summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/arch/x86/amd64.S96
-rw-r--r--lib/arch/x86/i386.S64
-rwxr-xr-xlib/copying.txt29
-rw-r--r--lib/core/hotcodereloading.nim41
-rw-r--r--lib/core/locks.nim90
-rw-r--r--lib/core/macrocache.nim246
-rw-r--r--lib/core/macros.nim1812
-rw-r--r--lib/core/rlocks.nim57
-rw-r--r--lib/core/typeinfo.nim723
-rw-r--r--[-rwxr-xr-x]lib/cycle.h0
-rw-r--r--lib/deprecated/pure/future.nim6
-rw-r--r--lib/deprecated/pure/mersenne.nim51
-rw-r--r--lib/deprecated/pure/ospaths.nim22
-rw-r--r--lib/deprecated/pure/oswalkdir.nim13
-rw-r--r--lib/deprecated/pure/sums.nim80
-rw-r--r--lib/deps.txt14
-rwxr-xr-xlib/devel/urls.nim181
-rwxr-xr-xlib/ecmas/dom.nim450
-rw-r--r--lib/experimental/diff.nim339
-rw-r--r--lib/genode/alloc.nim119
-rw-r--r--lib/genode/constructibles.nim21
-rw-r--r--lib/genode/entrypoints.nim22
-rw-r--r--lib/genode/env.nim29
-rw-r--r--lib/genode/signals.nim77
-rw-r--r--lib/genode_cpp/signals.h39
-rw-r--r--lib/genode_cpp/syslocks.h81
-rw-r--r--lib/genode_cpp/threads.h73
-rwxr-xr-xlib/impure/db_mysql.nim173
-rwxr-xr-xlib/impure/db_postgres.nim166
-rwxr-xr-xlib/impure/db_sqlite.nim178
-rwxr-xr-xlib/impure/dialogs.nim223
-rwxr-xr-xlib/impure/graphics.nim522
-rw-r--r--lib/impure/nre.nim751
-rw-r--r--lib/impure/nre/.gitignore9
-rw-r--r--lib/impure/nre/private/util.nim51
-rw-r--r--lib/impure/rdstdin.nim74
-rw-r--r--lib/impure/re.nim611
-rwxr-xr-xlib/impure/web.nim62
-rwxr-xr-xlib/impure/zipfiles.nim144
-rw-r--r--lib/js/asyncjs.nim269
-rw-r--r--lib/js/dom.nim1841
-rw-r--r--lib/js/jsconsole.nim125
-rw-r--r--lib/js/jscore.nim153
-rw-r--r--lib/js/jsffi.nim527
-rw-r--r--lib/js/jsre.nim97
-rwxr-xr-xlib/lgpl.txt502
-rw-r--r--[-rwxr-xr-x]lib/nimbase.h668
-rw-r--r--lib/nimhcr.nim671
-rw-r--r--lib/nimhcr.nim.cfg5
-rw-r--r--lib/nimrtl.nim40
-rw-r--r--lib/nimrtl.nim.cfg6
-rwxr-xr-xlib/oldwrappers/cairo/cairo.nim698
-rwxr-xr-xlib/oldwrappers/cairo/cairoft.nim36
-rwxr-xr-xlib/oldwrappers/cairo/cairowin32.nim36
-rwxr-xr-xlib/oldwrappers/cairo/cairoxlib.nim40
-rwxr-xr-xlib/oldwrappers/gtk/atk.nim1369
-rwxr-xr-xlib/oldwrappers/gtk/gdk2.nim3958
-rwxr-xr-xlib/oldwrappers/gtk/gdk2pixbuf.nim277
-rwxr-xr-xlib/oldwrappers/gtk/gdkglext.nim564
-rwxr-xr-xlib/oldwrappers/gtk/glib2.nim4503
-rwxr-xr-xlib/oldwrappers/gtk/gtk2.nim17271
-rwxr-xr-xlib/oldwrappers/gtk/gtkglext.nim50
-rwxr-xr-xlib/oldwrappers/gtk/gtkhtml.nim499
-rwxr-xr-xlib/oldwrappers/gtk/libglade2.nim118
-rwxr-xr-xlib/oldwrappers/gtk/pango.nim1208
-rwxr-xr-xlib/oldwrappers/gtk/pangoutils.nim46
-rwxr-xr-xlib/oldwrappers/iup.nim945
-rwxr-xr-xlib/oldwrappers/libcurl.nim644
-rwxr-xr-xlib/oldwrappers/lua/lauxlib.nim224
-rwxr-xr-xlib/oldwrappers/lua/lua.nim391
-rwxr-xr-xlib/oldwrappers/lua/lualib.nim73
-rwxr-xr-xlib/oldwrappers/mysql.nim1154
-rwxr-xr-xlib/oldwrappers/odbcsql.nim788
-rwxr-xr-xlib/oldwrappers/opengl/gl.nim1432
-rwxr-xr-xlib/oldwrappers/opengl/glext.nim4175
-rwxr-xr-xlib/oldwrappers/opengl/glu.nim311
-rwxr-xr-xlib/oldwrappers/opengl/glut.nim378
-rwxr-xr-xlib/oldwrappers/opengl/glx.nim148
-rwxr-xr-xlib/oldwrappers/opengl/wingl.nim348
-rwxr-xr-xlib/oldwrappers/pcre/pcre.nim279
-rwxr-xr-xlib/oldwrappers/pcre/pcre_all.c30072
-rwxr-xr-xlib/oldwrappers/postgres.nim386
-rwxr-xr-xlib/oldwrappers/python.nim1583
-rwxr-xr-xlib/oldwrappers/sdl/sdl.nim2522
-rwxr-xr-xlib/oldwrappers/sdl/sdl_gfx.nim421
-rwxr-xr-xlib/oldwrappers/sdl/sdl_image.nim227
-rwxr-xr-xlib/oldwrappers/sdl/sdl_mixer.nim737
-rwxr-xr-xlib/oldwrappers/sdl/sdl_mixer_nosmpeg.nim572
-rwxr-xr-xlib/oldwrappers/sdl/sdl_net.nim431
-rwxr-xr-xlib/oldwrappers/sdl/sdl_ttf.nim346
-rwxr-xr-xlib/oldwrappers/sdl/smpeg.nim319
-rwxr-xr-xlib/oldwrappers/sqlite3.nim376
-rwxr-xr-xlib/oldwrappers/tcl.nim857
-rwxr-xr-xlib/oldwrappers/x11/cursorfont.nim110
-rwxr-xr-xlib/oldwrappers/x11/keysym.nim1925
-rwxr-xr-xlib/oldwrappers/x11/x.nim399
-rwxr-xr-xlib/oldwrappers/x11/xatom.nim81
-rwxr-xr-xlib/oldwrappers/x11/xcms.nim396
-rwxr-xr-xlib/oldwrappers/x11/xf86dga.nim235
-rwxr-xr-xlib/oldwrappers/x11/xf86vmode.nim229
-rwxr-xr-xlib/oldwrappers/x11/xi.nim307
-rwxr-xr-xlib/oldwrappers/x11/xinerama.nim25
-rwxr-xr-xlib/oldwrappers/x11/xkb.nim2409
-rwxr-xr-xlib/oldwrappers/x11/xkblib.nim699
-rwxr-xr-xlib/oldwrappers/x11/xlib.nim2218
-rwxr-xr-xlib/oldwrappers/x11/xrandr.nim194
-rwxr-xr-xlib/oldwrappers/x11/xrender.nim231
-rwxr-xr-xlib/oldwrappers/x11/xresource.nim200
-rwxr-xr-xlib/oldwrappers/x11/xshm.nim77
-rwxr-xr-xlib/oldwrappers/x11/xutil.nim412
-rwxr-xr-xlib/oldwrappers/x11/xv.nim84
-rwxr-xr-xlib/oldwrappers/x11/xvlib.nim234
-rwxr-xr-xlib/oldwrappers/zip/libzip.nim241
-rwxr-xr-xlib/oldwrappers/zip/libzip_all.c4189
-rwxr-xr-xlib/oldwrappers/zip/zlib.nim181
-rwxr-xr-xlib/oldwrappers/zip/zzip.nim172
-rw-r--r--lib/packages/docutils/dochelpers.nim298
-rw-r--r--lib/packages/docutils/docutils.nimble.old7
-rw-r--r--lib/packages/docutils/highlite.nim1039
-rw-r--r--lib/packages/docutils/rst.nim3886
-rw-r--r--lib/packages/docutils/rstast.nim444
-rw-r--r--lib/packages/docutils/rstgen.nim1566
-rw-r--r--lib/packages/docutils/rstidx.nim141
-rw-r--r--lib/posix/epoll.nim99
-rw-r--r--lib/posix/inotify.nim111
-rw-r--r--lib/posix/kqueue.nim161
-rw-r--r--lib/posix/linux.nim39
-rw-r--r--[-rwxr-xr-x]lib/posix/posix.nim3001
-rw-r--r--lib/posix/posix_freertos_consts.nim506
-rw-r--r--lib/posix/posix_haiku.nim603
-rw-r--r--lib/posix/posix_linux_amd64.nim587
-rw-r--r--lib/posix/posix_linux_amd64_consts.nim730
-rw-r--r--lib/posix/posix_macos_amd64.nim620
-rw-r--r--lib/posix/posix_nintendoswitch.nim506
-rw-r--r--lib/posix/posix_nintendoswitch_consts.nim587
-rw-r--r--lib/posix/posix_openbsd_amd64.nim565
-rw-r--r--lib/posix/posix_other.nim706
-rw-r--r--lib/posix/posix_other_consts.nim757
-rw-r--r--lib/posix/posix_utils.nim133
-rw-r--r--lib/posix/termios.nim256
-rw-r--r--lib/pure/algorithm.nim917
-rw-r--r--lib/pure/async.nim9
-rw-r--r--lib/pure/asyncdispatch.nim2065
-rw-r--r--lib/pure/asyncdispatch.nim.cfg3
-rw-r--r--lib/pure/asyncfile.nim537
-rw-r--r--lib/pure/asyncfutures.nim527
-rw-r--r--lib/pure/asynchttpserver.nim440
-rw-r--r--lib/pure/asyncmacro.nim383
-rw-r--r--lib/pure/asyncnet.nim1004
-rw-r--r--lib/pure/asyncstreams.nim147
-rw-r--r--lib/pure/base64.nim273
-rw-r--r--lib/pure/bitops.nim883
-rw-r--r--[-rwxr-xr-x]lib/pure/browsers.nim115
-rw-r--r--[-rwxr-xr-x]lib/pure/cgi.nim456
-rw-r--r--lib/pure/collections/chains.nim44
-rw-r--r--lib/pure/collections/critbits.nim537
-rw-r--r--lib/pure/collections/deques.nim480
-rw-r--r--lib/pure/collections/hashcommon.nim76
-rw-r--r--lib/pure/collections/heapqueue.nim266
-rw-r--r--lib/pure/collections/intsets.nim23
-rw-r--r--lib/pure/collections/lists.nim1015
-rw-r--r--lib/pure/collections/rtarrays.nim37
-rw-r--r--lib/pure/collections/sequtils.nim1162
-rw-r--r--lib/pure/collections/setimpl.nim156
-rw-r--r--lib/pure/collections/sets.nim930
-rw-r--r--lib/pure/collections/sharedlist.nim105
-rw-r--r--lib/pure/collections/sharedtables.nim252
-rw-r--r--lib/pure/collections/tableimpl.nim231
-rw-r--r--lib/pure/collections/tables.nim2972
-rw-r--r--[-rwxr-xr-x]lib/pure/colors.nim823
-rw-r--r--[-rwxr-xr-x]lib/pure/complex.nim483
-rw-r--r--lib/pure/concurrency/atomics.nim433
-rw-r--r--lib/pure/concurrency/cpuinfo.nim110
-rw-r--r--lib/pure/concurrency/cpuload.nim106
-rw-r--r--lib/pure/concurrency/threadpool.nim606
-rw-r--r--lib/pure/concurrency/threadpool.nim.cfg1
-rw-r--r--lib/pure/cookies.nim81
-rw-r--r--lib/pure/coro.nim345
-rw-r--r--lib/pure/coro.nimcfg1
-rw-r--r--lib/pure/cstrutils.nim122
-rw-r--r--lib/pure/distros.nim279
-rw-r--r--[-rwxr-xr-x]lib/pure/dynlib.nim191
-rw-r--r--lib/pure/encodings.nim511
-rw-r--r--lib/pure/endians.nim148
-rw-r--r--lib/pure/fenv.nim182
-rw-r--r--[-rwxr-xr-x]lib/pure/hashes.nim856
-rwxr-xr-xlib/pure/hashtabs.nim163
-rw-r--r--lib/pure/htmlgen.nim812
-rw-r--r--[-rwxr-xr-x]lib/pure/htmlparser.nim2263
-rw-r--r--[-rwxr-xr-x]lib/pure/httpclient.nim1596
-rw-r--r--lib/pure/httpcore.nim368
-rwxr-xr-xlib/pure/httpserver.nim259
-rw-r--r--lib/pure/includes/unicode_ranges.nim2007
-rw-r--r--lib/pure/ioselects/ioselectors_epoll.nim534
-rw-r--r--lib/pure/ioselects/ioselectors_kqueue.nim639
-rw-r--r--lib/pure/ioselects/ioselectors_poll.nim324
-rw-r--r--lib/pure/ioselects/ioselectors_select.nim454
-rw-r--r--lib/pure/json.nim1394
-rw-r--r--lib/pure/lenientops.nim58
-rw-r--r--[-rwxr-xr-x]lib/pure/lexbase.nim151
-rw-r--r--[-rwxr-xr-x]lib/pure/logging.nim983
-rwxr-xr-xlib/pure/macros.nim250
-rw-r--r--lib/pure/marshal.nim367
-rw-r--r--[-rwxr-xr-x]lib/pure/math.nim1471
-rw-r--r--[-rwxr-xr-x]lib/pure/md5.nim500
-rw-r--r--lib/pure/memfiles.nim568
-rw-r--r--lib/pure/mimetypes.nim1071
-rw-r--r--lib/pure/nativesockets.nim870
-rw-r--r--lib/pure/net.nim2175
-rw-r--r--lib/pure/nimprof.nim233
-rw-r--r--lib/pure/nimprof.nim.cfg1
-rw-r--r--lib/pure/oids.nim99
-rw-r--r--lib/pure/options.nim381
-rw-r--r--[-rwxr-xr-x]lib/pure/os.nim2023
-rw-r--r--[-rwxr-xr-x]lib/pure/osproc.nim1884
-rw-r--r--[-rwxr-xr-x]lib/pure/parsecfg.nim799
-rw-r--r--[-rwxr-xr-x]lib/pure/parsecsv.nim393
-rw-r--r--lib/pure/parsejson.nim522
-rw-r--r--[-rwxr-xr-x]lib/pure/parseopt.nim565
-rw-r--r--[-rwxr-xr-x]lib/pure/parsesql.nim1256
-rwxr-xr-xlib/pure/parseurl.nim95
-rw-r--r--[-rwxr-xr-x]lib/pure/parseutils.nim1196
-rw-r--r--[-rwxr-xr-x]lib/pure/parsexml.nim769
-rw-r--r--lib/pure/pathnorm.nim121
-rw-r--r--[-rwxr-xr-x]lib/pure/pegs.nim2177
-rw-r--r--lib/pure/prelude.nim28
-rw-r--r--lib/pure/random.nim766
-rw-r--r--lib/pure/rationals.nim340
-rwxr-xr-xlib/pure/re.nim340
-rwxr-xr-xlib/pure/regexprs.nim179
-rw-r--r--lib/pure/reservedmem.nim229
-rw-r--r--[-rwxr-xr-x]lib/pure/ropes.nim448
-rw-r--r--lib/pure/segfaults.nim88
-rw-r--r--lib/pure/selectors.nim375
-rwxr-xr-xlib/pure/sockets.nim416
-rw-r--r--lib/pure/ssl_certs.nim172
-rw-r--r--lib/pure/ssl_config.nim51
-rw-r--r--lib/pure/stats.nim335
-rw-r--r--[-rwxr-xr-x]lib/pure/streams.nim1610
-rw-r--r--lib/pure/streamwrapper.nim121
-rw-r--r--lib/pure/strformat.nim790
-rw-r--r--lib/pure/strmisc.nim83
-rw-r--r--lib/pure/strscans.nim696
-rw-r--r--[-rwxr-xr-x]lib/pure/strtabs.nim434
-rw-r--r--[-rwxr-xr-x]lib/pure/strutils.nim3584
-rw-r--r--lib/pure/sugar.nim429
-rw-r--r--[-rwxr-xr-x]lib/pure/terminal.nim1339
-rw-r--r--[-rwxr-xr-x]lib/pure/times.nim3164
-rw-r--r--lib/pure/typetraits.nim376
-rw-r--r--[-rwxr-xr-x]lib/pure/unicode.nim2507
-rw-r--r--[-rwxr-xr-x]lib/pure/unidecode/gen.py34
-rw-r--r--[-rwxr-xr-x]lib/pure/unidecode/unidecode.dat841
-rw-r--r--[-rwxr-xr-x]lib/pure/unidecode/unidecode.nim91
-rw-r--r--lib/pure/unittest.nim789
-rw-r--r--lib/pure/uri.nim572
-rwxr-xr-xlib/pure/variants.nim181
-rw-r--r--lib/pure/volatile.nim34
-rwxr-xr-xlib/pure/xmldom.nim1093
-rwxr-xr-xlib/pure/xmldomparser.nim168
-rwxr-xr-xlib/pure/xmlgen.nim411
-rw-r--r--[-rwxr-xr-x]lib/pure/xmlparser.nim138
-rw-r--r--[-rwxr-xr-x]lib/pure/xmltree.nim984
-rwxr-xr-xlib/pure/yamllexer.nim355
-rw-r--r--lib/std/appdirs.nim94
-rw-r--r--lib/std/assertions.nim122
-rw-r--r--lib/std/cmdline.nim313
-rw-r--r--lib/std/compilesettings.nim66
-rw-r--r--lib/std/decls.nim31
-rw-r--r--lib/std/dirs.nim135
-rw-r--r--lib/std/editdistance.nim266
-rw-r--r--lib/std/effecttraits.nim63
-rw-r--r--lib/std/enumerate.nim70
-rw-r--r--lib/std/enumutils.nim202
-rw-r--r--lib/std/envvars.nim221
-rw-r--r--lib/std/exitprocs.nim87
-rw-r--r--lib/std/files.nim46
-rw-r--r--lib/std/formatfloat.nim143
-rw-r--r--lib/std/genasts.nim89
-rw-r--r--lib/std/importutils.nim44
-rw-r--r--lib/std/isolation.nim49
-rw-r--r--lib/std/jsbigints.nim228
-rw-r--r--lib/std/jsfetch.nim202
-rw-r--r--lib/std/jsformdata.nim69
-rw-r--r--lib/std/jsheaders.nim83
-rw-r--r--lib/std/jsonutils.nim493
-rw-r--r--lib/std/logic.nim10
-rw-r--r--lib/std/monotimes.nim160
-rw-r--r--lib/std/objectdollar.nim13
-rw-r--r--lib/std/oserrors.nim117
-rw-r--r--lib/std/outparams.nim38
-rw-r--r--lib/std/packedsets.nim601
-rw-r--r--lib/std/paths.nim302
-rw-r--r--lib/std/private/asciitables.nim83
-rw-r--r--lib/std/private/bitops_utils.nim22
-rw-r--r--lib/std/private/decode_helpers.nim42
-rw-r--r--lib/std/private/digitsutils.nim116
-rw-r--r--lib/std/private/dragonbox.nim1325
-rw-r--r--lib/std/private/gitutils.nim74
-rw-r--r--lib/std/private/globs.nim70
-rw-r--r--lib/std/private/jsutils.nim96
-rw-r--r--lib/std/private/miscdollars.nim39
-rw-r--r--lib/std/private/ntpath.nim61
-rw-r--r--lib/std/private/osappdirs.nim176
-rw-r--r--lib/std/private/oscommon.nim186
-rw-r--r--lib/std/private/osdirs.nim570
-rw-r--r--lib/std/private/osfiles.nim416
-rw-r--r--lib/std/private/ospaths2.nim1030
-rw-r--r--lib/std/private/osseps.nim113
-rw-r--r--lib/std/private/ossymlinks.nim78
-rw-r--r--lib/std/private/schubfach.nim436
-rw-r--r--lib/std/private/since.nim33
-rw-r--r--lib/std/private/strimpl.nim113
-rw-r--r--lib/std/private/syslocks.nim234
-rw-r--r--lib/std/private/threadtypes.nim176
-rw-r--r--lib/std/private/underscored_calls.nim56
-rw-r--r--lib/std/private/win_getsysteminfo.nim15
-rw-r--r--lib/std/private/win_setenv.nim106
-rw-r--r--lib/std/setutils.nim77
-rw-r--r--lib/std/sha1.nim287
-rw-r--r--lib/std/socketstreams.nim182
-rw-r--r--lib/std/stackframes.nim30
-rw-r--r--lib/std/staticos.nim13
-rw-r--r--lib/std/strbasics.nim119
-rw-r--r--lib/std/symlinks.nim33
-rw-r--r--lib/std/syncio.nim942
-rw-r--r--lib/std/sysatomics.nim376
-rw-r--r--lib/std/sysrand.nim326
-rw-r--r--lib/std/tasks.nim312
-rw-r--r--lib/std/tempfiles.nim192
-rw-r--r--lib/std/time_t.nim23
-rw-r--r--lib/std/typedthreads.nim305
-rw-r--r--lib/std/varints.nim121
-rw-r--r--lib/std/vmutils.nim11
-rw-r--r--lib/std/widestrs.nim239
-rw-r--r--lib/std/with.nim48
-rw-r--r--lib/std/wordwrap.nim74
-rw-r--r--lib/std/wrapnils.nim193
-rw-r--r--lib/stdlib.nimble5
-rw-r--r--[-rwxr-xr-x]lib/system.nim4267
-rw-r--r--[-rwxr-xr-x]lib/system/alloc.nim1633
-rw-r--r--[-rwxr-xr-x]lib/system/ansi_c.nim304
-rw-r--r--lib/system/arc.nim267
-rwxr-xr-xlib/system/arithm.nim334
-rw-r--r--lib/system/arithmetics.nim405
-rw-r--r--[-rwxr-xr-x]lib/system/assign.nim318
-rw-r--r--lib/system/avltree.nim97
-rw-r--r--lib/system/basic_types.nim94
-rw-r--r--lib/system/bitmasks.nim39
-rw-r--r--lib/system/cellseqs_v1.nim46
-rw-r--r--lib/system/cellseqs_v2.nim53
-rw-r--r--[-rwxr-xr-x]lib/system/cellsets.nim248
-rw-r--r--lib/system/cgprocs.nim10
-rw-r--r--lib/system/channels_builtin.nim459
-rw-r--r--lib/system/chcks.nim161
-rwxr-xr-xlib/system/cntbits.nim12
-rw-r--r--lib/system/comparisons.nim337
-rw-r--r--lib/system/compilation.nim209
-rw-r--r--lib/system/coro_detection.nim20
-rw-r--r--lib/system/countbits_impl.nim93
-rw-r--r--lib/system/ctypes.nim84
-rw-r--r--lib/system/cyclebreaker.nim184
-rwxr-xr-xlib/system/debugger.nim500
-rw-r--r--lib/system/deepcopy.nim206
-rw-r--r--lib/system/dollars.nim147
-rw-r--r--[-rwxr-xr-x]lib/system/dyncalls.nim225
-rwxr-xr-xlib/system/ecmasys.nim531
-rw-r--r--lib/system/embedded.nim61
-rw-r--r--lib/system/exceptions.nim122
-rw-r--r--[-rwxr-xr-x]lib/system/excpt.nim893
-rw-r--r--lib/system/fatal.nim58
-rw-r--r--lib/system/formatfloat.nim6
-rw-r--r--[-rwxr-xr-x]lib/system/gc.nim1286
-rw-r--r--lib/system/gc_common.nim482
-rw-r--r--lib/system/gc_hooks.nim53
-rw-r--r--lib/system/gc_interface.nim100
-rw-r--r--lib/system/gc_ms.nim526
-rw-r--r--lib/system/gc_regions.nim442
-rw-r--r--[-rwxr-xr-x]lib/system/hti.nim115
-rw-r--r--lib/system/inclrtl.nim50
-rw-r--r--lib/system/indexerrors.nim15
-rw-r--r--lib/system/indices.nim164
-rw-r--r--lib/system/integerops.nim132
-rw-r--r--lib/system/iterators.nim353
-rw-r--r--lib/system/iterators_1.nim180
-rw-r--r--lib/system/jssys.nim768
-rw-r--r--lib/system/memalloc.nim449
-rw-r--r--lib/system/memory.nim55
-rw-r--r--lib/system/memtracker.nim106
-rwxr-xr-xlib/system/mm.nim189
-rw-r--r--lib/system/mm/boehm.nim140
-rw-r--r--lib/system/mm/go.nim153
-rw-r--r--lib/system/mm/malloc.nim97
-rw-r--r--lib/system/mm/none.nim46
-rw-r--r--lib/system/mmdisp.nim120
-rw-r--r--lib/system/nimscript.nim452
-rw-r--r--lib/system/orc.nim543
-rw-r--r--lib/system/osalloc.nim218
-rw-r--r--lib/system/platforms.nim105
-rw-r--r--[-rwxr-xr-x]lib/system/profiler.nim142
-rw-r--r--lib/system/rawquits.nim27
-rw-r--r--[-rwxr-xr-x]lib/system/repr.nim426
-rw-r--r--lib/system/repr_impl.nim15
-rw-r--r--lib/system/repr_v2.nim194
-rw-r--r--lib/system/reprjs.nim251
-rw-r--r--lib/system/seqs_v2.nim227
-rw-r--r--lib/system/seqs_v2_reimpl.nim24
-rw-r--r--lib/system/setops.nim89
-rw-r--r--[-rwxr-xr-x]lib/system/sets.nim32
-rw-r--r--lib/system/stacktraces.nim83
-rw-r--r--lib/system/strmantle.nim263
-rw-r--r--lib/system/strs_v2.nim224
-rwxr-xr-xlib/system/sysio.nim187
-rw-r--r--[-rwxr-xr-x]lib/system/sysstr.nim488
-rw-r--r--lib/system/threadids.nim103
-rw-r--r--lib/system/threadimpl.nim111
-rw-r--r--lib/system/threadlocalstorage.nim125
-rw-r--r--lib/system/timers.nim99
-rw-r--r--lib/system_overview.rst177
-rwxr-xr-xlib/ucmaps/8859-1.txt303
-rwxr-xr-xlib/ucmaps/8859-10.txt303
-rwxr-xr-xlib/ucmaps/8859-13.txt299
-rwxr-xr-xlib/ucmaps/8859-14.txt301
-rwxr-xr-xlib/ucmaps/8859-15.txt303
-rwxr-xr-xlib/ucmaps/8859-2.txt303
-rwxr-xr-xlib/ucmaps/8859-3.txt296
-rwxr-xr-xlib/ucmaps/8859-4.txt303
-rwxr-xr-xlib/ucmaps/8859-5.txt303
-rwxr-xr-xlib/ucmaps/8859-6.txt260
-rwxr-xr-xlib/ucmaps/8859-7.txt302
-rwxr-xr-xlib/ucmaps/8859-8.txt270
-rwxr-xr-xlib/ucmaps/8859-9.txt307
-rwxr-xr-xlib/ucmaps/cp1250.txt274
-rwxr-xr-xlib/ucmaps/cp1251.txt274
-rwxr-xr-xlib/ucmaps/cp1252.txt274
-rwxr-xr-xlib/ucmaps/cp1253.txt274
-rwxr-xr-xlib/ucmaps/cp1254.txt274
-rwxr-xr-xlib/ucmaps/cp1255.txt274
-rwxr-xr-xlib/ucmaps/cp1256.txt274
-rwxr-xr-xlib/ucmaps/cp1257.txt274
-rwxr-xr-xlib/ucmaps/cp1258.txt274
-rwxr-xr-xlib/ucmaps/cp437.txt273
-rwxr-xr-xlib/ucmaps/cp737.txt273
-rwxr-xr-xlib/ucmaps/cp775.txt274
-rwxr-xr-xlib/ucmaps/cp850.txt273
-rwxr-xr-xlib/ucmaps/cp852.txt273
-rwxr-xr-xlib/ucmaps/cp855.txt274
-rwxr-xr-xlib/ucmaps/cp856.txt303
-rwxr-xr-xlib/ucmaps/cp857.txt274
-rwxr-xr-xlib/ucmaps/cp860.txt274
-rwxr-xr-xlib/ucmaps/cp861.txt274
-rwxr-xr-xlib/ucmaps/cp862.txt274
-rwxr-xr-xlib/ucmaps/cp863.txt274
-rwxr-xr-xlib/ucmaps/cp864.txt274
-rwxr-xr-xlib/ucmaps/cp865.txt274
-rwxr-xr-xlib/ucmaps/cp866.txt274
-rwxr-xr-xlib/ucmaps/cp869.txt274
-rwxr-xr-xlib/ucmaps/cp874.txt274
-rwxr-xr-xlib/ucmaps/cp932.txt7998
-rwxr-xr-xlib/windows/mmsystem.nim2655
-rwxr-xr-xlib/windows/nb30.nim232
-rwxr-xr-xlib/windows/ole2.nim208
-rw-r--r--lib/windows/registry.nim82
-rwxr-xr-xlib/windows/shellapi.nim863
-rwxr-xr-xlib/windows/shfolder.nim93
-rwxr-xr-xlib/windows/windows.nim23776
-rw-r--r--[-rwxr-xr-x]lib/windows/winlean.nim1128
-rwxr-xr-xlib/wrappers/cairo/cairo.nim737
-rwxr-xr-xlib/wrappers/gtk/gdk2.nim3868
-rwxr-xr-xlib/wrappers/gtk/gdk2pixbuf.nim271
-rwxr-xr-xlib/wrappers/gtk/glib2.nim4498
-rwxr-xr-xlib/wrappers/gtk/gtk2.nim16873
-rwxr-xr-xlib/wrappers/gtk/libglade2.nim108
-rwxr-xr-xlib/wrappers/gtk/pango.nim1157
-rwxr-xr-xlib/wrappers/iup.nim945
-rw-r--r--lib/wrappers/linenoise/LICENSE.txt25
-rw-r--r--lib/wrappers/linenoise/README.markdown52
-rw-r--r--lib/wrappers/linenoise/linenoise.c1207
-rw-r--r--lib/wrappers/linenoise/linenoise.h84
-rw-r--r--lib/wrappers/linenoise/linenoise.nim72
-rwxr-xr-xlib/wrappers/odbcsql.nim788
-rw-r--r--lib/wrappers/openssl.nim909
-rw-r--r--lib/wrappers/pcre.nim473
-rwxr-xr-xlib/wrappers/pcre/pcre.nim259
-rwxr-xr-xlib/wrappers/pcre/pcre_all.c30072
-rwxr-xr-xlib/wrappers/postgres.nim350
-rwxr-xr-xlib/wrappers/python.nim1583
-rwxr-xr-xlib/wrappers/sdl/sdl.nim2551
-rwxr-xr-xlib/wrappers/sdl/sdl_gfx.nim452
-rwxr-xr-xlib/wrappers/sdl/sdl_image.nim232
-rwxr-xr-xlib/wrappers/sdl/sdl_mixer.nim484
-rwxr-xr-xlib/wrappers/sdl/sdl_mixer_nosmpeg.nim351
-rwxr-xr-xlib/wrappers/sdl/sdl_net.nim427
-rwxr-xr-xlib/wrappers/sdl/sdl_ttf.nim343
-rwxr-xr-xlib/wrappers/sdl/smpeg.nim335
-rw-r--r--[-rwxr-xr-x]lib/wrappers/tinyc.nim59
-rwxr-xr-xlib/wrappers/x11/cursorfont.nim110
-rwxr-xr-xlib/wrappers/x11/keysym.nim1925
-rwxr-xr-xlib/wrappers/x11/x.nim399
-rwxr-xr-xlib/wrappers/x11/xatom.nim81
-rwxr-xr-xlib/wrappers/x11/xcms.nim396
-rwxr-xr-xlib/wrappers/x11/xf86dga.nim235
-rwxr-xr-xlib/wrappers/x11/xf86vmode.nim229
-rwxr-xr-xlib/wrappers/x11/xi.nim307
-rwxr-xr-xlib/wrappers/x11/xinerama.nim25
-rwxr-xr-xlib/wrappers/x11/xkb.nim2409
-rwxr-xr-xlib/wrappers/x11/xkblib.nim699
-rwxr-xr-xlib/wrappers/x11/xlib.nim2218
-rwxr-xr-xlib/wrappers/x11/xrandr.nim194
-rwxr-xr-xlib/wrappers/x11/xrender.nim231
-rwxr-xr-xlib/wrappers/x11/xresource.nim200
-rwxr-xr-xlib/wrappers/x11/xshm.nim77
-rwxr-xr-xlib/wrappers/x11/xutil.nim412
-rwxr-xr-xlib/wrappers/x11/xv.nim84
-rwxr-xr-xlib/wrappers/x11/xvlib.nim234
-rwxr-xr-xlib/wrappers/zip/libzip.nim241
-rwxr-xr-xlib/wrappers/zip/libzip_all.c4189
-rwxr-xr-xlib/wrappers/zip/zlib.nim181
-rwxr-xr-xlib/wrappers/zip/zzip.nim172
518 files changed, 125007 insertions, 248579 deletions
diff --git a/lib/arch/x86/amd64.S b/lib/arch/x86/amd64.S
new file mode 100644
index 000000000..47a26f627
--- /dev/null
+++ b/lib/arch/x86/amd64.S
@@ -0,0 +1,96 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Rokas Kupstys
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+# Partially based on code from musl libc Copyright © 2005-2014 Rich Felker, et al.
+
+.globl narch_coroExecWithStack
+.globl narch_setjmp
+.globl narch_longjmp
+.text
+
+
+# SysV ABI - first argument is rdi.
+# MS ABI   - first argument is rcx.
+#if defined(__MINGW32__) || defined(__MINGW64__)
+  #define REG_ARG1 rcx
+  #define REG_ARG2 rdx
+#else
+  #define REG_ARG1 rdi
+  #define REG_ARG2 rsi
+#endif
+
+
+narch_coroExecWithStack:
+  mov  %REG_ARG2, %rsp        # swap stack with one passed to func
+  sub  $0x30, %rsp            # shadow space (for ms ABI) 0x20 + 0x10 for possible misalignment
+  and  $-0x10, %rsp           # 16-byte stack alignment
+  call *%REG_ARG1
+
+
+narch_setjmp:
+  add   $0x10, %REG_ARG1      # 16-byte alignment
+  and   $-0x10, %REG_ARG1
+  mov   %rbx, 0x00(%REG_ARG1) # jmp_buf, move registers onto it
+  mov   %rbp, 0x08(%REG_ARG1)
+  mov   %r12, 0x10(%REG_ARG1)
+  mov   %r13, 0x18(%REG_ARG1)
+  mov   %r14, 0x20(%REG_ARG1)
+  mov   %r15, 0x28(%REG_ARG1)
+  lea   0x08(%rsp), %rdx      # this is our rsp WITHOUT current ret addr
+  mov   %rdx, 0x30(%REG_ARG1)
+  mov   (%rsp), %rdx          # save return addr ptr for new rip
+  mov   %rdx, 0x38(%REG_ARG1)
+  mov   %rsi, 0x40(%REG_ARG1)
+  mov   %rdi, 0x48(%REG_ARG1)
+#if defined(__MINGW32__) || defined(__MINGW64__)
+  movaps %xmm6,  0x50(%REG_ARG1)
+  movaps %xmm7,  0x60(%REG_ARG1)
+  movaps %xmm8,  0x70(%REG_ARG1)
+  movaps %xmm9,  0x80(%REG_ARG1)
+  movaps %xmm10, 0x90(%REG_ARG1)
+  movaps %xmm11, 0xA0(%REG_ARG1)
+  movaps %xmm12, 0xB0(%REG_ARG1)
+  movaps %xmm13, 0xC0(%REG_ARG1)
+  movaps %xmm14, 0xD0(%REG_ARG1)
+  movaps %xmm15, 0xE0(%REG_ARG1)
+#endif
+  xor   %rax, %rax            # always return 0
+  ret
+
+
+narch_longjmp:
+  add   $0x10, %REG_ARG1      # 16-byte alignment
+  and   $-0x10, %REG_ARG1     #
+  mov   %REG_ARG2, %rax       # val will be longjmp return
+  test  %rax, %rax
+  jnz   narch_longjmp_1
+  inc   %rax                  # if val==0, val=1 per longjmp semantics
+narch_longjmp_1:
+  mov   0x00(%REG_ARG1), %rbx # jmp_buf, restore regs from it
+  mov   0x08(%REG_ARG1), %rbp
+  mov   0x10(%REG_ARG1), %r12
+  mov   0x18(%REG_ARG1), %r13
+  mov   0x20(%REG_ARG1), %r14
+  mov   0x28(%REG_ARG1), %r15
+  mov   0x30(%REG_ARG1), %rsp # this ends up being the stack pointer
+  mov   0x38(%REG_ARG1), %rdx # this is the instruction pointer
+  mov   0x40(%REG_ARG1), %rsi
+  mov   0x48(%REG_ARG1), %rdi
+#if defined(__MINGW32__) || defined(__MINGW64__)
+  movaps 0x50(%REG_ARG1), %xmm6
+  movaps 0x60(%REG_ARG1), %xmm7
+  movaps 0x70(%REG_ARG1), %xmm8
+  movaps 0x80(%REG_ARG1), %xmm9
+  movaps 0x90(%REG_ARG1), %xmm10
+  movaps 0xA0(%REG_ARG1), %xmm11
+  movaps 0xB0(%REG_ARG1), %xmm12
+  movaps 0xC0(%REG_ARG1), %xmm13
+  movaps 0xD0(%REG_ARG1), %xmm14
+  movaps 0xE0(%REG_ARG1), %xmm15
+#endif
+  jmp  *%rdx                  # goto saved address without altering rsp
diff --git a/lib/arch/x86/i386.S b/lib/arch/x86/i386.S
new file mode 100644
index 000000000..d7de4a4c3
--- /dev/null
+++ b/lib/arch/x86/i386.S
@@ -0,0 +1,64 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Rokas Kupstys
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+# Partially based on code from musl libc Copyright © 2005-2014 Rich Felker, et al.
+
+.globl narch_coroExecWithStack
+.globl narch_setjmp
+.globl narch_longjmp
+#if defined(__MINGW32__) || defined(__MINGW64__)
+.globl @narch_coroExecWithStack@8
+.globl @narch_setjmp@4
+.globl @narch_longjmp@8
+#endif
+.text
+
+
+#if defined(__MINGW32__) || defined(__MINGW64__)
+@narch_coroExecWithStack@8:
+#endif
+narch_coroExecWithStack:
+  mov  %edx, %esp            # swap stack with one passed to func
+  sub  $0x10, %esp           # 16-byte alignment
+  and  $-0x10, %esp          #
+  sub  $4, %esp              # Simulate misalignment caused by return addr
+  jmp *%ecx
+
+
+#if defined(__MINGW32__) || defined(__MINGW64__)
+@narch_setjmp@4:
+#endif
+narch_setjmp:
+    mov  %ebx, (%ecx)
+    mov  %esi, 0x04(%ecx)
+    mov  %edi, 0x08(%ecx)
+    mov  %ebp, 0x0C(%ecx)
+    lea  0x04(%esp), %eax
+    mov  %eax, 0x10(%ecx)
+    mov  (%esp), %eax
+    mov  %eax, 0x14(%ecx)
+    xor  %eax, %eax
+    ret
+
+
+#if defined(__MINGW32__) || defined(__MINGW64__)
+@narch_longjmp@8:
+#endif
+narch_longjmp:
+    mov  %edx, %eax
+    test %eax, %eax
+    jnz  narch_longjmp_1
+    inc  %eax
+narch_longjmp_1:
+    mov  (%ecx), %ebx
+    mov  0x04(%ecx), %esi
+    mov  0x08(%ecx), %edi
+    mov  0x0C(%ecx), %ebp
+    mov  0x10(%ecx), %esp
+    mov  0x14(%ecx), %edx
+    jmp *%edx
diff --git a/lib/copying.txt b/lib/copying.txt
deleted file mode 100755
index 6fcdca1df..000000000
--- a/lib/copying.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-=======================================================

-                  The Nimrod Runtime Library

-             Copyright (C) 2004-2010  Andreas Rumpf

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

-

-This is the file copying.txt, it applies to the Nimrod Run-Time Library

-(lib) and base packages (base) distributed by members of the Nimrod

-Development Team.

-

-The source code of the Nimrod Runtime Libraries and packages are

-distributed under the Library GNU General Public License

-(see the file lgpl.txt) with the following modification:

-

-As a special exception, the copyright holders of this library give you

-permission to link this library with independent modules to produce an

-executable, regardless of the license terms of these independent modules,

-and to copy and distribute the resulting executable under terms of your choice,

-provided that you also meet, for each linked independent module, the terms

-and conditions of the license of that module. An independent module is a module

-which is not derived from or based on this library. If you modify this

-library, you may extend this exception to your version of the library, but

-you are not obligated to do so. If you do not wish to do so, delete this

-exception statement from your version.

-

-If you didn't receive a copy of the file lgpl.txt, contact:

-      Free Software Foundation

-      675 Mass Ave

-      Cambridge, MA  02139

-      USA

diff --git a/lib/core/hotcodereloading.nim b/lib/core/hotcodereloading.nim
new file mode 100644
index 000000000..3a876885c
--- /dev/null
+++ b/lib/core/hotcodereloading.nim
@@ -0,0 +1,41 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Unstable API.
+
+when defined(hotcodereloading):
+  import
+    std/macros
+
+  template beforeCodeReload*(body: untyped) =
+    hcrAddEventHandler(true, proc = body) {.executeOnReload.}
+
+  template afterCodeReload*(body: untyped) =
+    hcrAddEventHandler(false, proc = body) {.executeOnReload.}
+
+  macro hasModuleChanged*(module: typed): untyped =
+    if module.kind != nnkSym or module.symKind != nskModule:
+      error "hasModuleChanged expects a module symbol", module
+    return newCall(bindSym"hcrHasModuleChanged", newLit(module.signatureHash))
+
+  proc hasAnyModuleChanged*(): bool = hcrReloadNeeded()
+
+  when not defined(js):
+    template performCodeReload* =
+      when isMainModule:
+        {.warning: "Code residing in the main module will not be changed from calling a code-reload".}
+      hcrPerformCodeReload()
+  else:
+    template performCodeReload* = discard
+else:
+  template beforeCodeReload*(body: untyped) = discard
+  template afterCodeReload*(body: untyped) = discard
+  template hasModuleChanged*(module: typed): bool = false
+  proc hasAnyModuleChanged*(): bool = false
+  template performCodeReload*() = discard
diff --git a/lib/core/locks.nim b/lib/core/locks.nim
new file mode 100644
index 000000000..523727479
--- /dev/null
+++ b/lib/core/locks.nim
@@ -0,0 +1,90 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains Nim's support for locks and condition vars.
+
+#[
+for js, for now we treat locks as noop's to avoid pushing `when defined(js)`
+in client code that uses locks.
+]#
+
+when not compileOption("threads") and not defined(nimdoc):
+  when false: # fix #12330
+    {.error: "Locks requires --threads:on option.".}
+
+import std/private/syslocks
+
+type
+  Lock* = SysLock ## Nim lock; whether this is re-entrant
+                  ## or not is unspecified!
+  Cond* = SysCond ## Nim condition variable
+
+{.push stackTrace: off.}
+
+
+proc `$`*(lock: Lock): string =
+  # workaround bug #14873
+  result = "()"
+
+proc initLock*(lock: var Lock) {.inline.} =
+  ## Initializes the given lock.
+  when not defined(js):
+    initSysLock(lock)
+
+proc deinitLock*(lock: Lock) {.inline.} =
+  ## Frees the resources associated with the lock.
+  deinitSys(lock)
+
+proc tryAcquire*(lock: var Lock): bool {.inline.} =
+  ## Tries to acquire the given lock. Returns `true` on success.
+  result = tryAcquireSys(lock)
+
+proc acquire*(lock: var Lock) {.inline.} =
+  ## Acquires the given lock.
+  when not defined(js):
+    acquireSys(lock)
+
+proc release*(lock: var Lock) {.inline.} =
+  ## Releases the given lock.
+  when not defined(js):
+    releaseSys(lock)
+
+
+proc initCond*(cond: var Cond) {.inline.} =
+  ## Initializes the given condition variable.
+  initSysCond(cond)
+
+proc deinitCond*(cond: Cond) {.inline.} =
+  ## Frees the resources associated with the condition variable.
+  deinitSysCond(cond)
+
+proc wait*(cond: var Cond, lock: var Lock) {.inline.} =
+  ## Waits on the condition variable `cond`.
+  waitSysCond(cond, lock)
+
+proc signal*(cond: var Cond) {.inline.} =
+  ## Sends a signal to the condition variable `cond`.
+  signalSysCond(cond)
+
+proc broadcast*(cond: var Cond) {.inline.} =
+  ## Unblocks all threads currently blocked on the
+  ## specified condition variable `cond`.
+  broadcastSysCond(cond)
+
+template withLock*(a: Lock, body: untyped) =
+  ## Acquires the given lock, executes the statements in body and
+  ## releases the lock after the statements finish executing.
+  acquire(a)
+  {.locks: [a].}:
+    try:
+      body
+    finally:
+      release(a)
+
+{.pop.}
diff --git a/lib/core/macrocache.nim b/lib/core/macrocache.nim
new file mode 100644
index 000000000..39999fa11
--- /dev/null
+++ b/lib/core/macrocache.nim
@@ -0,0 +1,246 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module provides an API for macros to collect compile-time information
+## across module boundaries. It should be used instead of global `{.compileTime.}`
+## variables as those break incremental compilation.
+##
+## The main feature of this module is that if you create `CacheTable`s or
+## any other `Cache` types with the same name in different modules, their
+## content will be shared, meaning that you can fill a `CacheTable` in
+## one module, and iterate over its contents in another.
+
+runnableExamples:
+  import std/macros
+
+  const mcTable = CacheTable"myTable"
+  const mcSeq = CacheSeq"mySeq"
+  const mcCounter = CacheCounter"myCounter"
+
+  static:
+    # add new key "val" with the value `myval`
+    let myval = newLit("hello ic")
+    mcTable["val"] = myval
+    assert mcTable["val"].kind == nnkStrLit
+
+  # Can access the same cache from different static contexts
+  # All the information is retained
+  static:
+    # get value from `mcTable` and add it to `mcSeq`
+    mcSeq.add(mcTable["val"])
+    assert mcSeq.len == 1
+
+  static:
+    assert mcSeq[0].strVal == "hello ic"
+
+    # increase `mcCounter` by 3
+    mcCounter.inc(3)
+    assert mcCounter.value == 3
+
+
+type
+  CacheSeq* = distinct string
+    ## Compile-time sequence of `NimNode`s.
+  CacheTable* = distinct string
+    ## Compile-time table of key-value pairs.
+    ##
+    ## Keys are `string`s and values are `NimNode`s.
+  CacheCounter* = distinct string
+    ## Compile-time counter, uses `int` for storing the count.
+
+proc value*(c: CacheCounter): int {.magic: "NccValue".} =
+  ## Returns the value of a counter `c`.
+  runnableExamples:
+    static:
+      let counter = CacheCounter"valTest"
+      # default value is 0
+      assert counter.value == 0
+
+      inc counter
+      assert counter.value == 1
+
+proc inc*(c: CacheCounter; by = 1) {.magic: "NccInc".} =
+  ## Increments the counter `c` with the value `by`.
+  runnableExamples:
+    static:
+      let counter = CacheCounter"incTest"
+      inc counter
+      inc counter, 5
+
+      assert counter.value == 6
+
+proc add*(s: CacheSeq; value: NimNode) {.magic: "NcsAdd".} =
+  ## Adds `value` to `s`.
+  runnableExamples:
+    import std/macros
+    const mySeq = CacheSeq"addTest"
+
+    static:
+      mySeq.add(newLit(5))
+      mySeq.add(newLit("hello ic"))
+
+      assert mySeq.len == 2
+      assert mySeq[1].strVal == "hello ic"
+
+proc incl*(s: CacheSeq; value: NimNode) {.magic: "NcsIncl".} =
+  ## Adds `value` to `s`.
+  ##
+  ## .. hint:: This doesn't do anything if `value` is already in `s`.
+  runnableExamples:
+    import std/macros
+    const mySeq = CacheSeq"inclTest"
+
+    static:
+      mySeq.incl(newLit(5))
+      mySeq.incl(newLit(5))
+
+      # still one element
+      assert mySeq.len == 1
+
+proc len*(s: CacheSeq): int {.magic: "NcsLen".} =
+  ## Returns the length of `s`.
+  runnableExamples:
+    import std/macros
+
+    const mySeq = CacheSeq"lenTest"
+    static:
+      let val = newLit("helper")
+      mySeq.add(val)
+      assert mySeq.len == 1
+
+      mySeq.add(val)
+      assert mySeq.len == 2
+
+proc `[]`*(s: CacheSeq; i: int): NimNode {.magic: "NcsAt".} =
+  ## Returns the `i`th value from `s`.
+  runnableExamples:
+    import std/macros
+
+    const mySeq = CacheSeq"subTest"
+    static:
+      mySeq.add(newLit(42))
+      assert mySeq[0].intVal == 42
+
+proc `[]`*(s: CacheSeq; i: BackwardsIndex): NimNode =
+  ## Returns the `i`th last value from `s`.
+  runnableExamples:
+    import std/macros
+
+    const mySeq = CacheSeq"backTest"
+    static:
+      mySeq &= newLit(42)
+      mySeq &= newLit(7)
+      assert mySeq[^1].intVal == 7  # Last item
+      assert mySeq[^2].intVal == 42 # Second last item
+  s[s.len - int(i)]
+
+iterator items*(s: CacheSeq): NimNode =
+  ## Iterates over each item in `s`.
+  runnableExamples:
+    import std/macros
+    const myseq = CacheSeq"itemsTest"
+
+    static:
+      myseq.add(newLit(5))
+      myseq.add(newLit(42))
+
+      for val in myseq:
+        # check that all values in `myseq` are int literals
+        assert val.kind == nnkIntLit
+
+  for i in 0 ..< len(s): yield s[i]
+
+proc `[]=`*(t: CacheTable; key: string, value: NimNode) {.magic: "NctPut".} =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## .. warning:: `key` has to be unique! Assigning `value` to a `key` that is already
+  ##   in the table will result in a compiler error.
+  runnableExamples:
+    import std/macros
+
+    const mcTable = CacheTable"subTest"
+    static:
+      # assign newLit(5) to the key "value"
+      mcTable["value"] = newLit(5)
+
+      # check that we can get the value back
+      assert mcTable["value"].kind == nnkIntLit
+
+proc len*(t: CacheTable): int {.magic: "NctLen".} =
+  ## Returns the number of elements in `t`.
+  runnableExamples:
+    import std/macros
+
+    const dataTable = CacheTable"lenTest"
+    static:
+      dataTable["key"] = newLit(5)
+      assert dataTable.len == 1
+
+proc `[]`*(t: CacheTable; key: string): NimNode {.magic: "NctGet".} =
+  ## Retrieves the `NimNode` value at `t[key]`.
+  runnableExamples:
+    import std/macros
+
+    const mcTable = CacheTable"subTest"
+    static:
+      mcTable["toAdd"] = newStmtList()
+
+      # get the NimNode back
+      assert mcTable["toAdd"].kind == nnkStmtList
+
+proc hasKey*(t: CacheTable; key: string): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * [contains proc][contains(CacheTable, string)] for use with the `in` operator
+  runnableExamples:
+    import std/macros
+    const mcTable = CacheTable"hasKeyEx"
+    static:
+      assert not mcTable.hasKey("foo")
+      mcTable["foo"] = newEmptyNode()
+      # Will now be true since we inserted a value
+      assert mcTable.hasKey("foo")
+  discard "Implemented in vmops"
+
+proc contains*(t: CacheTable; key: string): bool {.inline.} =
+  ## Alias of [hasKey][hasKey(CacheTable, string)] for use with the `in` operator.
+  runnableExamples:
+    import std/macros
+    const mcTable = CacheTable"containsEx"
+    static:
+      mcTable["foo"] = newEmptyNode()
+      # Will be true since we gave it a value before
+      assert "foo" in mcTable
+  t.hasKey(key)
+
+proc hasNext(t: CacheTable; iter: int): bool {.magic: "NctHasNext".}
+proc next(t: CacheTable; iter: int): (string, NimNode, int) {.magic: "NctNext".}
+
+iterator pairs*(t: CacheTable): (string, NimNode) =
+  ## Iterates over all `(key, value)` pairs in `t`.
+  runnableExamples:
+    import std/macros
+    const mytabl = CacheTable"values"
+
+    static:
+      mytabl["intVal"] = newLit(5)
+      mytabl["otherVal"] = newLit(6)
+      for key, val in mytabl:
+        # make sure that we actually get the same keys
+        assert key in ["intVal", "otherVal"]
+
+        # all vals are int literals
+        assert val.kind == nnkIntLit
+
+  var h = 0
+  while hasNext(t, h):
+    let (a, b, h2) = next(t, h)
+    yield (a, b)
+    h = h2
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
new file mode 100644
index 000000000..7646b165c
--- /dev/null
+++ b/lib/core/macros.nim
@@ -0,0 +1,1812 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+include "system/inclrtl"
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, formatfloat]
+
+
+## This module contains the interface to the compiler's abstract syntax
+## tree (`AST`:idx:). Macros operate on this tree.
+##
+## See also:
+## * `macros tutorial <tut3.html>`_
+## * `macros section in Nim manual <manual.html#macros>`_
+
+## .. include:: ../../doc/astspec.txt
+
+## .. importdoc:: system.nim
+
+# If you look for the implementation of the magic symbol
+# ``{.magic: "Foo".}``, search for `mFoo` and `opcFoo`.
+
+type
+  NimNodeKind* = enum
+    nnkNone, nnkEmpty, nnkIdent, nnkSym,
+    nnkType, nnkCharLit, nnkIntLit, nnkInt8Lit,
+    nnkInt16Lit, nnkInt32Lit, nnkInt64Lit, nnkUIntLit, nnkUInt8Lit,
+    nnkUInt16Lit, nnkUInt32Lit, nnkUInt64Lit, nnkFloatLit,
+    nnkFloat32Lit, nnkFloat64Lit, nnkFloat128Lit, nnkStrLit, nnkRStrLit,
+    nnkTripleStrLit, nnkNilLit, nnkComesFrom, nnkDotCall,
+    nnkCommand, nnkCall, nnkCallStrLit, nnkInfix,
+    nnkPrefix, nnkPostfix, nnkHiddenCallConv,
+    nnkExprEqExpr,
+    nnkExprColonExpr, nnkIdentDefs, nnkVarTuple,
+    nnkPar, nnkObjConstr, nnkCurly, nnkCurlyExpr,
+    nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange,
+    nnkDotExpr, nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr,
+    nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkAccQuoted,
+    nnkTableConstr, nnkBind,
+    nnkClosedSymChoice,
+    nnkOpenSymChoice,
+    nnkHiddenStdConv,
+    nnkHiddenSubConv, nnkConv, nnkCast, nnkStaticExpr,
+    nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv,
+    nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange,
+    nnkStringToCString, nnkCStringToString, nnkAsgn,
+    nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit,
+    nnkImportAs, nnkProcDef, nnkMethodDef, nnkConverterDef,
+    nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch,
+    nnkElifBranch, nnkExceptBranch, nnkElse,
+    nnkAsmStmt, nnkPragma, nnkPragmaBlock, nnkIfStmt, nnkWhenStmt,
+    nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkCaseStmt,
+    nnkTypeSection, nnkVarSection, nnkLetSection, nnkConstSection,
+    nnkConstDef, nnkTypeDef,
+    nnkYieldStmt, nnkDefer, nnkTryStmt, nnkFinally, nnkRaiseStmt,
+    nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, nnkStaticStmt,
+    nnkDiscardStmt, nnkStmtList,
+    nnkImportStmt,
+    nnkImportExceptStmt,
+    nnkExportStmt,
+    nnkExportExceptStmt,
+    nnkFromStmt,
+    nnkIncludeStmt,
+    nnkBindStmt, nnkMixinStmt, nnkUsingStmt,
+    nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr,
+    nnkStmtListType, nnkBlockType,
+    nnkWith, nnkWithout,
+    nnkTypeOfExpr, nnkObjectTy,
+    nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy,
+    nnkRecList, nnkRecCase, nnkRecWhen,
+    nnkRefTy, nnkPtrTy, nnkVarTy,
+    nnkConstTy, nnkOutTy,
+    nnkDistinctTy,
+    nnkProcTy,
+    nnkIteratorTy,         # iterator type
+    nnkSinkAsgn,
+    nnkEnumTy,
+    nnkEnumFieldDef,
+    nnkArgList, nnkPattern
+    nnkHiddenTryStmt,
+    nnkClosure,
+    nnkGotoState,
+    nnkState,
+    nnkBreakState,
+    nnkFuncDef,
+    nnkTupleConstr,
+    nnkError,  ## erroneous AST node
+    nnkModuleRef, nnkReplayAction, nnkNilRodNode ## internal IC nodes
+    nnkOpenSym
+
+  NimNodeKinds* = set[NimNodeKind]
+  NimTypeKind* = enum  # some types are no longer used, see ast.nim
+    ntyNone, ntyBool, ntyChar, ntyEmpty,
+    ntyAlias, ntyNil, ntyExpr, ntyStmt,
+    ntyTypeDesc, ntyGenericInvocation, ntyGenericBody, ntyGenericInst,
+    ntyGenericParam, ntyDistinct, ntyEnum, ntyOrdinal,
+    ntyArray, ntyObject, ntyTuple, ntySet,
+    ntyRange, ntyPtr, ntyRef, ntyVar,
+    ntySequence, ntyProc, ntyPointer, ntyOpenArray,
+    ntyString, ntyCString, ntyForward, ntyInt,
+    ntyInt8, ntyInt16, ntyInt32, ntyInt64,
+    ntyFloat, ntyFloat32, ntyFloat64, ntyFloat128,
+    ntyUInt, ntyUInt8, ntyUInt16, ntyUInt32, ntyUInt64,
+    ntyUnused0, ntyUnused1, ntyUnused2,
+    ntyVarargs,
+    ntyUncheckedArray,
+    ntyError,
+    ntyBuiltinTypeClass, ntyUserTypeClass, ntyUserTypeClassInst,
+    ntyCompositeTypeClass, ntyInferred, ntyAnd, ntyOr, ntyNot,
+    ntyAnything, ntyStatic, ntyFromExpr, ntyOptDeprecated, ntyVoid
+
+  TNimTypeKinds* {.deprecated.} = set[NimTypeKind]
+  NimSymKind* = enum
+    nskUnknown, nskConditional, nskDynLib, nskParam,
+    nskGenericParam, nskTemp, nskModule, nskType, nskVar, nskLet,
+    nskConst, nskResult,
+    nskProc, nskFunc, nskMethod, nskIterator,
+    nskConverter, nskMacro, nskTemplate, nskField,
+    nskEnumField, nskForVar, nskLabel,
+    nskStub
+
+  TNimSymKinds* {.deprecated.} = set[NimSymKind]
+
+const
+  nnkMutableTy* {.deprecated.} = nnkOutTy
+  nnkSharedTy* {.deprecated.} = nnkSinkAsgn
+
+type
+  NimIdent* {.deprecated.} = object of RootObj
+    ## Represents a Nim identifier in the AST. **Note**: This is only
+    ## rarely useful, for identifier construction from a string
+    ## use `ident"abc"`.
+
+  NimSymObj = object # hidden
+  NimSym* {.deprecated.} = ref NimSymObj
+    ## Represents a Nim *symbol* in the compiler; a *symbol* is a looked-up
+    ## *ident*.
+
+
+const
+  nnkLiterals* = {nnkCharLit..nnkNilLit}
+  # see matching set CallNodes below
+  nnkCallKinds* = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
+                   nnkCallStrLit, nnkHiddenCallConv}
+  nnkPragmaCallKinds = {nnkExprColonExpr, nnkCall, nnkCallStrLit}
+
+{.push warnings: off.}
+
+proc toNimIdent*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect, deprecated:
+  "Deprecated since version 0.18.0: Use 'ident' or 'newIdentNode' instead.".}
+  ## Constructs an identifier from the string `s`.
+
+proc `==`*(a, b: NimIdent): bool {.magic: "EqIdent", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Use '==' on 'NimNode' instead.".}
+  ## Compares two Nim identifiers.
+
+proc `==`*(a, b: NimNode): bool {.magic: "EqNimrodNode", noSideEffect.}
+  ## Compare two Nim nodes. Return true if nodes are structurally
+  ## equivalent. This means two independently created nodes can be equal.
+
+proc `==`*(a, b: NimSym): bool {.magic: "EqNimrodNode", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Use '==(NimNode, NimNode)' instead.".}
+  ## Compares two Nim symbols.
+
+{.pop.}
+
+proc sameType*(a, b: NimNode): bool {.magic: "SameNodeType", noSideEffect.} =
+  ## Compares two Nim nodes' types. Return true if the types are the same,
+  ## e.g. true when comparing alias with original type.
+  discard
+
+proc len*(n: NimNode): int {.magic: "NLen", noSideEffect.}
+  ## Returns the number of children of `n`.
+
+proc `[]`*(n: NimNode, i: int): NimNode {.magic: "NChild", noSideEffect.}
+  ## Get `n`'s `i`'th child.
+
+proc `[]`*(n: NimNode, i: BackwardsIndex): NimNode = n[n.len - i.int]
+  ## Get `n`'s `i`'th child.
+
+template `^^`(n: NimNode, i: untyped): untyped =
+  (when i is BackwardsIndex: n.len - int(i) else: int(i))
+
+proc `[]`*[T, U: Ordinal](n: NimNode, x: HSlice[T, U]): seq[NimNode] =
+  ## Slice operation for NimNode.
+  ## Returns a seq of child of `n` who inclusive range `[n[x.a], n[x.b]]`.
+  let xa = n ^^ x.a
+  let L = (n ^^ x.b) - xa + 1
+  result = newSeq[NimNode](L)
+  for i in 0..<L:
+    result[i] = n[i + xa]
+
+proc `[]=`*(n: NimNode, i: int, child: NimNode) {.magic: "NSetChild",
+  noSideEffect.}
+  ## Set `n`'s `i`'th child to `child`.
+
+proc `[]=`*(n: NimNode, i: BackwardsIndex, child: NimNode) =
+  ## Set `n`'s `i`'th child to `child`.
+  n[n.len - i.int] = child
+
+template `or`*(x, y: NimNode): NimNode =
+  ## Evaluate `x` and when it is not an empty node, return
+  ## it. Otherwise evaluate to `y`. Can be used to chain several
+  ## expressions to get the first expression that is not empty.
+  ##   ```nim
+  ##   let node = mightBeEmpty() or mightAlsoBeEmpty() or fallbackNode
+  ##   ```
+
+  let arg = x
+  if arg != nil and arg.kind != nnkEmpty:
+    arg
+  else:
+    y
+
+proc add*(father, child: NimNode): NimNode {.magic: "NAdd", discardable,
+  noSideEffect.}
+  ## Adds the `child` to the `father` node. Returns the
+  ## father node so that calls can be nested.
+
+proc add*(father: NimNode, children: varargs[NimNode]): NimNode {.
+  magic: "NAddMultiple", discardable, noSideEffect.}
+  ## Adds each child of `children` to the `father` node.
+  ## Returns the `father` node so that calls can be nested.
+
+proc del*(father: NimNode, idx = 0, n = 1) {.magic: "NDel", noSideEffect.}
+  ## Deletes `n` children of `father` starting at index `idx`.
+
+proc kind*(n: NimNode): NimNodeKind {.magic: "NKind", noSideEffect.}
+  ## Returns the `kind` of the node `n`.
+
+proc intVal*(n: NimNode): BiggestInt {.magic: "NIntVal", noSideEffect.}
+  ## Returns an integer value from any integer literal or enum field symbol.
+
+proc floatVal*(n: NimNode): BiggestFloat {.magic: "NFloatVal", noSideEffect.}
+  ## Returns a float from any floating point literal.
+
+
+proc symKind*(symbol: NimNode): NimSymKind {.magic: "NSymKind", noSideEffect.}
+proc getImpl*(symbol: NimNode): NimNode {.magic: "GetImpl", noSideEffect.}
+  ## Returns a copy of the declaration of a symbol or `nil`.
+proc strVal*(n: NimNode): string  {.magic: "NStrVal", noSideEffect.}
+  ## Returns the string value of an identifier, symbol, comment, or string literal.
+  ##
+  ## See also:
+  ## * `strVal= proc<#strVal=,NimNode,string>`_ for setting the string value.
+
+{.push warnings: off.} # silence `deprecated`
+
+proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; All functionality is defined on 'NimNode'.".}
+
+proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; All functionality is defined on 'NimNode'.".}
+
+proc getImpl*(s: NimSym): NimNode {.magic: "GetImpl", noSideEffect, deprecated: "use `getImpl: NimNode -> NimNode` instead".}
+
+proc `$`*(i: NimIdent): string {.magic: "NStrVal", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Use 'strVal' instead.".}
+  ## Converts a Nim identifier to a string.
+
+proc `$`*(s: NimSym): string {.magic: "NStrVal", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Use 'strVal' instead.".}
+  ## Converts a Nim symbol to a string.
+
+{.pop.}
+
+when (NimMajor, NimMinor, NimPatch) >= (1, 3, 5) or defined(nimSymImplTransform):
+  proc getImplTransformed*(symbol: NimNode): NimNode {.magic: "GetImplTransf", noSideEffect.}
+    ## For a typed proc returns the AST after transformation pass; this is useful
+    ## for debugging how the compiler transforms code (e.g.: `defer`, `for`) but
+    ## note that code transformations are implementation dependent and subject to change.
+    ## See an example in `tests/macros/tmacros_various.nim`.
+
+proc owner*(sym: NimNode): NimNode {.magic: "SymOwner", noSideEffect, deprecated.}
+  ## Accepts a node of kind `nnkSym` and returns its owner's symbol.
+  ## The meaning of 'owner' depends on `sym`'s `NimSymKind` and declaration
+  ## context. For top level declarations this is an `nskModule` symbol,
+  ## for proc local variables an `nskProc` symbol, for enum/object fields an
+  ## `nskType` symbol, etc. For symbols without an owner, `nil` is returned.
+  ##
+  ## See also:
+  ## * `symKind proc<#symKind,NimNode>`_ to get the kind of a symbol
+  ## * `getImpl proc<#getImpl,NimNode>`_ to get the declaration of a symbol
+
+proc isInstantiationOf*(instanceProcSym, genProcSym: NimNode): bool {.magic: "SymIsInstantiationOf", noSideEffect.}
+  ## Checks if a proc symbol is an instance of the generic proc symbol.
+  ## Useful to check proc symbols against generic symbols
+  ## returned by `bindSym`.
+
+proc getType*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.}
+  ## With 'getType' you can access the node's `type`:idx:. A Nim type is
+  ## mapped to a Nim AST too, so it's slightly confusing but it means the same
+  ## API can be used to traverse types. Recursive types are flattened for you
+  ## so there is no danger of infinite recursions during traversal. To
+  ## resolve recursive types, you have to call 'getType' again. To see what
+  ## kind of type it is, call `typeKind` on getType's result.
+
+proc getType*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.}
+  ## Version of `getType` which takes a `typedesc`.
+
+proc typeKind*(n: NimNode): NimTypeKind {.magic: "NGetType", noSideEffect.}
+  ## Returns the type kind of the node 'n' that should represent a type, that
+  ## means the node should have been obtained via `getType`.
+
+proc getTypeInst*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.} =
+  ## Returns the `type`:idx: of a node in a form matching the way the
+  ## type instance was declared in the code.
+  runnableExamples:
+    type
+      Vec[N: static[int], T] = object
+        arr: array[N, T]
+      Vec4[T] = Vec[4, T]
+      Vec4f = Vec4[float32]
+    var a: Vec4f
+    var b: Vec4[float32]
+    var c: Vec[4, float32]
+    macro dumpTypeInst(x: typed): untyped =
+      newLit(x.getTypeInst.repr)
+    doAssert(dumpTypeInst(a) == "Vec4f")
+    doAssert(dumpTypeInst(b) == "Vec4[float32]")
+    doAssert(dumpTypeInst(c) == "Vec[4, float32]")
+
+proc getTypeInst*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.}
+  ## Version of `getTypeInst` which takes a `typedesc`.
+
+proc getTypeImpl*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.} =
+  ## Returns the `type`:idx: of a node in a form matching the implementation
+  ## of the type. Any intermediate aliases are expanded to arrive at the final
+  ## type implementation. You can instead use `getImpl` on a symbol if you
+  ## want to find the intermediate aliases.
+  runnableExamples:
+    type
+      Vec[N: static[int], T] = object
+        arr: array[N, T]
+      Vec4[T] = Vec[4, T]
+      Vec4f = Vec4[float32]
+    var a: Vec4f
+    var b: Vec4[float32]
+    var c: Vec[4, float32]
+    macro dumpTypeImpl(x: typed): untyped =
+      newLit(x.getTypeImpl.repr)
+    let t = """
+object
+  arr: array[0 .. 3, float32]"""
+    doAssert(dumpTypeImpl(a) == t)
+    doAssert(dumpTypeImpl(b) == t)
+    doAssert(dumpTypeImpl(c) == t)
+
+proc signatureHash*(n: NimNode): string {.magic: "NSigHash", noSideEffect.}
+  ## Returns a stable identifier derived from the signature of a symbol.
+  ## The signature combines many factors such as the type of the symbol,
+  ## the owning module of the symbol and others. The same identifier is
+  ## used in the back-end to produce the mangled symbol name.
+
+proc symBodyHash*(s: NimNode): string {.noSideEffect.} =
+  ## Returns a stable digest for symbols derived not only from type signature
+  ## and owning module, but also implementation body. All procs/variables used in
+  ## the implementation of this symbol are hashed recursively as well, including
+  ## magics from system module.
+  discard
+
+proc getTypeImpl*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.}
+  ## Version of `getTypeImpl` which takes a `typedesc`.
+
+proc `intVal=`*(n: NimNode, val: BiggestInt) {.magic: "NSetIntVal", noSideEffect.}
+proc `floatVal=`*(n: NimNode, val: BiggestFloat) {.magic: "NSetFloatVal", noSideEffect.}
+
+{.push warnings: off.}
+
+proc `symbol=`*(n: NimNode, val: NimSym) {.magic: "NSetSymbol", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Generate a new 'NimNode' with 'genSym' instead.".}
+
+proc `ident=`*(n: NimNode, val: NimIdent) {.magic: "NSetIdent", noSideEffect, deprecated:
+  "Deprecated since version 0.18.1; Generate a new 'NimNode' with 'ident(string)' instead.".}
+
+{.pop.}
+
+proc `strVal=`*(n: NimNode, val: string) {.magic: "NSetStrVal", noSideEffect.}
+  ## Sets the string value of a string literal or comment.
+  ## Setting `strVal` is disallowed for `nnkIdent` and `nnkSym` nodes; a new node
+  ## must be created using `ident` or `bindSym` instead.
+  ##
+  ## See also:
+  ## * `strVal proc<#strVal,NimNode>`_ for getting the string value.
+  ## * `ident proc<#ident,string>`_ for creating an identifier.
+  ## * `bindSym proc<#bindSym%2C%2CBindSymRule>`_ for binding a symbol.
+
+proc newNimNode*(kind: NimNodeKind,
+                 lineInfoFrom: NimNode = nil): NimNode
+  {.magic: "NNewNimNode", noSideEffect.}
+  ## Creates a new AST node of the specified kind.
+  ##
+  ## The `lineInfoFrom` parameter is used for line information when the
+  ## produced code crashes. You should ensure that it is set to a node that
+  ## you are transforming.
+
+proc copyNimNode*(n: NimNode): NimNode {.magic: "NCopyNimNode", noSideEffect.} =
+  ## Creates a new AST node by copying the node `n`. Note that unlike `copyNimTree`,
+  ## child nodes of `n` are not copied.
+  runnableExamples:
+    macro foo(x: typed) =
+      var s = copyNimNode(x)
+      doAssert s.len == 0
+      doAssert s.kind == nnkStmtList
+
+    foo:
+      let x = 12
+      echo x
+
+proc copyNimTree*(n: NimNode): NimNode {.magic: "NCopyNimTree", noSideEffect.} =
+  ## Creates a new AST node by recursively copying the node `n`. Note that
+  ## unlike `copyNimNode`, this copies `n`, the children of `n`, etc.
+  runnableExamples:
+    macro foo(x: typed) =
+      var s = copyNimTree(x)
+      doAssert s.len == 2
+      doAssert s.kind == nnkStmtList
+
+    foo:
+      let x = 12
+      echo x
+
+when defined(nimHasNoReturnError):
+  {.pragma: errorNoReturn, noreturn.}
+else:
+  {.pragma: errorNoReturn.}
+
+proc error*(msg: string, n: NimNode = nil) {.magic: "NError", benign, errorNoReturn.}
+  ## Writes an error message at compile time. The optional `n: NimNode`
+  ## parameter is used as the source for file and line number information in
+  ## the compilation error message.
+
+proc warning*(msg: string, n: NimNode = nil) {.magic: "NWarning", benign.}
+  ## Writes a warning message at compile time.
+
+proc hint*(msg: string, n: NimNode = nil) {.magic: "NHint", benign.}
+  ## Writes a hint message at compile time.
+
+proc newStrLitNode*(s: string): NimNode {.noSideEffect.} =
+  ## Creates a string literal node from `s`.
+  result = newNimNode(nnkStrLit)
+  result.strVal = s
+
+proc newCommentStmtNode*(s: string): NimNode {.noSideEffect.} =
+  ## Creates a comment statement node.
+  result = newNimNode(nnkCommentStmt)
+  result.strVal = s
+
+proc newIntLitNode*(i: BiggestInt): NimNode =
+  ## Creates an int literal node from `i`.
+  result = newNimNode(nnkIntLit)
+  result.intVal = i
+
+proc newFloatLitNode*(f: BiggestFloat): NimNode =
+  ## Creates a float literal node from `f`.
+  result = newNimNode(nnkFloatLit)
+  result.floatVal = f
+
+{.push warnings: off.}
+
+proc newIdentNode*(i: NimIdent): NimNode {.deprecated: "use ident(string)".} =
+  ## Creates an identifier node from `i`.
+  result = newNimNode(nnkIdent)
+  result.ident = i
+
+{.pop.}
+
+proc newIdentNode*(i: string): NimNode {.magic: "StrToIdent", noSideEffect.}
+  ## Creates an identifier node from `i`. It is simply an alias for
+  ## `ident(string)`. Use that, it's shorter.
+
+proc ident*(name: string): NimNode {.magic: "StrToIdent", noSideEffect.}
+  ## Create a new ident node from a string.
+
+type
+  BindSymRule* = enum    ## Specifies how `bindSym` behaves. The difference
+                         ## between open and closed symbols can be found in
+                         ## `<manual.html#symbol-lookup-in-generics-open-and-closed-symbols>`_
+    brClosed,            ## only the symbols in current scope are bound
+    brOpen,              ## open for overloaded symbols, but may be a single
+                         ## symbol if not ambiguous (the rules match that of
+                         ## binding in generics)
+    brForceOpen          ## same as brOpen, but it will always be open even
+                         ## if not ambiguous (this cannot be achieved with
+                         ## any other means in the language currently)
+
+proc bindSym*(ident: string | NimNode, rule: BindSymRule = brClosed): NimNode {.
+              magic: "NBindSym", noSideEffect.}
+  ## Creates a node that binds `ident` to a symbol node. The bound symbol
+  ## may be an overloaded symbol.
+  ## if `ident` is a NimNode, it must have `nnkIdent` kind.
+  ## If `rule == brClosed` either an `nnkClosedSymChoice` tree is
+  ## returned or `nnkSym` if the symbol is not ambiguous.
+  ## If `rule == brOpen` either an `nnkOpenSymChoice` tree is
+  ## returned or `nnkSym` if the symbol is not ambiguous.
+  ## If `rule == brForceOpen` always an `nnkOpenSymChoice` tree is
+  ## returned even if the symbol is not ambiguous.
+  ##
+  ## See the `manual <manual.html#macros-bindsym>`_ for more details.
+
+proc genSym*(kind: NimSymKind = nskLet; ident = ""): NimNode {.
+  magic: "NGenSym", noSideEffect.}
+  ## Generates a fresh symbol that is guaranteed to be unique. The symbol
+  ## needs to occur in a declaration context.
+
+proc callsite*(): NimNode {.magic: "NCallSite", benign, deprecated:
+  "Deprecated since v0.18.1; use `varargs[untyped]` in the macro prototype instead".}
+  ## Returns the AST of the invocation expression that invoked this macro.
+  # see https://github.com/nim-lang/RFCs/issues/387 as candidate replacement.
+
+proc toStrLit*(n: NimNode): NimNode =
+  ## Converts the AST `n` to the concrete Nim code and wraps that
+  ## in a string literal node.
+  return newStrLitNode(repr(n))
+
+type
+  LineInfo* = object
+    filename*: string
+    line*,column*: int
+
+proc `$`*(arg: LineInfo): string =
+  ## Return a string representation in the form `filepath(line, column)`.
+  # BUG: without `result = `, gives compile error
+  result = arg.filename & "(" & $arg.line & ", " & $arg.column & ")"
+
+#proc lineinfo*(n: NimNode): LineInfo {.magic: "NLineInfo", noSideEffect.}
+#  ## returns the position the node appears in the original source file
+#  ## in the form filename(line, col)
+
+proc getLine(arg: NimNode): int {.magic: "NLineInfo", noSideEffect.}
+proc getColumn(arg: NimNode): int {.magic: "NLineInfo", noSideEffect.}
+proc getFile(arg: NimNode): string {.magic: "NLineInfo", noSideEffect.}
+
+proc copyLineInfo*(arg: NimNode, info: NimNode) {.magic: "NLineInfo", noSideEffect.}
+  ## Copy lineinfo from `info`.
+
+proc setLine(arg: NimNode, line: uint16) {.magic: "NLineInfo", noSideEffect.}
+proc setColumn(arg: NimNode, column: int16) {.magic: "NLineInfo", noSideEffect.}
+proc setFile(arg: NimNode, file: string) {.magic: "NLineInfo", noSideEffect.}
+
+proc setLineInfo*(arg: NimNode, file: string, line: int, column: int) =
+  ## Sets the line info on the NimNode. The file needs to exists, but can be a
+  ## relative path. If you want to attach line info to a block using `quote`
+  ## you'll need to add the line information after the quote block.
+  arg.setFile(file)
+  arg.setLine(line.uint16)
+  arg.setColumn(column.int16)
+
+proc setLineInfo*(arg: NimNode, lineInfo: LineInfo) =
+  ## See `setLineInfo proc<#setLineInfo,NimNode,string,int,int>`_
+  setLineInfo(arg, lineInfo.filename, lineInfo.line, lineInfo.column)
+
+proc lineInfoObj*(n: NimNode): LineInfo =
+  ## Returns `LineInfo` of `n`, using absolute path for `filename`.
+  result = LineInfo(filename: n.getFile, line: n.getLine, column: n.getColumn)
+
+proc lineInfo*(arg: NimNode): string =
+  ## Return line info in the form `filepath(line, column)`.
+  $arg.lineInfoObj
+
+proc internalParseExpr(s, filename: string): NimNode {.
+  magic: "ParseExprToAst", noSideEffect.}
+
+proc internalParseStmt(s, filename: string): NimNode {.
+  magic: "ParseStmtToAst", noSideEffect.}
+
+proc internalErrorFlag*(): string {.magic: "NError", noSideEffect.}
+  ## Some builtins set an error flag. This is then turned into a proper
+  ## exception. **Note**: Ordinary application code should not call this.
+
+proc parseExpr*(s: string; filename: string = ""): NimNode {.noSideEffect.} =
+  ## Compiles the passed string to its AST representation.
+  ## Expects a single expression. Raises `ValueError` for parsing errors.
+  ## A filename can be given for more informative errors.
+  result = internalParseExpr(s, filename)
+  let x = internalErrorFlag()
+  if x.len > 0: raise newException(ValueError, x)
+
+proc parseStmt*(s: string; filename: string = ""): NimNode {.noSideEffect.} =
+  ## Compiles the passed string to its AST representation.
+  ## Expects one or more statements. Raises `ValueError` for parsing errors.
+  ## A filename can be given for more informative errors.
+  result = internalParseStmt(s, filename)
+  let x = internalErrorFlag()
+  if x.len > 0: raise newException(ValueError, x)
+
+proc getAst*(macroOrTemplate: untyped): NimNode {.magic: "ExpandToAst", noSideEffect.}
+  ## Obtains the AST nodes returned from a macro or template invocation.
+  ## See also `genasts.genAst`.
+  ## Example:
+  ##   ```nim
+  ##   macro FooMacro() =
+  ##     var ast = getAst(BarTemplate())
+  ##   ```
+
+proc quote*(bl: typed, op = "``"): NimNode {.magic: "QuoteAst", noSideEffect.} =
+  ## Quasi-quoting operator.
+  ## Accepts an expression or a block and returns the AST that represents it.
+  ## Within the quoted AST, you are able to interpolate NimNode expressions
+  ## from the surrounding scope. If no operator is given, quoting is done using
+  ## backticks. Otherwise, the given operator must be used as a prefix operator
+  ## for any interpolated expression. The original meaning of the interpolation
+  ## operator may be obtained by escaping it (by prefixing it with itself) when used
+  ## as a unary operator:
+  ## e.g. `@` is escaped as `@@`, `&%` is escaped as `&%&%` and so on; see examples.
+  ##
+  ## A custom operator interpolation needs accent quoted (``) whenever it resolves
+  ## to a symbol.
+  ##
+  ## See also `genasts <genasts.html>`_ which avoids some issues with `quote`.
+  runnableExamples:
+    macro check(ex: untyped) =
+      # this is a simplified version of the check macro from the
+      # unittest module.
+
+      # If there is a failed check, we want to make it easy for
+      # the user to jump to the faulty line in the code, so we
+      # get the line info here:
+      var info = ex.lineinfo
+
+      # We will also display the code string of the failed check:
+      var expString = ex.toStrLit
+
+      # Finally we compose the code to implement the check:
+      result = quote do:
+        if not `ex`:
+          echo `info` & ": Check failed: " & `expString`
+    check 1 + 1 == 2
+
+  runnableExamples:
+    # example showing how to define a symbol that requires backtick without
+    # quoting it.
+    var destroyCalled = false
+    macro bar() =
+      let s = newTree(nnkAccQuoted, ident"=destroy")
+      # let s = ident"`=destroy`" # this would not work
+      result = quote do:
+        type Foo = object
+        # proc `=destroy`(a: var Foo) = destroyCalled = true # this would not work
+        proc `s`(a: var Foo) = destroyCalled = true
+        block:
+          let a = Foo()
+    bar()
+    doAssert destroyCalled
+
+  runnableExamples:
+    # custom `op`
+    var destroyCalled = false
+    macro bar(ident) =
+      var x = 1.5
+      result = quote("@") do:
+        type Foo = object
+        let `@ident` = 0 # custom op interpolated symbols need quoted (``)
+        proc `=destroy`(a: var Foo) =
+          doAssert @x == 1.5
+          doAssert compiles(@x == 1.5)
+          let b1 = @[1,2]
+          let b2 = @@[1,2]
+          doAssert $b1 == "[1, 2]"
+          doAssert $b2 == "@[1, 2]"
+          destroyCalled = true
+        block:
+          let a = Foo()
+    bar(someident)
+    doAssert destroyCalled
+
+    proc `&%`(x: int): int = 1
+    proc `&%`(x, y: int): int = 2
+
+    macro bar2() =
+      var x = 3
+      result = quote("&%") do:
+        var y = &%x # quoting operator
+        doAssert &%&%y == 1 # unary operator => need to escape
+        doAssert y &% y == 2 # binary operator => no need to escape
+        doAssert y == 3
+    bar2()
+
+proc expectKind*(n: NimNode, k: NimNodeKind) =
+  ## Checks that `n` is of kind `k`. If this is not the case,
+  ## compilation aborts with an error message. This is useful for writing
+  ## macros that check the AST that is passed to them.
+  if n.kind != k: error("Expected a node of kind " & $k & ", got " & $n.kind, n)
+
+proc expectMinLen*(n: NimNode, min: int) =
+  ## Checks that `n` has at least `min` children. If this is not the case,
+  ## compilation aborts with an error message. This is useful for writing
+  ## macros that check its number of arguments.
+  if n.len < min: error("Expected a node with at least " & $min & " children, got " & $n.len, n)
+
+proc expectLen*(n: NimNode, len: int) =
+  ## Checks that `n` has exactly `len` children. If this is not the case,
+  ## compilation aborts with an error message. This is useful for writing
+  ## macros that check its number of arguments.
+  if n.len != len: error("Expected a node with " & $len & " children, got " & $n.len, n)
+
+proc expectLen*(n: NimNode, min, max: int) =
+  ## Checks that `n` has a number of children in the range `min..max`.
+  ## If this is not the case, compilation aborts with an error message.
+  ## This is useful for writing macros that check its number of arguments.
+  if n.len < min or n.len > max:
+    error("Expected a node with " & $min & ".." & $max & " children, got " & $n.len, n)
+
+proc newTree*(kind: NimNodeKind,
+              children: varargs[NimNode]): NimNode =
+  ## Produces a new node with children.
+  result = newNimNode(kind)
+  result.add(children)
+
+proc newCall*(theProc: NimNode, args: varargs[NimNode]): NimNode =
+  ## Produces a new call node. `theProc` is the proc that is called with
+  ## the arguments `args[0..]`.
+  result = newNimNode(nnkCall)
+  result.add(theProc)
+  result.add(args)
+
+{.push warnings: off.}
+
+proc newCall*(theProc: NimIdent, args: varargs[NimNode]): NimNode {.deprecated:
+  "Deprecated since v0.18.1; use 'newCall(string, ...)' or 'newCall(NimNode, ...)' instead".} =
+  ## Produces a new call node. `theProc` is the proc that is called with
+  ## the arguments `args[0..]`.
+  result = newNimNode(nnkCall)
+  result.add(newIdentNode(theProc))
+  result.add(args)
+
+{.pop.}
+
+proc newCall*(theProc: string,
+              args: varargs[NimNode]): NimNode =
+  ## Produces a new call node. `theProc` is the proc that is called with
+  ## the arguments `args[0..]`.
+  result = newNimNode(nnkCall)
+  result.add(newIdentNode(theProc))
+  result.add(args)
+
+proc newLit*(c: char): NimNode =
+  ## Produces a new character literal node.
+  result = newNimNode(nnkCharLit)
+  result.intVal = ord(c)
+
+proc newLit*(i: int): NimNode =
+  ## Produces a new integer literal node.
+  result = newNimNode(nnkIntLit)
+  result.intVal = i
+
+proc newLit*(i: int8): NimNode =
+  ## Produces a new integer literal node.
+  result = newNimNode(nnkInt8Lit)
+  result.intVal = i
+
+proc newLit*(i: int16): NimNode =
+  ## Produces a new integer literal node.
+  result = newNimNode(nnkInt16Lit)
+  result.intVal = i
+
+proc newLit*(i: int32): NimNode =
+  ## Produces a new integer literal node.
+  result = newNimNode(nnkInt32Lit)
+  result.intVal = i
+
+proc newLit*(i: int64): NimNode =
+  ## Produces a new integer literal node.
+  result = newNimNode(nnkInt64Lit)
+  result.intVal = i
+
+proc newLit*(i: uint): NimNode =
+  ## Produces a new unsigned integer literal node.
+  result = newNimNode(nnkUIntLit)
+  result.intVal = BiggestInt(i)
+
+proc newLit*(i: uint8): NimNode =
+  ## Produces a new unsigned integer literal node.
+  result = newNimNode(nnkUInt8Lit)
+  result.intVal = BiggestInt(i)
+
+proc newLit*(i: uint16): NimNode =
+  ## Produces a new unsigned integer literal node.
+  result = newNimNode(nnkUInt16Lit)
+  result.intVal = BiggestInt(i)
+
+proc newLit*(i: uint32): NimNode =
+  ## Produces a new unsigned integer literal node.
+  result = newNimNode(nnkUInt32Lit)
+  result.intVal = BiggestInt(i)
+
+proc newLit*(i: uint64): NimNode =
+  ## Produces a new unsigned integer literal node.
+  result = newNimNode(nnkUInt64Lit)
+  result.intVal = BiggestInt(i)
+
+proc newLit*(b: bool): NimNode =
+  ## Produces a new boolean literal node.
+  result = if b: bindSym"true" else: bindSym"false"
+
+proc newLit*(s: string): NimNode =
+  ## Produces a new string literal node.
+  result = newNimNode(nnkStrLit)
+  result.strVal = s
+
+when false:
+  # the float type is not really a distinct type as described in https://github.com/nim-lang/Nim/issues/5875
+  proc newLit*(f: float): NimNode =
+    ## Produces a new float literal node.
+    result = newNimNode(nnkFloatLit)
+    result.floatVal = f
+
+proc newLit*(f: float32): NimNode =
+  ## Produces a new float literal node.
+  result = newNimNode(nnkFloat32Lit)
+  result.floatVal = f
+
+proc newLit*(f: float64): NimNode =
+  ## Produces a new float literal node.
+  result = newNimNode(nnkFloat64Lit)
+  result.floatVal = f
+
+when declared(float128):
+  proc newLit*(f: float128): NimNode =
+    ## Produces a new float literal node.
+    result = newNimNode(nnkFloat128Lit)
+    result.floatVal = f
+
+proc newLit*(arg: enum): NimNode =
+  result = newCall(
+    arg.typeof.getTypeInst[1],
+    newLit(int(arg))
+  )
+
+proc newLit*[N,T](arg: array[N,T]): NimNode
+proc newLit*[T](arg: seq[T]): NimNode
+proc newLit*[T](s: set[T]): NimNode
+proc newLit*[T: tuple](arg: T): NimNode
+
+proc newLit*(arg: object): NimNode =
+  result = nnkObjConstr.newTree(arg.typeof.getTypeInst[1])
+  for a, b in arg.fieldPairs:
+    result.add nnkExprColonExpr.newTree( newIdentNode(a), newLit(b) )
+
+proc newLit*(arg: ref object): NimNode =
+  ## produces a new ref type literal node.
+  result = nnkObjConstr.newTree(arg.typeof.getTypeInst[1])
+  for a, b in fieldPairs(arg[]):
+    result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b))
+
+proc newLit*[N,T](arg: array[N,T]): NimNode =
+  result = nnkBracket.newTree
+  for x in arg:
+    result.add newLit(x)
+
+proc newLit*[T](arg: seq[T]): NimNode =
+  let bracket = nnkBracket.newTree
+  for x in arg:
+    bracket.add newLit(x)
+  result = nnkPrefix.newTree(
+    bindSym"@",
+    bracket
+  )
+  if arg.len == 0:
+    # add type cast for empty seq
+    var typ = getTypeInst(typeof(arg))[1]
+    result = newCall(typ,result)
+
+proc newLit*[T](s: set[T]): NimNode =
+  result = nnkCurly.newTree
+  for x in s:
+    result.add newLit(x)
+  if result.len == 0:
+    # add type cast for empty set
+    var typ = getTypeInst(typeof(s))[1]
+    result = newCall(typ,result)
+
+proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
+  ## See `typetraits.isNamedTuple`
+
+proc newLit*[T: tuple](arg: T): NimNode =
+  ## use -d:nimHasWorkaround14720 to restore behavior prior to PR, forcing
+  ## a named tuple even when `arg` is unnamed.
+  result = nnkTupleConstr.newTree
+  when defined(nimHasWorkaround14720) or isNamedTuple(T):
+    for a, b in arg.fieldPairs:
+      result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b))
+  else:
+    for b in arg.fields:
+      result.add newLit(b)
+
+proc nestList*(op: NimNode; pack: NimNode): NimNode =
+  ## Nests the list `pack` into a tree of call expressions:
+  ## `[a, b, c]` is transformed into `op(a, op(c, d))`.
+  ## This is also known as fold expression.
+  if pack.len < 1:
+    error("`nestList` expects a node with at least 1 child")
+  result = pack[^1]
+  for i in countdown(pack.len - 2, 0):
+    result = newCall(op, pack[i], result)
+
+proc nestList*(op: NimNode; pack: NimNode; init: NimNode): NimNode =
+  ## Nests the list `pack` into a tree of call expressions:
+  ## `[a, b, c]` is transformed into `op(a, op(c, d))`.
+  ## This is also known as fold expression.
+  result = init
+  for i in countdown(pack.len - 1, 0):
+    result = newCall(op, pack[i], result)
+
+proc eqIdent*(a: string; b: string): bool {.magic: "EqIdent", noSideEffect.}
+  ## Style insensitive comparison.
+
+proc eqIdent*(a: NimNode; b: string): bool {.magic: "EqIdent", noSideEffect.}
+  ## Style insensitive comparison.  `a` can be an identifier or a
+  ## symbol. `a` may be wrapped in an export marker
+  ## (`nnkPostfix`) or quoted with backticks (`nnkAccQuoted`),
+  ## these nodes will be unwrapped.
+
+proc eqIdent*(a: string; b: NimNode): bool {.magic: "EqIdent", noSideEffect.}
+  ## Style insensitive comparison.  `b` can be an identifier or a
+  ## symbol. `b` may be wrapped in an export marker
+  ## (`nnkPostfix`) or quoted with backticks (`nnkAccQuoted`),
+  ## these nodes will be unwrapped.
+
+proc eqIdent*(a: NimNode; b: NimNode): bool {.magic: "EqIdent", noSideEffect.}
+  ## Style insensitive comparison.  `a` and `b` can be an
+  ## identifier or a symbol. Both may be wrapped in an export marker
+  ## (`nnkPostfix`) or quoted with backticks (`nnkAccQuoted`),
+  ## these nodes will be unwrapped.
+
+const collapseSymChoice = not defined(nimLegacyMacrosCollapseSymChoice)
+
+proc treeTraverse(n: NimNode; res: var string; level = 0; isLisp = false, indented = false) {.benign.} =
+  if level > 0:
+    if indented:
+      res.add("\n")
+      for i in 0 .. level-1:
+        if isLisp:
+          res.add(" ")          # dumpLisp indentation
+        else:
+          res.add("  ")         # dumpTree indentation
+    else:
+      res.add(" ")
+
+  if isLisp:
+    res.add("(")
+  res.add(($n.kind).substr(3))
+
+  case n.kind
+  of nnkEmpty, nnkNilLit:
+    discard # same as nil node in this representation
+  of nnkCharLit .. nnkInt64Lit:
+    res.add(" " & $n.intVal)
+  of nnkUIntLit .. nnkUInt64Lit:
+    res.add(" " & $cast[uint64](n.intVal))
+  of nnkFloatLit .. nnkFloat64Lit:
+    res.add(" " & $n.floatVal)
+  of nnkStrLit .. nnkTripleStrLit, nnkCommentStmt, nnkIdent, nnkSym:
+    res.add(" " & $n.strVal.newLit.repr)
+  of nnkNone:
+    assert false
+  elif n.kind in {nnkOpenSymChoice, nnkClosedSymChoice} and collapseSymChoice:
+    res.add(" " & $n.len)
+    if n.len > 0:
+      var allSameSymName = true
+      for i in 0..<n.len:
+        if n[i].kind != nnkSym or not eqIdent(n[i], n[0]):
+          allSameSymName = false
+          break
+      if allSameSymName:
+        res.add(" " & $n[0].strVal.newLit.repr)
+      else:
+        for j in 0 ..< n.len:
+          n[j].treeTraverse(res, level+1, isLisp, indented)
+  else:
+    for j in 0 ..< n.len:
+      n[j].treeTraverse(res, level+1, isLisp, indented)
+
+  if isLisp:
+    res.add(")")
+
+proc treeRepr*(n: NimNode): string {.benign.} =
+  ## Convert the AST `n` to a human-readable tree-like string.
+  ##
+  ## See also `repr`, `lispRepr`_, and `astGenRepr`_.
+  result = ""
+  n.treeTraverse(result, isLisp = false, indented = true)
+
+proc lispRepr*(n: NimNode; indented = false): string {.benign.} =
+  ## Convert the AST `n` to a human-readable lisp-like string.
+  ##
+  ## See also `repr`, `treeRepr`_, and `astGenRepr`_.
+  result = ""
+  n.treeTraverse(result, isLisp = true, indented = indented)
+
+proc astGenRepr*(n: NimNode): string {.benign.} =
+  ## Convert the AST `n` to the code required to generate that AST.
+  ##
+  ## See also `repr`_, `treeRepr`_, and `lispRepr`_.
+
+  const
+    NodeKinds = {nnkEmpty, nnkIdent, nnkSym, nnkNone, nnkCommentStmt}
+    LitKinds = {nnkCharLit..nnkInt64Lit, nnkFloatLit..nnkFloat64Lit, nnkStrLit..nnkTripleStrLit}
+
+  proc traverse(res: var string, level: int, n: NimNode) {.benign.} =
+    for i in 0..level-1: res.add "  "
+    if n.kind in NodeKinds:
+      res.add("new" & ($n.kind).substr(3) & "Node(")
+    elif n.kind in LitKinds:
+      res.add("newLit(")
+    elif n.kind == nnkNilLit:
+      res.add("newNilLit()")
+    else:
+      res.add($n.kind)
+
+    case n.kind
+    of nnkEmpty, nnkNilLit: discard
+    of nnkCharLit: res.add("'" & $chr(n.intVal) & "'")
+    of nnkIntLit..nnkInt64Lit: res.add($n.intVal)
+    of nnkFloatLit..nnkFloat64Lit: res.add($n.floatVal)
+    of nnkStrLit..nnkTripleStrLit, nnkCommentStmt, nnkIdent, nnkSym:
+      res.add(n.strVal.newLit.repr)
+    of nnkNone: assert false
+    elif n.kind in {nnkOpenSymChoice, nnkClosedSymChoice} and collapseSymChoice:
+      res.add(", # unrepresentable symbols: " & $n.len)
+      if n.len > 0:
+        res.add(" " & n[0].strVal.newLit.repr)
+    else:
+      res.add(".newTree(")
+      for j in 0..<n.len:
+        res.add "\n"
+        traverse(res, level + 1, n[j])
+        if j != n.len-1:
+          res.add(",")
+
+      res.add("\n")
+      for i in 0..level-1: res.add "  "
+      res.add(")")
+
+    if n.kind in NodeKinds+LitKinds:
+      res.add(")")
+
+  result = ""
+  traverse(result, 0, n)
+
+macro dumpTree*(s: untyped): untyped = echo s.treeRepr
+  ## Accepts a block of nim code and prints the parsed abstract syntax
+  ## tree using the `treeRepr` proc. Printing is done *at compile time*.
+  ##
+  ## You can use this as a tool to explore the Nim's abstract syntax
+  ## tree and to discover what kind of nodes must be created to represent
+  ## a certain expression/statement.
+  ##
+  ## For example:
+  ##   ```nim
+  ##   dumpTree:
+  ##     echo "Hello, World!"
+  ##   ```
+  ##
+  ## Outputs:
+  ##   ```
+  ##   StmtList
+  ##     Command
+  ##       Ident "echo"
+  ##       StrLit "Hello, World!"
+  ##   ```
+  ##
+  ## Also see `dumpAstGen` and `dumpLisp`.
+
+macro dumpLisp*(s: untyped): untyped = echo s.lispRepr(indented = true)
+  ## Accepts a block of nim code and prints the parsed abstract syntax
+  ## tree using the `lispRepr` proc. Printing is done *at compile time*.
+  ##
+  ## You can use this as a tool to explore the Nim's abstract syntax
+  ## tree and to discover what kind of nodes must be created to represent
+  ## a certain expression/statement.
+  ##
+  ## For example:
+  ##   ```nim
+  ##   dumpLisp:
+  ##     echo "Hello, World!"
+  ##   ```
+  ##
+  ## Outputs:
+  ##   ```
+  ##   (StmtList
+  ##    (Command
+  ##     (Ident "echo")
+  ##     (StrLit "Hello, World!")))
+  ##   ```
+  ##
+  ## Also see `dumpAstGen` and `dumpTree`.
+
+macro dumpAstGen*(s: untyped): untyped = echo s.astGenRepr
+  ## Accepts a block of nim code and prints the parsed abstract syntax
+  ## tree using the `astGenRepr` proc. Printing is done *at compile time*.
+  ##
+  ## You can use this as a tool to write macros quicker by writing example
+  ## outputs and then copying the snippets into the macro for modification.
+  ##
+  ## For example:
+  ##   ```nim
+  ##   dumpAstGen:
+  ##     echo "Hello, World!"
+  ##   ```
+  ##
+  ## Outputs:
+  ##   ```
+  ##   nnkStmtList.newTree(
+  ##     nnkCommand.newTree(
+  ##       newIdentNode("echo"),
+  ##       newLit("Hello, World!")
+  ##     )
+  ##   )
+  ##   ```
+  ##
+  ## Also see `dumpTree` and `dumpLisp`.
+
+proc newEmptyNode*(): NimNode {.noSideEffect.} =
+  ## Create a new empty node.
+  result = newNimNode(nnkEmpty)
+
+proc newStmtList*(stmts: varargs[NimNode]): NimNode =
+  ## Create a new statement list.
+  result = newNimNode(nnkStmtList).add(stmts)
+
+proc newPar*(exprs: NimNode): NimNode =
+  ## Create a new parentheses-enclosed expression.
+  newNimNode(nnkPar).add(exprs)
+
+proc newPar*(exprs: varargs[NimNode]): NimNode {.deprecated:
+        "don't use newPar/nnkPar to construct tuple expressions; use nnkTupleConstr instead".} =
+  ## Create a new parentheses-enclosed expression.
+  newNimNode(nnkPar).add(exprs)
+
+proc newBlockStmt*(label, body: NimNode): NimNode =
+  ## Create a new block statement with label.
+  return newNimNode(nnkBlockStmt).add(label, body)
+
+proc newBlockStmt*(body: NimNode): NimNode =
+  ## Create a new block: stmt.
+  return newNimNode(nnkBlockStmt).add(newEmptyNode(), body)
+
+proc newVarStmt*(name, value: NimNode): NimNode =
+  ## Create a new var stmt.
+  return newNimNode(nnkVarSection).add(
+    newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
+
+proc newLetStmt*(name, value: NimNode): NimNode =
+  ## Create a new let stmt.
+  return newNimNode(nnkLetSection).add(
+    newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
+
+proc newConstStmt*(name, value: NimNode): NimNode =
+  ## Create a new const stmt.
+  newNimNode(nnkConstSection).add(
+    newNimNode(nnkConstDef).add(name, newNimNode(nnkEmpty), value))
+
+proc newAssignment*(lhs, rhs: NimNode): NimNode =
+  return newNimNode(nnkAsgn).add(lhs, rhs)
+
+proc newDotExpr*(a, b: NimNode): NimNode =
+  ## Create new dot expression.
+  ## a.dot(b) -> `a.b`
+  return newNimNode(nnkDotExpr).add(a, b)
+
+proc newColonExpr*(a, b: NimNode): NimNode =
+  ## Create new colon expression.
+  ## newColonExpr(a, b) -> `a: b`
+  newNimNode(nnkExprColonExpr).add(a, b)
+
+proc newIdentDefs*(name, kind: NimNode;
+                   default = newEmptyNode()): NimNode =
+  ## Creates a new `nnkIdentDefs` node of a specific kind and value.
+  ##
+  ## `nnkIdentDefs` need to have at least three children, but they can have
+  ## more: first comes a list of identifiers followed by a type and value
+  ## nodes. This helper proc creates a three node subtree, the first subnode
+  ## being a single identifier name. Both the `kind` node and `default`
+  ## (value) nodes may be empty depending on where the `nnkIdentDefs`
+  ## appears: tuple or object definitions will have an empty `default` node,
+  ## `let` or `var` blocks may have an empty `kind` node if the
+  ## identifier is being assigned a value. Example:
+  ##
+  ##   ```nim
+  ##   var varSection = newNimNode(nnkVarSection).add(
+  ##     newIdentDefs(ident("a"), ident("string")),
+  ##     newIdentDefs(ident("b"), newEmptyNode(), newLit(3)))
+  ##   # --> var
+  ##   #       a: string
+  ##   #       b = 3
+  ##   ```
+  ##
+  ## If you need to create multiple identifiers you need to use the lower level
+  ## `newNimNode`:
+  ##   ```nim
+  ##   result = newNimNode(nnkIdentDefs).add(
+  ##     ident("a"), ident("b"), ident("c"), ident("string"),
+  ##       newStrLitNode("Hello"))
+  ##   ```
+  newNimNode(nnkIdentDefs).add(name, kind, default)
+
+proc newNilLit*(): NimNode =
+  ## New nil literal shortcut.
+  result = newNimNode(nnkNilLit)
+
+proc last*(node: NimNode): NimNode = node[node.len-1]
+  ## Return the last item in nodes children. Same as `node[^1]`.
+
+
+const
+  RoutineNodes* = {nnkProcDef, nnkFuncDef, nnkMethodDef, nnkDo, nnkLambda,
+                   nnkIteratorDef, nnkTemplateDef, nnkConverterDef, nnkMacroDef}
+  AtomicNodes* = {nnkNone..nnkNilLit}
+  # see matching set nnkCallKinds above
+  CallNodes* = nnkCallKinds
+
+proc expectKind*(n: NimNode; k: set[NimNodeKind]) =
+  ## Checks that `n` is of kind `k`. If this is not the case,
+  ## compilation aborts with an error message. This is useful for writing
+  ## macros that check the AST that is passed to them.
+  if n.kind notin k: error("Expected one of " & $k & ", got " & $n.kind, n)
+
+proc newProc*(name = newEmptyNode();
+              params: openArray[NimNode] = [newEmptyNode()];
+              body: NimNode = newStmtList();
+              procType = nnkProcDef;
+              pragmas: NimNode = newEmptyNode()): NimNode =
+  ## Shortcut for creating a new proc.
+  ##
+  ## The `params` array must start with the return type of the proc,
+  ## followed by a list of IdentDefs which specify the params.
+  if procType notin RoutineNodes:
+    error("Expected one of " & $RoutineNodes & ", got " & $procType)
+  pragmas.expectKind({nnkEmpty, nnkPragma})
+  result = newNimNode(procType).add(
+    name,
+    newEmptyNode(),
+    newEmptyNode(),
+    newNimNode(nnkFormalParams).add(params),
+    pragmas,
+    newEmptyNode(),
+    body)
+
+proc newIfStmt*(branches: varargs[tuple[cond, body: NimNode]]): NimNode =
+  ## Constructor for `if` statements.
+  ##   ```nim
+  ##   newIfStmt(
+  ##     (Ident, StmtList),
+  ##     ...
+  ##   )
+  ##   ```
+  result = newNimNode(nnkIfStmt)
+  if len(branches) < 1:
+    error("If statement must have at least one branch")
+  for i in branches:
+    result.add(newTree(nnkElifBranch, i.cond, i.body))
+
+proc newEnum*(name: NimNode, fields: openArray[NimNode],
+              public, pure: bool): NimNode =
+
+  ## Creates a new enum. `name` must be an ident. Fields are allowed to be
+  ## either idents or EnumFieldDef:
+  ##   ```nim
+  ##   newEnum(
+  ##     name    = ident("Colors"),
+  ##     fields  = [ident("Blue"), ident("Red")],
+  ##     public  = true, pure = false)
+  ##
+  ##   # type Colors* = Blue Red
+  ##   ```
+
+  expectKind name, nnkIdent
+  if len(fields) < 1:
+    error("Enum must contain at least one field")
+  for field in fields:
+    expectKind field, {nnkIdent, nnkEnumFieldDef}
+
+  let enumBody = newNimNode(nnkEnumTy).add(newEmptyNode()).add(fields)
+  var typeDefArgs = [name, newEmptyNode(), enumBody]
+
+  if public:
+    let postNode = newNimNode(nnkPostfix).add(
+      newIdentNode("*"), typeDefArgs[0])
+
+    typeDefArgs[0] = postNode
+
+  if pure:
+    let pragmaNode = newNimNode(nnkPragmaExpr).add(
+      typeDefArgs[0],
+      add(newNimNode(nnkPragma), newIdentNode("pure")))
+
+    typeDefArgs[0] = pragmaNode
+
+  let
+    typeDef   = add(newNimNode(nnkTypeDef), typeDefArgs)
+    typeSect  = add(newNimNode(nnkTypeSection), typeDef)
+
+  return typeSect
+
+proc copyChildrenTo*(src, dest: NimNode) =
+  ## Copy all children from `src` to `dest`.
+  for i in 0 ..< src.len:
+    dest.add src[i].copyNimTree
+
+template expectRoutine(node: NimNode) =
+  expectKind(node, RoutineNodes)
+
+proc name*(someProc: NimNode): NimNode =
+  someProc.expectRoutine
+  result = someProc[0]
+  if result.kind == nnkPostfix:
+    if result[1].kind == nnkAccQuoted:
+      result = result[1][0]
+    else:
+      result = result[1]
+  elif result.kind == nnkAccQuoted:
+    result = result[0]
+
+proc `name=`*(someProc: NimNode; val: NimNode) =
+  someProc.expectRoutine
+  if someProc[0].kind == nnkPostfix:
+    someProc[0][1] = val
+  else: someProc[0] = val
+
+proc params*(someProc: NimNode): NimNode =
+  if someProc.kind == nnkProcTy:
+    someProc[0]
+  else:
+    someProc.expectRoutine
+    someProc[3]
+
+proc `params=`* (someProc: NimNode; params: NimNode) =
+  expectKind(params, nnkFormalParams)
+  if someProc.kind == nnkProcTy:
+    someProc[0] = params
+  else:
+    someProc.expectRoutine
+    someProc[3] = params
+
+proc pragma*(someProc: NimNode): NimNode =
+  ## Get the pragma of a proc type.
+  ## These will be expanded.
+  if someProc.kind == nnkProcTy:
+    result = someProc[1]
+  else:
+    someProc.expectRoutine
+    result = someProc[4]
+proc `pragma=`*(someProc: NimNode; val: NimNode) =
+  ## Set the pragma of a proc type.
+  expectKind(val, {nnkEmpty, nnkPragma})
+  if someProc.kind == nnkProcTy:
+    someProc[1] = val
+  else:
+    someProc.expectRoutine
+    someProc[4] = val
+
+proc addPragma*(someProc, pragma: NimNode) =
+  ## Adds pragma to routine definition.
+  someProc.expectKind(RoutineNodes + {nnkProcTy})
+  var pragmaNode = someProc.pragma
+  if pragmaNode.isNil or pragmaNode.kind == nnkEmpty:
+    pragmaNode = newNimNode(nnkPragma)
+    someProc.pragma = pragmaNode
+  pragmaNode.add(pragma)
+
+template badNodeKind(n, f) =
+  error("Invalid node kind " & $n.kind & " for macros.`" & $f & "`", n)
+
+proc body*(someProc: NimNode): NimNode =
+  case someProc.kind:
+  of RoutineNodes:
+    return someProc[6]
+  of nnkBlockStmt, nnkWhileStmt:
+    return someProc[1]
+  of nnkForStmt:
+    return someProc.last
+  else:
+    badNodeKind someProc, "body"
+
+proc `body=`*(someProc: NimNode, val: NimNode) =
+  case someProc.kind
+  of RoutineNodes:
+    someProc[6] = val
+  of nnkBlockStmt, nnkWhileStmt:
+    someProc[1] = val
+  of nnkForStmt:
+    someProc[len(someProc)-1] = val
+  else:
+    badNodeKind someProc, "body="
+
+proc basename*(a: NimNode): NimNode =
+  ## Pull an identifier from prefix/postfix expressions.
+  case a.kind
+  of nnkIdent: result = a
+  of nnkPostfix, nnkPrefix: result = a[1]
+  of nnkPragmaExpr: result = basename(a[0])
+  else:
+    error("Do not know how to get basename of (" & treeRepr(a) & ")\n" &
+      repr(a), a)
+
+proc `$`*(node: NimNode): string =
+  ## Get the string of an identifier node.
+  case node.kind
+  of nnkPostfix:
+    result = node.basename.strVal & "*"
+  of nnkStrLit..nnkTripleStrLit, nnkCommentStmt, nnkSym, nnkIdent:
+    result = node.strVal
+  of nnkOpenSymChoice, nnkClosedSymChoice, nnkOpenSym:
+    result = $node[0]
+  of nnkAccQuoted:
+    result = ""
+    for i in 0 ..< node.len:
+      result.add(repr(node[i]))
+  else:
+    badNodeKind node, "$"
+
+iterator items*(n: NimNode): NimNode {.inline.} =
+  ## Iterates over the children of the NimNode `n`.
+  for i in 0 ..< n.len:
+    yield n[i]
+
+iterator pairs*(n: NimNode): (int, NimNode) {.inline.} =
+  ## Iterates over the children of the NimNode `n` and its indices.
+  for i in 0 ..< n.len:
+    yield (i, n[i])
+
+iterator children*(n: NimNode): NimNode {.inline.} =
+  ## Iterates over the children of the NimNode `n`.
+  for i in 0 ..< n.len:
+    yield n[i]
+
+template findChild*(n: NimNode; cond: untyped): NimNode {.dirty.} =
+  ## Find the first child node matching condition (or nil).
+  ##   ```nim
+  ##   var res = findChild(n, it.kind == nnkPostfix and
+  ##                          it.basename.ident == ident"foo")
+  ##   ```
+  block:
+    var res: NimNode
+    for it in n.children:
+      if cond:
+        res = it
+        break
+    res
+
+proc insert*(a: NimNode; pos: int; b: NimNode) =
+  ## Insert node `b` into node `a` at `pos`.
+  if len(a)-1 < pos:
+    # add some empty nodes first
+    for i in len(a)-1..pos-2:
+      a.add newEmptyNode()
+    a.add b
+  else:
+    # push the last item onto the list again
+    # and shift each item down to pos up one
+    a.add(a[a.len-1])
+    for i in countdown(len(a) - 3, pos):
+      a[i + 1] = a[i]
+    a[pos] = b
+
+proc `basename=`*(a: NimNode; val: string) =
+  case a.kind
+  of nnkIdent:
+    a.strVal = val
+  of nnkPostfix, nnkPrefix:
+    a[1] = ident(val)
+  of nnkPragmaExpr: `basename=`(a[0], val)
+  else:
+    error("Do not know how to get basename of (" & treeRepr(a) & ")\n" &
+      repr(a), a)
+
+proc postfix*(node: NimNode; op: string): NimNode =
+  newNimNode(nnkPostfix).add(ident(op), node)
+
+proc prefix*(node: NimNode; op: string): NimNode =
+  newNimNode(nnkPrefix).add(ident(op), node)
+
+proc infix*(a: NimNode; op: string;
+            b: NimNode): NimNode =
+  newNimNode(nnkInfix).add(ident(op), a, b)
+
+proc unpackPostfix*(node: NimNode): tuple[node: NimNode; op: string] =
+  node.expectKind nnkPostfix
+  result = (node[1], $node[0])
+
+proc unpackPrefix*(node: NimNode): tuple[node: NimNode; op: string] =
+  node.expectKind nnkPrefix
+  result = (node[1], $node[0])
+
+proc unpackInfix*(node: NimNode): tuple[left: NimNode; op: string; right: NimNode] =
+  expectKind(node, nnkInfix)
+  result = (node[1], $node[0], node[2])
+
+proc copy*(node: NimNode): NimNode =
+  ## An alias for `copyNimTree<#copyNimTree,NimNode>`_.
+  return node.copyNimTree()
+
+proc expectIdent*(n: NimNode, name: string) {.since: (1,1).} =
+  ## Check that `eqIdent(n,name)` holds true. If this is not the
+  ## case, compilation aborts with an error message. This is useful
+  ## for writing macros that check the AST that is passed to them.
+  if not eqIdent(n, name):
+    error("Expected identifier to be `" & name & "` here", n)
+
+proc hasArgOfName*(params: NimNode; name: string): bool =
+  ## Search `nnkFormalParams` for an argument.
+  expectKind(params, nnkFormalParams)
+  for i in 1..<params.len:
+    for j in 0..<params[i].len-2:
+      if name.eqIdent($params[i][j]):
+        return true
+
+proc addIdentIfAbsent*(dest: NimNode, ident: string) =
+  ## Add `ident` to `dest` if it is not present. This is intended for use
+  ## with pragmas.
+  for node in dest.children:
+    case node.kind
+    of nnkIdent:
+      if ident.eqIdent($node): return
+    of nnkExprColonExpr:
+      if ident.eqIdent($node[0]): return
+    else: discard
+  dest.add(ident(ident))
+
+proc boolVal*(n: NimNode): bool {.noSideEffect.} =
+  if n.kind == nnkIntLit: n.intVal != 0
+  else: n == bindSym"true" # hacky solution for now
+
+proc nodeID*(n: NimNode): int {.magic: "NodeId".}
+  ## Returns the id of `n`, when the compiler has been compiled
+  ## with the flag `-d:useNodeids`, otherwise returns `-1`. This
+  ## proc is for the purpose to debug the compiler only.
+
+macro expandMacros*(body: typed): untyped =
+  ## Expands one level of macro - useful for debugging.
+  ## Can be used to inspect what happens when a macro call is expanded,
+  ## without altering its result.
+  ##
+  ## For instance,
+  ##
+  ##   ```nim
+  ##   import std/[sugar, macros]
+  ##
+  ##   let
+  ##     x = 10
+  ##     y = 20
+  ##   expandMacros:
+  ##     dump(x + y)
+  ##   ```
+  ##
+  ## will actually dump `x + y`, but at the same time will print at
+  ## compile time the expansion of the `dump` macro, which in this
+  ## case is `debugEcho ["x + y", " = ", x + y]`.
+  echo body.toStrLit
+  result = body
+
+proc extractTypeImpl(n: NimNode): NimNode =
+  ## attempts to extract the type definition of the given symbol
+  case n.kind
+  of nnkSym: # can extract an impl
+    result = n.getImpl.extractTypeImpl()
+  of nnkObjectTy, nnkRefTy, nnkPtrTy: result = n
+  of nnkBracketExpr:
+    if n.typeKind == ntyTypeDesc:
+      result = n[1].extractTypeImpl()
+    else:
+      doAssert n.typeKind == ntyGenericInst
+      result = n[0].getImpl()
+  of nnkTypeDef:
+    result = n[2]
+  else: error("Invalid node to retrieve type implementation of: " & $n.kind)
+
+proc customPragmaNode(n: NimNode): NimNode =
+  expectKind(n, {nnkSym, nnkDotExpr, nnkBracketExpr, nnkTypeOfExpr, nnkType, nnkCheckedFieldExpr})
+  let
+    typ = n.getTypeInst()
+
+  if typ.kind == nnkBracketExpr and typ.len > 1 and typ[1].kind == nnkProcTy:
+    return typ[1][1]
+  elif typ.typeKind == ntyTypeDesc:
+    let impl = getImpl(
+      if kind(typ[1]) == nnkBracketExpr: typ[1][0]
+      else: typ[1]
+    )
+    if impl.kind == nnkNilLit:
+      return impl
+    elif impl[0].kind == nnkPragmaExpr:
+      return impl[0][1]
+    else:
+      return impl[0] # handle types which don't have macro at all
+
+  if n.kind == nnkSym: # either an variable or a proc
+    let impl = n.getImpl()
+    if impl.kind in RoutineNodes:
+      return impl.pragma
+    elif impl.kind in {nnkIdentDefs, nnkConstDef} and impl[0].kind == nnkPragmaExpr:
+      return impl[0][1]
+    else:
+      let timpl = getImpl(if typ.kind == nnkBracketExpr: typ[0] else: typ)
+      if timpl.len>0 and timpl[0].len>1:
+        return timpl[0][1]
+      else:
+        return timpl
+
+  if n.kind in {nnkDotExpr, nnkCheckedFieldExpr}:
+    let name = $(if n.kind == nnkCheckedFieldExpr: n[0][1] else: n[1])
+    var typInst = getTypeInst(if n.kind == nnkCheckedFieldExpr or n[0].kind == nnkHiddenDeref: n[0][0] else: n[0])
+    while typInst.kind in {nnkVarTy, nnkBracketExpr}: typInst = typInst[0]
+    var typDef = getImpl(typInst)
+    while typDef != nil:
+      typDef.expectKind(nnkTypeDef)
+      let typ = typDef[2].extractTypeImpl()
+      if typ.kind notin {nnkRefTy, nnkPtrTy, nnkObjectTy}: break
+      let isRef = typ.kind in {nnkRefTy, nnkPtrTy}
+      if isRef and typ[0].kind in {nnkSym, nnkBracketExpr}: # defines ref type for another object(e.g. X = ref X)
+        typDef = getImpl(typ[0])
+      else: # object definition, maybe an object directly defined as a ref type
+        let
+          obj = (if isRef: typ[0] else: typ)
+        var identDefsStack = newSeq[NimNode](obj[2].len)
+        for i in 0..<identDefsStack.len: identDefsStack[i] = obj[2][i]
+        while identDefsStack.len > 0:
+          var identDefs = identDefsStack.pop()
+
+          case identDefs.kind
+          of nnkRecList:
+            for child in identDefs.children:
+              identDefsStack.add(child)
+          of nnkRecCase:
+            # Add condition definition
+            identDefsStack.add(identDefs[0])
+            # Add branches
+            for i in 1 ..< identDefs.len:
+              identDefsStack.add(identDefs[i].last)
+          else:
+            for i in 0 .. identDefs.len - 3:
+              let varNode = identDefs[i]
+              if varNode.kind == nnkPragmaExpr:
+                var varName = varNode[0]
+                if varName.kind == nnkPostfix:
+                  # This is a public field. We are skipping the postfix *
+                  varName = varName[1]
+                if eqIdent($varName, name):
+                  return varNode[1]
+
+        if obj[1].kind == nnkOfInherit: # explore the parent object
+          typDef = getImpl(obj[1][0])
+        else:
+          typDef = nil
+
+macro hasCustomPragma*(n: typed, cp: typed{nkSym}): untyped =
+  ## Expands to `true` if expression `n` which is expected to be `nnkDotExpr`
+  ## (if checking a field), a proc or a type has custom pragma `cp`.
+  ##
+  ## See also `getCustomPragmaVal`_.
+  ##
+  ##   ```nim
+  ##   template myAttr() {.pragma.}
+  ##   type
+  ##     MyObj = object
+  ##       myField {.myAttr.}: int
+  ##
+  ##   proc myProc() {.myAttr.} = discard
+  ##
+  ##   var o: MyObj
+  ##   assert(o.myField.hasCustomPragma(myAttr))
+  ##   assert(myProc.hasCustomPragma(myAttr))
+  ##   ```
+  let pragmaNode = customPragmaNode(n)
+  for p in pragmaNode:
+    if (p.kind == nnkSym and p == cp) or
+        (p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym and p[0] == cp):
+      return newLit(true)
+  return newLit(false)
+
+macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped =
+  ## Expands to value of custom pragma `cp` of expression `n` which is expected
+  ## to be `nnkDotExpr`, a proc or a type.
+  ##
+  ## See also `hasCustomPragma`_.
+  ##
+  ##   ```nim
+  ##   template serializationKey(key: string) {.pragma.}
+  ##   type
+  ##     MyObj {.serializationKey: "mo".} = object
+  ##       myField {.serializationKey: "mf".}: int
+  ##   var o: MyObj
+  ##   assert(o.myField.getCustomPragmaVal(serializationKey) == "mf")
+  ##   assert(o.getCustomPragmaVal(serializationKey) == "mo")
+  ##   assert(MyObj.getCustomPragmaVal(serializationKey) == "mo")
+  ##   ```
+  result = nil
+  let pragmaNode = customPragmaNode(n)
+  for p in pragmaNode:
+    if p.kind in nnkPragmaCallKinds and p.len > 0 and p[0].kind == nnkSym and p[0] == cp:
+      if p.len == 2 or (p.len == 3 and p[1].kind == nnkSym and p[1].symKind == nskType):
+        result = p[1]
+      else:
+        let def = p[0].getImpl[3]
+        result = newTree(nnkPar)
+        for i in 1 ..< def.len:
+          let key = def[i][0]
+          let val = p[i]
+          result.add newTree(nnkExprColonExpr, key, val)
+      break
+  if result.kind == nnkEmpty:
+    error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning an empty node results in most cases in a cryptic error,
+
+macro unpackVarargs*(callee: untyped; args: varargs[untyped]): untyped =
+  ## Calls `callee` with `args` unpacked as individual arguments.
+  ## This is useful in 2 cases:
+  ## * when forwarding `varargs[T]` for some typed `T`
+  ## * when forwarding `varargs[untyped]` when `args` can potentially be empty,
+  ##   due to a compiler limitation
+  runnableExamples:
+    template call1(fun: typed; args: varargs[untyped]): untyped =
+      unpackVarargs(fun, args)
+      # when varargsLen(args) > 0: fun(args) else: fun() # this would also work
+    template call2(fun: typed; args: varargs[typed]): untyped =
+      unpackVarargs(fun, args)
+    proc fn1(a = 0, b = 1) = discard (a, b)
+    call1(fn1, 10, 11)
+    call1(fn1) # `args` is empty in this case
+    if false: call2(echo, 10, 11) # would print 1011
+  result = newCall(callee)
+  for i in 0 ..< args.len:
+    result.add args[i]
+
+proc getProjectPath*(): string = discard
+  ## Returns the path to the currently compiling project.
+  ##
+  ## This is not to be confused with `system.currentSourcePath <system.html#currentSourcePath.t>`_
+  ## which returns the path of the source file containing that template
+  ## call.
+  ##
+  ## For example, assume a `dir1/foo.nim` that imports a `dir2/bar.nim`,
+  ## have the `bar.nim` print out both `getProjectPath` and
+  ## `currentSourcePath` outputs.
+  ##
+  ## Now when `foo.nim` is compiled, the `getProjectPath` from
+  ## `bar.nim` will return the `dir1/` path, while the `currentSourcePath`
+  ## will return the path to the `bar.nim` source file.
+  ##
+  ## Now when `bar.nim` is compiled directly, the `getProjectPath`
+  ## will now return the `dir2/` path, and the `currentSourcePath`
+  ## will still return the same path, the path to the `bar.nim` source
+  ## file.
+  ##
+  ## The path returned by this proc is set at compile time.
+  ##
+  ## See also:
+  ## * `getCurrentDir proc <os.html#getCurrentDir>`_
+
+proc getSize*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} =
+  ## Returns the same result as `system.sizeof` if the size is
+  ## known by the Nim compiler. Returns a negative value if the Nim
+  ## compiler does not know the size.
+proc getAlign*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} =
+  ## Returns the same result as `system.alignof` if the alignment
+  ## is known by the Nim compiler. It works on `NimNode` for use
+  ## in macro context. Returns a negative value if the Nim compiler
+  ## does not know the alignment.
+proc getOffset*(arg: NimNode): int {.magic: "NSizeOf", noSideEffect.} =
+  ## Returns the same result as `system.offsetof` if the offset is
+  ## known by the Nim compiler. It expects a resolved symbol node
+  ## from a field of a type. Therefore it only requires one argument
+  ## instead of two. Returns a negative value if the Nim compiler
+  ## does not know the offset.
+
+proc isExported*(n: NimNode): bool {.noSideEffect.} =
+  ## Returns whether the symbol is exported or not.
+
+proc extractDocCommentsAndRunnables*(n: NimNode): NimNode =
+  ## returns a `nnkStmtList` containing the top-level doc comments and
+  ## runnableExamples in `a`, stopping at the first child that is neither.
+  ## Example:
+  ##
+  ##   ```nim
+  ##   import std/macros
+  ##   macro transf(a): untyped =
+  ##     result = quote do:
+  ##       proc fun2*() = discard
+  ##     let header = extractDocCommentsAndRunnables(a.body)
+  ##     # correct usage: rest is appended
+  ##     result.body = header
+  ##     result.body.add quote do: discard # just an example
+  ##     # incorrect usage: nesting inside a nnkStmtList:
+  ##     # result.body = quote do: (`header`; discard)
+  ##
+  ##   proc fun*() {.transf.} =
+  ##     ## first comment
+  ##     runnableExamples: discard
+  ##     runnableExamples: discard
+  ##     ## last comment
+  ##     discard # first statement after doc comments + runnableExamples
+  ##     ## not docgen'd
+  ##   ```
+
+  result = newStmtList()
+  for ni in n:
+    case ni.kind
+    of nnkCommentStmt:
+      result.add ni
+    of nnkCall, nnkCommand:
+      if ni[0].kind == nnkIdent and ni[0].eqIdent "runnableExamples":
+        result.add ni
+      else: break
+    else: break
diff --git a/lib/core/rlocks.nim b/lib/core/rlocks.nim
new file mode 100644
index 000000000..8cb0cef05
--- /dev/null
+++ b/lib/core/rlocks.nim
@@ -0,0 +1,57 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Anatoly Galiulin
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains Nim's support for reentrant locks.
+
+
+when not compileOption("threads") and not defined(nimdoc):
+  when false:
+    # make rlocks modlue consistent with locks module,
+    # so they can replace each other seamlessly.
+    {.error: "Rlocks requires --threads:on option.".}
+
+import std/private/syslocks
+
+type
+  RLock* = SysLock ## Nim lock, re-entrant
+
+proc initRLock*(lock: var RLock) {.inline.} =
+  ## Initializes the given lock.
+  when defined(posix):
+    var a: SysLockAttr
+    initSysLockAttr(a)
+    setSysLockType(a, SysLockType_Reentrant)
+    initSysLock(lock, a.addr)
+  else:
+    initSysLock(lock)
+
+proc deinitRLock*(lock: RLock) {.inline.} =
+  ## Frees the resources associated with the lock.
+  deinitSys(lock)
+
+proc tryAcquire*(lock: var RLock): bool {.inline.} =
+  ## Tries to acquire the given lock. Returns `true` on success.
+  result = tryAcquireSys(lock)
+
+proc acquire*(lock: var RLock) {.inline.} =
+  ## Acquires the given lock.
+  acquireSys(lock)
+
+proc release*(lock: var RLock) {.inline.} =
+  ## Releases the given lock.
+  releaseSys(lock)
+
+template withRLock*(lock: RLock, code: untyped) =
+  ## Acquires the given lock and then executes the code.
+  acquire(lock)
+  {.locks: [lock].}:
+    try:
+      code
+    finally:
+      release(lock)
diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim
new file mode 100644
index 000000000..f2fee91c4
--- /dev/null
+++ b/lib/core/typeinfo.nim
@@ -0,0 +1,723 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Dominik Picheta, Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements an interface to Nim's `runtime type information`:idx:
+## (`RTTI`:idx:). See the `marshal <marshal.html>`_ module for an example of
+## what this allows you to do.
+##
+## .. note:: Even though `Any` and its operations hide the nasty low level
+##   details from its users, it remains inherently unsafe! Also, Nim's
+##   runtime type information will evolve and may eventually be deprecated.
+##   As an alternative approach to programmatically understanding and
+##   manipulating types, consider using the `macros <macros.html>`_ module to
+##   work with the types' AST representation at compile time. See for example
+##   the `getTypeImpl proc <macros.html#getTypeImpl,NimNode>`_. As an alternative
+##   approach to storing arbitrary types at runtime, consider using generics.
+
+runnableExamples:
+  var x: Any
+
+  var i = 42
+  x = i.toAny
+  assert x.kind == akInt
+  assert x.getInt == 42
+
+  var s = @[1, 2, 3]
+  x = s.toAny
+  assert x.kind == akSequence
+  assert x.len == 3
+
+{.push hints: off.}
+
+include "system/inclrtl.nim"
+include "system/hti.nim"
+
+{.pop.}
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  AnyKind* = enum       ## The kind of `Any`.
+    akNone = 0,         ## invalid
+    akBool = 1,         ## bool
+    akChar = 2,         ## char
+    akEnum = 14,        ## enum
+    akArray = 16,       ## array
+    akObject = 17,      ## object
+    akTuple = 18,       ## tuple
+    akSet = 19,         ## set
+    akRange = 20,       ## range
+    akPtr = 21,         ## ptr
+    akRef = 22,         ## ref
+    akSequence = 24,    ## sequence
+    akProc = 25,        ## proc
+    akPointer = 26,     ## pointer
+    akString = 28,      ## string
+    akCString = 29,     ## cstring
+    akInt = 31,         ## int
+    akInt8 = 32,        ## int8
+    akInt16 = 33,       ## int16
+    akInt32 = 34,       ## int32
+    akInt64 = 35,       ## int64
+    akFloat = 36,       ## float
+    akFloat32 = 37,     ## float32
+    akFloat64 = 38,     ## float64
+    akFloat128 = 39,    ## float128
+    akUInt = 40,        ## uint
+    akUInt8 = 41,       ## uint8
+    akUInt16 = 42,      ## uin16
+    akUInt32 = 43,      ## uint32
+    akUInt64 = 44,      ## uint64
+#    akOpt = 44+18       ## the builtin 'opt' type.
+
+  Any* = object
+    ## A type that can represent any nim value.
+    ##
+    ## .. danger:: The wrapped value can be modified with its wrapper! This means
+    ##   that `Any` keeps a non-traced pointer to its wrapped value and
+    ##   **must not** live longer than its wrapped value.
+    value: pointer
+    when defined(js):
+      rawType: PNimType
+    else:
+      rawTypePtr: pointer
+
+  ppointer = ptr pointer
+  pbyteArray = ptr array[0xffff, uint8]
+
+when not defined(gcDestructors):
+  type
+    TGenericSeq {.importc.} = object
+      len, space: int
+      when defined(gogc):
+        elemSize: int
+    PGenSeq = ptr TGenericSeq
+
+  when defined(gogc):
+    const GenericSeqSize = 3 * sizeof(int)
+  else:
+    const GenericSeqSize = 2 * sizeof(int)
+
+else:
+  include system/seqs_v2_reimpl
+
+from std/private/strimpl import cmpNimIdentifier
+
+when not defined(js):
+  template rawType(x: Any): PNimType =
+    cast[PNimType](x.rawTypePtr)
+
+  template `rawType=`(x: var Any, p: PNimType) =
+    x.rawTypePtr = cast[pointer](p)
+
+proc genericAssign(dest, src: pointer, mt: PNimType) {.importCompilerProc.}
+
+when not defined(gcDestructors):
+  proc genericShallowAssign(dest, src: pointer, mt: PNimType) {.importCompilerProc.}
+  proc incrSeq(seq: PGenSeq, elemSize, elemAlign: int): PGenSeq {.importCompilerProc.}
+  proc newObj(typ: PNimType, size: int): pointer {.importCompilerProc.}
+  proc newSeq(typ: PNimType, len: int): pointer {.importCompilerProc.}
+  proc objectInit(dest: pointer, typ: PNimType) {.importCompilerProc.}
+else:
+  proc nimNewObj(size, align: int): pointer {.importCompilerProc.}
+  proc newSeqPayload(cap, elemSize, elemAlign: int): pointer {.importCompilerProc.}
+  proc prepareSeqAddUninit(len: int; p: pointer; addlen, elemSize, elemAlign: int): pointer {.
+    importCompilerProc.}
+  proc zeroNewElements(len: int; p: pointer; addlen, elemSize, elemAlign: int) {.
+    importCompilerProc.}
+
+template `+!!`(a, b): untyped = cast[pointer](cast[int](a) + b)
+
+proc getDiscriminant(aa: pointer, n: ptr TNimNode): int =
+  assert(n.kind == nkCase)
+  var d: int
+  let a = cast[int](aa)
+  case n.typ.size
+  of 1: d = int(cast[ptr uint8](a +% n.offset)[])
+  of 2: d = int(cast[ptr uint16](a +% n.offset)[])
+  of 4: d = int(cast[ptr uint32](a +% n.offset)[])
+  of 8: d = int(cast[ptr uint64](a +% n.offset)[])
+  else: assert(false)
+  return d
+
+proc selectBranch(aa: pointer, n: ptr TNimNode): ptr TNimNode =
+  let discr = getDiscriminant(aa, n)
+  if discr <% n.len:
+    result = n.sons[discr]
+    if result == nil: result = n.sons[n.len]
+    # n.sons[n.len] contains the `else` part (but may be nil)
+  else:
+    result = n.sons[n.len]
+
+proc newAny(value: pointer, rawType: PNimType): Any {.inline.} =
+  result.value = value
+  result.rawType = rawType
+
+proc toAny*[T](x: var T): Any {.inline.} =
+  ## Constructs an `Any` object from `x`. This captures `x`'s address, so
+  ## `x` can be modified with its `Any` wrapper! The caller needs to ensure
+  ## that the wrapper **does not** live longer than `x`!
+  newAny(addr(x), cast[PNimType](getTypeInfo(x)))
+
+proc kind*(x: Any): AnyKind {.inline.} =
+  ## Gets the type kind.
+  result = AnyKind(ord(x.rawType.kind))
+
+proc size*(x: Any): int {.inline.} =
+  ## Returns the size of `x`'s type.
+  result = x.rawType.size
+
+proc baseTypeKind*(x: Any): AnyKind {.inline.} =
+  ## Gets the base type's kind. If `x` has no base type, `akNone` is returned.
+  if x.rawType.base != nil:
+    result = AnyKind(ord(x.rawType.base.kind))
+
+proc baseTypeSize*(x: Any): int {.inline.} =
+  ## Returns the size of `x`'s base type. If `x` has no base type, 0 is returned.
+  if x.rawType.base != nil:
+    result = x.rawType.base.size
+
+proc invokeNew*(x: Any) =
+  ## Performs `new(x)`. `x` needs to represent a `ref`.
+  assert x.rawType.kind == tyRef
+  when defined(gcDestructors):
+    cast[ppointer](x.value)[] = nimNewObj(x.rawType.base.size, x.rawType.base.align)
+  else:
+    var z = newObj(x.rawType, x.rawType.base.size)
+    genericAssign(x.value, addr(z), x.rawType)
+
+proc invokeNewSeq*(x: Any, len: int) =
+  ## Performs `newSeq(x, len)`. `x` needs to represent a `seq`.
+  assert x.rawType.kind == tySequence
+  when defined(gcDestructors):
+    var s = cast[ptr NimSeqV2Reimpl](x.value)
+    s.len = len
+    let elem = x.rawType.base
+    s.p = cast[ptr NimSeqPayloadReimpl](newSeqPayload(len, elem.size, elem.align))
+  else:
+    var z = newSeq(x.rawType, len)
+    genericShallowAssign(x.value, addr(z), x.rawType)
+
+proc extendSeq*(x: Any) =
+  ## Performs `setLen(x, x.len+1)`. `x` needs to represent a `seq`.
+  assert x.rawType.kind == tySequence
+  when defined(gcDestructors):
+    var s = cast[ptr NimSeqV2Reimpl](x.value)
+    let elem = x.rawType.base
+    if s.p == nil or s.p.cap < s.len+1:
+      s.p = cast[ptr NimSeqPayloadReimpl](prepareSeqAddUninit(s.len, s.p, 1, elem.size, elem.align))
+    zeroNewElements(s.len, s.p, 1, elem.size, elem.align)
+    inc s.len
+  else:
+    var y = cast[ptr PGenSeq](x.value)[]
+    var z = incrSeq(y, x.rawType.base.size, x.rawType.base.align)
+    # 'incrSeq' already freed the memory for us and copied over the RC!
+    # So we simply copy the raw pointer into 'x.value':
+    cast[ppointer](x.value)[] = z
+    #genericShallowAssign(x.value, addr(z), x.rawType)
+
+proc setObjectRuntimeType*(x: Any) =
+  ## This needs to be called to set `x`'s runtime object type field.
+  assert x.rawType.kind == tyObject
+  when defined(gcDestructors):
+    cast[ppointer](x.value)[] = x.rawType.typeInfoV2
+  else:
+    objectInit(x.value, x.rawType)
+
+proc skipRange(x: PNimType): PNimType {.inline.} =
+  result = x
+  if result.kind == tyRange: result = result.base
+
+proc align(address, alignment: int): int =
+  result = (address + (alignment - 1)) and not (alignment - 1)
+
+proc `[]`*(x: Any, i: int): Any =
+  ## Accessor for an any `x` that represents an array or a sequence.
+  case x.rawType.kind
+  of tyArray:
+    let bs = x.rawType.base.size
+    if i >=% x.rawType.size div bs:
+      raise newException(IndexDefect, formatErrorIndexBound(i, x.rawType.size div bs))
+    return newAny(x.value +!! i*bs, x.rawType.base)
+  of tySequence:
+    when defined(gcDestructors):
+      var s = cast[ptr NimSeqV2Reimpl](x.value)
+      if i >=% s.len:
+        raise newException(IndexDefect, formatErrorIndexBound(i, s.len-1))
+      let bs = x.rawType.base.size
+      let ba = x.rawType.base.align
+      let headerSize = align(sizeof(int), ba)
+      return newAny(s.p +!! (headerSize+i*bs), x.rawType.base)
+    else:
+      var s = cast[ppointer](x.value)[]
+      if s == nil: raise newException(ValueError, "sequence is nil")
+      let bs = x.rawType.base.size
+      if i >=% cast[PGenSeq](s).len:
+        raise newException(IndexDefect, formatErrorIndexBound(i, cast[PGenSeq](s).len-1))
+      return newAny(s +!! (align(GenericSeqSize, x.rawType.base.align)+i*bs), x.rawType.base)
+  else: assert false
+
+proc `[]=`*(x: Any, i: int, y: Any) =
+  ## Accessor for an any `x` that represents an array or a sequence.
+  case x.rawType.kind
+  of tyArray:
+    var bs = x.rawType.base.size
+    if i >=% x.rawType.size div bs:
+      raise newException(IndexDefect, formatErrorIndexBound(i, x.rawType.size div bs))
+    assert y.rawType == x.rawType.base
+    genericAssign(x.value +!! i*bs, y.value, y.rawType)
+  of tySequence:
+    when defined(gcDestructors):
+      var s = cast[ptr NimSeqV2Reimpl](x.value)
+      if i >=% s.len:
+        raise newException(IndexDefect, formatErrorIndexBound(i, s.len-1))
+      let bs = x.rawType.base.size
+      let ba = x.rawType.base.align
+      let headerSize = align(sizeof(int), ba)
+      assert y.rawType == x.rawType.base
+      genericAssign(s.p +!! (headerSize+i*bs), y.value, y.rawType)
+    else:
+      var s = cast[ppointer](x.value)[]
+      if s == nil: raise newException(ValueError, "sequence is nil")
+      var bs = x.rawType.base.size
+      if i >=% cast[PGenSeq](s).len:
+        raise newException(IndexDefect, formatErrorIndexBound(i, cast[PGenSeq](s).len-1))
+      assert y.rawType == x.rawType.base
+      genericAssign(s +!! (align(GenericSeqSize, x.rawType.base.align)+i*bs), y.value, y.rawType)
+  else: assert false
+
+proc len*(x: Any): int =
+  ## `len` for an any `x` that represents an array or a sequence.
+  case x.rawType.kind
+  of tyArray:
+    result = x.rawType.size div x.rawType.base.size
+  of tySequence:
+    when defined(gcDestructors):
+      result = cast[ptr NimSeqV2Reimpl](x.value).len
+    else:
+      let pgenSeq = cast[PGenSeq](cast[ppointer](x.value)[])
+      if isNil(pgenSeq):
+        result = 0
+      else:
+        result = pgenSeq.len
+  else: assert false
+
+
+proc base*(x: Any): Any =
+  ## Returns the base type of `x` (useful for inherited object types).
+  result.rawType = x.rawType.base
+  result.value = x.value
+
+
+proc isNil*(x: Any): bool =
+  ## `isNil` for an `x` that represents a cstring, proc or
+  ## some pointer type.
+  assert x.rawType.kind in {tyCstring, tyRef, tyPtr, tyPointer, tyProc}
+  result = isNil(cast[ppointer](x.value)[])
+
+const pointerLike =
+  when defined(gcDestructors): {tyCstring, tyRef, tyPtr, tyPointer, tyProc}
+  else: {tyString, tyCstring, tyRef, tyPtr, tyPointer, tySequence, tyProc}
+
+proc getPointer*(x: Any): pointer =
+  ## Retrieves the pointer value out of `x`. `x` needs to be of kind
+  ## `akString`, `akCString`, `akProc`, `akRef`, `akPtr`,
+  ## `akPointer` or `akSequence`.
+  assert x.rawType.kind in pointerLike
+  result = cast[ppointer](x.value)[]
+
+proc setPointer*(x: Any, y: pointer) =
+  ## Sets the pointer value of `x`. `x` needs to be of kind
+  ## `akString`, `akCString`, `akProc`, `akRef`, `akPtr`,
+  ## `akPointer` or `akSequence`.
+  assert x.rawType.kind in pointerLike
+  if y != nil and x.rawType.kind != tyPointer:
+    genericAssign(x.value, y, x.rawType)
+  else:
+    cast[ppointer](x.value)[] = y
+
+proc fieldsAux(p: pointer, n: ptr TNimNode,
+               ret: var seq[tuple[name: cstring, any: Any]]) =
+  case n.kind
+  of nkNone: assert(false)
+  of nkSlot:
+    ret.add((n.name, newAny(p +!! n.offset, n.typ)))
+    assert ret[ret.len()-1][0] != nil
+  of nkList:
+    for i in 0..n.len-1: fieldsAux(p, n.sons[i], ret)
+  of nkCase:
+    var m = selectBranch(p, n)
+    ret.add((n.name, newAny(p +!! n.offset, n.typ)))
+    if m != nil: fieldsAux(p, m, ret)
+
+iterator fields*(x: Any): tuple[name: string, any: Any] =
+  ## Iterates over every active field of `x`. `x` needs to represent an object
+  ## or a tuple.
+  assert x.rawType.kind in {tyTuple, tyObject}
+  let p = x.value
+  var t = x.rawType
+  # XXX BUG: does not work yet, however is questionable anyway
+  when false:
+    if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
+  var ret: seq[tuple[name: cstring, any: Any]]
+  if t.kind == tyObject:
+    while true:
+      fieldsAux(p, t.node, ret)
+      t = t.base
+      if t.isNil: break
+  else:
+    fieldsAux(p, t.node, ret)
+  for name, any in items(ret):
+    yield ($name, any)
+
+proc getFieldNode(p: pointer, n: ptr TNimNode, name: cstring): ptr TNimNode =
+  case n.kind
+  of nkNone: assert(false)
+  of nkSlot:
+    if cmpNimIdentifier(n.name, name) == 0:
+      result = n
+  of nkList:
+    for i in 0..n.len-1:
+      result = getFieldNode(p, n.sons[i], name)
+      if result != nil: break
+  of nkCase:
+    if cmpNimIdentifier(n.name, name) == 0:
+      result = n
+    else:
+      let m = selectBranch(p, n)
+      if m != nil: result = getFieldNode(p, m, name)
+
+proc `[]=`*(x: Any, fieldName: string, value: Any) =
+  ## Sets a field of `x`. `x` needs to represent an object or a tuple.
+  var t = x.rawType
+  # XXX BUG: does not work yet, however is questionable anyway
+  when false:
+    if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
+  assert x.rawType.kind in {tyTuple, tyObject}
+  let n = getFieldNode(x.value, t.node, fieldName)
+  if n != nil:
+    assert n.typ == value.rawType
+    genericAssign(x.value +!! n.offset, value.value, value.rawType)
+  else:
+    raise newException(ValueError, "invalid field name: " & fieldName)
+
+proc `[]`*(x: Any, fieldName: string): Any =
+  ## Gets a field of `x`. `x` needs to represent an object or a tuple.
+  var t = x.rawType
+  # XXX BUG: does not work yet, however is questionable anyway
+  when false:
+    if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[]
+  assert x.rawType.kind in {tyTuple, tyObject}
+  let n = getFieldNode(x.value, t.node, fieldName)
+  if n != nil:
+    result.value = x.value +!! n.offset
+    result.rawType = n.typ
+  elif x.rawType.kind == tyObject and x.rawType.base != nil:
+    return `[]`(newAny(x.value, x.rawType.base), fieldName)
+  else:
+    raise newException(ValueError, "invalid field name: " & fieldName)
+
+proc `[]`*(x: Any): Any =
+  ## Dereference operator for `Any`. `x` needs to represent a ptr or a ref.
+  assert x.rawType.kind in {tyRef, tyPtr}
+  result.value = cast[ppointer](x.value)[]
+  result.rawType = x.rawType.base
+
+proc `[]=`*(x, y: Any) =
+  ## Dereference operator for `Any`. `x` needs to represent a ptr or a ref.
+  assert x.rawType.kind in {tyRef, tyPtr}
+  assert y.rawType == x.rawType.base
+  genericAssign(cast[ppointer](x.value)[], y.value, y.rawType)
+
+proc getInt*(x: Any): int =
+  ## Retrieves the `int` value out of `x`. `x` needs to represent an `int`.
+  assert skipRange(x.rawType).kind == tyInt
+  result = cast[ptr int](x.value)[]
+
+proc getInt8*(x: Any): int8 =
+  ## Retrieves the `int8` value out of `x`. `x` needs to represent an `int8`.
+  assert skipRange(x.rawType).kind == tyInt8
+  result = cast[ptr int8](x.value)[]
+
+proc getInt16*(x: Any): int16 =
+  ## Retrieves the `int16` value out of `x`. `x` needs to represent an `int16`.
+  assert skipRange(x.rawType).kind == tyInt16
+  result = cast[ptr int16](x.value)[]
+
+proc getInt32*(x: Any): int32 =
+  ## Retrieves the `int32` value out of `x`. `x` needs to represent an `int32`.
+  assert skipRange(x.rawType).kind == tyInt32
+  result = cast[ptr int32](x.value)[]
+
+proc getInt64*(x: Any): int64 =
+  ## Retrieves the `int64` value out of `x`. `x` needs to represent an `int64`.
+  assert skipRange(x.rawType).kind == tyInt64
+  result = cast[ptr int64](x.value)[]
+
+proc getBiggestInt*(x: Any): BiggestInt =
+  ## Retrieves the integer value out of `x`. `x` needs to represent
+  ## some integer, a bool, a char, an enum or a small enough bit set.
+  ## The value might be sign-extended to `BiggestInt`.
+  let t = skipRange(x.rawType)
+  case t.kind
+  of tyInt: result = BiggestInt(cast[ptr int](x.value)[])
+  of tyInt8: result = BiggestInt(cast[ptr int8](x.value)[])
+  of tyInt16: result = BiggestInt(cast[ptr int16](x.value)[])
+  of tyInt32: result = BiggestInt(cast[ptr int32](x.value)[])
+  of tyInt64, tyUInt64: result = BiggestInt(cast[ptr int64](x.value)[])
+  of tyBool: result = BiggestInt(cast[ptr bool](x.value)[])
+  of tyChar: result = BiggestInt(cast[ptr char](x.value)[])
+  of tyEnum, tySet:
+    case t.size
+    of 1: result = int64(cast[ptr uint8](x.value)[])
+    of 2: result = int64(cast[ptr uint16](x.value)[])
+    of 4: result = BiggestInt(cast[ptr int32](x.value)[])
+    of 8: result = BiggestInt(cast[ptr int64](x.value)[])
+    else: assert false
+  of tyUInt: result = BiggestInt(cast[ptr uint](x.value)[])
+  of tyUInt8: result = BiggestInt(cast[ptr uint8](x.value)[])
+  of tyUInt16: result = BiggestInt(cast[ptr uint16](x.value)[])
+  of tyUInt32: result = BiggestInt(cast[ptr uint32](x.value)[])
+  else: assert false
+
+proc setBiggestInt*(x: Any, y: BiggestInt) =
+  ## Sets the integer value of `x`. `x` needs to represent
+  ## some integer, a bool, a char, an enum or a small enough bit set.
+  let t = skipRange(x.rawType)
+  case t.kind
+  of tyInt: cast[ptr int](x.value)[] = int(y)
+  of tyInt8: cast[ptr int8](x.value)[] = int8(y)
+  of tyInt16: cast[ptr int16](x.value)[] = int16(y)
+  of tyInt32: cast[ptr int32](x.value)[] = int32(y)
+  of tyInt64, tyUInt64: cast[ptr int64](x.value)[] = int64(y)
+  of tyBool: cast[ptr bool](x.value)[] = y != 0
+  of tyChar: cast[ptr char](x.value)[] = chr(y.int)
+  of tyEnum, tySet:
+    case t.size
+    of 1: cast[ptr uint8](x.value)[] = uint8(y.int)
+    of 2: cast[ptr uint16](x.value)[] = uint16(y.int)
+    of 4: cast[ptr int32](x.value)[] = int32(y)
+    of 8: cast[ptr int64](x.value)[] = y
+    else: assert false
+  of tyUInt: cast[ptr uint](x.value)[] = uint(y)
+  of tyUInt8: cast[ptr uint8](x.value)[] = uint8(y)
+  of tyUInt16: cast[ptr uint16](x.value)[] = uint16(y)
+  of tyUInt32: cast[ptr uint32](x.value)[] = uint32(y)
+  else: assert false
+
+proc getUInt*(x: Any): uint =
+  ## Retrieves the `uint` value out of `x`. `x` needs to represent a `uint`.
+  assert skipRange(x.rawType).kind == tyUInt
+  result = cast[ptr uint](x.value)[]
+
+proc getUInt8*(x: Any): uint8 =
+  ## Retrieves the `uint8` value out of `x`. `x` needs to represent a `uint8`.
+  assert skipRange(x.rawType).kind == tyUInt8
+  result = cast[ptr uint8](x.value)[]
+
+proc getUInt16*(x: Any): uint16 =
+  ## Retrieves the `uint16` value out of `x`. `x` needs to represent a `uint16`.
+  assert skipRange(x.rawType).kind == tyUInt16
+  result = cast[ptr uint16](x.value)[]
+
+proc getUInt32*(x: Any): uint32 =
+  ## Retrieves the `uint32` value out of `x`. `x` needs to represent a `uint32`.
+  assert skipRange(x.rawType).kind == tyUInt32
+  result = cast[ptr uint32](x.value)[]
+
+proc getUInt64*(x: Any): uint64 =
+  ## Retrieves the `uint64` value out of `x`. `x` needs to represent a `uint64`.
+  assert skipRange(x.rawType).kind == tyUInt64
+  result = cast[ptr uint64](x.value)[]
+
+proc getBiggestUint*(x: Any): uint64 =
+  ## Retrieves the unsigned integer value out of `x`. `x` needs to
+  ## represent an unsigned integer.
+  let t = skipRange(x.rawType)
+  case t.kind
+  of tyUInt: result = uint64(cast[ptr uint](x.value)[])
+  of tyUInt8: result = uint64(cast[ptr uint8](x.value)[])
+  of tyUInt16: result = uint64(cast[ptr uint16](x.value)[])
+  of tyUInt32: result = uint64(cast[ptr uint32](x.value)[])
+  of tyUInt64: result = uint64(cast[ptr uint64](x.value)[])
+  else: assert false
+
+proc setBiggestUint*(x: Any; y: uint64) =
+  ## Sets the unsigned integer value of `x`. `x` needs to represent an
+  ## unsigned integer.
+  let t = skipRange(x.rawType)
+  case t.kind:
+  of tyUInt: cast[ptr uint](x.value)[] = uint(y)
+  of tyUInt8: cast[ptr uint8](x.value)[] = uint8(y)
+  of tyUInt16: cast[ptr uint16](x.value)[] = uint16(y)
+  of tyUInt32: cast[ptr uint32](x.value)[] = uint32(y)
+  of tyUInt64: cast[ptr uint64](x.value)[] = uint64(y)
+  else: assert false
+
+proc getChar*(x: Any): char =
+  ## Retrieves the `char` value out of `x`. `x` needs to represent a `char`.
+  let t = skipRange(x.rawType)
+  assert t.kind == tyChar
+  result = cast[ptr char](x.value)[]
+
+proc getBool*(x: Any): bool =
+  ## Retrieves the `bool` value out of `x`. `x` needs to represent a `bool`.
+  let t = skipRange(x.rawType)
+  assert t.kind == tyBool
+  result = cast[ptr bool](x.value)[]
+
+proc skipRange*(x: Any): Any =
+  ## Skips the range information of `x`.
+  assert x.rawType.kind == tyRange
+  result.rawType = x.rawType.base
+  result.value = x.value
+
+proc getEnumOrdinal*(x: Any, name: string): int =
+  ## Gets the enum field ordinal from `name`. `x` needs to represent an enum
+  ## but is only used to access the type information. In case of an error
+  ## `low(int)` is returned.
+  let typ = skipRange(x.rawType)
+  assert typ.kind == tyEnum
+  let n = typ.node
+  let s = n.sons
+  for i in 0 .. n.len-1:
+    if cmpNimIdentifier($s[i].name, name) == 0:
+      if ntfEnumHole notin typ.flags:
+        return i
+      else:
+        return s[i].offset
+  result = low(int)
+
+proc getEnumField*(x: Any, ordinalValue: int): string =
+  ## Gets the enum field name as a string. `x` needs to represent an enum
+  ## but is only used to access the type information. The field name of
+  ## `ordinalValue` is returned.
+  let typ = skipRange(x.rawType)
+  assert typ.kind == tyEnum
+  let e = ordinalValue
+  if ntfEnumHole notin typ.flags:
+    if e <% typ.node.len:
+      return $typ.node.sons[e].name
+  else:
+    # ugh we need a slow linear search:
+    let n = typ.node
+    let s = n.sons
+    for i in 0 .. n.len-1:
+      if s[i].offset == e: return $s[i].name
+  result = $e
+
+proc getEnumField*(x: Any): string =
+  ## Gets the enum field name as a string. `x` needs to represent an enum.
+  result = getEnumField(x, getBiggestInt(x).int)
+
+proc getFloat*(x: Any): float =
+  ## Retrieves the `float` value out of `x`. `x` needs to represent a `float`.
+  assert skipRange(x.rawType).kind == tyFloat
+  result = cast[ptr float](x.value)[]
+
+proc getFloat32*(x: Any): float32 =
+  ## Retrieves the `float32` value out of `x`. `x` needs to represent a `float32`.
+  assert skipRange(x.rawType).kind == tyFloat32
+  result = cast[ptr float32](x.value)[]
+
+proc getFloat64*(x: Any): float64 =
+  ## Retrieves the `float64` value out of `x`. `x` needs to represent a `float64`.
+  assert skipRange(x.rawType).kind == tyFloat64
+  result = cast[ptr float64](x.value)[]
+
+proc getBiggestFloat*(x: Any): BiggestFloat =
+  ## Retrieves the float value out of `x`. `x` needs to represent
+  ## some float. The value is extended to `BiggestFloat`.
+  case skipRange(x.rawType).kind
+  of tyFloat: result = BiggestFloat(cast[ptr float](x.value)[])
+  of tyFloat32: result = BiggestFloat(cast[ptr float32](x.value)[])
+  of tyFloat64: result = BiggestFloat(cast[ptr float64](x.value)[])
+  else: assert false
+
+proc setBiggestFloat*(x: Any, y: BiggestFloat) =
+  ## Sets the float value of `x`. `x` needs to represent
+  ## some float.
+  case skipRange(x.rawType).kind
+  of tyFloat: cast[ptr float](x.value)[] = y
+  of tyFloat32: cast[ptr float32](x.value)[] = y.float32
+  of tyFloat64: cast[ptr float64](x.value)[] = y
+  else: assert false
+
+proc getString*(x: Any): string =
+  ## Retrieves the `string` value out of `x`. `x` needs to represent a `string`.
+  assert x.rawType.kind == tyString
+  when defined(gcDestructors):
+    result = cast[ptr string](x.value)[]
+  else:
+    if not isNil(cast[ptr pointer](x.value)[]):
+      result = cast[ptr string](x.value)[]
+
+proc setString*(x: Any, y: string) =
+  ## Sets the `string` value of `x`. `x` needs to represent a `string`.
+  assert x.rawType.kind == tyString
+  cast[ptr string](x.value)[] = y # also correct for gcDestructors
+
+proc getCString*(x: Any): cstring =
+  ## Retrieves the `cstring` value out of `x`. `x` needs to represent a `cstring`.
+  assert x.rawType.kind == tyCstring
+  result = cast[ptr cstring](x.value)[]
+
+proc assign*(x, y: Any) =
+  ## Copies the value of `y` to `x`. The assignment operator for `Any`
+  ## does NOT do this; it performs a shallow copy instead!
+  assert y.rawType == x.rawType
+  genericAssign(x.value, y.value, y.rawType)
+
+iterator elements*(x: Any): int =
+  ## Iterates over every element of `x`. `x` needs to represent a `set`.
+  assert x.rawType.kind == tySet
+  let typ = x.rawType
+  let p = x.value
+  # "typ.slots.len" field is for sets the "first" field
+  var u: int64
+  case typ.size
+  of 1: u = int64(cast[ptr uint8](p)[])
+  of 2: u = int64(cast[ptr uint16](p)[])
+  of 4: u = int64(cast[ptr uint32](p)[])
+  of 8: u = cast[ptr int64](p)[]
+  else:
+    let a = cast[pbyteArray](p)
+    for i in 0 .. typ.size*8-1:
+      if (int(a[i div 8]) and (1 shl (i mod 8))) != 0:
+        yield i + typ.node.len
+  if typ.size <= 8:
+    for i in 0..sizeof(int64)*8-1:
+      if (u and (1'i64 shl int64(i))) != 0'i64:
+        yield i + typ.node.len
+
+proc inclSetElement*(x: Any, elem: int) =
+  ## Includes an element `elem` in `x`. `x` needs to represent a Nim bitset.
+  assert x.rawType.kind == tySet
+  let typ = x.rawType
+  let p = x.value
+  # "typ.slots.len" field is for sets the "first" field
+  let e = elem - typ.node.len
+  case typ.size
+  of 1:
+    var a = cast[ptr int8](p)
+    a[] = a[] or (1'i8 shl int8(e))
+  of 2:
+    var a = cast[ptr int16](p)
+    a[] = a[] or (1'i16 shl int16(e))
+  of 4:
+    var a = cast[ptr int32](p)
+    a[] = a[] or (1'i32 shl int32(e))
+  of 8:
+    var a = cast[ptr int64](p)
+    a[] = a[] or (1'i64 shl e)
+  else:
+    var a = cast[pbyteArray](p)
+    a[e shr 3] = a[e shr 3] or uint8(1 shl (e and 7))
diff --git a/lib/cycle.h b/lib/cycle.h
index 4d714ba3f..4d714ba3f 100755..100644
--- a/lib/cycle.h
+++ b/lib/cycle.h
diff --git a/lib/deprecated/pure/future.nim b/lib/deprecated/pure/future.nim
new file mode 100644
index 000000000..0e06161f2
--- /dev/null
+++ b/lib/deprecated/pure/future.nim
@@ -0,0 +1,6 @@
+## This module is a deprecated alias for the `sugar` module. Deprecated since 0.19.0.
+
+{.deprecated: "Use the new 'sugar' module instead".}
+
+import std/sugar
+export sugar
diff --git a/lib/deprecated/pure/mersenne.nim b/lib/deprecated/pure/mersenne.nim
new file mode 100644
index 000000000..37c5085b1
--- /dev/null
+++ b/lib/deprecated/pure/mersenne.nim
@@ -0,0 +1,51 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+## The [Mersenne Twister](https://en.wikipedia.org/wiki/Mersenne_Twister)
+## random number generator.
+## .. note:: The procs in this module work at compile-time.
+
+{.deprecated: "use `std/random` instead".}
+
+runnableExamples:
+  var rand = newMersenneTwister(uint32.high)  ## must be "var"
+  doAssert rand.getNum() != rand.getNum()  ## pseudorandom number
+## See also
+## ========
+## * `random module<random.html>`_ for Nim's standard random number generator
+type
+  MersenneTwister* = object
+    ## The Mersenne Twister.
+    mt: array[0..623, uint32]
+    index: int
+
+proc newMersenneTwister*(seed: uint32): MersenneTwister =
+  ## Creates a new `MersenneTwister` with seed `seed`.
+  result.index = 0
+  result.mt[0] = seed
+  for i in 1'u32 .. 623'u32:
+    result.mt[i] = (0x6c078965'u32 * (result.mt[i-1] xor
+                                      (result.mt[i-1] shr 30'u32)) + i)
+
+proc generateNumbers(m: var MersenneTwister) =
+
+  for i in 0..623:
+    var y = (m.mt[i] and 0x80000000'u32) +
+            (m.mt[(i+1) mod 624] and 0x7fffffff'u32)
+    m.mt[i] = m.mt[(i+397) mod 624] xor uint32(y shr 1'u32)
+    if (y mod 2'u32) != 0:
+      m.mt[i] = m.mt[i] xor 0x9908b0df'u32
+
+proc getNum*(m: var MersenneTwister): uint32 =
+  ## Returns the next pseudorandom `uint32`.
+  if m.index == 0:
+    generateNumbers(m)
+  result = m.mt[m.index]
+  m.index = (m.index + 1) mod m.mt.len
+  result = result xor (result shr 11'u32)
+  result = result xor ((result shl 7'u32) and 0x9d2c5680'u32)
+  result = result xor ((result shl 15'u32) and 0xefc60000'u32)
+  result = result xor (result shr 18'u32)
diff --git a/lib/deprecated/pure/ospaths.nim b/lib/deprecated/pure/ospaths.nim
new file mode 100644
index 000000000..43fcb17cc
--- /dev/null
+++ b/lib/deprecated/pure/ospaths.nim
@@ -0,0 +1,22 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module is deprecated since 0.20.0, `import std/os` instead.
+
+{.deprecated: "use `std/os` instead".}
+
+import std/os
+export ReadEnvEffect, WriteEnvEffect, ReadDirEffect, WriteDirEffect, OSErrorCode,
+  doslikeFileSystem, CurDir, ParDir, DirSep, AltSep, PathSep, FileSystemCaseSensitive,
+  ExeExt, ScriptExt, DynlibFormat, ExtSep, joinPath, `/`, splitPath, parentDir,
+  tailDir, isRootDir, parentDirs, `/../`, searchExtPos, splitFile, extractFilename,
+  lastPathPart, changeFileExt, addFileExt, cmpPaths, isAbsolute, unixToNativePath,
+  `==`, `$`, osErrorMsg, raiseOSError, osLastError, getEnv, existsEnv, putEnv,
+  getHomeDir, getConfigDir, getTempDir, expandTilde, quoteShellWindows,
+  quoteShellPosix, quoteShell, quoteShellCommand
diff --git a/lib/deprecated/pure/oswalkdir.nim b/lib/deprecated/pure/oswalkdir.nim
new file mode 100644
index 000000000..57a2cb81d
--- /dev/null
+++ b/lib/deprecated/pure/oswalkdir.nim
@@ -0,0 +1,13 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module is deprecated, `import std/os` instead.
+{.deprecated: "import 'std/os' instead".}
+import std/os
+export PathComponent, walkDir, walkDirRec
diff --git a/lib/deprecated/pure/sums.nim b/lib/deprecated/pure/sums.nim
new file mode 100644
index 000000000..a6ce1b85d
--- /dev/null
+++ b/lib/deprecated/pure/sums.nim
@@ -0,0 +1,80 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 b3liever
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+
+## Accurate summation functions.
+
+{.deprecated: "use the nimble package `sums` instead.".}
+
+runnableExamples:
+  import std/math
+
+  template `~=`(x, y: float): bool = abs(x - y) < 1e-4
+
+  let
+    n = 1_000_000
+    first = 1e10
+    small = 0.1
+  var data = @[first]
+  for _ in 1 .. n:
+    data.add(small)
+
+  let result = first + small * n.float
+
+  doAssert abs(sum(data) - result) > 0.3
+  doAssert sumKbn(data) ~= result
+  doAssert sumPairs(data) ~= result
+
+## See also
+## ========
+## * `math module <math.html>`_ for a standard `sum proc <math.html#sum,openArray[T]>`_
+
+func sumKbn*[T](x: openArray[T]): T =
+  ## Kahan-Babuška-Neumaier summation: O(1) error growth, at the expense
+  ## of a considerable increase in computational cost.
+  ##
+  ## See:
+  ## * https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements
+  if len(x) == 0: return
+  var sum = x[0]
+  var c = T(0)
+  for i in 1 ..< len(x):
+    let xi = x[i]
+    let t = sum + xi
+    if abs(sum) >= abs(xi):
+      c += (sum - t) + xi
+    else:
+      c += (xi - t) + sum
+    sum = t
+  result = sum + c
+
+func sumPairwise[T](x: openArray[T], i0, n: int): T =
+  if n < 128:
+    result = x[i0]
+    for i in i0 + 1 ..< i0 + n:
+      result += x[i]
+  else:
+    let n2 = n div 2
+    result = sumPairwise(x, i0, n2) + sumPairwise(x, i0 + n2, n - n2)
+
+func sumPairs*[T](x: openArray[T]): T =
+  ## Pairwise (cascade) summation of `x[i0:i0+n-1]`, with O(log n) error growth
+  ## (vs O(n) for a simple loop) with negligible performance cost if
+  ## the base case is large enough.
+  ##
+  ## See, e.g.:
+  ## * https://en.wikipedia.org/wiki/Pairwise_summation
+  ## * Higham, Nicholas J. (1993), "The accuracy of floating point
+  ##   summation", SIAM Journal on Scientific Computing 14 (4): 783–799.
+  ##
+  ## In fact, the root-mean-square error growth, assuming random roundoff
+  ## errors, is only O(sqrt(log n)), which is nearly indistinguishable from O(1)
+  ## in practice. See:
+  ## * Manfred Tasche and Hansmartin Zeuner, Handbook of
+  ##   Analytic-Computational Methods in Applied Mathematics (2000).
+  let n = len(x)
+  if n == 0: T(0) else: sumPairwise(x, 0, n)
diff --git a/lib/deps.txt b/lib/deps.txt
new file mode 100644
index 000000000..2a44b5fe2
--- /dev/null
+++ b/lib/deps.txt
@@ -0,0 +1,14 @@
+# Dragonbox.nim and Schubfach.nim
+
+"Dragonbox" is Nim's "float64 to string" algorithm.
+"Schubfach" is Nim's "float32 to string" algorithm. These are based on
+
+https://github.com/abolz/Drachennest/blob/master/src/dragonbox.cc
+https://github.com/abolz/Drachennest/blob/master/src/schubfach_32.cc
+
+commit e6714a39ad331b4489d0b6aaf3968635bff4eb5e
+
+The `.cc` files were translated by c2nim via `--cpp --keepBodies --nep1`
+and then modified to remove the unsafe code.
+
+We used c2nim as of commit f0469c909d9e2e28d59687e394bf5ac862f561b6.
diff --git a/lib/devel/urls.nim b/lib/devel/urls.nim
deleted file mode 100755
index 6acf636f9..000000000
--- a/lib/devel/urls.nim
+++ /dev/null
@@ -1,181 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Parses & constructs URLs.
-
-
-# From the spec:
-#
-#   This specification uses the Augmented Backus-Naur Form (ABNF)
-#   notation of [RFC2234], including the following core ABNF syntax rules
-#   defined by that specification: ALPHA (letters), CR (carriage return),
-#   DIGIT (decimal digits), DQUOTE (double quote), HEXDIG (hexadecimal
-#   digits), LF (line feed), and SP (space).
-#
-#
-#   URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
-#
-#   hier-part     = "//" authority path-abempty
-#                 / path-absolute
-#                 / path-rootless
-#                 / path-empty
-#
-#   URI-reference = URI / relative-ref
-#
-#   absolute-URI  = scheme ":" hier-part [ "?" query ]
-#
-#  relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
-#
-#   relative-part = "//" authority path-abempty
-#                 / path-absolute
-#                 / path-noscheme
-#                 / path-empty
-#
-#   scheme        = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-#
-#   authority     = [ userinfo "@" ] host [ ":" port ]
-#   userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
-#   host          = IP-literal / IPv4address / reg-name
-#   port          = *DIGIT
-#
-#   IP-literal    = "[" ( IPv6address / IPvFuture  ) "]"
-#
-#   IPvFuture     = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
-#
-#   IPv6address   =                            6( h16 ":" ) ls32
-#                 /                       "::" 5( h16 ":" ) ls32
-#                 / [               h16 ] "::" 4( h16 ":" ) ls32
-#                 / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
-#                 / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
-#                 / [ *3( h16 ":" ) h16 ] "::"    h16 ":"   ls32
-#                 / [ *4( h16 ":" ) h16 ] "::"              ls32
-#                 / [ *5( h16 ":" ) h16 ] "::"              h16
-#                 / [ *6( h16 ":" ) h16 ] "::"
-#
-#   h16           = 1*4HEXDIG
-#   ls32          = ( h16 ":" h16 ) / IPv4address
-#   IPv4address   = dec-octet "." dec-octet "." dec-octet "." dec-octet
-#
-#   dec-octet     = DIGIT                 ; 0-9
-#                 / %x31-39 DIGIT         ; 10-99
-#                 / "1" 2DIGIT            ; 100-199
-#                 / "2" %x30-34 DIGIT     ; 200-249
-#                 / "25" %x30-35          ; 250-255
-#
-#   reg-name      = *( unreserved / pct-encoded / sub-delims )
-#
-#   path          = path-abempty    ; begins with "/" or is empty
-#                 / path-absolute   ; begins with "/" but not "//"
-#                 / path-noscheme   ; begins with a non-colon segment
-#                 / path-rootless   ; begins with a segment
-#                 / path-empty      ; zero characters
-#
-#   path-abempty  = *( "/" segment )
-#   path-absolute = "/" [ segment-nz *( "/" segment ) ]
-#   path-noscheme = segment-nz-nc *( "/" segment )
-#   path-rootless = segment-nz *( "/" segment )
-#   path-empty    = 0<pchar>
-#
-#   segment       = *pchar
-#   segment-nz    = 1*pchar
-#   segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
-#                 ; non-zero-length segment without any colon ":"
-#
-#   pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
-#
-#   query         = *( pchar / "/" / "?" )
-#
-#   fragment      = *( pchar / "/" / "?" )
-#
-#   pct-encoded   = "%" HEXDIG HEXDIG
-#
-#   unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
-#   reserved      = gen-delims / sub-delims
-#   gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
-#   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
-#                 / "*" / "+" / "," / ";" / "="
-#
-
-
-import strutils
-
-type
-  TUrl* = tuple[      ## represents a *Uniform Resource Locator* (URL)
-                      ## any optional component is "" if it does not exist
-    protocol: string  ## for example ``http:``
-    username: string  ## for example ``paul`` (optional)
-    password: string  ## for example ``r2d2`` (optional)
-    subdomain: string ## 
-    domain,
-    port,
-    path,
-    query,
-    anchor: string]
-
-proc host*(u: TUrl): string =
-  ## returns the host of the URL
-
-proc parse*(url: string): TURL =
-  const pattern = r"([a-zA-Z]+://)?(.+@)?(.+\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?"
-  var m: array[0..7, string] #Array with the matches
-  discard regexprs.match(url, pattern, m)
- 
-  var msplit = m[2].split(':')
-
-  var username: string = ""
-  var password: string = ""
-  if m[2] != "":
-    username = msplit[0]
-    if msplit.len() == 2:
-      password = msplit[1].replace("@", "")
-
-  var path: string = ""
-  var query: string = ""
-  var anchor: string = ""
-     
-  if m[7] != nil:
-    msplit = m[7].split('?')
-    path = msplit[0]
-    query = ""
-    anchor = ""
-    if msplit.len() == 2:
-      query = "?" & msplit[1]
-     
-    msplit = path.split('#')
-    if msplit.len() == 2:
-      anchor = "#" & msplit[1]
-      path = msplit[0]
-    msplit = query.split('#')
-    if msplit.len() == 2:
-      anchor = "#" & msplit[1]
-      query = msplit[0]
- 
-  result = (protocol: m[1], username: username, password: password,
-    subdomain: m[3], domain: m[4] & m[5], port: m[6], path: path, query: query, anchor: anchor)
- 
-when isMainModule:
-  proc test(r: TURL) =
-    echo("protocol=" & r.protocol)
-    echo("username=" & r.username)
-    echo("password=" & r.password)
-    echo("subdomain=" & r.subdomain)
-    echo("domain=" & r.domain)
-    echo("port=" & r.port)
-    echo("path=" & r.path)
-    echo("query=" & r.query)
-    echo("anchor=" & r.anchor)
-    echo("---------------")
-   
-  var r: TUrl
-  r = parse(r"http://google.co.uk/search?var=bleahdhsad")
-  test(r)
-  r = parse(r"http://dom96:test@google.com:80/search.php?q=562gs6&foo=6gs6&bar=7hs6#test")
-  test(r)
-  r = parse(r"http://www.google.co.uk/search?q=multiple+subdomains&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:pl:official&client=firefox-a")
-  test(r)
\ No newline at end of file
diff --git a/lib/ecmas/dom.nim b/lib/ecmas/dom.nim
deleted file mode 100755
index 6d9224c26..000000000
--- a/lib/ecmas/dom.nim
+++ /dev/null
@@ -1,450 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Declaration of the Document Object Model for the ECMAScript backend.
-##  (c) 2008 Andreas Rumpf
-
-when not defined(ecmascript):
-  {.error: "This module only works on the ECMAScript platform".}
-
-type
-  TEventHandlers* {.importc.} = object of TObject
-    onabort*: proc (event: ref TEvent)
-    onblur*: proc (event: ref TEvent)
-    onchange*: proc (event: ref TEvent)
-    onclick*: proc (event: ref TEvent)
-    ondblclick*: proc (event: ref TEvent)
-    onerror*: proc (event: ref TEvent)
-    onfocus*: proc (event: ref TEvent)
-    onkeydown*: proc (event: ref TEvent)
-    onkeypress*: proc (event: ref TEvent)
-    onkeyup*: proc (event: ref TEvent)
-    onload*: proc (event: ref TEvent)
-    onmousedown*: proc (event: ref TEvent)
-    onmousemove*: proc (event: ref TEvent)
-    onmouseout*: proc (event: ref TEvent)
-    onmouseover*: proc (event: ref TEvent)
-    onmouseup*: proc (event: ref TEvent)
-    onreset*: proc (event: ref TEvent)
-    onselect*: proc (event: ref TEvent)
-    onsubmit*: proc (event: ref TEvent)
-    onunload*: proc (event: ref TEvent)
-
-  TWindow* {.importc.} = object of TEventHandlers
-    document*: ref TDocument
-    event*: ref TEvent
-    history*: ref THistory
-    location*: ref TLocation
-    closed*: bool
-    defaultStatus*: cstring
-    innerHeight*, innerWidth*: int
-    locationbar*: ref TLocationBar
-    menubar*: ref TMenuBar
-    name*: cstring
-    outerHeight*, outerWidth*: int
-    pageXOffset*, pageYOffset*: int
-    personalbar*: ref TPersonalBar
-    scrollbars*: ref TScrollBars
-    statusbar*: ref TStatusBar
-    status*: cstring
-    toolbar*: ref TToolBar
-
-    alert*: proc (msg: cstring)
-    back*: proc ()
-    blur*: proc ()
-    captureEvents*: proc (eventMask: int)
-    clearInterval*: proc (interval: ref TInterval)
-    clearTimeout*: proc (timeout: ref TTimeOut)
-    close*: proc ()
-    confirm*: proc (msg: cstring): bool
-    disableExternalCapture*: proc ()
-    enableExternalCapture*: proc ()
-    find*: proc (text: cstring, caseSensitive = false, backwards = false)
-    focus*: proc ()
-    forward*: proc ()
-    handleEvent*: proc (e: ref TEvent)
-    home*: proc ()
-    moveBy*: proc (x, y: int)
-    moveTo*: proc (x, y: int)
-    open*: proc (uri, windowname: cstring,
-                 properties: cstring = nil): ref TWindow
-    print*: proc ()
-    prompt*: proc (text, default: cstring): cstring
-    releaseEvents*: proc (eventMask: int)
-    resizeBy*: proc (x, y: int)
-    resizeTo*: proc (x, y: int)
-    routeEvent*: proc (event: ref TEvent)
-    scrollBy*: proc (x, y: int)
-    scrollTo*: proc (x, y: int)
-    setInterval*: proc (code: cstring, pause: int): ref TInterval
-    setTimeout*: proc (code: cstring, pause: int): ref TTimeOut
-    stop*: proc ()
-    frames*: seq[TFrame]
-
-  TFrame* {.importc.} = object of TWindow
-
-  TDocument* {.importc.} = object of TEventHandlers
-    alinkColor*: cstring
-    bgColor*: cstring
-    charset*: cstring
-    cookie*: cstring
-    defaultCharset*: cstring
-    fgColor*: cstring
-    lastModified*: cstring
-    linkColor*: cstring
-    referrer*: cstring
-    title*: cstring
-    URL*: cstring
-    vlinkColor*: cstring
-    captureEvents*: proc (eventMask: int)
-    createAttribute*: proc (identifier: cstring): ref TNode
-    createElement*: proc (identifier: cstring): ref TNode
-    createTextNode*: proc (identifier: cstring): ref TNode
-    getElementById*: proc (id: cstring): ref TNode
-    getElementsByName*: proc (name: cstring): seq[ref TNode]
-    getElementsByTagName*: proc (name: cstring): seq[ref TNode]
-    getSelection*: proc (): cstring
-    handleEvent*: proc (event: ref TEvent)
-    open*: proc ()
-    releaseEvents*: proc (eventMask: int)
-    routeEvent*: proc (event: ref TEvent)
-    write*: proc (text: cstring)
-    writeln*: proc (text: cstring)
-    anchors*: seq[ref TAnchor]
-    forms*: seq[ref TForm]
-    images*: seq[ref TImage]
-    applets*: seq[ref TApplet]
-    embeds*: seq[ref TEmbed]
-    links*: seq[ref TLink]
-
-  TLink* {.importc.} = object of TObject
-    name*: cstring
-    target*: cstring
-    text*: cstring
-    x*: int
-    y*: int
-
-  TEmbed* {.importc.} = object of TObject
-    height*: int
-    hspace*: int
-    name*: cstring
-    src*: cstring
-    width*: int
-    `type`*: cstring
-    vspace*: int
-    play*: proc ()
-    stop*: proc ()
-
-  TAnchor* {.importc.} = object of TObject
-    name*: cstring
-    text*: cstring
-    x*, y*: int
-
-  TApplet* {.importc.} = object of TObject
-
-  TElement* {.importc.} = object of TEventHandlers
-    checked*: bool
-    defaultChecked*: bool
-    defaultValue*: cstring
-    disabled*: bool
-    form*: ref TForm
-    name*: cstring
-    readOnly*: bool
-    `type`*: cstring
-    value*: cstring
-    blur*: proc ()
-    click*: proc ()
-    focus*: proc ()
-    handleEvent*: proc (event: ref TEvent)
-    select*: proc ()
-    options*: seq[ref TOption]
-
-  TOption* {.importc.} = object of TObject
-    defaultSelected*: bool
-    selected*: bool
-    selectedIndex*: int
-    text*: cstring
-    value*: cstring
-
-  TForm* {.importc.} = object of TEventHandlers
-    action*: cstring
-    encoding*: cstring
-    `method`*: cstring
-    name*: cstring
-    target*: cstring
-    handleEvent*: proc (event: ref TEvent)
-    reset*: proc ()
-    submit*: proc ()
-    elements*: seq[ref TElement]
-
-  TImage* {.importc.} = object of TEventHandlers
-    border*: int
-    complete*: bool
-    height*: int
-    hspace*: int
-    lowsrc*: cstring
-    name*: cstring
-    src*: cstring
-    vspace*: int
-    width*: int
-    handleEvent*: proc (event: ref TEvent)
-
-  TNodeType* = enum
-    ElementNode = 1,
-    AttributeNode,
-    TextNode,
-    CDATANode,
-    EntityRefNode,
-    EntityNode,
-    ProcessingInstructionNode,
-    CommentNode,
-    DocumentNode,
-    DocumentTypeNode,
-    DocumentFragmentNode,
-    NotationNode
-  TNode* {.importc.} = object of TObject
-    attributes*: seq[ref TNode]
-    childNodes*: seq[ref TNode]
-    data*: cstring
-    firstChild*: ref TNode
-    lastChild*: ref TNode
-    nextSibling*: ref TNode
-    nodeName*: cstring
-    nodeType*: TNodeType
-    nodeValue*: cstring
-    parentNode*: ref TNode
-    previousSibling*: ref TNode
-    appendChild*: proc (child: ref TNode)
-    appendData*: proc (data: cstring)
-    cloneNode*: proc (copyContent: bool)
-    deleteData*: proc (start, len: int)
-    getAttribute*: proc (attr: cstring): cstring
-    getAttributeNode*: proc (attr: cstring): ref TNode
-    getElementsByTagName*: proc (): seq[ref TNode]
-    hasChildNodes*: proc (): bool
-    insertBefore*: proc (newNode, before: ref TNode)
-    insertData*: proc (position: int, data: cstring)
-    removeAttribute*: proc (attr: cstring)
-    removeAttributeNode*: proc (attr: ref TNode)
-    removeChild*: proc (child: ref TNode)
-    replaceChild*: proc (newNode, oldNode: ref TNode)
-    replaceData*: proc (start, len: int, text: cstring)
-    setAttribute*: proc (name, value: cstring)
-    setAttributeNode*: proc (attr: ref TNode)
-    style*: ref TStyle
-
-  TStyle* {.importc.} = object of TObject
-    background*: cstring
-    backgroundAttachment*: cstring
-    backgroundColor*: cstring
-    backgroundImage*: cstring
-    backgroundPosition*: cstring
-    backgroundRepeat*: cstring
-    border*: cstring
-    borderBottom*: cstring
-    borderBottomColor*: cstring
-    borderBottomStyle*: cstring
-    borderBottomWidth*: cstring
-    borderColor*: cstring
-    borderLeft*: cstring
-    borderLeftColor*: cstring
-    borderLeftStyle*: cstring
-    borderLeftWidth*: cstring
-    borderRight*: cstring
-    borderRightColor*: cstring
-    borderRightStyle*: cstring
-    borderRightWidth*: cstring
-    borderStyle*: cstring
-    borderTop*: cstring
-    borderTopColor*: cstring
-    borderTopStyle*: cstring
-    borderTopWidth*: cstring
-    borderWidth*: cstring
-    bottom*: cstring
-    captionSide*: cstring
-    clear*: cstring
-    clip*: cstring
-    color*: cstring
-    cursor*: cstring
-    direction*: cstring
-    display*: cstring
-    emptyCells*: cstring
-    cssFloat*: cstring
-    font*: cstring
-    fontFamily*: cstring
-    fontSize*: cstring
-    fontStretch*: cstring
-    fontStyle*: cstring
-    fontVariant*: cstring
-    fontWeight*: cstring
-    height*: cstring
-    left*: cstring
-    letterSpacing*: cstring
-    lineHeight*: cstring
-    listStyle*: cstring
-    listStyleImage*: cstring
-    listStylePosition*: cstring
-    listStyleType*: cstring
-    margin*: cstring
-    marginBottom*: cstring
-    marginLeft*: cstring
-    marginRight*: cstring
-    marginTop*: cstring
-    maxHeight*: cstring
-    maxWidth*: cstring
-    minHeight*: cstring
-    minWidth*: cstring
-    overflow*: cstring
-    padding*: cstring
-    paddingBottom*: cstring
-    paddingLeft*: cstring
-    paddingRight*: cstring
-    paddingTop*: cstring
-    pageBreakAfter*: cstring
-    pageBreakBefore*: cstring
-    position*: cstring
-    right*: cstring
-    scrollbar3dLightColor*: cstring
-    scrollbarArrowColor*: cstring
-    scrollbarBaseColor*: cstring
-    scrollbarDarkshadowColor*: cstring
-    scrollbarFaceColor*: cstring
-    scrollbarHighlightColor*: cstring
-    scrollbarShadowColor*: cstring
-    scrollbarTrackColor*: cstring
-    tableLayout*: cstring
-    textAlign*: cstring
-    textDecoration*: cstring
-    textIndent*: cstring
-    textTransform*: cstring
-    top*: cstring
-    verticalAlign*: cstring
-    visibility*: cstring
-    width*: cstring
-    wordSpacing*: cstring
-    zIndex*: int
-    getAttribute*: proc (attr: cstring, caseSensitive=false): cstring
-    removeAttribute*: proc (attr: cstring, caseSensitive=false)
-    setAttribute*: proc (attr, value: cstring, caseSensitive=false)
-
-  TEvent* {.importc.} = object of TObject
-    altKey*, ctrlKey*, shiftKey*: bool
-    button*: int
-    clientX*, clientY*: int
-    keyCode*: int
-    layerX*, layerY*: int
-    modifiers*: int
-    ALT_MASK*, CONTROL_MASK*, SHIFT_MASK*, META_MASK*: int
-    offsetX*, offsetY*: int
-    pageX*, pageY*: int
-    screenX*, screenY*: int
-    which*: int
-    `type`*: cstring
-    x*, y*: int
-    ABORT*: int
-    BLUR*: int
-    CHANGE*: int
-    CLICK*: int
-    DBLCLICK*: int
-    DRAGDROP*: int
-    ERROR*: int
-    FOCUS*: int
-    KEYDOWN*: int
-    KEYPRESS*: int
-    KEYUP*: int
-    LOAD*: int
-    MOUSEDOWN*: int
-    MOUSEMOVE*: int
-    MOUSEOUT*: int
-    MOUSEOVER*: int
-    MOUSEUP*: int
-    MOVE*: int
-    RESET*: int
-    RESIZE*: int
-    SELECT*: int
-    SUBMIT*: int
-    UNLOAD*: int
-
-  TLocation* {.importc.} = object of TObject
-    hash*: cstring
-    host*: cstring
-    hostname*: cstring
-    href*: cstring
-    pathname*: cstring
-    port*: cstring
-    protocol*: cstring
-    search*: cstring
-    reload*: proc ()
-    replace*: proc (s: cstring)
-
-  THistory* {.importc.} = object of TObject
-    length*: int
-    back*: proc ()
-    forward*: proc ()
-    go*: proc (pagesToJump: int)
-
-  TNavigator* {.importc.} = object of TObject
-    appCodeName*: cstring
-    appName*: cstring
-    appVersion*: cstring
-    cookieEnabled*: bool
-    language*: cstring
-    platform*: cstring
-    userAgent*: cstring
-    javaEnabled*: proc (): bool
-    mimeTypes*: seq[ref TMimeType]
-
-  TPlugin* {.importc.} = object of TObject
-    description*: cstring
-    filename*: cstring
-    name*: cstring
-
-  TMimeType* {.importc.} = object of TObject
-    description*: cstring
-    enabledPlugin*: ref TPlugin
-    suffixes*: seq[cstring]
-    `type`*: cstring
-
-  TLocationBar* {.importc.} = object of TObject
-    visible*: bool
-  TMenuBar* = TLocationBar
-  TPersonalBar* = TLocationBar
-  TScrollBars* = TLocationBar
-  TToolBar* = TLocationBar
-  TStatusBar* = TLocationBar
-
-  TScreen* {.importc.} = object of TObject
-    availHeight*: int
-    availWidth*: int
-    colorDepth*: int
-    height*: int
-    pixelDepth*: int
-    width*: int
-
-  TTimeOut* {.importc.} = object of TObject
-  TInterval* {.importc.} = object of TObject
-
-var
-  window* {.importc, nodecl.}: ref TWindow
-  document* {.importc, nodecl.}: ref TDocument
-  navigator* {.importc, nodecl.}: ref TNavigator
-  screen* {.importc, nodecl.}: ref TScreen
-
-proc decodeURI*(uri: cstring): cstring {.importc, nodecl.}
-proc encodeURI*(uri: cstring): cstring {.importc, nodecl.}
-
-proc escape*(uri: cstring): cstring {.importc, nodecl.}
-proc unescape*(uri: cstring): cstring {.importc, nodecl.}
-
-proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
-proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
-proc isFinite(x: biggestFloat): bool {.importc, nodecl.}
-proc isNaN(x: biggestFloat): bool {.importc, nodecl.}
-proc parseFloat(s: cstring): biggestFloat {.importc, nodecl.}
-proc parseInt(s: cstring): int {.importc, nodecl.}
diff --git a/lib/experimental/diff.nim b/lib/experimental/diff.nim
new file mode 100644
index 000000000..669e9f613
--- /dev/null
+++ b/lib/experimental/diff.nim
@@ -0,0 +1,339 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements an algorithm to compute the
+## `diff`:idx: between two sequences of lines.
+##
+## - To learn more see `Diff on Wikipedia. <http://wikipedia.org/wiki/Diff>`_
+
+runnableExamples:
+  assert diffInt(
+    [0, 1, 2, 3, 4, 5, 6, 7, 8],
+    [-1, 1, 2, 3, 4, 5, 666, 7, 42]) ==
+    @[Item(startA: 0, startB: 0, deletedA: 1, insertedB: 1),
+      Item(startA: 6, startB: 6, deletedA: 1, insertedB: 1),
+      Item(startA: 8, startB: 8, deletedA: 1, insertedB: 1)]
+
+runnableExamples:
+  # 2 samples of text (from "The Call of Cthulhu" by Lovecraft)
+  let txt0 = """
+abc
+def ghi
+jkl2"""
+  let txt1 = """
+bacx
+abc
+def ghi
+jkl"""
+  assert diffText(txt0, txt1) ==
+    @[Item(startA: 0, startB: 0, deletedA: 0, insertedB: 1),
+      Item(startA: 2, startB: 3, deletedA: 1, insertedB: 1)]
+
+# code owner: Arne Döring
+#
+# This is based on C# code written by Matthias Hertel, http://www.mathertel.de
+#
+# This Class implements the Difference Algorithm published in
+# "An O(ND) Difference Algorithm and its Variations" by Eugene Myers
+# Algorithmica Vol. 1 No. 2, 1986, p 251.
+
+import std/[tables, strutils]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type
+  Item* = object    ## An Item in the list of differences.
+    startA*: int    ## Start Line number in Data A.
+    startB*: int    ## Start Line number in Data B.
+    deletedA*: int  ## Number of changes in Data A.
+    insertedB*: int ## Number of changes in Data B.
+
+  DiffData = object ## Data on one input file being compared.
+    data: seq[int] ## Buffer of numbers that will be compared.
+    modified: seq[bool] ## Array of booleans that flag for modified
+                        ## data. This is the result of the diff.
+                        ## This means deletedA in the first Data or
+                        ## inserted in the second Data.
+
+  Smsrd = object
+    x, y: int
+
+# template to avoid a seq copy. Required until `sink` parameters are ready.
+template newDiffData(initData: seq[int]; L: int): DiffData =
+  DiffData(
+    data: initData,
+    modified: newSeq[bool](L + 2)
+  )
+
+proc len(d: DiffData): int {.inline.} = d.data.len
+
+proc diffCodes(aText: string; h: var Table[string, int]): DiffData =
+  ## This function converts all textlines of the text into unique numbers for every unique textline
+  ## so further work can work only with simple numbers.
+  ## `aText` the input text
+  ## `h` This extern initialized hashtable is used for storing all ever used textlines.
+  ## `trimSpace` ignore leading and trailing space characters
+  ## Returns a array of integers.
+  var lastUsedCode = h.len
+  result.data = newSeq[int]()
+  for s in aText.splitLines:
+    if h.contains s:
+      result.data.add h[s]
+    else:
+      inc lastUsedCode
+      h[s] = lastUsedCode
+      result.data.add lastUsedCode
+  result.modified = newSeq[bool](result.data.len + 2)
+
+proc optimize(data: var DiffData) =
+  ## If a sequence of modified lines starts with a line that contains the same content
+  ## as the line that appends the changes, the difference sequence is modified so that the
+  ## appended line and not the starting line is marked as modified.
+  ## This leads to more readable diff sequences when comparing text files.
+  var startPos = 0
+  while startPos < data.len:
+    while startPos < data.len and not data.modified[startPos]:
+      inc startPos
+    var endPos = startPos
+    while endPos < data.len and data.modified[endPos]:
+      inc endPos
+
+    if endPos < data.len and data.data[startPos] == data.data[endPos]:
+      data.modified[startPos] = false
+      data.modified[endPos] = true
+    else:
+      startPos = endPos
+
+proc sms(dataA: var DiffData; lowerA, upperA: int; dataB: DiffData; lowerB, upperB: int;
+         downVector, upVector: var openArray[int]): Smsrd =
+  ## This is the algorithm to find the Shortest Middle Snake (sms).
+  ## `dataA` sequence A
+  ## `lowerA` lower bound of the actual range in dataA
+  ## `upperA` upper bound of the actual range in dataA (exclusive)
+  ## `dataB` sequence B
+  ## `lowerB` lower bound of the actual range in dataB
+  ## `upperB` upper bound of the actual range in dataB (exclusive)
+  ## `downVector` a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.
+  ## `upVector` a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.
+  ## Returns a MiddleSnakeData record containing x,y and u,v.
+
+  let max = dataA.len + dataB.len + 1
+
+  let downK = lowerA - lowerB # the k-line to start the forward search
+  let upK = upperA - upperB # the k-line to start the reverse search
+
+  let delta = (upperA - lowerA) - (upperB - lowerB)
+  let oddDelta = (delta and 1) != 0
+
+  # The vectors in the publication accepts negative indexes. the vectors implemented here are 0-based
+  # and are access using a specific offset: upOffset upVector and downOffset for downVector
+  let downOffset = max - downK
+  let upOffset = max - upK
+
+  let maxD = ((upperA - lowerA + upperB - lowerB) div 2) + 1
+
+  downVector[downOffset + downK + 1] = lowerA
+  upVector[upOffset + upK - 1] = upperA
+
+  for D in 0 .. maxD:
+    # Extend the forward path.
+    for k in countup(downK - D, downK + D, 2):
+      # find the only or better starting point
+      var x: int
+      if k == downK - D:
+        x = downVector[downOffset + k + 1] # down
+      else:
+        x = downVector[downOffset + k - 1] + 1 # a step to the right
+        if k < downK + D and downVector[downOffset + k + 1] >= x:
+          x = downVector[downOffset + k + 1] # down
+
+      var y = x - k
+
+      # find the end of the furthest reaching forward D-path in diagonal k.
+      while x < upperA and y < upperB and dataA.data[x] == dataB.data[y]:
+        inc x
+        inc y
+
+      downVector[downOffset + k] = x
+
+      # overlap ?
+      if oddDelta and upK - D < k and k < upK + D:
+        if upVector[upOffset + k] <= downVector[downOffset + k]:
+          return Smsrd(x: downVector[downOffset + k],
+                       y: downVector[downOffset + k] - k)
+
+    # Extend the reverse path.
+    for k in countup(upK - D, upK + D, 2):
+      # find the only or better starting point
+      var x: int
+      if k == upK + D:
+        x = upVector[upOffset + k - 1] # up
+      else:
+        x = upVector[upOffset + k + 1] - 1 # left
+        if k > upK - D and upVector[upOffset + k - 1] < x:
+          x = upVector[upOffset + k - 1] # up
+
+      var y = x - k
+      while x > lowerA and y > lowerB and dataA.data[x - 1] == dataB.data[y - 1]:
+        dec x
+        dec y
+
+      upVector[upOffset + k] = x
+
+      # overlap ?
+      if not oddDelta and downK-D <= k and k <= downK+D:
+        if upVector[upOffset + k] <= downVector[downOffset + k]:
+          return Smsrd(x: downVector[downOffset + k],
+                       y: downVector[downOffset + k] - k)
+
+  assert false, "the algorithm should never come here."
+
+proc lcs(dataA: var DiffData; lowerA, upperA: int; dataB: var DiffData; lowerB, upperB: int;
+         downVector, upVector: var openArray[int]) =
+  ## This is the divide-and-conquer implementation of the longes common-subsequence (lcs)
+  ## algorithm.
+  ## The published algorithm passes recursively parts of the A and B sequences.
+  ## To avoid copying these arrays the lower and upper bounds are passed while the sequences stay constant.
+  ## `dataA` sequence A
+  ## `lowerA` lower bound of the actual range in dataA
+  ## `upperA` upper bound of the actual range in dataA (exclusive)
+  ## `dataB` sequence B
+  ## `lowerB` lower bound of the actual range in dataB
+  ## `upperB` upper bound of the actual range in dataB (exclusive)
+  ## `downVector` a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.
+  ## `upVector` a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.
+
+  # make mutable copy:
+  var lowerA = lowerA
+  var lowerB = lowerB
+  var upperA = upperA
+  var upperB = upperB
+
+  # Fast walkthrough equal lines at the start
+  while lowerA < upperA and lowerB < upperB and dataA.data[lowerA] == dataB.data[lowerB]:
+    inc lowerA
+    inc lowerB
+
+  # Fast walkthrough equal lines at the end
+  while lowerA < upperA and lowerB < upperB and dataA.data[upperA - 1] == dataB.data[upperB - 1]:
+    dec upperA
+    dec upperB
+
+  if lowerA == upperA:
+    # mark as inserted lines.
+    while lowerB < upperB:
+      dataB.modified[lowerB] = true
+      inc lowerB
+
+  elif lowerB == upperB:
+    # mark as deleted lines.
+    while lowerA < upperA:
+      dataA.modified[lowerA] = true
+      inc lowerA
+
+  else:
+    # Find the middle snake and length of an optimal path for A and B
+    let smsrd = sms(dataA, lowerA, upperA, dataB, lowerB, upperB, downVector, upVector)
+    # Debug.Write(2, "MiddleSnakeData", String.Format("{0},{1}", smsrd.x, smsrd.y))
+
+    # The path is from LowerX to (x,y) and (x,y) to UpperX
+    lcs(dataA, lowerA, smsrd.x, dataB, lowerB, smsrd.y, downVector, upVector)
+    lcs(dataA, smsrd.x, upperA, dataB, smsrd.y, upperB, downVector, upVector)  # 2002.09.20: no need for 2 points
+
+proc createDiffs(dataA, dataB: DiffData): seq[Item] =
+  ## Scan the tables of which lines are inserted and deleted,
+  ## producing an edit script in forward order.
+  var startA = 0
+  var startB = 0
+  var lineA = 0
+  var lineB = 0
+  while lineA < dataA.len or lineB < dataB.len:
+    if lineA < dataA.len and not dataA.modified[lineA] and
+       lineB < dataB.len and not dataB.modified[lineB]:
+      # equal lines
+      inc lineA
+      inc lineB
+    else:
+      # maybe deleted and/or inserted lines
+      startA = lineA
+      startB = lineB
+
+      while lineA < dataA.len and (lineB >= dataB.len or dataA.modified[lineA]):
+        inc lineA
+
+      while lineB < dataB.len and (lineA >= dataA.len or dataB.modified[lineB]):
+        inc lineB
+
+      if (startA < lineA) or (startB < lineB):
+        result.add Item(startA: startA,
+                        startB: startB,
+                        deletedA: lineA - startA,
+                        insertedB: lineB - startB)
+
+
+proc diffInt*(arrayA, arrayB: openArray[int]): seq[Item] =
+  ## Find the difference in 2 arrays of integers.
+  ##
+  ## `arrayA` A-version of the numbers (usually the old one)
+  ##
+  ## `arrayB` B-version of the numbers (usually the new one)
+  ##
+  ## Returns a sequence of Items that describe the differences.
+
+  # The A-Version of the data (original data) to be compared.
+  var dataA = newDiffData(@arrayA, arrayA.len)
+
+  # The B-Version of the data (modified data) to be compared.
+  var dataB = newDiffData(@arrayB, arrayB.len)
+
+  let max = dataA.len + dataB.len + 1
+  # vector for the (0,0) to (x,y) search
+  var downVector = newSeq[int](2 * max + 2)
+  # vector for the (u,v) to (N,M) search
+  var upVector = newSeq[int](2 * max + 2)
+
+  lcs(dataA, 0, dataA.len, dataB, 0, dataB.len, downVector, upVector)
+  result = createDiffs(dataA, dataB)
+
+proc diffText*(textA, textB: string): seq[Item] =
+  ## Find the difference in 2 text documents, comparing by textlines.
+  ##
+  ## The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents
+  ## each line is converted into a (hash) number. This hash-value is computed by storing all
+  ## textlines into a common hashtable so i can find duplicates in there, and generating a
+  ## new number each time a new textline is inserted.
+  ##
+  ## `textA` A-version of the text (usually the old one)
+  ##
+  ## `textB` B-version of the text (usually the new one)
+  ##
+  ## Returns a seq of Items that describe the differences.
+  # See also `gitutils.diffStrings`.
+  # prepare the input-text and convert to comparable numbers.
+  var h = initTable[string, int]()  # TextA.len + TextB.len  <- probably wrong initial size
+  # The A-Version of the data (original data) to be compared.
+  var dataA = diffCodes(textA, h)
+
+  # The B-Version of the data (modified data) to be compared.
+  var dataB = diffCodes(textB, h)
+
+  h.clear # free up hashtable memory (maybe)
+
+  let max = dataA.len + dataB.len + 1
+  # vector for the (0,0) to (x,y) search
+  var downVector = newSeq[int](2 * max + 2)
+  # vector for the (u,v) to (N,M) search
+  var upVector = newSeq[int](2 * max + 2)
+
+  lcs(dataA, 0, dataA.len, dataB, 0, dataB.len, downVector, upVector)
+
+  optimize(dataA)
+  optimize(dataB)
+  result = createDiffs(dataA, dataB)
diff --git a/lib/genode/alloc.nim b/lib/genode/alloc.nim
new file mode 100644
index 000000000..24fb9954e
--- /dev/null
+++ b/lib/genode/alloc.nim
@@ -0,0 +1,119 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Emery Hemingway
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Low level dataspace allocator for Genode.
+# For interacting with dataspaces outside of the
+# standard library see the Genode Nimble package.
+
+when not defined(genode):
+  {.error: "Genode only module".}
+
+when not declared(GenodeEnv):
+  import genode/env
+
+type RamDataspaceCapability {.
+  importcpp: "Genode::Ram_dataspace_capability", pure.} = object
+
+type
+  Map = object
+    attachment: pointer
+    size: int
+    ds: RamDataspaceCapability
+
+  SlabMeta = object
+    next: ptr MapSlab
+    ds: RamDataspaceCapability
+
+  MapSlab = object
+    meta: SlabMeta
+    maps: array[1,Map]
+
+const SlabBackendSize = 4096
+
+proc ramAvail(env: GenodeEnv): int {.
+  importcpp: "#->pd().avail_ram().value".}
+  ## Return number of bytes available for allocation.
+
+proc capsAvail(env: GenodeEnv): int {.
+  importcpp: "#->pd().avail_caps().value".}
+  ## Return the number of available capabilities.
+  ## Each dataspace allocation consumes a capability.
+
+proc allocDataspace(env: GenodeEnv; size: int): RamDataspaceCapability {.
+  importcpp: "#->pd().alloc(@)".}
+  ## Allocate a dataspace and its capability.
+
+proc attachDataspace(env: GenodeEnv; ds: RamDataspaceCapability): pointer {.
+  importcpp: "#->rm().attach(@)".}
+  ## Attach a dataspace into the component address-space.
+
+proc detachAddress(env: GenodeEnv; p: pointer) {.
+  importcpp: "#->rm().detach(@)".}
+  ## Detach a dataspace from the component address-space.
+
+proc freeDataspace(env: GenodeEnv; ds: RamDataspaceCapability) {.
+  importcpp: "#->pd().free(@)".}
+  ## Free a dataspace.
+
+proc newMapSlab(): ptr MapSlab =
+  let
+    ds = runtimeEnv.allocDataspace SlabBackendSize
+    p = runtimeEnv.attachDataspace ds
+  result = cast[ptr MapSlab](p)
+  result.meta.ds = ds
+
+iterator items(s: ptr MapSlab): ptr Map =
+  let mapCount = (SlabBackendSize - sizeof(SlabMeta)) div sizeof(Map)
+  for i in 0 ..< mapCount:
+    yield s.maps[i].addr
+
+var slabs: ptr MapSlab
+
+proc osAllocPages(size: int): pointer =
+  if slabs.isNil:
+    slabs = newMapSlab()
+  var
+    slab = slabs
+    map: ptr Map
+  let mapCount = (SlabBackendSize - sizeof(SlabMeta)) div sizeof(Map)
+  block findFreeMap:
+    while true:
+      # lookup first free spot in slabs
+      for m in slab.items:
+        if m.attachment.isNil:
+          map = m
+          break findFreeMap
+      if slab.meta.next.isNil:
+        slab.meta.next = newMapSlab()
+          # tack a new slab on the tail
+      slab = slab.meta.next
+        # move to next slab in linked list
+  map.ds = runtimeEnv.allocDataspace size
+  map.size = size
+  map.attachment = runtimeEnv.attachDataspace map.ds
+  result = map.attachment
+
+proc osTryAllocPages(size: int): pointer =
+  if runtimeEnv.ramAvail() >= size and runtimeEnv.capsAvail() > 4:
+    result = osAllocPages size
+
+proc osDeallocPages(p: pointer; size: int) =
+  var slab = slabs
+  while not slab.isNil:
+    # lookup first free spot in slabs
+    for m in slab.items:
+      if m.attachment == p:
+        if m.size != size:
+          echo "cannot partially detach dataspace"
+          rawQuit -1
+        runtimeEnv.detachAddress m.attachment
+        runtimeEnv.freeDataspace m.ds
+        m[] = Map()
+        return
+    slab = slab.meta.next
diff --git a/lib/genode/constructibles.nim b/lib/genode/constructibles.nim
new file mode 100644
index 000000000..3a4a646e0
--- /dev/null
+++ b/lib/genode/constructibles.nim
@@ -0,0 +1,21 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Emery Hemingway
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+type Constructible*[T] {.
+  importcpp: "Genode::Constructible",
+  header: "<util/reconstructible.h>", byref, pure.} = object
+
+proc construct*[T](x: Constructible[T]) {.importcpp.}
+  ## Construct a constructible C++ object.
+
+proc destruct*[T](x: Constructible[T]) {.importcpp.}
+  ## Destruct a constructible C++ object.
+
+proc constructed*[T](x: Constructible[T]): bool {.importcpp.}
+  ## Test if an object is constructed.
diff --git a/lib/genode/entrypoints.nim b/lib/genode/entrypoints.nim
new file mode 100644
index 000000000..0bf5e0e0e
--- /dev/null
+++ b/lib/genode/entrypoints.nim
@@ -0,0 +1,22 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Emery Hemingway
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## See `Genode Foundations - Entrypoint <https://genode.org/documentation/genode-foundations/21.05/functional_specification/Entrypoint.html>`
+## for a description of Entrypoints.
+
+type
+  EntrypointObj {.
+    importcpp: "Genode::Entrypoint",
+    header: "<base/entrypoint.h>",
+    pure.} = object
+  Entrypoint* = ptr EntrypointObj
+    ## Opaque Entrypoint object.
+
+proc ep*(env: GenodeEnv): Entrypoint {.importcpp: "(&#->ep())".}
+  ## Access the entrypoint associated with `env`.
diff --git a/lib/genode/env.nim b/lib/genode/env.nim
new file mode 100644
index 000000000..babe2a8a0
--- /dev/null
+++ b/lib/genode/env.nim
@@ -0,0 +1,29 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Emery Hemingway
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+#
+# This file contains the minimum required definitions
+# for interacting with the initial Genode environment.
+# It is reserved for use only within the standard
+# library. See `componentConstructHook` in the system
+# module for accessing the Genode environment after the
+# standard library has finished initializating.
+#
+
+when not defined(genode):
+  {.error: "Genode only module".}
+
+type
+  GenodeEnvObj* {.importcpp: "Genode::Env", header: "<base/env.h>", pure.} = object
+  GenodeEnvPtr* = ptr GenodeEnvObj
+
+const runtimeEnvSym* = "nim_runtime_env"
+
+when not defined(nimscript):
+  var runtimeEnv* {.importcpp: runtimeEnvSym.}: GenodeEnvPtr
diff --git a/lib/genode/signals.nim b/lib/genode/signals.nim
new file mode 100644
index 000000000..7d1875730
--- /dev/null
+++ b/lib/genode/signals.nim
@@ -0,0 +1,77 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Emery Hemingway
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## See `Genode Foundations - Asynchronous notifications <https://genode.org/documentation/genode-foundations/21.05/architecture/Inter-component_communication.html#Asynchronous_notifications>`
+## for a description of Genode signals.
+
+when not defined(genode) or defined(nimdoc):
+  {.error: "Genode only module".}
+
+import ./entrypoints, ./constructibles
+
+export ep # Entrypoint accessor on GenodeEnv
+
+type
+  SignalContextCapability* {.
+    importcpp: "Genode::Signal_context_capability",
+    header: "<base/signal.h>", pure.} = object
+    ## Capability to an asynchronous signal context.
+
+proc isValid*(cap: SignalContextCapability): bool {.importcpp: "#.valid()".}
+  ## Call the Genode core to check if this `SignalContextCapability` is valid.
+  # TODO: RpcEffect
+
+type
+  HandlerProc = proc () {.closure, gcsafe.}
+
+  SignalHandlerBase {.
+    importcpp: "Nim::SignalHandler",
+    header: "genode_cpp/signals.h",
+    pure.} = object
+
+  SignalHandlerCpp = Constructible[SignalHandlerBase]
+
+  SignalHandlerObj = object
+    cpp: SignalHandlerCpp
+    cb: HandlerProc
+      ## Signal handling procedure called during dispatch.
+
+  SignalHandler* = ref SignalHandlerObj
+    ## Nim object enclosing a Genode signal handler.
+
+proc construct(cpp: SignalHandlerCpp; ep: Entrypoint; sh: SignalHandler) {.importcpp.}
+
+proc cap(cpp: SignalHandlerCpp): SignalContextCapability {.importcpp: "#->cap()".}
+
+proc newSignalHandler*(ep: Entrypoint; cb: HandlerProc): SignalHandler =
+  ## Create a new signal handler. A label is recommended for
+  ## debugging purposes. A signal handler will not be garbage
+  ## collected until after it has been dissolved.
+  result = SignalHandler(cb: cb)
+  result.cpp.construct(ep, result)
+  GCref result
+
+proc dissolve*(sig: SignalHandler) =
+  ## Dissolve signal dispatcher from entrypoint.
+  # TODO: =destroy?
+  destruct sig.cpp
+  sig.cb = nil # lose the callback
+  GCunref sig
+
+proc cap*(sig: SignalHandler): SignalContextCapability =
+  ## Signal context capability. Can be delegated to external components.
+  sig.cpp.cap
+
+proc submit*(cap: SignalContextCapability) {.
+    importcpp: "Genode::Signal_transmitter(#).submit()".}
+  ## Submit a signal to a context capability.
+
+proc nimHandleSignal(p: pointer) {.exportc.} =
+  ## C symbol invoked by entrypoint during signal dispatch.
+  cast[SignalHandler](p).cb()
diff --git a/lib/genode_cpp/signals.h b/lib/genode_cpp/signals.h
new file mode 100644
index 000000000..fa3975d38
--- /dev/null
+++ b/lib/genode_cpp/signals.h
@@ -0,0 +1,39 @@
+/*
+ *
+ *           Nim's Runtime Library
+ *       (c) Copyright 2022 Emery Hemingway
+ *
+ *   See the file "copying.txt", included in this
+ *   distribution, for details about the copyright.
+ *
+ */
+
+#ifndef _NIM_SIGNALS_H_
+#define _NIM_SIGNALS_H_
+
+#include <libc/component.h>
+#include <base/signal.h>
+#include <util/reconstructible.h>
+
+// Symbol for calling back into Nim
+extern "C" void nimHandleSignal(void *arg);
+
+namespace Nim { struct SignalHandler; }
+
+struct Nim::SignalHandler
+{
+	// Pointer to the Nim handler object.
+	void *arg;
+
+	void handle_signal() {
+		Libc::with_libc([this] () { nimHandleSignal(arg); }); }
+
+	Genode::Signal_handler<SignalHandler> handler;
+
+	SignalHandler(Genode::Entrypoint *ep, void *arg)
+	: arg(arg), handler(*ep, *this, &SignalHandler::handle_signal) { }
+
+	Genode::Signal_context_capability cap() { return handler; }
+};
+
+#endif
diff --git a/lib/genode_cpp/syslocks.h b/lib/genode_cpp/syslocks.h
new file mode 100644
index 000000000..b5d5ae694
--- /dev/null
+++ b/lib/genode_cpp/syslocks.h
@@ -0,0 +1,81 @@
+/*
+ *
+ *           Nim's Runtime Library
+ *       (c) Copyright 2017 Emery Hemingway
+ *
+ *   See the file "copying.txt", included in this
+ *   distribution, for details about the copyright.
+ *
+ */
+
+#ifndef _GENODE_CPP__SYSLOCKS_H_
+#define _GENODE_CPP__SYSLOCKS_H_
+
+/* Genode includes */
+#include <base/semaphore.h>
+#include <base/mutex.h>
+
+namespace Nim {
+	struct SysLock;
+	struct SysCond;
+}
+
+struct Nim::SysLock
+{
+	Genode::Mutex _mutex_a, _mutex_b;
+	bool         _locked;
+
+	void acquireSys()
+	{
+		Genode::Mutex::Guard guard(_mutex_a);
+		_locked = true;
+		_mutex_b.acquire();
+	}
+
+	bool tryAcquireSys()
+	{
+		if (_locked)
+			return false;
+
+		Genode::Mutex::Guard guard(_mutex_a);
+
+		if (_locked) {
+			return false;
+		} else {
+			_locked = true;
+			_mutex_b.acquire();
+			return true;
+		}
+	}
+
+	void releaseSys()
+	{
+		Genode::Mutex::Guard guard(_mutex_a);
+		_locked = false;
+		_mutex_b.release();
+	}
+};
+
+struct Nim::SysCond
+{
+	Genode::Semaphore _semaphore;
+
+	void waitSysCond(SysLock &syslock)
+	{
+		syslock.releaseSys();
+		_semaphore.down();
+		syslock.acquireSys();
+	}
+
+	void signalSysCond()
+	{
+		_semaphore.up();
+	}
+
+	void broadcastSysCond()
+	{
+		_semaphore.up();
+	}
+};
+
+#endif
diff --git a/lib/genode_cpp/threads.h b/lib/genode_cpp/threads.h
new file mode 100644
index 000000000..c901efb45
--- /dev/null
+++ b/lib/genode_cpp/threads.h
@@ -0,0 +1,73 @@
+/*
+ *
+ *           Nim's Runtime Library
+ *       (c) Copyright 2017 Emery Hemingway
+ *
+ *   See the file "copying.txt", included in this
+ *   distribution, for details about the copyright.
+ *
+ */
+
+
+#ifndef _GENODE_CPP__THREAD_H_
+#define _GENODE_CPP__THREAD_H_
+
+#include <base/thread.h>
+#include <base/env.h>
+#include <util/reconstructible.h>
+
+namespace Nim { struct SysThread; }
+
+struct Nim::SysThread
+{
+	typedef void (Entry)(void*);
+
+	struct Thread : Genode::Thread
+	{
+		void *_tls;
+
+		Entry *_func;
+		void  *_arg;
+
+		void entry() override {
+			(_func)(_arg); }
+
+		Thread(Genode::Env &env, Genode::size_t stack_size, Entry func, void *arg, int affinity)
+		: Genode::Thread(env, "nim-thread", stack_size,
+		                 env.cpu().affinity_space().location_of_index(affinity),
+		                 Genode::Cpu_session::Weight(Genode::Cpu_session::Weight::DEFAULT_WEIGHT-1),
+		                 env.cpu()),
+		  _func(func), _arg(arg)
+		{
+			Genode::Thread::start();
+		}
+	};
+
+	Genode::Constructible<Thread> _thread;
+
+	void initThread(Genode::Env *env, Genode::size_t stack_size, Entry func, void *arg, int aff) {
+		_thread.construct(*env, stack_size, func, arg, aff); }
+
+	void joinThread() {
+		_thread->join(); }
+
+	static bool offMainThread() {
+		return dynamic_cast<SysThread::Thread*>(Genode::Thread::myself()); }
+
+	static void *threadVarGetValue()
+	{
+		SysThread::Thread *thr =
+			static_cast<SysThread::Thread*>(Genode::Thread::myself());
+		return thr->_tls;
+	}
+
+	static void threadVarSetValue(void *value)
+	{
+		SysThread::Thread *thr =
+			static_cast<SysThread::Thread*>(Genode::Thread::myself());
+		thr->_tls = value;
+	}
+
+};
+
+#endif
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim
deleted file mode 100755
index af8d9d982..000000000
--- a/lib/impure/db_mysql.nim
+++ /dev/null
@@ -1,173 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## A higher level `mySQL`:idx: database wrapper. The same interface is 
-## implemented for other databases too.
-
-import strutils, mysql
-
-type
-  TDbConn* = PMySQL    ## encapsulates a database connection
-  TRow* = seq[string]  ## a row of a dataset
-  EDb* = object of EIO ## exception that is raised if a database error occurs
-
-  TSqlQuery* = distinct string ## an SQL query string
- 
-proc dbError(db: TDbConn) {.noreturn.} = 
-  ## raises an EDb exception.
-  var e: ref EDb
-  new(e)
-  e.msg = $mysql.error(db)
-  raise e
-
-proc dbError*(msg: string) {.noreturn.} = 
-  ## raises an EDb exception with message `msg`.
-  var e: ref EDb
-  new(e)
-  e.msg = msg
-  raise e
-
-when false:
-  proc dbQueryOpt*(db: TDbConn, query: string, args: openarray[string]) =
-    var stmt = mysql_stmt_init(db)
-    if stmt == nil: dbError(db)
-    if mysql_stmt_prepare(stmt, query, len(query)) != 0: 
-      dbError(db)
-    var 
-      binding: seq[MYSQL_BIND]
-    discard mysql_stmt_close(stmt)
-
-proc dbQuote(s: string): string =
-  result = "'"
-  for c in items(s):
-    if c == '\'': add(result, "''")
-    else: add(result, c)
-  add(result, '\'')
-
-proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
-  result = ""
-  var a = 0
-  for c in items(string(formatstr)):
-    if c == '?':
-      add(result, dbQuote(args[a]))
-      inc(a)
-    else: 
-      add(result, c)
-  
-proc TryExec*(db: TDbConn, query: TSqlQuery, args: openarray[string]): bool =
-  ## tries to execute the query and returns true if successful, false otherwise.
-  var q = dbFormat(query, args)
-  return mysql.RealQuery(db, q, q.len) == 0'i32
-
-proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
-  ## executes the query and raises EDB if not successful.
-  var q = dbFormat(query, args)
-  if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
-    
-proc newRow(L: int): TRow = 
-  newSeq(result, L)
-  for i in 0..L-1: result[i] = ""
-  
-proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) =  
-  if row != nil:
-    while mysql.FetchRow(sqlres) != nil: nil
-  mysql.FreeResult(sqlres)
-  
-iterator FastRows*(db: TDbConn, query: TSqlQuery,
-                   args: openarray[string]): TRow =
-  ## executes the query and iterates over the result dataset. This is very 
-  ## fast, but potenially dangerous: If the for-loop-body executes another
-  ## query, the results can be undefined. For MySQL this is the case!.
-  Exec(db, query, args)
-  var sqlres = mysql.UseResult(db)
-  if sqlres != nil:
-    var L = int(mysql.NumFields(sqlres))
-    var result = newRow(L)
-    var row: cstringArray
-    while true:
-      row = mysql.FetchRow(sqlres)
-      if row == nil: break
-      for i in 0..L-1: 
-        setLen(result[i], 0)
-        add(result[i], row[i])
-      yield result
-    properFreeResult(sqlres, row)
-
-proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
-                 args: openarray[string]): seq[TRow] =
-  ## executes the query and returns the whole result dataset.
-  result = @[]
-  Exec(db, query, args)
-  var sqlres = mysql.UseResult(db)
-  if sqlres != nil:
-    var L = int(mysql.NumFields(sqlres))
-    var row: cstringArray
-    var j = 0
-    while true:
-      row = mysql.FetchRow(sqlres)
-      if row == nil: break
-      setLen(result, j+1)
-      newSeq(result[j], L)
-      for i in 0..L-1: result[j][i] = $row[i]
-      inc(j)
-    mysql.FreeResult(sqlres)
-
-iterator Rows*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): TRow =
-  ## same as `FastRows`, but slower and safe.
-  for r in items(GetAllRows(db, query, args)): yield r
-
-proc GetValue*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): string = 
-  ## executes the query and returns the result dataset's the first column 
-  ## of the first row. Returns "" if the dataset contains no rows. This uses
-  ## `FastRows`, so it inherits its fragile behaviour.
-  result = ""
-  for row in FastRows(db, query, args): 
-    result = row[0]
-    break
-
-proc TryInsertID*(db: TDbConn, query: TSqlQuery, 
-                  args: openarray[string]): int64 =
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row or -1 in case of an error.
-  var q = dbFormat(query, args)
-  if mysql.RealQuery(db, q, q.len) != 0'i32: 
-    result = -1'i64
-  else:
-    result = mysql.InsertId(db)
-  
-proc InsertID*(db: TDbConn, query: TSqlQuery, args: openArray[string]): int64 = 
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row.
-  result = TryInsertID(db, query, args)
-  if result < 0: dbError(db)
-
-proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery, 
-                       args: openArray[string]): int64 = 
-  ## runs the query (typically "UPDATE") and returns the
-  ## number of affected rows
-  Exec(db, query, args)
-  result = mysql.AffectedRows(db)
-
-proc Close*(db: TDbConn) = 
-  ## closes the database connection.
-  if db != nil: mysql.Close(db)
-
-proc Open*(connection, user, password, database: string): TDbConn =
-  ## opens a database connection. Raises `EDb` if the connection could not
-  ## be established.
-  result = mysql.Init(nil)
-  if result == nil: dbError("could not open database connection") 
-  if mysql.RealConnect(result, "", user, password, database, 
-                       0'i32, nil, 0) == nil:
-    var errmsg = $mysql.error(result)
-    db_mysql.Close(result)
-    dbError(errmsg)
-
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim
deleted file mode 100755
index 131609a64..000000000
--- a/lib/impure/db_postgres.nim
+++ /dev/null
@@ -1,166 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## A higher level `PostgreSQL`:idx: database wrapper. This interface 
-## is implemented for other databases too.
-
-import strutils, postgres
-
-type
-  TDbConn* = PPGconn   ## encapsulates a database connection
-  TRow* = seq[string]  ## a row of a dataset
-  EDb* = object of EIO ## exception that is raised if a database error occurs
-  
-  TSqlQuery* = distinct string ## an SQL query string
-  
-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
-  new(e)
-  e.msg = $PQerrorMessage(db)
-  raise e
-
-proc dbError*(msg: string) {.noreturn.} = 
-  ## raises an EDb exception with message `msg`.
-  var e: ref EDb
-  new(e)
-  e.msg = msg
-  raise e
-
-proc dbQuote(s: string): string =
-  result = "'"
-  for c in items(s):
-    if c == '\'': add(result, "''")
-    else: add(result, c)
-  add(result, '\'')
-
-proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
-  result = ""
-  var a = 0
-  for c in items(string(formatstr)):
-    if c == '?':
-      add(result, dbQuote(args[a]))
-      inc(a)
-    else: 
-      add(result, c)
-  
-proc TryExec*(db: TDbConn, query: TSqlQuery, 
-              args: openarray[string]): bool =
-  ## tries to execute the query and returns true if successful, false otherwise.
-  var q = dbFormat(query, args)
-  var res = PQExec(db, q)
-  result = PQresultStatus(res) == PGRES_COMMAND_OK
-  PQclear(res)
-
-proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
-  ## executes the query and raises EDB if not successful.
-  var q = dbFormat(query, args)
-  var res = PQExec(db, q)
-  if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
-  PQclear(res)
-  
-proc newRow(L: int): TRow =
-  newSeq(result, L)
-  for i in 0..L-1: result[i] = ""
-  
-proc setupQuery(db: TDbConn, query: TSqlQuery, 
-                args: openarray[string]): PPGresult = 
-  var q = dbFormat(query, args)
-  result = PQExec(db, q)
-  if PQresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
-  
-proc setRow(res: PPGresult, r: var TRow, line, cols: int) =
-  for col in 0..cols-1:
-    setLen(r[col], 0)
-    var x = PQgetvalue(res, line, col)
-    add(r[col], x)
-  
-iterator FastRows*(db: TDbConn, query: TSqlQuery,
-                   args: openarray[string]): TRow =
-  ## executes the query and iterates over the result dataset. This is very 
-  ## fast, but potenially dangerous: If the for-loop-body executes another
-  ## query, the results can be undefined. For Postgres it is safe though.
-  var res = setupQuery(db, query, args)
-  var L = int(PQnfields(res))
-  var result = newRow(L)
-  for i in 0..PQntuples(res)-1:
-    setRow(res, result, i, L)
-    yield result
-  PQclear(res)
-
-proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
-                 args: openarray[string]): seq[TRow] =
-  ## executes the query and returns the whole result dataset.
-  result = @[]
-  for r in FastRows(db, query, args):
-    result.add(r)
-
-iterator Rows*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): TRow =
-  ## same as `FastRows`, but slower and safe.
-  for r in items(GetAllRows(db, query, args)): yield r
-
-proc GetValue*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): string = 
-  ## executes the query and returns the result dataset's the first column 
-  ## of the first row. Returns "" if the dataset contains no rows.
-  var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
-  result = if isNil(x): "" else: $x
-  
-proc TryInsertID*(db: TDbConn, query: TSqlQuery, 
-                  args: openarray[string]): int64 =
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row or -1 in case of an error. For Postgre this adds
-  ## ``RETURNING id`` to the query, so it only works if your primary key is
-  ## named ``id``. 
-  var val = GetValue(db, TSqlQuery(string(query) & " RETURNING id"), args)
-  if val.len > 0:
-    result = ParseBiggestInt(val)
-  else:
-    result = -1
-
-proc InsertID*(db: TDbConn, query: TSqlQuery, 
-               args: openArray[string]): int64 = 
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row. For Postgre this adds
-  ## ``RETURNING id`` to the query, so it only works if your primary key is
-  ## named ``id``. 
-  result = TryInsertID(db, query, args)
-  if result < 0: dbError(db)
-  
-proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery, 
-                       args: openArray[string]): int64 = 
-  ## executes the query (typically "UPDATE") and returns the
-  ## number of affected rows.
-  var q = dbFormat(query, args)
-  var res = PQExec(db, q)
-  if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
-  result = parseBiggestInt($PQcmdTuples(res))
-  PQclear(res)
-
-proc Close*(db: TDbConn) = 
-  ## closes the database connection.
-  if db != nil: PQfinish(db)
-
-proc Open*(connection, user, password, database: string): TDbConn =
-  ## opens a database connection. Raises `EDb` if the connection could not
-  ## be established.
-  result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
-  if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil
-
-
diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim
deleted file mode 100755
index 8c2de0dc7..000000000
--- a/lib/impure/db_sqlite.nim
+++ /dev/null
@@ -1,178 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## A higher level `SQLite`:idx: database wrapper. This interface 
-## is implemented for other databases too.
-
-import strutils, sqlite3
-
-type
-  TDbConn* = PSqlite3  ## encapsulates a database connection
-  TRow* = seq[string]  ## a row of a dataset
-  EDb* = object of EIO ## exception that is raised if a database error occurs
-  
-  TSqlQuery* = distinct string ## an SQL query string
-  
-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
-  new(e)
-  e.msg = $sqlite3.errmsg(db)
-  raise e
-
-proc dbError*(msg: string) {.noreturn.} = 
-  ## raises an EDb exception with message `msg`.
-  var e: ref EDb
-  new(e)
-  e.msg = msg
-  raise e
-
-proc dbQuote(s: string): string =
-  result = "'"
-  for c in items(s):
-    if c == '\'': add(result, "''")
-    else: add(result, c)
-  add(result, '\'')
-
-proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
-  result = ""
-  var a = 0
-  for c in items(string(formatstr)):
-    if c == '?':
-      add(result, dbQuote(args[a]))
-      inc(a)
-    else: 
-      add(result, c)
-  
-proc TryExec*(db: TDbConn, query: TSqlQuery, 
-              args: openarray[string]): bool =
-  ## tries to execute the query and returns true if successful, false otherwise.
-  var q = dbFormat(query, args)
-  var stmt: sqlite3.PStmt
-  if prepare_v2(db, q, q.len, stmt, nil) == SQLITE_OK:
-    if step(stmt) == SQLITE_DONE:
-      result = finalize(stmt) == SQLITE_OK
-
-proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
-  ## executes the query and raises EDB if not successful.
-  if not TryExec(db, query, args): dbError(db)
-  
-proc newRow(L: int): TRow =
-  newSeq(result, L)
-  for i in 0..L-1: result[i] = ""
-  
-proc setupQuery(db: TDbConn, query: TSqlQuery, 
-                args: openarray[string]): PStmt = 
-  var q = dbFormat(query, args)
-  if prepare_v2(db, q, q.len, result, nil) != SQLITE_OK: dbError(db)
-  
-proc setRow(stmt: PStmt, r: var TRow, cols: int) =
-  for col in 0..cols-1:
-    setLen(r[col], column_bytes(stmt, col)) # set capacity
-    setLen(r[col], 0)
-    add(r[col], column_text(stmt, col))
-  
-iterator FastRows*(db: TDbConn, query: TSqlQuery,
-                   args: openarray[string]): TRow =
-  ## executes the query and iterates over the result dataset. This is very 
-  ## fast, but potenially dangerous: If the for-loop-body executes another
-  ## query, the results can be undefined. For Sqlite it is safe though.
-  var stmt = setupQuery(db, query, args)
-  var L = int(columnCount(stmt))
-  var result = newRow(L)
-  while step(stmt) == SQLITE_ROW: 
-    setRow(stmt, result, L)
-    yield result
-  if finalize(stmt) != SQLITE_OK: dbError(db)
-
-proc GetAllRows*(db: TDbConn, query: TSqlQuery, 
-                 args: openarray[string]): seq[TRow] =
-  ## executes the query and returns the whole result dataset.
-  result = @[]
-  for r in FastRows(db, query, args):
-    result.add(r)
-
-iterator Rows*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): TRow =
-  ## same as `FastRows`, but slower and safe.
-  for r in FastRows(db, query, args): yield r
-
-proc GetValue*(db: TDbConn, query: TSqlQuery, 
-               args: openarray[string]): string = 
-  ## executes the query and returns the result dataset's the first column 
-  ## of the first row. Returns "" if the dataset contains no rows.
-  var stmt = setupQuery(db, query, args)
-  if step(stmt) == SQLITE_ROW: 
-    result = newString(column_bytes(stmt, 0))
-    setLen(result, 0)
-    add(result, column_text(stmt, 0))
-    if finalize(stmt) != SQLITE_OK: dbError(db)
-  else:
-    result = ""
-  
-proc TryInsertID*(db: TDbConn, query: TSqlQuery, 
-                  args: openarray[string]): int64 =
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row or -1 in case of an error. 
-  if tryExec(db, query, args): 
-    result = last_insert_rowid(db)
-  else:
-    result = -1
-
-proc InsertID*(db: TDbConn, query: TSqlQuery, 
-               args: openArray[string]): int64 = 
-  ## executes the query (typically "INSERT") and returns the 
-  ## generated ID for the row. For Postgre this adds
-  ## ``RETURNING id`` to the query, so it only works if your primary key is
-  ## named ``id``. 
-  result = TryInsertID(db, query, args)
-  if result < 0: dbError(db)
-  
-proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery, 
-                       args: openArray[string]): int64 = 
-  ## executes the query (typically "UPDATE") and returns the
-  ## number of affected rows.
-  Exec(db, query, args)
-  result = changes(db)
-
-proc Close*(db: TDbConn) = 
-  ## closes the database connection.
-  if sqlite3.close(db) != SQLITE_OK:
-    dbError(db)
-    
-proc Open*(connection, user, password, database: string): TDbConn =
-  ## opens a database connection. Raises `EDb` if the connection could not
-  ## be established. Only the ``connection`` parameter is used for ``sqlite``.
-  var db: TDbConn
-  if sqlite3.open(connection, db) == SQLITE_OK:
-    return db
-  else:
-    dbError(db)
-   
-when isMainModule:
-  var db = open("db.sql", "", "", "")
-  Exec(db, sql"create table tbl1(one varchar(10), two smallint)", [])
-  exec(db, sql"insert into tbl1 values('hello!',10)", [])
-  exec(db, sql"insert into tbl1 values('goodbye', 20)", [])
-  #db.query("create table tbl1(one varchar(10), two smallint)")
-  #db.query("insert into tbl1 values('hello!',10)")
-  #db.query("insert into tbl1 values('goodbye', 20)")
-  for r in db.rows(sql"select * from tbl1", []):
-    echo(r[0], r[1])
-  
-  db_sqlite.close(db)
diff --git a/lib/impure/dialogs.nim b/lib/impure/dialogs.nim
deleted file mode 100755
index ef52d573a..000000000
--- a/lib/impure/dialogs.nim
+++ /dev/null
@@ -1,223 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-
-## This module implements portable dialogs for Nimrod; the implementation
-## builds on the GTK interface. On Windows, native dialogs are shown if
-## appropriate.
-
-import
-  glib2, gtk2
-
-when defined(Windows):
-  import windows, ShellAPI, os
-
-proc info*(window: PWindow, msg: string) =
-  ## Shows an information message to the user. The process waits until the
-  ## user presses the OK button.
-  when defined(Windows):
-    discard MessageBoxA(0, msg, "Information", MB_OK or MB_ICONINFORMATION)
-  else:
-    var dialog = message_dialog_new(window,
-                DIALOG_MODAL or DIALOG_DESTROY_WITH_PARENT,
-                MESSAGE_INFO, BUTTONS_OK, "%s", cstring(msg))
-    setTitle(dialog, "Information")
-    discard run(dialog)
-    destroy(PWidget(dialog))
-
-proc warning*(window: PWindow, msg: string) =
-  ## Shows a warning message to the user. The process waits until the user
-  ## presses the OK button.
-  when defined(Windows):
-    discard MessageBoxA(0, msg, "Warning", MB_OK or MB_ICONWARNING)
-  else:
-    var dialog = DIALOG(message_dialog_new(window,
-                DIALOG_MODAL or DIALOG_DESTROY_WITH_PARENT,
-                MESSAGE_WARNING, BUTTONS_OK, "%s", cstring(msg)))
-    setTitle(dialog, "Warning")
-    discard run(dialog)
-    destroy(PWidget(dialog))
-
-proc error*(window: PWindow, msg: string) =
-  ## Shows an error message to the user. The process waits until the user
-  ## presses the OK button.
-  when defined(Windows):
-    discard MessageBoxA(0, msg, "Error", MB_OK or MB_ICONERROR)
-  else:
-    var dialog = DIALOG(message_dialog_new(window,
-                DIALOG_MODAL or DIALOG_DESTROY_WITH_PARENT,
-                MESSAGE_ERROR, BUTTONS_OK, "%s", cstring(msg)))
-    setTitle(dialog, "Error")
-    discard run(dialog)
-    destroy(PWidget(dialog))
-
-
-proc ChooseFileToOpen*(window: PWindow, root: string = ""): string =
-  ## Opens a dialog that requests a filename from the user. Returns ""
-  ## if the user closed the dialog without selecting a file. On Windows,
-  ## the native dialog is used, else the GTK dialog is used.
-  when defined(Windows):
-    var
-      opf: TOPENFILENAME
-      buf: array [0..2047, char]
-    opf.lStructSize = sizeof(opf)
-    if root.len > 0:
-      opf.lpstrInitialDir = root
-    opf.lpstrFilter = "All Files\0*.*\0\0"
-    opf.flags = OFN_FILEMUSTEXIST
-    opf.lpstrFile = buf
-    opf.nMaxFile = sizeof(buf)
-    var res = GetOpenFileName(addr(opf))
-    if res != 0:
-      result = $buf
-    else:
-      result = ""
-  else:
-    var chooser = file_chooser_dialog_new("Open File", window,
-                FILE_CHOOSER_ACTION_OPEN, 
-                STOCK_CANCEL, RESPONSE_CANCEL,
-                STOCK_OPEN, RESPONSE_OK, nil)
-    if root.len > 0:
-      discard set_current_folder(chooser, root)
-    if run(chooser) == cint(RESPONSE_OK):
-      var x = get_filename(chooser)
-      result = $x
-      g_free(x)
-    else:
-      result = ""
-    destroy(PWidget(chooser))
-
-proc ChooseFilesToOpen*(window: PWindow, root: string = ""): seq[string] =
-  ## Opens a dialog that requests filenames from the user. Returns ``@[]``
-  ## if the user closed the dialog without selecting a file. On Windows,
-  ## the native dialog is used, else the GTK dialog is used.
-  when defined(Windows):
-    var
-      opf: TOPENFILENAME
-      buf: array [0..2047*4, char]
-    opf.lStructSize = sizeof(opf)
-    if root.len > 0:
-      opf.lpstrInitialDir = root
-    opf.lpstrFilter = "All Files\0*.*\0\0"
-    opf.flags = OFN_FILEMUSTEXIST or OFN_ALLOWMULTISELECT or OFN_EXPLORER
-    opf.lpstrFile = buf
-    opf.nMaxFile = sizeof(buf)
-    var res = GetOpenFileName(addr(opf))
-    result = @[]
-    if res != 0:
-      # parsing the result is horrible:
-      var
-        i = 0
-        s: string
-        path = ""
-      while buf[i] != '\0':
-        add(path, buf[i])
-        inc(i)
-      inc(i)
-      if buf[i] != '\0':
-        while true:
-          s = ""
-          while buf[i] != '\0':
-            add(s, buf[i])
-            inc(i)
-          add(result, s)
-          inc(i)
-          if buf[i] == '\0': break
-        for i in 0..result.len-1: result[i] = os.joinPath(path, result[i])
-  else:
-    var chooser = file_chooser_dialog_new("Open Files", window,
-                FILE_CHOOSER_ACTION_OPEN,
-                STOCK_CANCEL, RESPONSE_CANCEL,
-                STOCK_OPEN, RESPONSE_OK, nil)
-    if root.len > 0:
-      discard set_current_folder(chooser, root)
-    set_select_multiple(chooser, true)
-    result = @[]
-    if run(chooser) == cint(RESPONSE_OK):
-      var L = get_filenames(chooser)
-      var it = L
-      while it != nil:
-        add(result, $cast[cstring](it.data))
-        g_free(it.data)
-        it = it.next
-      free(L)
-    destroy(PWidget(chooser))
-
-
-proc ChooseFileToSave*(window: PWindow, root: string = ""): string =
-  ## Opens a dialog that requests a filename to save to from the user.
-  ## Returns "" if the user closed the dialog without selecting a file.
-  ## On Windows, the native dialog is used, else the GTK dialog is used.
-  when defined(Windows):
-    var
-      opf: TOPENFILENAME
-      buf: array [0..2047, char]
-    opf.lStructSize = sizeof(opf)
-    if root.len > 0:
-      opf.lpstrInitialDir = root
-    opf.lpstrFilter = "All Files\0*.*\0\0"
-    opf.flags = OFN_OVERWRITEPROMPT
-    opf.lpstrFile = buf
-    opf.nMaxFile = sizeof(buf)
-    var res = GetSaveFileName(addr(opf))
-    if res != 0:
-      result = $buf
-    else:
-      result = ""
-  else:
-    var chooser = file_chooser_dialog_new("Save File", window,
-                FILE_CHOOSER_ACTION_SAVE,
-                STOCK_CANCEL, RESPONSE_CANCEL,
-                STOCK_OPEN, RESPONSE_OK, nil)
-    if root.len > 0:
-      discard set_current_folder(chooser, root)
-    set_do_overwrite_confirmation(chooser, true)
-    if run(chooser) == cint(RESPONSE_OK):
-      var x = get_filename(chooser)
-      result = $x
-      g_free(x)
-    else:
-      result = ""
-    destroy(PWidget(chooser))
-
-
-proc ChooseDir*(window: PWindow, root: string = ""): string =
-  ## Opens a dialog that requests a directory from the user.
-  ## Returns "" if the user closed the dialog without selecting a directory.
-  ## On Windows, the native dialog is used, else the GTK dialog is used.
-  when defined(Windows):
-    var
-      lpItemID: PItemIDList
-      BrowseInfo: TBrowseInfo
-      DisplayName: array [0..MAX_PATH, char]
-      TempPath: array [0..MAX_PATH, char]
-    Result = ""
-    #BrowseInfo.hwndOwner = Application.Handle
-    BrowseInfo.pszDisplayName = DisplayName
-    BrowseInfo.ulFlags = 1 #BIF_RETURNONLYFSDIRS
-    lpItemID = SHBrowseForFolder(cast[LPBrowseInfo](addr(BrowseInfo)))
-    if lpItemId != nil:
-      discard SHGetPathFromIDList(lpItemID, TempPath)
-      Result = $TempPath
-      discard GlobalFreePtr(lpItemID)
-  else:
-    var chooser = file_chooser_dialog_new("Select Directory", window,
-                FILE_CHOOSER_ACTION_SELECT_FOLDER,
-                STOCK_CANCEL, RESPONSE_CANCEL,
-                STOCK_OPEN, RESPONSE_OK, nil)
-    if root.len > 0:
-      discard set_current_folder(chooser, root)
-    if run(chooser) == cint(RESPONSE_OK):
-      var x = get_filename(chooser)
-      result = $x
-      g_free(x)
-    else:
-      result = ""
-    destroy(PWidget(chooser))
-
diff --git a/lib/impure/graphics.nim b/lib/impure/graphics.nim
deleted file mode 100755
index 2c9f2f49a..000000000
--- a/lib/impure/graphics.nim
+++ /dev/null
@@ -1,522 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf, Dominik Picheta
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements graphical output for Nimrod; the current
-## implementation uses SDL but the interface is meant to support multiple
-## backends some day. 
-
-import colors, math
-from sdl import PSurface # Bug
-from sdl_ttf import OpenFont, closeFont
-
-type
-  TRect* = tuple[x, y, width, height: int]
-  TPoint* = tuple[x, y: int]
-
-  PSurface* = ref TSurface ## a surface to draw onto
-  TSurface {.pure, final.} = object
-    w, h: int
-    s: sdl.PSurface
-  
-  EGraphics* = object of EBase
-
-  TFont {.pure, final.} = object
-    f: sdl_ttf.PFont
-    color: SDL.TColor
-  PFont* = ref TFont ## represents a font
-
-proc toSdlColor(c: TColor): Sdl.TColor =
-  # Convert colors.TColor to SDL.TColor
-  var x = c.extractRGB  
-  result.r = toU8(x.r)
-  result.g = toU8(x.g)
-  result.b = toU8(x.b)
-
-proc raiseEGraphics = 
-  raise newException(EGraphics, $SDL.GetError())
-  
-proc surfaceFinalizer(s: PSurface) = sdl.freeSurface(s.s)
-  
-proc newSurface*(width, height: int): PSurface =
-  ## creates a new surface.
-  new(result, surfaceFinalizer)
-  result.w = width
-  result.h = height
-  result.s = SDL.CreateRGBSurface(SDL.SWSURFACE, width, height, 
-      32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0)
-   
-  assert(not sdl.MustLock(result.s))
-
-proc fontFinalizer(f: PFont) = closeFont(f.f)
-
-proc newFont*(name = "VeraMono.ttf", size = 9, color = colBlack): PFont =  
-  ## Creates a new font object. Raises ``EIO`` if the font cannot be loaded.
-  new(result, fontFinalizer)
-  result.f = OpenFont(name, size)
-  if result.f == nil:
-    raise newException(EIO, "Could not open font file: " & name)
-  result.color = toSdlColor(color)
-
-var
-  defaultFont*: PFont ## default font that is used; this needs to initialized
-                      ## by the client!
-
-proc initDefaultFont*(name = "VeraMono.ttf", size = 9, color = colBlack) = 
-  ## initializes the `defaultFont` var.
-  defaultFont = newFont(name, size, color)
-
-proc newScreenSurface(width, height: int): PSurface =
-  ## Creates a new screen surface
-  new(result, surfaceFinalizer)
-  result.w = width
-  result.h = height
-  result.s = SDL.SetVideoMode(width, height, 0, 0)
-
-proc writeToBMP*(sur: PSurface, filename: string) =
-  ## Saves the contents of the surface `sur` to the file `filename` as a 
-  ## BMP file.
-  if sdl.saveBMP(sur.s, filename) != 0:
-    raise newException(EIO, "cannot write: " & filename)
-
-type
-  TPixels = array[0..1000_000-1, int32]
-  PPixels = ptr TPixels
-
-template setPix(video, pitch, x, y, col: expr): stmt =
-  video[y * pitch + x] = int32(col)
-
-template getPix(video, pitch, x, y: expr): expr = 
-  colors.TColor(video[y * pitch + x])
-
-const
-  ColSize = 4
-
-proc getPixel(sur: PSurface, x, y: Natural): colors.TColor {.inline.} =
-  assert x <% sur.w
-  assert y <% sur.h
-  result = getPix(cast[PPixels](sur.s.pixels), sur.s.pitch div ColSize, x, y)
-
-proc setPixel(sur: PSurface, x, y: Natural, col: colors.TColor) {.inline.} =
-  assert x <% sur.w
-  assert y <% sur.h
-  var pixs = cast[PPixels](sur.s.pixels)
-  #pixs[y * (sur.s.pitch div colSize) + x] = int(col)
-  setPix(pixs, sur.s.pitch div ColSize, x, y, col)
-
-proc `[]`*(sur: PSurface, p: TPoint): TColor =
-  ## get pixel at position `p`. No range checking is done!
-  result = getPixel(sur, p.x, p.y)
-
-proc `[,]`*(sur: PSurface, x, y: int): TColor = 
-  ## get pixel at position ``(x, y)``. No range checking is done!
-  result = getPixel(sur, x, y)
-
-proc `[]=`*(sur: PSurface, p: TPoint, col: TColor) = 
-  ## set the pixel at position `p`. No range checking is done!
-  setPixel(sur, p.x, p.y, col)
-
-proc `[,]=`*(sur: PSurface, x, y: int, col: TColor) =
-  ## set the pixel at position ``(x, y)``. No range checking is done!
-  setPixel(sur, x, y, col)
-
-proc blit*(destSurf: PSurface, destRect: TRect, srcSurf: PSurface, 
-           srcRect: TRect) =
-  ## Copies ``srcSurf`` into ``destSurf``
-  var destTRect, srcTRect: SDL.TRect
-
-  destTRect.x = int16(destRect.x)
-  destTRect.y = int16(destRect.y)
-  destTRect.w = int16(destRect.width)
-  destTRect.h = int16(destRect.height)
-
-  srcTRect.x = int16(srcRect.x)
-  srcTRect.y = int16(srcRect.y)
-  srcTRect.w = int16(srcRect.width)
-  srcTRect.h = int16(srcRect.height)
-
-  if SDL.blitSurface(srcSurf.s, addr(srcTRect), destSurf.s, addr(destTRect)) != 0:
-    raiseEGraphics()
-
-proc textBounds*(text: string, font = defaultFont): tuple[width, height: int] =
-  var w, h: cint
-  if sdl_ttf.SizeUTF8(font.f, text, w, h) < 0: raiseEGraphics()
-  result.width = int(w)
-  result.height = int(h)
-
-proc drawText*(sur: PSurface, p: TPoint, text: string, font = defaultFont) =
-  ## Draws text with a transparent background, at location ``p`` with the given
-  ## font.
-  var textSur: PSurface # This surface will have the text drawn on it
-  new(textSur, surfaceFinalizer)
-  
-  # Render the text
-  textSur.s = sdl_ttf.RenderTextBlended(font.f, text, font.color)
-  # Merge the text surface with sur
-  sur.blit((p.x, p.y, sur.w, sur.h), textSur, (0, 0, sur.w, sur.h))
-  # Free the surface
-  SDL.FreeSurface(sur.s)
-
-proc drawText*(sur: PSurface, p: TPoint, text: string,
-               bg: TColor, font = defaultFont) =
-  ## Draws text, at location ``p`` with font ``font``. ``bg`` 
-  ## is the background color.
-  var textSur: PSurface # This surface will have the text drawn on it
-  new(textSur, surfaceFinalizer)
-  textSur.s = sdl_ttf.RenderTextShaded(font.f, text, font.color, toSdlColor(bg))
-  # Merge the text surface with sur
-  sur.blit((p.x, p.y, sur.w, sur.h), textSur, (0, 0, sur.w, sur.h))
-  # Free the surface
-  SDL.FreeSurface(sur.s)
-  
-proc drawCircle*(sur: PSurface, p: TPoint, r: Natural, color: TColor) =
-  ## draws a circle with center `p` and radius `r` with the given color
-  ## onto the surface `sur`.
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-  var a = 1 - r
-  var py = r
-  var px = 0
-  var x = p.x
-  var y = p.y
-  while px <= py + 1:
-    if x+px <% sur.w:
-      if y+py <% sur.h: setPix(video, pitch, x+px, y+py, color)
-      if y-py <% sur.h: setPix(video, pitch, x+px, y-py, color)
-    
-    if x-px <% sur.w:
-      if y+py <% sur.h: setPix(video, pitch, x-px, y+py, color)
-      if y-py <% sur.h: setPix(video, pitch, x-px, y-py, color)
-
-    if x+py <% sur.w:
-      if y+px <% sur.h: setPix(video, pitch, x+py, y+px, color)
-      if y-px <% sur.h: setPix(video, pitch, x+py, y-px, color)
-      
-    if x-py <% sur.w:
-      if y+px <% sur.h: setPix(video, pitch, x-py, y+px, color)
-      if y-px <% sur.h: setPix(video, pitch, x-py, y-px, color)
-
-    if a < 0:
-      a = a + (2 * px + 3)
-    else:
-      a = a + (2 * (px - py) + 5)
-      py = py - 1
-    px = px + 1
-
-proc `>-<`(val: int, s: PSurface): int {.inline.} = 
-  return if val < 0: 0 elif val >= s.w: s.w-1 else: val
-
-proc `>|<`(val: int, s: PSurface): int {.inline.} = 
-  return if val < 0: 0 elif val >= s.h: s.h-1 else: val
-
-proc drawLine*(sur: PSurface, p1, p2: TPoint, color: TColor) =
-  ## draws a line between the two points `p1` and `p2` with the given color
-  ## onto the surface `sur`.
-  var stepx, stepy: int = 0
-  var x0 = p1.x >-< sur
-  var x1 = p2.x >-< sur
-  var y0 = p1.y >|< sur
-  var y1 = p2.y >|< sur
-  var dy = y1 - y0
-  var dx = x1 - x0
-  if dy < 0:
-    dy = -dy 
-    stepy = -1
-  else:
-    stepy = 1
-  if dx < 0:
-    dx = -dx
-    stepx = -1
-  else:
-    stepx = 1
-  dy = dy * 2 
-  dx = dx * 2
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-  setPix(video, pitch, x0, y0, color)
-  if dx > dy:
-    var fraction = dy - (dx div 2)
-    while x0 != x1:
-      if fraction >= 0:
-        y0 = y0 + stepy
-        fraction = fraction - dx
-      x0 = x0 + stepx
-      fraction = fraction + dy
-      setPix(video, pitch, x0, y0, color)
-  else:
-    var fraction = dx - (dy div 2)
-    while y0 != y1:
-      if fraction >= 0:
-        x0 = x0 + stepx
-        fraction = fraction - dy
-      y0 = y0 + stepy
-      fraction = fraction + dx
-      setPix(video, pitch, x0, y0, color)
-
-proc drawHorLine*(sur: PSurface, x, y, w: Natural, Color: TColor) =
-  ## draws a horizontal line from (x,y) to (x+w-1, y).
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-
-  if y >= 0 and y <= sur.s.h:
-    for i in 0 .. min(sur.s.w-x, w-1)-1:
-      setPix(video, pitch, x + i, y, color)
-
-proc drawVerLine*(sur: PSurface, x, y, h: Natural, Color: TColor) =
-  ## draws a vertical line from (x,y) to (x, y+h-1).
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-
-  if x >= 0 and x <= sur.s.w:
-    for i in 0 .. min(sur.s.h-y, h-1)-1:
-      setPix(video, pitch, x, y + i, color)
-
-proc fillCircle*(s: PSurface, p: TPoint, r: Natural, color: TColor) =
-  ## draws a circle with center `p` and radius `r` with the given color
-  ## onto the surface `sur` and fills it.
-  var a = 1 - r
-  var py: int = r
-  var px = 0
-  var x = p.x
-  var y = p.y
-  while px <= py:
-    # Fill up the middle half of the circle
-    DrawVerLine(s, x + px, y, py + 1, color)
-    DrawVerLine(s, x + px, y - py, py, color)
-    if px != 0:
-      DrawVerLine(s, x - px, y, py + 1, color)
-      DrawVerLine(s, x - px, y - py, py, color)
-    if a < 0:
-      a = a + (2 * px + 3)
-    else:
-      a = a + (2 * (px - py) + 5)
-      py = py - 1
-      # Fill up the left/right half of the circle
-      if py >= px:
-        DrawVerLine(s, x + py + 1, y, px + 1, color)
-        DrawVerLine(s, x + py + 1, y - px, px, color)
-        DrawVerLine(s, x - py - 1, y, px + 1, color)
-        DrawVerLine(s, x - py - 1, y - px,  px, color)
-    px = px + 1
-
-proc drawRect*(sur: PSurface, r: TRect, color: TColor) =
-  ## draws a rectangle.
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-  if (r.x >= 0 and r.x <= sur.s.w) and (r.y >= 0 and r.y <= sur.s.h):
-    var minW = min(sur.s.w - r.x, r.width - 1)
-    var minH = min(sur.s.h - r.y, r.height - 1)
-    
-    # Draw Top
-    for i in 0 .. minW - 1:
-      setPix(video, pitch, r.x + i, r.y, color)
-      setPix(video, pitch, r.x + i, r.y + minH - 1, color) # Draw bottom
-      
-    # Draw left side    
-    for i in 0 .. minH - 1:
-      setPix(video, pitch, r.x, r.y + i, color)
-      setPix(video, pitch, r.x + minW - 1, r.y + i, color) # Draw right side
-    
-proc fillRect*(sur: PSurface, r: TRect, col: TColor) =
-  ## draws and fills a rectangle.
-  var video = cast[PPixels](sur.s.pixels)
-  assert video != nil
-  var pitch = sur.s.pitch div ColSize
-
-  for i in r.y..min(sur.s.h, r.y+r.height-1)-1:
-    for j in r.x..min(sur.s.w, r.x+r.width-1)-1:
-      setPix(video, pitch, j, i, col)
-
-proc Plot4EllipsePoints(sur: PSurface, CX, CY, X, Y: Natural, col: TColor) =
-  var video = cast[PPixels](sur.s.pixels)
-  var pitch = sur.s.pitch div ColSize
-  if CX+X <= sur.s.w-1:
-    if CY+Y <= sur.s.h-1: setPix(video, pitch, CX+X, CY+Y, col)
-    if CY-Y <= sur.s.h-1: setPix(video, pitch, CX+X, CY-Y, col)    
-  if CX-X <= sur.s.w-1:
-    if CY+Y <= sur.s.h-1: setPix(video, pitch, CX-X, CY+Y, col)
-    if CY-Y <= sur.s.h-1: setPix(video, pitch, CX-X, CY-Y, col)
-
-proc drawEllipse*(sur: PSurface, CX, CY, XRadius, YRadius: Natural, 
-                  col: TColor) =
-  ## Draws an ellipse, ``CX`` and ``CY`` specify the center X and Y of the 
-  ## ellipse, ``XRadius`` and ``YRadius`` specify half the width and height
-  ## of the ellipse.
-  var 
-    X, Y: Natural
-    XChange, YChange: Natural
-    EllipseError: Natural
-    TwoASquare, TwoBSquare: Natural
-    StoppingX, StoppingY: Natural
-    
-  TwoASquare = 2 * XRadius * XRadius
-  TwoBSquare = 2 * YRadius * YRadius
-  X = XRadius
-  Y = 0
-  XChange = YRadius * YRadius * (1 - 2 * XRadius)
-  YChange = XRadius * XRadius
-  EllipseError = 0
-  StoppingX = TwoBSquare * XRadius
-  StoppingY = 0
-  
-  while StoppingX >=  StoppingY: # 1st set of points, y` > - 1
-    sur.Plot4EllipsePoints(CX, CY, X, Y, col)
-    inc(Y)
-    inc(StoppingY, TwoASquare)
-    inc(EllipseError, YChange)
-    inc(YChange, TwoASquare)
-    if (2 * EllipseError + XChange) > 0 :
-      dec(x)
-      dec(StoppingX, TwoBSquare)
-      inc(EllipseError, XChange)
-      inc(XChange, TwoBSquare)
-      
-  # 1st point set is done; start the 2nd set of points
-  X = 0
-  Y = YRadius
-  XChange = YRadius * YRadius
-  YChange = XRadius * XRadius * (1 - 2 * YRadius)
-  EllipseError = 0
-  StoppingX = 0
-  StoppingY = TwoASquare * YRadius
-  while StoppingX <= StoppingY:
-    sur.Plot4EllipsePoints(CX, CY, X, Y, col)
-    inc(X)
-    inc(StoppingX, TwoBSquare)
-    inc(EllipseError, XChange)
-    inc(XChange,TwoBSquare)
-    if (2 * EllipseError + YChange) > 0:
-      dec(Y)
-      dec(StoppingY, TwoASquare)
-      inc(EllipseError, YChange)
-      inc(YChange,TwoASquare)
-  
-
-proc plotAA(sur: PSurface, x, y, c: float, color: TColor) =
-  if (x.toInt() > 0 and x.toInt() < sur.s.w) and (y.toInt() > 0 and 
-      y.toInt() < sur.s.h):
-    var video = cast[PPixels](sur.s.pixels)
-    var pitch = sur.s.pitch div ColSize
-
-    var pixColor = getPix(video, pitch, x.toInt, y.toInt)
-
-    setPix(video, pitch, x.toInt(), y.toInt(), 
-           pixColor.intensity(1.0 - c) + color.intensity(c))
-         
-proc ipart(x: float): float = return x.trunc()
-proc fpart(x: float): float = return x - ipart(x)
-proc rfpart(x: float): float = return 1.0 - fpart(x)
-
-proc drawLineAA(sur: PSurface, p1, p2: TPoint, color: TColor) =
-  ## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's 
-  ## line algorithm
-  var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(), 
-                          p1.y.toFloat(), p2.y.toFloat())
-  var dx = x2 - x1
-  var dy = y2 - y1
-  if abs(dx) < abs(dy):
-    swap(x1, y1)
-    swap(x2, y2)
-  if x2 < x1:
-    swap(x1, x2)
-    swap(y1, y2)
-
-  var gradient = dy / dx
-  # handle first endpoint
-  var xend = x1  # Should be round(x1), but since this is an int anyway..
-  var yend = y1 + gradient * (xend - x1)
-  var xgap = rfpart(x1 + 0.5)
-  var xpxl1 = xend # this will be used in the main loop
-  var ypxl1 = ipart(yend)
-  sur.plotAA(xpxl1, ypxl1, rfpart(yend) * xgap, color)
-  sur.plotAA(xpxl1, ypxl1 + 1.0, fpart(yend) * xgap, color)
-  var intery = yend + gradient # first y-intersection for the main loop
-  # handle second endpoint
-  xend = x2 # Should be round(x1), but since this is an int anyway..
-  yend = y2 + gradient * (xend - x2)
-  xgap = fpart(x2 + 0.5)
-  var xpxl2 = xend  # this will be used in the main loop
-  var ypxl2 = ipart(yend)
-  sur.plotAA(xpxl2, ypxl2, rfpart(yend) * xgap, color)
-  sur.plotAA(xpxl2, ypxl2 + 1.0, fpart(yend) * xgap, color)  
-  # main loop
-  for x in xpxl1.toInt + 1..xpxl2.toInt - 1:
-    sur.plotAA(x.toFloat(), ipart(intery), rfpart(intery), color)
-    sur.plotAA(x.toFloat(), ipart(intery) + 1.0, fpart(intery), color)
-    intery = intery + gradient
-
-template withEvents(surf: PSurface, event: expr, actions: stmt): stmt =
-  while True:
-    var event: SDL.TEvent
-    if SDL.PollEvent(addr(event)) == 1:
-      actions
-
-if sdl.Init(sdl.INIT_VIDEO) < 0: raiseEGraphics()
-if sdl_ttf.Init() < 0: raiseEGraphics()
-
-when isMainModule:
-  var surf = newScreenSurface(800, 600)
-  var r: TRect = (0, 0, 900, 900)
-    
-  # Draw the shapes
-  surf.fillRect(r, colWhite)
-  surf.drawLineAA((100, 170), (400, 471), colTan)
-  surf.drawLine((100, 170), (400, 471), colRed)
-  
-  surf.drawEllipse(200, 300, 200, 30, colSeaGreen)
-  surf.drawHorLine(1, 300, 400, colViolet) 
-  # Check if the ellipse is the size it's suppose to be.
-  surf.drawVerLine(200, 300 - 30 + 1, 60, colViolet) # ^^ | i suppose it is
-  
-  surf.drawEllipse(400, 300, 300, 300, colOrange)
-  surf.drawEllipse(5, 5, 5, 5, colGreen)
-  
-  surf.drawHorLine(5, 5, 900, colRed)
-  surf.drawVerLine(5, 60, 800, colRed)
-  surf.drawCircle((600, 500), 60, colRed)
-  
-  #surf.drawText((300, 300), "TEST", colMidnightBlue)
-  #var textSize = textBounds("TEST")
-  #surf.drawText((300, 300 + textSize.height), $textSize.width & ", " &
-  #  $textSize.height, colDarkGreen)
-  
-  var mouseStartX = 0
-  var mouseStartY = 0
-  withEvents(surf, event):
-    case event.kind:
-    of SDL.QUITEV:
-      break
-    of SDL.KEYDOWN:
-      if event.sym == SDL.K_LEFT:
-        echo(event.sym)
-        surf.drawHorLine(395, 300, 5, colPaleGoldenRod)
-        echo("Drawing")
-      else:
-        echo(event.sym)
-    of SDL.MOUSEBUTTONDOWN:
-      # button.x/y is F* UP!
-      echo("MOUSEDOWN ", event.x)
-      mouseStartX = event.x
-      mouseStartY = event.y
-      
-    of SDL.MOUSEBUTTONUP:
-      echo("MOUSEUP ", mouseStartX)
-      if mouseStartX != 0 and mouseStartY != 0:
-        echo(mouseStartX, "->", int(event.x))
-        surf.drawLineAA((mouseStartX, MouseStartY), 
-          (int(event.x), int(event.y)), colPaleGoldenRod)
-        mouseStartX = 0
-        mouseStartY = 0
-      
-    else:
-      #echo(event.theType)
-      
-    SDL.UpdateRect(surf.s, int32(0), int32(0), int32(800), int32(600))
-    
-  surf.writeToBMP("test.bmp")
-  SDL.Quit()
diff --git a/lib/impure/nre.nim b/lib/impure/nre.nim
new file mode 100644
index 000000000..39d238055
--- /dev/null
+++ b/lib/impure/nre.nim
@@ -0,0 +1,751 @@
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(js):
+  {.error: "This library needs to be compiled with a c-like backend, and depends on PCRE; See jsre for JS backend.".}
+
+## What is NRE?
+## ============
+##
+## A regular expression library for Nim using PCRE to do the hard work.
+##
+## For documentation on how to write patterns, there exists `the official PCRE
+## pattern documentation
+## <https://www.pcre.org/original/doc/html/pcrepattern.html>`_. You can also
+## search the internet for a wide variety of third-party documentation and
+## tools.
+##
+## .. warning:: If you love `sequtils.toSeq` we have bad news for you. This
+##   library doesn't work with it due to documented compiler limitations. As
+##   a workaround, use this:
+runnableExamples:
+  # either `import std/nre except toSeq` or fully qualify `sequtils.toSeq`:
+  import std/sequtils
+  iterator iota(n: int): int =
+    for i in 0..<n: yield i
+  assert sequtils.toSeq(iota(3)) == @[0, 1, 2]
+## .. note:: There are also alternative nimble packages such as [tinyre](https://github.com/khchen/tinyre)
+##   and [regex](https://github.com/nitely/nim-regex).
+## Licencing
+## ---------
+##
+## PCRE has `some additional terms`_ that you must agree to in order to use
+## this module.
+##
+## .. _`some additional terms`: http://pcre.sourceforge.net/license.txt
+runnableExamples:
+  import std/sugar
+  let vowels = re"[aeoui]"
+  let bounds = collect:
+    for match in "moiga".findIter(vowels): match.matchBounds
+  assert bounds == @[1 .. 1, 2 .. 2, 4 .. 4]
+  from std/sequtils import toSeq
+  let s = sequtils.toSeq("moiga".findIter(vowels))
+    # fully qualified to avoid confusion with nre.toSeq
+  assert s.len == 3
+
+  let firstVowel = "foo".find(vowels)
+  let hasVowel = firstVowel.isSome()
+  assert hasVowel
+  let matchBounds = firstVowel.get().captureBounds[-1]
+  assert matchBounds.a == 1
+
+  # as with module `re`, unless specified otherwise, `start` parameter in each
+  # proc indicates where the scan starts, but outputs are relative to the start
+  # of the input string, not to `start`:
+  assert find("uxabc", re"(?<=x|y)ab", start = 1).get.captures[-1] == "ab"
+  assert find("uxabc", re"ab", start = 3).isNone
+
+from std/pcre import nil
+import nre/private/util
+import std/tables
+from std/strutils import `%`
+import std/options
+from std/unicode import runeLenAt
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+export options
+
+type
+  Regex* = ref object
+    ## Represents the pattern that things are matched against, constructed with
+    ## `re(string)`. Examples: `re"foo"`, `re(r"(*ANYCRLF)(?x)foo #
+    ## comment".`
+    ##
+    ## `pattern: string`
+    ## :   the string that was used to create the pattern. For details on how
+    ##     to write a pattern, please see `the official PCRE pattern
+    ##     documentation.
+    ##     <https://www.pcre.org/original/doc/html/pcrepattern.html>`_
+    ##
+    ## `captureCount: int`
+    ## :   the number of captures that the pattern has.
+    ##
+    ## `captureNameId: Table[string, int]`
+    ## :   a table from the capture names to their numeric id.
+    ##
+    ##
+    ## Options
+    ## .......
+    ##
+    ## The following options may appear anywhere in the pattern, and they affect
+    ## the rest of it.
+    ##
+    ## -  `(?i)` - case insensitive
+    ## -  `(?m)` - multi-line: `^` and `$` match the beginning and end of
+    ##    lines, not of the subject string
+    ## -  `(?s)` - `.` also matches newline (*dotall*)
+    ## -  `(?U)` - expressions are not greedy by default. `?` can be added
+    ##    to a qualifier to make it greedy
+    ## -  `(?x)` - whitespace and comments (`#`) are ignored (*extended*)
+    ## -  `(?X)` - character escapes without special meaning (`\w` vs.
+    ##    `\a`) are errors (*extra*)
+    ##
+    ## One or a combination of these options may appear only at the beginning
+    ## of the pattern:
+    ##
+    ## -  `(*UTF8)` - treat both the pattern and subject as UTF-8
+    ## -  `(*UCP)` - Unicode character properties; `\w` matches `Ñ`
+    ## -  `(*U)` - a combination of the two options above
+    ## -  `(*FIRSTLINE*)` - fails if there is not a match on the first line
+    ## -  `(*NO_AUTO_CAPTURE)` - turn off auto-capture for groups;
+    ##    `(?<name>...)` can be used to capture
+    ## -  `(*CR)` - newlines are separated by `\r`
+    ## -  `(*LF)` - newlines are separated by `\n` (UNIX default)
+    ## -  `(*CRLF)` - newlines are separated by `\r\n` (Windows default)
+    ## -  `(*ANYCRLF)` - newlines are separated by any of the above
+    ## -  `(*ANY)` - newlines are separated by any of the above and Unicode
+    ##    newlines:
+    ##
+    ##     single characters VT (vertical tab, U+000B), FF (form feed, U+000C),
+    ##     NEL (next line, U+0085), LS (line separator, U+2028), and PS
+    ##     (paragraph separator, U+2029). For the 8-bit library, the last two
+    ##     are recognized only in UTF-8 mode.
+    ##     —  man pcre
+    ##
+    ## -  `(*JAVASCRIPT_COMPAT)` - JavaScript compatibility
+    ## -  `(*NO_STUDY)` - turn off studying; study is enabled by default
+    ##
+    ## For more details on the leading option groups, see the `Option
+    ## Setting <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#OPTION_SETTING>`_
+    ## and the `Newline
+    ## Convention <http://man7.org/linux/man-pages/man3/pcresyntax.3.html#NEWLINE_CONVENTION>`_
+    ## sections of the `PCRE syntax
+    ## manual <http://man7.org/linux/man-pages/man3/pcresyntax.3.html>`_.
+    ##
+    ## Some of these options are not part of PCRE and are converted by nre
+    ## into PCRE flags. These include `NEVER_UTF`, `ANCHORED`,
+    ## `DOLLAR_ENDONLY`, `FIRSTLINE`, `NO_AUTO_CAPTURE`,
+    ## `JAVASCRIPT_COMPAT`, `U`, `NO_STUDY`. In other PCRE wrappers, you
+    ## will need to pass these as separate flags to PCRE.
+    pattern*: string
+    pcreObj: ptr pcre.Pcre  ## not nil
+    pcreExtra: ptr pcre.ExtraData  ## nil
+
+    captureNameToId: Table[string, int]
+
+  RegexMatch* = object
+    ## Usually seen as Option[RegexMatch], it represents the result of an
+    ## execution. On failure, it is none, on success, it is some.
+    ##
+    ## `pattern: Regex`
+    ## :   the pattern that is being matched
+    ##
+    ## `str: string`
+    ## :   the string that was matched against
+    ##
+    ## `captures[]: string`
+    ## :   the string value of whatever was captured at that id. If the value
+    ##     is invalid, then behavior is undefined. If the id is `-1`, then
+    ##     the whole match is returned. If the given capture was not matched,
+    ##     `nil` is returned. See examples for `match`.
+    ##
+    ## `captureBounds[]: HSlice[int, int]`
+    ## :   gets the bounds of the given capture according to the same rules as
+    ##     the above. If the capture is not filled, then `None` is returned.
+    ##     The bounds are both inclusive.  See examples for `match`.
+    ##
+    ## `match: string`
+    ## :   the full text of the match.
+    ##
+    ## `matchBounds: HSlice[int, int]`
+    ## :   the bounds of the match, as in `captureBounds[]`
+    ##
+    ## `(captureBounds|captures).toTable`
+    ## :   returns a table with each named capture as a key.
+    ##
+    ## `(captureBounds|captures).toSeq`
+    ## :   returns all the captures by their number.
+    ##
+    ## `$: string`
+    ## :   same as `match`
+    pattern*: Regex  ## The regex doing the matching.
+                     ## Not nil.
+    str*: string  ## The string that was matched against.
+    pcreMatchBounds: seq[HSlice[cint, cint]] ## First item is the bounds of the match
+                                            ## Other items are the captures
+                                            ## `a` is inclusive start, `b` is exclusive end
+
+  Captures* = distinct RegexMatch
+  CaptureBounds* = distinct RegexMatch
+
+  RegexError* = ref object of CatchableError
+
+  RegexInternalError* = ref object of RegexError
+    ## Internal error in the module, this probably means that there is a bug
+
+  InvalidUnicodeError* = ref object of RegexError
+    ## Thrown when matching fails due to invalid unicode in strings
+    pos*: int  ## the location of the invalid unicode in bytes
+
+  SyntaxError* = ref object of RegexError
+    ## Thrown when there is a syntax error in the
+    ## regular expression string passed in
+    pos*: int  ## the location of the syntax error in bytes
+    pattern*: string  ## the pattern that caused the problem
+
+  StudyError* = ref object of RegexError
+    ## Thrown when studying the regular expression fails
+    ## for whatever reason. The message contains the error
+    ## code.
+
+proc destroyRegex(pattern: Regex) =
+  `=destroy`(pattern.pattern)
+  pcre.free_substring(cast[cstring](pattern.pcreObj))
+  if pattern.pcreExtra != nil:
+    pcre.free_study(pattern.pcreExtra)
+  `=destroy`(pattern.captureNameToId)
+
+proc getinfo[T](pattern: Regex, opt: cint): T =
+  let retcode = pcre.fullinfo(pattern.pcreObj, pattern.pcreExtra, opt, addr result)
+
+  if retcode < 0:
+    # XXX Error message that doesn't expose implementation details
+    raise newException(FieldDefect, "Invalid getinfo for $1, errno $2" % [$opt, $retcode])
+
+proc getNameToNumberTable(pattern: Regex): Table[string, int] =
+  let entryCount = getinfo[cint](pattern, pcre.INFO_NAMECOUNT)
+  let entrySize = getinfo[cint](pattern, pcre.INFO_NAMEENTRYSIZE)
+  let table = cast[ptr UncheckedArray[uint8]](
+                getinfo[int](pattern, pcre.INFO_NAMETABLE))
+
+  result = initTable[string, int]()
+
+  for i in 0 ..< entryCount:
+    let pos = i * entrySize
+    let num = (int(table[pos]) shl 8) or int(table[pos + 1]) - 1
+    var name = ""
+
+    var idx = 2
+    while table[pos + idx] != 0:
+      name.add(char(table[pos + idx]))
+      idx += 1
+
+    result[name] = num
+
+proc initRegex(pattern: string, flags: int, study = true): Regex =
+  new(result, destroyRegex)
+  result.pattern = pattern
+
+  var errorMsg: cstring
+  var errOffset: cint
+
+  result.pcreObj = pcre.compile(cstring(pattern),
+                                # better hope int is at least 4 bytes..
+                                cint(flags), addr errorMsg,
+                                addr errOffset, nil)
+  if result.pcreObj == nil:
+    # failed to compile
+    raise SyntaxError(msg: $errorMsg, pos: errOffset, pattern: pattern)
+
+  if study:
+    var options: cint = 0
+    var hasJit: cint
+    if pcre.config(pcre.CONFIG_JIT, addr hasJit) == 0:
+      if hasJit == 1'i32:
+        options = pcre.STUDY_JIT_COMPILE
+    result.pcreExtra = pcre.study(result.pcreObj, options, addr errorMsg)
+    if errorMsg != nil:
+      raise StudyError(msg: $errorMsg)
+
+  result.captureNameToId = result.getNameToNumberTable()
+
+proc captureCount*(pattern: Regex): int =
+  return getinfo[cint](pattern, pcre.INFO_CAPTURECOUNT)
+
+proc captureNameId*(pattern: Regex): Table[string, int] =
+  return pattern.captureNameToId
+
+proc matchesCrLf(pattern: Regex): bool =
+  let flags = uint32(getinfo[culong](pattern, pcre.INFO_OPTIONS))
+  let newlineFlags = flags and (pcre.NEWLINE_CRLF or
+                                pcre.NEWLINE_ANY or
+                                pcre.NEWLINE_ANYCRLF)
+  if newlineFlags > 0u32:
+    return true
+
+  # get flags from build config
+  var confFlags: cint
+  if pcre.config(pcre.CONFIG_NEWLINE, addr confFlags) != 0:
+    assert(false, "CONFIG_NEWLINE apparently got screwed up")
+
+  case confFlags
+  of 13: return false
+  of 10: return false
+  of (13 shl 8) or 10: return true
+  of -2: return true
+  of -1: return true
+  else: return false
+
+
+func captureBounds*(pattern: RegexMatch): CaptureBounds = return CaptureBounds(pattern)
+
+func captures*(pattern: RegexMatch): Captures = return Captures(pattern)
+
+func contains*(pattern: CaptureBounds, i: int): bool =
+  let pattern = RegexMatch(pattern)
+  pattern.pcreMatchBounds[i + 1].a != -1
+
+func contains*(pattern: Captures, i: int): bool =
+  i in CaptureBounds(pattern)
+
+func `[]`*(pattern: CaptureBounds, i: int): HSlice[int, int] =
+  let pattern = RegexMatch(pattern)
+  if not (i in pattern.captureBounds):
+    raise newException(IndexDefect, "Group '" & $i & "' was not captured")
+
+  let bounds = pattern.pcreMatchBounds[i + 1]
+  int(bounds.a)..int(bounds.b-1)
+
+func `[]`*(pattern: Captures, i: int): string =
+  let pattern = RegexMatch(pattern)
+  let bounds = pattern.captureBounds[i]
+
+  pattern.str.substr(bounds.a, bounds.b)
+
+func match*(pattern: RegexMatch): string =
+  return pattern.captures[-1]
+
+func matchBounds*(pattern: RegexMatch): HSlice[int, int] =
+  return pattern.captureBounds[-1]
+
+func contains*(pattern: CaptureBounds, name: string): bool =
+  let pattern = RegexMatch(pattern)
+  let nameToId = pattern.pattern.captureNameToId
+  if not (name in nameToId):
+      return false
+  nameToId[name] in pattern.captureBounds
+
+func contains*(pattern: Captures, name: string): bool =
+  name in CaptureBounds(pattern)
+
+func checkNamedCaptured(pattern: RegexMatch, name: string) =
+  if not (name in pattern.captureBounds):
+    raise newException(KeyError, "Group '" & name & "' was not captured")
+
+func `[]`*(pattern: CaptureBounds, name: string): HSlice[int, int] =
+  let pattern = RegexMatch(pattern)
+  checkNamedCaptured(pattern, name)
+  {.noSideEffect.}:
+    result = pattern.captureBounds[pattern.pattern.captureNameToId[name]]
+
+func `[]`*(pattern: Captures, name: string): string =
+  let pattern = RegexMatch(pattern)
+  checkNamedCaptured(pattern, name)
+  {.noSideEffect.}:
+    result = pattern.captures[pattern.pattern.captureNameToId[name]]
+
+template toTableImpl() {.dirty.} =
+  for key in RegexMatch(pattern).pattern.captureNameId.keys:
+    if key in pattern:
+      result[key] = pattern[key]
+
+func toTable*(pattern: Captures): Table[string, string] =
+  result = initTable[string, string]()
+  toTableImpl()
+
+func toTable*(pattern: CaptureBounds): Table[string, HSlice[int, int]] =
+  result = initTable[string, HSlice[int, int]]()
+  toTableImpl()
+
+template itemsImpl() {.dirty.} =
+  for i in 0 ..< RegexMatch(pattern).pattern.captureCount:
+    # done in this roundabout way to avoid multiple yields (potential code
+    # bloat)
+    let nextYieldVal = if i in pattern:
+      some(pattern[i])
+    else:
+      default
+
+    yield nextYieldVal
+
+iterator items*(pattern: CaptureBounds,
+                default = none(HSlice[int, int])): Option[HSlice[int, int]] =
+  itemsImpl()
+
+iterator items*(pattern: Captures,
+                default: Option[string] = none(string)): Option[string] =
+  itemsImpl()
+
+proc toSeq*(pattern: CaptureBounds,
+            default = none(HSlice[int, int])): seq[Option[HSlice[int, int]]] =
+  result = @[]
+  for it in pattern.items(default): result.add it
+
+proc toSeq*(pattern: Captures,
+            default: Option[string] = none(string)): seq[Option[string]] =
+  result = @[]
+  for it in pattern.items(default): result.add it
+
+proc `$`*(pattern: RegexMatch): string =
+  return pattern.captures[-1]
+
+proc `==`*(a, b: Regex): bool =
+  if not a.isNil and not b.isNil:
+    return a.pattern == b.pattern and
+           a.pcreObj == b.pcreObj and
+           a.pcreExtra == b.pcreExtra
+  else:
+    return system.`==`(a, b)
+
+proc `==`*(a, b: RegexMatch): bool =
+  return a.pattern == b.pattern and
+         a.str == b.str
+
+const PcreOptions = {
+  "NEVER_UTF": pcre.NEVER_UTF,
+  "ANCHORED": pcre.ANCHORED,
+  "DOLLAR_ENDONLY": pcre.DOLLAR_ENDONLY,
+  "FIRSTLINE": pcre.FIRSTLINE,
+  "NO_AUTO_CAPTURE": pcre.NO_AUTO_CAPTURE,
+  "JAVASCRIPT_COMPAT": pcre.JAVASCRIPT_COMPAT,
+  "U": pcre.UTF8 or pcre.UCP
+}.toTable
+
+# Options that are supported inside regular expressions themselves
+const SkipOptions = [
+  "LIMIT_MATCH=", "LIMIT_RECURSION=", "NO_AUTO_POSSESS", "NO_START_OPT",
+  "UTF8", "UTF16", "UTF32", "UTF", "UCP",
+  "CR", "LF", "CRLF", "ANYCRLF", "ANY", "BSR_ANYCRLF", "BSR_UNICODE"
+]
+
+proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study: bool] =
+  result = ("", 0, true)
+
+  var optionStart = 0
+  var equals = false
+  for i, c in pattern:
+    if optionStart == i:
+      if c != '(':
+        break
+      optionStart = i
+
+    elif optionStart == i-1:
+      if c != '*':
+        break
+
+    elif c == ')':
+      let name = pattern[optionStart+2 .. i-1]
+      if equals or name in SkipOptions:
+        result.pattern.add pattern[optionStart .. i]
+      elif PcreOptions.hasKey name:
+        result.flags = result.flags or PcreOptions[name]
+      elif name == "NO_STUDY":
+        result.study = false
+      else:
+        break
+      optionStart = i+1
+      equals = false
+
+    elif not equals:
+      if c == '=':
+        equals = true
+        if pattern[optionStart+2 .. i] notin SkipOptions:
+          break
+      elif c notin {'A'..'Z', '0'..'9', '_'}:
+        break
+
+  result.pattern.add pattern[optionStart .. pattern.high]
+
+proc re*(pattern: string): Regex =
+  let (pattern, flags, study) = extractOptions(pattern)
+  initRegex(pattern, flags, study)
+
+proc matchImpl(str: string, pattern: Regex, start, endpos: int, flags: int): Option[RegexMatch] =
+  var myResult = RegexMatch(pattern: pattern, str: str)
+  # See PCRE man pages.
+  # 2x capture count to make room for start-end pairs
+  # 1x capture count as slack space for PCRE
+  let vecsize = (pattern.captureCount() + 1) * 3
+  # div 2 because each element is 2 cints long
+  # plus 1 because we need the ceiling, not the floor
+  myResult.pcreMatchBounds = newSeq[HSlice[cint, cint]]((vecsize + 1) div 2)
+  myResult.pcreMatchBounds.setLen(vecsize div 3)
+
+  let strlen = if endpos == int.high: str.len else: endpos+1
+  doAssert(strlen <= str.len)  # don't want buffer overflows
+
+  let execRet = pcre.exec(pattern.pcreObj,
+                          pattern.pcreExtra,
+                          cstring(str),
+                          cint(strlen),
+                          cint(start),
+                          cint(flags),
+                          cast[ptr cint](addr myResult.pcreMatchBounds[0]),
+                          cint(vecsize))
+  if execRet >= 0:
+    return some(myResult)
+
+  case execRet:
+    of pcre.ERROR_NOMATCH:
+      return none(RegexMatch)
+    of pcre.ERROR_NULL:
+      raise newException(AccessViolationDefect, "Expected non-null parameters")
+    of pcre.ERROR_BADOPTION:
+      raise RegexInternalError(msg: "Unknown pattern flag. Either a bug or " &
+        "outdated PCRE.")
+    of pcre.ERROR_BADUTF8, pcre.ERROR_SHORTUTF8, pcre.ERROR_BADUTF8_OFFSET:
+      raise InvalidUnicodeError(msg: "Invalid unicode byte sequence",
+        pos: myResult.pcreMatchBounds[0].a)
+    else:
+      raise RegexInternalError(msg: "Unknown internal error: " & $execRet)
+
+proc match*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[RegexMatch] =
+  ## Like `find(...)<#find,string,Regex,int>`_, but anchored to the start of the
+  ## string.
+  runnableExamples:
+    assert "foo".match(re"f").isSome
+    assert "foo".match(re"o").isNone
+
+    assert "abc".match(re"(\w)").get.captures[0] == "a"
+    assert "abc".match(re"(?<letter>\w)").get.captures["letter"] == "a"
+    assert "abc".match(re"(\w)\w").get.captures[-1] == "ab"
+
+    assert "abc".match(re"(\w)").get.captureBounds[0] == 0 .. 0
+    assert 0 in "abc".match(re"(\w)").get.captureBounds
+    assert "abc".match(re"").get.captureBounds[-1] == 0 .. -1
+    assert "abc".match(re"abc").get.captureBounds[-1] == 0 .. 2
+  return str.matchImpl(pattern, start, endpos, pcre.ANCHORED)
+
+iterator findIter*(str: string, pattern: Regex, start = 0, endpos = int.high): RegexMatch =
+  ## Works the same as `find(...)<#find,string,Regex,int>`_, but finds every
+  ## non-overlapping match:
+  runnableExamples:
+    import std/sugar
+    assert collect(for a in "2222".findIter(re"22"): a.match) == @["22", "22"]
+     # not @["22", "22", "22"]
+  ## Arguments are the same as `find(...)<#find,string,Regex,int>`_
+  ##
+  ## Variants:
+  ##
+  ## -  `proc findAll(...)` returns a `seq[string]`
+  # see pcredemo for explanation => https://www.pcre.org/original/doc/html/pcredemo.html
+  let matchesCrLf = pattern.matchesCrLf()
+  let unicode = uint32(getinfo[culong](pattern, pcre.INFO_OPTIONS) and
+    pcre.UTF8) > 0u32
+  let strlen = if endpos == int.high: str.len else: endpos+1
+  var offset = start
+  var match: Option[RegexMatch]
+  var neverMatched = true
+
+  while true:
+    var flags = 0
+    if match.isSome and
+       match.get.matchBounds.a > match.get.matchBounds.b:
+      # 0-len match
+      flags = pcre.NOTEMPTY_ATSTART
+    match = str.matchImpl(pattern, offset, endpos, flags)
+
+    if match.isNone:
+      # either the end of the input or the string
+      # cannot be split here - we also need to bail
+      # if we've never matched and we've already tried to...
+      if flags == 0 or offset >= strlen or neverMatched: # All matches found
+        break
+
+      if matchesCrLf and offset < (str.len - 1) and
+         str[offset] == '\r' and str[offset + 1] == '\L':
+        # if PCRE treats CrLf as newline, skip both at the same time
+        offset += 2
+      elif unicode:
+        # XXX what about invalid unicode?
+        offset += str.runeLenAt(offset)
+        assert(offset <= strlen)
+      else:
+        offset += 1
+    else:
+      neverMatched = false
+      offset = match.get.matchBounds.b + 1
+      yield match.get
+
+proc find*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[RegexMatch] =
+  ## Finds the given pattern in the string between the end and start
+  ## positions.
+  ##
+  ## `start`
+  ## :   The start point at which to start matching. `|abc` is `0`;
+  ##     `a|bc` is `1`
+  ##
+  ## `endpos`
+  ## :   The maximum index for a match; `int.high` means the end of the
+  ##     string, otherwise it’s an inclusive upper bound.
+  return str.matchImpl(pattern, start, endpos, 0)
+
+proc findAll*(str: string, pattern: Regex, start = 0, endpos = int.high): seq[string] =
+  result = @[]
+  for match in str.findIter(pattern, start, endpos):
+    result.add(match.match)
+
+proc contains*(str: string, pattern: Regex, start = 0, endpos = int.high): bool =
+  ## Determine if the string contains the given pattern between the end and
+  ## start positions:
+  ## This function is equivalent to `isSome(str.find(pattern, start, endpos))`.
+  runnableExamples:
+    assert "abc".contains(re"bc")
+    assert not "abc".contains(re"cd")
+    assert not "abc".contains(re"a", start = 1)
+
+  return isSome(str.find(pattern, start, endpos))
+
+proc split*(str: string, pattern: Regex, maxSplit = -1, start = 0): seq[string] =
+  ## Splits the string with the given regex. This works according to the
+  ## rules that Perl and Javascript use.
+  ##
+  ## `start` behaves the same as in `find(...)<#find,string,Regex,int>`_.
+  ##
+  runnableExamples:
+    # -  If the match is zero-width, then the string is still split:
+    assert "123".split(re"") == @["1", "2", "3"]
+
+    # -  If the pattern has a capture in it, it is added after the string
+    #    split:
+    assert "12".split(re"(\d)") == @["", "1", "", "2", ""]
+
+    # -  If `maxsplit != -1`, then the string will only be split
+    #    `maxsplit - 1` times. This means that there will be `maxsplit`
+    #    strings in the output seq.
+    assert "1.2.3".split(re"\.", maxsplit = 2) == @["1", "2.3"]
+
+  result = @[]
+  var lastIdx = start
+  var splits = 0
+  var bounds = 0 .. -1
+  var never_ran = true
+
+  for match in str.findIter(pattern, start = start):
+    never_ran = false
+
+    # bounds are inclusive:
+    #
+    # 0123456
+    #  ^^^
+    # (1, 3)
+    bounds = match.matchBounds
+
+    # "12".split("") would be @["", "1", "2"], but
+    # if we skip an empty first match, it's the correct
+    # @["1", "2"]
+    if bounds.a <= bounds.b or bounds.a > start:
+      result.add(str.substr(lastIdx, bounds.a - 1))
+      splits += 1
+
+    lastIdx = bounds.b + 1
+
+    for cap in match.captures:
+      # if there are captures, include them in the result
+      if cap.isSome:
+        result.add(cap.get)
+
+    if splits == maxSplit - 1:
+      break
+
+  # "12".split("\b") would be @["1", "2", ""], but
+  # if we skip an empty last match, it's the correct
+  # @["1", "2"]
+  # If matches were never found, then the input string is the result
+  if bounds.a <= bounds.b or bounds.b < str.high or never_ran:
+    # last match: Each match takes the previous substring,
+    # but "1 2".split(/ /) needs to return @["1", "2"].
+    # This handles "2"
+    result.add(str.substr(bounds.b + 1, str.high))
+
+template replaceImpl(str: string, pattern: Regex,
+                     replacement: untyped) {.dirty.} =
+  # XXX seems very similar to split, maybe I can reduce code duplication
+  # somehow?
+  result = ""
+  var lastIdx = 0
+  for match {.inject.} in str.findIter(pattern):
+    let bounds = match.matchBounds
+    result.add(str.substr(lastIdx, bounds.a - 1))
+    let nextVal = replacement
+    result.add(nextVal)
+
+    lastIdx = bounds.b + 1
+
+  result.add(str.substr(lastIdx, str.len - 1))
+  return result
+
+proc replace*(str: string, pattern: Regex,
+              subproc: proc (match: RegexMatch): string): string =
+  ## Replaces each match of Regex in the string with `subproc`, which should
+  ## never be or return `nil`.
+  ##
+  ## If `subproc` is a `proc (RegexMatch): string`, then it is executed with
+  ## each match and the return value is the replacement value.
+  ##
+  ## If `subproc` is a `proc (string): string`, then it is executed with the
+  ## full text of the match and the return value is the replacement value.
+  ##
+  ## If `subproc` is a string, the syntax is as follows:
+  ##
+  ## -  `$$` - literal `$`
+  ## -  `$123` - capture number `123`
+  ## -  `$foo` - named capture `foo`
+  ## -  `${foo}` - same as above
+  ## -  `$1$#` - first and second captures
+  ## -  `$#` - first capture
+  ## -  `$0` - full match
+  ##
+  ## If a given capture is missing, `IndexDefect` thrown for un-named captures
+  ## and `KeyError` for named captures.
+  replaceImpl(str, pattern, subproc(match))
+
+proc replace*(str: string, pattern: Regex,
+              subproc: proc (match: string): string): string =
+  replaceImpl(str, pattern, subproc(match.match))
+
+proc replace*(str: string, pattern: Regex, sub: string): string =
+  # - 1 because the string numbers are 0-indexed
+  replaceImpl(str, pattern,
+    formatStr(sub, match.captures[name], match.captures[id - 1]))
+
+proc escapeRe*(str: string): string {.gcsafe.} =
+  ## Escapes the string so it doesn't match any special characters.
+  ## Incompatible with the Extra flag (`X`).
+  ##
+  ## Escaped char: `\ + * ? [ ^ ] $ ( ) { } = ! < > | : -`
+  runnableExamples:
+    assert escapeRe("fly+wind") == "fly\\+wind"
+    assert escapeRe("!") == "\\!"
+    assert escapeRe("nim*") == "nim\\*"
+
+  #([\\+*?[^\]$(){}=!<>|:-])
+  const SpecialCharMatcher = {'\\', '+', '*', '?', '[', '^', ']', '$', '(',
+                              ')', '{', '}', '=', '!', '<', '>', '|', ':',
+                              '-'}
+
+  for c in items(str):
+    case c
+    of SpecialCharMatcher:
+      result.add("\\")
+      result.add(c)
+    else:
+      result.add(c)
diff --git a/lib/impure/nre/.gitignore b/lib/impure/nre/.gitignore
new file mode 100644
index 000000000..3d647a25e
--- /dev/null
+++ b/lib/impure/nre/.gitignore
@@ -0,0 +1,9 @@
+# all executables
+*
+!*/
+!*.*
+*.exe
+
+# Wildcard patterns.
+*.swp
+nimcache
diff --git a/lib/impure/nre/private/util.nim b/lib/impure/nre/private/util.nim
new file mode 100644
index 000000000..ed8420776
--- /dev/null
+++ b/lib/impure/nre/private/util.nim
@@ -0,0 +1,51 @@
+## INTERNAL FILE FOR USE ONLY BY nre.nim.
+import std/tables
+
+const Ident = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\128'..'\255'}
+const StartIdent = Ident - {'0'..'9'}
+
+template formatStr*(howExpr, namegetter, idgetter): untyped =
+  let how = howExpr
+  var val = newStringOfCap(how.len)
+  var i = 0
+  var lastNum = 1
+
+  while i < how.len:
+    if how[i] != '$':
+      val.add(how[i])
+      i += 1
+    else:
+      if how[i + 1] == '$':
+        val.add('$')
+        i += 2
+      elif how[i + 1] == '#':
+        var id {.inject.} = lastNum
+        val.add(idgetter)
+        lastNum += 1
+        i += 2
+      elif how[i + 1] in {'0'..'9'}:
+        i += 1
+        var id {.inject.} = 0
+        while i < how.len and how[i] in {'0'..'9'}:
+          id += (id * 10) + (ord(how[i]) - ord('0'))
+          i += 1
+        val.add(idgetter)
+        lastNum = id + 1
+      elif how[i + 1] in StartIdent:
+        i += 1
+        var name {.inject.} = ""
+        while i < how.len and how[i] in Ident:
+          name.add(how[i])
+          i += 1
+        val.add(namegetter)
+      elif how[i + 1] == '{':
+        i += 2
+        var name {.inject.} = ""
+        while i < how.len and how[i] != '}':
+          name.add(how[i])
+          i += 1
+        i += 1
+        val.add(namegetter)
+      else:
+        raise newException(ValueError, "Syntax error in format string at " & $i)
+  val
diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim
new file mode 100644
index 000000000..f4fc26380
--- /dev/null
+++ b/lib/impure/rdstdin.nim
@@ -0,0 +1,74 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains code for reading from `stdin`:idx:. On UNIX the
+## linenoise library is wrapped and set up to provide default key bindings
+## (e.g. you can navigate with the arrow keys). On Windows `system.readLine`
+## is used. This suffices because Windows' console already provides the
+## wanted functionality.
+
+runnableExamples("-r:off"):
+  echo readLineFromStdin("Is Nim awesome? (Y/n): ")
+  var line: string
+  while true:
+    let ok = readLineFromStdin("How are you? ", line)
+    if not ok: break # ctrl-C or ctrl-D will cause a break
+    if line.len > 0: echo line
+  echo "exiting"
+
+
+when defined(windows):
+  when defined(nimPreviewSlimSystem):
+    import std/syncio
+
+  proc readLineFromStdin*(prompt: string): string {.
+                          tags: [ReadIOEffect, WriteIOEffect].} =
+    ## Reads a line from stdin.
+    stdout.write(prompt)
+    stdout.flushFile()
+    result = readLine(stdin)
+
+  proc readLineFromStdin*(prompt: string, line: var string): bool {.
+                          tags: [ReadIOEffect, WriteIOEffect].} =
+    ## Reads a `line` from stdin. `line` must not be
+    ## `nil`! May throw an IO exception.
+    ## A line of text may be delimited by `CR`, `LF` or
+    ## `CRLF`. The newline character(s) are not part of the returned string.
+    ## Returns `false` if the end of the file has been reached, `true`
+    ## otherwise. If `false` is returned `line` contains no new data.
+    stdout.write(prompt)
+    result = readLine(stdin, line)
+
+elif defined(genode):
+  proc readLineFromStdin*(prompt: string): string {.
+                          tags: [ReadIOEffect, WriteIOEffect].} =
+    stdin.readLine()
+
+  proc readLineFromStdin*(prompt: string, line: var string): bool {.
+                          tags: [ReadIOEffect, WriteIOEffect].} =
+    stdin.readLine(line)
+
+else:
+  import std/linenoise
+
+  proc readLineFromStdin*(prompt: string, line: var string): bool {.
+                          tags: [ReadIOEffect, WriteIOEffect].} =
+    var buffer = linenoise.readLine(prompt)
+    if isNil(buffer):
+      line.setLen(0)
+      return false
+    line = $buffer
+    if line.len > 0:
+      historyAdd(buffer)
+    linenoise.free(buffer)
+    result = true
+
+  proc readLineFromStdin*(prompt: string): string {.inline.} =
+    if not readLineFromStdin(prompt, result):
+      raise newException(IOError, "Linenoise returned nil")
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
new file mode 100644
index 000000000..053c6ab55
--- /dev/null
+++ b/lib/impure/re.nim
@@ -0,0 +1,611 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(js):
+  {.error: "This library needs to be compiled with a c-like backend, and depends on PCRE; See jsre for JS backend.".}
+
+## Regular expression support for Nim.
+##
+## This module is implemented by providing a wrapper around the
+## `PCRE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
+## C library. This means that your application will depend on the PCRE
+## library's licence when using this module, which should not be a problem
+## though.
+##
+## .. note:: There are also alternative nimble packages such as [tinyre](https://github.com/khchen/tinyre)
+##   and [regex](https://github.com/nitely/nim-regex).
+##
+## PCRE's licence follows:
+##
+## .. include:: ../../doc/regexprs.txt
+##
+
+runnableExamples:
+  ## Unless specified otherwise, `start` parameter in each proc indicates
+  ## where the scan starts, but outputs are relative to the start of the input
+  ## string, not to `start`:
+  doAssert find("uxabc", re"(?<=x|y)ab", start = 1) == 2 # lookbehind assertion
+  doAssert find("uxabc", re"ab", start = 3) == -1 # we're past `start` => not found
+  doAssert not match("xabc", re"^abc$", start = 1)
+    # can't match start of string since we're starting at 1
+
+import
+  std/[pcre, strutils, rtarrays]
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+const
+  MaxSubpatterns* = 20
+    ## defines the maximum number of subpatterns that can be captured.
+    ## This limit still exists for `replacef` and `parallelReplace`.
+
+type
+  RegexFlag* = enum     ## options for regular expressions
+    reIgnoreCase = 0,   ## do caseless matching
+    reMultiLine = 1,    ## `^` and `$` match newlines within data
+    reDotAll = 2,       ## `.` matches anything including NL
+    reExtended = 3,     ## ignore whitespace and `#` comments
+    reStudy = 4         ## study the expression (may be omitted if the
+                        ## expression will be used only once)
+
+  RegexDesc = object
+    h: ptr Pcre
+    e: ptr ExtraData
+
+  Regex* = ref RegexDesc ## a compiled regular expression
+
+  RegexError* = object of ValueError
+    ## is raised if the pattern is no valid regular expression.
+
+when defined(gcDestructors):
+  when defined(nimAllowNonVarDestructor):
+    proc `=destroy`(x: RegexDesc) =
+      pcre.free_substring(cast[cstring](x.h))
+      if not isNil(x.e):
+        pcre.free_study(x.e)
+  else:
+    proc `=destroy`(x: var RegexDesc) =
+      pcre.free_substring(cast[cstring](x.h))
+      if not isNil(x.e):
+        pcre.free_study(x.e)
+
+proc raiseInvalidRegex(msg: string) {.noinline, noreturn.} =
+  var e: ref RegexError
+  new(e)
+  e.msg = msg
+  raise e
+
+proc rawCompile(pattern: string, flags: cint): ptr Pcre =
+  var
+    msg: cstring = ""
+    offset: cint = 0
+  result = pcre.compile(pattern, flags, addr(msg), addr(offset), nil)
+  if result == nil:
+    raiseInvalidRegex($msg & "\n" & pattern & "\n" & spaces(offset) & "^\n")
+
+proc finalizeRegEx(x: Regex) =
+  # XXX This is a hack, but PCRE does not export its "free" function properly.
+  # Sigh. The hack relies on PCRE's implementation (see `pcre_get.c`).
+  # Fortunately the implementation is unlikely to change.
+  pcre.free_substring(cast[cstring](x.h))
+  if not isNil(x.e):
+    pcre.free_study(x.e)
+
+proc re*(s: string, flags = {reStudy}): Regex =
+  ## Constructor of regular expressions.
+  ##
+  ## Note that Nim's
+  ## extended raw string literals support the syntax `re"[abc]"` as
+  ## a short form for `re(r"[abc]")`. Also note that since this
+  ## compiles the regular expression, which is expensive, you should
+  ## avoid putting it directly in the arguments of the functions like
+  ## the examples show below if you plan to use it a lot of times, as
+  ## this will hurt performance immensely. (e.g. outside a loop, ...)
+  when defined(gcDestructors):
+    result = Regex()
+  else:
+    new(result, finalizeRegEx)
+  result.h = rawCompile(s, cast[cint](flags - {reStudy}))
+  if reStudy in flags:
+    var msg: cstring = ""
+    var options: cint = 0
+    var hasJit: cint = 0
+    if pcre.config(pcre.CONFIG_JIT, addr hasJit) == 0:
+      if hasJit == 1'i32:
+        options = pcre.STUDY_JIT_COMPILE
+    result.e = pcre.study(result.h, options, addr msg)
+    if not isNil(msg): raiseInvalidRegex($msg)
+
+proc rex*(s: string, flags = {reStudy, reExtended}): Regex =
+  ## Constructor for extended regular expressions.
+  ##
+  ## The extended means that comments starting with `#` and
+  ## whitespace are ignored.
+  result = re(s, flags)
+
+proc bufSubstr(b: cstring, sPos, ePos: int): string {.inline.} =
+  ## Return a Nim string built from a slice of a cstring buffer.
+  ## Don't assume cstring is '\0' terminated
+  let sz = ePos - sPos
+  result = newString(sz+1)
+  copyMem(addr(result[0]), unsafeAddr(b[sPos]), sz)
+  result.setLen(sz)
+
+proc matchOrFind(buf: cstring, pattern: Regex, matches: var openArray[string],
+                 start, bufSize, flags: cint): cint =
+  var
+    rtarray = initRtArray[cint]((matches.len+1)*3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize, start, flags,
+      cast[ptr cint](rawMatches), (matches.len+1).cint*3)
+  if res < 0'i32: return res
+  for i in 1..int(res)-1:
+    var a = rawMatches[i * 2]
+    var b = rawMatches[i * 2 + 1]
+    if a >= 0'i32:
+      matches[i-1] = bufSubstr(buf, int(a), int(b))
+    else: matches[i-1] = ""
+  return rawMatches[1] - rawMatches[0]
+
+const MaxReBufSize* = high(cint)
+  ## Maximum PCRE (API 1) buffer start/size equal to `high(cint)`, which even
+  ## for 64-bit systems can be either 2`31`:sup:-1 or 2`63`:sup:-1.
+
+proc findBounds*(buf: cstring, pattern: Regex, matches: var openArray[string],
+                 start = 0, bufSize: int): tuple[first, last: int] =
+  ## returns the starting position and end position of `pattern` in `buf`
+  ## (where `buf` has length `bufSize` and is not necessarily `'\0'` terminated),
+  ## and the captured
+  ## substrings in the array `matches`. If it does not match, nothing
+  ## is written into `matches` and `(-1,0)` is returned.
+  ##
+  ## Note: The memory for `matches` needs to be allocated before this function is
+  ## called, otherwise it will just remain empty.
+  var
+    rtarray = initRtArray[cint]((matches.len+1)*3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
+      cast[ptr cint](rawMatches), (matches.len+1).cint*3)
+  if res < 0'i32: return (-1, 0)
+  for i in 1..int(res)-1:
+    var a = rawMatches[i * 2]
+    var b = rawMatches[i * 2 + 1]
+    if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b))
+    else: matches[i-1] = ""
+  return (rawMatches[0].int, rawMatches[1].int - 1)
+
+proc findBounds*(s: string, pattern: Regex, matches: var openArray[string],
+                 start = 0): tuple[first, last: int] {.inline.} =
+  ## returns the starting position and end position of `pattern` in `s`
+  ## and the captured substrings in the array `matches`.
+  ## If it does not match, nothing
+  ## is written into `matches` and `(-1,0)` is returned.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  runnableExamples:
+    var matches = newSeq[string](1)
+    let (first, last) = findBounds("Hello World", re"(W\w+)", matches)
+    doAssert first == 6
+    doAssert last == 10
+    doAssert matches[0] == "World"
+  result = findBounds(cstring(s), pattern, matches,
+      min(start, MaxReBufSize), min(s.len, MaxReBufSize))
+
+proc findBounds*(buf: cstring, pattern: Regex,
+                 matches: var openArray[tuple[first, last: int]],
+                 start = 0, bufSize: int): tuple[first, last: int] =
+  ## returns the starting position and end position of `pattern` in `buf`
+  ## (where `buf` has length `bufSize` and is not necessarily `'\0'` terminated),
+  ## and the captured substrings in the array `matches`.
+  ## If it does not match, nothing is written into `matches` and
+  ## `(-1,0)` is returned.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  var
+    rtarray = initRtArray[cint]((matches.len+1)*3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
+      cast[ptr cint](rawMatches), (matches.len+1).cint*3)
+  if res < 0'i32: return (-1, 0)
+  for i in 1..int(res)-1:
+    var a = rawMatches[i * 2]
+    var b = rawMatches[i * 2 + 1]
+    if a >= 0'i32: matches[i-1] = (int(a), int(b)-1)
+    else: matches[i-1] = (-1,0)
+  return (rawMatches[0].int, rawMatches[1].int - 1)
+
+proc findBounds*(s: string, pattern: Regex,
+                 matches: var openArray[tuple[first, last: int]],
+                 start = 0): tuple[first, last: int] {.inline.} =
+  ## returns the starting position and end position of `pattern` in `s`
+  ## and the captured substrings in the array `matches`.
+  ## If it does not match, nothing is written into `matches` and
+  ## `(-1,0)` is returned.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  runnableExamples:
+    var matches = newSeq[tuple[first, last: int]](1)
+    let (first, last) = findBounds("Hello World", re"(\w+)", matches)
+    doAssert first == 0
+    doAssert last == 4
+    doAssert matches[0] == (0, 4)
+  result = findBounds(cstring(s), pattern, matches,
+      min(start, MaxReBufSize), min(s.len, MaxReBufSize))
+
+proc findBoundsImpl(buf: cstring, pattern: Regex,
+                    start = 0, bufSize = 0, flags = 0): tuple[first, last: int] =
+  var rtarray = initRtArray[cint](3)
+  let rawMatches = rtarray.getRawData
+  let res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, flags.int32,
+                cast[ptr cint](rawMatches), 3)
+
+  if res < 0'i32:
+    result = (-1, 0)
+  else:
+    result = (int(rawMatches[0]), int(rawMatches[1]-1))
+
+proc findBounds*(buf: cstring, pattern: Regex,
+                 start = 0, bufSize: int): tuple[first, last: int] =
+  ## returns the `first` and `last` position of `pattern` in `buf`,
+  ## where `buf` has length `bufSize` (not necessarily `'\0'` terminated).
+  ## If it does not match, `(-1,0)` is returned.
+  var
+    rtarray = initRtArray[cint](3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
+      cast[ptr cint](rawMatches), 3)
+  if res < 0'i32: return (int(res), 0)
+  return (int(rawMatches[0]), int(rawMatches[1]-1))
+
+proc findBounds*(s: string, pattern: Regex,
+                 start = 0): tuple[first, last: int] {.inline.} =
+  ## returns the `first` and `last` position of `pattern` in `s`.
+  ## If it does not match, `(-1,0)` is returned.
+  ##
+  ## Note: there is a speed improvement if the matches do not need to be captured.
+  runnableExamples:
+    assert findBounds("01234abc89", re"abc") == (5,7)
+  result = findBounds(cstring(s), pattern,
+      min(start, MaxReBufSize), min(s.len, MaxReBufSize))
+
+proc matchOrFind(buf: cstring, pattern: Regex, start, bufSize: int, flags: cint): cint =
+  var
+    rtarray = initRtArray[cint](3)
+    rawMatches = rtarray.getRawData
+  result = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, flags,
+                    cast[ptr cint](rawMatches), 3)
+  if result >= 0'i32:
+    result = rawMatches[1] - rawMatches[0]
+
+proc matchLen*(s: string, pattern: Regex, matches: var openArray[string],
+              start = 0): int {.inline.} =
+  ## the same as `match`, but it returns the length of the match,
+  ## if there is no match, `-1` is returned. Note that a match length
+  ## of zero can happen.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  result = matchOrFind(cstring(s), pattern, matches, start.cint, s.len.cint, pcre.ANCHORED)
+
+proc matchLen*(buf: cstring, pattern: Regex, matches: var openArray[string],
+              start = 0, bufSize: int): int {.inline.} =
+  ## the same as `match`, but it returns the length of the match,
+  ## if there is no match, `-1` is returned. Note that a match length
+  ## of zero can happen.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  return matchOrFind(buf, pattern, matches, start.cint, bufSize.cint, pcre.ANCHORED)
+
+proc matchLen*(s: string, pattern: Regex, start = 0): int {.inline.} =
+  ## the same as `match`, but it returns the length of the match,
+  ## if there is no match, `-1` is returned. Note that a match length
+  ## of zero can happen.
+  ##
+  runnableExamples:
+    doAssert matchLen("abcdefg", re"cde", 2) == 3
+    doAssert matchLen("abcdefg", re"abcde") == 5
+    doAssert matchLen("abcdefg", re"cde") == -1
+  result = matchOrFind(cstring(s), pattern, start.cint, s.len.cint, pcre.ANCHORED)
+
+proc matchLen*(buf: cstring, pattern: Regex, start = 0, bufSize: int): int {.inline.} =
+  ## the same as `match`, but it returns the length of the match,
+  ## if there is no match, `-1` is returned. Note that a match length
+  ## of zero can happen.
+  result = matchOrFind(buf, pattern, start.cint, bufSize, pcre.ANCHORED)
+
+proc match*(s: string, pattern: Regex, start = 0): bool {.inline.} =
+  ## returns `true` if `s[start..]` matches the `pattern`.
+  result = matchLen(cstring(s), pattern, start, s.len) != -1
+
+proc match*(s: string, pattern: Regex, matches: var openArray[string],
+           start = 0): bool {.inline.} =
+  ## returns `true` if `s[start..]` matches the `pattern` and
+  ## the captured substrings in the array `matches`. If it does not
+  ## match, nothing is written into `matches` and `false` is
+  ## returned.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  runnableExamples:
+    import std/sequtils
+    var matches: array[2, string]
+    if match("abcdefg", re"c(d)ef(g)", matches, 2):
+      doAssert toSeq(matches) == @["d", "g"]
+  result = matchLen(cstring(s), pattern, matches, start, s.len) != -1
+
+proc match*(buf: cstring, pattern: Regex, matches: var openArray[string],
+           start = 0, bufSize: int): bool {.inline.} =
+  ## returns `true` if `buf[start..<bufSize]` matches the `pattern` and
+  ## the captured substrings in the array `matches`. If it does not
+  ## match, nothing is written into `matches` and `false` is
+  ## returned.
+  ## `buf` has length `bufSize` (not necessarily `'\0'` terminated).
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  result = matchLen(buf, pattern, matches, start, bufSize) != -1
+
+proc find*(buf: cstring, pattern: Regex, matches: var openArray[string],
+           start = 0, bufSize: int): int =
+  ## returns the starting position of `pattern` in `buf` and the captured
+  ## substrings in the array `matches`. If it does not match, nothing
+  ## is written into `matches` and `-1` is returned.
+  ## `buf` has length `bufSize` (not necessarily `'\0'` terminated).
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  var
+    rtarray = initRtArray[cint]((matches.len+1)*3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
+      cast[ptr cint](rawMatches), (matches.len+1).cint*3)
+  if res < 0'i32: return res
+  for i in 1..int(res)-1:
+    var a = rawMatches[i * 2]
+    var b = rawMatches[i * 2 + 1]
+    if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b))
+    else: matches[i-1] = ""
+  return rawMatches[0]
+
+proc find*(s: string, pattern: Regex, matches: var openArray[string],
+           start = 0): int {.inline.} =
+  ## returns the starting position of `pattern` in `s` and the captured
+  ## substrings in the array `matches`. If it does not match, nothing
+  ## is written into `matches` and `-1` is returned.
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  result = find(cstring(s), pattern, matches, start, s.len)
+
+proc find*(buf: cstring, pattern: Regex, start = 0, bufSize: int): int =
+  ## returns the starting position of `pattern` in `buf`,
+  ## where `buf` has length `bufSize` (not necessarily `'\0'` terminated).
+  ## If it does not match, `-1` is returned.
+  var
+    rtarray = initRtArray[cint](3)
+    rawMatches = rtarray.getRawData
+    res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, start.cint, 0'i32,
+      cast[ptr cint](rawMatches), 3)
+  if res < 0'i32: return res
+  return rawMatches[0]
+
+proc find*(s: string, pattern: Regex, start = 0): int {.inline.} =
+  ## returns the starting position of `pattern` in `s`. If it does not
+  ## match, `-1` is returned. We start the scan at `start`.
+  runnableExamples:
+    doAssert find("abcdefg", re"cde") == 2
+    doAssert find("abcdefg", re"abc") == 0
+    doAssert find("abcdefg", re"zz") == -1 # not found
+    doAssert find("abcdefg", re"cde", start = 2) == 2 # still 2
+    doAssert find("abcdefg", re"cde", start = 3) == -1 # we're past the start position
+    doAssert find("xabc", re"(?<=x|y)abc", start = 1) == 1
+      # lookbehind assertion `(?<=x|y)` can look behind `start`
+  result = find(cstring(s), pattern, start, s.len)
+
+iterator findAll*(s: string, pattern: Regex, start = 0): string =
+  ## Yields all matching *substrings* of `s` that match `pattern`.
+  ##
+  ## Note that since this is an iterator you should not modify the string you
+  ## are iterating over: bad things could happen.
+  var
+    i = int32(start)
+    rtarray = initRtArray[cint](3)
+    rawMatches = rtarray.getRawData
+  while true:
+    let res = pcre.exec(pattern.h, pattern.e, s, len(s).cint, i, 0'i32,
+      cast[ptr cint](rawMatches), 3)
+    if res < 0'i32: break
+    let a = rawMatches[0]
+    let b = rawMatches[1]
+    if a == b and a == i: break
+    yield substr(s, int(a), int(b)-1)
+    i = b
+
+iterator findAll*(buf: cstring, pattern: Regex, start = 0, bufSize: int): string =
+  ## Yields all matching `substrings` of `s` that match `pattern`.
+  ##
+  ## Note that since this is an iterator you should not modify the string you
+  ## are iterating over: bad things could happen.
+  var
+    i = int32(start)
+    rtarray = initRtArray[cint](3)
+    rawMatches = rtarray.getRawData
+  while true:
+    let res = pcre.exec(pattern.h, pattern.e, buf, bufSize.cint, i, 0'i32,
+      cast[ptr cint](rawMatches), 3)
+    if res < 0'i32: break
+    let a = rawMatches[0]
+    let b = rawMatches[1]
+    if a == b and a == i: break
+    var str = newString(b-a)
+    copyMem(str[0].addr, unsafeAddr(buf[a]), b-a)
+    yield str
+    i = b
+
+proc findAll*(s: string, pattern: Regex, start = 0): seq[string] {.inline.} =
+  ## returns all matching `substrings` of `s` that match `pattern`.
+  ## If it does not match, `@[]` is returned.
+  result = @[]
+  for x in findAll(s, pattern, start): result.add x
+
+template `=~` *(s: string, pattern: Regex): untyped =
+  ## This calls `match` with an implicit declared `matches` array that
+  ## can be used in the scope of the `=~` call:
+  runnableExamples:
+    proc parse(line: string): string =
+      if line =~ re"\s*(\w+)\s*\=\s*(\w+)": # matches a key=value pair:
+        result = $(matches[0], matches[1])
+      elif line =~ re"\s*(\#.*)": # matches a comment
+        # note that the implicit `matches` array is different from 1st branch
+        result = $(matches[0],)
+      else: raiseAssert "unreachable"
+      doAssert not declared(matches)
+    doAssert parse("NAME = LENA") == """("NAME", "LENA")"""
+    doAssert parse("   # comment ... ") == """("# comment ... ",)"""
+  bind MaxSubpatterns
+  when not declaredInScope(matches):
+    var matches {.inject.}: array[MaxSubpatterns, string]
+  match(s, pattern, matches)
+
+# ------------------------- more string handling ------------------------------
+
+proc contains*(s: string, pattern: Regex, start = 0): bool {.inline.} =
+  ## same as `find(s, pattern, start) >= 0`
+  return find(s, pattern, start) >= 0
+
+proc contains*(s: string, pattern: Regex, matches: var openArray[string],
+              start = 0): bool {.inline.} =
+  ## same as `find(s, pattern, matches, start) >= 0`
+  ##
+  ## .. note:: The memory for `matches` needs to be allocated before this function is called, otherwise it will just remain empty.
+  return find(s, pattern, matches, start) >= 0
+
+proc startsWith*(s: string, prefix: Regex): bool {.inline.} =
+  ## returns true if `s` starts with the pattern `prefix`
+  result = matchLen(s, prefix) >= 0
+
+proc endsWith*(s: string, suffix: Regex): bool {.inline.} =
+  ## returns true if `s` ends with the pattern `suffix`
+  for i in 0 .. s.len-1:
+    if matchLen(s, suffix, i) == s.len - i: return true
+
+proc replace*(s: string, sub: Regex, by = ""): string =
+  ## Replaces `sub` in `s` by the string `by`. Captures cannot be
+  ## accessed in `by`.
+  runnableExamples:
+    doAssert "var1=key; var2=key2".replace(re"(\w+)=(\w+)") == "; "
+    doAssert "var1=key; var2=key2".replace(re"(\w+)=(\w+)", "?") == "?; ?"
+  result = ""
+  var prev = 0
+  var flags = int32(0)
+  while prev < s.len:
+    var match = findBoundsImpl(s.cstring, sub, prev, s.len, flags)
+    flags = 0
+    if match.first < 0: break
+    add(result, substr(s, prev, match.first-1))
+    add(result, by)
+    if match.first > match.last:
+      # 0-len match
+      flags = pcre.NOTEMPTY_ATSTART
+    prev = match.last + 1
+  add(result, substr(s, prev))
+
+proc replacef*(s: string, sub: Regex, by: string): string =
+  ## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by`
+  ## with the notation `$i` and `$#` (see strutils.\`%\`).
+  runnableExamples:
+    doAssert "var1=key; var2=key2".replacef(re"(\w+)=(\w+)", "$1<-$2$2") ==
+      "var1<-keykey; var2<-key2key2"
+  result = ""
+  var caps: array[MaxSubpatterns, string]
+  var prev = 0
+  while prev < s.len:
+    var match = findBounds(s, sub, caps, prev)
+    if match.first < 0: break
+    add(result, substr(s, prev, match.first-1))
+    addf(result, by, caps)
+    if match.last + 1 == prev: break
+    prev = match.last + 1
+  add(result, substr(s, prev))
+
+proc multiReplace*(s: string, subs: openArray[
+                   tuple[pattern: Regex, repl: string]]): string =
+  ## Returns a modified copy of `s` with the substitutions in `subs`
+  ## applied in parallel.
+  result = ""
+  var i = 0
+  var caps: array[MaxSubpatterns, string]
+  while i < s.len:
+    block searchSubs:
+      for j in 0..high(subs):
+        var x = matchLen(s, subs[j][0], caps, i)
+        if x > 0:
+          addf(result, subs[j][1], caps)
+          inc(i, x)
+          break searchSubs
+      add(result, s[i])
+      inc(i)
+  # copy the rest:
+  add(result, substr(s, i))
+
+proc transformFile*(infile, outfile: string,
+                    subs: openArray[tuple[pattern: Regex, repl: string]]) =
+  ## reads in the file `infile`, performs a parallel replacement (calls
+  ## `parallelReplace`) and writes back to `outfile`. Raises `IOError` if an
+  ## error occurs. This is supposed to be used for quick scripting.
+  var x = readFile(infile)
+  writeFile(outfile, x.multiReplace(subs))
+
+iterator split*(s: string, sep: Regex; maxsplit = -1): string =
+  ## Splits the string `s` into substrings.
+  ##
+  ## Substrings are separated by the regular expression `sep`
+  ## (and the portion matched by `sep` is not returned).
+  runnableExamples:
+    import std/sequtils
+    doAssert toSeq(split("00232this02939is39an22example111", re"\d+")) ==
+      @["", "this", "is", "an", "example", ""]
+  var last = 0
+  var splits = maxsplit
+  var x = -1
+  if len(s) == 0:
+    last = 1
+  if matchLen(s, sep, 0) == 0:
+    x = 0
+  while last <= len(s):
+    var first = last
+    var sepLen = 1
+    if x == 0:
+      inc(last)
+    while last < len(s):
+      x = matchLen(s, sep, last)
+      if x >= 0:
+        sepLen = x
+        break
+      inc(last)
+    if splits == 0: last = len(s)
+    yield substr(s, first, last-1)
+    if splits == 0: break
+    dec(splits)
+    inc(last, sepLen)
+
+proc split*(s: string, sep: Regex, maxsplit = -1): seq[string] {.inline.} =
+  ## Splits the string `s` into a seq of substrings.
+  ##
+  ## The portion matched by `sep` is not returned.
+  result = @[]
+  for x in split(s, sep, maxsplit): result.add x
+
+proc escapeRe*(s: string): string =
+  ## escapes `s` so that it is matched verbatim when used as a regular
+  ## expression.
+  result = ""
+  for c in items(s):
+    case c
+    of 'a'..'z', 'A'..'Z', '0'..'9', '_':
+      result.add(c)
+    else:
+      result.add("\\x")
+      result.add(toHex(ord(c), 2))
diff --git a/lib/impure/web.nim b/lib/impure/web.nim
deleted file mode 100755
index af302cc57..000000000
--- a/lib/impure/web.nim
+++ /dev/null
@@ -1,62 +0,0 @@
-#

-#

-#            Nimrod's Runtime Library

-#        (c) Copyright 2010 Andreas Rumpf

-#

-#    See the file "copying.txt", included in this

-#    distribution, for details about the copyright.

-#

-

-## This module contains simple high-level procedures for dealing with the
-## web. Use cases: 
-##
-## * requesting URLs
-## * sending and retrieving emails
-## * sending and retrieving files from an FTP server
-##
-## Currently only requesting URLs is implemented. The implementation depends
-## on the libcurl library!
-##
-## **Deprecated since version 0.8.8:** Use the ``httpclient`` module instead. 
-## 
-
-{.deprecated.}
-
-import libcurl, streams
-
-proc curlwrapperWrite(p: pointer, size, nmemb: int, 
-                      data: pointer): int {.cdecl.} = 
-  var stream = cast[PStream](data)
-  stream.writeData(stream, p, size*nmemb)
-  return size*nmemb
-
-proc URLretrieveStream*(url: string): PStream = 
-  ## retrieves the given `url` and returns a stream which one can read from to
-  ## obtain the contents. Returns nil if an error occurs.
-  result = newStringStream()
-  var hCurl = easy_init() 
-  if hCurl == nil: return nil
-  if easy_setopt(hCurl, OPT_URL, url) != E_OK: return nil
-  if easy_setopt(hCurl, OPT_WRITEFUNCTION, 
-                      curlwrapperWrite) != E_OK: return nil
-  if easy_setopt(hCurl, OPT_WRITEDATA, result) != E_OK: return nil
-  if easy_perform(hCurl) != E_OK: return nil
-  easy_cleanup(hCurl)
-  
-proc URLretrieveString*(url: string): string = 
-  ## retrieves the given `url` and returns the contents. Returns nil if an
-  ## error occurs.
-  var stream = newStringStream()
-  var hCurl = easy_init()
-  if hCurl == nil: return nil
-  if easy_setopt(hCurl, OPT_URL, url) != E_OK: return nil
-  if easy_setopt(hCurl, OPT_WRITEFUNCTION, 
-                      curlwrapperWrite) != E_OK: return nil
-  if easy_setopt(hCurl, OPT_WRITEDATA, stream) != E_OK: return nil
-  if easy_perform(hCurl) != E_OK: return nil
-  easy_cleanup(hCurl)
-  result = stream.data
-
-when isMainModule:
-  echo URLretrieveString("http://nimrod.ethexor.com/")
-
diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim
deleted file mode 100755
index 09bf8f7cc..000000000
--- a/lib/impure/zipfiles.nim
+++ /dev/null
@@ -1,144 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements a zip archive creator/reader/modifier.
-
-import 
-  streams, libzip, times, os
-
-type
-  TZipArchive* = object of TObject ## represents a zip archive
-    mode: TFileMode
-    w: PZip
-
-
-proc zipError(z: var TZipArchive) = 
-  var e: ref EIO
-  new(e)
-  e.msg = $zip_strerror(z.w)
-  raise e
-  
-proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =
-  ## Opens a zip file for reading, writing or appending. All file modes are 
-  ## supported. Returns true iff successful, false otherwise.
-  var err, flags: int32
-  case mode
-  of fmRead, fmReadWriteExisting, fmAppend: flags = 0
-  of fmWrite:                               
-    if existsFile(filename): removeFile(filename)
-    flags = ZIP_CREATE or ZIP_EXCL
-  of fmReadWrite: flags = ZIP_CREATE
-  z.w = zip_open(filename, flags, addr(err))
-  z.mode = mode
-  result = z.w != nil
-
-proc close*(z: var TZipArchive) =
-  ## Closes a zip file.
-  zip_close(z.w)
- 
-proc createDir*(z: var TZipArchive, dir: string) = 
-  ## Creates a directory within the `z` archive. This does not fail if the
-  ## directory already exists. Note that for adding a file like 
-  ## ``"path1/path2/filename"`` it is not necessary
-  ## to create the ``"path/path2"`` subdirectories - it will be done 
-  ## automatically by ``addFile``. 
-  assert(z.mode != fmRead) 
-  discard zip_add_dir(z.w, dir)
-  zip_error_clear(z.w)
-
-proc addFile*(z: var TZipArchive, dest, src: string) = 
-  ## Adds the file `src` to the archive `z` with the name `dest`. `dest`
-  ## may contain a path that will be created. 
-  assert(z.mode != fmRead) 
-  var zipsrc = zip_source_file(z.w, src, 0, -1)
-  if zipsrc == nil:
-    echo("Dest: " & dest)
-    echo("Src: " & src)
-    zipError(z)
-  if zip_add(z.w, dest, zipsrc) < 0'i32:
-    zip_source_free(zipsrc)
-    zipError(z)
-
-proc addFile*(z: var TZipArchive, file: string) = 
-  ## A shortcut for ``addFile(z, file, file)``, i.e. the name of the source is
-  ## the name of the destination.
-  addFile(z, file, file)
-  
-proc mySourceCallback(state, data: pointer, len: int, 
-                      cmd: Tzip_source_cmd): int {.cdecl.} = 
-  var src = cast[PStream](state)
-  case cmd
-  of ZIP_SOURCE_OPEN: 
-    if src.setPosition != nil: src.setPosition(src, 0) # reset
-  of ZIP_SOURCE_READ:
-    result = src.readData(src, data, len)
-  of ZIP_SOURCE_CLOSE: src.close(src)
-  of ZIP_SOURCE_STAT: 
-    var stat = cast[PZipStat](data)
-    zip_stat_init(stat)
-    stat.size = high(int32)-1 # we don't know the size
-    stat.mtime = getTime()
-    result = sizeof(TZipStat)
-  of ZIP_SOURCE_ERROR:
-    var err = cast[ptr array[0..1, cint]](data)
-    err[0] = ZIP_ER_INTERNAL
-    err[1] = 0
-    result = 2*sizeof(cint)
-  of constZIP_SOURCE_FREE: GC_unref(src)
-  else: assert(false)
-  
-proc addFile*(z: var TZipArchive, dest: string, src: PStream) = 
-  ## Adds a file named with `dest` to the archive `z`. `dest`
-  ## may contain a path. The file's content is read from the `src` stream.
-  assert(z.mode != fmRead)
-  GC_ref(src)
-  var zipsrc = zip_source_function(z.w, mySourceCallback, cast[pointer](src))
-  if zipsrc == nil: zipError(z)
-  if zip_add(z.w, dest, zipsrc) < 0'i32:
-    zip_source_free(zipsrc)
-    zipError(z)
-  
-# -------------- zip file stream ---------------------------------------------
-
-type
-  TZipFileStream = object of TStream
-    f: Pzip_file
-
-  PZipFileStream* = 
-    ref TZipFileStream ## a reader stream of a file within a zip archive 
-
-proc fsClose(s: PZipFileStream) = zip_fclose(s.f)
-proc fsReadData(s: PZipFileStream, buffer: pointer, bufLen: int): int = 
-  result = zip_fread(s.f, buffer, bufLen)
-
-proc newZipFileStream(f: PZipFile): PZipFileStream = 
-  new(result)
-  result.f = f
-  result.close = fsClose
-  result.readData = fsReadData
-  # other methods are nil!
-
-# ----------------------------------------------------------------------------
-  
-proc getStream*(z: var TZipArchive, filename: string): PZipFileStream = 
-  ## returns a stream that can be used to read the file named `filename`
-  ## from the archive `z`. Returns nil in case of an error.
-  ## The returned stream does not support the `setPosition`, `getPosition`, 
-  ## `writeData` or `atEnd` methods.
-  var x = zip_fopen(z.w, filename, 0'i32)
-  if x != nil: result = newZipFileStream(x)
-  
-iterator walkFiles*(z: var TZipArchive): string = 
-  ## walks over all files in the archive `z` and returns the filename 
-  ## (including the path).
-  var i = 0
-  var num = int(zip_get_num_files(z.w))
-  while i < num:
-    yield $zip_get_name(z.w, i, 0'i32)
-    inc(i)
diff --git a/lib/js/asyncjs.nim b/lib/js/asyncjs.nim
new file mode 100644
index 000000000..9b043f3e5
--- /dev/null
+++ b/lib/js/asyncjs.nim
@@ -0,0 +1,269 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim Authors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+
+## This module implements types and macros for writing asynchronous code
+## for the JS backend. It provides tools for interaction with JavaScript async API-s
+## and libraries, writing async procedures in Nim and converting callback-based code
+## to promises.
+##
+## A Nim procedure is asynchronous when it includes the `{.async.}` pragma. It
+## should always have a `Future[T]` return type or not have a return type at all.
+## A `Future[void]` return type is assumed by default.
+##
+## This is roughly equivalent to the `async` keyword in JavaScript code.
+##
+##   ```nim
+##   proc loadGame(name: string): Future[Game] {.async.} =
+##     # code
+##   ```
+##
+## should be equivalent to
+##
+##   ```javascript
+##   async function loadGame(name) {
+##     // code
+##   }
+##   ```
+##
+## A call to an asynchronous procedure usually needs `await` to wait for
+## the completion of the `Future`.
+##
+##   ```nim
+##   var game = await loadGame(name)
+##   ```
+##
+## Often, you might work with callback-based API-s. You can wrap them with
+## asynchronous procedures using promises and `newPromise`:
+##
+##   ```nim
+##   proc loadGame(name: string): Future[Game] =
+##     var promise = newPromise() do (resolve: proc(response: Game)):
+##       cbBasedLoadGame(name) do (game: Game):
+##         resolve(game)
+##     return promise
+##   ```
+##
+## Forward definitions work properly, you just need to always add the `{.async.}` pragma:
+##
+##   ```nim
+##   proc loadGame(name: string): Future[Game] {.async.}
+##   ```
+##
+## JavaScript compatibility
+## ========================
+##
+## Nim currently generates `async/await` JavaScript code which is supported in modern
+## EcmaScript and most modern versions of browsers, Node.js and Electron.
+## If you need to use this module with older versions of JavaScript, you can
+## use a tool that backports the resulting JavaScript code, as babel.
+
+# xxx code: javascript above gives `LanguageXNotSupported` warning.
+
+when not defined(js) and not defined(nimsuggest):
+  {.fatal: "Module asyncjs is designed to be used with the JavaScript backend.".}
+
+import std/jsffi
+import std/macros
+import std/private/since
+
+type
+  Future*[T] = ref object
+    future*: T
+  ## Wraps the return type of an asynchronous procedure.
+
+  PromiseJs* {.importjs: "Promise".} = ref object
+  ## A JavaScript Promise.
+
+
+proc replaceReturn(node: var NimNode) =
+  var z = 0
+  for s in node:
+    var son = node[z]
+    let jsResolve = ident("jsResolve")
+    if son.kind == nnkReturnStmt:
+      let value = if son[0].kind != nnkEmpty: nnkCall.newTree(jsResolve, son[0]) else: jsResolve
+      node[z] = nnkReturnStmt.newTree(value)
+    elif son.kind == nnkAsgn and son[0].kind == nnkIdent and $son[0] == "result":
+      node[z] = nnkAsgn.newTree(son[0], nnkCall.newTree(jsResolve, son[1]))
+    elif son.kind in RoutineNodes:
+      discard
+    else:
+      replaceReturn(son)
+    inc z
+
+proc isFutureVoid(node: NimNode): bool =
+  result = node.kind == nnkBracketExpr and
+           node[0].kind == nnkIdent and $node[0] == "Future" and
+           node[1].kind == nnkIdent and $node[1] == "void"
+
+proc generateJsasync(arg: NimNode): NimNode =
+  if arg.kind notin {nnkProcDef, nnkLambda, nnkMethodDef, nnkDo, nnkProcTy}:
+      error("Cannot transform this node kind into an async proc." &
+            " proc/method definition or lambda node expected.")
+
+  # Transform type X = proc (): something {.async.}
+  # into      type X = proc (): Future[something]
+  if arg.kind == nnkProcTy:
+    result = arg
+    if arg[0][0].kind == nnkEmpty:
+      result[0][0] = quote do: Future[void]
+    return result
+
+  result = arg
+  var isVoid = false
+  let jsResolve = ident("jsResolve")
+  if arg.params[0].kind == nnkEmpty:
+    result.params[0] = nnkBracketExpr.newTree(ident("Future"), ident("void"))
+    isVoid = true
+  elif isFutureVoid(arg.params[0]):
+    isVoid = true
+
+  var code = result.body
+  replaceReturn(code)
+  result.body = nnkStmtList.newTree()
+
+  if len(code) > 0:
+    var awaitFunction = quote:
+      proc await[T](f: Future[T]): T {.importjs: "(await #)", used.}
+    result.body.add(awaitFunction)
+
+    var resolve: NimNode
+    if isVoid:
+      resolve = quote:
+        var `jsResolve` {.importjs: "undefined".}: Future[void]
+    else:
+      resolve = quote:
+        proc jsResolve[T](a: T): Future[T] {.importjs: "#", used.}
+        proc jsResolve[T](a: Future[T]): Future[T] {.importjs: "#", used.}
+    result.body.add(resolve)
+  else:
+    result.body = newEmptyNode()
+  for child in code:
+    result.body.add(child)
+
+  if len(code) > 0 and isVoid:
+    var voidFix = quote:
+      return `jsResolve`
+    result.body.add(voidFix)
+
+  let asyncPragma = quote:
+    {.codegenDecl: "async function $2($3)".}
+
+  result.addPragma(asyncPragma[0])
+
+macro async*(arg: untyped): untyped =
+  ## Macro which converts normal procedures into
+  ## javascript-compatible async procedures.
+  if arg.kind == nnkStmtList:
+    result = newStmtList()
+    for oneProc in arg:
+      result.add generateJsasync(oneProc)
+  else:
+    result = generateJsasync(arg)
+
+proc newPromise*[T](handler: proc(resolve: proc(response: T))): Future[T] {.importjs: "(new Promise(#))".}
+  ## A helper for wrapping callback-based functions
+  ## into promises and async procedures.
+
+proc newPromise*(handler: proc(resolve: proc())): Future[void] {.importjs: "(new Promise(#))".}
+  ## A helper for wrapping callback-based functions
+  ## into promises and async procedures.
+
+template maybeFuture(T): untyped =
+  # avoids `Future[Future[T]]`
+  when T is Future: T
+  else: Future[T]
+
+
+since (1, 5, 1):
+  #[
+  TODO:
+  * map `Promise.all()`
+  * proc toString*(a: Error): cstring {.importjs: "#.toString()".}
+
+  Note:
+  We probably can't have a `waitFor` in js in browser (single threaded), but maybe it would be possible
+  in in nodejs, see https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options
+  and https://stackoverflow.com/questions/61377358/javascript-wait-for-async-call-to-finish-before-returning-from-function-witho
+  ]#
+
+  type Error*  {.importjs: "Error".} = ref object of JsRoot
+    ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
+    message*: cstring
+    name*: cstring
+
+  type OnReject* = proc(reason: Error)
+
+  proc then*[T](future: Future[T], onSuccess: proc, onReject: OnReject = nil): auto =
+    ## See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
+    ## Returns a `Future` from the return type of `onSuccess(T.default)`.
+    runnableExamples("-r:off"):
+      from std/sugar import `=>`
+
+      proc fn(n: int): Future[int] {.async.} =
+        if n >= 7: raise newException(ValueError, "foobar: " & $n)
+        else: result = n * 2
+
+      proc asyncFact(n: int): Future[int] {.async.} =
+        if n > 0: result = n * await asyncFact(n-1)
+        else: result = 1
+
+      proc main() {.async.} =
+        block: # then
+          assert asyncFact(3).await == 3*2
+          assert asyncFact(3).then(asyncFact).await == 6*5*4*3*2
+          let x1 = await fn(3)
+          assert x1 == 3 * 2
+          let x2 = await fn(4)
+            .then((a: int) => a.float)
+            .then((a: float) => $a)
+          assert x2 == "8.0"
+
+        block: # then with `onReject` callback
+          var witness = 1
+          await fn(6).then((a: int) => (witness = 2), (r: Error) => (witness = 3))
+          assert witness == 2
+          await fn(7).then((a: int) => (witness = 2), (r: Error) => (witness = 3))
+          assert witness == 3
+
+    template impl(call): untyped =
+      # see D20210421T014713
+      when typeof(block: call) is void:
+        var ret: Future[void]
+      else:
+        var ret = default(maybeFuture(typeof(call)))
+      typeof(ret)
+    when T is void:
+      type A = impl(onSuccess())
+    else:
+      type A = impl(onSuccess(default(T)))
+    var ret: A
+    {.emit: "`ret` = `future`.then(`onSuccess`, `onReject`);".}
+    return ret
+
+  proc catch*[T](future: Future[T], onReject: OnReject): Future[void] =
+    ## See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
+    runnableExamples("-r:off"):
+      from std/sugar import `=>`
+      from std/strutils import contains
+
+      proc fn(n: int): Future[int] {.async.} =
+        if n >= 7: raise newException(ValueError, "foobar: " & $n)
+        else: result = n * 2
+
+      proc main() {.async.} =
+        var reason: Error
+        await fn(6).catch((r: Error) => (reason = r)) # note: `()` are needed, `=> reason = r` would not work
+        assert reason == nil
+        await fn(7).catch((r: Error) => (reason = r))
+        assert reason != nil
+        assert  "foobar: 7" in $reason.message
+
+      discard main()
+
+    {.emit: "`result` = `future`.catch(`onReject`);".}
diff --git a/lib/js/dom.nim b/lib/js/dom.nim
new file mode 100644
index 000000000..be2a34db1
--- /dev/null
+++ b/lib/js/dom.nim
@@ -0,0 +1,1841 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Declaration of the Document Object Model for the `JavaScript backend
+## <backends.html#backends-the-javascript-target>`_.
+##
+##
+## Document Ready
+## --------------
+##
+## * Basic example of a document ready:
+runnableExamples"-b:js -r:off":
+  proc example(e: Event) = echo "Document is ready"
+  document.addEventListener("DOMContentLoaded", example)  # You can also use "load" event.
+## * This example runs 5 seconds after the document ready:
+runnableExamples"-b:js -r:off":
+  proc example() = echo "5 seconds after document ready"
+  proc domReady(e: Event) = discard setTimeout(example, 5_000) # Document is ready.
+  document.addEventListener("DOMContentLoaded", domReady)
+## Document onUnload
+## -----------------
+##
+## * Simple example of how to implement code that runs when the page unloads:
+runnableExamples"-b:js -r:off":
+  proc example(e: Event) = echo "Document is unloaded"
+  document.addEventListener("unload", example)  # You can also use "beforeunload".
+## Document Autorefresh
+## --------------------
+##
+## * Minimal example of a document autorefresh:
+runnableExamples"-b:js -r:off":
+  proc example() = window.location.reload()
+  discard setTimeout(example, 5_000)
+## - For more examples, see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
+
+
+import std/private/since
+when not defined(js):
+  {.error: "This module only works on the JavaScript platform".}
+
+const
+  DomApiVersion* = 3 ## the version of DOM API we try to follow. No guarantees though.
+
+type
+  EventTarget* {.importc.} = ref object of RootObj
+    onabort*: proc (event: Event) {.closure.}
+    onblur*: proc (event: Event) {.closure.}
+    onchange*: proc (event: Event) {.closure.}
+    onclick*: proc (event: Event) {.closure.}
+    ondblclick*: proc (event: Event) {.closure.}
+    onerror*: proc (event: Event) {.closure.}
+    onfocus*: proc (event: Event) {.closure.}
+    onkeydown*: proc (event: Event) {.closure.}
+    onkeypress*: proc (event: Event) {.closure.}
+    onkeyup*: proc (event: Event) {.closure.}
+    onload*: proc (event: Event) {.closure.}
+    onmousedown*: proc (event: Event) {.closure.}
+    onmousemove*: proc (event: Event) {.closure.}
+    onmouseout*: proc (event: Event) {.closure.}
+    onmouseover*: proc (event: Event) {.closure.}
+    onmouseup*: proc (event: Event) {.closure.}
+    onreset*: proc (event: Event) {.closure.}
+    onselect*: proc (event: Event) {.closure.}
+    onstorage*: proc (event: Event) {.closure.}
+    onsubmit*: proc (event: Event) {.closure.}
+    onunload*: proc (event: Event) {.closure.}
+    onloadstart*: proc (event: Event) {.closure.}
+    onprogress*: proc (event: Event) {.closure.}
+    onloadend*: proc (event: Event) {.closure.}
+
+  DomEvent* {.pure.} = enum
+    ## see `docs<https://developer.mozilla.org/en-US/docs/Web/Events>`_
+    Abort = "abort",
+    BeforeInput = "beforeinput",
+    Blur = "blur",
+    Click = "click",
+    CompositionEnd = "compositionend",
+    CompositionStart = "compositionstart",
+    CompositionUpdate = "compositionupdate",
+    DblClick = "dblclick",
+    Error = "error",
+    Focus = "focus",
+    FocusIn = "focusin",
+    FocusOut = "focusout",
+    Input = "input",
+    KeyDown = "keydown",
+    KeyPress = "keypress",
+    KeyUp = "keyup",
+    Load = "load",
+    MouseDown = "mousedown",
+    MouseEnter = "mouseenter",
+    MouseLeave = "mouseleave",
+    MouseMove = "mousemove",
+    MouseOut = "mouseout",
+    MouseOver = "mouseover",
+    MouseUp = "mouseup",
+    Resize = "resize",
+    Scroll = "scroll",
+    Select = "select",
+    Storage = "storage",
+    Unload = "unload",
+    Wheel = "wheel"
+
+  PerformanceMemory* {.importc.} = ref object
+    jsHeapSizeLimit*: float
+    totalJSHeapSize*: float
+    usedJSHeapSize*: float
+
+  PerformanceTiming* {.importc.} = ref object
+    connectStart*: float
+    domComplete*: float
+    domContentLoadedEventEnd*: float
+    domContentLoadedEventStart*: float
+    domInteractive*: float
+    domLoading*: float
+    domainLookupEnd*: float
+    domainLookupStart*: float
+    fetchStart*: float
+    loadEventEnd*: float
+    loadEventStart*: float
+    navigationStart*: float
+    redirectEnd*: float
+    redirectStart*: float
+    requestStart*: float
+    responseEnd*: float
+    responseStart*: float
+    secureConnectionStart*: float
+    unloadEventEnd*: float
+    unloadEventStart*: float
+
+  Performance* {.importc.} = ref object
+    memory*: PerformanceMemory
+    timing*: PerformanceTiming
+
+  Range* {.importc.} = ref object
+    ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Range>`_
+    collapsed*: bool
+    commonAncestorContainer*: Node
+    endContainer*: Node
+    endOffset*: int
+    startContainer*: Node
+    startOffset*: int
+
+  Selection* {.importc.} = ref object
+    ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Selection>`_
+    anchorNode*: Node
+    anchorOffset*: int
+    focusNode*: Node
+    focusOffset*: int
+    isCollapsed*: bool
+    rangeCount*: int
+    `type`*: cstring
+
+  Storage* {.importc.} = ref object
+
+  Window* {.importc.} = ref object of EventTarget
+    document*: Document
+    event*: Event
+    history*: History
+    location*: Location
+    closed*: bool
+    defaultStatus*: cstring
+    devicePixelRatio*: float
+    innerHeight*, innerWidth*: int
+    locationbar*: ref LocationBar
+    menubar*: ref MenuBar
+    name*: cstring
+    outerHeight*, outerWidth*: int
+    pageXOffset*, pageYOffset*: int
+    scrollX*: float
+    scrollY*: float
+    personalbar*: ref PersonalBar
+    scrollbars*: ref ScrollBars
+    statusbar*: ref StatusBar
+    status*: cstring
+    toolbar*: ref ToolBar
+    frames*: seq[Frame]
+    screen*: Screen
+    performance*: Performance
+    onpopstate*: proc (event: Event)
+    localStorage*: Storage
+    sessionStorage*: Storage
+    parent*: Window
+
+  Frame* {.importc.} = ref object of Window
+
+  ClassList* {.importc.} = ref object of RootObj
+
+  NodeType* = enum
+    ElementNode = 1,
+    AttributeNode,
+    TextNode,
+    CDATANode,
+    EntityRefNode,
+    EntityNode,
+    ProcessingInstructionNode,
+    CommentNode,
+    DocumentNode,
+    DocumentTypeNode,
+    DocumentFragmentNode,
+    NotationNode
+
+  Node* {.importc.} = ref object of EventTarget
+    attributes*: seq[Node]
+    childNodes*: seq[Node]
+    children*: seq[Node]
+    data*: cstring
+    firstChild*: Node
+    lastChild*: Node
+    nextSibling*: Node
+    nodeName*: cstring
+    nodeType*: NodeType
+    nodeValue*: cstring
+    parentNode*: Node
+    content*: Node
+    previousSibling*: Node
+    ownerDocument*: Document
+    innerHTML*: cstring
+    outerHTML*: cstring
+    innerText*: cstring
+    textContent*: cstring
+    style*: Style
+    baseURI*: cstring
+    parentElement*: Element
+    isConnected*: bool
+
+  Document* {.importc.} = ref object of Node
+    activeElement*: Element
+    documentElement*: Element
+    alinkColor*: cstring
+    bgColor*: cstring
+    body*: Element
+    charset*: cstring
+    cookie*: cstring
+    defaultCharset*: cstring
+    fgColor*: cstring
+    head*: Element
+    hidden*: bool
+    lastModified*: cstring
+    linkColor*: cstring
+    referrer*: cstring
+    title*: cstring
+    URL*: cstring
+    visibilityState*: cstring
+    vlinkColor*: cstring
+    anchors*: seq[AnchorElement]
+    forms*: seq[FormElement]
+    images*: seq[ImageElement]
+    applets*: seq[Element]
+    embeds*: seq[EmbedElement]
+    links*: seq[LinkElement]
+    fonts*: FontFaceSet
+
+  Element* {.importc.} = ref object of Node
+    className*: cstring
+    classList*: ClassList
+    checked*: bool
+    defaultChecked*: bool
+    defaultValue*: cstring
+    disabled*: bool
+    form*: FormElement
+    name*: cstring
+    readOnly*: bool
+    options*: seq[OptionElement]
+    selectedOptions*: seq[OptionElement]
+    clientWidth*, clientHeight*: int
+    contentEditable*: cstring
+    isContentEditable*: bool
+    dir*: cstring
+    offsetHeight*: int
+    offsetWidth*: int
+    offsetLeft*: int
+    offsetTop*: int
+
+  ValidityState* {.importc.} = ref object ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ValidityState>`_
+    badInput*: bool
+    customError*: bool
+    patternMismatch*: bool
+    rangeOverflow*: bool
+    rangeUnderflow*: bool
+    stepMismatch*: bool
+    tooLong*: bool
+    tooShort*: bool
+    typeMismatch*: bool
+    valid*: bool
+    valueMissing*: bool
+
+  Blob* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Blob>`_
+    size*: int
+    `type`*: cstring
+
+  File* {.importc.} = ref object of Blob ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/File>`_
+    lastModified*: int
+    name*: cstring
+
+  TextAreaElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement>`_
+    value*: cstring
+    selectionStart*, selectionEnd*: int
+    selectionDirection*: cstring
+    rows*, cols*: int
+
+  InputElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement>`_
+    # Properties related to the parent form
+    formAction*: cstring
+    formEncType*: cstring
+    formMethod*: cstring
+    formNoValidate*: bool
+    formTarget*: cstring
+
+    # Properties that apply to any type of input element that is not hidden
+    `type`*: cstring
+    autofocus*: bool
+    required*: bool
+    value*: cstring
+    validity*: ValidityState
+    validationMessage*: cstring
+    willValidate*: bool
+
+    # Properties that apply only to elements of type "checkbox" or "radio"
+    indeterminate*: bool
+
+    # Properties that apply only to elements of type "image"
+    alt*: cstring
+    height*: cstring
+    src*: cstring
+    width*: cstring
+
+    # Properties that apply only to elements of type "file"
+    accept*: cstring
+    files*: seq[Blob]
+
+    # Properties that apply only to text/number-containing or elements
+    autocomplete*: cstring
+    maxLength*: int
+    size*: int
+    pattern*: cstring
+    placeholder*: cstring
+    min*: cstring
+    max*: cstring
+    selectionStart*: int
+    selectionEnd*: int
+    selectionDirection*: cstring
+
+    # Properties not yet categorized
+    dirName*: cstring
+    accessKey*: cstring
+    list*: Element
+    multiple*: bool
+    labels*: seq[Element]
+    step*: cstring
+    valueAsDate*: cstring
+    valueAsNumber*: float
+
+  LinkElement* {.importc.} = ref object of Element
+    target*: cstring
+    text*: cstring
+    x*: int
+    y*: int
+
+  EmbedElement* {.importc.} = ref object of Element
+    height*: int
+    hspace*: int
+    src*: cstring
+    width*: int
+    `type`*: cstring
+    vspace*: int
+
+  AnchorElement* {.importc.} = ref object of Element
+    text*: cstring
+    x*, y*: int
+
+  OptionElement* {.importc.} = ref object of Element
+    defaultSelected*: bool
+    selected*: bool
+    selectedIndex*: int
+    text*: cstring
+    value*: cstring
+
+  FormElement* {.importc.} = ref object of Element ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement>`_
+    acceptCharset*: cstring
+    action*: cstring
+    autocomplete*: cstring
+    elements*: seq[Element]
+    encoding*: cstring
+    enctype*: cstring
+    length*: int
+    `method`*: cstring
+    noValidate*: bool
+    target*: cstring
+
+  ImageElement* {.importc.} = ref object of Element
+    border*: int
+    complete*: bool
+    height*: int
+    hspace*: int
+    lowsrc*: cstring
+    src*: cstring
+    vspace*: int
+    width*: int
+
+  Style* {.importc.} = ref object of RootObj
+    alignContent*: cstring
+    alignItems*: cstring
+    alignSelf*: cstring
+    all*: cstring
+    animation*: cstring
+    animationDelay*: cstring
+    animationDirection*: cstring
+    animationDuration*: cstring
+    animationFillMode*: cstring
+    animationIterationCount*: cstring
+    animationName*: cstring
+    animationPlayState*: cstring
+    animationTimingFunction*: cstring
+    backdropFilter*: cstring
+    backfaceVisibility*: cstring
+    background*: cstring
+    backgroundAttachment*: cstring
+    backgroundBlendMode*: cstring
+    backgroundClip*: cstring
+    backgroundColor*: cstring
+    backgroundImage*: cstring
+    backgroundOrigin*: cstring
+    backgroundPosition*: cstring
+    backgroundRepeat*: cstring
+    backgroundSize*: cstring
+    blockSize*: cstring
+    border*: cstring
+    borderBlock*: cstring
+    borderBlockColor*: cstring
+    borderBlockEnd*: cstring
+    borderBlockEndColor*: cstring
+    borderBlockEndStyle*: cstring
+    borderBlockEndWidth*: cstring
+    borderBlockStart*: cstring
+    borderBlockStartColor*: cstring
+    borderBlockStartStyle*: cstring
+    borderBlockStartWidth*: cstring
+    borderBlockStyle*: cstring
+    borderBlockWidth*: cstring
+    borderBottom*: cstring
+    borderBottomColor*: cstring
+    borderBottomLeftRadius*: cstring
+    borderBottomRightRadius*: cstring
+    borderBottomStyle*: cstring
+    borderBottomWidth*: cstring
+    borderCollapse*: cstring
+    borderColor*: cstring
+    borderEndEndRadius*: cstring
+    borderEndStartRadius*: cstring
+    borderImage*: cstring
+    borderImageOutset*: cstring
+    borderImageRepeat*: cstring
+    borderImageSlice*: cstring
+    borderImageSource*: cstring
+    borderImageWidth*: cstring
+    borderInline*: cstring
+    borderInlineColor*: cstring
+    borderInlineEnd*: cstring
+    borderInlineEndColor*: cstring
+    borderInlineEndStyle*: cstring
+    borderInlineEndWidth*: cstring
+    borderInlineStart*: cstring
+    borderInlineStartColor*: cstring
+    borderInlineStartStyle*: cstring
+    borderInlineStartWidth*: cstring
+    borderInlineStyle*: cstring
+    borderInlineWidth*: cstring
+    borderLeft*: cstring
+    borderLeftColor*: cstring
+    borderLeftStyle*: cstring
+    borderLeftWidth*: cstring
+    borderRadius*: cstring
+    borderRight*: cstring
+    borderRightColor*: cstring
+    borderRightStyle*: cstring
+    borderRightWidth*: cstring
+    borderSpacing*: cstring
+    borderStartEndRadius*: cstring
+    borderStartStartRadius*: cstring
+    borderStyle*: cstring
+    borderTop*: cstring
+    borderTopColor*: cstring
+    borderTopLeftRadius*: cstring
+    borderTopRightRadius*: cstring
+    borderTopStyle*: cstring
+    borderTopWidth*: cstring
+    borderWidth*: cstring
+    bottom*: cstring
+    boxDecorationBreak*: cstring
+    boxShadow*: cstring
+    boxSizing*: cstring
+    breakAfter*: cstring
+    breakBefore*: cstring
+    breakInside*: cstring
+    captionSide*: cstring
+    caretColor*: cstring
+    clear*: cstring
+    clip*: cstring
+    clipPath*: cstring
+    color*: cstring
+    colorAdjust*: cstring
+    columnCount*: cstring
+    columnFill*: cstring
+    columnGap*: cstring
+    columnRule*: cstring
+    columnRuleColor*: cstring
+    columnRuleStyle*: cstring
+    columnRuleWidth*: cstring
+    columnSpan*: cstring
+    columnWidth*: cstring
+    columns*: cstring
+    contain*: cstring
+    content*: cstring
+    counterIncrement*: cstring
+    counterReset*: cstring
+    counterSet*: cstring
+    cursor*: cstring
+    direction*: cstring
+    display*: cstring
+    emptyCells*: cstring
+    filter*: cstring
+    flex*: cstring
+    flexBasis*: cstring
+    flexDirection*: cstring
+    flexFlow*: cstring
+    flexGrow*: cstring
+    flexShrink*: cstring
+    flexWrap*: cstring
+    cssFloat*: cstring
+    font*: cstring
+    fontFamily*: cstring
+    fontFeatureSettings*: cstring
+    fontKerning*: cstring
+    fontLanguageOverride*: cstring
+    fontOpticalSizing*: cstring
+    fontSize*: cstring
+    fontSizeAdjust*: cstring
+    fontStretch*: cstring
+    fontStyle*: cstring
+    fontSynthesis*: cstring
+    fontVariant*: cstring
+    fontVariantAlternates*: cstring
+    fontVariantCaps*: cstring
+    fontVariantEastAsian*: cstring
+    fontVariantLigatures*: cstring
+    fontVariantNumeric*: cstring
+    fontVariantPosition*: cstring
+    fontVariationSettings*: cstring
+    fontWeight*: cstring
+    gap*: cstring
+    grid*: cstring
+    gridArea*: cstring
+    gridAutoColumns*: cstring
+    gridAutoFlow*: cstring
+    gridAutoRows*: cstring
+    gridColumn*: cstring
+    gridColumnEnd*: cstring
+    gridColumnStart*: cstring
+    gridRow*: cstring
+    gridRowEnd*: cstring
+    gridRowStart*: cstring
+    gridTemplate*: cstring
+    gridTemplateAreas*: cstring
+    gridTemplateColumns*: cstring
+    gridTemplateRows*: cstring
+    hangingPunctuation*: cstring
+    height*: cstring
+    hyphens*: cstring
+    imageOrientation*: cstring
+    imageRendering*: cstring
+    inlineSize*: cstring
+    inset*: cstring
+    insetBlock*: cstring
+    insetBlockEnd*: cstring
+    insetBlockStart*: cstring
+    insetInline*: cstring
+    insetInlineEnd*: cstring
+    insetInlineStart*: cstring
+    isolation*: cstring
+    justifyContent*: cstring
+    justifyItems*: cstring
+    justifySelf*: cstring
+    left*: cstring
+    letterSpacing*: cstring
+    lineBreak*: cstring
+    lineHeight*: cstring
+    listStyle*: cstring
+    listStyleImage*: cstring
+    listStylePosition*: cstring
+    listStyleType*: cstring
+    margin*: cstring
+    marginBlock*: cstring
+    marginBlockEnd*: cstring
+    marginBlockStart*: cstring
+    marginBottom*: cstring
+    marginInline*: cstring
+    marginInlineEnd*: cstring
+    marginInlineStart*: cstring
+    marginLeft*: cstring
+    marginRight*: cstring
+    marginTop*: cstring
+    mask*: cstring
+    maskBorder*: cstring
+    maskBorderMode*: cstring
+    maskBorderOutset*: cstring
+    maskBorderRepeat*: cstring
+    maskBorderSlice*: cstring
+    maskBorderSource*: cstring
+    maskBorderWidth*: cstring
+    maskClip*: cstring
+    maskComposite*: cstring
+    maskImage*: cstring
+    maskMode*: cstring
+    maskOrigin*: cstring
+    maskPosition*: cstring
+    maskRepeat*: cstring
+    maskSize*: cstring
+    maskType*: cstring
+    maxBlockSize*: cstring
+    maxHeight*: cstring
+    maxInlineSize*: cstring
+    maxWidth*: cstring
+    minBlockSize*: cstring
+    minHeight*: cstring
+    minInlineSize*: cstring
+    minWidth*: cstring
+    mixBlendMode*: cstring
+    objectFit*: cstring
+    objectPosition*: cstring
+    offset*: cstring
+    offsetAnchor*: cstring
+    offsetDistance*: cstring
+    offsetPath*: cstring
+    offsetRotate*: cstring
+    opacity*: cstring
+    order*: cstring
+    orphans*: cstring
+    outline*: cstring
+    outlineColor*: cstring
+    outlineOffset*: cstring
+    outlineStyle*: cstring
+    outlineWidth*: cstring
+    overflow*: cstring
+    overflowAnchor*: cstring
+    overflowBlock*: cstring
+    overflowInline*: cstring
+    overflowWrap*: cstring
+    overflowX*: cstring
+    overflowY*: cstring
+    overscrollBehavior*: cstring
+    overscrollBehaviorBlock*: cstring
+    overscrollBehaviorInline*: cstring
+    overscrollBehaviorX*: cstring
+    overscrollBehaviorY*: cstring
+    padding*: cstring
+    paddingBlock*: cstring
+    paddingBlockEnd*: cstring
+    paddingBlockStart*: cstring
+    paddingBottom*: cstring
+    paddingInline*: cstring
+    paddingInlineEnd*: cstring
+    paddingInlineStart*: cstring
+    paddingLeft*: cstring
+    paddingRight*: cstring
+    paddingTop*: cstring
+    pageBreakAfter*: cstring
+    pageBreakBefore*: cstring
+    pageBreakInside*: cstring
+    paintOrder*: cstring
+    perspective*: cstring
+    perspectiveOrigin*: cstring
+    placeContent*: cstring
+    placeItems*: cstring
+    placeSelf*: cstring
+    pointerEvents*: cstring
+    position*: cstring
+    quotes*: cstring
+    resize*: cstring
+    right*: cstring
+    rotate*: cstring
+    rowGap*: cstring
+    scale*: cstring
+    scrollBehavior*: cstring
+    scrollMargin*: cstring
+    scrollMarginBlock*: cstring
+    scrollMarginBlockEnd*: cstring
+    scrollMarginBlockStart*: cstring
+    scrollMarginBottom*: cstring
+    scrollMarginInline*: cstring
+    scrollMarginInlineEnd*: cstring
+    scrollMarginInlineStart*: cstring
+    scrollMarginLeft*: cstring
+    scrollMarginRight*: cstring
+    scrollMarginTop*: cstring
+    scrollPadding*: cstring
+    scrollPaddingBlock*: cstring
+    scrollPaddingBlockEnd*: cstring
+    scrollPaddingBlockStart*: cstring
+    scrollPaddingBottom*: cstring
+    scrollPaddingInline*: cstring
+    scrollPaddingInlineEnd*: cstring
+    scrollPaddingInlineStart*: cstring
+    scrollPaddingLeft*: cstring
+    scrollPaddingRight*: cstring
+    scrollPaddingTop*: cstring
+    scrollSnapAlign*: cstring
+    scrollSnapStop*: cstring
+    scrollSnapType*: cstring
+    scrollbar3dLightColor*: cstring
+    scrollbarArrowColor*: cstring
+    scrollbarBaseColor*: cstring
+    scrollbarColor*: cstring
+    scrollbarDarkshadowColor*: cstring
+    scrollbarFaceColor*: cstring
+    scrollbarHighlightColor*: cstring
+    scrollbarShadowColor*: cstring
+    scrollbarTrackColor*: cstring
+    scrollbarWidth*: cstring
+    shapeImageThreshold*: cstring
+    shapeMargin*: cstring
+    shapeOutside*: cstring
+    tabSize*: cstring
+    tableLayout*: cstring
+    textAlign*: cstring
+    textAlignLast*: cstring
+    textCombineUpright*: cstring
+    textDecoration*: cstring
+    textDecorationColor*: cstring
+    textDecorationLine*: cstring
+    textDecorationSkipInk*: cstring
+    textDecorationStyle*: cstring
+    textDecorationThickness*: cstring
+    textEmphasis*: cstring
+    textEmphasisColor*: cstring
+    textEmphasisPosition*: cstring
+    textEmphasisStyle*: cstring
+    textIndent*: cstring
+    textJustify*: cstring
+    textOrientation*: cstring
+    textOverflow*: cstring
+    textRendering*: cstring
+    textShadow*: cstring
+    textTransform*: cstring
+    textUnderlineOffset*: cstring
+    textUnderlinePosition*: cstring
+    top*: cstring
+    touchAction*: cstring
+    transform*: cstring
+    transformBox*: cstring
+    transformOrigin*: cstring
+    transformStyle*: cstring
+    transition*: cstring
+    transitionDelay*: cstring
+    transitionDuration*: cstring
+    transitionProperty*: cstring
+    transitionTimingFunction*: cstring
+    translate*: cstring
+    unicodeBidi*: cstring
+    verticalAlign*: cstring
+    visibility*: cstring
+    whiteSpace*: cstring
+    widows*: cstring
+    width*: cstring
+    willChange*: cstring
+    wordBreak*: cstring
+    wordSpacing*: cstring
+    writingMode*: cstring
+    zIndex*: cstring
+
+  EventPhase* = enum
+    None = 0,
+    CapturingPhase,
+    AtTarget,
+    BubblingPhase
+
+  Event* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Event>`_
+    bubbles*: bool
+    cancelBubble*: bool
+    cancelable*: bool
+    composed*: bool
+    currentTarget*: Node
+    defaultPrevented*: bool
+    eventPhase*: int
+    target*: Node
+    `type`*: cstring
+    isTrusted*: bool
+
+  UIEvent* {.importc.} = ref object of Event ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/UIEvent>`_
+    detail*: int64
+    view*: Window
+
+  KeyboardEvent* {.importc.} = ref object of UIEvent ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent>`_
+    altKey*, ctrlKey*, metaKey*, shiftKey*: bool
+    code*: cstring
+    isComposing*: bool
+    key*: cstring
+    keyCode*: int
+    location*: int
+
+  KeyboardEventKey* {.pure.} = enum ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>`_
+    # Modifier keys
+    Alt,
+    AltGraph,
+    CapsLock,
+    Control,
+    Fn,
+    FnLock,
+    Hyper,
+    Meta,
+    NumLock,
+    ScrollLock,
+    Shift,
+    Super,
+    Symbol,
+    SymbolLock,
+
+    # Whitespace keys
+    ArrowDown,
+    ArrowLeft,
+    ArrowRight,
+    ArrowUp,
+    End,
+    Home,
+    PageDown,
+    PageUp,
+
+    # Editing keys
+    Backspace,
+    Clear,
+    Copy,
+    CrSel,
+    Cut,
+    Delete,
+    EraseEof,
+    ExSel,
+    Insert,
+    Paste,
+    Redo,
+    Undo,
+
+    # UI keys
+    Accept,
+    Again,
+    Attn,
+    Cancel,
+    ContextMenu,
+    Escape,
+    Execute,
+    Find,
+    Finish,
+    Help,
+    Pause,
+    Play,
+    Props,
+    Select,
+    ZoomIn,
+    ZoomOut,
+
+    # Device keys
+    BrigtnessDown,
+    BrigtnessUp,
+    Eject,
+    LogOff,
+    Power,
+    PowerOff,
+    PrintScreen,
+    Hibernate,
+    Standby,
+    WakeUp,
+
+    # Common IME keys
+    AllCandidates,
+    Alphanumeric,
+    CodeInput,
+    Compose,
+    Convert,
+    Dead,
+    FinalMode,
+    GroupFirst,
+    GroupLast,
+    GroupNext,
+    GroupPrevious,
+    ModeChange,
+    NextCandidate,
+    NonConvert,
+    PreviousCandidate,
+    Process,
+    SingleCandidate,
+
+    # Korean keyboards only
+    HangulMode,
+    HanjaMode,
+    JunjaMode,
+
+    # Japanese keyboards only
+    Eisu,
+    Hankaku,
+    Hiragana,
+    HiraganaKatakana,
+    KanaMode,
+    KanjiMode,
+    Katakana,
+    Romaji,
+    Zenkaku,
+    ZenkakuHanaku,
+
+    # Function keys
+    F1,
+    F2,
+    F3,
+    F4,
+    F5,
+    F6,
+    F7,
+    F8,
+    F9,
+    F10,
+    F11,
+    F12,
+    F13,
+    F14,
+    F15,
+    F16,
+    F17,
+    F18,
+    F19,
+    F20,
+    Soft1,
+    Soft2,
+    Soft3,
+    Soft4,
+
+    # Phone keys
+    AppSwitch,
+    Call,
+    Camera,
+    CameraFocus,
+    EndCall,
+    GoBack,
+    GoHome,
+    HeadsetHook,
+    LastNumberRedial,
+    Notification,
+    MannerMode,
+    VoiceDial,
+
+    # Multimedia keys
+    ChannelDown,
+    ChannelUp,
+    MediaFastForward,
+    MediaPause,
+    MediaPlay,
+    MediaPlayPause,
+    MediaRecord,
+    MediaRewind,
+    MediaStop,
+    MediaTrackNext,
+    MediaTrackPrevious,
+
+    # Audio control keys
+    AudioBalanceLeft,
+    AudioBalanceRight,
+    AudioBassDown,
+    AudioBassBoostDown,
+    AudioBassBoostToggle,
+    AudioBassBoostUp,
+    AudioBassUp,
+    AudioFaderFront,
+    AudioFaderRear,
+    AudioSurroundModeNext,
+    AudioTrebleDown,
+    AudioTrebleUp,
+    AudioVolumeDown,
+    AUdioVolumeMute,
+    AudioVolumeUp,
+    MicrophoneToggle,
+    MicrophoneVolumeDown,
+    MicrophoneVolumeMute,
+    MicrophoneVolumeUp,
+
+    # TV control keys
+    TV,
+    TV3DMode,
+    TVAntennaCable,
+    TVAudioDescription,
+    TVAudioDescriptionMixDown,
+    TVAudioDescriptionMixUp,
+    TVContentsMenu,
+    TVDataService,
+    TVInput,
+    TVInputComponent1,
+    TVInputComponent2,
+    TVInputComposite1,
+    TVInputComposite2,
+    TVInputHDMI1,
+    TVInputHDMI2,
+    TVInputHDMI3,
+    TVInputHDMI4,
+    TVInputVGA1,
+    TVMediaContext,
+    TVNetwork,
+    TVNumberEntry,
+    TVPower,
+    TVRadioService,
+    TVSatellite,
+    TVSatelliteBS,
+    TVSatelliteCS,
+    TVSatelliteToggle,
+    TVTerrestrialAnalog,
+    TVTerrestrialDigital,
+    TVTimer,
+
+    # Media controller keys
+    AVRInput,
+    AVRPower,
+    ColorF0Red,
+    ColorF1Green,
+    ColorF2Yellow,
+    ColorF3Blue,
+    ColorF4Grey,
+    ColorF5Brown,
+    ClosedCaptionToggle,
+    Dimmer,
+    DisplaySwap,
+    DVR,
+    Exit,
+    FavoriteClear0,
+    FavoriteClear1,
+    FavoriteClear2,
+    FavoriteClear3,
+    FavoriteRecall0,
+    FavoriteRecall1,
+    FavoriteRecall2,
+    FavoriteRecall3,
+    FavoriteStore0,
+    FavoriteStore1,
+    FavoriteStore2,
+    FavoriteStore3,
+    Guide,
+    GuideNextDay,
+    GuidePreviousDay,
+    Info,
+    InstantReplay,
+    Link,
+    ListProgram,
+    LiveContent,
+    Lock,
+    MediaApps,
+    MediaAudioTrack,
+    MediaLast,
+    MediaSkipBackward,
+    MediaSkipForward,
+    MediaStepBackward,
+    MediaStepForward,
+    MediaTopMenu,
+    NavigateIn,
+    NavigateNext,
+    NavigateOut,
+    NavigatePrevious,
+    NextFavoriteChannel,
+    NextUserProfile,
+    OnDemand,
+    Pairing,
+    PinPDown,
+    PinPMove,
+    PinPUp,
+    PlaySpeedDown,
+    PlaySpeedReset,
+    PlaySpeedUp,
+    RandomToggle,
+    RcLowBattery,
+    RecordSpeedNext,
+    RfBypass,
+    ScanChannelsToggle,
+    ScreenModeNext,
+    Settings,
+    SplitScreenToggle,
+    STBInput,
+    STBPower,
+    Subtitle,
+    Teletext,
+    VideoModeNext,
+    Wink,
+    ZoomToggle,
+
+    # Speech recognition keys
+    SpeechCorrectionList,
+    SpeechInputToggle,
+
+    # Document keys
+    Close,
+    New,
+    Open,
+    Print,
+    Save,
+    SpellCheck,
+    MailForward,
+    MailReply,
+    MailSend,
+
+    # Application selector keys
+    LaunchCalculator,
+    LaunchCalendar,
+    LaunchContacts,
+    LaunchMail,
+    LaunchMediaPlayer,
+    LaunchMusicPlayer,
+    LaunchMyComputer,
+    LaunchPhone,
+    LaunchScreenSaver,
+    LaunchSpreadsheet,
+    LaunchWebBrowser,
+    LaunchWebCam,
+    LaunchWordProcessor,
+    LaunchApplication1,
+    LaunchApplication2,
+    LaunchApplication3,
+    LaunchApplication4,
+    LaunchApplication5,
+    LaunchApplication6,
+    LaunchApplication7,
+    LaunchApplication8,
+    LaunchApplication9,
+    LaunchApplication10,
+    LaunchApplication11,
+    LaunchApplication12,
+    LaunchApplication13,
+    LaunchApplication14,
+    LaunchApplication15,
+    LaunchApplication16,
+
+    # Browser control keys
+    BrowserBack,
+    BrowserFavorites,
+    BrowserForward,
+    BrowserHome,
+    BrowserRefresh,
+    BrowserSearch,
+    BrowserStop,
+
+    # Numeric keypad keys
+    Key11,
+    Key12,
+    Separator
+
+  MouseButtons* = enum
+    NoButton = 0,
+    PrimaryButton = 1,
+    SecondaryButton = 2,
+    AuxilaryButton = 4,
+    FourthButton = 8,
+    FifthButton = 16
+
+  MouseEvent* {.importc.} = ref object of UIEvent ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent>`_
+    altKey*, ctrlKey*, metaKey*, shiftKey*: bool
+    button*: int
+    buttons*: int
+    clientX*, clientY*: int
+    movementX*, movementY*: int
+    offsetX*, offsetY*: int
+    pageX*, pageY*: int
+    relatedTarget*: EventTarget
+    #region*: cstring
+    screenX*, screenY*: int
+    x*, y*: int
+
+  DataTransferItemKind* {.pure.} = enum
+    File = "file",
+    String = "string"
+
+  DataTransferItem* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem>`_
+    kind*: cstring
+    `type`*: cstring
+
+  DataTransfer* {.importc.} = ref object of RootObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer>`_
+    dropEffect*: cstring
+    effectAllowed*: cstring
+    files*: seq[Element]
+    items*: seq[DataTransferItem]
+    types*: seq[cstring]
+
+  DataTransferDropEffect* {.pure.} = enum
+    None = "none",
+    Copy = "copy",
+    Link = "link",
+    Move = "move"
+
+  DataTransferEffectAllowed* {.pure.} = enum
+    None = "none",
+    Copy = "copy",
+    CopyLink = "copyLink",
+    CopyMove = "copyMove",
+    Link = "link",
+    LinkMove = "linkMove",
+    Move = "move",
+    All = "all",
+    Uninitialized = "uninitialized"
+
+  DragEventTypes* = enum
+    Drag = "drag",
+    DragEnd = "dragend",
+    DragEnter = "dragenter",
+    DragExit = "dragexit",
+    DragLeave = "dragleave",
+    DragOver = "dragover",
+    DragStart = "dragstart",
+    Drop = "drop"
+
+  DragEvent* {.importc.} = object of MouseEvent
+    ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DragEvent>`_
+    dataTransfer*: DataTransfer
+
+  ClipboardEvent* {.importc.} = object of Event
+    ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_
+    clipboardData*: DataTransfer
+
+  StorageEvent* {.importc.} = ref object of Event ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent>`_
+    key*: cstring
+    newValue*, oldValue*: cstring
+    storageArea*: Storage
+    url*: cstring
+
+  TouchList* {.importc.} = ref object of RootObj
+    length*: int
+
+  Touch* {.importc.} = ref object of RootObj
+    identifier*: int
+    screenX*, screenY*, clientX*, clientY*, pageX*, pageY*: int
+    target*: Element
+    radiusX*, radiusY*: int
+    rotationAngle*: int
+    force*: float
+
+  TouchEvent* {.importc.} = ref object of UIEvent
+    changedTouches*, targetTouches*, touches*: seq[Touch]
+
+  Location* {.importc.} = ref object of RootObj
+    hash*: cstring
+    host*: cstring
+    hostname*: cstring
+    href*: cstring
+    pathname*: cstring
+    port*: cstring
+    protocol*: cstring
+    search*: cstring
+    origin*: cstring
+
+  History* {.importc.} = ref object of RootObj
+    length*: int
+
+  Navigator* {.importc.} = ref object of RootObj
+    appCodeName*: cstring
+    appName*: cstring
+    appVersion*: cstring
+    buildID*: cstring        ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/buildID
+    cookieEnabled*: bool
+    deviceMemory*: float     ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory
+    doNotTrack*: cstring     ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack
+    language*: cstring
+    languages*: seq[cstring] ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages
+    maxTouchPoints*: cint    ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/maxTouchPoints
+    onLine*: bool            ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
+    oscpu*: cstring          ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/oscpu
+    platform*: cstring
+    userAgent*: cstring
+    vendor*: cstring         ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vendor
+    webdriver*: bool         ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver
+    mimeTypes*: seq[ref MimeType]
+
+  Plugin* {.importc.} = object of RootObj
+    description*: cstring
+    filename*: cstring
+    name*: cstring
+
+  MimeType* {.importc.} = object of RootObj
+    description*: cstring
+    enabledPlugin*: ref Plugin
+    suffixes*: seq[cstring]
+    `type`*: cstring
+
+  LocationBar* {.importc.} = object of RootObj
+    visible*: bool
+  MenuBar* = LocationBar
+  PersonalBar* = LocationBar
+  ScrollBars* = LocationBar
+  ToolBar* = LocationBar
+  StatusBar* = LocationBar
+
+  Screen* {.importc.} = ref object of RootObj
+    availHeight*: int
+    availWidth*: int
+    colorDepth*: int
+    height*: int
+    pixelDepth*: int
+    width*: int
+
+  TimeOut* {.importc.} = ref object of RootObj
+  Interval* {.importc.} = ref object of RootObj
+
+  AddEventListenerOptions* = object
+    capture*: bool
+    once*: bool
+    passive*: bool
+
+  FontFaceSetReady* {.importc.} = ref object
+    ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready>`_
+    then*: proc(cb: proc())
+
+  FontFaceSet* {.importc.} = ref object
+    ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet>`_
+    ready*: FontFaceSetReady
+    onloadingdone*: proc(event: Event)
+
+  ScrollIntoViewOptions* = object
+    behavior*: cstring
+    `block`*: cstring
+    inline*: cstring
+
+  MediaQueryList* {.importc.} = ref object of EventTarget
+    matches*: bool
+    media*: cstring
+
+since (1, 3):
+  type
+    DomParser* = ref object
+      ## DOM Parser object (defined on browser only, may not be on NodeJS).
+      ## * https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
+      ##
+      ##   ```nim
+      ##   let prsr = newDomParser()
+      ##   discard prsr.parseFromString("<html><marquee>Hello World</marquee></html>".cstring, "text/html".cstring)
+      ##   ```
+
+    DomException* {.importc.} = ref object
+      ## The DOMException interface represents an abnormal event (called an exception)
+      ## which occurs as a result of calling a method or accessing a property of a web API.
+      ## Each exception has a name, which is a short "CamelCase" style string identifying
+      ## the error or abnormal condition.
+      ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException
+
+    FileReader* {.importc.} = ref object of EventTarget
+      ## The FileReader object lets web applications asynchronously read the contents of files
+      ## (or raw data buffers) stored on the user's computer, using File or Blob objects to specify
+      ## the file or data to read.
+      ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader
+
+    FileReaderState* = distinct range[0'u16..2'u16]
+    RootNodeOptions* = object of RootObj
+      composed*: bool
+    DocumentOrShadowRoot* {.importc.} = object of RootObj
+      activeElement*: Element
+      # styleSheets*: StyleSheetList
+    ShadowRoot* {.importc.} = ref object of DocumentOrShadowRoot
+      delegatesFocus*: bool
+      host*: Element
+      innerHTML*: cstring
+      mode*: cstring # "open" or "closed"
+    ShadowRootInit* = object of RootObj
+      mode*: cstring
+      delegatesFocus*: bool
+
+    HTMLSlotElement* {.importc.} = ref object of RootObj
+      name*: cstring
+    SlotOptions* = object of RootObj
+      flatten*: bool
+
+  const
+    fileReaderEmpty* = 0.FileReaderState
+    fileReaderLoading* = 1.FileReaderState
+    fileReaderDone* = 2.FileReaderState
+
+proc id*(n: Node): cstring {.importcpp: "#.id", nodecl.}
+proc `id=`*(n: Node; x: cstring) {.importcpp: "#.id = #", nodecl.}
+proc class*(n: Node): cstring {.importcpp: "#.className", nodecl.}
+proc `class=`*(n: Node; v: cstring) {.importcpp: "#.className = #", nodecl.}
+
+proc value*(n: Node): cstring {.importcpp: "#.value", nodecl.}
+proc `value=`*(n: Node; v: cstring) {.importcpp: "#.value = #", nodecl.}
+
+proc checked*(n: Node): bool {.importcpp: "#.checked", nodecl.}
+proc `checked=`*(n: Node; v: bool) {.importcpp: "#.checked = #", nodecl.}
+
+proc `disabled=`*(n: Node; v: bool) {.importcpp: "#.disabled = #", nodecl.}
+
+when defined(nodejs):
+  # we provide a dummy DOM for nodejs for testing purposes
+  proc len*(x: Node): int = x.childNodes.len
+  proc `[]`*(x: Node; idx: int): Element =
+    assert idx >= 0 and idx < x.childNodes.len
+    result = cast[Element](x.childNodes[idx])
+
+  var document* = Document(nodeType: DocumentNode)
+  document.ownerDocument = document
+
+  proc getElem(x: Element; id: cstring): Element =
+    if x.id == id: return x
+    for i in 0..<x.len:
+      result = getElem(x[i], id)
+      if result != nil: return result
+
+  proc getElementById*(doc: Document; id: cstring): Element =
+    getElem(doc.body, id)
+  proc getElementById*(id: cstring): Element = document.getElementById(id)
+
+  proc appendChild*(parent, n: Node) =
+    n.parentNode = parent
+    n.ownerDocument = parent.ownerDocument
+    parent.childNodes.add n
+
+  proc replaceChild*(parent, newNode, oldNode: Node) =
+    newNode.parentNode = parent
+    oldNode.parentNode = nil
+    var i = 0
+    while i < parent.len:
+      if Node(parent[i]) == oldNode:
+        parent.childNodes[i] = newNode
+        return
+      inc i
+    raiseAssert "old node not in node list"
+
+  proc removeChild*(parent, child: Node) =
+    child.parentNode = nil
+    var i = 0
+    while i < parent.len:
+      if Node(parent[i]) == child:
+        parent.childNodes.delete(i)
+        return
+      inc i
+    raiseAssert "old node not in node list"
+
+  proc insertBefore*(parent, newNode, before: Node) =
+    appendChild(parent, newNode)
+    var i = 0
+    while i < parent.len-1:
+      if Node(parent[i]) == before:
+        for j in countdown(parent.len-1, i-1):
+          parent.childNodes[j] = parent.childNodes[j-1]
+        parent.childNodes[i-1] = newNode
+        return
+      inc i
+    #raiseAssert "before not in node list"
+
+  proc createElement*(d: Document, identifier: cstring): Element =
+    new(result)
+    result.nodeName = identifier
+    result.nodeType = NodeType.ElementNode
+
+  proc createTextNode*(d: Document, identifier: cstring): Node =
+    new(result)
+    result.nodeName = "#text"
+    result.nodeValue = identifier
+    result.nodeType = NodeType.TextNode
+
+  proc createComment*(d: Document, data: cstring): Node =
+    new(result)
+    result.nodeName = "#comment"
+    result.nodeValue = data
+    result.nodeType = NodeType.CommentNode
+
+else:
+  proc len*(x: Node): int {.importcpp: "#.childNodes.length".}
+  proc `[]`*(x: Node; idx: int): Element {.importcpp: "#.childNodes[#]".}
+  proc getElementById*(id: cstring): Element {.importc: "document.getElementById", nodecl.}
+  proc appendChild*(n, child: Node) {.importcpp.}
+  proc removeChild*(n, child: Node) {.importcpp.}
+  proc remove*(child: Node) {.importcpp.}
+  proc replaceChild*(n, newNode, oldNode: Node) {.importcpp.}
+  proc insertBefore*(n, newNode, before: Node) {.importcpp.}
+  proc getElementById*(d: Document, id: cstring): Element {.importcpp.}
+  proc createElement*(d: Document, identifier: cstring): Element {.importcpp.}
+  proc createElementNS*(d: Document, namespaceURI, qualifiedIdentifier: cstring): Element {.importcpp.}
+  proc createTextNode*(d: Document, identifier: cstring): Node {.importcpp.}
+  proc createComment*(d: Document, data: cstring): Node {.importcpp.}
+
+proc setTimeout*(action: proc(); ms: int): TimeOut {.importc, nodecl.}
+proc clearTimeout*(t: TimeOut) {.importc, nodecl.}
+proc setInterval*(action: proc(); ms: int): Interval {.importc, nodecl.}
+proc clearInterval*(i: Interval) {.importc, nodecl.}
+
+{.push importcpp.}
+
+# EventTarget "methods"
+proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false)
+proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), options: AddEventListenerOptions)
+proc dispatchEvent*(et: EventTarget, ev: Event)
+proc removeEventListener*(et: EventTarget; ev: cstring; cb: proc(ev: Event))
+
+# Window "methods"
+proc alert*(w: Window, msg: cstring)
+proc back*(w: Window)
+proc blur*(w: Window)
+proc clearInterval*(w: Window, interval: Interval)
+proc clearTimeout*(w: Window, timeout: TimeOut)
+proc close*(w: Window)
+proc confirm*(w: Window, msg: cstring): bool
+proc disableExternalCapture*(w: Window)
+proc enableExternalCapture*(w: Window)
+proc find*(w: Window, text: cstring, caseSensitive = false,
+           backwards = false): bool
+proc focus*(w: Window)
+proc forward*(w: Window)
+proc getComputedStyle*(w: Window, e: Node, pe: Node = nil): Style
+  ## .. warning:: The returned Style may or may not be read-only at run-time in the browser. getComputedStyle is performance costly.
+
+proc handleEvent*(w: Window, e: Event)
+proc home*(w: Window)
+proc moveBy*(w: Window, x, y: int)
+proc moveTo*(w: Window, x, y: int)
+proc open*(w: Window, uri, windowname: cstring,
+           properties: cstring = nil): Window
+proc print*(w: Window)
+proc prompt*(w: Window, text, default: cstring): cstring
+proc resizeBy*(w: Window, x, y: int)
+proc resizeTo*(w: Window, x, y: int)
+proc routeEvent*(w: Window, event: Event)
+proc scrollBy*(w: Window, x, y: int)
+proc scrollTo*(w: Window, x, y: int)
+proc setInterval*(w: Window, code: cstring, pause: int): Interval
+proc setInterval*(w: Window, function: proc (), pause: int): Interval
+proc setTimeout*(w: Window, code: cstring, pause: int): TimeOut
+proc setTimeout*(w: Window, function: proc (), pause: int): Interval
+proc stop*(w: Window)
+proc requestAnimationFrame*(w: Window, function: proc (time: float)): int
+proc cancelAnimationFrame*(w: Window, id: int)
+proc matchMedia*(w: Window, mediaQueryString: cstring): MediaQueryList
+
+# Node "methods"
+proc appendData*(n: Node, data: cstring)
+proc cloneNode*(n: Node, copyContent: bool): Node
+proc deleteData*(n: Node, start, len: int)
+proc focus*(e: Node)
+proc getAttribute*(n: Node, attr: cstring): cstring
+proc getAttributeNode*(n: Node, attr: cstring): Node
+proc hasAttribute*(n: Node, attr: cstring): bool
+proc hasChildNodes*(n: Node): bool
+proc normalize*(n: Node)
+proc insertData*(n: Node, position: int, data: cstring)
+proc removeAttribute*(n: Node, attr: cstring)
+proc removeAttributeNode*(n, attr: Node)
+proc replaceData*(n: Node, start, len: int, text: cstring)
+proc scrollIntoView*(n: Node)
+proc scrollIntoView*(n: Node, options: ScrollIntoViewOptions)
+proc setAttribute*(n: Node, name, value: cstring)
+proc setAttributeNode*(n: Node, attr: Node)
+proc querySelector*(n: Node, selectors: cstring): Element
+proc querySelectorAll*(n: Node, selectors: cstring): seq[Element]
+proc compareDocumentPosition*(n: Node, otherNode:Node): int
+proc lookupPrefix*(n: Node): cstring
+proc lookupNamespaceURI*(n: Node): cstring
+proc isDefaultNamespace*(n: Node): bool
+proc contains*(n: Node): bool
+proc isEqualNode*(n: Node): bool
+proc isSameNode*(n: Node): bool
+
+since (1, 3):
+  proc getRootNode*(n: Node,options: RootNodeOptions): Node
+
+  # DocumentOrShadowRoot
+  proc getSelection*(n: DocumentOrShadowRoot): Selection
+  proc elementFromPoint*(n: DocumentOrShadowRoot; x, y: float): Element
+
+  # shadow dom
+  proc attachShadow*(n: Element): ShadowRoot
+  proc assignedNodes*(n: HTMLSlotElement; options: SlotOptions): seq[Node]
+  proc assignedElements*(n: HTMLSlotElement; options: SlotOptions): seq[Element]
+
+# Document "methods"
+proc createAttribute*(d: Document, identifier: cstring): Node
+proc getElementsByName*(d: Document, name: cstring): seq[Element]
+proc getElementsByTagName*(d: Document, name: cstring): seq[Element]
+proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
+proc insertNode*(range: Range, node: Node)
+proc getSelection*(d: Document): Selection
+proc handleEvent*(d: Document, event: Event)
+proc open*(d: Document)
+proc routeEvent*(d: Document, event: Event)
+proc write*(d: Document, text: cstring)
+proc writeln*(d: Document, text: cstring)
+proc querySelector*(d: Document, selectors: cstring): Element
+proc querySelectorAll*(d: Document, selectors: cstring): seq[Element]
+
+# Element "methods"
+proc blur*(e: Element)
+proc click*(e: Element)
+proc focus*(e: Element)
+proc handleEvent*(e: Element, event: Event)
+proc select*(e: Element)
+proc getElementsByTagName*(e: Element, name: cstring): seq[Element]
+proc getElementsByClassName*(e: Element, name: cstring): seq[Element]
+
+# FormElement "methods"
+proc reset*(f: FormElement)
+proc submit*(f: FormElement)
+proc checkValidity*(e: FormElement): bool
+proc reportValidity*(e: FormElement): bool
+
+# EmbedElement "methods"
+proc play*(e: EmbedElement)
+proc stop*(e: EmbedElement)
+
+# Location "methods"
+proc reload*(loc: Location)
+proc replace*(loc: Location, s: cstring)
+
+# History "methods"
+proc back*(h: History)
+proc forward*(h: History)
+proc go*(h: History, pagesToJump: int)
+proc pushState*[T](h: History, stateObject: T, title, url: cstring)
+
+# Navigator "methods"
+proc javaEnabled*(h: Navigator): bool
+since (1, 3):
+  proc canShare*(self: Navigator; data: cstring): bool           ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/canShare
+  proc sendBeacon*(self: Navigator; url, data: cstring): bool    ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
+  proc vibrate*(self: Navigator; pattern: cint): bool            ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
+  proc vibrate*(self: Navigator; pattern: openArray[cint]): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
+  proc registerProtocolHandler*(self: Navigator; scheme, url, title: cstring) ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
+
+# ClassList "methods"
+proc add*(c: ClassList, class: cstring)
+proc remove*(c: ClassList, class: cstring)
+proc contains*(c: ClassList, class: cstring): bool
+proc toggle*(c: ClassList, class: cstring)
+
+# Style "methods"
+proc getPropertyValue*(s: Style, property: cstring): cstring
+proc removeProperty*(s: Style, property: cstring)
+proc setProperty*(s: Style, property, value: cstring, priority = "")
+proc getPropertyPriority*(s: Style, property: cstring): cstring
+
+# Event "methods"
+proc preventDefault*(ev: Event)
+proc stopImmediatePropagation*(ev: Event)
+proc stopPropagation*(ev: Event)
+
+# KeyboardEvent "methods"
+proc getModifierState*(ev: KeyboardEvent, keyArg: cstring): bool
+
+# MouseEvent "methods"
+proc getModifierState*(ev: MouseEvent, keyArg: cstring): bool
+
+# TouchEvent "methods"
+proc identifiedTouch*(list: TouchList): Touch
+proc item*(list: TouchList, i: int): Touch
+
+# DataTransfer "methods"
+proc clearData*(dt: DataTransfer, format: cstring)
+proc getData*(dt: DataTransfer, format: cstring): cstring
+proc setData*(dt: DataTransfer, format: cstring, data: cstring)
+proc setDragImage*(dt: DataTransfer, img: Element, xOffset: int, yOffset: int)
+
+# DataTransferItem "methods"
+proc getAsFile*(dti: DataTransferItem): File
+
+# InputElement "methods"
+proc setSelectionRange*(e: InputElement, selectionStart: int, selectionEnd: int, selectionDirection: cstring = "none")
+proc setRangeText*(e: InputElement, replacement: cstring, startindex: int = 0, endindex: int = 0, selectionMode: cstring = "preserve")
+proc setCustomValidity*(e: InputElement, error: cstring)
+proc checkValidity*(e: InputElement): bool
+
+# Blob "methods"
+proc slice*(e: Blob, startindex: int = 0, endindex: int = e.size, contentType: cstring = "")
+
+# Performance "methods"
+proc now*(p: Performance): float
+
+# Selection "methods"
+proc removeAllRanges*(s: Selection)
+proc deleteFromDocument*(s: Selection)
+proc getRangeAt*(s: Selection, index: int): Range
+converter toString*(s: Selection): cstring
+proc `$`*(s: Selection): string = $(s.toString())
+
+# Storage "methods"
+proc getItem*(s: Storage, key: cstring): cstring
+proc setItem*(s: Storage, key, value: cstring)
+proc clear*(s: Storage)
+proc removeItem*(s: Storage, key: cstring)
+
+{.pop.}
+
+proc setAttr*(n: Node; key, val: cstring) {.importcpp: "#.setAttribute(@)".}
+
+var
+  window* {.importc, nodecl.}: Window
+  navigator* {.importc, nodecl.}: Navigator
+  screen* {.importc, nodecl.}: Screen
+
+when not defined(nodejs):
+  var document* {.importc, nodecl.}: Document
+
+proc decodeURI*(uri: cstring): cstring {.importc, nodecl.}
+proc encodeURI*(uri: cstring): cstring {.importc, nodecl.}
+
+proc escape*(uri: cstring): cstring {.importc, nodecl.}
+proc unescape*(uri: cstring): cstring {.importc, nodecl.}
+
+proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
+proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
+proc isFinite*(x: BiggestFloat): bool {.importc, nodecl.}
+proc isNaN*(x: BiggestFloat): bool {.importc, nodecl.}
+  ## see also `math.isNaN`.
+
+proc newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.}
+
+proc getElementsByClass*(n: Node; name: cstring): seq[Node] {.
+  importcpp: "#.getElementsByClassName(#)", nodecl.}
+
+
+type
+  BoundingRect* {.importc.} = object
+    top*, bottom*, left*, right*, x*, y*, width*, height*: float
+
+proc getBoundingClientRect*(e: Node): BoundingRect {.
+  importcpp: "getBoundingClientRect", nodecl.}
+proc clientHeight*(): int {.
+  importcpp: "(window.innerHeight || document.documentElement.clientHeight)@", nodecl.}
+proc clientWidth*(): int {.
+  importcpp: "(window.innerWidth || document.documentElement.clientWidth)@", nodecl.}
+
+proc inViewport*(el: Node): bool =
+  let rect = el.getBoundingClientRect()
+  result = rect.top >= 0 and rect.left >= 0 and
+           rect.bottom <= clientHeight().float and
+           rect.right <= clientWidth().float
+
+proc scrollTop*(e: Node): int {.importcpp: "#.scrollTop", nodecl.}
+proc `scrollTop=`*(e: Node, value: int) {.importcpp: "#.scrollTop = #", nodecl.}
+proc scrollLeft*(e: Node): int {.importcpp: "#.scrollLeft", nodecl.}
+proc scrollHeight*(e: Node): int {.importcpp: "#.scrollHeight", nodecl.}
+proc scrollWidth*(e: Node): int {.importcpp: "#.scrollWidth", nodecl.}
+proc offsetHeight*(e: Node): int {.importcpp: "#.offsetHeight", nodecl.}
+proc offsetWidth*(e: Node): int {.importcpp: "#.offsetWidth", nodecl.}
+proc offsetTop*(e: Node): int {.importcpp: "#.offsetTop", nodecl.}
+proc offsetLeft*(e: Node): int {.importcpp: "#.offsetLeft", nodecl.}
+
+since (1, 3):
+  func newDomParser*(): DomParser {.importcpp: "new DOMParser()".}
+    ## DOM Parser constructor.
+  func parseFromString*(this: DomParser; str: cstring; mimeType: cstring): Document {.importcpp.}
+    ## Parse from string to `Document`.
+
+  proc newDomException*(): DomException {.importcpp: "new DomException()", constructor.}
+    ## DOM Exception constructor
+  proc message*(ex: DomException): cstring {.importcpp: "#.message", nodecl.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/message
+  proc name*(ex: DomException): cstring  {.importcpp: "#.name", nodecl.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name
+
+  proc newFileReader*(): FileReader {.importcpp: "new FileReader()", constructor.}
+    ## File Reader constructor
+  proc error*(f: FileReader): DomException {.importcpp: "#.error", nodecl.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/error
+  proc readyState*(f: FileReader): FileReaderState {.importcpp: "#.readyState", nodecl.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readyState
+  proc resultAsString*(f: FileReader): cstring {.importcpp: "#.result", nodecl.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
+  proc abort*(f: FileReader) {.importcpp: "#.abort()".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/abort
+  proc readAsBinaryString*(f: FileReader, b: Blob) {.importcpp: "#.readAsBinaryString(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsBinaryString
+  proc readAsDataURL*(f: FileReader, b: Blob) {.importcpp: "#.readAsDataURL(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
+  proc readAsText*(f: FileReader, b: Blob|File, encoding = cstring"UTF-8") {.importcpp: "#.readAsText(#, #)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText
+
+since (1, 5):
+  proc elementsFromPoint*(n: DocumentOrShadowRoot; x, y: float): seq[Element] {.importcpp.}
+
+
+since (1, 7):
+
+  proc insertAdjacentText*(self: Node; position, data: cstring) {.importjs: "#.$1(#, #)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText
+
+  proc insertAdjacentElement*(self: Node; position: cstring; element: Node) {.importjs: "#.$1(#, #)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement
+
+  proc insertAdjacentHTML*(self: Node; position, html: cstring) {.importjs: "#.$1(#, #)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
+
+  proc after*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/after
+
+  proc before*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/before
+
+  proc append*(self: Node; element: Node): Node {.importjs: "#.$1(@)", varargs.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/append
+
+  proc closest*(self: Node; cssSelector: cstring): Node {.importjs: "#.$1(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
+
+  proc hasAttributeNS*(self: Node; namespace, localName: cstring): bool {.importjs: "(#.$1(#, #) || false)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributeNS
+
+  proc removeAttributeNS*(self: Node; namespace, attributeName: cstring) {.importjs: "#.$1(#, #)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttributeNS
+
+  proc hasPointerCapture*(self: Node; pointerId: SomeNumber): bool {.importjs: "(#.$1(#) || false)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/hasPointerCapture
+
+  proc releasePointerCapture*(self: Node; pointerId: SomeNumber) {.importjs: "#.$1(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/releasePointerCapture
+
+  proc requestPointerLock*(self: Node) {.importjs: "#.$1()".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock
+
+  proc replaceChildren*(self: Node; replacements: Node) {.importjs: "#.$1(@)", varargs.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren
+
+  proc replaceWith*(self: Node; replacements: Node) {.importjs: "#.$1(@)", varargs.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith
+
+  proc scrollIntoViewIfNeeded*(self: Node; centerIfNeeded: bool) {.importjs: "#.$1(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
+
+  proc setHTML*(self: Node; html: cstring) {.importjs: "#.$1(#)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTML
+
+  proc toggleAttribute*(self: Node; name: cstring; force = false): bool {.importjs: "(#.$1(#, #) || false)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute
+
+  proc matches*(self: Node; cssSelector: cstring): bool {.importjs: "(#.$1(#) || false)".}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
+
+
+since (2, 1):
+  type VisualViewport* {.importc.} = ref object of EventTarget
+    offsetLeft*, offsetTop*, pageLeft*, pageTop*, width*, height*, scale*: float
+    onResize*, onScroll*: proc (event: Event) {.closure.}
+
+  func visualViewport*(self: Window): VisualViewport {.importjs: "#.$1", nodecl.}
diff --git a/lib/js/jsconsole.nim b/lib/js/jsconsole.nim
new file mode 100644
index 000000000..e74127334
--- /dev/null
+++ b/lib/js/jsconsole.nim
@@ -0,0 +1,125 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Wrapper for the `console` object for the `JavaScript backend
+## <backends.html#backends-the-javascript-target>`_.
+##
+## Styled Messages
+## ===============
+##
+## CSS-styled messages in the browser are useful for debugging purposes.
+## To use them, prefix the message with one or more `%c`,
+## and provide the CSS style as the last argument.
+## The amount of `%c`'s must match the amount of CSS-styled strings.
+##
+runnableExamples("-r:off"):
+  console.log "%c My Debug Message", "color: red" # Notice the "%c"
+  console.log "%c My Debug %c Message", "color: red", "font-size: 2em"
+
+import std/private/since, std/private/miscdollars  # toLocation
+
+when not defined(js):
+  {.error: "This module only works on the JavaScript platform".}
+
+type Console* = ref object of JsRoot
+
+proc log*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/log
+
+proc debug*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/debug
+
+proc info*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/info
+
+proc error*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/error
+
+template exception*(console: Console, args: varargs[untyped]) =
+  ## Alias for `console.error()`.
+  error(console, args)
+
+proc trace*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/trace
+
+proc warn*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/warn
+
+proc clear*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/clear
+
+proc count*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/count
+
+proc countReset*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/countReset
+
+proc group*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/group
+
+proc groupCollapsed*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Console/groupCollapsed
+
+proc groupEnd*(console: Console) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/groupEnd
+
+proc time*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/time
+
+proc timeEnd*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/timeEnd
+
+proc timeLog*(console: Console, label = "".cstring) {.importcpp.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/timeLog
+
+proc table*(console: Console) {.importcpp, varargs.}
+  ## https://developer.mozilla.org/docs/Web/API/Console/table
+
+since (1, 5):
+  type InstantiationInfo = tuple[filename: string, line: int, column: int]
+
+  func getMsg(info: InstantiationInfo; msg: string): string =
+    var temp = ""
+    temp.toLocation(info.filename, info.line, info.column + 1)
+    result.addQuoted("[jsAssert] " & temp)
+    result.add ','
+    result.addQuoted(msg)
+
+  template jsAssert*(console: Console; assertion) =
+    ## JavaScript `console.assert`, for NodeJS this prints to stderr,
+    ## assert failure just prints to console and do not quit the program,
+    ## this is not meant to be better or even equal than normal assertions,
+    ## is just for when you need faster performance *and* assertions,
+    ## otherwise use the normal assertions for better user experience.
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Console/assert
+    runnableExamples:
+      console.jsAssert(42 == 42) # OK
+      console.jsAssert(42 != 42) # Fail, prints "Assertion failed" and continues
+      console.jsAssert('`' == '\n' and '\t' == '\0') # Message correctly formatted
+      assert 42 == 42  # Normal assertions keep working
+
+    const
+      loc = instantiationInfo(fullPaths = compileOption("excessiveStackTrace"))
+      msg = getMsg(loc, astToStr(assertion)).cstring
+    {.line: loc.}:
+      {.emit: ["console.assert(", assertion, ", ", msg, ");"].}
+
+  func dir*(console: Console; obj: auto) {.importcpp.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Console/dir
+
+  func dirxml*(console: Console; obj: auto) {.importcpp.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Console/dirxml
+
+  func timeStamp*(console: Console; label: cstring) {.importcpp.}
+    ## https://developer.mozilla.org/en-US/docs/Web/API/Console/timeStamp
+    ##
+    ## ..warning:: non-standard
+
+
+var console* {.importc, nodecl.}: Console
diff --git a/lib/js/jscore.nim b/lib/js/jscore.nim
new file mode 100644
index 000000000..be353875c
--- /dev/null
+++ b/lib/js/jscore.nim
@@ -0,0 +1,153 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module wraps core JavaScript functions.
+##
+## Unless your application has very
+## specific requirements and solely targets JavaScript, you should be using
+## the relevant functions in the `math`, `json`, and `times` stdlib
+## modules instead.
+import std/private/[since, jsutils]
+
+when not defined(js):
+  {.error: "This module only works on the JavaScript platform".}
+
+type
+  MathLib* = ref object
+  JsonLib* = ref object
+  DateLib* = ref object
+  DateTime* = ref object
+
+var
+  Math* {.importc, nodecl.}: MathLib
+  Date* {.importc, nodecl.}: DateLib
+  JSON* {.importc, nodecl.}: JsonLib
+
+# Math library
+proc abs*(m: MathLib, a: SomeNumber): SomeNumber {.importcpp.}
+proc acos*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc acosh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc asin*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc asinh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc atan*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc atan2*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc atanh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc cbrt*(m: MathLib, f: SomeFloat): SomeFloat {.importcpp.}
+proc ceil*(m: MathLib, f: SomeFloat): SomeFloat {.importcpp.}
+proc clz32*(m: MathLib, f: SomeInteger): int {.importcpp.}
+proc cos*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc cosh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc exp*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc expm1*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc floor*(m: MathLib, f: SomeFloat): int {.importcpp.}
+proc fround*(m: MathLib, f: SomeFloat): float32 {.importcpp.}
+proc hypot*(m: MathLib, args: varargs[distinct SomeNumber]): float {.importcpp.}
+proc imul*(m: MathLib, a, b: int32): int32 {.importcpp.}
+proc log*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc log10*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc log1p*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc log2*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc max*(m: MathLib, a, b: SomeNumber): SomeNumber {.importcpp.}
+proc min*[T: SomeNumber | JsRoot](m: MathLib, a, b: T): T {.importcpp.}
+proc pow*(m: MathLib, a, b: distinct SomeNumber): float {.importcpp.}
+proc random*(m: MathLib): float {.importcpp.}
+proc round*(m: MathLib, f: SomeFloat): int {.importcpp.}
+proc sign*(m: MathLib, f: SomeNumber): int {.importcpp.}
+proc sin*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc sinh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc sqrt*(m: MathLib, f: SomeFloat): SomeFloat {.importcpp.}
+proc tan*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc tanh*(m: MathLib, a: SomeNumber): float {.importcpp.}
+proc trunc*(m: MathLib, f: SomeFloat): int {.importcpp.}
+
+# Date library
+proc now*(d: DateLib): int {.importcpp.}
+proc UTC*(d: DateLib): int {.importcpp.}
+proc parse*(d: DateLib, s: cstring): int {.importcpp.}
+
+proc newDate*(): DateTime {.
+  importcpp: "new Date()".}
+
+proc newDate*(date: int|string): DateTime {.
+  importcpp: "new Date(#)".}
+
+whenJsNoBigInt64:
+  proc newDate*(date: int64): DateTime {.
+    importcpp: "new Date(#)".}
+do:
+  proc newDate*(date: int64): DateTime {.
+    importcpp: "new Date(Number(#))".}
+
+proc newDate*(year, month, day, hours, minutes,
+             seconds, milliseconds: int): DateTime {.
+  importcpp: "new Date(#,#,#,#,#,#,#)".}
+
+proc getDay*(d: DateTime): int {.importcpp.}
+proc getFullYear*(d: DateTime): int {.importcpp.}
+proc getHours*(d: DateTime): int {.importcpp.}
+proc getMilliseconds*(d: DateTime): int {.importcpp.}
+proc getMinutes*(d: DateTime): int {.importcpp.}
+proc getMonth*(d: DateTime): int {.importcpp.}
+proc getSeconds*(d: DateTime): int {.importcpp.}
+proc getTime*(d: DateTime): int {.importcpp.}
+proc getTimezoneOffset*(d: DateTime): int {.importcpp.}
+proc getUTCDate*(d: DateTime): int {.importcpp.}
+proc getUTCDay*(d: DateTime): int {.importcpp.}
+proc getUTCFullYear*(d: DateTime): int {.importcpp.}
+proc getUTCHours*(d: DateTime): int {.importcpp.}
+proc getUTCMilliseconds*(d: DateTime): int {.importcpp.}
+proc getUTCMinutes*(d: DateTime): int {.importcpp.}
+proc getUTCMonth*(d: DateTime): int {.importcpp.}
+proc getUTCSeconds*(d: DateTime): int {.importcpp.}
+proc getYear*(d: DateTime): int {.importcpp.}
+
+proc setFullYear*(d: DateTime, year: int) {.importcpp.}
+
+func toDateString*(d: DateTime): cstring {.importcpp.}
+func toISOString*(d: DateTime): cstring {.importcpp.}
+func toJSON*(d: DateTime): cstring {.importcpp.}
+proc toString*(d: DateTime): cstring {.importcpp.}
+func toTimeString*(d: DateTime): cstring {.importcpp.}
+func toUTCString*(d: DateTime): cstring {.importcpp.}
+
+#JSON library
+proc stringify*(l: JsonLib, s: JsRoot): cstring {.importcpp.}
+proc parse*(l: JsonLib, s: cstring): JsRoot {.importcpp.}
+
+
+since (1, 5):
+  func debugger*() {.importjs: "debugger@".}
+    ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger
+
+  func copyWithin*[T](self: openArray[T]; target: int): seq[T] {.importjs: "#.copyWithin(#)".}
+  func copyWithin*[T](self: openArray[T]; target, start: int): seq[T] {.importjs: "#.copyWithin(#, #)".}
+  func copyWithin*[T](self: openArray[T]; target, start, ends: int): seq[T] {.importjs: "#.copyWithin(#, #, #)".} =
+    ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin
+    ## `copyWithin` uses shallow copy.
+    runnableExamples:
+      assert ['a', 'b', 'c', 'd', 'e'].copyWithin(0, 3, 4) == @['d', 'b', 'c', 'd', 'e']
+      assert ['a', 'b', 'c', 'd', 'e'].copyWithin(1, 3) == @['a', 'd', 'e', 'd', 'e']
+      assert [1, 2, 3, 4, 5].copyWithin(-2) == @[1, 2, 3, 1, 2]
+      assert [1, 2, 3, 4, 5].copyWithin(0, 3) == @[4, 5, 3, 4, 5]
+      assert [1, 2, 3, 4, 5].copyWithin(0, 3, 4) == @[4, 2, 3, 4, 5]
+      assert [1, 2, 3, 4, 5].copyWithin(-2, -3, -1) == @[1, 2, 3, 3, 4]
+
+
+since (1, 7):
+  func shift*[T](self: seq[T]): T {.importjs: "#.$1()".} =
+    ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
+    runnableExamples:
+      var arrai = @[1, 2, 3]
+      assert arrai.shift() == 1
+      assert arrai == @[2, 3]
+
+  func queueMicrotask*(function: proc) {.importjs: "$1(#)".} =
+    ## * https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask
+    ## * https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
+    runnableExamples"-r:off": queueMicrotask(proc() = echo "Microtask")
diff --git a/lib/js/jsffi.nim b/lib/js/jsffi.nim
new file mode 100644
index 000000000..d50d58ae5
--- /dev/null
+++ b/lib/js/jsffi.nim
@@ -0,0 +1,527 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim Authors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This Module implements types and macros to facilitate the wrapping of, and
+## interaction with JavaScript libraries. Using the provided types `JsObject`
+## and `JsAssoc` together with the provided macros allows for smoother
+## interfacing with JavaScript, allowing for example quick and easy imports of
+## JavaScript variables:
+
+runnableExamples:
+  # Here, we are using jQuery for just a few calls and do not want to wrap the
+  # whole library:
+
+  # import the document object and the console
+  var document {.importc, nodecl.}: JsObject
+  var console {.importc, nodecl.}: JsObject
+  # import the "$" function
+  proc jq(selector: JsObject): JsObject {.importjs: "$$(#)".}
+
+  # Use jQuery to make the following code run, after the document is ready.
+  # This uses an experimental `.()` operator for `JsObject`, to emit
+  # JavaScript calls, when no corresponding proc exists for `JsObject`.
+  proc main =
+    jq(document).ready(proc() =
+      console.log("Hello JavaScript!")
+    )
+
+
+when not defined(js) and not defined(nimsuggest):
+  {.fatal: "Module jsFFI is designed to be used with the JavaScript backend.".}
+
+import std/[macros, tables]
+
+const
+  setImpl = "#[#] = #"
+  getImpl = "#[#]"
+
+var
+  mangledNames {.compileTime.} = initTable[string, string]()
+  nameCounter {.compileTime.} = 0
+
+proc validJsName(name: string): bool =
+  result = true
+  const reservedWords = ["break", "case", "catch", "class", "const", "continue",
+    "debugger", "default", "delete", "do", "else", "export", "extends",
+    "finally", "for", "function", "if", "import", "in", "instanceof", "new",
+    "return", "super", "switch", "this", "throw", "try", "typeof", "var",
+    "void", "while", "with", "yield", "enum", "implements", "interface",
+    "let", "package", "private", "protected", "public", "static", "await",
+    "abstract", "boolean", "byte", "char", "double", "final", "float", "goto",
+    "int", "long", "native", "short", "synchronized", "throws", "transient",
+    "volatile", "null", "true", "false"]
+  case name
+  of reservedWords: return false
+  else: discard
+  if name[0] notin {'A'..'Z','a'..'z','_','$'}: return false
+  for chr in name:
+    if chr notin {'A'..'Z','a'..'z','_','$','0'..'9'}:
+      return false
+
+template mangleJsName(name: string): string =
+  inc nameCounter
+  "mangledName" & $nameCounter
+
+# only values that can be mapped 1 to 1 with cstring should be keys: they have an injective function with cstring
+
+proc toJsKey*[T: SomeInteger](text: cstring, t: type T): T {.importjs: "parseInt(#)".}
+
+proc toJsKey*[T: enum](text: cstring, t: type T): T =
+  T(text.toJsKey(int))
+
+proc toJsKey*(text: cstring, t: type cstring): cstring =
+  text
+
+proc toJsKey*[T: SomeFloat](text: cstring, t: type T): T {.importjs: "parseFloat(#)".}
+
+type
+  JsKey* = concept a, type T
+    cstring.toJsKey(T) is T
+
+  JsObject* = ref object of JsRoot
+    ## Dynamically typed wrapper around a JavaScript object.
+  JsAssoc*[K: JsKey, V] = ref object of JsRoot
+    ## Statically typed wrapper around a JavaScript object.
+
+  js* = JsObject
+
+var
+  jsArguments* {.importc: "arguments", nodecl}: JsObject
+    ## JavaScript's arguments pseudo-variable.
+  jsNull* {.importc: "null", nodecl.}: JsObject
+    ## JavaScript's null literal.
+  jsUndefined* {.importc: "undefined", nodecl.}: JsObject
+    ## JavaScript's undefined literal.
+  jsDirname* {.importc: "__dirname", nodecl.}: cstring
+    ## JavaScript's __dirname pseudo-variable.
+  jsFilename* {.importc: "__filename", nodecl.}: cstring
+    ## JavaScript's __filename pseudo-variable.
+
+proc isNull*[T](x: T): bool {.noSideEffect, importjs: "(# === null)".}
+  ## Checks if a value is exactly null.
+
+proc isUndefined*[T](x: T): bool {.noSideEffect, importjs: "(# === undefined)".}
+  ## Checks if a value is exactly undefined.
+
+# Exceptions
+type
+  JsError* {.importc: "Error".} = object of JsRoot
+    message*: cstring
+  JsEvalError* {.importc: "EvalError".} = object of JsError
+  JsRangeError* {.importc: "RangeError".} = object of JsError
+  JsReferenceError* {.importc: "ReferenceError".} = object of JsError
+  JsSyntaxError* {.importc: "SyntaxError".} = object of JsError
+  JsTypeError* {.importc: "TypeError".} = object of JsError
+  JsURIError* {.importc: "URIError".} = object of JsError
+
+# New
+proc newJsObject*: JsObject {.importjs: "{@}".}
+  ## Creates a new empty JsObject.
+
+proc newJsAssoc*[K: JsKey, V]: JsAssoc[K, V] {.importjs: "{@}".}
+  ## Creates a new empty JsAssoc with key type `K` and value type `V`.
+
+# Checks
+proc hasOwnProperty*(x: JsObject, prop: cstring): bool
+  {.importjs: "#.hasOwnProperty(#)".}
+  ## Checks, whether `x` has a property of name `prop`.
+
+proc jsTypeOf*(x: JsObject): cstring {.importjs: "typeof(#)".}
+  ## Returns the name of the JsObject's JavaScript type as a cstring.
+
+proc jsNew*(x: auto): JsObject {.importjs: "(new #)".}
+  ## Turns a regular function call into an invocation of the
+  ## JavaScript's `new` operator.
+
+proc jsDelete*(x: auto): JsObject {.importjs: "(delete #)".}
+  ## JavaScript's `delete` operator.
+
+proc require*(module: cstring): JsObject {.importc.}
+  ## JavaScript's `require` function.
+
+# Conversion to and from JsObject
+proc to*(x: JsObject, T: typedesc): T {.importjs: "(#)".}
+  ## Converts a JsObject `x` to type `T`.
+
+proc toJs*[T](val: T): JsObject {.importjs: "(#)".}
+  ## Converts a value of any type to type JsObject.
+
+template toJs*(s: string): JsObject = cstring(s).toJs
+
+macro jsFromAst*(n: untyped): untyped =
+  result = n
+  if n.kind == nnkStmtList:
+    result = newProc(procType = nnkDo, body = result)
+  return quote: toJs(`result`)
+
+proc `&`*(a, b: cstring): cstring {.importjs: "(# + #)".}
+  ## Concatenation operator for JavaScript strings.
+
+proc `+`*(x, y: JsObject): JsObject {.importjs: "(# + #)".}
+proc `-`*(x, y: JsObject): JsObject {.importjs: "(# - #)".}
+proc `*`*(x, y: JsObject): JsObject {.importjs: "(# * #)".}
+proc `/`*(x, y: JsObject): JsObject {.importjs: "(# / #)".}
+proc `%`*(x, y: JsObject): JsObject {.importjs: "(# % #)".}
+proc `+=`*(x, y: JsObject): JsObject {.importjs: "(# += #)", discardable.}
+proc `-=`*(x, y: JsObject): JsObject {.importjs: "(# -= #)", discardable.}
+proc `*=`*(x, y: JsObject): JsObject {.importjs: "(# *= #)", discardable.}
+proc `/=`*(x, y: JsObject): JsObject {.importjs: "(# /= #)", discardable.}
+proc `%=`*(x, y: JsObject): JsObject {.importjs: "(# %= #)", discardable.}
+proc `++`*(x:    JsObject): JsObject {.importjs: "(++#)".}
+proc `--`*(x:    JsObject): JsObject {.importjs: "(--#)".}
+proc `>`*(x, y: JsObject): JsObject {.importjs: "(# > #)".}
+proc `<`*(x, y: JsObject): JsObject {.importjs: "(# < #)".}
+proc `>=`*(x, y: JsObject): JsObject {.importjs: "(# >= #)".}
+proc `<=`*(x, y: JsObject): JsObject {.importjs: "(# <= #)".}
+proc `**`*(x, y: JsObject): JsObject {.importjs: "((#) ** #)".}
+  # (#) needed, refs https://github.com/nim-lang/Nim/pull/16409#issuecomment-760550812
+proc `and`*(x, y: JsObject): JsObject {.importjs: "(# && #)".}
+proc `or`*(x, y: JsObject): JsObject {.importjs: "(# || #)".}
+proc `not`*(x:    JsObject): JsObject {.importjs: "(!#)".}
+proc `in`*(x, y: JsObject): JsObject {.importjs: "(# in #)".}
+
+proc `[]`*(obj: JsObject, field: cstring): JsObject {.importjs: getImpl.}
+  ## Returns the value of a property of name `field` from a JsObject `obj`.
+
+proc `[]`*(obj: JsObject, field: int): JsObject {.importjs: getImpl.}
+  ## Returns the value of a property of name `field` from a JsObject `obj`.
+
+proc `[]=`*[T](obj: JsObject, field: cstring, val: T) {.importjs: setImpl.}
+  ## Sets the value of a property of name `field` in a JsObject `obj` to `v`.
+
+proc `[]=`*[T](obj: JsObject, field: int, val: T) {.importjs: setImpl.}
+  ## Sets the value of a property of name `field` in a JsObject `obj` to `v`.
+
+proc `[]`*[K: JsKey, V](obj: JsAssoc[K, V], field: K): V
+  {.importjs: getImpl.}
+  ## Returns the value of a property of name `field` from a JsAssoc `obj`.
+
+proc `[]=`*[K: JsKey, V](obj: JsAssoc[K, V], field: K, val: V)
+  {.importjs: setImpl.}
+  ## Sets the value of a property of name `field` in a JsAssoc `obj` to `v`.
+
+proc `[]`*[V](obj: JsAssoc[cstring, V], field: string): V =
+  obj[cstring(field)]
+
+proc `[]=`*[V](obj: JsAssoc[cstring, V], field: string, val: V) =
+  obj[cstring(field)] = val
+
+proc `==`*(x, y: JsRoot): bool {.importjs: "(# === #)".}
+  ## Compares two JsObjects or JsAssocs. Be careful though, as this is comparison
+  ## like in JavaScript, so if your JsObjects are in fact JavaScript Objects,
+  ## and not strings or numbers, this is a *comparison of references*.
+
+{.experimental.}
+macro `.`*(obj: JsObject, field: untyped): JsObject =
+  ## Experimental dot accessor (get) for type JsObject.
+  ## Returns the value of a property of name `field` from a JsObject `x`.
+  runnableExamples:
+    let obj = newJsObject()
+    obj.a = 20
+    assert obj.a.to(int) == 20
+  if validJsName($field):
+    let importString = "#." & $field
+    let helperName = genSym(nskProc, "helper")
+    result = quote do:
+      proc `helperName`(o: JsObject): JsObject
+        {.importjs: `importString`.}
+      `helperName`(`obj`)
+  else:
+    if not mangledNames.hasKey($field):
+      mangledNames[$field] = mangleJsName($field)
+    let importString = "#." & mangledNames[$field]
+    let helperName = genSym(nskProc, "helper")
+    result = quote do:
+      proc `helperName`(o: JsObject): JsObject
+        {.importjs: `importString`.}
+      `helperName`(`obj`)
+
+macro `.=`*(obj: JsObject, field, value: untyped): untyped =
+  ## Experimental dot accessor (set) for type JsObject.
+  ## Sets the value of a property of name `field` in a JsObject `x` to `value`.
+  if validJsName($field):
+    let importString = "#." & $field & " = #"
+    let helperName = genSym(nskProc, "helper")
+    result = quote do:
+      proc `helperName`(o: JsObject, v: auto)
+        {.importjs: `importString`.}
+      `helperName`(`obj`, `value`)
+  else:
+    if not mangledNames.hasKey($field):
+      mangledNames[$field] = mangleJsName($field)
+    let importString = "#." & mangledNames[$field] & " = #"
+    let helperName = genSym(nskProc, "helper")
+    result = quote do:
+      proc `helperName`(o: JsObject, v: auto)
+        {.importjs: `importString`.}
+      `helperName`(`obj`, `value`)
+
+macro `.()`*(obj: JsObject,
+             field: untyped,
+             args: varargs[JsObject, jsFromAst]): JsObject =
+  ## Experimental "method call" operator for type JsObject.
+  ## Takes the name of a method of the JavaScript object (`field`) and calls
+  ## it with `args` as arguments, returning a JsObject (which may be discarded,
+  ## and may be `undefined`, if the method does not return anything,
+  ## so be careful when using this.)
+  ##
+  ## Example:
+  ##   ```nim
+  ##   # Let's get back to the console example:
+  ##   var console {.importc, nodecl.}: JsObject
+  ##   let res = console.log("I return undefined!")
+  ##   console.log(res) # This prints undefined, as console.log always returns
+  ##                    # undefined. Thus one has to be careful, when using
+  ##                    # JsObject calls.
+  ##   ```
+  var importString: string
+  if validJsName($field):
+    importString = "#." & $field & "(@)"
+  else:
+    if not mangledNames.hasKey($field):
+      mangledNames[$field] = mangleJsName($field)
+    importString = "#." & mangledNames[$field] & "(@)"
+  let helperName = genSym(nskProc, "helper")
+  result = quote do:
+    proc `helperName`(o: JsObject): JsObject
+      {.importjs: `importString`, discardable.}
+    `helperName`(`obj`)
+  for idx in 0 ..< args.len:
+    let paramName = newIdentNode("param" & $idx)
+    result[0][3].add newIdentDefs(paramName, newIdentNode("JsObject"))
+    result[1].add args[idx].copyNimTree
+
+macro `.`*[K: cstring, V](obj: JsAssoc[K, V],
+                                   field: untyped): V =
+  ## Experimental dot accessor (get) for type JsAssoc.
+  ## Returns the value of a property of name `field` from a JsObject `x`.
+  var importString: string
+  if validJsName($field):
+    importString = "#." & $field
+  else:
+    if not mangledNames.hasKey($field):
+      mangledNames[$field] = mangleJsName($field)
+    importString = "#." & mangledNames[$field]
+  let helperName = genSym(nskProc, "helper")
+  result = quote do:
+    proc `helperName`(o: type(`obj`)): `obj`.V
+      {.importjs: `importString`.}
+    `helperName`(`obj`)
+
+macro `.=`*[K: cstring, V](obj: JsAssoc[K, V],
+                                    field: untyped,
+                                    value: V): untyped =
+  ## Experimental dot accessor (set) for type JsAssoc.
+  ## Sets the value of a property of name `field` in a JsObject `x` to `value`.
+  var importString: string
+  if validJsName($field):
+    importString = "#." & $field & " = #"
+  else:
+    if not mangledNames.hasKey($field):
+      mangledNames[$field] = mangleJsName($field)
+    importString = "#." & mangledNames[$field] & " = #"
+  let helperName = genSym(nskProc, "helper")
+  result = quote do:
+    proc `helperName`(o: type(`obj`), v: `obj`.V)
+      {.importjs: `importString`.}
+    `helperName`(`obj`, `value`)
+
+macro `.()`*[K: cstring, V: proc](obj: JsAssoc[K, V],
+                                           field: untyped,
+                                           args: varargs[untyped]): auto =
+  ## Experimental "method call" operator for type JsAssoc.
+  ## Takes the name of a method of the JavaScript object (`field`) and calls
+  ## it with `args` as arguments. Here, everything is typechecked, so you do not
+  ## have to worry about `undefined` return values.
+  let dotOp = bindSym"."
+  result = quote do:
+    (`dotOp`(`obj`, `field`))()
+  for elem in args:
+    result.add elem
+
+# Iterators:
+
+iterator pairs*(obj: JsObject): (cstring, JsObject) =
+  ## Yields tuples of type `(cstring, JsObject)`, with the first entry
+  ## being the `name` of a fields in the JsObject and the second being its
+  ## value wrapped into a JsObject.
+  var k: cstring
+  var v: JsObject
+  {.emit: "for (var `k` in `obj`) {".}
+  {.emit: "  if (!`obj`.hasOwnProperty(`k`)) { continue; }".}
+  {.emit: "  `v` = `obj`[`k`];".}
+  yield (k, v)
+  {.emit: "}".}
+
+iterator items*(obj: JsObject): JsObject =
+  ## Yields the `values` of each field in a JsObject, wrapped into a JsObject.
+  var v: JsObject
+  {.emit: "for (var k in `obj`) {".}
+  {.emit: "  if (!`obj`.hasOwnProperty(k)) { continue; }".}
+  {.emit: "  `v` = `obj`[k];".}
+  yield v
+  {.emit: "}".}
+
+iterator keys*(obj: JsObject): cstring =
+  ## Yields the `names` of each field in a JsObject.
+  var k: cstring
+  {.emit: "for (var `k` in `obj`) {".}
+  {.emit: "  if (!`obj`.hasOwnProperty(`k`)) { continue; }".}
+  yield k
+  {.emit: "}".}
+
+iterator pairs*[K: JsKey, V](assoc: JsAssoc[K, V]): (K,V) =
+  ## Yields tuples of type `(K, V)`, with the first entry
+  ## being a `key` in the JsAssoc and the second being its corresponding value.
+  var k: cstring
+  var v: V
+  {.emit: "for (var `k` in `assoc`) {".}
+  {.emit: "  if (!`assoc`.hasOwnProperty(`k`)) { continue; }".}
+  {.emit: "  `v` = `assoc`[`k`];".}
+  yield (k.toJsKey(K), v)
+  {.emit: "}".}
+
+iterator items*[K, V](assoc: JsAssoc[K, V]): V =
+  ## Yields the `values` in a JsAssoc.
+  var v: V
+  {.emit: "for (var k in `assoc`) {".}
+  {.emit: "  if (!`assoc`.hasOwnProperty(k)) { continue; }".}
+  {.emit: "  `v` = `assoc`[k];".}
+  yield v
+  {.emit: "}".}
+
+iterator keys*[K: JsKey, V](assoc: JsAssoc[K, V]): K =
+  ## Yields the `keys` in a JsAssoc.
+  var k: cstring
+  {.emit: "for (var `k` in `assoc`) {".}
+  {.emit: "  if (!`assoc`.hasOwnProperty(`k`)) { continue; }".}
+  yield k.toJsKey(K)
+  {.emit: "}".}
+
+# Literal generation
+
+macro `{}`*(typ: typedesc, xs: varargs[untyped]): auto =
+  ## Takes a `typedesc` as its first argument, and a series of expressions of
+  ## type `key: value`, and returns a value of the specified type with each
+  ## field `key` set to `value`, as specified in the arguments of `{}`.
+  ##
+  ## Example:
+  ##
+  ##   ```nim
+  ##   # Let's say we have a type with a ton of fields, where some fields do not
+  ##   # need to be set, and we do not want those fields to be set to `nil`:
+  ##   type
+  ##     ExtremelyHugeType = ref object
+  ##       a, b, c, d, e, f, g: int
+  ##       h, i, j, k, l: cstring
+  ##       # And even more fields ...
+  ##
+  ##   let obj = ExtremelyHugeType{ a: 1, k: "foo".cstring, d: 42 }
+  ##
+  ##   # This generates roughly the same JavaScript as:
+  ##   {.emit: "var obj = {a: 1, k: "foo", d: 42};".}
+  ##   ```
+  let a = ident"a"
+  var body = quote do:
+    var `a` {.noinit.}: `typ`
+    {.emit: "`a` = {};".}
+  for x in xs.children:
+    if x.kind == nnkExprColonExpr:
+      let
+        k = x[0]
+        kString = quote do:
+          when compiles($`k`): $`k` else: "invalid"
+        v = x[1]
+      body.add quote do:
+        when compiles(`a`.`k`):
+          `a`.`k` = `v`
+        elif compiles(`a`[`k`]):
+          `a`[`k`] = `v`
+        else:
+          `a`[`kString`] = `v`
+
+    else:
+      error("Expression `" & $x.toStrLit & "` not allowed in `{}` macro")
+
+  body.add quote do:
+    return `a`
+
+  result = quote do:
+    proc inner(): `typ` {.gensym.} =
+      `body`
+    inner()
+
+# Macro to build a lambda using JavaScript's `this`
+# from a proc, `this` being the first argument.
+
+proc replaceSyms(n: NimNode): NimNode =
+  if n.kind == nnkSym:
+    result = newIdentNode($n)
+  else:
+    result = n
+    for i in 0..<n.len:
+      result[i] = replaceSyms(n[i])
+
+macro bindMethod*(procedure: typed): auto {.deprecated: "Don't use it with closures".} =
+  ## Takes the name of a procedure and wraps it into a lambda missing the first
+  ## argument, which passes the JavaScript builtin `this` as the first
+  ## argument to the procedure. Returns the resulting lambda.
+  ##
+  ## Example:
+  ##
+  ## We want to generate roughly this JavaScript:
+  ##   ```js
+  ##   var obj = {a: 10};
+  ##   obj.someMethod = function() {
+  ##     return this.a + 42;
+  ##   };
+  ##   ```
+  ##
+  ## We can achieve this using the `bindMethod` macro:
+  ##
+  ##   ```nim
+  ##   let obj = JsObject{ a: 10 }
+  ##   proc someMethodImpl(that: JsObject): int =
+  ##     that.a.to(int) + 42
+  ##   obj.someMethod = bindMethod someMethodImpl
+  ##
+  ##   # Alternatively:
+  ##   obj.someMethod = bindMethod
+  ##     proc(that: JsObject): int = that.a.to(int) + 42
+  ##   ```
+  if not (procedure.kind == nnkSym or procedure.kind == nnkLambda):
+    error("Argument has to be a proc or a symbol corresponding to a proc.")
+  var
+    rawProc = if procedure.kind == nnkSym:
+        getImpl(procedure)
+      else:
+        procedure
+    args = rawProc[3].copyNimTree.replaceSyms
+    thisType = args[1][1]
+    params = newNimNode(nnkFormalParams).add(args[0])
+    body = newNimNode(nnkLambda)
+    this = newIdentNode("this")
+    # construct the `this` parameter:
+    thisQuote = quote do:
+      var `this` {.nodecl, importc: "this".}: `thisType`
+    call = newNimNode(nnkCall).add(rawProc[0], thisQuote[0][0][0])
+  # construct the procedure call inside the method
+  if args.len > 2:
+    for idx in 2..args.len-1:
+      params.add(args[idx])
+      call.add(args[idx][0])
+  body.add(newNimNode(nnkEmpty),
+      rawProc[1],
+      rawProc[2],
+      params,
+      rawProc[4],
+      rawProc[5],
+      newTree(nnkStmtList, thisQuote, call)
+  )
+  result = body
diff --git a/lib/js/jsre.nim b/lib/js/jsre.nim
new file mode 100644
index 000000000..2d931eb20
--- /dev/null
+++ b/lib/js/jsre.nim
@@ -0,0 +1,97 @@
+## Regular Expressions for the JavaScript target.
+## * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
+when not defined(js):
+  {.error: "This module only works on the JavaScript platform".}
+
+type RegExp* = ref object of JsRoot
+  ## Regular Expressions for JavaScript target.
+  ## See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
+  flags*: cstring        ## cstring that contains the flags of the RegExp object.
+  dotAll*: bool          ## Whether `.` matches newlines or not.
+  global*: bool          ## Whether to test against all possible matches in a string, or only against the first.
+  ignoreCase*: bool      ## Whether to ignore case while attempting a match in a string.
+  multiline*: bool       ## Whether to search in strings across multiple lines.
+  source*: cstring       ## The text of the pattern.
+  sticky*: bool          ## Whether the search is sticky.
+  unicode*: bool         ## Whether Unicode features are enabled.
+  lastIndex*: cint       ## Index at which to start the next match (read/write property).
+  input*: cstring        ## Read-only and modified on successful match.
+  lastMatch*: cstring    ## Ditto.
+  lastParen*: cstring    ## Ditto.
+  leftContext*: cstring  ## Ditto.
+  rightContext*: cstring ## Ditto.
+  hasIndices*: bool      ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices
+
+
+func newRegExp*(pattern: cstring; flags: cstring): RegExp {.importjs: "new RegExp(@)".}
+  ## Creates a new RegExp object.
+
+func newRegExp*(pattern: cstring): RegExp {.importjs: "new RegExp(@)".}
+
+func compile*(self: RegExp; pattern: cstring; flags: cstring) {.importjs: "#.compile(@)".}
+  ## Recompiles a regular expression during execution of a script.
+
+func replace*(pattern: cstring; self: RegExp; replacement: cstring): cstring {.importjs: "#.replace(#, #)".}
+  ## Returns a new string with some or all matches of a pattern replaced by given replacement
+
+func replace*(pattern: cstring, self: RegExp, cb: proc (args: varargs[cstring]): cstring): cstring {.importcpp.}
+  ## Returns a new string with some or all matches of a pattern replaced by given callback function
+
+func split*(pattern: cstring; self: RegExp): seq[cstring] {.importjs: "(#.split(#) || [])".}
+  ## Divides a string into an ordered list of substrings and returns the array
+
+func match*(pattern: cstring; self: RegExp): seq[cstring] {.importjs: "(#.match(#) || [])".}
+  ## Returns an array of matches of a RegExp against given string
+
+func exec*(self: RegExp; pattern: cstring): seq[cstring] {.importjs: "(#.exec(#) || [])".}
+  ## Executes a search for a match in its string parameter.
+
+func toCstring*(self: RegExp): cstring {.importjs: "#.toString()".}
+  ## Returns a string representing the RegExp object.
+
+func `$`*(self: RegExp): string = $toCstring(self)
+
+func contains*(pattern: cstring; self: RegExp): bool =
+  ## Tests for a substring match in its string parameter.
+  runnableExamples:
+    let jsregex: RegExp = newRegExp(r"bc$", r"i")
+    assert jsregex in r"abc"
+    assert jsregex notin r"abcd"
+    assert "xabc".contains jsregex
+  {.emit: "`result` = `self`.test(`pattern`);".}
+
+func startsWith*(pattern: cstring; self: RegExp): bool =
+  ## Tests if string starts with given RegExp
+  runnableExamples:
+    let jsregex: RegExp = newRegExp(r"abc", r"i")
+    assert "abcd".startsWith jsregex
+  pattern.contains(newRegExp(("^" & $(self.source)).cstring, self.flags))
+
+func endsWith*(pattern: cstring; self: RegExp): bool =
+  ## Tests if string ends with given RegExp
+  runnableExamples:
+    let jsregex: RegExp = newRegExp(r"bcd", r"i")
+    assert "abcd".endsWith jsregex
+  pattern.contains(newRegExp(($(self.source) & "$").cstring, self.flags))
+
+
+runnableExamples:
+  let jsregex: RegExp = newRegExp(r"\s+", r"i")
+  jsregex.compile(r"\w+", r"i")
+  assert "nim javascript".contains jsregex
+  assert jsregex.exec(r"nim javascript") == @["nim".cstring]
+  assert jsregex.toCstring() == r"/\w+/i"
+  jsregex.compile(r"[0-9]", r"i")
+  assert "0123456789abcd".contains jsregex
+  assert $jsregex == "/[0-9]/i"
+  jsregex.compile(r"abc", r"i")
+  assert "abcd".startsWith jsregex
+  assert "dabc".endsWith jsregex
+  jsregex.compile(r"\d", r"i")
+  assert "do1ne".split(jsregex) == @["do".cstring, "ne".cstring]
+  jsregex.compile(r"[lw]", r"i")
+  assert "hello world".replace(jsregex,"X") == "heXlo world"
+  jsregex.compile(r"([a-z])\1*", r"g")
+  assert "abbcccdddd".replace(jsregex, proc (m: varargs[cstring]): cstring = ($m[0] & $(m.len)).cstring) == "a1b2c3d4"
+  let digitsRegex: RegExp = newRegExp(r"\d")
+  assert "foo".match(digitsRegex) == @[]
diff --git a/lib/lgpl.txt b/lib/lgpl.txt
deleted file mode 100755
index f6fa6c9e5..000000000
--- a/lib/lgpl.txt
+++ /dev/null
@@ -1,502 +0,0 @@
-		  GNU LESSER GENERAL PUBLIC LICENSE
-		       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
-		  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-  
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  Do not make any other change in
-these notices.
-
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-			    NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 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
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/lib/nimbase.h b/lib/nimbase.h
index c7b3e551d..cf0c8002b 100755..100644
--- a/lib/nimbase.h
+++ b/lib/nimbase.h
@@ -1,7 +1,7 @@
 /*
 
-            Nimrod's Runtime Library
-        (c) Copyright 2010 Andreas Rumpf
+            Nim's Runtime Library
+        (c) Copyright 2015 Andreas Rumpf
 
     See the file "copying.txt", included in this
     distribution, for details about the copyright.
@@ -10,28 +10,85 @@
 /* compiler symbols:
 __BORLANDC__
 _MSC_VER
-__WATCOMC__
-__LCC__
 __GNUC__
-__DMC__
-__POCC__
 __TINYC__
+__clang__
+__AVR__
+__arm__
+__EMSCRIPTEN__
 */
 
 
 #ifndef NIMBASE_H
 #define NIMBASE_H
 
-#if !defined(__TINYC__)
-#  include  <math.h>
+/*------------ declaring a custom attribute to support using LLVM's Address Sanitizer ------------ */
+
+/*
+   This definition exists to provide support for using the LLVM ASAN (Address SANitizer) tooling with Nim. This
+   should only be used to mark implementations of the GC system that raise false flags with the ASAN tooling, or
+   for functions that are hot and need to be disabled for performance reasons. Based on the official ASAN
+   documentation, both the clang and gcc compilers are supported. In addition to that, a check is performed to
+   verify that the necessary attribute is supported by the compiler.
+
+   To flag a proc as ignored, append the following code pragma to the proc declaration:
+      {.codegenDecl: "CLANG_NO_SANITIZE_ADDRESS $# $#$#".}
+
+   For further information, please refer to the official documentation:
+     https://github.com/google/sanitizers/wiki/AddressSanitizer
+ */
+#define CLANG_NO_SANITIZE_ADDRESS
+#if defined(__clang__)
+#  if __has_attribute(no_sanitize_address)
+#    undef CLANG_NO_SANITIZE_ADDRESS
+#    define CLANG_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#  endif
+#endif
+
+
+/* ------------ ignore typical warnings in Nim-generated files ------------- */
+#if defined(__GNUC__) || defined(__clang__)
+#  pragma GCC diagnostic ignored "-Wpragmas"
+#  pragma GCC diagnostic ignored "-Wwritable-strings"
+#  pragma GCC diagnostic ignored "-Winvalid-noreturn"
+#  pragma GCC diagnostic ignored "-Wformat"
+#  pragma GCC diagnostic ignored "-Wlogical-not-parentheses"
+#  pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
+#  pragma GCC diagnostic ignored "-Wshadow"
+#  pragma GCC diagnostic ignored "-Wunused-function"
+#  pragma GCC diagnostic ignored "-Wunused-variable"
+#  pragma GCC diagnostic ignored "-Winvalid-offsetof"
+#  pragma GCC diagnostic ignored "-Wtautological-compare"
+#  pragma GCC diagnostic ignored "-Wswitch-bool"
+#  pragma GCC diagnostic ignored "-Wmacro-redefined"
+#  pragma GCC diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+#  pragma GCC diagnostic ignored "-Wpointer-bool-conversion"
+#  pragma GCC diagnostic ignored "-Wconstant-conversion"
+#endif
+
+#if defined(_MSC_VER)
+#  pragma warning(disable: 4005 4100 4101 4189 4191 4200 4244 4293 4296 4309)
+#  pragma warning(disable: 4310 4365 4456 4477 4514 4574 4611 4668 4702 4706)
+#  pragma warning(disable: 4710 4711 4774 4800 4809 4820 4996 4090 4297)
+#endif
+/* ------------------------------------------------------------------------- */
+
+#if defined(__GNUC__) && !defined(__ZEPHYR__)
+/* Zephyr does some magic in it's headers that override the GCC stdlib. This breaks that. */
+#  define _GNU_SOURCE 1
+#endif
+
+#if defined(__TINYC__)
+/*#  define __GNUC__ 3
+#  define GCC_MAJOR 4
+#  define __GNUC_MINOR__ 4
+#  define __GNUC_PATCHLEVEL__ 5 */
+#  define __DECLSPEC_SUPPORTED 1
 #endif
 
 /* calling convention mess ----------------------------------------------- */
-#if defined(__GNUC__) || defined(__LCC__) || defined(__POCC__) \
-                      || defined(__TINYC__)
+#if defined(__GNUC__) || defined(__TINYC__)
   /* these should support C99's inline */
-  /* the test for __POCC__ has to come before the test for _MSC_VER,
-     because PellesC defines _MSC_VER too. This is brain-dead. */
 #  define N_INLINE(rettype, name) inline rettype name
 #elif defined(__BORLANDC__) || defined(_MSC_VER)
 /* Borland's compiler is really STRANGE here; note that the __fastcall
@@ -39,77 +96,131 @@ __TINYC__
    the return type, so we do not handle this mess in the code generator
    but rather here. */
 #  define N_INLINE(rettype, name) __inline rettype name
-#elif defined(__DMC__)
-#  define N_INLINE(rettype, name) inline rettype name
-#elif defined(__WATCOMC__)
-#  define N_INLINE(rettype, name) __inline rettype name
 #else /* others are less picky: */
 #  define N_INLINE(rettype, name) rettype __inline name
 #endif
 
-#if defined(__POCC__) || defined(_MSC_VER)
-#  define HAVE_LRINT 1
-#endif
+#define N_INLINE_PTR(rettype, name) rettype (*name)
 
-#if defined(__POCC__)
-#  define NIM_CONST /* PCC is really picky with const modifiers */
-#  undef _MSC_VER /* Yeah, right PCC defines _MSC_VER even if it is
-                     not that compatible. Well done. */
-#elif defined(__cplusplus)
+#if defined(__cplusplus)
 #  define NIM_CONST /* C++ is picky with const modifiers */
 #else
 #  define NIM_CONST  const
 #endif
 
-#define NIM_THREADVAR __thread
+/*
+  NIM_THREADVAR declaration based on
+  http://stackoverflow.com/questions/18298280/how-to-declare-a-variable-as-thread-local-portably
+*/
+#if defined _WIN32
+#  if defined _MSC_VER || defined __BORLANDC__
+#    define NIM_THREADVAR __declspec(thread)
+#  else
+#    define NIM_THREADVAR __thread
+#  endif
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
+#  define NIM_THREADVAR _Thread_local
+#elif defined _WIN32 && ( \
+       defined _MSC_VER || \
+       defined __ICL || \
+       defined __BORLANDC__ )
+#  define NIM_THREADVAR __declspec(thread)
+#elif defined(__TINYC__) || defined(__GENODE__)
+#  define NIM_THREADVAR
+/* note that ICC (linux) and Clang are covered by __GNUC__ */
+#elif defined __GNUC__ || \
+       defined __SUNPRO_C || \
+       defined __xlC__
+#  define NIM_THREADVAR __thread
+#else
+#  error "Cannot define NIM_THREADVAR"
+#endif
+
+#if defined(__cplusplus)
+  #define NIM_THREAD_LOCAL thread_local
+#endif
 
 /* --------------- how int64 constants should be declared: ----------- */
-#if defined(__GNUC__) || defined(__LCC__) || \
-    defined(__POCC__) || defined(__DMC__)
+#if defined(__GNUC__) || defined(_MSC_VER)
 #  define IL64(x) x##LL
 #else /* works only without LL */
-#  define IL64(x) x
+#  define IL64(x) ((NI64)x)
 #endif
 
 /* ---------------- casting without correct aliasing rules ----------- */
 
-#if defined(__GNUCC__)
+#if defined(__GNUC__)
 #  define NIM_CAST(type, ptr) (((union{type __x__;}*)(ptr))->__x__)
 #else
 #  define NIM_CAST(type, ptr) ((type)(ptr))
 #endif
 
+
 /* ------------------------------------------------------------------- */
+#ifdef  __cplusplus
+#  define NIM_EXTERNC extern "C"
+#else
+#  define NIM_EXTERNC
+#endif
 
 #if defined(WIN32) || defined(_WIN32) /* only Windows has this mess... */
+#  define N_LIB_PRIVATE
 #  define N_CDECL(rettype, name) rettype __cdecl name
 #  define N_STDCALL(rettype, name) rettype __stdcall name
 #  define N_SYSCALL(rettype, name) rettype __syscall name
 #  define N_FASTCALL(rettype, name) rettype __fastcall name
-#  define N_SAFECALL(rettype, name) rettype __safecall name
+#  define N_THISCALL(rettype, name) rettype __thiscall name
+#  define N_SAFECALL(rettype, name) rettype __stdcall name
 /* function pointers with calling convention: */
 #  define N_CDECL_PTR(rettype, name) rettype (__cdecl *name)
 #  define N_STDCALL_PTR(rettype, name) rettype (__stdcall *name)
 #  define N_SYSCALL_PTR(rettype, name) rettype (__syscall *name)
 #  define N_FASTCALL_PTR(rettype, name) rettype (__fastcall *name)
-#  define N_SAFECALL_PTR(rettype, name) rettype (__safecall *name)
+#  define N_THISCALL_PTR(rettype, name) rettype (__thiscall *name)
+#  define N_SAFECALL_PTR(rettype, name) rettype (__stdcall *name)
 
-#  define N_LIB_EXPORT  extern __declspec(dllexport)
+#  ifdef __EMSCRIPTEN__
+#    define N_LIB_EXPORT  NIM_EXTERNC __declspec(dllexport) __attribute__((used))
+#    define N_LIB_EXPORT_VAR  __declspec(dllexport) __attribute__((used))
+#  else
+#    define N_LIB_EXPORT  NIM_EXTERNC __declspec(dllexport)
+#    define N_LIB_EXPORT_VAR  __declspec(dllexport)
+#  endif
 #  define N_LIB_IMPORT  extern __declspec(dllimport)
 #else
-#  define N_CDECL(rettype, name) rettype name
-#  define N_STDCALL(rettype, name) rettype name
-#  define N_SYSCALL(rettype, name) rettype name
-#  define N_FASTCALL(rettype, name) rettype name
-#  define N_SAFECALL(rettype, name) rettype name
-/* function pointers with calling convention: */
-#  define N_CDECL_PTR(rettype, name) rettype (*name)
-#  define N_STDCALL_PTR(rettype, name) rettype (*name)
-#  define N_SYSCALL_PTR(rettype, name) rettype (*name)
-#  define N_FASTCALL_PTR(rettype, name) rettype (*name)
-#  define N_SAFECALL_PTR(rettype, name) rettype (*name)
-
-#  define N_LIB_EXPORT  extern
+#  define N_LIB_PRIVATE __attribute__((visibility("hidden")))
+#  if defined(__GNUC__)
+#    define N_CDECL(rettype, name) rettype name
+#    define N_STDCALL(rettype, name) rettype name
+#    define N_SYSCALL(rettype, name) rettype name
+#    define N_FASTCALL(rettype, name) __attribute__((fastcall)) rettype name
+#    define N_SAFECALL(rettype, name) rettype name
+/*   function pointers with calling convention: */
+#    define N_CDECL_PTR(rettype, name) rettype (*name)
+#    define N_STDCALL_PTR(rettype, name) rettype (*name)
+#    define N_SYSCALL_PTR(rettype, name) rettype (*name)
+#    define N_FASTCALL_PTR(rettype, name) __attribute__((fastcall)) rettype (*name)
+#    define N_SAFECALL_PTR(rettype, name) rettype (*name)
+#  else
+#    define N_CDECL(rettype, name) rettype name
+#    define N_STDCALL(rettype, name) rettype name
+#    define N_SYSCALL(rettype, name) rettype name
+#    define N_FASTCALL(rettype, name) rettype name
+#    define N_SAFECALL(rettype, name) rettype name
+/*   function pointers with calling convention: */
+#    define N_CDECL_PTR(rettype, name) rettype (*name)
+#    define N_STDCALL_PTR(rettype, name) rettype (*name)
+#    define N_SYSCALL_PTR(rettype, name) rettype (*name)
+#    define N_FASTCALL_PTR(rettype, name) rettype (*name)
+#    define N_SAFECALL_PTR(rettype, name) rettype (*name)
+#  endif
+#  ifdef __EMSCRIPTEN__
+#    define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default"), used))
+#    define N_LIB_EXPORT_VAR  __attribute__((visibility("default"), used))
+#  else
+#    define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default")))
+#    define N_LIB_EXPORT_VAR  __attribute__((visibility("default")))
+#  endif
 #  define N_LIB_IMPORT  extern
 #endif
 
@@ -117,13 +228,8 @@ __TINYC__
 /* specify no calling convention */
 #define N_NOCONV_PTR(rettype, name) rettype (*name)
 
-#define N_CLOSURE(rettype, name) rettype name
-/* specify no calling convention */
-#define N_CLOSURE_PTR(rettype, name) rettype (*name)
-
-
 #if defined(__GNUC__) || defined(__ICC__)
-#  define N_NOINLINE(rettype, name) rettype __attribute__((noinline)) name
+#  define N_NOINLINE(rettype, name) rettype __attribute__((__noinline__)) name
 #elif defined(_MSC_VER)
 #  define N_NOINLINE(rettype, name) __declspec(noinline) rettype name
 #else
@@ -132,194 +238,221 @@ __TINYC__
 
 #define N_NOINLINE_PTR(rettype, name) rettype (*name)
 
-#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
-    defined(__POCC__) || defined(_MSC_VER)
+#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(WIN32) || defined(_WIN32)
 /* these compilers have a fastcall so use it: */
-#  define N_NIMCALL(rettype, name) rettype __fastcall name
-#  define N_NIMCALL_PTR(rettype, name) rettype (__fastcall *name)
+#  ifdef __TINYC__
+#    define N_NIMCALL(rettype, name) rettype __attribute((__fastcall)) name
+#    define N_NIMCALL_PTR(rettype, name) rettype (__attribute((__fastcall)) *name)
+#    define N_RAW_NIMCALL __attribute((__fastcall))
+#  else
+#    define N_NIMCALL(rettype, name) rettype __fastcall name
+#    define N_NIMCALL_PTR(rettype, name) rettype (__fastcall *name)
+#    define N_RAW_NIMCALL __fastcall
+#  endif
 #else
 #  define N_NIMCALL(rettype, name) rettype name /* no modifier */
 #  define N_NIMCALL_PTR(rettype, name) rettype (*name)
+#  define N_RAW_NIMCALL
 #endif
 
-/* ----------------------------------------------------------------------- */
-
-/* from float_cast.h: */
+#define N_CLOSURE(rettype, name) N_NIMCALL(rettype, name)
+#define N_CLOSURE_PTR(rettype, name) N_NIMCALL_PTR(rettype, name)
 
-/*
-** Copyright (C) 2001 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
-**
-** Permission to use, copy, modify, distribute, and sell this file for any
-** purpose is hereby granted without fee, provided that the above copyright
-** and this permission notice appear in all copies.  No representations are
-** made about the suitability of this software for any purpose.  It is
-** provided "as is" without express or implied warranty.
-*/
+/* ----------------------------------------------------------------------- */
 
-/* Version 1.1 */
-
-
-/*============================================================================
-**  On Intel Pentium processors (especially PIII and probably P4), converting
-**  from float to int is very slow. To meet the C specs, the code produced by
-**  most C compilers targeting Pentium needs to change the FPU rounding mode
-**  before the float to int conversion is performed.
-**
-**  Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
-**  is this flushing of the pipeline which is so slow.
-**
-**  Fortunately the ISO C99 specifications define the functions lrint, lrintf,
-**  llrint and llrintf which fix this problem as a side effect.
-**
-**  On Unix-like systems, the configure process should have detected the
-**  presence of these functions. If they weren't found we have to replace them
-**  here with a standard C cast.
-*/
+#define COMMA ,
 
-/*
-**	The C99 prototypes for lrint and lrintf are as follows:
-**
-**		long int lrintf (float x);
-**		long int lrint  (double x);
-*/
+#include <limits.h>
+#include <stddef.h>
 
-#if defined(__LCC__) || (defined(__GNUC__) && defined(WIN32))
-/* Linux' GCC does not seem to have these. Why? */
-#  define HAVE_LRINT
-#  define HAVE_LRINTF
+// define NIM_STATIC_ASSERT
+// example use case: CT sizeof for importc types verification
+// where we have {.completeStruct.} (or lack of {.incompleteStruct.})
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
+#define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
+#elif defined(__cplusplus)
+#define NIM_STATIC_ASSERT(x, msg) static_assert((x), msg)
+#else
+#define _NIM_STATIC_ASSERT_FINAL(x, append_name) typedef int NIM_STATIC_ASSERT_AUX ## append_name[(x) ? 1 : -1];
+#define _NIM_STATIC_ASSERT_STAGE_3(x, line)      _NIM_STATIC_ASSERT_FINAL(x, _AT_LINE_##line)
+#define _NIM_STATIC_ASSERT_STAGE_2(x, line)      _NIM_STATIC_ASSERT_STAGE_3(x, line)
+#define NIM_STATIC_ASSERT(x, msg)                _NIM_STATIC_ASSERT_STAGE_2(x,__LINE__)
+// On failure, your C compiler will say something like:
+//   "error: 'NIM_STATIC_ASSERT_AUX_AT_LINE_XXX' declared as an array with a negative size"
+// Adding the line number helps to avoid redefinitions which are not allowed in
+// old GCC versions, however the order of evaluation for __LINE__ is a little tricky,
+// hence all the helper macros. See https://stackoverflow.com/a/3385694 for more info.
 #endif
 
-#if defined(HAVE_LRINT) && defined(HAVE_LRINTF)
-
-/*  These defines enable functionality introduced with the 1999 ISO C
-**  standard. They must be defined before the inclusion of math.h to
-**  engage them. If optimisation is enabled, these functions will be
-**  inlined. With optimisation switched off, you have to link in the
-**  maths library using -lm.
-*/
-
-#  define  _ISOC9X_SOURCE  1
-#  define  _ISOC99_SOURCE  1
-#  define  __USE_ISOC9X  1
-#  define  __USE_ISOC99  1
+/* C99 compiler? */
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
+#  define HAVE_STDINT_H
+#endif
 
-#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
-   && !defined(__BORLANDC__) && !defined(__POCC__)
+/* Known compiler with stdint.h that doesn't fit the general pattern? */
+#if defined(__AVR__) || (defined(__cplusplus) && (__cplusplus < 201103))
+#  define HAVE_STDINT_H
+#endif
 
-/*  Win32 doesn't seem to have these functions.
-**  Therefore implement inline versions of these functions here.
-*/
-static N_INLINE(long int, lrint)(double flt) {
-  long int intgr;
-  _asm {
-    fld flt
-    fistp intgr
-  };
-  return intgr;
-}
+#if (!defined(HAVE_STDINT_H) && defined(__cplusplus) && (__cplusplus >= 201103))
+#  define HAVE_CSTDINT
+#endif
 
-static N_INLINE(long int, lrintf)(float flt) {
-  long int intgr;
-  _asm {
-    fld flt
-    fistp intgr
-  };
-  return intgr;
-}
 
+/* wrap all Nim typedefs into namespace Nim */
+#ifdef USE_NIM_NAMESPACE
+#ifdef HAVE_CSTDINT
+#include <cstdint>
 #else
-
-#  ifndef lrint
-#    define  lrint(dbl)   ((long int)(dbl))
-#  endif
-#  ifndef lrintf
-#    define  lrintf(flt)  ((long int)(flt))
-#  endif
-
-#endif /* defined(HAVE_LRINT) && defined(HAVE_LRINTF) */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <stddef.h>
-#include <signal.h>
-#include <setjmp.h>
-
-/*
-#ifndef INF
-static unsigned long nimInf[2]={0xffffffff, 0x7fffffff};
-#  define INF (*(double*) nimInf)
-#endif */
-
-/* C99 compiler? */
-#if (defined(__STD_VERSION__) && (__STD_VERSION__ >= 199901))
-#  define HAVE_STDINT_H
+#include <stdint.h>
+#endif
+namespace USE_NIM_NAMESPACE {
 #endif
 
-#if defined(__LCC__) || defined(__DMC__) || defined(__POCC__)
-#  define HAVE_STDINT_H
+// preexisting check, seems paranoid, maybe remove
+#if defined(NIM_TRUE) || defined(NIM_FALSE) || defined(NIM_BOOL)
+#error "nim reserved preprocessor macros clash"
 #endif
 
 /* bool types (C++ has it): */
 #ifdef __cplusplus
-#  ifndef NIM_TRUE
-#    define NIM_TRUE true
-#  endif
-#  ifndef NIM_FALSE
-#    define NIM_FALSE false
-#  endif
-#  define NIM_BOOL bool
+#define NIM_BOOL bool
+#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
+// see #13798: to avoid conflicts for code emitting `#include <stdbool.h>`
+#define NIM_BOOL _Bool
 #else
-#  ifdef bool
-#    define NIM_BOOL bool
-#  else
-  typedef unsigned char NIM_BOOL;
-#  endif
-#  ifndef NIM_TRUE
-#    define NIM_TRUE ((NIM_BOOL) 1)
-#  endif
-#  ifndef NIM_FALSE
-#    define NIM_FALSE ((NIM_BOOL) 0)
-#  endif
+typedef unsigned char NIM_BOOL; // best effort
 #endif
 
-#define NIM_NIL ((void*)0) /* C's NULL is fucked up in some C compilers, so
+NIM_STATIC_ASSERT(sizeof(NIM_BOOL) == 1, ""); // check whether really needed
+NIM_STATIC_ASSERT(CHAR_BIT == 8, "");
+  // fail fast for (rare) environments where this doesn't hold, as some implicit
+  // assumptions would need revisiting (e.g. `uint8` or https://github.com/nim-lang/Nim/pull/18505)
+
+#define NIM_TRUE true
+#define NIM_FALSE false
+
+#ifdef __cplusplus
+#  if __cplusplus >= 201103L
+#    /* nullptr is more type safe (less implicit conversions than 0) */
+#    define NIM_NIL nullptr
+#  else
+#    // both `((void*)0)` and `NULL` would cause codegen to emit
+#    // error: assigning to 'Foo *' from incompatible type 'void *'
+#    // but codegen could be fixed if need. See also potential caveat regarding
+#    // NULL.
+#    // However, `0` causes other issues, see #13798
+#    define NIM_NIL 0
+#  endif
+#else
+#  include <stdbool.h>
+#  define NIM_NIL ((void*)0) /* C's NULL is fucked up in some C compilers, so
                               the generated code does not rely on it anymore */
+#endif
 
-#if defined(__BORLANDC__) || defined(__DMC__) \
-   || defined(__WATCOMC__) || defined(_MSC_VER)
+#if defined(__BORLANDC__) || defined(_MSC_VER)
 typedef signed char NI8;
 typedef signed short int NI16;
 typedef signed int NI32;
+typedef __int64 NI64;
 /* XXX: Float128? */
 typedef unsigned char NU8;
 typedef unsigned short int NU16;
-typedef unsigned __int64 NU64;
-typedef __int64 NI64;
 typedef unsigned int NU32;
+typedef unsigned __int64 NU64;
 #elif defined(HAVE_STDINT_H)
+#ifndef USE_NIM_NAMESPACE
 #  include <stdint.h>
+#endif
 typedef int8_t NI8;
 typedef int16_t NI16;
 typedef int32_t NI32;
 typedef int64_t NI64;
-typedef uint64_t NU64;
 typedef uint8_t NU8;
 typedef uint16_t NU16;
 typedef uint32_t NU32;
+typedef uint64_t NU64;
+#elif defined(HAVE_CSTDINT)
+#ifndef USE_NIM_NAMESPACE
+#  include <cstdint>
+#endif
+typedef std::int8_t NI8;
+typedef std::int16_t NI16;
+typedef std::int32_t NI32;
+typedef std::int64_t NI64;
+typedef std::uint8_t NU8;
+typedef std::uint16_t NU16;
+typedef std::uint32_t NU32;
+typedef std::uint64_t NU64;
+#else
+/* Unknown compiler/version, do our best */
+#ifdef __INT8_TYPE__
+typedef __INT8_TYPE__ NI8;
 #else
 typedef signed char NI8;
+#endif
+#ifdef __INT16_TYPE__
+typedef __INT16_TYPE__ NI16;
+#else
 typedef signed short int NI16;
+#endif
+#ifdef __INT32_TYPE__
+typedef __INT32_TYPE__ NI32;
+#else
 typedef signed int NI32;
+#endif
+#ifdef __INT64_TYPE__
+typedef __INT64_TYPE__ NI64;
+#else
+typedef long long int NI64;
+#endif
 /* XXX: Float128? */
+#ifdef __UINT8_TYPE__
+typedef __UINT8_TYPE__ NU8;
+#else
 typedef unsigned char NU8;
+#endif
+#ifdef __UINT16_TYPE__
+typedef __UINT16_TYPE__ NU16;
+#else
 typedef unsigned short int NU16;
-typedef unsigned long long int NU64;
-typedef long long int NI64;
+#endif
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ NU32;
+#else
 typedef unsigned int NU32;
 #endif
+#ifdef __UINT64_TYPE__
+typedef __UINT64_TYPE__ NU64;
+#else
+typedef unsigned long long int NU64;
+#endif
+#endif
+
+#ifdef NIM_INTBITS
+#  if NIM_INTBITS == 64
+typedef NI64 NI;
+typedef NU64 NU;
+#  elif NIM_INTBITS == 32
+typedef NI32 NI;
+typedef NU32 NU;
+#  elif NIM_INTBITS == 16
+typedef NI16 NI;
+typedef NU16 NU;
+#  elif NIM_INTBITS == 8
+typedef NI8 NI;
+typedef NU8 NU;
+#  else
+#    error "invalid bit width for int"
+#  endif
+#endif
+
+// for now there isn't an easy way for C code to reach the program result
+// when hot code reloading is ON - users will have to:
+// load the nimhcr.dll, get the hcrGetGlobal proc from there and use it
+#ifndef NIM_HOT_CODE_RELOADING
+extern NI nim_program_result;
+#endif
 
 typedef float NF32;
 typedef double NF64;
@@ -334,31 +467,18 @@ typedef char* NCSTRING;
 #  define NIM_IMAN 0
 #endif
 
-static N_INLINE(NI32, float64ToInt32)(double val) {
-  val = val + 68719476736.0*1.5;
-  /* 2^36 * 1.5,  (52-_shiftamt=36) uses limited precisicion to floor */
-  return ((NI32*)&val)[NIM_IMAN] >> 16; /* 16.16 fixed point representation */
-}
-
-static N_INLINE(NI32, float32ToInt32)(float val) {
-  return float64ToInt32((double)val);
-}
-
-#define float64ToInt64(x) ((NI64) (x))
-
-#define zeroMem(a, size) memset(a, 0, size)
-#define equalMem(a, b, size) (memcmp(a, b, size) == 0)
+#define NIM_STRLIT_FLAG ((NU)(1) << ((NIM_INTBITS) - 2)) /* This has to be the same as system.strlitFlag! */
 
 #define STRING_LITERAL(name, str, length) \
-  static const struct {                   \
-    TGenericSeq Sup;                      \
-    NIM_CHAR data[length + 1];            \
-  } name = {{length, length}, str}
-
-typedef struct TStringDesc* string;
-
-/* declared size of a sequence: */
-#if defined(__GNUC__)
+   static const struct {                   \
+     TGenericSeq Sup;                      \
+     NIM_CHAR data[(length) + 1];          \
+  } name = {{length, (NI) ((NU)length | NIM_STRLIT_FLAG)}, str}
+
+/* declared size of a sequence/variable length array: */
+#if defined(__cplusplus) && defined(__clang__)
+#  define SEQ_DECL_SIZE 1
+#elif defined(__GNUC__) || defined(_MSC_VER)
 #  define SEQ_DECL_SIZE /* empty is correct! */
 #else
 #  define SEQ_DECL_SIZE 1000000
@@ -367,18 +487,15 @@ typedef struct TStringDesc* string;
 #define ALLOC_0(size)  calloc(1, size)
 #define DL_ALLOC_0(size) dlcalloc(1, size)
 
-#define GenericSeqSize sizeof(TGenericSeq)
 #define paramCount() cmdCount
 
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__i386__)
-#  ifndef NAN
-static unsigned long nimNaN[2]={0xffffffff, 0x7fffffff};
-#    define NAN (*(double*) nimNaN)
-#  endif
-#endif
-
+// NAN definition copied from math.h included in the Windows SDK version 10.0.14393.0
 #ifndef NAN
-#  define NAN (0.0 / 0.0)
+#  ifndef _HUGE_ENUF
+#    define _HUGE_ENUF  1e+300  // _HUGE_ENUF*_HUGE_ENUF must overflow
+#  endif
+#  define NAN_INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
+#  define NAN ((float)(NAN_INFINITY * 0.0F))
 #endif
 
 #ifndef INF
@@ -386,42 +503,107 @@ static unsigned long nimNaN[2]={0xffffffff, 0x7fffffff};
 #    define INF INFINITY
 #  elif defined(HUGE_VAL)
 #    define INF  HUGE_VAL
+#  elif defined(_MSC_VER)
+#    include <float.h>
+#    define INF (DBL_MAX+DBL_MAX)
 #  else
 #    define INF (1.0 / 0.0)
 #  endif
 #endif
-/*
-typedef struct TSafePoint TSafePoint;
-struct TSafePoint {
-  NI exc;
-  NCSTRING excname;
-  NCSTRING msg;
-  TSafePoint* prev;
-  jmp_buf context;
-}; */
-
-typedef struct TFrame TFrame;
-struct TFrame {
+
+typedef struct TFrame_ TFrame;
+struct TFrame_ {
   TFrame* prev;
   NCSTRING procname;
   NI line;
   NCSTRING filename;
-  NI len;
+  NI16 len;
+  NI16 calldepth;
+  NI frameMsgLen;
 };
 
-extern TFrame* framePtr;
-/*extern TSafePoint* excHandler; */
+#define NIM_POSIX_INIT  __attribute__((constructor))
 
-#if defined(__cplusplus)
-struct NimException {
-  TSafePoint sp;
-
-  NimException(NI aExc, NCSTRING aExcname, NCSTRING aMsg) {
-    sp.exc = aExc; sp.excname = aExcname; sp.msg = aMsg;
-    sp.prev = excHandler;
-    excHandler = &sp;
-  }
-};
+#ifdef __GNUC__
+#  define NIM_LIKELY(x) __builtin_expect(x, 1)
+#  define NIM_UNLIKELY(x) __builtin_expect(x, 0)
+/* We need the following for the posix wrapper. In particular it will give us
+   POSIX_SPAWN_USEVFORK: */
+#  ifndef _GNU_SOURCE
+#    define _GNU_SOURCE
+#  endif
+#else
+#  define NIM_LIKELY(x) (x)
+#  define NIM_UNLIKELY(x) (x)
+#endif
+
+#if 0 // defined(__GNUC__) || defined(__clang__)
+// not needed anymore because the stack marking cares about
+// interior pointers now
+static inline void GCGuard (void *ptr) { asm volatile ("" :: "X" (ptr)); }
+#  define GC_GUARD __attribute__ ((cleanup(GCGuard)))
+#else
+#  define GC_GUARD
+#endif
+
+// Test to see if Nim and the C compiler agree on the size of a pointer.
+NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "Pointer size mismatch between Nim and C/C++ backend. You probably need to setup the backend compiler for target CPU.");
+
+#ifdef USE_NIM_NAMESPACE
+}
+#endif
+
+#if defined(_MSC_VER)
+#  define NIM_ALIGN(x)  __declspec(align(x))
+#  define NIM_ALIGNOF(x) __alignof(x)
+#else
+#  define NIM_ALIGN(x)  __attribute__((aligned(x)))
+#  define NIM_ALIGNOF(x) __alignof__(x)
 #endif
 
+/* ---------------- platform specific includes ----------------------- */
+
+/* VxWorks related includes */
+#if defined(__VXWORKS__)
+#  include <sys/types.h>
+#  include <types/vxWind.h>
+#  include <tool/gnu/toolMacros.h>
+#elif defined(__FreeBSD__)
+#  include <sys/types.h>
+#endif
+
+/* these exist to make the codegen logic simpler */
+#define nimModInt(a, b, res) (((*res) = (a) % (b)), 0)
+#define nimModInt64(a, b, res) (((*res) = (a) % (b)), 0)
+
+#if (!defined(_MSC_VER) || defined(__clang__)) && !defined(NIM_EmulateOverflowChecks)
+  /* these exist because we cannot have .compilerProcs that are importc'ed
+    by a different name */
+
+  #define nimAddInt64(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res)
+  #define nimSubInt64(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res)
+  #define nimMulInt64(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res)
+
+  #if NIM_INTBITS == 32
+    #if defined(__arm__) && defined(__GNUC__)
+      /* arm-none-eabi-gcc targets defines int32_t as long int */
+      #define nimAddInt(a, b, res) __builtin_saddl_overflow(a, b, res)
+      #define nimSubInt(a, b, res) __builtin_ssubl_overflow(a, b, res)
+      #define nimMulInt(a, b, res) __builtin_smull_overflow(a, b, res)
+    #else
+      #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res)
+      #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
+      #define nimMulInt(a, b, res) __builtin_smul_overflow(a, b, res)
+    #endif
+  #else
+    /* map it to the 'long long' variant */
+    #define nimAddInt(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res)
+    #define nimSubInt(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res)
+    #define nimMulInt(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res)
+  #endif
 #endif
+
+#define NIM_NOALIAS __restrict
+/* __restrict is said to work for all the C(++) compilers out there that we support */
+
+#endif /* NIMBASE_H */
diff --git a/lib/nimhcr.nim b/lib/nimhcr.nim
new file mode 100644
index 000000000..e87bb2413
--- /dev/null
+++ b/lib/nimhcr.nim
@@ -0,0 +1,671 @@
+discard """
+batchable: false
+"""
+
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# This is the Nim hot code reloading run-time for the native targets.
+#
+# This minimal dynamic library is not subject to reloading when the
+# `hotCodeReloading` build mode is enabled. It's responsible for providing
+# a permanent memory location for all globals and procs within a program
+# and orchestrating the reloading. For globals, this is easily achieved
+# by storing them on the heap. For procs, we produce on the fly simple
+# trampolines that can be dynamically overwritten to jump to a different
+# target. In the host program, all globals and procs are first registered
+# here with `hcrRegisterGlobal` and `hcrRegisterProc` and then the
+# returned permanent locations are used in every reference to these symbols
+# onwards.
+#
+# Detailed description:
+#
+# When code is compiled with the hotCodeReloading option for native targets
+# a couple of things happen for all modules in a project:
+# - the useNimRtl option is forced (including when building the HCR runtime too)
+# - all modules of a target get built into separate shared libraries
+#   - the smallest granularity of reloads is modules
+#   - for each .c (or .cpp) in the corresponding nimcache folder of the project
+#     a shared object is built with the name of the source file + DLL extension
+#   - only the main module produces whatever the original project type intends
+#     (again in nimcache) and is then copied to its original destination
+#   - linking is done in parallel - just like compilation
+# - function calls to functions from the same project go through function pointers:
+#   - with a few exceptions - see the nonReloadable pragma
+#   - the forward declarations of the original functions become function
+#     pointers as static globals with the same names
+#   - the original function definitions get suffixed with <name>_actual
+#   - the function pointers get initialized with the address of the corresponding
+#     function in the DatInit of their module through a call to either hcrRegisterProc
+#     or hcrGetProc. When being registered, the <name>_actual address is passed to
+#     hcrRegisterProc and a permanent location is returned and assigned to the pointer.
+#     This way the implementation (<name>_actual) can change but the address for it
+#     will be the same - this works by just updating a jump instruction (trampoline).
+#     For functions from other modules hcrGetProc is used (after they are registered).
+# - globals are initialized only once and their state is preserved
+#   - including locals with the {.global.} pragma
+#   - their definitions are changed into pointer definitions which are initialized
+#     in the DatInit() of their module with calls to hcrRegisterGlobal (supplying the
+#     size of the type that this HCR runtime should allocate) and a bool is returned
+#     which when true triggers the initialization code for the global (only once).
+#     Globals from other modules: a global pointer coupled with a hcrGetGlobal call.
+#   - globals which have already been initialized cannot have their values changed
+#     by changing their initialization - use a handler or some other mechanism
+#   - new globals can be introduced when reloading
+# - top-level code (global scope) is executed only once - at the first module load
+# - the runtime knows every symbol's module owner (globals and procs)
+# - both the RTL and HCR shared libraries need to be near the program for execution
+#   - same folder, in the PATH or LD_LIBRARY_PATH env var, etc (depending on OS)
+# - the main module is responsible for initializing the HCR runtime
+#   - the main module loads the RTL and HCR shared objects
+#   - after that a call to hcrInit() is done in the main module which triggers
+#     the loading of all modules the main one imports, and doing that for the
+#     dependencies of each module recursively. Basically a DFS traversal.
+#   - then initialization takes place with several passes over all modules:
+#     - HcrInit - initializes the pointers for HCR procs such as hcrRegisterProc
+#     - HcrCreateTypeInfos - creates globals which will be referenced in the next pass
+#     - DatInit - usual dat init + register/get procs and get globals
+#     - Init - it does the following multiplexed operations:
+#       - register globals (if already registered - then just retrieve pointer)
+#       - execute top level scope (only if loaded for the first time)
+#   - when modules are loaded the originally built shared libraries get copied in
+#     the same folder and the copies are loaded instead of the original files
+#   - a module import tree is built in the runtime (and maintained when reloading)
+# - hcrPerformCodeReload
+#   - named `performCodeReload`, requires the hotcodereloading module
+#   - explicitly called by the user - the current active callstack shouldn't contain
+#     any functions which are defined in modules that will be reloaded (or crash!).
+#     The reason is that old dynamic libraries get unloaded.
+#     Example:
+#       if A is the main module and it imports B, then only B is reloadable and only
+#       if when calling hcrPerformCodeReload there is no function defined in B in the
+#       current active callstack at the point of the call (it has to be done from A)
+#   - for reloading to take place the user has to have rebuilt parts of the application
+#     without changes affecting the main module in any way - it shouldn't be rebuilt.
+#   - to determine what needs to be reloaded the runtime starts traversing the import
+#     tree from the root and checks the timestamps of the loaded shared objects
+#   - modules that are no longer referenced are unloaded and cleaned up properly
+#   - symbols (procs/globals) that have been removed in the code are also cleaned up
+#     - so changing the init of a global does nothing, but removing it, reloading,
+#       and then re-introducing it with a new initializer works
+#   - new modules can be imported, and imports can also be reodereded/removed
+#   - hcrReloadNeeded() can be used to determine if any module needs reloading
+#     - named `hasAnyModuleChanged`, requires the hotcodereloading module
+# - code in the beforeCodeReload/afterCodeReload handlers is executed on each reload
+#   - require the hotcodereloading module
+#   - such handlers can be added and removed
+#   - before each reload all "beforeCodeReload" handlers are executed and after
+#     that all handlers (including "after") from the particular module are deleted
+#   - the order of execution is the same as the order of top-level code execution.
+#     Example: if A imports B which imports C, then all handlers in C will be executed
+#     first (from top to bottom) followed by all from B and lastly all from A
+#   - after the reload all "after" handlers are executed the same way as "before"
+#   - the handlers for a reloaded module are always removed when reloading and then
+#     registered when the top-level scope is executed (thanks to `executeOnReload`)
+#
+# TODO next:
+#
+# - implement the before/after handlers and hasModuleChanged for the javascript target
+# - ARM support for the trampolines
+# - investigate:
+#   - soon the system module might be importing other modules - the init order...?
+#     (revert https://github.com/nim-lang/Nim/pull/11971 when working on this)
+#   - rethink the closure iterators
+#     - ability to keep old versions of dynamic libraries alive
+#       - because of async server code
+#       - perhaps with refcounting of .dlls for unfinished closures
+#   - linking with static libs
+#     - all shared objects for each module will (probably) have to link to them
+#       - state in static libs gets duplicated
+#       - linking is slow and therefore iteration time suffers
+#         - have just a single .dll for all .nim files and bulk reload?
+#   - think about the compile/link/passc/passl/emit/injectStmt pragmas
+#     - if a passc pragma is introduced (either written or dragged in by a new
+#       import) the whole command line for compilation changes - for example:
+#         winlean.nim: {.passc: "-DWIN32_LEAN_AND_MEAN".}
+#   - play with plugins/dlls/lfIndirect/lfDynamicLib/lfExportLib - shouldn't add an extra '*'
+#   - everything thread-local related
+# - tests
+#   - add a new travis build matrix entry which builds everything with HCR enabled
+#     - currently building with useNimRtl is problematic - lots of problems...
+#     - how to supply the nimrtl/nimhcr shared objects to all test binaries...?
+#     - think about building to C++ instead of only to C - added type safety
+#   - run tests through valgrind and the sanitizers!
+#
+# TODO - nice to have cool stuff:
+#
+# - separate handling of global state for much faster reloading and manipulation
+#   - imagine sliders in an IDE for tweaking variables
+#   - perhaps using shared memory
+# - multi-dll projects - how everything can be reloaded..?
+#   - a single HCR instance shared across multiple .dlls
+#   - instead of having to call hcrPerformCodeReload from a function in each dll
+#     - which currently renders the main module of each dll not reloadable
+# - ability to check with the current callstack if a reload is "legal"
+#   - if it is in any function which is in a module about to be reloaded ==> error
+# - pragma annotations for files - to be excluded from dll shenanigans
+#   - for such file-global pragmas look at codeReordering or injectStmt
+#   - how would the initialization order be kept? messy...
+# - C code calling stable exportc interface of nim code (for bindings)
+#   - generate proxy functions with the stable names
+#     - in a non-reloadable part (the main binary) that call the function pointers
+#     - parameter passing/forwarding - how? use the same trampoline jumping?
+#     - extracting the dependencies for these stubs/proxies will be hard...
+# - changing memory layout of types - detecting this..?
+#   - implement with registerType() call to HCR runtime...?
+#     - and checking if a previously registered type matches
+#   - issue an error
+#     - or let the user handle this by transferring the state properly
+#       - perhaps in the before/afterCodeReload handlers
+# - implement executeOnReload for global vars too - not just statements (and document!)
+# - cleanup at shutdown - freeing all globals
+# - fallback mechanism if the program crashes (the program should detect crashes
+#   by itself using SEH/signals on Windows/Unix) - should be able to revert to
+#   previous versions of the .dlls by calling some function from HCR
+# - improve runtime performance - possibilities
+#   - implement a way for multiple .nim files to be bundled into the same dll
+#     and have all calls within that domain to use the "_actual" versions of
+#     procs so there are no indirections (or the ability to just bundle everything
+#     except for a few unreloadable modules into a single mega reloadable dll)
+#   - try to load the .dlls at specific addresses of memory (close to each other)
+#     allocated with execution flags - check this: https://github.com/fancycode/MemoryModule
+#
+# TODO - unimportant:
+#
+# - have a "bad call" trampoline that all no-longer-present functions are routed to call there
+#     - so the user gets some error msg if he calls a dangling pointer instead of a crash
+# - before/afterCodeReload and hasModuleChanged should be accessible only where appropriate
+# - nim_program_result is inaccessible in HCR mode from external C code (see nimbase.h)
+# - proper .json build file - but the format is different... multiple link commands...
+# - avoid registering globals on each loop when using an iterator in global scope
+#
+# TODO - REPL:
+# - proper way (as proposed by Zahary):
+#   - parse the input code and put everything in global scope except for
+#     statements with side effects only - those go in afterCodeReload blocks
+# - my very hacky idea: just append to a closure iterator the new statements
+#   followed by a yield statement. So far I can think of 2 problems:
+#   - import and some other code cannot be written inside of a proc -
+#     has to be parsed and extracted in the outer scope
+#   - when new variables are created they are actually locals to the closure
+#     so the struct for the closure state grows in memory, but it has already
+#     been allocated when the closure was created with the previous smaller size.
+#     That would lead to working with memory outside of the initially allocated
+#     block. Perhaps something can be done about this - some way of re-allocating
+#     the state and transferring the old...
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+when not defined(js) and (defined(hotcodereloading) or
+                          defined(createNimHcr) or
+                          defined(testNimHcr)):
+  const
+    dllExt = when defined(windows): "dll"
+             elif defined(macosx): "dylib"
+             else: "so"
+  type
+    HcrProcGetter* = proc (libHandle: pointer, procName: cstring): pointer {.nimcall.}
+    HcrGcMarkerProc = proc () {.nimcall, raises: [].}
+    HcrModuleInitializer* = proc () {.nimcall.}
+
+when defined(createNimHcr):
+  when system.appType != "lib":
+    {.error: "This file has to be compiled as a library!".}
+
+  import std/[os, tables, sets, times, strutils, reservedmem, dynlib]
+
+  template trace(args: varargs[untyped]) =
+    when defined(testNimHcr) or defined(traceHcr):
+      echo args
+
+  proc sanitize(arg: Time): string =
+    when defined(testNimHcr): return "<time>"
+    else: return $arg
+
+  proc sanitize(arg: string|cstring): string =
+    when defined(testNimHcr): return ($arg).splitFile.name.splitFile.name
+    else: return $arg
+
+  {.pragma: nimhcr, compilerproc, exportc, dynlib.}
+
+  # XXX these types are CPU specific and need ARM etc support
+  type
+    ShortJumpInstruction {.packed.} = object
+      opcode: byte
+      offset: int32
+
+    LongJumpInstruction {.packed.} = object
+      opcode1: byte
+      opcode2: byte
+      offset: int32
+      absoluteAddr: pointer
+
+  proc writeJump(jumpTableEntry: ptr LongJumpInstruction, targetFn: pointer) =
+    let
+      jumpFrom = jumpTableEntry.shift(sizeof(ShortJumpInstruction))
+      jumpDistance = distance(jumpFrom, targetFn)
+
+    if abs(jumpDistance) < 0x7fff0000:
+      let shortJump = cast[ptr ShortJumpInstruction](jumpTableEntry)
+      shortJump.opcode = 0xE9 # relative jump
+      shortJump.offset = int32(jumpDistance)
+    else:
+      jumpTableEntry.opcode1 = 0xff # indirect absolute jump
+      jumpTableEntry.opcode2 = 0x25
+      when hostCPU == "i386":
+        # on x86 we write the absolute address of the following pointer
+        jumpTableEntry.offset = cast[int32](addr jumpTableEntry.absoluteAddr)
+      else:
+        # on x64, we use a relative address for the same location
+        jumpTableEntry.offset = 0
+      jumpTableEntry.absoluteAddr = targetFn
+
+  if hostCPU == "arm":
+    const jumpSize = 8
+  elif hostCPU == "arm64":
+    const jumpSize = 16
+
+  const defaultJumpTableSize = case hostCPU
+                               of "i386": 50
+                               of "amd64": 500
+                               else: 50
+
+  let jumpTableSizeStr = getEnv("HOT_CODE_RELOADING_JUMP_TABLE_SIZE")
+  let jumpTableSize = if jumpTableSizeStr.len > 0: parseInt(jumpTableSizeStr)
+                      else: defaultJumpTableSize
+
+  # TODO: perhaps keep track of free slots due to removed procs using a free list
+  var jumpTable = ReservedMemSeq[LongJumpInstruction].init(
+    memStart = cast[pointer](0x10000000),
+    maxLen = jumpTableSize * 1024 * 1024 div sizeof(LongJumpInstruction),
+    accessFlags = memExecReadWrite)
+
+  type
+    ProcSym = object
+      jump: ptr LongJumpInstruction
+      gen: int
+
+    GlobalVarSym = object
+      p: pointer
+      markerProc: HcrGcMarkerProc
+      gen: int
+
+    ModuleDesc = object
+      procs: Table[string, ProcSym]
+      globals: Table[string, GlobalVarSym]
+      imports: seq[string]
+      handle: LibHandle
+      hash: string
+      gen: int
+      lastModification: Time
+      handlers: seq[tuple[isBefore: bool, cb: proc () {.nimcall.}]]
+
+  proc newModuleDesc(): ModuleDesc =
+    result.procs = initTable[string, ProcSym]()
+    result.globals = initTable[string, GlobalVarSym]()
+    result.handle = nil
+    result.gen = -1
+    result.lastModification = low(Time)
+
+  # the global state necessary for traversing and reloading the module import tree
+  var modules = initTable[string, ModuleDesc]()
+  var root: string
+  var system: string
+  var mainDatInit: HcrModuleInitializer
+  var generation = 0
+
+  # necessary for queries such as "has module X changed" - contains all but the main module
+  var hashToModuleMap = initTable[string, string]()
+
+  # necessary for registering handlers and keeping them up-to-date
+  var currentModule: string
+
+  # supplied from the main module - used by others to initialize pointers to this runtime
+  var hcrDynlibHandle: pointer
+  var getProcAddr: HcrProcGetter
+
+  proc hcrRegisterProc*(module: cstring, name: cstring, fn: pointer): pointer {.nimhcr.} =
+    trace "  register proc: ", module.sanitize, " ", name
+    # Please note: We must allocate a local copy of the strings, because the supplied
+    # `cstring` will reside in the data segment of a DLL that will be later unloaded.
+    let name = $name
+    let module = $module
+
+    var jumpTableEntryAddr: ptr LongJumpInstruction
+
+    modules[module].procs.withValue(name, p):
+      trace "    update proc: ", name
+      jumpTableEntryAddr = p.jump
+      p.gen = generation
+    do:
+      let len = jumpTable.len
+      jumpTable.setLen(len + 1)
+      jumpTableEntryAddr = addr jumpTable[len]
+      modules[module].procs[name] = ProcSym(jump: jumpTableEntryAddr, gen: generation)
+
+    writeJump jumpTableEntryAddr, fn
+    return jumpTableEntryAddr
+
+  proc hcrGetProc*(module: cstring, name: cstring): pointer {.nimhcr.} =
+    trace "  get proc: ", module.sanitize, " ", name
+    return modules[$module].procs.getOrDefault($name, ProcSym()).jump
+
+  proc hcrRegisterGlobal*(module: cstring,
+                          name: cstring,
+                          size: Natural,
+                          gcMarker: HcrGcMarkerProc,
+                          outPtr: ptr pointer): bool {.nimhcr.} =
+    trace "  register global: ", module.sanitize, " ", name
+    # Please note: We must allocate local copies of the strings, because the supplied
+    # `cstring` will reside in the data segment of a DLL that will be later unloaded.
+    # Also using a ptr pointer instead of a var pointer (an output parameter)
+    # because for the C++ backend var parameters use references and in this use case
+    # it is not possible to cast an int* (for example) to a void* and then pass it
+    # to void*& since the casting yields an rvalue and references bind only to lvalues.
+    let name = $name
+    let module = $module
+
+    modules[module].globals.withValue(name, global):
+      trace "    update global: ", name
+      outPtr[] = global.p
+      global.gen = generation
+      global.markerProc = gcMarker
+      return false
+    do:
+      outPtr[] = alloc0(size)
+      modules[module].globals[name] = GlobalVarSym(p: outPtr[],
+                                                   gen: generation,
+                                                   markerProc: gcMarker)
+      return true
+
+  proc hcrGetGlobal*(module: cstring, name: cstring): pointer {.nimhcr.} =
+    trace "  get global: ", module.sanitize, " ", name
+    return modules[$module].globals[$name].p
+
+  proc getListOfModules(cstringArray: ptr pointer): seq[string] =
+    var curr = cast[ptr cstring](cstringArray)
+    while len(curr[]) > 0:
+      result.add($curr[])
+      curr = cast[ptr cstring](cast[int64](curr) + sizeof(ptr cstring))
+
+  template cleanup(collection, body) =
+    var toDelete: seq[string]
+    for name, data in collection.pairs:
+      if data.gen < generation:
+        toDelete.add(name)
+        trace "HCR Cleaning ", astToStr(collection), " :: ", name, " ", data.gen
+    for name {.inject.} in toDelete:
+      body
+
+  proc cleanupGlobal(module: string, name: string) =
+    var g: GlobalVarSym
+    if modules[module].globals.take(name, g):
+      dealloc g.p
+
+  proc cleanupSymbols(module: string) =
+    cleanup modules[module].globals:
+      cleanupGlobal(module, name)
+
+    cleanup modules[module].procs:
+      modules[module].procs.del(name)
+
+  proc unloadDll(name: string) =
+    if modules[name].handle != nil:
+      unloadLib(modules[name].handle)
+
+  proc loadDll(name: cstring) {.nimhcr.} =
+    let name = $name
+    trace "HCR LOADING: ", name.sanitize
+    if modules.contains(name):
+      unloadDll(name)
+    else:
+      modules[name] = newModuleDesc()
+
+    let copiedName = name & ".copy." & dllExt
+    copyFileWithPermissions(name, copiedName)
+
+    let lib = loadLib(copiedName)
+    assert lib != nil
+    modules[name].handle = lib
+    modules[name].gen = generation
+    modules[name].lastModification = getLastModificationTime(name)
+
+    # update the list of imports by the module
+    let getImportsProc = cast[proc (): ptr pointer {.nimcall.}](
+      checkedSymAddr(lib, "HcrGetImportedModules"))
+    modules[name].imports = getListOfModules(getImportsProc())
+    # get the hash of the module
+    let getHashProc = cast[proc (): cstring {.nimcall.}](
+      checkedSymAddr(lib, "HcrGetSigHash"))
+    modules[name].hash = $getHashProc()
+    hashToModuleMap[modules[name].hash] = name
+
+    # Remove handlers for this module if reloading - they will be re-registered.
+    # In order for them to be re-registered we need to de-register all globals
+    # that trigger the registering of handlers through calls to hcrAddEventHandler
+    modules[name].handlers.setLen(0)
+
+  proc initHcrData(name: cstring) {.nimhcr.} =
+    trace "HCR Hcr init: ", name.sanitize
+    cast[proc (h: pointer, gpa: HcrProcGetter) {.nimcall.}](
+      checkedSymAddr(modules[$name].handle, "HcrInit000"))(hcrDynlibHandle, getProcAddr)
+
+  proc initTypeInfoGlobals(name: cstring) {.nimhcr.} =
+    trace "HCR TypeInfo globals init: ", name.sanitize
+    cast[HcrModuleInitializer](checkedSymAddr(modules[$name].handle, "HcrCreateTypeInfos"))()
+
+  proc initPointerData(name: cstring) {.nimhcr.} =
+    trace "HCR Dat init: ", name.sanitize
+    cast[HcrModuleInitializer](checkedSymAddr(modules[$name].handle, "DatInit000"))()
+
+  proc initGlobalScope(name: cstring) {.nimhcr.} =
+    trace "HCR Init000: ", name.sanitize
+    # set the currently inited module - necessary for registering the before/after HCR handlers
+    currentModule = $name
+    cast[HcrModuleInitializer](checkedSymAddr(modules[$name].handle, "Init000"))()
+
+  var modulesToInit: seq[string] = @[]
+  var allModulesOrderedByDFS: seq[string] = @[]
+
+  proc recursiveDiscovery(dlls: seq[string]) =
+    for curr in dlls:
+      if modules.contains(curr):
+        # skip updating modules that have already been updated to the latest generation
+        if modules[curr].gen >= generation:
+          trace "HCR SKIP: ", curr.sanitize, " gen is already: ", modules[curr].gen
+          continue
+        # skip updating an unmodified module but continue traversing its dependencies
+        if modules[curr].lastModification >= getLastModificationTime(curr):
+          trace "HCR SKIP (not modified): ", curr.sanitize, " ", modules[curr].lastModification.sanitize
+          # update generation so module doesn't get collected
+          modules[curr].gen = generation
+          # recurse to imported modules - they might be changed
+          recursiveDiscovery(modules[curr].imports)
+          allModulesOrderedByDFS.add(curr)
+          continue
+      loadDll(curr.cstring)
+      # first load all dependencies of the current module and init it after that
+      recursiveDiscovery(modules[curr].imports)
+
+      allModulesOrderedByDFS.add(curr)
+      modulesToInit.add(curr)
+
+  proc initModules() =
+    # first init the pointers to hcr functions and also do the registering of typeinfo globals
+    for curr in modulesToInit:
+      initHcrData(curr.cstring)
+      initTypeInfoGlobals(curr.cstring)
+    # for now system always gets fully inited before any other module (including when reloading)
+    initPointerData(system.cstring)
+    initGlobalScope(system.cstring)
+    # proceed with the DatInit calls - for all modules - including the main one!
+    for curr in allModulesOrderedByDFS:
+      if curr != system:
+        initPointerData(curr.cstring)
+    mainDatInit()
+    # execute top-level code (in global scope)
+    for curr in modulesToInit:
+      if curr != system:
+        initGlobalScope(curr.cstring)
+    # cleanup old symbols which are gone now
+    for curr in modulesToInit:
+      cleanupSymbols(curr)
+
+  proc hcrInit*(moduleList: ptr pointer, main, sys: cstring,
+                datInit: HcrModuleInitializer, handle: pointer, gpa: HcrProcGetter) {.nimhcr.} =
+    trace "HCR INITING: ", main.sanitize, " gen: ", generation
+    # initialize globals
+    root = $main
+    system = $sys
+    mainDatInit = datInit
+    hcrDynlibHandle = handle
+    getProcAddr = gpa
+    # the root is already added and we need it because symbols from it will also be registered in the HCR system
+    modules[root].imports = getListOfModules(moduleList)
+    modules[root].gen = high(int) # something huge so it doesn't get collected
+    # recursively initialize all modules
+    recursiveDiscovery(modules[root].imports)
+    initModules()
+    # the next module to be inited will be the root
+    currentModule = root
+
+  proc hcrHasModuleChanged*(moduleHash: string): bool {.nimhcr.} =
+    let module = hashToModuleMap[moduleHash]
+    return modules[module].lastModification < getLastModificationTime(module)
+
+  proc hcrReloadNeeded*(): bool {.nimhcr.} =
+    for hash, _ in hashToModuleMap:
+      if hcrHasModuleChanged(hash):
+        return true
+    return false
+
+  proc hcrPerformCodeReload*() {.nimhcr.} =
+    if not hcrReloadNeeded():
+      trace "HCR - no changes"
+      return
+
+    # We disable the GC during the reload, because the reloading procedures
+    # will replace type info objects and GC marker procs. This seems to create
+    # problems when the GC is executed while the reload is underway.
+    # Future versions of NIMHCR won't use the GC, because all globals and the
+    # metadata needed to access them will be placed in shared memory, so they
+    # can be manipulated from external programs without reloading.
+    when declared(GC_disable):
+      GC_disable()
+      defer: GC_enable()
+    elif declared(GC_disableOrc):
+      GC_disableOrc()
+      defer: GC_enableOrc()
+
+    inc(generation)
+    trace "HCR RELOADING: ", generation
+
+    var traversedHandlerModules = initHashSet[string]()
+
+    proc recursiveExecuteHandlers(isBefore: bool, module: string) =
+      # do not process an already traversed module
+      if traversedHandlerModules.containsOrIncl(module): return
+      traversedHandlerModules.incl module
+      # first recurse to do a DFS traversal
+      for curr in modules[module].imports:
+        recursiveExecuteHandlers(isBefore, curr)
+      # and then execute the handlers - from leaf modules all the way up to the root module
+      for curr in modules[module].handlers:
+        if curr.isBefore == isBefore:
+         curr.cb()
+
+    # first execute the before reload handlers
+    traversedHandlerModules.clear()
+    recursiveExecuteHandlers(true, root)
+
+    # do the reloading
+    modulesToInit = @[]
+    allModulesOrderedByDFS = @[]
+    recursiveDiscovery(modules[root].imports)
+    initModules()
+
+    # execute the after reload handlers
+    traversedHandlerModules.clear()
+    recursiveExecuteHandlers(false, root)
+
+    # collecting no longer referenced modules - based on their generation
+    cleanup modules:
+      cleanupSymbols(name)
+      unloadDll(name)
+      hashToModuleMap.del(modules[name].hash)
+      modules.del(name)
+
+  proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) {.nimhcr.} =
+    modules[currentModule].handlers.add(
+      (isBefore: isBefore, cb: cb))
+
+  proc hcrAddModule*(module: cstring) {.nimhcr.} =
+    if not modules.contains($module):
+      modules[$module] = newModuleDesc()
+
+  proc hcrGeneration*(): int {.nimhcr.} =
+    generation
+
+  proc hcrMarkGlobals*() {.compilerproc, exportc, dynlib, nimcall, gcsafe.} =
+    # This is gcsafe, because it will be registered
+    # only in the GC of the main thread.
+    {.gcsafe.}:
+      for _, module in modules:
+        for _, global in module.globals:
+          if global.markerProc != nil:
+            global.markerProc()
+
+elif defined(hotcodereloading) or defined(testNimHcr):
+  when not defined(js):
+    const
+      nimhcrLibname = when defined(windows): "nimhcr." & dllExt
+                      elif defined(macosx): "libnimhcr." & dllExt
+                      else: "libnimhcr." & dllExt
+
+    {.pragma: nimhcr, compilerproc, importc, dynlib: nimhcrLibname.}
+
+    proc hcrRegisterProc*(module: cstring, name: cstring, fn: pointer): pointer {.nimhcr.}
+
+    proc hcrGetProc*(module: cstring, name: cstring): pointer {.nimhcr.}
+
+    proc hcrRegisterGlobal*(module: cstring, name: cstring, size: Natural,
+                            gcMarker: HcrGcMarkerProc, outPtr: ptr pointer): bool {.nimhcr.}
+    proc hcrGetGlobal*(module: cstring, name: cstring): pointer {.nimhcr.}
+
+    proc hcrInit*(moduleList: ptr pointer,
+                  main, sys: cstring,
+                  datInit: HcrModuleInitializer,
+                  handle: pointer,
+                  gpa: HcrProcGetter) {.nimhcr.}
+
+    proc hcrAddModule*(module: cstring) {.nimhcr.}
+
+    proc hcrHasModuleChanged*(moduleHash: string): bool {.nimhcr.}
+
+    proc hcrReloadNeeded*(): bool {.nimhcr.}
+
+    proc hcrPerformCodeReload*() {.nimhcr.}
+
+    proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) {.nimhcr.}
+
+    proc hcrMarkGlobals*() {.raises: [], nimhcr, nimcall, gcsafe.}
+
+    when declared(nimRegisterGlobalMarker):
+      nimRegisterGlobalMarker(cast[GlobalMarkerProc](hcrMarkGlobals))
+
+  else:
+    proc hcrHasModuleChanged*(moduleHash: string): bool =
+      # TODO
+      false
+
+    proc hcrAddEventHandler*(isBefore: bool, cb: proc () {.nimcall.}) =
+      # TODO
+      discard
+
diff --git a/lib/nimhcr.nim.cfg b/lib/nimhcr.nim.cfg
new file mode 100644
index 000000000..282bec27c
--- /dev/null
+++ b/lib/nimhcr.nim.cfg
@@ -0,0 +1,5 @@
+--app:lib
+--threads:on
+-d:useNimRtl
+-d:createNimHcr
+
diff --git a/lib/nimrtl.nim b/lib/nimrtl.nim
new file mode 100644
index 000000000..a2fb6ce60
--- /dev/null
+++ b/lib/nimrtl.nim
@@ -0,0 +1,40 @@
+discard """
+batchable: false
+"""
+
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2010 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Main file to generate a DLL from the standard library.
+## The default Nimrtl does not only contain the `system` module, but these
+## too:
+##
+## * parseutils
+## * strutils
+## * parseopt
+## * parsecfg
+## * strtabs
+## * times
+## * os
+## * osproc
+## * unicode
+## * pegs
+## * ropes
+## * cstrutils
+##
+
+when system.appType != "lib":
+  {.error: "This file has to be compiled as a library!".}
+
+when not defined(createNimRtl):
+  {.error: "This file has to be compiled with '-d:createNimRtl'".}
+
+import
+  std/[parseutils, strutils, parseopt, parsecfg, strtabs, unicode, pegs, ropes,
+  os, osproc, times, cstrutils]
diff --git a/lib/nimrtl.nim.cfg b/lib/nimrtl.nim.cfg
new file mode 100644
index 000000000..a5cec596f
--- /dev/null
+++ b/lib/nimrtl.nim.cfg
@@ -0,0 +1,6 @@
+# The RTL.dll needs to be compiled with these options!
+
+--app:lib
+--threads:on
+--define:createNimRtl
+
diff --git a/lib/oldwrappers/cairo/cairo.nim b/lib/oldwrappers/cairo/cairo.nim
deleted file mode 100755
index 6da8183f3..000000000
--- a/lib/oldwrappers/cairo/cairo.nim
+++ /dev/null
@@ -1,698 +0,0 @@
-
-#* cairo - a vector graphics library with display and print output
-# *
-# * Copyright © 2002 University of Southern California
-# * Copyright © 2005 Red Hat, Inc.
-# *
-# * This library is free software; you can redistribute it and/or
-# * modify it either under the terms of the GNU Lesser General Public
-# * License version 2.1 as published by the Free Software Foundation
-# * (the "LGPL") or, at your option, under the terms of the Mozilla
-# * Public License Version 1.1 (the "MPL"). If you do not alter this
-# * notice, a recipient may use your version of this file under either
-# * the MPL or the LGPL.
-# *
-# * You should have received a copy of the LGPL along with this library
-# * in the file COPYING-LGPL-2.1; if not, write to the Free Software
-# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# * You should have received a copy of the MPL along with this library
-# * in the file COPYING-MPL-1.1
-# *
-# * The contents of this file are subject to the Mozilla Public License
-# * Version 1.1 (the "License"); you may not use this file except in
-# * compliance with the License. You may obtain a copy of the License at
-# * http://www.mozilla.org/MPL/
-# *
-# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
-# * OF ANY KIND, either express or implied. See the LGPL or the MPL for
-# * the specific language governing rights and limitations.
-# *
-# * The Original Code is the cairo graphics library.
-# *
-# * The Initial Developer of the Original Code is University of Southern
-# * California.
-# *
-# * Contributor(s):
-# *	Carl D. Worth <cworth@cworth.org>
-# #*
-# *  This FreePascal binding generated August 26, 2005
-# *  by Jeffrey Pohlmeyer <yetanothergeek@yahoo.com>
-#
-
-#
-#  - Updated to cairo version 1.4
-#  - Grouped OS specific fuctions in separated units
-#  - Organized the functions by group and ordered exactly as the c header
-#  - Cleared parameter list syntax according to pascal standard
-#
-#  By Luiz Américo Pereira Câmara
-#  October 2007
-#
-
-when defined(windows):
-  const
-    LIB_CAIRO* = "cairo.dll"
-else:
-  const
-    LIB_CAIRO* = "libcairo.so"
-
-type
-  PByte = cstring
-  TCairoStatus* = enum
-    CAIRO_STATUS_SUCCESS = 0, CAIRO_STATUS_NO_MEMORY,
-    CAIRO_STATUS_INVALID_RESTORE, CAIRO_STATUS_INVALID_POP_GROUP,
-    CAIRO_STATUS_NO_CURRENT_POINT, CAIRO_STATUS_INVALID_MATRIX,
-    CAIRO_STATUS_INVALID_STATUS, CAIRO_STATUS_NULL_POINTER,
-    CAIRO_STATUS_INVALID_STRING, CAIRO_STATUS_INVALID_PATH_DATA,
-    CAIRO_STATUS_READ_ERROR, CAIRO_STATUS_WRITE_ERROR,
-    CAIRO_STATUS_SURFACE_FINISHED, CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
-    CAIRO_STATUS_PATTERN_TYPE_MISMATCH, CAIRO_STATUS_INVALID_CONTENT,
-    CAIRO_STATUS_INVALID_FORMAT, CAIRO_STATUS_INVALID_VISUAL,
-    CAIRO_STATUS_FILE_NOT_FOUND, CAIRO_STATUS_INVALID_DASH
-  TCairoOperator* = enum
-    CAIRO_OPERATOR_CLEAR, CAIRO_OPERATOR_SOURCE, CAIRO_OPERATOR_OVER,
-    CAIRO_OPERATOR_IN, CAIRO_OPERATOR_OUT, CAIRO_OPERATOR_ATOP,
-    CAIRO_OPERATOR_DEST, CAIRO_OPERATOR_DEST_OVER, CAIRO_OPERATOR_DEST_IN,
-    CAIRO_OPERATOR_DEST_OUT, CAIRO_OPERATOR_DEST_ATOP, CAIRO_OPERATOR_XOR,
-    CAIRO_OPERATOR_ADD, CAIRO_OPERATOR_SATURATE
-  TCairoAntialias* = enum
-    CAIRO_ANTIALIAS_DEFAULT, CAIRO_ANTIALIAS_NONE, CAIRO_ANTIALIAS_GRAY,
-    CAIRO_ANTIALIAS_SUBPIXEL
-  TCairoFillRule* = enum
-    CAIRO_FILL_RULE_WINDING, CAIRO_FILL_RULE_EVEN_ODD
-  TCairoLineCap* = enum
-    CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_SQUARE
-  TCairoLineJoin* = enum
-    CAIRO_LINE_JOIN_MITER, CAIRO_LINE_JOIN_ROUND, CAIRO_LINE_JOIN_BEVEL
-  TCairoFontSlant* = enum
-    CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_SLANT_OBLIQUE
-  TCairoFontWeight* = enum
-    CAIRO_FONT_WEIGHT_NORMAL, CAIRO_FONT_WEIGHT_BOLD
-  TCairoSubpixelOrder* = enum
-    CAIRO_SUBPIXEL_ORDER_DEFAULT, CAIRO_SUBPIXEL_ORDER_RGB,
-    CAIRO_SUBPIXEL_ORDER_BGR, CAIRO_SUBPIXEL_ORDER_VRGB,
-    CAIRO_SUBPIXEL_ORDER_VBGR
-  TCairoHintStyle* = enum
-    CAIRO_HINT_STYLE_DEFAULT, CAIRO_HINT_STYLE_NONE, CAIRO_HINT_STYLE_SLIGHT,
-    CAIRO_HINT_STYLE_MEDIUM, CAIRO_HINT_STYLE_FULL
-  TCairoHintMetrics* = enum
-    CAIRO_HINT_METRICS_DEFAULT, CAIRO_HINT_METRICS_OFF, CAIRO_HINT_METRICS_ON
-  TCairoPathDataType* = enum
-    CAIRO_PATH_MOVE_TO, CAIRO_PATH_LINE_TO, CAIRO_PATH_CURVE_TO,
-    CAIRO_PATH_CLOSE_PATH
-  TCairoContent* = enum
-    CAIRO_CONTENT_COLOR = 0x00001000, CAIRO_CONTENT_ALPHA = 0x00002000,
-    CAIRO_CONTENT_COLOR_ALPHA = 0x00003000
-  TCairoFormat* = enum
-    CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_RGB24, CAIRO_FORMAT_A8, CAIRO_FORMAT_A1
-  TCairoExtend* = enum
-    CAIRO_EXTEND_NONE, CAIRO_EXTEND_REPEAT, CAIRO_EXTEND_REFLECT,
-    CAIRO_EXTEND_PAD
-  TCairoFilter* = enum
-    CAIRO_FILTER_FAST, CAIRO_FILTER_GOOD, CAIRO_FILTER_BEST,
-    CAIRO_FILTER_NEAREST, CAIRO_FILTER_BILINEAR, CAIRO_FILTER_GAUSSIAN
-  TCairoFontType* = enum
-    CAIRO_FONT_TYPE_TOY, CAIRO_FONT_TYPE_FT, CAIRO_FONT_TYPE_WIN32,
-    CAIRO_FONT_TYPE_ATSUI
-  TCairoPatternType* = enum
-    CAIRO_PATTERN_TYPE_SOLID, CAIRO_PATTERN_TYPE_SURFACE,
-    CAIRO_PATTERN_TYPE_LINEAR, CAIRO_PATTERN_TYPE_RADIAL
-  TCairoSurfaceType* = enum
-    CAIRO_SURFACE_TYPE_IMAGE, CAIRO_SURFACE_TYPE_PDF, CAIRO_SURFACE_TYPE_PS,
-    CAIRO_SURFACE_TYPE_XLIB, CAIRO_SURFACE_TYPE_XCB, CAIRO_SURFACE_TYPE_GLITZ,
-    CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_SURFACE_TYPE_WIN32,
-    CAIRO_SURFACE_TYPE_BEOS, CAIRO_SURFACE_TYPE_DIRECTFB,
-    CAIRO_SURFACE_TYPE_SVG, CAIRO_SURFACE_TYPE_OS2
-  TCairoSvgVersion* = enum
-    CAIRO_SVG_VERSION_1_1, CAIRO_SVG_VERSION_1_2
-  PCairoSurface* = ptr TCairoSurface
-  PPCairoSurface* = ptr PCairoSurface
-  PCairo* = ptr TCairo
-  PCairoPattern* = ptr TCairoPattern
-  PCairoFontOptions* = ptr TCairoFontOptions
-  PCairoFontFace* = ptr TCairoFontFace
-  PCairoScaledFont* = ptr TCairoScaledFont
-  PCairoBool* = ptr TCairoBool
-  TCairoBool* = int32
-  PCairoMatrix* = ptr TCairoMatrix
-  PCairoUserDataKey* = ptr TCairoUserDataKey
-  PCairoGlyph* = ptr TCairoGlyph
-  PCairoTextExtents* = ptr TCairoTextExtents
-  PCairoFontExtents* = ptr TCairoFontExtents
-  PCairoPathDataType* = ptr TCairoPathDataType
-  PCairoPathData* = ptr TCairoPathData
-  PCairoPath* = ptr TCairoPath
-  PCairoRectangle* = ptr TCairoRectangle
-  PCairoRectangleList* = ptr TCairoRectangleList
-  TCairoDestroyFunc* = proc (data: Pointer){.cdecl.}
-  TCairoWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TCairoStatus{.
-      cdecl.}
-  TCairoReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TCairoStatus{.
-      cdecl.}
-  TCairo* {.final.} = object           #OPAQUE
-  TCairoSurface* {.final.} = object   #OPAQUE
-  TCairoPattern* {.final.} = object   #OPAQUE
-  TCairoScaledFont* {.final.} = object #OPAQUE
-  TCairoFontFace* {.final.} = object #OPAQUE
-  TCairoFontOptions* {.final.} = object #OPAQUE
-  TCairoMatrix* {.final.} = object
-    xx: float64
-    yx: float64
-    xy: float64
-    yy: float64
-    x0: float64
-    y0: float64
-
-  TCairoUserDataKey* {.final.} = object
-    unused: int32
-
-  TCairoGlyph* {.final.} = object
-    index: int32
-    x: float64
-    y: float64
-
-  TCairoTextExtents* {.final.} = object
-    x_bearing: float64
-    y_bearing: float64
-    width: float64
-    height: float64
-    x_advance: float64
-    y_advance: float64
-
-  TCairoFontExtents* {.final.} = object
-    ascent: float64
-    descent: float64
-    height: float64
-    max_x_advance: float64
-    max_y_advance: float64
-
-  TCairoPathData* {.final.} = object #* _type : TCairoPathDataType;
-                                     #       length : LongInt;
-                                     #    end
-    x: float64
-    y: float64
-
-  TCairoPath* {.final.} = object
-    status: TCairoStatus
-    data: PCairoPathData
-    num_data: int32
-
-  TCairoRectangle* {.final.} = object
-    x, y, width, height: float64
-
-  TCairoRectangleList* {.final.} = object
-    status: TCairoStatus
-    rectangles: PCairoRectangle
-    num_rectangles: int32
-
-
-proc cairo_version*(): int32{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_version_string*(): cstring{.cdecl, importc, dynlib: LIB_CAIRO.}
-  #Helper function to retrieve decoded version
-proc cairo_version*(major, minor, micro: var int32)
-  #* Functions for manipulating state objects
-proc cairo_create*(target: PCairoSurface): PCairo{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_reference*(cr: PCairo): PCairo{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_destroy*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_reference_count*(cr: PCairo): int32{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_user_data*(cr: PCairo, key: PCairoUserDataKey): pointer{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_user_data*(cr: PCairo, key: PCairoUserDataKey,
-                          user_data: Pointer, destroy: TCairoDestroyFunc): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_save*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_restore*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_push_group*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_push_group_with_content*(cr: PCairo, content: TCairoContent){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pop_group*(cr: PCairo): PCairoPattern{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pop_group_to_source*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Modify state
-proc cairo_set_operator*(cr: PCairo, op: TCairoOperator){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_source*(cr: PCairo, source: PCairoPattern){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_source_rgb*(cr: PCairo, red, green, blue: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_source_rgba*(cr: PCairo, red, green, blue, alpha: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_source_surface*(cr: PCairo, surface: PCairoSurface,
-                               x, y: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_tolerance*(cr: PCairo, tolerance: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_antialias*(cr: PCairo, antialias: TCairoAntialias){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_fill_rule*(cr: PCairo, fill_rule: TCairoFillRule){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_line_width*(cr: PCairo, width: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_line_cap*(cr: PCairo, line_cap: TCairoLineCap){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_line_join*(cr: PCairo, line_join: TCairoLineJoin){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_dash*(cr: PCairo, dashes: openarray[float64],
-                     offset: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_miter_limit*(cr: PCairo, limit: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_translate*(cr: PCairo, tx, ty: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scale*(cr: PCairo, sx, sy: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rotate*(cr: PCairo, angle: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_transform*(cr: PCairo, matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_matrix*(cr: PCairo, matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_identity_matrix*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_user_to_device*(cr: PCairo, x, y: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_user_to_device_distance*(cr: PCairo, dx, dy: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_device_to_user*(cr: PCairo, x, y: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_device_to_user_distance*(cr: PCairo, dx, dy: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Path creation functions
-proc cairo_new_path*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_move_to*(cr: PCairo, x, y: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_new_sub_path*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_line_to*(cr: PCairo, x, y: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_curve_to*(cr: PCairo, x1, y1, x2, y2, x3, y3: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_arc*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_arc_negative*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rel_move_to*(cr: PCairo, dx, dy: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rel_line_to*(cr: PCairo, dx, dy: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rel_curve_to*(cr: PCairo, dx1, dy1, dx2, dy2, dx3, dy3: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rectangle*(cr: PCairo, x, y, width, height: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_close_path*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Painting functions
-proc cairo_paint*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_paint_with_alpha*(cr: PCairo, alpha: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_mask*(cr: PCairo, pattern: PCairoPattern){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_mask_surface*(cr: PCairo, surface: PCairoSurface,
-                         surface_x, surface_y: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_stroke*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_stroke_preserve*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_fill*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_fill_preserve*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_copy_page*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_show_page*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Insideness testing
-proc cairo_in_stroke*(cr: PCairo, x, y: float64): TCairoBool{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_in_fill*(cr: PCairo, x, y: float64): TCairoBool{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Rectangular extents
-proc cairo_stroke_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_fill_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Clipping
-proc cairo_reset_clip*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_clip*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_clip_preserve*(cr: PCairo){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_clip_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_copy_clip_rectangle_list*(cr: PCairo): PCairoRectangleList{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_rectangle_list_destroy*(rectangle_list: PCairoRectangleList){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Font/Text functions
-proc cairo_font_options_create*(): PCairoFontOptions{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_copy*(original: PCairoFontOptions): PCairoFontOptions{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_destroy*(options: PCairoFontOptions){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_status*(options: PCairoFontOptions): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_merge*(options, other: PCairoFontOptions){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_equal*(options, other: PCairoFontOptions): TCairoBool{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_hash*(options: PCairoFontOptions): int32{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_set_antialias*(options: PCairoFontOptions,
-                                       antialias: TCairoAntialias){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_get_antialias*(options: PCairoFontOptions): TCairoAntialias{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_set_subpixel_order*(options: PCairoFontOptions,
-    subpixel_order: TCairoSubpixelOrder){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_get_subpixel_order*(options: PCairoFontOptions): TCairoSubpixelOrder{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_set_hint_style*(options: PCairoFontOptions,
-                                        hint_style: TCairoHintStyle){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_options_get_hint_style*(options: PCairoFontOptions): TCairoHintStyle{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_set_hint_metrics*(options: PCairoFontOptions,
-    hint_metrics: TCairoHintMetrics){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_options_get_hint_metrics*(options: PCairoFontOptions): TCairoHintMetrics{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* This interface is for dealing with text as text, not caring about the
-  #   font object inside the the TCairo.
-proc cairo_select_font_face*(cr: PCairo, family: cstring,
-                             slant: TCairoFontSlant,
-                             weight: TCairoFontWeight){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_font_size*(cr: PCairo, size: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_font_matrix*(cr: PCairo, matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_font_matrix*(cr: PCairo, matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_font_options*(cr: PCairo, options: PCairoFontOptions){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_font_options*(cr: PCairo, options: PCairoFontOptions){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_set_font_face*(cr: PCairo, font_face: PCairoFontFace){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_font_face*(cr: PCairo): PCairoFontFace{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_set_scaled_font*(cr: PCairo, scaled_font: PCairoScaledFont){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_scaled_font*(cr: PCairo): PCairoScaledFont{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_show_text*(cr: PCairo, utf8: cstring){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_show_glyphs*(cr: PCairo, glyphs: PCairoGlyph, num_glyphs: int32){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_text_path*(cr: PCairo, utf8: cstring){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_glyph_path*(cr: PCairo, glyphs: PCairoGlyph, num_glyphs: int32){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_text_extents*(cr: PCairo, utf8: cstring,
-                         extents: PCairoTextExtents){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_glyph_extents*(cr: PCairo, glyphs: PCairoGlyph,
-                          num_glyphs: int32, extents: PCairoTextExtents){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_extents*(cr: PCairo, extents: PCairoFontExtents){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Generic identifier for a font style
-proc cairo_font_face_reference*(font_face: PCairoFontFace): PCairoFontFace{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_face_destroy*(font_face: PCairoFontFace){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_font_face_get_reference_count*(font_face: PCairoFontFace): int32{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_face_status*(font_face: PCairoFontFace): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_face_get_type*(font_face: PCairoFontFace): TCairoFontType{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_face_get_user_data*(font_face: PCairoFontFace,
-                                    key: PCairoUserDataKey): pointer{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_font_face_set_user_data*(font_face: PCairoFontFace,
-                                    key: PCairoUserDataKey,
-                                    user_data: pointer,
-                                    destroy: TCairoDestroyFunc): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Portable interface to general font features
-proc cairo_scaled_font_create*(font_face: PCairoFontFace,
-                               font_matrix: PCairoMatrix,
-                               ctm: PCairoMatrix,
-                               options: PCairoFontOptions): PCairoScaledFont{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_reference*(scaled_font: PCairoScaledFont): PCairoScaledFont{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_destroy*(scaled_font: PCairoScaledFont){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_reference_count*(scaled_font: PCairoScaledFont): int32{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_status*(scaled_font: PCairoScaledFont): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_type*(scaled_font: PCairoScaledFont): TCairoFontType{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_user_data*(scaled_font: PCairoScaledFont,
-                                      key: PCairoUserDataKey): Pointer{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_set_user_data*(scaled_font: PCairoScaledFont,
-                                      key: PCairoUserDataKey,
-                                      user_data: Pointer,
-                                      destroy: TCairoDestroyFunc): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_extents*(scaled_font: PCairoScaledFont,
-                                extents: PCairoFontExtents){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_text_extents*(scaled_font: PCairoScaledFont,
-                                     utf8: cstring,
-                                     extents: PCairoTextExtents){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_glyph_extents*(scaled_font: PCairoScaledFont,
-                                      glyphs: PCairoGlyph, num_glyphs: int32,
-                                      extents: PCairoTextExtents){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_font_face*(scaled_font: PCairoScaledFont): PCairoFontFace{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_font_matrix*(scaled_font: PCairoScaledFont,
-                                        font_matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_ctm*(scaled_font: PCairoScaledFont,
-                                ctm: PCairoMatrix){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_scaled_font_get_font_options*(scaled_font: PCairoScaledFont,
-    options: PCairoFontOptions){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Query functions
-proc cairo_get_operator*(cr: PCairo): TCairoOperator{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_source*(cr: PCairo): PCairoPattern{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_tolerance*(cr: PCairo): float64{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_antialias*(cr: PCairo): TCairoAntialias{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_current_point*(cr: PCairo, x, y: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_fill_rule*(cr: PCairo): TCairoFillRule{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_line_width*(cr: PCairo): float64{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_line_cap*(cr: PCairo): TCairoLineCap{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_line_join*(cr: PCairo): TCairoLineJoin{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_miter_limit*(cr: PCairo): float64{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_dash_count*(cr: PCairo): int32{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_dash*(cr: PCairo, dashes, offset: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_matrix*(cr: PCairo, matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_get_target*(cr: PCairo): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_get_group_target*(cr: PCairo): PCairoSurface{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_copy_path*(cr: PCairo): PCairoPath{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_copy_path_flat*(cr: PCairo): PCairoPath{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_append_path*(cr: PCairo, path: PCairoPath){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_path_destroy*(path: PCairoPath){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Error status queries
-proc cairo_status*(cr: PCairo): TCairoStatus{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_status_to_string*(status: TCairoStatus): cstring{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Surface manipulation
-proc cairo_surface_create_similar*(other: PCairoSurface,
-                                   content: TCairoContent,
-                                   width, height: int32): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_reference*(surface: PCairoSurface): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_finish*(surface: PCairoSurface){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_destroy*(surface: PCairoSurface){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_get_reference_count*(surface: PCairoSurface): int32{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_status*(surface: PCairoSurface): TCairoStatus{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_get_type*(surface: PCairoSurface): TCairoSurfaceType{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_get_content*(surface: PCairoSurface): TCairoContent{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_write_to_png*(surface: PCairoSurface, filename: cstring): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_write_to_png_stream*(surface: PCairoSurface,
-                                        write_func: TCairoWriteFunc,
-                                        closure: pointer): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_get_user_data*(surface: PCairoSurface,
-                                  key: PCairoUserDataKey): pointer{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_set_user_data*(surface: PCairoSurface,
-                                  key: PCairoUserDataKey,
-                                  user_data: pointer,
-                                  destroy: TCairoDestroyFunc): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_get_font_options*(surface: PCairoSurface,
-                                     options: PCairoFontOptions){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_flush*(surface: PCairoSurface){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_mark_dirty*(surface: PCairoSurface){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_mark_dirty_rectangle*(surface: PCairoSurface,
-    x, y, width, height: int32){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_surface_set_device_offset*(surface: PCairoSurface,
-                                      x_offset, y_offset: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_get_device_offset*(surface: PCairoSurface,
-                                      x_offset, y_offset: var float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_surface_set_fallback_resolution*(surface: PCairoSurface,
-    x_pixels_per_inch, y_pixels_per_inch: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Image-surface functions
-proc cairo_image_surface_create*(format: TCairoFormat, width, height: int32): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_image_surface_create_for_data*(data: Pbyte, format: TCairoFormat,
-    width, height, stride: int32): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_image_surface_get_data*(surface: PCairoSurface): cstring{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_image_surface_get_format*(surface: PCairoSurface): TCairoFormat{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_image_surface_get_width*(surface: PCairoSurface): int32{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_image_surface_get_height*(surface: PCairoSurface): int32{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_image_surface_get_stride*(surface: PCairoSurface): int32{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_image_surface_create_from_png*(filename: cstring): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_image_surface_create_from_png_stream*(read_func: TCairoReadFunc,
-    closure: pointer): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Pattern creation functions
-proc cairo_pattern_create_rgb*(red, green, blue: float64): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_create_rgba*(red, green, blue, alpha: float64): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_create_for_surface*(surface: PCairoSurface): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_create_linear*(x0, y0, x1, y1: float64): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_create_radial*(cx0, cy0, radius0, cx1, cy1, radius1: float64): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_reference*(pattern: PCairoPattern): PCairoPattern{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_destroy*(pattern: PCairoPattern){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_reference_count*(pattern: PCairoPattern): int32{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_status*(pattern: PCairoPattern): TCairoStatus{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_user_data*(pattern: PCairoPattern,
-                                  key: PCairoUserDataKey): Pointer{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_pattern_set_user_data*(pattern: PCairoPattern,
-                                  key: PCairoUserDataKey,
-                                  user_data: Pointer,
-                                  destroy: TCairoDestroyFunc): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_type*(pattern: PCairoPattern): TCairoPatternType{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_add_color_stop_rgb*(pattern: PCairoPattern,
-                                       offset, red, green, blue: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_add_color_stop_rgba*(pattern: PCairoPattern, offset, red,
-    green, blue, alpha: float64){.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_set_matrix*(pattern: PCairoPattern,
-                               matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_matrix*(pattern: PCairoPattern,
-                               matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_pattern_set_extend*(pattern: PCairoPattern, extend: TCairoExtend){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_extend*(pattern: PCairoPattern): TCairoExtend{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_set_filter*(pattern: PCairoPattern, filter: TCairoFilter){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_filter*(pattern: PCairoPattern): TCairoFilter{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_rgba*(pattern: PCairoPattern,
-                             red, green, blue, alpha: var float64): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_surface*(pattern: PCairoPattern,
-                                surface: PPCairoSurface): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_color_stop_rgba*(pattern: PCairoPattern, index: int32,
-    offset, red, green, blue, alpha: var float64): TCairoStatus{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_color_stop_count*(pattern: PCairoPattern,
-    count: var int32): TCairoStatus{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_linear_points*(pattern: PCairoPattern,
-                                      x0, y0, x1, y1: var float64): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pattern_get_radial_circles*(pattern: PCairoPattern,
-                                       x0, y0, r0, x1, y1, r1: var float64): TCairoStatus{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* Matrix functions
-proc cairo_matrix_init*(matrix: PCairoMatrix, xx, yx, xy, yy, x0, y0: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_matrix_init_identity*(matrix: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_init_translate*(matrix: PCairoMatrix, tx, ty: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_matrix_init_scale*(matrix: PCairoMatrix, sx, sy: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_init_rotate*(matrix: PCairoMatrix, radians: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_matrix_translate*(matrix: PCairoMatrix, tx, ty: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_scale*(matrix: PCairoMatrix, sx, sy: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_rotate*(matrix: PCairoMatrix, radians: float64){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_invert*(matrix: PCairoMatrix): TCairoStatus{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_multiply*(result, a, b: PCairoMatrix){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_matrix_transform_distance*(matrix: PCairoMatrix, dx, dy: var float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_matrix_transform_point*(matrix: PCairoMatrix, x, y: var float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* PDF functions
-proc cairo_pdf_surface_create*(filename: cstring,
-                               width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pdf_surface_create_for_stream*(write_func: TCairoWriteFunc,
-    closure: Pointer, width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_pdf_surface_set_size*(surface: PCairoSurface,
-                                 width_in_points, height_in_points: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-  #* PS functions
-proc cairo_ps_surface_create*(filename: cstring,
-                              width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ps_surface_create_for_stream*(write_func: TCairoWriteFunc,
-    closure: Pointer, width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ps_surface_set_size*(surface: PCairoSurface,
-                                width_in_points, height_in_points: float64){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ps_surface_dsc_comment*(surface: PCairoSurface, comment: cstring){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ps_surface_dsc_begin_setup*(surface: PCairoSurface){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-proc cairo_ps_surface_dsc_begin_page_setup*(surface: PCairoSurface){.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* SVG functions
-proc cairo_svg_surface_create*(filename: cstring,
-                               width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_svg_surface_create_for_stream*(write_func: TCairoWriteFunc,
-    closure: Pointer, width_in_points, height_in_points: float64): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_svg_surface_restrict_to_version*(surface: PCairoSurface,
-    version: TCairoSvgVersion){.cdecl, importc, dynlib: LIB_CAIRO.}
-  #todo: see how translate this
-  #procedure cairo_svg_get_versions(TCairoSvgVersion const	**versions,
-  #                        int                      	 *num_versions);
-proc cairo_svg_version_to_string*(version: TCairoSvgVersion): cstring{.cdecl, importc,
-    dynlib: LIB_CAIRO.}
-  #* Functions to be used while debugging (not intended for use in production code)
-proc cairo_debug_reset_static_data*(){.cdecl, importc, dynlib: LIB_CAIRO.}
-# implementation
-
-proc cairo_version(major, minor, micro: var int32) =
-  var version: int32
-  version = cairo_version()
-  major = version div 10000'i32
-  minor = (version mod (major * 10000'i32)) div 100'i32
-  micro = (version mod ((major * 10000'i32) + (minor * 100'i32)))
diff --git a/lib/oldwrappers/cairo/cairoft.nim b/lib/oldwrappers/cairo/cairoft.nim
deleted file mode 100755
index 2418aa922..000000000
--- a/lib/oldwrappers/cairo/cairoft.nim
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Translation of cairo-ft.h 
-# by Jeffrey Pohlmeyer 
-# updated to version 1.4 by Luiz Américo Pereira Câmara 2007
-#
-
-import cairo, freetypeh
-
-#todo: properly define FcPattern:
-#It will require translate FontConfig header
-
-#*
-#typedef struct _XftPattern {
-#  int		    num;
-#  int		    size;
-#  XftPatternElt   *elts;
-# } XftPattern;
-# typedef FcPattern XftPattern;
-#
-
-type 
-  FcPattern* = Pointer
-  PFcPattern* = ptr FcPattern
-
-proc cairo_ft_font_face_create_for_pattern*(pattern: PFcPattern): PCairoFontFace{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ft_font_options_substitute*(options: PCairoFontOptions, 
-                                       pattern: PFcPattern){.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_ft_font_face_create_for_ft_face*(face: TFT_Face, 
-       load_flags: int32): PCairoFontFace {.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ft_scaled_font_lock_face*(
-  scaled_font: PCairoScaledFont): TFT_Face{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_ft_scaled_font_unlock_face*(
-  scaled_font: PCairoScaledFont){.cdecl, importc, dynlib: LIB_CAIRO.}
-
diff --git a/lib/oldwrappers/cairo/cairowin32.nim b/lib/oldwrappers/cairo/cairowin32.nim
deleted file mode 100755
index 5d07c2611..000000000
--- a/lib/oldwrappers/cairo/cairowin32.nim
+++ /dev/null
@@ -1,36 +0,0 @@
-
-#
-# Translation of cairo-win32.h version 1.4
-# by Luiz Américo Pereira Câmara 2007
-#
-
-import 
-  Cairo, windows
-
-proc cairo_win32_surface_create*(hdc: HDC): PCairoSurface{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_win32_surface_create_with_ddb*(hdc: HDC, format: TCairoFormat, 
-    width, height: int32): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_surface_create_with_dib*(format: TCairoFormat, 
-    width, height: int32): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_surface_get_dc*(surface: PCairoSurface): HDC{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_win32_surface_get_image*(surface: PCairoSurface): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_font_face_create_for_logfontw*(logfont: pLOGFONTW): PCairoFontFace{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_font_face_create_for_hfont*(font: HFONT): PCairoFontFace{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_scaled_font_select_font*(scaled_font: PCairoScaledFont, 
-    hdc: HDC): TCairoStatus{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_scaled_font_done_font*(scaled_font: PCairoScaledFont){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_scaled_font_get_metrics_factor*(
-    scaled_font: PCairoScaledFont): float64{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_scaled_font_get_logical_to_device*(
-    scaled_font: PCairoScaledFont, logical_to_device: PCairoMatrix){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_win32_scaled_font_get_device_to_logical*(
-    scaled_font: PCairoScaledFont, device_to_logical: PCairoMatrix){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-# implementation
diff --git a/lib/oldwrappers/cairo/cairoxlib.nim b/lib/oldwrappers/cairo/cairoxlib.nim
deleted file mode 100755
index dfe44eb87..000000000
--- a/lib/oldwrappers/cairo/cairoxlib.nim
+++ /dev/null
@@ -1,40 +0,0 @@
-
-#
-# Translation of cairo-xlib.h version 1.4
-# by Jeffrey Pohlmeyer 
-# updated to version 1.4 by Luiz Américo Pereira Câmara 2007
-#
-
-import 
-  Cairo, x, xlib, xrender
-
-proc cairo_xlib_surface_create*(dpy: PDisplay, drawable: TDrawable, 
-                                visual: PVisual, width, height: int32): PCairoSurface{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_create_for_bitmap*(dpy: PDisplay, bitmap: TPixmap, 
-    screen: PScreen, width, height: int32): PCairoSurface{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_create_with_xrender_format*(dpy: PDisplay, 
-    drawable: TDrawable, screen: PScreen, format: PXRenderPictFormat, 
-    width, height: int32): PCairoSurface{.cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_depth*(surface: PCairoSurface): int32{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_display*(surface: PCairoSurface): PDisplay{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_drawable*(surface: PCairoSurface): TDrawable{.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_height*(surface: PCairoSurface): int32{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_screen*(surface: PCairoSurface): PScreen{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_visual*(surface: PCairoSurface): PVisual{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_get_width*(surface: PCairoSurface): int32{.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_set_size*(surface: PCairoSurface, 
-                                  width, height: int32){.cdecl, importc, 
-    dynlib: LIB_CAIRO.}
-proc cairo_xlib_surface_set_drawable*(surface: PCairoSurface, 
-                                      drawable: TDrawable, width, height: int32){.
-    cdecl, importc, dynlib: LIB_CAIRO.}
-# implementation
diff --git a/lib/oldwrappers/gtk/atk.nim b/lib/oldwrappers/gtk/atk.nim
deleted file mode 100755
index ae7a34c4b..000000000
--- a/lib/oldwrappers/gtk/atk.nim
+++ /dev/null
@@ -1,1369 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2
-
-when defined(windows):
-  const
-    atklib = "libatk-1.0-0.dll"
-else:
-  const
-    atklib = "libatk-1.0.so"
-type
-  PAtkImplementor* = pointer
-  PAtkAction* = pointer
-  PAtkComponent* = pointer
-  PAtkDocument* = pointer
-  PAtkEditableText* = pointer
-  PAtkHypertext* = pointer
-  PAtkImage* = pointer
-  PAtkSelection* = pointer
-  PAtkStreamableContent* = pointer
-  PAtkTable* = pointer
-  PAtkText* = pointer
-  PAtkValue* = pointer
-  PAtkRelationSet* = ptr TAtkRelationSet
-  PAtkStateSet* = ptr TAtkStateSet
-  PAtkAttributeSet* = ptr TAtkAttributeSet
-  PAtkCoordType* = ptr TAtkCoordType
-  TAtkCoordType* = enum
-    ATK_XY_SCREEN, ATK_XY_WINDOW
-  PAtkRole* = ptr TAtkRole
-  TAtkRole* = enum
-    ATK_ROLE_INVALID, ATK_ROLE_ACCEL_LABEL, ATK_ROLE_ALERT, ATK_ROLE_ANIMATION,
-    ATK_ROLE_ARROW, ATK_ROLE_CALENDAR, ATK_ROLE_CANVAS, ATK_ROLE_CHECK_BOX,
-    ATK_ROLE_CHECK_MENU_ITEM, ATK_ROLE_COLOR_CHOOSER, ATK_ROLE_COLUMN_HEADER,
-    ATK_ROLE_COMBO_BOX, ATK_ROLE_DATE_EDITOR, ATK_ROLE_DESKTOP_ICON,
-    ATK_ROLE_DESKTOP_FRAME, ATK_ROLE_DIAL, ATK_ROLE_DIALOG,
-    ATK_ROLE_DIRECTORY_PANE, ATK_ROLE_DRAWING_AREA, ATK_ROLE_FILE_CHOOSER,
-    ATK_ROLE_FILLER, ATK_ROLE_FONT_CHOOSER, ATK_ROLE_FRAME, ATK_ROLE_GLASS_PANE,
-    ATK_ROLE_HTML_CONTAINER, ATK_ROLE_ICON, ATK_ROLE_IMAGE,
-    ATK_ROLE_INTERNAL_FRAME, ATK_ROLE_LABEL, ATK_ROLE_LAYERED_PANE,
-    ATK_ROLE_LIST, ATK_ROLE_LIST_ITEM, ATK_ROLE_MENU, ATK_ROLE_MENU_BAR,
-    ATK_ROLE_MENU_ITEM, ATK_ROLE_OPTION_PANE, ATK_ROLE_PAGE_TAB,
-    ATK_ROLE_PAGE_TAB_LIST, ATK_ROLE_PANEL, ATK_ROLE_PASSWORD_TEXT,
-    ATK_ROLE_POPUP_MENU, ATK_ROLE_PROGRESS_BAR, ATK_ROLE_PUSH_BUTTON,
-    ATK_ROLE_RADIO_BUTTON, ATK_ROLE_RADIO_MENU_ITEM, ATK_ROLE_ROOT_PANE,
-    ATK_ROLE_ROW_HEADER, ATK_ROLE_SCROLL_BAR, ATK_ROLE_SCROLL_PANE,
-    ATK_ROLE_SEPARATOR, ATK_ROLE_SLIDER, ATK_ROLE_SPLIT_PANE,
-    ATK_ROLE_SPIN_BUTTON, ATK_ROLE_STATUSBAR, ATK_ROLE_TABLE,
-    ATK_ROLE_TABLE_CELL, ATK_ROLE_TABLE_COLUMN_HEADER,
-    ATK_ROLE_TABLE_ROW_HEADER, ATK_ROLE_TEAR_OFF_MENU_ITEM, ATK_ROLE_TERMINAL,
-    ATK_ROLE_TEXT, ATK_ROLE_TOGGLE_BUTTON, ATK_ROLE_TOOL_BAR, ATK_ROLE_TOOL_TIP,
-    ATK_ROLE_TREE, ATK_ROLE_TREE_TABLE, ATK_ROLE_UNKNOWN, ATK_ROLE_VIEWPORT,
-    ATK_ROLE_WINDOW, ATK_ROLE_LAST_DEFINED
-  PAtkLayer* = ptr TAtkLayer
-  TAtkLayer* = enum
-    ATK_LAYER_INVALID, ATK_LAYER_BACKGROUND, ATK_LAYER_CANVAS, ATK_LAYER_WIDGET,
-    ATK_LAYER_MDI, ATK_LAYER_POPUP, ATK_LAYER_OVERLAY
-  PAtkPropertyValues* = ptr TAtkPropertyValues
-  TAtkPropertyValues* {.final, pure.} = object
-    property_name*: cstring
-    old_value*: TGValue
-    new_value*: TGValue
-
-  TAtkFunction* = proc (data: gpointer): gboolean{.cdecl.}
-  PAtkObject* = ptr TAtkObject
-  PPAtkObject* = ptr PAtkObject
-  TAtkObject* = object of TGObject
-    description*: cstring
-    name*: cstring
-    accessible_parent*: PAtkObject
-    role*: TAtkRole
-    relation_set*: PAtkRelationSet
-    layer*: TAtkLayer
-
-  TAtkPropertyChangeHandler* = proc (para1: PAtkObject,
-                                     para2: PAtkPropertyValues){.cdecl.}
-  PAtkObjectClass* = ptr TAtkObjectClass
-  TAtkObjectClass* = object of TGObjectClass
-    get_name*: proc (accessible: PAtkObject): cstring{.cdecl.}
-    get_description*: proc (accessible: PAtkObject): cstring{.cdecl.}
-    get_parent*: proc (accessible: PAtkObject): PAtkObject{.cdecl.}
-    get_n_children*: proc (accessible: PAtkObject): gint{.cdecl.}
-    ref_child*: proc (accessible: PAtkObject, i: gint): PAtkObject{.cdecl.}
-    get_index_in_parent*: proc (accessible: PAtkObject): gint{.cdecl.}
-    ref_relation_set*: proc (accessible: PAtkObject): PAtkRelationSet{.cdecl.}
-    get_role*: proc (accessible: PAtkObject): TAtkRole{.cdecl.}
-    get_layer*: proc (accessible: PAtkObject): TAtkLayer{.cdecl.}
-    get_mdi_zorder*: proc (accessible: PAtkObject): gint{.cdecl.}
-    ref_state_set*: proc (accessible: PAtkObject): PAtkStateSet{.cdecl.}
-    set_name*: proc (accessible: PAtkObject, name: cstring){.cdecl.}
-    set_description*: proc (accessible: PAtkObject, description: cstring){.cdecl.}
-    set_parent*: proc (accessible: PAtkObject, parent: PAtkObject){.cdecl.}
-    set_role*: proc (accessible: PAtkObject, role: TAtkRole){.cdecl.}
-    connect_property_change_handler*: proc (accessible: PAtkObject,
-        handler: TAtkPropertyChangeHandler): guint{.cdecl.}
-    remove_property_change_handler*: proc (accessible: PAtkObject,
-        handler_id: guint){.cdecl.}
-    initialize*: proc (accessible: PAtkObject, data: gpointer){.cdecl.}
-    children_changed*: proc (accessible: PAtkObject, change_index: guint,
-                             changed_child: gpointer){.cdecl.}
-    focus_event*: proc (accessible: PAtkObject, focus_in: gboolean){.cdecl.}
-    property_change*: proc (accessible: PAtkObject, values: PAtkPropertyValues){.
-        cdecl.}
-    state_change*: proc (accessible: PAtkObject, name: cstring,
-                         state_set: gboolean){.cdecl.}
-    visible_data_changed*: proc (accessible: PAtkObject){.cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-    pad3*: TAtkFunction
-    pad4*: TAtkFunction
-
-  PAtkImplementorIface* = ptr TAtkImplementorIface
-  TAtkImplementorIface* = object of TGTypeInterface
-    ref_accessible*: proc (implementor: PAtkImplementor): PAtkObject{.cdecl.}
-
-  PAtkActionIface* = ptr TAtkActionIface
-  TAtkActionIface* = object of TGTypeInterface
-    do_action*: proc (action: PAtkAction, i: gint): gboolean{.cdecl.}
-    get_n_actions*: proc (action: PAtkAction): gint{.cdecl.}
-    get_description*: proc (action: PAtkAction, i: gint): cstring{.cdecl.}
-    get_name*: proc (action: PAtkAction, i: gint): cstring{.cdecl.}
-    get_keybinding*: proc (action: PAtkAction, i: gint): cstring{.cdecl.}
-    set_description*: proc (action: PAtkAction, i: gint, desc: cstring): gboolean{.
-        cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-
-  TAtkFocusHandler* = proc (para1: PAtkObject, para2: gboolean){.cdecl.}
-  PAtkComponentIface* = ptr TAtkComponentIface
-  TAtkComponentIface* = object of TGTypeInterface
-    add_focus_handler*: proc (component: PAtkComponent,
-                              handler: TAtkFocusHandler): guint{.cdecl.}
-    contains*: proc (component: PAtkComponent, x: gint, y: gint,
-                     coord_type: TAtkCoordType): gboolean{.cdecl.}
-    ref_accessible_at_point*: proc (component: PAtkComponent, x: gint, y: gint,
-                                    coord_type: TAtkCoordType): PAtkObject{.
-        cdecl.}
-    get_extents*: proc (component: PAtkComponent, x: Pgint, y: Pgint,
-                        width: Pgint, height: Pgint, coord_type: TAtkCoordType){.
-        cdecl.}
-    get_position*: proc (component: PAtkComponent, x: Pgint, y: Pgint,
-                         coord_type: TAtkCoordType){.cdecl.}
-    get_size*: proc (component: PAtkComponent, width: Pgint, height: Pgint){.
-        cdecl.}
-    grab_focus*: proc (component: PAtkComponent): gboolean{.cdecl.}
-    remove_focus_handler*: proc (component: PAtkComponent, handler_id: guint){.
-        cdecl.}
-    set_extents*: proc (component: PAtkComponent, x: gint, y: gint, width: gint,
-                        height: gint, coord_type: TAtkCoordType): gboolean{.
-        cdecl.}
-    set_position*: proc (component: PAtkComponent, x: gint, y: gint,
-                         coord_type: TAtkCoordType): gboolean{.cdecl.}
-    set_size*: proc (component: PAtkComponent, width: gint, height: gint): gboolean{.
-        cdecl.}
-    get_layer*: proc (component: PAtkComponent): TAtkLayer{.cdecl.}
-    get_mdi_zorder*: proc (component: PAtkComponent): gint{.cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-
-  PAtkDocumentIface* = ptr TAtkDocumentIface
-  TAtkDocumentIface* = object of TGTypeInterface
-    get_document_type*: proc (document: PAtkDocument): cstring{.cdecl.}
-    get_document*: proc (document: PAtkDocument): gpointer{.cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-    pad3*: TAtkFunction
-    pad4*: TAtkFunction
-    pad5*: TAtkFunction
-    pad6*: TAtkFunction
-    pad7*: TAtkFunction
-    pad8*: TAtkFunction
-
-  PAtkEditableTextIface* = ptr TAtkEditableTextIface
-  TAtkEditableTextIface* = object of TGTypeInterface
-    set_run_attributes*: proc (text: PAtkEditableText,
-                               attrib_set: PAtkAttributeSet, start_offset: gint,
-                               end_offset: gint): gboolean{.cdecl.}
-    set_text_contents*: proc (text: PAtkEditableText, `string`: cstring){.cdecl.}
-    insert_text*: proc (text: PAtkEditableText, `string`: cstring, length: gint,
-                        position: Pgint){.cdecl.}
-    copy_text*: proc (text: PAtkEditableText, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    cut_text*: proc (text: PAtkEditableText, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    delete_text*: proc (text: PAtkEditableText, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    paste_text*: proc (text: PAtkEditableText, position: gint){.cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-
-  PAtkGObjectAccessible* = ptr TAtkGObjectAccessible
-  TAtkGObjectAccessible* = object of TAtkObject
-
-  PAtkGObjectAccessibleClass* = ptr TAtkGObjectAccessibleClass
-  TAtkGObjectAccessibleClass* = object of TAtkObjectClass
-    pad5*: TAtkFunction
-    pad6*: TAtkFunction
-
-  PAtkHyperlink* = ptr TAtkHyperlink
-  TAtkHyperlink* = object of TGObject
-
-  PAtkHyperlinkClass* = ptr TAtkHyperlinkClass
-  TAtkHyperlinkClass* = object of TGObjectClass
-    get_uri*: proc (link: PAtkHyperlink, i: gint): cstring{.cdecl.}
-    get_object*: proc (link: PAtkHyperlink, i: gint): PAtkObject{.cdecl.}
-    get_end_index*: proc (link: PAtkHyperlink): gint{.cdecl.}
-    get_start_index*: proc (link: PAtkHyperlink): gint{.cdecl.}
-    is_valid*: proc (link: PAtkHyperlink): gboolean{.cdecl.}
-    get_n_anchors*: proc (link: PAtkHyperlink): gint{.cdecl.}
-    pad7*: TAtkFunction
-    pad8*: TAtkFunction
-    pad9*: TAtkFunction
-    pad10*: TAtkFunction
-
-  PAtkHypertextIface* = ptr TAtkHypertextIface
-  TAtkHypertextIface* = object of TGTypeInterface
-    get_link*: proc (hypertext: PAtkHypertext, link_index: gint): PAtkHyperlink{.
-        cdecl.}
-    get_n_links*: proc (hypertext: PAtkHypertext): gint{.cdecl.}
-    get_link_index*: proc (hypertext: PAtkHypertext, char_index: gint): gint{.
-        cdecl.}
-    pad11*: TAtkFunction
-    pad12*: TAtkFunction
-    pad13*: TAtkFunction
-    pad14*: TAtkFunction
-
-  PAtkImageIface* = ptr TAtkImageIface
-  TAtkImageIface* = object of TGTypeInterface
-    get_image_position*: proc (image: PAtkImage, x: Pgint, y: Pgint,
-                               coord_type: TAtkCoordType){.cdecl.}
-    get_image_description*: proc (image: PAtkImage): cstring{.cdecl.}
-    get_image_size*: proc (image: PAtkImage, width: Pgint, height: Pgint){.cdecl.}
-    set_image_description*: proc (image: PAtkImage, description: cstring): gboolean{.
-        cdecl.}
-    pad15*: TAtkFunction
-    pad16*: TAtkFunction
-
-  PAtkObjectFactory* = ptr TAtkObjectFactory
-  TAtkObjectFactory* = object of TGObject
-
-  PAtkObjectFactoryClass* = ptr TAtkObjectFactoryClass
-  TAtkObjectFactoryClass* = object of TGObjectClass
-    create_accessible*: proc (obj: PGObject): PAtkObject{.cdecl.}
-    invalidate*: proc (factory: PAtkObjectFactory){.cdecl.}
-    get_accessible_type*: proc (): GType{.cdecl.}
-    pad17*: TAtkFunction
-    pad18*: TAtkFunction
-
-  PAtkRegistry* = ptr TAtkRegistry
-  TAtkRegistry* = object of TGObject
-    factory_type_registry*: PGHashTable
-    factory_singleton_cache*: PGHashTable
-
-  PAtkRegistryClass* = ptr TAtkRegistryClass
-  TAtkRegistryClass* = object of TGObjectClass
-
-  PAtkRelationType* = ptr TAtkRelationType
-  TAtkRelationType* = enum
-    ATK_RELATION_NULL, ATK_RELATION_CONTROLLED_BY, ATK_RELATION_CONTROLLER_FOR,
-    ATK_RELATION_LABEL_FOR, ATK_RELATION_LABELLED_BY, ATK_RELATION_MEMBER_OF,
-    ATK_RELATION_NODE_CHILD_OF, ATK_RELATION_LAST_DEFINED
-  PAtkRelation* = ptr TAtkRelation
-  PGPtrArray = pointer
-  TAtkRelation* = object of TGObject
-    target*: PGPtrArray
-    relationship*: TAtkRelationType
-
-  PAtkRelationClass* = ptr TAtkRelationClass
-  TAtkRelationClass* = object of TGObjectClass
-
-  TAtkRelationSet* = object of TGObject
-    relations*: PGPtrArray
-
-  PAtkRelationSetClass* = ptr TAtkRelationSetClass
-  TAtkRelationSetClass* = object of TGObjectClass
-    pad19*: TAtkFunction
-    pad20*: TAtkFunction
-
-  PAtkSelectionIface* = ptr TAtkSelectionIface
-  TAtkSelectionIface* = object of TGTypeInterface
-    add_selection*: proc (selection: PAtkSelection, i: gint): gboolean{.cdecl.}
-    clear_selection*: proc (selection: PAtkSelection): gboolean{.cdecl.}
-    ref_selection*: proc (selection: PAtkSelection, i: gint): PAtkObject{.cdecl.}
-    get_selection_count*: proc (selection: PAtkSelection): gint{.cdecl.}
-    is_child_selected*: proc (selection: PAtkSelection, i: gint): gboolean{.
-        cdecl.}
-    remove_selection*: proc (selection: PAtkSelection, i: gint): gboolean{.cdecl.}
-    select_all_selection*: proc (selection: PAtkSelection): gboolean{.cdecl.}
-    selection_changed*: proc (selection: PAtkSelection){.cdecl.}
-    pad1*: TAtkFunction
-    pad2*: TAtkFunction
-
-  PAtkStateType* = ptr TAtkStateType
-  TAtkStateType* = enum
-    ATK_STATE_INVALID, ATK_STATE_ACTIVE, ATK_STATE_ARMED, ATK_STATE_BUSY,
-    ATK_STATE_CHECKED, ATK_STATE_DEFUNCT, ATK_STATE_EDITABLE, ATK_STATE_ENABLED,
-    ATK_STATE_EXPANDABLE, ATK_STATE_EXPANDED, ATK_STATE_FOCUSABLE,
-    ATK_STATE_FOCUSED, ATK_STATE_HORIZONTAL, ATK_STATE_ICONIFIED,
-    ATK_STATE_MODAL, ATK_STATE_MULTI_LINE, ATK_STATE_MULTISELECTABLE,
-    ATK_STATE_OPAQUE, ATK_STATE_PRESSED, ATK_STATE_RESIZABLE,
-    ATK_STATE_SELECTABLE, ATK_STATE_SELECTED, ATK_STATE_SENSITIVE,
-    ATK_STATE_SHOWING, ATK_STATE_SINGLE_LINE, ATK_STATE_STALE,
-    ATK_STATE_TRANSIENT, ATK_STATE_VERTICAL, ATK_STATE_VISIBLE,
-    ATK_STATE_LAST_DEFINED
-  PAtkState* = ptr TAtkState
-  TAtkState* = guint64
-  TAtkStateSet* = object of TGObject
-
-  PAtkStateSetClass* = ptr TAtkStateSetClass
-  TAtkStateSetClass* = object of TGObjectClass
-
-  PAtkStreamableContentIface* = ptr TAtkStreamableContentIface
-  TAtkStreamableContentIface* = object of TGTypeInterface
-    get_n_mime_types*: proc (streamable: PAtkStreamableContent): gint{.cdecl.}
-    get_mime_type*: proc (streamable: PAtkStreamableContent, i: gint): cstring{.
-        cdecl.}
-    get_stream*: proc (streamable: PAtkStreamableContent, mime_type: cstring): PGIOChannel{.
-        cdecl.}
-    pad21*: TAtkFunction
-    pad22*: TAtkFunction
-    pad23*: TAtkFunction
-    pad24*: TAtkFunction
-
-  PAtkTableIface* = ptr TAtkTableIface
-  TAtkTableIface* = object of TGTypeInterface
-    ref_at*: proc (table: PAtkTable, row: gint, column: gint): PAtkObject{.cdecl.}
-    get_index_at*: proc (table: PAtkTable, row: gint, column: gint): gint{.cdecl.}
-    get_column_at_index*: proc (table: PAtkTable, index: gint): gint{.cdecl.}
-    get_row_at_index*: proc (table: PAtkTable, index: gint): gint{.cdecl.}
-    get_n_columns*: proc (table: PAtkTable): gint{.cdecl.}
-    get_n_rows*: proc (table: PAtkTable): gint{.cdecl.}
-    get_column_extent_at*: proc (table: PAtkTable, row: gint, column: gint): gint{.
-        cdecl.}
-    get_row_extent_at*: proc (table: PAtkTable, row: gint, column: gint): gint{.
-        cdecl.}
-    get_caption*: proc (table: PAtkTable): PAtkObject{.cdecl.}
-    get_column_description*: proc (table: PAtkTable, column: gint): cstring{.
-        cdecl.}
-    get_column_header*: proc (table: PAtkTable, column: gint): PAtkObject{.cdecl.}
-    get_row_description*: proc (table: PAtkTable, row: gint): cstring{.cdecl.}
-    get_row_header*: proc (table: PAtkTable, row: gint): PAtkObject{.cdecl.}
-    get_summary*: proc (table: PAtkTable): PAtkObject{.cdecl.}
-    set_caption*: proc (table: PAtkTable, caption: PAtkObject){.cdecl.}
-    set_column_description*: proc (table: PAtkTable, column: gint,
-                                   description: cstring){.cdecl.}
-    set_column_header*: proc (table: PAtkTable, column: gint, header: PAtkObject){.
-        cdecl.}
-    set_row_description*: proc (table: PAtkTable, row: gint, description: cstring){.
-        cdecl.}
-    set_row_header*: proc (table: PAtkTable, row: gint, header: PAtkObject){.
-        cdecl.}
-    set_summary*: proc (table: PAtkTable, accessible: PAtkObject){.cdecl.}
-    get_selected_columns*: proc (table: PAtkTable, selected: PPgint): gint{.
-        cdecl.}
-    get_selected_rows*: proc (table: PAtkTable, selected: PPgint): gint{.cdecl.}
-    is_column_selected*: proc (table: PAtkTable, column: gint): gboolean{.cdecl.}
-    is_row_selected*: proc (table: PAtkTable, row: gint): gboolean{.cdecl.}
-    is_selected*: proc (table: PAtkTable, row: gint, column: gint): gboolean{.
-        cdecl.}
-    add_row_selection*: proc (table: PAtkTable, row: gint): gboolean{.cdecl.}
-    remove_row_selection*: proc (table: PAtkTable, row: gint): gboolean{.cdecl.}
-    add_column_selection*: proc (table: PAtkTable, column: gint): gboolean{.
-        cdecl.}
-    remove_column_selection*: proc (table: PAtkTable, column: gint): gboolean{.
-        cdecl.}
-    row_inserted*: proc (table: PAtkTable, row: gint, num_inserted: gint){.cdecl.}
-    column_inserted*: proc (table: PAtkTable, column: gint, num_inserted: gint){.
-        cdecl.}
-    row_deleted*: proc (table: PAtkTable, row: gint, num_deleted: gint){.cdecl.}
-    column_deleted*: proc (table: PAtkTable, column: gint, num_deleted: gint){.
-        cdecl.}
-    row_reordered*: proc (table: PAtkTable){.cdecl.}
-    column_reordered*: proc (table: PAtkTable){.cdecl.}
-    model_changed*: proc (table: PAtkTable){.cdecl.}
-    pad25*: TAtkFunction
-    pad26*: TAtkFunction
-    pad27*: TAtkFunction
-    pad28*: TAtkFunction
-
-  TAtkAttributeSet* = TGSList
-  PAtkAttribute* = ptr TAtkAttribute
-  TAtkAttribute* {.final, pure.} = object
-    name*: cstring
-    value*: cstring
-
-  PAtkTextAttribute* = ptr TAtkTextAttribute
-  TAtkTextAttribute* = enum
-    ATK_TEXT_ATTR_INVALID, ATK_TEXT_ATTR_LEFT_MARGIN,
-    ATK_TEXT_ATTR_RIGHT_MARGIN, ATK_TEXT_ATTR_INDENT, ATK_TEXT_ATTR_INVISIBLE,
-    ATK_TEXT_ATTR_EDITABLE, ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
-    ATK_TEXT_ATTR_PIXELS_BELOW_LINES, ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
-    ATK_TEXT_ATTR_BG_FULL_HEIGHT, ATK_TEXT_ATTR_RISE, ATK_TEXT_ATTR_UNDERLINE,
-    ATK_TEXT_ATTR_STRIKETHROUGH, ATK_TEXT_ATTR_SIZE, ATK_TEXT_ATTR_SCALE,
-    ATK_TEXT_ATTR_WEIGHT, ATK_TEXT_ATTR_LANGUAGE, ATK_TEXT_ATTR_FAMILY_NAME,
-    ATK_TEXT_ATTR_BG_COLOR, ATK_TEXT_ATTR_FG_COLOR, ATK_TEXT_ATTR_BG_STIPPLE,
-    ATK_TEXT_ATTR_FG_STIPPLE, ATK_TEXT_ATTR_WRAP_MODE, ATK_TEXT_ATTR_DIRECTION,
-    ATK_TEXT_ATTR_JUSTIFICATION, ATK_TEXT_ATTR_STRETCH, ATK_TEXT_ATTR_VARIANT,
-    ATK_TEXT_ATTR_STYLE, ATK_TEXT_ATTR_LAST_DEFINED
-  PAtkTextBoundary* = ptr TAtkTextBoundary
-  TAtkTextBoundary* = enum
-    ATK_TEXT_BOUNDARY_CHAR, ATK_TEXT_BOUNDARY_WORD_START,
-    ATK_TEXT_BOUNDARY_WORD_END, ATK_TEXT_BOUNDARY_SENTENCE_START,
-    ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START,
-    ATK_TEXT_BOUNDARY_LINE_END
-  PAtkTextIface* = ptr TAtkTextIface
-  TAtkTextIface* = object of TGTypeInterface
-    get_text*: proc (text: PAtkText, start_offset: gint, end_offset: gint): cstring{.
-        cdecl.}
-    get_text_after_offset*: proc (text: PAtkText, offset: gint,
-                                  boundary_type: TAtkTextBoundary,
-                                  start_offset: Pgint, end_offset: Pgint): cstring{.
-        cdecl.}
-    get_text_at_offset*: proc (text: PAtkText, offset: gint,
-                               boundary_type: TAtkTextBoundary,
-                               start_offset: Pgint, end_offset: Pgint): cstring{.
-        cdecl.}
-    get_character_at_offset*: proc (text: PAtkText, offset: gint): gunichar{.
-        cdecl.}
-    get_text_before_offset*: proc (text: PAtkText, offset: gint,
-                                   boundary_type: TAtkTextBoundary,
-                                   start_offset: Pgint, end_offset: Pgint): cstring{.
-        cdecl.}
-    get_caret_offset*: proc (text: PAtkText): gint{.cdecl.}
-    get_run_attributes*: proc (text: PAtkText, offset: gint,
-                               start_offset: Pgint, end_offset: Pgint): PAtkAttributeSet{.
-        cdecl.}
-    get_default_attributes*: proc (text: PAtkText): PAtkAttributeSet{.cdecl.}
-    get_character_extents*: proc (text: PAtkText, offset: gint, x: Pgint,
-                                  y: Pgint, width: Pgint, height: Pgint,
-                                  coords: TAtkCoordType){.cdecl.}
-    get_character_count*: proc (text: PAtkText): gint{.cdecl.}
-    get_offset_at_point*: proc (text: PAtkText, x: gint, y: gint,
-                                coords: TAtkCoordType): gint{.cdecl.}
-    get_n_selections*: proc (text: PAtkText): gint{.cdecl.}
-    get_selection*: proc (text: PAtkText, selection_num: gint,
-                          start_offset: Pgint, end_offset: Pgint): cstring{.cdecl.}
-    add_selection*: proc (text: PAtkText, start_offset: gint, end_offset: gint): gboolean{.
-        cdecl.}
-    remove_selection*: proc (text: PAtkText, selection_num: gint): gboolean{.
-        cdecl.}
-    set_selection*: proc (text: PAtkText, selection_num: gint,
-                          start_offset: gint, end_offset: gint): gboolean{.cdecl.}
-    set_caret_offset*: proc (text: PAtkText, offset: gint): gboolean{.cdecl.}
-    text_changed*: proc (text: PAtkText, position: gint, length: gint){.cdecl.}
-    text_caret_moved*: proc (text: PAtkText, location: gint){.cdecl.}
-    text_selection_changed*: proc (text: PAtkText){.cdecl.}
-    pad29*: TAtkFunction
-    pad30*: TAtkFunction
-    pad31*: TAtkFunction
-    pad32*: TAtkFunction
-
-  TAtkEventListener* = proc (para1: PAtkObject){.cdecl.}
-  TAtkEventListenerInitProc* = proc ()
-  TAtkEventListenerInit* = proc (para1: TAtkEventListenerInitProc){.cdecl.}
-  PAtkKeyEventStruct* = ptr TAtkKeyEventStruct
-  TAtkKeyEventStruct* {.final, pure.} = object
-    `type`*: gint
-    state*: guint
-    keyval*: guint
-    length*: gint
-    string*: cstring
-    keycode*: guint16
-    timestamp*: guint32
-
-  TAtkKeySnoopFunc* = proc (event: PAtkKeyEventStruct, func_data: gpointer): gint{.
-      cdecl.}
-  PAtkKeyEventType* = ptr TAtkKeyEventType
-  TAtkKeyEventType* = enum
-    ATK_KEY_EVENT_PRESS, ATK_KEY_EVENT_RELEASE, ATK_KEY_EVENT_LAST_DEFINED
-  PAtkUtil* = ptr TAtkUtil
-  TAtkUtil* = object of TGObject
-
-  PAtkUtilClass* = ptr TAtkUtilClass
-  TAtkUtilClass* = object of TGObjectClass
-    add_global_event_listener*: proc (listener: TGSignalEmissionHook,
-                                      event_type: cstring): guint{.cdecl.}
-    remove_global_event_listener*: proc (listener_id: guint){.cdecl.}
-    add_key_event_listener*: proc (listener: TAtkKeySnoopFunc, data: gpointer): guint{.
-        cdecl.}
-    remove_key_event_listener*: proc (listener_id: guint){.cdecl.}
-    get_root*: proc (): PAtkObject{.cdecl.}
-    get_toolkit_name*: proc (): cstring{.cdecl.}
-    get_toolkit_version*: proc (): cstring{.cdecl.}
-
-  PAtkValueIface* = ptr TAtkValueIface
-  TAtkValueIface* = object of TGTypeInterface
-    get_current_value*: proc (obj: PAtkValue, value: PGValue){.cdecl.}
-    get_maximum_value*: proc (obj: PAtkValue, value: PGValue){.cdecl.}
-    get_minimum_value*: proc (obj: PAtkValue, value: PGValue){.cdecl.}
-    set_current_value*: proc (obj: PAtkValue, value: PGValue): gboolean{.cdecl.}
-    pad33*: TAtkFunction
-    pad34*: TAtkFunction
-
-
-proc atk_role_register*(name: cstring): TAtkRole{.cdecl, dynlib: atklib,
-    importc: "atk_role_register".}
-proc atk_object_get_type*(): GType{.cdecl, dynlib: atklib,
-                                    importc: "atk_object_get_type".}
-proc ATK_TYPE_OBJECT*(): GType
-proc ATK_OBJECT*(obj: pointer): PAtkObject
-proc ATK_OBJECT_CLASS*(klass: pointer): PAtkObjectClass
-proc ATK_IS_OBJECT*(obj: pointer): bool
-proc ATK_IS_OBJECT_CLASS*(klass: pointer): bool
-proc ATK_OBJECT_GET_CLASS*(obj: pointer): PAtkObjectClass
-proc ATK_TYPE_IMPLEMENTOR*(): GType
-proc ATK_IS_IMPLEMENTOR*(obj: pointer): bool
-proc ATK_IMPLEMENTOR*(obj: pointer): PAtkImplementor
-proc ATK_IMPLEMENTOR_GET_IFACE*(obj: pointer): PAtkImplementorIface
-proc atk_implementor_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_implementor_get_type".}
-proc atk_implementor_ref_accessible*(implementor: PAtkImplementor): PAtkObject{.
-    cdecl, dynlib: atklib, importc: "atk_implementor_ref_accessible".}
-proc atk_object_get_name*(accessible: PAtkObject): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_name".}
-proc atk_object_get_description*(accessible: PAtkObject): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_description".}
-proc atk_object_get_parent*(accessible: PAtkObject): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_parent".}
-proc atk_object_get_n_accessible_children*(accessible: PAtkObject): gint{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_n_accessible_children".}
-proc atk_object_ref_accessible_child*(accessible: PAtkObject, i: gint): PAtkObject{.
-    cdecl, dynlib: atklib, importc: "atk_object_ref_accessible_child".}
-proc atk_object_ref_relation_set*(accessible: PAtkObject): PAtkRelationSet{.
-    cdecl, dynlib: atklib, importc: "atk_object_ref_relation_set".}
-proc atk_object_get_role*(accessible: PAtkObject): TAtkRole{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_role".}
-proc atk_object_get_layer*(accessible: PAtkObject): TAtkLayer{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_layer".}
-proc atk_object_get_mdi_zorder*(accessible: PAtkObject): gint{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_mdi_zorder".}
-proc atk_object_ref_state_set*(accessible: PAtkObject): PAtkStateSet{.cdecl,
-    dynlib: atklib, importc: "atk_object_ref_state_set".}
-proc atk_object_get_index_in_parent*(accessible: PAtkObject): gint{.cdecl,
-    dynlib: atklib, importc: "atk_object_get_index_in_parent".}
-proc atk_object_set_name*(accessible: PAtkObject, name: cstring){.cdecl,
-    dynlib: atklib, importc: "atk_object_set_name".}
-proc atk_object_set_description*(accessible: PAtkObject, description: cstring){.
-    cdecl, dynlib: atklib, importc: "atk_object_set_description".}
-proc atk_object_set_parent*(accessible: PAtkObject, parent: PAtkObject){.cdecl,
-    dynlib: atklib, importc: "atk_object_set_parent".}
-proc atk_object_set_role*(accessible: PAtkObject, role: TAtkRole){.cdecl,
-    dynlib: atklib, importc: "atk_object_set_role".}
-proc atk_object_connect_property_change_handler*(accessible: PAtkObject,
-    handler: TAtkPropertyChangeHandler): guint{.cdecl, dynlib: atklib,
-    importc: "atk_object_connect_property_change_handler".}
-proc atk_object_remove_property_change_handler*(accessible: PAtkObject,
-    handler_id: guint){.cdecl, dynlib: atklib,
-                        importc: "atk_object_remove_property_change_handler".}
-proc atk_object_notify_state_change*(accessible: PAtkObject, state: TAtkState,
-                                     value: gboolean){.cdecl, dynlib: atklib,
-    importc: "atk_object_notify_state_change".}
-proc atk_object_initialize*(accessible: PAtkObject, data: gpointer){.cdecl,
-    dynlib: atklib, importc: "atk_object_initialize".}
-proc atk_role_get_name*(role: TAtkRole): cstring{.cdecl, dynlib: atklib,
-    importc: "atk_role_get_name".}
-proc atk_role_for_name*(name: cstring): TAtkRole{.cdecl, dynlib: atklib,
-    importc: "atk_role_for_name".}
-proc ATK_TYPE_ACTION*(): GType
-proc ATK_IS_ACTION*(obj: pointer): bool
-proc ATK_ACTION*(obj: pointer): PAtkAction
-proc ATK_ACTION_GET_IFACE*(obj: pointer): PAtkActionIface
-proc atk_action_get_type*(): GType{.cdecl, dynlib: atklib,
-                                    importc: "atk_action_get_type".}
-proc atk_action_do_action*(action: PAtkAction, i: gint): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_action_do_action".}
-proc atk_action_get_n_actions*(action: PAtkAction): gint{.cdecl, dynlib: atklib,
-    importc: "atk_action_get_n_actions".}
-proc atk_action_get_description*(action: PAtkAction, i: gint): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_action_get_description".}
-proc atk_action_get_name*(action: PAtkAction, i: gint): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_action_get_name".}
-proc atk_action_get_keybinding*(action: PAtkAction, i: gint): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_action_get_keybinding".}
-proc atk_action_set_description*(action: PAtkAction, i: gint, desc: cstring): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_action_set_description".}
-proc ATK_TYPE_COMPONENT*(): GType
-proc ATK_IS_COMPONENT*(obj: pointer): bool
-proc ATK_COMPONENT*(obj: pointer): PAtkComponent
-proc ATK_COMPONENT_GET_IFACE*(obj: pointer): PAtkComponentIface
-proc atk_component_get_type*(): GType{.cdecl, dynlib: atklib,
-                                       importc: "atk_component_get_type".}
-proc atk_component_add_focus_handler*(component: PAtkComponent,
-                                      handler: TAtkFocusHandler): guint{.cdecl,
-    dynlib: atklib, importc: "atk_component_add_focus_handler".}
-proc atk_component_contains*(component: PAtkComponent, x, y: gint,
-                             coord_type: TAtkCoordType): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_component_contains".}
-proc atk_component_ref_accessible_at_point*(component: PAtkComponent,
-    x, y: gint, coord_type: TAtkCoordType): PAtkObject{.cdecl, dynlib: atklib,
-    importc: "atk_component_ref_accessible_at_point".}
-proc atk_component_get_extents*(component: PAtkComponent,
-                                x, y, width, height: Pgint,
-                                coord_type: TAtkCoordType){.cdecl,
-    dynlib: atklib, importc: "atk_component_get_extents".}
-proc atk_component_get_position*(component: PAtkComponent, x: Pgint, y: Pgint,
-                                 coord_type: TAtkCoordType){.cdecl,
-    dynlib: atklib, importc: "atk_component_get_position".}
-proc atk_component_get_size*(component: PAtkComponent, width: Pgint,
-                             height: Pgint){.cdecl, dynlib: atklib,
-    importc: "atk_component_get_size".}
-proc atk_component_get_layer*(component: PAtkComponent): TAtkLayer{.cdecl,
-    dynlib: atklib, importc: "atk_component_get_layer".}
-proc atk_component_get_mdi_zorder*(component: PAtkComponent): gint{.cdecl,
-    dynlib: atklib, importc: "atk_component_get_mdi_zorder".}
-proc atk_component_grab_focus*(component: PAtkComponent): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_component_grab_focus".}
-proc atk_component_remove_focus_handler*(component: PAtkComponent,
-    handler_id: guint){.cdecl, dynlib: atklib,
-                        importc: "atk_component_remove_focus_handler".}
-proc atk_component_set_extents*(component: PAtkComponent, x: gint, y: gint,
-                                width: gint, height: gint,
-                                coord_type: TAtkCoordType): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_component_set_extents".}
-proc atk_component_set_position*(component: PAtkComponent, x: gint, y: gint,
-                                 coord_type: TAtkCoordType): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_component_set_position".}
-proc atk_component_set_size*(component: PAtkComponent, width: gint, height: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_component_set_size".}
-proc ATK_TYPE_DOCUMENT*(): GType
-proc ATK_IS_DOCUMENT*(obj: pointer): bool
-proc ATK_DOCUMENT*(obj: pointer): PAtkDocument
-proc ATK_DOCUMENT_GET_IFACE*(obj: pointer): PAtkDocumentIface
-proc atk_document_get_type*(): GType{.cdecl, dynlib: atklib,
-                                      importc: "atk_document_get_type".}
-proc atk_document_get_document_type*(document: PAtkDocument): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_document_get_document_type".}
-proc atk_document_get_document*(document: PAtkDocument): gpointer{.cdecl,
-    dynlib: atklib, importc: "atk_document_get_document".}
-proc ATK_TYPE_EDITABLE_TEXT*(): GType
-proc ATK_IS_EDITABLE_TEXT*(obj: pointer): bool
-proc ATK_EDITABLE_TEXT*(obj: pointer): PAtkEditableText
-proc ATK_EDITABLE_TEXT_GET_IFACE*(obj: pointer): PAtkEditableTextIface
-proc atk_editable_text_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_editable_text_get_type".}
-proc atk_editable_text_set_run_attributes*(text: PAtkEditableText,
-    attrib_set: PAtkAttributeSet, start_offset: gint, end_offset: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_editable_text_set_run_attributes".}
-proc atk_editable_text_set_text_contents*(text: PAtkEditableText, string: cstring){.
-    cdecl, dynlib: atklib, importc: "atk_editable_text_set_text_contents".}
-proc atk_editable_text_insert_text*(text: PAtkEditableText, `string`: cstring,
-                                    length: gint, position: Pgint){.cdecl,
-    dynlib: atklib, importc: "atk_editable_text_insert_text".}
-proc atk_editable_text_copy_text*(text: PAtkEditableText, start_pos: gint,
-                                  end_pos: gint){.cdecl, dynlib: atklib,
-    importc: "atk_editable_text_copy_text".}
-proc atk_editable_text_cut_text*(text: PAtkEditableText, start_pos: gint,
-                                 end_pos: gint){.cdecl, dynlib: atklib,
-    importc: "atk_editable_text_cut_text".}
-proc atk_editable_text_delete_text*(text: PAtkEditableText, start_pos: gint,
-                                    end_pos: gint){.cdecl, dynlib: atklib,
-    importc: "atk_editable_text_delete_text".}
-proc atk_editable_text_paste_text*(text: PAtkEditableText, position: gint){.
-    cdecl, dynlib: atklib, importc: "atk_editable_text_paste_text".}
-proc ATK_TYPE_GOBJECT_ACCESSIBLE*(): GType
-proc ATK_GOBJECT_ACCESSIBLE*(obj: pointer): PAtkGObjectAccessible
-proc ATK_GOBJECT_ACCESSIBLE_CLASS*(klass: pointer): PAtkGObjectAccessibleClass
-proc ATK_IS_GOBJECT_ACCESSIBLE*(obj: pointer): bool
-proc ATK_IS_GOBJECT_ACCESSIBLE_CLASS*(klass: pointer): bool
-proc ATK_GOBJECT_ACCESSIBLE_GET_CLASS*(obj: pointer): PAtkGObjectAccessibleClass
-proc atk_gobject_accessible_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_gobject_accessible_get_type".}
-proc atk_gobject_accessible_for_object*(obj: PGObject): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_gobject_accessible_for_object".}
-proc atk_gobject_accessible_get_object*(obj: PAtkGObjectAccessible): PGObject{.
-    cdecl, dynlib: atklib, importc: "atk_gobject_accessible_get_object".}
-proc ATK_TYPE_HYPERLINK*(): GType
-proc ATK_HYPERLINK*(obj: pointer): PAtkHyperlink
-proc ATK_HYPERLINK_CLASS*(klass: pointer): PAtkHyperlinkClass
-proc ATK_IS_HYPERLINK*(obj: pointer): bool
-proc ATK_IS_HYPERLINK_CLASS*(klass: pointer): bool
-proc ATK_HYPERLINK_GET_CLASS*(obj: pointer): PAtkHyperlinkClass
-proc atk_hyperlink_get_type*(): GType{.cdecl, dynlib: atklib,
-                                       importc: "atk_hyperlink_get_type".}
-proc atk_hyperlink_get_uri*(link: PAtkHyperlink, i: gint): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_get_uri".}
-proc atk_hyperlink_get_object*(link: PAtkHyperlink, i: gint): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_get_object".}
-proc atk_hyperlink_get_end_index*(link: PAtkHyperlink): gint{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_get_end_index".}
-proc atk_hyperlink_get_start_index*(link: PAtkHyperlink): gint{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_get_start_index".}
-proc atk_hyperlink_is_valid*(link: PAtkHyperlink): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_is_valid".}
-proc atk_hyperlink_get_n_anchors*(link: PAtkHyperlink): gint{.cdecl,
-    dynlib: atklib, importc: "atk_hyperlink_get_n_anchors".}
-proc ATK_TYPE_HYPERTEXT*(): GType
-proc ATK_IS_HYPERTEXT*(obj: pointer): bool
-proc ATK_HYPERTEXT*(obj: pointer): PAtkHypertext
-proc ATK_HYPERTEXT_GET_IFACE*(obj: pointer): PAtkHypertextIface
-proc atk_hypertext_get_type*(): GType{.cdecl, dynlib: atklib,
-                                       importc: "atk_hypertext_get_type".}
-proc atk_hypertext_get_link*(hypertext: PAtkHypertext, link_index: gint): PAtkHyperlink{.
-    cdecl, dynlib: atklib, importc: "atk_hypertext_get_link".}
-proc atk_hypertext_get_n_links*(hypertext: PAtkHypertext): gint{.cdecl,
-    dynlib: atklib, importc: "atk_hypertext_get_n_links".}
-proc atk_hypertext_get_link_index*(hypertext: PAtkHypertext, char_index: gint): gint{.
-    cdecl, dynlib: atklib, importc: "atk_hypertext_get_link_index".}
-proc ATK_TYPE_IMAGE*(): GType
-proc ATK_IS_IMAGE*(obj: pointer): bool
-proc ATK_IMAGE*(obj: pointer): PAtkImage
-proc ATK_IMAGE_GET_IFACE*(obj: pointer): PAtkImageIface
-proc atk_image_get_type*(): GType{.cdecl, dynlib: atklib,
-                                   importc: "atk_image_get_type".}
-proc atk_image_get_image_description*(image: PAtkImage): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_image_get_image_description".}
-proc atk_image_get_image_size*(image: PAtkImage, width: Pgint, height: Pgint){.
-    cdecl, dynlib: atklib, importc: "atk_image_get_image_size".}
-proc atk_image_set_image_description*(image: PAtkImage, description: cstring): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_image_set_image_description".}
-proc atk_image_get_image_position*(image: PAtkImage, x: Pgint, y: Pgint,
-                                   coord_type: TAtkCoordType){.cdecl,
-    dynlib: atklib, importc: "atk_image_get_image_position".}
-proc ATK_TYPE_OBJECT_FACTORY*(): GType
-proc ATK_OBJECT_FACTORY*(obj: pointer): PAtkObjectFactory
-proc ATK_OBJECT_FACTORY_CLASS*(klass: pointer): PAtkObjectFactoryClass
-proc ATK_IS_OBJECT_FACTORY*(obj: pointer): bool
-proc ATK_IS_OBJECT_FACTORY_CLASS*(klass: pointer): bool
-proc ATK_OBJECT_FACTORY_GET_CLASS*(obj: pointer): PAtkObjectFactoryClass
-proc atk_object_factory_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_object_factory_get_type".}
-proc atk_object_factory_create_accessible*(factory: PAtkObjectFactory,
-    obj: PGObject): PAtkObject{.cdecl, dynlib: atklib,
-                                importc: "atk_object_factory_create_accessible".}
-proc atk_object_factory_invalidate*(factory: PAtkObjectFactory){.cdecl,
-    dynlib: atklib, importc: "atk_object_factory_invalidate".}
-proc atk_object_factory_get_accessible_type*(factory: PAtkObjectFactory): GType{.
-    cdecl, dynlib: atklib, importc: "atk_object_factory_get_accessible_type".}
-proc ATK_TYPE_REGISTRY*(): GType
-proc ATK_REGISTRY*(obj: pointer): PAtkRegistry
-proc ATK_REGISTRY_CLASS*(klass: pointer): PAtkRegistryClass
-proc ATK_IS_REGISTRY*(obj: pointer): bool
-proc ATK_IS_REGISTRY_CLASS*(klass: pointer): bool
-proc ATK_REGISTRY_GET_CLASS*(obj: pointer): PAtkRegistryClass
-proc atk_registry_get_type*(): GType{.cdecl, dynlib: atklib,
-                                      importc: "atk_registry_get_type".}
-proc atk_registry_set_factory_type*(registry: PAtkRegistry, `type`: GType,
-                                    factory_type: GType){.cdecl, dynlib: atklib,
-    importc: "atk_registry_set_factory_type".}
-proc atk_registry_get_factory_type*(registry: PAtkRegistry, `type`: GType): GType{.
-    cdecl, dynlib: atklib, importc: "atk_registry_get_factory_type".}
-proc atk_registry_get_factory*(registry: PAtkRegistry, `type`: GType): PAtkObjectFactory{.
-    cdecl, dynlib: atklib, importc: "atk_registry_get_factory".}
-proc atk_get_default_registry*(): PAtkRegistry{.cdecl, dynlib: atklib,
-    importc: "atk_get_default_registry".}
-proc ATK_TYPE_RELATION*(): GType
-proc ATK_RELATION*(obj: pointer): PAtkRelation
-proc ATK_RELATION_CLASS*(klass: pointer): PAtkRelationClass
-proc ATK_IS_RELATION*(obj: pointer): bool
-proc ATK_IS_RELATION_CLASS*(klass: pointer): bool
-proc ATK_RELATION_GET_CLASS*(obj: pointer): PAtkRelationClass
-proc atk_relation_get_type*(): GType{.cdecl, dynlib: atklib,
-                                      importc: "atk_relation_get_type".}
-proc atk_relation_type_register*(name: cstring): TAtkRelationType{.cdecl,
-    dynlib: atklib, importc: "atk_relation_type_register".}
-proc atk_relation_type_get_name*(`type`: TAtkRelationType): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_relation_type_get_name".}
-proc atk_relation_type_for_name*(name: cstring): TAtkRelationType{.cdecl,
-    dynlib: atklib, importc: "atk_relation_type_for_name".}
-proc atk_relation_new*(targets: PPAtkObject, n_targets: gint,
-                       relationship: TAtkRelationType): PAtkRelation{.cdecl,
-    dynlib: atklib, importc: "atk_relation_new".}
-proc atk_relation_get_relation_type*(relation: PAtkRelation): TAtkRelationType{.
-    cdecl, dynlib: atklib, importc: "atk_relation_get_relation_type".}
-proc atk_relation_get_target*(relation: PAtkRelation): PGPtrArray{.cdecl,
-    dynlib: atklib, importc: "atk_relation_get_target".}
-proc ATK_TYPE_RELATION_SET*(): GType
-proc ATK_RELATION_SET*(obj: pointer): PAtkRelationSet
-proc ATK_RELATION_SET_CLASS*(klass: pointer): PAtkRelationSetClass
-proc ATK_IS_RELATION_SET*(obj: pointer): bool
-proc ATK_IS_RELATION_SET_CLASS*(klass: pointer): bool
-proc ATK_RELATION_SET_GET_CLASS*(obj: pointer): PAtkRelationSetClass
-proc atk_relation_set_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_relation_set_get_type".}
-proc atk_relation_set_new*(): PAtkRelationSet{.cdecl, dynlib: atklib,
-    importc: "atk_relation_set_new".}
-proc atk_relation_set_contains*(RelationSet: PAtkRelationSet,
-                                relationship: TAtkRelationType): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_relation_set_contains".}
-proc atk_relation_set_remove*(RelationSet: PAtkRelationSet,
-                              relation: PAtkRelation){.cdecl, dynlib: atklib,
-    importc: "atk_relation_set_remove".}
-proc atk_relation_set_add*(RelationSet: PAtkRelationSet, relation: PAtkRelation){.
-    cdecl, dynlib: atklib, importc: "atk_relation_set_add".}
-proc atk_relation_set_get_n_relations*(RelationSet: PAtkRelationSet): gint{.
-    cdecl, dynlib: atklib, importc: "atk_relation_set_get_n_relations".}
-proc atk_relation_set_get_relation*(RelationSet: PAtkRelationSet, i: gint): PAtkRelation{.
-    cdecl, dynlib: atklib, importc: "atk_relation_set_get_relation".}
-proc atk_relation_set_get_relation_by_type*(RelationSet: PAtkRelationSet,
-    relationship: TAtkRelationType): PAtkRelation{.cdecl, dynlib: atklib,
-    importc: "atk_relation_set_get_relation_by_type".}
-proc ATK_TYPE_SELECTION*(): GType
-proc ATK_IS_SELECTION*(obj: pointer): bool
-proc ATK_SELECTION*(obj: pointer): PAtkSelection
-proc ATK_SELECTION_GET_IFACE*(obj: pointer): PAtkSelectionIface
-proc atk_selection_get_type*(): GType{.cdecl, dynlib: atklib,
-                                       importc: "atk_selection_get_type".}
-proc atk_selection_add_selection*(selection: PAtkSelection, i: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_selection_add_selection".}
-proc atk_selection_clear_selection*(selection: PAtkSelection): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_selection_clear_selection".}
-proc atk_selection_ref_selection*(selection: PAtkSelection, i: gint): PAtkObject{.
-    cdecl, dynlib: atklib, importc: "atk_selection_ref_selection".}
-proc atk_selection_get_selection_count*(selection: PAtkSelection): gint{.cdecl,
-    dynlib: atklib, importc: "atk_selection_get_selection_count".}
-proc atk_selection_is_child_selected*(selection: PAtkSelection, i: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_selection_is_child_selected".}
-proc atk_selection_remove_selection*(selection: PAtkSelection, i: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_selection_remove_selection".}
-proc atk_selection_select_all_selection*(selection: PAtkSelection): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_selection_select_all_selection".}
-proc atk_state_type_register*(name: cstring): TAtkStateType{.cdecl,
-    dynlib: atklib, importc: "atk_state_type_register".}
-proc atk_state_type_get_name*(`type`: TAtkStateType): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_state_type_get_name".}
-proc atk_state_type_for_name*(name: cstring): TAtkStateType{.cdecl,
-    dynlib: atklib, importc: "atk_state_type_for_name".}
-proc ATK_TYPE_STATE_SET*(): GType
-proc ATK_STATE_SET*(obj: pointer): PAtkStateSet
-proc ATK_STATE_SET_CLASS*(klass: pointer): PAtkStateSetClass
-proc ATK_IS_STATE_SET*(obj: pointer): bool
-proc ATK_IS_STATE_SET_CLASS*(klass: pointer): bool
-proc ATK_STATE_SET_GET_CLASS*(obj: pointer): PAtkStateSetClass
-proc atk_state_set_get_type*(): GType{.cdecl, dynlib: atklib,
-                                       importc: "atk_state_set_get_type".}
-proc atk_state_set_new*(): PAtkStateSet{.cdecl, dynlib: atklib,
-    importc: "atk_state_set_new".}
-proc atk_state_set_is_empty*(StateSet: PAtkStateSet): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_state_set_is_empty".}
-proc atk_state_set_add_state*(StateSet: PAtkStateSet, `type`: TAtkStateType): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_add_state".}
-proc atk_state_set_add_states*(StateSet: PAtkStateSet, types: PAtkStateType,
-                               n_types: gint){.cdecl, dynlib: atklib,
-    importc: "atk_state_set_add_states".}
-proc atk_state_set_clear_states*(StateSet: PAtkStateSet){.cdecl, dynlib: atklib,
-    importc: "atk_state_set_clear_states".}
-proc atk_state_set_contains_state*(StateSet: PAtkStateSet, `type`: TAtkStateType): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_contains_state".}
-proc atk_state_set_contains_states*(StateSet: PAtkStateSet,
-                                    types: PAtkStateType, n_types: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_contains_states".}
-proc atk_state_set_remove_state*(StateSet: PAtkStateSet, `type`: TAtkStateType): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_remove_state".}
-proc atk_state_set_and_sets*(StateSet: PAtkStateSet, compare_set: PAtkStateSet): PAtkStateSet{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_and_sets".}
-proc atk_state_set_or_sets*(StateSet: PAtkStateSet, compare_set: PAtkStateSet): PAtkStateSet{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_or_sets".}
-proc atk_state_set_xor_sets*(StateSet: PAtkStateSet, compare_set: PAtkStateSet): PAtkStateSet{.
-    cdecl, dynlib: atklib, importc: "atk_state_set_xor_sets".}
-proc ATK_TYPE_STREAMABLE_CONTENT*(): GType
-proc ATK_IS_STREAMABLE_CONTENT*(obj: pointer): bool
-proc ATK_STREAMABLE_CONTENT*(obj: pointer): PAtkStreamableContent
-proc ATK_STREAMABLE_CONTENT_GET_IFACE*(obj: pointer): PAtkStreamableContentIface
-proc atk_streamable_content_get_type*(): GType{.cdecl, dynlib: atklib,
-    importc: "atk_streamable_content_get_type".}
-proc atk_streamable_content_get_n_mime_types*(streamable: PAtkStreamableContent): gint{.
-    cdecl, dynlib: atklib, importc: "atk_streamable_content_get_n_mime_types".}
-proc atk_streamable_content_get_mime_type*(streamable: PAtkStreamableContent,
-    i: gint): cstring{.cdecl, dynlib: atklib,
-                      importc: "atk_streamable_content_get_mime_type".}
-proc atk_streamable_content_get_stream*(streamable: PAtkStreamableContent,
-                                        mime_type: cstring): PGIOChannel{.cdecl,
-    dynlib: atklib, importc: "atk_streamable_content_get_stream".}
-proc ATK_TYPE_TABLE*(): GType
-proc ATK_IS_TABLE*(obj: pointer): bool
-proc ATK_TABLE*(obj: pointer): PAtkTable
-proc ATK_TABLE_GET_IFACE*(obj: pointer): PAtkTableIface
-proc atk_table_get_type*(): GType{.cdecl, dynlib: atklib,
-                                   importc: "atk_table_get_type".}
-proc atk_table_ref_at*(table: PAtkTable, row, column: gint): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_table_ref_at".}
-proc atk_table_get_index_at*(table: PAtkTable, row, column: gint): gint{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_index_at".}
-proc atk_table_get_column_at_index*(table: PAtkTable, index: gint): gint{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_column_at_index".}
-proc atk_table_get_row_at_index*(table: PAtkTable, index: gint): gint{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_row_at_index".}
-proc atk_table_get_n_columns*(table: PAtkTable): gint{.cdecl, dynlib: atklib,
-    importc: "atk_table_get_n_columns".}
-proc atk_table_get_n_rows*(table: PAtkTable): gint{.cdecl, dynlib: atklib,
-    importc: "atk_table_get_n_rows".}
-proc atk_table_get_column_extent_at*(table: PAtkTable, row: gint, column: gint): gint{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_column_extent_at".}
-proc atk_table_get_row_extent_at*(table: PAtkTable, row: gint, column: gint): gint{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_row_extent_at".}
-proc atk_table_get_caption*(table: PAtkTable): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_caption".}
-proc atk_table_get_column_description*(table: PAtkTable, column: gint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_column_description".}
-proc atk_table_get_column_header*(table: PAtkTable, column: gint): PAtkObject{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_column_header".}
-proc atk_table_get_row_description*(table: PAtkTable, row: gint): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_row_description".}
-proc atk_table_get_row_header*(table: PAtkTable, row: gint): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_row_header".}
-proc atk_table_get_summary*(table: PAtkTable): PAtkObject{.cdecl,
-    dynlib: atklib, importc: "atk_table_get_summary".}
-proc atk_table_set_caption*(table: PAtkTable, caption: PAtkObject){.cdecl,
-    dynlib: atklib, importc: "atk_table_set_caption".}
-proc atk_table_set_column_description*(table: PAtkTable, column: gint,
-                                       description: cstring){.cdecl,
-    dynlib: atklib, importc: "atk_table_set_column_description".}
-proc atk_table_set_column_header*(table: PAtkTable, column: gint,
-                                  header: PAtkObject){.cdecl, dynlib: atklib,
-    importc: "atk_table_set_column_header".}
-proc atk_table_set_row_description*(table: PAtkTable, row: gint,
-                                    description: cstring){.cdecl, dynlib: atklib,
-    importc: "atk_table_set_row_description".}
-proc atk_table_set_row_header*(table: PAtkTable, row: gint, header: PAtkObject){.
-    cdecl, dynlib: atklib, importc: "atk_table_set_row_header".}
-proc atk_table_set_summary*(table: PAtkTable, accessible: PAtkObject){.cdecl,
-    dynlib: atklib, importc: "atk_table_set_summary".}
-proc atk_table_get_selected_columns*(table: PAtkTable, selected: PPgint): gint{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_selected_columns".}
-proc atk_table_get_selected_rows*(table: PAtkTable, selected: PPgint): gint{.
-    cdecl, dynlib: atklib, importc: "atk_table_get_selected_rows".}
-proc atk_table_is_column_selected*(table: PAtkTable, column: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_table_is_column_selected".}
-proc atk_table_is_row_selected*(table: PAtkTable, row: gint): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_table_is_row_selected".}
-proc atk_table_is_selected*(table: PAtkTable, row: gint, column: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_table_is_selected".}
-proc atk_table_add_row_selection*(table: PAtkTable, row: gint): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_table_add_row_selection".}
-proc atk_table_remove_row_selection*(table: PAtkTable, row: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_table_remove_row_selection".}
-proc atk_table_add_column_selection*(table: PAtkTable, column: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_table_add_column_selection".}
-proc atk_table_remove_column_selection*(table: PAtkTable, column: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_table_remove_column_selection".}
-proc atk_text_attribute_register*(name: cstring): TAtkTextAttribute{.cdecl,
-    dynlib: atklib, importc: "atk_text_attribute_register".}
-proc ATK_TYPE_TEXT*(): GType
-proc ATK_IS_TEXT*(obj: pointer): bool
-proc ATK_TEXT*(obj: pointer): PAtkText
-proc ATK_TEXT_GET_IFACE*(obj: pointer): PAtkTextIface
-proc atk_text_get_type*(): GType{.cdecl, dynlib: atklib,
-                                  importc: "atk_text_get_type".}
-proc atk_text_get_text*(text: PAtkText, start_offset: gint, end_offset: gint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_text".}
-proc atk_text_get_character_at_offset*(text: PAtkText, offset: gint): gunichar{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_character_at_offset".}
-proc atk_text_get_text_after_offset*(text: PAtkText, offset: gint,
-                                     boundary_type: TAtkTextBoundary,
-                                     start_offset: Pgint, end_offset: Pgint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_text_after_offset".}
-proc atk_text_get_text_at_offset*(text: PAtkText, offset: gint,
-                                  boundary_type: TAtkTextBoundary,
-                                  start_offset: Pgint, end_offset: Pgint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_text_at_offset".}
-proc atk_text_get_text_before_offset*(text: PAtkText, offset: gint,
-                                      boundary_type: TAtkTextBoundary,
-                                      start_offset: Pgint, end_offset: Pgint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_text_before_offset".}
-proc atk_text_get_caret_offset*(text: PAtkText): gint{.cdecl, dynlib: atklib,
-    importc: "atk_text_get_caret_offset".}
-proc atk_text_get_character_extents*(text: PAtkText, offset: gint, x: Pgint,
-                                     y: Pgint, width: Pgint, height: Pgint,
-                                     coords: TAtkCoordType){.cdecl,
-    dynlib: atklib, importc: "atk_text_get_character_extents".}
-proc atk_text_get_run_attributes*(text: PAtkText, offset: gint,
-                                  start_offset: Pgint, end_offset: Pgint): PAtkAttributeSet{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_run_attributes".}
-proc atk_text_get_default_attributes*(text: PAtkText): PAtkAttributeSet{.cdecl,
-    dynlib: atklib, importc: "atk_text_get_default_attributes".}
-proc atk_text_get_character_count*(text: PAtkText): gint{.cdecl, dynlib: atklib,
-    importc: "atk_text_get_character_count".}
-proc atk_text_get_offset_at_point*(text: PAtkText, x: gint, y: gint,
-                                   coords: TAtkCoordType): gint{.cdecl,
-    dynlib: atklib, importc: "atk_text_get_offset_at_point".}
-proc atk_text_get_n_selections*(text: PAtkText): gint{.cdecl, dynlib: atklib,
-    importc: "atk_text_get_n_selections".}
-proc atk_text_get_selection*(text: PAtkText, selection_num: gint,
-                             start_offset: Pgint, end_offset: Pgint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_get_selection".}
-proc atk_text_add_selection*(text: PAtkText, start_offset: gint,
-                             end_offset: gint): gboolean{.cdecl, dynlib: atklib,
-    importc: "atk_text_add_selection".}
-proc atk_text_remove_selection*(text: PAtkText, selection_num: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_text_remove_selection".}
-proc atk_text_set_selection*(text: PAtkText, selection_num: gint,
-                             start_offset: gint, end_offset: gint): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_text_set_selection".}
-proc atk_text_set_caret_offset*(text: PAtkText, offset: gint): gboolean{.cdecl,
-    dynlib: atklib, importc: "atk_text_set_caret_offset".}
-proc atk_attribute_set_free*(attrib_set: PAtkAttributeSet){.cdecl,
-    dynlib: atklib, importc: "atk_attribute_set_free".}
-proc atk_text_attribute_get_name*(attr: TAtkTextAttribute): cstring{.cdecl,
-    dynlib: atklib, importc: "atk_text_attribute_get_name".}
-proc atk_text_attribute_for_name*(name: cstring): TAtkTextAttribute{.cdecl,
-    dynlib: atklib, importc: "atk_text_attribute_for_name".}
-proc atk_text_attribute_get_value*(attr: TAtkTextAttribute, index: gint): cstring{.
-    cdecl, dynlib: atklib, importc: "atk_text_attribute_get_value".}
-proc ATK_TYPE_UTIL*(): GType
-proc ATK_IS_UTIL*(obj: pointer): bool
-proc ATK_UTIL*(obj: pointer): PAtkUtil
-proc ATK_UTIL_CLASS*(klass: pointer): PAtkUtilClass
-proc ATK_IS_UTIL_CLASS*(klass: pointer): bool
-proc ATK_UTIL_GET_CLASS*(obj: pointer): PAtkUtilClass
-proc atk_util_get_type*(): GType{.cdecl, dynlib: atklib,
-                                  importc: "atk_util_get_type".}
-proc atk_add_focus_tracker*(focus_tracker: TAtkEventListener): guint{.cdecl,
-    dynlib: atklib, importc: "atk_add_focus_tracker".}
-proc atk_remove_focus_tracker*(tracker_id: guint){.cdecl, dynlib: atklib,
-    importc: "atk_remove_focus_tracker".}
-proc atk_focus_tracker_init*(add_function: TAtkEventListenerInit){.cdecl,
-    dynlib: atklib, importc: "atk_focus_tracker_init".}
-proc atk_focus_tracker_notify*(anObject: PAtkObject){.cdecl, dynlib: atklib,
-    importc: "atk_focus_tracker_notify".}
-proc atk_add_global_event_listener*(listener: TGSignalEmissionHook,
-                                    event_type: cstring): guint{.cdecl,
-    dynlib: atklib, importc: "atk_add_global_event_listener".}
-proc atk_remove_global_event_listener*(listener_id: guint){.cdecl,
-    dynlib: atklib, importc: "atk_remove_global_event_listener".}
-proc atk_add_key_event_listener*(listener: TAtkKeySnoopFunc, data: gpointer): guint{.
-    cdecl, dynlib: atklib, importc: "atk_add_key_event_listener".}
-proc atk_remove_key_event_listener*(listener_id: guint){.cdecl, dynlib: atklib,
-    importc: "atk_remove_key_event_listener".}
-proc atk_get_root*(): PAtkObject{.cdecl, dynlib: atklib, importc: "atk_get_root".}
-proc atk_get_toolkit_name*(): cstring{.cdecl, dynlib: atklib,
-                                      importc: "atk_get_toolkit_name".}
-proc atk_get_toolkit_version*(): cstring{.cdecl, dynlib: atklib,
-    importc: "atk_get_toolkit_version".}
-proc ATK_TYPE_VALUE*(): GType
-proc ATK_IS_VALUE*(obj: pointer): bool
-proc ATK_VALUE*(obj: pointer): PAtkValue
-proc ATK_VALUE_GET_IFACE*(obj: pointer): PAtkValueIface
-proc atk_value_get_type*(): GType{.cdecl, dynlib: atklib,
-                                   importc: "atk_value_get_type".}
-proc atk_value_get_current_value*(obj: PAtkValue, value: PGValue){.cdecl,
-    dynlib: atklib, importc: "atk_value_get_current_value".}
-proc atk_value_get_maximum_value*(obj: PAtkValue, value: PGValue){.cdecl,
-    dynlib: atklib, importc: "atk_value_get_maximum_value".}
-proc atk_value_get_minimum_value*(obj: PAtkValue, value: PGValue){.cdecl,
-    dynlib: atklib, importc: "atk_value_get_minimum_value".}
-proc atk_value_set_current_value*(obj: PAtkValue, value: PGValue): gboolean{.
-    cdecl, dynlib: atklib, importc: "atk_value_set_current_value".}
-proc ATK_TYPE_OBJECT*(): GType =
-  result = atk_object_get_type()
-
-proc ATK_OBJECT*(obj: pointer): PAtkObject =
-  result = cast[PAtkObject](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_OBJECT()))
-
-proc ATK_OBJECT_CLASS*(klass: pointer): PAtkObjectClass =
-  result = cast[PAtkObjectClass](G_TYPE_CHECK_CLASS_CAST(klass, ATK_TYPE_OBJECT()))
-
-proc ATK_IS_OBJECT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_OBJECT())
-
-proc ATK_IS_OBJECT_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_OBJECT())
-
-proc ATK_OBJECT_GET_CLASS*(obj: pointer): PAtkObjectClass =
-  result = cast[PAtkObjectClass](G_TYPE_INSTANCE_GET_CLASS(obj, ATK_TYPE_OBJECT()))
-
-proc ATK_TYPE_IMPLEMENTOR*(): GType =
-  result = atk_implementor_get_type()
-
-proc ATK_IS_IMPLEMENTOR*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_IMPLEMENTOR())
-
-proc ATK_IMPLEMENTOR*(obj: pointer): PAtkImplementor =
-  result = PAtkImplementor(G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_IMPLEMENTOR()))
-
-proc ATK_IMPLEMENTOR_GET_IFACE*(obj: pointer): PAtkImplementorIface =
-  result = cast[PAtkImplementorIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_IMPLEMENTOR()))
-
-proc ATK_TYPE_ACTION*(): GType =
-  result = atk_action_get_type()
-
-proc ATK_IS_ACTION*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_ACTION())
-
-proc ATK_ACTION*(obj: pointer): PAtkAction =
-  result = PAtkAction(G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_ACTION()))
-
-proc ATK_ACTION_GET_IFACE*(obj: pointer): PAtkActionIface =
-  result = cast[PAtkActionIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-    ATK_TYPE_ACTION()))
-
-proc ATK_TYPE_COMPONENT*(): GType =
-  result = atk_component_get_type()
-
-proc ATK_IS_COMPONENT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_COMPONENT())
-
-proc ATK_COMPONENT*(obj: pointer): PAtkComponent =
-  result = PAtkComponent(G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_COMPONENT()))
-
-proc ATK_COMPONENT_GET_IFACE*(obj: pointer): PAtkComponentIface =
-  result = cast[PAtkComponentIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_COMPONENT()))
-
-proc ATK_TYPE_DOCUMENT*(): GType =
-  result = atk_document_get_type()
-
-proc ATK_IS_DOCUMENT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_DOCUMENT())
-
-proc ATK_DOCUMENT*(obj: pointer): PAtkDocument =
-  result = cast[PAtkDocument](G_TYPE_CHECK_INSTANCE_CAST(obj,
-    ATK_TYPE_DOCUMENT()))
-
-proc ATK_DOCUMENT_GET_IFACE*(obj: pointer): PAtkDocumentIface =
-  result = cast[PAtkDocumentIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_DOCUMENT()))
-
-proc ATK_TYPE_EDITABLE_TEXT*(): GType =
-  result = atk_editable_text_get_type()
-
-proc ATK_IS_EDITABLE_TEXT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_EDITABLE_TEXT())
-
-proc ATK_EDITABLE_TEXT*(obj: pointer): PAtkEditableText =
-  result = cast[PAtkEditableText](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      ATK_TYPE_EDITABLE_TEXT()))
-
-proc ATK_EDITABLE_TEXT_GET_IFACE*(obj: pointer): PAtkEditableTextIface =
-  result = cast[PAtkEditableTextIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_EDITABLE_TEXT()))
-
-proc ATK_TYPE_GOBJECT_ACCESSIBLE*(): GType =
-  result = atk_gobject_accessible_get_type()
-
-proc ATK_GOBJECT_ACCESSIBLE*(obj: pointer): PAtkGObjectAccessible =
-  result = cast[PAtkGObjectAccessible](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      ATK_TYPE_GOBJECT_ACCESSIBLE()))
-
-proc ATK_GOBJECT_ACCESSIBLE_CLASS*(klass: pointer): PAtkGObjectAccessibleClass =
-  result = cast[PAtkGObjectAccessibleClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      ATK_TYPE_GOBJECT_ACCESSIBLE()))
-
-proc ATK_IS_GOBJECT_ACCESSIBLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_GOBJECT_ACCESSIBLE())
-
-proc ATK_IS_GOBJECT_ACCESSIBLE_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_GOBJECT_ACCESSIBLE())
-
-proc ATK_GOBJECT_ACCESSIBLE_GET_CLASS*(obj: pointer): PAtkGObjectAccessibleClass =
-  result = cast[PAtkGObjectAccessibleClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      ATK_TYPE_GOBJECT_ACCESSIBLE()))
-
-proc ATK_TYPE_HYPERLINK*(): GType =
-  result = atk_hyperlink_get_type()
-
-proc ATK_HYPERLINK*(obj: pointer): PAtkHyperlink =
-  result = cast[PAtkHyperlink](G_TYPE_CHECK_INSTANCE_CAST(obj,
-                              ATK_TYPE_HYPERLINK()))
-
-proc ATK_HYPERLINK_CLASS*(klass: pointer): PAtkHyperlinkClass =
-  result = cast[PAtkHyperlinkClass](G_TYPE_CHECK_CLASS_CAST(klass,
-                                    ATK_TYPE_HYPERLINK()))
-
-proc ATK_IS_HYPERLINK*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_HYPERLINK())
-
-proc ATK_IS_HYPERLINK_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_HYPERLINK())
-
-proc ATK_HYPERLINK_GET_CLASS*(obj: pointer): PAtkHyperlinkClass =
-  result = cast[PAtkHyperlinkClass](G_TYPE_INSTANCE_GET_CLASS(obj, ATK_TYPE_HYPERLINK()))
-
-proc ATK_TYPE_HYPERTEXT*(): GType =
-  result = atk_hypertext_get_type()
-
-proc ATK_IS_HYPERTEXT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_HYPERTEXT())
-
-proc ATK_HYPERTEXT*(obj: pointer): PAtkHypertext =
-  result = cast[PAtkHypertext](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_HYPERTEXT()))
-
-proc ATK_HYPERTEXT_GET_IFACE*(obj: pointer): PAtkHypertextIface =
-  result = cast[PAtkHypertextIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_HYPERTEXT()))
-
-proc ATK_TYPE_IMAGE*(): GType =
-  result = atk_image_get_type()
-
-proc ATK_IS_IMAGE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_IMAGE())
-
-proc ATK_IMAGE*(obj: pointer): PAtkImage =
-  result = cast[PAtkImage](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_IMAGE()))
-
-proc ATK_IMAGE_GET_IFACE*(obj: pointer): PAtkImageIface =
-  result = cast[PAtkImageIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, ATK_TYPE_IMAGE()))
-
-proc ATK_TYPE_OBJECT_FACTORY*(): GType =
-  result = atk_object_factory_get_type()
-
-proc ATK_OBJECT_FACTORY*(obj: pointer): PAtkObjectFactory =
-  result = cast[PAtkObjectFactory](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      ATK_TYPE_OBJECT_FACTORY()))
-
-proc ATK_OBJECT_FACTORY_CLASS*(klass: pointer): PAtkObjectFactoryClass =
-  result = cast[PAtkObjectFactoryClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      ATK_TYPE_OBJECT_FACTORY()))
-
-proc ATK_IS_OBJECT_FACTORY*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_OBJECT_FACTORY())
-
-proc ATK_IS_OBJECT_FACTORY_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_OBJECT_FACTORY())
-
-proc ATK_OBJECT_FACTORY_GET_CLASS*(obj: pointer): PAtkObjectFactoryClass =
-  result = cast[PAtkObjectFactoryClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      ATK_TYPE_OBJECT_FACTORY()))
-
-proc ATK_TYPE_REGISTRY*(): GType =
-  result = atk_registry_get_type()
-
-proc ATK_REGISTRY*(obj: pointer): PAtkRegistry =
-  result = cast[PAtkRegistry](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_REGISTRY()))
-
-proc ATK_REGISTRY_CLASS*(klass: pointer): PAtkRegistryClass =
-  result = cast[PAtkRegistryClass](G_TYPE_CHECK_CLASS_CAST(klass,
-                                   ATK_TYPE_REGISTRY()))
-
-proc ATK_IS_REGISTRY*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_REGISTRY())
-
-proc ATK_IS_REGISTRY_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_REGISTRY())
-
-proc ATK_REGISTRY_GET_CLASS*(obj: pointer): PAtkRegistryClass =
-  result = cast[PAtkRegistryClass](G_TYPE_INSTANCE_GET_CLASS(obj, ATK_TYPE_REGISTRY()))
-
-proc ATK_TYPE_RELATION*(): GType =
-  result = atk_relation_get_type()
-
-proc ATK_RELATION*(obj: pointer): PAtkRelation =
-  result = cast[PAtkRelation](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_RELATION()))
-
-proc ATK_RELATION_CLASS*(klass: pointer): PAtkRelationClass =
-  result = cast[PAtkRelationClass](G_TYPE_CHECK_CLASS_CAST(klass, ATK_TYPE_RELATION()))
-
-proc ATK_IS_RELATION*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_RELATION())
-
-proc ATK_IS_RELATION_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_RELATION())
-
-proc ATK_RELATION_GET_CLASS*(obj: pointer): PAtkRelationClass =
-  result = cast[PAtkRelationClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-    ATK_TYPE_RELATION()))
-
-proc ATK_TYPE_RELATION_SET*(): GType =
-  result = atk_relation_set_get_type()
-
-proc ATK_RELATION_SET*(obj: pointer): PAtkRelationSet =
-  result = cast[PAtkRelationSet](G_TYPE_CHECK_INSTANCE_CAST(obj,
-    ATK_TYPE_RELATION_SET()))
-
-proc ATK_RELATION_SET_CLASS*(klass: pointer): PAtkRelationSetClass =
-  result = cast[PAtkRelationSetClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      ATK_TYPE_RELATION_SET()))
-
-proc ATK_IS_RELATION_SET*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_RELATION_SET())
-
-proc ATK_IS_RELATION_SET_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_RELATION_SET())
-
-proc ATK_RELATION_SET_GET_CLASS*(obj: pointer): PAtkRelationSetClass =
-  result = cast[PAtkRelationSetClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      ATK_TYPE_RELATION_SET()))
-
-proc ATK_TYPE_SELECTION*(): GType =
-  result = atk_selection_get_type()
-
-proc ATK_IS_SELECTION*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_SELECTION())
-
-proc ATK_SELECTION*(obj: pointer): PAtkSelection =
-  result = cast[PAtkSelection](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_SELECTION()))
-
-proc ATK_SELECTION_GET_IFACE*(obj: pointer): PAtkSelectionIface =
-  result = cast[PAtkSelectionIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_SELECTION()))
-
-proc ATK_TYPE_STATE_SET*(): GType =
-  result = atk_state_set_get_type()
-
-proc ATK_STATE_SET*(obj: pointer): PAtkStateSet =
-  result = cast[PAtkStateSet](G_TYPE_CHECK_INSTANCE_CAST(obj,
-    ATK_TYPE_STATE_SET()))
-
-proc ATK_STATE_SET_CLASS*(klass: pointer): PAtkStateSetClass =
-  result = cast[PAtkStateSetClass](G_TYPE_CHECK_CLASS_CAST(klass,
-    ATK_TYPE_STATE_SET()))
-
-proc ATK_IS_STATE_SET*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_STATE_SET())
-
-proc ATK_IS_STATE_SET_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_STATE_SET())
-
-proc ATK_STATE_SET_GET_CLASS*(obj: pointer): PAtkStateSetClass =
-  result = cast[PAtkStateSetClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-    ATK_TYPE_STATE_SET()))
-
-proc ATK_TYPE_STREAMABLE_CONTENT*(): GType =
-  result = atk_streamable_content_get_type()
-
-proc ATK_IS_STREAMABLE_CONTENT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_STREAMABLE_CONTENT())
-
-proc ATK_STREAMABLE_CONTENT*(obj: pointer): PAtkStreamableContent =
-  result = cast[PAtkStreamableContent](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      ATK_TYPE_STREAMABLE_CONTENT()))
-
-proc ATK_STREAMABLE_CONTENT_GET_IFACE*(obj: pointer): PAtkStreamableContentIface =
-  result = cast[PAtkStreamableContentIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      ATK_TYPE_STREAMABLE_CONTENT()))
-
-proc ATK_TYPE_TABLE*(): GType =
-  result = atk_table_get_type()
-
-proc ATK_IS_TABLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_TABLE())
-
-proc ATK_TABLE*(obj: pointer): PAtkTable =
-  result = cast[PAtkTable](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_TABLE()))
-
-proc ATK_TABLE_GET_IFACE*(obj: pointer): PAtkTableIface =
-  result = cast[PAtkTableIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, ATK_TYPE_TABLE()))
-
-proc ATK_TYPE_TEXT*(): GType =
-  result = atk_text_get_type()
-
-proc ATK_IS_TEXT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_TEXT())
-
-proc ATK_TEXT*(obj: pointer): PAtkText =
-  result = cast[PAtkText](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_TEXT()))
-
-proc ATK_TEXT_GET_IFACE*(obj: pointer): PAtkTextIface =
-  result = cast[PAtkTextIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, ATK_TYPE_TEXT()))
-
-proc ATK_TYPE_UTIL*(): GType =
-  result = atk_util_get_type()
-
-proc ATK_IS_UTIL*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_UTIL())
-
-proc ATK_UTIL*(obj: pointer): PAtkUtil =
-  result = cast[PAtkUtil](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_UTIL()))
-
-proc ATK_UTIL_CLASS*(klass: pointer): PAtkUtilClass =
-  result = cast[PAtkUtilClass](G_TYPE_CHECK_CLASS_CAST(klass, ATK_TYPE_UTIL()))
-
-proc ATK_IS_UTIL_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, ATK_TYPE_UTIL())
-
-proc ATK_UTIL_GET_CLASS*(obj: pointer): PAtkUtilClass =
-  result = cast[PAtkUtilClass](G_TYPE_INSTANCE_GET_CLASS(obj, ATK_TYPE_UTIL()))
-
-proc ATK_TYPE_VALUE*(): GType =
-  result = atk_value_get_type()
-
-proc ATK_IS_VALUE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, ATK_TYPE_VALUE())
-
-proc ATK_VALUE*(obj: pointer): PAtkValue =
-  result = cast[PAtkValue](G_TYPE_CHECK_INSTANCE_CAST(obj, ATK_TYPE_VALUE()))
-
-proc ATK_VALUE_GET_IFACE*(obj: pointer): PAtkValueIface =
-  result = cast[PAtkValueIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, ATK_TYPE_VALUE()))
diff --git a/lib/oldwrappers/gtk/gdk2.nim b/lib/oldwrappers/gtk/gdk2.nim
deleted file mode 100755
index 0ca5056b5..000000000
--- a/lib/oldwrappers/gtk/gdk2.nim
+++ /dev/null
@@ -1,3958 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2, gdk2pixbuf, pango
-
-when defined(win32):
-  const
-    gdklib = "libgdk-win32-2.0-0.dll"
-    GDK_HAVE_WCHAR_H = 1
-    GDK_HAVE_WCTYPE_H = 1
-elif defined(darwin):
-  #    linklib gtk-x11-2.0
-  #    linklib gdk-x11-2.0
-  #    linklib pango-1.0.0
-  #    linklib glib-2.0.0
-  #    linklib gobject-2.0.0
-  #    linklib gdk_pixbuf-2.0.0
-  #    linklib atk-1.0.0
-  const
-    gdklib = "gdk-x11-2.0"
-else:
-  const
-    gdklib = "libgdk-x11-2.0.so"
-const
-  NUMPTSTOBUFFER* = 200
-  GDK_MAX_TIMECOORD_AXES* = 128
-
-type
-  PGdkDeviceClass* = ptr TGdkDeviceClass
-  TGdkDeviceClass* = object of TGObjectClass
-
-  PGdkVisualClass* = ptr TGdkVisualClass
-  TGdkVisualClass* = object of TGObjectClass
-
-  PGdkColor* = ptr TGdkColor
-  TGdkColor* {.final, pure.} = object
-    pixel*: guint32
-    red*: guint16
-    green*: guint16
-    blue*: guint16
-
-  PGdkColormap* = ptr TGdkColormap
-  PGdkDrawable* = ptr TGdkDrawable
-  TGdkDrawable* = object of TGObject
-
-  PGdkWindow* = ptr TGdkWindow
-  TGdkWindow* = TGdkDrawable
-  PGdkPixmap* = ptr TGdkPixmap
-  TGdkPixmap* = TGdkDrawable
-  PGdkBitmap* = ptr TGdkBitmap
-  TGdkBitmap* = TGdkDrawable
-  PGdkFontType* = ptr TGdkFontType
-  TGdkFontType* = enum
-    GDK_FONT_FONT, GDK_FONT_FONTSET
-  PGdkFont* = ptr TGdkFont
-  TGdkFont* {.final, pure.} = object
-    `type`*: TGdkFontType
-    ascent*: gint
-    descent*: gint
-
-  PGdkFunction* = ptr TGdkFunction
-  TGdkFunction* = enum
-    GDK_COPY, GDK_INVERT, GDK_XOR, GDK_CLEAR, GDK_AND, GDK_AND_REVERSE,
-    GDK_AND_INVERT, GDK_NOOP, GDK_OR, GDK_EQUIV, GDK_OR_REVERSE,
-    GDK_COPY_INVERT, GDK_OR_INVERT, GDK_NAND, GDK_NOR, GDK_SET
-  PGdkCapStyle* = ptr TGdkCapStyle
-  TGdkCapStyle* = enum
-    GDK_CAP_NOT_LAST, GDK_CAP_BUTT, GDK_CAP_ROUND, GDK_CAP_PROJECTING
-  PGdkFill* = ptr TGdkFill
-  TGdkFill* = enum
-    GDK_SOLID, GDK_TILED, GDK_STIPPLED, GDK_OPAQUE_STIPPLED
-  PGdkJoinStyle* = ptr TGdkJoinStyle
-  TGdkJoinStyle* = enum
-    GDK_JOIN_MITER, GDK_JOIN_ROUND, GDK_JOIN_BEVEL
-  PGdkLineStyle* = ptr TGdkLineStyle
-  TGdkLineStyle* = enum
-    GDK_LINE_SOLID, GDK_LINE_ON_OFF_DASH, GDK_LINE_DOUBLE_DASH
-  PGdkSubwindowMode* = ptr TGdkSubwindowMode
-  TGdkSubwindowMode* = int
-  PGdkGCValuesMask* = ptr TGdkGCValuesMask
-  TGdkGCValuesMask* = int32
-  PGdkGCValues* = ptr TGdkGCValues
-  TGdkGCValues* {.final, pure.} = object
-    foreground*: TGdkColor
-    background*: TGdkColor
-    font*: PGdkFont
-    `function`*: TGdkFunction
-    fill*: TGdkFill
-    tile*: PGdkPixmap
-    stipple*: PGdkPixmap
-    clip_mask*: PGdkPixmap
-    subwindow_mode*: TGdkSubwindowMode
-    ts_x_origin*: gint
-    ts_y_origin*: gint
-    clip_x_origin*: gint
-    clip_y_origin*: gint
-    graphics_exposures*: gint
-    line_width*: gint
-    line_style*: TGdkLineStyle
-    cap_style*: TGdkCapStyle
-    join_style*: TGdkJoinStyle
-
-  PGdkGC* = ptr TGdkGC
-  TGdkGC* = object of TGObject
-    clip_x_origin*: gint
-    clip_y_origin*: gint
-    ts_x_origin*: gint
-    ts_y_origin*: gint
-    colormap*: PGdkColormap
-
-  PGdkImageType* = ptr TGdkImageType
-  TGdkImageType* = enum
-    GDK_IMAGE_NORMAL, GDK_IMAGE_SHARED, GDK_IMAGE_FASTEST
-  PGdkImage* = ptr TGdkImage
-  PGdkDevice* = ptr TGdkDevice
-  PGdkTimeCoord* = ptr TGdkTimeCoord
-  PPGdkTimeCoord* = ptr PGdkTimeCoord
-  PGdkRgbDither* = ptr TGdkRgbDither
-  TGdkRgbDither* = enum
-    GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_MAX
-  PGdkDisplay* = ptr TGdkDisplay
-  PGdkScreen* = ptr TGdkScreen
-  TGdkScreen* = object of TGObject
-
-  PGdkInputCondition* = ptr TGdkInputCondition
-  TGdkInputCondition* = int32
-  PGdkStatus* = ptr TGdkStatus
-  TGdkStatus* = int32
-  TGdkPoint* {.final, pure.} = object
-    x*: gint
-    y*: gint
-
-  PGdkPoint* = ptr TGdkPoint
-  PPGdkPoint* = ptr PGdkPoint
-  PGdkSpan* = ptr TGdkSpan
-  PGdkWChar* = ptr TGdkWChar
-  TGdkWChar* = guint32
-  PGdkSegment* = ptr TGdkSegment
-  TGdkSegment* {.final, pure.} = object
-    x1*: gint
-    y1*: gint
-    x2*: gint
-    y2*: gint
-
-  PGdkRectangle* = ptr TGdkRectangle
-  TGdkRectangle* {.final, pure.} = object
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-
-  PGdkAtom* = ptr TGdkAtom
-  TGdkAtom* = gulong
-  PGdkByteOrder* = ptr TGdkByteOrder
-  TGdkByteOrder* = enum
-    GDK_LSB_FIRST, GDK_MSB_FIRST
-  PGdkModifierType* = ptr TGdkModifierType
-  TGdkModifierType* = gint
-  PGdkVisualType* = ptr TGdkVisualType
-  TGdkVisualType* = enum
-    GDK_VISUAL_STATIC_GRAY, GDK_VISUAL_GRAYSCALE, GDK_VISUAL_STATIC_COLOR,
-    GDK_VISUAL_PSEUDO_COLOR, GDK_VISUAL_TRUE_COLOR, GDK_VISUAL_DIRECT_COLOR
-  PGdkVisual* = ptr TGdkVisual
-  TGdkVisual* = object of TGObject
-    TheType*: TGdkVisualType
-    depth*: gint
-    byte_order*: TGdkByteOrder
-    colormap_size*: gint
-    bits_per_rgb*: gint
-    red_mask*: guint32
-    red_shift*: gint
-    red_prec*: gint
-    green_mask*: guint32
-    green_shift*: gint
-    green_prec*: gint
-    blue_mask*: guint32
-    blue_shift*: gint
-    blue_prec*: gint
-    screen*: PGdkScreen
-
-  PGdkColormapClass* = ptr TGdkColormapClass
-  TGdkColormapClass* = object of TGObjectClass
-
-  TGdkColormap* = object of TGObject
-    size*: gint
-    colors*: PGdkColor
-    visual*: PGdkVisual
-    windowing_data*: gpointer
-    screen*: PGdkScreen
-
-  PGdkCursorType* = ptr TGdkCursorType
-  TGdkCursorType* = gint
-  PGdkCursor* = ptr TGdkCursor
-  TGdkCursor* {.final, pure.} = object
-    `type`*: TGdkCursorType
-    ref_count*: guint
-
-  PGdkDragAction* = ptr TGdkDragAction
-  TGdkDragAction* = int32
-  PGdkDragProtocol* = ptr TGdkDragProtocol
-  TGdkDragProtocol* = enum
-    GDK_DRAG_PROTO_MOTIF, GDK_DRAG_PROTO_XDND, GDK_DRAG_PROTO_ROOTWIN,
-    GDK_DRAG_PROTO_NONE, GDK_DRAG_PROTO_WIN32_DROPFILES, GDK_DRAG_PROTO_OLE2,
-    GDK_DRAG_PROTO_LOCAL
-  PGdkDragContext* = ptr TGdkDragContext
-  TGdkDragContext* = object of TGObject
-    protocol*: TGdkDragProtocol
-    is_source*: gboolean
-    source_window*: PGdkWindow
-    dest_window*: PGdkWindow
-    targets*: PGList
-    actions*: TGdkDragAction
-    suggested_action*: TGdkDragAction
-    action*: TGdkDragAction
-    start_time*: guint32
-    windowing_data*: gpointer
-
-  PGdkDragContextClass* = ptr TGdkDragContextClass
-  TGdkDragContextClass* = object of TGObjectClass
-
-  PGdkRegionBox* = ptr TGdkRegionBox
-  TGdkRegionBox* = TGdkSegment
-  PGdkRegion* = ptr TGdkRegion
-  TGdkRegion* {.final, pure.} = object
-    size*: int32
-    numRects*: int32
-    rects*: PGdkRegionBox
-    extents*: TGdkRegionBox
-
-  PPOINTBLOCK* = ptr TPOINTBLOCK
-  TPOINTBLOCK* {.final, pure.} = object
-    pts*: array[0..(NUMPTSTOBUFFER) - 1, TGdkPoint]
-    next*: PPOINTBLOCK
-
-  PGdkDrawableClass* = ptr TGdkDrawableClass
-  TGdkDrawableClass* = object of TGObjectClass
-    create_gc*: proc (drawable: PGdkDrawable, values: PGdkGCValues,
-                      mask: TGdkGCValuesMask): PGdkGC{.cdecl.}
-    draw_rectangle*: proc (drawable: PGdkDrawable, gc: PGdkGC, filled: gint,
-                           x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_arc*: proc (drawable: PGdkDrawable, gc: PGdkGC, filled: gint, x: gint,
-                     y: gint, width: gint, height: gint, angle1: gint,
-                     angle2: gint){.cdecl.}
-    draw_polygon*: proc (drawable: PGdkDrawable, gc: PGdkGC, filled: gint,
-                         points: PGdkPoint, npoints: gint){.cdecl.}
-    draw_text*: proc (drawable: PGdkDrawable, font: PGdkFont, gc: PGdkGC,
-                      x: gint, y: gint, text: cstring, text_length: gint){.cdecl.}
-    draw_text_wc*: proc (drawable: PGdkDrawable, font: PGdkFont, gc: PGdkGC,
-                         x: gint, y: gint, text: PGdkWChar, text_length: gint){.
-        cdecl.}
-    draw_drawable*: proc (drawable: PGdkDrawable, gc: PGdkGC, src: PGdkDrawable,
-                          xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                          width: gint, height: gint){.cdecl.}
-    draw_points*: proc (drawable: PGdkDrawable, gc: PGdkGC, points: PGdkPoint,
-                        npoints: gint){.cdecl.}
-    draw_segments*: proc (drawable: PGdkDrawable, gc: PGdkGC, segs: PGdkSegment,
-                          nsegs: gint){.cdecl.}
-    draw_lines*: proc (drawable: PGdkDrawable, gc: PGdkGC, points: PGdkPoint,
-                       npoints: gint){.cdecl.}
-    draw_glyphs*: proc (drawable: PGdkDrawable, gc: PGdkGC, font: PPangoFont,
-                        x: gint, y: gint, glyphs: PPangoGlyphString){.cdecl.}
-    draw_image*: proc (drawable: PGdkDrawable, gc: PGdkGC, image: PGdkImage,
-                       xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                       width: gint, height: gint){.cdecl.}
-    get_depth*: proc (drawable: PGdkDrawable): gint{.cdecl.}
-    get_size*: proc (drawable: PGdkDrawable, width: Pgint, height: Pgint){.cdecl.}
-    set_colormap*: proc (drawable: PGdkDrawable, cmap: PGdkColormap){.cdecl.}
-    get_colormap*: proc (drawable: PGdkDrawable): PGdkColormap{.cdecl.}
-    get_visual*: proc (drawable: PGdkDrawable): PGdkVisual{.cdecl.}
-    get_screen*: proc (drawable: PGdkDrawable): PGdkScreen{.cdecl.}
-    get_image*: proc (drawable: PGdkDrawable, x: gint, y: gint, width: gint,
-                      height: gint): PGdkImage{.cdecl.}
-    get_clip_region*: proc (drawable: PGdkDrawable): PGdkRegion{.cdecl.}
-    get_visible_region*: proc (drawable: PGdkDrawable): PGdkRegion{.cdecl.}
-    get_composite_drawable*: proc (drawable: PGdkDrawable, x: gint, y: gint,
-                                   width: gint, height: gint,
-                                   composite_x_offset: Pgint,
-                                   composite_y_offset: Pgint): PGdkDrawable{.
-        cdecl.}
-    `draw_pixbuf`*: proc (drawable: PGdkDrawable, gc: PGdkGC,
-                          pixbuf: PGdkPixbuf, src_x: gint, src_y: gint,
-                          dest_x: gint, dest_y: gint, width: gint, height: gint,
-                          dither: TGdkRgbDither, x_dither: gint, y_dither: gint){.
-        cdecl.}
-    `copy_to_image`*: proc (drawable: PGdkDrawable, image: PGdkImage,
-                            src_x: gint, src_y: gint, dest_x: gint,
-                            dest_y: gint, width: gint, height: gint): PGdkImage{.
-        cdecl.}
-    `gdk_reserved1`: proc (){.cdecl.}
-    `gdk_reserved2`: proc (){.cdecl.}
-    `gdk_reserved3`: proc (){.cdecl.}
-    `gdk_reserved4`: proc (){.cdecl.}
-    `gdk_reserved5`: proc (){.cdecl.}
-    `gdk_reserved6`: proc (){.cdecl.}
-    `gdk_reserved7`: proc (){.cdecl.}
-    `gdk_reserved9`: proc (){.cdecl.}
-    `gdk_reserved10`: proc (){.cdecl.}
-    `gdk_reserved11`: proc (){.cdecl.}
-    `gdk_reserved12`: proc (){.cdecl.}
-    `gdk_reserved13`: proc (){.cdecl.}
-    `gdk_reserved14`: proc (){.cdecl.}
-    `gdk_reserved15`: proc (){.cdecl.}
-    `gdk_reserved16`: proc (){.cdecl.}
-
-  PGdkEvent* = ptr TGdkEvent
-  TGdkEventFunc* = proc (event: PGdkEvent, data: gpointer){.cdecl.}
-  PGdkXEvent* = ptr TGdkXEvent
-  TGdkXEvent* = proc ()
-  PGdkFilterReturn* = ptr TGdkFilterReturn
-  TGdkFilterReturn* = enum
-    GDK_FILTER_CONTINUE, GDK_FILTER_TRANSLATE, GDK_FILTER_REMOVE
-  TGdkFilterFunc* = proc (xevent: PGdkXEvent, event: PGdkEvent, data: gpointer): TGdkFilterReturn{.
-      cdecl.}
-  PGdkEventType* = ptr TGdkEventType
-  TGdkEventType* = gint
-  PGdkEventMask* = ptr TGdkEventMask
-  TGdkEventMask* = gint32
-  PGdkVisibilityState* = ptr TGdkVisibilityState
-  TGdkVisibilityState* = enum
-    GDK_VISIBILITY_UNOBSCURED, GDK_VISIBILITY_PARTIAL,
-    GDK_VISIBILITY_FULLY_OBSCURED
-  PGdkScrollDirection* = ptr TGdkScrollDirection
-  TGdkScrollDirection* = enum
-    GDK_SCROLL_UP, GDK_SCROLL_DOWN, GDK_SCROLL_LEFT, GDK_SCROLL_RIGHT
-  PGdkNotifyType* = ptr TGdkNotifyType
-  TGdkNotifyType* = int
-  PGdkCrossingMode* = ptr TGdkCrossingMode
-  TGdkCrossingMode* = enum
-    GDK_CROSSING_NORMAL, GDK_CROSSING_GRAB, GDK_CROSSING_UNGRAB
-  PGdkPropertyState* = ptr TGdkPropertyState
-  TGdkPropertyState* = enum
-    GDK_PROPERTY_NEW_VALUE, GDK_PROPERTY_STATE_DELETE
-  PGdkWindowState* = ptr TGdkWindowState
-  TGdkWindowState* = gint
-  PGdkSettingAction* = ptr TGdkSettingAction
-  TGdkSettingAction* = enum
-    GDK_SETTING_ACTION_NEW, GDK_SETTING_ACTION_CHANGED,
-    GDK_SETTING_ACTION_DELETED
-  PGdkEventAny* = ptr TGdkEventAny
-  TGdkEventAny* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-
-  PGdkEventExpose* = ptr TGdkEventExpose
-  TGdkEventExpose* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    area*: TGdkRectangle
-    region*: PGdkRegion
-    count*: gint
-
-  PGdkEventNoExpose* = ptr TGdkEventNoExpose
-  TGdkEventNoExpose* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-
-  PGdkEventVisibility* = ptr TGdkEventVisibility
-  TGdkEventVisibility* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    state*: TGdkVisibilityState
-
-  PGdkEventMotion* = ptr TGdkEventMotion
-  TGdkEventMotion* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    axes*: Pgdouble
-    state*: guint
-    is_hint*: gint16
-    device*: PGdkDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PGdkEventButton* = ptr TGdkEventButton
-  TGdkEventButton* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    axes*: Pgdouble
-    state*: guint
-    button*: guint
-    device*: PGdkDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PGdkEventScroll* = ptr TGdkEventScroll
-  TGdkEventScroll* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    state*: guint
-    direction*: TGdkScrollDirection
-    device*: PGdkDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PGdkEventKey* = ptr TGdkEventKey
-  TGdkEventKey* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    time*: guint32
-    state*: guint
-    keyval*: guint
-    length*: gint
-    `string`*: cstring
-    hardware_keycode*: guint16
-    group*: guint8
-
-  PGdkEventCrossing* = ptr TGdkEventCrossing
-  TGdkEventCrossing* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    subwindow*: PGdkWindow
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    x_root*: gdouble
-    y_root*: gdouble
-    mode*: TGdkCrossingMode
-    detail*: TGdkNotifyType
-    focus*: gboolean
-    state*: guint
-
-  PGdkEventFocus* = ptr TGdkEventFocus
-  TGdkEventFocus* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    `in`*: gint16
-
-  PGdkEventConfigure* = ptr TGdkEventConfigure
-  TGdkEventConfigure* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-
-  PGdkEventProperty* = ptr TGdkEventProperty
-  TGdkEventProperty* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    atom*: TGdkAtom
-    time*: guint32
-    state*: guint
-
-  TGdkNativeWindow* = pointer
-  PGdkEventSelection* = ptr TGdkEventSelection
-  TGdkEventSelection* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    selection*: TGdkAtom
-    target*: TGdkAtom
-    `property`*: TGdkAtom
-    time*: guint32
-    requestor*: TGdkNativeWindow
-
-  PGdkEventProximity* = ptr TGdkEventProximity
-  TGdkEventProximity* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    time*: guint32
-    device*: PGdkDevice
-
-  PmatDUMMY* = ptr TmatDUMMY
-  TmatDUMMY* {.final, pure.} = object
-    b*: array[0..19, char]
-
-  PGdkEventClient* = ptr TGdkEventClient
-  TGdkEventClient* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    message_type*: TGdkAtom
-    data_format*: gushort
-    b*: array[0..19, char]
-
-  PGdkEventSetting* = ptr TGdkEventSetting
-  TGdkEventSetting* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    action*: TGdkSettingAction
-    name*: cstring
-
-  PGdkEventWindowState* = ptr TGdkEventWindowState
-  TGdkEventWindowState* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    changed_mask*: TGdkWindowState
-    new_window_state*: TGdkWindowState
-
-  PGdkEventDND* = ptr TGdkEventDND
-  TGdkEventDND* {.final, pure.} = object
-    `type`*: TGdkEventType
-    window*: PGdkWindow
-    send_event*: gint8
-    context*: PGdkDragContext
-    time*: guint32
-    x_root*: gshort
-    y_root*: gshort
-
-  TGdkEvent* {.final, pure.} = object
-    data*: array[0..255, char] # union of
-                               # `type`: TGdkEventType
-                               #  any: TGdkEventAny
-                               #  expose: TGdkEventExpose
-                               #  no_expose: TGdkEventNoExpose
-                               #  visibility: TGdkEventVisibility
-                               #  motion: TGdkEventMotion
-                               #  button: TGdkEventButton
-                               #  scroll: TGdkEventScroll
-                               #  key: TGdkEventKey
-                               #  crossing: TGdkEventCrossing
-                               #  focus_change: TGdkEventFocus
-                               #  configure: TGdkEventConfigure
-                               #  `property`: TGdkEventProperty
-                               #  selection: TGdkEventSelection
-                               #  proximity: TGdkEventProximity
-                               #  client: TGdkEventClient
-                               #  dnd: TGdkEventDND
-                               #  window_state: TGdkEventWindowState
-                               #  setting: TGdkEventSetting
-
-  PGdkGCClass* = ptr TGdkGCClass
-  TGdkGCClass* = object of TGObjectClass
-    get_values*: proc (gc: PGdkGC, values: PGdkGCValues){.cdecl.}
-    set_values*: proc (gc: PGdkGC, values: PGdkGCValues, mask: TGdkGCValuesMask){.
-        cdecl.}
-    set_dashes*: proc (gc: PGdkGC, dash_offset: gint,
-                       dash_list: openarray[gint8]){.cdecl.}
-    `gdk_reserved1`*: proc (){.cdecl.}
-    `gdk_reserved2`*: proc (){.cdecl.}
-    `gdk_reserved3`*: proc (){.cdecl.}
-    `gdk_reserved4`*: proc (){.cdecl.}
-
-  PGdkImageClass* = ptr TGdkImageClass
-  TGdkImageClass* = object of TGObjectClass
-
-  TGdkImage* = object of TGObject
-    `type`*: TGdkImageType
-    visual*: PGdkVisual
-    byte_order*: TGdkByteOrder
-    width*: gint
-    height*: gint
-    depth*: guint16
-    bpp*: guint16
-    bpl*: guint16
-    bits_per_pixel*: guint16
-    mem*: gpointer
-    colormap*: PGdkColormap
-    windowing_data*: gpointer
-
-  PGdkExtensionMode* = ptr TGdkExtensionMode
-  TGdkExtensionMode* = enum
-    GDK_EXTENSION_EVENTS_NONE, GDK_EXTENSION_EVENTS_ALL,
-    GDK_EXTENSION_EVENTS_CURSOR
-  PGdkInputSource* = ptr TGdkInputSource
-  TGdkInputSource* = enum
-    GDK_SOURCE_MOUSE, GDK_SOURCE_PEN, GDK_SOURCE_ERASER, GDK_SOURCE_CURSOR
-  PGdkInputMode* = ptr TGdkInputMode
-  TGdkInputMode* = enum
-    GDK_MODE_DISABLED, GDK_MODE_SCREEN, GDK_MODE_WINDOW
-  PGdkAxisUse* = ptr TGdkAxisUse
-  TGdkAxisUse* = int32
-  PGdkDeviceKey* = ptr TGdkDeviceKey
-  TGdkDeviceKey* {.final, pure.} = object
-    keyval*: guint
-    modifiers*: TGdkModifierType
-
-  PGdkDeviceAxis* = ptr TGdkDeviceAxis
-  TGdkDeviceAxis* {.final, pure.} = object
-    use*: TGdkAxisUse
-    min*: gdouble
-    max*: gdouble
-
-  TGdkDevice* = object of TGObject
-    name*: cstring
-    source*: TGdkInputSource
-    mode*: TGdkInputMode
-    has_cursor*: gboolean
-    num_axes*: gint
-    axes*: PGdkDeviceAxis
-    num_keys*: gint
-    keys*: PGdkDeviceKey
-
-  TGdkTimeCoord* {.final, pure.} = object
-    time*: guint32
-    axes*: array[0..(GDK_MAX_TIMECOORD_AXES) - 1, gdouble]
-
-  PGdkKeymapKey* = ptr TGdkKeymapKey
-  TGdkKeymapKey* {.final, pure.} = object
-    keycode*: guint
-    group*: gint
-    level*: gint
-
-  PGdkKeymap* = ptr TGdkKeymap
-  TGdkKeymap* = object of TGObject
-    display*: PGdkDisplay
-
-  PGdkKeymapClass* = ptr TGdkKeymapClass
-  TGdkKeymapClass* = object of TGObjectClass
-    direction_changed*: proc (keymap: PGdkKeymap){.cdecl.}
-
-  PGdkPangoAttrStipple* = ptr TGdkPangoAttrStipple
-  TGdkPangoAttrStipple* {.final, pure.} = object
-    attr*: TPangoAttribute
-    stipple*: PGdkBitmap
-
-  PGdkPangoAttrEmbossed* = ptr TGdkPangoAttrEmbossed
-  TGdkPangoAttrEmbossed* {.final, pure.} = object
-    attr*: TPangoAttribute
-    embossed*: gboolean
-
-  PGdkPixmapObject* = ptr TGdkPixmapObject
-  TGdkPixmapObject* = object of TGdkDrawable
-    impl*: PGdkDrawable
-    depth*: gint
-
-  PGdkPixmapObjectClass* = ptr TGdkPixmapObjectClass
-  TGdkPixmapObjectClass* = object of TGdkDrawableClass
-
-  PGdkPropMode* = ptr TGdkPropMode
-  TGdkPropMode* = enum
-    GDK_PROP_MODE_REPLACE, GDK_PROP_MODE_PREPEND, GDK_PROP_MODE_APPEND
-  PGdkFillRule* = ptr TGdkFillRule
-  TGdkFillRule* = enum
-    GDK_EVEN_ODD_RULE, GDK_WINDING_RULE
-  PGdkOverlapType* = ptr TGdkOverlapType
-  TGdkOverlapType* = enum
-    GDK_OVERLAP_RECTANGLE_IN, GDK_OVERLAP_RECTANGLE_OUT,
-    GDK_OVERLAP_RECTANGLE_PART
-  TGdkSpanFunc* = proc (span: PGdkSpan, data: gpointer){.cdecl.}
-  PGdkRgbCmap* = ptr TGdkRgbCmap
-  TGdkRgbCmap* {.final, pure.} = object
-    colors*: array[0..255, guint32]
-    n_colors*: gint
-    info_list*: PGSList
-
-  TGdkDisplay* = object of TGObject
-    queued_events*: PGList
-    queued_tail*: PGList
-    button_click_time*: array[0..1, guint32]
-    button_window*: array[0..1, PGdkWindow]
-    button_number*: array[0..1, guint]
-    double_click_time*: guint
-
-  PGdkDisplayClass* = ptr TGdkDisplayClass
-  TGdkDisplayClass* = object of TGObjectClass
-    get_display_name*: proc (display: PGdkDisplay): cstring{.cdecl.}
-    get_n_screens*: proc (display: PGdkDisplay): gint{.cdecl.}
-    get_screen*: proc (display: PGdkDisplay, screen_num: gint): PGdkScreen{.
-        cdecl.}
-    get_default_screen*: proc (display: PGdkDisplay): PGdkScreen{.cdecl.}
-
-  PGdkScreenClass* = ptr TGdkScreenClass
-  TGdkScreenClass* = object of TGObjectClass
-    get_display*: proc (screen: PGdkScreen): PGdkDisplay{.cdecl.}
-    get_width*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_height*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_width_mm*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_height_mm*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_root_depth*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_screen_num*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_root_window*: proc (screen: PGdkScreen): PGdkWindow{.cdecl.}
-    get_default_colormap*: proc (screen: PGdkScreen): PGdkColormap{.cdecl.}
-    set_default_colormap*: proc (screen: PGdkScreen, colormap: PGdkColormap){.
-        cdecl.}
-    get_window_at_pointer*: proc (screen: PGdkScreen, win_x: Pgint, win_y: Pgint): PGdkWindow{.
-        cdecl.}
-    get_n_monitors*: proc (screen: PGdkScreen): gint{.cdecl.}
-    get_monitor_geometry*: proc (screen: PGdkScreen, monitor_num: gint,
-                                 dest: PGdkRectangle){.cdecl.}
-
-  PGdkGrabStatus* = ptr TGdkGrabStatus
-  TGdkGrabStatus* = int
-  TGdkInputFunction* = proc (data: gpointer, source: gint,
-                             condition: TGdkInputCondition){.cdecl.}
-  TGdkDestroyNotify* = proc (data: gpointer){.cdecl.}
-  TGdkSpan* {.final, pure.} = object
-    x*: gint
-    y*: gint
-    width*: gint
-
-  PGdkWindowClass* = ptr TGdkWindowClass
-  TGdkWindowClass* = enum
-    GDK_INPUT_OUTPUT, GDK_INPUT_ONLY
-  PGdkWindowType* = ptr TGdkWindowType
-  TGdkWindowType* = enum
-    GDK_WINDOW_ROOT, GDK_WINDOW_TOPLEVEL, GDK_WINDOW_CHILD, GDK_WINDOW_DIALOG,
-    GDK_WINDOW_TEMP, GDK_WINDOW_FOREIGN
-  PGdkWindowAttributesType* = ptr TGdkWindowAttributesType
-  TGdkWindowAttributesType* = int32
-  PGdkWindowHints* = ptr TGdkWindowHints
-  TGdkWindowHints* = int32
-  PGdkWindowTypeHint* = ptr TGdkWindowTypeHint
-  TGdkWindowTypeHint* = enum
-    GDK_WINDOW_TYPE_HINT_NORMAL, GDK_WINDOW_TYPE_HINT_DIALOG,
-    GDK_WINDOW_TYPE_HINT_MENU, GDK_WINDOW_TYPE_HINT_TOOLBAR
-  PGdkWMDecoration* = ptr TGdkWMDecoration
-  TGdkWMDecoration* = int32
-  PGdkWMFunction* = ptr TGdkWMFunction
-  TGdkWMFunction* = int32
-  PGdkGravity* = ptr TGdkGravity
-  TGdkGravity* = int
-  PGdkWindowEdge* = ptr TGdkWindowEdge
-  TGdkWindowEdge* = enum
-    GDK_WINDOW_EDGE_NORTH_WEST, GDK_WINDOW_EDGE_NORTH,
-    GDK_WINDOW_EDGE_NORTH_EAST, GDK_WINDOW_EDGE_WEST, GDK_WINDOW_EDGE_EAST,
-    GDK_WINDOW_EDGE_SOUTH_WEST, GDK_WINDOW_EDGE_SOUTH,
-    GDK_WINDOW_EDGE_SOUTH_EAST
-  PGdkWindowAttr* = ptr TGdkWindowAttr
-  TGdkWindowAttr* {.final, pure.} = object
-    title*: cstring
-    event_mask*: gint
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-    wclass*: TGdkWindowClass
-    visual*: PGdkVisual
-    colormap*: PGdkColormap
-    window_type*: TGdkWindowType
-    cursor*: PGdkCursor
-    wmclass_name*: cstring
-    wmclass_class*: cstring
-    override_redirect*: gboolean
-
-  PGdkGeometry* = ptr TGdkGeometry
-  TGdkGeometry* {.final, pure.} = object
-    min_width*: gint
-    min_height*: gint
-    max_width*: gint
-    max_height*: gint
-    base_width*: gint
-    base_height*: gint
-    width_inc*: gint
-    height_inc*: gint
-    min_aspect*: gdouble
-    max_aspect*: gdouble
-    win_gravity*: TGdkGravity
-
-  PGdkPointerHooks* = ptr TGdkPointerHooks
-  TGdkPointerHooks* {.final, pure.} = object
-    get_pointer*: proc (window: PGdkWindow, x: Pgint, y: Pgint,
-                        mask: PGdkModifierType): PGdkWindow{.cdecl.}
-    window_at_pointer*: proc (screen: PGdkScreen, win_x: Pgint, win_y: Pgint): PGdkWindow{.
-        cdecl.}
-
-  PGdkWindowObject* = ptr TGdkWindowObject
-  TGdkWindowObject* = object of TGdkDrawable
-    impl*: PGdkDrawable
-    parent*: PGdkWindowObject
-    user_data*: gpointer
-    x*: gint
-    y*: gint
-    extension_events*: gint
-    filters*: PGList
-    children*: PGList
-    bg_color*: TGdkColor
-    bg_pixmap*: PGdkPixmap
-    paint_stack*: PGSList
-    update_area*: PGdkRegion
-    update_freeze_count*: guint
-    window_type*: guint8
-    depth*: guint8
-    resize_count*: guint8
-    state*: TGdkWindowState
-    flag0*: guint16
-    event_mask*: TGdkEventMask
-
-  PGdkWindowObjectClass* = ptr TGdkWindowObjectClass
-  TGdkWindowObjectClass* = object of TGdkDrawableClass
-
-  gdk_window_invalidate_maybe_recurse_child_func* = proc (para1: PGdkWindow,
-      para2: gpointer): gboolean
-
-proc GDK_TYPE_COLORMAP*(): GType
-proc GDK_COLORMAP*(anObject: pointer): PGdkColormap
-proc GDK_COLORMAP_CLASS*(klass: pointer): PGdkColormapClass
-proc GDK_IS_COLORMAP*(anObject: pointer): bool
-proc GDK_IS_COLORMAP_CLASS*(klass: pointer): bool
-proc GDK_COLORMAP_GET_CLASS*(obj: pointer): PGdkColormapClass
-proc GDK_TYPE_COLOR*(): GType
-proc gdk_colormap_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                      importc: "gdk_colormap_get_type".}
-proc gdk_colormap_new*(visual: PGdkVisual, allocate: gboolean): PGdkColormap{.
-    cdecl, dynlib: gdklib, importc: "gdk_colormap_new".}
-proc gdk_colormap_alloc_colors*(colormap: PGdkColormap, colors: PGdkColor,
-                                ncolors: gint, writeable: gboolean,
-                                best_match: gboolean, success: Pgboolean): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_colormap_alloc_colors".}
-proc gdk_colormap_alloc_color*(colormap: PGdkColormap, color: PGdkColor,
-                               writeable: gboolean, best_match: gboolean): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_colormap_alloc_color".}
-proc gdk_colormap_free_colors*(colormap: PGdkColormap, colors: PGdkColor,
-                               ncolors: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_colormap_free_colors".}
-proc gdk_colormap_query_color*(colormap: PGdkColormap, pixel: gulong,
-                               result: PGdkColor){.cdecl, dynlib: gdklib,
-    importc: "gdk_colormap_query_color".}
-proc gdk_colormap_get_visual*(colormap: PGdkColormap): PGdkVisual{.cdecl,
-    dynlib: gdklib, importc: "gdk_colormap_get_visual".}
-proc gdk_color_copy*(color: PGdkColor): PGdkColor{.cdecl, dynlib: gdklib,
-    importc: "gdk_color_copy".}
-proc gdk_color_free*(color: PGdkColor){.cdecl, dynlib: gdklib,
-                                        importc: "gdk_color_free".}
-proc gdk_color_parse*(spec: cstring, color: PGdkColor): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_color_parse".}
-proc gdk_color_hash*(colora: PGdkColor): guint{.cdecl, dynlib: gdklib,
-    importc: "gdk_color_hash".}
-proc gdk_color_equal*(colora: PGdkColor, colorb: PGdkColor): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_color_equal".}
-proc gdk_color_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                   importc: "gdk_color_get_type".}
-const
-  GDK_CURSOR_IS_PIXMAP* = - (1)
-  GDK_X_CURSOR* = 0
-  GDK_ARROW* = 2
-  GDK_BASED_ARROW_DOWN* = 4
-  GDK_BASED_ARROW_UP* = 6
-  GDK_BOAT* = 8
-  GDK_BOGOSITY* = 10
-  GDK_BOTTOM_LEFT_CORNER* = 12
-  GDK_BOTTOM_RIGHT_CORNER* = 14
-  GDK_BOTTOM_SIDE* = 16
-  GDK_BOTTOM_TEE* = 18
-  GDK_BOX_SPIRAL* = 20
-  GDK_CENTER_PTR* = 22
-  GDK_CIRCLE* = 24
-  GDK_CLOCK* = 26
-  GDK_COFFEE_MUG* = 28
-  GDK_CROSS* = 30
-  GDK_CROSS_REVERSE* = 32
-  GDK_CROSSHAIR* = 34
-  GDK_DIAMOND_CROSS* = 36
-  GDK_DOT* = 38
-  GDK_DOTBOX* = 40
-  GDK_DOUBLE_ARROW* = 42
-  GDK_DRAFT_LARGE* = 44
-  GDK_DRAFT_SMALL* = 46
-  GDK_DRAPED_BOX* = 48
-  GDK_EXCHANGE* = 50
-  GDK_FLEUR* = 52
-  GDK_GOBBLER* = 54
-  GDK_GUMBY* = 56
-  GDK_HAND1* = 58
-  GDK_HAND2* = 60
-  GDK_HEART* = 62
-  GDK_ICON* = 64
-  GDK_IRON_CROSS* = 66
-  GDK_LEFT_PTR* = 68
-  GDK_LEFT_SIDE* = 70
-  GDK_LEFT_TEE* = 72
-  GDK_LEFTBUTTON* = 74
-  GDK_LL_ANGLE* = 76
-  GDK_LR_ANGLE* = 78
-  GDK_MAN* = 80
-  GDK_MIDDLEBUTTON* = 82
-  GDK_MOUSE* = 84
-  GDK_PENCIL* = 86
-  GDK_PIRATE* = 88
-  GDK_PLUS* = 90
-  GDK_QUESTION_ARROW* = 92
-  GDK_RIGHT_PTR* = 94
-  GDK_RIGHT_SIDE* = 96
-  GDK_RIGHT_TEE* = 98
-  GDK_RIGHTBUTTON* = 100
-  GDK_RTL_LOGO* = 102
-  GDK_SAILBOAT* = 104
-  GDK_SB_DOWN_ARROW* = 106
-  GDK_SB_H_DOUBLE_ARROW* = 108
-  GDK_SB_LEFT_ARROW* = 110
-  GDK_SB_RIGHT_ARROW* = 112
-  GDK_SB_UP_ARROW* = 114
-  GDK_SB_V_DOUBLE_ARROW* = 116
-  GDK_SHUTTLE* = 118
-  GDK_SIZING* = 120
-  GDK_SPIDER* = 122
-  GDK_SPRAYCAN* = 124
-  GDK_STAR* = 126
-  GDK_TARGET* = 128
-  GDK_TCROSS* = 130
-  GDK_TOP_LEFT_ARROW* = 132
-  GDK_TOP_LEFT_CORNER* = 134
-  GDK_TOP_RIGHT_CORNER* = 136
-  GDK_TOP_SIDE* = 138
-  GDK_TOP_TEE* = 140
-  GDK_TREK* = 142
-  GDK_UL_ANGLE* = 144
-  GDK_UMBRELLA* = 146
-  GDK_UR_ANGLE* = 148
-  GDK_WATCH* = 150
-  GDK_XTERM* = 152
-  GDK_LAST_CURSOR* = GDK_XTERM + 1
-
-proc GDK_TYPE_CURSOR*(): GType
-proc gdk_cursor_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_cursor_get_type".}
-proc gdk_cursor_new_for_screen*(screen: PGdkScreen, cursor_type: TGdkCursorType): PGdkCursor{.
-    cdecl, dynlib: gdklib, importc: "gdk_cursor_new_for_screen".}
-proc gdk_cursor_new_from_pixmap*(source: PGdkPixmap, mask: PGdkPixmap,
-                                 fg: PGdkColor, bg: PGdkColor, x: gint, y: gint): PGdkCursor{.
-    cdecl, dynlib: gdklib, importc: "gdk_cursor_new_from_pixmap".}
-proc gdk_cursor_get_screen*(cursor: PGdkCursor): PGdkScreen{.cdecl,
-    dynlib: gdklib, importc: "gdk_cursor_get_screen".}
-proc gdk_cursor_ref*(cursor: PGdkCursor): PGdkCursor{.cdecl, dynlib: gdklib,
-    importc: "gdk_cursor_ref".}
-proc gdk_cursor_unref*(cursor: PGdkCursor){.cdecl, dynlib: gdklib,
-    importc: "gdk_cursor_unref".}
-const
-  GDK_ACTION_DEFAULT* = 1 shl 0
-  GDK_ACTION_COPY* = 1 shl 1
-  GDK_ACTION_MOVE* = 1 shl 2
-  GDK_ACTION_LINK* = 1 shl 3
-  GDK_ACTION_PRIVATE* = 1 shl 4
-  GDK_ACTION_ASK* = 1 shl 5
-
-proc GDK_TYPE_DRAG_CONTEXT*(): GType
-proc GDK_DRAG_CONTEXT*(anObject: Pointer): PGdkDragContext
-proc GDK_DRAG_CONTEXT_CLASS*(klass: Pointer): PGdkDragContextClass
-proc GDK_IS_DRAG_CONTEXT*(anObject: Pointer): bool
-proc GDK_IS_DRAG_CONTEXT_CLASS*(klass: Pointer): bool
-proc GDK_DRAG_CONTEXT_GET_CLASS*(obj: Pointer): PGdkDragContextClass
-proc gdk_drag_context_get_type*(): GType{.cdecl, dynlib: gdklib,
-    importc: "gdk_drag_context_get_type".}
-proc gdk_drag_context_new*(): PGdkDragContext{.cdecl, dynlib: gdklib,
-    importc: "gdk_drag_context_new".}
-proc gdk_drag_status*(context: PGdkDragContext, action: TGdkDragAction,
-                      time: guint32){.cdecl, dynlib: gdklib,
-                                      importc: "gdk_drag_status".}
-proc gdk_drop_reply*(context: PGdkDragContext, ok: gboolean, time: guint32){.
-    cdecl, dynlib: gdklib, importc: "gdk_drop_reply".}
-proc gdk_drop_finish*(context: PGdkDragContext, success: gboolean, time: guint32){.
-    cdecl, dynlib: gdklib, importc: "gdk_drop_finish".}
-proc gdk_drag_get_selection*(context: PGdkDragContext): TGdkAtom{.cdecl,
-    dynlib: gdklib, importc: "gdk_drag_get_selection".}
-proc gdk_drag_begin*(window: PGdkWindow, targets: PGList): PGdkDragContext{.
-    cdecl, dynlib: gdklib, importc: "gdk_drag_begin".}
-proc gdk_drag_get_protocol_for_display*(display: PGdkDisplay, xid: guint32,
-                                        protocol: PGdkDragProtocol): guint32{.
-    cdecl, dynlib: gdklib, importc: "gdk_drag_get_protocol_for_display".}
-proc gdk_drag_find_window*(context: PGdkDragContext, drag_window: PGdkWindow,
-                           x_root: gint, y_root: gint, w: var PGdkWindow,
-                           protocol: PGdkDragProtocol){.cdecl, dynlib: gdklib,
-    importc: "gdk_drag_find_window".}
-proc gdk_drag_motion*(context: PGdkDragContext, dest_window: PGdkWindow,
-                      protocol: TGdkDragProtocol, x_root: gint, y_root: gint,
-                      suggested_action: TGdkDragAction,
-                      possible_actions: TGdkDragAction, time: guint32): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_drag_motion".}
-proc gdk_drag_drop*(context: PGdkDragContext, time: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_drag_drop".}
-proc gdk_drag_abort*(context: PGdkDragContext, time: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_drag_abort".}
-proc gdkregion_EXTENTCHECK*(r1, r2: PGdkRegionBox): bool
-proc gdkregion_EXTENTS*(r: PGdkRegionBox, idRect: PGdkRegion)
-proc gdkregion_MEMCHECK*(reg: PGdkRegion, ARect, firstrect: var PGdkRegionBox): bool
-proc gdkregion_CHECK_PREVIOUS*(Reg: PGdkRegion, R: PGdkRegionBox,
-                               Rx1, Ry1, Rx2, Ry2: gint): bool
-proc gdkregion_ADDRECT*(reg: PGdkRegion, r: PGdkRegionBox,
-                        rx1, ry1, rx2, ry2: gint)
-proc gdkregion_ADDRECTNOX*(reg: PGdkRegion, r: PGdkRegionBox,
-                           rx1, ry1, rx2, ry2: gint)
-proc gdkregion_EMPTY_REGION*(pReg: PGdkRegion): bool
-proc gdkregion_REGION_NOT_EMPTY*(pReg: PGdkRegion): bool
-proc gdkregion_INBOX*(r: TGdkRegionBox, x, y: gint): bool
-proc GDK_TYPE_DRAWABLE*(): GType
-proc GDK_DRAWABLE*(anObject: Pointer): PGdkDrawable
-proc GDK_DRAWABLE_CLASS*(klass: Pointer): PGdkDrawableClass
-proc GDK_IS_DRAWABLE*(anObject: Pointer): bool
-proc GDK_IS_DRAWABLE_CLASS*(klass: Pointer): bool
-proc GDK_DRAWABLE_GET_CLASS*(obj: Pointer): PGdkDrawableClass
-proc gdk_drawable_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                      importc: "gdk_drawable_get_type".}
-proc gdk_drawable_get_size*(drawable: PGdkDrawable, width: Pgint, height: Pgint){.
-    cdecl, dynlib: gdklib, importc: "gdk_drawable_get_size".}
-proc gdk_drawable_set_colormap*(drawable: PGdkDrawable, colormap: PGdkColormap){.
-    cdecl, dynlib: gdklib, importc: "gdk_drawable_set_colormap".}
-proc gdk_drawable_get_colormap*(drawable: PGdkDrawable): PGdkColormap{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_colormap".}
-proc gdk_drawable_get_visual*(drawable: PGdkDrawable): PGdkVisual{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_visual".}
-proc gdk_drawable_get_depth*(drawable: PGdkDrawable): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_depth".}
-proc gdk_drawable_get_screen*(drawable: PGdkDrawable): PGdkScreen{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_screen".}
-proc gdk_drawable_get_display*(drawable: PGdkDrawable): PGdkDisplay{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_display".}
-proc gdk_draw_point*(drawable: PGdkDrawable, gc: PGdkGC, x: gint, y: gint){.
-    cdecl, dynlib: gdklib, importc: "gdk_draw_point".}
-proc gdk_draw_line*(drawable: PGdkDrawable, gc: PGdkGC, x1: gint, y1: gint,
-                    x2: gint, y2: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_line".}
-proc gdk_draw_rectangle*(drawable: PGdkDrawable, gc: PGdkGC, filled: gint,
-                         x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_draw_rectangle".}
-proc gdk_draw_arc*(drawable: PGdkDrawable, gc: PGdkGC, filled: gint, x: gint,
-                   y: gint, width: gint, height: gint, angle1: gint,
-                   angle2: gint){.cdecl, dynlib: gdklib, importc: "gdk_draw_arc".}
-proc gdk_draw_polygon*(drawable: PGdkDrawable, gc: PGdkGC, filled: gint,
-                       points: PGdkPoint, npoints: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_polygon".}
-proc gdk_draw_drawable*(drawable: PGdkDrawable, gc: PGdkGC, src: PGdkDrawable,
-                        xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                        width: gint, height: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_drawable".}
-proc gdk_draw_image*(drawable: PGdkDrawable, gc: PGdkGC, image: PGdkImage,
-                     xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                     width: gint, height: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_image".}
-proc gdk_draw_points*(drawable: PGdkDrawable, gc: PGdkGC, points: PGdkPoint,
-                      npoints: gint){.cdecl, dynlib: gdklib,
-                                      importc: "gdk_draw_points".}
-proc gdk_draw_segments*(drawable: PGdkDrawable, gc: PGdkGC, segs: PGdkSegment,
-                        nsegs: gint){.cdecl, dynlib: gdklib,
-                                      importc: "gdk_draw_segments".}
-proc gdk_draw_lines*(drawable: PGdkDrawable, gc: PGdkGC, points: PGdkPoint,
-                     npoints: gint){.cdecl, dynlib: gdklib,
-                                     importc: "gdk_draw_lines".}
-proc gdk_draw_glyphs*(drawable: PGdkDrawable, gc: PGdkGC, font: PPangoFont,
-                      x: gint, y: gint, glyphs: PPangoGlyphString){.cdecl,
-    dynlib: gdklib, importc: "gdk_draw_glyphs".}
-proc gdk_draw_layout_line*(drawable: PGdkDrawable, gc: PGdkGC, x: gint, y: gint,
-                           line: PPangoLayoutLine){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_layout_line".}
-proc gdk_draw_layout*(drawable: PGdkDrawable, gc: PGdkGC, x: gint, y: gint,
-                      layout: PPangoLayout){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_layout".}
-proc gdk_draw_layout_line_with_colors*(drawable: PGdkDrawable, gc: PGdkGC,
-                                       x: gint, y: gint, line: PPangoLayoutLine,
-                                       foreground: PGdkColor,
-                                       background: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_draw_layout_line_with_colors".}
-proc gdk_draw_layout_with_colors*(drawable: PGdkDrawable, gc: PGdkGC, x: gint,
-                                  y: gint, layout: PPangoLayout,
-                                  foreground: PGdkColor, background: PGdkColor){.
-    cdecl, dynlib: gdklib, importc: "gdk_draw_layout_with_colors".}
-proc gdk_drawable_get_image*(drawable: PGdkDrawable, x: gint, y: gint,
-                             width: gint, height: gint): PGdkImage{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_image".}
-proc gdk_drawable_get_clip_region*(drawable: PGdkDrawable): PGdkRegion{.cdecl,
-    dynlib: gdklib, importc: "gdk_drawable_get_clip_region".}
-proc gdk_drawable_get_visible_region*(drawable: PGdkDrawable): PGdkRegion{.
-    cdecl, dynlib: gdklib, importc: "gdk_drawable_get_visible_region".}
-const
-  GDK_NOTHING* = - (1)
-  GDK_DELETE* = 0
-  GDK_DESTROY* = 1
-  GDK_EXPOSE* = 2
-  GDK_MOTION_NOTIFY* = 3
-  GDK_BUTTON_PRESS* = 4
-  GDK_2BUTTON_PRESS* = 5
-  GDK_3BUTTON_PRESS* = 6
-  GDK_BUTTON_RELEASE* = 7
-  GDK_KEY_PRESS* = 8
-  GDK_KEY_RELEASE* = 9
-  GDK_ENTER_NOTIFY* = 10
-  GDK_LEAVE_NOTIFY* = 11
-  GDK_FOCUS_CHANGE* = 12
-  GDK_CONFIGURE* = 13
-  GDK_MAP* = 14
-  GDK_UNMAP* = 15
-  GDK_PROPERTY_NOTIFY* = 16
-  GDK_SELECTION_CLEAR* = 17
-  GDK_SELECTION_REQUEST* = 18
-  GDK_SELECTION_NOTIFY* = 19
-  GDK_PROXIMITY_IN* = 20
-  GDK_PROXIMITY_OUT* = 21
-  GDK_DRAG_ENTER* = 22
-  GDK_DRAG_LEAVE* = 23
-  GDK_DRAG_MOTION_EVENT* = 24
-  GDK_DRAG_STATUS_EVENT* = 25
-  GDK_DROP_START* = 26
-  GDK_DROP_FINISHED* = 27
-  GDK_CLIENT_EVENT* = 28
-  GDK_VISIBILITY_NOTIFY* = 29
-  GDK_NO_EXPOSE* = 30
-  GDK_SCROLL* = 31
-  GDK_WINDOW_STATE* = 32
-  GDK_SETTING* = 33
-  GDK_NOTIFY_ANCESTOR* = 0
-  GDK_NOTIFY_VIRTUAL* = 1
-  GDK_NOTIFY_INFERIOR* = 2
-  GDK_NOTIFY_NONLINEAR* = 3
-  GDK_NOTIFY_NONLINEAR_VIRTUAL* = 4
-  GDK_NOTIFY_UNKNOWN* = 5
-
-proc GDK_TYPE_EVENT*(): GType
-const
-  G_PRIORITY_DEFAULT* = 0
-  GDK_PRIORITY_EVENTS* = G_PRIORITY_DEFAULT
-    #GDK_PRIORITY_REDRAW* = G_PRIORITY_HIGH_IDLE + 20
-  GDK_EXPOSURE_MASK* = 1 shl 1
-  GDK_POINTER_MOTION_MASK* = 1 shl 2
-  GDK_POINTER_MOTION_HINT_MASK* = 1 shl 3
-  GDK_BUTTON_MOTION_MASK* = 1 shl 4
-  GDK_BUTTON1_MOTION_MASK* = 1 shl 5
-  GDK_BUTTON2_MOTION_MASK* = 1 shl 6
-  GDK_BUTTON3_MOTION_MASK* = 1 shl 7
-  GDK_BUTTON_PRESS_MASK* = 1 shl 8
-  GDK_BUTTON_RELEASE_MASK* = 1 shl 9
-  GDK_KEY_PRESS_MASK* = 1 shl 10
-  GDK_KEY_RELEASE_MASK* = 1 shl 11
-  GDK_ENTER_NOTIFY_MASK* = 1 shl 12
-  GDK_LEAVE_NOTIFY_MASK* = 1 shl 13
-  GDK_FOCUS_CHANGE_MASK* = 1 shl 14
-  GDK_STRUCTURE_MASK* = 1 shl 15
-  GDK_PROPERTY_CHANGE_MASK* = 1 shl 16
-  GDK_VISIBILITY_NOTIFY_MASK* = 1 shl 17
-  GDK_PROXIMITY_IN_MASK* = 1 shl 18
-  GDK_PROXIMITY_OUT_MASK* = 1 shl 19
-  GDK_SUBSTRUCTURE_MASK* = 1 shl 20
-  GDK_SCROLL_MASK* = 1 shl 21
-  GDK_ALL_EVENTS_MASK* = 0x003FFFFE
-  GDK_WINDOW_STATE_WITHDRAWN* = 1 shl 0
-  GDK_WINDOW_STATE_ICONIFIED* = 1 shl 1
-  GDK_WINDOW_STATE_MAXIMIZED* = 1 shl 2
-  GDK_WINDOW_STATE_STICKY* = 1 shl 3
-
-proc gdk_event_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                   importc: "gdk_event_get_type".}
-proc gdk_events_pending*(): gboolean{.cdecl, dynlib: gdklib,
-                                      importc: "gdk_events_pending".}
-proc gdk_event_get*(): PGdkEvent{.cdecl, dynlib: gdklib,
-                                  importc: "gdk_event_get".}
-proc gdk_event_peek*(): PGdkEvent{.cdecl, dynlib: gdklib,
-                                   importc: "gdk_event_peek".}
-proc gdk_event_get_graphics_expose*(window: PGdkWindow): PGdkEvent{.cdecl,
-    dynlib: gdklib, importc: "gdk_event_get_graphics_expose".}
-proc gdk_event_put*(event: PGdkEvent){.cdecl, dynlib: gdklib,
-                                       importc: "gdk_event_put".}
-proc gdk_event_copy*(event: PGdkEvent): PGdkEvent{.cdecl, dynlib: gdklib,
-    importc: "gdk_event_copy".}
-proc gdk_event_free*(event: PGdkEvent){.cdecl, dynlib: gdklib,
-                                        importc: "gdk_event_free".}
-proc gdk_event_get_time*(event: PGdkEvent): guint32{.cdecl, dynlib: gdklib,
-    importc: "gdk_event_get_time".}
-proc gdk_event_get_state*(event: PGdkEvent, state: PGdkModifierType): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_event_get_state".}
-proc gdk_event_get_coords*(event: PGdkEvent, x_win: Pgdouble, y_win: Pgdouble): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_event_get_coords".}
-proc gdk_event_get_root_coords*(event: PGdkEvent, x_root: Pgdouble,
-                                y_root: Pgdouble): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_event_get_root_coords".}
-proc gdk_event_get_axis*(event: PGdkEvent, axis_use: TGdkAxisUse,
-                         value: Pgdouble): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_event_get_axis".}
-proc gdk_event_handler_set*(func: TGdkEventFunc, data: gpointer,
-                            notify: TGDestroyNotify){.cdecl, dynlib: gdklib,
-    importc: "gdk_event_handler_set".}
-proc gdk_set_show_events*(show_events: gboolean){.cdecl, dynlib: gdklib,
-    importc: "gdk_set_show_events".}
-proc gdk_get_show_events*(): gboolean{.cdecl, dynlib: gdklib,
-                                       importc: "gdk_get_show_events".}
-proc GDK_TYPE_FONT*(): GType
-proc gdk_font_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                  importc: "gdk_font_get_type".}
-proc gdk_font_load_for_display*(display: PGdkDisplay, font_name: cstring): PGdkFont{.
-    cdecl, dynlib: gdklib, importc: "gdk_font_load_for_display".}
-proc gdk_fontset_load_for_display*(display: PGdkDisplay, fontset_name: cstring): PGdkFont{.
-    cdecl, dynlib: gdklib, importc: "gdk_fontset_load_for_display".}
-proc gdk_font_from_description_for_display*(display: PGdkDisplay,
-    font_desc: PPangoFontDescription): PGdkFont{.cdecl, dynlib: gdklib,
-    importc: "gdk_font_from_description_for_display".}
-proc gdk_font_ref*(font: PGdkFont): PGdkFont{.cdecl, dynlib: gdklib,
-    importc: "gdk_font_ref".}
-proc gdk_font_unref*(font: PGdkFont){.cdecl, dynlib: gdklib,
-                                      importc: "gdk_font_unref".}
-proc gdk_font_id*(font: PGdkFont): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_font_id".}
-proc gdk_font_equal*(fonta: PGdkFont, fontb: PGdkFont): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_font_equal".}
-proc gdk_string_width*(font: PGdkFont, `string`: cstring): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_string_width".}
-proc gdk_text_width*(font: PGdkFont, text: cstring, text_length: gint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_text_width".}
-proc gdk_text_width_wc*(font: PGdkFont, text: PGdkWChar, text_length: gint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_text_width_wc".}
-proc gdk_char_width*(font: PGdkFont, character: gchar): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_char_width".}
-proc gdk_char_width_wc*(font: PGdkFont, character: TGdkWChar): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_char_width_wc".}
-proc gdk_string_measure*(font: PGdkFont, `string`: cstring): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_string_measure".}
-proc gdk_text_measure*(font: PGdkFont, text: cstring, text_length: gint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_text_measure".}
-proc gdk_char_measure*(font: PGdkFont, character: gchar): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_char_measure".}
-proc gdk_string_height*(font: PGdkFont, `string`: cstring): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_string_height".}
-proc gdk_text_height*(font: PGdkFont, text: cstring, text_length: gint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_text_height".}
-proc gdk_char_height*(font: PGdkFont, character: gchar): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_char_height".}
-proc gdk_text_extents*(font: PGdkFont, text: cstring, text_length: gint,
-                       lbearing: Pgint, rbearing: Pgint, width: Pgint,
-                       ascent: Pgint, descent: Pgint){.cdecl, dynlib: gdklib,
-    importc: "gdk_text_extents".}
-proc gdk_text_extents_wc*(font: PGdkFont, text: PGdkWChar, text_length: gint,
-                          lbearing: Pgint, rbearing: Pgint, width: Pgint,
-                          ascent: Pgint, descent: Pgint){.cdecl, dynlib: gdklib,
-    importc: "gdk_text_extents_wc".}
-proc gdk_string_extents*(font: PGdkFont, `string`: cstring, lbearing: Pgint,
-                         rbearing: Pgint, width: Pgint, ascent: Pgint,
-                         descent: Pgint){.cdecl, dynlib: gdklib,
-    importc: "gdk_string_extents".}
-proc gdk_font_get_display*(font: PGdkFont): PGdkDisplay{.cdecl, dynlib: gdklib,
-    importc: "gdk_font_get_display".}
-const
-  GDK_GC_FOREGROUND* = 1 shl 0
-  GDK_GC_BACKGROUND* = 1 shl 1
-  GDK_GC_FONT* = 1 shl 2
-  GDK_GC_FUNCTION* = 1 shl 3
-  GDK_GC_FILL* = 1 shl 4
-  GDK_GC_TILE* = 1 shl 5
-  GDK_GC_STIPPLE* = 1 shl 6
-  GDK_GC_CLIP_MASK* = 1 shl 7
-  GDK_GC_SUBWINDOW* = 1 shl 8
-  GDK_GC_TS_X_ORIGIN* = 1 shl 9
-  GDK_GC_TS_Y_ORIGIN* = 1 shl 10
-  GDK_GC_CLIP_X_ORIGIN* = 1 shl 11
-  GDK_GC_CLIP_Y_ORIGIN* = 1 shl 12
-  GDK_GC_EXPOSURES* = 1 shl 13
-  GDK_GC_LINE_WIDTH* = 1 shl 14
-  GDK_GC_LINE_STYLE* = 1 shl 15
-  GDK_GC_CAP_STYLE* = 1 shl 16
-  GDK_GC_JOIN_STYLE* = 1 shl 17
-  GDK_CLIP_BY_CHILDREN* = 0
-  GDK_INCLUDE_INFERIORS* = 1
-
-proc GDK_TYPE_GC*(): GType
-proc GDK_GC*(anObject: Pointer): PGdkGC
-proc GDK_GC_CLASS*(klass: Pointer): PGdkGCClass
-proc GDK_IS_GC*(anObject: Pointer): bool
-proc GDK_IS_GC_CLASS*(klass: Pointer): bool
-proc GDK_GC_GET_CLASS*(obj: Pointer): PGdkGCClass
-proc gdk_gc_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                importc: "gdk_gc_get_type".}
-proc gdk_gc_new*(drawable: PGdkDrawable): PGdkGC{.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_new".}
-proc gdk_gc_new_with_values*(drawable: PGdkDrawable, values: PGdkGCValues,
-                             values_mask: TGdkGCValuesMask): PGdkGC{.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_new_with_values".}
-proc gdk_gc_get_values*(gc: PGdkGC, values: PGdkGCValues){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_get_values".}
-proc gdk_gc_set_values*(gc: PGdkGC, values: PGdkGCValues,
-                        values_mask: TGdkGCValuesMask){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_values".}
-proc gdk_gc_set_foreground*(gc: PGdkGC, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_foreground".}
-proc gdk_gc_set_background*(gc: PGdkGC, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_background".}
-proc gdk_gc_set_function*(gc: PGdkGC, `function`: TGdkFunction){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_function".}
-proc gdk_gc_set_fill*(gc: PGdkGC, fill: TGdkFill){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_fill".}
-proc gdk_gc_set_tile*(gc: PGdkGC, tile: PGdkPixmap){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_tile".}
-proc gdk_gc_set_stipple*(gc: PGdkGC, stipple: PGdkPixmap){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_stipple".}
-proc gdk_gc_set_ts_origin*(gc: PGdkGC, x: gint, y: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_ts_origin".}
-proc gdk_gc_set_clip_origin*(gc: PGdkGC, x: gint, y: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_clip_origin".}
-proc gdk_gc_set_clip_mask*(gc: PGdkGC, mask: PGdkBitmap){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_clip_mask".}
-proc gdk_gc_set_clip_rectangle*(gc: PGdkGC, rectangle: PGdkRectangle){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_clip_rectangle".}
-proc gdk_gc_set_clip_region*(gc: PGdkGC, region: PGdkRegion){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_clip_region".}
-proc gdk_gc_set_subwindow*(gc: PGdkGC, mode: TGdkSubwindowMode){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_subwindow".}
-proc gdk_gc_set_exposures*(gc: PGdkGC, exposures: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_exposures".}
-proc gdk_gc_set_line_attributes*(gc: PGdkGC, line_width: gint,
-                                 line_style: TGdkLineStyle,
-                                 cap_style: TGdkCapStyle,
-                                 join_style: TGdkJoinStyle){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_line_attributes".}
-proc gdk_gc_set_dashes*(gc: PGdkGC, dash_offset: gint,
-                        dash_list: openarray[gint8]){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_set_dashes".}
-proc gdk_gc_offset*(gc: PGdkGC, x_offset: gint, y_offset: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_offset".}
-proc gdk_gc_copy*(dst_gc: PGdkGC, src_gc: PGdkGC){.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_copy".}
-proc gdk_gc_set_colormap*(gc: PGdkGC, colormap: PGdkColormap){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_colormap".}
-proc gdk_gc_get_colormap*(gc: PGdkGC): PGdkColormap{.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_get_colormap".}
-proc gdk_gc_set_rgb_fg_color*(gc: PGdkGC, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_rgb_fg_color".}
-proc gdk_gc_set_rgb_bg_color*(gc: PGdkGC, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_gc_set_rgb_bg_color".}
-proc gdk_gc_get_screen*(gc: PGdkGC): PGdkScreen{.cdecl, dynlib: gdklib,
-    importc: "gdk_gc_get_screen".}
-proc GDK_TYPE_IMAGE*(): GType
-proc GDK_IMAGE*(anObject: Pointer): PGdkImage
-proc GDK_IMAGE_CLASS*(klass: Pointer): PGdkImageClass
-proc GDK_IS_IMAGE*(anObject: Pointer): bool
-proc GDK_IS_IMAGE_CLASS*(klass: Pointer): bool
-proc GDK_IMAGE_GET_CLASS*(obj: Pointer): PGdkImageClass
-proc gdk_image_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                   importc: "gdk_image_get_type".}
-proc gdk_image_new*(`type`: TGdkImageType, visual: PGdkVisual, width: gint,
-                    height: gint): PGdkImage{.cdecl, dynlib: gdklib,
-    importc: "gdk_image_new".}
-proc gdk_image_put_pixel*(image: PGdkImage, x: gint, y: gint, pixel: guint32){.
-    cdecl, dynlib: gdklib, importc: "gdk_image_put_pixel".}
-proc gdk_image_get_pixel*(image: PGdkImage, x: gint, y: gint): guint32{.cdecl,
-    dynlib: gdklib, importc: "gdk_image_get_pixel".}
-proc gdk_image_set_colormap*(image: PGdkImage, colormap: PGdkColormap){.cdecl,
-    dynlib: gdklib, importc: "gdk_image_set_colormap".}
-proc gdk_image_get_colormap*(image: PGdkImage): PGdkColormap{.cdecl,
-    dynlib: gdklib, importc: "gdk_image_get_colormap".}
-const
-  GDK_AXIS_IGNORE* = 0
-  GDK_AXIS_X* = 1
-  GDK_AXIS_Y* = 2
-  GDK_AXIS_PRESSURE* = 3
-  GDK_AXIS_XTILT* = 4
-  GDK_AXIS_YTILT* = 5
-  GDK_AXIS_WHEEL* = 6
-  GDK_AXIS_LAST* = 7
-
-proc GDK_TYPE_DEVICE*(): GType
-proc GDK_DEVICE*(anObject: Pointer): PGdkDevice
-proc GDK_DEVICE_CLASS*(klass: Pointer): PGdkDeviceClass
-proc GDK_IS_DEVICE*(anObject: Pointer): bool
-proc GDK_IS_DEVICE_CLASS*(klass: Pointer): bool
-proc GDK_DEVICE_GET_CLASS*(obj: Pointer): PGdkDeviceClass
-proc gdk_device_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_device_get_type".}
-proc gdk_device_set_source*(device: PGdkDevice, source: TGdkInputSource){.cdecl,
-    dynlib: gdklib, importc: "gdk_device_set_source".}
-proc gdk_device_set_mode*(device: PGdkDevice, mode: TGdkInputMode): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_device_set_mode".}
-proc gdk_device_set_key*(device: PGdkDevice, index: guint, keyval: guint,
-                         modifiers: TGdkModifierType){.cdecl, dynlib: gdklib,
-    importc: "gdk_device_set_key".}
-proc gdk_device_set_axis_use*(device: PGdkDevice, index: guint, use: TGdkAxisUse){.
-    cdecl, dynlib: gdklib, importc: "gdk_device_set_axis_use".}
-proc gdk_device_get_state*(device: PGdkDevice, window: PGdkWindow,
-                           axes: Pgdouble, mask: PGdkModifierType){.cdecl,
-    dynlib: gdklib, importc: "gdk_device_get_state".}
-proc gdk_device_get_history*(device: PGdkDevice, window: PGdkWindow,
-                             start: guint32, stop: guint32,
-                             s: var PPGdkTimeCoord, n_events: Pgint): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_device_get_history".}
-proc gdk_device_free_history*(events: PPGdkTimeCoord, n_events: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_device_free_history".}
-proc gdk_device_get_axis*(device: PGdkDevice, axes: Pgdouble, use: TGdkAxisUse,
-                          value: Pgdouble): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_device_get_axis".}
-proc gdk_input_set_extension_events*(window: PGdkWindow, mask: gint,
-                                     mode: TGdkExtensionMode){.cdecl,
-    dynlib: gdklib, importc: "gdk_input_set_extension_events".}
-proc gdk_device_get_core_pointer*(): PGdkDevice{.cdecl, dynlib: gdklib,
-    importc: "gdk_device_get_core_pointer".}
-proc GDK_TYPE_KEYMAP*(): GType
-proc GDK_KEYMAP*(anObject: Pointer): PGdkKeymap
-proc GDK_KEYMAP_CLASS*(klass: Pointer): PGdkKeymapClass
-proc GDK_IS_KEYMAP*(anObject: Pointer): bool
-proc GDK_IS_KEYMAP_CLASS*(klass: Pointer): bool
-proc GDK_KEYMAP_GET_CLASS*(obj: Pointer): PGdkKeymapClass
-proc gdk_keymap_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_keymap_get_type".}
-proc gdk_keymap_get_for_display*(display: PGdkDisplay): PGdkKeymap{.cdecl,
-    dynlib: gdklib, importc: "gdk_keymap_get_for_display".}
-proc gdk_keymap_lookup_key*(keymap: PGdkKeymap, key: PGdkKeymapKey): guint{.
-    cdecl, dynlib: gdklib, importc: "gdk_keymap_lookup_key".}
-proc gdk_keymap_translate_keyboard_state*(keymap: PGdkKeymap,
-    hardware_keycode: guint, state: TGdkModifierType, group: gint,
-    keyval: Pguint, effective_group: Pgint, level: Pgint,
-    consumed_modifiers: PGdkModifierType): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_keymap_translate_keyboard_state".}
-proc gdk_keymap_get_entries_for_keyval*(keymap: PGdkKeymap, keyval: guint,
-                                        s: var PGdkKeymapKey, n_keys: Pgint): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_keymap_get_entries_for_keyval".}
-proc gdk_keymap_get_entries_for_keycode*(keymap: PGdkKeymap,
-    hardware_keycode: guint, s: var PGdkKeymapKey, sasdf: var Pguint,
-    n_entries: Pgint): gboolean{.cdecl, dynlib: gdklib,
-                                 importc: "gdk_keymap_get_entries_for_keycode".}
-proc gdk_keymap_get_direction*(keymap: PGdkKeymap): TPangoDirection{.cdecl,
-    dynlib: gdklib, importc: "gdk_keymap_get_direction".}
-proc gdk_keyval_name*(keyval: guint): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_name".}
-proc gdk_keyval_from_name*(keyval_name: cstring): guint{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_from_name".}
-proc gdk_keyval_convert_case*(symbol: guint, lower: Pguint, upper: Pguint){.
-    cdecl, dynlib: gdklib, importc: "gdk_keyval_convert_case".}
-proc gdk_keyval_to_upper*(keyval: guint): guint{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_to_upper".}
-proc gdk_keyval_to_lower*(keyval: guint): guint{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_to_lower".}
-proc gdk_keyval_is_upper*(keyval: guint): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_is_upper".}
-proc gdk_keyval_is_lower*(keyval: guint): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_is_lower".}
-proc gdk_keyval_to_unicode*(keyval: guint): guint32{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyval_to_unicode".}
-proc gdk_unicode_to_keyval*(wc: guint32): guint{.cdecl, dynlib: gdklib,
-    importc: "gdk_unicode_to_keyval".}
-const
-  GDK_KEY_VoidSymbol* = 0x00FFFFFF
-  GDK_KEY_BackSpace* = 0x0000FF08
-  GDK_KEY_Tab* = 0x0000FF09
-  GDK_KEY_Linefeed* = 0x0000FF0A
-  GDK_KEY_Clear* = 0x0000FF0B
-  GDK_KEY_Return* = 0x0000FF0D
-  GDK_KEY_Pause* = 0x0000FF13
-  GDK_KEY_Scroll_Lock* = 0x0000FF14
-  GDK_KEY_Sys_Req* = 0x0000FF15
-  GDK_KEY_Escape* = 0x0000FF1B
-  GDK_KEY_Delete* = 0x0000FFFF
-  GDK_KEY_Multi_key* = 0x0000FF20
-  GDK_KEY_Codeinput* = 0x0000FF37
-  GDK_KEY_SingleCandidate* = 0x0000FF3C
-  GDK_KEY_MultipleCandidate* = 0x0000FF3D
-  GDK_KEY_PreviousCandidate* = 0x0000FF3E
-  GDK_KEY_Kanji* = 0x0000FF21
-  GDK_KEY_Muhenkan* = 0x0000FF22
-  GDK_KEY_Henkan_Mode* = 0x0000FF23
-  GDK_KEY_Henkan* = 0x0000FF23
-  GDK_KEY_Romaji* = 0x0000FF24
-  GDK_KEY_Hiragana* = 0x0000FF25
-  GDK_KEY_Katakana* = 0x0000FF26
-  GDK_KEY_Hiragana_Katakana* = 0x0000FF27
-  GDK_KEY_Zenkaku* = 0x0000FF28
-  GDK_KEY_Hankaku* = 0x0000FF29
-  GDK_KEY_Zenkaku_Hankaku* = 0x0000FF2A
-  GDK_KEY_Touroku* = 0x0000FF2B
-  GDK_KEY_Massyo* = 0x0000FF2C
-  GDK_KEY_Kana_Lock* = 0x0000FF2D
-  GDK_KEY_Kana_Shift* = 0x0000FF2E
-  GDK_KEY_Eisu_Shift* = 0x0000FF2F
-  GDK_KEY_Eisu_toggle* = 0x0000FF30
-  GDK_KEY_Kanji_Bangou* = 0x0000FF37
-  GDK_KEY_Zen_Koho* = 0x0000FF3D
-  GDK_KEY_Mae_Koho* = 0x0000FF3E
-  GDK_KEY_Home* = 0x0000FF50
-  GDK_KEY_Left* = 0x0000FF51
-  GDK_KEY_Up* = 0x0000FF52
-  GDK_KEY_Right* = 0x0000FF53
-  GDK_KEY_Down* = 0x0000FF54
-  GDK_KEY_Prior* = 0x0000FF55
-  GDK_KEY_Page_Up* = 0x0000FF55
-  GDK_KEY_Next* = 0x0000FF56
-  GDK_KEY_Page_Down* = 0x0000FF56
-  GDK_KEY_End* = 0x0000FF57
-  GDK_KEY_Begin* = 0x0000FF58
-  GDK_KEY_Select* = 0x0000FF60
-  GDK_KEY_Print* = 0x0000FF61
-  GDK_KEY_Execute* = 0x0000FF62
-  GDK_KEY_Insert* = 0x0000FF63
-  GDK_KEY_Undo* = 0x0000FF65
-  GDK_KEY_Redo* = 0x0000FF66
-  GDK_KEY_Menu* = 0x0000FF67
-  GDK_KEY_Find* = 0x0000FF68
-  GDK_KEY_Cancel* = 0x0000FF69
-  GDK_KEY_Help* = 0x0000FF6A
-  GDK_KEY_Break* = 0x0000FF6B
-  GDK_KEY_Mode_switch* = 0x0000FF7E
-  GDK_KEY_script_switch* = 0x0000FF7E
-  GDK_KEY_Num_Lock* = 0x0000FF7F
-  GDK_KEY_KP_Space* = 0x0000FF80
-  GDK_KEY_KP_Tab* = 0x0000FF89
-  GDK_KEY_KP_Enter* = 0x0000FF8D
-  GDK_KEY_KP_F1* = 0x0000FF91
-  GDK_KEY_KP_F2* = 0x0000FF92
-  GDK_KEY_KP_F3* = 0x0000FF93
-  GDK_KEY_KP_F4* = 0x0000FF94
-  GDK_KEY_KP_Home* = 0x0000FF95
-  GDK_KEY_KP_Left* = 0x0000FF96
-  GDK_KEY_KP_Up* = 0x0000FF97
-  GDK_KEY_KP_Right* = 0x0000FF98
-  GDK_KEY_KP_Down* = 0x0000FF99
-  GDK_KEY_KP_Prior* = 0x0000FF9A
-  GDK_KEY_KP_Page_Up* = 0x0000FF9A
-  GDK_KEY_KP_Next* = 0x0000FF9B
-  GDK_KEY_KP_Page_Down* = 0x0000FF9B
-  GDK_KEY_KP_End* = 0x0000FF9C
-  GDK_KEY_KP_Begin* = 0x0000FF9D
-  GDK_KEY_KP_Insert* = 0x0000FF9E
-  GDK_KEY_KP_Delete* = 0x0000FF9F
-  GDK_KEY_KP_Equal* = 0x0000FFBD
-  GDK_KEY_KP_Multiply* = 0x0000FFAA
-  GDK_KEY_KP_Add* = 0x0000FFAB
-  GDK_KEY_KP_Separator* = 0x0000FFAC
-  GDK_KEY_KP_Subtract* = 0x0000FFAD
-  GDK_KEY_KP_Decimal* = 0x0000FFAE
-  GDK_KEY_KP_Divide* = 0x0000FFAF
-  GDK_KEY_KP_0* = 0x0000FFB0
-  GDK_KEY_KP_1* = 0x0000FFB1
-  GDK_KEY_KP_2* = 0x0000FFB2
-  GDK_KEY_KP_3* = 0x0000FFB3
-  GDK_KEY_KP_4* = 0x0000FFB4
-  GDK_KEY_KP_5* = 0x0000FFB5
-  GDK_KEY_KP_6* = 0x0000FFB6
-  GDK_KEY_KP_7* = 0x0000FFB7
-  GDK_KEY_KP_8* = 0x0000FFB8
-  GDK_KEY_KP_9* = 0x0000FFB9
-  GDK_KEY_F1* = 0x0000FFBE
-  GDK_KEY_F2* = 0x0000FFBF
-  GDK_KEY_F3* = 0x0000FFC0
-  GDK_KEY_F4* = 0x0000FFC1
-  GDK_KEY_F5* = 0x0000FFC2
-  GDK_KEY_F6* = 0x0000FFC3
-  GDK_KEY_F7* = 0x0000FFC4
-  GDK_KEY_F8* = 0x0000FFC5
-  GDK_KEY_F9* = 0x0000FFC6
-  GDK_KEY_F10* = 0x0000FFC7
-  GDK_KEY_F11* = 0x0000FFC8
-  GDK_KEY_L1* = 0x0000FFC8
-  GDK_KEY_F12* = 0x0000FFC9
-  GDK_KEY_L2* = 0x0000FFC9
-  GDK_KEY_F13* = 0x0000FFCA
-  GDK_KEY_L3* = 0x0000FFCA
-  GDK_KEY_F14* = 0x0000FFCB
-  GDK_KEY_L4* = 0x0000FFCB
-  GDK_KEY_F15* = 0x0000FFCC
-  GDK_KEY_L5* = 0x0000FFCC
-  GDK_KEY_F16* = 0x0000FFCD
-  GDK_KEY_L6* = 0x0000FFCD
-  GDK_KEY_F17* = 0x0000FFCE
-  GDK_KEY_L7* = 0x0000FFCE
-  GDK_KEY_F18* = 0x0000FFCF
-  GDK_KEY_L8* = 0x0000FFCF
-  GDK_KEY_F19* = 0x0000FFD0
-  GDK_KEY_L9* = 0x0000FFD0
-  GDK_KEY_F20* = 0x0000FFD1
-  GDK_KEY_L10* = 0x0000FFD1
-  GDK_KEY_F21* = 0x0000FFD2
-  GDK_KEY_R1* = 0x0000FFD2
-  GDK_KEY_F22* = 0x0000FFD3
-  GDK_KEY_R2* = 0x0000FFD3
-  GDK_KEY_F23* = 0x0000FFD4
-  GDK_KEY_R3* = 0x0000FFD4
-  GDK_KEY_F24* = 0x0000FFD5
-  GDK_KEY_R4* = 0x0000FFD5
-  GDK_KEY_F25* = 0x0000FFD6
-  GDK_KEY_R5* = 0x0000FFD6
-  GDK_KEY_F26* = 0x0000FFD7
-  GDK_KEY_R6* = 0x0000FFD7
-  GDK_KEY_F27* = 0x0000FFD8
-  GDK_KEY_R7* = 0x0000FFD8
-  GDK_KEY_F28* = 0x0000FFD9
-  GDK_KEY_R8* = 0x0000FFD9
-  GDK_KEY_F29* = 0x0000FFDA
-  GDK_KEY_R9* = 0x0000FFDA
-  GDK_KEY_F30* = 0x0000FFDB
-  GDK_KEY_R10* = 0x0000FFDB
-  GDK_KEY_F31* = 0x0000FFDC
-  GDK_KEY_R11* = 0x0000FFDC
-  GDK_KEY_F32* = 0x0000FFDD
-  GDK_KEY_R12* = 0x0000FFDD
-  GDK_KEY_F33* = 0x0000FFDE
-  GDK_KEY_R13* = 0x0000FFDE
-  GDK_KEY_F34* = 0x0000FFDF
-  GDK_KEY_R14* = 0x0000FFDF
-  GDK_KEY_F35* = 0x0000FFE0
-  GDK_KEY_R15* = 0x0000FFE0
-  GDK_KEY_Shift_L* = 0x0000FFE1
-  GDK_KEY_Shift_R* = 0x0000FFE2
-  GDK_KEY_Control_L* = 0x0000FFE3
-  GDK_KEY_Control_R* = 0x0000FFE4
-  GDK_KEY_Caps_Lock* = 0x0000FFE5
-  GDK_KEY_Shift_Lock* = 0x0000FFE6
-  GDK_KEY_Meta_L* = 0x0000FFE7
-  GDK_KEY_Meta_R* = 0x0000FFE8
-  GDK_KEY_Alt_L* = 0x0000FFE9
-  GDK_KEY_Alt_R* = 0x0000FFEA
-  GDK_KEY_Super_L* = 0x0000FFEB
-  GDK_KEY_Super_R* = 0x0000FFEC
-  GDK_KEY_Hyper_L* = 0x0000FFED
-  GDK_KEY_Hyper_R* = 0x0000FFEE
-  GDK_KEY_ISO_Lock* = 0x0000FE01
-  GDK_KEY_ISO_Level2_Latch* = 0x0000FE02
-  GDK_KEY_ISO_Level3_Shift* = 0x0000FE03
-  GDK_KEY_ISO_Level3_Latch* = 0x0000FE04
-  GDK_KEY_ISO_Level3_Lock* = 0x0000FE05
-  GDK_KEY_ISO_Group_Shift* = 0x0000FF7E
-  GDK_KEY_ISO_Group_Latch* = 0x0000FE06
-  GDK_KEY_ISO_Group_Lock* = 0x0000FE07
-  GDK_KEY_ISO_Next_Group* = 0x0000FE08
-  GDK_KEY_ISO_Next_Group_Lock* = 0x0000FE09
-  GDK_KEY_ISO_Prev_Group* = 0x0000FE0A
-  GDK_KEY_ISO_Prev_Group_Lock* = 0x0000FE0B
-  GDK_KEY_ISO_First_Group* = 0x0000FE0C
-  GDK_KEY_ISO_First_Group_Lock* = 0x0000FE0D
-  GDK_KEY_ISO_Last_Group* = 0x0000FE0E
-  GDK_KEY_ISO_Last_Group_Lock* = 0x0000FE0F
-  GDK_KEY_ISO_Left_Tab* = 0x0000FE20
-  GDK_KEY_ISO_Move_Line_Up* = 0x0000FE21
-  GDK_KEY_ISO_Move_Line_Down* = 0x0000FE22
-  GDK_KEY_ISO_Partial_Line_Up* = 0x0000FE23
-  GDK_KEY_ISO_Partial_Line_Down* = 0x0000FE24
-  GDK_KEY_ISO_Partial_Space_Left* = 0x0000FE25
-  GDK_KEY_ISO_Partial_Space_Right* = 0x0000FE26
-  GDK_KEY_ISO_Set_Margin_Left* = 0x0000FE27
-  GDK_KEY_ISO_Set_Margin_Right* = 0x0000FE28
-  GDK_KEY_ISO_Release_Margin_Left* = 0x0000FE29
-  GDK_KEY_ISO_Release_Margin_Right* = 0x0000FE2A
-  GDK_KEY_ISO_Release_Both_Margins* = 0x0000FE2B
-  GDK_KEY_ISO_Fast_Cursor_Left* = 0x0000FE2C
-  GDK_KEY_ISO_Fast_Cursor_Right* = 0x0000FE2D
-  GDK_KEY_ISO_Fast_Cursor_Up* = 0x0000FE2E
-  GDK_KEY_ISO_Fast_Cursor_Down* = 0x0000FE2F
-  GDK_KEY_ISO_Continuous_Underline* = 0x0000FE30
-  GDK_KEY_ISO_Discontinuous_Underline* = 0x0000FE31
-  GDK_KEY_ISO_Emphasize* = 0x0000FE32
-  GDK_KEY_ISO_Center_Object* = 0x0000FE33
-  GDK_KEY_ISO_Enter* = 0x0000FE34
-  GDK_KEY_dead_grave* = 0x0000FE50
-  GDK_KEY_dead_acute* = 0x0000FE51
-  GDK_KEY_dead_circumflex* = 0x0000FE52
-  GDK_KEY_dead_tilde* = 0x0000FE53
-  GDK_KEY_dead_macron* = 0x0000FE54
-  GDK_KEY_dead_breve* = 0x0000FE55
-  GDK_KEY_dead_abovedot* = 0x0000FE56
-  GDK_KEY_dead_diaeresis* = 0x0000FE57
-  GDK_KEY_dead_abovering* = 0x0000FE58
-  GDK_KEY_dead_doubleacute* = 0x0000FE59
-  GDK_KEY_dead_caron* = 0x0000FE5A
-  GDK_KEY_dead_cedilla* = 0x0000FE5B
-  GDK_KEY_dead_ogonek* = 0x0000FE5C
-  GDK_KEY_dead_iota* = 0x0000FE5D
-  GDK_KEY_dead_voiced_sound* = 0x0000FE5E
-  GDK_KEY_dead_semivoiced_sound* = 0x0000FE5F
-  GDK_KEY_dead_belowdot* = 0x0000FE60
-  GDK_KEY_First_Virtual_Screen* = 0x0000FED0
-  GDK_KEY_Prev_Virtual_Screen* = 0x0000FED1
-  GDK_KEY_Next_Virtual_Screen* = 0x0000FED2
-  GDK_KEY_Last_Virtual_Screen* = 0x0000FED4
-  GDK_KEY_Terminate_Server* = 0x0000FED5
-  GDK_KEY_AccessX_Enable* = 0x0000FE70
-  GDK_KEY_AccessX_Feedback_Enable* = 0x0000FE71
-  GDK_KEY_RepeatKeys_Enable* = 0x0000FE72
-  GDK_KEY_SlowKeys_Enable* = 0x0000FE73
-  GDK_KEY_BounceKeys_Enable* = 0x0000FE74
-  GDK_KEY_StickyKeys_Enable* = 0x0000FE75
-  GDK_KEY_MouseKeys_Enable* = 0x0000FE76
-  GDK_KEY_MouseKeys_Accel_Enable* = 0x0000FE77
-  GDK_KEY_Overlay1_Enable* = 0x0000FE78
-  GDK_KEY_Overlay2_Enable* = 0x0000FE79
-  GDK_KEY_AudibleBell_Enable* = 0x0000FE7A
-  GDK_KEY_Pointer_Left* = 0x0000FEE0
-  GDK_KEY_Pointer_Right* = 0x0000FEE1
-  GDK_KEY_Pointer_Up* = 0x0000FEE2
-  GDK_KEY_Pointer_Down* = 0x0000FEE3
-  GDK_KEY_Pointer_UpLeft* = 0x0000FEE4
-  GDK_KEY_Pointer_UpRight* = 0x0000FEE5
-  GDK_KEY_Pointer_DownLeft* = 0x0000FEE6
-  GDK_KEY_Pointer_DownRight* = 0x0000FEE7
-  GDK_KEY_Pointer_Button_Dflt* = 0x0000FEE8
-  GDK_KEY_Pointer_Button1* = 0x0000FEE9
-  GDK_KEY_Pointer_Button2* = 0x0000FEEA
-  GDK_KEY_Pointer_Button3* = 0x0000FEEB
-  GDK_KEY_Pointer_Button4* = 0x0000FEEC
-  GDK_KEY_Pointer_Button5* = 0x0000FEED
-  GDK_KEY_Pointer_DblClick_Dflt* = 0x0000FEEE
-  GDK_KEY_Pointer_DblClick1* = 0x0000FEEF
-  GDK_KEY_Pointer_DblClick2* = 0x0000FEF0
-  GDK_KEY_Pointer_DblClick3* = 0x0000FEF1
-  GDK_KEY_Pointer_DblClick4* = 0x0000FEF2
-  GDK_KEY_Pointer_DblClick5* = 0x0000FEF3
-  GDK_KEY_Pointer_Drag_Dflt* = 0x0000FEF4
-  GDK_KEY_Pointer_Drag1* = 0x0000FEF5
-  GDK_KEY_Pointer_Drag2* = 0x0000FEF6
-  GDK_KEY_Pointer_Drag3* = 0x0000FEF7
-  GDK_KEY_Pointer_Drag4* = 0x0000FEF8
-  GDK_KEY_Pointer_Drag5* = 0x0000FEFD
-  GDK_KEY_Pointer_EnableKeys* = 0x0000FEF9
-  GDK_KEY_Pointer_Accelerate* = 0x0000FEFA
-  GDK_KEY_Pointer_DfltBtnNext* = 0x0000FEFB
-  GDK_KEY_Pointer_DfltBtnPrev* = 0x0000FEFC
-  GDK_KEY_3270_Duplicate* = 0x0000FD01
-  GDK_KEY_3270_FieldMark* = 0x0000FD02
-  GDK_KEY_3270_Right2* = 0x0000FD03
-  GDK_KEY_3270_Left2* = 0x0000FD04
-  GDK_KEY_3270_BackTab* = 0x0000FD05
-  GDK_KEY_3270_EraseEOF* = 0x0000FD06
-  GDK_KEY_3270_EraseInput* = 0x0000FD07
-  GDK_KEY_3270_Reset* = 0x0000FD08
-  GDK_KEY_3270_Quit* = 0x0000FD09
-  GDK_KEY_3270_PA1* = 0x0000FD0A
-  GDK_KEY_3270_PA2* = 0x0000FD0B
-  GDK_KEY_3270_PA3* = 0x0000FD0C
-  GDK_KEY_3270_Test* = 0x0000FD0D
-  GDK_KEY_3270_Attn* = 0x0000FD0E
-  GDK_KEY_3270_CursorBlink* = 0x0000FD0F
-  GDK_KEY_3270_AltCursor* = 0x0000FD10
-  GDK_KEY_3270_KeyClick* = 0x0000FD11
-  GDK_KEY_3270_Jump* = 0x0000FD12
-  GDK_KEY_3270_Ident* = 0x0000FD13
-  GDK_KEY_3270_Rule* = 0x0000FD14
-  GDK_KEY_3270_Copy* = 0x0000FD15
-  GDK_KEY_3270_Play* = 0x0000FD16
-  GDK_KEY_3270_Setup* = 0x0000FD17
-  GDK_KEY_3270_Record* = 0x0000FD18
-  GDK_KEY_3270_ChangeScreen* = 0x0000FD19
-  GDK_KEY_3270_DeleteWord* = 0x0000FD1A
-  GDK_KEY_3270_ExSelect* = 0x0000FD1B
-  GDK_KEY_3270_CursorSelect* = 0x0000FD1C
-  GDK_KEY_3270_PrintScreen* = 0x0000FD1D
-  GDK_KEY_3270_Enter* = 0x0000FD1E
-  GDK_KEY_space* = 0x00000020
-  GDK_KEY_exclam* = 0x00000021
-  GDK_KEY_quotedbl* = 0x00000022
-  GDK_KEY_numbersign* = 0x00000023
-  GDK_KEY_dollar* = 0x00000024
-  GDK_KEY_percent* = 0x00000025
-  GDK_KEY_ampersand* = 0x00000026
-  GDK_KEY_apostrophe* = 0x00000027
-  GDK_KEY_quoteright* = 0x00000027
-  GDK_KEY_parenleft* = 0x00000028
-  GDK_KEY_parenright* = 0x00000029
-  GDK_KEY_asterisk* = 0x0000002A
-  GDK_KEY_plus* = 0x0000002B
-  GDK_KEY_comma* = 0x0000002C
-  GDK_KEY_minus* = 0x0000002D
-  GDK_KEY_period* = 0x0000002E
-  GDK_KEY_slash* = 0x0000002F
-  GDK_KEY_0* = 0x00000030
-  GDK_KEY_1* = 0x00000031
-  GDK_KEY_2* = 0x00000032
-  GDK_KEY_3* = 0x00000033
-  GDK_KEY_4* = 0x00000034
-  GDK_KEY_5* = 0x00000035
-  GDK_KEY_6* = 0x00000036
-  GDK_KEY_7* = 0x00000037
-  GDK_KEY_8* = 0x00000038
-  GDK_KEY_9* = 0x00000039
-  GDK_KEY_colon* = 0x0000003A
-  GDK_KEY_semicolon* = 0x0000003B
-  GDK_KEY_less* = 0x0000003C
-  GDK_KEY_equal* = 0x0000003D
-  GDK_KEY_greater* = 0x0000003E
-  GDK_KEY_question* = 0x0000003F
-  GDK_KEY_at* = 0x00000040
-  GDK_KEY_CAPITAL_A* = 0x00000041
-  GDK_KEY_CAPITAL_B* = 0x00000042
-  GDK_KEY_CAPITAL_C* = 0x00000043
-  GDK_KEY_CAPITAL_D* = 0x00000044
-  GDK_KEY_CAPITAL_E* = 0x00000045
-  GDK_KEY_CAPITAL_F* = 0x00000046
-  GDK_KEY_CAPITAL_G* = 0x00000047
-  GDK_KEY_CAPITAL_H* = 0x00000048
-  GDK_KEY_CAPITAL_I* = 0x00000049
-  GDK_KEY_CAPITAL_J* = 0x0000004A
-  GDK_KEY_CAPITAL_K* = 0x0000004B
-  GDK_KEY_CAPITAL_L* = 0x0000004C
-  GDK_KEY_CAPITAL_M* = 0x0000004D
-  GDK_KEY_CAPITAL_N* = 0x0000004E
-  GDK_KEY_CAPITAL_O* = 0x0000004F
-  GDK_KEY_CAPITAL_P* = 0x00000050
-  GDK_KEY_CAPITAL_Q* = 0x00000051
-  GDK_KEY_CAPITAL_R* = 0x00000052
-  GDK_KEY_CAPITAL_S* = 0x00000053
-  GDK_KEY_CAPITAL_T* = 0x00000054
-  GDK_KEY_CAPITAL_U* = 0x00000055
-  GDK_KEY_CAPITAL_V* = 0x00000056
-  GDK_KEY_CAPITAL_W* = 0x00000057
-  GDK_KEY_CAPITAL_X* = 0x00000058
-  GDK_KEY_CAPITAL_Y* = 0x00000059
-  GDK_KEY_CAPITAL_Z* = 0x0000005A
-  GDK_KEY_bracketleft* = 0x0000005B
-  GDK_KEY_backslash* = 0x0000005C
-  GDK_KEY_bracketright* = 0x0000005D
-  GDK_KEY_asciicircum* = 0x0000005E
-  GDK_KEY_underscore* = 0x0000005F
-  GDK_KEY_grave* = 0x00000060
-  GDK_KEY_quoteleft* = 0x00000060
-  GDK_KEY_a* = 0x00000061
-  GDK_KEY_b* = 0x00000062
-  GDK_KEY_c* = 0x00000063
-  GDK_KEY_d* = 0x00000064
-  GDK_KEY_e* = 0x00000065
-  GDK_KEY_f* = 0x00000066
-  GDK_KEY_g* = 0x00000067
-  GDK_KEY_h* = 0x00000068
-  GDK_KEY_i* = 0x00000069
-  GDK_KEY_j* = 0x0000006A
-  GDK_KEY_k* = 0x0000006B
-  GDK_KEY_l* = 0x0000006C
-  GDK_KEY_m* = 0x0000006D
-  GDK_KEY_n* = 0x0000006E
-  GDK_KEY_o* = 0x0000006F
-  GDK_KEY_p* = 0x00000070
-  GDK_KEY_q* = 0x00000071
-  GDK_KEY_r* = 0x00000072
-  GDK_KEY_s* = 0x00000073
-  GDK_KEY_t* = 0x00000074
-  GDK_KEY_u* = 0x00000075
-  GDK_KEY_v* = 0x00000076
-  GDK_KEY_w* = 0x00000077
-  GDK_KEY_x* = 0x00000078
-  GDK_KEY_y* = 0x00000079
-  GDK_KEY_z* = 0x0000007A
-  GDK_KEY_braceleft* = 0x0000007B
-  GDK_KEY_bar* = 0x0000007C
-  GDK_KEY_braceright* = 0x0000007D
-  GDK_KEY_asciitilde* = 0x0000007E
-  GDK_KEY_nobreakspace* = 0x000000A0
-  GDK_KEY_exclamdown* = 0x000000A1
-  GDK_KEY_cent* = 0x000000A2
-  GDK_KEY_sterling* = 0x000000A3
-  GDK_KEY_currency* = 0x000000A4
-  GDK_KEY_yen* = 0x000000A5
-  GDK_KEY_brokenbar* = 0x000000A6
-  GDK_KEY_section* = 0x000000A7
-  GDK_KEY_diaeresis* = 0x000000A8
-  GDK_KEY_copyright* = 0x000000A9
-  GDK_KEY_ordfeminine* = 0x000000AA
-  GDK_KEY_guillemotleft* = 0x000000AB
-  GDK_KEY_notsign* = 0x000000AC
-  GDK_KEY_hyphen* = 0x000000AD
-  GDK_KEY_registered* = 0x000000AE
-  GDK_KEY_macron* = 0x000000AF
-  GDK_KEY_degree* = 0x000000B0
-  GDK_KEY_plusminus* = 0x000000B1
-  GDK_KEY_twosuperior* = 0x000000B2
-  GDK_KEY_threesuperior* = 0x000000B3
-  GDK_KEY_acute* = 0x000000B4
-  GDK_KEY_mu* = 0x000000B5
-  GDK_KEY_paragraph* = 0x000000B6
-  GDK_KEY_periodcentered* = 0x000000B7
-  GDK_KEY_cedilla* = 0x000000B8
-  GDK_KEY_onesuperior* = 0x000000B9
-  GDK_KEY_masculine* = 0x000000BA
-  GDK_KEY_guillemotright* = 0x000000BB
-  GDK_KEY_onequarter* = 0x000000BC
-  GDK_KEY_onehalf* = 0x000000BD
-  GDK_KEY_threequarters* = 0x000000BE
-  GDK_KEY_questiondown* = 0x000000BF
-  GDK_KEY_CAPITAL_Agrave* = 0x000000C0
-  GDK_KEY_CAPITAL_Aacute* = 0x000000C1
-  GDK_KEY_CAPITAL_Acircumflex* = 0x000000C2
-  GDK_KEY_CAPITAL_Atilde* = 0x000000C3
-  GDK_KEY_CAPITAL_Adiaeresis* = 0x000000C4
-  GDK_KEY_CAPITAL_Aring* = 0x000000C5
-  GDK_KEY_CAPITAL_AE* = 0x000000C6
-  GDK_KEY_CAPITAL_Ccedilla* = 0x000000C7
-  GDK_KEY_CAPITAL_Egrave* = 0x000000C8
-  GDK_KEY_CAPITAL_Eacute* = 0x000000C9
-  GDK_KEY_CAPITAL_Ecircumflex* = 0x000000CA
-  GDK_KEY_CAPITAL_Ediaeresis* = 0x000000CB
-  GDK_KEY_CAPITAL_Igrave* = 0x000000CC
-  GDK_KEY_CAPITAL_Iacute* = 0x000000CD
-  GDK_KEY_CAPITAL_Icircumflex* = 0x000000CE
-  GDK_KEY_CAPITAL_Idiaeresis* = 0x000000CF
-  GDK_KEY_CAPITAL_ETH* = 0x000000D0
-  GDK_KEY_CAPITAL_Ntilde* = 0x000000D1
-  GDK_KEY_CAPITAL_Ograve* = 0x000000D2
-  GDK_KEY_CAPITAL_Oacute* = 0x000000D3
-  GDK_KEY_CAPITAL_Ocircumflex* = 0x000000D4
-  GDK_KEY_CAPITAL_Otilde* = 0x000000D5
-  GDK_KEY_CAPITAL_Odiaeresis* = 0x000000D6
-  GDK_KEY_multiply* = 0x000000D7
-  GDK_KEY_Ooblique* = 0x000000D8
-  GDK_KEY_CAPITAL_Ugrave* = 0x000000D9
-  GDK_KEY_CAPITAL_Uacute* = 0x000000DA
-  GDK_KEY_CAPITAL_Ucircumflex* = 0x000000DB
-  GDK_KEY_CAPITAL_Udiaeresis* = 0x000000DC
-  GDK_KEY_CAPITAL_Yacute* = 0x000000DD
-  GDK_KEY_CAPITAL_THORN* = 0x000000DE
-  GDK_KEY_ssharp* = 0x000000DF
-  GDK_KEY_agrave* = 0x000000E0
-  GDK_KEY_aacute* = 0x000000E1
-  GDK_KEY_acircumflex* = 0x000000E2
-  GDK_KEY_atilde* = 0x000000E3
-  GDK_KEY_adiaeresis* = 0x000000E4
-  GDK_KEY_aring* = 0x000000E5
-  GDK_KEY_ae* = 0x000000E6
-  GDK_KEY_ccedilla* = 0x000000E7
-  GDK_KEY_egrave* = 0x000000E8
-  GDK_KEY_eacute* = 0x000000E9
-  GDK_KEY_ecircumflex* = 0x000000EA
-  GDK_KEY_ediaeresis* = 0x000000EB
-  GDK_KEY_igrave* = 0x000000EC
-  GDK_KEY_iacute* = 0x000000ED
-  GDK_KEY_icircumflex* = 0x000000EE
-  GDK_KEY_idiaeresis* = 0x000000EF
-  GDK_KEY_eth* = 0x000000F0
-  GDK_KEY_ntilde* = 0x000000F1
-  GDK_KEY_ograve* = 0x000000F2
-  GDK_KEY_oacute* = 0x000000F3
-  GDK_KEY_ocircumflex* = 0x000000F4
-  GDK_KEY_otilde* = 0x000000F5
-  GDK_KEY_odiaeresis* = 0x000000F6
-  GDK_KEY_division* = 0x000000F7
-  GDK_KEY_oslash* = 0x000000F8
-  GDK_KEY_ugrave* = 0x000000F9
-  GDK_KEY_uacute* = 0x000000FA
-  GDK_KEY_ucircumflex* = 0x000000FB
-  GDK_KEY_udiaeresis* = 0x000000FC
-  GDK_KEY_yacute* = 0x000000FD
-  GDK_KEY_thorn* = 0x000000FE
-  GDK_KEY_ydiaeresis* = 0x000000FF
-  GDK_KEY_CAPITAL_Aogonek* = 0x000001A1
-  GDK_KEY_breve* = 0x000001A2
-  GDK_KEY_CAPITAL_Lstroke* = 0x000001A3
-  GDK_KEY_CAPITAL_Lcaron* = 0x000001A5
-  GDK_KEY_CAPITAL_Sacute* = 0x000001A6
-  GDK_KEY_CAPITAL_Scaron* = 0x000001A9
-  GDK_KEY_CAPITAL_Scedilla* = 0x000001AA
-  GDK_KEY_CAPITAL_Tcaron* = 0x000001AB
-  GDK_KEY_CAPITAL_Zacute* = 0x000001AC
-  GDK_KEY_CAPITAL_Zcaron* = 0x000001AE
-  GDK_KEY_CAPITAL_Zabovedot* = 0x000001AF
-  GDK_KEY_aogonek* = 0x000001B1
-  GDK_KEY_ogonek* = 0x000001B2
-  GDK_KEY_lstroke* = 0x000001B3
-  GDK_KEY_lcaron* = 0x000001B5
-  GDK_KEY_sacute* = 0x000001B6
-  GDK_KEY_caron* = 0x000001B7
-  GDK_KEY_scaron* = 0x000001B9
-  GDK_KEY_scedilla* = 0x000001BA
-  GDK_KEY_tcaron* = 0x000001BB
-  GDK_KEY_zacute* = 0x000001BC
-  GDK_KEY_doubleacute* = 0x000001BD
-  GDK_KEY_zcaron* = 0x000001BE
-  GDK_KEY_zabovedot* = 0x000001BF
-  GDK_KEY_CAPITAL_Racute* = 0x000001C0
-  GDK_KEY_CAPITAL_Abreve* = 0x000001C3
-  GDK_KEY_CAPITAL_Lacute* = 0x000001C5
-  GDK_KEY_CAPITAL_Cacute* = 0x000001C6
-  GDK_KEY_CAPITAL_Ccaron* = 0x000001C8
-  GDK_KEY_CAPITAL_Eogonek* = 0x000001CA
-  GDK_KEY_CAPITAL_Ecaron* = 0x000001CC
-  GDK_KEY_CAPITAL_Dcaron* = 0x000001CF
-  GDK_KEY_CAPITAL_Dstroke* = 0x000001D0
-  GDK_KEY_CAPITAL_Nacute* = 0x000001D1
-  GDK_KEY_CAPITAL_Ncaron* = 0x000001D2
-  GDK_KEY_CAPITAL_Odoubleacute* = 0x000001D5
-  GDK_KEY_CAPITAL_Rcaron* = 0x000001D8
-  GDK_KEY_CAPITAL_Uring* = 0x000001D9
-  GDK_KEY_CAPITAL_Udoubleacute* = 0x000001DB
-  GDK_KEY_CAPITAL_Tcedilla* = 0x000001DE
-  GDK_KEY_racute* = 0x000001E0
-  GDK_KEY_abreve* = 0x000001E3
-  GDK_KEY_lacute* = 0x000001E5
-  GDK_KEY_cacute* = 0x000001E6
-  GDK_KEY_ccaron* = 0x000001E8
-  GDK_KEY_eogonek* = 0x000001EA
-  GDK_KEY_ecaron* = 0x000001EC
-  GDK_KEY_dcaron* = 0x000001EF
-  GDK_KEY_dstroke* = 0x000001F0
-  GDK_KEY_nacute* = 0x000001F1
-  GDK_KEY_ncaron* = 0x000001F2
-  GDK_KEY_odoubleacute* = 0x000001F5
-  GDK_KEY_udoubleacute* = 0x000001FB
-  GDK_KEY_rcaron* = 0x000001F8
-  GDK_KEY_uring* = 0x000001F9
-  GDK_KEY_tcedilla* = 0x000001FE
-  GDK_KEY_abovedot* = 0x000001FF
-  GDK_KEY_CAPITAL_Hstroke* = 0x000002A1
-  GDK_KEY_CAPITAL_Hcircumflex* = 0x000002A6
-  GDK_KEY_CAPITAL_Iabovedot* = 0x000002A9
-  GDK_KEY_CAPITAL_Gbreve* = 0x000002AB
-  GDK_KEY_CAPITAL_Jcircumflex* = 0x000002AC
-  GDK_KEY_hstroke* = 0x000002B1
-  GDK_KEY_hcircumflex* = 0x000002B6
-  GDK_KEY_idotless* = 0x000002B9
-  GDK_KEY_gbreve* = 0x000002BB
-  GDK_KEY_jcircumflex* = 0x000002BC
-  GDK_KEY_CAPITAL_Cabovedot* = 0x000002C5
-  GDK_KEY_CAPITAL_Ccircumflex* = 0x000002C6
-  GDK_KEY_CAPITAL_Gabovedot* = 0x000002D5
-  GDK_KEY_CAPITAL_Gcircumflex* = 0x000002D8
-  GDK_KEY_CAPITAL_Ubreve* = 0x000002DD
-  GDK_KEY_CAPITAL_Scircumflex* = 0x000002DE
-  GDK_KEY_cabovedot* = 0x000002E5
-  GDK_KEY_ccircumflex* = 0x000002E6
-  GDK_KEY_gabovedot* = 0x000002F5
-  GDK_KEY_gcircumflex* = 0x000002F8
-  GDK_KEY_ubreve* = 0x000002FD
-  GDK_KEY_scircumflex* = 0x000002FE
-  GDK_KEY_kra* = 0x000003A2
-  GDK_KEY_kappa* = 0x000003A2
-  GDK_KEY_CAPITAL_Rcedilla* = 0x000003A3
-  GDK_KEY_CAPITAL_Itilde* = 0x000003A5
-  GDK_KEY_CAPITAL_Lcedilla* = 0x000003A6
-  GDK_KEY_CAPITAL_Emacron* = 0x000003AA
-  GDK_KEY_CAPITAL_Gcedilla* = 0x000003AB
-  GDK_KEY_CAPITAL_Tslash* = 0x000003AC
-  GDK_KEY_rcedilla* = 0x000003B3
-  GDK_KEY_itilde* = 0x000003B5
-  GDK_KEY_lcedilla* = 0x000003B6
-  GDK_KEY_emacron* = 0x000003BA
-  GDK_KEY_gcedilla* = 0x000003BB
-  GDK_KEY_tslash* = 0x000003BC
-  GDK_KEY_CAPITAL_ENG* = 0x000003BD
-  GDK_KEY_eng* = 0x000003BF
-  GDK_KEY_CAPITAL_Amacron* = 0x000003C0
-  GDK_KEY_CAPITAL_Iogonek* = 0x000003C7
-  GDK_KEY_CAPITAL_Eabovedot* = 0x000003CC
-  GDK_KEY_CAPITAL_Imacron* = 0x000003CF
-  GDK_KEY_CAPITAL_Ncedilla* = 0x000003D1
-  GDK_KEY_CAPITAL_Omacron* = 0x000003D2
-  GDK_KEY_CAPITAL_Kcedilla* = 0x000003D3
-  GDK_KEY_CAPITAL_Uogonek* = 0x000003D9
-  GDK_KEY_CAPITAL_Utilde* = 0x000003DD
-  GDK_KEY_CAPITAL_Umacron* = 0x000003DE
-  GDK_KEY_amacron* = 0x000003E0
-  GDK_KEY_iogonek* = 0x000003E7
-  GDK_KEY_eabovedot* = 0x000003EC
-  GDK_KEY_imacron* = 0x000003EF
-  GDK_KEY_ncedilla* = 0x000003F1
-  GDK_KEY_omacron* = 0x000003F2
-  GDK_KEY_kcedilla* = 0x000003F3
-  GDK_KEY_uogonek* = 0x000003F9
-  GDK_KEY_utilde* = 0x000003FD
-  GDK_KEY_umacron* = 0x000003FE
-  GDK_KEY_CAPITAL_OE* = 0x000013BC
-  GDK_KEY_oe* = 0x000013BD
-  GDK_KEY_CAPITAL_Ydiaeresis* = 0x000013BE
-  GDK_KEY_overline* = 0x0000047E
-  GDK_KEY_kana_fullstop* = 0x000004A1
-  GDK_KEY_kana_openingbracket* = 0x000004A2
-  GDK_KEY_kana_closingbracket* = 0x000004A3
-  GDK_KEY_kana_comma* = 0x000004A4
-  GDK_KEY_kana_conjunctive* = 0x000004A5
-  GDK_KEY_kana_middledot* = 0x000004A5
-  GDK_KEY_kana_WO* = 0x000004A6
-  GDK_KEY_kana_a* = 0x000004A7
-  GDK_KEY_kana_i* = 0x000004A8
-  GDK_KEY_kana_u* = 0x000004A9
-  GDK_KEY_kana_e* = 0x000004AA
-  GDK_KEY_kana_o* = 0x000004AB
-  GDK_KEY_kana_ya* = 0x000004AC
-  GDK_KEY_kana_yu* = 0x000004AD
-  GDK_KEY_kana_yo* = 0x000004AE
-  GDK_KEY_kana_tsu* = 0x000004AF
-  GDK_KEY_kana_tu* = 0x000004AF
-  GDK_KEY_prolongedsound* = 0x000004B0
-  GDK_KEY_kana_CAPITAL_A* = 0x000004B1
-  GDK_KEY_kana_CAPITAL_I* = 0x000004B2
-  GDK_KEY_kana_CAPITAL_U* = 0x000004B3
-  GDK_KEY_kana_CAPITAL_E* = 0x000004B4
-  GDK_KEY_kana_CAPITAL_O* = 0x000004B5
-  GDK_KEY_kana_KA* = 0x000004B6
-  GDK_KEY_kana_KI* = 0x000004B7
-  GDK_KEY_kana_KU* = 0x000004B8
-  GDK_KEY_kana_KE* = 0x000004B9
-  GDK_KEY_kana_KO* = 0x000004BA
-  GDK_KEY_kana_SA* = 0x000004BB
-  GDK_KEY_kana_SHI* = 0x000004BC
-  GDK_KEY_kana_SU* = 0x000004BD
-  GDK_KEY_kana_SE* = 0x000004BE
-  GDK_KEY_kana_SO* = 0x000004BF
-  GDK_KEY_kana_TA* = 0x000004C0
-  GDK_KEY_kana_CHI* = 0x000004C1
-  GDK_KEY_kana_TI* = 0x000004C1
-  GDK_KEY_kana_CAPITAL_TSU* = 0x000004C2
-  GDK_KEY_kana_CAPITAL_TU* = 0x000004C2
-  GDK_KEY_kana_TE* = 0x000004C3
-  GDK_KEY_kana_TO* = 0x000004C4
-  GDK_KEY_kana_NA* = 0x000004C5
-  GDK_KEY_kana_NI* = 0x000004C6
-  GDK_KEY_kana_NU* = 0x000004C7
-  GDK_KEY_kana_NE* = 0x000004C8
-  GDK_KEY_kana_NO* = 0x000004C9
-  GDK_KEY_kana_HA* = 0x000004CA
-  GDK_KEY_kana_HI* = 0x000004CB
-  GDK_KEY_kana_FU* = 0x000004CC
-  GDK_KEY_kana_HU* = 0x000004CC
-  GDK_KEY_kana_HE* = 0x000004CD
-  GDK_KEY_kana_HO* = 0x000004CE
-  GDK_KEY_kana_MA* = 0x000004CF
-  GDK_KEY_kana_MI* = 0x000004D0
-  GDK_KEY_kana_MU* = 0x000004D1
-  GDK_KEY_kana_ME* = 0x000004D2
-  GDK_KEY_kana_MO* = 0x000004D3
-  GDK_KEY_kana_CAPITAL_YA* = 0x000004D4
-  GDK_KEY_kana_CAPITAL_YU* = 0x000004D5
-  GDK_KEY_kana_CAPITAL_YO* = 0x000004D6
-  GDK_KEY_kana_RA* = 0x000004D7
-  GDK_KEY_kana_RI* = 0x000004D8
-  GDK_KEY_kana_RU* = 0x000004D9
-  GDK_KEY_kana_RE* = 0x000004DA
-  GDK_KEY_kana_RO* = 0x000004DB
-  GDK_KEY_kana_WA* = 0x000004DC
-  GDK_KEY_kana_N* = 0x000004DD
-  GDK_KEY_voicedsound* = 0x000004DE
-  GDK_KEY_semivoicedsound* = 0x000004DF
-  GDK_KEY_kana_switch* = 0x0000FF7E
-  GDK_KEY_Arabic_comma* = 0x000005AC
-  GDK_KEY_Arabic_semicolon* = 0x000005BB
-  GDK_KEY_Arabic_question_mark* = 0x000005BF
-  GDK_KEY_Arabic_hamza* = 0x000005C1
-  GDK_KEY_Arabic_maddaonalef* = 0x000005C2
-  GDK_KEY_Arabic_hamzaonalef* = 0x000005C3
-  GDK_KEY_Arabic_hamzaonwaw* = 0x000005C4
-  GDK_KEY_Arabic_hamzaunderalef* = 0x000005C5
-  GDK_KEY_Arabic_hamzaonyeh* = 0x000005C6
-  GDK_KEY_Arabic_alef* = 0x000005C7
-  GDK_KEY_Arabic_beh* = 0x000005C8
-  GDK_KEY_Arabic_tehmarbuta* = 0x000005C9
-  GDK_KEY_Arabic_teh* = 0x000005CA
-  GDK_KEY_Arabic_theh* = 0x000005CB
-  GDK_KEY_Arabic_jeem* = 0x000005CC
-  GDK_KEY_Arabic_hah* = 0x000005CD
-  GDK_KEY_Arabic_khah* = 0x000005CE
-  GDK_KEY_Arabic_dal* = 0x000005CF
-  GDK_KEY_Arabic_thal* = 0x000005D0
-  GDK_KEY_Arabic_ra* = 0x000005D1
-  GDK_KEY_Arabic_zain* = 0x000005D2
-  GDK_KEY_Arabic_seen* = 0x000005D3
-  GDK_KEY_Arabic_sheen* = 0x000005D4
-  GDK_KEY_Arabic_sad* = 0x000005D5
-  GDK_KEY_Arabic_dad* = 0x000005D6
-  GDK_KEY_Arabic_tah* = 0x000005D7
-  GDK_KEY_Arabic_zah* = 0x000005D8
-  GDK_KEY_Arabic_ain* = 0x000005D9
-  GDK_KEY_Arabic_ghain* = 0x000005DA
-  GDK_KEY_Arabic_tatweel* = 0x000005E0
-  GDK_KEY_Arabic_feh* = 0x000005E1
-  GDK_KEY_Arabic_qaf* = 0x000005E2
-  GDK_KEY_Arabic_kaf* = 0x000005E3
-  GDK_KEY_Arabic_lam* = 0x000005E4
-  GDK_KEY_Arabic_meem* = 0x000005E5
-  GDK_KEY_Arabic_noon* = 0x000005E6
-  GDK_KEY_Arabic_ha* = 0x000005E7
-  GDK_KEY_Arabic_heh* = 0x000005E7
-  GDK_KEY_Arabic_waw* = 0x000005E8
-  GDK_KEY_Arabic_alefmaksura* = 0x000005E9
-  GDK_KEY_Arabic_yeh* = 0x000005EA
-  GDK_KEY_Arabic_fathatan* = 0x000005EB
-  GDK_KEY_Arabic_dammatan* = 0x000005EC
-  GDK_KEY_Arabic_kasratan* = 0x000005ED
-  GDK_KEY_Arabic_fatha* = 0x000005EE
-  GDK_KEY_Arabic_damma* = 0x000005EF
-  GDK_KEY_Arabic_kasra* = 0x000005F0
-  GDK_KEY_Arabic_shadda* = 0x000005F1
-  GDK_KEY_Arabic_sukun* = 0x000005F2
-  GDK_KEY_Arabic_switch* = 0x0000FF7E
-  GDK_KEY_Serbian_dje* = 0x000006A1
-  GDK_KEY_Macedonia_gje* = 0x000006A2
-  GDK_KEY_Cyrillic_io* = 0x000006A3
-  GDK_KEY_Ukrainian_ie* = 0x000006A4
-  GDK_KEY_Ukranian_je* = 0x000006A4
-  GDK_KEY_Macedonia_dse* = 0x000006A5
-  GDK_KEY_Ukrainian_i* = 0x000006A6
-  GDK_KEY_Ukranian_i* = 0x000006A6
-  GDK_KEY_Ukrainian_yi* = 0x000006A7
-  GDK_KEY_Ukranian_yi* = 0x000006A7
-  GDK_KEY_Cyrillic_je* = 0x000006A8
-  GDK_KEY_Serbian_je* = 0x000006A8
-  GDK_KEY_Cyrillic_lje* = 0x000006A9
-  GDK_KEY_Serbian_lje* = 0x000006A9
-  GDK_KEY_Cyrillic_nje* = 0x000006AA
-  GDK_KEY_Serbian_nje* = 0x000006AA
-  GDK_KEY_Serbian_tshe* = 0x000006AB
-  GDK_KEY_Macedonia_kje* = 0x000006AC
-  GDK_KEY_Byelorussian_shortu* = 0x000006AE
-  GDK_KEY_Cyrillic_dzhe* = 0x000006AF
-  GDK_KEY_Serbian_dze* = 0x000006AF
-  GDK_KEY_numerosign* = 0x000006B0
-  GDK_KEY_Serbian_CAPITAL_DJE* = 0x000006B1
-  GDK_KEY_Macedonia_CAPITAL_GJE* = 0x000006B2
-  GDK_KEY_Cyrillic_CAPITAL_IO* = 0x000006B3
-  GDK_KEY_Ukrainian_CAPITAL_IE* = 0x000006B4
-  GDK_KEY_Ukranian_CAPITAL_JE* = 0x000006B4
-  GDK_KEY_Macedonia_CAPITAL_DSE* = 0x000006B5
-  GDK_KEY_Ukrainian_CAPITAL_I* = 0x000006B6
-  GDK_KEY_Ukranian_CAPITAL_I* = 0x000006B6
-  GDK_KEY_Ukrainian_CAPITAL_YI* = 0x000006B7
-  GDK_KEY_Ukranian_CAPITAL_YI* = 0x000006B7
-  GDK_KEY_Cyrillic_CAPITAL_JE* = 0x000006B8
-  GDK_KEY_Serbian_CAPITAL_JE* = 0x000006B8
-  GDK_KEY_Cyrillic_CAPITAL_LJE* = 0x000006B9
-  GDK_KEY_Serbian_CAPITAL_LJE* = 0x000006B9
-  GDK_KEY_Cyrillic_CAPITAL_NJE* = 0x000006BA
-  GDK_KEY_Serbian_CAPITAL_NJE* = 0x000006BA
-  GDK_KEY_Serbian_CAPITAL_TSHE* = 0x000006BB
-  GDK_KEY_Macedonia_CAPITAL_KJE* = 0x000006BC
-  GDK_KEY_Byelorussian_CAPITAL_SHORTU* = 0x000006BE
-  GDK_KEY_Cyrillic_CAPITAL_DZHE* = 0x000006BF
-  GDK_KEY_Serbian_CAPITAL_DZE* = 0x000006BF
-  GDK_KEY_Cyrillic_yu* = 0x000006C0
-  GDK_KEY_Cyrillic_a* = 0x000006C1
-  GDK_KEY_Cyrillic_be* = 0x000006C2
-  GDK_KEY_Cyrillic_tse* = 0x000006C3
-  GDK_KEY_Cyrillic_de* = 0x000006C4
-  GDK_KEY_Cyrillic_ie* = 0x000006C5
-  GDK_KEY_Cyrillic_ef* = 0x000006C6
-  GDK_KEY_Cyrillic_ghe* = 0x000006C7
-  GDK_KEY_Cyrillic_ha* = 0x000006C8
-  GDK_KEY_Cyrillic_i* = 0x000006C9
-  GDK_KEY_Cyrillic_shorti* = 0x000006CA
-  GDK_KEY_Cyrillic_ka* = 0x000006CB
-  GDK_KEY_Cyrillic_el* = 0x000006CC
-  GDK_KEY_Cyrillic_em* = 0x000006CD
-  GDK_KEY_Cyrillic_en* = 0x000006CE
-  GDK_KEY_Cyrillic_o* = 0x000006CF
-  GDK_KEY_Cyrillic_pe* = 0x000006D0
-  GDK_KEY_Cyrillic_ya* = 0x000006D1
-  GDK_KEY_Cyrillic_er* = 0x000006D2
-  GDK_KEY_Cyrillic_es* = 0x000006D3
-  GDK_KEY_Cyrillic_te* = 0x000006D4
-  GDK_KEY_Cyrillic_u* = 0x000006D5
-  GDK_KEY_Cyrillic_zhe* = 0x000006D6
-  GDK_KEY_Cyrillic_ve* = 0x000006D7
-  GDK_KEY_Cyrillic_softsign* = 0x000006D8
-  GDK_KEY_Cyrillic_yeru* = 0x000006D9
-  GDK_KEY_Cyrillic_ze* = 0x000006DA
-  GDK_KEY_Cyrillic_sha* = 0x000006DB
-  GDK_KEY_Cyrillic_e* = 0x000006DC
-  GDK_KEY_Cyrillic_shcha* = 0x000006DD
-  GDK_KEY_Cyrillic_che* = 0x000006DE
-  GDK_KEY_Cyrillic_hardsign* = 0x000006DF
-  GDK_KEY_Cyrillic_CAPITAL_YU* = 0x000006E0
-  GDK_KEY_Cyrillic_CAPITAL_A* = 0x000006E1
-  GDK_KEY_Cyrillic_CAPITAL_BE* = 0x000006E2
-  GDK_KEY_Cyrillic_CAPITAL_TSE* = 0x000006E3
-  GDK_KEY_Cyrillic_CAPITAL_DE* = 0x000006E4
-  GDK_KEY_Cyrillic_CAPITAL_IE* = 0x000006E5
-  GDK_KEY_Cyrillic_CAPITAL_EF* = 0x000006E6
-  GDK_KEY_Cyrillic_CAPITAL_GHE* = 0x000006E7
-  GDK_KEY_Cyrillic_CAPITAL_HA* = 0x000006E8
-  GDK_KEY_Cyrillic_CAPITAL_I* = 0x000006E9
-  GDK_KEY_Cyrillic_CAPITAL_SHORTI* = 0x000006EA
-  GDK_KEY_Cyrillic_CAPITAL_KA* = 0x000006EB
-  GDK_KEY_Cyrillic_CAPITAL_EL* = 0x000006EC
-  GDK_KEY_Cyrillic_CAPITAL_EM* = 0x000006ED
-  GDK_KEY_Cyrillic_CAPITAL_EN* = 0x000006EE
-  GDK_KEY_Cyrillic_CAPITAL_O* = 0x000006EF
-  GDK_KEY_Cyrillic_CAPITAL_PE* = 0x000006F0
-  GDK_KEY_Cyrillic_CAPITAL_YA* = 0x000006F1
-  GDK_KEY_Cyrillic_CAPITAL_ER* = 0x000006F2
-  GDK_KEY_Cyrillic_CAPITAL_ES* = 0x000006F3
-  GDK_KEY_Cyrillic_CAPITAL_TE* = 0x000006F4
-  GDK_KEY_Cyrillic_CAPITAL_U* = 0x000006F5
-  GDK_KEY_Cyrillic_CAPITAL_ZHE* = 0x000006F6
-  GDK_KEY_Cyrillic_CAPITAL_VE* = 0x000006F7
-  GDK_KEY_Cyrillic_CAPITAL_SOFTSIGN* = 0x000006F8
-  GDK_KEY_Cyrillic_CAPITAL_YERU* = 0x000006F9
-  GDK_KEY_Cyrillic_CAPITAL_ZE* = 0x000006FA
-  GDK_KEY_Cyrillic_CAPITAL_SHA* = 0x000006FB
-  GDK_KEY_Cyrillic_CAPITAL_E* = 0x000006FC
-  GDK_KEY_Cyrillic_CAPITAL_SHCHA* = 0x000006FD
-  GDK_KEY_Cyrillic_CAPITAL_CHE* = 0x000006FE
-  GDK_KEY_Cyrillic_CAPITAL_HARDSIGN* = 0x000006FF
-  GDK_KEY_Greek_CAPITAL_ALPHAaccent* = 0x000007A1
-  GDK_KEY_Greek_CAPITAL_EPSILONaccent* = 0x000007A2
-  GDK_KEY_Greek_CAPITAL_ETAaccent* = 0x000007A3
-  GDK_KEY_Greek_CAPITAL_IOTAaccent* = 0x000007A4
-  GDK_KEY_Greek_CAPITAL_IOTAdiaeresis* = 0x000007A5
-  GDK_KEY_Greek_CAPITAL_OMICRONaccent* = 0x000007A7
-  GDK_KEY_Greek_CAPITAL_UPSILONaccent* = 0x000007A8
-  GDK_KEY_Greek_CAPITAL_UPSILONdieresis* = 0x000007A9
-  GDK_KEY_Greek_CAPITAL_OMEGAaccent* = 0x000007AB
-  GDK_KEY_Greek_accentdieresis* = 0x000007AE
-  GDK_KEY_Greek_horizbar* = 0x000007AF
-  GDK_KEY_Greek_alphaaccent* = 0x000007B1
-  GDK_KEY_Greek_epsilonaccent* = 0x000007B2
-  GDK_KEY_Greek_etaaccent* = 0x000007B3
-  GDK_KEY_Greek_iotaaccent* = 0x000007B4
-  GDK_KEY_Greek_iotadieresis* = 0x000007B5
-  GDK_KEY_Greek_iotaaccentdieresis* = 0x000007B6
-  GDK_KEY_Greek_omicronaccent* = 0x000007B7
-  GDK_KEY_Greek_upsilonaccent* = 0x000007B8
-  GDK_KEY_Greek_upsilondieresis* = 0x000007B9
-  GDK_KEY_Greek_upsilonaccentdieresis* = 0x000007BA
-  GDK_KEY_Greek_omegaaccent* = 0x000007BB
-  GDK_KEY_Greek_CAPITAL_ALPHA* = 0x000007C1
-  GDK_KEY_Greek_CAPITAL_BETA* = 0x000007C2
-  GDK_KEY_Greek_CAPITAL_GAMMA* = 0x000007C3
-  GDK_KEY_Greek_CAPITAL_DELTA* = 0x000007C4
-  GDK_KEY_Greek_CAPITAL_EPSILON* = 0x000007C5
-  GDK_KEY_Greek_CAPITAL_ZETA* = 0x000007C6
-  GDK_KEY_Greek_CAPITAL_ETA* = 0x000007C7
-  GDK_KEY_Greek_CAPITAL_THETA* = 0x000007C8
-  GDK_KEY_Greek_CAPITAL_IOTA* = 0x000007C9
-  GDK_KEY_Greek_CAPITAL_KAPPA* = 0x000007CA
-  GDK_KEY_Greek_CAPITAL_LAMDA* = 0x000007CB
-  GDK_KEY_Greek_CAPITAL_LAMBDA* = 0x000007CB
-  GDK_KEY_Greek_CAPITAL_MU* = 0x000007CC
-  GDK_KEY_Greek_CAPITAL_NU* = 0x000007CD
-  GDK_KEY_Greek_CAPITAL_XI* = 0x000007CE
-  GDK_KEY_Greek_CAPITAL_OMICRON* = 0x000007CF
-  GDK_KEY_Greek_CAPITAL_PI* = 0x000007D0
-  GDK_KEY_Greek_CAPITAL_RHO* = 0x000007D1
-  GDK_KEY_Greek_CAPITAL_SIGMA* = 0x000007D2
-  GDK_KEY_Greek_CAPITAL_TAU* = 0x000007D4
-  GDK_KEY_Greek_CAPITAL_UPSILON* = 0x000007D5
-  GDK_KEY_Greek_CAPITAL_PHI* = 0x000007D6
-  GDK_KEY_Greek_CAPITAL_CHI* = 0x000007D7
-  GDK_KEY_Greek_CAPITAL_PSI* = 0x000007D8
-  GDK_KEY_Greek_CAPITAL_OMEGA* = 0x000007D9
-  GDK_KEY_Greek_alpha* = 0x000007E1
-  GDK_KEY_Greek_beta* = 0x000007E2
-  GDK_KEY_Greek_gamma* = 0x000007E3
-  GDK_KEY_Greek_delta* = 0x000007E4
-  GDK_KEY_Greek_epsilon* = 0x000007E5
-  GDK_KEY_Greek_zeta* = 0x000007E6
-  GDK_KEY_Greek_eta* = 0x000007E7
-  GDK_KEY_Greek_theta* = 0x000007E8
-  GDK_KEY_Greek_iota* = 0x000007E9
-  GDK_KEY_Greek_kappa* = 0x000007EA
-  GDK_KEY_Greek_lamda* = 0x000007EB
-  GDK_KEY_Greek_lambda* = 0x000007EB
-  GDK_KEY_Greek_mu* = 0x000007EC
-  GDK_KEY_Greek_nu* = 0x000007ED
-  GDK_KEY_Greek_xi* = 0x000007EE
-  GDK_KEY_Greek_omicron* = 0x000007EF
-  GDK_KEY_Greek_pi* = 0x000007F0
-  GDK_KEY_Greek_rho* = 0x000007F1
-  GDK_KEY_Greek_sigma* = 0x000007F2
-  GDK_KEY_Greek_finalsmallsigma* = 0x000007F3
-  GDK_KEY_Greek_tau* = 0x000007F4
-  GDK_KEY_Greek_upsilon* = 0x000007F5
-  GDK_KEY_Greek_phi* = 0x000007F6
-  GDK_KEY_Greek_chi* = 0x000007F7
-  GDK_KEY_Greek_psi* = 0x000007F8
-  GDK_KEY_Greek_omega* = 0x000007F9
-  GDK_KEY_Greek_switch* = 0x0000FF7E
-  GDK_KEY_leftradical* = 0x000008A1
-  GDK_KEY_topleftradical* = 0x000008A2
-  GDK_KEY_horizconnector* = 0x000008A3
-  GDK_KEY_topintegral* = 0x000008A4
-  GDK_KEY_botintegral* = 0x000008A5
-  GDK_KEY_vertconnector* = 0x000008A6
-  GDK_KEY_topleftsqbracket* = 0x000008A7
-  GDK_KEY_botleftsqbracket* = 0x000008A8
-  GDK_KEY_toprightsqbracket* = 0x000008A9
-  GDK_KEY_botrightsqbracket* = 0x000008AA
-  GDK_KEY_topleftparens* = 0x000008AB
-  GDK_KEY_botleftparens* = 0x000008AC
-  GDK_KEY_toprightparens* = 0x000008AD
-  GDK_KEY_botrightparens* = 0x000008AE
-  GDK_KEY_leftmiddlecurlybrace* = 0x000008AF
-  GDK_KEY_rightmiddlecurlybrace* = 0x000008B0
-  GDK_KEY_topleftsummation* = 0x000008B1
-  GDK_KEY_botleftsummation* = 0x000008B2
-  GDK_KEY_topvertsummationconnector* = 0x000008B3
-  GDK_KEY_botvertsummationconnector* = 0x000008B4
-  GDK_KEY_toprightsummation* = 0x000008B5
-  GDK_KEY_botrightsummation* = 0x000008B6
-  GDK_KEY_rightmiddlesummation* = 0x000008B7
-  GDK_KEY_lessthanequal* = 0x000008BC
-  GDK_KEY_notequal* = 0x000008BD
-  GDK_KEY_greaterthanequal* = 0x000008BE
-  GDK_KEY_integral* = 0x000008BF
-  GDK_KEY_therefore* = 0x000008C0
-  GDK_KEY_variation* = 0x000008C1
-  GDK_KEY_infinity* = 0x000008C2
-  GDK_KEY_nabla* = 0x000008C5
-  GDK_KEY_approximate* = 0x000008C8
-  GDK_KEY_similarequal* = 0x000008C9
-  GDK_KEY_ifonlyif* = 0x000008CD
-  GDK_KEY_implies* = 0x000008CE
-  GDK_KEY_identical* = 0x000008CF
-  GDK_KEY_radical* = 0x000008D6
-  GDK_KEY_includedin* = 0x000008DA
-  GDK_KEY_includes* = 0x000008DB
-  GDK_KEY_intersection* = 0x000008DC
-  GDK_KEY_union* = 0x000008DD
-  GDK_KEY_logicaland* = 0x000008DE
-  GDK_KEY_logicalor* = 0x000008DF
-  GDK_KEY_partialderivative* = 0x000008EF
-  GDK_KEY_function* = 0x000008F6
-  GDK_KEY_leftarrow* = 0x000008FB
-  GDK_KEY_uparrow* = 0x000008FC
-  GDK_KEY_rightarrow* = 0x000008FD
-  GDK_KEY_downarrow* = 0x000008FE
-  GDK_KEY_blank* = 0x000009DF
-  GDK_KEY_soliddiamond* = 0x000009E0
-  GDK_KEY_checkerboard* = 0x000009E1
-  GDK_KEY_ht* = 0x000009E2
-  GDK_KEY_ff* = 0x000009E3
-  GDK_KEY_cr* = 0x000009E4
-  GDK_KEY_lf* = 0x000009E5
-  GDK_KEY_nl* = 0x000009E8
-  GDK_KEY_vt* = 0x000009E9
-  GDK_KEY_lowrightcorner* = 0x000009EA
-  GDK_KEY_uprightcorner* = 0x000009EB
-  GDK_KEY_upleftcorner* = 0x000009EC
-  GDK_KEY_lowleftcorner* = 0x000009ED
-  GDK_KEY_crossinglines* = 0x000009EE
-  GDK_KEY_horizlinescan1* = 0x000009EF
-  GDK_KEY_horizlinescan3* = 0x000009F0
-  GDK_KEY_horizlinescan5* = 0x000009F1
-  GDK_KEY_horizlinescan7* = 0x000009F2
-  GDK_KEY_horizlinescan9* = 0x000009F3
-  GDK_KEY_leftt* = 0x000009F4
-  GDK_KEY_rightt* = 0x000009F5
-  GDK_KEY_bott* = 0x000009F6
-  GDK_KEY_topt* = 0x000009F7
-  GDK_KEY_vertbar* = 0x000009F8
-  GDK_KEY_emspace* = 0x00000AA1
-  GDK_KEY_enspace* = 0x00000AA2
-  GDK_KEY_em3space* = 0x00000AA3
-  GDK_KEY_em4space* = 0x00000AA4
-  GDK_KEY_digitspace* = 0x00000AA5
-  GDK_KEY_punctspace* = 0x00000AA6
-  GDK_KEY_thinspace* = 0x00000AA7
-  GDK_KEY_hairspace* = 0x00000AA8
-  GDK_KEY_emdash* = 0x00000AA9
-  GDK_KEY_endash* = 0x00000AAA
-  GDK_KEY_signifblank* = 0x00000AAC
-  GDK_KEY_ellipsis* = 0x00000AAE
-  GDK_KEY_doubbaselinedot* = 0x00000AAF
-  GDK_KEY_onethird* = 0x00000AB0
-  GDK_KEY_twothirds* = 0x00000AB1
-  GDK_KEY_onefifth* = 0x00000AB2
-  GDK_KEY_twofifths* = 0x00000AB3
-  GDK_KEY_threefifths* = 0x00000AB4
-  GDK_KEY_fourfifths* = 0x00000AB5
-  GDK_KEY_onesixth* = 0x00000AB6
-  GDK_KEY_fivesixths* = 0x00000AB7
-  GDK_KEY_careof* = 0x00000AB8
-  GDK_KEY_figdash* = 0x00000ABB
-  GDK_KEY_leftanglebracket* = 0x00000ABC
-  GDK_KEY_decimalpoint* = 0x00000ABD
-  GDK_KEY_rightanglebracket* = 0x00000ABE
-  GDK_KEY_marker* = 0x00000ABF
-  GDK_KEY_oneeighth* = 0x00000AC3
-  GDK_KEY_threeeighths* = 0x00000AC4
-  GDK_KEY_fiveeighths* = 0x00000AC5
-  GDK_KEY_seveneighths* = 0x00000AC6
-  GDK_KEY_trademark* = 0x00000AC9
-  GDK_KEY_signaturemark* = 0x00000ACA
-  GDK_KEY_trademarkincircle* = 0x00000ACB
-  GDK_KEY_leftopentriangle* = 0x00000ACC
-  GDK_KEY_rightopentriangle* = 0x00000ACD
-  GDK_KEY_emopencircle* = 0x00000ACE
-  GDK_KEY_emopenrectangle* = 0x00000ACF
-  GDK_KEY_leftsinglequotemark* = 0x00000AD0
-  GDK_KEY_rightsinglequotemark* = 0x00000AD1
-  GDK_KEY_leftdoublequotemark* = 0x00000AD2
-  GDK_KEY_rightdoublequotemark* = 0x00000AD3
-  GDK_KEY_prescription* = 0x00000AD4
-  GDK_KEY_minutes* = 0x00000AD6
-  GDK_KEY_seconds* = 0x00000AD7
-  GDK_KEY_latincross* = 0x00000AD9
-  GDK_KEY_hexagram* = 0x00000ADA
-  GDK_KEY_filledrectbullet* = 0x00000ADB
-  GDK_KEY_filledlefttribullet* = 0x00000ADC
-  GDK_KEY_filledrighttribullet* = 0x00000ADD
-  GDK_KEY_emfilledcircle* = 0x00000ADE
-  GDK_KEY_emfilledrect* = 0x00000ADF
-  GDK_KEY_enopencircbullet* = 0x00000AE0
-  GDK_KEY_enopensquarebullet* = 0x00000AE1
-  GDK_KEY_openrectbullet* = 0x00000AE2
-  GDK_KEY_opentribulletup* = 0x00000AE3
-  GDK_KEY_opentribulletdown* = 0x00000AE4
-  GDK_KEY_openstar* = 0x00000AE5
-  GDK_KEY_enfilledcircbullet* = 0x00000AE6
-  GDK_KEY_enfilledsqbullet* = 0x00000AE7
-  GDK_KEY_filledtribulletup* = 0x00000AE8
-  GDK_KEY_filledtribulletdown* = 0x00000AE9
-  GDK_KEY_leftpointer* = 0x00000AEA
-  GDK_KEY_rightpointer* = 0x00000AEB
-  GDK_KEY_club* = 0x00000AEC
-  GDK_KEY_diamond* = 0x00000AED
-  GDK_KEY_heart* = 0x00000AEE
-  GDK_KEY_maltesecross* = 0x00000AF0
-  GDK_KEY_dagger* = 0x00000AF1
-  GDK_KEY_doubledagger* = 0x00000AF2
-  GDK_KEY_checkmark* = 0x00000AF3
-  GDK_KEY_ballotcross* = 0x00000AF4
-  GDK_KEY_musicalsharp* = 0x00000AF5
-  GDK_KEY_musicalflat* = 0x00000AF6
-  GDK_KEY_malesymbol* = 0x00000AF7
-  GDK_KEY_femalesymbol* = 0x00000AF8
-  GDK_KEY_telephone* = 0x00000AF9
-  GDK_KEY_telephonerecorder* = 0x00000AFA
-  GDK_KEY_phonographcopyright* = 0x00000AFB
-  GDK_KEY_caret* = 0x00000AFC
-  GDK_KEY_singlelowquotemark* = 0x00000AFD
-  GDK_KEY_doublelowquotemark* = 0x00000AFE
-  GDK_KEY_cursor* = 0x00000AFF
-  GDK_KEY_leftcaret* = 0x00000BA3
-  GDK_KEY_rightcaret* = 0x00000BA6
-  GDK_KEY_downcaret* = 0x00000BA8
-  GDK_KEY_upcaret* = 0x00000BA9
-  GDK_KEY_overbar* = 0x00000BC0
-  GDK_KEY_downtack* = 0x00000BC2
-  GDK_KEY_upshoe* = 0x00000BC3
-  GDK_KEY_downstile* = 0x00000BC4
-  GDK_KEY_underbar* = 0x00000BC6
-  GDK_KEY_jot* = 0x00000BCA
-  GDK_KEY_quad* = 0x00000BCC
-  GDK_KEY_uptack* = 0x00000BCE
-  GDK_KEY_circle* = 0x00000BCF
-  GDK_KEY_upstile* = 0x00000BD3
-  GDK_KEY_downshoe* = 0x00000BD6
-  GDK_KEY_rightshoe* = 0x00000BD8
-  GDK_KEY_leftshoe* = 0x00000BDA
-  GDK_KEY_lefttack* = 0x00000BDC
-  GDK_KEY_righttack* = 0x00000BFC
-  GDK_KEY_hebrew_doublelowline* = 0x00000CDF
-  GDK_KEY_hebrew_aleph* = 0x00000CE0
-  GDK_KEY_hebrew_bet* = 0x00000CE1
-  GDK_KEY_hebrew_beth* = 0x00000CE1
-  GDK_KEY_hebrew_gimel* = 0x00000CE2
-  GDK_KEY_hebrew_gimmel* = 0x00000CE2
-  GDK_KEY_hebrew_dalet* = 0x00000CE3
-  GDK_KEY_hebrew_daleth* = 0x00000CE3
-  GDK_KEY_hebrew_he* = 0x00000CE4
-  GDK_KEY_hebrew_waw* = 0x00000CE5
-  GDK_KEY_hebrew_zain* = 0x00000CE6
-  GDK_KEY_hebrew_zayin* = 0x00000CE6
-  GDK_KEY_hebrew_chet* = 0x00000CE7
-  GDK_KEY_hebrew_het* = 0x00000CE7
-  GDK_KEY_hebrew_tet* = 0x00000CE8
-  GDK_KEY_hebrew_teth* = 0x00000CE8
-  GDK_KEY_hebrew_yod* = 0x00000CE9
-  GDK_KEY_hebrew_finalkaph* = 0x00000CEA
-  GDK_KEY_hebrew_kaph* = 0x00000CEB
-  GDK_KEY_hebrew_lamed* = 0x00000CEC
-  GDK_KEY_hebrew_finalmem* = 0x00000CED
-  GDK_KEY_hebrew_mem* = 0x00000CEE
-  GDK_KEY_hebrew_finalnun* = 0x00000CEF
-  GDK_KEY_hebrew_nun* = 0x00000CF0
-  GDK_KEY_hebrew_samech* = 0x00000CF1
-  GDK_KEY_hebrew_samekh* = 0x00000CF1
-  GDK_KEY_hebrew_ayin* = 0x00000CF2
-  GDK_KEY_hebrew_finalpe* = 0x00000CF3
-  GDK_KEY_hebrew_pe* = 0x00000CF4
-  GDK_KEY_hebrew_finalzade* = 0x00000CF5
-  GDK_KEY_hebrew_finalzadi* = 0x00000CF5
-  GDK_KEY_hebrew_zade* = 0x00000CF6
-  GDK_KEY_hebrew_zadi* = 0x00000CF6
-  GDK_KEY_hebrew_qoph* = 0x00000CF7
-  GDK_KEY_hebrew_kuf* = 0x00000CF7
-  GDK_KEY_hebrew_resh* = 0x00000CF8
-  GDK_KEY_hebrew_shin* = 0x00000CF9
-  GDK_KEY_hebrew_taw* = 0x00000CFA
-  GDK_KEY_hebrew_taf* = 0x00000CFA
-  GDK_KEY_Hebrew_switch* = 0x0000FF7E
-  GDK_KEY_Thai_kokai* = 0x00000DA1
-  GDK_KEY_Thai_khokhai* = 0x00000DA2
-  GDK_KEY_Thai_khokhuat* = 0x00000DA3
-  GDK_KEY_Thai_khokhwai* = 0x00000DA4
-  GDK_KEY_Thai_khokhon* = 0x00000DA5
-  GDK_KEY_Thai_khorakhang* = 0x00000DA6
-  GDK_KEY_Thai_ngongu* = 0x00000DA7
-  GDK_KEY_Thai_chochan* = 0x00000DA8
-  GDK_KEY_Thai_choching* = 0x00000DA9
-  GDK_KEY_Thai_chochang* = 0x00000DAA
-  GDK_KEY_Thai_soso* = 0x00000DAB
-  GDK_KEY_Thai_chochoe* = 0x00000DAC
-  GDK_KEY_Thai_yoying* = 0x00000DAD
-  GDK_KEY_Thai_dochada* = 0x00000DAE
-  GDK_KEY_Thai_topatak* = 0x00000DAF
-  GDK_KEY_Thai_thothan* = 0x00000DB0
-  GDK_KEY_Thai_thonangmontho* = 0x00000DB1
-  GDK_KEY_Thai_thophuthao* = 0x00000DB2
-  GDK_KEY_Thai_nonen* = 0x00000DB3
-  GDK_KEY_Thai_dodek* = 0x00000DB4
-  GDK_KEY_Thai_totao* = 0x00000DB5
-  GDK_KEY_Thai_thothung* = 0x00000DB6
-  GDK_KEY_Thai_thothahan* = 0x00000DB7
-  GDK_KEY_Thai_thothong* = 0x00000DB8
-  GDK_KEY_Thai_nonu* = 0x00000DB9
-  GDK_KEY_Thai_bobaimai* = 0x00000DBA
-  GDK_KEY_Thai_popla* = 0x00000DBB
-  GDK_KEY_Thai_phophung* = 0x00000DBC
-  GDK_KEY_Thai_fofa* = 0x00000DBD
-  GDK_KEY_Thai_phophan* = 0x00000DBE
-  GDK_KEY_Thai_fofan* = 0x00000DBF
-  GDK_KEY_Thai_phosamphao* = 0x00000DC0
-  GDK_KEY_Thai_moma* = 0x00000DC1
-  GDK_KEY_Thai_yoyak* = 0x00000DC2
-  GDK_KEY_Thai_rorua* = 0x00000DC3
-  GDK_KEY_Thai_ru* = 0x00000DC4
-  GDK_KEY_Thai_loling* = 0x00000DC5
-  GDK_KEY_Thai_lu* = 0x00000DC6
-  GDK_KEY_Thai_wowaen* = 0x00000DC7
-  GDK_KEY_Thai_sosala* = 0x00000DC8
-  GDK_KEY_Thai_sorusi* = 0x00000DC9
-  GDK_KEY_Thai_sosua* = 0x00000DCA
-  GDK_KEY_Thai_hohip* = 0x00000DCB
-  GDK_KEY_Thai_lochula* = 0x00000DCC
-  GDK_KEY_Thai_oang* = 0x00000DCD
-  GDK_KEY_Thai_honokhuk* = 0x00000DCE
-  GDK_KEY_Thai_paiyannoi* = 0x00000DCF
-  GDK_KEY_Thai_saraa* = 0x00000DD0
-  GDK_KEY_Thai_maihanakat* = 0x00000DD1
-  GDK_KEY_Thai_saraaa* = 0x00000DD2
-  GDK_KEY_Thai_saraam* = 0x00000DD3
-  GDK_KEY_Thai_sarai* = 0x00000DD4
-  GDK_KEY_Thai_saraii* = 0x00000DD5
-  GDK_KEY_Thai_saraue* = 0x00000DD6
-  GDK_KEY_Thai_sarauee* = 0x00000DD7
-  GDK_KEY_Thai_sarau* = 0x00000DD8
-  GDK_KEY_Thai_sarauu* = 0x00000DD9
-  GDK_KEY_Thai_phinthu* = 0x00000DDA
-  GDK_KEY_Thai_maihanakat_maitho* = 0x00000DDE
-  GDK_KEY_Thai_baht* = 0x00000DDF
-  GDK_KEY_Thai_sarae* = 0x00000DE0
-  GDK_KEY_Thai_saraae* = 0x00000DE1
-  GDK_KEY_Thai_sarao* = 0x00000DE2
-  GDK_KEY_Thai_saraaimaimuan* = 0x00000DE3
-  GDK_KEY_Thai_saraaimaimalai* = 0x00000DE4
-  GDK_KEY_Thai_lakkhangyao* = 0x00000DE5
-  GDK_KEY_Thai_maiyamok* = 0x00000DE6
-  GDK_KEY_Thai_maitaikhu* = 0x00000DE7
-  GDK_KEY_Thai_maiek* = 0x00000DE8
-  GDK_KEY_Thai_maitho* = 0x00000DE9
-  GDK_KEY_Thai_maitri* = 0x00000DEA
-  GDK_KEY_Thai_maichattawa* = 0x00000DEB
-  GDK_KEY_Thai_thanthakhat* = 0x00000DEC
-  GDK_KEY_Thai_nikhahit* = 0x00000DED
-  GDK_KEY_Thai_leksun* = 0x00000DF0
-  GDK_KEY_Thai_leknung* = 0x00000DF1
-  GDK_KEY_Thai_leksong* = 0x00000DF2
-  GDK_KEY_Thai_leksam* = 0x00000DF3
-  GDK_KEY_Thai_leksi* = 0x00000DF4
-  GDK_KEY_Thai_lekha* = 0x00000DF5
-  GDK_KEY_Thai_lekhok* = 0x00000DF6
-  GDK_KEY_Thai_lekchet* = 0x00000DF7
-  GDK_KEY_Thai_lekpaet* = 0x00000DF8
-  GDK_KEY_Thai_lekkao* = 0x00000DF9
-  GDK_KEY_Hangul* = 0x0000FF31
-  GDK_KEY_Hangul_Start* = 0x0000FF32
-  GDK_KEY_Hangul_End* = 0x0000FF33
-  GDK_KEY_Hangul_Hanja* = 0x0000FF34
-  GDK_KEY_Hangul_Jamo* = 0x0000FF35
-  GDK_KEY_Hangul_Romaja* = 0x0000FF36
-  GDK_KEY_Hangul_Codeinput* = 0x0000FF37
-  GDK_KEY_Hangul_Jeonja* = 0x0000FF38
-  GDK_KEY_Hangul_Banja* = 0x0000FF39
-  GDK_KEY_Hangul_PreHanja* = 0x0000FF3A
-  GDK_KEY_Hangul_PostHanja* = 0x0000FF3B
-  GDK_KEY_Hangul_SingleCandidate* = 0x0000FF3C
-  GDK_KEY_Hangul_MultipleCandidate* = 0x0000FF3D
-  GDK_KEY_Hangul_PreviousCandidate* = 0x0000FF3E
-  GDK_KEY_Hangul_Special* = 0x0000FF3F
-  GDK_KEY_Hangul_switch* = 0x0000FF7E
-  GDK_KEY_Hangul_Kiyeog* = 0x00000EA1
-  GDK_KEY_Hangul_SsangKiyeog* = 0x00000EA2
-  GDK_KEY_Hangul_KiyeogSios* = 0x00000EA3
-  GDK_KEY_Hangul_Nieun* = 0x00000EA4
-  GDK_KEY_Hangul_NieunJieuj* = 0x00000EA5
-  GDK_KEY_Hangul_NieunHieuh* = 0x00000EA6
-  GDK_KEY_Hangul_Dikeud* = 0x00000EA7
-  GDK_KEY_Hangul_SsangDikeud* = 0x00000EA8
-  GDK_KEY_Hangul_Rieul* = 0x00000EA9
-  GDK_KEY_Hangul_RieulKiyeog* = 0x00000EAA
-  GDK_KEY_Hangul_RieulMieum* = 0x00000EAB
-  GDK_KEY_Hangul_RieulPieub* = 0x00000EAC
-  GDK_KEY_Hangul_RieulSios* = 0x00000EAD
-  GDK_KEY_Hangul_RieulTieut* = 0x00000EAE
-  GDK_KEY_Hangul_RieulPhieuf* = 0x00000EAF
-  GDK_KEY_Hangul_RieulHieuh* = 0x00000EB0
-  GDK_KEY_Hangul_Mieum* = 0x00000EB1
-  GDK_KEY_Hangul_Pieub* = 0x00000EB2
-  GDK_KEY_Hangul_SsangPieub* = 0x00000EB3
-  GDK_KEY_Hangul_PieubSios* = 0x00000EB4
-  GDK_KEY_Hangul_Sios* = 0x00000EB5
-  GDK_KEY_Hangul_SsangSios* = 0x00000EB6
-  GDK_KEY_Hangul_Ieung* = 0x00000EB7
-  GDK_KEY_Hangul_Jieuj* = 0x00000EB8
-  GDK_KEY_Hangul_SsangJieuj* = 0x00000EB9
-  GDK_KEY_Hangul_Cieuc* = 0x00000EBA
-  GDK_KEY_Hangul_Khieuq* = 0x00000EBB
-  GDK_KEY_Hangul_Tieut* = 0x00000EBC
-  GDK_KEY_Hangul_Phieuf* = 0x00000EBD
-  GDK_KEY_Hangul_Hieuh* = 0x00000EBE
-  GDK_KEY_Hangul_A* = 0x00000EBF
-  GDK_KEY_Hangul_AE* = 0x00000EC0
-  GDK_KEY_Hangul_YA* = 0x00000EC1
-  GDK_KEY_Hangul_YAE* = 0x00000EC2
-  GDK_KEY_Hangul_EO* = 0x00000EC3
-  GDK_KEY_Hangul_E* = 0x00000EC4
-  GDK_KEY_Hangul_YEO* = 0x00000EC5
-  GDK_KEY_Hangul_YE* = 0x00000EC6
-  GDK_KEY_Hangul_O* = 0x00000EC7
-  GDK_KEY_Hangul_WA* = 0x00000EC8
-  GDK_KEY_Hangul_WAE* = 0x00000EC9
-  GDK_KEY_Hangul_OE* = 0x00000ECA
-  GDK_KEY_Hangul_YO* = 0x00000ECB
-  GDK_KEY_Hangul_U* = 0x00000ECC
-  GDK_KEY_Hangul_WEO* = 0x00000ECD
-  GDK_KEY_Hangul_WE* = 0x00000ECE
-  GDK_KEY_Hangul_WI* = 0x00000ECF
-  GDK_KEY_Hangul_YU* = 0x00000ED0
-  GDK_KEY_Hangul_EU* = 0x00000ED1
-  GDK_KEY_Hangul_YI* = 0x00000ED2
-  GDK_KEY_Hangul_I* = 0x00000ED3
-  GDK_KEY_Hangul_J_Kiyeog* = 0x00000ED4
-  GDK_KEY_Hangul_J_SsangKiyeog* = 0x00000ED5
-  GDK_KEY_Hangul_J_KiyeogSios* = 0x00000ED6
-  GDK_KEY_Hangul_J_Nieun* = 0x00000ED7
-  GDK_KEY_Hangul_J_NieunJieuj* = 0x00000ED8
-  GDK_KEY_Hangul_J_NieunHieuh* = 0x00000ED9
-  GDK_KEY_Hangul_J_Dikeud* = 0x00000EDA
-  GDK_KEY_Hangul_J_Rieul* = 0x00000EDB
-  GDK_KEY_Hangul_J_RieulKiyeog* = 0x00000EDC
-  GDK_KEY_Hangul_J_RieulMieum* = 0x00000EDD
-  GDK_KEY_Hangul_J_RieulPieub* = 0x00000EDE
-  GDK_KEY_Hangul_J_RieulSios* = 0x00000EDF
-  GDK_KEY_Hangul_J_RieulTieut* = 0x00000EE0
-  GDK_KEY_Hangul_J_RieulPhieuf* = 0x00000EE1
-  GDK_KEY_Hangul_J_RieulHieuh* = 0x00000EE2
-  GDK_KEY_Hangul_J_Mieum* = 0x00000EE3
-  GDK_KEY_Hangul_J_Pieub* = 0x00000EE4
-  GDK_KEY_Hangul_J_PieubSios* = 0x00000EE5
-  GDK_KEY_Hangul_J_Sios* = 0x00000EE6
-  GDK_KEY_Hangul_J_SsangSios* = 0x00000EE7
-  GDK_KEY_Hangul_J_Ieung* = 0x00000EE8
-  GDK_KEY_Hangul_J_Jieuj* = 0x00000EE9
-  GDK_KEY_Hangul_J_Cieuc* = 0x00000EEA
-  GDK_KEY_Hangul_J_Khieuq* = 0x00000EEB
-  GDK_KEY_Hangul_J_Tieut* = 0x00000EEC
-  GDK_KEY_Hangul_J_Phieuf* = 0x00000EED
-  GDK_KEY_Hangul_J_Hieuh* = 0x00000EEE
-  GDK_KEY_Hangul_RieulYeorinHieuh* = 0x00000EEF
-  GDK_KEY_Hangul_SunkyeongeumMieum* = 0x00000EF0
-  GDK_KEY_Hangul_SunkyeongeumPieub* = 0x00000EF1
-  GDK_KEY_Hangul_PanSios* = 0x00000EF2
-  GDK_KEY_Hangul_KkogjiDalrinIeung* = 0x00000EF3
-  GDK_KEY_Hangul_SunkyeongeumPhieuf* = 0x00000EF4
-  GDK_KEY_Hangul_YeorinHieuh* = 0x00000EF5
-  GDK_KEY_Hangul_AraeA* = 0x00000EF6
-  GDK_KEY_Hangul_AraeAE* = 0x00000EF7
-  GDK_KEY_Hangul_J_PanSios* = 0x00000EF8
-  GDK_KEY_Hangul_J_KkogjiDalrinIeung* = 0x00000EF9
-  GDK_KEY_Hangul_J_YeorinHieuh* = 0x00000EFA
-  GDK_KEY_Korean_Won* = 0x00000EFF
-  GDK_KEY_EcuSign* = 0x000020A0
-  GDK_KEY_ColonSign* = 0x000020A1
-  GDK_KEY_CruzeiroSign* = 0x000020A2
-  GDK_KEY_FFrancSign* = 0x000020A3
-  GDK_KEY_LiraSign* = 0x000020A4
-  GDK_KEY_MillSign* = 0x000020A5
-  GDK_KEY_NairaSign* = 0x000020A6
-  GDK_KEY_PesetaSign* = 0x000020A7
-  GDK_KEY_RupeeSign* = 0x000020A8
-  GDK_KEY_WonSign* = 0x000020A9
-  GDK_KEY_NewSheqelSign* = 0x000020AA
-  GDK_KEY_DongSign* = 0x000020AB
-  GDK_KEY_EuroSign* = 0x000020AC
-
-proc gdk_pango_context_get_for_screen*(screen: PGdkScreen): PPangoContext{.
-    cdecl, dynlib: gdklib, importc: "gdk_pango_context_get_for_screen".}
-proc gdk_pango_context_set_colormap*(context: PPangoContext,
-                                     colormap: PGdkColormap){.cdecl,
-    dynlib: gdklib, importc: "gdk_pango_context_set_colormap".}
-proc gdk_pango_layout_line_get_clip_region*(line: PPangoLayoutLine,
-    x_origin: gint, y_origin: gint, index_ranges: Pgint, n_ranges: gint): PGdkRegion{.
-    cdecl, dynlib: gdklib, importc: "gdk_pango_layout_line_get_clip_region".}
-proc gdk_pango_layout_get_clip_region*(layout: PPangoLayout, x_origin: gint,
-                                       y_origin: gint, index_ranges: Pgint,
-                                       n_ranges: gint): PGdkRegion{.cdecl,
-    dynlib: gdklib, importc: "gdk_pango_layout_get_clip_region".}
-proc gdk_pango_attr_stipple_new*(stipple: PGdkBitmap): PPangoAttribute{.cdecl,
-    dynlib: gdklib, importc: "gdk_pango_attr_stipple_new".}
-proc gdk_pango_attr_embossed_new*(embossed: gboolean): PPangoAttribute{.cdecl,
-    dynlib: gdklib, importc: "gdk_pango_attr_embossed_new".}
-proc gdk_pixbuf_render_threshold_alpha*(pixbuf: PGdkPixbuf, bitmap: PGdkBitmap,
-                                        src_x: int32, src_y: int32,
-                                        dest_x: int32, dest_y: int32,
-                                        width: int32, height: int32,
-                                        alpha_threshold: int32){.cdecl,
-    dynlib: gdklib, importc: "gdk_pixbuf_render_threshold_alpha".}
-proc gdk_pixbuf_render_to_drawable*(pixbuf: PGdkPixbuf, drawable: PGdkDrawable,
-                                    gc: PGdkGC, src_x: int32, src_y: int32,
-                                    dest_x: int32, dest_y: int32, width: int32,
-                                    height: int32, dither: TGdkRgbDither,
-                                    x_dither: int32, y_dither: int32){.cdecl,
-    dynlib: gdklib, importc: "gdk_pixbuf_render_to_drawable".}
-proc gdk_pixbuf_render_to_drawable_alpha*(pixbuf: PGdkPixbuf,
-    drawable: PGdkDrawable, src_x: int32, src_y: int32, dest_x: int32,
-    dest_y: int32, width: int32, height: int32, alpha_mode: TGdkPixbufAlphaMode,
-    alpha_threshold: int32, dither: TGdkRgbDither, x_dither: int32,
-    y_dither: int32){.cdecl, dynlib: gdklib,
-                      importc: "gdk_pixbuf_render_to_drawable_alpha".}
-proc gdk_pixbuf_render_pixmap_and_mask_for_colormap*(pixbuf: PGdkPixbuf,
-    colormap: PGdkColormap, n: var PGdkPixmap, nasdfdsafw4e: var PGdkBitmap,
-    alpha_threshold: int32){.cdecl, dynlib: gdklib, importc: "gdk_pixbuf_render_pixmap_and_mask_for_colormap".}
-proc gdk_pixbuf_get_from_drawable*(dest: PGdkPixbuf, src: PGdkDrawable,
-                                   cmap: PGdkColormap, src_x: int32,
-                                   src_y: int32, dest_x: int32, dest_y: int32,
-                                   width: int32, height: int32): PGdkPixbuf{.
-    cdecl, dynlib: gdklib, importc: "gdk_pixbuf_get_from_drawable".}
-proc gdk_pixbuf_get_from_image*(dest: PGdkPixbuf, src: PGdkImage,
-                                cmap: PGdkColormap, src_x: int32, src_y: int32,
-                                dest_x: int32, dest_y: int32, width: int32,
-                                height: int32): PGdkPixbuf{.cdecl,
-    dynlib: gdklib, importc: "gdk_pixbuf_get_from_image".}
-proc GDK_TYPE_PIXMAP*(): GType
-proc GDK_PIXMAP*(anObject: Pointer): PGdkPixmap
-proc GDK_PIXMAP_CLASS*(klass: Pointer): PGdkPixmapObjectClass
-proc GDK_IS_PIXMAP*(anObject: Pointer): bool
-proc GDK_IS_PIXMAP_CLASS*(klass: Pointer): bool
-proc GDK_PIXMAP_GET_CLASS*(obj: Pointer): PGdkPixmapObjectClass
-proc GDK_PIXMAP_OBJECT*(anObject: Pointer): PGdkPixmapObject
-proc gdk_pixmap_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_pixmap_get_type".}
-proc gdk_pixmap_new*(window: PGdkWindow, width: gint, height: gint, depth: gint): PGdkPixmap{.
-    cdecl, dynlib: gdklib, importc: "gdk_pixmap_new".}
-proc gdk_bitmap_create_from_data*(window: PGdkWindow, data: cstring, width: gint,
-                                  height: gint): PGdkBitmap{.cdecl,
-    dynlib: gdklib, importc: "gdk_bitmap_create_from_data".}
-proc gdk_pixmap_create_from_data*(window: PGdkWindow, data: cstring, width: gint,
-                                  height: gint, depth: gint, fg: PGdkColor,
-                                  bg: PGdkColor): PGdkPixmap{.cdecl,
-    dynlib: gdklib, importc: "gdk_pixmap_create_from_data".}
-proc gdk_pixmap_create_from_xpm*(window: PGdkWindow, k: var PGdkBitmap,
-                                 transparent_color: PGdkColor, filename: cstring): PGdkPixmap{.
-    cdecl, dynlib: gdklib, importc: "gdk_pixmap_create_from_xpm".}
-proc gdk_pixmap_colormap_create_from_xpm*(window: PGdkWindow,
-    colormap: PGdkColormap, k: var PGdkBitmap, transparent_color: PGdkColor,
-    filename: cstring): PGdkPixmap{.cdecl, dynlib: gdklib, importc: "gdk_pixmap_colormap_create_from_xpm".}
-proc gdk_pixmap_create_from_xpm_d*(window: PGdkWindow, k: var PGdkBitmap,
-                                   transparent_color: PGdkColor, data: PPgchar): PGdkPixmap{.
-    cdecl, dynlib: gdklib, importc: "gdk_pixmap_create_from_xpm_d".}
-proc gdk_pixmap_colormap_create_from_xpm_d*(window: PGdkWindow,
-    colormap: PGdkColormap, k: var PGdkBitmap, transparent_color: PGdkColor,
-    data: PPgchar): PGdkPixmap{.cdecl, dynlib: gdklib, importc: "gdk_pixmap_colormap_create_from_xpm_d".}
-proc gdk_pixmap_foreign_new_for_display*(display: PGdkDisplay,
-    anid: TGdkNativeWindow): PGdkPixmap{.cdecl, dynlib: gdklib,
-    importc: "gdk_pixmap_foreign_new_for_display".}
-proc gdk_pixmap_lookup_for_display*(display: PGdkDisplay, anid: TGdkNativeWindow): PGdkPixmap{.
-    cdecl, dynlib: gdklib, importc: "gdk_pixmap_lookup_for_display".}
-proc gdk_atom_intern*(atom_name: cstring, only_if_exists: gboolean): TGdkAtom{.
-    cdecl, dynlib: gdklib, importc: "gdk_atom_intern".}
-proc gdk_atom_name*(atom: TGdkAtom): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_atom_name".}
-proc gdk_property_get*(window: PGdkWindow, `property`: TGdkAtom,
-                       `type`: TGdkAtom, offset: gulong, length: gulong,
-                       pdelete: gint, actual_property_type: PGdkAtom,
-                       actual_format: Pgint, actual_length: Pgint,
-                       data: PPguchar): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_property_get".}
-proc gdk_property_change*(window: PGdkWindow, `property`: TGdkAtom,
-                          `type`: TGdkAtom, format: gint, mode: TGdkPropMode,
-                          data: Pguchar, nelements: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_property_change".}
-proc gdk_property_delete*(window: PGdkWindow, `property`: TGdkAtom){.cdecl,
-    dynlib: gdklib, importc: "gdk_property_delete".}
-proc gdk_text_property_to_text_list_for_display*(display: PGdkDisplay,
-    encoding: TGdkAtom, format: gint, text: Pguchar, length: gint,
-    t: var PPgchar): gint{.cdecl, dynlib: gdklib, importc: "gdk_text_property_to_text_list_for_display".}
-proc gdk_text_property_to_utf8_list_for_display*(display: PGdkDisplay,
-    encoding: TGdkAtom, format: gint, text: Pguchar, length: gint,
-    t: var PPgchar): gint{.cdecl, dynlib: gdklib, importc: "gdk_text_property_to_utf8_list_for_display".}
-proc gdk_utf8_to_string_target*(str: cstring): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_utf8_to_string_target".}
-proc gdk_string_to_compound_text_for_display*(display: PGdkDisplay, str: cstring,
-    encoding: PGdkAtom, format: Pgint, ctext: PPguchar, length: Pgint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_string_to_compound_text_for_display".}
-proc gdk_utf8_to_compound_text_for_display*(display: PGdkDisplay, str: cstring,
-    encoding: PGdkAtom, format: Pgint, ctext: PPguchar, length: Pgint): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_utf8_to_compound_text_for_display".}
-proc gdk_free_text_list*(list: PPgchar){.cdecl, dynlib: gdklib,
-    importc: "gdk_free_text_list".}
-proc gdk_free_compound_text*(ctext: Pguchar){.cdecl, dynlib: gdklib,
-    importc: "gdk_free_compound_text".}
-proc gdk_region_new*(): PGdkRegion{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_region_new".}
-proc gdk_region_polygon*(points: PGdkPoint, npoints: gint,
-                         fill_rule: TGdkFillRule): PGdkRegion{.cdecl,
-    dynlib: gdklib, importc: "gdk_region_polygon".}
-proc gdk_region_copy*(region: PGdkRegion): PGdkRegion{.cdecl, dynlib: gdklib,
-    importc: "gdk_region_copy".}
-proc gdk_region_rectangle*(rectangle: PGdkRectangle): PGdkRegion{.cdecl,
-    dynlib: gdklib, importc: "gdk_region_rectangle".}
-proc gdk_region_destroy*(region: PGdkRegion){.cdecl, dynlib: gdklib,
-    importc: "gdk_region_destroy".}
-proc gdk_region_get_clipbox*(region: PGdkRegion, rectangle: PGdkRectangle){.
-    cdecl, dynlib: gdklib, importc: "gdk_region_get_clipbox".}
-proc gdk_region_get_rectangles*(region: PGdkRegion, s: var PGdkRectangle,
-                                n_rectangles: Pgint){.cdecl, dynlib: gdklib,
-    importc: "gdk_region_get_rectangles".}
-proc gdk_region_empty*(region: PGdkRegion): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_region_empty".}
-proc gdk_region_equal*(region1: PGdkRegion, region2: PGdkRegion): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_region_equal".}
-proc gdk_region_point_in*(region: PGdkRegion, x: int32, y: int32): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_region_point_in".}
-proc gdk_region_rect_in*(region: PGdkRegion, rect: PGdkRectangle): TGdkOverlapType{.
-    cdecl, dynlib: gdklib, importc: "gdk_region_rect_in".}
-proc gdk_region_offset*(region: PGdkRegion, dx: gint, dy: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_offset".}
-proc gdk_region_shrink*(region: PGdkRegion, dx: gint, dy: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_shrink".}
-proc gdk_region_union_with_rect*(region: PGdkRegion, rect: PGdkRectangle){.
-    cdecl, dynlib: gdklib, importc: "gdk_region_union_with_rect".}
-proc gdk_region_intersect*(source1: PGdkRegion, source2: PGdkRegion){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_intersect".}
-proc gdk_region_union*(source1: PGdkRegion, source2: PGdkRegion){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_union".}
-proc gdk_region_subtract*(source1: PGdkRegion, source2: PGdkRegion){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_subtract".}
-proc gdk_region_xor*(source1: PGdkRegion, source2: PGdkRegion){.cdecl,
-    dynlib: gdklib, importc: "gdk_region_xor".}
-proc gdk_region_spans_intersect_foreach*(region: PGdkRegion, spans: PGdkSpan,
-    n_spans: int32, sorted: gboolean, `function`: TGdkSpanFunc, data: gpointer){.
-    cdecl, dynlib: gdklib, importc: "gdk_region_spans_intersect_foreach".}
-proc gdk_rgb_find_color*(colormap: PGdkColormap, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_rgb_find_color".}
-proc gdk_draw_rgb_image*(drawable: PGdkDrawable, gc: PGdkGC, x: gint, y: gint,
-                         width: gint, height: gint, dith: TGdkRgbDither,
-                         rgb_buf: Pguchar, rowstride: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_draw_rgb_image".}
-proc gdk_draw_rgb_image_dithalign*(drawable: PGdkDrawable, gc: PGdkGC, x: gint,
-                                   y: gint, width: gint, height: gint,
-                                   dith: TGdkRgbDither, rgb_buf: Pguchar,
-                                   rowstride: gint, xdith: gint, ydith: gint){.
-    cdecl, dynlib: gdklib, importc: "gdk_draw_rgb_image_dithalign".}
-proc gdk_draw_rgb_32_image*(drawable: PGdkDrawable, gc: PGdkGC, x: gint,
-                            y: gint, width: gint, height: gint,
-                            dith: TGdkRgbDither, buf: Pguchar, rowstride: gint){.
-    cdecl, dynlib: gdklib, importc: "gdk_draw_rgb_32_image".}
-proc gdk_draw_rgb_32_image_dithalign*(drawable: PGdkDrawable, gc: PGdkGC,
-                                      x: gint, y: gint, width: gint,
-                                      height: gint, dith: TGdkRgbDither,
-                                      buf: Pguchar, rowstride: gint,
-                                      xdith: gint, ydith: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_draw_rgb_32_image_dithalign".}
-proc gdk_draw_gray_image*(drawable: PGdkDrawable, gc: PGdkGC, x: gint, y: gint,
-                          width: gint, height: gint, dith: TGdkRgbDither,
-                          buf: Pguchar, rowstride: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_gray_image".}
-proc gdk_draw_indexed_image*(drawable: PGdkDrawable, gc: PGdkGC, x: gint,
-                             y: gint, width: gint, height: gint,
-                             dith: TGdkRgbDither, buf: Pguchar, rowstride: gint,
-                             cmap: PGdkRgbCmap){.cdecl, dynlib: gdklib,
-    importc: "gdk_draw_indexed_image".}
-proc gdk_rgb_cmap_new*(colors: Pguint32, n_colors: gint): PGdkRgbCmap{.cdecl,
-    dynlib: gdklib, importc: "gdk_rgb_cmap_new".}
-proc gdk_rgb_cmap_free*(cmap: PGdkRgbCmap){.cdecl, dynlib: gdklib,
-    importc: "gdk_rgb_cmap_free".}
-proc gdk_rgb_set_verbose*(verbose: gboolean){.cdecl, dynlib: gdklib,
-    importc: "gdk_rgb_set_verbose".}
-proc gdk_rgb_set_install*(install: gboolean){.cdecl, dynlib: gdklib,
-    importc: "gdk_rgb_set_install".}
-proc gdk_rgb_set_min_colors*(min_colors: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_rgb_set_min_colors".}
-proc GDK_TYPE_DISPLAY*(): GType
-proc GDK_DISPLAY_OBJECT*(anObject: pointer): PGdkDisplay
-proc GDK_DISPLAY_CLASS*(klass: pointer): PGdkDisplayClass
-proc GDK_IS_DISPLAY*(anObject: pointer): bool
-proc GDK_IS_DISPLAY_CLASS*(klass: pointer): bool
-proc GDK_DISPLAY_GET_CLASS*(obj: pointer): PGdkDisplayClass
-proc gdk_display_open*(display_name: cstring): PGdkDisplay{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_open".}
-proc gdk_display_get_name*(display: PGdkDisplay): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_display_get_name".}
-proc gdk_display_get_n_screens*(display: PGdkDisplay): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_get_n_screens".}
-proc gdk_display_get_screen*(display: PGdkDisplay, screen_num: gint): PGdkScreen{.
-    cdecl, dynlib: gdklib, importc: "gdk_display_get_screen".}
-proc gdk_display_get_default_screen*(display: PGdkDisplay): PGdkScreen{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_get_default_screen".}
-proc gdk_display_pointer_ungrab*(display: PGdkDisplay, time: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_display_pointer_ungrab".}
-proc gdk_display_keyboard_ungrab*(display: PGdkDisplay, time: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_display_keyboard_ungrab".}
-proc gdk_display_pointer_is_grabbed*(display: PGdkDisplay): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_pointer_is_grabbed".}
-proc gdk_display_beep*(display: PGdkDisplay){.cdecl, dynlib: gdklib,
-    importc: "gdk_display_beep".}
-proc gdk_display_sync*(display: PGdkDisplay){.cdecl, dynlib: gdklib,
-    importc: "gdk_display_sync".}
-proc gdk_display_close*(display: PGdkDisplay){.cdecl, dynlib: gdklib,
-    importc: "gdk_display_close".}
-proc gdk_display_list_devices*(display: PGdkDisplay): PGList{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_list_devices".}
-proc gdk_display_get_event*(display: PGdkDisplay): PGdkEvent{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_get_event".}
-proc gdk_display_peek_event*(display: PGdkDisplay): PGdkEvent{.cdecl,
-    dynlib: gdklib, importc: "gdk_display_peek_event".}
-proc gdk_display_put_event*(display: PGdkDisplay, event: PGdkEvent){.cdecl,
-    dynlib: gdklib, importc: "gdk_display_put_event".}
-proc gdk_display_add_client_message_filter*(display: PGdkDisplay,
-    message_type: TGdkAtom, func: TGdkFilterFunc, data: gpointer){.cdecl,
-    dynlib: gdklib, importc: "gdk_display_add_client_message_filter".}
-proc gdk_display_set_double_click_time*(display: PGdkDisplay, msec: guint){.
-    cdecl, dynlib: gdklib, importc: "gdk_display_set_double_click_time".}
-proc gdk_display_set_sm_client_id*(display: PGdkDisplay, sm_client_id: cstring){.
-    cdecl, dynlib: gdklib, importc: "gdk_display_set_sm_client_id".}
-proc gdk_set_default_display*(display: PGdkDisplay){.cdecl, dynlib: gdklib,
-    importc: "gdk_set_default_display".}
-proc gdk_get_default_display*(): PGdkDisplay{.cdecl, dynlib: gdklib,
-    importc: "gdk_get_default_display".}
-proc GDK_TYPE_SCREEN*(): GType
-proc GDK_SCREEN*(anObject: Pointer): PGdkScreen
-proc GDK_SCREEN_CLASS*(klass: Pointer): PGdkScreenClass
-proc GDK_IS_SCREEN*(anObject: Pointer): bool
-proc GDK_IS_SCREEN_CLASS*(klass: Pointer): bool
-proc GDK_SCREEN_GET_CLASS*(obj: Pointer): PGdkScreenClass
-proc gdk_screen_get_default_colormap*(screen: PGdkScreen): PGdkColormap{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_default_colormap".}
-proc gdk_screen_set_default_colormap*(screen: PGdkScreen, colormap: PGdkColormap){.
-    cdecl, dynlib: gdklib, importc: "gdk_screen_set_default_colormap".}
-proc gdk_screen_get_system_colormap*(screen: PGdkScreen): PGdkColormap{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_system_colormap".}
-proc gdk_screen_get_system_visual*(screen: PGdkScreen): PGdkVisual{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_system_visual".}
-proc gdk_screen_get_rgb_colormap*(screen: PGdkScreen): PGdkColormap{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_rgb_colormap".}
-proc gdk_screen_get_rgb_visual*(screen: PGdkScreen): PGdkVisual{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_rgb_visual".}
-proc gdk_screen_get_root_window*(screen: PGdkScreen): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_root_window".}
-proc gdk_screen_get_display*(screen: PGdkScreen): PGdkDisplay{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_display".}
-proc gdk_screen_get_number*(screen: PGdkScreen): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_get_number".}
-proc gdk_screen_get_window_at_pointer*(screen: PGdkScreen, win_x: Pgint,
-                                       win_y: Pgint): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_window_at_pointer".}
-proc gdk_screen_get_width*(screen: PGdkScreen): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_get_width".}
-proc gdk_screen_get_height*(screen: PGdkScreen): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_get_height".}
-proc gdk_screen_get_width_mm*(screen: PGdkScreen): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_get_width_mm".}
-proc gdk_screen_get_height_mm*(screen: PGdkScreen): gint{.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_get_height_mm".}
-proc gdk_screen_close*(screen: PGdkScreen){.cdecl, dynlib: gdklib,
-    importc: "gdk_screen_close".}
-proc gdk_screen_list_visuals*(screen: PGdkScreen): PGList{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_list_visuals".}
-proc gdk_screen_get_toplevel_windows*(screen: PGdkScreen): PGList{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_toplevel_windows".}
-proc gdk_screen_get_n_monitors*(screen: PGdkScreen): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_n_monitors".}
-proc gdk_screen_get_monitor_geometry*(screen: PGdkScreen, monitor_num: gint,
-                                      dest: PGdkRectangle){.cdecl,
-    dynlib: gdklib, importc: "gdk_screen_get_monitor_geometry".}
-proc gdk_screen_get_monitor_at_point*(screen: PGdkScreen, x: gint, y: gint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_screen_get_monitor_at_point".}
-proc gdk_screen_get_monitor_at_window*(screen: PGdkScreen, window: PGdkWindow): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_screen_get_monitor_at_window".}
-proc gdk_screen_broadcast_client_message*(screen: PGdkScreen, event: PGdkEvent){.
-    cdecl, dynlib: gdklib, importc: "gdk_screen_broadcast_client_message".}
-proc gdk_get_default_screen*(): PGdkScreen{.cdecl, dynlib: gdklib,
-    importc: "gdk_get_default_screen".}
-proc gdk_screen_get_setting*(screen: PGdkScreen, name: cstring, value: PGValue): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_screen_get_setting".}
-proc GDK_SELECTION_PRIMARY*(): TGdkAtom
-proc GDK_SELECTION_SECONDARY*(): TGdkAtom
-proc GDK_SELECTION_CLIPBOARD*(): TGdkAtom
-proc GDK_TARGET_BITMAP*(): TGdkAtom
-proc GDK_TARGET_COLORMAP*(): TGdkAtom
-proc GDK_TARGET_DRAWABLE*(): TGdkAtom
-proc GDK_TARGET_PIXMAP*(): TGdkAtom
-proc GDK_TARGET_STRING*(): TGdkAtom
-proc GDK_SELECTION_TYPE_ATOM*(): TGdkAtom
-proc GDK_SELECTION_TYPE_BITMAP*(): TGdkAtom
-proc GDK_SELECTION_TYPE_COLORMAP*(): TGdkAtom
-proc GDK_SELECTION_TYPE_DRAWABLE*(): TGdkAtom
-proc GDK_SELECTION_TYPE_INTEGER*(): TGdkAtom
-proc GDK_SELECTION_TYPE_PIXMAP*(): TGdkAtom
-proc GDK_SELECTION_TYPE_WINDOW*(): TGdkAtom
-proc GDK_SELECTION_TYPE_STRING*(): TGdkAtom
-proc gdk_selection_owner_set_for_display*(display: PGdkDisplay,
-    owner: PGdkWindow, selection: TGdkAtom, time: guint32, send_event: gboolean): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_selection_owner_set_for_display".}
-proc gdk_selection_owner_get_for_display*(display: PGdkDisplay,
-    selection: TGdkAtom): PGdkWindow{.cdecl, dynlib: gdklib, importc: "gdk_selection_owner_get_for_display".}
-proc gdk_selection_convert*(requestor: PGdkWindow, selection: TGdkAtom,
-                            target: TGdkAtom, time: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_selection_convert".}
-proc gdk_selection_property_get*(requestor: PGdkWindow, data: PPguchar,
-                                 prop_type: PGdkAtom, prop_format: Pgint): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_selection_property_get".}
-proc gdk_selection_send_notify_for_display*(display: PGdkDisplay,
-    requestor: guint32, selection: TGdkAtom, target: TGdkAtom,
-    `property`: TGdkAtom, time: guint32){.cdecl, dynlib: gdklib,
-    importc: "gdk_selection_send_notify_for_display".}
-const
-  GDK_CURRENT_TIME* = 0
-  GDK_PARENT_RELATIVE* = 1
-  GDK_OK* = 0
-  GDK_ERROR* = - (1)
-  GDK_ERROR_PARAM* = - (2)
-  GDK_ERROR_FILE* = - (3)
-  GDK_ERROR_MEM* = - (4)
-  GDK_SHIFT_MASK* = 1 shl 0
-  GDK_LOCK_MASK* = 1 shl 1
-  GDK_CONTROL_MASK* = 1 shl 2
-  GDK_MOD1_MASK* = 1 shl 3
-  GDK_MOD2_MASK* = 1 shl 4
-  GDK_MOD3_MASK* = 1 shl 5
-  GDK_MOD4_MASK* = 1 shl 6
-  GDK_MOD5_MASK* = 1 shl 7
-  GDK_BUTTON1_MASK* = 1 shl 8
-  GDK_BUTTON2_MASK* = 1 shl 9
-  GDK_BUTTON3_MASK* = 1 shl 10
-  GDK_BUTTON4_MASK* = 1 shl 11
-  GDK_BUTTON5_MASK* = 1 shl 12
-  GDK_RELEASE_MASK* = 1 shl 30
-  GDK_MODIFIER_MASK* = ord(GDK_RELEASE_MASK) or 0x00001FFF
-  GDK_INPUT_READ* = 1 shl 0
-  GDK_INPUT_WRITE* = 1 shl 1
-  GDK_INPUT_EXCEPTION* = 1 shl 2
-  GDK_GRAB_SUCCESS* = 0
-  GDK_GRAB_ALREADY_GRABBED* = 1
-  GDK_GRAB_INVALID_TIME* = 2
-  GDK_GRAB_NOT_VIEWABLE* = 3
-  GDK_GRAB_FROZEN* = 4
-
-proc GDK_ATOM_TO_POINTER*(atom: TGdkAtom): Pointer
-proc GDK_POINTER_TO_ATOM*(p: Pointer): TGdkAtom
-proc `GDK_MAKE_ATOM`*(val: guint): TGdkAtom
-proc GDK_NONE*(): TGdkAtom
-proc GDK_TYPE_VISUAL*(): GType
-proc GDK_VISUAL*(anObject: Pointer): PGdkVisual
-proc GDK_VISUAL_CLASS*(klass: Pointer): PGdkVisualClass
-proc GDK_IS_VISUAL*(anObject: Pointer): bool
-proc GDK_IS_VISUAL_CLASS*(klass: Pointer): bool
-proc GDK_VISUAL_GET_CLASS*(obj: Pointer): PGdkVisualClass
-proc gdk_visual_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_visual_get_type".}
-const
-  GDK_WA_TITLE* = 1 shl 1
-  GDK_WA_X* = 1 shl 2
-  GDK_WA_Y* = 1 shl 3
-  GDK_WA_CURSOR* = 1 shl 4
-  GDK_WA_COLORMAP* = 1 shl 5
-  GDK_WA_VISUAL* = 1 shl 6
-  GDK_WA_WMCLASS* = 1 shl 7
-  GDK_WA_NOREDIR* = 1 shl 8
-  GDK_HINT_POS* = 1 shl 0
-  GDK_HINT_MIN_SIZE* = 1 shl 1
-  GDK_HINT_MAX_SIZE* = 1 shl 2
-  GDK_HINT_BASE_SIZE* = 1 shl 3
-  GDK_HINT_ASPECT* = 1 shl 4
-  GDK_HINT_RESIZE_INC* = 1 shl 5
-  GDK_HINT_WIN_GRAVITY* = 1 shl 6
-  GDK_HINT_USER_POS* = 1 shl 7
-  GDK_HINT_USER_SIZE* = 1 shl 8
-  GDK_DECOR_ALL* = 1 shl 0
-  GDK_DECOR_BORDER* = 1 shl 1
-  GDK_DECOR_RESIZEH* = 1 shl 2
-  GDK_DECOR_TITLE* = 1 shl 3
-  GDK_DECOR_MENU* = 1 shl 4
-  GDK_DECOR_MINIMIZE* = 1 shl 5
-  GDK_DECOR_MAXIMIZE* = 1 shl 6
-  GDK_FUNC_ALL* = 1 shl 0
-  GDK_FUNC_RESIZE* = 1 shl 1
-  GDK_FUNC_MOVE* = 1 shl 2
-  GDK_FUNC_MINIMIZE* = 1 shl 3
-  GDK_FUNC_MAXIMIZE* = 1 shl 4
-  GDK_FUNC_CLOSE* = 1 shl 5
-  GDK_GRAVITY_NORTH_WEST* = 1
-  GDK_GRAVITY_NORTH* = 2
-  GDK_GRAVITY_NORTH_EAST* = 3
-  GDK_GRAVITY_WEST* = 4
-  GDK_GRAVITY_CENTER* = 5
-  GDK_GRAVITY_EAST* = 6
-  GDK_GRAVITY_SOUTH_WEST* = 7
-  GDK_GRAVITY_SOUTH* = 8
-  GDK_GRAVITY_SOUTH_EAST* = 9
-  GDK_GRAVITY_STATIC* = 10
-
-proc GDK_TYPE_WINDOW*(): GType
-proc GDK_WINDOW*(anObject: Pointer): PGdkWindow
-proc GDK_WINDOW_CLASS*(klass: Pointer): PGdkWindowObjectClass
-proc GDK_IS_WINDOW*(anObject: Pointer): bool
-proc GDK_IS_WINDOW_CLASS*(klass: Pointer): bool
-proc GDK_WINDOW_GET_CLASS*(obj: Pointer): PGdkWindowObjectClass
-proc GDK_WINDOW_OBJECT*(anObject: Pointer): PGdkWindowObject
-const
-  bm_TGdkWindowObject_guffaw_gravity* = 0x00000001'i16
-  bp_TGdkWindowObject_guffaw_gravity* = 0'i16
-  bm_TGdkWindowObject_input_only* = 0x00000002'i16
-  bp_TGdkWindowObject_input_only* = 1'i16
-  bm_TGdkWindowObject_modal_hint* = 0x00000004'i16
-  bp_TGdkWindowObject_modal_hint* = 2'i16
-  bm_TGdkWindowObject_destroyed* = 0x00000018'i16
-  bp_TGdkWindowObject_destroyed* = 3'i16
-
-proc GdkWindowObject_guffaw_gravity*(a: var TGdkWindowObject): guint
-proc GdkWindowObject_set_guffaw_gravity*(a: var TGdkWindowObject,
-    `guffaw_gravity`: guint)
-proc GdkWindowObject_input_only*(a: var TGdkWindowObject): guint
-proc GdkWindowObject_set_input_only*(a: var TGdkWindowObject,
-                                     `input_only`: guint)
-proc GdkWindowObject_modal_hint*(a: var TGdkWindowObject): guint
-proc GdkWindowObject_set_modal_hint*(a: var TGdkWindowObject,
-                                     `modal_hint`: guint)
-proc GdkWindowObject_destroyed*(a: var TGdkWindowObject): guint
-proc GdkWindowObject_set_destroyed*(a: var TGdkWindowObject, `destroyed`: guint)
-proc gdk_window_object_get_type*(): GType{.cdecl, dynlib: gdklib,
-    importc: "gdk_window_object_get_type".}
-proc gdk_window_new*(parent: PGdkWindow, attributes: PGdkWindowAttr,
-                     attributes_mask: gint): PGdkWindow{.cdecl, dynlib: gdklib,
-    importc: "gdk_window_new".}
-proc gdk_window_destroy*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_destroy".}
-proc gdk_window_get_window_type*(window: PGdkWindow): TGdkWindowType{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_window_type".}
-proc gdk_window_at_pointer*(win_x: Pgint, win_y: Pgint): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_at_pointer".}
-proc gdk_window_show*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_show".}
-proc gdk_window_hide*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_hide".}
-proc gdk_window_withdraw*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_withdraw".}
-proc gdk_window_show_unraised*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_show_unraised".}
-proc gdk_window_move*(window: PGdkWindow, x: gint, y: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_move".}
-proc gdk_window_resize*(window: PGdkWindow, width: gint, height: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_resize".}
-proc gdk_window_move_resize*(window: PGdkWindow, x: gint, y: gint, width: gint,
-                             height: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_move_resize".}
-proc gdk_window_reparent*(window: PGdkWindow, new_parent: PGdkWindow, x: gint,
-                          y: gint){.cdecl, dynlib: gdklib,
-                                    importc: "gdk_window_reparent".}
-proc gdk_window_clear*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_clear".}
-proc gdk_window_clear_area*(window: PGdkWindow, x: gint, y: gint, width: gint,
-                            height: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_clear_area".}
-proc gdk_window_clear_area_e*(window: PGdkWindow, x: gint, y: gint, width: gint,
-                              height: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_clear_area_e".}
-proc gdk_window_raise*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_raise".}
-proc gdk_window_lower*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_lower".}
-proc gdk_window_focus*(window: PGdkWindow, timestamp: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_focus".}
-proc gdk_window_set_user_data*(window: PGdkWindow, user_data: gpointer){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_user_data".}
-proc gdk_window_set_override_redirect*(window: PGdkWindow,
-                                       override_redirect: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_override_redirect".}
-proc gdk_window_add_filter*(window: PGdkWindow, `function`: TGdkFilterFunc,
-                            data: gpointer){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_add_filter".}
-proc gdk_window_remove_filter*(window: PGdkWindow, `function`: TGdkFilterFunc,
-                               data: gpointer){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_remove_filter".}
-proc gdk_window_scroll*(window: PGdkWindow, dx: gint, dy: gint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_scroll".}
-proc gdk_window_shape_combine_mask*(window: PGdkWindow, mask: PGdkBitmap,
-                                    x: gint, y: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_shape_combine_mask".}
-proc gdk_window_shape_combine_region*(window: PGdkWindow,
-                                      shape_region: PGdkRegion, offset_x: gint,
-                                      offset_y: gint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_shape_combine_region".}
-proc gdk_window_set_child_shapes*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_set_child_shapes".}
-proc gdk_window_merge_child_shapes*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_merge_child_shapes".}
-proc gdk_window_is_visible*(window: PGdkWindow): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_is_visible".}
-proc gdk_window_is_viewable*(window: PGdkWindow): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_is_viewable".}
-proc gdk_window_get_state*(window: PGdkWindow): TGdkWindowState{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_state".}
-proc gdk_window_set_static_gravities*(window: PGdkWindow, use_static: gboolean): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_window_set_static_gravities".}
-proc gdk_window_foreign_new_for_display*(display: PGdkDisplay,
-    anid: TGdkNativeWindow): PGdkWindow{.cdecl, dynlib: gdklib,
-    importc: "gdk_window_foreign_new_for_display".}
-proc gdk_window_lookup_for_display*(display: PGdkDisplay, anid: TGdkNativeWindow): PGdkWindow{.
-    cdecl, dynlib: gdklib, importc: "gdk_window_lookup_for_display".}
-proc gdk_window_set_type_hint*(window: PGdkWindow, hint: TGdkWindowTypeHint){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_set_type_hint".}
-proc gdk_window_set_modal_hint*(window: PGdkWindow, modal: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_modal_hint".}
-proc gdk_window_set_geometry_hints*(window: PGdkWindow, geometry: PGdkGeometry,
-                                    geom_mask: TGdkWindowHints){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_geometry_hints".}
-proc gdk_set_sm_client_id*(sm_client_id: cstring){.cdecl, dynlib: gdklib,
-    importc: "gdk_set_sm_client_id".}
-proc gdk_window_begin_paint_rect*(window: PGdkWindow, rectangle: PGdkRectangle){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_begin_paint_rect".}
-proc gdk_window_begin_paint_region*(window: PGdkWindow, region: PGdkRegion){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_begin_paint_region".}
-proc gdk_window_end_paint*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_end_paint".}
-proc gdk_window_set_title*(window: PGdkWindow, title: cstring){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_title".}
-proc gdk_window_set_role*(window: PGdkWindow, role: cstring){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_role".}
-proc gdk_window_set_transient_for*(window: PGdkWindow, parent: PGdkWindow){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_set_transient_for".}
-proc gdk_window_set_background*(window: PGdkWindow, color: PGdkColor){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_background".}
-proc gdk_window_set_back_pixmap*(window: PGdkWindow, pixmap: PGdkPixmap,
-                                 parent_relative: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_back_pixmap".}
-proc gdk_window_set_cursor*(window: PGdkWindow, cursor: PGdkCursor){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_cursor".}
-proc gdk_window_get_user_data*(window: PGdkWindow, data: gpointer){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_user_data".}
-proc gdk_window_get_geometry*(window: PGdkWindow, x: Pgint, y: Pgint,
-                              width: Pgint, height: Pgint, depth: Pgint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_geometry".}
-proc gdk_window_get_position*(window: PGdkWindow, x: Pgint, y: Pgint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_position".}
-proc gdk_window_get_origin*(window: PGdkWindow, x: Pgint, y: Pgint): gint{.
-    cdecl, dynlib: gdklib, importc: "gdk_window_get_origin".}
-proc gdk_window_get_root_origin*(window: PGdkWindow, x: Pgint, y: Pgint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_root_origin".}
-proc gdk_window_get_frame_extents*(window: PGdkWindow, rect: PGdkRectangle){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_get_frame_extents".}
-proc gdk_window_get_pointer*(window: PGdkWindow, x: Pgint, y: Pgint,
-                             mask: PGdkModifierType): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_pointer".}
-proc gdk_window_get_parent*(window: PGdkWindow): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_parent".}
-proc gdk_window_get_toplevel*(window: PGdkWindow): PGdkWindow{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_toplevel".}
-proc gdk_window_get_children*(window: PGdkWindow): PGList{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_children".}
-proc gdk_window_peek_children*(window: PGdkWindow): PGList{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_peek_children".}
-proc gdk_window_get_events*(window: PGdkWindow): TGdkEventMask{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_events".}
-proc gdk_window_set_events*(window: PGdkWindow, event_mask: TGdkEventMask){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_set_events".}
-proc gdk_window_set_icon_list*(window: PGdkWindow, pixbufs: PGList){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_icon_list".}
-proc gdk_window_set_icon*(window: PGdkWindow, icon_window: PGdkWindow,
-                          pixmap: PGdkPixmap, mask: PGdkBitmap){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_icon".}
-proc gdk_window_set_icon_name*(window: PGdkWindow, name: cstring){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_icon_name".}
-proc gdk_window_set_group*(window: PGdkWindow, leader: PGdkWindow){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_group".}
-proc gdk_window_set_decorations*(window: PGdkWindow,
-                                 decorations: TGdkWMDecoration){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_set_decorations".}
-proc gdk_window_get_decorations*(window: PGdkWindow,
-                                 decorations: PGdkWMDecoration): gboolean{.
-    cdecl, dynlib: gdklib, importc: "gdk_window_get_decorations".}
-proc gdk_window_set_functions*(window: PGdkWindow, functions: TGdkWMFunction){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_set_functions".}
-proc gdk_window_iconify*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_iconify".}
-proc gdk_window_deiconify*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_deiconify".}
-proc gdk_window_stick*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_stick".}
-proc gdk_window_unstick*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_unstick".}
-proc gdk_window_maximize*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_maximize".}
-proc gdk_window_unmaximize*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_unmaximize".}
-proc gdk_window_register_dnd*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_register_dnd".}
-proc gdk_window_begin_resize_drag*(window: PGdkWindow, edge: TGdkWindowEdge,
-                                   button: gint, root_x: gint, root_y: gint,
-                                   timestamp: guint32){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_begin_resize_drag".}
-proc gdk_window_begin_move_drag*(window: PGdkWindow, button: gint, root_x: gint,
-                                 root_y: gint, timestamp: guint32){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_begin_move_drag".}
-proc gdk_window_invalidate_rect*(window: PGdkWindow, rect: PGdkRectangle,
-                                 invalidate_children: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_invalidate_rect".}
-proc gdk_window_invalidate_region*(window: PGdkWindow, region: PGdkRegion,
-                                   invalidate_children: gboolean){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_invalidate_region".}
-proc gdk_window_invalidate_maybe_recurse*(window: PGdkWindow,
-    region: PGdkRegion,
-    child_func: gdk_window_invalidate_maybe_recurse_child_func,
-    user_data: gpointer){.cdecl, dynlib: gdklib,
-                          importc: "gdk_window_invalidate_maybe_recurse".}
-proc gdk_window_get_update_area*(window: PGdkWindow): PGdkRegion{.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_update_area".}
-proc gdk_window_freeze_updates*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_freeze_updates".}
-proc gdk_window_thaw_updates*(window: PGdkWindow){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_thaw_updates".}
-proc gdk_window_process_all_updates*(){.cdecl, dynlib: gdklib, importc: "gdk_window_process_all_updates".}
-proc gdk_window_process_updates*(window: PGdkWindow, update_children: gboolean){.
-    cdecl, dynlib: gdklib, importc: "gdk_window_process_updates".}
-proc gdk_window_set_debug_updates*(setting: gboolean){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_set_debug_updates".}
-proc gdk_window_constrain_size*(geometry: PGdkGeometry, flags: guint,
-                                width: gint, height: gint, new_width: Pgint,
-                                new_height: Pgint){.cdecl, dynlib: gdklib,
-    importc: "gdk_window_constrain_size".}
-proc gdk_window_get_internal_paint_info*(window: PGdkWindow,
-    e: var PGdkDrawable, x_offset: Pgint, y_offset: Pgint){.cdecl,
-    dynlib: gdklib, importc: "gdk_window_get_internal_paint_info".}
-proc gdk_set_pointer_hooks*(new_hooks: PGdkPointerHooks): PGdkPointerHooks{.
-    cdecl, dynlib: gdklib, importc: "gdk_set_pointer_hooks".}
-proc gdk_get_default_root_window*(): PGdkWindow{.cdecl, dynlib: gdklib,
-    importc: "gdk_get_default_root_window".}
-proc gdk_parse_args*(argc: Pgint, v: var PPgchar){.cdecl, dynlib: gdklib,
-    importc: "gdk_parse_args".}
-proc gdk_init*(argc: Pgint, v: var PPgchar){.cdecl, dynlib: gdklib,
-    importc: "gdk_init".}
-proc gdk_init_check*(argc: Pgint, v: var PPgchar): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_init_check".}
-when not defined(GDK_DISABLE_DEPRECATED):
-  proc gdk_exit*(error_code: gint){.cdecl, dynlib: gdklib, importc: "gdk_exit".}
-proc gdk_set_locale*(): cstring{.cdecl, dynlib: gdklib, importc: "gdk_set_locale".}
-proc gdk_get_program_class*(): cstring{.cdecl, dynlib: gdklib,
-                                        importc: "gdk_get_program_class".}
-proc gdk_set_program_class*(program_class: cstring){.cdecl, dynlib: gdklib,
-    importc: "gdk_set_program_class".}
-proc gdk_error_trap_push*(){.cdecl, dynlib: gdklib,
-                             importc: "gdk_error_trap_push".}
-proc gdk_error_trap_pop*(): gint{.cdecl, dynlib: gdklib,
-                                  importc: "gdk_error_trap_pop".}
-when not defined(GDK_DISABLE_DEPRECATED):
-  proc gdk_set_use_xshm*(use_xshm: gboolean){.cdecl, dynlib: gdklib,
-      importc: "gdk_set_use_xshm".}
-  proc gdk_get_use_xshm*(): gboolean{.cdecl, dynlib: gdklib,
-                                     importc: "gdk_get_use_xshm".}
-proc gdk_get_display*(): cstring{.cdecl, dynlib: gdklib,
-                                 importc: "gdk_get_display".}
-proc gdk_get_display_arg_name*(): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_get_display_arg_name".}
-when not defined(GDK_DISABLE_DEPRECATED):
-  proc gdk_input_add_full*(source: gint, condition: TGdkInputCondition,
-                          `function`: TGdkInputFunction, data: gpointer,
-                          destroy: TGdkDestroyNotify): gint{.cdecl,
-      dynlib: gdklib, importc: "gdk_input_add_full".}
-  proc gdk_input_add*(source: gint, condition: TGdkInputCondition,
-                     `function`: TGdkInputFunction, data: gpointer): gint{.
-      cdecl, dynlib: gdklib, importc: "gdk_input_add".}
-  proc gdk_input_remove*(tag: gint){.cdecl, dynlib: gdklib,
-                                    importc: "gdk_input_remove".}
-proc gdk_pointer_grab*(window: PGdkWindow, owner_events: gboolean,
-                       event_mask: TGdkEventMask, confine_to: PGdkWindow,
-                       cursor: PGdkCursor, time: guint32): TGdkGrabStatus{.
-    cdecl, dynlib: gdklib, importc: "gdk_pointer_grab".}
-proc gdk_keyboard_grab*(window: PGdkWindow, owner_events: gboolean,
-                        time: guint32): TGdkGrabStatus{.cdecl, dynlib: gdklib,
-    importc: "gdk_keyboard_grab".}
-when not defined(GDK_MULTIHEAD_SAFE):
-  proc gdk_pointer_ungrab*(time: guint32){.cdecl, dynlib: gdklib,
-      importc: "gdk_pointer_ungrab".}
-  proc gdk_keyboard_ungrab*(time: guint32){.cdecl, dynlib: gdklib,
-      importc: "gdk_keyboard_ungrab".}
-  proc gdk_pointer_is_grabbed*(): gboolean{.cdecl, dynlib: gdklib,
-      importc: "gdk_pointer_is_grabbed".}
-  proc gdk_screen_width*(): gint{.cdecl, dynlib: gdklib,
-                                 importc: "gdk_screen_width".}
-  proc gdk_screen_height*(): gint{.cdecl, dynlib: gdklib,
-                                  importc: "gdk_screen_height".}
-  proc gdk_screen_width_mm*(): gint{.cdecl, dynlib: gdklib,
-                                    importc: "gdk_screen_width_mm".}
-  proc gdk_screen_height_mm*(): gint{.cdecl, dynlib: gdklib,
-                                     importc: "gdk_screen_height_mm".}
-  proc gdk_beep*(){.cdecl, dynlib: gdklib, importc: "gdk_beep".}
-proc gdk_flush*(){.cdecl, dynlib: gdklib, importc: "gdk_flush".}
-when not defined(GDK_MULTIHEAD_SAFE):
-  proc gdk_set_double_click_time*(msec: guint){.cdecl, dynlib: gdklib,
-      importc: "gdk_set_double_click_time".}
-proc gdk_rectangle_intersect*(src1: PGdkRectangle, src2: PGdkRectangle,
-                              dest: PGdkRectangle): gboolean{.cdecl,
-    dynlib: gdklib, importc: "gdk_rectangle_intersect".}
-proc gdk_rectangle_union*(src1: PGdkRectangle, src2: PGdkRectangle,
-                          dest: PGdkRectangle){.cdecl, dynlib: gdklib,
-    importc: "gdk_rectangle_union".}
-proc gdk_rectangle_get_type*(): GType{.cdecl, dynlib: gdklib,
-                                       importc: "gdk_rectangle_get_type".}
-proc GDK_TYPE_RECTANGLE*(): GType
-proc gdk_wcstombs*(src: PGdkWChar): cstring{.cdecl, dynlib: gdklib,
-    importc: "gdk_wcstombs".}
-proc gdk_mbstowcs*(dest: PGdkWChar, src: cstring, dest_max: gint): gint{.cdecl,
-    dynlib: gdklib, importc: "gdk_mbstowcs".}
-when not defined(GDK_MULTIHEAD_SAFE):
-  proc gdk_event_send_client_message*(event: PGdkEvent, xid: guint32): gboolean{.
-      cdecl, dynlib: gdklib, importc: "gdk_event_send_client_message".}
-  proc gdk_event_send_clientmessage_toall*(event: PGdkEvent){.cdecl,
-      dynlib: gdklib, importc: "gdk_event_send_clientmessage_toall".}
-proc gdk_event_send_client_message_for_display*(display: PGdkDisplay,
-    event: PGdkEvent, xid: guint32): gboolean{.cdecl, dynlib: gdklib,
-    importc: "gdk_event_send_client_message_for_display".}
-proc gdk_threads_enter*(){.cdecl, dynlib: gdklib, importc: "gdk_threads_enter".}
-proc gdk_threads_leave*(){.cdecl, dynlib: gdklib, importc: "gdk_threads_leave".}
-proc gdk_threads_init*(){.cdecl, dynlib: gdklib, importc: "gdk_threads_init".}
-
-proc GDK_TYPE_RECTANGLE*(): GType =
-  result = gdk_rectangle_get_type()
-
-proc GDK_TYPE_COLORMAP*(): GType =
-  result = gdk_colormap_get_type()
-
-proc GDK_COLORMAP*(anObject: pointer): PGdkColormap =
-  result = cast[PGdkColormap](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_COLORMAP()))
-
-proc GDK_COLORMAP_CLASS*(klass: pointer): PGdkColormapClass =
-  result = cast[PGdkColormapClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_COLORMAP()))
-
-proc GDK_IS_COLORMAP*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_COLORMAP())
-
-proc GDK_IS_COLORMAP_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_COLORMAP())
-
-proc GDK_COLORMAP_GET_CLASS*(obj: pointer): PGdkColormapClass =
-  result = cast[PGdkColormapClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_COLORMAP()))
-
-proc GDK_TYPE_COLOR*(): GType =
-  result = gdk_color_get_type()
-
-proc gdk_cursor_destroy*(cursor: PGdkCursor) =
-  gdk_cursor_unref(cursor)
-
-proc GDK_TYPE_CURSOR*(): GType =
-  result = gdk_cursor_get_type()
-
-proc GDK_TYPE_DRAG_CONTEXT*(): GType =
-  result = gdk_drag_context_get_type()
-
-proc GDK_DRAG_CONTEXT*(anObject: Pointer): PGdkDragContext =
-  result = cast[PGdkDragContext](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GDK_TYPE_DRAG_CONTEXT()))
-
-proc GDK_DRAG_CONTEXT_CLASS*(klass: Pointer): PGdkDragContextClass =
-  result = cast[PGdkDragContextClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GDK_TYPE_DRAG_CONTEXT()))
-
-proc GDK_IS_DRAG_CONTEXT*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_DRAG_CONTEXT())
-
-proc GDK_IS_DRAG_CONTEXT_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_DRAG_CONTEXT())
-
-proc GDK_DRAG_CONTEXT_GET_CLASS*(obj: Pointer): PGdkDragContextClass =
-  result = cast[PGdkDragContextClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GDK_TYPE_DRAG_CONTEXT()))
-
-proc gdkregion_EXTENTCHECK*(r1, r2: PGdkRegionBox): bool =
-  result = ((r1.x2) > r2.x1) and ((r1.x1) < r2.x2) and
-      ((r1.y2) > r2.y1) and ((r1.y1) < r2.y2)
-
-proc gdkregion_EXTENTS*(r: PGdkRegionBox, idRect: PGdkRegion) =
-  if ((r.x1) < idRect.extents.x1):
-    idRect.extents.x1 = r.x1
-  if (r.y1) < idRect.extents.y1:
-    idRect.extents.y1 = r.y1
-  if (r.x2) > idRect.extents.x2:
-    idRect.extents.x2 = r.x2
-
-proc gdkregion_MEMCHECK*(reg: PGdkRegion, ARect, firstrect: var PGdkRegionBox): bool =
-  assert(false) # to implement
-
-proc gdkregion_CHECK_PREVIOUS*(Reg: PGdkRegion, R: PGdkRegionBox,
-                               Rx1, Ry1, Rx2, Ry2: gint): bool =
-  assert(false) # to implement
-
-proc gdkregion_ADDRECT*(reg: PGdkRegion, r: PGdkRegionBox,
-                        rx1, ry1, rx2, ry2: gint) =
-  if (((rx1) < rx2) and ((ry1) < ry2) and
-      gdkregion_CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)):
-    r.x1 = rx1
-    r.y1 = ry1
-    r.x2 = rx2
-    r.y2 = ry2
-
-proc gdkregion_ADDRECTNOX*(reg: PGdkRegion, r: PGdkRegionBox,
-                           rx1, ry1, rx2, ry2: gint) =
-  if (((rx1) < rx2) and ((ry1) < ry2) and
-      gdkregion_CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)):
-    r.x1 = rx1
-    r.y1 = ry1
-    r.x2 = rx2
-    r.y2 = ry2
-    inc(reg . numRects)
-
-proc gdkregion_EMPTY_REGION*(pReg: PGdkRegion): bool =
-  result = pReg.numRects == 0'i32
-
-proc gdkregion_REGION_NOT_EMPTY*(pReg: PGdkRegion): bool =
-  result = pReg.numRects != 0'i32
-
-proc gdkregion_INBOX*(r: TGdkRegionBox, x, y: gint): bool =
-  result = ((((r.x2) > x) and ((r.x1) <= x)) and
-            ((r.y2) > y)) and ((r.y1) <= y)
-
-proc GDK_TYPE_DRAWABLE*(): GType =
-  result = gdk_drawable_get_type()
-
-proc GDK_DRAWABLE*(anObject: Pointer): PGdkDrawable =
-  result = cast[PGdkDrawable](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_DRAWABLE()))
-
-proc GDK_DRAWABLE_CLASS*(klass: Pointer): PGdkDrawableClass =
-  result = cast[PGdkDrawableClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_DRAWABLE()))
-
-proc GDK_IS_DRAWABLE*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_DRAWABLE())
-
-proc GDK_IS_DRAWABLE_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_DRAWABLE())
-
-proc GDK_DRAWABLE_GET_CLASS*(obj: Pointer): PGdkDrawableClass =
-  result = cast[PGdkDrawableClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_DRAWABLE()))
-
-proc gdk_draw_pixmap*(drawable: PGdkDrawable, gc: PGdkGC, src: PGdkDrawable,
-                      xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                      width: gint, height: gint) =
-  gdk_draw_drawable(drawable, gc, src, xsrc, ysrc, xdest, ydest, width, height)
-
-proc gdk_draw_bitmap*(drawable: PGdkDrawable, gc: PGdkGC, src: PGdkDrawable,
-                      xsrc: gint, ysrc: gint, xdest: gint, ydest: gint,
-                      width: gint, height: gint) =
-  gdk_draw_drawable(drawable, gc, src, xsrc, ysrc, xdest, ydest, width, height)
-
-proc GDK_TYPE_EVENT*(): GType =
-  result = gdk_event_get_type()
-
-proc GDK_TYPE_FONT*(): GType =
-  result = gdk_font_get_type()
-
-proc GDK_TYPE_GC*(): GType =
-  result = gdk_gc_get_type()
-
-proc GDK_GC*(anObject: Pointer): PGdkGC =
-  result = cast[PGdkGC](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_GC()))
-
-proc GDK_GC_CLASS*(klass: Pointer): PGdkGCClass =
-  result = cast[PGdkGCClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_GC()))
-
-proc GDK_IS_GC*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_GC())
-
-proc GDK_IS_GC_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_GC())
-
-proc GDK_GC_GET_CLASS*(obj: Pointer): PGdkGCClass =
-  result = cast[PGdkGCClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_GC()))
-
-proc gdk_gc_destroy*(gc: PGdkGC) =
-  g_object_unref(G_OBJECT(gc))
-
-proc GDK_TYPE_IMAGE*(): GType =
-  result = gdk_image_get_type()
-
-proc GDK_IMAGE*(anObject: Pointer): PGdkImage =
-  result = cast[PGdkImage](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_IMAGE()))
-
-proc GDK_IMAGE_CLASS*(klass: Pointer): PGdkImageClass =
-  result = cast[PGdkImageClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_IMAGE()))
-
-proc GDK_IS_IMAGE*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_IMAGE())
-
-proc GDK_IS_IMAGE_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_IMAGE())
-
-proc GDK_IMAGE_GET_CLASS*(obj: Pointer): PGdkImageClass =
-  result = cast[PGdkImageClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_IMAGE()))
-
-proc gdk_image_destroy*(image: PGdkImage) =
-  g_object_unref(G_OBJECT(image))
-
-proc GDK_TYPE_DEVICE*(): GType =
-  result = gdk_device_get_type()
-
-proc GDK_DEVICE*(anObject: Pointer): PGdkDevice =
-  result = cast[PGdkDevice](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_DEVICE()))
-
-proc GDK_DEVICE_CLASS*(klass: Pointer): PGdkDeviceClass =
-  result = cast[PGdkDeviceClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_DEVICE()))
-
-proc GDK_IS_DEVICE*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_DEVICE())
-
-proc GDK_IS_DEVICE_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_DEVICE())
-
-proc GDK_DEVICE_GET_CLASS*(obj: Pointer): PGdkDeviceClass =
-  result = cast[PGdkDeviceClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_DEVICE()))
-
-proc GDK_TYPE_KEYMAP*(): GType =
-  result = gdk_keymap_get_type()
-
-proc GDK_KEYMAP*(anObject: Pointer): PGdkKeymap =
-  result = cast[PGdkKeymap](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_KEYMAP()))
-
-proc GDK_KEYMAP_CLASS*(klass: Pointer): PGdkKeymapClass =
-  result = cast[PGdkKeymapClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_KEYMAP()))
-
-proc GDK_IS_KEYMAP*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_KEYMAP())
-
-proc GDK_IS_KEYMAP_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_KEYMAP())
-
-proc GDK_KEYMAP_GET_CLASS*(obj: Pointer): PGdkKeymapClass =
-  result = cast[PGdkKeymapClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_KEYMAP()))
-
-proc GDK_TYPE_PIXMAP*(): GType =
-  result = gdk_pixmap_get_type()
-
-proc GDK_PIXMAP*(anObject: Pointer): PGdkPixmap =
-  result = cast[PGdkPixmap](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_PIXMAP()))
-
-proc GDK_PIXMAP_CLASS*(klass: Pointer): PGdkPixmapObjectClass =
-  result = cast[PGdkPixmapObjectClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_PIXMAP()))
-
-proc GDK_IS_PIXMAP*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_PIXMAP())
-
-proc GDK_IS_PIXMAP_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_PIXMAP())
-
-proc GDK_PIXMAP_GET_CLASS*(obj: Pointer): PGdkPixmapObjectClass =
-  result = cast[PGdkPixmapObjectClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_PIXMAP()))
-
-proc GDK_PIXMAP_OBJECT*(anObject: Pointer): PGdkPixmapObject =
-  result = cast[PGdkPixmapObject](GDK_PIXMAP(anObject))
-
-proc gdk_bitmap_ref*(drawable: PGdkDrawable): PGdkDrawable =
-  result = GDK_DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc gdk_bitmap_unref*(drawable: PGdkDrawable) =
-  g_object_unref(G_OBJECT(drawable))
-
-proc gdk_pixmap_ref*(drawable: PGdkDrawable): PGdkDrawable =
-  result = GDK_DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc gdk_pixmap_unref*(drawable: PGdkDrawable) =
-  g_object_unref(G_OBJECT(drawable))
-
-proc gdk_rgb_get_cmap*(): PGdkColormap =
-  result = nil #gdk_rgb_get_colormap()
-
-proc GDK_TYPE_DISPLAY*(): GType =
-  nil
-  #result = nil
-
-proc GDK_DISPLAY_OBJECT*(anObject: pointer): PGdkDisplay =
-  result = cast[PGdkDisplay](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_DISPLAY()))
-
-proc GDK_DISPLAY_CLASS*(klass: pointer): PGdkDisplayClass =
-  result = cast[PGdkDisplayClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_DISPLAY()))
-
-proc GDK_IS_DISPLAY*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_DISPLAY())
-
-proc GDK_IS_DISPLAY_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_DISPLAY())
-
-proc GDK_DISPLAY_GET_CLASS*(obj: pointer): PGdkDisplayClass =
-  result = cast[PGdkDisplayClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_DISPLAY()))
-
-proc GDK_TYPE_SCREEN*(): GType =
-  nil
-
-proc GDK_SCREEN*(anObject: Pointer): PGdkScreen =
-  result = cast[PGdkScreen](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_SCREEN()))
-
-proc GDK_SCREEN_CLASS*(klass: Pointer): PGdkScreenClass =
-  result = cast[PGdkScreenClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_SCREEN()))
-
-proc GDK_IS_SCREEN*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_SCREEN())
-
-proc GDK_IS_SCREEN_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_SCREEN())
-
-proc GDK_SCREEN_GET_CLASS*(obj: Pointer): PGdkScreenClass =
-  result = cast[PGdkScreenClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_SCREEN()))
-
-proc GDK_SELECTION_PRIMARY*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(1)
-
-proc GDK_SELECTION_SECONDARY*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(2)
-
-proc GDK_SELECTION_CLIPBOARD*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(69)
-
-proc GDK_TARGET_BITMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(5)
-
-proc GDK_TARGET_COLORMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(7)
-
-proc GDK_TARGET_DRAWABLE*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(17)
-
-proc GDK_TARGET_PIXMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(20)
-
-proc GDK_TARGET_STRING*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(31)
-
-proc GDK_SELECTION_TYPE_ATOM*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(4)
-
-proc GDK_SELECTION_TYPE_BITMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(5)
-
-proc GDK_SELECTION_TYPE_COLORMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(7)
-
-proc GDK_SELECTION_TYPE_DRAWABLE*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(17)
-
-proc GDK_SELECTION_TYPE_INTEGER*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(19)
-
-proc GDK_SELECTION_TYPE_PIXMAP*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(20)
-
-proc GDK_SELECTION_TYPE_WINDOW*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(33)
-
-proc GDK_SELECTION_TYPE_STRING*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(31)
-
-proc GDK_ATOM_TO_POINTER*(atom: TGdkAtom): pointer =
-  result = cast[Pointer](atom)
-
-proc GDK_POINTER_TO_ATOM*(p: Pointer): TGdkAtom =
-  result = cast[TGdkAtom](p)
-
-proc `GDK_MAKE_ATOM`*(val: guint): TGdkAtom =
-  result = cast[TGdkAtom](val)
-
-proc GDK_NONE*(): TGdkAtom =
-  result = `GDK_MAKE_ATOM`(0)
-
-proc GDK_TYPE_VISUAL*(): GType =
-  result = gdk_visual_get_type()
-
-proc GDK_VISUAL*(anObject: Pointer): PGdkVisual =
-  result = cast[PGdkVisual](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_VISUAL()))
-
-proc GDK_VISUAL_CLASS*(klass: Pointer): PGdkVisualClass =
-  result = cast[PGdkVisualClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_VISUAL()))
-
-proc GDK_IS_VISUAL*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_VISUAL())
-
-proc GDK_IS_VISUAL_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_VISUAL())
-
-proc GDK_VISUAL_GET_CLASS*(obj: Pointer): PGdkVisualClass =
-  result = cast[PGdkVisualClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_VISUAL()))
-
-proc gdk_visual_ref*(v: PGdkVisual) =
-  discard g_object_ref(v)
-
-proc gdk_visual_unref*(v: PGdkVisual) =
-  g_object_unref(v)
-
-proc GDK_TYPE_WINDOW*(): GType =
-  result = gdk_window_object_get_type()
-
-proc GDK_WINDOW*(anObject: Pointer): PGdkWindow =
-  result = cast[PGdkWindow](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_WINDOW()))
-
-proc GDK_WINDOW_CLASS*(klass: Pointer): PGdkWindowObjectClass =
-  result = cast[PGdkWindowObjectClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_WINDOW()))
-
-proc GDK_IS_WINDOW*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_WINDOW())
-
-proc GDK_IS_WINDOW_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_WINDOW())
-
-proc GDK_WINDOW_GET_CLASS*(obj: Pointer): PGdkWindowObjectClass =
-  result = cast[PGdkWindowObjectClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_WINDOW()))
-
-proc GDK_WINDOW_OBJECT*(anObject: Pointer): PGdkWindowObject =
-  result = cast[PGdkWindowObject](GDK_WINDOW(anObject))
-
-proc GdkWindowObject_guffaw_gravity*(a: var TGdkWindowObject): guint =
-  result = (a.flag0 and bm_TGdkWindowObject_guffaw_gravity) shr
-      bp_TGdkWindowObject_guffaw_gravity
-
-proc GdkWindowObject_set_guffaw_gravity*(a: var TGdkWindowObject,
-    `guffaw_gravity`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`guffaw_gravity` shl bp_TGdkWindowObject_guffaw_gravity) and
-      bm_TGdkWindowObject_guffaw_gravity)
-
-proc GdkWindowObject_input_only*(a: var TGdkWindowObject): guint =
-  result = (a.flag0 and bm_TGdkWindowObject_input_only) shr
-      bp_TGdkWindowObject_input_only
-
-proc GdkWindowObject_set_input_only*(a: var TGdkWindowObject,
-                                     `input_only`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`input_only` shl bp_TGdkWindowObject_input_only) and
-      bm_TGdkWindowObject_input_only)
-
-proc GdkWindowObject_modal_hint*(a: var TGdkWindowObject): guint =
-  result = (a.flag0 and bm_TGdkWindowObject_modal_hint) shr
-      bp_TGdkWindowObject_modal_hint
-
-proc GdkWindowObject_set_modal_hint*(a: var TGdkWindowObject,
-                                     `modal_hint`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`modal_hint` shl bp_TGdkWindowObject_modal_hint) and
-      bm_TGdkWindowObject_modal_hint)
-
-proc GdkWindowObject_destroyed*(a: var TGdkWindowObject): guint =
-  result = (a.flag0 and bm_TGdkWindowObject_destroyed) shr
-      bp_TGdkWindowObject_destroyed
-
-proc GdkWindowObject_set_destroyed*(a: var TGdkWindowObject, `destroyed`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`destroyed` shl bp_TGdkWindowObject_destroyed) and
-      bm_TGdkWindowObject_destroyed)
-
-proc GDK_ROOT_PARENT*(): PGdkWindow =
-  result = gdk_get_default_root_window()
-
-proc gdk_window_get_size*(drawable: PGdkDrawable, width: Pgint, height: Pgint) =
-  gdk_drawable_get_size(drawable, width, height)
-
-proc gdk_window_get_type*(window: PGdkWindow): TGdkWindowType =
-  result = gdk_window_get_window_type(window)
-
-proc gdk_window_get_colormap*(drawable: PGdkDrawable): PGdkColormap =
-  result = gdk_drawable_get_colormap(drawable)
-
-proc gdk_window_set_colormap*(drawable: PGdkDrawable, colormap: PGdkColormap) =
-  gdk_drawable_set_colormap(drawable, colormap)
-
-proc gdk_window_get_visual*(drawable: PGdkDrawable): PGdkVisual =
-  result = gdk_drawable_get_visual(drawable)
-
-proc gdk_window_ref*(drawable: PGdkDrawable): PGdkDrawable =
-  result = GDK_DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc gdk_window_unref*(drawable: PGdkDrawable) =
-  g_object_unref(G_OBJECT(drawable))
-
-proc gdk_window_copy_area*(drawable: PGdkDrawable, gc: PGdkGC, x, y: gint,
-                           source_drawable: PGdkDrawable,
-                           source_x, source_y: gint, width, height: gint) =
-  gdk_draw_pixmap(drawable, gc, source_drawable, source_x, source_y, x, y,
-                  width, height)
diff --git a/lib/oldwrappers/gtk/gdk2pixbuf.nim b/lib/oldwrappers/gtk/gdk2pixbuf.nim
deleted file mode 100755
index daaa1479b..000000000
--- a/lib/oldwrappers/gtk/gdk2pixbuf.nim
+++ /dev/null
@@ -1,277 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2
-
-when defined(win32):
-  const
-    gdkpixbuflib = "libgdk_pixbuf-2.0-0.dll"
-elif defined(darwin):
-  const
-    gdkpixbuflib = "gdk_pixbuf-2.0.0"
-  # linklib gtk-x11-2.0
-  # linklib gdk-x11-2.0
-  # linklib pango-1.0.0
-  # linklib glib-2.0.0
-  # linklib gobject-2.0.0
-  # linklib gdk_pixbuf-2.0.0
-  # linklib atk-1.0.0
-else:
-  const
-    gdkpixbuflib = "libgdk_pixbuf-2.0.so"
-
-type
-  PGdkPixbuf* = pointer
-  PGdkPixbufAnimation* = pointer
-  PGdkPixbufAnimationIter* = pointer
-  PGdkPixbufAlphaMode* = ptr TGdkPixbufAlphaMode
-  TGdkPixbufAlphaMode* = enum
-    GDK_PIXBUF_ALPHA_BILEVEL, GDK_PIXBUF_ALPHA_FULL
-  PGdkColorspace* = ptr TGdkColorspace
-  TGdkColorspace* = enum
-    GDK_COLORSPACE_RGB
-  TGdkPixbufDestroyNotify* = proc (pixels: Pguchar, data: gpointer){.cdecl.}
-  PGdkPixbufError* = ptr TGdkPixbufError
-  TGdkPixbufError* = enum
-    GDK_PIXBUF_ERROR_CORRUPT_IMAGE, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-    GDK_PIXBUF_ERROR_BAD_OPTION, GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
-    GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION, GDK_PIXBUF_ERROR_FAILED
-  PGdkInterpType* = ptr TGdkInterpType
-  TGdkInterpType* = enum
-    GDK_INTERP_NEAREST, GDK_INTERP_TILES, GDK_INTERP_BILINEAR, GDK_INTERP_HYPER
-
-proc GDK_TYPE_PIXBUF*(): GType
-proc GDK_PIXBUF*(anObject: pointer): PGdkPixbuf
-proc GDK_IS_PIXBUF*(anObject: pointer): bool
-proc GDK_TYPE_PIXBUF_ANIMATION*(): GType
-proc GDK_PIXBUF_ANIMATION*(anObject: pointer): PGdkPixbufAnimation
-proc GDK_IS_PIXBUF_ANIMATION*(anObject: pointer): bool
-proc GDK_TYPE_PIXBUF_ANIMATION_ITER*(): GType
-proc GDK_PIXBUF_ANIMATION_ITER*(anObject: pointer): PGdkPixbufAnimationIter
-proc GDK_IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool
-proc GDK_PIXBUF_ERROR*(): TGQuark
-proc gdk_pixbuf_error_quark*(): TGQuark{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_error_quark".}
-proc gdk_pixbuf_get_type*(): GType{.cdecl, dynlib: gdkpixbuflib,
-                                    importc: "gdk_pixbuf_get_type".}
-when not defined(GDK_PIXBUF_DISABLE_DEPRECATED):
-  proc gdk_pixbuf_ref*(pixbuf: PGdkPixbuf): PGdkPixbuf{.cdecl,
-      dynlib: gdkpixbuflib, importc: "gdk_pixbuf_ref".}
-  proc gdk_pixbuf_unref*(pixbuf: PGdkPixbuf){.cdecl, dynlib: gdkpixbuflib,
-      importc: "gdk_pixbuf_unref".}
-proc gdk_pixbuf_get_colorspace*(pixbuf: PGdkPixbuf): TGdkColorspace{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_colorspace".}
-proc gdk_pixbuf_get_n_channels*(pixbuf: PGdkPixbuf): int32{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_n_channels".}
-proc gdk_pixbuf_get_has_alpha*(pixbuf: PGdkPixbuf): gboolean{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_has_alpha".}
-proc gdk_pixbuf_get_bits_per_sample*(pixbuf: PGdkPixbuf): int32{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_bits_per_sample".}
-proc gdk_pixbuf_get_pixels*(pixbuf: PGdkPixbuf): Pguchar{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_pixels".}
-proc gdk_pixbuf_get_width*(pixbuf: PGdkPixbuf): int32{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_width".}
-proc gdk_pixbuf_get_height*(pixbuf: PGdkPixbuf): int32{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_height".}
-proc gdk_pixbuf_get_rowstride*(pixbuf: PGdkPixbuf): int32{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_rowstride".}
-proc gdk_pixbuf_new*(colorspace: TGdkColorspace, has_alpha: gboolean,
-                     bits_per_sample: int32, width: int32, height: int32): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new".}
-proc gdk_pixbuf_copy*(pixbuf: PGdkPixbuf): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_copy".}
-proc gdk_pixbuf_new_subpixbuf*(src_pixbuf: PGdkPixbuf, src_x: int32,
-                               src_y: int32, width: int32, height: int32): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_subpixbuf".}
-proc gdk_pixbuf_new_from_file*(filename: cstring, error: pointer): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_file".}
-proc gdk_pixbuf_new_from_data*(data: Pguchar, colorspace: TGdkColorspace,
-                               has_alpha: gboolean, bits_per_sample: int32,
-                               width: int32, height: int32, rowstride: int32,
-                               destroy_fn: TGdkPixbufDestroyNotify,
-                               destroy_fn_data: gpointer): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_data".}
-proc gdk_pixbuf_new_from_xpm_data*(data: PPchar): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_xpm_data".}
-proc gdk_pixbuf_new_from_inline*(data_length: gint, a: var guint8,
-                                 copy_pixels: gboolean, error: pointer): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_inline".}
-proc gdk_pixbuf_new_from_file_at_size*(filename: cstring, width, height: gint,
-                                       error: pointer): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_file_at_size".}
-proc gdk_pixbuf_new_from_file_at_scale*(filename: cstring, width, height: gint,
-    preserve_aspect_ratio: gboolean, error: pointer): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_new_from_file_at_scale".}
-proc gdk_pixbuf_fill*(pixbuf: PGdkPixbuf, pixel: guint32){.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_fill".}
-proc gdk_pixbuf_save*(pixbuf: PGdkPixbuf, filename: cstring, `type`: cstring,
-                      error: pointer): gboolean{.cdecl, varargs,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_save".}
-proc gdk_pixbuf_savev*(pixbuf: PGdkPixbuf, filename: cstring, `type`: cstring,
-                       option_keys: PPchar, option_values: PPchar,
-                       error: pointer): gboolean{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_savev".}
-proc gdk_pixbuf_add_alpha*(pixbuf: PGdkPixbuf, substitute_color: gboolean,
-                           r: guchar, g: guchar, b: guchar): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_add_alpha".}
-proc gdk_pixbuf_copy_area*(src_pixbuf: PGdkPixbuf, src_x: int32, src_y: int32,
-                           width: int32, height: int32, dest_pixbuf: PGdkPixbuf,
-                           dest_x: int32, dest_y: int32){.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_copy_area".}
-proc gdk_pixbuf_saturate_and_pixelate*(src: PGdkPixbuf, dest: PGdkPixbuf,
-                                       saturation: gfloat, pixelate: gboolean){.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_saturate_and_pixelate".}
-proc gdk_pixbuf_scale*(src: PGdkPixbuf, dest: PGdkPixbuf, dest_x: int32,
-                       dest_y: int32, dest_width: int32, dest_height: int32,
-                       offset_x: float64, offset_y: float64, scale_x: float64,
-                       scale_y: float64, interp_type: TGdkInterpType){.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_scale".}
-proc gdk_pixbuf_composite*(src: PGdkPixbuf, dest: PGdkPixbuf, dest_x: int32,
-                           dest_y: int32, dest_width: int32, dest_height: int32,
-                           offset_x: float64, offset_y: float64,
-                           scale_x: float64, scale_y: float64,
-                           interp_type: TGdkInterpType, overall_alpha: int32){.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_composite".}
-proc gdk_pixbuf_composite_color*(src: PGdkPixbuf, dest: PGdkPixbuf,
-                                 dest_x: int32, dest_y: int32,
-                                 dest_width: int32, dest_height: int32,
-                                 offset_x: float64, offset_y: float64,
-                                 scale_x: float64, scale_y: float64,
-                                 interp_type: TGdkInterpType,
-                                 overall_alpha: int32, check_x: int32,
-                                 check_y: int32, check_size: int32,
-                                 color1: guint32, color2: guint32){.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_composite_color".}
-proc gdk_pixbuf_scale_simple*(src: PGdkPixbuf, dest_width: int32,
-                              dest_height: int32, interp_type: TGdkInterpType): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_scale_simple".}
-proc gdk_pixbuf_composite_color_simple*(src: PGdkPixbuf, dest_width: int32,
-                                        dest_height: int32,
-                                        interp_type: TGdkInterpType,
-                                        overall_alpha: int32, check_size: int32,
-                                        color1: guint32, color2: guint32): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_composite_color_simple".}
-proc gdk_pixbuf_animation_get_type*(): GType{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_animation_get_type".}
-proc gdk_pixbuf_animation_new_from_file*(filename: cstring, error: pointer): PGdkPixbufAnimation{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_new_from_file".}
-when not defined(GDK_PIXBUF_DISABLE_DEPRECATED):
-  proc gdk_pixbuf_animation_ref*(animation: PGdkPixbufAnimation): PGdkPixbufAnimation{.
-      cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_ref".}
-  proc gdk_pixbuf_animation_unref*(animation: PGdkPixbufAnimation){.cdecl,
-      dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_unref".}
-proc gdk_pixbuf_animation_get_width*(animation: PGdkPixbufAnimation): int32{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_get_width".}
-proc gdk_pixbuf_animation_get_height*(animation: PGdkPixbufAnimation): int32{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_get_height".}
-proc gdk_pixbuf_animation_is_static_image*(animation: PGdkPixbufAnimation): gboolean{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_is_static_image".}
-proc gdk_pixbuf_animation_get_static_image*(animation: PGdkPixbufAnimation): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_animation_get_static_image".}
-proc gdk_pixbuf_animation_get_iter*(animation: PGdkPixbufAnimation,
-                                    e: var TGTimeVal): PGdkPixbufAnimationIter{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_get_iter".}
-proc gdk_pixbuf_animation_iter_get_type*(): GType{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_animation_iter_get_type".}
-proc gdk_pixbuf_animation_iter_get_delay_time*(iter: PGdkPixbufAnimationIter): int32{.
-    cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_animation_iter_get_delay_time".}
-proc gdk_pixbuf_animation_iter_get_pixbuf*(iter: PGdkPixbufAnimationIter): PGdkPixbuf{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_iter_get_pixbuf".}
-proc gdk_pixbuf_animation_iter_on_currently_loading_frame*(
-    iter: PGdkPixbufAnimationIter): gboolean{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_animation_iter_on_currently_loading_frame".}
-proc gdk_pixbuf_animation_iter_advance*(iter: PGdkPixbufAnimationIter,
-                                        e: var TGTimeVal): gboolean{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_animation_iter_advance".}
-proc gdk_pixbuf_get_option*(pixbuf: PGdkPixbuf, key: cstring): cstring{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_get_option".}
-type
-  PGdkPixbufLoader* = ptr TGdkPixbufLoader
-  TGdkPixbufLoader* {.final, pure.} = object
-    parent_instance*: TGObject
-    priv*: gpointer
-
-  PGdkPixbufLoaderClass* = ptr TGdkPixbufLoaderClass
-  TGdkPixbufLoaderClass* {.final, pure.} = object
-    parent_class*: TGObjectClass
-    area_prepared*: proc (loader: PGdkPixbufLoader){.cdecl.}
-    area_updated*: proc (loader: PGdkPixbufLoader, x: int32, y: int32,
-                         width: int32, height: int32){.cdecl.}
-    closed*: proc (loader: PGdkPixbufLoader){.cdecl.}
-
-
-proc GDK_TYPE_PIXBUF_LOADER*(): GType
-proc GDK_PIXBUF_LOADER*(obj: pointer): PGdkPixbufLoader
-proc GDK_PIXBUF_LOADER_CLASS*(klass: pointer): PGdkPixbufLoaderClass
-proc GDK_IS_PIXBUF_LOADER*(obj: pointer): bool
-proc GDK_IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool
-proc GDK_PIXBUF_LOADER_GET_CLASS*(obj: pointer): PGdkPixbufLoaderClass
-proc gdk_pixbuf_loader_get_type*(): GType{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_loader_get_type".}
-proc gdk_pixbuf_loader_new*(): PGdkPixbufLoader{.cdecl, dynlib: gdkpixbuflib,
-    importc: "gdk_pixbuf_loader_new".}
-proc gdk_pixbuf_loader_new_with_type*(image_type: cstring, error: pointer): PGdkPixbufLoader{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_loader_new_with_type".}
-proc gdk_pixbuf_loader_write*(loader: PGdkPixbufLoader, buf: Pguchar,
-                              count: gsize, error: pointer): gboolean{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_loader_write".}
-proc gdk_pixbuf_loader_get_pixbuf*(loader: PGdkPixbufLoader): PGdkPixbuf{.cdecl,
-    dynlib: gdkpixbuflib, importc: "gdk_pixbuf_loader_get_pixbuf".}
-proc gdk_pixbuf_loader_get_animation*(loader: PGdkPixbufLoader): PGdkPixbufAnimation{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_loader_get_animation".}
-proc gdk_pixbuf_loader_close*(loader: PGdkPixbufLoader, error: pointer): gboolean{.
-    cdecl, dynlib: gdkpixbuflib, importc: "gdk_pixbuf_loader_close".}
-proc GDK_TYPE_PIXBUF_LOADER*(): GType =
-  result = gdk_pixbuf_loader_get_type()
-
-proc GDK_PIXBUF_LOADER*(obj: pointer): PGdkPixbufLoader =
-  result = cast[PGdkPixbufLoader](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GDK_TYPE_PIXBUF_LOADER()))
-
-proc GDK_PIXBUF_LOADER_CLASS*(klass: pointer): PGdkPixbufLoaderClass =
-  result = cast[PGdkPixbufLoaderClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GDK_TYPE_PIXBUF_LOADER()))
-
-proc GDK_IS_PIXBUF_LOADER*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GDK_TYPE_PIXBUF_LOADER())
-
-proc GDK_IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_PIXBUF_LOADER())
-
-proc GDK_PIXBUF_LOADER_GET_CLASS*(obj: pointer): PGdkPixbufLoaderClass =
-  result = cast[PGdkPixbufLoaderClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GDK_TYPE_PIXBUF_LOADER()))
-
-proc GDK_TYPE_PIXBUF*(): GType =
-  result = gdk_pixbuf_get_type()
-
-proc GDK_PIXBUF*(anObject: pointer): PGdkPixbuf =
-  result = cast[PGdkPixbuf](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_PIXBUF()))
-
-proc GDK_IS_PIXBUF*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_PIXBUF())
-
-proc GDK_TYPE_PIXBUF_ANIMATION*(): GType =
-  result = gdk_pixbuf_animation_get_type()
-
-proc GDK_PIXBUF_ANIMATION*(anObject: pointer): PGdkPixbufAnimation =
-  result = cast[PGdkPixbufAnimation](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GDK_TYPE_PIXBUF_ANIMATION()))
-
-proc GDK_IS_PIXBUF_ANIMATION*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_PIXBUF_ANIMATION())
-
-proc GDK_TYPE_PIXBUF_ANIMATION_ITER*(): GType =
-  result = gdk_pixbuf_animation_iter_get_type()
-
-proc GDK_PIXBUF_ANIMATION_ITER*(anObject: pointer): PGdkPixbufAnimationIter =
-  result = cast[PGdkPixbufAnimationIter](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-    GDK_TYPE_PIXBUF_ANIMATION_ITER()))
-
-proc GDK_IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_PIXBUF_ANIMATION_ITER())
-
-proc GDK_PIXBUF_ERROR*(): TGQuark =
-  result = gdk_pixbuf_error_quark()
diff --git a/lib/oldwrappers/gtk/gdkglext.nim b/lib/oldwrappers/gtk/gdkglext.nim
deleted file mode 100755
index 524b5f730..000000000
--- a/lib/oldwrappers/gtk/gdkglext.nim
+++ /dev/null
@@ -1,564 +0,0 @@
-{.deadCodeElim: on.}
-
-import 
-  Glib2, Gdk2
-
-when defined(WIN32): 
-  const 
-    GdkGLExtLib = "libgdkglext-win32-1.0-0.dll"
-else: 
-  const 
-    GdkGLExtLib = "libgdkglext-x11-1.0.so"
-type 
-  TGdkGLConfigAttrib* = int32
-  TGdkGLConfigCaveat* = int32
-  TGdkGLVisualType* = int32
-  TGdkGLTransparentType* = int32
-  TGdkGLDrawableTypeMask* = int32
-  TGdkGLRenderTypeMask* = int32
-  TGdkGLBufferMask* = int32
-  TGdkGLConfigError* = int32
-  TGdkGLRenderType* = int32
-  TGdkGLDrawableAttrib* = int32
-  TGdkGLPbufferAttrib* = int32
-  TGdkGLEventMask* = int32
-  TGdkGLEventType* = int32
-  TGdkGLDrawableType* = int32
-  TGdkGLProc* = Pointer
-  PGdkGLConfig* = ptr TGdkGLConfig
-  PGdkGLContext* = ptr TGdkGLContext
-  PGdkGLDrawable* = ptr TGdkGLDrawable
-  PGdkGLPixmap* = ptr TGdkGLPixmap
-  PGdkGLWindow* = ptr TGdkGLWindow
-  TGdkGLConfig* = object of TGObject
-    layer_plane*: gint
-    n_aux_buffers*: gint
-    n_sample_buffers*: gint
-    flag0*: int16
-
-  PGdkGLConfigClass* = ptr TGdkGLConfigClass
-  TGdkGLConfigClass* = object of TGObjectClass
-
-  TGdkGLContext* = object of TGObject
-
-  PGdkGLContextClass* = ptr TGdkGLContextClass
-  TGdkGLContextClass* = object of TGObjectClass
-
-  TGdkGLDrawable* = object of TGObject
-
-  PGdkGLDrawableClass* = ptr TGdkGLDrawableClass
-  TGdkGLDrawableClass* = object of TGTypeInterface
-    create_new_context*: proc (gldrawable: PGdkGLDrawable, 
-                               share_list: PGdkGLContext, direct: gboolean, 
-                               render_type: int32): PGdkGLContext{.cdecl.}
-    make_context_current*: proc (draw: PGdkGLDrawable, a_read: PGdkGLDrawable, 
-                                 glcontext: PGdkGLContext): gboolean{.cdecl.}
-    is_double_buffered*: proc (gldrawable: PGdkGLDrawable): gboolean{.cdecl.}
-    swap_buffers*: proc (gldrawable: PGdkGLDrawable){.cdecl.}
-    wait_gl*: proc (gldrawable: PGdkGLDrawable){.cdecl.}
-    wait_gdk*: proc (gldrawable: PGdkGLDrawable){.cdecl.}
-    gl_begin*: proc (draw: PGdkGLDrawable, a_read: PGdkGLDrawable, 
-                     glcontext: PGdkGLContext): gboolean{.cdecl.}
-    gl_end*: proc (gldrawable: PGdkGLDrawable){.cdecl.}
-    get_gl_config*: proc (gldrawable: PGdkGLDrawable): PGdkGLConfig{.cdecl.}
-    get_size*: proc (gldrawable: PGdkGLDrawable, width, height: PGInt){.cdecl.}
-
-  TGdkGLPixmap* = object of TGObject
-    drawable*: PGdkDrawable
-
-  PGdkGLPixmapClass* = ptr TGdkGLPixmapClass
-  TGdkGLPixmapClass* = object of TGObjectClass
-
-  TGdkGLWindow* = object of TGObject
-    drawable*: PGdkDrawable
-
-  PGdkGLWindowClass* = ptr TGdkGLWindowClass
-  TGdkGLWindowClass* = object of TGObjectClass
-
-
-const 
-  HEADER_GDKGLEXT_MAJOR_VERSION* = 1
-  HEADER_GDKGLEXT_MINOR_VERSION* = 0
-  HEADER_GDKGLEXT_MICRO_VERSION* = 6
-  HEADER_GDKGLEXT_INTERFACE_AGE* = 4
-  HEADER_GDKGLEXT_BINARY_AGE* = 6
-
-proc HEADER_GDKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool
-var 
-  gdkglext_major_version*{.importc, dynlib: GdkGLExtLib.}: guint
-  gdkglext_minor_version*{.importc, dynlib: GdkGLExtLib.}: guint
-  gdkglext_micro_version*{.importc, dynlib: GdkGLExtLib.}: guint
-  gdkglext_interface_age*{.importc, dynlib: GdkGLExtLib.}: guint
-  gdkglext_binary_age*{.importc, dynlib: GdkGLExtLib.}: guint
-
-const 
-  GDK_GL_SUCCESS* = 0
-  GDK_GL_ATTRIB_LIST_NONE* = 0
-  GDK_GL_USE_GL* = 1
-  GDK_GL_BUFFER_SIZE* = 2
-  GDK_GL_LEVEL* = 3
-  GDK_GL_RGBA* = 4
-  GDK_GL_DOUBLEBUFFER* = 5
-  GDK_GL_STEREO* = 6
-  GDK_GL_AUX_BUFFERS* = 7
-  GDK_GL_RED_SIZE* = 8
-  GDK_GL_GREEN_SIZE* = 9
-  GDK_GL_BLUE_SIZE* = 10
-  GDK_GL_ALPHA_SIZE* = 11
-  GDK_GL_DEPTH_SIZE* = 12
-  GDK_GL_STENCIL_SIZE* = 13
-  GDK_GL_ACCUM_RED_SIZE* = 14
-  GDK_GL_ACCUM_GREEN_SIZE* = 15
-  GDK_GL_ACCUM_BLUE_SIZE* = 16
-  GDK_GL_ACCUM_ALPHA_SIZE* = 17
-  GDK_GL_CONFIG_CAVEAT* = 0x00000020
-  GDK_GL_X_VISUAL_TYPE* = 0x00000022
-  GDK_GL_TRANSPARENT_TYPE* = 0x00000023
-  GDK_GL_TRANSPARENT_INDEX_VALUE* = 0x00000024
-  GDK_GL_TRANSPARENT_RED_VALUE* = 0x00000025
-  GDK_GL_TRANSPARENT_GREEN_VALUE* = 0x00000026
-  GDK_GL_TRANSPARENT_BLUE_VALUE* = 0x00000027
-  GDK_GL_TRANSPARENT_ALPHA_VALUE* = 0x00000028
-  GDK_GL_DRAWABLE_TYPE* = 0x00008010
-  GDK_GL_RENDER_TYPE* = 0x00008011
-  GDK_GL_X_RENDERABLE* = 0x00008012
-  GDK_GL_FBCONFIG_ID* = 0x00008013
-  GDK_GL_MAX_PBUFFER_WIDTH* = 0x00008016
-  GDK_GL_MAX_PBUFFER_HEIGHT* = 0x00008017
-  GDK_GL_MAX_PBUFFER_PIXELS* = 0x00008018
-  GDK_GL_VISUAL_ID* = 0x0000800B
-  GDK_GL_SCREEN* = 0x0000800C
-  GDK_GL_SAMPLE_BUFFERS* = 100000
-  GDK_GL_SAMPLES* = 100001
-  GDK_GL_DONT_CARE* = 0xFFFFFFFF
-  GDK_GL_NONE* = 0x00008000
-  GDK_GL_CONFIG_CAVEAT_DONT_CARE* = 0xFFFFFFFF
-  GDK_GL_CONFIG_CAVEAT_NONE* = 0x00008000
-  GDK_GL_SLOW_CONFIG* = 0x00008001
-  GDK_GL_NON_CONFORMANT_CONFIG* = 0x0000800D
-  GDK_GL_VISUAL_TYPE_DONT_CARE* = 0xFFFFFFFF
-  GDK_GL_TRUE_COLOR* = 0x00008002
-  GDK_GL_DIRECT_COLOR* = 0x00008003
-  GDK_GL_PSEUDO_COLOR* = 0x00008004
-  GDK_GL_STATIC_COLOR* = 0x00008005
-  GDK_GL_GRAY_SCALE* = 0x00008006
-  GDK_GL_STATIC_GRAY* = 0x00008007
-  GDK_GL_TRANSPARENT_NONE* = 0x00008000
-  GDK_GL_TRANSPARENT_RGB* = 0x00008008
-  GDK_GL_TRANSPARENT_INDEX* = 0x00008009
-  GDK_GL_WINDOW_BIT* = 1 shl 0
-  GDK_GL_PIXMAP_BIT* = 1 shl 1
-  GDK_GL_PBUFFER_BIT* = 1 shl 2
-  GDK_GL_RGBA_BIT* = 1 shl 0
-  GDK_GL_COLOR_INDEX_BIT* = 1 shl 1
-  GDK_GL_FRONT_LEFT_BUFFER_BIT* = 1 shl 0
-  GDK_GL_FRONT_RIGHT_BUFFER_BIT* = 1 shl 1
-  GDK_GL_BACK_LEFT_BUFFER_BIT* = 1 shl 2
-  GDK_GL_BACK_RIGHT_BUFFER_BIT* = 1 shl 3
-  GDK_GL_AUX_BUFFERS_BIT* = 1 shl 4
-  GDK_GL_DEPTH_BUFFER_BIT* = 1 shl 5
-  GDK_GL_STENCIL_BUFFER_BIT* = 1 shl 6
-  GDK_GL_ACCUM_BUFFER_BIT* = 1 shl 7
-  GDK_GL_BAD_SCREEN* = 1
-  GDK_GL_BAD_ATTRIBUTE* = 2
-  GDK_GL_NO_EXTENSION* = 3
-  GDK_GL_BAD_VISUAL* = 4
-  GDK_GL_BAD_CONTEXT* = 5
-  GDK_GL_BAD_VALUE* = 6
-  GDK_GL_BAD_ENUM* = 7
-  GDK_GL_RGBA_TYPE* = 0x00008014
-  GDK_GL_COLOR_INDEX_TYPE* = 0x00008015
-  GDK_GL_PRESERVED_CONTENTS* = 0x0000801B
-  GDK_GL_LARGEST_PBUFFER* = 0x0000801C
-  GDK_GL_WIDTH* = 0x0000801D
-  GDK_GL_HEIGHT* = 0x0000801E
-  GDK_GL_EVENT_MASK* = 0x0000801F
-  GDK_GL_PBUFFER_PRESERVED_CONTENTS* = 0x0000801B
-  GDK_GL_PBUFFER_LARGEST_PBUFFER* = 0x0000801C
-  GDK_GL_PBUFFER_HEIGHT* = 0x00008040
-  GDK_GL_PBUFFER_WIDTH* = 0x00008041
-  GDK_GL_PBUFFER_CLOBBER_MASK* = 1 shl 27
-  GDK_GL_DAMAGED* = 0x00008020
-  GDK_GL_SAVED* = 0x00008021
-  GDK_GL_WINDOW_VALUE* = 0x00008022
-  GDK_GL_PBUFFER* = 0x00008023
-
-proc gdk_gl_config_attrib_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_attrib_get_type".}
-proc GDK_TYPE_GL_CONFIG_ATTRIB*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_attrib_get_type".}
-proc gdk_gl_config_caveat_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_caveat_get_type".}
-proc GDK_TYPE_GL_CONFIG_CAVEAT*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_caveat_get_type".}
-proc gdk_gl_visual_type_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_visual_type_get_type".}
-proc GDK_TYPE_GL_VISUAL_TYPE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                        importc: "gdk_gl_visual_type_get_type".}
-proc gdk_gl_transparent_type_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_transparent_type_get_type".}
-proc GDK_TYPE_GL_TRANSPARENT_TYPE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_transparent_type_get_type".}
-proc gdk_gl_drawable_type_mask_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_type_mask_get_type".}
-proc GDK_TYPE_GL_DRAWABLE_TYPE_MASK*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_type_mask_get_type".}
-proc gdk_gl_render_type_mask_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_render_type_mask_get_type".}
-proc GDK_TYPE_GL_RENDER_TYPE_MASK*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_render_type_mask_get_type".}
-proc gdk_gl_buffer_mask_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_buffer_mask_get_type".}
-proc GDK_TYPE_GL_BUFFER_MASK*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                        importc: "gdk_gl_buffer_mask_get_type".}
-proc gdk_gl_config_error_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_error_get_type".}
-proc GDK_TYPE_GL_CONFIG_ERROR*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_error_get_type".}
-proc gdk_gl_render_type_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_render_type_get_type".}
-proc GDK_TYPE_GL_RENDER_TYPE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                        importc: "gdk_gl_render_type_get_type".}
-proc gdk_gl_drawable_attrib_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_attrib_get_type".}
-proc GDK_TYPE_GL_DRAWABLE_ATTRIB*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_attrib_get_type".}
-proc gdk_gl_pbuffer_attrib_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_pbuffer_attrib_get_type".}
-proc GDK_TYPE_GL_PBUFFER_ATTRIB*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_pbuffer_attrib_get_type".}
-proc gdk_gl_event_mask_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_event_mask_get_type".}
-proc GDK_TYPE_GL_EVENT_MASK*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                       importc: "gdk_gl_event_mask_get_type".}
-proc gdk_gl_event_type_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_event_type_get_type".}
-proc GDK_TYPE_GL_EVENT_TYPE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                       importc: "gdk_gl_event_type_get_type".}
-proc gdk_gl_drawable_type_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_type_get_type".}
-proc GDK_TYPE_GL_DRAWABLE_TYPE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_type_get_type".}
-proc gdk_gl_config_mode_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_config_mode_get_type".}
-proc GDK_TYPE_GL_CONFIG_MODE*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                        importc: "gdk_gl_config_mode_get_type".}
-proc gdk_gl_parse_args*(argc: var int32, argv: ptr cstringArray): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_parse_args".}
-proc gdk_gl_init_check*(argc: var int32, argv: ptr cstringArray): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_init_check".}
-proc gdk_gl_init*(argc: var int32, argv: ptr cstringArray){.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_init".}
-proc gdk_gl_query_gl_extension*(extension: cstring): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_query_gl_extension".}
-proc gdk_gl_get_proc_address*(proc_name: cstring): TGdkGLProc{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_get_proc_address".}
-const 
-  bm_TGdkGLConfig_is_rgba* = 1 shl 0
-  bp_TGdkGLConfig_is_rgba* = 0
-  bm_TGdkGLConfig_is_double_buffered* = 1 shl 1
-  bp_TGdkGLConfig_is_double_buffered* = 1
-  bm_TGdkGLConfig_as_single_mode* = 1 shl 2
-  bp_TGdkGLConfig_as_single_mode* = 2
-  bm_TGdkGLConfig_is_stereo* = 1 shl 3
-  bp_TGdkGLConfig_is_stereo* = 3
-  bm_TGdkGLConfig_has_alpha* = 1 shl 4
-  bp_TGdkGLConfig_has_alpha* = 4
-  bm_TGdkGLConfig_has_depth_buffer* = 1 shl 5
-  bp_TGdkGLConfig_has_depth_buffer* = 5
-  bm_TGdkGLConfig_has_stencil_buffer* = 1 shl 6
-  bp_TGdkGLConfig_has_stencil_buffer* = 6
-  bm_TGdkGLConfig_has_accum_buffer* = 1 shl 7
-  bp_TGdkGLConfig_has_accum_buffer* = 7
-
-const 
-  GDK_GL_MODE_RGB* = 0
-  GDK_GL_MODE_RGBA* = 0
-  GDK_GL_MODE_INDEX* = 1 shl 0
-  GDK_GL_MODE_SINGLE* = 0
-  GDK_GL_MODE_DOUBLE* = 1 shl 1
-  GDK_GL_MODE_STEREO* = 1 shl 2
-  GDK_GL_MODE_ALPHA* = 1 shl 3
-  GDK_GL_MODE_DEPTH* = 1 shl 4
-  GDK_GL_MODE_STENCIL* = 1 shl 5
-  GDK_GL_MODE_ACCUM* = 1 shl 6
-  GDK_GL_MODE_MULTISAMPLE* = 1 shl 7
-
-type 
-  TGdkGLConfigMode* = int32
-  PGdkGLConfigMode* = ptr TGdkGLConfigMode
-
-proc GDK_TYPE_GL_CONFIG*(): GType
-proc GDK_GL_CONFIG*(anObject: Pointer): PGdkGLConfig
-proc GDK_GL_CONFIG_CLASS*(klass: Pointer): PGdkGLConfigClass
-proc GDK_IS_GL_CONFIG*(anObject: Pointer): bool
-proc GDK_IS_GL_CONFIG_CLASS*(klass: Pointer): bool
-proc GDK_GL_CONFIG_GET_CLASS*(obj: Pointer): PGdkGLConfigClass
-proc gdk_gl_config_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                       importc: "gdk_gl_config_get_type".}
-proc gdk_gl_config_get_screen*(glconfig: PGdkGLConfig): PGdkScreen{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_screen".}
-proc gdk_gl_config_get_attrib*(glconfig: PGdkGLConfig, attribute: int, 
-                               value: var cint): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_attrib".}
-proc gdk_gl_config_get_colormap*(glconfig: PGdkGLConfig): PGdkColormap{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_colormap".}
-proc gdk_gl_config_get_visual*(glconfig: PGdkGLConfig): PGdkVisual{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_visual".}
-proc gdk_gl_config_get_depth*(glconfig: PGdkGLConfig): gint{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_depth".}
-proc gdk_gl_config_get_layer_plane*(glconfig: PGdkGLConfig): gint{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_layer_plane".}
-proc gdk_gl_config_get_n_aux_buffers*(glconfig: PGdkGLConfig): gint{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_n_aux_buffers".}
-proc gdk_gl_config_get_n_sample_buffers*(glconfig: PGdkGLConfig): gint{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_get_n_sample_buffers".}
-proc gdk_gl_config_is_rgba*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_is_rgba".}
-proc gdk_gl_config_is_double_buffered*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_is_double_buffered".}
-proc gdk_gl_config_is_stereo*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_is_stereo".}
-proc gdk_gl_config_has_alpha*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_has_alpha".}
-proc gdk_gl_config_has_depth_buffer*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_has_depth_buffer".}
-proc gdk_gl_config_has_stencil_buffer*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_has_stencil_buffer".}
-proc gdk_gl_config_has_accum_buffer*(glconfig: PGdkGLConfig): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_config_has_accum_buffer".}
-proc GDK_TYPE_GL_CONTEXT*(): GType
-proc GDK_GL_CONTEXT*(anObject: Pointer): PGdkGLContext
-proc GDK_GL_CONTEXT_CLASS*(klass: Pointer): PGdkGLContextClass
-proc GDK_IS_GL_CONTEXT*(anObject: Pointer): bool
-proc GDK_IS_GL_CONTEXT_CLASS*(klass: Pointer): bool
-proc GDK_GL_CONTEXT_GET_CLASS*(obj: Pointer): PGdkGLContextClass
-proc gdk_gl_context_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                        importc: "gdk_gl_context_get_type".}
-proc gdk_gl_context_new*(gldrawable: PGdkGLDrawable, share_list: PGdkGLContext, 
-                         direct: gboolean, render_type: int32): PGdkGLContext{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_context_new".}
-proc gdk_gl_context_destroy*(glcontext: PGdkGLContext){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_context_destroy".}
-proc gdk_gl_context_copy*(glcontext: PGdkGLContext, src: PGdkGLContext, 
-                          mask: int32): gboolean{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_context_copy".}
-proc gdk_gl_context_get_gl_drawable*(glcontext: PGdkGLContext): PGdkGLDrawable{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_context_get_gl_drawable".}
-proc gdk_gl_context_get_gl_config*(glcontext: PGdkGLContext): PGdkGLConfig{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_context_get_gl_config".}
-proc gdk_gl_context_get_share_list*(glcontext: PGdkGLContext): PGdkGLContext{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_context_get_share_list".}
-proc gdk_gl_context_is_direct*(glcontext: PGdkGLContext): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_context_is_direct".}
-proc gdk_gl_context_get_render_type*(glcontext: PGdkGLContext): int32{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_context_get_render_type".}
-proc gdk_gl_context_get_current*(): PGdkGLContext{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_context_get_current".}
-proc GDK_TYPE_GL_DRAWABLE*(): GType
-proc GDK_GL_DRAWABLE*(inst: Pointer): PGdkGLDrawable
-proc GDK_GL_DRAWABLE_CLASS*(vtable: Pointer): PGdkGLDrawableClass
-proc GDK_IS_GL_DRAWABLE*(inst: Pointer): bool
-proc GDK_IS_GL_DRAWABLE_CLASS*(vtable: Pointer): bool
-proc GDK_GL_DRAWABLE_GET_CLASS*(inst: Pointer): PGdkGLDrawableClass
-proc gdk_gl_drawable_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_get_type".}
-proc gdk_gl_drawable_make_current*(gldrawable: PGdkGLDrawable, 
-                                   glcontext: PGdkGLContext): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_make_current".}
-proc gdk_gl_drawable_is_double_buffered*(gldrawable: PGdkGLDrawable): gboolean{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_is_double_buffered".}
-proc gdk_gl_drawable_swap_buffers*(gldrawable: PGdkGLDrawable){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_swap_buffers".}
-proc gdk_gl_drawable_wait_gl*(gldrawable: PGdkGLDrawable){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_wait_gl".}
-proc gdk_gl_drawable_wait_gdk*(gldrawable: PGdkGLDrawable){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_wait_gdk".}
-proc gdk_gl_drawable_gl_begin*(gldrawable: PGdkGLDrawable, 
-                               glcontext: PGdkGLContext): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_gl_begin".}
-proc gdk_gl_drawable_gl_end*(gldrawable: PGdkGLDrawable){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_gl_end".}
-proc gdk_gl_drawable_get_gl_config*(gldrawable: PGdkGLDrawable): PGdkGLConfig{.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_get_gl_config".}
-proc gdk_gl_drawable_get_size*(gldrawable: PGdkGLDrawable, width, height: PGInt){.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_drawable_get_size".}
-proc gdk_gl_drawable_get_current*(): PGdkGLDrawable{.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_drawable_get_current".}
-proc GDK_TYPE_GL_PIXMAP*(): GType
-proc GDK_GL_PIXMAP*(anObject: Pointer): PGdkGLPixmap
-proc GDK_GL_PIXMAP_CLASS*(klass: Pointer): PGdkGLPixmapClass
-proc GDK_IS_GL_PIXMAP*(anObject: Pointer): bool
-proc GDK_IS_GL_PIXMAP_CLASS*(klass: Pointer): bool
-proc GDK_GL_PIXMAP_GET_CLASS*(obj: Pointer): PGdkGLPixmapClass
-proc gdk_gl_pixmap_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                       importc: "gdk_gl_pixmap_get_type".}
-proc gdk_gl_pixmap_new*(glconfig: PGdkGLConfig, pixmap: PGdkPixmap, 
-                        attrib_list: ptr int32): PGdkGLPixmap{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_pixmap_new".}
-proc gdk_gl_pixmap_destroy*(glpixmap: PGdkGLPixmap){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_pixmap_destroy".}
-proc gdk_gl_pixmap_get_pixmap*(glpixmap: PGdkGLPixmap): PGdkPixmap{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_pixmap_get_pixmap".}
-proc gdk_pixmap_set_gl_capability*(pixmap: PGdkPixmap, glconfig: PGdkGLConfig, 
-                                   attrib_list: ptr int32): PGdkGLPixmap{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_pixmap_set_gl_capability".}
-proc gdk_pixmap_unset_gl_capability*(pixmap: PGdkPixmap){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_pixmap_unset_gl_capability".}
-proc gdk_pixmap_is_gl_capable*(pixmap: PGdkPixmap): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_pixmap_is_gl_capable".}
-proc gdk_pixmap_get_gl_pixmap*(pixmap: PGdkPixmap): PGdkGLPixmap{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_pixmap_get_gl_pixmap".}
-proc gdk_pixmap_get_gl_drawable*(pixmap: PGdkPixmap): PGdkGLDrawable
-proc GDK_TYPE_GL_WINDOW*(): GType
-proc GDK_GL_WINDOW*(anObject: Pointer): PGdkGLWindow
-proc GDK_GL_WINDOW_CLASS*(klass: Pointer): PGdkGLWindowClass
-proc GDK_IS_GL_WINDOW*(anObject: Pointer): bool
-proc GDK_IS_GL_WINDOW_CLASS*(klass: Pointer): bool
-proc GDK_GL_WINDOW_GET_CLASS*(obj: Pointer): PGdkGLWindowClass
-proc gdk_gl_window_get_type*(): GType{.cdecl, dynlib: GdkGLExtLib, 
-                                       importc: "gdk_gl_window_get_type".}
-proc gdk_gl_window_new*(glconfig: PGdkGLConfig, window: PGdkWindow, 
-                        attrib_list: ptr int32): PGdkGLWindow{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_window_new".}
-proc gdk_gl_window_destroy*(glwindow: PGdkGLWindow){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_window_destroy".}
-proc gdk_gl_window_get_window*(glwindow: PGdkGLWindow): PGdkWindow{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_window_get_window".}
-proc gdk_window_set_gl_capability*(window: PGdkWindow, glconfig: PGdkGLConfig, 
-                                   attrib_list: ptr int32): PGdkGLWindow{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_window_set_gl_capability".}
-proc gdk_window_unset_gl_capability*(window: PGdkWindow){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_window_unset_gl_capability".}
-proc gdk_window_is_gl_capable*(window: PGdkWindow): gboolean{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_window_is_gl_capable".}
-proc gdk_window_get_gl_window*(window: PGdkWindow): PGdkGLWindow{.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_window_get_gl_window".}
-proc gdk_window_get_gl_drawable*(window: PGdkWindow): PGdkGLDrawable
-proc gdk_gl_draw_cube*(solid: gboolean, size: float64){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_draw_cube".}
-proc gdk_gl_draw_sphere*(solid: gboolean, radius: float64, slices: int32, 
-                         stacks: int32){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_draw_sphere".}
-proc gdk_gl_draw_cone*(solid: gboolean, base: float64, height: float64, 
-                       slices: int32, stacks: int32){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_draw_cone".}
-proc gdk_gl_draw_torus*(solid: gboolean, inner_radius: float64, 
-                        outer_radius: float64, nsides: int32, rings: int32){.
-    cdecl, dynlib: GdkGLExtLib, importc: "gdk_gl_draw_torus".}
-proc gdk_gl_draw_tetrahedron*(solid: gboolean){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_draw_tetrahedron".}
-proc gdk_gl_draw_octahedron*(solid: gboolean){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_draw_octahedron".}
-proc gdk_gl_draw_dodecahedron*(solid: gboolean){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_draw_dodecahedron".}
-proc gdk_gl_draw_icosahedron*(solid: gboolean){.cdecl, dynlib: GdkGLExtLib, 
-    importc: "gdk_gl_draw_icosahedron".}
-proc gdk_gl_draw_teapot*(solid: gboolean, scale: float64){.cdecl, 
-    dynlib: GdkGLExtLib, importc: "gdk_gl_draw_teapot".}
-proc HEADER_GDKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool = 
-  result = (HEADER_GDKGLEXT_MAJOR_VERSION > major) or
-      ((HEADER_GDKGLEXT_MAJOR_VERSION == major) and
-      (HEADER_GDKGLEXT_MINOR_VERSION > minor)) or
-      ((HEADER_GDKGLEXT_MAJOR_VERSION == major) and
-      (HEADER_GDKGLEXT_MINOR_VERSION == minor) and
-      (HEADER_GDKGLEXT_MICRO_VERSION >= micro))
-
-proc GDK_TYPE_GL_CONFIG*(): GType = 
-  result = gdk_gl_config_get_type()
-
-proc GDK_GL_CONFIG*(anObject: Pointer): PGdkGLConfig = 
-  result = cast[PGdkGLConfig](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_GL_CONFIG()))
-
-proc GDK_GL_CONFIG_CLASS*(klass: Pointer): PGdkGLConfigClass = 
-  result = cast[PGdkGLConfigClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_GL_CONFIG()))
-
-proc GDK_IS_GL_CONFIG*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_GL_CONFIG())
-
-proc GDK_IS_GL_CONFIG_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_GL_CONFIG())
-
-proc GDK_GL_CONFIG_GET_CLASS*(obj: Pointer): PGdkGLConfigClass = 
-  result = cast[PGdkGLConfigClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_GL_CONFIG()))
-
-proc GDK_TYPE_GL_CONTEXT*(): GType = 
-  result = gdk_gl_context_get_type()
-
-proc GDK_GL_CONTEXT*(anObject: Pointer): PGdkGLContext = 
-  result = cast[PGdkGLContext](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      GDK_TYPE_GL_CONTEXT()))
-
-proc GDK_GL_CONTEXT_CLASS*(klass: Pointer): PGdkGLContextClass = 
-  result = cast[PGdkGLContextClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_GL_CONTEXT()))
-
-proc GDK_IS_GL_CONTEXT*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_GL_CONTEXT())
-
-proc GDK_IS_GL_CONTEXT_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_GL_CONTEXT())
-
-proc GDK_GL_CONTEXT_GET_CLASS*(obj: Pointer): PGdkGLContextClass = 
-  result = cast[PGdkGLContextClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_GL_CONTEXT()))
-
-proc GDK_TYPE_GL_DRAWABLE*(): GType = 
-  result = gdk_gl_drawable_get_type()
-
-proc GDK_GL_DRAWABLE*(inst: Pointer): PGdkGLDrawable = 
-  result = cast[PGdkGLDrawable](G_TYPE_CHECK_INSTANCE_CAST(inst, GDK_TYPE_GL_DRAWABLE()))
-
-proc GDK_GL_DRAWABLE_CLASS*(vtable: Pointer): PGdkGLDrawableClass = 
-  result = cast[PGdkGLDrawableClass](G_TYPE_CHECK_CLASS_CAST(vtable, 
-      GDK_TYPE_GL_DRAWABLE()))
-
-proc GDK_IS_GL_DRAWABLE*(inst: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(inst, GDK_TYPE_GL_DRAWABLE())
-
-proc GDK_IS_GL_DRAWABLE_CLASS*(vtable: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(vtable, GDK_TYPE_GL_DRAWABLE())
-
-proc GDK_GL_DRAWABLE_GET_CLASS*(inst: Pointer): PGdkGLDrawableClass = 
-  result = cast[PGdkGLDrawableClass](G_TYPE_INSTANCE_GET_INTERFACE(inst, 
-      GDK_TYPE_GL_DRAWABLE()))
-
-proc GDK_TYPE_GL_PIXMAP*(): GType = 
-  result = gdk_gl_pixmap_get_type()
-
-proc GDK_GL_PIXMAP*(anObject: Pointer): PGdkGLPixmap = 
-  result = cast[PGdkGLPixmap](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_GL_PIXMAP()))
-
-proc GDK_GL_PIXMAP_CLASS*(klass: Pointer): PGdkGLPixmapClass = 
-  result = cast[PGdkGLPixmapClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_GL_PIXMAP()))
-
-proc GDK_IS_GL_PIXMAP*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_GL_PIXMAP())
-
-proc GDK_IS_GL_PIXMAP_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_GL_PIXMAP())
-
-proc GDK_GL_PIXMAP_GET_CLASS*(obj: Pointer): PGdkGLPixmapClass = 
-  result = cast[PGdkGLPixmapClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_GL_PIXMAP()))
-
-proc gdk_pixmap_get_gl_drawable*(pixmap: PGdkPixmap): PGdkGLDrawable = 
-  result = GDK_GL_DRAWABLE(gdk_pixmap_get_gl_pixmap(pixmap))
-
-proc GDK_TYPE_GL_WINDOW*(): GType = 
-  result = gdk_gl_window_get_type()
-
-proc GDK_GL_WINDOW*(anObject: Pointer): PGdkGLWindow = 
-  result = cast[PGdkGLWindow](G_TYPE_CHECK_INSTANCE_CAST(anObject, GDK_TYPE_GL_WINDOW()))
-
-proc GDK_GL_WINDOW_CLASS*(klass: Pointer): PGdkGLWindowClass = 
-  result = cast[PGdkGLWindowClass](G_TYPE_CHECK_CLASS_CAST(klass, GDK_TYPE_GL_WINDOW()))
-
-proc GDK_IS_GL_WINDOW*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GDK_TYPE_GL_WINDOW())
-
-proc GDK_IS_GL_WINDOW_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GDK_TYPE_GL_WINDOW())
-
-proc GDK_GL_WINDOW_GET_CLASS*(obj: Pointer): PGdkGLWindowClass = 
-  result = cast[PGdkGLWindowClass](G_TYPE_INSTANCE_GET_CLASS(obj, GDK_TYPE_GL_WINDOW()))
-
-proc gdk_window_get_gl_drawable*(window: PGdkWindow): PGdkGLDrawable = 
-  result = GDK_GL_DRAWABLE(gdk_window_get_gl_window(window))
diff --git a/lib/oldwrappers/gtk/glib2.nim b/lib/oldwrappers/gtk/glib2.nim
deleted file mode 100755
index 3f33501e8..000000000
--- a/lib/oldwrappers/gtk/glib2.nim
+++ /dev/null
@@ -1,4503 +0,0 @@
-{.deadCodeElim: on.}
-
-when defined(windows):
-  const
-    gliblib = "libglib-2.0-0.dll"
-    gmodulelib = "libgmodule-2.0-0.dll"
-    gobjectlib = "libgobject-2.0-0.dll"
-else:
-  const
-    gliblib = "libglib-2.0.so"
-    gmodulelib = "libgmodule-2.0.so"
-    gobjectlib = "libgobject-2.0.so"
-    
-# gthreadlib = "libgthread-2.0.so"
-
-type
-  PGTypePlugin* = pointer
-  PGParamSpecPool* = pointer
-  PPchar* = ptr cstring
-  PPPchar* = ptr PPchar
-  PPPgchar* = ptr PPgchar
-  PPgchar* = ptr cstring
-  gchar* = char
-  gshort* = cshort
-  glong* = clong
-  gint* = cint
-  gboolean* = bool
-  guchar* = char
-  gushort* = int16
-  gulong* = int
-  guint* = cint
-  gfloat* = cfloat
-  gdouble* = cdouble
-  gpointer* = pointer
-  Pgshort* = ptr gshort
-  Pglong* = ptr glong
-  Pgint* = ptr gint
-  PPgint* = ptr Pgint
-  Pgboolean* = ptr gboolean
-  Pguchar* = ptr guchar
-  PPguchar* = ptr Pguchar
-  Pgushort* = ptr gushort
-  Pgulong* = ptr gulong
-  Pguint* = ptr guint
-  Pgfloat* = ptr gfloat
-  Pgdouble* = ptr gdouble
-  pgpointer* = ptr gpointer
-  gconstpointer* = pointer
-  PGCompareFunc* = ptr TGCompareFunc
-  TGCompareFunc* = proc (a, b: gconstpointer): gint{.cdecl.}
-  PGCompareDataFunc* = ptr TGCompareDataFunc
-  TGCompareDataFunc* = proc (a, b: gconstpointer, user_data: gpointer): gint{.
-      cdecl.}
-  PGEqualFunc* = ptr TGEqualFunc
-  TGEqualFunc* = proc (a, b: gconstpointer): gboolean{.cdecl.}
-  PGDestroyNotify* = ptr TGDestroyNotify
-  TGDestroyNotify* = proc (data: gpointer){.cdecl.}
-  PGFunc* = ptr TGFunc
-  TGFunc* = proc (data, userdata: gpointer, key: gconstpointer){.cdecl.}
-  PGHashFunc* = ptr TGHashFunc
-  TGHashFunc* = proc (key: gconstpointer): guint{.cdecl.}
-  PGHFunc* = ptr TGHFunc
-  TGHFunc* = proc (key, value, user_data: gpointer){.cdecl.}
-  PGFreeFunc* = proc (data: gpointer){.cdecl.}
-  PGTimeVal* = ptr TGTimeVal
-  TGTimeVal* {.final.} = object
-    tv_sec*: glong
-    tv_usec*: glong
-
-  guint64* = int64
-  gint8* = int8
-  guint8* = int8
-  gint16* = int16
-  guint16* = int16
-  gint32* = int32
-  guint32* = int32
-  gint64* = int64
-  gssize* = int32
-  gsize* = int32
-  Pgint8* = ptr gint8
-  Pguint8* = ptr guint8
-  Pgint16* = ptr gint16
-  Pguint16* = ptr guint16
-  Pgint32* = ptr gint32
-  Pguint32* = ptr guint32
-  Pgint64* = ptr gint64
-  Pguint64* = ptr guint64
-  pgssize* = ptr gssize
-  pgsize* = ptr gsize
-  TGQuark* = guint32
-  PGQuark* = ptr TGQuark
-  PGTypeCValue* = ptr TGTypeCValue
-  TGTypeCValue* {.final.} = object
-    v_double*: gdouble
-
-  GType* = gulong
-  PGType* = ptr GType
-  PGTypeClass* = ptr TGTypeClass
-  TGTypeClass* {.final.} = object
-    g_type*: GType
-
-  PGTypeInstance* = ptr TGTypeInstance
-  TGTypeInstance* {.final.} = object
-    g_class*: PGTypeClass
-
-  PGTypeInterface* = ptr TGTypeInterface
-  TGTypeInterface* {.pure.} = object
-    g_type*: GType
-    g_instance_type*: GType
-
-  PGTypeQuery* = ptr TGTypeQuery
-  TGTypeQuery* {.final.} = object
-    theType*: GType
-    type_name*: cstring
-    class_size*: guint
-    instance_size*: guint
-
-  PGValue* = ptr TGValue
-  TGValue* {.final.} = object
-    g_type*: GType
-    data*: array[0..1, gdouble]
-
-  PGData* = pointer
-  PPGData* = ptr PGData
-  PGSList* = ptr TGSList
-  PPGSList* = ptr PGSList
-  TGSList* {.final.} = object
-    data*: gpointer
-    next*: PGSList
-
-  PGList* = ptr TGList
-  TGList* {.final.} = object
-    data*: gpointer
-    next*: PGList
-    prev*: PGList
-
-  TGParamFlags* = int32
-  PGParamFlags* = ptr TGParamFlags
-  PGParamSpec* = ptr TGParamSpec
-  PPGParamSpec* = ptr PGParamSpec
-  TGParamSpec* {.final.} = object
-    g_type_instance*: TGTypeInstance
-    name*: cstring
-    flags*: TGParamFlags
-    value_type*: GType
-    owner_type*: GType
-    nick*: cstring
-    blurb*: cstring
-    qdata*: PGData
-    ref_count*: guint
-    param_id*: guint
-
-  PGParamSpecClass* = ptr TGParamSpecClass
-  TGParamSpecClass* {.final.} = object
-    g_type_class*: TGTypeClass
-    value_type*: GType
-    finalize*: proc (pspec: PGParamSpec){.cdecl.}
-    value_set_default*: proc (pspec: PGParamSpec, value: PGValue){.cdecl.}
-    value_validate*: proc (pspec: PGParamSpec, value: PGValue): gboolean{.cdecl.}
-    values_cmp*: proc (pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-        cdecl.}
-    dummy*: array[0..3, gpointer]
-
-  PGParameter* = ptr TGParameter
-  TGParameter* {.final.} = object
-    name*: cstring
-    value*: TGValue
-
-  TGBoxedCopyFunc* = proc (boxed: gpointer): gpointer{.cdecl.}
-  TGBoxedFreeFunc* = proc (boxed: gpointer){.cdecl.}
-
-  PGsource = pointer # I don't know and don't care
-
-const
-  G_TYPE_FUNDAMENTAL_SHIFT* = 2
-  G_TYPE_FUNDAMENTAL_MAX* = 255 shl G_TYPE_FUNDAMENTAL_SHIFT
-  G_TYPE_INVALID* = GType(0 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_NONE* = GType(1 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INTERFACE* = GType(2 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_CHAR* = GType(3 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UCHAR* = GType(4 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_BOOLEAN* = GType(5 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INT* = GType(6 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UINT* = GType(7 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_LONG* = GType(8 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_ULONG* = GType(9 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INT64* = GType(10 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UINT64* = GType(11 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_ENUM* = GType(12 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_FLAGS* = GType(13 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_FLOAT* = GType(14 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_DOUBLE* = GType(15 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_STRING* = GType(16 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_POINTER* = GType(17 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_BOXED* = GType(18 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_PARAM* = GType(19 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_OBJECT* = GType(20 shl G_TYPE_FUNDAMENTAL_SHIFT)
-
-proc G_TYPE_MAKE_FUNDAMENTAL*(x: int): GType
-const
-  G_TYPE_RESERVED_GLIB_FIRST* = 21
-  G_TYPE_RESERVED_GLIB_LAST* = 31
-  G_TYPE_RESERVED_BSE_FIRST* = 32
-  G_TYPE_RESERVED_BSE_LAST* = 48
-  G_TYPE_RESERVED_USER_FIRST* = 49
-
-proc G_TYPE_IS_FUNDAMENTAL*(theType: GType): bool
-proc G_TYPE_IS_DERIVED*(theType: GType): bool
-proc G_TYPE_IS_INTERFACE*(theType: GType): bool
-proc G_TYPE_IS_CLASSED*(theType: GType): gboolean
-proc G_TYPE_IS_INSTANTIATABLE*(theType: GType): bool
-proc G_TYPE_IS_DERIVABLE*(theType: GType): bool
-proc G_TYPE_IS_DEEP_DERIVABLE*(theType: GType): bool
-proc G_TYPE_IS_ABSTRACT*(theType: GType): bool
-proc G_TYPE_IS_VALUE_ABSTRACT*(theType: GType): bool
-proc G_TYPE_IS_VALUE_TYPE*(theType: GType): bool
-proc G_TYPE_HAS_VALUE_TABLE*(theType: GType): bool
-proc G_TYPE_CHECK_INSTANCE*(instance: Pointer): gboolean
-proc G_TYPE_CHECK_INSTANCE_CAST*(instance: Pointer, g_type: GType): PGTypeInstance
-proc G_TYPE_CHECK_INSTANCE_TYPE*(instance: Pointer, g_type: GType): bool
-proc G_TYPE_INSTANCE_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass
-proc G_TYPE_INSTANCE_GET_INTERFACE*(instance: Pointer, g_type: GType): Pointer
-proc G_TYPE_CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer
-proc G_TYPE_CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool
-proc G_TYPE_CHECK_VALUE*(value: Pointer): bool
-proc G_TYPE_CHECK_VALUE_TYPE*(value: pointer, g_type: GType): bool
-proc G_TYPE_FROM_INSTANCE*(instance: Pointer): GType
-proc G_TYPE_FROM_CLASS*(g_class: Pointer): GType
-proc G_TYPE_FROM_INTERFACE*(g_iface: Pointer): GType
-type
-  TGTypeDebugFlags* = int32
-  PGTypeDebugFlags* = ptr TGTypeDebugFlags
-
-const
-  G_TYPE_DEBUG_NONE* = 0
-  G_TYPE_DEBUG_OBJECTS* = 1 shl 0
-  G_TYPE_DEBUG_SIGNALS* = 1 shl 1
-  G_TYPE_DEBUG_MASK* = 0x00000003
-
-proc g_type_init*(){.cdecl, dynlib: gobjectlib, importc: "g_type_init".}
-proc g_type_init_with_debug_flags*(debug_flags: TGTypeDebugFlags){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_init_with_debug_flags".}
-proc g_type_name*(theType: GType): cstring{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_name".}
-proc g_type_qname*(theType: GType): TGQuark{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_qname".}
-proc g_type_from_name*(name: cstring): GType{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_from_name".}
-proc g_type_parent*(theType: GType): GType{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_parent".}
-proc g_type_depth*(theType: GType): guint{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_depth".}
-proc g_type_next_base*(leaf_type: GType, root_type: GType): GType{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_next_base".}
-proc g_type_is_a*(theType: GType, is_a_type: GType): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_is_a".}
-proc g_type_class_ref*(theType: GType): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_class_ref".}
-proc g_type_class_peek*(theType: GType): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_class_peek".}
-proc g_type_class_unref*(g_class: gpointer){.cdecl, dynlib: gobjectlib,
-    importc: "g_type_class_unref".}
-proc g_type_class_peek_parent*(g_class: gpointer): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_class_peek_parent".}
-proc g_type_interface_peek*(instance_class: gpointer, iface_type: GType): gpointer{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_interface_peek".}
-proc g_type_interface_peek_parent*(g_iface: gpointer): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_interface_peek_parent".}
-proc g_type_children*(theType: GType, n_children: Pguint): PGType{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_children".}
-proc g_type_interfaces*(theType: GType, n_interfaces: Pguint): PGType{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_interfaces".}
-proc g_type_set_qdata*(theType: GType, quark: TGQuark, data: gpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_set_qdata".}
-proc g_type_get_qdata*(theType: GType, quark: TGQuark): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_get_qdata".}
-proc g_type_query*(theType: GType, query: PGTypeQuery){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_query".}
-type
-  TGBaseInitFunc* = proc (g_class: gpointer){.cdecl.}
-  TGBaseFinalizeFunc* = proc (g_class: gpointer){.cdecl.}
-  TGClassInitFunc* = proc (g_class: gpointer, class_data: gpointer){.cdecl.}
-  TGClassFinalizeFunc* = proc (g_class: gpointer, class_data: gpointer){.cdecl.}
-  TGInstanceInitFunc* = proc (instance: PGTypeInstance, g_class: gpointer){.
-      cdecl.}
-  TGInterfaceInitFunc* = proc (g_iface: gpointer, iface_data: gpointer){.cdecl.}
-  TGInterfaceFinalizeFunc* = proc (g_iface: gpointer, iface_data: gpointer){.
-      cdecl.}
-  TGTypeClassCacheFunc* = proc (cache_data: gpointer, g_class: PGTypeClass): gboolean{.
-      cdecl.}
-  TGTypeFundamentalFlags* = int32
-  PGTypeFundamentalFlags* = ptr TGTypeFundamentalFlags
-
-const
-  G_TYPE_FLAG_CLASSED* = 1 shl 0
-  G_TYPE_FLAG_INSTANTIATABLE* = 1 shl 1
-  G_TYPE_FLAG_DERIVABLE* = 1 shl 2
-  G_TYPE_FLAG_DEEP_DERIVABLE* = 1 shl 3
-
-type
-  TGTypeFlags* = int32
-  PGTypeFlags* = ptr TGTypeFlags
-
-const
-  G_TYPE_FLAG_ABSTRACT* = 1 shl 4
-  G_TYPE_FLAG_VALUE_ABSTRACT* = 1 shl 5
-
-type
-  PGTypeValueTable* = ptr TGTypeValueTable
-  TGTypeValueTable* {.final.} = object
-    value_init*: proc (value: PGValue){.cdecl.}
-    value_free*: proc (value: PGValue){.cdecl.}
-    value_copy*: proc (src_value: PGValue, dest_value: PGValue){.cdecl.}
-    value_peek_pointer*: proc (value: PGValue): gpointer{.cdecl.}
-    collect_format*: cstring
-    collect_value*: proc (value: PGValue, n_collect_values: guint,
-                          collect_values: PGTypeCValue, collect_flags: guint): cstring{.
-        cdecl.}
-    lcopy_format*: cstring
-    lcopy_value*: proc (value: PGValue, n_collect_values: guint,
-                        collect_values: PGTypeCValue, collect_flags: guint): cstring{.
-        cdecl.}
-
-  PGTypeInfo* = ptr TGTypeInfo
-  TGTypeInfo* {.final.} = object
-    class_size*: guint16
-    base_init*: TGBaseInitFunc
-    base_finalize*: TGBaseFinalizeFunc
-    class_init*: TGClassInitFunc
-    class_finalize*: TGClassFinalizeFunc
-    class_data*: gconstpointer
-    instance_size*: guint16
-    n_preallocs*: guint16
-    instance_init*: TGInstanceInitFunc
-    value_table*: PGTypeValueTable
-
-  PGTypeFundamentalInfo* = ptr TGTypeFundamentalInfo
-  TGTypeFundamentalInfo* {.final.} = object
-    type_flags*: TGTypeFundamentalFlags
-
-  PGInterfaceInfo* = ptr TGInterfaceInfo
-  TGInterfaceInfo* {.final.} = object
-    interface_init*: TGInterfaceInitFunc
-    interface_finalize*: TGInterfaceFinalizeFunc
-    interface_data*: gpointer
-
-
-proc g_type_register_static*(parent_type: GType, type_name: cstring,
-                             info: PGTypeInfo, flags: TGTypeFlags): GType{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_register_static".}
-proc g_type_register_dynamic*(parent_type: GType, type_name: cstring,
-                              plugin: PGTypePlugin, flags: TGTypeFlags): GType{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_register_dynamic".}
-proc g_type_register_fundamental*(type_id: GType, type_name: cstring,
-                                  info: PGTypeInfo,
-                                  finfo: PGTypeFundamentalInfo,
-                                  flags: TGTypeFlags): GType{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_register_fundamental".}
-proc g_type_add_interface_static*(instance_type: GType, interface_type: GType,
-                                  info: PGInterfaceInfo){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_add_interface_static".}
-proc g_type_add_interface_dynamic*(instance_type: GType, interface_type: GType,
-                                   plugin: PGTypePlugin){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_add_interface_dynamic".}
-proc g_type_interface_add_prerequisite*(interface_type: GType,
-                                        prerequisite_type: GType){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_interface_add_prerequisite".}
-proc g_type_get_plugin*(theType: GType): PGTypePlugin{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_get_plugin".}
-proc g_type_interface_get_plugin*(instance_type: GType,
-                                  implementation_type: GType): PGTypePlugin{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_interface_get_plugin".}
-proc g_type_fundamental_next*(): GType{.cdecl, dynlib: gobjectlib,
-                                        importc: "g_type_fundamental_next".}
-proc g_type_fundamental*(type_id: GType): GType{.cdecl, dynlib: gobjectlib,
-    importc: "g_type_fundamental".}
-proc g_type_create_instance*(theType: GType): PGTypeInstance{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_create_instance".}
-proc g_type_free_instance*(instance: PGTypeInstance){.cdecl, dynlib: gobjectlib,
-    importc: "g_type_free_instance".}
-proc g_type_add_class_cache_func*(cache_data: gpointer,
-                                  cache_func: TGTypeClassCacheFunc){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_add_class_cache_func".}
-proc g_type_remove_class_cache_func*(cache_data: gpointer,
-                                     cache_func: TGTypeClassCacheFunc){.cdecl,
-    dynlib: gobjectlib, importc: "g_type_remove_class_cache_func".}
-proc g_type_class_unref_uncached*(g_class: gpointer){.cdecl, dynlib: gobjectlib,
-    importc: "g_type_class_unref_uncached".}
-proc g_type_value_table_peek*(theType: GType): PGTypeValueTable{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_value_table_peek".}
-proc private_g_type_check_instance*(instance: PGTypeInstance): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_check_instance".}
-proc private_g_type_check_instance_cast*(instance: PGTypeInstance,
-    iface_type: GType): PGTypeInstance{.cdecl, dynlib: gobjectlib,
-                                        importc: "g_type_check_instance_cast".}
-proc private_g_type_check_instance_is_a*(instance: PGTypeInstance,
-    iface_type: GType): gboolean{.cdecl, dynlib: gobjectlib,
-                                  importc: "g_type_check_instance_is_a".}
-proc private_g_type_check_class_cast*(g_class: PGTypeClass, is_a_type: GType): PGTypeClass{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_class_cast".}
-proc private_g_type_check_class_is_a*(g_class: PGTypeClass, is_a_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_class_is_a".}
-proc private_g_type_check_is_value_type*(theType: GType): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_check_is_value_type".}
-proc private_g_type_check_value*(value: PGValue): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_check_value".}
-proc private_g_type_check_value_holds*(value: PGValue, theType: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_value_holds".}
-proc private_g_type_test_flags*(theType: GType, flags: guint): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_test_flags".}
-proc g_type_name_from_instance*(instance: PGTypeInstance): cstring{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_name_from_instance".}
-proc g_type_name_from_class*(g_class: PGTypeClass): cstring{.cdecl,
-    dynlib: gobjectlib, importc: "g_type_name_from_class".}
-const
-  G_TYPE_FLAG_RESERVED_ID_BIT* = GType(1 shl 0)
-
-proc G_TYPE_IS_VALUE*(theType: GType): bool
-proc G_IS_VALUE*(value: pointer): bool
-proc G_VALUE_TYPE*(value: Pointer): GType
-proc G_VALUE_TYPE_NAME*(value: Pointer): cstring
-proc G_VALUE_HOLDS*(value: pointer, g_type: GType): bool
-type
-  TGValueTransform* = proc (src_value: PGValue, dest_value: PGValue){.cdecl.}
-
-proc g_value_init*(value: PGValue, g_type: GType): PGValue{.cdecl,
-    dynlib: gobjectlib, importc: "g_value_init".}
-proc g_value_copy*(src_value: PGValue, dest_value: PGValue){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_copy".}
-proc g_value_reset*(value: PGValue): PGValue{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_reset".}
-proc g_value_unset*(value: PGValue){.cdecl, dynlib: gobjectlib,
-                                     importc: "g_value_unset".}
-proc g_value_set_instance*(value: PGValue, instance: gpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_instance".}
-proc g_value_fits_pointer*(value: PGValue): gboolean{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_fits_pointer".}
-proc g_value_peek_pointer*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_peek_pointer".}
-proc g_value_type_compatible*(src_type: GType, dest_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_type_compatible".}
-proc g_value_type_transformable*(src_type: GType, dest_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_type_transformable".}
-proc g_value_transform*(src_value: PGValue, dest_value: PGValue): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_transform".}
-proc g_value_register_transform_func*(src_type: GType, dest_type: GType,
-                                      transform_func: TGValueTransform){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_register_transform_func".}
-const
-  G_VALUE_NOCOPY_CONTENTS* = 1 shl 27
-
-type
-  PGValueArray* = ptr TGValueArray
-  TGValueArray* {.final.} = object
-    n_values*: guint
-    values*: PGValue
-    n_prealloced*: guint
-
-
-proc g_value_array_get_nth*(value_array: PGValueArray, index: guint): PGValue{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_get_nth".}
-proc g_value_array_new*(n_prealloced: guint): PGValueArray{.cdecl,
-    dynlib: gobjectlib, importc: "g_value_array_new".}
-proc g_value_array_free*(value_array: PGValueArray){.cdecl, dynlib: gobjectlib,
-    importc: "g_value_array_free".}
-proc g_value_array_copy*(value_array: PGValueArray): PGValueArray{.cdecl,
-    dynlib: gobjectlib, importc: "g_value_array_copy".}
-proc g_value_array_prepend*(value_array: PGValueArray, value: PGValue): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_prepend".}
-proc g_value_array_append*(value_array: PGValueArray, value: PGValue): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_append".}
-proc g_value_array_insert*(value_array: PGValueArray, index: guint,
-                           value: PGValue): PGValueArray{.cdecl,
-    dynlib: gobjectlib, importc: "g_value_array_insert".}
-proc g_value_array_remove*(value_array: PGValueArray, index: guint): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_remove".}
-proc g_value_array_sort*(value_array: PGValueArray, compare_func: TGCompareFunc): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_sort".}
-proc g_value_array_sort_with_data*(value_array: PGValueArray,
-                                   compare_func: TGCompareDataFunc,
-                                   user_data: gpointer): PGValueArray{.cdecl,
-    dynlib: gobjectlib, importc: "g_value_array_sort_with_data".}
-const
-  G_VALUE_COLLECT_INT* = 'i'
-  G_VALUE_COLLECT_LONG* = 'l'
-  G_VALUE_COLLECT_INT64* = 'q'
-  G_VALUE_COLLECT_DOUBLE* = 'd'
-  G_VALUE_COLLECT_POINTER* = 'p'
-  G_VALUE_COLLECT_FORMAT_MAX_LENGTH* = 8
-
-proc G_VALUE_HOLDS_CHAR*(value: PGValue): bool
-proc G_VALUE_HOLDS_UCHAR*(value: PGValue): bool
-proc G_VALUE_HOLDS_BOOLEAN*(value: PGValue): bool
-proc G_VALUE_HOLDS_INT*(value: PGValue): bool
-proc G_VALUE_HOLDS_UINT*(value: PGValue): bool
-proc G_VALUE_HOLDS_LONG*(value: PGValue): bool
-proc G_VALUE_HOLDS_ULONG*(value: PGValue): bool
-proc G_VALUE_HOLDS_INT64*(value: PGValue): bool
-proc G_VALUE_HOLDS_UINT64*(value: PGValue): bool
-proc G_VALUE_HOLDS_FLOAT*(value: PGValue): bool
-proc G_VALUE_HOLDS_DOUBLE*(value: PGValue): bool
-proc G_VALUE_HOLDS_STRING*(value: PGValue): bool
-proc G_VALUE_HOLDS_POINTER*(value: PGValue): bool
-proc g_value_set_char*(value: PGValue, v_char: gchar){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_char".}
-proc g_value_get_char*(value: PGValue): gchar{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_char".}
-proc g_value_set_uchar*(value: PGValue, v_uchar: guchar){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_uchar".}
-proc g_value_get_uchar*(value: PGValue): guchar{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_uchar".}
-proc g_value_set_boolean*(value: PGValue, v_boolean: gboolean){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_boolean".}
-proc g_value_get_boolean*(value: PGValue): gboolean{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_boolean".}
-proc g_value_set_int*(value: PGValue, v_int: gint){.cdecl, dynlib: gobjectlib,
-    importc: "g_value_set_int".}
-proc g_value_get_int*(value: PGValue): gint{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_int".}
-proc g_value_set_uint*(value: PGValue, v_uint: guint){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_uint".}
-proc g_value_get_uint*(value: PGValue): guint{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_uint".}
-proc g_value_set_long*(value: PGValue, v_long: glong){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_long".}
-proc g_value_get_long*(value: PGValue): glong{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_long".}
-proc g_value_set_ulong*(value: PGValue, v_ulong: gulong){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_ulong".}
-proc g_value_get_ulong*(value: PGValue): gulong{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_ulong".}
-proc g_value_set_int64*(value: PGValue, v_int64: gint64){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_int64".}
-proc g_value_get_int64*(value: PGValue): gint64{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_int64".}
-proc g_value_set_uint64*(value: PGValue, v_uint64: guint64){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_uint64".}
-proc g_value_get_uint64*(value: PGValue): guint64{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_uint64".}
-proc g_value_set_float*(value: PGValue, v_float: gfloat){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_float".}
-proc g_value_get_float*(value: PGValue): gfloat{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_float".}
-proc g_value_set_double*(value: PGValue, v_double: gdouble){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_double".}
-proc g_value_get_double*(value: PGValue): gdouble{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_double".}
-proc g_value_set_string*(value: PGValue, v_string: cstring){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_string".}
-proc g_value_set_static_string*(value: PGValue, v_string: cstring){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_static_string".}
-proc g_value_get_string*(value: PGValue): cstring{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_string".}
-proc g_value_dup_string*(value: PGValue): cstring{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_dup_string".}
-proc g_value_set_pointer*(value: PGValue, v_pointer: gpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_pointer".}
-proc g_value_get_pointer*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_pointer".}
-proc g_pointer_type_register_static*(name: cstring): GType{.cdecl,
-    dynlib: gobjectlib, importc: "g_pointer_type_register_static".}
-proc g_strdup_value_contents*(value: PGValue): cstring{.cdecl,
-    dynlib: gobjectlib, importc: "g_strdup_value_contents".}
-proc g_value_set_string_take_ownership*(value: PGValue, v_string: cstring){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_string_take_ownership".}
-type
-  Tgchararray* = gchar
-  Pgchararray* = ptr Tgchararray
-
-proc G_TYPE_IS_PARAM*(theType: GType): bool
-proc G_PARAM_SPEC*(pspec: Pointer): PGParamSpec
-proc G_IS_PARAM_SPEC*(pspec: Pointer): bool
-proc G_PARAM_SPEC_CLASS*(pclass: Pointer): PGParamSpecClass
-proc G_IS_PARAM_SPEC_CLASS*(pclass: Pointer): bool
-proc G_PARAM_SPEC_GET_CLASS*(pspec: Pointer): PGParamSpecClass
-proc G_PARAM_SPEC_TYPE*(pspec: Pointer): GType
-proc G_PARAM_SPEC_TYPE_NAME*(pspec: Pointer): cstring
-proc G_PARAM_SPEC_VALUE_TYPE*(pspec: Pointer): GType
-proc G_VALUE_HOLDS_PARAM*(value: Pointer): bool
-const
-  G_PARAM_READABLE* = 1 shl 0
-  G_PARAM_WRITABLE* = 1 shl 1
-  G_PARAM_CONSTRUCT* = 1 shl 2
-  G_PARAM_CONSTRUCT_ONLY* = 1 shl 3
-  G_PARAM_LAX_VALIDATION* = 1 shl 4
-  G_PARAM_PRIVATE* = 1 shl 5
-  G_PARAM_READWRITE* = G_PARAM_READABLE or G_PARAM_WRITABLE
-  G_PARAM_MASK* = 0x000000FF
-  G_PARAM_USER_SHIFT* = 8
-
-proc g_param_spec_ref*(pspec: PGParamSpec): PGParamSpec{.cdecl, dynlib: gliblib,
-    importc: "g_param_spec_ref".}
-proc g_param_spec_unref*(pspec: PGParamSpec){.cdecl, dynlib: gliblib,
-    importc: "g_param_spec_unref".}
-proc g_param_spec_sink*(pspec: PGParamSpec){.cdecl, dynlib: gliblib,
-    importc: "g_param_spec_sink".}
-proc g_param_spec_get_qdata*(pspec: PGParamSpec, quark: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_get_qdata".}
-proc g_param_spec_set_qdata*(pspec: PGParamSpec, quark: TGQuark, data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_set_qdata".}
-proc g_param_spec_set_qdata_full*(pspec: PGParamSpec, quark: TGQuark,
-                                  data: gpointer, destroy: TGDestroyNotify){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_set_qdata_full".}
-proc g_param_spec_steal_qdata*(pspec: PGParamSpec, quark: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_steal_qdata".}
-proc g_param_value_set_default*(pspec: PGParamSpec, value: PGValue){.cdecl,
-    dynlib: gliblib, importc: "g_param_value_set_default".}
-proc g_param_value_defaults*(pspec: PGParamSpec, value: PGValue): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_defaults".}
-proc g_param_value_validate*(pspec: PGParamSpec, value: PGValue): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_validate".}
-proc g_param_value_convert*(pspec: PGParamSpec, src_value: PGValue,
-                            dest_value: PGValue, strict_validation: gboolean): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_convert".}
-proc g_param_values_cmp*(pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-    cdecl, dynlib: gliblib, importc: "g_param_values_cmp".}
-proc g_param_spec_get_name*(pspec: PGParamSpec): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_param_spec_get_name".}
-proc g_param_spec_get_nick*(pspec: PGParamSpec): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_param_spec_get_nick".}
-proc g_param_spec_get_blurb*(pspec: PGParamSpec): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_param_spec_get_blurb".}
-proc g_value_set_param*(value: PGValue, param: PGParamSpec){.cdecl,
-    dynlib: gliblib, importc: "g_value_set_param".}
-proc g_value_get_param*(value: PGValue): PGParamSpec{.cdecl, dynlib: gliblib,
-    importc: "g_value_get_param".}
-proc g_value_dup_param*(value: PGValue): PGParamSpec{.cdecl, dynlib: gliblib,
-    importc: "g_value_dup_param".}
-proc g_value_set_param_take_ownership*(value: PGValue, param: PGParamSpec){.
-    cdecl, dynlib: gliblib, importc: "g_value_set_param_take_ownership".}
-type
-  PGParamSpecTypeInfo* = ptr TGParamSpecTypeInfo
-  TGParamSpecTypeInfo* {.final.} = object
-    instance_size*: guint16
-    n_preallocs*: guint16
-    instance_init*: proc (pspec: PGParamSpec){.cdecl.}
-    value_type*: GType
-    finalize*: proc (pspec: PGParamSpec){.cdecl.}
-    value_set_default*: proc (pspec: PGParamSpec, value: PGValue){.cdecl.}
-    value_validate*: proc (pspec: PGParamSpec, value: PGValue): gboolean{.cdecl.}
-    values_cmp*: proc (pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-        cdecl.}
-
-
-proc g_param_type_register_static*(name: cstring,
-                                   pspec_info: PGParamSpecTypeInfo): GType{.
-    cdecl, dynlib: gliblib, importc: "g_param_type_register_static".}
-proc g_param_type_register_static_constant*(name: cstring,
-    pspec_info: PGParamSpecTypeInfo, opt_type: GType): GType{.cdecl,
-    dynlib: gliblib, importc: "`g_param_type_register_static_constant`".}
-proc g_param_spec_internal*(param_type: GType, name: cstring, nick: cstring,
-                            blurb: cstring, flags: TGParamFlags): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_internal".}
-proc g_param_spec_pool_new*(type_prefixing: gboolean): PGParamSpecPool{.cdecl,
-    dynlib: gliblib, importc: "g_param_spec_pool_new".}
-proc g_param_spec_pool_insert*(pool: PGParamSpecPool, pspec: PGParamSpec,
-                               owner_type: GType){.cdecl, dynlib: gliblib,
-    importc: "g_param_spec_pool_insert".}
-proc g_param_spec_pool_remove*(pool: PGParamSpecPool, pspec: PGParamSpec){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_remove".}
-proc g_param_spec_pool_lookup*(pool: PGParamSpecPool, param_name: cstring,
-                               owner_type: GType, walk_ancestors: gboolean): PGParamSpec{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_lookup".}
-proc g_param_spec_pool_list_owned*(pool: PGParamSpecPool, owner_type: GType): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_list_owned".}
-proc g_param_spec_pool_list*(pool: PGParamSpecPool, owner_type: GType,
-                             n_pspecs_p: Pguint): PPGParamSpec{.cdecl,
-    dynlib: gliblib, importc: "g_param_spec_pool_list".}
-type
-  PGClosure* = ptr TGClosure
-  PGClosureNotifyData* = ptr TGClosureNotifyData
-  TGClosureNotify* = proc (data: gpointer, closure: PGClosure){.cdecl.}
-  TGClosure* {.final.} = object
-    flag0*: int32
-    marshal*: proc (closure: PGClosure, return_value: PGValue,
-                    n_param_values: guint, param_values: PGValue,
-                    invocation_hint, marshal_data: gpointer){.cdecl.}
-    data*: gpointer
-    notifiers*: PGClosureNotifyData
-
-  TGCallBackProcedure* = proc () {.cdecl.}
-  TGCallback* = proc () {.cdecl.}
-  TGClosureMarshal* = proc (closure: PGClosure, return_value: PGValue,
-                            n_param_values: guint, param_values: PGValue,
-                            invocation_hint: gpointer, marshal_data: gpointer){.
-      cdecl.}
-  TGClosureNotifyData* {.final.} = object
-    data*: gpointer
-    notify*: TGClosureNotify
-
-
-proc G_CLOSURE_NEEDS_MARSHAL*(closure: Pointer): bool
-proc G_CLOSURE_N_NOTIFIERS*(cl: PGClosure): int32
-proc G_CCLOSURE_SWAP_DATA*(cclosure: PGClosure): int32
-proc G_CALLBACK*(f: pointer): TGCallback
-const
-  bm_TGClosure_ref_count* = 0x00007FFF'i32
-  bp_TGClosure_ref_count* = 0'i32
-  bm_TGClosure_meta_marshal* = 0x00008000'i32
-  bp_TGClosure_meta_marshal* = 15'i32
-  bm_TGClosure_n_guards* = 0x00010000'i32
-  bp_TGClosure_n_guards* = 16'i32
-  bm_TGClosure_n_fnotifiers* = 0x00060000'i32
-  bp_TGClosure_n_fnotifiers* = 17'i32
-  bm_TGClosure_n_inotifiers* = 0x07F80000'i32
-  bp_TGClosure_n_inotifiers* = 19'i32
-  bm_TGClosure_in_inotify* = 0x08000000'i32
-  bp_TGClosure_in_inotify* = 27'i32
-  bm_TGClosure_floating* = 0x10000000'i32
-  bp_TGClosure_floating* = 28'i32
-  bm_TGClosure_derivative_flag* = 0x20000000'i32
-  bp_TGClosure_derivative_flag* = 29'i32
-  bm_TGClosure_in_marshal* = 0x40000000'i32
-  bp_TGClosure_in_marshal* = 30'i32
-  bm_TGClosure_is_invalid* = 0x80000000'i32
-  bp_TGClosure_is_invalid* = 31'i32
-
-proc ref_count*(a: var TGClosure): guint
-proc set_ref_count*(a: var TGClosure, ref_count: guint)
-proc meta_marshal*(a: PGClosure): guint
-proc set_meta_marshal*(a: var TGClosure, meta_marshal: guint)
-proc n_guards*(a: PGClosure): guint
-proc set_n_guards*(a: var TGClosure, n_guards: guint)
-proc n_fnotifiers*(a: PGClosure): guint
-proc set_n_fnotifiers*(a: var TGClosure, n_fnotifiers: guint)
-proc n_inotifiers*(a: PGClosure): guint
-proc in_inotify*(a: var TGClosure): guint
-proc set_in_inotify*(a: var TGClosure, in_inotify: guint)
-proc floating*(a: var TGClosure): guint
-proc set_floating*(a: var TGClosure, floating: guint)
-proc derivative_flag*(a: PGClosure): guint
-proc set_derivative_flag*(a: var TGClosure, derivative_flag: guint)
-proc in_marshal*(a: var TGClosure): guint
-proc set_in_marshal*(a: var TGClosure, in_marshal: guint)
-proc is_invalid*(a: var TGClosure): guint
-proc set_is_invalid*(a: var TGClosure, is_invalid: guint)
-type
-  PGCClosure* = ptr TGCClosure
-  TGCClosure* {.final.} = object
-    closure*: TGClosure
-    callback*: gpointer
-
-
-proc g_cclosure_new*(callback_func: TGCallback, user_data: gpointer,
-                     destroy_data: TGClosureNotify): PGClosure{.cdecl,
-    dynlib: gliblib, importc: "g_cclosure_new".}
-proc g_cclosure_new_swap*(callback_func: TGCallback, user_data: gpointer,
-                          destroy_data: TGClosureNotify): PGClosure{.cdecl,
-    dynlib: gliblib, importc: "g_cclosure_new_swap".}
-proc g_signal_type_cclosure_new*(itype: GType, struct_offset: guint): PGClosure{.
-    cdecl, dynlib: gliblib, importc: "g_signal_type_cclosure_new".}
-proc g_closure_ref*(closure: PGClosure): PGClosure{.cdecl, dynlib: gliblib,
-    importc: "g_closure_ref".}
-proc g_closure_sink*(closure: PGClosure){.cdecl, dynlib: gliblib,
-    importc: "g_closure_sink".}
-proc g_closure_unref*(closure: PGClosure){.cdecl, dynlib: gliblib,
-    importc: "g_closure_unref".}
-proc g_closure_new_simple*(sizeof_closure: guint, data: gpointer): PGClosure{.
-    cdecl, dynlib: gliblib, importc: "g_closure_new_simple".}
-proc g_closure_add_finalize_notifier*(closure: PGClosure, notify_data: gpointer,
-                                      notify_func: TGClosureNotify){.cdecl,
-    dynlib: gliblib, importc: "g_closure_add_finalize_notifier".}
-proc g_closure_remove_finalize_notifier*(closure: PGClosure,
-    notify_data: gpointer, notify_func: TGClosureNotify){.cdecl,
-    dynlib: gliblib, importc: "g_closure_remove_finalize_notifier".}
-proc g_closure_add_invalidate_notifier*(closure: PGClosure,
-                                        notify_data: gpointer,
-                                        notify_func: TGClosureNotify){.cdecl,
-    dynlib: gliblib, importc: "g_closure_add_invalidate_notifier".}
-proc g_closure_remove_invalidate_notifier*(closure: PGClosure,
-    notify_data: gpointer, notify_func: TGClosureNotify){.cdecl,
-    dynlib: gliblib, importc: "g_closure_remove_invalidate_notifier".}
-proc g_closure_add_marshal_guards*(closure: PGClosure,
-                                   pre_marshal_data: gpointer,
-                                   pre_marshal_notify: TGClosureNotify,
-                                   post_marshal_data: gpointer,
-                                   post_marshal_notify: TGClosureNotify){.cdecl,
-    dynlib: gliblib, importc: "g_closure_add_marshal_guards".}
-proc g_closure_set_marshal*(closure: PGClosure, marshal: TGClosureMarshal){.
-    cdecl, dynlib: gliblib, importc: "g_closure_set_marshal".}
-proc g_closure_set_meta_marshal*(closure: PGClosure, marshal_data: gpointer,
-                                 meta_marshal: TGClosureMarshal){.cdecl,
-    dynlib: gliblib, importc: "g_closure_set_meta_marshal".}
-proc g_closure_invalidate*(closure: PGClosure){.cdecl, dynlib: gliblib,
-    importc: "g_closure_invalidate".}
-proc g_closure_invoke*(closure: PGClosure, return_value: PGValue,
-                       n_param_values: guint, param_values: PGValue,
-                       invocation_hint: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_closure_invoke".}
-type
-  PGSignalInvocationHint* = ptr TGSignalInvocationHint
-  PGSignalCMarshaller* = ptr TGSignalCMarshaller
-  TGSignalCMarshaller* = TGClosureMarshal
-  TGSignalEmissionHook* = proc (ihint: PGSignalInvocationHint,
-                                n_param_values: guint, param_values: PGValue,
-                                data: gpointer): gboolean{.cdecl.}
-  TGSignalAccumulator* = proc (ihint: PGSignalInvocationHint,
-                               return_accu: PGValue, handler_return: PGValue,
-                               data: gpointer): gboolean{.cdecl.}
-  PGSignalFlags* = ptr TGSignalFlags
-  TGSignalFlags* = int32
-  TGSignalInvocationHint* {.final.} = object
-    signal_id*: guint
-    detail*: TGQuark
-    run_type*: TGSignalFlags
-
-  PGSignalQuery* = ptr TGSignalQuery
-  TGSignalQuery* {.final.} = object
-    signal_id*: guint
-    signal_name*: cstring
-    itype*: GType
-    signal_flags*: TGSignalFlags
-    return_type*: GType
-    n_params*: guint
-    param_types*: PGType
-
-
-const
-  G_SIGNAL_RUN_FIRST* = 1 shl 0
-  G_SIGNAL_RUN_LAST* = 1 shl 1
-  G_SIGNAL_RUN_CLEANUP* = 1 shl 2
-  G_SIGNAL_NO_RECURSE* = 1 shl 3
-  G_SIGNAL_DETAILED* = 1 shl 4
-  G_SIGNAL_ACTION* = 1 shl 5
-  G_SIGNAL_NO_HOOKS* = 1 shl 6
-  G_SIGNAL_FLAGS_MASK* = 0x0000007F
-
-type
-  PGConnectFlags* = ptr TGConnectFlags
-  TGConnectFlags* = int32
-
-const
-  G_CONNECT_AFTER* = 1 shl 0
-  G_CONNECT_SWAPPED* = 1 shl 1
-
-type
-  PGSignalMatchType* = ptr TGSignalMatchType
-  TGSignalMatchType* = int32
-
-const
-  G_SIGNAL_MATCH_ID* = 1 shl 0
-  G_SIGNAL_MATCH_DETAIL* = 1 shl 1
-  G_SIGNAL_MATCH_CLOSURE* = 1 shl 2
-  G_SIGNAL_MATCH_FUNC* = 1 shl 3
-  G_SIGNAL_MATCH_DATA* = 1 shl 4
-  G_SIGNAL_MATCH_UNBLOCKED* = 1 shl 5
-  G_SIGNAL_MATCH_MASK* = 0x0000003F
-  G_SIGNAL_TYPE_STATIC_SCOPE* = G_TYPE_FLAG_RESERVED_ID_BIT
-
-proc g_signal_newv*(signal_name: cstring, itype: GType,
-                    signal_flags: TGSignalFlags, class_closure: PGClosure,
-                    accumulator: TGSignalAccumulator, accu_data: gpointer,
-                    c_marshaller: TGSignalCMarshaller, return_type: GType,
-                    n_params: guint, param_types: PGType): guint{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_newv".}
-proc g_signal_emitv*(instance_and_params: PGValue, signal_id: guint,
-                     detail: TGQuark, return_value: PGValue){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_emitv".}
-proc g_signal_lookup*(name: cstring, itype: GType): guint{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_lookup".}
-proc g_signal_name*(signal_id: guint): cstring{.cdecl, dynlib: gobjectlib,
-    importc: "g_signal_name".}
-proc g_signal_query*(signal_id: guint, query: PGSignalQuery){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_query".}
-proc g_signal_list_ids*(itype: GType, n_ids: Pguint): Pguint{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_list_ids".}
-proc g_signal_parse_name*(detailed_signal: cstring, itype: GType,
-                          signal_id_p: Pguint, detail_p: PGQuark,
-                          force_detail_quark: gboolean): gboolean{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_parse_name".}
-proc g_signal_get_invocation_hint*(instance: gpointer): PGSignalInvocationHint{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_get_invocation_hint".}
-proc g_signal_stop_emission*(instance: gpointer, signal_id: guint,
-                             detail: TGQuark){.cdecl, dynlib: gobjectlib,
-    importc: "g_signal_stop_emission".}
-proc g_signal_stop_emission_by_name*(instance: gpointer,
-                                     detailed_signal: cstring){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_stop_emission_by_name".}
-proc g_signal_add_emission_hook*(signal_id: guint, quark: TGQuark,
-                                 hook_func: TGSignalEmissionHook,
-                                 hook_data: gpointer,
-                                 data_destroy: TGDestroyNotify): gulong{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_add_emission_hook".}
-proc g_signal_remove_emission_hook*(signal_id: guint, hook_id: gulong){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_remove_emission_hook".}
-proc g_signal_has_handler_pending*(instance: gpointer, signal_id: guint,
-                                   detail: TGQuark, may_be_blocked: gboolean): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_has_handler_pending".}
-proc g_signal_connect_closure_by_id*(instance: gpointer, signal_id: guint,
-                                     detail: TGQuark, closure: PGClosure,
-                                     after: gboolean): gulong{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_connect_closure_by_id".}
-proc g_signal_connect_closure*(instance: gpointer, detailed_signal: cstring,
-                               closure: PGClosure, after: gboolean): gulong{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_connect_closure".}
-proc g_signal_connect_data*(instance: gpointer, detailed_signal: cstring,
-                            c_handler: TGCallback, data: gpointer,
-                            destroy_data: TGClosureNotify,
-                            connect_flags: TGConnectFlags): gulong{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_connect_data".}
-proc g_signal_handler_block*(instance: gpointer, handler_id: gulong){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_handler_block".}
-proc g_signal_handler_unblock*(instance: gpointer, handler_id: gulong){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_handler_unblock".}
-proc g_signal_handler_disconnect*(instance: gpointer, handler_id: gulong){.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_disconnect".}
-proc g_signal_handler_is_connected*(instance: gpointer, handler_id: gulong): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_is_connected".}
-proc g_signal_handler_find*(instance: gpointer, mask: TGSignalMatchType,
-                            signal_id: guint, detail: TGQuark,
-                            closure: PGClosure, func: gpointer, data: gpointer): gulong{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_find".}
-proc g_signal_handlers_block_matched*(instance: gpointer,
-                                      mask: TGSignalMatchType, signal_id: guint,
-                                      detail: TGQuark, closure: PGClosure,
-                                      func: gpointer, data: gpointer): guint{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handlers_block_matched".}
-proc g_signal_handlers_unblock_matched*(instance: gpointer,
-                                        mask: TGSignalMatchType,
-                                        signal_id: guint, detail: TGQuark,
-                                        closure: PGClosure, func: gpointer,
-                                        data: gpointer): guint{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_handlers_unblock_matched".}
-proc g_signal_handlers_disconnect_matched*(instance: gpointer,
-    mask: TGSignalMatchType, signal_id: guint, detail: TGQuark,
-    closure: PGClosure, func: gpointer, data: gpointer): guint{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_handlers_disconnect_matched".}
-proc g_signal_override_class_closure*(signal_id: guint, instance_type: GType,
-                                      class_closure: PGClosure){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_override_class_closure".}
-proc g_signal_chain_from_overridden*(instance_and_params: PGValue,
-                                     return_value: PGValue){.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_chain_from_overridden".}
-proc g_signal_connect*(instance: gpointer, detailed_signal: cstring,
-                       c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_connect_after*(instance: gpointer, detailed_signal: cstring,
-                             c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_connect_swapped*(instance: gpointer, detailed_signal: cstring,
-                               c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_handlers_disconnect_by_func*(instance: gpointer,
-    func, data: gpointer): guint
-proc g_signal_handlers_block_by_func*(instance: gpointer, func, data: gpointer)
-proc g_signal_handlers_unblock_by_func*(instance: gpointer, func, data: gpointer)
-proc g_signal_handlers_destroy*(instance: gpointer){.cdecl, dynlib: gobjectlib,
-    importc: "g_signal_handlers_destroy".}
-proc g_signals_destroy*(itype: GType){.cdecl, dynlib: gobjectlib,
-                                       importc: "`g_signals_destroy`".}
-type
-  TGTypePluginUse* = proc (plugin: PGTypePlugin){.cdecl.}
-  TGTypePluginUnuse* = proc (plugin: PGTypePlugin){.cdecl.}
-  TGTypePluginCompleteTypeInfo* = proc (plugin: PGTypePlugin, g_type: GType,
-                                        info: PGTypeInfo,
-                                        value_table: PGTypeValueTable){.cdecl.}
-  TGTypePluginCompleteInterfaceInfo* = proc (plugin: PGTypePlugin,
-      instance_type: GType, interface_type: GType, info: PGInterfaceInfo){.cdecl.}
-  PGTypePluginClass* = ptr TGTypePluginClass
-  TGTypePluginClass* {.final.} = object
-    base_iface*: TGTypeInterface
-    use_plugin*: TGTypePluginUse
-    unuse_plugin*: TGTypePluginUnuse
-    complete_type_info*: TGTypePluginCompleteTypeInfo
-    complete_interface_info*: TGTypePluginCompleteInterfaceInfo
-
-
-proc G_TYPE_TYPE_PLUGIN*(): GType
-proc G_TYPE_PLUGIN*(inst: Pointer): PGTypePlugin
-proc G_TYPE_PLUGIN_CLASS*(vtable: Pointer): PGTypePluginClass
-proc G_IS_TYPE_PLUGIN*(inst: Pointer): bool
-proc G_IS_TYPE_PLUGIN_CLASS*(vtable: Pointer): bool
-proc G_TYPE_PLUGIN_GET_CLASS*(inst: Pointer): PGTypePluginClass
-proc g_type_plugin_get_type*(): GType{.cdecl, dynlib: gliblib,
-                                       importc: "g_type_plugin_get_type".}
-proc g_type_plugin_use*(plugin: PGTypePlugin){.cdecl, dynlib: gliblib,
-    importc: "g_type_plugin_use".}
-proc g_type_plugin_unuse*(plugin: PGTypePlugin){.cdecl, dynlib: gliblib,
-    importc: "g_type_plugin_unuse".}
-proc g_type_plugin_complete_type_info*(plugin: PGTypePlugin, g_type: GType,
-                                       info: PGTypeInfo,
-                                       value_table: PGTypeValueTable){.cdecl,
-    dynlib: gliblib, importc: "g_type_plugin_complete_type_info".}
-proc g_type_plugin_complete_interface_info*(plugin: PGTypePlugin,
-    instance_type: GType, interface_type: GType, info: PGInterfaceInfo){.cdecl,
-    dynlib: gliblib, importc: "g_type_plugin_complete_interface_info".}
-type
-  PGObject* = ptr TGObject
-  TGObject* {.pure.} = object
-    g_type_instance*: TGTypeInstance
-    ref_count*: guint
-    qdata*: PGData
-
-  TGObjectGetPropertyFunc* = proc (anObject: PGObject, property_id: guint,
-                                   value: PGValue, pspec: PGParamSpec){.cdecl.}
-  TGObjectSetPropertyFunc* = proc (anObject: PGObject, property_id: guint,
-                                   value: PGValue, pspec: PGParamSpec){.cdecl.}
-  TGObjectFinalizeFunc* = proc (anObject: PGObject){.cdecl.}
-  TGWeakNotify* = proc (data: gpointer, where_the_object_was: PGObject){.cdecl.}
-  PGObjectConstructParam* = ptr TGObjectConstructParam
-  PGObjectClass* = ptr TGObjectClass
-  TGObjectClass* {.pure.} = object
-    g_type_class*: TGTypeClass
-    construct_properties*: PGSList
-    constructor*: proc (theType: GType, n_construct_properties: guint,
-                        construct_properties: PGObjectConstructParam): PGObject{.
-        cdecl.}
-    set_property*: proc (anObject: PGObject, property_id: guint, value: PGValue,
-                         pspec: PGParamSpec){.cdecl.}
-    get_property*: proc (anObject: PGObject, property_id: guint, value: PGValue,
-                         pspec: PGParamSpec){.cdecl.}
-    dispose*: proc (anObject: PGObject){.cdecl.}
-    finalize*: proc (anObject: PGObject){.cdecl.}
-    dispatch_properties_changed*: proc (anObject: PGObject, n_pspecs: guint,
-                                        pspecs: PPGParamSpec){.cdecl.}
-    notify*: proc (anObject: PGObject, pspec: PGParamSpec){.cdecl.}
-    pdummy*: array[0..7, gpointer]
-
-  TGObjectConstructParam* {.final.} = object
-    pspec*: PGParamSpec
-    value*: PGValue
-
-
-proc G_TYPE_IS_OBJECT*(theType: GType): bool
-proc G_OBJECT*(anObject: pointer): PGObject
-proc G_OBJECT_CLASS*(class: Pointer): PGObjectClass
-proc G_IS_OBJECT*(anObject: pointer): bool
-proc G_IS_OBJECT_CLASS*(class: Pointer): bool
-proc G_OBJECT_GET_CLASS*(anObject: pointer): PGObjectClass
-proc G_OBJECT_TYPE*(anObject: pointer): GType
-proc G_OBJECT_TYPE_NAME*(anObject: pointer): cstring
-proc G_OBJECT_CLASS_TYPE*(class: Pointer): GType
-proc G_OBJECT_CLASS_NAME*(class: Pointer): cstring
-proc G_VALUE_HOLDS_OBJECT*(value: Pointer): bool
-proc g_object_class_install_property*(oclass: PGObjectClass, property_id: guint,
-                                      pspec: PGParamSpec){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_class_install_property".}
-proc g_object_class_find_property*(oclass: PGObjectClass, property_name: cstring): PGParamSpec{.
-    cdecl, dynlib: gobjectlib, importc: "g_object_class_find_property".}
-proc g_object_class_list_properties*(oclass: PGObjectClass, n_properties: Pguint): PPGParamSpec{.
-    cdecl, dynlib: gobjectlib, importc: "g_object_class_list_properties".}
-proc g_object_set_property*(anObject: PGObject, property_name: cstring,
-                            value: PGValue){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_set_property".}
-proc g_object_get_property*(anObject: PGObject, property_name: cstring,
-                            value: PGValue){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_get_property".}
-proc g_object_freeze_notify*(anObject: PGObject){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_freeze_notify".}
-proc g_object_notify*(anObject: PGObject, property_name: cstring){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_notify".}
-proc g_object_thaw_notify*(anObject: PGObject){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_thaw_notify".}
-proc g_object_ref*(anObject: gpointer): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_object_ref".}
-proc g_object_unref*(anObject: gpointer){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_unref".}
-proc g_object_weak_ref*(anObject: PGObject, notify: TGWeakNotify, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_weak_ref".}
-proc g_object_weak_unref*(anObject: PGObject, notify: TGWeakNotify,
-                          data: gpointer){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_weak_unref".}
-proc g_object_add_weak_pointer*(anObject: PGObject,
-                                weak_pointer_location: Pgpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_add_weak_pointer".}
-proc g_object_remove_weak_pointer*(anObject: PGObject,
-                                   weak_pointer_location: Pgpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_remove_weak_pointer".}
-proc g_object_get_qdata*(anObject: PGObject, quark: TGQuark): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_object_get_qdata".}
-proc g_object_set_qdata*(anObject: PGObject, quark: TGQuark, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_set_qdata".}
-proc g_object_set_qdata_full*(anObject: PGObject, quark: TGQuark,
-                              data: gpointer, destroy: TGDestroyNotify){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_set_qdata_full".}
-proc g_object_steal_qdata*(anObject: PGObject, quark: TGQuark): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_object_steal_qdata".}
-proc g_object_get_data*(anObject: PGObject, key: cstring): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_object_get_data".}
-proc g_object_set_data*(anObject: PGObject, key: cstring, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_set_data".}
-proc g_object_set_data_full*(anObject: PGObject, key: cstring, data: gpointer,
-                             destroy: TGDestroyNotify){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_set_data_full".}
-proc g_object_steal_data*(anObject: PGObject, key: cstring): gpointer{.cdecl,
-    dynlib: gobjectlib, importc: "g_object_steal_data".}
-proc g_object_watch_closure*(anObject: PGObject, closure: PGClosure){.cdecl,
-    dynlib: gobjectlib, importc: "g_object_watch_closure".}
-proc g_cclosure_new_object*(callback_func: TGCallback, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_cclosure_new_object".}
-proc g_cclosure_new_object_swap*(callback_func: TGCallback, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_cclosure_new_object_swap".}
-proc g_closure_new_object*(sizeof_closure: guint, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_closure_new_object".}
-proc g_value_set_object*(value: PGValue, v_object: gpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_object".}
-proc g_value_get_object*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_object".}
-proc g_value_dup_object*(value: PGValue): PGObject{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_dup_object".}
-proc g_signal_connect_object*(instance: gpointer, detailed_signal: cstring,
-                              c_handler: TGCallback, gobject: gpointer,
-                              connect_flags: TGConnectFlags): gulong{.cdecl,
-    dynlib: gobjectlib, importc: "g_signal_connect_object".}
-proc g_object_run_dispose*(anObject: PGObject){.cdecl, dynlib: gobjectlib,
-    importc: "g_object_run_dispose".}
-proc g_value_set_object_take_ownership*(value: PGValue, v_object: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_object_take_ownership".}
-proc G_OBJECT_WARN_INVALID_PSPEC*(anObject: gpointer, pname: cstring,
-                                  property_id: gint, pspec: gpointer)
-proc G_OBJECT_WARN_INVALID_PROPERTY_ID*(anObject: gpointer, property_id: gint,
-                                        pspec: gpointer)
-type
-  G_FLAGS_TYPE* = GType
-
-const
-  G_E* = 2.7182818284590451
-  G_LN2* = 0.6931471805599452
-  G_LN10* = 2.3025850929940455
-  G_PI* = 3.1415926535897936
-  G_PI_2* = 1.5707963267948968
-  G_PI_4* = 0.7853981633974483
-  G_SQRT2* = 1.4142135623730951
-  G_LITTLE_ENDIAN* = 1234
-  G_BIG_ENDIAN* = 4321
-  G_PDP_ENDIAN* = 3412
-
-proc GUINT16_SWAP_LE_BE_CONSTANT*(val: guint16): guint16
-proc GUINT32_SWAP_LE_BE_CONSTANT*(val: guint32): guint32
-type
-  PGEnumClass* = ptr TGEnumClass
-  PGEnumValue* = ptr TGEnumValue
-  TGEnumClass* {.final.} = object
-    g_type_class*: TGTypeClass
-    minimum*: gint
-    maximum*: gint
-    n_values*: guint
-    values*: PGEnumValue
-
-  TGEnumValue* {.final.} = object
-    value*: gint
-    value_name*: cstring
-    value_nick*: cstring
-
-  PGFlagsClass* = ptr TGFlagsClass
-  PGFlagsValue* = ptr TGFlagsValue
-  TGFlagsClass* {.final.} = object
-    g_type_class*: TGTypeClass
-    mask*: guint
-    n_values*: guint
-    values*: PGFlagsValue
-
-  TGFlagsValue* {.final.} = object
-    value*: guint
-    value_name*: cstring
-    value_nick*: cstring
-
-
-proc G_TYPE_IS_ENUM*(theType: GType): gboolean
-proc G_ENUM_CLASS*(class: pointer): PGEnumClass
-proc G_IS_ENUM_CLASS*(class: pointer): gboolean
-proc G_ENUM_CLASS_TYPE*(class: pointer): GType
-proc G_ENUM_CLASS_TYPE_NAME*(class: pointer): cstring
-proc G_TYPE_IS_FLAGS*(theType: GType): gboolean
-proc G_FLAGS_CLASS*(class: pointer): PGFlagsClass
-proc G_IS_FLAGS_CLASS*(class: pointer): gboolean
-proc G_FLAGS_CLASS_TYPE*(class: pointer): GType
-proc G_FLAGS_CLASS_TYPE_NAME*(class: pointer): cstring
-proc G_VALUE_HOLDS_ENUM*(value: pointer): gboolean
-proc G_VALUE_HOLDS_FLAGS*(value: pointer): gboolean
-proc g_enum_get_value*(enum_class: PGEnumClass, value: gint): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value".}
-proc g_enum_get_value_by_name*(enum_class: PGEnumClass, name: cstring): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value_by_name".}
-proc g_enum_get_value_by_nick*(enum_class: PGEnumClass, nick: cstring): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value_by_nick".}
-proc g_flags_get_first_value*(flags_class: PGFlagsClass, value: guint): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_first_value".}
-proc g_flags_get_value_by_name*(flags_class: PGFlagsClass, name: cstring): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_value_by_name".}
-proc g_flags_get_value_by_nick*(flags_class: PGFlagsClass, nick: cstring): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_value_by_nick".}
-proc g_value_set_enum*(value: PGValue, v_enum: gint){.cdecl, dynlib: gliblib,
-    importc: "g_value_set_enum".}
-proc g_value_get_enum*(value: PGValue): gint{.cdecl, dynlib: gliblib,
-    importc: "g_value_get_enum".}
-proc g_value_set_flags*(value: PGValue, v_flags: guint){.cdecl, dynlib: gliblib,
-    importc: "g_value_set_flags".}
-proc g_value_get_flags*(value: PGValue): guint{.cdecl, dynlib: gliblib,
-    importc: "g_value_get_flags".}
-proc g_enum_register_static*(name: cstring, const_static_values: PGEnumValue): GType{.
-    cdecl, dynlib: gliblib, importc: "g_enum_register_static".}
-proc g_flags_register_static*(name: cstring, const_static_values: PGFlagsValue): GType{.
-    cdecl, dynlib: gliblib, importc: "g_flags_register_static".}
-proc g_enum_complete_type_info*(g_enum_type: GType, info: PGTypeInfo,
-                                const_values: PGEnumValue){.cdecl,
-    dynlib: gliblib, importc: "g_enum_complete_type_info".}
-proc g_flags_complete_type_info*(g_flags_type: GType, info: PGTypeInfo,
-                                 const_values: PGFlagsValue){.cdecl,
-    dynlib: gliblib, importc: "g_flags_complete_type_info".}
-const
-  G_MINFLOAT* = 0.0
-  G_MAXFLOAT* = 1.6999999999999995E308
-  G_MINDOUBLE* = G_MINFLOAT
-  G_MAXDOUBLE* = G_MAXFLOAT
-  G_MAXSHORT* = 32767
-  G_MINSHORT* = - G_MAXSHORT - 1
-  G_MAXUSHORT* = 2 * G_MAXSHORT + 1
-  G_MAXINT* = 2147483647
-  G_MININT* = - G_MAXINT - 1
-  G_MAXUINT* = -1
-  G_MINLONG* = G_MININT
-  G_MAXLONG* = G_MAXINT
-  G_MAXULONG* = G_MAXUINT
-  G_MAXINT64* = high(int64)
-  G_MININT64* = low(int64)
-
-const
-  G_GINT16_FORMAT* = "hi"
-  G_GUINT16_FORMAT* = "hu"
-  G_GINT32_FORMAT* = 'i'
-  G_GUINT32_FORMAT* = 'u'
-  G_HAVE_GINT64* = 1
-  G_GINT64_FORMAT* = "I64i"
-  G_GUINT64_FORMAT* = "I64u"
-  GLIB_SIZEOF_VOID_P* = SizeOf(Pointer)
-  GLIB_SIZEOF_LONG* = SizeOf(int32)
-  GLIB_SIZEOF_SIZE_T* = SizeOf(int32)
-
-type
-  PGSystemThread* = ptr TGSystemThread
-  TGSystemThread* {.final.} = object
-    data*: array[0..3, char]
-    dummy_double*: float64
-    dummy_pointer*: pointer
-    dummy_long*: int32
-
-
-const
-  GLIB_SYSDEF_POLLIN* = 1
-  GLIB_SYSDEF_POLLOUT* = 4
-  GLIB_SYSDEF_POLLPRI* = 2
-  GLIB_SYSDEF_POLLERR* = 8
-  GLIB_SYSDEF_POLLHUP* = 16
-  GLIB_SYSDEF_POLLNVAL* = 32
-
-proc GUINT_TO_POINTER*(i: guint): pointer
-type
-  PGAsciiType* = ptr TGAsciiType
-  TGAsciiType* = int32
-
-const
-  G_ASCII_ALNUM* = 1 shl 0
-  G_ASCII_ALPHA* = 1 shl 1
-  G_ASCII_CNTRL* = 1 shl 2
-  G_ASCII_DIGIT* = 1 shl 3
-  G_ASCII_GRAPH* = 1 shl 4
-  G_ASCII_LOWER* = 1 shl 5
-  G_ASCII_PRINT* = 1 shl 6
-  G_ASCII_PUNCT* = 1 shl 7
-  G_ASCII_SPACE* = 1 shl 8
-  G_ASCII_UPPER* = 1 shl 9
-  G_ASCII_XDIGIT* = 1 shl 10
-
-proc g_ascii_tolower*(c: gchar): gchar{.cdecl, dynlib: gliblib,
-                                        importc: "g_ascii_tolower".}
-proc g_ascii_toupper*(c: gchar): gchar{.cdecl, dynlib: gliblib,
-                                        importc: "g_ascii_toupper".}
-proc g_ascii_digit_value*(c: gchar): gint{.cdecl, dynlib: gliblib,
-    importc: "g_ascii_digit_value".}
-proc g_ascii_xdigit_value*(c: gchar): gint{.cdecl, dynlib: gliblib,
-    importc: "g_ascii_xdigit_value".}
-const
-  G_STR_DELIMITERS* = "``-|> <."
-
-proc g_strdelimit*(str: cstring, delimiters: cstring, new_delimiter: gchar): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strdelimit".}
-proc g_strcanon*(str: cstring, valid_chars: cstring, substitutor: gchar): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strcanon".}
-proc g_strerror*(errnum: gint): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strerror".}
-proc g_strsignal*(signum: gint): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strsignal".}
-proc g_strreverse*(str: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strreverse".}
-proc g_strlcpy*(dest: cstring, src: cstring, dest_size: gsize): gsize{.cdecl,
-    dynlib: gliblib, importc: "g_strlcpy".}
-proc g_strlcat*(dest: cstring, src: cstring, dest_size: gsize): gsize{.cdecl,
-    dynlib: gliblib, importc: "g_strlcat".}
-proc g_strstr_len*(haystack: cstring, haystack_len: gssize, needle: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strstr_len".}
-proc g_strrstr*(haystack: cstring, needle: cstring): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_strrstr".}
-proc g_strrstr_len*(haystack: cstring, haystack_len: gssize, needle: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strrstr_len".}
-proc g_str_has_suffix*(str: cstring, suffix: cstring): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_str_has_suffix".}
-proc g_str_has_prefix*(str: cstring, prefix: cstring): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_str_has_prefix".}
-proc g_strtod*(nptr: cstring, endptr: PPgchar): gdouble{.cdecl, dynlib: gliblib,
-    importc: "g_strtod".}
-proc g_ascii_strtod*(nptr: cstring, endptr: PPgchar): gdouble{.cdecl,
-    dynlib: gliblib, importc: "g_ascii_strtod".}
-const
-  G_ASCII_DTOSTR_BUF_SIZE* = 29 + 10
-
-proc g_ascii_dtostr*(buffer: cstring, buf_len: gint, d: gdouble): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_ascii_dtostr".}
-proc g_ascii_formatd*(buffer: cstring, buf_len: gint, format: cstring,
-                      d: gdouble): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_ascii_formatd".}
-proc g_strchug*(str: cstring): cstring{.cdecl, dynlib: gliblib,
-                                        importc: "g_strchug".}
-proc g_strchomp*(str: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strchomp".}
-proc g_ascii_strcasecmp*(s1: cstring, s2: cstring): gint{.cdecl,
-    dynlib: gliblib, importc: "g_ascii_strcasecmp".}
-proc g_ascii_strncasecmp*(s1: cstring, s2: cstring, n: gsize): gint{.cdecl,
-    dynlib: gliblib, importc: "g_ascii_strncasecmp".}
-proc g_ascii_strdown*(str: cstring, len: gssize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_ascii_strdown".}
-proc g_ascii_strup*(str: cstring, len: gssize): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_ascii_strup".}
-proc g_strdup*(str: cstring): cstring{.cdecl, dynlib: gliblib,
-                                       importc: "g_strdup".}
-proc g_strndup*(str: cstring, n: gsize): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strndup".}
-proc g_strnfill*(length: gsize, fill_char: gchar): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_strnfill".}
-proc g_strcompress*(source: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_strcompress".}
-proc g_strescape*(source: cstring, exceptions: cstring): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_strescape".}
-proc g_memdup*(mem: gconstpointer, byte_size: guint): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_memdup".}
-proc g_strsplit*(str: cstring, delimiter: cstring, max_tokens: gint): PPgchar{.
-    cdecl, dynlib: gliblib, importc: "g_strsplit".}
-proc g_strjoinv*(separator: cstring, str_array: PPgchar): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_strjoinv".}
-proc g_strfreev*(str_array: PPgchar){.cdecl, dynlib: gliblib,
-                                      importc: "g_strfreev".}
-proc g_strdupv*(str_array: PPgchar): PPgchar{.cdecl, dynlib: gliblib,
-    importc: "g_strdupv".}
-proc g_stpcpy*(dest: cstring, src: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_stpcpy".}
-proc g_get_user_name*(): cstring{.cdecl, dynlib: gliblib,
-                                  importc: "g_get_user_name".}
-proc g_get_real_name*(): cstring{.cdecl, dynlib: gliblib,
-                                  importc: "g_get_real_name".}
-proc g_get_home_dir*(): cstring{.cdecl, dynlib: gliblib,
-                                 importc: "g_get_home_dir".}
-proc g_get_tmp_dir*(): cstring{.cdecl, dynlib: gliblib, importc: "g_get_tmp_dir".}
-proc g_get_prgname*(): cstring{.cdecl, dynlib: gliblib, importc: "g_get_prgname".}
-proc g_set_prgname*(prgname: cstring){.cdecl, dynlib: gliblib,
-                                       importc: "g_set_prgname".}
-type
-  PGDebugKey* = ptr TGDebugKey
-  TGDebugKey* {.final.} = object
-    key*: cstring
-    value*: guint
-
-
-proc g_parse_debug_string*(str: cstring, keys: PGDebugKey, nkeys: guint): guint{.
-    cdecl, dynlib: gliblib, importc: "g_parse_debug_string".}
-proc g_path_is_absolute*(file_name: cstring): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_path_is_absolute".}
-proc g_path_skip_root*(file_name: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_path_skip_root".}
-proc g_basename*(file_name: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_basename".}
-proc g_dirname*(file_name: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_path_get_dirname".}
-proc g_get_current_dir*(): cstring{.cdecl, dynlib: gliblib,
-                                    importc: "g_get_current_dir".}
-proc g_path_get_basename*(file_name: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_path_get_basename".}
-proc g_path_get_dirname*(file_name: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_path_get_dirname".}
-proc g_nullify_pointer*(nullify_location: Pgpointer){.cdecl, dynlib: gliblib,
-    importc: "g_nullify_pointer".}
-proc g_getenv*(variable: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_getenv".}
-type
-  TGVoidFunc* = proc (){.cdecl.}
-
-proc g_atexit*(func: TGVoidFunc){.cdecl, dynlib: gliblib, importc: "g_atexit".}
-proc g_find_program_in_path*(program: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_find_program_in_path".}
-proc g_bit_nth_lsf*(mask: gulong, nth_bit: gint): gint{.cdecl, dynlib: gliblib,
-    importc: "g_bit_nth_lsf".}
-proc g_bit_nth_msf*(mask: gulong, nth_bit: gint): gint{.cdecl, dynlib: gliblib,
-    importc: "g_bit_nth_msf".}
-proc g_bit_storage*(number: gulong): guint{.cdecl, dynlib: gliblib,
-    importc: "g_bit_storage".}
-type
-  PPGTrashStack* = ptr PGTrashStack
-  PGTrashStack* = ptr TGTrashStack
-  TGTrashStack* {.final.} = object
-    next*: PGTrashStack
-
-
-proc g_trash_stack_push*(stack_p: PPGTrashStack, data_p: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_trash_stack_push".}
-proc g_trash_stack_pop*(stack_p: PPGTrashStack): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_trash_stack_pop".}
-proc g_trash_stack_peek*(stack_p: PPGTrashStack): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_trash_stack_peek".}
-proc g_trash_stack_height*(stack_p: PPGTrashStack): guint{.cdecl,
-    dynlib: gliblib, importc: "g_trash_stack_height".}
-type
-  PGHashTable* = pointer
-  TGHRFunc* = proc (key, value, user_data: gpointer): gboolean{.cdecl.}
-
-proc g_hash_table_new*(hash_func: TGHashFunc, key_equal_func: TGEqualFunc): PGHashTable{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_new".}
-proc g_hash_table_new_full*(hash_func: TGHashFunc, key_equal_func: TGEqualFunc,
-                            key_destroy_func: TGDestroyNotify,
-                            value_destroy_func: TGDestroyNotify): PGHashTable{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_new_full".}
-proc g_hash_table_destroy*(hash_table: PGHashTable){.cdecl, dynlib: gliblib,
-    importc: "g_hash_table_destroy".}
-proc g_hash_table_insert*(hash_table: PGHashTable, key: gpointer,
-                          value: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_hash_table_insert".}
-proc g_hash_table_replace*(hash_table: PGHashTable, key: gpointer,
-                           value: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_hash_table_replace".}
-proc g_hash_table_remove*(hash_table: PGHashTable, key: gconstpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_remove".}
-proc g_hash_table_steal*(hash_table: PGHashTable, key: gconstpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_steal".}
-proc g_hash_table_lookup*(hash_table: PGHashTable, key: gconstpointer): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_lookup".}
-proc g_hash_table_lookup_extended*(hash_table: PGHashTable,
-                                   lookup_key: gconstpointer,
-                                   orig_key: Pgpointer, value: Pgpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_lookup_extended".}
-proc g_hash_table_foreach*(hash_table: PGHashTable, func: TGHFunc,
-                           user_data: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_hash_table_foreach".}
-proc g_hash_table_foreach_remove*(hash_table: PGHashTable, func: TGHRFunc,
-                                  user_data: gpointer): guint{.cdecl,
-    dynlib: gliblib, importc: "g_hash_table_foreach_remove".}
-proc g_hash_table_foreach_steal*(hash_table: PGHashTable, func: TGHRFunc,
-                                 user_data: gpointer): guint{.cdecl,
-    dynlib: gliblib, importc: "g_hash_table_foreach_steal".}
-proc g_hash_table_size*(hash_table: PGHashTable): guint{.cdecl, dynlib: gliblib,
-    importc: "g_hash_table_size".}
-proc g_str_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_str_equal".}
-proc g_str_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib,
-    importc: "g_str_hash".}
-proc g_int_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_int_equal".}
-proc g_int_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib,
-    importc: "g_int_hash".}
-proc g_direct_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib,
-    importc: "g_direct_hash".}
-proc g_direct_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_direct_equal".}
-proc g_quark_try_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib,
-    importc: "g_quark_try_string".}
-proc g_quark_from_static_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib,
-    importc: "g_quark_from_static_string".}
-proc g_quark_from_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib,
-    importc: "g_quark_from_string".}
-proc g_quark_to_string*(quark: TGQuark): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_quark_to_string".}
-const
-  G_MEM_ALIGN* = GLIB_SIZEOF_VOID_P
-
-type
-  PGMemVTable* = ptr TGMemVTable
-  TGMemVTable* {.final.} = object
-    malloc*: proc (n_bytes: gsize): gpointer{.cdecl.}
-    realloc*: proc (mem: gpointer, n_bytes: gsize): gpointer{.cdecl.}
-    free*: proc (mem: gpointer){.cdecl.}
-    calloc*: proc (n_blocks: gsize, n_block_bytes: gsize): gpointer{.cdecl.}
-    try_malloc*: proc (n_bytes: gsize): gpointer{.cdecl.}
-    try_realloc*: proc (mem: gpointer, n_bytes: gsize): gpointer{.cdecl.}
-
-  PGMemChunk* = pointer
-  PGAllocator* = pointer
-
-proc g_malloc*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_malloc".}
-proc g_malloc0*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_malloc0".}
-proc g_realloc*(mem: gpointer, n_bytes: gulong): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_realloc".}
-proc g_free*(mem: gpointer){.cdecl, dynlib: gliblib, importc: "g_free".}
-proc g_try_malloc*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_try_malloc".}
-proc g_try_realloc*(mem: gpointer, n_bytes: gulong): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_try_realloc".}
-#proc g_new*(bytes_per_struct, n_structs: gsize): gpointer
-#proc g_new0*(bytes_per_struct, n_structs: gsize): gpointer
-#proc g_renew*(struct_size: gsize, OldMem: gpointer, n_structs: gsize): gpointer
-proc g_mem_set_vtable*(vtable: PGMemVTable){.cdecl, dynlib: gliblib,
-    importc: "g_mem_set_vtable".}
-proc g_mem_is_system_malloc*(): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_mem_is_system_malloc".}
-proc g_mem_profile*(){.cdecl, dynlib: gliblib, importc: "g_mem_profile".}
-proc g_chunk_new*(chunk: Pointer): Pointer
-proc g_chunk_new0*(chunk: Pointer): Pointer
-proc g_chunk_free*(mem_chunk: PGMemChunk, mem: gpointer)
-const
-  G_ALLOC_ONLY* = 1
-  G_ALLOC_AND_FREE* = 2
-
-proc g_mem_chunk_new*(name: cstring, atom_size: gint, area_size: gulong,
-                      theType: gint): PGMemChunk{.cdecl, dynlib: gliblib,
-    importc: "g_mem_chunk_new".}
-proc g_mem_chunk_destroy*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib,
-    importc: "g_mem_chunk_destroy".}
-proc g_mem_chunk_alloc*(mem_chunk: PGMemChunk): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_mem_chunk_alloc".}
-proc g_mem_chunk_alloc0*(mem_chunk: PGMemChunk): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_mem_chunk_alloc0".}
-proc g_mem_chunk_free*(mem_chunk: PGMemChunk, mem: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_mem_chunk_free".}
-proc g_mem_chunk_clean*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib,
-    importc: "g_mem_chunk_clean".}
-proc g_mem_chunk_reset*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib,
-    importc: "g_mem_chunk_reset".}
-proc g_mem_chunk_print*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib,
-    importc: "g_mem_chunk_print".}
-proc g_mem_chunk_info*(){.cdecl, dynlib: gliblib, importc: "g_mem_chunk_info".}
-proc g_blow_chunks*(){.cdecl, dynlib: gliblib, importc: "g_blow_chunks".}
-proc g_allocator_new*(name: cstring, n_preallocs: guint): PGAllocator{.cdecl,
-    dynlib: gliblib, importc: "g_allocator_new".}
-proc g_allocator_free*(allocator: PGAllocator){.cdecl, dynlib: gliblib,
-    importc: "g_allocator_free".}
-const
-  G_ALLOCATOR_LIST* = 1
-  G_ALLOCATOR_SLIST* = 2
-  G_ALLOCATOR_NODE* = 3
-
-proc g_slist_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib,
-    importc: "g_slist_push_allocator".}
-proc g_slist_pop_allocator*(){.cdecl, dynlib: gliblib,
-                               importc: "g_slist_pop_allocator".}
-proc g_slist_alloc*(): PGSList{.cdecl, dynlib: gliblib, importc: "g_slist_alloc".}
-proc g_slist_free*(list: PGSList){.cdecl, dynlib: gliblib,
-                                   importc: "g_slist_free".}
-proc g_slist_free_1*(list: PGSList){.cdecl, dynlib: gliblib,
-                                     importc: "g_slist_free_1".}
-proc g_slist_append*(list: PGSList, data: gpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_append".}
-proc g_slist_prepend*(list: PGSList, data: gpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_prepend".}
-proc g_slist_insert*(list: PGSList, data: gpointer, position: gint): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert".}
-proc g_slist_insert_sorted*(list: PGSList, data: gpointer, func: TGCompareFunc): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert_sorted".}
-proc g_slist_insert_before*(slist: PGSList, sibling: PGSList, data: gpointer): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert_before".}
-proc g_slist_concat*(list1: PGSList, list2: PGSList): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_concat".}
-proc g_slist_remove*(list: PGSList, data: gconstpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_remove".}
-proc g_slist_remove_all*(list: PGSList, data: gconstpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_remove_all".}
-proc g_slist_remove_link*(list: PGSList, link: PGSList): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_remove_link".}
-proc g_slist_delete_link*(list: PGSList, link: PGSList): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_delete_link".}
-proc g_slist_reverse*(list: PGSList): PGSList{.cdecl, dynlib: gliblib,
-    importc: "g_slist_reverse".}
-proc g_slist_copy*(list: PGSList): PGSList{.cdecl, dynlib: gliblib,
-    importc: "g_slist_copy".}
-proc g_slist_nth*(list: PGSList, n: guint): PGSList{.cdecl, dynlib: gliblib,
-    importc: "g_slist_nth".}
-proc g_slist_find*(list: PGSList, data: gconstpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_find".}
-proc g_slist_find_custom*(list: PGSList, data: gconstpointer,
-                          func: TGCompareFunc): PGSList{.cdecl, dynlib: gliblib,
-    importc: "g_slist_find_custom".}
-proc g_slist_position*(list: PGSList, llink: PGSList): gint{.cdecl,
-    dynlib: gliblib, importc: "g_slist_position".}
-proc g_slist_index*(list: PGSList, data: gconstpointer): gint{.cdecl,
-    dynlib: gliblib, importc: "g_slist_index".}
-proc g_slist_last*(list: PGSList): PGSList{.cdecl, dynlib: gliblib,
-    importc: "g_slist_last".}
-proc g_slist_length*(list: PGSList): guint{.cdecl, dynlib: gliblib,
-    importc: "g_slist_length".}
-proc g_slist_foreach*(list: PGSList, func: TGFunc, user_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_slist_foreach".}
-proc g_slist_sort*(list: PGSList, compare_func: TGCompareFunc): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_sort".}
-proc g_slist_sort_with_data*(list: PGSList, compare_func: TGCompareDataFunc,
-                             user_data: gpointer): PGSList{.cdecl,
-    dynlib: gliblib, importc: "g_slist_sort_with_data".}
-proc g_slist_nth_data*(list: PGSList, n: guint): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_slist_nth_data".}
-proc g_slist_next*(slist: PGSList): PGSList
-proc g_list_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib,
-    importc: "g_list_push_allocator".}
-proc g_list_pop_allocator*(){.cdecl, dynlib: gliblib,
-                              importc: "g_list_pop_allocator".}
-proc g_list_alloc*(): PGList{.cdecl, dynlib: gliblib, importc: "g_list_alloc".}
-proc g_list_free*(list: PGList){.cdecl, dynlib: gliblib, importc: "g_list_free".}
-proc g_list_free_1*(list: PGList){.cdecl, dynlib: gliblib,
-                                   importc: "g_list_free_1".}
-proc g_list_append*(list: PGList, data: gpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_append".}
-proc g_list_prepend*(list: PGList, data: gpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_prepend".}
-proc g_list_insert*(list: PGList, data: gpointer, position: gint): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert".}
-proc g_list_insert_sorted*(list: PGList, data: gpointer, func: TGCompareFunc): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert_sorted".}
-proc g_list_insert_before*(list: PGList, sibling: PGList, data: gpointer): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert_before".}
-proc g_list_concat*(list1: PGList, list2: PGList): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_concat".}
-proc g_list_remove*(list: PGList, data: gconstpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_remove".}
-proc g_list_remove_all*(list: PGList, data: gconstpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_remove_all".}
-proc g_list_remove_link*(list: PGList, llink: PGList): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_remove_link".}
-proc g_list_delete_link*(list: PGList, link: PGList): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_delete_link".}
-proc g_list_reverse*(list: PGList): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_reverse".}
-proc g_list_copy*(list: PGList): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_copy".}
-proc g_list_nth*(list: PGList, n: guint): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_nth".}
-proc g_list_nth_prev*(list: PGList, n: guint): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_nth_prev".}
-proc g_list_find*(list: PGList, data: gconstpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_find".}
-proc g_list_find_custom*(list: PGList, data: gconstpointer, func: TGCompareFunc): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_find_custom".}
-proc g_list_position*(list: PGList, llink: PGList): gint{.cdecl,
-    dynlib: gliblib, importc: "g_list_position".}
-proc g_list_index*(list: PGList, data: gconstpointer): gint{.cdecl,
-    dynlib: gliblib, importc: "g_list_index".}
-proc g_list_last*(list: PGList): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_last".}
-proc g_list_first*(list: PGList): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_list_first".}
-proc g_list_length*(list: PGList): guint{.cdecl, dynlib: gliblib,
-    importc: "g_list_length".}
-proc g_list_foreach*(list: PGList, func: TGFunc, user_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_list_foreach".}
-proc g_list_sort*(list: PGList, compare_func: TGCompareFunc): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_sort".}
-proc g_list_sort_with_data*(list: PGList, compare_func: TGCompareDataFunc,
-                            user_data: gpointer): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_list_sort_with_data".}
-proc g_list_nth_data*(list: PGList, n: guint): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_list_nth_data".}
-proc g_list_previous*(list: PGList): PGList
-proc g_list_next*(list: PGList): PGList
-type
-  PGCache* = pointer
-  TGCacheNewFunc* = proc (key: gpointer): gpointer{.cdecl.}
-  TGCacheDupFunc* = proc (value: gpointer): gpointer{.cdecl.}
-  TGCacheDestroyFunc* = proc (value: gpointer){.cdecl.}
-
-proc g_cache_new*(value_new_func: TGCacheNewFunc,
-                  value_destroy_func: TGCacheDestroyFunc,
-                  key_dup_func: TGCacheDupFunc,
-                  key_destroy_func: TGCacheDestroyFunc,
-                  hash_key_func: TGHashFunc, hash_value_func: TGHashFunc,
-                  key_equal_func: TGEqualFunc): PGCache{.cdecl, dynlib: gliblib,
-    importc: "g_cache_new".}
-proc g_cache_destroy*(cache: PGCache){.cdecl, dynlib: gliblib,
-                                       importc: "g_cache_destroy".}
-proc g_cache_insert*(cache: PGCache, key: gpointer): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_cache_insert".}
-proc g_cache_remove*(cache: PGCache, value: gconstpointer){.cdecl,
-    dynlib: gliblib, importc: "g_cache_remove".}
-proc g_cache_key_foreach*(cache: PGCache, func: TGHFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_cache_key_foreach".}
-proc g_cache_value_foreach*(cache: PGCache, func: TGHFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_cache_value_foreach".}
-type
-  PGCompletionFunc* = ptr TGCompletionFunc
-  TGCompletionFunc* = gchar
-  TGCompletionStrncmpFunc* = proc (s1: cstring, s2: cstring, n: gsize): gint{.
-      cdecl.}
-  PGCompletion* = ptr TGCompletion
-  TGCompletion* {.final.} = object
-    items*: PGList
-    func*: TGCompletionFunc
-    prefix*: cstring
-    cache*: PGList
-    strncmp_func*: TGCompletionStrncmpFunc
-
-
-proc g_completion_new*(func: TGCompletionFunc): PGCompletion{.cdecl,
-    dynlib: gliblib, importc: "g_completion_new".}
-proc g_completion_add_items*(cmp: PGCompletion, items: PGList){.cdecl,
-    dynlib: gliblib, importc: "g_completion_add_items".}
-proc g_completion_remove_items*(cmp: PGCompletion, items: PGList){.cdecl,
-    dynlib: gliblib, importc: "g_completion_remove_items".}
-proc g_completion_clear_items*(cmp: PGCompletion){.cdecl, dynlib: gliblib,
-    importc: "g_completion_clear_items".}
-proc g_completion_complete*(cmp: PGCompletion, prefix: cstring,
-                            new_prefix: PPgchar): PGList{.cdecl,
-    dynlib: gliblib, importc: "g_completion_complete".}
-proc g_completion_set_compare*(cmp: PGCompletion,
-                               strncmp_func: TGCompletionStrncmpFunc){.cdecl,
-    dynlib: gliblib, importc: "g_completion_set_compare".}
-proc g_completion_free*(cmp: PGCompletion){.cdecl, dynlib: gliblib,
-    importc: "g_completion_free".}
-type
-  PGConvertError* = ptr TGConvertError
-  TGConvertError* = enum
-    G_CONVERT_ERROR_NO_CONVERSION, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
-    G_CONVERT_ERROR_FAILED, G_CONVERT_ERROR_PARTIAL_INPUT,
-    G_CONVERT_ERROR_BAD_URI, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
-
-proc G_CONVERT_ERROR*(): TGQuark
-proc g_convert_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-                                        importc: "g_convert_error_quark".}
-type
-  PGIConv* = ptr TGIConv
-  TGIConv* = pointer
-
-proc g_iconv_open*(to_codeset: cstring, from_codeset: cstring): TGIConv{.cdecl,
-    dynlib: gliblib, importc: "g_iconv_open".}
-proc g_iconv*(`converter`: TGIConv, inbuf: PPgchar, inbytes_left: Pgsize,
-              outbuf: PPgchar, outbytes_left: Pgsize): gsize{.cdecl,
-    dynlib: gliblib, importc: "g_iconv".}
-proc g_iconv_close*(`converter`: TGIConv): gint{.cdecl, dynlib: gliblib,
-    importc: "g_iconv_close".}
-proc g_convert*(str: cstring, len: gssize, to_codeset: cstring,
-                from_codeset: cstring, bytes_read: Pgsize,
-                bytes_written: Pgsize, error: pointer): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_convert".}
-proc g_convert_with_iconv*(str: cstring, len: gssize, `converter`: TGIConv,
-                           bytes_read: Pgsize, bytes_written: Pgsize,
-                           error: pointer): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_convert_with_iconv".}
-proc g_convert_with_fallback*(str: cstring, len: gssize, to_codeset: cstring,
-                              from_codeset: cstring, fallback: cstring,
-                              bytes_read: Pgsize, bytes_written: Pgsize,
-                              error: pointer): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_convert_with_fallback".}
-proc g_locale_to_utf8*(opsysstring: cstring, len: gssize, bytes_read: Pgsize,
-                       bytes_written: Pgsize, error: pointer): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_locale_to_utf8".}
-proc g_locale_from_utf8*(utf8string: cstring, len: gssize, bytes_read: Pgsize,
-                         bytes_written: Pgsize, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_locale_from_utf8".}
-proc g_filename_to_utf8*(opsysstring: cstring, len: gssize, bytes_read: Pgsize,
-                         bytes_written: Pgsize, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_to_utf8".}
-proc g_filename_from_utf8*(utf8string: cstring, len: gssize, bytes_read: Pgsize,
-                           bytes_written: Pgsize, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_from_utf8".}
-proc g_filename_from_uri*(uri: cstring, hostname: PPchar, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_from_uri".}
-proc g_filename_to_uri*(filename: cstring, hostname: cstring, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_to_uri".}
-type
-  TGDataForeachFunc* = proc (key_id: TGQuark, data: gpointer,
-                             user_data: gpointer){.cdecl.}
-
-proc g_datalist_init*(datalist: PPGData){.cdecl, dynlib: gliblib,
-    importc: "g_datalist_init".}
-proc g_datalist_clear*(datalist: PPGData){.cdecl, dynlib: gliblib,
-    importc: "g_datalist_clear".}
-proc g_datalist_id_get_data*(datalist: PPGData, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_get_data".}
-proc g_datalist_id_set_data_full*(datalist: PPGData, key_id: TGQuark,
-                                  data: gpointer, destroy_func: TGDestroyNotify){.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_set_data_full".}
-proc g_datalist_id_remove_no_notify*(datalist: PPGData, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_remove_no_notify".}
-proc g_datalist_foreach*(datalist: PPGData, func: TGDataForeachFunc,
-                         user_data: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_datalist_foreach".}
-proc g_datalist_id_set_data*(datalist: PPGData, key_id: TGQuark, data: gpointer)
-proc g_datalist_id_remove_data*(datalist: PPGData, key_id: TGQuark)
-proc g_datalist_get_data*(datalist: PPGData, key_str: cstring): PPGData
-proc g_datalist_set_data_full*(datalist: PPGData, key_str: cstring,
-                               data: gpointer, destroy_func: TGDestroyNotify)
-proc g_datalist_set_data*(datalist: PPGData, key_str: cstring, data: gpointer)
-proc g_datalist_remove_no_notify*(datalist: PPGData, key_str: cstring)
-proc g_datalist_remove_data*(datalist: PPGData, key_str: cstring)
-proc g_dataset_id_get_data*(dataset_location: gconstpointer, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_dataset_id_get_data".}
-proc g_dataset_id_set_data_full*(dataset_location: gconstpointer,
-                                 key_id: TGQuark, data: gpointer,
-                                 destroy_func: TGDestroyNotify){.cdecl,
-    dynlib: gliblib, importc: "g_dataset_id_set_data_full".}
-proc g_dataset_id_remove_no_notify*(dataset_location: gconstpointer,
-                                    key_id: TGQuark): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_dataset_id_remove_no_notify".}
-proc g_dataset_foreach*(dataset_location: gconstpointer,
-                        func: TGDataForeachFunc, user_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_dataset_foreach".}
-proc g_dataset_id_set_data*(location: gconstpointer, key_id: TGQuark,
-                            data: gpointer)
-proc g_dataset_id_remove_data*(location: gconstpointer, key_id: TGQuark)
-proc g_dataset_get_data*(location: gconstpointer, key_str: cstring): gpointer
-proc g_dataset_set_data_full*(location: gconstpointer, key_str: cstring,
-                              data: gpointer, destroy_func: TGDestroyNotify)
-proc g_dataset_remove_no_notify*(location: gconstpointer, key_str: cstring)
-proc g_dataset_set_data*(location: gconstpointer, key_str: cstring,
-                         data: gpointer)
-proc g_dataset_remove_data*(location: gconstpointer, key_str: cstring)
-type
-  PGTime* = ptr TGTime
-  TGTime* = gint32
-  PGDateYear* = ptr TGDateYear
-  TGDateYear* = guint16
-  PGDateDay* = ptr TGDateDay
-  TGDateDay* = guint8
-  Ptm* = ptr Ttm
-  Ttm* {.final.} = object
-    tm_sec*: gint
-    tm_min*: gint
-    tm_hour*: gint
-    tm_mday*: gint
-    tm_mon*: gint
-    tm_year*: gint
-    tm_wday*: gint
-    tm_yday*: gint
-    tm_isdst*: gint
-    tm_gmtoff*: glong
-    tm_zone*: cstring
-
-
-type
-  PGDateDMY* = ptr TGDateDMY
-  TGDateDMY* = int
-
-const
-  G_DATE_DAY* = 0
-  G_DATE_MONTH* = 1
-  G_DATE_YEAR* = 2
-
-type
-  PGDateWeekday* = ptr TGDateWeekday
-  TGDateWeekday* = int
-
-const
-  G_DATE_BAD_WEEKDAY* = 0
-  G_DATE_MONDAY* = 1
-  G_DATE_TUESDAY* = 2
-  G_DATE_WEDNESDAY* = 3
-  G_DATE_THURSDAY* = 4
-  G_DATE_FRIDAY* = 5
-  G_DATE_SATURDAY* = 6
-  G_DATE_SUNDAY* = 7
-
-type
-  PGDateMonth* = ptr TGDateMonth
-  TGDateMonth* = int
-
-const
-  G_DATE_BAD_MONTH* = 0
-  G_DATE_JANUARY* = 1
-  G_DATE_FEBRUARY* = 2
-  G_DATE_MARCH* = 3
-  G_DATE_APRIL* = 4
-  G_DATE_MAY* = 5
-  G_DATE_JUNE* = 6
-  G_DATE_JULY* = 7
-  G_DATE_AUGUST* = 8
-  G_DATE_SEPTEMBER* = 9
-  G_DATE_OCTOBER* = 10
-  G_DATE_NOVEMBER* = 11
-  G_DATE_DECEMBER* = 12
-
-const
-  G_DATE_BAD_JULIAN* = 0
-  G_DATE_BAD_DAY* = 0
-  G_DATE_BAD_YEAR* = 0
-
-type
-  PGDate* = ptr TGDate
-  TGDate* {.final.} = object
-    flag0*: int32
-    flag1*: int32
-
-
-proc g_date_new*(): PGDate{.cdecl, dynlib: gliblib, importc: "g_date_new".}
-proc g_date_new_dmy*(day: TGDateDay, month: TGDateMonth, year: TGDateYear): PGDate{.
-    cdecl, dynlib: gliblib, importc: "g_date_new_dmy".}
-proc g_date_new_julian*(julian_day: guint32): PGDate{.cdecl, dynlib: gliblib,
-    importc: "g_date_new_julian".}
-proc g_date_free*(date: PGDate){.cdecl, dynlib: gliblib, importc: "g_date_free".}
-proc g_date_valid*(date: PGDate): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_valid".}
-proc g_date_valid_month*(month: TGDateMonth): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_valid_month".}
-proc g_date_valid_year*(year: TGDateYear): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_valid_year".}
-proc g_date_valid_weekday*(weekday: TGDateWeekday): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_date_valid_weekday".}
-proc g_date_valid_julian*(julian_date: guint32): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_date_valid_julian".}
-proc g_date_get_weekday*(date: PGDate): TGDateWeekday{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_weekday".}
-proc g_date_get_month*(date: PGDate): TGDateMonth{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_month".}
-proc g_date_get_year*(date: PGDate): TGDateYear{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_year".}
-proc g_date_get_day*(date: PGDate): TGDateDay{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_day".}
-proc g_date_get_julian*(date: PGDate): guint32{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_julian".}
-proc g_date_get_day_of_year*(date: PGDate): guint{.cdecl, dynlib: gliblib,
-    importc: "g_date_get_day_of_year".}
-proc g_date_get_monday_week_of_year*(date: PGDate): guint{.cdecl,
-    dynlib: gliblib, importc: "g_date_get_monday_week_of_year".}
-proc g_date_get_sunday_week_of_year*(date: PGDate): guint{.cdecl,
-    dynlib: gliblib, importc: "g_date_get_sunday_week_of_year".}
-proc g_date_clear*(date: PGDate, n_dates: guint){.cdecl, dynlib: gliblib,
-    importc: "g_date_clear".}
-proc g_date_set_parse*(date: PGDate, str: cstring){.cdecl, dynlib: gliblib,
-    importc: "g_date_set_parse".}
-proc g_date_set_time*(date: PGDate, time: TGTime){.cdecl, dynlib: gliblib,
-    importc: "g_date_set_time".}
-proc g_date_set_month*(date: PGDate, month: TGDateMonth){.cdecl,
-    dynlib: gliblib, importc: "g_date_set_month".}
-proc g_date_set_day*(date: PGDate, day: TGDateDay){.cdecl, dynlib: gliblib,
-    importc: "g_date_set_day".}
-proc g_date_set_year*(date: PGDate, year: TGDateYear){.cdecl, dynlib: gliblib,
-    importc: "g_date_set_year".}
-proc g_date_set_dmy*(date: PGDate, day: TGDateDay, month: TGDateMonth,
-                     y: TGDateYear){.cdecl, dynlib: gliblib,
-                                     importc: "g_date_set_dmy".}
-proc g_date_set_julian*(date: PGDate, julian_date: guint32){.cdecl,
-    dynlib: gliblib, importc: "g_date_set_julian".}
-proc g_date_is_first_of_month*(date: PGDate): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_is_first_of_month".}
-proc g_date_is_last_of_month*(date: PGDate): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_is_last_of_month".}
-proc g_date_add_days*(date: PGDate, n_days: guint){.cdecl, dynlib: gliblib,
-    importc: "g_date_add_days".}
-proc g_date_subtract_days*(date: PGDate, n_days: guint){.cdecl, dynlib: gliblib,
-    importc: "g_date_subtract_days".}
-proc g_date_add_months*(date: PGDate, n_months: guint){.cdecl, dynlib: gliblib,
-    importc: "g_date_add_months".}
-proc g_date_subtract_months*(date: PGDate, n_months: guint){.cdecl,
-    dynlib: gliblib, importc: "g_date_subtract_months".}
-proc g_date_add_years*(date: PGDate, n_years: guint){.cdecl, dynlib: gliblib,
-    importc: "g_date_add_years".}
-proc g_date_subtract_years*(date: PGDate, n_years: guint){.cdecl,
-    dynlib: gliblib, importc: "g_date_subtract_years".}
-proc g_date_is_leap_year*(year: TGDateYear): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_date_is_leap_year".}
-proc g_date_get_days_in_month*(month: TGDateMonth, year: TGDateYear): guint8{.
-    cdecl, dynlib: gliblib, importc: "g_date_get_days_in_month".}
-proc g_date_get_monday_weeks_in_year*(year: TGDateYear): guint8{.cdecl,
-    dynlib: gliblib, importc: "g_date_get_monday_weeks_in_year".}
-proc g_date_get_sunday_weeks_in_year*(year: TGDateYear): guint8{.cdecl,
-    dynlib: gliblib, importc: "g_date_get_sunday_weeks_in_year".}
-proc g_date_days_between*(date1: PGDate, date2: PGDate): gint{.cdecl,
-    dynlib: gliblib, importc: "g_date_days_between".}
-proc g_date_compare*(lhs: PGDate, rhs: PGDate): gint{.cdecl, dynlib: gliblib,
-    importc: "g_date_compare".}
-proc g_date_to_struct_tm*(date: PGDate, tm: Ptm){.cdecl, dynlib: gliblib,
-    importc: "g_date_to_struct_tm".}
-proc g_date_clamp*(date: PGDate, min_date: PGDate, max_date: PGDate){.cdecl,
-    dynlib: gliblib, importc: "g_date_clamp".}
-proc g_date_order*(date1: PGDate, date2: PGDate){.cdecl, dynlib: gliblib,
-    importc: "g_date_order".}
-proc g_date_strftime*(s: cstring, slen: gsize, format: cstring, date: PGDate): gsize{.
-    cdecl, dynlib: gliblib, importc: "g_date_strftime".}
-type
-  PGDir* = pointer
-
-proc g_dir_open*(path: cstring, flags: guint, error: pointer): PGDir{.cdecl,
-    dynlib: gliblib, importc: "g_dir_open".}
-proc g_dir_read_name*(dir: PGDir): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_dir_read_name".}
-proc g_dir_rewind*(dir: PGDir){.cdecl, dynlib: gliblib, importc: "g_dir_rewind".}
-proc g_dir_close*(dir: PGDir){.cdecl, dynlib: gliblib, importc: "g_dir_close".}
-type
-  PGFileError* = ptr TGFileError
-  TGFileError* = gint
-
-type
-  PGFileTest* = ptr TGFileTest
-  TGFileTest* = int
-
-const
-  G_FILE_TEST_IS_REGULAR* = 1 shl 0
-  G_FILE_TEST_IS_SYMLINK* = 1 shl 1
-  G_FILE_TEST_IS_DIR* = 1 shl 2
-  G_FILE_TEST_IS_EXECUTABLE* = 1 shl 3
-  G_FILE_TEST_EXISTS* = 1 shl 4
-
-const
-  G_FILE_ERROR_EXIST* = 0
-  G_FILE_ERROR_ISDIR* = 1
-  G_FILE_ERROR_ACCES* = 2
-  G_FILE_ERROR_NAMETOOLONG* = 3
-  G_FILE_ERROR_NOENT* = 4
-  G_FILE_ERROR_NOTDIR* = 5
-  G_FILE_ERROR_NXIO* = 6
-  G_FILE_ERROR_NODEV* = 7
-  G_FILE_ERROR_ROFS* = 8
-  G_FILE_ERROR_TXTBSY* = 9
-  G_FILE_ERROR_FAULT* = 10
-  G_FILE_ERROR_LOOP* = 11
-  G_FILE_ERROR_NOSPC* = 12
-  G_FILE_ERROR_NOMEM* = 13
-  G_FILE_ERROR_MFILE* = 14
-  G_FILE_ERROR_NFILE* = 15
-  G_FILE_ERROR_BADF* = 16
-  G_FILE_ERROR_INVAL* = 17
-  G_FILE_ERROR_PIPE* = 18
-  G_FILE_ERROR_AGAIN* = 19
-  G_FILE_ERROR_INTR* = 20
-  G_FILE_ERROR_IO* = 21
-  G_FILE_ERROR_PERM* = 22
-  G_FILE_ERROR_FAILED* = 23
-
-proc G_FILE_ERROR*(): TGQuark
-proc g_file_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-                                     importc: "g_file_error_quark".}
-proc g_file_error_from_errno*(err_no: gint): TGFileError{.cdecl,
-    dynlib: gliblib, importc: "g_file_error_from_errno".}
-proc g_file_test*(filename: cstring, test: TGFileTest): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_file_test".}
-proc g_file_get_contents*(filename: cstring, contents: PPgchar, length: Pgsize,
-                          error: pointer): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_file_get_contents".}
-proc g_mkstemp*(tmpl: cstring): int32{.cdecl, dynlib: gliblib,
-                                       importc: "g_mkstemp".}
-proc g_file_open_tmp*(tmpl: cstring, name_used: PPchar, error: pointer): int32{.
-    cdecl, dynlib: gliblib, importc: "g_file_open_tmp".}
-type
-  PGHook* = ptr TGHook
-  TGHook* {.final.} = object
-    data*: gpointer
-    next*: PGHook
-    prev*: PGHook
-    ref_count*: guint
-    hook_id*: gulong
-    flags*: guint
-    func*: gpointer
-    destroy*: TGDestroyNotify
-
-  PGHookList* = ptr TGHookList
-  TGHookCompareFunc* = proc (new_hook: PGHook, sibling: PGHook): gint{.cdecl.}
-  TGHookFindFunc* = proc (hook: PGHook, data: gpointer): gboolean{.cdecl.}
-  TGHookMarshaller* = proc (hook: PGHook, marshal_data: gpointer){.cdecl.}
-  TGHookCheckMarshaller* = proc (hook: PGHook, marshal_data: gpointer): gboolean{.
-      cdecl.}
-  TGHookFunc* = proc (data: gpointer){.cdecl.}
-  TGHookCheckFunc* = proc (data: gpointer): gboolean{.cdecl.}
-  TGHookFinalizeFunc* = proc (hook_list: PGHookList, hook: PGHook){.cdecl.}
-  TGHookList* {.final.} = object
-    seq_id*: gulong
-    flag0*: int32
-    hooks*: PGHook
-    hook_memchunk*: PGMemChunk
-    finalize_hook*: TGHookFinalizeFunc
-    dummy*: array[0..1, gpointer]
-
-
-type
-  PGHookFlagMask* = ptr TGHookFlagMask
-  TGHookFlagMask* = int
-
-const
-  G_HOOK_FLAG_ACTIVE* = 1'i32 shl 0'i32
-  G_HOOK_FLAG_IN_CALL* = 1'i32 shl 1'i32
-  G_HOOK_FLAG_MASK* = 0x0000000F'i32
-
-const
-  G_HOOK_FLAG_USER_SHIFT* = 4'i32
-  bm_TGHookList_hook_size* = 0x0000FFFF'i32
-  bp_TGHookList_hook_size* = 0'i32
-  bm_TGHookList_is_setup* = 0x00010000'i32
-  bp_TGHookList_is_setup* = 16'i32
-
-proc TGHookList_hook_size*(a: var TGHookList): guint
-proc TGHookList_set_hook_size*(a: var TGHookList, `hook_size`: guint)
-proc TGHookList_is_setup*(a: var TGHookList): guint
-proc TGHookList_set_is_setup*(a: var TGHookList, `is_setup`: guint)
-proc G_HOOK*(hook: pointer): PGHook
-proc G_HOOK_FLAGS*(hook: PGHook): guint
-proc G_HOOK_ACTIVE*(hook: PGHook): bool
-proc G_HOOK_IN_CALL*(hook: PGHook): bool
-proc G_HOOK_IS_VALID*(hook: PGHook): bool
-proc G_HOOK_IS_UNLINKED*(hook: PGHook): bool
-proc g_hook_list_init*(hook_list: PGHookList, hook_size: guint){.cdecl,
-    dynlib: gliblib, importc: "g_hook_list_init".}
-proc g_hook_list_clear*(hook_list: PGHookList){.cdecl, dynlib: gliblib,
-    importc: "g_hook_list_clear".}
-proc g_hook_alloc*(hook_list: PGHookList): PGHook{.cdecl, dynlib: gliblib,
-    importc: "g_hook_alloc".}
-proc g_hook_free*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib,
-    importc: "g_hook_free".}
-proc g_hook_ref*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib,
-    importc: "g_hook_ref".}
-proc g_hook_unref*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib,
-    importc: "g_hook_unref".}
-proc g_hook_destroy*(hook_list: PGHookList, hook_id: gulong): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_hook_destroy".}
-proc g_hook_destroy_link*(hook_list: PGHookList, hook: PGHook){.cdecl,
-    dynlib: gliblib, importc: "g_hook_destroy_link".}
-proc g_hook_prepend*(hook_list: PGHookList, hook: PGHook){.cdecl,
-    dynlib: gliblib, importc: "g_hook_prepend".}
-proc g_hook_insert_before*(hook_list: PGHookList, sibling: PGHook, hook: PGHook){.
-    cdecl, dynlib: gliblib, importc: "g_hook_insert_before".}
-proc g_hook_insert_sorted*(hook_list: PGHookList, hook: PGHook,
-                           func: TGHookCompareFunc){.cdecl, dynlib: gliblib,
-    importc: "g_hook_insert_sorted".}
-proc g_hook_get*(hook_list: PGHookList, hook_id: gulong): PGHook{.cdecl,
-    dynlib: gliblib, importc: "g_hook_get".}
-proc g_hook_find*(hook_list: PGHookList, need_valids: gboolean,
-                  func: TGHookFindFunc, data: gpointer): PGHook{.cdecl,
-    dynlib: gliblib, importc: "g_hook_find".}
-proc g_hook_find_data*(hook_list: PGHookList, need_valids: gboolean,
-                       data: gpointer): PGHook{.cdecl, dynlib: gliblib,
-    importc: "g_hook_find_data".}
-proc g_hook_find_func*(hook_list: PGHookList, need_valids: gboolean,
-                       func: gpointer): PGHook{.cdecl, dynlib: gliblib,
-    importc: "g_hook_find_func".}
-proc g_hook_find_func_data*(hook_list: PGHookList, need_valids: gboolean,
-                            func: gpointer, data: gpointer): PGHook{.cdecl,
-    dynlib: gliblib, importc: "g_hook_find_func_data".}
-proc g_hook_first_valid*(hook_list: PGHookList, may_be_in_call: gboolean): PGHook{.
-    cdecl, dynlib: gliblib, importc: "g_hook_first_valid".}
-proc g_hook_next_valid*(hook_list: PGHookList, hook: PGHook,
-                        may_be_in_call: gboolean): PGHook{.cdecl,
-    dynlib: gliblib, importc: "g_hook_next_valid".}
-proc g_hook_compare_ids*(new_hook: PGHook, sibling: PGHook): gint{.cdecl,
-    dynlib: gliblib, importc: "g_hook_compare_ids".}
-proc g_hook_append*(hook_list: PGHookList, hook: PGHook)
-proc g_hook_list_invoke_check*(hook_list: PGHookList, may_recurse: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_hook_list_invoke_check".}
-proc g_hook_list_marshal*(hook_list: PGHookList, may_recurse: gboolean,
-                          marshaller: TGHookMarshaller, marshal_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_hook_list_marshal".}
-proc g_hook_list_marshal_check*(hook_list: PGHookList, may_recurse: gboolean,
-                                marshaller: TGHookCheckMarshaller,
-                                marshal_data: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_hook_list_marshal_check".}
-type
-  PGThreadPool* = ptr TGThreadPool
-  TGThreadPool* {.final.} = object
-    func*: TGFunc
-    user_data*: gpointer
-    exclusive*: gboolean
-
-
-proc g_thread_pool_new*(func: TGFunc, user_data: gpointer, max_threads: gint,
-                        exclusive: gboolean, error: pointer): PGThreadPool{.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_new".}
-proc g_thread_pool_push*(pool: PGThreadPool, data: gpointer, error: pointer){.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_push".}
-proc g_thread_pool_set_max_threads*(pool: PGThreadPool, max_threads: gint,
-                                    error: pointer){.cdecl, dynlib: gliblib,
-    importc: "g_thread_pool_set_max_threads".}
-proc g_thread_pool_get_max_threads*(pool: PGThreadPool): gint{.cdecl,
-    dynlib: gliblib, importc: "g_thread_pool_get_max_threads".}
-proc g_thread_pool_get_num_threads*(pool: PGThreadPool): guint{.cdecl,
-    dynlib: gliblib, importc: "g_thread_pool_get_num_threads".}
-proc g_thread_pool_unprocessed*(pool: PGThreadPool): guint{.cdecl,
-    dynlib: gliblib, importc: "g_thread_pool_unprocessed".}
-proc g_thread_pool_free*(pool: PGThreadPool, immediate: gboolean, wait: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_free".}
-proc g_thread_pool_set_max_unused_threads*(max_threads: gint){.cdecl,
-    dynlib: gliblib, importc: "g_thread_pool_set_max_unused_threads".}
-proc g_thread_pool_get_max_unused_threads*(): gint{.cdecl, dynlib: gliblib,
-    importc: "g_thread_pool_get_max_unused_threads".}
-proc g_thread_pool_get_num_unused_threads*(): guint{.cdecl, dynlib: gliblib,
-    importc: "g_thread_pool_get_num_unused_threads".}
-proc g_thread_pool_stop_unused_threads*(){.cdecl, dynlib: gliblib,
-    importc: "g_thread_pool_stop_unused_threads".}
-type
-  PGTimer* = pointer
-
-const
-  G_USEC_PER_SEC* = 1000000
-
-proc g_timer_new*(): PGTimer{.cdecl, dynlib: gliblib, importc: "g_timer_new".}
-proc g_timer_destroy*(timer: PGTimer){.cdecl, dynlib: gliblib,
-                                       importc: "g_timer_destroy".}
-proc g_timer_start*(timer: PGTimer){.cdecl, dynlib: gliblib,
-                                     importc: "g_timer_start".}
-proc g_timer_stop*(timer: PGTimer){.cdecl, dynlib: gliblib,
-                                    importc: "g_timer_stop".}
-proc g_timer_reset*(timer: PGTimer){.cdecl, dynlib: gliblib,
-                                     importc: "g_timer_reset".}
-proc g_timer_elapsed*(timer: PGTimer, microseconds: Pgulong): gdouble{.cdecl,
-    dynlib: gliblib, importc: "g_timer_elapsed".}
-proc g_usleep*(microseconds: gulong){.cdecl, dynlib: gliblib,
-                                      importc: "g_usleep".}
-proc g_time_val_add*(time: PGTimeVal, microseconds: glong){.cdecl,
-    dynlib: gliblib, importc: "g_time_val_add".}
-type
-  Pgunichar* = ptr gunichar
-  gunichar* = guint32
-  Pgunichar2* = ptr gunichar2
-  gunichar2* = guint16
-  PGUnicodeType* = ptr TGUnicodeType
-  TGUnicodeType* = enum
-    G_UNICODE_CONTROL, G_UNICODE_FORMAT, G_UNICODE_UNASSIGNED,
-    G_UNICODE_PRIVATE_USE, G_UNICODE_SURROGATE, G_UNICODE_LOWERCASE_LETTER,
-    G_UNICODE_MODIFIER_LETTER, G_UNICODE_OTHER_LETTER,
-    G_UNICODE_TITLECASE_LETTER, G_UNICODE_UPPERCASE_LETTER,
-    G_UNICODE_COMBINING_MARK, G_UNICODE_ENCLOSING_MARK,
-    G_UNICODE_NON_SPACING_MARK, G_UNICODE_DECIMAL_NUMBER,
-    G_UNICODE_LETTER_NUMBER, G_UNICODE_OTHER_NUMBER,
-    G_UNICODE_CONNECT_PUNCTUATION, G_UNICODE_DASH_PUNCTUATION,
-    G_UNICODE_CLOSE_PUNCTUATION, G_UNICODE_FINAL_PUNCTUATION,
-    G_UNICODE_INITIAL_PUNCTUATION, G_UNICODE_OTHER_PUNCTUATION,
-    G_UNICODE_OPEN_PUNCTUATION, G_UNICODE_CURRENCY_SYMBOL,
-    G_UNICODE_MODIFIER_SYMBOL, G_UNICODE_MATH_SYMBOL, G_UNICODE_OTHER_SYMBOL,
-    G_UNICODE_LINE_SEPARATOR, G_UNICODE_PARAGRAPH_SEPARATOR,
-    G_UNICODE_SPACE_SEPARATOR
-  PGUnicodeBreakType* = ptr TGUnicodeBreakType
-  TGUnicodeBreakType* = enum
-    G_UNICODE_BREAK_MANDATORY, G_UNICODE_BREAK_CARRIAGE_RETURN,
-    G_UNICODE_BREAK_LINE_FEED, G_UNICODE_BREAK_COMBINING_MARK,
-    G_UNICODE_BREAK_SURROGATE, G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
-    G_UNICODE_BREAK_INSEPARABLE, G_UNICODE_BREAK_NON_BREAKING_GLUE,
-    G_UNICODE_BREAK_CONTINGENT, G_UNICODE_BREAK_SPACE, G_UNICODE_BREAK_AFTER,
-    G_UNICODE_BREAK_BEFORE, G_UNICODE_BREAK_BEFORE_AND_AFTER,
-    G_UNICODE_BREAK_HYPHEN, G_UNICODE_BREAK_NON_STARTER,
-    G_UNICODE_BREAK_OPEN_PUNCTUATION, G_UNICODE_BREAK_CLOSE_PUNCTUATION,
-    G_UNICODE_BREAK_QUOTATION, G_UNICODE_BREAK_EXCLAMATION,
-    G_UNICODE_BREAK_IDEOGRAPHIC, G_UNICODE_BREAK_NUMERIC,
-    G_UNICODE_BREAK_INFIX_SEPARATOR, G_UNICODE_BREAK_SYMBOL,
-    G_UNICODE_BREAK_ALPHABETIC, G_UNICODE_BREAK_PREFIX, G_UNICODE_BREAK_POSTFIX,
-    G_UNICODE_BREAK_COMPLEX_CONTEXT, G_UNICODE_BREAK_AMBIGUOUS,
-    G_UNICODE_BREAK_UNKNOWN
-
-proc g_get_charset*(charset: PPchar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_get_charset".}
-proc g_unichar_isalnum*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isalnum".}
-proc g_unichar_isalpha*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isalpha".}
-proc g_unichar_iscntrl*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_iscntrl".}
-proc g_unichar_isdigit*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isdigit".}
-proc g_unichar_isgraph*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isgraph".}
-proc g_unichar_islower*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_islower".}
-proc g_unichar_isprint*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isprint".}
-proc g_unichar_ispunct*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_ispunct".}
-proc g_unichar_isspace*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isspace".}
-proc g_unichar_isupper*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isupper".}
-proc g_unichar_isxdigit*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isxdigit".}
-proc g_unichar_istitle*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_istitle".}
-proc g_unichar_isdefined*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_isdefined".}
-proc g_unichar_iswide*(c: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_iswide".}
-proc g_unichar_toupper*(c: gunichar): gunichar{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_toupper".}
-proc g_unichar_tolower*(c: gunichar): gunichar{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_tolower".}
-proc g_unichar_totitle*(c: gunichar): gunichar{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_totitle".}
-proc g_unichar_digit_value*(c: gunichar): gint{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_digit_value".}
-proc g_unichar_xdigit_value*(c: gunichar): gint{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_xdigit_value".}
-proc g_unichar_type*(c: gunichar): TGUnicodeType{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_type".}
-proc g_unichar_break_type*(c: gunichar): TGUnicodeBreakType{.cdecl,
-    dynlib: gliblib, importc: "g_unichar_break_type".}
-proc g_unicode_canonical_ordering*(str: Pgunichar, len: gsize){.cdecl,
-    dynlib: gliblib, importc: "g_unicode_canonical_ordering".}
-proc g_unicode_canonical_decomposition*(ch: gunichar, result_len: Pgsize): Pgunichar{.
-    cdecl, dynlib: gliblib, importc: "g_unicode_canonical_decomposition".}
-proc g_utf8_next_char*(p: pguchar): pguchar
-proc g_utf8_get_char*(p: cstring): gunichar{.cdecl, dynlib: gliblib,
-    importc: "g_utf8_get_char".}
-proc g_utf8_get_char_validated*(p: cstring, max_len: gssize): gunichar{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_get_char_validated".}
-proc g_utf8_offset_to_pointer*(str: cstring, offset: glong): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_offset_to_pointer".}
-proc g_utf8_pointer_to_offset*(str: cstring, pos: cstring): glong{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_pointer_to_offset".}
-proc g_utf8_prev_char*(p: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_utf8_prev_char".}
-proc g_utf8_find_next_char*(p: cstring, `end`: cstring): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_find_next_char".}
-proc g_utf8_find_prev_char*(str: cstring, p: cstring): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_find_prev_char".}
-proc g_utf8_strlen*(p: cstring, max: gssize): glong{.cdecl, dynlib: gliblib,
-    importc: "g_utf8_strlen".}
-proc g_utf8_strncpy*(dest: cstring, src: cstring, n: gsize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_strncpy".}
-proc g_utf8_strchr*(p: cstring, len: gssize, c: gunichar): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_strchr".}
-proc g_utf8_strrchr*(p: cstring, len: gssize, c: gunichar): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_strrchr".}
-proc g_utf8_to_utf16*(str: cstring, len: glong, items_read: Pglong,
-                      items_written: Pglong, error: pointer): Pgunichar2{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_to_utf16".}
-proc g_utf8_to_ucs4*(str: cstring, len: glong, items_read: Pglong,
-                     items_written: Pglong, error: pointer): Pgunichar{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_to_ucs4".}
-proc g_utf8_to_ucs4_fast*(str: cstring, len: glong, items_written: Pglong): Pgunichar{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_to_ucs4_fast".}
-proc g_utf16_to_ucs4*(str: Pgunichar2, len: glong, items_read: Pglong,
-                      items_written: Pglong, error: pointer): Pgunichar{.cdecl,
-    dynlib: gliblib, importc: "g_utf16_to_ucs4".}
-proc g_utf16_to_utf8*(str: Pgunichar2, len: glong, items_read: Pglong,
-                      items_written: Pglong, error: pointer): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf16_to_utf8".}
-proc g_ucs4_to_utf16*(str: Pgunichar, len: glong, items_read: Pglong,
-                      items_written: Pglong, error: pointer): Pgunichar2{.
-    cdecl, dynlib: gliblib, importc: "g_ucs4_to_utf16".}
-proc g_ucs4_to_utf8*(str: Pgunichar, len: glong, items_read: Pglong,
-                     items_written: Pglong, error: pointer): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_ucs4_to_utf8".}
-proc g_unichar_to_utf8*(c: gunichar, outbuf: cstring): gint{.cdecl,
-    dynlib: gliblib, importc: "g_unichar_to_utf8".}
-proc g_utf8_validate*(str: cstring, max_len: gssize, `end`: PPgchar): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_validate".}
-proc g_unichar_validate*(ch: gunichar): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_unichar_validate".}
-proc g_utf8_strup*(str: cstring, len: gssize): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_utf8_strup".}
-proc g_utf8_strdown*(str: cstring, len: gssize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_strdown".}
-proc g_utf8_casefold*(str: cstring, len: gssize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_casefold".}
-type
-  PGNormalizeMode* = ptr TGNormalizeMode
-  TGNormalizeMode* = gint
-
-const
-  G_NORMALIZE_DEFAULT* = 0
-  G_NORMALIZE_NFD* = G_NORMALIZE_DEFAULT
-  G_NORMALIZE_DEFAULT_COMPOSE* = 1
-  G_NORMALIZE_NFC* = G_NORMALIZE_DEFAULT_COMPOSE
-  G_NORMALIZE_ALL* = 2
-  G_NORMALIZE_NFKD* = G_NORMALIZE_ALL
-  G_NORMALIZE_ALL_COMPOSE* = 3
-  G_NORMALIZE_NFKC* = G_NORMALIZE_ALL_COMPOSE
-
-proc g_utf8_normalize*(str: cstring, len: gssize, mode: TGNormalizeMode): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_normalize".}
-proc g_utf8_collate*(str1: cstring, str2: cstring): gint{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_collate".}
-proc g_utf8_collate_key*(str: cstring, len: gssize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_utf8_collate_key".}
-type
-  PGString* = ptr TGString
-  TGString* {.final.} = object
-    str*: cstring
-    len*: gsize
-    allocated_len*: gsize
-
-  PGStringChunk* = pointer
-
-proc g_string_chunk_new*(size: gsize): PGStringChunk{.cdecl, dynlib: gliblib,
-    importc: "g_string_chunk_new".}
-proc g_string_chunk_free*(chunk: PGStringChunk){.cdecl, dynlib: gliblib,
-    importc: "g_string_chunk_free".}
-proc g_string_chunk_insert*(chunk: PGStringChunk, str: cstring): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_string_chunk_insert".}
-proc g_string_chunk_insert_const*(chunk: PGStringChunk, str: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_string_chunk_insert_const".}
-proc g_string_new*(init: cstring): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_new".}
-proc g_string_new_len*(init: cstring, len: gssize): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_new_len".}
-proc g_string_sized_new*(dfl_size: gsize): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_sized_new".}
-proc g_string_free*(str: PGString, free_segment: gboolean): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_string_free".}
-proc g_string_equal*(v: PGString, v2: PGString): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_string_equal".}
-proc g_string_hash*(str: PGString): guint{.cdecl, dynlib: gliblib,
-    importc: "g_string_hash".}
-proc g_string_assign*(str: PGString, rval: cstring): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_assign".}
-proc g_string_truncate*(str: PGString, len: gsize): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_truncate".}
-proc g_string_set_size*(str: PGString, len: gsize): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_set_size".}
-proc g_string_insert_len*(str: PGString, pos: gssize, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert_len".}
-proc g_string_append*(str: PGString, val: cstring): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_append".}
-proc g_string_append_len*(str: PGString, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_append_len".}
-proc g_string_append_c*(str: PGString, c: gchar): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_append_c".}
-proc g_string_append_unichar*(str: PGString, wc: gunichar): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_append_unichar".}
-proc g_string_prepend*(str: PGString, val: cstring): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_prepend".}
-proc g_string_prepend_c*(str: PGString, c: gchar): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_prepend_c".}
-proc g_string_prepend_unichar*(str: PGString, wc: gunichar): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_prepend_unichar".}
-proc g_string_prepend_len*(str: PGString, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_prepend_len".}
-proc g_string_insert*(str: PGString, pos: gssize, val: cstring): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert".}
-proc g_string_insert_c*(str: PGString, pos: gssize, c: gchar): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_insert_c".}
-proc g_string_insert_unichar*(str: PGString, pos: gssize, wc: gunichar): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert_unichar".}
-proc g_string_erase*(str: PGString, pos: gssize, len: gssize): PGString{.cdecl,
-    dynlib: gliblib, importc: "g_string_erase".}
-proc g_string_ascii_down*(str: PGString): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_ascii_down".}
-proc g_string_ascii_up*(str: PGString): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_ascii_up".}
-proc g_string_down*(str: PGString): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_down".}
-proc g_string_up*(str: PGString): PGString{.cdecl, dynlib: gliblib,
-    importc: "g_string_up".}
-type
-  PGIOError* = ptr TGIOError
-  TGIOError* = enum
-    G_IO_ERROR_NONE, G_IO_ERROR_AGAIN, G_IO_ERROR_INVAL, G_IO_ERROR_UNKNOWN
-
-proc G_IO_CHANNEL_ERROR*(): TGQuark
-type
-  PGIOChannelError* = ptr TGIOChannelError
-  TGIOChannelError* = enum
-    G_IO_CHANNEL_ERROR_FBIG, G_IO_CHANNEL_ERROR_INVAL, G_IO_CHANNEL_ERROR_IO,
-    G_IO_CHANNEL_ERROR_ISDIR, G_IO_CHANNEL_ERROR_NOSPC, G_IO_CHANNEL_ERROR_NXIO,
-    G_IO_CHANNEL_ERROR_OVERFLOW, G_IO_CHANNEL_ERROR_PIPE,
-    G_IO_CHANNEL_ERROR_FAILED
-  PGIOStatus* = ptr TGIOStatus
-  TGIOStatus* = enum
-    G_IO_STATUS_ERROR, G_IO_STATUS_NORMAL, G_IO_STATUS_EOF, G_IO_STATUS_AGAIN
-  PGSeekType* = ptr TGSeekType
-  TGSeekType* = enum
-    G_SEEK_CUR, G_SEEK_SET, G_SEEK_END
-  PGIOCondition* = ptr TGIOCondition
-  TGIOCondition* = gint
-
-const
-  G_IO_IN* = GLIB_SYSDEF_POLLIN
-  G_IO_OUT* = GLIB_SYSDEF_POLLOUT
-  G_IO_PRI* = GLIB_SYSDEF_POLLPRI
-  G_IO_ERR* = GLIB_SYSDEF_POLLERR
-  G_IO_HUP* = GLIB_SYSDEF_POLLHUP
-  G_IO_NVAL* = GLIB_SYSDEF_POLLNVAL
-
-type
-  PGIOFlags* = ptr TGIOFlags
-  TGIOFlags* = gint
-
-const
-  G_IO_FLAG_APPEND* = 1 shl 0
-  G_IO_FLAG_NONBLOCK* = 1 shl 1
-  G_IO_FLAG_IS_READABLE* = 1 shl 2
-  G_IO_FLAG_IS_WRITEABLE* = 1 shl 3
-  G_IO_FLAG_IS_SEEKABLE* = 1 shl 4
-  G_IO_FLAG_MASK* = (1 shl 5) - 1
-  G_IO_FLAG_GET_MASK* = G_IO_FLAG_MASK
-  G_IO_FLAG_SET_MASK* = G_IO_FLAG_APPEND or G_IO_FLAG_NONBLOCK
-
-type
-  PGIOChannel* = ptr TGIOChannel
-  TGIOFunc* = proc (source: PGIOChannel, condition: TGIOCondition,
-                    data: gpointer): gboolean{.cdecl.}
-  PGIOFuncs* = ptr TGIOFuncs
-  TGIOFuncs* {.final.} = object
-    io_read*: proc (channel: PGIOChannel, buf: cstring, count: gsize,
-                    bytes_read: Pgsize, err: pointer): TGIOStatus{.cdecl.}
-    io_write*: proc (channel: PGIOChannel, buf: cstring, count: gsize,
-                     bytes_written: Pgsize, err: pointer): TGIOStatus{.cdecl.}
-    io_seek*: proc (channel: PGIOChannel, offset: gint64, theType: TGSeekType,
-                    err: pointer): TGIOStatus{.cdecl.}
-    io_close*: proc (channel: PGIOChannel, err: pointer): TGIOStatus{.cdecl.}
-    io_create_watch*: proc (channel: PGIOChannel, condition: TGIOCondition): PGSource{.
-        cdecl.}
-    io_free*: proc (channel: PGIOChannel){.cdecl.}
-    io_set_flags*: proc (channel: PGIOChannel, flags: TGIOFlags, err: pointer): TGIOStatus{.
-        cdecl.}
-    io_get_flags*: proc (channel: PGIOChannel): TGIOFlags{.cdecl.}
-
-  TGIOChannel* {.final.} = object
-    ref_count*: guint
-    funcs*: PGIOFuncs
-    encoding*: cstring
-    read_cd*: TGIConv
-    write_cd*: TGIConv
-    line_term*: cstring
-    line_term_len*: guint
-    buf_size*: gsize
-    read_buf*: PGString
-    encoded_read_buf*: PGString
-    write_buf*: PGString
-    partial_write_buf*: array[0..5, gchar]
-    flag0*: guint16
-    reserved1*: gpointer
-    reserved2*: gpointer
-
-
-const
-  bm_TGIOChannel_use_buffer* = 0x00000001'i16
-  bp_TGIOChannel_use_buffer* = 0'i16
-  bm_TGIOChannel_do_encode* = 0x00000002'i16
-  bp_TGIOChannel_do_encode* = 1'i16
-  bm_TGIOChannel_close_on_unref* = 0x00000004'i16
-  bp_TGIOChannel_close_on_unref* = 2'i16
-  bm_TGIOChannel_is_readable* = 0x00000008'i16
-  bp_TGIOChannel_is_readable* = 3'i16
-  bm_TGIOChannel_is_writeable* = 0x00000010'i16
-  bp_TGIOChannel_is_writeable* = 4'i16
-  bm_TGIOChannel_is_seekable* = 0x00000020'i16
-  bp_TGIOChannel_is_seekable* = 5'i16
-
-proc TGIOChannel_use_buffer*(a: var TGIOChannel): guint
-proc TGIOChannel_set_use_buffer*(a: var TGIOChannel, `use_buffer`: guint)
-proc TGIOChannel_do_encode*(a: var TGIOChannel): guint
-proc TGIOChannel_set_do_encode*(a: var TGIOChannel, `do_encode`: guint)
-proc TGIOChannel_close_on_unref*(a: var TGIOChannel): guint
-proc TGIOChannel_set_close_on_unref*(a: var TGIOChannel, `close_on_unref`: guint)
-proc TGIOChannel_is_readable*(a: var TGIOChannel): guint
-proc TGIOChannel_set_is_readable*(a: var TGIOChannel, `is_readable`: guint)
-proc TGIOChannel_is_writeable*(a: var TGIOChannel): guint
-proc TGIOChannel_set_is_writeable*(a: var TGIOChannel, `is_writeable`: guint)
-proc TGIOChannel_is_seekable*(a: var TGIOChannel): guint
-proc TGIOChannel_set_is_seekable*(a: var TGIOChannel, `is_seekable`: guint)
-proc g_io_channel_init*(channel: PGIOChannel){.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_init".}
-proc g_io_channel_ref*(channel: PGIOChannel){.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_ref".}
-proc g_io_channel_unref*(channel: PGIOChannel){.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_unref".}
-proc g_io_channel_read*(channel: PGIOChannel, buf: cstring, count: gsize,
-                        bytes_read: Pgsize): TGIOError{.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_read".}
-proc g_io_channel_write*(channel: PGIOChannel, buf: cstring, count: gsize,
-                         bytes_written: Pgsize): TGIOError{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_write".}
-proc g_io_channel_seek*(channel: PGIOChannel, offset: gint64,
-                        theType: TGSeekType): TGIOError{.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_seek".}
-proc g_io_channel_close*(channel: PGIOChannel){.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_close".}
-proc g_io_channel_shutdown*(channel: PGIOChannel, flush: gboolean, err: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_shutdown".}
-proc g_io_add_watch_full*(channel: PGIOChannel, priority: gint,
-                          condition: TGIOCondition, func: TGIOFunc,
-                          user_data: gpointer, notify: TGDestroyNotify): guint{.
-    cdecl, dynlib: gliblib, importc: "g_io_add_watch_full".}
-proc g_io_create_watch*(channel: PGIOChannel, condition: TGIOCondition): PGSource{.
-    cdecl, dynlib: gliblib, importc: "g_io_create_watch".}
-proc g_io_add_watch*(channel: PGIOChannel, condition: TGIOCondition,
-                     func: TGIOFunc, user_data: gpointer): guint{.cdecl,
-    dynlib: gliblib, importc: "g_io_add_watch".}
-proc g_io_channel_set_buffer_size*(channel: PGIOChannel, size: gsize){.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_set_buffer_size".}
-proc g_io_channel_get_buffer_size*(channel: PGIOChannel): gsize{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_get_buffer_size".}
-proc g_io_channel_get_buffer_condition*(channel: PGIOChannel): TGIOCondition{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_get_buffer_condition".}
-proc g_io_channel_set_flags*(channel: PGIOChannel, flags: TGIOFlags,
-                             error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_set_flags".}
-proc g_io_channel_get_flags*(channel: PGIOChannel): TGIOFlags{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_get_flags".}
-proc g_io_channel_set_line_term*(channel: PGIOChannel, line_term: cstring,
-                                 length: gint){.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_set_line_term".}
-proc g_io_channel_get_line_term*(channel: PGIOChannel, length: Pgint): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_get_line_term".}
-proc g_io_channel_set_buffered*(channel: PGIOChannel, buffered: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_set_buffered".}
-proc g_io_channel_get_buffered*(channel: PGIOChannel): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_get_buffered".}
-proc g_io_channel_set_encoding*(channel: PGIOChannel, encoding: cstring,
-                                error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_set_encoding".}
-proc g_io_channel_get_encoding*(channel: PGIOChannel): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_get_encoding".}
-proc g_io_channel_set_close_on_unref*(channel: PGIOChannel, do_close: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_set_close_on_unref".}
-proc g_io_channel_get_close_on_unref*(channel: PGIOChannel): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_get_close_on_unref".}
-proc g_io_channel_flush*(channel: PGIOChannel, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_flush".}
-proc g_io_channel_read_line*(channel: PGIOChannel, str_return: PPgchar,
-                             length: Pgsize, terminator_pos: Pgsize,
-                             error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_read_line".}
-proc g_io_channel_read_line_string*(channel: PGIOChannel, buffer: PGString,
-                                    terminator_pos: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_line_string".}
-proc g_io_channel_read_to_end*(channel: PGIOChannel, str_return: PPgchar,
-                               length: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_to_end".}
-proc g_io_channel_read_chars*(channel: PGIOChannel, buf: cstring, count: gsize,
-                              bytes_read: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_chars".}
-proc g_io_channel_read_unichar*(channel: PGIOChannel, thechar: Pgunichar,
-                                error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_read_unichar".}
-proc g_io_channel_write_chars*(channel: PGIOChannel, buf: cstring,
-                               count: gssize, bytes_written: Pgsize,
-                               error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_write_chars".}
-proc g_io_channel_write_unichar*(channel: PGIOChannel, thechar: gunichar,
-                                 error: pointer): TGIOStatus{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_write_unichar".}
-proc g_io_channel_seek_position*(channel: PGIOChannel, offset: gint64,
-                                 theType: TGSeekType, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_seek_position".}
-proc g_io_channel_new_file*(filename: cstring, mode: cstring, error: pointer): PGIOChannel{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_new_file".}
-proc g_io_channel_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_error_quark".}
-proc g_io_channel_error_from_errno*(en: gint): TGIOChannelError{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_error_from_errno".}
-proc g_io_channel_unix_new*(fd: int32): PGIOChannel{.cdecl, dynlib: gliblib,
-    importc: "g_io_channel_unix_new".}
-proc g_io_channel_unix_get_fd*(channel: PGIOChannel): gint{.cdecl,
-    dynlib: gliblib, importc: "g_io_channel_unix_get_fd".}
-const
-  G_LOG_LEVEL_USER_SHIFT* = 8
-
-type
-  PGLogLevelFlags* = ptr TGLogLevelFlags
-  TGLogLevelFlags* = int32
-
-const
-  G_LOG_FLAG_RECURSION* = 1 shl 0
-  G_LOG_FLAG_FATAL* = 1 shl 1
-  G_LOG_LEVEL_ERROR* = 1 shl 2
-  G_LOG_LEVEL_CRITICAL* = 1 shl 3
-  G_LOG_LEVEL_WARNING* = 1 shl 4
-  G_LOG_LEVEL_MESSAGE* = 1 shl 5
-  G_LOG_LEVEL_INFO* = 1 shl 6
-  G_LOG_LEVEL_DEBUG* = 1 shl 7
-  G_LOG_LEVEL_MASK* = not 3
-
-const
-  G_LOG_FATAL_MASK* = 5
-
-type
-  TGLogFunc* = proc (log_domain: cstring, log_level: TGLogLevelFlags,
-                     TheMessage: cstring, user_data: gpointer){.cdecl.}
-
-proc g_log_set_handler*(log_domain: cstring, log_levels: TGLogLevelFlags,
-                        log_func: TGLogFunc, user_data: gpointer): guint{.cdecl,
-    dynlib: gliblib, importc: "g_log_set_handler".}
-proc g_log_remove_handler*(log_domain: cstring, handler_id: guint){.cdecl,
-    dynlib: gliblib, importc: "g_log_remove_handler".}
-proc g_log_default_handler*(log_domain: cstring, log_level: TGLogLevelFlags,
-                            TheMessage: cstring, unused_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_log_default_handler".}
-proc g_log_set_fatal_mask*(log_domain: cstring, fatal_mask: TGLogLevelFlags): TGLogLevelFlags{.
-    cdecl, dynlib: gliblib, importc: "g_log_set_fatal_mask".}
-proc g_log_set_always_fatal*(fatal_mask: TGLogLevelFlags): TGLogLevelFlags{.
-    cdecl, dynlib: gliblib, importc: "g_log_set_always_fatal".}
-proc `g_log_fallback_handler`*(log_domain: cstring, log_level: TGLogLevelFlags,
-                               message: cstring, unused_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_log_fallback_handler".}
-const
-  G_LOG_DOMAIN* = nil
-
-when false:
-  proc g_error*(format: cstring){.varargs.}
-  proc g_message*(format: cstring){.varargs.}
-  proc g_critical*(format: cstring){.varargs.}
-  proc g_warning*(format: cstring){.varargs.}
-
-type
-  TGPrintFunc* = proc (str: cstring)
-
-proc g_set_print_handler*(func: TGPrintFunc): TGPrintFunc{.cdecl,
-    dynlib: gliblib, importc: "g_set_print_handler".}
-proc g_set_printerr_handler*(func: TGPrintFunc): TGPrintFunc{.cdecl,
-    dynlib: gliblib, importc: "g_set_printerr_handler".}
-type
-  PGMarkupError* = ptr TGMarkupError
-  TGMarkupError* = enum
-    G_MARKUP_ERROR_BAD_UTF8, G_MARKUP_ERROR_EMPTY, G_MARKUP_ERROR_PARSE,
-    G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
-    G_MARKUP_ERROR_INVALID_CONTENT
-
-proc G_MARKUP_ERROR*(): TGQuark
-proc g_markup_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-                                       importc: "g_markup_error_quark".}
-type
-  PGMarkupParseFlags* = ptr TGMarkupParseFlags
-  TGMarkupParseFlags* = int
-
-const
-  G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG* = 1 shl 0
-
-type
-  PGMarkupParseContext* = ptr TGMarkupParseContext
-  TGMarkupParseContext* = pointer
-  PGMarkupParser* = ptr TGMarkupParser
-  TGMarkupParser* {.final.} = object
-    start_element*: proc (context: PGMarkupParseContext, element_name: cstring,
-                          attribute_names: PPgchar, attribute_values: PPgchar,
-                          user_data: gpointer, error: pointer){.cdecl.}
-    end_element*: proc (context: PGMarkupParseContext, element_name: cstring,
-                        user_data: gpointer, error: pointer){.cdecl.}
-    text*: proc (context: PGMarkupParseContext, text: cstring, text_len: gsize,
-                 user_data: gpointer, error: pointer){.cdecl.}
-    passthrough*: proc (context: PGMarkupParseContext,
-                        passthrough_text: cstring, text_len: gsize,
-                        user_data: gpointer, error: pointer){.cdecl.}
-    error*: proc (context: PGMarkupParseContext, error: pointer,
-                  user_data: gpointer){.cdecl.}
-
-
-proc g_markup_parse_context_new*(parser: PGMarkupParser,
-                                 flags: TGMarkupParseFlags, user_data: gpointer,
-                                 user_data_dnotify: TGDestroyNotify): PGMarkupParseContext{.
-    cdecl, dynlib: gliblib, importc: "g_markup_parse_context_new".}
-proc g_markup_parse_context_free*(context: PGMarkupParseContext){.cdecl,
-    dynlib: gliblib, importc: "g_markup_parse_context_free".}
-proc g_markup_parse_context_parse*(context: PGMarkupParseContext, text: cstring,
-                                   text_len: gssize, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_markup_parse_context_parse".}
-proc g_markup_parse_context_end_parse*(context: PGMarkupParseContext,
-                                       error: pointer): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_markup_parse_context_end_parse".}
-proc g_markup_parse_context_get_position*(context: PGMarkupParseContext,
-    line_number: Pgint, char_number: Pgint){.cdecl, dynlib: gliblib,
-    importc: "g_markup_parse_context_get_position".}
-proc g_markup_escape_text*(text: cstring, length: gssize): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_markup_escape_text".}
-type
-  PGNode* = ptr TGNode
-  TGNode* {.final.} = object
-    data*: gpointer
-    next*: PGNode
-    prev*: PGNode
-    parent*: PGNode
-    children*: PGNode
-
-  PGTraverseFlags* = ptr TGTraverseFlags
-  TGTraverseFlags* = gint
-
-const
-  G_TRAVERSE_LEAFS* = 1 shl 0
-  G_TRAVERSE_NON_LEAFS* = 1 shl 1
-  G_TRAVERSE_ALL* = G_TRAVERSE_LEAFS or G_TRAVERSE_NON_LEAFS
-  G_TRAVERSE_MASK* = 0x00000003
-
-type
-  PGTraverseType* = ptr TGTraverseType
-  TGTraverseType* = enum
-    G_IN_ORDER, G_PRE_ORDER, G_POST_ORDER, G_LEVEL_ORDER
-  TGNodeTraverseFunc* = proc (node: PGNode, data: gpointer): gboolean{.cdecl.}
-  TGNodeForeachFunc* = proc (node: PGNode, data: gpointer){.cdecl.}
-
-proc G_NODE_IS_ROOT*(node: PGNode): bool
-proc G_NODE_IS_LEAF*(node: PGNode): bool
-proc g_node_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib,
-    importc: "g_node_push_allocator".}
-proc g_node_pop_allocator*(){.cdecl, dynlib: gliblib,
-                              importc: "g_node_pop_allocator".}
-proc g_node_new*(data: gpointer): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_new".}
-proc g_node_destroy*(root: PGNode){.cdecl, dynlib: gliblib,
-                                    importc: "g_node_destroy".}
-proc g_node_unlink*(node: PGNode){.cdecl, dynlib: gliblib,
-                                   importc: "g_node_unlink".}
-proc g_node_copy*(node: PGNode): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_copy".}
-proc g_node_insert*(parent: PGNode, position: gint, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert".}
-proc g_node_insert_before*(parent: PGNode, sibling: PGNode, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert_before".}
-proc g_node_insert_after*(parent: PGNode, sibling: PGNode, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert_after".}
-proc g_node_prepend*(parent: PGNode, node: PGNode): PGNode{.cdecl,
-    dynlib: gliblib, importc: "g_node_prepend".}
-proc g_node_n_nodes*(root: PGNode, flags: TGTraverseFlags): guint{.cdecl,
-    dynlib: gliblib, importc: "g_node_n_nodes".}
-proc g_node_get_root*(node: PGNode): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_get_root".}
-proc g_node_is_ancestor*(node: PGNode, descendant: PGNode): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_node_is_ancestor".}
-proc g_node_depth*(node: PGNode): guint{.cdecl, dynlib: gliblib,
-    importc: "g_node_depth".}
-proc g_node_find*(root: PGNode, order: TGTraverseType, flags: TGTraverseFlags,
-                  data: gpointer): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_find".}
-proc g_node_append*(parent: PGNode, node: PGNode): PGNode
-proc g_node_insert_data*(parent: PGNode, position: gint, data: gpointer): PGNode
-proc g_node_insert_data_before*(parent: PGNode, sibling: PGNode, data: gpointer): PGNode
-proc g_node_prepend_data*(parent: PGNode, data: gpointer): PGNode
-proc g_node_append_data*(parent: PGNode, data: gpointer): PGNode
-proc g_node_traverse*(root: PGNode, order: TGTraverseType,
-                      flags: TGTraverseFlags, max_depth: gint,
-                      func: TGNodeTraverseFunc, data: gpointer): guint{.cdecl,
-    dynlib: gliblib, importc: "g_node_traverse".}
-proc g_node_max_height*(root: PGNode): guint{.cdecl, dynlib: gliblib,
-    importc: "g_node_max_height".}
-proc g_node_children_foreach*(node: PGNode, flags: TGTraverseFlags,
-                              func: TGNodeForeachFunc, data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_node_children_foreach".}
-proc g_node_reverse_children*(node: PGNode){.cdecl, dynlib: gliblib,
-    importc: "g_node_reverse_children".}
-proc g_node_n_children*(node: PGNode): guint{.cdecl, dynlib: gliblib,
-    importc: "g_node_n_children".}
-proc g_node_nth_child*(node: PGNode, n: guint): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_nth_child".}
-proc g_node_last_child*(node: PGNode): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_last_child".}
-proc g_node_find_child*(node: PGNode, flags: TGTraverseFlags, data: gpointer): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_find_child".}
-proc g_node_child_position*(node: PGNode, child: PGNode): gint{.cdecl,
-    dynlib: gliblib, importc: "g_node_child_position".}
-proc g_node_child_index*(node: PGNode, data: gpointer): gint{.cdecl,
-    dynlib: gliblib, importc: "g_node_child_index".}
-proc g_node_first_sibling*(node: PGNode): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_first_sibling".}
-proc g_node_last_sibling*(node: PGNode): PGNode{.cdecl, dynlib: gliblib,
-    importc: "g_node_last_sibling".}
-proc g_node_prev_sibling*(node: PGNode): PGNode
-proc g_node_next_sibling*(node: PGNode): PGNode
-proc g_node_first_child*(node: PGNode): PGNode
-type
-  PGTree* = pointer
-  TGTraverseFunc* = proc (key: gpointer, value: gpointer, data: gpointer): gboolean{.
-      cdecl.}
-
-proc g_tree_new*(key_compare_func: TGCompareFunc): PGTree{.cdecl,
-    dynlib: gliblib, importc: "g_tree_new".}
-proc g_tree_new_with_data*(key_compare_func: TGCompareDataFunc,
-                           key_compare_data: gpointer): PGTree{.cdecl,
-    dynlib: gliblib, importc: "g_tree_new_with_data".}
-proc g_tree_new_full*(key_compare_func: TGCompareDataFunc,
-                      key_compare_data: gpointer,
-                      key_destroy_func: TGDestroyNotify,
-                      value_destroy_func: TGDestroyNotify): PGTree{.cdecl,
-    dynlib: gliblib, importc: "g_tree_new_full".}
-proc g_tree_destroy*(tree: PGTree){.cdecl, dynlib: gliblib,
-                                    importc: "g_tree_destroy".}
-proc g_tree_insert*(tree: PGTree, key: gpointer, value: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_tree_insert".}
-proc g_tree_replace*(tree: PGTree, key: gpointer, value: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_tree_replace".}
-proc g_tree_remove*(tree: PGTree, key: gconstpointer){.cdecl, dynlib: gliblib,
-    importc: "g_tree_remove".}
-proc g_tree_steal*(tree: PGTree, key: gconstpointer){.cdecl, dynlib: gliblib,
-    importc: "g_tree_steal".}
-proc g_tree_lookup*(tree: PGTree, key: gconstpointer): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_tree_lookup".}
-proc g_tree_lookup_extended*(tree: PGTree, lookup_key: gconstpointer,
-                             orig_key: Pgpointer, value: Pgpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_tree_lookup_extended".}
-proc g_tree_foreach*(tree: PGTree, func: TGTraverseFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_tree_foreach".}
-proc g_tree_search*(tree: PGTree, search_func: TGCompareFunc,
-                    user_data: gconstpointer): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_tree_search".}
-proc g_tree_height*(tree: PGTree): gint{.cdecl, dynlib: gliblib,
-    importc: "g_tree_height".}
-proc g_tree_nnodes*(tree: PGTree): gint{.cdecl, dynlib: gliblib,
-    importc: "g_tree_nnodes".}
-type
-  PGPatternSpec* = pointer
-
-proc g_pattern_spec_new*(pattern: cstring): PGPatternSpec{.cdecl,
-    dynlib: gliblib, importc: "g_pattern_spec_new".}
-proc g_pattern_spec_free*(pspec: PGPatternSpec){.cdecl, dynlib: gliblib,
-    importc: "g_pattern_spec_free".}
-proc g_pattern_spec_equal*(pspec1: PGPatternSpec, pspec2: PGPatternSpec): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_pattern_spec_equal".}
-proc g_pattern_match*(pspec: PGPatternSpec, string_length: guint, str: cstring,
-                      string_reversed: cstring): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_pattern_match".}
-proc g_pattern_match_string*(pspec: PGPatternSpec, str: cstring): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_pattern_match_string".}
-proc g_pattern_match_simple*(pattern: cstring, str: cstring): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_pattern_match_simple".}
-proc g_spaced_primes_closest*(num: guint): guint{.cdecl, dynlib: gliblib,
-    importc: "g_spaced_primes_closest".}
-proc g_qsort_with_data*(pbase: gconstpointer, total_elems: gint, size: gsize,
-                        compare_func: TGCompareDataFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_qsort_with_data".}
-type
-  PGQueue* = ptr TGQueue
-  TGQueue* {.final.} = object
-    head*: PGList
-    tail*: PGList
-    length*: guint
-
-
-proc g_queue_new*(): PGQueue{.cdecl, dynlib: gliblib, importc: "g_queue_new".}
-proc g_queue_free*(queue: PGQueue){.cdecl, dynlib: gliblib,
-                                    importc: "g_queue_free".}
-proc g_queue_push_head*(queue: PGQueue, data: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_queue_push_head".}
-proc g_queue_push_tail*(queue: PGQueue, data: gpointer){.cdecl, dynlib: gliblib,
-    importc: "g_queue_push_tail".}
-proc g_queue_pop_head*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_queue_pop_head".}
-proc g_queue_pop_tail*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_queue_pop_tail".}
-proc g_queue_is_empty*(queue: PGQueue): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_queue_is_empty".}
-proc g_queue_peek_head*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_queue_peek_head".}
-proc g_queue_peek_tail*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib,
-    importc: "g_queue_peek_tail".}
-proc g_queue_push_head_link*(queue: PGQueue, link: PGList){.cdecl,
-    dynlib: gliblib, importc: "g_queue_push_head_link".}
-proc g_queue_push_tail_link*(queue: PGQueue, link: PGList){.cdecl,
-    dynlib: gliblib, importc: "g_queue_push_tail_link".}
-proc g_queue_pop_head_link*(queue: PGQueue): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_queue_pop_head_link".}
-proc g_queue_pop_tail_link*(queue: PGQueue): PGList{.cdecl, dynlib: gliblib,
-    importc: "g_queue_pop_tail_link".}
-type
-  PGRand* = pointer
-
-proc g_rand_new_with_seed*(seed: guint32): PGRand{.cdecl, dynlib: gliblib,
-    importc: "g_rand_new_with_seed".}
-proc g_rand_new*(): PGRand{.cdecl, dynlib: gliblib, importc: "g_rand_new".}
-proc g_rand_free*(rand: PGRand){.cdecl, dynlib: gliblib, importc: "g_rand_free".}
-proc g_rand_set_seed*(rand: PGRand, seed: guint32){.cdecl, dynlib: gliblib,
-    importc: "g_rand_set_seed".}
-proc g_rand_boolean*(rand: PGRand): gboolean
-proc g_rand_int*(rand: PGRand): guint32{.cdecl, dynlib: gliblib,
-    importc: "g_rand_int".}
-proc g_rand_int_range*(rand: PGRand, `begin`: gint32, `end`: gint32): gint32{.
-    cdecl, dynlib: gliblib, importc: "g_rand_int_range".}
-proc g_rand_double*(rand: PGRand): gdouble{.cdecl, dynlib: gliblib,
-    importc: "g_rand_double".}
-proc g_rand_double_range*(rand: PGRand, `begin`: gdouble, `end`: gdouble): gdouble{.
-    cdecl, dynlib: gliblib, importc: "g_rand_double_range".}
-proc g_random_set_seed*(seed: guint32){.cdecl, dynlib: gliblib,
-                                        importc: "g_random_set_seed".}
-proc g_random_boolean*(): gboolean
-proc g_random_int*(): guint32{.cdecl, dynlib: gliblib, importc: "g_random_int".}
-proc g_random_int_range*(`begin`: gint32, `end`: gint32): gint32{.cdecl,
-    dynlib: gliblib, importc: "g_random_int_range".}
-proc g_random_double*(): gdouble{.cdecl, dynlib: gliblib,
-                                  importc: "g_random_double".}
-proc g_random_double_range*(`begin`: gdouble, `end`: gdouble): gdouble{.cdecl,
-    dynlib: gliblib, importc: "g_random_double_range".}
-type
-  PGTuples* = ptr TGTuples
-  TGTuples* {.final.} = object
-    len*: guint
-
-  PGRelation* = pointer
-
-proc g_relation_new*(fields: gint): PGRelation{.cdecl, dynlib: gliblib,
-    importc: "g_relation_new".}
-proc g_relation_destroy*(relation: PGRelation){.cdecl, dynlib: gliblib,
-    importc: "g_relation_destroy".}
-proc g_relation_index*(relation: PGRelation, field: gint, hash_func: TGHashFunc,
-                       key_equal_func: TGEqualFunc){.cdecl, dynlib: gliblib,
-    importc: "g_relation_index".}
-proc g_relation_delete*(relation: PGRelation, key: gconstpointer, field: gint): gint{.
-    cdecl, dynlib: gliblib, importc: "g_relation_delete".}
-proc g_relation_select*(relation: PGRelation, key: gconstpointer, field: gint): PGTuples{.
-    cdecl, dynlib: gliblib, importc: "g_relation_select".}
-proc g_relation_count*(relation: PGRelation, key: gconstpointer, field: gint): gint{.
-    cdecl, dynlib: gliblib, importc: "g_relation_count".}
-proc g_relation_print*(relation: PGRelation){.cdecl, dynlib: gliblib,
-    importc: "g_relation_print".}
-proc g_tuples_destroy*(tuples: PGTuples){.cdecl, dynlib: gliblib,
-    importc: "g_tuples_destroy".}
-proc g_tuples_index*(tuples: PGTuples, index: gint, field: gint): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_tuples_index".}
-type
-  PGTokenType* = ptr TGTokenType
-  TGTokenType* = gint
-
-const
-  G_TOKEN_LEFT_PAREN* = 40
-  G_TOKEN_RIGHT_PAREN* = 41
-  G_TOKEN_LEFT_CURLY* = 123
-  G_TOKEN_RIGHT_CURLY* = 125
-  G_TOKEN_LEFT_BRACE* = 91
-  G_TOKEN_RIGHT_BRACE* = 93
-  G_TOKEN_EQUAL_SIGN* = 61
-  G_TOKEN_COMMA* = 44
-  G_TOKEN_NONE* = 256
-  G_TOKEN_ERROR* = 257
-  G_TOKEN_CHAR* = 258
-  G_TOKEN_OCTAL* = 260
-  G_TOKEN_INT* = 261
-  G_TOKEN_HEX* = 262
-  G_TOKEN_FLOAT* = 263
-  G_TOKEN_STRING* = 264
-  G_TOKEN_SYMBOL* = 265
-  G_TOKEN_IDENTIFIER* = 266
-  G_TOKEN_IDENTIFIER_NULL* = 267
-  G_TOKEN_COMMENT_SINGLE* = 268
-  G_TOKEN_COMMENT_MULTI* = 269
-  G_TOKEN_LAST* = 270
-
-type
-  PGScanner* = ptr TGScanner
-  PGScannerConfig* = ptr TGScannerConfig
-  PGTokenValue* = ptr TGTokenValue
-  TGTokenValue* {.final.} = object
-    v_float*: gdouble
-
-  TGScannerMsgFunc* = proc (scanner: PGScanner, message: cstring,
-                            error: gboolean){.cdecl.}
-  TGScanner* {.final.} = object
-    user_data*: gpointer
-    max_parse_errors*: guint
-    parse_errors*: guint
-    input_name*: cstring
-    qdata*: PGData
-    config*: PGScannerConfig
-    token*: TGTokenType
-    value*: TGTokenValue
-    line*: guint
-    position*: guint
-    next_token*: TGTokenType
-    next_value*: TGTokenValue
-    next_line*: guint
-    next_position*: guint
-    symbol_table*: PGHashTable
-    input_fd*: gint
-    text*: cstring
-    text_end*: cstring
-    buffer*: cstring
-    scope_id*: guint
-    msg_handler*: TGScannerMsgFunc
-
-  TGScannerConfig* {.final.} = object
-    cset_skip_characters*: cstring
-    cset_identifier_first*: cstring
-    cset_identifier_nth*: cstring
-    cpair_comment_single*: cstring
-    flag0*: int32
-    padding_dummy*: guint
-
-
-const
-  G_CSET_A_2_Z_UCASE* = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-  G_CSET_a_2_z_lcase* = "abcdefghijklmnopqrstuvwxyz"
-  G_CSET_DIGITS* = "0123456789"
-
-const
-  bm_TGScannerConfig_case_sensitive* = 0x00000001'i32
-  bp_TGScannerConfig_case_sensitive* = 0'i32
-  bm_TGScannerConfig_skip_comment_multi* = 0x00000002'i32
-  bp_TGScannerConfig_skip_comment_multi* = 1'i32
-  bm_TGScannerConfig_skip_comment_single* = 0x00000004'i32
-  bp_TGScannerConfig_skip_comment_single* = 2'i32
-  bm_TGScannerConfig_scan_comment_multi* = 0x00000008'i32
-  bp_TGScannerConfig_scan_comment_multi* = 3'i32
-  bm_TGScannerConfig_scan_identifier* = 0x00000010'i32
-  bp_TGScannerConfig_scan_identifier* = 4'i32
-  bm_TGScannerConfig_scan_identifier_1char* = 0x00000020'i32
-  bp_TGScannerConfig_scan_identifier_1char* = 5'i32
-  bm_TGScannerConfig_scan_identifier_NULL* = 0x00000040'i32
-  bp_TGScannerConfig_scan_identifier_NULL* = 6'i32
-  bm_TGScannerConfig_scan_symbols* = 0x00000080'i32
-  bp_TGScannerConfig_scan_symbols* = 7'i32
-  bm_TGScannerConfig_scan_binary* = 0x00000100'i32
-  bp_TGScannerConfig_scan_binary* = 8'i32
-  bm_TGScannerConfig_scan_octal* = 0x00000200'i32
-  bp_TGScannerConfig_scan_octal* = 9'i32
-  bm_TGScannerConfig_scan_float* = 0x00000400'i32
-  bp_TGScannerConfig_scan_float* = 10'i32
-  bm_TGScannerConfig_scan_hex* = 0x00000800'i32
-  bp_TGScannerConfig_scan_hex* = 11'i32
-  bm_TGScannerConfig_scan_hex_dollar* = 0x00001000'i32
-  bp_TGScannerConfig_scan_hex_dollar* = 12'i32
-  bm_TGScannerConfig_scan_string_sq* = 0x00002000'i32
-  bp_TGScannerConfig_scan_string_sq* = 13'i32
-  bm_TGScannerConfig_scan_string_dq* = 0x00004000'i32
-  bp_TGScannerConfig_scan_string_dq* = 14'i32
-  bm_TGScannerConfig_numbers_2_int* = 0x00008000'i32
-  bp_TGScannerConfig_numbers_2_int* = 15'i32
-  bm_TGScannerConfig_int_2_float* = 0x00010000'i32
-  bp_TGScannerConfig_int_2_float* = 16'i32
-  bm_TGScannerConfig_identifier_2_string* = 0x00020000'i32
-  bp_TGScannerConfig_identifier_2_string* = 17'i32
-  bm_TGScannerConfig_char_2_token* = 0x00040000'i32
-  bp_TGScannerConfig_char_2_token* = 18'i32
-  bm_TGScannerConfig_symbol_2_token* = 0x00080000'i32
-  bp_TGScannerConfig_symbol_2_token* = 19'i32
-  bm_TGScannerConfig_scope_0_fallback* = 0x00100000'i32
-  bp_TGScannerConfig_scope_0_fallback* = 20'i32
-
-proc TGScannerConfig_case_sensitive*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_case_sensitive*(a: var TGScannerConfig,
-    `case_sensitive`: guint)
-proc TGScannerConfig_skip_comment_multi*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_skip_comment_multi*(a: var TGScannerConfig,
-    `skip_comment_multi`: guint)
-proc TGScannerConfig_skip_comment_single*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_skip_comment_single*(a: var TGScannerConfig,
-    `skip_comment_single`: guint)
-proc TGScannerConfig_scan_comment_multi*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_comment_multi*(a: var TGScannerConfig,
-    `scan_comment_multi`: guint)
-proc TGScannerConfig_scan_identifier*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier*(a: var TGScannerConfig,
-    `scan_identifier`: guint)
-proc TGScannerConfig_scan_identifier_1char*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier_1char*(a: var TGScannerConfig,
-    `scan_identifier_1char`: guint)
-proc TGScannerConfig_scan_identifier_NULL*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier_NULL*(a: var TGScannerConfig,
-    `scan_identifier_NULL`: guint)
-proc TGScannerConfig_scan_symbols*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_symbols*(a: var TGScannerConfig,
-                                       `scan_symbols`: guint)
-proc TGScannerConfig_scan_binary*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_binary*(a: var TGScannerConfig,
-                                      `scan_binary`: guint)
-proc TGScannerConfig_scan_octal*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_octal*(a: var TGScannerConfig, `scan_octal`: guint)
-proc TGScannerConfig_scan_float*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_float*(a: var TGScannerConfig, `scan_float`: guint)
-proc TGScannerConfig_scan_hex*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_hex*(a: var TGScannerConfig, `scan_hex`: guint)
-proc TGScannerConfig_scan_hex_dollar*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_hex_dollar*(a: var TGScannerConfig,
-    `scan_hex_dollar`: guint)
-proc TGScannerConfig_scan_string_sq*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_string_sq*(a: var TGScannerConfig,
-    `scan_string_sq`: guint)
-proc TGScannerConfig_scan_string_dq*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scan_string_dq*(a: var TGScannerConfig,
-    `scan_string_dq`: guint)
-proc TGScannerConfig_numbers_2_int*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_numbers_2_int*(a: var TGScannerConfig,
-                                        `numbers_2_int`: guint)
-proc TGScannerConfig_int_2_float*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_int_2_float*(a: var TGScannerConfig,
-                                      `int_2_float`: guint)
-proc TGScannerConfig_identifier_2_string*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_identifier_2_string*(a: var TGScannerConfig,
-    `identifier_2_string`: guint)
-proc TGScannerConfig_char_2_token*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_char_2_token*(a: var TGScannerConfig,
-                                       `char_2_token`: guint)
-proc TGScannerConfig_symbol_2_token*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_symbol_2_token*(a: var TGScannerConfig,
-    `symbol_2_token`: guint)
-proc TGScannerConfig_scope_0_fallback*(a: var TGScannerConfig): guint
-proc TGScannerConfig_set_scope_0_fallback*(a: var TGScannerConfig,
-    `scope_0_fallback`: guint)
-proc g_scanner_new*(config_templ: PGScannerConfig): PGScanner{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_new".}
-proc g_scanner_destroy*(scanner: PGScanner){.cdecl, dynlib: gliblib,
-    importc: "g_scanner_destroy".}
-proc g_scanner_input_file*(scanner: PGScanner, input_fd: gint){.cdecl,
-    dynlib: gliblib, importc: "g_scanner_input_file".}
-proc g_scanner_sync_file_offset*(scanner: PGScanner){.cdecl, dynlib: gliblib,
-    importc: "g_scanner_sync_file_offset".}
-proc g_scanner_input_text*(scanner: PGScanner, text: cstring, text_len: guint){.
-    cdecl, dynlib: gliblib, importc: "g_scanner_input_text".}
-proc g_scanner_get_next_token*(scanner: PGScanner): TGTokenType{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_get_next_token".}
-proc g_scanner_peek_next_token*(scanner: PGScanner): TGTokenType{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_peek_next_token".}
-proc g_scanner_cur_token*(scanner: PGScanner): TGTokenType{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_cur_token".}
-proc g_scanner_cur_value*(scanner: PGScanner): TGTokenValue{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_cur_value".}
-proc g_scanner_cur_line*(scanner: PGScanner): guint{.cdecl, dynlib: gliblib,
-    importc: "g_scanner_cur_line".}
-proc g_scanner_cur_position*(scanner: PGScanner): guint{.cdecl, dynlib: gliblib,
-    importc: "g_scanner_cur_position".}
-proc g_scanner_eof*(scanner: PGScanner): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_scanner_eof".}
-proc g_scanner_set_scope*(scanner: PGScanner, scope_id: guint): guint{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_set_scope".}
-proc g_scanner_scope_add_symbol*(scanner: PGScanner, scope_id: guint,
-                                 symbol: cstring, value: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_scanner_scope_add_symbol".}
-proc g_scanner_scope_remove_symbol*(scanner: PGScanner, scope_id: guint,
-                                    symbol: cstring){.cdecl, dynlib: gliblib,
-    importc: "g_scanner_scope_remove_symbol".}
-proc g_scanner_scope_lookup_symbol*(scanner: PGScanner, scope_id: guint,
-                                    symbol: cstring): gpointer{.cdecl,
-    dynlib: gliblib, importc: "g_scanner_scope_lookup_symbol".}
-proc g_scanner_scope_foreach_symbol*(scanner: PGScanner, scope_id: guint,
-                                     func: TGHFunc, user_data: gpointer){.cdecl,
-    dynlib: gliblib, importc: "g_scanner_scope_foreach_symbol".}
-proc g_scanner_lookup_symbol*(scanner: PGScanner, symbol: cstring): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_scanner_lookup_symbol".}
-proc g_scanner_unexp_token*(scanner: PGScanner, expected_token: TGTokenType,
-                            identifier_spec: cstring, symbol_spec: cstring,
-                            symbol_name: cstring, `message`: cstring,
-                            is_error: gint){.cdecl, dynlib: gliblib,
-    importc: "g_scanner_unexp_token".}
-proc G_SHELL_ERROR*(): TGQuark
-type
-  PGShellError* = ptr TGShellError
-  TGShellError* = enum
-    G_SHELL_ERROR_BAD_QUOTING, G_SHELL_ERROR_EMPTY_STRING, G_SHELL_ERROR_FAILED
-
-proc g_shell_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-                                      importc: "g_shell_error_quark".}
-proc g_shell_quote*(unquoted_string: cstring): cstring{.cdecl, dynlib: gliblib,
-    importc: "g_shell_quote".}
-proc g_shell_unquote*(quoted_string: cstring, error: pointer): cstring{.cdecl,
-    dynlib: gliblib, importc: "g_shell_unquote".}
-proc g_shell_parse_argv*(command_line: cstring, argcp: Pgint, argvp: PPPgchar,
-                         error: pointer): gboolean{.cdecl, dynlib: gliblib,
-    importc: "g_shell_parse_argv".}
-proc G_SPAWN_ERROR*(): TGQuark
-type
-  PGSpawnError* = ptr TGSpawnError
-  TGSpawnError* = enum
-    G_SPAWN_ERROR_FORK, G_SPAWN_ERROR_READ, G_SPAWN_ERROR_CHDIR,
-    G_SPAWN_ERROR_ACCES, G_SPAWN_ERROR_PERM, G_SPAWN_ERROR_2BIG,
-    G_SPAWN_ERROR_NOEXEC, G_SPAWN_ERROR_NAMETOOLONG, G_SPAWN_ERROR_NOENT,
-    G_SPAWN_ERROR_NOMEM, G_SPAWN_ERROR_NOTDIR, G_SPAWN_ERROR_LOOP,
-    G_SPAWN_ERROR_TXTBUSY, G_SPAWN_ERROR_IO, G_SPAWN_ERROR_NFILE,
-    G_SPAWN_ERROR_MFILE, G_SPAWN_ERROR_INVAL, G_SPAWN_ERROR_ISDIR,
-    G_SPAWN_ERROR_LIBBAD, G_SPAWN_ERROR_FAILED
-  TGSpawnChildSetupFunc* = proc (user_data: gpointer){.cdecl.}
-  PGSpawnFlags* = ptr TGSpawnFlags
-  TGSpawnFlags* = int
-
-const
-  G_SPAWN_LEAVE_DESCRIPTORS_OPEN* = 1 shl 0
-  G_SPAWN_DO_NOT_REAP_CHILD* = 1 shl 1
-  G_SPAWN_SEARCH_PATH* = 1 shl 2
-  G_SPAWN_STDOUT_TO_DEV_NULL* = 1 shl 3
-  G_SPAWN_STDERR_TO_DEV_NULL* = 1 shl 4
-  G_SPAWN_CHILD_INHERITS_STDIN* = 1 shl 5
-  G_SPAWN_FILE_AND_ARGV_ZERO* = 1 shl 6
-
-proc g_spawn_error_quark*(): TGQuark{.cdecl, dynlib: gliblib,
-                                      importc: "g_spawn_error_quark".}
-proc g_spawn_async*(working_directory: cstring, argv: PPgchar, envp: PPgchar,
-                    flags: TGSpawnFlags, child_setup: TGSpawnChildSetupFunc,
-                    user_data: gpointer, child_pid: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_async".}
-proc g_spawn_async_with_pipes*(working_directory: cstring, argv: PPgchar,
-                               envp: PPgchar, flags: TGSpawnFlags,
-                               child_setup: TGSpawnChildSetupFunc,
-                               user_data: gpointer, child_pid: Pgint,
-                               standard_input: Pgint, standard_output: Pgint,
-                               standard_error: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_async_with_pipes".}
-proc g_spawn_sync*(working_directory: cstring, argv: PPgchar, envp: PPgchar,
-                   flags: TGSpawnFlags, child_setup: TGSpawnChildSetupFunc,
-                   user_data: gpointer, standard_output: PPgchar,
-                   standard_error: PPgchar, exit_status: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_sync".}
-proc g_spawn_command_line_sync*(command_line: cstring, standard_output: PPgchar,
-                                standard_error: PPgchar, exit_status: Pgint,
-                                error: pointer): gboolean{.cdecl,
-    dynlib: gliblib, importc: "g_spawn_command_line_sync".}
-proc g_spawn_command_line_async*(command_line: cstring, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_command_line_async".}
-proc G_TYPE_IS_BOXED*(theType: GType): gboolean
-proc G_VALUE_HOLDS_BOXED*(value: PGValue): gboolean
-proc G_TYPE_CLOSURE*(): GType
-proc G_TYPE_VALUE*(): GType
-proc G_TYPE_VALUE_ARRAY*(): GType
-proc G_TYPE_GSTRING*(): GType
-proc g_boxed_copy*(boxed_type: GType, src_boxed: gconstpointer): gpointer{.
-    cdecl, dynlib: gobjectlib, importc: "g_boxed_copy".}
-proc g_boxed_free*(boxed_type: GType, boxed: gpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_boxed_free".}
-proc g_value_set_boxed*(value: PGValue, v_boxed: gconstpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_boxed".}
-proc g_value_set_static_boxed*(value: PGValue, v_boxed: gconstpointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_value_set_static_boxed".}
-proc g_value_get_boxed*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_get_boxed".}
-proc g_value_dup_boxed*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib,
-    importc: "g_value_dup_boxed".}
-proc g_boxed_type_register_static*(name: cstring, boxed_copy: TGBoxedCopyFunc,
-                                   boxed_free: TGBoxedFreeFunc): GType{.cdecl,
-    dynlib: gobjectlib, importc: "g_boxed_type_register_static".}
-proc g_value_set_boxed_take_ownership*(value: PGValue, v_boxed: gconstpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_boxed_take_ownership".}
-proc g_closure_get_type*(): GType{.cdecl, dynlib: gobjectlib,
-                                   importc: "g_closure_get_type".}
-proc g_value_get_type*(): GType{.cdecl, dynlib: gobjectlib,
-                                 importc: "g_value_get_type".}
-proc g_value_array_get_type*(): GType{.cdecl, dynlib: gobjectlib,
-                                       importc: "g_value_array_get_type".}
-proc g_gstring_get_type*(): GType{.cdecl, dynlib: gobjectlib,
-                                   importc: "g_gstring_get_type".}
-type
-  PGModule* = pointer
-  TGModuleFlags* = int32
-  TGModuleCheckInit* = proc (module: PGModule): cstring{.cdecl.}
-  TGModuleUnload* = proc (module: PGModule){.cdecl.}
-
-const
-  G_MODULE_BIND_LAZY* = 1 shl 0
-  G_MODULE_BIND_MASK* = 1
-
-proc g_module_supported*(): gboolean{.cdecl, dynlib: gmodulelib,
-                                      importc: "g_module_supported".}
-proc g_module_open*(file_name: cstring, flags: TGModuleFlags): PGModule{.cdecl,
-    dynlib: gmodulelib, importc: "g_module_open".}
-proc g_module_close*(module: PGModule): gboolean{.cdecl, dynlib: gmodulelib,
-    importc: "g_module_close".}
-proc g_module_make_resident*(module: PGModule){.cdecl, dynlib: gmodulelib,
-    importc: "g_module_make_resident".}
-proc g_module_error*(): cstring{.cdecl, dynlib: gmodulelib,
-                                 importc: "g_module_error".}
-proc g_module_symbol*(module: PGModule, symbol_name: cstring, symbol: Pgpointer): gboolean{.
-    cdecl, dynlib: gmodulelib, importc: "g_module_symbol".}
-proc g_module_name*(module: PGModule): cstring{.cdecl, dynlib: gmodulelib,
-    importc: "g_module_name".}
-proc g_module_build_path*(directory: cstring, module_name: cstring): cstring{.
-    cdecl, dynlib: gmodulelib, importc: "g_module_build_path".}
-proc g_cclosure_marshal_VOID_VOID*(closure: PGClosure, return_value: PGValue,
-                                    n_param_values: GUInt,
-                                    param_values: PGValue,
-                                    invocation_hint: GPointer,
-                                    marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__VOID".}
-proc g_cclosure_marshal_VOID_BOOLEAN*(closure: PGClosure,
-                                       return_value: PGValue,
-                                       n_param_values: GUInt,
-                                       param_values: PGValue,
-                                       invocation_hint: GPointer,
-                                       marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__BOOLEAN".}
-proc g_cclosure_marshal_VOID_CHAR*(closure: PGClosure, return_value: PGValue,
-                                    n_param_values: GUInt,
-                                    param_values: PGValue,
-                                    invocation_hint: GPointer,
-                                    marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__CHAR".}
-proc g_cclosure_marshal_VOID_UCHAR*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UCHAR".}
-proc g_cclosure_marshal_VOID_INT*(closure: PGClosure, return_value: PGValue,
-                                   n_param_values: GUInt, param_values: PGValue,
-                                   invocation_hint: GPointer,
-                                   marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__INT".}
-proc g_cclosure_marshal_VOID_UINT*(closure: PGClosure, return_value: PGValue,
-                                    n_param_values: GUInt,
-                                    param_values: PGValue,
-                                    invocation_hint: GPointer,
-                                    marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UINT".}
-proc g_cclosure_marshal_VOID_LONG*(closure: PGClosure, return_value: PGValue,
-                                    n_param_values: GUInt,
-                                    param_values: PGValue,
-                                    invocation_hint: GPointer,
-                                    marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__LONG".}
-proc g_cclosure_marshal_VOID_ULONG*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__ULONG".}
-proc g_cclosure_marshal_VOID_ENUM*(closure: PGClosure, return_value: PGValue,
-                                    n_param_values: GUInt,
-                                    param_values: PGValue,
-                                    invocation_hint: GPointer,
-                                    marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__ENUM".}
-proc g_cclosure_marshal_VOID_FLAGS*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__FLAGS".}
-proc g_cclosure_marshal_VOID_FLOAT*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__FLOAT".}
-proc g_cclosure_marshal_VOID_DOUBLE*(closure: PGClosure, return_value: PGValue,
-                                      n_param_values: GUInt,
-                                      param_values: PGValue,
-                                      invocation_hint: GPointer,
-                                      marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__DOUBLE".}
-proc g_cclosure_marshal_VOID_STRING*(closure: PGClosure, return_value: PGValue,
-                                      n_param_values: GUInt,
-                                      param_values: PGValue,
-                                      invocation_hint: GPointer,
-                                      marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__STRING".}
-proc g_cclosure_marshal_VOID_PARAM*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__PARAM".}
-proc g_cclosure_marshal_VOID_BOXED*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__BOXED".}
-proc g_cclosure_marshal_VOID_POINTER*(closure: PGClosure,
-                                       return_value: PGValue,
-                                       n_param_values: GUInt,
-                                       param_values: PGValue,
-                                       invocation_hint: GPointer,
-                                       marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__POINTER".}
-proc g_cclosure_marshal_VOID_OBJECT*(closure: PGClosure, return_value: PGValue,
-                                      n_param_values: GUInt,
-                                      param_values: PGValue,
-                                      invocation_hint: GPointer,
-                                      marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__OBJECT".}
-proc g_cclosure_marshal_STRING_OBJECT_POINTER*(closure: PGClosure,
-    return_value: PGValue, n_param_values: GUInt, param_values: PGValue,
-    invocation_hint: GPointer, marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_STRING__OBJECT_POINTER".}
-proc g_cclosure_marshal_VOID_UINT_POINTER*(closure: PGClosure,
-    return_value: PGValue, n_param_values: GUInt, param_values: PGValue,
-    invocation_hint: GPointer, marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UINT_POINTER".}
-proc g_cclosure_marshal_BOOLEAN_FLAGS*(closure: PGClosure,
-                                        return_value: PGValue,
-                                        n_param_values: GUInt,
-                                        param_values: PGValue,
-                                        invocation_hint: GPointer,
-                                        marshal_data: GPointer){.cdecl,
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_BOOLEAN__FLAGS".}
-proc g_cclosure_marshal_BOOL_FLAGS*(closure: PGClosure, return_value: PGValue,
-                                     n_param_values: GUInt,
-                                     param_values: PGValue,
-                                     invocation_hint: GPointer,
-                                     marshal_data: GPointer){.cdecl,
-    dynlib: gliblib, importc: "g_cclosure_marshal_BOOLEAN__FLAGS".}
-
-proc GUINT16_SWAP_LE_BE_CONSTANT*(val: guint16): guint16 =
-  Result = ((val and 0x00FF'i16) shl 8'i16) or ((val and 0xFF00'i16) shr 8'i16)
-
-proc GUINT32_SWAP_LE_BE_CONSTANT*(val: guint32): guint32 =
-  Result = ((val and 0x000000FF'i32) shl 24'i32) or ((val and 0x0000FF00'i32) shl 8'i32) or
-      ((val and 0x00FF0000'i32) shr 8'i32) or ((val and 0xFF000000'i32) shr 24'i32)
-
-proc GUINT_TO_POINTER*(i: guint): pointer =
-  Result = cast[Pointer](TAddress(i))
-
-
-when false:
-
-  type
-    PGArray* = pointer
-
-  proc g_array_append_val*(a: PGArray, v: gpointer): PGArray =
-    result = g_array_append_vals(a, addr(v), 1)
-
-  proc g_array_prepend_val*(a: PGArray, v: gpointer): PGArray =
-    result = g_array_prepend_vals(a, addr(v), 1)
-
-  proc g_array_insert_val*(a: PGArray, i: guint, v: gpointer): PGArray =
-    result = g_array_insert_vals(a, i, addr(v), 1)
-
-  proc g_ptr_array_index*(parray: PGPtrArray, index: guint): gpointer =
-    result = cast[PGPointer](cast[int](parray ^. pdata) +
-        index * SizeOf(GPointer))^
-
-  proc G_THREAD_ERROR*(): TGQuark =
-    result = g_thread_error_quark()
-
-  proc g_mutex_lock*(mutex: PGMutex) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.mutex_lock(mutex)
-
-  proc g_mutex_trylock*(mutex: PGMutex): gboolean =
-    if g_threads_got_initialized:
-      result = g_thread_functions_for_glib_use.mutex_trylock(mutex)
-    else:
-      result = true
-
-  proc g_mutex_unlock*(mutex: PGMutex) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.mutex_unlock(mutex)
-
-  proc g_mutex_free*(mutex: PGMutex) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.mutex_free(mutex)
-
-  proc g_cond_wait*(cond: PGCond, mutex: PGMutex) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.cond_wait(cond, mutex)
-
-  proc g_cond_timed_wait*(cond: PGCond, mutex: PGMutex, end_time: PGTimeVal): gboolean =
-    if g_threads_got_initialized:
-      result = g_thread_functions_for_glib_use.cond_timed_wait(cond, mutex,
-          end_time)
-    else:
-      result = true
-
-  proc g_thread_supported*(): gboolean =
-    result = g_threads_got_initialized
-
-  proc g_mutex_new*(): PGMutex =
-    result = g_thread_functions_for_glib_use.mutex_new()
-
-  proc g_cond_new*(): PGCond =
-    result = g_thread_functions_for_glib_use.cond_new()
-
-  proc g_cond_signal*(cond: PGCond) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.cond_signal(cond)
-
-  proc g_cond_broadcast*(cond: PGCond) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.cond_broadcast(cond)
-
-  proc g_cond_free*(cond: PGCond) =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.cond_free(cond)
-
-  proc g_private_new*(dest: TGDestroyNotify): PGPrivate =
-    result = g_thread_functions_for_glib_use.private_new(dest)
-
-  proc g_private_get*(private_key: PGPrivate): gpointer =
-    if g_threads_got_initialized:
-      result = g_thread_functions_for_glib_use.private_get(private_key)
-    else:
-      result = private_key
-
-  proc g_private_set*(private_key: var PGPrivate, data: gpointer) =
-    if g_threads_got_initialized:
-      nil
-    else:
-      private_key = data
-
-  proc g_thread_yield*() =
-    if g_threads_got_initialized:
-      g_thread_functions_for_glib_use.thread_yield
-
-  proc g_thread_create*(func: TGThreadFunc, data: gpointer, joinable: gboolean,
-                        error: pointer): PGThread =
-    result = g_thread_create_full(func, data, 0, joinable, false,
-                                  G_THREAD_PRIORITY_NORMAL, error)
-
-  proc g_static_mutex_get_mutex*(mutex: PPGMutex): PGMutex =
-    result = g_static_mutex_get_mutex_impl(mutex)
-
-  proc g_static_mutex_lock*(mutex: PGStaticMutex) =
-    g_mutex_lock(g_static_mutex_get_mutex_impl(PPGMutex(mutex)))
-
-  proc g_static_mutex_trylock*(mutex: PGStaticMutex): gboolean =
-    result = g_mutex_trylock(g_static_mutex_get_mutex(PPGMutex(mutex)))
-
-  proc g_static_mutex_unlock*(mutex: PGStaticMutex) =
-    g_mutex_unlock(g_static_mutex_get_mutex_impl(PPGMutex(mutex)))
-
-  proc g_main_new*(is_running: gboolean): PGMainLoop =
-    result = g_main_loop_new(nil, is_running)
-
-  proc g_main_iteration*(may_block: gboolean): gboolean =
-    result = g_main_context_iteration(nil, may_block)
-
-  proc g_main_pending*(): gboolean =
-    result = g_main_context_pending(nil)
-
-  proc g_main_set_poll_func*(func: TGPollFunc) =
-    g_main_context_set_poll_func(nil, func)
-
-proc g_slist_next*(slist: PGSList): PGSList =
-  if slist != nil:
-    result = slist.next
-  else:
-    result = nil
-
-proc g_new*(bytes_per_struct, n_structs: int): gpointer =
-  result = g_malloc(n_structs * bytes_per_struct)
-
-proc g_new0*(bytes_per_struct, n_structs: int): gpointer =
-  result = g_malloc0(n_structs * bytes_per_struct)
-
-proc g_renew*(struct_size: int, OldMem: gpointer, n_structs: int): gpointer =
-  result = g_realloc(OldMem, struct_size * n_structs)
-
-proc g_chunk_new*(chunk: Pointer): Pointer =
-  result = g_mem_chunk_alloc(chunk)
-
-proc g_chunk_new0*(chunk: Pointer): Pointer =
-  result = g_mem_chunk_alloc0(chunk)
-
-proc g_chunk_free*(mem_chunk: PGMemChunk, mem: gpointer) =
-  g_mem_chunk_free(mem_chunk, mem)
-
-proc g_list_previous*(list: PGList): PGList =
-  if list != nil:
-    result = list.prev
-  else:
-    result = nil
-
-proc g_list_next*(list: PGList): PGList =
-  if list != nil:
-    result = list.next
-  else:
-    result = nil
-
-proc G_CONVERT_ERROR*(): TGQuark =
-  result = g_convert_error_quark()
-
-proc g_datalist_id_set_data*(datalist: PPGData, key_id: TGQuark, data: gpointer) =
-  g_datalist_id_set_data_full(datalist, key_id, data, TGDestroyNotify(nil))
-
-proc g_datalist_id_remove_data*(datalist: PPGData, key_id: TGQuark) =
-  g_datalist_id_set_data(datalist, key_id, nil)
-
-proc g_datalist_get_data*(datalist: PPGData, key_str: cstring): PPGData =
-  result = cast[PPGData](g_datalist_id_get_data(datalist,
-                                                g_quark_try_string(key_str)))
-
-proc g_datalist_set_data_full*(datalist: PPGData, key_str: cstring,
-                               data: gpointer, destroy_func: TGDestroyNotify) =
-  g_datalist_id_set_data_full(datalist, g_quark_from_string(key_str), data,
-                              destroy_func)
-
-proc g_datalist_set_data*(datalist: PPGData, key_str: cstring, data: gpointer) =
-  g_datalist_set_data_full(datalist, key_str, data, nil)
-
-proc g_datalist_remove_no_notify*(datalist: PPGData, key_str: cstring) =
-  discard g_datalist_id_remove_no_notify(datalist, g_quark_try_string(key_str))
-
-proc g_datalist_remove_data*(datalist: PPGData, key_str: cstring) =
-  g_datalist_id_set_data(datalist, g_quark_try_string(key_str), nil)
-
-proc g_dataset_id_set_data*(location: gconstpointer, key_id: TGQuark,
-                            data: gpointer) =
-  g_dataset_id_set_data_full(location, key_id, data, nil)
-
-proc g_dataset_id_remove_data*(location: gconstpointer, key_id: TGQuark) =
-  g_dataset_id_set_data(location, key_id, nil)
-
-proc g_dataset_get_data*(location: gconstpointer, key_str: cstring): gpointer =
-  result = g_dataset_id_get_data(location, g_quark_try_string(key_str))
-
-proc g_dataset_set_data_full*(location: gconstpointer, key_str: cstring,
-                              data: gpointer, destroy_func: TGDestroyNotify) =
-  g_dataset_id_set_data_full(location, g_quark_from_string(key_str), data,
-                             destroy_func)
-
-proc g_dataset_remove_no_notify*(location: gconstpointer, key_str: cstring) =
-  discard g_dataset_id_remove_no_notify(location, g_quark_try_string(key_str))
-
-proc g_dataset_set_data*(location: gconstpointer, key_str: cstring,
-                         data: gpointer) =
-  g_dataset_set_data_full(location, key_str, data, nil)
-
-proc g_dataset_remove_data*(location: gconstpointer, key_str: cstring) =
-  g_dataset_id_set_data(location, g_quark_try_string(key_str), nil)
-
-proc G_FILE_ERROR*(): TGQuark =
-  result = g_file_error_quark()
-
-proc TGHookList_hook_size*(a: var TGHookList): guint =
-  result = (a.flag0 and bm_TGHookList_hook_size) shr bp_TGHookList_hook_size
-
-proc TGHookList_set_hook_size*(a: var TGHookList, `hook_size`: guint) =
-  a.flag0 = a.flag0 or
-      ((`hook_size` shl bp_TGHookList_hook_size) and bm_TGHookList_hook_size)
-
-proc TGHookList_is_setup*(a: var TGHookList): guint =
-  result = (a.flag0 and bm_TGHookList_is_setup) shr bp_TGHookList_is_setup
-
-proc TGHookList_set_is_setup*(a: var TGHookList, `is_setup`: guint) =
-  a.flag0 = a.flag0 or
-      ((`is_setup` shl bp_TGHookList_is_setup) and bm_TGHookList_is_setup)
-
-proc G_HOOK*(hook: pointer): PGHook =
-  result = cast[PGHook](hook)
-
-proc G_HOOK_FLAGS*(hook: PGHook): guint =
-  result = hook.flags
-
-proc G_HOOK_ACTIVE*(hook: PGHook): bool =
-  result = (hook.flags and G_HOOK_FLAG_ACTIVE) != 0'i32
-
-proc G_HOOK_IN_CALL*(hook: PGHook): bool =
-  result = (hook.flags and G_HOOK_FLAG_IN_CALL) != 0'i32
-
-proc G_HOOK_IS_VALID*(hook: PGHook): bool =
-  result = (hook.hook_id != 0) and G_HOOK_ACTIVE(hook)
-
-proc G_HOOK_IS_UNLINKED*(hook: PGHook): bool =
-  result = (hook.next == nil) and (hook.prev == nil) and
-      (hook.hook_id == 0) and (hook.ref_count == 0'i32)
-
-proc g_hook_append*(hook_list: PGHookList, hook: PGHook) =
-  g_hook_insert_before(hook_list, nil, hook)
-
-proc G_IO_CHANNEL_ERROR*(): TGQuark =
-  result = g_io_channel_error_quark()
-
-proc TGIOChannel_use_buffer*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_use_buffer) shr
-      bp_TGIOChannel_use_buffer
-
-proc TGIOChannel_set_use_buffer*(a: var TGIOChannel, `use_buffer`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`use_buffer` shl bp_TGIOChannel_use_buffer) and
-      bm_TGIOChannel_use_buffer)
-
-proc TGIOChannel_do_encode*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_do_encode) shr
-      bp_TGIOChannel_do_encode
-
-proc TGIOChannel_set_do_encode*(a: var TGIOChannel, `do_encode`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`do_encode` shl bp_TGIOChannel_do_encode) and
-      bm_TGIOChannel_do_encode)
-
-proc TGIOChannel_close_on_unref*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_close_on_unref) shr
-      bp_TGIOChannel_close_on_unref
-
-proc TGIOChannel_set_close_on_unref*(a: var TGIOChannel, `close_on_unref`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`close_on_unref` shl bp_TGIOChannel_close_on_unref) and
-      bm_TGIOChannel_close_on_unref)
-
-proc TGIOChannel_is_readable*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_is_readable) shr
-      bp_TGIOChannel_is_readable
-
-proc TGIOChannel_set_is_readable*(a: var TGIOChannel, `is_readable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_readable` shl bp_TGIOChannel_is_readable) and
-      bm_TGIOChannel_is_readable)
-
-proc TGIOChannel_is_writeable*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_is_writeable) shr
-      bp_TGIOChannel_is_writeable
-
-proc TGIOChannel_set_is_writeable*(a: var TGIOChannel, `is_writeable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_writeable` shl bp_TGIOChannel_is_writeable) and
-      bm_TGIOChannel_is_writeable)
-
-proc TGIOChannel_is_seekable*(a: var TGIOChannel): guint =
-  result = (a.flag0 and bm_TGIOChannel_is_seekable) shr
-      bp_TGIOChannel_is_seekable
-
-proc TGIOChannel_set_is_seekable*(a: var TGIOChannel, `is_seekable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_seekable` shl bp_TGIOChannel_is_seekable) and
-      bm_TGIOChannel_is_seekable)
-
-proc g_utf8_next_char*(p: pguchar): pguchar =
-  result = cast[pguchar](cast[TAddress](p)+1) # p + ord((g_utf8_skip + p^ )^ )
-
-when false:
-  proc GLIB_CHECK_VERSION*(major, minor, micro: guint): bool =
-    result = ((GLIB_MAJOR_VERSION > major) or
-        ((GLIB_MAJOR_VERSION == major) and (GLIB_MINOR_VERSION > minor)) or
-        ((GLIB_MAJOR_VERSION == major) and (GLIB_MINOR_VERSION == minor) and
-        (GLIB_MICRO_VERSION >= micro)))
-
-  proc g_error*(format: cstring) =
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format)
-
-  proc g_message*(format: cstring) =
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format)
-
-  proc g_critical*(format: cstring) =
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format)
-
-  proc g_warning*(format: cstring) =
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format)
-
-proc G_MARKUP_ERROR*(): TGQuark =
-  result = g_markup_error_quark()
-
-proc G_NODE_IS_ROOT*(node: PGNode): bool =
-  result = (node . parent == nil) and (node . next == nil) and
-      (node . prev == nil)
-
-proc G_NODE_IS_LEAF*(node: PGNode): bool =
-  result = node . children == nil
-
-proc g_node_append*(parent: PGNode, node: PGNode): PGNode =
-  result = g_node_insert_before(parent, nil, node)
-
-proc g_node_insert_data*(parent: PGNode, position: gint, data: gpointer): PGNode =
-  result = g_node_insert(parent, position, g_node_new(data))
-
-proc g_node_insert_data_before*(parent: PGNode, sibling: PGNode, data: gpointer): PGNode =
-  result = g_node_insert_before(parent, sibling, g_node_new(data))
-
-proc g_node_prepend_data*(parent: PGNode, data: gpointer): PGNode =
-  result = g_node_prepend(parent, g_node_new(data))
-
-proc g_node_append_data*(parent: PGNode, data: gpointer): PGNode =
-  result = g_node_insert_before(parent, nil, g_node_new(data))
-
-proc g_node_prev_sibling*(node: PGNode): PGNode =
-  if node != nil:
-    result = node.prev
-  else:
-    result = nil
-
-proc g_node_next_sibling*(node: PGNode): PGNode =
-  if node != nil:
-    result = node.next
-  else:
-    result = nil
-
-proc g_node_first_child*(node: PGNode): PGNode =
-  if node != nil:
-    result = node.children
-  else:
-    result = nil
-
-proc g_rand_boolean*(rand: PGRand): gboolean =
-  result = (int(g_rand_int(rand)) and (1 shl 15)) != 0
-
-proc g_random_boolean*(): gboolean =
-  result = (int(g_random_int()) and (1 shl 15)) != 0
-
-proc TGScannerConfig_case_sensitive*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_case_sensitive) shr
-      bp_TGScannerConfig_case_sensitive
-
-proc TGScannerConfig_set_case_sensitive*(a: var TGScannerConfig,
-    `case_sensitive`: guint) =
-  a.flag0 = a.flag0 or
-      ((`case_sensitive` shl bp_TGScannerConfig_case_sensitive) and
-      bm_TGScannerConfig_case_sensitive)
-
-proc TGScannerConfig_skip_comment_multi*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_skip_comment_multi) shr
-      bp_TGScannerConfig_skip_comment_multi
-
-proc TGScannerConfig_set_skip_comment_multi*(a: var TGScannerConfig,
-    `skip_comment_multi`: guint) =
-  a.flag0 = a.flag0 or
-      ((`skip_comment_multi` shl bp_TGScannerConfig_skip_comment_multi) and
-      bm_TGScannerConfig_skip_comment_multi)
-
-proc TGScannerConfig_skip_comment_single*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_skip_comment_single) shr
-      bp_TGScannerConfig_skip_comment_single
-
-proc TGScannerConfig_set_skip_comment_single*(a: var TGScannerConfig,
-    `skip_comment_single`: guint) =
-  a.flag0 = a.flag0 or
-      ((`skip_comment_single` shl bp_TGScannerConfig_skip_comment_single) and
-      bm_TGScannerConfig_skip_comment_single)
-
-proc TGScannerConfig_scan_comment_multi*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_comment_multi) shr
-      bp_TGScannerConfig_scan_comment_multi
-
-proc TGScannerConfig_set_scan_comment_multi*(a: var TGScannerConfig,
-    `scan_comment_multi`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_comment_multi` shl bp_TGScannerConfig_scan_comment_multi) and
-      bm_TGScannerConfig_scan_comment_multi)
-
-proc TGScannerConfig_scan_identifier*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier) shr
-      bp_TGScannerConfig_scan_identifier
-
-proc TGScannerConfig_set_scan_identifier*(a: var TGScannerConfig,
-    `scan_identifier`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_identifier` shl bp_TGScannerConfig_scan_identifier) and
-      bm_TGScannerConfig_scan_identifier)
-
-proc TGScannerConfig_scan_identifier_1char*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier_1char) shr
-      bp_TGScannerConfig_scan_identifier_1char
-
-proc TGScannerConfig_set_scan_identifier_1char*(a: var TGScannerConfig,
-    `scan_identifier_1char`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_identifier_1char` shl bp_TGScannerConfig_scan_identifier_1char) and
-      bm_TGScannerConfig_scan_identifier_1char)
-
-proc TGScannerConfig_scan_identifier_NULL*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier_NULL) shr
-      bp_TGScannerConfig_scan_identifier_NULL
-
-proc TGScannerConfig_set_scan_identifier_NULL*(a: var TGScannerConfig,
-    `scan_identifier_NULL`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_identifier_NULL` shl bp_TGScannerConfig_scan_identifier_NULL) and
-      bm_TGScannerConfig_scan_identifier_NULL)
-
-proc TGScannerConfig_scan_symbols*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_symbols) shr
-      bp_TGScannerConfig_scan_symbols
-
-proc TGScannerConfig_set_scan_symbols*(a: var TGScannerConfig,
-                                       `scan_symbols`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_symbols` shl bp_TGScannerConfig_scan_symbols) and
-      bm_TGScannerConfig_scan_symbols)
-
-proc TGScannerConfig_scan_binary*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_binary) shr
-      bp_TGScannerConfig_scan_binary
-
-proc TGScannerConfig_set_scan_binary*(a: var TGScannerConfig,
-                                      `scan_binary`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_binary` shl bp_TGScannerConfig_scan_binary) and
-      bm_TGScannerConfig_scan_binary)
-
-proc TGScannerConfig_scan_octal*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_octal) shr
-      bp_TGScannerConfig_scan_octal
-
-proc TGScannerConfig_set_scan_octal*(a: var TGScannerConfig, `scan_octal`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_octal` shl bp_TGScannerConfig_scan_octal) and
-      bm_TGScannerConfig_scan_octal)
-
-proc TGScannerConfig_scan_float*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_float) shr
-      bp_TGScannerConfig_scan_float
-
-proc TGScannerConfig_set_scan_float*(a: var TGScannerConfig, `scan_float`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_float` shl bp_TGScannerConfig_scan_float) and
-      bm_TGScannerConfig_scan_float)
-
-proc TGScannerConfig_scan_hex*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_hex) shr
-      bp_TGScannerConfig_scan_hex
-
-proc TGScannerConfig_set_scan_hex*(a: var TGScannerConfig, `scan_hex`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_hex` shl bp_TGScannerConfig_scan_hex) and
-      bm_TGScannerConfig_scan_hex)
-
-proc TGScannerConfig_scan_hex_dollar*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_hex_dollar) shr
-      bp_TGScannerConfig_scan_hex_dollar
-
-proc TGScannerConfig_set_scan_hex_dollar*(a: var TGScannerConfig,
-    `scan_hex_dollar`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_hex_dollar` shl bp_TGScannerConfig_scan_hex_dollar) and
-      bm_TGScannerConfig_scan_hex_dollar)
-
-proc TGScannerConfig_scan_string_sq*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_string_sq) shr
-      bp_TGScannerConfig_scan_string_sq
-
-proc TGScannerConfig_set_scan_string_sq*(a: var TGScannerConfig,
-    `scan_string_sq`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_string_sq` shl bp_TGScannerConfig_scan_string_sq) and
-      bm_TGScannerConfig_scan_string_sq)
-
-proc TGScannerConfig_scan_string_dq*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scan_string_dq) shr
-      bp_TGScannerConfig_scan_string_dq
-
-proc TGScannerConfig_set_scan_string_dq*(a: var TGScannerConfig,
-    `scan_string_dq`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scan_string_dq` shl bp_TGScannerConfig_scan_string_dq) and
-      bm_TGScannerConfig_scan_string_dq)
-
-proc TGScannerConfig_numbers_2_int*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_numbers_2_int) shr
-      bp_TGScannerConfig_numbers_2_int
-
-proc TGScannerConfig_set_numbers_2_int*(a: var TGScannerConfig,
-                                        `numbers_2_int`: guint) =
-  a.flag0 = a.flag0 or
-      ((`numbers_2_int` shl bp_TGScannerConfig_numbers_2_int) and
-      bm_TGScannerConfig_numbers_2_int)
-
-proc TGScannerConfig_int_2_float*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_int_2_float) shr
-      bp_TGScannerConfig_int_2_float
-
-proc TGScannerConfig_set_int_2_float*(a: var TGScannerConfig,
-                                      `int_2_float`: guint) =
-  a.flag0 = a.flag0 or
-      ((`int_2_float` shl bp_TGScannerConfig_int_2_float) and
-      bm_TGScannerConfig_int_2_float)
-
-proc TGScannerConfig_identifier_2_string*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_identifier_2_string) shr
-      bp_TGScannerConfig_identifier_2_string
-
-proc TGScannerConfig_set_identifier_2_string*(a: var TGScannerConfig,
-    `identifier_2_string`: guint) =
-  a.flag0 = a.flag0 or
-      ((`identifier_2_string` shl bp_TGScannerConfig_identifier_2_string) and
-      bm_TGScannerConfig_identifier_2_string)
-
-proc TGScannerConfig_char_2_token*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_char_2_token) shr
-      bp_TGScannerConfig_char_2_token
-
-proc TGScannerConfig_set_char_2_token*(a: var TGScannerConfig,
-                                       `char_2_token`: guint) =
-  a.flag0 = a.flag0 or
-      ((`char_2_token` shl bp_TGScannerConfig_char_2_token) and
-      bm_TGScannerConfig_char_2_token)
-
-proc TGScannerConfig_symbol_2_token*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_symbol_2_token) shr
-      bp_TGScannerConfig_symbol_2_token
-
-proc TGScannerConfig_set_symbol_2_token*(a: var TGScannerConfig,
-    `symbol_2_token`: guint) =
-  a.flag0 = a.flag0 or
-      ((`symbol_2_token` shl bp_TGScannerConfig_symbol_2_token) and
-      bm_TGScannerConfig_symbol_2_token)
-
-proc TGScannerConfig_scope_0_fallback*(a: var TGScannerConfig): guint =
-  result = (a.flag0 and bm_TGScannerConfig_scope_0_fallback) shr
-      bp_TGScannerConfig_scope_0_fallback
-
-proc TGScannerConfig_set_scope_0_fallback*(a: var TGScannerConfig,
-    `scope_0_fallback`: guint) =
-  a.flag0 = a.flag0 or
-      ((`scope_0_fallback` shl bp_TGScannerConfig_scope_0_fallback) and
-      bm_TGScannerConfig_scope_0_fallback)
-
-proc g_scanner_freeze_symbol_table*(scanner: PGScanner) =
-  if Scanner == nil: nil
-
-proc g_scanner_thaw_symbol_table*(scanner: PGScanner) =
-  if Scanner == nil: nil
-
-proc G_SHELL_ERROR*(): TGQuark =
-  result = g_shell_error_quark()
-
-proc G_SPAWN_ERROR*(): TGQuark =
-  result = g_spawn_error_quark()
-
-when false:
-  proc g_ascii_isalnum*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_ALNUM) != 0
-
-  proc g_ascii_isalpha*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_ALPHA) != 0
-
-  proc g_ascii_iscntrl*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_CNTRL) != 0
-
-  proc g_ascii_isdigit*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_DIGIT) != 0
-
-  proc g_ascii_isgraph*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_GRAPH) != 0
-
-  proc g_ascii_islower*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_LOWER) != 0
-
-  proc g_ascii_isprint*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_PRINT) != 0
-
-  proc g_ascii_ispunct*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_PUNCT) != 0
-
-  proc g_ascii_isspace*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_SPACE) != 0
-
-  proc g_ascii_isupper*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_UPPER) != 0
-
-  proc g_ascii_isxdigit*(c: gchar): bool =
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_XDIGIT) != 0
-
-  proc g_strstrip*(str: cstring): cstring =
-    result = g_strchomp(g_strchug(str))
-
-proc G_TYPE_MAKE_FUNDAMENTAL*(x: int): GType =
-  result = GType(x shl G_TYPE_FUNDAMENTAL_SHIFT)
-
-proc G_TYPE_IS_FUNDAMENTAL*(theType: GType): bool =
-  result = theType <= G_TYPE_FUNDAMENTAL_MAX
-
-proc G_TYPE_IS_DERIVED*(theType: GType): bool =
-  result = theType > G_TYPE_FUNDAMENTAL_MAX
-
-proc G_TYPE_IS_INTERFACE*(theType: GType): bool =
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_INTERFACE
-
-proc G_TYPE_IS_CLASSED*(theType: GType): gboolean =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_CLASSED)
-
-proc G_TYPE_IS_INSTANTIATABLE*(theType: GType): bool =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_INSTANTIATABLE)
-
-proc G_TYPE_IS_DERIVABLE*(theType: GType): bool =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_DERIVABLE)
-
-proc G_TYPE_IS_DEEP_DERIVABLE*(theType: GType): bool =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_DEEP_DERIVABLE)
-
-proc G_TYPE_IS_ABSTRACT*(theType: GType): bool =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_ABSTRACT)
-
-proc G_TYPE_IS_VALUE_ABSTRACT*(theType: GType): bool =
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_VALUE_ABSTRACT)
-
-proc G_TYPE_IS_VALUE_TYPE*(theType: GType): bool =
-  result = private_g_type_check_is_value_type(theType)
-
-proc G_TYPE_HAS_VALUE_TABLE*(theType: GType): bool =
-  result = (g_type_value_table_peek(theType)) != nil
-
-proc G_TYPE_CHECK_INSTANCE*(instance: Pointer): gboolean =
-  result = private_g_type_check_instance(cast[PGTypeInstance](instance))
-
-proc G_TYPE_CHECK_INSTANCE_CAST*(instance: Pointer, g_type: GType): PGTypeInstance =
-  result = cast[PGTypeInstance](private_g_type_check_instance_cast(
-                                  cast[PGTypeInstance](instance), g_type))
-
-proc G_TYPE_CHECK_INSTANCE_TYPE*(instance: Pointer, g_type: GType): bool =
-  result = private_g_type_check_instance_is_a(
-             cast[PGTypeInstance](instance), g_type)
-
-proc G_TYPE_INSTANCE_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass =
-  result = cast[PGTypeInstance](Instance).g_class
-  result = private_g_type_check_class_cast(result, g_type)
-
-proc G_TYPE_INSTANCE_GET_INTERFACE*(instance: Pointer, g_type: GType): Pointer =
-  result = g_type_interface_peek((cast[PGTypeInstance](instance)).g_class, g_type)
-
-proc G_TYPE_CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer =
-  result = private_g_type_check_class_cast(cast[PGTypeClass](g_class), g_type)
-
-proc G_TYPE_CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool =
-  result = private_g_type_check_class_is_a(cast[PGTypeClass](g_class), g_type)
-
-proc G_TYPE_CHECK_VALUE*(value: Pointer): bool =
-  result = private_g_type_check_value(cast[PGValue](Value))
-
-proc G_TYPE_CHECK_VALUE_TYPE*(value: pointer, g_type: GType): bool =
-  result = private_g_type_check_value_holds(cast[PGValue](value), g_type)
-
-proc G_TYPE_FROM_INSTANCE*(instance: Pointer): GType =
-  result = G_TYPE_FROM_CLASS((cast[PGTypeInstance](instance)) . g_class)
-
-proc G_TYPE_FROM_CLASS*(g_class: Pointer): GType =
-  result = (cast[PGTypeClass](g_class)) . g_type
-
-proc G_TYPE_FROM_INTERFACE*(g_iface: Pointer): GType =
-  result = (cast[PGTypeInterface](g_iface)) . g_type
-
-proc G_TYPE_IS_VALUE*(theType: GType): bool =
-  result = private_g_type_check_is_value_type(theType)
-
-proc G_IS_VALUE*(value: Pointer): bool =
-  result = G_TYPE_CHECK_VALUE(value)
-
-proc G_VALUE_TYPE*(value: Pointer): GType =
-  result = (cast[PGValue](value)) . g_type
-
-proc G_VALUE_TYPE_NAME*(value: Pointer): cstring =
-  result = g_type_name(G_VALUE_TYPE(value))
-
-proc G_VALUE_HOLDS*(value: pointer, g_type: GType): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, g_type)
-
-proc G_TYPE_IS_PARAM*(theType: GType): bool =
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_PARAM
-
-proc G_PARAM_SPEC*(pspec: Pointer): PGParamSpec =
-  result = cast[PGParamSpec](G_TYPE_CHECK_INSTANCE_CAST(pspec, G_TYPE_PARAM))
-
-proc G_IS_PARAM_SPEC*(pspec: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(pspec, G_TYPE_PARAM)
-
-proc G_PARAM_SPEC_CLASS*(pclass: Pointer): PGParamSpecClass =
-  result = cast[PGParamSpecClass](
-             G_TYPE_CHECK_CLASS_CAST(pclass, G_TYPE_PARAM))
-
-proc G_IS_PARAM_SPEC_CLASS*(pclass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(pclass, G_TYPE_PARAM)
-
-proc G_PARAM_SPEC_GET_CLASS*(pspec: Pointer): PGParamSpecClass =
-  result = cast[PGParamSpecClass](G_TYPE_INSTANCE_GET_CLASS(pspec, G_TYPE_PARAM))
-
-proc G_PARAM_SPEC_TYPE*(pspec: Pointer): GType =
-  result = G_TYPE_FROM_INSTANCE(pspec)
-
-proc G_PARAM_SPEC_TYPE_NAME*(pspec: Pointer): cstring =
-  result = g_type_name(G_PARAM_SPEC_TYPE(pspec))
-
-proc G_PARAM_SPEC_VALUE_TYPE*(pspec: Pointer): GType =
-  result = (G_PARAM_SPEC(pspec)) . value_type
-
-proc G_VALUE_HOLDS_PARAM*(value: Pointer): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_PARAM)
-
-proc G_CLOSURE_NEEDS_MARSHAL*(closure: Pointer): bool =
-  result = cast[PGClosure](closure).marshal == nil
-
-proc G_CLOSURE_N_NOTIFIERS*(cl: PGClosure): int32 =
-  result = ((meta_marshal(cl) + ((n_guards(cl)) shl 1'i32)) + (n_fnotifiers(cl))) +
-      (n_inotifiers(cl))
-
-proc G_CCLOSURE_SWAP_DATA*(cclosure: PGClosure): int32 =
-  result = derivative_flag(cclosure)
-
-proc G_CALLBACK*(f: pointer): TGCallback =
-  result = cast[TGCallback](f)
-
-proc ref_count*(a: var TGClosure): guint =
-  result = (a.flag0 and bm_TGClosure_ref_count) shr bp_TGClosure_ref_count
-
-proc set_ref_count*(a: var TGClosure, `ref_count`: guint) =
-  a.flag0 = a.flag0 or
-      ((`ref_count` shl bp_TGClosure_ref_count) and bm_TGClosure_ref_count)
-
-proc meta_marshal*(a: PGClosure): guint =
-  result = (a . flag0 and bm_TGClosure_meta_marshal) shr
-      bp_TGClosure_meta_marshal
-
-proc set_meta_marshal*(a: var TGClosure, `meta_marshal`: guint) =
-  a.flag0 = a.flag0 or
-      ((`meta_marshal` shl bp_TGClosure_meta_marshal) and
-      bm_TGClosure_meta_marshal)
-
-proc n_guards*(a: PGClosure): guint =
-  result = (a . flag0 and bm_TGClosure_n_guards) shr bp_TGClosure_n_guards
-
-proc set_n_guards*(a: var TGClosure, `n_guards`: guint) =
-  a.flag0 = a.flag0 or
-      ((`n_guards` shl bp_TGClosure_n_guards) and bm_TGClosure_n_guards)
-
-proc n_fnotifiers*(a: PGClosure): guint =
-  result = (a . flag0 and bm_TGClosure_n_fnotifiers) shr
-      bp_TGClosure_n_fnotifiers
-
-proc set_n_fnotifiers*(a: var TGClosure, `n_fnotifiers`: guint) =
-  a.flag0 = a.flag0 or
-      ((`n_fnotifiers` shl bp_TGClosure_n_fnotifiers) and
-      bm_TGClosure_n_fnotifiers)
-
-proc n_inotifiers*(a: PGClosure): guint =
-  result = (a . flag0 and bm_TGClosure_n_inotifiers) shr
-      bp_TGClosure_n_inotifiers
-
-proc set_n_inotifiers*(a: var TGClosure, `n_inotifiers`: guint) =
-  a.flag0 = a.flag0 or
-      ((`n_inotifiers` shl bp_TGClosure_n_inotifiers) and
-      bm_TGClosure_n_inotifiers)
-
-proc in_inotify*(a: var TGClosure): guint =
-  result = (a.flag0 and bm_TGClosure_in_inotify) shr bp_TGClosure_in_inotify
-
-proc set_in_inotify*(a: var TGClosure, `in_inotify`: guint) =
-  a.flag0 = a.flag0 or
-      ((`in_inotify` shl bp_TGClosure_in_inotify) and bm_TGClosure_in_inotify)
-
-proc floating*(a: var TGClosure): guint =
-  result = (a.flag0 and bm_TGClosure_floating) shr bp_TGClosure_floating
-
-proc set_floating*(a: var TGClosure, `floating`: guint) =
-  a.flag0 = a.flag0 or
-      ((`floating` shl bp_TGClosure_floating) and bm_TGClosure_floating)
-
-proc derivative_flag*(a: PGClosure): guint =
-  result = (a . flag0 and bm_TGClosure_derivative_flag) shr
-      bp_TGClosure_derivative_flag
-
-proc set_derivative_flag*(a: var TGClosure, `derivative_flag`: guint) =
-  a.flag0 = a.flag0 or
-      ((`derivative_flag` shl bp_TGClosure_derivative_flag) and
-      bm_TGClosure_derivative_flag)
-
-proc in_marshal*(a: var TGClosure): guint =
-  result = (a.flag0 and bm_TGClosure_in_marshal) shr bp_TGClosure_in_marshal
-
-proc set_in_marshal*(a: var TGClosure, in_marshal: guint) =
-  a.flag0 = a.flag0 or
-      ((in_marshal shl bp_TGClosure_in_marshal) and bm_TGClosure_in_marshal)
-
-proc is_invalid*(a: var TGClosure): guint =
-  result = (a.flag0 and bm_TGClosure_is_invalid) shr bp_TGClosure_is_invalid
-
-proc set_is_invalid*(a: var TGClosure, is_invalid: guint) =
-  a.flag0 = a.flag0 or
-      ((is_invalid shl bp_TGClosure_is_invalid) and bm_TGClosure_is_invalid)
-
-proc g_signal_connect*(instance: gpointer, detailed_signal: cstring,
-                       c_handler: TGCallback, data: gpointer): gulong =
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data,
-                                 nil, TGConnectFlags(0))
-
-proc g_signal_connect_after*(instance: gpointer, detailed_signal: cstring,
-                             c_handler: TGCallback, data: gpointer): gulong =
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data,
-                                 nil, G_CONNECT_AFTER)
-
-proc g_signal_connect_swapped*(instance: gpointer, detailed_signal: cstring,
-                               c_handler: TGCallback, data: gpointer): gulong =
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data,
-                                 nil, G_CONNECT_SWAPPED)
-
-proc g_signal_handlers_disconnect_by_func*(instance: gpointer,
-    func, data: gpointer): guint =
-  result = g_signal_handlers_disconnect_matched(instance,
-      TGSignalMatchType(G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil,
-      func, data)
-
-proc g_signal_handlers_block_by_func*(instance: gpointer, func, data: gpointer) =
-  discard g_signal_handlers_block_matched(instance, TGSignalMatchType(
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil, func, data)
-
-proc g_signal_handlers_unblock_by_func*(instance: gpointer, func, data: gpointer) =
-  discard g_signal_handlers_unblock_matched(instance, TGSignalMatchType(
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil, func, data)
-
-proc G_TYPE_IS_OBJECT*(theType: GType): bool =
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_OBJECT
-
-proc G_OBJECT*(anObject: pointer): PGObject =
-  result = cast[PGObject](G_TYPE_CHECK_INSTANCE_CAST(anObject, G_TYPE_OBJECT))
-
-proc G_OBJECT_CLASS*(class: Pointer): PGObjectClass =
-  result = cast[PGObjectClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_OBJECT))
-
-proc G_IS_OBJECT*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, G_TYPE_OBJECT)
-
-proc G_IS_OBJECT_CLASS*(class: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_OBJECT)
-
-proc G_OBJECT_GET_CLASS*(anObject: pointer): PGObjectClass =
-  result = cast[PGObjectClass](G_TYPE_INSTANCE_GET_CLASS(anObject, G_TYPE_OBJECT))
-
-proc G_OBJECT_TYPE*(anObject: pointer): GType =
-  result = G_TYPE_FROM_INSTANCE(anObject)
-
-proc G_OBJECT_TYPE_NAME*(anObject: pointer): cstring =
-  result = g_type_name(G_OBJECT_TYPE(anObject))
-
-proc G_OBJECT_CLASS_TYPE*(class: Pointer): GType =
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_OBJECT_CLASS_NAME*(class: Pointer): cstring =
-  result = g_type_name(G_OBJECT_CLASS_TYPE(class))
-
-proc G_VALUE_HOLDS_OBJECT*(value: Pointer): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_OBJECT)
-
-proc G_OBJECT_WARN_INVALID_PROPERTY_ID*(anObject: gpointer, property_id: gint,
-                                        pspec: gpointer) =
-  G_OBJECT_WARN_INVALID_PSPEC(anObject, "property", property_id, pspec)
-
-proc G_OBJECT_WARN_INVALID_PSPEC*(anObject: gpointer, pname: cstring,
-                                  property_id: gint, pspec: gpointer) =
-  var
-    theObject: PGObject
-    pspec2: PGParamSpec
-    property_id: guint
-  theObject = cast[PGObject](anObject)
-  pspec2 = cast[PGParamSpec](pspec)
-  property_id = (property_id)
-  write(stdout, "invalid thingy\n")
-  #g_warning("%s: invalid %s id %u for \"%s\" of type `%s\' in `%s\'", "", pname,
-  #          `property_id`, `pspec` . name,
-  #          g_type_name(G_PARAM_SPEC_TYPE(`pspec`)),
-  #          G_OBJECT_TYPE_NAME(theobject))
-
-proc G_TYPE_TYPE_PLUGIN*(): GType =
-  result = g_type_plugin_get_type()
-
-proc G_TYPE_PLUGIN*(inst: Pointer): PGTypePlugin =
-  result = PGTypePlugin(G_TYPE_CHECK_INSTANCE_CAST(inst, G_TYPE_TYPE_PLUGIN()))
-
-proc G_TYPE_PLUGIN_CLASS*(vtable: Pointer): PGTypePluginClass =
-  result = cast[PGTypePluginClass](G_TYPE_CHECK_CLASS_CAST(vtable,
-    G_TYPE_TYPE_PLUGIN()))
-
-proc G_IS_TYPE_PLUGIN*(inst: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(inst, G_TYPE_TYPE_PLUGIN())
-
-proc G_IS_TYPE_PLUGIN_CLASS*(vtable: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(vtable, G_TYPE_TYPE_PLUGIN())
-
-proc G_TYPE_PLUGIN_GET_CLASS*(inst: Pointer): PGTypePluginClass =
-  result = cast[PGTypePluginClass](G_TYPE_INSTANCE_GET_INTERFACE(inst,
-      G_TYPE_TYPE_PLUGIN()))
-
-proc G_TYPE_IS_ENUM*(theType: GType): gboolean =
-  result = (G_TYPE_FUNDAMENTAL(theType) == G_TYPE_ENUM)
-
-proc G_ENUM_CLASS*(class: pointer): PGEnumClass =
-  result = cast[PGEnumClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_ENUM))
-
-proc G_IS_ENUM_CLASS*(class: pointer): gboolean =
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_ENUM)
-
-proc G_ENUM_CLASS_TYPE*(class: pointer): GType =
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_ENUM_CLASS_TYPE_NAME*(class: pointer): cstring =
-  result = g_type_name(G_ENUM_CLASS_TYPE(class))
-
-proc G_TYPE_IS_FLAGS*(theType: GType): gboolean =
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_FLAGS
-
-proc G_FLAGS_CLASS*(class: pointer): PGFlagsClass =
-  result = cast[PGFlagsClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_FLAGS))
-
-proc G_IS_FLAGS_CLASS*(class: pointer): gboolean =
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_FLAGS)
-
-proc G_FLAGS_CLASS_TYPE*(class: pointer): GType =
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_FLAGS_CLASS_TYPE_NAME*(class: pointer): cstring =
-  result = g_type_name(G_FLAGS_TYPE(cast[TAddress](class)))
-
-proc G_VALUE_HOLDS_ENUM*(value: pointer): gboolean =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_ENUM)
-
-proc G_VALUE_HOLDS_FLAGS*(value: pointer): gboolean =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_FLAGS)
-
-proc CLAMP*(x, MinX, MaxX: int): int =
-  if x < MinX:
-    result = MinX
-  elif x > MaxX:
-    result = MaxX
-  else:
-    result = x
-
-proc GPOINTER_TO_SIZE*(p: GPointer): GSize =
-  result = GSize(cast[TAddress](p))
-
-proc GSIZE_TO_POINTER*(s: GSize): GPointer =
-  result = cast[GPointer](s)
-
-proc G_VALUE_HOLDS_CHAR*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_CHAR)
-
-proc G_VALUE_HOLDS_UCHAR*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UCHAR)
-
-proc G_VALUE_HOLDS_BOOLEAN*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_BOOLEAN)
-
-proc G_VALUE_HOLDS_INT*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_INT)
-
-proc G_VALUE_HOLDS_UINT*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UINT)
-
-proc G_VALUE_HOLDS_LONG*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_LONG)
-
-proc G_VALUE_HOLDS_ULONG*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_ULONG)
-
-proc G_VALUE_HOLDS_INT64*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_INT64)
-
-proc G_VALUE_HOLDS_UINT64*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UINT64)
-
-proc G_VALUE_HOLDS_FLOAT*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_FLOAT)
-
-proc G_VALUE_HOLDS_DOUBLE*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_DOUBLE)
-
-proc G_VALUE_HOLDS_STRING*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_STRING)
-
-proc G_VALUE_HOLDS_POINTER*(value: PGValue): bool =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_POINTER)
-
-proc G_TYPE_IS_BOXED*(theType: GType): gboolean =
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_BOXED
-
-proc G_VALUE_HOLDS_BOXED*(value: PGValue): gboolean =
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_BOXED)
-
-proc G_TYPE_CLOSURE*(): GType =
-  result = g_closure_get_type()
-
-proc G_TYPE_VALUE*(): GType =
-  result = g_value_get_type()
-
-proc G_TYPE_VALUE_ARRAY*(): GType =
-  result = g_value_array_get_type()
-
-proc G_TYPE_GSTRING*(): GType =
-  result = g_gstring_get_type()
diff --git a/lib/oldwrappers/gtk/gtk2.nim b/lib/oldwrappers/gtk/gtk2.nim
deleted file mode 100755
index e7c5be7be..000000000
--- a/lib/oldwrappers/gtk/gtk2.nim
+++ /dev/null
@@ -1,17271 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2, atk, pango, gdk2pixbuf, gdk2
-
-when defined(win32):
-  const
-    gtklib = "libgtk-win32-2.0-0.dll"
-elif defined(darwin):
-  const
-    gtklib = "gtk-x11-2.0"
-  # linklib gtk-x11-2.0
-  # linklib gdk-x11-2.0
-  # linklib pango-1.0.0
-  # linklib glib-2.0.0
-  # linklib gobject-2.0.0
-  # linklib gdk_pixbuf-2.0.0
-  # linklib atk-1.0.0
-else:
-  const
-    gtklib = "libgtk-x11-2.0.so"
-type
-  PPPchar* = PPPgchar
-
-const
-  GTK_MAX_COMPOSE_LEN* = 7
-
-type
-  PGtkObject* = ptr TGtkObject
-  PPGtkObject* = ptr PGtkObject
-  PGtkArg* = ptr TGtkArg
-  PGtkType* = ptr TGtkType
-  TGtkType* = GType
-  PGtkWidget* = ptr TGtkWidget
-  PGtkMisc* = ptr TGtkMisc
-  PGtkLabel* = ptr TGtkLabel
-  PGtkMenu* = ptr TGtkMenu
-  PGtkAnchorType* = ptr TGtkAnchorType
-  TGtkAnchorType* = int32
-  PGtkArrowType* = ptr TGtkArrowType
-  TGtkArrowType* = int32
-  PGtkAttachOptions* = ptr TGtkAttachOptions
-  TGtkAttachOptions* = int32
-  PGtkButtonBoxStyle* = ptr TGtkButtonBoxStyle
-  TGtkButtonBoxStyle* = int32
-  PGtkCurveType* = ptr TGtkCurveType
-  TGtkCurveType* = int32
-  PGtkDeleteType* = ptr TGtkDeleteType
-  TGtkDeleteType* = int32
-  PGtkDirectionType* = ptr TGtkDirectionType
-  TGtkDirectionType* = int32
-  PGtkExpanderStyle* = ptr TGtkExpanderStyle
-  TGtkExpanderStyle* = int32
-  PPGtkIconSize* = ptr PGtkIconSize
-  PGtkIconSize* = ptr TGtkIconSize
-  TGtkIconSize* = int32
-  PGtkTextDirection* = ptr TGtkTextDirection
-  TGtkTextDirection* = int32
-  PGtkJustification* = ptr TGtkJustification
-  TGtkJustification* = int32
-  PGtkMenuDirectionType* = ptr TGtkMenuDirectionType
-  TGtkMenuDirectionType* = int32
-  PGtkMetricType* = ptr TGtkMetricType
-  TGtkMetricType* = int32
-  PGtkMovementStep* = ptr TGtkMovementStep
-  TGtkMovementStep* = int32
-  PGtkOrientation* = ptr TGtkOrientation
-  TGtkOrientation* = int32
-  PGtkCornerType* = ptr TGtkCornerType
-  TGtkCornerType* = int32
-  PGtkPackType* = ptr TGtkPackType
-  TGtkPackType* = int32
-  PGtkPathPriorityType* = ptr TGtkPathPriorityType
-  TGtkPathPriorityType* = int32
-  PGtkPathType* = ptr TGtkPathType
-  TGtkPathType* = int32
-  PGtkPolicyType* = ptr TGtkPolicyType
-  TGtkPolicyType* = int32
-  PGtkPositionType* = ptr TGtkPositionType
-  TGtkPositionType* = int32
-  PGtkReliefStyle* = ptr TGtkReliefStyle
-  TGtkReliefStyle* = int32
-  PGtkResizeMode* = ptr TGtkResizeMode
-  TGtkResizeMode* = int32
-  PGtkScrollType* = ptr TGtkScrollType
-  TGtkScrollType* = int32
-  PGtkSelectionMode* = ptr TGtkSelectionMode
-  TGtkSelectionMode* = int32
-  PGtkShadowType* = ptr TGtkShadowType
-  TGtkShadowType* = int32
-  PGtkStateType* = ptr TGtkStateType
-  TGtkStateType* = int32
-  PGtkSubmenuDirection* = ptr TGtkSubmenuDirection
-  TGtkSubmenuDirection* = int32
-  PGtkSubmenuPlacement* = ptr TGtkSubmenuPlacement
-  TGtkSubmenuPlacement* = int32
-  PGtkToolbarStyle* = ptr TGtkToolbarStyle
-  TGtkToolbarStyle* = int32
-  PGtkUpdateType* = ptr TGtkUpdateType
-  TGtkUpdateType* = int32
-  PGtkVisibility* = ptr TGtkVisibility
-  TGtkVisibility* = int32
-  PGtkWindowPosition* = ptr TGtkWindowPosition
-  TGtkWindowPosition* = int32
-  PGtkWindowType* = ptr TGtkWindowType
-  TGtkWindowType* = int32
-  PGtkWrapMode* = ptr TGtkWrapMode
-  TGtkWrapMode* = int32
-  PGtkSortType* = ptr TGtkSortType
-  TGtkSortType* = int32
-  PGtkStyle* = ptr TGtkStyle
-  PPGtkTreeModel* = ptr PGtkTreeModel
-  PGtkTreeModel* = pointer
-  PGtkTreePath* = pointer
-  PGtkTreeIter* = ptr TGtkTreeIter
-  PGtkSelectionData* = ptr TGtkSelectionData
-  PGtkTextTagTable* = ptr TGtkTextTagTable
-  PGtkTextBTreeNode* = pointer
-  PGtkTextBTree* = pointer
-  PGtkTextLine* = ptr TGtkTextLine
-  PGtkTreeViewColumn* = ptr TGtkTreeViewColumn
-  PGtkTreeView* = ptr TGtkTreeView
-  TGtkTreeViewColumnDropFunc* = proc (tree_view: PGtkTreeView,
-                                      column: PGtkTreeViewColumn,
-                                      prev_column: PGtkTreeViewColumn,
-                                      next_column: PGtkTreeViewColumn,
-                                      data: gpointer): gboolean{.cdecl.}
-  TGtkTreeViewMappingFunc* = proc (tree_view: PGtkTreeView, path: PGtkTreePath,
-                                   user_data: gpointer){.cdecl.}
-  TGtkTreeViewSearchEqualFunc* = proc (model: PGtkTreeModel, column: gint,
-                                       key: cstring, iter: PGtkTreeIter,
-                                       search_data: gpointer): gboolean{.cdecl.}
-  TGtkTreeDestroyCountFunc* = proc (tree_view: PGtkTreeView, path: PGtkTreePath,
-                                    children: gint, user_data: gpointer){.cdecl.}
-  PGtkTreeViewDropPosition* = ptr TGtkTreeViewDropPosition
-  TGtkTreeViewDropPosition* = enum
-    GTK_TREE_VIEW_DROP_BEFORE, GTK_TREE_VIEW_DROP_AFTER,
-    GTK_TREE_VIEW_DROP_INTO_OR_BEFORE, GTK_TREE_VIEW_DROP_INTO_OR_AFTER
-  PGtkObjectFlags* = ptr TGtkObjectFlags
-  TGtkObjectFlags* = int32
-  TGtkObject* = object of TGObject
-    flags*: guint32
-
-  PGtkObjectClass* = ptr TGtkObjectClass
-  TGtkObjectClass* = object of TGObjectClass
-    set_arg*: proc (anObject: PGtkObject, arg: PGtkArg, arg_id: guint){.cdecl.}
-    get_arg*: proc (anObject: PGtkObject, arg: PGtkArg, arg_id: guint){.cdecl.}
-    destroy*: proc (anObject: PGtkObject){.cdecl.}
-
-  PGtkFundamentalType* = ptr TGtkFundamentalType
-  TGtkFundamentalType* = GType
-  TGtkFunction* = proc (data: gpointer): gboolean{.cdecl.}
-  TGtkDestroyNotify* = proc (data: gpointer){.cdecl.}
-  TGtkCallbackMarshal* = proc (anObject: PGtkObject, data: gpointer,
-                               n_args: guint, args: PGtkArg){.cdecl.}
-  TGtkSignalFuncProc* = proc ()
-  TGtkSignalFunc* = proc (para1: TGtkSignalFuncProc){.cdecl.}
-  PGtkSignalMarshaller* = ptr TGtkSignalMarshaller
-  TGtkSignalMarshaller* = TGSignalCMarshaller
-  TGtkArgSignalData* {.final, pure.} = object
-    f*: TGtkSignalFunc
-    d*: gpointer
-
-  TGtkArg* {.final, pure.} = object
-    `type`*: TGtkType
-    name*: cstring
-    d*: gdouble               # was a union type
-
-  PGtkTypeInfo* = ptr TGtkTypeInfo
-  TGtkTypeInfo* {.final, pure.} = object
-    type_name*: cstring
-    object_size*: guint
-    class_size*: guint
-    class_init_func*: pointer #TGtkClassInitFunc
-    object_init_func*: pointer #TGtkObjectInitFunc
-    reserved_1*: gpointer
-    reserved_2*: gpointer
-    base_class_init_func*: pointer #TGtkClassInitFunc
-
-  PGtkEnumValue* = ptr TGtkEnumValue
-  TGtkEnumValue* = TGEnumValue
-  PGtkFlagValue* = ptr TGtkFlagValue
-  TGtkFlagValue* = TGFlagsValue
-  PGtkWidgetFlags* = ptr TGtkWidgetFlags
-  TGtkWidgetFlags* = int32
-  PGtkWidgetHelpType* = ptr TGtkWidgetHelpType
-  TGtkWidgetHelpType* = enum
-    GTK_WIDGET_HELP_TOOLTIP, GTK_WIDGET_HELP_WHATS_THIS
-  PGtkAllocation* = ptr TGtkAllocation
-  TGtkAllocation* = TGdkRectangle
-  TGtkCallback* = proc (widget: PGtkWidget, data: gpointer){.cdecl.}
-  PGtkRequisition* = ptr TGtkRequisition
-  TGtkRequisition* {.final, pure.} = object
-    width*: gint
-    height*: gint
-
-  TGtkWidget* = object of TGtkObject
-    private_flags*: guint16
-    state*: guint8
-    saved_state*: guint8
-    name*: cstring
-    style*: PGtkStyle
-    requisition*: TGtkRequisition
-    allocation*: TGtkAllocation
-    window*: PGdkWindow
-    parent*: PGtkWidget
-
-  PGtkWidgetClass* = ptr TGtkWidgetClass
-  TGtkWidgetClass* = object of TGtkObjectClass
-    activate_signal*: guint
-    set_scroll_adjustments_signal*: guint
-    dispatch_child_properties_changed*: proc (widget: PGtkWidget,
-        n_pspecs: guint, pspecs: PPGParamSpec){.cdecl.}
-    show*: proc (widget: PGtkWidget){.cdecl.}
-    show_all*: proc (widget: PGtkWidget){.cdecl.}
-    hide*: proc (widget: PGtkWidget){.cdecl.}
-    hide_all*: proc (widget: PGtkWidget){.cdecl.}
-    map*: proc (widget: PGtkWidget){.cdecl.}
-    unmap*: proc (widget: PGtkWidget){.cdecl.}
-    realize*: proc (widget: PGtkWidget){.cdecl.}
-    unrealize*: proc (widget: PGtkWidget){.cdecl.}
-    size_request*: proc (widget: PGtkWidget, requisition: PGtkRequisition){.
-        cdecl.}
-    size_allocate*: proc (widget: PGtkWidget, allocation: PGtkAllocation){.cdecl.}
-    state_changed*: proc (widget: PGtkWidget, previous_state: TGtkStateType){.
-        cdecl.}
-    parent_set*: proc (widget: PGtkWidget, previous_parent: PGtkWidget){.cdecl.}
-    hierarchy_changed*: proc (widget: PGtkWidget, previous_toplevel: PGtkWidget){.
-        cdecl.}
-    style_set*: proc (widget: PGtkWidget, previous_style: PGtkStyle){.cdecl.}
-    direction_changed*: proc (widget: PGtkWidget,
-                              previous_direction: TGtkTextDirection){.cdecl.}
-    grab_notify*: proc (widget: PGtkWidget, was_grabbed: gboolean){.cdecl.}
-    child_notify*: proc (widget: PGtkWidget, pspec: PGParamSpec){.cdecl.}
-    mnemonic_activate*: proc (widget: PGtkWidget, group_cycling: gboolean): gboolean{.
-        cdecl.}
-    grab_focus*: proc (widget: PGtkWidget){.cdecl.}
-    focus*: proc (widget: PGtkWidget, direction: TGtkDirectionType): gboolean{.
-        cdecl.}
-    event*: proc (widget: PGtkWidget, event: PGdkEvent): gboolean{.cdecl.}
-    button_press_event*: proc (widget: PGtkWidget, event: PGdkEventButton): gboolean{.
-        cdecl.}
-    button_release_event*: proc (widget: PGtkWidget, event: PGdkEventButton): gboolean{.
-        cdecl.}
-    scroll_event*: proc (widget: PGtkWidget, event: PGdkEventScroll): gboolean{.
-        cdecl.}
-    motion_notify_event*: proc (widget: PGtkWidget, event: PGdkEventMotion): gboolean{.
-        cdecl.}
-    delete_event*: proc (widget: PGtkWidget, event: PGdkEventAny): gboolean{.
-        cdecl.}
-    destroy_event*: proc (widget: PGtkWidget, event: PGdkEventAny): gboolean{.
-        cdecl.}
-    expose_event*: proc (widget: PGtkWidget, event: PGdkEventExpose): gboolean{.
-        cdecl.}
-    key_press_event*: proc (widget: PGtkWidget, event: PGdkEventKey): gboolean{.
-        cdecl.}
-    key_release_event*: proc (widget: PGtkWidget, event: PGdkEventKey): gboolean{.
-        cdecl.}
-    enter_notify_event*: proc (widget: PGtkWidget, event: PGdkEventCrossing): gboolean{.
-        cdecl.}
-    leave_notify_event*: proc (widget: PGtkWidget, event: PGdkEventCrossing): gboolean{.
-        cdecl.}
-    configure_event*: proc (widget: PGtkWidget, event: PGdkEventConfigure): gboolean{.
-        cdecl.}
-    focus_in_event*: proc (widget: PGtkWidget, event: PGdkEventFocus): gboolean{.
-        cdecl.}
-    focus_out_event*: proc (widget: PGtkWidget, event: PGdkEventFocus): gboolean{.
-        cdecl.}
-    map_event*: proc (widget: PGtkWidget, event: PGdkEventAny): gboolean{.cdecl.}
-    unmap_event*: proc (widget: PGtkWidget, event: PGdkEventAny): gboolean{.
-        cdecl.}
-    property_notify_event*: proc (widget: PGtkWidget, event: PGdkEventProperty): gboolean{.
-        cdecl.}
-    selection_clear_event*: proc (widget: PGtkWidget, event: PGdkEventSelection): gboolean{.
-        cdecl.}
-    selection_request_event*: proc (widget: PGtkWidget,
-                                    event: PGdkEventSelection): gboolean{.cdecl.}
-    selection_notify_event*: proc (widget: PGtkWidget, event: PGdkEventSelection): gboolean{.
-        cdecl.}
-    proximity_in_event*: proc (widget: PGtkWidget, event: PGdkEventProximity): gboolean{.
-        cdecl.}
-    proximity_out_event*: proc (widget: PGtkWidget, event: PGdkEventProximity): gboolean{.
-        cdecl.}
-    visibility_notify_event*: proc (widget: PGtkWidget,
-                                    event: PGdkEventVisibility): gboolean{.cdecl.}
-    client_event*: proc (widget: PGtkWidget, event: PGdkEventClient): gboolean{.
-        cdecl.}
-    no_expose_event*: proc (widget: PGtkWidget, event: PGdkEventAny): gboolean{.
-        cdecl.}
-    window_state_event*: proc (widget: PGtkWidget, event: PGdkEventWindowState): gboolean{.
-        cdecl.}
-    selection_get*: proc (widget: PGtkWidget, selection_data: PGtkSelectionData,
-                          info: guint, time: guint){.cdecl.}
-    selection_received*: proc (widget: PGtkWidget,
-                               selection_data: PGtkSelectionData, time: guint){.
-        cdecl.}
-    drag_begin*: proc (widget: PGtkWidget, context: PGdkDragContext){.cdecl.}
-    drag_end*: proc (widget: PGtkWidget, context: PGdkDragContext){.cdecl.}
-    drag_data_get*: proc (widget: PGtkWidget, context: PGdkDragContext,
-                          selection_data: PGtkSelectionData, info: guint,
-                          time: guint){.cdecl.}
-    drag_data_delete*: proc (widget: PGtkWidget, context: PGdkDragContext){.
-        cdecl.}
-    drag_leave*: proc (widget: PGtkWidget, context: PGdkDragContext, time: guint){.
-        cdecl.}
-    drag_motion*: proc (widget: PGtkWidget, context: PGdkDragContext, x: gint,
-                        y: gint, time: guint): gboolean{.cdecl.}
-    drag_drop*: proc (widget: PGtkWidget, context: PGdkDragContext, x: gint,
-                      y: gint, time: guint): gboolean{.cdecl.}
-    drag_data_received*: proc (widget: PGtkWidget, context: PGdkDragContext,
-                               x: gint, y: gint,
-                               selection_data: PGtkSelectionData, info: guint,
-                               time: guint){.cdecl.}
-    popup_menu*: proc (widget: PGtkWidget): gboolean{.cdecl.}
-    show_help*: proc (widget: PGtkWidget, help_type: TGtkWidgetHelpType): gboolean{.
-        cdecl.}
-    get_accessible*: proc (widget: PGtkWidget): PAtkObject{.cdecl.}
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-    gtk_reserved5*: proc (){.cdecl.}
-    gtk_reserved6*: proc (){.cdecl.}
-    gtk_reserved7*: proc (){.cdecl.}
-    gtk_reserved8*: proc (){.cdecl.}
-
-  PGtkWidgetAuxInfo* = ptr TGtkWidgetAuxInfo
-  TGtkWidgetAuxInfo* {.final, pure.} = object
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-    flag0*: guint16
-
-  PGtkWidgetShapeInfo* = ptr TGtkWidgetShapeInfo
-  TGtkWidgetShapeInfo* {.final, pure.} = object
-    offset_x*: gint16
-    offset_y*: gint16
-    shape_mask*: PGdkBitmap
-
-  TGtkMisc* = object of TGtkWidget
-    xalign*: gfloat
-    yalign*: gfloat
-    xpad*: guint16
-    ypad*: guint16
-
-  PGtkMiscClass* = ptr TGtkMiscClass
-  TGtkMiscClass* = object of TGtkWidgetClass
-
-  PGtkAccelFlags* = ptr TGtkAccelFlags
-  TGtkAccelFlags* = int32
-  PGtkAccelGroup* = ptr TGtkAccelGroup
-  PGtkAccelGroupEntry* = ptr TGtkAccelGroupEntry
-  TGtkAccelGroupActivate* = proc (accel_group: PGtkAccelGroup,
-                                  acceleratable: PGObject, keyval: guint,
-                                  modifier: TGdkModifierType): gboolean{.cdecl.}
-  TGtkAccelGroup* = object of TGObject
-    lock_count*: guint
-    modifier_mask*: TGdkModifierType
-    acceleratables*: PGSList
-    n_accels*: guint
-    priv_accels*: PGtkAccelGroupEntry
-
-  PGtkAccelGroupClass* = ptr TGtkAccelGroupClass
-  TGtkAccelGroupClass* = object of TGObjectClass
-    accel_changed*: proc (accel_group: PGtkAccelGroup, keyval: guint,
-                          modifier: TGdkModifierType, accel_closure: PGClosure){.
-        cdecl.}
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkAccelKey* = ptr TGtkAccelKey
-  TGtkAccelKey* {.final, pure.} = object
-    accel_key*: guint
-    accel_mods*: TGdkModifierType
-    flag0*: guint16
-
-  TGtkAccelGroupEntry* {.final, pure.} = object
-    key*: TGtkAccelKey
-    closure*: PGClosure
-    accel_path_quark*: TGQuark
-
-  Tgtk_accel_group_find_func* = proc (key: PGtkAccelKey, closure: PGClosure,
-                                      data: gpointer): gboolean{.cdecl.}
-  PGtkContainer* = ptr TGtkContainer
-  TGtkContainer* = object of TGtkWidget
-    focus_child*: PGtkWidget
-    GtkContainer_flag0*: int32
-
-  PGtkContainerClass* = ptr TGtkContainerClass
-  TGtkContainerClass* = object of TGtkWidgetClass
-    add*: proc (container: PGtkContainer, widget: PGtkWidget){.cdecl.}
-    remove*: proc (container: PGtkContainer, widget: PGtkWidget){.cdecl.}
-    check_resize*: proc (container: PGtkContainer){.cdecl.}
-    forall*: proc (container: PGtkContainer, include_internals: gboolean,
-                   callback: TGtkCallback, callback_data: gpointer){.cdecl.}
-    set_focus_child*: proc (container: PGtkContainer, widget: PGtkWidget){.cdecl.}
-    child_type*: proc (container: PGtkContainer): TGtkType{.cdecl.}
-    composite_name*: proc (container: PGtkContainer, child: PGtkWidget): cstring{.
-        cdecl.}
-    set_child_property*: proc (container: PGtkContainer, child: PGtkWidget,
-                               property_id: guint, value: PGValue,
-                               pspec: PGParamSpec){.cdecl.}
-    get_child_property*: proc (container: PGtkContainer, child: PGtkWidget,
-                               property_id: guint, value: PGValue,
-                               pspec: PGParamSpec){.cdecl.}
-    gtk_reserved20: proc (){.cdecl.}
-    gtk_reserved21: proc (){.cdecl.}
-    gtk_reserved23: proc (){.cdecl.}
-    gtk_reserved24: proc (){.cdecl.}
-
-  PGtkBin* = ptr TGtkBin
-  TGtkBin* = object of TGtkContainer
-    child*: PGtkWidget
-
-  PGtkBinClass* = ptr TGtkBinClass
-  TGtkBinClass* = object of TGtkContainerClass
-
-  PGtkWindowGeometryInfo* = pointer
-  PGtkWindowGroup* = ptr TGtkWindowGroup
-  PGtkWindow* = ptr TGtkWindow
-  TGtkWindow* = object of TGtkBin
-    title*: cstring
-    wmclass_name*: cstring
-    wmclass_class*: cstring
-    wm_role*: cstring
-    focus_widget*: PGtkWidget
-    default_widget*: PGtkWidget
-    transient_parent*: PGtkWindow
-    geometry_info*: PGtkWindowGeometryInfo
-    frame*: PGdkWindow
-    group*: PGtkWindowGroup
-    configure_request_count*: guint16
-    gtkwindow_flag0*: int32
-    frame_left*: guint
-    frame_top*: guint
-    frame_right*: guint
-    frame_bottom*: guint
-    keys_changed_handler*: guint
-    mnemonic_modifier*: TGdkModifierType
-    screen*: PGdkScreen
-
-  PGtkWindowClass* = ptr TGtkWindowClass
-  TGtkWindowClass* = object of TGtkBinClass
-    set_focus*: proc (window: PGtkWindow, focus: PGtkWidget){.cdecl.}
-    frame_event*: proc (window: PGtkWindow, event: PGdkEvent): gboolean{.cdecl.}
-    activate_focus*: proc (window: PGtkWindow){.cdecl.}
-    activate_default*: proc (window: PGtkWindow){.cdecl.}
-    move_focus*: proc (window: PGtkWindow, direction: TGtkDirectionType){.cdecl.}
-    keys_changed*: proc (window: PGtkWindow){.cdecl.}
-    gtk_reserved30: proc (){.cdecl.}
-    gtk_reserved31: proc (){.cdecl.}
-    gtk_reserved32: proc (){.cdecl.}
-    gtk_reserved33: proc (){.cdecl.}
-
-  TGtkWindowGroup* = object of TGObject
-    grabs*: PGSList
-
-  PGtkWindowGroupClass* = ptr TGtkWindowGroupClass
-  TGtkWindowGroupClass* = object of TGObjectClass
-    gtk_reserved40: proc (){.cdecl.}
-    gtk_reserved41: proc (){.cdecl.}
-    gtk_reserved42: proc (){.cdecl.}
-    gtk_reserved43: proc (){.cdecl.}
-
-  TGtkWindowKeysForeachFunc* = proc (window: PGtkWindow, keyval: guint,
-                                     modifiers: TGdkModifierType,
-                                     is_mnemonic: gboolean, data: gpointer){.
-      cdecl.}
-  PGtkLabelSelectionInfo* = pointer
-  TGtkLabel* = object of TGtkMisc
-    `label`*: cstring
-    GtkLabel_flag0*: guint16
-    mnemonic_keyval*: guint
-    text*: cstring
-    attrs*: PPangoAttrList
-    effective_attrs*: PPangoAttrList
-    layout*: PPangoLayout
-    mnemonic_widget*: PGtkWidget
-    mnemonic_window*: PGtkWindow
-    select_info*: PGtkLabelSelectionInfo
-
-  PGtkLabelClass* = ptr TGtkLabelClass
-  TGtkLabelClass* = object of TGtkMiscClass
-    move_cursor*: proc (`label`: PGtkLabel, step: TGtkMovementStep, count: gint,
-                        extend_selection: gboolean){.cdecl.}
-    copy_clipboard*: proc (`label`: PGtkLabel){.cdecl.}
-    populate_popup*: proc (`label`: PGtkLabel, menu: PGtkMenu){.cdecl.}
-    gtk_reserved50: proc (){.cdecl.}
-    gtk_reserved51: proc (){.cdecl.}
-    gtk_reserved52: proc (){.cdecl.}
-    gtk_reserved53: proc (){.cdecl.}
-
-  PGtkAccelLabel* = ptr TGtkAccelLabel
-  TGtkAccelLabel* = object of TGtkLabel
-    queue_id*: guint
-    accel_padding*: guint
-    accel_widget*: PGtkWidget
-    accel_closure*: PGClosure
-    accel_group*: PGtkAccelGroup
-    accel_string*: cstring
-    accel_string_width*: guint16
-
-  PGtkAccelLabelClass* = ptr TGtkAccelLabelClass
-  TGtkAccelLabelClass* = object of TGtkLabelClass
-    signal_quote1*: cstring
-    signal_quote2*: cstring
-    mod_name_shift*: cstring
-    mod_name_control*: cstring
-    mod_name_alt*: cstring
-    mod_separator*: cstring
-    accel_seperator*: cstring
-    GtkAccelLabelClass_flag0*: guint16
-    gtk_reserved61: proc (){.cdecl.}
-    gtk_reserved62: proc (){.cdecl.}
-    gtk_reserved63: proc (){.cdecl.}
-    gtk_reserved64: proc (){.cdecl.}
-
-  TGtkAccelMapForeach* = proc (data: gpointer, accel_path: cstring,
-                               accel_key: guint, accel_mods: TGdkModifierType,
-                               changed: gboolean){.cdecl.}
-  PGtkAccessible* = ptr TGtkAccessible
-  TGtkAccessible* = object of TAtkObject
-    widget*: PGtkWidget
-
-  PGtkAccessibleClass* = ptr TGtkAccessibleClass
-  TGtkAccessibleClass* = object of TAtkObjectClass
-    connect_widget_destroyed*: proc (accessible: PGtkAccessible){.cdecl.}
-    gtk_reserved71: proc (){.cdecl.}
-    gtk_reserved72: proc (){.cdecl.}
-    gtk_reserved73: proc (){.cdecl.}
-    gtk_reserved74: proc (){.cdecl.}
-
-  PGtkAdjustment* = ptr TGtkAdjustment
-  TGtkAdjustment* = object of TGtkObject
-    lower*: gdouble
-    upper*: gdouble
-    value*: gdouble
-    step_increment*: gdouble
-    page_increment*: gdouble
-    page_size*: gdouble
-
-  PGtkAdjustmentClass* = ptr TGtkAdjustmentClass
-  TGtkAdjustmentClass* = object of TGtkObjectClass
-    changed*: proc (adjustment: PGtkAdjustment){.cdecl.}
-    value_changed*: proc (adjustment: PGtkAdjustment){.cdecl.}
-    gtk_reserved81: proc (){.cdecl.}
-    gtk_reserved82: proc (){.cdecl.}
-    gtk_reserved83: proc (){.cdecl.}
-    gtk_reserved84: proc (){.cdecl.}
-
-  PGtkAlignment* = ptr TGtkAlignment
-  TGtkAlignment* = object of TGtkBin
-    xalign*: gfloat
-    yalign*: gfloat
-    xscale*: gfloat
-    yscale*: gfloat
-
-  PGtkAlignmentClass* = ptr TGtkAlignmentClass
-  TGtkAlignmentClass* = object of TGtkBinClass
-
-  PGtkFrame* = ptr TGtkFrame
-  TGtkFrame* = object of TGtkBin
-    label_widget*: PGtkWidget
-    shadow_type*: gint16
-    label_xalign*: gfloat
-    label_yalign*: gfloat
-    child_allocation*: TGtkAllocation
-
-  PGtkFrameClass* = ptr TGtkFrameClass
-  TGtkFrameClass* = object of TGtkBinClass
-    compute_child_allocation*: proc (frame: PGtkFrame,
-                                     allocation: PGtkAllocation){.cdecl.}
-
-  PGtkAspectFrame* = ptr TGtkAspectFrame
-  TGtkAspectFrame* = object of TGtkFrame
-    xalign*: gfloat
-    yalign*: gfloat
-    ratio*: gfloat
-    obey_child*: gboolean
-    center_allocation*: TGtkAllocation
-
-  PGtkAspectFrameClass* = ptr TGtkAspectFrameClass
-  TGtkAspectFrameClass* = object of TGtkFrameClass
-
-  PGtkArrow* = ptr TGtkArrow
-  TGtkArrow* = object of TGtkMisc
-    arrow_type*: gint16
-    shadow_type*: gint16
-
-  PGtkArrowClass* = ptr TGtkArrowClass
-  TGtkArrowClass* = object of TGtkMiscClass
-
-  PGtkBindingEntry* = ptr TGtkBindingEntry
-  PGtkBindingSignal* = ptr TGtkBindingSignal
-  PGtkBindingArg* = ptr TGtkBindingArg
-  PGtkBindingSet* = ptr TGtkBindingSet
-  TGtkBindingSet* {.final, pure.} = object
-    set_name*: cstring
-    priority*: gint
-    widget_path_pspecs*: PGSList
-    widget_class_pspecs*: PGSList
-    class_branch_pspecs*: PGSList
-    entries*: PGtkBindingEntry
-    current*: PGtkBindingEntry
-    flag0*: guint16
-
-  TGtkBindingEntry* {.final, pure.} = object
-    keyval*: guint
-    modifiers*: TGdkModifierType
-    binding_set*: PGtkBindingSet
-    flag0*: guint16
-    set_next*: PGtkBindingEntry
-    hash_next*: PGtkBindingEntry
-    signals*: PGtkBindingSignal
-
-  TGtkBindingSignal* {.final, pure.} = object
-    next*: PGtkBindingSignal
-    signal_name*: cstring
-    n_args*: guint
-    args*: PGtkBindingArg
-
-  TGtkBindingArg* {.final, pure.} = object
-    arg_type*: TGtkType
-    d*: gdouble
-
-  PGtkBox* = ptr TGtkBox
-  TGtkBox* = object of TGtkContainer
-    children*: PGList
-    spacing*: gint16
-    gtkbox_flag0*: guint16
-
-  PGtkBoxClass* = ptr TGtkBoxClass
-  TGtkBoxClass* = object of TGtkContainerClass
-
-  PGtkBoxChild* = ptr TGtkBoxChild
-  TGtkBoxChild* {.final, pure.} = object
-    widget*: PGtkWidget
-    padding*: guint16
-    flag0*: guint16
-
-  PGtkButtonBox* = ptr TGtkButtonBox
-  TGtkButtonBox* = object of TGtkBox
-    child_min_width*: gint
-    child_min_height*: gint
-    child_ipad_x*: gint
-    child_ipad_y*: gint
-    layout_style*: TGtkButtonBoxStyle
-
-  PGtkButtonBoxClass* = ptr TGtkButtonBoxClass
-  TGtkButtonBoxClass* = object of TGtkBoxClass
-
-  PGtkButton* = ptr TGtkButton
-  TGtkButton* = object of TGtkBin
-    event_window*: PGdkWindow
-    label_text*: cstring
-    activate_timeout*: guint
-    gtkbutton_flag0*: guint16
-
-  PGtkButtonClass* = ptr TGtkButtonClass
-  TGtkButtonClass* = object of TGtkBinClass
-    pressed*: proc (button: PGtkButton){.cdecl.}
-    released*: proc (button: PGtkButton){.cdecl.}
-    clicked*: proc (button: PGtkButton){.cdecl.}
-    enter*: proc (button: PGtkButton){.cdecl.}
-    leave*: proc (button: PGtkButton){.cdecl.}
-    activate*: proc (button: PGtkButton){.cdecl.}
-    gtk_reserved101: proc (){.cdecl.}
-    gtk_reserved102: proc (){.cdecl.}
-    gtk_reserved103: proc (){.cdecl.}
-    gtk_reserved104: proc (){.cdecl.}
-
-  PGtkCalendarDisplayOptions* = ptr TGtkCalendarDisplayOptions
-  TGtkCalendarDisplayOptions* = int32
-  PGtkCalendar* = ptr TGtkCalendar
-  TGtkCalendar* = object of TGtkWidget
-    header_style*: PGtkStyle
-    label_style*: PGtkStyle
-    month*: gint
-    year*: gint
-    selected_day*: gint
-    day_month*: array[0..5, array[0..6, gint]]
-    day*: array[0..5, array[0..6, gint]]
-    num_marked_dates*: gint
-    marked_date*: array[0..30, gint]
-    display_flags*: TGtkCalendarDisplayOptions
-    marked_date_color*: array[0..30, TGdkColor]
-    gc*: PGdkGC
-    xor_gc*: PGdkGC
-    focus_row*: gint
-    focus_col*: gint
-    highlight_row*: gint
-    highlight_col*: gint
-    private_data*: gpointer
-    grow_space*: array[0..31, gchar]
-    gtk_reserved111: proc (){.cdecl.}
-    gtk_reserved112: proc (){.cdecl.}
-    gtk_reserved113: proc (){.cdecl.}
-    gtk_reserved114: proc (){.cdecl.}
-
-  PGtkCalendarClass* = ptr TGtkCalendarClass
-  TGtkCalendarClass* = object of TGtkWidgetClass
-    month_changed*: proc (calendar: PGtkCalendar){.cdecl.}
-    day_selected*: proc (calendar: PGtkCalendar){.cdecl.}
-    day_selected_double_click*: proc (calendar: PGtkCalendar){.cdecl.}
-    prev_month*: proc (calendar: PGtkCalendar){.cdecl.}
-    next_month*: proc (calendar: PGtkCalendar){.cdecl.}
-    prev_year*: proc (calendar: PGtkCalendar){.cdecl.}
-    next_year*: proc (calendar: PGtkCalendar){.cdecl.}
-
-  PGtkCellEditable* = pointer
-  PGtkCellEditableIface* = ptr TGtkCellEditableIface
-  TGtkCellEditableIface* = object of TGTypeInterface
-    editing_done*: proc (cell_editable: PGtkCellEditable){.cdecl.}
-    remove_widget*: proc (cell_editable: PGtkCellEditable){.cdecl.}
-    start_editing*: proc (cell_editable: PGtkCellEditable, event: PGdkEvent){.
-        cdecl.}
-
-  PGtkCellRendererState* = ptr TGtkCellRendererState
-  TGtkCellRendererState* = int32
-  PGtkCellRendererMode* = ptr TGtkCellRendererMode
-  TGtkCellRendererMode* = enum
-    GTK_CELL_RENDERER_MODE_INERT, GTK_CELL_RENDERER_MODE_ACTIVATABLE,
-    GTK_CELL_RENDERER_MODE_EDITABLE
-  PGtkCellRenderer* = ptr TGtkCellRenderer
-  TGtkCellRenderer* = object of  TGtkObject
-    xalign*: gfloat
-    yalign*: gfloat
-    width*: gint
-    height*: gint
-    xpad*: guint16
-    ypad*: guint16
-    GtkCellRenderer_flag0*: guint16
-
-  PGtkCellRendererClass* = ptr TGtkCellRendererClass
-  TGtkCellRendererClass* = object of TGtkObjectClass
-    get_size*: proc (cell: PGtkCellRenderer, widget: PGtkWidget,
-                     cell_area: PGdkRectangle, x_offset: Pgint, y_offset: Pgint,
-                     width: Pgint, height: Pgint){.cdecl.}
-    render*: proc (cell: PGtkCellRenderer, window: PGdkWindow,
-                   widget: PGtkWidget, background_area: PGdkRectangle,
-                   cell_area: PGdkRectangle, expose_area: PGdkRectangle,
-                   flags: TGtkCellRendererState){.cdecl.}
-    activate*: proc (cell: PGtkCellRenderer, event: PGdkEvent,
-                     widget: PGtkWidget, path: cstring,
-                     background_area: PGdkRectangle, cell_area: PGdkRectangle,
-                     flags: TGtkCellRendererState): gboolean{.cdecl.}
-    start_editing*: proc (cell: PGtkCellRenderer, event: PGdkEvent,
-                          widget: PGtkWidget, path: cstring,
-                          background_area: PGdkRectangle,
-                          cell_area: PGdkRectangle, flags: TGtkCellRendererState): PGtkCellEditable{.
-        cdecl.}
-    gtk_reserved121: proc (){.cdecl.}
-    gtk_reserved122: proc (){.cdecl.}
-    gtk_reserved123: proc (){.cdecl.}
-    gtk_reserved124: proc (){.cdecl.}
-
-  PGtkCellRendererText* = ptr TGtkCellRendererText
-  TGtkCellRendererText* = object of TGtkCellRenderer
-    text*: cstring
-    font*: PPangoFontDescription
-    font_scale*: gdouble
-    foreground*: TPangoColor
-    background*: TPangoColor
-    extra_attrs*: PPangoAttrList
-    underline_style*: TPangoUnderline
-    rise*: gint
-    fixed_height_rows*: gint
-    GtkCellRendererText_flag0*: guint16
-
-  PGtkCellRendererTextClass* = ptr TGtkCellRendererTextClass
-  TGtkCellRendererTextClass* = object of TGtkCellRendererClass
-    edited*: proc (cell_renderer_text: PGtkCellRendererText, path: cstring,
-                   new_text: cstring){.cdecl.}
-    gtk_reserved131: proc (){.cdecl.}
-    gtk_reserved132: proc (){.cdecl.}
-    gtk_reserved133: proc (){.cdecl.}
-    gtk_reserved134: proc (){.cdecl.}
-
-  PGtkCellRendererToggle* = ptr TGtkCellRendererToggle
-  TGtkCellRendererToggle* = object of TGtkCellRenderer
-    GtkCellRendererToggle_flag0*: guint16
-
-  PGtkCellRendererToggleClass* = ptr TGtkCellRendererToggleClass
-  TGtkCellRendererToggleClass* = object of TGtkCellRendererClass
-    toggled*: proc (cell_renderer_toggle: PGtkCellRendererToggle, path: cstring){.
-        cdecl.}
-    gtk_reserved141: proc (){.cdecl.}
-    gtk_reserved142: proc (){.cdecl.}
-    gtk_reserved143: proc (){.cdecl.}
-    gtk_reserved144: proc (){.cdecl.}
-
-  PGtkCellRendererPixbuf* = ptr TGtkCellRendererPixbuf
-  TGtkCellRendererPixbuf* = object of TGtkCellRenderer
-    pixbuf*: PGdkPixbuf
-    pixbuf_expander_open*: PGdkPixbuf
-    pixbuf_expander_closed*: PGdkPixbuf
-
-  PGtkCellRendererPixbufClass* = ptr TGtkCellRendererPixbufClass
-  TGtkCellRendererPixbufClass* = object of TGtkCellRendererClass
-    gtk_reserved151: proc (){.cdecl.}
-    gtk_reserved152: proc (){.cdecl.}
-    gtk_reserved153: proc (){.cdecl.}
-    gtk_reserved154: proc (){.cdecl.}
-
-  PGtkItem* = ptr TGtkItem
-  TGtkItem* = object of TGtkBin
-
-  PGtkItemClass* = ptr TGtkItemClass
-  TGtkItemClass* = object of TGtkBinClass
-    select*: proc (item: PGtkItem){.cdecl.}
-    deselect*: proc (item: PGtkItem){.cdecl.}
-    toggle*: proc (item: PGtkItem){.cdecl.}
-    gtk_reserved161: proc (){.cdecl.}
-    gtk_reserved162: proc (){.cdecl.}
-    gtk_reserved163: proc (){.cdecl.}
-    gtk_reserved164: proc (){.cdecl.}
-
-  PGtkMenuItem* = ptr TGtkMenuItem
-  TGtkMenuItem* = object of TGtkItem
-    submenu*: PGtkWidget
-    event_window*: PGdkWindow
-    toggle_size*: guint16
-    accelerator_width*: guint16
-    accel_path*: cstring
-    GtkMenuItem_flag0*: guint16
-    timer*: guint
-
-  PGtkMenuItemClass* = ptr TGtkMenuItemClass
-  TGtkMenuItemClass* = object of TGtkItemClass
-    GtkMenuItemClass_flag0*: guint16
-    activate*: proc (menu_item: PGtkMenuItem){.cdecl.}
-    activate_item*: proc (menu_item: PGtkMenuItem){.cdecl.}
-    toggle_size_request*: proc (menu_item: PGtkMenuItem, requisition: Pgint){.
-        cdecl.}
-    toggle_size_allocate*: proc (menu_item: PGtkMenuItem, allocation: gint){.
-        cdecl.}
-    gtk_reserved171: proc (){.cdecl.}
-    gtk_reserved172: proc (){.cdecl.}
-    gtk_reserved173: proc (){.cdecl.}
-    gtk_reserved174: proc (){.cdecl.}
-
-  PGtkToggleButton* = ptr TGtkToggleButton
-  TGtkToggleButton* = object of TGtkButton
-    GtkToggleButton_flag0*: guint16
-
-  PGtkToggleButtonClass* = ptr TGtkToggleButtonClass
-  TGtkToggleButtonClass* = object of TGtkButtonClass
-    toggled*: proc (toggle_button: PGtkToggleButton){.cdecl.}
-    gtk_reserved171: proc (){.cdecl.}
-    gtk_reserved172: proc (){.cdecl.}
-    gtk_reserved173: proc (){.cdecl.}
-    gtk_reserved174: proc (){.cdecl.}
-
-  PGtkCheckButton* = ptr TGtkCheckButton
-  TGtkCheckButton* = object of TGtkToggleButton
-
-  PGtkCheckButtonClass* = ptr TGtkCheckButtonClass
-  TGtkCheckButtonClass* = object of TGtkToggleButtonClass
-    draw_indicator*: proc (check_button: PGtkCheckButton, area: PGdkRectangle){.
-        cdecl.}
-    gtk_reserved181: proc (){.cdecl.}
-    gtk_reserved182: proc (){.cdecl.}
-    gtk_reserved183: proc (){.cdecl.}
-    gtk_reserved184: proc (){.cdecl.}
-
-  PGtkCheckMenuItem* = ptr TGtkCheckMenuItem
-  TGtkCheckMenuItem* = object of TGtkMenuItem
-    GtkCheckMenuItem_flag0*: guint16
-
-  PGtkCheckMenuItemClass* = ptr TGtkCheckMenuItemClass
-  TGtkCheckMenuItemClass* = object of TGtkMenuItemClass
-    toggled*: proc (check_menu_item: PGtkCheckMenuItem){.cdecl.}
-    draw_indicator*: proc (check_menu_item: PGtkCheckMenuItem,
-                           area: PGdkRectangle){.cdecl.}
-    gtk_reserved191: proc (){.cdecl.}
-    gtk_reserved192: proc (){.cdecl.}
-    gtk_reserved193: proc (){.cdecl.}
-    gtk_reserved194: proc (){.cdecl.}
-
-  PGtkClipboard* = pointer
-  TGtkClipboardReceivedFunc* = proc (clipboard: PGtkClipboard,
-                                     selection_data: PGtkSelectionData,
-                                     data: gpointer){.cdecl.}
-  TGtkClipboardTextReceivedFunc* = proc (clipboard: PGtkClipboard, text: cstring,
-      data: gpointer){.cdecl.}
-  TGtkClipboardGetFunc* = proc (clipboard: PGtkClipboard,
-                                selection_data: PGtkSelectionData, info: guint,
-                                user_data_or_owner: gpointer){.cdecl.}
-  TGtkClipboardClearFunc* = proc (clipboard: PGtkClipboard,
-                                  user_data_or_owner: gpointer){.cdecl.}
-  PGtkCList* = ptr TGtkCList
-  PGtkCListColumn* = ptr TGtkCListColumn
-  PGtkCListRow* = ptr TGtkCListRow
-  PGtkCell* = ptr TGtkCell
-  PGtkCellType* = ptr TGtkCellType
-  TGtkCellType* = enum
-    GTK_CELL_EMPTY, GTK_CELL_TEXT, GTK_CELL_PIXMAP, GTK_CELL_PIXTEXT,
-    GTK_CELL_WIDGET
-  PGtkCListDragPos* = ptr TGtkCListDragPos
-  TGtkCListDragPos* = enum
-    GTK_CLIST_DRAG_NONE, GTK_CLIST_DRAG_BEFORE, GTK_CLIST_DRAG_INTO,
-    GTK_CLIST_DRAG_AFTER
-  PGtkButtonAction* = ptr TGtkButtonAction
-  TGtkButtonAction* = int32
-  TGtkCListCompareFunc* = proc (clist: PGtkCList, ptr1: gconstpointer,
-                                ptr2: gconstpointer): gint{.cdecl.}
-  PGtkCListCellInfo* = ptr TGtkCListCellInfo
-  TGtkCListCellInfo* {.final, pure.} = object
-    row*: gint
-    column*: gint
-
-  PGtkCListDestInfo* = ptr TGtkCListDestInfo
-  TGtkCListDestInfo* {.final, pure.} = object
-    cell*: TGtkCListCellInfo
-    insert_pos*: TGtkCListDragPos
-
-  TGtkCList* = object of TGtkContainer
-    GtkCList_flags*: guint16
-    row_mem_chunk*: PGMemChunk
-    cell_mem_chunk*: PGMemChunk
-    freeze_count*: guint
-    internal_allocation*: TGdkRectangle
-    rows*: gint
-    row_height*: gint
-    row_list*: PGList
-    row_list_end*: PGList
-    columns*: gint
-    column_title_area*: TGdkRectangle
-    title_window*: PGdkWindow
-    column*: PGtkCListColumn
-    clist_window*: PGdkWindow
-    clist_window_width*: gint
-    clist_window_height*: gint
-    hoffset*: gint
-    voffset*: gint
-    shadow_type*: TGtkShadowType
-    selection_mode*: TGtkSelectionMode
-    selection*: PGList
-    selection_end*: PGList
-    undo_selection*: PGList
-    undo_unselection*: PGList
-    undo_anchor*: gint
-    button_actions*: array[0..4, guint8]
-    drag_button*: guint8
-    click_cell*: TGtkCListCellInfo
-    hadjustment*: PGtkAdjustment
-    vadjustment*: PGtkAdjustment
-    xor_gc*: PGdkGC
-    fg_gc*: PGdkGC
-    bg_gc*: PGdkGC
-    cursor_drag*: PGdkCursor
-    x_drag*: gint
-    focus_row*: gint
-    focus_header_column*: gint
-    anchor*: gint
-    anchor_state*: TGtkStateType
-    drag_pos*: gint
-    htimer*: gint
-    vtimer*: gint
-    sort_type*: TGtkSortType
-    compare*: TGtkCListCompareFunc
-    sort_column*: gint
-    drag_highlight_row*: gint
-    drag_highlight_pos*: TGtkCListDragPos
-
-  PGtkCListClass* = ptr TGtkCListClass
-  TGtkCListClass* = object of TGtkContainerClass
-    set_scroll_adjustments*: proc (clist: PGtkCList,
-                                   hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-    refresh*: proc (clist: PGtkCList){.cdecl.}
-    select_row*: proc (clist: PGtkCList, row: gint, column: gint,
-                       event: PGdkEvent){.cdecl.}
-    unselect_row*: proc (clist: PGtkCList, row: gint, column: gint,
-                         event: PGdkEvent){.cdecl.}
-    row_move*: proc (clist: PGtkCList, source_row: gint, dest_row: gint){.cdecl.}
-    click_column*: proc (clist: PGtkCList, column: gint){.cdecl.}
-    resize_column*: proc (clist: PGtkCList, column: gint, width: gint){.cdecl.}
-    toggle_focus_row*: proc (clist: PGtkCList){.cdecl.}
-    select_all*: proc (clist: PGtkCList){.cdecl.}
-    unselect_all*: proc (clist: PGtkCList){.cdecl.}
-    undo_selection*: proc (clist: PGtkCList){.cdecl.}
-    start_selection*: proc (clist: PGtkCList){.cdecl.}
-    end_selection*: proc (clist: PGtkCList){.cdecl.}
-    extend_selection*: proc (clist: PGtkCList, scroll_type: TGtkScrollType,
-                             position: gfloat, auto_start_selection: gboolean){.
-        cdecl.}
-    scroll_horizontal*: proc (clist: PGtkCList, scroll_type: TGtkScrollType,
-                              position: gfloat){.cdecl.}
-    scroll_vertical*: proc (clist: PGtkCList, scroll_type: TGtkScrollType,
-                            position: gfloat){.cdecl.}
-    toggle_add_mode*: proc (clist: PGtkCList){.cdecl.}
-    abort_column_resize*: proc (clist: PGtkCList){.cdecl.}
-    resync_selection*: proc (clist: PGtkCList, event: PGdkEvent){.cdecl.}
-    selection_find*: proc (clist: PGtkCList, row_number: gint,
-                           row_list_element: PGList): PGList{.cdecl.}
-    draw_row*: proc (clist: PGtkCList, area: PGdkRectangle, row: gint,
-                     clist_row: PGtkCListRow){.cdecl.}
-    draw_drag_highlight*: proc (clist: PGtkCList, target_row: PGtkCListRow,
-                                target_row_number: gint,
-                                drag_pos: TGtkCListDragPos){.cdecl.}
-    clear*: proc (clist: PGtkCList){.cdecl.}
-    fake_unselect_all*: proc (clist: PGtkCList, row: gint){.cdecl.}
-    sort_list*: proc (clist: PGtkCList){.cdecl.}
-    insert_row*: proc (clist: PGtkCList, row: gint): gint{.cdecl, varargs.}
-    remove_row*: proc (clist: PGtkCList, row: gint){.cdecl.}
-    set_cell_contents*: proc (clist: PGtkCList, clist_row: PGtkCListRow,
-                              column: gint, thetype: TGtkCellType, text: cstring,
-                              spacing: guint8, pixmap: PGdkPixmap,
-                              mask: PGdkBitmap){.cdecl.}
-    cell_size_request*: proc (clist: PGtkCList, clist_row: PGtkCListRow,
-                              column: gint, requisition: PGtkRequisition){.cdecl.}
-
-  PGPtrArray = pointer
-  PGArray = pointer
-  TGtkCListColumn* {.final, pure.} = object
-    title*: cstring
-    area*: TGdkRectangle
-    button*: PGtkWidget
-    window*: PGdkWindow
-    width*: gint
-    min_width*: gint
-    max_width*: gint
-    justification*: TGtkJustification
-    flag0*: guint16
-
-  TGtkCListRow* {.final, pure.} = object
-    cell*: PGtkCell
-    state*: TGtkStateType
-    foreground*: TGdkColor
-    background*: TGdkColor
-    style*: PGtkStyle
-    data*: gpointer
-    destroy*: TGtkDestroyNotify
-    flag0*: guint16
-
-  PGtkCellText* = ptr TGtkCellText
-  TGtkCellText* {.final, pure.} = object
-    `type`*: TGtkCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PGtkStyle
-    text*: cstring
-
-  PGtkCellPixmap* = ptr TGtkCellPixmap
-  TGtkCellPixmap* {.final, pure.} = object
-    `type`*: TGtkCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PGtkStyle
-    pixmap*: PGdkPixmap
-    mask*: PGdkBitmap
-
-  PGtkCellPixText* = ptr TGtkCellPixText
-  TGtkCellPixText* {.final, pure.} = object
-    `type`*: TGtkCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PGtkStyle
-    text*: cstring
-    spacing*: guint8
-    pixmap*: PGdkPixmap
-    mask*: PGdkBitmap
-
-  PGtkCellWidget* = ptr TGtkCellWidget
-  TGtkCellWidget* {.final, pure.} = object
-    `type`*: TGtkCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PGtkStyle
-    widget*: PGtkWidget
-
-  TGtkCell* {.final, pure.} = object
-    `type`*: TGtkCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PGtkStyle
-    text*: cstring
-    spacing*: guint8
-    pixmap*: PGdkPixmap
-    mask*: PGdkBitmap
-
-  PGtkDialogFlags* = ptr TGtkDialogFlags
-  TGtkDialogFlags* = int32
-  PGtkResponseType* = ptr TGtkResponseType
-  TGtkResponseType* = int32
-  PGtkDialog* = ptr TGtkDialog
-  TGtkDialog* = object of TGtkWindow
-    vbox*: PGtkWidget
-    action_area*: PGtkWidget
-    separator*: PGtkWidget
-
-  PGtkDialogClass* = ptr TGtkDialogClass
-  TGtkDialogClass* = object of TGtkWindowClass
-    response*: proc (dialog: PGtkDialog, response_id: gint){.cdecl.}
-    closeFile*: proc (dialog: PGtkDialog){.cdecl.}
-    gtk_reserved201: proc (){.cdecl.}
-    gtk_reserved202: proc (){.cdecl.}
-    gtk_reserved203: proc (){.cdecl.}
-    gtk_reserved204: proc (){.cdecl.}
-
-  PGtkVBox* = ptr TGtkVBox
-  TGtkVBox* = object of TGtkBox
-
-  PGtkVBoxClass* = ptr TGtkVBoxClass
-  TGtkVBoxClass* = object of TGtkBoxClass
-
-  TGtkColorSelectionChangePaletteFunc* = proc (colors: PGdkColor, n_colors: gint){.
-      cdecl.}
-  TGtkColorSelectionChangePaletteWithScreenFunc* = proc (screen: PGdkScreen,
-      colors: PGdkColor, n_colors: gint){.cdecl.}
-  PGtkColorSelection* = ptr TGtkColorSelection
-  TGtkColorSelection* = object of TGtkVBox
-    private_data*: gpointer
-
-  PGtkColorSelectionClass* = ptr TGtkColorSelectionClass
-  TGtkColorSelectionClass* = object of TGtkVBoxClass
-    color_changed*: proc (color_selection: PGtkColorSelection){.cdecl.}
-    gtk_reserved211: proc (){.cdecl.}
-    gtk_reserved212: proc (){.cdecl.}
-    gtk_reserved213: proc (){.cdecl.}
-    gtk_reserved214: proc (){.cdecl.}
-
-  PGtkColorSelectionDialog* = ptr TGtkColorSelectionDialog
-  TGtkColorSelectionDialog* = object of TGtkDialog
-    colorsel*: PGtkWidget
-    ok_button*: PGtkWidget
-    cancel_button*: PGtkWidget
-    help_button*: PGtkWidget
-
-  PGtkColorSelectionDialogClass* = ptr TGtkColorSelectionDialogClass
-  TGtkColorSelectionDialogClass* = object of TGtkDialogClass
-    gtk_reserved221: proc (){.cdecl.}
-    gtk_reserved222: proc (){.cdecl.}
-    gtk_reserved223: proc (){.cdecl.}
-    gtk_reserved224: proc (){.cdecl.}
-
-  PGtkHBox* = ptr TGtkHBox
-  TGtkHBox* = object of TGtkBox
-
-  PGtkHBoxClass* = ptr TGtkHBoxClass
-  TGtkHBoxClass* = object of TGtkBoxClass
-
-  PGtkCombo* = ptr TGtkCombo
-  TGtkCombo* = object of TGtkHBox
-    entry*: PGtkWidget
-    button*: PGtkWidget
-    popup*: PGtkWidget
-    popwin*: PGtkWidget
-    list*: PGtkWidget
-    entry_change_id*: guint
-    list_change_id*: guint
-    GtkCombo_flag0*: guint16
-    current_button*: guint16
-    activate_id*: guint
-
-  PGtkComboClass* = ptr TGtkComboClass
-  TGtkComboClass* = object of TGtkHBoxClass
-    gtk_reserved231: proc (){.cdecl.}
-    gtk_reserved232: proc (){.cdecl.}
-    gtk_reserved233: proc (){.cdecl.}
-    gtk_reserved234: proc (){.cdecl.}
-
-  PGtkCTreePos* = ptr TGtkCTreePos
-  TGtkCTreePos* = enum
-    GTK_CTREE_POS_BEFORE, GTK_CTREE_POS_AS_CHILD, GTK_CTREE_POS_AFTER
-  PGtkCTreeLineStyle* = ptr TGtkCTreeLineStyle
-  TGtkCTreeLineStyle* = enum
-    GTK_CTREE_LINES_NONE, GTK_CTREE_LINES_SOLID, GTK_CTREE_LINES_DOTTED,
-    GTK_CTREE_LINES_TABBED
-  PGtkCTreeExpanderStyle* = ptr TGtkCTreeExpanderStyle
-  TGtkCTreeExpanderStyle* = enum
-    GTK_CTREE_EXPANDER_NONE, GTK_CTREE_EXPANDER_SQUARE,
-    GTK_CTREE_EXPANDER_TRIANGLE, GTK_CTREE_EXPANDER_CIRCULAR
-  PGtkCTreeExpansionType* = ptr TGtkCTreeExpansionType
-  TGtkCTreeExpansionType* = enum
-    GTK_CTREE_EXPANSION_EXPAND, GTK_CTREE_EXPANSION_EXPAND_RECURSIVE,
-    GTK_CTREE_EXPANSION_COLLAPSE, GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE,
-    GTK_CTREE_EXPANSION_TOGGLE, GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE
-  PGtkCTree* = ptr TGtkCTree
-  PGtkCTreeNode* = ptr TGtkCTreeNode
-  TGtkCTreeFunc* = proc (ctree: PGtkCTree, node: PGtkCTreeNode, data: gpointer){.
-      cdecl.}
-  TGtkCTreeGNodeFunc* = proc (ctree: PGtkCTree, depth: guint, gnode: PGNode,
-                              cnode: PGtkCTreeNode, data: gpointer): gboolean{.
-      cdecl.}
-  TGtkCTreeCompareDragFunc* = proc (ctree: PGtkCTree,
-                                    source_node: PGtkCTreeNode,
-                                    new_parent: PGtkCTreeNode,
-                                    new_sibling: PGtkCTreeNode): gboolean{.cdecl.}
-  TGtkCTree* = object of TGtkCList
-    lines_gc*: PGdkGC
-    tree_indent*: gint
-    tree_spacing*: gint
-    tree_column*: gint
-    GtkCTree_flag0*: guint16
-    drag_compare*: TGtkCTreeCompareDragFunc
-
-  PGtkCTreeClass* = ptr TGtkCTreeClass
-  TGtkCTreeClass* = object of TGtkCListClass
-    tree_select_row*: proc (ctree: PGtkCTree, row: PGtkCTreeNode, column: gint){.
-        cdecl.}
-    tree_unselect_row*: proc (ctree: PGtkCTree, row: PGtkCTreeNode, column: gint){.
-        cdecl.}
-    tree_expand*: proc (ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl.}
-    tree_collapse*: proc (ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl.}
-    tree_move*: proc (ctree: PGtkCTree, node: PGtkCTreeNode,
-                      new_parent: PGtkCTreeNode, new_sibling: PGtkCTreeNode){.
-        cdecl.}
-    change_focus_row_expansion*: proc (ctree: PGtkCTree,
-                                       action: TGtkCTreeExpansionType){.cdecl.}
-
-  PGtkCTreeRow* = ptr TGtkCTreeRow
-  TGtkCTreeRow* {.final, pure.} = object
-    row*: TGtkCListRow
-    parent*: PGtkCTreeNode
-    sibling*: PGtkCTreeNode
-    children*: PGtkCTreeNode
-    pixmap_closed*: PGdkPixmap
-    mask_closed*: PGdkBitmap
-    pixmap_opened*: PGdkPixmap
-    mask_opened*: PGdkBitmap
-    level*: guint16
-    GtkCTreeRow_flag0*: guint16
-
-  TGtkCTreeNode* {.final, pure.} = object
-    list*: TGList
-
-  PGtkDrawingArea* = ptr TGtkDrawingArea
-  TGtkDrawingArea* = object of TGtkWidget
-    draw_data*: gpointer
-
-  PGtkDrawingAreaClass* = ptr TGtkDrawingAreaClass
-  TGtkDrawingAreaClass* = object of TGtkWidgetClass
-    gtk_reserved241: proc (){.cdecl.}
-    gtk_reserved242: proc (){.cdecl.}
-    gtk_reserved243: proc (){.cdecl.}
-    gtk_reserved244: proc (){.cdecl.}
-
-  Tctlpoint* = array[0..1, gfloat]
-  Pctlpoint* = ptr Tctlpoint
-  PGtkCurve* = ptr TGtkCurve
-  TGtkCurve* = object of TGtkDrawingArea
-    cursor_type*: gint
-    min_x*: gfloat
-    max_x*: gfloat
-    min_y*: gfloat
-    max_y*: gfloat
-    pixmap*: PGdkPixmap
-    curve_type*: TGtkCurveType
-    height*: gint
-    grab_point*: gint
-    last*: gint
-    num_points*: gint
-    point*: PGdkPoint
-    num_ctlpoints*: gint
-    ctlpoint*: Pctlpoint
-
-  PGtkCurveClass* = ptr TGtkCurveClass
-  TGtkCurveClass* = object of TGtkDrawingAreaClass
-    curve_type_changed*: proc (curve: PGtkCurve){.cdecl.}
-    gtk_reserved251: proc (){.cdecl.}
-    gtk_reserved252: proc (){.cdecl.}
-    gtk_reserved253: proc (){.cdecl.}
-    gtk_reserved254: proc (){.cdecl.}
-
-  PGtkDestDefaults* = ptr TGtkDestDefaults
-  TGtkDestDefaults* = int32
-  PGtkTargetFlags* = ptr TGtkTargetFlags
-  TGtkTargetFlags* = int32
-  PGtkEditable* = pointer
-  PGtkEditableClass* = ptr TGtkEditableClass
-  TGtkEditableClass* = object of TGTypeInterface
-    insert_text*: proc (editable: PGtkEditable, text: cstring, length: gint,
-                        position: Pgint){.cdecl.}
-    delete_text*: proc (editable: PGtkEditable, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    changed*: proc (editable: PGtkEditable){.cdecl.}
-    do_insert_text*: proc (editable: PGtkEditable, text: cstring, length: gint,
-                           position: Pgint){.cdecl.}
-    do_delete_text*: proc (editable: PGtkEditable, start_pos: gint,
-                           end_pos: gint){.cdecl.}
-    get_chars*: proc (editable: PGtkEditable, start_pos: gint, end_pos: gint): cstring{.
-        cdecl.}
-    set_selection_bounds*: proc (editable: PGtkEditable, start_pos: gint,
-                                 end_pos: gint){.cdecl.}
-    get_selection_bounds*: proc (editable: PGtkEditable, start_pos: Pgint,
-                                 end_pos: Pgint): gboolean{.cdecl.}
-    set_position*: proc (editable: PGtkEditable, position: gint){.cdecl.}
-    get_position*: proc (editable: PGtkEditable): gint{.cdecl.}
-
-  PGtkIMContext* = ptr TGtkIMContext
-  TGtkIMContext* = object of TGObject
-
-  PGtkIMContextClass* = ptr TGtkIMContextClass
-  TGtkIMContextClass* = object of TGtkObjectClass
-    preedit_start*: proc (context: PGtkIMContext){.cdecl.}
-    preedit_end*: proc (context: PGtkIMContext){.cdecl.}
-    preedit_changed*: proc (context: PGtkIMContext){.cdecl.}
-    commit*: proc (context: PGtkIMContext, str: cstring){.cdecl.}
-    retrieve_surrounding*: proc (context: PGtkIMContext): gboolean{.cdecl.}
-    delete_surrounding*: proc (context: PGtkIMContext, offset: gint,
-                               n_chars: gint): gboolean{.cdecl.}
-    set_client_window*: proc (context: PGtkIMContext, window: PGdkWindow){.cdecl.}
-    get_preedit_string*: proc (context: PGtkIMContext, str: PPgchar,
-                               attrs: var PPangoAttrList, cursor_pos: Pgint){.
-        cdecl.}
-    filter_keypress*: proc (context: PGtkIMContext, event: PGdkEventKey): gboolean{.
-        cdecl.}
-    focus_in*: proc (context: PGtkIMContext){.cdecl.}
-    focus_out*: proc (context: PGtkIMContext){.cdecl.}
-    reset*: proc (context: PGtkIMContext){.cdecl.}
-    set_cursor_location*: proc (context: PGtkIMContext, area: PGdkRectangle){.
-        cdecl.}
-    set_use_preedit*: proc (context: PGtkIMContext, use_preedit: gboolean){.
-        cdecl.}
-    set_surrounding*: proc (context: PGtkIMContext, text: cstring, len: gint,
-                            cursor_index: gint){.cdecl.}
-    get_surrounding*: proc (context: PGtkIMContext, text: PPgchar,
-                            cursor_index: Pgint): gboolean{.cdecl.}
-    gtk_reserved261: proc (){.cdecl.}
-    gtk_reserved262: proc (){.cdecl.}
-    gtk_reserved263: proc (){.cdecl.}
-    gtk_reserved264: proc (){.cdecl.}
-    gtk_reserved265: proc (){.cdecl.}
-    gtk_reserved266: proc (){.cdecl.}
-
-  PGtkMenuShell* = ptr TGtkMenuShell
-  TGtkMenuShell* = object of TGtkContainer
-    children*: PGList
-    active_menu_item*: PGtkWidget
-    parent_menu_shell*: PGtkWidget
-    button*: guint
-    activate_time*: guint32
-    GtkMenuShell_flag0*: guint16
-
-  PGtkMenuShellClass* = ptr TGtkMenuShellClass
-  TGtkMenuShellClass* = object of TGtkContainerClass
-    GtkMenuShellClass_flag0*: guint16
-    deactivate*: proc (menu_shell: PGtkMenuShell){.cdecl.}
-    selection_done*: proc (menu_shell: PGtkMenuShell){.cdecl.}
-    move_current*: proc (menu_shell: PGtkMenuShell,
-                         direction: TGtkMenuDirectionType){.cdecl.}
-    activate_current*: proc (menu_shell: PGtkMenuShell, force_hide: gboolean){.
-        cdecl.}
-    cancel*: proc (menu_shell: PGtkMenuShell){.cdecl.}
-    select_item*: proc (menu_shell: PGtkMenuShell, menu_item: PGtkWidget){.cdecl.}
-    insert*: proc (menu_shell: PGtkMenuShell, child: PGtkWidget, position: gint){.
-        cdecl.}
-    gtk_reserved271: proc (){.cdecl.}
-    gtk_reserved272: proc (){.cdecl.}
-    gtk_reserved273: proc (){.cdecl.}
-    gtk_reserved274: proc (){.cdecl.}
-
-  TGtkMenuPositionFunc* = proc (menu: PGtkMenu, x: Pgint, y: Pgint,
-                                push_in: Pgboolean, user_data: gpointer){.cdecl.}
-  TGtkMenuDetachFunc* = proc (attach_widget: PGtkWidget, menu: PGtkMenu){.cdecl.}
-  TGtkMenu* = object of TGtkMenuShell
-    parent_menu_item*: PGtkWidget
-    old_active_menu_item*: PGtkWidget
-    accel_group*: PGtkAccelGroup
-    accel_path*: cstring
-    position_func*: TGtkMenuPositionFunc
-    position_func_data*: gpointer
-    toggle_size*: guint
-    toplevel*: PGtkWidget
-    tearoff_window*: PGtkWidget
-    tearoff_hbox*: PGtkWidget
-    tearoff_scrollbar*: PGtkWidget
-    tearoff_adjustment*: PGtkAdjustment
-    view_window*: PGdkWindow
-    bin_window*: PGdkWindow
-    scroll_offset*: gint
-    saved_scroll_offset*: gint
-    scroll_step*: gint
-    timeout_id*: guint
-    navigation_region*: PGdkRegion
-    navigation_timeout*: guint
-    GtkMenu_flag0*: guint16
-
-  PGtkMenuClass* = ptr TGtkMenuClass
-  TGtkMenuClass* = object of TGtkMenuShellClass
-    gtk_reserved281: proc (){.cdecl.}
-    gtk_reserved282: proc (){.cdecl.}
-    gtk_reserved283: proc (){.cdecl.}
-    gtk_reserved284: proc (){.cdecl.}
-
-  PGtkEntry* = ptr TGtkEntry
-  TGtkEntry* = object of TGtkWidget
-    text*: cstring
-    GtkEntry_flag0*: guint16
-    text_length*: guint16
-    text_max_length*: guint16
-    text_area*: PGdkWindow
-    im_context*: PGtkIMContext
-    popup_menu*: PGtkWidget
-    current_pos*: gint
-    selection_bound*: gint
-    cached_layout*: PPangoLayout
-    flag1*: guint16
-    button*: guint
-    blink_timeout*: guint
-    recompute_idle*: guint
-    scroll_offset*: gint
-    ascent*: gint
-    descent*: gint
-    text_size*: guint16
-    n_bytes*: guint16
-    preedit_length*: guint16
-    preedit_cursor*: guint16
-    dnd_position*: gint
-    drag_start_x*: gint
-    drag_start_y*: gint
-    invisible_char*: gunichar
-    width_chars*: gint
-
-  PGtkEntryClass* = ptr TGtkEntryClass
-  TGtkEntryClass* = object of TGtkWidgetClass
-    populate_popup*: proc (entry: PGtkEntry, menu: PGtkMenu){.cdecl.}
-    activate*: proc (entry: PGtkEntry){.cdecl.}
-    move_cursor*: proc (entry: PGtkEntry, step: TGtkMovementStep, count: gint,
-                        extend_selection: gboolean){.cdecl.}
-    insert_at_cursor*: proc (entry: PGtkEntry, str: cstring){.cdecl.}
-    delete_from_cursor*: proc (entry: PGtkEntry, thetype: TGtkDeleteType,
-                               count: gint){.cdecl.}
-    cut_clipboard*: proc (entry: PGtkEntry){.cdecl.}
-    copy_clipboard*: proc (entry: PGtkEntry){.cdecl.}
-    paste_clipboard*: proc (entry: PGtkEntry){.cdecl.}
-    toggle_overwrite*: proc (entry: PGtkEntry){.cdecl.}
-    gtk_reserved291: proc (){.cdecl.}
-    gtk_reserved292: proc (){.cdecl.}
-    gtk_reserved293: proc (){.cdecl.}
-    gtk_reserved294: proc (){.cdecl.}
-
-  PGtkEventBox* = ptr TGtkEventBox
-  TGtkEventBox* = object of TGtkBin
-
-  PGtkEventBoxClass* = ptr TGtkEventBoxClass
-  TGtkEventBoxClass* = object of TGtkBinClass
-
-  PGtkFileSelection* = ptr TGtkFileSelection
-  TGtkFileSelection* = object of TGtkDialog
-    dir_list*: PGtkWidget
-    file_list*: PGtkWidget
-    selection_entry*: PGtkWidget
-    selection_text*: PGtkWidget
-    main_vbox*: PGtkWidget
-    ok_button*: PGtkWidget
-    cancel_button*: PGtkWidget
-    help_button*: PGtkWidget
-    history_pulldown*: PGtkWidget
-    history_menu*: PGtkWidget
-    history_list*: PGList
-    fileop_dialog*: PGtkWidget
-    fileop_entry*: PGtkWidget
-    fileop_file*: cstring
-    cmpl_state*: gpointer
-    fileop_c_dir*: PGtkWidget
-    fileop_del_file*: PGtkWidget
-    fileop_ren_file*: PGtkWidget
-    button_area*: PGtkWidget
-    gtkFileSelection_action_area*: PGtkWidget
-    selected_names*: PGPtrArray
-    last_selected*: cstring
-
-  PGtkFileSelectionClass* = ptr TGtkFileSelectionClass
-  TGtkFileSelectionClass* = object of TGtkDialogClass
-    gtk_reserved301: proc (){.cdecl.}
-    gtk_reserved302: proc (){.cdecl.}
-    gtk_reserved303: proc (){.cdecl.}
-    gtk_reserved304: proc (){.cdecl.}
-
-  PGtkFixed* = ptr TGtkFixed
-  TGtkFixed* = object of TGtkContainer
-    children*: PGList
-
-  PGtkFixedClass* = ptr TGtkFixedClass
-  TGtkFixedClass* = object of TGtkContainerClass
-
-  PGtkFixedChild* = ptr TGtkFixedChild
-  TGtkFixedChild* {.final, pure.} = object
-    widget*: PGtkWidget
-    x*: gint
-    y*: gint
-
-  PGtkFontSelection* = ptr TGtkFontSelection
-  TGtkFontSelection* = object of TGtkVBox
-    font_entry*: PGtkWidget
-    family_list*: PGtkWidget
-    font_style_entry*: PGtkWidget
-    face_list*: PGtkWidget
-    size_entry*: PGtkWidget
-    size_list*: PGtkWidget
-    pixels_button*: PGtkWidget
-    points_button*: PGtkWidget
-    filter_button*: PGtkWidget
-    preview_entry*: PGtkWidget
-    family*: PPangoFontFamily
-    face*: PPangoFontFace
-    size*: gint
-    font*: PGdkFont
-
-  PGtkFontSelectionClass* = ptr TGtkFontSelectionClass
-  TGtkFontSelectionClass* = object of TGtkVBoxClass
-    gtk_reserved311: proc (){.cdecl.}
-    gtk_reserved312: proc (){.cdecl.}
-    gtk_reserved313: proc (){.cdecl.}
-    gtk_reserved314: proc (){.cdecl.}
-
-  PGtkFontSelectionDialog* = ptr TGtkFontSelectionDialog
-  TGtkFontSelectionDialog* = object of TGtkDialog
-    fontsel*: PGtkWidget
-    main_vbox*: PGtkWidget
-    GtkFontSelectionDialog_action_area*: PGtkWidget
-    ok_button*: PGtkWidget
-    apply_button*: PGtkWidget
-    cancel_button*: PGtkWidget
-    dialog_width*: gint
-    auto_resize*: gboolean
-
-  PGtkFontSelectionDialogClass* = ptr TGtkFontSelectionDialogClass
-  TGtkFontSelectionDialogClass* = object of TGtkDialogClass
-    gtk_reserved321: proc (){.cdecl.}
-    gtk_reserved322: proc (){.cdecl.}
-    gtk_reserved323: proc (){.cdecl.}
-    gtk_reserved324: proc (){.cdecl.}
-
-  PGtkGammaCurve* = ptr TGtkGammaCurve
-  TGtkGammaCurve* = object of TGtkVBox
-    table*: PGtkWidget
-    curve*: PGtkWidget
-    button*: array[0..4, PGtkWidget]
-    gamma*: gfloat
-    gamma_dialog*: PGtkWidget
-    gamma_text*: PGtkWidget
-
-  PGtkGammaCurveClass* = ptr TGtkGammaCurveClass
-  TGtkGammaCurveClass* = object of TGtkVBoxClass
-    gtk_reserved331: proc (){.cdecl.}
-    gtk_reserved332: proc (){.cdecl.}
-    gtk_reserved333: proc (){.cdecl.}
-    gtk_reserved334: proc (){.cdecl.}
-
-  PGtkHandleBox* = ptr TGtkHandleBox
-  TGtkHandleBox* = object of TGtkBin
-    bin_window*: PGdkWindow
-    float_window*: PGdkWindow
-    shadow_type*: TGtkShadowType
-    GtkHandleBox_flag0*: guint16
-    deskoff_x*: gint
-    deskoff_y*: gint
-    attach_allocation*: TGtkAllocation
-    float_allocation*: TGtkAllocation
-
-  PGtkHandleBoxClass* = ptr TGtkHandleBoxClass
-  TGtkHandleBoxClass* = object of TGtkBinClass
-    child_attached*: proc (handle_box: PGtkHandleBox, child: PGtkWidget){.cdecl.}
-    child_detached*: proc (handle_box: PGtkHandleBox, child: PGtkWidget){.cdecl.}
-    gtk_reserved341: proc (){.cdecl.}
-    gtk_reserved342: proc (){.cdecl.}
-    gtk_reserved343: proc (){.cdecl.}
-    gtk_reserved344: proc (){.cdecl.}
-
-  PGtkPaned* = ptr TGtkPaned
-  TGtkPaned* = object of TGtkContainer
-    child1*: PGtkWidget
-    child2*: PGtkWidget
-    handle*: PGdkWindow
-    xor_gc*: PGdkGC
-    cursor_type*: TGdkCursorType
-    handle_pos*: TGdkRectangle
-    child1_size*: gint
-    last_allocation*: gint
-    min_position*: gint
-    max_position*: gint
-    GtkPaned_flag0*: guint16
-    last_child1_focus*: PGtkWidget
-    last_child2_focus*: PGtkWidget
-    saved_focus*: PGtkWidget
-    drag_pos*: gint
-    original_position*: gint
-
-  PGtkPanedClass* = ptr TGtkPanedClass
-  TGtkPanedClass* = object of TGtkContainerClass
-    cycle_child_focus*: proc (paned: PGtkPaned, reverse: gboolean): gboolean{.
-        cdecl.}
-    toggle_handle_focus*: proc (paned: PGtkPaned): gboolean{.cdecl.}
-    move_handle*: proc (paned: PGtkPaned, scroll: TGtkScrollType): gboolean{.
-        cdecl.}
-    cycle_handle_focus*: proc (paned: PGtkPaned, reverse: gboolean): gboolean{.
-        cdecl.}
-    accept_position*: proc (paned: PGtkPaned): gboolean{.cdecl.}
-    cancel_position*: proc (paned: PGtkPaned): gboolean{.cdecl.}
-    gtk_reserved351: proc (){.cdecl.}
-    gtk_reserved352: proc (){.cdecl.}
-    gtk_reserved353: proc (){.cdecl.}
-    gtk_reserved354: proc (){.cdecl.}
-
-  PGtkHButtonBox* = ptr TGtkHButtonBox
-  TGtkHButtonBox* = object of TGtkButtonBox
-
-  PGtkHButtonBoxClass* = ptr TGtkHButtonBoxClass
-  TGtkHButtonBoxClass* = object of TGtkButtonBoxClass
-
-  PGtkHPaned* = ptr TGtkHPaned
-  TGtkHPaned* = object of TGtkPaned
-
-  PGtkHPanedClass* = ptr TGtkHPanedClass
-  TGtkHPanedClass* = object of TGtkPanedClass
-
-  PGtkRulerMetric* = ptr TGtkRulerMetric
-  PGtkRuler* = ptr TGtkRuler
-  TGtkRuler* = object of TGtkWidget
-    backing_store*: PGdkPixmap
-    non_gr_exp_gc*: PGdkGC
-    metric*: PGtkRulerMetric
-    xsrc*: gint
-    ysrc*: gint
-    slider_size*: gint
-    lower*: gdouble
-    upper*: gdouble
-    position*: gdouble
-    max_size*: gdouble
-
-  PGtkRulerClass* = ptr TGtkRulerClass
-  TGtkRulerClass* = object of TGtkWidgetClass
-    draw_ticks*: proc (ruler: PGtkRuler){.cdecl.}
-    draw_pos*: proc (ruler: PGtkRuler){.cdecl.}
-    gtk_reserved361: proc (){.cdecl.}
-    gtk_reserved362: proc (){.cdecl.}
-    gtk_reserved363: proc (){.cdecl.}
-    gtk_reserved364: proc (){.cdecl.}
-
-  TGtkRulerMetric* {.final, pure.} = object
-    metric_name*: cstring
-    abbrev*: cstring
-    pixels_per_unit*: gdouble
-    ruler_scale*: array[0..9, gdouble]
-    subdivide*: array[0..4, gint]
-
-  PGtkHRuler* = ptr TGtkHRuler
-  TGtkHRuler* = object of TGtkRuler
-
-  PGtkHRulerClass* = ptr TGtkHRulerClass
-  TGtkHRulerClass* = object of TGtkRulerClass
-
-  PGtkRcContext* = pointer
-  PGtkSettings* = ptr TGtkSettings
-  TGtkSettings* = object of TGObject
-    queued_settings*: PGData
-    property_values*: PGValue
-    rc_context*: PGtkRcContext
-    screen*: PGdkScreen
-
-  PGtkSettingsClass* = ptr TGtkSettingsClass
-  TGtkSettingsClass* = object of TGObjectClass
-
-  PGtkSettingsValue* = ptr TGtkSettingsValue
-  TGtkSettingsValue* {.final, pure.} = object
-    origin*: cstring
-    value*: TGValue
-
-  PGtkRcFlags* = ptr TGtkRcFlags
-  TGtkRcFlags* = int32
-  PGtkRcStyle* = ptr TGtkRcStyle
-  TGtkRcStyle* = object of TGObject
-    name*: cstring
-    bg_pixmap_name*: array[0..4, cstring]
-    font_desc*: PPangoFontDescription
-    color_flags*: array[0..4, TGtkRcFlags]
-    fg*: array[0..4, TGdkColor]
-    bg*: array[0..4, TGdkColor]
-    text*: array[0..4, TGdkColor]
-    base*: array[0..4, TGdkColor]
-    xthickness*: gint
-    ythickness*: gint
-    rc_properties*: PGArray
-    rc_style_lists*: PGSList
-    icon_factories*: PGSList
-    GtkRcStyle_flag0*: guint16
-
-  PGtkRcStyleClass* = ptr TGtkRcStyleClass
-  TGtkRcStyleClass* = object of TGObjectClass
-    create_rc_style*: proc (rc_style: PGtkRcStyle): PGtkRcStyle{.cdecl.}
-    parse*: proc (rc_style: PGtkRcStyle, settings: PGtkSettings,
-                  scanner: PGScanner): guint{.cdecl.}
-    merge*: proc (dest: PGtkRcStyle, src: PGtkRcStyle){.cdecl.}
-    create_style*: proc (rc_style: PGtkRcStyle): PGtkStyle{.cdecl.}
-    gtk_reserved371: proc (){.cdecl.}
-    gtk_reserved372: proc (){.cdecl.}
-    gtk_reserved373: proc (){.cdecl.}
-    gtk_reserved374: proc (){.cdecl.}
-
-  PGtkRcTokenType* = ptr TGtkRcTokenType
-  TGtkRcTokenType* = enum
-    GTK_RC_TOKEN_INVALID, GTK_RC_TOKEN_INCLUDE, GTK_RC_TOKEN_NORMAL,
-    GTK_RC_TOKEN_ACTIVE, GTK_RC_TOKEN_PRELIGHT, GTK_RC_TOKEN_SELECTED,
-    GTK_RC_TOKEN_INSENSITIVE, GTK_RC_TOKEN_FG, GTK_RC_TOKEN_BG,
-    GTK_RC_TOKEN_TEXT, GTK_RC_TOKEN_BASE, GTK_RC_TOKEN_XTHICKNESS,
-    GTK_RC_TOKEN_YTHICKNESS, GTK_RC_TOKEN_FONT, GTK_RC_TOKEN_FONTSET,
-    GTK_RC_TOKEN_FONT_NAME, GTK_RC_TOKEN_BG_PIXMAP, GTK_RC_TOKEN_PIXMAP_PATH,
-    GTK_RC_TOKEN_STYLE, GTK_RC_TOKEN_BINDING, GTK_RC_TOKEN_BIND,
-    GTK_RC_TOKEN_WIDGET, GTK_RC_TOKEN_WIDGET_CLASS, GTK_RC_TOKEN_CLASS,
-    GTK_RC_TOKEN_LOWEST, GTK_RC_TOKEN_GTK, GTK_RC_TOKEN_APPLICATION,
-    GTK_RC_TOKEN_THEME, GTK_RC_TOKEN_RC, GTK_RC_TOKEN_HIGHEST,
-    GTK_RC_TOKEN_ENGINE, GTK_RC_TOKEN_MODULE_PATH, GTK_RC_TOKEN_IM_MODULE_PATH,
-    GTK_RC_TOKEN_IM_MODULE_FILE, GTK_RC_TOKEN_STOCK, GTK_RC_TOKEN_LTR,
-    GTK_RC_TOKEN_RTL, GTK_RC_TOKEN_LAST
-  PGtkRcProperty* = ptr TGtkRcProperty
-  TGtkRcProperty* {.final, pure.} = object
-    type_name*: TGQuark
-    property_name*: TGQuark
-    origin*: cstring
-    value*: TGValue
-
-  PGtkIconSource* = pointer
-  TGtkRcPropertyParser* = proc (pspec: PGParamSpec, rc_string: PGString,
-                                property_value: PGValue): gboolean{.cdecl.}
-  TGtkStyle* = object of TGObject
-    fg*: array[0..4, TGdkColor]
-    bg*: array[0..4, TGdkColor]
-    light*: array[0..4, TGdkColor]
-    dark*: array[0..4, TGdkColor]
-    mid*: array[0..4, TGdkColor]
-    text*: array[0..4, TGdkColor]
-    base*: array[0..4, TGdkColor]
-    text_aa*: array[0..4, TGdkColor]
-    black*: TGdkColor
-    white*: TGdkColor
-    font_desc*: PPangoFontDescription
-    xthickness*: gint
-    ythickness*: gint
-    fg_gc*: array[0..4, PGdkGC]
-    bg_gc*: array[0..4, PGdkGC]
-    light_gc*: array[0..4, PGdkGC]
-    dark_gc*: array[0..4, PGdkGC]
-    mid_gc*: array[0..4, PGdkGC]
-    text_gc*: array[0..4, PGdkGC]
-    base_gc*: array[0..4, PGdkGC]
-    text_aa_gc*: array[0..4, PGdkGC]
-    black_gc*: PGdkGC
-    white_gc*: PGdkGC
-    bg_pixmap*: array[0..4, PGdkPixmap]
-    attach_count*: gint
-    depth*: gint
-    colormap*: PGdkColormap
-    private_font*: PGdkFont
-    private_font_desc*: PPangoFontDescription
-    rc_style*: PGtkRcStyle
-    styles*: PGSList
-    property_cache*: PGArray
-    icon_factories*: PGSList
-
-  PGtkStyleClass* = ptr TGtkStyleClass
-  TGtkStyleClass* = object of TGObjectClass
-    realize*: proc (style: PGtkStyle){.cdecl.}
-    unrealize*: proc (style: PGtkStyle){.cdecl.}
-    copy*: proc (style: PGtkStyle, src: PGtkStyle){.cdecl.}
-    clone*: proc (style: PGtkStyle): PGtkStyle{.cdecl.}
-    init_from_rc*: proc (style: PGtkStyle, rc_style: PGtkRcStyle){.cdecl.}
-    set_background*: proc (style: PGtkStyle, window: PGdkWindow,
-                           state_type: TGtkStateType){.cdecl.}
-    render_icon*: proc (style: PGtkStyle, source: PGtkIconSource,
-                        direction: TGtkTextDirection, state: TGtkStateType,
-                        size: TGtkIconSize, widget: PGtkWidget, detail: cstring): PGdkPixbuf{.
-        cdecl.}
-    draw_hline*: proc (style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, area: PGdkRectangle,
-                       widget: PGtkWidget, detail: cstring, x1: gint, x2: gint,
-                       y: gint){.cdecl.}
-    draw_vline*: proc (style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, area: PGdkRectangle,
-                       widget: PGtkWidget, detail: cstring, y1: gint, y2: gint,
-                       x: gint){.cdecl.}
-    draw_shadow*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_polygon*: proc (style: PGtkStyle, window: PGdkWindow,
-                         state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                         area: PGdkRectangle, widget: PGtkWidget,
-                         detail: cstring, point: PGdkPoint, npoints: gint,
-                         fill: gboolean){.cdecl.}
-    draw_arrow*: proc (style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       arrow_type: TGtkArrowType, fill: gboolean, x: gint,
-                       y: gint, width: gint, height: gint){.cdecl.}
-    draw_diamond*: proc (style: PGtkStyle, window: PGdkWindow,
-                         state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                         area: PGdkRectangle, widget: PGtkWidget,
-                         detail: cstring, x: gint, y: gint, width: gint,
-                         height: gint){.cdecl.}
-    draw_string*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, area: PGdkRectangle,
-                        widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                        `string`: cstring){.cdecl.}
-    draw_box*: proc (style: PGtkStyle, window: PGdkWindow,
-                     state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                     area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                     x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_flat_box*: proc (style: PGtkStyle, window: PGdkWindow,
-                          state_type: TGtkStateType,
-                          shadow_type: TGtkShadowType, area: PGdkRectangle,
-                          widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                          width: gint, height: gint){.cdecl.}
-    draw_check*: proc (style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_option*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_tab*: proc (style: PGtkStyle, window: PGdkWindow,
-                     state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                     area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                     x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_shadow_gap*: proc (style: PGtkStyle, window: PGdkWindow,
-                            state_type: TGtkStateType,
-                            shadow_type: TGtkShadowType, area: PGdkRectangle,
-                            widget: PGtkWidget, detail: cstring, x: gint,
-                            y: gint, width: gint, height: gint,
-                            gap_side: TGtkPositionType, gap_x: gint,
-                            gap_width: gint){.cdecl.}
-    draw_box_gap*: proc (style: PGtkStyle, window: PGdkWindow,
-                         state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                         area: PGdkRectangle, widget: PGtkWidget,
-                         detail: cstring, x: gint, y: gint, width: gint,
-                         height: gint, gap_side: TGtkPositionType, gap_x: gint,
-                         gap_width: gint){.cdecl.}
-    draw_extension*: proc (style: PGtkStyle, window: PGdkWindow,
-                           state_type: TGtkStateType,
-                           shadow_type: TGtkShadowType, area: PGdkRectangle,
-                           widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                           width: gint, height: gint, gap_side: TGtkPositionType){.
-        cdecl.}
-    draw_focus*: proc (style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, area: PGdkRectangle,
-                       widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                       width: gint, height: gint){.cdecl.}
-    draw_slider*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint,
-                        orientation: TGtkOrientation){.cdecl.}
-    draw_handle*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint,
-                        orientation: TGtkOrientation){.cdecl.}
-    draw_expander*: proc (style: PGtkStyle, window: PGdkWindow,
-                          state_type: TGtkStateType, area: PGdkRectangle,
-                          widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                          expander_style: TGtkExpanderStyle){.cdecl.}
-    draw_layout*: proc (style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, use_text: gboolean,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, layout: PPangoLayout){.cdecl.}
-    draw_resize_grip*: proc (style: PGtkStyle, window: PGdkWindow,
-                             state_type: TGtkStateType, area: PGdkRectangle,
-                             widget: PGtkWidget, detail: cstring,
-                             edge: TGdkWindowEdge, x: gint, y: gint,
-                             width: gint, height: gint){.cdecl.}
-    gtk_reserved381: proc (){.cdecl.}
-    gtk_reserved382: proc (){.cdecl.}
-    gtk_reserved383: proc (){.cdecl.}
-    gtk_reserved384: proc (){.cdecl.}
-    gtk_reserved385: proc (){.cdecl.}
-    gtk_reserved386: proc (){.cdecl.}
-    gtk_reserved387: proc (){.cdecl.}
-    gtk_reserved388: proc (){.cdecl.}
-    gtk_reserved389: proc (){.cdecl.}
-    gtk_reserved3810: proc (){.cdecl.}
-    gtk_reserved3811: proc (){.cdecl.}
-    gtk_reserved3812: proc (){.cdecl.}
-
-  PGtkBorder* = ptr TGtkBorder
-  TGtkBorder* {.final, pure.} = object
-    left*: gint
-    right*: gint
-    top*: gint
-    bottom*: gint
-
-  PGtkRangeLayout* = pointer
-  PGtkRangeStepTimer* = pointer
-  PGtkRange* = ptr TGtkRange
-  TGtkRange* = object of TGtkWidget
-    adjustment*: PGtkAdjustment
-    update_policy*: TGtkUpdateType
-    GtkRange_flag0*: guint16
-    min_slider_size*: gint
-    orientation*: TGtkOrientation
-    range_rect*: TGdkRectangle
-    slider_start*: gint
-    slider_end*: gint
-    round_digits*: gint
-    flag1*: guint16
-    layout*: PGtkRangeLayout
-    timer*: PGtkRangeStepTimer
-    slide_initial_slider_position*: gint
-    slide_initial_coordinate*: gint
-    update_timeout_id*: guint
-    event_window*: PGdkWindow
-
-  PGtkRangeClass* = ptr TGtkRangeClass
-  TGtkRangeClass* = object of TGtkWidgetClass
-    slider_detail*: cstring
-    stepper_detail*: cstring
-    value_changed*: proc (range: PGtkRange){.cdecl.}
-    adjust_bounds*: proc (range: PGtkRange, new_value: gdouble){.cdecl.}
-    move_slider*: proc (range: PGtkRange, scroll: TGtkScrollType){.cdecl.}
-    get_range_border*: proc (range: PGtkRange, border: PGtkBorder){.cdecl.}
-    gtk_reserved401: proc (){.cdecl.}
-    gtk_reserved402: proc (){.cdecl.}
-    gtk_reserved403: proc (){.cdecl.}
-    gtk_reserved404: proc (){.cdecl.}
-
-  PGtkScale* = ptr TGtkScale
-  TGtkScale* = object of TGtkRange
-    digits*: gint
-    GtkScale_flag0*: guint16
-
-  PGtkScaleClass* = ptr TGtkScaleClass
-  TGtkScaleClass* = object of TGtkRangeClass
-    format_value*: proc (scale: PGtkScale, value: gdouble): cstring{.cdecl.}
-    draw_value*: proc (scale: PGtkScale){.cdecl.}
-    gtk_reserved411: proc (){.cdecl.}
-    gtk_reserved412: proc (){.cdecl.}
-    gtk_reserved413: proc (){.cdecl.}
-    gtk_reserved414: proc (){.cdecl.}
-
-  PGtkHScale* = ptr TGtkHScale
-  TGtkHScale* = object of TGtkScale
-
-  PGtkHScaleClass* = ptr TGtkHScaleClass
-  TGtkHScaleClass* = object of TGtkScaleClass
-
-  PGtkScrollbar* = ptr TGtkScrollbar
-  TGtkScrollbar* = object of TGtkRange
-
-  PGtkScrollbarClass* = ptr TGtkScrollbarClass
-  TGtkScrollbarClass* = object of TGtkRangeClass
-    gtk_reserved421: proc (){.cdecl.}
-    gtk_reserved422: proc (){.cdecl.}
-    gtk_reserved423: proc (){.cdecl.}
-    gtk_reserved424: proc (){.cdecl.}
-
-  PGtkHScrollbar* = ptr TGtkHScrollbar
-  TGtkHScrollbar* = object of TGtkScrollbar
-
-  PGtkHScrollbarClass* = ptr TGtkHScrollbarClass
-  TGtkHScrollbarClass* = object of TGtkScrollbarClass
-
-  PGtkSeparator* = ptr TGtkSeparator
-  TGtkSeparator* = object of TGtkWidget
-
-  PGtkSeparatorClass* = ptr TGtkSeparatorClass
-  TGtkSeparatorClass* = object of TGtkWidgetClass
-
-  PGtkHSeparator* = ptr TGtkHSeparator
-  TGtkHSeparator* = object of TGtkSeparator
-
-  PGtkHSeparatorClass* = ptr TGtkHSeparatorClass
-  TGtkHSeparatorClass* = object of TGtkSeparatorClass
-
-  PGtkIconFactory* = ptr TGtkIconFactory
-  TGtkIconFactory* = object of TGObject
-    icons*: PGHashTable
-
-  PGtkIconFactoryClass* = ptr TGtkIconFactoryClass
-  TGtkIconFactoryClass* = object of TGObjectClass
-    gtk_reserved431: proc (){.cdecl.}
-    gtk_reserved432: proc (){.cdecl.}
-    gtk_reserved433: proc (){.cdecl.}
-    gtk_reserved434: proc (){.cdecl.}
-
-  PGtkIconSet* = pointer
-  PGtkImagePixmapData* = ptr TGtkImagePixmapData
-  TGtkImagePixmapData* {.final, pure.} = object
-    pixmap*: PGdkPixmap
-
-  PGtkImageImageData* = ptr TGtkImageImageData
-  TGtkImageImageData* {.final, pure.} = object
-    image*: PGdkImage
-
-  PGtkImagePixbufData* = ptr TGtkImagePixbufData
-  TGtkImagePixbufData* {.final, pure.} = object
-    pixbuf*: PGdkPixbuf
-
-  PGtkImageStockData* = ptr TGtkImageStockData
-  TGtkImageStockData* {.final, pure.} = object
-    stock_id*: cstring
-
-  PGtkImageIconSetData* = ptr TGtkImageIconSetData
-  TGtkImageIconSetData* {.final, pure.} = object
-    icon_set*: PGtkIconSet
-
-  PGtkImageAnimationData* = ptr TGtkImageAnimationData
-  TGtkImageAnimationData* {.final, pure.} = object
-    anim*: PGdkPixbufAnimation
-    iter*: PGdkPixbufAnimationIter
-    frame_timeout*: guint
-
-  PGtkImageType* = ptr TGtkImageType
-  TGtkImageType* = enum
-    GTK_IMAGE_EMPTY, GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE, GTK_IMAGE_PIXBUF,
-    GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ANIMATION
-  PGtkImage* = ptr TGtkImage
-  TGtkImage* = object of TGtkMisc
-    storage_type*: TGtkImageType
-    pixmap*: TGtkImagePixmapData
-    mask*: PGdkBitmap
-    icon_size*: TGtkIconSize
-
-  PGtkImageClass* = ptr TGtkImageClass
-  TGtkImageClass* = object of TGtkMiscClass
-    gtk_reserved441: proc (){.cdecl.}
-    gtk_reserved442: proc (){.cdecl.}
-    gtk_reserved443: proc (){.cdecl.}
-    gtk_reserved444: proc (){.cdecl.}
-
-  PGtkImageMenuItem* = ptr TGtkImageMenuItem
-  TGtkImageMenuItem* = object of TGtkMenuItem
-    image*: PGtkWidget
-
-  PGtkImageMenuItemClass* = ptr TGtkImageMenuItemClass
-  TGtkImageMenuItemClass* = object of TGtkMenuItemClass
-
-  PGtkIMContextSimple* = ptr TGtkIMContextSimple
-  TGtkIMContextSimple* = object of TGtkIMContext
-    tables*: PGSList
-    compose_buffer*: array[0..(GTK_MAX_COMPOSE_LEN + 1) - 1, guint]
-    tentative_match*: gunichar
-    tentative_match_len*: gint
-    GtkIMContextSimple_flag0*: guint16
-
-  PGtkIMContextSimpleClass* = ptr TGtkIMContextSimpleClass
-  TGtkIMContextSimpleClass* = object of TGtkIMContextClass
-
-  PGtkIMMulticontext* = ptr TGtkIMMulticontext
-  TGtkIMMulticontext* = object of TGtkIMContext
-    slave*: PGtkIMContext
-    client_window*: PGdkWindow
-    context_id*: cstring
-
-  PGtkIMMulticontextClass* = ptr TGtkIMMulticontextClass
-  TGtkIMMulticontextClass* = object of TGtkIMContextClass
-    gtk_reserved451: proc (){.cdecl.}
-    gtk_reserved452: proc (){.cdecl.}
-    gtk_reserved453: proc (){.cdecl.}
-    gtk_reserved454: proc (){.cdecl.}
-
-  PGtkInputDialog* = ptr TGtkInputDialog
-  TGtkInputDialog* = object of TGtkDialog
-    axis_list*: PGtkWidget
-    axis_listbox*: PGtkWidget
-    mode_optionmenu*: PGtkWidget
-    close_button*: PGtkWidget
-    save_button*: PGtkWidget
-    axis_items*: array[0..(GDK_AXIS_LAST) - 1, PGtkWidget]
-    current_device*: PGdkDevice
-    keys_list*: PGtkWidget
-    keys_listbox*: PGtkWidget
-
-  PGtkInputDialogClass* = ptr TGtkInputDialogClass
-  TGtkInputDialogClass* = object of TGtkDialogClass
-    enable_device*: proc (inputd: PGtkInputDialog, device: PGdkDevice){.cdecl.}
-    disable_device*: proc (inputd: PGtkInputDialog, device: PGdkDevice){.cdecl.}
-    gtk_reserved461: proc (){.cdecl.}
-    gtk_reserved462: proc (){.cdecl.}
-    gtk_reserved463: proc (){.cdecl.}
-    gtk_reserved464: proc (){.cdecl.}
-
-  PGtkInvisible* = ptr TGtkInvisible
-  TGtkInvisible* = object of TGtkWidget
-    has_user_ref_count*: gboolean
-    screen*: PGdkScreen
-
-  PGtkInvisibleClass* = ptr TGtkInvisibleClass
-  TGtkInvisibleClass* = object of TGtkWidgetClass
-    gtk_reserved701: proc (){.cdecl.}
-    gtk_reserved702: proc (){.cdecl.}
-    gtk_reserved703: proc (){.cdecl.}
-    gtk_reserved704: proc (){.cdecl.}
-
-  TGtkPrintFunc* = proc (func_data: gpointer, str: cstring){.cdecl.}
-  PGtkTranslateFunc* = ptr TGtkTranslateFunc
-  TGtkTranslateFunc* = gchar
-  TGtkItemFactoryCallback* = proc (){.cdecl.}
-  TGtkItemFactoryCallback1* = proc (callback_data: gpointer,
-                                    callback_action: guint, widget: PGtkWidget){.
-      cdecl.}
-  PGtkItemFactory* = ptr TGtkItemFactory
-  TGtkItemFactory* = object of TGtkObject
-    path*: cstring
-    accel_group*: PGtkAccelGroup
-    widget*: PGtkWidget
-    items*: PGSList
-    translate_func*: TGtkTranslateFunc
-    translate_data*: gpointer
-    translate_notify*: TGtkDestroyNotify
-
-  PGtkItemFactoryClass* = ptr TGtkItemFactoryClass
-  TGtkItemFactoryClass* = object of TGtkObjectClass
-    item_ht*: PGHashTable
-    gtk_reserved471: proc (){.cdecl.}
-    gtk_reserved472: proc (){.cdecl.}
-    gtk_reserved473: proc (){.cdecl.}
-    gtk_reserved474: proc (){.cdecl.}
-
-  PGtkItemFactoryEntry* = ptr TGtkItemFactoryEntry
-  TGtkItemFactoryEntry* {.final, pure.} = object
-    path*: cstring
-    accelerator*: cstring
-    callback*: TGtkItemFactoryCallback
-    callback_action*: guint
-    item_type*: cstring
-    extra_data*: gconstpointer
-
-  PGtkItemFactoryItem* = ptr TGtkItemFactoryItem
-  TGtkItemFactoryItem* {.final, pure.} = object
-    path*: cstring
-    widgets*: PGSList
-
-  PGtkLayout* = ptr TGtkLayout
-  TGtkLayout* = object of TGtkContainer
-    children*: PGList
-    width*: guint
-    height*: guint
-    hadjustment*: PGtkAdjustment
-    vadjustment*: PGtkAdjustment
-    bin_window*: PGdkWindow
-    visibility*: TGdkVisibilityState
-    scroll_x*: gint
-    scroll_y*: gint
-    freeze_count*: guint
-
-  PGtkLayoutClass* = ptr TGtkLayoutClass
-  TGtkLayoutClass* = object of TGtkContainerClass
-    set_scroll_adjustments*: proc (layout: PGtkLayout,
-                                   hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-    gtk_reserved481: proc (){.cdecl.}
-    gtk_reserved482: proc (){.cdecl.}
-    gtk_reserved483: proc (){.cdecl.}
-    gtk_reserved484: proc (){.cdecl.}
-
-  PGtkList* = ptr TGtkList
-  TGtkList* = object of TGtkContainer
-    children*: PGList
-    selection*: PGList
-    undo_selection*: PGList
-    undo_unselection*: PGList
-    last_focus_child*: PGtkWidget
-    undo_focus_child*: PGtkWidget
-    htimer*: guint
-    vtimer*: guint
-    anchor*: gint
-    drag_pos*: gint
-    anchor_state*: TGtkStateType
-    GtkList_flag0*: guint16
-
-  PGtkListClass* = ptr TGtkListClass
-  TGtkListClass* = object of TGtkContainerClass
-    selection_changed*: proc (list: PGtkList){.cdecl.}
-    select_child*: proc (list: PGtkList, child: PGtkWidget){.cdecl.}
-    unselect_child*: proc (list: PGtkList, child: PGtkWidget){.cdecl.}
-
-  TGtkTreeModelForeachFunc* = proc (model: PGtkTreeModel, path: PGtkTreePath,
-                                    iter: PGtkTreeIter, data: gpointer): gboolean{.
-      cdecl.}
-  PGtkTreeModelFlags* = ptr TGtkTreeModelFlags
-  TGtkTreeModelFlags* = int32
-  TGtkTreeIter* {.final, pure.} = object
-    stamp*: gint
-    user_data*: gpointer
-    user_data2*: gpointer
-    user_data3*: gpointer
-
-  PGtkTreeModelIface* = ptr TGtkTreeModelIface
-  TGtkTreeModelIface* = object of TGTypeInterface
-    row_changed*: proc (tree_model: PGtkTreeModel, path: PGtkTreePath,
-                        iter: PGtkTreeIter){.cdecl.}
-    row_inserted*: proc (tree_model: PGtkTreeModel, path: PGtkTreePath,
-                         iter: PGtkTreeIter){.cdecl.}
-    row_has_child_toggled*: proc (tree_model: PGtkTreeModel, path: PGtkTreePath,
-                                  iter: PGtkTreeIter){.cdecl.}
-    row_deleted*: proc (tree_model: PGtkTreeModel, path: PGtkTreePath){.cdecl.}
-    rows_reordered*: proc (tree_model: PGtkTreeModel, path: PGtkTreePath,
-                           iter: PGtkTreeIter, new_order: Pgint){.cdecl.}
-    get_flags*: proc (tree_model: PGtkTreeModel): TGtkTreeModelFlags{.cdecl.}
-    get_n_columns*: proc (tree_model: PGtkTreeModel): gint{.cdecl.}
-    get_column_type*: proc (tree_model: PGtkTreeModel, index: gint): GType{.
-        cdecl.}
-    get_iter*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                     path: PGtkTreePath): gboolean{.cdecl.}
-    get_path*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter): PGtkTreePath{.
-        cdecl.}
-    get_value*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                      column: gint, value: PGValue){.cdecl.}
-    iter_next*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter): gboolean{.
-        cdecl.}
-    iter_children*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                          parent: PGtkTreeIter): gboolean{.cdecl.}
-    iter_has_child*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter): gboolean{.
-        cdecl.}
-    iter_n_children*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter): gint{.
-        cdecl.}
-    iter_nth_child*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                           parent: PGtkTreeIter, n: gint): gboolean{.cdecl.}
-    iter_parent*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                        child: PGtkTreeIter): gboolean{.cdecl.}
-    ref_node*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter){.cdecl.}
-    unref_node*: proc (tree_model: PGtkTreeModel, iter: PGtkTreeIter){.cdecl.}
-
-  PGtkTreeSortable* = pointer
-  TGtkTreeIterCompareFunc* = proc (model: PGtkTreeModel, a: PGtkTreeIter,
-                                   b: PGtkTreeIter, user_data: gpointer): gint{.
-      cdecl.}
-  PGtkTreeSortableIface* = ptr TGtkTreeSortableIface
-  TGtkTreeSortableIface* = object of TGTypeInterface
-    sort_column_changed*: proc (sortable: PGtkTreeSortable){.cdecl.}
-    get_sort_column_id*: proc (sortable: PGtkTreeSortable,
-                               sort_column_id: Pgint, order: PGtkSortType): gboolean{.
-        cdecl.}
-    set_sort_column_id*: proc (sortable: PGtkTreeSortable, sort_column_id: gint,
-                               order: TGtkSortType){.cdecl.}
-    set_sort_func*: proc (sortable: PGtkTreeSortable, sort_column_id: gint,
-                          func: TGtkTreeIterCompareFunc, data: gpointer,
-                          destroy: TGtkDestroyNotify){.cdecl.}
-    set_default_sort_func*: proc (sortable: PGtkTreeSortable,
-                                  func: TGtkTreeIterCompareFunc, data: gpointer,
-                                  destroy: TGtkDestroyNotify){.cdecl.}
-    has_default_sort_func*: proc (sortable: PGtkTreeSortable): gboolean{.cdecl.}
-
-  PGtkTreeModelSort* = ptr TGtkTreeModelSort
-  TGtkTreeModelSort* = object of TGObject
-    root*: gpointer
-    stamp*: gint
-    child_flags*: guint
-    child_model*: PGtkTreeModel
-    zero_ref_count*: gint
-    sort_list*: PGList
-    sort_column_id*: gint
-    order*: TGtkSortType
-    default_sort_func*: TGtkTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TGtkDestroyNotify
-    changed_id*: guint
-    inserted_id*: guint
-    has_child_toggled_id*: guint
-    deleted_id*: guint
-    reordered_id*: guint
-
-  PGtkTreeModelSortClass* = ptr TGtkTreeModelSortClass
-  TGtkTreeModelSortClass* = object of TGObjectClass
-    gtk_reserved491: proc (){.cdecl.}
-    gtk_reserved492: proc (){.cdecl.}
-    gtk_reserved493: proc (){.cdecl.}
-    gtk_reserved494: proc (){.cdecl.}
-
-  PGtkListStore* = ptr TGtkListStore
-  TGtkListStore* = object of TGObject
-    stamp*: gint
-    root*: gpointer
-    tail*: gpointer
-    sort_list*: PGList
-    n_columns*: gint
-    sort_column_id*: gint
-    order*: TGtkSortType
-    column_headers*: PGType
-    length*: gint
-    default_sort_func*: TGtkTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TGtkDestroyNotify
-    GtkListStore_flag0*: guint16
-
-  PGtkListStoreClass* = ptr TGtkListStoreClass
-  TGtkListStoreClass* = object of TGObjectClass
-    gtk_reserved501: proc (){.cdecl.}
-    gtk_reserved502: proc (){.cdecl.}
-    gtk_reserved503: proc (){.cdecl.}
-    gtk_reserved504: proc (){.cdecl.}
-
-  TGtkModuleInitFunc* = proc (argc: Pgint, argv: PPPgchar){.cdecl.}
-  TGtkKeySnoopFunc* = proc (grab_widget: PGtkWidget, event: PGdkEventKey,
-                            func_data: gpointer): gint{.cdecl.}
-  PGtkMenuBar* = ptr TGtkMenuBar
-  TGtkMenuBar* = object of TGtkMenuShell
-
-  PGtkMenuBarClass* = ptr TGtkMenuBarClass
-  TGtkMenuBarClass* = object of TGtkMenuShellClass
-    gtk_reserved511: proc (){.cdecl.}
-    gtk_reserved512: proc (){.cdecl.}
-    gtk_reserved513: proc (){.cdecl.}
-    gtk_reserved514: proc (){.cdecl.}
-
-  PGtkMessageType* = ptr TGtkMessageType
-  TGtkMessageType* = enum
-    GTK_MESSAGE_INFO, GTK_MESSAGE_WARNING, GTK_MESSAGE_QUESTION,
-    GTK_MESSAGE_ERROR
-  PGtkButtonsType* = ptr TGtkButtonsType
-  TGtkButtonsType* = enum
-    GTK_BUTTONS_NONE, GTK_BUTTONS_OK, GTK_BUTTONS_CLOSE, GTK_BUTTONS_CANCEL,
-    GTK_BUTTONS_YES_NO, GTK_BUTTONS_OK_CANCEL
-  PGtkMessageDialog* = ptr TGtkMessageDialog
-  TGtkMessageDialog* = object of TGtkDialog
-    image*: PGtkWidget
-    label*: PGtkWidget
-
-  PGtkMessageDialogClass* = ptr TGtkMessageDialogClass
-  TGtkMessageDialogClass* = object of TGtkDialogClass
-    gtk_reserved521: proc (){.cdecl.}
-    gtk_reserved522: proc (){.cdecl.}
-    gtk_reserved523: proc (){.cdecl.}
-    gtk_reserved524: proc (){.cdecl.}
-
-  PGtkNotebookPage* = pointer
-  PGtkNotebookTab* = ptr TGtkNotebookTab
-  TGtkNotebookTab* = enum
-    GTK_NOTEBOOK_TAB_FIRST, GTK_NOTEBOOK_TAB_LAST
-  PGtkNotebook* = ptr TGtkNotebook
-  TGtkNotebook* = object of TGtkContainer
-    cur_page*: PGtkNotebookPage
-    children*: PGList
-    first_tab*: PGList
-    focus_tab*: PGList
-    menu*: PGtkWidget
-    event_window*: PGdkWindow
-    timer*: guint32
-    tab_hborder*: guint16
-    tab_vborder*: guint16
-    GtkNotebook_flag0*: guint16
-
-  PGtkNotebookClass* = ptr TGtkNotebookClass
-  TGtkNotebookClass* = object of TGtkContainerClass
-    switch_page*: proc (notebook: PGtkNotebook, page: PGtkNotebookPage,
-                        page_num: guint){.cdecl.}
-    select_page*: proc (notebook: PGtkNotebook, move_focus: gboolean): gboolean{.
-        cdecl.}
-    focus_tab*: proc (notebook: PGtkNotebook, thetype: TGtkNotebookTab): gboolean{.
-        cdecl.}
-    change_current_page*: proc (notebook: PGtkNotebook, offset: gint){.cdecl.}
-    move_focus_out*: proc (notebook: PGtkNotebook, direction: TGtkDirectionType){.
-        cdecl.}
-    gtk_reserved531: proc (){.cdecl.}
-    gtk_reserved532: proc (){.cdecl.}
-    gtk_reserved533: proc (){.cdecl.}
-    gtk_reserved534: proc (){.cdecl.}
-
-  PGtkOldEditable* = ptr TGtkOldEditable
-  TGtkOldEditable* = object of TGtkWidget
-    current_pos*: guint
-    selection_start_pos*: guint
-    selection_end_pos*: guint
-    GtkOldEditable_flag0*: guint16
-    clipboard_text*: cstring
-
-  TGtkTextFunction* = proc (editable: PGtkOldEditable, time: guint32){.cdecl.}
-  PGtkOldEditableClass* = ptr TGtkOldEditableClass
-  TGtkOldEditableClass* = object of TGtkWidgetClass
-    activate*: proc (editable: PGtkOldEditable){.cdecl.}
-    set_editable*: proc (editable: PGtkOldEditable, is_editable: gboolean){.
-        cdecl.}
-    move_cursor*: proc (editable: PGtkOldEditable, x: gint, y: gint){.cdecl.}
-    move_word*: proc (editable: PGtkOldEditable, n: gint){.cdecl.}
-    move_page*: proc (editable: PGtkOldEditable, x: gint, y: gint){.cdecl.}
-    move_to_row*: proc (editable: PGtkOldEditable, row: gint){.cdecl.}
-    move_to_column*: proc (editable: PGtkOldEditable, row: gint){.cdecl.}
-    kill_char*: proc (editable: PGtkOldEditable, direction: gint){.cdecl.}
-    kill_word*: proc (editable: PGtkOldEditable, direction: gint){.cdecl.}
-    kill_line*: proc (editable: PGtkOldEditable, direction: gint){.cdecl.}
-    cut_clipboard*: proc (editable: PGtkOldEditable){.cdecl.}
-    copy_clipboard*: proc (editable: PGtkOldEditable){.cdecl.}
-    paste_clipboard*: proc (editable: PGtkOldEditable){.cdecl.}
-    update_text*: proc (editable: PGtkOldEditable, start_pos: gint,
-                        end_pos: gint){.cdecl.}
-    get_chars*: proc (editable: PGtkOldEditable, start_pos: gint, end_pos: gint): cstring{.
-        cdecl.}
-    set_selection*: proc (editable: PGtkOldEditable, start_pos: gint,
-                          end_pos: gint){.cdecl.}
-    set_position*: proc (editable: PGtkOldEditable, position: gint){.cdecl.}
-
-  PGtkOptionMenu* = ptr TGtkOptionMenu
-  TGtkOptionMenu* = object of TGtkButton
-    menu*: PGtkWidget
-    menu_item*: PGtkWidget
-    width*: guint16
-    height*: guint16
-
-  PGtkOptionMenuClass* = ptr TGtkOptionMenuClass
-  TGtkOptionMenuClass* = object of TGtkButtonClass
-    changed*: proc (option_menu: PGtkOptionMenu){.cdecl.}
-    gtk_reserved541: proc (){.cdecl.}
-    gtk_reserved542: proc (){.cdecl.}
-    gtk_reserved543: proc (){.cdecl.}
-    gtk_reserved544: proc (){.cdecl.}
-
-  PGtkPixmap* = ptr TGtkPixmap
-  TGtkPixmap* = object of TGtkMisc
-    pixmap*: PGdkPixmap
-    mask*: PGdkBitmap
-    pixmap_insensitive*: PGdkPixmap
-    GtkPixmap_flag0*: guint16
-
-  PGtkPixmapClass* = ptr TGtkPixmapClass
-  TGtkPixmapClass* = object of TGtkMiscClass
-
-  PGtkPlug* = ptr TGtkPlug
-  TGtkPlug* = object of TGtkWindow
-    socket_window*: PGdkWindow
-    modality_window*: PGtkWidget
-    modality_group*: PGtkWindowGroup
-    grabbed_keys*: PGHashTable
-    GtkPlug_flag0*: guint16
-
-  PGtkPlugClass* = ptr TGtkPlugClass
-  TGtkPlugClass* = object of TGtkWindowClass
-    embedded*: proc (plug: PGtkPlug){.cdecl.}
-    gtk_reserved551: proc (){.cdecl.}
-    gtk_reserved552: proc (){.cdecl.}
-    gtk_reserved553: proc (){.cdecl.}
-    gtk_reserved554: proc (){.cdecl.}
-
-  PGtkPreview* = ptr TGtkPreview
-  TGtkPreview* = object of TGtkWidget
-    buffer*: Pguchar
-    buffer_width*: guint16
-    buffer_height*: guint16
-    bpp*: guint16
-    rowstride*: guint16
-    dither*: TGdkRgbDither
-    GtkPreview_flag0*: guint16
-
-  PGtkPreviewInfo* = ptr TGtkPreviewInfo
-  TGtkPreviewInfo* {.final, pure.} = object
-    lookup*: Pguchar
-    gamma*: gdouble
-
-  PGtkDitherInfo* = ptr TGtkDitherInfo
-  TGtkDitherInfo* {.final, pure.} = object
-    c*: array[0..3, guchar]
-
-  PGtkPreviewClass* = ptr TGtkPreviewClass
-  TGtkPreviewClass* = object of TGtkWidgetClass
-    info*: TGtkPreviewInfo
-
-  PGtkProgress* = ptr TGtkProgress
-  TGtkProgress* = object of TGtkWidget
-    adjustment*: PGtkAdjustment
-    offscreen_pixmap*: PGdkPixmap
-    format*: cstring
-    x_align*: gfloat
-    y_align*: gfloat
-    GtkProgress_flag0*: guint16
-
-  PGtkProgressClass* = ptr TGtkProgressClass
-  TGtkProgressClass* = object of TGtkWidgetClass
-    paint*: proc (progress: PGtkProgress){.cdecl.}
-    update*: proc (progress: PGtkProgress){.cdecl.}
-    act_mode_enter*: proc (progress: PGtkProgress){.cdecl.}
-    gtk_reserved561: proc (){.cdecl.}
-    gtk_reserved562: proc (){.cdecl.}
-    gtk_reserved563: proc (){.cdecl.}
-    gtk_reserved564: proc (){.cdecl.}
-
-  PGtkProgressBarStyle* = ptr TGtkProgressBarStyle
-  TGtkProgressBarStyle* = enum
-    GTK_PROGRESS_CONTINUOUS, GTK_PROGRESS_DISCRETE
-  PGtkProgressBarOrientation* = ptr TGtkProgressBarOrientation
-  TGtkProgressBarOrientation* = enum
-    GTK_PROGRESS_LEFT_TO_RIGHT, GTK_PROGRESS_RIGHT_TO_LEFT,
-    GTK_PROGRESS_BOTTOM_TO_TOP, GTK_PROGRESS_TOP_TO_BOTTOM
-  PGtkProgressBar* = ptr TGtkProgressBar
-  TGtkProgressBar* = object of TGtkProgress
-    bar_style*: TGtkProgressBarStyle
-    orientation*: TGtkProgressBarOrientation
-    blocks*: guint
-    in_block*: gint
-    activity_pos*: gint
-    activity_step*: guint
-    activity_blocks*: guint
-    pulse_fraction*: gdouble
-    GtkProgressBar_flag0*: guint16
-
-  PGtkProgressBarClass* = ptr TGtkProgressBarClass
-  TGtkProgressBarClass* = object of TGtkProgressClass
-    gtk_reserved571: proc (){.cdecl.}
-    gtk_reserved572: proc (){.cdecl.}
-    gtk_reserved573: proc (){.cdecl.}
-    gtk_reserved574: proc (){.cdecl.}
-
-  PGtkRadioButton* = ptr TGtkRadioButton
-  TGtkRadioButton* = object of TGtkCheckButton
-    group*: PGSList
-
-  PGtkRadioButtonClass* = ptr TGtkRadioButtonClass
-  TGtkRadioButtonClass* = object of TGtkCheckButtonClass
-    gtk_reserved581: proc (){.cdecl.}
-    gtk_reserved582: proc (){.cdecl.}
-    gtk_reserved583: proc (){.cdecl.}
-    gtk_reserved584: proc (){.cdecl.}
-
-  PGtkRadioMenuItem* = ptr TGtkRadioMenuItem
-  TGtkRadioMenuItem* = object of TGtkCheckMenuItem
-    group*: PGSList
-
-  PGtkRadioMenuItemClass* = ptr TGtkRadioMenuItemClass
-  TGtkRadioMenuItemClass* = object of TGtkCheckMenuItemClass
-    gtk_reserved591: proc (){.cdecl.}
-    gtk_reserved592: proc (){.cdecl.}
-    gtk_reserved593: proc (){.cdecl.}
-    gtk_reserved594: proc (){.cdecl.}
-
-  PGtkScrolledWindow* = ptr TGtkScrolledWindow
-  TGtkScrolledWindow* = object of TGtkBin
-    hscrollbar*: PGtkWidget
-    vscrollbar*: PGtkWidget
-    GtkScrolledWindow_flag0*: guint16
-    shadow_type*: guint16
-
-  PGtkScrolledWindowClass* = ptr TGtkScrolledWindowClass
-  TGtkScrolledWindowClass* = object of TGtkBinClass
-    scrollbar_spacing*: gint
-    scroll_child*: proc (scrolled_window: PGtkScrolledWindow,
-                         scroll: TGtkScrollType, horizontal: gboolean){.cdecl.}
-    move_focus_out*: proc (scrolled_window: PGtkScrolledWindow,
-                           direction: TGtkDirectionType){.cdecl.}
-    gtk_reserved601: proc (){.cdecl.}
-    gtk_reserved602: proc (){.cdecl.}
-    gtk_reserved603: proc (){.cdecl.}
-    gtk_reserved604: proc (){.cdecl.}
-
-  TGtkSelectionData* {.final, pure.} = object
-    selection*: TGdkAtom
-    target*: TGdkAtom
-    thetype*: TGdkAtom
-    format*: gint
-    data*: Pguchar
-    length*: gint
-    display*: PGdkDisplay
-
-  PGtkTargetEntry* = ptr TGtkTargetEntry
-  TGtkTargetEntry* {.final, pure.} = object
-    target*: cstring
-    flags*: guint
-    info*: guint
-
-  PGtkTargetList* = ptr TGtkTargetList
-  TGtkTargetList* {.final, pure.} = object
-    list*: PGList
-    ref_count*: guint
-
-  PGtkTargetPair* = ptr TGtkTargetPair
-  TGtkTargetPair* {.final, pure.} = object
-    target*: TGdkAtom
-    flags*: guint
-    info*: guint
-
-  PGtkSeparatorMenuItem* = ptr TGtkSeparatorMenuItem
-  TGtkSeparatorMenuItem* = object of TGtkMenuItem
-
-  PGtkSeparatorMenuItemClass* = ptr TGtkSeparatorMenuItemClass
-  TGtkSeparatorMenuItemClass* = object of TGtkMenuItemClass
-
-  PGtkSizeGroup* = ptr TGtkSizeGroup
-  TGtkSizeGroup* = object of TGObject
-    widgets*: PGSList
-    mode*: guint8
-    GtkSizeGroup_flag0*: guint16
-    requisition*: TGtkRequisition
-
-  PGtkSizeGroupClass* = ptr TGtkSizeGroupClass
-  TGtkSizeGroupClass* = object of TGObjectClass
-    gtk_reserved611: proc (){.cdecl.}
-    gtk_reserved612: proc (){.cdecl.}
-    gtk_reserved613: proc (){.cdecl.}
-    gtk_reserved614: proc (){.cdecl.}
-
-  PGtkSizeGroupMode* = ptr TGtkSizeGroupMode
-  TGtkSizeGroupMode* = enum
-    GTK_SIZE_GROUP_NONE, GTK_SIZE_GROUP_HORIZONTAL, GTK_SIZE_GROUP_VERTICAL,
-    GTK_SIZE_GROUP_BOTH
-  PGtkSocket* = ptr TGtkSocket
-  TGtkSocket* = object of TGtkContainer
-    request_width*: guint16
-    request_height*: guint16
-    current_width*: guint16
-    current_height*: guint16
-    plug_window*: PGdkWindow
-    plug_widget*: PGtkWidget
-    xembed_version*: gshort
-    GtkSocket_flag0*: guint16
-    accel_group*: PGtkAccelGroup
-    toplevel*: PGtkWidget
-
-  PGtkSocketClass* = ptr TGtkSocketClass
-  TGtkSocketClass* = object of TGtkContainerClass
-    plug_added*: proc (socket: PGtkSocket){.cdecl.}
-    plug_removed*: proc (socket: PGtkSocket): gboolean{.cdecl.}
-    gtk_reserved621: proc (){.cdecl.}
-    gtk_reserved622: proc (){.cdecl.}
-    gtk_reserved623: proc (){.cdecl.}
-    gtk_reserved624: proc (){.cdecl.}
-
-  PGtkSpinButtonUpdatePolicy* = ptr TGtkSpinButtonUpdatePolicy
-  TGtkSpinButtonUpdatePolicy* = enum
-    GTK_UPDATE_ALWAYS, GTK_UPDATE_IF_VALID
-  PGtkSpinType* = ptr TGtkSpinType
-  TGtkSpinType* = enum
-    GTK_SPIN_STEP_FORWARD, GTK_SPIN_STEP_BACKWARD, GTK_SPIN_PAGE_FORWARD,
-    GTK_SPIN_PAGE_BACKWARD, GTK_SPIN_HOME, GTK_SPIN_END, GTK_SPIN_USER_DEFINED
-  PGtkSpinButton* = ptr TGtkSpinButton
-  TGtkSpinButton* = object of TGtkEntry
-    adjustment*: PGtkAdjustment
-    panel*: PGdkWindow
-    timer*: guint32
-    climb_rate*: gdouble
-    timer_step*: gdouble
-    update_policy*: TGtkSpinButtonUpdatePolicy
-    GtkSpinButton_flag0*: int32
-
-  PGtkSpinButtonClass* = ptr TGtkSpinButtonClass
-  TGtkSpinButtonClass* = object of TGtkEntryClass
-    input*: proc (spin_button: PGtkSpinButton, new_value: Pgdouble): gint{.cdecl.}
-    output*: proc (spin_button: PGtkSpinButton): gint{.cdecl.}
-    value_changed*: proc (spin_button: PGtkSpinButton){.cdecl.}
-    change_value*: proc (spin_button: PGtkSpinButton, scroll: TGtkScrollType){.
-        cdecl.}
-    gtk_reserved631: proc (){.cdecl.}
-    gtk_reserved632: proc (){.cdecl.}
-    gtk_reserved633: proc (){.cdecl.}
-    gtk_reserved634: proc (){.cdecl.}
-
-  PGtkStockItem* = ptr TGtkStockItem
-  TGtkStockItem* {.final, pure.} = object
-    stock_id*: cstring
-    label*: cstring
-    modifier*: TGdkModifierType
-    keyval*: guint
-    translation_domain*: cstring
-
-  PGtkStatusbar* = ptr TGtkStatusbar
-  TGtkStatusbar* = object of TGtkHBox
-    frame*: PGtkWidget
-    `label`*: PGtkWidget
-    messages*: PGSList
-    keys*: PGSList
-    seq_context_id*: guint
-    seq_message_id*: guint
-    grip_window*: PGdkWindow
-    GtkStatusbar_flag0*: guint16
-
-  PGtkStatusbarClass* = ptr TGtkStatusbarClass
-  TGtkStatusbarClass* = object of TGtkHBoxClass
-    messages_mem_chunk*: PGMemChunk
-    text_pushed*: proc (statusbar: PGtkStatusbar, context_id: guint,
-                        text: cstring){.cdecl.}
-    text_popped*: proc (statusbar: PGtkStatusbar, context_id: guint,
-                        text: cstring){.cdecl.}
-    gtk_reserved641: proc (){.cdecl.}
-    gtk_reserved642: proc (){.cdecl.}
-    gtk_reserved643: proc (){.cdecl.}
-    gtk_reserved644: proc (){.cdecl.}
-
-  PGtkTableRowCol* = ptr TGtkTableRowCol
-  PGtkTable* = ptr TGtkTable
-  TGtkTable* = object of TGtkContainer
-    children*: PGList
-    rows*: PGtkTableRowCol
-    cols*: PGtkTableRowCol
-    nrows*: guint16
-    ncols*: guint16
-    column_spacing*: guint16
-    row_spacing*: guint16
-    GtkTable_flag0*: guint16
-
-  PGtkTableClass* = ptr TGtkTableClass
-  TGtkTableClass* = object of TGtkContainerClass
-
-  PGtkTableChild* = ptr TGtkTableChild
-  TGtkTableChild* {.final, pure.} = object
-    widget*: PGtkWidget
-    left_attach*: guint16
-    right_attach*: guint16
-    top_attach*: guint16
-    bottom_attach*: guint16
-    xpadding*: guint16
-    ypadding*: guint16
-    GtkTableChild_flag0*: guint16
-
-  TGtkTableRowCol* {.final, pure.} = object
-    requisition*: guint16
-    allocation*: guint16
-    spacing*: guint16
-    flag0*: guint16
-
-  PGtkTearoffMenuItem* = ptr TGtkTearoffMenuItem
-  TGtkTearoffMenuItem* = object of TGtkMenuItem
-    GtkTearoffMenuItem_flag0*: guint16
-
-  PGtkTearoffMenuItemClass* = ptr TGtkTearoffMenuItemClass
-  TGtkTearoffMenuItemClass* = object of TGtkMenuItemClass
-    gtk_reserved651: proc (){.cdecl.}
-    gtk_reserved652: proc (){.cdecl.}
-    gtk_reserved653: proc (){.cdecl.}
-    gtk_reserved654: proc (){.cdecl.}
-
-  PGtkTextFont* = pointer
-  PGtkPropertyMark* = ptr TGtkPropertyMark
-  TGtkPropertyMark* {.final, pure.} = object
-    `property`*: PGList
-    offset*: guint
-    index*: guint
-
-  PGtkText* = ptr TGtkText
-  TGtkText* = object of TGtkOldEditable
-    text_area*: PGdkWindow
-    hadj*: PGtkAdjustment
-    vadj*: PGtkAdjustment
-    gc*: PGdkGC
-    line_wrap_bitmap*: PGdkPixmap
-    line_arrow_bitmap*: PGdkPixmap
-    text*: Pguchar
-    text_len*: guint
-    gap_position*: guint
-    gap_size*: guint
-    text_end*: guint
-    line_start_cache*: PGList
-    first_line_start_index*: guint
-    first_cut_pixels*: guint
-    first_onscreen_hor_pixel*: guint
-    first_onscreen_ver_pixel*: guint
-    GtkText_flag0*: guint16
-    freeze_count*: guint
-    text_properties*: PGList
-    text_properties_end*: PGList
-    point*: TGtkPropertyMark
-    scratch_buffer*: Pguchar
-    scratch_buffer_len*: guint
-    last_ver_value*: gint
-    cursor_pos_x*: gint
-    cursor_pos_y*: gint
-    cursor_mark*: TGtkPropertyMark
-    cursor_char*: TGdkWChar
-    cursor_char_offset*: gchar
-    cursor_virtual_x*: gint
-    cursor_drawn_level*: gint
-    current_line*: PGList
-    tab_stops*: PGList
-    default_tab_width*: gint
-    current_font*: PGtkTextFont
-    timer*: gint
-    button*: guint
-    bg_gc*: PGdkGC
-
-  PGtkTextClass* = ptr TGtkTextClass
-  TGtkTextClass* = object of TGtkOldEditableClass
-    set_scroll_adjustments*: proc (text: PGtkText, hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-
-  PGtkTextSearchFlags* = ptr TGtkTextSearchFlags
-  TGtkTextSearchFlags* = int32
-  PGtkTextIter* = ptr TGtkTextIter
-  TGtkTextIter* {.final, pure.} = object
-    dummy1*: gpointer
-    dummy2*: gpointer
-    dummy3*: gint
-    dummy4*: gint
-    dummy5*: gint
-    dummy6*: gint
-    dummy7*: gint
-    dummy8*: gint
-    dummy9*: gpointer
-    dummy10*: gpointer
-    dummy11*: gint
-    dummy12*: gint
-    dummy13*: gint
-    dummy14*: gpointer
-
-  TGtkTextCharPredicate* = proc (ch: gunichar, user_data: gpointer): gboolean{.
-      cdecl.}
-  PGtkTextTagClass* = ptr TGtkTextTagClass
-  PGtkTextAttributes* = ptr TGtkTextAttributes
-  PGtkTextTag* = ptr TGtkTextTag
-  PPGtkTextTag* = ptr PGtkTextTag
-  TGtkTextTag* = object of TGObject
-    table*: PGtkTextTagTable
-    name*: cstring
-    priority*: int32
-    values*: PGtkTextAttributes
-    GtkTextTag_flag0*: int32
-
-  TGtkTextTagClass* = object of TGObjectClass
-    event*: proc (tag: PGtkTextTag, event_object: PGObject, event: PGdkEvent,
-                  iter: PGtkTextIter): gboolean{.cdecl.}
-    gtk_reserved661: proc (){.cdecl.}
-    gtk_reserved662: proc (){.cdecl.}
-    gtk_reserved663: proc (){.cdecl.}
-    gtk_reserved664: proc (){.cdecl.}
-
-  PGtkTextAppearance* = ptr TGtkTextAppearance
-  TGtkTextAppearance* {.final, pure.} = object
-    bg_color*: TGdkColor
-    fg_color*: TGdkColor
-    bg_stipple*: PGdkBitmap
-    fg_stipple*: PGdkBitmap
-    rise*: gint
-    padding1*: gpointer
-    flag0*: guint16
-
-  TGtkTextAttributes* {.final, pure.} = object
-    refcount*: guint
-    appearance*: TGtkTextAppearance
-    justification*: TGtkJustification
-    direction*: TGtkTextDirection
-    font*: PPangoFontDescription
-    font_scale*: gdouble
-    left_margin*: gint
-    indent*: gint
-    right_margin*: gint
-    pixels_above_lines*: gint
-    pixels_below_lines*: gint
-    pixels_inside_wrap*: gint
-    tabs*: PPangoTabArray
-    wrap_mode*: TGtkWrapMode
-    language*: PPangoLanguage
-    padding1*: gpointer
-    flag0*: guint16
-
-  TGtkTextTagTableForeach* = proc (tag: PGtkTextTag, data: gpointer){.cdecl.}
-  TGtkTextTagTable* = object of TGObject
-    hash*: PGHashTable
-    anonymous*: PGSList
-    anon_count*: gint
-    buffers*: PGSList
-
-  PGtkTextTagTableClass* = ptr TGtkTextTagTableClass
-  TGtkTextTagTableClass* = object of TGObjectClass
-    tag_changed*: proc (table: PGtkTextTagTable, tag: PGtkTextTag,
-                        size_changed: gboolean){.cdecl.}
-    tag_added*: proc (table: PGtkTextTagTable, tag: PGtkTextTag){.cdecl.}
-    tag_removed*: proc (table: PGtkTextTagTable, tag: PGtkTextTag){.cdecl.}
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkTextMark* = ptr TGtkTextMark
-  TGtkTextMark* = object of TGObject
-    segment*: gpointer
-
-  PGtkTextMarkClass* = ptr TGtkTextMarkClass
-  TGtkTextMarkClass* = object of TGObjectClass
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkTextMarkBody* = ptr TGtkTextMarkBody
-  TGtkTextMarkBody* {.final, pure.} = object
-    obj*: PGtkTextMark
-    name*: cstring
-    tree*: PGtkTextBTree
-    line*: PGtkTextLine
-    flag0*: guint16
-
-  PGtkTextChildAnchor* = ptr TGtkTextChildAnchor
-  TGtkTextChildAnchor* = object of TGObject
-    segment*: gpointer
-
-  PGtkTextChildAnchorClass* = ptr TGtkTextChildAnchorClass
-  TGtkTextChildAnchorClass* = object of TGObjectClass
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkTextPixbuf* = ptr TGtkTextPixbuf
-  TGtkTextPixbuf* {.final, pure.} = object
-    pixbuf*: PGdkPixbuf
-
-  PGtkTextChildBody* = ptr TGtkTextChildBody
-  TGtkTextChildBody* {.final, pure.} = object
-    obj*: PGtkTextChildAnchor
-    widgets*: PGSList
-    tree*: PGtkTextBTree
-    line*: PGtkTextLine
-
-  PGtkTextLineSegment* = ptr TGtkTextLineSegment
-  PGtkTextLineSegmentClass* = ptr TGtkTextLineSegmentClass
-  PGtkTextTagInfo* = ptr TGtkTextTagInfo
-  TGtkTextTagInfo* {.final, pure.} = object
-    tag*: PGtkTextTag
-    tag_root*: PGtkTextBTreeNode
-    toggle_count*: gint
-
-  PGtkTextToggleBody* = ptr TGtkTextToggleBody
-  TGtkTextToggleBody* {.final, pure.} = object
-    info*: PGtkTextTagInfo
-    inNodeCounts*: gboolean
-
-  TGtkTextLineSegment* {.final, pure.} = object
-    `type`*: PGtkTextLineSegmentClass
-    next*: PGtkTextLineSegment
-    char_count*: int32
-    byte_count*: int32
-    body*: TGtkTextChildBody
-
-  PGtkTextSegSplitFunc* = ptr TGtkTextSegSplitFunc
-  TGtkTextSegSplitFunc* = TGtkTextLineSegment
-  TGtkTextSegDeleteFunc* = proc (seg: PGtkTextLineSegment, line: PGtkTextLine,
-                                 tree_gone: gboolean): gboolean{.cdecl.}
-  PGtkTextSegCleanupFunc* = ptr TGtkTextSegCleanupFunc
-  TGtkTextSegCleanupFunc* = TGtkTextLineSegment
-  TGtkTextSegLineChangeFunc* = proc (seg: PGtkTextLineSegment,
-                                     line: PGtkTextLine){.cdecl.}
-  TGtkTextSegCheckFunc* = proc (seg: PGtkTextLineSegment, line: PGtkTextLine){.
-      cdecl.}
-  TGtkTextLineSegmentClass* {.final, pure.} = object
-    name*: cstring
-    leftGravity*: gboolean
-    splitFunc*: TGtkTextSegSplitFunc
-    deleteFunc*: TGtkTextSegDeleteFunc
-    cleanupFunc*: TGtkTextSegCleanupFunc
-    lineChangeFunc*: TGtkTextSegLineChangeFunc
-    checkFunc*: TGtkTextSegCheckFunc
-
-  PGtkTextLineData* = ptr TGtkTextLineData
-  TGtkTextLineData* {.final, pure.} = object
-    view_id*: gpointer
-    next*: PGtkTextLineData
-    height*: gint
-    flag0*: int32
-
-  TGtkTextLine* {.final, pure.} = object
-    parent*: PGtkTextBTreeNode
-    next*: PGtkTextLine
-    segments*: PGtkTextLineSegment
-    views*: PGtkTextLineData
-
-  PGtkTextLogAttrCache* = pointer
-  PGtkTextBuffer* = ptr TGtkTextBuffer
-  TGtkTextBuffer* = object of TGObject
-    tag_table*: PGtkTextTagTable
-    btree*: PGtkTextBTree
-    clipboard_contents_buffers*: PGSList
-    selection_clipboards*: PGSList
-    log_attr_cache*: PGtkTextLogAttrCache
-    user_action_count*: guint
-    GtkTextBuffer_flag0*: guint16
-
-  PGtkTextBufferClass* = ptr TGtkTextBufferClass
-  TGtkTextBufferClass* = object of TGObjectClass
-    insert_text*: proc (buffer: PGtkTextBuffer, pos: PGtkTextIter, text: cstring,
-                        length: gint){.cdecl.}
-    insert_pixbuf*: proc (buffer: PGtkTextBuffer, pos: PGtkTextIter,
-                          pixbuf: PGdkPixbuf){.cdecl.}
-    insert_child_anchor*: proc (buffer: PGtkTextBuffer, pos: PGtkTextIter,
-                                anchor: PGtkTextChildAnchor){.cdecl.}
-    delete_range*: proc (buffer: PGtkTextBuffer, start: PGtkTextIter,
-                         theEnd: PGtkTextIter){.cdecl.}
-    changed*: proc (buffer: PGtkTextBuffer){.cdecl.}
-    modified_changed*: proc (buffer: PGtkTextBuffer){.cdecl.}
-    mark_set*: proc (buffer: PGtkTextBuffer, location: PGtkTextIter,
-                     mark: PGtkTextMark){.cdecl.}
-    mark_deleted*: proc (buffer: PGtkTextBuffer, mark: PGtkTextMark){.cdecl.}
-    apply_tag*: proc (buffer: PGtkTextBuffer, tag: PGtkTextTag,
-                      start_char: PGtkTextIter, end_char: PGtkTextIter){.cdecl.}
-    remove_tag*: proc (buffer: PGtkTextBuffer, tag: PGtkTextTag,
-                       start_char: PGtkTextIter, end_char: PGtkTextIter){.cdecl.}
-    begin_user_action*: proc (buffer: PGtkTextBuffer){.cdecl.}
-    end_user_action*: proc (buffer: PGtkTextBuffer){.cdecl.}
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-    gtk_reserved5: proc (){.cdecl.}
-    gtk_reserved6: proc (){.cdecl.}
-
-  PGtkTextLineDisplay* = ptr TGtkTextLineDisplay
-  PGtkTextLayout* = ptr TGtkTextLayout
-  TGtkTextLayout* = object of TGObject
-    screen_width*: gint
-    width*: gint
-    height*: gint
-    buffer*: PGtkTextBuffer
-    default_style*: PGtkTextAttributes
-    ltr_context*: PPangoContext
-    rtl_context*: PPangoContext
-    one_style_cache*: PGtkTextAttributes
-    one_display_cache*: PGtkTextLineDisplay
-    wrap_loop_count*: gint
-    GtkTextLayout_flag0*: guint16
-    preedit_string*: cstring
-    preedit_attrs*: PPangoAttrList
-    preedit_len*: gint
-    preedit_cursor*: gint
-
-  PGtkTextLayoutClass* = ptr TGtkTextLayoutClass
-  TGtkTextLayoutClass* = object of TGObjectClass
-    invalidated*: proc (layout: PGtkTextLayout){.cdecl.}
-    changed*: proc (layout: PGtkTextLayout, y: gint, old_height: gint,
-                    new_height: gint){.cdecl.}
-    wrap*: proc (layout: PGtkTextLayout, line: PGtkTextLine,
-                 line_data: PGtkTextLineData): PGtkTextLineData{.cdecl.}
-    get_log_attrs*: proc (layout: PGtkTextLayout, line: PGtkTextLine,
-                          attrs: var PPangoLogAttr, n_attrs: Pgint){.cdecl.}
-    invalidate*: proc (layout: PGtkTextLayout, start: PGtkTextIter,
-                       theEnd: PGtkTextIter){.cdecl.}
-    free_line_data*: proc (layout: PGtkTextLayout, line: PGtkTextLine,
-                           line_data: PGtkTextLineData){.cdecl.}
-    allocate_child*: proc (layout: PGtkTextLayout, child: PGtkWidget, x: gint,
-                           y: gint){.cdecl.}
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkTextAttrAppearance* = ptr TGtkTextAttrAppearance
-  TGtkTextAttrAppearance* {.final, pure.} = object
-    attr*: TPangoAttribute
-    appearance*: TGtkTextAppearance
-
-  PGtkTextCursorDisplay* = ptr TGtkTextCursorDisplay
-  TGtkTextCursorDisplay* {.final, pure.} = object
-    x*: gint
-    y*: gint
-    height*: gint
-    flag0*: guint16
-
-  TGtkTextLineDisplay* {.final, pure.} = object
-    layout*: PPangoLayout
-    cursors*: PGSList
-    shaped_objects*: PGSList
-    direction*: TGtkTextDirection
-    width*: gint
-    total_width*: gint
-    height*: gint
-    x_offset*: gint
-    left_margin*: gint
-    right_margin*: gint
-    top_margin*: gint
-    bottom_margin*: gint
-    insert_index*: gint
-    size_only*: gboolean
-    line*: PGtkTextLine
-
-  PGtkTextWindow* = pointer
-  PGtkTextPendingScroll* = pointer
-  PGtkTextWindowType* = ptr TGtkTextWindowType
-  TGtkTextWindowType* = enum
-    GTK_TEXT_WINDOW_PRIVATE, GTK_TEXT_WINDOW_WIDGET, GTK_TEXT_WINDOW_TEXT,
-    GTK_TEXT_WINDOW_LEFT, GTK_TEXT_WINDOW_RIGHT, GTK_TEXT_WINDOW_TOP,
-    GTK_TEXT_WINDOW_BOTTOM
-  PGtkTextView* = ptr TGtkTextView
-  TGtkTextView* = object of TGtkContainer
-    layout*: PGtkTextLayout
-    buffer*: PGtkTextBuffer
-    selection_drag_handler*: guint
-    scroll_timeout*: guint
-    pixels_above_lines*: gint
-    pixels_below_lines*: gint
-    pixels_inside_wrap*: gint
-    wrap_mode*: TGtkWrapMode
-    justify*: TGtkJustification
-    left_margin*: gint
-    right_margin*: gint
-    indent*: gint
-    tabs*: PPangoTabArray
-    GtkTextView_flag0*: guint16
-    text_window*: PGtkTextWindow
-    left_window*: PGtkTextWindow
-    right_window*: PGtkTextWindow
-    top_window*: PGtkTextWindow
-    bottom_window*: PGtkTextWindow
-    hadjustment*: PGtkAdjustment
-    vadjustment*: PGtkAdjustment
-    xoffset*: gint
-    yoffset*: gint
-    width*: gint
-    height*: gint
-    virtual_cursor_x*: gint
-    virtual_cursor_y*: gint
-    first_para_mark*: PGtkTextMark
-    first_para_pixels*: gint
-    dnd_mark*: PGtkTextMark
-    blink_timeout*: guint
-    first_validate_idle*: guint
-    incremental_validate_idle*: guint
-    im_context*: PGtkIMContext
-    popup_menu*: PGtkWidget
-    drag_start_x*: gint
-    drag_start_y*: gint
-    children*: PGSList
-    pending_scroll*: PGtkTextPendingScroll
-    pending_place_cursor_button*: gint
-
-  PGtkTextViewClass* = ptr TGtkTextViewClass
-  TGtkTextViewClass* = object of TGtkContainerClass
-    set_scroll_adjustments*: proc (text_view: PGtkTextView,
-                                   hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-    populate_popup*: proc (text_view: PGtkTextView, menu: PGtkMenu){.cdecl.}
-    move_cursor*: proc (text_view: PGtkTextView, step: TGtkMovementStep,
-                        count: gint, extend_selection: gboolean){.cdecl.}
-    page_horizontally*: proc (text_view: PGtkTextView, count: gint,
-                              extend_selection: gboolean){.cdecl.}
-    set_anchor*: proc (text_view: PGtkTextView){.cdecl.}
-    insert_at_cursor*: proc (text_view: PGtkTextView, str: cstring){.cdecl.}
-    delete_from_cursor*: proc (text_view: PGtkTextView, thetype: TGtkDeleteType,
-                               count: gint){.cdecl.}
-    cut_clipboard*: proc (text_view: PGtkTextView){.cdecl.}
-    copy_clipboard*: proc (text_view: PGtkTextView){.cdecl.}
-    paste_clipboard*: proc (text_view: PGtkTextView){.cdecl.}
-    toggle_overwrite*: proc (text_view: PGtkTextView){.cdecl.}
-    move_focus*: proc (text_view: PGtkTextView, direction: TGtkDirectionType){.
-        cdecl.}
-    gtk_reserved711: proc (){.cdecl.}
-    gtk_reserved712: proc (){.cdecl.}
-    gtk_reserved713: proc (){.cdecl.}
-    gtk_reserved714: proc (){.cdecl.}
-    gtk_reserved715: proc (){.cdecl.}
-    gtk_reserved716: proc (){.cdecl.}
-    gtk_reserved717: proc (){.cdecl.}
-    gtk_reserved718: proc (){.cdecl.}
-
-  PGtkTipsQuery* = ptr TGtkTipsQuery
-  TGtkTipsQuery* = object of TGtkLabel
-    GtkTipsQuery_flag0*: guint16
-    label_inactive*: cstring
-    label_no_tip*: cstring
-    caller*: PGtkWidget
-    last_crossed*: PGtkWidget
-    query_cursor*: PGdkCursor
-
-  PGtkTipsQueryClass* = ptr TGtkTipsQueryClass
-  TGtkTipsQueryClass* = object of TGtkLabelClass
-    start_query*: proc (tips_query: PGtkTipsQuery){.cdecl.}
-    stop_query*: proc (tips_query: PGtkTipsQuery){.cdecl.}
-    widget_entered*: proc (tips_query: PGtkTipsQuery, widget: PGtkWidget,
-                           tip_text: cstring, tip_private: cstring){.cdecl.}
-    widget_selected*: proc (tips_query: PGtkTipsQuery, widget: PGtkWidget,
-                            tip_text: cstring, tip_private: cstring,
-                            event: PGdkEventButton): gint{.cdecl.}
-    gtk_reserved721: proc (){.cdecl.}
-    gtk_reserved722: proc (){.cdecl.}
-    gtk_reserved723: proc (){.cdecl.}
-    gtk_reserved724: proc (){.cdecl.}
-
-  PGtkTooltips* = ptr TGtkTooltips
-  PGtkTooltipsData* = ptr TGtkTooltipsData
-  TGtkTooltipsData* {.final, pure.} = object
-    tooltips*: PGtkTooltips
-    widget*: PGtkWidget
-    tip_text*: cstring
-    tip_private*: cstring
-
-  TGtkTooltips* = object of TGtkObject
-    tip_window*: PGtkWidget
-    tip_label*: PGtkWidget
-    active_tips_data*: PGtkTooltipsData
-    tips_data_list*: PGList
-    GtkTooltips_flag0*: int32
-    flag1*: guint16
-    timer_tag*: gint
-    last_popdown*: TGTimeVal
-
-  PGtkTooltipsClass* = ptr TGtkTooltipsClass
-  TGtkTooltipsClass* = object of TGtkObjectClass
-    gtk_reserved1: proc (){.cdecl.}
-    gtk_reserved2: proc (){.cdecl.}
-    gtk_reserved3: proc (){.cdecl.}
-    gtk_reserved4: proc (){.cdecl.}
-
-  PGtkToolbarChildType* = ptr TGtkToolbarChildType
-  TGtkToolbarChildType* = enum
-    GTK_TOOLBAR_CHILD_SPACE, GTK_TOOLBAR_CHILD_BUTTON,
-    GTK_TOOLBAR_CHILD_TOGGLEBUTTON, GTK_TOOLBAR_CHILD_RADIOBUTTON,
-    GTK_TOOLBAR_CHILD_WIDGET
-  PGtkToolbarSpaceStyle* = ptr TGtkToolbarSpaceStyle
-  TGtkToolbarSpaceStyle* = enum
-    GTK_TOOLBAR_SPACE_EMPTY, GTK_TOOLBAR_SPACE_LINE
-  PGtkToolbarChild* = ptr TGtkToolbarChild
-  TGtkToolbarChild* {.final, pure.} = object
-    `type`*: TGtkToolbarChildType
-    widget*: PGtkWidget
-    icon*: PGtkWidget
-    label*: PGtkWidget
-
-  PGtkToolbar* = ptr TGtkToolbar
-  TGtkToolbar* = object of TGtkContainer
-    num_children*: gint
-    children*: PGList
-    orientation*: TGtkOrientation
-    GtkToolbar_style*: TGtkToolbarStyle
-    icon_size*: TGtkIconSize
-    tooltips*: PGtkTooltips
-    button_maxw*: gint
-    button_maxh*: gint
-    style_set_connection*: guint
-    icon_size_connection*: guint
-    GtkToolbar_flag0*: guint16
-
-  PGtkToolbarClass* = ptr TGtkToolbarClass
-  TGtkToolbarClass* = object of TGtkContainerClass
-    orientation_changed*: proc (toolbar: PGtkToolbar,
-                                orientation: TGtkOrientation){.cdecl.}
-    style_changed*: proc (toolbar: PGtkToolbar, style: TGtkToolbarStyle){.cdecl.}
-    gtk_reserved731: proc (){.cdecl.}
-    gtk_reserved732: proc (){.cdecl.}
-    gtk_reserved733: proc (){.cdecl.}
-    gtk_reserved734: proc (){.cdecl.}
-
-  PGtkTreeViewMode* = ptr TGtkTreeViewMode
-  TGtkTreeViewMode* = enum
-    GTK_TREE_VIEW_LINE, GTK_TREE_VIEW_ITEM
-  PGtkTree* = ptr TGtkTree
-  TGtkTree* = object of TGtkContainer
-    children*: PGList
-    root_tree*: PGtkTree
-    tree_owner*: PGtkWidget
-    selection*: PGList
-    level*: guint
-    indent_value*: guint
-    current_indent*: guint
-    GtkTree_flag0*: guint16
-
-  PGtkTreeClass* = ptr TGtkTreeClass
-  TGtkTreeClass* = object of TGtkContainerClass
-    selection_changed*: proc (tree: PGtkTree){.cdecl.}
-    select_child*: proc (tree: PGtkTree, child: PGtkWidget){.cdecl.}
-    unselect_child*: proc (tree: PGtkTree, child: PGtkWidget){.cdecl.}
-
-  PGtkTreeDragSource* = pointer
-  PGtkTreeDragDest* = pointer
-  PGtkTreeDragSourceIface* = ptr TGtkTreeDragSourceIface
-  TGtkTreeDragSourceIface* = object of TGTypeInterface
-    row_draggable*: proc (drag_source: PGtkTreeDragSource, path: PGtkTreePath): gboolean{.
-        cdecl.}
-    drag_data_get*: proc (drag_source: PGtkTreeDragSource, path: PGtkTreePath,
-                          selection_data: PGtkSelectionData): gboolean{.cdecl.}
-    drag_data_delete*: proc (drag_source: PGtkTreeDragSource, path: PGtkTreePath): gboolean{.
-        cdecl.}
-
-  PGtkTreeDragDestIface* = ptr TGtkTreeDragDestIface
-  TGtkTreeDragDestIface* = object of TGTypeInterface
-    drag_data_received*: proc (drag_dest: PGtkTreeDragDest, dest: PGtkTreePath,
-                               selection_data: PGtkSelectionData): gboolean{.
-        cdecl.}
-    row_drop_possible*: proc (drag_dest: PGtkTreeDragDest,
-                              dest_path: PGtkTreePath,
-                              selection_data: PGtkSelectionData): gboolean{.
-        cdecl.}
-
-  PGtkTreeItem* = ptr TGtkTreeItem
-  TGtkTreeItem* = object of TGtkItem
-    subtree*: PGtkWidget
-    pixmaps_box*: PGtkWidget
-    plus_pix_widget*: PGtkWidget
-    minus_pix_widget*: PGtkWidget
-    pixmaps*: PGList
-    GtkTreeItem_flag0*: guint16
-
-  PGtkTreeItemClass* = ptr TGtkTreeItemClass
-  TGtkTreeItemClass* = object of TGtkItemClass
-    expand*: proc (tree_item: PGtkTreeItem){.cdecl.}
-    collapse*: proc (tree_item: PGtkTreeItem){.cdecl.}
-
-  PGtkTreeSelection* = ptr TGtkTreeSelection
-  TGtkTreeSelectionFunc* = proc (selection: PGtkTreeSelection,
-                                 model: PGtkTreeModel, path: PGtkTreePath,
-                                 path_currently_selected: gboolean,
-                                 data: gpointer): gboolean{.cdecl.}
-  TGtkTreeSelectionForeachFunc* = proc (model: PGtkTreeModel,
-                                        path: PGtkTreePath, iter: PGtkTreeIter,
-                                        data: gpointer){.cdecl.}
-  TGtkTreeSelection* = object of TGObject
-    tree_view*: PGtkTreeView
-    thetype*: TGtkSelectionMode
-    user_func*: TGtkTreeSelectionFunc
-    user_data*: gpointer
-    destroy*: TGtkDestroyNotify
-
-  PGtkTreeSelectionClass* = ptr TGtkTreeSelectionClass
-  TGtkTreeSelectionClass* = object of TGObjectClass
-    changed*: proc (selection: PGtkTreeSelection){.cdecl.}
-    gtk_reserved741: proc (){.cdecl.}
-    gtk_reserved742: proc (){.cdecl.}
-    gtk_reserved743: proc (){.cdecl.}
-    gtk_reserved744: proc (){.cdecl.}
-
-  PGtkTreeStore* = ptr TGtkTreeStore
-  TGtkTreeStore* = object of TGObject
-    stamp*: gint
-    root*: gpointer
-    last*: gpointer
-    n_columns*: gint
-    sort_column_id*: gint
-    sort_list*: PGList
-    order*: TGtkSortType
-    column_headers*: PGType
-    default_sort_func*: TGtkTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TGtkDestroyNotify
-    GtkTreeStore_flag0*: guint16
-
-  PGtkTreeStoreClass* = ptr TGtkTreeStoreClass
-  TGtkTreeStoreClass* = object of TGObjectClass
-    gtk_reserved751: proc (){.cdecl.}
-    gtk_reserved752: proc (){.cdecl.}
-    gtk_reserved753: proc (){.cdecl.}
-    gtk_reserved754: proc (){.cdecl.}
-
-  PGtkTreeViewColumnSizing* = ptr TGtkTreeViewColumnSizing
-  TGtkTreeViewColumnSizing* = enum
-    GTK_TREE_VIEW_COLUMN_GROW_ONLY, GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-    GTK_TREE_VIEW_COLUMN_FIXED
-  TGtkTreeCellDataFunc* = proc (tree_column: PGtkTreeViewColumn,
-                                cell: PGtkCellRenderer,
-                                tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                                data: gpointer){.cdecl.}
-  TGtkTreeViewColumn* = object of TGtkObject
-    tree_view*: PGtkWidget
-    button*: PGtkWidget
-    child*: PGtkWidget
-    arrow*: PGtkWidget
-    alignment*: PGtkWidget
-    window*: PGdkWindow
-    editable_widget*: PGtkCellEditable
-    xalign*: gfloat
-    property_changed_signal*: guint
-    spacing*: gint
-    column_type*: TGtkTreeViewColumnSizing
-    requested_width*: gint
-    button_request*: gint
-    resized_width*: gint
-    width*: gint
-    fixed_width*: gint
-    min_width*: gint
-    max_width*: gint
-    drag_x*: gint
-    drag_y*: gint
-    title*: cstring
-    cell_list*: PGList
-    sort_clicked_signal*: guint
-    sort_column_changed_signal*: guint
-    sort_column_id*: gint
-    sort_order*: TGtkSortType
-    GtkTreeViewColumn_flag0*: guint16
-
-  PGtkTreeViewColumnClass* = ptr TGtkTreeViewColumnClass
-  TGtkTreeViewColumnClass* = object of TGtkObjectClass
-    clicked*: proc (tree_column: PGtkTreeViewColumn){.cdecl.}
-    gtk_reserved751: proc (){.cdecl.}
-    gtk_reserved752: proc (){.cdecl.}
-    gtk_reserved753: proc (){.cdecl.}
-    gtk_reserved754: proc (){.cdecl.}
-
-  PGtkRBNodeColor* = ptr TGtkRBNodeColor
-  TGtkRBNodeColor* = int32
-  PGtkRBTree* = ptr TGtkRBTree
-  PGtkRBNode* = ptr TGtkRBNode
-  TGtkRBTreeTraverseFunc* = proc (tree: PGtkRBTree, node: PGtkRBNode,
-                                  data: gpointer){.cdecl.}
-  TGtkRBTree* {.final, pure.} = object
-    root*: PGtkRBNode
-    `nil`*: PGtkRBNode
-    parent_tree*: PGtkRBTree
-    parent_node*: PGtkRBNode
-
-  TGtkRBNode* {.final, pure.} = object
-    flag0*: guint16
-    left*: PGtkRBNode
-    right*: PGtkRBNode
-    parent*: PGtkRBNode
-    count*: gint
-    offset*: gint
-    children*: PGtkRBTree
-
-  PGtkTreeRowReference* = pointer
-  PGtkTreeViewFlags* = ptr TGtkTreeViewFlags
-  TGtkTreeViewFlags* = int32
-  TGtkTreeViewSearchDialogPositionFunc* = proc (tree_view: PGtkTreeView,
-      search_dialog: PGtkWidget){.cdecl.}
-  PGtkTreeViewColumnReorder* = ptr TGtkTreeViewColumnReorder
-  TGtkTreeViewColumnReorder* {.final, pure.} = object
-    left_align*: gint
-    right_align*: gint
-    left_column*: PGtkTreeViewColumn
-    right_column*: PGtkTreeViewColumn
-
-  PGtkTreeViewPrivate* = ptr TGtkTreeViewPrivate
-  TGtkTreeViewPrivate* {.final, pure.} = object
-    model*: PGtkTreeModel
-    flags*: guint
-    tree*: PGtkRBTree
-    button_pressed_node*: PGtkRBNode
-    button_pressed_tree*: PGtkRBTree
-    children*: PGList
-    width*: gint
-    height*: gint
-    expander_size*: gint
-    hadjustment*: PGtkAdjustment
-    vadjustment*: PGtkAdjustment
-    bin_window*: PGdkWindow
-    header_window*: PGdkWindow
-    drag_window*: PGdkWindow
-    drag_highlight_window*: PGdkWindow
-    drag_column*: PGtkTreeViewColumn
-    last_button_press*: PGtkTreeRowReference
-    last_button_press_2*: PGtkTreeRowReference
-    top_row*: PGtkTreeRowReference
-    top_row_dy*: gint
-    dy*: gint
-    drag_column_x*: gint
-    expander_column*: PGtkTreeViewColumn
-    edited_column*: PGtkTreeViewColumn
-    presize_handler_timer*: guint
-    validate_rows_timer*: guint
-    scroll_sync_timer*: guint
-    focus_column*: PGtkTreeViewColumn
-    anchor*: PGtkTreeRowReference
-    cursor*: PGtkTreeRowReference
-    drag_pos*: gint
-    x_drag*: gint
-    prelight_node*: PGtkRBNode
-    prelight_tree*: PGtkRBTree
-    expanded_collapsed_node*: PGtkRBNode
-    expanded_collapsed_tree*: PGtkRBTree
-    expand_collapse_timeout*: guint
-    selection*: PGtkTreeSelection
-    n_columns*: gint
-    columns*: PGList
-    header_height*: gint
-    column_drop_func*: TGtkTreeViewColumnDropFunc
-    column_drop_func_data*: gpointer
-    column_drop_func_data_destroy*: TGtkDestroyNotify
-    column_drag_info*: PGList
-    cur_reorder*: PGtkTreeViewColumnReorder
-    destroy_count_func*: TGtkTreeDestroyCountFunc
-    destroy_count_data*: gpointer
-    destroy_count_destroy*: TGtkDestroyNotify
-    scroll_timeout*: guint
-    drag_dest_row*: PGtkTreeRowReference
-    drag_dest_pos*: TGtkTreeViewDropPosition
-    open_dest_timeout*: guint
-    pressed_button*: gint
-    press_start_x*: gint
-    press_start_y*: gint
-    scroll_to_path*: PGtkTreeRowReference
-    scroll_to_column*: PGtkTreeViewColumn
-    scroll_to_row_align*: gfloat
-    scroll_to_col_align*: gfloat
-    flag0*: guint16
-    search_column*: gint
-    search_dialog_position_func*: TGtkTreeViewSearchDialogPositionFunc
-    search_equal_func*: TGtkTreeViewSearchEqualFunc
-    search_user_data*: gpointer
-    search_destroy*: TGtkDestroyNotify
-
-  TGtkTreeView* = object of TGtkContainer
-    priv*: PGtkTreeViewPrivate
-
-  PGtkTreeViewClass* = ptr TGtkTreeViewClass
-  TGtkTreeViewClass* = object of TGtkContainerClass
-    set_scroll_adjustments*: proc (tree_view: PGtkTreeView,
-                                   hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-    row_activated*: proc (tree_view: PGtkTreeView, path: PGtkTreePath,
-                          column: PGtkTreeViewColumn){.cdecl.}
-    test_expand_row*: proc (tree_view: PGtkTreeView, iter: PGtkTreeIter,
-                            path: PGtkTreePath): gboolean{.cdecl.}
-    test_collapse_row*: proc (tree_view: PGtkTreeView, iter: PGtkTreeIter,
-                              path: PGtkTreePath): gboolean{.cdecl.}
-    row_expanded*: proc (tree_view: PGtkTreeView, iter: PGtkTreeIter,
-                         path: PGtkTreePath){.cdecl.}
-    row_collapsed*: proc (tree_view: PGtkTreeView, iter: PGtkTreeIter,
-                          path: PGtkTreePath){.cdecl.}
-    columns_changed*: proc (tree_view: PGtkTreeView){.cdecl.}
-    cursor_changed*: proc (tree_view: PGtkTreeView){.cdecl.}
-    move_cursor*: proc (tree_view: PGtkTreeView, step: TGtkMovementStep,
-                        count: gint): gboolean{.cdecl.}
-    select_all*: proc (tree_view: PGtkTreeView){.cdecl.}
-    unselect_all*: proc (tree_view: PGtkTreeView){.cdecl.}
-    select_cursor_row*: proc (tree_view: PGtkTreeView, start_editing: gboolean){.
-        cdecl.}
-    toggle_cursor_row*: proc (tree_view: PGtkTreeView){.cdecl.}
-    expand_collapse_cursor_row*: proc (tree_view: PGtkTreeView,
-                                       logical: gboolean, expand: gboolean,
-                                       open_all: gboolean){.cdecl.}
-    select_cursor_parent*: proc (tree_view: PGtkTreeView){.cdecl.}
-    start_interactive_search*: proc (tree_view: PGtkTreeView){.cdecl.}
-    gtk_reserved760: proc (){.cdecl.}
-    gtk_reserved761: proc (){.cdecl.}
-    gtk_reserved762: proc (){.cdecl.}
-    gtk_reserved763: proc (){.cdecl.}
-    gtk_reserved764: proc (){.cdecl.}
-
-  PGtkVButtonBox* = ptr TGtkVButtonBox
-  TGtkVButtonBox* = object of TGtkButtonBox
-
-  PGtkVButtonBoxClass* = ptr TGtkVButtonBoxClass
-  TGtkVButtonBoxClass* = object of TGtkButtonBoxClass
-
-  PGtkViewport* = ptr TGtkViewport
-  TGtkViewport* = object of TGtkBin
-    shadow_type*: TGtkShadowType
-    view_window*: PGdkWindow
-    bin_window*: PGdkWindow
-    hadjustment*: PGtkAdjustment
-    vadjustment*: PGtkAdjustment
-
-  PGtkViewportClass* = ptr TGtkViewportClass
-  TGtkViewportClass* = object of TGtkBinClass
-    set_scroll_adjustments*: proc (viewport: PGtkViewport,
-                                   hadjustment: PGtkAdjustment,
-                                   vadjustment: PGtkAdjustment){.cdecl.}
-
-  PGtkVPaned* = ptr TGtkVPaned
-  TGtkVPaned* = object of TGtkPaned
-
-  PGtkVPanedClass* = ptr TGtkVPanedClass
-  TGtkVPanedClass* = object of TGtkPanedClass
-
-  PGtkVRuler* = ptr TGtkVRuler
-  TGtkVRuler* = object of TGtkRuler
-
-  PGtkVRulerClass* = ptr TGtkVRulerClass
-  TGtkVRulerClass* = object of TGtkRulerClass
-
-  PGtkVScale* = ptr TGtkVScale
-  TGtkVScale* = object of TGtkScale
-
-  PGtkVScaleClass* = ptr TGtkVScaleClass
-  TGtkVScaleClass* = object of TGtkScaleClass
-
-  PGtkVScrollbar* = ptr TGtkVScrollbar
-  TGtkVScrollbar* = object of TGtkScrollbar
-
-  PGtkVScrollbarClass* = ptr TGtkVScrollbarClass
-  TGtkVScrollbarClass* = object of TGtkScrollbarClass
-
-  PGtkVSeparator* = ptr TGtkVSeparator
-  TGtkVSeparator* = object of TGtkSeparator
-
-  PGtkVSeparatorClass* = ptr TGtkVSeparatorClass
-  TGtkVSeparatorClass* = object of TGtkSeparatorClass
-
-
-const
-  GTK_IN_DESTRUCTION* = 1 shl 0
-  GTK_FLOATING* = 1 shl 1
-  GTK_RESERVED_1* = 1 shl 2
-  GTK_RESERVED_2* = 1 shl 3
-  GTK_ARG_READABLE* = G_PARAM_READABLE
-  GTK_ARG_WRITABLE* = G_PARAM_WRITABLE
-  GTK_ARG_CONSTRUCT* = G_PARAM_CONSTRUCT
-  GTK_ARG_CONSTRUCT_ONLY* = G_PARAM_CONSTRUCT_ONLY
-  GTK_ARG_CHILD_ARG* = 1 shl 4
-
-proc GTK_TYPE_OBJECT*(): GType
-proc GTK_OBJECT*(anObject: pointer): PGtkObject
-proc GTK_OBJECT_CLASS*(klass: pointer): PGtkObjectClass
-proc GTK_IS_OBJECT*(anObject: pointer): bool
-proc GTK_IS_OBJECT_CLASS*(klass: pointer): bool
-proc GTK_OBJECT_GET_CLASS*(anObject: pointer): PGtkObjectClass
-proc GTK_OBJECT_TYPE*(anObject: pointer): GType
-proc GTK_OBJECT_TYPE_NAME*(anObject: pointer): cstring
-proc GTK_OBJECT_FLAGS*(obj: pointer): guint32
-proc GTK_OBJECT_FLOATING*(obj: pointer): gboolean
-proc GTK_OBJECT_SET_FLAGS*(obj: pointer, flag: guint32)
-proc GTK_OBJECT_UNSET_FLAGS*(obj: pointer, flag: guint32)
-proc gtk_object_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_object_get_type".}
-proc gtk_object_new*(thetype: TGtkType, first_property_name: cstring): PGtkObject{.
-    cdecl, varargs, dynlib: gtklib, importc: "gtk_object_new".}
-proc gtk_object_sink*(anObject: PGtkObject){.cdecl, dynlib: gtklib,
-    importc: "gtk_object_sink".}
-proc gtk_object_destroy*(anObject: PGtkObject){.cdecl, dynlib: gtklib,
-    importc: "gtk_object_destroy".}
-const
-  GTK_TYPE_INVALID* = G_TYPE_INVALID
-  GTK_TYPE_NONE* = G_TYPE_NONE
-  GTK_TYPE_ENUM* = G_TYPE_ENUM
-  GTK_TYPE_FLAGS* = G_TYPE_FLAGS
-  GTK_TYPE_CHAR* = G_TYPE_CHAR
-  GTK_TYPE_UCHAR* = G_TYPE_UCHAR
-  GTK_TYPE_BOOL* = G_TYPE_BOOLEAN
-  GTK_TYPE_INT* = G_TYPE_INT
-  GTK_TYPE_UINT* = G_TYPE_UINT
-  GTK_TYPE_LONG* = G_TYPE_LONG
-  GTK_TYPE_ULONG* = G_TYPE_ULONG
-  GTK_TYPE_FLOAT* = G_TYPE_FLOAT
-  GTK_TYPE_DOUBLE* = G_TYPE_DOUBLE
-  GTK_TYPE_STRING* = G_TYPE_STRING
-  GTK_TYPE_BOXED* = G_TYPE_BOXED
-  GTK_TYPE_POINTER* = G_TYPE_POINTER
-
-proc GTK_TYPE_IDENTIFIER*(): GType
-proc gtk_identifier_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_identifier_get_type".}
-proc GTK_SIGNAL_FUNC*(f: pointer): TGtkSignalFunc
-proc gtk_type_class*(thetype: TGtkType): gpointer{.cdecl, dynlib: gtklib,
-    importc: "gtk_type_class".}
-const
-  GTK_TOPLEVEL* = 1 shl 4
-  GTK_NO_WINDOW* = 1 shl 5
-  GTK_REALIZED* = 1 shl 6
-  GTK_MAPPED* = 1 shl 7
-  GTK_VISIBLE* = 1 shl 8
-  GTK_SENSITIVE* = 1 shl 9
-  GTK_PARENT_SENSITIVE* = 1 shl 10
-  GTK_CAN_FOCUS* = 1 shl 11
-  GTK_HAS_FOCUS* = 1 shl 12
-  GTK_CAN_DEFAULT* = 1 shl 13
-  GTK_HAS_DEFAULT* = 1 shl 14
-  GTK_HAS_GRAB* = 1 shl 15
-  GTK_RC_STYLE* = 1 shl 16
-  GTK_COMPOSITE_CHILD* = 1 shl 17
-  GTK_NO_REPARENT* = 1 shl 18
-  GTK_APP_PAINTABLE* = 1 shl 19
-  GTK_RECEIVES_DEFAULT* = 1 shl 20
-  GTK_DOUBLE_BUFFERED* = 1 shl 21
-
-const
-  bm_TGtkWidgetAuxInfo_x_set* = 0x00000001'i16
-  bp_TGtkWidgetAuxInfo_x_set* = 0'i16
-  bm_TGtkWidgetAuxInfo_y_set* = 0x00000002'i16
-  bp_TGtkWidgetAuxInfo_y_set* = 1'i16
-
-proc GTK_TYPE_WIDGET*(): GType
-proc GTK_WIDGET*(widget: pointer): PGtkWidget
-proc GTK_WIDGET_CLASS*(klass: pointer): PGtkWidgetClass
-proc GTK_IS_WIDGET*(widget: pointer): bool
-proc GTK_IS_WIDGET_CLASS*(klass: pointer): bool
-proc GTK_WIDGET_GET_CLASS*(obj: pointer): PGtkWidgetClass
-proc GTK_WIDGET_TYPE*(wid: pointer): GType
-proc GTK_WIDGET_STATE*(wid: pointer): int32
-proc GTK_WIDGET_SAVED_STATE*(wid: pointer): int32
-proc GTK_WIDGET_FLAGS*(wid: pointer): guint32
-proc GTK_WIDGET_TOPLEVEL*(wid: pointer): gboolean
-proc GTK_WIDGET_NO_WINDOW*(wid: pointer): gboolean
-proc GTK_WIDGET_REALIZED*(wid: pointer): gboolean
-proc GTK_WIDGET_MAPPED*(wid: pointer): gboolean
-proc GTK_WIDGET_VISIBLE*(wid: pointer): gboolean
-proc GTK_WIDGET_DRAWABLE*(wid: pointer): gboolean
-proc GTK_WIDGET_SENSITIVE*(wid: pointer): gboolean
-proc GTK_WIDGET_PARENT_SENSITIVE*(wid: pointer): gboolean
-proc GTK_WIDGET_IS_SENSITIVE*(wid: pointer): gboolean
-proc GTK_WIDGET_CAN_FOCUS*(wid: pointer): gboolean
-proc GTK_WIDGET_HAS_FOCUS*(wid: pointer): gboolean
-proc GTK_WIDGET_CAN_DEFAULT*(wid: pointer): gboolean
-proc GTK_WIDGET_HAS_DEFAULT*(wid: pointer): gboolean
-proc GTK_WIDGET_HAS_GRAB*(wid: pointer): gboolean
-proc GTK_WIDGET_RC_STYLE*(wid: pointer): gboolean
-proc GTK_WIDGET_COMPOSITE_CHILD*(wid: pointer): gboolean
-proc GTK_WIDGET_APP_PAINTABLE*(wid: pointer): gboolean
-proc GTK_WIDGET_RECEIVES_DEFAULT*(wid: pointer): gboolean
-proc GTK_WIDGET_DOUBLE_BUFFERED*(wid: pointer): gboolean
-proc GTK_WIDGET_SET_FLAGS*(wid: PGtkWidget, flags: TGtkWidgetFlags): TGtkWidgetFlags
-proc GTK_WIDGET_UNSET_FLAGS*(wid: PGtkWidget, flags: TGtkWidgetFlags): TGtkWidgetFlags
-proc GTK_TYPE_REQUISITION*(): GType
-proc x_set*(a: var TGtkWidgetAuxInfo): guint
-proc set_x_set*(a: var TGtkWidgetAuxInfo, x_set: guint)
-proc y_set*(a: var TGtkWidgetAuxInfo): guint
-proc set_y_set*(a: var TGtkWidgetAuxInfo, y_set: guint)
-proc gtk_widget_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_widget_get_type".}
-proc gtk_widget_ref*(widget: PGtkWidget): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_ref".}
-proc gtk_widget_unref*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_unref".}
-proc gtk_widget_destroy*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_destroy".}
-proc gtk_widget_destroyed*(widget: PGtkWidget, r: var PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_destroyed".}
-proc gtk_widget_unparent*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_unparent".}
-proc gtk_widget_show*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_show".}
-proc gtk_widget_show_now*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_show_now".}
-proc gtk_widget_hide*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_hide".}
-proc gtk_widget_show_all*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_show_all".}
-proc gtk_widget_hide_all*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_hide_all".}
-proc gtk_widget_map*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_map".}
-proc gtk_widget_unmap*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_unmap".}
-proc gtk_widget_realize*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_realize".}
-proc gtk_widget_unrealize*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_unrealize".}
-proc gtk_widget_queue_draw*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_queue_draw".}
-proc gtk_widget_queue_draw_area*(widget: PGtkWidget, x: gint, y: gint,
-                                 width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_queue_draw_area".}
-proc gtk_widget_queue_resize*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_queue_resize".}
-proc gtk_widget_size_request*(widget: PGtkWidget, requisition: PGtkRequisition){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_size_request".}
-proc gtk_widget_size_allocate*(widget: PGtkWidget, allocation: PGtkAllocation){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_size_allocate".}
-proc gtk_widget_get_child_requisition*(widget: PGtkWidget,
-                                       requisition: PGtkRequisition){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_child_requisition".}
-proc gtk_widget_add_accelerator*(widget: PGtkWidget, accel_signal: cstring,
-                                 accel_group: PGtkAccelGroup, accel_key: guint,
-                                 accel_mods: TGdkModifierType,
-                                 accel_flags: TGtkAccelFlags){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_add_accelerator".}
-proc gtk_widget_remove_accelerator*(widget: PGtkWidget,
-                                    accel_group: PGtkAccelGroup,
-                                    accel_key: guint,
-                                    accel_mods: TGdkModifierType): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_remove_accelerator".}
-proc gtk_widget_set_accel_path*(widget: PGtkWidget, accel_path: cstring,
-                                accel_group: PGtkAccelGroup){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_accel_path".}
-proc gtk_widget_get_accel_path*(widget: PGtkWidget, locked: Pgboolean): cstring{.
-    cdecl, dynlib: gtklib, importc: "_gtk_widget_get_accel_path".}
-proc gtk_widget_list_accel_closures*(widget: PGtkWidget): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_list_accel_closures".}
-proc gtk_widget_mnemonic_activate*(widget: PGtkWidget, group_cycling: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_mnemonic_activate".}
-proc gtk_widget_event*(widget: PGtkWidget, event: PGdkEvent): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_event".}
-proc gtk_widget_send_expose*(widget: PGtkWidget, event: PGdkEvent): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_send_expose".}
-proc gtk_widget_activate*(widget: PGtkWidget): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_activate".}
-proc gtk_widget_set_scroll_adjustments*(widget: PGtkWidget,
-                                        hadjustment: PGtkAdjustment,
-                                        vadjustment: PGtkAdjustment): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_scroll_adjustments".}
-proc gtk_widget_reparent*(widget: PGtkWidget, new_parent: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_reparent".}
-proc gtk_widget_intersect*(widget: PGtkWidget, area: PGdkRectangle,
-                           intersection: PGdkRectangle): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_intersect".}
-proc gtk_widget_region_intersect*(widget: PGtkWidget, region: PGdkRegion): PGdkRegion{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_region_intersect".}
-proc gtk_widget_freeze_child_notify*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_freeze_child_notify".}
-proc gtk_widget_child_notify*(widget: PGtkWidget, child_property: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_child_notify".}
-proc gtk_widget_thaw_child_notify*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_thaw_child_notify".}
-proc gtk_widget_is_focus*(widget: PGtkWidget): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_is_focus".}
-proc gtk_widget_grab_focus*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_grab_focus".}
-proc gtk_widget_grab_default*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_grab_default".}
-proc gtk_widget_set_name*(widget: PGtkWidget, name: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_name".}
-proc gtk_widget_get_name*(widget: PGtkWidget): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_get_name".}
-proc gtk_widget_set_state*(widget: PGtkWidget, state: TGtkStateType){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_state".}
-proc gtk_widget_set_sensitive*(widget: PGtkWidget, sensitive: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_sensitive".}
-proc gtk_widget_set_app_paintable*(widget: PGtkWidget, app_paintable: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_app_paintable".}
-proc gtk_widget_set_double_buffered*(widget: PGtkWidget,
-                                     double_buffered: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_double_buffered".}
-proc gtk_widget_set_redraw_on_allocate*(widget: PGtkWidget,
-                                        redraw_on_allocate: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_redraw_on_allocate".}
-proc gtk_widget_set_parent*(widget: PGtkWidget, parent: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_parent".}
-proc gtk_widget_set_parent_window*(widget: PGtkWidget, parent_window: PGdkWindow){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_parent_window".}
-proc gtk_widget_set_child_visible*(widget: PGtkWidget, is_visible: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_child_visible".}
-proc gtk_widget_get_child_visible*(widget: PGtkWidget): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_child_visible".}
-proc gtk_widget_get_parent*(widget: PGtkWidget): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_parent".}
-proc gtk_widget_get_parent_window*(widget: PGtkWidget): PGdkWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_parent_window".}
-proc gtk_widget_child_focus*(widget: PGtkWidget, direction: TGtkDirectionType): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_child_focus".}
-proc gtk_widget_set_size_request*(widget: PGtkWidget, width: gint, height: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_size_request".}
-proc gtk_widget_get_size_request*(widget: PGtkWidget, width: Pgint,
-                                  height: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_get_size_request".}
-proc gtk_widget_set_events*(widget: PGtkWidget, events: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_events".}
-proc gtk_widget_add_events*(widget: PGtkWidget, events: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_add_events".}
-proc gtk_widget_set_extension_events*(widget: PGtkWidget,
-                                      mode: TGdkExtensionMode){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_extension_events".}
-proc gtk_widget_get_extension_events*(widget: PGtkWidget): TGdkExtensionMode{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_get_extension_events".}
-proc gtk_widget_get_toplevel*(widget: PGtkWidget): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_toplevel".}
-proc gtk_widget_get_ancestor*(widget: PGtkWidget, widget_type: TGtkType): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_get_ancestor".}
-proc gtk_widget_get_colormap*(widget: PGtkWidget): PGdkColormap{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_colormap".}
-proc gtk_widget_get_visual*(widget: PGtkWidget): PGdkVisual{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_visual".}
-proc gtk_widget_get_screen*(widget: PGtkWidget): PGdkScreen{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_screen".}
-proc gtk_widget_has_screen*(widget: PGtkWidget): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_has_screen".}
-proc gtk_widget_get_display*(widget: PGtkWidget): PGdkDisplay{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_display".}
-proc gtk_widget_get_root_window*(widget: PGtkWidget): PGdkWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_root_window".}
-proc gtk_widget_get_settings*(widget: PGtkWidget): PGtkSettings{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_settings".}
-proc gtk_widget_get_clipboard*(widget: PGtkWidget, selection: TGdkAtom): PGtkClipboard{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_get_clipboard".}
-proc gtk_widget_get_accessible*(widget: PGtkWidget): PAtkObject{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_accessible".}
-proc gtk_widget_set_colormap*(widget: PGtkWidget, colormap: PGdkColormap){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_colormap".}
-proc gtk_widget_get_events*(widget: PGtkWidget): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_get_events".}
-proc gtk_widget_get_pointer*(widget: PGtkWidget, x: Pgint, y: Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_pointer".}
-proc gtk_widget_is_ancestor*(widget: PGtkWidget, ancestor: PGtkWidget): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_is_ancestor".}
-proc gtk_widget_translate_coordinates*(src_widget: PGtkWidget,
-                                       dest_widget: PGtkWidget, src_x: gint,
-                                       src_y: gint, dest_x: Pgint, dest_y: Pgint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_translate_coordinates".}
-proc gtk_widget_hide_on_delete*(widget: PGtkWidget): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_hide_on_delete".}
-proc gtk_widget_set_style*(widget: PGtkWidget, style: PGtkStyle){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_style".}
-proc gtk_widget_ensure_style*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_ensure_style".}
-proc gtk_widget_get_style*(widget: PGtkWidget): PGtkStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_style".}
-proc gtk_widget_modify_style*(widget: PGtkWidget, style: PGtkRcStyle){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_modify_style".}
-proc gtk_widget_get_modifier_style*(widget: PGtkWidget): PGtkRcStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_modifier_style".}
-proc gtk_widget_modify_fg*(widget: PGtkWidget, state: TGtkStateType,
-                           color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_modify_fg".}
-proc gtk_widget_modify_bg*(widget: PGtkWidget, state: TGtkStateType,
-                           color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_modify_bg".}
-proc gtk_widget_modify_text*(widget: PGtkWidget, state: TGtkStateType,
-                             color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_modify_text".}
-proc gtk_widget_modify_base*(widget: PGtkWidget, state: TGtkStateType,
-                             color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_modify_base".}
-proc gtk_widget_modify_font*(widget: PGtkWidget,
-                             font_desc: PPangoFontDescription){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_modify_font".}
-proc gtk_widget_create_pango_context*(widget: PGtkWidget): PPangoContext{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_create_pango_context".}
-proc gtk_widget_get_pango_context*(widget: PGtkWidget): PPangoContext{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_pango_context".}
-proc gtk_widget_create_pango_layout*(widget: PGtkWidget, text: cstring): PPangoLayout{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_create_pango_layout".}
-proc gtk_widget_render_icon*(widget: PGtkWidget, stock_id: cstring,
-                             size: TGtkIconSize, detail: cstring): PGdkPixbuf{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_render_icon".}
-proc gtk_widget_set_composite_name*(widget: PGtkWidget, name: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_composite_name".}
-proc gtk_widget_get_composite_name*(widget: PGtkWidget): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_composite_name".}
-proc gtk_widget_reset_rc_styles*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_reset_rc_styles".}
-proc gtk_widget_push_colormap*(cmap: PGdkColormap){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_push_colormap".}
-proc gtk_widget_push_composite_child*(){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_push_composite_child".}
-proc gtk_widget_pop_composite_child*(){.cdecl, dynlib: gtklib, importc: "gtk_widget_pop_composite_child".}
-proc gtk_widget_pop_colormap*(){.cdecl, dynlib: gtklib,
-                                 importc: "gtk_widget_pop_colormap".}
-proc gtk_widget_class_install_style_property*(klass: PGtkWidgetClass,
-    pspec: PGParamSpec){.cdecl, dynlib: gtklib,
-                         importc: "gtk_widget_class_install_style_property".}
-proc gtk_widget_class_install_style_property_parser*(klass: PGtkWidgetClass,
-    pspec: PGParamSpec, parser: TGtkRcPropertyParser){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_class_install_style_property_parser".}
-proc gtk_widget_class_find_style_property*(klass: PGtkWidgetClass,
-    property_name: cstring): PGParamSpec{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_class_find_style_property".}
-proc gtk_widget_class_list_style_properties*(klass: PGtkWidgetClass,
-    n_properties: Pguint): PPGParamSpec{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_class_list_style_properties".}
-proc gtk_widget_style_get_property*(widget: PGtkWidget, property_name: cstring,
-                                    value: PGValue){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_style_get_property".}
-proc gtk_widget_set_default_colormap*(colormap: PGdkColormap){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_default_colormap".}
-proc gtk_widget_get_default_style*(): PGtkStyle{.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_get_default_style".}
-proc gtk_widget_set_direction*(widget: PGtkWidget, dir: TGtkTextDirection){.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_set_direction".}
-proc gtk_widget_get_direction*(widget: PGtkWidget): TGtkTextDirection{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_direction".}
-proc gtk_widget_set_default_direction*(dir: TGtkTextDirection){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_set_default_direction".}
-proc gtk_widget_get_default_direction*(): TGtkTextDirection{.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_get_default_direction".}
-proc gtk_widget_shape_combine_mask*(widget: PGtkWidget, shape_mask: PGdkBitmap,
-                                    offset_x: gint, offset_y: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_shape_combine_mask".}
-proc gtk_widget_reset_shapes*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_reset_shapes".}
-proc gtk_widget_path*(widget: PGtkWidget, path_length: Pguint, path: PPgchar,
-                      path_reversed: PPgchar){.cdecl, dynlib: gtklib,
-    importc: "gtk_widget_path".}
-proc gtk_widget_class_path*(widget: PGtkWidget, path_length: Pguint,
-                            path: PPgchar, path_reversed: PPgchar){.cdecl,
-    dynlib: gtklib, importc: "gtk_widget_class_path".}
-proc gtk_requisition_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_requisition_get_type".}
-proc gtk_requisition_copy*(requisition: PGtkRequisition): PGtkRequisition{.
-    cdecl, dynlib: gtklib, importc: "gtk_requisition_copy".}
-proc gtk_requisition_free*(requisition: PGtkRequisition){.cdecl, dynlib: gtklib,
-    importc: "gtk_requisition_free".}
-proc gtk_widget_get_aux_info*(widget: PGtkWidget, create: gboolean): PGtkWidgetAuxInfo{.
-    cdecl, dynlib: gtklib, importc: "gtk_widget_get_aux_info".}
-proc gtk_widget_propagate_hierarchy_changed*(widget: PGtkWidget,
-    previous_toplevel: PGtkWidget){.cdecl, dynlib: gtklib, importc: "_gtk_widget_propagate_hierarchy_changed".}
-proc gtk_widget_peek_colormap*(): PGdkColormap{.cdecl, dynlib: gtklib,
-    importc: "_gtk_widget_peek_colormap".}
-proc GTK_TYPE_MISC*(): GType
-proc GTK_MISC*(obj: pointer): PGtkMisc
-proc GTK_MISC_CLASS*(klass: pointer): PGtkMiscClass
-proc GTK_IS_MISC*(obj: pointer): bool
-proc GTK_IS_MISC_CLASS*(klass: pointer): bool
-proc GTK_MISC_GET_CLASS*(obj: pointer): PGtkMiscClass
-proc gtk_misc_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_misc_get_type".}
-proc gtk_misc_set_alignment*(misc: PGtkMisc, xalign: gfloat, yalign: gfloat){.
-    cdecl, dynlib: gtklib, importc: "gtk_misc_set_alignment".}
-proc gtk_misc_get_alignment*(misc: PGtkMisc, xalign, yalign: var Pgfloat){.
-    cdecl, dynlib: gtklib, importc: "gtk_misc_get_alignment".}
-proc gtk_misc_set_padding*(misc: PGtkMisc, xpad: gint, ypad: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_misc_set_padding".}
-proc gtk_misc_get_padding*(misc: PGtkMisc, xpad, ypad: var Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_misc_get_padding".}
-const
-  GTK_ACCEL_VISIBLE* = 1 shl 0
-  GTK_ACCEL_LOCKED* = 1 shl 1
-  GTK_ACCEL_MASK* = 0x00000007
-  bm_TGtkAccelKey_accel_flags* = 0x0000FFFF'i16
-  bp_TGtkAccelKey_accel_flags* = 0'i16
-
-proc GTK_TYPE_ACCEL_GROUP*(): GType
-proc GTK_ACCEL_GROUP*(anObject: pointer): PGtkAccelGroup
-proc GTK_ACCEL_GROUP_CLASS*(klass: pointer): PGtkAccelGroupClass
-proc GTK_IS_ACCEL_GROUP*(anObject: pointer): bool
-proc GTK_IS_ACCEL_GROUP_CLASS*(klass: pointer): bool
-proc GTK_ACCEL_GROUP_GET_CLASS*(obj: pointer): PGtkAccelGroupClass
-proc accel_flags*(a: var TGtkAccelKey): guint
-proc set_accel_flags*(a: var TGtkAccelKey, `accel_flags`: guint)
-proc gtk_accel_group_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_group_get_type".}
-proc gtk_accel_group_new*(): PGtkAccelGroup{.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_group_new".}
-proc gtk_accel_group_lock*(accel_group: PGtkAccelGroup){.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_group_lock".}
-proc gtk_accel_group_unlock*(accel_group: PGtkAccelGroup){.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_group_unlock".}
-proc gtk_accel_group_connect*(accel_group: PGtkAccelGroup, accel_key: guint,
-                              accel_mods: TGdkModifierType,
-                              accel_flags: TGtkAccelFlags, closure: PGClosure){.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_connect".}
-proc gtk_accel_group_connect_by_path*(accel_group: PGtkAccelGroup,
-                                      accel_path: cstring, closure: PGClosure){.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_connect_by_path".}
-proc gtk_accel_group_disconnect*(accel_group: PGtkAccelGroup, closure: PGClosure): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_disconnect".}
-proc gtk_accel_group_disconnect_key*(accel_group: PGtkAccelGroup,
-                                     accel_key: guint,
-                                     accel_mods: TGdkModifierType): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_disconnect_key".}
-proc gtk_accel_group_attach*(accel_group: PGtkAccelGroup, anObject: PGObject){.
-    cdecl, dynlib: gtklib, importc: "_gtk_accel_group_attach".}
-proc gtk_accel_group_detach*(accel_group: PGtkAccelGroup, anObject: PGObject){.
-    cdecl, dynlib: gtklib, importc: "_gtk_accel_group_detach".}
-proc gtk_accel_groups_activate*(anObject: PGObject, accel_key: guint,
-                                accel_mods: TGdkModifierType): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_groups_activate".}
-proc gtk_accel_groups_from_object*(anObject: PGObject): PGSList{.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_groups_from_object".}
-proc gtk_accel_group_find*(accel_group: PGtkAccelGroup,
-                           find_func: Tgtk_accel_group_find_func, data: gpointer): PGtkAccelKey{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_find".}
-proc gtk_accel_group_from_accel_closure*(closure: PGClosure): PGtkAccelGroup{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_from_accel_closure".}
-proc gtk_accelerator_valid*(keyval: guint, modifiers: TGdkModifierType): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_accelerator_valid".}
-proc gtk_accelerator_parse*(accelerator: cstring, accelerator_key: Pguint,
-                            accelerator_mods: PGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_accelerator_parse".}
-proc gtk_accelerator_name*(accelerator_key: guint,
-                           accelerator_mods: TGdkModifierType): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_accelerator_name".}
-proc gtk_accelerator_set_default_mod_mask*(default_mod_mask: TGdkModifierType){.
-    cdecl, dynlib: gtklib, importc: "gtk_accelerator_set_default_mod_mask".}
-proc gtk_accelerator_get_default_mod_mask*(): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_accelerator_get_default_mod_mask".}
-proc gtk_accel_group_query*(accel_group: PGtkAccelGroup, accel_key: guint,
-                            accel_mods: TGdkModifierType, n_entries: Pguint): PGtkAccelGroupEntry{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_group_query".}
-proc gtk_accel_group_reconnect*(accel_group: PGtkAccelGroup,
-                                accel_path_quark: TGQuark){.cdecl,
-    dynlib: gtklib, importc: "_gtk_accel_group_reconnect".}
-const
-  bm_TGtkContainer_border_width* = 0x0000FFFF'i32
-  bp_TGtkContainer_border_width* = 0'i32
-  bm_TGtkContainer_need_resize* = 0x00010000'i32
-  bp_TGtkContainer_need_resize* = 16'i32
-  bm_TGtkContainer_resize_mode* = 0x00060000'i32
-  bp_TGtkContainer_resize_mode* = 17'i32
-  bm_TGtkContainer_reallocate_redraws* = 0x00080000'i32
-  bp_TGtkContainer_reallocate_redraws* = 19'i32
-  bm_TGtkContainer_has_focus_chain* = 0x00100000'i32
-  bp_TGtkContainer_has_focus_chain* = 20'i32
-
-proc GTK_TYPE_CONTAINER*(): GType
-proc GTK_CONTAINER*(obj: pointer): PGtkContainer
-proc GTK_CONTAINER_CLASS*(klass: pointer): PGtkContainerClass
-proc GTK_IS_CONTAINER*(obj: pointer): bool
-proc GTK_IS_CONTAINER_CLASS*(klass: pointer): bool
-proc GTK_CONTAINER_GET_CLASS*(obj: pointer): PGtkContainerClass
-proc GTK_IS_RESIZE_CONTAINER*(widget: pointer): bool
-proc border_width*(a: var TGtkContainer): guint
-proc set_border_width*(a: var TGtkContainer, `border_width`: guint)
-proc need_resize*(a: var TGtkContainer): guint
-proc set_need_resize*(a: var TGtkContainer, `need_resize`: guint)
-proc resize_mode*(a: PGtkContainer): guint
-proc set_resize_mode*(a: var TGtkContainer, `resize_mode`: guint)
-proc reallocate_redraws*(a: var TGtkContainer): guint
-proc set_reallocate_redraws*(a: var TGtkContainer, `reallocate_redraws`: guint)
-proc has_focus_chain*(a: var TGtkContainer): guint
-proc set_has_focus_chain*(a: var TGtkContainer, `has_focus_chain`: guint)
-proc gtk_container_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_container_get_type".}
-proc gtk_container_set_border_width*(container: PGtkContainer,
-                                     border_width: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_set_border_width".}
-proc gtk_container_get_border_width*(container: PGtkContainer): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_container_get_border_width".}
-proc gtk_container_add*(container: PGtkContainer, widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_add".}
-proc gtk_container_remove*(container: PGtkContainer, widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_remove".}
-proc gtk_container_set_resize_mode*(container: PGtkContainer,
-                                    resize_mode: TGtkResizeMode){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_set_resize_mode".}
-proc gtk_container_get_resize_mode*(container: PGtkContainer): TGtkResizeMode{.
-    cdecl, dynlib: gtklib, importc: "gtk_container_get_resize_mode".}
-proc gtk_container_check_resize*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_check_resize".}
-proc gtk_container_foreach*(container: PGtkContainer, callback: TGtkCallback,
-                            callback_data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_container_foreach".}
-proc gtk_container_get_children*(container: PGtkContainer): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_container_get_children".}
-proc gtk_container_propagate_expose*(container: PGtkContainer,
-                                     child: PGtkWidget, event: PGdkEventExpose){.
-    cdecl, dynlib: gtklib, importc: "gtk_container_propagate_expose".}
-proc gtk_container_set_focus_chain*(container: PGtkContainer,
-                                    focusable_widgets: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_set_focus_chain".}
-proc gtk_container_get_focus_chain*(container: PGtkContainer, s: var PGList): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_container_get_focus_chain".}
-proc gtk_container_unset_focus_chain*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_unset_focus_chain".}
-proc gtk_container_set_reallocate_redraws*(container: PGtkContainer,
-    needs_redraws: gboolean){.cdecl, dynlib: gtklib,
-                              importc: "gtk_container_set_reallocate_redraws".}
-proc gtk_container_set_focus_child*(container: PGtkContainer, child: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_container_set_focus_child".}
-proc gtk_container_set_focus_vadjustment*(container: PGtkContainer,
-    adjustment: PGtkAdjustment){.cdecl, dynlib: gtklib,
-                                 importc: "gtk_container_set_focus_vadjustment".}
-proc gtk_container_get_focus_vadjustment*(container: PGtkContainer): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_container_get_focus_vadjustment".}
-proc gtk_container_set_focus_hadjustment*(container: PGtkContainer,
-    adjustment: PGtkAdjustment){.cdecl, dynlib: gtklib,
-                                 importc: "gtk_container_set_focus_hadjustment".}
-proc gtk_container_get_focus_hadjustment*(container: PGtkContainer): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_container_get_focus_hadjustment".}
-proc gtk_container_resize_children*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "gtk_container_resize_children".}
-proc gtk_container_child_type*(container: PGtkContainer): TGtkType{.cdecl,
-    dynlib: gtklib, importc: "gtk_container_child_type".}
-proc gtk_container_class_install_child_property*(cclass: PGtkContainerClass,
-    property_id: guint, pspec: PGParamSpec){.cdecl, dynlib: gtklib,
-    importc: "gtk_container_class_install_child_property".}
-proc gtk_container_class_find_child_property*(cclass: PGObjectClass,
-    property_name: cstring): PGParamSpec{.cdecl, dynlib: gtklib,
-    importc: "gtk_container_class_find_child_property".}
-proc gtk_container_class_list_child_properties*(cclass: PGObjectClass,
-    n_properties: Pguint): PPGParamSpec{.cdecl, dynlib: gtklib,
-    importc: "gtk_container_class_list_child_properties".}
-proc gtk_container_child_set_property*(container: PGtkContainer,
-                                       child: PGtkWidget, property_name: cstring,
-                                       value: PGValue){.cdecl, dynlib: gtklib,
-    importc: "gtk_container_child_set_property".}
-proc gtk_container_child_get_property*(container: PGtkContainer,
-                                       child: PGtkWidget, property_name: cstring,
-                                       value: PGValue){.cdecl, dynlib: gtklib,
-    importc: "gtk_container_child_get_property".}
-proc GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID*(anObject: pointer,
-    property_id: guint, pspec: pointer)
-proc gtk_container_forall*(container: PGtkContainer, callback: TGtkCallback,
-                           callback_data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_container_forall".}
-proc gtk_container_queue_resize*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "_gtk_container_queue_resize".}
-proc gtk_container_clear_resize_widgets*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "_gtk_container_clear_resize_widgets".}
-proc gtk_container_child_composite_name*(container: PGtkContainer,
-    child: PGtkWidget): cstring{.cdecl, dynlib: gtklib,
-                                importc: "_gtk_container_child_composite_name".}
-proc gtk_container_dequeue_resize_handler*(container: PGtkContainer){.cdecl,
-    dynlib: gtklib, importc: "_gtk_container_dequeue_resize_handler".}
-proc gtk_container_focus_sort*(container: PGtkContainer, children: PGList,
-                                 direction: TGtkDirectionType,
-                                 old_focus: PGtkWidget): PGList{.cdecl,
-    dynlib: gtklib, importc: "_gtk_container_focus_sort".}
-proc GTK_TYPE_BIN*(): GType
-proc GTK_BIN*(obj: pointer): PGtkBin
-proc GTK_BIN_CLASS*(klass: pointer): PGtkBinClass
-proc GTK_IS_BIN*(obj: pointer): bool
-proc GTK_IS_BIN_CLASS*(klass: pointer): bool
-proc GTK_BIN_GET_CLASS*(obj: pointer): PGtkBinClass
-proc gtk_bin_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_bin_get_type".}
-proc gtk_bin_get_child*(bin: PGtkBin): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_bin_get_child".}
-const
-  bm_TGtkWindow_allow_shrink* = 0x00000001'i32
-  bp_TGtkWindow_allow_shrink* = 0'i32
-  bm_TGtkWindow_allow_grow* = 0x00000002'i32
-  bp_TGtkWindow_allow_grow* = 1'i32
-  bm_TGtkWindow_configure_notify_received* = 0x00000004'i32
-  bp_TGtkWindow_configure_notify_received* = 2'i32
-  bm_TGtkWindow_need_default_position* = 0x00000008'i32
-  bp_TGtkWindow_need_default_position* = 3'i32
-  bm_TGtkWindow_need_default_size* = 0x00000010'i32
-  bp_TGtkWindow_need_default_size* = 4'i32
-  bm_TGtkWindow_position* = 0x000000E0'i32
-  bp_TGtkWindow_position* = 5'i32
-  bm_TGtkWindow_type* = 0x00000F00'i32
-  bp_TGtkWindow_type* = 8'i32
-  bm_TGtkWindow_has_user_ref_count* = 0x00001000'i32
-  bp_TGtkWindow_has_user_ref_count* = 12'i32
-  bm_TGtkWindow_has_focus* = 0x00002000'i32
-  bp_TGtkWindow_has_focus* = 13'i32
-  bm_TGtkWindow_modal* = 0x00004000'i32
-  bp_TGtkWindow_modal* = 14'i32
-  bm_TGtkWindow_destroy_with_parent* = 0x00008000'i32
-  bp_TGtkWindow_destroy_with_parent* = 15'i32
-  bm_TGtkWindow_has_frame* = 0x00010000'i32
-  bp_TGtkWindow_has_frame* = 16'i32
-  bm_TGtkWindow_iconify_initially* = 0x00020000'i32
-  bp_TGtkWindow_iconify_initially* = 17'i32
-  bm_TGtkWindow_stick_initially* = 0x00040000'i32
-  bp_TGtkWindow_stick_initially* = 18'i32
-  bm_TGtkWindow_maximize_initially* = 0x00080000'i32
-  bp_TGtkWindow_maximize_initially* = 19'i32
-  bm_TGtkWindow_decorated* = 0x00100000'i32
-  bp_TGtkWindow_decorated* = 20'i32
-  bm_TGtkWindow_type_hint* = 0x00E00000'i32
-  bp_TGtkWindow_type_hint* = 21'i32
-  bm_TGtkWindow_gravity* = 0x1F000000'i32
-  bp_TGtkWindow_gravity* = 24'i32
-
-proc GTK_TYPE_WINDOW*(): GType
-proc GTK_WINDOW*(obj: pointer): PGtkWindow
-proc GTK_WINDOW_CLASS*(klass: pointer): PGtkWindowClass
-proc GTK_IS_WINDOW*(obj: pointer): bool
-proc GTK_IS_WINDOW_CLASS*(klass: pointer): bool
-proc GTK_WINDOW_GET_CLASS*(obj: pointer): PGtkWindowClass
-proc allow_shrink*(a: var TGtkWindow): guint
-proc set_allow_shrink*(a: var TGtkWindow, `allow_shrink`: guint)
-proc allow_grow*(a: var TGtkWindow): guint
-proc set_allow_grow*(a: var TGtkWindow, `allow_grow`: guint)
-proc configure_notify_received*(a: var TGtkWindow): guint
-proc set_configure_notify_received*(a: var TGtkWindow,
-                                    `configure_notify_received`: guint)
-proc need_default_position*(a: var TGtkWindow): guint
-proc set_need_default_position*(a: var TGtkWindow,
-                                `need_default_position`: guint)
-proc need_default_size*(a: var TGtkWindow): guint
-proc set_need_default_size*(a: var TGtkWindow, `need_default_size`: guint)
-proc position*(a: var TGtkWindow): guint
-proc set_position*(a: var TGtkWindow, `position`: guint)
-proc get_type*(a: var TGtkWindow): guint
-proc set_type*(a: var TGtkWindow, `type`: guint)
-proc has_user_ref_count*(a: var TGtkWindow): guint
-proc set_has_user_ref_count*(a: var TGtkWindow, `has_user_ref_count`: guint)
-proc has_focus*(a: var TGtkWindow): guint
-proc set_has_focus*(a: var TGtkWindow, `has_focus`: guint)
-proc modal*(a: var TGtkWindow): guint
-proc set_modal*(a: var TGtkWindow, `modal`: guint)
-proc destroy_with_parent*(a: var TGtkWindow): guint
-proc set_destroy_with_parent*(a: var TGtkWindow, `destroy_with_parent`: guint)
-proc has_frame*(a: var TGtkWindow): guint
-proc set_has_frame*(a: var TGtkWindow, `has_frame`: guint)
-proc iconify_initially*(a: var TGtkWindow): guint
-proc set_iconify_initially*(a: var TGtkWindow, `iconify_initially`: guint)
-proc stick_initially*(a: var TGtkWindow): guint
-proc set_stick_initially*(a: var TGtkWindow, `stick_initially`: guint)
-proc maximize_initially*(a: var TGtkWindow): guint
-proc set_maximize_initially*(a: var TGtkWindow, `maximize_initially`: guint)
-proc decorated*(a: var TGtkWindow): guint
-proc set_decorated*(a: var TGtkWindow, `decorated`: guint)
-proc type_hint*(a: var TGtkWindow): guint
-proc set_type_hint*(a: var TGtkWindow, `type_hint`: guint)
-proc gravity*(a: var TGtkWindow): guint
-proc set_gravity*(a: var TGtkWindow, `gravity`: guint)
-proc GTK_TYPE_WINDOW_GROUP*(): GType
-proc GTK_WINDOW_GROUP*(anObject: pointer): PGtkWindowGroup
-proc GTK_WINDOW_GROUP_CLASS*(klass: pointer): PGtkWindowGroupClass
-proc GTK_IS_WINDOW_GROUP*(anObject: pointer): bool
-proc GTK_IS_WINDOW_GROUP_CLASS*(klass: pointer): bool
-proc GTK_WINDOW_GROUP_GET_CLASS*(obj: pointer): PGtkWindowGroupClass
-proc gtk_window_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_window_get_type".}
-proc gtk_window_new*(thetype: TGtkWindowType): PGtkWindow {.cdecl,
-    dynlib: gtklib, importc: "gtk_window_new".}
-proc gtk_window_set_title*(window: PGtkWindow, title: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_title".}
-proc gtk_window_get_title*(window: PGtkWindow): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_get_title".}
-proc gtk_window_set_wmclass*(window: PGtkWindow, wmclass_name: cstring,
-                             wmclass_class: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_set_wmclass".}
-proc gtk_window_set_role*(window: PGtkWindow, role: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_role".}
-proc gtk_window_get_role*(window: PGtkWindow): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_get_role".}
-proc gtk_window_add_accel_group*(window: PGtkWindow, accel_group: PGtkAccelGroup){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_add_accel_group".}
-proc gtk_window_remove_accel_group*(window: PGtkWindow,
-                                    accel_group: PGtkAccelGroup){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_remove_accel_group".}
-proc gtk_window_set_position*(window: PGtkWindow, position: TGtkWindowPosition){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_position".}
-proc gtk_window_activate_focus*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_activate_focus".}
-proc gtk_window_set_focus*(window: PGtkWindow, focus: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_focus".}
-proc gtk_window_get_focus*(window: PGtkWindow): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_focus".}
-proc gtk_window_set_default*(window: PGtkWindow, default_widget: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_default".}
-proc gtk_window_activate_default*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_activate_default".}
-proc gtk_window_set_transient_for*(window: PGtkWindow, parent: PGtkWindow){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_transient_for".}
-proc gtk_window_get_transient_for*(window: PGtkWindow): PGtkWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_transient_for".}
-proc gtk_window_set_type_hint*(window: PGtkWindow, hint: TGdkWindowTypeHint){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_type_hint".}
-proc gtk_window_get_type_hint*(window: PGtkWindow): TGdkWindowTypeHint{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_type_hint".}
-proc gtk_window_set_destroy_with_parent*(window: PGtkWindow, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_destroy_with_parent".}
-proc gtk_window_get_destroy_with_parent*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_destroy_with_parent".}
-proc gtk_window_set_resizable*(window: PGtkWindow, resizable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_resizable".}
-proc gtk_window_get_resizable*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_resizable".}
-proc gtk_window_set_gravity*(window: PGtkWindow, gravity: TGdkGravity){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_gravity".}
-proc gtk_window_get_gravity*(window: PGtkWindow): TGdkGravity{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_gravity".}
-proc gtk_window_set_geometry_hints*(window: PGtkWindow,
-                                    geometry_widget: PGtkWidget,
-                                    geometry: PGdkGeometry,
-                                    geom_mask: TGdkWindowHints){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_geometry_hints".}
-proc gtk_window_set_screen*(window: PGtkWindow, screen: PGdkScreen){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_screen".}
-proc gtk_window_get_screen*(window: PGtkWindow): PGdkScreen{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_screen".}
-proc gtk_window_set_has_frame*(window: PGtkWindow, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_has_frame".}
-proc gtk_window_get_has_frame*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_has_frame".}
-proc gtk_window_set_frame_dimensions*(window: PGtkWindow, left: gint, top: gint,
-                                      right: gint, bottom: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_frame_dimensions".}
-proc gtk_window_get_frame_dimensions*(window: PGtkWindow, left: Pgint,
-                                      top: Pgint, right: Pgint, bottom: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_get_frame_dimensions".}
-proc gtk_window_set_decorated*(window: PGtkWindow, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_decorated".}
-proc gtk_window_get_decorated*(window: PGtkWindow): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_decorated".}
-proc gtk_window_set_icon_list*(window: PGtkWindow, list: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_icon_list".}
-proc gtk_window_get_icon_list*(window: PGtkWindow): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_icon_list".}
-proc gtk_window_set_icon*(window: PGtkWindow, icon: PGdkPixbuf){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_icon".}
-proc gtk_window_get_icon*(window: PGtkWindow): PGdkPixbuf{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_get_icon".}
-proc gtk_window_set_default_icon_list*(list: PGList){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_set_default_icon_list".}
-proc gtk_window_get_default_icon_list*(): PGList{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_get_default_icon_list".}
-proc gtk_window_set_modal*(window: PGtkWindow, modal: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_modal".}
-proc gtk_window_get_modal*(window: PGtkWindow): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_get_modal".}
-proc gtk_window_list_toplevels*(): PGList{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_list_toplevels".}
-proc gtk_window_add_mnemonic*(window: PGtkWindow, keyval: guint,
-                              target: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_add_mnemonic".}
-proc gtk_window_remove_mnemonic*(window: PGtkWindow, keyval: guint,
-                                 target: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_remove_mnemonic".}
-proc gtk_window_mnemonic_activate*(window: PGtkWindow, keyval: guint,
-                                   modifier: TGdkModifierType): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_window_mnemonic_activate".}
-proc gtk_window_set_mnemonic_modifier*(window: PGtkWindow,
-                                       modifier: TGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_set_mnemonic_modifier".}
-proc gtk_window_get_mnemonic_modifier*(window: PGtkWindow): TGdkModifierType{.
-    cdecl, dynlib: gtklib, importc: "gtk_window_get_mnemonic_modifier".}
-proc gtk_window_present*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_present".}
-proc gtk_window_iconify*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_iconify".}
-proc gtk_window_deiconify*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_deiconify".}
-proc gtk_window_stick*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_stick".}
-proc gtk_window_unstick*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_unstick".}
-proc gtk_window_maximize*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_maximize".}
-proc gtk_window_unmaximize*(window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_unmaximize".}
-proc gtk_window_begin_resize_drag*(window: PGtkWindow, edge: TGdkWindowEdge,
-                                   button: gint, root_x: gint, root_y: gint,
-                                   timestamp: guint32){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_begin_resize_drag".}
-proc gtk_window_begin_move_drag*(window: PGtkWindow, button: gint, root_x: gint,
-                                 root_y: gint, timestamp: guint32){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_begin_move_drag".}
-proc gtk_window_set_default_size*(window: PGtkWindow, width: gint, height: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_set_default_size".}
-proc gtk_window_get_default_size*(window: PGtkWindow, width: Pgint,
-                                  height: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_get_default_size".}
-proc gtk_window_resize*(window: PGtkWindow, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_resize".}
-proc gtk_window_get_size*(window: PGtkWindow, width: Pgint, height: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_get_size".}
-proc gtk_window_move*(window: PGtkWindow, x: gint, y: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_move".}
-proc gtk_window_get_position*(window: PGtkWindow, root_x: Pgint, root_y: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_window_get_position".}
-proc gtk_window_parse_geometry*(window: PGtkWindow, geometry: cstring): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_window_parse_geometry".}
-proc gtk_window_reshow_with_initial_size*(window: PGtkWindow){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_reshow_with_initial_size".}
-proc gtk_window_group_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_group_get_type".}
-proc gtk_window_group_new*(): PGtkWindowGroup{.cdecl, dynlib: gtklib,
-    importc: "gtk_window_group_new".}
-proc gtk_window_group_add_window*(window_group: PGtkWindowGroup,
-                                  window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_group_add_window".}
-proc gtk_window_group_remove_window*(window_group: PGtkWindowGroup,
-                                     window: PGtkWindow){.cdecl, dynlib: gtklib,
-    importc: "gtk_window_group_remove_window".}
-proc gtk_window_set_default_icon_name*(name: cstring) {.
-    cdecl, dynlib: gtklib, importc.}
-proc gtk_window_internal_set_focus*(window: PGtkWindow, focus: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "_gtk_window_internal_set_focus".}
-proc gtk_window_remove_embedded_xid*(window: PGtkWindow, xid: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_remove_embedded_xid".}
-proc gtk_window_add_embedded_xid*(window: PGtkWindow, xid: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_window_add_embedded_xid".}
-proc gtk_window_reposition*(window: PGtkWindow, x: gint, y: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_window_reposition".}
-proc gtk_window_constrain_size*(window: PGtkWindow, width: gint, height: gint,
-                                  new_width: Pgint, new_height: Pgint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_window_constrain_size".}
-proc gtk_window_get_group*(window: PGtkWindow): PGtkWindowGroup{.cdecl,
-    dynlib: gtklib, importc: "_gtk_window_get_group".}
-proc gtk_window_activate_key*(window: PGtkWindow, event: PGdkEventKey): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_window_activate_key".}
-proc gtk_window_keys_foreach*(window: PGtkWindow,
-                                func: TGtkWindowKeysForeachFunc,
-                                func_data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "_gtk_window_keys_foreach".}
-proc gtk_window_query_nonaccels*(window: PGtkWindow, accel_key: guint,
-                                   accel_mods: TGdkModifierType): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_window_query_nonaccels".}
-const
-  bm_TGtkLabel_jtype* = 0x00000003'i16
-  bp_TGtkLabel_jtype* = 0'i16
-  bm_TGtkLabel_wrap* = 0x00000004'i16
-  bp_TGtkLabel_wrap* = 2'i16
-  bm_TGtkLabel_use_underline* = 0x00000008'i16
-  bp_TGtkLabel_use_underline* = 3'i16
-  bm_TGtkLabel_use_markup* = 0x00000010'i16
-  bp_TGtkLabel_use_markup* = 4'i16
-
-proc GTK_TYPE_LABEL*(): GType
-proc GTK_LABEL*(obj: pointer): PGtkLabel
-proc GTK_LABEL_CLASS*(klass: pointer): PGtkLabelClass
-proc GTK_IS_LABEL*(obj: pointer): bool
-proc GTK_IS_LABEL_CLASS*(klass: pointer): bool
-proc GTK_LABEL_GET_CLASS*(obj: pointer): PGtkLabelClass
-proc jtype*(a: var TGtkLabel): guint
-proc set_jtype*(a: var TGtkLabel, `jtype`: guint)
-proc wrap*(a: var TGtkLabel): guint
-proc set_wrap*(a: var TGtkLabel, `wrap`: guint)
-proc use_underline*(a: var TGtkLabel): guint
-proc set_use_underline*(a: var TGtkLabel, `use_underline`: guint)
-proc use_markup*(a: var TGtkLabel): guint
-proc set_use_markup*(a: var TGtkLabel, `use_markup`: guint)
-proc gtk_label_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_label_get_type".}
-proc gtk_label_new*(str: cstring): PGtkLabel {.cdecl, dynlib: gtklib,
-    importc: "gtk_label_new".}
-proc gtk_label_new_with_mnemonic*(str: cstring): PGtkLabel {.cdecl,
-    dynlib: gtklib, importc: "gtk_label_new_with_mnemonic".}
-proc gtk_label_set_text*(`label`: PGtkLabel, str: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_text".}
-proc gtk_label_get_text*(`label`: PGtkLabel): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_label_get_text".}
-proc gtk_label_set_attributes*(`label`: PGtkLabel, attrs: PPangoAttrList){.
-    cdecl, dynlib: gtklib, importc: "gtk_label_set_attributes".}
-proc gtk_label_get_attributes*(`label`: PGtkLabel): PPangoAttrList{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_attributes".}
-proc gtk_label_set_label*(`label`: PGtkLabel, str: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_label".}
-proc gtk_label_get_label*(`label`: PGtkLabel): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_label_get_label".}
-proc gtk_label_set_markup*(`label`: PGtkLabel, str: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_markup".}
-proc gtk_label_set_use_markup*(`label`: PGtkLabel, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_use_markup".}
-proc gtk_label_get_use_markup*(`label`: PGtkLabel): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_use_markup".}
-proc gtk_label_set_use_underline*(`label`: PGtkLabel, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_use_underline".}
-proc gtk_label_get_use_underline*(`label`: PGtkLabel): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_use_underline".}
-proc gtk_label_set_markup_with_mnemonic*(`label`: PGtkLabel, str: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_label_set_markup_with_mnemonic".}
-proc gtk_label_get_mnemonic_keyval*(`label`: PGtkLabel): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_mnemonic_keyval".}
-proc gtk_label_set_mnemonic_widget*(`label`: PGtkLabel, widget: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_label_set_mnemonic_widget".}
-proc gtk_label_get_mnemonic_widget*(`label`: PGtkLabel): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_mnemonic_widget".}
-proc gtk_label_set_text_with_mnemonic*(`label`: PGtkLabel, str: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_text_with_mnemonic".}
-proc gtk_label_set_justify*(`label`: PGtkLabel, jtype: TGtkJustification){.
-    cdecl, dynlib: gtklib, importc: "gtk_label_set_justify".}
-proc gtk_label_get_justify*(`label`: PGtkLabel): TGtkJustification{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_justify".}
-proc gtk_label_set_pattern*(`label`: PGtkLabel, pattern: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_pattern".}
-proc gtk_label_set_line_wrap*(`label`: PGtkLabel, wrap: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_line_wrap".}
-proc gtk_label_get_line_wrap*(`label`: PGtkLabel): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_line_wrap".}
-proc gtk_label_set_selectable*(`label`: PGtkLabel, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_label_set_selectable".}
-proc gtk_label_get_selectable*(`label`: PGtkLabel): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_selectable".}
-proc gtk_label_select_region*(`label`: PGtkLabel, start_offset: gint,
-                              end_offset: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_label_select_region".}
-proc gtk_label_get_selection_bounds*(`label`: PGtkLabel, start: Pgint,
-                                     theEnd: Pgint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_selection_bounds".}
-proc gtk_label_get_layout*(`label`: PGtkLabel): PPangoLayout{.cdecl,
-    dynlib: gtklib, importc: "gtk_label_get_layout".}
-proc gtk_label_get_layout_offsets*(`label`: PGtkLabel, x: Pgint, y: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_label_get_layout_offsets".}
-const
-  bm_TGtkAccelLabelClass_latin1_to_char* = 0x00000001'i16
-  bp_TGtkAccelLabelClass_latin1_to_char* = 0'i16
-
-proc GTK_TYPE_ACCEL_LABEL*(): GType
-proc GTK_ACCEL_LABEL*(obj: pointer): PGtkAccelLabel
-proc GTK_ACCEL_LABEL_CLASS*(klass: pointer): PGtkAccelLabelClass
-proc GTK_IS_ACCEL_LABEL*(obj: pointer): bool
-proc GTK_IS_ACCEL_LABEL_CLASS*(klass: pointer): bool
-proc GTK_ACCEL_LABEL_GET_CLASS*(obj: pointer): PGtkAccelLabelClass
-proc latin1_to_char*(a: var TGtkAccelLabelClass): guint
-proc set_latin1_to_char*(a: var TGtkAccelLabelClass, `latin1_to_char`: guint)
-proc gtk_accel_label_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_label_get_type".}
-proc gtk_accel_label_new*(`string`: cstring): PGtkAccelLabel {.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_label_new".}
-proc gtk_accel_label_get_accel_widget*(accel_label: PGtkAccelLabel): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_label_get_accel_widget".}
-proc gtk_accel_label_get_accel_width*(accel_label: PGtkAccelLabel): guint{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_label_get_accel_width".}
-proc gtk_accel_label_set_accel_widget*(accel_label: PGtkAccelLabel,
-                                       accel_widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_label_set_accel_widget".}
-proc gtk_accel_label_set_accel_closure*(accel_label: PGtkAccelLabel,
-                                        accel_closure: PGClosure){.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_label_set_accel_closure".}
-proc gtk_accel_label_refetch*(accel_label: PGtkAccelLabel): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_label_refetch".}
-proc gtk_accel_map_add_entry*(accel_path: cstring, accel_key: guint,
-                              accel_mods: TGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_accel_map_add_entry".}
-proc gtk_accel_map_lookup_entry*(accel_path: cstring, key: PGtkAccelKey): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_map_lookup_entry".}
-proc gtk_accel_map_change_entry*(accel_path: cstring, accel_key: guint,
-                                 accel_mods: TGdkModifierType, replace: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_map_change_entry".}
-proc gtk_accel_map_load*(file_name: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_map_load".}
-proc gtk_accel_map_save*(file_name: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_map_save".}
-proc gtk_accel_map_foreach*(data: gpointer, foreach_func: TGtkAccelMapForeach){.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_map_foreach".}
-proc gtk_accel_map_load_fd*(fd: gint){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_accel_map_load_fd".}
-proc gtk_accel_map_load_scanner*(scanner: PGScanner){.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_map_load_scanner".}
-proc gtk_accel_map_save_fd*(fd: gint){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_accel_map_save_fd".}
-proc gtk_accel_map_add_filter*(filter_pattern: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_accel_map_add_filter".}
-proc gtk_accel_map_foreach_unfiltered*(data: gpointer,
-                                       foreach_func: TGtkAccelMapForeach){.
-    cdecl, dynlib: gtklib, importc: "gtk_accel_map_foreach_unfiltered".}
-proc gtk_accel_map_init*(){.cdecl, dynlib: gtklib,
-                              importc: "_gtk_accel_map_init".}
-proc gtk_accel_map_add_group*(accel_path: cstring, accel_group: PGtkAccelGroup){.
-    cdecl, dynlib: gtklib, importc: "_gtk_accel_map_add_group".}
-proc gtk_accel_map_remove_group*(accel_path: cstring,
-                                   accel_group: PGtkAccelGroup){.cdecl,
-    dynlib: gtklib, importc: "_gtk_accel_map_remove_group".}
-proc gtk_accel_path_is_valid*(accel_path: cstring): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_accel_path_is_valid".}
-proc GTK_TYPE_ACCESSIBLE*(): GType
-proc GTK_ACCESSIBLE*(obj: pointer): PGtkAccessible
-proc GTK_ACCESSIBLE_CLASS*(klass: pointer): PGtkAccessibleClass
-proc GTK_IS_ACCESSIBLE*(obj: pointer): bool
-proc GTK_IS_ACCESSIBLE_CLASS*(klass: pointer): bool
-proc GTK_ACCESSIBLE_GET_CLASS*(obj: pointer): PGtkAccessibleClass
-proc gtk_accessible_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_accessible_get_type".}
-proc gtk_accessible_connect_widget_destroyed*(accessible: PGtkAccessible){.
-    cdecl, dynlib: gtklib, importc: "gtk_accessible_connect_widget_destroyed".}
-proc GTK_TYPE_ADJUSTMENT*(): GType
-proc GTK_ADJUSTMENT*(obj: pointer): PGtkAdjustment
-proc GTK_ADJUSTMENT_CLASS*(klass: pointer): PGtkAdjustmentClass
-proc GTK_IS_ADJUSTMENT*(obj: pointer): bool
-proc GTK_IS_ADJUSTMENT_CLASS*(klass: pointer): bool
-proc GTK_ADJUSTMENT_GET_CLASS*(obj: pointer): PGtkAdjustmentClass
-proc gtk_adjustment_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_adjustment_get_type".}
-proc gtk_adjustment_new*(value: gdouble, lower: gdouble, upper: gdouble,
-                         step_increment: gdouble, page_increment: gdouble,
-                         page_size: gdouble): PGtkAdjustment {.cdecl, dynlib: gtklib,
-    importc: "gtk_adjustment_new".}
-proc gtk_adjustment_changed*(adjustment: PGtkAdjustment){.cdecl, dynlib: gtklib,
-    importc: "gtk_adjustment_changed".}
-proc gtk_adjustment_value_changed*(adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_adjustment_value_changed".}
-proc gtk_adjustment_clamp_page*(adjustment: PGtkAdjustment, lower: gdouble,
-                                upper: gdouble){.cdecl, dynlib: gtklib,
-    importc: "gtk_adjustment_clamp_page".}
-proc gtk_adjustment_get_value*(adjustment: PGtkAdjustment): gdouble{.cdecl,
-    dynlib: gtklib, importc: "gtk_adjustment_get_value".}
-proc gtk_adjustment_set_value*(adjustment: PGtkAdjustment, value: gdouble){.
-    cdecl, dynlib: gtklib, importc: "gtk_adjustment_set_value".}
-proc GTK_TYPE_ALIGNMENT*(): GType
-proc GTK_ALIGNMENT*(obj: pointer): PGtkAlignment
-proc GTK_ALIGNMENT_CLASS*(klass: pointer): PGtkAlignmentClass
-proc GTK_IS_ALIGNMENT*(obj: pointer): bool
-proc GTK_IS_ALIGNMENT_CLASS*(klass: pointer): bool
-proc GTK_ALIGNMENT_GET_CLASS*(obj: pointer): PGtkAlignmentClass
-proc gtk_alignment_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_alignment_get_type".}
-proc gtk_alignment_new*(xalign: gfloat, yalign: gfloat, xscale: gfloat,
-                        yscale: gfloat): PGtkAlignment {.cdecl, dynlib: gtklib,
-    importc: "gtk_alignment_new".}
-proc gtk_alignment_set*(alignment: PGtkAlignment, xalign: gfloat,
-                        yalign: gfloat, xscale: gfloat, yscale: gfloat){.cdecl,
-    dynlib: gtklib, importc: "gtk_alignment_set".}
-proc GTK_TYPE_FRAME*(): GType
-proc GTK_FRAME*(obj: pointer): PGtkFrame
-proc GTK_FRAME_CLASS*(klass: pointer): PGtkFrameClass
-proc GTK_IS_FRAME*(obj: pointer): bool
-proc GTK_IS_FRAME_CLASS*(klass: pointer): bool
-proc GTK_FRAME_GET_CLASS*(obj: pointer): PGtkFrameClass
-proc gtk_frame_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_frame_get_type".}
-proc gtk_frame_new*(`label`: cstring): PGtkFrame {.cdecl, dynlib: gtklib,
-    importc: "gtk_frame_new".}
-proc gtk_frame_set_label*(frame: PGtkFrame, `label`: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_frame_set_label".}
-proc gtk_frame_get_label*(frame: PGtkFrame): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_frame_get_label".}
-proc gtk_frame_set_label_widget*(frame: PGtkFrame, label_widget: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_frame_set_label_widget".}
-proc gtk_frame_get_label_widget*(frame: PGtkFrame): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_frame_get_label_widget".}
-proc gtk_frame_set_label_align*(frame: PGtkFrame, xalign: gfloat, yalign: gfloat){.
-    cdecl, dynlib: gtklib, importc: "gtk_frame_set_label_align".}
-proc gtk_frame_get_label_align*(frame: PGtkFrame, xalign: Pgfloat,
-                                yalign: Pgfloat){.cdecl, dynlib: gtklib,
-    importc: "gtk_frame_get_label_align".}
-proc gtk_frame_set_shadow_type*(frame: PGtkFrame, thetype: TGtkShadowType){.
-    cdecl, dynlib: gtklib, importc: "gtk_frame_set_shadow_type".}
-proc gtk_frame_get_shadow_type*(frame: PGtkFrame): TGtkShadowType{.cdecl,
-    dynlib: gtklib, importc: "gtk_frame_get_shadow_type".}
-proc GTK_TYPE_ASPECT_FRAME*(): GType
-proc GTK_ASPECT_FRAME*(obj: pointer): PGtkAspectFrame
-proc GTK_ASPECT_FRAME_CLASS*(klass: pointer): PGtkAspectFrameClass
-proc GTK_IS_ASPECT_FRAME*(obj: pointer): bool
-proc GTK_IS_ASPECT_FRAME_CLASS*(klass: pointer): bool
-proc GTK_ASPECT_FRAME_GET_CLASS*(obj: pointer): PGtkAspectFrameClass
-proc gtk_aspect_frame_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_aspect_frame_get_type".}
-proc gtk_aspect_frame_new*(`label`: cstring, xalign: gfloat, yalign: gfloat,
-                           ratio: gfloat, obey_child: gboolean): PGtkAspectFrame {.
-    cdecl, dynlib: gtklib, importc: "gtk_aspect_frame_new".}
-proc gtk_aspect_frame_set*(aspect_frame: PGtkAspectFrame, xalign: gfloat,
-                           yalign: gfloat, ratio: gfloat, obey_child: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_aspect_frame_set".}
-proc GTK_TYPE_ARROW*(): GType
-proc GTK_ARROW*(obj: pointer): PGtkArrow
-proc GTK_ARROW_CLASS*(klass: pointer): PGtkArrowClass
-proc GTK_IS_ARROW*(obj: pointer): bool
-proc GTK_IS_ARROW_CLASS*(klass: pointer): bool
-proc GTK_ARROW_GET_CLASS*(obj: pointer): PGtkArrowClass
-proc gtk_arrow_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_arrow_get_type".}
-proc gtk_arrow_new*(arrow_type: TGtkArrowType, shadow_type: TGtkShadowType): PGtkArrow{.
-    cdecl, dynlib: gtklib, importc: "gtk_arrow_new".}
-proc gtk_arrow_set*(arrow: PGtkArrow, arrow_type: TGtkArrowType,
-                    shadow_type: TGtkShadowType){.cdecl, dynlib: gtklib,
-    importc: "gtk_arrow_set".}
-const
-  bm_TGtkBindingSet_parsed* = 0x00000001'i16
-  bp_TGtkBindingSet_parsed* = 0'i16
-  bm_TGtkBindingEntry_destroyed* = 0x00000001'i16
-  bp_TGtkBindingEntry_destroyed* = 0'i16
-  bm_TGtkBindingEntry_in_emission* = 0x00000002'i16
-  bp_TGtkBindingEntry_in_emission* = 1'i16
-
-proc gtk_binding_entry_add*(binding_set: PGtkBindingSet, keyval: guint,
-                            modifiers: TGdkModifierType)
-proc parsed*(a: var TGtkBindingSet): guint
-proc set_parsed*(a: var TGtkBindingSet, `parsed`: guint)
-proc destroyed*(a: var TGtkBindingEntry): guint
-proc set_destroyed*(a: var TGtkBindingEntry, `destroyed`: guint)
-proc in_emission*(a: var TGtkBindingEntry): guint
-proc set_in_emission*(a: var TGtkBindingEntry, `in_emission`: guint)
-proc gtk_binding_set_new*(set_name: cstring): PGtkBindingSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_set_new".}
-proc gtk_binding_set_by_class*(object_class: gpointer): PGtkBindingSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_set_by_class".}
-proc gtk_binding_set_find*(set_name: cstring): PGtkBindingSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_set_find".}
-proc gtk_bindings_activate*(anObject: PGtkObject, keyval: guint,
-                            modifiers: TGdkModifierType): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_bindings_activate".}
-proc gtk_binding_set_activate*(binding_set: PGtkBindingSet, keyval: guint,
-                               modifiers: TGdkModifierType, anObject: PGtkObject): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_binding_set_activate".}
-proc gtk_binding_entry_clear*(binding_set: PGtkBindingSet, keyval: guint,
-                              modifiers: TGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_entry_clear".}
-proc gtk_binding_set_add_path*(binding_set: PGtkBindingSet,
-                               path_type: TGtkPathType, path_pattern: cstring,
-                               priority: TGtkPathPriorityType){.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_set_add_path".}
-proc gtk_binding_entry_remove*(binding_set: PGtkBindingSet, keyval: guint,
-                               modifiers: TGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_entry_remove".}
-proc gtk_binding_entry_add_signall*(binding_set: PGtkBindingSet, keyval: guint,
-                                    modifiers: TGdkModifierType,
-                                    signal_name: cstring, binding_args: PGSList){.
-    cdecl, dynlib: gtklib, importc: "gtk_binding_entry_add_signall".}
-proc gtk_binding_parse_binding*(scanner: PGScanner): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_binding_parse_binding".}
-proc gtk_bindings_activate_event*(anObject: PGtkObject, event: PGdkEventKey): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_bindings_activate_event".}
-proc gtk_binding_reset_parsed*(){.cdecl, dynlib: gtklib,
-                                  importc: "_gtk_binding_reset_parsed".}
-const
-  bm_TGtkBox_homogeneous* = 0x00000001'i16
-  bp_TGtkBox_homogeneous* = 0'i16
-  bm_TGtkBoxChild_expand* = 0x00000001'i16
-  bp_TGtkBoxChild_expand* = 0'i16
-  bm_TGtkBoxChild_fill* = 0x00000002'i16
-  bp_TGtkBoxChild_fill* = 1'i16
-  bm_TGtkBoxChild_pack* = 0x00000004'i16
-  bp_TGtkBoxChild_pack* = 2'i16
-  bm_TGtkBoxChild_is_secondary* = 0x00000008'i16
-  bp_TGtkBoxChild_is_secondary* = 3'i16
-
-proc GTK_TYPE_BOX*(): GType
-proc GTK_BOX*(obj: pointer): PGtkBox
-proc GTK_BOX_CLASS*(klass: pointer): PGtkBoxClass
-proc GTK_IS_BOX*(obj: pointer): bool
-proc GTK_IS_BOX_CLASS*(klass: pointer): bool
-proc GTK_BOX_GET_CLASS*(obj: pointer): PGtkBoxClass
-proc homogeneous*(a: var TGtkBox): guint
-proc set_homogeneous*(a: var TGtkBox, `homogeneous`: guint)
-proc expand*(a: var TGtkBoxChild): guint
-proc set_expand*(a: var TGtkBoxChild, `expand`: guint)
-proc fill*(a: var TGtkBoxChild): guint
-proc set_fill*(a: var TGtkBoxChild, `fill`: guint)
-proc pack*(a: var TGtkBoxChild): guint
-proc set_pack*(a: var TGtkBoxChild, `pack`: guint)
-proc is_secondary*(a: var TGtkBoxChild): guint
-proc set_is_secondary*(a: var TGtkBoxChild, `is_secondary`: guint)
-proc gtk_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_box_get_type".}
-proc gtk_box_pack_start*(box: PGtkBox, child: PGtkWidget, expand: gboolean,
-                         fill: gboolean, padding: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_box_pack_start".}
-proc gtk_box_pack_end*(box: PGtkBox, child: PGtkWidget, expand: gboolean,
-                       fill: gboolean, padding: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_box_pack_end".}
-proc gtk_box_pack_start_defaults*(box: PGtkBox, widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_box_pack_start_defaults".}
-proc gtk_box_pack_end_defaults*(box: PGtkBox, widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_box_pack_end_defaults".}
-proc gtk_box_set_homogeneous*(box: PGtkBox, homogeneous: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_box_set_homogeneous".}
-proc gtk_box_get_homogeneous*(box: PGtkBox): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_box_get_homogeneous".}
-proc gtk_box_set_spacing*(box: PGtkBox, spacing: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_box_set_spacing".}
-proc gtk_box_get_spacing*(box: PGtkBox): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_box_get_spacing".}
-proc gtk_box_reorder_child*(box: PGtkBox, child: PGtkWidget, position: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_box_reorder_child".}
-proc gtk_box_query_child_packing*(box: PGtkBox, child: PGtkWidget,
-                                  expand: Pgboolean, fill: Pgboolean,
-                                  padding: Pguint, pack_type: PGtkPackType){.
-    cdecl, dynlib: gtklib, importc: "gtk_box_query_child_packing".}
-proc gtk_box_set_child_packing*(box: PGtkBox, child: PGtkWidget,
-                                expand: gboolean, fill: gboolean,
-                                padding: guint, pack_type: TGtkPackType){.cdecl,
-    dynlib: gtklib, importc: "gtk_box_set_child_packing".}
-const
-  GTK_BUTTONBOX_DEFAULT* = - (1)
-
-proc GTK_TYPE_BUTTON_BOX*(): GType
-proc GTK_BUTTON_BOX*(obj: pointer): PGtkButtonBox
-proc GTK_BUTTON_BOX_CLASS*(klass: pointer): PGtkButtonBoxClass
-proc GTK_IS_BUTTON_BOX*(obj: pointer): bool
-proc GTK_IS_BUTTON_BOX_CLASS*(klass: pointer): bool
-proc GTK_BUTTON_BOX_GET_CLASS*(obj: pointer): PGtkButtonBoxClass
-proc gtk_button_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_button_box_get_type".}
-proc gtk_button_box_get_layout*(widget: PGtkButtonBox): TGtkButtonBoxStyle{.
-    cdecl, dynlib: gtklib, importc: "gtk_button_box_get_layout".}
-proc gtk_button_box_set_layout*(widget: PGtkButtonBox,
-                                layout_style: TGtkButtonBoxStyle){.cdecl,
-    dynlib: gtklib, importc: "gtk_button_box_set_layout".}
-proc gtk_button_box_set_child_secondary*(widget: PGtkButtonBox,
-    child: PGtkWidget, is_secondary: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_box_set_child_secondary".}
-proc gtk_button_box_child_requisition*(widget: PGtkWidget,
-    nvis_children: var int32, nvis_secondaries: var int32, width: var int32,
-    height: var int32){.cdecl, dynlib: gtklib,
-                       importc: "_gtk_button_box_child_requisition".}
-const
-  bm_TGtkButton_constructed* = 0x00000001'i16
-  bp_TGtkButton_constructed* = 0'i16
-  bm_TGtkButton_in_button* = 0x00000002'i16
-  bp_TGtkButton_in_button* = 1'i16
-  bm_TGtkButton_button_down* = 0x00000004'i16
-  bp_TGtkButton_button_down* = 2'i16
-  bm_TGtkButton_relief* = 0x00000018'i16
-  bp_TGtkButton_relief* = 3'i16
-  bm_TGtkButton_use_underline* = 0x00000020'i16
-  bp_TGtkButton_use_underline* = 5'i16
-  bm_TGtkButton_use_stock* = 0x00000040'i16
-  bp_TGtkButton_use_stock* = 6'i16
-  bm_TGtkButton_depressed* = 0x00000080'i16
-  bp_TGtkButton_depressed* = 7'i16
-  bm_TGtkButton_depress_on_activate* = 0x00000100'i16
-  bp_TGtkButton_depress_on_activate* = 8'i16
-
-proc GTK_TYPE_BUTTON*(): GType
-proc GTK_BUTTON*(obj: pointer): PGtkButton
-proc GTK_BUTTON_CLASS*(klass: pointer): PGtkButtonClass
-proc GTK_IS_BUTTON*(obj: pointer): bool
-proc GTK_IS_BUTTON_CLASS*(klass: pointer): bool
-proc GTK_BUTTON_GET_CLASS*(obj: pointer): PGtkButtonClass
-proc constructed*(a: var TGtkButton): guint
-proc set_constructed*(a: var TGtkButton, `constructed`: guint)
-proc in_button*(a: var TGtkButton): guint
-proc set_in_button*(a: var TGtkButton, `in_button`: guint)
-proc button_down*(a: var TGtkButton): guint
-proc set_button_down*(a: var TGtkButton, `button_down`: guint)
-proc relief*(a: var TGtkButton): guint
-proc set_relief*(a: var TGtkButton, `relief`: guint)
-proc use_underline*(a: var TGtkButton): guint
-proc set_use_underline*(a: var TGtkButton, `use_underline`: guint)
-proc use_stock*(a: var TGtkButton): guint
-proc set_use_stock*(a: var TGtkButton, `use_stock`: guint)
-proc depressed*(a: var TGtkButton): guint
-proc set_depressed*(a: var TGtkButton, `depressed`: guint)
-proc depress_on_activate*(a: var TGtkButton): guint
-proc set_depress_on_activate*(a: var TGtkButton, `depress_on_activate`: guint)
-proc gtk_button_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_button_get_type".}
-proc gtk_button_new*(): PGtkButton {.cdecl, dynlib: gtklib,
-                                    importc: "gtk_button_new".}
-proc gtk_button_new_with_label*(`label`: cstring): PGtkButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_button_new_with_label".}
-proc gtk_button_new_from_stock*(stock_id: cstring): PGtkButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_button_new_from_stock".}
-proc gtk_button_new_with_mnemonic*(`label`: cstring): PGtkButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_button_new_with_mnemonic".}
-proc gtk_button_pressed*(button: PGtkButton){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_pressed".}
-proc gtk_button_released*(button: PGtkButton){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_released".}
-proc gtk_button_clicked*(button: PGtkButton){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_clicked".}
-proc gtk_button_enter*(button: PGtkButton){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_enter".}
-proc gtk_button_leave*(button: PGtkButton){.cdecl, dynlib: gtklib,
-    importc: "gtk_button_leave".}
-proc gtk_button_set_relief*(button: PGtkButton, newstyle: TGtkReliefStyle){.
-    cdecl, dynlib: gtklib, importc: "gtk_button_set_relief".}
-proc gtk_button_get_relief*(button: PGtkButton): TGtkReliefStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_button_get_relief".}
-proc gtk_button_set_label*(button: PGtkButton, `label`: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_button_set_label".}
-proc gtk_button_get_label*(button: PGtkButton): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_button_get_label".}
-proc gtk_button_set_use_underline*(button: PGtkButton, use_underline: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_button_set_use_underline".}
-proc gtk_button_get_use_underline*(button: PGtkButton): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_button_get_use_underline".}
-proc gtk_button_set_use_stock*(button: PGtkButton, use_stock: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_button_set_use_stock".}
-proc gtk_button_get_use_stock*(button: PGtkButton): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_button_get_use_stock".}
-proc gtk_button_set_depressed*(button: PGtkButton, depressed: gboolean){.
-    cdecl, dynlib: gtklib, importc: "_gtk_button_set_depressed".}
-proc gtk_button_paint*(button: PGtkButton, area: PGdkRectangle,
-                         state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                         main_detail: cstring, default_detail: cstring){.cdecl,
-    dynlib: gtklib, importc: "_gtk_button_paint".}
-proc gtk_button_set_image*(button: PGtkButton, image: PGtkWidget) {.cdecl,
-    dynlib: gtklib, importc.}
-proc gtk_button_get_image*(button: PGtkButton): PGtkWidget {.cdecl, 
-    dynlib: gtklib, importc.}
-    
-const
-  GTK_CALENDAR_SHOW_HEADING* = 1 shl 0
-  GTK_CALENDAR_SHOW_DAY_NAMES* = 1 shl 1
-  GTK_CALENDAR_NO_MONTH_CHANGE* = 1 shl 2
-  GTK_CALENDAR_SHOW_WEEK_NUMBERS* = 1 shl 3
-  GTK_CALENDAR_WEEK_START_MONDAY* = 1 shl 4
-
-proc GTK_TYPE_CALENDAR*(): GType
-proc GTK_CALENDAR*(obj: pointer): PGtkCalendar
-proc GTK_CALENDAR_CLASS*(klass: pointer): PGtkCalendarClass
-proc GTK_IS_CALENDAR*(obj: pointer): bool
-proc GTK_IS_CALENDAR_CLASS*(klass: pointer): bool
-proc GTK_CALENDAR_GET_CLASS*(obj: pointer): PGtkCalendarClass
-proc gtk_calendar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_get_type".}
-proc gtk_calendar_new*(): PGtkCalendar {.cdecl, dynlib: gtklib,
-                                      importc: "gtk_calendar_new".}
-proc gtk_calendar_select_month*(calendar: PGtkCalendar, month: guint,
-                                year: guint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_select_month".}
-proc gtk_calendar_select_day*(calendar: PGtkCalendar, day: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_calendar_select_day".}
-proc gtk_calendar_mark_day*(calendar: PGtkCalendar, day: guint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_calendar_mark_day".}
-proc gtk_calendar_unmark_day*(calendar: PGtkCalendar, day: guint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_calendar_unmark_day".}
-proc gtk_calendar_clear_marks*(calendar: PGtkCalendar){.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_clear_marks".}
-proc gtk_calendar_display_options*(calendar: PGtkCalendar,
-                                   flags: TGtkCalendarDisplayOptions){.cdecl,
-    dynlib: gtklib, importc: "gtk_calendar_display_options".}
-proc gtk_calendar_get_date*(calendar: PGtkCalendar, year: Pguint, month: Pguint,
-                            day: Pguint){.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_get_date".}
-proc gtk_calendar_freeze*(calendar: PGtkCalendar){.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_freeze".}
-proc gtk_calendar_thaw*(calendar: PGtkCalendar){.cdecl, dynlib: gtklib,
-    importc: "gtk_calendar_thaw".}
-proc GTK_TYPE_CELL_EDITABLE*(): GType
-proc GTK_CELL_EDITABLE*(obj: pointer): PGtkCellEditable
-proc GTK_CELL_EDITABLE_CLASS*(obj: pointer): PGtkCellEditableIface
-proc GTK_IS_CELL_EDITABLE*(obj: pointer): bool
-proc GTK_CELL_EDITABLE_GET_IFACE*(obj: pointer): PGtkCellEditableIface
-proc gtk_cell_editable_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_editable_get_type".}
-proc gtk_cell_editable_start_editing*(cell_editable: PGtkCellEditable,
-                                      event: PGdkEvent){.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_editable_start_editing".}
-proc gtk_cell_editable_editing_done*(cell_editable: PGtkCellEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_cell_editable_editing_done".}
-proc gtk_cell_editable_remove_widget*(cell_editable: PGtkCellEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_cell_editable_remove_widget".}
-const
-  GTK_CELL_RENDERER_SELECTED* = 1 shl 0
-  GTK_CELL_RENDERER_PRELIT* = 1 shl 1
-  GTK_CELL_RENDERER_INSENSITIVE* = 1 shl 2
-  GTK_CELL_RENDERER_SORTED* = 1 shl 3
-
-const
-  bm_TGtkCellRenderer_mode* = 0x00000003'i16
-  bp_TGtkCellRenderer_mode* = 0'i16
-  bm_TGtkCellRenderer_visible* = 0x00000004'i16
-  bp_TGtkCellRenderer_visible* = 2'i16
-  bm_TGtkCellRenderer_is_expander* = 0x00000008'i16
-  bp_TGtkCellRenderer_is_expander* = 3'i16
-  bm_TGtkCellRenderer_is_expanded* = 0x00000010'i16
-  bp_TGtkCellRenderer_is_expanded* = 4'i16
-  bm_TGtkCellRenderer_cell_background_set* = 0x00000020'i16
-  bp_TGtkCellRenderer_cell_background_set* = 5'i16
-
-proc GTK_TYPE_CELL_RENDERER*(): GType
-proc GTK_CELL_RENDERER*(obj: pointer): PGtkCellRenderer
-proc GTK_CELL_RENDERER_CLASS*(klass: pointer): PGtkCellRendererClass
-proc GTK_IS_CELL_RENDERER*(obj: pointer): bool
-proc GTK_IS_CELL_RENDERER_CLASS*(klass: pointer): bool
-proc GTK_CELL_RENDERER_GET_CLASS*(obj: pointer): PGtkCellRendererClass
-proc mode*(a: var TGtkCellRenderer): guint
-proc set_mode*(a: var TGtkCellRenderer, `mode`: guint)
-proc visible*(a: var TGtkCellRenderer): guint
-proc set_visible*(a: var TGtkCellRenderer, `visible`: guint)
-proc is_expander*(a: var TGtkCellRenderer): guint
-proc set_is_expander*(a: var TGtkCellRenderer, `is_expander`: guint)
-proc is_expanded*(a: var TGtkCellRenderer): guint
-proc set_is_expanded*(a: var TGtkCellRenderer, `is_expanded`: guint)
-proc cell_background_set*(a: var TGtkCellRenderer): guint
-proc set_cell_background_set*(a: var TGtkCellRenderer,
-                              `cell_background_set`: guint)
-proc gtk_cell_renderer_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_get_type".}
-proc gtk_cell_renderer_get_size*(cell: PGtkCellRenderer, widget: PGtkWidget,
-                                 cell_area: PGdkRectangle, x_offset: Pgint,
-                                 y_offset: Pgint, width: Pgint, height: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_cell_renderer_get_size".}
-proc gtk_cell_renderer_render*(cell: PGtkCellRenderer, window: PGdkWindow,
-                               widget: PGtkWidget,
-                               background_area: PGdkRectangle,
-                               cell_area: PGdkRectangle,
-                               expose_area: PGdkRectangle,
-                               flags: TGtkCellRendererState){.cdecl,
-    dynlib: gtklib, importc: "gtk_cell_renderer_render".}
-proc gtk_cell_renderer_activate*(cell: PGtkCellRenderer, event: PGdkEvent,
-                                 widget: PGtkWidget, path: cstring,
-                                 background_area: PGdkRectangle,
-                                 cell_area: PGdkRectangle,
-                                 flags: TGtkCellRendererState): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_cell_renderer_activate".}
-proc gtk_cell_renderer_start_editing*(cell: PGtkCellRenderer, event: PGdkEvent,
-                                      widget: PGtkWidget, path: cstring,
-                                      background_area: PGdkRectangle,
-                                      cell_area: PGdkRectangle,
-                                      flags: TGtkCellRendererState): PGtkCellEditable{.
-    cdecl, dynlib: gtklib, importc: "gtk_cell_renderer_start_editing".}
-proc gtk_cell_renderer_set_fixed_size*(cell: PGtkCellRenderer, width: gint,
-                                       height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_set_fixed_size".}
-proc gtk_cell_renderer_get_fixed_size*(cell: PGtkCellRenderer, width: Pgint,
-                                       height: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_get_fixed_size".}
-const
-  bm_TGtkCellRendererText_strikethrough* = 0x00000001'i16
-  bp_TGtkCellRendererText_strikethrough* = 0'i16
-  bm_TGtkCellRendererText_editable* = 0x00000002'i16
-  bp_TGtkCellRendererText_editable* = 1'i16
-  bm_TGtkCellRendererText_scale_set* = 0x00000004'i16
-  bp_TGtkCellRendererText_scale_set* = 2'i16
-  bm_TGtkCellRendererText_foreground_set* = 0x00000008'i16
-  bp_TGtkCellRendererText_foreground_set* = 3'i16
-  bm_TGtkCellRendererText_background_set* = 0x00000010'i16
-  bp_TGtkCellRendererText_background_set* = 4'i16
-  bm_TGtkCellRendererText_underline_set* = 0x00000020'i16
-  bp_TGtkCellRendererText_underline_set* = 5'i16
-  bm_TGtkCellRendererText_rise_set* = 0x00000040'i16
-  bp_TGtkCellRendererText_rise_set* = 6'i16
-  bm_TGtkCellRendererText_strikethrough_set* = 0x00000080'i16
-  bp_TGtkCellRendererText_strikethrough_set* = 7'i16
-  bm_TGtkCellRendererText_editable_set* = 0x00000100'i16
-  bp_TGtkCellRendererText_editable_set* = 8'i16
-  bm_TGtkCellRendererText_calc_fixed_height* = 0x00000200'i16
-  bp_TGtkCellRendererText_calc_fixed_height* = 9'i16
-
-proc GTK_TYPE_CELL_RENDERER_TEXT*(): GType
-proc GTK_CELL_RENDERER_TEXT*(obj: pointer): PGtkCellRendererText
-proc GTK_CELL_RENDERER_TEXT_CLASS*(klass: pointer): PGtkCellRendererTextClass
-proc GTK_IS_CELL_RENDERER_TEXT*(obj: pointer): bool
-proc GTK_IS_CELL_RENDERER_TEXT_CLASS*(klass: pointer): bool
-proc GTK_CELL_RENDERER_TEXT_GET_CLASS*(obj: pointer): PGtkCellRendererTextClass
-proc strikethrough*(a: var TGtkCellRendererText): guint
-proc set_strikethrough*(a: var TGtkCellRendererText, `strikethrough`: guint)
-proc editable*(a: var TGtkCellRendererText): guint
-proc set_editable*(a: var TGtkCellRendererText, `editable`: guint)
-proc scale_set*(a: var TGtkCellRendererText): guint
-proc set_scale_set*(a: var TGtkCellRendererText, `scale_set`: guint)
-proc foreground_set*(a: var TGtkCellRendererText): guint
-proc set_foreground_set*(a: var TGtkCellRendererText, `foreground_set`: guint)
-proc background_set*(a: var TGtkCellRendererText): guint
-proc set_background_set*(a: var TGtkCellRendererText, `background_set`: guint)
-proc underline_set*(a: var TGtkCellRendererText): guint
-proc set_underline_set*(a: var TGtkCellRendererText, `underline_set`: guint)
-proc rise_set*(a: var TGtkCellRendererText): guint
-proc set_rise_set*(a: var TGtkCellRendererText, `rise_set`: guint)
-proc strikethrough_set*(a: var TGtkCellRendererText): guint
-proc set_strikethrough_set*(a: var TGtkCellRendererText,
-                            `strikethrough_set`: guint)
-proc editable_set*(a: var TGtkCellRendererText): guint
-proc set_editable_set*(a: var TGtkCellRendererText, `editable_set`: guint)
-proc calc_fixed_height*(a: var TGtkCellRendererText): guint
-proc set_calc_fixed_height*(a: var TGtkCellRendererText,
-                            `calc_fixed_height`: guint)
-proc gtk_cell_renderer_text_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_text_get_type".}
-proc gtk_cell_renderer_text_new*(): PGtkCellRenderer{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_text_new".}
-proc gtk_cell_renderer_text_set_fixed_height_from_font*(
-    renderer: PGtkCellRendererText, number_of_rows: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_cell_renderer_text_set_fixed_height_from_font".}
-const
-  bm_TGtkCellRendererToggle_active* = 0x00000001'i16
-  bp_TGtkCellRendererToggle_active* = 0'i16
-  bm_TGtkCellRendererToggle_activatable* = 0x00000002'i16
-  bp_TGtkCellRendererToggle_activatable* = 1'i16
-  bm_TGtkCellRendererToggle_radio* = 0x00000004'i16
-  bp_TGtkCellRendererToggle_radio* = 2'i16
-
-proc GTK_TYPE_CELL_RENDERER_TOGGLE*(): GType
-proc GTK_CELL_RENDERER_TOGGLE*(obj: pointer): PGtkCellRendererToggle
-proc GTK_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): PGtkCellRendererToggleClass
-proc GTK_IS_CELL_RENDERER_TOGGLE*(obj: pointer): bool
-proc GTK_IS_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): bool
-proc GTK_CELL_RENDERER_TOGGLE_GET_CLASS*(obj: pointer): PGtkCellRendererToggleClass
-proc active*(a: var TGtkCellRendererToggle): guint
-proc set_active*(a: var TGtkCellRendererToggle, `active`: guint)
-proc activatable*(a: var TGtkCellRendererToggle): guint
-proc set_activatable*(a: var TGtkCellRendererToggle, `activatable`: guint)
-proc radio*(a: var TGtkCellRendererToggle): guint
-proc set_radio*(a: var TGtkCellRendererToggle, `radio`: guint)
-proc gtk_cell_renderer_toggle_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_toggle_get_type".}
-proc gtk_cell_renderer_toggle_new*(): PGtkCellRenderer{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_toggle_new".}
-proc gtk_cell_renderer_toggle_get_radio*(toggle: PGtkCellRendererToggle): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_cell_renderer_toggle_get_radio".}
-proc gtk_cell_renderer_toggle_set_radio*(toggle: PGtkCellRendererToggle,
-    radio: gboolean){.cdecl, dynlib: gtklib,
-                      importc: "gtk_cell_renderer_toggle_set_radio".}
-proc gtk_cell_renderer_toggle_get_active*(toggle: PGtkCellRendererToggle): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_cell_renderer_toggle_get_active".}
-proc gtk_cell_renderer_toggle_set_active*(toggle: PGtkCellRendererToggle,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_cell_renderer_toggle_set_active".}
-proc GTK_TYPE_CELL_RENDERER_PIXBUF*(): GType
-proc GTK_CELL_RENDERER_PIXBUF*(obj: pointer): PGtkCellRendererPixbuf
-proc GTK_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): PGtkCellRendererPixbufClass
-proc GTK_IS_CELL_RENDERER_PIXBUF*(obj: pointer): bool
-proc GTK_IS_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): bool
-proc GTK_CELL_RENDERER_PIXBUF_GET_CLASS*(obj: pointer): PGtkCellRendererPixbufClass
-proc gtk_cell_renderer_pixbuf_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_pixbuf_get_type".}
-proc gtk_cell_renderer_pixbuf_new*(): PGtkCellRenderer{.cdecl, dynlib: gtklib,
-    importc: "gtk_cell_renderer_pixbuf_new".}
-proc GTK_TYPE_ITEM*(): GType
-proc GTK_ITEM*(obj: pointer): PGtkItem
-proc GTK_ITEM_CLASS*(klass: pointer): PGtkItemClass
-proc GTK_IS_ITEM*(obj: pointer): bool
-proc GTK_IS_ITEM_CLASS*(klass: pointer): bool
-proc GTK_ITEM_GET_CLASS*(obj: pointer): PGtkItemClass
-proc gtk_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_item_get_type".}
-proc gtk_item_select*(item: PGtkItem){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_item_select".}
-proc gtk_item_deselect*(item: PGtkItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_item_deselect".}
-proc gtk_item_toggle*(item: PGtkItem){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_item_toggle".}
-const
-  bm_TGtkMenuItem_show_submenu_indicator* = 0x00000001'i16
-  bp_TGtkMenuItem_show_submenu_indicator* = 0'i16
-  bm_TGtkMenuItem_submenu_placement* = 0x00000002'i16
-  bp_TGtkMenuItem_submenu_placement* = 1'i16
-  bm_TGtkMenuItem_submenu_direction* = 0x00000004'i16
-  bp_TGtkMenuItem_submenu_direction* = 2'i16
-  bm_TGtkMenuItem_right_justify* = 0x00000008'i16
-  bp_TGtkMenuItem_right_justify* = 3'i16
-  bm_TGtkMenuItem_timer_from_keypress* = 0x00000010'i16
-  bp_TGtkMenuItem_timer_from_keypress* = 4'i16
-  bm_TGtkMenuItemClass_hide_on_activate* = 0x00000001'i16
-  bp_TGtkMenuItemClass_hide_on_activate* = 0'i16
-
-proc GTK_TYPE_MENU_ITEM*(): GType
-proc GTK_MENU_ITEM*(obj: pointer): PGtkMenuItem
-proc GTK_MENU_ITEM_CLASS*(klass: pointer): PGtkMenuItemClass
-proc GTK_IS_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkMenuItemClass
-proc show_submenu_indicator*(a: var TGtkMenuItem): guint
-proc set_show_submenu_indicator*(a: var TGtkMenuItem,
-                                 `show_submenu_indicator`: guint)
-proc submenu_placement*(a: var TGtkMenuItem): guint
-proc set_submenu_placement*(a: var TGtkMenuItem, `submenu_placement`: guint)
-proc submenu_direction*(a: var TGtkMenuItem): guint
-proc set_submenu_direction*(a: var TGtkMenuItem, `submenu_direction`: guint)
-proc right_justify*(a: var TGtkMenuItem): guint
-proc set_right_justify*(a: var TGtkMenuItem, `right_justify`: guint)
-proc timer_from_keypress*(a: var TGtkMenuItem): guint
-proc set_timer_from_keypress*(a: var TGtkMenuItem, `timer_from_keypress`: guint)
-proc hide_on_activate*(a: var TGtkMenuItemClass): guint
-proc set_hide_on_activate*(a: var TGtkMenuItemClass, `hide_on_activate`: guint)
-proc gtk_menu_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_item_get_type".}
-proc gtk_menu_item_new*(): PGtkMenuItem {.cdecl, dynlib: gtklib,
-                                       importc: "gtk_menu_item_new".}
-proc gtk_menu_item_new_with_label*(`label`: cstring): PGtkMenuItem {.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_new_with_label".}
-proc gtk_menu_item_new_with_mnemonic*(`label`: cstring): PGtkMenuItem {.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_new_with_mnemonic".}
-proc gtk_menu_item_set_submenu*(menu_item: PGtkMenuItem, submenu: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_item_set_submenu".}
-proc gtk_menu_item_get_submenu*(menu_item: PGtkMenuItem): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_get_submenu".}
-proc gtk_menu_item_remove_submenu*(menu_item: PGtkMenuItem){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_remove_submenu".}
-proc gtk_menu_item_select*(menu_item: PGtkMenuItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_item_select".}
-proc gtk_menu_item_deselect*(menu_item: PGtkMenuItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_item_deselect".}
-proc gtk_menu_item_activate*(menu_item: PGtkMenuItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_item_activate".}
-proc gtk_menu_item_toggle_size_request*(menu_item: PGtkMenuItem,
-                                        requisition: Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_toggle_size_request".}
-proc gtk_menu_item_toggle_size_allocate*(menu_item: PGtkMenuItem,
-    allocation: gint){.cdecl, dynlib: gtklib,
-                       importc: "gtk_menu_item_toggle_size_allocate".}
-proc gtk_menu_item_set_right_justified*(menu_item: PGtkMenuItem,
-                                        right_justified: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_item_set_right_justified".}
-proc gtk_menu_item_get_right_justified*(menu_item: PGtkMenuItem): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_item_get_right_justified".}
-proc gtk_menu_item_set_accel_path*(menu_item: PGtkMenuItem, accel_path: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_item_set_accel_path".}
-proc gtk_menu_item_refresh_accel_path*(menu_item: PGtkMenuItem,
-    prefix: cstring, accel_group: PGtkAccelGroup, group_changed: gboolean){.
-    cdecl, dynlib: gtklib, importc: "_gtk_menu_item_refresh_accel_path".}
-proc gtk_menu_item_is_selectable*(menu_item: PGtkWidget): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_menu_item_is_selectable".}
-const
-  bm_TGtkToggleButton_active* = 0x00000001'i16
-  bp_TGtkToggleButton_active* = 0'i16
-  bm_TGtkToggleButton_draw_indicator* = 0x00000002'i16
-  bp_TGtkToggleButton_draw_indicator* = 1'i16
-  bm_TGtkToggleButton_inconsistent* = 0x00000004'i16
-  bp_TGtkToggleButton_inconsistent* = 2'i16
-
-proc GTK_TYPE_TOGGLE_BUTTON*(): GType
-proc GTK_TOGGLE_BUTTON*(obj: pointer): PGtkToggleButton
-proc GTK_TOGGLE_BUTTON_CLASS*(klass: pointer): PGtkToggleButtonClass
-proc GTK_IS_TOGGLE_BUTTON*(obj: pointer): bool
-proc GTK_IS_TOGGLE_BUTTON_CLASS*(klass: pointer): bool
-proc GTK_TOGGLE_BUTTON_GET_CLASS*(obj: pointer): PGtkToggleButtonClass
-proc active*(a: var TGtkToggleButton): guint
-proc set_active*(a: var TGtkToggleButton, `active`: guint)
-proc draw_indicator*(a: var TGtkToggleButton): guint
-proc set_draw_indicator*(a: var TGtkToggleButton, `draw_indicator`: guint)
-proc inconsistent*(a: var TGtkToggleButton): guint
-proc set_inconsistent*(a: var TGtkToggleButton, `inconsistent`: guint)
-proc gtk_toggle_button_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_toggle_button_get_type".}
-proc gtk_toggle_button_new*(): PGtkToggleButton {.cdecl, dynlib: gtklib,
-    importc: "gtk_toggle_button_new".}
-proc gtk_toggle_button_new_with_label*(`label`: cstring): PGtkToggleButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_toggle_button_new_with_label".}
-proc gtk_toggle_button_new_with_mnemonic*(`label`: cstring): PGtkToggleButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_toggle_button_new_with_mnemonic".}
-proc gtk_toggle_button_set_mode*(toggle_button: PGtkToggleButton,
-                                 draw_indicator: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_toggle_button_set_mode".}
-proc gtk_toggle_button_get_mode*(toggle_button: PGtkToggleButton): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_toggle_button_get_mode".}
-proc gtk_toggle_button_set_active*(toggle_button: PGtkToggleButton,
-                                   is_active: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_toggle_button_set_active".}
-proc gtk_toggle_button_get_active*(toggle_button: PGtkToggleButton): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_toggle_button_get_active".}
-proc gtk_toggle_button_toggled*(toggle_button: PGtkToggleButton){.cdecl,
-    dynlib: gtklib, importc: "gtk_toggle_button_toggled".}
-proc gtk_toggle_button_set_inconsistent*(toggle_button: PGtkToggleButton,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_toggle_button_set_inconsistent".}
-proc gtk_toggle_button_get_inconsistent*(toggle_button: PGtkToggleButton): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_toggle_button_get_inconsistent".}
-proc GTK_TYPE_CHECK_BUTTON*(): GType
-proc GTK_CHECK_BUTTON*(obj: pointer): PGtkCheckButton
-proc GTK_CHECK_BUTTON_CLASS*(klass: pointer): PGtkCheckButtonClass
-proc GTK_IS_CHECK_BUTTON*(obj: pointer): bool
-proc GTK_IS_CHECK_BUTTON_CLASS*(klass: pointer): bool
-proc GTK_CHECK_BUTTON_GET_CLASS*(obj: pointer): PGtkCheckButtonClass
-proc gtk_check_button_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_check_button_get_type".}
-proc gtk_check_button_new*(): PGtkCheckButton{.cdecl, dynlib: gtklib,
-    importc: "gtk_check_button_new".}
-proc gtk_check_button_new_with_label*(`label`: cstring): PGtkCheckButton{.cdecl,
-    dynlib: gtklib, importc: "gtk_check_button_new_with_label".}
-proc gtk_check_button_new_with_mnemonic*(`label`: cstring): PGtkCheckButton {.cdecl,
-    dynlib: gtklib, importc: "gtk_check_button_new_with_mnemonic".}
-proc gtk_check_button_get_props*(check_button: PGtkCheckButton,
-                                   indicator_size: Pgint,
-                                   indicator_spacing: Pgint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_check_button_get_props".}
-const
-  bm_TGtkCheckMenuItem_active* = 0x00000001'i16
-  bp_TGtkCheckMenuItem_active* = 0'i16
-  bm_TGtkCheckMenuItem_always_show_toggle* = 0x00000002'i16
-  bp_TGtkCheckMenuItem_always_show_toggle* = 1'i16
-  bm_TGtkCheckMenuItem_inconsistent* = 0x00000004'i16
-  bp_TGtkCheckMenuItem_inconsistent* = 2'i16
-
-proc GTK_TYPE_CHECK_MENU_ITEM*(): GType
-proc GTK_CHECK_MENU_ITEM*(obj: pointer): PGtkCheckMenuItem
-proc GTK_CHECK_MENU_ITEM_CLASS*(klass: pointer): PGtkCheckMenuItemClass
-proc GTK_IS_CHECK_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_CHECK_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_CHECK_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkCheckMenuItemClass
-proc active*(a: var TGtkCheckMenuItem): guint
-proc set_active*(a: var TGtkCheckMenuItem, `active`: guint)
-proc always_show_toggle*(a: var TGtkCheckMenuItem): guint
-proc set_always_show_toggle*(a: var TGtkCheckMenuItem,
-                             `always_show_toggle`: guint)
-proc inconsistent*(a: var TGtkCheckMenuItem): guint
-proc set_inconsistent*(a: var TGtkCheckMenuItem, `inconsistent`: guint)
-proc gtk_check_menu_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_check_menu_item_get_type".}
-proc gtk_check_menu_item_new*(): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_check_menu_item_new".}
-proc gtk_check_menu_item_new_with_label*(`label`: cstring): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_check_menu_item_new_with_label".}
-proc gtk_check_menu_item_new_with_mnemonic*(`label`: cstring): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_check_menu_item_new_with_mnemonic".}
-proc gtk_check_menu_item_set_active*(check_menu_item: PGtkCheckMenuItem,
-                                     is_active: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_check_menu_item_set_active".}
-proc gtk_check_menu_item_get_active*(check_menu_item: PGtkCheckMenuItem): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_check_menu_item_get_active".}
-proc gtk_check_menu_item_toggled*(check_menu_item: PGtkCheckMenuItem){.cdecl,
-    dynlib: gtklib, importc: "gtk_check_menu_item_toggled".}
-proc gtk_check_menu_item_set_inconsistent*(check_menu_item: PGtkCheckMenuItem,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_check_menu_item_set_inconsistent".}
-proc gtk_check_menu_item_get_inconsistent*(check_menu_item: PGtkCheckMenuItem): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_check_menu_item_get_inconsistent".}
-proc gtk_clipboard_get_for_display*(display: PGdkDisplay, selection: TGdkAtom): PGtkClipboard{.
-    cdecl, dynlib: gtklib, importc: "gtk_clipboard_get_for_display".}
-proc gtk_clipboard_get_display*(clipboard: PGtkClipboard): PGdkDisplay{.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_get_display".}
-proc gtk_clipboard_set_with_data*(clipboard: PGtkClipboard,
-                                  targets: PGtkTargetEntry, n_targets: guint,
-                                  get_func: TGtkClipboardGetFunc,
-                                  clear_func: TGtkClipboardClearFunc,
-                                  user_data: gpointer): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_set_with_data".}
-proc gtk_clipboard_set_with_owner*(clipboard: PGtkClipboard,
-                                   targets: PGtkTargetEntry, n_targets: guint,
-                                   get_func: TGtkClipboardGetFunc,
-                                   clear_func: TGtkClipboardClearFunc,
-                                   owner: PGObject): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_set_with_owner".}
-proc gtk_clipboard_get_owner*(clipboard: PGtkClipboard): PGObject{.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_get_owner".}
-proc gtk_clipboard_clear*(clipboard: PGtkClipboard){.cdecl, dynlib: gtklib,
-    importc: "gtk_clipboard_clear".}
-proc gtk_clipboard_set_text*(clipboard: PGtkClipboard, text: cstring, len: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_clipboard_set_text".}
-proc gtk_clipboard_request_contents*(clipboard: PGtkClipboard, target: TGdkAtom,
-                                     callback: TGtkClipboardReceivedFunc,
-                                     user_data: gpointer){.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_request_contents".}
-proc gtk_clipboard_request_text*(clipboard: PGtkClipboard,
-                                 callback: TGtkClipboardTextReceivedFunc,
-                                 user_data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_clipboard_request_text".}
-proc gtk_clipboard_wait_for_contents*(clipboard: PGtkClipboard, target: TGdkAtom): PGtkSelectionData{.
-    cdecl, dynlib: gtklib, importc: "gtk_clipboard_wait_for_contents".}
-proc gtk_clipboard_wait_for_text*(clipboard: PGtkClipboard): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_clipboard_wait_for_text".}
-proc gtk_clipboard_wait_is_text_available*(clipboard: PGtkClipboard): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_clipboard_wait_is_text_available".}
-const
-  GTK_CLIST_IN_DRAG* = 1 shl 0
-  GTK_CLIST_ROW_HEIGHT_SET* = 1 shl 1
-  GTK_CLIST_SHOW_TITLES* = 1 shl 2
-  GTK_CLIST_ADD_MODE* = 1 shl 4
-  GTK_CLIST_AUTO_SORT* = 1 shl 5
-  GTK_CLIST_AUTO_RESIZE_BLOCKED* = 1 shl 6
-  GTK_CLIST_REORDERABLE* = 1 shl 7
-  GTK_CLIST_USE_DRAG_ICONS* = 1 shl 8
-  GTK_CLIST_DRAW_DRAG_LINE* = 1 shl 9
-  GTK_CLIST_DRAW_DRAG_RECT* = 1 shl 10
-  GTK_BUTTON_IGNORED* = 0
-  GTK_BUTTON_SELECTS* = 1 shl 0
-  GTK_BUTTON_DRAGS* = 1 shl 1
-  GTK_BUTTON_EXPANDS* = 1 shl 2
-
-const
-  bm_TGtkCListColumn_visible* = 0x00000001'i16
-  bp_TGtkCListColumn_visible* = 0'i16
-  bm_TGtkCListColumn_width_set* = 0x00000002'i16
-  bp_TGtkCListColumn_width_set* = 1'i16
-  bm_TGtkCListColumn_resizeable* = 0x00000004'i16
-  bp_TGtkCListColumn_resizeable* = 2'i16
-  bm_TGtkCListColumn_auto_resize* = 0x00000008'i16
-  bp_TGtkCListColumn_auto_resize* = 3'i16
-  bm_TGtkCListColumn_button_passive* = 0x00000010'i16
-  bp_TGtkCListColumn_button_passive* = 4'i16
-  bm_TGtkCListRow_fg_set* = 0x00000001'i16
-  bp_TGtkCListRow_fg_set* = 0'i16
-  bm_TGtkCListRow_bg_set* = 0x00000002'i16
-  bp_TGtkCListRow_bg_set* = 1'i16
-  bm_TGtkCListRow_selectable* = 0x00000004'i16
-  bp_TGtkCListRow_selectable* = 2'i16
-
-proc GTK_TYPE_CLIST*(): GType
-proc GTK_CLIST*(obj: pointer): PGtkCList
-proc GTK_CLIST_CLASS*(klass: pointer): PGtkCListClass
-proc GTK_IS_CLIST*(obj: pointer): bool
-proc GTK_IS_CLIST_CLASS*(klass: pointer): bool
-proc GTK_CLIST_GET_CLASS*(obj: pointer): PGtkCListClass
-proc GTK_CLIST_FLAGS*(clist: pointer): guint16
-proc GTK_CLIST_SET_FLAG*(clist: PGtkCList, flag: guint16)
-proc GTK_CLIST_UNSET_FLAG*(clist: PGtkCList, flag: guint16)
-#proc GTK_CLIST_IN_DRAG_get*(clist: pointer): bool
-#proc GTK_CLIST_ROW_HEIGHT_SET_get*(clist: pointer): bool
-#proc GTK_CLIST_SHOW_TITLES_get*(clist: pointer): bool
-#proc GTK_CLIST_ADD_MODE_get*(clist: pointer): bool
-#proc GTK_CLIST_AUTO_SORT_get*(clist: pointer): bool
-#proc GTK_CLIST_AUTO_RESIZE_BLOCKED_get*(clist: pointer): bool
-#proc GTK_CLIST_REORDERABLE_get*(clist: pointer): bool
-#proc GTK_CLIST_USE_DRAG_ICONS_get*(clist: pointer): bool
-#proc GTK_CLIST_DRAW_DRAG_LINE_get*(clist: pointer): bool
-#proc GTK_CLIST_DRAW_DRAG_RECT_get*(clist: pointer): bool
-#proc GTK_CLIST_ROW_get*(glist: PGList): PGtkCListRow
-#proc GTK_CELL_TEXT_get*(cell: pointer): PGtkCellText
-#proc GTK_CELL_PIXMAP_get*(cell: pointer): PGtkCellPixmap
-#proc GTK_CELL_PIXTEXT_get*(cell: pointer): PGtkCellPixText
-#proc GTK_CELL_WIDGET_get*(cell: pointer): PGtkCellWidget
-proc visible*(a: var TGtkCListColumn): guint
-proc set_visible*(a: var TGtkCListColumn, `visible`: guint)
-proc width_set*(a: var TGtkCListColumn): guint
-proc set_width_set*(a: var TGtkCListColumn, `width_set`: guint)
-proc resizeable*(a: var TGtkCListColumn): guint
-proc set_resizeable*(a: var TGtkCListColumn, `resizeable`: guint)
-proc auto_resize*(a: var TGtkCListColumn): guint
-proc set_auto_resize*(a: var TGtkCListColumn, `auto_resize`: guint)
-proc button_passive*(a: var TGtkCListColumn): guint
-proc set_button_passive*(a: var TGtkCListColumn, `button_passive`: guint)
-proc fg_set*(a: var TGtkCListRow): guint
-proc set_fg_set*(a: var TGtkCListRow, `fg_set`: guint)
-proc bg_set*(a: var TGtkCListRow): guint
-proc set_bg_set*(a: var TGtkCListRow, `bg_set`: guint)
-proc selectable*(a: var TGtkCListRow): guint
-proc set_selectable*(a: var TGtkCListRow, `selectable`: guint)
-proc gtk_clist_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_clist_get_type".}
-proc gtk_clist_new*(columns: gint): PGtkCList {.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_new".}
-proc gtk_clist_set_hadjustment*(clist: PGtkCList, adjustment: PGtkAdjustment){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_hadjustment".}
-proc gtk_clist_set_vadjustment*(clist: PGtkCList, adjustment: PGtkAdjustment){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_vadjustment".}
-proc gtk_clist_get_hadjustment*(clist: PGtkCList): PGtkAdjustment{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_hadjustment".}
-proc gtk_clist_get_vadjustment*(clist: PGtkCList): PGtkAdjustment{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_vadjustment".}
-proc gtk_clist_set_shadow_type*(clist: PGtkCList, thetype: TGtkShadowType){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_shadow_type".}
-proc gtk_clist_set_selection_mode*(clist: PGtkCList, mode: TGtkSelectionMode){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_selection_mode".}
-proc gtk_clist_set_reorderable*(clist: PGtkCList, reorderable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_reorderable".}
-proc gtk_clist_set_use_drag_icons*(clist: PGtkCList, use_icons: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_use_drag_icons".}
-proc gtk_clist_set_button_actions*(clist: PGtkCList, button: guint,
-                                   button_actions: guint8){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_button_actions".}
-proc gtk_clist_freeze*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_freeze".}
-proc gtk_clist_thaw*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_clist_thaw".}
-proc gtk_clist_column_titles_show*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_column_titles_show".}
-proc gtk_clist_column_titles_hide*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_column_titles_hide".}
-proc gtk_clist_column_title_active*(clist: PGtkCList, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_column_title_active".}
-proc gtk_clist_column_title_passive*(clist: PGtkCList, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_column_title_passive".}
-proc gtk_clist_column_titles_active*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_column_titles_active".}
-proc gtk_clist_column_titles_passive*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_column_titles_passive".}
-proc gtk_clist_set_column_title*(clist: PGtkCList, column: gint, title: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_column_title".}
-proc gtk_clist_get_column_title*(clist: PGtkCList, column: gint): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_column_title".}
-proc gtk_clist_set_column_widget*(clist: PGtkCList, column: gint,
-                                  widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_column_widget".}
-proc gtk_clist_get_column_widget*(clist: PGtkCList, column: gint): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_get_column_widget".}
-proc gtk_clist_set_column_justification*(clist: PGtkCList, column: gint,
-    justification: TGtkJustification){.cdecl, dynlib: gtklib, importc: "gtk_clist_set_column_justification".}
-proc gtk_clist_set_column_visibility*(clist: PGtkCList, column: gint,
-                                      visible: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_column_visibility".}
-proc gtk_clist_set_column_resizeable*(clist: PGtkCList, column: gint,
-                                      resizeable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_column_resizeable".}
-proc gtk_clist_set_column_auto_resize*(clist: PGtkCList, column: gint,
-                                       auto_resize: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_column_auto_resize".}
-proc gtk_clist_columns_autosize*(clist: PGtkCList): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_columns_autosize".}
-proc gtk_clist_optimal_column_width*(clist: PGtkCList, column: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_optimal_column_width".}
-proc gtk_clist_set_column_width*(clist: PGtkCList, column: gint, width: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_column_width".}
-proc gtk_clist_set_column_min_width*(clist: PGtkCList, column: gint,
-                                     min_width: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_column_min_width".}
-proc gtk_clist_set_column_max_width*(clist: PGtkCList, column: gint,
-                                     max_width: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_column_max_width".}
-proc gtk_clist_set_row_height*(clist: PGtkCList, height: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_row_height".}
-proc gtk_clist_moveto*(clist: PGtkCList, row: gint, column: gint,
-                       row_align: gfloat, col_align: gfloat){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_moveto".}
-proc gtk_clist_row_is_visible*(clist: PGtkCList, row: gint): TGtkVisibility{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_row_is_visible".}
-proc gtk_clist_get_cell_type*(clist: PGtkCList, row: gint, column: gint): TGtkCellType{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_get_cell_type".}
-proc gtk_clist_set_text*(clist: PGtkCList, row: gint, column: gint, text: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_text".}
-proc gtk_clist_get_text*(clist: PGtkCList, row: gint, column: gint,
-                         text: PPgchar): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_get_text".}
-proc gtk_clist_set_pixmap*(clist: PGtkCList, row: gint, column: gint,
-                           pixmap: PGdkPixmap, mask: PGdkBitmap){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_pixmap".}
-proc gtk_clist_get_pixmap*(clist: PGtkCList, row: gint, column: gint,
-                           pixmap: var PGdkPixmap, mask: var PGdkBitmap): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_get_pixmap".}
-proc gtk_clist_set_pixtext*(clist: PGtkCList, row: gint, column: gint,
-                            text: cstring, spacing: guint8, pixmap: PGdkPixmap,
-                            mask: PGdkBitmap){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_pixtext".}
-proc gtk_clist_set_foreground*(clist: PGtkCList, row: gint, color: PGdkColor){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_foreground".}
-proc gtk_clist_set_background*(clist: PGtkCList, row: gint, color: PGdkColor){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_background".}
-proc gtk_clist_set_cell_style*(clist: PGtkCList, row: gint, column: gint,
-                               style: PGtkStyle){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_set_cell_style".}
-proc gtk_clist_get_cell_style*(clist: PGtkCList, row: gint, column: gint): PGtkStyle{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_get_cell_style".}
-proc gtk_clist_set_row_style*(clist: PGtkCList, row: gint, style: PGtkStyle){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_row_style".}
-proc gtk_clist_get_row_style*(clist: PGtkCList, row: gint): PGtkStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_row_style".}
-proc gtk_clist_set_shift*(clist: PGtkCList, row: gint, column: gint,
-                          vertical: gint, horizontal: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_shift".}
-proc gtk_clist_set_selectable*(clist: PGtkCList, row: gint, selectable: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_selectable".}
-proc gtk_clist_get_selectable*(clist: PGtkCList, row: gint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_selectable".}
-proc gtk_clist_remove*(clist: PGtkCList, row: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_remove".}
-proc gtk_clist_set_row_data*(clist: PGtkCList, row: gint, data: gpointer){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_set_row_data".}
-proc gtk_clist_set_row_data_full*(clist: PGtkCList, row: gint, data: gpointer,
-                                  destroy: TGtkDestroyNotify){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_row_data_full".}
-proc gtk_clist_get_row_data*(clist: PGtkCList, row: gint): gpointer{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_row_data".}
-proc gtk_clist_find_row_from_data*(clist: PGtkCList, data: gpointer): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_find_row_from_data".}
-proc gtk_clist_select_row*(clist: PGtkCList, row: gint, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_select_row".}
-proc gtk_clist_unselect_row*(clist: PGtkCList, row: gint, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_unselect_row".}
-proc gtk_clist_undo_selection*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_undo_selection".}
-proc gtk_clist_clear*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_clear".}
-proc gtk_clist_get_selection_info*(clist: PGtkCList, x: gint, y: gint,
-                                   row: Pgint, column: Pgint): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_get_selection_info".}
-proc gtk_clist_select_all*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_select_all".}
-proc gtk_clist_unselect_all*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-    importc: "gtk_clist_unselect_all".}
-proc gtk_clist_swap_rows*(clist: PGtkCList, row1: gint, row2: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_swap_rows".}
-proc gtk_clist_row_move*(clist: PGtkCList, source_row: gint, dest_row: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_clist_row_move".}
-proc gtk_clist_set_compare_func*(clist: PGtkCList,
-                                 cmp_func: TGtkCListCompareFunc){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_compare_func".}
-proc gtk_clist_set_sort_column*(clist: PGtkCList, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_sort_column".}
-proc gtk_clist_set_sort_type*(clist: PGtkCList, sort_type: TGtkSortType){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_sort_type".}
-proc gtk_clist_sort*(clist: PGtkCList){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_clist_sort".}
-proc gtk_clist_set_auto_sort*(clist: PGtkCList, auto_sort: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_clist_set_auto_sort".}
-proc gtk_clist_create_cell_layout*(clist: PGtkCList, clist_row: PGtkCListRow,
-                                     column: gint): PPangoLayout{.cdecl,
-    dynlib: gtklib, importc: "_gtk_clist_create_cell_layout".}
-const
-  GTK_DIALOG_MODAL* = 1 shl 0
-  GTK_DIALOG_DESTROY_WITH_PARENT* = 1 shl 1
-  GTK_DIALOG_NO_SEPARATOR* = 1 shl 2
-  GTK_RESPONSE_NONE* = - (1)
-  GTK_RESPONSE_REJECT* = - (2)
-  GTK_RESPONSE_ACCEPT* = - (3)
-  GTK_RESPONSE_DELETE_EVENT* = - (4)
-  GTK_RESPONSE_OK* = - (5)
-  GTK_RESPONSE_CANCEL* = - (6)
-  GTK_RESPONSE_CLOSE* = - (7)
-  GTK_RESPONSE_YES* = - (8)
-  GTK_RESPONSE_NO* = - (9)
-  GTK_RESPONSE_APPLY* = - (10)
-  GTK_RESPONSE_HELP* = - (11)
-
-proc GTK_TYPE_DIALOG*(): GType
-proc GTK_DIALOG*(obj: pointer): PGtkDialog
-proc GTK_DIALOG_CLASS*(klass: pointer): PGtkDialogClass
-proc GTK_IS_DIALOG*(obj: pointer): bool
-proc GTK_IS_DIALOG_CLASS*(klass: pointer): bool
-proc GTK_DIALOG_GET_CLASS*(obj: pointer): PGtkDialogClass
-proc gtk_dialog_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_dialog_get_type".}
-proc gtk_dialog_new*(): PGtkDialog {.cdecl, dynlib: gtklib,
-                                    importc: "gtk_dialog_new".}
-proc gtk_dialog_add_action_widget*(dialog: PGtkDialog, child: PGtkWidget,
-                                   response_id: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_dialog_add_action_widget".}
-proc gtk_dialog_add_button*(dialog: PGtkDialog, button_text: cstring,
-                            response_id: gint): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_dialog_add_button".}
-proc gtk_dialog_set_response_sensitive*(dialog: PGtkDialog, response_id: gint,
-                                        setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_dialog_set_response_sensitive".}
-proc gtk_dialog_set_default_response*(dialog: PGtkDialog, response_id: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_dialog_set_default_response".}
-proc gtk_dialog_set_has_separator*(dialog: PGtkDialog, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_dialog_set_has_separator".}
-proc gtk_dialog_get_has_separator*(dialog: PGtkDialog): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_dialog_get_has_separator".}
-proc gtk_dialog_response*(dialog: PGtkDialog, response_id: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_dialog_response".}
-proc gtk_dialog_run*(dialog: PGtkDialog): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_dialog_run".}
-proc gtk_show_about_dialog*(parent: PGtkWindow, firstPropertyName: cstring) {.
-    cdecl, dynlib: gtklib, importc: "gtk_show_about_dialog", varargs.}
-    
-proc GTK_TYPE_VBOX*(): GType
-proc GTK_VBOX*(obj: pointer): PGtkVBox
-proc GTK_VBOX_CLASS*(klass: pointer): PGtkVBoxClass
-proc GTK_IS_VBOX*(obj: pointer): bool
-proc GTK_IS_VBOX_CLASS*(klass: pointer): bool
-proc GTK_VBOX_GET_CLASS*(obj: pointer): PGtkVBoxClass
-proc gtk_vbox_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_vbox_get_type".}
-proc gtk_vbox_new*(homogeneous: gboolean, spacing: gint): PGtkVBox {.cdecl,
-    dynlib: gtklib, importc: "gtk_vbox_new".}
-proc GTK_TYPE_COLOR_SELECTION*(): GType
-proc GTK_COLOR_SELECTION*(obj: pointer): PGtkColorSelection
-proc GTK_COLOR_SELECTION_CLASS*(klass: pointer): PGtkColorSelectionClass
-proc GTK_IS_COLOR_SELECTION*(obj: pointer): bool
-proc GTK_IS_COLOR_SELECTION_CLASS*(klass: pointer): bool
-proc GTK_COLOR_SELECTION_GET_CLASS*(obj: pointer): PGtkColorSelectionClass
-proc gtk_color_selection_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_get_type".}
-proc gtk_color_selection_new*(): PGtkColorSelection {.cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_new".}
-proc gtk_color_selection_get_has_opacity_control*(colorsel: PGtkColorSelection): gboolean{.
-    cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_get_has_opacity_control".}
-proc gtk_color_selection_set_has_opacity_control*(colorsel: PGtkColorSelection,
-    has_opacity: gboolean){.cdecl, dynlib: gtklib, importc: "gtk_color_selection_set_has_opacity_control".}
-proc gtk_color_selection_get_has_palette*(colorsel: PGtkColorSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_color_selection_get_has_palette".}
-proc gtk_color_selection_set_has_palette*(colorsel: PGtkColorSelection,
-    has_palette: gboolean){.cdecl, dynlib: gtklib,
-                            importc: "gtk_color_selection_set_has_palette".}
-proc gtk_color_selection_set_current_color*(colorsel: PGtkColorSelection,
-    color: PGdkColor){.cdecl, dynlib: gtklib,
-                       importc: "gtk_color_selection_set_current_color".}
-proc gtk_color_selection_set_current_alpha*(colorsel: PGtkColorSelection,
-    alpha: guint16){.cdecl, dynlib: gtklib,
-                     importc: "gtk_color_selection_set_current_alpha".}
-proc gtk_color_selection_get_current_color*(colorsel: PGtkColorSelection,
-    color: PGdkColor){.cdecl, dynlib: gtklib,
-                       importc: "gtk_color_selection_get_current_color".}
-proc gtk_color_selection_get_current_alpha*(colorsel: PGtkColorSelection): guint16{.
-    cdecl, dynlib: gtklib, importc: "gtk_color_selection_get_current_alpha".}
-proc gtk_color_selection_set_previous_color*(colorsel: PGtkColorSelection,
-    color: PGdkColor){.cdecl, dynlib: gtklib,
-                       importc: "gtk_color_selection_set_previous_color".}
-proc gtk_color_selection_set_previous_alpha*(colorsel: PGtkColorSelection,
-    alpha: guint16){.cdecl, dynlib: gtklib,
-                     importc: "gtk_color_selection_set_previous_alpha".}
-proc gtk_color_selection_get_previous_color*(colorsel: PGtkColorSelection,
-    color: PGdkColor){.cdecl, dynlib: gtklib,
-                       importc: "gtk_color_selection_get_previous_color".}
-proc gtk_color_selection_get_previous_alpha*(colorsel: PGtkColorSelection): guint16{.
-    cdecl, dynlib: gtklib, importc: "gtk_color_selection_get_previous_alpha".}
-proc gtk_color_selection_is_adjusting*(colorsel: PGtkColorSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_color_selection_is_adjusting".}
-proc gtk_color_selection_palette_from_string*(str: cstring,
-    colors: var PGdkColor, n_colors: Pgint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_palette_from_string".}
-proc gtk_color_selection_palette_to_string*(colors: PGdkColor, n_colors: gint): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_color_selection_palette_to_string".}
-proc gtk_color_selection_set_change_palette_with_screen_hook*(
-    func: TGtkColorSelectionChangePaletteWithScreenFunc): TGtkColorSelectionChangePaletteWithScreenFunc{.
-    cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_set_change_palette_with_screen_hook".}
-proc GTK_TYPE_COLOR_SELECTION_DIALOG*(): GType
-proc GTK_COLOR_SELECTION_DIALOG*(obj: pointer): PGtkColorSelectionDialog
-proc GTK_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): PGtkColorSelectionDialogClass
-proc GTK_IS_COLOR_SELECTION_DIALOG*(obj: pointer): bool
-proc GTK_IS_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): bool
-proc GTK_COLOR_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PGtkColorSelectionDialogClass
-proc gtk_color_selection_dialog_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_color_selection_dialog_get_type".}
-proc gtk_color_selection_dialog_new*(title: cstring): PGtkColorSelectionDialog {.cdecl,
-    dynlib: gtklib, importc: "gtk_color_selection_dialog_new".}
-proc GTK_TYPE_HBOX*(): GType
-proc GTK_HBOX*(obj: pointer): PGtkHBox
-proc GTK_HBOX_CLASS*(klass: pointer): PGtkHBoxClass
-proc GTK_IS_HBOX*(obj: pointer): bool
-proc GTK_IS_HBOX_CLASS*(klass: pointer): bool
-proc GTK_HBOX_GET_CLASS*(obj: pointer): PGtkHBoxClass
-proc gtk_hbox_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_hbox_get_type".}
-proc gtk_hbox_new*(homogeneous: gboolean, spacing: gint): PGtkHBox {.cdecl,
-    dynlib: gtklib, importc: "gtk_hbox_new".}
-const
-  bm_TGtkCombo_value_in_list* = 0x00000001'i16
-  bp_TGtkCombo_value_in_list* = 0'i16
-  bm_TGtkCombo_ok_if_empty* = 0x00000002'i16
-  bp_TGtkCombo_ok_if_empty* = 1'i16
-  bm_TGtkCombo_case_sensitive* = 0x00000004'i16
-  bp_TGtkCombo_case_sensitive* = 2'i16
-  bm_TGtkCombo_use_arrows* = 0x00000008'i16
-  bp_TGtkCombo_use_arrows* = 3'i16
-  bm_TGtkCombo_use_arrows_always* = 0x00000010'i16
-  bp_TGtkCombo_use_arrows_always* = 4'i16
-
-proc GTK_TYPE_COMBO*(): GType
-proc GTK_COMBO*(obj: pointer): PGtkCombo
-proc GTK_COMBO_CLASS*(klass: pointer): PGtkComboClass
-proc GTK_IS_COMBO*(obj: pointer): bool
-proc GTK_IS_COMBO_CLASS*(klass: pointer): bool
-proc GTK_COMBO_GET_CLASS*(obj: pointer): PGtkComboClass
-proc value_in_list*(a: var TGtkCombo): guint
-proc set_value_in_list*(a: var TGtkCombo, `value_in_list`: guint)
-proc ok_if_empty*(a: var TGtkCombo): guint
-proc set_ok_if_empty*(a: var TGtkCombo, `ok_if_empty`: guint)
-proc case_sensitive*(a: var TGtkCombo): guint
-proc set_case_sensitive*(a: var TGtkCombo, `case_sensitive`: guint)
-proc use_arrows*(a: var TGtkCombo): guint
-proc set_use_arrows*(a: var TGtkCombo, `use_arrows`: guint)
-proc use_arrows_always*(a: var TGtkCombo): guint
-proc set_use_arrows_always*(a: var TGtkCombo, `use_arrows_always`: guint)
-proc gtk_combo_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_combo_get_type".}
-proc gtk_combo_new*(): PGtkCombo {.cdecl, dynlib: gtklib,
-                                   importc: "gtk_combo_new".}
-proc gtk_combo_set_value_in_list*(combo: PGtkCombo, val: gboolean,
-                                  ok_if_empty: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_combo_set_value_in_list".}
-proc gtk_combo_set_use_arrows*(combo: PGtkCombo, val: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_combo_set_use_arrows".}
-proc gtk_combo_set_use_arrows_always*(combo: PGtkCombo, val: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_combo_set_use_arrows_always".}
-proc gtk_combo_set_case_sensitive*(combo: PGtkCombo, val: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_combo_set_case_sensitive".}
-proc gtk_combo_set_item_string*(combo: PGtkCombo, item: PGtkItem,
-                                item_value: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_combo_set_item_string".}
-proc gtk_combo_set_popdown_strings*(combo: PGtkCombo, strings: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_combo_set_popdown_strings".}
-proc gtk_combo_disable_activate*(combo: PGtkCombo){.cdecl, dynlib: gtklib,
-    importc: "gtk_combo_disable_activate".}
-const
-  bm_TGtkCTree_line_style* = 0x00000003'i16
-  bp_TGtkCTree_line_style* = 0'i16
-  bm_TGtkCTree_expander_style* = 0x0000000C'i16
-  bp_TGtkCTree_expander_style* = 2'i16
-  bm_TGtkCTree_show_stub* = 0x00000010'i16
-  bp_TGtkCTree_show_stub* = 4'i16
-  bm_TGtkCTreeRow_is_leaf* = 0x00000001'i16
-  bp_TGtkCTreeRow_is_leaf* = 0'i16
-  bm_TGtkCTreeRow_expanded* = 0x00000002'i16
-  bp_TGtkCTreeRow_expanded* = 1'i16
-
-proc GTK_TYPE_CTREE*(): GType
-proc GTK_CTREE*(obj: pointer): PGtkCTree
-proc GTK_CTREE_CLASS*(klass: pointer): PGtkCTreeClass
-proc GTK_IS_CTREE*(obj: pointer): bool
-proc GTK_IS_CTREE_CLASS*(klass: pointer): bool
-proc GTK_CTREE_GET_CLASS*(obj: pointer): PGtkCTreeClass
-proc GTK_CTREE_ROW*(`node`: TAddress): PGtkCTreeRow
-proc GTK_CTREE_NODE*(`node`: TAddress): PGtkCTreeNode
-proc GTK_CTREE_NODE_NEXT*(`nnode`: TAddress): PGtkCTreeNode
-proc GTK_CTREE_NODE_PREV*(`pnode`: TAddress): PGtkCTreeNode
-proc GTK_CTREE_FUNC*(`func`: TAddress): TGtkCTreeFunc
-proc GTK_TYPE_CTREE_NODE*(): GType
-proc line_style*(a: var TGtkCTree): guint
-proc set_line_style*(a: var TGtkCTree, `line_style`: guint)
-proc expander_style*(a: var TGtkCTree): guint
-proc set_expander_style*(a: var TGtkCTree, `expander_style`: guint)
-proc show_stub*(a: var TGtkCTree): guint
-proc set_show_stub*(a: var TGtkCTree, `show_stub`: guint)
-proc is_leaf*(a: var TGtkCTreeRow): guint
-proc set_is_leaf*(a: var TGtkCTreeRow, `is_leaf`: guint)
-proc expanded*(a: var TGtkCTreeRow): guint
-proc set_expanded*(a: var TGtkCTreeRow, `expanded`: guint)
-proc gtk_ctree_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_ctree_get_type".}
-proc gtk_ctree_new*(columns: gint, tree_column: gint): PGtkCTree {.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_new".}
-proc gtk_ctree_insert_node*(ctree: PGtkCTree, parent: PGtkCTreeNode,
-                            sibling: PGtkCTreeNode, text: openarray[cstring],
-                            spacing: guint8, pixmap_closed: PGdkPixmap,
-                            mask_closed: PGdkBitmap, pixmap_opened: PGdkPixmap,
-                            mask_opened: PGdkBitmap, is_leaf: gboolean,
-                            expanded: gboolean): PGtkCTreeNode{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_insert_node".}
-proc gtk_ctree_remove_node*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_remove_node".}
-proc gtk_ctree_insert_gnode*(ctree: PGtkCTree, parent: PGtkCTreeNode,
-                             sibling: PGtkCTreeNode, gnode: PGNode,
-                             fun: TGtkCTreeGNodeFunc, data: gpointer): PGtkCTreeNode{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_insert_gnode".}
-proc gtk_ctree_export_to_gnode*(ctree: PGtkCTree, parent: PGNode,
-                                sibling: PGNode, node: PGtkCTreeNode,
-                                fun: TGtkCTreeGNodeFunc, data: gpointer): PGNode{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_export_to_gnode".}
-proc gtk_ctree_post_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                               fun: TGtkCTreeFunc, data: gpointer){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_post_recursive".}
-proc gtk_ctree_post_recursive_to_depth*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                        depth: gint, fun: TGtkCTreeFunc,
-                                        data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_post_recursive_to_depth".}
-proc gtk_ctree_pre_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                              fun: TGtkCTreeFunc, data: gpointer){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_pre_recursive".}
-proc gtk_ctree_pre_recursive_to_depth*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                       depth: gint, fun: TGtkCTreeFunc,
-                                       data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_pre_recursive_to_depth".}
-proc gtk_ctree_is_viewable*(ctree: PGtkCTree, node: PGtkCTreeNode): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_is_viewable".}
-proc gtk_ctree_last*(ctree: PGtkCTree, node: PGtkCTreeNode): PGtkCTreeNode{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_last".}
-proc gtk_ctree_find_node_ptr*(ctree: PGtkCTree, ctree_row: PGtkCTreeRow): PGtkCTreeNode{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_find_node_ptr".}
-proc gtk_ctree_node_nth*(ctree: PGtkCTree, row: guint): PGtkCTreeNode{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_nth".}
-proc gtk_ctree_find*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                     child: PGtkCTreeNode): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_find".}
-proc gtk_ctree_is_ancestor*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                            child: PGtkCTreeNode): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_is_ancestor".}
-proc gtk_ctree_find_by_row_data*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                 data: gpointer): PGtkCTreeNode{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_find_by_row_data".}
-proc gtk_ctree_find_all_by_row_data*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                     data: gpointer): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_find_all_by_row_data".}
-proc gtk_ctree_find_by_row_data_custom*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                        data: gpointer, fun: TGCompareFunc): PGtkCTreeNode{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_find_by_row_data_custom".}
-proc gtk_ctree_find_all_by_row_data_custom*(ctree: PGtkCTree,
-    node: PGtkCTreeNode, data: gpointer, fun: TGCompareFunc): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_find_all_by_row_data_custom".}
-proc gtk_ctree_is_hot_spot*(ctree: PGtkCTree, x: gint, y: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_is_hot_spot".}
-proc gtk_ctree_move*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                     new_parent: PGtkCTreeNode, new_sibling: PGtkCTreeNode){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_move".}
-proc gtk_ctree_expand*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_expand".}
-proc gtk_ctree_expand_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_expand_recursive".}
-proc gtk_ctree_expand_to_depth*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                depth: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_expand_to_depth".}
-proc gtk_ctree_collapse*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_collapse".}
-proc gtk_ctree_collapse_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_collapse_recursive".}
-proc gtk_ctree_collapse_to_depth*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                  depth: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_collapse_to_depth".}
-proc gtk_ctree_toggle_expansion*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_toggle_expansion".}
-proc gtk_ctree_toggle_expansion_recursive*(ctree: PGtkCTree,
-    node: PGtkCTreeNode){.cdecl, dynlib: gtklib,
-                           importc: "gtk_ctree_toggle_expansion_recursive".}
-proc gtk_ctree_select*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_select".}
-proc gtk_ctree_select_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_select_recursive".}
-proc gtk_ctree_unselect*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_unselect".}
-proc gtk_ctree_unselect_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_unselect_recursive".}
-proc gtk_ctree_real_select_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                      state: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_real_select_recursive".}
-proc gtk_ctree_node_set_text*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                              column: gint, text: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_set_text".}
-proc gtk_ctree_node_set_pixmap*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                column: gint, pixmap: PGdkPixmap,
-                                mask: PGdkBitmap){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_node_set_pixmap".}
-proc gtk_ctree_node_set_pixtext*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                 column: gint, text: cstring, spacing: guint8,
-                                 pixmap: PGdkPixmap, mask: PGdkBitmap){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_set_pixtext".}
-proc gtk_ctree_set_node_info*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                              text: cstring, spacing: guint8,
-                              pixmap_closed: PGdkPixmap,
-                              mask_closed: PGdkBitmap,
-                              pixmap_opened: PGdkPixmap,
-                              mask_opened: PGdkBitmap, is_leaf: gboolean,
-                              expanded: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_set_node_info".}
-proc gtk_ctree_node_set_shift*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                               column: gint, vertical: gint, horizontal: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_set_shift".}
-proc gtk_ctree_node_set_selectable*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                    selectable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_set_selectable".}
-proc gtk_ctree_node_get_selectable*(ctree: PGtkCTree, node: PGtkCTreeNode): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_get_selectable".}
-proc gtk_ctree_node_get_cell_type*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                   column: gint): TGtkCellType{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_get_cell_type".}
-proc gtk_ctree_node_get_text*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                              column: gint, text: PPgchar): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_get_text".}
-proc gtk_ctree_node_set_row_style*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                   style: PGtkStyle){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_node_set_row_style".}
-proc gtk_ctree_node_get_row_style*(ctree: PGtkCTree, node: PGtkCTreeNode): PGtkStyle{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_get_row_style".}
-proc gtk_ctree_node_set_cell_style*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                    column: gint, style: PGtkStyle){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_set_cell_style".}
-proc gtk_ctree_node_get_cell_style*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                    column: gint): PGtkStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_get_cell_style".}
-proc gtk_ctree_node_set_foreground*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                    color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_node_set_foreground".}
-proc gtk_ctree_node_set_background*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                    color: PGdkColor){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_node_set_background".}
-proc gtk_ctree_node_set_row_data*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                  data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_ctree_node_set_row_data".}
-proc gtk_ctree_node_set_row_data_full*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                                       data: gpointer,
-                                       destroy: TGtkDestroyNotify){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_node_set_row_data_full".}
-proc gtk_ctree_node_get_row_data*(ctree: PGtkCTree, node: PGtkCTreeNode): gpointer{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_get_row_data".}
-proc gtk_ctree_node_moveto*(ctree: PGtkCTree, node: PGtkCTreeNode,
-                            column: gint, row_align: gfloat, col_align: gfloat){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_moveto".}
-proc gtk_ctree_node_is_visible*(ctree: PGtkCTree, node: PGtkCTreeNode): TGtkVisibility{.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_node_is_visible".}
-proc gtk_ctree_set_indent*(ctree: PGtkCTree, indent: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_set_indent".}
-proc gtk_ctree_set_spacing*(ctree: PGtkCTree, spacing: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_set_spacing".}
-proc gtk_ctree_set_show_stub*(ctree: PGtkCTree, show_stub: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_set_show_stub".}
-proc gtk_ctree_set_line_style*(ctree: PGtkCTree, line_style: TGtkCTreeLineStyle){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_set_line_style".}
-proc gtk_ctree_set_expander_style*(ctree: PGtkCTree,
-                                   expander_style: TGtkCTreeExpanderStyle){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_set_expander_style".}
-proc gtk_ctree_set_drag_compare_func*(ctree: PGtkCTree,
-                                      cmp_func: TGtkCTreeCompareDragFunc){.
-    cdecl, dynlib: gtklib, importc: "gtk_ctree_set_drag_compare_func".}
-proc gtk_ctree_sort_node*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_sort_node".}
-proc gtk_ctree_sort_recursive*(ctree: PGtkCTree, node: PGtkCTreeNode){.cdecl,
-    dynlib: gtklib, importc: "gtk_ctree_sort_recursive".}
-proc gtk_ctree_set_reorderable*(t: pointer, r: bool)
-proc gtk_ctree_node_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_ctree_node_get_type".}
-proc GTK_TYPE_DRAWING_AREA*(): GType
-proc GTK_DRAWING_AREA*(obj: pointer): PGtkDrawingArea
-proc GTK_DRAWING_AREA_CLASS*(klass: pointer): PGtkDrawingAreaClass
-proc GTK_IS_DRAWING_AREA*(obj: pointer): bool
-proc GTK_IS_DRAWING_AREA_CLASS*(klass: pointer): bool
-proc GTK_DRAWING_AREA_GET_CLASS*(obj: pointer): PGtkDrawingAreaClass
-proc gtk_drawing_area_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_drawing_area_get_type".}
-proc gtk_drawing_area_new*(): PGtkDrawingArea {.cdecl, dynlib: gtklib,
-    importc: "gtk_drawing_area_new".}
-proc GTK_TYPE_CURVE*(): GType
-proc GTK_CURVE*(obj: pointer): PGtkCurve
-proc GTK_CURVE_CLASS*(klass: pointer): PGtkCurveClass
-proc GTK_IS_CURVE*(obj: pointer): bool
-proc GTK_IS_CURVE_CLASS*(klass: pointer): bool
-proc GTK_CURVE_GET_CLASS*(obj: pointer): PGtkCurveClass
-proc gtk_curve_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_curve_get_type".}
-proc gtk_curve_new*(): PGtkCurve {.cdecl, dynlib: gtklib,
-                                   importc: "gtk_curve_new".}
-proc gtk_curve_reset*(curve: PGtkCurve){.cdecl, dynlib: gtklib,
-    importc: "gtk_curve_reset".}
-proc gtk_curve_set_gamma*(curve: PGtkCurve, gamma: gfloat){.cdecl,
-    dynlib: gtklib, importc: "gtk_curve_set_gamma".}
-proc gtk_curve_set_range*(curve: PGtkCurve, min_x: gfloat, max_x: gfloat,
-                          min_y: gfloat, max_y: gfloat){.cdecl, dynlib: gtklib,
-    importc: "gtk_curve_set_range".}
-proc gtk_curve_set_curve_type*(curve: PGtkCurve, thetype: TGtkCurveType){.cdecl,
-    dynlib: gtklib, importc: "gtk_curve_set_curve_type".}
-const
-  GTK_DEST_DEFAULT_MOTION* = 1 shl 0
-  GTK_DEST_DEFAULT_HIGHLIGHT* = 1 shl 1
-  GTK_DEST_DEFAULT_DROP* = 1 shl 2
-  GTK_DEST_DEFAULT_ALL* = 0x00000007
-  GTK_TARGET_SAME_APP* = 1 shl 0
-  GTK_TARGET_SAME_WIDGET* = 1 shl 1
-
-proc gtk_drag_get_data*(widget: PGtkWidget, context: PGdkDragContext,
-                        target: TGdkAtom, time: guint32){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_get_data".}
-proc gtk_drag_finish*(context: PGdkDragContext, success: gboolean,
-                      del: gboolean, time: guint32){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_finish".}
-proc gtk_drag_get_source_widget*(context: PGdkDragContext): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_get_source_widget".}
-proc gtk_drag_highlight*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_highlight".}
-proc gtk_drag_unhighlight*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_unhighlight".}
-proc gtk_drag_dest_set*(widget: PGtkWidget, flags: TGtkDestDefaults,
-                        targets: PGtkTargetEntry, n_targets: gint,
-                        actions: TGdkDragAction){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_dest_set".}
-proc gtk_drag_dest_set_proxy*(widget: PGtkWidget, proxy_window: PGdkWindow,
-                              protocol: TGdkDragProtocol,
-                              use_coordinates: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_dest_set_proxy".}
-proc gtk_drag_dest_unset*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_dest_unset".}
-proc gtk_drag_dest_find_target*(widget: PGtkWidget, context: PGdkDragContext,
-                                target_list: PGtkTargetList): TGdkAtom{.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_dest_find_target".}
-proc gtk_drag_dest_get_target_list*(widget: PGtkWidget): PGtkTargetList{.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_dest_get_target_list".}
-proc gtk_drag_dest_set_target_list*(widget: PGtkWidget,
-                                    target_list: PGtkTargetList){.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_dest_set_target_list".}
-proc gtk_drag_source_set*(widget: PGtkWidget,
-                          start_button_mask: TGdkModifierType,
-                          targets: PGtkTargetEntry, n_targets: gint,
-                          actions: TGdkDragAction){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_source_set".}
-proc gtk_drag_source_unset*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_source_unset".}
-proc gtk_drag_source_set_icon*(widget: PGtkWidget, colormap: PGdkColormap,
-                               pixmap: PGdkPixmap, mask: PGdkBitmap){.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_source_set_icon".}
-proc gtk_drag_source_set_icon_pixbuf*(widget: PGtkWidget, pixbuf: PGdkPixbuf){.
-    cdecl, dynlib: gtklib, importc: "gtk_drag_source_set_icon_pixbuf".}
-proc gtk_drag_source_set_icon_stock*(widget: PGtkWidget, stock_id: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_drag_source_set_icon_stock".}
-proc gtk_drag_begin*(widget: PGtkWidget, targets: PGtkTargetList,
-                     actions: TGdkDragAction, button: gint, event: PGdkEvent): PGdkDragContext{.
-    cdecl, dynlib: gtklib, importc: "gtk_drag_begin".}
-proc gtk_drag_set_icon_widget*(context: PGdkDragContext, widget: PGtkWidget,
-                               hot_x: gint, hot_y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_set_icon_widget".}
-proc gtk_drag_set_icon_pixmap*(context: PGdkDragContext, colormap: PGdkColormap,
-                               pixmap: PGdkPixmap, mask: PGdkBitmap,
-                               hot_x: gint, hot_y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_set_icon_pixmap".}
-proc gtk_drag_set_icon_pixbuf*(context: PGdkDragContext, pixbuf: PGdkPixbuf,
-                               hot_x: gint, hot_y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_set_icon_pixbuf".}
-proc gtk_drag_set_icon_stock*(context: PGdkDragContext, stock_id: cstring,
-                              hot_x: gint, hot_y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_drag_set_icon_stock".}
-proc gtk_drag_set_icon_default*(context: PGdkDragContext){.cdecl,
-    dynlib: gtklib, importc: "gtk_drag_set_icon_default".}
-proc gtk_drag_check_threshold*(widget: PGtkWidget, start_x: gint, start_y: gint,
-                               current_x: gint, current_y: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_drag_check_threshold".}
-proc gtk_drag_source_handle_event*(widget: PGtkWidget, event: PGdkEvent){.
-    cdecl, dynlib: gtklib, importc: "_gtk_drag_source_handle_event".}
-proc gtk_drag_dest_handle_event*(toplevel: PGtkWidget, event: PGdkEvent){.
-    cdecl, dynlib: gtklib, importc: "_gtk_drag_dest_handle_event".}
-proc GTK_TYPE_EDITABLE*(): GType
-proc GTK_EDITABLE*(obj: pointer): PGtkEditable
-proc GTK_EDITABLE_CLASS*(vtable: pointer): PGtkEditableClass
-proc GTK_IS_EDITABLE*(obj: pointer): bool
-proc GTK_IS_EDITABLE_CLASS*(vtable: pointer): bool
-proc GTK_EDITABLE_GET_CLASS*(inst: pointer): PGtkEditableClass
-proc gtk_editable_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_editable_get_type".}
-proc gtk_editable_select_region*(editable: PGtkEditable, start: gint,
-                                 theEnd: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_editable_select_region".}
-proc gtk_editable_get_selection_bounds*(editable: PGtkEditable, start: Pgint,
-                                        theEnd: Pgint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_get_selection_bounds".}
-proc gtk_editable_insert_text*(editable: PGtkEditable, new_text: cstring,
-                               new_text_length: gint, position: Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_insert_text".}
-proc gtk_editable_delete_text*(editable: PGtkEditable, start_pos: gint,
-                               end_pos: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_editable_delete_text".}
-proc gtk_editable_get_chars*(editable: PGtkEditable, start_pos: gint,
-                             end_pos: gint): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_editable_get_chars".}
-proc gtk_editable_cut_clipboard*(editable: PGtkEditable){.cdecl, dynlib: gtklib,
-    importc: "gtk_editable_cut_clipboard".}
-proc gtk_editable_copy_clipboard*(editable: PGtkEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_copy_clipboard".}
-proc gtk_editable_paste_clipboard*(editable: PGtkEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_paste_clipboard".}
-proc gtk_editable_delete_selection*(editable: PGtkEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_delete_selection".}
-proc gtk_editable_set_position*(editable: PGtkEditable, position: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_set_position".}
-proc gtk_editable_get_position*(editable: PGtkEditable): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_get_position".}
-proc gtk_editable_set_editable*(editable: PGtkEditable, is_editable: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_editable_set_editable".}
-proc gtk_editable_get_editable*(editable: PGtkEditable): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_editable_get_editable".}
-proc GTK_TYPE_IM_CONTEXT*(): GType
-proc GTK_IM_CONTEXT*(obj: pointer): PGtkIMContext
-proc GTK_IM_CONTEXT_CLASS*(klass: pointer): PGtkIMContextClass
-proc GTK_IS_IM_CONTEXT*(obj: pointer): bool
-proc GTK_IS_IM_CONTEXT_CLASS*(klass: pointer): bool
-proc GTK_IM_CONTEXT_GET_CLASS*(obj: pointer): PGtkIMContextClass
-proc gtk_im_context_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_get_type".}
-proc gtk_im_context_set_client_window*(context: PGtkIMContext,
-                                       window: PGdkWindow){.cdecl,
-    dynlib: gtklib, importc: "gtk_im_context_set_client_window".}
-proc gtk_im_context_filter_keypress*(context: PGtkIMContext, event: PGdkEventKey): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_im_context_filter_keypress".}
-proc gtk_im_context_focus_in*(context: PGtkIMContext){.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_focus_in".}
-proc gtk_im_context_focus_out*(context: PGtkIMContext){.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_focus_out".}
-proc gtk_im_context_reset*(context: PGtkIMContext){.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_reset".}
-proc gtk_im_context_set_cursor_location*(context: PGtkIMContext,
-    area: PGdkRectangle){.cdecl, dynlib: gtklib,
-                          importc: "gtk_im_context_set_cursor_location".}
-proc gtk_im_context_set_use_preedit*(context: PGtkIMContext,
-                                     use_preedit: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_im_context_set_use_preedit".}
-proc gtk_im_context_set_surrounding*(context: PGtkIMContext, text: cstring,
-                                     len: gint, cursor_index: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_im_context_set_surrounding".}
-proc gtk_im_context_get_surrounding*(context: PGtkIMContext, text: PPgchar,
-                                     cursor_index: Pgint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_im_context_get_surrounding".}
-proc gtk_im_context_delete_surrounding*(context: PGtkIMContext, offset: gint,
-                                        n_chars: gint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_im_context_delete_surrounding".}
-const
-  bm_TGtkMenuShell_active* = 0x00000001'i16
-  bp_TGtkMenuShell_active* = 0'i16
-  bm_TGtkMenuShell_have_grab* = 0x00000002'i16
-  bp_TGtkMenuShell_have_grab* = 1'i16
-  bm_TGtkMenuShell_have_xgrab* = 0x00000004'i16
-  bp_TGtkMenuShell_have_xgrab* = 2'i16
-  bm_TGtkMenuShell_ignore_leave* = 0x00000008'i16
-  bp_TGtkMenuShell_ignore_leave* = 3'i16
-  bm_TGtkMenuShell_menu_flag* = 0x00000010'i16
-  bp_TGtkMenuShell_menu_flag* = 4'i16
-  bm_TGtkMenuShell_ignore_enter* = 0x00000020'i16
-  bp_TGtkMenuShell_ignore_enter* = 5'i16
-  bm_TGtkMenuShellClass_submenu_placement* = 0x00000001'i16
-  bp_TGtkMenuShellClass_submenu_placement* = 0'i16
-
-proc GTK_TYPE_MENU_SHELL*(): GType
-proc GTK_MENU_SHELL*(obj: pointer): PGtkMenuShell
-proc GTK_MENU_SHELL_CLASS*(klass: pointer): PGtkMenuShellClass
-proc GTK_IS_MENU_SHELL*(obj: pointer): bool
-proc GTK_IS_MENU_SHELL_CLASS*(klass: pointer): bool
-proc GTK_MENU_SHELL_GET_CLASS*(obj: pointer): PGtkMenuShellClass
-proc active*(a: var TGtkMenuShell): guint
-proc set_active*(a: var TGtkMenuShell, `active`: guint)
-proc have_grab*(a: var TGtkMenuShell): guint
-proc set_have_grab*(a: var TGtkMenuShell, `have_grab`: guint)
-proc have_xgrab*(a: var TGtkMenuShell): guint
-proc set_have_xgrab*(a: var TGtkMenuShell, `have_xgrab`: guint)
-proc ignore_leave*(a: var TGtkMenuShell): guint
-proc set_ignore_leave*(a: var TGtkMenuShell, `ignore_leave`: guint)
-proc menu_flag*(a: var TGtkMenuShell): guint
-proc set_menu_flag*(a: var TGtkMenuShell, `menu_flag`: guint)
-proc ignore_enter*(a: var TGtkMenuShell): guint
-proc set_ignore_enter*(a: var TGtkMenuShell, `ignore_enter`: guint)
-proc submenu_placement*(a: var TGtkMenuShellClass): guint
-proc set_submenu_placement*(a: var TGtkMenuShellClass,
-                            `submenu_placement`: guint)
-proc gtk_menu_shell_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_shell_get_type".}
-proc gtk_menu_shell_append*(menu_shell: PGtkMenuShell, child: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_shell_append".}
-proc gtk_menu_shell_prepend*(menu_shell: PGtkMenuShell, child: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_shell_prepend".}
-proc gtk_menu_shell_insert*(menu_shell: PGtkMenuShell, child: PGtkWidget,
-                            position: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_shell_insert".}
-proc gtk_menu_shell_deactivate*(menu_shell: PGtkMenuShell){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_shell_deactivate".}
-proc gtk_menu_shell_select_item*(menu_shell: PGtkMenuShell,
-                                 menu_item: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_shell_select_item".}
-proc gtk_menu_shell_deselect*(menu_shell: PGtkMenuShell){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_shell_deselect".}
-proc gtk_menu_shell_activate_item*(menu_shell: PGtkMenuShell,
-                                   menu_item: PGtkWidget,
-                                   force_deactivate: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_shell_activate_item".}
-proc gtk_menu_shell_select_first*(menu_shell: PGtkMenuShell){.cdecl,
-    dynlib: gtklib, importc: "_gtk_menu_shell_select_first".}
-proc gtk_menu_shell_activate*(menu_shell: PGtkMenuShell){.cdecl,
-    dynlib: gtklib, importc: "_gtk_menu_shell_activate".}
-const
-  bm_TGtkMenu_needs_destruction_ref_count* = 0x00000001'i16
-  bp_TGtkMenu_needs_destruction_ref_count* = 0'i16
-  bm_TGtkMenu_torn_off* = 0x00000002'i16
-  bp_TGtkMenu_torn_off* = 1'i16
-  bm_TGtkMenu_tearoff_active* = 0x00000004'i16
-  bp_TGtkMenu_tearoff_active* = 2'i16
-  bm_TGtkMenu_scroll_fast* = 0x00000008'i16
-  bp_TGtkMenu_scroll_fast* = 3'i16
-  bm_TGtkMenu_upper_arrow_visible* = 0x00000010'i16
-  bp_TGtkMenu_upper_arrow_visible* = 4'i16
-  bm_TGtkMenu_lower_arrow_visible* = 0x00000020'i16
-  bp_TGtkMenu_lower_arrow_visible* = 5'i16
-  bm_TGtkMenu_upper_arrow_prelight* = 0x00000040'i16
-  bp_TGtkMenu_upper_arrow_prelight* = 6'i16
-  bm_TGtkMenu_lower_arrow_prelight* = 0x00000080'i16
-  bp_TGtkMenu_lower_arrow_prelight* = 7'i16
-
-proc GTK_TYPE_MENU*(): GType
-proc GTK_MENU*(obj: pointer): PGtkMenu
-proc GTK_MENU_CLASS*(klass: pointer): PGtkMenuClass
-proc GTK_IS_MENU*(obj: pointer): bool
-proc GTK_IS_MENU_CLASS*(klass: pointer): bool
-proc GTK_MENU_GET_CLASS*(obj: pointer): PGtkMenuClass
-proc needs_destruction_ref_count*(a: var TGtkMenu): guint
-proc set_needs_destruction_ref_count*(a: var TGtkMenu,
-                                      `needs_destruction_ref_count`: guint)
-proc torn_off*(a: var TGtkMenu): guint
-proc set_torn_off*(a: var TGtkMenu, `torn_off`: guint)
-proc tearoff_active*(a: var TGtkMenu): guint
-proc set_tearoff_active*(a: var TGtkMenu, `tearoff_active`: guint)
-proc scroll_fast*(a: var TGtkMenu): guint
-proc set_scroll_fast*(a: var TGtkMenu, `scroll_fast`: guint)
-proc upper_arrow_visible*(a: var TGtkMenu): guint
-proc set_upper_arrow_visible*(a: var TGtkMenu, `upper_arrow_visible`: guint)
-proc lower_arrow_visible*(a: var TGtkMenu): guint
-proc set_lower_arrow_visible*(a: var TGtkMenu, `lower_arrow_visible`: guint)
-proc upper_arrow_prelight*(a: var TGtkMenu): guint
-proc set_upper_arrow_prelight*(a: var TGtkMenu, `upper_arrow_prelight`: guint)
-proc lower_arrow_prelight*(a: var TGtkMenu): guint
-proc set_lower_arrow_prelight*(a: var TGtkMenu, `lower_arrow_prelight`: guint)
-proc gtk_menu_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_menu_get_type".}
-proc gtk_menu_new*(): PGtkMenu {.cdecl, dynlib: gtklib, importc: "gtk_menu_new".}
-proc gtk_menu_popup*(menu: PGtkMenu, parent_menu_shell: PGtkWidget,
-                     parent_menu_item: PGtkWidget, fun: TGtkMenuPositionFunc,
-                     data: gpointer, button: guint, activate_time: guint32){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_popup".}
-proc gtk_menu_reposition*(menu: PGtkMenu){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_reposition".}
-proc gtk_menu_popdown*(menu: PGtkMenu){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_menu_popdown".}
-proc gtk_menu_get_active*(menu: PGtkMenu): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_get_active".}
-proc gtk_menu_set_active*(menu: PGtkMenu, index: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_set_active".}
-proc gtk_menu_set_accel_group*(menu: PGtkMenu, accel_group: PGtkAccelGroup){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_set_accel_group".}
-proc gtk_menu_get_accel_group*(menu: PGtkMenu): PGtkAccelGroup{.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_get_accel_group".}
-proc gtk_menu_set_accel_path*(menu: PGtkMenu, accel_path: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_set_accel_path".}
-proc gtk_menu_attach_to_widget*(menu: PGtkMenu, attach_widget: PGtkWidget,
-                                detacher: TGtkMenuDetachFunc){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_attach_to_widget".}
-proc gtk_menu_detach*(menu: PGtkMenu){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_menu_detach".}
-proc gtk_menu_get_attach_widget*(menu: PGtkMenu): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_get_attach_widget".}
-proc gtk_menu_set_tearoff_state*(menu: PGtkMenu, torn_off: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_set_tearoff_state".}
-proc gtk_menu_get_tearoff_state*(menu: PGtkMenu): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_get_tearoff_state".}
-proc gtk_menu_set_title*(menu: PGtkMenu, title: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_set_title".}
-proc gtk_menu_get_title*(menu: PGtkMenu): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_get_title".}
-proc gtk_menu_reorder_child*(menu: PGtkMenu, child: PGtkWidget, position: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_menu_reorder_child".}
-proc gtk_menu_set_screen*(menu: PGtkMenu, screen: PGdkScreen){.cdecl,
-    dynlib: gtklib, importc: "gtk_menu_set_screen".}
-const
-  bm_TGtkEntry_editable* = 0x00000001'i16
-  bp_TGtkEntry_editable* = 0'i16
-  bm_TGtkEntry_visible* = 0x00000002'i16
-  bp_TGtkEntry_visible* = 1'i16
-  bm_TGtkEntry_overwrite_mode* = 0x00000004'i16
-  bp_TGtkEntry_overwrite_mode* = 2'i16
-  bm_TGtkEntry_in_drag* = 0x00000008'i16
-  bp_TGtkEntry_in_drag* = 3'i16
-  bm_TGtkEntry_cache_includes_preedit* = 0x00000001'i16
-  bp_TGtkEntry_cache_includes_preedit* = 0'i16
-  bm_TGtkEntry_need_im_reset* = 0x00000002'i16
-  bp_TGtkEntry_need_im_reset* = 1'i16
-  bm_TGtkEntry_has_frame* = 0x00000004'i16
-  bp_TGtkEntry_has_frame* = 2'i16
-  bm_TGtkEntry_activates_default* = 0x00000008'i16
-  bp_TGtkEntry_activates_default* = 3'i16
-  bm_TGtkEntry_cursor_visible* = 0x00000010'i16
-  bp_TGtkEntry_cursor_visible* = 4'i16
-  bm_TGtkEntry_in_click* = 0x00000020'i16
-  bp_TGtkEntry_in_click* = 5'i16
-  bm_TGtkEntry_is_cell_renderer* = 0x00000040'i16
-  bp_TGtkEntry_is_cell_renderer* = 6'i16
-  bm_TGtkEntry_editing_canceled* = 0x00000080'i16
-  bp_TGtkEntry_editing_canceled* = 7'i16
-  bm_TGtkEntry_mouse_cursor_obscured* = 0x00000100'i16
-  bp_TGtkEntry_mouse_cursor_obscured* = 8'i16
-
-proc GTK_TYPE_ENTRY*(): GType
-proc GTK_ENTRY*(obj: pointer): PGtkEntry
-proc GTK_ENTRY_CLASS*(klass: pointer): PGtkEntryClass
-proc GTK_IS_ENTRY*(obj: pointer): bool
-proc GTK_IS_ENTRY_CLASS*(klass: pointer): bool
-proc GTK_ENTRY_GET_CLASS*(obj: pointer): PGtkEntryClass
-proc editable*(a: var TGtkEntry): guint
-proc set_editable*(a: var TGtkEntry, `editable`: guint)
-proc visible*(a: var TGtkEntry): guint
-proc set_visible*(a: var TGtkEntry, `visible`: guint)
-proc overwrite_mode*(a: var TGtkEntry): guint
-proc set_overwrite_mode*(a: var TGtkEntry, `overwrite_mode`: guint)
-proc in_drag*(a: var TGtkEntry): guint
-proc set_in_drag*(a: var TGtkEntry, `in_drag`: guint)
-proc cache_includes_preedit*(a: var TGtkEntry): guint
-proc set_cache_includes_preedit*(a: var TGtkEntry,
-                                 `cache_includes_preedit`: guint)
-proc need_im_reset*(a: var TGtkEntry): guint
-proc set_need_im_reset*(a: var TGtkEntry, `need_im_reset`: guint)
-proc has_frame*(a: var TGtkEntry): guint
-proc set_has_frame*(a: var TGtkEntry, `has_frame`: guint)
-proc activates_default*(a: var TGtkEntry): guint
-proc set_activates_default*(a: var TGtkEntry, `activates_default`: guint)
-proc cursor_visible*(a: var TGtkEntry): guint
-proc set_cursor_visible*(a: var TGtkEntry, `cursor_visible`: guint)
-proc in_click*(a: var TGtkEntry): guint
-proc set_in_click*(a: var TGtkEntry, `in_click`: guint)
-proc is_cell_renderer*(a: var TGtkEntry): guint
-proc set_is_cell_renderer*(a: var TGtkEntry, `is_cell_renderer`: guint)
-proc editing_canceled*(a: var TGtkEntry): guint
-proc set_editing_canceled*(a: var TGtkEntry, `editing_canceled`: guint)
-proc mouse_cursor_obscured*(a: var TGtkEntry): guint
-proc set_mouse_cursor_obscured*(a: var TGtkEntry, `mouse_cursor_obscured`: guint)
-proc gtk_entry_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_entry_get_type".}
-proc gtk_entry_new*(): PGtkEntry {.cdecl, dynlib: gtklib,
-                                   importc: "gtk_entry_new".}
-proc gtk_entry_set_visibility*(entry: PGtkEntry, visible: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_set_visibility".}
-proc gtk_entry_get_visibility*(entry: PGtkEntry): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_visibility".}
-proc gtk_entry_set_invisible_char*(entry: PGtkEntry, ch: gunichar){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_set_invisible_char".}
-proc gtk_entry_get_invisible_char*(entry: PGtkEntry): gunichar{.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_invisible_char".}
-proc gtk_entry_set_has_frame*(entry: PGtkEntry, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_set_has_frame".}
-proc gtk_entry_get_has_frame*(entry: PGtkEntry): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_has_frame".}
-proc gtk_entry_set_max_length*(entry: PGtkEntry, max: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_set_max_length".}
-proc gtk_entry_get_max_length*(entry: PGtkEntry): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_entry_get_max_length".}
-proc gtk_entry_set_activates_default*(entry: PGtkEntry, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_entry_set_activates_default".}
-proc gtk_entry_get_activates_default*(entry: PGtkEntry): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_activates_default".}
-proc gtk_entry_set_width_chars*(entry: PGtkEntry, n_chars: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_set_width_chars".}
-proc gtk_entry_get_width_chars*(entry: PGtkEntry): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_entry_get_width_chars".}
-proc gtk_entry_set_text*(entry: PGtkEntry, text: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_entry_set_text".}
-proc gtk_entry_get_text*(entry: PGtkEntry): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_entry_get_text".}
-proc gtk_entry_get_layout*(entry: PGtkEntry): PPangoLayout{.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_layout".}
-proc gtk_entry_get_layout_offsets*(entry: PGtkEntry, x: Pgint, y: Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_entry_get_layout_offsets".}
-const
-  GTK_ANCHOR_CENTER* = 0
-  GTK_ANCHOR_NORTH* = 1
-  GTK_ANCHOR_NORTH_WEST* = 2
-  GTK_ANCHOR_NORTH_EAST* = 3
-  GTK_ANCHOR_SOUTH* = 4
-  GTK_ANCHOR_SOUTH_WEST* = 5
-  GTK_ANCHOR_SOUTH_EAST* = 6
-  GTK_ANCHOR_WEST* = 7
-  GTK_ANCHOR_EAST* = 8
-  GTK_ANCHOR_N* = GTK_ANCHOR_NORTH
-  GTK_ANCHOR_NW* = GTK_ANCHOR_NORTH_WEST
-  GTK_ANCHOR_NE* = GTK_ANCHOR_NORTH_EAST
-  GTK_ANCHOR_S* = GTK_ANCHOR_SOUTH
-  GTK_ANCHOR_SW* = GTK_ANCHOR_SOUTH_WEST
-  GTK_ANCHOR_SE* = GTK_ANCHOR_SOUTH_EAST
-  GTK_ANCHOR_W* = GTK_ANCHOR_WEST
-  GTK_ANCHOR_E* = GTK_ANCHOR_EAST
-  GTK_ARROW_UP* = 0
-  GTK_ARROW_DOWN* = 1
-  GTK_ARROW_LEFT* = 2
-  GTK_ARROW_RIGHT* = 3
-  GTK_EXPAND* = 1 shl 0
-  GTK_SHRINK* = 1 shl 1
-  GTK_FILL* = 1 shl 2
-  GTK_BUTTONBOX_DEFAULT_STYLE* = 0
-  GTK_BUTTONBOX_SPREAD* = 1
-  GTK_BUTTONBOX_EDGE* = 2
-  GTK_BUTTONBOX_START* = 3
-  GTK_BUTTONBOX_END* = 4
-  GTK_CURVE_TYPE_LINEAR* = 0
-  GTK_CURVE_TYPE_SPLINE* = 1
-  GTK_CURVE_TYPE_FREE* = 2
-  GTK_DELETE_CHARS* = 0
-  GTK_DELETE_WORD_ENDS* = 1
-  GTK_DELETE_WORDS* = 2
-  GTK_DELETE_DISPLAY_LINES* = 3
-  GTK_DELETE_DISPLAY_LINE_ENDS* = 4
-  GTK_DELETE_PARAGRAPH_ENDS* = 5
-  GTK_DELETE_PARAGRAPHS* = 6
-  GTK_DELETE_WHITESPACE* = 7
-  GTK_DIR_TAB_FORWARD* = 0
-  GTK_DIR_TAB_BACKWARD* = 1
-  GTK_DIR_UP* = 2
-  GTK_DIR_DOWN* = 3
-  GTK_DIR_LEFT* = 4
-  GTK_DIR_RIGHT* = 5
-  GTK_EXPANDER_COLLAPSED* = 0
-  GTK_EXPANDER_SEMI_COLLAPSED* = 1
-  GTK_EXPANDER_SEMI_EXPANDED* = 2
-  GTK_EXPANDER_EXPANDED* = 3
-  GTK_ICON_SIZE_INVALID* = 0
-  GTK_ICON_SIZE_MENU* = 1
-  GTK_ICON_SIZE_SMALL_TOOLBAR* = 2
-  GTK_ICON_SIZE_LARGE_TOOLBAR* = 3
-  GTK_ICON_SIZE_BUTTON* = 4
-  GTK_ICON_SIZE_DND* = 5
-  GTK_ICON_SIZE_DIALOG* = 6
-  GTK_TEXT_DIR_NONE* = 0
-  GTK_TEXT_DIR_LTR* = 1
-  GTK_TEXT_DIR_RTL* = 2
-  GTK_JUSTIFY_LEFT* = 0
-  GTK_JUSTIFY_RIGHT* = 1
-  GTK_JUSTIFY_CENTER* = 2
-  GTK_JUSTIFY_FILL* = 3
-  GTK_MENU_DIR_PARENT* = 0
-  GTK_MENU_DIR_CHILD* = 1
-  GTK_MENU_DIR_NEXT* = 2
-  GTK_MENU_DIR_PREV* = 3
-  GTK_PIXELS* = 0
-  GTK_INCHES* = 1
-  GTK_CENTIMETERS* = 2
-  GTK_MOVEMENT_LOGICAL_POSITIONS* = 0
-  GTK_MOVEMENT_VISUAL_POSITIONS* = 1
-  GTK_MOVEMENT_WORDS* = 2
-  GTK_MOVEMENT_DISPLAY_LINES* = 3
-  GTK_MOVEMENT_DISPLAY_LINE_ENDS* = 4
-  GTK_MOVEMENT_PARAGRAPHS* = 5
-  GTK_MOVEMENT_PARAGRAPH_ENDS* = 6
-  GTK_MOVEMENT_PAGES* = 7
-  GTK_MOVEMENT_BUFFER_ENDS* = 8
-  GTK_ORIENTATION_HORIZONTAL* = 0
-  GTK_ORIENTATION_VERTICAL* = 1
-  GTK_CORNER_TOP_LEFT* = 0
-  GTK_CORNER_BOTTOM_LEFT* = 1
-  GTK_CORNER_TOP_RIGHT* = 2
-  GTK_CORNER_BOTTOM_RIGHT* = 3
-  GTK_PACK_START* = 0
-  GTK_PACK_END* = 1
-  GTK_PATH_PRIO_LOWEST* = 0
-  GTK_PATH_PRIO_GTK* = 4
-  GTK_PATH_PRIO_APPLICATION* = 8
-  GTK_PATH_PRIO_THEME* = 10
-  GTK_PATH_PRIO_RC* = 12
-  GTK_PATH_PRIO_HIGHEST* = 15
-  GTK_PATH_WIDGET* = 0
-  GTK_PATH_WIDGET_CLASS* = 1
-  GTK_PATH_CLASS* = 2
-  GTK_POLICY_ALWAYS* = 0
-  GTK_POLICY_AUTOMATIC* = 1
-  GTK_POLICY_NEVER* = 2
-  GTK_POS_LEFT* = 0
-  GTK_POS_RIGHT* = 1
-  GTK_POS_TOP* = 2
-  GTK_POS_BOTTOM* = 3
-  GTK_PREVIEW_COLOR* = 0
-  GTK_PREVIEW_GRAYSCALE* = 1
-  GTK_RELIEF_NORMAL* = 0
-  GTK_RELIEF_HALF* = 1
-  GTK_RELIEF_NONE* = 2
-  GTK_RESIZE_PARENT* = 0
-  GTK_RESIZE_QUEUE* = 1
-  GTK_RESIZE_IMMEDIATE* = 2
-  GTK_SCROLL_NONE* = 0
-  GTK_SCROLL_JUMP* = 1
-  GTK_SCROLL_STEP_BACKWARD* = 2
-  GTK_SCROLL_STEP_FORWARD* = 3
-  GTK_SCROLL_PAGE_BACKWARD* = 4
-  GTK_SCROLL_PAGE_FORWARD* = 5
-  GTK_SCROLL_STEP_UP* = 6
-  GTK_SCROLL_STEP_DOWN* = 7
-  GTK_SCROLL_PAGE_UP* = 8
-  GTK_SCROLL_PAGE_DOWN* = 9
-  GTK_SCROLL_STEP_LEFT* = 10
-  GTK_SCROLL_STEP_RIGHT* = 11
-  GTK_SCROLL_PAGE_LEFT* = 12
-  GTK_SCROLL_PAGE_RIGHT* = 13
-  GTK_SCROLL_START* = 14
-  GTK_SCROLL_END* = 15
-  GTK_SELECTION_NONE* = 0
-  GTK_SELECTION_SINGLE* = 1
-  GTK_SELECTION_BROWSE* = 2
-  GTK_SELECTION_MULTIPLE* = 3
-  GTK_SELECTION_EXTENDED* = GTK_SELECTION_MULTIPLE
-  GTK_SHADOW_NONE* = 0
-  GTK_SHADOW_IN* = 1
-  GTK_SHADOW_OUT* = 2
-  GTK_SHADOW_ETCHED_IN* = 3
-  GTK_SHADOW_ETCHED_OUT* = 4
-  GTK_STATE_NORMAL* = 0
-  GTK_STATE_ACTIVE* = 1
-  GTK_STATE_PRELIGHT* = 2
-  GTK_STATE_SELECTED* = 3
-  GTK_STATE_INSENSITIVE* = 4
-  GTK_DIRECTION_LEFT* = 0
-  GTK_DIRECTION_RIGHT* = 1
-  GTK_TOP_BOTTOM* = 0
-  GTK_LEFT_RIGHT* = 1
-  GTK_TOOLBAR_ICONS* = 0
-  GTK_TOOLBAR_TEXT* = 1
-  GTK_TOOLBAR_BOTH* = 2
-  GTK_TOOLBAR_BOTH_HORIZ* = 3
-  GTK_UPDATE_CONTINUOUS* = 0
-  GTK_UPDATE_DISCONTINUOUS* = 1
-  GTK_UPDATE_DELAYED* = 2
-  GTK_VISIBILITY_NONE* = 0
-  GTK_VISIBILITY_PARTIAL* = 1
-  GTK_VISIBILITY_FULL* = 2
-  GTK_WIN_POS_NONE* = 0
-  GTK_WIN_POS_CENTER* = 1
-  GTK_WIN_POS_MOUSE* = 2
-  GTK_WIN_POS_CENTER_ALWAYS* = 3
-  GTK_WIN_POS_CENTER_ON_PARENT* = 4
-  GTK_WINDOW_TOPLEVEL* = 0
-  GTK_WINDOW_POPUP* = 1
-  GTK_WRAP_NONE* = 0
-  GTK_WRAP_CHAR* = 1
-  GTK_WRAP_WORD* = 2
-  GTK_SORT_ASCENDING* = 0
-  GTK_SORT_DESCENDING* = 1
-
-proc GTK_TYPE_EVENT_BOX*(): GType
-proc GTK_EVENT_BOX*(obj: pointer): PGtkEventBox
-proc GTK_EVENT_BOX_CLASS*(klass: pointer): PGtkEventBoxClass
-proc GTK_IS_EVENT_BOX*(obj: pointer): bool
-proc GTK_IS_EVENT_BOX_CLASS*(klass: pointer): bool
-proc GTK_EVENT_BOX_GET_CLASS*(obj: pointer): PGtkEventBoxClass
-proc gtk_event_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_event_box_get_type".}
-proc gtk_event_box_new*(): PGtkEventBox {.cdecl, dynlib: gtklib,
-                                          importc: "gtk_event_box_new".}
-const
-  FNM_PATHNAME* = 1 shl 0
-  FNM_NOESCAPE* = 1 shl 1
-  FNM_PERIOD* = 1 shl 2
-
-const
-  FNM_FILE_NAME* = FNM_PATHNAME
-  FNM_LEADING_DIR* = 1 shl 3
-  FNM_CASEFOLD* = 1 shl 4
-
-const
-  FNM_NOMATCH* = 1
-
-proc fnmatch*(`pattern`: char, `string`: char, `flags`: gint): gint{.cdecl,
-    dynlib: gtklib, importc: "fnmatch".}
-proc GTK_TYPE_FILE_SELECTION*(): GType
-proc GTK_FILE_SELECTION*(obj: pointer): PGtkFileSelection
-proc GTK_FILE_SELECTION_CLASS*(klass: pointer): PGtkFileSelectionClass
-proc GTK_IS_FILE_SELECTION*(obj: pointer): bool
-proc GTK_IS_FILE_SELECTION_CLASS*(klass: pointer): bool
-proc GTK_FILE_SELECTION_GET_CLASS*(obj: pointer): PGtkFileSelectionClass
-proc gtk_file_selection_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_file_selection_get_type".}
-proc gtk_file_selection_new*(title: cstring): PGtkFileSelection {.cdecl, dynlib: gtklib,
-    importc: "gtk_file_selection_new".}
-proc gtk_file_selection_set_filename*(filesel: PGtkFileSelection,
-                                      filename: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_file_selection_set_filename".}
-proc gtk_file_selection_get_filename*(filesel: PGtkFileSelection): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_selection_get_filename".}
-proc gtk_file_selection_complete*(filesel: PGtkFileSelection, pattern: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_file_selection_complete".}
-proc gtk_file_selection_show_fileop_buttons*(filesel: PGtkFileSelection){.cdecl,
-    dynlib: gtklib, importc: "gtk_file_selection_show_fileop_buttons".}
-proc gtk_file_selection_hide_fileop_buttons*(filesel: PGtkFileSelection){.cdecl,
-    dynlib: gtklib, importc: "gtk_file_selection_hide_fileop_buttons".}
-proc gtk_file_selection_get_selections*(filesel: PGtkFileSelection): PPgchar{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_selection_get_selections".}
-proc gtk_file_selection_set_select_multiple*(filesel: PGtkFileSelection,
-    select_multiple: gboolean){.cdecl, dynlib: gtklib, importc: "gtk_file_selection_set_select_multiple".}
-proc gtk_file_selection_get_select_multiple*(filesel: PGtkFileSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_selection_get_select_multiple".}
-proc GTK_TYPE_FIXED*(): GType
-proc GTK_FIXED*(obj: pointer): PGtkFixed
-proc GTK_FIXED_CLASS*(klass: pointer): PGtkFixedClass
-proc GTK_IS_FIXED*(obj: pointer): bool
-proc GTK_IS_FIXED_CLASS*(klass: pointer): bool
-proc GTK_FIXED_GET_CLASS*(obj: pointer): PGtkFixedClass
-proc gtk_fixed_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_fixed_get_type".}
-proc gtk_fixed_new*(): PGtkFixed {.cdecl, dynlib: gtklib,
-                                   importc: "gtk_fixed_new".}
-proc gtk_fixed_put*(fixed: PGtkFixed, widget: PGtkWidget, x: gint, y: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_fixed_put".}
-proc gtk_fixed_move*(fixed: PGtkFixed, widget: PGtkWidget, x: gint, y: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_fixed_move".}
-proc gtk_fixed_set_has_window*(fixed: PGtkFixed, has_window: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_fixed_set_has_window".}
-proc gtk_fixed_get_has_window*(fixed: PGtkFixed): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_fixed_get_has_window".}
-proc GTK_TYPE_FONT_SELECTION*(): GType
-proc GTK_FONT_SELECTION*(obj: pointer): PGtkFontSelection
-proc GTK_FONT_SELECTION_CLASS*(klass: pointer): PGtkFontSelectionClass
-proc GTK_IS_FONT_SELECTION*(obj: pointer): bool
-proc GTK_IS_FONT_SELECTION_CLASS*(klass: pointer): bool
-proc GTK_FONT_SELECTION_GET_CLASS*(obj: pointer): PGtkFontSelectionClass
-proc GTK_TYPE_FONT_SELECTION_DIALOG*(): GType
-proc GTK_FONT_SELECTION_DIALOG*(obj: pointer): PGtkFontSelectionDialog
-proc GTK_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): PGtkFontSelectionDialogClass
-proc GTK_IS_FONT_SELECTION_DIALOG*(obj: pointer): bool
-proc GTK_IS_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): bool
-proc GTK_FONT_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PGtkFontSelectionDialogClass
-proc gtk_font_selection_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_font_selection_get_type".}
-proc gtk_font_selection_new*(): PGtkFontSelection{.cdecl, dynlib: gtklib,
-    importc: "gtk_font_selection_new".}
-proc gtk_font_selection_get_font_name*(fontsel: PGtkFontSelection): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_font_selection_get_font_name".}
-proc gtk_font_selection_set_font_name*(fontsel: PGtkFontSelection,
-                                       fontname: cstring): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_font_selection_set_font_name".}
-proc gtk_font_selection_get_preview_text*(fontsel: PGtkFontSelection): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_font_selection_get_preview_text".}
-proc gtk_font_selection_set_preview_text*(fontsel: PGtkFontSelection,
-    text: cstring){.cdecl, dynlib: gtklib,
-                   importc: "gtk_font_selection_set_preview_text".}
-proc gtk_font_selection_dialog_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_font_selection_dialog_get_type".}
-proc gtk_font_selection_dialog_new*(title: cstring): PGtkFontSelectionDialog{.cdecl,
-    dynlib: gtklib, importc: "gtk_font_selection_dialog_new".}
-proc gtk_font_selection_dialog_get_font_name*(fsd: PGtkFontSelectionDialog): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_font_selection_dialog_get_font_name".}
-proc gtk_font_selection_dialog_set_font_name*(fsd: PGtkFontSelectionDialog,
-    fontname: cstring): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_font_selection_dialog_set_font_name".}
-proc gtk_font_selection_dialog_get_preview_text*(fsd: PGtkFontSelectionDialog): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_font_selection_dialog_get_preview_text".}
-proc gtk_font_selection_dialog_set_preview_text*(fsd: PGtkFontSelectionDialog,
-    text: cstring){.cdecl, dynlib: gtklib,
-                   importc: "gtk_font_selection_dialog_set_preview_text".}
-proc GTK_TYPE_GAMMA_CURVE*(): GType
-proc GTK_GAMMA_CURVE*(obj: pointer): PGtkGammaCurve
-proc GTK_GAMMA_CURVE_CLASS*(klass: pointer): PGtkGammaCurveClass
-proc GTK_IS_GAMMA_CURVE*(obj: pointer): bool
-proc GTK_IS_GAMMA_CURVE_CLASS*(klass: pointer): bool
-proc GTK_GAMMA_CURVE_GET_CLASS*(obj: pointer): PGtkGammaCurveClass
-proc gtk_gamma_curve_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_gamma_curve_get_type".}
-proc gtk_gamma_curve_new*(): PGtkGammaCurve{.cdecl, dynlib: gtklib,
-    importc: "gtk_gamma_curve_new".}
-proc gtk_gc_get*(depth: gint, colormap: PGdkColormap, values: PGdkGCValues,
-                 values_mask: TGdkGCValuesMask): PGdkGC{.cdecl, dynlib: gtklib,
-    importc: "gtk_gc_get".}
-proc gtk_gc_release*(gc: PGdkGC){.cdecl, dynlib: gtklib,
-                                  importc: "gtk_gc_release".}
-const
-  bm_TGtkHandleBox_handle_position* = 0x00000003'i16
-  bp_TGtkHandleBox_handle_position* = 0'i16
-  bm_TGtkHandleBox_float_window_mapped* = 0x00000004'i16
-  bp_TGtkHandleBox_float_window_mapped* = 2'i16
-  bm_TGtkHandleBox_child_detached* = 0x00000008'i16
-  bp_TGtkHandleBox_child_detached* = 3'i16
-  bm_TGtkHandleBox_in_drag* = 0x00000010'i16
-  bp_TGtkHandleBox_in_drag* = 4'i16
-  bm_TGtkHandleBox_shrink_on_detach* = 0x00000020'i16
-  bp_TGtkHandleBox_shrink_on_detach* = 5'i16
-  bm_TGtkHandleBox_snap_edge* = 0x000001C0'i16
-  bp_TGtkHandleBox_snap_edge* = 6'i16
-
-proc GTK_TYPE_HANDLE_BOX*(): GType
-proc GTK_HANDLE_BOX*(obj: pointer): PGtkHandleBox
-proc GTK_HANDLE_BOX_CLASS*(klass: pointer): PGtkHandleBoxClass
-proc GTK_IS_HANDLE_BOX*(obj: pointer): bool
-proc GTK_IS_HANDLE_BOX_CLASS*(klass: pointer): bool
-proc GTK_HANDLE_BOX_GET_CLASS*(obj: pointer): PGtkHandleBoxClass
-proc handle_position*(a: var TGtkHandleBox): guint
-proc set_handle_position*(a: var TGtkHandleBox, `handle_position`: guint)
-proc float_window_mapped*(a: var TGtkHandleBox): guint
-proc set_float_window_mapped*(a: var TGtkHandleBox, `float_window_mapped`: guint)
-proc child_detached*(a: var TGtkHandleBox): guint
-proc set_child_detached*(a: var TGtkHandleBox, `child_detached`: guint)
-proc in_drag*(a: var TGtkHandleBox): guint
-proc set_in_drag*(a: var TGtkHandleBox, `in_drag`: guint)
-proc shrink_on_detach*(a: var TGtkHandleBox): guint
-proc set_shrink_on_detach*(a: var TGtkHandleBox, `shrink_on_detach`: guint)
-proc snap_edge*(a: var TGtkHandleBox): gint
-proc set_snap_edge*(a: var TGtkHandleBox, `snap_edge`: gint)
-proc gtk_handle_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_handle_box_get_type".}
-proc gtk_handle_box_new*(): PGtkHandleBox{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_handle_box_new".}
-proc gtk_handle_box_set_shadow_type*(handle_box: PGtkHandleBox,
-                                     thetype: TGtkShadowType){.cdecl,
-    dynlib: gtklib, importc: "gtk_handle_box_set_shadow_type".}
-proc gtk_handle_box_get_shadow_type*(handle_box: PGtkHandleBox): TGtkShadowType{.
-    cdecl, dynlib: gtklib, importc: "gtk_handle_box_get_shadow_type".}
-proc gtk_handle_box_set_handle_position*(handle_box: PGtkHandleBox,
-    position: TGtkPositionType){.cdecl, dynlib: gtklib,
-                                 importc: "gtk_handle_box_set_handle_position".}
-proc gtk_handle_box_get_handle_position*(handle_box: PGtkHandleBox): TGtkPositionType{.
-    cdecl, dynlib: gtklib, importc: "gtk_handle_box_get_handle_position".}
-proc gtk_handle_box_set_snap_edge*(handle_box: PGtkHandleBox,
-                                   edge: TGtkPositionType){.cdecl,
-    dynlib: gtklib, importc: "gtk_handle_box_set_snap_edge".}
-proc gtk_handle_box_get_snap_edge*(handle_box: PGtkHandleBox): TGtkPositionType{.
-    cdecl, dynlib: gtklib, importc: "gtk_handle_box_get_snap_edge".}
-const
-  bm_TGtkPaned_position_set* = 0x00000001'i16
-  bp_TGtkPaned_position_set* = 0'i16
-  bm_TGtkPaned_in_drag* = 0x00000002'i16
-  bp_TGtkPaned_in_drag* = 1'i16
-  bm_TGtkPaned_child1_shrink* = 0x00000004'i16
-  bp_TGtkPaned_child1_shrink* = 2'i16
-  bm_TGtkPaned_child1_resize* = 0x00000008'i16
-  bp_TGtkPaned_child1_resize* = 3'i16
-  bm_TGtkPaned_child2_shrink* = 0x00000010'i16
-  bp_TGtkPaned_child2_shrink* = 4'i16
-  bm_TGtkPaned_child2_resize* = 0x00000020'i16
-  bp_TGtkPaned_child2_resize* = 5'i16
-  bm_TGtkPaned_orientation* = 0x00000040'i16
-  bp_TGtkPaned_orientation* = 6'i16
-  bm_TGtkPaned_in_recursion* = 0x00000080'i16
-  bp_TGtkPaned_in_recursion* = 7'i16
-  bm_TGtkPaned_handle_prelit* = 0x00000100'i16
-  bp_TGtkPaned_handle_prelit* = 8'i16
-
-proc GTK_TYPE_PANED*(): GType
-proc GTK_PANED*(obj: pointer): PGtkPaned
-proc GTK_PANED_CLASS*(klass: pointer): PGtkPanedClass
-proc GTK_IS_PANED*(obj: pointer): bool
-proc GTK_IS_PANED_CLASS*(klass: pointer): bool
-proc GTK_PANED_GET_CLASS*(obj: pointer): PGtkPanedClass
-proc position_set*(a: var TGtkPaned): guint
-proc set_position_set*(a: var TGtkPaned, `position_set`: guint)
-proc in_drag*(a: var TGtkPaned): guint
-proc set_in_drag*(a: var TGtkPaned, `in_drag`: guint)
-proc child1_shrink*(a: var TGtkPaned): guint
-proc set_child1_shrink*(a: var TGtkPaned, `child1_shrink`: guint)
-proc child1_resize*(a: var TGtkPaned): guint
-proc set_child1_resize*(a: var TGtkPaned, `child1_resize`: guint)
-proc child2_shrink*(a: var TGtkPaned): guint
-proc set_child2_shrink*(a: var TGtkPaned, `child2_shrink`: guint)
-proc child2_resize*(a: var TGtkPaned): guint
-proc set_child2_resize*(a: var TGtkPaned, `child2_resize`: guint)
-proc orientation*(a: var TGtkPaned): guint
-proc set_orientation*(a: var TGtkPaned, `orientation`: guint)
-proc in_recursion*(a: var TGtkPaned): guint
-proc set_in_recursion*(a: var TGtkPaned, `in_recursion`: guint)
-proc handle_prelit*(a: var TGtkPaned): guint
-proc set_handle_prelit*(a: var TGtkPaned, `handle_prelit`: guint)
-proc gtk_paned_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_paned_get_type".}
-proc gtk_paned_add1*(paned: PGtkPaned, child: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_paned_add1".}
-proc gtk_paned_add2*(paned: PGtkPaned, child: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_paned_add2".}
-proc gtk_paned_pack1*(paned: PGtkPaned, child: PGtkWidget, resize: gboolean,
-                      shrink: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_paned_pack1".}
-proc gtk_paned_pack2*(paned: PGtkPaned, child: PGtkWidget, resize: gboolean,
-                      shrink: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_paned_pack2".}
-proc gtk_paned_get_position*(paned: PGtkPaned): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_paned_get_position".}
-proc gtk_paned_set_position*(paned: PGtkPaned, position: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paned_set_position".}
-proc gtk_paned_compute_position*(paned: PGtkPaned, allocation: gint,
-                                 child1_req: gint, child2_req: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paned_compute_position".}
-proc GTK_TYPE_HBUTTON_BOX*(): GType
-proc GTK_HBUTTON_BOX*(obj: pointer): PGtkHButtonBox
-proc GTK_HBUTTON_BOX_CLASS*(klass: pointer): PGtkHButtonBoxClass
-proc GTK_IS_HBUTTON_BOX*(obj: pointer): bool
-proc GTK_IS_HBUTTON_BOX_CLASS*(klass: pointer): bool
-proc GTK_HBUTTON_BOX_GET_CLASS*(obj: pointer): PGtkHButtonBoxClass
-proc gtk_hbutton_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_hbutton_box_get_type".}
-proc gtk_hbutton_box_new*(): PGtkHButtonBox{.cdecl, dynlib: gtklib,
-    importc: "gtk_hbutton_box_new".}
-proc GTK_TYPE_HPANED*(): GType
-proc GTK_HPANED*(obj: pointer): PGtkHPaned
-proc GTK_HPANED_CLASS*(klass: pointer): PGtkHPanedClass
-proc GTK_IS_HPANED*(obj: pointer): bool
-proc GTK_IS_HPANED_CLASS*(klass: pointer): bool
-proc GTK_HPANED_GET_CLASS*(obj: pointer): PGtkHPanedClass
-proc gtk_hpaned_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_hpaned_get_type".}
-proc gtk_hpaned_new*(): PGtkHPaned{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_hpaned_new".}
-proc GTK_TYPE_RULER*(): GType
-proc GTK_RULER*(obj: pointer): PGtkRuler
-proc GTK_RULER_CLASS*(klass: pointer): PGtkRulerClass
-proc GTK_IS_RULER*(obj: pointer): bool
-proc GTK_IS_RULER_CLASS*(klass: pointer): bool
-proc GTK_RULER_GET_CLASS*(obj: pointer): PGtkRulerClass
-proc gtk_ruler_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_ruler_get_type".}
-proc gtk_ruler_set_metric*(ruler: PGtkRuler, metric: TGtkMetricType){.cdecl,
-    dynlib: gtklib, importc: "gtk_ruler_set_metric".}
-proc gtk_ruler_set_range*(ruler: PGtkRuler, lower: gdouble, upper: gdouble,
-                          position: gdouble, max_size: gdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_ruler_set_range".}
-proc gtk_ruler_draw_ticks*(ruler: PGtkRuler){.cdecl, dynlib: gtklib,
-    importc: "gtk_ruler_draw_ticks".}
-proc gtk_ruler_draw_pos*(ruler: PGtkRuler){.cdecl, dynlib: gtklib,
-    importc: "gtk_ruler_draw_pos".}
-proc gtk_ruler_get_metric*(ruler: PGtkRuler): TGtkMetricType{.cdecl,
-    dynlib: gtklib, importc: "gtk_ruler_get_metric".}
-proc gtk_ruler_get_range*(ruler: PGtkRuler, lower: Pgdouble, upper: Pgdouble,
-                          position: Pgdouble, max_size: Pgdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_ruler_get_range".}
-proc GTK_TYPE_HRULER*(): GType
-proc GTK_HRULER*(obj: pointer): PGtkHRuler
-proc GTK_HRULER_CLASS*(klass: pointer): PGtkHRulerClass
-proc GTK_IS_HRULER*(obj: pointer): bool
-proc GTK_IS_HRULER_CLASS*(klass: pointer): bool
-proc GTK_HRULER_GET_CLASS*(obj: pointer): PGtkHRulerClass
-proc gtk_hruler_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_hruler_get_type".}
-proc gtk_hruler_new*(): PGtkHRuler{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_hruler_new".}
-proc GTK_TYPE_SETTINGS*(): GType
-proc GTK_SETTINGS*(obj: pointer): PGtkSettings
-proc GTK_SETTINGS_CLASS*(klass: pointer): PGtkSettingsClass
-proc GTK_IS_SETTINGS*(obj: pointer): bool
-proc GTK_IS_SETTINGS_CLASS*(klass: pointer): bool
-proc GTK_SETTINGS_GET_CLASS*(obj: pointer): PGtkSettingsClass
-proc gtk_settings_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_settings_get_type".}
-proc gtk_settings_get_for_screen*(screen: PGdkScreen): PGtkSettings{.cdecl,
-    dynlib: gtklib, importc: "gtk_settings_get_for_screen".}
-proc gtk_settings_install_property*(pspec: PGParamSpec){.cdecl, dynlib: gtklib,
-    importc: "gtk_settings_install_property".}
-proc gtk_settings_install_property_parser*(pspec: PGParamSpec,
-    parser: TGtkRcPropertyParser){.cdecl, dynlib: gtklib, importc: "gtk_settings_install_property_parser".}
-proc gtk_rc_property_parse_color*(pspec: PGParamSpec, gstring: PGString,
-                                  property_value: PGValue): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_property_parse_color".}
-proc gtk_rc_property_parse_enum*(pspec: PGParamSpec, gstring: PGString,
-                                 property_value: PGValue): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_property_parse_enum".}
-proc gtk_rc_property_parse_flags*(pspec: PGParamSpec, gstring: PGString,
-                                  property_value: PGValue): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_property_parse_flags".}
-proc gtk_rc_property_parse_requisition*(pspec: PGParamSpec, gstring: PGString,
-                                        property_value: PGValue): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_rc_property_parse_requisition".}
-proc gtk_rc_property_parse_border*(pspec: PGParamSpec, gstring: PGString,
-                                   property_value: PGValue): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_property_parse_border".}
-proc gtk_settings_set_property_value*(settings: PGtkSettings, name: cstring,
-                                      svalue: PGtkSettingsValue){.cdecl,
-    dynlib: gtklib, importc: "gtk_settings_set_property_value".}
-proc gtk_settings_set_string_property*(settings: PGtkSettings, name: cstring,
-                                       v_string: cstring, origin: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_settings_set_string_property".}
-proc gtk_settings_set_long_property*(settings: PGtkSettings, name: cstring,
-                                     v_long: glong, origin: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_settings_set_long_property".}
-proc gtk_settings_set_double_property*(settings: PGtkSettings, name: cstring,
-                                       v_double: gdouble, origin: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_settings_set_double_property".}
-proc gtk_settings_handle_event*(event: PGdkEventSetting){.cdecl,
-    dynlib: gtklib, importc: "_gtk_settings_handle_event".}
-proc gtk_rc_property_parser_from_type*(thetype: GType): TGtkRcPropertyParser{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rc_property_parser_from_type".}
-proc gtk_settings_parse_convert*(parser: TGtkRcPropertyParser,
-                                   src_value: PGValue, pspec: PGParamSpec,
-                                   dest_value: PGValue): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_settings_parse_convert".}
-const
-  GTK_RC_FG* = 1 shl 0
-  GTK_RC_BG* = 1 shl 1
-  GTK_RC_TEXT* = 1 shl 2
-  GTK_RC_BASE* = 1 shl 3
-  bm_TGtkRcStyle_engine_specified* = 0x00000001'i16
-  bp_TGtkRcStyle_engine_specified* = 0'i16
-
-proc GTK_TYPE_RC_STYLE*(): GType
-proc GTK_RC_STYLE_get*(anObject: pointer): PGtkRcStyle
-proc GTK_RC_STYLE_CLASS*(klass: pointer): PGtkRcStyleClass
-proc GTK_IS_RC_STYLE*(anObject: pointer): bool
-proc GTK_IS_RC_STYLE_CLASS*(klass: pointer): bool
-proc GTK_RC_STYLE_GET_CLASS*(obj: pointer): PGtkRcStyleClass
-proc engine_specified*(a: var TGtkRcStyle): guint
-proc set_engine_specified*(a: var TGtkRcStyle, `engine_specified`: guint)
-proc gtk_rc_init*(){.cdecl, dynlib: gtklib, importc: "_gtk_rc_init".}
-proc gtk_rc_add_default_file*(filename: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_add_default_file".}
-proc gtk_rc_set_default_files*(filenames: PPgchar){.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_set_default_files".}
-proc gtk_rc_get_default_files*(): PPgchar{.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_get_default_files".}
-proc gtk_rc_get_style*(widget: PGtkWidget): PGtkStyle{.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_get_style".}
-proc gtk_rc_get_style_by_paths*(settings: PGtkSettings, widget_path: cstring,
-                                class_path: cstring, thetype: GType): PGtkStyle{.
-    cdecl, dynlib: gtklib, importc: "gtk_rc_get_style_by_paths".}
-proc gtk_rc_reparse_all_for_settings*(settings: PGtkSettings,
-                                      force_load: gboolean): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_reparse_all_for_settings".}
-proc gtk_rc_find_pixmap_in_path*(settings: PGtkSettings, scanner: PGScanner,
-                                 pixmap_file: cstring): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_find_pixmap_in_path".}
-proc gtk_rc_parse*(filename: cstring){.cdecl, dynlib: gtklib,
-                                      importc: "gtk_rc_parse".}
-proc gtk_rc_parse_string*(rc_string: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_parse_string".}
-proc gtk_rc_reparse_all*(): gboolean{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_rc_reparse_all".}
-proc gtk_rc_style_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_rc_style_get_type".}
-proc gtk_rc_style_new*(): PGtkRcStyle{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_rc_style_new".}
-proc gtk_rc_style_copy*(orig: PGtkRcStyle): PGtkRcStyle{.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_style_copy".}
-proc gtk_rc_style_ref*(rc_style: PGtkRcStyle){.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_style_ref".}
-proc gtk_rc_style_unref*(rc_style: PGtkRcStyle){.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_style_unref".}
-proc gtk_rc_find_module_in_path*(module_file: cstring): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_find_module_in_path".}
-proc gtk_rc_get_theme_dir*(): cstring{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_rc_get_theme_dir".}
-proc gtk_rc_get_module_dir*(): cstring{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_rc_get_module_dir".}
-proc gtk_rc_get_im_module_path*(): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_get_im_module_path".}
-proc gtk_rc_get_im_module_file*(): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_rc_get_im_module_file".}
-proc gtk_rc_scanner_new*(): PGScanner{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_rc_scanner_new".}
-proc gtk_rc_parse_color*(scanner: PGScanner, color: PGdkColor): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_rc_parse_color".}
-proc gtk_rc_parse_state*(scanner: PGScanner, state: PGtkStateType): guint{.
-    cdecl, dynlib: gtklib, importc: "gtk_rc_parse_state".}
-proc gtk_rc_parse_priority*(scanner: PGScanner, priority: PGtkPathPriorityType): guint{.
-    cdecl, dynlib: gtklib, importc: "gtk_rc_parse_priority".}
-proc gtk_rc_style_lookup_rc_property*(rc_style: PGtkRcStyle,
-                                        type_name: TGQuark,
-                                        property_name: TGQuark): PGtkRcProperty{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rc_style_lookup_rc_property".}
-proc gtk_rc_context_get_default_font_name*(settings: PGtkSettings): cstring{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rc_context_get_default_font_name".}
-proc GTK_TYPE_STYLE*(): GType
-proc GTK_STYLE*(anObject: pointer): PGtkStyle
-proc GTK_STYLE_CLASS*(klass: pointer): PGtkStyleClass
-proc GTK_IS_STYLE*(anObject: pointer): bool
-proc GTK_IS_STYLE_CLASS*(klass: pointer): bool
-proc GTK_STYLE_GET_CLASS*(obj: pointer): PGtkStyleClass
-proc GTK_TYPE_BORDER*(): GType
-proc GTK_STYLE_ATTACHED*(style: pointer): bool
-proc gtk_style_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                   importc: "gtk_style_get_type".}
-proc gtk_style_new*(): PGtkStyle{.cdecl, dynlib: gtklib,
-                                  importc: "gtk_style_new".}
-proc gtk_style_copy*(style: PGtkStyle): PGtkStyle{.cdecl, dynlib: gtklib,
-    importc: "gtk_style_copy".}
-proc gtk_style_attach*(style: PGtkStyle, window: PGdkWindow): PGtkStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_style_attach".}
-proc gtk_style_detach*(style: PGtkStyle){.cdecl, dynlib: gtklib,
-    importc: "gtk_style_detach".}
-proc gtk_style_set_background*(style: PGtkStyle, window: PGdkWindow,
-                               state_type: TGtkStateType){.cdecl,
-    dynlib: gtklib, importc: "gtk_style_set_background".}
-proc gtk_style_apply_default_background*(style: PGtkStyle, window: PGdkWindow,
-    set_bg: gboolean, state_type: TGtkStateType, area: PGdkRectangle, x: gint,
-    y: gint, width: gint, height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_style_apply_default_background".}
-proc gtk_style_lookup_icon_set*(style: PGtkStyle, stock_id: cstring): PGtkIconSet{.
-    cdecl, dynlib: gtklib, importc: "gtk_style_lookup_icon_set".}
-proc gtk_style_render_icon*(style: PGtkStyle, source: PGtkIconSource,
-                            direction: TGtkTextDirection, state: TGtkStateType,
-                            size: TGtkIconSize, widget: PGtkWidget,
-                            detail: cstring): PGdkPixbuf{.cdecl, dynlib: gtklib,
-    importc: "gtk_style_render_icon".}
-proc gtk_paint_hline*(style: PGtkStyle, window: PGdkWindow,
-                      state_type: TGtkStateType, area: PGdkRectangle,
-                      widget: PGtkWidget, detail: cstring, x1: gint, x2: gint,
-                      y: gint){.cdecl, dynlib: gtklib,
-                                importc: "gtk_paint_hline".}
-proc gtk_paint_vline*(style: PGtkStyle, window: PGdkWindow,
-                      state_type: TGtkStateType, area: PGdkRectangle,
-                      widget: PGtkWidget, detail: cstring, y1: gint, y2: gint,
-                      x: gint){.cdecl, dynlib: gtklib,
-                                importc: "gtk_paint_vline".}
-proc gtk_paint_shadow*(style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_shadow".}
-proc gtk_paint_polygon*(style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        points: PGdkPoint, npoints: gint, fill: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_paint_polygon".}
-proc gtk_paint_arrow*(style: PGtkStyle, window: PGdkWindow,
-                      state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                      area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                      arrow_type: TGtkArrowType, fill: gboolean, x: gint,
-                      y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_arrow".}
-proc gtk_paint_diamond*(style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_diamond".}
-proc gtk_paint_box*(style: PGtkStyle, window: PGdkWindow,
-                    state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                    area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                    x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_box".}
-proc gtk_paint_flat_box*(style: PGtkStyle, window: PGdkWindow,
-                         state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                         area: PGdkRectangle, widget: PGtkWidget,
-                         detail: cstring, x: gint, y: gint, width: gint,
-                         height: gint){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_paint_flat_box".}
-proc gtk_paint_check*(style: PGtkStyle, window: PGdkWindow,
-                      state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                      area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                      x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_check".}
-proc gtk_paint_option*(style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_option".}
-proc gtk_paint_tab*(style: PGtkStyle, window: PGdkWindow,
-                    state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                    area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                    x: gint, y: gint, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_tab".}
-proc gtk_paint_shadow_gap*(style: PGtkStyle, window: PGdkWindow,
-                           state_type: TGtkStateType,
-                           shadow_type: TGtkShadowType, area: PGdkRectangle,
-                           widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                           width: gint, height: gint,
-                           gap_side: TGtkPositionType, gap_x: gint,
-                           gap_width: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_paint_shadow_gap".}
-proc gtk_paint_box_gap*(style: PGtkStyle, window: PGdkWindow,
-                        state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                        area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                        x: gint, y: gint, width: gint, height: gint,
-                        gap_side: TGtkPositionType, gap_x: gint, gap_width: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_paint_box_gap".}
-proc gtk_paint_extension*(style: PGtkStyle, window: PGdkWindow,
-                          state_type: TGtkStateType,
-                          shadow_type: TGtkShadowType, area: PGdkRectangle,
-                          widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                          width: gint, height: gint, gap_side: TGtkPositionType){.
-    cdecl, dynlib: gtklib, importc: "gtk_paint_extension".}
-proc gtk_paint_focus*(style: PGtkStyle, window: PGdkWindow,
-                      state_type: TGtkStateType, area: PGdkRectangle,
-                      widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                      width: gint, height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_paint_focus".}
-proc gtk_paint_slider*(style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, width: gint, height: gint,
-                       orientation: TGtkOrientation){.cdecl, dynlib: gtklib,
-    importc: "gtk_paint_slider".}
-proc gtk_paint_handle*(style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, shadow_type: TGtkShadowType,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, width: gint, height: gint,
-                       orientation: TGtkOrientation){.cdecl, dynlib: gtklib,
-    importc: "gtk_paint_handle".}
-proc gtk_paint_expander*(style: PGtkStyle, window: PGdkWindow,
-                         state_type: TGtkStateType, area: PGdkRectangle,
-                         widget: PGtkWidget, detail: cstring, x: gint, y: gint,
-                         expander_style: TGtkExpanderStyle){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_expander".}
-proc gtk_paint_layout*(style: PGtkStyle, window: PGdkWindow,
-                       state_type: TGtkStateType, use_text: gboolean,
-                       area: PGdkRectangle, widget: PGtkWidget, detail: cstring,
-                       x: gint, y: gint, layout: PPangoLayout){.cdecl,
-    dynlib: gtklib, importc: "gtk_paint_layout".}
-proc gtk_paint_resize_grip*(style: PGtkStyle, window: PGdkWindow,
-                            state_type: TGtkStateType, area: PGdkRectangle,
-                            widget: PGtkWidget, detail: cstring,
-                            edge: TGdkWindowEdge, x: gint, y: gint, width: gint,
-                            height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_paint_resize_grip".}
-proc gtk_border_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_border_get_type".}
-proc gtk_border_copy*(border: PGtkBorder): PGtkBorder{.cdecl, dynlib: gtklib,
-    importc: "gtk_border_copy".}
-proc gtk_border_free*(border: PGtkBorder){.cdecl, dynlib: gtklib,
-    importc: "gtk_border_free".}
-proc gtk_style_peek_property_value*(style: PGtkStyle, widget_type: GType,
-                                      pspec: PGParamSpec,
-                                      parser: TGtkRcPropertyParser): PGValue{.
-    cdecl, dynlib: gtklib, importc: "_gtk_style_peek_property_value".}
-proc gtk_get_insertion_cursor_gc*(widget: PGtkWidget, is_primary: gboolean): PGdkGC{.
-    cdecl, dynlib: gtklib, importc: "_gtk_get_insertion_cursor_gc".}
-proc gtk_draw_insertion_cursor*(widget: PGtkWidget, drawable: PGdkDrawable,
-                                  gc: PGdkGC, location: PGdkRectangle,
-                                  direction: TGtkTextDirection,
-                                  draw_arrow: gboolean){.cdecl, dynlib: gtklib,
-    importc: "_gtk_draw_insertion_cursor".}
-const
-  bm_TGtkRange_inverted* = 0x00000001'i16
-  bp_TGtkRange_inverted* = 0'i16
-  bm_TGtkRange_flippable* = 0x00000002'i16
-  bp_TGtkRange_flippable* = 1'i16
-  bm_TGtkRange_has_stepper_a* = 0x00000004'i16
-  bp_TGtkRange_has_stepper_a* = 2'i16
-  bm_TGtkRange_has_stepper_b* = 0x00000008'i16
-  bp_TGtkRange_has_stepper_b* = 3'i16
-  bm_TGtkRange_has_stepper_c* = 0x00000010'i16
-  bp_TGtkRange_has_stepper_c* = 4'i16
-  bm_TGtkRange_has_stepper_d* = 0x00000020'i16
-  bp_TGtkRange_has_stepper_d* = 5'i16
-  bm_TGtkRange_need_recalc* = 0x00000040'i16
-  bp_TGtkRange_need_recalc* = 6'i16
-  bm_TGtkRange_slider_size_fixed* = 0x00000080'i16
-  bp_TGtkRange_slider_size_fixed* = 7'i16
-  bm_TGtkRange_trough_click_forward* = 0x00000001'i16
-  bp_TGtkRange_trough_click_forward* = 0'i16
-  bm_TGtkRange_update_pending* = 0x00000002'i16
-  bp_TGtkRange_update_pending* = 1'i16
-
-proc GTK_TYPE_RANGE*(): GType
-proc GTK_RANGE*(obj: pointer): PGtkRange
-proc GTK_RANGE_CLASS*(klass: pointer): PGtkRangeClass
-proc GTK_IS_RANGE*(obj: pointer): bool
-proc GTK_IS_RANGE_CLASS*(klass: pointer): bool
-proc GTK_RANGE_GET_CLASS*(obj: pointer): PGtkRangeClass
-proc inverted*(a: var TGtkRange): guint
-proc set_inverted*(a: var TGtkRange, `inverted`: guint)
-proc flippable*(a: var TGtkRange): guint
-proc set_flippable*(a: var TGtkRange, `flippable`: guint)
-proc has_stepper_a*(a: var TGtkRange): guint
-proc set_has_stepper_a*(a: var TGtkRange, `has_stepper_a`: guint)
-proc has_stepper_b*(a: var TGtkRange): guint
-proc set_has_stepper_b*(a: var TGtkRange, `has_stepper_b`: guint)
-proc has_stepper_c*(a: var TGtkRange): guint
-proc set_has_stepper_c*(a: var TGtkRange, `has_stepper_c`: guint)
-proc has_stepper_d*(a: var TGtkRange): guint
-proc set_has_stepper_d*(a: var TGtkRange, `has_stepper_d`: guint)
-proc need_recalc*(a: var TGtkRange): guint
-proc set_need_recalc*(a: var TGtkRange, `need_recalc`: guint)
-proc slider_size_fixed*(a: var TGtkRange): guint
-proc set_slider_size_fixed*(a: var TGtkRange, `slider_size_fixed`: guint)
-proc trough_click_forward*(a: var TGtkRange): guint
-proc set_trough_click_forward*(a: var TGtkRange, `trough_click_forward`: guint)
-proc update_pending*(a: var TGtkRange): guint
-proc set_update_pending*(a: var TGtkRange, `update_pending`: guint)
-proc gtk_range_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_range_get_type".}
-proc gtk_range_set_update_policy*(range: PGtkRange, policy: TGtkUpdateType){.
-    cdecl, dynlib: gtklib, importc: "gtk_range_set_update_policy".}
-proc gtk_range_get_update_policy*(range: PGtkRange): TGtkUpdateType{.cdecl,
-    dynlib: gtklib, importc: "gtk_range_get_update_policy".}
-proc gtk_range_set_adjustment*(range: PGtkRange, adjustment: PGtkAdjustment){.
-    cdecl, dynlib: gtklib, importc: "gtk_range_set_adjustment".}
-proc gtk_range_get_adjustment*(range: PGtkRange): PGtkAdjustment{.cdecl,
-    dynlib: gtklib, importc: "gtk_range_get_adjustment".}
-proc gtk_range_set_inverted*(range: PGtkRange, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_range_set_inverted".}
-proc gtk_range_get_inverted*(range: PGtkRange): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_range_get_inverted".}
-proc gtk_range_set_increments*(range: PGtkRange, step: gdouble, page: gdouble){.
-    cdecl, dynlib: gtklib, importc: "gtk_range_set_increments".}
-proc gtk_range_set_range*(range: PGtkRange, min: gdouble, max: gdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_range_set_range".}
-proc gtk_range_set_value*(range: PGtkRange, value: gdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_range_set_value".}
-proc gtk_range_get_value*(range: PGtkRange): gdouble{.cdecl, dynlib: gtklib,
-    importc: "gtk_range_get_value".}
-const
-  bm_TGtkScale_draw_value* = 0x00000001'i16
-  bp_TGtkScale_draw_value* = 0'i16
-  bm_TGtkScale_value_pos* = 0x00000006'i16
-  bp_TGtkScale_value_pos* = 1'i16
-
-proc GTK_TYPE_SCALE*(): GType
-proc GTK_SCALE*(obj: pointer): PGtkScale
-proc GTK_SCALE_CLASS*(klass: pointer): PGtkScaleClass
-proc GTK_IS_SCALE*(obj: pointer): bool
-proc GTK_IS_SCALE_CLASS*(klass: pointer): bool
-proc GTK_SCALE_GET_CLASS*(obj: pointer): PGtkScaleClass
-proc draw_value*(a: var TGtkScale): guint
-proc set_draw_value*(a: var TGtkScale, `draw_value`: guint)
-proc value_pos*(a: var TGtkScale): guint
-proc set_value_pos*(a: var TGtkScale, `value_pos`: guint)
-proc gtk_scale_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_scale_get_type".}
-proc gtk_scale_set_digits*(scale: PGtkScale, digits: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_scale_set_digits".}
-proc gtk_scale_get_digits*(scale: PGtkScale): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_scale_get_digits".}
-proc gtk_scale_set_draw_value*(scale: PGtkScale, draw_value: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_scale_set_draw_value".}
-proc gtk_scale_get_draw_value*(scale: PGtkScale): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_scale_get_draw_value".}
-proc gtk_scale_set_value_pos*(scale: PGtkScale, pos: TGtkPositionType){.cdecl,
-    dynlib: gtklib, importc: "gtk_scale_set_value_pos".}
-proc gtk_scale_get_value_pos*(scale: PGtkScale): TGtkPositionType{.cdecl,
-    dynlib: gtklib, importc: "gtk_scale_get_value_pos".}
-proc gtk_scale_get_value_size*(scale: PGtkScale, width: Pgint, height: Pgint){.
-    cdecl, dynlib: gtklib, importc: "_gtk_scale_get_value_size".}
-proc gtk_scale_format_value*(scale: PGtkScale, value: gdouble): cstring{.cdecl,
-    dynlib: gtklib, importc: "_gtk_scale_format_value".}
-proc GTK_TYPE_HSCALE*(): GType
-proc GTK_HSCALE*(obj: pointer): PGtkHScale
-proc GTK_HSCALE_CLASS*(klass: pointer): PGtkHScaleClass
-proc GTK_IS_HSCALE*(obj: pointer): bool
-proc GTK_IS_HSCALE_CLASS*(klass: pointer): bool
-proc GTK_HSCALE_GET_CLASS*(obj: pointer): PGtkHScaleClass
-proc gtk_hscale_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_hscale_get_type".}
-proc gtk_hscale_new*(adjustment: PGtkAdjustment): PGtkHScale{.cdecl,
-    dynlib: gtklib, importc: "gtk_hscale_new".}
-proc gtk_hscale_new_with_range*(min: gdouble, max: gdouble, step: gdouble): PGtkHScale{.
-    cdecl, dynlib: gtklib, importc: "gtk_hscale_new_with_range".}
-proc GTK_TYPE_SCROLLBAR*(): GType
-proc GTK_SCROLLBAR*(obj: pointer): PGtkScrollbar
-proc GTK_SCROLLBAR_CLASS*(klass: pointer): PGtkScrollbarClass
-proc GTK_IS_SCROLLBAR*(obj: pointer): bool
-proc GTK_IS_SCROLLBAR_CLASS*(klass: pointer): bool
-proc GTK_SCROLLBAR_GET_CLASS*(obj: pointer): PGtkScrollbarClass
-proc gtk_scrollbar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_scrollbar_get_type".}
-proc GTK_TYPE_HSCROLLBAR*(): GType
-proc GTK_HSCROLLBAR*(obj: pointer): PGtkHScrollbar
-proc GTK_HSCROLLBAR_CLASS*(klass: pointer): PGtkHScrollbarClass
-proc GTK_IS_HSCROLLBAR*(obj: pointer): bool
-proc GTK_IS_HSCROLLBAR_CLASS*(klass: pointer): bool
-proc GTK_HSCROLLBAR_GET_CLASS*(obj: pointer): PGtkHScrollbarClass
-proc gtk_hscrollbar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_hscrollbar_get_type".}
-proc gtk_hscrollbar_new*(adjustment: PGtkAdjustment): PGtkHScrollbar{.cdecl,
-    dynlib: gtklib, importc: "gtk_hscrollbar_new".}
-proc GTK_TYPE_SEPARATOR*(): GType
-proc GTK_SEPARATOR*(obj: pointer): PGtkSeparator
-proc GTK_SEPARATOR_CLASS*(klass: pointer): PGtkSeparatorClass
-proc GTK_IS_SEPARATOR*(obj: pointer): bool
-proc GTK_IS_SEPARATOR_CLASS*(klass: pointer): bool
-proc GTK_SEPARATOR_GET_CLASS*(obj: pointer): PGtkSeparatorClass
-proc gtk_separator_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_separator_get_type".}
-proc GTK_TYPE_HSEPARATOR*(): GType
-proc GTK_HSEPARATOR*(obj: pointer): PGtkHSeparator
-proc GTK_HSEPARATOR_CLASS*(klass: pointer): PGtkHSeparatorClass
-proc GTK_IS_HSEPARATOR*(obj: pointer): bool
-proc GTK_IS_HSEPARATOR_CLASS*(klass: pointer): bool
-proc GTK_HSEPARATOR_GET_CLASS*(obj: pointer): PGtkHSeparatorClass
-proc gtk_hseparator_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_hseparator_get_type".}
-proc gtk_hseparator_new*(): PGtkHSeparator{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_hseparator_new".}
-proc GTK_TYPE_ICON_FACTORY*(): GType
-proc GTK_ICON_FACTORY*(anObject: pointer): PGtkIconFactory
-proc GTK_ICON_FACTORY_CLASS*(klass: pointer): PGtkIconFactoryClass
-proc GTK_IS_ICON_FACTORY*(anObject: pointer): bool
-proc GTK_IS_ICON_FACTORY_CLASS*(klass: pointer): bool
-proc GTK_ICON_FACTORY_GET_CLASS*(obj: pointer): PGtkIconFactoryClass
-proc GTK_TYPE_ICON_SET*(): GType
-proc GTK_TYPE_ICON_SOURCE*(): GType
-proc gtk_icon_factory_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_factory_get_type".}
-proc gtk_icon_factory_new*(): PGtkIconFactory{.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_factory_new".}
-proc gtk_icon_factory_add*(factory: PGtkIconFactory, stock_id: cstring,
-                           icon_set: PGtkIconSet){.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_factory_add".}
-proc gtk_icon_factory_lookup*(factory: PGtkIconFactory, stock_id: cstring): PGtkIconSet{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_factory_lookup".}
-proc gtk_icon_factory_add_default*(factory: PGtkIconFactory){.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_factory_add_default".}
-proc gtk_icon_factory_remove_default*(factory: PGtkIconFactory){.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_factory_remove_default".}
-proc gtk_icon_factory_lookup_default*(stock_id: cstring): PGtkIconSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_factory_lookup_default".}
-proc gtk_icon_size_lookup*(size: TGtkIconSize, width: Pgint, height: Pgint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_size_lookup".}
-proc gtk_icon_size_register*(name: cstring, width: gint, height: gint): TGtkIconSize{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_size_register".}
-proc gtk_icon_size_register_alias*(alias: cstring, target: TGtkIconSize){.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_size_register_alias".}
-proc gtk_icon_size_from_name*(name: cstring): TGtkIconSize{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_size_from_name".}
-proc gtk_icon_size_get_name*(size: TGtkIconSize): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_size_get_name".}
-proc gtk_icon_set_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_icon_set_get_type".}
-proc gtk_icon_set_new*(): PGtkIconSet{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_icon_set_new".}
-proc gtk_icon_set_new_from_pixbuf*(pixbuf: PGdkPixbuf): PGtkIconSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_set_new_from_pixbuf".}
-proc gtk_icon_set_ref*(icon_set: PGtkIconSet): PGtkIconSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_set_ref".}
-proc gtk_icon_set_unref*(icon_set: PGtkIconSet){.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_set_unref".}
-proc gtk_icon_set_copy*(icon_set: PGtkIconSet): PGtkIconSet{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_set_copy".}
-proc gtk_icon_set_render_icon*(icon_set: PGtkIconSet, style: PGtkStyle,
-                               direction: TGtkTextDirection,
-                               state: TGtkStateType, size: TGtkIconSize,
-                               widget: PGtkWidget, detail: cstring): PGdkPixbuf{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_set_render_icon".}
-proc gtk_icon_set_add_source*(icon_set: PGtkIconSet, source: PGtkIconSource){.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_set_add_source".}
-proc gtk_icon_set_get_sizes*(icon_set: PGtkIconSet, sizes: PPGtkIconSize,
-                             n_sizes: pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_set_get_sizes".}
-proc gtk_icon_source_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_source_get_type".}
-proc gtk_icon_source_new*(): PGtkIconSource{.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_source_new".}
-proc gtk_icon_source_copy*(source: PGtkIconSource): PGtkIconSource{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_copy".}
-proc gtk_icon_source_free*(source: PGtkIconSource){.cdecl, dynlib: gtklib,
-    importc: "gtk_icon_source_free".}
-proc gtk_icon_source_set_filename*(source: PGtkIconSource, filename: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_set_filename".}
-proc gtk_icon_source_set_pixbuf*(source: PGtkIconSource, pixbuf: PGdkPixbuf){.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_set_pixbuf".}
-proc gtk_icon_source_get_filename*(source: PGtkIconSource): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_get_filename".}
-proc gtk_icon_source_get_pixbuf*(source: PGtkIconSource): PGdkPixbuf{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_get_pixbuf".}
-proc gtk_icon_source_set_direction_wildcarded*(source: PGtkIconSource,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_icon_source_set_direction_wildcarded".}
-proc gtk_icon_source_set_state_wildcarded*(source: PGtkIconSource,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_icon_source_set_state_wildcarded".}
-proc gtk_icon_source_set_size_wildcarded*(source: PGtkIconSource,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_icon_source_set_size_wildcarded".}
-proc gtk_icon_source_get_size_wildcarded*(source: PGtkIconSource): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_get_size_wildcarded".}
-proc gtk_icon_source_get_state_wildcarded*(source: PGtkIconSource): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_get_state_wildcarded".}
-proc gtk_icon_source_get_direction_wildcarded*(source: PGtkIconSource): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_get_direction_wildcarded".}
-proc gtk_icon_source_set_direction*(source: PGtkIconSource,
-                                    direction: TGtkTextDirection){.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_set_direction".}
-proc gtk_icon_source_set_state*(source: PGtkIconSource, state: TGtkStateType){.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_set_state".}
-proc gtk_icon_source_set_size*(source: PGtkIconSource, size: TGtkIconSize){.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_set_size".}
-proc gtk_icon_source_get_direction*(source: PGtkIconSource): TGtkTextDirection{.
-    cdecl, dynlib: gtklib, importc: "gtk_icon_source_get_direction".}
-proc gtk_icon_source_get_state*(source: PGtkIconSource): TGtkStateType{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_get_state".}
-proc gtk_icon_source_get_size*(source: PGtkIconSource): TGtkIconSize{.cdecl,
-    dynlib: gtklib, importc: "gtk_icon_source_get_size".}
-proc gtk_icon_set_invalidate_caches*(){.cdecl, dynlib: gtklib,
-    importc: "_gtk_icon_set_invalidate_caches".}
-proc gtk_icon_factory_list_ids*(): PGSList{.cdecl, dynlib: gtklib,
-    importc: "_gtk_icon_factory_list_ids".}
-proc GTK_TYPE_IMAGE*(): GType
-proc GTK_IMAGE*(obj: pointer): PGtkImage
-proc GTK_IMAGE_CLASS*(klass: pointer): PGtkImageClass
-proc GTK_IS_IMAGE*(obj: pointer): bool
-proc GTK_IS_IMAGE_CLASS*(klass: pointer): bool
-proc GTK_IMAGE_GET_CLASS*(obj: pointer): PGtkImageClass
-proc gtk_image_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_image_get_type".}
-proc gtk_image_new*(): PGtkImage{.cdecl, dynlib: gtklib,
-                                   importc: "gtk_image_new".}
-proc gtk_image_new_from_pixmap*(pixmap: PGdkPixmap, mask: PGdkBitmap): PGtkImage{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_new_from_pixmap".}
-proc gtk_image_new_from_image*(image: PGdkImage, mask: PGdkBitmap): PGtkImage{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_new_from_image".}
-proc gtk_image_new_from_file*(filename: cstring): PGtkImage{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_new_from_file".}
-proc gtk_image_new_from_pixbuf*(pixbuf: PGdkPixbuf): PGtkImage{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_new_from_pixbuf".}
-proc gtk_image_new_from_stock*(stock_id: cstring, size: TGtkIconSize): PGtkImage{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_new_from_stock".}
-proc gtk_image_new_from_icon_set*(icon_set: PGtkIconSet, size: TGtkIconSize): PGtkImage{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_new_from_icon_set".}
-proc gtk_image_new_from_animation*(animation: PGdkPixbufAnimation): PGtkImage{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_new_from_animation".}
-proc gtk_image_set_from_pixmap*(image: PGtkImage, pixmap: PGdkPixmap,
-                                mask: PGdkBitmap){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_set_from_pixmap".}
-proc gtk_image_set_from_image*(image: PGtkImage, gdk_image: PGdkImage,
-                               mask: PGdkBitmap){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_set_from_image".}
-proc gtk_image_set_from_file*(image: PGtkImage, filename: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_image_set_from_file".}
-proc gtk_image_set_from_pixbuf*(image: PGtkImage, pixbuf: PGdkPixbuf){.cdecl,
-    dynlib: gtklib, importc: "gtk_image_set_from_pixbuf".}
-proc gtk_image_set_from_stock*(image: PGtkImage, stock_id: cstring,
-                               size: TGtkIconSize){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_set_from_stock".}
-proc gtk_image_set_from_icon_set*(image: PGtkImage, icon_set: PGtkIconSet,
-                                  size: TGtkIconSize){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_set_from_icon_set".}
-proc gtk_image_set_from_animation*(image: PGtkImage,
-                                   animation: PGdkPixbufAnimation){.cdecl,
-    dynlib: gtklib, importc: "gtk_image_set_from_animation".}
-proc gtk_image_get_storage_type*(image: PGtkImage): TGtkImageType{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_get_storage_type".}
-proc gtk_image_get_pixbuf*(image: PGtkImage): PGdkPixbuf{.cdecl, dynlib: gtklib,
-    importc: "gtk_image_get_pixbuf".}
-proc gtk_image_get_stock*(image: PGtkImage, stock_id: PPgchar,
-                          size: PGtkIconSize){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_get_stock".}
-proc gtk_image_get_animation*(image: PGtkImage): PGdkPixbufAnimation{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_get_animation".}
-proc GTK_TYPE_IMAGE_MENU_ITEM*(): GType
-proc GTK_IMAGE_MENU_ITEM*(obj: pointer): PGtkImageMenuItem
-proc GTK_IMAGE_MENU_ITEM_CLASS*(klass: pointer): PGtkImageMenuItemClass
-proc GTK_IS_IMAGE_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_IMAGE_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_IMAGE_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkImageMenuItemClass
-proc gtk_image_menu_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_image_menu_item_get_type".}
-proc gtk_image_menu_item_new*(): PGtkImageMenuItem{.cdecl, dynlib: gtklib,
-    importc: "gtk_image_menu_item_new".}
-proc gtk_image_menu_item_new_with_label*(`label`: cstring): PGtkImageMenuItem{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_menu_item_new_with_label".}
-proc gtk_image_menu_item_new_with_mnemonic*(`label`: cstring): PGtkImageMenuItem{.cdecl,
-    dynlib: gtklib, importc: "gtk_image_menu_item_new_with_mnemonic".}
-proc gtk_image_menu_item_new_from_stock*(stock_id: cstring,
-    accel_group: PGtkAccelGroup): PGtkImageMenuItem{.cdecl, dynlib: gtklib,
-    importc: "gtk_image_menu_item_new_from_stock".}
-proc gtk_image_menu_item_set_image*(image_menu_item: PGtkImageMenuItem,
-                                    image: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_image_menu_item_set_image".}
-proc gtk_image_menu_item_get_image*(image_menu_item: PGtkImageMenuItem): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_image_menu_item_get_image".}
-const
-  bm_TGtkIMContextSimple_in_hex_sequence* = 0x00000001'i16
-  bp_TGtkIMContextSimple_in_hex_sequence* = 0'i16
-
-proc GTK_TYPE_IM_CONTEXT_SIMPLE*(): GType
-proc GTK_IM_CONTEXT_SIMPLE*(obj: pointer): PGtkIMContextSimple
-proc GTK_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): PGtkIMContextSimpleClass
-proc GTK_IS_IM_CONTEXT_SIMPLE*(obj: pointer): bool
-proc GTK_IS_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): bool
-proc GTK_IM_CONTEXT_SIMPLE_GET_CLASS*(obj: pointer): PGtkIMContextSimpleClass
-proc in_hex_sequence*(a: var TGtkIMContextSimple): guint
-proc set_in_hex_sequence*(a: var TGtkIMContextSimple, `in_hex_sequence`: guint)
-proc gtk_im_context_simple_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_simple_get_type".}
-proc gtk_im_context_simple_new*(): PGtkIMContext{.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_simple_new".}
-proc gtk_im_context_simple_add_table*(context_simple: PGtkIMContextSimple,
-                                      data: Pguint16, max_seq_len: gint,
-                                      n_seqs: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_im_context_simple_add_table".}
-proc GTK_TYPE_IM_MULTICONTEXT*(): GType
-proc GTK_IM_MULTICONTEXT*(obj: pointer): PGtkIMMulticontext
-proc GTK_IM_MULTICONTEXT_CLASS*(klass: pointer): PGtkIMMulticontextClass
-proc GTK_IS_IM_MULTICONTEXT*(obj: pointer): bool
-proc GTK_IS_IM_MULTICONTEXT_CLASS*(klass: pointer): bool
-proc GTK_IM_MULTICONTEXT_GET_CLASS*(obj: pointer): PGtkIMMulticontextClass
-proc gtk_im_multicontext_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_im_multicontext_get_type".}
-proc gtk_im_multicontext_new*(): PGtkIMContext{.cdecl, dynlib: gtklib,
-    importc: "gtk_im_multicontext_new".}
-proc gtk_im_multicontext_append_menuitems*(context: PGtkIMMulticontext,
-    menushell: PGtkMenuShell){.cdecl, dynlib: gtklib,
-                               importc: "gtk_im_multicontext_append_menuitems".}
-proc GTK_TYPE_INPUT_DIALOG*(): GType
-proc GTK_INPUT_DIALOG*(obj: pointer): PGtkInputDialog
-proc GTK_INPUT_DIALOG_CLASS*(klass: pointer): PGtkInputDialogClass
-proc GTK_IS_INPUT_DIALOG*(obj: pointer): bool
-proc GTK_IS_INPUT_DIALOG_CLASS*(klass: pointer): bool
-proc GTK_INPUT_DIALOG_GET_CLASS*(obj: pointer): PGtkInputDialogClass
-proc gtk_input_dialog_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_input_dialog_get_type".}
-proc gtk_input_dialog_new*(): PGtkInputDialog{.cdecl, dynlib: gtklib,
-    importc: "gtk_input_dialog_new".}
-proc GTK_TYPE_INVISIBLE*(): GType
-proc GTK_INVISIBLE*(obj: pointer): PGtkInvisible
-proc GTK_INVISIBLE_CLASS*(klass: pointer): PGtkInvisibleClass
-proc GTK_IS_INVISIBLE*(obj: pointer): bool
-proc GTK_IS_INVISIBLE_CLASS*(klass: pointer): bool
-proc GTK_INVISIBLE_GET_CLASS*(obj: pointer): PGtkInvisibleClass
-proc gtk_invisible_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_invisible_get_type".}
-proc gtk_invisible_new*(): PGtkInvisible{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_invisible_new".}
-proc gtk_invisible_new_for_screen*(screen: PGdkScreen): PGtkInvisible{.cdecl,
-    dynlib: gtklib, importc: "gtk_invisible_new_for_screen".}
-proc gtk_invisible_set_screen*(invisible: PGtkInvisible, screen: PGdkScreen){.
-    cdecl, dynlib: gtklib, importc: "gtk_invisible_set_screen".}
-proc gtk_invisible_get_screen*(invisible: PGtkInvisible): PGdkScreen{.cdecl,
-    dynlib: gtklib, importc: "gtk_invisible_get_screen".}
-proc GTK_TYPE_ITEM_FACTORY*(): GType
-proc GTK_ITEM_FACTORY*(anObject: pointer): PGtkItemFactory
-proc GTK_ITEM_FACTORY_CLASS*(klass: pointer): PGtkItemFactoryClass
-proc GTK_IS_ITEM_FACTORY*(anObject: pointer): bool
-proc GTK_IS_ITEM_FACTORY_CLASS*(klass: pointer): bool
-proc GTK_ITEM_FACTORY_GET_CLASS*(obj: pointer): PGtkItemFactoryClass
-proc gtk_item_factory_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_item_factory_get_type".}
-proc gtk_item_factory_new*(container_type: TGtkType, path: cstring,
-                           accel_group: PGtkAccelGroup): PGtkItemFactory{.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_new".}
-proc gtk_item_factory_construct*(ifactory: PGtkItemFactory,
-                                 container_type: TGtkType, path: cstring,
-                                 accel_group: PGtkAccelGroup){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_construct".}
-proc gtk_item_factory_add_foreign*(accel_widget: PGtkWidget, full_path: cstring,
-                                   accel_group: PGtkAccelGroup, keyval: guint,
-                                   modifiers: TGdkModifierType){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_add_foreign".}
-proc gtk_item_factory_from_widget*(widget: PGtkWidget): PGtkItemFactory{.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_from_widget".}
-proc gtk_item_factory_path_from_widget*(widget: PGtkWidget): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_path_from_widget".}
-proc gtk_item_factory_get_item*(ifactory: PGtkItemFactory, path: cstring): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_item_factory_get_item".}
-proc gtk_item_factory_get_widget*(ifactory: PGtkItemFactory, path: cstring): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_item_factory_get_widget".}
-proc gtk_item_factory_get_widget_by_action*(ifactory: PGtkItemFactory,
-    action: guint): PGtkWidget{.cdecl, dynlib: gtklib, importc: "gtk_item_factory_get_widget_by_action".}
-proc gtk_item_factory_get_item_by_action*(ifactory: PGtkItemFactory,
-    action: guint): PGtkWidget{.cdecl, dynlib: gtklib,
-                                importc: "gtk_item_factory_get_item_by_action".}
-proc gtk_item_factory_create_item*(ifactory: PGtkItemFactory,
-                                   entry: PGtkItemFactoryEntry,
-                                   callback_data: gpointer, callback_type: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_item_factory_create_item".}
-proc gtk_item_factory_create_items*(ifactory: PGtkItemFactory, n_entries: guint,
-                                    entries: PGtkItemFactoryEntry,
-                                    callback_data: gpointer){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_create_items".}
-proc gtk_item_factory_delete_item*(ifactory: PGtkItemFactory, path: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_item_factory_delete_item".}
-proc gtk_item_factory_delete_entry*(ifactory: PGtkItemFactory,
-                                    entry: PGtkItemFactoryEntry){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_delete_entry".}
-proc gtk_item_factory_delete_entries*(ifactory: PGtkItemFactory,
-                                      n_entries: guint,
-                                      entries: PGtkItemFactoryEntry){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_delete_entries".}
-proc gtk_item_factory_popup*(ifactory: PGtkItemFactory, x: guint, y: guint,
-                             mouse_button: guint, time: guint32){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_popup".}
-proc gtk_item_factory_popup_with_data*(ifactory: PGtkItemFactory,
-                                       popup_data: gpointer,
-                                       destroy: TGtkDestroyNotify, x: guint,
-                                       y: guint, mouse_button: guint,
-                                       time: guint32){.cdecl, dynlib: gtklib,
-    importc: "gtk_item_factory_popup_with_data".}
-proc gtk_item_factory_popup_data*(ifactory: PGtkItemFactory): gpointer{.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_popup_data".}
-proc gtk_item_factory_popup_data_from_widget*(widget: PGtkWidget): gpointer{.
-    cdecl, dynlib: gtklib, importc: "gtk_item_factory_popup_data_from_widget".}
-proc gtk_item_factory_set_translate_func*(ifactory: PGtkItemFactory,
-    fun: TGtkTranslateFunc, data: gpointer, notify: TGtkDestroyNotify){.cdecl,
-    dynlib: gtklib, importc: "gtk_item_factory_set_translate_func".}
-proc GTK_TYPE_LAYOUT*(): GType
-proc GTK_LAYOUT*(obj: pointer): PGtkLayout
-proc GTK_LAYOUT_CLASS*(klass: pointer): PGtkLayoutClass
-proc GTK_IS_LAYOUT*(obj: pointer): bool
-proc GTK_IS_LAYOUT_CLASS*(klass: pointer): bool
-proc GTK_LAYOUT_GET_CLASS*(obj: pointer): PGtkLayoutClass
-proc gtk_layout_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_layout_get_type".}
-proc gtk_layout_new*(hadjustment: PGtkAdjustment, vadjustment: PGtkAdjustment): PGtkLayout{.
-    cdecl, dynlib: gtklib, importc: "gtk_layout_new".}
-proc gtk_layout_put*(layout: PGtkLayout, child_widget: PGtkWidget, x: gint,
-                     y: gint){.cdecl, dynlib: gtklib, importc: "gtk_layout_put".}
-proc gtk_layout_move*(layout: PGtkLayout, child_widget: PGtkWidget, x: gint,
-                      y: gint){.cdecl, dynlib: gtklib,
-                                importc: "gtk_layout_move".}
-proc gtk_layout_set_size*(layout: PGtkLayout, width: guint, height: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_layout_set_size".}
-proc gtk_layout_get_size*(layout: PGtkLayout, width: Pguint, height: Pguint){.
-    cdecl, dynlib: gtklib, importc: "gtk_layout_get_size".}
-proc gtk_layout_get_hadjustment*(layout: PGtkLayout): PGtkAdjustment{.cdecl,
-    dynlib: gtklib, importc: "gtk_layout_get_hadjustment".}
-proc gtk_layout_get_vadjustment*(layout: PGtkLayout): PGtkAdjustment{.cdecl,
-    dynlib: gtklib, importc: "gtk_layout_get_vadjustment".}
-proc gtk_layout_set_hadjustment*(layout: PGtkLayout, adjustment: PGtkAdjustment){.
-    cdecl, dynlib: gtklib, importc: "gtk_layout_set_hadjustment".}
-proc gtk_layout_set_vadjustment*(layout: PGtkLayout, adjustment: PGtkAdjustment){.
-    cdecl, dynlib: gtklib, importc: "gtk_layout_set_vadjustment".}
-const
-  bm_TGtkList_selection_mode* = 0x00000003'i16
-  bp_TGtkList_selection_mode* = 0'i16
-  bm_TGtkList_drag_selection* = 0x00000004'i16
-  bp_TGtkList_drag_selection* = 2'i16
-  bm_TGtkList_add_mode* = 0x00000008'i16
-  bp_TGtkList_add_mode* = 3'i16
-
-proc GTK_TYPE_LIST*(): GType
-proc GTK_LIST*(obj: pointer): PGtkList
-proc GTK_LIST_CLASS*(klass: pointer): PGtkListClass
-proc GTK_IS_LIST*(obj: pointer): bool
-proc GTK_IS_LIST_CLASS*(klass: pointer): bool
-proc GTK_LIST_GET_CLASS*(obj: pointer): PGtkListClass
-proc selection_mode*(a: var TGtkList): guint
-proc set_selection_mode*(a: var TGtkList, `selection_mode`: guint)
-proc drag_selection*(a: var TGtkList): guint
-proc set_drag_selection*(a: var TGtkList, `drag_selection`: guint)
-proc add_mode*(a: var TGtkList): guint
-proc set_add_mode*(a: var TGtkList, `add_mode`: guint)
-proc gtk_list_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_list_get_type".}
-proc gtk_list_new*(): PGtkList{.cdecl, dynlib: gtklib, importc: "gtk_list_new".}
-proc gtk_list_insert_items*(list: PGtkList, items: PGList, position: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_insert_items".}
-proc gtk_list_append_items*(list: PGtkList, items: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_append_items".}
-proc gtk_list_prepend_items*(list: PGtkList, items: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_prepend_items".}
-proc gtk_list_remove_items*(list: PGtkList, items: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_remove_items".}
-proc gtk_list_remove_items_no_unref*(list: PGtkList, items: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_remove_items_no_unref".}
-proc gtk_list_clear_items*(list: PGtkList, start: gint, theEnd: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_clear_items".}
-proc gtk_list_select_item*(list: PGtkList, item: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_select_item".}
-proc gtk_list_unselect_item*(list: PGtkList, item: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_unselect_item".}
-proc gtk_list_select_child*(list: PGtkList, child: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_select_child".}
-proc gtk_list_unselect_child*(list: PGtkList, child: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_unselect_child".}
-proc gtk_list_child_position*(list: PGtkList, child: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_list_child_position".}
-proc gtk_list_set_selection_mode*(list: PGtkList, mode: TGtkSelectionMode){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_set_selection_mode".}
-proc gtk_list_extend_selection*(list: PGtkList, scroll_type: TGtkScrollType,
-                                position: gfloat, auto_start_selection: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_extend_selection".}
-proc gtk_list_start_selection*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_start_selection".}
-proc gtk_list_end_selection*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_end_selection".}
-proc gtk_list_select_all*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_select_all".}
-proc gtk_list_unselect_all*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_unselect_all".}
-proc gtk_list_scroll_horizontal*(list: PGtkList, scroll_type: TGtkScrollType,
-                                 position: gfloat){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_scroll_horizontal".}
-proc gtk_list_scroll_vertical*(list: PGtkList, scroll_type: TGtkScrollType,
-                               position: gfloat){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_scroll_vertical".}
-proc gtk_list_toggle_add_mode*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_toggle_add_mode".}
-proc gtk_list_toggle_focus_row*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_toggle_focus_row".}
-proc gtk_list_toggle_row*(list: PGtkList, item: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_toggle_row".}
-proc gtk_list_undo_selection*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_undo_selection".}
-proc gtk_list_end_drag_selection*(list: PGtkList){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_end_drag_selection".}
-const
-  GTK_TREE_MODEL_ITERS_PERSIST* = 1 shl 0
-  GTK_TREE_MODEL_LIST_ONLY* = 1 shl 1
-
-proc GTK_TYPE_TREE_MODEL*(): GType
-proc GTK_TREE_MODEL*(obj: pointer): PGtkTreeModel
-proc GTK_IS_TREE_MODEL*(obj: pointer): bool
-proc GTK_TREE_MODEL_GET_IFACE*(obj: pointer): PGtkTreeModelIface
-proc GTK_TYPE_TREE_ITER*(): GType
-proc GTK_TYPE_TREE_PATH*(): GType
-proc gtk_tree_path_new*(): PGtkTreePath{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_new".}
-proc gtk_tree_path_new_from_string*(path: cstring): PGtkTreePath{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_new_from_string".}
-proc gtk_tree_path_to_string*(path: PGtkTreePath): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_to_string".}
-proc gtk_tree_path_new_root*(): PGtkTreePath
-proc gtk_tree_path_new_first*(): PGtkTreePath{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_new_first".}
-proc gtk_tree_path_append_index*(path: PGtkTreePath, index: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_append_index".}
-proc gtk_tree_path_prepend_index*(path: PGtkTreePath, index: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_prepend_index".}
-proc gtk_tree_path_get_depth*(path: PGtkTreePath): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_get_depth".}
-proc gtk_tree_path_get_indices*(path: PGtkTreePath): Pgint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_get_indices".}
-proc gtk_tree_path_free*(path: PGtkTreePath){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_free".}
-proc gtk_tree_path_copy*(path: PGtkTreePath): PGtkTreePath{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_copy".}
-proc gtk_tree_path_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_tree_path_get_type".}
-proc gtk_tree_path_compare*(a: PGtkTreePath, b: PGtkTreePath): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_path_compare".}
-proc gtk_tree_path_next*(path: PGtkTreePath){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_next".}
-proc gtk_tree_path_prev*(path: PGtkTreePath): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_prev".}
-proc gtk_tree_path_up*(path: PGtkTreePath): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_up".}
-proc gtk_tree_path_down*(path: PGtkTreePath){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_path_down".}
-proc gtk_tree_path_is_ancestor*(path: PGtkTreePath, descendant: PGtkTreePath): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_path_is_ancestor".}
-proc gtk_tree_path_is_descendant*(path: PGtkTreePath, ancestor: PGtkTreePath): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_path_is_descendant".}
-proc gtk_tree_row_reference_new*(model: PGtkTreeModel, path: PGtkTreePath): PGtkTreeRowReference{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_new".}
-proc gtk_tree_row_reference_new_proxy*(proxy: PGObject, model: PGtkTreeModel,
-                                       path: PGtkTreePath): PGtkTreeRowReference{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_new_proxy".}
-proc gtk_tree_row_reference_get_path*(reference: PGtkTreeRowReference): PGtkTreePath{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_get_path".}
-proc gtk_tree_row_reference_valid*(reference: PGtkTreeRowReference): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_valid".}
-proc gtk_tree_row_reference_free*(reference: PGtkTreeRowReference){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_row_reference_free".}
-proc gtk_tree_row_reference_inserted*(proxy: PGObject, path: PGtkTreePath){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_inserted".}
-proc gtk_tree_row_reference_deleted*(proxy: PGObject, path: PGtkTreePath){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_deleted".}
-proc gtk_tree_row_reference_reordered*(proxy: PGObject, path: PGtkTreePath,
-                                       iter: PGtkTreeIter, new_order: Pgint){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_row_reference_reordered".}
-proc gtk_tree_iter_copy*(iter: PGtkTreeIter): PGtkTreeIter{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_iter_copy".}
-proc gtk_tree_iter_free*(iter: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_iter_free".}
-proc gtk_tree_iter_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_tree_iter_get_type".}
-proc gtk_tree_model_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_get_type".}
-proc gtk_tree_model_get_flags*(tree_model: PGtkTreeModel): TGtkTreeModelFlags{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_get_flags".}
-proc gtk_tree_model_get_n_columns*(tree_model: PGtkTreeModel): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_get_n_columns".}
-proc gtk_tree_model_get_column_type*(tree_model: PGtkTreeModel, index: gint): GType{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_get_column_type".}
-proc gtk_tree_model_get_iter*(tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                              path: PGtkTreePath): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_get_iter".}
-proc gtk_tree_model_get_iter_from_string*(tree_model: PGtkTreeModel,
-    iter: PGtkTreeIter, path_string: cstring): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_get_iter_from_string".}
-proc gtk_tree_model_get_iter_root*(tree_model: PGtkTreeModel, iter: PGtkTreeIter): gboolean
-proc gtk_tree_model_get_iter_first*(tree_model: PGtkTreeModel,
-                                    iter: PGtkTreeIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_get_iter_first".}
-proc gtk_tree_model_get_path*(tree_model: PGtkTreeModel, iter: PGtkTreeIter): PGtkTreePath{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_get_path".}
-proc gtk_tree_model_get_value*(tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                               column: gint, value: PGValue){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_get_value".}
-proc gtk_tree_model_iter_next*(tree_model: PGtkTreeModel, iter: PGtkTreeIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_iter_next".}
-proc gtk_tree_model_iter_children*(tree_model: PGtkTreeModel,
-                                   iter: PGtkTreeIter, parent: PGtkTreeIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_iter_children".}
-proc gtk_tree_model_iter_has_child*(tree_model: PGtkTreeModel,
-                                    iter: PGtkTreeIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_iter_has_child".}
-proc gtk_tree_model_iter_n_children*(tree_model: PGtkTreeModel,
-                                     iter: PGtkTreeIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_iter_n_children".}
-proc gtk_tree_model_iter_nth_child*(tree_model: PGtkTreeModel,
-                                    iter: PGtkTreeIter, parent: PGtkTreeIter,
-                                    n: gint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_iter_nth_child".}
-proc gtk_tree_model_iter_parent*(tree_model: PGtkTreeModel, iter: PGtkTreeIter,
-                                 child: PGtkTreeIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_model_iter_parent".}
-proc gtk_tree_model_ref_node*(tree_model: PGtkTreeModel, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_ref_node".}
-proc gtk_tree_model_unref_node*(tree_model: PGtkTreeModel, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_unref_node".}
-proc gtk_tree_model_foreach*(model: PGtkTreeModel,
-                             fun: TGtkTreeModelForeachFunc,
-                             user_data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_foreach".}
-proc gtk_tree_model_row_changed*(tree_model: PGtkTreeModel, path: PGtkTreePath,
-                                 iter: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_row_changed".}
-proc gtk_tree_model_row_inserted*(tree_model: PGtkTreeModel, path: PGtkTreePath,
-                                  iter: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_row_inserted".}
-proc gtk_tree_model_row_has_child_toggled*(tree_model: PGtkTreeModel,
-    path: PGtkTreePath, iter: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_row_has_child_toggled".}
-proc gtk_tree_model_row_deleted*(tree_model: PGtkTreeModel, path: PGtkTreePath){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_row_deleted".}
-proc gtk_tree_model_rows_reordered*(tree_model: PGtkTreeModel,
-                                    path: PGtkTreePath, iter: PGtkTreeIter,
-                                    new_order: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_rows_reordered".}
-const
-  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID* = - (1)
-
-proc GTK_TYPE_TREE_SORTABLE*(): GType
-proc GTK_TREE_SORTABLE*(obj: pointer): PGtkTreeSortable
-proc GTK_TREE_SORTABLE_CLASS*(obj: pointer): PGtkTreeSortableIface
-proc GTK_IS_TREE_SORTABLE*(obj: pointer): bool
-proc GTK_TREE_SORTABLE_GET_IFACE*(obj: pointer): PGtkTreeSortableIface
-proc gtk_tree_sortable_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_sortable_get_type".}
-proc gtk_tree_sortable_sort_column_changed*(sortable: PGtkTreeSortable){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_sortable_sort_column_changed".}
-proc gtk_tree_sortable_get_sort_column_id*(sortable: PGtkTreeSortable,
-    sort_column_id: Pgint, order: PGtkSortType): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_sortable_get_sort_column_id".}
-proc gtk_tree_sortable_set_sort_column_id*(sortable: PGtkTreeSortable,
-    sort_column_id: gint, order: TGtkSortType){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_sortable_set_sort_column_id".}
-proc gtk_tree_sortable_set_sort_func*(sortable: PGtkTreeSortable,
-                                      sort_column_id: gint,
-                                      sort_func: TGtkTreeIterCompareFunc,
-                                      user_data: gpointer,
-                                      destroy: TGtkDestroyNotify){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_sortable_set_sort_func".}
-proc gtk_tree_sortable_set_default_sort_func*(sortable: PGtkTreeSortable,
-    sort_func: TGtkTreeIterCompareFunc, user_data: gpointer,
-    destroy: TGtkDestroyNotify){.cdecl, dynlib: gtklib, importc: "gtk_tree_sortable_set_default_sort_func".}
-proc gtk_tree_sortable_has_default_sort_func*(sortable: PGtkTreeSortable): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_sortable_has_default_sort_func".}
-proc GTK_TYPE_TREE_MODEL_SORT*(): GType
-proc GTK_TREE_MODEL_SORT*(obj: pointer): PGtkTreeModelSort
-proc GTK_TREE_MODEL_SORT_CLASS*(klass: pointer): PGtkTreeModelSortClass
-proc GTK_IS_TREE_MODEL_SORT*(obj: pointer): bool
-proc GTK_IS_TREE_MODEL_SORT_CLASS*(klass: pointer): bool
-proc GTK_TREE_MODEL_SORT_GET_CLASS*(obj: pointer): PGtkTreeModelSortClass
-proc gtk_tree_model_sort_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_sort_get_type".}
-proc gtk_tree_model_sort_new_with_model*(child_model: PGtkTreeModel): PGtkTreeModel{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_sort_new_with_model".}
-proc gtk_tree_model_sort_get_model*(tree_model: PGtkTreeModelSort): PGtkTreeModel{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_sort_get_model".}
-proc gtk_tree_model_sort_convert_child_path_to_path*(
-    tree_model_sort: PGtkTreeModelSort, child_path: PGtkTreePath): PGtkTreePath{.
-    cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_sort_convert_child_path_to_path".}
-proc gtk_tree_model_sort_convert_child_iter_to_iter*(
-    tree_model_sort: PGtkTreeModelSort, sort_iter: PGtkTreeIter,
-    child_iter: PGtkTreeIter){.cdecl, dynlib: gtklib, importc: "gtk_tree_model_sort_convert_child_iter_to_iter".}
-proc gtk_tree_model_sort_convert_path_to_child_path*(
-    tree_model_sort: PGtkTreeModelSort, sorted_path: PGtkTreePath): PGtkTreePath{.
-    cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_sort_convert_path_to_child_path".}
-proc gtk_tree_model_sort_convert_iter_to_child_iter*(
-    tree_model_sort: PGtkTreeModelSort, child_iter: PGtkTreeIter,
-    sorted_iter: PGtkTreeIter){.cdecl, dynlib: gtklib, importc: "gtk_tree_model_sort_convert_iter_to_child_iter".}
-proc gtk_tree_model_sort_reset_default_sort_func*(
-    tree_model_sort: PGtkTreeModelSort){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_model_sort_reset_default_sort_func".}
-proc gtk_tree_model_sort_clear_cache*(tree_model_sort: PGtkTreeModelSort){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_model_sort_clear_cache".}
-const
-  bm_TGtkListStore_columns_dirty* = 0x00000001'i16
-  bp_TGtkListStore_columns_dirty* = 0'i16
-
-proc GTK_TYPE_LIST_STORE*(): GType
-proc GTK_LIST_STORE*(obj: pointer): PGtkListStore
-proc GTK_LIST_STORE_CLASS*(klass: pointer): PGtkListStoreClass
-proc GTK_IS_LIST_STORE*(obj: pointer): bool
-proc GTK_IS_LIST_STORE_CLASS*(klass: pointer): bool
-proc GTK_LIST_STORE_GET_CLASS*(obj: pointer): PGtkListStoreClass
-proc columns_dirty*(a: var TGtkListStore): guint
-proc set_columns_dirty*(a: var TGtkListStore, `columns_dirty`: guint)
-proc gtk_list_store_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_list_store_get_type".}
-proc gtk_list_store_newv*(n_columns: gint, types: PGType): PGtkListStore{.cdecl,
-    dynlib: gtklib, importc: "gtk_list_store_newv".}
-proc gtk_list_store_set_column_types*(list_store: PGtkListStore,
-                                      n_columns: gint, types: PGType){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_store_set_column_types".}
-proc gtk_list_store_set_value*(list_store: PGtkListStore, iter: PGtkTreeIter,
-                               column: gint, value: PGValue){.cdecl,
-    dynlib: gtklib, importc: "gtk_list_store_set_value".}
-proc gtk_list_store_remove*(list_store: PGtkListStore, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_store_remove".}
-proc gtk_list_store_insert*(list_store: PGtkListStore, iter: PGtkTreeIter,
-                            position: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_store_insert".}
-proc gtk_list_store_insert_before*(list_store: PGtkListStore,
-                                   iter: PGtkTreeIter, sibling: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_store_insert_before".}
-proc gtk_list_store_insert_after*(list_store: PGtkListStore, iter: PGtkTreeIter,
-                                  sibling: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_store_insert_after".}
-proc gtk_list_store_prepend*(list_store: PGtkListStore, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_store_prepend".}
-proc gtk_list_store_append*(list_store: PGtkListStore, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_list_store_append".}
-proc gtk_list_store_clear*(list_store: PGtkListStore){.cdecl, dynlib: gtklib,
-    importc: "gtk_list_store_clear".}
-
-when false:
-  const
-    GTK_PRIORITY_RESIZE* = G_PRIORITY_HIGH_IDLE + 10
-
-proc gtk_check_version*(required_major: guint, required_minor: guint,
-                        required_micro: guint): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_check_version".}
-proc gtk_disable_setlocale*(){.cdecl, dynlib: gtklib,
-                               importc: "gtk_disable_setlocale".}
-proc gtk_set_locale*(): cstring{.cdecl, dynlib: gtklib, importc: "gtk_set_locale".}
-proc gtk_get_default_language*(): PPangoLanguage{.cdecl, dynlib: gtklib,
-    importc: "gtk_get_default_language".}
-proc gtk_events_pending*(): gint{.cdecl, dynlib: gtklib,
-                                  importc: "gtk_events_pending".}
-proc gtk_main_do_event*(event: PGdkEvent){.cdecl, dynlib: gtklib,
-    importc: "gtk_main_do_event".}
-proc gtk_main*(){.cdecl, dynlib: gtklib, importc: "gtk_main".}
-proc gtk_init*(argc, argv: pointer){.cdecl, dynlib: gtklib, importc: "gtk_init".}
-proc gtk_main_level*(): guint{.cdecl, dynlib: gtklib, importc: "gtk_main_level".}
-proc gtk_main_quit*(){.cdecl, dynlib: gtklib, importc: "gtk_main_quit".}
-proc gtk_main_iteration*(): gboolean{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_main_iteration".}
-proc gtk_main_iteration_do*(blocking: gboolean): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_main_iteration_do".}
-proc gtk_true*(): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_true".}
-proc gtk_false*(): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_false".}
-proc gtk_grab_add*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_grab_add".}
-proc gtk_grab_get_current*(): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_grab_get_current".}
-proc gtk_grab_remove*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_grab_remove".}
-proc gtk_init_add*(`function`: TGtkFunction, data: gpointer){.cdecl,
-    dynlib: gtklib, importc: "gtk_init_add".}
-proc gtk_quit_add_destroy*(main_level: guint, anObject: PGtkObject){.cdecl,
-    dynlib: gtklib, importc: "gtk_quit_add_destroy".}
-proc gtk_quit_add*(main_level: guint, `function`: TGtkFunction, data: gpointer): guint{.
-    cdecl, dynlib: gtklib, importc: "gtk_quit_add".}
-proc gtk_quit_add_full*(main_level: guint, `function`: TGtkFunction,
-                        marshal: TGtkCallbackMarshal, data: gpointer,
-                        destroy: TGtkDestroyNotify): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_quit_add_full".}
-proc gtk_quit_remove*(quit_handler_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_quit_remove".}
-proc gtk_quit_remove_by_data*(data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_quit_remove_by_data".}
-proc gtk_timeout_add*(interval: guint32, `function`: TGtkFunction,
-                      data: gpointer): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_timeout_add".}
-proc gtk_timeout_add_full*(interval: guint32, `function`: TGtkFunction,
-                           marshal: TGtkCallbackMarshal, data: gpointer,
-                           destroy: TGtkDestroyNotify): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_timeout_add_full".}
-proc gtk_timeout_remove*(timeout_handler_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_timeout_remove".}
-proc gtk_idle_add*(`function`: TGtkFunction, data: gpointer): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_idle_add".}
-proc gtk_idle_add_priority*(priority: gint, `function`: TGtkFunction,
-                            data: gpointer): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_idle_add_priority".}
-proc gtk_idle_add_full*(priority: gint, `function`: TGtkFunction,
-                        marshal: TGtkCallbackMarshal, data: gpointer,
-                        destroy: TGtkDestroyNotify): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_idle_add_full".}
-proc gtk_idle_remove*(idle_handler_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_idle_remove".}
-proc gtk_idle_remove_by_data*(data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_idle_remove_by_data".}
-proc gtk_input_add_full*(source: gint, condition: TGdkInputCondition,
-                         `function`: TGdkInputFunction,
-                         marshal: TGtkCallbackMarshal, data: gpointer,
-                         destroy: TGtkDestroyNotify): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_input_add_full".}
-proc gtk_input_remove*(input_handler_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_input_remove".}
-proc gtk_key_snooper_install*(snooper: TGtkKeySnoopFunc, func_data: gpointer): guint{.
-    cdecl, dynlib: gtklib, importc: "gtk_key_snooper_install".}
-proc gtk_key_snooper_remove*(snooper_handler_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_key_snooper_remove".}
-proc gtk_get_current_event*(): PGdkEvent{.cdecl, dynlib: gtklib,
-    importc: "gtk_get_current_event".}
-proc gtk_get_current_event_time*(): guint32{.cdecl, dynlib: gtklib,
-    importc: "gtk_get_current_event_time".}
-proc gtk_get_current_event_state*(state: PGdkModifierType): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_get_current_event_state".}
-proc gtk_get_event_widget*(event: PGdkEvent): PGtkWidget{.cdecl, dynlib: gtklib,
-    importc: "gtk_get_event_widget".}
-proc gtk_propagate_event*(widget: PGtkWidget, event: PGdkEvent){.cdecl,
-    dynlib: gtklib, importc: "gtk_propagate_event".}
-proc gtk_boolean_handled_accumulator*(ihint: PGSignalInvocationHint,
-                                        return_accu: PGValue,
-                                        handler_return: PGValue, dummy: gpointer): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_boolean_handled_accumulator".}
-proc gtk_find_module*(name: cstring, thetype: cstring): cstring{.cdecl,
-    dynlib: gtklib, importc: "_gtk_find_module".}
-proc gtk_get_module_path*(thetype: cstring): PPgchar{.cdecl, dynlib: gtklib,
-    importc: "_gtk_get_module_path".}
-proc GTK_TYPE_MENU_BAR*(): GType
-proc GTK_MENU_BAR*(obj: pointer): PGtkMenuBar
-proc GTK_MENU_BAR_CLASS*(klass: pointer): PGtkMenuBarClass
-proc GTK_IS_MENU_BAR*(obj: pointer): bool
-proc GTK_IS_MENU_BAR_CLASS*(klass: pointer): bool
-proc GTK_MENU_BAR_GET_CLASS*(obj: pointer): PGtkMenuBarClass
-proc gtk_menu_bar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_menu_bar_get_type".}
-proc gtk_menu_bar_new*(): PGtkMenuBar{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_menu_bar_new".}
-proc gtk_menu_bar_cycle_focus*(menubar: PGtkMenuBar, dir: TGtkDirectionType){.
-    cdecl, dynlib: gtklib, importc: "_gtk_menu_bar_cycle_focus".}
-proc GTK_TYPE_MESSAGE_DIALOG*(): GType
-proc GTK_MESSAGE_DIALOG*(obj: pointer): PGtkMessageDialog
-proc GTK_MESSAGE_DIALOG_CLASS*(klass: pointer): PGtkMessageDialogClass
-proc GTK_IS_MESSAGE_DIALOG*(obj: pointer): bool
-proc GTK_IS_MESSAGE_DIALOG_CLASS*(klass: pointer): bool
-proc GTK_MESSAGE_DIALOG_GET_CLASS*(obj: pointer): PGtkMessageDialogClass
-proc gtk_message_dialog_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_message_dialog_get_type".}
-const
-  bm_TGtkNotebook_show_tabs* = 0x00000001'i16
-  bp_TGtkNotebook_show_tabs* = 0'i16
-  bm_TGtkNotebook_homogeneous* = 0x00000002'i16
-  bp_TGtkNotebook_homogeneous* = 1'i16
-  bm_TGtkNotebook_show_border* = 0x00000004'i16
-  bp_TGtkNotebook_show_border* = 2'i16
-  bm_TGtkNotebook_tab_pos* = 0x00000018'i16
-  bp_TGtkNotebook_tab_pos* = 3'i16
-  bm_TGtkNotebook_scrollable* = 0x00000020'i16
-  bp_TGtkNotebook_scrollable* = 5'i16
-  bm_TGtkNotebook_in_child* = 0x000000C0'i16
-  bp_TGtkNotebook_in_child* = 6'i16
-  bm_TGtkNotebook_click_child* = 0x00000300'i16
-  bp_TGtkNotebook_click_child* = 8'i16
-  bm_TGtkNotebook_button* = 0x00000C00'i16
-  bp_TGtkNotebook_button* = 10'i16
-  bm_TGtkNotebook_need_timer* = 0x00001000'i16
-  bp_TGtkNotebook_need_timer* = 12'i16
-  bm_TGtkNotebook_child_has_focus* = 0x00002000'i16
-  bp_TGtkNotebook_child_has_focus* = 13'i16
-  bm_TGtkNotebook_have_visible_child* = 0x00004000'i16
-  bp_TGtkNotebook_have_visible_child* = 14'i16
-  bm_TGtkNotebook_focus_out* = 0x00008000'i16
-  bp_TGtkNotebook_focus_out* = 15'i16
-
-proc GTK_TYPE_NOTEBOOK*(): GType
-proc GTK_NOTEBOOK*(obj: pointer): PGtkNotebook
-proc GTK_NOTEBOOK_CLASS*(klass: pointer): PGtkNotebookClass
-proc GTK_IS_NOTEBOOK*(obj: pointer): bool
-proc GTK_IS_NOTEBOOK_CLASS*(klass: pointer): bool
-proc GTK_NOTEBOOK_GET_CLASS*(obj: pointer): PGtkNotebookClass
-proc show_tabs*(a: var TGtkNotebook): guint
-proc set_show_tabs*(a: var TGtkNotebook, `show_tabs`: guint)
-proc homogeneous*(a: var TGtkNotebook): guint
-proc set_homogeneous*(a: var TGtkNotebook, `homogeneous`: guint)
-proc show_border*(a: var TGtkNotebook): guint
-proc set_show_border*(a: var TGtkNotebook, `show_border`: guint)
-proc tab_pos*(a: var TGtkNotebook): guint
-proc set_tab_pos*(a: var TGtkNotebook, `tab_pos`: guint)
-proc scrollable*(a: var TGtkNotebook): guint
-proc set_scrollable*(a: var TGtkNotebook, `scrollable`: guint)
-proc in_child*(a: var TGtkNotebook): guint
-proc set_in_child*(a: var TGtkNotebook, `in_child`: guint)
-proc click_child*(a: var TGtkNotebook): guint
-proc set_click_child*(a: var TGtkNotebook, `click_child`: guint)
-proc button*(a: var TGtkNotebook): guint
-proc set_button*(a: var TGtkNotebook, `button`: guint)
-proc need_timer*(a: var TGtkNotebook): guint
-proc set_need_timer*(a: var TGtkNotebook, `need_timer`: guint)
-proc child_has_focus*(a: var TGtkNotebook): guint
-proc set_child_has_focus*(a: var TGtkNotebook, `child_has_focus`: guint)
-proc have_visible_child*(a: var TGtkNotebook): guint
-proc set_have_visible_child*(a: var TGtkNotebook, `have_visible_child`: guint)
-proc focus_out*(a: var TGtkNotebook): guint
-proc set_focus_out*(a: var TGtkNotebook, `focus_out`: guint)
-proc gtk_notebook_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_get_type".}
-proc gtk_notebook_new*(): PGtkNotebook{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_notebook_new".}
-proc gtk_notebook_append_page*(notebook: PGtkNotebook, child: PGtkWidget,
-                               tab_label: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_append_page".}
-proc gtk_notebook_append_page_menu*(notebook: PGtkNotebook, child: PGtkWidget,
-                                    tab_label: PGtkWidget,
-                                    menu_label: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_append_page_menu".}
-proc gtk_notebook_prepend_page*(notebook: PGtkNotebook, child: PGtkWidget,
-                                tab_label: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_prepend_page".}
-proc gtk_notebook_prepend_page_menu*(notebook: PGtkNotebook, child: PGtkWidget,
-                                     tab_label: PGtkWidget,
-                                     menu_label: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_prepend_page_menu".}
-proc gtk_notebook_insert_page*(notebook: PGtkNotebook, child: PGtkWidget,
-                               tab_label: PGtkWidget, position: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_insert_page".}
-proc gtk_notebook_insert_page_menu*(notebook: PGtkNotebook, child: PGtkWidget,
-                                    tab_label: PGtkWidget,
-                                    menu_label: PGtkWidget, position: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_insert_page_menu".}
-proc gtk_notebook_remove_page*(notebook: PGtkNotebook, page_num: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_remove_page".}
-proc gtk_notebook_get_current_page*(notebook: PGtkNotebook): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_get_current_page".}
-proc gtk_notebook_get_n_pages*(notebook: PGtkNotebook): gint {.cdecl, 
-    dynlib: gtklib, importc.}
-proc gtk_notebook_get_nth_page*(notebook: PGtkNotebook, page_num: gint): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_get_nth_page".}
-proc gtk_notebook_page_num*(notebook: PGtkNotebook, child: PGtkWidget): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_page_num".}
-proc gtk_notebook_set_current_page*(notebook: PGtkNotebook, page_num: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_current_page".}
-proc gtk_notebook_next_page*(notebook: PGtkNotebook){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_next_page".}
-proc gtk_notebook_prev_page*(notebook: PGtkNotebook){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_prev_page".}
-proc gtk_notebook_set_show_border*(notebook: PGtkNotebook, show_border: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_show_border".}
-proc gtk_notebook_get_show_border*(notebook: PGtkNotebook): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_get_show_border".}
-proc gtk_notebook_set_show_tabs*(notebook: PGtkNotebook, show_tabs: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_show_tabs".}
-proc gtk_notebook_get_show_tabs*(notebook: PGtkNotebook): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_get_show_tabs".}
-proc gtk_notebook_set_tab_pos*(notebook: PGtkNotebook, pos: TGtkPositionType){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_tab_pos".}
-proc gtk_notebook_get_tab_pos*(notebook: PGtkNotebook): TGtkPositionType{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_get_tab_pos".}
-proc gtk_notebook_set_scrollable*(notebook: PGtkNotebook, scrollable: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_scrollable".}
-proc gtk_notebook_get_scrollable*(notebook: PGtkNotebook): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_get_scrollable".}
-proc gtk_notebook_popup_enable*(notebook: PGtkNotebook){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_popup_enable".}
-proc gtk_notebook_popup_disable*(notebook: PGtkNotebook){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_popup_disable".}
-proc gtk_notebook_get_tab_label*(notebook: PGtkNotebook, child: PGtkWidget): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_get_tab_label".}
-proc gtk_notebook_set_tab_label*(notebook: PGtkNotebook, child: PGtkWidget,
-                                 tab_label: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_set_tab_label".}
-proc gtk_notebook_set_tab_label_text*(notebook: PGtkNotebook, child: PGtkWidget,
-                                      tab_text: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_set_tab_label_text".}
-proc gtk_notebook_get_tab_label_text*(notebook: PGtkNotebook, child: PGtkWidget): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_get_tab_label_text".}
-proc gtk_notebook_get_menu_label*(notebook: PGtkNotebook, child: PGtkWidget): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_get_menu_label".}
-proc gtk_notebook_set_menu_label*(notebook: PGtkNotebook, child: PGtkWidget,
-                                  menu_label: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_notebook_set_menu_label".}
-proc gtk_notebook_set_menu_label_text*(notebook: PGtkNotebook,
-                                       child: PGtkWidget, menu_text: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_menu_label_text".}
-proc gtk_notebook_get_menu_label_text*(notebook: PGtkNotebook, child: PGtkWidget): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_get_menu_label_text".}
-proc gtk_notebook_query_tab_label_packing*(notebook: PGtkNotebook,
-    child: PGtkWidget, expand: Pgboolean, fill: Pgboolean,
-    pack_type: PGtkPackType){.cdecl, dynlib: gtklib,
-                              importc: "gtk_notebook_query_tab_label_packing".}
-proc gtk_notebook_set_tab_label_packing*(notebook: PGtkNotebook,
-    child: PGtkWidget, expand: gboolean, fill: gboolean, pack_type: TGtkPackType){.
-    cdecl, dynlib: gtklib, importc: "gtk_notebook_set_tab_label_packing".}
-proc gtk_notebook_reorder_child*(notebook: PGtkNotebook, child: PGtkWidget,
-                                 position: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_notebook_reorder_child".}
-const
-  bm_TGtkOldEditable_has_selection* = 0x00000001'i16
-  bp_TGtkOldEditable_has_selection* = 0'i16
-  bm_TGtkOldEditable_editable* = 0x00000002'i16
-  bp_TGtkOldEditable_editable* = 1'i16
-  bm_TGtkOldEditable_visible* = 0x00000004'i16
-  bp_TGtkOldEditable_visible* = 2'i16
-
-proc GTK_TYPE_OLD_EDITABLE*(): GType
-proc GTK_OLD_EDITABLE*(obj: pointer): PGtkOldEditable
-proc GTK_OLD_EDITABLE_CLASS*(klass: pointer): PGtkOldEditableClass
-proc GTK_IS_OLD_EDITABLE*(obj: pointer): bool
-proc GTK_IS_OLD_EDITABLE_CLASS*(klass: pointer): bool
-proc GTK_OLD_EDITABLE_GET_CLASS*(obj: pointer): PGtkOldEditableClass
-proc has_selection*(a: var TGtkOldEditable): guint
-proc set_has_selection*(a: var TGtkOldEditable, `has_selection`: guint)
-proc editable*(a: var TGtkOldEditable): guint
-proc set_editable*(a: var TGtkOldEditable, `editable`: guint)
-proc visible*(a: var TGtkOldEditable): guint
-proc set_visible*(a: var TGtkOldEditable, `visible`: guint)
-proc gtk_old_editable_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_old_editable_get_type".}
-proc gtk_old_editable_claim_selection*(old_editable: PGtkOldEditable,
-                                       claim: gboolean, time: guint32){.cdecl,
-    dynlib: gtklib, importc: "gtk_old_editable_claim_selection".}
-proc gtk_old_editable_changed*(old_editable: PGtkOldEditable){.cdecl,
-    dynlib: gtklib, importc: "gtk_old_editable_changed".}
-proc GTK_TYPE_OPTION_MENU*(): GType
-proc GTK_OPTION_MENU*(obj: pointer): PGtkOptionMenu
-proc GTK_OPTION_MENU_CLASS*(klass: pointer): PGtkOptionMenuClass
-proc GTK_IS_OPTION_MENU*(obj: pointer): bool
-proc GTK_IS_OPTION_MENU_CLASS*(klass: pointer): bool
-proc GTK_OPTION_MENU_GET_CLASS*(obj: pointer): PGtkOptionMenuClass
-proc gtk_option_menu_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_option_menu_get_type".}
-proc gtk_option_menu_new*(): PGtkOptionMenu{.cdecl, dynlib: gtklib,
-    importc: "gtk_option_menu_new".}
-proc gtk_option_menu_get_menu*(option_menu: PGtkOptionMenu): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_option_menu_get_menu".}
-proc gtk_option_menu_set_menu*(option_menu: PGtkOptionMenu, menu: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_option_menu_set_menu".}
-proc gtk_option_menu_remove_menu*(option_menu: PGtkOptionMenu){.cdecl,
-    dynlib: gtklib, importc: "gtk_option_menu_remove_menu".}
-proc gtk_option_menu_get_history*(option_menu: PGtkOptionMenu): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_option_menu_get_history".}
-proc gtk_option_menu_set_history*(option_menu: PGtkOptionMenu, index: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_option_menu_set_history".}
-const
-  bm_TGtkPixmap_build_insensitive* = 0x00000001'i16
-  bp_TGtkPixmap_build_insensitive* = 0'i16
-
-proc GTK_TYPE_PIXMAP*(): GType
-proc GTK_PIXMAP*(obj: pointer): PGtkPixmap
-proc GTK_PIXMAP_CLASS*(klass: pointer): PGtkPixmapClass
-proc GTK_IS_PIXMAP*(obj: pointer): bool
-proc GTK_IS_PIXMAP_CLASS*(klass: pointer): bool
-proc GTK_PIXMAP_GET_CLASS*(obj: pointer): PGtkPixmapClass
-proc build_insensitive*(a: var TGtkPixmap): guint
-proc set_build_insensitive*(a: var TGtkPixmap, `build_insensitive`: guint)
-proc gtk_pixmap_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_pixmap_get_type".}
-proc gtk_pixmap_new*(pixmap: PGdkPixmap, mask: PGdkBitmap): PGtkPixmap{.cdecl,
-    dynlib: gtklib, importc: "gtk_pixmap_new".}
-proc gtk_pixmap_set*(pixmap: PGtkPixmap, val: PGdkPixmap, mask: PGdkBitmap){.
-    cdecl, dynlib: gtklib, importc: "gtk_pixmap_set".}
-proc gtk_pixmap_get*(pixmap: PGtkPixmap, val: var PGdkPixmap,
-                     mask: var PGdkBitmap){.cdecl, dynlib: gtklib,
-    importc: "gtk_pixmap_get".}
-proc gtk_pixmap_set_build_insensitive*(pixmap: PGtkPixmap, build: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_pixmap_set_build_insensitive".}
-const
-  bm_TGtkPlug_same_app* = 0x00000001'i16
-  bp_TGtkPlug_same_app* = 0'i16
-
-proc GTK_TYPE_PLUG*(): GType
-proc GTK_PLUG*(obj: pointer): PGtkPlug
-proc GTK_PLUG_CLASS*(klass: pointer): PGtkPlugClass
-proc GTK_IS_PLUG*(obj: pointer): bool
-proc GTK_IS_PLUG_CLASS*(klass: pointer): bool
-proc GTK_PLUG_GET_CLASS*(obj: pointer): PGtkPlugClass
-proc same_app*(a: var TGtkPlug): guint
-proc set_same_app*(a: var TGtkPlug, `same_app`: guint)
-proc gtk_plug_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_plug_get_type".}
-proc gtk_plug_construct_for_display*(plug: PGtkPlug, display: PGdkDisplay,
-                                     socket_id: TGdkNativeWindow){.cdecl,
-    dynlib: gtklib, importc: "gtk_plug_construct_for_display".}
-proc gtk_plug_new_for_display*(display: PGdkDisplay, socket_id: TGdkNativeWindow): PGtkPlug{.
-    cdecl, dynlib: gtklib, importc: "gtk_plug_new_for_display".}
-proc gtk_plug_get_id*(plug: PGtkPlug): TGdkNativeWindow{.cdecl, dynlib: gtklib,
-    importc: "gtk_plug_get_id".}
-proc gtk_plug_add_to_socket*(plug: PGtkPlug, socket: PGtkSocket){.cdecl,
-    dynlib: gtklib, importc: "_gtk_plug_add_to_socket".}
-proc gtk_plug_remove_from_socket*(plug: PGtkPlug, socket: PGtkSocket){.cdecl,
-    dynlib: gtklib, importc: "_gtk_plug_remove_from_socket".}
-const
-  bm_TGtkPreview_type* = 0x00000001'i16
-  bp_TGtkPreview_type* = 0'i16
-  bm_TGtkPreview_expand* = 0x00000002'i16
-  bp_TGtkPreview_expand* = 1'i16
-
-proc GTK_TYPE_PREVIEW*(): GType
-proc GTK_PREVIEW*(obj: pointer): PGtkPreview
-proc GTK_PREVIEW_CLASS*(klass: pointer): PGtkPreviewClass
-proc GTK_IS_PREVIEW*(obj: pointer): bool
-proc GTK_IS_PREVIEW_CLASS*(klass: pointer): bool
-proc GTK_PREVIEW_GET_CLASS*(obj: pointer): PGtkPreviewClass
-proc get_type*(a: var TGtkPreview): guint
-proc set_type*(a: var TGtkPreview, `type`: guint)
-proc get_expand*(a: var TGtkPreview): guint
-proc set_expand*(a: var TGtkPreview, `expand`: guint)
-proc gtk_preview_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_preview_get_type".}
-proc gtk_preview_uninit*(){.cdecl, dynlib: gtklib, importc: "gtk_preview_uninit".}
-proc gtk_preview_new*(thetype: TGtkPreviewClass): PGtkPreview{.cdecl,
-    dynlib: gtklib, importc: "gtk_preview_new".}
-proc gtk_preview_size*(preview: PGtkPreview, width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_preview_size".}
-proc gtk_preview_put*(preview: PGtkPreview, window: PGdkWindow, gc: PGdkGC,
-                      srcx: gint, srcy: gint, destx: gint, desty: gint,
-                      width: gint, height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_put".}
-proc gtk_preview_draw_row*(preview: PGtkPreview, data: Pguchar, x: gint,
-                           y: gint, w: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_draw_row".}
-proc gtk_preview_set_expand*(preview: PGtkPreview, expand: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_preview_set_expand".}
-proc gtk_preview_set_gamma*(gamma: float64){.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_set_gamma".}
-proc gtk_preview_set_color_cube*(nred_shades: guint, ngreen_shades: guint,
-                                 nblue_shades: guint, ngray_shades: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_preview_set_color_cube".}
-proc gtk_preview_set_install_cmap*(install_cmap: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_set_install_cmap".}
-proc gtk_preview_set_reserved*(nreserved: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_set_reserved".}
-proc gtk_preview_set_dither*(preview: PGtkPreview, dither: TGdkRgbDither){.
-    cdecl, dynlib: gtklib, importc: "gtk_preview_set_dither".}
-proc gtk_preview_get_info*(): PGtkPreviewInfo{.cdecl, dynlib: gtklib,
-    importc: "gtk_preview_get_info".}
-proc gtk_preview_reset*(){.cdecl, dynlib: gtklib, importc: "gtk_preview_reset".}
-const
-  bm_TGtkProgress_show_text* = 0x00000001'i16
-  bp_TGtkProgress_show_text* = 0'i16
-  bm_TGtkProgress_activity_mode* = 0x00000002'i16
-  bp_TGtkProgress_activity_mode* = 1'i16
-  bm_TGtkProgress_use_text_format* = 0x00000004'i16
-  bp_TGtkProgress_use_text_format* = 2'i16
-
-proc show_text*(a: var TGtkProgress): guint
-proc set_show_text*(a: var TGtkProgress, `show_text`: guint)
-proc activity_mode*(a: var TGtkProgress): guint
-proc set_activity_mode*(a: var TGtkProgress, `activity_mode`: guint)
-proc use_text_format*(a: var TGtkProgress): guint
-proc set_use_text_format*(a: var TGtkProgress, `use_text_format`: guint)
-const
-  bm_TGtkProgressBar_activity_dir* = 0x00000001'i16
-  bp_TGtkProgressBar_activity_dir* = 0'i16
-
-proc GTK_TYPE_PROGRESS_BAR*(): GType
-proc GTK_PROGRESS_BAR*(obj: pointer): PGtkProgressBar
-proc GTK_PROGRESS_BAR_CLASS*(klass: pointer): PGtkProgressBarClass
-proc GTK_IS_PROGRESS_BAR*(obj: pointer): bool
-proc GTK_IS_PROGRESS_BAR_CLASS*(klass: pointer): bool
-proc GTK_PROGRESS_BAR_GET_CLASS*(obj: pointer): PGtkProgressBarClass
-proc activity_dir*(a: var TGtkProgressBar): guint
-proc set_activity_dir*(a: var TGtkProgressBar, `activity_dir`: guint)
-proc gtk_progress_bar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_progress_bar_get_type".}
-proc gtk_progress_bar_new*(): PGtkProgressBar{.cdecl, dynlib: gtklib,
-    importc: "gtk_progress_bar_new".}
-proc gtk_progress_bar_pulse*(pbar: PGtkProgressBar){.cdecl, dynlib: gtklib,
-    importc: "gtk_progress_bar_pulse".}
-proc gtk_progress_bar_set_text*(pbar: PGtkProgressBar, text: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_progress_bar_set_text".}
-proc gtk_progress_bar_set_fraction*(pbar: PGtkProgressBar, fraction: gdouble){.
-    cdecl, dynlib: gtklib, importc: "gtk_progress_bar_set_fraction".}
-proc gtk_progress_bar_set_pulse_step*(pbar: PGtkProgressBar, fraction: gdouble){.
-    cdecl, dynlib: gtklib, importc: "gtk_progress_bar_set_pulse_step".}
-proc gtk_progress_bar_set_orientation*(pbar: PGtkProgressBar,
-                                       orientation: TGtkProgressBarOrientation){.
-    cdecl, dynlib: gtklib, importc: "gtk_progress_bar_set_orientation".}
-proc gtk_progress_bar_get_text*(pbar: PGtkProgressBar): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_progress_bar_get_text".}
-proc gtk_progress_bar_get_fraction*(pbar: PGtkProgressBar): gdouble{.cdecl,
-    dynlib: gtklib, importc: "gtk_progress_bar_get_fraction".}
-proc gtk_progress_bar_get_pulse_step*(pbar: PGtkProgressBar): gdouble{.cdecl,
-    dynlib: gtklib, importc: "gtk_progress_bar_get_pulse_step".}
-proc gtk_progress_bar_get_orientation*(pbar: PGtkProgressBar): TGtkProgressBarOrientation{.
-    cdecl, dynlib: gtklib, importc: "gtk_progress_bar_get_orientation".}
-proc GTK_TYPE_RADIO_BUTTON*(): GType
-proc GTK_RADIO_BUTTON*(obj: pointer): PGtkRadioButton
-proc GTK_RADIO_BUTTON_CLASS*(klass: pointer): PGtkRadioButtonClass
-proc GTK_IS_RADIO_BUTTON*(obj: pointer): bool
-proc GTK_IS_RADIO_BUTTON_CLASS*(klass: pointer): bool
-proc GTK_RADIO_BUTTON_GET_CLASS*(obj: pointer): PGtkRadioButtonClass
-proc gtk_radio_button_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_radio_button_get_type".}
-proc gtk_radio_button_new*(group: PGSList): PGtkRadioButton{.cdecl, dynlib: gtklib,
-    importc: "gtk_radio_button_new".}
-proc gtk_radio_button_new_from_widget*(group: PGtkRadioButton): PGtkRadioButton{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_button_new_from_widget".}
-proc gtk_radio_button_new_with_label*(group: PGSList, `label`: cstring): PGtkRadioButton{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_button_new_with_label".}
-proc gtk_radio_button_new_with_label_from_widget*(group: PGtkRadioButton,
-    `label`: cstring): PGtkRadioButton{.cdecl, dynlib: gtklib, importc: "gtk_radio_button_new_with_label_from_widget".}
-proc gtk_radio_button_new_with_mnemonic*(group: PGSList, `label`: cstring): PGtkRadioButton{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_button_new_with_mnemonic".}
-proc gtk_radio_button_new_with_mnemonic_from_widget*(group: PGtkRadioButton,
-    `label`: cstring): PGtkRadioButton{.cdecl, dynlib: gtklib, importc: "gtk_radio_button_new_with_mnemonic_from_widget".}
-proc gtk_radio_button_get_group*(radio_button: PGtkRadioButton): PGSList{.cdecl,
-    dynlib: gtklib, importc: "gtk_radio_button_get_group".}
-proc gtk_radio_button_set_group*(radio_button: PGtkRadioButton, group: PGSList){.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_button_set_group".}
-proc GTK_TYPE_RADIO_MENU_ITEM*(): GType
-proc GTK_RADIO_MENU_ITEM*(obj: pointer): PGtkRadioMenuItem
-proc GTK_RADIO_MENU_ITEM_CLASS*(klass: pointer): PGtkRadioMenuItemClass
-proc GTK_IS_RADIO_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_RADIO_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_RADIO_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkRadioMenuItemClass
-proc gtk_radio_menu_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_radio_menu_item_get_type".}
-proc gtk_radio_menu_item_new*(group: PGSList): PGtkRadioMenuItem{.cdecl,
-    dynlib: gtklib, importc: "gtk_radio_menu_item_new".}
-proc gtk_radio_menu_item_new_with_label*(group: PGSList, `label`: cstring): PGtkRadioMenuItem{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_menu_item_new_with_label".}
-proc gtk_radio_menu_item_new_with_mnemonic*(group: PGSList, `label`: cstring): PGtkRadioMenuItem{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_menu_item_new_with_mnemonic".}
-proc gtk_radio_menu_item_get_group*(radio_menu_item: PGtkRadioMenuItem): PGSList{.
-    cdecl, dynlib: gtklib, importc: "gtk_radio_menu_item_get_group".}
-proc gtk_radio_menu_item_set_group*(radio_menu_item: PGtkRadioMenuItem,
-                                    group: PGSList){.cdecl, dynlib: gtklib,
-    importc: "gtk_radio_menu_item_set_group".}
-const
-  bm_TGtkScrolledWindow_hscrollbar_policy* = 0x00000003'i16
-  bp_TGtkScrolledWindow_hscrollbar_policy* = 0'i16
-  bm_TGtkScrolledWindow_vscrollbar_policy* = 0x0000000C'i16
-  bp_TGtkScrolledWindow_vscrollbar_policy* = 2'i16
-  bm_TGtkScrolledWindow_hscrollbar_visible* = 0x00000010'i16
-  bp_TGtkScrolledWindow_hscrollbar_visible* = 4'i16
-  bm_TGtkScrolledWindow_vscrollbar_visible* = 0x00000020'i16
-  bp_TGtkScrolledWindow_vscrollbar_visible* = 5'i16
-  bm_TGtkScrolledWindow_window_placement* = 0x000000C0'i16
-  bp_TGtkScrolledWindow_window_placement* = 6'i16
-  bm_TGtkScrolledWindow_focus_out* = 0x00000100'i16
-  bp_TGtkScrolledWindow_focus_out* = 8'i16
-
-proc GTK_TYPE_SCROLLED_WINDOW*(): GType
-proc GTK_SCROLLED_WINDOW*(obj: pointer): PGtkScrolledWindow
-proc GTK_SCROLLED_WINDOW_CLASS*(klass: pointer): PGtkScrolledWindowClass
-proc GTK_IS_SCROLLED_WINDOW*(obj: pointer): bool
-proc GTK_IS_SCROLLED_WINDOW_CLASS*(klass: pointer): bool
-proc GTK_SCROLLED_WINDOW_GET_CLASS*(obj: pointer): PGtkScrolledWindowClass
-proc hscrollbar_policy*(a: var TGtkScrolledWindow): guint
-proc set_hscrollbar_policy*(a: var TGtkScrolledWindow,
-                            `hscrollbar_policy`: guint)
-proc vscrollbar_policy*(a: var TGtkScrolledWindow): guint
-proc set_vscrollbar_policy*(a: var TGtkScrolledWindow,
-                            `vscrollbar_policy`: guint)
-proc hscrollbar_visible*(a: var TGtkScrolledWindow): guint
-proc set_hscrollbar_visible*(a: var TGtkScrolledWindow,
-                             `hscrollbar_visible`: guint)
-proc vscrollbar_visible*(a: var TGtkScrolledWindow): guint
-proc set_vscrollbar_visible*(a: var TGtkScrolledWindow,
-                             `vscrollbar_visible`: guint)
-proc window_placement*(a: var TGtkScrolledWindow): guint
-proc set_window_placement*(a: var TGtkScrolledWindow, `window_placement`: guint)
-proc focus_out*(a: var TGtkScrolledWindow): guint
-proc set_focus_out*(a: var TGtkScrolledWindow, `focus_out`: guint)
-proc gtk_scrolled_window_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_scrolled_window_get_type".}
-proc gtk_scrolled_window_new*(hadjustment: PGtkAdjustment,
-                              vadjustment: PGtkAdjustment): PGtkScrolledWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_scrolled_window_new".}
-proc gtk_scrolled_window_set_hadjustment*(scrolled_window: PGtkScrolledWindow,
-    hadjustment: PGtkAdjustment){.cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_set_hadjustment".}
-proc gtk_scrolled_window_set_vadjustment*(scrolled_window: PGtkScrolledWindow,
-    hadjustment: PGtkAdjustment){.cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_set_vadjustment".}
-proc gtk_scrolled_window_get_hadjustment*(scrolled_window: PGtkScrolledWindow): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_get_hadjustment".}
-proc gtk_scrolled_window_get_vadjustment*(scrolled_window: PGtkScrolledWindow): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_get_vadjustment".}
-proc gtk_scrolled_window_set_policy*(scrolled_window: PGtkScrolledWindow,
-                                     hscrollbar_policy: TGtkPolicyType,
-                                     vscrollbar_policy: TGtkPolicyType){.cdecl,
-    dynlib: gtklib, importc: "gtk_scrolled_window_set_policy".}
-proc gtk_scrolled_window_get_policy*(scrolled_window: PGtkScrolledWindow,
-                                     hscrollbar_policy: PGtkPolicyType,
-                                     vscrollbar_policy: PGtkPolicyType){.cdecl,
-    dynlib: gtklib, importc: "gtk_scrolled_window_get_policy".}
-proc gtk_scrolled_window_set_placement*(scrolled_window: PGtkScrolledWindow,
-                                        window_placement: TGtkCornerType){.
-    cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_set_placement".}
-proc gtk_scrolled_window_get_placement*(scrolled_window: PGtkScrolledWindow): TGtkCornerType{.
-    cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_get_placement".}
-proc gtk_scrolled_window_set_shadow_type*(scrolled_window: PGtkScrolledWindow,
-    thetype: TGtkShadowType){.cdecl, dynlib: gtklib,
-                              importc: "gtk_scrolled_window_set_shadow_type".}
-proc gtk_scrolled_window_get_shadow_type*(scrolled_window: PGtkScrolledWindow): TGtkShadowType{.
-    cdecl, dynlib: gtklib, importc: "gtk_scrolled_window_get_shadow_type".}
-proc gtk_scrolled_window_add_with_viewport*(scrolled_window: PGtkScrolledWindow,
-    child: PGtkWidget){.cdecl, dynlib: gtklib,
-                        importc: "gtk_scrolled_window_add_with_viewport".}
-proc GTK_TYPE_SELECTION_DATA*(): GType
-proc gtk_target_list_new*(targets: PGtkTargetEntry, ntargets: guint): PGtkTargetList{.
-    cdecl, dynlib: gtklib, importc: "gtk_target_list_new".}
-proc gtk_target_list_ref*(list: PGtkTargetList){.cdecl, dynlib: gtklib,
-    importc: "gtk_target_list_ref".}
-proc gtk_target_list_unref*(list: PGtkTargetList){.cdecl, dynlib: gtklib,
-    importc: "gtk_target_list_unref".}
-proc gtk_target_list_add*(list: PGtkTargetList, target: TGdkAtom, flags: guint,
-                          info: guint){.cdecl, dynlib: gtklib,
-                                        importc: "gtk_target_list_add".}
-proc gtk_target_list_add_table*(list: PGtkTargetList, targets: PGtkTargetEntry,
-                                ntargets: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_target_list_add_table".}
-proc gtk_target_list_remove*(list: PGtkTargetList, target: TGdkAtom){.cdecl,
-    dynlib: gtklib, importc: "gtk_target_list_remove".}
-proc gtk_target_list_find*(list: PGtkTargetList, target: TGdkAtom, info: Pguint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_target_list_find".}
-proc gtk_selection_owner_set*(widget: PGtkWidget, selection: TGdkAtom,
-                              time: guint32): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_selection_owner_set".}
-proc gtk_selection_owner_set_for_display*(display: PGdkDisplay,
-    widget: PGtkWidget, selection: TGdkAtom, time: guint32): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_selection_owner_set_for_display".}
-proc gtk_selection_add_target*(widget: PGtkWidget, selection: TGdkAtom,
-                               target: TGdkAtom, info: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_selection_add_target".}
-proc gtk_selection_add_targets*(widget: PGtkWidget, selection: TGdkAtom,
-                                targets: PGtkTargetEntry, ntargets: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_add_targets".}
-proc gtk_selection_clear_targets*(widget: PGtkWidget, selection: TGdkAtom){.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_clear_targets".}
-proc gtk_selection_convert*(widget: PGtkWidget, selection: TGdkAtom,
-                            target: TGdkAtom, time: guint32): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_selection_convert".}
-proc gtk_selection_data_set*(selection_data: PGtkSelectionData,
-                             thetype: TGdkAtom, format: gint, data: Pguchar,
-                             length: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_selection_data_set".}
-proc gtk_selection_data_set_text*(selection_data: PGtkSelectionData,
-                                  str: cstring, len: gint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_selection_data_set_text".}
-proc gtk_selection_data_get_text*(selection_data: PGtkSelectionData): Pguchar{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_data_get_text".}
-proc gtk_selection_data_targets_include_text*(selection_data: PGtkSelectionData): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_data_targets_include_text".}
-proc gtk_selection_remove_all*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "gtk_selection_remove_all".}
-proc gtk_selection_clear*(widget: PGtkWidget, event: PGdkEventSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_clear".}
-proc gtk_selection_request*(widget: PGtkWidget, event: PGdkEventSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_request".}
-proc gtk_selection_incr_event*(window: PGdkWindow, event: PGdkEventProperty): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_incr_event".}
-proc gtk_selection_notify*(widget: PGtkWidget, event: PGdkEventSelection): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_notify".}
-proc gtk_selection_property_notify*(widget: PGtkWidget, event: PGdkEventProperty): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_property_notify".}
-proc gtk_selection_data_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_selection_data_get_type".}
-proc gtk_selection_data_copy*(data: PGtkSelectionData): PGtkSelectionData{.
-    cdecl, dynlib: gtklib, importc: "gtk_selection_data_copy".}
-proc gtk_selection_data_free*(data: PGtkSelectionData){.cdecl, dynlib: gtklib,
-    importc: "gtk_selection_data_free".}
-proc GTK_TYPE_SEPARATOR_MENU_ITEM*(): GType
-proc GTK_SEPARATOR_MENU_ITEM*(obj: pointer): PGtkSeparatorMenuItem
-proc GTK_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): PGtkSeparatorMenuItemClass
-proc GTK_IS_SEPARATOR_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_SEPARATOR_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkSeparatorMenuItemClass
-proc gtk_separator_menu_item_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_separator_menu_item_get_type".}
-proc gtk_separator_menu_item_new*(): PGtkSeparatorMenuItem{.cdecl, dynlib: gtklib,
-    importc: "gtk_separator_menu_item_new".}
-const
-  bm_TGtkSizeGroup_have_width* = 0x00000001'i16
-  bp_TGtkSizeGroup_have_width* = 0'i16
-  bm_TGtkSizeGroup_have_height* = 0x00000002'i16
-  bp_TGtkSizeGroup_have_height* = 1'i16
-
-proc GTK_TYPE_SIZE_GROUP*(): GType
-proc GTK_SIZE_GROUP*(obj: pointer): PGtkSizeGroup
-proc GTK_SIZE_GROUP_CLASS*(klass: pointer): PGtkSizeGroupClass
-proc GTK_IS_SIZE_GROUP*(obj: pointer): bool
-proc GTK_IS_SIZE_GROUP_CLASS*(klass: pointer): bool
-proc GTK_SIZE_GROUP_GET_CLASS*(obj: pointer): PGtkSizeGroupClass
-proc have_width*(a: var TGtkSizeGroup): guint
-proc set_have_width*(a: var TGtkSizeGroup, `have_width`: guint)
-proc have_height*(a: var TGtkSizeGroup): guint
-proc set_have_height*(a: var TGtkSizeGroup, `have_height`: guint)
-proc gtk_size_group_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_size_group_get_type".}
-proc gtk_size_group_new*(mode: TGtkSizeGroupMode): PGtkSizeGroup{.cdecl,
-    dynlib: gtklib, importc: "gtk_size_group_new".}
-proc gtk_size_group_set_mode*(size_group: PGtkSizeGroup, mode: TGtkSizeGroupMode){.
-    cdecl, dynlib: gtklib, importc: "gtk_size_group_set_mode".}
-proc gtk_size_group_get_mode*(size_group: PGtkSizeGroup): TGtkSizeGroupMode{.
-    cdecl, dynlib: gtklib, importc: "gtk_size_group_get_mode".}
-proc gtk_size_group_add_widget*(size_group: PGtkSizeGroup, widget: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_size_group_add_widget".}
-proc gtk_size_group_remove_widget*(size_group: PGtkSizeGroup, widget: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_size_group_remove_widget".}
-proc gtk_size_group_get_child_requisition*(widget: PGtkWidget,
-    requisition: PGtkRequisition){.cdecl, dynlib: gtklib, importc: "_gtk_size_group_get_child_requisition".}
-proc gtk_size_group_compute_requisition*(widget: PGtkWidget,
-    requisition: PGtkRequisition){.cdecl, dynlib: gtklib, importc: "_gtk_size_group_compute_requisition".}
-proc gtk_size_group_queue_resize*(widget: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "_gtk_size_group_queue_resize".}
-const
-  bm_TGtkSocket_same_app* = 0x00000001'i16
-  bp_TGtkSocket_same_app* = 0'i16
-  bm_TGtkSocket_focus_in* = 0x00000002'i16
-  bp_TGtkSocket_focus_in* = 1'i16
-  bm_TGtkSocket_have_size* = 0x00000004'i16
-  bp_TGtkSocket_have_size* = 2'i16
-  bm_TGtkSocket_need_map* = 0x00000008'i16
-  bp_TGtkSocket_need_map* = 3'i16
-  bm_TGtkSocket_is_mapped* = 0x00000010'i16
-  bp_TGtkSocket_is_mapped* = 4'i16
-
-proc GTK_TYPE_SOCKET*(): GType
-proc GTK_SOCKET*(obj: pointer): PGtkSocket
-proc GTK_SOCKET_CLASS*(klass: pointer): PGtkSocketClass
-proc GTK_IS_SOCKET*(obj: pointer): bool
-proc GTK_IS_SOCKET_CLASS*(klass: pointer): bool
-proc GTK_SOCKET_GET_CLASS*(obj: pointer): PGtkSocketClass
-proc same_app*(a: var TGtkSocket): guint
-proc set_same_app*(a: var TGtkSocket, `same_app`: guint)
-proc focus_in*(a: var TGtkSocket): guint
-proc set_focus_in*(a: var TGtkSocket, `focus_in`: guint)
-proc have_size*(a: var TGtkSocket): guint
-proc set_have_size*(a: var TGtkSocket, `have_size`: guint)
-proc need_map*(a: var TGtkSocket): guint
-proc set_need_map*(a: var TGtkSocket, `need_map`: guint)
-proc is_mapped*(a: var TGtkSocket): guint
-proc set_is_mapped*(a: var TGtkSocket, `is_mapped`: guint)
-proc gtk_socket_new*(): PGtkSocket {.cdecl, dynlib: gtklib,
-                                    importc: "gtk_socket_new".}
-proc gtk_socket_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_socket_get_type".}
-proc gtk_socket_add_id*(socket: PGtkSocket, window_id: TGdkNativeWindow){.cdecl,
-    dynlib: gtklib, importc: "gtk_socket_add_id".}
-proc gtk_socket_get_id*(socket: PGtkSocket): TGdkNativeWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_socket_get_id".}
-const
-  GTK_INPUT_ERROR* = - (1)
-  bm_TGtkSpinButton_in_child* = 0x00000003'i32
-  bp_TGtkSpinButton_in_child* = 0'i32
-  bm_TGtkSpinButton_click_child* = 0x0000000C'i32
-  bp_TGtkSpinButton_click_child* = 2'i32
-  bm_TGtkSpinButton_button* = 0x00000030'i32
-  bp_TGtkSpinButton_button* = 4'i32
-  bm_TGtkSpinButton_need_timer* = 0x00000040'i32
-  bp_TGtkSpinButton_need_timer* = 6'i32
-  bm_TGtkSpinButton_timer_calls* = 0x00000380'i32
-  bp_TGtkSpinButton_timer_calls* = 7'i32
-  bm_TGtkSpinButton_digits* = 0x000FFC00'i32
-  bp_TGtkSpinButton_digits* = 10'i32
-  bm_TGtkSpinButton_numeric* = 0x00100000'i32
-  bp_TGtkSpinButton_numeric* = 20'i32
-  bm_TGtkSpinButton_wrap* = 0x00200000'i32
-  bp_TGtkSpinButton_wrap* = 21'i32
-  bm_TGtkSpinButton_snap_to_ticks* = 0x00400000'i32
-  bp_TGtkSpinButton_snap_to_ticks* = 22'i32
-
-proc GTK_TYPE_SPIN_BUTTON*(): GType
-proc GTK_SPIN_BUTTON*(obj: pointer): PGtkSpinButton
-proc GTK_SPIN_BUTTON_CLASS*(klass: pointer): PGtkSpinButtonClass
-proc GTK_IS_SPIN_BUTTON*(obj: pointer): bool
-proc GTK_IS_SPIN_BUTTON_CLASS*(klass: pointer): bool
-proc GTK_SPIN_BUTTON_GET_CLASS*(obj: pointer): PGtkSpinButtonClass
-proc in_child*(a: var TGtkSpinButton): guint
-proc set_in_child*(a: var TGtkSpinButton, `in_child`: guint)
-proc click_child*(a: var TGtkSpinButton): guint
-proc set_click_child*(a: var TGtkSpinButton, `click_child`: guint)
-proc button*(a: var TGtkSpinButton): guint
-proc set_button*(a: var TGtkSpinButton, `button`: guint)
-proc need_timer*(a: var TGtkSpinButton): guint
-proc set_need_timer*(a: var TGtkSpinButton, `need_timer`: guint)
-proc timer_calls*(a: var TGtkSpinButton): guint
-proc set_timer_calls*(a: var TGtkSpinButton, `timer_calls`: guint)
-proc digits*(a: var TGtkSpinButton): guint
-proc set_digits*(a: var TGtkSpinButton, `digits`: guint)
-proc numeric*(a: var TGtkSpinButton): guint
-proc set_numeric*(a: var TGtkSpinButton, `numeric`: guint)
-proc wrap*(a: var TGtkSpinButton): guint
-proc set_wrap*(a: var TGtkSpinButton, `wrap`: guint)
-proc snap_to_ticks*(a: var TGtkSpinButton): guint
-proc set_snap_to_ticks*(a: var TGtkSpinButton, `snap_to_ticks`: guint)
-proc gtk_spin_button_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_get_type".}
-proc gtk_spin_button_configure*(spin_button: PGtkSpinButton,
-                                adjustment: PGtkAdjustment, climb_rate: gdouble,
-                                digits: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_configure".}
-proc gtk_spin_button_new*(adjustment: PGtkAdjustment, climb_rate: gdouble,
-                          digits: guint): PGtkSpinButton{.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_new".}
-proc gtk_spin_button_new_with_range*(min: gdouble, max: gdouble, step: gdouble): PGtkSpinButton{.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_new_with_range".}
-proc gtk_spin_button_set_adjustment*(spin_button: PGtkSpinButton,
-                                     adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_set_adjustment".}
-proc gtk_spin_button_get_adjustment*(spin_button: PGtkSpinButton): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_get_adjustment".}
-proc gtk_spin_button_set_digits*(spin_button: PGtkSpinButton, digits: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_set_digits".}
-proc gtk_spin_button_get_digits*(spin_button: PGtkSpinButton): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_get_digits".}
-proc gtk_spin_button_set_increments*(spin_button: PGtkSpinButton, step: gdouble,
-                                     page: gdouble){.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_set_increments".}
-proc gtk_spin_button_get_increments*(spin_button: PGtkSpinButton,
-                                     step: Pgdouble, page: Pgdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_get_increments".}
-proc gtk_spin_button_set_range*(spin_button: PGtkSpinButton, min: gdouble,
-                                max: gdouble){.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_set_range".}
-proc gtk_spin_button_get_range*(spin_button: PGtkSpinButton, min: Pgdouble,
-                                max: Pgdouble){.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_get_range".}
-proc gtk_spin_button_get_value*(spin_button: PGtkSpinButton): gdouble{.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_get_value".}
-proc gtk_spin_button_get_value_as_int*(spin_button: PGtkSpinButton): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_get_value_as_int".}
-proc gtk_spin_button_set_value*(spin_button: PGtkSpinButton, value: gdouble){.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_set_value".}
-proc gtk_spin_button_set_update_policy*(spin_button: PGtkSpinButton,
-                                        policy: TGtkSpinButtonUpdatePolicy){.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_set_update_policy".}
-proc gtk_spin_button_get_update_policy*(spin_button: PGtkSpinButton): TGtkSpinButtonUpdatePolicy{.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_get_update_policy".}
-proc gtk_spin_button_set_numeric*(spin_button: PGtkSpinButton, numeric: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_set_numeric".}
-proc gtk_spin_button_get_numeric*(spin_button: PGtkSpinButton): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_get_numeric".}
-proc gtk_spin_button_spin*(spin_button: PGtkSpinButton, direction: TGtkSpinType,
-                           increment: gdouble){.cdecl, dynlib: gtklib,
-    importc: "gtk_spin_button_spin".}
-proc gtk_spin_button_set_wrap*(spin_button: PGtkSpinButton, wrap: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_set_wrap".}
-proc gtk_spin_button_get_wrap*(spin_button: PGtkSpinButton): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_get_wrap".}
-proc gtk_spin_button_set_snap_to_ticks*(spin_button: PGtkSpinButton,
-                                        snap_to_ticks: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_set_snap_to_ticks".}
-proc gtk_spin_button_get_snap_to_ticks*(spin_button: PGtkSpinButton): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_spin_button_get_snap_to_ticks".}
-proc gtk_spin_button_update*(spin_button: PGtkSpinButton){.cdecl,
-    dynlib: gtklib, importc: "gtk_spin_button_update".}
-const
-  GTK_STOCK_DIALOG_INFO* = "gtk-dialog-info"
-  GTK_STOCK_DIALOG_WARNING* = "gtk-dialog-warning"
-  GTK_STOCK_DIALOG_ERROR* = "gtk-dialog-error"
-  GTK_STOCK_DIALOG_QUESTION* = "gtk-dialog-question"
-  GTK_STOCK_DND* = "gtk-dnd"
-  GTK_STOCK_DND_MULTIPLE* = "gtk-dnd-multiple"
-  GTK_STOCK_ABOUT* = "gtk-about"
-  GTK_STOCK_ADD_name* = "gtk-add"
-  GTK_STOCK_APPLY* = "gtk-apply"
-  GTK_STOCK_BOLD* = "gtk-bold"
-  GTK_STOCK_CANCEL* = "gtk-cancel"
-  GTK_STOCK_CDROM* = "gtk-cdrom"
-  GTK_STOCK_CLEAR* = "gtk-clear"
-  GTK_STOCK_CLOSE* = "gtk-close"
-  GTK_STOCK_COLOR_PICKER* = "gtk-color-picker"
-  GTK_STOCK_CONVERT* = "gtk-convert"
-  GTK_STOCK_CONNECT* = "gtk-connect"
-  GTK_STOCK_COPY* = "gtk-copy"
-  GTK_STOCK_CUT* = "gtk-cut"
-  GTK_STOCK_DELETE* = "gtk-delete"
-  GTK_STOCK_EDIT* = "gtk-edit"
-  GTK_STOCK_EXECUTE* = "gtk-execute"
-  GTK_STOCK_FIND* = "gtk-find"
-  GTK_STOCK_FIND_AND_REPLACE* = "gtk-find-and-replace"
-  GTK_STOCK_FLOPPY* = "gtk-floppy"
-  GTK_STOCK_GOTO_BOTTOM* = "gtk-goto-bottom"
-  GTK_STOCK_GOTO_FIRST* = "gtk-goto-first"
-  GTK_STOCK_GOTO_LAST* = "gtk-goto-last"
-  GTK_STOCK_GOTO_TOP* = "gtk-goto-top"
-  GTK_STOCK_GO_BACK* = "gtk-go-back"
-  GTK_STOCK_GO_DOWN* = "gtk-go-down"
-  GTK_STOCK_GO_FORWARD* = "gtk-go-forward"
-  GTK_STOCK_GO_UP* = "gtk-go-up"
-  GTK_STOCK_HELP* = "gtk-help"
-  GTK_STOCK_HOME* = "gtk-home"
-  GTK_STOCK_INDEX* = "gtk-index"
-  GTK_STOCK_ITALIC* = "gtk-italic"
-  GTK_STOCK_JUMP_TO* = "gtk-jump-to"
-  GTK_STOCK_JUSTIFY_CENTER* = "gtk-justify-center"
-  GTK_STOCK_JUSTIFY_FILL* = "gtk-justify-fill"
-  GTK_STOCK_JUSTIFY_LEFT* = "gtk-justify-left"
-  GTK_STOCK_JUSTIFY_RIGHT* = "gtk-justify-right"
-  GTK_STOCK_MEDIA_FORWARD* = "gtk-media-forward"
-  GTK_STOCK_MEDIA_NEXT* = "gtk-media-next"
-  GTK_STOCK_MEDIA_PAUSE* = "gtk-media-pause"
-  GTK_STOCK_MEDIA_PLAY* = "gtk-media-play"
-  GTK_STOCK_MEDIA_PREVIOUS* = "gtk-media-previous"
-  GTK_STOCK_MEDIA_RECORD* = "gtk-media-record"
-  GTK_STOCK_MEDIA_REWIND* = "gtk-media-rewind"
-  GTK_STOCK_MEDIA_STOP* = "gtk-media-stop"
-  GTK_STOCK_MISSING_IMAGE* = "gtk-missing-image"
-  GTK_STOCK_NEW* = "gtk-new"
-  GTK_STOCK_NO* = "gtk-no"
-  GTK_STOCK_OK* = "gtk-ok"
-  GTK_STOCK_OPEN* = "gtk-open"
-  GTK_STOCK_PASTE* = "gtk-paste"
-  GTK_STOCK_PREFERENCES* = "gtk-preferences"
-  GTK_STOCK_PRINT* = "gtk-print"
-  GTK_STOCK_PRINT_PREVIEW* = "gtk-print-preview"
-  GTK_STOCK_PROPERTIES* = "gtk-properties"
-  GTK_STOCK_QUIT* = "gtk-quit"
-  GTK_STOCK_REDO* = "gtk-redo"
-  GTK_STOCK_REFRESH* = "gtk-refresh"
-  GTK_STOCK_REMOVE* = "gtk-remove"
-  GTK_STOCK_REVERT_TO_SAVED* = "gtk-revert-to-saved"
-  GTK_STOCK_SAVE* = "gtk-save"
-  GTK_STOCK_SAVE_AS* = "gtk-save-as"
-  GTK_STOCK_SELECT_COLOR* = "gtk-select-color"
-  GTK_STOCK_SELECT_FONT* = "gtk-select-font"
-  GTK_STOCK_SORT_ASCENDING* = "gtk-sort-ascending"
-  GTK_STOCK_SORT_DESCENDING* = "gtk-sort-descending"
-  GTK_STOCK_SPELL_CHECK* = "gtk-spell-check"
-  GTK_STOCK_STOP* = "gtk-stop"
-  GTK_STOCK_STRIKETHROUGH* = "gtk-strikethrough"
-  GTK_STOCK_UNDELETE* = "gtk-undelete"
-  GTK_STOCK_UNDERLINE* = "gtk-underline"
-  GTK_STOCK_UNDO* = "gtk-undo"
-  GTK_STOCK_YES* = "gtk-yes"
-  GTK_STOCK_ZOOM_100* = "gtk-zoom-100"
-  GTK_STOCK_ZOOM_FIT* = "gtk-zoom-fit"
-  GTK_STOCK_ZOOM_IN* = "gtk-zoom-in"
-  GTK_STOCK_ZOOM_OUT* = "gtk-zoom-out"
-
-proc gtk_stock_add*(items: PGtkStockItem, n_items: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_stock_add".}
-proc gtk_stock_add_static*(items: PGtkStockItem, n_items: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_stock_add_static".}
-proc gtk_stock_lookup*(stock_id: cstring, item: PGtkStockItem): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_stock_lookup".}
-proc gtk_stock_list_ids*(): PGSList{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_stock_list_ids".}
-proc gtk_stock_item_copy*(item: PGtkStockItem): PGtkStockItem{.cdecl,
-    dynlib: gtklib, importc: "gtk_stock_item_copy".}
-proc gtk_stock_item_free*(item: PGtkStockItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_stock_item_free".}
-proc GTK_TYPE_STATUSBAR*(): GType
-proc GTK_STATUSBAR*(obj: pointer): PGtkStatusbar
-proc GTK_STATUSBAR_CLASS*(klass: pointer): PGtkStatusbarClass
-proc GTK_IS_STATUSBAR*(obj: pointer): bool
-proc GTK_IS_STATUSBAR_CLASS*(klass: pointer): bool
-proc GTK_STATUSBAR_GET_CLASS*(obj: pointer): PGtkStatusbarClass
-const
-  bm_TGtkStatusbar_has_resize_grip* = 0x00000001'i16
-  bp_TGtkStatusbar_has_resize_grip* = 0'i16
-
-proc has_resize_grip*(a: var TGtkStatusbar): guint
-proc set_has_resize_grip*(a: var TGtkStatusbar, `has_resize_grip`: guint)
-proc gtk_statusbar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_statusbar_get_type".}
-proc gtk_statusbar_new*(): PGtkStatusbar{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_statusbar_new".}
-proc gtk_statusbar_get_context_id*(statusbar: PGtkStatusbar,
-                                   context_description: cstring): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_statusbar_get_context_id".}
-proc gtk_statusbar_push*(statusbar: PGtkStatusbar, context_id: guint,
-                         text: cstring): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_statusbar_push".}
-proc gtk_statusbar_pop*(statusbar: PGtkStatusbar, context_id: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_statusbar_pop".}
-proc gtk_statusbar_remove*(statusbar: PGtkStatusbar, context_id: guint,
-                           message_id: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_statusbar_remove".}
-proc gtk_statusbar_set_has_resize_grip*(statusbar: PGtkStatusbar,
-                                        setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_statusbar_set_has_resize_grip".}
-proc gtk_statusbar_get_has_resize_grip*(statusbar: PGtkStatusbar): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_statusbar_get_has_resize_grip".}
-const
-  bm_TGtkTable_homogeneous* = 0x00000001'i16
-  bp_TGtkTable_homogeneous* = 0'i16
-  bm_TGtkTableChild_xexpand* = 0x00000001'i16
-  bp_TGtkTableChild_xexpand* = 0'i16
-  bm_TGtkTableChild_yexpand* = 0x00000002'i16
-  bp_TGtkTableChild_yexpand* = 1'i16
-  bm_TGtkTableChild_xshrink* = 0x00000004'i16
-  bp_TGtkTableChild_xshrink* = 2'i16
-  bm_TGtkTableChild_yshrink* = 0x00000008'i16
-  bp_TGtkTableChild_yshrink* = 3'i16
-  bm_TGtkTableChild_xfill* = 0x00000010'i16
-  bp_TGtkTableChild_xfill* = 4'i16
-  bm_TGtkTableChild_yfill* = 0x00000020'i16
-  bp_TGtkTableChild_yfill* = 5'i16
-  bm_TGtkTableRowCol_need_expand* = 0x00000001'i16
-  bp_TGtkTableRowCol_need_expand* = 0'i16
-  bm_TGtkTableRowCol_need_shrink* = 0x00000002'i16
-  bp_TGtkTableRowCol_need_shrink* = 1'i16
-  bm_TGtkTableRowCol_expand* = 0x00000004'i16
-  bp_TGtkTableRowCol_expand* = 2'i16
-  bm_TGtkTableRowCol_shrink* = 0x00000008'i16
-  bp_TGtkTableRowCol_shrink* = 3'i16
-  bm_TGtkTableRowCol_empty* = 0x00000010'i16
-  bp_TGtkTableRowCol_empty* = 4'i16
-
-proc GTK_TYPE_TABLE*(): GType
-proc GTK_TABLE*(obj: pointer): PGtkTable
-proc GTK_TABLE_CLASS*(klass: pointer): PGtkTableClass
-proc GTK_IS_TABLE*(obj: pointer): bool
-proc GTK_IS_TABLE_CLASS*(klass: pointer): bool
-proc GTK_TABLE_GET_CLASS*(obj: pointer): PGtkTableClass
-proc homogeneous*(a: var TGtkTable): guint
-proc set_homogeneous*(a: var TGtkTable, `homogeneous`: guint)
-proc xexpand*(a: var TGtkTableChild): guint
-proc set_xexpand*(a: var TGtkTableChild, `xexpand`: guint)
-proc yexpand*(a: var TGtkTableChild): guint
-proc set_yexpand*(a: var TGtkTableChild, `yexpand`: guint)
-proc xshrink*(a: var TGtkTableChild): guint
-proc set_xshrink*(a: var TGtkTableChild, `xshrink`: guint)
-proc yshrink*(a: var TGtkTableChild): guint
-proc set_yshrink*(a: var TGtkTableChild, `yshrink`: guint)
-proc xfill*(a: var TGtkTableChild): guint
-proc set_xfill*(a: var TGtkTableChild, `xfill`: guint)
-proc yfill*(a: var TGtkTableChild): guint
-proc set_yfill*(a: var TGtkTableChild, `yfill`: guint)
-proc need_expand*(a: var TGtkTableRowCol): guint
-proc set_need_expand*(a: var TGtkTableRowCol, `need_expand`: guint)
-proc need_shrink*(a: var TGtkTableRowCol): guint
-proc set_need_shrink*(a: var TGtkTableRowCol, `need_shrink`: guint)
-proc expand*(a: var TGtkTableRowCol): guint
-proc set_expand*(a: var TGtkTableRowCol, `expand`: guint)
-proc shrink*(a: var TGtkTableRowCol): guint
-proc set_shrink*(a: var TGtkTableRowCol, `shrink`: guint)
-proc empty*(a: var TGtkTableRowCol): guint
-proc set_empty*(a: var TGtkTableRowCol, `empty`: guint)
-proc gtk_table_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_table_get_type".}
-proc gtk_table_new*(rows: guint, columns: guint, homogeneous: gboolean): PGtkTable{.
-    cdecl, dynlib: gtklib, importc: "gtk_table_new".}
-proc gtk_table_resize*(table: PGtkTable, rows: guint, columns: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_table_resize".}
-proc gtk_table_attach*(table: PGtkTable, child: PGtkWidget, left_attach: guint,
-                       right_attach: guint, top_attach: guint,
-                       bottom_attach: guint, xoptions: TGtkAttachOptions,
-                       yoptions: TGtkAttachOptions, xpadding: guint,
-                       ypadding: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_table_attach".}
-proc gtk_table_attach_defaults*(table: PGtkTable, widget: PGtkWidget,
-                                left_attach: guint, right_attach: guint,
-                                top_attach: guint, bottom_attach: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_table_attach_defaults".}
-proc gtk_table_set_row_spacing*(table: PGtkTable, row: guint, spacing: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_table_set_row_spacing".}
-proc gtk_table_get_row_spacing*(table: PGtkTable, row: guint): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_table_get_row_spacing".}
-proc gtk_table_set_col_spacing*(table: PGtkTable, column: guint, spacing: guint){.
-    cdecl, dynlib: gtklib, importc: "gtk_table_set_col_spacing".}
-proc gtk_table_get_col_spacing*(table: PGtkTable, column: guint): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_table_get_col_spacing".}
-proc gtk_table_set_row_spacings*(table: PGtkTable, spacing: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_table_set_row_spacings".}
-proc gtk_table_get_default_row_spacing*(table: PGtkTable): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_table_get_default_row_spacing".}
-proc gtk_table_set_col_spacings*(table: PGtkTable, spacing: guint){.cdecl,
-    dynlib: gtklib, importc: "gtk_table_set_col_spacings".}
-proc gtk_table_get_default_col_spacing*(table: PGtkTable): guint{.cdecl,
-    dynlib: gtklib, importc: "gtk_table_get_default_col_spacing".}
-proc gtk_table_set_homogeneous*(table: PGtkTable, homogeneous: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_table_set_homogeneous".}
-proc gtk_table_get_homogeneous*(table: PGtkTable): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_table_get_homogeneous".}
-const
-  bm_TGtkTearoffMenuItem_torn_off* = 0x00000001'i16
-  bp_TGtkTearoffMenuItem_torn_off* = 0'i16
-
-proc GTK_TYPE_TEAROFF_MENU_ITEM*(): GType
-proc GTK_TEAROFF_MENU_ITEM*(obj: pointer): PGtkTearoffMenuItem
-proc GTK_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): PGtkTearoffMenuItemClass
-proc GTK_IS_TEAROFF_MENU_ITEM*(obj: pointer): bool
-proc GTK_IS_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): bool
-proc GTK_TEAROFF_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkTearoffMenuItemClass
-proc torn_off*(a: var TGtkTearoffMenuItem): guint
-proc set_torn_off*(a: var TGtkTearoffMenuItem, `torn_off`: guint)
-proc gtk_tearoff_menu_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tearoff_menu_item_get_type".}
-proc gtk_tearoff_menu_item_new*(): PGtkTearoffMenuItem{.cdecl, dynlib: gtklib,
-    importc: "gtk_tearoff_menu_item_new".}
-const
-  bm_TGtkText_line_wrap* = 0x00000001'i16
-  bp_TGtkText_line_wrap* = 0'i16
-  bm_TGtkText_word_wrap* = 0x00000002'i16
-  bp_TGtkText_word_wrap* = 1'i16
-  bm_TGtkText_use_wchar* = 0x00000004'i16
-  bp_TGtkText_use_wchar* = 2'i16
-
-proc GTK_TYPE_TEXT*(): GType
-proc GTK_TEXT*(obj: pointer): PGtkText
-proc GTK_TEXT_CLASS*(klass: pointer): PGtkTextClass
-proc GTK_IS_TEXT*(obj: pointer): bool
-proc GTK_IS_TEXT_CLASS*(klass: pointer): bool
-proc GTK_TEXT_GET_CLASS*(obj: pointer): PGtkTextClass
-proc line_wrap*(a: PGtkText): guint
-proc set_line_wrap*(a: PGtkText, `line_wrap`: guint)
-proc word_wrap*(a: PGtkText): guint
-proc set_word_wrap*(a: PGtkText, `word_wrap`: guint)
-proc use_wchar*(a: PGtkText): gboolean
-proc set_use_wchar*(a: PGtkText, `use_wchar`: gboolean)
-proc gtk_text_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_text_get_type".}
-proc gtk_text_new*(hadj: PGtkAdjustment, vadj: PGtkAdjustment): PGtkText{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_new".}
-proc gtk_text_set_editable*(text: PGtkText, editable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_set_editable".}
-proc gtk_text_set_word_wrap*(text: PGtkText, word_wrap: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_set_word_wrap".}
-proc gtk_text_set_line_wrap*(text: PGtkText, line_wrap: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_set_line_wrap".}
-proc gtk_text_set_adjustments*(text: PGtkText, hadj: PGtkAdjustment,
-                               vadj: PGtkAdjustment){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_set_adjustments".}
-proc gtk_text_set_point*(text: PGtkText, index: guint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_set_point".}
-proc gtk_text_get_point*(text: PGtkText): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_get_point".}
-proc gtk_text_get_length*(text: PGtkText): guint{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_get_length".}
-proc gtk_text_freeze*(text: PGtkText){.cdecl, dynlib: gtklib,
-                                       importc: "gtk_text_freeze".}
-proc gtk_text_thaw*(text: PGtkText){.cdecl, dynlib: gtklib,
-                                     importc: "gtk_text_thaw".}
-proc gtk_text_insert*(text: PGtkText, font: PGdkFont, fore: PGdkColor,
-                      back: PGdkColor, chars: cstring, length: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_insert".}
-proc gtk_text_backward_delete*(text: PGtkText, nchars: guint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_backward_delete".}
-proc gtk_text_forward_delete*(text: PGtkText, nchars: guint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_forward_delete".}
-proc GTK_TEXT_INDEX_WCHAR*(t: PGtkText, index: guint): guint32
-proc GTK_TEXT_INDEX_UCHAR*(t: PGtkText, index: guint): GUChar
-const
-  GTK_TEXT_SEARCH_VISIBLE_ONLY* = 0
-  GTK_TEXT_SEARCH_TEXT_ONLY* = 1
-
-proc GTK_TYPE_TEXT_ITER*(): GType
-proc gtk_text_iter_get_buffer*(iter: PGtkTextIter): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_buffer".}
-proc gtk_text_iter_copy*(iter: PGtkTextIter): PGtkTextIter{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_copy".}
-proc gtk_text_iter_free*(iter: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_iter_free".}
-proc gtk_text_iter_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_text_iter_get_type".}
-proc gtk_text_iter_get_offset*(iter: PGtkTextIter): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_iter_get_offset".}
-proc gtk_text_iter_get_line*(iter: PGtkTextIter): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_iter_get_line".}
-proc gtk_text_iter_get_line_offset*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_line_offset".}
-proc gtk_text_iter_get_line_index*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_line_index".}
-proc gtk_text_iter_get_visible_line_offset*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_visible_line_offset".}
-proc gtk_text_iter_get_visible_line_index*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_visible_line_index".}
-proc gtk_text_iter_get_char*(iter: PGtkTextIter): gunichar{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_char".}
-proc gtk_text_iter_get_slice*(start: PGtkTextIter, theEnd: PGtkTextIter): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_slice".}
-proc gtk_text_iter_get_text*(start: PGtkTextIter, theEnd: PGtkTextIter): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_text".}
-proc gtk_text_iter_get_visible_slice*(start: PGtkTextIter, theEnd: PGtkTextIter): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_visible_slice".}
-proc gtk_text_iter_get_visible_text*(start: PGtkTextIter, theEnd: PGtkTextIter): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_visible_text".}
-proc gtk_text_iter_get_pixbuf*(iter: PGtkTextIter): PGdkPixbuf{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_pixbuf".}
-proc gtk_text_iter_get_marks*(iter: PGtkTextIter): PGSList{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_marks".}
-proc gtk_text_iter_get_child_anchor*(iter: PGtkTextIter): PGtkTextChildAnchor{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_child_anchor".}
-proc gtk_text_iter_get_toggled_tags*(iter: PGtkTextIter, toggled_on: gboolean): PGSList{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_get_toggled_tags".}
-proc gtk_text_iter_begins_tag*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_begins_tag".}
-proc gtk_text_iter_ends_tag*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_ends_tag".}
-proc gtk_text_iter_toggles_tag*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_toggles_tag".}
-proc gtk_text_iter_has_tag*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_has_tag".}
-proc gtk_text_iter_get_tags*(iter: PGtkTextIter): PGSList{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_tags".}
-proc gtk_text_iter_editable*(iter: PGtkTextIter, default_setting: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_editable".}
-proc gtk_text_iter_can_insert*(iter: PGtkTextIter, default_editability: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_can_insert".}
-proc gtk_text_iter_starts_word*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_starts_word".}
-proc gtk_text_iter_ends_word*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_ends_word".}
-proc gtk_text_iter_inside_word*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_inside_word".}
-proc gtk_text_iter_starts_sentence*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_starts_sentence".}
-proc gtk_text_iter_ends_sentence*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_ends_sentence".}
-proc gtk_text_iter_inside_sentence*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_inside_sentence".}
-proc gtk_text_iter_starts_line*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_starts_line".}
-proc gtk_text_iter_ends_line*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_ends_line".}
-proc gtk_text_iter_is_cursor_position*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_is_cursor_position".}
-proc gtk_text_iter_get_chars_in_line*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_chars_in_line".}
-proc gtk_text_iter_get_bytes_in_line*(iter: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_bytes_in_line".}
-proc gtk_text_iter_get_attributes*(iter: PGtkTextIter,
-                                   values: PGtkTextAttributes): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_attributes".}
-proc gtk_text_iter_get_language*(iter: PGtkTextIter): PPangoLanguage{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_get_language".}
-proc gtk_text_iter_is_end*(iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_iter_is_end".}
-proc gtk_text_iter_is_start*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_is_start".}
-proc gtk_text_iter_forward_char*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_forward_char".}
-proc gtk_text_iter_backward_char*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_backward_char".}
-proc gtk_text_iter_forward_chars*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_chars".}
-proc gtk_text_iter_backward_chars*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_chars".}
-proc gtk_text_iter_forward_line*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_forward_line".}
-proc gtk_text_iter_backward_line*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_backward_line".}
-proc gtk_text_iter_forward_lines*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_lines".}
-proc gtk_text_iter_backward_lines*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_lines".}
-proc gtk_text_iter_forward_word_end*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_forward_word_end".}
-proc gtk_text_iter_backward_word_start*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_backward_word_start".}
-proc gtk_text_iter_forward_word_ends*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_word_ends".}
-proc gtk_text_iter_backward_word_starts*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_word_starts".}
-proc gtk_text_iter_forward_sentence_end*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_forward_sentence_end".}
-proc gtk_text_iter_backward_sentence_start*(iter: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_sentence_start".}
-proc gtk_text_iter_forward_sentence_ends*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_sentence_ends".}
-proc gtk_text_iter_backward_sentence_starts*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_sentence_starts".}
-proc gtk_text_iter_forward_cursor_position*(iter: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_cursor_position".}
-proc gtk_text_iter_backward_cursor_position*(iter: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_cursor_position".}
-proc gtk_text_iter_forward_cursor_positions*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_cursor_positions".}
-proc gtk_text_iter_backward_cursor_positions*(iter: PGtkTextIter, count: gint): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_cursor_positions".}
-proc gtk_text_iter_set_offset*(iter: PGtkTextIter, char_offset: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_set_offset".}
-proc gtk_text_iter_set_line*(iter: PGtkTextIter, line_number: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_set_line".}
-proc gtk_text_iter_set_line_offset*(iter: PGtkTextIter, char_on_line: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_set_line_offset".}
-proc gtk_text_iter_set_line_index*(iter: PGtkTextIter, byte_on_line: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_set_line_index".}
-proc gtk_text_iter_forward_to_end*(iter: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_iter_forward_to_end".}
-proc gtk_text_iter_forward_to_line_end*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_forward_to_line_end".}
-proc gtk_text_iter_set_visible_line_offset*(iter: PGtkTextIter,
-    char_on_line: gint){.cdecl, dynlib: gtklib,
-                         importc: "gtk_text_iter_set_visible_line_offset".}
-proc gtk_text_iter_set_visible_line_index*(iter: PGtkTextIter,
-    byte_on_line: gint){.cdecl, dynlib: gtklib,
-                         importc: "gtk_text_iter_set_visible_line_index".}
-proc gtk_text_iter_forward_to_tag_toggle*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_to_tag_toggle".}
-proc gtk_text_iter_backward_to_tag_toggle*(iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_to_tag_toggle".}
-proc gtk_text_iter_forward_find_char*(iter: PGtkTextIter,
-                                      pred: TGtkTextCharPredicate,
-                                      user_data: gpointer, limit: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_find_char".}
-proc gtk_text_iter_backward_find_char*(iter: PGtkTextIter,
-                                       pred: TGtkTextCharPredicate,
-                                       user_data: gpointer, limit: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_find_char".}
-proc gtk_text_iter_forward_search*(iter: PGtkTextIter, str: cstring,
-                                   flags: TGtkTextSearchFlags,
-                                   match_start: PGtkTextIter,
-                                   match_end: PGtkTextIter, limit: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_forward_search".}
-proc gtk_text_iter_backward_search*(iter: PGtkTextIter, str: cstring,
-                                    flags: TGtkTextSearchFlags,
-                                    match_start: PGtkTextIter,
-                                    match_end: PGtkTextIter, limit: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_backward_search".}
-proc gtk_text_iter_equal*(lhs: PGtkTextIter, rhs: PGtkTextIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_iter_equal".}
-proc gtk_text_iter_compare*(lhs: PGtkTextIter, rhs: PGtkTextIter): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_compare".}
-proc gtk_text_iter_in_range*(iter: PGtkTextIter, start: PGtkTextIter,
-                             theEnd: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_in_range".}
-proc gtk_text_iter_order*(first: PGtkTextIter, second: PGtkTextIter){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_iter_order".}
-proc GTK_TYPE_TEXT_TAG*(): GType
-proc GTK_TEXT_TAG*(obj: pointer): PGtkTextTag
-proc GTK_TEXT_TAG_CLASS*(klass: pointer): PGtkTextTagClass
-proc GTK_IS_TEXT_TAG*(obj: pointer): bool
-proc GTK_IS_TEXT_TAG_CLASS*(klass: pointer): bool
-proc GTK_TEXT_TAG_GET_CLASS*(obj: pointer): PGtkTextTagClass
-proc GTK_TYPE_TEXT_ATTRIBUTES*(): GType
-proc gtk_text_tag_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                      importc: "gtk_text_tag_get_type".}
-proc gtk_text_tag_new*(name: cstring): PGtkTextTag{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_tag_new".}
-proc gtk_text_tag_get_priority*(tag: PGtkTextTag): gint{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_tag_get_priority".}
-proc gtk_text_tag_set_priority*(tag: PGtkTextTag, priority: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_tag_set_priority".}
-proc gtk_text_tag_event*(tag: PGtkTextTag, event_object: PGObject,
-                         event: PGdkEvent, iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_tag_event".}
-proc gtk_text_attributes_new*(): PGtkTextAttributes{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_attributes_new".}
-proc gtk_text_attributes_copy*(src: PGtkTextAttributes): PGtkTextAttributes{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_attributes_copy".}
-proc gtk_text_attributes_copy_values*(src: PGtkTextAttributes,
-                                      dest: PGtkTextAttributes){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_attributes_copy_values".}
-proc gtk_text_attributes_unref*(values: PGtkTextAttributes){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_attributes_unref".}
-proc gtk_text_attributes_ref*(values: PGtkTextAttributes){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_attributes_ref".}
-proc gtk_text_attributes_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_attributes_get_type".}
-const
-  bm_TGtkTextTag_bg_color_set* = 0x00000001'i32
-  bp_TGtkTextTag_bg_color_set* = 0'i32
-  bm_TGtkTextTag_bg_stipple_set* = 0x00000002'i32
-  bp_TGtkTextTag_bg_stipple_set* = 1'i32
-  bm_TGtkTextTag_fg_color_set* = 0x00000004'i32
-  bp_TGtkTextTag_fg_color_set* = 2'i32
-  bm_TGtkTextTag_scale_set* = 0x00000008'i32
-  bp_TGtkTextTag_scale_set* = 3'i32
-  bm_TGtkTextTag_fg_stipple_set* = 0x00000010'i32
-  bp_TGtkTextTag_fg_stipple_set* = 4'i32
-  bm_TGtkTextTag_justification_set* = 0x00000020'i32
-  bp_TGtkTextTag_justification_set* = 5'i32
-  bm_TGtkTextTag_left_margin_set* = 0x00000040'i32
-  bp_TGtkTextTag_left_margin_set* = 6'i32
-  bm_TGtkTextTag_indent_set* = 0x00000080'i32
-  bp_TGtkTextTag_indent_set* = 7'i32
-  bm_TGtkTextTag_rise_set* = 0x00000100'i32
-  bp_TGtkTextTag_rise_set* = 8'i32
-  bm_TGtkTextTag_strikethrough_set* = 0x00000200'i32
-  bp_TGtkTextTag_strikethrough_set* = 9'i32
-  bm_TGtkTextTag_right_margin_set* = 0x00000400'i32
-  bp_TGtkTextTag_right_margin_set* = 10'i32
-  bm_TGtkTextTag_pixels_above_lines_set* = 0x00000800'i32
-  bp_TGtkTextTag_pixels_above_lines_set* = 11'i32
-  bm_TGtkTextTag_pixels_below_lines_set* = 0x00001000'i32
-  bp_TGtkTextTag_pixels_below_lines_set* = 12'i32
-  bm_TGtkTextTag_pixels_inside_wrap_set* = 0x00002000'i32
-  bp_TGtkTextTag_pixels_inside_wrap_set* = 13'i32
-  bm_TGtkTextTag_tabs_set* = 0x00004000'i32
-  bp_TGtkTextTag_tabs_set* = 14'i32
-  bm_TGtkTextTag_underline_set* = 0x00008000'i32
-  bp_TGtkTextTag_underline_set* = 15'i32
-  bm_TGtkTextTag_wrap_mode_set* = 0x00010000'i32
-  bp_TGtkTextTag_wrap_mode_set* = 16'i32
-  bm_TGtkTextTag_bg_full_height_set* = 0x00020000'i32
-  bp_TGtkTextTag_bg_full_height_set* = 17'i32
-  bm_TGtkTextTag_invisible_set* = 0x00040000'i32
-  bp_TGtkTextTag_invisible_set* = 18'i32
-  bm_TGtkTextTag_editable_set* = 0x00080000'i32
-  bp_TGtkTextTag_editable_set* = 19'i32
-  bm_TGtkTextTag_language_set* = 0x00100000'i32
-  bp_TGtkTextTag_language_set* = 20'i32
-  bm_TGtkTextTag_pad1* = 0x00200000'i32
-  bp_TGtkTextTag_pad1* = 21'i32
-  bm_TGtkTextTag_pad2* = 0x00400000'i32
-  bp_TGtkTextTag_pad2* = 22'i32
-  bm_TGtkTextTag_pad3* = 0x00800000'i32
-  bp_TGtkTextTag_pad3* = 23'i32
-
-proc bg_color_set*(a: var TGtkTextTag): guint
-proc set_bg_color_set*(a: var TGtkTextTag, `bg_color_set`: guint)
-proc bg_stipple_set*(a: var TGtkTextTag): guint
-proc set_bg_stipple_set*(a: var TGtkTextTag, `bg_stipple_set`: guint)
-proc fg_color_set*(a: var TGtkTextTag): guint
-proc set_fg_color_set*(a: var TGtkTextTag, `fg_color_set`: guint)
-proc scale_set*(a: var TGtkTextTag): guint
-proc set_scale_set*(a: var TGtkTextTag, `scale_set`: guint)
-proc fg_stipple_set*(a: var TGtkTextTag): guint
-proc set_fg_stipple_set*(a: var TGtkTextTag, `fg_stipple_set`: guint)
-proc justification_set*(a: var TGtkTextTag): guint
-proc set_justification_set*(a: var TGtkTextTag, `justification_set`: guint)
-proc left_margin_set*(a: var TGtkTextTag): guint
-proc set_left_margin_set*(a: var TGtkTextTag, `left_margin_set`: guint)
-proc indent_set*(a: var TGtkTextTag): guint
-proc set_indent_set*(a: var TGtkTextTag, `indent_set`: guint)
-proc rise_set*(a: var TGtkTextTag): guint
-proc set_rise_set*(a: var TGtkTextTag, `rise_set`: guint)
-proc strikethrough_set*(a: var TGtkTextTag): guint
-proc set_strikethrough_set*(a: var TGtkTextTag, `strikethrough_set`: guint)
-proc right_margin_set*(a: var TGtkTextTag): guint
-proc set_right_margin_set*(a: var TGtkTextTag, `right_margin_set`: guint)
-proc pixels_above_lines_set*(a: var TGtkTextTag): guint
-proc set_pixels_above_lines_set*(a: var TGtkTextTag,
-                                 `pixels_above_lines_set`: guint)
-proc pixels_below_lines_set*(a: var TGtkTextTag): guint
-proc set_pixels_below_lines_set*(a: var TGtkTextTag,
-                                 `pixels_below_lines_set`: guint)
-proc pixels_inside_wrap_set*(a: var TGtkTextTag): guint
-proc set_pixels_inside_wrap_set*(a: var TGtkTextTag,
-                                 `pixels_inside_wrap_set`: guint)
-proc tabs_set*(a: var TGtkTextTag): guint
-proc set_tabs_set*(a: var TGtkTextTag, `tabs_set`: guint)
-proc underline_set*(a: var TGtkTextTag): guint
-proc set_underline_set*(a: var TGtkTextTag, `underline_set`: guint)
-proc wrap_mode_set*(a: var TGtkTextTag): guint
-proc set_wrap_mode_set*(a: var TGtkTextTag, `wrap_mode_set`: guint)
-proc bg_full_height_set*(a: var TGtkTextTag): guint
-proc set_bg_full_height_set*(a: var TGtkTextTag, `bg_full_height_set`: guint)
-proc invisible_set*(a: var TGtkTextTag): guint
-proc set_invisible_set*(a: var TGtkTextTag, `invisible_set`: guint)
-proc editable_set*(a: var TGtkTextTag): guint
-proc set_editable_set*(a: var TGtkTextTag, `editable_set`: guint)
-proc language_set*(a: var TGtkTextTag): guint
-proc set_language_set*(a: var TGtkTextTag, `language_set`: guint)
-proc pad1*(a: var TGtkTextTag): guint
-proc set_pad1*(a: var TGtkTextTag, `pad1`: guint)
-proc pad2*(a: var TGtkTextTag): guint
-proc set_pad2*(a: var TGtkTextTag, `pad2`: guint)
-proc pad3*(a: var TGtkTextTag): guint
-proc set_pad3*(a: var TGtkTextTag, `pad3`: guint)
-const
-  bm_TGtkTextAppearance_underline* = 0x0000000F'i16
-  bp_TGtkTextAppearance_underline* = 0'i16
-  bm_TGtkTextAppearance_strikethrough* = 0x00000010'i16
-  bp_TGtkTextAppearance_strikethrough* = 4'i16
-  bm_TGtkTextAppearance_draw_bg* = 0x00000020'i16
-  bp_TGtkTextAppearance_draw_bg* = 5'i16
-  bm_TGtkTextAppearance_inside_selection* = 0x00000040'i16
-  bp_TGtkTextAppearance_inside_selection* = 6'i16
-  bm_TGtkTextAppearance_is_text* = 0x00000080'i16
-  bp_TGtkTextAppearance_is_text* = 7'i16
-  bm_TGtkTextAppearance_pad1* = 0x00000100'i16
-  bp_TGtkTextAppearance_pad1* = 8'i16
-  bm_TGtkTextAppearance_pad2* = 0x00000200'i16
-  bp_TGtkTextAppearance_pad2* = 9'i16
-  bm_TGtkTextAppearance_pad3* = 0x00000400'i16
-  bp_TGtkTextAppearance_pad3* = 10'i16
-  bm_TGtkTextAppearance_pad4* = 0x00000800'i16
-  bp_TGtkTextAppearance_pad4* = 11'i16
-
-proc underline*(a: var TGtkTextAppearance): guint
-proc set_underline*(a: var TGtkTextAppearance, `underline`: guint)
-proc strikethrough*(a: var TGtkTextAppearance): guint
-proc set_strikethrough*(a: var TGtkTextAppearance, `strikethrough`: guint)
-proc draw_bg*(a: var TGtkTextAppearance): guint
-proc set_draw_bg*(a: var TGtkTextAppearance, `draw_bg`: guint)
-proc inside_selection*(a: var TGtkTextAppearance): guint
-proc set_inside_selection*(a: var TGtkTextAppearance, `inside_selection`: guint)
-proc is_text*(a: var TGtkTextAppearance): guint
-proc set_is_text*(a: var TGtkTextAppearance, `is_text`: guint)
-proc pad1*(a: var TGtkTextAppearance): guint
-proc set_pad1*(a: var TGtkTextAppearance, `pad1`: guint)
-proc pad2*(a: var TGtkTextAppearance): guint
-proc set_pad2*(a: var TGtkTextAppearance, `pad2`: guint)
-proc pad3*(a: var TGtkTextAppearance): guint
-proc set_pad3*(a: var TGtkTextAppearance, `pad3`: guint)
-proc pad4*(a: var TGtkTextAppearance): guint
-proc set_pad4*(a: var TGtkTextAppearance, `pad4`: guint)
-const
-  bm_TGtkTextAttributes_invisible* = 0x00000001'i16
-  bp_TGtkTextAttributes_invisible* = 0'i16
-  bm_TGtkTextAttributes_bg_full_height* = 0x00000002'i16
-  bp_TGtkTextAttributes_bg_full_height* = 1'i16
-  bm_TGtkTextAttributes_editable* = 0x00000004'i16
-  bp_TGtkTextAttributes_editable* = 2'i16
-  bm_TGtkTextAttributes_realized* = 0x00000008'i16
-  bp_TGtkTextAttributes_realized* = 3'i16
-  bm_TGtkTextAttributes_pad1* = 0x00000010'i16
-  bp_TGtkTextAttributes_pad1* = 4'i16
-  bm_TGtkTextAttributes_pad2* = 0x00000020'i16
-  bp_TGtkTextAttributes_pad2* = 5'i16
-  bm_TGtkTextAttributes_pad3* = 0x00000040'i16
-  bp_TGtkTextAttributes_pad3* = 6'i16
-  bm_TGtkTextAttributes_pad4* = 0x00000080'i16
-  bp_TGtkTextAttributes_pad4* = 7'i16
-
-proc invisible*(a: var TGtkTextAttributes): guint
-proc set_invisible*(a: var TGtkTextAttributes, `invisible`: guint)
-proc bg_full_height*(a: var TGtkTextAttributes): guint
-proc set_bg_full_height*(a: var TGtkTextAttributes, `bg_full_height`: guint)
-proc editable*(a: var TGtkTextAttributes): guint
-proc set_editable*(a: var TGtkTextAttributes, `editable`: guint)
-proc realized*(a: var TGtkTextAttributes): guint
-proc set_realized*(a: var TGtkTextAttributes, `realized`: guint)
-proc pad1*(a: var TGtkTextAttributes): guint
-proc set_pad1*(a: var TGtkTextAttributes, `pad1`: guint)
-proc pad2*(a: var TGtkTextAttributes): guint
-proc set_pad2*(a: var TGtkTextAttributes, `pad2`: guint)
-proc pad3*(a: var TGtkTextAttributes): guint
-proc set_pad3*(a: var TGtkTextAttributes, `pad3`: guint)
-proc pad4*(a: var TGtkTextAttributes): guint
-proc set_pad4*(a: var TGtkTextAttributes, `pad4`: guint)
-proc GTK_TYPE_TEXT_TAG_TABLE*(): GType
-proc GTK_TEXT_TAG_TABLE*(obj: pointer): PGtkTextTagTable
-proc GTK_TEXT_TAG_TABLE_CLASS*(klass: pointer): PGtkTextTagTableClass
-proc GTK_IS_TEXT_TAG_TABLE*(obj: pointer): bool
-proc GTK_IS_TEXT_TAG_TABLE_CLASS*(klass: pointer): bool
-proc GTK_TEXT_TAG_TABLE_GET_CLASS*(obj: pointer): PGtkTextTagTableClass
-proc gtk_text_tag_table_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_tag_table_get_type".}
-proc gtk_text_tag_table_new*(): PGtkTextTagTable{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_tag_table_new".}
-proc gtk_text_tag_table_add*(table: PGtkTextTagTable, tag: PGtkTextTag){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_tag_table_add".}
-proc gtk_text_tag_table_remove*(table: PGtkTextTagTable, tag: PGtkTextTag){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_tag_table_remove".}
-proc gtk_text_tag_table_lookup*(table: PGtkTextTagTable, name: cstring): PGtkTextTag{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_tag_table_lookup".}
-proc gtk_text_tag_table_foreach*(table: PGtkTextTagTable,
-                                 fun: TGtkTextTagTableForeach, data: gpointer){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_tag_table_foreach".}
-proc gtk_text_tag_table_get_size*(table: PGtkTextTagTable): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_tag_table_get_size".}
-proc gtk_text_tag_table_add_buffer*(table: PGtkTextTagTable, buffer: gpointer){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_tag_table_add_buffer".}
-proc gtk_text_tag_table_remove_buffer*(table: PGtkTextTagTable,
-    buffer: gpointer){.cdecl, dynlib: gtklib,
-                       importc: "_gtk_text_tag_table_remove_buffer".}
-proc GTK_TYPE_TEXT_MARK*(): GType
-proc GTK_TEXT_MARK*(anObject: pointer): PGtkTextMark
-proc GTK_TEXT_MARK_CLASS*(klass: pointer): PGtkTextMarkClass
-proc GTK_IS_TEXT_MARK*(anObject: pointer): bool
-proc GTK_IS_TEXT_MARK_CLASS*(klass: pointer): bool
-proc GTK_TEXT_MARK_GET_CLASS*(obj: pointer): PGtkTextMarkClass
-proc gtk_text_mark_get_type*(): GType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_text_mark_get_type".}
-proc gtk_text_mark_set_visible*(mark: PGtkTextMark, setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_mark_set_visible".}
-proc gtk_text_mark_get_visible*(mark: PGtkTextMark): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_mark_get_visible".}
-proc gtk_text_mark_get_name*(mark: PGtkTextMark): cstring{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_mark_get_name".}
-proc gtk_text_mark_get_deleted*(mark: PGtkTextMark): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_mark_get_deleted".}
-proc gtk_text_mark_get_buffer*(mark: PGtkTextMark): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_mark_get_buffer".}
-proc gtk_text_mark_get_left_gravity*(mark: PGtkTextMark): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_mark_get_left_gravity".}
-const
-  bm_TGtkTextMarkBody_visible* = 0x00000001'i16
-  bp_TGtkTextMarkBody_visible* = 0'i16
-  bm_TGtkTextMarkBody_not_deleteable* = 0x00000002'i16
-  bp_TGtkTextMarkBody_not_deleteable* = 1'i16
-
-proc visible*(a: var TGtkTextMarkBody): guint
-proc set_visible*(a: var TGtkTextMarkBody, `visible`: guint)
-proc not_deleteable*(a: var TGtkTextMarkBody): guint
-proc set_not_deleteable*(a: var TGtkTextMarkBody, `not_deleteable`: guint)
-proc gtk_mark_segment_new*(tree: PGtkTextBTree, left_gravity: gboolean,
-                             name: cstring): PGtkTextLineSegment{.cdecl,
-    dynlib: gtklib, importc: "_gtk_mark_segment_new".}
-proc GTK_TYPE_TEXT_CHILD_ANCHOR*(): GType
-proc GTK_TEXT_CHILD_ANCHOR*(anObject: pointer): PGtkTextChildAnchor
-proc GTK_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): PGtkTextChildAnchorClass
-proc GTK_IS_TEXT_CHILD_ANCHOR*(anObject: pointer): bool
-proc GTK_IS_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): bool
-proc GTK_TEXT_CHILD_ANCHOR_GET_CLASS*(obj: pointer): PGtkTextChildAnchorClass
-proc gtk_text_child_anchor_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_child_anchor_get_type".}
-proc gtk_text_child_anchor_new*(): PGtkTextChildAnchor{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_child_anchor_new".}
-proc gtk_text_child_anchor_get_widgets*(anchor: PGtkTextChildAnchor): PGList{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_child_anchor_get_widgets".}
-proc gtk_text_child_anchor_get_deleted*(anchor: PGtkTextChildAnchor): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_child_anchor_get_deleted".}
-proc gtk_pixbuf_segment_new*(pixbuf: PGdkPixbuf): PGtkTextLineSegment{.cdecl,
-    dynlib: gtklib, importc: "_gtk_pixbuf_segment_new".}
-proc gtk_widget_segment_new*(anchor: PGtkTextChildAnchor): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "_gtk_widget_segment_new".}
-proc gtk_widget_segment_add*(widget_segment: PGtkTextLineSegment,
-                               child: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "_gtk_widget_segment_add".}
-proc gtk_widget_segment_remove*(widget_segment: PGtkTextLineSegment,
-                                  child: PGtkWidget){.cdecl, dynlib: gtklib,
-    importc: "_gtk_widget_segment_remove".}
-proc gtk_widget_segment_ref*(widget_segment: PGtkTextLineSegment){.cdecl,
-    dynlib: gtklib, importc: "_gtk_widget_segment_ref".}
-proc gtk_widget_segment_unref*(widget_segment: PGtkTextLineSegment){.cdecl,
-    dynlib: gtklib, importc: "_gtk_widget_segment_unref".}
-proc gtk_anchored_child_get_layout*(child: PGtkWidget): PGtkTextLayout{.cdecl,
-    dynlib: gtklib, importc: "_gtk_anchored_child_get_layout".}
-proc gtk_text_line_segment_split*(iter: PGtkTextIter): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_line_segment_split".}
-proc gtk_char_segment_new*(text: cstring, len: guint): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "_gtk_char_segment_new".}
-proc gtk_char_segment_new_from_two_strings*(text1: cstring, len1: guint,
-    text2: cstring, len2: guint): PGtkTextLineSegment{.cdecl, dynlib: gtklib,
-    importc: "_gtk_char_segment_new_from_two_strings".}
-proc gtk_toggle_segment_new*(info: PGtkTextTagInfo, StateOn: gboolean): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "_gtk_toggle_segment_new".}
-proc gtk_text_btree_new*(table: PGtkTextTagTable, buffer: PGtkTextBuffer): PGtkTextBTree{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_new".}
-proc gtk_text_btree_ref*(tree: PGtkTextBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_ref".}
-proc gtk_text_btree_unref*(tree: PGtkTextBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_unref".}
-proc gtk_text_btree_get_buffer*(tree: PGtkTextBTree): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_buffer".}
-proc gtk_text_btree_get_chars_changed_stamp*(tree: PGtkTextBTree): guint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_chars_changed_stamp".}
-proc gtk_text_btree_get_segments_changed_stamp*(tree: PGtkTextBTree): guint{.
-    cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_segments_changed_stamp".}
-proc gtk_text_btree_segments_changed*(tree: PGtkTextBTree){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_segments_changed".}
-proc gtk_text_btree_is_end*(tree: PGtkTextBTree, line: PGtkTextLine,
-                              seg: PGtkTextLineSegment, byte_index: int32,
-                              char_offset: int32): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_is_end".}
-proc gtk_text_btree_delete*(start: PGtkTextIter, theEnd: PGtkTextIter){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_delete".}
-proc gtk_text_btree_insert*(iter: PGtkTextIter, text: cstring, len: gint){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_insert".}
-proc gtk_text_btree_insert_pixbuf*(iter: PGtkTextIter, pixbuf: PGdkPixbuf){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_insert_pixbuf".}
-proc gtk_text_btree_insert_child_anchor*(iter: PGtkTextIter,
-    anchor: PGtkTextChildAnchor){.cdecl, dynlib: gtklib, importc: "_gtk_text_btree_insert_child_anchor".}
-proc gtk_text_btree_unregister_child_anchor*(anchor: PGtkTextChildAnchor){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_unregister_child_anchor".}
-proc gtk_text_btree_find_line_by_y*(tree: PGtkTextBTree, view_id: gpointer,
-                                      ypixel: gint, line_top_y: Pgint): PGtkTextLine{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_find_line_by_y".}
-proc gtk_text_btree_find_line_top*(tree: PGtkTextBTree, line: PGtkTextLine,
-                                     view_id: gpointer): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_find_line_top".}
-proc gtk_text_btree_add_view*(tree: PGtkTextBTree, layout: PGtkTextLayout){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_add_view".}
-proc gtk_text_btree_remove_view*(tree: PGtkTextBTree, view_id: gpointer){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_remove_view".}
-proc gtk_text_btree_invalidate_region*(tree: PGtkTextBTree,
-    start: PGtkTextIter, theEnd: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_invalidate_region".}
-proc gtk_text_btree_get_view_size*(tree: PGtkTextBTree, view_id: gpointer,
-                                     width: Pgint, height: Pgint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_view_size".}
-proc gtk_text_btree_is_valid*(tree: PGtkTextBTree, view_id: gpointer): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_is_valid".}
-proc gtk_text_btree_validate*(tree: PGtkTextBTree, view_id: gpointer,
-                                max_pixels: gint, y: Pgint, old_height: Pgint,
-                                new_height: Pgint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_validate".}
-proc gtk_text_btree_validate_line*(tree: PGtkTextBTree, line: PGtkTextLine,
-                                     view_id: gpointer){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_validate_line".}
-proc gtk_text_btree_tag*(start: PGtkTextIter, theEnd: PGtkTextIter,
-                           tag: PGtkTextTag, apply: gboolean){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_tag".}
-proc gtk_text_btree_get_line*(tree: PGtkTextBTree, line_number: gint,
-                                real_line_number: Pgint): PGtkTextLine{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_line".}
-proc gtk_text_btree_get_line_no_last*(tree: PGtkTextBTree, line_number: gint,
-                                        real_line_number: Pgint): PGtkTextLine{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_line_no_last".}
-proc gtk_text_btree_get_end_iter_line*(tree: PGtkTextBTree): PGtkTextLine{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_end_iter_line".}
-proc gtk_text_btree_get_line_at_char*(tree: PGtkTextBTree, char_index: gint,
-                                        line_start_index: Pgint,
-                                        real_char_index: Pgint): PGtkTextLine{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_line_at_char".}
-proc gtk_text_btree_get_tags*(iter: PGtkTextIter, num_tags: Pgint): PPGtkTextTag{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_tags".}
-proc gtk_text_btree_get_text*(start: PGtkTextIter, theEnd: PGtkTextIter,
-                                include_hidden: gboolean,
-                                include_nonchars: gboolean): cstring{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_text".}
-proc gtk_text_btree_line_count*(tree: PGtkTextBTree): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_line_count".}
-proc gtk_text_btree_char_count*(tree: PGtkTextBTree): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_char_count".}
-proc gtk_text_btree_char_is_invisible*(iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_char_is_invisible".}
-proc gtk_text_btree_get_iter_at_char*(tree: PGtkTextBTree, iter: PGtkTextIter,
-                                        char_index: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_iter_at_char".}
-proc gtk_text_btree_get_iter_at_line_char*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, line_number: gint, char_index: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_iter_at_line_char".}
-proc gtk_text_btree_get_iter_at_line_byte*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, line_number: gint, byte_index: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_iter_at_line_byte".}
-proc gtk_text_btree_get_iter_from_string*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, `string`: cstring): gboolean{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_iter_from_string".}
-proc gtk_text_btree_get_iter_at_mark_name*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, mark_name: cstring): gboolean{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_iter_at_mark_name".}
-proc gtk_text_btree_get_iter_at_mark*(tree: PGtkTextBTree, iter: PGtkTextIter,
-                                        mark: PGtkTextMark){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_get_iter_at_mark".}
-proc gtk_text_btree_get_end_iter*(tree: PGtkTextBTree, iter: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_end_iter".}
-proc gtk_text_btree_get_iter_at_line*(tree: PGtkTextBTree, iter: PGtkTextIter,
-                                        line: PGtkTextLine, byte_offset: gint){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_iter_at_line".}
-proc gtk_text_btree_get_iter_at_first_toggle*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_iter_at_first_toggle".}
-proc gtk_text_btree_get_iter_at_last_toggle*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, tag: PGtkTextTag): gboolean{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_iter_at_last_toggle".}
-proc gtk_text_btree_get_iter_at_child_anchor*(tree: PGtkTextBTree,
-    iter: PGtkTextIter, anchor: PGtkTextChildAnchor){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_iter_at_child_anchor".}
-proc gtk_text_btree_set_mark*(tree: PGtkTextBTree,
-                                existing_mark: PGtkTextMark, name: cstring,
-                                left_gravity: gboolean, index: PGtkTextIter,
-                                should_exist: gboolean): PGtkTextMark{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_btree_set_mark".}
-proc gtk_text_btree_remove_mark_by_name*(tree: PGtkTextBTree, name: cstring){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_remove_mark_by_name".}
-proc gtk_text_btree_remove_mark*(tree: PGtkTextBTree, segment: PGtkTextMark){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_remove_mark".}
-proc gtk_text_btree_get_selection_bounds*(tree: PGtkTextBTree,
-    start: PGtkTextIter, theEnd: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_get_selection_bounds".}
-proc gtk_text_btree_place_cursor*(tree: PGtkTextBTree, `where`: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_place_cursor".}
-proc gtk_text_btree_mark_is_insert*(tree: PGtkTextBTree, segment: PGtkTextMark): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_mark_is_insert".}
-proc gtk_text_btree_mark_is_selection_bound*(tree: PGtkTextBTree,
-    segment: PGtkTextMark): gboolean{.cdecl, dynlib: gtklib, importc: "_gtk_text_btree_mark_is_selection_bound".}
-proc gtk_text_btree_get_mark_by_name*(tree: PGtkTextBTree, name: cstring): PGtkTextMark{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_btree_get_mark_by_name".}
-proc gtk_text_btree_first_could_contain_tag*(tree: PGtkTextBTree,
-    tag: PGtkTextTag): PGtkTextLine{.cdecl, dynlib: gtklib, importc: "_gtk_text_btree_first_could_contain_tag".}
-proc gtk_text_btree_last_could_contain_tag*(tree: PGtkTextBTree,
-    tag: PGtkTextTag): PGtkTextLine{.cdecl, dynlib: gtklib, importc: "_gtk_text_btree_last_could_contain_tag".}
-const
-  bm_TGtkTextLineData_width* = 0x00FFFFFF'i32
-  bp_TGtkTextLineData_width* = 0'i32
-  bm_TGtkTextLineData_valid* = 0xFF000000'i32
-  bp_TGtkTextLineData_valid* = 24'i32
-
-proc width*(a: PGtkTextLineData): gint
-proc set_width*(a: PGtkTextLineData, NewWidth: gint)
-proc valid*(a: PGtkTextLineData): gint
-proc set_valid*(a: PGtkTextLineData, `valid`: gint)
-proc gtk_text_line_get_number*(line: PGtkTextLine): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_get_number".}
-proc gtk_text_line_char_has_tag*(line: PGtkTextLine, tree: PGtkTextBTree,
-                                   char_in_line: gint, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_char_has_tag".}
-proc gtk_text_line_byte_has_tag*(line: PGtkTextLine, tree: PGtkTextBTree,
-                                   byte_in_line: gint, tag: PGtkTextTag): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_byte_has_tag".}
-proc gtk_text_line_is_last*(line: PGtkTextLine, tree: PGtkTextBTree): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_is_last".}
-proc gtk_text_line_contains_end_iter*(line: PGtkTextLine, tree: PGtkTextBTree): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_contains_end_iter".}
-proc gtk_text_line_next*(line: PGtkTextLine): PGtkTextLine{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_next".}
-proc gtk_text_line_next_excluding_last*(line: PGtkTextLine): PGtkTextLine{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_next_excluding_last".}
-proc gtk_text_line_previous*(line: PGtkTextLine): PGtkTextLine{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_previous".}
-proc gtk_text_line_add_data*(line: PGtkTextLine, data: PGtkTextLineData){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_add_data".}
-proc gtk_text_line_remove_data*(line: PGtkTextLine, view_id: gpointer): gpointer{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_remove_data".}
-proc gtk_text_line_get_data*(line: PGtkTextLine, view_id: gpointer): gpointer{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_get_data".}
-proc gtk_text_line_invalidate_wrap*(line: PGtkTextLine, ld: PGtkTextLineData){.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_invalidate_wrap".}
-proc gtk_text_line_char_count*(line: PGtkTextLine): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_char_count".}
-proc gtk_text_line_byte_count*(line: PGtkTextLine): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_byte_count".}
-proc gtk_text_line_char_index*(line: PGtkTextLine): gint{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_char_index".}
-proc gtk_text_line_byte_to_segment*(line: PGtkTextLine, byte_offset: gint,
-                                      seg_offset: Pgint): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_byte_to_segment".}
-proc gtk_text_line_char_to_segment*(line: PGtkTextLine, char_offset: gint,
-                                      seg_offset: Pgint): PGtkTextLineSegment{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_char_to_segment".}
-proc gtk_text_line_byte_to_char_offsets*(line: PGtkTextLine,
-    byte_offset: gint, line_char_offset: Pgint, seg_char_offset: Pgint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_byte_to_char_offsets".}
-proc gtk_text_line_char_to_byte_offsets*(line: PGtkTextLine,
-    char_offset: gint, line_byte_offset: Pgint, seg_byte_offset: Pgint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_line_char_to_byte_offsets".}
-proc gtk_text_line_byte_to_any_segment*(line: PGtkTextLine, byte_offset: gint,
-    seg_offset: Pgint): PGtkTextLineSegment{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_line_byte_to_any_segment".}
-proc gtk_text_line_char_to_any_segment*(line: PGtkTextLine, char_offset: gint,
-    seg_offset: Pgint): PGtkTextLineSegment{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_line_char_to_any_segment".}
-proc gtk_text_line_byte_to_char*(line: PGtkTextLine, byte_offset: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_byte_to_char".}
-proc gtk_text_line_char_to_byte*(line: PGtkTextLine, char_offset: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_char_to_byte".}
-proc gtk_text_line_next_could_contain_tag*(line: PGtkTextLine,
-    tree: PGtkTextBTree, tag: PGtkTextTag): PGtkTextLine{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_line_next_could_contain_tag".}
-proc gtk_text_line_previous_could_contain_tag*(line: PGtkTextLine,
-    tree: PGtkTextBTree, tag: PGtkTextTag): PGtkTextLine{.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_line_previous_could_contain_tag".}
-proc gtk_text_line_data_new*(layout: PGtkTextLayout, line: PGtkTextLine): PGtkTextLineData{.
-    cdecl, dynlib: gtklib, importc: "_gtk_text_line_data_new".}
-proc gtk_text_btree_check*(tree: PGtkTextBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_check".}
-proc gtk_text_btree_spew*(tree: PGtkTextBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_btree_spew".}
-proc gtk_toggle_segment_check_func*(segPtr: PGtkTextLineSegment,
-                                      line: PGtkTextLine){.cdecl,
-    dynlib: gtklib, importc: "_gtk_toggle_segment_check_func".}
-proc gtk_change_node_toggle_count*(node: PGtkTextBTreeNode,
-                                     info: PGtkTextTagInfo, delta: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_change_node_toggle_count".}
-proc gtk_text_btree_release_mark_segment*(tree: PGtkTextBTree,
-    segment: PGtkTextLineSegment){.cdecl, dynlib: gtklib, importc: "_gtk_text_btree_release_mark_segment".}
-proc gtk_text_btree_notify_will_remove_tag*(tree: PGtkTextBTree,
-    tag: PGtkTextTag){.cdecl, dynlib: gtklib,
-                       importc: "_gtk_text_btree_notify_will_remove_tag".}
-const
-  bm_TGtkTextBuffer_modified* = 0x00000001'i16
-  bp_TGtkTextBuffer_modified* = 0'i16
-
-proc GTK_TYPE_TEXT_BUFFER*(): GType
-proc GTK_TEXT_BUFFER*(obj: pointer): PGtkTextBuffer
-proc GTK_TEXT_BUFFER_CLASS*(klass: pointer): PGtkTextBufferClass
-proc GTK_IS_TEXT_BUFFER*(obj: pointer): bool
-proc GTK_IS_TEXT_BUFFER_CLASS*(klass: pointer): bool
-proc GTK_TEXT_BUFFER_GET_CLASS*(obj: pointer): PGtkTextBufferClass
-proc modified*(a: var TGtkTextBuffer): guint
-proc set_modified*(a: var TGtkTextBuffer, `modified`: guint)
-proc gtk_text_buffer_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_get_type".}
-proc gtk_text_buffer_new*(table: PGtkTextTagTable): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_new".}
-proc gtk_text_buffer_get_line_count*(buffer: PGtkTextBuffer): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_line_count".}
-proc gtk_text_buffer_get_char_count*(buffer: PGtkTextBuffer): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_char_count".}
-proc gtk_text_buffer_get_tag_table*(buffer: PGtkTextBuffer): PGtkTextTagTable{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_tag_table".}
-proc gtk_text_buffer_set_text*(buffer: PGtkTextBuffer, text: cstring, len: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_set_text".}
-proc gtk_text_buffer_insert*(buffer: PGtkTextBuffer, iter: PGtkTextIter,
-                             text: cstring, len: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_insert".}
-proc gtk_text_buffer_insert_at_cursor*(buffer: PGtkTextBuffer, text: cstring,
-                                       len: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_insert_at_cursor".}
-proc gtk_text_buffer_insert_interactive*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, text: cstring, len: gint, default_editable: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_insert_interactive".}
-proc gtk_text_buffer_insert_interactive_at_cursor*(buffer: PGtkTextBuffer,
-    text: cstring, len: gint, default_editable: gboolean): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_insert_interactive_at_cursor".}
-proc gtk_text_buffer_insert_range*(buffer: PGtkTextBuffer, iter: PGtkTextIter,
-                                   start: PGtkTextIter, theEnd: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_insert_range".}
-proc gtk_text_buffer_insert_range_interactive*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, start: PGtkTextIter, theEnd: PGtkTextIter,
-    default_editable: gboolean): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_insert_range_interactive".}
-proc gtk_text_buffer_delete*(buffer: PGtkTextBuffer, start: PGtkTextIter,
-                             theEnd: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_delete".}
-proc gtk_text_buffer_delete_interactive*(buffer: PGtkTextBuffer,
-    start_iter: PGtkTextIter, end_iter: PGtkTextIter, default_editable: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_delete_interactive".}
-proc gtk_text_buffer_get_text*(buffer: PGtkTextBuffer, start: PGtkTextIter,
-                               theEnd: PGtkTextIter,
-                               include_hidden_chars: gboolean): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_text".}
-proc gtk_text_buffer_get_slice*(buffer: PGtkTextBuffer, start: PGtkTextIter,
-                                theEnd: PGtkTextIter,
-                                include_hidden_chars: gboolean): cstring{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_slice".}
-proc gtk_text_buffer_insert_pixbuf*(buffer: PGtkTextBuffer, iter: PGtkTextIter,
-                                    pixbuf: PGdkPixbuf){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_insert_pixbuf".}
-proc gtk_text_buffer_insert_child_anchor*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, anchor: PGtkTextChildAnchor){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_insert_child_anchor".}
-proc gtk_text_buffer_create_child_anchor*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter): PGtkTextChildAnchor{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_create_child_anchor".}
-proc gtk_text_buffer_create_mark*(buffer: PGtkTextBuffer, mark_name: cstring,
-                                  `where`: PGtkTextIter, left_gravity: gboolean): PGtkTextMark{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_create_mark".}
-proc gtk_text_buffer_move_mark*(buffer: PGtkTextBuffer, mark: PGtkTextMark,
-                                `where`: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_move_mark".}
-proc gtk_text_buffer_delete_mark*(buffer: PGtkTextBuffer, mark: PGtkTextMark){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_delete_mark".}
-proc gtk_text_buffer_get_mark*(buffer: PGtkTextBuffer, name: cstring): PGtkTextMark{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_mark".}
-proc gtk_text_buffer_move_mark_by_name*(buffer: PGtkTextBuffer, name: cstring,
-                                        `where`: PGtkTextIter){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_move_mark_by_name".}
-proc gtk_text_buffer_delete_mark_by_name*(buffer: PGtkTextBuffer, name: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_delete_mark_by_name".}
-proc gtk_text_buffer_get_insert*(buffer: PGtkTextBuffer): PGtkTextMark{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_insert".}
-proc gtk_text_buffer_get_selection_bound*(buffer: PGtkTextBuffer): PGtkTextMark{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_selection_bound".}
-proc gtk_text_buffer_place_cursor*(buffer: PGtkTextBuffer, `where`: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_place_cursor".}
-proc gtk_text_buffer_apply_tag*(buffer: PGtkTextBuffer, tag: PGtkTextTag,
-                                start: PGtkTextIter, theEnd: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_apply_tag".}
-proc gtk_text_buffer_remove_tag*(buffer: PGtkTextBuffer, tag: PGtkTextTag,
-                                 start: PGtkTextIter, theEnd: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_remove_tag".}
-proc gtk_text_buffer_apply_tag_by_name*(buffer: PGtkTextBuffer, name: cstring,
-                                        start: PGtkTextIter,
-                                        theEnd: PGtkTextIter){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_apply_tag_by_name".}
-proc gtk_text_buffer_remove_tag_by_name*(buffer: PGtkTextBuffer, name: cstring,
-    start: PGtkTextIter, theEnd: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_remove_tag_by_name".}
-proc gtk_text_buffer_remove_all_tags*(buffer: PGtkTextBuffer,
-                                      start: PGtkTextIter, theEnd: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_remove_all_tags".}
-proc gtk_text_buffer_get_iter_at_line_offset*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, line_number: gint, char_offset: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_iter_at_line_offset".}
-proc gtk_text_buffer_get_iter_at_line_index*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, line_number: gint, byte_index: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_iter_at_line_index".}
-proc gtk_text_buffer_get_iter_at_offset*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, char_offset: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_get_iter_at_offset".}
-proc gtk_text_buffer_get_iter_at_line*(buffer: PGtkTextBuffer,
-                                       iter: PGtkTextIter, line_number: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_iter_at_line".}
-proc gtk_text_buffer_get_start_iter*(buffer: PGtkTextBuffer, iter: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_start_iter".}
-proc gtk_text_buffer_get_end_iter*(buffer: PGtkTextBuffer, iter: PGtkTextIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_end_iter".}
-proc gtk_text_buffer_get_bounds*(buffer: PGtkTextBuffer, start: PGtkTextIter,
-                                 theEnd: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_get_bounds".}
-proc gtk_text_buffer_get_iter_at_mark*(buffer: PGtkTextBuffer,
-                                       iter: PGtkTextIter, mark: PGtkTextMark){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_get_iter_at_mark".}
-proc gtk_text_buffer_get_iter_at_child_anchor*(buffer: PGtkTextBuffer,
-    iter: PGtkTextIter, anchor: PGtkTextChildAnchor){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_get_iter_at_child_anchor".}
-proc gtk_text_buffer_get_modified*(buffer: PGtkTextBuffer): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_get_modified".}
-proc gtk_text_buffer_set_modified*(buffer: PGtkTextBuffer, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_set_modified".}
-proc gtk_text_buffer_add_selection_clipboard*(buffer: PGtkTextBuffer,
-    clipboard: PGtkClipboard){.cdecl, dynlib: gtklib, importc: "gtk_text_buffer_add_selection_clipboard".}
-proc gtk_text_buffer_remove_selection_clipboard*(buffer: PGtkTextBuffer,
-    clipboard: PGtkClipboard){.cdecl, dynlib: gtklib, importc: "gtk_text_buffer_remove_selection_clipboard".}
-proc gtk_text_buffer_cut_clipboard*(buffer: PGtkTextBuffer,
-                                    clipboard: PGtkClipboard,
-                                    default_editable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_cut_clipboard".}
-proc gtk_text_buffer_copy_clipboard*(buffer: PGtkTextBuffer,
-                                     clipboard: PGtkClipboard){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_copy_clipboard".}
-proc gtk_text_buffer_paste_clipboard*(buffer: PGtkTextBuffer,
-                                      clipboard: PGtkClipboard,
-                                      override_location: PGtkTextIter,
-                                      default_editable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_paste_clipboard".}
-proc gtk_text_buffer_get_selection_bounds*(buffer: PGtkTextBuffer,
-    start: PGtkTextIter, theEnd: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_buffer_get_selection_bounds".}
-proc gtk_text_buffer_delete_selection*(buffer: PGtkTextBuffer,
-                                       interactive: gboolean,
-                                       default_editable: gboolean): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_buffer_delete_selection".}
-proc gtk_text_buffer_begin_user_action*(buffer: PGtkTextBuffer){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_begin_user_action".}
-proc gtk_text_buffer_end_user_action*(buffer: PGtkTextBuffer){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_buffer_end_user_action".}
-proc gtk_text_buffer_spew*(buffer: PGtkTextBuffer){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_buffer_spew".}
-proc gtk_text_buffer_get_btree*(buffer: PGtkTextBuffer): PGtkTextBTree{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_buffer_get_btree".}
-proc gtk_text_buffer_get_line_log_attrs*(buffer: PGtkTextBuffer,
-    anywhere_in_line: PGtkTextIter, char_len: Pgint): PPangoLogAttr{.cdecl,
-    dynlib: gtklib, importc: "_gtk_text_buffer_get_line_log_attrs".}
-proc gtk_text_buffer_notify_will_remove_tag*(buffer: PGtkTextBuffer,
-    tag: PGtkTextTag){.cdecl, dynlib: gtklib,
-                       importc: "_gtk_text_buffer_notify_will_remove_tag".}
-proc GTK_TYPE_TEXT_LAYOUT*(): GType
-proc GTK_TEXT_LAYOUT*(obj: pointer): PGtkTextLayout
-proc GTK_TEXT_LAYOUT_CLASS*(klass: pointer): PGtkTextLayoutClass
-proc GTK_IS_TEXT_LAYOUT*(obj: pointer): bool
-proc GTK_IS_TEXT_LAYOUT_CLASS*(klass: pointer): bool
-proc GTK_TEXT_LAYOUT_GET_CLASS*(obj: pointer): PGtkTextLayoutClass
-const
-  bm_TGtkTextLayout_cursor_visible* = 0x00000001'i16
-  bp_TGtkTextLayout_cursor_visible* = 0'i16
-  bm_TGtkTextLayout_cursor_direction* = 0x00000006'i16
-  bp_TGtkTextLayout_cursor_direction* = 1'i16
-
-proc cursor_visible*(a: var TGtkTextLayout): guint
-proc set_cursor_visible*(a: var TGtkTextLayout, `cursor_visible`: guint)
-proc cursor_direction*(a: var TGtkTextLayout): gint
-proc set_cursor_direction*(a: var TGtkTextLayout, `cursor_direction`: gint)
-const
-  bm_TGtkTextCursorDisplay_is_strong* = 0x00000001'i16
-  bp_TGtkTextCursorDisplay_is_strong* = 0'i16
-  bm_TGtkTextCursorDisplay_is_weak* = 0x00000002'i16
-  bp_TGtkTextCursorDisplay_is_weak* = 1'i16
-
-proc is_strong*(a: var TGtkTextCursorDisplay): guint
-proc set_is_strong*(a: var TGtkTextCursorDisplay, `is_strong`: guint)
-proc is_weak*(a: var TGtkTextCursorDisplay): guint
-proc set_is_weak*(a: var TGtkTextCursorDisplay, `is_weak`: guint)
-proc gtk_text_layout_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_get_type".}
-proc gtk_text_layout_new*(): PGtkTextLayout{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_new".}
-proc gtk_text_layout_set_buffer*(layout: PGtkTextLayout, buffer: PGtkTextBuffer){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_set_buffer".}
-proc gtk_text_layout_get_buffer*(layout: PGtkTextLayout): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_get_buffer".}
-proc gtk_text_layout_set_default_style*(layout: PGtkTextLayout,
-                                        values: PGtkTextAttributes){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_set_default_style".}
-proc gtk_text_layout_set_contexts*(layout: PGtkTextLayout,
-                                   ltr_context: PPangoContext,
-                                   rtl_context: PPangoContext){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_set_contexts".}
-proc gtk_text_layout_set_cursor_direction*(layout: PGtkTextLayout,
-    direction: TGtkTextDirection){.cdecl, dynlib: gtklib, importc: "gtk_text_layout_set_cursor_direction".}
-proc gtk_text_layout_default_style_changed*(layout: PGtkTextLayout){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_default_style_changed".}
-proc gtk_text_layout_set_screen_width*(layout: PGtkTextLayout, width: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_set_screen_width".}
-proc gtk_text_layout_set_preedit_string*(layout: PGtkTextLayout,
-    preedit_string: cstring, preedit_attrs: PPangoAttrList, cursor_pos: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_set_preedit_string".}
-proc gtk_text_layout_set_cursor_visible*(layout: PGtkTextLayout,
-    cursor_visible: gboolean){.cdecl, dynlib: gtklib,
-                               importc: "gtk_text_layout_set_cursor_visible".}
-proc gtk_text_layout_get_cursor_visible*(layout: PGtkTextLayout): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_cursor_visible".}
-proc gtk_text_layout_get_size*(layout: PGtkTextLayout, width: Pgint,
-                               height: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_get_size".}
-proc gtk_text_layout_get_lines*(layout: PGtkTextLayout, top_y: gint,
-                                bottom_y: gint, first_line_y: Pgint): PGSList{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_lines".}
-proc gtk_text_layout_wrap_loop_start*(layout: PGtkTextLayout){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_wrap_loop_start".}
-proc gtk_text_layout_wrap_loop_end*(layout: PGtkTextLayout){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_wrap_loop_end".}
-proc gtk_text_layout_get_line_display*(layout: PGtkTextLayout,
-                                       line: PGtkTextLine, size_only: gboolean): PGtkTextLineDisplay{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_line_display".}
-proc gtk_text_layout_free_line_display*(layout: PGtkTextLayout,
-                                        display: PGtkTextLineDisplay){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_free_line_display".}
-proc gtk_text_layout_get_line_at_y*(layout: PGtkTextLayout,
-                                    target_iter: PGtkTextIter, y: gint,
-                                    line_top: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_get_line_at_y".}
-proc gtk_text_layout_get_iter_at_pixel*(layout: PGtkTextLayout,
-                                        iter: PGtkTextIter, x: gint, y: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_iter_at_pixel".}
-proc gtk_text_layout_invalidate*(layout: PGtkTextLayout, start: PGtkTextIter,
-                                 theEnd: PGtkTextIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_invalidate".}
-proc gtk_text_layout_free_line_data*(layout: PGtkTextLayout, line: PGtkTextLine,
-                                     line_data: PGtkTextLineData){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_free_line_data".}
-proc gtk_text_layout_is_valid*(layout: PGtkTextLayout): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_is_valid".}
-proc gtk_text_layout_validate_yrange*(layout: PGtkTextLayout,
-                                      anchor_line: PGtkTextIter, y0: gint,
-                                      y1: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_validate_yrange".}
-proc gtk_text_layout_validate*(layout: PGtkTextLayout, max_pixels: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_validate".}
-proc gtk_text_layout_wrap*(layout: PGtkTextLayout, line: PGtkTextLine,
-                           line_data: PGtkTextLineData): PGtkTextLineData{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_wrap".}
-proc gtk_text_layout_changed*(layout: PGtkTextLayout, y: gint, old_height: gint,
-                              new_height: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_changed".}
-proc gtk_text_layout_get_iter_location*(layout: PGtkTextLayout,
-                                        iter: PGtkTextIter, rect: PGdkRectangle){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_iter_location".}
-proc gtk_text_layout_get_line_yrange*(layout: PGtkTextLayout,
-                                      iter: PGtkTextIter, y: Pgint,
-                                      height: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_get_line_yrange".}
-proc gtk_text_layout_get_line_xrange*(layout: PGtkTextLayout,
-                                        iter: PGtkTextIter, x: Pgint,
-                                        width: Pgint){.cdecl, dynlib: gtklib,
-    importc: "_gtk_text_layout_get_line_xrange".}
-proc gtk_text_layout_get_cursor_locations*(layout: PGtkTextLayout,
-    iter: PGtkTextIter, strong_pos: PGdkRectangle, weak_pos: PGdkRectangle){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_layout_get_cursor_locations".}
-proc gtk_text_layout_clamp_iter_to_vrange*(layout: PGtkTextLayout,
-    iter: PGtkTextIter, top: gint, bottom: gint): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_clamp_iter_to_vrange".}
-proc gtk_text_layout_move_iter_to_line_end*(layout: PGtkTextLayout,
-    iter: PGtkTextIter, direction: gint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_move_iter_to_line_end".}
-proc gtk_text_layout_move_iter_to_previous_line*(layout: PGtkTextLayout,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_layout_move_iter_to_previous_line".}
-proc gtk_text_layout_move_iter_to_next_line*(layout: PGtkTextLayout,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_layout_move_iter_to_next_line".}
-proc gtk_text_layout_move_iter_to_x*(layout: PGtkTextLayout, iter: PGtkTextIter,
-                                     x: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_move_iter_to_x".}
-proc gtk_text_layout_move_iter_visually*(layout: PGtkTextLayout,
-    iter: PGtkTextIter, count: gint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_move_iter_visually".}
-proc gtk_text_layout_iter_starts_line*(layout: PGtkTextLayout,
-                                       iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_iter_starts_line".}
-proc gtk_text_layout_get_iter_at_line*(layout: PGtkTextLayout,
-                                       iter: PGtkTextIter, line: PGtkTextLine,
-                                       byte_offset: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_layout_get_iter_at_line".}
-proc gtk_text_child_anchor_register_child*(anchor: PGtkTextChildAnchor,
-    child: PGtkWidget, layout: PGtkTextLayout){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_child_anchor_register_child".}
-proc gtk_text_child_anchor_unregister_child*(anchor: PGtkTextChildAnchor,
-    child: PGtkWidget){.cdecl, dynlib: gtklib,
-                        importc: "gtk_text_child_anchor_unregister_child".}
-proc gtk_text_child_anchor_queue_resize*(anchor: PGtkTextChildAnchor,
-    layout: PGtkTextLayout){.cdecl, dynlib: gtklib,
-                             importc: "gtk_text_child_anchor_queue_resize".}
-proc gtk_text_anchored_child_set_layout*(child: PGtkWidget,
-    layout: PGtkTextLayout){.cdecl, dynlib: gtklib,
-                             importc: "gtk_text_anchored_child_set_layout".}
-proc gtk_text_layout_spew*(layout: PGtkTextLayout){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_layout_spew".}
-const # GTK_TEXT_VIEW_PRIORITY_VALIDATE* = GDK_PRIORITY_REDRAW + 5
-  bm_TGtkTextView_editable* = 0x00000001'i16
-  bp_TGtkTextView_editable* = 0'i16
-  bm_TGtkTextView_overwrite_mode* = 0x00000002'i16
-  bp_TGtkTextView_overwrite_mode* = 1'i16
-  bm_TGtkTextView_cursor_visible* = 0x00000004'i16
-  bp_TGtkTextView_cursor_visible* = 2'i16
-  bm_TGtkTextView_need_im_reset* = 0x00000008'i16
-  bp_TGtkTextView_need_im_reset* = 3'i16
-  bm_TGtkTextView_just_selected_element* = 0x00000010'i16
-  bp_TGtkTextView_just_selected_element* = 4'i16
-  bm_TGtkTextView_disable_scroll_on_focus* = 0x00000020'i16
-  bp_TGtkTextView_disable_scroll_on_focus* = 5'i16
-  bm_TGtkTextView_onscreen_validated* = 0x00000040'i16
-  bp_TGtkTextView_onscreen_validated* = 6'i16
-  bm_TGtkTextView_mouse_cursor_obscured* = 0x00000080'i16
-  bp_TGtkTextView_mouse_cursor_obscured* = 7'i16
-
-proc GTK_TYPE_TEXT_VIEW*(): GType
-proc GTK_TEXT_VIEW*(obj: pointer): PGtkTextView
-proc GTK_TEXT_VIEW_CLASS*(klass: pointer): PGtkTextViewClass
-proc GTK_IS_TEXT_VIEW*(obj: pointer): bool
-proc GTK_IS_TEXT_VIEW_CLASS*(klass: pointer): bool
-proc GTK_TEXT_VIEW_GET_CLASS*(obj: pointer): PGtkTextViewClass
-proc editable*(a: var TGtkTextView): guint
-proc set_editable*(a: var TGtkTextView, `editable`: guint)
-proc overwrite_mode*(a: var TGtkTextView): guint
-proc set_overwrite_mode*(a: var TGtkTextView, `overwrite_mode`: guint)
-proc cursor_visible*(a: var TGtkTextView): guint
-proc set_cursor_visible*(a: var TGtkTextView, `cursor_visible`: guint)
-proc need_im_reset*(a: var TGtkTextView): guint
-proc set_need_im_reset*(a: var TGtkTextView, `need_im_reset`: guint)
-proc just_selected_element*(a: var TGtkTextView): guint
-proc set_just_selected_element*(a: var TGtkTextView,
-                                `just_selected_element`: guint)
-proc disable_scroll_on_focus*(a: var TGtkTextView): guint
-proc set_disable_scroll_on_focus*(a: var TGtkTextView,
-                                  `disable_scroll_on_focus`: guint)
-proc onscreen_validated*(a: var TGtkTextView): guint
-proc set_onscreen_validated*(a: var TGtkTextView, `onscreen_validated`: guint)
-proc mouse_cursor_obscured*(a: var TGtkTextView): guint
-proc set_mouse_cursor_obscured*(a: var TGtkTextView,
-                                `mouse_cursor_obscured`: guint)
-proc gtk_text_view_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_get_type".}
-proc gtk_text_view_new*(): PGtkTextView{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_text_view_new".}
-proc gtk_text_view_new_with_buffer*(buffer: PGtkTextBuffer): PGtkTextView{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_new_with_buffer".}
-proc gtk_text_view_set_buffer*(text_view: PGtkTextView, buffer: PGtkTextBuffer){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_set_buffer".}
-proc gtk_text_view_get_buffer*(text_view: PGtkTextView): PGtkTextBuffer{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_buffer".}
-proc gtk_text_view_scroll_to_iter*(text_view: PGtkTextView, iter: PGtkTextIter,
-                                   within_margin: gdouble, use_align: gboolean,
-                                   xalign: gdouble, yalign: gdouble): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_scroll_to_iter".}
-proc gtk_text_view_scroll_to_mark*(text_view: PGtkTextView, mark: PGtkTextMark,
-                                   within_margin: gdouble, use_align: gboolean,
-                                   xalign: gdouble, yalign: gdouble){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_scroll_to_mark".}
-proc gtk_text_view_scroll_mark_onscreen*(text_view: PGtkTextView,
-    mark: PGtkTextMark){.cdecl, dynlib: gtklib,
-                         importc: "gtk_text_view_scroll_mark_onscreen".}
-proc gtk_text_view_move_mark_onscreen*(text_view: PGtkTextView,
-                                       mark: PGtkTextMark): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_move_mark_onscreen".}
-proc gtk_text_view_place_cursor_onscreen*(text_view: PGtkTextView): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_place_cursor_onscreen".}
-proc gtk_text_view_get_visible_rect*(text_view: PGtkTextView,
-                                     visible_rect: PGdkRectangle){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_visible_rect".}
-proc gtk_text_view_set_cursor_visible*(text_view: PGtkTextView,
-                                       setting: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_set_cursor_visible".}
-proc gtk_text_view_get_cursor_visible*(text_view: PGtkTextView): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_cursor_visible".}
-proc gtk_text_view_get_iter_location*(text_view: PGtkTextView,
-                                      iter: PGtkTextIter,
-                                      location: PGdkRectangle){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_iter_location".}
-proc gtk_text_view_get_iter_at_location*(text_view: PGtkTextView,
-    iter: PGtkTextIter, x: gint, y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_get_iter_at_location".}
-proc gtk_text_view_get_line_yrange*(text_view: PGtkTextView, iter: PGtkTextIter,
-                                    y: Pgint, height: Pgint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_line_yrange".}
-proc gtk_text_view_get_line_at_y*(text_view: PGtkTextView,
-                                  target_iter: PGtkTextIter, y: gint,
-                                  line_top: Pgint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_get_line_at_y".}
-proc gtk_text_view_buffer_to_window_coords*(text_view: PGtkTextView,
-    win: TGtkTextWindowType, buffer_x: gint, buffer_y: gint, window_x: Pgint,
-    window_y: Pgint){.cdecl, dynlib: gtklib,
-                      importc: "gtk_text_view_buffer_to_window_coords".}
-proc gtk_text_view_window_to_buffer_coords*(text_view: PGtkTextView,
-    win: TGtkTextWindowType, window_x: gint, window_y: gint, buffer_x: Pgint,
-    buffer_y: Pgint){.cdecl, dynlib: gtklib,
-                      importc: "gtk_text_view_window_to_buffer_coords".}
-proc gtk_text_view_get_window*(text_view: PGtkTextView, win: TGtkTextWindowType): PGdkWindow{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_window".}
-proc gtk_text_view_get_window_type*(text_view: PGtkTextView, window: PGdkWindow): TGtkTextWindowType{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_window_type".}
-proc gtk_text_view_set_border_window_size*(text_view: PGtkTextView,
-    thetype: TGtkTextWindowType, size: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_set_border_window_size".}
-proc gtk_text_view_get_border_window_size*(text_view: PGtkTextView,
-    thetype: TGtkTextWindowType): gint{.cdecl, dynlib: gtklib, importc: "gtk_text_view_get_border_window_size".}
-proc gtk_text_view_forward_display_line*(text_view: PGtkTextView,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_view_forward_display_line".}
-proc gtk_text_view_backward_display_line*(text_view: PGtkTextView,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_view_backward_display_line".}
-proc gtk_text_view_forward_display_line_end*(text_view: PGtkTextView,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_view_forward_display_line_end".}
-proc gtk_text_view_backward_display_line_start*(text_view: PGtkTextView,
-    iter: PGtkTextIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_text_view_backward_display_line_start".}
-proc gtk_text_view_starts_display_line*(text_view: PGtkTextView,
-                                        iter: PGtkTextIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_starts_display_line".}
-proc gtk_text_view_move_visually*(text_view: PGtkTextView, iter: PGtkTextIter,
-                                  count: gint): gboolean{.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_move_visually".}
-proc gtk_text_view_add_child_at_anchor*(text_view: PGtkTextView,
-                                        child: PGtkWidget,
-                                        anchor: PGtkTextChildAnchor){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_add_child_at_anchor".}
-proc gtk_text_view_add_child_in_window*(text_view: PGtkTextView,
-                                        child: PGtkWidget,
-                                        which_window: TGtkTextWindowType,
-                                        xpos: gint, ypos: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_add_child_in_window".}
-proc gtk_text_view_move_child*(text_view: PGtkTextView, child: PGtkWidget,
-                               xpos: gint, ypos: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_text_view_move_child".}
-proc gtk_text_view_set_wrap_mode*(text_view: PGtkTextView,
-                                  wrap_mode: TGtkWrapMode){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_set_wrap_mode".}
-proc gtk_text_view_get_wrap_mode*(text_view: PGtkTextView): TGtkWrapMode{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_wrap_mode".}
-proc gtk_text_view_set_editable*(text_view: PGtkTextView, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_set_editable".}
-proc gtk_text_view_get_editable*(text_view: PGtkTextView): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_editable".}
-proc gtk_text_view_set_pixels_above_lines*(text_view: PGtkTextView,
-    pixels_above_lines: gint){.cdecl, dynlib: gtklib,
-                               importc: "gtk_text_view_set_pixels_above_lines".}
-proc gtk_text_view_get_pixels_above_lines*(text_view: PGtkTextView): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_pixels_above_lines".}
-proc gtk_text_view_set_pixels_below_lines*(text_view: PGtkTextView,
-    pixels_below_lines: gint){.cdecl, dynlib: gtklib,
-                               importc: "gtk_text_view_set_pixels_below_lines".}
-proc gtk_text_view_get_pixels_below_lines*(text_view: PGtkTextView): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_pixels_below_lines".}
-proc gtk_text_view_set_pixels_inside_wrap*(text_view: PGtkTextView,
-    pixels_inside_wrap: gint){.cdecl, dynlib: gtklib,
-                               importc: "gtk_text_view_set_pixels_inside_wrap".}
-proc gtk_text_view_get_pixels_inside_wrap*(text_view: PGtkTextView): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_pixels_inside_wrap".}
-proc gtk_text_view_set_justification*(text_view: PGtkTextView,
-                                      justification: TGtkJustification){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_set_justification".}
-proc gtk_text_view_get_justification*(text_view: PGtkTextView): TGtkJustification{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_justification".}
-proc gtk_text_view_set_left_margin*(text_view: PGtkTextView, left_margin: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_set_left_margin".}
-proc gtk_text_view_get_left_margin*(text_view: PGtkTextView): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_left_margin".}
-proc gtk_text_view_set_right_margin*(text_view: PGtkTextView, right_margin: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_set_right_margin".}
-proc gtk_text_view_get_right_margin*(text_view: PGtkTextView): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_right_margin".}
-proc gtk_text_view_set_indent*(text_view: PGtkTextView, indent: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_set_indent".}
-proc gtk_text_view_get_indent*(text_view: PGtkTextView): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_indent".}
-proc gtk_text_view_set_tabs*(text_view: PGtkTextView, tabs: PPangoTabArray){.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_set_tabs".}
-proc gtk_text_view_get_tabs*(text_view: PGtkTextView): PPangoTabArray{.cdecl,
-    dynlib: gtklib, importc: "gtk_text_view_get_tabs".}
-proc gtk_text_view_get_default_attributes*(text_view: PGtkTextView): PGtkTextAttributes{.
-    cdecl, dynlib: gtklib, importc: "gtk_text_view_get_default_attributes".}
-const
-  bm_TGtkTipsQuery_emit_always* = 0x00000001'i16
-  bp_TGtkTipsQuery_emit_always* = 0'i16
-  bm_TGtkTipsQuery_in_query* = 0x00000002'i16
-  bp_TGtkTipsQuery_in_query* = 1'i16
-
-proc GTK_TYPE_TIPS_QUERY*(): GType
-proc GTK_TIPS_QUERY*(obj: pointer): PGtkTipsQuery
-proc GTK_TIPS_QUERY_CLASS*(klass: pointer): PGtkTipsQueryClass
-proc GTK_IS_TIPS_QUERY*(obj: pointer): bool
-proc GTK_IS_TIPS_QUERY_CLASS*(klass: pointer): bool
-proc GTK_TIPS_QUERY_GET_CLASS*(obj: pointer): PGtkTipsQueryClass
-proc emit_always*(a: var TGtkTipsQuery): guint
-proc set_emit_always*(a: var TGtkTipsQuery, `emit_always`: guint)
-proc in_query*(a: var TGtkTipsQuery): guint
-proc set_in_query*(a: var TGtkTipsQuery, `in_query`: guint)
-proc gtk_tips_query_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tips_query_get_type".}
-proc gtk_tips_query_new*(): PGtkTipsQuery{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_tips_query_new".}
-proc gtk_tips_query_start_query*(tips_query: PGtkTipsQuery){.cdecl,
-    dynlib: gtklib, importc: "gtk_tips_query_start_query".}
-proc gtk_tips_query_stop_query*(tips_query: PGtkTipsQuery){.cdecl,
-    dynlib: gtklib, importc: "gtk_tips_query_stop_query".}
-proc gtk_tips_query_set_caller*(tips_query: PGtkTipsQuery, caller: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_tips_query_set_caller".}
-proc gtk_tips_query_set_labels*(tips_query: PGtkTipsQuery,
-                                label_inactive: cstring, label_no_tip: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_tips_query_set_labels".}
-const
-  bm_TGtkTooltips_delay* = 0x3FFFFFFF'i32
-  bp_TGtkTooltips_delay* = 0'i32
-  bm_TGtkTooltips_enabled* = 0x40000000'i32
-  bp_TGtkTooltips_enabled* = 30'i32
-  bm_TGtkTooltips_have_grab* = 0x80000000'i32
-  bp_TGtkTooltips_have_grab* = 31'i32
-  bm_TGtkTooltips_use_sticky_delay* = 0x00000001'i32
-  bp_TGtkTooltips_use_sticky_delay* = 0'i32
-
-proc GTK_TYPE_TOOLTIPS*(): GType
-proc GTK_TOOLTIPS*(obj: pointer): PGtkTooltips
-proc GTK_TOOLTIPS_CLASS*(klass: pointer): PGtkTooltipsClass
-proc GTK_IS_TOOLTIPS*(obj: pointer): bool
-proc GTK_IS_TOOLTIPS_CLASS*(klass: pointer): bool
-proc GTK_TOOLTIPS_GET_CLASS*(obj: pointer): PGtkTooltipsClass
-proc delay*(a: var TGtkTooltips): guint
-proc set_delay*(a: var TGtkTooltips, `delay`: guint)
-proc enabled*(a: var TGtkTooltips): guint
-proc set_enabled*(a: var TGtkTooltips, `enabled`: guint)
-proc have_grab*(a: var TGtkTooltips): guint
-proc set_have_grab*(a: var TGtkTooltips, `have_grab`: guint)
-proc use_sticky_delay*(a: var TGtkTooltips): guint
-proc set_use_sticky_delay*(a: var TGtkTooltips, `use_sticky_delay`: guint)
-proc gtk_tooltips_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tooltips_get_type".}
-proc gtk_tooltips_new*(): PGtkTooltips{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_tooltips_new".}
-proc gtk_tooltips_enable*(tooltips: PGtkTooltips){.cdecl, dynlib: gtklib,
-    importc: "gtk_tooltips_enable".}
-proc gtk_tooltips_disable*(tooltips: PGtkTooltips){.cdecl, dynlib: gtklib,
-    importc: "gtk_tooltips_disable".}
-proc gtk_tooltips_set_tip*(tooltips: PGtkTooltips, widget: PGtkWidget,
-                           tip_text: cstring, tip_private: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_tooltips_set_tip".}
-proc gtk_tooltips_data_get*(widget: PGtkWidget): PGtkTooltipsData{.cdecl,
-    dynlib: gtklib, importc: "gtk_tooltips_data_get".}
-proc gtk_tooltips_force_window*(tooltips: PGtkTooltips){.cdecl, dynlib: gtklib,
-    importc: "gtk_tooltips_force_window".}
-proc gtk_tooltips_toggle_keyboard_mode*(widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tooltips_toggle_keyboard_mode".}
-const
-  bm_TGtkToolbar_style_set* = 0x00000001'i16
-  bp_TGtkToolbar_style_set* = 0'i16
-  bm_TGtkToolbar_icon_size_set* = 0x00000002'i16
-  bp_TGtkToolbar_icon_size_set* = 1'i16
-
-proc GTK_TYPE_TOOLBAR*(): GType
-proc GTK_TOOLBAR*(obj: pointer): PGtkToolbar
-proc GTK_TOOLBAR_CLASS*(klass: pointer): PGtkToolbarClass
-proc GTK_IS_TOOLBAR*(obj: pointer): bool
-proc GTK_IS_TOOLBAR_CLASS*(klass: pointer): bool
-proc GTK_TOOLBAR_GET_CLASS*(obj: pointer): PGtkToolbarClass
-proc style_set*(a: var TGtkToolbar): guint
-proc set_style_set*(a: var TGtkToolbar, `style_set`: guint)
-proc icon_size_set*(a: var TGtkToolbar): guint
-proc set_icon_size_set*(a: var TGtkToolbar, `icon_size_set`: guint)
-proc gtk_toolbar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_toolbar_get_type".}
-proc gtk_toolbar_new*(): PGtkToolbar{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_toolbar_new".}
-proc gtk_toolbar_append_item*(toolbar: PGtkToolbar, text: cstring,
-                              tooltip_text: cstring,
-                              tooltip_private_text: cstring, icon: PGtkWidget,
-                              callback: TGtkSignalFunc, user_data: gpointer): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_append_item".}
-proc gtk_toolbar_prepend_item*(toolbar: PGtkToolbar, text: cstring,
-                               tooltip_text: cstring,
-                               tooltip_private_text: cstring, icon: PGtkWidget,
-                               callback: TGtkSignalFunc, user_data: gpointer): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_prepend_item".}
-proc gtk_toolbar_insert_item*(toolbar: PGtkToolbar, text: cstring,
-                              tooltip_text: cstring,
-                              tooltip_private_text: cstring, icon: PGtkWidget,
-                              callback: TGtkSignalFunc, user_data: gpointer,
-                              position: gint): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_insert_item".}
-proc gtk_toolbar_insert_stock*(toolbar: PGtkToolbar, stock_id: cstring,
-                               tooltip_text: cstring,
-                               tooltip_private_text: cstring,
-                               callback: TGtkSignalFunc, user_data: gpointer,
-                               position: gint): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_insert_stock".}
-proc gtk_toolbar_append_space*(toolbar: PGtkToolbar){.cdecl, dynlib: gtklib,
-    importc: "gtk_toolbar_append_space".}
-proc gtk_toolbar_prepend_space*(toolbar: PGtkToolbar){.cdecl, dynlib: gtklib,
-    importc: "gtk_toolbar_prepend_space".}
-proc gtk_toolbar_insert_space*(toolbar: PGtkToolbar, position: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_insert_space".}
-proc gtk_toolbar_remove_space*(toolbar: PGtkToolbar, position: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_remove_space".}
-proc gtk_toolbar_append_element*(toolbar: PGtkToolbar,
-                                 thetype: TGtkToolbarChildType,
-                                 widget: PGtkWidget, text: cstring,
-                                 tooltip_text: cstring,
-                                 tooltip_private_text: cstring,
-                                 icon: PGtkWidget, callback: TGtkSignalFunc,
-                                 user_data: gpointer): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_append_element".}
-proc gtk_toolbar_prepend_element*(toolbar: PGtkToolbar,
-                                  thetype: TGtkToolbarChildType,
-                                  widget: PGtkWidget, text: cstring,
-                                  tooltip_text: cstring,
-                                  tooltip_private_text: cstring,
-                                  icon: PGtkWidget, callback: TGtkSignalFunc,
-                                  user_data: gpointer): PGtkWidget{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_prepend_element".}
-proc gtk_toolbar_insert_element*(toolbar: PGtkToolbar,
-                                 thetype: TGtkToolbarChildType,
-                                 widget: PGtkWidget, text: cstring,
-                                 tooltip_text: cstring,
-                                 tooltip_private_text: cstring,
-                                 icon: PGtkWidget, callback: TGtkSignalFunc,
-                                 user_data: gpointer, position: gint): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_insert_element".}
-proc gtk_toolbar_append_widget*(toolbar: PGtkToolbar, widget: PGtkWidget,
-                                tooltip_text: cstring,
-                                tooltip_private_text: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_append_widget".}
-proc gtk_toolbar_prepend_widget*(toolbar: PGtkToolbar, widget: PGtkWidget,
-                                 tooltip_text: cstring,
-                                 tooltip_private_text: cstring){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_prepend_widget".}
-proc gtk_toolbar_insert_widget*(toolbar: PGtkToolbar, widget: PGtkWidget,
-                                tooltip_text: cstring,
-                                tooltip_private_text: cstring, position: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_insert_widget".}
-proc gtk_toolbar_set_orientation*(toolbar: PGtkToolbar,
-                                  orientation: TGtkOrientation){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_set_orientation".}
-proc gtk_toolbar_set_style*(toolbar: PGtkToolbar, style: TGtkToolbarStyle){.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_set_style".}
-proc gtk_toolbar_set_icon_size*(toolbar: PGtkToolbar, icon_size: TGtkIconSize){.
-    cdecl, dynlib: gtklib, importc: "gtk_toolbar_set_icon_size".}
-proc gtk_toolbar_set_tooltips*(toolbar: PGtkToolbar, enable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_set_tooltips".}
-proc gtk_toolbar_unset_style*(toolbar: PGtkToolbar){.cdecl, dynlib: gtklib,
-    importc: "gtk_toolbar_unset_style".}
-proc gtk_toolbar_unset_icon_size*(toolbar: PGtkToolbar){.cdecl, dynlib: gtklib,
-    importc: "gtk_toolbar_unset_icon_size".}
-proc gtk_toolbar_get_orientation*(toolbar: PGtkToolbar): TGtkOrientation{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_get_orientation".}
-proc gtk_toolbar_get_style*(toolbar: PGtkToolbar): TGtkToolbarStyle{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_get_style".}
-proc gtk_toolbar_get_icon_size*(toolbar: PGtkToolbar): TGtkIconSize{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_get_icon_size".}
-proc gtk_toolbar_get_tooltips*(toolbar: PGtkToolbar): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_toolbar_get_tooltips".}
-const
-  bm_TGtkTree_selection_mode* = 0x00000003'i16
-  bp_TGtkTree_selection_mode* = 0'i16
-  bm_TGtkTree_view_mode* = 0x00000004'i16
-  bp_TGtkTree_view_mode* = 2'i16
-  bm_TGtkTree_view_line* = 0x00000008'i16
-  bp_TGtkTree_view_line* = 3'i16
-
-proc GTK_TYPE_TREE*(): GType
-proc GTK_TREE*(obj: pointer): PGtkTree
-proc GTK_TREE_CLASS*(klass: pointer): PGtkTreeClass
-proc GTK_IS_TREE*(obj: pointer): bool
-proc GTK_IS_TREE_CLASS*(klass: pointer): bool
-proc GTK_TREE_GET_CLASS*(obj: pointer): PGtkTreeClass
-proc GTK_IS_ROOT_TREE*(obj: pointer): bool
-proc GTK_TREE_ROOT_TREE*(obj: pointer): PGtkTree
-proc GTK_TREE_SELECTION_OLD*(obj: pointer): PGList
-proc selection_mode*(a: var TGtkTree): guint
-proc set_selection_mode*(a: var TGtkTree, `selection_mode`: guint)
-proc view_mode*(a: var TGtkTree): guint
-proc set_view_mode*(a: var TGtkTree, `view_mode`: guint)
-proc view_line*(a: var TGtkTree): guint
-proc set_view_line*(a: var TGtkTree, `view_line`: guint)
-proc gtk_tree_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                     importc: "gtk_tree_get_type".}
-proc gtk_tree_new*(): PGtkTree{.cdecl, dynlib: gtklib, importc: "gtk_tree_new".}
-proc gtk_tree_append*(tree: PGtkTree, tree_item: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_append".}
-proc gtk_tree_prepend*(tree: PGtkTree, tree_item: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_prepend".}
-proc gtk_tree_insert*(tree: PGtkTree, tree_item: PGtkWidget, position: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_insert".}
-proc gtk_tree_remove_items*(tree: PGtkTree, items: PGList){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_remove_items".}
-proc gtk_tree_clear_items*(tree: PGtkTree, start: gint, theEnd: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_clear_items".}
-proc gtk_tree_select_item*(tree: PGtkTree, item: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_select_item".}
-proc gtk_tree_unselect_item*(tree: PGtkTree, item: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_unselect_item".}
-proc gtk_tree_select_child*(tree: PGtkTree, tree_item: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_select_child".}
-proc gtk_tree_unselect_child*(tree: PGtkTree, tree_item: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_unselect_child".}
-proc gtk_tree_child_position*(tree: PGtkTree, child: PGtkWidget): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_child_position".}
-proc gtk_tree_set_selection_mode*(tree: PGtkTree, mode: TGtkSelectionMode){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_set_selection_mode".}
-proc gtk_tree_set_view_mode*(tree: PGtkTree, mode: TGtkTreeViewMode){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_set_view_mode".}
-proc gtk_tree_set_view_lines*(tree: PGtkTree, flag: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_set_view_lines".}
-proc gtk_tree_remove_item*(tree: PGtkTree, child: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_remove_item".}
-proc GTK_TYPE_TREE_DRAG_SOURCE*(): GType
-proc GTK_TREE_DRAG_SOURCE*(obj: pointer): PGtkTreeDragSource
-proc GTK_IS_TREE_DRAG_SOURCE*(obj: pointer): bool
-proc GTK_TREE_DRAG_SOURCE_GET_IFACE*(obj: pointer): PGtkTreeDragSourceIface
-proc gtk_tree_drag_source_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_drag_source_get_type".}
-proc gtk_tree_drag_source_row_draggable*(drag_source: PGtkTreeDragSource,
-    path: PGtkTreePath): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_tree_drag_source_row_draggable".}
-proc gtk_tree_drag_source_drag_data_delete*(drag_source: PGtkTreeDragSource,
-    path: PGtkTreePath): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_tree_drag_source_drag_data_delete".}
-proc gtk_tree_drag_source_drag_data_get*(drag_source: PGtkTreeDragSource,
-    path: PGtkTreePath, selection_data: PGtkSelectionData): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_drag_source_drag_data_get".}
-proc GTK_TYPE_TREE_DRAG_DEST*(): GType
-proc GTK_TREE_DRAG_DEST*(obj: pointer): PGtkTreeDragDest
-proc GTK_IS_TREE_DRAG_DEST*(obj: pointer): bool
-proc GTK_TREE_DRAG_DEST_GET_IFACE*(obj: pointer): PGtkTreeDragDestIface
-proc gtk_tree_drag_dest_get_type*(): GType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_drag_dest_get_type".}
-proc gtk_tree_drag_dest_drag_data_received*(drag_dest: PGtkTreeDragDest,
-    dest: PGtkTreePath, selection_data: PGtkSelectionData): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_drag_dest_drag_data_received".}
-proc gtk_tree_drag_dest_row_drop_possible*(drag_dest: PGtkTreeDragDest,
-    dest_path: PGtkTreePath, selection_data: PGtkSelectionData): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_drag_dest_row_drop_possible".}
-proc gtk_tree_set_row_drag_data*(selection_data: PGtkSelectionData,
-                                 tree_model: PGtkTreeModel, path: PGtkTreePath): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_set_row_drag_data".}
-const
-  bm_TGtkTreeItem_expanded* = 0x00000001'i16
-  bp_TGtkTreeItem_expanded* = 0'i16
-
-proc GTK_TYPE_TREE_ITEM*(): GType
-proc GTK_TREE_ITEM*(obj: pointer): PGtkTreeItem
-proc GTK_TREE_ITEM_CLASS*(klass: pointer): PGtkTreeItemClass
-proc GTK_IS_TREE_ITEM*(obj: pointer): bool
-proc GTK_IS_TREE_ITEM_CLASS*(klass: pointer): bool
-proc GTK_TREE_ITEM_GET_CLASS*(obj: pointer): PGtkTreeItemClass
-proc GTK_TREE_ITEM_SUBTREE*(obj: pointer): PGtkWidget
-proc expanded*(a: var TGtkTreeItem): guint
-proc set_expanded*(a: var TGtkTreeItem, `expanded`: guint)
-proc gtk_tree_item_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_item_get_type".}
-proc gtk_tree_item_new*(): PGtkTreeItem{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_tree_item_new".}
-proc gtk_tree_item_new_with_label*(`label`: cstring): PGtkTreeItem{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_item_new_with_label".}
-proc gtk_tree_item_set_subtree*(tree_item: PGtkTreeItem, subtree: PGtkWidget){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_item_set_subtree".}
-proc gtk_tree_item_remove_subtree*(tree_item: PGtkTreeItem){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_item_remove_subtree".}
-proc gtk_tree_item_select*(tree_item: PGtkTreeItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_item_select".}
-proc gtk_tree_item_deselect*(tree_item: PGtkTreeItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_item_deselect".}
-proc gtk_tree_item_expand*(tree_item: PGtkTreeItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_item_expand".}
-proc gtk_tree_item_collapse*(tree_item: PGtkTreeItem){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_item_collapse".}
-proc GTK_TYPE_TREE_SELECTION*(): GType
-proc GTK_TREE_SELECTION*(obj: pointer): PGtkTreeSelection
-proc GTK_TREE_SELECTION_CLASS*(klass: pointer): PGtkTreeSelectionClass
-proc GTK_IS_TREE_SELECTION*(obj: pointer): bool
-proc GTK_IS_TREE_SELECTION_CLASS*(klass: pointer): bool
-proc GTK_TREE_SELECTION_GET_CLASS*(obj: pointer): PGtkTreeSelectionClass
-proc gtk_tree_selection_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_selection_get_type".}
-proc gtk_tree_selection_set_mode*(selection: PGtkTreeSelection,
-                                  thetype: TGtkSelectionMode){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_set_mode".}
-proc gtk_tree_selection_get_mode*(selection: PGtkTreeSelection): TGtkSelectionMode{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_selection_get_mode".}
-proc gtk_tree_selection_set_select_function*(selection: PGtkTreeSelection,
-    fun: TGtkTreeSelectionFunc, data: gpointer, destroy: TGtkDestroyNotify){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_selection_set_select_function".}
-proc gtk_tree_selection_get_user_data*(selection: PGtkTreeSelection): gpointer{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_selection_get_user_data".}
-proc gtk_tree_selection_get_tree_view*(selection: PGtkTreeSelection): PGtkTreeView{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_selection_get_tree_view".}
-proc gtk_tree_selection_get_selected*(selection: PGtkTreeSelection,
-                                      model: PPGtkTreeModel, iter: PGtkTreeIter): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_selection_get_selected".}
-proc gtk_tree_selection_get_selected_rows*(selection: PGtkTreeSelection,
-    model: PPGtkTreeModel): PGList{.cdecl, dynlib: gtklib, importc: "gtk_tree_selection_get_selected_rows".}
-proc gtk_tree_selection_selected_foreach*(selection: PGtkTreeSelection,
-    fun: TGtkTreeSelectionForeachFunc, data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_selection_selected_foreach".}
-proc gtk_tree_selection_select_path*(selection: PGtkTreeSelection,
-                                     path: PGtkTreePath){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_selection_select_path".}
-proc gtk_tree_selection_unselect_path*(selection: PGtkTreeSelection,
-                                       path: PGtkTreePath){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_unselect_path".}
-proc gtk_tree_selection_select_iter*(selection: PGtkTreeSelection,
-                                     iter: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_selection_select_iter".}
-proc gtk_tree_selection_unselect_iter*(selection: PGtkTreeSelection,
-                                       iter: PGtkTreeIter){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_unselect_iter".}
-proc gtk_tree_selection_path_is_selected*(selection: PGtkTreeSelection,
-    path: PGtkTreePath): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_tree_selection_path_is_selected".}
-proc gtk_tree_selection_iter_is_selected*(selection: PGtkTreeSelection,
-    iter: PGtkTreeIter): gboolean{.cdecl, dynlib: gtklib, importc: "gtk_tree_selection_iter_is_selected".}
-proc gtk_tree_selection_select_all*(selection: PGtkTreeSelection){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_select_all".}
-proc gtk_tree_selection_unselect_all*(selection: PGtkTreeSelection){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_unselect_all".}
-proc gtk_tree_selection_select_range*(selection: PGtkTreeSelection,
-                                      start_path: PGtkTreePath,
-                                      end_path: PGtkTreePath){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_selection_select_range".}
-const
-  bm_TGtkTreeStore_columns_dirty* = 0x00000001'i16
-  bp_TGtkTreeStore_columns_dirty* = 0'i16
-
-proc GTK_TYPE_TREE_STORE*(): GType
-proc GTK_TREE_STORE*(obj: pointer): PGtkTreeStore
-proc GTK_TREE_STORE_CLASS*(klass: pointer): PGtkTreeStoreClass
-proc GTK_IS_TREE_STORE*(obj: pointer): bool
-proc GTK_IS_TREE_STORE_CLASS*(klass: pointer): bool
-proc GTK_TREE_STORE_GET_CLASS*(obj: pointer): PGtkTreeStoreClass
-proc columns_dirty*(a: var TGtkTreeStore): guint
-proc set_columns_dirty*(a: var TGtkTreeStore, `columns_dirty`: guint)
-proc gtk_tree_store_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_store_get_type".}
-proc gtk_tree_store_newv*(n_columns: gint, types: PGType): PGtkTreeStore{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_newv".}
-proc gtk_tree_store_set_column_types*(tree_store: PGtkTreeStore,
-                                      n_columns: gint, types: PGType){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_set_column_types".}
-proc gtk_tree_store_set_value*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                               column: gint, value: PGValue){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_set_value".}
-proc gtk_tree_store_remove*(tree_store: PGtkTreeStore, iter: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_store_remove".}
-proc gtk_tree_store_insert*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                            parent: PGtkTreeIter, position: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_insert".}
-proc gtk_tree_store_insert_before*(tree_store: PGtkTreeStore,
-                                   iter: PGtkTreeIter, parent: PGtkTreeIter,
-                                   sibling: PGtkTreeIter){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_insert_before".}
-proc gtk_tree_store_insert_after*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                                  parent: PGtkTreeIter, sibling: PGtkTreeIter){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_store_insert_after".}
-proc gtk_tree_store_prepend*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                             parent: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_store_prepend".}
-proc gtk_tree_store_append*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                            parent: PGtkTreeIter){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_store_append".}
-proc gtk_tree_store_is_ancestor*(tree_store: PGtkTreeStore, iter: PGtkTreeIter,
-                                 descendant: PGtkTreeIter): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_store_is_ancestor".}
-proc gtk_tree_store_iter_depth*(tree_store: PGtkTreeStore, iter: PGtkTreeIter): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_store_iter_depth".}
-proc gtk_tree_store_clear*(tree_store: PGtkTreeStore){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_store_clear".}
-const
-  bm_TGtkTreeViewColumn_visible* = 0x00000001'i16
-  bp_TGtkTreeViewColumn_visible* = 0'i16
-  bm_TGtkTreeViewColumn_resizable* = 0x00000002'i16
-  bp_TGtkTreeViewColumn_resizable* = 1'i16
-  bm_TGtkTreeViewColumn_clickable* = 0x00000004'i16
-  bp_TGtkTreeViewColumn_clickable* = 2'i16
-  bm_TGtkTreeViewColumn_dirty* = 0x00000008'i16
-  bp_TGtkTreeViewColumn_dirty* = 3'i16
-  bm_TGtkTreeViewColumn_show_sort_indicator* = 0x00000010'i16
-  bp_TGtkTreeViewColumn_show_sort_indicator* = 4'i16
-  bm_TGtkTreeViewColumn_maybe_reordered* = 0x00000020'i16
-  bp_TGtkTreeViewColumn_maybe_reordered* = 5'i16
-  bm_TGtkTreeViewColumn_reorderable* = 0x00000040'i16
-  bp_TGtkTreeViewColumn_reorderable* = 6'i16
-  bm_TGtkTreeViewColumn_use_resized_width* = 0x00000080'i16
-  bp_TGtkTreeViewColumn_use_resized_width* = 7'i16
-
-proc GTK_TYPE_TREE_VIEW_COLUMN*(): GType
-proc GTK_TREE_VIEW_COLUMN*(obj: pointer): PGtkTreeViewColumn
-proc GTK_TREE_VIEW_COLUMN_CLASS*(klass: pointer): PGtkTreeViewColumnClass
-proc GTK_IS_TREE_VIEW_COLUMN*(obj: pointer): bool
-proc GTK_IS_TREE_VIEW_COLUMN_CLASS*(klass: pointer): bool
-proc GTK_TREE_VIEW_COLUMN_GET_CLASS*(obj: pointer): PGtkTreeViewColumnClass
-proc visible*(a: var TGtkTreeViewColumn): guint
-proc set_visible*(a: var TGtkTreeViewColumn, `visible`: guint)
-proc resizable*(a: var TGtkTreeViewColumn): guint
-proc set_resizable*(a: var TGtkTreeViewColumn, `resizable`: guint)
-proc clickable*(a: var TGtkTreeViewColumn): guint
-proc set_clickable*(a: var TGtkTreeViewColumn, `clickable`: guint)
-proc dirty*(a: var TGtkTreeViewColumn): guint
-proc set_dirty*(a: var TGtkTreeViewColumn, `dirty`: guint)
-proc show_sort_indicator*(a: var TGtkTreeViewColumn): guint
-proc set_show_sort_indicator*(a: var TGtkTreeViewColumn,
-                              `show_sort_indicator`: guint)
-proc maybe_reordered*(a: var TGtkTreeViewColumn): guint
-proc set_maybe_reordered*(a: var TGtkTreeViewColumn, `maybe_reordered`: guint)
-proc reorderable*(a: var TGtkTreeViewColumn): guint
-proc set_reorderable*(a: var TGtkTreeViewColumn, `reorderable`: guint)
-proc use_resized_width*(a: var TGtkTreeViewColumn): guint
-proc set_use_resized_width*(a: var TGtkTreeViewColumn,
-                            `use_resized_width`: guint)
-proc gtk_tree_view_column_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_get_type".}
-proc gtk_tree_view_column_new*(): PGtkTreeViewColumn{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_new".}
-proc gtk_tree_view_column_pack_start*(tree_column: PGtkTreeViewColumn,
-                                      cell: PGtkCellRenderer, expand: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_pack_start".}
-proc gtk_tree_view_column_pack_end*(tree_column: PGtkTreeViewColumn,
-                                    cell: PGtkCellRenderer, expand: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_pack_end".}
-proc gtk_tree_view_column_clear*(tree_column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_clear".}
-proc gtk_tree_view_column_get_cell_renderers*(tree_column: PGtkTreeViewColumn): PGList{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_cell_renderers".}
-proc gtk_tree_view_column_add_attribute*(tree_column: PGtkTreeViewColumn,
-    cell_renderer: PGtkCellRenderer, attribute: cstring, column: gint){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_add_attribute".}
-proc gtk_tree_view_column_set_cell_data_func*(tree_column: PGtkTreeViewColumn,
-    cell_renderer: PGtkCellRenderer, fun: TGtkTreeCellDataFunc,
-    func_data: gpointer, destroy: TGtkDestroyNotify){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_set_cell_data_func".}
-proc gtk_tree_view_column_clear_attributes*(tree_column: PGtkTreeViewColumn,
-    cell_renderer: PGtkCellRenderer){.cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_clear_attributes".}
-proc gtk_tree_view_column_set_spacing*(tree_column: PGtkTreeViewColumn,
-                                       spacing: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_set_spacing".}
-proc gtk_tree_view_column_get_spacing*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_spacing".}
-proc gtk_tree_view_column_set_visible*(tree_column: PGtkTreeViewColumn,
-                                       visible: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_set_visible".}
-proc gtk_tree_view_column_get_visible*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_visible".}
-proc gtk_tree_view_column_set_resizable*(tree_column: PGtkTreeViewColumn,
-    resizable: gboolean){.cdecl, dynlib: gtklib,
-                          importc: "gtk_tree_view_column_set_resizable".}
-proc gtk_tree_view_column_get_resizable*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_resizable".}
-proc gtk_tree_view_column_set_sizing*(tree_column: PGtkTreeViewColumn,
-                                      thetype: TGtkTreeViewColumnSizing){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_set_sizing".}
-proc gtk_tree_view_column_get_sizing*(tree_column: PGtkTreeViewColumn): TGtkTreeViewColumnSizing{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_sizing".}
-proc gtk_tree_view_column_get_width*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_width".}
-proc gtk_tree_view_column_get_fixed_width*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_fixed_width".}
-proc gtk_tree_view_column_set_fixed_width*(tree_column: PGtkTreeViewColumn,
-    fixed_width: gint){.cdecl, dynlib: gtklib,
-                        importc: "gtk_tree_view_column_set_fixed_width".}
-proc gtk_tree_view_column_set_min_width*(tree_column: PGtkTreeViewColumn,
-    min_width: gint){.cdecl, dynlib: gtklib,
-                      importc: "gtk_tree_view_column_set_min_width".}
-proc gtk_tree_view_column_get_min_width*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_min_width".}
-proc gtk_tree_view_column_set_max_width*(tree_column: PGtkTreeViewColumn,
-    max_width: gint){.cdecl, dynlib: gtklib,
-                      importc: "gtk_tree_view_column_set_max_width".}
-proc gtk_tree_view_column_get_max_width*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_max_width".}
-proc gtk_tree_view_column_clicked*(tree_column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_clicked".}
-proc gtk_tree_view_column_set_title*(tree_column: PGtkTreeViewColumn,
-                                     title: cstring){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_set_title".}
-proc gtk_tree_view_column_get_title*(tree_column: PGtkTreeViewColumn): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_title".}
-proc gtk_tree_view_column_set_clickable*(tree_column: PGtkTreeViewColumn,
-    clickable: gboolean){.cdecl, dynlib: gtklib,
-                          importc: "gtk_tree_view_column_set_clickable".}
-proc gtk_tree_view_column_get_clickable*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_clickable".}
-proc gtk_tree_view_column_set_widget*(tree_column: PGtkTreeViewColumn,
-                                      widget: PGtkWidget){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_set_widget".}
-proc gtk_tree_view_column_get_widget*(tree_column: PGtkTreeViewColumn): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_widget".}
-proc gtk_tree_view_column_set_alignment*(tree_column: PGtkTreeViewColumn,
-    xalign: gfloat){.cdecl, dynlib: gtklib,
-                     importc: "gtk_tree_view_column_set_alignment".}
-proc gtk_tree_view_column_get_alignment*(tree_column: PGtkTreeViewColumn): gfloat{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_alignment".}
-proc gtk_tree_view_column_set_reorderable*(tree_column: PGtkTreeViewColumn,
-    reorderable: gboolean){.cdecl, dynlib: gtklib,
-                            importc: "gtk_tree_view_column_set_reorderable".}
-proc gtk_tree_view_column_get_reorderable*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_reorderable".}
-proc gtk_tree_view_column_set_sort_column_id*(tree_column: PGtkTreeViewColumn,
-    sort_column_id: gint){.cdecl, dynlib: gtklib,
-                           importc: "gtk_tree_view_column_set_sort_column_id".}
-proc gtk_tree_view_column_get_sort_column_id*(tree_column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_sort_column_id".}
-proc gtk_tree_view_column_set_sort_indicator*(tree_column: PGtkTreeViewColumn,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_tree_view_column_set_sort_indicator".}
-proc gtk_tree_view_column_get_sort_indicator*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_sort_indicator".}
-proc gtk_tree_view_column_set_sort_order*(tree_column: PGtkTreeViewColumn,
-    order: TGtkSortType){.cdecl, dynlib: gtklib,
-                          importc: "gtk_tree_view_column_set_sort_order".}
-proc gtk_tree_view_column_get_sort_order*(tree_column: PGtkTreeViewColumn): TGtkSortType{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_sort_order".}
-proc gtk_tree_view_column_cell_set_cell_data*(tree_column: PGtkTreeViewColumn,
-    tree_model: PGtkTreeModel, iter: PGtkTreeIter, is_expander: gboolean,
-    is_expanded: gboolean){.cdecl, dynlib: gtklib,
-                            importc: "gtk_tree_view_column_cell_set_cell_data".}
-proc gtk_tree_view_column_cell_get_size*(tree_column: PGtkTreeViewColumn,
-    cell_area: PGdkRectangle, x_offset: Pgint, y_offset: Pgint, width: Pgint,
-    height: Pgint){.cdecl, dynlib: gtklib,
-                    importc: "gtk_tree_view_column_cell_get_size".}
-proc gtk_tree_view_column_cell_is_visible*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_cell_is_visible".}
-proc gtk_tree_view_column_focus_cell*(tree_column: PGtkTreeViewColumn,
-                                      cell: PGtkCellRenderer){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_column_focus_cell".}
-proc gtk_tree_view_column_set_expand*(tree_column: PGtkTreeViewColumn,
-                                      Expand: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_column_set_expand".}
-proc gtk_tree_view_column_get_expand*(tree_column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_column_get_expand".}
-const
-  GTK_RBNODE_BLACK* = 1 shl 0
-  GTK_RBNODE_RED* = 1 shl 1
-  GTK_RBNODE_IS_PARENT* = 1 shl 2
-  GTK_RBNODE_IS_SELECTED* = 1 shl 3
-  GTK_RBNODE_IS_PRELIT* = 1 shl 4
-  GTK_RBNODE_IS_SEMI_COLLAPSED* = 1 shl 5
-  GTK_RBNODE_IS_SEMI_EXPANDED* = 1 shl 6
-  GTK_RBNODE_INVALID* = 1 shl 7
-  GTK_RBNODE_COLUMN_INVALID* = 1 shl 8
-  GTK_RBNODE_DESCENDANTS_INVALID* = 1 shl 9
-  GTK_RBNODE_NON_COLORS* = GTK_RBNODE_IS_PARENT or GTK_RBNODE_IS_SELECTED or
-      GTK_RBNODE_IS_PRELIT or GTK_RBNODE_IS_SEMI_COLLAPSED or
-      GTK_RBNODE_IS_SEMI_EXPANDED or GTK_RBNODE_INVALID or
-      GTK_RBNODE_COLUMN_INVALID or GTK_RBNODE_DESCENDANTS_INVALID
-
-const
-  bm_TGtkRBNode_flags* = 0x00003FFF'i16
-  bp_TGtkRBNode_flags* = 0'i16
-  bm_TGtkRBNode_parity* = 0x00004000'i16
-  bp_TGtkRBNode_parity* = 14'i16
-
-proc flags*(a: PGtkRBNode): guint
-proc set_flags*(a: PGtkRBNode, `flags`: guint)
-proc parity*(a: PGtkRBNode): guint
-proc set_parity*(a: PGtkRBNode, `parity`: guint)
-proc GTK_RBNODE_GET_COLOR*(node: PGtkRBNode): guint
-proc GTK_RBNODE_SET_COLOR*(node: PGtkRBNode, color: guint)
-proc GTK_RBNODE_GET_HEIGHT*(node: PGtkRBNode): gint
-proc GTK_RBNODE_SET_FLAG*(node: PGtkRBNode, flag: guint16)
-proc GTK_RBNODE_UNSET_FLAG*(node: PGtkRBNode, flag: guint16)
-proc GTK_RBNODE_FLAG_SET*(node: PGtkRBNode, flag: guint): bool
-proc gtk_rbtree_push_allocator*(allocator: PGAllocator){.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_push_allocator".}
-proc gtk_rbtree_pop_allocator*(){.cdecl, dynlib: gtklib,
-                                    importc: "_gtk_rbtree_pop_allocator".}
-proc gtk_rbtree_new*(): PGtkRBTree{.cdecl, dynlib: gtklib,
-                                      importc: "_gtk_rbtree_new".}
-proc gtk_rbtree_free*(tree: PGtkRBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_free".}
-proc gtk_rbtree_remove*(tree: PGtkRBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_remove".}
-proc gtk_rbtree_destroy*(tree: PGtkRBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_destroy".}
-proc gtk_rbtree_insert_before*(tree: PGtkRBTree, node: PGtkRBNode,
-                                 height: gint, valid: gboolean): PGtkRBNode{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_insert_before".}
-proc gtk_rbtree_insert_after*(tree: PGtkRBTree, node: PGtkRBNode,
-                                height: gint, valid: gboolean): PGtkRBNode{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_insert_after".}
-proc gtk_rbtree_remove_node*(tree: PGtkRBTree, node: PGtkRBNode){.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_remove_node".}
-proc gtk_rbtree_reorder*(tree: PGtkRBTree, new_order: Pgint, length: gint){.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_reorder".}
-proc gtk_rbtree_find_count*(tree: PGtkRBTree, count: gint): PGtkRBNode{.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_find_count".}
-proc gtk_rbtree_node_set_height*(tree: PGtkRBTree, node: PGtkRBNode,
-                                   height: gint){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_node_set_height".}
-proc gtk_rbtree_node_mark_invalid*(tree: PGtkRBTree, node: PGtkRBNode){.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_node_mark_invalid".}
-proc gtk_rbtree_node_mark_valid*(tree: PGtkRBTree, node: PGtkRBNode){.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_node_mark_valid".}
-proc gtk_rbtree_column_invalid*(tree: PGtkRBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_column_invalid".}
-proc gtk_rbtree_mark_invalid*(tree: PGtkRBTree){.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_mark_invalid".}
-proc gtk_rbtree_set_fixed_height*(tree: PGtkRBTree, height: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_set_fixed_height".}
-proc gtk_rbtree_node_find_offset*(tree: PGtkRBTree, node: PGtkRBNode): gint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_node_find_offset".}
-proc gtk_rbtree_node_find_parity*(tree: PGtkRBTree, node: PGtkRBNode): gint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_node_find_parity".}
-proc gtk_rbtree_traverse*(tree: PGtkRBTree, node: PGtkRBNode,
-                            order: TGTraverseType,
-                            fun: TGtkRBTreeTraverseFunc, data: gpointer){.
-    cdecl, dynlib: gtklib, importc: "_gtk_rbtree_traverse".}
-proc gtk_rbtree_next*(tree: PGtkRBTree, node: PGtkRBNode): PGtkRBNode{.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_next".}
-proc gtk_rbtree_prev*(tree: PGtkRBTree, node: PGtkRBNode): PGtkRBNode{.cdecl,
-    dynlib: gtklib, importc: "_gtk_rbtree_prev".}
-proc gtk_rbtree_get_depth*(tree: PGtkRBTree): gint{.cdecl, dynlib: gtklib,
-    importc: "_gtk_rbtree_get_depth".}
-const
-  TREE_VIEW_DRAG_WIDTH* = 6
-  GTK_TREE_VIEW_IS_LIST* = 1 shl 0
-  GTK_TREE_VIEW_SHOW_EXPANDERS* = 1 shl 1
-  GTK_TREE_VIEW_IN_COLUMN_RESIZE* = 1 shl 2
-  GTK_TREE_VIEW_ARROW_PRELIT* = 1 shl 3
-  GTK_TREE_VIEW_HEADERS_VISIBLE* = 1 shl 4
-  GTK_TREE_VIEW_DRAW_KEYFOCUS* = 1 shl 5
-  GTK_TREE_VIEW_MODEL_SETUP* = 1 shl 6
-  GTK_TREE_VIEW_IN_COLUMN_DRAG* = 1 shl 7
-  DRAG_COLUMN_WINDOW_STATE_UNSET* = 0
-  DRAG_COLUMN_WINDOW_STATE_ORIGINAL* = 1
-  DRAG_COLUMN_WINDOW_STATE_ARROW* = 2
-  DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT* = 3
-  DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT* = 4
-
-proc GTK_TREE_VIEW_SET_FLAG*(tree_view: PGtkTreeView, flag: guint)
-proc GTK_TREE_VIEW_UNSET_FLAG*(tree_view: PGtkTreeView, flag: guint)
-proc GTK_TREE_VIEW_FLAG_SET*(tree_view: PGtkTreeView, flag: guint): bool
-proc TREE_VIEW_HEADER_HEIGHT*(tree_view: PGtkTreeView): int32
-proc TREE_VIEW_COLUMN_REQUESTED_WIDTH*(column: PGtkTreeViewColumn): int32
-proc TREE_VIEW_DRAW_EXPANDERS*(tree_view: PGtkTreeView): bool
-proc TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER*(tree_view: PGtkTreeView): int32
-const
-  bm_TGtkTreeViewPrivate_scroll_to_use_align* = 0x00000001'i16
-  bp_TGtkTreeViewPrivate_scroll_to_use_align* = 0'i16
-  bm_TGtkTreeViewPrivate_fixed_height_check* = 0x00000002'i16
-  bp_TGtkTreeViewPrivate_fixed_height_check* = 1'i16
-  bm_TGtkTreeViewPrivate_reorderable* = 0x00000004'i16
-  bp_TGtkTreeViewPrivate_reorderable* = 2'i16
-  bm_TGtkTreeViewPrivate_header_has_focus* = 0x00000008'i16
-  bp_TGtkTreeViewPrivate_header_has_focus* = 3'i16
-  bm_TGtkTreeViewPrivate_drag_column_window_state* = 0x00000070'i16
-  bp_TGtkTreeViewPrivate_drag_column_window_state* = 4'i16
-  bm_TGtkTreeViewPrivate_has_rules* = 0x00000080'i16
-  bp_TGtkTreeViewPrivate_has_rules* = 7'i16
-  bm_TGtkTreeViewPrivate_mark_rows_col_dirty* = 0x00000100'i16
-  bp_TGtkTreeViewPrivate_mark_rows_col_dirty* = 8'i16
-  bm_TGtkTreeViewPrivate_enable_search* = 0x00000200'i16
-  bp_TGtkTreeViewPrivate_enable_search* = 9'i16
-  bm_TGtkTreeViewPrivate_disable_popdown* = 0x00000400'i16
-  bp_TGtkTreeViewPrivate_disable_popdown* = 10'i16
-
-proc scroll_to_use_align*(a: var TGtkTreeViewPrivate): guint
-proc set_scroll_to_use_align*(a: var TGtkTreeViewPrivate,
-                              `scroll_to_use_align`: guint)
-proc fixed_height_check*(a: var TGtkTreeViewPrivate): guint
-proc set_fixed_height_check*(a: var TGtkTreeViewPrivate,
-                             `fixed_height_check`: guint)
-proc reorderable*(a: var TGtkTreeViewPrivate): guint
-proc set_reorderable*(a: var TGtkTreeViewPrivate, `reorderable`: guint)
-proc header_has_focus*(a: var TGtkTreeViewPrivate): guint
-proc set_header_has_focus*(a: var TGtkTreeViewPrivate, `header_has_focus`: guint)
-proc drag_column_window_state*(a: var TGtkTreeViewPrivate): guint
-proc set_drag_column_window_state*(a: var TGtkTreeViewPrivate,
-                                   `drag_column_window_state`: guint)
-proc has_rules*(a: var TGtkTreeViewPrivate): guint
-proc set_has_rules*(a: var TGtkTreeViewPrivate, `has_rules`: guint)
-proc mark_rows_col_dirty*(a: var TGtkTreeViewPrivate): guint
-proc set_mark_rows_col_dirty*(a: var TGtkTreeViewPrivate,
-                              `mark_rows_col_dirty`: guint)
-proc enable_search*(a: var TGtkTreeViewPrivate): guint
-proc set_enable_search*(a: var TGtkTreeViewPrivate, `enable_search`: guint)
-proc disable_popdown*(a: var TGtkTreeViewPrivate): guint
-proc set_disable_popdown*(a: var TGtkTreeViewPrivate, `disable_popdown`: guint)
-proc gtk_tree_selection_internal_select_node*(selection: PGtkTreeSelection,
-    node: PGtkRBNode, tree: PGtkRBTree, path: PGtkTreePath,
-    state: TGdkModifierType, override_browse_mode: gboolean){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_selection_internal_select_node".}
-proc gtk_tree_view_find_node*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                                tree: var PGtkRBTree, node: var PGtkRBNode): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_find_node".}
-proc gtk_tree_view_find_path*(tree_view: PGtkTreeView, tree: PGtkRBTree,
-                                node: PGtkRBNode): PGtkTreePath{.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_find_path".}
-proc gtk_tree_view_child_move_resize*(tree_view: PGtkTreeView,
-                                        widget: PGtkWidget, x: gint, y: gint,
-                                        width: gint, height: gint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_child_move_resize".}
-proc gtk_tree_view_queue_draw_node*(tree_view: PGtkTreeView, tree: PGtkRBTree,
-                                      node: PGtkRBNode,
-                                      clip_rect: PGdkRectangle){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_queue_draw_node".}
-proc gtk_tree_view_column_realize_button*(column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_realize_button".}
-proc gtk_tree_view_column_unrealize_button*(column: PGtkTreeViewColumn){.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_unrealize_button".}
-proc gtk_tree_view_column_set_tree_view*(column: PGtkTreeViewColumn,
-    tree_view: PGtkTreeView){.cdecl, dynlib: gtklib,
-                              importc: "_gtk_tree_view_column_set_tree_view".}
-proc gtk_tree_view_column_unset_tree_view*(column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_unset_tree_view".}
-proc gtk_tree_view_column_set_width*(column: PGtkTreeViewColumn, width: gint){.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_set_width".}
-proc gtk_tree_view_column_start_drag*(tree_view: PGtkTreeView,
-                                        column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_start_drag".}
-proc gtk_tree_view_column_start_editing*(tree_column: PGtkTreeViewColumn,
-    editable_widget: PGtkCellEditable){.cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_start_editing".}
-proc gtk_tree_view_column_stop_editing*(tree_column: PGtkTreeViewColumn){.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_stop_editing".}
-proc gtk_tree_view_install_mark_rows_col_dirty*(tree_view: PGtkTreeView){.
-    cdecl, dynlib: gtklib,
-    importc: "_gtk_tree_view_install_mark_rows_col_dirty".}
-proc DOgtk_tree_view_column_autosize*(tree_view: PGtkTreeView,
-                                      column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_autosize".}
-proc gtk_tree_view_column_has_editable_cell*(column: PGtkTreeViewColumn): gboolean{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_has_editable_cell".}
-proc gtk_tree_view_column_get_edited_cell*(column: PGtkTreeViewColumn): PGtkCellRenderer{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_get_edited_cell".}
-proc gtk_tree_view_column_count_special_cells*(column: PGtkTreeViewColumn): gint{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_count_special_cells".}
-proc gtk_tree_view_column_get_cell_at_pos*(column: PGtkTreeViewColumn, x: gint): PGtkCellRenderer{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_get_cell_at_pos".}
-proc gtk_tree_selection_new*(): PGtkTreeSelection{.cdecl, dynlib: gtklib,
-    importc: "_gtk_tree_selection_new".}
-proc gtk_tree_selection_new_with_tree_view*(tree_view: PGtkTreeView): PGtkTreeSelection{.
-    cdecl, dynlib: gtklib, importc: "_gtk_tree_selection_new_with_tree_view".}
-proc gtk_tree_selection_set_tree_view*(selection: PGtkTreeSelection,
-    tree_view: PGtkTreeView){.cdecl, dynlib: gtklib,
-                              importc: "_gtk_tree_selection_set_tree_view".}
-proc gtk_tree_view_column_cell_render*(tree_column: PGtkTreeViewColumn,
-    window: PGdkWindow, background_area: PGdkRectangle,
-    cell_area: PGdkRectangle, expose_area: PGdkRectangle, flags: guint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_cell_render".}
-proc gtk_tree_view_column_cell_focus*(tree_column: PGtkTreeViewColumn,
-                                        direction: gint, left: gboolean,
-                                        right: gboolean): gboolean{.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_cell_focus".}
-proc gtk_tree_view_column_cell_draw_focus*(tree_column: PGtkTreeViewColumn,
-    window: PGdkWindow, background_area: PGdkRectangle,
-    cell_area: PGdkRectangle, expose_area: PGdkRectangle, flags: guint){.cdecl,
-    dynlib: gtklib, importc: "_gtk_tree_view_column_cell_draw_focus".}
-proc gtk_tree_view_column_cell_set_dirty*(tree_column: PGtkTreeViewColumn,
-    install_handler: gboolean){.cdecl, dynlib: gtklib, importc: "_gtk_tree_view_column_cell_set_dirty".}
-proc gtk_tree_view_column_get_neighbor_sizes*(column: PGtkTreeViewColumn,
-    cell: PGtkCellRenderer, left: Pgint, right: Pgint){.cdecl, dynlib: gtklib,
-    importc: "_gtk_tree_view_column_get_neighbor_sizes".}
-proc GTK_TYPE_TREE_VIEW*(): GType
-proc GTK_TREE_VIEW*(obj: pointer): PGtkTreeView
-proc GTK_TREE_VIEW_CLASS*(klass: pointer): PGtkTreeViewClass
-proc GTK_IS_TREE_VIEW*(obj: pointer): bool
-proc GTK_IS_TREE_VIEW_CLASS*(klass: pointer): bool
-proc GTK_TREE_VIEW_GET_CLASS*(obj: pointer): PGtkTreeViewClass
-proc gtk_tree_view_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_get_type".}
-proc gtk_tree_view_new*(): PGtkTreeView{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_tree_view_new".}
-proc gtk_tree_view_new_with_model*(model: PGtkTreeModel): PGtkTreeView{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_new_with_model".}
-proc gtk_tree_view_get_model*(tree_view: PGtkTreeView): PGtkTreeModel{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_model".}
-proc gtk_tree_view_set_model*(tree_view: PGtkTreeView, model: PGtkTreeModel){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_model".}
-proc gtk_tree_view_get_selection*(tree_view: PGtkTreeView): PGtkTreeSelection{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_selection".}
-proc gtk_tree_view_get_hadjustment*(tree_view: PGtkTreeView): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_hadjustment".}
-proc gtk_tree_view_set_hadjustment*(tree_view: PGtkTreeView,
-                                    adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_hadjustment".}
-proc gtk_tree_view_get_vadjustment*(tree_view: PGtkTreeView): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_vadjustment".}
-proc gtk_tree_view_set_vadjustment*(tree_view: PGtkTreeView,
-                                    adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_vadjustment".}
-proc gtk_tree_view_get_headers_visible*(tree_view: PGtkTreeView): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_headers_visible".}
-proc gtk_tree_view_set_headers_visible*(tree_view: PGtkTreeView,
-                                        headers_visible: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_headers_visible".}
-proc gtk_tree_view_columns_autosize*(tree_view: PGtkTreeView){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_columns_autosize".}
-proc gtk_tree_view_set_headers_clickable*(tree_view: PGtkTreeView,
-    setting: gboolean){.cdecl, dynlib: gtklib,
-                        importc: "gtk_tree_view_set_headers_clickable".}
-proc gtk_tree_view_set_rules_hint*(tree_view: PGtkTreeView, setting: gboolean){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_rules_hint".}
-proc gtk_tree_view_get_rules_hint*(tree_view: PGtkTreeView): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_rules_hint".}
-proc gtk_tree_view_append_column*(tree_view: PGtkTreeView,
-                                  column: PGtkTreeViewColumn): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_append_column".}
-proc gtk_tree_view_remove_column*(tree_view: PGtkTreeView,
-                                  column: PGtkTreeViewColumn): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_remove_column".}
-proc gtk_tree_view_insert_column*(tree_view: PGtkTreeView,
-                                  column: PGtkTreeViewColumn, position: gint): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_insert_column".}
-proc gtk_tree_view_insert_column_with_data_func*(tree_view: PGtkTreeView,
-    position: gint, title: cstring, cell: PGtkCellRenderer,
-    fun: TGtkTreeCellDataFunc, data: gpointer, dnotify: TGDestroyNotify): gint{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_insert_column_with_data_func".}
-proc gtk_tree_view_get_column*(tree_view: PGtkTreeView, n: gint): PGtkTreeViewColumn{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_column".}
-proc gtk_tree_view_get_columns*(tree_view: PGtkTreeView): PGList{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_columns".}
-proc gtk_tree_view_move_column_after*(tree_view: PGtkTreeView,
-                                      column: PGtkTreeViewColumn,
-                                      base_column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_move_column_after".}
-proc gtk_tree_view_set_expander_column*(tree_view: PGtkTreeView,
-                                        column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_expander_column".}
-proc gtk_tree_view_get_expander_column*(tree_view: PGtkTreeView): PGtkTreeViewColumn{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_expander_column".}
-proc gtk_tree_view_set_column_drag_function*(tree_view: PGtkTreeView,
-    fun: TGtkTreeViewColumnDropFunc, user_data: gpointer,
-    destroy: TGtkDestroyNotify){.cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_column_drag_function".}
-proc gtk_tree_view_scroll_to_point*(tree_view: PGtkTreeView, tree_x: gint,
-                                    tree_y: gint){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_scroll_to_point".}
-proc gtk_tree_view_scroll_to_cell*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                                   column: PGtkTreeViewColumn,
-                                   use_align: gboolean, row_align: gfloat,
-                                   col_align: gfloat){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_scroll_to_cell".}
-proc gtk_tree_view_row_activated*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                                  column: PGtkTreeViewColumn){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_row_activated".}
-proc gtk_tree_view_expand_all*(tree_view: PGtkTreeView){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_expand_all".}
-proc gtk_tree_view_collapse_all*(tree_view: PGtkTreeView){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_collapse_all".}
-proc gtk_tree_view_expand_row*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                               open_all: gboolean): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_expand_row".}
-proc gtk_tree_view_collapse_row*(tree_view: PGtkTreeView, path: PGtkTreePath): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_collapse_row".}
-proc gtk_tree_view_map_expanded_rows*(tree_view: PGtkTreeView,
-                                      fun: TGtkTreeViewMappingFunc,
-                                      data: gpointer){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_map_expanded_rows".}
-proc gtk_tree_view_row_expanded*(tree_view: PGtkTreeView, path: PGtkTreePath): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_row_expanded".}
-proc gtk_tree_view_set_reorderable*(tree_view: PGtkTreeView,
-                                    reorderable: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_reorderable".}
-proc gtk_tree_view_get_reorderable*(tree_view: PGtkTreeView): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_reorderable".}
-proc gtk_tree_view_set_cursor*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                               focus_column: PGtkTreeViewColumn,
-                               start_editing: gboolean){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_set_cursor".}
-proc gtk_tree_view_set_cursor_on_cell*(tree_view: PGtkTreeView,
-                                       path: PGtkTreePath,
-                                       focus_column: PGtkTreeViewColumn,
-                                       focus_cell: PGtkCellRenderer,
-                                       start_editing: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_cursor_on_cell".}
-proc gtk_tree_view_get_bin_window*(tree_view: PGtkTreeView): PGdkWindow{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_bin_window".}
-proc gtk_tree_view_get_cell_area*(tree_view: PGtkTreeView, path: PGtkTreePath,
-                                  column: PGtkTreeViewColumn,
-                                  rect: PGdkRectangle){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_get_cell_area".}
-proc gtk_tree_view_get_background_area*(tree_view: PGtkTreeView,
-                                        path: PGtkTreePath,
-                                        column: PGtkTreeViewColumn,
-                                        rect: PGdkRectangle){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_background_area".}
-proc gtk_tree_view_get_visible_rect*(tree_view: PGtkTreeView,
-                                     visible_rect: PGdkRectangle){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_visible_rect".}
-proc gtk_tree_view_widget_to_tree_coords*(tree_view: PGtkTreeView, wx: gint,
-    wy: gint, tx: Pgint, ty: Pgint){.cdecl, dynlib: gtklib, importc: "gtk_tree_view_widget_to_tree_coords".}
-proc gtk_tree_view_tree_to_widget_coords*(tree_view: PGtkTreeView, tx: gint,
-    ty: gint, wx: Pgint, wy: Pgint){.cdecl, dynlib: gtklib, importc: "gtk_tree_view_tree_to_widget_coords".}
-proc gtk_tree_view_enable_model_drag_source*(tree_view: PGtkTreeView,
-    start_button_mask: TGdkModifierType, targets: PGtkTargetEntry,
-    n_targets: gint, actions: TGdkDragAction){.cdecl, dynlib: gtklib,
-    importc: "gtk_tree_view_enable_model_drag_source".}
-proc gtk_tree_view_enable_model_drag_dest*(tree_view: PGtkTreeView,
-    targets: PGtkTargetEntry, n_targets: gint, actions: TGdkDragAction){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_enable_model_drag_dest".}
-proc gtk_tree_view_unset_rows_drag_source*(tree_view: PGtkTreeView){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_unset_rows_drag_source".}
-proc gtk_tree_view_unset_rows_drag_dest*(tree_view: PGtkTreeView){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_unset_rows_drag_dest".}
-proc gtk_tree_view_set_drag_dest_row*(tree_view: PGtkTreeView,
-                                      path: PGtkTreePath,
-                                      pos: TGtkTreeViewDropPosition){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_drag_dest_row".}
-proc gtk_tree_view_create_row_drag_icon*(tree_view: PGtkTreeView,
-    path: PGtkTreePath): PGdkPixmap{.cdecl, dynlib: gtklib, importc: "gtk_tree_view_create_row_drag_icon".}
-proc gtk_tree_view_set_enable_search*(tree_view: PGtkTreeView,
-                                      enable_search: gboolean){.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_set_enable_search".}
-proc gtk_tree_view_get_enable_search*(tree_view: PGtkTreeView): gboolean{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_enable_search".}
-proc gtk_tree_view_get_search_column*(tree_view: PGtkTreeView): gint{.cdecl,
-    dynlib: gtklib, importc: "gtk_tree_view_get_search_column".}
-proc gtk_tree_view_set_search_column*(tree_view: PGtkTreeView, column: gint){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_search_column".}
-proc gtk_tree_view_get_search_equal_func*(tree_view: PGtkTreeView): TGtkTreeViewSearchEqualFunc{.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_get_search_equal_func".}
-proc gtk_tree_view_set_search_equal_func*(tree_view: PGtkTreeView,
-    search_equal_func: TGtkTreeViewSearchEqualFunc, search_user_data: gpointer,
-    search_destroy: TGtkDestroyNotify){.cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_search_equal_func".}
-proc gtk_tree_view_set_destroy_count_func*(tree_view: PGtkTreeView,
-    fun: TGtkTreeDestroyCountFunc, data: gpointer, destroy: TGtkDestroyNotify){.
-    cdecl, dynlib: gtklib, importc: "gtk_tree_view_set_destroy_count_func".}
-proc GTK_TYPE_VBUTTON_BOX*(): GType
-proc GTK_VBUTTON_BOX*(obj: pointer): PGtkVButtonBox
-proc GTK_VBUTTON_BOX_CLASS*(klass: pointer): PGtkVButtonBoxClass
-proc GTK_IS_VBUTTON_BOX*(obj: pointer): bool
-proc GTK_IS_VBUTTON_BOX_CLASS*(klass: pointer): bool
-proc GTK_VBUTTON_BOX_GET_CLASS*(obj: pointer): PGtkVButtonBoxClass
-proc gtk_vbutton_box_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_vbutton_box_get_type".}
-proc gtk_vbutton_box_new*(): PGtkVButtonBox{.cdecl, dynlib: gtklib,
-    importc: "gtk_vbutton_box_new".}
-proc GTK_TYPE_VIEWPORT*(): GType
-proc GTK_VIEWPORT*(obj: pointer): PGtkViewport
-proc GTK_VIEWPORT_CLASS*(klass: pointer): PGtkViewportClass
-proc GTK_IS_VIEWPORT*(obj: pointer): bool
-proc GTK_IS_VIEWPORT_CLASS*(klass: pointer): bool
-proc GTK_VIEWPORT_GET_CLASS*(obj: pointer): PGtkViewportClass
-proc gtk_viewport_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_viewport_get_type".}
-proc gtk_viewport_new*(hadjustment: PGtkAdjustment, vadjustment: PGtkAdjustment): PGtkViewport{.
-    cdecl, dynlib: gtklib, importc: "gtk_viewport_new".}
-proc gtk_viewport_get_hadjustment*(viewport: PGtkViewport): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_viewport_get_hadjustment".}
-proc gtk_viewport_get_vadjustment*(viewport: PGtkViewport): PGtkAdjustment{.
-    cdecl, dynlib: gtklib, importc: "gtk_viewport_get_vadjustment".}
-proc gtk_viewport_set_hadjustment*(viewport: PGtkViewport,
-                                   adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_viewport_set_hadjustment".}
-proc gtk_viewport_set_vadjustment*(viewport: PGtkViewport,
-                                   adjustment: PGtkAdjustment){.cdecl,
-    dynlib: gtklib, importc: "gtk_viewport_set_vadjustment".}
-proc gtk_viewport_set_shadow_type*(viewport: PGtkViewport,
-                                   thetype: TGtkShadowType){.cdecl,
-    dynlib: gtklib, importc: "gtk_viewport_set_shadow_type".}
-proc gtk_viewport_get_shadow_type*(viewport: PGtkViewport): TGtkShadowType{.
-    cdecl, dynlib: gtklib, importc: "gtk_viewport_get_shadow_type".}
-proc GTK_TYPE_VPANED*(): GType
-proc GTK_VPANED*(obj: pointer): PGtkVPaned
-proc GTK_VPANED_CLASS*(klass: pointer): PGtkVPanedClass
-proc GTK_IS_VPANED*(obj: pointer): bool
-proc GTK_IS_VPANED_CLASS*(klass: pointer): bool
-proc GTK_VPANED_GET_CLASS*(obj: pointer): PGtkVPanedClass
-proc gtk_vpaned_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_vpaned_get_type".}
-proc gtk_vpaned_new*(): PGtkVPaned{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_vpaned_new".}
-proc GTK_TYPE_VRULER*(): GType
-proc GTK_VRULER*(obj: pointer): PGtkVRuler
-proc GTK_VRULER_CLASS*(klass: pointer): PGtkVRulerClass
-proc GTK_IS_VRULER*(obj: pointer): bool
-proc GTK_IS_VRULER_CLASS*(klass: pointer): bool
-proc GTK_VRULER_GET_CLASS*(obj: pointer): PGtkVRulerClass
-proc gtk_vruler_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_vruler_get_type".}
-proc gtk_vruler_new*(): PGtkVRuler{.cdecl, dynlib: gtklib,
-                                    importc: "gtk_vruler_new".}
-proc GTK_TYPE_VSCALE*(): GType
-proc GTK_VSCALE*(obj: pointer): PGtkVScale
-proc GTK_VSCALE_CLASS*(klass: pointer): PGtkVScaleClass
-proc GTK_IS_VSCALE*(obj: pointer): bool
-proc GTK_IS_VSCALE_CLASS*(klass: pointer): bool
-proc GTK_VSCALE_GET_CLASS*(obj: pointer): PGtkVScaleClass
-proc gtk_vscale_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-                                       importc: "gtk_vscale_get_type".}
-proc gtk_vscale_new*(adjustment: PGtkAdjustment): PGtkVScale{.cdecl,
-    dynlib: gtklib, importc: "gtk_vscale_new".}
-proc gtk_vscale_new_with_range*(min: gdouble, max: gdouble, step: gdouble): PGtkVScale{.
-    cdecl, dynlib: gtklib, importc: "gtk_vscale_new_with_range".}
-proc GTK_TYPE_VSCROLLBAR*(): GType
-proc GTK_VSCROLLBAR*(obj: pointer): PGtkVScrollbar
-proc GTK_VSCROLLBAR_CLASS*(klass: pointer): PGtkVScrollbarClass
-proc GTK_IS_VSCROLLBAR*(obj: pointer): bool
-proc GTK_IS_VSCROLLBAR_CLASS*(klass: pointer): bool
-proc GTK_VSCROLLBAR_GET_CLASS*(obj: pointer): PGtkVScrollbarClass
-proc gtk_vscrollbar_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_vscrollbar_get_type".}
-proc gtk_vscrollbar_new*(adjustment: PGtkAdjustment): PGtkVScrollbar{.cdecl,
-    dynlib: gtklib, importc: "gtk_vscrollbar_new".}
-proc GTK_TYPE_VSEPARATOR*(): GType
-proc GTK_VSEPARATOR*(obj: pointer): PGtkVSeparator
-proc GTK_VSEPARATOR_CLASS*(klass: pointer): PGtkVSeparatorClass
-proc GTK_IS_VSEPARATOR*(obj: pointer): bool
-proc GTK_IS_VSEPARATOR_CLASS*(klass: pointer): bool
-proc GTK_VSEPARATOR_GET_CLASS*(obj: pointer): PGtkVSeparatorClass
-proc gtk_vseparator_get_type*(): TGtkType{.cdecl, dynlib: gtklib,
-    importc: "gtk_vseparator_get_type".}
-proc gtk_vseparator_new*(): PGtkVSeparator{.cdecl, dynlib: gtklib,
-                                        importc: "gtk_vseparator_new".}
-proc GTK_TYPE_OBJECT*(): GType =
-  result = gtk_object_get_type()
-
-proc GTK_CHECK_CAST*(instance: Pointer, g_type: GType): PGTypeInstance =
-  result = G_TYPE_CHECK_INSTANCE_CAST(instance, g_type)
-
-proc GTK_CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer =
-  result = G_TYPE_CHECK_CLASS_CAST(g_class, g_type)
-
-proc GTK_CHECK_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass =
-  result = G_TYPE_INSTANCE_GET_CLASS(instance, g_type)
-
-proc GTK_CHECK_TYPE*(instance: Pointer, g_type: GType): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type)
-
-proc GTK_CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(g_class, g_type)
-
-proc GTK_OBJECT*(anObject: pointer): PGtkObject =
-  result = cast[PGtkObject](GTK_CHECK_CAST(anObject, GTK_TYPE_OBJECT()))
-
-proc GTK_OBJECT_CLASS*(klass: pointer): PGtkObjectClass =
-  result = cast[PGtkObjectClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_OBJECT()))
-
-proc GTK_IS_OBJECT*(anObject: pointer): bool =
-  result = GTK_CHECK_TYPE(anObject, GTK_TYPE_OBJECT())
-
-proc GTK_IS_OBJECT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_OBJECT())
-
-proc GTK_OBJECT_GET_CLASS*(anObject: pointer): PGtkObjectClass =
-  result = cast[PGtkObjectClass](GTK_CHECK_GET_CLASS(anObject, GTK_TYPE_OBJECT()))
-
-proc GTK_OBJECT_TYPE*(anObject: pointer): GType =
-  result = G_TYPE_FROM_INSTANCE(anObject)
-
-proc GTK_OBJECT_TYPE_NAME*(anObject: pointer): cstring =
-  result = g_type_name(GTK_OBJECT_TYPE(anObject))
-
-proc GTK_OBJECT_FLAGS*(obj: pointer): guint32 =
-  result = (GTK_OBJECT(obj)).flags
-
-proc GTK_OBJECT_FLOATING*(obj: pointer): gboolean =
-  result = ((GTK_OBJECT_FLAGS(obj)) and cint(GTK_FLOATING)) != 0'i32
-
-proc GTK_OBJECT_SET_FLAGS*(obj: pointer, flag: guint32) =
-  GTK_OBJECT(obj).flags = GTK_OBJECT(obj).flags or flag
-
-proc GTK_OBJECT_UNSET_FLAGS*(obj: pointer, flag: guint32) =
-  GTK_OBJECT(obj) . flags = GTK_OBJECT(obj). flags and not (flag)
-
-proc gtk_object_data_try_key*(`string`: cstring): TGQuark =
-  result = g_quark_try_string(`string`)
-
-proc gtk_object_data_force_id*(`string`: cstring): TGQuark =
-  result = g_quark_from_string(`string`)
-
-proc GTK_CLASS_NAME*(`class`: pointer): cstring =
-  result = g_type_name(G_TYPE_FROM_CLASS(`class`))
-
-proc GTK_CLASS_TYPE*(`class`: pointer): GType =
-  result = G_TYPE_FROM_CLASS(`class`)
-
-proc GTK_TYPE_IS_OBJECT*(thetype: GType): gboolean =
-  result = g_type_is_a(thetype, GTK_TYPE_OBJECT())
-
-proc GTK_TYPE_IDENTIFIER*(): GType =
-  result = gtk_identifier_get_type()
-
-proc GTK_SIGNAL_FUNC*(f: pointer): TGtkSignalFunc =
-  result = cast[TGtkSignalFunc](f)
-
-proc gtk_type_name*(thetype: GType): cstring =
-  result = g_type_name(thetype)
-
-proc gtk_type_from_name*(name: cstring): GType =
-  result = g_type_from_name(name)
-
-proc gtk_type_parent*(thetype: GType): GType =
-  result = g_type_parent(thetype)
-
-proc gtk_type_is_a*(thetype, is_a_type: GType): gboolean =
-  result = g_type_is_a(thetype, is_a_type)
-
-proc GTK_FUNDAMENTAL_TYPE*(thetype: GType): GType =
-  result = G_TYPE_FUNDAMENTAL(thetype)
-
-proc GTK_VALUE_CHAR*(a: TGtkArg): gchar =
-  var a = a
-  Result = cast[ptr gchar](addr(a.d))^
-
-proc GTK_VALUE_UCHAR*(a: TGtkArg): guchar =
-  var a = a
-  Result = cast[ptr guchar](addr(a.d))^
-
-proc GTK_VALUE_BOOL*(a: TGtkArg): gboolean =
-  var a = a
-  Result = cast[ptr gboolean](addr(a.d))^
-
-proc GTK_VALUE_INT*(a: TGtkArg): gint =
-  var a = a
-  Result = cast[ptr gint](addr(a.d))^
-
-proc GTK_VALUE_UINT*(a: TGtkArg): guint =
-  var a = a
-  Result = cast[ptr guint](addr(a.d))^
-
-proc GTK_VALUE_LONG*(a: TGtkArg): glong =
-  var a = a
-  Result = cast[ptr glong](addr(a.d))^
-
-proc GTK_VALUE_ULONG*(a: TGtkArg): gulong =
-  var a = a
-  Result = cast[ptr gulong](addr(a.d))^
-
-proc GTK_VALUE_FLOAT*(a: TGtkArg): gfloat =
-  var a = a
-  Result = cast[ptr gfloat](addr(a.d))^
-
-proc GTK_VALUE_DOUBLE*(a: TGtkArg): gdouble =
-  var a = a
-  Result = cast[ptr gdouble](addr(a.d))^
-
-proc GTK_VALUE_STRING*(a: TGtkArg): cstring =
-  var a = a
-  Result = cast[ptr cstring](addr(a.d))^
-
-proc GTK_VALUE_ENUM*(a: TGtkArg): gint =
-  var a = a
-  Result = cast[ptr gint](addr(a.d))^
-
-proc GTK_VALUE_FLAGS*(a: TGtkArg): guint =
-  var a = a
-  Result = cast[ptr guint](addr(a.d))^
-
-proc GTK_VALUE_BOXED*(a: TGtkArg): gpointer =
-  var a = a
-  Result = cast[ptr gpointer](addr(a.d))^
-
-proc GTK_VALUE_OBJECT*(a: TGtkArg): PGtkObject =
-  var a = a
-  Result = cast[ptr PGtkObject](addr(a.d))^
-
-proc GTK_VALUE_POINTER*(a: TGtkArg): GPointer =
-  var a = a
-  Result = cast[ptr gpointer](addr(a.d))^
-
-proc GTK_VALUE_SIGNAL*(a: TGtkArg): TGtkArgSignalData =
-  var a = a
-  Result = cast[ptr TGtkArgSignalData](addr(a.d))^
-
-proc GTK_RETLOC_CHAR*(a: TGtkArg): cstring =
-  var a = a
-  Result = cast[ptr cstring](addr(a.d))^
-
-proc GTK_RETLOC_UCHAR*(a: TGtkArg): Pguchar =
-  var a = a
-  Result = cast[ptr pguchar](addr(a.d))^
-
-proc GTK_RETLOC_BOOL*(a: TGtkArg): Pgboolean =
-  var a = a
-  Result = cast[ptr pgboolean](addr(a.d))^
-
-proc GTK_RETLOC_INT*(a: TGtkArg): Pgint =
-  var a = a
-  Result = cast[ptr pgint](addr(a.d))^
-
-proc GTK_RETLOC_UINT*(a: TGtkArg): Pguint =
-  var a = a
-  Result = cast[ptr pguint](addr(a.d))^
-
-proc GTK_RETLOC_LONG*(a: TGtkArg): Pglong =
-  var a = a
-  Result = cast[ptr pglong](addr(a.d))^
-
-proc GTK_RETLOC_ULONG*(a: TGtkArg): Pgulong =
-  var a = a
-  Result = cast[ptr pgulong](addr(a.d))^
-
-proc GTK_RETLOC_FLOAT*(a: TGtkArg): Pgfloat =
-  var a = a
-  Result = cast[ptr pgfloat](addr(a.d))^
-
-proc GTK_RETLOC_DOUBLE*(a: TGtkArg): Pgdouble =
-  var a = a
-  Result = cast[ptr pgdouble](addr(a.d))^
-
-proc GTK_RETLOC_STRING*(a: TGtkArg): Ppgchar =
-  var a = a
-  Result = cast[ptr Ppgchar](addr(a.d))^
-
-proc GTK_RETLOC_ENUM*(a: TGtkArg): Pgint =
-  var a = a
-  Result = cast[ptr Pgint](addr(a.d))^
-
-proc GTK_RETLOC_FLAGS*(a: TGtkArg): Pguint =
-  var a = a
-  Result = cast[ptr pguint](addr(a.d))^
-
-proc GTK_RETLOC_BOXED*(a: TGtkArg): Pgpointer =
-  var a = a
-  Result = cast[ptr pgpointer](addr(a.d))^
-
-proc GTK_RETLOC_OBJECT*(a: TGtkArg): PPGtkObject =
-  var a = a
-  Result = cast[ptr ppgtkobject](addr(a.d))^
-
-proc GTK_RETLOC_POINTER*(a: TGtkArg): Pgpointer =
-  var a = a
-  Result = cast[ptr pgpointer](addr(a.d))^
-
-proc GTK_TYPE_WIDGET*(): GType =
-  result = gtk_widget_get_type()
-
-proc GTK_WIDGET*(widget: pointer): PGtkWidget =
-  result = cast[PGtkWidget](GTK_CHECK_CAST(widget, GTK_TYPE_WIDGET()))
-
-proc GTK_WIDGET_CLASS*(klass: pointer): PGtkWidgetClass =
-  result = cast[PGtkWidgetClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_WIDGET()))
-
-proc GTK_IS_WIDGET*(widget: pointer): bool =
-  result = GTK_CHECK_TYPE(widget, GTK_TYPE_WIDGET())
-
-proc GTK_IS_WIDGET_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_WIDGET())
-
-proc GTK_WIDGET_GET_CLASS*(obj: pointer): PGtkWidgetClass =
-  result = cast[PGtkWidgetClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_WIDGET()))
-
-proc GTK_WIDGET_TYPE*(wid: pointer): GType =
-  result = GTK_OBJECT_TYPE(wid)
-
-proc GTK_WIDGET_STATE*(wid: pointer): int32 =
-  result = (GTK_WIDGET(wid)) . state
-
-proc GTK_WIDGET_SAVED_STATE*(wid: pointer): int32 =
-  result = (GTK_WIDGET(wid)) . saved_state
-
-proc GTK_WIDGET_FLAGS*(wid: pointer): guint32 =
-  result = GTK_OBJECT_FLAGS(wid)
-
-proc GTK_WIDGET_TOPLEVEL*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_TOPLEVEL)) != 0'i32
-
-proc GTK_WIDGET_NO_WINDOW*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_NO_WINDOW)) != 0'i32
-
-proc GTK_WIDGET_REALIZED*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_REALIZED)) != 0'i32
-
-proc GTK_WIDGET_MAPPED*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_MAPPED)) != 0'i32
-
-proc GTK_WIDGET_VISIBLE*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_VISIBLE)) != 0'i32
-
-proc GTK_WIDGET_DRAWABLE*(wid: pointer): gboolean =
-  result = (GTK_WIDGET_VISIBLE(wid)) and (GTK_WIDGET_MAPPED(wid))
-
-proc GTK_WIDGET_SENSITIVE*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_SENSITIVE)) != 0'i32
-
-proc GTK_WIDGET_PARENT_SENSITIVE*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_PARENT_SENSITIVE)) != 0'i32
-
-proc GTK_WIDGET_IS_SENSITIVE*(wid: pointer): gboolean =
-  result = (GTK_WIDGET_SENSITIVE(wid)) and (GTK_WIDGET_PARENT_SENSITIVE(wid))
-
-proc GTK_WIDGET_CAN_FOCUS*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_CAN_FOCUS)) != 0'i32
-
-proc GTK_WIDGET_HAS_FOCUS*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_HAS_FOCUS)) != 0'i32
-
-proc GTK_WIDGET_CAN_DEFAULT*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_CAN_DEFAULT)) != 0'i32
-
-proc GTK_WIDGET_HAS_DEFAULT*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_HAS_DEFAULT)) != 0'i32
-
-proc GTK_WIDGET_HAS_GRAB*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_HAS_GRAB)) != 0'i32
-
-proc GTK_WIDGET_RC_STYLE*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_RC_STYLE)) != 0'i32
-
-proc GTK_WIDGET_COMPOSITE_CHILD*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_COMPOSITE_CHILD)) != 0'i32
-
-proc GTK_WIDGET_APP_PAINTABLE*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_APP_PAINTABLE)) != 0'i32
-
-proc GTK_WIDGET_RECEIVES_DEFAULT*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_RECEIVES_DEFAULT)) != 0'i32
-
-proc GTK_WIDGET_DOUBLE_BUFFERED*(wid: pointer): gboolean =
-  result = ((GTK_WIDGET_FLAGS(wid)) and cint(GTK_DOUBLE_BUFFERED)) != 0'i32
-
-proc GTK_TYPE_REQUISITION*(): GType =
-  result = gtk_requisition_get_type()
-
-proc x_set*(a: var TGtkWidgetAuxInfo): guint =
-  result = (a.flag0 and bm_TGtkWidgetAuxInfo_x_set) shr
-      bp_TGtkWidgetAuxInfo_x_set
-
-proc set_x_set*(a: var TGtkWidgetAuxInfo, `x_set`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`x_set` shl bp_TGtkWidgetAuxInfo_x_set) and
-      bm_TGtkWidgetAuxInfo_x_set)
-
-proc y_set*(a: var TGtkWidgetAuxInfo): guint =
-  result = (a.flag0 and bm_TGtkWidgetAuxInfo_y_set) shr
-      bp_TGtkWidgetAuxInfo_y_set
-
-proc set_y_set*(a: var TGtkWidgetAuxInfo, `y_set`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`y_set` shl bp_TGtkWidgetAuxInfo_y_set) and
-      bm_TGtkWidgetAuxInfo_y_set)
-
-proc gtk_widget_set_visual*(widget, visual: pointer) =
-  if (Widget != nil) and (visual != nil): nil
-
-proc gtk_widget_push_visual*(visual: pointer) =
-  if (visual != nil): nil
-
-proc gtk_widget_pop_visual*() =
-  nil
-
-proc gtk_widget_set_default_visual*(visual: pointer) =
-  if (visual != nil): nil
-
-proc gtk_widget_set_rc_style*(widget: pointer) =
-  gtk_widget_set_style(cast[PGtkWidget](widget), nil)
-
-proc gtk_widget_restore_default_style*(widget: pointer) =
-  gtk_widget_set_style(cast[PGtkWidget](widget), nil)
-
-proc GTK_WIDGET_SET_FLAGS*(wid: PGtkWidget, flags: TGtkWidgetFlags): TGtkWidgetFlags =
-  cast[pGtkObject](wid).flags = cast[pGtkObject](wid).flags or (flags)
-  result = cast[pGtkObject](wid).flags
-
-proc GTK_WIDGET_UNSET_FLAGS*(wid: PGtkWidget, flags: TGtkWidgetFlags): TGtkWidgetFlags =
-  cast[pGtkObject](wid).flags = cast[pGtkObject](wid).flags and (not (flags))
-  result = cast[pGtkObject](wid).flags
-
-proc GTK_TYPE_MISC*(): GType =
-  result = gtk_misc_get_type()
-
-proc GTK_MISC*(obj: pointer): PGtkMisc =
-  result = cast[PGtkMisc](GTK_CHECK_CAST(obj, GTK_TYPE_MISC()))
-
-proc GTK_MISC_CLASS*(klass: pointer): PGtkMiscClass =
-  result = cast[PGtkMiscClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_MISC()))
-
-proc GTK_IS_MISC*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MISC())
-
-proc GTK_IS_MISC_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MISC())
-
-proc GTK_MISC_GET_CLASS*(obj: pointer): PGtkMiscClass =
-  result = cast[PGtkMiscClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_MISC()))
-
-proc GTK_TYPE_ACCEL_GROUP*(): GType =
-  result = gtk_accel_group_get_type()
-
-proc GTK_ACCEL_GROUP*(anObject: pointer): PGtkAccelGroup =
-  result = cast[PGtkAccelGroup](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GTK_TYPE_ACCEL_GROUP()))
-
-proc GTK_ACCEL_GROUP_CLASS*(klass: pointer): PGtkAccelGroupClass =
-  result = cast[PGtkAccelGroupClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_ACCEL_GROUP()))
-
-proc GTK_IS_ACCEL_GROUP*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_ACCEL_GROUP())
-
-proc GTK_IS_ACCEL_GROUP_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_ACCEL_GROUP())
-
-proc GTK_ACCEL_GROUP_GET_CLASS*(obj: pointer): PGtkAccelGroupClass =
-  result = cast[PGtkAccelGroupClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_ACCEL_GROUP()))
-
-proc accel_flags*(a: var TGtkAccelKey): guint =
-  result = (a.flag0 and bm_TGtkAccelKey_accel_flags) shr
-      bp_TGtkAccelKey_accel_flags
-
-proc set_accel_flags*(a: var TGtkAccelKey, `accel_flags`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`accel_flags` shl bp_TGtkAccelKey_accel_flags) and
-      bm_TGtkAccelKey_accel_flags)
-
-proc gtk_accel_group_ref*(AccelGroup: PGtkAccelGroup) =
-  discard g_object_ref(AccelGroup)
-
-proc gtk_accel_group_unref*(AccelGroup: PGtkAccelGroup) =
-  g_object_unref(AccelGroup)
-
-proc GTK_TYPE_CONTAINER*(): GType =
-  result = gtk_container_get_type()
-
-proc GTK_CONTAINER*(obj: pointer): PGtkContainer =
-  result = cast[PGtkContainer](GTK_CHECK_CAST(obj, GTK_TYPE_CONTAINER()))
-
-proc GTK_CONTAINER_CLASS*(klass: pointer): PGtkContainerClass =
-  result = cast[PGtkContainerClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_CONTAINER()))
-
-proc GTK_IS_CONTAINER*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CONTAINER())
-
-proc GTK_IS_CONTAINER_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CONTAINER())
-
-proc GTK_CONTAINER_GET_CLASS*(obj: pointer): PGtkContainerClass =
-  result = cast[PGtkContainerClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CONTAINER()))
-
-proc GTK_IS_RESIZE_CONTAINER*(widget: pointer): bool =
-  result = (GTK_IS_CONTAINER(widget)) and
-      ((resize_mode(cast[PGtkContainer](widget))) != cint(GTK_RESIZE_PARENT))
-
-proc border_width*(a: var TGtkContainer): guint =
-  result = (a.GtkContainer_flag0 and bm_TGtkContainer_border_width) shr
-      bp_TGtkContainer_border_width
-
-proc set_border_width*(a: var TGtkContainer, `border_width`: guint) =
-  a.GtkContainer_flag0 = a.GtkContainer_flag0 or
-      ((`border_width` shl bp_TGtkContainer_border_width) and
-      bm_TGtkContainer_border_width)
-
-proc need_resize*(a: var TGtkContainer): guint =
-  result = (a.GtkContainer_flag0 and bm_TGtkContainer_need_resize) shr
-      bp_TGtkContainer_need_resize
-
-proc set_need_resize*(a: var TGtkContainer, `need_resize`: guint) =
-  a.GtkContainer_flag0 = a.GtkContainer_flag0 or
-      ((`need_resize` shl bp_TGtkContainer_need_resize) and
-      bm_TGtkContainer_need_resize)
-
-proc resize_mode*(a: PGtkContainer): guint =
-  result = (a.GtkContainer_flag0 and bm_TGtkContainer_resize_mode) shr
-      bp_TGtkContainer_resize_mode
-
-proc set_resize_mode*(a: var TGtkContainer, `resize_mode`: guint) =
-  a.GtkContainerflag0 = a.GtkContainerflag0 or
-      ((`resize_mode` shl bp_TGtkContainer_resize_mode) and
-      bm_TGtkContainer_resize_mode)
-
-proc reallocate_redraws*(a: var TGtkContainer): guint =
-  result = (a.GtkContainerflag0 and bm_TGtkContainer_reallocate_redraws) shr
-      bp_TGtkContainer_reallocate_redraws
-
-proc set_reallocate_redraws*(a: var TGtkContainer, `reallocate_redraws`: guint) =
-  a.GtkContainerflag0 = a.GtkContainerflag0 or
-      ((`reallocate_redraws` shl bp_TGtkContainer_reallocate_redraws) and
-      bm_TGtkContainer_reallocate_redraws)
-
-proc has_focus_chain*(a: var TGtkContainer): guint =
-  result = (a.GtkContainerflag0 and bm_TGtkContainer_has_focus_chain) shr
-      bp_TGtkContainer_has_focus_chain
-
-proc set_has_focus_chain*(a: var TGtkContainer, `has_focus_chain`: guint) =
-  a.GtkContainerflag0 = a.GtkContainerflag0 or
-      ((`has_focus_chain` shl bp_TGtkContainer_has_focus_chain) and
-      bm_TGtkContainer_has_focus_chain)
-
-proc GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID*(anObject: pointer,
-    property_id: guint, pspec: pointer) =
-  write(stdout, "WARNING: invalid child property id\n")
-
-proc GTK_TYPE_BIN*(): GType =
-  result = gtk_bin_get_type()
-
-proc GTK_BIN*(obj: pointer): PGtkBin =
-  result = cast[PGtkBin](GTK_CHECK_CAST(obj, GTK_TYPE_BIN()))
-
-proc GTK_BIN_CLASS*(klass: pointer): PGtkBinClass =
-  result = cast[PGtkBinClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_BIN()))
-
-proc GTK_IS_BIN*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_BIN())
-
-proc GTK_IS_BIN_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_BIN())
-
-proc GTK_BIN_GET_CLASS*(obj: pointer): PGtkBinClass =
-  result = cast[PGtkBinClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_BIN()))
-
-proc GTK_TYPE_WINDOW*(): GType =
-  result = gtk_window_get_type()
-
-proc GTK_WINDOW*(obj: pointer): PGtkWindow =
-  result = cast[PGtkWindow](GTK_CHECK_CAST(obj, GTK_TYPE_WINDOW()))
-
-proc GTK_WINDOW_CLASS*(klass: pointer): PGtkWindowClass =
-  result = cast[PGtkWindowClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_WINDOW()))
-
-proc GTK_IS_WINDOW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_WINDOW())
-
-proc GTK_IS_WINDOW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_WINDOW())
-
-proc GTK_WINDOW_GET_CLASS*(obj: pointer): PGtkWindowClass =
-  result = cast[PGtkWindowClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_WINDOW()))
-
-proc allow_shrink*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_allow_shrink) shr
-      bp_TGtkWindow_allow_shrink
-
-proc set_allow_shrink*(a: var TGtkWindow, `allow_shrink`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`allow_shrink` shl bp_TGtkWindow_allow_shrink) and
-      bm_TGtkWindow_allow_shrink)
-
-proc allow_grow*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_allow_grow) shr
-      bp_TGtkWindow_allow_grow
-
-proc set_allow_grow*(a: var TGtkWindow, `allow_grow`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`allow_grow` shl bp_TGtkWindow_allow_grow) and
-      bm_TGtkWindow_allow_grow)
-
-proc configure_notify_received*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_configure_notify_received) shr
-      bp_TGtkWindow_configure_notify_received
-
-proc set_configure_notify_received*(a: var TGtkWindow,
-                                    `configure_notify_received`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`configure_notify_received` shl
-      bp_TGtkWindow_configure_notify_received) and
-      bm_TGtkWindow_configure_notify_received)
-
-proc need_default_position*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_need_default_position) shr
-      bp_TGtkWindow_need_default_position
-
-proc set_need_default_position*(a: var TGtkWindow,
-                                `need_default_position`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`need_default_position` shl bp_TGtkWindow_need_default_position) and
-      bm_TGtkWindow_need_default_position)
-
-proc need_default_size*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_need_default_size) shr
-      bp_TGtkWindow_need_default_size
-
-proc set_need_default_size*(a: var TGtkWindow, `need_default_size`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`need_default_size` shl bp_TGtkWindow_need_default_size) and
-      bm_TGtkWindow_need_default_size)
-
-proc position*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_position) shr bp_TGtkWindow_position
-
-proc set_position*(a: var TGtkWindow, `position`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`position` shl bp_TGtkWindow_position) and bm_TGtkWindow_position)
-
-proc get_type*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_type) shr bp_TGtkWindow_type
-
-proc set_type*(a: var TGtkWindow, `type`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`type` shl bp_TGtkWindow_type) and bm_TGtkWindow_type)
-
-proc has_user_ref_count*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_has_user_ref_count) shr
-      bp_TGtkWindow_has_user_ref_count
-
-proc set_has_user_ref_count*(a: var TGtkWindow, `has_user_ref_count`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`has_user_ref_count` shl bp_TGtkWindow_has_user_ref_count) and
-      bm_TGtkWindow_has_user_ref_count)
-
-proc has_focus*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_has_focus) shr bp_TGtkWindow_has_focus
-
-proc set_has_focus*(a: var TGtkWindow, `has_focus`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`has_focus` shl bp_TGtkWindow_has_focus) and bm_TGtkWindow_has_focus)
-
-proc modal*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_modal) shr bp_TGtkWindow_modal
-
-proc set_modal*(a: var TGtkWindow, `modal`: guint) =
-  a.GtkWindow_flag0 = a.GtkWindow_flag0 or
-      ((`modal` shl bp_TGtkWindow_modal) and bm_TGtkWindow_modal)
-
-proc destroy_with_parent*(a: var TGtkWindow): guint =
-  result = (a.GtkWindow_flag0 and bm_TGtkWindow_destroy_with_parent) shr
-      bp_TGtkWindow_destroy_with_parent
-
-proc set_destroy_with_parent*(a: var TGtkWindow, `destroy_with_parent`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`destroy_with_parent` shl bp_TGtkWindow_destroy_with_parent) and
-      bm_TGtkWindow_destroy_with_parent)
-
-proc has_frame*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_has_frame) shr bp_TGtkWindow_has_frame
-
-proc set_has_frame*(a: var TGtkWindow, `has_frame`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`has_frame` shl bp_TGtkWindow_has_frame) and bm_TGtkWindow_has_frame)
-
-proc iconify_initially*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_iconify_initially) shr
-      bp_TGtkWindow_iconify_initially
-
-proc set_iconify_initially*(a: var TGtkWindow, `iconify_initially`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`iconify_initially` shl bp_TGtkWindow_iconify_initially) and
-      bm_TGtkWindow_iconify_initially)
-
-proc stick_initially*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_stick_initially) shr
-      bp_TGtkWindow_stick_initially
-
-proc set_stick_initially*(a: var TGtkWindow, `stick_initially`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`stick_initially` shl bp_TGtkWindow_stick_initially) and
-      bm_TGtkWindow_stick_initially)
-
-proc maximize_initially*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_maximize_initially) shr
-      bp_TGtkWindow_maximize_initially
-
-proc set_maximize_initially*(a: var TGtkWindow, `maximize_initially`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`maximize_initially` shl bp_TGtkWindow_maximize_initially) and
-      bm_TGtkWindow_maximize_initially)
-
-proc decorated*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_decorated) shr bp_TGtkWindow_decorated
-
-proc set_decorated*(a: var TGtkWindow, `decorated`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`decorated` shl bp_TGtkWindow_decorated) and bm_TGtkWindow_decorated)
-
-proc type_hint*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_type_hint) shr bp_TGtkWindow_type_hint
-
-proc set_type_hint*(a: var TGtkWindow, `type_hint`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`type_hint` shl bp_TGtkWindow_type_hint) and bm_TGtkWindow_type_hint)
-
-proc gravity*(a: var TGtkWindow): guint =
-  result = (a.GtkWindowflag0 and bm_TGtkWindow_gravity) shr bp_TGtkWindow_gravity
-
-proc set_gravity*(a: var TGtkWindow, `gravity`: guint) =
-  a.GtkWindowflag0 = a.GtkWindowflag0 or
-      ((`gravity` shl bp_TGtkWindow_gravity) and bm_TGtkWindow_gravity)
-
-proc GTK_TYPE_WINDOW_GROUP*(): GType =
-  result = gtk_window_group_get_type()
-
-proc GTK_WINDOW_GROUP*(anObject: pointer): PGtkWindowGroup =
-  result = cast[PGtkWindowGroup](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GTK_TYPE_WINDOW_GROUP()))
-
-proc GTK_WINDOW_GROUP_CLASS*(klass: pointer): PGtkWindowGroupClass =
-  result = cast[PGtkWindowGroupClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_WINDOW_GROUP()))
-
-proc GTK_IS_WINDOW_GROUP*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_WINDOW_GROUP())
-
-proc GTK_IS_WINDOW_GROUP_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_WINDOW_GROUP())
-
-proc GTK_WINDOW_GROUP_GET_CLASS*(obj: pointer): PGtkWindowGroupClass =
-  result = cast[PGtkWindowGroupClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_WINDOW_GROUP()))
-
-proc gtk_window_position*(window: PGtkWindow, position: TGtkWindowPosition) =
-  gtk_window_set_position(window, position)
-
-proc GTK_TYPE_LABEL*(): GType =
-  result = gtk_label_get_type()
-
-proc GTK_LABEL*(obj: pointer): PGtkLabel =
-  result = cast[PGtkLabel](GTK_CHECK_CAST(obj, GTK_TYPE_LABEL()))
-
-proc GTK_LABEL_CLASS*(klass: pointer): PGtkLabelClass =
-  result = cast[PGtkLabelClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_LABEL()))
-
-proc GTK_IS_LABEL*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_LABEL())
-
-proc GTK_IS_LABEL_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_LABEL())
-
-proc GTK_LABEL_GET_CLASS*(obj: pointer): PGtkLabelClass =
-  result = cast[PGtkLabelClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_LABEL()))
-
-proc jtype*(a: var TGtkLabel): guint =
-  result = (a.GtkLabelflag0 and bm_TGtkLabel_jtype) shr bp_TGtkLabel_jtype
-
-proc set_jtype*(a: var TGtkLabel, `jtype`: guint) =
-  a.GtkLabelflag0 = a.GtkLabelflag0 or
-      (int16(`jtype` shl bp_TGtkLabel_jtype) and bm_TGtkLabel_jtype)
-
-proc wrap*(a: var TGtkLabel): guint =
-  result = (a.GtkLabelflag0 and bm_TGtkLabel_wrap) shr bp_TGtkLabel_wrap
-
-proc set_wrap*(a: var TGtkLabel, `wrap`: guint) =
-  a.GtkLabelflag0 = a.GtkLabelflag0 or (int16(`wrap` shl bp_TGtkLabel_wrap) and bm_TGtkLabel_wrap)
-
-proc use_underline*(a: var TGtkLabel): guint =
-  result = (a.GtkLabelflag0 and bm_TGtkLabel_use_underline) shr
-      bp_TGtkLabel_use_underline
-
-proc set_use_underline*(a: var TGtkLabel, `use_underline`: guint) =
-  a.GtkLabelflag0 = a.GtkLabelflag0 or
-      (int16(`use_underline` shl bp_TGtkLabel_use_underline) and
-      bm_TGtkLabel_use_underline)
-
-proc use_markup*(a: var TGtkLabel): guint =
-  result = (a.GtkLabelflag0 and bm_TGtkLabel_use_markup) shr bp_TGtkLabel_use_markup
-
-proc set_use_markup*(a: var TGtkLabel, `use_markup`: guint) =
-  a.GtkLabelflag0 = a.GtkLabelflag0 or
-      (int16(`use_markup` shl bp_TGtkLabel_use_markup) and bm_TGtkLabel_use_markup)
-
-proc GTK_TYPE_ACCEL_LABEL*(): GType =
-  result = gtk_accel_label_get_type()
-
-proc GTK_ACCEL_LABEL*(obj: pointer): PGtkAccelLabel =
-  result = cast[PGtkAccelLabel](GTK_CHECK_CAST(obj, GTK_TYPE_ACCEL_LABEL()))
-
-proc GTK_ACCEL_LABEL_CLASS*(klass: pointer): PGtkAccelLabelClass =
-  result = cast[PGtkAccelLabelClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ACCEL_LABEL()))
-
-proc GTK_IS_ACCEL_LABEL*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ACCEL_LABEL())
-
-proc GTK_IS_ACCEL_LABEL_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ACCEL_LABEL())
-
-proc GTK_ACCEL_LABEL_GET_CLASS*(obj: pointer): PGtkAccelLabelClass =
-  result = cast[PGtkAccelLabelClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ACCEL_LABEL()))
-
-proc latin1_to_char*(a: var TGtkAccelLabelClass): guint =
-  result = (a.GtkAccelLabelClassflag0 and bm_TGtkAccelLabelClass_latin1_to_char) shr
-      bp_TGtkAccelLabelClass_latin1_to_char
-
-proc set_latin1_to_char*(a: var TGtkAccelLabelClass, `latin1_to_char`: guint) =
-  a.GtkAccelLabelClassflag0 = a.GtkAccelLabelClassflag0 or
-      (int16(`latin1_to_char` shl bp_TGtkAccelLabelClass_latin1_to_char) and
-      bm_TGtkAccelLabelClass_latin1_to_char)
-
-proc gtk_accel_label_accelerator_width*(accel_label: PGtkAccelLabel): guint =
-  result = gtk_accel_label_get_accel_width(accel_label)
-
-proc GTK_TYPE_ACCESSIBLE*(): GType =
-  result = gtk_accessible_get_type()
-
-proc GTK_ACCESSIBLE*(obj: pointer): PGtkAccessible =
-  result = cast[PGtkAccessible](GTK_CHECK_CAST(obj, GTK_TYPE_ACCESSIBLE()))
-
-proc GTK_ACCESSIBLE_CLASS*(klass: pointer): PGtkAccessibleClass =
-  result = cast[PGtkAccessibleClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ACCESSIBLE()))
-
-proc GTK_IS_ACCESSIBLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ACCESSIBLE())
-
-proc GTK_IS_ACCESSIBLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ACCESSIBLE())
-
-proc GTK_ACCESSIBLE_GET_CLASS*(obj: pointer): PGtkAccessibleClass =
-  result = cast[PGtkAccessibleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ACCESSIBLE()))
-
-proc GTK_TYPE_ADJUSTMENT*(): GType =
-  result = gtk_adjustment_get_type()
-
-proc GTK_ADJUSTMENT*(obj: pointer): PGtkAdjustment =
-  result = cast[PGtkAdjustment](GTK_CHECK_CAST(obj, GTK_TYPE_ADJUSTMENT()))
-
-proc GTK_ADJUSTMENT_CLASS*(klass: pointer): PGtkAdjustmentClass =
-  result = cast[PGtkAdjustmentClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ADJUSTMENT()))
-
-proc GTK_IS_ADJUSTMENT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ADJUSTMENT())
-
-proc GTK_IS_ADJUSTMENT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ADJUSTMENT())
-
-proc GTK_ADJUSTMENT_GET_CLASS*(obj: pointer): PGtkAdjustmentClass =
-  result = cast[PGtkAdjustmentClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ADJUSTMENT()))
-
-proc GTK_TYPE_ALIGNMENT*(): GType =
-  result = gtk_alignment_get_type()
-
-proc GTK_ALIGNMENT*(obj: pointer): PGtkAlignment =
-  result = cast[PGtkAlignment](GTK_CHECK_CAST(obj, GTK_TYPE_ALIGNMENT()))
-
-proc GTK_ALIGNMENT_CLASS*(klass: pointer): PGtkAlignmentClass =
-  result = cast[PGtkAlignmentClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ALIGNMENT()))
-
-proc GTK_IS_ALIGNMENT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ALIGNMENT())
-
-proc GTK_IS_ALIGNMENT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ALIGNMENT())
-
-proc GTK_ALIGNMENT_GET_CLASS*(obj: pointer): PGtkAlignmentClass =
-  result = cast[PGtkAlignmentClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ALIGNMENT()))
-
-proc GTK_TYPE_FRAME*(): GType =
-  result = gtk_frame_get_type()
-
-proc GTK_FRAME*(obj: pointer): PGtkFrame =
-  result = cast[PGtkFrame](GTK_CHECK_CAST(obj, GTK_TYPE_FRAME()))
-
-proc GTK_FRAME_CLASS*(klass: pointer): PGtkFrameClass =
-  result = cast[PGtkFrameClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_FRAME()))
-
-proc GTK_IS_FRAME*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_FRAME())
-
-proc GTK_IS_FRAME_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_FRAME())
-
-proc GTK_FRAME_GET_CLASS*(obj: pointer): PGtkFrameClass =
-  result = cast[PGtkFrameClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_FRAME()))
-
-proc GTK_TYPE_ASPECT_FRAME*(): GType =
-  result = gtk_aspect_frame_get_type()
-
-proc GTK_ASPECT_FRAME*(obj: pointer): PGtkAspectFrame =
-  result = cast[PGtkAspectFrame](GTK_CHECK_CAST(obj, GTK_TYPE_ASPECT_FRAME()))
-
-proc GTK_ASPECT_FRAME_CLASS*(klass: pointer): PGtkAspectFrameClass =
-  result = cast[PGtkAspectFrameClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_ASPECT_FRAME()))
-
-proc GTK_IS_ASPECT_FRAME*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ASPECT_FRAME())
-
-proc GTK_IS_ASPECT_FRAME_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ASPECT_FRAME())
-
-proc GTK_ASPECT_FRAME_GET_CLASS*(obj: pointer): PGtkAspectFrameClass =
-  result = cast[PGtkAspectFrameClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ASPECT_FRAME()))
-
-proc GTK_TYPE_ARROW*(): GType =
-  result = gtk_arrow_get_type()
-
-proc GTK_ARROW*(obj: pointer): PGtkArrow =
-  result = cast[PGtkArrow](GTK_CHECK_CAST(obj, GTK_TYPE_ARROW()))
-
-proc GTK_ARROW_CLASS*(klass: pointer): PGtkArrowClass =
-  result = cast[PGtkArrowClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ARROW()))
-
-proc GTK_IS_ARROW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ARROW())
-
-proc GTK_IS_ARROW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ARROW())
-
-proc GTK_ARROW_GET_CLASS*(obj: pointer): PGtkArrowClass =
-  result = cast[PGtkArrowClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ARROW()))
-
-proc parsed*(a: var TGtkBindingSet): guint =
-  result = (a.flag0 and bm_TGtkBindingSet_parsed) shr
-      bp_TGtkBindingSet_parsed
-
-proc set_parsed*(a: var TGtkBindingSet, `parsed`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`parsed` shl bp_TGtkBindingSet_parsed) and bm_TGtkBindingSet_parsed)
-
-proc destroyed*(a: var TGtkBindingEntry): guint =
-  result = (a.flag0 and bm_TGtkBindingEntry_destroyed) shr
-      bp_TGtkBindingEntry_destroyed
-
-proc set_destroyed*(a: var TGtkBindingEntry, `destroyed`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`destroyed` shl bp_TGtkBindingEntry_destroyed) and
-      bm_TGtkBindingEntry_destroyed)
-
-proc in_emission*(a: var TGtkBindingEntry): guint =
-  result = (a.flag0 and bm_TGtkBindingEntry_in_emission) shr
-      bp_TGtkBindingEntry_in_emission
-
-proc set_in_emission*(a: var TGtkBindingEntry, `in_emission`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`in_emission` shl bp_TGtkBindingEntry_in_emission) and
-      bm_TGtkBindingEntry_in_emission)
-
-proc gtk_binding_entry_add*(binding_set: PGtkBindingSet, keyval: guint,
-                            modifiers: TGdkModifierType) =
-  gtk_binding_entry_clear(binding_set, keyval, modifiers)
-
-proc GTK_TYPE_BOX*(): GType =
-  result = gtk_box_get_type()
-
-proc GTK_BOX*(obj: pointer): PGtkBox =
-  result = cast[PGtkBox](GTK_CHECK_CAST(obj, GTK_TYPE_BOX()))
-
-proc GTK_BOX_CLASS*(klass: pointer): PGtkBoxClass =
-  result = cast[PGtkBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_BOX()))
-
-proc GTK_IS_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_BOX())
-
-proc GTK_IS_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_BOX())
-
-proc GTK_BOX_GET_CLASS*(obj: pointer): PGtkBoxClass =
-  result = cast[PGtkBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_BOX()))
-
-proc homogeneous*(a: var TGtkBox): guint =
-  result = (a.GtkBoxflag0 and bm_TGtkBox_homogeneous) shr bp_TGtkBox_homogeneous
-
-proc set_homogeneous*(a: var TGtkBox, `homogeneous`: guint) =
-  a.GtkBoxflag0 = a.GtkBoxflag0 or
-      (int16(`homogeneous` shl bp_TGtkBox_homogeneous) and bm_TGtkBox_homogeneous)
-
-proc expand*(a: var TGtkBoxChild): guint =
-  result = (a.flag0 and bm_TGtkBoxChild_expand) shr bp_TGtkBoxChild_expand
-
-proc set_expand*(a: var TGtkBoxChild, `expand`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`expand` shl bp_TGtkBoxChild_expand) and bm_TGtkBoxChild_expand)
-
-proc fill*(a: var TGtkBoxChild): guint =
-  result = (a.flag0 and bm_TGtkBoxChild_fill) shr bp_TGtkBoxChild_fill
-
-proc set_fill*(a: var TGtkBoxChild, `fill`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`fill` shl bp_TGtkBoxChild_fill) and bm_TGtkBoxChild_fill)
-
-proc pack*(a: var TGtkBoxChild): guint =
-  result = (a.flag0 and bm_TGtkBoxChild_pack) shr bp_TGtkBoxChild_pack
-
-proc set_pack*(a: var TGtkBoxChild, `pack`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pack` shl bp_TGtkBoxChild_pack) and bm_TGtkBoxChild_pack)
-
-proc is_secondary*(a: var TGtkBoxChild): guint =
-  result = (a.flag0 and bm_TGtkBoxChild_is_secondary) shr
-      bp_TGtkBoxChild_is_secondary
-
-proc set_is_secondary*(a: var TGtkBoxChild, `is_secondary`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_secondary` shl bp_TGtkBoxChild_is_secondary) and
-      bm_TGtkBoxChild_is_secondary)
-
-proc GTK_TYPE_BUTTON_BOX*(): GType =
-  result = gtk_button_box_get_type()
-
-proc GTK_BUTTON_BOX*(obj: pointer): PGtkButtonBox =
-  result = cast[PGtkButtonBox](GTK_CHECK_CAST(obj, GTK_TYPE_BUTTON_BOX()))
-
-proc GTK_BUTTON_BOX_CLASS*(klass: pointer): PGtkButtonBoxClass =
-  result = cast[PGtkButtonBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_BUTTON_BOX()))
-
-proc GTK_IS_BUTTON_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_BUTTON_BOX())
-
-proc GTK_IS_BUTTON_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_BUTTON_BOX())
-
-proc GTK_BUTTON_BOX_GET_CLASS*(obj: pointer): PGtkButtonBoxClass =
-  result = cast[PGtkButtonBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_BUTTON_BOX()))
-
-proc gtk_button_box_set_spacing*(b: pointer, s: gint) =
-  gtk_box_set_spacing(GTK_BOX(b), s)
-
-proc gtk_button_box_get_spacing*(b: pointer): gint =
-  result = gtk_box_get_spacing(GTK_BOX(b))
-
-proc GTK_TYPE_BUTTON*(): GType =
-  result = gtk_button_get_type()
-
-proc GTK_BUTTON*(obj: pointer): PGtkButton =
-  result = cast[PGtkButton](GTK_CHECK_CAST(obj, GTK_TYPE_BUTTON()))
-
-proc GTK_BUTTON_CLASS*(klass: pointer): PGtkButtonClass =
-  result = cast[PGtkButtonClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_BUTTON()))
-
-proc GTK_IS_BUTTON*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_BUTTON())
-
-proc GTK_IS_BUTTON_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_BUTTON())
-
-proc GTK_BUTTON_GET_CLASS*(obj: pointer): PGtkButtonClass =
-  result = cast[PGtkButtonClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_BUTTON()))
-
-proc constructed*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_constructed) shr
-      bp_TGtkButton_constructed
-
-proc set_constructed*(a: var TGtkButton, `constructed`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`constructed` shl bp_TGtkButton_constructed) and
-      bm_TGtkButton_constructed)
-
-proc in_button*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_in_button) shr bp_TGtkButton_in_button
-
-proc set_in_button*(a: var TGtkButton, `in_button`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`in_button` shl bp_TGtkButton_in_button) and bm_TGtkButton_in_button)
-
-proc button_down*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_button_down) shr
-      bp_TGtkButton_button_down
-
-proc set_button_down*(a: var TGtkButton, `button_down`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`button_down` shl bp_TGtkButton_button_down) and
-      bm_TGtkButton_button_down)
-
-proc relief*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_relief) shr bp_TGtkButton_relief
-
-proc set_relief*(a: var TGtkButton, `relief`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`relief` shl bp_TGtkButton_relief) and bm_TGtkButton_relief)
-
-proc use_underline*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_use_underline) shr
-      bp_TGtkButton_use_underline
-
-proc set_use_underline*(a: var TGtkButton, `use_underline`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`use_underline` shl bp_TGtkButton_use_underline) and
-      bm_TGtkButton_use_underline)
-
-proc use_stock*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_use_stock) shr bp_TGtkButton_use_stock
-
-proc set_use_stock*(a: var TGtkButton, `use_stock`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`use_stock` shl bp_TGtkButton_use_stock) and bm_TGtkButton_use_stock)
-
-proc depressed*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_depressed) shr bp_TGtkButton_depressed
-
-proc set_depressed*(a: var TGtkButton, `depressed`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`depressed` shl bp_TGtkButton_depressed) and bm_TGtkButton_depressed)
-
-proc depress_on_activate*(a: var TGtkButton): guint =
-  result = (a.GtkButtonflag0 and bm_TGtkButton_depress_on_activate) shr
-      bp_TGtkButton_depress_on_activate
-
-proc set_depress_on_activate*(a: var TGtkButton, `depress_on_activate`: guint) =
-  a.GtkButtonflag0 = a.GtkButtonflag0 or
-      (int16(`depress_on_activate` shl bp_TGtkButton_depress_on_activate) and
-      bm_TGtkButton_depress_on_activate)
-
-proc GTK_TYPE_CALENDAR*(): GType =
-  result = gtk_calendar_get_type()
-
-proc GTK_CALENDAR*(obj: pointer): PGtkCalendar =
-  result = cast[PGtkCalendar](GTK_CHECK_CAST(obj, GTK_TYPE_CALENDAR()))
-
-proc GTK_CALENDAR_CLASS*(klass: pointer): PGtkCalendarClass =
-  result = cast[PGtkCalendarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_CALENDAR()))
-
-proc GTK_IS_CALENDAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CALENDAR())
-
-proc GTK_IS_CALENDAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CALENDAR())
-
-proc GTK_CALENDAR_GET_CLASS*(obj: pointer): PGtkCalendarClass =
-  result = cast[PGtkCalendarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CALENDAR()))
-
-proc GTK_TYPE_CELL_EDITABLE*(): GType =
-  result = gtk_cell_editable_get_type()
-
-proc GTK_CELL_EDITABLE*(obj: pointer): PGtkCellEditable =
-  result = cast[PGtkCellEditable](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GTK_TYPE_CELL_EDITABLE()))
-
-proc GTK_CELL_EDITABLE_CLASS*(obj: pointer): PGtkCellEditableIface =
-  result = cast[PGtkCellEditableIface](G_TYPE_CHECK_CLASS_CAST(obj,
-      GTK_TYPE_CELL_EDITABLE()))
-
-proc GTK_IS_CELL_EDITABLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_CELL_EDITABLE())
-
-proc GTK_CELL_EDITABLE_GET_IFACE*(obj: pointer): PGtkCellEditableIface =
-  result = cast[PGtkCellEditableIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      GTK_TYPE_CELL_EDITABLE()))
-
-proc GTK_TYPE_CELL_RENDERER*(): GType =
-  result = gtk_cell_renderer_get_type()
-
-proc GTK_CELL_RENDERER*(obj: pointer): PGtkCellRenderer =
-  result = cast[PGtkCellRenderer](GTK_CHECK_CAST(obj, GTK_TYPE_CELL_RENDERER()))
-
-proc GTK_CELL_RENDERER_CLASS*(klass: pointer): PGtkCellRendererClass =
-  result = cast[PGtkCellRendererClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CELL_RENDERER()))
-
-proc GTK_IS_CELL_RENDERER*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CELL_RENDERER())
-
-proc GTK_IS_CELL_RENDERER_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CELL_RENDERER())
-
-proc GTK_CELL_RENDERER_GET_CLASS*(obj: pointer): PGtkCellRendererClass =
-  result = cast[PGtkCellRendererClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CELL_RENDERER()))
-
-proc mode*(a: var TGtkCellRenderer): guint =
-  result = (a.GtkCellRendererflag0 and bm_TGtkCellRenderer_mode) shr
-      bp_TGtkCellRenderer_mode
-
-proc set_mode*(a: var TGtkCellRenderer, `mode`: guint) =
-  a.GtkCellRendererflag0 = a.GtkCellRendererflag0 or
-      (int16(`mode` shl bp_TGtkCellRenderer_mode) and bm_TGtkCellRenderer_mode)
-
-proc visible*(a: var TGtkCellRenderer): guint =
-  result = (a.GtkCellRendererflag0 and bm_TGtkCellRenderer_visible) shr
-      bp_TGtkCellRenderer_visible
-
-proc set_visible*(a: var TGtkCellRenderer, `visible`: guint) =
-  a.GtkCellRendererflag0 = a.GtkCellRendererflag0 or
-      (int16(`visible` shl bp_TGtkCellRenderer_visible) and
-      bm_TGtkCellRenderer_visible)
-
-proc is_expander*(a: var TGtkCellRenderer): guint =
-  result = (a.GtkCellRendererflag0 and bm_TGtkCellRenderer_is_expander) shr
-      bp_TGtkCellRenderer_is_expander
-
-proc set_is_expander*(a: var TGtkCellRenderer, `is_expander`: guint) =
-  a.GtkCellRendererflag0 = a.GtkCellRendererflag0 or
-      (int16(`is_expander` shl bp_TGtkCellRenderer_is_expander) and
-      bm_TGtkCellRenderer_is_expander)
-
-proc is_expanded*(a: var TGtkCellRenderer): guint =
-  result = (a.GtkCellRendererflag0 and bm_TGtkCellRenderer_is_expanded) shr
-      bp_TGtkCellRenderer_is_expanded
-
-proc set_is_expanded*(a: var TGtkCellRenderer, `is_expanded`: guint) =
-  a.GtkCellRendererflag0 = a.GtkCellRendererflag0 or
-      (int16(`is_expanded` shl bp_TGtkCellRenderer_is_expanded) and
-      bm_TGtkCellRenderer_is_expanded)
-
-proc cell_background_set*(a: var TGtkCellRenderer): guint =
-  result = (a.GtkCellRendererflag0 and bm_TGtkCellRenderer_cell_background_set) shr
-      bp_TGtkCellRenderer_cell_background_set
-
-proc set_cell_background_set*(a: var TGtkCellRenderer,
-                              `cell_background_set`: guint) =
-  a.GtkCellRendererflag0 = a.GtkCellRendererflag0 or
-      (int16(`cell_background_set` shl bp_TGtkCellRenderer_cell_background_set) and
-      bm_TGtkCellRenderer_cell_background_set)
-
-proc GTK_TYPE_CELL_RENDERER_TEXT*(): GType =
-  result = gtk_cell_renderer_text_get_type()
-
-proc GTK_CELL_RENDERER_TEXT*(obj: pointer): PGtkCellRendererText =
-  result = cast[PGtkCellRendererText](GTK_CHECK_CAST(obj, GTK_TYPE_CELL_RENDERER_TEXT()))
-
-proc GTK_CELL_RENDERER_TEXT_CLASS*(klass: pointer): PGtkCellRendererTextClass =
-  result = cast[PGtkCellRendererTextClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CELL_RENDERER_TEXT()))
-
-proc GTK_IS_CELL_RENDERER_TEXT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CELL_RENDERER_TEXT())
-
-proc GTK_IS_CELL_RENDERER_TEXT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CELL_RENDERER_TEXT())
-
-proc GTK_CELL_RENDERER_TEXT_GET_CLASS*(obj: pointer): PGtkCellRendererTextClass =
-  result = cast[PGtkCellRendererTextClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_CELL_RENDERER_TEXT()))
-
-proc strikethrough*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_strikethrough) shr
-      bp_TGtkCellRendererText_strikethrough
-
-proc set_strikethrough*(a: var TGtkCellRendererText, `strikethrough`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`strikethrough` shl bp_TGtkCellRendererText_strikethrough) and
-      bm_TGtkCellRendererText_strikethrough)
-
-proc editable*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_editable) shr
-      bp_TGtkCellRendererText_editable
-
-proc set_editable*(a: var TGtkCellRendererText, `editable`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`editable` shl bp_TGtkCellRendererText_editable) and
-      bm_TGtkCellRendererText_editable)
-
-proc scale_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_scale_set) shr
-      bp_TGtkCellRendererText_scale_set
-
-proc set_scale_set*(a: var TGtkCellRendererText, `scale_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`scale_set` shl bp_TGtkCellRendererText_scale_set) and
-      bm_TGtkCellRendererText_scale_set)
-
-proc foreground_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_foreground_set) shr
-      bp_TGtkCellRendererText_foreground_set
-
-proc set_foreground_set*(a: var TGtkCellRendererText, `foreground_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`foreground_set` shl bp_TGtkCellRendererText_foreground_set) and
-      bm_TGtkCellRendererText_foreground_set)
-
-proc background_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_background_set) shr
-      bp_TGtkCellRendererText_background_set
-
-proc set_background_set*(a: var TGtkCellRendererText, `background_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`background_set` shl bp_TGtkCellRendererText_background_set) and
-      bm_TGtkCellRendererText_background_set)
-
-proc underline_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_underline_set) shr
-      bp_TGtkCellRendererText_underline_set
-
-proc set_underline_set*(a: var TGtkCellRendererText, `underline_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`underline_set` shl bp_TGtkCellRendererText_underline_set) and
-      bm_TGtkCellRendererText_underline_set)
-
-proc rise_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_rise_set) shr
-      bp_TGtkCellRendererText_rise_set
-
-proc set_rise_set*(a: var TGtkCellRendererText, `rise_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`rise_set` shl bp_TGtkCellRendererText_rise_set) and
-      bm_TGtkCellRendererText_rise_set)
-
-proc strikethrough_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_strikethrough_set) shr
-      bp_TGtkCellRendererText_strikethrough_set
-
-proc set_strikethrough_set*(a: var TGtkCellRendererText,
-                            `strikethrough_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`strikethrough_set` shl bp_TGtkCellRendererText_strikethrough_set) and
-      bm_TGtkCellRendererText_strikethrough_set)
-
-proc editable_set*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_editable_set) shr
-      bp_TGtkCellRendererText_editable_set
-
-proc set_editable_set*(a: var TGtkCellRendererText, `editable_set`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`editable_set` shl bp_TGtkCellRendererText_editable_set) and
-      bm_TGtkCellRendererText_editable_set)
-
-proc calc_fixed_height*(a: var TGtkCellRendererText): guint =
-  result = (a.GtkCellRendererTextflag0 and bm_TGtkCellRendererText_calc_fixed_height) shr
-      bp_TGtkCellRendererText_calc_fixed_height
-
-proc set_calc_fixed_height*(a: var TGtkCellRendererText,
-                            `calc_fixed_height`: guint) =
-  a.GtkCellRendererTextflag0 = a.GtkCellRendererTextflag0 or
-      (int16(`calc_fixed_height` shl bp_TGtkCellRendererText_calc_fixed_height) and
-      bm_TGtkCellRendererText_calc_fixed_height)
-
-proc GTK_TYPE_CELL_RENDERER_TOGGLE*(): GType =
-  result = gtk_cell_renderer_toggle_get_type()
-
-proc GTK_CELL_RENDERER_TOGGLE*(obj: pointer): PGtkCellRendererToggle =
-  result = cast[PGtkCellRendererToggle](GTK_CHECK_CAST(obj,
-      GTK_TYPE_CELL_RENDERER_TOGGLE()))
-
-proc GTK_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): PGtkCellRendererToggleClass =
-  result = cast[PGtkCellRendererToggleClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CELL_RENDERER_TOGGLE()))
-
-proc GTK_IS_CELL_RENDERER_TOGGLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CELL_RENDERER_TOGGLE())
-
-proc GTK_IS_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CELL_RENDERER_TOGGLE())
-
-proc GTK_CELL_RENDERER_TOGGLE_GET_CLASS*(obj: pointer): PGtkCellRendererToggleClass =
-  result = cast[PGtkCellRendererToggleClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_CELL_RENDERER_TOGGLE()))
-
-proc active*(a: var TGtkCellRendererToggle): guint =
-  result = (a.GtkCellRendererToggleflag0 and bm_TGtkCellRendererToggle_active) shr
-      bp_TGtkCellRendererToggle_active
-
-proc set_active*(a: var TGtkCellRendererToggle, `active`: guint) =
-  a.GtkCellRendererToggleflag0 = a.GtkCellRendererToggleflag0 or
-      (int16(`active` shl bp_TGtkCellRendererToggle_active) and
-      bm_TGtkCellRendererToggle_active)
-
-proc activatable*(a: var TGtkCellRendererToggle): guint =
-  result = (a.GtkCellRendererToggleflag0 and bm_TGtkCellRendererToggle_activatable) shr
-      bp_TGtkCellRendererToggle_activatable
-
-proc set_activatable*(a: var TGtkCellRendererToggle, `activatable`: guint) =
-  a.GtkCellRendererToggleflag0 = a.GtkCellRendererToggleflag0 or
-      (int16(`activatable` shl bp_TGtkCellRendererToggle_activatable) and
-      bm_TGtkCellRendererToggle_activatable)
-
-proc radio*(a: var TGtkCellRendererToggle): guint =
-  result = (a.GtkCellRendererToggleflag0 and bm_TGtkCellRendererToggle_radio) shr
-      bp_TGtkCellRendererToggle_radio
-
-proc set_radio*(a: var TGtkCellRendererToggle, `radio`: guint) =
-  a.GtkCellRendererToggleflag0 = a.GtkCellRendererToggleflag0 or
-      (int16(`radio` shl bp_TGtkCellRendererToggle_radio) and
-      bm_TGtkCellRendererToggle_radio)
-
-proc GTK_TYPE_CELL_RENDERER_PIXBUF*(): GType =
-  result = gtk_cell_renderer_pixbuf_get_type()
-
-proc GTK_CELL_RENDERER_PIXBUF*(obj: pointer): PGtkCellRendererPixbuf =
-  result = cast[PGtkCellRendererPixbuf](GTK_CHECK_CAST(obj,
-      GTK_TYPE_CELL_RENDERER_PIXBUF()))
-
-proc GTK_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): PGtkCellRendererPixbufClass =
-  result = cast[PGtkCellRendererPixbufClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CELL_RENDERER_PIXBUF()))
-
-proc GTK_IS_CELL_RENDERER_PIXBUF*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CELL_RENDERER_PIXBUF())
-
-proc GTK_IS_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CELL_RENDERER_PIXBUF())
-
-proc GTK_CELL_RENDERER_PIXBUF_GET_CLASS*(obj: pointer): PGtkCellRendererPixbufClass =
-  result = cast[PGtkCellRendererPixbufClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_CELL_RENDERER_PIXBUF()))
-
-proc GTK_TYPE_ITEM*(): GType =
-  result = gtk_item_get_type()
-
-proc GTK_ITEM*(obj: pointer): PGtkItem =
-  result = cast[PGtkItem](GTK_CHECK_CAST(obj, GTK_TYPE_ITEM()))
-
-proc GTK_ITEM_CLASS*(klass: pointer): PGtkItemClass =
-  result = cast[PGtkItemClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ITEM()))
-
-proc GTK_IS_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ITEM())
-
-proc GTK_IS_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ITEM())
-
-proc GTK_ITEM_GET_CLASS*(obj: pointer): PGtkItemClass =
-  result = cast[PGtkItemClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ITEM()))
-
-proc GTK_TYPE_MENU_ITEM*(): GType =
-  result = gtk_menu_item_get_type()
-
-proc GTK_MENU_ITEM*(obj: pointer): PGtkMenuItem =
-  result = cast[PGtkMenuItem](GTK_CHECK_CAST(obj, GTK_TYPE_MENU_ITEM()))
-
-proc GTK_MENU_ITEM_CLASS*(klass: pointer): PGtkMenuItemClass =
-  result = cast[PGtkMenuItemClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_MENU_ITEM()))
-
-proc GTK_IS_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MENU_ITEM())
-
-proc GTK_IS_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MENU_ITEM())
-
-proc GTK_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkMenuItemClass =
-  result = cast[PGtkMenuItemClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_MENU_ITEM()))
-
-proc show_submenu_indicator*(a: var TGtkMenuItem): guint =
-  result = (a.GtkMenuItemflag0 and bm_TGtkMenuItem_show_submenu_indicator) shr
-      bp_TGtkMenuItem_show_submenu_indicator
-
-proc set_show_submenu_indicator*(a: var TGtkMenuItem,
-                                 `show_submenu_indicator`: guint) =
-  a.GtkMenuItemflag0 = a.GtkMenuItemflag0 or
-      (int16(`show_submenu_indicator` shl bp_TGtkMenuItem_show_submenu_indicator) and
-      bm_TGtkMenuItem_show_submenu_indicator)
-
-proc submenu_placement*(a: var TGtkMenuItem): guint =
-  result = (a.GtkMenuItemflag0 and bm_TGtkMenuItem_submenu_placement) shr
-      bp_TGtkMenuItem_submenu_placement
-
-proc set_submenu_placement*(a: var TGtkMenuItem, `submenu_placement`: guint) =
-  a.GtkMenuItemflag0 = a.GtkMenuItemflag0 or
-      (int16(`submenu_placement` shl bp_TGtkMenuItem_submenu_placement) and
-      bm_TGtkMenuItem_submenu_placement)
-
-proc submenu_direction*(a: var TGtkMenuItem): guint =
-  result = (a.GtkMenuItemflag0 and bm_TGtkMenuItem_submenu_direction) shr
-      bp_TGtkMenuItem_submenu_direction
-
-proc set_submenu_direction*(a: var TGtkMenuItem, `submenu_direction`: guint) =
-  a.GtkMenuItemflag0 = a.GtkMenuItemflag0 or
-      (int16(`submenu_direction` shl bp_TGtkMenuItem_submenu_direction) and
-      bm_TGtkMenuItem_submenu_direction)
-
-proc right_justify*(a: var TGtkMenuItem): guint =
-  result = (a.GtkMenuItemflag0 and bm_TGtkMenuItem_right_justify) shr
-      bp_TGtkMenuItem_right_justify
-
-proc set_right_justify*(a: var TGtkMenuItem, `right_justify`: guint) =
-  a.GtkMenuItemflag0 = a.GtkMenuItemflag0 or
-      (int16(`right_justify` shl bp_TGtkMenuItem_right_justify) and
-      bm_TGtkMenuItem_right_justify)
-
-proc timer_from_keypress*(a: var TGtkMenuItem): guint =
-  result = (a.GtkMenuItemflag0 and bm_TGtkMenuItem_timer_from_keypress) shr
-      bp_TGtkMenuItem_timer_from_keypress
-
-proc set_timer_from_keypress*(a: var TGtkMenuItem, `timer_from_keypress`: guint) =
-  a.GtkMenuItemflag0 = a.GtkMenuItemflag0 or
-      (int16(`timer_from_keypress` shl bp_TGtkMenuItem_timer_from_keypress) and
-      bm_TGtkMenuItem_timer_from_keypress)
-
-proc hide_on_activate*(a: var TGtkMenuItemClass): guint =
-  result = (a.GtkMenuItemClassflag0 and bm_TGtkMenuItemClass_hide_on_activate) shr
-      bp_TGtkMenuItemClass_hide_on_activate
-
-proc set_hide_on_activate*(a: var TGtkMenuItemClass, `hide_on_activate`: guint) =
-  a.GtkMenuItemClassflag0 = a.GtkMenuItemClassflag0 or
-      (int16(`hide_on_activate` shl bp_TGtkMenuItemClass_hide_on_activate) and
-      bm_TGtkMenuItemClass_hide_on_activate)
-
-proc gtk_menu_item_right_justify*(menu_item: PGtkMenuItem) =
-  gtk_menu_item_set_right_justified(menu_item, true)
-
-proc GTK_TYPE_TOGGLE_BUTTON*(): GType =
-  result = gtk_toggle_button_get_type()
-
-proc GTK_TOGGLE_BUTTON*(obj: pointer): PGtkToggleButton =
-  result = cast[PGtkToggleButton](GTK_CHECK_CAST(obj, GTK_TYPE_TOGGLE_BUTTON()))
-
-proc GTK_TOGGLE_BUTTON_CLASS*(klass: pointer): PGtkToggleButtonClass =
-  result = cast[PGtkToggleButtonClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TOGGLE_BUTTON()))
-
-proc GTK_IS_TOGGLE_BUTTON*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TOGGLE_BUTTON())
-
-proc GTK_IS_TOGGLE_BUTTON_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TOGGLE_BUTTON())
-
-proc GTK_TOGGLE_BUTTON_GET_CLASS*(obj: pointer): PGtkToggleButtonClass =
-  result = cast[PGtkToggleButtonClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TOGGLE_BUTTON()))
-
-proc active*(a: var TGtkToggleButton): guint =
-  result = (a.GtkToggleButtonflag0 and bm_TGtkToggleButton_active) shr
-      bp_TGtkToggleButton_active
-
-proc set_active*(a: var TGtkToggleButton, `active`: guint) =
-  a.GtkToggleButtonflag0 = a.GtkToggleButtonflag0 or
-      (int16(`active` shl bp_TGtkToggleButton_active) and
-      bm_TGtkToggleButton_active)
-
-proc draw_indicator*(a: var TGtkToggleButton): guint =
-  result = (a.GtkToggleButtonflag0 and bm_TGtkToggleButton_draw_indicator) shr
-      bp_TGtkToggleButton_draw_indicator
-
-proc set_draw_indicator*(a: var TGtkToggleButton, `draw_indicator`: guint) =
-  a.GtkToggleButtonflag0 = a.GtkToggleButtonflag0 or
-      (int16(`draw_indicator` shl bp_TGtkToggleButton_draw_indicator) and
-      bm_TGtkToggleButton_draw_indicator)
-
-proc inconsistent*(a: var TGtkToggleButton): guint =
-  result = (a.GtkToggleButtonflag0 and bm_TGtkToggleButton_inconsistent) shr
-      bp_TGtkToggleButton_inconsistent
-
-proc set_inconsistent*(a: var TGtkToggleButton, `inconsistent`: guint) =
-  a.GtkToggleButtonflag0 = a.GtkToggleButtonflag0 or
-      (int16(`inconsistent` shl bp_TGtkToggleButton_inconsistent) and
-      bm_TGtkToggleButton_inconsistent)
-
-proc GTK_TYPE_CHECK_BUTTON*(): GType =
-  result = gtk_check_button_get_type()
-
-proc GTK_CHECK_BUTTON*(obj: pointer): PGtkCheckButton =
-  result = cast[PGtkCheckButton](GTK_CHECK_CAST(obj, GTK_TYPE_CHECK_BUTTON()))
-
-proc GTK_CHECK_BUTTON_CLASS*(klass: pointer): PGtkCheckButtonClass =
-  result = cast[PGtkCheckButtonClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CHECK_BUTTON()))
-
-proc GTK_IS_CHECK_BUTTON*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CHECK_BUTTON())
-
-proc GTK_IS_CHECK_BUTTON_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CHECK_BUTTON())
-
-proc GTK_CHECK_BUTTON_GET_CLASS*(obj: pointer): PGtkCheckButtonClass =
-  result = cast[PGtkCheckButtonClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CHECK_BUTTON()))
-
-proc GTK_TYPE_CHECK_MENU_ITEM*(): GType =
-  result = gtk_check_menu_item_get_type()
-
-proc GTK_CHECK_MENU_ITEM*(obj: pointer): PGtkCheckMenuItem =
-  result = cast[PGtkCheckMenuItem](GTK_CHECK_CAST(obj, GTK_TYPE_CHECK_MENU_ITEM()))
-
-proc GTK_CHECK_MENU_ITEM_CLASS*(klass: pointer): PGtkCheckMenuItemClass =
-  result = cast[PGtkCheckMenuItemClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_CHECK_MENU_ITEM()))
-
-proc GTK_IS_CHECK_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CHECK_MENU_ITEM())
-
-proc GTK_IS_CHECK_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CHECK_MENU_ITEM())
-
-proc GTK_CHECK_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkCheckMenuItemClass =
-  result = cast[PGtkCheckMenuItemClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_CHECK_MENU_ITEM()))
-
-proc active*(a: var TGtkCheckMenuItem): guint =
-  result = (a.GtkCheckMenuItemflag0 and bm_TGtkCheckMenuItem_active) shr
-      bp_TGtkCheckMenuItem_active
-
-proc set_active*(a: var TGtkCheckMenuItem, `active`: guint) =
-  a.GtkCheckMenuItemflag0 = a.GtkCheckMenuItemflag0 or
-      (int16(`active` shl bp_TGtkCheckMenuItem_active) and
-      bm_TGtkCheckMenuItem_active)
-
-proc always_show_toggle*(a: var TGtkCheckMenuItem): guint =
-  result = (a.GtkCheckMenuItemflag0 and bm_TGtkCheckMenuItem_always_show_toggle) shr
-      bp_TGtkCheckMenuItem_always_show_toggle
-
-proc set_always_show_toggle*(a: var TGtkCheckMenuItem,
-                             `always_show_toggle`: guint) =
-  a.GtkCheckMenuItemflag0 = a.GtkCheckMenuItemflag0 or
-      (int16(`always_show_toggle` shl bp_TGtkCheckMenuItem_always_show_toggle) and
-      bm_TGtkCheckMenuItem_always_show_toggle)
-
-proc inconsistent*(a: var TGtkCheckMenuItem): guint =
-  result = (a.GtkCheckMenuItemflag0 and bm_TGtkCheckMenuItem_inconsistent) shr
-      bp_TGtkCheckMenuItem_inconsistent
-
-proc set_inconsistent*(a: var TGtkCheckMenuItem, `inconsistent`: guint) =
-  a.GtkCheckMenuItemflag0 = a.GtkCheckMenuItemflag0 or
-      (int16(`inconsistent` shl bp_TGtkCheckMenuItem_inconsistent) and
-      bm_TGtkCheckMenuItem_inconsistent)
-
-proc GTK_TYPE_CLIST*(): GType =
-  result = gtk_clist_get_type()
-
-proc GTK_CLIST*(obj: pointer): PGtkCList =
-  result = cast[PGtkCList](GTK_CHECK_CAST(obj, GTK_TYPE_CLIST()))
-
-proc GTK_CLIST_CLASS*(klass: pointer): PGtkCListClass =
-  result = cast[PGtkCListClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_CLIST()))
-
-proc GTK_IS_CLIST*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CLIST())
-
-proc GTK_IS_CLIST_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CLIST())
-
-proc GTK_CLIST_GET_CLASS*(obj: pointer): PGtkCListClass =
-  result = cast[PGtkCListClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CLIST()))
-
-proc GTK_CLIST_FLAGS*(clist: pointer): guint16 =
-  result = toU16(GTK_CLIST(clist).flags)
-
-proc GTK_CLIST_SET_FLAG*(clist: PGtkCList, flag: guint16) =
-  clist.flags = GTK_CLIST(clist).flags or (flag)
-
-proc GTK_CLIST_UNSET_FLAG*(clist: PGtkCList, flag: guint16) =
-  clist.flags = GTK_CLIST(clist).flags and not (flag)
-
-proc GTK_CLIST_IN_DRAG_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_IN_DRAG)) != 0'i32
-
-proc GTK_CLIST_ROW_HEIGHT_SET_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_ROW_HEIGHT_SET)) != 0'i32
-
-proc GTK_CLIST_SHOW_TITLES_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_SHOW_TITLES)) != 0'i32
-
-proc GTK_CLIST_ADD_MODE_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_ADD_MODE)) != 0'i32
-
-proc GTK_CLIST_AUTO_SORT_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_AUTO_SORT)) != 0'i32
-
-proc GTK_CLIST_AUTO_RESIZE_BLOCKED_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_AUTO_RESIZE_BLOCKED)) != 0'i32
-
-proc GTK_CLIST_REORDERABLE_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_REORDERABLE)) != 0'i32
-
-proc GTK_CLIST_USE_DRAG_ICONS_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_USE_DRAG_ICONS)) != 0'i32
-
-proc GTK_CLIST_DRAW_DRAG_LINE_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_DRAW_DRAG_LINE)) != 0'i32
-
-proc GTK_CLIST_DRAW_DRAG_RECT_get*(clist: pointer): bool =
-  result = ((GTK_CLIST_FLAGS(clist)) and cint(GTK_CLIST_DRAW_DRAG_RECT)) != 0'i32
-
-proc GTK_CLIST_ROW_get*(glist: PGList): PGtkCListRow =
-  result = cast[PGtkCListRow](glist . data)
-
-when false:
-  proc GTK_CELL_TEXT_get*(cell: pointer): PGtkCellText =
-    result = cast[PGtkCellText](addr((cell)))
-
-  proc GTK_CELL_PIXMAP_get*(cell: pointer): PGtkCellPixmap =
-    result = cast[PGtkCellPixmap](addr((cell)))
-
-  proc GTK_CELL_PIXTEXT_get*(cell: pointer): PGtkCellPixText =
-    result = cast[PGtkCellPixText](addr((cell)))
-
-  proc GTK_CELL_WIDGET_get*(cell: pointer): PGtkCellWidget =
-    result = cast[PGtkCellWidget](addr((cell)))
-
-proc visible*(a: var TGtkCListColumn): guint =
-  result = (a.flag0 and bm_TGtkCListColumn_visible) shr
-      bp_TGtkCListColumn_visible
-
-proc set_visible*(a: var TGtkCListColumn, `visible`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`visible` shl bp_TGtkCListColumn_visible) and
-      bm_TGtkCListColumn_visible)
-
-proc width_set*(a: var TGtkCListColumn): guint =
-  result = (a.flag0 and bm_TGtkCListColumn_width_set) shr
-      bp_TGtkCListColumn_width_set
-
-proc set_width_set*(a: var TGtkCListColumn, `width_set`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`width_set` shl bp_TGtkCListColumn_width_set) and
-      bm_TGtkCListColumn_width_set)
-
-proc resizeable*(a: var TGtkCListColumn): guint =
-  result = (a.flag0 and bm_TGtkCListColumn_resizeable) shr
-      bp_TGtkCListColumn_resizeable
-
-proc set_resizeable*(a: var TGtkCListColumn, `resizeable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`resizeable` shl bp_TGtkCListColumn_resizeable) and
-      bm_TGtkCListColumn_resizeable)
-
-proc auto_resize*(a: var TGtkCListColumn): guint =
-  result = (a.flag0 and bm_TGtkCListColumn_auto_resize) shr
-      bp_TGtkCListColumn_auto_resize
-
-proc set_auto_resize*(a: var TGtkCListColumn, `auto_resize`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`auto_resize` shl bp_TGtkCListColumn_auto_resize) and
-      bm_TGtkCListColumn_auto_resize)
-
-proc button_passive*(a: var TGtkCListColumn): guint =
-  result = (a.flag0 and bm_TGtkCListColumn_button_passive) shr
-      bp_TGtkCListColumn_button_passive
-
-proc set_button_passive*(a: var TGtkCListColumn, `button_passive`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`button_passive` shl bp_TGtkCListColumn_button_passive) and
-      bm_TGtkCListColumn_button_passive)
-
-proc fg_set*(a: var TGtkCListRow): guint =
-  result = (a.flag0 and bm_TGtkCListRow_fg_set) shr bp_TGtkCListRow_fg_set
-
-proc set_fg_set*(a: var TGtkCListRow, `fg_set`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`fg_set` shl bp_TGtkCListRow_fg_set) and bm_TGtkCListRow_fg_set)
-
-proc bg_set*(a: var TGtkCListRow): guint =
-  result = (a.flag0 and bm_TGtkCListRow_bg_set) shr bp_TGtkCListRow_bg_set
-
-proc set_bg_set*(a: var TGtkCListRow, `bg_set`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`bg_set` shl bp_TGtkCListRow_bg_set) and bm_TGtkCListRow_bg_set)
-
-proc selectable*(a: var TGtkCListRow): guint =
-  result = (a.flag0 and bm_TGtkCListRow_selectable) shr
-      bp_TGtkCListRow_selectable
-
-proc set_selectable*(a: var TGtkCListRow, `selectable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`selectable` shl bp_TGtkCListRow_selectable) and
-      bm_TGtkCListRow_selectable)
-
-proc GTK_TYPE_DIALOG*(): GType =
-  result = gtk_dialog_get_type()
-
-proc GTK_DIALOG*(obj: pointer): PGtkDialog =
-  result = cast[PGtkDialog](GTK_CHECK_CAST(obj, GTK_TYPE_DIALOG()))
-
-proc GTK_DIALOG_CLASS*(klass: pointer): PGtkDialogClass =
-  result = cast[PGtkDialogClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_DIALOG()))
-
-proc GTK_IS_DIALOG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_DIALOG())
-
-proc GTK_IS_DIALOG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_DIALOG())
-
-proc GTK_DIALOG_GET_CLASS*(obj: pointer): PGtkDialogClass =
-  result = cast[PGtkDialogClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_DIALOG()))
-
-proc GTK_TYPE_VBOX*(): GType =
-  result = gtk_vbox_get_type()
-
-proc GTK_VBOX*(obj: pointer): PGtkVBox =
-  result = cast[PGtkVBox](GTK_CHECK_CAST(obj, GTK_TYPE_VBOX()))
-
-proc GTK_VBOX_CLASS*(klass: pointer): PGtkVBoxClass =
-  result = cast[PGtkVBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VBOX()))
-
-proc GTK_IS_VBOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VBOX())
-
-proc GTK_IS_VBOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VBOX())
-
-proc GTK_VBOX_GET_CLASS*(obj: pointer): PGtkVBoxClass =
-  result = cast[PGtkVBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VBOX()))
-
-proc GTK_TYPE_COLOR_SELECTION*(): GType =
-  result = gtk_color_selection_get_type()
-
-proc GTK_COLOR_SELECTION*(obj: pointer): PGtkColorSelection =
-  result = cast[PGtkColorSelection](GTK_CHECK_CAST(obj, GTK_TYPE_COLOR_SELECTION()))
-
-proc GTK_COLOR_SELECTION_CLASS*(klass: pointer): PGtkColorSelectionClass =
-  result = cast[PGtkColorSelectionClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_COLOR_SELECTION()))
-
-proc GTK_IS_COLOR_SELECTION*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_COLOR_SELECTION())
-
-proc GTK_IS_COLOR_SELECTION_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_COLOR_SELECTION())
-
-proc GTK_COLOR_SELECTION_GET_CLASS*(obj: pointer): PGtkColorSelectionClass =
-  result = cast[PGtkColorSelectionClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_COLOR_SELECTION()))
-
-proc GTK_TYPE_COLOR_SELECTION_DIALOG*(): GType =
-  result = gtk_color_selection_dialog_get_type()
-
-proc GTK_COLOR_SELECTION_DIALOG*(obj: pointer): PGtkColorSelectionDialog =
-  result = cast[PGtkColorSelectionDialog](GTK_CHECK_CAST(obj,
-      GTK_TYPE_COLOR_SELECTION_DIALOG()))
-
-proc GTK_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): PGtkColorSelectionDialogClass =
-  result = cast[PGtkColorSelectionDialogClass](
-      GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_COLOR_SELECTION_DIALOG()))
-
-proc GTK_IS_COLOR_SELECTION_DIALOG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_COLOR_SELECTION_DIALOG())
-
-proc GTK_IS_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_COLOR_SELECTION_DIALOG())
-
-proc GTK_COLOR_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PGtkColorSelectionDialogClass =
-  result = cast[PGtkColorSelectionDialogClass](
-      GTK_CHECK_GET_CLASS(obj, GTK_TYPE_COLOR_SELECTION_DIALOG()))
-
-proc GTK_TYPE_HBOX*(): GType =
-  result = gtk_hbox_get_type()
-
-proc GTK_HBOX*(obj: pointer): PGtkHBox =
-  result = cast[PGtkHBox](GTK_CHECK_CAST(obj, GTK_TYPE_HBOX()))
-
-proc GTK_HBOX_CLASS*(klass: pointer): PGtkHBoxClass =
-  result = cast[PGtkHBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HBOX()))
-
-proc GTK_IS_HBOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HBOX())
-
-proc GTK_IS_HBOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HBOX())
-
-proc GTK_HBOX_GET_CLASS*(obj: pointer): PGtkHBoxClass =
-  result = cast[PGtkHBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HBOX()))
-
-proc GTK_TYPE_COMBO*(): GType =
-  result = gtk_combo_get_type()
-
-proc GTK_COMBO*(obj: pointer): PGtkCombo =
-  result = cast[PGtkCombo](GTK_CHECK_CAST(obj, GTK_TYPE_COMBO()))
-
-proc GTK_COMBO_CLASS*(klass: pointer): PGtkComboClass =
-  result = cast[PGtkComboClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_COMBO()))
-
-proc GTK_IS_COMBO*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_COMBO())
-
-proc GTK_IS_COMBO_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_COMBO())
-
-proc GTK_COMBO_GET_CLASS*(obj: pointer): PGtkComboClass =
-  result = cast[PGtkComboClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_COMBO()))
-
-proc value_in_list*(a: var TGtkCombo): guint =
-  result = (a.GtkComboflag0 and bm_TGtkCombo_value_in_list) shr
-      bp_TGtkCombo_value_in_list
-
-proc set_value_in_list*(a: var TGtkCombo, `value_in_list`: guint) =
-  a.GtkComboflag0 = a.GtkComboflag0 or
-      (int16(`value_in_list` shl bp_TGtkCombo_value_in_list) and
-      bm_TGtkCombo_value_in_list)
-
-proc ok_if_empty*(a: var TGtkCombo): guint =
-  result = (a.GtkComboflag0 and bm_TGtkCombo_ok_if_empty) shr
-      bp_TGtkCombo_ok_if_empty
-
-proc set_ok_if_empty*(a: var TGtkCombo, `ok_if_empty`: guint) =
-  a.GtkComboflag0 = a.GtkComboflag0 or
-      (int16(`ok_if_empty` shl bp_TGtkCombo_ok_if_empty) and
-      bm_TGtkCombo_ok_if_empty)
-
-proc case_sensitive*(a: var TGtkCombo): guint =
-  result = (a.GtkComboflag0 and bm_TGtkCombo_case_sensitive) shr
-      bp_TGtkCombo_case_sensitive
-
-proc set_case_sensitive*(a: var TGtkCombo, `case_sensitive`: guint) =
-  a.GtkComboflag0 = a.GtkComboflag0 or
-      (int16(`case_sensitive` shl bp_TGtkCombo_case_sensitive) and
-      bm_TGtkCombo_case_sensitive)
-
-proc use_arrows*(a: var TGtkCombo): guint =
-  result = (a.GtkComboflag0 and bm_TGtkCombo_use_arrows) shr bp_TGtkCombo_use_arrows
-
-proc set_use_arrows*(a: var TGtkCombo, `use_arrows`: guint) =
-  a.GtkComboflag0 = a.GtkComboflag0 or
-      (int16(`use_arrows` shl bp_TGtkCombo_use_arrows) and bm_TGtkCombo_use_arrows)
-
-proc use_arrows_always*(a: var TGtkCombo): guint =
-  result = (a.GtkComboflag0 and bm_TGtkCombo_use_arrows_always) shr
-      bp_TGtkCombo_use_arrows_always
-
-proc set_use_arrows_always*(a: var TGtkCombo, `use_arrows_always`: guint) =
-  a.GtkComboflag0 = a.GtkComboflag0 or
-      (int16(`use_arrows_always` shl bp_TGtkCombo_use_arrows_always) and
-      bm_TGtkCombo_use_arrows_always)
-
-proc GTK_TYPE_CTREE*(): GType =
-  result = gtk_ctree_get_type()
-
-proc GTK_CTREE*(obj: pointer): PGtkCTree =
-  result = cast[PGtkCTree](GTK_CHECK_CAST(obj, GTK_TYPE_CTREE()))
-
-proc GTK_CTREE_CLASS*(klass: pointer): PGtkCTreeClass =
-  result = cast[PGtkCTreeClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_CTREE()))
-
-proc GTK_IS_CTREE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CTREE())
-
-proc GTK_IS_CTREE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CTREE())
-
-proc GTK_CTREE_GET_CLASS*(obj: pointer): PGtkCTreeClass =
-  result = cast[PGtkCTreeClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CTREE()))
-
-proc GTK_CTREE_ROW*(node: TAddress): PGtkCTreeRow =
-  result = cast[PGtkCTreeRow]((cast[PGList](node)) . data)
-
-proc GTK_CTREE_NODE*(node: TAddress): PGtkCTreeNode =
-  result = cast[PGtkCTreeNode](node)
-
-proc GTK_CTREE_NODE_NEXT*(nnode: TAddress): PGtkCTreeNode =
-  result = cast[PGtkCTreeNode]((cast[PGList](nnode)) . next)
-
-proc GTK_CTREE_NODE_PREV*(`pnode`: TAddress): PGtkCTreeNode =
-  result = cast[PGtkCTreeNode]((cast[PGList](`pnode`)) . prev)
-
-proc GTK_CTREE_FUNC*(`func`: TAddress): TGtkCTreeFunc =
-  result = cast[TGtkCTreeFunc](`func`)
-
-proc GTK_TYPE_CTREE_NODE*(): GType =
-  result = gtk_ctree_node_get_type()
-
-proc line_style*(a: var TGtkCTree): guint =
-  result = (a.GtkCTreeflag0 and bm_TGtkCTree_line_style) shr bp_TGtkCTree_line_style
-
-proc set_line_style*(a: var TGtkCTree, `line_style`: guint) =
-  a.GtkCTreeflag0 = a.GtkCTreeflag0 or
-      (int16(`line_style` shl bp_TGtkCTree_line_style) and bm_TGtkCTree_line_style)
-
-proc expander_style*(a: var TGtkCTree): guint =
-  result = (a.GtkCTreeflag0 and bm_TGtkCTree_expander_style) shr
-      bp_TGtkCTree_expander_style
-
-proc set_expander_style*(a: var TGtkCTree, `expander_style`: guint) =
-  a.GtkCTreeflag0 = a.GtkCTreeflag0 or
-      (int16(`expander_style` shl bp_TGtkCTree_expander_style) and
-      bm_TGtkCTree_expander_style)
-
-proc show_stub*(a: var TGtkCTree): guint =
-  result = (a.GtkCTreeflag0 and bm_TGtkCTree_show_stub) shr bp_TGtkCTree_show_stub
-
-proc set_show_stub*(a: var TGtkCTree, `show_stub`: guint) =
-  a.GtkCTreeflag0 = a.GtkCTreeflag0 or
-      (int16(`show_stub` shl bp_TGtkCTree_show_stub) and bm_TGtkCTree_show_stub)
-
-proc is_leaf*(a: var TGtkCTreeRow): guint =
-  result = (a.GtkCTreeRow_flag0 and bm_TGtkCTreeRow_is_leaf) shr bp_TGtkCTreeRow_is_leaf
-
-proc set_is_leaf*(a: var TGtkCTreeRow, `is_leaf`: guint) =
-  a.GtkCTreeRow_flag0 = a.GtkCTreeRow_flag0 or
-      (int16(`is_leaf` shl bp_TGtkCTreeRow_is_leaf) and bm_TGtkCTreeRow_is_leaf)
-
-proc expanded*(a: var TGtkCTreeRow): guint =
-  result = (a.GtkCTreeRow_flag0 and bm_TGtkCTreeRow_expanded) shr
-      bp_TGtkCTreeRow_expanded
-
-proc set_expanded*(a: var TGtkCTreeRow, `expanded`: guint) =
-  a.GtkCTreeRow_flag0 = a.GtkCTreeRowflag0 or
-      (int16(`expanded` shl bp_TGtkCTreeRow_expanded) and bm_TGtkCTreeRow_expanded)
-
-proc gtk_ctree_set_reorderable*(t: pointer, r: bool) =
-  gtk_clist_set_reorderable(cast[PGtkCList](t), r)
-
-proc GTK_TYPE_DRAWING_AREA*(): GType =
-  result = gtk_drawing_area_get_type()
-
-proc GTK_DRAWING_AREA*(obj: pointer): PGtkDrawingArea =
-  result = cast[PGtkDrawingArea](GTK_CHECK_CAST(obj, GTK_TYPE_DRAWING_AREA()))
-
-proc GTK_DRAWING_AREA_CLASS*(klass: pointer): PGtkDrawingAreaClass =
-  result = cast[PGtkDrawingAreaClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_DRAWING_AREA()))
-
-proc GTK_IS_DRAWING_AREA*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_DRAWING_AREA())
-
-proc GTK_IS_DRAWING_AREA_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_DRAWING_AREA())
-
-proc GTK_DRAWING_AREA_GET_CLASS*(obj: pointer): PGtkDrawingAreaClass =
-  result = cast[PGtkDrawingAreaClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_DRAWING_AREA()))
-
-proc GTK_TYPE_CURVE*(): GType =
-  result = gtk_curve_get_type()
-
-proc GTK_CURVE*(obj: pointer): PGtkCurve =
-  result = cast[PGtkCurve](GTK_CHECK_CAST(obj, GTK_TYPE_CURVE()))
-
-proc GTK_CURVE_CLASS*(klass: pointer): PGtkCurveClass =
-  result = cast[PGtkCurveClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_CURVE()))
-
-proc GTK_IS_CURVE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_CURVE())
-
-proc GTK_IS_CURVE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_CURVE())
-
-proc GTK_CURVE_GET_CLASS*(obj: pointer): PGtkCurveClass =
-  result = cast[PGtkCurveClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_CURVE()))
-
-proc GTK_TYPE_EDITABLE*(): GType =
-  result = gtk_editable_get_type()
-
-proc GTK_EDITABLE*(obj: pointer): PGtkEditable =
-  result = cast[PGtkEditable](G_TYPE_CHECK_INSTANCE_CAST(obj, GTK_TYPE_EDITABLE()))
-
-proc GTK_EDITABLE_CLASS*(vtable: pointer): PGtkEditableClass =
-  result = cast[PGtkEditableClass](G_TYPE_CHECK_CLASS_CAST(vtable, GTK_TYPE_EDITABLE()))
-
-proc GTK_IS_EDITABLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_EDITABLE())
-
-proc GTK_IS_EDITABLE_CLASS*(vtable: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(vtable, GTK_TYPE_EDITABLE())
-
-proc GTK_EDITABLE_GET_CLASS*(inst: pointer): PGtkEditableClass =
-  result = cast[PGtkEditableClass](G_TYPE_INSTANCE_GET_INTERFACE(inst,
-      GTK_TYPE_EDITABLE()))
-
-proc GTK_TYPE_IM_CONTEXT*(): GType =
-  result = gtk_im_context_get_type()
-
-proc GTK_IM_CONTEXT*(obj: pointer): PGtkIMContext =
-  result = cast[PGtkIMContext](GTK_CHECK_CAST(obj, GTK_TYPE_IM_CONTEXT()))
-
-proc GTK_IM_CONTEXT_CLASS*(klass: pointer): PGtkIMContextClass =
-  result = cast[PGtkIMContextClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_IM_CONTEXT()))
-
-proc GTK_IS_IM_CONTEXT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_IM_CONTEXT())
-
-proc GTK_IS_IM_CONTEXT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_IM_CONTEXT())
-
-proc GTK_IM_CONTEXT_GET_CLASS*(obj: pointer): PGtkIMContextClass =
-  result = cast[PGtkIMContextClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_IM_CONTEXT()))
-
-proc GTK_TYPE_MENU_SHELL*(): GType =
-  result = gtk_menu_shell_get_type()
-
-proc GTK_MENU_SHELL*(obj: pointer): PGtkMenuShell =
-  result = cast[PGtkMenuShell](GTK_CHECK_CAST(obj, GTK_TYPE_MENU_SHELL()))
-
-proc GTK_MENU_SHELL_CLASS*(klass: pointer): PGtkMenuShellClass =
-  result = cast[PGtkMenuShellClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_MENU_SHELL()))
-
-proc GTK_IS_MENU_SHELL*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MENU_SHELL())
-
-proc GTK_IS_MENU_SHELL_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MENU_SHELL())
-
-proc GTK_MENU_SHELL_GET_CLASS*(obj: pointer): PGtkMenuShellClass =
-  result = cast[PGtkMenuShellClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_MENU_SHELL()))
-
-proc active*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_active) shr bp_TGtkMenuShell_active
-
-proc set_active*(a: var TGtkMenuShell, `active`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`active` shl bp_TGtkMenuShell_active) and bm_TGtkMenuShell_active)
-
-proc have_grab*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_have_grab) shr
-      bp_TGtkMenuShell_have_grab
-
-proc set_have_grab*(a: var TGtkMenuShell, `have_grab`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`have_grab` shl bp_TGtkMenuShell_have_grab) and
-      bm_TGtkMenuShell_have_grab)
-
-proc have_xgrab*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_have_xgrab) shr
-      bp_TGtkMenuShell_have_xgrab
-
-proc set_have_xgrab*(a: var TGtkMenuShell, `have_xgrab`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`have_xgrab` shl bp_TGtkMenuShell_have_xgrab) and
-      bm_TGtkMenuShell_have_xgrab)
-
-proc ignore_leave*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_ignore_leave) shr
-      bp_TGtkMenuShell_ignore_leave
-
-proc set_ignore_leave*(a: var TGtkMenuShell, `ignore_leave`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`ignore_leave` shl bp_TGtkMenuShell_ignore_leave) and
-      bm_TGtkMenuShell_ignore_leave)
-
-proc menu_flag*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_menu_flag) shr
-      bp_TGtkMenuShell_menu_flag
-
-proc set_menu_flag*(a: var TGtkMenuShell, `menu_flag`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`menu_flag` shl bp_TGtkMenuShell_menu_flag) and
-      bm_TGtkMenuShell_menu_flag)
-
-proc ignore_enter*(a: var TGtkMenuShell): guint =
-  result = (a.GtkMenuShellflag0 and bm_TGtkMenuShell_ignore_enter) shr
-      bp_TGtkMenuShell_ignore_enter
-
-proc set_ignore_enter*(a: var TGtkMenuShell, `ignore_enter`: guint) =
-  a.GtkMenuShellflag0 = a.GtkMenuShellflag0 or
-      (int16(`ignore_enter` shl bp_TGtkMenuShell_ignore_enter) and
-      bm_TGtkMenuShell_ignore_enter)
-
-proc submenu_placement*(a: var TGtkMenuShellClass): guint =
-  result = (a.GtkMenuShellClassflag0 and bm_TGtkMenuShellClass_submenu_placement) shr
-      bp_TGtkMenuShellClass_submenu_placement
-
-proc set_submenu_placement*(a: var TGtkMenuShellClass,
-                            `submenu_placement`: guint) =
-  a.GtkMenuShellClassflag0 = a.GtkMenuShellClassflag0 or
-      (int16(`submenu_placement` shl bp_TGtkMenuShellClass_submenu_placement) and
-      bm_TGtkMenuShellClass_submenu_placement)
-
-proc GTK_TYPE_MENU*(): GType =
-  result = gtk_menu_get_type()
-
-proc GTK_MENU*(obj: pointer): PGtkMenu =
-  result = cast[PGtkMenu](GTK_CHECK_CAST(obj, GTK_TYPE_MENU()))
-
-proc GTK_MENU_CLASS*(klass: pointer): PGtkMenuClass =
-  result = cast[PGtkMenuClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_MENU()))
-
-proc GTK_IS_MENU*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MENU())
-
-proc GTK_IS_MENU_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MENU())
-
-proc GTK_MENU_GET_CLASS*(obj: pointer): PGtkMenuClass =
-  result = cast[PGtkMenuClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_MENU()))
-
-proc needs_destruction_ref_count*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_needs_destruction_ref_count) shr
-      bp_TGtkMenu_needs_destruction_ref_count
-
-proc set_needs_destruction_ref_count*(a: var TGtkMenu,
-                                      `needs_destruction_ref_count`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`needs_destruction_ref_count` shl
-      bp_TGtkMenu_needs_destruction_ref_count) and
-      bm_TGtkMenu_needs_destruction_ref_count)
-
-proc torn_off*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_torn_off) shr bp_TGtkMenu_torn_off
-
-proc set_torn_off*(a: var TGtkMenu, `torn_off`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`torn_off` shl bp_TGtkMenu_torn_off) and bm_TGtkMenu_torn_off)
-
-proc tearoff_active*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_tearoff_active) shr
-      bp_TGtkMenu_tearoff_active
-
-proc set_tearoff_active*(a: var TGtkMenu, `tearoff_active`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`tearoff_active` shl bp_TGtkMenu_tearoff_active) and
-      bm_TGtkMenu_tearoff_active)
-
-proc scroll_fast*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_scroll_fast) shr bp_TGtkMenu_scroll_fast
-
-proc set_scroll_fast*(a: var TGtkMenu, `scroll_fast`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`scroll_fast` shl bp_TGtkMenu_scroll_fast) and
-      bm_TGtkMenu_scroll_fast)
-
-proc upper_arrow_visible*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_upper_arrow_visible) shr
-      bp_TGtkMenu_upper_arrow_visible
-
-proc set_upper_arrow_visible*(a: var TGtkMenu, `upper_arrow_visible`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`upper_arrow_visible` shl bp_TGtkMenu_upper_arrow_visible) and
-      bm_TGtkMenu_upper_arrow_visible)
-
-proc lower_arrow_visible*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_lower_arrow_visible) shr
-      bp_TGtkMenu_lower_arrow_visible
-
-proc set_lower_arrow_visible*(a: var TGtkMenu, `lower_arrow_visible`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`lower_arrow_visible` shl bp_TGtkMenu_lower_arrow_visible) and
-      bm_TGtkMenu_lower_arrow_visible)
-
-proc upper_arrow_prelight*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_upper_arrow_prelight) shr
-      bp_TGtkMenu_upper_arrow_prelight
-
-proc set_upper_arrow_prelight*(a: var TGtkMenu, `upper_arrow_prelight`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`upper_arrow_prelight` shl bp_TGtkMenu_upper_arrow_prelight) and
-      bm_TGtkMenu_upper_arrow_prelight)
-
-proc lower_arrow_prelight*(a: var TGtkMenu): guint =
-  result = (a.GtkMenuflag0 and bm_TGtkMenu_lower_arrow_prelight) shr
-      bp_TGtkMenu_lower_arrow_prelight
-
-proc set_lower_arrow_prelight*(a: var TGtkMenu, `lower_arrow_prelight`: guint) =
-  a.GtkMenuflag0 = a.GtkMenuflag0 or
-      (int16(`lower_arrow_prelight` shl bp_TGtkMenu_lower_arrow_prelight) and
-      bm_TGtkMenu_lower_arrow_prelight)
-
-proc gtk_menu_append*(menu, child: PGtkWidget) =
-  gtk_menu_shell_append(cast[PGtkMenuShell](menu), child)
-
-proc gtk_menu_prepend*(menu, child: PGtkWidget) =
-  gtk_menu_shell_prepend(cast[PGtkMenuShell](menu), child)
-
-proc gtk_menu_insert*(menu, child: PGtkWidget, pos: gint) =
-  gtk_menu_shell_insert(cast[PGtkMenuShell](menu), child, pos)
-
-proc GTK_TYPE_ENTRY*(): GType =
-  result = gtk_entry_get_type()
-
-proc GTK_ENTRY*(obj: pointer): PGtkEntry =
-  result = cast[PGtkEntry](GTK_CHECK_CAST(obj, GTK_TYPE_ENTRY()))
-
-proc GTK_ENTRY_CLASS*(klass: pointer): PGtkEntryClass =
-  result = cast[PGtkEntryClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_ENTRY()))
-
-proc GTK_IS_ENTRY*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_ENTRY())
-
-proc GTK_IS_ENTRY_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ENTRY())
-
-proc GTK_ENTRY_GET_CLASS*(obj: pointer): PGtkEntryClass =
-  result = cast[PGtkEntryClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ENTRY()))
-
-proc editable*(a: var TGtkEntry): guint =
-  result = (a.GtkEntryflag0 and bm_TGtkEntry_editable) shr bp_TGtkEntry_editable
-
-proc set_editable*(a: var TGtkEntry, `editable`: guint) =
-  a.GtkEntryflag0 = a.GtkEntryflag0 or
-      (int16(`editable` shl bp_TGtkEntry_editable) and bm_TGtkEntry_editable)
-
-proc visible*(a: var TGtkEntry): guint =
-  result = (a.GtkEntryflag0 and bm_TGtkEntry_visible) shr bp_TGtkEntry_visible
-
-proc set_visible*(a: var TGtkEntry, `visible`: guint) =
-  a.GtkEntryflag0 = a.GtkEntryflag0 or
-      (int16(`visible` shl bp_TGtkEntry_visible) and bm_TGtkEntry_visible)
-
-proc overwrite_mode*(a: var TGtkEntry): guint =
-  result = (a.GtkEntryflag0 and bm_TGtkEntry_overwrite_mode) shr
-      bp_TGtkEntry_overwrite_mode
-
-proc set_overwrite_mode*(a: var TGtkEntry, `overwrite_mode`: guint) =
-  a.GtkEntryflag0 = a.GtkEntryflag0 or
-      (int16(`overwrite_mode` shl bp_TGtkEntry_overwrite_mode) and
-      bm_TGtkEntry_overwrite_mode)
-
-proc in_drag*(a: var TGtkEntry): guint =
-  result = (a.GtkEntryflag0 and bm_TGtkEntry_in_drag) shr bp_TGtkEntry_in_drag
-
-proc set_in_drag*(a: var TGtkEntry, `in_drag`: guint) =
-  a.GtkEntryflag0 = a.GtkEntryflag0 or
-      (int16(`in_drag` shl bp_TGtkEntry_in_drag) and bm_TGtkEntry_in_drag)
-
-proc cache_includes_preedit*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_cache_includes_preedit) shr
-      bp_TGtkEntry_cache_includes_preedit
-
-proc set_cache_includes_preedit*(a: var TGtkEntry,
-                                 `cache_includes_preedit`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`cache_includes_preedit` shl bp_TGtkEntry_cache_includes_preedit) and
-      bm_TGtkEntry_cache_includes_preedit)
-
-proc need_im_reset*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_need_im_reset) shr
-      bp_TGtkEntry_need_im_reset
-
-proc set_need_im_reset*(a: var TGtkEntry, `need_im_reset`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`need_im_reset` shl bp_TGtkEntry_need_im_reset) and
-      bm_TGtkEntry_need_im_reset)
-
-proc has_frame*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_has_frame) shr bp_TGtkEntry_has_frame
-
-proc set_has_frame*(a: var TGtkEntry, `has_frame`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`has_frame` shl bp_TGtkEntry_has_frame) and bm_TGtkEntry_has_frame)
-
-proc activates_default*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_activates_default) shr
-      bp_TGtkEntry_activates_default
-
-proc set_activates_default*(a: var TGtkEntry, `activates_default`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`activates_default` shl bp_TGtkEntry_activates_default) and
-      bm_TGtkEntry_activates_default)
-
-proc cursor_visible*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_cursor_visible) shr
-      bp_TGtkEntry_cursor_visible
-
-proc set_cursor_visible*(a: var TGtkEntry, `cursor_visible`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`cursor_visible` shl bp_TGtkEntry_cursor_visible) and
-      bm_TGtkEntry_cursor_visible)
-
-proc in_click*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_in_click) shr bp_TGtkEntry_in_click
-
-proc set_in_click*(a: var TGtkEntry, `in_click`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`in_click` shl bp_TGtkEntry_in_click) and bm_TGtkEntry_in_click)
-
-proc is_cell_renderer*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_is_cell_renderer) shr
-      bp_TGtkEntry_is_cell_renderer
-
-proc set_is_cell_renderer*(a: var TGtkEntry, `is_cell_renderer`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`is_cell_renderer` shl bp_TGtkEntry_is_cell_renderer) and
-      bm_TGtkEntry_is_cell_renderer)
-
-proc editing_canceled*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_editing_canceled) shr
-      bp_TGtkEntry_editing_canceled
-
-proc set_editing_canceled*(a: var TGtkEntry, `editing_canceled`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`editing_canceled` shl bp_TGtkEntry_editing_canceled) and
-      bm_TGtkEntry_editing_canceled)
-
-proc mouse_cursor_obscured*(a: var TGtkEntry): guint =
-  result = (a.flag1 and bm_TGtkEntry_mouse_cursor_obscured) shr
-      bp_TGtkEntry_mouse_cursor_obscured
-
-proc set_mouse_cursor_obscured*(a: var TGtkEntry, `mouse_cursor_obscured`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`mouse_cursor_obscured` shl bp_TGtkEntry_mouse_cursor_obscured) and
-      bm_TGtkEntry_mouse_cursor_obscured)
-
-proc GTK_TYPE_EVENT_BOX*(): GType =
-  result = gtk_event_box_get_type()
-
-proc GTK_EVENT_BOX*(obj: pointer): PGtkEventBox =
-  result = cast[PGtkEventBox](GTK_CHECK_CAST(obj, GTK_TYPE_EVENT_BOX()))
-
-proc GTK_EVENT_BOX_CLASS*(klass: pointer): PGtkEventBoxClass =
-  result = cast[PGtkEventBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_EVENT_BOX()))
-
-proc GTK_IS_EVENT_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_EVENT_BOX())
-
-proc GTK_IS_EVENT_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_EVENT_BOX())
-
-proc GTK_EVENT_BOX_GET_CLASS*(obj: pointer): PGtkEventBoxClass =
-  result = cast[PGtkEventBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_EVENT_BOX()))
-
-proc GTK_TYPE_FILE_SELECTION*(): GType =
-  result = gtk_file_selection_get_type()
-
-proc GTK_FILE_SELECTION*(obj: pointer): PGtkFileSelection =
-  result = cast[PGtkFileSelection](GTK_CHECK_CAST(obj, GTK_TYPE_FILE_SELECTION()))
-
-proc GTK_FILE_SELECTION_CLASS*(klass: pointer): PGtkFileSelectionClass =
-  result = cast[PGtkFileSelectionClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_FILE_SELECTION()))
-
-proc GTK_IS_FILE_SELECTION*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_FILE_SELECTION())
-
-proc GTK_IS_FILE_SELECTION_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_FILE_SELECTION())
-
-proc GTK_FILE_SELECTION_GET_CLASS*(obj: pointer): PGtkFileSelectionClass =
-  result = cast[PGtkFileSelectionClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_FILE_SELECTION()))
-
-proc GTK_TYPE_FIXED*(): GType =
-  result = gtk_fixed_get_type()
-
-proc GTK_FIXED*(obj: pointer): PGtkFixed =
-  result = cast[PGtkFixed](GTK_CHECK_CAST(obj, GTK_TYPE_FIXED()))
-
-proc GTK_FIXED_CLASS*(klass: pointer): PGtkFixedClass =
-  result = cast[PGtkFixedClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_FIXED()))
-
-proc GTK_IS_FIXED*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_FIXED())
-
-proc GTK_IS_FIXED_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_FIXED())
-
-proc GTK_FIXED_GET_CLASS*(obj: pointer): PGtkFixedClass =
-  result = cast[PGtkFixedClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_FIXED()))
-
-proc GTK_TYPE_FONT_SELECTION*(): GType =
-  result = gtk_font_selection_get_type()
-
-proc GTK_FONT_SELECTION*(obj: pointer): PGtkFontSelection =
-  result = cast[PGtkFontSelection](GTK_CHECK_CAST(obj, GTK_TYPE_FONT_SELECTION()))
-
-proc GTK_FONT_SELECTION_CLASS*(klass: pointer): PGtkFontSelectionClass =
-  result = cast[PGtkFontSelectionClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_FONT_SELECTION()))
-
-proc GTK_IS_FONT_SELECTION*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_FONT_SELECTION())
-
-proc GTK_IS_FONT_SELECTION_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_FONT_SELECTION())
-
-proc GTK_FONT_SELECTION_GET_CLASS*(obj: pointer): PGtkFontSelectionClass =
-  result = cast[PGtkFontSelectionClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_FONT_SELECTION()))
-
-proc GTK_TYPE_FONT_SELECTION_DIALOG*(): GType =
-  result = gtk_font_selection_dialog_get_type()
-
-proc GTK_FONT_SELECTION_DIALOG*(obj: pointer): PGtkFontSelectionDialog =
-  result = cast[PGtkFontSelectionDialog](GTK_CHECK_CAST(obj,
-      GTK_TYPE_FONT_SELECTION_DIALOG()))
-
-proc GTK_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): PGtkFontSelectionDialogClass =
-  result = cast[PGtkFontSelectionDialogClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_FONT_SELECTION_DIALOG()))
-
-proc GTK_IS_FONT_SELECTION_DIALOG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_FONT_SELECTION_DIALOG())
-
-proc GTK_IS_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_FONT_SELECTION_DIALOG())
-
-proc GTK_FONT_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PGtkFontSelectionDialogClass =
-  result = cast[PGtkFontSelectionDialogClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_FONT_SELECTION_DIALOG()))
-
-proc GTK_TYPE_GAMMA_CURVE*(): GType =
-  result = gtk_gamma_curve_get_type()
-
-proc GTK_GAMMA_CURVE*(obj: pointer): PGtkGammaCurve =
-  result = cast[PGtkGammaCurve](GTK_CHECK_CAST(obj, GTK_TYPE_GAMMA_CURVE()))
-
-proc GTK_GAMMA_CURVE_CLASS*(klass: pointer): PGtkGammaCurveClass =
-  result = cast[PGtkGammaCurveClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_GAMMA_CURVE()))
-
-proc GTK_IS_GAMMA_CURVE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_GAMMA_CURVE())
-
-proc GTK_IS_GAMMA_CURVE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_GAMMA_CURVE())
-
-proc GTK_GAMMA_CURVE_GET_CLASS*(obj: pointer): PGtkGammaCurveClass =
-  result = cast[PGtkGammaCurveClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_GAMMA_CURVE()))
-
-proc GTK_TYPE_HANDLE_BOX*(): GType =
-  result = gtk_handle_box_get_type()
-
-proc GTK_HANDLE_BOX*(obj: pointer): PGtkHandleBox =
-  result = cast[PGtkHandleBox](GTK_CHECK_CAST(obj, GTK_TYPE_HANDLE_BOX()))
-
-proc GTK_HANDLE_BOX_CLASS*(klass: pointer): PGtkHandleBoxClass =
-  result = cast[PGtkHandleBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HANDLE_BOX()))
-
-proc GTK_IS_HANDLE_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HANDLE_BOX())
-
-proc GTK_IS_HANDLE_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HANDLE_BOX())
-
-proc GTK_HANDLE_BOX_GET_CLASS*(obj: pointer): PGtkHandleBoxClass =
-  result = cast[PGtkHandleBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HANDLE_BOX()))
-
-proc handle_position*(a: var TGtkHandleBox): guint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_handle_position) shr
-      bp_TGtkHandleBox_handle_position
-
-proc set_handle_position*(a: var TGtkHandleBox, `handle_position`: guint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`handle_position` shl bp_TGtkHandleBox_handle_position) and
-      bm_TGtkHandleBox_handle_position)
-
-proc float_window_mapped*(a: var TGtkHandleBox): guint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_float_window_mapped) shr
-      bp_TGtkHandleBox_float_window_mapped
-
-proc set_float_window_mapped*(a: var TGtkHandleBox, `float_window_mapped`: guint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`float_window_mapped` shl bp_TGtkHandleBox_float_window_mapped) and
-      bm_TGtkHandleBox_float_window_mapped)
-
-proc child_detached*(a: var TGtkHandleBox): guint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_child_detached) shr
-      bp_TGtkHandleBox_child_detached
-
-proc set_child_detached*(a: var TGtkHandleBox, `child_detached`: guint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`child_detached` shl bp_TGtkHandleBox_child_detached) and
-      bm_TGtkHandleBox_child_detached)
-
-proc in_drag*(a: var TGtkHandleBox): guint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_in_drag) shr
-      bp_TGtkHandleBox_in_drag
-
-proc set_in_drag*(a: var TGtkHandleBox, `in_drag`: guint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`in_drag` shl bp_TGtkHandleBox_in_drag) and bm_TGtkHandleBox_in_drag)
-
-proc shrink_on_detach*(a: var TGtkHandleBox): guint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_shrink_on_detach) shr
-      bp_TGtkHandleBox_shrink_on_detach
-
-proc set_shrink_on_detach*(a: var TGtkHandleBox, `shrink_on_detach`: guint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`shrink_on_detach` shl bp_TGtkHandleBox_shrink_on_detach) and
-      bm_TGtkHandleBox_shrink_on_detach)
-
-proc snap_edge*(a: var TGtkHandleBox): gint =
-  result = (a.GtkHandleBoxflag0 and bm_TGtkHandleBox_snap_edge) shr
-      bp_TGtkHandleBox_snap_edge
-
-proc set_snap_edge*(a: var TGtkHandleBox, `snap_edge`: gint) =
-  a.GtkHandleBoxflag0 = a.GtkHandleBoxflag0 or
-      (int16(`snap_edge` shl bp_TGtkHandleBox_snap_edge) and
-      bm_TGtkHandleBox_snap_edge)
-
-proc GTK_TYPE_PANED*(): GType =
-  result = gtk_paned_get_type()
-
-proc GTK_PANED*(obj: pointer): PGtkPaned =
-  result = cast[PGtkPaned](GTK_CHECK_CAST(obj, GTK_TYPE_PANED()))
-
-proc GTK_PANED_CLASS*(klass: pointer): PGtkPanedClass =
-  result = cast[PGtkPanedClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_PANED()))
-
-proc GTK_IS_PANED*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PANED())
-
-proc GTK_IS_PANED_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PANED())
-
-proc GTK_PANED_GET_CLASS*(obj: pointer): PGtkPanedClass =
-  result = cast[PGtkPanedClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PANED()))
-
-proc position_set*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_position_set) shr
-      bp_TGtkPaned_position_set
-
-proc set_position_set*(a: var TGtkPaned, `position_set`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`position_set` shl bp_TGtkPaned_position_set) and
-      bm_TGtkPaned_position_set)
-
-proc in_drag*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_in_drag) shr bp_TGtkPaned_in_drag
-
-proc set_in_drag*(a: var TGtkPaned, `in_drag`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`in_drag` shl bp_TGtkPaned_in_drag) and bm_TGtkPaned_in_drag)
-
-proc child1_shrink*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_child1_shrink) shr
-      bp_TGtkPaned_child1_shrink
-
-proc set_child1_shrink*(a: var TGtkPaned, `child1_shrink`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`child1_shrink` shl bp_TGtkPaned_child1_shrink) and
-      bm_TGtkPaned_child1_shrink)
-
-proc child1_resize*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_child1_resize) shr
-      bp_TGtkPaned_child1_resize
-
-proc set_child1_resize*(a: var TGtkPaned, `child1_resize`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`child1_resize` shl bp_TGtkPaned_child1_resize) and
-      bm_TGtkPaned_child1_resize)
-
-proc child2_shrink*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_child2_shrink) shr
-      bp_TGtkPaned_child2_shrink
-
-proc set_child2_shrink*(a: var TGtkPaned, `child2_shrink`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`child2_shrink` shl bp_TGtkPaned_child2_shrink) and
-      bm_TGtkPaned_child2_shrink)
-
-proc child2_resize*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_child2_resize) shr
-      bp_TGtkPaned_child2_resize
-
-proc set_child2_resize*(a: var TGtkPaned, `child2_resize`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`child2_resize` shl bp_TGtkPaned_child2_resize) and
-      bm_TGtkPaned_child2_resize)
-
-proc orientation*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_orientation) shr
-      bp_TGtkPaned_orientation
-
-proc set_orientation*(a: var TGtkPaned, `orientation`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`orientation` shl bp_TGtkPaned_orientation) and
-      bm_TGtkPaned_orientation)
-
-proc in_recursion*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_in_recursion) shr
-      bp_TGtkPaned_in_recursion
-
-proc set_in_recursion*(a: var TGtkPaned, `in_recursion`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`in_recursion` shl bp_TGtkPaned_in_recursion) and
-      bm_TGtkPaned_in_recursion)
-
-proc handle_prelit*(a: var TGtkPaned): guint =
-  result = (a.GtkPanedflag0 and bm_TGtkPaned_handle_prelit) shr
-      bp_TGtkPaned_handle_prelit
-
-proc set_handle_prelit*(a: var TGtkPaned, `handle_prelit`: guint) =
-  a.GtkPanedflag0 = a.GtkPanedflag0 or
-      (int16(`handle_prelit` shl bp_TGtkPaned_handle_prelit) and
-      bm_TGtkPaned_handle_prelit)
-
-proc gtk_paned_gutter_size*(p: pointer, s: gint) =
-  if (p != nil) and (s != 0'i32): nil
-
-proc gtk_paned_set_gutter_size*(p: pointer, s: gint) =
-  if (p != nil) and (s != 0'i32): nil
-
-proc GTK_TYPE_HBUTTON_BOX*(): GType =
-  result = gtk_hbutton_box_get_type()
-
-proc GTK_HBUTTON_BOX*(obj: pointer): PGtkHButtonBox =
-  result = cast[PGtkHButtonBox](GTK_CHECK_CAST(obj, GTK_TYPE_HBUTTON_BOX()))
-
-proc GTK_HBUTTON_BOX_CLASS*(klass: pointer): PGtkHButtonBoxClass =
-  result = cast[PGtkHButtonBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HBUTTON_BOX()))
-
-proc GTK_IS_HBUTTON_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HBUTTON_BOX())
-
-proc GTK_IS_HBUTTON_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HBUTTON_BOX())
-
-proc GTK_HBUTTON_BOX_GET_CLASS*(obj: pointer): PGtkHButtonBoxClass =
-  result = cast[PGtkHButtonBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HBUTTON_BOX()))
-
-proc GTK_TYPE_HPANED*(): GType =
-  result = gtk_hpaned_get_type()
-
-proc GTK_HPANED*(obj: pointer): PGtkHPaned =
-  result = cast[PGtkHPaned](GTK_CHECK_CAST(obj, GTK_TYPE_HPANED()))
-
-proc GTK_HPANED_CLASS*(klass: pointer): PGtkHPanedClass =
-  result = cast[PGtkHPanedClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HPANED()))
-
-proc GTK_IS_HPANED*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HPANED())
-
-proc GTK_IS_HPANED_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HPANED())
-
-proc GTK_HPANED_GET_CLASS*(obj: pointer): PGtkHPanedClass =
-  result = cast[PGtkHPanedClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HPANED()))
-
-proc GTK_TYPE_RULER*(): GType =
-  result = gtk_ruler_get_type()
-
-proc GTK_RULER*(obj: pointer): PGtkRuler =
-  result = cast[PGtkRuler](GTK_CHECK_CAST(obj, GTK_TYPE_RULER()))
-
-proc GTK_RULER_CLASS*(klass: pointer): PGtkRulerClass =
-  result = cast[PGtkRulerClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_RULER()))
-
-proc GTK_IS_RULER*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_RULER())
-
-proc GTK_IS_RULER_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_RULER())
-
-proc GTK_RULER_GET_CLASS*(obj: pointer): PGtkRulerClass =
-  result = cast[PGtkRulerClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_RULER()))
-
-proc GTK_TYPE_HRULER*(): GType =
-  result = gtk_hruler_get_type()
-
-proc GTK_HRULER*(obj: pointer): PGtkHRuler =
-  result = cast[PGtkHRuler](GTK_CHECK_CAST(obj, GTK_TYPE_HRULER()))
-
-proc GTK_HRULER_CLASS*(klass: pointer): PGtkHRulerClass =
-  result = cast[PGtkHRulerClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HRULER()))
-
-proc GTK_IS_HRULER*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HRULER())
-
-proc GTK_IS_HRULER_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HRULER())
-
-proc GTK_HRULER_GET_CLASS*(obj: pointer): PGtkHRulerClass =
-  result = cast[PGtkHRulerClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HRULER()))
-
-proc GTK_TYPE_SETTINGS*(): GType =
-  result = gtk_settings_get_type()
-
-proc GTK_SETTINGS*(obj: pointer): PGtkSettings =
-  result = cast[PGtkSettings](GTK_CHECK_CAST(obj, GTK_TYPE_SETTINGS()))
-
-proc GTK_SETTINGS_CLASS*(klass: pointer): PGtkSettingsClass =
-  result = cast[PGtkSettingsClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SETTINGS()))
-
-proc GTK_IS_SETTINGS*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SETTINGS())
-
-proc GTK_IS_SETTINGS_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SETTINGS())
-
-proc GTK_SETTINGS_GET_CLASS*(obj: pointer): PGtkSettingsClass =
-  result = cast[PGtkSettingsClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SETTINGS()))
-
-proc GTK_TYPE_RC_STYLE*(): GType =
-  result = gtk_rc_style_get_type()
-
-proc GTK_RC_STYLE_get*(anObject: pointer): PGtkRcStyle =
-  result = cast[PGtkRcStyle](G_TYPE_CHECK_INSTANCE_CAST(anObject, GTK_TYPE_RC_STYLE()))
-
-proc GTK_RC_STYLE_CLASS*(klass: pointer): PGtkRcStyleClass =
-  result = cast[PGtkRcStyleClass](G_TYPE_CHECK_CLASS_CAST(klass, GTK_TYPE_RC_STYLE()))
-
-proc GTK_IS_RC_STYLE*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_RC_STYLE())
-
-proc GTK_IS_RC_STYLE_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_RC_STYLE())
-
-proc GTK_RC_STYLE_GET_CLASS*(obj: pointer): PGtkRcStyleClass =
-  result = cast[PGtkRcStyleClass](G_TYPE_INSTANCE_GET_CLASS(obj, GTK_TYPE_RC_STYLE()))
-
-proc engine_specified*(a: var TGtkRcStyle): guint =
-  result = (a.GtkRcStyleflag0 and bm_TGtkRcStyle_engine_specified) shr
-      bp_TGtkRcStyle_engine_specified
-
-proc set_engine_specified*(a: var TGtkRcStyle, `engine_specified`: guint) =
-  a.GtkRcStyleflag0 = a.GtkRcStyleflag0 or
-      (int16(`engine_specified` shl bp_TGtkRcStyle_engine_specified) and
-      bm_TGtkRcStyle_engine_specified)
-
-proc GTK_TYPE_STYLE*(): GType =
-  result = gtk_style_get_type()
-
-proc GTK_STYLE*(anObject: pointer): PGtkStyle =
-  result = cast[PGtkStyle](G_TYPE_CHECK_INSTANCE_CAST(anObject, GTK_TYPE_STYLE()))
-
-proc GTK_STYLE_CLASS*(klass: pointer): PGtkStyleClass =
-  result = cast[PGtkStyleClass](G_TYPE_CHECK_CLASS_CAST(klass, GTK_TYPE_STYLE()))
-
-proc GTK_IS_STYLE*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_STYLE())
-
-proc GTK_IS_STYLE_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_STYLE())
-
-proc GTK_STYLE_GET_CLASS*(obj: pointer): PGtkStyleClass =
-  result = cast[PGtkStyleClass](G_TYPE_INSTANCE_GET_CLASS(obj, GTK_TYPE_STYLE()))
-
-proc GTK_TYPE_BORDER*(): GType =
-  result = gtk_border_get_type()
-
-proc GTK_STYLE_ATTACHED*(style: pointer): bool =
-  result = ((GTK_STYLE(style)).attach_count) > 0'i32
-
-proc gtk_style_apply_default_pixmap*(style: PGtkStyle, window: PGdkWindow,
-                                     state_type: TGtkStateType,
-                                     area: PGdkRectangle, x: gint, y: gint,
-                                     width: gint, height: gint) =
-  gtk_style_apply_default_background(style, window, true, state_type, area, x,
-                                     y, width, height)
-
-proc GTK_TYPE_RANGE*(): GType =
-  result = gtk_range_get_type()
-
-proc GTK_RANGE*(obj: pointer): PGtkRange =
-  result = cast[PGtkRange](GTK_CHECK_CAST(obj, GTK_TYPE_RANGE()))
-
-proc GTK_RANGE_CLASS*(klass: pointer): PGtkRangeClass =
-  result = cast[PGtkRangeClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_RANGE()))
-
-proc GTK_IS_RANGE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_RANGE())
-
-proc GTK_IS_RANGE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_RANGE())
-
-proc GTK_RANGE_GET_CLASS*(obj: pointer): PGtkRangeClass =
-  result = cast[PGtkRangeClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_RANGE()))
-
-proc inverted*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_inverted) shr bp_TGtkRange_inverted
-
-proc set_inverted*(a: var TGtkRange, `inverted`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`inverted` shl bp_TGtkRange_inverted) and bm_TGtkRange_inverted)
-
-proc flippable*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_flippable) shr bp_TGtkRange_flippable
-
-proc set_flippable*(a: var TGtkRange, `flippable`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`flippable` shl bp_TGtkRange_flippable) and bm_TGtkRange_flippable)
-
-proc has_stepper_a*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_has_stepper_a) shr
-      bp_TGtkRange_has_stepper_a
-
-proc set_has_stepper_a*(a: var TGtkRange, `has_stepper_a`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`has_stepper_a` shl bp_TGtkRange_has_stepper_a) and
-      bm_TGtkRange_has_stepper_a)
-
-proc has_stepper_b*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_has_stepper_b) shr
-      bp_TGtkRange_has_stepper_b
-
-proc set_has_stepper_b*(a: var TGtkRange, `has_stepper_b`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`has_stepper_b` shl bp_TGtkRange_has_stepper_b) and
-      bm_TGtkRange_has_stepper_b)
-
-proc has_stepper_c*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_has_stepper_c) shr
-      bp_TGtkRange_has_stepper_c
-
-proc set_has_stepper_c*(a: var TGtkRange, `has_stepper_c`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`has_stepper_c` shl bp_TGtkRange_has_stepper_c) and
-      bm_TGtkRange_has_stepper_c)
-
-proc has_stepper_d*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_has_stepper_d) shr
-      bp_TGtkRange_has_stepper_d
-
-proc set_has_stepper_d*(a: var TGtkRange, `has_stepper_d`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`has_stepper_d` shl bp_TGtkRange_has_stepper_d) and
-      bm_TGtkRange_has_stepper_d)
-
-proc need_recalc*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_need_recalc) shr
-      bp_TGtkRange_need_recalc
-
-proc set_need_recalc*(a: var TGtkRange, `need_recalc`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`need_recalc` shl bp_TGtkRange_need_recalc) and
-      bm_TGtkRange_need_recalc)
-
-proc slider_size_fixed*(a: var TGtkRange): guint =
-  result = (a.GtkRangeflag0 and bm_TGtkRange_slider_size_fixed) shr
-      bp_TGtkRange_slider_size_fixed
-
-proc set_slider_size_fixed*(a: var TGtkRange, `slider_size_fixed`: guint) =
-  a.GtkRangeflag0 = a.GtkRangeflag0 or
-      (int16(`slider_size_fixed` shl bp_TGtkRange_slider_size_fixed) and
-      bm_TGtkRange_slider_size_fixed)
-
-proc trough_click_forward*(a: var TGtkRange): guint =
-  result = (a.flag1 and bm_TGtkRange_trough_click_forward) shr
-      bp_TGtkRange_trough_click_forward
-
-proc set_trough_click_forward*(a: var TGtkRange, `trough_click_forward`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`trough_click_forward` shl bp_TGtkRange_trough_click_forward) and
-      bm_TGtkRange_trough_click_forward)
-
-proc update_pending*(a: var TGtkRange): guint =
-  result = (a.flag1 and bm_TGtkRange_update_pending) shr
-      bp_TGtkRange_update_pending
-
-proc set_update_pending*(a: var TGtkRange, `update_pending`: guint) =
-  a.flag1 = a.flag1 or
-      (int16(`update_pending` shl bp_TGtkRange_update_pending) and
-      bm_TGtkRange_update_pending)
-
-proc GTK_TYPE_SCALE*(): GType =
-  result = gtk_scale_get_type()
-
-proc GTK_SCALE*(obj: pointer): PGtkScale =
-  result = cast[PGtkScale](GTK_CHECK_CAST(obj, GTK_TYPE_SCALE()))
-
-proc GTK_SCALE_CLASS*(klass: pointer): PGtkScaleClass =
-  result = cast[PGtkScaleClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SCALE()))
-
-proc GTK_IS_SCALE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SCALE())
-
-proc GTK_IS_SCALE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SCALE())
-
-proc GTK_SCALE_GET_CLASS*(obj: pointer): PGtkScaleClass =
-  result = cast[PGtkScaleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SCALE()))
-
-proc draw_value*(a: var TGtkScale): guint =
-  result = (a.GtkScaleflag0 and bm_TGtkScale_draw_value) shr bp_TGtkScale_draw_value
-
-proc set_draw_value*(a: var TGtkScale, `draw_value`: guint) =
-  a.GtkScaleflag0 = a.GtkScaleflag0 or
-      (int16(`draw_value` shl bp_TGtkScale_draw_value) and bm_TGtkScale_draw_value)
-
-proc value_pos*(a: var TGtkScale): guint =
-  result = (a.GtkScaleflag0 and bm_TGtkScale_value_pos) shr bp_TGtkScale_value_pos
-
-proc set_value_pos*(a: var TGtkScale, `value_pos`: guint) =
-  a.GtkScaleflag0 = a.GtkScaleflag0 or
-      (int16(`value_pos` shl bp_TGtkScale_value_pos) and bm_TGtkScale_value_pos)
-
-proc GTK_TYPE_HSCALE*(): GType =
-  result = gtk_hscale_get_type()
-
-proc GTK_HSCALE*(obj: pointer): PGtkHScale =
-  result = cast[PGtkHScale](GTK_CHECK_CAST(obj, GTK_TYPE_HSCALE()))
-
-proc GTK_HSCALE_CLASS*(klass: pointer): PGtkHScaleClass =
-  result = cast[PGtkHScaleClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HSCALE()))
-
-proc GTK_IS_HSCALE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HSCALE())
-
-proc GTK_IS_HSCALE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HSCALE())
-
-proc GTK_HSCALE_GET_CLASS*(obj: pointer): PGtkHScaleClass =
-  result = cast[PGtkHScaleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HSCALE()))
-
-proc GTK_TYPE_SCROLLBAR*(): GType =
-  result = gtk_scrollbar_get_type()
-
-proc GTK_SCROLLBAR*(obj: pointer): PGtkScrollbar =
-  result = cast[PGtkScrollbar](GTK_CHECK_CAST(obj, GTK_TYPE_SCROLLBAR()))
-
-proc GTK_SCROLLBAR_CLASS*(klass: pointer): PGtkScrollbarClass =
-  result = cast[PGtkScrollbarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SCROLLBAR()))
-
-proc GTK_IS_SCROLLBAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SCROLLBAR())
-
-proc GTK_IS_SCROLLBAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SCROLLBAR())
-
-proc GTK_SCROLLBAR_GET_CLASS*(obj: pointer): PGtkScrollbarClass =
-  result = cast[PGtkScrollbarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SCROLLBAR()))
-
-proc GTK_TYPE_HSCROLLBAR*(): GType =
-  result = gtk_hscrollbar_get_type()
-
-proc GTK_HSCROLLBAR*(obj: pointer): PGtkHScrollbar =
-  result = cast[PGtkHScrollbar](GTK_CHECK_CAST(obj, GTK_TYPE_HSCROLLBAR()))
-
-proc GTK_HSCROLLBAR_CLASS*(klass: pointer): PGtkHScrollbarClass =
-  result = cast[PGtkHScrollbarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HSCROLLBAR()))
-
-proc GTK_IS_HSCROLLBAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HSCROLLBAR())
-
-proc GTK_IS_HSCROLLBAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HSCROLLBAR())
-
-proc GTK_HSCROLLBAR_GET_CLASS*(obj: pointer): PGtkHScrollbarClass =
-  result = cast[PGtkHScrollbarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HSCROLLBAR()))
-
-proc GTK_TYPE_SEPARATOR*(): GType =
-  result = gtk_separator_get_type()
-
-proc GTK_SEPARATOR*(obj: pointer): PGtkSeparator =
-  result = cast[PGtkSeparator](GTK_CHECK_CAST(obj, GTK_TYPE_SEPARATOR()))
-
-proc GTK_SEPARATOR_CLASS*(klass: pointer): PGtkSeparatorClass =
-  result = cast[PGtkSeparatorClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SEPARATOR()))
-
-proc GTK_IS_SEPARATOR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SEPARATOR())
-
-proc GTK_IS_SEPARATOR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SEPARATOR())
-
-proc GTK_SEPARATOR_GET_CLASS*(obj: pointer): PGtkSeparatorClass =
-  result = cast[PGtkSeparatorClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SEPARATOR()))
-
-proc GTK_TYPE_HSEPARATOR*(): GType =
-  result = gtk_hseparator_get_type()
-
-proc GTK_HSEPARATOR*(obj: pointer): PGtkHSeparator =
-  result = cast[PGtkHSeparator](GTK_CHECK_CAST(obj, GTK_TYPE_HSEPARATOR()))
-
-proc GTK_HSEPARATOR_CLASS*(klass: pointer): PGtkHSeparatorClass =
-  result = cast[PGtkHSeparatorClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_HSEPARATOR()))
-
-proc GTK_IS_HSEPARATOR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_HSEPARATOR())
-
-proc GTK_IS_HSEPARATOR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_HSEPARATOR())
-
-proc GTK_HSEPARATOR_GET_CLASS*(obj: pointer): PGtkHSeparatorClass =
-  result = cast[PGtkHSeparatorClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_HSEPARATOR()))
-
-proc GTK_TYPE_ICON_FACTORY*(): GType =
-  result = gtk_icon_factory_get_type()
-
-proc GTK_ICON_FACTORY*(anObject: pointer): PGtkIconFactory =
-  result = cast[PGtkIconFactory](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GTK_TYPE_ICON_FACTORY()))
-
-proc GTK_ICON_FACTORY_CLASS*(klass: pointer): PGtkIconFactoryClass =
-  result = cast[PGtkIconFactoryClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_ICON_FACTORY()))
-
-proc GTK_IS_ICON_FACTORY*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_ICON_FACTORY())
-
-proc GTK_IS_ICON_FACTORY_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_ICON_FACTORY())
-
-proc GTK_ICON_FACTORY_GET_CLASS*(obj: pointer): PGtkIconFactoryClass =
-  result = cast[PGtkIconFactoryClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_ICON_FACTORY()))
-
-proc GTK_TYPE_ICON_SET*(): GType =
-  result = gtk_icon_set_get_type()
-
-proc GTK_TYPE_ICON_SOURCE*(): GType =
-  result = gtk_icon_source_get_type()
-
-proc GTK_TYPE_IMAGE*(): GType =
-  result = gtk_image_get_type()
-
-proc GTK_IMAGE*(obj: pointer): PGtkImage =
-  result = cast[PGtkImage](GTK_CHECK_CAST(obj, GTK_TYPE_IMAGE()))
-
-proc GTK_IMAGE_CLASS*(klass: pointer): PGtkImageClass =
-  result = cast[PGtkImageClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_IMAGE()))
-
-proc GTK_IS_IMAGE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_IMAGE())
-
-proc GTK_IS_IMAGE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_IMAGE())
-
-proc GTK_IMAGE_GET_CLASS*(obj: pointer): PGtkImageClass =
-  result = cast[PGtkImageClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_IMAGE()))
-
-proc GTK_TYPE_IMAGE_MENU_ITEM*(): GType =
-  result = gtk_image_menu_item_get_type()
-
-proc GTK_IMAGE_MENU_ITEM*(obj: pointer): PGtkImageMenuItem =
-  result = cast[PGtkImageMenuItem](GTK_CHECK_CAST(obj, GTK_TYPE_IMAGE_MENU_ITEM()))
-
-proc GTK_IMAGE_MENU_ITEM_CLASS*(klass: pointer): PGtkImageMenuItemClass =
-  result = cast[PGtkImageMenuItemClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_IMAGE_MENU_ITEM()))
-
-proc GTK_IS_IMAGE_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_IMAGE_MENU_ITEM())
-
-proc GTK_IS_IMAGE_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_IMAGE_MENU_ITEM())
-
-proc GTK_IMAGE_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkImageMenuItemClass =
-  result = cast[PGtkImageMenuItemClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_IMAGE_MENU_ITEM()))
-
-proc GTK_TYPE_IM_CONTEXT_SIMPLE*(): GType =
-  result = gtk_im_context_simple_get_type()
-
-proc GTK_IM_CONTEXT_SIMPLE*(obj: pointer): PGtkIMContextSimple =
-  result = cast[PGtkIMContextSimple](GTK_CHECK_CAST(obj, GTK_TYPE_IM_CONTEXT_SIMPLE()))
-
-proc GTK_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): PGtkIMContextSimpleClass =
-  result = cast[PGtkIMContextSimpleClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_IM_CONTEXT_SIMPLE()))
-
-proc GTK_IS_IM_CONTEXT_SIMPLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_IM_CONTEXT_SIMPLE())
-
-proc GTK_IS_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_IM_CONTEXT_SIMPLE())
-
-proc GTK_IM_CONTEXT_SIMPLE_GET_CLASS*(obj: pointer): PGtkIMContextSimpleClass =
-  result = cast[PGtkIMContextSimpleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_IM_CONTEXT_SIMPLE()))
-
-proc in_hex_sequence*(a: var TGtkIMContextSimple): guint =
-  result = (a.GtkIMContextSimpleflag0 and bm_TGtkIMContextSimple_in_hex_sequence) shr
-      bp_TGtkIMContextSimple_in_hex_sequence
-
-proc set_in_hex_sequence*(a: var TGtkIMContextSimple, `in_hex_sequence`: guint) =
-  a.GtkIMContextSimpleflag0 = a.GtkIMContextSimpleflag0 or
-      (int16(`in_hex_sequence` shl bp_TGtkIMContextSimple_in_hex_sequence) and
-      bm_TGtkIMContextSimple_in_hex_sequence)
-
-proc GTK_TYPE_IM_MULTICONTEXT*(): GType =
-  result = gtk_im_multicontext_get_type()
-
-proc GTK_IM_MULTICONTEXT*(obj: pointer): PGtkIMMulticontext =
-  result = cast[PGtkIMMulticontext](GTK_CHECK_CAST(obj, GTK_TYPE_IM_MULTICONTEXT()))
-
-proc GTK_IM_MULTICONTEXT_CLASS*(klass: pointer): PGtkIMMulticontextClass =
-  result = cast[PGtkIMMulticontextClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_IM_MULTICONTEXT()))
-
-proc GTK_IS_IM_MULTICONTEXT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_IM_MULTICONTEXT())
-
-proc GTK_IS_IM_MULTICONTEXT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_IM_MULTICONTEXT())
-
-proc GTK_IM_MULTICONTEXT_GET_CLASS*(obj: pointer): PGtkIMMulticontextClass =
-  result = cast[PGtkIMMulticontextClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_IM_MULTICONTEXT()))
-
-proc GTK_TYPE_INPUT_DIALOG*(): GType =
-  result = gtk_input_dialog_get_type()
-
-proc GTK_INPUT_DIALOG*(obj: pointer): PGtkInputDialog =
-  result = cast[PGtkInputDialog](GTK_CHECK_CAST(obj, GTK_TYPE_INPUT_DIALOG()))
-
-proc GTK_INPUT_DIALOG_CLASS*(klass: pointer): PGtkInputDialogClass =
-  result = cast[PGtkInputDialogClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_INPUT_DIALOG()))
-
-proc GTK_IS_INPUT_DIALOG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_INPUT_DIALOG())
-
-proc GTK_IS_INPUT_DIALOG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_INPUT_DIALOG())
-
-proc GTK_INPUT_DIALOG_GET_CLASS*(obj: pointer): PGtkInputDialogClass =
-  result = cast[PGtkInputDialogClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_INPUT_DIALOG()))
-
-proc GTK_TYPE_INVISIBLE*(): GType =
-  result = gtk_invisible_get_type()
-
-proc GTK_INVISIBLE*(obj: pointer): PGtkInvisible =
-  result = cast[PGtkInvisible](GTK_CHECK_CAST(obj, GTK_TYPE_INVISIBLE()))
-
-proc GTK_INVISIBLE_CLASS*(klass: pointer): PGtkInvisibleClass =
-  result = cast[PGtkInvisibleClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_INVISIBLE()))
-
-proc GTK_IS_INVISIBLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_INVISIBLE())
-
-proc GTK_IS_INVISIBLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_INVISIBLE())
-
-proc GTK_INVISIBLE_GET_CLASS*(obj: pointer): PGtkInvisibleClass =
-  result = cast[PGtkInvisibleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_INVISIBLE()))
-
-proc GTK_TYPE_ITEM_FACTORY*(): GType =
-  result = gtk_item_factory_get_type()
-
-proc GTK_ITEM_FACTORY*(anObject: pointer): PGtkItemFactory =
-  result = cast[PGtkItemFactory](GTK_CHECK_CAST(anObject, GTK_TYPE_ITEM_FACTORY()))
-
-proc GTK_ITEM_FACTORY_CLASS*(klass: pointer): PGtkItemFactoryClass =
-  result = cast[PGtkItemFactoryClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_ITEM_FACTORY()))
-
-proc GTK_IS_ITEM_FACTORY*(anObject: pointer): bool =
-  result = GTK_CHECK_TYPE(anObject, GTK_TYPE_ITEM_FACTORY())
-
-proc GTK_IS_ITEM_FACTORY_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_ITEM_FACTORY())
-
-proc GTK_ITEM_FACTORY_GET_CLASS*(obj: pointer): PGtkItemFactoryClass =
-  result = cast[PGtkItemFactoryClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_ITEM_FACTORY()))
-
-proc GTK_TYPE_LAYOUT*(): GType =
-  result = gtk_layout_get_type()
-
-proc GTK_LAYOUT*(obj: pointer): PGtkLayout =
-  result = cast[PGtkLayout](GTK_CHECK_CAST(obj, GTK_TYPE_LAYOUT()))
-
-proc GTK_LAYOUT_CLASS*(klass: pointer): PGtkLayoutClass =
-  result = cast[PGtkLayoutClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_LAYOUT()))
-
-proc GTK_IS_LAYOUT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_LAYOUT())
-
-proc GTK_IS_LAYOUT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_LAYOUT())
-
-proc GTK_LAYOUT_GET_CLASS*(obj: pointer): PGtkLayoutClass =
-  result = cast[PGtkLayoutClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_LAYOUT()))
-
-proc GTK_TYPE_LIST*(): GType =
-  result = gtk_list_get_type()
-
-proc GTK_LIST*(obj: pointer): PGtkList =
-  result = cast[PGtkList](GTK_CHECK_CAST(obj, GTK_TYPE_LIST()))
-
-proc GTK_LIST_CLASS*(klass: pointer): PGtkListClass =
-  result = cast[PGtkListClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_LIST()))
-
-proc GTK_IS_LIST*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_LIST())
-
-proc GTK_IS_LIST_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_LIST())
-
-proc GTK_LIST_GET_CLASS*(obj: pointer): PGtkListClass =
-  result = cast[PGtkListClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_LIST()))
-
-proc selection_mode*(a: var TGtkList): guint =
-  result = (a.GtkListflag0 and bm_TGtkList_selection_mode) shr
-      bp_TGtkList_selection_mode
-
-proc set_selection_mode*(a: var TGtkList, `selection_mode`: guint) =
-  a.GtkListflag0 = a.GtkListflag0 or
-      (int16(`selection_mode` shl bp_TGtkList_selection_mode) and
-      bm_TGtkList_selection_mode)
-
-proc drag_selection*(a: var TGtkList): guint =
-  result = (a.GtkListflag0 and bm_TGtkList_drag_selection) shr
-      bp_TGtkList_drag_selection
-
-proc set_drag_selection*(a: var TGtkList, `drag_selection`: guint) =
-  a.GtkListflag0 = a.GtkListflag0 or
-      (int16(`drag_selection` shl bp_TGtkList_drag_selection) and
-      bm_TGtkList_drag_selection)
-
-proc add_mode*(a: var TGtkList): guint =
-  result = (a.GtkListflag0 and bm_TGtkList_add_mode) shr bp_TGtkList_add_mode
-
-proc set_add_mode*(a: var TGtkList, `add_mode`: guint) =
-  a.GtkListflag0 = a.GtkListflag0 or
-      (int16(`add_mode` shl bp_TGtkList_add_mode) and bm_TGtkList_add_mode)
-
-proc gtk_list_item_get_type(): GType {.importc, cdecl, dynlib: gtklib.}
-
-proc GTK_TYPE_LIST_ITEM*(): GType =
-  result = gtk_list_item_get_type()
-
-type
-  TGtkListItem = object of TGtkItem
-  TGtkListItemClass = object of TGtkItemClass
-  PGtkListItem = ptr TGtkListItem
-  PGtkListItemClass = ptr TGtkListItemClass
-
-proc GTK_LIST_ITEM*(obj: pointer): PGtkListItem =
-  result = cast[PGtkListItem](GTK_CHECK_CAST(obj, GTK_TYPE_LIST_ITEM()))
-
-proc GTK_LIST_ITEM_CLASS*(klass: pointer): PGtkListItemClass =
-  result = cast[PGtkListItemClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_LIST_ITEM()))
-
-proc GTK_IS_LIST_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_LIST_ITEM())
-
-proc GTK_IS_LIST_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_LIST_ITEM())
-
-proc GTK_LIST_ITEM_GET_CLASS*(obj: pointer): PGtkListItemClass =
-  result = cast[PGtkListItemClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_LIST_ITEM()))
-
-#proc gtk_tree_model_get_type(): GType {.importc, cdecl, dynlib: gtklib.}
-
-proc GTK_TYPE_TREE_MODEL*(): GType =
-  result = gtk_tree_model_get_type()
-
-proc GTK_TREE_MODEL*(obj: pointer): PGtkTreeModel =
-  result = cast[PGtkTreeModel](G_TYPE_CHECK_INSTANCE_CAST(obj, GTK_TYPE_TREE_MODEL()))
-
-proc GTK_IS_TREE_MODEL*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TREE_MODEL())
-
-proc GTK_TREE_MODEL_GET_IFACE*(obj: pointer): PGtkTreeModelIface =
-  result = cast[PGtkTreeModelIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      GTK_TYPE_TREE_MODEL()))
-
-proc GTK_TYPE_TREE_ITER*(): GType =
-  result = gtk_tree_iter_get_type()
-
-proc GTK_TYPE_TREE_PATH*(): GType =
-  result = gtk_tree_path_get_type()
-
-proc gtk_tree_path_new_root*(): PGtkTreePath =
-  result = gtk_tree_path_new_first()
-
-proc gtk_tree_model_get_iter_root*(tree_model: PGtkTreeModel, iter: PGtkTreeIter): gboolean =
-  result = gtk_tree_model_get_iter_first(tree_model, iter)
-
-proc GTK_TYPE_TREE_SORTABLE*(): GType =
-  result = gtk_tree_sortable_get_type()
-
-proc GTK_TREE_SORTABLE*(obj: pointer): PGtkTreeSortable =
-  result = cast[PGtkTreeSortable](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GTK_TYPE_TREE_SORTABLE()))
-
-proc GTK_TREE_SORTABLE_CLASS*(obj: pointer): PGtkTreeSortableIface =
-  result = cast[PGtkTreeSortableIface](G_TYPE_CHECK_CLASS_CAST(obj,
-      GTK_TYPE_TREE_SORTABLE()))
-
-proc GTK_IS_TREE_SORTABLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TREE_SORTABLE())
-
-proc GTK_TREE_SORTABLE_GET_IFACE*(obj: pointer): PGtkTreeSortableIface =
-  result = cast[PGtkTreeSortableIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      GTK_TYPE_TREE_SORTABLE()))
-
-proc GTK_TYPE_TREE_MODEL_SORT*(): GType =
-  result = gtk_tree_model_sort_get_type()
-
-proc GTK_TREE_MODEL_SORT*(obj: pointer): PGtkTreeModelSort =
-  result = cast[PGtkTreeModelSort](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_MODEL_SORT()))
-
-proc GTK_TREE_MODEL_SORT_CLASS*(klass: pointer): PGtkTreeModelSortClass =
-  result = cast[PGtkTreeModelSortClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TREE_MODEL_SORT()))
-
-proc GTK_IS_TREE_MODEL_SORT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_MODEL_SORT())
-
-proc GTK_IS_TREE_MODEL_SORT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_MODEL_SORT())
-
-proc GTK_TREE_MODEL_SORT_GET_CLASS*(obj: pointer): PGtkTreeModelSortClass =
-  result = cast[PGtkTreeModelSortClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_TREE_MODEL_SORT()))
-
-proc GTK_TYPE_LIST_STORE*(): GType =
-  result = gtk_list_store_get_type()
-
-proc GTK_LIST_STORE*(obj: pointer): PGtkListStore =
-  result = cast[PGtkListStore](GTK_CHECK_CAST(obj, GTK_TYPE_LIST_STORE()))
-
-proc GTK_LIST_STORE_CLASS*(klass: pointer): PGtkListStoreClass =
-  result = cast[PGtkListStoreClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_LIST_STORE()))
-
-proc GTK_IS_LIST_STORE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_LIST_STORE())
-
-proc GTK_IS_LIST_STORE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_LIST_STORE())
-
-proc GTK_LIST_STORE_GET_CLASS*(obj: pointer): PGtkListStoreClass =
-  result = cast[PGtkListStoreClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_LIST_STORE()))
-
-proc columns_dirty*(a: var TGtkListStore): guint =
-  result = (a.GtkListStoreflag0 and bm_TGtkListStore_columns_dirty) shr
-      bp_TGtkListStore_columns_dirty
-
-proc set_columns_dirty*(a: var TGtkListStore, `columns_dirty`: guint) =
-  a.GtkListStoreflag0 = a.GtkListStoreflag0 or
-      (int16(`columns_dirty` shl bp_TGtkListStore_columns_dirty) and
-      bm_TGtkListStore_columns_dirty)
-
-proc GTK_TYPE_MENU_BAR*(): GType =
-  result = gtk_menu_bar_get_type()
-
-proc GTK_MENU_BAR*(obj: pointer): PGtkMenuBar =
-  result = cast[PGtkMenuBar](GTK_CHECK_CAST(obj, GTK_TYPE_MENU_BAR()))
-
-proc GTK_MENU_BAR_CLASS*(klass: pointer): PGtkMenuBarClass =
-  result = cast[PGtkMenuBarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_MENU_BAR()))
-
-proc GTK_IS_MENU_BAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MENU_BAR())
-
-proc GTK_IS_MENU_BAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MENU_BAR())
-
-proc GTK_MENU_BAR_GET_CLASS*(obj: pointer): PGtkMenuBarClass =
-  result = cast[PGtkMenuBarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_MENU_BAR()))
-
-proc gtk_menu_bar_append*(menu, child: PGtkWidget) =
-  gtk_menu_shell_append(cast[PGtkMenuShell](menu), child)
-
-proc gtk_menu_bar_prepend*(menu, child: PGtkWidget) =
-  gtk_menu_shell_prepend(cast[PGtkMenuShell](menu), child)
-
-proc gtk_menu_bar_insert*(menu, child: PGtkWidget, pos: gint) =
-  gtk_menu_shell_insert(cast[PGtkMenuShell](menu), child, pos)
-
-proc GTK_TYPE_MESSAGE_DIALOG*(): GType =
-  result = gtk_message_dialog_get_type()
-
-proc GTK_MESSAGE_DIALOG*(obj: pointer): PGtkMessageDialog =
-  result = cast[PGtkMessageDialog](GTK_CHECK_CAST(obj, GTK_TYPE_MESSAGE_DIALOG()))
-
-proc GTK_MESSAGE_DIALOG_CLASS*(klass: pointer): PGtkMessageDialogClass =
-  result = cast[PGtkMessageDialogClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_MESSAGE_DIALOG()))
-
-proc GTK_IS_MESSAGE_DIALOG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_MESSAGE_DIALOG())
-
-proc GTK_IS_MESSAGE_DIALOG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_MESSAGE_DIALOG())
-
-proc GTK_MESSAGE_DIALOG_GET_CLASS*(obj: pointer): PGtkMessageDialogClass =
-  result = cast[PGtkMessageDialogClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_MESSAGE_DIALOG()))
-
-proc GTK_TYPE_NOTEBOOK*(): GType =
-  result = gtk_notebook_get_type()
-
-proc GTK_NOTEBOOK*(obj: pointer): PGtkNotebook =
-  result = cast[PGtkNotebook](GTK_CHECK_CAST(obj, GTK_TYPE_NOTEBOOK()))
-
-proc GTK_NOTEBOOK_CLASS*(klass: pointer): PGtkNotebookClass =
-  result = cast[PGtkNotebookClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_NOTEBOOK()))
-
-proc GTK_IS_NOTEBOOK*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_NOTEBOOK())
-
-proc GTK_IS_NOTEBOOK_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_NOTEBOOK())
-
-proc GTK_NOTEBOOK_GET_CLASS*(obj: pointer): PGtkNotebookClass =
-  result = cast[PGtkNotebookClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_NOTEBOOK()))
-
-proc show_tabs*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_show_tabs) shr
-      bp_TGtkNotebook_show_tabs
-
-proc set_show_tabs*(a: var TGtkNotebook, `show_tabs`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`show_tabs` shl bp_TGtkNotebook_show_tabs) and
-      bm_TGtkNotebook_show_tabs)
-
-proc homogeneous*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_homogeneous) shr
-      bp_TGtkNotebook_homogeneous
-
-proc set_homogeneous*(a: var TGtkNotebook, `homogeneous`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`homogeneous` shl bp_TGtkNotebook_homogeneous) and
-      bm_TGtkNotebook_homogeneous)
-
-proc show_border*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_show_border) shr
-      bp_TGtkNotebook_show_border
-
-proc set_show_border*(a: var TGtkNotebook, `show_border`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`show_border` shl bp_TGtkNotebook_show_border) and
-      bm_TGtkNotebook_show_border)
-
-proc tab_pos*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_tab_pos) shr bp_TGtkNotebook_tab_pos
-
-proc set_tab_pos*(a: var TGtkNotebook, `tab_pos`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`tab_pos` shl bp_TGtkNotebook_tab_pos) and bm_TGtkNotebook_tab_pos)
-
-proc scrollable*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_scrollable) shr
-      bp_TGtkNotebook_scrollable
-
-proc set_scrollable*(a: var TGtkNotebook, `scrollable`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`scrollable` shl bp_TGtkNotebook_scrollable) and
-      bm_TGtkNotebook_scrollable)
-
-proc in_child*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_in_child) shr
-      bp_TGtkNotebook_in_child
-
-proc set_in_child*(a: var TGtkNotebook, `in_child`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`in_child` shl bp_TGtkNotebook_in_child) and bm_TGtkNotebook_in_child)
-
-proc click_child*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_click_child) shr
-      bp_TGtkNotebook_click_child
-
-proc set_click_child*(a: var TGtkNotebook, `click_child`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`click_child` shl bp_TGtkNotebook_click_child) and
-      bm_TGtkNotebook_click_child)
-
-proc button*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_button) shr bp_TGtkNotebook_button
-
-proc set_button*(a: var TGtkNotebook, `button`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`button` shl bp_TGtkNotebook_button) and bm_TGtkNotebook_button)
-
-proc need_timer*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_need_timer) shr
-      bp_TGtkNotebook_need_timer
-
-proc set_need_timer*(a: var TGtkNotebook, `need_timer`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`need_timer` shl bp_TGtkNotebook_need_timer) and
-      bm_TGtkNotebook_need_timer)
-
-proc child_has_focus*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_child_has_focus) shr
-      bp_TGtkNotebook_child_has_focus
-
-proc set_child_has_focus*(a: var TGtkNotebook, `child_has_focus`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`child_has_focus` shl bp_TGtkNotebook_child_has_focus) and
-      bm_TGtkNotebook_child_has_focus)
-
-proc have_visible_child*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_have_visible_child) shr
-      bp_TGtkNotebook_have_visible_child
-
-proc set_have_visible_child*(a: var TGtkNotebook, `have_visible_child`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`have_visible_child` shl bp_TGtkNotebook_have_visible_child) and
-      bm_TGtkNotebook_have_visible_child)
-
-proc focus_out*(a: var TGtkNotebook): guint =
-  result = (a.GtkNotebookflag0 and bm_TGtkNotebook_focus_out) shr
-      bp_TGtkNotebook_focus_out
-
-proc set_focus_out*(a: var TGtkNotebook, `focus_out`: guint) =
-  a.GtkNotebookflag0 = a.GtkNotebookflag0 or
-      (int16(`focus_out` shl bp_TGtkNotebook_focus_out) and
-      bm_TGtkNotebook_focus_out)
-
-proc GTK_TYPE_OLD_EDITABLE*(): GType =
-  result = gtk_old_editable_get_type()
-
-proc GTK_OLD_EDITABLE*(obj: pointer): PGtkOldEditable =
-  result = cast[PGtkOldEditable](GTK_CHECK_CAST(obj, GTK_TYPE_OLD_EDITABLE()))
-
-proc GTK_OLD_EDITABLE_CLASS*(klass: pointer): PGtkOldEditableClass =
-  result = cast[PGtkOldEditableClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_OLD_EDITABLE()))
-
-proc GTK_IS_OLD_EDITABLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_OLD_EDITABLE())
-
-proc GTK_IS_OLD_EDITABLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_OLD_EDITABLE())
-
-proc GTK_OLD_EDITABLE_GET_CLASS*(obj: pointer): PGtkOldEditableClass =
-  result = cast[PGtkOldEditableClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_OLD_EDITABLE()))
-
-proc has_selection*(a: var TGtkOldEditable): guint =
-  result = (a.GtkOldEditableflag0 and bm_TGtkOldEditable_has_selection) shr
-      bp_TGtkOldEditable_has_selection
-
-proc set_has_selection*(a: var TGtkOldEditable, `has_selection`: guint) =
-  a.GtkOldEditableflag0 = a.GtkOldEditableflag0 or
-      (int16(`has_selection` shl bp_TGtkOldEditable_has_selection) and
-      bm_TGtkOldEditable_has_selection)
-
-proc editable*(a: var TGtkOldEditable): guint =
-  result = (a.GtkOldEditableflag0 and bm_TGtkOldEditable_editable) shr
-      bp_TGtkOldEditable_editable
-
-proc set_editable*(a: var TGtkOldEditable, `editable`: guint) =
-  a.GtkOldEditableflag0 = a.GtkOldEditableflag0 or
-      (int16(`editable` shl bp_TGtkOldEditable_editable) and
-      bm_TGtkOldEditable_editable)
-
-proc visible*(a: var TGtkOldEditable): guint =
-  result = (a.GtkOldEditableflag0 and bm_TGtkOldEditable_visible) shr
-      bp_TGtkOldEditable_visible
-
-proc set_visible*(a: var TGtkOldEditable, `visible`: guint) =
-  a.GtkOldEditableflag0 = a.GtkOldEditableflag0 or
-      (int16(`visible` shl bp_TGtkOldEditable_visible) and
-      bm_TGtkOldEditable_visible)
-
-proc GTK_TYPE_OPTION_MENU*(): GType =
-  result = gtk_option_menu_get_type()
-
-proc GTK_OPTION_MENU*(obj: pointer): PGtkOptionMenu =
-  result = cast[PGtkOptionMenu](GTK_CHECK_CAST(obj, GTK_TYPE_OPTION_MENU()))
-
-proc GTK_OPTION_MENU_CLASS*(klass: pointer): PGtkOptionMenuClass =
-  result = cast[PGtkOptionMenuClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_OPTION_MENU()))
-
-proc GTK_IS_OPTION_MENU*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_OPTION_MENU())
-
-proc GTK_IS_OPTION_MENU_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_OPTION_MENU())
-
-proc GTK_OPTION_MENU_GET_CLASS*(obj: pointer): PGtkOptionMenuClass =
-  result = cast[PGtkOptionMenuClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_OPTION_MENU()))
-
-proc GTK_TYPE_PIXMAP*(): GType =
-  result = gtk_pixmap_get_type()
-
-proc GTK_PIXMAP*(obj: pointer): PGtkPixmap =
-  result = cast[PGtkPixmap](GTK_CHECK_CAST(obj, GTK_TYPE_PIXMAP()))
-
-proc GTK_PIXMAP_CLASS*(klass: pointer): PGtkPixmapClass =
-  result = cast[PGtkPixmapClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_PIXMAP()))
-
-proc GTK_IS_PIXMAP*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PIXMAP())
-
-proc GTK_IS_PIXMAP_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PIXMAP())
-
-proc GTK_PIXMAP_GET_CLASS*(obj: pointer): PGtkPixmapClass =
-  result = cast[PGtkPixmapClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PIXMAP()))
-
-proc build_insensitive*(a: var TGtkPixmap): guint =
-  result = (a.GtkPixmapflag0 and bm_TGtkPixmap_build_insensitive) shr
-      bp_TGtkPixmap_build_insensitive
-
-proc set_build_insensitive*(a: var TGtkPixmap, `build_insensitive`: guint) =
-  a.GtkPixmapflag0 = a.GtkPixmapflag0 or
-      (int16(`build_insensitive` shl bp_TGtkPixmap_build_insensitive) and
-      bm_TGtkPixmap_build_insensitive)
-
-proc GTK_TYPE_PLUG*(): GType =
-  result = gtk_plug_get_type()
-
-proc GTK_PLUG*(obj: pointer): PGtkPlug =
-  result = cast[PGtkPlug](GTK_CHECK_CAST(obj, GTK_TYPE_PLUG()))
-
-proc GTK_PLUG_CLASS*(klass: pointer): PGtkPlugClass =
-  result = cast[PGtkPlugClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_PLUG()))
-
-proc GTK_IS_PLUG*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PLUG())
-
-proc GTK_IS_PLUG_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PLUG())
-
-proc GTK_PLUG_GET_CLASS*(obj: pointer): PGtkPlugClass =
-  result = cast[PGtkPlugClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PLUG()))
-
-proc same_app*(a: var TGtkPlug): guint =
-  result = (a.GtkPlugflag0 and bm_TGtkPlug_same_app) shr bp_TGtkPlug_same_app
-
-proc set_same_app*(a: var TGtkPlug, `same_app`: guint) =
-  a.GtkPlugflag0 = a.GtkPlugflag0 or
-      (int16(`same_app` shl bp_TGtkPlug_same_app) and bm_TGtkPlug_same_app)
-
-proc GTK_TYPE_PREVIEW*(): GType =
-  result = gtk_preview_get_type()
-
-proc GTK_PREVIEW*(obj: pointer): PGtkPreview =
-  result = cast[PGtkPreview](GTK_CHECK_CAST(obj, GTK_TYPE_PREVIEW()))
-
-proc GTK_PREVIEW_CLASS*(klass: pointer): PGtkPreviewClass =
-  result = cast[PGtkPreviewClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_PREVIEW()))
-
-proc GTK_IS_PREVIEW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PREVIEW())
-
-proc GTK_IS_PREVIEW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PREVIEW())
-
-proc GTK_PREVIEW_GET_CLASS*(obj: pointer): PGtkPreviewClass =
-  result = cast[PGtkPreviewClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PREVIEW()))
-
-proc get_type*(a: var TGtkPreview): guint =
-  result = (a.GtkPreviewflag0 and bm_TGtkPreview_type) shr bp_TGtkPreview_type
-
-proc set_type*(a: var TGtkPreview, `type`: guint) =
-  a.GtkPreviewflag0 = a.GtkPreviewflag0 or
-      (int16(`type` shl bp_TGtkPreview_type) and bm_TGtkPreview_type)
-
-proc get_expand*(a: var TGtkPreview): guint =
-  result = (a.GtkPreviewflag0 and bm_TGtkPreview_expand) shr bp_TGtkPreview_expand
-
-proc set_expand*(a: var TGtkPreview, `expand`: guint) =
-  a.GtkPreviewflag0 = a.GtkPreviewflag0 or
-      (int16(`expand` shl bp_TGtkPreview_expand) and bm_TGtkPreview_expand)
-
-proc gtk_progress_get_type(): GType {.importc, cdecl, dynlib: gtklib.}
-
-proc GTK_TYPE_PROGRESS*(): GType =
-  result = gtk_progress_get_type()
-
-proc GTK_PROGRESS*(obj: pointer): PGtkProgress =
-  result = cast[PGtkProgress](GTK_CHECK_CAST(obj, GTK_TYPE_PROGRESS()))
-
-proc GTK_PROGRESS_CLASS*(klass: pointer): PGtkProgressClass =
-  result = cast[PGtkProgressClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_PROGRESS()))
-
-proc GTK_IS_PROGRESS*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PROGRESS())
-
-proc GTK_IS_PROGRESS_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PROGRESS())
-
-proc GTK_PROGRESS_GET_CLASS*(obj: pointer): PGtkProgressClass =
-  result = cast[PGtkProgressClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PROGRESS()))
-
-proc show_text*(a: var TGtkProgress): guint =
-  result = (a.GtkProgressflag0 and bm_TGtkProgress_show_text) shr
-      bp_TGtkProgress_show_text
-
-proc set_show_text*(a: var TGtkProgress, `show_text`: guint) =
-  a.GtkProgressflag0 = a.GtkProgressflag0 or
-      (int16(`show_text` shl bp_TGtkProgress_show_text) and
-      bm_TGtkProgress_show_text)
-
-proc activity_mode*(a: var TGtkProgress): guint =
-  result = (a.GtkProgressflag0 and bm_TGtkProgress_activity_mode) shr
-      bp_TGtkProgress_activity_mode
-
-proc set_activity_mode*(a: var TGtkProgress, `activity_mode`: guint) =
-  a.GtkProgressflag0 = a.GtkProgressflag0 or
-      (int16(`activity_mode` shl bp_TGtkProgress_activity_mode) and
-      bm_TGtkProgress_activity_mode)
-
-proc use_text_format*(a: var TGtkProgress): guint =
-  result = (a.GtkProgressflag0 and bm_TGtkProgress_use_text_format) shr
-      bp_TGtkProgress_use_text_format
-
-proc set_use_text_format*(a: var TGtkProgress, `use_text_format`: guint) =
-  a.GtkProgressflag0 = a.GtkProgressflag0 or
-      (int16(`use_text_format` shl bp_TGtkProgress_use_text_format) and
-      bm_TGtkProgress_use_text_format)
-
-proc GTK_TYPE_PROGRESS_BAR*(): GType =
-  result = gtk_progress_bar_get_type()
-
-proc GTK_PROGRESS_BAR*(obj: pointer): PGtkProgressBar =
-  result = cast[PGtkProgressBar](GTK_CHECK_CAST(obj, GTK_TYPE_PROGRESS_BAR()))
-
-proc GTK_PROGRESS_BAR_CLASS*(klass: pointer): PGtkProgressBarClass =
-  result = cast[PGtkProgressBarClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_PROGRESS_BAR()))
-
-proc GTK_IS_PROGRESS_BAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_PROGRESS_BAR())
-
-proc GTK_IS_PROGRESS_BAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_PROGRESS_BAR())
-
-proc GTK_PROGRESS_BAR_GET_CLASS*(obj: pointer): PGtkProgressBarClass =
-  result = cast[PGtkProgressBarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_PROGRESS_BAR()))
-
-proc activity_dir*(a: var TGtkProgressBar): guint =
-  result = (a.GtkProgressBarflag0 and bm_TGtkProgressBar_activity_dir) shr
-      bp_TGtkProgressBar_activity_dir
-
-proc set_activity_dir*(a: var TGtkProgressBar, `activity_dir`: guint) =
-  a.GtkProgressBarflag0 = a.GtkProgressBarflag0 or
-      (int16(`activity_dir` shl bp_TGtkProgressBar_activity_dir) and
-      bm_TGtkProgressBar_activity_dir)
-
-proc GTK_TYPE_RADIO_BUTTON*(): GType =
-  result = gtk_radio_button_get_type()
-
-proc GTK_RADIO_BUTTON*(obj: pointer): PGtkRadioButton =
-  result = cast[PGtkRadioButton](GTK_CHECK_CAST(obj, GTK_TYPE_RADIO_BUTTON()))
-
-proc GTK_RADIO_BUTTON_CLASS*(klass: pointer): PGtkRadioButtonClass =
-  result = cast[PGtkRadioButtonClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_RADIO_BUTTON()))
-
-proc GTK_IS_RADIO_BUTTON*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_RADIO_BUTTON())
-
-proc GTK_IS_RADIO_BUTTON_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_RADIO_BUTTON())
-
-proc GTK_RADIO_BUTTON_GET_CLASS*(obj: pointer): PGtkRadioButtonClass =
-  result = cast[PGtkRadioButtonClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_RADIO_BUTTON()))
-
-proc GTK_TYPE_RADIO_MENU_ITEM*(): GType =
-  result = gtk_radio_menu_item_get_type()
-
-proc GTK_RADIO_MENU_ITEM*(obj: pointer): PGtkRadioMenuItem =
-  result = cast[PGtkRadioMenuItem](GTK_CHECK_CAST(obj, GTK_TYPE_RADIO_MENU_ITEM()))
-
-proc GTK_RADIO_MENU_ITEM_CLASS*(klass: pointer): PGtkRadioMenuItemClass =
-  result = cast[PGtkRadioMenuItemClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_RADIO_MENU_ITEM()))
-
-proc GTK_IS_RADIO_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_RADIO_MENU_ITEM())
-
-proc GTK_IS_RADIO_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_RADIO_MENU_ITEM())
-
-proc GTK_RADIO_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkRadioMenuItemClass =
-  result = cast[PGtkRadioMenuItemClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_RADIO_MENU_ITEM()))
-
-proc GTK_TYPE_SCROLLED_WINDOW*(): GType =
-  result = gtk_scrolled_window_get_type()
-
-proc GTK_SCROLLED_WINDOW*(obj: pointer): PGtkScrolledWindow =
-  result = cast[PGtkScrolledWindow](GTK_CHECK_CAST(obj, GTK_TYPE_SCROLLED_WINDOW()))
-
-proc GTK_SCROLLED_WINDOW_CLASS*(klass: pointer): PGtkScrolledWindowClass =
-  result = cast[PGtkScrolledWindowClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_SCROLLED_WINDOW()))
-
-proc GTK_IS_SCROLLED_WINDOW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SCROLLED_WINDOW())
-
-proc GTK_IS_SCROLLED_WINDOW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SCROLLED_WINDOW())
-
-proc GTK_SCROLLED_WINDOW_GET_CLASS*(obj: pointer): PGtkScrolledWindowClass =
-  result = cast[PGtkScrolledWindowClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_SCROLLED_WINDOW()))
-
-proc hscrollbar_policy*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_hscrollbar_policy) shr
-      bp_TGtkScrolledWindow_hscrollbar_policy
-
-proc set_hscrollbar_policy*(a: var TGtkScrolledWindow,
-                            `hscrollbar_policy`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      (int16(`hscrollbar_policy` shl bp_TGtkScrolledWindow_hscrollbar_policy) and
-      bm_TGtkScrolledWindow_hscrollbar_policy)
-
-proc vscrollbar_policy*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_vscrollbar_policy) shr
-      bp_TGtkScrolledWindow_vscrollbar_policy
-
-proc set_vscrollbar_policy*(a: var TGtkScrolledWindow,
-                            `vscrollbar_policy`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      (int16(`vscrollbar_policy` shl bp_TGtkScrolledWindow_vscrollbar_policy) and
-      bm_TGtkScrolledWindow_vscrollbar_policy)
-
-proc hscrollbar_visible*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_hscrollbar_visible) shr
-      bp_TGtkScrolledWindow_hscrollbar_visible
-
-proc set_hscrollbar_visible*(a: var TGtkScrolledWindow,
-                             `hscrollbar_visible`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      (int16(`hscrollbar_visible` shl bp_TGtkScrolledWindow_hscrollbar_visible) and
-      bm_TGtkScrolledWindow_hscrollbar_visible)
-
-proc vscrollbar_visible*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_vscrollbar_visible) shr
-      bp_TGtkScrolledWindow_vscrollbar_visible
-
-proc set_vscrollbar_visible*(a: var TGtkScrolledWindow,
-                             `vscrollbar_visible`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      int16((`vscrollbar_visible` shl bp_TGtkScrolledWindow_vscrollbar_visible) and
-      bm_TGtkScrolledWindow_vscrollbar_visible)
-
-proc window_placement*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_window_placement) shr
-      bp_TGtkScrolledWindow_window_placement
-
-proc set_window_placement*(a: var TGtkScrolledWindow, `window_placement`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      (int16(`window_placement` shl bp_TGtkScrolledWindow_window_placement) and
-      bm_TGtkScrolledWindow_window_placement)
-
-proc focus_out*(a: var TGtkScrolledWindow): guint =
-  result = (a.GtkScrolledWindowflag0 and bm_TGtkScrolledWindow_focus_out) shr
-      bp_TGtkScrolledWindow_focus_out
-
-proc set_focus_out*(a: var TGtkScrolledWindow, `focus_out`: guint) =
-  a.GtkScrolledWindowflag0 = a.GtkScrolledWindowflag0 or
-      (int16(`focus_out` shl bp_TGtkScrolledWindow_focus_out) and
-      bm_TGtkScrolledWindow_focus_out)
-
-proc GTK_TYPE_SELECTION_DATA*(): GType =
-  result = gtk_selection_data_get_type()
-
-proc GTK_TYPE_SEPARATOR_MENU_ITEM*(): GType =
-  result = gtk_separator_menu_item_get_type()
-
-proc GTK_SEPARATOR_MENU_ITEM*(obj: pointer): PGtkSeparatorMenuItem =
-  result = cast[PGtkSeparatorMenuItem](GTK_CHECK_CAST(obj,
-      GTK_TYPE_SEPARATOR_MENU_ITEM()))
-
-proc GTK_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): PGtkSeparatorMenuItemClass =
-  result = cast[PGtkSeparatorMenuItemClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_SEPARATOR_MENU_ITEM()))
-
-proc GTK_IS_SEPARATOR_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SEPARATOR_MENU_ITEM())
-
-proc GTK_IS_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SEPARATOR_MENU_ITEM())
-
-proc GTK_SEPARATOR_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkSeparatorMenuItemClass =
-  result = cast[PGtkSeparatorMenuItemClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_SEPARATOR_MENU_ITEM()))
-
-proc gtk_signal_lookup*(name: cstring, object_type: GType): guint =
-  result = g_signal_lookup(name, object_type)
-
-proc gtk_signal_name*(signal_id: guint): cstring =
-  result = g_signal_name(signal_id)
-
-proc gtk_signal_emit_stop*(instance: gpointer, signal_id: guint, detail: TGQuark) =
-  if detail != 0'i32: g_signal_stop_emission(instance, signal_id, 0)
-
-proc gtk_signal_connect_full*(anObject: PGtkObject, name: cstring,
-                         fun: TGtkSignalFunc, unknown1: pointer,
-                         func_data: gpointer, unknown2: pointer,
-                         unknown3, unknown4: int): gulong {.
-  importc, cdecl, dynlib: gtklib.}
-
-proc gtk_signal_compat_matched*(anObject: PGtkObject, fun: TGtkSignalFunc,
-                                data: gpointer, m: TGSignalMatchType,
-                                u: int) {.importc, cdecl, dynlib: gtklib.}
-
-proc gtk_signal_connect*(anObject: PGtkObject, name: cstring,
-                         fun: TGtkSignalFunc, func_data: gpointer): gulong =
-  result = gtk_signal_connect_full(anObject, name, fun, nil, func_data, nil,
-                                   0, 0)
-
-proc gtk_signal_connect_after*(anObject: PGtkObject, name: cstring,
-                               fun: TGtkSignalFunc, func_data: gpointer): gulong =
-  result = gtk_signal_connect_full(anObject, name, fun, nil, func_data, nil,
-                                   0, 1)
-
-proc gtk_signal_connect_object*(anObject: PGtkObject, name: cstring,
-                                fun: TGtkSignalFunc, slot_object: gpointer): gulong =
-  result = gtk_signal_connect_full(anObject, name, fun, nil, slot_object, nil,
-                                   1, 0)
-
-proc gtk_signal_connect_object_after*(anObject: PGtkObject, name: cstring,
-                                      fun: TGtkSignalFunc,
-                                      slot_object: gpointer): gulong =
-  result = gtk_signal_connect_full(anObject, name, fun, nil, slot_object, nil,
-                                   1, 1)
-
-proc gtk_signal_disconnect*(anObject: gpointer, handler_id: gulong) =
-  g_signal_handler_disconnect(anObject, handler_id)
-
-proc gtk_signal_handler_block*(anObject: gpointer, handler_id: gulong) =
-  g_signal_handler_block(anObject, handler_id)
-
-proc gtk_signal_handler_unblock*(anObject: gpointer, handler_id: gulong) =
-  g_signal_handler_unblock(anObject, handler_id)
-
-proc gtk_signal_disconnect_by_data*(anObject: PGtkObject, data: gpointer) =
-  gtk_signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 0)
-
-proc gtk_signal_disconnect_by_func*(anObject: PGtkObject, fun: TGtkSignalFunc,
-                                    data: gpointer) =
-  gtk_signal_compat_matched(anObject, fun, data, cast[TGSignalMatchType](
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0)
-
-proc gtk_signal_handler_block_by_func*(anObject: PGtkObject,
-                                       fun: TGtkSignalFunc, data: gpointer) =
-  gtk_signal_compat_matched(anObject, fun, data, TGSignalMatchType(
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0)
-
-proc gtk_signal_handler_block_by_data*(anObject: PGtkObject, data: gpointer) =
-  gtk_signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 1)
-
-proc gtk_signal_handler_unblock_by_func*(anObject: PGtkObject,
-    fun: TGtkSignalFunc, data: gpointer) =
-  gtk_signal_compat_matched(anObject, fun, data, cast[TGSignalMatchType](
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0)
-
-proc gtk_signal_handler_unblock_by_data*(anObject: PGtkObject, data: gpointer) =
-  gtk_signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 2)
-
-proc gtk_signal_handler_pending*(anObject: PGtkObject, signal_id: guint,
-                                 may_be_blocked: gboolean): gboolean =
-  Result = g_signal_has_handler_pending(anObject, signal_id, 0, may_be_blocked)
-
-proc gtk_signal_handler_pending_by_func*(anObject: PGtkObject, signal_id: guint,
-    may_be_blocked: gboolean, fun: TGtkSignalFunc, data: gpointer): gboolean =
-  var t: TGSignalMatchType
-  t = cast[TGSignalMatchType](G_SIGNAL_MATCH_ID or G_SIGNAL_MATCH_FUNC or
-      G_SIGNAL_MATCH_DATA)
-  if not may_be_blocked:
-    t = t or cast[TGSignalMatchType](G_SIGNAL_MATCH_UNBLOCKED)
-  Result = g_signal_handler_find(anObject, t, signal_id, 0, nil, fun,
-                                 data) != 0
-
-proc GTK_TYPE_SIZE_GROUP*(): GType =
-  result = gtk_size_group_get_type()
-
-proc GTK_SIZE_GROUP*(obj: pointer): PGtkSizeGroup =
-  result = cast[PGtkSizeGroup](GTK_CHECK_CAST(obj, GTK_TYPE_SIZE_GROUP()))
-
-proc GTK_SIZE_GROUP_CLASS*(klass: pointer): PGtkSizeGroupClass =
-  result = cast[PGtkSizeGroupClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SIZE_GROUP()))
-
-proc GTK_IS_SIZE_GROUP*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SIZE_GROUP())
-
-proc GTK_IS_SIZE_GROUP_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SIZE_GROUP())
-
-proc GTK_SIZE_GROUP_GET_CLASS*(obj: pointer): PGtkSizeGroupClass =
-  result = cast[PGtkSizeGroupClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SIZE_GROUP()))
-
-proc have_width*(a: var TGtkSizeGroup): guint =
-  result = (a.GtkSizeGroupflag0 and bm_TGtkSizeGroup_have_width) shr
-      bp_TGtkSizeGroup_have_width
-
-proc set_have_width*(a: var TGtkSizeGroup, `have_width`: guint) =
-  a.GtkSizeGroupflag0 = a.GtkSizeGroupflag0 or
-      (int16(`have_width` shl bp_TGtkSizeGroup_have_width) and
-      bm_TGtkSizeGroup_have_width)
-
-proc have_height*(a: var TGtkSizeGroup): guint =
-  result = (a.GtkSizeGroupflag0 and bm_TGtkSizeGroup_have_height) shr
-      bp_TGtkSizeGroup_have_height
-
-proc set_have_height*(a: var TGtkSizeGroup, `have_height`: guint) =
-  a.GtkSizeGroupflag0 = a.GtkSizeGroupflag0 or
-      (int16(`have_height` shl bp_TGtkSizeGroup_have_height) and
-      bm_TGtkSizeGroup_have_height)
-
-proc GTK_TYPE_SOCKET*(): GType =
-  result = gtk_socket_get_type()
-
-proc GTK_SOCKET*(obj: pointer): PGtkSocket =
-  result = cast[PGtkSocket](GTK_CHECK_CAST(obj, GTK_TYPE_SOCKET()))
-
-proc GTK_SOCKET_CLASS*(klass: pointer): PGtkSocketClass =
-  result = cast[PGtkSocketClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SOCKET()))
-
-proc GTK_IS_SOCKET*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SOCKET())
-
-proc GTK_IS_SOCKET_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SOCKET())
-
-proc GTK_SOCKET_GET_CLASS*(obj: pointer): PGtkSocketClass =
-  result = cast[PGtkSocketClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SOCKET()))
-
-proc same_app*(a: var TGtkSocket): guint =
-  result = (a.GtkSocketflag0 and bm_TGtkSocket_same_app) shr bp_TGtkSocket_same_app
-
-proc set_same_app*(a: var TGtkSocket, `same_app`: guint) =
-  a.GtkSocketflag0 = a.GtkSocketflag0 or
-      (int16(`same_app` shl bp_TGtkSocket_same_app) and bm_TGtkSocket_same_app)
-
-proc focus_in*(a: var TGtkSocket): guint =
-  result = (a.GtkSocketflag0 and bm_TGtkSocket_focus_in) shr bp_TGtkSocket_focus_in
-
-proc set_focus_in*(a: var TGtkSocket, `focus_in`: guint) =
-  a.GtkSocketflag0 = a.GtkSocketflag0 or
-      (int16(`focus_in` shl bp_TGtkSocket_focus_in) and bm_TGtkSocket_focus_in)
-
-proc have_size*(a: var TGtkSocket): guint =
-  result = (a.GtkSocketflag0 and bm_TGtkSocket_have_size) shr bp_TGtkSocket_have_size
-
-proc set_have_size*(a: var TGtkSocket, `have_size`: guint) =
-  a.GtkSocketflag0 = a.GtkSocketflag0 or
-      (int16(`have_size` shl bp_TGtkSocket_have_size) and bm_TGtkSocket_have_size)
-
-proc need_map*(a: var TGtkSocket): guint =
-  result = (a.GtkSocketflag0 and bm_TGtkSocket_need_map) shr bp_TGtkSocket_need_map
-
-proc set_need_map*(a: var TGtkSocket, `need_map`: guint) =
-  a.GtkSocketflag0 = a.GtkSocketflag0 or
-      (int16(`need_map` shl bp_TGtkSocket_need_map) and bm_TGtkSocket_need_map)
-
-proc is_mapped*(a: var TGtkSocket): guint =
-  result = (a.GtkSocketflag0 and bm_TGtkSocket_is_mapped) shr bp_TGtkSocket_is_mapped
-
-proc set_is_mapped*(a: var TGtkSocket, `is_mapped`: guint) =
-  a.GtkSocketflag0 = a.GtkSocketflag0 or
-      (int16(`is_mapped` shl bp_TGtkSocket_is_mapped) and bm_TGtkSocket_is_mapped)
-
-proc GTK_TYPE_SPIN_BUTTON*(): GType =
-  result = gtk_spin_button_get_type()
-
-proc GTK_SPIN_BUTTON*(obj: pointer): PGtkSpinButton =
-  result = cast[PGtkSpinButton](GTK_CHECK_CAST(obj, GTK_TYPE_SPIN_BUTTON()))
-
-proc GTK_SPIN_BUTTON_CLASS*(klass: pointer): PGtkSpinButtonClass =
-  result = cast[PGtkSpinButtonClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_SPIN_BUTTON()))
-
-proc GTK_IS_SPIN_BUTTON*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_SPIN_BUTTON())
-
-proc GTK_IS_SPIN_BUTTON_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_SPIN_BUTTON())
-
-proc GTK_SPIN_BUTTON_GET_CLASS*(obj: pointer): PGtkSpinButtonClass =
-  result = cast[PGtkSpinButtonClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_SPIN_BUTTON()))
-
-proc in_child*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_in_child) shr
-      bp_TGtkSpinButton_in_child
-
-proc set_in_child*(a: var TGtkSpinButton, `in_child`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`in_child` shl bp_TGtkSpinButton_in_child) and
-      bm_TGtkSpinButton_in_child)
-
-proc click_child*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_click_child) shr
-      bp_TGtkSpinButton_click_child
-
-proc set_click_child*(a: var TGtkSpinButton, `click_child`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`click_child` shl bp_TGtkSpinButton_click_child) and
-      bm_TGtkSpinButton_click_child)
-
-proc button*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_button) shr
-      bp_TGtkSpinButton_button
-
-proc set_button*(a: var TGtkSpinButton, `button`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`button` shl bp_TGtkSpinButton_button) and bm_TGtkSpinButton_button)
-
-proc need_timer*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_need_timer) shr
-      bp_TGtkSpinButton_need_timer
-
-proc set_need_timer*(a: var TGtkSpinButton, `need_timer`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`need_timer` shl bp_TGtkSpinButton_need_timer) and
-      bm_TGtkSpinButton_need_timer)
-
-proc timer_calls*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_timer_calls) shr
-      bp_TGtkSpinButton_timer_calls
-
-proc set_timer_calls*(a: var TGtkSpinButton, `timer_calls`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`timer_calls` shl bp_TGtkSpinButton_timer_calls) and
-      bm_TGtkSpinButton_timer_calls)
-
-proc digits*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_digits) shr
-      bp_TGtkSpinButton_digits
-
-proc set_digits*(a: var TGtkSpinButton, `digits`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`digits` shl bp_TGtkSpinButton_digits) and bm_TGtkSpinButton_digits)
-
-proc numeric*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_numeric) shr
-      bp_TGtkSpinButton_numeric
-
-proc set_numeric*(a: var TGtkSpinButton, `numeric`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`numeric` shl bp_TGtkSpinButton_numeric) and
-      bm_TGtkSpinButton_numeric)
-
-proc wrap*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_wrap) shr bp_TGtkSpinButton_wrap
-
-proc set_wrap*(a: var TGtkSpinButton, `wrap`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`wrap` shl bp_TGtkSpinButton_wrap) and bm_TGtkSpinButton_wrap)
-
-proc snap_to_ticks*(a: var TGtkSpinButton): guint =
-  result = (a.GtkSpinButtonflag0 and bm_TGtkSpinButton_snap_to_ticks) shr
-      bp_TGtkSpinButton_snap_to_ticks
-
-proc set_snap_to_ticks*(a: var TGtkSpinButton, `snap_to_ticks`: guint) =
-  a.GtkSpinButtonflag0 = a.GtkSpinButtonflag0 or
-      ((`snap_to_ticks` shl bp_TGtkSpinButton_snap_to_ticks) and
-      bm_TGtkSpinButton_snap_to_ticks)
-
-proc GTK_TYPE_STATUSBAR*(): GType =
-  result = gtk_statusbar_get_type()
-
-proc GTK_STATUSBAR*(obj: pointer): PGtkStatusbar =
-  result = cast[PGtkStatusbar](GTK_CHECK_CAST(obj, GTK_TYPE_STATUSBAR()))
-
-proc GTK_STATUSBAR_CLASS*(klass: pointer): PGtkStatusbarClass =
-  result = cast[PGtkStatusbarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_STATUSBAR()))
-
-proc GTK_IS_STATUSBAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_STATUSBAR())
-
-proc GTK_IS_STATUSBAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_STATUSBAR())
-
-proc GTK_STATUSBAR_GET_CLASS*(obj: pointer): PGtkStatusbarClass =
-  result = cast[PGtkStatusbarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_STATUSBAR()))
-
-proc has_resize_grip*(a: var TGtkStatusbar): guint =
-  result = (a.GtkStatusbarflag0 and bm_TGtkStatusbar_has_resize_grip) shr
-      bp_TGtkStatusbar_has_resize_grip
-
-proc set_has_resize_grip*(a: var TGtkStatusbar, `has_resize_grip`: guint) =
-  a.GtkStatusbarflag0 = a.GtkStatusbarflag0 or
-      (int16(`has_resize_grip` shl bp_TGtkStatusbar_has_resize_grip) and
-      bm_TGtkStatusbar_has_resize_grip)
-
-proc GTK_TYPE_TABLE*(): GType =
-  result = gtk_table_get_type()
-
-proc GTK_TABLE*(obj: pointer): PGtkTable =
-  result = cast[PGtkTable](GTK_CHECK_CAST(obj, GTK_TYPE_TABLE()))
-
-proc GTK_TABLE_CLASS*(klass: pointer): PGtkTableClass =
-  result = cast[PGtkTableClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TABLE()))
-
-proc GTK_IS_TABLE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TABLE())
-
-proc GTK_IS_TABLE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TABLE())
-
-proc GTK_TABLE_GET_CLASS*(obj: pointer): PGtkTableClass =
-  result = cast[PGtkTableClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TABLE()))
-
-proc homogeneous*(a: var TGtkTable): guint =
-  result = (a.GtkTableflag0 and bm_TGtkTable_homogeneous) shr
-      bp_TGtkTable_homogeneous
-
-proc set_homogeneous*(a: var TGtkTable, `homogeneous`: guint) =
-  a.GtkTableflag0 = a.GtkTableflag0 or
-      (int16(`homogeneous` shl bp_TGtkTable_homogeneous) and
-      bm_TGtkTable_homogeneous)
-
-proc xexpand*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_xexpand) shr
-      bp_TGtkTableChild_xexpand
-
-proc set_xexpand*(a: var TGtkTableChild, `xexpand`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`xexpand` shl bp_TGtkTableChild_xexpand) and
-      bm_TGtkTableChild_xexpand)
-
-proc yexpand*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_yexpand) shr
-      bp_TGtkTableChild_yexpand
-
-proc set_yexpand*(a: var TGtkTableChild, `yexpand`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`yexpand` shl bp_TGtkTableChild_yexpand) and
-      bm_TGtkTableChild_yexpand)
-
-proc xshrink*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_xshrink) shr
-      bp_TGtkTableChild_xshrink
-
-proc set_xshrink*(a: var TGtkTableChild, `xshrink`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`xshrink` shl bp_TGtkTableChild_xshrink) and
-      bm_TGtkTableChild_xshrink)
-
-proc yshrink*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_yshrink) shr
-      bp_TGtkTableChild_yshrink
-
-proc set_yshrink*(a: var TGtkTableChild, `yshrink`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`yshrink` shl bp_TGtkTableChild_yshrink) and
-      bm_TGtkTableChild_yshrink)
-
-proc xfill*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_xfill) shr bp_TGtkTableChild_xfill
-
-proc set_xfill*(a: var TGtkTableChild, `xfill`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`xfill` shl bp_TGtkTableChild_xfill) and bm_TGtkTableChild_xfill)
-
-proc yfill*(a: var TGtkTableChild): guint =
-  result = (a.GtkTableChildflag0 and bm_TGtkTableChild_yfill) shr bp_TGtkTableChild_yfill
-
-proc set_yfill*(a: var TGtkTableChild, `yfill`: guint) =
-  a.GtkTableChildflag0 = a.GtkTableChildflag0 or
-      (int16(`yfill` shl bp_TGtkTableChild_yfill) and bm_TGtkTableChild_yfill)
-
-proc need_expand*(a: var TGtkTableRowCol): guint =
-  result = (a.flag0 and bm_TGtkTableRowCol_need_expand) shr
-      bp_TGtkTableRowCol_need_expand
-
-proc set_need_expand*(a: var TGtkTableRowCol, `need_expand`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`need_expand` shl bp_TGtkTableRowCol_need_expand) and
-      bm_TGtkTableRowCol_need_expand)
-
-proc need_shrink*(a: var TGtkTableRowCol): guint =
-  result = (a.flag0 and bm_TGtkTableRowCol_need_shrink) shr
-      bp_TGtkTableRowCol_need_shrink
-
-proc set_need_shrink*(a: var TGtkTableRowCol, `need_shrink`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`need_shrink` shl bp_TGtkTableRowCol_need_shrink) and
-      bm_TGtkTableRowCol_need_shrink)
-
-proc expand*(a: var TGtkTableRowCol): guint =
-  result = (a.flag0 and bm_TGtkTableRowCol_expand) shr
-      bp_TGtkTableRowCol_expand
-
-proc set_expand*(a: var TGtkTableRowCol, `expand`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`expand` shl bp_TGtkTableRowCol_expand) and bm_TGtkTableRowCol_expand)
-
-proc shrink*(a: var TGtkTableRowCol): guint =
-  result = (a.flag0 and bm_TGtkTableRowCol_shrink) shr
-      bp_TGtkTableRowCol_shrink
-
-proc set_shrink*(a: var TGtkTableRowCol, `shrink`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`shrink` shl bp_TGtkTableRowCol_shrink) and bm_TGtkTableRowCol_shrink)
-
-proc empty*(a: var TGtkTableRowCol): guint =
-  result = (a.flag0 and bm_TGtkTableRowCol_empty) shr
-      bp_TGtkTableRowCol_empty
-
-proc set_empty*(a: var TGtkTableRowCol, `empty`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`empty` shl bp_TGtkTableRowCol_empty) and bm_TGtkTableRowCol_empty)
-
-proc GTK_TYPE_TEAROFF_MENU_ITEM*(): GType =
-  result = gtk_tearoff_menu_item_get_type()
-
-proc GTK_TEAROFF_MENU_ITEM*(obj: pointer): PGtkTearoffMenuItem =
-  result = cast[PGtkTearoffMenuItem](GTK_CHECK_CAST(obj, GTK_TYPE_TEAROFF_MENU_ITEM()))
-
-proc GTK_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): PGtkTearoffMenuItemClass =
-  result = cast[PGtkTearoffMenuItemClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TEAROFF_MENU_ITEM()))
-
-proc GTK_IS_TEAROFF_MENU_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TEAROFF_MENU_ITEM())
-
-proc GTK_IS_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEAROFF_MENU_ITEM())
-
-proc GTK_TEAROFF_MENU_ITEM_GET_CLASS*(obj: pointer): PGtkTearoffMenuItemClass =
-  result = cast[PGtkTearoffMenuItemClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TEAROFF_MENU_ITEM()))
-
-proc torn_off*(a: var TGtkTearoffMenuItem): guint =
-  result = (a.GtkTearoffMenuItemflag0 and bm_TGtkTearoffMenuItem_torn_off) shr
-      bp_TGtkTearoffMenuItem_torn_off
-
-proc set_torn_off*(a: var TGtkTearoffMenuItem, `torn_off`: guint) =
-  a.GtkTearoffMenuItemflag0 = a.GtkTearoffMenuItemflag0 or
-      (int16(`torn_off` shl bp_TGtkTearoffMenuItem_torn_off) and
-      bm_TGtkTearoffMenuItem_torn_off)
-
-proc GTK_TYPE_TEXT*(): GType =
-  result = gtk_text_get_type()
-
-proc GTK_TEXT*(obj: pointer): PGtkText =
-  result = cast[PGtkText](GTK_CHECK_CAST(obj, GTK_TYPE_TEXT()))
-
-proc GTK_TEXT_CLASS*(klass: pointer): PGtkTextClass =
-  result = cast[PGtkTextClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TEXT()))
-
-proc GTK_IS_TEXT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TEXT())
-
-proc GTK_IS_TEXT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT())
-
-proc GTK_TEXT_GET_CLASS*(obj: pointer): PGtkTextClass =
-  result = cast[PGtkTextClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TEXT()))
-
-proc line_wrap*(a: PGtkText): guint =
-  result = (a.GtkTextflag0 and bm_TGtkText_line_wrap) shr bp_TGtkText_line_wrap
-
-proc set_line_wrap*(a: PGtkText, `line_wrap`: guint) =
-  a.GtkTextflag0 = a.GtkTextflag0 or
-      (int16(`line_wrap` shl bp_TGtkText_line_wrap) and bm_TGtkText_line_wrap)
-
-proc word_wrap*(a: PGtkText): guint =
-  result = (a . GtkTextflag0 and bm_TGtkText_word_wrap) shr bp_TGtkText_word_wrap
-
-proc set_word_wrap*(a: PGtkText, `word_wrap`: guint) =
-  a.GtkTextflag0 = a.GtkTextflag0 or
-      (int16(`word_wrap` shl bp_TGtkText_word_wrap) and bm_TGtkText_word_wrap)
-
-proc use_wchar*(a: PGtkText): gboolean =
-  result = ((a.GtkTextflag0 and bm_TGtkText_use_wchar) shr bp_TGtkText_use_wchar) >
-      0'i16
-
-proc set_use_wchar*(a: PGtkText, `use_wchar`: gboolean) =
-  if `use_wchar`:
-    a . GtkTextflag0 = a . GtkTextflag0 or bm_TGtkText_use_wchar
-  else:
-    a . GtkTextflag0 = a . GtkTextflag0 and not bm_TGtkText_use_wchar
-
-proc GTK_TEXT_INDEX_WCHAR*(t: PGtkText, index: guint): guint32 =
-  nil
-
-proc GTK_TEXT_INDEX_UCHAR*(t: PGtkText, index: guint): GUChar =
-  nil
-
-proc GTK_TYPE_TEXT_ITER*(): GType =
-  result = gtk_text_iter_get_type()
-
-proc GTK_TYPE_TEXT_TAG*(): GType =
-  result = gtk_text_tag_get_type()
-
-proc GTK_TEXT_TAG*(obj: pointer): PGtkTextTag =
-  result = cast[PGtkTextTag](G_TYPE_CHECK_INSTANCE_CAST(obj, GTK_TYPE_TEXT_TAG()))
-
-proc GTK_TEXT_TAG_CLASS*(klass: pointer): PGtkTextTagClass =
-  result = cast[PGtkTextTagClass](G_TYPE_CHECK_CLASS_CAST(klass, GTK_TYPE_TEXT_TAG()))
-
-proc GTK_IS_TEXT_TAG*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TEXT_TAG())
-
-proc GTK_IS_TEXT_TAG_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_TAG())
-
-proc GTK_TEXT_TAG_GET_CLASS*(obj: pointer): PGtkTextTagClass =
-  result = cast[PGtkTextTagClass](G_TYPE_INSTANCE_GET_CLASS(obj, GTK_TYPE_TEXT_TAG()))
-
-proc GTK_TYPE_TEXT_ATTRIBUTES*(): GType =
-  result = gtk_text_attributes_get_type()
-
-proc bg_color_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_bg_color_set) shr
-      bp_TGtkTextTag_bg_color_set
-
-proc set_bg_color_set*(a: var TGtkTextTag, `bg_color_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`bg_color_set` shl bp_TGtkTextTag_bg_color_set) and
-      bm_TGtkTextTag_bg_color_set)
-
-proc bg_stipple_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_bg_stipple_set) shr
-      bp_TGtkTextTag_bg_stipple_set
-
-proc set_bg_stipple_set*(a: var TGtkTextTag, `bg_stipple_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`bg_stipple_set` shl bp_TGtkTextTag_bg_stipple_set) and
-      bm_TGtkTextTag_bg_stipple_set)
-
-proc fg_color_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_fg_color_set) shr
-      bp_TGtkTextTag_fg_color_set
-
-proc set_fg_color_set*(a: var TGtkTextTag, `fg_color_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`fg_color_set` shl bp_TGtkTextTag_fg_color_set) and
-      bm_TGtkTextTag_fg_color_set)
-
-proc scale_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_scale_set) shr
-      bp_TGtkTextTag_scale_set
-
-proc set_scale_set*(a: var TGtkTextTag, `scale_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`scale_set` shl bp_TGtkTextTag_scale_set) and
-      bm_TGtkTextTag_scale_set)
-
-proc fg_stipple_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_fg_stipple_set) shr
-      bp_TGtkTextTag_fg_stipple_set
-
-proc set_fg_stipple_set*(a: var TGtkTextTag, `fg_stipple_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`fg_stipple_set` shl bp_TGtkTextTag_fg_stipple_set) and
-      bm_TGtkTextTag_fg_stipple_set)
-
-proc justification_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_justification_set) shr
-      bp_TGtkTextTag_justification_set
-
-proc set_justification_set*(a: var TGtkTextTag, `justification_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`justification_set` shl bp_TGtkTextTag_justification_set) and
-      bm_TGtkTextTag_justification_set)
-
-proc left_margin_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_left_margin_set) shr
-      bp_TGtkTextTag_left_margin_set
-
-proc set_left_margin_set*(a: var TGtkTextTag, `left_margin_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`left_margin_set` shl bp_TGtkTextTag_left_margin_set) and
-      bm_TGtkTextTag_left_margin_set)
-
-proc indent_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_indent_set) shr
-      bp_TGtkTextTag_indent_set
-
-proc set_indent_set*(a: var TGtkTextTag, `indent_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`indent_set` shl bp_TGtkTextTag_indent_set) and
-      bm_TGtkTextTag_indent_set)
-
-proc rise_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_rise_set) shr bp_TGtkTextTag_rise_set
-
-proc set_rise_set*(a: var TGtkTextTag, `rise_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`rise_set` shl bp_TGtkTextTag_rise_set) and bm_TGtkTextTag_rise_set)
-
-proc strikethrough_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_strikethrough_set) shr
-      bp_TGtkTextTag_strikethrough_set
-
-proc set_strikethrough_set*(a: var TGtkTextTag, `strikethrough_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`strikethrough_set` shl bp_TGtkTextTag_strikethrough_set) and
-      bm_TGtkTextTag_strikethrough_set)
-
-proc right_margin_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_right_margin_set) shr
-      bp_TGtkTextTag_right_margin_set
-
-proc set_right_margin_set*(a: var TGtkTextTag, `right_margin_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`right_margin_set` shl bp_TGtkTextTag_right_margin_set) and
-      bm_TGtkTextTag_right_margin_set)
-
-proc pixels_above_lines_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pixels_above_lines_set) shr
-      bp_TGtkTextTag_pixels_above_lines_set
-
-proc set_pixels_above_lines_set*(a: var TGtkTextTag,
-                                 `pixels_above_lines_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pixels_above_lines_set` shl bp_TGtkTextTag_pixels_above_lines_set) and
-      bm_TGtkTextTag_pixels_above_lines_set)
-
-proc pixels_below_lines_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pixels_below_lines_set) shr
-      bp_TGtkTextTag_pixels_below_lines_set
-
-proc set_pixels_below_lines_set*(a: var TGtkTextTag,
-                                 `pixels_below_lines_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pixels_below_lines_set` shl bp_TGtkTextTag_pixels_below_lines_set) and
-      bm_TGtkTextTag_pixels_below_lines_set)
-
-proc pixels_inside_wrap_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pixels_inside_wrap_set) shr
-      bp_TGtkTextTag_pixels_inside_wrap_set
-
-proc set_pixels_inside_wrap_set*(a: var TGtkTextTag,
-                                 `pixels_inside_wrap_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pixels_inside_wrap_set` shl bp_TGtkTextTag_pixels_inside_wrap_set) and
-      bm_TGtkTextTag_pixels_inside_wrap_set)
-
-proc tabs_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_tabs_set) shr bp_TGtkTextTag_tabs_set
-
-proc set_tabs_set*(a: var TGtkTextTag, `tabs_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`tabs_set` shl bp_TGtkTextTag_tabs_set) and bm_TGtkTextTag_tabs_set)
-
-proc underline_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_underline_set) shr
-      bp_TGtkTextTag_underline_set
-
-proc set_underline_set*(a: var TGtkTextTag, `underline_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`underline_set` shl bp_TGtkTextTag_underline_set) and
-      bm_TGtkTextTag_underline_set)
-
-proc wrap_mode_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_wrap_mode_set) shr
-      bp_TGtkTextTag_wrap_mode_set
-
-proc set_wrap_mode_set*(a: var TGtkTextTag, `wrap_mode_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`wrap_mode_set` shl bp_TGtkTextTag_wrap_mode_set) and
-      bm_TGtkTextTag_wrap_mode_set)
-
-proc bg_full_height_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_bg_full_height_set) shr
-      bp_TGtkTextTag_bg_full_height_set
-
-proc set_bg_full_height_set*(a: var TGtkTextTag, `bg_full_height_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`bg_full_height_set` shl bp_TGtkTextTag_bg_full_height_set) and
-      bm_TGtkTextTag_bg_full_height_set)
-
-proc invisible_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_invisible_set) shr
-      bp_TGtkTextTag_invisible_set
-
-proc set_invisible_set*(a: var TGtkTextTag, `invisible_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`invisible_set` shl bp_TGtkTextTag_invisible_set) and
-      bm_TGtkTextTag_invisible_set)
-
-proc editable_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_editable_set) shr
-      bp_TGtkTextTag_editable_set
-
-proc set_editable_set*(a: var TGtkTextTag, `editable_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`editable_set` shl bp_TGtkTextTag_editable_set) and
-      bm_TGtkTextTag_editable_set)
-
-proc language_set*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_language_set) shr
-      bp_TGtkTextTag_language_set
-
-proc set_language_set*(a: var TGtkTextTag, `language_set`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`language_set` shl bp_TGtkTextTag_language_set) and
-      bm_TGtkTextTag_language_set)
-
-proc pad1*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pad1) shr bp_TGtkTextTag_pad1
-
-proc set_pad1*(a: var TGtkTextTag, `pad1`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pad1` shl bp_TGtkTextTag_pad1) and bm_TGtkTextTag_pad1)
-
-proc pad2*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pad2) shr bp_TGtkTextTag_pad2
-
-proc set_pad2*(a: var TGtkTextTag, `pad2`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pad2` shl bp_TGtkTextTag_pad2) and bm_TGtkTextTag_pad2)
-
-proc pad3*(a: var TGtkTextTag): guint =
-  result = (a.GtkTextTagflag0 and bm_TGtkTextTag_pad3) shr bp_TGtkTextTag_pad3
-
-proc set_pad3*(a: var TGtkTextTag, `pad3`: guint) =
-  a.GtkTextTagflag0 = a.GtkTextTagflag0 or
-      ((`pad3` shl bp_TGtkTextTag_pad3) and bm_TGtkTextTag_pad3)
-
-proc underline*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_underline) shr
-      bp_TGtkTextAppearance_underline
-
-proc set_underline*(a: var TGtkTextAppearance, `underline`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`underline` shl bp_TGtkTextAppearance_underline) and
-      bm_TGtkTextAppearance_underline)
-
-proc strikethrough*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_strikethrough) shr
-      bp_TGtkTextAppearance_strikethrough
-
-proc set_strikethrough*(a: var TGtkTextAppearance, `strikethrough`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`strikethrough` shl bp_TGtkTextAppearance_strikethrough) and
-      bm_TGtkTextAppearance_strikethrough)
-
-proc draw_bg*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_draw_bg) shr
-      bp_TGtkTextAppearance_draw_bg
-
-proc set_draw_bg*(a: var TGtkTextAppearance, `draw_bg`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`draw_bg` shl bp_TGtkTextAppearance_draw_bg) and
-      bm_TGtkTextAppearance_draw_bg)
-
-proc inside_selection*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_inside_selection) shr
-      bp_TGtkTextAppearance_inside_selection
-
-proc set_inside_selection*(a: var TGtkTextAppearance, `inside_selection`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`inside_selection` shl bp_TGtkTextAppearance_inside_selection) and
-      bm_TGtkTextAppearance_inside_selection)
-
-proc is_text*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_is_text) shr
-      bp_TGtkTextAppearance_is_text
-
-proc set_is_text*(a: var TGtkTextAppearance, `is_text`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_text` shl bp_TGtkTextAppearance_is_text) and
-      bm_TGtkTextAppearance_is_text)
-
-proc pad1*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_pad1) shr
-      bp_TGtkTextAppearance_pad1
-
-proc set_pad1*(a: var TGtkTextAppearance, `pad1`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad1` shl bp_TGtkTextAppearance_pad1) and bm_TGtkTextAppearance_pad1)
-
-proc pad2*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_pad2) shr
-      bp_TGtkTextAppearance_pad2
-
-proc set_pad2*(a: var TGtkTextAppearance, `pad2`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad2` shl bp_TGtkTextAppearance_pad2) and bm_TGtkTextAppearance_pad2)
-
-proc pad3*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_pad3) shr
-      bp_TGtkTextAppearance_pad3
-
-proc set_pad3*(a: var TGtkTextAppearance, `pad3`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad3` shl bp_TGtkTextAppearance_pad3) and bm_TGtkTextAppearance_pad3)
-
-proc pad4*(a: var TGtkTextAppearance): guint =
-  result = (a.flag0 and bm_TGtkTextAppearance_pad4) shr
-      bp_TGtkTextAppearance_pad4
-
-proc set_pad4*(a: var TGtkTextAppearance, `pad4`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad4` shl bp_TGtkTextAppearance_pad4) and bm_TGtkTextAppearance_pad4)
-
-proc invisible*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_invisible) shr
-      bp_TGtkTextAttributes_invisible
-
-proc set_invisible*(a: var TGtkTextAttributes, `invisible`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`invisible` shl bp_TGtkTextAttributes_invisible) and
-      bm_TGtkTextAttributes_invisible)
-
-proc bg_full_height*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_bg_full_height) shr
-      bp_TGtkTextAttributes_bg_full_height
-
-proc set_bg_full_height*(a: var TGtkTextAttributes, `bg_full_height`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`bg_full_height` shl bp_TGtkTextAttributes_bg_full_height) and
-      bm_TGtkTextAttributes_bg_full_height)
-
-proc editable*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_editable) shr
-      bp_TGtkTextAttributes_editable
-
-proc set_editable*(a: var TGtkTextAttributes, `editable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`editable` shl bp_TGtkTextAttributes_editable) and
-      bm_TGtkTextAttributes_editable)
-
-proc realized*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_realized) shr
-      bp_TGtkTextAttributes_realized
-
-proc set_realized*(a: var TGtkTextAttributes, `realized`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`realized` shl bp_TGtkTextAttributes_realized) and
-      bm_TGtkTextAttributes_realized)
-
-proc pad1*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_pad1) shr
-      bp_TGtkTextAttributes_pad1
-
-proc set_pad1*(a: var TGtkTextAttributes, `pad1`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad1` shl bp_TGtkTextAttributes_pad1) and bm_TGtkTextAttributes_pad1)
-
-proc pad2*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_pad2) shr
-      bp_TGtkTextAttributes_pad2
-
-proc set_pad2*(a: var TGtkTextAttributes, `pad2`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad2` shl bp_TGtkTextAttributes_pad2) and bm_TGtkTextAttributes_pad2)
-
-proc pad3*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_pad3) shr
-      bp_TGtkTextAttributes_pad3
-
-proc set_pad3*(a: var TGtkTextAttributes, `pad3`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad3` shl bp_TGtkTextAttributes_pad3) and bm_TGtkTextAttributes_pad3)
-
-proc pad4*(a: var TGtkTextAttributes): guint =
-  result = (a.flag0 and bm_TGtkTextAttributes_pad4) shr
-      bp_TGtkTextAttributes_pad4
-
-proc set_pad4*(a: var TGtkTextAttributes, `pad4`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`pad4` shl bp_TGtkTextAttributes_pad4) and bm_TGtkTextAttributes_pad4)
-
-proc GTK_TYPE_TEXT_TAG_TABLE*(): GType =
-  result = gtk_text_tag_table_get_type()
-
-proc GTK_TEXT_TAG_TABLE*(obj: pointer): PGtkTextTagTable =
-  result = cast[PGtkTextTagTable](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GTK_TYPE_TEXT_TAG_TABLE()))
-
-proc GTK_TEXT_TAG_TABLE_CLASS*(klass: pointer): PGtkTextTagTableClass =
-  result = cast[PGtkTextTagTableClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TEXT_TAG_TABLE()))
-
-proc GTK_IS_TEXT_TAG_TABLE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TEXT_TAG_TABLE())
-
-proc GTK_IS_TEXT_TAG_TABLE_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_TAG_TABLE())
-
-proc GTK_TEXT_TAG_TABLE_GET_CLASS*(obj: pointer): PGtkTextTagTableClass =
-  result = cast[PGtkTextTagTableClass](G_TYPE_INSTANCE_GET_CLASS(obj, GTK_TYPE_TEXT_TAG_TABLE()))
-
-proc GTK_TYPE_TEXT_MARK*(): GType =
-  result = gtk_text_mark_get_type()
-
-proc GTK_TEXT_MARK*(anObject: pointer): PGtkTextMark =
-  result = cast[PGtkTextMark](G_TYPE_CHECK_INSTANCE_CAST(anObject, GTK_TYPE_TEXT_MARK()))
-
-proc GTK_TEXT_MARK_CLASS*(klass: pointer): PGtkTextMarkClass =
-  result = cast[PGtkTextMarkClass](G_TYPE_CHECK_CLASS_CAST(klass, GTK_TYPE_TEXT_MARK()))
-
-proc GTK_IS_TEXT_MARK*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_TEXT_MARK())
-
-proc GTK_IS_TEXT_MARK_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_MARK())
-
-proc GTK_TEXT_MARK_GET_CLASS*(obj: pointer): PGtkTextMarkClass =
-  result = cast[PGtkTextMarkClass](G_TYPE_INSTANCE_GET_CLASS(obj, GTK_TYPE_TEXT_MARK()))
-
-proc visible*(a: var TGtkTextMarkBody): guint =
-  result = (a.flag0 and bm_TGtkTextMarkBody_visible) shr
-      bp_TGtkTextMarkBody_visible
-
-proc set_visible*(a: var TGtkTextMarkBody, `visible`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`visible` shl bp_TGtkTextMarkBody_visible) and
-      bm_TGtkTextMarkBody_visible)
-
-proc not_deleteable*(a: var TGtkTextMarkBody): guint =
-  result = (a.flag0 and bm_TGtkTextMarkBody_not_deleteable) shr
-      bp_TGtkTextMarkBody_not_deleteable
-
-proc set_not_deleteable*(a: var TGtkTextMarkBody, `not_deleteable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`not_deleteable` shl bp_TGtkTextMarkBody_not_deleteable) and
-      bm_TGtkTextMarkBody_not_deleteable)
-
-proc GTK_TYPE_TEXT_CHILD_ANCHOR*(): GType =
-  result = gtk_text_child_anchor_get_type()
-
-proc GTK_TEXT_CHILD_ANCHOR*(anObject: pointer): PGtkTextChildAnchor =
-  result = cast[PGtkTextChildAnchor](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      GTK_TYPE_TEXT_CHILD_ANCHOR()))
-
-proc GTK_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): PGtkTextChildAnchorClass =
-  result = cast[PGtkTextChildAnchorClass](G_TYPE_CHECK_CLASS_CAST(klass, GTK_TYPE_TEXT_CHILD_ANCHOR()))
-
-proc GTK_IS_TEXT_CHILD_ANCHOR*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, GTK_TYPE_TEXT_CHILD_ANCHOR())
-
-proc GTK_IS_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_CHILD_ANCHOR())
-
-proc GTK_TEXT_CHILD_ANCHOR_GET_CLASS*(obj: pointer): PGtkTextChildAnchorClass =
-  result = cast[PGtkTextChildAnchorClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_TEXT_CHILD_ANCHOR()))
-
-proc width*(a: PGtkTextLineData): gint =
-  result = a . flag0 and bm_TGtkTextLineData_width
-
-proc set_width*(a: PGtkTextLineData, NewWidth: gint) =
-  a . flag0 = (bm_TGtkTextLineData_width and NewWidth) or a . flag0
-
-proc valid*(a: PGtkTextLineData): gint =
-  result = (a . flag0 and bm_TGtkTextLineData_valid) shr
-      bp_TGtkTextLineData_valid
-
-proc set_valid*(a: PGtkTextLineData, `valid`: gint) =
-  a . flag0 = a .
-      flag0 or
-      ((`valid` shl bp_TGtkTextLineData_valid) and bm_TGtkTextLineData_valid)
-
-proc GTK_TYPE_TEXT_BUFFER*(): GType =
-  result = gtk_text_buffer_get_type()
-
-proc GTK_TEXT_BUFFER*(obj: pointer): PGtkTextBuffer =
-  result = cast[PGtkTextBuffer](G_TYPE_CHECK_INSTANCE_CAST(obj, GTK_TYPE_TEXT_BUFFER()))
-
-proc GTK_TEXT_BUFFER_CLASS*(klass: pointer): PGtkTextBufferClass =
-  result = cast[PGtkTextBufferClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TEXT_BUFFER()))
-
-proc GTK_IS_TEXT_BUFFER*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TEXT_BUFFER())
-
-proc GTK_IS_TEXT_BUFFER_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_BUFFER())
-
-proc GTK_TEXT_BUFFER_GET_CLASS*(obj: pointer): PGtkTextBufferClass =
-  result = cast[PGtkTextBufferClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_TEXT_BUFFER()))
-
-proc modified*(a: var TGtkTextBuffer): guint =
-  result = (a.GtkTextBufferflag0 and bm_TGtkTextBuffer_modified) shr
-      bp_TGtkTextBuffer_modified
-
-proc set_modified*(a: var TGtkTextBuffer, `modified`: guint) =
-  a.GtkTextBufferflag0 = a.GtkTextBufferflag0 or
-      (int16(`modified` shl bp_TGtkTextBuffer_modified) and
-      bm_TGtkTextBuffer_modified)
-
-proc GTK_TYPE_TEXT_LAYOUT*(): GType =
-  result = gtk_text_layout_get_type()
-
-proc GTK_TEXT_LAYOUT*(obj: pointer): PGtkTextLayout =
-  result = cast[PGtkTextLayout](G_TYPE_CHECK_INSTANCE_CAST(obj, GTK_TYPE_TEXT_LAYOUT()))
-
-proc GTK_TEXT_LAYOUT_CLASS*(klass: pointer): PGtkTextLayoutClass =
-  result = cast[PGtkTextLayoutClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TEXT_LAYOUT()))
-
-proc GTK_IS_TEXT_LAYOUT*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TEXT_LAYOUT())
-
-proc GTK_IS_TEXT_LAYOUT_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_LAYOUT())
-
-proc GTK_TEXT_LAYOUT_GET_CLASS*(obj: pointer): PGtkTextLayoutClass =
-  result = cast[PGtkTextLayoutClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      GTK_TYPE_TEXT_LAYOUT()))
-
-proc cursor_visible*(a: var TGtkTextLayout): guint =
-  result = (a.GtkTextLayoutflag0 and bm_TGtkTextLayout_cursor_visible) shr
-      bp_TGtkTextLayout_cursor_visible
-
-proc set_cursor_visible*(a: var TGtkTextLayout, `cursor_visible`: guint) =
-  a.GtkTextLayoutflag0 = a.GtkTextLayoutflag0 or
-      (int16(`cursor_visible` shl bp_TGtkTextLayout_cursor_visible) and
-      bm_TGtkTextLayout_cursor_visible)
-
-proc cursor_direction*(a: var TGtkTextLayout): gint =
-  result = (a.GtkTextLayoutflag0 and bm_TGtkTextLayout_cursor_direction) shr
-      bp_TGtkTextLayout_cursor_direction
-
-proc set_cursor_direction*(a: var TGtkTextLayout, `cursor_direction`: gint) =
-  a.GtkTextLayoutflag0 = a.GtkTextLayoutflag0 or
-      (int16(`cursor_direction` shl bp_TGtkTextLayout_cursor_direction) and
-      bm_TGtkTextLayout_cursor_direction)
-
-proc is_strong*(a: var TGtkTextCursorDisplay): guint =
-  result = (a.flag0 and bm_TGtkTextCursorDisplay_is_strong) shr
-      bp_TGtkTextCursorDisplay_is_strong
-
-proc set_is_strong*(a: var TGtkTextCursorDisplay, `is_strong`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_strong` shl bp_TGtkTextCursorDisplay_is_strong) and
-      bm_TGtkTextCursorDisplay_is_strong)
-
-proc is_weak*(a: var TGtkTextCursorDisplay): guint =
-  result = (a.flag0 and bm_TGtkTextCursorDisplay_is_weak) shr
-      bp_TGtkTextCursorDisplay_is_weak
-
-proc set_is_weak*(a: var TGtkTextCursorDisplay, `is_weak`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_weak` shl bp_TGtkTextCursorDisplay_is_weak) and
-      bm_TGtkTextCursorDisplay_is_weak)
-
-proc GTK_TYPE_TEXT_VIEW*(): GType =
-  result = gtk_text_view_get_type()
-
-proc GTK_TEXT_VIEW*(obj: pointer): PGtkTextView =
-  result = cast[PGtkTextView](GTK_CHECK_CAST(obj, GTK_TYPE_TEXT_VIEW()))
-
-proc GTK_TEXT_VIEW_CLASS*(klass: pointer): PGtkTextViewClass =
-  result = cast[PGtkTextViewClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TEXT_VIEW()))
-
-proc GTK_IS_TEXT_VIEW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TEXT_VIEW())
-
-proc GTK_IS_TEXT_VIEW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TEXT_VIEW())
-
-proc GTK_TEXT_VIEW_GET_CLASS*(obj: pointer): PGtkTextViewClass =
-  result = cast[PGtkTextViewClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TEXT_VIEW()))
-
-proc editable*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_editable) shr
-      bp_TGtkTextView_editable
-
-proc set_editable*(a: var TGtkTextView, `editable`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`editable` shl bp_TGtkTextView_editable) and bm_TGtkTextView_editable)
-
-proc overwrite_mode*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_overwrite_mode) shr
-      bp_TGtkTextView_overwrite_mode
-
-proc set_overwrite_mode*(a: var TGtkTextView, `overwrite_mode`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`overwrite_mode` shl bp_TGtkTextView_overwrite_mode) and
-      bm_TGtkTextView_overwrite_mode)
-
-proc cursor_visible*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_cursor_visible) shr
-      bp_TGtkTextView_cursor_visible
-
-proc set_cursor_visible*(a: var TGtkTextView, `cursor_visible`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`cursor_visible` shl bp_TGtkTextView_cursor_visible) and
-      bm_TGtkTextView_cursor_visible)
-
-proc need_im_reset*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_need_im_reset) shr
-      bp_TGtkTextView_need_im_reset
-
-proc set_need_im_reset*(a: var TGtkTextView, `need_im_reset`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`need_im_reset` shl bp_TGtkTextView_need_im_reset) and
-      bm_TGtkTextView_need_im_reset)
-
-proc just_selected_element*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_just_selected_element) shr
-      bp_TGtkTextView_just_selected_element
-
-proc set_just_selected_element*(a: var TGtkTextView,
-                                `just_selected_element`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`just_selected_element` shl bp_TGtkTextView_just_selected_element) and
-      bm_TGtkTextView_just_selected_element)
-
-proc disable_scroll_on_focus*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_disable_scroll_on_focus) shr
-      bp_TGtkTextView_disable_scroll_on_focus
-
-proc set_disable_scroll_on_focus*(a: var TGtkTextView,
-                                  `disable_scroll_on_focus`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`disable_scroll_on_focus` shl bp_TGtkTextView_disable_scroll_on_focus) and
-      bm_TGtkTextView_disable_scroll_on_focus)
-
-proc onscreen_validated*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_onscreen_validated) shr
-      bp_TGtkTextView_onscreen_validated
-
-proc set_onscreen_validated*(a: var TGtkTextView, `onscreen_validated`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`onscreen_validated` shl bp_TGtkTextView_onscreen_validated) and
-      bm_TGtkTextView_onscreen_validated)
-
-proc mouse_cursor_obscured*(a: var TGtkTextView): guint =
-  result = (a.GtkTextViewflag0 and bm_TGtkTextView_mouse_cursor_obscured) shr
-      bp_TGtkTextView_mouse_cursor_obscured
-
-proc set_mouse_cursor_obscured*(a: var TGtkTextView,
-                                `mouse_cursor_obscured`: guint) =
-  a.GtkTextViewflag0 = a.GtkTextViewflag0 or
-      (int16(`mouse_cursor_obscured` shl bp_TGtkTextView_mouse_cursor_obscured) and
-      bm_TGtkTextView_mouse_cursor_obscured)
-
-proc GTK_TYPE_TIPS_QUERY*(): GType =
-  result = gtk_tips_query_get_type()
-
-proc GTK_TIPS_QUERY*(obj: pointer): PGtkTipsQuery =
-  result = cast[PGtkTipsQuery](GTK_CHECK_CAST(obj, GTK_TYPE_TIPS_QUERY()))
-
-proc GTK_TIPS_QUERY_CLASS*(klass: pointer): PGtkTipsQueryClass =
-  result = cast[PGtkTipsQueryClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TIPS_QUERY()))
-
-proc GTK_IS_TIPS_QUERY*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TIPS_QUERY())
-
-proc GTK_IS_TIPS_QUERY_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TIPS_QUERY())
-
-proc GTK_TIPS_QUERY_GET_CLASS*(obj: pointer): PGtkTipsQueryClass =
-  result = cast[PGtkTipsQueryClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TIPS_QUERY()))
-
-proc emit_always*(a: var TGtkTipsQuery): guint =
-  result = (a.GtkTipsQueryflag0 and bm_TGtkTipsQuery_emit_always) shr
-      bp_TGtkTipsQuery_emit_always
-
-proc set_emit_always*(a: var TGtkTipsQuery, `emit_always`: guint) =
-  a.GtkTipsQueryflag0 = a.GtkTipsQueryflag0 or
-      (int16(`emit_always` shl bp_TGtkTipsQuery_emit_always) and
-      bm_TGtkTipsQuery_emit_always)
-
-proc in_query*(a: var TGtkTipsQuery): guint =
-  result = (a.GtkTipsQueryflag0 and bm_TGtkTipsQuery_in_query) shr
-      bp_TGtkTipsQuery_in_query
-
-proc set_in_query*(a: var TGtkTipsQuery, `in_query`: guint) =
-  a.GtkTipsQueryflag0 = a.GtkTipsQueryflag0 or
-      (int16(`in_query` shl bp_TGtkTipsQuery_in_query) and
-      bm_TGtkTipsQuery_in_query)
-
-proc GTK_TYPE_TOOLTIPS*(): GType =
-  result = gtk_tooltips_get_type()
-
-proc GTK_TOOLTIPS*(obj: pointer): PGtkTooltips =
-  result = cast[PGtkTooltips](GTK_CHECK_CAST(obj, GTK_TYPE_TOOLTIPS()))
-
-proc GTK_TOOLTIPS_CLASS*(klass: pointer): PGtkTooltipsClass =
-  result = cast[PGtkTooltipsClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TOOLTIPS()))
-
-proc GTK_IS_TOOLTIPS*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TOOLTIPS())
-
-proc GTK_IS_TOOLTIPS_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TOOLTIPS())
-
-proc GTK_TOOLTIPS_GET_CLASS*(obj: pointer): PGtkTooltipsClass =
-  result = cast[PGtkTooltipsClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TOOLTIPS()))
-
-proc delay*(a: var TGtkTooltips): guint =
-  result = (a.GtkTooltipsflag0 and bm_TGtkTooltips_delay) shr bp_TGtkTooltips_delay
-
-proc set_delay*(a: var TGtkTooltips, `delay`: guint) =
-  a.GtkTooltipsflag0 = a.GtkTooltipsflag0 or
-      ((`delay` shl bp_TGtkTooltips_delay) and bm_TGtkTooltips_delay)
-
-proc enabled*(a: var TGtkTooltips): guint =
-  result = (a.GtkTooltipsflag0 and bm_TGtkTooltips_enabled) shr bp_TGtkTooltips_enabled
-
-proc set_enabled*(a: var TGtkTooltips, `enabled`: guint) =
-  a.GtkTooltipsflag0 = a.GtkTooltipsflag0 or
-      ((`enabled` shl bp_TGtkTooltips_enabled) and bm_TGtkTooltips_enabled)
-
-proc have_grab*(a: var TGtkTooltips): guint =
-  result = (a.GtkTooltipsflag0 and bm_TGtkTooltips_have_grab) shr
-      bp_TGtkTooltips_have_grab
-
-proc set_have_grab*(a: var TGtkTooltips, `have_grab`: guint) =
-  a.GtkTooltipsflag0 = a.GtkTooltipsflag0 or
-      ((`have_grab` shl bp_TGtkTooltips_have_grab) and
-      bm_TGtkTooltips_have_grab)
-
-proc use_sticky_delay*(a: var TGtkTooltips): guint =
-  result = (a.GtkTooltipsflag0 and bm_TGtkTooltips_use_sticky_delay) shr
-      bp_TGtkTooltips_use_sticky_delay
-
-proc set_use_sticky_delay*(a: var TGtkTooltips, `use_sticky_delay`: guint) =
-  a.GtkTooltipsflag0 = a.GtkTooltipsflag0 or
-      ((`use_sticky_delay` shl bp_TGtkTooltips_use_sticky_delay) and
-      bm_TGtkTooltips_use_sticky_delay)
-
-proc GTK_TYPE_TOOLBAR*(): GType =
-  result = gtk_toolbar_get_type()
-
-proc GTK_TOOLBAR*(obj: pointer): PGtkToolbar =
-  result = cast[PGtkToolbar](GTK_CHECK_CAST(obj, GTK_TYPE_TOOLBAR()))
-
-proc GTK_TOOLBAR_CLASS*(klass: pointer): PGtkToolbarClass =
-  result = cast[PGtkToolbarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TOOLBAR()))
-
-proc GTK_IS_TOOLBAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TOOLBAR())
-
-proc GTK_IS_TOOLBAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TOOLBAR())
-
-proc GTK_TOOLBAR_GET_CLASS*(obj: pointer): PGtkToolbarClass =
-  result = cast[PGtkToolbarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TOOLBAR()))
-
-proc style_set*(a: var TGtkToolbar): guint =
-  result = (a.GtkToolbarflag0 and bm_TGtkToolbar_style_set) shr
-      bp_TGtkToolbar_style_set
-
-proc set_style_set*(a: var TGtkToolbar, `style_set`: guint) =
-  a.GtkToolbarflag0 = a.GtkToolbarflag0 or
-      (int16(`style_set` shl bp_TGtkToolbar_style_set) and
-      bm_TGtkToolbar_style_set)
-
-proc icon_size_set*(a: var TGtkToolbar): guint =
-  result = (a.GtkToolbarflag0 and bm_TGtkToolbar_icon_size_set) shr
-      bp_TGtkToolbar_icon_size_set
-
-proc set_icon_size_set*(a: var TGtkToolbar, `icon_size_set`: guint) =
-  a.GtkToolbarflag0 = a.GtkToolbarflag0 or
-      (int16(`icon_size_set` shl bp_TGtkToolbar_icon_size_set) and
-      bm_TGtkToolbar_icon_size_set)
-
-proc GTK_TYPE_TREE*(): GType =
-  result = gtk_tree_get_type()
-
-proc GTK_TREE*(obj: pointer): PGtkTree =
-  result = cast[PGtkTree](GTK_CHECK_CAST(obj, GTK_TYPE_TREE()))
-
-proc GTK_TREE_CLASS*(klass: pointer): PGtkTreeClass =
-  result = cast[PGtkTreeClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TREE()))
-
-proc GTK_IS_TREE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE())
-
-proc GTK_IS_TREE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE())
-
-proc GTK_TREE_GET_CLASS*(obj: pointer): PGtkTreeClass =
-  result = cast[PGtkTreeClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TREE()))
-
-proc GTK_IS_ROOT_TREE*(obj: pointer): bool =
-  result = (cast[PGtkObject]((GTK_TREE(obj)) . root_tree)) ==
-     (cast[PGtkObject](obj))
-
-proc GTK_TREE_ROOT_TREE*(obj: pointer): PGtkTree =
-  result = GTK_TREE(obj).root_tree
-
-proc GTK_TREE_SELECTION_OLD*(obj: pointer): PGList =
-  result = (GTK_TREE_ROOT_TREE(obj)).selection
-
-proc selection_mode*(a: var TGtkTree): guint =
-  result = (a.GtkTreeflag0 and bm_TGtkTree_selection_mode) shr
-      bp_TGtkTree_selection_mode
-
-proc set_selection_mode*(a: var TGtkTree, `selection_mode`: guint) =
-  a.GtkTreeflag0 = a.GtkTreeflag0 or
-      (int16(`selection_mode` shl bp_TGtkTree_selection_mode) and
-      bm_TGtkTree_selection_mode)
-
-proc view_mode*(a: var TGtkTree): guint =
-  result = (a.GtkTreeflag0 and bm_TGtkTree_view_mode) shr bp_TGtkTree_view_mode
-
-proc set_view_mode*(a: var TGtkTree, `view_mode`: guint) =
-  a.GtkTreeflag0 = a.GtkTreeflag0 or
-      (int16(`view_mode` shl bp_TGtkTree_view_mode) and bm_TGtkTree_view_mode)
-
-proc view_line*(a: var TGtkTree): guint =
-  result = (a.GtkTreeflag0 and bm_TGtkTree_view_line) shr bp_TGtkTree_view_line
-
-proc set_view_line*(a: var TGtkTree, `view_line`: guint) =
-  a.GtkTreeflag0 = a.GtkTreeflag0 or
-      (int16(`view_line` shl bp_TGtkTree_view_line) and bm_TGtkTree_view_line)
-
-proc GTK_TYPE_TREE_DRAG_SOURCE*(): GType =
-  result = gtk_tree_drag_source_get_type()
-
-proc GTK_TREE_DRAG_SOURCE*(obj: pointer): PGtkTreeDragSource =
-  result = cast[PGtkTreeDragSource](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GTK_TYPE_TREE_DRAG_SOURCE()))
-
-proc GTK_IS_TREE_DRAG_SOURCE*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TREE_DRAG_SOURCE())
-
-proc GTK_TREE_DRAG_SOURCE_GET_IFACE*(obj: pointer): PGtkTreeDragSourceIface =
-  result = cast[PGtkTreeDragSourceIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      GTK_TYPE_TREE_DRAG_SOURCE()))
-
-proc GTK_TYPE_TREE_DRAG_DEST*(): GType =
-  result = gtk_tree_drag_dest_get_type()
-
-proc GTK_TREE_DRAG_DEST*(obj: pointer): PGtkTreeDragDest =
-  result = cast[PGtkTreeDragDest](G_TYPE_CHECK_INSTANCE_CAST(obj,
-      GTK_TYPE_TREE_DRAG_DEST()))
-
-proc GTK_IS_TREE_DRAG_DEST*(obj: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_TREE_DRAG_DEST())
-
-proc GTK_TREE_DRAG_DEST_GET_IFACE*(obj: pointer): PGtkTreeDragDestIface =
-  result = cast[PGtkTreeDragDestIface](G_TYPE_INSTANCE_GET_INTERFACE(obj,
-      GTK_TYPE_TREE_DRAG_DEST()))
-
-proc GTK_TYPE_TREE_ITEM*(): GType =
-  result = gtk_tree_item_get_type()
-
-proc GTK_TREE_ITEM*(obj: pointer): PGtkTreeItem =
-  result = cast[PGtkTreeItem](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_ITEM()))
-
-proc GTK_TREE_ITEM_CLASS*(klass: pointer): PGtkTreeItemClass =
-  result = cast[PGtkTreeItemClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TREE_ITEM()))
-
-proc GTK_IS_TREE_ITEM*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_ITEM())
-
-proc GTK_IS_TREE_ITEM_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_ITEM())
-
-proc GTK_TREE_ITEM_GET_CLASS*(obj: pointer): PGtkTreeItemClass =
-  result = cast[PGtkTreeItemClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TREE_ITEM()))
-
-proc GTK_TREE_ITEM_SUBTREE*(obj: pointer): PGtkWidget =
-  result = (GTK_TREE_ITEM(obj)).subtree
-
-proc expanded*(a: var TGtkTreeItem): guint =
-  result = (a.GtkTreeItemflag0 and bm_TGtkTreeItem_expanded) shr
-      bp_TGtkTreeItem_expanded
-
-proc set_expanded*(a: var TGtkTreeItem, `expanded`: guint) =
-  a.GtkTreeItemflag0 = a.GtkTreeItemflag0 or
-      (int16(`expanded` shl bp_TGtkTreeItem_expanded) and bm_TGtkTreeItem_expanded)
-
-proc GTK_TYPE_TREE_SELECTION*(): GType =
-  result = gtk_tree_selection_get_type()
-
-proc GTK_TREE_SELECTION*(obj: pointer): PGtkTreeSelection =
-  result = cast[PGtkTreeSelection](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_SELECTION()))
-
-proc GTK_TREE_SELECTION_CLASS*(klass: pointer): PGtkTreeSelectionClass =
-  result = cast[PGtkTreeSelectionClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TREE_SELECTION()))
-
-proc GTK_IS_TREE_SELECTION*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_SELECTION())
-
-proc GTK_IS_TREE_SELECTION_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_SELECTION())
-
-proc GTK_TREE_SELECTION_GET_CLASS*(obj: pointer): PGtkTreeSelectionClass =
-  result = cast[PGtkTreeSelectionClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_TREE_SELECTION()))
-
-proc GTK_TYPE_TREE_STORE*(): GType =
-  result = gtk_tree_store_get_type()
-
-proc GTK_TREE_STORE*(obj: pointer): PGtkTreeStore =
-  result = cast[PGtkTreeStore](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_STORE()))
-
-proc GTK_TREE_STORE_CLASS*(klass: pointer): PGtkTreeStoreClass =
-  result = cast[PGtkTreeStoreClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TREE_STORE()))
-
-proc GTK_IS_TREE_STORE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_STORE())
-
-proc GTK_IS_TREE_STORE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_STORE())
-
-proc GTK_TREE_STORE_GET_CLASS*(obj: pointer): PGtkTreeStoreClass =
-  result = cast[PGtkTreeStoreClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TREE_STORE()))
-
-proc columns_dirty*(a: var TGtkTreeStore): guint =
-  result = (a.GtkTreeStoreflag0 and bm_TGtkTreeStore_columns_dirty) shr
-      bp_TGtkTreeStore_columns_dirty
-
-proc set_columns_dirty*(a: var TGtkTreeStore, `columns_dirty`: guint) =
-  a.GtkTreeStoreflag0 = a.GtkTreeStoreflag0 or
-      (int16(`columns_dirty` shl bp_TGtkTreeStore_columns_dirty) and
-      bm_TGtkTreeStore_columns_dirty)
-
-proc GTK_TYPE_TREE_VIEW_COLUMN*(): GType =
-  result = gtk_tree_view_column_get_type()
-
-proc GTK_TREE_VIEW_COLUMN*(obj: pointer): PGtkTreeViewColumn =
-  result = cast[PGtkTreeViewColumn](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_VIEW_COLUMN()))
-
-proc GTK_TREE_VIEW_COLUMN_CLASS*(klass: pointer): PGtkTreeViewColumnClass =
-  result = cast[PGtkTreeViewColumnClass](GTK_CHECK_CLASS_CAST(klass,
-      GTK_TYPE_TREE_VIEW_COLUMN()))
-
-proc GTK_IS_TREE_VIEW_COLUMN*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_VIEW_COLUMN())
-
-proc GTK_IS_TREE_VIEW_COLUMN_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_VIEW_COLUMN())
-
-proc GTK_TREE_VIEW_COLUMN_GET_CLASS*(obj: pointer): PGtkTreeViewColumnClass =
-  result = cast[PGtkTreeViewColumnClass](GTK_CHECK_GET_CLASS(obj,
-      GTK_TYPE_TREE_VIEW_COLUMN()))
-
-proc visible*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_visible) shr
-      bp_TGtkTreeViewColumn_visible
-
-proc set_visible*(a: var TGtkTreeViewColumn, `visible`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`visible` shl bp_TGtkTreeViewColumn_visible) and
-      bm_TGtkTreeViewColumn_visible)
-
-proc resizable*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_resizable) shr
-      bp_TGtkTreeViewColumn_resizable
-
-proc set_resizable*(a: var TGtkTreeViewColumn, `resizable`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`resizable` shl bp_TGtkTreeViewColumn_resizable) and
-      bm_TGtkTreeViewColumn_resizable)
-
-proc clickable*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_clickable) shr
-      bp_TGtkTreeViewColumn_clickable
-
-proc set_clickable*(a: var TGtkTreeViewColumn, `clickable`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`clickable` shl bp_TGtkTreeViewColumn_clickable) and
-      bm_TGtkTreeViewColumn_clickable)
-
-proc dirty*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_dirty) shr
-      bp_TGtkTreeViewColumn_dirty
-
-proc set_dirty*(a: var TGtkTreeViewColumn, `dirty`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`dirty` shl bp_TGtkTreeViewColumn_dirty) and
-      bm_TGtkTreeViewColumn_dirty)
-
-proc show_sort_indicator*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_show_sort_indicator) shr
-      bp_TGtkTreeViewColumn_show_sort_indicator
-
-proc set_show_sort_indicator*(a: var TGtkTreeViewColumn,
-                              `show_sort_indicator`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`show_sort_indicator` shl bp_TGtkTreeViewColumn_show_sort_indicator) and
-      bm_TGtkTreeViewColumn_show_sort_indicator)
-
-proc maybe_reordered*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_maybe_reordered) shr
-      bp_TGtkTreeViewColumn_maybe_reordered
-
-proc set_maybe_reordered*(a: var TGtkTreeViewColumn, `maybe_reordered`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`maybe_reordered` shl bp_TGtkTreeViewColumn_maybe_reordered) and
-      bm_TGtkTreeViewColumn_maybe_reordered)
-
-proc reorderable*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_reorderable) shr
-      bp_TGtkTreeViewColumn_reorderable
-
-proc set_reorderable*(a: var TGtkTreeViewColumn, `reorderable`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`reorderable` shl bp_TGtkTreeViewColumn_reorderable) and
-      bm_TGtkTreeViewColumn_reorderable)
-
-proc use_resized_width*(a: var TGtkTreeViewColumn): guint =
-  result = (a.GtkTreeViewColumnflag0 and bm_TGtkTreeViewColumn_use_resized_width) shr
-      bp_TGtkTreeViewColumn_use_resized_width
-
-proc set_use_resized_width*(a: var TGtkTreeViewColumn,
-                            `use_resized_width`: guint) =
-  a.GtkTreeViewColumnflag0 = a.GtkTreeViewColumnflag0 or
-      (int16(`use_resized_width` shl bp_TGtkTreeViewColumn_use_resized_width) and
-      bm_TGtkTreeViewColumn_use_resized_width)
-
-proc flags*(a: PGtkRBNode): guint =
-  result = (a . flag0 and bm_TGtkRBNode_flags) shr bp_TGtkRBNode_flags
-
-proc set_flags*(a: PGtkRBNode, `flags`: guint) =
-  a . flag0 = a .
-      flag0 or (int16(`flags` shl bp_TGtkRBNode_flags) and bm_TGtkRBNode_flags)
-
-proc parity*(a: PGtkRBNode): guint =
-  result = (a . flag0 and bm_TGtkRBNode_parity) shr bp_TGtkRBNode_parity
-
-proc set_parity*(a: PGtkRBNode, `parity`: guint) =
-  a . flag0 = a .
-      flag0 or (int16(`parity` shl bp_TGtkRBNode_parity) and bm_TGtkRBNode_parity)
-
-proc GTK_RBNODE_GET_COLOR*(node: PGtkRBNode): guint =
-  if node == nil:
-    Result = GTK_RBNODE_BLACK
-  elif (int(flags(node)) and GTK_RBNODE_RED) == GTK_RBNODE_RED:
-    Result = GTK_RBNODE_RED
-  else:
-    Result = GTK_RBNODE_BLACK
-
-proc GTK_RBNODE_SET_COLOR*(node: PGtkRBNode, color: guint) =
-  if node == nil:
-    return
-  if ((flags(node) and (color)) != color):
-    set_flags(node, flags(node) xor cint(GTK_RBNODE_RED or GTK_RBNODE_BLACK))
-
-proc GTK_RBNODE_GET_HEIGHT*(node: PGtkRBNode): gint =
-  var if_local1: gint
-  if node.children != nil:
-    if_local1 = node.children.root.offset
-  else:
-    if_local1 = 0
-  result = node.offset - ((node.left.offset) + node.right.offset + if_local1)
-
-proc GTK_RBNODE_FLAG_SET*(node: PGtkRBNode, flag: guint): bool =
-  result = (node != nil) and ((flags(node) and (flag)) == flag)
-
-proc GTK_RBNODE_SET_FLAG*(node: PGtkRBNode, flag: guint16) =
-  set_flags(node, (flag) or flags(node))
-
-proc GTK_RBNODE_UNSET_FLAG*(node: PGtkRBNode, flag: guint16) =
-  set_flags(node, (not (flag)) and flags(node))
-
-proc GTK_TREE_VIEW_FLAG_SET*(tree_view: PGtkTreeView, flag: guint): bool =
-  result = ((tree_view.priv.flags) and (flag)) == flag
-
-proc TREE_VIEW_HEADER_HEIGHT*(tree_view: PGtkTreeView): int32 =
-  var if_local1: int32
-  if GTK_TREE_VIEW_FLAG_SET(tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE):
-    if_local1 = tree_view.priv.header_height
-  else:
-    if_local1 = 0
-  result = if_local1
-
-proc TREE_VIEW_COLUMN_REQUESTED_WIDTH*(column: PGtkTreeViewColumn): int32 =
-  var MinWidth, MaxWidth: int
-  if column.min_width != -1'i32:
-    MinWidth = column.min_width
-  else:
-    MinWidth = column.requested_width
-  if column.max_width != - 1'i32:
-    MaxWidth = column.max_width
-  else:
-    MaxWidth = column.requested_width
-  result = CLAMP(column.requested_width, MinWidth, MaxWidth)
-
-proc TREE_VIEW_DRAW_EXPANDERS*(tree_view: PGtkTreeView): bool =
-  result = (not (GTK_TREE_VIEW_FLAG_SET(tree_view, GTK_TREE_VIEW_IS_LIST))) and
-      (GTK_TREE_VIEW_FLAG_SET(tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
-
-proc TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER*(tree_view: PGtkTreeView): int32 =
-  result = 10'i32 * (TREE_VIEW_HEADER_HEIGHT(tree_view))
-
-proc scroll_to_use_align*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_scroll_to_use_align) shr
-      bp_TGtkTreeViewPrivate_scroll_to_use_align
-
-proc set_scroll_to_use_align*(a: var TGtkTreeViewPrivate,
-                              `scroll_to_use_align`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`scroll_to_use_align` shl bp_TGtkTreeViewPrivate_scroll_to_use_align) and
-      bm_TGtkTreeViewPrivate_scroll_to_use_align)
-
-proc fixed_height_check*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_fixed_height_check) shr
-      bp_TGtkTreeViewPrivate_fixed_height_check
-
-proc set_fixed_height_check*(a: var TGtkTreeViewPrivate,
-                             `fixed_height_check`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`fixed_height_check` shl bp_TGtkTreeViewPrivate_fixed_height_check) and
-      bm_TGtkTreeViewPrivate_fixed_height_check)
-
-proc reorderable*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_reorderable) shr
-      bp_TGtkTreeViewPrivate_reorderable
-
-proc set_reorderable*(a: var TGtkTreeViewPrivate, `reorderable`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`reorderable` shl bp_TGtkTreeViewPrivate_reorderable) and
-      bm_TGtkTreeViewPrivate_reorderable)
-
-proc header_has_focus*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_header_has_focus) shr
-      bp_TGtkTreeViewPrivate_header_has_focus
-
-proc set_header_has_focus*(a: var TGtkTreeViewPrivate, `header_has_focus`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`header_has_focus` shl bp_TGtkTreeViewPrivate_header_has_focus) and
-      bm_TGtkTreeViewPrivate_header_has_focus)
-
-proc drag_column_window_state*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_drag_column_window_state) shr
-      bp_TGtkTreeViewPrivate_drag_column_window_state
-
-proc set_drag_column_window_state*(a: var TGtkTreeViewPrivate,
-                                   `drag_column_window_state`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`drag_column_window_state` shl
-      bp_TGtkTreeViewPrivate_drag_column_window_state) and
-      bm_TGtkTreeViewPrivate_drag_column_window_state)
-
-proc has_rules*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_has_rules) shr
-      bp_TGtkTreeViewPrivate_has_rules
-
-proc set_has_rules*(a: var TGtkTreeViewPrivate, `has_rules`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`has_rules` shl bp_TGtkTreeViewPrivate_has_rules) and
-      bm_TGtkTreeViewPrivate_has_rules)
-
-proc mark_rows_col_dirty*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_mark_rows_col_dirty) shr
-      bp_TGtkTreeViewPrivate_mark_rows_col_dirty
-
-proc set_mark_rows_col_dirty*(a: var TGtkTreeViewPrivate,
-                              `mark_rows_col_dirty`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`mark_rows_col_dirty` shl bp_TGtkTreeViewPrivate_mark_rows_col_dirty) and
-      bm_TGtkTreeViewPrivate_mark_rows_col_dirty)
-
-proc enable_search*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_enable_search) shr
-      bp_TGtkTreeViewPrivate_enable_search
-
-proc set_enable_search*(a: var TGtkTreeViewPrivate, `enable_search`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`enable_search` shl bp_TGtkTreeViewPrivate_enable_search) and
-      bm_TGtkTreeViewPrivate_enable_search)
-
-proc disable_popdown*(a: var TGtkTreeViewPrivate): guint =
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_disable_popdown) shr
-      bp_TGtkTreeViewPrivate_disable_popdown
-
-proc set_disable_popdown*(a: var TGtkTreeViewPrivate, `disable_popdown`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`disable_popdown` shl bp_TGtkTreeViewPrivate_disable_popdown) and
-      bm_TGtkTreeViewPrivate_disable_popdown)
-
-proc GTK_TREE_VIEW_SET_FLAG*(tree_view: PGtkTreeView, flag: guint) =
-  tree_view . priv . flags = tree_view . priv . flags or (flag)
-
-proc GTK_TREE_VIEW_UNSET_FLAG*(tree_view: PGtkTreeView, flag: guint) =
-  tree_view . priv . flags = tree_view . priv . flags and not (flag)
-
-proc GTK_TYPE_TREE_VIEW*(): GType =
-  result = gtk_tree_view_get_type()
-
-proc GTK_TREE_VIEW*(obj: pointer): PGtkTreeView =
-  result = cast[PGtkTreeView](GTK_CHECK_CAST(obj, GTK_TYPE_TREE_VIEW()))
-
-proc GTK_TREE_VIEW_CLASS*(klass: pointer): PGtkTreeViewClass =
-  result = cast[PGtkTreeViewClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_TREE_VIEW()))
-
-proc GTK_IS_TREE_VIEW*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_TREE_VIEW())
-
-proc GTK_IS_TREE_VIEW_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_TREE_VIEW())
-
-proc GTK_TREE_VIEW_GET_CLASS*(obj: pointer): PGtkTreeViewClass =
-  result = cast[PGtkTreeViewClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_TREE_VIEW()))
-
-proc GTK_TYPE_VBUTTON_BOX*(): GType =
-  result = gtk_vbutton_box_get_type()
-
-proc GTK_VBUTTON_BOX*(obj: pointer): PGtkVButtonBox =
-  result = cast[PGtkVButtonBox](GTK_CHECK_CAST(obj, GTK_TYPE_VBUTTON_BOX()))
-
-proc GTK_VBUTTON_BOX_CLASS*(klass: pointer): PGtkVButtonBoxClass =
-  result = cast[PGtkVButtonBoxClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VBUTTON_BOX()))
-
-proc GTK_IS_VBUTTON_BOX*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VBUTTON_BOX())
-
-proc GTK_IS_VBUTTON_BOX_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VBUTTON_BOX())
-
-proc GTK_VBUTTON_BOX_GET_CLASS*(obj: pointer): PGtkVButtonBoxClass =
-  result = cast[PGtkVButtonBoxClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VBUTTON_BOX()))
-
-proc GTK_TYPE_VIEWPORT*(): GType =
-  result = gtk_viewport_get_type()
-
-proc GTK_VIEWPORT*(obj: pointer): PGtkViewport =
-  result = cast[PGtkViewport](GTK_CHECK_CAST(obj, GTK_TYPE_VIEWPORT()))
-
-proc GTK_VIEWPORT_CLASS*(klass: pointer): PGtkViewportClass =
-  result = cast[PGtkViewportClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VIEWPORT()))
-
-proc GTK_IS_VIEWPORT*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VIEWPORT())
-
-proc GTK_IS_VIEWPORT_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VIEWPORT())
-
-proc GTK_VIEWPORT_GET_CLASS*(obj: pointer): PGtkViewportClass =
-  result = cast[PGtkViewportClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VIEWPORT()))
-
-proc GTK_TYPE_VPANED*(): GType =
-  result = gtk_vpaned_get_type()
-
-proc GTK_VPANED*(obj: pointer): PGtkVPaned =
-  result = cast[PGtkVPaned](GTK_CHECK_CAST(obj, GTK_TYPE_VPANED()))
-
-proc GTK_VPANED_CLASS*(klass: pointer): PGtkVPanedClass =
-  result = cast[PGtkVPanedClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VPANED()))
-
-proc GTK_IS_VPANED*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VPANED())
-
-proc GTK_IS_VPANED_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VPANED())
-
-proc GTK_VPANED_GET_CLASS*(obj: pointer): PGtkVPanedClass =
-  result = cast[PGtkVPanedClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VPANED()))
-
-proc GTK_TYPE_VRULER*(): GType =
-  result = gtk_vruler_get_type()
-
-proc GTK_VRULER*(obj: pointer): PGtkVRuler =
-  result = cast[PGtkVRuler](GTK_CHECK_CAST(obj, GTK_TYPE_VRULER()))
-
-proc GTK_VRULER_CLASS*(klass: pointer): PGtkVRulerClass =
-  result = cast[PGtkVRulerClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VRULER()))
-
-proc GTK_IS_VRULER*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VRULER())
-
-proc GTK_IS_VRULER_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VRULER())
-
-proc GTK_VRULER_GET_CLASS*(obj: pointer): PGtkVRulerClass =
-  result = cast[PGtkVRulerClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VRULER()))
-
-proc GTK_TYPE_VSCALE*(): GType =
-  result = gtk_vscale_get_type()
-
-proc GTK_VSCALE*(obj: pointer): PGtkVScale =
-  result = cast[PGtkVScale](GTK_CHECK_CAST(obj, GTK_TYPE_VSCALE()))
-
-proc GTK_VSCALE_CLASS*(klass: pointer): PGtkVScaleClass =
-  result = cast[PGtkVScaleClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VSCALE()))
-
-proc GTK_IS_VSCALE*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VSCALE())
-
-proc GTK_IS_VSCALE_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VSCALE())
-
-proc GTK_VSCALE_GET_CLASS*(obj: pointer): PGtkVScaleClass =
-  result = cast[PGtkVScaleClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VSCALE()))
-
-proc GTK_TYPE_VSCROLLBAR*(): GType =
-  result = gtk_vscrollbar_get_type()
-
-proc GTK_VSCROLLBAR*(obj: pointer): PGtkVScrollbar =
-  result = cast[PGtkVScrollbar](GTK_CHECK_CAST(obj, GTK_TYPE_VSCROLLBAR()))
-
-proc GTK_VSCROLLBAR_CLASS*(klass: pointer): PGtkVScrollbarClass =
-  result = cast[PGtkVScrollbarClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VSCROLLBAR()))
-
-proc GTK_IS_VSCROLLBAR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VSCROLLBAR())
-
-proc GTK_IS_VSCROLLBAR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VSCROLLBAR())
-
-proc GTK_VSCROLLBAR_GET_CLASS*(obj: pointer): PGtkVScrollbarClass =
-  result = cast[PGtkVScrollbarClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VSCROLLBAR()))
-
-proc GTK_TYPE_VSEPARATOR*(): GType =
-  result = gtk_vseparator_get_type()
-
-proc GTK_VSEPARATOR*(obj: pointer): PGtkVSeparator =
-  result = cast[PGtkVSeparator](GTK_CHECK_CAST(obj, GTK_TYPE_VSEPARATOR()))
-
-proc GTK_VSEPARATOR_CLASS*(klass: pointer): PGtkVSeparatorClass =
-  result = cast[PGtkVSeparatorClass](GTK_CHECK_CLASS_CAST(klass, GTK_TYPE_VSEPARATOR()))
-
-proc GTK_IS_VSEPARATOR*(obj: pointer): bool =
-  result = GTK_CHECK_TYPE(obj, GTK_TYPE_VSEPARATOR())
-
-proc GTK_IS_VSEPARATOR_CLASS*(klass: pointer): bool =
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_TYPE_VSEPARATOR())
-
-proc GTK_VSEPARATOR_GET_CLASS*(obj: pointer): PGtkVSeparatorClass =
-  result = cast[PGtkVSeparatorClass](GTK_CHECK_GET_CLASS(obj, GTK_TYPE_VSEPARATOR()))
-
-
-# these were missing:
-type
-   PGtkCellLayout* = pointer
-   PPGtkCellLayout* = ptr PGtkCellLayout
-   PGtkSignalRunType* = ptr TGtkSignalRunType
-   TGtkSignalRunType* =  int32
-   PGtkFileChooserAction* = ptr TGtkFileChooserAction
-   TGtkFileChooserAction* = enum 
-     GTK_FILE_CHOOSER_ACTION_OPEN,
-     GTK_FILE_CHOOSER_ACTION_SAVE,
-     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
-     GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
-   PGtkFileChooserError* = ptr TGtkFileChooserError
-   TGtkFileChooserError* = enum
-     GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
-     GTK_FILE_CHOOSER_ERROR_BAD_FILENAME
-
-
-const 
-  GTK_ARG_READWRITE* = GTK_ARG_READABLE or GTK_ARG_WRITABLE
-
-proc gtk_binding_entry_add_signal*(binding_set: PGtkBindingSet, keyval: guint, 
-                                   modifiers: TGdkModifierType, 
-                                   signal_name: cstring, n_args: guint){.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_clist_new_with_titles*(columns: gint): PGtkCList{.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_clist_prepend*(clist: PGtkCList): gint{.importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_clist_append*(clist: PGtkCList): gint{.importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_clist_insert*(clist: PGtkCList, row: gint): gint{.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_cell_layout_set_attributes*(cell_layout: PGtkCellLayout, 
-                                     cell: PGtkCellRenderer){.cdecl, varargs, 
-    importc, dynlib: gtklib, importc: "gtk_cell_layout_set_attributes".}
-proc gtk_container_add_with_properties*(container: PGtkContainer, 
-                                        widget: PGtkWidget, 
-                                        first_prop_name: cstring){.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_container_child_set*(container: PGtkContainer, child: PGtkWidget, 
-                              first_prop_name: cstring){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_container_child_get*(container: PGtkContainer, child: PGtkWidget, 
-                              first_prop_name: cstring){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_container_child_set_valist*(container: PGtkContainer, 
-                                     child: PGtkWidget, 
-                                     first_property_name: cstring){.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_container_child_get_valist*(container: PGtkContainer, 
-                                     child: PGtkWidget, 
-                                     first_property_name: cstring){.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_ctree_new_with_titles*(columns: gint, tree_column: gint): PGtkCTree{.
-    importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_curve_get_vector*(curve: PGtkCurve, veclen: int32){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_curve_set_vector*(curve: PGtkCurve, veclen: int32){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_dialog_add_buttons*(dialog: PGtkDialog, first_button_text: cstring){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_dialog_new_with_buttons*(title: cstring, parent: PGtkWindow, 
-                                  flags: TGtkDialogFlags, 
-                                  first_button_text: cstring): PGtkDialog{.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_list_store_new*(n_columns: gint): PGtkListStore{.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_list_store_set*(list_store: PGtkListStore, iter: PGtkTreeIter){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_list_store_set_valist*(list_store: PGtkListStore, iter: PGtkTreeIter){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_message_dialog_new*(parent: PGtkWindow, flags: TGtkDialogFlags, 
-                             thetype: TGtkMessageType, buttons: TGtkButtonsType, 
-                             message_format: cstring): PGtkMessageDialog{.varargs, 
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_signal_new*(name: cstring, signal_flags: TGtkSignalRunType, 
-                     object_type: TGtkType, function_offset: guint, 
-                     marshaller: TGtkSignalMarshaller, return_val: TGtkType, 
-                     n_args: guint): guint{.
-                     varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_signal_emit*(anObject: PGtkObject, signal_id: guint){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_signal_emit_by_name*(anObject: PGtkObject, name: cstring){.varargs, 
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_text_buffer_insert_with_tags*(buffer: PGtkTextBuffer, 
-                                       iter: PGtkTextIter, text: cstring, 
-                                       length: gint, first_tag: PGtkTextTag){.
-    varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_text_buffer_insert_with_tags_by_name*(buffer: PGtkTextBuffer, 
-    iter: PGtkTextIter, text: cstring, length: gint, first_tag_name: cstring){.
-    varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_text_buffer_create_tag*(buffer: PGtkTextBuffer, tag_name: cstring, 
-                                 first_property_name: cstring): PGtkTextTag{.
-    varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_tree_model_get*(tree_model: PGtkTreeModel, iter: PGtkTreeIter){.
-    varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_tree_model_get_valist*(tree_model: PGtkTreeModel, iter: PGtkTreeIter){.
-    varargs, importc, cdecl, dynlib: gtklib.}
-proc gtk_tree_store_new*(n_columns: gint): PGtkTreeStore{.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_tree_store_set*(tree_store: PGtkTreeStore, iter: PGtkTreeIter){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_tree_store_set_valist*(tree_store: PGtkTreeStore, iter: PGtkTreeIter){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_tree_store_iter_is_valid*(tree_store: PGtkTreeStore, iter: PGtkTreeIter): gboolean{.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_tree_store_reorder*(tree_store: PGtkTreeStore, parent: PGtkTreeIter, 
-                             new_order: pgint){.cdecl, importc, dynlib: gtklib.}
-proc gtk_tree_store_swap*(tree_store: PGtkTreeStore, a: PGtkTreeIter, 
-                          b: PGtkTreeIter){.cdecl, importc, dynlib: gtklib.}
-proc gtk_tree_store_move_before*(tree_store: PGtkTreeStore, iter: PGtkTreeIter, 
-                                 position: PGtkTreeIter){.cdecl,importc,  dynlib: gtklib.}
-proc gtk_tree_store_move_after*(tree_store: PGtkTreeStore, iter: PGtkTreeIter, 
-                                position: PGtkTreeIter){.cdecl,importc,  dynlib: gtklib.}
-proc gtk_tree_view_insert_column_with_attributes*(tree_view: PGtkTreeView, 
-    position: gint, title: cstring, cell: PGtkCellRenderer): gint{.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_tree_view_column_new_with_attributes*(title: cstring, 
-    cell: PGtkCellRenderer): PGtkTreeViewColumn{.importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_tree_view_column_set_attributes*(tree_column: PGtkTreeViewColumn, 
-    cell_renderer: PGtkCellRenderer){.importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_widget_new*(thetype: TGtkType, first_property_name: cstring): PGtkWidget{.
-    importc, varargs, cdecl, dynlib: gtklib.}
-proc gtk_widget_set*(widget: PGtkWidget, first_property_name: cstring){.varargs, 
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_widget_queue_clear*(widget: PGtkWidget){.importc, cdecl, dynlib: gtklib.}
-proc gtk_widget_queue_clear_area*(widget: PGtkWidget, x: gint, y: gint, 
-                                  width: gint, height: gint){.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_widget_draw*(widget: PGtkWidget, area: PGdkRectangle){.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_widget_style_get_valist*(widget: PGtkWidget, 
-                                  first_property_name: cstring){.varargs, cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_widget_style_get*(widget: PGtkWidget, first_property_name: cstring){.
-    varargs, cdecl, importc, dynlib: gtklib.}
-proc gtk_file_chooser_dialog_new*(title: cstring, parent: PGtkWindow, 
-                                  action: TGtkFileChooserAction, 
-                                  first_button_text: cstring): PGtkDialog {.cdecl, 
-    varargs, dynlib: gtklib, importc: "gtk_file_chooser_dialog_new".}
-proc gtk_file_chooser_dialog_new_with_backend*(title: cstring, 
-    parent: PGtkWindow, action: TGtkFileChooserAction, backend: cstring, 
-    first_button_text: cstring): PGtkDialog {.varargs, cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_dialog_new_with_backend".}
-proc gtk_object_ref*(anObject: PGtkObject): PGtkObject{.cdecl,importc,  dynlib: gtklib.}
-proc gtk_object_unref*(anObject: PGtkObject){.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_weakref*(anObject: PGtkObject, notify: TGtkDestroyNotify, 
-                         data: gpointer){.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_weakunref*(anObject: PGtkObject, notify: TGtkDestroyNotify, 
-                           data: gpointer){.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_set_data*(anObject: PGtkObject, key: cstring, data: gpointer){.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_object_set_data_full*(anObject: PGtkObject, key: cstring, 
-                               data: gpointer, destroy: TGtkDestroyNotify){.
-    importc, cdecl, dynlib: gtklib.}
-proc gtk_object_remove_data*(anObject: PGtkObject, key: cstring){.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_object_get_data*(anObject: PGtkObject, key: cstring): gpointer{.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_object_remove_no_notify*(anObject: PGtkObject, key: cstring){.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_object_set_user_data*(anObject: PGtkObject, data: gpointer){.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_object_get_user_data*(anObject: PGtkObject): gpointer{.cdecl, 
-    importc, dynlib: gtklib.}
-proc gtk_object_set_data_by_id*(anObject: PGtkObject, data_id: TGQuark, 
-                                data: gpointer){.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_set_data_by_id_full*(anObject: PGtkObject, data_id: TGQuark, 
-                                     data: gpointer, destroy: TGtkDestroyNotify){.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_object_get_data_by_id*(anObject: PGtkObject, data_id: TGQuark): gpointer{.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_object_remove_data_by_id*(anObject: PGtkObject, data_id: TGQuark){.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_object_remove_no_notify_by_id*(anObject: PGtkObject, key_id: TGQuark){.
-    cdecl, importc, dynlib: gtklib.}
-proc gtk_object_data_try_key*(str: cstring): TGQuark{.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_data_force_id*(str: cstring): TGQuark{.cdecl, importc, dynlib: gtklib.}
-proc gtk_object_get*(anObject: PGtkObject, first_property_name: cstring){.cdecl, 
-    importc, varargs, dynlib: gtklib.}
-proc gtk_object_set*(anObject: PGtkObject, first_property_name: cstring){.cdecl, 
-    importc, varargs, dynlib: gtklib.}
-proc gtk_object_add_arg_type*(arg_name: cstring, arg_type: TGtkType, 
-                              arg_flags: guint, arg_id: guint){.cdecl, 
-    importc, dynlib: gtklib.}
-
-
-type
-  PGtkFileChooser* = pointer
-  PPGtkFileChooser* = ptr PGtkFileChooser
-
-type 
-  PGtkFileFilter* = pointer
-  PPGtkFileFilter* = ref PGtkFileFilter
-  PGtkFileFilterFlags* = ref TGtkFileFilterFlags
-  TGtkFileFilterFlags* = enum 
-    GTK_FILE_FILTER_FILENAME = 1 shl 0, GTK_FILE_FILTER_URI = 1 shl 1, 
-    GTK_FILE_FILTER_DISPLAY_NAME = 1 shl 2, GTK_FILE_FILTER_MIME_TYPE = 1 shl 3
-  PGtkFileFilterInfo* = ref TGtkFileFilterInfo
-  TGtkFileFilterInfo* {.final, pure.} = object 
-    contains*: TGtkFileFilterFlags
-    filename*: cstring
-    uri*: cstring
-    display_name*: cstring
-    mime_type*: cstring
-
-  TGtkFileFilterFunc* = proc (filter_info: PGtkFileFilterInfo, data: gpointer): gboolean{.
-      cdecl.}
-
-proc GTK_TYPE_FILE_FILTER*(): GType
-proc GTK_FILE_FILTER*(obj: pointer): PGtkFileFilter
-proc GTK_IS_FILE_FILTER*(obj: pointer): gboolean
-proc gtk_file_filter_get_type*(): GType{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_filter_get_type".}
-proc gtk_file_filter_new*(): PGtkFileFilter{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_filter_new".}
-proc gtk_file_filter_set_name*(filter: PGtkFileFilter, name: cstring){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_filter_set_name".}
-proc gtk_file_filter_get_name*(filter: PGtkFileFilter): cstring{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_filter_get_name".}
-proc gtk_file_filter_add_mime_type*(filter: PGtkFileFilter, mime_type: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_file_filter_add_mime_type".}
-proc gtk_file_filter_add_pattern*(filter: PGtkFileFilter, pattern: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_file_filter_add_pattern".}
-proc gtk_file_filter_add_custom*(filter: PGtkFileFilter, 
-                                 needed: TGtkFileFilterFlags, 
-                                 func: TGtkFileFilterFunc, data: gpointer, 
-                                 notify: TGDestroyNotify){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_filter_add_custom".}
-proc gtk_file_filter_get_needed*(filter: PGtkFileFilter): TGtkFileFilterFlags{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_filter_get_needed".}
-proc gtk_file_filter_filter*(filter: PGtkFileFilter, 
-                             filter_info: PGtkFileFilterInfo): gboolean{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_filter_filter".}
-
-proc GTK_TYPE_FILE_FILTER(): GType = 
-  result = gtk_file_filter_get_type()
-
-proc GTK_FILE_FILTER(obj: pointer): PGtkFileFilter = 
-  result = cast[PGtkFileFilter](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-                                GTK_TYPE_FILE_FILTER()))
-
-proc GTK_IS_FILE_FILTER(obj: pointer): gboolean = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_FILE_FILTER())
-
-
-proc gtk_file_chooser_get_type*():GType {.
-  cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_type".}
-
-proc gtk_file_chooser_error_quark*(): TGQuark {.
-  cdecl, dynlib: gtklib, importc: "gtk_file_chooser_error_quark".}
-
-proc GTK_TYPE_FILE_CHOOSER*(): GType =
-  result = gtk_file_chooser_get_type()
-
-proc GTK_FILE_CHOOSER*(obj: pointer): PGtkFileChooser =
-  result = cast[PGtkFileChooser](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-    GTK_TYPE_FILE_CHOOSER()))
-
-proc GTK_IS_FILE_CHOOSER*(obj: pointer): gboolean =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GTK_TYPE_FILE_CHOOSER())
-
-proc gtk_file_chooser_set_action*(chooser: PGtkFileChooser, 
-                                  action: TGtkFileChooserAction){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_set_action".}
-proc gtk_file_chooser_get_action*(chooser: PGtkFileChooser): TGtkFileChooserAction{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_action".}
-proc gtk_file_chooser_set_local_only*(chooser: PGtkFileChooser, 
-                                      local_only: gboolean){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_set_local_only".}
-proc gtk_file_chooser_get_local_only*(chooser: PGtkFileChooser): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_local_only".}
-proc gtk_file_chooser_set_select_multiple*(chooser: PGtkFileChooser, 
-    select_multiple: gboolean){.cdecl, dynlib: gtklib, 
-                                importc: "gtk_file_chooser_set_select_multiple".}
-proc gtk_file_chooser_get_select_multiple*(chooser: PGtkFileChooser): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_select_multiple".}
-proc gtk_file_chooser_set_current_name*(chooser: PGtkFileChooser, name: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_set_current_name".}
-proc gtk_file_chooser_get_filename*(chooser: PGtkFileChooser): cstring{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_get_filename".}
-proc gtk_file_chooser_set_filename*(chooser: PGtkFileChooser, filename: cstring): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_set_filename".}
-proc gtk_file_chooser_select_filename*(chooser: PGtkFileChooser, 
-                                       filename: cstring): gboolean{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_select_filename".}
-proc gtk_file_chooser_unselect_filename*(chooser: PGtkFileChooser, 
-    filename: cstring){.cdecl, dynlib: gtklib, 
-                        importc: "gtk_file_chooser_unselect_filename".}
-proc gtk_file_chooser_select_all*(chooser: PGtkFileChooser){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_select_all".}
-proc gtk_file_chooser_unselect_all*(chooser: PGtkFileChooser){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_unselect_all".}
-proc gtk_file_chooser_get_filenames*(chooser: PGtkFileChooser): PGSList{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_get_filenames".}
-proc gtk_file_chooser_set_current_folder*(chooser: PGtkFileChooser, 
-    filename: cstring): gboolean{.cdecl, dynlib: gtklib, 
-                                 importc: "gtk_file_chooser_set_current_folder".}
-proc gtk_file_chooser_get_current_folder*(chooser: PGtkFileChooser): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_current_folder".}
-proc gtk_file_chooser_get_uri*(chooser: PGtkFileChooser): cstring{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_get_uri".}
-proc gtk_file_chooser_set_uri*(chooser: PGtkFileChooser, uri: cstring): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_set_uri".}
-proc gtk_file_chooser_select_uri*(chooser: PGtkFileChooser, uri: cstring): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_select_uri".}
-proc gtk_file_chooser_unselect_uri*(chooser: PGtkFileChooser, uri: cstring){.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_unselect_uri".}
-proc gtk_file_chooser_get_uris*(chooser: PGtkFileChooser): PGSList{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_get_uris".}
-proc gtk_file_chooser_set_current_folder_uri*(chooser: PGtkFileChooser, 
-    uri: cstring): gboolean{.cdecl, dynlib: gtklib, 
-                            importc: "gtk_file_chooser_set_current_folder_uri".}
-proc gtk_file_chooser_get_current_folder_uri*(chooser: PGtkFileChooser): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_current_folder_uri".}
-proc gtk_file_chooser_set_preview_widget*(chooser: PGtkFileChooser, 
-    preview_widget: PGtkWidget){.cdecl, dynlib: gtklib, 
-                                 importc: "gtk_file_chooser_set_preview_widget".}
-proc gtk_file_chooser_get_preview_widget*(chooser: PGtkFileChooser): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_preview_widget".}
-proc gtk_file_chooser_set_preview_widget_active*(chooser: PGtkFileChooser, 
-    active: gboolean){.cdecl, dynlib: gtklib, 
-                       importc: "gtk_file_chooser_set_preview_widget_active".}
-proc gtk_file_chooser_get_preview_widget_active*(chooser: PGtkFileChooser): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_preview_widget_active".}
-proc gtk_file_chooser_set_use_preview_label*(chooser: PGtkFileChooser, 
-    use_label: gboolean){.cdecl, dynlib: gtklib, 
-                          importc: "gtk_file_chooser_set_use_preview_label".}
-proc gtk_file_chooser_get_use_preview_label*(chooser: PGtkFileChooser): gboolean{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_use_preview_label".}
-proc gtk_file_chooser_get_preview_filename*(chooser: PGtkFileChooser): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_preview_filename".}
-proc gtk_file_chooser_get_preview_uri*(chooser: PGtkFileChooser): cstring{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_preview_uri".}
-proc gtk_file_chooser_set_extra_widget*(chooser: PGtkFileChooser, 
-                                        extra_widget: PGtkWidget){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_set_extra_widget".}
-proc gtk_file_chooser_get_extra_widget*(chooser: PGtkFileChooser): PGtkWidget{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_extra_widget".}
-proc gtk_file_chooser_add_filter*(chooser: PGtkFileChooser, 
-                                  filter: PGtkFileFilter){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_add_filter".}
-proc gtk_file_chooser_remove_filter*(chooser: PGtkFileChooser, 
-                                     filter: PGtkFileFilter){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_remove_filter".}
-proc gtk_file_chooser_list_filters*(chooser: PGtkFileChooser): PGSList{.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_list_filters".}
-proc gtk_file_chooser_set_filter*(chooser: PGtkFileChooser, 
-                                  filter: PGtkFileFilter){.cdecl, 
-    dynlib: gtklib, importc: "gtk_file_chooser_set_filter".}
-proc gtk_file_chooser_get_filter*(chooser: PGtkFileChooser): PGtkFileFilter{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_get_filter".}
-proc gtk_file_chooser_add_shortcut_folder*(chooser: PGtkFileChooser, 
-    folder: cstring, error: pointer): gboolean{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_add_shortcut_folder".}
-proc gtk_file_chooser_remove_shortcut_folder*(chooser: PGtkFileChooser, 
-    folder: cstring, error: pointer): gboolean{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_remove_shortcut_folder".}
-proc gtk_file_chooser_list_shortcut_folders*(chooser: PGtkFileChooser): PGSList{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_list_shortcut_folders".}
-proc gtk_file_chooser_add_shortcut_folder_uri*(chooser: PGtkFileChooser, 
-    uri: cstring, error: pointer): gboolean{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_add_shortcut_folder_uri".}
-proc gtk_file_chooser_remove_shortcut_folder_uri*(chooser: PGtkFileChooser, 
-    uri: cstring, error: pointer): gboolean{.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_remove_shortcut_folder_uri".}
-proc gtk_file_chooser_list_shortcut_folder_uris*(chooser: PGtkFileChooser): PGSList{.
-    cdecl, dynlib: gtklib, importc: "gtk_file_chooser_list_shortcut_folder_uris".}
-
-proc gtk_file_chooser_set_do_overwrite_confirmation*(chooser: PGtkFileChooser,
-    do_overwrite_confirmation: gboolean) {.cdecl, dynlib: gtklib, 
-    importc: "gtk_file_chooser_set_do_overwrite_confirmation".}
-
-proc gtk_nimrod_init*() =
-  var
-    cmdLine {.importc: "cmdLine".}: array [0..255, cstring]
-    cmdCount {.importc: "cmdCount".}: cint
-  gtk_init(addr(cmdLine), addr(cmdCount))
diff --git a/lib/oldwrappers/gtk/gtkglext.nim b/lib/oldwrappers/gtk/gtkglext.nim
deleted file mode 100755
index 38da5d25e..000000000
--- a/lib/oldwrappers/gtk/gtkglext.nim
+++ /dev/null
@@ -1,50 +0,0 @@
-{.deadCodeElim: on.}
-
-import 
-  Glib2, Gdk2, Gtk2, GdkGLExt
-
-const 
-  GtkGLExtLib* = if defined(WIN32): "libgtkglext-win32-1.0-0.dll" else: "libgtkglext-x11-1.0.so"
-
-const 
-  HEADER_GTKGLEXT_MAJOR_VERSION* = 1
-  HEADER_GTKGLEXT_MINOR_VERSION* = 0
-  HEADER_GTKGLEXT_MICRO_VERSION* = 6
-  HEADER_GTKGLEXT_INTERFACE_AGE* = 4
-  HEADER_GTKGLEXT_BINARY_AGE* = 6
-
-proc gtk_gl_parse_args*(argc: Plongint, argv: PPPChar): gboolean{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_gl_parse_args".}
-proc gtk_gl_init_check*(argc: Plongint, argv: PPPChar): gboolean{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_gl_init_check".}
-proc gtk_gl_init*(argc: Plongint, argv: PPPChar){.cdecl, dynlib: GtkGLExtLib, 
-    importc: "gtk_gl_init".}
-proc gtk_widget_set_gl_capability*(widget: PGtkWidget, glconfig: PGdkGLConfig, 
-                                   share_list: PGdkGLContext, direct: gboolean, 
-                                   render_type: int): gboolean{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_set_gl_capability".}
-proc gtk_widget_is_gl_capable*(widget: PGtkWidget): gboolean{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_is_gl_capable".}
-proc gtk_widget_get_gl_config*(widget: PGtkWidget): PGdkGLConfig{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_get_gl_config".}
-proc gtk_widget_create_gl_context*(widget: PGtkWidget, 
-                                   share_list: PGdkGLContext, direct: gboolean, 
-                                   render_type: int): PGdkGLContext{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_create_gl_context".}
-proc gtk_widget_get_gl_context*(widget: PGtkWidget): PGdkGLContext{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_get_gl_context".}
-proc gtk_widget_get_gl_window*(widget: PGtkWidget): PGdkGLWindow{.cdecl, 
-    dynlib: GtkGLExtLib, importc: "gtk_widget_get_gl_window".}
-proc gtk_widget_get_gl_drawable*(widget: PGtkWidget): PGdkGLDrawable = 
-  nil
-
-proc HEADER_GTKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool = 
-  result = (HEADER_GTKGLEXT_MAJOR_VERSION > major) or
-      ((HEADER_GTKGLEXT_MAJOR_VERSION == major) and
-      (HEADER_GTKGLEXT_MINOR_VERSION > minor)) or
-      ((HEADER_GTKGLEXT_MAJOR_VERSION == major) and
-      (HEADER_GTKGLEXT_MINOR_VERSION == minor) and
-      (HEADER_GTKGLEXT_MICRO_VERSION >= micro))
-
-proc gtk_widget_get_gl_drawable*(widget: PGtkWidget): PGdkGLDrawable = 
-  result = GDK_GL_DRAWABLE(gtk_widget_get_gl_window(widget))
diff --git a/lib/oldwrappers/gtk/gtkhtml.nim b/lib/oldwrappers/gtk/gtkhtml.nim
deleted file mode 100755
index c9ccc3595..000000000
--- a/lib/oldwrappers/gtk/gtkhtml.nim
+++ /dev/null
@@ -1,499 +0,0 @@
-{.deadCodeElim: on.}
-
-import 
-  gtk2, glib2, atk, pango, gdk2pixbuf, gdk2
-
-when defined(windows): 
-  {.define: GTK_WINDOWING_WIN32.}
-  const 
-    gtkhtmllib = "libgtkhtml-win32-2.0-0.dll"
-else: 
-  const 
-    gtkhtmllib = "libgtkhtml-2.so"
-const 
-  DOM_UNSPECIFIED_EVENT_TYPE_ERR* = 0
-  DOM_INDEX_SIZE_ERR* = 1
-  DOM_DOMSTRING_SIZE_ERR* = 2
-  DOM_HIERARCHY_REQUEST_ERR* = 3
-  DOM_WRONG_DOCUMENT_ERR* = 4
-  DOM_INVALID_CHARACTER_ERR* = 5
-  DOM_NO_DATA_ALLOWED_ERR* = 6
-  DOM_NO_MODIFICATION_ALLOWED_ERR* = 7
-  DOM_NOT_FOUND_ERR* = 8
-  DOM_NOT_SUPPORTED_ERR* = 9
-  DOM_INUSE_ATTRIBUTE_ERR* = 10
-  DOM_INVALID_STATE_ERR* = 11
-  DOM_SYNTAX_ERR* = 12
-  DOM_INVALID_MODIFICATION_ERR* = 13
-  DOM_NAMESPACE_ERR* = 14
-  DOM_INVALID_ACCESS_ERR* = 15
-  DOM_NO_EXCEPTION* = 255
-  DOM_ELEMENT_NODE* = 1
-  DOM_ATTRIBUTE_NODE* = 2
-  DOM_TEXT_NODE* = 3
-  DOM_CDATA_SECTION_NODE* = 4
-  DOM_ENTITY_REFERENCE_NODE* = 5
-  DOM_ENTITY_NODE* = 6
-  DOM_PROCESSING_INSTRUCTION_NODE* = 7
-  DOM_COMMENT_NODE* = 8
-  DOM_DOCUMENT_NODE* = 9
-  DOM_DOCUMENT_TYPE_NODE* = 10
-  DOM_DOCUMENT_FRAGMENT_NODE* = 11
-  DOM_NOTATION_NODE* = 12
-  bm_HtmlFontSpecification_weight = 0x0000000F
-  bp_HtmlFontSpecification_weight = 0
-  bm_HtmlFontSpecification_style = 0x00000030
-  bp_HtmlFontSpecification_style = 4
-  bm_HtmlFontSpecification_variant = 0x000000C0
-  bp_HtmlFontSpecification_variant = 6
-  bm_HtmlFontSpecification_stretch = 0x00000F00
-  bp_HtmlFontSpecification_stretch = 8
-  bm_HtmlFontSpecification_decoration = 0x00007000
-  bp_HtmlFontSpecification_decoration = 12
-
-type 
-  TDomString* = gchar
-  TDomBoolean* = gboolean
-  TDomException* = gushort
-  TDomTimeStamp* = guint64
-  PDomNode* = ptr TDomNode
-  TDomNode* = object of TGObject
-    xmlnode*: pointer
-    style*: pointer
-
-  PDomNodeClass* = ptr TDomNodeClass
-  TDomNodeClass* = object of TGObjectClass
-    `get_nodeName`*: proc (node: PDomNode): PDomString{.cdecl.}
-    `get_nodeValue`*: proc (node: PDomNode, exc: PDomException): PDomString {.
-        cdecl.}
-    `set_nodeValue`*: proc (node: PDomNode, value: PDomString, 
-                            exc: PDomException): PDomString{.cdecl.}
-
-  PDomDocument* = ptr TDomDocument
-  TDomDocument* {.final, pure.} = object 
-    parent*: PDomNode
-    iterators*: PGSList
-
-  PDomDocumentClass* = ptr TDomDocumentClass
-  TDomDocumentClass* {.final, pure.} = object 
-    parent_class*: PDomNodeClass
-
-  PHtmlFocusIterator* = ptr THtmlFocusIterator
-  THtmlFocusIterator* = object of TGObject
-    document*: PDomDocument
-    current_node*: PDomNode
-
-  PHtmlFocusIteratorClass* = ptr THtmlFocusIteratorClass
-  THtmlFocusIteratorClass* = object of TGObjectClass
-
-  THtmlParserType* = enum 
-    HTML_PARSER_TYPE_HTML, HTML_PARSER_TYPE_XML
-  PHtmlParser* = ptr THtmlParser
-  THtmlParser* = object of TGObject
-    parser_type*: THtmlParserType
-    document*: PHtmlDocument
-    stream*: PHtmlStream
-    xmlctxt*: xmlParserCtxtPtr
-    res*: int32
-    chars*: array[0..9, char]
-    blocking*: gboolean
-    blocking_node*: PDomNode
-
-  PHtmlParserClass* = ptr THtmlParserClass
-  THtmlParserClass* = object of TGtkObjectClass
-    done_parsing*: proc (parser: PHtmlParser){.cdecl.}
-    new_node*: proc (parser: PHtmlParser, node: PDomNode)
-    parsed_document_node*: proc (parser: PHtmlParser, document: PDomDocument)
-
-  PHtmlStream* = ptr THtmlStream
-  THtmlStreamCloseFunc* = proc (stream: PHtmlStream, user_data: gpointer){.cdecl.}
-  THtmlStreamWriteFunc* = proc (stream: PHtmlStream, buffer: Pgchar, 
-                                size: guint, user_data: gpointer){.cdecl.}
-  THtmlStreamCancelFunc* = proc (stream: PHtmlStream, user_data: gpointer, 
-                                 cancel_data: gpointer){.cdecl.}
-  THtmlStream* = object of TGObject
-    write_func*: THtmlStreamWriteFunc
-    close_func*: THtmlStreamCloseFunc
-    cancel_func*: THtmlStreamCancelFunc
-    user_data*: gpointer
-    cancel_data*: gpointer
-    written*: gint
-    mime_type*: cstring
-
-  PHtmlStreamClass* = ptr THtmlStreamClass
-  THtmlStreamClass* = object of TGObjectClass
-
-  THtmlStreamBufferCloseFunc* = proc (str: Pgchar, len: gint, 
-                                      user_data: gpointer){.cdecl.}
-  PGtkHtmlContext* = ptr TGtkHtmlContext
-  TGtkHtmlContext* = object of TGObject
-    documents*: PGSList
-    standard_font*: PHtmlFontSpecification
-    fixed_font*: PHtmlFontSpecification
-    debug_painting*: gboolean
-
-  PGtkHtmlContextClass* = ptr TGtkHtmlContextClass
-  TGtkHtmlContextClass* = object of TGObjectClass
-
-  THtmlDocumentState* = enum 
-    HTML_DOCUMENT_STATE_DONE, HTML_DOCUMENT_STATE_PARSING
-  PHtmlDocument* = ptr THtmlDocument
-  THtmlDocument* = object of TGObject
-    stylesheets*: PGSList
-    current_stream*: PHtmlStream
-    state*: THtmlDocumentState
-
-  PHtmlDocumentClass* = ptr THtmlDocumentClass
-  THtmlDocumentClass* = object of TGObjectClass
-    request_url*: proc (document: PHtmlDocument, url: Pgchar, 
-                        stream: PHtmlStream){.cdecl.}
-    link_clicked*: proc (document: PHtmlDocument, url: Pgchar){.cdecl.}
-    set_base*: proc (document: PHtmlDocument, url: Pgchar){.cdecl.}
-    title_changed*: proc (document: PHtmlDocument, new_title: Pgchar){.cdecl.}
-    submit*: proc (document: PHtmlDocument, `method`: Pgchar, url: Pgchar, 
-                   encoding: Pgchar){.cdecl.}
-
-  PHtmlView* = ptr THtmlView
-  THtmlView* = object of TGtkLayout
-    document*: PHtmlDocument
-    node_table*: PGHashTable
-    relayout_idle_id*: guint
-    relayout_timeout_id*: guint
-    mouse_down_x*: gint
-    mouse_down_y*: gint
-    mouse_detail*: gint
-    sel_start_ypos*: gint
-    sel_start_index*: gint
-    sel_end_ypos*: gint
-    sel_end_index*: gint
-    sel_flag*: gboolean
-    sel_backwards*: gboolean
-    sel_start_found*: gboolean
-    sel_list*: PGSList
-    jump_to_anchor*: pgchar
-    magnification*: gdouble
-    magnification_modified*: gboolean
-    on_url*: gboolean
-
-  PHtmlViewClass* = ptr THtmlViewClass
-  THtmlViewClass* = object of TGtkLayoutClass
-    move_cursor*: proc (html_view: PHtmlView, step: TGtkMovementStep, 
-                        count: gint, extend_selection: gboolean){.cdecl.}
-    on_url*: proc (html_view: PHtmlView, url: Pgchar)
-    activate*: proc (html_view: PHtmlView)
-    move_focus_out*: proc (html_view: PHtmlView, direction: TGtkDirectionType)
-
-
-proc DOM_TYPE_NODE*(): GType
-proc DOM_NODE*(theobject: pointer): PDomNode
-proc DOM_NODE_CLASS*(klass: pointer): PDomNodeClass
-proc DOM_IS_NODE*(theobject: pointer): bool
-proc DOM_IS_NODE_CLASS*(klass: pointer): bool
-proc DOM_NODE_GET_CLASS*(obj: pointer): int32
-proc dom_node_get_type*(): GType{.cdecl, dynlib: gtkhtmllib, 
-                                  importc: "dom_node_get_type".}
-proc dom_Node_mkref*(node: pointer): PDomNode{.cdecl, dynlib: gtkhtmllib, 
-    importc: "dom_Node_mkref".}
-proc dom_Node_get_childNodes*(node: PDomNode): PDomNodeList{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_childNodes".}
-proc dom_Node_removeChild*(node: PDomNode, oldChild: PDomNode, 
-                           exc: PDomException): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_removeChild".}
-proc dom_Node_get_nodeValue*(node: PDomNode, exc: PDomException): PDomString{.
-    cdecl, dynlib: gtkhtmllib, importc: "dom_Node__get_nodeValue".}
-proc dom_Node_get_firstChild*(node: PDomNode): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_firstChild".}
-proc dom_Node_get_nodeName*(node: PDomNode): PDomString{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_nodeName".}
-proc dom_Node_get_attributes*(node: PDomNode): PDomNamedNodeMap{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_attributes".}
-proc dom_Document_get_doctype*(doc: PDomDocument): PDomDocumentType{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Document__get_doctype".}
-proc dom_Node_hasChildNodes*(node: PDomNode): DomBoolean{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_hasChildNodes".}
-proc dom_Node_get_parentNode*(node: PDomNode): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_parentNode".}
-proc dom_Node_get_nextSibling*(node: PDomNode): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_nextSibling".}
-proc dom_Node_get_nodeType*(node: PDomNode): gushort{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_nodeType".}
-proc dom_Node_hasAttributes*(node: PDomNode): DomBoolean{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_hasAttributes".}
-proc dom_Node_cloneNode*(node: PDomNode, deep: DomBoolean): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_cloneNode".}
-proc dom_Node_appendChild*(node: PDomNode, newChild: PDomNode, 
-                           exc: PDomException): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_appendChild".}
-proc dom_Node_get_localName*(node: PDomNode): PDomString{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_localName".}
-proc dom_Node_get_namespaceURI*(node: PDomNode): PDomString{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_namespaceURI".}
-proc dom_Node_get_previousSibling*(node: PDomNode): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_previousSibling".}
-proc dom_Node_get_lastChild*(node: PDomNode): PDomNode{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_lastChild".}
-proc dom_Node_set_nodeValue*(node: PDomNode, value: PDomString, 
-                             exc: PDomException){.cdecl, dynlib: gtkhtmllib, 
-    importc: "dom_Node__set_nodeValue".}
-proc dom_Node_get_ownerDocument*(node: PDomNode): PDomDocument{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node__get_ownerDocument".}
-proc dom_Node_hasAttributes*(node: PDomNode): gboolean{.cdecl, 
-    dynlib: gtkhtmllib, importc: "dom_Node_hasAttributes".}
-proc DOM_TYPE_DOCUMENT*(): GType
-proc DOM_DOCUMENT*(theobject: pointer): PDomDocument
-proc DOM_DOCUMENT_CLASS*(klass: pointer): PDomDocumentClass
-proc DOM_IS_DOCUMENT*(theobject: pointer): bool
-proc DOM_IS_DOCUMENT_CLASS*(klass: pointer): bool
-proc DOM_DOCUMENT_GET_CLASS*(obj: pointer): PDomDocumentClass
-proc dom_document_get_type*(): GType
-proc dom_Document_get_documentElement*(doc: PDomDocument): PDomElement
-proc dom_Document_createElement*(doc: PDomDocument, tagName: PDomString): PDomElement
-proc dom_Document_createTextNode*(doc: PDomDocument, data: PDomString): PDomText
-proc dom_Document_createComment*(doc: PDomDocument, data: PDomString): PDomComment
-proc dom_Document_importNode*(doc: PDomDocument, importedNode: PDomNode, 
-                              deep: DomBoolean, exc: PDomException): PDomNode
-proc HTML_TYPE_FOCUS_ITERATOR*(): GType
-proc HTML_FOCUS_ITERATOR*(theobject: pointer): PHtmlFocusIterator
-proc HTML_FOCUS_ITERATOR_CLASS*(klass: pointer): PHtmlFocusIteratorClass
-proc HTML_IS_FOCUS_ITERATOR*(theobject: pointer): bool
-proc HTML_IS_FOCUS_ITERATOR_CLASS*(klass: pointer): bool
-proc HTML_FOCUS_ITERATOR_GET_CLASS*(obj: pointer): PHtmlFocusIteratorClass
-proc html_focus_iterator_next_element*(document: PDomDocument, 
-                                       element: PDomElement): PDomElement{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_focus_iterator_next_element".}
-proc html_focus_iterator_prev_element*(document: PDomDocument, 
-                                       element: PDomElement): PDomElement{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_focus_iterator_prev_element".}
-proc HTML_PARSER_TYPE*(): GType
-proc HTML_PARSER*(obj: pointer): PHtmlParser
-proc HTML_PARSER_CLASS*(klass: pointer): PHtmlParserClass
-proc HTML_IS_PARSER*(obj: pointer): bool
-proc html_parser_get_type*(): GType
-proc html_parser_new*(document: PHtmlDocument, parser_type: THtmlParserType): PHtmlParser
-proc HTML_TYPE_STREAM*(): GType
-proc HTML_STREAM*(obj: pointer): PHtmlStream
-proc HTML_STREAM_CLASS*(klass: pointer): PHtmlStreamClass
-proc HTML_IS_STREAM*(obj: pointer): bool
-proc HTML_IS_STREAM_CLASS*(klass: pointer): bool
-proc HTML_STREAM_GET_CLASS*(obj: pointer): PHtmlStreamClass
-proc html_stream_get_type*(): GType{.cdecl, dynlib: gtkhtmllib, 
-                                     importc: "html_stream_get_type".}
-proc html_stream_new*(write_func: THtmlStreamWriteFunc, 
-                      close_func: THtmlStreamCloseFunc, user_data: gpointer): PHtmlStream{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_stream_new".}
-proc html_stream_write*(stream: PHtmlStream, buffer: Pgchar, size: guint){.
-    cdecl, dynlib: gtkhtmllib, importc: "html_stream_write".}
-proc html_stream_close*(stream: PHtmlStream){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_stream_close".}
-proc html_stream_destroy*(stream: PHtmlStream){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_stream_destroy".}
-proc html_stream_get_written*(stream: PHtmlStream): gint{.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_stream_get_written".}
-proc html_stream_cancel*(stream: PHtmlStream){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_stream_cancel".}
-proc html_stream_set_cancel_func*(stream: PHtmlStream, 
-                                  abort_func: THtmlStreamCancelFunc, 
-                                  cancel_data: gpointer){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_stream_set_cancel_func".}
-proc html_stream_get_mime_type*(stream: PHtmlStream): cstring{.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_stream_get_mime_type".}
-proc html_stream_set_mime_type*(stream: PHtmlStream, mime_type: cstring){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_stream_set_mime_type".}
-proc html_stream_buffer_new*(close_func: THtmlStreamBufferCloseFunc, 
-                             user_data: gpointer): PHtmlStream{.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_stream_buffer_new".}
-proc html_event_mouse_move*(view: PHtmlView, event: PGdkEventMotion){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_event_mouse_move".}
-proc html_event_button_press*(view: PHtmlView, button: PGdkEventButton){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_event_button_press".}
-proc html_event_button_release*(view: PHtmlView, event: PGdkEventButton){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_event_button_release".}
-proc html_event_activate*(view: PHtmlView){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_event_activate".}
-proc html_event_key_press*(view: PHtmlView, event: PGdkEventKey): gboolean{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_event_key_press".}
-proc html_event_find_root_box*(self: PHtmlBox, x: gint, y: gint): PHtmlBox{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_event_find_root_box".}
-proc html_selection_start*(view: PHtmlView, event: PGdkEventButton){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_selection_start".}
-proc html_selection_end*(view: PHtmlView, event: PGdkEventButton){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_selection_end".}
-proc html_selection_update*(view: PHtmlView, event: PGdkEventMotion){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_selection_update".}
-proc html_selection_clear*(view: PHtmlView){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_selection_clear".}
-proc html_selection_set*(view: PHtmlView, start: PDomNode, offset: int32, 
-                         len: int32){.cdecl, dynlib: gtkhtmllib, 
-                                      importc: "html_selection_set".}
-proc GTK_HTML_CONTEXT_TYPE*(): GType
-proc GTK_HTML_CONTEXT*(obj: pointer): PGtkHtmlContext
-proc GTK_HTML_CONTEXT_CLASS*(klass: pointer): PGtkHtmlContextClass
-proc GTK_HTML_IS_CONTEXT*(obj: pointer): bool
-proc GTK_HTML_IS_CONTEXT_CLASS*(klass: pointer): bool
-proc gtk_html_context_get_type*(): GType
-proc gtk_html_context_get*(): PGtkHtmlContext
-proc HTML_TYPE_DOCUMENT*(): GType
-proc HTML_DOCUMENT*(obj: pointer): PHtmlDocument
-proc HTML_DOCUMENT_CLASS*(klass: pointer): PHtmlDocumentClass
-proc HTML_IS_DOCUMENT*(obj: pointer): bool
-proc html_document_get_type*(): GType{.cdecl, dynlib: gtkhtmllib, 
-                                       importc: "html_document_get_type".}
-proc html_document_new*(): PHtmlDocument{.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_document_new".}
-proc html_document_open_stream*(document: PHtmlDocument, mime_type: Pgchar): gboolean{.
-    cdecl, dynlib: gtkhtmllib, importc: "html_document_open_stream".}
-proc html_document_write_stream*(document: PHtmlDocument, buffer: Pgchar, 
-                                 len: gint){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_document_write_stream".}
-proc html_document_close_stream*(document: PHtmlDocument){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_document_close_stream".}
-proc html_document_clear*(document: PHtmlDocument){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_document_clear".}
-proc HTML_TYPE_VIEW*(): GType
-proc HTML_VIEW*(obj: pointer): PHtmlView
-proc HTML_VIEW_CLASS*(klass: pointer): PHtmlViewClass
-proc HTML_IS_VIEW*(obj: pointer): bool
-proc html_view_get_type*(): GType{.cdecl, dynlib: gtkhtmllib, 
-                                   importc: "html_view_get_type".}
-proc html_view_new*(): PGtkWidget{.cdecl, dynlib: gtkhtmllib, 
-                                   importc: "html_view_new".}
-proc html_view_set_document*(view: PHtmlView, document: PHtmlDocument){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_view_set_document".}
-proc html_view_jump_to_anchor*(view: PHtmlView, anchor: Pgchar){.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_view_jump_to_anchor".}
-proc html_view_get_magnification*(view: PHtmlView): gdouble{.cdecl, 
-    dynlib: gtkhtmllib, importc: "html_view_get_magnification".}
-proc html_view_set_magnification*(view: PHtmlView, magnification: gdouble){.
-    cdecl, dynlib: gtkhtmllib, importc: "html_view_set_magnification".}
-proc html_view_zoom_in*(view: PHtmlView){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_view_zoom_in".}
-proc html_view_zoom_out*(view: PHtmlView){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_view_zoom_out".}
-proc html_view_zoom_reset*(view: PHtmlView){.cdecl, dynlib: gtkhtmllib, 
-    importc: "html_view_zoom_reset".}
-proc DOM_TYPE_NODE*(): GType = 
-  result = dom_node_get_type()
-
-proc DOM_NODE*(theobject: pointer): PDomNode = 
-  result = G_TYPE_CHECK_INSTANCE_CAST(theobject, DOM_TYPE_NODE(), TDomNode)
-
-proc DOM_NODE_CLASS*(klass: pointer): PDomNodeClass = 
-  result = G_TYPE_CHECK_CLASS_CAST(klass, DOM_TYPE_NODE(), TDomNodeClass)
-
-proc DOM_IS_NODE*(theobject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, DOM_TYPE_NODE())
-
-proc DOM_IS_NODE_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, DOM_TYPE_NODE())
-
-proc DOM_NODE_GET_CLASS*(obj: pointer): PDomNodeClass = 
-  result = G_TYPE_INSTANCE_GET_CLASS(obj, DOM_TYPE_NODE(), TDomNodeClass)
-
-proc DOM_TYPE_DOCUMENT*(): GType = 
-  result = dom_document_get_type()
-
-proc DOM_DOCUMENT*(theobject: pointer): PDomDocument = 
-  result = G_TYPE_CHECK_INSTANCE_CAST(theobject, DOM_TYPE_DOCUMENT(), TDomDocument)
-
-proc DOM_DOCUMENT_CLASS*(klass: pointer): PDomDocumentClass = 
-  result = G_TYPE_CHECK_CLASS_CAST(klass, DOM_TYPE_DOCUMENT(), TDomDocumentClass)
-
-proc DOM_IS_DOCUMENT*(theobject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, DOM_TYPE_DOCUMENT())
-
-proc DOM_IS_DOCUMENT_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, DOM_TYPE_DOCUMENT())
-
-proc DOM_DOCUMENT_GET_CLASS*(obj: pointer): PDomDocumentClass = 
-  result = G_TYPE_INSTANCE_GET_CLASS(obj, DOM_TYPE_DOCUMENT(), TDomDocumentClass)
-
-proc HTML_TYPE_FOCUS_ITERATOR*(): GType = 
-  result = html_focus_iterator_get_type()
-
-proc HTML_FOCUS_ITERATOR*(theobject: pointer): PHtmlFocusIterator = 
-  result = G_TYPE_CHECK_INSTANCE_CAST(theobject, HTML_TYPE_FOCUS_ITERATOR(), 
-                                      HtmlFocusIterator)
-
-proc HTML_FOCUS_ITERATOR_CLASS*(klass: pointer): PHtmlFocusIteratorClass = 
-  result = G_TYPE_CHECK_CLASS_CAST(klass, HTML_TYPE_FOCUS_ITERATOR(), 
-                                   HtmlFocusIteratorClass)
-
-proc HTML_IS_FOCUS_ITERATOR*(theobject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, HTML_TYPE_FOCUS_ITERATOR())
-
-proc HTML_IS_FOCUS_ITERATOR_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, HTML_TYPE_FOCUS_ITERATOR())
-
-proc HTML_FOCUS_ITERATOR_GET_CLASS*(obj: pointer): PHtmlFocusIteratorClass = 
-  result = G_TYPE_INSTANCE_GET_CLASS(obj, HTML_TYPE_FOCUS_ITERATOR(), 
-                                     HtmlFocusIteratorClass)
-
-proc HTML_PARSER_TYPE*(): GType = 
-  result = html_parser_get_type()
-
-proc HTML_PARSER*(obj: pointer): PHtmlParser = 
-  result = GTK_CHECK_CAST(obj, HTML_PARSER_TYPE(), THtmlParser)
-
-proc HTML_PARSER_CLASS*(klass: pointer): PHtmlParserClass = 
-  result = GTK_CHECK_CLASS_CAST(klass, HTML_PARSER_TYPE(), THtmlParserClass)
-
-proc HTML_IS_PARSER*(obj: pointer): bool = 
-  result = GTK_CHECK_TYPE(obj, HTML_PARSER_TYPE())
-
-proc HTML_TYPE_STREAM*(): GType = 
-  result = html_stream_get_type()
-
-proc HTML_STREAM*(obj: pointer): PHtmlStream = 
-  result = PHtmlStream(G_TYPE_CHECK_INSTANCE_CAST(obj, HTML_TYPE_STREAM()))
-
-proc HTML_STREAM_CLASS*(klass: pointer): PHtmlStreamClass = 
-  result = G_TYPE_CHECK_CLASS_CAST(klass, HTML_TYPE_STREAM())
-
-proc HTML_IS_STREAM*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, HTML_TYPE_STREAM())
-
-proc HTML_IS_STREAM_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, HTML_TYPE_STREAM())
-
-proc HTML_STREAM_GET_CLASS*(obj: pointer): PHtmlStreamClass = 
-  result = PHtmlStreamClass(G_TYPE_INSTANCE_GET_CLASS(obj, HTML_TYPE_STREAM()))
-
-proc GTK_HTML_CONTEXT_TYPE*(): GType = 
-  result = gtk_html_context_get_type()
-
-proc GTK_HTML_CONTEXT*(obj: pointer): PGtkHtmlContext = 
-  result = GTK_CHECK_CAST(obj, GTK_HTML_CONTEXT_TYPE(), TGtkHtmlContext)
-
-proc GTK_HTML_CONTEXT_CLASS*(klass: pointer): PGtkHtmlContextClass = 
-  result = GTK_CHECK_CLASS_CAST(klass, GTK_HTML_CONTEXT_TYPE(), 
-                                TGtkHtmlContextClass)
-
-proc GTK_HTML_IS_CONTEXT*(obj: pointer): bool = 
-  result = GTK_CHECK_TYPE(obj, GTK_HTML_CONTEXT_TYPE())
-
-proc GTK_HTML_IS_CONTEXT_CLASS*(klass: pointer): bool = 
-  result = GTK_CHECK_CLASS_TYPE(klass, GTK_HTML_CONTEXT_TYPE())
-
-proc HTML_TYPE_DOCUMENT*(): GType = 
-  result = html_document_get_type()
-
-proc HTML_DOCUMENT*(obj: pointer): PHtmlDocument = 
-  result = PHtmlDocument(GTK_CHECK_CAST(obj, HTML_TYPE_DOCUMENT()))
-
-proc HTML_DOCUMENT_CLASS*(klass: pointer): PHtmlDocumentClass = 
-  result = GTK_CHECK_CLASS_CAST(klass, HTML_TYPE_DOCUMENT())
-
-proc HTML_IS_DOCUMENT*(obj: pointer): bool = 
-  result = GTK_CHECK_TYPE(obj, HTML_TYPE_DOCUMENT())
-
-proc HTML_TYPE_VIEW*(): GType = 
-  result = html_view_get_type()
-
-proc HTML_VIEW*(obj: pointer): PHtmlView = 
-  result = PHtmlView(GTK_CHECK_CAST(obj, HTML_TYPE_VIEW()))
-
-proc HTML_VIEW_CLASS*(klass: pointer): PHtmlViewClass = 
-  result = PHtmlViewClass(GTK_CHECK_CLASS_CAST(klass, HTML_TYPE_VIEW()))
-
-proc HTML_IS_VIEW*(obj: pointer): bool = 
-  result = GTK_CHECK_TYPE(obj, HTML_TYPE_VIEW())
diff --git a/lib/oldwrappers/gtk/libglade2.nim b/lib/oldwrappers/gtk/libglade2.nim
deleted file mode 100755
index 5e323680e..000000000
--- a/lib/oldwrappers/gtk/libglade2.nim
+++ /dev/null
@@ -1,118 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2, gtk2
-
-when defined(win32):
-  const
-    LibGladeLib = "libglade-2.0-0.dll"
-else:
-  const
-    LibGladeLib = "libglade-2.0.so"
-type
-  PLongint* = ptr int32
-  PSmallInt* = ptr int16
-  PByte* = ptr int8
-  PWord* = ptr int16
-  PDWord* = ptr int32
-  PDouble* = ptr float64
-
-proc glade_init*(){.cdecl, dynlib: LibGladeLib, importc: "glade_init".}
-proc glade_require*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib,
-    importc: "glade_require".}
-proc glade_provide*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib,
-    importc: "glade_provide".}
-type
-  PGladeXMLPrivate* = pointer
-  PGladeXML* = ptr TGladeXML
-  TGladeXML* = object of TGObject
-    filename*: cstring
-    priv*: PGladeXMLPrivate
-
-  PGladeXMLClass* = ptr TGladeXMLClass
-  TGladeXMLClass* = object of TGObjectClass
-
-  TGladeXMLConnectFunc* = proc (handler_name: cstring, anObject: PGObject,
-                                signal_name: cstring, signal_data: cstring,
-                                connect_object: PGObject, after: gboolean,
-                                user_data: gpointer){.cdecl.}
-
-proc GLADE_TYPE_XML*(): GType
-proc GLADE_XML*(obj: pointer): PGladeXML
-proc GLADE_XML_CLASS*(klass: pointer): PGladeXMLClass
-proc GLADE_IS_XML*(obj: pointer): gboolean
-proc GLADE_IS_XML_CLASS*(klass: pointer): gboolean
-proc GLADE_XML_GET_CLASS*(obj: pointer): PGladeXMLClass
-proc glade_xml_get_type*(): GType{.cdecl, dynlib: LibGladeLib,
-                                   importc: "glade_xml_get_type".}
-proc glade_xml_new*(fname: cstring, root: cstring, domain: cstring): PGladeXML{.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_new".}
-proc glade_xml_new_from_buffer*(buffer: cstring, size: int32, root: cstring,
-                                domain: cstring): PGladeXML{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_new_from_buffer".}
-proc glade_xml_construct*(self: PGladeXML, fname: cstring, root: cstring,
-                          domain: cstring): gboolean{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_construct".}
-proc glade_xml_signal_connect*(self: PGladeXML, handlername: cstring,
-                               func: TGCallback){.cdecl, dynlib: LibGladeLib,
-    importc: "glade_xml_signal_connect".}
-proc glade_xml_signal_connect_data*(self: PGladeXML, handlername: cstring,
-                                    func: TGCallback, user_data: gpointer){.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_signal_connect_data".}
-proc glade_xml_signal_autoconnect*(self: PGladeXML){.cdecl, dynlib: LibGladeLib,
-    importc: "glade_xml_signal_autoconnect".}
-proc glade_xml_signal_connect_full*(self: PGladeXML, handler_name: cstring,
-                                    func: TGladeXMLConnectFunc,
-                                    user_data: gpointer){.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_signal_connect_full".}
-proc glade_xml_signal_autoconnect_full*(self: PGladeXML,
-                                        func: TGladeXMLConnectFunc,
-                                        user_data: gpointer){.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_signal_autoconnect_full".}
-proc glade_xml_get_widget*(self: PGladeXML, name: cstring): PGtkWidget{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_get_widget".}
-proc glade_xml_get_widget_prefix*(self: PGladeXML, name: cstring): PGList{.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_get_widget_prefix".}
-proc glade_xml_relative_file*(self: PGladeXML, filename: cstring): cstring{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_xml_relative_file".}
-proc glade_get_widget_name*(widget: PGtkWidget): cstring{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_get_widget_name".}
-proc glade_get_widget_tree*(widget: PGtkWidget): PGladeXML{.cdecl,
-    dynlib: LibGladeLib, importc: "glade_get_widget_tree".}
-type
-  PGladeXMLCustomWidgetHandler* = ptr TGladeXMLCustomWidgetHandler
-  TGladeXMLCustomWidgetHandler* = TGtkWidget
-
-proc glade_set_custom_handler*(handler: TGladeXMLCustomWidgetHandler,
-                               user_data: gpointer){.cdecl, dynlib: LibGladeLib,
-    importc: "glade_set_custom_handler".}
-proc glade_gnome_init*() =
-  glade_init()
-
-proc glade_bonobo_init*() =
-  glade_init()
-
-proc glade_xml_new_with_domain*(fname: cstring, root: cstring, domain: cstring): PGladeXML =
-  result = glade_xml_new(fname, root, domain)
-
-proc glade_xml_new_from_memory*(buffer: cstring, size: int32, root: cstring,
-                                domain: cstring): PGladeXML =
-  result = glade_xml_new_from_buffer(buffer, size, root, domain)
-
-proc GLADE_TYPE_XML*(): GType =
-  result = glade_xml_get_type()
-
-proc GLADE_XML*(obj: pointer): PGladeXML =
-  result = cast[PGladeXML](G_TYPE_CHECK_INSTANCE_CAST(obj, GLADE_TYPE_XML()))
-
-proc GLADE_XML_CLASS*(klass: pointer): PGladeXMLClass =
-  result = cast[PGladeXMLClass](G_TYPE_CHECK_CLASS_CAST(klass, GLADE_TYPE_XML()))
-
-proc GLADE_IS_XML*(obj: pointer): gboolean =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, GLADE_TYPE_XML())
-
-proc GLADE_IS_XML_CLASS*(klass: pointer): gboolean =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, GLADE_TYPE_XML())
-
-proc GLADE_XML_GET_CLASS*(obj: pointer): PGladeXMLClass =
-  result = cast[PGladeXMLClass](G_TYPE_INSTANCE_GET_CLASS(obj, GLADE_TYPE_XML()))
diff --git a/lib/oldwrappers/gtk/pango.nim b/lib/oldwrappers/gtk/pango.nim
deleted file mode 100755
index ade2da989..000000000
--- a/lib/oldwrappers/gtk/pango.nim
+++ /dev/null
@@ -1,1208 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2
-
-when defined(win32):
-  const
-    pangolib* = "libpango-1.0-0.dll"
-else:
-  const
-    pangolib* = "libpango-1.0.so.0"
-type
-  PPangoFont* = pointer
-  PPangoFontFamily* = pointer
-  PPangoFontset* = pointer
-  PPangoFontMetrics* = pointer
-  PPangoFontFace* = pointer
-  PPangoFontMap* = pointer
-  PPangoFontsetClass* = pointer
-  PPangoFontFamilyClass* = pointer
-  PPangoFontFaceClass* = pointer
-  PPangoFontClass* = pointer
-  PPangoFontMapClass* = pointer
-  PPangoFontDescription* = ptr TPangoFontDescription
-  TPangoFontDescription* = pointer
-  PPangoAttrList* = ptr TPangoAttrList
-  TPangoAttrList* = pointer
-  PPangoAttrIterator* = ptr TPangoAttrIterator
-  TPangoAttrIterator* = pointer
-  PPangoLayout* = ptr TPangoLayout
-  TPangoLayout* = pointer
-  PPangoLayoutClass* = ptr TPangoLayoutClass
-  TPangoLayoutClass* = pointer
-  PPangoLayoutIter* = ptr TPangoLayoutIter
-  TPangoLayoutIter* = pointer
-  PPangoContext* = ptr TPangoContext
-  TPangoContext* = pointer
-  PPangoContextClass* = ptr TPangoContextClass
-  TPangoContextClass* = pointer
-  PPangoFontsetSimple* = ptr TPangoFontsetSimple
-  TPangoFontsetSimple* = pointer
-  PPangoTabArray* = ptr TPangoTabArray
-  TPangoTabArray* = pointer
-  PPangoGlyphString* = ptr TPangoGlyphString
-  PPangoAnalysis* = ptr TPangoAnalysis
-  PPangoItem* = ptr TPangoItem
-  PPangoLanguage* = ptr TPangoLanguage
-  TPangoLanguage* = pointer
-  PPangoGlyph* = ptr TPangoGlyph
-  TPangoGlyph* = guint32
-  PPangoRectangle* = ptr TPangoRectangle
-  TPangoRectangle* {.final, pure.} = object
-    x*: int32
-    y*: int32
-    width*: int32
-    height*: int32
-
-  PPangoDirection* = ptr TPangoDirection
-  TPangoDirection* = enum
-    PANGO_DIRECTION_LTR, PANGO_DIRECTION_RTL, PANGO_DIRECTION_TTB_LTR,
-    PANGO_DIRECTION_TTB_RTL
-  PPangoColor* = ptr TPangoColor
-  TPangoColor* {.final, pure.} = object
-    red*: guint16
-    green*: guint16
-    blue*: guint16
-
-  PPangoAttrType* = ptr TPangoAttrType
-  TPangoAttrType* = int32
-  PPangoUnderline* = ptr TPangoUnderline
-  TPangoUnderline* = int32
-  PPangoAttribute* = ptr TPangoAttribute
-  PPangoAttrClass* = ptr TPangoAttrClass
-  TPangoAttribute* {.final, pure.} = object
-    klass*: PPangoAttrClass
-    start_index*: int
-    end_index*: int
-
-  TPangoAttrClass* {.final, pure.} = object
-    `type`*: TPangoAttrType
-    copy*: proc (attr: PPangoAttribute): PPangoAttribute{.cdecl.}
-    destroy*: proc (attr: PPangoAttribute){.cdecl.}
-    equal*: proc (attr1: PPangoAttribute, attr2: PPangoAttribute): gboolean{.
-        cdecl.}
-
-  PPangoAttrString* = ptr TPangoAttrString
-  TPangoAttrString* {.final, pure.} = object
-    attr*: TPangoAttribute
-    value*: cstring
-
-  PPangoAttrLanguage* = ptr TPangoAttrLanguage
-  TPangoAttrLanguage* {.final, pure.} = object
-    attr*: TPangoAttribute
-    value*: PPangoLanguage
-
-  PPangoAttrInt* = ptr TPangoAttrInt
-  TPangoAttrInt* {.final, pure.} = object
-    attr*: TPangoAttribute
-    value*: int32
-
-  PPangoAttrFloat* = ptr TPangoAttrFloat
-  TPangoAttrFloat* {.final, pure.} = object
-    attr*: TPangoAttribute
-    value*: gdouble
-
-  PPangoAttrColor* = ptr TPangoAttrColor
-  TPangoAttrColor* {.final, pure.} = object
-    attr*: TPangoAttribute
-    color*: TPangoColor
-
-  PPangoAttrShape* = ptr TPangoAttrShape
-  TPangoAttrShape* {.final, pure.} = object
-    attr*: TPangoAttribute
-    ink_rect*: TPangoRectangle
-    logical_rect*: TPangoRectangle
-
-  PPangoAttrFontDesc* = ptr TPangoAttrFontDesc
-  TPangoAttrFontDesc* {.final, pure.} = object
-    attr*: TPangoAttribute
-    desc*: PPangoFontDescription
-
-  PPangoLogAttr* = ptr TPangoLogAttr
-  TPangoLogAttr* {.final, pure.} = object
-    flag0*: guint16
-
-  PPangoCoverageLevel* = ptr TPangoCoverageLevel
-  TPangoCoverageLevel* = enum
-    PANGO_COVERAGE_NONE, PANGO_COVERAGE_FALLBACK, PANGO_COVERAGE_APPROXIMATE,
-    PANGO_COVERAGE_EXACT
-  PPangoBlockInfo* = ptr TPangoBlockInfo
-  TPangoBlockInfo* {.final, pure.} = object
-    data*: Pguchar
-    level*: TPangoCoverageLevel
-
-  PPangoCoverage* = ptr TPangoCoverage
-  TPangoCoverage* {.final, pure.} = object
-    ref_count*: int
-    n_blocks*: int32
-    data_size*: int32
-    blocks*: PPangoBlockInfo
-
-  PPangoEngineRange* = ptr TPangoEngineRange
-  TPangoEngineRange* {.final, pure.} = object
-    start*: int32
-    theEnd*: int32
-    langs*: cstring
-
-  PPangoEngineInfo* = ptr TPangoEngineInfo
-  TPangoEngineInfo* {.final, pure.} = object
-    id*: cstring
-    engine_type*: cstring
-    render_type*: cstring
-    ranges*: PPangoEngineRange
-    n_ranges*: gint
-
-  PPangoEngine* = ptr TPangoEngine
-  TPangoEngine* {.final, pure.} = object
-    id*: cstring
-    `type`*: cstring
-    length*: gint
-
-  TPangoEngineLangScriptBreak* = proc (text: cstring, len: int32,
-                                       analysis: PPangoAnalysis,
-                                       attrs: PPangoLogAttr, attrs_len: int32){.
-      cdecl.}
-  PPangoEngineLang* = ptr TPangoEngineLang
-  TPangoEngineLang* {.final, pure.} = object
-    engine*: TPangoEngine
-    script_break*: TPangoEngineLangScriptBreak
-
-  TPangoEngineShapeScript* = proc (font: PPangoFont, text: cstring,
-                                   length: int32, analysis: PPangoAnalysis,
-                                   glyphs: PPangoGlyphString){.cdecl.}
-  TPangoEngineShapeGetCoverage* = proc (font: PPangoFont,
-                                        language: PPangoLanguage): PPangoCoverage{.
-      cdecl.}
-  PPangoEngineShape* = ptr TPangoEngineShape
-  TPangoEngineShape* {.final, pure.} = object
-    engine*: TPangoEngine
-    script_shape*: TPangoEngineShapeScript
-    get_coverage*: TPangoEngineShapeGetCoverage
-
-  PPangoStyle* = ptr TPangoStyle
-  TPangoStyle* = gint
-  PPangoVariant* = ptr TPangoVariant
-  TPangoVariant* = gint
-  PPangoWeight* = ptr TPangoWeight
-  TPangoWeight* = gint
-  PPangoStretch* = ptr TPangoStretch
-  TPangoStretch* = gint
-  PPangoFontMask* = ptr TPangoFontMask
-  TPangoFontMask* = int32
-  PPangoGlyphUnit* = ptr TPangoGlyphUnit
-  TPangoGlyphUnit* = gint32
-  PPangoGlyphGeometry* = ptr TPangoGlyphGeometry
-  TPangoGlyphGeometry* {.final, pure.} = object
-    width*: TPangoGlyphUnit
-    x_offset*: TPangoGlyphUnit
-    y_offset*: TPangoGlyphUnit
-
-  PPangoGlyphVisAttr* = ptr TPangoGlyphVisAttr
-  TPangoGlyphVisAttr* {.final, pure.} = object
-    flag0*: int16
-
-  PPangoGlyphInfo* = ptr TPangoGlyphInfo
-  TPangoGlyphInfo* {.final, pure.} = object
-    glyph*: TPangoGlyph
-    geometry*: TPangoGlyphGeometry
-    attr*: TPangoGlyphVisAttr
-
-  TPangoGlyphString* {.final, pure.} = object
-    num_glyphs*: gint
-    glyphs*: PPangoGlyphInfo
-    log_clusters*: Pgint
-    space*: gint
-
-  TPangoAnalysis* {.final, pure.} = object
-    shape_engine*: PPangoEngineShape
-    lang_engine*: PPangoEngineLang
-    font*: PPangoFont
-    level*: guint8
-    language*: PPangoLanguage
-    extra_attrs*: PGSList
-
-  TPangoItem* {.final, pure.} = object
-    offset*: gint
-    length*: gint
-    num_chars*: gint
-    analysis*: TPangoAnalysis
-
-  PPangoAlignment* = ptr TPangoAlignment
-  TPangoAlignment* = enum
-    PANGO_ALIGN_LEFT, PANGO_ALIGN_CENTER, PANGO_ALIGN_RIGHT
-  PPangoWrapMode* = ptr TPangoWrapMode
-  TPangoWrapMode* = enum
-    PANGO_WRAP_WORD, PANGO_WRAP_CHAR
-  PPangoLayoutLine* = ptr TPangoLayoutLine
-  TPangoLayoutLine* {.final, pure.} = object
-    layout*: PPangoLayout
-    start_index*: gint
-    length*: gint
-    runs*: PGSList
-
-  PPangoLayoutRun* = ptr TPangoLayoutRun
-  TPangoLayoutRun* {.final, pure.} = object
-    item*: PPangoItem
-    glyphs*: PPangoGlyphString
-
-  PPangoTabAlign* = ptr TPangoTabAlign
-  TPangoTabAlign* = enum
-    PANGO_TAB_LEFT
-
-const
-  PANGO_SCALE* = 1024
-
-proc PANGO_PIXELS*(d: int): int
-proc PANGO_ASCENT*(rect: TPangoRectangle): int32
-proc PANGO_DESCENT*(rect: TPangoRectangle): int32
-proc PANGO_LBEARING*(rect: TPangoRectangle): int32
-proc PANGO_RBEARING*(rect: TPangoRectangle): int32
-proc PANGO_TYPE_LANGUAGE*(): GType
-proc pango_language_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                        importc: "pango_language_get_type".}
-proc pango_language_from_string*(language: cstring): PPangoLanguage{.cdecl,
-    dynlib: pangolib, importc: "pango_language_from_string".}
-proc pango_language_to_string*(language: PPangoLanguage): cstring
-proc pango_language_matches*(language: PPangoLanguage, range_list: cstring): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_language_matches".}
-const
-  PANGO_ATTR_INVALID* = 0
-  PANGO_ATTR_LANGUAGE* = 1
-  PANGO_ATTR_FAMILY* = 2
-  PANGO_ATTR_STYLE* = 3
-  PANGO_ATTR_WEIGHT* = 4
-  PANGO_ATTR_VARIANT* = 5
-  PANGO_ATTR_STRETCH* = 6
-  PANGO_ATTR_SIZE* = 7
-  PANGO_ATTR_FONT_DESC* = 8
-  PANGO_ATTR_FOREGROUND* = 9
-  PANGO_ATTR_BACKGROUND* = 10
-  PANGO_ATTR_UNDERLINE* = 11
-  PANGO_ATTR_STRIKETHROUGH* = 12
-  PANGO_ATTR_RISE* = 13
-  PANGO_ATTR_SHAPE* = 14
-  PANGO_ATTR_SCALE* = 15
-  PANGO_UNDERLINE_NONE* = 0
-  PANGO_UNDERLINE_SINGLE* = 1
-  PANGO_UNDERLINE_DOUBLE* = 2
-  PANGO_UNDERLINE_LOW* = 3
-
-proc PANGO_TYPE_COLOR*(): GType
-proc pango_color_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                     importc: "pango_color_get_type".}
-proc pango_color_copy*(src: PPangoColor): PPangoColor{.cdecl, dynlib: pangolib,
-    importc: "pango_color_copy".}
-proc pango_color_free*(color: PPangoColor){.cdecl, dynlib: pangolib,
-    importc: "pango_color_free".}
-proc pango_color_parse*(color: PPangoColor, spec: cstring): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_color_parse".}
-proc PANGO_TYPE_ATTR_LIST*(): GType
-proc pango_attr_type_register*(name: cstring): TPangoAttrType{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_type_register".}
-proc pango_attribute_copy*(attr: PPangoAttribute): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attribute_copy".}
-proc pango_attribute_destroy*(attr: PPangoAttribute){.cdecl, dynlib: pangolib,
-    importc: "pango_attribute_destroy".}
-proc pango_attribute_equal*(attr1: PPangoAttribute, attr2: PPangoAttribute): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_attribute_equal".}
-proc pango_attr_language_new*(language: PPangoLanguage): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_language_new".}
-proc pango_attr_family_new*(family: cstring): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_family_new".}
-proc pango_attr_foreground_new*(red: guint16, green: guint16, blue: guint16): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_foreground_new".}
-proc pango_attr_background_new*(red: guint16, green: guint16, blue: guint16): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_background_new".}
-proc pango_attr_size_new*(size: int32): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_size_new".}
-proc pango_attr_style_new*(style: TPangoStyle): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_style_new".}
-proc pango_attr_weight_new*(weight: TPangoWeight): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_weight_new".}
-proc pango_attr_variant_new*(variant: TPangoVariant): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_variant_new".}
-proc pango_attr_stretch_new*(stretch: TPangoStretch): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_stretch_new".}
-proc pango_attr_font_desc_new*(desc: PPangoFontDescription): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_font_desc_new".}
-proc pango_attr_underline_new*(underline: TPangoUnderline): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_underline_new".}
-proc pango_attr_strikethrough_new*(strikethrough: gboolean): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_strikethrough_new".}
-proc pango_attr_rise_new*(rise: int32): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_rise_new".}
-proc pango_attr_shape_new*(ink_rect: PPangoRectangle,
-                           logical_rect: PPangoRectangle): PPangoAttribute{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_shape_new".}
-proc pango_attr_scale_new*(scale_factor: gdouble): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_scale_new".}
-proc pango_attr_list_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_attr_list_get_type".}
-proc pango_attr_list_new*(): PPangoAttrList{.cdecl, dynlib: pangolib,
-    importc: "pango_attr_list_new".}
-proc pango_attr_list_ref*(list: PPangoAttrList){.cdecl, dynlib: pangolib,
-    importc: "pango_attr_list_ref".}
-proc pango_attr_list_unref*(list: PPangoAttrList){.cdecl, dynlib: pangolib,
-    importc: "pango_attr_list_unref".}
-proc pango_attr_list_copy*(list: PPangoAttrList): PPangoAttrList{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_list_copy".}
-proc pango_attr_list_insert*(list: PPangoAttrList, attr: PPangoAttribute){.
-    cdecl, dynlib: pangolib, importc: "pango_attr_list_insert".}
-proc pango_attr_list_insert_before*(list: PPangoAttrList, attr: PPangoAttribute){.
-    cdecl, dynlib: pangolib, importc: "pango_attr_list_insert_before".}
-proc pango_attr_list_change*(list: PPangoAttrList, attr: PPangoAttribute){.
-    cdecl, dynlib: pangolib, importc: "pango_attr_list_change".}
-proc pango_attr_list_splice*(list: PPangoAttrList, other: PPangoAttrList,
-                             pos: gint, len: gint){.cdecl, dynlib: pangolib,
-    importc: "pango_attr_list_splice".}
-proc pango_attr_list_get_iterator*(list: PPangoAttrList): PPangoAttrIterator{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_list_get_iterator".}
-proc pango_attr_iterator_range*(`iterator`: PPangoAttrIterator, start: Pgint,
-                                theEnd: Pgint){.cdecl, dynlib: pangolib,
-    importc: "pango_attr_iterator_range".}
-proc pango_attr_iterator_next*(`iterator`: PPangoAttrIterator): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_iterator_next".}
-proc pango_attr_iterator_copy*(`iterator`: PPangoAttrIterator): PPangoAttrIterator{.
-    cdecl, dynlib: pangolib, importc: "pango_attr_iterator_copy".}
-proc pango_attr_iterator_destroy*(`iterator`: PPangoAttrIterator){.cdecl,
-    dynlib: pangolib, importc: "pango_attr_iterator_destroy".}
-proc pango_attr_iterator_get*(`iterator`: PPangoAttrIterator,
-                              `type`: TPangoAttrType): PPangoAttribute{.cdecl,
-    dynlib: pangolib, importc: "pango_attr_iterator_get".}
-proc pango_attr_iterator_get_font*(`iterator`: PPangoAttrIterator,
-                                   desc: PPangoFontDescription,
-                                   language: var PPangoLanguage,
-                                   extra_attrs: PPGSList){.cdecl,
-    dynlib: pangolib, importc: "pango_attr_iterator_get_font".}
-proc pango_parse_markup*(markup_text: cstring, length: int32,
-                         accel_marker: gunichar, attr_list: var PPangoAttrList,
-                         text: PPchar, accel_char: Pgunichar, error: pointer): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_parse_markup".}
-const
-  bm_TPangoLogAttr_is_line_break* = 0x00000001'i16
-  bp_TPangoLogAttr_is_line_break* = 0'i16
-  bm_TPangoLogAttr_is_mandatory_break* = 0x00000002'i16
-  bp_TPangoLogAttr_is_mandatory_break* = 1'i16
-  bm_TPangoLogAttr_is_char_break* = 0x00000004'i16
-  bp_TPangoLogAttr_is_char_break* = 2'i16
-  bm_TPangoLogAttr_is_white* = 0x00000008'i16
-  bp_TPangoLogAttr_is_white* = 3'i16
-  bm_TPangoLogAttr_is_cursor_position* = 0x00000010'i16
-  bp_TPangoLogAttr_is_cursor_position* = 4'i16
-  bm_TPangoLogAttr_is_word_start* = 0x00000020'i16
-  bp_TPangoLogAttr_is_word_start* = 5'i16
-  bm_TPangoLogAttr_is_word_end* = 0x00000040'i16
-  bp_TPangoLogAttr_is_word_end* = 6'i16
-  bm_TPangoLogAttr_is_sentence_boundary* = 0x00000080'i16
-  bp_TPangoLogAttr_is_sentence_boundary* = 7'i16
-  bm_TPangoLogAttr_is_sentence_start* = 0x00000100'i16
-  bp_TPangoLogAttr_is_sentence_start* = 8'i16
-  bm_TPangoLogAttr_is_sentence_end* = 0x00000200'i16
-  bp_TPangoLogAttr_is_sentence_end* = 9'i16
-
-proc is_line_break*(a: var TPangoLogAttr): guint
-proc set_is_line_break*(a: var TPangoLogAttr, `is_line_break`: guint)
-proc is_mandatory_break*(a: var TPangoLogAttr): guint
-proc set_is_mandatory_break*(a: var TPangoLogAttr, `is_mandatory_break`: guint)
-proc is_char_break*(a: var TPangoLogAttr): guint
-proc set_is_char_break*(a: var TPangoLogAttr, `is_char_break`: guint)
-proc is_white*(a: var TPangoLogAttr): guint
-proc set_is_white*(a: var TPangoLogAttr, `is_white`: guint)
-proc is_cursor_position*(a: var TPangoLogAttr): guint
-proc set_is_cursor_position*(a: var TPangoLogAttr, `is_cursor_position`: guint)
-proc is_word_start*(a: var TPangoLogAttr): guint
-proc set_is_word_start*(a: var TPangoLogAttr, `is_word_start`: guint)
-proc is_word_end*(a: var TPangoLogAttr): guint
-proc set_is_word_end*(a: var TPangoLogAttr, `is_word_end`: guint)
-proc is_sentence_boundary*(a: var TPangoLogAttr): guint
-proc set_is_sentence_boundary*(a: var TPangoLogAttr,
-                               `is_sentence_boundary`: guint)
-proc is_sentence_start*(a: var TPangoLogAttr): guint
-proc set_is_sentence_start*(a: var TPangoLogAttr, `is_sentence_start`: guint)
-proc is_sentence_end*(a: var TPangoLogAttr): guint
-proc set_is_sentence_end*(a: var TPangoLogAttr, `is_sentence_end`: guint)
-proc pango_break*(text: cstring, length: int32, analysis: PPangoAnalysis,
-                  attrs: PPangoLogAttr, attrs_len: int32){.cdecl,
-    dynlib: pangolib, importc: "pango_break".}
-proc pango_find_paragraph_boundary*(text: cstring, length: gint,
-                                    paragraph_delimiter_index: Pgint,
-                                    next_paragraph_start: Pgint){.cdecl,
-    dynlib: pangolib, importc: "pango_find_paragraph_boundary".}
-proc pango_get_log_attrs*(text: cstring, length: int32, level: int32,
-                          language: PPangoLanguage, log_attrs: PPangoLogAttr,
-                          attrs_len: int32){.cdecl, dynlib: pangolib,
-    importc: "pango_get_log_attrs".}
-proc PANGO_TYPE_CONTEXT*(): GType
-proc PANGO_CONTEXT*(anObject: pointer): PPangoContext
-proc PANGO_CONTEXT_CLASS*(klass: pointer): PPangoContextClass
-proc PANGO_IS_CONTEXT*(anObject: pointer): bool
-proc PANGO_IS_CONTEXT_CLASS*(klass: pointer): bool
-proc PANGO_CONTEXT_GET_CLASS*(obj: PPangoContext): PPangoContextClass
-proc pango_context_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                       importc: "pango_context_get_type".}
-proc pango_context_list_families*(context: PPangoContext,
-                                  families: openarray[ptr PPangoFontFamily]){.cdecl,
-    dynlib: pangolib, importc: "pango_context_list_families".}
-proc pango_context_load_font*(context: PPangoContext,
-                              desc: PPangoFontDescription): PPangoFont{.cdecl,
-    dynlib: pangolib, importc: "pango_context_load_font".}
-proc pango_context_load_fontset*(context: PPangoContext,
-                                 desc: PPangoFontDescription,
-                                 language: PPangoLanguage): PPangoFontset{.
-    cdecl, dynlib: pangolib, importc: "pango_context_load_fontset".}
-proc pango_context_get_metrics*(context: PPangoContext,
-                                desc: PPangoFontDescription,
-                                language: PPangoLanguage): PPangoFontMetrics{.
-    cdecl, dynlib: pangolib, importc: "pango_context_get_metrics".}
-proc pango_context_set_font_description*(context: PPangoContext,
-    desc: PPangoFontDescription){.cdecl, dynlib: pangolib,
-                                  importc: "pango_context_set_font_description".}
-proc pango_context_get_font_description*(context: PPangoContext): PPangoFontDescription{.
-    cdecl, dynlib: pangolib, importc: "pango_context_get_font_description".}
-proc pango_context_get_language*(context: PPangoContext): PPangoLanguage{.cdecl,
-    dynlib: pangolib, importc: "pango_context_get_language".}
-proc pango_context_set_language*(context: PPangoContext,
-                                 language: PPangoLanguage){.cdecl,
-    dynlib: pangolib, importc: "pango_context_set_language".}
-proc pango_context_set_base_dir*(context: PPangoContext,
-                                 direction: TPangoDirection){.cdecl,
-    dynlib: pangolib, importc: "pango_context_set_base_dir".}
-proc pango_context_get_base_dir*(context: PPangoContext): TPangoDirection{.
-    cdecl, dynlib: pangolib, importc: "pango_context_get_base_dir".}
-proc pango_itemize*(context: PPangoContext, text: cstring, start_index: int32,
-                    length: int32, attrs: PPangoAttrList,
-                    cached_iter: PPangoAttrIterator): PGList{.cdecl,
-    dynlib: pangolib, importc: "pango_itemize".}
-proc pango_coverage_new*(): PPangoCoverage{.cdecl, dynlib: pangolib,
-    importc: "pango_coverage_new".}
-proc pango_coverage_ref*(coverage: PPangoCoverage): PPangoCoverage{.cdecl,
-    dynlib: pangolib, importc: "pango_coverage_ref".}
-proc pango_coverage_unref*(coverage: PPangoCoverage){.cdecl, dynlib: pangolib,
-    importc: "pango_coverage_unref".}
-proc pango_coverage_copy*(coverage: PPangoCoverage): PPangoCoverage{.cdecl,
-    dynlib: pangolib, importc: "pango_coverage_copy".}
-proc pango_coverage_get*(coverage: PPangoCoverage, index: int32): TPangoCoverageLevel{.
-    cdecl, dynlib: pangolib, importc: "pango_coverage_get".}
-proc pango_coverage_set*(coverage: PPangoCoverage, index: int32,
-                         level: TPangoCoverageLevel){.cdecl, dynlib: pangolib,
-    importc: "pango_coverage_set".}
-proc pango_coverage_max*(coverage: PPangoCoverage, other: PPangoCoverage){.
-    cdecl, dynlib: pangolib, importc: "pango_coverage_max".}
-proc pango_coverage_to_bytes*(coverage: PPangoCoverage, bytes: PPguchar,
-                              n_bytes: var int32){.cdecl, dynlib: pangolib,
-    importc: "pango_coverage_to_bytes".}
-proc pango_coverage_from_bytes*(bytes: Pguchar, n_bytes: int32): PPangoCoverage{.
-    cdecl, dynlib: pangolib, importc: "pango_coverage_from_bytes".}
-proc PANGO_TYPE_FONTSET*(): GType
-proc PANGO_FONTSET*(anObject: pointer): PPangoFontset
-proc PANGO_IS_FONTSET*(anObject: pointer): bool
-proc pango_fontset_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                       importc: "pango_fontset_get_type".}
-proc pango_fontset_get_font*(fontset: PPangoFontset, wc: guint): PPangoFont{.
-    cdecl, dynlib: pangolib, importc: "pango_fontset_get_font".}
-proc pango_fontset_get_metrics*(fontset: PPangoFontset): PPangoFontMetrics{.
-    cdecl, dynlib: pangolib, importc: "pango_fontset_get_metrics".}
-const
-  PANGO_STYLE_NORMAL* = 0
-  PANGO_STYLE_OBLIQUE* = 1
-  PANGO_STYLE_ITALIC* = 2
-  PANGO_VARIANT_NORMAL* = 0
-  PANGO_VARIANT_SMALL_CAPS* = 1
-  PANGO_WEIGHT_ULTRALIGHT* = 200
-  PANGO_WEIGHT_LIGHT* = 300
-  PANGO_WEIGHT_NORMAL* = 400
-  PANGO_WEIGHT_BOLD* = 700
-  PANGO_WEIGHT_ULTRABOLD* = 800
-  PANGO_WEIGHT_HEAVY* = 900
-  PANGO_STRETCH_ULTRA_CONDENSED* = 0
-  PANGO_STRETCH_EXTRA_CONDENSED* = 1
-  PANGO_STRETCH_CONDENSED* = 2
-  PANGO_STRETCH_SEMI_CONDENSED* = 3
-  PANGO_STRETCH_NORMAL* = 4
-  PANGO_STRETCH_SEMI_EXPANDED* = 5
-  PANGO_STRETCH_EXPANDED* = 6
-  PANGO_STRETCH_EXTRA_EXPANDED* = 7
-  PANGO_STRETCH_ULTRA_EXPANDED* = 8
-  PANGO_FONT_MASK_FAMILY* = 1 shl 0
-  PANGO_FONT_MASK_STYLE* = 1 shl 1
-  PANGO_FONT_MASK_VARIANT* = 1 shl 2
-  PANGO_FONT_MASK_WEIGHT* = 1 shl 3
-  PANGO_FONT_MASK_STRETCH* = 1 shl 4
-  PANGO_FONT_MASK_SIZE* = 1 shl 5
-  PANGO_SCALE_XX_SMALL* = 0.5787037037036999
-  PANGO_SCALE_X_SMALL* = 0.6444444444443999
-  PANGO_SCALE_SMALL* = 0.8333333333332999
-  PANGO_SCALE_MEDIUM* = 1.0
-  PANGO_SCALE_LARGE* = 1.2
-  PANGO_SCALE_X_LARGE* = 1.4399999999999
-  PANGO_SCALE_XX_LARGE* = 1.728
-
-proc PANGO_TYPE_FONT_DESCRIPTION*(): GType
-proc pango_font_description_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_font_description_get_type".}
-proc pango_font_description_new*(): PPangoFontDescription{.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_new".}
-proc pango_font_description_copy*(desc: PPangoFontDescription): PPangoFontDescription{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_copy".}
-proc pango_font_description_copy_static*(desc: PPangoFontDescription): PPangoFontDescription{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_copy_static".}
-proc pango_font_description_hash*(desc: PPangoFontDescription): guint{.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_hash".}
-proc pango_font_description_equal*(desc1: PPangoFontDescription,
-                                   desc2: PPangoFontDescription): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_equal".}
-proc pango_font_description_free*(desc: PPangoFontDescription){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_free".}
-proc pango_font_descriptions_free*(descs: var PPangoFontDescription,
-                                   n_descs: int32){.cdecl, dynlib: pangolib,
-    importc: "pango_font_descriptions_free".}
-proc pango_font_description_set_family*(desc: PPangoFontDescription,
-                                        family: cstring){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_set_family".}
-proc pango_font_description_set_family_static*(desc: PPangoFontDescription,
-    family: cstring){.cdecl, dynlib: pangolib,
-                      importc: "pango_font_description_set_family_static".}
-proc pango_font_description_get_family*(desc: PPangoFontDescription): cstring{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_family".}
-proc pango_font_description_set_style*(desc: PPangoFontDescription,
-                                       style: TPangoStyle){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_set_style".}
-proc pango_font_description_get_style*(desc: PPangoFontDescription): TPangoStyle{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_style".}
-proc pango_font_description_set_variant*(desc: PPangoFontDescription,
-    variant: TPangoVariant){.cdecl, dynlib: pangolib,
-                             importc: "pango_font_description_set_variant".}
-proc pango_font_description_get_variant*(desc: PPangoFontDescription): TPangoVariant{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_variant".}
-proc pango_font_description_set_weight*(desc: PPangoFontDescription,
-                                        weight: TPangoWeight){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_set_weight".}
-proc pango_font_description_get_weight*(desc: PPangoFontDescription): TPangoWeight{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_weight".}
-proc pango_font_description_set_stretch*(desc: PPangoFontDescription,
-    stretch: TPangoStretch){.cdecl, dynlib: pangolib,
-                             importc: "pango_font_description_set_stretch".}
-proc pango_font_description_get_stretch*(desc: PPangoFontDescription): TPangoStretch{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_stretch".}
-proc pango_font_description_set_size*(desc: PPangoFontDescription, size: gint){.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_set_size".}
-proc pango_font_description_get_size*(desc: PPangoFontDescription): gint{.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_get_size".}
-proc pango_font_description_set_absolute_size*(desc: PPangoFontDescription,
-    size: float64){.cdecl, dynlib: pangolib,
-                    importc: "pango_font_description_set_absolute_size".}
-proc pango_font_description_get_size_is_absolute*(desc: PPangoFontDescription,
-    size: float64): gboolean{.cdecl, dynlib: pangolib, importc: "pango_font_description_get_size_is_absolute".}
-proc pango_font_description_get_set_fields*(desc: PPangoFontDescription): TPangoFontMask{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_get_set_fields".}
-proc pango_font_description_unset_fields*(desc: PPangoFontDescription,
-    to_unset: TPangoFontMask){.cdecl, dynlib: pangolib,
-                               importc: "pango_font_description_unset_fields".}
-proc pango_font_description_merge*(desc: PPangoFontDescription,
-                                   desc_to_merge: PPangoFontDescription,
-                                   replace_existing: gboolean){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_merge".}
-proc pango_font_description_merge_static*(desc: PPangoFontDescription,
-    desc_to_merge: PPangoFontDescription, replace_existing: gboolean){.cdecl,
-    dynlib: pangolib, importc: "pango_font_description_merge_static".}
-proc pango_font_description_better_match*(desc: PPangoFontDescription,
-    old_match: PPangoFontDescription, new_match: PPangoFontDescription): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_better_match".}
-proc pango_font_description_from_string*(str: cstring): PPangoFontDescription{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_from_string".}
-proc pango_font_description_to_string*(desc: PPangoFontDescription): cstring{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_to_string".}
-proc pango_font_description_to_filename*(desc: PPangoFontDescription): cstring{.
-    cdecl, dynlib: pangolib, importc: "pango_font_description_to_filename".}
-proc PANGO_TYPE_FONT_METRICS*(): GType
-proc pango_font_metrics_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_font_metrics_get_type".}
-proc pango_font_metrics_ref*(metrics: PPangoFontMetrics): PPangoFontMetrics{.
-    cdecl, dynlib: pangolib, importc: "pango_font_metrics_ref".}
-proc pango_font_metrics_unref*(metrics: PPangoFontMetrics){.cdecl,
-    dynlib: pangolib, importc: "pango_font_metrics_unref".}
-proc pango_font_metrics_get_ascent*(metrics: PPangoFontMetrics): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_font_metrics_get_ascent".}
-proc pango_font_metrics_get_descent*(metrics: PPangoFontMetrics): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_font_metrics_get_descent".}
-proc pango_font_metrics_get_approximate_char_width*(metrics: PPangoFontMetrics): int32{.
-    cdecl, dynlib: pangolib,
-    importc: "pango_font_metrics_get_approximate_char_width".}
-proc pango_font_metrics_get_approximate_digit_width*(metrics: PPangoFontMetrics): int32{.
-    cdecl, dynlib: pangolib,
-    importc: "pango_font_metrics_get_approximate_digit_width".}
-proc PANGO_TYPE_FONT_FAMILY*(): GType
-proc PANGO_FONT_FAMILY*(anObject: Pointer): PPangoFontFamily
-proc PANGO_IS_FONT_FAMILY*(anObject: Pointer): bool
-proc pango_font_family_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_font_family_get_type".}
-proc pango_font_family_list_faces*(family: PPangoFontFamily,
-                                   faces: var openarray[ptr PPangoFontFace]){.
-    cdecl, dynlib: pangolib, importc: "pango_font_family_list_faces".}
-proc pango_font_family_get_name*(family: PPangoFontFamily): cstring{.cdecl,
-    dynlib: pangolib, importc: "pango_font_family_get_name".}
-proc PANGO_TYPE_FONT_FACE*(): GType
-proc PANGO_FONT_FACE*(anObject: pointer): PPangoFontFace
-proc PANGO_IS_FONT_FACE*(anObject: pointer): bool
-proc pango_font_face_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_font_face_get_type".}
-proc pango_font_face_describe*(face: PPangoFontFace): PPangoFontDescription{.
-    cdecl, dynlib: pangolib, importc: "pango_font_face_describe".}
-proc pango_font_face_get_face_name*(face: PPangoFontFace): cstring{.cdecl,
-    dynlib: pangolib, importc: "pango_font_face_get_face_name".}
-proc PANGO_TYPE_FONT*(): GType
-proc PANGO_FONT*(anObject: pointer): PPangoFont
-proc PANGO_IS_FONT*(anObject: pointer): bool
-proc pango_font_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                    importc: "pango_font_get_type".}
-proc pango_font_describe*(font: PPangoFont): PPangoFontDescription{.cdecl,
-    dynlib: pangolib, importc: "pango_font_describe".}
-proc pango_font_get_coverage*(font: PPangoFont, language: PPangoLanguage): PPangoCoverage{.
-    cdecl, dynlib: pangolib, importc: "pango_font_get_coverage".}
-proc pango_font_find_shaper*(font: PPangoFont, language: PPangoLanguage,
-                             ch: guint32): PPangoEngineShape{.cdecl,
-    dynlib: pangolib, importc: "pango_font_find_shaper".}
-proc pango_font_get_metrics*(font: PPangoFont, language: PPangoLanguage): PPangoFontMetrics{.
-    cdecl, dynlib: pangolib, importc: "pango_font_get_metrics".}
-proc pango_font_get_glyph_extents*(font: PPangoFont, glyph: TPangoGlyph,
-                                   ink_rect: PPangoRectangle,
-                                   logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_font_get_glyph_extents".}
-proc PANGO_TYPE_FONT_MAP*(): GType
-proc PANGO_FONT_MAP*(anObject: pointer): PPangoFontMap
-proc PANGO_IS_FONT_MAP*(anObject: pointer): bool
-proc pango_font_map_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                        importc: "pango_font_map_get_type".}
-proc pango_font_map_load_font*(fontmap: PPangoFontMap, context: PPangoContext,
-                               desc: PPangoFontDescription): PPangoFont{.cdecl,
-    dynlib: pangolib, importc: "pango_font_map_load_font".}
-proc pango_font_map_load_fontset*(fontmap: PPangoFontMap,
-                                  context: PPangoContext,
-                                  desc: PPangoFontDescription,
-                                  language: PPangoLanguage): PPangoFontset{.
-    cdecl, dynlib: pangolib, importc: "pango_font_map_load_fontset".}
-proc pango_font_map_list_families*(fontmap: PPangoFontMap,
-                                   families: var openarray[ptr PPangoFontFamily]){.cdecl,
-    dynlib: pangolib, importc: "pango_font_map_list_families".}
-const
-  bm_TPangoGlyphVisAttr_is_cluster_start* = 0x00000001'i16
-  bp_TPangoGlyphVisAttr_is_cluster_start* = 0'i16
-
-proc is_cluster_start*(a: var TPangoGlyphVisAttr): guint
-proc set_is_cluster_start*(a: var TPangoGlyphVisAttr, `is_cluster_start`: guint)
-proc PANGO_TYPE_GLYPH_STRING*(): GType
-proc pango_glyph_string_new*(): PPangoGlyphString{.cdecl, dynlib: pangolib,
-    importc: "pango_glyph_string_new".}
-proc pango_glyph_string_set_size*(`string`: PPangoGlyphString, new_len: gint){.
-    cdecl, dynlib: pangolib, importc: "pango_glyph_string_set_size".}
-proc pango_glyph_string_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_glyph_string_get_type".}
-proc pango_glyph_string_copy*(`string`: PPangoGlyphString): PPangoGlyphString{.
-    cdecl, dynlib: pangolib, importc: "pango_glyph_string_copy".}
-proc pango_glyph_string_free*(`string`: PPangoGlyphString){.cdecl,
-    dynlib: pangolib, importc: "pango_glyph_string_free".}
-proc pango_glyph_string_extents*(glyphs: PPangoGlyphString, font: PPangoFont,
-                                 ink_rect: PPangoRectangle,
-                                 logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_glyph_string_extents".}
-proc pango_glyph_string_extents_range*(glyphs: PPangoGlyphString, start: int32,
-                                       theEnd: int32, font: PPangoFont,
-                                       ink_rect: PPangoRectangle,
-                                       logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_glyph_string_extents_range".}
-proc pango_glyph_string_get_logical_widths*(glyphs: PPangoGlyphString,
-    text: cstring, length: int32, embedding_level: int32,
-    logical_widths: var int32){.cdecl, dynlib: pangolib,
-                               importc: "pango_glyph_string_get_logical_widths".}
-proc pango_glyph_string_index_to_x*(glyphs: PPangoGlyphString, text: cstring,
-                                    length: int32, analysis: PPangoAnalysis,
-                                    index: int32, trailing: gboolean,
-                                    x_pos: var int32){.cdecl, dynlib: pangolib,
-    importc: "pango_glyph_string_index_to_x".}
-proc pango_glyph_string_x_to_index*(glyphs: PPangoGlyphString, text: cstring,
-                                    length: int32, analysis: PPangoAnalysis,
-                                    x_pos: int32, index,
-                                    trailing: var int32){.cdecl,
-    dynlib: pangolib, importc: "pango_glyph_string_x_to_index".}
-proc pango_shape*(text: cstring, length: gint, analysis: PPangoAnalysis,
-                  glyphs: PPangoGlyphString){.cdecl, dynlib: pangolib,
-    importc: "pango_shape".}
-proc pango_reorder_items*(logical_items: PGList): PGList{.cdecl,
-    dynlib: pangolib, importc: "pango_reorder_items".}
-proc pango_item_new*(): PPangoItem{.cdecl, dynlib: pangolib,
-                                    importc: "pango_item_new".}
-proc pango_item_copy*(item: PPangoItem): PPangoItem{.cdecl, dynlib: pangolib,
-    importc: "pango_item_copy".}
-proc pango_item_free*(item: PPangoItem){.cdecl, dynlib: pangolib,
-    importc: "pango_item_free".}
-proc pango_item_split*(orig: PPangoItem, split_index: int32, split_offset: int32): PPangoItem{.
-    cdecl, dynlib: pangolib, importc: "pango_item_split".}
-proc PANGO_TYPE_LAYOUT*(): GType
-proc PANGO_LAYOUT*(anObject: pointer): PPangoLayout
-proc PANGO_LAYOUT_CLASS*(klass: pointer): PPangoLayoutClass
-proc PANGO_IS_LAYOUT*(anObject: pointer): bool
-proc PANGO_IS_LAYOUT_CLASS*(klass: pointer): bool
-proc PANGO_LAYOUT_GET_CLASS*(obj: PPangoLayout): PPangoLayoutClass
-proc pango_layout_get_type*(): GType{.cdecl, dynlib: pangolib,
-                                      importc: "pango_layout_get_type".}
-proc pango_layout_new*(context: PPangoContext): PPangoLayout{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_new".}
-proc pango_layout_copy*(src: PPangoLayout): PPangoLayout{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_copy".}
-proc pango_layout_get_context*(layout: PPangoLayout): PPangoContext{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_context".}
-proc pango_layout_set_attributes*(layout: PPangoLayout, attrs: PPangoAttrList){.
-    cdecl, dynlib: pangolib, importc: "pango_layout_set_attributes".}
-proc pango_layout_get_attributes*(layout: PPangoLayout): PPangoAttrList{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_attributes".}
-proc pango_layout_set_text*(layout: PPangoLayout, text: cstring, length: int32){.
-    cdecl, dynlib: pangolib, importc: "pango_layout_set_text".}
-proc pango_layout_get_text*(layout: PPangoLayout): cstring{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_text".}
-proc pango_layout_set_markup*(layout: PPangoLayout, markup: cstring,
-                              length: int32){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_set_markup".}
-proc pango_layout_set_markup_with_accel*(layout: PPangoLayout, markup: cstring,
-    length: int32, accel_marker: gunichar, accel_char: Pgunichar){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_markup_with_accel".}
-proc pango_layout_set_font_description*(layout: PPangoLayout,
-                                        desc: PPangoFontDescription){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_font_description".}
-proc pango_layout_set_width*(layout: PPangoLayout, width: int32){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_width".}
-proc pango_layout_get_width*(layout: PPangoLayout): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_width".}
-proc pango_layout_set_wrap*(layout: PPangoLayout, wrap: TPangoWrapMode){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_wrap".}
-proc pango_layout_get_wrap*(layout: PPangoLayout): TPangoWrapMode{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_wrap".}
-proc pango_layout_set_indent*(layout: PPangoLayout, indent: int32){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_indent".}
-proc pango_layout_get_indent*(layout: PPangoLayout): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_indent".}
-proc pango_layout_set_spacing*(layout: PPangoLayout, spacing: int32){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_spacing".}
-proc pango_layout_get_spacing*(layout: PPangoLayout): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_spacing".}
-proc pango_layout_set_justify*(layout: PPangoLayout, justify: gboolean){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_justify".}
-proc pango_layout_get_justify*(layout: PPangoLayout): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_justify".}
-proc pango_layout_set_alignment*(layout: PPangoLayout,
-                                 alignment: TPangoAlignment){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_alignment".}
-proc pango_layout_get_alignment*(layout: PPangoLayout): TPangoAlignment{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_alignment".}
-proc pango_layout_set_tabs*(layout: PPangoLayout, tabs: PPangoTabArray){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_set_tabs".}
-proc pango_layout_get_tabs*(layout: PPangoLayout): PPangoTabArray{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_tabs".}
-proc pango_layout_set_single_paragraph_mode*(layout: PPangoLayout,
-    setting: gboolean){.cdecl, dynlib: pangolib,
-                        importc: "pango_layout_set_single_paragraph_mode".}
-proc pango_layout_get_single_paragraph_mode*(layout: PPangoLayout): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_layout_get_single_paragraph_mode".}
-proc pango_layout_context_changed*(layout: PPangoLayout){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_context_changed".}
-proc pango_layout_get_log_attrs*(layout: PPangoLayout, attrs: var PPangoLogAttr,
-                                 n_attrs: Pgint){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_get_log_attrs".}
-proc pango_layout_index_to_pos*(layout: PPangoLayout, index: int32,
-                                pos: PPangoRectangle){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_index_to_pos".}
-proc pango_layout_get_cursor_pos*(layout: PPangoLayout, index: int32,
-                                  strong_pos: PPangoRectangle,
-                                  weak_pos: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_cursor_pos".}
-proc pango_layout_move_cursor_visually*(layout: PPangoLayout, strong: gboolean,
-                                        old_index: int32, old_trailing: int32,
-                                        direction: int32, new_index,
-                                        new_trailing: var int32){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_move_cursor_visually".}
-proc pango_layout_xy_to_index*(layout: PPangoLayout, x: int32, y: int32,
-                               index, trailing: var int32): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_layout_xy_to_index".}
-proc pango_layout_get_extents*(layout: PPangoLayout, ink_rect: PPangoRectangle,
-                               logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_extents".}
-proc pango_layout_get_pixel_extents*(layout: PPangoLayout,
-                                     ink_rect: PPangoRectangle,
-                                     logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_pixel_extents".}
-proc pango_layout_get_size*(layout: PPangoLayout, width: var int32,
-                            height: var int32){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_get_size".}
-proc pango_layout_get_pixel_size*(layout: PPangoLayout, width: var int32,
-                                  height: var int32){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_get_pixel_size".}
-proc pango_layout_get_line_count*(layout: PPangoLayout): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_line_count".}
-proc pango_layout_get_line*(layout: PPangoLayout, line: int32): PPangoLayoutLine{.
-    cdecl, dynlib: pangolib, importc: "pango_layout_get_line".}
-proc pango_layout_get_lines*(layout: PPangoLayout): PGSList{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_lines".}
-proc pango_layout_line_ref*(line: PPangoLayoutLine){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_line_ref".}
-proc pango_layout_line_unref*(line: PPangoLayoutLine){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_line_unref".}
-proc pango_layout_line_x_to_index*(line: PPangoLayoutLine, x_pos: int32,
-                                   index: var int32, trailing: var int32): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_layout_line_x_to_index".}
-proc pango_layout_line_index_to_x*(line: PPangoLayoutLine, index: int32,
-                                   trailing: gboolean, x_pos: var int32){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_line_index_to_x".}
-proc pango_layout_line_get_extents*(line: PPangoLayoutLine,
-                                    ink_rect: PPangoRectangle,
-                                    logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_line_get_extents".}
-proc pango_layout_line_get_pixel_extents*(layout_line: PPangoLayoutLine,
-    ink_rect: PPangoRectangle, logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_line_get_pixel_extents".}
-proc pango_layout_get_iter*(layout: PPangoLayout): PPangoLayoutIter{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_get_iter".}
-proc pango_layout_iter_free*(iter: PPangoLayoutIter){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_iter_free".}
-proc pango_layout_iter_get_index*(iter: PPangoLayoutIter): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_index".}
-proc pango_layout_iter_get_run*(iter: PPangoLayoutIter): PPangoLayoutRun{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_run".}
-proc pango_layout_iter_get_line*(iter: PPangoLayoutIter): PPangoLayoutLine{.
-    cdecl, dynlib: pangolib, importc: "pango_layout_iter_get_line".}
-proc pango_layout_iter_at_last_line*(iter: PPangoLayoutIter): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_at_last_line".}
-proc pango_layout_iter_next_char*(iter: PPangoLayoutIter): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_next_char".}
-proc pango_layout_iter_next_cluster*(iter: PPangoLayoutIter): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_next_cluster".}
-proc pango_layout_iter_next_run*(iter: PPangoLayoutIter): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_next_run".}
-proc pango_layout_iter_next_line*(iter: PPangoLayoutIter): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_next_line".}
-proc pango_layout_iter_get_char_extents*(iter: PPangoLayoutIter,
-    logical_rect: PPangoRectangle){.cdecl, dynlib: pangolib, importc: "pango_layout_iter_get_char_extents".}
-proc pango_layout_iter_get_cluster_extents*(iter: PPangoLayoutIter,
-    ink_rect: PPangoRectangle, logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_cluster_extents".}
-proc pango_layout_iter_get_run_extents*(iter: PPangoLayoutIter,
-                                        ink_rect: PPangoRectangle,
-                                        logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_run_extents".}
-proc pango_layout_iter_get_line_extents*(iter: PPangoLayoutIter,
-    ink_rect: PPangoRectangle, logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_line_extents".}
-proc pango_layout_iter_get_line_yrange*(iter: PPangoLayoutIter, y0: var int32,
-                                        y1: var int32){.cdecl, dynlib: pangolib,
-    importc: "pango_layout_iter_get_line_yrange".}
-proc pango_layout_iter_get_layout_extents*(iter: PPangoLayoutIter,
-    ink_rect: PPangoRectangle, logical_rect: PPangoRectangle){.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_layout_extents".}
-proc pango_layout_iter_get_baseline*(iter: PPangoLayoutIter): int32{.cdecl,
-    dynlib: pangolib, importc: "pango_layout_iter_get_baseline".}
-proc PANGO_TYPE_TAB_ARRAY*(): GType
-proc pango_tab_array_new*(initial_size: gint, positions_in_pixels: gboolean): PPangoTabArray{.
-    cdecl, dynlib: pangolib, importc: "pango_tab_array_new".}
-proc pango_tab_array_get_type*(): GType{.cdecl, dynlib: pangolib,
-    importc: "pango_tab_array_get_type".}
-proc pango_tab_array_copy*(src: PPangoTabArray): PPangoTabArray{.cdecl,
-    dynlib: pangolib, importc: "pango_tab_array_copy".}
-proc pango_tab_array_free*(tab_array: PPangoTabArray){.cdecl, dynlib: pangolib,
-    importc: "pango_tab_array_free".}
-proc pango_tab_array_get_size*(tab_array: PPangoTabArray): gint{.cdecl,
-    dynlib: pangolib, importc: "pango_tab_array_get_size".}
-proc pango_tab_array_resize*(tab_array: PPangoTabArray, new_size: gint){.cdecl,
-    dynlib: pangolib, importc: "pango_tab_array_resize".}
-proc pango_tab_array_set_tab*(tab_array: PPangoTabArray, tab_index: gint,
-                              alignment: TPangoTabAlign, location: gint){.cdecl,
-    dynlib: pangolib, importc: "pango_tab_array_set_tab".}
-proc pango_tab_array_get_tab*(tab_array: PPangoTabArray, tab_index: gint,
-                              alignment: PPangoTabAlign, location: Pgint){.
-    cdecl, dynlib: pangolib, importc: "pango_tab_array_get_tab".}
-proc pango_tab_array_get_positions_in_pixels*(tab_array: PPangoTabArray): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_tab_array_get_positions_in_pixels".}
-proc PANGO_ASCENT*(rect: TPangoRectangle): int32 =
-  result = - int(rect.y)
-
-proc PANGO_DESCENT*(rect: TPangoRectangle): int32 =
-  result = int(rect.y) + int(rect.height)
-
-proc PANGO_LBEARING*(rect: TPangoRectangle): int32 =
-  result = rect.x
-
-proc PANGO_RBEARING*(rect: TPangoRectangle): int32 =
-  result = (rect.x) + (rect.width)
-
-proc PANGO_TYPE_LANGUAGE*(): GType =
-  result = pango_language_get_type()
-
-proc pango_language_to_string*(language: PPangoLanguage): cstring =
-  result = cast[cstring](language)
-
-proc PANGO_PIXELS*(d: int): int =
-  if d >= 0:
-    result = (d + (PANGO_SCALE div 2)) div PANGO_SCALE
-  else:
-    result = (d - (PANGO_SCALE div 2)) div PANGO_SCALE
-
-proc PANGO_TYPE_COLOR*(): GType =
-  result = pango_color_get_type()
-
-proc PANGO_TYPE_ATTR_LIST*(): GType =
-  result = pango_attr_list_get_type()
-
-proc is_line_break*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_line_break) shr
-      bp_TPangoLogAttr_is_line_break
-
-proc set_is_line_break*(a: var TPangoLogAttr, `is_line_break`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_line_break` shl bp_TPangoLogAttr_is_line_break) and
-      bm_TPangoLogAttr_is_line_break)
-
-proc is_mandatory_break*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_mandatory_break) shr
-      bp_TPangoLogAttr_is_mandatory_break
-
-proc set_is_mandatory_break*(a: var TPangoLogAttr, `is_mandatory_break`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_mandatory_break` shl bp_TPangoLogAttr_is_mandatory_break) and
-      bm_TPangoLogAttr_is_mandatory_break)
-
-proc is_char_break*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_char_break) shr
-      bp_TPangoLogAttr_is_char_break
-
-proc set_is_char_break*(a: var TPangoLogAttr, `is_char_break`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_char_break` shl bp_TPangoLogAttr_is_char_break) and
-      bm_TPangoLogAttr_is_char_break)
-
-proc is_white*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_white) shr
-      bp_TPangoLogAttr_is_white
-
-proc set_is_white*(a: var TPangoLogAttr, `is_white`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_white` shl bp_TPangoLogAttr_is_white) and
-      bm_TPangoLogAttr_is_white)
-
-proc is_cursor_position*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_cursor_position) shr
-      bp_TPangoLogAttr_is_cursor_position
-
-proc set_is_cursor_position*(a: var TPangoLogAttr, `is_cursor_position`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_cursor_position` shl bp_TPangoLogAttr_is_cursor_position) and
-      bm_TPangoLogAttr_is_cursor_position)
-
-proc is_word_start*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_word_start) shr
-      bp_TPangoLogAttr_is_word_start
-
-proc set_is_word_start*(a: var TPangoLogAttr, `is_word_start`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_word_start` shl bp_TPangoLogAttr_is_word_start) and
-      bm_TPangoLogAttr_is_word_start)
-
-proc is_word_end*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_word_end) shr
-      bp_TPangoLogAttr_is_word_end
-
-proc set_is_word_end*(a: var TPangoLogAttr, `is_word_end`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_word_end` shl bp_TPangoLogAttr_is_word_end) and
-      bm_TPangoLogAttr_is_word_end)
-
-proc is_sentence_boundary*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_boundary) shr
-      bp_TPangoLogAttr_is_sentence_boundary
-
-proc set_is_sentence_boundary*(a: var TPangoLogAttr,
-                               `is_sentence_boundary`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_boundary` shl bp_TPangoLogAttr_is_sentence_boundary) and
-      bm_TPangoLogAttr_is_sentence_boundary)
-
-proc is_sentence_start*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_start) shr
-      bp_TPangoLogAttr_is_sentence_start
-
-proc set_is_sentence_start*(a: var TPangoLogAttr, `is_sentence_start`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_start` shl bp_TPangoLogAttr_is_sentence_start) and
-      bm_TPangoLogAttr_is_sentence_start)
-
-proc is_sentence_end*(a: var TPangoLogAttr): guint =
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_end) shr
-      bp_TPangoLogAttr_is_sentence_end
-
-proc set_is_sentence_end*(a: var TPangoLogAttr, `is_sentence_end`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_end` shl bp_TPangoLogAttr_is_sentence_end) and
-      bm_TPangoLogAttr_is_sentence_end)
-
-proc PANGO_TYPE_CONTEXT*(): GType =
-  result = pango_context_get_type()
-
-proc PANGO_CONTEXT*(anObject: pointer): PPangoContext =
-  result = cast[PPangoContext](G_TYPE_CHECK_INSTANCE_CAST(anObject, PANGO_TYPE_CONTEXT()))
-
-proc PANGO_CONTEXT_CLASS*(klass: pointer): PPangoContextClass =
-  result = cast[PPangoContextClass](G_TYPE_CHECK_CLASS_CAST(klass, PANGO_TYPE_CONTEXT()))
-
-proc PANGO_IS_CONTEXT*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_CONTEXT())
-
-proc PANGO_IS_CONTEXT_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_CONTEXT())
-
-proc PANGO_CONTEXT_GET_CLASS*(obj: PPangoContext): PPangoContextClass =
-  result = cast[PPangoContextClass](G_TYPE_INSTANCE_GET_CLASS(obj, PANGO_TYPE_CONTEXT()))
-
-proc PANGO_TYPE_FONTSET*(): GType =
-  result = pango_fontset_get_type()
-
-proc PANGO_FONTSET*(anObject: pointer): PPangoFontset =
-  result = cast[PPangoFontset](G_TYPE_CHECK_INSTANCE_CAST(anObject, PANGO_TYPE_FONTSET()))
-
-proc PANGO_IS_FONTSET*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONTSET())
-
-proc PANGO_FONTSET_CLASS*(klass: pointer): PPangoFontsetClass =
-  result = cast[PPangoFontsetClass](G_TYPE_CHECK_CLASS_CAST(klass, PANGO_TYPE_FONTSET()))
-
-proc PANGO_IS_FONTSET_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_FONTSET())
-
-proc PANGO_FONTSET_GET_CLASS*(obj: PPangoFontset): PPangoFontsetClass =
-  result = cast[PPangoFontsetClass](G_TYPE_INSTANCE_GET_CLASS(obj, PANGO_TYPE_FONTSET()))
-
-proc pango_fontset_simple_get_type(): GType {.importc, cdecl, dynlib: pangolib.}
-
-proc PANGO_TYPE_FONTSET_SIMPLE*(): GType =
-  result = pango_fontset_simple_get_type()
-
-proc PANGO_FONTSET_SIMPLE*(anObject: pointer): PPangoFontsetSimple =
-  result = cast[PPangoFontsetSimple](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      PANGO_TYPE_FONTSET_SIMPLE()))
-
-proc PANGO_IS_FONTSET_SIMPLE*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONTSET_SIMPLE())
-
-proc PANGO_TYPE_FONT_DESCRIPTION*(): GType =
-  result = pango_font_description_get_type()
-
-proc PANGO_TYPE_FONT_METRICS*(): GType =
-  result = pango_font_metrics_get_type()
-
-proc PANGO_TYPE_FONT_FAMILY*(): GType =
-  result = pango_font_family_get_type()
-
-proc PANGO_FONT_FAMILY*(anObject: pointer): PPangoFontFamily =
-  result = cast[PPangoFontFamily](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      PANGO_TYPE_FONT_FAMILY()))
-
-proc PANGO_IS_FONT_FAMILY*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONT_FAMILY())
-
-proc PANGO_FONT_FAMILY_CLASS*(klass: Pointer): PPangoFontFamilyClass =
-  result = cast[PPangoFontFamilyClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      PANGO_TYPE_FONT_FAMILY()))
-
-proc PANGO_IS_FONT_FAMILY_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_FONT_FAMILY())
-
-proc PANGO_FONT_FAMILY_GET_CLASS*(obj: PPangoFontFamily): PPangoFontFamilyClass =
-  result = cast[PPangoFontFamilyClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      PANGO_TYPE_FONT_FAMILY()))
-
-proc PANGO_TYPE_FONT_FACE*(): GType =
-  result = pango_font_face_get_type()
-
-proc PANGO_FONT_FACE*(anObject: Pointer): PPangoFontFace =
-  result = cast[PPangoFontFace](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      PANGO_TYPE_FONT_FACE()))
-
-proc PANGO_IS_FONT_FACE*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONT_FACE())
-
-proc PANGO_FONT_FACE_CLASS*(klass: Pointer): PPangoFontFaceClass =
-  result = cast[PPangoFontFaceClass](G_TYPE_CHECK_CLASS_CAST(klass,
-      PANGO_TYPE_FONT_FACE()))
-
-proc PANGO_IS_FONT_FACE_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_FONT_FACE())
-
-proc PANGO_FONT_FACE_GET_CLASS*(obj: Pointer): PPangoFontFaceClass =
-  result = cast[PPangoFontFaceClass](G_TYPE_INSTANCE_GET_CLASS(obj,
-      PANGO_TYPE_FONT_FACE()))
-
-proc PANGO_TYPE_FONT*(): GType =
-  result = pango_font_get_type()
-
-proc PANGO_FONT*(anObject: Pointer): PPangoFont =
-  result = cast[PPangoFont](G_TYPE_CHECK_INSTANCE_CAST(anObject, PANGO_TYPE_FONT()))
-
-proc PANGO_IS_FONT*(anObject: Pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONT())
-
-proc PANGO_FONT_CLASS*(klass: Pointer): PPangoFontClass =
-  result = cast[PPangoFontClass](G_TYPE_CHECK_CLASS_CAST(klass, PANGO_TYPE_FONT()))
-
-proc PANGO_IS_FONT_CLASS*(klass: Pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_FONT())
-
-proc PANGO_FONT_GET_CLASS*(obj: PPangoFont): PPangoFontClass =
-  result = cast[PPangoFontClass](G_TYPE_INSTANCE_GET_CLASS(obj, PANGO_TYPE_FONT()))
-
-proc PANGO_TYPE_FONT_MAP*(): GType =
-  result = pango_font_map_get_type()
-
-proc PANGO_FONT_MAP*(anObject: pointer): PPangoFontmap =
-  result = cast[PPangoFontmap](G_TYPE_CHECK_INSTANCE_CAST(anObject,
-      PANGO_TYPE_FONT_MAP()))
-
-proc PANGO_IS_FONT_MAP*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_FONT_MAP())
-
-proc PANGO_FONT_MAP_CLASS*(klass: pointer): PPangoFontMapClass =
-  result = cast[PPangoFontMapClass](G_TYPE_CHECK_CLASS_CAST(klass, PANGO_TYPE_FONT_MAP()))
-
-proc PANGO_IS_FONT_MAP_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_FONT_MAP())
-
-proc PANGO_FONT_MAP_GET_CLASS*(obj: PPangoFontMap): PPangoFontMapClass =
-  result = cast[PPangoFontMapClass](G_TYPE_INSTANCE_GET_CLASS(obj, PANGO_TYPE_FONT_MAP()))
-
-proc is_cluster_start*(a: var TPangoGlyphVisAttr): guint =
-  result = (a.flag0 and bm_TPangoGlyphVisAttr_is_cluster_start) shr
-      bp_TPangoGlyphVisAttr_is_cluster_start
-
-proc set_is_cluster_start*(a: var TPangoGlyphVisAttr, `is_cluster_start`: guint) =
-  a.flag0 = a.flag0 or
-      (int16(`is_cluster_start` shl bp_TPangoGlyphVisAttr_is_cluster_start) and
-      bm_TPangoGlyphVisAttr_is_cluster_start)
-
-proc PANGO_TYPE_GLYPH_STRING*(): GType =
-  result = pango_glyph_string_get_type()
-
-proc PANGO_TYPE_LAYOUT*(): GType =
-  result = pango_layout_get_type()
-
-proc PANGO_LAYOUT*(anObject: pointer): PPangoLayout =
-  result = cast[PPangoLayout](G_TYPE_CHECK_INSTANCE_CAST(anObject, PANGO_TYPE_LAYOUT()))
-
-proc PANGO_LAYOUT_CLASS*(klass: pointer): PPangoLayoutClass =
-  result = cast[PPangoLayoutClass](G_TYPE_CHECK_CLASS_CAST(klass, PANGO_TYPE_LAYOUT()))
-
-proc PANGO_IS_LAYOUT*(anObject: pointer): bool =
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, PANGO_TYPE_LAYOUT())
-
-proc PANGO_IS_LAYOUT_CLASS*(klass: pointer): bool =
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, PANGO_TYPE_LAYOUT())
-
-proc PANGO_LAYOUT_GET_CLASS*(obj: PPangoLayout): PPangoLayoutClass =
-  result = cast[PPangoLayoutClass](G_TYPE_INSTANCE_GET_CLASS(obj, PANGO_TYPE_LAYOUT()))
-
-proc PANGO_TYPE_TAB_ARRAY*(): GType =
-  result = pango_tab_array_get_type()
diff --git a/lib/oldwrappers/gtk/pangoutils.nim b/lib/oldwrappers/gtk/pangoutils.nim
deleted file mode 100755
index e6f3ab94c..000000000
--- a/lib/oldwrappers/gtk/pangoutils.nim
+++ /dev/null
@@ -1,46 +0,0 @@
-{.deadCodeElim: on.}
-
-import
-  glib2, pango
-
-type
-  pint32* = ptr int32
-
-proc pango_split_file_list*(str: cstring): PPchar{.cdecl, dynlib: pangolib,
-    importc: "pango_split_file_list".}
-proc pango_trim_string*(str: cstring): cstring{.cdecl, dynlib: pangolib,
-    importc: "pango_trim_string".}
-proc pango_read_line*(stream: TFile, str: PGString): gint{.cdecl,
-    dynlib: pangolib, importc: "pango_read_line".}
-proc pango_skip_space*(pos: PPchar): gboolean{.cdecl, dynlib: pangolib,
-    importc: "pango_skip_space".}
-proc pango_scan_word*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_scan_word".}
-proc pango_scan_string*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_scan_string".}
-proc pango_scan_int*(pos: PPchar, OutInt: pint32): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_scan_int".}
-proc pango_config_key_get(key: cstring): cstring{.cdecl, dynlib: pangolib,
-    importc: "pango_config_key_get".}
-proc pango_lookup_aliases(fontname: cstring, families: PPPchar,
-                          n_families: pint32){.cdecl, dynlib: pangolib,
-    importc: "pango_lookup_aliases".}
-proc pango_parse_style*(str: cstring, style: PPangoStyle, warn: gboolean): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_parse_style".}
-proc pango_parse_variant*(str: cstring, variant: PPangoVariant, warn: gboolean): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_parse_variant".}
-proc pango_parse_weight*(str: cstring, weight: PPangoWeight, warn: gboolean): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_parse_weight".}
-proc pango_parse_stretch*(str: cstring, stretch: PPangoStretch, warn: gboolean): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_parse_stretch".}
-proc pango_get_sysconf_subdirectory(): cstring{.cdecl, dynlib: pangolib,
-    importc: "pango_get_sysconf_subdirectory".}
-proc pango_get_lib_subdirectory(): cstring{.cdecl, dynlib: pangolib,
-    importc: "pango_get_lib_subdirectory".}
-proc pango_log2vis_get_embedding_levels*(str: Pgunichar, len: int32,
-    pbase_dir: PPangoDirection, embedding_level_list: Pguint8): gboolean{.cdecl,
-    dynlib: pangolib, importc: "pango_log2vis_get_embedding_levels".}
-proc pango_get_mirror_char*(ch: gunichar, mirrored_ch: Pgunichar): gboolean{.
-    cdecl, dynlib: pangolib, importc: "pango_get_mirror_char".}
-proc pango_language_get_sample_string*(language: PPangoLanguage): cstring{.
-    cdecl, dynlib: pangolib, importc: "pango_language_get_sample_string".}
diff --git a/lib/oldwrappers/iup.nim b/lib/oldwrappers/iup.nim
deleted file mode 100755
index c37d31047..000000000
--- a/lib/oldwrappers/iup.nim
+++ /dev/null
@@ -1,945 +0,0 @@
-#
-#    Binding for the IUP GUI toolkit
-#       (c) 2010 Andreas Rumpf 
-#    C header files translated by hand
-#    Licence of IUP follows:
-
-
-# ****************************************************************************
-# Copyright (C) 1994-2009 Tecgraf, PUC-Rio.
-# 
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-# ****************************************************************************
-
-{.deadCodeElim: on.}
-
-when defined(windows): 
-  const dllname = "iup(30|27|26|25|24).dll"
-elif defined(macosx):
-  const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).dylib"
-else: 
-  const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).so.1"
-
-const
-  IUP_NAME* = "IUP - Portable User Interface"
-  IUP_COPYRIGHT* = "Copyright (C) 1994-2009 Tecgraf, PUC-Rio."
-  IUP_DESCRIPTION* = "Portable toolkit for building graphical user interfaces."
-  constIUP_VERSION* = "3.0"
-  constIUP_VERSION_NUMBER* = 300000
-  constIUP_VERSION_DATE* = "2009/07/18"
-
-type
-  Ihandle {.pure.} = object
-  PIhandle* = ptr Ihandle
-
-  Icallback* = proc (arg: PIhandle): cint {.cdecl.}
-
-#                      pre-definided dialogs
-proc FileDlg*: PIhandle {.importc: "IupFileDlg", dynlib: dllname, cdecl.}
-proc MessageDlg*: PIhandle {.importc: "IupMessageDlg", dynlib: dllname, cdecl.}
-proc ColorDlg*: PIhandle {.importc: "IupColorDlg", dynlib: dllname, cdecl.}
-proc FontDlg*: PIhandle {.importc: "IupFontDlg", dynlib: dllname, cdecl.}
-
-proc GetFile*(arq: cstring): cint {.
-  importc: "IupGetFile", dynlib: dllname, cdecl.}
-proc Message*(title, msg: cstring) {.
-  importc: "IupMessage", dynlib: dllname, cdecl.}
-proc Messagef*(title, format: cstring) {.
-  importc: "IupMessagef", dynlib: dllname, cdecl, varargs.}
-proc Alarm*(title, msg, b1, b2, b3: cstring): cint {.
-  importc: "IupAlarm", dynlib: dllname, cdecl.}
-proc Scanf*(format: cstring): cint {.
-  importc: "IupScanf", dynlib: dllname, cdecl, varargs.}
-proc ListDialog*(theType: cint, title: cstring, size: cint, 
-                 list: cstringArray, op, max_col, max_lin: cint, 
-                 marks: ptr cint): cint {.
-                 importc: "IupListDialog", dynlib: dllname, cdecl.}
-proc GetText*(title, text: cstring): cint {.
-  importc: "IupGetText", dynlib: dllname, cdecl.}
-proc GetColor*(x, y: cint, r, g, b: var byte): cint {.
-  importc: "IupGetColor", dynlib: dllname, cdecl.}
-
-type
-  Iparamcb* = proc (dialog: PIhandle, param_index: cint, 
-                    user_data: pointer): cint {.cdecl.}
-
-proc GetParam*(title: cstring, action: Iparamcb, user_data: pointer, 
-               format: cstring): cint {.
-               importc: "IupGetParam", cdecl, varargs, dynlib: dllname.}
-proc GetParamv*(title: cstring, action: Iparamcb, user_data: pointer, 
-                format: cstring, param_count, param_extra: cint, 
-                param_data: pointer): cint {.
-                importc: "IupGetParamv", cdecl, dynlib: dllname.}
-
-
-#                      Functions
-
-proc Open*(argc: ptr cint, argv: ptr cstringArray): cint {.
-  importc: "IupOpen", cdecl, dynlib: dllname.}
-proc Close*() {.importc: "IupClose", cdecl, dynlib: dllname.}
-proc ImageLibOpen*() {.importc: "IupImageLibOpen", cdecl, dynlib: dllname.}
-
-proc MainLoop*(): cint {.importc: "IupMainLoop", cdecl, dynlib: dllname.}
-proc LoopStep*(): cint {.importc: "IupLoopStep", cdecl, dynlib: dllname.}
-proc MainLoopLevel*(): cint {.importc: "IupMainLoopLevel", cdecl, dynlib: dllname.}
-proc Flush*() {.importc: "IupFlush", cdecl, dynlib: dllname.}
-proc ExitLoop*() {.importc: "IupExitLoop", cdecl, dynlib: dllname.}
-
-proc Update*(ih: PIhandle) {.importc: "IupUpdate", cdecl, dynlib: dllname.}
-proc UpdateChildren*(ih: PIhandle) {.importc: "IupUpdateChildren", cdecl, dynlib: dllname.}
-proc Redraw*(ih: PIhandle, children: cint) {.importc: "IupRedraw", cdecl, dynlib: dllname.}
-proc Refresh*(ih: PIhandle) {.importc: "IupRefresh", cdecl, dynlib: dllname.}
-
-proc MapFont*(iupfont: cstring): cstring {.importc: "IupMapFont", cdecl, dynlib: dllname.}
-proc UnMapFont*(driverfont: cstring): cstring {.importc: "IupUnMapFont", cdecl, dynlib: dllname.}
-proc Help*(url: cstring): cint {.importc: "IupHelp", cdecl, dynlib: dllname.}
-proc Load*(filename: cstring): cstring {.importc: "IupLoad", cdecl, dynlib: dllname.}
-
-proc IupVersion*(): cstring {.importc: "IupVersion", cdecl, dynlib: dllname.}
-proc IupVersionDate*(): cstring {.importc: "IupVersionDate", cdecl, dynlib: dllname.}
-proc IupVersionNumber*(): cint {.importc: "IupVersionNumber", cdecl, dynlib: dllname.}
-proc SetLanguage*(lng: cstring) {.importc: "IupSetLanguage", cdecl, dynlib: dllname.}
-proc GetLanguage*(): cstring {.importc: "IupGetLanguage", cdecl, dynlib: dllname.}
-
-proc Destroy*(ih: PIhandle) {.importc: "IupDestroy", cdecl, dynlib: dllname.}
-proc Detach*(child: PIhandle) {.importc: "IupDetach", cdecl, dynlib: dllname.}
-proc Append*(ih, child: PIhandle): PIhandle {.
-  importc: "IupAppend", cdecl, dynlib: dllname.}
-proc Insert*(ih, ref_child, child: PIhandle): PIhandle {.
-  importc: "IupInsert", cdecl, dynlib: dllname.}
-proc GetChild*(ih: PIhandle, pos: cint): PIhandle {.
-  importc: "IupGetChild", cdecl, dynlib: dllname.}
-proc GetChildPos*(ih, child: PIhandle): cint {.
-  importc: "IupGetChildPos", cdecl, dynlib: dllname.}
-proc GetChildCount*(ih: PIhandle): cint {.
-  importc: "IupGetChildCount", cdecl, dynlib: dllname.}
-proc GetNextChild*(ih, child: PIhandle): PIhandle {.
-  importc: "IupGetNextChild", cdecl, dynlib: dllname.}
-proc GetBrother*(ih: PIhandle): PIhandle {.
-  importc: "IupGetBrother", cdecl, dynlib: dllname.}
-proc GetParent*(ih: PIhandle): PIhandle {.
-  importc: "IupGetParent", cdecl, dynlib: dllname.}
-proc GetDialog*(ih: PIhandle): PIhandle {.
-  importc: "IupGetDialog", cdecl, dynlib: dllname.}
-proc GetDialogChild*(ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupGetDialogChild", cdecl, dynlib: dllname.}
-proc Reparent*(ih, new_parent: PIhandle): cint {.
-  importc: "IupReparent", cdecl, dynlib: dllname.}
-
-proc Popup*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupPopup", cdecl, dynlib: dllname.}
-proc Show*(ih: PIhandle): cint {.
-  importc: "IupShow", cdecl, dynlib: dllname.}
-proc ShowXY*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupShowXY", cdecl, dynlib: dllname.}
-proc Hide*(ih: PIhandle): cint {.
-  importc: "IupHide", cdecl, dynlib: dllname.}
-proc Map*(ih: PIhandle): cint {.
-  importc: "IupMap", cdecl, dynlib: dllname.}
-proc Unmap*(ih: PIhandle) {.
-  importc: "IupUnmap", cdecl, dynlib: dllname.}
-
-proc SetAttribute*(ih: PIhandle, name, value: cstring) {.
-  importc: "IupSetAttribute", cdecl, dynlib: dllname.}
-proc StoreAttribute*(ih: PIhandle, name, value: cstring) {.
-  importc: "IupStoreAttribute", cdecl, dynlib: dllname.}
-proc SetAttributes*(ih: PIhandle, str: cstring): PIhandle {.
-  importc: "IupSetAttributes", cdecl, dynlib: dllname.}
-proc GetAttribute*(ih: PIhandle, name: cstring): cstring {.
-  importc: "IupGetAttribute", cdecl, dynlib: dllname.}
-proc GetAttributes*(ih: PIhandle): cstring {.
-  importc: "IupGetAttributes", cdecl, dynlib: dllname.}
-proc GetInt*(ih: PIhandle, name: cstring): cint {.
-  importc: "IupGetInt", cdecl, dynlib: dllname.}
-proc GetInt2*(ih: PIhandle, name: cstring): cint {.
-  importc: "IupGetInt2", cdecl, dynlib: dllname.}
-proc GetIntInt*(ih: PIhandle, name: cstring, i1, i2: var cint): cint {.
-  importc: "IupGetIntInt", cdecl, dynlib: dllname.}
-proc GetFloat*(ih: PIhandle, name: cstring): cfloat {.
-  importc: "IupGetFloat", cdecl, dynlib: dllname.}
-proc SetfAttribute*(ih: PIhandle, name, format: cstring) {.
-  importc: "IupSetfAttribute", cdecl, dynlib: dllname, varargs.}
-proc GetAllAttributes*(ih: PIhandle, names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllAttributes", cdecl, dynlib: dllname.}
-proc SetAtt*(handle_name: cstring, ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupSetAtt", cdecl, dynlib: dllname, varargs.}
-
-proc SetGlobal*(name, value: cstring) {.
-  importc: "IupSetGlobal", cdecl, dynlib: dllname.}
-proc StoreGlobal*(name, value: cstring) {.
-  importc: "IupStoreGlobal", cdecl, dynlib: dllname.}
-proc GetGlobal*(name: cstring): cstring {.
-  importc: "IupGetGlobal", cdecl, dynlib: dllname.}
-
-proc SetFocus*(ih: PIhandle): PIhandle {.
-  importc: "IupSetFocus", cdecl, dynlib: dllname.}
-proc GetFocus*(): PIhandle {.
-  importc: "IupGetFocus", cdecl, dynlib: dllname.}
-proc PreviousField*(ih: PIhandle): PIhandle {.
-  importc: "IupPreviousField", cdecl, dynlib: dllname.}
-proc NextField*(ih: PIhandle): PIhandle {.
-  importc: "IupNextField", cdecl, dynlib: dllname.}
-
-proc GetCallback*(ih: PIhandle, name: cstring): Icallback {.
-  importc: "IupGetCallback", cdecl, dynlib: dllname.}
-proc SetCallback*(ih: PIhandle, name: cstring, func: Icallback): Icallback {.
-  importc: "IupSetCallback", cdecl, dynlib: dllname.}
-proc SetCallbacks*(ih: PIhandle, name: cstring, func: Icallback): PIhandle {.
-  importc: "IupSetCallbacks", cdecl, dynlib: dllname, varargs.}
-
-proc GetFunction*(name: cstring): Icallback {.
-  importc: "IupGetFunction", cdecl, dynlib: dllname.}
-proc SetFunction*(name: cstring, func: Icallback): Icallback {.
-  importc: "IupSetFunction", cdecl, dynlib: dllname.}
-proc GetActionName*(): cstring {.
-  importc: "IupGetActionName", cdecl, dynlib: dllname.}
-
-proc GetHandle*(name: cstring): PIhandle {.
-  importc: "IupGetHandle", cdecl, dynlib: dllname.}
-proc SetHandle*(name: cstring, ih: PIhandle): PIhandle {.
-  importc: "IupSetHandle", cdecl, dynlib: dllname.}
-proc GetAllNames*(names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllNames", cdecl, dynlib: dllname.}
-proc GetAllDialogs*(names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllDialogs", cdecl, dynlib: dllname.}
-proc GetName*(ih: PIhandle): cstring {.
-  importc: "IupGetName", cdecl, dynlib: dllname.}
-
-proc SetAttributeHandle*(ih: PIhandle, name: cstring, ih_named: PIhandle) {.
-  importc: "IupSetAttributeHandle", cdecl, dynlib: dllname.}
-proc GetAttributeHandle*(ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupGetAttributeHandle", cdecl, dynlib: dllname.}
-
-proc GetClassName*(ih: PIhandle): cstring {.
-  importc: "IupGetClassName", cdecl, dynlib: dllname.}
-proc GetClassType*(ih: PIhandle): cstring {.
-  importc: "IupGetClassType", cdecl, dynlib: dllname.}
-proc GetClassAttributes*(classname: cstring, names: cstringArray, 
-                         n: cint): cint {.
-  importc: "IupGetClassAttributes", cdecl, dynlib: dllname.}
-proc SaveClassAttributes*(ih: PIhandle) {.
-  importc: "IupSaveClassAttributes", cdecl, dynlib: dllname.}
-proc SetClassDefaultAttribute*(classname, name, value: cstring) {.
-  importc: "IupSetClassDefaultAttribute", cdecl, dynlib: dllname.}
-
-proc Create*(classname: cstring): PIhandle {.
-  importc: "IupCreate", cdecl, dynlib: dllname.}
-proc Createv*(classname: cstring, params: pointer): PIhandle {.
-  importc: "IupCreatev", cdecl, dynlib: dllname.}
-proc Createp*(classname: cstring, first: pointer): PIhandle {.
-  importc: "IupCreatep", cdecl, dynlib: dllname, varargs.}
-
-proc Fill*(): PIhandle {.importc: "IupFill", cdecl, dynlib: dllname.}
-proc Radio*(child: PIhandle): PIhandle {.
-  importc: "IupRadio", cdecl, dynlib: dllname.}
-proc Vbox*(child: PIhandle): PIhandle {.
-  importc: "IupVbox", cdecl, dynlib: dllname, varargs.}
-proc Vboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupVboxv", cdecl, dynlib: dllname.}
-proc Zbox*(child: PIhandle): PIhandle {.
-  importc: "IupZbox", cdecl, dynlib: dllname, varargs.}
-proc Zboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupZboxv", cdecl, dynlib: dllname.}
-proc Hbox*(child: PIhandle): PIhandle {.
-  importc: "IupHbox", cdecl, dynlib: dllname, varargs.}
-proc Hboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupHboxv", cdecl, dynlib: dllname.}
-
-proc Normalizer*(ih_first: PIhandle): PIhandle {.
-  importc: "IupNormalizer", cdecl, dynlib: dllname, varargs.}
-proc Normalizerv*(ih_list: ptr PIhandle): PIhandle {.
-  importc: "IupNormalizerv", cdecl, dynlib: dllname.}
-
-proc Cbox*(child: PIhandle): PIhandle {.
-  importc: "IupCbox", cdecl, dynlib: dllname, varargs.}
-proc Cboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupCboxv", cdecl, dynlib: dllname.}
-proc Sbox*(child: PIhandle): PIhandle {.
-  importc: "IupSbox", cdecl, dynlib: dllname.}
-
-proc Frame*(child: PIhandle): PIhandle {.
-  importc: "IupFrame", cdecl, dynlib: dllname.}
-
-proc Image*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImage", cdecl, dynlib: dllname.}
-proc ImageRGB*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImageRGB", cdecl, dynlib: dllname.}
-proc ImageRGBA*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImageRGBA", cdecl, dynlib: dllname.}
-
-proc Item*(title, action: cstring): PIhandle {.
-  importc: "IupItem", cdecl, dynlib: dllname.}
-proc Submenu*(title: cstring, child: PIhandle): PIhandle {.
-  importc: "IupSubmenu", cdecl, dynlib: dllname.}
-proc Separator*(): PIhandle {.
-  importc: "IupSeparator", cdecl, dynlib: dllname.}
-proc Menu*(child: PIhandle): PIhandle {.
-  importc: "IupMenu", cdecl, dynlib: dllname, varargs.}
-proc Menuv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupMenuv", cdecl, dynlib: dllname.}
-
-proc Button*(title, action: cstring): PIhandle {.
-  importc: "IupButton", cdecl, dynlib: dllname.}
-proc Canvas*(action: cstring): PIhandle {.
-  importc: "IupCanvas", cdecl, dynlib: dllname.}
-proc Dialog*(child: PIhandle): PIhandle {.
-  importc: "IupDialog", cdecl, dynlib: dllname.}
-proc User*(): PIhandle {.
-  importc: "IupUser", cdecl, dynlib: dllname.}
-proc Label*(title: cstring): PIhandle {.
-  importc: "IupLabel", cdecl, dynlib: dllname.}
-proc List*(action: cstring): PIhandle {.
-  importc: "IupList", cdecl, dynlib: dllname.}
-proc Text*(action: cstring): PIhandle {.
-  importc: "IupText", cdecl, dynlib: dllname.}
-proc MultiLine*(action: cstring): PIhandle {.
-  importc: "IupMultiLine", cdecl, dynlib: dllname.}
-proc Toggle*(title, action: cstring): PIhandle {.
-  importc: "IupToggle", cdecl, dynlib: dllname.}
-proc Timer*(): PIhandle {.
-  importc: "IupTimer", cdecl, dynlib: dllname.}
-proc ProgressBar*(): PIhandle {.
-  importc: "IupProgressBar", cdecl, dynlib: dllname.}
-proc Val*(theType: cstring): PIhandle {.
-  importc: "IupVal", cdecl, dynlib: dllname.}
-proc Tabs*(child: PIhandle): PIhandle {.
-  importc: "IupTabs", cdecl, dynlib: dllname, varargs.}
-proc Tabsv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupTabsv", cdecl, dynlib: dllname.}
-proc Tree*(): PIhandle {.importc: "IupTree", cdecl, dynlib: dllname.}
-
-proc Spin*(): PIhandle {.importc: "IupSpin", cdecl, dynlib: dllname.}
-proc Spinbox*(child: PIhandle): PIhandle {.
-  importc: "IupSpinbox", cdecl, dynlib: dllname.}
-
-# IupText utilities
-proc TextConvertLinColToPos*(ih: PIhandle, lin, col: cint, pos: var cint) {.
-  importc: "IupTextConvertLinColToPos", cdecl, dynlib: dllname.}
-proc TextConvertPosToLinCol*(ih: PIhandle, pos: cint, lin, col: var cint) {.
-  importc: "IupTextConvertPosToLinCol", cdecl, dynlib: dllname.}
-
-proc ConvertXYToPos*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupConvertXYToPos", cdecl, dynlib: dllname.}
-
-# IupTree utilities
-proc TreeSetUserId*(ih: PIhandle, id: cint, userid: pointer): cint {.
-  importc: "IupTreeSetUserId", cdecl, dynlib: dllname.}
-proc TreeGetUserId*(ih: PIhandle, id: cint): pointer {.
-  importc: "IupTreeGetUserId", cdecl, dynlib: dllname.}
-proc TreeGetId*(ih: PIhandle, userid: pointer): cint {.
-  importc: "IupTreeGetId", cdecl, dynlib: dllname.}
-
-proc TreeSetAttribute*(ih: PIhandle, name: cstring, id: cint, value: cstring) {.
-  importc: "IupTreeSetAttribute", cdecl, dynlib: dllname.}
-proc TreeStoreAttribute*(ih: PIhandle, name: cstring, id: cint, value: cstring) {.
-  importc: "IupTreeStoreAttribute", cdecl, dynlib: dllname.}
-proc TreeGetAttribute*(ih: PIhandle, name: cstring, id: cint): cstring {.
-  importc: "IupTreeGetAttribute", cdecl, dynlib: dllname.}
-proc TreeGetInt*(ih: PIhandle, name: cstring, id: cint): cint {.
-  importc: "IupTreeGetInt", cdecl, dynlib: dllname.}
-proc TreeGetFloat*(ih: PIhandle, name: cstring, id: cint): cfloat {.
-  importc: "IupTreeGetFloat", cdecl, dynlib: dllname.}
-proc TreeSetfAttribute*(ih: PIhandle, name: cstring, id: cint, format: cstring) {.
-  importc: "IupTreeSetfAttribute", cdecl, dynlib: dllname, varargs.}
-
-
-#                   Common Return Values
-const
-  IUP_ERROR* = cint(1)
-  IUP_NOERROR* = cint(0)
-  IUP_OPENED* = cint(-1)
-  IUP_INVALID* = cint(-1)
-
-  # Callback Return Values
-  IUP_IGNORE* = cint(-1)
-  IUP_DEFAULT* = cint(-2)
-  IUP_CLOSE* = cint(-3)
-  IUP_CONTINUE* = cint(-4)
-
-  # IupPopup and IupShowXY Parameter Values
-  IUP_CENTER* = cint(0xFFFF) 
-  IUP_LEFT* = cint(0xFFFE) 
-  IUP_RIGHT* = cint(0xFFFD) 
-  IUP_MOUSEPOS* = cint(0xFFFC) 
-  IUP_CURRENT* = cint(0xFFFB) 
-  IUP_CENTERPARENT* = cint(0xFFFA) 
-  IUP_TOP* = IUP_LEFT
-  IUP_BOTTOM* = IUP_RIGHT
-
-  # SHOW_CB Callback Values
-  IUP_SHOW* = cint(0)
-  IUP_RESTORE* = cint(1)
-  IUP_MINIMIZE* = cint(2)
-  IUP_MAXIMIZE* = cint(3)
-  IUP_HIDE* = cint(4)
-
-  # SCROLL_CB Callback Values
-  IUP_SBUP* = cint(0)
-  IUP_SBDN* = cint(1)
-  IUP_SBPGUP* = cint(2)   
-  IUP_SBPGDN* = cint(3)
-  IUP_SBPOSV* = cint(4)
-  IUP_SBDRAGV* = cint(5) 
-  IUP_SBLEFT* = cint(6)
-  IUP_SBRIGHT* = cint(7)
-  IUP_SBPGLEFT* = cint(8)
-  IUP_SBPGRIGHT* = cint(9)
-  IUP_SBPOSH* = cint(10)
-  IUP_SBDRAGH* = cint(11)
-
-  # Mouse Button Values and Macros
-  IUP_BUTTON1* = cint(ord('1'))
-  IUP_BUTTON2* = cint(ord('2'))
-  IUP_BUTTON3* = cint(ord('3'))
-  IUP_BUTTON4* = cint(ord('4'))
-  IUP_BUTTON5* = cint(ord('5'))
-
-proc isShift*(s: cstring): bool = return s[0] == 'S'
-proc isControl*(s: cstring): bool = return s[1] == 'C'
-proc isButton1*(s: cstring): bool = return s[2] == '1'
-proc isButton2*(s: cstring): bool = return s[3] == '2'
-proc isbutton3*(s: cstring): bool = return s[4] == '3'
-proc isDouble*(s: cstring): bool = return s[5] == 'D'
-proc isAlt*(s: cstring): bool = return s[6] == 'A'
-proc isSys*(s: cstring): bool = return s[7] == 'Y'
-proc isButton4*(s: cstring): bool = return s[8] == '4'
-proc isButton5*(s: cstring): bool = return s[9] == '5'
-
-# Pre-Defined Masks
-const
-  IUP_MASK_FLOAT* = "[+/-]?(/d+/.?/d*|/./d+)"
-  IUP_MASK_UFLOAT* = "(/d+/.?/d*|/./d+)"
-  IUP_MASK_EFLOAT* = "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
-  IUP_MASK_INT* = "[+/-]?/d+"
-  IUP_MASK_UINT* = "/d+"
-  
-# from 32 to 126, all character sets are equal,

-# the key code i the same as the character code.

-const

-  K_SP* = cint(ord(' '))

-  K_exclam* = cint(ord('!'))   

-  K_quotedbl* = cint(ord('\"'))

-  K_numbersign* = cint(ord('#'))

-  K_dollar* = cint(ord('$'))

-  K_percent* = cint(ord('%'))

-  K_ampersand* = cint(ord('&'))

-  K_apostrophe* = cint(ord('\''))

-  K_parentleft* = cint(ord('('))

-  K_parentright* = cint(ord(')'))

-  K_asterisk* = cint(ord('*'))

-  K_plus* = cint(ord('+'))

-  K_comma* = cint(ord(','))

-  K_minus* = cint(ord('-'))

-  K_period* = cint(ord('.'))

-  K_slash* = cint(ord('/'))

-  K_0* = cint(ord('0'))

-  K_1* = cint(ord('1'))

-  K_2* = cint(ord('2'))

-  K_3* = cint(ord('3'))

-  K_4* = cint(ord('4'))

-  K_5* = cint(ord('5'))

-  K_6* = cint(ord('6'))

-  K_7* = cint(ord('7'))

-  K_8* = cint(ord('8'))

-  K_9* = cint(ord('9'))

-  K_colon* = cint(ord(':'))

-  K_semicolon* = cint(ord(';'))

-  K_less* = cint(ord('<'))

-  K_equal* = cint(ord('='))

-  K_greater* = cint(ord('>'))   

-  K_question* = cint(ord('?'))   

-  K_at* = cint(ord('@'))   

-  K_upperA* = cint(ord('A'))   

-  K_upperB* = cint(ord('B'))   

-  K_upperC* = cint(ord('C'))   

-  K_upperD* = cint(ord('D'))   

-  K_upperE* = cint(ord('E'))   

-  K_upperF* = cint(ord('F'))   

-  K_upperG* = cint(ord('G'))   

-  K_upperH* = cint(ord('H'))   

-  K_upperI* = cint(ord('I'))   

-  K_upperJ* = cint(ord('J'))   

-  K_upperK* = cint(ord('K'))   

-  K_upperL* = cint(ord('L'))   

-  K_upperM* = cint(ord('M'))   

-  K_upperN* = cint(ord('N'))   

-  K_upperO* = cint(ord('O'))   

-  K_upperP* = cint(ord('P'))   

-  K_upperQ* = cint(ord('Q'))  

-  K_upperR* = cint(ord('R'))  

-  K_upperS* = cint(ord('S'))  

-  K_upperT* = cint(ord('T'))  

-  K_upperU* = cint(ord('U'))  

-  K_upperV* = cint(ord('V')) 

-  K_upperW* = cint(ord('W')) 

-  K_upperX* = cint(ord('X'))  

-  K_upperY* = cint(ord('Y'))  

-  K_upperZ* = cint(ord('Z'))  

-  K_bracketleft* = cint(ord('[')) 

-  K_backslash* = cint(ord('\\'))  

-  K_bracketright* = cint(ord(']'))  

-  K_circum* = cint(ord('^'))   

-  K_underscore* = cint(ord('_'))   

-  K_grave* = cint(ord('`'))   

-  K_lowera* = cint(ord('a'))  

-  K_lowerb* = cint(ord('b'))   

-  K_lowerc* = cint(ord('c')) 

-  K_lowerd* = cint(ord('d'))   

-  K_lowere* = cint(ord('e'))   

-  K_lowerf* = cint(ord('f'))  

-  K_lowerg* = cint(ord('g'))

-  K_lowerh* = cint(ord('h')) 

-  K_loweri* = cint(ord('i')) 

-  K_lowerj* = cint(ord('j')) 

-  K_lowerk* = cint(ord('k'))

-  K_lowerl* = cint(ord('l'))

-  K_lowerm* = cint(ord('m'))

-  K_lowern* = cint(ord('n'))

-  K_lowero* = cint(ord('o'))

-  K_lowerp* = cint(ord('p'))

-  K_lowerq* = cint(ord('q'))

-  K_lowerr* = cint(ord('r'))

-  K_lowers* = cint(ord('s'))

-  K_lowert* = cint(ord('t'))

-  K_loweru* = cint(ord('u'))

-  K_lowerv* = cint(ord('v'))

-  K_lowerw* = cint(ord('w'))

-  K_lowerx* = cint(ord('x'))

-  K_lowery* = cint(ord('y'))

-  K_lowerz* = cint(ord('z'))

-  K_braceleft* = cint(ord('{'))

-  K_bar* = cint(ord('|'))

-  K_braceright* = cint(ord('}'))

-  K_tilde* = cint(ord('~'))

-

-proc isPrint*(c: cint): bool = return c > 31 and c < 127

-

-# also define the escape sequences that have keys associated

-const

-  K_BS* = cint(ord('\b'))

-  K_TAB* = cint(ord('\t'))

-  K_LF* = cint(10)

-  K_CR* = cint(13)

-

-# IUP Extended Key Codes, range start at 128

-# Modifiers use 256 interval

-# These key code definitions are specific to IUP

-

-proc isXkey*(c: cint): bool = return c > 128

-proc isShiftXkey*(c: cint): bool = return c > 256 and c < 512

-proc isCtrlXkey*(c: cint): bool = return c > 512 and c < 768

-proc isAltXkey*(c: cint): bool = return c > 768 and c < 1024

-proc isSysXkey*(c: cint): bool = return c > 1024 and c < 1280

-

-proc IUPxCODE*(c: cint): cint = return c + cint(128) # Normal (must be above 128)

-proc IUPsxCODE*(c: cint): cint = 
-  return c + cint(256)
-  # Shift (must have range to include the standard keys and the normal 
-  # extended keys, so must be above 256
-
-proc IUPcxCODE*(c: cint): cint = return c + cint(512) # Ctrl

-proc IUPmxCODE*(c: cint): cint = return c + cint(768) # Alt

-proc IUPyxCODE*(c: cint): cint = return c + cint(1024) # Sys (Win or Apple) 

-
-const

-  IUP_NUMMAXCODES* = 1280 ## 5*256=1280  Normal+Shift+Ctrl+Alt+Sys

-

-  K_HOME* = IUPxCODE(1)                

-  K_UP* = IUPxCODE(2)

-  K_PGUP* = IUPxCODE(3)

-  K_LEFT* = IUPxCODE(4)

-  K_MIDDLE* = IUPxCODE(5)

-  K_RIGHT* = IUPxCODE(6)

-  K_END* = IUPxCODE(7)

-  K_DOWN* = IUPxCODE(8)

-  K_PGDN* = IUPxCODE(9)

-  K_INS* = IUPxCODE(10)    

-  K_DEL* = IUPxCODE(11)    

-  K_PAUSE* = IUPxCODE(12)

-  K_ESC* = IUPxCODE(13)

-  K_ccedilla* = IUPxCODE(14)

-  K_F1* = IUPxCODE(15)

-  K_F2* = IUPxCODE(16)

-  K_F3* = IUPxCODE(17)

-  K_F4* = IUPxCODE(18)

-  K_F5* = IUPxCODE(19)

-  K_F6* = IUPxCODE(20)

-  K_F7* = IUPxCODE(21)

-  K_F8* = IUPxCODE(22)

-  K_F9* = IUPxCODE(23)

-  K_F10* = IUPxCODE(24)

-  K_F11* = IUPxCODE(25)

-  K_F12* = IUPxCODE(26)

-  K_Print* = IUPxCODE(27)

-  K_Menu* = IUPxCODE(28)

-

-  K_acute* = IUPxCODE(29) # no Shift/Ctrl/Alt

-

-  K_sHOME* = IUPsxCODE(K_HOME)

-  K_sUP* = IUPsxCODE(K_UP)

-  K_sPGUP* = IUPsxCODE(K_PGUP)

-  K_sLEFT* = IUPsxCODE(K_LEFT)

-  K_sMIDDLE* = IUPsxCODE(K_MIDDLE)

-  K_sRIGHT* = IUPsxCODE(K_RIGHT)

-  K_sEND* = IUPsxCODE(K_END)

-  K_sDOWN* = IUPsxCODE(K_DOWN)

-  K_sPGDN* = IUPsxCODE(K_PGDN)

-  K_sINS* = IUPsxCODE(K_INS)

-  K_sDEL* = IUPsxCODE(K_DEL)

-  K_sSP* = IUPsxCODE(K_SP)

-  K_sTAB* = IUPsxCODE(K_TAB)

-  K_sCR* = IUPsxCODE(K_CR)

-  K_sBS* = IUPsxCODE(K_BS)

-  K_sPAUSE* = IUPsxCODE(K_PAUSE)

-  K_sESC* = IUPsxCODE(K_ESC)

-  K_sCcedilla* = IUPsxCODE(K_ccedilla)

-  K_sF1* = IUPsxCODE(K_F1)

-  K_sF2* = IUPsxCODE(K_F2)

-  K_sF3* = IUPsxCODE(K_F3)

-  K_sF4* = IUPsxCODE(K_F4)

-  K_sF5* = IUPsxCODE(K_F5)

-  K_sF6* = IUPsxCODE(K_F6)

-  K_sF7* = IUPsxCODE(K_F7)

-  K_sF8* = IUPsxCODE(K_F8)

-  K_sF9* = IUPsxCODE(K_F9)

-  K_sF10* = IUPsxCODE(K_F10)

-  K_sF11* = IUPsxCODE(K_F11)

-  K_sF12* = IUPsxCODE(K_F12)

-  K_sPrint* = IUPsxCODE(K_Print)

-  K_sMenu* = IUPsxCODE(K_Menu)

-

-  K_cHOME* = IUPcxCODE(K_HOME)

-  K_cUP* = IUPcxCODE(K_UP)

-  K_cPGUP* = IUPcxCODE(K_PGUP)

-  K_cLEFT* = IUPcxCODE(K_LEFT)

-  K_cMIDDLE* = IUPcxCODE(K_MIDDLE)

-  K_cRIGHT* = IUPcxCODE(K_RIGHT)

-  K_cEND* = IUPcxCODE(K_END)

-  K_cDOWN* = IUPcxCODE(K_DOWN)

-  K_cPGDN* = IUPcxCODE(K_PGDN)

-  K_cINS* = IUPcxCODE(K_INS)

-  K_cDEL* = IUPcxCODE(K_DEL)

-  K_cSP* = IUPcxCODE(K_SP)

-  K_cTAB* = IUPcxCODE(K_TAB)

-  K_cCR* = IUPcxCODE(K_CR)

-  K_cBS* = IUPcxCODE(K_BS)

-  K_cPAUSE* = IUPcxCODE(K_PAUSE)

-  K_cESC* = IUPcxCODE(K_ESC)

-  K_cCcedilla* = IUPcxCODE(K_ccedilla)

-  K_cF1* = IUPcxCODE(K_F1)

-  K_cF2* = IUPcxCODE(K_F2)

-  K_cF3* = IUPcxCODE(K_F3)

-  K_cF4* = IUPcxCODE(K_F4)

-  K_cF5* = IUPcxCODE(K_F5)

-  K_cF6* = IUPcxCODE(K_F6)

-  K_cF7* = IUPcxCODE(K_F7)

-  K_cF8* = IUPcxCODE(K_F8)

-  K_cF9* = IUPcxCODE(K_F9)

-  K_cF10* = IUPcxCODE(K_F10)

-  K_cF11* = IUPcxCODE(K_F11)

-  K_cF12* = IUPcxCODE(K_F12)

-  K_cPrint* = IUPcxCODE(K_Print)

-  K_cMenu* = IUPcxCODE(K_Menu)

-

-  K_mHOME* = IUPmxCODE(K_HOME)

-  K_mUP* = IUPmxCODE(K_UP)

-  K_mPGUP* = IUPmxCODE(K_PGUP)

-  K_mLEFT* = IUPmxCODE(K_LEFT)

-  K_mMIDDLE* = IUPmxCODE(K_MIDDLE)

-  K_mRIGHT* = IUPmxCODE(K_RIGHT)

-  K_mEND* = IUPmxCODE(K_END)

-  K_mDOWN* = IUPmxCODE(K_DOWN)

-  K_mPGDN* = IUPmxCODE(K_PGDN)

-  K_mINS* = IUPmxCODE(K_INS)

-  K_mDEL* = IUPmxCODE(K_DEL)

-  K_mSP* = IUPmxCODE(K_SP)

-  K_mTAB* = IUPmxCODE(K_TAB)

-  K_mCR* = IUPmxCODE(K_CR)

-  K_mBS* = IUPmxCODE(K_BS)

-  K_mPAUSE* = IUPmxCODE(K_PAUSE)

-  K_mESC* = IUPmxCODE(K_ESC)

-  K_mCcedilla* = IUPmxCODE(K_ccedilla)

-  K_mF1* = IUPmxCODE(K_F1)

-  K_mF2* = IUPmxCODE(K_F2)

-  K_mF3* = IUPmxCODE(K_F3)

-  K_mF4* = IUPmxCODE(K_F4)

-  K_mF5* = IUPmxCODE(K_F5)

-  K_mF6* = IUPmxCODE(K_F6)

-  K_mF7* = IUPmxCODE(K_F7)

-  K_mF8* = IUPmxCODE(K_F8)

-  K_mF9* = IUPmxCODE(K_F9)

-  K_mF10* = IUPmxCODE(K_F10)

-  K_mF11* = IUPmxCODE(K_F11)

-  K_mF12* = IUPmxCODE(K_F12)

-  K_mPrint* = IUPmxCODE(K_Print)

-  K_mMenu* = IUPmxCODE(K_Menu)

-

-  K_yHOME* = IUPyxCODE(K_HOME)

-  K_yUP* = IUPyxCODE(K_UP)

-  K_yPGUP* = IUPyxCODE(K_PGUP)

-  K_yLEFT* = IUPyxCODE(K_LEFT)

-  K_yMIDDLE* = IUPyxCODE(K_MIDDLE)

-  K_yRIGHT* = IUPyxCODE(K_RIGHT)

-  K_yEND* = IUPyxCODE(K_END)

-  K_yDOWN* = IUPyxCODE(K_DOWN)

-  K_yPGDN* = IUPyxCODE(K_PGDN)

-  K_yINS* = IUPyxCODE(K_INS)

-  K_yDEL* = IUPyxCODE(K_DEL)

-  K_ySP* = IUPyxCODE(K_SP)

-  K_yTAB* = IUPyxCODE(K_TAB)

-  K_yCR* = IUPyxCODE(K_CR)

-  K_yBS* = IUPyxCODE(K_BS)

-  K_yPAUSE* = IUPyxCODE(K_PAUSE)

-  K_yESC* = IUPyxCODE(K_ESC)

-  K_yCcedilla* = IUPyxCODE(K_ccedilla)

-  K_yF1* = IUPyxCODE(K_F1)

-  K_yF2* = IUPyxCODE(K_F2)

-  K_yF3* = IUPyxCODE(K_F3)

-  K_yF4* = IUPyxCODE(K_F4)

-  K_yF5* = IUPyxCODE(K_F5)

-  K_yF6* = IUPyxCODE(K_F6)

-  K_yF7* = IUPyxCODE(K_F7)

-  K_yF8* = IUPyxCODE(K_F8)

-  K_yF9* = IUPyxCODE(K_F9)

-  K_yF10* = IUPyxCODE(K_F10)

-  K_yF11* = IUPyxCODE(K_F11)

-  K_yF12* = IUPyxCODE(K_F12)

-  K_yPrint* = IUPyxCODE(K_Print)

-  K_yMenu* = IUPyxCODE(K_Menu)

-

-  K_sPlus* = IUPsxCODE(K_plus)   

-  K_sComma* = IUPsxCODE(K_comma)   

-  K_sMinus* = IUPsxCODE(K_minus)   

-  K_sPeriod* = IUPsxCODE(K_period)   

-  K_sSlash* = IUPsxCODE(K_slash)   

-  K_sAsterisk* = IUPsxCODE(K_asterisk)

-                        

-  K_cupperA* = IUPcxCODE(K_upperA)

-  K_cupperB* = IUPcxCODE(K_upperB)

-  K_cupperC* = IUPcxCODE(K_upperC)

-  K_cupperD* = IUPcxCODE(K_upperD)

-  K_cupperE* = IUPcxCODE(K_upperE)

-  K_cupperF* = IUPcxCODE(K_upperF)

-  K_cupperG* = IUPcxCODE(K_upperG)

-  K_cupperH* = IUPcxCODE(K_upperH)

-  K_cupperI* = IUPcxCODE(K_upperI)

-  K_cupperJ* = IUPcxCODE(K_upperJ)

-  K_cupperK* = IUPcxCODE(K_upperK)

-  K_cupperL* = IUPcxCODE(K_upperL)

-  K_cupperM* = IUPcxCODE(K_upperM)

-  K_cupperN* = IUPcxCODE(K_upperN)

-  K_cupperO* = IUPcxCODE(K_upperO)

-  K_cupperP* = IUPcxCODE(K_upperP)

-  K_cupperQ* = IUPcxCODE(K_upperQ)

-  K_cupperR* = IUPcxCODE(K_upperR)

-  K_cupperS* = IUPcxCODE(K_upperS)

-  K_cupperT* = IUPcxCODE(K_upperT)

-  K_cupperU* = IUPcxCODE(K_upperU)

-  K_cupperV* = IUPcxCODE(K_upperV)

-  K_cupperW* = IUPcxCODE(K_upperW)

-  K_cupperX* = IUPcxCODE(K_upperX)

-  K_cupperY* = IUPcxCODE(K_upperY)

-  K_cupperZ* = IUPcxCODE(K_upperZ)

-  K_c1* = IUPcxCODE(K_1)

-  K_c2* = IUPcxCODE(K_2)

-  K_c3* = IUPcxCODE(K_3)

-  K_c4* = IUPcxCODE(K_4)

-  K_c5* = IUPcxCODE(K_5)

-  K_c6* = IUPcxCODE(K_6)

-  K_c7* = IUPcxCODE(K_7)        

-  K_c8* = IUPcxCODE(K_8)         

-  K_c9* = IUPcxCODE(K_9)

-  K_c0* = IUPcxCODE(K_0)

-  K_cPlus* = IUPcxCODE(K_plus)   

-  K_cComma* = IUPcxCODE(K_comma)   

-  K_cMinus* = IUPcxCODE(K_minus)   

-  K_cPeriod* = IUPcxCODE(K_period)   

-  K_cSlash* = IUPcxCODE(K_slash)   

-  K_cSemicolon* = IUPcxCODE(K_semicolon) 

-  K_cEqual* = IUPcxCODE(K_equal)

-  K_cBracketleft* = IUPcxCODE(K_bracketleft)

-  K_cBracketright* = IUPcxCODE(K_bracketright)

-  K_cBackslash* = IUPcxCODE(K_backslash)

-  K_cAsterisk* = IUPcxCODE(K_asterisk)

-

-  K_mupperA* = IUPmxCODE(K_upperA)

-  K_mupperB* = IUPmxCODE(K_upperB)

-  K_mupperC* = IUPmxCODE(K_upperC)

-  K_mupperD* = IUPmxCODE(K_upperD)

-  K_mupperE* = IUPmxCODE(K_upperE)

-  K_mupperF* = IUPmxCODE(K_upperF)

-  K_mupperG* = IUPmxCODE(K_upperG)

-  K_mupperH* = IUPmxCODE(K_upperH)

-  K_mupperI* = IUPmxCODE(K_upperI)

-  K_mupperJ* = IUPmxCODE(K_upperJ)

-  K_mupperK* = IUPmxCODE(K_upperK)

-  K_mupperL* = IUPmxCODE(K_upperL)

-  K_mupperM* = IUPmxCODE(K_upperM)

-  K_mupperN* = IUPmxCODE(K_upperN)

-  K_mupperO* = IUPmxCODE(K_upperO)

-  K_mupperP* = IUPmxCODE(K_upperP)

-  K_mupperQ* = IUPmxCODE(K_upperQ)

-  K_mupperR* = IUPmxCODE(K_upperR)

-  K_mupperS* = IUPmxCODE(K_upperS)

-  K_mupperT* = IUPmxCODE(K_upperT)

-  K_mupperU* = IUPmxCODE(K_upperU)

-  K_mupperV* = IUPmxCODE(K_upperV)

-  K_mupperW* = IUPmxCODE(K_upperW)

-  K_mupperX* = IUPmxCODE(K_upperX)

-  K_mupperY* = IUPmxCODE(K_upperY)

-  K_mupperZ* = IUPmxCODE(K_upperZ)

-  K_m1* = IUPmxCODE(K_1)

-  K_m2* = IUPmxCODE(K_2)

-  K_m3* = IUPmxCODE(K_3)

-  K_m4* = IUPmxCODE(K_4)

-  K_m5* = IUPmxCODE(K_5)

-  K_m6* = IUPmxCODE(K_6)

-  K_m7* = IUPmxCODE(K_7)        

-  K_m8* = IUPmxCODE(K_8)         

-  K_m9* = IUPmxCODE(K_9)

-  K_m0* = IUPmxCODE(K_0)

-  K_mPlus* = IUPmxCODE(K_plus)   

-  K_mComma* = IUPmxCODE(K_comma)   

-  K_mMinus* = IUPmxCODE(K_minus)   

-  K_mPeriod* = IUPmxCODE(K_period)   

-  K_mSlash* = IUPmxCODE(K_slash)   

-  K_mSemicolon* = IUPmxCODE(K_semicolon) 

-  K_mEqual* = IUPmxCODE(K_equal)

-  K_mBracketleft* = IUPmxCODE(K_bracketleft)

-  K_mBracketright* = IUPmxCODE(K_bracketright)

-  K_mBackslash* = IUPmxCODE(K_backslash)

-  K_mAsterisk* = IUPmxCODE(K_asterisk)

-

-  K_yA* = IUPyxCODE(K_upperA)

-  K_yB* = IUPyxCODE(K_upperB)

-  K_yC* = IUPyxCODE(K_upperC)

-  K_yD* = IUPyxCODE(K_upperD)

-  K_yE* = IUPyxCODE(K_upperE)

-  K_yF* = IUPyxCODE(K_upperF)

-  K_yG* = IUPyxCODE(K_upperG)

-  K_yH* = IUPyxCODE(K_upperH)

-  K_yI* = IUPyxCODE(K_upperI)

-  K_yJ* = IUPyxCODE(K_upperJ)

-  K_yK* = IUPyxCODE(K_upperK)

-  K_yL* = IUPyxCODE(K_upperL)

-  K_yM* = IUPyxCODE(K_upperM)

-  K_yN* = IUPyxCODE(K_upperN)

-  K_yO* = IUPyxCODE(K_upperO)

-  K_yP* = IUPyxCODE(K_upperP)

-  K_yQ* = IUPyxCODE(K_upperQ)

-  K_yR* = IUPyxCODE(K_upperR)

-  K_yS* = IUPyxCODE(K_upperS)

-  K_yT* = IUPyxCODE(K_upperT)

-  K_yU* = IUPyxCODE(K_upperU)

-  K_yV* = IUPyxCODE(K_upperV)

-  K_yW* = IUPyxCODE(K_upperW)

-  K_yX* = IUPyxCODE(K_upperX)

-  K_yY* = IUPyxCODE(K_upperY)

-  K_yZ* = IUPyxCODE(K_upperZ)

-  K_y1* = IUPyxCODE(K_1)

-  K_y2* = IUPyxCODE(K_2)

-  K_y3* = IUPyxCODE(K_3)

-  K_y4* = IUPyxCODE(K_4)

-  K_y5* = IUPyxCODE(K_5)

-  K_y6* = IUPyxCODE(K_6)

-  K_y7* = IUPyxCODE(K_7)        

-  K_y8* = IUPyxCODE(K_8)         

-  K_y9* = IUPyxCODE(K_9)

-  K_y0* = IUPyxCODE(K_0)

-  K_yPlus* = IUPyxCODE(K_plus)

-  K_yComma* = IUPyxCODE(K_comma)

-  K_yMinus* = IUPyxCODE(K_minus)   

-  K_yPeriod* = IUPyxCODE(K_period)   

-  K_ySlash* = IUPyxCODE(K_slash)   

-  K_ySemicolon* = IUPyxCODE(K_semicolon) 

-  K_yEqual* = IUPyxCODE(K_equal)

-  K_yBracketleft* = IUPyxCODE(K_bracketleft)

-  K_yBracketright* = IUPyxCODE(K_bracketright)

-  K_yBackslash* = IUPyxCODE(K_backslash)

-  K_yAsterisk* = IUPyxCODE(K_asterisk)

-
-proc ControlsOpen*(): cint {.cdecl, importc: "IupControlsOpen", dynlib: dllname.}

-proc ControlsClose*() {.cdecl, importc: "IupControlsClose", dynlib: dllname.}

-

-proc OldValOpen*() {.cdecl, importc: "IupOldValOpen", dynlib: dllname.}

-proc OldTabsOpen*() {.cdecl, importc: "IupOldTabsOpen", dynlib: dllname.}

-

-proc Colorbar*(): PIhandle {.cdecl, importc: "IupColorbar", dynlib: dllname.}

-proc Cells*(): PIhandle {.cdecl, importc: "IupCells", dynlib: dllname.}

-proc ColorBrowser*(): PIhandle {.cdecl, importc: "IupColorBrowser", dynlib: dllname.}

-proc Gauge*(): PIhandle {.cdecl, importc: "IupGauge", dynlib: dllname.}

-proc Dial*(theType: cstring): PIhandle {.cdecl, importc: "IupDial", dynlib: dllname.}

-proc Matrix*(action: cstring): PIhandle {.cdecl, importc: "IupMatrix", dynlib: dllname.}

-

-# IupMatrix utilities

-proc MatSetAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                      value: cstring) {.
-                      cdecl, importc: "IupMatSetAttribute", dynlib: dllname.}

-proc MatStoreAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                        value: cstring) {.cdecl, 
-                        importc: "IupMatStoreAttribute", dynlib: dllname.}

-proc MatGetAttribute*(ih: PIhandle, name: cstring, lin, col: cint): cstring {.
-  cdecl, importc: "IupMatGetAttribute", dynlib: dllname.}

-proc MatGetInt*(ih: PIhandle, name: cstring, lin, col: cint): cint {.
-  cdecl, importc: "IupMatGetInt", dynlib: dllname.}

-proc MatGetFloat*(ih: PIhandle, name: cstring, lin, col: cint): cfloat {.
-  cdecl, importc: "IupMatGetFloat", dynlib: dllname.}

-proc MatSetfAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                       format: cstring) {.cdecl, 
-                       importc: "IupMatSetfAttribute", 
-                       dynlib: dllname, varargs.}

-

-# Used by IupColorbar

-const
-  IUP_PRIMARY* = -1

-  IUP_SECONDARY* = -2

-

-# Initialize PPlot widget class

-proc PPlotOpen*() {.cdecl, importc: "IupPPlotOpen", dynlib: dllname.}

-

-# Create an PPlot widget instance

-proc PPlot*: PIhandle {.cdecl, importc: "IupPPlot", dynlib: dllname.}

-

-# Add dataset to plot

-proc PPlotBegin*(ih: PIhandle, strXdata: cint) {.
-  cdecl, importc: "IupPPlotBegin", dynlib: dllname.}

-proc PPlotAdd*(ih: PIhandle, x, y: cfloat) {.
-  cdecl, importc: "IupPPlotAdd", dynlib: dllname.}

-proc PPlotAddStr*(ih: PIhandle, x: cstring, y: cfloat) {.
-  cdecl, importc: "IupPPlotAddStr", dynlib: dllname.}

-proc PPlotEnd*(ih: PIhandle): cint {.
-  cdecl, importc: "IupPPlotEnd", dynlib: dllname.}

-

-proc PPlotInsertStr*(ih: PIhandle, index, sample_index: cint, x: cstring, 
-                     y: cfloat) {.cdecl, importc: "IupPPlotInsertStr", 
-                     dynlib: dllname.}

-proc PPlotInsert*(ih: PIhandle, index, sample_index: cint, 
-                  x, y: cfloat) {.
-                  cdecl, importc: "IupPPlotInsert", dynlib: dllname.}

-

-# convert from plot coordinates to pixels

-proc PPlotTransform*(ih: PIhandle, x, y: cfloat, ix, iy: var cint) {.
-  cdecl, importc: "IupPPlotTransform", dynlib: dllname.}

-

-# Plot on the given device. Uses a "cdCanvas*".

-proc PPlotPaintTo*(ih: PIhandle, cnv: pointer) {.
-  cdecl, importc: "IupPPlotPaintTo", dynlib: dllname.}

-

-
diff --git a/lib/oldwrappers/libcurl.nim b/lib/oldwrappers/libcurl.nim
deleted file mode 100755
index 9cb352fb7..000000000
--- a/lib/oldwrappers/libcurl.nim
+++ /dev/null
@@ -1,644 +0,0 @@
-#
-#    $Id: header,v 1.1 2000/07/13 06:33:45 michael Exp $
-#    This file is part of the Free Pascal packages
-#    Copyright (c) 1999-2000 by the Free Pascal development team
-#
-#    See the file COPYING.FPC, included in this distribution,
-#    for details about the copyright.
-#
-#    This program 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.
-#
-# **********************************************************************
-#
-#   the curl library is governed by its own copyright, see the curl
-#   website for this. 
-# 
-
-{.deadCodeElim: on.}
-
-import times
-
-when defined(windows):
-  const libname = "libcurl.dll"
-elif defined(macosx):
-  const libname = "libcurl-7.19.3.dylib"
-elif defined(unix):
-  const libname = "libcurl.so.4"
-
-type 
-  Pcurl_calloc_callback* = ptr Tcurl_calloc_callback
-  Pcurl_closepolicy* = ptr Tcurl_closepolicy
-  Pcurl_forms* = ptr Tcurl_forms
-  Pcurl_ftpauth* = ptr Tcurl_ftpauth
-  Pcurl_ftpmethod* = ptr Tcurl_ftpmethod
-  Pcurl_ftpssl* = ptr Tcurl_ftpssl
-  PCURL_HTTP_VERSION* = ptr TCURL_HTTP_VERSION
-  Pcurl_httppost* = ptr Tcurl_httppost
-  PPcurl_httppost* = ptr Pcurl_httppost
-  Pcurl_infotype* = ptr Tcurl_infotype
-  Pcurl_lock_access* = ptr Tcurl_lock_access
-  Pcurl_lock_data* = ptr Tcurl_lock_data
-  Pcurl_malloc_callback* = ptr tcurl_malloc_callback
-  PCURL_NETRC_OPTION* = ptr TCURL_NETRC_OPTION
-  Pcurl_proxytype* = ptr Tcurl_proxytype
-  Pcurl_realloc_callback* = ptr tcurl_realloc_callback
-  Pcurl_slist* = ptr Tcurl_slist
-  Pcurl_socket* = ptr Tcurl_socket
-  PCURL_SSL_VERSION* = ptr TCURL_SSL_VERSION
-  Pcurl_strdup_callback* = ptr Tcurl_strdup_callback
-  PCURL_TIMECOND* = ptr TCURL_TIMECOND
-  Pcurl_version_info_data* = ptr Tcurl_version_info_data
-  PCURLcode* = ptr TCURLcode
-  PCURLFORMcode* = ptr TCURLFORMcode
-  PCURLformoption* = ptr TCURLformoption
-  PCURLINFO* = ptr TCURLINFO
-  Pcurliocmd* = ptr Tcurliocmd
-  Pcurlioerr* = ptr Tcurlioerr
-  PCURLM* = ptr TCURLM
-  PCURLMcode* = ptr TCURLMcode
-  PCURLMoption* = ptr TCURLMoption
-  PCURLMSG* = ptr TCURLMSG
-  PCURLoption* = ptr TCURLoption
-  PCURLSH* = ptr TCURLSH
-  PCURLSHcode* = ptr TCURLSHcode
-  PCURLSHoption* = ptr TCURLSHoption
-  PCURLversion* = ptr TCURLversion
-  Pfd_set* = pointer
-  PCURL* = ptr TCurl
-  TCurl* = pointer
-  Tcurl_httppost* {.final, pure.} = object 
-    next*: Pcurl_httppost
-    name*: cstring
-    namelength*: int32
-    contents*: cstring
-    contentslength*: int32
-    buffer*: cstring
-    bufferlength*: int32
-    contenttype*: cstring
-    contentheader*: Pcurl_slist
-    more*: Pcurl_httppost
-    flags*: int32
-    showfilename*: cstring
-
-  Tcurl_progress_callback* = proc (clientp: pointer, dltotal: float64, 
-                                   dlnow: float64, ultotal: float64, 
-                                   ulnow: float64): int32{.cdecl.}
-  Tcurl_write_callback* = proc (buffer: cstring, size: int, nitems: int, 
-                                outstream: pointer): int{.cdecl.}
-  Tcurl_read_callback* = proc (buffer: cstring, size: int, nitems: int, 
-                               instream: pointer): int{.cdecl.}
-  Tcurl_passwd_callback* = proc (clientp: pointer, prompt: cstring, 
-                                 buffer: cstring, buflen: int32): int32{.cdecl.}
-  Tcurlioerr* = enum 
-    CURLIOE_OK, CURLIOE_UNKNOWNCMD, CURLIOE_FAILRESTART, CURLIOE_LAST
-  Tcurliocmd* = enum 
-    CURLIOCMD_NOP, CURLIOCMD_RESTARTREAD, CURLIOCMD_LAST
-  Tcurl_ioctl_callback* = proc (handle: PCURL, cmd: int32, 
-                                clientp: pointer): Tcurlioerr {.cdecl.}
-  Tcurl_malloc_callback* = proc (size: int): pointer {.cdecl.}
-  Tcurl_free_callback* = proc (p: pointer) {.cdecl.}
-  Tcurl_realloc_callback* = proc (p: pointer, size: int): pointer {.cdecl.}
-  Tcurl_strdup_callback* = proc (str: cstring): cstring {.cdecl.}
-  Tcurl_calloc_callback* = proc (nmemb: int, size: int): pointer
-  Tcurl_infotype* = enum 
-    CURLINFO_TEXT = 0, CURLINFO_HEADER_IN, CURLINFO_HEADER_OUT, 
-    CURLINFO_DATA_IN, CURLINFO_DATA_OUT, CURLINFO_SSL_DATA_IN, 
-    CURLINFO_SSL_DATA_OUT, CURLINFO_END
-  Tcurl_debug_callback* = proc (handle: PCURL, theType: Tcurl_infotype, 
-                                data: cstring, size: int, 
-                                userptr: pointer): int32 {.cdecl.}
-  TCURLcode* = enum 
-    CURLE_OK = 0, CURLE_UNSUPPORTED_PROTOCOL, CURLE_FAILED_INIT, 
-    CURLE_URL_MALFORMAT, CURLE_URL_MALFORMAT_USER, CURLE_COULDNT_RESOLVE_PROXY, 
-    CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, 
-    CURLE_FTP_WEIRD_SERVER_REPLY, CURLE_FTP_ACCESS_DENIED, 
-    CURLE_FTP_USER_PASSWORD_INCORRECT, CURLE_FTP_WEIRD_PASS_REPLY, 
-    CURLE_FTP_WEIRD_USER_REPLY, CURLE_FTP_WEIRD_PASV_REPLY, 
-    CURLE_FTP_WEIRD_227_FORMAT, CURLE_FTP_CANT_GET_HOST, 
-    CURLE_FTP_CANT_RECONNECT, CURLE_FTP_COULDNT_SET_BINARY, CURLE_PARTIAL_FILE, 
-    CURLE_FTP_COULDNT_RETR_FILE, CURLE_FTP_WRITE_ERROR, CURLE_FTP_QUOTE_ERROR, 
-    CURLE_HTTP_RETURNED_ERROR, CURLE_WRITE_ERROR, CURLE_MALFORMAT_USER, 
-    CURLE_FTP_COULDNT_STOR_FILE, CURLE_READ_ERROR, CURLE_OUT_OF_MEMORY, 
-    CURLE_OPERATION_TIMEOUTED, CURLE_FTP_COULDNT_SET_ASCII, 
-    CURLE_FTP_PORT_FAILED, CURLE_FTP_COULDNT_USE_REST, 
-    CURLE_FTP_COULDNT_GET_SIZE, CURLE_HTTP_RANGE_ERROR, CURLE_HTTP_POST_ERROR, 
-    CURLE_SSL_CONNECT_ERROR, CURLE_BAD_DOWNLOAD_RESUME, 
-    CURLE_FILE_COULDNT_READ_FILE, CURLE_LDAP_CANNOT_BIND, 
-    CURLE_LDAP_SEARCH_FAILED, CURLE_LIBRARY_NOT_FOUND, CURLE_FUNCTION_NOT_FOUND, 
-    CURLE_ABORTED_BY_CALLBACK, CURLE_BAD_FUNCTION_ARGUMENT, 
-    CURLE_BAD_CALLING_ORDER, CURLE_INTERFACE_FAILED, CURLE_BAD_PASSWORD_ENTERED, 
-    CURLE_TOO_MANY_REDIRECTS, CURLE_UNKNOWN_TELNET_OPTION, 
-    CURLE_TELNET_OPTION_SYNTAX, CURLE_OBSOLETE, CURLE_SSL_PEER_CERTIFICATE, 
-    CURLE_GOT_NOTHING, CURLE_SSL_ENGINE_NOTFOUND, CURLE_SSL_ENGINE_SETFAILED, 
-    CURLE_SEND_ERROR, CURLE_RECV_ERROR, CURLE_SHARE_IN_USE, 
-    CURLE_SSL_CERTPROBLEM, CURLE_SSL_CIPHER, CURLE_SSL_CACERT, 
-    CURLE_BAD_CONTENT_ENCODING, CURLE_LDAP_INVALID_URL, CURLE_FILESIZE_EXCEEDED, 
-    CURLE_FTP_SSL_FAILED, CURLE_SEND_FAIL_REWIND, CURLE_SSL_ENGINE_INITFAILED, 
-    CURLE_LOGIN_DENIED, CURLE_TFTP_NOTFOUND, CURLE_TFTP_PERM, 
-    CURLE_TFTP_DISKFULL, CURLE_TFTP_ILLEGAL, CURLE_TFTP_UNKNOWNID, 
-    CURLE_TFTP_EXISTS, CURLE_TFTP_NOSUCHUSER, CURLE_CONV_FAILED, 
-    CURLE_CONV_REQD, CURL_LAST
-  Tcurl_conv_callback* = proc (buffer: cstring, len: int): TCURLcode {.cdecl.}
-  Tcurl_ssl_ctx_callback* = proc (curl: PCURL, 
-                                 ssl_ctx, userptr: pointer): TCURLcode {.cdecl.}
-  Tcurl_proxytype* = enum 
-    CURLPROXY_HTTP = 0, CURLPROXY_SOCKS4 = 4, CURLPROXY_SOCKS5 = 5
-  Tcurl_ftpssl* = enum 
-    CURLFTPSSL_NONE, CURLFTPSSL_TRY, CURLFTPSSL_CONTROL, CURLFTPSSL_ALL, 
-    CURLFTPSSL_LAST
-  Tcurl_ftpauth* = enum 
-    CURLFTPAUTH_DEFAULT, CURLFTPAUTH_SSL, CURLFTPAUTH_TLS, CURLFTPAUTH_LAST
-  Tcurl_ftpmethod* = enum 
-    CURLFTPMETHOD_DEFAULT, CURLFTPMETHOD_MULTICWD, CURLFTPMETHOD_NOCWD, 
-    CURLFTPMETHOD_SINGLECWD, CURLFTPMETHOD_LAST
-  TCURLoption* = enum 
-    CURLOPT_PORT = 0 + 3,
-    CURLOPT_TIMEOUT = 0 + 13, 
-    CURLOPT_INFILESIZE = 0 + 14, 
-    CURLOPT_LOW_SPEED_LIMIT = 0 + 19, 
-    CURLOPT_LOW_SPEED_TIME = 0 + 20, 
-    CURLOPT_RESUME_FROM = 0 + 21,
-    CURLOPT_CRLF = 0 + 27, 
-    CURLOPT_SSLVERSION = 0 + 32, 
-    CURLOPT_TIMECONDITION = 0 + 33, 
-    CURLOPT_TIMEVALUE = 0 + 34, 
-    CURLOPT_VERBOSE = 0 + 41, 
-    CURLOPT_HEADER = 0 + 42, 
-    CURLOPT_NOPROGRESS = 0 + 43, 
-    CURLOPT_NOBODY = 0 + 44, 
-    CURLOPT_FAILONERROR = 0 + 45, 
-    CURLOPT_UPLOAD = 0 + 46, 
-    CURLOPT_POST = 0 + 47, 
-    CURLOPT_FTPLISTONLY = 0 + 48, 
-    CURLOPT_FTPAPPEND = 0 + 50, 
-    CURLOPT_NETRC = 0 + 51, 
-    CURLOPT_FOLLOWLOCATION = 0 + 52, 
-    CURLOPT_TRANSFERTEXT = 0 + 53, 
-    CURLOPT_PUT = 0 + 54, 
-    CURLOPT_AUTOREFERER = 0 + 58, 
-    CURLOPT_PROXYPORT = 0 + 59, 
-    CURLOPT_POSTFIELDSIZE = 0 + 60, 
-    CURLOPT_HTTPPROXYTUNNEL = 0 + 61, 
-    CURLOPT_SSL_VERIFYPEER = 0 + 64, 
-    CURLOPT_MAXREDIRS = 0 + 68, 
-    CURLOPT_FILETIME = 0 + 69, 
-    CURLOPT_MAXCONNECTS = 0 + 71, 
-    CURLOPT_CLOSEPOLICY = 0 + 72, 
-    CURLOPT_FRESH_CONNECT = 0 + 74, 
-    CURLOPT_FORBID_REUSE = 0 + 75, 
-    CURLOPT_CONNECTTIMEOUT = 0 + 78, 
-    CURLOPT_HTTPGET = 0 + 80, 
-    CURLOPT_SSL_VERIFYHOST = 0 + 81, 
-    CURLOPT_HTTP_VERSION = 0 + 84, 
-    CURLOPT_FTP_USE_EPSV = 0 + 85, 
-    CURLOPT_SSLENGINE_DEFAULT = 0 + 90, 
-    CURLOPT_DNS_USE_GLOBAL_CACHE = 0 + 91, 
-    CURLOPT_DNS_CACHE_TIMEOUT = 0 + 92, 
-    CURLOPT_COOKIESESSION = 0 + 96, 
-    CURLOPT_BUFFERSIZE = 0 + 98, 
-    CURLOPT_NOSIGNAL = 0 + 99, 
-    CURLOPT_PROXYTYPE = 0 + 101, 
-    CURLOPT_UNRESTRICTED_AUTH = 0 + 105, 
-    CURLOPT_FTP_USE_EPRT = 0 + 106, 
-    CURLOPT_HTTPAUTH = 0 + 107, 
-    CURLOPT_FTP_CREATE_MISSING_DIRS = 0 + 110, 
-    CURLOPT_PROXYAUTH = 0 + 111, 
-    CURLOPT_FTP_RESPONSE_TIMEOUT = 0 + 112, 
-    CURLOPT_IPRESOLVE = 0 + 113, 
-    CURLOPT_MAXFILESIZE = 0 + 114, 
-    CURLOPT_FTP_SSL = 0 + 119, 
-    CURLOPT_TCP_NODELAY = 0 + 121, 
-    CURLOPT_FTPSSLAUTH = 0 + 129, 
-    CURLOPT_IGNORE_CONTENT_LENGTH = 0 + 136, 
-    CURLOPT_FTP_SKIP_PASV_IP = 0 + 137, 
-    CURLOPT_FTP_FILEMETHOD = 0 + 138, 
-    CURLOPT_LOCALPORT = 0 + 139, 
-    CURLOPT_LOCALPORTRANGE = 0 + 140, 
-    CURLOPT_CONNECT_ONLY = 0 + 141, 
-
-    CURLOPT_FILE = 10000 + 1, 
-    CURLOPT_URL = 10000 + 2,  
-    CURLOPT_PROXY = 10000 + 4, 
-    CURLOPT_USERPWD = 10000 + 5, 
-    CURLOPT_PROXYUSERPWD = 10000 + 6, 
-    CURLOPT_RANGE = 10000 + 7, 
-    CURLOPT_INFILE = 10000 + 9, 
-    CURLOPT_ERRORBUFFER = 10000 + 10, 
-    CURLOPT_POSTFIELDS = 10000 + 15, 
-    CURLOPT_REFERER = 10000 + 16, 
-    CURLOPT_FTPPORT = 10000 + 17, 
-    CURLOPT_USERAGENT = 10000 + 18, 
-    CURLOPT_COOKIE = 10000 + 22, 
-    CURLOPT_HTTPHEADER = 10000 + 23, 
-    CURLOPT_HTTPPOST = 10000 + 24, 
-    CURLOPT_SSLCERT = 10000 + 25, 
-    CURLOPT_SSLCERTPASSWD = 10000 + 26, 
-    CURLOPT_QUOTE = 10000 + 28, 
-    CURLOPT_WRITEHEADER = 10000 + 29, 
-    CURLOPT_COOKIEFILE = 10000 + 31, 
-    CURLOPT_CUSTOMREQUEST = 10000 + 36, 
-    CURLOPT_STDERR = 10000 + 37, 
-    CURLOPT_POSTQUOTE = 10000 + 39, 
-    CURLOPT_WRITEINFO = 10000 + 40, 
-    CURLOPT_PROGRESSDATA = 10000 + 57, 
-    CURLOPT_INTERFACE = 10000 + 62, 
-    CURLOPT_KRB4LEVEL = 10000 + 63,
-    CURLOPT_CAINFO = 10000 + 65, 
-    CURLOPT_TELNETOPTIONS = 10000 + 70, 
-    CURLOPT_RANDOM_FILE = 10000 + 76, 
-    CURLOPT_EGDSOCKET = 10000 + 77, 
-    CURLOPT_COOKIEJAR = 10000 + 82, 
-    CURLOPT_SSL_CIPHER_LIST = 10000 + 83, 
-    CURLOPT_SSLCERTTYPE = 10000 + 86, 
-    CURLOPT_SSLKEY = 10000 + 87, 
-    CURLOPT_SSLKEYTYPE = 10000 + 88, 
-    CURLOPT_SSLENGINE = 10000 + 89, 
-    CURLOPT_PREQUOTE = 10000 + 93, 
-    CURLOPT_DEBUGDATA = 10000 + 95, 
-    CURLOPT_CAPATH = 10000 + 97, 
-    CURLOPT_SHARE = 10000 + 100, 
-    CURLOPT_ENCODING = 10000 + 102, 
-    CURLOPT_PRIVATE = 10000 + 103, 
-    CURLOPT_HTTP200ALIASES = 10000 + 104, 
-    CURLOPT_SSL_CTX_DATA = 10000 + 109, 
-    CURLOPT_NETRC_FILE = 10000 + 118, 
-    CURLOPT_SOURCE_USERPWD = 10000 + 123, 
-    CURLOPT_SOURCE_PREQUOTE = 10000 + 127, 
-    CURLOPT_SOURCE_POSTQUOTE = 10000 + 128, 
-    CURLOPT_IOCTLDATA = 10000 + 131, 
-    CURLOPT_SOURCE_URL = 10000 + 132, 
-    CURLOPT_SOURCE_QUOTE = 10000 + 133, 
-    CURLOPT_FTP_ACCOUNT = 10000 + 134, 
-    CURLOPT_COOKIELIST = 10000 + 135, 
-    CURLOPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147, 
-    CURLOPT_LASTENTRY = 10000 + 148,
-    
-    CURLOPT_WRITEFUNCTION = 20000 + 11, 
-    CURLOPT_READFUNCTION = 20000 + 12, 
-    CURLOPT_PROGRESSFUNCTION = 20000 + 56, 
-    CURLOPT_HEADERFUNCTION = 20000 + 79, 
-    CURLOPT_DEBUGFUNCTION = 20000 + 94, 
-    CURLOPT_SSL_CTX_FUNCTION = 20000 + 108, 
-    CURLOPT_IOCTLFUNCTION = 20000 + 130, 
-    CURLOPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142, 
-    CURLOPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143, 
-    CURLOPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144, 
-
-    CURLOPT_INFILESIZE_LARGE = 30000 + 115, 
-    CURLOPT_RESUME_FROM_LARGE = 30000 + 116, 
-    CURLOPT_MAXFILESIZE_LARGE = 30000 + 117, 
-    CURLOPT_POSTFIELDSIZE_LARGE = 30000 + 120, 
-    CURLOPT_MAX_SEND_SPEED_LARGE = 30000 + 145, 
-    CURLOPT_MAX_RECV_SPEED_LARGE = 30000 + 146
-
-    
-  TCURL_HTTP_VERSION* = enum 
-    CURL_HTTP_VERSION_NONE, CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, 
-    CURL_HTTP_VERSION_LAST
-    
-  TCURL_NETRC_OPTION* = enum 
-    CURL_NETRC_IGNORED, CURL_NETRC_OPTIONAL, CURL_NETRC_REQUIRED, 
-    CURL_NETRC_LAST
-    
-  TCURL_SSL_VERSION* = enum 
-    CURL_SSLVERSION_DEFAULT, CURL_SSLVERSION_TLSv1, CURL_SSLVERSION_SSLv2, 
-    CURL_SSLVERSION_SSLv3, CURL_SSLVERSION_LAST
-  
-  TCURL_TIMECOND* = enum 
-    CURL_TIMECOND_NONE, CURL_TIMECOND_IFMODSINCE, CURL_TIMECOND_IFUNMODSINCE, 
-    CURL_TIMECOND_LASTMOD, CURL_TIMECOND_LAST
-  
-  TCURLformoption* = enum 
-    CURLFORM_NOTHING, CURLFORM_COPYNAME, CURLFORM_PTRNAME, CURLFORM_NAMELENGTH, 
-    CURLFORM_COPYCONTENTS, CURLFORM_PTRCONTENTS, CURLFORM_CONTENTSLENGTH, 
-    CURLFORM_FILECONTENT, CURLFORM_ARRAY, CURLFORM_OBSOLETE, CURLFORM_FILE, 
-    CURLFORM_BUFFER, CURLFORM_BUFFERPTR, CURLFORM_BUFFERLENGTH, 
-    CURLFORM_CONTENTTYPE, CURLFORM_CONTENTHEADER, CURLFORM_FILENAME, 
-    CURLFORM_END, CURLFORM_OBSOLETE2, CURLFORM_LASTENTRY
-  
-  Tcurl_forms* {.pure, final.} = object 
-    option*: TCURLformoption
-    value*: cstring
-
-  TCURLFORMcode* = enum 
-    CURL_FORMADD_OK, CURL_FORMADD_MEMORY, CURL_FORMADD_OPTION_TWICE, 
-    CURL_FORMADD_NULL, CURL_FORMADD_UNKNOWN_OPTION, CURL_FORMADD_INCOMPLETE, 
-    CURL_FORMADD_ILLEGAL_ARRAY, CURL_FORMADD_DISABLED, CURL_FORMADD_LAST
-
-  Tcurl_formget_callback* = proc (arg: pointer, buf: cstring, 
-                                 length: int): int {.cdecl.}
-  Tcurl_slist* {.pure, final.} = object 
-    data*: cstring
-    next*: Pcurl_slist
-
-  TCURLINFO* = enum 
-    CURLINFO_NONE = 0, 
-    CURLINFO_LASTONE = 30,
-    CURLINFO_EFFECTIVE_URL = 0x00100000 + 1, 
-    CURLINFO_CONTENT_TYPE = 0x00100000 + 18, 
-    CURLINFO_PRIVATE = 0x00100000 + 21, 
-    CURLINFO_FTP_ENTRY_PATH = 0x00100000 + 30,
-
-    CURLINFO_RESPONSE_CODE = 0x00200000 + 2, 
-    CURLINFO_HEADER_SIZE = 0x00200000 + 11, 
-    CURLINFO_REQUEST_SIZE = 0x00200000 + 12, 
-    CURLINFO_SSL_VERIFYRESULT = 0x00200000 + 13, 
-    CURLINFO_FILETIME = 0x00200000 + 14, 
-    CURLINFO_REDIRECT_COUNT = 0x00200000 + 20, 
-    CURLINFO_HTTP_CONNECTCODE = 0x00200000 + 22, 
-    CURLINFO_HTTPAUTH_AVAIL = 0x00200000 + 23, 
-    CURLINFO_PROXYAUTH_AVAIL = 0x00200000 + 24, 
-    CURLINFO_OS_ERRNO = 0x00200000 + 25, 
-    CURLINFO_NUM_CONNECTS = 0x00200000 + 26, 
-    CURLINFO_LASTSOCKET = 0x00200000 + 29, 
-    
-    CURLINFO_TOTAL_TIME = 0x00300000 + 3, 
-    CURLINFO_NAMELOOKUP_TIME = 0x00300000 + 4, 
-    CURLINFO_CONNECT_TIME = 0x00300000 + 5, 
-    CURLINFO_PRETRANSFER_TIME = 0x00300000 + 6, 
-    CURLINFO_SIZE_UPLOAD = 0x00300000 + 7, 
-    CURLINFO_SIZE_DOWNLOAD = 0x00300000 + 8, 
-    CURLINFO_SPEED_DOWNLOAD = 0x00300000 + 9, 
-    CURLINFO_SPEED_UPLOAD = 0x00300000 + 10, 
-    CURLINFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15, 
-    CURLINFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16, 
-    CURLINFO_STARTTRANSFER_TIME = 0x00300000 + 17, 
-    CURLINFO_REDIRECT_TIME = 0x00300000 + 19, 
-
-    CURLINFO_SSL_ENGINES = 0x00400000 + 27, 
-    CURLINFO_COOKIELIST = 0x00400000 + 28
-
-  Tcurl_closepolicy* = enum 
-    CURLCLOSEPOLICY_NONE, CURLCLOSEPOLICY_OLDEST, 
-    CURLCLOSEPOLICY_LEAST_RECENTLY_USED, CURLCLOSEPOLICY_LEAST_TRAFFIC, 
-    CURLCLOSEPOLICY_SLOWEST, CURLCLOSEPOLICY_CALLBACK, CURLCLOSEPOLICY_LAST
-  Tcurl_lock_data* = enum 
-    CURL_LOCK_DATA_NONE = 0, CURL_LOCK_DATA_SHARE, CURL_LOCK_DATA_COOKIE, 
-    CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_DATA_CONNECT, 
-    CURL_LOCK_DATA_LAST
-  Tcurl_lock_access* = enum 
-    CURL_LOCK_ACCESS_NONE = 0, CURL_LOCK_ACCESS_SHARED = 1, 
-    CURL_LOCK_ACCESS_SINGLE = 2, CURL_LOCK_ACCESS_LAST
-  
-  Tcurl_lock_function* = proc (handle: PCURL, data: Tcurl_lock_data, 
-                              locktype: Tcurl_lock_access, 
-                              userptr: pointer) {.cdecl.}
-  Tcurl_unlock_function* = proc (handle: PCURL, data: Tcurl_lock_data, 
-                                userptr: pointer) {.cdecl.}
-  TCURLSH* = pointer
-  TCURLSHcode* = enum 
-    CURLSHE_OK, CURLSHE_BAD_OPTION, CURLSHE_IN_USE, CURLSHE_INVALID, 
-    CURLSHE_NOMEM, CURLSHE_LAST
-  
-  TCURLSHoption* = enum 
-    CURLSHOPT_NONE, CURLSHOPT_SHARE, CURLSHOPT_UNSHARE, CURLSHOPT_LOCKFUNC, 
-    CURLSHOPT_UNLOCKFUNC, CURLSHOPT_USERDATA, CURLSHOPT_LAST
-  
-  TCURLversion* = enum 
-    CURLVERSION_FIRST, CURLVERSION_SECOND, CURLVERSION_THIRD, CURLVERSION_LAST
-  
-  Tcurl_version_info_data* {.pure, final.} = object 
-    age*: TCURLversion
-    version*: cstring
-    version_num*: int32
-    host*: cstring
-    features*: int32
-    ssl_version*: cstring
-    ssl_version_num*: int32
-    libz_version*: cstring
-    protocols*: cstringArray
-    ares*: cstring
-    ares_num*: int32
-    libidn*: cstring
-    iconv_ver_num*: int32
-
-  TCURLM* = pointer
-  Tcurl_socket* = int32
-  TCURLMcode* = enum 
-    CURLM_CALL_MULTI_PERFORM = -1, 
-    CURLM_OK = 0, 
-    CURLM_BAD_HANDLE, 
-    CURLM_BAD_EASY_HANDLE, 
-    CURLM_OUT_OF_MEMORY, 
-    CURLM_INTERNAL_ERROR, 
-    CURLM_BAD_SOCKET, 
-    CURLM_UNKNOWN_OPTION, 
-    CURLM_LAST
-    
-  TCURLMSGEnum* = enum 
-    CURLMSG_NONE, CURLMSG_DONE, CURLMSG_LAST
-  TCURLMsg* {.pure, final.} = object 
-    msg*: TCURLMSGEnum
-    easy_handle*: PCURL
-    whatever*: Pointer        #data : record
-                              #      case longint of
-                              #        0 : ( whatever : pointer );
-                              #        1 : ( result : CURLcode );
-                              #    end;
-  
-  Tcurl_socket_callback* = proc (easy: PCURL, s: Tcurl_socket, what: int32, 
-                                 userp, socketp: pointer): int32 {.cdecl.}
-  TCURLMoption* = enum 
-    CURLMOPT_SOCKETDATA = 10000 + 2, 
-    CURLMOPT_LASTENTRY = 10000 + 3,
-    CURLMOPT_SOCKETFUNCTION = 20000 + 1
-    
-const 
-  CURLOPT_SSLKEYPASSWD* = CURLOPT_SSLCERTPASSWD
-
-  CURLAUTH_ANY* = not (0)
-  CURLAUTH_BASIC* = 1 shl 0
-  CURLAUTH_ANYSAFE* = not (CURLAUTH_BASIC)
-  CURLAUTH_DIGEST* = 1 shl 1
-  CURLAUTH_GSSNEGOTIATE* = 1 shl 2
-  CURLAUTH_NONE* = 0
-  CURLAUTH_NTLM* = 1 shl 3
-  CURLE_ALREADY_COMPLETE* = 99999
-  CURLE_FTP_BAD_DOWNLOAD_RESUME* = CURLE_BAD_DOWNLOAD_RESUME
-  CURLE_FTP_PARTIAL_FILE* = CURLE_PARTIAL_FILE
-  CURLE_HTTP_NOT_FOUND* = CURLE_HTTP_RETURNED_ERROR
-  CURLE_HTTP_PORT_FAILED* = CURLE_INTERFACE_FAILED
-  CURLE_OPERATION_TIMEDOUT* = CURLE_OPERATION_TIMEOUTED
-  CURL_ERROR_SIZE* = 256
-  CURL_FORMAT_OFF_T* = "%ld"
-  CURL_GLOBAL_NOTHING* = 0
-  CURL_GLOBAL_SSL* = 1 shl 0
-  CURL_GLOBAL_WIN32* = 1 shl 1
-  CURL_GLOBAL_ALL* = CURL_GLOBAL_SSL or CURL_GLOBAL_WIN32
-  CURL_GLOBAL_DEFAULT* = CURL_GLOBAL_ALL
-  CURLINFO_DOUBLE* = 0x00300000
-  CURLINFO_HTTP_CODE* = CURLINFO_RESPONSE_CODE
-  CURLINFO_LONG* = 0x00200000
-  CURLINFO_MASK* = 0x000FFFFF
-  CURLINFO_SLIST* = 0x00400000
-  CURLINFO_STRING* = 0x00100000
-  CURLINFO_TYPEMASK* = 0x00F00000
-  CURL_IPRESOLVE_V4* = 1
-  CURL_IPRESOLVE_V6* = 2
-  CURL_IPRESOLVE_WHATEVER* = 0
-  CURL_MAX_WRITE_SIZE* = 16384
-  CURLM_CALL_MULTI_SOCKET* = CURLM_CALL_MULTI_PERFORM
-  CURLOPT_CLOSEFUNCTION* = - (5)
-  CURLOPT_FTPASCII* = CURLOPT_TRANSFERTEXT
-  CURLOPT_HEADERDATA* = CURLOPT_WRITEHEADER
-  CURLOPT_HTTPREQUEST* = - (1)
-  CURLOPT_MUTE* = - (2)
-  CURLOPT_PASSWDDATA* = - (4)
-  CURLOPT_PASSWDFUNCTION* = - (3)
-  CURLOPT_PASV_HOST* = - (9)
-  CURLOPT_READDATA* = CURLOPT_INFILE
-  CURLOPT_SOURCE_HOST* = - (6)
-  CURLOPT_SOURCE_PATH* = - (7)
-  CURLOPT_SOURCE_PORT* = - (8)
-  CURLOPTTYPE_FUNCTIONPOINT* = 20000
-  CURLOPTTYPE_LONG* = 0
-  CURLOPTTYPE_OBJECTPOINT* = 10000
-  CURLOPTTYPE_OFF_T* = 30000
-  CURLOPT_WRITEDATA* = CURLOPT_FILE
-  CURL_POLL_IN* = 1
-  CURL_POLL_INOUT* = 3
-  CURL_POLL_NONE* = 0
-  CURL_POLL_OUT* = 2
-  CURL_POLL_REMOVE* = 4
-  CURL_READFUNC_ABORT* = 0x10000000
-  CURL_SOCKET_BAD* = - (1)
-  CURL_SOCKET_TIMEOUT* = CURL_SOCKET_BAD
-  CURL_VERSION_ASYNCHDNS* = 1 shl 7
-  CURL_VERSION_CONV* = 1 shl 12
-  CURL_VERSION_DEBUG* = 1 shl 6
-  CURL_VERSION_GSSNEGOTIATE* = 1 shl 5
-  CURL_VERSION_IDN* = 1 shl 10
-  CURL_VERSION_IPV6* = 1 shl 0
-  CURL_VERSION_KERBEROS4* = 1 shl 1
-  CURL_VERSION_LARGEFILE* = 1 shl 9
-  CURL_VERSION_LIBZ* = 1 shl 3
-  CURLVERSION_NOW* = CURLVERSION_THIRD
-  CURL_VERSION_NTLM* = 1 shl 4
-  CURL_VERSION_SPNEGO* = 1 shl 8
-  CURL_VERSION_SSL* = 1 shl 2
-  CURL_VERSION_SSPI* = 1 shl 11
-  FILE_OFFSET_BITS* = 0
-  FILESIZEBITS* = 0
-  FUNCTIONPOINT* = CURLOPTTYPE_FUNCTIONPOINT
-  HTTPPOST_BUFFER* = 1 shl 4
-  HTTPPOST_FILENAME* = 1 shl 0
-  HTTPPOST_PTRBUFFER* = 1 shl 5
-  HTTPPOST_PTRCONTENTS* = 1 shl 3
-  HTTPPOST_PTRNAME* = 1 shl 2
-  HTTPPOST_READFILE* = 1 shl 1
-  LIBCURL_VERSION* = "7.15.5"
-  LIBCURL_VERSION_MAJOR* = 7
-  LIBCURL_VERSION_MINOR* = 15
-  LIBCURL_VERSION_NUM* = 0x00070F05
-  LIBCURL_VERSION_PATCH* = 5
-
-proc curl_strequal*(s1, s2: cstring): int32{.cdecl, 
-    dynlib: libname, importc: "curl_strequal".}
-proc curl_strnequal*(s1, s2: cstring, n: int): int32 {.cdecl, 
-    dynlib: libname, importc: "curl_strnequal".}
-proc curl_formadd*(httppost, last_post: PPcurl_httppost): TCURLFORMcode {.
-    cdecl, varargs, dynlib: libname, importc: "curl_formadd".}
-
-proc curl_formget*(form: Pcurl_httppost, arg: pointer, 
-                   append: Tcurl_formget_callback): int32 {.cdecl, 
-    dynlib: libname, importc: "curl_formget".}
-proc curl_formfree*(form: Pcurl_httppost){.cdecl, dynlib: libname, 
-    importc: "curl_formfree".}
-proc curl_getenv*(variable: cstring): cstring{.cdecl, dynlib: libname, 
-    importc: "curl_getenv".}
-proc curl_version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
-proc curl_easy_escape*(handle: PCURL, str: cstring, len: int32): cstring{.cdecl, 
-    dynlib: libname, importc: "curl_easy_escape".}
-proc curl_escape*(str: cstring, len: int32): cstring{.cdecl, 
-    dynlib: libname, importc: "curl_escape".}
-proc curl_easy_unescape*(handle: PCURL, str: cstring, len: int32, 
-                         outlength: var int32): cstring{.cdecl, 
-    dynlib: libname, importc: "curl_easy_unescape".}
-proc curl_unescape*(str: cstring, len: int32): cstring{.cdecl, 
-    dynlib: libname, importc: "curl_unescape".}
-proc curl_free*(p: pointer){.cdecl, dynlib: libname, 
-                             importc: "curl_free".}
-proc curl_global_init*(flags: int32): TCURLcode {.cdecl, dynlib: libname, 
-    importc: "curl_global_init".}
-proc curl_global_init_mem*(flags: int32, m: Tcurl_malloc_callback, 
-                           f: Tcurl_free_callback, r: Tcurl_realloc_callback, 
-                           s: Tcurl_strdup_callback, 
-                           c: Tcurl_calloc_callback): TCURLcode {.
-    cdecl, dynlib: libname, importc: "curl_global_init_mem".}
-proc curl_global_cleanup*() {.cdecl, dynlib: libname, 
-                              importc: "curl_global_cleanup".}
-proc curl_slist_append*(curl_slist: Pcurl_slist, P: cstring): Pcurl_slist {.
-    cdecl, dynlib: libname, importc: "curl_slist_append".}
-proc curl_slist_free_all*(para1: Pcurl_slist) {.cdecl, dynlib: libname, 
-    importc: "curl_slist_free_all".}
-proc curl_getdate*(p: cstring, unused: ptr TTime): TTime {.cdecl, 
-    dynlib: libname, importc: "curl_getdate".}
-proc curl_share_init*(): PCURLSH{.cdecl, dynlib: libname, 
-                                  importc: "curl_share_init".}
-proc curl_share_setopt*(para1: PCURLSH, option: TCURLSHoption): TCURLSHcode {.
-    cdecl, varargs, dynlib: libname, importc: "curl_share_setopt".}
-
-proc curl_share_cleanup*(para1: PCURLSH): TCURLSHcode {.cdecl, 
-    dynlib: libname, importc: "curl_share_cleanup".}
-proc curl_version_info*(para1: TCURLversion): Pcurl_version_info_data{.cdecl, 
-    dynlib: libname, importc: "curl_version_info".}
-proc curl_easy_strerror*(para1: TCURLcode): cstring {.cdecl, 
-    dynlib: libname, importc: "curl_easy_strerror".}
-proc curl_share_strerror*(para1: TCURLSHcode): cstring {.cdecl, 
-    dynlib: libname, importc: "curl_share_strerror".}
-proc curl_easy_init*(): PCURL {.cdecl, dynlib: libname, 
-                               importc: "curl_easy_init".}
-proc curl_easy_setopt*(curl: PCURL, option: TCURLoption): TCURLcode {.cdecl, 
-    varargs, dynlib: libname, importc: "curl_easy_setopt".}
-
-proc curl_easy_perform*(curl: PCURL): TCURLcode {.cdecl, dynlib: libname, 
-    importc: "curl_easy_perform".}
-proc curl_easy_cleanup*(curl: PCURL) {.cdecl, dynlib: libname, 
-                                       importc: "curl_easy_cleanup".}
-proc curl_easy_getinfo*(curl: PCURL, info: TCURLINFO): TCURLcode {.
-    cdecl, varargs, dynlib: libname, importc: "curl_easy_getinfo".}
-
-proc curl_easy_duphandle*(curl: PCURL): PCURL {.cdecl, dynlib: libname, 
-    importc: "curl_easy_duphandle".}
-proc curl_easy_reset*(curl: PCURL) {.cdecl, dynlib: libname, 
-                                     importc: "curl_easy_reset".}
-proc curl_multi_init*(): PCURLM {.cdecl, dynlib: libname, 
-                                  importc: "curl_multi_init".}
-proc curl_multi_add_handle*(multi_handle: PCURLM, 
-                            curl_handle: PCURL): TCURLMcode {.
-    cdecl, dynlib: libname, importc: "curl_multi_add_handle".}
-proc curl_multi_remove_handle*(multi_handle: PCURLM, 
-                               curl_handle: PCURL): TCURLMcode {.
-    cdecl, dynlib: libname, importc: "curl_multi_remove_handle".}
-proc curl_multi_fdset*(multi_handle: PCURLM, read_fd_set: Pfd_set, 
-                       write_fd_set: Pfd_set, exc_fd_set: Pfd_set, 
-                       max_fd: var int32): TCURLMcode {.cdecl, 
-    dynlib: libname, importc: "curl_multi_fdset".}
-proc curl_multi_perform*(multi_handle: PCURLM, 
-                         running_handles: var int32): TCURLMcode {.
-    cdecl, dynlib: libname, importc: "curl_multi_perform".}
-proc curl_multi_cleanup*(multi_handle: PCURLM): TCURLMcode {.cdecl, 
-    dynlib: libname, importc: "curl_multi_cleanup".}
-proc curl_multi_info_read*(multi_handle: PCURLM, 
-                           msgs_in_queue: var int32): PCURLMsg {.
-    cdecl, dynlib: libname, importc: "curl_multi_info_read".}
-proc curl_multi_strerror*(para1: TCURLMcode): cstring {.cdecl, 
-    dynlib: libname, importc: "curl_multi_strerror".}
-proc curl_multi_socket*(multi_handle: PCURLM, s: Tcurl_socket, 
-                        running_handles: var int32): TCURLMcode {.cdecl, 
-    dynlib: libname, importc: "curl_multi_socket".}
-proc curl_multi_socket_all*(multi_handle: PCURLM, 
-                            running_handles: var int32): TCURLMcode {.
-    cdecl, dynlib: libname, importc: "curl_multi_socket_all".}
-proc curl_multi_timeout*(multi_handle: PCURLM, milliseconds: var int32): TCURLMcode{.
-    cdecl, dynlib: libname, importc: "curl_multi_timeout".}
-proc curl_multi_setopt*(multi_handle: PCURLM, option: TCURLMoption): TCURLMcode{.
-    cdecl, varargs, dynlib: libname, importc: "curl_multi_setopt".}
-
-proc curl_multi_assign*(multi_handle: PCURLM, sockfd: Tcurl_socket, 
-                        sockp: pointer): TCURLMcode {.cdecl, 
-    dynlib: libname, importc: "curl_multi_assign".}
-
-
diff --git a/lib/oldwrappers/lua/lauxlib.nim b/lib/oldwrappers/lua/lauxlib.nim
deleted file mode 100755
index 477dd5874..000000000
--- a/lib/oldwrappers/lua/lauxlib.nim
+++ /dev/null
@@ -1,224 +0,0 @@
-#*****************************************************************************
-# *                                                                            *
-# *  File:        lauxlib.pas                                                  *
-# *  Authors:     TeCGraf           (C headers + actual Lua libraries)         *
-# *               Lavergne Thomas   (original translation to Pascal)           *
-# *               Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal)       *
-# *  Description: Lua auxiliary library                                        *
-# *                                                                            *
-# *****************************************************************************
-#
-#** $Id: lauxlib.h,v 1.59 2003/03/18 12:25:32 roberto Exp $
-#** Auxiliary functions for building Lua libraries
-#** See Copyright Notice in lua.h
-#
-#
-#** Translated to pascal by Lavergne Thomas
-#** Notes :
-#**    - Pointers type was prefixed with 'P'
-#** Bug reports :
-#**    - thomas.lavergne@laposte.net
-#**   In french or in english
-#
-
-import lua
-
-proc lua_pushstring*(L: Plua_State, s: string)
-  # compatibilty macros
-proc luaL_getn*(L: Plua_State, n: int): int
-  # calls lua_objlen
-proc luaL_setn*(L: Plua_State, t, n: int)
-  # does nothing!
-type 
-  TLuaL_reg*{.final.} = object 
-    name*: cstring
-    func*: lua_CFunction
-
-  PluaL_reg* = ptr TLuaL_reg
-
-proc luaL_openlib*(L: Plua_State, libname: cstring, lr: PluaL_reg, nup: int){.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_register*(L: Plua_State, libname: cstring, lr: PluaL_reg){.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checklstring*(L: Plua_State, numArg: int, len: Psize_t): cstring{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_optlstring*(L: Plua_State, numArg: int, def: cstring, len: Psize_t): cstring{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_newmetatable*(L: Plua_State, tname: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_loadfile*(L: Plua_State, filename: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_loadstring*(L: Plua_State, s: cstring): int{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc lua_open*(): Plua_State
-  # compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
-  #
-  #** ===============================================================
-  #** some useful macros
-  #** ===============================================================
-  #
-proc luaL_argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring)
-proc luaL_checkstring*(L: Plua_State, n: int): cstring
-proc luaL_optstring*(L: Plua_State, n: int, d: cstring): cstring
-proc luaL_checkint*(L: Plua_State, n: int): int
-proc luaL_checklong*(L: Plua_State, n: int): int32
-proc luaL_optint*(L: Plua_State, n: int, d: float64): int
-proc luaL_optlong*(L: Plua_State, n: int, d: float64): int32
-proc luaL_typename*(L: Plua_State, i: int): cstring
-proc lua_dofile*(L: Plua_State, filename: cstring): int
-proc lua_dostring*(L: Plua_State, str: cstring): int
-proc lua_Lgetmetatable*(L: Plua_State, tname: cstring)
-  # not translated:
-  # #define luaL_opt(L,f,n,d)	(lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
-  #
-  #** =======================================================
-  #** Generic Buffer manipulation
-  #** =======================================================
-  #
-const                         # note: this is just arbitrary, as it related to the BUFSIZ defined in stdio.h ...
-  LUAL_BUFFERSIZE* = 4096
-
-type 
-  luaL_Buffer*{.final.} = object 
-    p*: cstring               # current position in buffer 
-    lvl*: int                 # number of strings in the stack (level) 
-    L*: Plua_State
-    buffer*: array[0..LUAL_BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
-  
-  PluaL_Buffer* = ptr luaL_Buffer
-
-proc luaL_addchar*(B: PluaL_Buffer, c: Char)
-  # warning: see note above about LUAL_BUFFERSIZE
-  # compatibility only (alias for luaL_addchar) 
-proc luaL_putchar*(B: PluaL_Buffer, c: Char)
-  # warning: see note above about LUAL_BUFFERSIZE
-proc luaL_addsize*(B: PluaL_Buffer, n: int)
-proc luaL_buffinit*(L: Plua_State, B: PluaL_Buffer){.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_prepbuffer*(B: PluaL_Buffer): cstring{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_addlstring*(B: PluaL_Buffer, s: cstring, L: size_t){.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_addstring*(B: PluaL_Buffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_addvalue*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_pushresult*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaL_gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl, 
-    dynlib: LUA_LIB_NAME, importc.}
-proc luaL_findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{.
-    cdecl, dynlib: LUA_LIB_NAME, importc.}
-  # compatibility with ref system 
-  # pre-defined references 
-const 
-  LUA_NOREF* = - 2
-  LUA_REFNIL* = - 1
-
-proc lua_unref*(L: Plua_State, theref: int)
-proc lua_getref*(L: Plua_State, theref: int)
-  #
-  #** Compatibility macros and functions
-  #
-
-# implementation
-
-proc lua_pushstring(L: Plua_State, s: string) = 
-  lua_pushlstring(L, cstring(s), len(s))
-
-proc luaL_getn(L: Plua_State, n: int): int = 
-  Result = lua_objlen(L, n)
-
-proc luaL_setn(L: Plua_State, t, n: int) = 
-  # does nothing as this operation is deprecated
-  nil
-  
-proc lua_open(): Plua_State = 
-  Result = luaL_newstate()
-
-proc luaL_typename(L: Plua_State, i: int): cstring = 
-  Result = lua_typename(L, lua_type(L, i))
-
-proc lua_dofile(L: Plua_State, filename: cstring): int = 
-  Result = luaL_loadfile(L, filename)
-  if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
-  
-proc lua_dostring(L: Plua_State, str: cstring): int = 
-  Result = luaL_loadstring(L, str)
-  if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
-  
-proc lua_Lgetmetatable(L: Plua_State, tname: cstring) = 
-  lua_getfield(L, LUA_REGISTRYINDEX, tname)
-
-proc luaL_argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) = 
-  if not cond:
-    discard luaL_argerror(L, numarg, extramsg)
-  
-proc luaL_checkstring(L: Plua_State, n: int): cstring = 
-  Result = luaL_checklstring(L, n, nil)
-
-proc luaL_optstring(L: Plua_State, n: int, d: cstring): cstring = 
-  Result = luaL_optlstring(L, n, d, nil)
-
-proc luaL_checkint(L: Plua_State, n: int): int = 
-  Result = toInt(luaL_checknumber(L, n))
-
-proc luaL_checklong(L: Plua_State, n: int): int32 = 
-  Result = int32(ToInt(luaL_checknumber(L, n)))
-
-proc luaL_optint(L: Plua_State, n: int, d: float64): int = 
-  Result = int(ToInt(luaL_optnumber(L, n, d)))
-
-proc luaL_optlong(L: Plua_State, n: int, d: float64): int32 = 
-  Result = int32(ToInt(luaL_optnumber(L, n, d)))
-
-proc luaL_addchar(B: PluaL_Buffer, c: Char) = 
-  if cast[int](addr((B.p))) < (cast[int](addr((B.buffer[0]))) + LUAL_BUFFERSIZE): 
-    discard luaL_prepbuffer(B)
-  B.p[1] = c
-  B.p = cast[cstring](cast[int](B.p) + 1)
-
-proc luaL_putchar(B: PluaL_Buffer, c: Char) = 
-  luaL_addchar(B, c)
-
-proc luaL_addsize(B: PluaL_Buffer, n: int) = 
-  B.p = cast[cstring](cast[int](B.p) + n)
-
-proc lua_unref(L: Plua_State, theref: int) = 
-  luaL_unref(L, LUA_REGISTRYINDEX, theref)
-
-proc lua_getref(L: Plua_State, theref: int) = 
-  lua_rawgeti(L, LUA_REGISTRYINDEX, theref)
diff --git a/lib/oldwrappers/lua/lua.nim b/lib/oldwrappers/lua/lua.nim
deleted file mode 100755
index 54f8d46bb..000000000
--- a/lib/oldwrappers/lua/lua.nim
+++ /dev/null
@@ -1,391 +0,0 @@
-#*****************************************************************************
-# *                                                                            *
-# *  File:        lua.pas                                                      *
-# *  Authors:     TeCGraf           (C headers + actual Lua libraries)         *
-# *               Lavergne Thomas   (original translation to Pascal)           *
-# *               Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal)       *
-# *  Description: Basic Lua library                                            *
-# *                                                                            *
-# *****************************************************************************
-#
-#** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $
-#** Lua - An Extensible Extension Language
-#** TeCGraf: Computer Graphics Technology Group, PUC-Rio, Brazil
-#** http://www.lua.org   mailto:info@lua.org
-#** See Copyright Notice at the end of this file
-#
-#
-#** Updated to Lua 5.1.1 by Bram Kuijvenhoven (bram at kuijvenhoven dot net),
-#**   Hexis BV (http://www.hexis.nl), the Netherlands
-#** Notes:
-#**    - Only tested with FPC (FreePascal Compiler)
-#**    - Using LuaBinaries styled DLL/SO names, which include version names
-#**    - LUA_YIELD was suffixed by '_' for avoiding name collision
-#
-#
-#** Translated to pascal by Lavergne Thomas
-#** Notes :
-#**    - Pointers type was prefixed with 'P'
-#**    - lua_upvalueindex constant was transformed to function
-#**    - Some compatibility function was isolated because with it you must have
-#**      lualib.
-#**    - LUA_VERSION was suffixed by '_' for avoiding name collision.
-#** Bug reports :
-#**    - thomas.lavergne@laposte.net
-#**   In french or in english
-#
-
-when defined(MACOSX): 
-  const 
-    LUA_NAME* = "liblua(|5.2|5.1|5.0).dylib"
-    LUA_LIB_NAME* = "liblua(|5.2|5.1|5.0).dylib"
-elif defined(UNIX): 
-  const 
-    LUA_NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
-    LUA_LIB_NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
-else: 
-  const 
-    LUA_NAME* = "lua(|5.2|5.1|5.0).dll"
-    LUA_LIB_NAME* = "lua(|5.2|5.1|5.0).dll"
-type 
-  size_t* = int
-  Psize_t* = ptr size_t
-
-const 
-  LUA_VERSION* = "Lua 5.1"
-  LUA_RELEASE* = "Lua 5.1.1"
-  LUA_VERSION_NUM* = 501
-  LUA_COPYRIGHT* = "Copyright (C) 1994-2006 Lua.org, PUC-Rio"
-  LUA_AUTHORS* = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
-  # option for multiple returns in `lua_pcall' and `lua_call' 
-  LUA_MULTRET* = - 1          #
-                              #** pseudo-indices
-                              #
-  LUA_REGISTRYINDEX* = - 10000
-  LUA_ENVIRONINDEX* = - 10001
-  LUA_GLOBALSINDEX* = - 10002
-
-proc lua_upvalueindex*(I: int): int
-const                         # thread status; 0 is OK 
-  constLUA_YIELD* = 1
-  LUA_ERRRUN* = 2
-  LUA_ERRSYNTAX* = 3
-  LUA_ERRMEM* = 4
-  LUA_ERRERR* = 5
-
-type 
-  Plua_State* = Pointer
-  lua_CFunction* = proc (L: Plua_State): int{.cdecl.}
-  
-#
-#** functions that read/write blocks when loading/dumping Lua chunks
-#
-type 
-  lua_Reader* = proc (L: Plua_State, ud: Pointer, sz: Psize_t): cstring{.cdecl.}
-  lua_Writer* = proc (L: Plua_State, p: Pointer, sz: size_t, ud: Pointer): int{.
-      cdecl.}
-  lua_Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.}
-
-const
-  LUA_TNONE* = - 1
-  LUA_TNIL* = 0
-  LUA_TBOOLEAN* = 1
-  LUA_TLIGHTUSERDATA* = 2
-  LUA_TNUMBER* = 3
-  LUA_TSTRING* = 4
-  LUA_TTABLE* = 5
-  LUA_TFUNCTION* = 6
-  LUA_TUSERDATA* = 7
-  LUA_TTHREAD* = 8            # minimum Lua stack available to a C function 
-  LUA_MINSTACK* = 20
-
-type                          # Type of Numbers in Lua 
-  lua_Number* = float
-  lua_Integer* = int
-
-proc lua_newstate*(f: lua_Alloc, ud: Pointer): Plua_State{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_close*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_newthread*(L: Plua_State): Plua_State{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_atpanic*(L: Plua_State, panicf: lua_CFunction): lua_CFunction{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_gettop*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_settop*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_pushvalue*(L: Plua_State, Idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_remove*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_insert*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_replace*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_checkstack*(L: Plua_State, sz: int): cint{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_xmove*(`from`, `to`: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_isnumber*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_isstring*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_iscfunction*(L: Plua_State, idx: int): cint{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_isuserdata*(L: Plua_State, idx: int): cint{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_type*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_typename*(L: Plua_State, tp: int): cstring{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_equal*(L: Plua_State, idx1, idx2: int): cint{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_rawequal*(L: Plua_State, idx1, idx2: int): cint{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_lessthan*(L: Plua_State, idx1, idx2: int): cint{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_tonumber*(L: Plua_State, idx: int): lua_Number{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_tointeger*(L: Plua_State, idx: int): lua_Integer{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_toboolean*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_tolstring*(L: Plua_State, idx: int, length: Psize_t): cstring{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_objlen*(L: Plua_State, idx: int): size_t{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_tocfunction*(L: Plua_State, idx: int): lua_CFunction{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_touserdata*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_tothread*(L: Plua_State, idx: int): Plua_State{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_topointer*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushnil*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_pushnumber*(L: Plua_State, n: lua_Number){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushinteger*(L: Plua_State, n: lua_Integer){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushlstring*(L: Plua_State, s: cstring, len: size_t){.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_pushstring*(L: Plua_State, s: cstring){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushvfstring*(L: Plua_State, fmt: cstring, argp: Pointer): cstring{.
-    cdecl, dynlib: LUA_NAME, importc.}
-proc lua_pushfstring*(L: Plua_State, fmt: cstring): cstring{.cdecl, varargs, 
-    dynlib: LUA_NAME, importc.}
-proc lua_pushcclosure*(L: Plua_State, fn: lua_CFunction, n: int){.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_pushboolean*(L: Plua_State, b: cint){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushlightuserdata*(L: Plua_State, p: Pointer){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pushthread*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_gettable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_getfield*(L: Plua_state, idx: int, k: cstring){.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_rawget*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_rawgeti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_createtable*(L: Plua_State, narr, nrec: int){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_newuserdata*(L: Plua_State, sz: size_t): Pointer{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_getmetatable*(L: Plua_State, objindex: int): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_getfenv*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_settable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_setfield*(L: Plua_State, idx: int, k: cstring){.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_rawset*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_rawseti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_setmetatable*(L: Plua_State, objindex: int): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_setfenv*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_call*(L: Plua_State, nargs, nresults: int){.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_pcall*(L: Plua_State, nargs, nresults, errf: int): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_cpcall*(L: Plua_State, func: lua_CFunction, ud: Pointer): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_load*(L: Plua_State, reader: lua_Reader, dt: Pointer, 
-               chunkname: cstring): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_dump*(L: Plua_State, writer: lua_Writer, data: Pointer): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_yield*(L: Plua_State, nresults: int): int{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_resume*(L: Plua_State, narg: int): int{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_status*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_gc*(L: Plua_State, what, data: int): int{.cdecl, dynlib: LUA_NAME, 
-    importc.}
-proc lua_error*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_next*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_concat*(L: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_getallocf*(L: Plua_State, ud: ptr Pointer): lua_Alloc{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_setallocf*(L: Plua_State, f: lua_Alloc, ud: Pointer){.cdecl, 
-    dynlib: LUA_NAME, importc.}
-
-#
-#** Garbage-collection functions and options
-#
-const 
-  LUA_GCSTOP* = 0
-  LUA_GCRESTART* = 1
-  LUA_GCCOLLECT* = 2
-  LUA_GCCOUNT* = 3
-  LUA_GCCOUNTB* = 4
-  LUA_GCSTEP* = 5
-  LUA_GCSETPAUSE* = 6
-  LUA_GCSETSTEPMUL* = 7
-
-#
-#** ===============================================================
-#** some useful macros
-#** ===============================================================
-#
-
-proc lua_pop*(L: Plua_State, n: int)
-proc lua_newtable*(L: Plua_state)
-proc lua_register*(L: Plua_State, n: cstring, f: lua_CFunction)
-proc lua_pushcfunction*(L: Plua_State, f: lua_CFunction)
-proc lua_strlen*(L: Plua_state, i: int): size_t
-proc lua_isfunction*(L: Plua_State, n: int): bool
-proc lua_istable*(L: Plua_State, n: int): bool
-proc lua_islightuserdata*(L: Plua_State, n: int): bool
-proc lua_isnil*(L: Plua_State, n: int): bool
-proc lua_isboolean*(L: Plua_State, n: int): bool
-proc lua_isthread*(L: Plua_State, n: int): bool
-proc lua_isnone*(L: Plua_State, n: int): bool
-proc lua_isnoneornil*(L: Plua_State, n: int): bool
-proc lua_pushliteral*(L: Plua_State, s: cstring)
-proc lua_setglobal*(L: Plua_State, s: cstring)
-proc lua_getglobal*(L: Plua_State, s: cstring)
-proc lua_tostring*(L: Plua_State, i: int): cstring
-#
-#** compatibility macros and functions
-#
-proc lua_getregistry*(L: Plua_State)
-proc lua_getgccount*(L: Plua_State): int
-type 
-  lua_Chunkreader* = lua_Reader
-  lua_Chunkwriter* = lua_Writer
-  
-#
-#** ======================================================================
-#** Debug API
-#** ======================================================================
-#
-
-const 
-  LUA_HOOKCALL* = 0
-  LUA_HOOKRET* = 1
-  LUA_HOOKLINE* = 2
-  LUA_HOOKCOUNT* = 3
-  LUA_HOOKTAILRET* = 4
-
-const 
-  LUA_MASKCALL* = 1 shl Ord(LUA_HOOKCALL)
-  LUA_MASKRET* = 1 shl Ord(LUA_HOOKRET)
-  LUA_MASKLINE* = 1 shl Ord(LUA_HOOKLINE)
-  LUA_MASKCOUNT* = 1 shl Ord(LUA_HOOKCOUNT)
-
-const 
-  LUA_IDSIZE* = 60
-
-type 
-  lua_Debug*{.final.} = object  # activation record 
-    event*: int
-    name*: cstring            # (n) 
-    namewhat*: cstring        # (n) `global', `local', `field', `method' 
-    what*: cstring            # (S) `Lua', `C', `main', `tail'
-    source*: cstring          # (S) 
-    currentline*: int         # (l) 
-    nups*: int                # (u) number of upvalues 
-    linedefined*: int         # (S) 
-    lastlinedefined*: int     # (S) 
-    short_src*: array[0..LUA_IDSIZE - 1, Char] # (S) 
-                                               # private part 
-    i_ci*: int                # active function 
-  
-  Plua_Debug* = ptr lua_Debug
-  lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.}
-  
-#
-#** ======================================================================
-#** Debug API
-#** ======================================================================
-#
-
-proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_getinfo*(L: Plua_State, what: cstring, ar: Plua_Debug): int{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_getlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_setlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_getupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_setupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl, 
-    dynlib: LUA_NAME, importc.}
-proc lua_sethook*(L: Plua_State, func: lua_Hook, mask: int, count: int): int{.
-    cdecl, dynlib: LUA_NAME, importc.}
-proc lua_gethook*(L: Plua_State): lua_Hook{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_gethookmask*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
-proc lua_gethookcount*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.}
-# implementation
-
-proc lua_upvalueindex(I: int): int = 
-  Result = LUA_GLOBALSINDEX - i
-
-proc lua_pop(L: Plua_State, n: int) = 
-  lua_settop(L, - n - 1)
-
-proc lua_newtable(L: Plua_State) = 
-  lua_createtable(L, 0, 0)
-
-proc lua_register(L: Plua_State, n: cstring, f: lua_CFunction) = 
-  lua_pushcfunction(L, f)
-  lua_setglobal(L, n)
-
-proc lua_pushcfunction(L: Plua_State, f: lua_CFunction) = 
-  lua_pushcclosure(L, f, 0)
-
-proc lua_strlen(L: Plua_State, i: int): size_t = 
-  Result = lua_objlen(L, i)
-
-proc lua_isfunction(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TFUNCTION
-
-proc lua_istable(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TTABLE
-
-proc lua_islightuserdata(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TLIGHTUSERDATA
-
-proc lua_isnil(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TNIL
-
-proc lua_isboolean(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TBOOLEAN
-
-proc lua_isthread(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TTHREAD
-
-proc lua_isnone(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) == LUA_TNONE
-
-proc lua_isnoneornil(L: Plua_State, n: int): bool = 
-  Result = lua_type(L, n) <= 0
-
-proc lua_pushliteral(L: Plua_State, s: cstring) = 
-  lua_pushlstring(L, s, len(s))
-
-proc lua_setglobal(L: Plua_State, s: cstring) = 
-  lua_setfield(L, LUA_GLOBALSINDEX, s)
-
-proc lua_getglobal(L: Plua_State, s: cstring) = 
-  lua_getfield(L, LUA_GLOBALSINDEX, s)
-
-proc lua_tostring(L: Plua_State, i: int): cstring = 
-  Result = lua_tolstring(L, i, nil)
-
-proc lua_getregistry(L: Plua_State) = 
-  lua_pushvalue(L, LUA_REGISTRYINDEX)
-
-proc lua_getgccount(L: Plua_State): int = 
-  Result = lua_gc(L, LUA_GCCOUNT, 0)
diff --git a/lib/oldwrappers/lua/lualib.nim b/lib/oldwrappers/lua/lualib.nim
deleted file mode 100755
index df5d53101..000000000
--- a/lib/oldwrappers/lua/lualib.nim
+++ /dev/null
@@ -1,73 +0,0 @@
-#*****************************************************************************
-# *                                                                            *
-# *  File:        lualib.pas                                                   *
-# *  Authors:     TeCGraf           (C headers + actual Lua libraries)         *
-# *               Lavergne Thomas   (original translation to Pascal)           *
-# *               Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal)       *
-# *  Description: Standard Lua libraries                                       *
-# *                                                                            *
-# *****************************************************************************
-#
-#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
-#** Lua standard libraries
-#** See Copyright Notice in lua.h
-#
-#
-#** Translated to pascal by Lavergne Thomas
-#** Bug reports :
-#**    - thomas.lavergne@laposte.net
-#**   In french or in english
-#
-
-import lua
-
-const 
-  LUA_COLIBNAME* = "coroutine"
-  LUA_TABLIBNAME* = "table"
-  LUA_IOLIBNAME* = "io"
-  LUA_OSLIBNAME* = "os"
-  LUA_STRLINAME* = "string"
-  LUA_MATHLIBNAME* = "math"
-  LUA_DBLIBNAME* = "debug"
-  LUA_LOADLIBNAME* = "package"
-
-proc luaopen_base*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaopen_table*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaopen_io*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, importc.}
-proc luaopen_string*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaopen_math*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaopen_debug*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaopen_package*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, 
-    importc.}
-proc luaL_openlibs*(L: Plua_State){.cdecl, dynlib: LUA_LIB_NAME, importc.}
-  # compatibility code 
-proc lua_baselibopen*(L: Plua_State): Bool
-proc lua_tablibopen*(L: Plua_State): Bool
-proc lua_iolibopen*(L: Plua_State): Bool
-proc lua_strlibopen*(L: Plua_State): Bool
-proc lua_mathlibopen*(L: Plua_State): Bool
-proc lua_dblibopen*(L: Plua_State): Bool
-# implementation
-
-proc lua_baselibopen(L: Plua_State): Bool = 
-  Result = luaopen_base(L) != 0'i32
-
-proc lua_tablibopen(L: Plua_State): Bool = 
-  Result = luaopen_table(L) != 0'i32
-
-proc lua_iolibopen(L: Plua_State): Bool = 
-  Result = luaopen_io(L) != 0'i32
-
-proc lua_strlibopen(L: Plua_State): Bool = 
-  Result = luaopen_string(L) != 0'i32
-
-proc lua_mathlibopen(L: Plua_State): Bool = 
-  Result = luaopen_math(L) != 0'i32
-
-proc lua_dblibopen(L: Plua_State): Bool = 
-  Result = luaopen_debug(L) != 0'i32
diff --git a/lib/oldwrappers/mysql.nim b/lib/oldwrappers/mysql.nim
deleted file mode 100755
index e94afb1a2..000000000
--- a/lib/oldwrappers/mysql.nim
+++ /dev/null
@@ -1,1154 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-{.deadCodeElim: on.}
-
-when defined(Unix): 
-  const 
-    mysqllib = "libmysqlclient.so.15"
-
-# mysqllib = "libmysqlclient.so.15"
-when defined(Windows): 
-  const
-    mysqllib = "libmysql.dll"
-    
-# Copyright (C) 2000-2003 MySQL AB
-#  
-#     This program is free software; you can redistribute it and/or modify
-#     it under the terms of the GNU General Public License as published by
-#     the Free Software Foundation; either version 2 of the License, or
-#     (at your option) any later version.
-#  
-#     This program 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 General Public License for more details.
-#  
-#     You should have received a copy of the GNU General Public License
-#     along with this program; if not, write to the Free Software
-#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
-
-type 
-  my_bool* = bool
-  Pmy_bool* = ptr my_bool
-  PVIO* = Pointer
-  Pgptr* = ptr gptr
-  gptr* = cstring
-  Pmy_socket* = ptr my_socket
-  my_socket* = cint
-  PPByte* = pointer 
-  cuint* = cint
-  
-#  ------------ Start of declaration in "mysql_com.h"   ---------------------  
-#
-#  ** Common definition between mysql server & client
-#   
-# Field/table name length
-
-const 
-  NAME_LEN* = 64
-  HOSTNAME_LENGTH* = 60
-  USERNAME_LENGTH* = 16
-  SERVER_VERSION_LENGTH* = 60
-  SQLSTATE_LENGTH* = 5
-  LOCAL_HOST* = "localhost"
-  LOCAL_HOST_NAMEDPIPE* = '.'
-
-const 
-  MYSQL_NAMEDPIPE* = "MySQL"
-  MYSQL_SERVICENAME* = "MySQL"
-
-type 
-  enum_server_command* = enum     
-    COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, COM_CREATE_DB, 
-    COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, COM_PROCESS_INFO, 
-    COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, COM_TIME, 
-    COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, COM_TABLE_DUMP, 
-    COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_STMT_PREPARE, COM_STMT_EXECUTE, 
-    COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, COM_STMT_RESET, COM_SET_OPTION, 
-    COM_STMT_FETCH, COM_END
-
-const 
-  SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake; 
-                        # this is also length of obfuscated password, 
-                        # recieved from client
-  SCRAMBLE_LENGTH_323* = 8 # length of password stored in the db: 
-                           # new passwords are preceeded with '*'  
-  SCRAMBLED_PASSWORD_CHAR_LENGTH* = SCRAMBLE_LENGTH * 2 + 1
-  SCRAMBLED_PASSWORD_CHAR_LENGTH_323* = SCRAMBLE_LENGTH_323 * 2
-  NOT_NULL_FLAG* = 1          #  Field can't be NULL
-  PRI_KEY_FLAG* = 2           #  Field is part of a primary key
-  UNIQUE_KEY_FLAG* = 4        #  Field is part of a unique key
-  MULTIPLE_KEY_FLAG* = 8      #  Field is part of a key
-  BLOB_FLAG* = 16             #  Field is a blob
-  UNSIGNED_FLAG* = 32         #  Field is unsigned
-  ZEROFILL_FLAG* = 64         #  Field is zerofill
-  BINARY_FLAG* = 128          #  Field is binary
-                              # The following are only sent to new clients  
-  ENUM_FLAG* = 256            # field is an enum
-  AUTO_INCREMENT_FLAG* = 512  # field is a autoincrement field
-  TIMESTAMP_FLAG* = 1024      # Field is a timestamp
-  SET_FLAG* = 2048            # field is a set
-  NO_DEFAULT_VALUE_FLAG* = 4096 # Field doesn't have default value
-  NUM_FLAG* = 32768           # Field is num (for clients)
-  PART_KEY_FLAG* = 16384      # Intern; Part of some key
-  GROUP_FLAG* = 32768         # Intern: Group field
-  UNIQUE_FLAG* = 65536        # Intern: Used by sql_yacc
-  BINCMP_FLAG* = 131072       # Intern: Used by sql_yacc
-  REFRESH_GRANT* = 1          # Refresh grant tables
-  REFRESH_LOG* = 2            # Start on new log file
-  REFRESH_TABLES* = 4         # close all tables
-  REFRESH_HOSTS* = 8          # Flush host cache
-  REFRESH_STATUS* = 16        # Flush status variables
-  REFRESH_THREADS* = 32       # Flush thread cache
-  REFRESH_SLAVE* = 64         # Reset master info and restart slave thread
-  REFRESH_MASTER* = 128 # Remove all bin logs in the index and truncate the index
-                        # The following can't be set with mysql_refresh()  
-  REFRESH_READ_LOCK* = 16384  # Lock tables for read
-  REFRESH_FAST* = 32768       # Intern flag
-  REFRESH_QUERY_CACHE* = 65536 # RESET (remove all queries) from query cache
-  REFRESH_QUERY_CACHE_FREE* = 0x00020000 # pack query cache
-  REFRESH_DES_KEY_FILE* = 0x00040000
-  REFRESH_USER_RESOURCES* = 0x00080000
-  CLIENT_LONG_PASSWORD* = 1   # new more secure passwords
-  CLIENT_FOUND_ROWS* = 2      # Found instead of affected rows
-  CLIENT_LONG_FLAG* = 4       # Get all column flags
-  CLIENT_CONNECT_WITH_DB* = 8 # One can specify db on connect
-  CLIENT_NO_SCHEMA* = 16      # Don't allow database.table.column
-  CLIENT_COMPRESS* = 32       # Can use compression protocol
-  CLIENT_ODBC* = 64           # Odbc client
-  CLIENT_LOCAL_FILES* = 128   # Can use LOAD DATA LOCAL
-  CLIENT_IGNORE_SPACE* = 256  # Ignore spaces before '('
-  CLIENT_PROTOCOL_41* = 512   # New 4.1 protocol
-  CLIENT_INTERACTIVE* = 1024  # This is an interactive client
-  CLIENT_SSL* = 2048          # Switch to SSL after handshake
-  CLIENT_IGNORE_SIGPIPE* = 4096 # IGNORE sigpipes
-  CLIENT_TRANSACTIONS* = 8192 # Client knows about transactions
-  CLIENT_RESERVED* = 16384    # Old flag for 4.1 protocol
-  CLIENT_SECURE_CONNECTION* = 32768 # New 4.1 authentication
-  CLIENT_MULTI_STATEMENTS* = 65536 # Enable/disable multi-stmt support
-  CLIENT_MULTI_RESULTS* = 131072 # Enable/disable multi-results
-  CLIENT_REMEMBER_OPTIONS*: int = 1 shl 31
-  SERVER_STATUS_IN_TRANS* = 1 # Transaction has started
-  SERVER_STATUS_AUTOCOMMIT* = 2 # Server in auto_commit mode
-  SERVER_STATUS_MORE_RESULTS* = 4 # More results on server
-  SERVER_MORE_RESULTS_EXISTS* = 8 # Multi query - next query exists
-  SERVER_QUERY_NO_GOOD_INDEX_USED* = 16
-  SERVER_QUERY_NO_INDEX_USED* = 32 # The server was able to fulfill the clients request and opened a
-                                   #      read-only non-scrollable cursor for a query. This flag comes
-                                   #      in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. 
-  SERVER_STATUS_CURSOR_EXISTS* = 64 # This flag is sent when a read-only cursor is exhausted, in reply to
-                                    #      COM_STMT_FETCH command. 
-  SERVER_STATUS_LAST_ROW_SENT* = 128
-  SERVER_STATUS_DB_DROPPED* = 256 # A database was dropped
-  SERVER_STATUS_NO_BACKSLASH_ESCAPES* = 512
-  MYSQL_ERRMSG_SIZE* = 200
-  NET_READ_TIMEOUT* = 30      # Timeout on read
-  NET_WRITE_TIMEOUT* = 60     # Timeout on write
-  NET_WAIT_TIMEOUT* = 8 * 60 * 60 # Wait for new query
-  ONLY_KILL_QUERY* = 1
-
-const 
-  MAX_TINYINT_WIDTH* = 3      # Max width for a TINY w.o. sign
-  MAX_SMALLINT_WIDTH* = 5     # Max width for a SHORT w.o. sign
-  MAX_MEDIUMINT_WIDTH* = 8    # Max width for a INT24 w.o. sign
-  MAX_INT_WIDTH* = 10         # Max width for a LONG w.o. sign
-  MAX_BIGINT_WIDTH* = 20      # Max width for a LONGLONG
-  MAX_CHAR_WIDTH* = 255       # Max length for a CHAR colum
-  MAX_BLOB_WIDTH* = 8192      # Default width for blob
-
-type 
-  Pst_net* = ptr st_net
-  st_net*{.final.} = object
-    vio*: PVio
-    buff*: cstring
-    buff_end*: cstring
-    write_pos*: cstring
-    read_pos*: cstring
-    fd*: my_socket            # For Perl DBI/dbd
-    max_packet*: int
-    max_packet_size*: int
-    pkt_nr*: cuint
-    compress_pkt_nr*: cuint
-    write_timeout*: cuint
-    read_timeout*: cuint
-    retry_count*: cuint
-    fcntl*: cint
-    compress*: my_bool #   The following variable is set if we are doing several queries in one
-                       #        command ( as in LOAD TABLE ... FROM MASTER ),
-                       #        and do not want to confuse the client with OK at the wrong time 
-    remain_in_buf*: int
-    len*: int
-    buf_length*: int
-    where_b*: int
-    return_status*: ptr cint
-    reading_or_writing*: char
-    save_char*: cchar
-    no_send_ok*: my_bool      # For SPs and other things that do multiple stmts
-    no_send_eof*: my_bool     # For SPs' first version read-only cursors
-    no_send_error*: my_bool # Set if OK packet is already sent, and
-                            # we do not need to send error messages
-                            #   Pointer to query object in query cache, do not equal NULL (0) for
-                            #        queries in cache that have not stored its results yet 
-                            # $endif
-    last_error*: array[0..(MYSQL_ERRMSG_SIZE) - 1, char]
-    sqlstate*: array[0..(SQLSTATE_LENGTH + 1) - 1, char]
-    last_errno*: cuint
-    error*: char
-    query_cache_query*: gptr
-    report_error*: my_bool    # We should report error (we have unreported error)
-    return_errno*: my_bool
-
-  NET* = st_net
-  PNET* = ptr NET
-
-const 
-  packet_error* = -1
-
-type 
-  enum_field_types* = enum    # For backward compatibility  
-    MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, 
-    MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, 
-    MYSQL_TYPE_LONGLONG, MYSQL_TYPE_INT24, MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, 
-    MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, MYSQL_TYPE_NEWDATE, 
-    MYSQL_TYPE_VARCHAR, MYSQL_TYPE_BIT, MYSQL_TYPE_NEWDECIMAL = 246, 
-    MYSQL_TYPE_ENUM = 247, MYSQL_TYPE_SET = 248, MYSQL_TYPE_TINY_BLOB = 249, 
-    MYSQL_TYPE_MEDIUM_BLOB = 250, MYSQL_TYPE_LONG_BLOB = 251, 
-    MYSQL_TYPE_BLOB = 252, MYSQL_TYPE_VAR_STRING = 253, MYSQL_TYPE_STRING = 254, 
-    MYSQL_TYPE_GEOMETRY = 255
-
-const 
-  CLIENT_MULTI_QUERIES* = CLIENT_MULTI_STATEMENTS
-  FIELD_TYPE_DECIMAL* = MYSQL_TYPE_DECIMAL
-  FIELD_TYPE_NEWDECIMAL* = MYSQL_TYPE_NEWDECIMAL
-  FIELD_TYPE_TINY* = MYSQL_TYPE_TINY
-  FIELD_TYPE_SHORT* = MYSQL_TYPE_SHORT
-  FIELD_TYPE_LONG* = MYSQL_TYPE_LONG
-  FIELD_TYPE_FLOAT* = MYSQL_TYPE_FLOAT
-  FIELD_TYPE_DOUBLE* = MYSQL_TYPE_DOUBLE
-  FIELD_TYPE_NULL* = MYSQL_TYPE_NULL
-  FIELD_TYPE_TIMESTAMP* = MYSQL_TYPE_TIMESTAMP
-  FIELD_TYPE_LONGLONG* = MYSQL_TYPE_LONGLONG
-  FIELD_TYPE_INT24* = MYSQL_TYPE_INT24
-  FIELD_TYPE_DATE* = MYSQL_TYPE_DATE
-  FIELD_TYPE_TIME* = MYSQL_TYPE_TIME
-  FIELD_TYPE_DATETIME* = MYSQL_TYPE_DATETIME
-  FIELD_TYPE_YEAR* = MYSQL_TYPE_YEAR
-  FIELD_TYPE_NEWDATE* = MYSQL_TYPE_NEWDATE
-  FIELD_TYPE_ENUM* = MYSQL_TYPE_ENUM
-  FIELD_TYPE_SET* = MYSQL_TYPE_SET
-  FIELD_TYPE_TINY_BLOB* = MYSQL_TYPE_TINY_BLOB
-  FIELD_TYPE_MEDIUM_BLOB* = MYSQL_TYPE_MEDIUM_BLOB
-  FIELD_TYPE_LONG_BLOB* = MYSQL_TYPE_LONG_BLOB
-  FIELD_TYPE_BLOB* = MYSQL_TYPE_BLOB
-  FIELD_TYPE_VAR_STRING* = MYSQL_TYPE_VAR_STRING
-  FIELD_TYPE_STRING* = MYSQL_TYPE_STRING
-  FIELD_TYPE_CHAR* = MYSQL_TYPE_TINY
-  FIELD_TYPE_INTERVAL* = MYSQL_TYPE_ENUM
-  FIELD_TYPE_GEOMETRY* = MYSQL_TYPE_GEOMETRY
-  FIELD_TYPE_BIT* = MYSQL_TYPE_BIT # Shutdown/kill enums and constants  
-                                   # Bits for THD::killable.  
-  MYSQL_SHUTDOWN_KILLABLE_CONNECT* = chr(1 shl 0)
-  MYSQL_SHUTDOWN_KILLABLE_TRANS* = chr(1 shl 1)
-  MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE* = chr(1 shl 2)
-  MYSQL_SHUTDOWN_KILLABLE_UPDATE* = chr(1 shl 3)
-  
-type 
-  mysql_enum_shutdown_level* = enum 
-    SHUTDOWN_DEFAULT = 0, SHUTDOWN_WAIT_CONNECTIONS = 1,  
-    SHUTDOWN_WAIT_TRANSACTIONS = 2,  
-    SHUTDOWN_WAIT_UPDATES = 8,  
-    SHUTDOWN_WAIT_ALL_BUFFERS = 16, 
-    SHUTDOWN_WAIT_CRITICAL_BUFFERS = 17,  
-    KILL_QUERY = 254,        
-    KILL_CONNECTION = 255
-  enum_cursor_type* = enum    # options for mysql_set_option  
-    CURSOR_TYPE_NO_CURSOR = 0, CURSOR_TYPE_READ_ONLY = 1, 
-    CURSOR_TYPE_FOR_UPDATE = 2, CURSOR_TYPE_SCROLLABLE = 4
-  enum_mysql_set_option* = enum 
-    MYSQL_OPTION_MULTI_STATEMENTS_ON, MYSQL_OPTION_MULTI_STATEMENTS_OFF
-
-proc net_new_transaction*(net: st_net): st_net
-proc my_net_init*(net: PNET, vio: PVio): my_bool{.cdecl, dynlib: mysqllib, 
-    importc: "my_net_init".}
-proc my_net_local_init*(net: PNET){.cdecl, dynlib: mysqllib, 
-                                    importc: "my_net_local_init".}
-proc net_end*(net: PNET){.cdecl, dynlib: mysqllib, importc: "net_end".}
-proc net_clear*(net: PNET){.cdecl, dynlib: mysqllib, importc: "net_clear".}
-proc net_realloc*(net: PNET, len: int): my_bool{.cdecl, dynlib: mysqllib, 
-    importc: "net_realloc".}
-proc net_flush*(net: PNET): my_bool{.cdecl, dynlib: mysqllib, 
-                                     importc: "net_flush".}
-proc my_net_write*(net: PNET, packet: cstring, length: int): my_bool{.cdecl, 
-    dynlib: mysqllib, importc: "my_net_write".}
-proc net_write_command*(net: PNET, command: char, header: cstring, 
-                        head_len: int, packet: cstring, length: int): my_bool{.
-    cdecl, dynlib: mysqllib, importc: "net_write_command".}
-proc net_real_write*(net: PNET, packet: cstring, length: int): cint{.cdecl, 
-    dynlib: mysqllib, importc: "net_real_write".}
-proc my_net_read*(net: PNET): int{.cdecl, dynlib: mysqllib, 
-                                      importc: "my_net_read".}
-  # The following function is not meant for normal usage
-  #      Currently it's used internally by manager.c  
-type 
-  Psockaddr* = ptr sockaddr
-  sockaddr*{.final.} = object  # undefined structure
-
-proc my_connect*(s: my_socket, name: Psockaddr, namelen: cuint, timeout: cuint): cint{.
-    cdecl, dynlib: mysqllib, importc: "my_connect".}
-type 
-  Prand_struct* = ptr rand_struct
-  rand_struct*{.final.} = object  # The following is for user defined functions  
-    seed1*: int
-    seed2*: int
-    max_value*: int
-    max_value_dbl*: cdouble
-
-  Item_result* = enum 
-    STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT
-  PItem_result* = ptr Item_result
-  Pst_udf_args* = ptr st_udf_args
-  st_udf_args*{.final.} = object 
-    arg_count*: cuint         # Number of arguments
-    arg_type*: PItem_result   # Pointer to item_results
-    args*: cstringArray             # Pointer to item_results
-    lengths*: ptr int         # Length of string arguments
-    maybe_null*: cstring      # Length of string arguments
-    attributes*: cstringArray       # Pointer to attribute name
-    attribute_lengths*: ptr int # Length of attribute arguments
-  
-  UDF_ARGS* = st_udf_args
-  PUDF_ARGS* = ptr UDF_ARGS   # This holds information about the result  
-  Pst_udf_init* = ptr st_udf_init
-  st_udf_init*{.final.} = object 
-    maybe_null*: my_bool      # 1 if function can return NULL
-    decimals*: cuint          # for real functions
-    max_length*: int          # For string functions
-    theptr*: cstring          # free pointer for function data
-    const_item*: my_bool      # free pointer for function data
-  
-  UDF_INIT* = st_udf_init
-  PUDF_INIT* = ptr UDF_INIT   # Constants when using compression  
-
-const 
-  NET_HEADER_SIZE* = 4        # standard header size
-  COMP_HEADER_SIZE* = 3 # compression header extra size
-                        # Prototypes to password functions  
-                        # These functions are used for authentication by client and server and
-                        #      implemented in sql/password.c     
-
-proc randominit*(para1: Prand_struct, seed1: int, seed2: int){.cdecl, 
-    dynlib: mysqllib, importc: "randominit".}
-proc my_rnd*(para1: Prand_struct): cdouble{.cdecl, dynlib: mysqllib, 
-    importc: "my_rnd".}
-proc create_random_string*(fto: cstring, len: cuint, rand_st: Prand_struct){.
-    cdecl, dynlib: mysqllib, importc: "create_random_string".}
-proc hash_password*(fto: int, password: cstring, password_len: cuint){.cdecl, 
-    dynlib: mysqllib, importc: "hash_password".}
-proc make_scrambled_password_323*(fto: cstring, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "make_scrambled_password_323".}
-proc scramble_323*(fto: cstring, message: cstring, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "scramble_323".}
-proc check_scramble_323*(para1: cstring, message: cstring, salt: int): my_bool{.
-    cdecl, dynlib: mysqllib, importc: "check_scramble_323".}
-proc get_salt_from_password_323*(res: ptr int, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "get_salt_from_password_323".}
-proc make_password_from_salt_323*(fto: cstring, salt: ptr int){.cdecl, 
-    dynlib: mysqllib, importc: "make_password_from_salt_323".}
-proc octet2hex*(fto: cstring, str: cstring, length: cuint): cstring{.cdecl, 
-    dynlib: mysqllib, importc: "octet2hex".}
-proc make_scrambled_password*(fto: cstring, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "make_scrambled_password".}
-proc scramble*(fto: cstring, message: cstring, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "scramble".}
-proc check_scramble*(reply: cstring, message: cstring, hash_stage2: pointer): my_bool{.
-    cdecl, dynlib: mysqllib, importc: "check_scramble".}
-proc get_salt_from_password*(res: pointer, password: cstring){.cdecl, 
-    dynlib: mysqllib, importc: "get_salt_from_password".}
-proc make_password_from_salt*(fto: cstring, hash_stage2: pointer){.cdecl, 
-    dynlib: mysqllib, importc: "make_password_from_salt".}
-  # end of password.c  
-proc get_tty_password*(opt_message: cstring): cstring{.cdecl, dynlib: mysqllib, 
-    importc: "get_tty_password".}
-proc mysql_errno_to_sqlstate*(mysql_errno: cuint): cstring{.cdecl, 
-    dynlib: mysqllib, importc: "mysql_errno_to_sqlstate".}
-  # Some other useful functions  
-proc modify_defaults_file*(file_location: cstring, option: cstring, 
-                           option_value: cstring, section_name: cstring, 
-                           remove_option: cint): cint{.cdecl, dynlib: mysqllib, 
-    importc: "load_defaults".}
-proc load_defaults*(conf_file: cstring, groups: cstringArray, argc: ptr cint, 
-                    argv: ptr cstringArray): cint{.cdecl, dynlib: mysqllib, 
-    importc: "load_defaults".}
-proc my_init*(): my_bool{.cdecl, dynlib: mysqllib, importc: "my_init".}
-proc my_thread_init*(): my_bool{.cdecl, dynlib: mysqllib, 
-                                 importc: "my_thread_init".}
-proc my_thread_end*(){.cdecl, dynlib: mysqllib, importc: "my_thread_end".}
-const 
-  NULL_LENGTH*: int = int(not (0)) # For net_store_length
-
-const 
-  MYSQL_STMT_HEADER* = 4
-  MYSQL_LONG_DATA_HEADER* = 6 #  ------------ Stop of declaration in "mysql_com.h"   -----------------------  
-                              # $include "mysql_time.h"
-                              # $include "mysql_version.h"
-                              # $include "typelib.h"
-                              # $include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
-                              #      var
-                              #         mysql_port : cuint;cvar;external;
-                              #         mysql_unix_port : Pchar;cvar;external;
-
-const 
-  CLIENT_NET_READ_TIMEOUT* = 365 * 24 * 3600 # Timeout on read
-  CLIENT_NET_WRITE_TIMEOUT* = 365 * 24 * 3600 # Timeout on write
-
-type 
-  Pst_mysql_field* = ptr st_mysql_field
-  st_mysql_field*{.final.} = object 
-    name*: cstring            # Name of column
-    org_name*: cstring        # Original column name, if an alias
-    table*: cstring           # Table of column if column was a field
-    org_table*: cstring       # Org table name, if table was an alias
-    db*: cstring              # Database for table
-    catalog*: cstring         # Catalog for table
-    def*: cstring             # Default value (set by mysql_list_fields)
-    len*: int              # Width of column (create length)
-    max_length*: int       # Max width for selected set
-    name_length*: cuint
-    org_name_length*: cuint
-    table_length*: cuint
-    org_table_length*: cuint
-    db_length*: cuint
-    catalog_length*: cuint
-    def_length*: cuint
-    flags*: cuint             # Div flags
-    decimals*: cuint          # Number of decimals in field
-    charsetnr*: cuint         # Character set
-    ftype*: enum_field_types  # Type of field. See mysql_com.h for types
-  
-  MYSQL_FIELD* = st_mysql_field
-  PMYSQL_FIELD* = ptr MYSQL_FIELD
-  PMYSQL_ROW* = ptr MYSQL_ROW # return data as array of strings
-  MYSQL_ROW* = cstringArray
-  PMYSQL_FIELD_OFFSET* = ptr MYSQL_FIELD_OFFSET # offset to current field
-  MYSQL_FIELD_OFFSET* = cuint
-
-proc IS_PRI_KEY*(n: int32): bool
-proc IS_NOT_NULL*(n: int32): bool
-proc IS_BLOB*(n: int32): bool
-proc IS_NUM*(t: enum_field_types): bool
-proc INTERNAL_NUM_FIELD*(f: Pst_mysql_field): bool
-proc IS_NUM_FIELD*(f: Pst_mysql_field): bool
-
-type 
-  my_ulonglong* = int64
-  Pmy_ulonglong* = ptr my_ulonglong
-
-const 
-  MYSQL_COUNT_ERROR* = not (my_ulonglong(0))
-
-type 
-  Pst_mysql_rows* = ptr st_mysql_rows
-  st_mysql_rows*{.final.} = object 
-    next*: Pst_mysql_rows     # list of rows
-    data*: MYSQL_ROW
-    len*: int
-
-  MYSQL_ROWS* = st_mysql_rows
-  PMYSQL_ROWS* = ptr MYSQL_ROWS
-  PMYSQL_ROW_OFFSET* = ptr MYSQL_ROW_OFFSET # offset to current row
-  MYSQL_ROW_OFFSET* = MYSQL_ROWS #  ------------ Start of declaration in "my_alloc.h"     --------------------  
-                                 # $include "my_alloc.h"
-
-const 
-  ALLOC_MAX_BLOCK_TO_DROP* = 4096
-  ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP* = 10 # struct for once_alloc (block)  
-
-type 
-  Pst_used_mem* = ptr st_used_mem
-  st_used_mem*{.final.} = object 
-    next*: Pst_used_mem       # Next block in use
-    left*: cuint              # memory left in block
-    size*: cuint              # size of block
-  
-  USED_MEM* = st_used_mem
-  PUSED_MEM* = ptr USED_MEM
-  Pst_mem_root* = ptr st_mem_root
-  st_mem_root*{.final.} = object 
-    free*: PUSED_MEM          # blocks with free memory in it
-    used*: PUSED_MEM          # blocks almost without free memory
-    pre_alloc*: PUSED_MEM     # preallocated block
-    min_malloc*: cuint        # if block have less memory it will be put in 'used' list
-    block_size*: cuint        # initial block size
-    block_num*: cuint # allocated blocks counter
-                      #    first free block in queue test counter (if it exceed
-                      #       MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)     
-    first_block_usage*: cuint
-    error_handler*: proc (){.cdecl.}
-
-  MEM_ROOT* = st_mem_root
-  PMEM_ROOT* = ptr MEM_ROOT   #  ------------ Stop of declaration in "my_alloc.h"    ----------------------  
-
-type 
-  Pst_mysql_data* = ptr st_mysql_data
-  st_mysql_data*{.final.} = object 
-    rows*: my_ulonglong
-    fields*: cuint
-    data*: PMYSQL_ROWS
-    alloc*: MEM_ROOT
-    prev_ptr*: ptr PMYSQL_ROWS
-
-  MYSQL_DATA* = st_mysql_data
-  PMYSQL_DATA* = ptr MYSQL_DATA
-  mysql_option* = enum 
-    MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, 
-    MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, 
-    MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, 
-    MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, 
-    MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, 
-    MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 
-    MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, 
-    MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT
-
-const 
-  MAX_MYSQL_MANAGER_ERR* = 256
-  MAX_MYSQL_MANAGER_MSG* = 256
-  MANAGER_OK* = 200
-  MANAGER_INFO* = 250
-  MANAGER_ACCESS* = 401
-  MANAGER_CLIENT_ERR* = 450
-  MANAGER_INTERNAL_ERR* = 500
-
-type 
-  st_dynamic_array*{.final.} = object 
-    buffer*: cstring
-    elements*: cuint
-    max_element*: cuint
-    alloc_increment*: cuint
-    size_of_element*: cuint
-
-  DYNAMIC_ARRAY* = st_dynamic_array
-  Pst_dynamic_array* = ptr st_dynamic_array
-  Pst_mysql_options* = ptr st_mysql_options
-  st_mysql_options*{.final.} = object 
-    connect_timeout*: cuint
-    read_timeout*: cuint
-    write_timeout*: cuint
-    port*: cuint
-    protocol*: cuint
-    client_flag*: int
-    host*: cstring
-    user*: cstring
-    password*: cstring
-    unix_socket*: cstring
-    db*: cstring
-    init_commands*: Pst_dynamic_array
-    my_cnf_file*: cstring
-    my_cnf_group*: cstring
-    charset_dir*: cstring
-    charset_name*: cstring
-    ssl_key*: cstring         # PEM key file
-    ssl_cert*: cstring        # PEM cert file
-    ssl_ca*: cstring          # PEM CA file
-    ssl_capath*: cstring      # PEM directory of CA-s?
-    ssl_cipher*: cstring      # cipher to use
-    shared_memory_base_name*: cstring
-    max_allowed_packet*: int
-    use_ssl*: my_bool         # if to use SSL or not
-    compress*: my_bool
-    named_pipe*: my_bool #  On connect, find out the replication role of the server, and
-                         #       establish connections to all the peers  
-    rpl_probe*: my_bool #  Each call to mysql_real_query() will parse it to tell if it is a read
-                        #       or a write, and direct it to the slave or the master      
-    rpl_parse*: my_bool #  If set, never read from a master, only from slave, when doing
-                        #       a read that is replication-aware    
-    no_master_reads*: my_bool
-    separate_thread*: my_bool
-    methods_to_use*: mysql_option
-    client_ip*: cstring
-    secure_auth*: my_bool     # Refuse client connecting to server if it uses old (pre-4.1.1) protocol
-    report_data_truncation*: my_bool # 0 - never report, 1 - always report (default)
-                                     # function pointers for local infile support  
-    local_infile_init*: proc (para1: var pointer, para2: cstring, para3: pointer): cint{.
-        cdecl.}
-    local_infile_read*: proc (para1: pointer, para2: cstring, para3: cuint): cint
-    local_infile_end*: proc (para1: pointer)
-    local_infile_error*: proc (para1: pointer, para2: cstring, para3: cuint): cint
-    local_infile_userdata*: pointer
-
-  mysql_status* = enum 
-    MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT
-  mysql_protocol_type* = enum  # There are three types of queries - the ones that have to go to
-                               #      the master, the ones that go to a slave, and the adminstrative
-                               #      type which must happen on the pivot connectioin 
-    MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, 
-    MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
-  mysql_rpl_type* = enum 
-    MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
-  charset_info_st*{.final.} = object 
-    number*: cuint
-    primary_number*: cuint
-    binary_number*: cuint
-    state*: cuint
-    csname*: cstring
-    name*: cstring
-    comment*: cstring
-    tailoring*: cstring
-    ftype*: cstring
-    to_lower*: cstring
-    to_upper*: cstring
-    sort_order*: cstring
-    contractions*: ptr int16
-    sort_order_big*: ptr ptr int16
-    tab_to_uni*: ptr int16
-    tab_from_uni*: pointer    # was ^MY_UNI_IDX
-    state_map*: cstring
-    ident_map*: cstring
-    strxfrm_multiply*: cuint
-    mbminlen*: cuint
-    mbmaxlen*: cuint
-    min_sort_char*: int16
-    max_sort_char*: int16
-    escape_with_backslash_is_dangerous*: my_bool
-    cset*: pointer            # was ^MY_CHARSET_HANDLER
-    coll*: pointer            # was ^MY_COLLATION_HANDLER;
-  
-  CHARSET_INFO* = charset_info_st
-  Pcharset_info_st* = ptr charset_info_st
-  Pcharacter_set* = ptr character_set
-  character_set*{.final.} = object 
-    number*: cuint
-    state*: cuint
-    csname*: cstring
-    name*: cstring
-    comment*: cstring
-    dir*: cstring
-    mbminlen*: cuint
-    mbmaxlen*: cuint
-
-  MY_CHARSET_INFO* = character_set
-  PMY_CHARSET_INFO* = ptr MY_CHARSET_INFO
-  Pst_mysql_methods* = ptr st_mysql_methods
-  Pst_mysql* = ptr st_mysql
-  st_mysql*{.final.} = object 
-    net*: NET                 # Communication parameters
-    connector_fd*: gptr       # ConnectorFd for SSL
-    host*: cstring
-    user*: cstring
-    passwd*: cstring
-    unix_socket*: cstring
-    server_version*: cstring
-    host_info*: cstring
-    info*: cstring
-    db*: cstring
-    charset*: Pcharset_info_st
-    fields*: PMYSQL_FIELD
-    field_alloc*: MEM_ROOT
-    affected_rows*: my_ulonglong
-    insert_id*: my_ulonglong  # id if insert on table with NEXTNR
-    extra_info*: my_ulonglong # Used by mysqlshow, not used by mysql 5.0 and up
-    thread_id*: int        # Id for connection in server
-    packet_length*: int
-    port*: cuint
-    client_flag*: int
-    server_capabilities*: int
-    protocol_version*: cuint
-    field_count*: cuint
-    server_status*: cuint
-    server_language*: cuint
-    warning_count*: cuint
-    options*: st_mysql_options
-    status*: mysql_status
-    free_me*: my_bool         # If free in mysql_close
-    reconnect*: my_bool       # set to 1 if automatic reconnect
-    scramble*: array[0..(SCRAMBLE_LENGTH + 1) - 1, char] # session-wide random string
-                                                         #  Set if this is the original connection, not a master or a slave we have
-                                                         #       added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()      
-    rpl_pivot*: my_bool #   Pointers to the master, and the next slave connections, points to
-                        #        itself if lone connection.       
-    master*: Pst_mysql
-    next_slave*: Pst_mysql
-    last_used_slave*: Pst_mysql # needed for round-robin slave pick
-    last_used_con*: Pst_mysql # needed for send/read/store/use result to work correctly with replication
-    stmts*: Pointer           # was PList, list of all statements
-    methods*: Pst_mysql_methods
-    thd*: pointer #   Points to boolean flag in MYSQL_RES  or MYSQL_STMT. We set this flag
-                  #        from mysql_stmt_close if close had to cancel result set of this object.       
-    unbuffered_fetch_owner*: Pmy_bool
-
-  MYSQL* = st_mysql
-  PMYSQL* = ptr MYSQL
-  Pst_mysql_res* = ptr st_mysql_res
-  st_mysql_res*{.final.} = object 
-    row_count*: my_ulonglong
-    fields*: PMYSQL_FIELD
-    data*: PMYSQL_DATA
-    data_cursor*: PMYSQL_ROWS
-    lengths*: ptr int         # column lengths of current row
-    handle*: PMYSQL           # for unbuffered reads
-    field_alloc*: MEM_ROOT
-    field_count*: cuint
-    current_field*: cuint
-    row*: MYSQL_ROW           # If unbuffered read
-    current_row*: MYSQL_ROW   # buffer to current row
-    eof*: my_bool             # Used by mysql_fetch_row
-    unbuffered_fetch_cancelled*: my_bool # mysql_stmt_close() had to cancel this result
-    methods*: Pst_mysql_methods
-
-  MYSQL_RES* = st_mysql_res
-  PMYSQL_RES* = ptr MYSQL_RES
-  Pst_mysql_stmt* = ptr st_mysql_stmt
-  PMYSQL_STMT* = ptr MYSQL_STMT
-  st_mysql_methods*{.final.} = object 
-    read_query_result*: proc (mysql: PMYSQL): my_bool{.cdecl.}
-    advanced_command*: proc (mysql: PMYSQL, command: enum_server_command, 
-                             header: cstring, header_length: int, 
-                             arg: cstring, arg_length: int, 
-                             skip_check: my_bool): my_bool
-    read_rows*: proc (mysql: PMYSQL, mysql_fields: PMYSQL_FIELD, fields: cuint): PMYSQL_DATA
-    use_result*: proc (mysql: PMYSQL): PMYSQL_RES
-    fetch_lengths*: proc (fto: ptr int, column: MYSQL_ROW, field_count: cuint)
-    flush_use_result*: proc (mysql: PMYSQL)
-    list_fields*: proc (mysql: PMYSQL): PMYSQL_FIELD
-    read_prepare_result*: proc (mysql: PMYSQL, stmt: PMYSQL_STMT): my_bool
-    stmt_execute*: proc (stmt: PMYSQL_STMT): cint
-    read_binary_rows*: proc (stmt: PMYSQL_STMT): cint
-    unbuffered_fetch*: proc (mysql: PMYSQL, row: cstringArray): cint
-    free_embedded_thd*: proc (mysql: PMYSQL)
-    read_statistics*: proc (mysql: PMYSQL): cstring
-    next_result*: proc (mysql: PMYSQL): my_bool
-    read_change_user_result*: proc (mysql: PMYSQL, buff: cstring, 
-                                    passwd: cstring): cint
-    read_rowsfrom_cursor*: proc (stmt: PMYSQL_STMT): cint
-
-  MYSQL_METHODS* = st_mysql_methods
-  PMYSQL_METHODS* = ptr MYSQL_METHODS
-  Pst_mysql_manager* = ptr st_mysql_manager
-  st_mysql_manager*{.final.} = object 
-    net*: NET
-    host*: cstring
-    user*: cstring
-    passwd*: cstring
-    port*: cuint
-    free_me*: my_bool
-    eof*: my_bool
-    cmd_status*: cint
-    last_errno*: cint
-    net_buf*: cstring
-    net_buf_pos*: cstring
-    net_data_end*: cstring
-    net_buf_size*: cint
-    last_error*: array[0..(MAX_MYSQL_MANAGER_ERR) - 1, char]
-
-  MYSQL_MANAGER* = st_mysql_manager
-  PMYSQL_MANAGER* = ptr MYSQL_MANAGER
-  Pst_mysql_parameters* = ptr st_mysql_parameters
-  st_mysql_parameters*{.final.} = object 
-    p_max_allowed_packet*: ptr int
-    p_net_buffer_length*: ptr int
-
-  MYSQL_PARAMETERS* = st_mysql_parameters
-  PMYSQL_PARAMETERS* = ptr MYSQL_PARAMETERS
-  enum_mysql_stmt_state* = enum     
-    MYSQL_STMT_INIT_DONE = 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE, 
-    MYSQL_STMT_FETCH_DONE
-  Pst_mysql_bind* = ptr st_mysql_bind
-  st_mysql_bind*{.final.} = object 
-    len*: int              # output length pointer
-    is_null*: Pmy_bool        # Pointer to null indicator
-    buffer*: pointer          # buffer to get/put data
-    error*: pmy_bool          # set this if you want to track data truncations happened during fetch
-    buffer_type*: enum_field_types # buffer type
-    buffer_length*: int    # buffer length, must be set for str/binary
-                           # Following are for internal use. Set by mysql_stmt_bind_param  
-    row_ptr*: ptr byte        # for the current data position
-    offset*: int           # offset position for char/binary fetch
-    length_value*: int     #  Used if length is 0
-    param_number*: cuint      # For null count and error messages
-    pack_length*: cuint       # Internal length for packed data
-    error_value*: my_bool     # used if error is 0
-    is_unsigned*: my_bool     # set if integer type is unsigned
-    long_data_used*: my_bool  # If used with mysql_send_long_data
-    is_null_value*: my_bool   # Used if is_null is 0
-    store_param_func*: proc (net: PNET, param: Pst_mysql_bind){.cdecl.}
-    fetch_result*: proc (para1: Pst_mysql_bind, para2: PMYSQL_FIELD, row: PPbyte)
-    skip_result*: proc (para1: Pst_mysql_bind, para2: PMYSQL_FIELD, row: PPbyte)
-
-  MYSQL_BIND* = st_mysql_bind
-  PMYSQL_BIND* = ptr MYSQL_BIND # statement handler  
-  st_mysql_stmt*{.final.} = object 
-    mem_root*: MEM_ROOT       # root allocations
-    mysql*: PMYSQL            # connection handle
-    params*: PMYSQL_BIND      # input parameters
-    `bind`*: PMYSQL_BIND      # input parameters
-    fields*: PMYSQL_FIELD     # result set metadata
-    result*: MYSQL_DATA       # cached result set
-    data_cursor*: PMYSQL_ROWS # current row in cached result
-    affected_rows*: my_ulonglong # copy of mysql->affected_rows after statement execution
-    insert_id*: my_ulonglong 
-    read_row_func*: proc (stmt: Pst_mysql_stmt, row: PPbyte): cint{.cdecl.}
-    stmt_id*: int          # Id for prepared statement
-    flags*: int            # i.e. type of cursor to open
-    prefetch_rows*: int    # number of rows per one COM_FETCH
-    server_status*: cuint # Copied from mysql->server_status after execute/fetch to know
-                          # server-side cursor status for this statement.
-    last_errno*: cuint        # error code
-    param_count*: cuint       # input parameter count
-    field_count*: cuint       # number of columns in result set
-    state*: enum_mysql_stmt_state # statement state
-    last_error*: array[0..(MYSQL_ERRMSG_SIZE) - 1, char] # error message
-    sqlstate*: array[0..(SQLSTATE_LENGTH + 1) - 1, char]
-    send_types_to_server*: my_bool # Types of input parameters should be sent to server
-    bind_param_done*: my_bool # input buffers were supplied
-    bind_result_done*: char # output buffers were supplied
-    unbuffered_fetch_cancelled*: my_bool        
-    update_max_length*: my_bool
-
-  MYSQL_STMT* = st_mysql_stmt # When doing mysql_stmt_store_result calculate max_length attribute
-                              # of statement metadata. This is to be consistent with the old API,
-                              # where this was done automatically.
-                              # In the new API we do that only by request because it slows down
-                              # mysql_stmt_store_result sufficiently.       
-  enum_stmt_attr_type* = enum
-    STMT_ATTR_UPDATE_MAX_LENGTH, STMT_ATTR_CURSOR_TYPE,  
-    STMT_ATTR_PREFETCH_ROWS 
-    
-proc mysql_server_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{.cdecl, 
-    dynlib: mysqllib, importc: "mysql_server_init".}
-proc mysql_server_end*(){.cdecl, dynlib: mysqllib, importc: "mysql_server_end".}
-  # mysql_server_init/end need to be called when using libmysqld or
-  #      libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
-  #      you don't need to call it explicitely; but you need to call
-  #      mysql_server_end() to free memory). The names are a bit misleading
-  #      (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
-  #      names which suit well whether you're using libmysqld or libmysqlclient. We
-  #      intend to promote these aliases over the mysql_server* ones.     
-proc mysql_library_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{.cdecl, 
-    dynlib: mysqllib, importc: "mysql_server_init".}
-proc mysql_library_end*(){.cdecl, dynlib: mysqllib, importc: "mysql_server_end".}
-proc mysql_get_parameters*(): PMYSQL_PARAMETERS{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_get_parameters".}
-  # Set up and bring down a thread; these function should be called
-  #      for each thread in an application which opens at least one MySQL
-  #      connection.  All uses of the connection(s) should be between these
-  #      function calls.     
-proc mysql_thread_init*(): my_bool{.stdcall, dynlib: mysqllib, 
-                                    importc: "mysql_thread_init".}
-proc mysql_thread_end*(){.stdcall, dynlib: mysqllib, importc: "mysql_thread_end".}
-  # Functions to get information from the MYSQL and MYSQL_RES structures
-  #      Should definitely be used if one uses shared libraries.     
-proc mysql_num_rows*(res: PMYSQL_RES): my_ulonglong{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_num_rows".}
-proc mysql_num_fields*(res: PMYSQL_RES): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_num_fields".}
-proc mysql_eof*(res: PMYSQL_RES): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_eof".}
-proc mysql_fetch_field_direct*(res: PMYSQL_RES, fieldnr: cuint): PMYSQL_FIELD{.
-    stdcall, dynlib: mysqllib, importc: "mysql_fetch_field_direct".}
-proc mysql_fetch_fields*(res: PMYSQL_RES): PMYSQL_FIELD{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_fetch_fields".}
-proc mysql_row_tell*(res: PMYSQL_RES): MYSQL_ROW_OFFSET{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_row_tell".}
-proc mysql_field_tell*(res: PMYSQL_RES): MYSQL_FIELD_OFFSET{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_field_tell".}
-proc mysql_field_count*(mysql: PMYSQL): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_field_count".}
-proc mysql_affected_rows*(mysql: PMYSQL): my_ulonglong{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_affected_rows".}
-proc mysql_insert_id*(mysql: PMYSQL): my_ulonglong{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_insert_id".}
-proc mysql_errno*(mysql: PMYSQL): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_errno".}
-proc mysql_error*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_error".}
-proc mysql_sqlstate*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_sqlstate".}
-proc mysql_warning_count*(mysql: PMYSQL): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_warning_count".}
-proc mysql_info*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_info".}
-proc mysql_thread_id*(mysql: PMYSQL): int{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_thread_id".}
-proc mysql_character_set_name*(mysql: PMYSQL): cstring{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_character_set_name".}
-proc mysql_set_character_set*(mysql: PMYSQL, csname: cstring): int32{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_set_character_set".}
-proc mysql_init*(mysql: PMYSQL): PMYSQL{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_init".}
-proc mysql_ssl_set*(mysql: PMYSQL, key: cstring, cert: cstring, ca: cstring, 
-                    capath: cstring, cipher: cstring): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_ssl_set".}
-proc mysql_change_user*(mysql: PMYSQL, user: cstring, passwd: cstring, 
-                        db: cstring): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_change_user".}
-proc mysql_real_connect*(mysql: PMYSQL, host: cstring, user: cstring, 
-                         passwd: cstring, db: cstring, port: cuint, 
-                         unix_socket: cstring, clientflag: int): PMYSQL{.
-    stdcall, dynlib: mysqllib, importc: "mysql_real_connect".}
-proc mysql_select_db*(mysql: PMYSQL, db: cstring): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_select_db".}
-proc mysql_query*(mysql: PMYSQL, q: cstring): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_query".}
-proc mysql_send_query*(mysql: PMYSQL, q: cstring, len: int): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_send_query".}
-proc mysql_real_query*(mysql: PMYSQL, q: cstring, len: int): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_real_query".}
-proc mysql_store_result*(mysql: PMYSQL): PMYSQL_RES{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_store_result".}
-proc mysql_use_result*(mysql: PMYSQL): PMYSQL_RES{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_use_result".}
-  # perform query on master  
-proc mysql_master_query*(mysql: PMYSQL, q: cstring, len: int): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_master_query".}
-proc mysql_master_send_query*(mysql: PMYSQL, q: cstring, len: int): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_master_send_query".}
-  # perform query on slave  
-proc mysql_slave_query*(mysql: PMYSQL, q: cstring, len: int): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_slave_query".}
-proc mysql_slave_send_query*(mysql: PMYSQL, q: cstring, len: int): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_slave_send_query".}
-proc mysql_get_character_set_info*(mysql: PMYSQL, charset: PMY_CHARSET_INFO){.
-    stdcall, dynlib: mysqllib, importc: "mysql_get_character_set_info".}
-  # local infile support  
-const 
-  LOCAL_INFILE_ERROR_LEN* = 512 
-  
-# procedure mysql_set_local_infile_handler(mysql:PMYSQL; local_infile_init:function (para1:Ppointer; para2:Pchar; para3:pointer):longint; local_infile_read:function (para1:pointer; para2:Pchar; para3:dword):longint; local_infile_end:procedure (_pa
-# para6:pointer);cdecl;external mysqllib name 'mysql_set_local_infile_handler';
-
-proc mysql_set_local_infile_default*(mysql: PMYSQL){.cdecl, dynlib: mysqllib, 
-    importc: "mysql_set_local_infile_default".}
-  # enable/disable parsing of all queries to decide if they go on master or
-  #      slave     
-proc mysql_enable_rpl_parse*(mysql: PMYSQL){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_enable_rpl_parse".}
-proc mysql_disable_rpl_parse*(mysql: PMYSQL){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_disable_rpl_parse".}
-  # get the value of the parse flag  
-proc mysql_rpl_parse_enabled*(mysql: PMYSQL): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_rpl_parse_enabled".}
-  #  enable/disable reads from master  
-proc mysql_enable_reads_from_master*(mysql: PMYSQL){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_enable_reads_from_master".}
-proc mysql_disable_reads_from_master*(mysql: PMYSQL){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_disable_reads_from_master".}
-  # get the value of the master read flag  
-proc mysql_reads_from_master_enabled*(mysql: PMYSQL): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_reads_from_master_enabled".}
-proc mysql_rpl_query_type*(q: cstring, length: cint): mysql_rpl_type{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_rpl_query_type".}
-  # discover the master and its slaves  
-proc mysql_rpl_probe*(mysql: PMYSQL): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_rpl_probe".}
-  # set the master, close/free the old one, if it is not a pivot  
-proc mysql_set_master*(mysql: PMYSQL, host: cstring, port: cuint, user: cstring, 
-                       passwd: cstring): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_set_master".}
-proc mysql_add_slave*(mysql: PMYSQL, host: cstring, port: cuint, user: cstring, 
-                      passwd: cstring): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_add_slave".}
-proc mysql_shutdown*(mysql: PMYSQL, shutdown_level: mysql_enum_shutdown_level): cint{.
-    stdcall, dynlib: mysqllib, importc: "mysql_shutdown".}
-proc mysql_dump_debug_info*(mysql: PMYSQL): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_dump_debug_info".}
-proc mysql_refresh*(mysql: PMYSQL, refresh_options: cuint): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_refresh".}
-proc mysql_kill*(mysql: PMYSQL, pid: int): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_kill".}
-proc mysql_set_server_option*(mysql: PMYSQL, option: enum_mysql_set_option): cint{.
-    stdcall, dynlib: mysqllib, importc: "mysql_set_server_option".}
-proc mysql_ping*(mysql: PMYSQL): cint{.stdcall, dynlib: mysqllib, 
-                                       importc: "mysql_ping".}
-proc mysql_stat*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stat".}
-proc mysql_get_server_info*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_get_server_info".}
-proc mysql_get_client_info*(): cstring{.stdcall, dynlib: mysqllib, 
-                                        importc: "mysql_get_client_info".}
-proc mysql_get_client_version*(): int{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_get_client_version".}
-proc mysql_get_host_info*(mysql: PMYSQL): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_get_host_info".}
-proc mysql_get_server_version*(mysql: PMYSQL): int{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_get_server_version".}
-proc mysql_get_proto_info*(mysql: PMYSQL): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_get_proto_info".}
-proc mysql_list_dbs*(mysql: PMYSQL, wild: cstring): PMYSQL_RES{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_list_dbs".}
-proc mysql_list_tables*(mysql: PMYSQL, wild: cstring): PMYSQL_RES{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_list_tables".}
-proc mysql_list_processes*(mysql: PMYSQL): PMYSQL_RES{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_list_processes".}
-proc mysql_options*(mysql: PMYSQL, option: mysql_option, arg: cstring): cint{.
-    stdcall, dynlib: mysqllib, importc: "mysql_options".}
-proc mysql_free_result*(result: PMYSQL_RES){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_free_result".}
-proc mysql_data_seek*(result: PMYSQL_RES, offset: my_ulonglong){.stdcall, 
-    dynlib: mysqllib, importc: "mysql_data_seek".}
-proc mysql_row_seek*(result: PMYSQL_RES, offset: MYSQL_ROW_OFFSET): MYSQL_ROW_OFFSET{.
-    stdcall, dynlib: mysqllib, importc: "mysql_row_seek".}
-proc mysql_field_seek*(result: PMYSQL_RES, offset: MYSQL_FIELD_OFFSET): MYSQL_FIELD_OFFSET{.
-    stdcall, dynlib: mysqllib, importc: "mysql_field_seek".}
-proc mysql_fetch_row*(result: PMYSQL_RES): MYSQL_ROW{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_fetch_row".}
-proc mysql_fetch_lengths*(result: PMYSQL_RES): ptr int{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_fetch_lengths".}
-proc mysql_fetch_field*(result: PMYSQL_RES): PMYSQL_FIELD{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_fetch_field".}
-proc mysql_list_fields*(mysql: PMYSQL, table: cstring, wild: cstring): PMYSQL_RES{.
-    stdcall, dynlib: mysqllib, importc: "mysql_list_fields".}
-proc mysql_escape_string*(fto: cstring, `from`: cstring, from_length: int): int{.
-    stdcall, dynlib: mysqllib, importc: "mysql_escape_string".}
-proc mysql_hex_string*(fto: cstring, `from`: cstring, from_length: int): int{.
-    stdcall, dynlib: mysqllib, importc: "mysql_hex_string".}
-proc mysql_real_escape_string*(mysql: PMYSQL, fto: cstring, `from`: cstring, 
-                               len: int): int{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_real_escape_string".}
-proc mysql_debug*(debug: cstring){.stdcall, dynlib: mysqllib, 
-                                   importc: "mysql_debug".}
-  #    function mysql_odbc_escape_string(mysql:PMYSQL; fto:Pchar; to_length:dword; from:Pchar; from_length:dword;
-  #               param:pointer; extend_buffer:function (para1:pointer; to:Pchar; length:Pdword):Pchar):Pchar;stdcall;external mysqllib name 'mysql_odbc_escape_string';
-proc myodbc_remove_escape*(mysql: PMYSQL, name: cstring){.stdcall, 
-    dynlib: mysqllib, importc: "myodbc_remove_escape".}
-proc mysql_thread_safe*(): cuint{.stdcall, dynlib: mysqllib, 
-                                  importc: "mysql_thread_safe".}
-proc mysql_embedded*(): my_bool{.stdcall, dynlib: mysqllib, 
-                                 importc: "mysql_embedded".}
-proc mysql_manager_init*(con: PMYSQL_MANAGER): PMYSQL_MANAGER{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_manager_init".}
-proc mysql_manager_connect*(con: PMYSQL_MANAGER, host: cstring, user: cstring, 
-                            passwd: cstring, port: cuint): PMYSQL_MANAGER{.
-    stdcall, dynlib: mysqllib, importc: "mysql_manager_connect".}
-proc mysql_manager_close*(con: PMYSQL_MANAGER){.stdcall, dynlib: mysqllib, 
-    importc: "mysql_manager_close".}
-proc mysql_manager_command*(con: PMYSQL_MANAGER, cmd: cstring, cmd_len: cint): cint{.
-    stdcall, dynlib: mysqllib, importc: "mysql_manager_command".}
-proc mysql_manager_fetch_line*(con: PMYSQL_MANAGER, res_buf: cstring, 
-                               res_buf_size: cint): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_manager_fetch_line".}
-proc mysql_read_query_result*(mysql: PMYSQL): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_read_query_result".}
-proc mysql_stmt_init*(mysql: PMYSQL): PMYSQL_STMT{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_init".}
-proc mysql_stmt_prepare*(stmt: PMYSQL_STMT, query: cstring, len: int): cint{.
-    stdcall, dynlib: mysqllib, importc: "mysql_stmt_prepare".}
-proc mysql_stmt_execute*(stmt: PMYSQL_STMT): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_execute".}
-proc mysql_stmt_fetch*(stmt: PMYSQL_STMT): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_fetch".}
-proc mysql_stmt_fetch_column*(stmt: PMYSQL_STMT, `bind`: PMYSQL_BIND, 
-                              column: cuint, offset: int): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_fetch_column".}
-proc mysql_stmt_store_result*(stmt: PMYSQL_STMT): cint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_store_result".}
-proc mysql_stmt_param_count*(stmt: PMYSQL_STMT): int{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_param_count".}
-proc mysql_stmt_attr_set*(stmt: PMYSQL_STMT, attr_type: enum_stmt_attr_type, 
-                          attr: pointer): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_attr_set".}
-proc mysql_stmt_attr_get*(stmt: PMYSQL_STMT, attr_type: enum_stmt_attr_type, 
-                          attr: pointer): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_attr_get".}
-proc mysql_stmt_bind_param*(stmt: PMYSQL_STMT, bnd: PMYSQL_BIND): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_stmt_bind_param".}
-proc mysql_stmt_bind_result*(stmt: PMYSQL_STMT, bnd: PMYSQL_BIND): my_bool{.
-    stdcall, dynlib: mysqllib, importc: "mysql_stmt_bind_result".}
-proc mysql_stmt_close*(stmt: PMYSQL_STMT): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_close".}
-proc mysql_stmt_reset*(stmt: PMYSQL_STMT): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_reset".}
-proc mysql_stmt_free_result*(stmt: PMYSQL_STMT): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_free_result".}
-proc mysql_stmt_send_long_data*(stmt: PMYSQL_STMT, param_number: cuint, 
-                                data: cstring, len: int): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_send_long_data".}
-proc mysql_stmt_result_metadata*(stmt: PMYSQL_STMT): PMYSQL_RES{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_result_metadata".}
-proc mysql_stmt_param_metadata*(stmt: PMYSQL_STMT): PMYSQL_RES{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_param_metadata".}
-proc mysql_stmt_errno*(stmt: PMYSQL_STMT): cuint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_errno".}
-proc mysql_stmt_error*(stmt: PMYSQL_STMT): cstring{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_stmt_error".}
-proc mysql_stmt_sqlstate*(stmt: PMYSQL_STMT): cstring{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_sqlstate".}
-proc mysql_stmt_row_seek*(stmt: PMYSQL_STMT, offset: MYSQL_ROW_OFFSET): MYSQL_ROW_OFFSET{.
-    stdcall, dynlib: mysqllib, importc: "mysql_stmt_row_seek".}
-proc mysql_stmt_row_tell*(stmt: PMYSQL_STMT): MYSQL_ROW_OFFSET{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_row_tell".}
-proc mysql_stmt_data_seek*(stmt: PMYSQL_STMT, offset: my_ulonglong){.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_data_seek".}
-proc mysql_stmt_num_rows*(stmt: PMYSQL_STMT): my_ulonglong{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_num_rows".}
-proc mysql_stmt_affected_rows*(stmt: PMYSQL_STMT): my_ulonglong{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_affected_rows".}
-proc mysql_stmt_insert_id*(stmt: PMYSQL_STMT): my_ulonglong{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_insert_id".}
-proc mysql_stmt_field_count*(stmt: PMYSQL_STMT): cuint{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_stmt_field_count".}
-proc mysql_commit*(mysql: PMYSQL): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_commit".}
-proc mysql_rollback*(mysql: PMYSQL): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_rollback".}
-proc mysql_autocommit*(mysql: PMYSQL, auto_mode: my_bool): my_bool{.stdcall, 
-    dynlib: mysqllib, importc: "mysql_autocommit".}
-proc mysql_more_results*(mysql: PMYSQL): my_bool{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_more_results".}
-proc mysql_next_result*(mysql: PMYSQL): cint{.stdcall, dynlib: mysqllib, 
-    importc: "mysql_next_result".}
-proc mysql_close*(sock: PMYSQL){.stdcall, dynlib: mysqllib, 
-                                 importc: "mysql_close".}
-  # status return codes  
-const 
-  MYSQL_NO_DATA* = 100
-  MYSQL_DATA_TRUNCATED* = 101
-
-proc mysql_reload*(mysql: PMySQL): cint
-
-when defined(USE_OLD_FUNCTIONS): 
-  proc mysql_connect*(mysql: PMYSQL, host: cstring, user: cstring, 
-                      passwd: cstring): PMYSQL{.stdcall, 
-      dynlib: External_library, importc: "mysql_connect".}
-  proc mysql_create_db*(mysql: PMYSQL, DB: cstring): cint{.stdcall, 
-      dynlib: External_library, importc: "mysql_create_db".}
-  proc mysql_drop_db*(mysql: PMYSQL, DB: cstring): cint{.stdcall, 
-      dynlib: External_library, importc: "mysql_drop_db".}
-
-proc net_safe_read*(mysql: PMYSQL): cuint{.cdecl, dynlib: mysqllib, 
-    importc: "net_safe_read".}
-
-proc net_new_transaction(net: st_net): st_net = 
-  assert false
-  #net.pkt_nr = 0
-  result = net
-
-proc IS_PRI_KEY(n: int32): bool = 
-  result = (n and PRI_KEY_FLAG) != 0
-
-proc IS_NOT_NULL(n: int32): bool = 
-  result = (n and NOT_NULL_FLAG) != 0
-
-proc IS_BLOB(n: int32): bool = 
-  result = (n and BLOB_FLAG) != 0
-
-proc IS_NUM_FIELD(f: pst_mysql_field): bool = 
-  result = (f.flags and NUM_FLAG) != 0
-
-proc IS_NUM(t: enum_field_types): bool = 
-  result = (t <= FIELD_TYPE_INT24) or (t == FIELD_TYPE_YEAR) or
-      (t == FIELD_TYPE_NEWDECIMAL)
-
-proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool = 
-  result = (f.ftype <= FIELD_TYPE_INT24) and
-      ((f.ftype != FIELD_TYPE_TIMESTAMP) or (f.len == 14) or (f.len == 8)) or
-      (f.ftype == FIELD_TYPE_YEAR)
-
-proc mysql_reload(mysql: PMySQL): cint = 
-  result = mysql_refresh(mysql, REFRESH_GRANT)
-
diff --git a/lib/oldwrappers/odbcsql.nim b/lib/oldwrappers/odbcsql.nim
deleted file mode 100755
index 77719e85f..000000000
--- a/lib/oldwrappers/odbcsql.nim
+++ /dev/null
@@ -1,788 +0,0 @@
-
-{.deadCodeElim: on.}
-
-when not defined(ODBCVER):
-  const
-    ODBCVER = 0x0351 ## define ODBC version 3.51 by default
-
-when defined(windows):
-  {.push callconv: stdcall.}
-  const odbclib = "odbc32.dll"
-else:
-  {.push callconv: cdecl.}
-  const odbclib = "libodbc.so"
-
-# DATA TYPES CORRESPONDENCE
-#   BDE fields  ODBC types
-#   ----------  ------------------
-#   ftBlob      SQL_BINARY
-#   ftBoolean   SQL_BIT
-#   ftDate      SQL_TYPE_DATE
-#   ftTime      SQL_TYPE_TIME
-#   ftDateTime  SQL_TYPE_TIMESTAMP
-#   ftInteger   SQL_INTEGER
-#   ftSmallint  SQL_SMALLINT
-#   ftFloat     SQL_DOUBLE
-#   ftString    SQL_CHAR
-#   ftMemo      SQL_BINARY // SQL_VARCHAR
-#
-
-type 
-  TSqlChar* = char
-  TSqlSmallInt* = int16
-  TSqlUSmallInt* = int16
-  TSqlHandle* = pointer
-  TSqlHEnv* = TSqlHandle
-  TSqlHDBC* = TSqlHandle
-  TSqlHStmt* = TSqlHandle
-  TSqlHDesc* = TSqlHandle
-  TSqlInteger* = int
-  TSqlUInteger* = int
-  TSqlPointer* = pointer
-  TSqlReal* = cfloat
-  TSqlDouble* = cdouble
-  TSqlFloat* = cdouble
-  TSqlHWND* = pointer
-  PSQLCHAR* = cstring
-  PSQLINTEGER* = ptr TSqlInteger
-  PSQLUINTEGER* = ptr TSqlUInteger
-  PSQLSMALLINT* = ptr TSqlSmallInt
-  PSQLUSMALLINT* = ptr TSqlUSmallInt
-  PSQLREAL* = ptr TSqlReal
-  PSQLDOUBLE* = ptr TSqlDouble
-  PSQLFLOAT* = ptr TSqlFloat
-  PSQLHANDLE* = ptr TSqlHandle
-
-const                         # SQL data type codes 
-  SQL_UNKNOWN_TYPE* = 0
-  SQL_LONGVARCHAR* = (- 1)
-  SQL_BINARY* = (- 2)
-  SQL_VARBINARY* = (- 3)
-  SQL_LONGVARBINARY* = (- 4)
-  SQL_BIGINT* = (- 5)
-  SQL_TINYINT* = (- 6)
-  SQL_BIT* = (- 7)
-  SQL_WCHAR* = (- 8)
-  SQL_WVARCHAR* = (- 9)
-  SQL_WLONGVARCHAR* = (- 10)
-  SQL_CHAR* = 1
-  SQL_NUMERIC* = 2
-  SQL_DECIMAL* = 3
-  SQL_INTEGER* = 4
-  SQL_SMALLINT* = 5
-  SQL_FLOAT* = 6
-  SQL_REAL* = 7
-  SQL_DOUBLE* = 8
-  SQL_DATETIME* = 9
-  SQL_VARCHAR* = 12
-  SQL_TYPE_DATE* = 91
-  SQL_TYPE_TIME* = 92
-  SQL_TYPE_TIMESTAMP* = 93
-  SQL_DATE* = 9
-  SQL_TIME* = 10
-  SQL_TIMESTAMP* = 11
-  SQL_INTERVAL* = 10
-  SQL_GUID* = - 11            # interval codes
-
-when ODBCVER >= 0x0300: 
-  const 
-    SQL_CODE_YEAR* = 1
-    SQL_CODE_MONTH* = 2
-    SQL_CODE_DAY* = 3
-    SQL_CODE_HOUR* = 4
-    SQL_CODE_MINUTE* = 5
-    SQL_CODE_SECOND* = 6
-    SQL_CODE_YEAR_TO_MONTH* = 7
-    SQL_CODE_DAY_TO_HOUR* = 8
-    SQL_CODE_DAY_TO_MINUTE* = 9
-    SQL_CODE_DAY_TO_SECOND* = 10
-    SQL_CODE_HOUR_TO_MINUTE* = 11
-    SQL_CODE_HOUR_TO_SECOND* = 12
-    SQL_CODE_MINUTE_TO_SECOND* = 13
-    SQL_INTERVAL_YEAR* = 100 + SQL_CODE_YEAR
-    SQL_INTERVAL_MONTH* = 100 + SQL_CODE_MONTH
-    SQL_INTERVAL_DAY* = 100 + SQL_CODE_DAY
-    SQL_INTERVAL_HOUR* = 100 + SQL_CODE_HOUR
-    SQL_INTERVAL_MINUTE* = 100 + SQL_CODE_MINUTE
-    SQL_INTERVAL_SECOND* = 100 + SQL_CODE_SECOND
-    SQL_INTERVAL_YEAR_TO_MONTH* = 100 + SQL_CODE_YEAR_TO_MONTH
-    SQL_INTERVAL_DAY_TO_HOUR* = 100 + SQL_CODE_DAY_TO_HOUR
-    SQL_INTERVAL_DAY_TO_MINUTE* = 100 + SQL_CODE_DAY_TO_MINUTE
-    SQL_INTERVAL_DAY_TO_SECOND* = 100 + SQL_CODE_DAY_TO_SECOND
-    SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
-    SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
-    SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
-else: 
-  const 
-    SQL_INTERVAL_YEAR* = - 80
-    SQL_INTERVAL_MONTH* = - 81
-    SQL_INTERVAL_YEAR_TO_MONTH* = - 82
-    SQL_INTERVAL_DAY* = - 83
-    SQL_INTERVAL_HOUR* = - 84
-    SQL_INTERVAL_MINUTE* = - 85
-    SQL_INTERVAL_SECOND* = - 86
-    SQL_INTERVAL_DAY_TO_HOUR* = - 87
-    SQL_INTERVAL_DAY_TO_MINUTE* = - 88
-    SQL_INTERVAL_DAY_TO_SECOND* = - 89
-    SQL_INTERVAL_HOUR_TO_MINUTE* = - 90
-    SQL_INTERVAL_HOUR_TO_SECOND* = - 91
-    SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
-
-
-when ODBCVER < 0x0300: 
-  const 
-    SQL_UNICODE* = - 95
-    SQL_UNICODE_VARCHAR* = - 96
-    SQL_UNICODE_LONGVARCHAR* = - 97
-    SQL_UNICODE_CHAR* = SQL_UNICODE
-else: 
-  # The previous definitions for SQL_UNICODE_ are historical and obsolete 
-  const 
-    SQL_UNICODE* = SQL_WCHAR
-    SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
-    SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
-    SQL_UNICODE_CHAR* = SQL_WCHAR
-const                         # C datatype to SQL datatype mapping 
-  SQL_C_CHAR* = SQL_CHAR
-  SQL_C_LONG* = SQL_INTEGER
-  SQL_C_SHORT* = SQL_SMALLINT
-  SQL_C_FLOAT* = SQL_REAL
-  SQL_C_DOUBLE* = SQL_DOUBLE
-  SQL_C_NUMERIC* = SQL_NUMERIC
-  SQL_C_DEFAULT* = 99
-  SQL_SIGNED_OFFSET* = - 20
-  SQL_UNSIGNED_OFFSET* = - 22
-  SQL_C_DATE* = SQL_DATE
-  SQL_C_TIME* = SQL_TIME
-  SQL_C_TIMESTAMP* = SQL_TIMESTAMP
-  SQL_C_TYPE_DATE* = SQL_TYPE_DATE
-  SQL_C_TYPE_TIME* = SQL_TYPE_TIME
-  SQL_C_TYPE_TIMESTAMP* = SQL_TYPE_TIMESTAMP
-  SQL_C_INTERVAL_YEAR* = SQL_INTERVAL_YEAR
-  SQL_C_INTERVAL_MONTH* = SQL_INTERVAL_MONTH
-  SQL_C_INTERVAL_DAY* = SQL_INTERVAL_DAY
-  SQL_C_INTERVAL_HOUR* = SQL_INTERVAL_HOUR
-  SQL_C_INTERVAL_MINUTE* = SQL_INTERVAL_MINUTE
-  SQL_C_INTERVAL_SECOND* = SQL_INTERVAL_SECOND
-  SQL_C_INTERVAL_YEAR_TO_MONTH* = SQL_INTERVAL_YEAR_TO_MONTH
-  SQL_C_INTERVAL_DAY_TO_HOUR* = SQL_INTERVAL_DAY_TO_HOUR
-  SQL_C_INTERVAL_DAY_TO_MINUTE* = SQL_INTERVAL_DAY_TO_MINUTE
-  SQL_C_INTERVAL_DAY_TO_SECOND* = SQL_INTERVAL_DAY_TO_SECOND
-  SQL_C_INTERVAL_HOUR_TO_MINUTE* = SQL_INTERVAL_HOUR_TO_MINUTE
-  SQL_C_INTERVAL_HOUR_TO_SECOND* = SQL_INTERVAL_HOUR_TO_SECOND
-  SQL_C_INTERVAL_MINUTE_TO_SECOND* = SQL_INTERVAL_MINUTE_TO_SECOND
-  SQL_C_BINARY* = SQL_BINARY
-  SQL_C_BIT* = SQL_BIT
-  SQL_C_SBIGINT* = SQL_BIGINT + SQL_SIGNED_OFFSET # SIGNED BIGINT
-  SQL_C_UBIGINT* = SQL_BIGINT + SQL_UNSIGNED_OFFSET # UNSIGNED BIGINT
-  SQL_C_TINYINT* = SQL_TINYINT
-  SQL_C_SLONG* = SQL_C_LONG + SQL_SIGNED_OFFSET # SIGNED INTEGER
-  SQL_C_SSHORT* = SQL_C_SHORT + SQL_SIGNED_OFFSET # SIGNED SMALLINT
-  SQL_C_STINYINT* = SQL_TINYINT + SQL_SIGNED_OFFSET # SIGNED TINYINT
-  SQL_C_ULONG* = SQL_C_LONG + SQL_UNSIGNED_OFFSET # UNSIGNED INTEGER
-  SQL_C_USHORT* = SQL_C_SHORT + SQL_UNSIGNED_OFFSET # UNSIGNED SMALLINT
-  SQL_C_UTINYINT* = SQL_TINYINT + SQL_UNSIGNED_OFFSET # UNSIGNED TINYINT
-  SQL_C_BOOKMARK* = SQL_C_ULONG # BOOKMARK
-  SQL_C_GUID* = SQL_GUID
-  SQL_TYPE_NULL* = 0
-
-when ODBCVER < 0x0300: 
-  const 
-    SQL_TYPE_MIN* = SQL_BIT
-    SQL_TYPE_MAX* = SQL_VARCHAR
-
-const 
-  SQL_C_VARBOOKMARK* = SQL_C_BINARY
-  SQL_API_SQLDESCRIBEPARAM* = 58
-  SQL_NO_TOTAL* = - 4
-
-type 
-  SQL_DATE_STRUCT* {.final, pure.} = object 
-    Year*: TSqlSmallInt
-    Month*: TSqlUSmallInt
-    Day*: TSqlUSmallInt
-
-  PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
-  SQL_TIME_STRUCT* {.final, pure.} = object 
-    Hour*: TSqlUSmallInt
-    Minute*: TSqlUSmallInt
-    Second*: TSqlUSmallInt
-
-  PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
-  SQL_TIMESTAMP_STRUCT* {.final, pure.} = object 
-    Year*: TSqlUSmallInt
-    Month*: TSqlUSmallInt
-    Day*: TSqlUSmallInt
-    Hour*: TSqlUSmallInt
-    Minute*: TSqlUSmallInt
-    Second*: TSqlUSmallInt
-    Fraction*: TSqlUInteger
-
-  PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
-
-const 
-  SQL_NAME_LEN* = 128
-  SQL_OV_ODBC3* = 3
-  SQL_OV_ODBC2* = 2
-  SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect 
-  SQL_DRIVER_NOPROMPT* = 0
-  SQL_DRIVER_COMPLETE* = 1
-  SQL_DRIVER_PROMPT* = 2
-  SQL_DRIVER_COMPLETE_REQUIRED* = 3 
-  SQL_IS_POINTER* = (- 4)  # whether an attribute is a pointer or not 
-  SQL_IS_UINTEGER* = (- 5)
-  SQL_IS_INTEGER* = (- 6)
-  SQL_IS_USMALLINT* = (- 7)
-  SQL_IS_SMALLINT* = (- 8)    # SQLExtendedFetch "fFetchType" values 
-  SQL_FETCH_BOOKMARK* = 8
-  SQL_SCROLL_OPTIONS* = 44    # SQL_USE_BOOKMARKS options 
-  SQL_UB_OFF* = 0
-  SQL_UB_ON* = 1
-  SQL_UB_DEFAULT* = SQL_UB_OFF
-  SQL_UB_FIXED* = SQL_UB_ON
-  SQL_UB_VARIABLE* = 2        # SQL_SCROLL_OPTIONS masks 
-  SQL_SO_FORWARD_ONLY* = 0x00000001
-  SQL_SO_KEYSET_DRIVEN* = 0x00000002
-  SQL_SO_DYNAMIC* = 0x00000004
-  SQL_SO_MIXED* = 0x00000008
-  SQL_SO_STATIC* = 0x00000010
-  SQL_BOOKMARK_PERSISTENCE* = 82
-  SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values 
-  SQL_BP_CLOSE* = 0x00000001
-  SQL_BP_DELETE* = 0x00000002
-  SQL_BP_DROP* = 0x00000004
-  SQL_BP_TRANSACTION* = 0x00000008
-  SQL_BP_UPDATE* = 0x00000010
-  SQL_BP_OTHER_HSTMT* = 0x00000020
-  SQL_BP_SCROLL* = 0x00000040
-  SQL_DYNAMIC_CURSOR_ATTRIBUTES1* = 144
-  SQL_DYNAMIC_CURSOR_ATTRIBUTES2* = 145
-  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1* = 146
-  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2* = 147
-  SQL_INDEX_KEYWORDS* = 148
-  SQL_INFO_SCHEMA_VIEWS* = 149
-  SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
-  SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
-  SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
-  SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's 
-  SQL_CA1_NEXT* = 1
-  SQL_CA1_ABSOLUTE* = 2
-  SQL_CA1_RELATIVE* = 4
-  SQL_CA1_BOOKMARK* = 8       # supported SQLSetPos LockType's 
-  SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
-  SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
-  SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations 
-  SQL_CA1_POS_POSITION* = 0x00000200
-  SQL_CA1_POS_UPDATE* = 0x00000400
-  SQL_CA1_POS_DELETE* = 0x00000800
-  SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes 
-  SQL_CA1_POSITIONED_UPDATE* = 0x00002000
-  SQL_CA1_POSITIONED_DELETE* = 0x00004000
-  SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations 
-  SQL_CA1_BULK_ADD* = 0x00010000
-  SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
-  SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
-  SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY 
-  SQL_CA2_READ_ONLY_CONCURRENCY* = 1
-  SQL_CA2_LOCK_CONCURRENCY* = 2
-  SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
-  SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates 
-  SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
-  SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
-  SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 #  semantics of SQL_ATTR_MAX_ROWS 
-  SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
-  SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
-  SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
-  SQL_CA2_MAX_ROWS_UPDATE* = 0x00000400
-  SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
-  SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
-      SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
-      SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of 
-                                                           # SQL_DIAG_CURSOR_ROW_COUNT 
-  SQL_CA2_CRC_EXACT* = 0x00001000
-  SQL_CA2_CRC_APPROXIMATE* = 0x00002000 #  the kinds of positioned statements that can be simulated 
-  SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
-  SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
-  SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 #  Operations in SQLBulkOperations 
-  SQL_ADD* = 4
-  SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
-  SQL_UPDATE_BY_BOOKMARK* = 5
-  SQL_DELETE_BY_BOOKMARK* = 6
-  SQL_FETCH_BY_BOOKMARK* = 7  # Operations in SQLSetPos 
-  SQL_POSITION* = 0
-  SQL_REFRESH* = 1
-  SQL_UPDATE* = 2
-  SQL_DELETE* = 3             # Lock options in SQLSetPos 
-  SQL_LOCK_NO_CHANGE* = 0
-  SQL_LOCK_EXCLUSIVE* = 1
-  SQL_LOCK_UNLOCK* = 2        # SQLExtendedFetch "rgfRowStatus" element values 
-  SQL_ROW_SUCCESS* = 0
-  SQL_ROW_DELETED* = 1
-  SQL_ROW_UPDATED* = 2
-  SQL_ROW_NOROW* = 3
-  SQL_ROW_ADDED* = 4
-  SQL_ROW_ERROR* = 5
-  SQL_ROW_SUCCESS_WITH_INFO* = 6
-  SQL_ROW_PROCEED* = 0
-  SQL_ROW_IGNORE* = 1
-  SQL_MAX_DSN_LENGTH* = 32    # maximum data source name size 
-  SQL_MAX_OPTION_STRING_LENGTH* = 256
-  SQL_ODBC_CURSORS* = 110
-  SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options 
-  SQL_CUR_USE_IF_NEEDED* = 0
-  SQL_CUR_USE_ODBC* = 1
-  SQL_CUR_USE_DRIVER* = 2
-  SQL_CUR_DEFAULT* = SQL_CUR_USE_DRIVER
-  SQL_PARAM_TYPE_UNKNOWN* = 0
-  SQL_PARAM_INPUT* = 1
-  SQL_PARAM_INPUT_OUTPUT* = 2
-  SQL_RESULT_COL* = 3
-  SQL_PARAM_OUTPUT* = 4
-  SQL_RETURN_VALUE* = 5       # special length/indicator values 
-  SQL_NULL_DATA* = (- 1)
-  SQL_DATA_AT_EXEC* = (- 2)
-  SQL_SUCCESS* = 0
-  SQL_SUCCESS_WITH_INFO* = 1
-  SQL_NO_DATA* = 100
-  SQL_ERROR* = (- 1)
-  SQL_INVALID_HANDLE* = (- 2)
-  SQL_STILL_EXECUTING* = 2
-  SQL_NEED_DATA* = 99         # flags for null-terminated string 
-  SQL_NTS* = (- 3)            # maximum message length 
-  SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants 
-  SQL_DATE_LEN* = 10
-  SQL_TIME_LEN* = 8           # add P+1 if precision is nonzero 
-  SQL_TIMESTAMP_LEN* = 19     # add P+1 if precision is nonzero 
-                              # handle type identifiers 
-  SQL_HANDLE_ENV* = 1
-  SQL_HANDLE_DBC* = 2
-  SQL_HANDLE_STMT* = 3
-  SQL_HANDLE_DESC* = 4        # environment attribute 
-  SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes 
-  SQL_ATTR_AUTO_IPD* = 10001
-  SQL_ATTR_METADATA_ID* = 10014 # statement attributes 
-  SQL_ATTR_APP_ROW_DESC* = 10010
-  SQL_ATTR_APP_PARAM_DESC* = 10011
-  SQL_ATTR_IMP_ROW_DESC* = 10012
-  SQL_ATTR_IMP_PARAM_DESC* = 10013
-  SQL_ATTR_CURSOR_SCROLLABLE* = (- 1)
-  SQL_ATTR_CURSOR_SENSITIVITY* = (- 2)
-  SQL_QUERY_TIMEOUT* = 0
-  SQL_MAX_ROWS* = 1
-  SQL_NOSCAN* = 2
-  SQL_MAX_LENGTH* = 3
-  SQL_ASYNC_ENABLE* = 4       # same as SQL_ATTR_ASYNC_ENABLE */
-  SQL_BIND_TYPE* = 5
-  SQL_CURSOR_TYPE* = 6
-  SQL_CONCURRENCY* = 7
-  SQL_KEYSET_SIZE* = 8
-  SQL_ROWSET_SIZE* = 9
-  SQL_SIMULATE_CURSOR* = 10
-  SQL_RETRIEVE_DATA* = 11
-  SQL_USE_BOOKMARKS* = 12
-  SQL_GET_BOOKMARK* = 13      #      GetStmtOption Only */
-  SQL_ROW_NUMBER* = 14        #      GetStmtOption Only */
-  SQL_ATTR_CURSOR_TYPE* = SQL_CURSOR_TYPE
-  SQL_ATTR_CONCURRENCY* = SQL_CONCURRENCY
-  SQL_ATTR_FETCH_BOOKMARK_PTR* = 16
-  SQL_ATTR_ROW_STATUS_PTR* = 25
-  SQL_ATTR_ROWS_FETCHED_PTR* = 26
-  SQL_AUTOCOMMIT* = 102
-  SQL_ATTR_AUTOCOMMIT* = SQL_AUTOCOMMIT
-  SQL_ATTR_ROW_NUMBER* = SQL_ROW_NUMBER
-  SQL_TXN_ISOLATION* = 108
-  SQL_ATTR_TXN_ISOLATION* = SQL_TXN_ISOLATION
-  SQL_ATTR_MAX_ROWS* = SQL_MAX_ROWS
-  SQL_ATTR_USE_BOOKMARKS* = SQL_USE_BOOKMARKS #* connection attributes */
-  SQL_ACCESS_MODE* = 101      #  SQL_AUTOCOMMIT              =102;
-  SQL_LOGIN_TIMEOUT* = 103
-  SQL_OPT_TRACE* = 104
-  SQL_OPT_TRACEFILE* = 105
-  SQL_TRANSLATE_DLL* = 106
-  SQL_TRANSLATE_OPTION* = 107 #  SQL_TXN_ISOLATION           =108;
-  SQL_CURRENT_QUALIFIER* = 109 #  SQL_ODBC_CURSORS            =110;
-  SQL_QUIET_MODE* = 111
-  SQL_PACKET_SIZE* = 112      #* connection attributes with new names */
-  SQL_ATTR_ACCESS_MODE* = SQL_ACCESS_MODE #  SQL_ATTR_AUTOCOMMIT                       =SQL_AUTOCOMMIT;
-  SQL_ATTR_CONNECTION_DEAD* = 1209 #* GetConnectAttr only */
-  SQL_ATTR_CONNECTION_TIMEOUT* = 113
-  SQL_ATTR_CURRENT_CATALOG* = SQL_CURRENT_QUALIFIER
-  SQL_ATTR_DISCONNECT_BEHAVIOR* = 114
-  SQL_ATTR_ENLIST_IN_DTC* = 1207
-  SQL_ATTR_ENLIST_IN_XA* = 1208
-  SQL_ATTR_LOGIN_TIMEOUT* = SQL_LOGIN_TIMEOUT #  SQL_ATTR_ODBC_CURSORS             =SQL_ODBC_CURSORS;
-  SQL_ATTR_PACKET_SIZE* = SQL_PACKET_SIZE
-  SQL_ATTR_QUIET_MODE* = SQL_QUIET_MODE
-  SQL_ATTR_TRACE* = SQL_OPT_TRACE
-  SQL_ATTR_TRACEFILE* = SQL_OPT_TRACEFILE
-  SQL_ATTR_TRANSLATE_LIB* = SQL_TRANSLATE_DLL
-  SQL_ATTR_TRANSLATE_OPTION* = SQL_TRANSLATE_OPTION #  SQL_ATTR_TXN_ISOLATION                  =SQL_TXN_ISOLATION;
-                                                    #* SQL_ACCESS_MODE options */
-  SQL_MODE_READ_WRITE* = 0
-  SQL_MODE_READ_ONLY* = 1
-  SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
-  SQL_AUTOCOMMIT_OFF* = 0
-  SQL_AUTOCOMMIT_ON* = 1
-  SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values 
-  SQL_NONSCROLLABLE* = 0
-  SQL_SCROLLABLE* = 1         # SQL_CURSOR_TYPE options 
-  SQL_CURSOR_FORWARD_ONLY* = 0
-  SQL_CURSOR_KEYSET_DRIVEN* = 1
-  SQL_CURSOR_DYNAMIC* = 2
-  SQL_CURSOR_STATIC* = 3
-  SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value 
-                                                     # SQL_CONCURRENCY options 
-  SQL_CONCUR_READ_ONLY* = 1
-  SQL_CONCUR_LOCK* = 2
-  SQL_CONCUR_ROWVER* = 3
-  SQL_CONCUR_VALUES* = 4
-  SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value 
-                                             # identifiers of fields in the SQL descriptor 
-  SQL_DESC_COUNT* = 1001
-  SQL_DESC_TYPE* = 1002
-  SQL_DESC_LENGTH* = 1003
-  SQL_DESC_OCTET_LENGTH_PTR* = 1004
-  SQL_DESC_PRECISION* = 1005
-  SQL_DESC_SCALE* = 1006
-  SQL_DESC_DATETIME_INTERVAL_CODE* = 1007
-  SQL_DESC_NULLABLE* = 1008
-  SQL_DESC_INDICATOR_PTR* = 1009
-  SQL_DESC_DATA_PTR* = 1010
-  SQL_DESC_NAME* = 1011
-  SQL_DESC_UNNAMED* = 1012
-  SQL_DESC_OCTET_LENGTH* = 1013
-  SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area 
-  SQL_DIAG_RETURNCODE* = 1
-  SQL_DIAG_NUMBER* = 2
-  SQL_DIAG_ROW_COUNT* = 3
-  SQL_DIAG_SQLSTATE* = 4
-  SQL_DIAG_NATIVE* = 5
-  SQL_DIAG_MESSAGE_TEXT* = 6
-  SQL_DIAG_DYNAMIC_FUNCTION* = 7
-  SQL_DIAG_CLASS_ORIGIN* = 8
-  SQL_DIAG_SUBCLASS_ORIGIN* = 9
-  SQL_DIAG_CONNECTION_NAME* = 10
-  SQL_DIAG_SERVER_NAME* = 11
-  SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes 
-  SQL_DIAG_ALTER_TABLE* = 4
-  SQL_DIAG_CREATE_INDEX* = (- 1)
-  SQL_DIAG_CREATE_TABLE* = 77
-  SQL_DIAG_CREATE_VIEW* = 84
-  SQL_DIAG_DELETE_WHERE* = 19
-  SQL_DIAG_DROP_INDEX* = (- 2)
-  SQL_DIAG_DROP_TABLE* = 32
-  SQL_DIAG_DROP_VIEW* = 36
-  SQL_DIAG_DYNAMIC_DELETE_CURSOR* = 38
-  SQL_DIAG_DYNAMIC_UPDATE_CURSOR* = 81
-  SQL_DIAG_GRANT* = 48
-  SQL_DIAG_INSERT* = 50
-  SQL_DIAG_REVOKE* = 59
-  SQL_DIAG_SELECT_CURSOR* = 85
-  SQL_DIAG_UNKNOWN_STATEMENT* = 0
-  SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity 
-  SQL_UNSPECIFIED* = 0
-  SQL_INSENSITIVE* = 1
-  SQL_SENSITIVE* = 2          # GetTypeInfo() request for all data types 
-  SQL_ALL_TYPES* = 0          # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() 
-  SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
-                    #    specifies the data type 
-  SQL_ARD_TYPE* = (- 99)      # SQL date/time type subcodes 
-  SQL_CODE_DATE* = 1
-  SQL_CODE_TIME* = 2
-  SQL_CODE_TIMESTAMP* = 3     # CLI option values 
-  SQL_FALSE* = 0
-  SQL_TRUE* = 1               # values of NULLABLE field in descriptor 
-  SQL_NO_NULLS* = 0
-  SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
-                    # not known whether or not a data type supports null values. 
-  SQL_NULLABLE_UNKNOWN* = 2 
-  SQL_CLOSE* = 0
-  SQL_DROP* = 1
-  SQL_UNBIND* = 2
-  SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
-                        #   and in SQLDataSources() 
-  SQL_FETCH_NEXT* = 1
-  SQL_FETCH_FIRST* = 2
-  SQL_FETCH_FIRST_USER* = 31
-  SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll() 
-  SQL_FETCH_LAST* = 3
-  SQL_FETCH_PRIOR* = 4
-  SQL_FETCH_ABSOLUTE* = 5
-  SQL_FETCH_RELATIVE* = 6   
-  SQL_NULL_HENV* = TSqlHEnv(nil)
-  SQL_NULL_HDBC* = TSqlHDBC(nil)
-  SQL_NULL_HSTMT* = TSqlHStmt(nil)
-  SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */
-  SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */
-  SQL_SCOPE_CURROW* = 0
-  SQL_SCOPE_TRANSACTION* = 1
-  SQL_SCOPE_SESSION* = 2      #* Column types and scopes in SQLSpecialColumns.  */
-  SQL_BEST_ROWID* = 1
-  SQL_ROWVER* = 2             
-  SQL_ROW_IDENTIFIER* = 1     #* Reserved values for UNIQUE argument of SQLStatistics() */
-  SQL_INDEX_UNIQUE* = 0
-  SQL_INDEX_ALL* = 1          #* Reserved values for RESERVED argument of SQLStatistics() */
-  SQL_QUICK* = 0
-  SQL_ENSURE* = 1             #* Values that may appear in the result set of SQLStatistics() */
-  SQL_TABLE_STAT* = 0
-  SQL_INDEX_CLUSTERED* = 1
-  SQL_INDEX_HASHED* = 2
-  SQL_INDEX_OTHER* = 3 
-  SQL_SCROLL_CONCURRENCY* = 43
-  SQL_TXN_CAPABLE* = 46
-  SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
-  SQL_USER_NAME* = 47
-  SQL_TXN_ISOLATION_OPTION* = 72
-  SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION 
-  SQL_OJ_CAPABILITIES* = 115
-  SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
-  SQL_XOPEN_CLI_YEAR* = 10000
-  SQL_CURSOR_SENSITIVITY* = 10001
-  SQL_DESCRIBE_PARAMETER* = 10002
-  SQL_CATALOG_NAME* = 10003
-  SQL_COLLATION_SEQ* = 10004
-  SQL_MAX_IDENTIFIER_LEN* = 10005
-  SQL_MAXIMUM_IDENTIFIER_LENGTH* = SQL_MAX_IDENTIFIER_LEN
-  SQL_SCCO_READ_ONLY* = 1
-  SQL_SCCO_LOCK* = 2
-  SQL_SCCO_OPT_ROWVER* = 4
-  SQL_SCCO_OPT_VALUES* = 8    #* SQL_TXN_CAPABLE values */
-  SQL_TC_NONE* = 0
-  SQL_TC_DML* = 1
-  SQL_TC_ALL* = 2
-  SQL_TC_DDL_COMMIT* = 3
-  SQL_TC_DDL_IGNORE* = 4      #* SQL_TXN_ISOLATION_OPTION bitmasks */
-  SQL_TXN_READ_UNCOMMITTED* = 1
-  SQL_TRANSACTION_READ_UNCOMMITTED* = SQL_TXN_READ_UNCOMMITTED
-  SQL_TXN_READ_COMMITTED* = 2
-  SQL_TRANSACTION_READ_COMMITTED* = SQL_TXN_READ_COMMITTED
-  SQL_TXN_REPEATABLE_READ* = 4
-  SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
-  SQL_TXN_SERIALIZABLE* = 8
-  SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE 
-  SQL_SS_ADDITIONS* = 1
-  SQL_SS_DELETIONS* = 2
-  SQL_SS_UPDATES* = 4         # SQLColAttributes defines 
-  SQL_COLUMN_COUNT* = 0
-  SQL_COLUMN_NAME* = 1
-  SQL_COLUMN_TYPE* = 2
-  SQL_COLUMN_LENGTH* = 3
-  SQL_COLUMN_PRECISION* = 4
-  SQL_COLUMN_SCALE* = 5
-  SQL_COLUMN_DISPLAY_SIZE* = 6
-  SQL_COLUMN_NULLABLE* = 7
-  SQL_COLUMN_UNSIGNED* = 8
-  SQL_COLUMN_MONEY* = 9
-  SQL_COLUMN_UPDATABLE* = 10
-  SQL_COLUMN_AUTO_INCREMENT* = 11
-  SQL_COLUMN_CASE_SENSITIVE* = 12
-  SQL_COLUMN_SEARCHABLE* = 13
-  SQL_COLUMN_TYPE_NAME* = 14
-  SQL_COLUMN_TABLE_NAME* = 15
-  SQL_COLUMN_OWNER_NAME* = 16
-  SQL_COLUMN_QUALIFIER_NAME* = 17
-  SQL_COLUMN_LABEL* = 18
-  SQL_COLATT_OPT_MAX* = SQL_COLUMN_LABEL
-  SQL_COLUMN_DRIVER_START* = 1000
-  SQL_DESC_ARRAY_SIZE* = 20
-  SQL_DESC_ARRAY_STATUS_PTR* = 21
-  SQL_DESC_AUTO_UNIQUE_VALUE* = SQL_COLUMN_AUTO_INCREMENT
-  SQL_DESC_BASE_COLUMN_NAME* = 22
-  SQL_DESC_BASE_TABLE_NAME* = 23
-  SQL_DESC_BIND_OFFSET_PTR* = 24
-  SQL_DESC_BIND_TYPE* = 25
-  SQL_DESC_CASE_SENSITIVE* = SQL_COLUMN_CASE_SENSITIVE
-  SQL_DESC_CATALOG_NAME* = SQL_COLUMN_QUALIFIER_NAME
-  SQL_DESC_CONCISE_TYPE* = SQL_COLUMN_TYPE
-  SQL_DESC_DATETIME_INTERVAL_PRECISION* = 26
-  SQL_DESC_DISPLAY_SIZE* = SQL_COLUMN_DISPLAY_SIZE
-  SQL_DESC_FIXED_PREC_SCALE* = SQL_COLUMN_MONEY
-  SQL_DESC_LABEL* = SQL_COLUMN_LABEL
-  SQL_DESC_LITERAL_PREFIX* = 27
-  SQL_DESC_LITERAL_SUFFIX* = 28
-  SQL_DESC_LOCAL_TYPE_NAME* = 29
-  SQL_DESC_MAXIMUM_SCALE* = 30
-  SQL_DESC_MINIMUM_SCALE* = 31
-  SQL_DESC_NUM_PREC_RADIX* = 32
-  SQL_DESC_PARAMETER_TYPE* = 33
-  SQL_DESC_ROWS_PROCESSED_PTR* = 34
-  SQL_DESC_SCHEMA_NAME* = SQL_COLUMN_OWNER_NAME
-  SQL_DESC_SEARCHABLE* = SQL_COLUMN_SEARCHABLE
-  SQL_DESC_TYPE_NAME* = SQL_COLUMN_TYPE_NAME
-  SQL_DESC_TABLE_NAME* = SQL_COLUMN_TABLE_NAME
-  SQL_DESC_UNSIGNED* = SQL_COLUMN_UNSIGNED
-  SQL_DESC_UPDATABLE* = SQL_COLUMN_UPDATABLE #* SQLEndTran() options */
-  SQL_COMMIT* = 0
-  SQL_ROLLBACK* = 1
-  SQL_ATTR_ROW_ARRAY_SIZE* = 27 #* SQLConfigDataSource() options */
-  ODBC_ADD_DSN* = 1
-  ODBC_CONFIG_DSN* = 2
-  ODBC_REMOVE_DSN* = 3
-  ODBC_ADD_SYS_DSN* = 4
-  ODBC_CONFIG_SYS_DSN* = 5
-  ODBC_REMOVE_SYS_DSN* = 6
-
-proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle, 
-                     OutputHandlePtr: var TSqlHandle): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, 
-                    Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, 
-                    Value: TSqlPointer, BufferLength: TSqlInteger, 
-                    StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: TSqlHandle): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                    RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR, 
-                    NativeError: var TSqlInteger, MessageText: PSQLCHAR, 
-                    BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                      RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, 
-                      DiagInfoPtr: TSqlPointer, BufferLength: TSqlSmallInt, 
-                      StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLConnect*(ConnectionHandle: TSqlHDBC, ServerName: PSQLCHAR, 
-                 NameLength1: TSqlSmallInt, UserName: PSQLCHAR, 
-                 NameLength2: TSqlSmallInt, Authentication: PSQLCHAR, 
-                 NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDisconnect*(ConnectionHandle: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring, 
-                       szCLen: TSqlSmallInt, szCsout: cstring, 
-                       cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, 
-                       f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR, 
-                       cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, 
-                       cbConnStrOutMax: TSqlSmallInt, 
-                       cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, 
-                    TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, 
-                 TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLDescribeCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                     ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                     NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, 
-                     ColumnSize: var TSqlUInteger, 
-                     DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLFetchScroll*(StatementHandle: TSqlHStmt, FetchOrientation: TSqlSmallInt, 
-                     FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt, 
-                       irow: TSqlInteger, pcrow: PSQLUINTEGER, 
-                       rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLGetData*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: TSqlPointer, 
-                 BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, 
-                     Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, 
-                     Value: TSqlPointer, BufferLength: TSqlInteger, 
-                     StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLGetInfo*(ConnectionHandle: TSqlHDBC, InfoType: TSqlUSmallInt, 
-                 InfoValue: TSqlPointer, BufferLength: TSqlSmallInt, 
-                 StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLBulkOperations*(StatementHandle: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer, 
-                 StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: TSqlPointer, 
-                 BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt, 
-                fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, 
-                     ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                     NameLength1: PSQLSMALLINT, Description: PSQLCHAR, 
-                     BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, 
-                 DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                 DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR, 
-                 BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetConnectAttr*(ConnectionHandle: TSqlHDBC, Attribute: TSqlInteger, 
-                        Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, 
-                       BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, 
-                       NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt, 
-                       fParamType: TSqlSmallInt, fCType: TSqlSmallInt, 
-                       fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger, 
-                       ibScale: TSqlSmallInt, rgbValue: TSqlPointer, 
-                       cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLFreeStmt*(StatementHandle: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                      FieldIdentifier: TSqlUSmallInt, 
-                      CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                      StringLength: PSQLSMALLINT, 
-                      NumericAttribute: TSqlPointer): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                 CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLTables*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                cbTableName: TSqlSmallInt, szTableType: PSQLCHAR, 
-                cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLColumns*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                 cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                 cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                 cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR, 
-                 cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLSpecialColumns*(StatementHandle: TSqlHStmt, IdentifierType: TSqlUSmallInt, 
-                        CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, 
-                        SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, 
-                        TableName: PSQLCHAR, NameLength3: TSqlSmallInt, 
-                        Scope: TSqlUSmallInt, 
-                        Nullable: TSqlUSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLProcedures*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                    cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                    cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                    cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLPrimaryKeys*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                     NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                     NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                     NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLProcedureColumns*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                          NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                          NameLength2: TSqlSmallInt, ProcName: PSQLCHAR, 
-                          NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR, 
-                          NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLStatistics*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                    NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                    NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                    NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt, 
-                    Reserved: TSqlUSmallInt): TSqlSmallInt {.
-                    dynlib: odbclib, importc.}
-
-{.pop.}
diff --git a/lib/oldwrappers/opengl/gl.nim b/lib/oldwrappers/opengl/gl.nim
deleted file mode 100755
index 79f09b544..000000000
--- a/lib/oldwrappers/opengl/gl.nim
+++ /dev/null
@@ -1,1432 +0,0 @@
-#
-#
-#  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.}
-proc glAlphaFunc*(func: TGLenum, theref: TGLclampf){.dynlib: dllname, importc.}
-proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, 
-                            residences: PGLboolean): TGLboolean{.dynlib: dllname, 
-    importc.}
-proc glArrayElement*(i: TGLint){.dynlib: dllname, importc.}
-proc glBegin*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname, importc.}
-proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, 
-               xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, 
-    importc.}
-proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, importc.}
-proc glCallList*(list: TGLuint){.dynlib: dllname, importc.}
-proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: Pointer){.dynlib: dllname, 
-    importc.}
-proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc.}
-proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc.}
-proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname, importc.}
-proc glClearDepth*(depth: TGLclampd){.dynlib: dllname, importc.}
-proc glClearIndex*(c: TGLfloat){.dynlib: dllname, importc.}
-proc glClearStencil*(s: TGLint){.dynlib: dllname, importc.}
-proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, importc.}
-proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname, importc.}
-proc glColor3bv*(v: PGLbyte){.dynlib: dllname, importc.}
-proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname, importc.}
-proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname, importc.}
-proc glColor3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glColor3i*(red, green, blue: TGLint){.dynlib: dllname, importc.}
-proc glColor3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname, importc.}
-proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname, importc.}
-proc glColor3ubv*(v: PGLubyte){.dynlib: dllname, importc.}
-proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname, importc.}
-proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc.}
-proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname, importc.}
-proc glColor3usv*(v: PGLushort){.dynlib: dllname, importc.}
-proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname, importc.}
-proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc.}
-proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname, importc.}
-proc glColor4dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc.}
-proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname, importc.}
-proc glColor4iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname, importc.}
-proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname, importc.}
-proc glColor4ubv*(v: PGLubyte){.dynlib: dllname, importc.}
-proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname, importc.}
-proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc.}
-proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname, importc.}
-proc glColor4usv*(v: PGLushort){.dynlib: dllname, importc.}
-proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname, importc.}
-proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, importc.}
-proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                     pointer: Pointer){.dynlib: dllname, importc.}
-proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){.
-    dynlib: dllname, importc.}
-proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, 
-                       x, y: TGLint, width: TGLsizei, border: TGLint){.
-    dynlib: dllname, importc.}
-proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, 
-                       x, y: TGLint, width, height: TGLsizei, border: TGLint){.
-    dynlib: dllname, importc.}
-proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint, 
-                          width: TGLsizei){.dynlib: dllname, importc.}
-proc glCopyTexSubImage2D*(target: TGLenum, level, xoffset, yoffset, x, y: TGLint, 
-                          width, height: TGLsizei){.dynlib: dllname, importc.}
-proc glCullFace*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname, importc.}
-proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc.}
-proc glDepthFunc*(func: TGLenum){.dynlib: dllname, importc.}
-proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc.}
-proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, importc.}
-proc glDisable*(cap: TGLenum){.dynlib: dllname, importc.}
-proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname, importc.}
-proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){.dynlib: dllname, 
-    importc.}
-proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, 
-                     indices: Pointer){.dynlib: dllname, importc.}
-proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, 
-                   pixels: Pointer){.dynlib: dllname, importc.}
-proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc.}
-proc glEdgeFlagPointer*(stride: TGLsizei, pointer: Pointer){.dynlib: dllname, 
-    importc.}
-proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc.}
-proc glEnable*(cap: TGLenum){.dynlib: dllname, importc.}
-proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname, importc.}
-proc glEnd*(){.dynlib: dllname, importc.}
-proc glEndList*(){.dynlib: dllname, importc.}
-proc glEvalCoord1d*(u: TGLdouble){.dynlib: dllname, importc.}
-proc glEvalCoord1dv*(u: PGLdouble){.dynlib: dllname, importc.}
-proc glEvalCoord1f*(u: TGLfloat){.dynlib: dllname, importc.}
-proc glEvalCoord1fv*(u: PGLfloat){.dynlib: dllname, importc.}
-proc glEvalCoord2d*(u, v: TGLdouble){.dynlib: dllname, importc.}
-proc glEvalCoord2dv*(u: PGLdouble){.dynlib: dllname, importc.}
-proc glEvalCoord2f*(u, v: TGLfloat){.dynlib: dllname, importc.}
-proc glEvalCoord2fv*(u: PGLfloat){.dynlib: dllname, importc.}
-proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname, importc.}
-proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname, importc.}
-proc glEvalPoint1*(i: TGLint){.dynlib: dllname, importc.}
-proc glEvalPoint2*(i, j: TGLint){.dynlib: dllname, importc.}
-proc glFeedbackBuffer*(size: TGLsizei, atype: TGLenum, buffer: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glFinish*(){.dynlib: dllname, importc.}
-proc glFlush*(){.dynlib: dllname, importc.}
-proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.}
-proc glFogi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.}
-proc glFrontFace*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glFrustum*(left, right, bottom, top, zNear, zFar: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname, importc.}
-proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc.}
-proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, importc.}
-proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname, importc.}
-proc glGetError*(): TGLenum{.dynlib: dllname, importc.}
-proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.}
-proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, importc.}
-proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, importc.}
-proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, importc.}
-proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, importc.}
-proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, importc.}
-proc glGetPointerv*(pname: TGLenum, params: Pointer){.dynlib: dllname, importc.}
-proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc.}
-proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, importc.}
-proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, atype: TGLenum, 
-                    pixels: Pointer){.dynlib: dllname, importc.}
-proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, 
-                               params: Pointer){.dynlib: dllname, importc.}
-proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, 
-                               params: PGLint){.dynlib: dllname, importc.}
-proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetTexParameteriv*(target, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glHint*(target, mode: TGLenum){.dynlib: dllname, importc.}
-proc glIndexMask*(mask: TGLuint){.dynlib: dllname, importc.}
-proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
-    dynlib: dllname, importc.}
-proc glIndexd*(c: TGLdouble){.dynlib: dllname, importc.}
-proc glIndexdv*(c: PGLdouble){.dynlib: dllname, importc.}
-proc glIndexf*(c: TGLfloat){.dynlib: dllname, importc.}
-proc glIndexfv*(c: PGLfloat){.dynlib: dllname, importc.}
-proc glIndexi*(c: TGLint){.dynlib: dllname, importc.}
-proc glIndexiv*(c: PGLint){.dynlib: dllname, importc.}
-proc glIndexs*(c: TGLshort){.dynlib: dllname, importc.}
-proc glIndexsv*(c: PGLshort){.dynlib: dllname, importc.}
-proc glIndexub*(c: TGLubyte){.dynlib: dllname, importc.}
-proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc.}
-proc glInitNames*(){.dynlib: dllname, importc.}
-proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, pointer: Pointer){.
-    dynlib: dllname, importc.}
-proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, importc.}
-proc glIsList*(list: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.}
-proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.}
-proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, importc.}
-proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname, importc.}
-proc glLineWidth*(width: TGLfloat){.dynlib: dllname, importc.}
-proc glListBase*(base: TGLuint){.dynlib: dllname, importc.}
-proc glLoadIdentity*(){.dynlib: dllname, importc.}
-proc glLoadMatrixd*(m: PGLdouble){.dynlib: dllname, importc.}
-proc glLoadMatrixf*(m: PGLfloat){.dynlib: dllname, importc.}
-proc glLoadName*(name: TGLuint){.dynlib: dllname, importc.}
-proc glLogicOp*(opcode: TGLenum){.dynlib: dllname, importc.}
-proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint, 
-              points: PGLdouble){.dynlib: dllname, importc.}
-proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint, 
-              points: PGLfloat){.dynlib: dllname, importc.}
-proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint, 
-              v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint, 
-              v1, v2: TGLfloat, vstride, vorder: TGLint, points: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname, importc.}
-proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname, importc.}
-proc glMapGrid2d*(un: TGLint, u1, u2: TGLdouble, vn: TGLint, v1, v2: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glMapGrid2f*(un: TGLint, u1, u2: TGLfloat, vn: TGLint, v1, v2: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glMatrixMode*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glMultMatrixd*(m: PGLdouble){.dynlib: dllname, importc.}
-proc glMultMatrixf*(m: PGLfloat){.dynlib: dllname, importc.}
-proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname, importc.}
-proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc.}
-proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc.}
-proc glNormal3d*(nx, ny, nz: TGLdouble){.dynlib: dllname, importc.}
-proc glNormal3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glNormal3f*(nx, ny, nz: TGLfloat){.dynlib: dllname, importc.}
-proc glNormal3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glNormal3i*(nx, ny, nz: TGLint){.dynlib: dllname, importc.}
-proc glNormal3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glNormal3s*(nx, ny, nz: TGLshort){.dynlib: dllname, importc.}
-proc glNormal3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
-    dynlib: dllname, importc.}
-proc glOrtho*(left, right, bottom, top, zNear, zFar: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glPassThrough*(token: TGLfloat){.dynlib: dllname, importc.}
-proc glPixelMapfv*(map: TGLenum, mapsize: TGLsizei, values: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glPixelMapuiv*(map: TGLenum, mapsize: TGLsizei, values: PGLuint){.
-    dynlib: dllname, importc.}
-proc glPixelMapusv*(map: TGLenum, mapsize: TGLsizei, values: PGLushort){.
-    dynlib: dllname, importc.}
-proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, importc.}
-proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc.}
-proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, importc.}
-proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, importc.}
-proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc.}
-proc glPopAttrib*(){.dynlib: dllname, importc.}
-proc glPopClientAttrib*(){.dynlib: dllname, importc.}
-proc glPopMatrix*(){.dynlib: dllname, importc.}
-proc glPopName*(){.dynlib: dllname, importc.}
-proc glPrioritizeTextures*(n: TGLsizei, textures: PGLuint, priorities: PGLclampf){.
-    dynlib: dllname, importc.}
-proc glPushAttrib*(mask: TGLbitfield){.dynlib: dllname, importc.}
-proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname, importc.}
-proc glPushMatrix*(){.dynlib: dllname, importc.}
-proc glPushName*(name: TGLuint){.dynlib: dllname, importc.}
-proc glRasterPos2d*(x, y: TGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos2dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos2f*(x, y: TGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos2fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos2i*(x, y: TGLint){.dynlib: dllname, importc.}
-proc glRasterPos2iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glRasterPos2s*(x, y: TGLshort){.dynlib: dllname, importc.}
-proc glRasterPos2sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos3i*(x, y, z: TGLint){.dynlib: dllname, importc.}
-proc glRasterPos3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname, importc.}
-proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos4dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname, importc.}
-proc glRasterPos4iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc.}
-proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, format, atype: TGLenum, 
-                   pixels: Pointer){.dynlib: dllname, importc.}
-proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc.}
-proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, importc.}
-proc glRectf*(x1, y1, x2, y2: TGLfloat){.dynlib: dllname, importc.}
-proc glRectfv*(v1: PGLfloat, v2: PGLfloat){.dynlib: dllname, importc.}
-proc glRecti*(x1, y1, x2, y2: TGLint){.dynlib: dllname, importc.}
-proc glRectiv*(v1: PGLint, v2: PGLint){.dynlib: dllname, importc.}
-proc glRects*(x1, y1, x2, y2: TGLshort){.dynlib: dllname, importc.}
-proc glRectsv*(v1: PGLshort, v2: PGLshort){.dynlib: dllname, importc.}
-proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname, importc.}
-proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname, importc.}
-proc glRotatef*(angle, x, y, z: TGLfloat){.dynlib: dllname, importc.}
-proc glScaled*(x, y, z: TGLdouble){.dynlib: dllname, importc.}
-proc glScalef*(x, y, z: TGLfloat){.dynlib: dllname, importc.}
-proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc.}
-proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, importc.}
-proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glStencilFunc*(func: TGLenum, theref: TGLint, mask: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc.}
-proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, importc.}
-proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord1f*(s: TGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord1fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord1i*(s: TGLint){.dynlib: dllname, importc.}
-proc glTexCoord1iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glTexCoord1s*(s: TGLshort){.dynlib: dllname, importc.}
-proc glTexCoord1sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glTexCoord2d*(s, t: TGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord2dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord2f*(s, t: TGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord2fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord2i*(s, t: TGLint){.dynlib: dllname, importc.}
-proc glTexCoord2iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glTexCoord2s*(s, t: TGLshort){.dynlib: dllname, importc.}
-proc glTexCoord2sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glTexCoord3d*(s, t, r: TGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord3f*(s, t, r: TGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord3i*(s, t, r: TGLint){.dynlib: dllname, importc.}
-proc glTexCoord3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glTexCoord3s*(s, t, r: TGLshort){.dynlib: dllname, importc.}
-proc glTexCoord3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord4fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord4i*(s, t, r, q: TGLint){.dynlib: dllname, importc.}
-proc glTexCoord4iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname, importc.}
-proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                        pointer: Pointer){.dynlib: dllname, importc.}
-proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexEnvfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexEnvi*(target: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, 
-    importc.}
-proc glTexEnviv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glTexGend*(coord: TGLenum, pname: TGLenum, param: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glTexGendv*(coord: TGLenum, pname: TGLenum, params: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glTexGenf*(coord: TGLenum, pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexGenfv*(coord: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, 
-    importc.}
-proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, width: TGLsizei, 
-                   border: TGLint, format, atype: TGLenum, pixels: Pointer){.
-    dynlib: dllname, importc.}
-proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, 
-                   width, height: TGLsizei, border: TGLint, format, atype: TGLenum, 
-                   pixels: Pointer){.dynlib: dllname, importc.}
-proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){.
-    dynlib: dllname, importc.}
-proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, 
-                      format, atype: TGLenum, pixels: Pointer){.dynlib: dllname, 
-    importc.}
-proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, 
-                      width, height: TGLsizei, format, atype: TGLenum, 
-                      pixels: Pointer){.dynlib: dllname, importc.}
-proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc.}
-proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc.}
-proc glVertex2d*(x, y: TGLdouble){.dynlib: dllname, importc.}
-proc glVertex2dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertex2f*(x, y: TGLfloat){.dynlib: dllname, importc.}
-proc glVertex2fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertex2i*(x, y: TGLint){.dynlib: dllname, importc.}
-proc glVertex2iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glVertex2s*(x, y: TGLshort){.dynlib: dllname, importc.}
-proc glVertex2sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glVertex3d*(x, y, z: TGLdouble){.dynlib: dllname, importc.}
-proc glVertex3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertex3f*(x, y, z: TGLfloat){.dynlib: dllname, importc.}
-proc glVertex3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertex3i*(x, y, z: TGLint){.dynlib: dllname, importc.}
-proc glVertex3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glVertex3s*(x, y, z: TGLshort){.dynlib: dllname, importc.}
-proc glVertex3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glVertex4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc.}
-proc glVertex4dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertex4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc.}
-proc glVertex4fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertex4i*(x, y, z, w: TGLint){.dynlib: dllname, importc.}
-proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc.}
-proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                      pointer: Pointer){.dynlib: dllname, importc.}
-proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc.}
-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/lib/oldwrappers/opengl/glext.nim b/lib/oldwrappers/opengl/glext.nim
deleted file mode 100755
index 0a2138584..000000000
--- a/lib/oldwrappers/opengl/glext.nim
+++ /dev/null
@@ -1,4175 +0,0 @@
-#
-#
-#  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.}
-proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, importc.}
-proc glDrawRangeElements*(mode: TGLenum, start: TGLuint, theend: TGLuint, 
-                          count: TGLsizei, thetype: TGLenum, indices: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glColorTable*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, 
-                   format: TGLenum, thetype: TGLenum, table: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glCopyColorTable*(target: TGLenum, internalformat: TGLenum, x: TGLint, 
-                       y: TGLint, width: TGLsizei){.dynlib: dllname, importc.}
-proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                      table: PGLvoid){.dynlib: dllname, importc.}
-proc glGetColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glColorSubTable*(target: TGLenum, start: TGLsizei, count: TGLsizei, 
-                      format: TGLenum, thetype: TGLenum, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glCopyColorSubTable*(target: TGLenum, start: TGLsizei, x: TGLint, y: TGLint, 
-                          width: TGLsizei){.dynlib: dllname, importc.}
-proc glConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, 
-                            width: TGLsizei, format: TGLenum, thetype: TGLenum, 
-                            image: PGLvoid){.dynlib: dllname, importc.}
-proc glConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, 
-                            width: TGLsizei, height: TGLsizei, format: TGLenum, 
-                            thetype: TGLenum, image: PGLvoid){.dynlib: dllname, 
-    importc.}
-proc glConvolutionParameterf*(target: TGLenum, pname: TGLenum, params: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameteri*(target: TGLenum, pname: TGLenum, params: TGLint){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glCopyConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, 
-                                x: TGLint, y: TGLint, width: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glCopyConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, 
-                                x: TGLint, y: TGLint, width: TGLsizei, 
-                                height: TGLsizei){.dynlib: dllname, importc.}
-proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                             image: PGLvoid){.dynlib: dllname, importc.}
-proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, 
-                                  params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetSeparableFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                           row: PGLvoid, column: PGLvoid, span: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glSeparableFilter2D*(target: TGLenum, internalformat: TGLenum, 
-                          width: TGLsizei, height: TGLsizei, format: TGLenum, 
-                          thetype: TGLenum, row: PGLvoid, column: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetHistogram*(target: TGLenum, reset: TGLboolean, format: TGLenum, 
-                     thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.}
-proc glGetHistogramParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetHistogramParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetMinmax*(target: TGLenum, reset: TGLboolean, format: TGLenum, 
-                  thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.}
-proc glGetMinmaxParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetMinmaxParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glHistogram*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, 
-                  sink: TGLboolean){.dynlib: dllname, importc.}
-proc glMinmax*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){.
-    dynlib: dllname, importc.}
-proc glResetHistogram*(target: TGLenum){.dynlib: dllname, importc.}
-proc glResetMinmax*(target: TGLenum){.dynlib: dllname, importc.}
-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.}
-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.}
-proc glCopyTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                          yoffset: TGLint, zoffset: TGLint, x: TGLint, y: TGLint, 
-                          width: TGLsizei, height: TGLsizei){.dynlib: dllname, 
-    importc.}
-
-
-proc glActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc.}
-proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc.}
-proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord1svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2iARB*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord2sARB*(target: TGLenum, s: TGLshort, t: TGLshort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord3iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, 
-                           r: TGLdouble, q: TGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, 
-                           q: TGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, 
-                           q: TGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, 
-                           q: TGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord4svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, 
-    importc.}
-
-proc glSampleCoverageARB*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, 
-    importc.}
-  #***** GL_ARB_texture_env_add *****//
-
-
-proc glWeightbvARB*(size: TGLint, weights: PGLbyte){.dynlib: dllname, importc.}
-proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, importc.}
-proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, importc.}
-proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, importc.}
-proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc.}
-proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc.}
-proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, importc.}
-proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, importc.}
-proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, importc.}
-proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                         pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, importc.}
-
-
-
-proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib2sARB*(index: TGLuint, x: TGLshort, y: TGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib4sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, 
-                          w: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, 
-                          w: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, 
-                          w: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4NubARB*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, 
-                            w: TGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.}
-proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.}
-proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.}
-proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib4NuivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glVertexAttribPointerARB*(index: TGLuint, size: TGLint, thetype: TGLenum, 
-                               normalized: TGLboolean, stride: TGLsizei, 
-                               pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc.}
-proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc.}
-proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, 
-                         str: PGLvoid){.dynlib: dllname, importc.}
-proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, importc.}
-proc glProgramEnvParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, 
-                                 y: TGLdouble, z: TGLdouble, w: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glProgramEnvParameter4dvARB*(target: TGLenum, index: TGLuint, 
-                                  params: PGLdouble){.dynlib: dllname, importc.}
-proc glProgramEnvParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, 
-                                 y: TGLfloat, z: TGLfloat, w: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glProgramEnvParameter4fvARB*(target: TGLenum, index: TGLuint, 
-                                  params: PGLfloat){.dynlib: dllname, importc.}
-proc glProgramLocalParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, 
-                                   y: TGLdouble, z: TGLdouble, w: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glProgramLocalParameter4dvARB*(target: TGLenum, index: TGLuint, 
-                                    params: PGLdouble){.dynlib: dllname, importc.}
-proc glProgramLocalParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, 
-                                   y: TGLfloat, z: TGLfloat, w: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glProgramLocalParameter4fvARB*(target: TGLenum, index: TGLuint, 
-                                    params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, 
-                                    params: PGLdouble){.dynlib: dllname, importc.}
-proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, 
-                                    params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, 
-                                      params: PGLdouble){.dynlib: dllname, 
-    importc.}
-proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, 
-                                      params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetProgramivARB*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetProgramStringARB*(target: TGLenum, pname: TGLenum, str: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribdvARB*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribfvARB*(index: TGLuint, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribivARB*(index: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribPointervARB*(index: TGLuint, pname: TGLenum, 
-                                   pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-  #***** GL_ARB_window_pos *****//
-proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.}
-proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos2svARB*(p: PGLshort){.dynlib: dllname, importc.}
-proc glWindowPos3dARB*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3fARB*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos3svARB*(p: PGLshort){.dynlib: dllname, importc.}
-
-
-
-proc glBlendEquationSeparate*(modeRGB: TGLenum, modeAlpha: TGLenum){.
-    dynlib: dllname, importc.}
-proc glDrawBuffers*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc.}
-proc glStencilOpSeparate*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, 
-                          dppass: TGLenum){.dynlib: dllname, importc.}
-proc glStencilFuncSeparate*(frontfunc: TGLenum, backfunc: TGLenum, theRef: TGLint, 
-                            mask: TGLuint){.dynlib: dllname, importc.}
-proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glAttachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glBindAttribLocation*(theProgram: TGLuint, index: TGLuint, name: PGLchar){.
-    dynlib: dllname, importc.}
-proc glCompileShader*(shader: TGLuint){.dynlib: dllname, importc.}
-proc glCreateProgram*(): TGLuint{.dynlib: dllname, importc.}
-proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, importc.}
-proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, importc.}
-proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, importc.}
-proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc.}
-proc glEnableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc.}
-proc glGetActiveAttrib*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, 
-                        len: PGLsizei, size: PGLint, thetype: PGLenum, 
-                        name: PGLchar){.dynlib: dllname, importc.}
-proc glGetActiveUniform*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, 
-                         len: PGLsizei, size: PGLint, thetype: PGLenum, 
-                         name: PGLchar){.dynlib: dllname, importc.}
-proc glGetAttachedShaders*(theProgram: TGLuint, maxCount: TGLsizei, 
-                           count: PGLsizei, obj: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glGetAttribLocation*(theProgram: TGLuint, name: PGLchar): TGLint{.
-    dynlib: dllname, importc.}
-proc glGetProgramiv*(theProgram: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetProgramInfoLog*(theProgram: TGLuint, bufSize: TGLsizei, len: PGLsizei, 
-                          infoLog: PGLchar){.dynlib: dllname, importc.}
-proc glGetShaderiv*(shader: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetShaderInfoLog*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, 
-                         infoLog: PGLchar){.dynlib: dllname, importc.}
-proc glGetShaderSource*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, 
-                        source: PGLchar){.dynlib: dllname, importc.}
-proc glGetUniformLocation*(theProgram: TGLuint, name: PGLchar): TGLint{.
-    dynlib: dllname, importc.}
-proc glGetUniformfv*(theProgram: TGLuint, location: TGLint, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetUniformiv*(theProgram: TGLuint, location: TGLint, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribdv*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribfv*(index: TGLuint, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribiv*(index: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribPointerv*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glIsProgram*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glLinkProgram*(theProgram: TGLuint){.dynlib: dllname, importc.}
-proc glShaderSource*(shader: TGLuint, count: TGLsizei, str: PGLchar, len: PGLint){.
-    dynlib: dllname, importc.}
-proc glUseProgram*(theProgram: TGLuint){.dynlib: dllname, importc.}
-proc glUniform1f*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc.}
-proc glUniform2f*(location: TGLint, v0: TGLfloat, v1: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glUniform3f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform4f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, 
-                  v3: TGLfloat){.dynlib: dllname, importc.}
-proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, importc.}
-proc glUniform2i*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, 
-    importc.}
-proc glUniform3i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){.
-    dynlib: dllname, importc.}
-proc glUniform4i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){.
-    dynlib: dllname, importc.}
-proc glUniform1fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform2fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform3fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform4fv*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform1iv*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform2iv*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform3iv*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform4iv*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniformMatrix2fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, 
-                         value: PGLfloat){.dynlib: dllname, importc.}
-proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, 
-                         value: PGLfloat){.dynlib: dllname, importc.}
-proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, 
-                         value: PGLfloat){.dynlib: dllname, importc.}
-proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, importc.}
-proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib1sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib2d*(index: TGLuint, x: TGLdouble, y: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib2f*(index: TGLuint, x: TGLfloat, y: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib2fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib2s*(index: TGLuint, x: TGLshort, y: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexAttrib2sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib3d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib3f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib3s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, 
-                         w: TGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.}
-proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, 
-                       w: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, 
-                       w: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.}
-proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, 
-                       w: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.}
-proc glVertexAttrib4usv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttribPointer*(index: TGLuint, size: TGLint, thetype: TGLenum, 
-                            normalized: TGLboolean, stride: TGLsizei, 
-                            pointer: PGLvoid){.dynlib: dllname, importc.}
-
-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.}
-proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, importc.}
-proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord1sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord2d*(target: TGLenum, s: TGLdouble, t: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord2f*(target: TGLenum, s: TGLfloat, t: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord2s*(target: TGLenum, s: TGLshort, t: TGLshort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord3f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord3i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord3s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble, 
-                        q: TGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.}
-proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, 
-                        q: TGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.}
-proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, q: TGLint){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.}
-proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, 
-                        q: TGLshort){.dynlib: dllname, importc.}
-proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.}
-proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc.}
-proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc.}
-proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc.}
-proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc.}
-proc glSampleCoverage*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, 
-    importc.}
-proc glCompressedTexImage3D*(target: TGLenum, level: TGLint, 
-                             internalformat: TGLenum, width: TGLsizei, 
-                             height: TGLsizei, depth: TGLsizei, border: TGLint, 
-                             imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glCompressedTexImage2D*(target: TGLenum, level: TGLint, 
-                             internalformat: TGLenum, width: TGLsizei, 
-                             height: TGLsizei, border: TGLint, imageSize: TGLsizei, 
-                             data: PGLvoid){.dynlib: dllname, importc.}
-proc glCompressedTexImage1D*(target: TGLenum, level: TGLint, 
-                             internalformat: TGLenum, width: TGLsizei, 
-                             border: TGLint, imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-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.}
-proc glCompressedTexSubImage2D*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                                yoffset: TGLint, width: TGLsizei, height: TGLsizei, 
-                                format: TGLenum, imageSize: TGLsizei, 
-                                data: PGLvoid){.dynlib: dllname, importc.}
-proc glCompressedTexSubImage1D*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                                width: TGLsizei, format: TGLenum, 
-                                imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetCompressedTexImage*(target: TGLenum, level: TGLint, img: PGLvoid){.
-    dynlib: dllname, importc.}
-
-  #***** 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.}
-proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc.}
-proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, importc.}
-proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc.}
-
-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.}
-proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-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.}
-proc glCompressedTexImage2DARB*(target: TGLenum, level: TGLint, 
-                                internalformat: TGLenum, width: TGLsizei, 
-                                height: TGLsizei, border: TGLint, 
-                                imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glCompressedTexImage1DARB*(target: TGLenum, level: TGLint, 
-                                internalformat: TGLenum, width: TGLsizei, 
-                                border: TGLint, imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-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.}
-proc glCompressedTexSubImage2DARB*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                                   yoffset: TGLint, width: TGLsizei, 
-                                   height: TGLsizei, format: TGLenum, 
-                                   imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glCompressedTexSubImage1DARB*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                                   width: TGLsizei, format: TGLenum, 
-                                   imageSize: TGLsizei, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetCompressedTexImageARB*(target: TGLenum, lod: TGLint, img: PGLvoid){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-  #***** 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.}
-  #***** 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.}
-  #***** 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.}
-proc glCopyColorSubTableEXT*(target: TGLenum, start: TGLsizei, x: TGLint, y: TGLint, 
-                             width: TGLsizei){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glUnlockArraysEXT*(){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, 
-                               width: TGLsizei, height: TGLsizei, format: TGLenum, 
-                               thetype: TGLenum, image: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glCopyConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, 
-                                   x: TGLint, y: TGLint, width: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glCopyConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, 
-                                   x: TGLint, y: TGLint, width: TGLsizei, 
-                                   height: TGLsizei){.dynlib: dllname, importc.}
-proc glGetConvolutionFilterEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                                image: PGLvoid){.dynlib: dllname, importc.}
-proc glSeparableFilter2DEXT*(target: TGLenum, internalformat: TGLenum, 
-                             width: TGLsizei, height: TGLsizei, format: TGLenum, 
-                             thetype: TGLenum, row: PGLvoid, column: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetSeparableFilterEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                              row: PGLvoid, column: PGLvoid, span: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameteriEXT*(target: TGLenum, pname: TGLenum, param: TGLint){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, 
-                                  params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, 
-                                     params: PGLint){.dynlib: dllname, importc.}
-proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, 
-                                     params: PGLfloat){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, importc.}
-proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, importc.}
-proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, importc.}
-proc glFogCoordPointerEXT*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, importc.}
-proc glGetHistogramEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, 
-                        thetype: TGLenum, values: PGLvoid){.dynlib: dllname, 
-    importc.}
-proc glGetHistogramParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetHistogramParameterfvEXT*(target: TGLenum, pname: TGLenum, 
-                                   params: PGLfloat){.dynlib: dllname, importc.}
-proc glMinmaxEXT*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){.
-    dynlib: dllname, importc.}
-proc glResetMinmaxEXT*(target: TGLenum){.dynlib: dllname, importc.}
-proc glGetMinmaxEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, 
-                     thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.}
-proc glGetMinmaxParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetMinmaxParameterfvEXT*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-  #***** GL_EXT_multi_draw_arrays *****//
-proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, 
-                           primcount: TGLsizei){.dynlib: dllname, importc.}
-proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, 
-                             indices: PGLvoid, primcount: TGLsizei){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-  # glColorSubTableEXT  { already defined }
-proc glGetColorTableEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                         data: PGLvoid){.dynlib: dllname, importc.}
-proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, 
-                                    params: PGLint){.dynlib: dllname, importc.}
-proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, 
-                                    params: PGLfloat){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-  #***** 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.}
-proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, importc.}
-proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, importc.}
-proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, importc.}
-proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, importc.}
-proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, importc.}
-proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, importc.}
-proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, importc.}
-proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, importc.}
-proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, importc.}
-proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, importc.}
-proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, importc.}
-proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, importc.}
-proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, importc.}
-proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, importc.}
-proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, importc.}
-proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                                 pointer: PGLvoid){.dynlib: dllname, importc.}
-  #***** 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.}
-  #***** 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.}
-proc glTexSubImage2DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, 
-                         yoffset: TGLint, width: TGLsizei, height: TGLsizei, 
-                         format: TGLenum, thetype: TGLenum, pixels: PGLvoid){.
-    dynlib: dllname, importc.}
-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.}
-  #***** 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.}
-  #***** 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.}
-proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, 
-                              priorities: PGLclampf){.dynlib: dllname, importc.}
-proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, 
-                               residences: PGLboolean): TGLboolean{.
-    dynlib: dllname, importc.}
-proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-  #***** 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.}
-proc glDrawArraysEXT*(mode: TGLenum, first: TGLint, count: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glVertexPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                         count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, 
-    importc.}
-proc glNormalPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, 
-                         pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                        count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, 
-    importc.}
-proc glIndexPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, 
-                        pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glTexCoordPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                           count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, 
-    importc.}
-proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, pointer: PGLboolean){.
-    dynlib: dllname, importc.}
-proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glEndVertexShaderEXT*(){.dynlib: dllname, importc.}
-proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc.}
-proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, importc.}
-proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc.}
-proc glShaderOp1EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glShaderOp2EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint){.
-    dynlib: dllname, importc.}
-proc glShaderOp3EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint, 
-                     arg3: TGLuint){.dynlib: dllname, importc.}
-proc glSwizzleEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, 
-                   outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc.}
-proc glWriteMaskEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, 
-                     outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc.}
-proc glInsertComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){.
-    dynlib: dllname, importc.}
-proc glExtractComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){.
-    dynlib: dllname, importc.}
-proc glGenSymbolsEXT*(datatype: TGLenum, storagetype: TGLenum, range: TGLenum, 
-                      components: TGLuint): TGLuint{.dynlib: dllname, importc.}
-proc glSetInvariantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glSetLocalConstantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glVariantbvEXT*(id: TGLuint, address: PGLbyte){.dynlib: dllname, importc.}
-proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, importc.}
-proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, importc.}
-proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, importc.}
-proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, importc.}
-proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, importc.}
-proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, importc.}
-proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, importc.}
-proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, 
-                          address: PGLvoid){.dynlib: dllname, importc.}
-proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc.}
-proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc.}
-proc glBindLightParameterEXT*(light: TGLenum, value: TGLenum): TGLuint{.
-    dynlib: dllname, importc.}
-proc glBindMaterialParameterEXT*(face: TGLenum, value: TGLenum): TGLuint{.
-    dynlib: dllname, importc.}
-proc glBindTexGenParameterEXT*(theunit: TGLenum, coord: TGLenum, value: TGLenum): TGLuint{.
-    dynlib: dllname, importc.}
-proc glBindTextureUnitParameterEXT*(theunit: TGLenum, value: TGLenum): TGLuint{.
-    dynlib: dllname, importc.}
-proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, importc.}
-proc glIsVariantEnabledEXT*(id: TGLuint, cap: TGLenum): TGLboolean{.
-    dynlib: dllname, importc.}
-proc glGetVariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){.
-    dynlib: dllname, importc.}
-proc glGetVariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetVariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetVariantPointervEXT*(id: TGLuint, value: TGLenum, data: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetInvariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){.
-    dynlib: dllname, importc.}
-proc glGetInvariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetInvariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetLocalConstantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){.
-    dynlib: dllname, importc.}
-proc glGetLocalConstantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetLocalConstantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                               pointer: PGLvoid){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, 
-                              ustride: TGLsizei, vstride: TGLsizei, 
-                              thepacked: TGLboolean, points: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glGetMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetMapAttribParameterivNV*(target: TGLenum, index: TGLuint, pname: TGLenum, 
-                                  params: PGLint){.dynlib: dllname, importc.}
-proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, 
-                                  params: PGLfloat){.dynlib: dllname, importc.}
-proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.}
-proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, importc.}
-proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, importc.}
-proc glIsFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glGetFenceivNV*(fence: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, importc.}
-proc glEndOcclusionQueryNV*(){.dynlib: dllname, importc.}
-proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetOcclusionQueryuivNV*(id: TGLuint, pname: TGLenum, params: PGLuint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glCombinerParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, 
-    importc.}
-proc glCombinerInputNV*(stage: TGLenum, portion: TGLenum, variable: TGLenum, 
-                        input: TGLenum, mapping: TGLenum, componentUsage: TGLenum){.
-    dynlib: dllname, importc.}
-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.}
-proc glFinalCombinerInputNV*(variable: TGLenum, input: TGLenum, mapping: TGLenum, 
-                             componentUsage: TGLenum){.dynlib: dllname, importc.}
-proc glGetCombinerInputParameterfvNV*(stage: TGLenum, portion: TGLenum, 
-                                      variable: TGLenum, pname: TGLenum, 
-                                      params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetCombinerInputParameterivNV*(stage: TGLenum, portion: TGLenum, 
-                                      variable: TGLenum, pname: TGLenum, 
-                                      params: PGLint){.dynlib: dllname, importc.}
-proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, 
-                                       pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, 
-                                       pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, 
-    params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, 
-    params: PGLint){.dynlib: dllname, importc.}
-  #***** GL_NV_register_combiners2 *****//
-const 
-  GL_PER_STAGE_CONSTANTS_NV* = 0x00008535
-
-proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, 
-                                   params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, 
-                                      params: PGLfloat){.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glDeleteProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.}
-proc glExecuteProgramNV*(target: TGLenum, id: TGLuint, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGenProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.}
-proc glAreProgramsResidentNV*(n: TGLsizei, ids: PGLuint, residences: PGLboolean): TGLboolean{.
-    dynlib: dllname, importc.}
-proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glGetProgramParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, 
-                                params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetProgramParameterdvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, 
-                                params: PGLdouble){.dynlib: dllname, importc.}
-proc glGetProgramivNV*(id: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetProgramStringNV*(id: TGLuint, pname: TGLenum, theProgram: PGLubyte){.
-    dynlib: dllname, importc.}
-proc glGetTrackMatrixivNV*(target: TGLenum, address: TGLuint, pname: TGLenum, 
-                           params: PGLint){.dynlib: dllname, importc.}
-proc glGetVertexAttribdvNV*(index: TGLuint, pname: TGLenum, params: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribfvNV*(index: TGLuint, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribivNV*(index: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetVertexAttribPointervNV*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, 
-                      theProgram: PGLubyte){.dynlib: dllname, importc.}
-proc glProgramParameter4fNV*(target: TGLenum, index: TGLuint, x: TGLfloat, 
-                             y: TGLfloat, z: TGLfloat, w: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glProgramParameter4fvNV*(target: TGLenum, index: TGLuint, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glProgramParameters4dvNV*(target: TGLenum, index: TGLuint, num: TGLuint, 
-                               params: PGLdouble){.dynlib: dllname, importc.}
-proc glProgramParameters4fvNV*(target: TGLenum, index: TGLuint, num: TGLuint, 
-                               params: PGLfloat){.dynlib: dllname, importc.}
-proc glTrackMatrixNV*(target: TGLenum, address: TGLuint, matrix: TGLenum, 
-                      transform: TGLenum){.dynlib: dllname, importc.}
-proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, 
-                              stride: TGLsizei, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib2sNV*(index: TGLuint, x: TGLshort, y: TGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib4sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, 
-                         w: TGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, 
-                         w: TGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, 
-                         w: TGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4ubNV*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, 
-                          w: TGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.}
-proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.}
-proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.}
-proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.}
-proc glVertexAttribs1svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs1fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs1dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs2svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs2fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs2dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs3svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs3fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs3dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs4svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs4fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs4dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs4ubvNV*(index: TGLuint, n: TGLsizei, v: PGLubyte){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, 
-    importc.}
-proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, 
-                                 count: TGLsizei){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, 
-    importc.}
-proc glGetTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc.}
-proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc.}
-proc glBeginFragmentShaderATI*(){.dynlib: dllname, importc.}
-proc glEndFragmentShaderATI*(){.dynlib: dllname, importc.}
-proc glPassTexCoordATI*(dst: TGLuint, coord: TGLuint, swizzle: TGLenum){.
-    dynlib: dllname, importc.}
-proc glSampleMapATI*(dst: TGLuint, interp: TGLuint, swizzle: TGLenum){.
-    dynlib: dllname, importc.}
-proc glColorFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, 
-                            dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, 
-                            arg1Mod: TGLuint){.dynlib: dllname, importc.}
-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.}
-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.}
-proc glAlphaFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, 
-                            arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint){.
-    dynlib: dllname, importc.}
-proc glAlphaFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, 
-                            arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, 
-                            arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint){.
-    dynlib: dllname, importc.}
-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.}
-proc glSetFragmentShaderConstantATI*(dst: TGLuint, value: PGLfloat){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glUpdateObjectBufferATI*(buffer: TGLuint, offset: TGLuint, size: TGLsizei, 
-                              pointer: PGLvoid, preserve: TGLenum){.
-    dynlib: dllname, importc.}
-proc glGetObjectBufferfvATI*(buffer: TGLuint, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetObjectBufferivATI*(buffer: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glDeleteObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc.}
-proc glArrayObjectATI*(thearray: TGLenum, size: TGLint, thetype: TGLenum, 
-                       stride: TGLsizei, buffer: TGLuint, offset: TGLuint){.
-    dynlib: dllname, importc.}
-proc glGetArrayObjectfvATI*(thearray: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetArrayObjectivATI*(thearray: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glVariantArrayObjectATI*(id: TGLuint, thetype: TGLenum, stride: TGLsizei, 
-                              buffer: TGLuint, offset: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetVariantArrayObjectivATI*(id: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, importc.}
-proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.}
-proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, importc.}
-proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glMultiModeDrawElementsIBM*(mode: PGLenum, count: PGLsizei, 
-                                 thetype: TGLenum, indices: PGLvoid, 
-                                 primcount: TGLsizei, modestride: TGLint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glSecondaryColorPointerListIBM*(size: TGLint, thetype: TGLenum, 
-                                     stride: TGLint, pointer: PGLvoid, 
-                                     ptrstride: TGLint){.dynlib: dllname, importc.}
-proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, 
-                               ptrstride: TGLint){.dynlib: dllname, importc.}
-proc glFogCoordPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, 
-                               ptrstride: TGLint){.dynlib: dllname, importc.}
-proc glNormalPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, 
-                             ptrstride: TGLint){.dynlib: dllname, importc.}
-proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, 
-                               pointer: PGLvoid, ptrstride: TGLint){.
-    dynlib: dllname, importc.}
-proc glVertexPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, 
-                             pointer: PGLvoid, ptrstride: TGLint){.
-    dynlib: dllname, importc.}
-  #***** GL_MESA_resize_buffers *****//
-proc glResizeBuffersMESA*(){.dynlib: dllname, importc.}
-  #***** GL_MESA_window_pos *****//
-proc glWindowPos2dMESA*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.}
-proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, importc.}
-proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3ivMESA*(p: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, importc.}
-proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos4iMESA*(x: TGLint, y: TGLint, z: TGLint, w: TGLint){.
-    dynlib: dllname, importc.}
-proc glWindowPos4sMESA*(x: TGLshort, y: TGLshort, z: TGLshort, w: TGLshort){.
-    dynlib: dllname, importc.}
-proc glWindowPos4fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glWindowPos4dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble, w: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glWindowPos4ivMESA*(p: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, importc.}
-proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glPixelTexGenParameterfSGIS*(pname: TGLenum, param: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetPixelTexGenParameterivSGIS*(pname: TGLenum, params: TGLint){.
-    dynlib: dllname, importc.}
-proc glGetPixelTexGenParameterfvSGIS*(pname: TGLenum, params: TGLfloat){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-  #***** 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.}
-proc glCopyColorTableSGI*(target: TGLenum, internalformat: TGLenum, x: TGLint, 
-                          y: TGLint, width: TGLsizei){.dynlib: dllname, importc.}
-proc glColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, 
-                         table: PGLvoid){.dynlib: dllname, importc.}
-proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, 
-                                    params: PGLint){.dynlib: dllname, importc.}
-proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, 
-                                    params: PGLfloat){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc.}
-proc glColor4ubVertex3fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, 
-                            x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glColor4ubVertex3fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc.}
-proc glColor3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, 
-                           y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.}
-proc glColor3fVertex3fvSUN*(c: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-proc glNormal3fVertex3fSUN*(nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, 
-                            y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.}
-proc glNormal3fVertex3fvSUN*(n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-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.}
-proc glColor4fNormal3fVertex3fvSUN*(c: PGLfloat, n: PGLfloat, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexCoord2fVertex3fSUN*(s: TGLfloat, t: TGLfloat, x: TGLfloat, y: TGLfloat, 
-                              z: TGLfloat){.dynlib: dllname, importc.}
-proc glTexCoord2fVertex3fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexCoord4fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, q: TGLfloat, 
-                              x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexCoord2fColor4ubVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLubyte, 
-                                      g: TGLubyte, b: TGLubyte, a: TGLubyte, 
-                                      x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexCoord2fColor4ubVertex3fvSUN*(tc: PGLfloat, c: PGLubyte, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexCoord2fColor3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, 
-                                     g: TGLfloat, b: TGLfloat, x: TGLfloat, 
-                                     y: TGLfloat, z: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexCoord2fColor3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glTexCoord2fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, nx: TGLfloat, 
-                                      ny: TGLfloat, nz: TGLfloat, x: TGLfloat, 
-                                      y: TGLfloat, z: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glTexCoord2fNormal3fVertex3fvSUN*(tc: PGLfloat, n: PGLfloat, v: PGLfloat){.
-    dynlib: dllname, importc.}
-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.}
-proc glTexCoord2fColor4fNormal3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, 
-    n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-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.}
-proc glTexCoord4fColor4fNormal3fVertex4fvSUN*(tc: PGLfloat, c: PGLfloat, 
-    n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiVertex3fSUN*(rc: TGLuint, x: TGLfloat, y: TGLfloat, 
-                                     z: TGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiVertex3fvSUN*(rc: PGLuint, v: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glReplacementCodeuiColor4ubVertex3fSUN*(rc: TGLuint, r: TGLubyte, g: TGLubyte, 
-    b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glReplacementCodeuiColor4ubVertex3fvSUN*(rc: PGLuint, c: PGLubyte, 
-    v: PGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiColor3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, g: TGLfloat, 
-    b: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiColor3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, 
-    v: PGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiNormal3fVertex3fSUN*(rc: TGLuint, nx: TGLfloat, 
-    ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glReplacementCodeuiNormal3fVertex3fvSUN*(rc: PGLuint, n: PGLfloat, 
-    v: PGLfloat){.dynlib: dllname, importc.}
-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.}
-proc glReplacementCodeuiColor4fNormal3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, 
-    n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiTexCoord2fVertex3fSUN*(rc: TGLuint, s: TGLfloat, 
-    t: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiTexCoord2fVertex3fvSUN*(rc: PGLuint, tc: PGLfloat, 
-    v: PGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN*(rc: TGLuint, s: TGLfloat, 
-    t: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, 
-    z: TGLfloat){.dynlib: dllname, importc.}
-proc glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN*(rc: PGLuint, 
-    tc: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.}
-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.}
-proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, 
-    tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.}
-proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.}
-proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glBufferDataARB*(target: TGLenum, size: TGLsizei, data: PGLvoid, 
-                      usage: TGLenum){.dynlib: dllname, importc.}
-proc glBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, 
-                         data: PGLvoid){.dynlib: dllname, importc.}
-proc glGetBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, 
-                            data: PGLvoid){.dynlib: dllname, importc.}
-proc glMapBufferARB*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, 
-    importc.}
-proc glUnmapBufferARB*(target: TGLenum): TGLboolean{.dynlib: dllname, importc.}
-proc glGetBufferParameterivARB*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetBufferPointervARB*(target: TGLenum, pname: TGLenum, params: PPGLvoid){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glDrawElementArrayAPPLE*(mode: TGLenum, first: TGLint, count: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, theend: TGLuint, 
-                                   first: TGLint, count: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, count: PGLsizei, 
-                                   primcount: TGLsizei){.dynlib: dllname, importc.}
-proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, 
-                                        theend: TGLuint, first: PGLint, 
-                                        count: PGLsizei, primcount: TGLsizei){.
-    dynlib: dllname, importc.}
-  #***** GL_APPLE_fence *****//
-const 
-  GL_DRAW_PIXELS_APPLE* = 0x00008A0A
-  GL_FENCE_APPLE* = 0x00008A0B
-
-proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.}
-proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.}
-proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc.}
-proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glFinishFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc.}
-proc glTestObjectAPPLE*(theobject: TGLenum, name: TGLuint): TGLboolean{.
-    dynlib: dllname, importc.}
-proc glFinishObjectAPPLE*(theobject: TGLenum, name: TGLint){.dynlib: dllname, 
-    importc.}
-  #***** GL_APPLE_vertex_array_object *****//
-const 
-  GL_VERTEX_ARRAY_BINDING_APPLE* = 0x000085B5
-
-proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, importc.}
-proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-proc glFlushVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glVertexArrayParameteriAPPLE*(pname: TGLenum, param: TGLint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, 
-    importc.}
-proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                              pointer: PGLvoid){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glDrawElementArrayNV*(mode: TGLenum, first: TGLint, count: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, theend: TGLuint, 
-                                first: TGLint, count: TGLsizei){.dynlib: dllname, 
-    importc.}
-proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, 
-                                primcount: TGLsizei){.dynlib: dllname, importc.}
-proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, 
-                                     theend: TGLuint, first: PGLint, 
-                                     count: PGLsizei, primcount: TGLsizei){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glProgramNamedParameter4dNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, 
-                                  x: TGLdouble, y: TGLdouble, z: TGLdouble, 
-                                  w: TGLdouble){.dynlib: dllname, importc.}
-proc glGetProgramNamedParameterfvNV*(id: TGLuint, length: TGLsizei, 
-                                     name: PGLubyte, params: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, 
-                                     name: PGLubyte, params: PGLdouble){.
-    dynlib: dllname, importc.}
-  # 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.}
-proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, importc.}
-  # 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.}
-  #***** 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.}
-proc glVertex2hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glVertex3hNV*(x: TGLushort, y: TGLushort, z: TGLushort){.dynlib: dllname, 
-    importc.}
-proc glVertex3hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glVertex4hNV*(x: TGLushort, y: TGLushort, z: TGLushort, w: TGLushort){.
-    dynlib: dllname, importc.}
-proc glVertex4hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glNormal3hNV*(nx: TGLushort, ny: TGLushort, nz: TGLushort){.dynlib: dllname, 
-    importc.}
-proc glNormal3hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){.
-    dynlib: dllname, importc.}
-proc glColor3hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glColor4hNV*(red: TGLushort, green: TGLushort, blue: TGLushort, 
-                  alpha: TGLushort){.dynlib: dllname, importc.}
-proc glColor4hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glTexCoord1hNV*(s: TGLushort){.dynlib: dllname, importc.}
-proc glTexCoord1hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glTexCoord2hNV*(s: TGLushort, t: TGLushort){.dynlib: dllname, importc.}
-proc glTexCoord2hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glTexCoord3hNV*(s: TGLushort, t: TGLushort, r: TGLushort){.dynlib: dllname, 
-    importc.}
-proc glTexCoord3hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glTexCoord4hNV*(s: TGLushort, t: TGLushort, r: TGLushort, q: TGLushort){.
-    dynlib: dllname, importc.}
-proc glTexCoord4hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glMultiTexCoord1hNV*(target: TGLenum, s: TGLushort){.dynlib: dllname, importc.}
-proc glMultiTexCoord1hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord2hNV*(target: TGLenum, s: TGLushort, t: TGLushort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord2hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, r: TGLushort){.
-    dynlib: dllname, importc.}
-proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, r: TGLushort, 
-                          q: TGLushort){.dynlib: dllname, importc.}
-proc glMultiTexCoord4hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, 
-    importc.}
-proc glFogCoordhNV*(fog: TGLushort){.dynlib: dllname, importc.}
-proc glFogCoordhvNV*(fog: PGLushort){.dynlib: dllname, importc.}
-proc glSecondaryColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3hvNV*(v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, importc.}
-proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib1hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib2hNV*(index: TGLuint, x: TGLushort, y: TGLushort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib2hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, z: TGLushort){.
-    dynlib: dllname, importc.}
-proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, z: TGLushort, 
-                         w: TGLushort){.dynlib: dllname, importc.}
-proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.}
-proc glVertexAttribs1hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs2hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs3hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
-    dynlib: dllname, importc.}
-proc glVertexAttribs4hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){.
-    dynlib: dllname, importc.}
-  #***** GL_ATI_map_object_buffer *****//
-proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, importc.}
-proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glStencilFuncSeparateATI*(frontfunc: TGLenum, backfunc: TGLenum, theRef: TGLint, 
-                               mask: TGLuint){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, 
-                                        params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, 
-                                        params: PGLint){.dynlib: dllname, 
-    importc.}
-  #***** 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.}
-proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.}
-proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glBeginQueryARB*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc.}
-proc glEndQueryARB*(target: TGLenum){.dynlib: dllname, importc.}
-proc glGetQueryivARB*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetQueryObjectivARB*(id: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetQueryObjectuivARB*(id: TGLuint, pname: TGLenum, params: PGLuint){.
-    dynlib: dllname, importc.}
-  #***** 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.}
-proc glGetHandleARB*(pname: TGLenum): GLhandleARB{.dynlib: dllname, importc.}
-proc glDetachObjectARB*(containerObj: GLhandleARB, attachedObj: GLhandleARB){.
-    dynlib: dllname, importc.}
-proc glCreateShaderObjectARB*(shaderType: TGLenum): GLhandleARB{.dynlib: dllname, 
-    importc.}
-proc glShaderSourceARB*(shaderObj: GLhandleARB, count: TGLsizei, str: PGLvoid, 
-                        len: PGLint){.dynlib: dllname, importc.}
-proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, importc.}
-proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, importc.}
-proc glAttachObjectARB*(containerObj: GLhandleARB, obj: GLhandleARB){.
-    dynlib: dllname, importc.}
-proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc.}
-proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, importc.}
-proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc.}
-proc glUniform1fARB*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc.}
-proc glUniform2fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform3fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform4fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, 
-                     v3: TGLfloat){.dynlib: dllname, importc.}
-proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, importc.}
-proc glUniform2iARB*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, 
-    importc.}
-proc glUniform3iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){.
-    dynlib: dllname, importc.}
-proc glUniform4iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){.
-    dynlib: dllname, importc.}
-proc glUniform1fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform2fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform3fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform4fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniform1ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform2ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform3ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniform4ivARB*(location: TGLint, count: TGLsizei, value: PGLint){.
-    dynlib: dllname, importc.}
-proc glUniformMatrix2fvARB*(location: TGLint, count: TGLsizei, 
-                            transpose: TGLboolean, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, 
-                            transpose: TGLboolean, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, 
-                            transpose: TGLboolean, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc glGetObjectParameterfvARB*(obj: GLhandleARB, pname: TGLenum, 
-                                params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetObjectParameterivARB*(obj: GLhandleARB, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetInfoLogARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, 
-                      infoLog: PGLcharARB){.dynlib: dllname, importc.}
-proc glGetAttachedObjectsARB*(containerObj: GLhandleARB, maxCount: TGLsizei, 
-                              count: PGLsizei, obj: PGLhandleARB){.
-    dynlib: dllname, importc.}
-proc glGetUniformLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{.
-    dynlib: dllname, importc.}
-proc glGetActiveUniformARB*(programObj: GLhandleARB, index: TGLuint, 
-                            maxLength: TGLsizei, len: PGLsizei, size: PGLint, 
-                            thetype: PGLenum, name: PGLcharARB){.
-    dynlib: dllname, importc.}
-proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, 
-                        params: PGLfloat){.dynlib: dllname, importc.}
-proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, 
-                           source: PGLcharARB){.dynlib: dllname, importc.}
-
-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.}
-proc glGetActiveAttribARB*(programObj: GLhandleARB, index: TGLuint, 
-                           maxLength: TGLsizei, len: PGLsizei, size: PGLint, 
-                           thetype: PGLenum, name: PGLcharARB){.dynlib: dllname, 
-    importc.}
-proc glGetAttribLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{.
-    dynlib: dllname, importc.}
-  # 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.}
-  #***** 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.}
-  #***** 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.}
-  #***** 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.}
-  #***** 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.}
-proc glBindRenderbufferEXT*(target: TGLenum, renderbuffer: TGLuint){.
-    dynlib: dllname, importc.}
-proc glDeleteRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){.
-    dynlib: dllname, importc.}
-proc glGenRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){.
-    dynlib: dllname, importc.}
-proc glRenderbufferStorageEXT*(target: TGLenum, internalformat: TGLenum, 
-                               width: TGLsizei, height: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, 
-                                      params: PGLint){.dynlib: dllname, importc.}
-proc glIsFramebufferEXT*(framebuffer: TGLuint): TGLboolean{.dynlib: dllname, 
-    importc.}
-proc glBindFramebufferEXT*(target: TGLenum, framebuffer: TGLuint){.
-    dynlib: dllname, importc.}
-proc glDeleteFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.
-    dynlib: dllname, importc.}
-proc glGenFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.dynlib: dllname, 
-    importc.}
-proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, 
-    importc.}
-proc glFramebufferTexture1DEXT*(target: TGLenum, attachment: TGLenum, 
-                                textarget: TGLenum, texture: TGLuint, level: TGLint){.
-    dynlib: dllname, importc.}
-proc glFramebufferTexture2DEXT*(target: TGLenum, attachment: TGLenum, 
-                                textarget: TGLenum, texture: TGLuint, level: TGLint){.
-    dynlib: dllname, importc.}
-proc glFramebufferTexture3DEXT*(target: TGLenum, attachment: TGLenum, 
-                                textarget: TGLenum, texture: TGLuint, 
-                                level: TGLint, zoffset: TGLint){.dynlib: dllname, 
-    importc.}
-proc glFramebufferRenderbufferEXT*(target: TGLenum, attachment: TGLenum, 
-                                   renderbuffertarget: TGLenum, 
-                                   renderbuffer: TGLuint){.dynlib: dllname, 
-    importc.}
-proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, 
-    attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, importc.}
-proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glFogCoordf*(coord: TGLfloat){.dynlib: dllname, importc.}
-proc glFogCoordfv*(coord: PGLfloat){.dynlib: dllname, importc.}
-proc glFogCoordd*(coord: TGLdouble){.dynlib: dllname, importc.}
-proc glFogCoorddv*(coord: PGLdouble){.dynlib: dllname, importc.}
-proc glFogCoordPointer*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){.
-    dynlib: dllname, importc.}
-proc glMultiDrawArrays*(mode: TGLenum, first: PGLint, count: PGLsizei, 
-                        primcount: TGLsizei){.dynlib: dllname, importc.}
-proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, 
-                          indices: PGLvoid, primcount: TGLsizei){.
-    dynlib: dllname, importc.}
-proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.}
-proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, 
-    importc.}
-proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.}
-proc glPointParameteriv*(pname: TGLenum, params: PGLint){.dynlib: dllname, 
-    importc.}
-proc glSecondaryColor3b*(red: TGLByte, green: TGLByte, blue: TGLByte){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3bv*(v: PGLbyte){.dynlib: dllname, importc.}
-proc glSecondaryColor3d*(red: TGLdouble, green: TGLdouble, blue: TGLdouble){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glSecondaryColor3f*(red: TGLfloat, green: TGLfloat, blue: TGLfloat){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glSecondaryColor3i*(red: TGLint, green: TGLint, blue: TGLint){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glSecondaryColor3s*(red: TGLshort, green: TGLshort, blue: TGLshort){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glSecondaryColor3ub*(red: TGLubyte, green: TGLubyte, blue: TGLubyte){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3ubv*(v: PGLubyte){.dynlib: dllname, importc.}
-proc glSecondaryColor3ui*(red: TGLuint, green: TGLuint, blue: TGLuint){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3uiv*(v: PGLuint){.dynlib: dllname, importc.}
-proc glSecondaryColor3us*(red: TGLushort, green: TGLushort, blue: TGLushort){.
-    dynlib: dllname, importc.}
-proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, importc.}
-proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, 
-                              pointer: PGLvoid){.dynlib: dllname, importc.}
-proc glWindowPos2d*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos2dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos2f*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos2i*(x: TGLint, y: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos2iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos2s*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.}
-proc glWindowPos2sv*(v: PGLshort){.dynlib: dllname, importc.}
-proc glWindowPos3d*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3dv*(v: PGLdouble){.dynlib: dllname, importc.}
-proc glWindowPos3f*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3fv*(v: PGLfloat){.dynlib: dllname, importc.}
-proc glWindowPos3i*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.}
-proc glWindowPos3iv*(v: PGLint){.dynlib: dllname, importc.}
-proc glWindowPos3s*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, 
-    importc.}
-proc glWindowPos3sv*(v: PGLshort){.dynlib: dllname, importc.}
-  #***** 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.}
-proc glDeleteQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.}
-proc glIsQuery*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glBeginQuery*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc.}
-proc glEndQuery*(target: TGLenum){.dynlib: dllname, importc.}
-proc glGetQueryiv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetQueryObjectiv*(id: TGLuint, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetQueryObjectuiv*(id: TGLuint, pname: TGLenum, params: PGLuint){.
-    dynlib: dllname, importc.}
-proc glBindBuffer*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, importc.}
-proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.}
-proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.}
-proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.}
-proc glBufferData*(target: TGLenum, size: GLsizeiptr, data: PGLvoid, 
-                   usage: TGLenum){.dynlib: dllname, importc.}
-proc glBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, 
-                      data: PGLvoid){.dynlib: dllname, importc.}
-proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, 
-                         data: PGLvoid){.dynlib: dllname, importc.}
-proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, 
-    importc.}
-proc glUnmapBuffer*(target: TGLenum): TGLboolean{.dynlib: dllname, importc.}
-proc glGetBufferParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
-    dynlib: dllname, importc.}
-proc glGetBufferPointerv*(target: TGLenum, pname: TGLenum, params: PGLvoid){.
-    dynlib: dllname, importc.}
-  #***** 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.}
diff --git a/lib/oldwrappers/opengl/glu.nim b/lib/oldwrappers/opengl/glu.nim
deleted file mode 100755
index 297f4d354..000000000
--- a/lib/oldwrappers/opengl/glu.nim
+++ /dev/null
@@ -1,311 +0,0 @@
-#
-#
-#  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):
-  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.}
-proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, 
-    importc.}
-proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, importc.}
-proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, importc.}
-proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
-    dynlib: dllname, importc.}
-proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
-    dynlib: dllname, importc.}
-proc gluProject*(objx, objy, objz: TGLdouble, 
-                 modelMatrix, projMatrix: var T16dArray, 
-                 viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
-    dynlib: dllname, importc.}
-proc gluUnProject*(winx, winy, winz: TGLdouble, 
-                   modelMatrix, projMatrix: var T16dArray, 
-                   viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
-    dynlib: dllname, importc.}
-proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum, 
-                    datain: Pointer, widthout, heightout: TGLint, 
-                    typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname, 
-    importc.}
-proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint, 
-                        format, atype: TGLenum, data: Pointer): int{.
-    dynlib: dllname, importc.}
-proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint, 
-                        format, atype: TGLenum, data: Pointer): int{.
-    dynlib: dllname, importc.}
-proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc.}
-proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, importc.}
-proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
-    dynlib: dllname, importc.}
-proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
-    dynlib: dllname, importc.}
-proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
-    dynlib: dllname, importc.}
-proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
-    dynlib: dllname, importc.}
-proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble, 
-                  slices, stacks: TGLint){.dynlib: dllname, importc.}
-proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, 
-              slices, loops: TGLint){.dynlib: dllname, importc.}
-proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, 
-                     slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
-    dynlib: dllname, importc.}
-proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
-    dynlib: dllname, importc.}
-proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
-    dynlib: dllname, importc.}
-proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc.}
-proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, importc.}
-proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
-    dynlib: dllname, importc.}
-proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, importc.}
-proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
-    dynlib: dllname, importc.}
-proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, importc.}
-proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.}
-proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
-    dynlib: dllname, importc.}
-proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname, 
-    importc.}
-proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
-    dynlib: dllname, importc.}
-proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
-    dynlib: dllname, importc.}
-proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, importc.}
-proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.}
-proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat, 
-                  stride: TGLint, atype: TGLenum){.dynlib: dllname, importc.}
-proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat, 
-                    stride: TGLint, ctlarray: PGLfloat, order: TGLint, 
-                    atype: TGLenum){.dynlib: dllname, importc.}
-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.}
-proc gluLoadSamplingMatrices*(nobj: PGLUnurbs, 
-                              modelMatrix, projMatrix: var T16dArray, 
-                              viewport: var TViewPortArray){.dynlib: dllname, 
-    importc.}
-proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
-    dynlib: dllname, importc.}
-proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
-    dynlib: dllname, importc.}
-proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
-    dynlib: dllname, importc.}
-  #*** 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.}
-proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, 
-    importc.}
-proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.}
-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
-
-# implementation
diff --git a/lib/oldwrappers/opengl/glut.nim b/lib/oldwrappers/opengl/glut.nim
deleted file mode 100755
index 55ee18bda..000000000
--- a/lib/oldwrappers/opengl/glut.nim
+++ /dev/null
@@ -1,378 +0,0 @@
-#
-#
-#  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
-  PInteger* = ptr int
-  PPChar* = ptr cstring
-  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: PInteger, argv: PPChar){.dynlib: dllname, importc.}
-proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, importc.}
-proc glutInitDisplayString*(str: cstring){.dynlib: dllname, importc.}
-proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, importc.}
-proc glutInitWindowSize*(width, height: int){.dynlib: dllname, importc.}
-proc glutMainLoop*(){.dynlib: dllname, importc.}
-  # GLUT window sub-API.
-proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, importc.}
-proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
-    importc.}
-proc glutDestroyWindow*(win: int){.dynlib: dllname, importc.}
-proc glutPostRedisplay*(){.dynlib: dllname, importc.}
-proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, importc.}
-proc glutSwapBuffers*(){.dynlib: dllname, importc.}
-proc glutGetWindow*(): int{.dynlib: dllname, importc.}
-proc glutSetWindow*(win: int){.dynlib: dllname, importc.}
-proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, importc.}
-proc glutSetIconTitle*(title: cstring){.dynlib: dllname, importc.}
-proc glutPositionWindow*(x, y: int){.dynlib: dllname, importc.}
-proc glutReshapeWindow*(width, height: int){.dynlib: dllname, importc.}
-proc glutPopWindow*(){.dynlib: dllname, importc.}
-proc glutPushWindow*(){.dynlib: dllname, importc.}
-proc glutIconifyWindow*(){.dynlib: dllname, importc.}
-proc glutShowWindow*(){.dynlib: dllname, importc.}
-proc glutHideWindow*(){.dynlib: dllname, importc.}
-proc glutFullScreen*(){.dynlib: dllname, importc.}
-proc glutSetCursor*(cursor: int){.dynlib: dllname, importc.}
-proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc.}
-  # GLUT overlay sub-API.
-proc glutEstablishOverlay*(){.dynlib: dllname, importc.}
-proc glutRemoveOverlay*(){.dynlib: dllname, importc.}
-proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc.}
-proc glutPostOverlayRedisplay*(){.dynlib: dllname, importc.}
-proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, importc.}
-proc glutShowOverlay*(){.dynlib: dllname, importc.}
-proc glutHideOverlay*(){.dynlib: dllname, importc.}
-  # GLUT menu sub-API.
-proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, importc.}
-proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc.}
-proc glutGetMenu*(): int{.dynlib: dllname, importc.}
-proc glutSetMenu*(menu: int){.dynlib: dllname, importc.}
-proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, importc.}
-proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, importc.}
-proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){.
-    dynlib: dllname, importc.}
-proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){.
-    dynlib: dllname, importc.}
-proc glutRemoveMenuItem*(item: int){.dynlib: dllname, importc.}
-proc glutAttachMenu*(button: int){.dynlib: dllname, importc.}
-proc glutDetachMenu*(button: int){.dynlib: dllname, importc.}
-  # GLUT window callback sub-API.
-proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
-proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.}
-proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.}
-proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
-proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
-proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
-proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){.
-    dynlib: dllname, importc.}
-proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
-proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
-proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
-proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
-proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.}
-proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.}
-proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
-proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.}
-proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.}
-proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.}
-proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.}
-proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){.
-    dynlib: dllname, importc.}
-  # GLUT color index sub-API.
-proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
-    importc.}
-proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, importc.}
-proc glutCopyColormap*(win: int){.dynlib: dllname, importc.}
-  # GLUT state retrieval sub-API.
-proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc.}
-proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc.}
-  # GLUT extension support sub-API
-proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, importc.}
-proc glutGetModifiers*(): int{.dynlib: dllname, importc.}
-proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc.}
-  # GLUT font sub-API
-proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
-    importc.}
-proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
-    importc.}
-proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
-    importc.}
-proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
-    importc.}
-proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
-    importc.}
-proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
-    importc.}
-  # GLUT pre-built models sub-API
-proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname,
-    importc.}
-proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname,
-    importc.}
-proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){.
-    dynlib: dllname, importc.}
-proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){.
-    dynlib: dllname, importc.}
-proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc.}
-proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc.}
-proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
-    dynlib: dllname, importc.}
-proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
-    dynlib: dllname, importc.}
-proc glutWireDodecahedron*(){.dynlib: dllname, importc.}
-proc glutSolidDodecahedron*(){.dynlib: dllname, importc.}
-proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, importc.}
-proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, importc.}
-proc glutWireOctahedron*(){.dynlib: dllname, importc.}
-proc glutSolidOctahedron*(){.dynlib: dllname, importc.}
-proc glutWireTetrahedron*(){.dynlib: dllname, importc.}
-proc glutSolidTetrahedron*(){.dynlib: dllname, importc.}
-proc glutWireIcosahedron*(){.dynlib: dllname, importc.}
-proc glutSolidIcosahedron*(){.dynlib: dllname, importc.}
-  # GLUT video resize sub-API.
-proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, importc.}
-proc glutSetupVideoResizing*(){.dynlib: dllname, importc.}
-proc glutStopVideoResizing*(){.dynlib: dllname, importc.}
-proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, importc.}
-proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, importc.}
-  # GLUT debugging sub-API.
-proc glutReportErrors*(){.dynlib: dllname, importc.}
-  # GLUT device control sub-API.
-proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, importc.}
-proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, importc.}
-proc glutForceJoystickFunc*(){.dynlib: dllname, importc.}
-  # GLUT game mode sub-API.
-  #example glutGameModeString('1280x1024:32@75');
-proc glutGameModeString*(AString: cstring){.dynlib: dllname, importc.}
-proc glutEnterGameMode*(): int{.dynlib: dllname, importc.}
-proc glutLeaveGameMode*(){.dynlib: dllname, importc.}
-proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, importc.}
-# implementation
diff --git a/lib/oldwrappers/opengl/glx.nim b/lib/oldwrappers/opengl/glx.nim
deleted file mode 100755
index a967acfc6..000000000
--- a/lib/oldwrappers/opengl/glx.nim
+++ /dev/null
@@ -1,148 +0,0 @@
-#
-#
-#  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.}
-proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
-                       direct: bool): GLXContext{.cdecl, dynlib: dllname,
-    importc.}
-proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
-    importc.}
-proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
-    cdecl, dynlib: dllname, importc.}
-proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
-    dynlib: dllname, importc.}
-proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
-    dynlib: dllname, importc.}
-proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
-    cdecl, dynlib: dllname, importc.}
-proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
-    dynlib: dllname, importc.}
-proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
-    dynlib: dllname, importc.}
-proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
-    dynlib: dllname, importc.}
-proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
-    importc.}
-proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
-                   value: var int): int{.cdecl, dynlib: dllname, importc.}
-proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, importc.}
-proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, importc.}
-proc glXWaitGL*(){.cdecl, dynlib: dllname, importc.}
-proc glXWaitX*(){.cdecl, dynlib: dllname, importc.}
-proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
-    importc.}
-  # GLX 1.1 and later
-proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
-    dynlib: dllname, importc.}
-proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
-    dynlib: dllname, importc.}
-proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
-    dynlib: dllname, importc.}
-  # Mesa GLX Extensions
-proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
-                             pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
-    cdecl, dynlib: dllname, importc.}
-proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
-    dynlib: dllname, importc.}
-proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
-                           x, y, width, height: int){.cdecl, dynlib: dllname,
-    importc.}
-proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
-    importc.}
-proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
-    cdecl, dynlib: dllname, importc.}
-# implementation
diff --git a/lib/oldwrappers/opengl/wingl.nim b/lib/oldwrappers/opengl/wingl.nim
deleted file mode 100755
index 2cebf8622..000000000
--- a/lib/oldwrappers/opengl/wingl.nim
+++ /dev/null
@@ -1,348 +0,0 @@
-
-import 
-  gl, windows
-
-proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, importc.}
-
-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.}
-proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, importc.}
-proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, 
-                             width: TGLint, height: TGLint): BOOL{.
-    dynlib: dllname, importc.}
-proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, 
-                                width: TGLint, height: TGLint, xSrc: TGLint, 
-                                ySrc: TGLint): BOOL{.dynlib: dllname, importc.}
-proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, 
-                          writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
-    dynlib: dllname, importc.}
-proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, importc.}
-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.}
-proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
-    dynlib: dllname, importc.}
-proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, 
-                                       pAddress: PGLvoid, pSize: PDWORD, 
-                                       count: UINT): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
-    dynlib: dllname, importc.}
-proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.}
-proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.}
-proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.}
-proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.}
-proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, importc.}
-proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.}
-proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.}
-proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, 
-                               pLastMissedUsage: PGLfloat): BOOL{.
-    dynlib: dllname, importc.}
-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.}
-proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, 
-                                   iLayerPlane: TGLint, nAttributes: TGLuint, 
-                                   piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
-    dynlib: dllname, importc.}
-proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, 
-                              pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 
-                              piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
-    dynlib: dllname, importc.}
-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.}
-proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, importc.}
-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.}
-proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.}
-proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
-    dynlib: dllname, importc.}
-proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.}
-proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
-    dynlib: dllname, importc.}
-proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, importc.}
-proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, importc.}
-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.}
-proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
-    dynlib: dllname, importc.}
-proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
-    dynlib: dllname, importc.}
-proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, importc.}
-proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
-    dynlib: dllname, importc.}
-proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, importc.}
-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.}
-proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.}
-proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
-    dynlib: dllname, importc.}
-proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.}
-proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
-    dynlib: dllname, importc.}
-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.}
-proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, 
-                                   iLayerPlane: TGLint, nAttributes: TGLuint, 
-                                   piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
-    dynlib: dllname, importc.}
-proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, 
-                              pfAttribFList: PGLfloat, nMaxFormats: TGLuint, 
-                              piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
-    dynlib: dllname, importc.}
-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.}
-proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, 
-                                      piValue: PGLint): BOOL{.dynlib: dllname, 
-    importc.}
-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.}
-proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, 
-                                    piValue: PGLint): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, 
-                          puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
-    dynlib: dllname, importc.}
-proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, 
-                          puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
-    dynlib: dllname, importc.}
-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.}
-proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc.}
-proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
-    dynlib: dllname, importc.}
-proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, 
-    importc.}
-proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
-    dynlib: dllname, importc.}
-proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
-    dynlib: dllname, importc.}
-proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
-    dynlib: dllname, importc.}
-proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, 
-                                       uMaxPixelDelay: PGLUINT): BOOL{.
-    dynlib: dllname, importc.}
-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/lib/oldwrappers/pcre/pcre.nim b/lib/oldwrappers/pcre/pcre.nim
deleted file mode 100755
index 05f937579..000000000
--- a/lib/oldwrappers/pcre/pcre.nim
+++ /dev/null
@@ -1,279 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-{.compile: "pcre_all.c" .}
-
-type
-  Pbyte = ptr byte
-  PPchar = ptr cstring
-  Pint = ptr cint
-  Ppcre* = ptr TPcre
-  Ppcre_callout_block* = ptr tpcre_callout_block
-  Ppcre_extra* = ptr Tpcre_extra
-  TPcre {.final, pure.} = object
-
-  # The structure for passing additional data to pcre_exec(). This is defined
-  # in such as way as to be extensible.
-  # Bits for which fields are set
-  # Opaque data from pcre_study()
-  # Maximum number of calls to match()
-  # Data passed back in callouts
-  # Const before type ignored
-  # Pointer to character tables
-  Tpcre_extra* {.final, pure.} = object
-    flags: cint
-    study_data: pointer
-    match_limit: cint
-    callout_data: pointer
-    tables: ptr byte
-
-  # The structure for passing out data via the pcre_callout_function. We use a
-  # structure so that new fields can be added on the end in future versions,
-  # without changing the API of the function, thereby allowing old clients to
-  # work without modification.
-  # Identifies version of block
-  # ------------------------ Version 0 -------------------------------
-  # Number compiled into pattern
-  # The offset vector
-  # Const before type ignored
-  # The subject being matched
-  # The length of the subject
-  # Offset to start of this match attempt
-  # Where we currently are in the subject
-  # Max current capture
-  # Most recently closed capture
-  # Data passed in with the call
-  # ------------------- Added for Version 1 --------------------------
-  # Offset to next item in the pattern
-  # Length of next item in the pattern
-  # ------------------------------------------------------------------
-  TPcre_callout_block* {.final, pure.} = object
-    version: cint
-    callout_number: cint
-    offset_vector: ptr cint
-    subject: ptr char
-    subject_length: cint
-    start_match: cint
-    current_position: cint
-    capture_top: cint
-    capture_last: cint
-    callout_data: pointer
-    pattern_position: cint
-    next_item_length: cint
-
-
-#************************************************
-#*       Perl-Compatible Regular Expressions    *
-#************************************************
-#
-#   Modified by Andreas Rumpf for h2pas.
-
-# In its original form, this is the .in file that is transformed by
-# "configure" into pcre.h.
-#
-#           Copyright (c) 1997-2005 University of Cambridge
-#
-# -----------------------------------------------------------------------------
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-#    * Redistributions of source code must retain the above copyright notice,
-#      this list of conditions and the following disclaimer.
-#
-#    * Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#    * Neither the name of the University of Cambridge nor the names of its
-#      contributors may be used to endorse or promote products derived from
-#      this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-# -----------------------------------------------------------------------------
-
-# The file pcre.h is build by "configure". Do not edit it; instead
-# make changes to pcre.in.
-
-const
-  PCRE_MAJOR* = 6
-  PCRE_MINOR* = 3
-  PCRE_DATE* = "2005/11/29"
-  # Options
-  PCRE_CASELESS* = 0x00000001
-  PCRE_MULTILINE* = 0x00000002
-  PCRE_DOTALL* = 0x00000004
-  PCRE_EXTENDED* = 0x00000008
-  PCRE_ANCHORED* = 0x00000010
-  PCRE_DOLLAR_ENDONLY* = 0x00000020
-  PCRE_EXTRA* = 0x00000040
-  PCRE_NOTBOL* = 0x00000080
-  PCRE_NOTEOL* = 0x00000100
-  PCRE_UNGREEDY* = 0x00000200
-  PCRE_NOTEMPTY* = 0x00000400
-  PCRE_UTF8* = 0x00000800
-  PCRE_NO_AUTO_CAPTURE* = 0x00001000
-  PCRE_NO_UTF8_CHECK* = 0x00002000
-  PCRE_AUTO_CALLOUT* = 0x00004000
-  PCRE_PARTIAL* = 0x00008000
-  PCRE_DFA_SHORTEST* = 0x00010000
-  PCRE_DFA_RESTART* = 0x00020000
-  PCRE_FIRSTLINE* = 0x00040000
-  # Exec-time and get/set-time error codes
-  PCRE_ERROR_NOMATCH* = -(1)
-  PCRE_ERROR_NULL* = -(2)
-  PCRE_ERROR_BADOPTION* = -(3)
-  PCRE_ERROR_BADMAGIC* = -(4)
-  PCRE_ERROR_UNKNOWN_NODE* = -(5)
-  PCRE_ERROR_NOMEMORY* = -(6)
-  PCRE_ERROR_NOSUBSTRING* = -(7)
-  PCRE_ERROR_MATCHLIMIT* = -(8)
-  # Never used by PCRE itself
-  PCRE_ERROR_CALLOUT* = -(9)
-  PCRE_ERROR_BADUTF8* = -(10)
-  PCRE_ERROR_BADUTF8_OFFSET* = -(11)
-  PCRE_ERROR_PARTIAL* = -(12)
-  PCRE_ERROR_BADPARTIAL* = -(13)
-  PCRE_ERROR_INTERNAL* = -(14)
-  PCRE_ERROR_BADCOUNT* = -(15)
-  PCRE_ERROR_DFA_UITEM* = -(16)
-  PCRE_ERROR_DFA_UCOND* = -(17)
-  PCRE_ERROR_DFA_UMLIMIT* = -(18)
-  PCRE_ERROR_DFA_WSSIZE* = -(19)
-  PCRE_ERROR_DFA_RECURSE* = -(20)
-  # Request types for pcre_fullinfo()
-  PCRE_INFO_OPTIONS* = 0
-  PCRE_INFO_SIZE* = 1
-  PCRE_INFO_CAPTURECOUNT* = 2
-  PCRE_INFO_BACKREFMAX* = 3
-  PCRE_INFO_FIRSTBYTE* = 4
-  # For backwards compatibility
-  PCRE_INFO_FIRSTCHAR* = 4
-  PCRE_INFO_FIRSTTABLE* = 5
-  PCRE_INFO_LASTLITERAL* = 6
-  PCRE_INFO_NAMEENTRYSIZE* = 7
-  PCRE_INFO_NAMECOUNT* = 8
-  PCRE_INFO_NAMETABLE* = 9
-  PCRE_INFO_STUDYSIZE* = 10
-  PCRE_INFO_DEFAULT_TABLES* = 11
-  # Request types for pcre_config()
-  PCRE_CONFIG_UTF8* = 0
-  PCRE_CONFIG_NEWLINE* = 1
-  PCRE_CONFIG_LINK_SIZE* = 2
-  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD* = 3
-  PCRE_CONFIG_MATCH_LIMIT* = 4
-  PCRE_CONFIG_STACKRECURSE* = 5
-  PCRE_CONFIG_UNICODE_PROPERTIES* = 6
-  # Bit flags for the pcre_extra structure
-  PCRE_EXTRA_STUDY_DATA* = 0x0001
-  PCRE_EXTRA_MATCH_LIMIT* = 0x0002
-  PCRE_EXTRA_CALLOUT_DATA* = 0x0004
-  PCRE_EXTRA_TABLES* = 0x0008
-
-# Exported PCRE functions
-
-proc pcre_compile*(para1: cstring, para2: cint, para3: ptr cstring,
-                  para4: ptr int, para5: Pbyte): Ppcre {.
-                  importc: "pcre_compile", noconv.}
-
-proc pcre_compile2*(para1: cstring, para2: cint, para3: Pint, para4: PPchar,
-                   para5: ptr int, para6: Pbyte): Ppcre {.
-                   importc: "pcre_compile2", noconv.}
-
-proc pcre_config*(para1: cint, para2: pointer): cint {.
-  importc: "pcre_config", noconv.}
-
-proc pcre_copy_named_substring*(para1: Ppcre, para2: cstring, para3: Pint,
-                               para4: cint, para5: cstring, para6: cstring,
-                               para7: cint): cint {.
-                               importc: "pcre_copy_named_substring", noconv.}
-
-proc pcre_copy_substring*(para1: cstring, para2: Pint, para3: cint, para4: cint,
-                         para5: cstring, para6: cint): cint {.
-                         importc: "pcre_copy_substring", noconv.}
-
-proc pcre_dfa_exec*(para1: Ppcre, para2: Ppcre_extra, para3: cstring,
-                   para4: cint, para5: cint, para6: cint, para7: Pint,
-                   para8: cint, para9: Pint, para10: cint): cint {.
-                   importc: "pcre_dfa_exec", noconv.}
-
-proc pcre_exec*(para1: Ppcre, para2: Ppcre_extra, para3: cstring,
-               para4: cint, para5: cint, para6: cint, para7: Pint,
-               para8: cint): cint {.importc: "pcre_exec", noconv.}
-
-proc pcre_free_substring*(para1: cstring) {.
-  importc: "pcre_free_substring", noconv.}
-
-proc pcre_free_substring_list*(para1: PPchar) {.
-  importc: "pcre_free_substring_list", noconv.}
-
-proc pcre_fullinfo*(para1: Ppcre, para2: Ppcre_extra, para3: cint,
-                   para4: pointer): cint {.importc: "pcre_fullinfo", noconv.}
-
-proc pcre_get_named_substring*(para1: Ppcre, para2: cstring, para3: Pint,
-                              para4: cint, para5: cstring, para6: PPchar): cint {.
-                              importc: "pcre_get_named_substring", noconv.}
-
-proc pcre_get_stringnumber*(para1: Ppcre, para2: cstring): cint {.
-  importc: "pcre_get_stringnumber", noconv.}
-
-proc pcre_get_substring*(para1: cstring, para2: Pint, para3: cint,
-                        para4: cint, para5: PPchar): cint {.
-                        importc: "pcre_get_substring", noconv.}
-
-proc pcre_get_substring_list*(para1: cstring, para2: Pint, para3: cint,
-                             para4: ptr PPchar): cint {.
-                             importc: "pcre_get_substring_list", noconv.}
-
-proc pcre_info*(para1: Ppcre, para2: Pint, para3: Pint): cint {.
-  importc: "pcre_info", noconv.}
-
-proc pcre_maketables*: ptr byte {.
-  importc: "pcre_maketables", noconv.}
-
-proc pcre_refcount*(para1: Ppcre, para2: cint): cint {.
-  importc: "pcre_refcount", noconv.}
-
-proc pcre_study*(para1: Ppcre, para2: cint,
-                 para3: ptr CString): Ppcre_extra {.importc, noconv.}
-
-proc pcre_version*: CString {.importc: "pcre_version", noconv.}
-
-# Indirection for store get and free functions. These can be set to
-# alternative malloc/free functions if required. Special ones are used in the
-# non-recursive case for "frames". There is also an optional callout function
-# that is triggered by the (?) regex item.
-#
-
-# we use Nimrod's memory manager (but not GC!) for these functions:
-type
-  TMalloc = proc (para1: int): pointer {.noconv.}
-  TFree = proc (para1: pointer) {.noconv.}
-var
-  pcre_malloc {.importc: "pcre_malloc".}: TMalloc
-  pcre_free {.importc: "pcre_free".}: TFree
-  pcre_stack_malloc {.importc: "pcre_stack_malloc".}: TMalloc
-  pcre_stack_free  {.importc: "pcre_stack_free".}: TFree
-  pcre_callout {.importc: "pcre_callout".}:
-    proc (para1: Ppcre_callout_block): cint {.noconv.}
-
-pcre_malloc = cast[TMalloc](system.alloc)
-pcre_free = cast[TFree](system.dealloc)
-pcre_stack_malloc = cast[TMalloc](system.alloc)
-pcre_stack_free = cast[TFree](system.dealloc)
-pcre_callout = nil
diff --git a/lib/oldwrappers/pcre/pcre_all.c b/lib/oldwrappers/pcre/pcre_all.c
deleted file mode 100755
index bcda06e50..000000000
--- a/lib/oldwrappers/pcre/pcre_all.c
+++ /dev/null
@@ -1,30072 +0,0 @@
-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* This file is automatically written by the dftables auxiliary

-program. If you edit it by hand, you might like to edit the Makefile to

-prevent its ever being regenerated.

-

-This file contains the default tables for characters with codes less than

-128 (ASCII characters). These tables are used when no external tables are

-passed to PCRE. */

-

-const unsigned char _pcre_default_tables[] = {

-

-/* This table is a lower casing table. */

-

-    0,  1,  2,  3,  4,  5,  6,  7,

-    8,  9, 10, 11, 12, 13, 14, 15,

-   16, 17, 18, 19, 20, 21, 22, 23,

-   24, 25, 26, 27, 28, 29, 30, 31,

-   32, 33, 34, 35, 36, 37, 38, 39,

-   40, 41, 42, 43, 44, 45, 46, 47,

-   48, 49, 50, 51, 52, 53, 54, 55,

-   56, 57, 58, 59, 60, 61, 62, 63,

-   64, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122, 91, 92, 93, 94, 95,

-   96, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122,123,124,125,126,127,

-  128,129,130,131,132,133,134,135,

-  136,137,138,139,140,141,142,143,

-  144,145,146,147,148,149,150,151,

-  152,153,154,155,156,157,158,159,

-  160,161,162,163,164,165,166,167,

-  168,169,170,171,172,173,174,175,

-  176,177,178,179,180,181,182,183,

-  184,185,186,187,188,189,190,191,

-  192,193,194,195,196,197,198,199,

-  200,201,202,203,204,205,206,207,

-  208,209,210,211,212,213,214,215,

-  216,217,218,219,220,221,222,223,

-  224,225,226,227,228,229,230,231,

-  232,233,234,235,236,237,238,239,

-  240,241,242,243,244,245,246,247,

-  248,249,250,251,252,253,254,255,

-

-/* This table is a case flipping table. */

-

-    0,  1,  2,  3,  4,  5,  6,  7,

-    8,  9, 10, 11, 12, 13, 14, 15,

-   16, 17, 18, 19, 20, 21, 22, 23,

-   24, 25, 26, 27, 28, 29, 30, 31,

-   32, 33, 34, 35, 36, 37, 38, 39,

-   40, 41, 42, 43, 44, 45, 46, 47,

-   48, 49, 50, 51, 52, 53, 54, 55,

-   56, 57, 58, 59, 60, 61, 62, 63,

-   64, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122, 91, 92, 93, 94, 95,

-   96, 65, 66, 67, 68, 69, 70, 71,

-   72, 73, 74, 75, 76, 77, 78, 79,

-   80, 81, 82, 83, 84, 85, 86, 87,

-   88, 89, 90,123,124,125,126,127,

-  128,129,130,131,132,133,134,135,

-  136,137,138,139,140,141,142,143,

-  144,145,146,147,148,149,150,151,

-  152,153,154,155,156,157,158,159,

-  160,161,162,163,164,165,166,167,

-  168,169,170,171,172,173,174,175,

-  176,177,178,179,180,181,182,183,

-  184,185,186,187,188,189,190,191,

-  192,193,194,195,196,197,198,199,

-  200,201,202,203,204,205,206,207,

-  208,209,210,211,212,213,214,215,

-  216,217,218,219,220,221,222,223,

-  224,225,226,227,228,229,230,231,

-  232,233,234,235,236,237,238,239,

-  240,241,242,243,244,245,246,247,

-  248,249,250,251,252,253,254,255,

-

-/* This table contains bit maps for various character classes.

-Each map is 32 bytes long and the bits run from the least

-significant end of each byte. The classes that have their own

-maps are: space, xdigit, digit, upper, lower, word, graph

-print, punct, and cntrl. Other classes are built from combinations. */

-

-  0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,

-  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,

-  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,

-  0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-/* This table identifies various classes of character by individual bits:

-  0x01   white space character

-  0x02   letter

-  0x04   decimal digit

-  0x08   hexadecimal digit

-  0x10   alphanumeric or '_'

-  0x80   regular expression metacharacter or binary zero

-*/

-

-  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */

-  0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /*    - '  */

-  0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /*  ( - /  */

-  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */

-  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /*  8 - ?  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  @ - G  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  H - O  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  P - W  */

-  0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /*  X - _  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  ` - g  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  h - o  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  p - w  */

-  0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /*  x -127 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */

-

-/* End of chartables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_compile(), along with

-supporting internal functions that are not used by other modules. */

-

-

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-/* This header contains definitions that are shared between the different

-modules, but which are not relevant to the exported API. This includes some

-functions whose names all begin with "_pcre_". */

-

-

-/* Define DEBUG to get debugging output on stdout. */

-

-/****

-#define DEBUG

-****/

-

-/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef

-inline, and there are *still* stupid compilers about that don't like indented

-pre-processor statements, or at least there were when I first wrote this. After

-all, it had only been about 10 years then... */

-

-#ifdef DEBUG

-#define DPRINTF(p) printf p

-#else

-#define DPRINTF(p) /*nothing*/

-#endif

-

-

-/* Get the definitions provided by running "configure" */

-

-

-/* On Unix systems config.in is converted by configure into config.h. PCRE is

-written in Standard C, but there are a few non-standard things it can cope

-with, allowing it to run on SunOS4 and other "close to standard" systems.

-

-On a non-Unix system you should just copy this file into config.h, and set up

-the macros the way you need them. You should normally change the definitions of

-HAVE_STRERROR and HAVE_MEMMOVE to 1. Unfortunately, because of the way autoconf

-works, these cannot be made the defaults. If your system has bcopy() and not

-memmove(), change the definition of HAVE_BCOPY instead of HAVE_MEMMOVE. If your

-system has neither bcopy() nor memmove(), leave them both as 0; an emulation

-function will be used. */

-

-/* If you are compiling for a system that uses EBCDIC instead of ASCII

-character codes, define this macro as 1. On systems that can use "configure",

-this can be done via --enable-ebcdic. */

-

-#ifndef EBCDIC

-#define EBCDIC 0

-#endif

-

-/* If you are compiling for a system that needs some magic to be inserted

-before the definition of an exported function, define this macro to contain the

-relevant magic. It apears at the start of every exported function. */

-

-#define EXPORT

-

-/* Define to empty if the "const" keyword does not work. */

-

-#undef const

-

-/* Define to "unsigned" if <stddef.h> doesn't define size_t. */

-

-#undef size_t

-

-/* The following two definitions are mainly for the benefit of SunOS4, which

-doesn't have the strerror() or memmove() functions that should be present in

-all Standard C libraries. The macros HAVE_STRERROR and HAVE_MEMMOVE should

-normally be defined with the value 1 for other systems, but unfortunately we

-can't make this the default because "configure" files generated by autoconf

-will only change 0 to 1; they won't change 1 to 0 if the functions are not

-found. */

-

-#define HAVE_STRERROR 1

-#define HAVE_MEMMOVE  1

-

-/* There are some non-Unix systems that don't even have bcopy(). If this macro

-is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of

-HAVE_BCOPY is not relevant. */

-

-#define HAVE_BCOPY    0

-

-/* The value of NEWLINE determines the newline character. The default is to

-leave it up to the compiler, but some sites want to force a particular value.

-On Unix systems, "configure" can be used to override this default. */

-

-#ifndef NEWLINE

-#define NEWLINE '\n'

-#endif

-

-/* The value of LINK_SIZE determines the number of bytes used to store

-links as offsets within the compiled regex. The default is 2, which allows for

-compiled patterns up to 64K long. This covers the vast majority of cases.

-However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for

-longer patterns in extreme cases. On Unix systems, "configure" can be used to

-override this default. */

-

-#ifndef LINK_SIZE

-#define LINK_SIZE   2

-#endif

-

-/* The value of MATCH_LIMIT determines the default number of times the match()

-function can be called during a single execution of pcre_exec(). (There is a

-runtime method of setting a different limit.) The limit exists in order to

-catch runaway regular expressions that take for ever to determine that they do

-not match. The default is set very large so that it does not accidentally catch

-legitimate cases. On Unix systems, "configure" can be used to override this

-default default. */

-

-#ifndef MATCH_LIMIT

-#define MATCH_LIMIT 10000000

-#endif

-

-/* When calling PCRE via the POSIX interface, additional working storage is

-required for holding the pointers to capturing substrings because PCRE requires

-three integers per substring, whereas the POSIX interface provides only two. If

-the number of expected substrings is small, the wrapper function uses space on

-the stack, because this is faster than using malloc() for each call. The

-threshold above which the stack is no longer use is defined by POSIX_MALLOC_

-THRESHOLD. On Unix systems, "configure" can be used to override this default.

-*/

-

-#ifndef POSIX_MALLOC_THRESHOLD

-#define POSIX_MALLOC_THRESHOLD 10

-#endif

-

-/* PCRE uses recursive function calls to handle backtracking while matching.

-This can sometimes be a problem on systems that have stacks of limited size.

-Define NO_RECURSE to get a version that doesn't use recursion in the match()

-function; instead it creates its own stack by steam using pcre_recurse_malloc

-to get memory. For more detail, see comments and other stuff just above the

-match() function. On Unix systems, "configure" can be used to set this in the

-Makefile (use --disable-stack-for-recursion). */

-

-/* #define NO_RECURSE */

-

-/* End */

-

-/* Standard C headers plus the external interface definition. The only time

-setjmp and stdarg are used is when NO_RECURSE is set. */

-

-#include <ctype.h>

-#include <limits.h>

-#include <setjmp.h>

-#include <stdarg.h>

-#include <stddef.h>

-#include <stdio.h>

-#include <stdlib.h>

-#include <string.h>

-

-#ifndef PCRE_SPY

-#define PCRE_DEFINITION       /* Win32 __declspec(export) trigger for .dll */

-#endif

-

-/* We need to have types that specify unsigned 16-bit and 32-bit integers. We

-cannot determine these outside the compilation (e.g. by running a program as

-part of "configure") because PCRE is often cross-compiled for use on other

-systems. Instead we make use of the maximum sizes that are available at

-preprocessor time in standard C environments. */

-

-#if USHRT_MAX == 65535

-  typedef unsigned short pcre_uint16;

-#elif UINT_MAX == 65535

-  typedef unsigned int pcre_uint16;

-#else

-  #error Cannot determine a type for 16-bit unsigned integers

-#endif

-

-#if UINT_MAX == 4294967295

-  typedef unsigned int pcre_uint32;

-#elif ULONG_MAX == 4294967295

-  typedef unsigned long int pcre_uint32;

-#else

-  #error Cannot determine a type for 32-bit unsigned integers

-#endif

-

-/* All character handling must be done as unsigned characters. Otherwise there

-are problems with top-bit-set characters and functions such as isspace().

-However, we leave the interface to the outside world as char *, because that

-should make things easier for callers. We define a short type for unsigned char

-to save lots of typing. I tried "uchar", but it causes problems on Digital

-Unix, where it is defined in sys/types, so use "uschar" instead. */

-

-typedef unsigned char uschar;

-

-/* Include the public PCRE header */

-

-/*************************************************

-*       Perl-Compatible Regular Expressions      *

-*************************************************/

-

-/* In its original form, this is the .in file that is transformed by

-"configure" into pcre.h.

-

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-#ifndef _PCRE_H

-#define _PCRE_H

-

-/* The file pcre.h is build by "configure". Do not edit it; instead

-make changes to pcre.in. */

-

-#define PCRE_MAJOR          6

-#define PCRE_MINOR          3

-#define PCRE_DATE           "2005/11/29"

-

-/* For other operating systems, we use the standard "extern". */

-

-#ifndef PCRE_DATA_SCOPE

-#  ifdef __cplusplus

-#    define PCRE_DATA_SCOPE     extern "C"

-#  else

-#    define PCRE_DATA_SCOPE     extern

-#  endif

-#endif

-

-/* Have to include stdlib.h in order to ensure that size_t is defined;

-it is needed here for malloc. */

-

-#include <stdlib.h>

-

-/* Allow for C++ users */

-

-#ifdef __cplusplus

-extern "C" {

-#endif

-

-/* Options */

-

-#define PCRE_CASELESS           0x00000001

-#define PCRE_MULTILINE          0x00000002

-#define PCRE_DOTALL             0x00000004

-#define PCRE_EXTENDED           0x00000008

-#define PCRE_ANCHORED           0x00000010

-#define PCRE_DOLLAR_ENDONLY     0x00000020

-#define PCRE_EXTRA              0x00000040

-#define PCRE_NOTBOL             0x00000080

-#define PCRE_NOTEOL             0x00000100

-#define PCRE_UNGREEDY           0x00000200

-#define PCRE_NOTEMPTY           0x00000400

-#define PCRE_UTF8               0x00000800

-#define PCRE_NO_AUTO_CAPTURE    0x00001000

-#define PCRE_NO_UTF8_CHECK      0x00002000

-#define PCRE_AUTO_CALLOUT       0x00004000

-#define PCRE_PARTIAL            0x00008000

-#define PCRE_DFA_SHORTEST       0x00010000

-#define PCRE_DFA_RESTART        0x00020000

-#define PCRE_FIRSTLINE          0x00040000

-

-/* Exec-time and get/set-time error codes */

-

-#define PCRE_ERROR_NOMATCH         (-1)

-#define PCRE_ERROR_NULL            (-2)

-#define PCRE_ERROR_BADOPTION       (-3)

-#define PCRE_ERROR_BADMAGIC        (-4)

-#define PCRE_ERROR_UNKNOWN_NODE    (-5)

-#define PCRE_ERROR_NOMEMORY        (-6)

-#define PCRE_ERROR_NOSUBSTRING     (-7)

-#define PCRE_ERROR_MATCHLIMIT      (-8)

-#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */

-#define PCRE_ERROR_BADUTF8        (-10)

-#define PCRE_ERROR_BADUTF8_OFFSET (-11)

-#define PCRE_ERROR_PARTIAL        (-12)

-#define PCRE_ERROR_BADPARTIAL     (-13)

-#define PCRE_ERROR_INTERNAL       (-14)

-#define PCRE_ERROR_BADCOUNT       (-15)

-#define PCRE_ERROR_DFA_UITEM      (-16)

-#define PCRE_ERROR_DFA_UCOND      (-17)

-#define PCRE_ERROR_DFA_UMLIMIT    (-18)

-#define PCRE_ERROR_DFA_WSSIZE     (-19)

-#define PCRE_ERROR_DFA_RECURSE    (-20)

-

-/* Request types for pcre_fullinfo() */

-

-#define PCRE_INFO_OPTIONS            0

-#define PCRE_INFO_SIZE               1

-#define PCRE_INFO_CAPTURECOUNT       2

-#define PCRE_INFO_BACKREFMAX         3

-#define PCRE_INFO_FIRSTBYTE          4

-#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */

-#define PCRE_INFO_FIRSTTABLE         5

-#define PCRE_INFO_LASTLITERAL        6

-#define PCRE_INFO_NAMEENTRYSIZE      7

-#define PCRE_INFO_NAMECOUNT          8

-#define PCRE_INFO_NAMETABLE          9

-#define PCRE_INFO_STUDYSIZE         10

-#define PCRE_INFO_DEFAULT_TABLES    11

-

-/* Request types for pcre_config() */

-

-#define PCRE_CONFIG_UTF8                    0

-#define PCRE_CONFIG_NEWLINE                 1

-#define PCRE_CONFIG_LINK_SIZE               2

-#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3

-#define PCRE_CONFIG_MATCH_LIMIT             4

-#define PCRE_CONFIG_STACKRECURSE            5

-#define PCRE_CONFIG_UNICODE_PROPERTIES      6

-

-/* Bit flags for the pcre_extra structure */

-

-#define PCRE_EXTRA_STUDY_DATA          0x0001

-#define PCRE_EXTRA_MATCH_LIMIT         0x0002

-#define PCRE_EXTRA_CALLOUT_DATA        0x0004

-#define PCRE_EXTRA_TABLES              0x0008

-

-/* Types */

-

-struct real_pcre;                 /* declaration; the definition is private  */

-typedef struct real_pcre pcre;

-

-/* The structure for passing additional data to pcre_exec(). This is defined in

-such as way as to be extensible. Always add new fields at the end, in order to

-remain compatible. */

-

-typedef struct pcre_extra {

-  unsigned long int flags;        /* Bits for which fields are set */

-  void *study_data;               /* Opaque data from pcre_study() */

-  unsigned long int match_limit;  /* Maximum number of calls to match() */

-  void *callout_data;             /* Data passed back in callouts */

-  const unsigned char *tables;    /* Pointer to character tables */

-} pcre_extra;

-

-/* The structure for passing out data via the pcre_callout_function. We use a

-structure so that new fields can be added on the end in future versions,

-without changing the API of the function, thereby allowing old clients to work

-without modification. */

-

-typedef struct pcre_callout_block {

-  int          version;           /* Identifies version of block */

-  /* ------------------------ Version 0 ------------------------------- */

-  int          callout_number;    /* Number compiled into pattern */

-  int         *offset_vector;     /* The offset vector */

-  const char  *subject;           /* The subject being matched */

-  int          subject_length;    /* The length of the subject */

-  int          start_match;       /* Offset to start of this match attempt */

-  int          current_position;  /* Where we currently are in the subject */

-  int          capture_top;       /* Max current capture */

-  int          capture_last;      /* Most recently closed capture */

-  void        *callout_data;      /* Data passed in with the call */

-  /* ------------------- Added for Version 1 -------------------------- */

-  int          pattern_position;  /* Offset to next item in the pattern */

-  int          next_item_length;  /* Length of next item in the pattern */

-  /* ------------------------------------------------------------------ */

-} pcre_callout_block;

-

-/* Indirection for store get and free functions. These can be set to

-alternative malloc/free functions if required. Special ones are used in the

-non-recursive case for "frames". There is also an optional callout function

-that is triggered by the (?) regex item. For Virtual Pascal, these definitions

-have to take another form. */

-

-#ifndef VPCOMPAT

-PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);

-PCRE_DATA_SCOPE void  (*pcre_free)(void *);

-PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);

-PCRE_DATA_SCOPE void  (*pcre_stack_free)(void *);

-PCRE_DATA_SCOPE int   (*pcre_callout)(pcre_callout_block *);

-#else   /* VPCOMPAT */

-PCRE_DATA_SCOPE void *pcre_malloc(size_t);

-PCRE_DATA_SCOPE void  pcre_free(void *);

-PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t);

-PCRE_DATA_SCOPE void  pcre_stack_free(void *);

-PCRE_DATA_SCOPE int   pcre_callout(pcre_callout_block *);

-#endif  /* VPCOMPAT */

-

-/* Exported PCRE functions */

-

-PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *,

-                  const unsigned char *);

-PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **,

-                  int *, const unsigned char *);

-PCRE_DATA_SCOPE int  pcre_config(int, void *);

-PCRE_DATA_SCOPE int  pcre_copy_named_substring(const pcre *, const char *,

-                  int *, int, const char *, char *, int);

-PCRE_DATA_SCOPE int  pcre_copy_substring(const char *, int *, int, int, char *,

-                  int);

-PCRE_DATA_SCOPE int  pcre_dfa_exec(const pcre *, const pcre_extra *,

-                  const char *, int, int, int, int *, int , int *, int);

-PCRE_DATA_SCOPE int  pcre_exec(const pcre *, const pcre_extra *, const char *,

-                   int, int, int, int *, int);

-PCRE_DATA_SCOPE void pcre_free_substring(const char *);

-PCRE_DATA_SCOPE void pcre_free_substring_list(const char **);

-PCRE_DATA_SCOPE int  pcre_fullinfo(const pcre *, const pcre_extra *, int,

-                  void *);

-PCRE_DATA_SCOPE int  pcre_get_named_substring(const pcre *, const char *,

-                  int *, int, const char *, const char **);

-PCRE_DATA_SCOPE int  pcre_get_stringnumber(const pcre *, const char *);

-PCRE_DATA_SCOPE int  pcre_get_substring(const char *, int *, int, int,

-                  const char **);

-PCRE_DATA_SCOPE int  pcre_get_substring_list(const char *, int *, int,

-                  const char ***);

-PCRE_DATA_SCOPE int  pcre_info(const pcre *, int *, int *);

-PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void);

-PCRE_DATA_SCOPE int  pcre_refcount(pcre *, int);

-PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **);

-PCRE_DATA_SCOPE const char *pcre_version(void);

-

-#ifdef __cplusplus

-}  /* extern "C" */

-#endif

-

-#endif /* End of pcre.h */

-

-/* Include the (copy of) the public ucp header, changing the external name into

-a private one. This does no harm, even if we aren't compiling UCP support. */

-

-#define ucp_findchar _pcre_ucp_findchar

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-

-#ifndef _UCP_H

-#define _UCP_H

-

-/* These are the character categories that are returned by ucp_findchar */

-

-enum {

-  ucp_C,     /* Other */

-  ucp_L,     /* Letter */

-  ucp_M,     /* Mark */

-  ucp_N,     /* Number */

-  ucp_P,     /* Punctuation */

-  ucp_S,     /* Symbol */

-  ucp_Z      /* Separator */

-};

-

-/* These are the detailed character types that are returned by ucp_findchar */

-

-enum {

-  ucp_Cc,    /* Control */

-  ucp_Cf,    /* Format */

-  ucp_Cn,    /* Unassigned */

-  ucp_Co,    /* Private use */

-  ucp_Cs,    /* Surrogate */

-  ucp_Ll,    /* Lower case letter */

-  ucp_Lm,    /* Modifier letter */

-  ucp_Lo,    /* Other letter */

-  ucp_Lt,    /* Title case letter */

-  ucp_Lu,    /* Upper case letter */

-  ucp_Mc,    /* Spacing mark */

-  ucp_Me,    /* Enclosing mark */

-  ucp_Mn,    /* Non-spacing mark */

-  ucp_Nd,    /* Decimal number */

-  ucp_Nl,    /* Letter number */

-  ucp_No,    /* Other number */

-  ucp_Pc,    /* Connector punctuation */

-  ucp_Pd,    /* Dash punctuation */

-  ucp_Pe,    /* Close punctuation */

-  ucp_Pf,    /* Final punctuation */

-  ucp_Pi,    /* Initial punctuation */

-  ucp_Po,    /* Other punctuation */

-  ucp_Ps,    /* Open punctuation */

-  ucp_Sc,    /* Currency symbol */

-  ucp_Sk,    /* Modifier symbol */

-  ucp_Sm,    /* Mathematical symbol */

-  ucp_So,    /* Other symbol */

-  ucp_Zl,    /* Line separator */

-  ucp_Zp,    /* Paragraph separator */

-  ucp_Zs     /* Space separator */

-};

-

-extern int ucp_findchar(const int, int *, int *);

-

-#endif

-

-/* End of ucp.h */

-

-/* When compiling for use with the Virtual Pascal compiler, these functions

-need to have their names changed. PCRE must be compiled with the -DVPCOMPAT

-option on the command line. */

-

-#ifdef VPCOMPAT

-#define strncmp(s1,s2,m) _strncmp(s1,s2,m)

-#define memcpy(d,s,n)    _memcpy(d,s,n)

-#define memmove(d,s,n)   _memmove(d,s,n)

-#define memset(s,c,n)    _memset(s,c,n)

-#else  /* VPCOMPAT */

-

-/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),

-define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY

-is set. Otherwise, include an emulating function for those systems that have

-neither (there some non-Unix environments where this is the case). This assumes

-that all calls to memmove are moving strings upwards in store, which is the

-case in PCRE. */

-

-#if ! HAVE_MEMMOVE

-#undef  memmove        /* some systems may have a macro */

-#if HAVE_BCOPY

-#define memmove(a, b, c) bcopy(b, a, c)

-#else  /* HAVE_BCOPY */

-void *

-pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)

-{

-int i;

-dest += n;

-src += n;

-for (i = 0; i < n; ++i) *(--dest) =  *(--src);

-}

-#define memmove(a, b, c) pcre_memmove(a, b, c)

-#endif   /* not HAVE_BCOPY */

-#endif   /* not HAVE_MEMMOVE */

-#endif   /* not VPCOMPAT */

-

-

-/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored

-in big-endian order) by default. These are used, for example, to link from the

-start of a subpattern to its alternatives and its end. The use of 2 bytes per

-offset limits the size of the compiled regex to around 64K, which is big enough

-for almost everybody. However, I received a request for an even bigger limit.

-For this reason, and also to make the code easier to maintain, the storing and

-loading of offsets from the byte string is now handled by the macros that are

-defined here.

-

-The macros are controlled by the value of LINK_SIZE. This defaults to 2 in

-the config.h file, but can be overridden by using -D on the command line. This

-is automated on Unix systems via the "configure" command. */

-

-#if LINK_SIZE == 2

-

-#define PUT(a,n,d)   \

-  (a[n] = (d) >> 8), \

-  (a[(n)+1] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 8) | (a)[(n)+1])

-

-#define MAX_PATTERN_SIZE (1 << 16)

-

-

-#elif LINK_SIZE == 3

-

-#define PUT(a,n,d)       \

-  (a[n] = (d) >> 16),    \

-  (a[(n)+1] = (d) >> 8), \

-  (a[(n)+2] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])

-

-#define MAX_PATTERN_SIZE (1 << 24)

-

-

-#elif LINK_SIZE == 4

-

-#define PUT(a,n,d)        \

-  (a[n] = (d) >> 24),     \

-  (a[(n)+1] = (d) >> 16), \

-  (a[(n)+2] = (d) >> 8),  \

-  (a[(n)+3] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])

-

-#define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */

-

-

-#else

-#error LINK_SIZE must be either 2, 3, or 4

-#endif

-

-

-/* Convenience macro defined in terms of the others */

-

-#define PUTINC(a,n,d)   PUT(a,n,d), a += LINK_SIZE

-

-

-/* PCRE uses some other 2-byte quantities that do not change when the size of

-offsets changes. There are used for repeat counts and for other things such as

-capturing parenthesis numbers in back references. */

-

-#define PUT2(a,n,d)   \

-  a[n] = (d) >> 8; \

-  a[(n)+1] = (d) & 255

-

-#define GET2(a,n) \

-  (((a)[n] << 8) | (a)[(n)+1])

-

-#define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2

-

-

-/* When UTF-8 encoding is being used, a character is no longer just a single

-byte. The macros for character handling generate simple sequences when used in

-byte-mode, and more complicated ones for UTF-8 characters. */

-

-#ifndef SUPPORT_UTF8

-#define GETCHAR(c, eptr) c = *eptr;

-#define GETCHARTEST(c, eptr) c = *eptr;

-#define GETCHARINC(c, eptr) c = *eptr++;

-#define GETCHARINCTEST(c, eptr) c = *eptr++;

-#define GETCHARLEN(c, eptr, len) c = *eptr;

-#define BACKCHAR(eptr)

-

-#else   /* SUPPORT_UTF8 */

-

-/* Get the next UTF-8 character, not advancing the pointer. This is called when

-we know we are in UTF-8 mode. */

-

-#define GETCHAR(c, eptr) \

-  c = *eptr; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the

-pointer. */

-

-#define GETCHARTEST(c, eptr) \

-  c = *eptr; \

-  if (utf8 && (c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, advancing the pointer. This is called when we

-know we are in UTF-8 mode. */

-

-#define GETCHARINC(c, eptr) \

-  c = *eptr++; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    while (gcaa-- > 0) \

-      { \

-      gcss -= 6; \

-      c |= (*eptr++ & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next character, testing for UTF-8 mode, and advancing the pointer */

-

-#define GETCHARINCTEST(c, eptr) \

-  c = *eptr++; \

-  if (utf8 && (c & 0xc0) == 0xc0) \

-    { \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    while (gcaa-- > 0) \

-      { \

-      gcss -= 6; \

-      c |= (*eptr++ & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, not advancing the pointer, incrementing length

-if there are extra bytes. This is called when we know we are in UTF-8 mode. */

-

-#define GETCHARLEN(c, eptr, len) \

-  c = *eptr; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    len += gcaa; \

-    }

-

-/* If the pointer is not at the start of a character, move it back until

-it is. Called only in UTF-8 mode. */

-

-#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--;

-

-#endif

-

-

-/* In case there is no definition of offsetof() provided - though any proper

-Standard C system should have one. */

-

-#ifndef offsetof

-#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))

-#endif

-

-

-/* These are the public options that can change during matching. */

-

-#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)

-

-/* Private options flags start at the most significant end of the four bytes,

-but skip the top bit so we can use ints for convenience without getting tangled

-with negative values. The public options defined in pcre.h start at the least

-significant end. Make sure they don't overlap! */

-

-#define PCRE_FIRSTSET      0x40000000  /* first_byte is set */

-#define PCRE_REQCHSET      0x20000000  /* req_byte is set */

-#define PCRE_STARTLINE     0x10000000  /* start after \n for multiline */

-#define PCRE_ICHANGED      0x08000000  /* i option changes within regex */

-#define PCRE_NOPARTIAL     0x04000000  /* can't use partial with this regex */

-

-/* Options for the "extra" block produced by pcre_study(). */

-

-#define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */

-

-/* Masks for identifying the public options that are permitted at compile

-time, run time, or study time, respectively. */

-

-#define PUBLIC_OPTIONS \

-  (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \

-   PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \

-   PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE)

-

-#define PUBLIC_EXEC_OPTIONS \

-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \

-   PCRE_PARTIAL)

-

-#define PUBLIC_DFA_EXEC_OPTIONS \

-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \

-   PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART)

-

-#define PUBLIC_STUDY_OPTIONS 0   /* None defined */

-

-/* Magic number to provide a small check against being handed junk. Also used

-to detect whether a pattern was compiled on a host of different endianness. */

-

-#define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */

-

-/* Negative values for the firstchar and reqchar variables */

-

-#define REQ_UNSET (-2)

-#define REQ_NONE  (-1)

-

-/* The maximum remaining length of subject we are prepared to search for a

-req_byte match. */

-

-#define REQ_BYTE_MAX 1000

-

-/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a

-variable-length repeat, or a anything other than literal characters. */

-

-#define REQ_CASELESS 0x0100    /* indicates caselessness */

-#define REQ_VARY     0x0200    /* reqbyte followed non-literal item */

-

-/* Miscellaneous definitions */

-

-typedef int BOOL;

-

-#define FALSE   0

-#define TRUE    1

-

-/* Escape items that are just an encoding of a particular data value. Note that

-ESC_n is defined as yet another macro, which is set in config.h to either \n

-(the default) or \r (which some people want). */

-

-#ifndef ESC_e

-#define ESC_e 27

-#endif

-

-#ifndef ESC_f

-#define ESC_f '\f'

-#endif

-

-#ifndef ESC_n

-#define ESC_n NEWLINE

-#endif

-

-#ifndef ESC_r

-#define ESC_r '\r'

-#endif

-

-/* We can't officially use ESC_t because it is a POSIX reserved identifier

-(presumably because of all the others like size_t). */

-

-#ifndef ESC_tee

-#define ESC_tee '\t'

-#endif

-

-/* These are escaped items that aren't just an encoding of a particular data

-value such as \n. They must have non-zero values, as check_escape() returns

-their negation. Also, they must appear in the same order as in the opcode

-definitions below, up to ESC_z. There's a dummy for OP_ANY because it

-corresponds to "." rather than an escape sequence. The final one must be

-ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two

-tests in the code for an escape greater than ESC_b and less than ESC_Z to

-detect the types that may be repeated. These are the types that consume

-characters. If any new escapes are put in between that don't consume a

-character, that code will have to change. */

-

-enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,

-       ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_X, ESC_Z, ESC_z, ESC_E,

-       ESC_Q, ESC_REF };

-

-/* Flag bits and data types for the extended class (OP_XCLASS) for classes that

-contain UTF-8 characters with values greater than 255. */

-

-#define XCL_NOT    0x01    /* Flag: this is a negative class */

-#define XCL_MAP    0x02    /* Flag: a 32-byte map is present */

-

-#define XCL_END       0    /* Marks end of individual items */

-#define XCL_SINGLE    1    /* Single item (one multibyte char) follows */

-#define XCL_RANGE     2    /* A range (two multibyte chars) follows */

-#define XCL_PROP      3    /* Unicode property (one property code) follows */

-#define XCL_NOTPROP   4    /* Unicode inverted property (ditto) */

-

-

-/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets

-that extract substrings. Starting from 1 (i.e. after OP_END), the values up to

-OP_EOD must correspond in order to the list of escapes immediately above.

-Note that whenever this list is updated, the two macro definitions that follow

-must also be updated to match. */

-

-enum {

-  OP_END,            /* 0 End of pattern */

-

-  /* Values corresponding to backslashed metacharacters */

-

-  OP_SOD,            /* 1 Start of data: \A */

-  OP_SOM,            /* 2 Start of match (subject + offset): \G */

-  OP_NOT_WORD_BOUNDARY,  /*  3 \B */

-  OP_WORD_BOUNDARY,      /*  4 \b */

-  OP_NOT_DIGIT,          /*  5 \D */

-  OP_DIGIT,              /*  6 \d */

-  OP_NOT_WHITESPACE,     /*  7 \S */

-  OP_WHITESPACE,         /*  8 \s */

-  OP_NOT_WORDCHAR,       /*  9 \W */

-  OP_WORDCHAR,           /* 10 \w */

-  OP_ANY,            /* 11 Match any character */

-  OP_ANYBYTE,        /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */

-  OP_NOTPROP,        /* 13 \P (not Unicode property) */

-  OP_PROP,           /* 14 \p (Unicode property) */

-  OP_EXTUNI,         /* 15 \X (extended Unicode sequence */

-  OP_EODN,           /* 16 End of data or \n at end of data: \Z. */

-  OP_EOD,            /* 17 End of data: \z */

-

-  OP_OPT,            /* 18 Set runtime options */

-  OP_CIRC,           /* 19 Start of line - varies with multiline switch */

-  OP_DOLL,           /* 20 End of line - varies with multiline switch */

-  OP_CHAR,           /* 21 Match one character, casefully */

-  OP_CHARNC,         /* 22 Match one character, caselessly */

-  OP_NOT,            /* 23 Match anything but the following char */

-

-  OP_STAR,           /* 24 The maximizing and minimizing versions of */

-  OP_MINSTAR,        /* 25 all these opcodes must come in pairs, with */

-  OP_PLUS,           /* 26 the minimizing one second. */

-  OP_MINPLUS,        /* 27 This first set applies to single characters */

-  OP_QUERY,          /* 28 */

-  OP_MINQUERY,       /* 29 */

-  OP_UPTO,           /* 30 From 0 to n matches */

-  OP_MINUPTO,        /* 31 */

-  OP_EXACT,          /* 32 Exactly n matches */

-

-  OP_NOTSTAR,        /* 33 The maximizing and minimizing versions of */

-  OP_NOTMINSTAR,     /* 34 all these opcodes must come in pairs, with */

-  OP_NOTPLUS,        /* 35 the minimizing one second. */

-  OP_NOTMINPLUS,     /* 36 This set applies to "not" single characters */

-  OP_NOTQUERY,       /* 37 */

-  OP_NOTMINQUERY,    /* 38 */

-  OP_NOTUPTO,        /* 39 From 0 to n matches */

-  OP_NOTMINUPTO,     /* 40 */

-  OP_NOTEXACT,       /* 41 Exactly n matches */

-

-  OP_TYPESTAR,       /* 42 The maximizing and minimizing versions of */

-  OP_TYPEMINSTAR,    /* 43 all these opcodes must come in pairs, with */

-  OP_TYPEPLUS,       /* 44 the minimizing one second. These codes must */

-  OP_TYPEMINPLUS,    /* 45 be in exactly the same order as those above. */

-  OP_TYPEQUERY,      /* 46 This set applies to character types such as \d */

-  OP_TYPEMINQUERY,   /* 47 */

-  OP_TYPEUPTO,       /* 48 From 0 to n matches */

-  OP_TYPEMINUPTO,    /* 49 */

-  OP_TYPEEXACT,      /* 50 Exactly n matches */

-

-  OP_CRSTAR,         /* 51 The maximizing and minimizing versions of */

-  OP_CRMINSTAR,      /* 52 all these opcodes must come in pairs, with */

-  OP_CRPLUS,         /* 53 the minimizing one second. These codes must */

-  OP_CRMINPLUS,      /* 54 be in exactly the same order as those above. */

-  OP_CRQUERY,        /* 55 These are for character classes and back refs */

-  OP_CRMINQUERY,     /* 56 */

-  OP_CRRANGE,        /* 57 These are different to the three sets above. */

-  OP_CRMINRANGE,     /* 58 */

-

-  OP_CLASS,          /* 59 Match a character class, chars < 256 only */

-  OP_NCLASS,         /* 60 Same, but the bitmap was created from a negative

-                           class - the difference is relevant only when a UTF-8

-                           character > 255 is encountered. */

-

-  OP_XCLASS,         /* 61 Extended class for handling UTF-8 chars within the

-                           class. This does both positive and negative. */

-

-  OP_REF,            /* 62 Match a back reference */

-  OP_RECURSE,        /* 63 Match a numbered subpattern (possibly recursive) */

-  OP_CALLOUT,        /* 64 Call out to external function if provided */

-

-  OP_ALT,            /* 65 Start of alternation */

-  OP_KET,            /* 66 End of group that doesn't have an unbounded repeat */

-  OP_KETRMAX,        /* 67 These two must remain together and in this */

-  OP_KETRMIN,        /* 68 order. They are for groups the repeat for ever. */

-

-  /* The assertions must come before ONCE and COND */

-

-  OP_ASSERT,         /* 69 Positive lookahead */

-  OP_ASSERT_NOT,     /* 70 Negative lookahead */

-  OP_ASSERTBACK,     /* 71 Positive lookbehind */

-  OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */

-  OP_REVERSE,        /* 73 Move pointer back - used in lookbehind assertions */

-

-  /* ONCE and COND must come after the assertions, with ONCE first, as there's

-  a test for >= ONCE for a subpattern that isn't an assertion. */

-

-  OP_ONCE,           /* 74 Once matched, don't back up into the subpattern */

-  OP_COND,           /* 75 Conditional group */

-  OP_CREF,           /* 76 Used to hold an extraction string number (cond ref) */

-

-  OP_BRAZERO,        /* 77 These two must remain together and in this */

-  OP_BRAMINZERO,     /* 78 order. */

-

-  OP_BRANUMBER,      /* 79 Used for extracting brackets whose number is greater

-                           than can fit into an opcode. */

-

-  OP_BRA             /* 80 This and greater values are used for brackets that

-                           extract substrings up to EXTRACT_BASIC_MAX. After

-                           that, use is made of OP_BRANUMBER. */

-};

-

-/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and

-study.c that all opcodes are less than 128 in value. This makes handling UTF-8

-character sequences easier. */

-

-/* The highest extraction number before we have to start using additional

-bytes. (Originally PCRE didn't have support for extraction counts highter than

-this number.) The value is limited by the number of opcodes left after OP_BRA,

-i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional

-opcodes. */

-

-#define EXTRACT_BASIC_MAX  100

-

-

-/* This macro defines textual names for all the opcodes. These are used only

-for debugging. The macro is referenced only in pcre_printint.c. */

-

-#define OP_NAME_LIST \

-  "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d",                \

-  "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte",                   \

-  "notprop", "prop", "extuni",                                    \

-  "\\Z", "\\z",                                                   \

-  "Opt", "^", "$", "char", "charnc", "not",                       \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{",                      \

-  "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \

-  "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \

-  "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\

-  "Brazero", "Braminzero", "Branumber", "Bra"

-

-

-/* This macro defines the length of fixed length operations in the compiled

-regex. The lengths are used when searching for specific things, and also in the

-debugging printing of a compiled regex. We use a macro so that it can be

-defined close to the definitions of the opcodes themselves.

-

-As things have been extended, some of these are no longer fixed lenths, but are

-minima instead. For example, the length of a single-character repeat may vary

-in UTF-8 mode. The code that uses this table must know about such things. */

-

-#define OP_LENGTHS \

-  1,                             /* End                                    */ \

-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \

-  1, 1,                          /* Any, Anybyte                           */ \

-  2, 2, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \

-  1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \

-  2,                             /* Char  - the minimum length             */ \

-  2,                             /* Charnc  - the minimum length           */ \

-  2,                             /* not                                    */ \

-  /* Positive single-char repeats                            ** These are  */ \

-  2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??      ** minima in  */ \

-  4, 4, 4,                       /* upto, minupto, exact     ** UTF-8 mode */ \

-  /* Negative single-char repeats - only for chars < 256                   */ \

-  2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \

-  4, 4, 4,                       /* NOT upto, minupto, exact               */ \

-  /* Positive type repeats                                                 */ \

-  2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \

-  4, 4, 4,                       /* Type upto, minupto, exact              */ \

-  /* Character class & ref repeats                                         */ \

-  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \

-  5, 5,                          /* CRRANGE, CRMINRANGE                    */ \

- 33,                             /* CLASS                                  */ \

- 33,                             /* NCLASS                                 */ \

-  0,                             /* XCLASS - variable length               */ \

-  3,                             /* REF                                    */ \

-  1+LINK_SIZE,                   /* RECURSE                                */ \

-  2+2*LINK_SIZE,                 /* CALLOUT                                */ \

-  1+LINK_SIZE,                   /* Alt                                    */ \

-  1+LINK_SIZE,                   /* Ket                                    */ \

-  1+LINK_SIZE,                   /* KetRmax                                */ \

-  1+LINK_SIZE,                   /* KetRmin                                */ \

-  1+LINK_SIZE,                   /* Assert                                 */ \

-  1+LINK_SIZE,                   /* Assert not                             */ \

-  1+LINK_SIZE,                   /* Assert behind                          */ \

-  1+LINK_SIZE,                   /* Assert behind not                      */ \

-  1+LINK_SIZE,                   /* Reverse                                */ \

-  1+LINK_SIZE,                   /* Once                                   */ \

-  1+LINK_SIZE,                   /* COND                                   */ \

-  3,                             /* CREF                                   */ \

-  1, 1,                          /* BRAZERO, BRAMINZERO                    */ \

-  3,                             /* BRANUMBER                              */ \

-  1+LINK_SIZE                    /* BRA                                    */ \

-

-

-/* A magic value for OP_CREF to indicate the "in recursion" condition. */

-

-#define CREF_RECURSE  0xffff

-

-/* Error code numbers. They are given names so that they can more easily be

-tracked. */

-

-enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,

-       ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,

-       ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,

-       ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,

-       ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47 };

-

-/* The real format of the start of the pcre block; the index of names and the

-code vector run on as long as necessary after the end. We store an explicit

-offset to the name table so that if a regex is compiled on one host, saved, and

-then run on another where the size of pointers is different, all might still

-be well. For the case of compiled-on-4 and run-on-8, we include an extra

-pointer that is always NULL. For future-proofing, a few dummy fields were

-originally included - even though you can never get this planning right - but

-there is only one left now.

-

-NOTE NOTE NOTE:

-Because people can now save and re-use compiled patterns, any additions to this

-structure should be made at the end, and something earlier (e.g. a new

-flag in the options or one of the dummy fields) should indicate that the new

-fields are present. Currently PCRE always sets the dummy fields to zero.

-NOTE NOTE NOTE:

-*/

-

-typedef struct real_pcre {

-  pcre_uint32 magic_number;

-  pcre_uint32 size;               /* Total that was malloced */

-  pcre_uint32 options;

-  pcre_uint32 dummy1;             /* For future use, maybe */

-

-  pcre_uint16 top_bracket;

-  pcre_uint16 top_backref;

-  pcre_uint16 first_byte;

-  pcre_uint16 req_byte;

-  pcre_uint16 name_table_offset;  /* Offset to name table that follows */

-  pcre_uint16 name_entry_size;    /* Size of any name items */

-  pcre_uint16 name_count;         /* Number of name items */

-  pcre_uint16 ref_count;          /* Reference count */

-

-  const unsigned char *tables;    /* Pointer to tables or NULL for std */

-  const unsigned char *nullpad;   /* NULL padding */

-} real_pcre;

-

-/* The format of the block used to store data from pcre_study(). The same

-remark (see NOTE above) about extending this structure applies. */

-

-typedef struct pcre_study_data {

-  pcre_uint32 size;               /* Total that was malloced */

-  pcre_uint32 options;

-  uschar start_bits[32];

-} pcre_study_data;

-

-/* Structure for passing "static" information around between the functions

-doing the compiling, so that they are thread-safe. */

-

-typedef struct compile_data {

-  const uschar *lcc;            /* Points to lower casing table */

-  const uschar *fcc;            /* Points to case-flipping table */

-  const uschar *cbits;          /* Points to character type table */

-  const uschar *ctypes;         /* Points to table of type maps */

-  const uschar *start_code;     /* The start of the compiled code */

-  const uschar *start_pattern;  /* The start of the pattern */

-  uschar *name_table;           /* The name/number table */

-  int  names_found;             /* Number of entries so far */

-  int  name_entry_size;         /* Size of each entry */

-  int  top_backref;             /* Maximum back reference */

-  unsigned int backref_map;     /* Bitmap of low back refs */

-  int  req_varyopt;             /* "After variable item" flag for reqbyte */

-  BOOL nopartial;               /* Set TRUE if partial won't work */

-} compile_data;

-

-/* Structure for maintaining a chain of pointers to the currently incomplete

-branches, for testing for left recursion. */

-

-typedef struct branch_chain {

-  struct branch_chain *outer;

-  uschar *current;

-} branch_chain;

-

-/* Structure for items in a linked list that represents an explicit recursive

-call within the pattern. */

-

-typedef struct recursion_info {

-  struct recursion_info *prevrec; /* Previous recursion record (or NULL) */

-  int group_num;                /* Number of group that was called */

-  const uschar *after_call;     /* "Return value": points after the call in the expr */

-  const uschar *save_start;     /* Old value of md->start_match */

-  int *offset_save;             /* Pointer to start of saved offsets */

-  int saved_max;                /* Number of saved offsets */

-} recursion_info;

-

-/* When compiling in a mode that doesn't use recursive calls to match(),

-a structure is used to remember local variables on the heap. It is defined in

-pcre.c, close to the match() function, so that it is easy to keep it in step

-with any changes of local variable. However, the pointer to the current frame

-must be saved in some "static" place over a longjmp(). We declare the

-structure here so that we can put a pointer in the match_data structure.

-NOTE: This isn't used for a "normal" compilation of pcre. */

-

-struct heapframe;

-

-/* Structure for passing "static" information around between the functions

-doing traditional NFA matching, so that they are thread-safe. */

-

-typedef struct match_data {

-  unsigned long int match_call_count; /* As it says */

-  unsigned long int match_limit;/* As it says */

-  int   *offset_vector;         /* Offset vector */

-  int    offset_end;            /* One past the end */

-  int    offset_max;            /* The maximum usable for return data */

-  const uschar *lcc;            /* Points to lower casing table */

-  const uschar *ctypes;         /* Points to table of type maps */

-  BOOL   offset_overflow;       /* Set if too many extractions */

-  BOOL   notbol;                /* NOTBOL flag */

-  BOOL   noteol;                /* NOTEOL flag */

-  BOOL   utf8;                  /* UTF8 flag */

-  BOOL   endonly;               /* Dollar not before final \n */

-  BOOL   notempty;              /* Empty string match not wanted */

-  BOOL   partial;               /* PARTIAL flag */

-  BOOL   hitend;                /* Hit the end of the subject at some point */

-  const uschar *start_code;     /* For use when recursing */

-  const uschar *start_subject;  /* Start of the subject string */

-  const uschar *end_subject;    /* End of the subject string */

-  const uschar *start_match;    /* Start of this match attempt */

-  const uschar *end_match_ptr;  /* Subject position at end match */

-  int    end_offset_top;        /* Highwater mark at end of match */

-  int    capture_last;          /* Most recent capture number */

-  int    start_offset;          /* The start offset value */

-  recursion_info *recursive;    /* Linked list of recursion data */

-  void  *callout_data;          /* To pass back to callouts */

-  struct heapframe *thisframe;  /* Used only when compiling for no recursion */

-} match_data;

-

-/* A similar structure is used for the same purpose by the DFA matching

-functions. */

-

-typedef struct dfa_match_data {

-  const uschar *start_code;     /* Start of the compiled pattern */

-  const uschar *start_subject;  /* Start of the subject string */

-  const uschar *end_subject;    /* End of subject string */

-  const uschar *tables;         /* Character tables */

-  int   moptions;               /* Match options */

-  int   poptions;               /* Pattern options */

-  void  *callout_data;          /* To pass back to callouts */

-} dfa_match_data;

-

-/* Bit definitions for entries in the pcre_ctypes table. */

-

-#define ctype_space   0x01

-#define ctype_letter  0x02

-#define ctype_digit   0x04

-#define ctype_xdigit  0x08

-#define ctype_word    0x10   /* alphameric or '_' */

-#define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */

-

-/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set

-of bits for a class map. Some classes are built by combining these tables. */

-

-#define cbit_space     0      /* [:space:] or \s */

-#define cbit_xdigit   32      /* [:xdigit:] */

-#define cbit_digit    64      /* [:digit:] or \d */

-#define cbit_upper    96      /* [:upper:] */

-#define cbit_lower   128      /* [:lower:] */

-#define cbit_word    160      /* [:word:] or \w */

-#define cbit_graph   192      /* [:graph:] */

-#define cbit_print   224      /* [:print:] */

-#define cbit_punct   256      /* [:punct:] */

-#define cbit_cntrl   288      /* [:cntrl:] */

-#define cbit_length  320      /* Length of the cbits table */

-

-/* Offsets of the various tables from the base tables pointer, and

-total length. */

-

-#define lcc_offset      0

-#define fcc_offset    256

-#define cbits_offset  512

-#define ctypes_offset (cbits_offset + cbit_length)

-#define tables_length (ctypes_offset + 256)

-

-/* Layout of the UCP type table that translates property names into codes for

-ucp_findchar(). */

-

-typedef struct {

-  const char *name;

-  int value;

-} ucp_type_table;

-

-

-/* Internal shared data tables. These are tables that are used by more than one

-of the exported public functions. They have to be "external" in the C sense,

-but are not part of the PCRE public API. The data for these tables is in the

-pcre_tables.c module. */

-

-extern const int    _pcre_utf8_table1[];

-extern const int    _pcre_utf8_table2[];

-extern const int    _pcre_utf8_table3[];

-extern const uschar _pcre_utf8_table4[];

-

-extern const int    _pcre_utf8_table1_size;

-

-extern const ucp_type_table _pcre_utt[];

-extern const int _pcre_utt_size;

-

-extern const uschar _pcre_default_tables[];

-

-extern const uschar _pcre_OP_lengths[];

-

-

-/* Internal shared functions. These are functions that are used by more than

-one of the exported public functions. They have to be "external" in the C

-sense, but are not part of the PCRE public API. */

-

-extern int         _pcre_ord2utf8(int, uschar *);

-extern void        _pcre_printint(pcre *, FILE *);

-extern real_pcre * _pcre_try_flipped(const real_pcre *, real_pcre *,

-                     const pcre_study_data *, pcre_study_data *);

-extern int         _pcre_ucp_findchar(const int, int *, int *);

-extern int         _pcre_valid_utf8(const uschar *, int);

-extern BOOL        _pcre_xclass(int, const uschar *);

-

-/* End of pcre_internal.h */

-

-

-/*************************************************

-*      Code parameters and static tables         *

-*************************************************/

-

-/* Maximum number of items on the nested bracket stacks at compile time. This

-applies to the nesting of all kinds of parentheses. It does not limit

-un-nested, non-capturing parentheses. This number can be made bigger if

-necessary - it is used to dimension one int and one unsigned char vector at

-compile time. */

-

-#define BRASTACK_SIZE 200

-

-

-/* Table for handling escaped characters in the range '0'-'z'. Positive returns

-are simple data values; negative values are for special things like \d and so

-on. Zero means further processing is needed (for things like \x), or the escape

-is invalid. */

-

-#if !EBCDIC   /* This is the "normal" table for ASCII systems */

-static const short int escapes[] = {

-     0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */

-     0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */

-   '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E,      0, -ESC_G,   /* @ - G */

-     0,      0,      0,      0,      0,      0,      0,      0,   /* H - O */

--ESC_P, -ESC_Q,      0, -ESC_S,      0,      0,      0, -ESC_W,   /* P - W */

--ESC_X,      0, -ESC_Z,    '[',   '\\',    ']',    '^',    '_',   /* X - _ */

-   '`',      7, -ESC_b,      0, -ESC_d,  ESC_e,  ESC_f,      0,   /* ` - g */

-     0,      0,      0,      0,      0,      0,  ESC_n,      0,   /* h - o */

--ESC_p,      0,  ESC_r, -ESC_s,  ESC_tee,    0,      0, -ESC_w,   /* p - w */

-     0,      0, -ESC_z                                            /* x - z */

-};

-

-#else         /* This is the "abnormal" table for EBCDIC systems */

-static const short int escapes[] = {

-/*  48 */     0,     0,      0,     '.',    '<',   '(',    '+',    '|',

-/*  50 */   '&',     0,      0,       0,      0,     0,      0,      0,

-/*  58 */     0,     0,    '!',     '$',    '*',   ')',    ';',    '~',

-/*  60 */   '-',   '/',      0,       0,      0,     0,      0,      0,

-/*  68 */     0,     0,    '|',     ',',    '%',   '_',    '>',    '?',

-/*  70 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  78 */     0,   '`',    ':',     '#',    '@',  '\'',    '=',    '"',

-/*  80 */     0,     7, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,

-/*  88 */     0,     0,      0,     '{',      0,     0,      0,      0,

-/*  90 */     0,     0,      0,     'l',      0, ESC_n,      0, -ESC_p,

-/*  98 */     0, ESC_r,      0,     '}',      0,     0,      0,      0,

-/*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,     0, -ESC_w,      0,

-/*  A8 */     0,-ESC_z,      0,       0,      0,   '[',      0,      0,

-/*  B0 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  B8 */     0,     0,      0,       0,      0,   ']',    '=',    '-',

-/*  C0 */   '{',-ESC_A, -ESC_B,  -ESC_C, -ESC_D,-ESC_E,      0, -ESC_G,

-/*  C8 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  D0 */   '}',     0,      0,       0,      0,     0,      0, -ESC_P,

-/*  D8 */-ESC_Q,     0,      0,       0,      0,     0,      0,      0,

-/*  E0 */  '\\',     0, -ESC_S,       0,      0,     0, -ESC_W, -ESC_X,

-/*  E8 */     0,-ESC_Z,      0,       0,      0,     0,      0,      0,

-/*  F0 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  F8 */     0,     0,      0,       0,      0,     0,      0,      0

-};

-#endif

-

-

-/* Tables of names of POSIX character classes and their lengths. The list is

-terminated by a zero length entry. The first three must be alpha, upper, lower,

-as this is assumed for handling case independence. */

-

-static const char *const posix_names[] = {

-  "alpha", "lower", "upper",

-  "alnum", "ascii", "blank", "cntrl", "digit", "graph",

-  "print", "punct", "space", "word",  "xdigit" };

-

-static const uschar posix_name_lengths[] = {

-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };

-

-/* Table of class bit maps for each POSIX class; up to three may be combined

-to form the class. The table for [:blank:] is dynamically modified to remove

-the vertical space characters. */

-

-static const int posix_class_maps[] = {

-  cbit_lower, cbit_upper, -1,             /* alpha */

-  cbit_lower, -1,         -1,             /* lower */

-  cbit_upper, -1,         -1,             /* upper */

-  cbit_digit, cbit_lower, cbit_upper,     /* alnum */

-  cbit_print, cbit_cntrl, -1,             /* ascii */

-  cbit_space, -1,         -1,             /* blank - a GNU extension */

-  cbit_cntrl, -1,         -1,             /* cntrl */

-  cbit_digit, -1,         -1,             /* digit */

-  cbit_graph, -1,         -1,             /* graph */

-  cbit_print, -1,         -1,             /* print */

-  cbit_punct, -1,         -1,             /* punct */

-  cbit_space, -1,         -1,             /* space */

-  cbit_word,  -1,         -1,             /* word - a Perl extension */

-  cbit_xdigit,-1,         -1              /* xdigit */

-};

-

-

-/* The texts of compile-time error messages. These are "char *" because they

-are passed to the outside world. */

-

-static const char *error_texts[] = {

-  "no error",

-  "\\ at end of pattern",

-  "\\c at end of pattern",

-  "unrecognized character follows \\",

-  "numbers out of order in {} quantifier",

-  /* 5 */

-  "number too big in {} quantifier",

-  "missing terminating ] for character class",

-  "invalid escape sequence in character class",

-  "range out of order in character class",

-  "nothing to repeat",

-  /* 10 */

-  "operand of unlimited repeat could match the empty string",

-  "internal error: unexpected repeat",

-  "unrecognized character after (?",

-  "POSIX named classes are supported only within a class",

-  "missing )",

-  /* 15 */

-  "reference to non-existent subpattern",

-  "erroffset passed as NULL",

-  "unknown option bit(s) set",

-  "missing ) after comment",

-  "parentheses nested too deeply",

-  /* 20 */

-  "regular expression too large",

-  "failed to get memory",

-  "unmatched parentheses",

-  "internal error: code overflow",

-  "unrecognized character after (?<",

-  /* 25 */

-  "lookbehind assertion is not fixed length",

-  "malformed number after (?(",

-  "conditional group contains more than two branches",

-  "assertion expected after (?(",

-  "(?R or (?digits must be followed by )",

-  /* 30 */

-  "unknown POSIX class name",

-  "POSIX collating elements are not supported",

-  "this version of PCRE is not compiled with PCRE_UTF8 support",

-  "spare error",

-  "character value in \\x{...} sequence is too large",

-  /* 35 */

-  "invalid condition (?(0)",

-  "\\C not allowed in lookbehind assertion",

-  "PCRE does not support \\L, \\l, \\N, \\U, or \\u",

-  "number after (?C is > 255",

-  "closing ) for (?C expected",

-  /* 40 */

-  "recursive call could loop indefinitely",

-  "unrecognized character after (?P",

-  "syntax error after (?P",

-  "two named groups have the same name",

-  "invalid UTF-8 string",

-  /* 45 */

-  "support for \\P, \\p, and \\X has not been compiled",

-  "malformed \\P or \\p sequence",

-  "unknown property name after \\P or \\p"

-};

-

-

-/* Table to identify digits and hex digits. This is used when compiling

-patterns. Note that the tables in chartables are dependent on the locale, and

-may mark arbitrary characters as digits - but the PCRE compiling code expects

-to handle only 0-9, a-z, and A-Z as digits when compiling. That is why we have

-a private table here. It costs 256 bytes, but it is a lot faster than doing

-character value tests (at least in some simple cases I timed), and in some

-applications one wants PCRE to compile efficiently as well as match

-efficiently.

-

-For convenience, we use the same bit definitions as in chartables:

-

-  0x04   decimal digit

-  0x08   hexadecimal digit

-

-Then we can use ctype_digit and ctype_xdigit in the code. */

-

-#if !EBCDIC    /* This is the "normal" case, for ASCII systems */

-static const unsigned char digitab[] =

-  {

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - '  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ( - /  */

-  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  */

-  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /*  8 - ?  */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  @ - G  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H - O  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  P - W  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  X - _  */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  ` - g  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h - o  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  p - w  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  x -127 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */

-

-#else          /* This is the "abnormal" case, for EBCDIC systems */

-static const unsigned char digitab[] =

-  {

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7  0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 10 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  32- 39 20 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 30 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 40 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  72- |     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 50 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  88- ¬     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 60 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ?     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "     */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* 128- g  80 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144- p  90 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160- x  A0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 B0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191    */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  { - G  C0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  } - P  D0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  \ - X  E0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239    */

-  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  F0 */

-  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255    */

-

-static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */

-  0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*   0-  7 */

-  0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  32- 39 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63 */

-  0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 */

-  0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /*  72- |  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 */

-  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /*  88- ¬  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 */

-  0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ?  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* 128- g  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143 */

-  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* 144- p  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159 */

-  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* 160- x  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175 */

-  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 */

-  0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  { - G  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207 */

-  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  } - P  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223 */

-  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /*  \ - X  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239 */

-  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */

-  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255 */

-#endif

-

-

-/* Definition to allow mutual recursion */

-

-static BOOL

-  compile_regex(int, int, int *, uschar **, const uschar **, int *, BOOL, int,

-    int *, int *, branch_chain *, compile_data *);

-

-

-

-/*************************************************

-*            Handle escapes                      *

-*************************************************/

-

-/* This function is called when a \ has been encountered. It either returns a

-positive value for a simple escape such as \n, or a negative value which

-encodes one of the more complicated things such as \d. When UTF-8 is enabled,

-a positive value greater than 255 may be returned. On entry, ptr is pointing at

-the \. On exit, it is on the final character of the escape sequence.

-

-Arguments:

-  ptrptr         points to the pattern position pointer

-  errorcodeptr   points to the errorcode variable

-  bracount       number of previous extracting brackets

-  options        the options bits

-  isclass        TRUE if inside a character class

-

-Returns:         zero or positive => a data character

-                 negative => a special escape sequence

-                 on error, errorptr is set

-*/

-

-static int

-check_escape(const uschar **ptrptr, int *errorcodeptr, int bracount,

-  int options, BOOL isclass)

-{

-const uschar *ptr = *ptrptr;

-int c, i;

-

-/* If backslash is at the end of the pattern, it's an error. */

-

-c = *(++ptr);

-if (c == 0) *errorcodeptr = ERR1;

-

-/* Non-alphamerics are literals. For digits or letters, do an initial lookup in

-a table. A non-zero result is something that can be returned immediately.

-Otherwise further processing may be required. */

-

-#if !EBCDIC    /* ASCII coding */

-else if (c < '0' || c > 'z') {}                           /* Not alphameric */

-else if ((i = escapes[c - '0']) != 0) c = i;

-

-#else          /* EBCDIC coding */

-else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {}   /* Not alphameric */

-else if ((i = escapes[c - 0x48]) != 0)  c = i;

-#endif

-

-/* Escapes that need further processing, or are illegal. */

-

-else

-  {

-  const uschar *oldptr;

-  switch (c)

-    {

-    /* A number of Perl escapes are not handled by PCRE. We give an explicit

-    error. */

-

-    case 'l':

-    case 'L':

-    case 'N':

-    case 'u':

-    case 'U':

-    *errorcodeptr = ERR37;

-    break;

-

-    /* The handling of escape sequences consisting of a string of digits

-    starting with one that is not zero is not straightforward. By experiment,

-    the way Perl works seems to be as follows:

-

-    Outside a character class, the digits are read as a decimal number. If the

-    number is less than 10, or if there are that many previous extracting

-    left brackets, then it is a back reference. Otherwise, up to three octal

-    digits are read to form an escaped byte. Thus \123 is likely to be octal

-    123 (cf \0123, which is octal 012 followed by the literal 3). If the octal

-    value is greater than 377, the least significant 8 bits are taken. Inside a

-    character class, \ followed by a digit is always an octal number. */

-

-    case '1': case '2': case '3': case '4': case '5':

-    case '6': case '7': case '8': case '9':

-

-    if (!isclass)

-      {

-      oldptr = ptr;

-      c -= '0';

-      while ((digitab[ptr[1]] & ctype_digit) != 0)

-        c = c * 10 + *(++ptr) - '0';

-      if (c < 10 || c <= bracount)

-        {

-        c = -(ESC_REF + c);

-        break;

-        }

-      ptr = oldptr;      /* Put the pointer back and fall through */

-      }

-

-    /* Handle an octal number following \. If the first digit is 8 or 9, Perl

-    generates a binary zero byte and treats the digit as a following literal.

-    Thus we have to pull back the pointer by one. */

-

-    if ((c = *ptr) >= '8')

-      {

-      ptr--;

-      c = 0;

-      break;

-      }

-

-    /* \0 always starts an octal number, but we may drop through to here with a

-    larger first octal digit. */

-

-    case '0':

-    c -= '0';

-    while(i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7')

-        c = c * 8 + *(++ptr) - '0';

-    c &= 255;     /* Take least significant 8 bits */

-    break;

-

-    /* \x is complicated when UTF-8 is enabled. \x{ddd} is a character number

-    which can be greater than 0xff, but only if the ddd are hex digits. */

-

-    case 'x':

-#ifdef SUPPORT_UTF8

-    if (ptr[1] == '{' && (options & PCRE_UTF8) != 0)

-      {

-      const uschar *pt = ptr + 2;

-      register int count = 0;

-      c = 0;

-      while ((digitab[*pt] & ctype_xdigit) != 0)

-        {

-        int cc = *pt++;

-        count++;

-#if !EBCDIC    /* ASCII coding */

-        if (cc >= 'a') cc -= 32;               /* Convert to upper case */

-        c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));

-#else          /* EBCDIC coding */

-        if (cc >= 'a' && cc <= 'z') cc += 64;  /* Convert to upper case */

-        c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));

-#endif

-        }

-      if (*pt == '}')

-        {

-        if (c < 0 || count > 8) *errorcodeptr = ERR34;

-        ptr = pt;

-        break;

-        }

-      /* If the sequence of hex digits does not end with '}', then we don't

-      recognize this construct; fall through to the normal \x handling. */

-      }

-#endif

-

-    /* Read just a single hex char */

-

-    c = 0;

-    while (i++ < 2 && (digitab[ptr[1]] & ctype_xdigit) != 0)

-      {

-      int cc;                               /* Some compilers don't like ++ */

-      cc = *(++ptr);                        /* in initializers */

-#if !EBCDIC    /* ASCII coding */

-      if (cc >= 'a') cc -= 32;              /* Convert to upper case */

-      c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));

-#else          /* EBCDIC coding */

-      if (cc <= 'z') cc += 64;              /* Convert to upper case */

-      c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));

-#endif

-      }

-    break;

-

-    /* Other special escapes not starting with a digit are straightforward */

-

-    case 'c':

-    c = *(++ptr);

-    if (c == 0)

-      {

-      *errorcodeptr = ERR2;

-      return 0;

-      }

-

-    /* A letter is upper-cased; then the 0x40 bit is flipped. This coding

-    is ASCII-specific, but then the whole concept of \cx is ASCII-specific.

-    (However, an EBCDIC equivalent has now been added.) */

-

-#if !EBCDIC    /* ASCII coding */

-    if (c >= 'a' && c <= 'z') c -= 32;

-    c ^= 0x40;

-#else          /* EBCDIC coding */

-    if (c >= 'a' && c <= 'z') c += 64;

-    c ^= 0xC0;

-#endif

-    break;

-

-    /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any

-    other alphameric following \ is an error if PCRE_EXTRA was set; otherwise,

-    for Perl compatibility, it is a literal. This code looks a bit odd, but

-    there used to be some cases other than the default, and there may be again

-    in future, so I haven't "optimized" it. */

-

-    default:

-    if ((options & PCRE_EXTRA) != 0) switch(c)

-      {

-      default:

-      *errorcodeptr = ERR3;

-      break;

-      }

-    break;

-    }

-  }

-

-*ptrptr = ptr;

-return c;

-}

-

-

-

-#ifdef SUPPORT_UCP

-/*************************************************

-*               Handle \P and \p                 *

-*************************************************/

-

-/* This function is called after \P or \p has been encountered, provided that

-PCRE is compiled with support for Unicode properties. On entry, ptrptr is

-pointing at the P or p. On exit, it is pointing at the final character of the

-escape sequence.

-

-Argument:

-  ptrptr         points to the pattern position pointer

-  negptr         points to a boolean that is set TRUE for negation else FALSE

-  errorcodeptr   points to the error code variable

-

-Returns:     value from ucp_type_table, or -1 for an invalid type

-*/

-

-static int

-get_ucp(const uschar **ptrptr, BOOL *negptr, int *errorcodeptr)

-{

-int c, i, bot, top;

-const uschar *ptr = *ptrptr;

-char name[4];

-

-c = *(++ptr);

-if (c == 0) goto ERROR_RETURN;

-

-*negptr = FALSE;

-

-/* \P or \p can be followed by a one- or two-character name in {}, optionally

-preceded by ^ for negation. */

-

-if (c == '{')

-  {

-  if (ptr[1] == '^')

-    {

-    *negptr = TRUE;

-    ptr++;

-    }

-  for (i = 0; i <= 2; i++)

-    {

-    c = *(++ptr);

-    if (c == 0) goto ERROR_RETURN;

-    if (c == '}') break;

-    name[i] = c;

-    }

-  if (c !='}')   /* Try to distinguish error cases */

-    {

-    while (*(++ptr) != 0 && *ptr != '}');

-    if (*ptr == '}') goto UNKNOWN_RETURN; else goto ERROR_RETURN;

-    }

-  name[i] = 0;

-  }

-

-/* Otherwise there is just one following character */

-

-else

-  {

-  name[0] = c;

-  name[1] = 0;

-  }

-

-*ptrptr = ptr;

-

-/* Search for a recognized property name using binary chop */

-

-bot = 0;

-top = _pcre_utt_size;

-

-while (bot < top)

-  {

-  i = (bot + top)/2;

-  c = strcmp(name, _pcre_utt[i].name);

-  if (c == 0) return _pcre_utt[i].value;

-  if (c > 0) bot = i + 1; else top = i;

-  }

-

-UNKNOWN_RETURN:

-*errorcodeptr = ERR47;

-*ptrptr = ptr;

-return -1;

-

-ERROR_RETURN:

-*errorcodeptr = ERR46;

-*ptrptr = ptr;

-return -1;

-}

-#endif

-

-

-

-

-/*************************************************

-*            Check for counted repeat            *

-*************************************************/

-

-/* This function is called when a '{' is encountered in a place where it might

-start a quantifier. It looks ahead to see if it really is a quantifier or not.

-It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}

-where the ddds are digits.

-

-Arguments:

-  p         pointer to the first char after '{'

-

-Returns:    TRUE or FALSE

-*/

-

-static BOOL

-is_counted_repeat(const uschar *p)

-{

-if ((digitab[*p++] & ctype_digit) == 0) return FALSE;

-while ((digitab[*p] & ctype_digit) != 0) p++;

-if (*p == '}') return TRUE;

-

-if (*p++ != ',') return FALSE;

-if (*p == '}') return TRUE;

-

-if ((digitab[*p++] & ctype_digit) == 0) return FALSE;

-while ((digitab[*p] & ctype_digit) != 0) p++;

-

-return (*p == '}');

-}

-

-

-

-/*************************************************

-*         Read repeat counts                     *

-*************************************************/

-

-/* Read an item of the form {n,m} and return the values. This is called only

-after is_counted_repeat() has confirmed that a repeat-count quantifier exists,

-so the syntax is guaranteed to be correct, but we need to check the values.

-

-Arguments:

-  p              pointer to first char after '{'

-  minp           pointer to int for min

-  maxp           pointer to int for max

-                 returned as -1 if no max

-  errorcodeptr   points to error code variable

-

-Returns:         pointer to '}' on success;

-                 current ptr on error, with errorcodeptr set non-zero

-*/

-

-static const uschar *

-read_repeat_counts(const uschar *p, int *minp, int *maxp, int *errorcodeptr)

-{

-int min = 0;

-int max = -1;

-

-/* Read the minimum value and do a paranoid check: a negative value indicates

-an integer overflow. */

-

-while ((digitab[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';

-if (min < 0 || min > 65535)

-  {

-  *errorcodeptr = ERR5;

-  return p;

-  }

-

-/* Read the maximum value if there is one, and again do a paranoid on its size.

-Also, max must not be less than min. */

-

-if (*p == '}') max = min; else

-  {

-  if (*(++p) != '}')

-    {

-    max = 0;

-    while((digitab[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';

-    if (max < 0 || max > 65535)

-      {

-      *errorcodeptr = ERR5;

-      return p;

-      }

-    if (max < min)

-      {

-      *errorcodeptr = ERR4;

-      return p;

-      }

-    }

-  }

-

-/* Fill in the required variables, and pass back the pointer to the terminating

-'}'. */

-

-*minp = min;

-*maxp = max;

-return p;

-}

-

-

-

-/*************************************************

-*      Find first significant op code            *

-*************************************************/

-

-/* This is called by several functions that scan a compiled expression looking

-for a fixed first character, or an anchoring op code etc. It skips over things

-that do not influence this. For some calls, a change of option is important.

-For some calls, it makes sense to skip negative forward and all backward

-assertions, and also the \b assertion; for others it does not.

-

-Arguments:

-  code         pointer to the start of the group

-  options      pointer to external options

-  optbit       the option bit whose changing is significant, or

-                 zero if none are

-  skipassert   TRUE if certain assertions are to be skipped

-

-Returns:       pointer to the first significant opcode

-*/

-

-static const uschar*

-first_significant_code(const uschar *code, int *options, int optbit,

-  BOOL skipassert)

-{

-for (;;)

-  {

-  switch ((int)*code)

-    {

-    case OP_OPT:

-    if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))

-      *options = (int)code[1];

-    code += 2;

-    break;

-

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    if (!skipassert) return code;

-    do code += GET(code, 1); while (*code == OP_ALT);

-    code += _pcre_OP_lengths[*code];

-    break;

-

-    case OP_WORD_BOUNDARY:

-    case OP_NOT_WORD_BOUNDARY:

-    if (!skipassert) return code;

-    /* Fall through */

-

-    case OP_CALLOUT:

-    case OP_CREF:

-    case OP_BRANUMBER:

-    code += _pcre_OP_lengths[*code];

-    break;

-

-    default:

-    return code;

-    }

-  }

-/* Control never reaches here */

-}

-

-

-

-

-/*************************************************

-*        Find the fixed length of a pattern      *

-*************************************************/

-

-/* Scan a pattern and compute the fixed length of subject that will match it,

-if the length is fixed. This is needed for dealing with backward assertions.

-In UTF8 mode, the result is in characters rather than bytes.

-

-Arguments:

-  code     points to the start of the pattern (the bracket)

-  options  the compiling options

-

-Returns:   the fixed length, or -1 if there is no fixed length,

-             or -2 if \C was encountered

-*/

-

-static int

-find_fixedlength(uschar *code, int options)

-{

-int length = -1;

-

-register int branchlength = 0;

-register uschar *cc = code + 1 + LINK_SIZE;

-

-/* Scan along the opcodes for this branch. If we get to the end of the

-branch, check the length against that of the other branches. */

-

-for (;;)

-  {

-  int d;

-  register int op = *cc;

-  if (op >= OP_BRA) op = OP_BRA;

-

-  switch (op)

-    {

-    case OP_BRA:

-    case OP_ONCE:

-    case OP_COND:

-    d = find_fixedlength(cc, options);

-    if (d < 0) return d;

-    branchlength += d;

-    do cc += GET(cc, 1); while (*cc == OP_ALT);

-    cc += 1 + LINK_SIZE;

-    break;

-

-    /* Reached end of a branch; if it's a ket it is the end of a nested

-    call. If it's ALT it is an alternation in a nested call. If it is

-    END it's the end of the outer call. All can be handled by the same code. */

-

-    case OP_ALT:

-    case OP_KET:

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_END:

-    if (length < 0) length = branchlength;

-      else if (length != branchlength) return -1;

-    if (*cc != OP_ALT) return length;

-    cc += 1 + LINK_SIZE;

-    branchlength = 0;

-    break;

-

-    /* Skip over assertive subpatterns */

-

-    case OP_ASSERT:

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    do cc += GET(cc, 1); while (*cc == OP_ALT);

-    /* Fall through */

-

-    /* Skip over things that don't match chars */

-

-    case OP_REVERSE:

-    case OP_BRANUMBER:

-    case OP_CREF:

-    case OP_OPT:

-    case OP_CALLOUT:

-    case OP_SOD:

-    case OP_SOM:

-    case OP_EOD:

-    case OP_EODN:

-    case OP_CIRC:

-    case OP_DOLL:

-    case OP_NOT_WORD_BOUNDARY:

-    case OP_WORD_BOUNDARY:

-    cc += _pcre_OP_lengths[*cc];

-    break;

-

-    /* Handle literal characters */

-

-    case OP_CHAR:

-    case OP_CHARNC:

-    branchlength++;

-    cc += 2;

-#ifdef SUPPORT_UTF8

-    if ((options & PCRE_UTF8) != 0)

-      {

-      while ((*cc & 0xc0) == 0x80) cc++;

-      }

-#endif

-    break;

-

-    /* Handle exact repetitions. The count is already in characters, but we

-    need to skip over a multibyte character in UTF8 mode.  */

-

-    case OP_EXACT:

-    branchlength += GET2(cc,1);

-    cc += 4;

-#ifdef SUPPORT_UTF8

-    if ((options & PCRE_UTF8) != 0)

-      {

-      while((*cc & 0x80) == 0x80) cc++;

-      }

-#endif

-    break;

-

-    case OP_TYPEEXACT:

-    branchlength += GET2(cc,1);

-    cc += 4;

-    break;

-

-    /* Handle single-char matchers */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    cc++;

-    /* Fall through */

-

-    case OP_NOT_DIGIT:

-    case OP_DIGIT:

-    case OP_NOT_WHITESPACE:

-    case OP_WHITESPACE:

-    case OP_NOT_WORDCHAR:

-    case OP_WORDCHAR:

-    case OP_ANY:

-    branchlength++;

-    cc++;

-    break;

-

-    /* The single-byte matcher isn't allowed */

-

-    case OP_ANYBYTE:

-    return -2;

-

-    /* Check a class for variable quantification */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-    cc += GET(cc, 1) - 33;

-    /* Fall through */

-#endif

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    cc += 33;

-

-    switch (*cc)

-      {

-      case OP_CRSTAR:

-      case OP_CRMINSTAR:

-      case OP_CRQUERY:

-      case OP_CRMINQUERY:

-      return -1;

-

-      case OP_CRRANGE:

-      case OP_CRMINRANGE:

-      if (GET2(cc,1) != GET2(cc,3)) return -1;

-      branchlength += GET2(cc,1);

-      cc += 5;

-      break;

-

-      default:

-      branchlength++;

-      }

-    break;

-

-    /* Anything else is variable length */

-

-    default:

-    return -1;

-    }

-  }

-/* Control never gets here */

-}

-

-

-

-

-/*************************************************

-*    Scan compiled regex for numbered bracket    *

-*************************************************/

-

-/* This little function scans through a compiled pattern until it finds a

-capturing bracket with the given number.

-

-Arguments:

-  code        points to start of expression

-  utf8        TRUE in UTF-8 mode

-  number      the required bracket number

-

-Returns:      pointer to the opcode for the bracket, or NULL if not found

-*/

-

-static const uschar *

-find_bracket(const uschar *code, BOOL utf8, int number)

-{

-#ifndef SUPPORT_UTF8

-utf8 = utf8;               /* Stop pedantic compilers complaining */

-#endif

-

-for (;;)

-  {

-  register int c = *code;

-  if (c == OP_END) return NULL;

-  else if (c > OP_BRA)

-    {

-    int n = c - OP_BRA;

-    if (n > EXTRACT_BASIC_MAX) n = GET2(code, 2+LINK_SIZE);

-    if (n == number) return (uschar *)code;

-    code += _pcre_OP_lengths[OP_BRA];

-    }

-  else

-    {

-    code += _pcre_OP_lengths[c];

-

-#ifdef SUPPORT_UTF8

-

-    /* In UTF-8 mode, opcodes that are followed by a character may be followed

-    by a multi-byte character. The length in the table is a minimum, so we have

-    to scan along to skip the extra bytes. All opcodes are less than 128, so we

-    can use relatively efficient code. */

-

-    if (utf8) switch(c)

-      {

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      while ((*code & 0xc0) == 0x80) code++;

-      break;

-

-      /* XCLASS is used for classes that cannot be represented just by a bit

-      map. This includes negated single high-valued characters. The length in

-      the table is zero; the actual length is stored in the compiled code. */

-

-      case OP_XCLASS:

-      code += GET(code, 1) + 1;

-      break;

-      }

-#endif

-    }

-  }

-}

-

-

-

-/*************************************************

-*   Scan compiled regex for recursion reference  *

-*************************************************/

-

-/* This little function scans through a compiled pattern until it finds an

-instance of OP_RECURSE.

-

-Arguments:

-  code        points to start of expression

-  utf8        TRUE in UTF-8 mode

-

-Returns:      pointer to the opcode for OP_RECURSE, or NULL if not found

-*/

-

-static const uschar *

-find_recurse(const uschar *code, BOOL utf8)

-{

-#ifndef SUPPORT_UTF8

-utf8 = utf8;               /* Stop pedantic compilers complaining */

-#endif

-

-for (;;)

-  {

-  register int c = *code;

-  if (c == OP_END) return NULL;

-  else if (c == OP_RECURSE) return code;

-  else if (c > OP_BRA)

-    {

-    code += _pcre_OP_lengths[OP_BRA];

-    }

-  else

-    {

-    code += _pcre_OP_lengths[c];

-

-#ifdef SUPPORT_UTF8

-

-    /* In UTF-8 mode, opcodes that are followed by a character may be followed

-    by a multi-byte character. The length in the table is a minimum, so we have

-    to scan along to skip the extra bytes. All opcodes are less than 128, so we

-    can use relatively efficient code. */

-

-    if (utf8) switch(c)

-      {

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      while ((*code & 0xc0) == 0x80) code++;

-      break;

-

-      /* XCLASS is used for classes that cannot be represented just by a bit

-      map. This includes negated single high-valued characters. The length in

-      the table is zero; the actual length is stored in the compiled code. */

-

-      case OP_XCLASS:

-      code += GET(code, 1) + 1;

-      break;

-      }

-#endif

-    }

-  }

-}

-

-

-

-/*************************************************

-*    Scan compiled branch for non-emptiness      *

-*************************************************/

-

-/* This function scans through a branch of a compiled pattern to see whether it

-can match the empty string or not. It is called only from could_be_empty()

-below. Note that first_significant_code() skips over assertions. If we hit an

-unclosed bracket, we return "empty" - this means we've struck an inner bracket

-whose current branch will already have been scanned.

-

-Arguments:

-  code        points to start of search

-  endcode     points to where to stop

-  utf8        TRUE if in UTF8 mode

-

-Returns:      TRUE if what is matched could be empty

-*/

-

-static BOOL

-could_be_empty_branch(const uschar *code, const uschar *endcode, BOOL utf8)

-{

-register int c;

-for (code = first_significant_code(code + 1 + LINK_SIZE, NULL, 0, TRUE);

-     code < endcode;

-     code = first_significant_code(code + _pcre_OP_lengths[c], NULL, 0, TRUE))

-  {

-  const uschar *ccode;

-

-  c = *code;

-

-  if (c >= OP_BRA)

-    {

-    BOOL empty_branch;

-    if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */

-

-    /* Scan a closed bracket */

-

-    empty_branch = FALSE;

-    do

-      {

-      if (!empty_branch && could_be_empty_branch(code, endcode, utf8))

-        empty_branch = TRUE;

-      code += GET(code, 1);

-      }

-    while (*code == OP_ALT);

-    if (!empty_branch) return FALSE;   /* All branches are non-empty */

-    code += 1 + LINK_SIZE;

-    c = *code;

-    }

-

-  else switch (c)

-    {

-    /* Check for quantifiers after a class */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-    ccode = code + GET(code, 1);

-    goto CHECK_CLASS_REPEAT;

-#endif

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    ccode = code + 33;

-

-#ifdef SUPPORT_UTF8

-    CHECK_CLASS_REPEAT:

-#endif

-

-    switch (*ccode)

-      {

-      case OP_CRSTAR:            /* These could be empty; continue */

-      case OP_CRMINSTAR:

-      case OP_CRQUERY:

-      case OP_CRMINQUERY:

-      break;

-

-      default:                   /* Non-repeat => class must match */

-      case OP_CRPLUS:            /* These repeats aren't empty */

-      case OP_CRMINPLUS:

-      return FALSE;

-

-      case OP_CRRANGE:

-      case OP_CRMINRANGE:

-      if (GET2(ccode, 1) > 0) return FALSE;  /* Minimum > 0 */

-      break;

-      }

-    break;

-

-    /* Opcodes that must match a character */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    case OP_EXTUNI:

-    case OP_NOT_DIGIT:

-    case OP_DIGIT:

-    case OP_NOT_WHITESPACE:

-    case OP_WHITESPACE:

-    case OP_NOT_WORDCHAR:

-    case OP_WORDCHAR:

-    case OP_ANY:

-    case OP_ANYBYTE:

-    case OP_CHAR:

-    case OP_CHARNC:

-    case OP_NOT:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_EXACT:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTEXACT:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEEXACT:

-    return FALSE;

-

-    /* End of branch */

-

-    case OP_KET:

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_ALT:

-    return TRUE;

-

-    /* In UTF-8 mode, STAR, MINSTAR, QUERY, MINQUERY, UPTO, and MINUPTO  may be

-    followed by a multibyte character */

-

-#ifdef SUPPORT_UTF8

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    case OP_UPTO:

-    case OP_MINUPTO:

-    if (utf8) while ((code[2] & 0xc0) == 0x80) code++;

-    break;

-#endif

-    }

-  }

-

-return TRUE;

-}

-

-

-

-/*************************************************

-*    Scan compiled regex for non-emptiness       *

-*************************************************/

-

-/* This function is called to check for left recursive calls. We want to check

-the current branch of the current pattern to see if it could match the empty

-string. If it could, we must look outwards for branches at other levels,

-stopping when we pass beyond the bracket which is the subject of the recursion.

-

-Arguments:

-  code        points to start of the recursion

-  endcode     points to where to stop (current RECURSE item)

-  bcptr       points to the chain of current (unclosed) branch starts

-  utf8        TRUE if in UTF-8 mode

-

-Returns:      TRUE if what is matched could be empty

-*/

-

-static BOOL

-could_be_empty(const uschar *code, const uschar *endcode, branch_chain *bcptr,

-  BOOL utf8)

-{

-while (bcptr != NULL && bcptr->current >= code)

-  {

-  if (!could_be_empty_branch(bcptr->current, endcode, utf8)) return FALSE;

-  bcptr = bcptr->outer;

-  }

-return TRUE;

-}

-

-

-

-/*************************************************

-*           Check for POSIX class syntax         *

-*************************************************/

-

-/* This function is called when the sequence "[:" or "[." or "[=" is

-encountered in a character class. It checks whether this is followed by an

-optional ^ and then a sequence of letters, terminated by a matching ":]" or

-".]" or "=]".

-

-Argument:

-  ptr      pointer to the initial [

-  endptr   where to return the end pointer

-  cd       pointer to compile data

-

-Returns:   TRUE or FALSE

-*/

-

-static BOOL

-check_posix_syntax(const uschar *ptr, const uschar **endptr, compile_data *cd)

-{

-int terminator;          /* Don't combine these lines; the Solaris cc */

-terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */

-if (*(++ptr) == '^') ptr++;

-while ((cd->ctypes[*ptr] & ctype_letter) != 0) ptr++;

-if (*ptr == terminator && ptr[1] == ']')

-  {

-  *endptr = ptr;

-  return TRUE;

-  }

-return FALSE;

-}

-

-

-

-

-/*************************************************

-*          Check POSIX class name                *

-*************************************************/

-

-/* This function is called to check the name given in a POSIX-style class entry

-such as [:alnum:].

-

-Arguments:

-  ptr        points to the first letter

-  len        the length of the name

-

-Returns:     a value representing the name, or -1 if unknown

-*/

-

-static int

-check_posix_name(const uschar *ptr, int len)

-{

-register int yield = 0;

-while (posix_name_lengths[yield] != 0)

-  {

-  if (len == posix_name_lengths[yield] &&

-    strncmp((const char *)ptr, posix_names[yield], len) == 0) return yield;

-  yield++;

-  }

-return -1;

-}

-

-

-/*************************************************

-*    Adjust OP_RECURSE items in repeated group   *

-*************************************************/

-

-/* OP_RECURSE items contain an offset from the start of the regex to the group

-that is referenced. This means that groups can be replicated for fixed

-repetition simply by copying (because the recursion is allowed to refer to

-earlier groups that are outside the current group). However, when a group is

-optional (i.e. the minimum quantifier is zero), OP_BRAZERO is inserted before

-it, after it has been compiled. This means that any OP_RECURSE items within it

-that refer to the group itself or any contained groups have to have their

-offsets adjusted. That is the job of this function. Before it is called, the

-partially compiled regex must be temporarily terminated with OP_END.

-

-Arguments:

-  group      points to the start of the group

-  adjust     the amount by which the group is to be moved

-  utf8       TRUE in UTF-8 mode

-  cd         contains pointers to tables etc.

-

-Returns:     nothing

-*/

-

-static void

-adjust_recurse(uschar *group, int adjust, BOOL utf8, compile_data *cd)

-{

-uschar *ptr = group;

-while ((ptr = (uschar *)find_recurse(ptr, utf8)) != NULL)

-  {

-  int offset = GET(ptr, 1);

-  if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);

-  ptr += 1 + LINK_SIZE;

-  }

-}

-

-

-

-/*************************************************

-*        Insert an automatic callout point       *

-*************************************************/

-

-/* This function is called when the PCRE_AUTO_CALLOUT option is set, to insert

-callout points before each pattern item.

-

-Arguments:

-  code           current code pointer

-  ptr            current pattern pointer

-  cd             pointers to tables etc

-

-Returns:         new code pointer

-*/

-

-static uschar *

-auto_callout(uschar *code, const uschar *ptr, compile_data *cd)

-{

-*code++ = OP_CALLOUT;

-*code++ = 255;

-PUT(code, 0, ptr - cd->start_pattern);  /* Pattern offset */

-PUT(code, LINK_SIZE, 0);                /* Default length */

-return code + 2*LINK_SIZE;

-}

-

-

-

-/*************************************************

-*         Complete a callout item                *

-*************************************************/

-

-/* A callout item contains the length of the next item in the pattern, which

-we can't fill in till after we have reached the relevant point. This is used

-for both automatic and manual callouts.

-

-Arguments:

-  previous_callout   points to previous callout item

-  ptr                current pattern pointer

-  cd                 pointers to tables etc

-

-Returns:             nothing

-*/

-

-static void

-complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd)

-{

-int length = ptr - cd->start_pattern - GET(previous_callout, 2);

-PUT(previous_callout, 2 + LINK_SIZE, length);

-}

-

-

-

-#ifdef SUPPORT_UCP

-/*************************************************

-*           Get othercase range                  *

-*************************************************/

-

-/* This function is passed the start and end of a class range, in UTF-8 mode

-with UCP support. It searches up the characters, looking for internal ranges of

-characters in the "other" case. Each call returns the next one, updating the

-start address.

-

-Arguments:

-  cptr        points to starting character value; updated

-  d           end value

-  ocptr       where to put start of othercase range

-  odptr       where to put end of othercase range

-

-Yield:        TRUE when range returned; FALSE when no more

-*/

-

-static BOOL

-get_othercase_range(int *cptr, int d, int *ocptr, int *odptr)

-{

-int c, chartype, othercase, next;

-

-for (c = *cptr; c <= d; c++)

-  {

-  if (_pcre_ucp_findchar(c, &chartype, &othercase) == ucp_L && othercase != 0)

-    break;

-  }

-

-if (c > d) return FALSE;

-

-*ocptr = othercase;

-next = othercase + 1;

-

-for (++c; c <= d; c++)

-  {

-  if (_pcre_ucp_findchar(c, &chartype, &othercase) != ucp_L ||

-        othercase != next)

-    break;

-  next++;

-  }

-

-*odptr = next - 1;

-*cptr = c;

-

-return TRUE;

-}

-#endif  /* SUPPORT_UCP */

-

-

-/*************************************************

-*           Compile one branch                   *

-*************************************************/

-

-/* Scan the pattern, compiling it into the code vector. If the options are

-changed during the branch, the pointer is used to change the external options

-bits.

-

-Arguments:

-  optionsptr     pointer to the option bits

-  brackets       points to number of extracting brackets used

-  codeptr        points to the pointer to the current code point

-  ptrptr         points to the current pattern pointer

-  errorcodeptr   points to error code variable

-  firstbyteptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)

-  reqbyteptr     set to the last literal character required, else < 0

-  bcptr          points to current branch chain

-  cd             contains pointers to tables etc.

-

-Returns:         TRUE on success

-                 FALSE, with *errorcodeptr set non-zero on error

-*/

-

-static BOOL

-compile_branch(int *optionsptr, int *brackets, uschar **codeptr,

-  const uschar **ptrptr, int *errorcodeptr, int *firstbyteptr,

-  int *reqbyteptr, branch_chain *bcptr, compile_data *cd)

-{

-int repeat_type, op_type;

-int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */

-int bravalue = 0;

-int greedy_default, greedy_non_default;

-int firstbyte, reqbyte;

-int zeroreqbyte, zerofirstbyte;

-int req_caseopt, reqvary, tempreqvary;

-int condcount = 0;

-int options = *optionsptr;

-int after_manual_callout = 0;

-register int c;

-register uschar *code = *codeptr;

-uschar *tempcode;

-BOOL inescq = FALSE;

-BOOL groupsetfirstbyte = FALSE;

-const uschar *ptr = *ptrptr;

-const uschar *tempptr;

-uschar *previous = NULL;

-uschar *previous_callout = NULL;

-uschar classbits[32];

-

-#ifdef SUPPORT_UTF8

-BOOL class_utf8;

-BOOL utf8 = (options & PCRE_UTF8) != 0;

-uschar *class_utf8data;

-uschar utf8_char[6];

-#else

-BOOL utf8 = FALSE;

-#endif

-

-/* Set up the default and non-default settings for greediness */

-

-greedy_default = ((options & PCRE_UNGREEDY) != 0);

-greedy_non_default = greedy_default ^ 1;

-

-/* Initialize no first byte, no required byte. REQ_UNSET means "no char

-matching encountered yet". It gets changed to REQ_NONE if we hit something that

-matches a non-fixed char first char; reqbyte just remains unset if we never

-find one.

-

-When we hit a repeat whose minimum is zero, we may have to adjust these values

-to take the zero repeat into account. This is implemented by setting them to

-zerofirstbyte and zeroreqbyte when such a repeat is encountered. The individual

-item types that can be repeated set these backoff variables appropriately. */

-

-firstbyte = reqbyte = zerofirstbyte = zeroreqbyte = REQ_UNSET;

-

-/* The variable req_caseopt contains either the REQ_CASELESS value or zero,

-according to the current setting of the caseless flag. REQ_CASELESS is a bit

-value > 255. It is added into the firstbyte or reqbyte variables to record the

-case status of the value. This is used only for ASCII characters. */

-

-req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;

-

-/* Switch on next character until the end of the branch */

-

-for (;; ptr++)

-  {

-  BOOL negate_class;

-  BOOL possessive_quantifier;

-  BOOL is_quantifier;

-  int class_charcount;

-  int class_lastchar;

-  int newoptions;

-  int recno;

-  int skipbytes;

-  int subreqbyte;

-  int subfirstbyte;

-  int mclength;

-  uschar mcbuffer[8];

-

-  /* Next byte in the pattern */

-

-  c = *ptr;

-

-  /* If in \Q...\E, check for the end; if not, we have a literal */

-

-  if (inescq && c != 0)

-    {

-    if (c == '\\' && ptr[1] == 'E')

-      {

-      inescq = FALSE;

-      ptr++;

-      continue;

-      }

-    else

-      {

-      if (previous_callout != NULL)

-        {

-        complete_callout(previous_callout, ptr, cd);

-        previous_callout = NULL;

-        }

-      if ((options & PCRE_AUTO_CALLOUT) != 0)

-        {

-        previous_callout = code;

-        code = auto_callout(code, ptr, cd);

-        }

-      goto NORMAL_CHAR;

-      }

-    }

-

-  /* Fill in length of a previous callout, except when the next thing is

-  a quantifier. */

-

-  is_quantifier = c == '*' || c == '+' || c == '?' ||

-    (c == '{' && is_counted_repeat(ptr+1));

-

-  if (!is_quantifier && previous_callout != NULL &&

-       after_manual_callout-- <= 0)

-    {

-    complete_callout(previous_callout, ptr, cd);

-    previous_callout = NULL;

-    }

-

-  /* In extended mode, skip white space and comments */

-

-  if ((options & PCRE_EXTENDED) != 0)

-    {

-    if ((cd->ctypes[c] & ctype_space) != 0) continue;

-    if (c == '#')

-      {

-      /* The space before the ; is to avoid a warning on a silly compiler

-      on the Macintosh. */

-      while ((c = *(++ptr)) != 0 && c != NEWLINE) ;

-      if (c != 0) continue;   /* Else fall through to handle end of string */

-      }

-    }

-

-  /* No auto callout for quantifiers. */

-

-  if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier)

-    {

-    previous_callout = code;

-    code = auto_callout(code, ptr, cd);

-    }

-

-  switch(c)

-    {

-    /* The branch terminates at end of string, |, or ). */

-

-    case 0:

-    case '|':

-    case ')':

-    *firstbyteptr = firstbyte;

-    *reqbyteptr = reqbyte;

-    *codeptr = code;

-    *ptrptr = ptr;

-    return TRUE;

-

-    /* Handle single-character metacharacters. In multiline mode, ^ disables

-    the setting of any following char as a first character. */

-

-    case '^':

-    if ((options & PCRE_MULTILINE) != 0)

-      {

-      if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-      }

-    previous = NULL;

-    *code++ = OP_CIRC;

-    break;

-

-    case '$':

-    previous = NULL;

-    *code++ = OP_DOLL;

-    break;

-

-    /* There can never be a first char if '.' is first, whatever happens about

-    repeats. The value of reqbyte doesn't change either. */

-

-    case '.':

-    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-    zerofirstbyte = firstbyte;

-    zeroreqbyte = reqbyte;

-    previous = code;

-    *code++ = OP_ANY;

-    break;

-

-    /* Character classes. If the included characters are all < 255 in value, we

-    build a 32-byte bitmap of the permitted characters, except in the special

-    case where there is only one such character. For negated classes, we build

-    the map as usual, then invert it at the end. However, we use a different

-    opcode so that data characters > 255 can be handled correctly.

-

-    If the class contains characters outside the 0-255 range, a different

-    opcode is compiled. It may optionally have a bit map for characters < 256,

-    but those above are are explicitly listed afterwards. A flag byte tells

-    whether the bitmap is present, and whether this is a negated class or not.

-    */

-

-    case '[':

-    previous = code;

-

-    /* PCRE supports POSIX class stuff inside a class. Perl gives an error if

-    they are encountered at the top level, so we'll do that too. */

-

-    if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&

-        check_posix_syntax(ptr, &tempptr, cd))

-      {

-      *errorcodeptr = (ptr[1] == ':')? ERR13 : ERR31;

-      goto FAILED;

-      }

-

-    /* If the first character is '^', set the negation flag and skip it. */

-

-    if ((c = *(++ptr)) == '^')

-      {

-      negate_class = TRUE;

-      c = *(++ptr);

-      }

-    else

-      {

-      negate_class = FALSE;

-      }

-

-    /* Keep a count of chars with values < 256 so that we can optimize the case

-    of just a single character (as long as it's < 256). For higher valued UTF-8

-    characters, we don't yet do any optimization. */

-

-    class_charcount = 0;

-    class_lastchar = -1;

-

-#ifdef SUPPORT_UTF8

-    class_utf8 = FALSE;                       /* No chars >= 256 */

-    class_utf8data = code + LINK_SIZE + 34;   /* For UTF-8 items */

-#endif

-

-    /* Initialize the 32-char bit map to all zeros. We have to build the

-    map in a temporary bit of store, in case the class contains only 1

-    character (< 256), because in that case the compiled code doesn't use the

-    bit map. */

-

-    memset(classbits, 0, 32 * sizeof(uschar));

-

-    /* Process characters until ] is reached. By writing this as a "do" it

-    means that an initial ] is taken as a data character. The first pass

-    through the regex checked the overall syntax, so we don't need to be very

-    strict here. At the start of the loop, c contains the first byte of the

-    character. */

-

-    do

-      {

-#ifdef SUPPORT_UTF8

-      if (utf8 && c > 127)

-        {                           /* Braces are required because the */

-        GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */

-        }

-#endif

-

-      /* Inside \Q...\E everything is literal except \E */

-

-      if (inescq)

-        {

-        if (c == '\\' && ptr[1] == 'E')

-          {

-          inescq = FALSE;

-          ptr++;

-          continue;

-          }

-        else goto LONE_SINGLE_CHARACTER;

-        }

-

-      /* Handle POSIX class names. Perl allows a negation extension of the

-      form [:^name:]. A square bracket that doesn't match the syntax is

-      treated as a literal. We also recognize the POSIX constructions

-      [.ch.] and [=ch=] ("collating elements") and fault them, as Perl

-      5.6 and 5.8 do. */

-

-      if (c == '[' &&

-          (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&

-          check_posix_syntax(ptr, &tempptr, cd))

-        {

-        BOOL local_negate = FALSE;

-        int posix_class, i;

-        register const uschar *cbits = cd->cbits;

-

-        if (ptr[1] != ':')

-          {

-          *errorcodeptr = ERR31;

-          goto FAILED;

-          }

-

-        ptr += 2;

-        if (*ptr == '^')

-          {

-          local_negate = TRUE;

-          ptr++;

-          }

-

-        posix_class = check_posix_name(ptr, tempptr - ptr);

-        if (posix_class < 0)

-          {

-          *errorcodeptr = ERR30;

-          goto FAILED;

-          }

-

-        /* If matching is caseless, upper and lower are converted to

-        alpha. This relies on the fact that the class table starts with

-        alpha, lower, upper as the first 3 entries. */

-

-        if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)

-          posix_class = 0;

-

-        /* Or into the map we are building up to 3 of the static class

-        tables, or their negations. The [:blank:] class sets up the same

-        chars as the [:space:] class (all white space). We remove the vertical

-        white space chars afterwards. */

-

-        posix_class *= 3;

-        for (i = 0; i < 3; i++)

-          {

-          BOOL blankclass = strncmp((char *)ptr, "blank", 5) == 0;

-          int taboffset = posix_class_maps[posix_class + i];

-          if (taboffset < 0) break;

-          if (local_negate)

-            {

-            if (i == 0)

-              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+taboffset];

-            else

-              for (c = 0; c < 32; c++) classbits[c] &= ~cbits[c+taboffset];

-            if (blankclass) classbits[1] |= 0x3c;

-            }

-          else

-            {

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+taboffset];

-            if (blankclass) classbits[1] &= ~0x3c;

-            }

-          }

-

-        ptr = tempptr + 1;

-        class_charcount = 10;  /* Set > 1; assumes more than 1 per class */

-        continue;    /* End of POSIX syntax handling */

-        }

-

-      /* Backslash may introduce a single character, or it may introduce one

-      of the specials, which just set a flag. Escaped items are checked for

-      validity in the pre-compiling pass. The sequence \b is a special case.

-      Inside a class (and only there) it is treated as backspace. Elsewhere

-      it marks a word boundary. Other escapes have preset maps ready to

-      or into the one we are building. We assume they have more than one

-      character in them, so set class_charcount bigger than one. */

-

-      if (c == '\\')

-        {

-        c = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);

-

-        if (-c == ESC_b) c = '\b';       /* \b is backslash in a class */

-        else if (-c == ESC_X) c = 'X';   /* \X is literal X in a class */

-        else if (-c == ESC_Q)            /* Handle start of quoted string */

-          {

-          if (ptr[1] == '\\' && ptr[2] == 'E')

-            {

-            ptr += 2; /* avoid empty string */

-            }

-          else inescq = TRUE;

-          continue;

-          }

-

-        if (c < 0)

-          {

-          register const uschar *cbits = cd->cbits;

-          class_charcount += 2;     /* Greater than 1 is what matters */

-          switch (-c)

-            {

-            case ESC_d:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit];

-            continue;

-

-            case ESC_D:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_digit];

-            continue;

-

-            case ESC_w:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_word];

-            continue;

-

-            case ESC_W:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];

-            continue;

-

-            case ESC_s:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_space];

-            classbits[1] &= ~0x08;   /* Perl 5.004 onwards omits VT from \s */

-            continue;

-

-            case ESC_S:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];

-            classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */

-            continue;

-

-#ifdef SUPPORT_UCP

-            case ESC_p:

-            case ESC_P:

-              {

-              BOOL negated;

-              int property = get_ucp(&ptr, &negated, errorcodeptr);

-              if (property < 0) goto FAILED;

-              class_utf8 = TRUE;

-              *class_utf8data++ = ((-c == ESC_p) != negated)?

-                XCL_PROP : XCL_NOTPROP;

-              *class_utf8data++ = property;

-              class_charcount -= 2;   /* Not a < 256 character */

-              }

-            continue;

-#endif

-

-            /* Unrecognized escapes are faulted if PCRE is running in its

-            strict mode. By default, for compatibility with Perl, they are

-            treated as literals. */

-

-            default:

-            if ((options & PCRE_EXTRA) != 0)

-              {

-              *errorcodeptr = ERR7;

-              goto FAILED;

-              }

-            c = *ptr;              /* The final character */

-            class_charcount -= 2;  /* Undo the default count from above */

-            }

-          }

-

-        /* Fall through if we have a single character (c >= 0). This may be

-        > 256 in UTF-8 mode. */

-

-        }   /* End of backslash handling */

-

-      /* A single character may be followed by '-' to form a range. However,

-      Perl does not permit ']' to be the end of the range. A '-' character

-      here is treated as a literal. */

-

-      if (ptr[1] == '-' && ptr[2] != ']')

-        {

-        int d;

-        ptr += 2;

-

-#ifdef SUPPORT_UTF8

-        if (utf8)

-          {                           /* Braces are required because the */

-          GETCHARLEN(d, ptr, ptr);    /* macro generates multiple statements */

-          }

-        else

-#endif

-        d = *ptr;  /* Not UTF-8 mode */

-

-        /* The second part of a range can be a single-character escape, but

-        not any of the other escapes. Perl 5.6 treats a hyphen as a literal

-        in such circumstances. */

-

-        if (d == '\\')

-          {

-          const uschar *oldptr = ptr;

-          d = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);

-

-          /* \b is backslash; \X is literal X; any other special means the '-'

-          was literal */

-

-          if (d < 0)

-            {

-            if (d == -ESC_b) d = '\b';

-            else if (d == -ESC_X) d = 'X'; else

-              {

-              ptr = oldptr - 2;

-              goto LONE_SINGLE_CHARACTER;  /* A few lines below */

-              }

-            }

-          }

-

-        /* The check that the two values are in the correct order happens in

-        the pre-pass. Optimize one-character ranges */

-

-        if (d == c) goto LONE_SINGLE_CHARACTER;  /* A few lines below */

-

-        /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless

-        matching, we have to use an XCLASS with extra data items. Caseless

-        matching for characters > 127 is available only if UCP support is

-        available. */

-

-#ifdef SUPPORT_UTF8

-        if (utf8 && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))

-          {

-          class_utf8 = TRUE;

-

-          /* With UCP support, we can find the other case equivalents of

-          the relevant characters. There may be several ranges. Optimize how

-          they fit with the basic range. */

-

-#ifdef SUPPORT_UCP

-          if ((options & PCRE_CASELESS) != 0)

-            {

-            int occ, ocd;

-            int cc = c;

-            int origd = d;

-            while (get_othercase_range(&cc, origd, &occ, &ocd))

-              {

-              if (occ >= c && ocd <= d) continue;  /* Skip embedded ranges */

-

-              if (occ < c  && ocd >= c - 1)        /* Extend the basic range */

-                {                                  /* if there is overlap,   */

-                c = occ;                           /* noting that if occ < c */

-                continue;                          /* we can't have ocd > d  */

-                }                                  /* because a subrange is  */

-              if (ocd > d && occ <= d + 1)         /* always shorter than    */

-                {                                  /* the basic range.       */

-                d = ocd;

-                continue;

-                }

-

-              if (occ == ocd)

-                {

-                *class_utf8data++ = XCL_SINGLE;

-                }

-              else

-                {

-                *class_utf8data++ = XCL_RANGE;

-                class_utf8data += _pcre_ord2utf8(occ, class_utf8data);

-                }

-              class_utf8data += _pcre_ord2utf8(ocd, class_utf8data);

-              }

-            }

-#endif  /* SUPPORT_UCP */

-

-          /* Now record the original range, possibly modified for UCP caseless

-          overlapping ranges. */

-

-          *class_utf8data++ = XCL_RANGE;

-          class_utf8data += _pcre_ord2utf8(c, class_utf8data);

-          class_utf8data += _pcre_ord2utf8(d, class_utf8data);

-

-          /* With UCP support, we are done. Without UCP support, there is no

-          caseless matching for UTF-8 characters > 127; we can use the bit map

-          for the smaller ones. */

-

-#ifdef SUPPORT_UCP

-          continue;    /* With next character in the class */

-#else

-          if ((options & PCRE_CASELESS) == 0 || c > 127) continue;

-

-          /* Adjust upper limit and fall through to set up the map */

-

-          d = 127;

-

-#endif  /* SUPPORT_UCP */

-          }

-#endif  /* SUPPORT_UTF8 */

-

-        /* We use the bit map for all cases when not in UTF-8 mode; else

-        ranges that lie entirely within 0-127 when there is UCP support; else

-        for partial ranges without UCP support. */

-

-        for (; c <= d; c++)

-          {

-          classbits[c/8] |= (1 << (c&7));

-          if ((options & PCRE_CASELESS) != 0)

-            {

-            int uc = cd->fcc[c];           /* flip case */

-            classbits[uc/8] |= (1 << (uc&7));

-            }

-          class_charcount++;                /* in case a one-char range */

-          class_lastchar = c;

-          }

-

-        continue;   /* Go get the next char in the class */

-        }

-

-      /* Handle a lone single character - we can get here for a normal

-      non-escape char, or after \ that introduces a single character or for an

-      apparent range that isn't. */

-

-      LONE_SINGLE_CHARACTER:

-

-      /* Handle a character that cannot go in the bit map */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))

-        {

-        class_utf8 = TRUE;

-        *class_utf8data++ = XCL_SINGLE;

-        class_utf8data += _pcre_ord2utf8(c, class_utf8data);

-

-#ifdef SUPPORT_UCP

-        if ((options & PCRE_CASELESS) != 0)

-          {

-          int chartype;

-          int othercase;

-          if (_pcre_ucp_findchar(c, &chartype, &othercase) >= 0 &&

-               othercase > 0)

-            {

-            *class_utf8data++ = XCL_SINGLE;

-            class_utf8data += _pcre_ord2utf8(othercase, class_utf8data);

-            }

-          }

-#endif  /* SUPPORT_UCP */

-

-        }

-      else

-#endif  /* SUPPORT_UTF8 */

-

-      /* Handle a single-byte character */

-        {

-        classbits[c/8] |= (1 << (c&7));

-        if ((options & PCRE_CASELESS) != 0)

-          {

-          c = cd->fcc[c];   /* flip case */

-          classbits[c/8] |= (1 << (c&7));

-          }

-        class_charcount++;

-        class_lastchar = c;

-        }

-      }

-

-    /* Loop until ']' reached; the check for end of string happens inside the

-    loop. This "while" is the end of the "do" above. */

-

-    while ((c = *(++ptr)) != ']' || inescq);

-

-    /* If class_charcount is 1, we saw precisely one character whose value is

-    less than 256. In non-UTF-8 mode we can always optimize. In UTF-8 mode, we

-    can optimize the negative case only if there were no characters >= 128

-    because OP_NOT and the related opcodes like OP_NOTSTAR operate on

-    single-bytes only. This is an historical hangover. Maybe one day we can

-    tidy these opcodes to handle multi-byte characters.

-

-    The optimization throws away the bit map. We turn the item into a

-    1-character OP_CHAR[NC] if it's positive, or OP_NOT if it's negative. Note

-    that OP_NOT does not support multibyte characters. In the positive case, it

-    can cause firstbyte to be set. Otherwise, there can be no first char if

-    this item is first, whatever repeat count may follow. In the case of

-    reqbyte, save the previous value for reinstating. */

-

-#ifdef SUPPORT_UTF8

-    if (class_charcount == 1 &&

-          (!utf8 ||

-          (!class_utf8 && (!negate_class || class_lastchar < 128))))

-

-#else

-    if (class_charcount == 1)

-#endif

-      {

-      zeroreqbyte = reqbyte;

-

-      /* The OP_NOT opcode works on one-byte characters only. */

-

-      if (negate_class)

-        {

-        if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-        zerofirstbyte = firstbyte;

-        *code++ = OP_NOT;

-        *code++ = class_lastchar;

-        break;

-        }

-

-      /* For a single, positive character, get the value into mcbuffer, and

-      then we can handle this with the normal one-character code. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && class_lastchar > 127)

-        mclength = _pcre_ord2utf8(class_lastchar, mcbuffer);

-      else

-#endif

-        {

-        mcbuffer[0] = class_lastchar;

-        mclength = 1;

-        }

-      goto ONE_CHAR;

-      }       /* End of 1-char optimization */

-

-    /* The general case - not the one-char optimization. If this is the first

-    thing in the branch, there can be no first char setting, whatever the

-    repeat count. Any reqbyte setting must remain unchanged after any kind of

-    repeat. */

-

-    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-    zerofirstbyte = firstbyte;

-    zeroreqbyte = reqbyte;

-

-    /* If there are characters with values > 255, we have to compile an

-    extended class, with its own opcode. If there are no characters < 256,

-    we can omit the bitmap. */

-

-#ifdef SUPPORT_UTF8

-    if (class_utf8)

-      {

-      *class_utf8data++ = XCL_END;    /* Marks the end of extra data */

-      *code++ = OP_XCLASS;

-      code += LINK_SIZE;

-      *code = negate_class? XCL_NOT : 0;

-

-      /* If the map is required, install it, and move on to the end of

-      the extra data */

-

-      if (class_charcount > 0)

-        {

-        *code++ |= XCL_MAP;

-        memcpy(code, classbits, 32);

-        code = class_utf8data;

-        }

-

-      /* If the map is not required, slide down the extra data. */

-

-      else

-        {

-        int len = class_utf8data - (code + 33);

-        memmove(code + 1, code + 33, len);

-        code += len + 1;

-        }

-

-      /* Now fill in the complete length of the item */

-

-      PUT(previous, 1, code - previous);

-      break;   /* End of class handling */

-      }

-#endif

-

-    /* If there are no characters > 255, negate the 32-byte map if necessary,

-    and copy it into the code vector. If this is the first thing in the branch,

-    there can be no first char setting, whatever the repeat count. Any reqbyte

-    setting must remain unchanged after any kind of repeat. */

-

-    if (negate_class)

-      {

-      *code++ = OP_NCLASS;

-      for (c = 0; c < 32; c++) code[c] = ~classbits[c];

-      }

-    else

-      {

-      *code++ = OP_CLASS;

-      memcpy(code, classbits, 32);

-      }

-    code += 32;

-    break;

-

-    /* Various kinds of repeat; '{' is not necessarily a quantifier, but this

-    has been tested above. */

-

-    case '{':

-    if (!is_quantifier) goto NORMAL_CHAR;

-    ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);

-    if (*errorcodeptr != 0) goto FAILED;

-    goto REPEAT;

-

-    case '*':

-    repeat_min = 0;

-    repeat_max = -1;

-    goto REPEAT;

-

-    case '+':

-    repeat_min = 1;

-    repeat_max = -1;

-    goto REPEAT;

-

-    case '?':

-    repeat_min = 0;

-    repeat_max = 1;

-

-    REPEAT:

-    if (previous == NULL)

-      {

-      *errorcodeptr = ERR9;

-      goto FAILED;

-      }

-

-    if (repeat_min == 0)

-      {

-      firstbyte = zerofirstbyte;    /* Adjust for zero repeat */

-      reqbyte = zeroreqbyte;        /* Ditto */

-      }

-

-    /* Remember whether this is a variable length repeat */

-

-    reqvary = (repeat_min == repeat_max)? 0 : REQ_VARY;

-

-    op_type = 0;                    /* Default single-char op codes */

-    possessive_quantifier = FALSE;  /* Default not possessive quantifier */

-

-    /* Save start of previous item, in case we have to move it up to make space

-    for an inserted OP_ONCE for the additional '+' extension. */

-

-    tempcode = previous;

-

-    /* If the next character is '+', we have a possessive quantifier. This

-    implies greediness, whatever the setting of the PCRE_UNGREEDY option.

-    If the next character is '?' this is a minimizing repeat, by default,

-    but if PCRE_UNGREEDY is set, it works the other way round. We change the

-    repeat type to the non-default. */

-

-    if (ptr[1] == '+')

-      {

-      repeat_type = 0;                  /* Force greedy */

-      possessive_quantifier = TRUE;

-      ptr++;

-      }

-    else if (ptr[1] == '?')

-      {

-      repeat_type = greedy_non_default;

-      ptr++;

-      }

-    else repeat_type = greedy_default;

-

-    /* If previous was a recursion, we need to wrap it inside brackets so that

-    it can be replicated if necessary. */

-

-    if (*previous == OP_RECURSE)

-      {

-      memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);

-      code += 1 + LINK_SIZE;

-      *previous = OP_BRA;

-      PUT(previous, 1, code - previous);

-      *code = OP_KET;

-      PUT(code, 1, code - previous);

-      code += 1 + LINK_SIZE;

-      }

-

-    /* If previous was a character match, abolish the item and generate a

-    repeat item instead. If a char item has a minumum of more than one, ensure

-    that it is set in reqbyte - it might not be if a sequence such as x{3} is

-    the first thing in a branch because the x will have gone into firstbyte

-    instead.  */

-

-    if (*previous == OP_CHAR || *previous == OP_CHARNC)

-      {

-      /* Deal with UTF-8 characters that take up more than one byte. It's

-      easier to write this out separately than try to macrify it. Use c to

-      hold the length of the character in bytes, plus 0x80 to flag that it's a

-      length rather than a small character. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && (code[-1] & 0x80) != 0)

-        {

-        uschar *lastchar = code - 1;

-        while((*lastchar & 0xc0) == 0x80) lastchar--;

-        c = code - lastchar;            /* Length of UTF-8 character */

-        memcpy(utf8_char, lastchar, c); /* Save the char */

-        c |= 0x80;                      /* Flag c as a length */

-        }

-      else

-#endif

-

-      /* Handle the case of a single byte - either with no UTF8 support, or

-      with UTF-8 disabled, or for a UTF-8 character < 128. */

-

-        {

-        c = code[-1];

-        if (repeat_min > 1) reqbyte = c | req_caseopt | cd->req_varyopt;

-        }

-

-      goto OUTPUT_SINGLE_REPEAT;   /* Code shared with single character types */

-      }

-

-    /* If previous was a single negated character ([^a] or similar), we use

-    one of the special opcodes, replacing it. The code is shared with single-

-    character repeats by setting opt_type to add a suitable offset into

-    repeat_type. OP_NOT is currently used only for single-byte chars. */

-

-    else if (*previous == OP_NOT)

-      {

-      op_type = OP_NOTSTAR - OP_STAR;  /* Use "not" opcodes */

-      c = previous[1];

-      goto OUTPUT_SINGLE_REPEAT;

-      }

-

-    /* If previous was a character type match (\d or similar), abolish it and

-    create a suitable repeat item. The code is shared with single-character

-    repeats by setting op_type to add a suitable offset into repeat_type. Note

-    the the Unicode property types will be present only when SUPPORT_UCP is

-    defined, but we don't wrap the little bits of code here because it just

-    makes it horribly messy. */

-

-    else if (*previous < OP_EODN)

-      {

-      uschar *oldcode;

-      int prop_type;

-      op_type = OP_TYPESTAR - OP_STAR;  /* Use type opcodes */

-      c = *previous;

-

-      OUTPUT_SINGLE_REPEAT:

-      prop_type = (*previous == OP_PROP || *previous == OP_NOTPROP)?

-        previous[1] : -1;

-

-      oldcode = code;

-      code = previous;                  /* Usually overwrite previous item */

-

-      /* If the maximum is zero then the minimum must also be zero; Perl allows

-      this case, so we do too - by simply omitting the item altogether. */

-

-      if (repeat_max == 0) goto END_REPEAT;

-

-      /* All real repeats make it impossible to handle partial matching (maybe

-      one day we will be able to remove this restriction). */

-

-      if (repeat_max != 1) cd->nopartial = TRUE;

-

-      /* Combine the op_type with the repeat_type */

-

-      repeat_type += op_type;

-

-      /* A minimum of zero is handled either as the special case * or ?, or as

-      an UPTO, with the maximum given. */

-

-      if (repeat_min == 0)

-        {

-        if (repeat_max == -1) *code++ = OP_STAR + repeat_type;

-          else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type;

-        else

-          {

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max);

-          }

-        }

-

-      /* A repeat minimum of 1 is optimized into some special cases. If the

-      maximum is unlimited, we use OP_PLUS. Otherwise, the original item it

-      left in place and, if the maximum is greater than 1, we use OP_UPTO with

-      one less than the maximum. */

-

-      else if (repeat_min == 1)

-        {

-        if (repeat_max == -1)

-          *code++ = OP_PLUS + repeat_type;

-        else

-          {

-          code = oldcode;                 /* leave previous item in place */

-          if (repeat_max == 1) goto END_REPEAT;

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max - 1);

-          }

-        }

-

-      /* The case {n,n} is just an EXACT, while the general case {n,m} is

-      handled as an EXACT followed by an UPTO. */

-

-      else

-        {

-        *code++ = OP_EXACT + op_type;  /* NB EXACT doesn't have repeat_type */

-        PUT2INC(code, 0, repeat_min);

-

-        /* If the maximum is unlimited, insert an OP_STAR. Before doing so,

-        we have to insert the character for the previous code. For a repeated

-        Unicode property match, there is an extra byte that defines the

-        required property. In UTF-8 mode, long characters have their length in

-        c, with the 0x80 bit as a flag. */

-

-        if (repeat_max < 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-            memcpy(code, utf8_char, c & 7);

-            code += c & 7;

-            }

-          else

-#endif

-            {

-            *code++ = c;

-            if (prop_type >= 0) *code++ = prop_type;

-            }

-          *code++ = OP_STAR + repeat_type;

-          }

-

-        /* Else insert an UPTO if the max is greater than the min, again

-        preceded by the character, for the previously inserted code. */

-

-        else if (repeat_max != repeat_min)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-            memcpy(code, utf8_char, c & 7);

-            code += c & 7;

-            }

-          else

-#endif

-          *code++ = c;

-          if (prop_type >= 0) *code++ = prop_type;

-          repeat_max -= repeat_min;

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max);

-          }

-        }

-

-      /* The character or character type itself comes last in all cases. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && c >= 128)

-        {

-        memcpy(code, utf8_char, c & 7);

-        code += c & 7;

-        }

-      else

-#endif

-      *code++ = c;

-

-      /* For a repeated Unicode property match, there is an extra byte that

-      defines the required property. */

-

-#ifdef SUPPORT_UCP

-      if (prop_type >= 0) *code++ = prop_type;

-#endif

-      }

-

-    /* If previous was a character class or a back reference, we put the repeat

-    stuff after it, but just skip the item if the repeat was {0,0}. */

-

-    else if (*previous == OP_CLASS ||

-             *previous == OP_NCLASS ||

-#ifdef SUPPORT_UTF8

-             *previous == OP_XCLASS ||

-#endif

-             *previous == OP_REF)

-      {

-      if (repeat_max == 0)

-        {

-        code = previous;

-        goto END_REPEAT;

-        }

-

-      /* All real repeats make it impossible to handle partial matching (maybe

-      one day we will be able to remove this restriction). */

-

-      if (repeat_max != 1) cd->nopartial = TRUE;

-

-      if (repeat_min == 0 && repeat_max == -1)

-        *code++ = OP_CRSTAR + repeat_type;

-      else if (repeat_min == 1 && repeat_max == -1)

-        *code++ = OP_CRPLUS + repeat_type;

-      else if (repeat_min == 0 && repeat_max == 1)

-        *code++ = OP_CRQUERY + repeat_type;

-      else

-        {

-        *code++ = OP_CRRANGE + repeat_type;

-        PUT2INC(code, 0, repeat_min);

-        if (repeat_max == -1) repeat_max = 0;  /* 2-byte encoding for max */

-        PUT2INC(code, 0, repeat_max);

-        }

-      }

-

-    /* If previous was a bracket group, we may have to replicate it in certain

-    cases. */

-

-    else if (*previous >= OP_BRA || *previous == OP_ONCE ||

-             *previous == OP_COND)

-      {

-      register int i;

-      int ketoffset = 0;

-      int len = code - previous;

-      uschar *bralink = NULL;

-

-      /* If the maximum repeat count is unlimited, find the end of the bracket

-      by scanning through from the start, and compute the offset back to it

-      from the current code pointer. There may be an OP_OPT setting following

-      the final KET, so we can't find the end just by going back from the code

-      pointer. */

-

-      if (repeat_max == -1)

-        {

-        register uschar *ket = previous;

-        do ket += GET(ket, 1); while (*ket != OP_KET);

-        ketoffset = code - ket;

-        }

-

-      /* The case of a zero minimum is special because of the need to stick

-      OP_BRAZERO in front of it, and because the group appears once in the

-      data, whereas in other cases it appears the minimum number of times. For

-      this reason, it is simplest to treat this case separately, as otherwise

-      the code gets far too messy. There are several special subcases when the

-      minimum is zero. */

-

-      if (repeat_min == 0)

-        {

-        /* If the maximum is also zero, we just omit the group from the output

-        altogether. */

-

-        if (repeat_max == 0)

-          {

-          code = previous;

-          goto END_REPEAT;

-          }

-

-        /* If the maximum is 1 or unlimited, we just have to stick in the

-        BRAZERO and do no more at this point. However, we do need to adjust

-        any OP_RECURSE calls inside the group that refer to the group itself or

-        any internal group, because the offset is from the start of the whole

-        regex. Temporarily terminate the pattern while doing this. */

-

-        if (repeat_max <= 1)

-          {

-          *code = OP_END;

-          adjust_recurse(previous, 1, utf8, cd);

-          memmove(previous+1, previous, len);

-          code++;

-          *previous++ = OP_BRAZERO + repeat_type;

-          }

-

-        /* If the maximum is greater than 1 and limited, we have to replicate

-        in a nested fashion, sticking OP_BRAZERO before each set of brackets.

-        The first one has to be handled carefully because it's the original

-        copy, which has to be moved up. The remainder can be handled by code

-        that is common with the non-zero minimum case below. We have to

-        adjust the value or repeat_max, since one less copy is required. Once

-        again, we may have to adjust any OP_RECURSE calls inside the group. */

-

-        else

-          {

-          int offset;

-          *code = OP_END;

-          adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd);

-          memmove(previous + 2 + LINK_SIZE, previous, len);

-          code += 2 + LINK_SIZE;

-          *previous++ = OP_BRAZERO + repeat_type;

-          *previous++ = OP_BRA;

-

-          /* We chain together the bracket offset fields that have to be

-          filled in later when the ends of the brackets are reached. */

-

-          offset = (bralink == NULL)? 0 : previous - bralink;

-          bralink = previous;

-          PUTINC(previous, 0, offset);

-          }

-

-        repeat_max--;

-        }

-

-      /* If the minimum is greater than zero, replicate the group as many

-      times as necessary, and adjust the maximum to the number of subsequent

-      copies that we need. If we set a first char from the group, and didn't

-      set a required char, copy the latter from the former. */

-

-      else

-        {

-        if (repeat_min > 1)

-          {

-          if (groupsetfirstbyte && reqbyte < 0) reqbyte = firstbyte;

-          for (i = 1; i < repeat_min; i++)

-            {

-            memcpy(code, previous, len);

-            code += len;

-            }

-          }

-        if (repeat_max > 0) repeat_max -= repeat_min;

-        }

-

-      /* This code is common to both the zero and non-zero minimum cases. If

-      the maximum is limited, it replicates the group in a nested fashion,

-      remembering the bracket starts on a stack. In the case of a zero minimum,

-      the first one was set up above. In all cases the repeat_max now specifies

-      the number of additional copies needed. */

-

-      if (repeat_max >= 0)

-        {

-        for (i = repeat_max - 1; i >= 0; i--)

-          {

-          *code++ = OP_BRAZERO + repeat_type;

-

-          /* All but the final copy start a new nesting, maintaining the

-          chain of brackets outstanding. */

-

-          if (i != 0)

-            {

-            int offset;

-            *code++ = OP_BRA;

-            offset = (bralink == NULL)? 0 : code - bralink;

-            bralink = code;

-            PUTINC(code, 0, offset);

-            }

-

-          memcpy(code, previous, len);

-          code += len;

-          }

-

-        /* Now chain through the pending brackets, and fill in their length

-        fields (which are holding the chain links pro tem). */

-

-        while (bralink != NULL)

-          {

-          int oldlinkoffset;

-          int offset = code - bralink + 1;

-          uschar *bra = code - offset;

-          oldlinkoffset = GET(bra, 1);

-          bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;

-          *code++ = OP_KET;

-          PUTINC(code, 0, offset);

-          PUT(bra, 1, offset);

-          }

-        }

-

-      /* If the maximum is unlimited, set a repeater in the final copy. We

-      can't just offset backwards from the current code point, because we

-      don't know if there's been an options resetting after the ket. The

-      correct offset was computed above. */

-

-      else code[-ketoffset] = OP_KETRMAX + repeat_type;

-      }

-

-    /* Else there's some kind of shambles */

-

-    else

-      {

-      *errorcodeptr = ERR11;

-      goto FAILED;

-      }

-

-    /* If the character following a repeat is '+', we wrap the entire repeated

-    item inside OP_ONCE brackets. This is just syntactic sugar, taken from

-    Sun's Java package. The repeated item starts at tempcode, not at previous,

-    which might be the first part of a string whose (former) last char we

-    repeated. However, we don't support '+' after a greediness '?'. */

-

-    if (possessive_quantifier)

-      {

-      int len = code - tempcode;

-      memmove(tempcode + 1+LINK_SIZE, tempcode, len);

-      code += 1 + LINK_SIZE;

-      len += 1 + LINK_SIZE;

-      tempcode[0] = OP_ONCE;

-      *code++ = OP_KET;

-      PUTINC(code, 0, len);

-      PUT(tempcode, 1, len);

-      }

-

-    /* In all case we no longer have a previous item. We also set the

-    "follows varying string" flag for subsequently encountered reqbytes if

-    it isn't already set and we have just passed a varying length item. */

-

-    END_REPEAT:

-    previous = NULL;

-    cd->req_varyopt |= reqvary;

-    break;

-

-

-    /* Start of nested bracket sub-expression, or comment or lookahead or

-    lookbehind or option setting or condition. First deal with special things

-    that can come after a bracket; all are introduced by ?, and the appearance

-    of any of them means that this is not a referencing group. They were

-    checked for validity in the first pass over the string, so we don't have to

-    check for syntax errors here.  */

-

-    case '(':

-    newoptions = options;

-    skipbytes = 0;

-

-    if (*(++ptr) == '?')

-      {

-      int set, unset;

-      int *optset;

-

-      switch (*(++ptr))

-        {

-        case '#':                 /* Comment; skip to ket */

-        ptr++;

-        while (*ptr != ')') ptr++;

-        continue;

-

-        case ':':                 /* Non-extracting bracket */

-        bravalue = OP_BRA;

-        ptr++;

-        break;

-

-        case '(':

-        bravalue = OP_COND;       /* Conditional group */

-

-        /* Condition to test for recursion */

-

-        if (ptr[1] == 'R')

-          {

-          code[1+LINK_SIZE] = OP_CREF;

-          PUT2(code, 2+LINK_SIZE, CREF_RECURSE);

-          skipbytes = 3;

-          ptr += 3;

-          }

-

-        /* Condition to test for a numbered subpattern match. We know that

-        if a digit follows ( then there will just be digits until ) because

-        the syntax was checked in the first pass. */

-

-        else if ((digitab[ptr[1]] && ctype_digit) != 0)

-          {

-          int condref;                 /* Don't amalgamate; some compilers */

-          condref = *(++ptr) - '0';    /* grumble at autoincrement in declaration */

-          while (*(++ptr) != ')') condref = condref*10 + *ptr - '0';

-          if (condref == 0)

-            {

-            *errorcodeptr = ERR35;

-            goto FAILED;

-            }

-          ptr++;

-          code[1+LINK_SIZE] = OP_CREF;

-          PUT2(code, 2+LINK_SIZE, condref);

-          skipbytes = 3;

-          }

-        /* For conditions that are assertions, we just fall through, having

-        set bravalue above. */

-        break;

-

-        case '=':                 /* Positive lookahead */

-        bravalue = OP_ASSERT;

-        ptr++;

-        break;

-

-        case '!':                 /* Negative lookahead */

-        bravalue = OP_ASSERT_NOT;

-        ptr++;

-        break;

-

-        case '<':                 /* Lookbehinds */

-        switch (*(++ptr))

-          {

-          case '=':               /* Positive lookbehind */

-          bravalue = OP_ASSERTBACK;

-          ptr++;

-          break;

-

-          case '!':               /* Negative lookbehind */

-          bravalue = OP_ASSERTBACK_NOT;

-          ptr++;

-          break;

-          }

-        break;

-

-        case '>':                 /* One-time brackets */

-        bravalue = OP_ONCE;

-        ptr++;

-        break;

-

-        case 'C':                 /* Callout - may be followed by digits; */

-        previous_callout = code;  /* Save for later completion */

-        after_manual_callout = 1; /* Skip one item before completing */

-        *code++ = OP_CALLOUT;     /* Already checked that the terminating */

-          {                       /* closing parenthesis is present. */

-          int n = 0;

-          while ((digitab[*(++ptr)] & ctype_digit) != 0)

-            n = n * 10 + *ptr - '0';

-          if (n > 255)

-            {

-            *errorcodeptr = ERR38;

-            goto FAILED;

-            }

-          *code++ = n;

-          PUT(code, 0, ptr - cd->start_pattern + 1);  /* Pattern offset */

-          PUT(code, LINK_SIZE, 0);                    /* Default length */

-          code += 2 * LINK_SIZE;

-          }

-        previous = NULL;

-        continue;

-

-        case 'P':                 /* Named subpattern handling */

-        if (*(++ptr) == '<')      /* Definition */

-          {

-          int i, namelen;

-          uschar *slot = cd->name_table;

-          const uschar *name;     /* Don't amalgamate; some compilers */

-          name = ++ptr;           /* grumble at autoincrement in declaration */

-

-          while (*ptr++ != '>');

-          namelen = ptr - name - 1;

-

-          for (i = 0; i < cd->names_found; i++)

-            {

-            int crc = memcmp(name, slot+2, namelen);

-            if (crc == 0)

-              {

-              if (slot[2+namelen] == 0)

-                {

-                *errorcodeptr = ERR43;

-                goto FAILED;

-                }

-              crc = -1;             /* Current name is substring */

-              }

-            if (crc < 0)

-              {

-              memmove(slot + cd->name_entry_size, slot,

-                (cd->names_found - i) * cd->name_entry_size);

-              break;

-              }

-            slot += cd->name_entry_size;

-            }

-

-          PUT2(slot, 0, *brackets + 1);

-          memcpy(slot + 2, name, namelen);

-          slot[2+namelen] = 0;

-          cd->names_found++;

-          goto NUMBERED_GROUP;

-          }

-

-        if (*ptr == '=' || *ptr == '>')  /* Reference or recursion */

-          {

-          int i, namelen;

-          int type = *ptr++;

-          const uschar *name = ptr;

-          uschar *slot = cd->name_table;

-

-          while (*ptr != ')') ptr++;

-          namelen = ptr - name;

-

-          for (i = 0; i < cd->names_found; i++)

-            {

-            if (strncmp((char *)name, (char *)slot+2, namelen) == 0) break;

-            slot += cd->name_entry_size;

-            }

-          if (i >= cd->names_found)

-            {

-            *errorcodeptr = ERR15;

-            goto FAILED;

-            }

-

-          recno = GET2(slot, 0);

-

-          if (type == '>') goto HANDLE_RECURSION;  /* A few lines below */

-

-          /* Back reference */

-

-          previous = code;

-          *code++ = OP_REF;

-          PUT2INC(code, 0, recno);

-          cd->backref_map |= (recno < 32)? (1 << recno) : 1;

-          if (recno > cd->top_backref) cd->top_backref = recno;

-          continue;

-          }

-

-        /* Should never happen */

-        break;

-

-        case 'R':                 /* Pattern recursion */

-        ptr++;                    /* Same as (?0)      */

-        /* Fall through */

-

-        /* Recursion or "subroutine" call */

-

-        case '0': case '1': case '2': case '3': case '4':

-        case '5': case '6': case '7': case '8': case '9':

-          {

-          const uschar *called;

-          recno = 0;

-          while((digitab[*ptr] & ctype_digit) != 0)

-            recno = recno * 10 + *ptr++ - '0';

-

-          /* Come here from code above that handles a named recursion */

-

-          HANDLE_RECURSION:

-

-          previous = code;

-

-          /* Find the bracket that is being referenced. Temporarily end the

-          regex in case it doesn't exist. */

-

-          *code = OP_END;

-          called = (recno == 0)?

-            cd->start_code : find_bracket(cd->start_code, utf8, recno);

-

-          if (called == NULL)

-            {

-            *errorcodeptr = ERR15;

-            goto FAILED;

-            }

-

-          /* If the subpattern is still open, this is a recursive call. We

-          check to see if this is a left recursion that could loop for ever,

-          and diagnose that case. */

-

-          if (GET(called, 1) == 0 && could_be_empty(called, code, bcptr, utf8))

-            {

-            *errorcodeptr = ERR40;

-            goto FAILED;

-            }

-

-          /* Insert the recursion/subroutine item */

-

-          *code = OP_RECURSE;

-          PUT(code, 1, called - cd->start_code);

-          code += 1 + LINK_SIZE;

-          }

-        continue;

-

-        /* Character after (? not specially recognized */

-

-        default:                  /* Option setting */

-        set = unset = 0;

-        optset = &set;

-

-        while (*ptr != ')' && *ptr != ':')

-          {

-          switch (*ptr++)

-            {

-            case '-': optset = &unset; break;

-

-            case 'i': *optset |= PCRE_CASELESS; break;

-            case 'm': *optset |= PCRE_MULTILINE; break;

-            case 's': *optset |= PCRE_DOTALL; break;

-            case 'x': *optset |= PCRE_EXTENDED; break;

-            case 'U': *optset |= PCRE_UNGREEDY; break;

-            case 'X': *optset |= PCRE_EXTRA; break;

-            }

-          }

-

-        /* Set up the changed option bits, but don't change anything yet. */

-

-        newoptions = (options | set) & (~unset);

-

-        /* If the options ended with ')' this is not the start of a nested

-        group with option changes, so the options change at this level. Compile

-        code to change the ims options if this setting actually changes any of

-        them. We also pass the new setting back so that it can be put at the

-        start of any following branches, and when this group ends (if we are in

-        a group), a resetting item can be compiled.

-

-        Note that if this item is right at the start of the pattern, the

-        options will have been abstracted and made global, so there will be no

-        change to compile. */

-

-        if (*ptr == ')')

-          {

-          if ((options & PCRE_IMS) != (newoptions & PCRE_IMS))

-            {

-            *code++ = OP_OPT;

-            *code++ = newoptions & PCRE_IMS;

-            }

-

-          /* Change options at this level, and pass them back for use

-          in subsequent branches. Reset the greedy defaults and the case

-          value for firstbyte and reqbyte. */

-

-          *optionsptr = options = newoptions;

-          greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);

-          greedy_non_default = greedy_default ^ 1;

-          req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;

-

-          previous = NULL;       /* This item can't be repeated */

-          continue;              /* It is complete */

-          }

-

-        /* If the options ended with ':' we are heading into a nested group

-        with possible change of options. Such groups are non-capturing and are

-        not assertions of any kind. All we need to do is skip over the ':';

-        the newoptions value is handled below. */

-

-        bravalue = OP_BRA;

-        ptr++;

-        }

-      }

-

-    /* If PCRE_NO_AUTO_CAPTURE is set, all unadorned brackets become

-    non-capturing and behave like (?:...) brackets */

-

-    else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)

-      {

-      bravalue = OP_BRA;

-      }

-

-    /* Else we have a referencing group; adjust the opcode. If the bracket

-    number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and

-    arrange for the true number to follow later, in an OP_BRANUMBER item. */

-

-    else

-      {

-      NUMBERED_GROUP:

-      if (++(*brackets) > EXTRACT_BASIC_MAX)

-        {

-        bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;

-        code[1+LINK_SIZE] = OP_BRANUMBER;

-        PUT2(code, 2+LINK_SIZE, *brackets);

-        skipbytes = 3;

-        }

-      else bravalue = OP_BRA + *brackets;

-      }

-

-    /* Process nested bracketed re. Assertions may not be repeated, but other

-    kinds can be. We copy code into a non-register variable in order to be able

-    to pass its address because some compilers complain otherwise. Pass in a

-    new setting for the ims options if they have changed. */

-

-    previous = (bravalue >= OP_ONCE)? code : NULL;

-    *code = bravalue;

-    tempcode = code;

-    tempreqvary = cd->req_varyopt;     /* Save value before bracket */

-

-    if (!compile_regex(

-         newoptions,                   /* The complete new option state */

-         options & PCRE_IMS,           /* The previous ims option state */

-         brackets,                     /* Extracting bracket count */

-         &tempcode,                    /* Where to put code (updated) */

-         &ptr,                         /* Input pointer (updated) */

-         errorcodeptr,                 /* Where to put an error message */

-         (bravalue == OP_ASSERTBACK ||

-          bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */

-         skipbytes,                    /* Skip over OP_COND/OP_BRANUMBER */

-         &subfirstbyte,                /* For possible first char */

-         &subreqbyte,                  /* For possible last char */

-         bcptr,                        /* Current branch chain */

-         cd))                          /* Tables block */

-      goto FAILED;

-

-    /* At the end of compiling, code is still pointing to the start of the

-    group, while tempcode has been updated to point past the end of the group

-    and any option resetting that may follow it. The pattern pointer (ptr)

-    is on the bracket. */

-

-    /* If this is a conditional bracket, check that there are no more than

-    two branches in the group. */

-

-    else if (bravalue == OP_COND)

-      {

-      uschar *tc = code;

-      condcount = 0;

-

-      do {

-         condcount++;

-         tc += GET(tc,1);

-         }

-      while (*tc != OP_KET);

-

-      if (condcount > 2)

-        {

-        *errorcodeptr = ERR27;

-        goto FAILED;

-        }

-

-      /* If there is just one branch, we must not make use of its firstbyte or

-      reqbyte, because this is equivalent to an empty second branch. */

-

-      if (condcount == 1) subfirstbyte = subreqbyte = REQ_NONE;

-      }

-

-    /* Handle updating of the required and first characters. Update for normal

-    brackets of all kinds, and conditions with two branches (see code above).

-    If the bracket is followed by a quantifier with zero repeat, we have to

-    back off. Hence the definition of zeroreqbyte and zerofirstbyte outside the

-    main loop so that they can be accessed for the back off. */

-

-    zeroreqbyte = reqbyte;

-    zerofirstbyte = firstbyte;

-    groupsetfirstbyte = FALSE;

-

-    if (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_COND)

-      {

-      /* If we have not yet set a firstbyte in this branch, take it from the

-      subpattern, remembering that it was set here so that a repeat of more

-      than one can replicate it as reqbyte if necessary. If the subpattern has

-      no firstbyte, set "none" for the whole branch. In both cases, a zero

-      repeat forces firstbyte to "none". */

-

-      if (firstbyte == REQ_UNSET)

-        {

-        if (subfirstbyte >= 0)

-          {

-          firstbyte = subfirstbyte;

-          groupsetfirstbyte = TRUE;

-          }

-        else firstbyte = REQ_NONE;

-        zerofirstbyte = REQ_NONE;

-        }

-

-      /* If firstbyte was previously set, convert the subpattern's firstbyte

-      into reqbyte if there wasn't one, using the vary flag that was in

-      existence beforehand. */

-

-      else if (subfirstbyte >= 0 && subreqbyte < 0)

-        subreqbyte = subfirstbyte | tempreqvary;

-

-      /* If the subpattern set a required byte (or set a first byte that isn't

-      really the first byte - see above), set it. */

-

-      if (subreqbyte >= 0) reqbyte = subreqbyte;

-      }

-

-    /* For a forward assertion, we take the reqbyte, if set. This can be

-    helpful if the pattern that follows the assertion doesn't set a different

-    char. For example, it's useful for /(?=abcde).+/. We can't set firstbyte

-    for an assertion, however because it leads to incorrect effect for patterns

-    such as /(?=a)a.+/ when the "real" "a" would then become a reqbyte instead

-    of a firstbyte. This is overcome by a scan at the end if there's no

-    firstbyte, looking for an asserted first char. */

-

-    else if (bravalue == OP_ASSERT && subreqbyte >= 0) reqbyte = subreqbyte;

-

-    /* Now update the main code pointer to the end of the group. */

-

-    code = tempcode;

-

-    /* Error if hit end of pattern */

-

-    if (*ptr != ')')

-      {

-      *errorcodeptr = ERR14;

-      goto FAILED;

-      }

-    break;

-

-    /* Check \ for being a real metacharacter; if not, fall through and handle

-    it as a data character at the start of a string. Escape items are checked

-    for validity in the pre-compiling pass. */

-

-    case '\\':

-    tempptr = ptr;

-    c = check_escape(&ptr, errorcodeptr, *brackets, options, FALSE);

-

-    /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values

-    are arranged to be the negation of the corresponding OP_values. For the

-    back references, the values are ESC_REF plus the reference number. Only

-    back references and those types that consume a character may be repeated.

-    We can test for values between ESC_b and ESC_Z for the latter; this may

-    have to change if any new ones are ever created. */

-

-    if (c < 0)

-      {

-      if (-c == ESC_Q)            /* Handle start of quoted string */

-        {

-        if (ptr[1] == '\\' && ptr[2] == 'E') ptr += 2; /* avoid empty string */

-          else inescq = TRUE;

-        continue;

-        }

-

-      /* For metasequences that actually match a character, we disable the

-      setting of a first character if it hasn't already been set. */

-

-      if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)

-        firstbyte = REQ_NONE;

-

-      /* Set values to reset to if this is followed by a zero repeat. */

-

-      zerofirstbyte = firstbyte;

-      zeroreqbyte = reqbyte;

-

-      /* Back references are handled specially */

-

-      if (-c >= ESC_REF)

-        {

-        int number = -c - ESC_REF;

-        previous = code;

-        *code++ = OP_REF;

-        PUT2INC(code, 0, number);

-        }

-

-      /* So are Unicode property matches, if supported. We know that get_ucp

-      won't fail because it was tested in the pre-pass. */

-

-#ifdef SUPPORT_UCP

-      else if (-c == ESC_P || -c == ESC_p)

-        {

-        BOOL negated;

-        int value = get_ucp(&ptr, &negated, errorcodeptr);

-        previous = code;

-        *code++ = ((-c == ESC_p) != negated)? OP_PROP : OP_NOTPROP;

-        *code++ = value;

-        }

-#endif

-

-      /* For the rest, we can obtain the OP value by negating the escape

-      value */

-

-      else

-        {

-        previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;

-        *code++ = -c;

-        }

-      continue;

-      }

-

-    /* We have a data character whose value is in c. In UTF-8 mode it may have

-    a value > 127. We set its representation in the length/buffer, and then

-    handle it as a data character. */

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && c > 127)

-      mclength = _pcre_ord2utf8(c, mcbuffer);

-    else

-#endif

-

-     {

-     mcbuffer[0] = c;

-     mclength = 1;

-     }

-

-    goto ONE_CHAR;

-

-    /* Handle a literal character. It is guaranteed not to be whitespace or #

-    when the extended flag is set. If we are in UTF-8 mode, it may be a

-    multi-byte literal character. */

-

-    default:

-    NORMAL_CHAR:

-    mclength = 1;

-    mcbuffer[0] = c;

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && (c & 0xc0) == 0xc0)

-      {

-      while ((ptr[1] & 0xc0) == 0x80)

-        mcbuffer[mclength++] = *(++ptr);

-      }

-#endif

-

-    /* At this point we have the character's bytes in mcbuffer, and the length

-    in mclength. When not in UTF-8 mode, the length is always 1. */

-

-    ONE_CHAR:

-    previous = code;

-    *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARNC : OP_CHAR;

-    for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];

-

-    /* Set the first and required bytes appropriately. If no previous first

-    byte, set it from this character, but revert to none on a zero repeat.

-    Otherwise, leave the firstbyte value alone, and don't change it on a zero

-    repeat. */

-

-    if (firstbyte == REQ_UNSET)

-      {

-      zerofirstbyte = REQ_NONE;

-      zeroreqbyte = reqbyte;

-

-      /* If the character is more than one byte long, we can set firstbyte

-      only if it is not to be matched caselessly. */

-

-      if (mclength == 1 || req_caseopt == 0)

-        {

-        firstbyte = mcbuffer[0] | req_caseopt;

-        if (mclength != 1) reqbyte = code[-1] | cd->req_varyopt;

-        }

-      else firstbyte = reqbyte = REQ_NONE;

-      }

-

-    /* firstbyte was previously set; we can set reqbyte only the length is

-    1 or the matching is caseful. */

-

-    else

-      {

-      zerofirstbyte = firstbyte;

-      zeroreqbyte = reqbyte;

-      if (mclength == 1 || req_caseopt == 0)

-        reqbyte = code[-1] | req_caseopt | cd->req_varyopt;

-      }

-

-    break;            /* End of literal character handling */

-    }

-  }                   /* end of big loop */

-

-/* Control never reaches here by falling through, only by a goto for all the

-error states. Pass back the position in the pattern so that it can be displayed

-to the user for diagnosing the error. */

-

-FAILED:

-*ptrptr = ptr;

-return FALSE;

-}

-

-

-

-

-/*************************************************

-*     Compile sequence of alternatives           *

-*************************************************/

-

-/* On entry, ptr is pointing past the bracket character, but on return

-it points to the closing bracket, or vertical bar, or end of string.

-The code variable is pointing at the byte into which the BRA operator has been

-stored. If the ims options are changed at the start (for a (?ims: group) or

-during any branch, we need to insert an OP_OPT item at the start of every

-following branch to ensure they get set correctly at run time, and also pass

-the new options into every subsequent branch compile.

-

-Argument:

-  options        option bits, including any changes for this subpattern

-  oldims         previous settings of ims option bits

-  brackets       -> int containing the number of extracting brackets used

-  codeptr        -> the address of the current code pointer

-  ptrptr         -> the address of the current pattern pointer

-  errorcodeptr   -> pointer to error code variable

-  lookbehind     TRUE if this is a lookbehind assertion

-  skipbytes      skip this many bytes at start (for OP_COND, OP_BRANUMBER)

-  firstbyteptr   place to put the first required character, or a negative number

-  reqbyteptr     place to put the last required character, or a negative number

-  bcptr          pointer to the chain of currently open branches

-  cd             points to the data block with tables pointers etc.

-

-Returns:      TRUE on success

-*/

-

-static BOOL

-compile_regex(int options, int oldims, int *brackets, uschar **codeptr,

-  const uschar **ptrptr, int *errorcodeptr, BOOL lookbehind, int skipbytes,

-  int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd)

-{

-const uschar *ptr = *ptrptr;

-uschar *code = *codeptr;

-uschar *last_branch = code;

-uschar *start_bracket = code;

-uschar *reverse_count = NULL;

-int firstbyte, reqbyte;

-int branchfirstbyte, branchreqbyte;

-branch_chain bc;

-

-bc.outer = bcptr;

-bc.current = code;

-

-firstbyte = reqbyte = REQ_UNSET;

-

-/* Offset is set zero to mark that this bracket is still open */

-

-PUT(code, 1, 0);

-code += 1 + LINK_SIZE + skipbytes;

-

-/* Loop for each alternative branch */

-

-for (;;)

-  {

-  /* Handle a change of ims options at the start of the branch */

-

-  if ((options & PCRE_IMS) != oldims)

-    {

-    *code++ = OP_OPT;

-    *code++ = options & PCRE_IMS;

-    }

-

-  /* Set up dummy OP_REVERSE if lookbehind assertion */

-

-  if (lookbehind)

-    {

-    *code++ = OP_REVERSE;

-    reverse_count = code;

-    PUTINC(code, 0, 0);

-    }

-

-  /* Now compile the branch */

-

-  if (!compile_branch(&options, brackets, &code, &ptr, errorcodeptr,

-        &branchfirstbyte, &branchreqbyte, &bc, cd))

-    {

-    *ptrptr = ptr;

-    return FALSE;

-    }

-

-  /* If this is the first branch, the firstbyte and reqbyte values for the

-  branch become the values for the regex. */

-

-  if (*last_branch != OP_ALT)

-    {

-    firstbyte = branchfirstbyte;

-    reqbyte = branchreqbyte;

-    }

-

-  /* If this is not the first branch, the first char and reqbyte have to

-  match the values from all the previous branches, except that if the previous

-  value for reqbyte didn't have REQ_VARY set, it can still match, and we set

-  REQ_VARY for the regex. */

-

-  else

-    {

-    /* If we previously had a firstbyte, but it doesn't match the new branch,

-    we have to abandon the firstbyte for the regex, but if there was previously

-    no reqbyte, it takes on the value of the old firstbyte. */

-

-    if (firstbyte >= 0 && firstbyte != branchfirstbyte)

-      {

-      if (reqbyte < 0) reqbyte = firstbyte;

-      firstbyte = REQ_NONE;

-      }

-

-    /* If we (now or from before) have no firstbyte, a firstbyte from the

-    branch becomes a reqbyte if there isn't a branch reqbyte. */

-

-    if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)

-        branchreqbyte = branchfirstbyte;

-

-    /* Now ensure that the reqbytes match */

-

-    if ((reqbyte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY))

-      reqbyte = REQ_NONE;

-    else reqbyte |= branchreqbyte;   /* To "or" REQ_VARY */

-    }

-

-  /* If lookbehind, check that this branch matches a fixed-length string,

-  and put the length into the OP_REVERSE item. Temporarily mark the end of

-  the branch with OP_END. */

-

-  if (lookbehind)

-    {

-    int length;

-    *code = OP_END;

-    length = find_fixedlength(last_branch, options);

-    DPRINTF(("fixed length = %d\n", length));

-    if (length < 0)

-      {

-      *errorcodeptr = (length == -2)? ERR36 : ERR25;

-      *ptrptr = ptr;

-      return FALSE;

-      }

-    PUT(reverse_count, 0, length);

-    }

-

-  /* Reached end of expression, either ')' or end of pattern. Go back through

-  the alternative branches and reverse the chain of offsets, with the field in

-  the BRA item now becoming an offset to the first alternative. If there are

-  no alternatives, it points to the end of the group. The length in the

-  terminating ket is always the length of the whole bracketed item. If any of

-  the ims options were changed inside the group, compile a resetting op-code

-  following, except at the very end of the pattern. Return leaving the pointer

-  at the terminating char. */

-

-  if (*ptr != '|')

-    {

-    int length = code - last_branch;

-    do

-      {

-      int prev_length = GET(last_branch, 1);

-      PUT(last_branch, 1, length);

-      length = prev_length;

-      last_branch -= length;

-      }

-    while (length > 0);

-

-    /* Fill in the ket */

-

-    *code = OP_KET;

-    PUT(code, 1, code - start_bracket);

-    code += 1 + LINK_SIZE;

-

-    /* Resetting option if needed */

-

-    if ((options & PCRE_IMS) != oldims && *ptr == ')')

-      {

-      *code++ = OP_OPT;

-      *code++ = oldims;

-      }

-

-    /* Set values to pass back */

-

-    *codeptr = code;

-    *ptrptr = ptr;

-    *firstbyteptr = firstbyte;

-    *reqbyteptr = reqbyte;

-    return TRUE;

-    }

-

-  /* Another branch follows; insert an "or" node. Its length field points back

-  to the previous branch while the bracket remains open. At the end the chain

-  is reversed. It's done like this so that the start of the bracket has a

-  zero offset until it is closed, making it possible to detect recursion. */

-

-  *code = OP_ALT;

-  PUT(code, 1, code - last_branch);

-  bc.current = last_branch = code;

-  code += 1 + LINK_SIZE;

-  ptr++;

-  }

-/* Control never reaches here */

-}

-

-

-

-

-/*************************************************

-*          Check for anchored expression         *

-*************************************************/

-

-/* Try to find out if this is an anchored regular expression. Consider each

-alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket

-all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then

-it's anchored. However, if this is a multiline pattern, then only OP_SOD

-counts, since OP_CIRC can match in the middle.

-

-We can also consider a regex to be anchored if OP_SOM starts all its branches.

-This is the code for \G, which means "match at start of match position, taking

-into account the match offset".

-

-A branch is also implicitly anchored if it starts with .* and DOTALL is set,

-because that will try the rest of the pattern at all possible matching points,

-so there is no point trying again.... er ....

-

-.... except when the .* appears inside capturing parentheses, and there is a

-subsequent back reference to those parentheses. We haven't enough information

-to catch that case precisely.

-

-At first, the best we could do was to detect when .* was in capturing brackets

-and the highest back reference was greater than or equal to that level.

-However, by keeping a bitmap of the first 31 back references, we can catch some

-of the more common cases more precisely.

-

-Arguments:

-  code           points to start of expression (the bracket)

-  options        points to the options setting

-  bracket_map    a bitmap of which brackets we are inside while testing; this

-                  handles up to substring 31; after that we just have to take

-                  the less precise approach

-  backref_map    the back reference bitmap

-

-Returns:     TRUE or FALSE

-*/

-

-static BOOL

-is_anchored(register const uschar *code, int *options, unsigned int bracket_map,

-  unsigned int backref_map)

-{

-do {

-   const uschar *scode =

-     first_significant_code(code + 1+LINK_SIZE, options, PCRE_MULTILINE, FALSE);

-   register int op = *scode;

-

-   /* Capturing brackets */

-

-   if (op > OP_BRA)

-     {

-     int new_map;

-     op -= OP_BRA;

-     if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);

-     new_map = bracket_map | ((op < 32)? (1 << op) : 1);

-     if (!is_anchored(scode, options, new_map, backref_map)) return FALSE;

-     }

-

-   /* Other brackets */

-

-   else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)

-     {

-     if (!is_anchored(scode, options, bracket_map, backref_map)) return FALSE;

-     }

-

-   /* .* is not anchored unless DOTALL is set and it isn't in brackets that

-   are or may be referenced. */

-

-   else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) &&

-            (*options & PCRE_DOTALL) != 0)

-     {

-     if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;

-     }

-

-   /* Check for explicit anchoring */

-

-   else if (op != OP_SOD && op != OP_SOM &&

-           ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))

-     return FALSE;

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);   /* Loop for each alternative */

-return TRUE;

-}

-

-

-

-/*************************************************

-*         Check for starting with ^ or .*        *

-*************************************************/

-

-/* This is called to find out if every branch starts with ^ or .* so that

-"first char" processing can be done to speed things up in multiline

-matching and for non-DOTALL patterns that start with .* (which must start at

-the beginning or after \n). As in the case of is_anchored() (see above), we

-have to take account of back references to capturing brackets that contain .*

-because in that case we can't make the assumption.

-

-Arguments:

-  code           points to start of expression (the bracket)

-  bracket_map    a bitmap of which brackets we are inside while testing; this

-                  handles up to substring 31; after that we just have to take

-                  the less precise approach

-  backref_map    the back reference bitmap

-

-Returns:         TRUE or FALSE

-*/

-

-static BOOL

-is_startline(const uschar *code, unsigned int bracket_map,

-  unsigned int backref_map)

-{

-do {

-   const uschar *scode = first_significant_code(code + 1+LINK_SIZE, NULL, 0,

-     FALSE);

-   register int op = *scode;

-

-   /* Capturing brackets */

-

-   if (op > OP_BRA)

-     {

-     int new_map;

-     op -= OP_BRA;

-     if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);

-     new_map = bracket_map | ((op < 32)? (1 << op) : 1);

-     if (!is_startline(scode, new_map, backref_map)) return FALSE;

-     }

-

-   /* Other brackets */

-

-   else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)

-     { if (!is_startline(scode, bracket_map, backref_map)) return FALSE; }

-

-   /* .* means "start at start or after \n" if it isn't in brackets that

-   may be referenced. */

-

-   else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR)

-     {

-     if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;

-     }

-

-   /* Check for explicit circumflex */

-

-   else if (op != OP_CIRC) return FALSE;

-

-   /* Move on to the next alternative */

-

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);  /* Loop for each alternative */

-return TRUE;

-}

-

-

-

-/*************************************************

-*       Check for asserted fixed first char      *

-*************************************************/

-

-/* During compilation, the "first char" settings from forward assertions are

-discarded, because they can cause conflicts with actual literals that follow.

-However, if we end up without a first char setting for an unanchored pattern,

-it is worth scanning the regex to see if there is an initial asserted first

-char. If all branches start with the same asserted char, or with a bracket all

-of whose alternatives start with the same asserted char (recurse ad lib), then

-we return that char, otherwise -1.

-

-Arguments:

-  code       points to start of expression (the bracket)

-  options    pointer to the options (used to check casing changes)

-  inassert   TRUE if in an assertion

-

-Returns:     -1 or the fixed first char

-*/

-

-static int

-find_firstassertedchar(const uschar *code, int *options, BOOL inassert)

-{

-register int c = -1;

-do {

-   int d;

-   const uschar *scode =

-     first_significant_code(code + 1+LINK_SIZE, options, PCRE_CASELESS, TRUE);

-   register int op = *scode;

-

-   if (op >= OP_BRA) op = OP_BRA;

-

-   switch(op)

-     {

-     default:

-     return -1;

-

-     case OP_BRA:

-     case OP_ASSERT:

-     case OP_ONCE:

-     case OP_COND:

-     if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)

-       return -1;

-     if (c < 0) c = d; else if (c != d) return -1;

-     break;

-

-     case OP_EXACT:       /* Fall through */

-     scode += 2;

-

-     case OP_CHAR:

-     case OP_CHARNC:

-     case OP_PLUS:

-     case OP_MINPLUS:

-     if (!inassert) return -1;

-     if (c < 0)

-       {

-       c = scode[1];

-       if ((*options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;

-       }

-     else if (c != scode[1]) return -1;

-     break;

-     }

-

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);

-return c;

-}

-

-

-

-/*************************************************

-*        Compile a Regular Expression            *

-*************************************************/

-

-/* This function takes a string and returns a pointer to a block of store

-holding a compiled version of the expression. The original API for this

-function had no error code return variable; it is retained for backwards

-compatibility. The new function is given a new name.

-

-Arguments:

-  pattern       the regular expression

-  options       various option bits

-  errorcodeptr  pointer to error code variable (pcre_compile2() only)

-                  can be NULL if you don't want a code value

-  errorptr      pointer to pointer to error text

-  erroroffset   ptr offset in pattern where error was detected

-  tables        pointer to character tables or NULL

-

-Returns:        pointer to compiled data block, or NULL on error,

-                with errorptr and erroroffset set

-*/

-

-EXPORT pcre *

-pcre_compile(const char *pattern, int options, const char **errorptr,

-  int *erroroffset, const unsigned char *tables)

-{

-return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);

-}

-

-

-EXPORT pcre *

-pcre_compile2(const char *pattern, int options, int *errorcodeptr,

-  const char **errorptr, int *erroroffset, const unsigned char *tables)

-{

-real_pcre *re;

-int length = 1 + LINK_SIZE;      /* For initial BRA plus length */

-int c, firstbyte, reqbyte;

-int bracount = 0;

-int branch_extra = 0;

-int branch_newextra;

-int item_count = -1;

-int name_count = 0;

-int max_name_size = 0;

-int lastitemlength = 0;

-int errorcode = 0;

-#ifdef SUPPORT_UTF8

-BOOL utf8;

-BOOL class_utf8;

-#endif

-BOOL inescq = FALSE;

-BOOL capturing;

-unsigned int brastackptr = 0;

-size_t size;

-uschar *code;

-const uschar *codestart;

-const uschar *ptr;

-compile_data compile_block;

-int brastack[BRASTACK_SIZE];

-uschar bralenstack[BRASTACK_SIZE];

-

-/* We can't pass back an error message if errorptr is NULL; I guess the best we

-can do is just return NULL, but we can set a code value if there is a code

-pointer. */

-

-if (errorptr == NULL)

-  {

-  if (errorcodeptr != NULL) *errorcodeptr = 99;

-  return NULL;

-  }

-

-*errorptr = NULL;

-if (errorcodeptr != NULL) *errorcodeptr = ERR0;

-

-/* However, we can give a message for this error */

-

-if (erroroffset == NULL)

-  {

-  errorcode = ERR16;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-*erroroffset = 0;

-

-/* Can't support UTF8 unless PCRE has been compiled to include the code. */

-

-#ifdef SUPPORT_UTF8

-utf8 = (options & PCRE_UTF8) != 0;

-if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&

-     (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)

-  {

-  errorcode = ERR44;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-#else

-if ((options & PCRE_UTF8) != 0)

-  {

-  errorcode = ERR32;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-#endif

-

-if ((options & ~PUBLIC_OPTIONS) != 0)

-  {

-  errorcode = ERR17;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Set up pointers to the individual character tables */

-

-if (tables == NULL) tables = _pcre_default_tables;

-compile_block.lcc = tables + lcc_offset;

-compile_block.fcc = tables + fcc_offset;

-compile_block.cbits = tables + cbits_offset;

-compile_block.ctypes = tables + ctypes_offset;

-

-/* Maximum back reference and backref bitmap. This is updated for numeric

-references during the first pass, but for named references during the actual

-compile pass. The bitmap records up to 31 back references to help in deciding

-whether (.*) can be treated as anchored or not. */

-

-compile_block.top_backref = 0;

-compile_block.backref_map = 0;

-

-/* Reflect pattern for debugging output */

-

-DPRINTF(("------------------------------------------------------------------\n"));

-DPRINTF(("%s\n", pattern));

-

-/* The first thing to do is to make a pass over the pattern to compute the

-amount of store required to hold the compiled code. This does not have to be

-perfect as long as errors are overestimates. At the same time we can detect any

-flag settings right at the start, and extract them. Make an attempt to correct

-for any counted white space if an "extended" flag setting appears late in the

-pattern. We can't be so clever for #-comments. */

-

-ptr = (const uschar *)(pattern - 1);

-while ((c = *(++ptr)) != 0)

-  {

-  int min, max;

-  int class_optcount;

-  int bracket_length;

-  int duplength;

-

-  /* If we are inside a \Q...\E sequence, all chars are literal */

-

-  if (inescq)

-    {

-    if ((options & PCRE_AUTO_CALLOUT) != 0) length += 2 + 2*LINK_SIZE;

-    goto NORMAL_CHAR;

-    }

-

-  /* Otherwise, first check for ignored whitespace and comments */

-

-  if ((options & PCRE_EXTENDED) != 0)

-    {

-    if ((compile_block.ctypes[c] & ctype_space) != 0) continue;

-    if (c == '#')

-      {

-      /* The space before the ; is to avoid a warning on a silly compiler

-      on the Macintosh. */

-      while ((c = *(++ptr)) != 0 && c != NEWLINE) ;

-      if (c == 0) break;

-      continue;

-      }

-    }

-

-  item_count++;    /* Is zero for the first non-comment item */

-

-  /* Allow space for auto callout before every item except quantifiers. */

-

-  if ((options & PCRE_AUTO_CALLOUT) != 0 &&

-       c != '*' && c != '+' && c != '?' &&

-       (c != '{' || !is_counted_repeat(ptr + 1)))

-    length += 2 + 2*LINK_SIZE;

-

-  switch(c)

-    {

-    /* A backslashed item may be an escaped data character or it may be a

-    character type. */

-

-    case '\\':

-    c = check_escape(&ptr, &errorcode, bracount, options, FALSE);

-    if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-    lastitemlength = 1;     /* Default length of last item for repeats */

-

-    if (c >= 0)             /* Data character */

-      {

-      length += 2;          /* For a one-byte character */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && c > 127)

-        {

-        int i;

-        for (i = 0; i < _pcre_utf8_table1_size; i++)

-          if (c <= _pcre_utf8_table1[i]) break;

-        length += i;

-        lastitemlength += i;

-        }

-#endif

-

-      continue;

-      }

-

-    /* If \Q, enter "literal" mode */

-

-    if (-c == ESC_Q)

-      {

-      inescq = TRUE;

-      continue;

-      }

-

-    /* \X is supported only if Unicode property support is compiled */

-

-#ifndef SUPPORT_UCP

-    if (-c == ESC_X)

-      {

-      errorcode = ERR45;

-      goto PCRE_ERROR_RETURN;

-      }

-#endif

-

-    /* \P and \p are for Unicode properties, but only when the support has

-    been compiled. Each item needs 2 bytes. */

-

-    else if (-c == ESC_P || -c == ESC_p)

-      {

-#ifdef SUPPORT_UCP

-      BOOL negated;

-      length += 2;

-      lastitemlength = 2;

-      if (get_ucp(&ptr, &negated, &errorcode) < 0) goto PCRE_ERROR_RETURN;

-      continue;

-#else

-      errorcode = ERR45;

-      goto PCRE_ERROR_RETURN;

-#endif

-      }

-

-    /* Other escapes need one byte */

-

-    length++;

-

-    /* A back reference needs an additional 2 bytes, plus either one or 5

-    bytes for a repeat. We also need to keep the value of the highest

-    back reference. */

-

-    if (c <= -ESC_REF)

-      {

-      int refnum = -c - ESC_REF;

-      compile_block.backref_map |= (refnum < 32)? (1 << refnum) : 1;

-      if (refnum > compile_block.top_backref)

-        compile_block.top_backref = refnum;

-      length += 2;   /* For single back reference */

-      if (ptr[1] == '{' && is_counted_repeat(ptr+2))

-        {

-        ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-        if ((min == 0 && (max == 1 || max == -1)) ||

-          (min == 1 && max == -1))

-            length++;

-        else length += 5;

-        if (ptr[1] == '?') ptr++;

-        }

-      }

-    continue;

-

-    case '^':     /* Single-byte metacharacters */

-    case '.':

-    case '$':

-    length++;

-    lastitemlength = 1;

-    continue;

-

-    case '*':            /* These repeats won't be after brackets; */

-    case '+':            /* those are handled separately */

-    case '?':

-    length++;

-    goto POSESSIVE;      /* A few lines below */

-

-    /* This covers the cases of braced repeats after a single char, metachar,

-    class, or back reference. */

-

-    case '{':

-    if (!is_counted_repeat(ptr+1)) goto NORMAL_CHAR;

-    ptr = read_repeat_counts(ptr+1, &min, &max, &errorcode);

-    if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-    /* These special cases just insert one extra opcode */

-

-    if ((min == 0 && (max == 1 || max == -1)) ||

-      (min == 1 && max == -1))

-        length++;

-

-    /* These cases might insert additional copies of a preceding character. */

-

-    else

-      {

-      if (min != 1)

-        {

-        length -= lastitemlength;   /* Uncount the original char or metachar */

-        if (min > 0) length += 3 + lastitemlength;

-        }

-      length += lastitemlength + ((max > 0)? 3 : 1);

-      }

-

-    if (ptr[1] == '?') ptr++;      /* Needs no extra length */

-

-    POSESSIVE:                     /* Test for possessive quantifier */

-    if (ptr[1] == '+')

-      {

-      ptr++;

-      length += 2 + 2*LINK_SIZE;   /* Allow for atomic brackets */

-      }

-    continue;

-

-    /* An alternation contains an offset to the next branch or ket. If any ims

-    options changed in the previous branch(es), and/or if we are in a

-    lookbehind assertion, extra space will be needed at the start of the

-    branch. This is handled by branch_extra. */

-

-    case '|':

-    length += 1 + LINK_SIZE + branch_extra;

-    continue;

-

-    /* A character class uses 33 characters provided that all the character

-    values are less than 256. Otherwise, it uses a bit map for low valued

-    characters, and individual items for others. Don't worry about character

-    types that aren't allowed in classes - they'll get picked up during the

-    compile. A character class that contains only one single-byte character

-    uses 2 or 3 bytes, depending on whether it is negated or not. Notice this

-    where we can. (In UTF-8 mode we can do this only for chars < 128.) */

-

-    case '[':

-    if (*(++ptr) == '^')

-      {

-      class_optcount = 10;  /* Greater than one */

-      ptr++;

-      }

-    else class_optcount = 0;

-

-#ifdef SUPPORT_UTF8

-    class_utf8 = FALSE;

-#endif

-

-    /* Written as a "do" so that an initial ']' is taken as data */

-

-    if (*ptr != 0) do

-      {

-      /* Inside \Q...\E everything is literal except \E */

-

-      if (inescq)

-        {

-        if (*ptr != '\\' || ptr[1] != 'E') goto GET_ONE_CHARACTER;

-        inescq = FALSE;

-        ptr += 1;

-        continue;

-        }

-

-      /* Outside \Q...\E, check for escapes */

-

-      if (*ptr == '\\')

-        {

-        c = check_escape(&ptr, &errorcode, bracount, options, TRUE);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-        /* \b is backspace inside a class; \X is literal */

-

-        if (-c == ESC_b) c = '\b';

-        else if (-c == ESC_X) c = 'X';

-

-        /* \Q enters quoting mode */

-

-        else if (-c == ESC_Q)

-          {

-          inescq = TRUE;

-          continue;

-          }

-

-        /* Handle escapes that turn into characters */

-

-        if (c >= 0) goto NON_SPECIAL_CHARACTER;

-

-        /* Escapes that are meta-things. The normal ones just affect the

-        bit map, but Unicode properties require an XCLASS extended item. */

-

-        else

-          {

-          class_optcount = 10;         /* \d, \s etc; make sure > 1 */

-#ifdef SUPPORT_UTF8

-          if (-c == ESC_p || -c == ESC_P)

-            {

-            if (!class_utf8)

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-            length += 2;

-            }

-#endif

-          }

-        }

-

-      /* Check the syntax for POSIX stuff. The bits we actually handle are

-      checked during the real compile phase. */

-

-      else if (*ptr == '[' && check_posix_syntax(ptr, &ptr, &compile_block))

-        {

-        ptr++;

-        class_optcount = 10;    /* Make sure > 1 */

-        }

-

-      /* Anything else increments the possible optimization count. We have to

-      detect ranges here so that we can compute the number of extra ranges for

-      caseless wide characters when UCP support is available. If there are wide

-      characters, we are going to have to use an XCLASS, even for single

-      characters. */

-

-      else

-        {

-        int d;

-

-        GET_ONE_CHARACTER:

-

-#ifdef SUPPORT_UTF8

-        if (utf8)

-          {

-          int extra = 0;

-          GETCHARLEN(c, ptr, extra);

-          ptr += extra;

-          }

-        else c = *ptr;

-#else

-        c = *ptr;

-#endif

-

-        /* Come here from handling \ above when it escapes to a char value */

-

-        NON_SPECIAL_CHARACTER:

-        class_optcount++;

-

-        d = -1;

-        if (ptr[1] == '-')

-          {

-          uschar const *hyptr = ptr++;

-          if (ptr[1] == '\\')

-            {

-            ptr++;

-            d = check_escape(&ptr, &errorcode, bracount, options, TRUE);

-            if (errorcode != 0) goto PCRE_ERROR_RETURN;

-            if (-d == ESC_b) d = '\b';        /* backspace */

-            else if (-d == ESC_X) d = 'X';    /* literal X in a class */

-            }

-          else if (ptr[1] != 0 && ptr[1] != ']')

-            {

-            ptr++;

-#ifdef SUPPORT_UTF8

-            if (utf8)

-              {

-              int extra = 0;

-              GETCHARLEN(d, ptr, extra);

-              ptr += extra;

-              }

-            else

-#endif

-            d = *ptr;

-            }

-          if (d < 0) ptr = hyptr;      /* go back to hyphen as data */

-          }

-

-        /* If d >= 0 we have a range. In UTF-8 mode, if the end is > 255, or >

-        127 for caseless matching, we will need to use an XCLASS. */

-

-        if (d >= 0)

-          {

-          class_optcount = 10;     /* Ensure > 1 */

-          if (d < c)

-            {

-            errorcode = ERR8;

-            goto PCRE_ERROR_RETURN;

-            }

-

-#ifdef SUPPORT_UTF8

-          if (utf8 && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))

-            {

-            uschar buffer[6];

-            if (!class_utf8)         /* Allow for XCLASS overhead */

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-

-#ifdef SUPPORT_UCP

-            /* If we have UCP support, find out how many extra ranges are

-            needed to map the other case of characters within this range. We

-            have to mimic the range optimization here, because extending the

-            range upwards might push d over a boundary that makes is use

-            another byte in the UTF-8 representation. */

-

-            if ((options & PCRE_CASELESS) != 0)

-              {

-              int occ, ocd;

-              int cc = c;

-              int origd = d;

-              while (get_othercase_range(&cc, origd, &occ, &ocd))

-                {

-                if (occ >= c && ocd <= d) continue;   /* Skip embedded */

-

-                if (occ < c  && ocd >= c - 1)  /* Extend the basic range */

-                  {                            /* if there is overlap,   */

-                  c = occ;                     /* noting that if occ < c */

-                  continue;                    /* we can't have ocd > d  */

-                  }                            /* because a subrange is  */

-                if (ocd > d && occ <= d + 1)   /* always shorter than    */

-                  {                            /* the basic range.       */

-                  d = ocd;

-                  continue;

-                  }

-

-                /* An extra item is needed */

-

-                length += 1 + _pcre_ord2utf8(occ, buffer) +

-                  ((occ == ocd)? 0 : _pcre_ord2utf8(ocd, buffer));

-                }

-              }

-#endif  /* SUPPORT_UCP */

-

-            /* The length of the (possibly extended) range */

-

-            length += 1 + _pcre_ord2utf8(c, buffer) + _pcre_ord2utf8(d, buffer);

-            }

-#endif  /* SUPPORT_UTF8 */

-

-          }

-

-        /* We have a single character. There is nothing to be done unless we

-        are in UTF-8 mode. If the char is > 255, or 127 when caseless, we must

-        allow for an XCL_SINGLE item, doubled for caselessness if there is UCP

-        support. */

-

-        else

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))

-            {

-            uschar buffer[6];

-            class_optcount = 10;     /* Ensure > 1 */

-            if (!class_utf8)         /* Allow for XCLASS overhead */

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-#ifdef SUPPORT_UCP

-            length += (((options & PCRE_CASELESS) != 0)? 2 : 1) *

-              (1 + _pcre_ord2utf8(c, buffer));

-#else   /* SUPPORT_UCP */

-            length += 1 + _pcre_ord2utf8(c, buffer);

-#endif  /* SUPPORT_UCP */

-            }

-#endif  /* SUPPORT_UTF8 */

-          }

-        }

-      }

-    while (*(++ptr) != 0 && (inescq || *ptr != ']')); /* Concludes "do" above */

-

-    if (*ptr == 0)                          /* Missing terminating ']' */

-      {

-      errorcode = ERR6;

-      goto PCRE_ERROR_RETURN;

-      }

-

-    /* We can optimize when there was only one optimizable character. Repeats

-    for positive and negated single one-byte chars are handled by the general

-    code. Here, we handle repeats for the class opcodes. */

-

-    if (class_optcount == 1) length += 3; else

-      {

-      length += 33;

-

-      /* A repeat needs either 1 or 5 bytes. If it is a possessive quantifier,

-      we also need extra for wrapping the whole thing in a sub-pattern. */

-

-      if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr+2))

-        {

-        ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-        if ((min == 0 && (max == 1 || max == -1)) ||

-          (min == 1 && max == -1))

-            length++;

-        else length += 5;

-        if (ptr[1] == '+')

-          {

-          ptr++;

-          length += 2 + 2*LINK_SIZE;

-          }

-        else if (ptr[1] == '?') ptr++;

-        }

-      }

-    continue;

-

-    /* Brackets may be genuine groups or special things */

-

-    case '(':

-    branch_newextra = 0;

-    bracket_length = 1 + LINK_SIZE;

-    capturing = FALSE;

-

-    /* Handle special forms of bracket, which all start (? */

-

-    if (ptr[1] == '?')

-      {

-      int set, unset;

-      int *optset;

-

-      switch (c = ptr[2])

-        {

-        /* Skip over comments entirely */

-        case '#':

-        ptr += 3;

-        while (*ptr != 0 && *ptr != ')') ptr++;

-        if (*ptr == 0)

-          {

-          errorcode = ERR18;

-          goto PCRE_ERROR_RETURN;

-          }

-        continue;

-

-        /* Non-referencing groups and lookaheads just move the pointer on, and

-        then behave like a non-special bracket, except that they don't increment

-        the count of extracting brackets. Ditto for the "once only" bracket,

-        which is in Perl from version 5.005. */

-

-        case ':':

-        case '=':

-        case '!':

-        case '>':

-        ptr += 2;

-        break;

-

-        /* (?R) specifies a recursive call to the regex, which is an extension

-        to provide the facility which can be obtained by (?p{perl-code}) in

-        Perl 5.6. In Perl 5.8 this has become (??{perl-code}).

-

-        From PCRE 4.00, items such as (?3) specify subroutine-like "calls" to

-        the appropriate numbered brackets. This includes both recursive and

-        non-recursive calls. (?R) is now synonymous with (?0). */

-

-        case 'R':

-        ptr++;

-

-        case '0': case '1': case '2': case '3': case '4':

-        case '5': case '6': case '7': case '8': case '9':

-        ptr += 2;

-        if (c != 'R')

-          while ((digitab[*(++ptr)] & ctype_digit) != 0);

-        if (*ptr != ')')

-          {

-          errorcode = ERR29;

-          goto PCRE_ERROR_RETURN;

-          }

-        length += 1 + LINK_SIZE;

-

-        /* If this item is quantified, it will get wrapped inside brackets so

-        as to use the code for quantified brackets. We jump down and use the

-        code that handles this for real brackets. */

-

-        if (ptr[1] == '+' || ptr[1] == '*' || ptr[1] == '?' || ptr[1] == '{')

-          {

-          length += 2 + 2 * LINK_SIZE;       /* to make bracketed */

-          duplength = 5 + 3 * LINK_SIZE;

-          goto HANDLE_QUANTIFIED_BRACKETS;

-          }

-        continue;

-

-        /* (?C) is an extension which provides "callout" - to provide a bit of

-        the functionality of the Perl (?{...}) feature. An optional number may

-        follow (default is zero). */

-

-        case 'C':

-        ptr += 2;

-        while ((digitab[*(++ptr)] & ctype_digit) != 0);

-        if (*ptr != ')')

-          {

-          errorcode = ERR39;

-          goto PCRE_ERROR_RETURN;

-          }

-        length += 2 + 2*LINK_SIZE;

-        continue;

-

-        /* Named subpatterns are an extension copied from Python */

-

-        case 'P':

-        ptr += 3;

-

-        /* Handle the definition of a named subpattern */

-

-        if (*ptr == '<')

-          {

-          const uschar *p;    /* Don't amalgamate; some compilers */

-          p = ++ptr;          /* grumble at autoincrement in declaration */

-          while ((compile_block.ctypes[*ptr] & ctype_word) != 0) ptr++;

-          if (*ptr != '>')

-            {

-            errorcode = ERR42;

-            goto PCRE_ERROR_RETURN;

-            }

-          name_count++;

-          if (ptr - p > max_name_size) max_name_size = (ptr - p);

-          capturing = TRUE;   /* Named parentheses are always capturing */

-          break;

-          }

-

-        /* Handle back references and recursive calls to named subpatterns */

-

-        if (*ptr == '=' || *ptr == '>')

-          {

-          while ((compile_block.ctypes[*(++ptr)] & ctype_word) != 0);

-          if (*ptr != ')')

-            {

-            errorcode = ERR42;

-            goto PCRE_ERROR_RETURN;

-            }

-          break;

-          }

-

-        /* Unknown character after (?P */

-

-        errorcode = ERR41;

-        goto PCRE_ERROR_RETURN;

-

-        /* Lookbehinds are in Perl from version 5.005 */

-

-        case '<':

-        ptr += 3;

-        if (*ptr == '=' || *ptr == '!')

-          {

-          branch_newextra = 1 + LINK_SIZE;

-          length += 1 + LINK_SIZE;         /* For the first branch */

-          break;

-          }

-        errorcode = ERR24;

-        goto PCRE_ERROR_RETURN;

-

-        /* Conditionals are in Perl from version 5.005. The bracket must either

-        be followed by a number (for bracket reference) or by an assertion

-        group, or (a PCRE extension) by 'R' for a recursion test. */

-

-        case '(':

-        if (ptr[3] == 'R' && ptr[4] == ')')

-          {

-          ptr += 4;

-          length += 3;

-          }

-        else if ((digitab[ptr[3]] & ctype_digit) != 0)

-          {

-          ptr += 4;

-          length += 3;

-          while ((digitab[*ptr] & ctype_digit) != 0) ptr++;

-          if (*ptr != ')')

-            {

-            errorcode = ERR26;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-        else   /* An assertion must follow */

-          {

-          ptr++;   /* Can treat like ':' as far as spacing is concerned */

-          if (ptr[2] != '?' ||

-             (ptr[3] != '=' && ptr[3] != '!' && ptr[3] != '<') )

-            {

-            ptr += 2;    /* To get right offset in message */

-            errorcode = ERR28;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-        break;

-

-        /* Else loop checking valid options until ) is met. Anything else is an

-        error. If we are without any brackets, i.e. at top level, the settings

-        act as if specified in the options, so massage the options immediately.

-        This is for backward compatibility with Perl 5.004. */

-

-        default:

-        set = unset = 0;

-        optset = &set;

-        ptr += 2;

-

-        for (;; ptr++)

-          {

-          c = *ptr;

-          switch (c)

-            {

-            case 'i':

-            *optset |= PCRE_CASELESS;

-            continue;

-

-            case 'm':

-            *optset |= PCRE_MULTILINE;

-            continue;

-

-            case 's':

-            *optset |= PCRE_DOTALL;

-            continue;

-

-            case 'x':

-            *optset |= PCRE_EXTENDED;

-            continue;

-

-            case 'X':

-            *optset |= PCRE_EXTRA;

-            continue;

-

-            case 'U':

-            *optset |= PCRE_UNGREEDY;

-            continue;

-

-            case '-':

-            optset = &unset;

-            continue;

-

-            /* A termination by ')' indicates an options-setting-only item; if

-            this is at the very start of the pattern (indicated by item_count

-            being zero), we use it to set the global options. This is helpful

-            when analyzing the pattern for first characters, etc. Otherwise

-            nothing is done here and it is handled during the compiling

-            process.

-

-            We allow for more than one options setting at the start. If such

-            settings do not change the existing options, nothing is compiled.

-            However, we must leave space just in case something is compiled.

-            This can happen for pathological sequences such as (?i)(?-i)

-            because the global options will end up with -i set. The space is

-            small and not significant. (Before I did this there was a reported

-            bug with (?i)(?-i) in a machine-generated pattern.)

-

-            [Historical note: Up to Perl 5.8, options settings at top level

-            were always global settings, wherever they appeared in the pattern.

-            That is, they were equivalent to an external setting. From 5.8

-            onwards, they apply only to what follows (which is what you might

-            expect).] */

-

-            case ')':

-            if (item_count == 0)

-              {

-              options = (options | set) & (~unset);

-              set = unset = 0;     /* To save length */

-              item_count--;        /* To allow for several */

-              length += 2;

-              }

-

-            /* Fall through */

-

-            /* A termination by ':' indicates the start of a nested group with

-            the given options set. This is again handled at compile time, but

-            we must allow for compiled space if any of the ims options are

-            set. We also have to allow for resetting space at the end of

-            the group, which is why 4 is added to the length and not just 2.

-            If there are several changes of options within the same group, this

-            will lead to an over-estimate on the length, but this shouldn't

-            matter very much. We also have to allow for resetting options at

-            the start of any alternations, which we do by setting

-            branch_newextra to 2. Finally, we record whether the case-dependent

-            flag ever changes within the regex. This is used by the "required

-            character" code. */

-

-            case ':':

-            if (((set|unset) & PCRE_IMS) != 0)

-              {

-              length += 4;

-              branch_newextra = 2;

-              if (((set|unset) & PCRE_CASELESS) != 0) options |= PCRE_ICHANGED;

-              }

-            goto END_OPTIONS;

-

-            /* Unrecognized option character */

-

-            default:

-            errorcode = ERR12;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-

-        /* If we hit a closing bracket, that's it - this is a freestanding

-        option-setting. We need to ensure that branch_extra is updated if

-        necessary. The only values branch_newextra can have here are 0 or 2.

-        If the value is 2, then branch_extra must either be 2 or 5, depending

-        on whether this is a lookbehind group or not. */

-

-        END_OPTIONS:

-        if (c == ')')

-          {

-          if (branch_newextra == 2 &&

-              (branch_extra == 0 || branch_extra == 1+LINK_SIZE))

-            branch_extra += branch_newextra;

-          continue;

-          }

-

-        /* If options were terminated by ':' control comes here. This is a

-        non-capturing group with an options change. There is nothing more that

-        needs to be done because "capturing" is already set FALSE by default;

-        we can just fall through. */

-

-        }

-      }

-

-    /* Ordinary parentheses, not followed by '?', are capturing unless

-    PCRE_NO_AUTO_CAPTURE is set. */

-

-    else capturing = (options & PCRE_NO_AUTO_CAPTURE) == 0;

-

-    /* Capturing brackets must be counted so we can process escapes in a

-    Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to need

-    an additional 3 bytes of memory per capturing bracket. */

-

-    if (capturing)

-      {

-      bracount++;

-      if (bracount > EXTRACT_BASIC_MAX) bracket_length += 3;

-      }

-

-    /* Save length for computing whole length at end if there's a repeat that

-    requires duplication of the group. Also save the current value of

-    branch_extra, and start the new group with the new value. If non-zero, this

-    will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */

-

-    if (brastackptr >= sizeof(brastack)/sizeof(int))

-      {

-      errorcode = ERR19;

-      goto PCRE_ERROR_RETURN;

-      }

-

-    bralenstack[brastackptr] = branch_extra;

-    branch_extra = branch_newextra;

-

-    brastack[brastackptr++] = length;

-    length += bracket_length;

-    continue;

-

-    /* Handle ket. Look for subsequent max/min; for certain sets of values we

-    have to replicate this bracket up to that many times. If brastackptr is

-    0 this is an unmatched bracket which will generate an error, but take care

-    not to try to access brastack[-1] when computing the length and restoring

-    the branch_extra value. */

-

-    case ')':

-    length += 1 + LINK_SIZE;

-    if (brastackptr > 0)

-      {

-      duplength = length - brastack[--brastackptr];

-      branch_extra = bralenstack[brastackptr];

-      }

-    else duplength = 0;

-

-    /* The following code is also used when a recursion such as (?3) is

-    followed by a quantifier, because in that case, it has to be wrapped inside

-    brackets so that the quantifier works. The value of duplength must be

-    set before arrival. */

-

-    HANDLE_QUANTIFIED_BRACKETS:

-

-    /* Leave ptr at the final char; for read_repeat_counts this happens

-    automatically; for the others we need an increment. */

-

-    if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2))

-      {

-      ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-      if (errorcode != 0) goto PCRE_ERROR_RETURN;

-      }

-    else if (c == '*') { min = 0; max = -1; ptr++; }

-    else if (c == '+') { min = 1; max = -1; ptr++; }

-    else if (c == '?') { min = 0; max = 1;  ptr++; }

-    else { min = 1; max = 1; }

-

-    /* If the minimum is zero, we have to allow for an OP_BRAZERO before the

-    group, and if the maximum is greater than zero, we have to replicate

-    maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting

-    bracket set. */

-

-    if (min == 0)

-      {

-      length++;

-      if (max > 0) length += (max - 1) * (duplength + 3 + 2*LINK_SIZE);

-      }

-

-    /* When the minimum is greater than zero, we have to replicate up to

-    minval-1 times, with no additions required in the copies. Then, if there

-    is a limited maximum we have to replicate up to maxval-1 times allowing

-    for a BRAZERO item before each optional copy and nesting brackets for all

-    but one of the optional copies. */

-

-    else

-      {

-      length += (min - 1) * duplength;

-      if (max > min)   /* Need this test as max=-1 means no limit */

-        length += (max - min) * (duplength + 3 + 2*LINK_SIZE)

-          - (2 + 2*LINK_SIZE);

-      }

-

-    /* Allow space for once brackets for "possessive quantifier" */

-

-    if (ptr[1] == '+')

-      {

-      ptr++;

-      length += 2 + 2*LINK_SIZE;

-      }

-    continue;

-

-    /* Non-special character. It won't be space or # in extended mode, so it is

-    always a genuine character. If we are in a \Q...\E sequence, check for the

-    end; if not, we have a literal. */

-

-    default:

-    NORMAL_CHAR:

-

-    if (inescq && c == '\\' && ptr[1] == 'E')

-      {

-      inescq = FALSE;

-      ptr++;

-      continue;

-      }

-

-    length += 2;          /* For a one-byte character */

-    lastitemlength = 1;   /* Default length of last item for repeats */

-

-    /* In UTF-8 mode, check for additional bytes. */

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && (c & 0xc0) == 0xc0)

-      {

-      while ((ptr[1] & 0xc0) == 0x80)         /* Can't flow over the end */

-        {                                     /* because the end is marked */

-        lastitemlength++;                     /* by a zero byte. */

-        length++;

-        ptr++;

-        }

-      }

-#endif

-

-    continue;

-    }

-  }

-

-length += 2 + LINK_SIZE;    /* For final KET and END */

-

-if ((options & PCRE_AUTO_CALLOUT) != 0)

-  length += 2 + 2*LINK_SIZE;  /* For final callout */

-

-if (length > MAX_PATTERN_SIZE)

-  {

-  errorcode = ERR20;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Compute the size of data block needed and get it, either from malloc or

-externally provided function. */

-

-size = length + sizeof(real_pcre) + name_count * (max_name_size + 3);

-re = (real_pcre *)(pcre_malloc)(size);

-

-if (re == NULL)

-  {

-  errorcode = ERR21;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Put in the magic number, and save the sizes, options, and character table

-pointer. NULL is used for the default character tables. The nullpad field is at

-the end; it's there to help in the case when a regex compiled on a system with

-4-byte pointers is run on another with 8-byte pointers. */

-

-re->magic_number = MAGIC_NUMBER;

-re->size = size;

-re->options = options;

-re->dummy1 = 0;

-re->name_table_offset = sizeof(real_pcre);

-re->name_entry_size = max_name_size + 3;

-re->name_count = name_count;

-re->ref_count = 0;

-re->tables = (tables == _pcre_default_tables)? NULL : tables;

-re->nullpad = NULL;

-

-/* The starting points of the name/number translation table and of the code are

-passed around in the compile data block. */

-

-compile_block.names_found = 0;

-compile_block.name_entry_size = max_name_size + 3;

-compile_block.name_table = (uschar *)re + re->name_table_offset;

-codestart = compile_block.name_table + re->name_entry_size * re->name_count;

-compile_block.start_code = codestart;

-compile_block.start_pattern = (const uschar *)pattern;

-compile_block.req_varyopt = 0;

-compile_block.nopartial = FALSE;

-

-/* Set up a starting, non-extracting bracket, then compile the expression. On

-error, errorcode will be set non-zero, so we don't need to look at the result

-of the function here. */

-

-ptr = (const uschar *)pattern;

-code = (uschar *)codestart;

-*code = OP_BRA;

-bracount = 0;

-(void)compile_regex(options, options & PCRE_IMS, &bracount, &code, &ptr,

-  &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, &compile_block);

-re->top_bracket = bracount;

-re->top_backref = compile_block.top_backref;

-

-if (compile_block.nopartial) re->options |= PCRE_NOPARTIAL;

-

-/* If not reached end of pattern on success, there's an excess bracket. */

-

-if (errorcode == 0 && *ptr != 0) errorcode = ERR22;

-

-/* Fill in the terminating state and check for disastrous overflow, but

-if debugging, leave the test till after things are printed out. */

-

-*code++ = OP_END;

-

-#ifndef DEBUG

-if (code - codestart > length) errorcode = ERR23;

-#endif

-

-/* Give an error if there's back reference to a non-existent capturing

-subpattern. */

-

-if (re->top_backref > re->top_bracket) errorcode = ERR15;

-

-/* Failed to compile, or error while post-processing */

-

-if (errorcode != 0)

-  {

-  (pcre_free)(re);

-  PCRE_ERROR_RETURN:

-  *erroroffset = ptr - (const uschar *)pattern;

-  PCRE_EARLY_ERROR_RETURN:

-  *errorptr = error_texts[errorcode];

-  if (errorcodeptr != NULL) *errorcodeptr = errorcode;

-  return NULL;

-  }

-

-/* If the anchored option was not passed, set the flag if we can determine that

-the pattern is anchored by virtue of ^ characters or \A or anything else (such

-as starting with .* when DOTALL is set).

-

-Otherwise, if we know what the first character has to be, save it, because that

-speeds up unanchored matches no end. If not, see if we can set the

-PCRE_STARTLINE flag. This is helpful for multiline matches when all branches

-start with ^. and also when all branches start with .* for non-DOTALL matches.

-*/

-

-if ((options & PCRE_ANCHORED) == 0)

-  {

-  int temp_options = options;

-  if (is_anchored(codestart, &temp_options, 0, compile_block.backref_map))

-    re->options |= PCRE_ANCHORED;

-  else

-    {

-    if (firstbyte < 0)

-      firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);

-    if (firstbyte >= 0)   /* Remove caseless flag for non-caseable chars */

-      {

-      int ch = firstbyte & 255;

-      re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&

-         compile_block.fcc[ch] == ch)? ch : firstbyte;

-      re->options |= PCRE_FIRSTSET;

-      }

-    else if (is_startline(codestart, 0, compile_block.backref_map))

-      re->options |= PCRE_STARTLINE;

-    }

-  }

-

-/* For an anchored pattern, we use the "required byte" only if it follows a

-variable length item in the regex. Remove the caseless flag for non-caseable

-bytes. */

-

-if (reqbyte >= 0 &&

-     ((re->options & PCRE_ANCHORED) == 0 || (reqbyte & REQ_VARY) != 0))

-  {

-  int ch = reqbyte & 255;

-  re->req_byte = ((reqbyte & REQ_CASELESS) != 0 &&

-    compile_block.fcc[ch] == ch)? (reqbyte & ~REQ_CASELESS) : reqbyte;

-  re->options |= PCRE_REQCHSET;

-  }

-

-/* Print out the compiled data for debugging */

-

-#ifdef DEBUG

-

-printf("Length = %d top_bracket = %d top_backref = %d\n",

-  length, re->top_bracket, re->top_backref);

-

-if (re->options != 0)

-  {

-  printf("%s%s%s%s%s%s%s%s%s%s\n",

-    ((re->options & PCRE_NOPARTIAL) != 0)? "nopartial " : "",

-    ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",

-    ((re->options & PCRE_CASELESS) != 0)? "caseless " : "",

-    ((re->options & PCRE_ICHANGED) != 0)? "case state changed " : "",

-    ((re->options & PCRE_EXTENDED) != 0)? "extended " : "",

-    ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",

-    ((re->options & PCRE_DOTALL) != 0)? "dotall " : "",

-    ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",

-    ((re->options & PCRE_EXTRA) != 0)? "extra " : "",

-    ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : "");

-  }

-

-if ((re->options & PCRE_FIRSTSET) != 0)

-  {

-  int ch = re->first_byte & 255;

-  const char *caseless = ((re->first_byte & REQ_CASELESS) == 0)? "" : " (caseless)";

-  if (isprint(ch)) printf("First char = %c%s\n", ch, caseless);

-    else printf("First char = \\x%02x%s\n", ch, caseless);

-  }

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  int ch = re->req_byte & 255;

-  const char *caseless = ((re->req_byte & REQ_CASELESS) == 0)? "" : " (caseless)";

-  if (isprint(ch)) printf("Req char = %c%s\n", ch, caseless);

-    else printf("Req char = \\x%02x%s\n", ch, caseless);

-  }

-

-_pcre_printint(re, stdout);

-

-/* This check is done here in the debugging case so that the code that

-was compiled can be seen. */

-

-if (code - codestart > length)

-  {

-  (pcre_free)(re);

-  *errorptr = error_texts[ERR23];

-  *erroroffset = ptr - (uschar *)pattern;

-  if (errorcodeptr != NULL) *errorcodeptr = ERR23;

-  return NULL;

-  }

-#endif

-

-return (pcre *)re;

-}

-

-/* End of pcre_compile.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_config(). */

-

-

-

-

-/*************************************************

-* Return info about what features are configured *

-*************************************************/

-

-/* This function has an extensible interface so that additional items can be

-added compatibly.

-

-Arguments:

-  what             what information is required

-  where            where to put the information

-

-Returns:           0 if data returned, negative on error

-*/

-

-EXPORT int

-pcre_config(int what, void *where)

-{

-switch (what)

-  {

-  case PCRE_CONFIG_UTF8:

-#ifdef SUPPORT_UTF8

-  *((int *)where) = 1;

-#else

-  *((int *)where) = 0;

-#endif

-  break;

-

-  case PCRE_CONFIG_UNICODE_PROPERTIES:

-#ifdef SUPPORT_UCP

-  *((int *)where) = 1;

-#else

-  *((int *)where) = 0;

-#endif

-  break;

-

-  case PCRE_CONFIG_NEWLINE:

-  *((int *)where) = NEWLINE;

-  break;

-

-  case PCRE_CONFIG_LINK_SIZE:

-  *((int *)where) = LINK_SIZE;

-  break;

-

-  case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:

-  *((int *)where) = POSIX_MALLOC_THRESHOLD;

-  break;

-

-  case PCRE_CONFIG_MATCH_LIMIT:

-  *((unsigned int *)where) = MATCH_LIMIT;

-  break;

-

-  case PCRE_CONFIG_STACKRECURSE:

-#ifdef NO_RECURSE

-  *((int *)where) = 0;

-#else

-  *((int *)where) = 1;

-#endif

-  break;

-

-  default: return PCRE_ERROR_BADOPTION;

-  }

-

-return 0;

-}

-

-/* End of pcre_config.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_dfa_exec(), which is an

-alternative matching function that uses a DFA algorithm. This is NOT Perl-

-compatible, but it has advantages in certain applications. */

-

-

-

-

-/* For use to indent debugging output */

-

-#define SP "                   "

-

-

-

-/*************************************************

-*      Code parameters and static tables         *

-*************************************************/

-

-/* These are offsets that are used to turn the OP_TYPESTAR and friends opcodes

-into others, under special conditions. A gap of 10 between the blocks should be

-enough. */

-

-#define OP_PROP_EXTRA    (EXTRACT_BASIC_MAX+1)

-#define OP_EXTUNI_EXTRA  (EXTRACT_BASIC_MAX+11)

-

-

-/* This table identifies those opcodes that are followed immediately by a

-character that is to be tested in some way. This makes is possible to

-centralize the loading of these characters. In the case of Type * etc, the

-"character" is the opcode for \D, \d, \S, \s, \W, or \w, which will always be a

-small value. */

-

-static uschar coptable[] = {

-  0,                             /* End                                    */

-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* \A, \G, \B, \b, \D, \d, \S, \s, \W, \w */

-  0, 0,                          /* Any, Anybyte                           */

-  0, 0, 0,                       /* NOTPROP, PROP, EXTUNI                  */

-  0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */

-  1,                             /* Char                                   */

-  1,                             /* Charnc                                 */

-  1,                             /* not                                    */

-  /* Positive single-char repeats                                          */

-  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */

-  3, 3, 3,                       /* upto, minupto, exact                   */

-  /* Negative single-char repeats - only for chars < 256                   */

-  1, 1, 1, 1, 1, 1,              /* NOT *, *?, +, +?, ?, ??                */

-  3, 3, 3,                       /* NOT upto, minupto, exact               */

-  /* Positive type repeats                                                 */

-  1, 1, 1, 1, 1, 1,              /* Type *, *?, +, +?, ?, ??               */

-  3, 3, 3,                       /* Type upto, minupto, exact              */

-  /* Character class & ref repeats                                         */

-  0, 0, 0, 0, 0, 0,              /* *, *?, +, +?, ?, ??                    */

-  0, 0,                          /* CRRANGE, CRMINRANGE                    */

-  0,                             /* CLASS                                  */

-  0,                             /* NCLASS                                 */

-  0,                             /* XCLASS - variable length               */

-  0,                             /* REF                                    */

-  0,                             /* RECURSE                                */

-  0,                             /* CALLOUT                                */

-  0,                             /* Alt                                    */

-  0,                             /* Ket                                    */

-  0,                             /* KetRmax                                */

-  0,                             /* KetRmin                                */

-  0,                             /* Assert                                 */

-  0,                             /* Assert not                             */

-  0,                             /* Assert behind                          */

-  0,                             /* Assert behind not                      */

-  0,                             /* Reverse                                */

-  0,                             /* Once                                   */

-  0,                             /* COND                                   */

-  0,                             /* CREF                                   */

-  0, 0,                          /* BRAZERO, BRAMINZERO                    */

-  0,                             /* BRANUMBER                              */

-  0                              /* BRA                                    */

-};

-

-/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,

-and \w */

-

-static uschar toptable1[] = {

-  0, 0, 0, 0, 0,

-  ctype_digit, ctype_digit,

-  ctype_space, ctype_space,

-  ctype_word,  ctype_word,

-  0                               /* OP_ANY */

-};

-

-static uschar toptable2[] = {

-  0, 0, 0, 0, 0,

-  ctype_digit, 0,

-  ctype_space, 0,

-  ctype_word,  0,

-  1                               /* OP_ANY */

-};

-

-

-/* Structure for holding data about a particular state, which is in effect the

-current data for an active path through the match tree. It must consist

-entirely of ints because the working vector we are passed, and which we put

-these structures in, is a vector of ints. */

-

-typedef struct stateblock {

-  int offset;                     /* Offset to opcode */

-  int count;                      /* Count for repeats */

-  int ims;                        /* ims flag bits */

-  int data;                       /* Some use extra data */

-} stateblock;

-

-#define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))

-

-

-#ifdef DEBUG

-/*************************************************

-*             Print character string             *

-*************************************************/

-

-/* Character string printing function for debugging.

-

-Arguments:

-  p            points to string

-  length       number of bytes

-  f            where to print

-

-Returns:       nothing

-*/

-

-static void

-pchars(unsigned char *p, int length, FILE *f)

-{

-int c;

-while (length-- > 0)

-  {

-  if (isprint(c = *(p++)))

-    fprintf(f, "%c", c);

-  else

-    fprintf(f, "\\x%02x", c);

-  }

-}

-#endif

-

-

-

-/*************************************************

-*    Execute a Regular Expression - DFA engine   *

-*************************************************/

-

-/* This internal function applies a compiled pattern to a subject string,

-starting at a given point, using a DFA engine. This function is called from the

-external one, possibly multiple times if the pattern is not anchored. The

-function calls itself recursively for some kinds of subpattern.

-

-Arguments:

-  md                the match_data block with fixed information

-  this_start_code   the opening bracket of this subexpression's code

-  current_subject   where we currently are in the subject string

-  start_offset      start offset in the subject string

-  offsets           vector to contain the matching string offsets

-  offsetcount       size of same

-  workspace         vector of workspace

-  wscount           size of same

-  ims               the current ims flags

-  rlevel            function call recursion level

-  recursing         regex recursive call level

-

-Returns:            > 0 =>

-                    = 0 =>

-                     -1 => failed to match

-                   < -1 => some kind of unexpected problem

-

-The following macros are used for adding states to the two state vectors (one

-for the current character, one for the following character). */

-

-#define ADD_ACTIVE(x,y) \

-  if (active_count++ < wscount) \

-    { \

-    next_active_state->offset = (x); \

-    next_active_state->count  = (y); \

-    next_active_state->ims    = ims; \

-    next_active_state++; \

-    DPRINTF(("%.*sADD_ACTIVE(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_ACTIVE_DATA(x,y,z) \

-  if (active_count++ < wscount) \

-    { \

-    next_active_state->offset = (x); \

-    next_active_state->count  = (y); \

-    next_active_state->ims    = ims; \

-    next_active_state->data   = (z); \

-    next_active_state++; \

-    DPRINTF(("%.*sADD_ACTIVE_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_NEW(x,y) \

-  if (new_count++ < wscount) \

-    { \

-    next_new_state->offset = (x); \

-    next_new_state->count  = (y); \

-    next_new_state->ims    = ims; \

-    next_new_state++; \

-    DPRINTF(("%.*sADD_NEW(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_NEW_DATA(x,y,z) \

-  if (new_count++ < wscount) \

-    { \

-    next_new_state->offset = (x); \

-    next_new_state->count  = (y); \

-    next_new_state->ims    = ims; \

-    next_new_state->data   = (z); \

-    next_new_state++; \

-    DPRINTF(("%.*sADD_NEW_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-/* And now, here is the code */

-

-static int

-internal_dfa_exec(

-  dfa_match_data *md,

-  const uschar *this_start_code,

-  const uschar *current_subject,

-  int start_offset,

-  int *offsets,

-  int offsetcount,

-  int *workspace,

-  int wscount,

-  int ims,

-  int  rlevel,

-  int  recursing)

-{

-stateblock *active_states, *new_states, *temp_states;

-stateblock *next_active_state, *next_new_state;

-

-const uschar *ctypes, *lcc, *fcc;

-const uschar *ptr;

-const uschar *end_code;

-

-int active_count, new_count, match_count;

-

-/* Some fields in the md block are frequently referenced, so we load them into

-independent variables in the hope that this will perform better. */

-

-const uschar *start_subject = md->start_subject;

-const uschar *end_subject = md->end_subject;

-const uschar *start_code = md->start_code;

-

-BOOL utf8 = (md->poptions & PCRE_UTF8) != 0;

-

-rlevel++;

-offsetcount &= (-2);

-

-wscount -= 2;

-wscount = (wscount - (wscount % (INTS_PER_STATEBLOCK * 2))) /

-          (2 * INTS_PER_STATEBLOCK);

-

-DPRINTF(("\n%.*s---------------------\n"

-  "%.*sCall to internal_dfa_exec f=%d r=%d\n",

-  rlevel*2-2, SP, rlevel*2-2, SP, rlevel, recursing));

-

-ctypes = md->tables + ctypes_offset;

-lcc = md->tables + lcc_offset;

-fcc = md->tables + fcc_offset;

-

-match_count = PCRE_ERROR_NOMATCH;   /* A negative number */

-

-active_states = (stateblock *)(workspace + 2);

-next_new_state = new_states = active_states + wscount;

-new_count = 0;

-

-/* The first thing in any (sub) pattern is a bracket of some sort. Push all

-the alternative states onto the list, and find out where the end is. This

-makes is possible to use this function recursively, when we want to stop at a

-matching internal ket rather than at the end.

-

-If the first opcode in the first alternative is OP_REVERSE, we are dealing with

-a backward assertion. In that case, we have to find out the maximum amount to

-move back, and set up each alternative appropriately. */

-

-if (this_start_code[1+LINK_SIZE] == OP_REVERSE)

-  {

-  int max_back = 0;

-  int gone_back;

-

-  end_code = this_start_code;

-  do

-    {

-    int back = GET(end_code, 2+LINK_SIZE);

-    if (back > max_back) max_back = back;

-    end_code += GET(end_code, 1);

-    }

-  while (*end_code == OP_ALT);

-

-  /* If we can't go back the amount required for the longest lookbehind

-  pattern, go back as far as we can; some alternatives may still be viable. */

-

-#ifdef SUPPORT_UTF8

-  /* In character mode we have to step back character by character */

-

-  if (utf8)

-    {

-    for (gone_back = 0; gone_back < max_back; gone_back++)

-      {

-      if (current_subject <= start_subject) break;

-      current_subject--;

-      while (current_subject > start_subject &&

-             (*current_subject & 0xc0) == 0x80)

-        current_subject--;

-      }

-    }

-  else

-#endif

-

-  /* In byte-mode we can do this quickly. */

-

-    {

-    gone_back = (current_subject - max_back < start_subject)?

-      current_subject - start_subject : max_back;

-    current_subject -= gone_back;

-    }

-

-  /* Now we can process the individual branches. */

-

-  end_code = this_start_code;

-  do

-    {

-    int back = GET(end_code, 2+LINK_SIZE);

-    if (back <= gone_back)

-      {

-      int bstate = end_code - start_code + 2 + 2*LINK_SIZE;

-      ADD_NEW_DATA(-bstate, 0, gone_back - back);

-      }

-    end_code += GET(end_code, 1);

-    }

-  while (*end_code == OP_ALT);

- }

-

-/* This is the code for a "normal" subpattern (not a backward assertion). The

-start of a whole pattern is always one of these. If we are at the top level,

-we may be asked to restart matching from the same point that we reached for a

-previous partial match. We still have to scan through the top-level branches to

-find the end state. */

-

-else

-  {

-  end_code = this_start_code;

-

-  /* Restarting */

-

-  if (rlevel == 1 && (md->moptions & PCRE_DFA_RESTART) != 0)

-    {

-    do { end_code += GET(end_code, 1); } while (*end_code == OP_ALT);

-    new_count = workspace[1];

-    if (!workspace[0])

-      memcpy(new_states, active_states, new_count * sizeof(stateblock));

-    }

-

-  /* Not restarting */

-

-  else

-    {

-    do

-      {

-      ADD_NEW(end_code - start_code + 1 + LINK_SIZE, 0);

-      end_code += GET(end_code, 1);

-      }

-    while (*end_code == OP_ALT);

-    }

-  }

-

-workspace[0] = 0;    /* Bit indicating which vector is current */

-

-DPRINTF(("%.*sEnd state = %d\n", rlevel*2-2, SP, end_code - start_code));

-

-/* Loop for scanning the subject */

-

-ptr = current_subject;

-for (;;)

-  {

-  int i, j;

-  int c, d, clen, dlen;

-

-  /* Make the new state list into the active state list and empty the

-  new state list. */

-

-  temp_states = active_states;

-  active_states = new_states;

-  new_states = temp_states;

-  active_count = new_count;

-  new_count = 0;

-

-  workspace[0] ^= 1;              /* Remember for the restarting feature */

-  workspace[1] = active_count;

-

-#ifdef DEBUG

-  printf("%.*sNext character: rest of subject = \"", rlevel*2-2, SP);

-  pchars((uschar *)ptr, strlen((char *)ptr), stdout);

-  printf("\"\n");

-

-  printf("%.*sActive states: ", rlevel*2-2, SP);

-  for (i = 0; i < active_count; i++)

-    printf("%d/%d ", active_states[i].offset, active_states[i].count);

-  printf("\n");

-#endif

-

-  /* Set the pointers for adding new states */

-

-  next_active_state = active_states + active_count;

-  next_new_state = new_states;

-

-  /* Load the current character from the subject outside the loop, as many

-  different states may want to look at it, and we assume that at least one

-  will. */

-

-  if (ptr < end_subject)

-    {

-    clen = 1;

-#ifdef SUPPORT_UTF8

-    if (utf8) { GETCHARLEN(c, ptr, clen); } else

-#endif  /* SUPPORT_UTF8 */

-    c = *ptr;

-    }

-  else

-    {

-    clen = 0;    /* At end subject */

-    c = -1;

-    }

-

-  /* Scan up the active states and act on each one. The result of an action

-  may be to add more states to the currently active list (e.g. on hitting a

-  parenthesis) or it may be to put states on the new list, for considering

-  when we move the character pointer on. */

-

-  for (i = 0; i < active_count; i++)

-    {

-    stateblock *current_state = active_states + i;

-    const uschar *code;

-    int state_offset = current_state->offset;

-    int count, codevalue;

-    int chartype, othercase;

-

-#ifdef DEBUG

-    printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);

-    if (c < 0) printf("-1\n");

-      else if (c > 32 && c < 127) printf("'%c'\n", c);

-        else printf("0x%02x\n", c);

-#endif

-

-    /* This variable is referred to implicity in the ADD_xxx macros. */

-

-    ims = current_state->ims;

-

-    /* A negative offset is a special case meaning "hold off going to this

-    (negated) state until the number of characters in the data field have

-    been skipped". */

-

-    if (state_offset < 0)

-      {

-      if (current_state->data > 0)

-        {

-        DPRINTF(("%.*sSkipping this character\n", rlevel*2-2, SP));

-        ADD_NEW_DATA(state_offset, current_state->count,

-          current_state->data - 1);

-        continue;

-        }

-      else

-        {

-        current_state->offset = state_offset = -state_offset;

-        }

-      }

-

-    /* Check for a duplicate state with the same count, and skip if found. */

-

-    for (j = 0; j < i; j++)

-      {

-      if (active_states[j].offset == state_offset &&

-          active_states[j].count == current_state->count)

-        {

-        DPRINTF(("%.*sDuplicate state: skipped\n", rlevel*2-2, SP));

-        goto NEXT_ACTIVE_STATE;

-        }

-      }

-

-    /* The state offset is the offset to the opcode */

-

-    code = start_code + state_offset;

-    codevalue = *code;

-    if (codevalue >= OP_BRA) codevalue = OP_BRA; /* All brackets are equal */

-

-    /* If this opcode is followed by an inline character, load it. It is

-    tempting to test for the presence of a subject character here, but that

-    is wrong, because sometimes zero repetitions of the subject are

-    permitted.

-

-    We also use this mechanism for opcodes such as OP_TYPEPLUS that take an

-    argument that is not a data character - but is always one byte long.

-    Unfortunately, we have to take special action to deal with  \P, \p, and

-    \X in this case. To keep the other cases fast, convert these ones to new

-    opcodes. */

-

-    if (coptable[codevalue] > 0)

-      {

-      dlen = 1;

-#ifdef SUPPORT_UTF8

-      if (utf8) { GETCHARLEN(d, (code + coptable[codevalue]), dlen); } else

-#endif  /* SUPPORT_UTF8 */

-      d = code[coptable[codevalue]];

-      if (codevalue >= OP_TYPESTAR)

-        {

-        if (d == OP_ANYBYTE) return PCRE_ERROR_DFA_UITEM;

-        if (d >= OP_NOTPROP)

-          codevalue += (d == OP_EXTUNI)? OP_EXTUNI_EXTRA : OP_PROP_EXTRA;

-        }

-      }

-    else

-      {

-      dlen = 0;         /* Not strictly necessary, but compilers moan */

-      d = -1;           /* if these variables are not set. */

-      }

-

-

-    /* Now process the individual opcodes */

-

-    switch (codevalue)

-      {

-

-/* ========================================================================== */

-      /* Reached a closing bracket. If not at the end of the pattern, carry

-      on with the next opcode. Otherwise, unless we have an empty string and

-      PCRE_NOTEMPTY is set, save the match data, shifting up all previous

-      matches so we always have the longest first. */

-

-      case OP_KET:

-      case OP_KETRMIN:

-      case OP_KETRMAX:

-      if (code != end_code)

-        {

-        ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);

-        if (codevalue != OP_KET)

-          {

-          ADD_ACTIVE(state_offset - GET(code, 1), 0);

-          }

-        }

-      else if (ptr > current_subject || (md->moptions & PCRE_NOTEMPTY) == 0)

-        {

-        if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0;

-          else if (match_count > 0 && ++match_count * 2 >= offsetcount)

-            match_count = 0;

-        count = ((match_count == 0)? offsetcount : match_count * 2) - 2;

-        if (count > 0) memmove(offsets + 2, offsets, count * sizeof(int));

-        if (offsetcount >= 2)

-          {

-          offsets[0] = current_subject - start_subject;

-          offsets[1] = ptr - start_subject;

-          DPRINTF(("%.*sSet matched string = \"%.*s\"\n", rlevel*2-2, SP,

-            offsets[1] - offsets[0], current_subject));

-          }

-        if ((md->moptions & PCRE_DFA_SHORTEST) != 0)

-          {

-          DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"

-            "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel,

-            match_count, rlevel*2-2, SP));

-          return match_count;

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These opcodes add to the current list of states without looking

-      at the current character. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_ALT:

-      do { code += GET(code, 1); } while (*code == OP_ALT);

-      ADD_ACTIVE(code - start_code, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRA:

-      do

-        {

-        ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);

-        code += GET(code, 1);

-        }

-      while (*code == OP_ALT);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRAZERO:

-      case OP_BRAMINZERO:

-      ADD_ACTIVE(state_offset + 1, 0);

-      code += 1 + GET(code, 2);

-      while (*code == OP_ALT) code += GET(code, 1);

-      ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRANUMBER:

-      ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_CIRC:

-      if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||

-          ((ims & PCRE_MULTILINE) != 0 && ptr[-1] == NEWLINE))

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EOD:

-      if (ptr >= end_subject) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_OPT:

-      ims = code[1];

-      ADD_ACTIVE(state_offset + 2, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_SOD:

-      if (ptr == start_subject) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_SOM:

-      if (ptr == start_subject + start_offset) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-

-/* ========================================================================== */

-      /* These opcodes inspect the next subject character, and sometimes

-      the previous one as well, but do not have an argument. The variable

-      clen contains the length of the current character and is zero if we are

-      at the end of the subject. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_ANY:

-      if (clen > 0 && (c != NEWLINE || (ims & PCRE_DOTALL) != 0))

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EODN:

-      if (clen == 0 || (c == NEWLINE && ptr + 1 == end_subject))

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_DOLL:

-      if ((md->moptions & PCRE_NOTEOL) == 0)

-        {

-        if (clen == 0 || (c == NEWLINE && (ptr + 1 == end_subject ||

-                                (ims & PCRE_MULTILINE) != 0)))

-          { ADD_ACTIVE(state_offset + 1, 0); }

-        }

-      else if (c == NEWLINE && (ims & PCRE_MULTILINE) != 0)

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-

-      case OP_DIGIT:

-      case OP_WHITESPACE:

-      case OP_WORDCHAR:

-      if (clen > 0 && c < 256 &&

-            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0)

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_NOT_DIGIT:

-      case OP_NOT_WHITESPACE:

-      case OP_NOT_WORDCHAR:

-      if (clen > 0 && (c >= 256 ||

-            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0))

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_WORD_BOUNDARY:

-      case OP_NOT_WORD_BOUNDARY:

-        {

-        int left_word, right_word;

-

-        if (ptr > start_subject)

-          {

-          const uschar *temp = ptr - 1;

-#ifdef SUPPORT_UTF8

-          if (utf8) BACKCHAR(temp);

-#endif

-          GETCHARTEST(d, temp);

-          left_word = d < 256 && (ctypes[d] & ctype_word) != 0;

-          }

-        else left_word = 0;

-

-        if (clen > 0) right_word = c < 256 && (ctypes[c] & ctype_word) != 0;

-          else right_word = 0;

-

-        if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))

-          { ADD_ACTIVE(state_offset + 1, 0); }

-        }

-      break;

-

-

-#ifdef SUPPORT_UCP

-

-      /*-----------------------------------------------------------------*/

-      /* Check the next character by Unicode property. We will get here only

-      if the support is in the binary; otherwise a compile-time error occurs.

-      */

-

-      case OP_PROP:

-      case OP_NOTPROP:

-      if (clen > 0)

-        {

-        int rqdtype, category;

-        category = ucp_findchar(c, &chartype, &othercase);

-        rqdtype = code[1];

-        if (rqdtype >= 128)

-          {

-          if ((rqdtype - 128 == category) == (codevalue == OP_PROP))

-            { ADD_NEW(state_offset + 2, 0); }

-          }

-        else

-          {

-          if ((rqdtype == chartype) == (codevalue == OP_PROP))

-            { ADD_NEW(state_offset + 2, 0); }

-          }

-        }

-      break;

-#endif

-

-

-

-/* ========================================================================== */

-      /* These opcodes likewise inspect the subject character, but have an

-      argument that is not a data character. It is one of these opcodes:

-      OP_ANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, OP_WORDCHAR,

-      OP_NOT_WORDCHAR. The value is loaded into d. */

-

-      case OP_TYPEPLUS:

-      case OP_TYPEMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          count++;

-          ADD_NEW(state_offset, count);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPEQUERY:

-      case OP_TYPEMINQUERY:

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          ADD_NEW(state_offset + 2, 0);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPESTAR:

-      case OP_TYPEMINSTAR:

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          ADD_NEW(state_offset, 0);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPEEXACT:

-      case OP_TYPEUPTO:

-      case OP_TYPEMINUPTO:

-      if (codevalue != OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 4, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + 4, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These are virtual opcodes that are used when something like

-      OP_TYPEPLUS has OP_PROP, OP_NOTPROP, or OP_EXTUNI as its argument. It

-      keeps the code above fast for the other cases. The argument is in the

-      d variable. */

-

-      case OP_PROP_EXTRA + OP_TYPEPLUS:

-      case OP_PROP_EXTRA + OP_TYPEMINPLUS:

-      count = current_state->count;           /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 3, 0); }

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[2];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          { count++; ADD_NEW(state_offset, count); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEPLUS:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        count++;

-        ADD_NEW_DATA(-state_offset, count, ncount);

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PROP_EXTRA + OP_TYPEQUERY:

-      case OP_PROP_EXTRA + OP_TYPEMINQUERY:

-      count = 3;

-      goto QS1;

-

-      case OP_PROP_EXTRA + OP_TYPESTAR:

-      case OP_PROP_EXTRA + OP_TYPEMINSTAR:

-      count = 0;

-

-      QS1:

-

-      ADD_ACTIVE(state_offset + 3, 0);

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[2];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          { ADD_NEW(state_offset + count, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEQUERY:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINQUERY:

-      count = 2;

-      goto QS2;

-

-      case OP_EXTUNI_EXTRA + OP_TYPESTAR:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINSTAR:

-      count = 0;

-

-      QS2:

-

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        ADD_NEW_DATA(-(state_offset + count), 0, ncount);

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PROP_EXTRA + OP_TYPEEXACT:

-      case OP_PROP_EXTRA + OP_TYPEUPTO:

-      case OP_PROP_EXTRA + OP_TYPEMINUPTO:

-      if (codevalue != OP_PROP_EXTRA + OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 5, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[4];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + 5, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEEXACT:

-      case OP_EXTUNI_EXTRA + OP_TYPEUPTO:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINUPTO:

-      if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 4, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        if (++count >= GET2(code, 1))

-          { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }

-        else

-          { ADD_NEW_DATA(-state_offset, count, ncount); }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These opcodes are followed by a character that is usually compared

-      to the current subject character; it is loaded into d. We still get

-      here even if there is no subject character, because in some cases zero

-      repetitions are permitted. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_CHAR:

-      if (clen > 0 && c == d) { ADD_NEW(state_offset + dlen + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_CHARNC:

-      if (clen == 0) break;

-

-#ifdef SUPPORT_UTF8

-      if (utf8)

-        {

-        if (c == d) { ADD_NEW(state_offset + dlen + 1, 0); } else

-          {

-          if (c < 128) othercase = fcc[c]; else

-

-          /* If we have Unicode property support, we can use it to test the

-          other case of the character, if there is one. The result of

-          ucp_findchar() is < 0 if the char isn't found, and othercase is

-          returned as zero if there isn't another case. */

-

-#ifdef SUPPORT_UCP

-          if (ucp_findchar(c, &chartype, &othercase) < 0)

-#endif

-            othercase = -1;

-

-          if (d == othercase) { ADD_NEW(state_offset + dlen + 1, 0); }

-          }

-        }

-      else

-#endif  /* SUPPORT_UTF8 */

-

-      /* Non-UTF-8 mode */

-        {

-        if (lcc[c] == lcc[d]) { ADD_NEW(state_offset + 2, 0); }

-        }

-      break;

-

-

-#ifdef SUPPORT_UCP

-      /*-----------------------------------------------------------------*/

-      /* This is a tricky one because it can match more than one character.

-      Find out how many characters to skip, and then set up a negative state

-      to wait for them to pass before continuing. */

-

-      case OP_EXTUNI:

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nclen = 1;

-          GETCHARLEN(c, nptr, nclen);

-          if (ucp_findchar(c, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += nclen;

-          }

-        ADD_NEW_DATA(-(state_offset + 1), 0, ncount);

-        }

-      break;

-#endif

-

-      /*-----------------------------------------------------------------*/

-      /* Match a negated single character. This is only used for one-byte

-      characters, that is, we know that d < 256. The character we are

-      checking (c) can be multibyte. */

-

-      case OP_NOT:

-      if (clen > 0)

-        {

-        int otherd = ((ims & PCRE_CASELESS) != 0)? fcc[d] : d;

-        if (c != d && c != otherd) { ADD_NEW(state_offset + dlen + 1, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_NOTPLUS:

-      case OP_NOTMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + dlen + 1, 0); }

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims & PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(d, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { count++; ADD_NEW(state_offset, count); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_QUERY:

-      case OP_MINQUERY:

-      case OP_NOTQUERY:

-      case OP_NOTMINQUERY:

-      ADD_ACTIVE(state_offset + dlen + 1, 0);

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims && PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(c, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { ADD_NEW(state_offset + dlen + 1, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_NOTSTAR:

-      case OP_NOTMINSTAR:

-      ADD_ACTIVE(state_offset + dlen + 1, 0);

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims && PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(c, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { ADD_NEW(state_offset, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_NOTEXACT:

-      case OP_NOTUPTO:

-      case OP_NOTMINUPTO:

-      if (codevalue != OP_EXACT && codevalue != OP_NOTEXACT)

-        { ADD_ACTIVE(state_offset + dlen + 3, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims & PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(d, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + dlen + 3, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-

-/* ========================================================================== */

-      /* These are the class-handling opcodes */

-

-      case OP_CLASS:

-      case OP_NCLASS:

-      case OP_XCLASS:

-        {

-        BOOL isinclass = FALSE;

-        int next_state_offset;

-        const uschar *ecode;

-

-        /* For a simple class, there is always just a 32-byte table, and we

-        can set isinclass from it. */

-

-        if (codevalue != OP_XCLASS)

-          {

-          ecode = code + 33;

-          if (clen > 0)

-            {

-            isinclass = (c > 255)? (codevalue == OP_NCLASS) :

-              ((code[1 + c/8] & (1 << (c&7))) != 0);

-            }

-          }

-

-        /* An extended class may have a table or a list of single characters,

-        ranges, or both, and it may be positive or negative. There's a

-        function that sorts all this out. */

-

-        else

-         {

-         ecode = code + GET(code, 1);

-         if (clen > 0) isinclass = _pcre_xclass(c, code + 1 + LINK_SIZE);

-         }

-

-        /* At this point, isinclass is set for all kinds of class, and ecode

-        points to the byte after the end of the class. If there is a

-        quantifier, this is where it will be. */

-

-        next_state_offset = ecode - start_code;

-

-        switch (*ecode)

-          {

-          case OP_CRSTAR:

-          case OP_CRMINSTAR:

-          ADD_ACTIVE(next_state_offset + 1, 0);

-          if (isinclass) { ADD_NEW(state_offset, 0); }

-          break;

-

-          case OP_CRPLUS:

-          case OP_CRMINPLUS:

-          count = current_state->count;  /* Already matched */

-          if (count > 0) { ADD_ACTIVE(next_state_offset + 1, 0); }

-          if (isinclass) { count++; ADD_NEW(state_offset, count); }

-          break;

-

-          case OP_CRQUERY:

-          case OP_CRMINQUERY:

-          ADD_ACTIVE(next_state_offset + 1, 0);

-          if (isinclass) { ADD_NEW(next_state_offset + 1, 0); }

-          break;

-

-          case OP_CRRANGE:

-          case OP_CRMINRANGE:

-          count = current_state->count;  /* Already matched */

-          if (count >= GET2(ecode, 1))

-            { ADD_ACTIVE(next_state_offset + 5, 0); }

-          if (isinclass)

-            {

-            if (++count >= GET2(ecode, 3))

-              { ADD_NEW(next_state_offset + 5, 0); }

-            else

-              { ADD_NEW(state_offset, count); }

-            }

-          break;

-

-          default:

-          if (isinclass) { ADD_NEW(next_state_offset, 0); }

-          break;

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These are the opcodes for fancy brackets of various kinds. We have

-      to use recursion in order to handle them. */

-

-      case OP_ASSERT:

-      case OP_ASSERT_NOT:

-      case OP_ASSERTBACK:

-      case OP_ASSERTBACK_NOT:

-        {

-        int rc;

-        int local_offsets[2];

-        int local_workspace[1000];

-        const uschar *endasscode = code + GET(code, 1);

-

-        while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);

-

-        rc = internal_dfa_exec(

-          md,                                   /* static match data */

-          code,                                 /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing);                           /* pass on regex recursion */

-

-        if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK))

-            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_COND:

-        {

-        int local_offsets[1000];

-        int local_workspace[1000];

-        int condcode = code[LINK_SIZE+1];

-

-        /* The only supported version of OP_CREF is for the value 0xffff, which

-        means "test if in a recursion". */

-

-        if (condcode == OP_CREF)

-          {

-          int value = GET2(code, LINK_SIZE+2);

-          if (value != 0xffff) return PCRE_ERROR_DFA_UCOND;

-          if (recursing > 0) { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }

-            else { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }

-          }

-

-        /* Otherwise, the condition is an assertion */

-

-        else

-          {

-          int rc;

-          const uschar *asscode = code + LINK_SIZE + 1;

-          const uschar *endasscode = asscode + GET(asscode, 1);

-

-          while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);

-

-          rc = internal_dfa_exec(

-            md,                                   /* fixed match data */

-            asscode,                              /* this subexpression's code */

-            ptr,                                  /* where we currently are */

-            ptr - start_subject,                  /* start offset */

-            local_offsets,                        /* offset vector */

-            sizeof(local_offsets)/sizeof(int),    /* size of same */

-            local_workspace,                      /* workspace vector */

-            sizeof(local_workspace)/sizeof(int),  /* size of same */

-            ims,                                  /* the current ims flags */

-            rlevel,                               /* function recursion level */

-            recursing);                           /* pass on regex recursion */

-

-          if ((rc >= 0) ==

-                (condcode == OP_ASSERT || condcode == OP_ASSERTBACK))

-            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }

-          else

-            { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_RECURSE:

-        {

-        int local_offsets[1000];

-        int local_workspace[1000];

-        int rc;

-

-        DPRINTF(("%.*sStarting regex recursion %d\n", rlevel*2-2, SP,

-          recursing + 1));

-

-        rc = internal_dfa_exec(

-          md,                                   /* fixed match data */

-          start_code + GET(code, 1),            /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing + 1);                       /* regex recurse level */

-

-        DPRINTF(("%.*sReturn from regex recursion %d: rc=%d\n", rlevel*2-2, SP,

-          recursing + 1, rc));

-

-        /* Ran out of internal offsets */

-

-        if (rc == 0) return PCRE_ERROR_DFA_RECURSE;

-

-        /* For each successful matched substring, set up the next state with a

-        count of characters to skip before trying it. Note that the count is in

-        characters, not bytes. */

-

-        if (rc > 0)

-          {

-          for (rc = rc*2 - 2; rc >= 0; rc -= 2)

-            {

-            const uschar *p = start_subject + local_offsets[rc];

-            const uschar *pp = start_subject + local_offsets[rc+1];

-            int charcount = local_offsets[rc+1] - local_offsets[rc];

-            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;

-            if (charcount > 0)

-              {

-              ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, (charcount - 1));

-              }

-            else

-              {

-              ADD_ACTIVE(state_offset + LINK_SIZE + 1, 0);

-              }

-            }

-          }

-        else if (rc != PCRE_ERROR_NOMATCH) return rc;

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_ONCE:

-        {

-        const uschar *endcode;

-        int local_offsets[2];

-        int local_workspace[1000];

-

-        int rc = internal_dfa_exec(

-          md,                                   /* fixed match data */

-          code,                                 /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing);                           /* pass on regex recursion */

-

-        if (rc >= 0)

-          {

-          const uschar *end_subpattern = code;

-          int charcount = local_offsets[1] - local_offsets[0];

-          int next_state_offset, repeat_state_offset;

-          BOOL is_repeated;

-

-          do { end_subpattern += GET(end_subpattern, 1); }

-            while (*end_subpattern == OP_ALT);

-          next_state_offset = end_subpattern - start_code + LINK_SIZE + 1;

-

-          /* If the end of this subpattern is KETRMAX or KETRMIN, we must

-          arrange for the repeat state also to be added to the relevant list.

-          Calculate the offset, or set -1 for no repeat. */

-

-          repeat_state_offset = (*end_subpattern == OP_KETRMAX ||

-                                 *end_subpattern == OP_KETRMIN)?

-            end_subpattern - start_code - GET(end_subpattern, 1) : -1;

-

-          /* If we have matched an empty string, add the next state at the

-          current character pointer. This is important so that the duplicate

-          checking kicks in, which is what breaks infinite loops that match an

-          empty string. */

-

-          if (charcount == 0)

-            {

-            ADD_ACTIVE(next_state_offset, 0);

-            }

-

-          /* Optimization: if there are no more active states, and there

-          are no new states yet set up, then skip over the subject string

-          right here, to save looping. Otherwise, set up the new state to swing

-          into action when the end of the substring is reached. */

-

-          else if (i + 1 >= active_count && new_count == 0)

-            {

-            ptr += charcount;

-            clen = 0;

-            ADD_NEW(next_state_offset, 0);

-

-            /* If we are adding a repeat state at the new character position,

-            we must fudge things so that it is the only current state.

-            Otherwise, it might be a duplicate of one we processed before, and

-            that would cause it to be skipped. */

-

-            if (repeat_state_offset >= 0)

-              {

-              next_active_state = active_states;

-              active_count = 0;

-              i = -1;

-              ADD_ACTIVE(repeat_state_offset, 0);

-              }

-            }

-          else

-            {

-            const uschar *p = start_subject + local_offsets[0];

-            const uschar *pp = start_subject + local_offsets[1];

-            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;

-            ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));

-            if (repeat_state_offset >= 0)

-              { ADD_NEW_DATA(-repeat_state_offset, 0, (charcount - 1)); }

-            }

-

-          }

-        else if (rc != PCRE_ERROR_NOMATCH) return rc;

-        }

-      break;

-

-

-/* ========================================================================== */

-      /* Handle callouts */

-

-      case OP_CALLOUT:

-      if (pcre_callout != NULL)

-        {

-        int rrc;

-        pcre_callout_block cb;

-        cb.version          = 1;   /* Version 1 of the callout block */

-        cb.callout_number   = code[1];

-        cb.offset_vector    = offsets;

-        cb.subject          = (char *)start_subject;

-        cb.subject_length   = end_subject - start_subject;

-        cb.start_match      = current_subject - start_subject;

-        cb.current_position = ptr - start_subject;

-        cb.pattern_position = GET(code, 2);

-        cb.next_item_length = GET(code, 2 + LINK_SIZE);

-        cb.capture_top      = 1;

-        cb.capture_last     = -1;

-        cb.callout_data     = md->callout_data;

-        if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */

-        if (rrc == 0) { ADD_ACTIVE(state_offset + 2 + 2*LINK_SIZE, 0); }

-        }

-      break;

-

-

-/* ========================================================================== */

-      default:        /* Unsupported opcode */

-      return PCRE_ERROR_DFA_UITEM;

-      }

-

-    NEXT_ACTIVE_STATE: continue;

-

-    }      /* End of loop scanning active states */

-

-  /* We have finished the processing at the current subject character. If no

-  new states have been set for the next character, we have found all the

-  matches that we are going to find. If we are at the top level and partial

-  matching has been requested, check for appropriate conditions. */

-

-  if (new_count <= 0)

-    {

-    if (match_count < 0 &&                     /* No matches found */

-        rlevel == 1 &&                         /* Top level match function */

-        (md->moptions & PCRE_PARTIAL) != 0 &&  /* Want partial matching */

-        ptr >= end_subject &&                  /* Reached end of subject */

-        ptr > current_subject)                 /* Matched non-empty string */

-      {

-      if (offsetcount >= 2)

-        {

-        offsets[0] = current_subject - start_subject;

-        offsets[1] = end_subject - start_subject;

-        }

-      match_count = PCRE_ERROR_PARTIAL;

-      }

-

-    DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"

-      "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel, match_count,

-      rlevel*2-2, SP));

-    return match_count;

-    }

-

-  /* One or more states are active for the next character. */

-

-  ptr += clen;    /* Advance to next subject character */

-  }               /* Loop to move along the subject string */

-

-/* Control never gets here, but we must keep the compiler happy. */

-

-DPRINTF(("%.*s+++ Unexpected end of internal_dfa_exec %d +++\n"

-  "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel, rlevel*2-2, SP));

-return PCRE_ERROR_NOMATCH;

-}

-

-

-

-

-/*************************************************

-*    Execute a Regular Expression - DFA engine   *

-*************************************************/

-

-/* This external function applies a compiled re to a subject string using a DFA

-engine. This function calls the internal function multiple times if the pattern

-is not anchored.

-

-Arguments:

-  argument_re     points to the compiled expression

-  extra_data      points to extra data or is NULL (not currently used)

-  subject         points to the subject string

-  length          length of subject string (may contain binary zeros)

-  start_offset    where to start in the subject string

-  options         option bits

-  offsets         vector of match offsets

-  offsetcount     size of same

-  workspace       workspace vector

-  wscount         size of same

-

-Returns:          > 0 => number of match offset pairs placed in offsets

-                  = 0 => offsets overflowed; longest matches are present

-                   -1 => failed to match

-                 < -1 => some kind of unexpected problem

-*/

-

-EXPORT int

-pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,

-  const char *subject, int length, int start_offset, int options, int *offsets,

-  int offsetcount, int *workspace, int wscount)

-{

-real_pcre *re = (real_pcre *)argument_re;

-dfa_match_data match_block;

-BOOL utf8, anchored, startline, firstline;

-const uschar *current_subject, *end_subject, *lcc;

-

-pcre_study_data internal_study;

-const pcre_study_data *study = NULL;

-real_pcre internal_re;

-

-const uschar *req_byte_ptr;

-const uschar *start_bits = NULL;

-BOOL first_byte_caseless = FALSE;

-BOOL req_byte_caseless = FALSE;

-int first_byte = -1;

-int req_byte = -1;

-int req_byte2 = -1;

-

-/* Plausibility checks */

-

-if ((options & ~PUBLIC_DFA_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;

-if (re == NULL || subject == NULL || workspace == NULL ||

-   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;

-if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;

-if (wscount < 20) return PCRE_ERROR_DFA_WSSIZE;

-

-/* We need to find the pointer to any study data before we test for byte

-flipping, so we scan the extra_data block first. This may set two fields in the

-match block, so we must initialize them beforehand. However, the other fields

-in the match block must not be set until after the byte flipping. */

-

-match_block.tables = re->tables;

-match_block.callout_data = NULL;

-

-if (extra_data != NULL)

-  {

-  unsigned int flags = extra_data->flags;

-  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)

-    study = (const pcre_study_data *)extra_data->study_data;

-  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0) return PCRE_ERROR_DFA_UMLIMIT;

-  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)

-    match_block.callout_data = extra_data->callout_data;

-  if ((flags & PCRE_EXTRA_TABLES) != 0)

-    match_block.tables = extra_data->tables;

-  }

-

-/* Check that the first field in the block is the magic number. If it is not,

-test for a regex that was compiled on a host of opposite endianness. If this is

-the case, flipped values are put in internal_re and internal_study if there was

-study data too. */

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-/* Set some local values */

-

-current_subject = (const unsigned char *)subject + start_offset;

-end_subject = (const unsigned char *)subject + length;

-req_byte_ptr = current_subject - 1;

-

-utf8 = (re->options & PCRE_UTF8) != 0;

-anchored = (options & PCRE_ANCHORED) != 0 || (re->options & PCRE_ANCHORED) != 0;

-

-/* The remaining fixed data for passing around. */

-

-match_block.start_code = (const uschar *)argument_re +

-    re->name_table_offset + re->name_count * re->name_entry_size;

-match_block.start_subject = (const unsigned char *)subject;

-match_block.end_subject = end_subject;

-match_block.moptions = options;

-match_block.poptions = re->options;

-

-/* Check a UTF-8 string if required. Unfortunately there's no way of passing

-back the character offset. */

-

-#ifdef SUPPORT_UTF8

-if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)

-  {

-  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)

-    return PCRE_ERROR_BADUTF8;

-  if (start_offset > 0 && start_offset < length)

-    {

-    int tb = ((uschar *)subject)[start_offset];

-    if (tb > 127)

-      {

-      tb &= 0xc0;

-      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;

-      }

-    }

-  }

-#endif

-

-/* If the exec call supplied NULL for tables, use the inbuilt ones. This

-is a feature that makes it possible to save compiled regex and re-use them

-in other programs later. */

-

-if (match_block.tables == NULL) match_block.tables = _pcre_default_tables;

-

-/* The lower casing table and the "must be at the start of a line" flag are

-used in a loop when finding where to start. */

-

-lcc = match_block.tables + lcc_offset;

-startline = (re->options & PCRE_STARTLINE) != 0;

-firstline = (re->options & PCRE_FIRSTLINE) != 0;

-

-/* Set up the first character to match, if available. The first_byte value is

-never set for an anchored regular expression, but the anchoring may be forced

-at run time, so we have to test for anchoring. The first char may be unset for

-an unanchored pattern, of course. If there's no first char and the pattern was

-studied, there may be a bitmap of possible first characters. */

-

-if (!anchored)

-  {

-  if ((re->options & PCRE_FIRSTSET) != 0)

-    {

-    first_byte = re->first_byte & 255;

-    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)

-      first_byte = lcc[first_byte];

-    }

-  else

-    {

-    if (startline && study != NULL &&

-         (study->options & PCRE_STUDY_MAPPED) != 0)

-      start_bits = study->start_bits;

-    }

-  }

-

-/* For anchored or unanchored matches, there may be a "last known required

-character" set. */

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  req_byte = re->req_byte & 255;

-  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;

-  req_byte2 = (match_block.tables + fcc_offset)[req_byte];  /* case flipped */

-  }

-

-/* Call the main matching function, looping for a non-anchored regex after a

-failed match. Unless restarting, optimize by moving to the first match

-character if possible, when not anchored. Then unless wanting a partial match,

-check for a required later character. */

-

-for (;;)

-  {

-  int rc;

-

-  if ((options & PCRE_DFA_RESTART) == 0)

-    {

-    const uschar *save_end_subject = end_subject;

-

-    /* Advance to a unique first char if possible. If firstline is TRUE, the

-    start of the match is constrained to the first line of a multiline string.

-    Implement this by temporarily adjusting end_subject so that we stop scanning

-    at a newline. If the match fails at the newline, later code breaks this loop.

-    */

-

-    if (firstline)

-      {

-      const uschar *t = current_subject;

-      while (t < save_end_subject && *t != '\n') t++;

-      end_subject = t;

-      }

-

-    if (first_byte >= 0)

-      {

-      if (first_byte_caseless)

-        while (current_subject < end_subject &&

-               lcc[*current_subject] != first_byte)

-          current_subject++;

-      else

-        while (current_subject < end_subject && *current_subject != first_byte)

-          current_subject++;

-      }

-

-    /* Or to just after \n for a multiline match if possible */

-

-    else if (startline)

-      {

-      if (current_subject > match_block.start_subject + start_offset)

-        {

-        while (current_subject < end_subject && current_subject[-1] != NEWLINE)

-          current_subject++;

-        }

-      }

-

-    /* Or to a non-unique first char after study */

-

-    else if (start_bits != NULL)

-      {

-      while (current_subject < end_subject)

-        {

-        register unsigned int c = *current_subject;

-        if ((start_bits[c/8] & (1 << (c&7))) == 0) current_subject++;

-          else break;

-        }

-      }

-

-    /* Restore fudged end_subject */

-

-    end_subject = save_end_subject;

-    }

-

-  /* If req_byte is set, we know that that character must appear in the subject

-  for the match to succeed. If the first character is set, req_byte must be

-  later in the subject; otherwise the test starts at the match point. This

-  optimization can save a huge amount of work in patterns with nested unlimited

-  repeats that aren't going to match. Writing separate code for cased/caseless

-  versions makes it go faster, as does using an autoincrement and backing off

-  on a match.

-

-  HOWEVER: when the subject string is very, very long, searching to its end can

-  take a long time, and give bad performance on quite ordinary patterns. This

-  showed up when somebody was matching /^C/ on a 32-megabyte string... so we

-  don't do this when the string is sufficiently long.

-

-  ALSO: this processing is disabled when partial matching is requested.

-  */

-

-  if (req_byte >= 0 &&

-      end_subject - current_subject < REQ_BYTE_MAX &&

-      (options & PCRE_PARTIAL) == 0)

-    {

-    register const uschar *p = current_subject + ((first_byte >= 0)? 1 : 0);

-

-    /* We don't need to repeat the search if we haven't yet reached the

-    place we found it at last time. */

-

-    if (p > req_byte_ptr)

-      {

-      if (req_byte_caseless)

-        {

-        while (p < end_subject)

-          {

-          register int pp = *p++;

-          if (pp == req_byte || pp == req_byte2) { p--; break; }

-          }

-        }

-      else

-        {

-        while (p < end_subject)

-          {

-          if (*p++ == req_byte) { p--; break; }

-          }

-        }

-

-      /* If we can't find the required character, break the matching loop,

-      which will cause a return or PCRE_ERROR_NOMATCH. */

-

-      if (p >= end_subject) break;

-

-      /* If we have found the required character, save the point where we

-      found it, so that we don't search again next time round the loop if

-      the start hasn't passed this character yet. */

-

-      req_byte_ptr = p;

-      }

-    }

-

-  /* OK, now we can do the business */

-

-  rc = internal_dfa_exec(

-    &match_block,                              /* fixed match data */

-    match_block.start_code,                    /* this subexpression's code */

-    current_subject,                           /* where we currently are */

-    start_offset,                              /* start offset in subject */

-    offsets,                                   /* offset vector */

-    offsetcount,                               /* size of same */

-    workspace,                                 /* workspace vector */

-    wscount,                                   /* size of same */

-    re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL), /* ims flags */

-    0,                                         /* function recurse level */

-    0);                                        /* regex recurse level */

-

-  /* Anything other than "no match" means we are done, always; otherwise, carry

-  on only if not anchored. */

-

-  if (rc != PCRE_ERROR_NOMATCH || anchored) return rc;

-

-  /* Advance to the next subject character unless we are at the end of a line

-  and firstline is set. */

-

-  if (firstline && *current_subject == NEWLINE) break;

-  current_subject++;

-

-#ifdef SUPPORT_UTF8

-  if (utf8)

-    {

-    while (current_subject < end_subject && (*current_subject & 0xc0) == 0x80)

-      current_subject++;

-    }

-#endif

-

-  if (current_subject > end_subject) break;

-  }

-

-return PCRE_ERROR_NOMATCH;

-}

-

-/* End of pcre_dfa_exec.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains pcre_exec(), the externally visible function that does

-pattern matching using an NFA algorithm, trying to mimic Perl as closely as

-possible. There are also some static supporting functions. */

-

-

-

-

-/* Structure for building a chain of data that actually lives on the

-stack, for holding the values of the subject pointer at the start of each

-subpattern, so as to detect when an empty string has been matched by a

-subpattern - to break infinite loops. When NO_RECURSE is set, these blocks

-are on the heap, not on the stack. */

-

-typedef struct eptrblock {

-  struct eptrblock *epb_prev;

-  const uschar *epb_saved_eptr;

-} eptrblock;

-

-/* Flag bits for the match() function */

-

-#define match_condassert   0x01    /* Called to check a condition assertion */

-#define match_isgroup      0x02    /* Set if start of bracketed group */

-

-/* Non-error returns from the match() function. Error returns are externally

-defined PCRE_ERROR_xxx codes, which are all negative. */

-

-#define MATCH_MATCH        1

-#define MATCH_NOMATCH      0

-

-/* Maximum number of ints of offset to save on the stack for recursive calls.

-If the offset vector is bigger, malloc is used. This should be a multiple of 3,

-because the offset vector is always a multiple of 3 long. */

-

-#define REC_STACK_SAVE_MAX 30

-

-/* Min and max values for the common repeats; for the maxima, 0 => infinity */

-

-static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };

-static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };

-

-

-

-#ifdef DEBUG

-/*************************************************

-*        Debugging function to print chars       *

-*************************************************/

-

-/* Print a sequence of chars in printable format, stopping at the end of the

-subject if the requested.

-

-Arguments:

-  p           points to characters

-  length      number to print

-  is_subject  TRUE if printing from within md->start_subject

-  md          pointer to matching data block, if is_subject is TRUE

-

-Returns:     nothing

-*/

-

-static void

-pchars(const uschar *p, int length, BOOL is_subject, match_data *md)

-{

-int c;

-if (is_subject && length > md->end_subject - p) length = md->end_subject - p;

-while (length-- > 0)

-  if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);

-}

-#endif

-

-

-

-/*************************************************

-*          Match a back-reference                *

-*************************************************/

-

-/* If a back reference hasn't been set, the length that is passed is greater

-than the number of characters left in the string, so the match fails.

-

-Arguments:

-  offset      index into the offset vector

-  eptr        points into the subject

-  length      length to be matched

-  md          points to match data block

-  ims         the ims flags

-

-Returns:      TRUE if matched

-*/

-

-static BOOL

-match_ref(int offset, register const uschar *eptr, int length, match_data *md,

-  unsigned long int ims)

-{

-const uschar *p = md->start_subject + md->offset_vector[offset];

-

-#ifdef DEBUG

-if (eptr >= md->end_subject)

-  printf("matching subject <null>");

-else

-  {

-  printf("matching subject ");

-  pchars(eptr, length, TRUE, md);

-  }

-printf(" against backref ");

-pchars(p, length, FALSE, md);

-printf("\n");

-#endif

-

-/* Always fail if not enough characters left */

-

-if (length > md->end_subject - eptr) return FALSE;

-

-/* Separate the caselesss case for speed */

-

-if ((ims & PCRE_CASELESS) != 0)

-  {

-  while (length-- > 0)

-    if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE;

-  }

-else

-  { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }

-

-return TRUE;

-}

-

-

-

-/***************************************************************************

-****************************************************************************

-                   RECURSION IN THE match() FUNCTION

-

-The match() function is highly recursive. Some regular expressions can cause

-it to recurse thousands of times. I was writing for Unix, so I just let it

-call itself recursively. This uses the stack for saving everything that has

-to be saved for a recursive call. On Unix, the stack can be large, and this

-works fine.

-

-It turns out that on non-Unix systems there are problems with programs that

-use a lot of stack. (This despite the fact that every last chip has oodles

-of memory these days, and techniques for extending the stack have been known

-for decades.) So....

-

-There is a fudge, triggered by defining NO_RECURSE, which avoids recursive

-calls by keeping local variables that need to be preserved in blocks of memory

-obtained from malloc instead instead of on the stack. Macros are used to

-achieve this so that the actual code doesn't look very different to what it

-always used to.

-****************************************************************************

-***************************************************************************/

-

-

-/* These versions of the macros use the stack, as normal */

-

-#ifndef NO_RECURSE

-#define REGISTER register

-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) rx = match(ra,rb,rc,rd,re,rf,rg)

-#define RRETURN(ra) return ra

-#else

-

-

-/* These versions of the macros manage a private stack on the heap. Note

-that the rd argument of RMATCH isn't actually used. It's the md argument of

-match(), which never changes. */

-

-#define REGISTER

-

-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg)\

-  {\

-  heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\

-  if (setjmp(frame->Xwhere) == 0)\

-    {\

-    newframe->Xeptr = ra;\

-    newframe->Xecode = rb;\

-    newframe->Xoffset_top = rc;\

-    newframe->Xims = re;\

-    newframe->Xeptrb = rf;\

-    newframe->Xflags = rg;\

-    newframe->Xprevframe = frame;\

-    frame = newframe;\

-    DPRINTF(("restarting from line %d\n", __LINE__));\

-    goto HEAP_RECURSE;\

-    }\

-  else\

-    {\

-    DPRINTF(("longjumped back to line %d\n", __LINE__));\

-    frame = md->thisframe;\

-    rx = frame->Xresult;\

-    }\

-  }

-

-#define RRETURN(ra)\

-  {\

-  heapframe *newframe = frame;\

-  frame = newframe->Xprevframe;\

-  (pcre_stack_free)(newframe);\

-  if (frame != NULL)\

-    {\

-    frame->Xresult = ra;\

-    md->thisframe = frame;\

-    longjmp(frame->Xwhere, 1);\

-    }\

-  return ra;\

-  }

-

-

-/* Structure for remembering the local variables in a private frame */

-

-typedef struct heapframe {

-  struct heapframe *Xprevframe;

-

-  /* Function arguments that may change */

-

-  const uschar *Xeptr;

-  const uschar *Xecode;

-  int Xoffset_top;

-  long int Xims;

-  eptrblock *Xeptrb;

-  int Xflags;

-

-  /* Function local variables */

-

-  const uschar *Xcallpat;

-  const uschar *Xcharptr;

-  const uschar *Xdata;

-  const uschar *Xnext;

-  const uschar *Xpp;

-  const uschar *Xprev;

-  const uschar *Xsaved_eptr;

-

-  recursion_info Xnew_recursive;

-

-  BOOL Xcur_is_word;

-  BOOL Xcondition;

-  BOOL Xminimize;

-  BOOL Xprev_is_word;

-

-  unsigned long int Xoriginal_ims;

-

-#ifdef SUPPORT_UCP

-  int Xprop_type;

-  int Xprop_fail_result;

-  int Xprop_category;

-  int Xprop_chartype;

-  int Xprop_othercase;

-  int Xprop_test_against;

-  int *Xprop_test_variable;

-#endif

-

-  int Xctype;

-  int Xfc;

-  int Xfi;

-  int Xlength;

-  int Xmax;

-  int Xmin;

-  int Xnumber;

-  int Xoffset;

-  int Xop;

-  int Xsave_capture_last;

-  int Xsave_offset1, Xsave_offset2, Xsave_offset3;

-  int Xstacksave[REC_STACK_SAVE_MAX];

-

-  eptrblock Xnewptrb;

-

-  /* Place to pass back result, and where to jump back to */

-

-  int  Xresult;

-  jmp_buf Xwhere;

-

-} heapframe;

-

-#endif

-

-

-/***************************************************************************

-***************************************************************************/

-

-

-

-/*************************************************

-*         Match from current position            *

-*************************************************/

-

-/* On entry ecode points to the first opcode, and eptr to the first character

-in the subject string, while eptrb holds the value of eptr at the start of the

-last bracketed group - used for breaking infinite loops matching zero-length

-strings. This function is called recursively in many circumstances. Whenever it

-returns a negative (error) response, the outer incarnation must also return the

-same response.

-

-Performance note: It might be tempting to extract commonly used fields from the

-md structure (e.g. utf8, end_subject) into individual variables to improve

-performance. Tests using gcc on a SPARC disproved this; in the first case, it

-made performance worse.

-

-Arguments:

-   eptr        pointer in subject

-   ecode       position in code

-   offset_top  current top pointer

-   md          pointer to "static" info for the match

-   ims         current /i, /m, and /s options

-   eptrb       pointer to chain of blocks containing eptr at start of

-                 brackets - for testing for empty matches

-   flags       can contain

-                 match_condassert - this is an assertion condition

-                 match_isgroup - this is the start of a bracketed group

-

-Returns:       MATCH_MATCH if matched            )  these values are >= 0

-               MATCH_NOMATCH if failed to match  )

-               a negative PCRE_ERROR_xxx value if aborted by an error condition

-                 (e.g. stopped by recursion limit)

-*/

-

-static int

-match(REGISTER const uschar *eptr, REGISTER const uschar *ecode,

-  int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,

-  int flags)

-{

-/* These variables do not need to be preserved over recursion in this function,

-so they can be ordinary variables in all cases. Mark them with "register"

-because they are used a lot in loops. */

-

-register int  rrc;    /* Returns from recursive calls */

-register int  i;      /* Used for loops not involving calls to RMATCH() */

-register int  c;      /* Character values not kept over RMATCH() calls */

-register BOOL utf8;   /* Local copy of UTF-8 flag for speed */

-

-/* When recursion is not being used, all "local" variables that have to be

-preserved over calls to RMATCH() are part of a "frame" which is obtained from

-heap storage. Set up the top-level frame here; others are obtained from the

-heap whenever RMATCH() does a "recursion". See the macro definitions above. */

-

-#ifdef NO_RECURSE

-heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));

-frame->Xprevframe = NULL;            /* Marks the top level */

-

-/* Copy in the original argument variables */

-

-frame->Xeptr = eptr;

-frame->Xecode = ecode;

-frame->Xoffset_top = offset_top;

-frame->Xims = ims;

-frame->Xeptrb = eptrb;

-frame->Xflags = flags;

-

-/* This is where control jumps back to to effect "recursion" */

-

-HEAP_RECURSE:

-

-/* Macros make the argument variables come from the current frame */

-

-#define eptr               frame->Xeptr

-#define ecode              frame->Xecode

-#define offset_top         frame->Xoffset_top

-#define ims                frame->Xims

-#define eptrb              frame->Xeptrb

-#define flags              frame->Xflags

-

-/* Ditto for the local variables */

-

-#ifdef SUPPORT_UTF8

-#define charptr            frame->Xcharptr

-#endif

-#define callpat            frame->Xcallpat

-#define data               frame->Xdata

-#define next               frame->Xnext

-#define pp                 frame->Xpp

-#define prev               frame->Xprev

-#define saved_eptr         frame->Xsaved_eptr

-

-#define new_recursive      frame->Xnew_recursive

-

-#define cur_is_word        frame->Xcur_is_word

-#define condition          frame->Xcondition

-#define minimize           frame->Xminimize

-#define prev_is_word       frame->Xprev_is_word

-

-#define original_ims       frame->Xoriginal_ims

-

-#ifdef SUPPORT_UCP

-#define prop_type          frame->Xprop_type

-#define prop_fail_result   frame->Xprop_fail_result

-#define prop_category      frame->Xprop_category

-#define prop_chartype      frame->Xprop_chartype

-#define prop_othercase     frame->Xprop_othercase

-#define prop_test_against  frame->Xprop_test_against

-#define prop_test_variable frame->Xprop_test_variable

-#endif

-

-#define ctype              frame->Xctype

-#define fc                 frame->Xfc

-#define fi                 frame->Xfi

-#define length             frame->Xlength

-#define max                frame->Xmax

-#define min                frame->Xmin

-#define number             frame->Xnumber

-#define offset             frame->Xoffset

-#define op                 frame->Xop

-#define save_capture_last  frame->Xsave_capture_last

-#define save_offset1       frame->Xsave_offset1

-#define save_offset2       frame->Xsave_offset2

-#define save_offset3       frame->Xsave_offset3

-#define stacksave          frame->Xstacksave

-

-#define newptrb            frame->Xnewptrb

-

-/* When recursion is being used, local variables are allocated on the stack and

-get preserved during recursion in the normal way. In this environment, fi and

-i, and fc and c, can be the same variables. */

-

-#else

-#define fi i

-#define fc c

-

-

-#ifdef SUPPORT_UTF8                /* Many of these variables are used ony */

-const uschar *charptr;             /* small blocks of the code. My normal  */

-#endif                             /* style of coding would have declared  */

-const uschar *callpat;             /* them within each of those blocks.    */

-const uschar *data;                /* However, in order to accommodate the */

-const uschar *next;                /* version of this code that uses an    */

-const uschar *pp;                  /* external "stack" implemented on the  */

-const uschar *prev;                /* heap, it is easier to declare them   */

-const uschar *saved_eptr;          /* all here, so the declarations can    */

-                                   /* be cut out in a block. The only      */

-recursion_info new_recursive;      /* declarations within blocks below are */

-                                   /* for variables that do not have to    */

-BOOL cur_is_word;                  /* be preserved over a recursive call   */

-BOOL condition;                    /* to RMATCH().                         */

-BOOL minimize;

-BOOL prev_is_word;

-

-unsigned long int original_ims;

-

-#ifdef SUPPORT_UCP

-int prop_type;

-int prop_fail_result;

-int prop_category;

-int prop_chartype;

-int prop_othercase;

-int prop_test_against;

-int *prop_test_variable;

-#endif

-

-int ctype;

-int length;

-int max;

-int min;

-int number;

-int offset;

-int op;

-int save_capture_last;

-int save_offset1, save_offset2, save_offset3;

-int stacksave[REC_STACK_SAVE_MAX];

-

-eptrblock newptrb;

-#endif

-

-/* These statements are here to stop the compiler complaining about unitialized

-variables. */

-

-#ifdef SUPPORT_UCP

-prop_fail_result = 0;

-prop_test_against = 0;

-prop_test_variable = NULL;

-#endif

-

-/* OK, now we can get on with the real code of the function. Recursion is

-specified by the macros RMATCH and RRETURN. When NO_RECURSE is *not* defined,

-these just turn into a recursive call to match() and a "return", respectively.

-However, RMATCH isn't like a function call because it's quite a complicated

-macro. It has to be used in one particular way. This shouldn't, however, impact

-performance when true recursion is being used. */

-

-if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);

-

-original_ims = ims;    /* Save for resetting on ')' */

-utf8 = md->utf8;       /* Local copy of the flag */

-

-/* At the start of a bracketed group, add the current subject pointer to the

-stack of such pointers, to be re-instated at the end of the group when we hit

-the closing ket. When match() is called in other circumstances, we don't add to

-this stack. */

-

-if ((flags & match_isgroup) != 0)

-  {

-  newptrb.epb_prev = eptrb;

-  newptrb.epb_saved_eptr = eptr;

-  eptrb = &newptrb;

-  }

-

-/* Now start processing the operations. */

-

-for (;;)

-  {

-  op = *ecode;

-  minimize = FALSE;

-

-  /* For partial matching, remember if we ever hit the end of the subject after

-  matching at least one subject character. */

-

-  if (md->partial &&

-      eptr >= md->end_subject &&

-      eptr > md->start_match)

-    md->hitend = TRUE;

-

-  /* Opening capturing bracket. If there is space in the offset vector, save

-  the current subject position in the working slot at the top of the vector. We

-  mustn't change the current values of the data slot, because they may be set

-  from a previous iteration of this group, and be referred to by a reference

-  inside the group.

-

-  If the bracket fails to match, we need to restore this value and also the

-  values of the final offsets, in case they were set by a previous iteration of

-  the same bracket.

-

-  If there isn't enough space in the offset vector, treat this as if it were a

-  non-capturing bracket. Don't worry about setting the flag for the error case

-  here; that is handled in the code for KET. */

-

-  if (op > OP_BRA)

-    {

-    number = op - OP_BRA;

-

-    /* For extended extraction brackets (large number), we have to fish out the

-    number from a dummy opcode at the start. */

-

-    if (number > EXTRACT_BASIC_MAX)

-      number = GET2(ecode, 2+LINK_SIZE);

-    offset = number << 1;

-

-#ifdef DEBUG

-    printf("start bracket %d subject=", number);

-    pchars(eptr, 16, TRUE, md);

-    printf("\n");

-#endif

-

-    if (offset < md->offset_max)

-      {

-      save_offset1 = md->offset_vector[offset];

-      save_offset2 = md->offset_vector[offset+1];

-      save_offset3 = md->offset_vector[md->offset_end - number];

-      save_capture_last = md->capture_last;

-

-      DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));

-      md->offset_vector[md->offset_end - number] = eptr - md->start_subject;

-

-      do

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-          match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        md->capture_last = save_capture_last;

-        ecode += GET(ecode, 1);

-        }

-      while (*ecode == OP_ALT);

-

-      DPRINTF(("bracket %d failed\n", number));

-

-      md->offset_vector[offset] = save_offset1;

-      md->offset_vector[offset+1] = save_offset2;

-      md->offset_vector[md->offset_end - number] = save_offset3;

-

-      RRETURN(MATCH_NOMATCH);

-      }

-

-    /* Insufficient room for saving captured contents */

-

-    else op = OP_BRA;

-    }

-

-  /* Other types of node can be handled by a switch */

-

-  switch(op)

-    {

-    case OP_BRA:     /* Non-capturing bracket: optimized */

-    DPRINTF(("start bracket 0\n"));

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode, 1);

-      }

-    while (*ecode == OP_ALT);

-    DPRINTF(("bracket 0 failed\n"));

-    RRETURN(MATCH_NOMATCH);

-

-    /* Conditional group: compilation checked that there are no more than

-    two branches. If the condition is false, skipping the first branch takes us

-    past the end if there is only one branch, but that's OK because that is

-    exactly what going to the ket would do. */

-

-    case OP_COND:

-    if (ecode[LINK_SIZE+1] == OP_CREF) /* Condition extract or recurse test */

-      {

-      offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */

-      condition = (offset == CREF_RECURSE * 2)?

-        (md->recursive != NULL) :

-        (offset < offset_top && md->offset_vector[offset] >= 0);

-      RMATCH(rrc, eptr, ecode + (condition?

-        (LINK_SIZE + 4) : (LINK_SIZE + 1 + GET(ecode, 1))),

-        offset_top, md, ims, eptrb, match_isgroup);

-      RRETURN(rrc);

-      }

-

-    /* The condition is an assertion. Call match() to evaluate it - setting

-    the final argument TRUE causes it to stop at the end of an assertion. */

-

-    else

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-          match_condassert | match_isgroup);

-      if (rrc == MATCH_MATCH)

-        {

-        ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE+2);

-        while (*ecode == OP_ALT) ecode += GET(ecode, 1);

-        }

-      else if (rrc != MATCH_NOMATCH)

-        {

-        RRETURN(rrc);         /* Need braces because of following else */

-        }

-      else ecode += GET(ecode, 1);

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      RRETURN(rrc);

-      }

-    /* Control never reaches here */

-

-    /* Skip over conditional reference or large extraction number data if

-    encountered. */

-

-    case OP_CREF:

-    case OP_BRANUMBER:

-    ecode += 3;

-    break;

-

-    /* End of the pattern. If we are in a recursion, we should restore the

-    offsets appropriately and continue from after the call. */

-

-    case OP_END:

-    if (md->recursive != NULL && md->recursive->group_num == 0)

-      {

-      recursion_info *rec = md->recursive;

-      DPRINTF(("Hit the end in a (?0) recursion\n"));

-      md->recursive = rec->prevrec;

-      memmove(md->offset_vector, rec->offset_save,

-        rec->saved_max * sizeof(int));

-      md->start_match = rec->save_start;

-      ims = original_ims;

-      ecode = rec->after_call;

-      break;

-      }

-

-    /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty

-    string - backtracking will then try other alternatives, if any. */

-

-    if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH);

-    md->end_match_ptr = eptr;          /* Record where we ended */

-    md->end_offset_top = offset_top;   /* and how many extracts were taken */

-    RRETURN(MATCH_MATCH);

-

-    /* Change option settings */

-

-    case OP_OPT:

-    ims = ecode[1];

-    ecode += 2;

-    DPRINTF(("ims set to %02lx\n", ims));

-    break;

-

-    /* Assertion brackets. Check the alternative branches in turn - the

-    matching won't pass the KET for an assertion. If any one branch matches,

-    the assertion is true. Lookbehind assertions have an OP_REVERSE item at the

-    start of each branch to move the current point backwards, so the code at

-    this level is identical to the lookahead case. */

-

-    case OP_ASSERT:

-    case OP_ASSERTBACK:

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-        match_isgroup);

-      if (rrc == MATCH_MATCH) break;

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode, 1);

-      }

-    while (*ecode == OP_ALT);

-    if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);

-

-    /* If checking an assertion for a condition, return MATCH_MATCH. */

-

-    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);

-

-    /* Continue from after the assertion, updating the offsets high water

-    mark, since extracts may have been taken during the assertion. */

-

-    do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-    ecode += 1 + LINK_SIZE;

-    offset_top = md->end_offset_top;

-    continue;

-

-    /* Negative assertion: all branches must fail to match */

-

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK_NOT:

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-        match_isgroup);

-      if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode,1);

-      }

-    while (*ecode == OP_ALT);

-

-    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);

-

-    ecode += 1 + LINK_SIZE;

-    continue;

-

-    /* Move the subject pointer back. This occurs only at the start of

-    each branch of a lookbehind assertion. If we are too close to the start to

-    move back, this match function fails. When working with UTF-8 we move

-    back a number of characters, not bytes. */

-

-    case OP_REVERSE:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      c = GET(ecode,1);

-      for (i = 0; i < c; i++)

-        {

-        eptr--;

-        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);

-        BACKCHAR(eptr)

-        }

-      }

-    else

-#endif

-

-    /* No UTF-8 support, or not in UTF-8 mode: count is byte count */

-

-      {

-      eptr -= GET(ecode,1);

-      if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);

-      }

-

-    /* Skip to next op code */

-

-    ecode += 1 + LINK_SIZE;

-    break;

-

-    /* The callout item calls an external function, if one is provided, passing

-    details of the match so far. This is mainly for debugging, though the

-    function is able to force a failure. */

-

-    case OP_CALLOUT:

-    if (pcre_callout != NULL)

-      {

-      pcre_callout_block cb;

-      cb.version          = 1;   /* Version 1 of the callout block */

-      cb.callout_number   = ecode[1];

-      cb.offset_vector    = md->offset_vector;

-      cb.subject          = (const char *)md->start_subject;

-      cb.subject_length   = md->end_subject - md->start_subject;

-      cb.start_match      = md->start_match - md->start_subject;

-      cb.current_position = eptr - md->start_subject;

-      cb.pattern_position = GET(ecode, 2);

-      cb.next_item_length = GET(ecode, 2 + LINK_SIZE);

-      cb.capture_top      = offset_top/2;

-      cb.capture_last     = md->capture_last;

-      cb.callout_data     = md->callout_data;

-      if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);

-      if (rrc < 0) RRETURN(rrc);

-      }

-    ecode += 2 + 2*LINK_SIZE;

-    break;

-

-    /* Recursion either matches the current regex, or some subexpression. The

-    offset data is the offset to the starting bracket from the start of the

-    whole pattern. (This is so that it works from duplicated subpatterns.)

-

-    If there are any capturing brackets started but not finished, we have to

-    save their starting points and reinstate them after the recursion. However,

-    we don't know how many such there are (offset_top records the completed

-    total) so we just have to save all the potential data. There may be up to

-    65535 such values, which is too large to put on the stack, but using malloc

-    for small numbers seems expensive. As a compromise, the stack is used when

-    there are no more than REC_STACK_SAVE_MAX values to store; otherwise malloc

-    is used. A problem is what to do if the malloc fails ... there is no way of

-    returning to the top level with an error. Save the top REC_STACK_SAVE_MAX

-    values on the stack, and accept that the rest may be wrong.

-

-    There are also other values that have to be saved. We use a chained

-    sequence of blocks that actually live on the stack. Thanks to Robin Houston

-    for the original version of this logic. */

-

-    case OP_RECURSE:

-      {

-      callpat = md->start_code + GET(ecode, 1);

-      new_recursive.group_num = *callpat - OP_BRA;

-

-      /* For extended extraction brackets (large number), we have to fish out

-      the number from a dummy opcode at the start. */

-

-      if (new_recursive.group_num > EXTRACT_BASIC_MAX)

-        new_recursive.group_num = GET2(callpat, 2+LINK_SIZE);

-

-      /* Add to "recursing stack" */

-

-      new_recursive.prevrec = md->recursive;

-      md->recursive = &new_recursive;

-

-      /* Find where to continue from afterwards */

-

-      ecode += 1 + LINK_SIZE;

-      new_recursive.after_call = ecode;

-

-      /* Now save the offset data. */

-

-      new_recursive.saved_max = md->offset_end;

-      if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)

-        new_recursive.offset_save = stacksave;

-      else

-        {

-        new_recursive.offset_save =

-          (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));

-        if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);

-        }

-

-      memcpy(new_recursive.offset_save, md->offset_vector,

-            new_recursive.saved_max * sizeof(int));

-      new_recursive.save_start = md->start_match;

-      md->start_match = eptr;

-

-      /* OK, now we can do the recursion. For each top-level alternative we

-      restore the offset and recursion data. */

-

-      DPRINTF(("Recursing into group %d\n", new_recursive.group_num));

-      do

-        {

-        RMATCH(rrc, eptr, callpat + 1 + LINK_SIZE, offset_top, md, ims,

-            eptrb, match_isgroup);

-        if (rrc == MATCH_MATCH)

-          {

-          md->recursive = new_recursive.prevrec;

-          if (new_recursive.offset_save != stacksave)

-            (pcre_free)(new_recursive.offset_save);

-          RRETURN(MATCH_MATCH);

-          }

-        else if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-

-        md->recursive = &new_recursive;

-        memcpy(md->offset_vector, new_recursive.offset_save,

-            new_recursive.saved_max * sizeof(int));

-        callpat += GET(callpat, 1);

-        }

-      while (*callpat == OP_ALT);

-

-      DPRINTF(("Recursion didn't match\n"));

-      md->recursive = new_recursive.prevrec;

-      if (new_recursive.offset_save != stacksave)

-        (pcre_free)(new_recursive.offset_save);

-      RRETURN(MATCH_NOMATCH);

-      }

-    /* Control never reaches here */

-

-    /* "Once" brackets are like assertion brackets except that after a match,

-    the point in the subject string is not moved back. Thus there can never be

-    a move back into the brackets. Friedl calls these "atomic" subpatterns.

-    Check the alternative branches in turn - the matching won't pass the KET

-    for this kind of subpattern. If any one branch matches, we carry on as at

-    the end of a normal bracket, leaving the subject pointer. */

-

-    case OP_ONCE:

-      {

-      prev = ecode;

-      saved_eptr = eptr;

-

-      do

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,

-          eptrb, match_isgroup);

-        if (rrc == MATCH_MATCH) break;

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        ecode += GET(ecode,1);

-        }

-      while (*ecode == OP_ALT);

-

-      /* If hit the end of the group (which could be repeated), fail */

-

-      if (*ecode != OP_ONCE && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);

-

-      /* Continue as from after the assertion, updating the offsets high water

-      mark, since extracts may have been taken. */

-

-      do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-

-      offset_top = md->end_offset_top;

-      eptr = md->end_match_ptr;

-

-      /* For a non-repeating ket, just continue at this level. This also

-      happens for a repeating ket if no characters were matched in the group.

-      This is the forcible breaking of infinite loops as implemented in Perl

-      5.005. If there is an options reset, it will get obeyed in the normal

-      course of events. */

-

-      if (*ecode == OP_KET || eptr == saved_eptr)

-        {

-        ecode += 1+LINK_SIZE;

-        break;

-        }

-

-      /* The repeating kets try the rest of the pattern or restart from the

-      preceding bracket, in the appropriate order. We need to reset any options

-      that changed within the bracket before re-running it, so check the next

-      opcode. */

-

-      if (ecode[1+LINK_SIZE] == OP_OPT)

-        {

-        ims = (ims & ~PCRE_IMS) | ecode[4];

-        DPRINTF(("ims set to %02lx at group repeat\n", ims));

-        }

-

-      if (*ecode == OP_KETRMIN)

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      else  /* OP_KETRMAX */

-        {

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      }

-    RRETURN(MATCH_NOMATCH);

-

-    /* An alternation is the end of a branch; scan along to find the end of the

-    bracketed group and go to there. */

-

-    case OP_ALT:

-    do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-    break;

-

-    /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating

-    that it may occur zero times. It may repeat infinitely, or not at all -

-    i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper

-    repeat limits are compiled as a number of copies, with the optional ones

-    preceded by BRAZERO or BRAMINZERO. */

-

-    case OP_BRAZERO:

-      {

-      next = ecode+1;

-      RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      do next += GET(next,1); while (*next == OP_ALT);

-      ecode = next + 1+LINK_SIZE;

-      }

-    break;

-

-    case OP_BRAMINZERO:

-      {

-      next = ecode+1;

-      do next += GET(next,1); while (*next == OP_ALT);

-      RMATCH(rrc, eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode++;

-      }

-    break;

-

-    /* End of a group, repeated or non-repeating. If we are at the end of

-    an assertion "group", stop matching and return MATCH_MATCH, but record the

-    current high water mark for use by positive assertions. Do this also

-    for the "once" (not-backup up) groups. */

-

-    case OP_KET:

-    case OP_KETRMIN:

-    case OP_KETRMAX:

-      {

-      prev = ecode - GET(ecode, 1);

-      saved_eptr = eptrb->epb_saved_eptr;

-

-      /* Back up the stack of bracket start pointers. */

-

-      eptrb = eptrb->epb_prev;

-

-      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||

-          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||

-          *prev == OP_ONCE)

-        {

-        md->end_match_ptr = eptr;      /* For ONCE */

-        md->end_offset_top = offset_top;

-        RRETURN(MATCH_MATCH);

-        }

-

-      /* In all other cases except a conditional group we have to check the

-      group number back at the start and if necessary complete handling an

-      extraction by setting the offsets and bumping the high water mark. */

-

-      if (*prev != OP_COND)

-        {

-        number = *prev - OP_BRA;

-

-        /* For extended extraction brackets (large number), we have to fish out

-        the number from a dummy opcode at the start. */

-

-        if (number > EXTRACT_BASIC_MAX) number = GET2(prev, 2+LINK_SIZE);

-        offset = number << 1;

-

-#ifdef DEBUG

-        printf("end bracket %d", number);

-        printf("\n");

-#endif

-

-        /* Test for a numbered group. This includes groups called as a result

-        of recursion. Note that whole-pattern recursion is coded as a recurse

-        into group 0, so it won't be picked up here. Instead, we catch it when

-        the OP_END is reached. */

-

-        if (number > 0)

-          {

-          md->capture_last = number;

-          if (offset >= md->offset_max) md->offset_overflow = TRUE; else

-            {

-            md->offset_vector[offset] =

-              md->offset_vector[md->offset_end - number];

-            md->offset_vector[offset+1] = eptr - md->start_subject;

-            if (offset_top <= offset) offset_top = offset + 2;

-            }

-

-          /* Handle a recursively called group. Restore the offsets

-          appropriately and continue from after the call. */

-

-          if (md->recursive != NULL && md->recursive->group_num == number)

-            {

-            recursion_info *rec = md->recursive;

-            DPRINTF(("Recursion (%d) succeeded - continuing\n", number));

-            md->recursive = rec->prevrec;

-            md->start_match = rec->save_start;

-            memcpy(md->offset_vector, rec->offset_save,

-              rec->saved_max * sizeof(int));

-            ecode = rec->after_call;

-            ims = original_ims;

-            break;

-            }

-          }

-        }

-

-      /* Reset the value of the ims flags, in case they got changed during

-      the group. */

-

-      ims = original_ims;

-      DPRINTF(("ims reset to %02lx\n", ims));

-

-      /* For a non-repeating ket, just continue at this level. This also

-      happens for a repeating ket if no characters were matched in the group.

-      This is the forcible breaking of infinite loops as implemented in Perl

-      5.005. If there is an options reset, it will get obeyed in the normal

-      course of events. */

-

-      if (*ecode == OP_KET || eptr == saved_eptr)

-        {

-        ecode += 1 + LINK_SIZE;

-        break;

-        }

-

-      /* The repeating kets try the rest of the pattern or restart from the

-      preceding bracket, in the appropriate order. */

-

-      if (*ecode == OP_KETRMIN)

-        {

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      else  /* OP_KETRMAX */

-        {

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      }

-

-    RRETURN(MATCH_NOMATCH);

-

-    /* Start of subject unless notbol, or after internal newline if multiline */

-

-    case OP_CIRC:

-    if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);

-    if ((ims & PCRE_MULTILINE) != 0)

-      {

-      if (eptr != md->start_subject && eptr[-1] != NEWLINE)

-        RRETURN(MATCH_NOMATCH);

-      ecode++;

-      break;

-      }

-    /* ... else fall through */

-

-    /* Start of subject assertion */

-

-    case OP_SOD:

-    if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Start of match assertion */

-

-    case OP_SOM:

-    if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Assert before internal newline if multiline, or before a terminating

-    newline unless endonly is set, else end of subject unless noteol is set. */

-

-    case OP_DOLL:

-    if ((ims & PCRE_MULTILINE) != 0)

-      {

-      if (eptr < md->end_subject)

-        { if (*eptr != NEWLINE) RRETURN(MATCH_NOMATCH); }

-      else

-        { if (md->noteol) RRETURN(MATCH_NOMATCH); }

-      ecode++;

-      break;

-      }

-    else

-      {

-      if (md->noteol) RRETURN(MATCH_NOMATCH);

-      if (!md->endonly)

-        {

-        if (eptr < md->end_subject - 1 ||

-           (eptr == md->end_subject - 1 && *eptr != NEWLINE))

-          RRETURN(MATCH_NOMATCH);

-        ecode++;

-        break;

-        }

-      }

-    /* ... else fall through */

-

-    /* End of subject assertion (\z) */

-

-    case OP_EOD:

-    if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* End of subject or ending \n assertion (\Z) */

-

-    case OP_EODN:

-    if (eptr < md->end_subject - 1 ||

-       (eptr == md->end_subject - 1 && *eptr != NEWLINE)) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Word boundary assertions */

-

-    case OP_NOT_WORD_BOUNDARY:

-    case OP_WORD_BOUNDARY:

-      {

-

-      /* Find out if the previous and current characters are "word" characters.

-      It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to

-      be "non-word" characters. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8)

-        {

-        if (eptr == md->start_subject) prev_is_word = FALSE; else

-          {

-          const uschar *lastptr = eptr - 1;

-          while((*lastptr & 0xc0) == 0x80) lastptr--;

-          GETCHAR(c, lastptr);

-          prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;

-          }

-        if (eptr >= md->end_subject) cur_is_word = FALSE; else

-          {

-          GETCHAR(c, eptr);

-          cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;

-          }

-        }

-      else

-#endif

-

-      /* More streamlined when not in UTF-8 mode */

-

-        {

-        prev_is_word = (eptr != md->start_subject) &&

-          ((md->ctypes[eptr[-1]] & ctype_word) != 0);

-        cur_is_word = (eptr < md->end_subject) &&

-          ((md->ctypes[*eptr] & ctype_word) != 0);

-        }

-

-      /* Now see if the situation is what we want */

-

-      if ((*ecode++ == OP_WORD_BOUNDARY)?

-           cur_is_word == prev_is_word : cur_is_word != prev_is_word)

-        RRETURN(MATCH_NOMATCH);

-      }

-    break;

-

-    /* Match a single character type; inline for speed */

-

-    case OP_ANY:

-    if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == NEWLINE)

-      RRETURN(MATCH_NOMATCH);

-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-#endif

-    ecode++;

-    break;

-

-    /* Match a single byte, even in UTF-8 mode. This opcode really does match

-    any byte, even newline, independent of the setting of PCRE_DOTALL. */

-

-    case OP_ANYBYTE:

-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_DIGIT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_digit) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_DIGIT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_digit) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_WHITESPACE:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_space) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_WHITESPACE:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_space) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_WORDCHAR:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_word) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_WORDCHAR:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_word) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-#ifdef SUPPORT_UCP

-    /* Check the next character by Unicode property. We will get here only

-    if the support is in the binary; otherwise a compile-time error occurs. */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-      {

-      int chartype, rqdtype;

-      int othercase;

-      int category = ucp_findchar(c, &chartype, &othercase);

-

-      rqdtype = *(++ecode);

-      ecode++;

-

-      if (rqdtype >= 128)

-        {

-        if ((rqdtype - 128 != category) == (op == OP_PROP))

-          RRETURN(MATCH_NOMATCH);

-        }

-      else

-        {

-        if ((rqdtype != chartype) == (op == OP_PROP))

-          RRETURN(MATCH_NOMATCH);

-        }

-      }

-    break;

-

-    /* Match an extended Unicode sequence. We will get here only if the support

-    is in the binary; otherwise a compile-time error occurs. */

-

-    case OP_EXTUNI:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-      {

-      int chartype;

-      int othercase;

-      int category = ucp_findchar(c, &chartype, &othercase);

-      if (category == ucp_M) RRETURN(MATCH_NOMATCH);

-      while (eptr < md->end_subject)

-        {

-        int len = 1;

-        if (!utf8) c = *eptr; else

-          {

-          GETCHARLEN(c, eptr, len);

-          }

-        category = ucp_findchar(c, &chartype, &othercase);

-        if (category != ucp_M) break;

-        eptr += len;

-        }

-      }

-    ecode++;

-    break;

-#endif

-

-

-    /* Match a back reference, possibly repeatedly. Look past the end of the

-    item to see if there is repeat information following. The code is similar

-    to that for character classes, but repeated for efficiency. Then obey

-    similar code to character type repeats - written out again for speed.

-    However, if the referenced string is the empty string, always treat

-    it as matched, any number of times (otherwise there could be infinite

-    loops). */

-

-    case OP_REF:

-      {

-      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */

-      ecode += 3;                                 /* Advance past item */

-

-      /* If the reference is unset, set the length to be longer than the amount

-      of subject left; this ensures that every attempt at a match fails. We

-      can't just fail here, because of the possibility of quantifiers with zero

-      minima. */

-

-      length = (offset >= offset_top || md->offset_vector[offset] < 0)?

-        md->end_subject - eptr + 1 :

-        md->offset_vector[offset+1] - md->offset_vector[offset];

-

-      /* Set up for repetition, or handle the non-repeated case */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);

-        eptr += length;

-        continue;              /* With the main loop */

-        }

-

-      /* If the length of the reference is zero, just continue with the

-      main loop. */

-

-      if (length == 0) continue;

-

-      /* First, ensure the minimum number of matches are present. We get back

-      the length of the reference string explicitly rather than passing the

-      address of eptr, so that eptr can be a register variable. */

-

-      for (i = 1; i <= min; i++)

-        {

-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);

-        eptr += length;

-        }

-

-      /* If min = max, continue at the same level without recursion.

-      They are not both allowed to be zero. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep trying and advancing the pointer */

-

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || !match_ref(offset, eptr, length, md, ims))

-            RRETURN(MATCH_NOMATCH);

-          eptr += length;

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest string and work backwards */

-

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (!match_ref(offset, eptr, length, md, ims)) break;

-          eptr += length;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          eptr -= length;

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-

-

-    /* Match a bit-mapped character class, possibly repeatedly. This op code is

-    used when all the characters in the class have values in the range 0-255,

-    and either the matching is caseful, or the characters are in the range

-    0-127 when UTF-8 processing is enabled. The only difference between

-    OP_CLASS and OP_NCLASS occurs when a data character outside the range is

-    encountered.

-

-    First, look past the end of the item to see if there is repeat information

-    following. Then obey similar code to character type repeats - written out

-    again for speed. */

-

-    case OP_NCLASS:

-    case OP_CLASS:

-      {

-      data = ecode + 1;                /* Save for matching */

-      ecode += 33;                     /* Advance past the item */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        min = max = 1;

-        break;

-        }

-

-      /* First, ensure the minimum number of matches are present. */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (c > 255)

-            {

-            if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);

-            }

-          else

-            {

-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-            }

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          c = *eptr++;

-          if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* If max == min we can continue with the main loop without the

-      need to recurse. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep testing the rest of the expression and advancing

-      the pointer while it matches the class. */

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            GETCHARINC(c, eptr);

-            if (c > 255)

-              {

-              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);

-              }

-            else

-              {

-              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-              }

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            c = *eptr++;

-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest possible run, then work backwards. */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c > 255)

-              {

-              if (op == OP_CLASS) break;

-              }

-            else

-              {

-              if ((data[c/8] & (1 << (c&7))) == 0) break;

-              }

-            eptr += len;

-            }

-          for (;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-          /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject) break;

-            c = *eptr;

-            if ((data[c/8] & (1 << (c&7))) == 0) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            eptr--;

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-

-    /* Match an extended character class. This opcode is encountered only

-    in UTF-8 mode, because that's the only time it is compiled. */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-      {

-      data = ecode + 1 + LINK_SIZE;                /* Save for matching */

-      ecode += GET(ecode, 1);                      /* Advance past the item */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        min = max = 1;

-        break;

-        }

-

-      /* First, ensure the minimum number of matches are present. */

-

-      for (i = 1; i <= min; i++)

-        {

-        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-        GETCHARINC(c, eptr);

-        if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);

-        }

-

-      /* If max == min we can continue with the main loop without the

-      need to recurse. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep testing the rest of the expression and advancing

-      the pointer while it matches the class. */

-

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest possible run, then work backwards. */

-

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          int len = 1;

-          if (eptr >= md->end_subject) break;

-          GETCHARLEN(c, eptr, len);

-          if (!_pcre_xclass(c, data)) break;

-          eptr += len;

-          }

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr)

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-

-      /* Control never gets here */

-      }

-#endif    /* End of XCLASS */

-

-    /* Match a single character, casefully */

-

-    case OP_CHAR:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      ecode++;

-      GETCHARLEN(fc, ecode, length);

-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);

-      }

-    else

-#endif

-

-    /* Non-UTF-8 mode */

-      {

-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);

-      if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);

-      ecode += 2;

-      }

-    break;

-

-    /* Match a single character, caselessly */

-

-    case OP_CHARNC:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      ecode++;

-      GETCHARLEN(fc, ecode, length);

-

-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-

-      /* If the pattern character's value is < 128, we have only one byte, and

-      can use the fast lookup table. */

-

-      if (fc < 128)

-        {

-        if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-        }

-

-      /* Otherwise we must pick up the subject character */

-

-      else

-        {

-        int dc;

-        GETCHARINC(dc, eptr);

-        ecode += length;

-

-        /* If we have Unicode property support, we can use it to test the other

-        case of the character, if there is one. The result of ucp_findchar() is

-        < 0 if the char isn't found, and othercase is returned as zero if there

-        isn't one. */

-

-        if (fc != dc)

-          {

-#ifdef SUPPORT_UCP

-          int chartype;

-          int othercase;

-          if (ucp_findchar(fc, &chartype, &othercase) < 0 || dc != othercase)

-#endif

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-      }

-    else

-#endif   /* SUPPORT_UTF8 */

-

-    /* Non-UTF-8 mode */

-      {

-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);

-      if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-      ecode += 2;

-      }

-    break;

-

-    /* Match a single character repeatedly; different opcodes share code. */

-

-    case OP_EXACT:

-    min = max = GET2(ecode, 1);

-    ecode += 3;

-    goto REPEATCHAR;

-

-    case OP_UPTO:

-    case OP_MINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_MINUPTO;

-    ecode += 3;

-    goto REPEATCHAR;

-

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    c = *ecode++ - OP_STAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single-character matches. We can give

-    up quickly if there are fewer than the minimum number of characters left in

-    the subject. */

-

-    REPEATCHAR:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      charptr = ecode;

-      GETCHARLEN(fc, ecode, length);

-      if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      ecode += length;

-

-      /* Handle multibyte character matching specially here. There is

-      support for caseless matching if UCP support is present. */

-

-      if (length > 1)

-        {

-        int oclength = 0;

-        uschar occhars[8];

-

-#ifdef SUPPORT_UCP

-        int othercase;

-        int chartype;

-        if ((ims & PCRE_CASELESS) != 0 &&

-             ucp_findchar(fc, &chartype, &othercase) >= 0 &&

-             othercase > 0)

-          oclength = _pcre_ord2utf8(othercase, occhars);

-#endif  /* SUPPORT_UCP */

-

-        for (i = 1; i <= min; i++)

-          {

-          if (memcmp(eptr, charptr, length) == 0) eptr += length;

-          /* Need braces because of following else */

-          else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }

-          else

-            {

-            if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);

-            eptr += oclength;

-            }

-          }

-

-        if (min == max) continue;

-

-        if (minimize)

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            if (memcmp(eptr, charptr, length) == 0) eptr += length;

-            /* Need braces because of following else */

-            else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }

-            else

-              {

-              if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);

-              eptr += oclength;

-              }

-            }

-          /* Control never gets here */

-          }

-        else

-          {

-          pp = eptr;

-          for (i = min; i < max; i++)

-            {

-            if (eptr > md->end_subject - length) break;

-            if (memcmp(eptr, charptr, length) == 0) eptr += length;

-            else if (oclength == 0) break;

-            else

-              {

-              if (memcmp(eptr, occhars, oclength) != 0) break;

-              eptr += oclength;

-              }

-            }

-          while (eptr >= pp)

-           {

-           RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-           if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-           eptr -= length;

-           }

-          RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-

-      /* If the length of a UTF-8 character is 1, we fall through here, and

-      obey the code as for non-UTF-8 characters below, though in this case the

-      value of fc will always be < 128. */

-      }

-    else

-#endif  /* SUPPORT_UTF8 */

-

-    /* When not in UTF-8 mode, load a single-byte character. */

-      {

-      if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      fc = *ecode++;

-      }

-

-    /* The value of fc at this point is always less than 256, though we may or

-    may not be in UTF-8 mode. The code is duplicated for the caseless and

-    caseful cases, for speed, since matching characters is likely to be quite

-    common. First, ensure the minimum number of matches are present. If min =

-    max, continue at the same level without recursing. Otherwise, if

-    minimizing, keep trying the rest of the expression and advancing one

-    matching character if failing, up to the maximum. Alternatively, if

-    maximizing, find the maximum number of characters and work backwards. */

-

-    DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,

-      max, eptr));

-

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-      fc = md->lcc[fc];

-      for (i = 1; i <= min; i++)

-        if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-      if (min == max) continue;

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject ||

-              fc != md->lcc[*eptr++])

-            RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break;

-          eptr++;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      /* Control never gets here */

-      }

-

-    /* Caseful comparisons (includes all multi-byte characters) */

-

-    else

-      {

-      for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH);

-      if (min == max) continue;

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject || fc != *eptr++)

-            RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject || fc != *eptr) break;

-          eptr++;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-    /* Match a negated single one-byte character. The character we are

-    checking can be multibyte. */

-

-    case OP_NOT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    GETCHARINCTEST(c, eptr);

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-#ifdef SUPPORT_UTF8

-      if (c < 256)

-#endif

-      c = md->lcc[c];

-      if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);

-      }

-    else

-      {

-      if (*ecode++ == c) RRETURN(MATCH_NOMATCH);

-      }

-    break;

-

-    /* Match a negated single one-byte character repeatedly. This is almost a

-    repeat of the code for a repeated single character, but I haven't found a

-    nice way of commoning these up that doesn't require a test of the

-    positive/negative option for each character match. Maybe that wouldn't add

-    very much to the time taken, but character matching *is* what this is all

-    about... */

-

-    case OP_NOTEXACT:

-    min = max = GET2(ecode, 1);

-    ecode += 3;

-    goto REPEATNOTCHAR;

-

-    case OP_NOTUPTO:

-    case OP_NOTMINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_NOTMINUPTO;

-    ecode += 3;

-    goto REPEATNOTCHAR;

-

-    case OP_NOTSTAR:

-    case OP_NOTMINSTAR:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTQUERY:

-    case OP_NOTMINQUERY:

-    c = *ecode++ - OP_NOTSTAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single-byte matches. We can give up quickly

-    if there are fewer than the minimum number of bytes left in the

-    subject. */

-

-    REPEATNOTCHAR:

-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-    fc = *ecode++;

-

-    /* The code is duplicated for the caseless and caseful cases, for speed,

-    since matching characters is likely to be quite common. First, ensure the

-    minimum number of matches are present. If min = max, continue at the same

-    level without recursing. Otherwise, if minimizing, keep trying the rest of

-    the expression and advancing one matching character if failing, up to the

-    maximum. Alternatively, if maximizing, find the maximum number of

-    characters and work backwards. */

-

-    DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,

-      max, eptr));

-

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-      fc = md->lcc[fc];

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        register int d;

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(d, eptr);

-          if (d < 256) d = md->lcc[d];

-          if (fc == d) RRETURN(MATCH_NOMATCH);

-          }

-        }

-      else

-#endif

-

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-        }

-

-      if (min == max) continue;

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            GETCHARINC(d, eptr);

-            if (d < 256) d = md->lcc[d];

-            if (fi >= max || eptr >= md->end_subject || fc == d)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++])

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* Maximize case */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(d, eptr, len);

-            if (d < 256) d = md->lcc[d];

-            if (fc == d) break;

-            eptr += len;

-            }

-          for(;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            eptr--;

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      /* Control never gets here */

-      }

-

-    /* Caseful comparisons */

-

-    else

-      {

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        register int d;

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(d, eptr);

-          if (fc == d) RRETURN(MATCH_NOMATCH);

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          if (fc == *eptr++) RRETURN(MATCH_NOMATCH);

-        }

-

-      if (min == max) continue;

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            GETCHARINC(d, eptr);

-            if (fi >= max || eptr >= md->end_subject || fc == d)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject || fc == *eptr++)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* Maximize case */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(d, eptr, len);

-            if (fc == d) break;

-            eptr += len;

-            }

-          for(;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || fc == *eptr) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            eptr--;

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-    /* Match a single character type repeatedly; several different opcodes

-    share code. This is very similar to the code for single characters, but we

-    repeat it in the interests of efficiency. */

-

-    case OP_TYPEEXACT:

-    min = max = GET2(ecode, 1);

-    minimize = TRUE;

-    ecode += 3;

-    goto REPEATTYPE;

-

-    case OP_TYPEUPTO:

-    case OP_TYPEMINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_TYPEMINUPTO;

-    ecode += 3;

-    goto REPEATTYPE;

-

-    case OP_TYPESTAR:

-    case OP_TYPEMINSTAR:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEQUERY:

-    case OP_TYPEMINQUERY:

-    c = *ecode++ - OP_TYPESTAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single character type matches. Note that

-    in UTF-8 mode, '.' matches a character of any length, but for the other

-    character types, the valid characters are all one-byte long. */

-

-    REPEATTYPE:

-    ctype = *ecode++;      /* Code for the character type */

-

-#ifdef SUPPORT_UCP

-    if (ctype == OP_PROP || ctype == OP_NOTPROP)

-      {

-      prop_fail_result = ctype == OP_NOTPROP;

-      prop_type = *ecode++;

-      if (prop_type >= 128)

-        {

-        prop_test_against = prop_type - 128;

-        prop_test_variable = &prop_category;

-        }

-      else

-        {

-        prop_test_against = prop_type;

-        prop_test_variable = &prop_chartype;

-        }

-      }

-    else prop_type = -1;

-#endif

-

-    /* First, ensure the minimum number of matches are present. Use inline

-    code for maximizing the speed, and do the type test once at the start

-    (i.e. keep it out of the loop). Also we can test that there are at least

-    the minimum number of bytes before we start. This isn't as effective in

-    UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that

-    is tidier. Also separate the UCP code, which can be the same for both UTF-8

-    and single-bytes. */

-

-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-    if (min > 0)

-      {

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-        }

-

-      else

-#endif     /* SUPPORT_UCP */

-

-/* Handle all other cases when the coding is UTF-8 */

-

-#ifdef SUPPORT_UTF8

-      if (utf8) switch(ctype)

-        {

-        case OP_ANY:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr++ == NEWLINE && (ims & PCRE_DOTALL) == 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_ANYBYTE:

-        eptr += min;

-        break;

-

-        case OP_NOT_DIGIT:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)

-            RRETURN(MATCH_NOMATCH);

-          }

-        break;

-

-        case OP_DIGIT:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        default:

-        RRETURN(PCRE_ERROR_INTERNAL);

-        }  /* End switch(ctype) */

-

-      else

-#endif     /* SUPPORT_UTF8 */

-

-      /* Code for the non-UTF-8 case for minimum matching of operators other

-      than OP_PROP and OP_NOTPROP. */

-

-      switch(ctype)

-        {

-        case OP_ANY:

-        if ((ims & PCRE_DOTALL) == 0)

-          {

-          for (i = 1; i <= min; i++)

-            if (*eptr++ == NEWLINE) RRETURN(MATCH_NOMATCH);

-          }

-        else eptr += min;

-        break;

-

-        case OP_ANYBYTE:

-        eptr += min;

-        break;

-

-        case OP_NOT_DIGIT:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_DIGIT:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_word) != 0)

-            RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_word) == 0)

-            RRETURN(MATCH_NOMATCH);

-        break;

-

-        default:

-        RRETURN(PCRE_ERROR_INTERNAL);

-        }

-      }

-

-    /* If min = max, continue at the same level without recursing */

-

-    if (min == max) continue;

-

-    /* If minimizing, we have to test the rest of the pattern before each

-    subsequent match. Again, separate the UTF-8 case for speed, and also

-    separate the UCP cases. */

-

-    if (minimize)

-      {

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-        }

-

-      else

-#endif     /* SUPPORT_UCP */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-

-          GETCHARINC(c, eptr);

-          switch(ctype)

-            {

-            case OP_ANY:

-            if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_ANYBYTE:

-            break;

-

-            case OP_NOT_DIGIT:

-            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_DIGIT:

-            if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WHITESPACE:

-            if (c < 256 && (md->ctypes[c] & ctype_space) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WHITESPACE:

-            if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WORDCHAR:

-            if (c < 256 && (md->ctypes[c] & ctype_word) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WORDCHAR:

-            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            default:

-            RRETURN(PCRE_ERROR_INTERNAL);

-            }

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          c = *eptr++;

-          switch(ctype)

-            {

-            case OP_ANY:

-            if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_ANYBYTE:

-            break;

-

-            case OP_NOT_DIGIT:

-            if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_DIGIT:

-            if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WHITESPACE:

-            if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WHITESPACE:

-            if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WORDCHAR:

-            if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WORDCHAR:

-            if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            default:

-            RRETURN(PCRE_ERROR_INTERNAL);

-            }

-          }

-        }

-      /* Control never gets here */

-      }

-

-    /* If maximizing it is worth using inline code for speed, doing the type

-    test once at the start (i.e. keep it out of the loop). Again, keep the

-    UTF-8 and UCP stuff separate. */

-

-    else

-      {

-      pp = eptr;  /* Remember where we started */

-

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (i = min; i < max; i++)

-          {

-          int len = 1;

-          if (eptr >= md->end_subject) break;

-          GETCHARLEN(c, eptr, len);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            break;

-          eptr+= len;

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject) break;

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) break;

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          for (;;)                        /* Move back over one extended */

-            {

-            int len = 1;

-            BACKCHAR(eptr);

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr--;

-            }

-          }

-        }

-

-      else

-#endif   /* SUPPORT_UCP */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-

-      if (utf8)

-        {

-        switch(ctype)

-          {

-          case OP_ANY:

-

-          /* Special code is required for UTF8, but when the maximum is unlimited

-          we don't need it, so we repeat the non-UTF8 code. This is probably

-          worth it, because .* is quite a common idiom. */

-

-          if (max < INT_MAX)

-            {

-            if ((ims & PCRE_DOTALL) == 0)

-              {

-              for (i = min; i < max; i++)

-                {

-                if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-                eptr++;

-                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-                }

-              }

-            else

-              {

-              for (i = min; i < max; i++)

-                {

-                eptr++;

-                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-                }

-              }

-            }

-

-          /* Handle unlimited UTF-8 repeat */

-

-          else

-            {

-            if ((ims & PCRE_DOTALL) == 0)

-              {

-              for (i = min; i < max; i++)

-                {

-                if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-                eptr++;

-                }

-              break;

-              }

-            else

-              {

-              c = max - min;

-              if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-              eptr += c;

-              }

-            }

-          break;

-

-          /* The byte case is the same as non-UTF8 */

-

-          case OP_ANYBYTE:

-          c = max - min;

-          if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-          eptr += c;

-          break;

-

-          case OP_NOT_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_NOT_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_NOT_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          default:

-          RRETURN(PCRE_ERROR_INTERNAL);

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr);

-          }

-        }

-      else

-#endif

-

-      /* Not UTF-8 mode */

-        {

-        switch(ctype)

-          {

-          case OP_ANY:

-          if ((ims & PCRE_DOTALL) == 0)

-            {

-            for (i = min; i < max; i++)

-              {

-              if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-              eptr++;

-              }

-            break;

-            }

-          /* For DOTALL case, fall through and treat as \C */

-

-          case OP_ANYBYTE:

-          c = max - min;

-          if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-          eptr += c;

-          break;

-

-          case OP_NOT_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_NOT_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_NOT_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          default:

-          RRETURN(PCRE_ERROR_INTERNAL);

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        }

-

-      /* Get here if we can't make it match with any permitted repetitions */

-

-      RRETURN(MATCH_NOMATCH);

-      }

-    /* Control never gets here */

-

-    /* There's been some horrible disaster. Since all codes > OP_BRA are

-    for capturing brackets, and there shouldn't be any gaps between 0 and

-    OP_BRA, arrival here can only mean there is something seriously wrong

-    in the code above or the OP_xxx definitions. */

-

-    default:

-    DPRINTF(("Unknown opcode %d\n", *ecode));

-    RRETURN(PCRE_ERROR_UNKNOWN_NODE);

-    }

-

-  /* Do not stick any code in here without much thought; it is assumed

-  that "continue" in the code above comes out to here to repeat the main

-  loop. */

-

-  }             /* End of main loop */

-/* Control never reaches here */

-}

-

-

-/***************************************************************************

-****************************************************************************

-                   RECURSION IN THE match() FUNCTION

-

-Undefine all the macros that were defined above to handle this. */

-

-#ifdef NO_RECURSE

-#undef eptr

-#undef ecode

-#undef offset_top

-#undef ims

-#undef eptrb

-#undef flags

-

-#undef callpat

-#undef charptr

-#undef data

-#undef next

-#undef pp

-#undef prev

-#undef saved_eptr

-

-#undef new_recursive

-

-#undef cur_is_word

-#undef condition

-#undef minimize

-#undef prev_is_word

-

-#undef original_ims

-

-#undef ctype

-#undef length

-#undef max

-#undef min

-#undef number

-#undef offset

-#undef op

-#undef save_capture_last

-#undef save_offset1

-#undef save_offset2

-#undef save_offset3

-#undef stacksave

-

-#undef newptrb

-

-#endif

-

-/* These two are defined as macros in both cases */

-

-#undef fc

-#undef fi

-

-/***************************************************************************

-***************************************************************************/

-

-

-

-/*************************************************

-*         Execute a Regular Expression           *

-*************************************************/

-

-/* This function applies a compiled re to a subject string and picks out

-portions of the string if it matches. Two elements in the vector are set for

-each substring: the offsets to the start and end of the substring.

-

-Arguments:

-  argument_re     points to the compiled expression

-  extra_data      points to extra data or is NULL

-  subject         points to the subject string

-  length          length of subject string (may contain binary zeros)

-  start_offset    where to start in the subject string

-  options         option bits

-  offsets         points to a vector of ints to be filled in with offsets

-  offsetcount     the number of elements in the vector

-

-Returns:          > 0 => success; value is the number of elements filled in

-                  = 0 => success, but offsets is not big enough

-                   -1 => failed to match

-                 < -1 => some kind of unexpected problem

-*/

-

-EXPORT int

-pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,

-  const char *subject, int length, int start_offset, int options, int *offsets,

-  int offsetcount)

-{

-int rc, resetcount, ocount;

-int first_byte = -1;

-int req_byte = -1;

-int req_byte2 = -1;

-unsigned long int ims = 0;

-BOOL using_temporary_offsets = FALSE;

-BOOL anchored;

-BOOL startline;

-BOOL firstline;

-BOOL first_byte_caseless = FALSE;

-BOOL req_byte_caseless = FALSE;

-match_data match_block;

-const uschar *tables;

-const uschar *start_bits = NULL;

-const uschar *start_match = (const uschar *)subject + start_offset;

-const uschar *end_subject;

-const uschar *req_byte_ptr = start_match - 1;

-

-pcre_study_data internal_study;

-const pcre_study_data *study;

-

-real_pcre internal_re;

-const real_pcre *external_re = (const real_pcre *)argument_re;

-const real_pcre *re = external_re;

-

-/* Plausibility checks */

-

-if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;

-if (re == NULL || subject == NULL ||

-   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;

-if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;

-

-/* Fish out the optional data from the extra_data structure, first setting

-the default values. */

-

-study = NULL;

-match_block.match_limit = MATCH_LIMIT;

-match_block.callout_data = NULL;

-

-/* The table pointer is always in native byte order. */

-

-tables = external_re->tables;

-

-if (extra_data != NULL)

-  {

-  register unsigned int flags = extra_data->flags;

-  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)

-    study = (const pcre_study_data *)extra_data->study_data;

-  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0)

-    match_block.match_limit = extra_data->match_limit;

-  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)

-    match_block.callout_data = extra_data->callout_data;

-  if ((flags & PCRE_EXTRA_TABLES) != 0) tables = extra_data->tables;

-  }

-

-/* If the exec call supplied NULL for tables, use the inbuilt ones. This

-is a feature that makes it possible to save compiled regex and re-use them

-in other programs later. */

-

-if (tables == NULL) tables = _pcre_default_tables;

-

-/* Check that the first field in the block is the magic number. If it is not,

-test for a regex that was compiled on a host of opposite endianness. If this is

-the case, flipped values are put in internal_re and internal_study if there was

-study data too. */

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-/* Set up other data */

-

-anchored = ((re->options | options) & PCRE_ANCHORED) != 0;

-startline = (re->options & PCRE_STARTLINE) != 0;

-firstline = (re->options & PCRE_FIRSTLINE) != 0;

-

-/* The code starts after the real_pcre block and the capture name table. */

-

-match_block.start_code = (const uschar *)external_re + re->name_table_offset +

-  re->name_count * re->name_entry_size;

-

-match_block.start_subject = (const uschar *)subject;

-match_block.start_offset = start_offset;

-match_block.end_subject = match_block.start_subject + length;

-end_subject = match_block.end_subject;

-

-match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;

-match_block.utf8 = (re->options & PCRE_UTF8) != 0;

-

-match_block.notbol = (options & PCRE_NOTBOL) != 0;

-match_block.noteol = (options & PCRE_NOTEOL) != 0;

-match_block.notempty = (options & PCRE_NOTEMPTY) != 0;

-match_block.partial = (options & PCRE_PARTIAL) != 0;

-match_block.hitend = FALSE;

-

-match_block.recursive = NULL;                   /* No recursion at top level */

-

-match_block.lcc = tables + lcc_offset;

-match_block.ctypes = tables + ctypes_offset;

-

-/* Partial matching is supported only for a restricted set of regexes at the

-moment. */

-

-if (match_block.partial && (re->options & PCRE_NOPARTIAL) != 0)

-  return PCRE_ERROR_BADPARTIAL;

-

-/* Check a UTF-8 string if required. Unfortunately there's no way of passing

-back the character offset. */

-

-#ifdef SUPPORT_UTF8

-if (match_block.utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)

-  {

-  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)

-    return PCRE_ERROR_BADUTF8;

-  if (start_offset > 0 && start_offset < length)

-    {

-    int tb = ((uschar *)subject)[start_offset];

-    if (tb > 127)

-      {

-      tb &= 0xc0;

-      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;

-      }

-    }

-  }

-#endif

-

-/* The ims options can vary during the matching as a result of the presence

-of (?ims) items in the pattern. They are kept in a local variable so that

-restoring at the exit of a group is easy. */

-

-ims = re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);

-

-/* If the expression has got more back references than the offsets supplied can

-hold, we get a temporary chunk of working store to use during the matching.

-Otherwise, we can use the vector supplied, rounding down its size to a multiple

-of 3. */

-

-ocount = offsetcount - (offsetcount % 3);

-

-if (re->top_backref > 0 && re->top_backref >= ocount/3)

-  {

-  ocount = re->top_backref * 3 + 3;

-  match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));

-  if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;

-  using_temporary_offsets = TRUE;

-  DPRINTF(("Got memory to hold back references\n"));

-  }

-else match_block.offset_vector = offsets;

-

-match_block.offset_end = ocount;

-match_block.offset_max = (2*ocount)/3;

-match_block.offset_overflow = FALSE;

-match_block.capture_last = -1;

-

-/* Compute the minimum number of offsets that we need to reset each time. Doing

-this makes a huge difference to execution time when there aren't many brackets

-in the pattern. */

-

-resetcount = 2 + re->top_bracket * 2;

-if (resetcount > offsetcount) resetcount = ocount;

-

-/* Reset the working variable associated with each extraction. These should

-never be used unless previously set, but they get saved and restored, and so we

-initialize them to avoid reading uninitialized locations. */

-

-if (match_block.offset_vector != NULL)

-  {

-  register int *iptr = match_block.offset_vector + ocount;

-  register int *iend = iptr - resetcount/2 + 1;

-  while (--iptr >= iend) *iptr = -1;

-  }

-

-/* Set up the first character to match, if available. The first_byte value is

-never set for an anchored regular expression, but the anchoring may be forced

-at run time, so we have to test for anchoring. The first char may be unset for

-an unanchored pattern, of course. If there's no first char and the pattern was

-studied, there may be a bitmap of possible first characters. */

-

-if (!anchored)

-  {

-  if ((re->options & PCRE_FIRSTSET) != 0)

-    {

-    first_byte = re->first_byte & 255;

-    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)

-      first_byte = match_block.lcc[first_byte];

-    }

-  else

-    if (!startline && study != NULL &&

-      (study->options & PCRE_STUDY_MAPPED) != 0)

-        start_bits = study->start_bits;

-  }

-

-/* For anchored or unanchored matches, there may be a "last known required

-character" set. */

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  req_byte = re->req_byte & 255;

-  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;

-  req_byte2 = (tables + fcc_offset)[req_byte];  /* case flipped */

-  }

-

-/* Loop for handling unanchored repeated matching attempts; for anchored regexs

-the loop runs just once. */

-

-do

-  {

-  const uschar *save_end_subject = end_subject;

-

-  /* Reset the maximum number of extractions we might see. */

-

-  if (match_block.offset_vector != NULL)

-    {

-    register int *iptr = match_block.offset_vector;

-    register int *iend = iptr + resetcount;

-    while (iptr < iend) *iptr++ = -1;

-    }

-

-  /* Advance to a unique first char if possible. If firstline is TRUE, the

-  start of the match is constrained to the first line of a multiline string.

-  Implement this by temporarily adjusting end_subject so that we stop scanning

-  at a newline. If the match fails at the newline, later code breaks this loop.

-  */

-

-  if (firstline)

-    {

-    const uschar *t = start_match;

-    while (t < save_end_subject && *t != '\n') t++;

-    end_subject = t;

-    }

-

-  /* Now test for a unique first byte */

-

-  if (first_byte >= 0)

-    {

-    if (first_byte_caseless)

-      while (start_match < end_subject &&

-             match_block.lcc[*start_match] != first_byte)

-        start_match++;

-    else

-      while (start_match < end_subject && *start_match != first_byte)

-        start_match++;

-    }

-

-  /* Or to just after \n for a multiline match if possible */

-

-  else if (startline)

-    {

-    if (start_match > match_block.start_subject + start_offset)

-      {

-      while (start_match < end_subject && start_match[-1] != NEWLINE)

-        start_match++;

-      }

-    }

-

-  /* Or to a non-unique first char after study */

-

-  else if (start_bits != NULL)

-    {

-    while (start_match < end_subject)

-      {

-      register unsigned int c = *start_match;

-      if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break;

-      }

-    }

-

-  /* Restore fudged end_subject */

-

-  end_subject = save_end_subject;

-

-#ifdef DEBUG  /* Sigh. Some compilers never learn. */

-  printf(">>>> Match against: ");

-  pchars(start_match, end_subject - start_match, TRUE, &match_block);

-  printf("\n");

-#endif

-

-  /* If req_byte is set, we know that that character must appear in the subject

-  for the match to succeed. If the first character is set, req_byte must be

-  later in the subject; otherwise the test starts at the match point. This

-  optimization can save a huge amount of backtracking in patterns with nested

-  unlimited repeats that aren't going to match. Writing separate code for

-  cased/caseless versions makes it go faster, as does using an autoincrement

-  and backing off on a match.

-

-  HOWEVER: when the subject string is very, very long, searching to its end can

-  take a long time, and give bad performance on quite ordinary patterns. This

-  showed up when somebody was matching /^C/ on a 32-megabyte string... so we

-  don't do this when the string is sufficiently long.

-

-  ALSO: this processing is disabled when partial matching is requested.

-  */

-

-  if (req_byte >= 0 &&

-      end_subject - start_match < REQ_BYTE_MAX &&

-      !match_block.partial)

-    {

-    register const uschar *p = start_match + ((first_byte >= 0)? 1 : 0);

-

-    /* We don't need to repeat the search if we haven't yet reached the

-    place we found it at last time. */

-

-    if (p > req_byte_ptr)

-      {

-      if (req_byte_caseless)

-        {

-        while (p < end_subject)

-          {

-          register int pp = *p++;

-          if (pp == req_byte || pp == req_byte2) { p--; break; }

-          }

-        }

-      else

-        {

-        while (p < end_subject)

-          {

-          if (*p++ == req_byte) { p--; break; }

-          }

-        }

-

-      /* If we can't find the required character, break the matching loop */

-

-      if (p >= end_subject) break;

-

-      /* If we have found the required character, save the point where we

-      found it, so that we don't search again next time round the loop if

-      the start hasn't passed this character yet. */

-

-      req_byte_ptr = p;

-      }

-    }

-

-  /* When a match occurs, substrings will be set for all internal extractions;

-  we just need to set up the whole thing as substring 0 before returning. If

-  there were too many extractions, set the return code to zero. In the case

-  where we had to get some local store to hold offsets for backreferences, copy

-  those back references that we can. In this case there need not be overflow

-  if certain parts of the pattern were not used. */

-

-  match_block.start_match = start_match;

-  match_block.match_call_count = 0;

-

-  rc = match(start_match, match_block.start_code, 2, &match_block, ims, NULL,

-    match_isgroup);

-

-  /* When the result is no match, if the subject's first character was a

-  newline and the PCRE_FIRSTLINE option is set, break (which will return

-  PCRE_ERROR_NOMATCH). The option requests that a match occur before the first

-  newline in the subject. Otherwise, advance the pointer to the next character

-  and continue - but the continuation will actually happen only when the

-  pattern is not anchored. */

-

-  if (rc == MATCH_NOMATCH)

-    {

-    if (firstline && *start_match == NEWLINE) break;

-    start_match++;

-#ifdef SUPPORT_UTF8

-    if (match_block.utf8)

-      while(start_match < end_subject && (*start_match & 0xc0) == 0x80)

-        start_match++;

-#endif

-    continue;

-    }

-

-  if (rc != MATCH_MATCH)

-    {

-    DPRINTF((">>>> error: returning %d\n", rc));

-    return rc;

-    }

-

-  /* We have a match! Copy the offset information from temporary store if

-  necessary */

-

-  if (using_temporary_offsets)

-    {

-    if (offsetcount >= 4)

-      {

-      memcpy(offsets + 2, match_block.offset_vector + 2,

-        (offsetcount - 2) * sizeof(int));

-      DPRINTF(("Copied offsets from temporary memory\n"));

-      }

-    if (match_block.end_offset_top > offsetcount)

-      match_block.offset_overflow = TRUE;

-

-    DPRINTF(("Freeing temporary memory\n"));

-    (pcre_free)(match_block.offset_vector);

-    }

-

-  rc = match_block.offset_overflow? 0 : match_block.end_offset_top/2;

-

-  if (offsetcount < 2) rc = 0; else

-    {

-    offsets[0] = start_match - match_block.start_subject;

-    offsets[1] = match_block.end_match_ptr - match_block.start_subject;

-    }

-

-  DPRINTF((">>>> returning %d\n", rc));

-  return rc;

-  }

-

-/* This "while" is the end of the "do" above */

-

-while (!anchored && start_match <= end_subject);

-

-if (using_temporary_offsets)

-  {

-  DPRINTF(("Freeing temporary memory\n"));

-  (pcre_free)(match_block.offset_vector);

-  }

-

-if (match_block.partial && match_block.hitend)

-  {

-  DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));

-  return PCRE_ERROR_PARTIAL;

-  }

-else

-  {

-  DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));

-  return PCRE_ERROR_NOMATCH;

-  }

-}

-

-/* End of pcre_exec.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/*PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_fullinfo(), which returns

-information about a compiled pattern. */

-

-

-

-

-/*************************************************

-*        Return info about compiled pattern      *

-*************************************************/

-

-/* This is a newer "info" function which has an extensible interface so

-that additional items can be added compatibly.

-

-Arguments:

-  argument_re      points to compiled code

-  extra_data       points extra data, or NULL

-  what             what information is required

-  where            where to put the information

-

-Returns:           0 if data returned, negative on error

-*/

-

-EXPORT int

-pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,

-  void *where)

-{

-real_pcre internal_re;

-pcre_study_data internal_study;

-const real_pcre *re = (const real_pcre *)argument_re;

-const pcre_study_data *study = NULL;

-

-if (re == NULL || where == NULL) return PCRE_ERROR_NULL;

-

-if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)

-  study = (const pcre_study_data *)extra_data->study_data;

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-switch (what)

-  {

-  case PCRE_INFO_OPTIONS:

-  *((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;

-  break;

-

-  case PCRE_INFO_SIZE:

-  *((size_t *)where) = re->size;

-  break;

-

-  case PCRE_INFO_STUDYSIZE:

-  *((size_t *)where) = (study == NULL)? 0 : study->size;

-  break;

-

-  case PCRE_INFO_CAPTURECOUNT:

-  *((int *)where) = re->top_bracket;

-  break;

-

-  case PCRE_INFO_BACKREFMAX:

-  *((int *)where) = re->top_backref;

-  break;

-

-  case PCRE_INFO_FIRSTBYTE:

-  *((int *)where) =

-    ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :

-    ((re->options & PCRE_STARTLINE) != 0)? -1 : -2;

-  break;

-

-  /* Make sure we pass back the pointer to the bit vector in the external

-  block, not the internal copy (with flipped integer fields). */

-

-  case PCRE_INFO_FIRSTTABLE:

-  *((const uschar **)where) =

-    (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?

-      ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;

-  break;

-

-  case PCRE_INFO_LASTLITERAL:

-  *((int *)where) =

-    ((re->options & PCRE_REQCHSET) != 0)? re->req_byte : -1;

-  break;

-

-  case PCRE_INFO_NAMEENTRYSIZE:

-  *((int *)where) = re->name_entry_size;

-  break;

-

-  case PCRE_INFO_NAMECOUNT:

-  *((int *)where) = re->name_count;

-  break;

-

-  case PCRE_INFO_NAMETABLE:

-  *((const uschar **)where) = (const uschar *)re + re->name_table_offset;

-  break;

-

-  case PCRE_INFO_DEFAULT_TABLES:

-  *((const uschar **)where) = (const uschar *)(_pcre_default_tables);

-  break;

-

-  default: return PCRE_ERROR_BADOPTION;

-  }

-

-return 0;

-}

-

-/* End of pcre_fullinfo.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains some convenience functions for extracting substrings

-from the subject string after a regex match has succeeded. The original idea

-for these functions came from Scott Wimer. */

-

-

-

-

-/*************************************************

-*           Find number for named string         *

-*************************************************/

-

-/* This function is used by the two extraction functions below, as well

-as being generally available.

-

-Arguments:

-  code        the compiled regex

-  stringname  the name whose number is required

-

-Returns:      the number of the named parentheses, or a negative number

-                (PCRE_ERROR_NOSUBSTRING) if not found

-*/

-

-int

-pcre_get_stringnumber(const pcre *code, const char *stringname)

-{

-int rc;

-int entrysize;

-int top, bot;

-uschar *nametable;

-

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)

-  return rc;

-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;

-

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)

-  return rc;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)

-  return rc;

-

-bot = 0;

-while (top > bot)

-  {

-  int mid = (top + bot) / 2;

-  uschar *entry = nametable + entrysize*mid;

-  int c = strcmp(stringname, (char *)(entry + 2));

-  if (c == 0) return (entry[0] << 8) + entry[1];

-  if (c > 0) bot = mid + 1; else top = mid;

-  }

-

-return PCRE_ERROR_NOSUBSTRING;

-}

-

-

-

-/*************************************************

-*      Copy captured string to given buffer      *

-*************************************************/

-

-/* This function copies a single captured substring into a given buffer.

-Note that we use memcpy() rather than strncpy() in case there are binary zeros

-in the string.

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringnumber   the number of the required substring

-  buffer         where to put the substring

-  size           the size of the buffer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) buffer too small

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_copy_substring(const char *subject, int *ovector, int stringcount,

-  int stringnumber, char *buffer, int size)

-{

-int yield;

-if (stringnumber < 0 || stringnumber >= stringcount)

-  return PCRE_ERROR_NOSUBSTRING;

-stringnumber *= 2;

-yield = ovector[stringnumber+1] - ovector[stringnumber];

-if (size < yield + 1) return PCRE_ERROR_NOMEMORY;

-memcpy(buffer, subject + ovector[stringnumber], yield);

-buffer[yield] = 0;

-return yield;

-}

-

-

-

-/*************************************************

-*   Copy named captured string to given buffer   *

-*************************************************/

-

-/* This function copies a single captured substring into a given buffer,

-identifying it by name.

-

-Arguments:

-  code           the compiled regex

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringname     the name of the required substring

-  buffer         where to put the substring

-  size           the size of the buffer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) buffer too small

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,

-  int stringcount, const char *stringname, char *buffer, int size)

-{

-int n = pcre_get_stringnumber(code, stringname);

-if (n <= 0) return n;

-return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);

-}

-

-

-

-/*************************************************

-*      Copy all captured strings to new store    *

-*************************************************/

-

-/* This function gets one chunk of store and builds a list of pointers and all

-of the captured substrings in it. A NULL pointer is put on the end of the list.

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  listptr        set to point to the list of pointers

-

-Returns:         if successful: 0

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) failed to get store

-*/

-

-int

-pcre_get_substring_list(const char *subject, int *ovector, int stringcount,

-  const char ***listptr)

-{

-int i;

-int size = sizeof(char *);

-int double_count = stringcount * 2;

-char **stringlist;

-char *p;

-

-for (i = 0; i < double_count; i += 2)

-  size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;

-

-stringlist = (char **)(pcre_malloc)(size);

-if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;

-

-*listptr = (const char **)stringlist;

-p = (char *)(stringlist + stringcount + 1);

-

-for (i = 0; i < double_count; i += 2)

-  {

-  int len = ovector[i+1] - ovector[i];

-  memcpy(p, subject + ovector[i], len);

-  *stringlist++ = p;

-  p += len;

-  *p++ = 0;

-  }

-

-*stringlist = NULL;

-return 0;

-}

-

-

-

-/*************************************************

-*   Free store obtained by get_substring_list    *

-*************************************************/

-

-/* This function exists for the benefit of people calling PCRE from non-C

-programs that can call its functions, but not free() or (pcre_free)() directly.

-

-Argument:   the result of a previous pcre_get_substring_list()

-Returns:    nothing

-*/

-

-void

-pcre_free_substring_list(const char **pointer)

-{

-(pcre_free)((void *)pointer);

-}

-

-

-

-/*************************************************

-*      Copy captured string to new store         *

-*************************************************/

-

-/* This function copies a single captured substring into a piece of new

-store

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringnumber   the number of the required substring

-  stringptr      where to put a pointer to the substring

-

-Returns:         if successful:

-                   the length of the string, not including the zero that

-                   is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) failed to get store

-                   PCRE_ERROR_NOSUBSTRING (-7) substring not present

-*/

-

-int

-pcre_get_substring(const char *subject, int *ovector, int stringcount,

-  int stringnumber, const char **stringptr)

-{

-int yield;

-char *substring;

-if (stringnumber < 0 || stringnumber >= stringcount)

-  return PCRE_ERROR_NOSUBSTRING;

-stringnumber *= 2;

-yield = ovector[stringnumber+1] - ovector[stringnumber];

-substring = (char *)(pcre_malloc)(yield + 1);

-if (substring == NULL) return PCRE_ERROR_NOMEMORY;

-memcpy(substring, subject + ovector[stringnumber], yield);

-substring[yield] = 0;

-*stringptr = substring;

-return yield;

-}

-

-

-

-/*************************************************

-*   Copy named captured string to new store      *

-*************************************************/

-

-/* This function copies a single captured substring, identified by name, into

-new store.

-

-Arguments:

-  code           the compiled regex

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringname     the name of the required substring

-  stringptr      where to put the pointer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) couldn't get memory

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,

-  int stringcount, const char *stringname, const char **stringptr)

-{

-int n = pcre_get_stringnumber(code, stringname);

-if (n <= 0) return n;

-return pcre_get_substring(subject, ovector, stringcount, n, stringptr);

-}

-

-

-

-

-/*************************************************

-*       Free store obtained by get_substring     *

-*************************************************/

-

-/* This function exists for the benefit of people calling PCRE from non-C

-programs that can call its functions, but not free() or (pcre_free)() directly.

-

-Argument:   the result of a previous pcre_get_substring()

-Returns:    nothing

-*/

-

-void

-pcre_free_substring(const char *pointer)

-{

-(pcre_free)((void *)pointer);

-}

-

-/* End of pcre_get.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains global variables that are exported by the PCRE library.

-PCRE is thread-clean and doesn't use any global variables in the normal sense.

-However, it calls memory allocation and freeing functions via the four

-indirections below, and it can optionally do callouts, using the fifth

-indirection. These values can be changed by the caller, but are shared between

-all threads. However, when compiling for Virtual Pascal, things are done

-differently, and global variables are not used (see pcre.in). */

-

-

-

-

-#ifndef VPCOMPAT

-#ifdef __cplusplus

-extern "C" void *(*pcre_malloc)(size_t) = malloc;

-extern "C" void  (*pcre_free)(void *) = free;

-extern "C" void *(*pcre_stack_malloc)(size_t) = malloc;

-extern "C" void  (*pcre_stack_free)(void *) = free;

-extern "C" int   (*pcre_callout)(pcre_callout_block *) = NULL;

-#else

-void *(*pcre_malloc)(size_t) = malloc;

-void  (*pcre_free)(void *) = free;

-void *(*pcre_stack_malloc)(size_t) = malloc;

-void  (*pcre_stack_free)(void *) = free;

-int   (*pcre_callout)(pcre_callout_block *) = NULL;

-#endif

-#endif

-

-/* End of pcre_globals.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_info(), which gives some

-information about a compiled pattern. However, use of this function is now

-deprecated, as it has been superseded by pcre_fullinfo(). */

-

-

-

-

-/*************************************************

-* (Obsolete) Return info about compiled pattern  *

-*************************************************/

-

-/* This is the original "info" function. It picks potentially useful data out

-of the private structure, but its interface was too rigid. It remains for

-backwards compatibility. The public options are passed back in an int - though

-the re->options field has been expanded to a long int, all the public options

-at the low end of it, and so even on 16-bit systems this will still be OK.

-Therefore, I haven't changed the API for pcre_info().

-

-Arguments:

-  argument_re   points to compiled code

-  optptr        where to pass back the options

-  first_byte    where to pass back the first character,

-                or -1 if multiline and all branches start ^,

-                or -2 otherwise

-

-Returns:        number of capturing subpatterns

-                or negative values on error

-*/

-

-EXPORT int

-pcre_info(const pcre *argument_re, int *optptr, int *first_byte)

-{

-real_pcre internal_re;

-const real_pcre *re = (const real_pcre *)argument_re;

-if (re == NULL) return PCRE_ERROR_NULL;

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, NULL, NULL);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  }

-if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);

-if (first_byte != NULL)

-  *first_byte = ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :

-     ((re->options & PCRE_STARTLINE) != 0)? -1 : -2;

-return re->top_bracket;

-}

-

-/* End of pcre_info.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_maketables(), which builds

-character tables for PCRE in the current locale. The file is compiled on its

-own as part of the PCRE library. However, it is also included in the

-compilation of dftables.c, in which case the macro DFTABLES is defined. */

-

-

-#ifndef DFTABLES

-#endif

-

-

-/*************************************************

-*           Create PCRE character tables         *

-*************************************************/

-

-/* This function builds a set of character tables for use by PCRE and returns

-a pointer to them. They are build using the ctype functions, and consequently

-their contents will depend upon the current locale setting. When compiled as

-part of the library, the store is obtained via pcre_malloc(), but when compiled

-inside dftables, use malloc().

-

-Arguments:   none

-Returns:     pointer to the contiguous block of data

-*/

-

-const unsigned char *

-pcre_maketables(void)

-{

-unsigned char *yield, *p;

-int i;

-

-#ifndef DFTABLES

-yield = (unsigned char*)(pcre_malloc)(tables_length);

-#else

-yield = (unsigned char*)malloc(tables_length);

-#endif

-

-if (yield == NULL) return NULL;

-p = yield;

-

-/* First comes the lower casing table */

-

-for (i = 0; i < 256; i++) *p++ = tolower(i);

-

-/* Next the case-flipping table */

-

-for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);

-

-/* Then the character class tables. Don't try to be clever and save effort

-on exclusive ones - in some locales things may be different. Note that the

-table for "space" includes everything "isspace" gives, including VT in the

-default locale. This makes it work for the POSIX class [:space:]. */

-

-memset(p, 0, cbit_length);

-for (i = 0; i < 256; i++)

-  {

-  if (isdigit(i))

-    {

-    p[cbit_digit  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (isupper(i))

-    {

-    p[cbit_upper  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (islower(i))

-    {

-    p[cbit_lower  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);

-  if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);

-  if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);

-  if (isgraph(i)) p[cbit_graph  + i/8] |= 1 << (i&7);

-  if (isprint(i)) p[cbit_print  + i/8] |= 1 << (i&7);

-  if (ispunct(i)) p[cbit_punct  + i/8] |= 1 << (i&7);

-  if (iscntrl(i)) p[cbit_cntrl  + i/8] |= 1 << (i&7);

-  }

-p += cbit_length;

-

-/* Finally, the character type table. In this, we exclude VT from the white

-space chars, because Perl doesn't recognize it as such for \s and for comments

-within regexes. */

-

-for (i = 0; i < 256; i++)

-  {

-  int x = 0;

-  if (i != 0x0b && isspace(i)) x += ctype_space;

-  if (isalpha(i)) x += ctype_letter;

-  if (isdigit(i)) x += ctype_digit;

-  if (isxdigit(i)) x += ctype_xdigit;

-  if (isalnum(i) || i == '_') x += ctype_word;

-

-  /* Note: strchr includes the terminating zero in the characters it considers.

-  In this instance, that is ok because we want binary zero to be flagged as a

-  meta-character, which in this sense is any character that terminates a run

-  of data characters. */

-

-  if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta; *p++ = x; }

-

-return yield;

-}

-

-/* End of pcre_maketables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This file contains a private PCRE function that converts an ordinal

-character value into a UTF8 string. */

-

-

-

-

-/*************************************************

-*       Convert character value to UTF-8         *

-*************************************************/

-

-/* This function takes an integer value in the range 0 - 0x7fffffff

-and encodes it as a UTF-8 character in 0 to 6 bytes.

-

-Arguments:

-  cvalue     the character value

-  buffer     pointer to buffer for result - at least 6 bytes long

-

-Returns:     number of characters placed in the buffer

-*/

-

-EXPORT int

-_pcre_ord2utf8(int cvalue, uschar *buffer)

-{

-register int i, j;

-for (i = 0; i < _pcre_utf8_table1_size; i++)

-  if (cvalue <= _pcre_utf8_table1[i]) break;

-buffer += i;

-for (j = i; j > 0; j--)

- {

- *buffer-- = 0x80 | (cvalue & 0x3f);

- cvalue >>= 6;

- }

-*buffer = _pcre_utf8_table2[i] | cvalue;

-return i + 1;

-}

-

-/* End of pcre_ord2utf8.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an PCRE private debugging function for printing out the

-internal form of a compiled regular expression, along with some supporting

-local functions. */

-

-

-

-

-static const char *OP_names[] = { OP_NAME_LIST };

-

-

-/*************************************************

-*       Print single- or multi-byte character    *

-*************************************************/

-

-static int

-print_char(FILE *f, uschar *ptr, BOOL utf8)

-{

-int c = *ptr;

-

-if (!utf8 || (c & 0xc0) != 0xc0)

-  {

-  if (isprint(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);

-  return 0;

-  }

-else

-  {

-  int i;

-  int a = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */

-  int s = 6*a;

-  c = (c & _pcre_utf8_table3[a]) << s;

-  for (i = 1; i <= a; i++)

-    {

-    /* This is a check for malformed UTF-8; it should only occur if the sanity

-    check has been turned off. Rather than swallow random bytes, just stop if

-    we hit a bad one. Print it with \X instead of \x as an indication. */

-

-    if ((ptr[i] & 0xc0) != 0x80)

-      {

-      fprintf(f, "\\X{%x}", c);

-      return i - 1;

-      }

-

-    /* The byte is OK */

-

-    s -= 6;

-    c |= (ptr[i] & 0x3f) << s;

-    }

-  if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);

-  return a;

-  }

-}

-

-

-

-/*************************************************

-*          Find Unicode property name            *

-*************************************************/

-

-static const char *

-get_ucpname(int property)

-{

-#ifdef SUPPORT_UCP

-int i;

-for (i = _pcre_utt_size; i >= 0; i--)

-  {

-  if (property == _pcre_utt[i].value) break;

-  }

-return (i >= 0)? _pcre_utt[i].name : "??";

-#else

-return "??";

-#endif

-}

-

-

-

-/*************************************************

-*         Print compiled regex                   *

-*************************************************/

-

-/* Make this function work for a regex with integers either byte order.

-However, we assume that what we are passed is a compiled regex. */

-

-EXPORT void

-_pcre_printint(pcre *external_re, FILE *f)

-{

-real_pcre *re = (real_pcre *)external_re;

-uschar *codestart, *code;

-BOOL utf8;

-

-unsigned int options = re->options;

-int offset = re->name_table_offset;

-int count = re->name_count;

-int size = re->name_entry_size;

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);

-  count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);

-  size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);

-  options = ((options << 24) & 0xff000000) |

-            ((options <<  8) & 0x00ff0000) |

-            ((options >>  8) & 0x0000ff00) |

-            ((options >> 24) & 0x000000ff);

-  }

-

-code = codestart = (uschar *)re + offset + count * size;

-utf8 = (options & PCRE_UTF8) != 0;

-

-for(;;)

-  {

-  uschar *ccode;

-  int c;

-  int extra = 0;

-

-  fprintf(f, "%3d ", (int)(code - codestart));

-

-  if (*code >= OP_BRA)

-    {

-    if (*code - OP_BRA > EXTRACT_BASIC_MAX)

-      fprintf(f, "%3d Bra extra\n", GET(code, 1));

-    else

-      fprintf(f, "%3d Bra %d\n", GET(code, 1), *code - OP_BRA);

-    code += _pcre_OP_lengths[OP_BRA];

-    continue;

-    }

-

-  switch(*code)

-    {

-    case OP_END:

-    fprintf(f, "    %s\n", OP_names[*code]);

-    fprintf(f, "------------------------------------------------------------------\n");

-    return;

-

-    case OP_OPT:

-    fprintf(f, " %.2x %s", code[1], OP_names[*code]);

-    break;

-

-    case OP_CHAR:

-      {

-      fprintf(f, "    ");

-      do

-        {

-        code++;

-        code += 1 + print_char(f, code, utf8);

-        }

-      while (*code == OP_CHAR);

-      fprintf(f, "\n");

-      continue;

-      }

-    break;

-

-    case OP_CHARNC:

-      {

-      fprintf(f, " NC ");

-      do

-        {

-        code++;

-        code += 1 + print_char(f, code, utf8);

-        }

-      while (*code == OP_CHARNC);

-      fprintf(f, "\n");

-      continue;

-      }

-    break;

-

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_ALT:

-    case OP_KET:

-    case OP_ASSERT:

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    case OP_ONCE:

-    case OP_COND:

-    case OP_REVERSE:

-    fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);

-    break;

-

-    case OP_BRANUMBER:

-    printf("%3d %s", GET2(code, 1), OP_names[*code]);

-    break;

-

-    case OP_CREF:

-    if (GET2(code, 1) == CREF_RECURSE)

-      fprintf(f, "    Cond recurse");

-    else

-      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);

-    break;

-

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    case OP_TYPESTAR:

-    case OP_TYPEMINSTAR:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEQUERY:

-    case OP_TYPEMINQUERY:

-    fprintf(f, "    ");

-    if (*code >= OP_TYPESTAR)

-      {

-      fprintf(f, "%s", OP_names[code[1]]);

-      if (code[1] == OP_PROP || code[1] == OP_NOTPROP)

-        {

-        fprintf(f, " %s ", get_ucpname(code[2]));

-        extra = 1;

-        }

-      }

-    else extra = print_char(f, code+1, utf8);

-    fprintf(f, "%s", OP_names[*code]);

-    break;

-

-    case OP_EXACT:

-    case OP_UPTO:

-    case OP_MINUPTO:

-    fprintf(f, "    ");

-    extra = print_char(f, code+3, utf8);

-    fprintf(f, "{");

-    if (*code != OP_EXACT) fprintf(f, ",");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_MINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_TYPEEXACT:

-    case OP_TYPEUPTO:

-    case OP_TYPEMINUPTO:

-    fprintf(f, "    %s", OP_names[code[3]]);

-    if (code[3] == OP_PROP || code[3] == OP_NOTPROP)

-      {

-      fprintf(f, " %s ", get_ucpname(code[4]));

-      extra = 1;

-      }

-    fprintf(f, "{");

-    if (*code != OP_TYPEEXACT) fprintf(f, "0,");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_TYPEMINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_NOT:

-    if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);

-      else fprintf(f, "    [^\\x%02x]", c);

-    break;

-

-    case OP_NOTSTAR:

-    case OP_NOTMINSTAR:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTQUERY:

-    case OP_NOTMINQUERY:

-    if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);

-      else fprintf(f, "    [^\\x%02x]", c);

-    fprintf(f, "%s", OP_names[*code]);

-    break;

-

-    case OP_NOTEXACT:

-    case OP_NOTUPTO:

-    case OP_NOTMINUPTO:

-    if (isprint(c = code[3])) fprintf(f, "    [^%c]{", c);

-      else fprintf(f, "    [^\\x%02x]{", c);

-    if (*code != OP_NOTEXACT) fprintf(f, "0,");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_NOTMINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_RECURSE:

-    fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);

-    break;

-

-    case OP_REF:

-    fprintf(f, "    \\%d", GET2(code,1));

-    ccode = code + _pcre_OP_lengths[*code];

-    goto CLASS_REF_REPEAT;

-

-    case OP_CALLOUT:

-    fprintf(f, "    %s %d %d %d", OP_names[*code], code[1], GET(code,2),

-      GET(code, 2 + LINK_SIZE));

-    break;

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1]));

-    break;

-

-    /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in

-    having this code always here, and it makes it less messy without all those

-    #ifdefs. */

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    case OP_XCLASS:

-      {

-      int i, min, max;

-      BOOL printmap;

-

-      fprintf(f, "    [");

-

-      if (*code == OP_XCLASS)

-        {

-        extra = GET(code, 1);

-        ccode = code + LINK_SIZE + 1;

-        printmap = (*ccode & XCL_MAP) != 0;

-        if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");

-        }

-      else

-        {

-        printmap = TRUE;

-        ccode = code + 1;

-        }

-

-      /* Print a bit map */

-

-      if (printmap)

-        {

-        for (i = 0; i < 256; i++)

-          {

-          if ((ccode[i/8] & (1 << (i&7))) != 0)

-            {

-            int j;

-            for (j = i+1; j < 256; j++)

-              if ((ccode[j/8] & (1 << (j&7))) == 0) break;

-            if (i == '-' || i == ']') fprintf(f, "\\");

-            if (isprint(i)) fprintf(f, "%c", i); else fprintf(f, "\\x%02x", i);

-            if (--j > i)

-              {

-              if (j != i + 1) fprintf(f, "-");

-              if (j == '-' || j == ']') fprintf(f, "\\");

-              if (isprint(j)) fprintf(f, "%c", j); else fprintf(f, "\\x%02x", j);

-              }

-            i = j;

-            }

-          }

-        ccode += 32;

-        }

-

-      /* For an XCLASS there is always some additional data */

-

-      if (*code == OP_XCLASS)

-        {

-        int ch;

-        while ((ch = *ccode++) != XCL_END)

-          {

-          if (ch == XCL_PROP)

-            {

-            fprintf(f, "\\p{%s}", get_ucpname(*ccode++));

-            }

-          else if (ch == XCL_NOTPROP)

-            {

-            fprintf(f, "\\P{%s}", get_ucpname(*ccode++));

-            }

-          else

-            {

-            ccode += 1 + print_char(f, ccode, TRUE);

-            if (ch == XCL_RANGE)

-              {

-              fprintf(f, "-");

-              ccode += 1 + print_char(f, ccode, TRUE);

-              }

-            }

-          }

-        }

-

-      /* Indicate a non-UTF8 class which was created by negation */

-

-      fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");

-

-      /* Handle repeats after a class or a back reference */

-

-      CLASS_REF_REPEAT:

-      switch(*ccode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        fprintf(f, "%s", OP_names[*ccode]);

-        extra += _pcre_OP_lengths[*ccode];

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        min = GET2(ccode,1);

-        max = GET2(ccode,3);

-        if (max == 0) fprintf(f, "{%d,}", min);

-        else fprintf(f, "{%d,%d}", min, max);

-        if (*ccode == OP_CRMINRANGE) fprintf(f, "?");

-        extra += _pcre_OP_lengths[*ccode];

-        break;

-        }

-      }

-    break;

-

-    /* Anything else is just an item with no data*/

-

-    default:

-    fprintf(f, "    %s", OP_names[*code]);

-    break;

-    }

-

-  code += _pcre_OP_lengths[*code] + extra;

-  fprintf(f, "\n");

-  }

-}

-

-/* End of pcre_printint.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_refcount(), which is an

-auxiliary function that can be used to maintain a reference count in a compiled

-pattern data block. This might be helpful in applications where the block is

-shared by different users. */

-

-

-

-/*************************************************

-*           Maintain reference count             *

-*************************************************/

-

-/* The reference count is a 16-bit field, initialized to zero. It is not

-possible to transfer a non-zero count from one host to a different host that

-has a different byte order - though I can't see why anyone in their right mind

-would ever want to do that!

-

-Arguments:

-  argument_re   points to compiled code

-  adjust        value to add to the count

-

-Returns:        the (possibly updated) count value (a non-negative number), or

-                a negative error number

-*/

-

-EXPORT int

-pcre_refcount(pcre *argument_re, int adjust)

-{

-real_pcre *re = (real_pcre *)argument_re;

-if (re == NULL) return PCRE_ERROR_NULL;

-re->ref_count = (-adjust > re->ref_count)? 0 :

-                (adjust + re->ref_count > 65535)? 65535 :

-                re->ref_count + adjust;

-return re->ref_count;

-}

-

-/* End of pcre_refcount.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_study(), along with local

-supporting functions. */

-

-

-

-

-/*************************************************

-*      Set a bit and maybe its alternate case    *

-*************************************************/

-

-/* Given a character, set its bit in the table, and also the bit for the other

-version of a letter if we are caseless.

-

-Arguments:

-  start_bits    points to the bit map

-  c             is the character

-  caseless      the caseless flag

-  cd            the block with char table pointers

-

-Returns:        nothing

-*/

-

-static void

-set_bit(uschar *start_bits, unsigned int c, BOOL caseless, compile_data *cd)

-{

-start_bits[c/8] |= (1 << (c&7));

-if (caseless && (cd->ctypes[c] & ctype_letter) != 0)

-  start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));

-}

-

-

-

-/*************************************************

-*          Create bitmap of starting chars       *

-*************************************************/

-

-/* This function scans a compiled unanchored expression and attempts to build a

-bitmap of the set of initial characters. If it can't, it returns FALSE. As time

-goes by, we may be able to get more clever at doing this.

-

-Arguments:

-  code         points to an expression

-  start_bits   points to a 32-byte table, initialized to 0

-  caseless     the current state of the caseless flag

-  utf8         TRUE if in UTF-8 mode

-  cd           the block with char table pointers

-

-Returns:       TRUE if table built, FALSE otherwise

-*/

-

-static BOOL

-set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,

-  BOOL utf8, compile_data *cd)

-{

-register int c;

-

-/* This next statement and the later reference to dummy are here in order to

-trick the optimizer of the IBM C compiler for OS/2 into generating correct

-code. Apparently IBM isn't going to fix the problem, and we would rather not

-disable optimization (in this module it actually makes a big difference, and

-the pcre module can use all the optimization it can get). */

-

-volatile int dummy;

-

-do

-  {

-  const uschar *tcode = code + 1 + LINK_SIZE;

-  BOOL try_next = TRUE;

-

-  while (try_next)

-    {

-    /* If a branch starts with a bracket or a positive lookahead assertion,

-    recurse to set bits from within them. That's all for this branch. */

-

-    if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT)

-      {

-      if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))

-        return FALSE;

-      try_next = FALSE;

-      }

-

-    else switch(*tcode)

-      {

-      default:

-      return FALSE;

-

-      /* Skip over callout */

-

-      case OP_CALLOUT:

-      tcode += 2 + 2*LINK_SIZE;

-      break;

-

-      /* Skip over extended extraction bracket number */

-

-      case OP_BRANUMBER:

-      tcode += 3;

-      break;

-

-      /* Skip over lookbehind and negative lookahead assertions */

-

-      case OP_ASSERT_NOT:

-      case OP_ASSERTBACK:

-      case OP_ASSERTBACK_NOT:

-      do tcode += GET(tcode, 1); while (*tcode == OP_ALT);

-      tcode += 1+LINK_SIZE;

-      break;

-

-      /* Skip over an option setting, changing the caseless flag */

-

-      case OP_OPT:

-      caseless = (tcode[1] & PCRE_CASELESS) != 0;

-      tcode += 2;

-      break;

-

-      /* BRAZERO does the bracket, but carries on. */

-

-      case OP_BRAZERO:

-      case OP_BRAMINZERO:

-      if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))

-        return FALSE;

-      dummy = 1;

-      do tcode += GET(tcode,1); while (*tcode == OP_ALT);

-      tcode += 1+LINK_SIZE;

-      break;

-

-      /* Single-char * or ? sets the bit and tries the next item */

-

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      set_bit(start_bits, tcode[1], caseless, cd);

-      tcode += 2;

-#ifdef SUPPORT_UTF8

-      if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;

-#endif

-      break;

-

-      /* Single-char upto sets the bit and tries the next */

-

-      case OP_UPTO:

-      case OP_MINUPTO:

-      set_bit(start_bits, tcode[3], caseless, cd);

-      tcode += 4;

-#ifdef SUPPORT_UTF8

-      if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;

-#endif

-      break;

-

-      /* At least one single char sets the bit and stops */

-

-      case OP_EXACT:       /* Fall through */

-      tcode += 2;

-

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      set_bit(start_bits, tcode[1], caseless, cd);

-      try_next = FALSE;

-      break;

-

-      /* Single character type sets the bits and stops */

-

-      case OP_NOT_DIGIT:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_digit];

-      try_next = FALSE;

-      break;

-

-      case OP_DIGIT:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_digit];

-      try_next = FALSE;

-      break;

-

-      case OP_NOT_WHITESPACE:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_space];

-      try_next = FALSE;

-      break;

-

-      case OP_WHITESPACE:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_space];

-      try_next = FALSE;

-      break;

-

-      case OP_NOT_WORDCHAR:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_word];

-      try_next = FALSE;

-      break;

-

-      case OP_WORDCHAR:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_word];

-      try_next = FALSE;

-      break;

-

-      /* One or more character type fudges the pointer and restarts, knowing

-      it will hit a single character type and stop there. */

-

-      case OP_TYPEPLUS:

-      case OP_TYPEMINPLUS:

-      tcode++;

-      break;

-

-      case OP_TYPEEXACT:

-      tcode += 3;

-      break;

-

-      /* Zero or more repeats of character types set the bits and then

-      try again. */

-

-      case OP_TYPEUPTO:

-      case OP_TYPEMINUPTO:

-      tcode += 2;               /* Fall through */

-

-      case OP_TYPESTAR:

-      case OP_TYPEMINSTAR:

-      case OP_TYPEQUERY:

-      case OP_TYPEMINQUERY:

-      switch(tcode[1])

-        {

-        case OP_ANY:

-        return FALSE;

-

-        case OP_NOT_DIGIT:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_digit];

-        break;

-

-        case OP_DIGIT:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_digit];

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_space];

-        break;

-

-        case OP_WHITESPACE:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_space];

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_word];

-        break;

-

-        case OP_WORDCHAR:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_word];

-        break;

-        }

-

-      tcode += 2;

-      break;

-

-      /* Character class where all the information is in a bit map: set the

-      bits and either carry on or not, according to the repeat count. If it was

-      a negative class, and we are operating with UTF-8 characters, any byte

-      with a value >= 0xc4 is a potentially valid starter because it starts a

-      character with a value > 255. */

-

-      case OP_NCLASS:

-      if (utf8)

-        {

-        start_bits[24] |= 0xf0;              /* Bits for 0xc4 - 0xc8 */

-        memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */

-        }

-      /* Fall through */

-

-      case OP_CLASS:

-        {

-        tcode++;

-

-        /* In UTF-8 mode, the bits in a bit map correspond to character

-        values, not to byte values. However, the bit map we are constructing is

-        for byte values. So we have to do a conversion for characters whose

-        value is > 127. In fact, there are only two possible starting bytes for

-        characters in the range 128 - 255. */

-

-        if (utf8)

-          {

-          for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];

-          for (c = 128; c < 256; c++)

-            {

-            if ((tcode[c/8] && (1 << (c&7))) != 0)

-              {

-              int d = (c >> 6) | 0xc0;            /* Set bit for this starter */

-              start_bits[d/8] |= (1 << (d&7));    /* and then skip on to the */

-              c = (c & 0xc0) + 0x40 - 1;          /* next relevant character. */

-              }

-            }

-          }

-

-        /* In non-UTF-8 mode, the two bit maps are completely compatible. */

-

-        else

-          {

-          for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];

-          }

-

-        /* Advance past the bit map, and act on what follows */

-

-        tcode += 32;

-        switch (*tcode)

-          {

-          case OP_CRSTAR:

-          case OP_CRMINSTAR:

-          case OP_CRQUERY:

-          case OP_CRMINQUERY:

-          tcode++;

-          break;

-

-          case OP_CRRANGE:

-          case OP_CRMINRANGE:

-          if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;

-            else try_next = FALSE;

-          break;

-

-          default:

-          try_next = FALSE;

-          break;

-          }

-        }

-      break; /* End of bitmap class handling */

-

-      }      /* End of switch */

-    }        /* End of try_next loop */

-

-  code += GET(code, 1);   /* Advance to next branch */

-  }

-while (*code == OP_ALT);

-return TRUE;

-}

-

-

-

-/*************************************************

-*          Study a compiled expression           *

-*************************************************/

-

-/* This function is handed a compiled expression that it must study to produce

-information that will speed up the matching. It returns a pcre_extra block

-which then gets handed back to pcre_exec().

-

-Arguments:

-  re        points to the compiled expression

-  options   contains option bits

-  errorptr  points to where to place error messages;

-            set NULL unless error

-

-Returns:    pointer to a pcre_extra block, with study_data filled in and the

-              appropriate flag set;

-            NULL on error or if no optimization possible

-*/

-

-EXPORT pcre_extra *

-pcre_study(const pcre *external_re, int options, const char **errorptr)

-{

-uschar start_bits[32];

-pcre_extra *extra;

-pcre_study_data *study;

-const uschar *tables;

-const real_pcre *re = (const real_pcre *)external_re;

-uschar *code = (uschar *)re + re->name_table_offset +

-  (re->name_count * re->name_entry_size);

-compile_data compile_block;

-

-*errorptr = NULL;

-

-if (re == NULL || re->magic_number != MAGIC_NUMBER)

-  {

-  *errorptr = "argument is not a compiled regular expression";

-  return NULL;

-  }

-

-if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)

-  {

-  *errorptr = "unknown or incorrect option bit(s) set";

-  return NULL;

-  }

-

-/* For an anchored pattern, or an unanchored pattern that has a first char, or

-a multiline pattern that matches only at "line starts", no further processing

-at present. */

-

-if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)

-  return NULL;

-

-/* Set the character tables in the block that is passed around */

-

-tables = re->tables;

-if (tables == NULL)

-  (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,

-  (void *)(&tables));

-

-compile_block.lcc = tables + lcc_offset;

-compile_block.fcc = tables + fcc_offset;

-compile_block.cbits = tables + cbits_offset;

-compile_block.ctypes = tables + ctypes_offset;

-

-/* See if we can find a fixed set of initial characters for the pattern. */

-

-memset(start_bits, 0, 32 * sizeof(uschar));

-if (!set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,

-  (re->options & PCRE_UTF8) != 0, &compile_block)) return NULL;

-

-/* Get a pcre_extra block and a pcre_study_data block. The study data is put in

-the latter, which is pointed to by the former, which may also get additional

-data set later by the calling program. At the moment, the size of

-pcre_study_data is fixed. We nevertheless save it in a field for returning via

-the pcre_fullinfo() function so that if it becomes variable in the future, we

-don't have to change that code. */

-

-extra = (pcre_extra *)(pcre_malloc)

-  (sizeof(pcre_extra) + sizeof(pcre_study_data));

-

-if (extra == NULL)

-  {

-  *errorptr = "failed to get memory";

-  return NULL;

-  }

-

-study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));

-extra->flags = PCRE_EXTRA_STUDY_DATA;

-extra->study_data = study;

-

-study->size = sizeof(pcre_study_data);

-study->options = PCRE_STUDY_MAPPED;

-memcpy(study->start_bits, start_bits, sizeof(start_bits));

-

-return extra;

-}

-

-/* End of pcre_study.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains some fixed tables that are used by more than one of the

-PCRE code modules. */

-

-

-

-

-/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that

-the definition is next to the definition of the opcodes in internal.h. */

-

-const uschar _pcre_OP_lengths[] = { OP_LENGTHS };

-

-

-

-/*************************************************

-*           Tables for UTF-8 support             *

-*************************************************/

-

-/* These are the breakpoints for different numbers of bytes in a UTF-8

-character. */

-

-const int _pcre_utf8_table1[] =

-  { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};

-

-const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1)/sizeof(int);

-

-/* These are the indicator bits and the mask for the data bits to set in the

-first byte of a character, indexed by the number of additional bytes. */

-

-const int _pcre_utf8_table2[] = { 0,    0xc0, 0xe0, 0xf0, 0xf8, 0xfc};

-const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};

-

-/* Table of the number of extra characters, indexed by the first character

-masked with 0x3f. The highest number for a valid UTF-8 character is in fact

-0x3d. */

-

-const uschar _pcre_utf8_table4[] = {

-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

-  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,

-  3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };

-

-/* This table translates Unicode property names into code values for the

-ucp_findchar() function. It is used by pcretest as well as by the library

-functions. */

-

-const ucp_type_table _pcre_utt[] = {

-  { "C",  128 + ucp_C },

-  { "Cc", ucp_Cc },

-  { "Cf", ucp_Cf },

-  { "Cn", ucp_Cn },

-  { "Co", ucp_Co },

-  { "Cs", ucp_Cs },

-  { "L",  128 + ucp_L },

-  { "Ll", ucp_Ll },

-  { "Lm", ucp_Lm },

-  { "Lo", ucp_Lo },

-  { "Lt", ucp_Lt },

-  { "Lu", ucp_Lu },

-  { "M",  128 + ucp_M },

-  { "Mc", ucp_Mc },

-  { "Me", ucp_Me },

-  { "Mn", ucp_Mn },

-  { "N",  128 + ucp_N },

-  { "Nd", ucp_Nd },

-  { "Nl", ucp_Nl },

-  { "No", ucp_No },

-  { "P",  128 + ucp_P },

-  { "Pc", ucp_Pc },

-  { "Pd", ucp_Pd },

-  { "Pe", ucp_Pe },

-  { "Pf", ucp_Pf },

-  { "Pi", ucp_Pi },

-  { "Po", ucp_Po },

-  { "Ps", ucp_Ps },

-  { "S",  128 + ucp_S },

-  { "Sc", ucp_Sc },

-  { "Sk", ucp_Sk },

-  { "Sm", ucp_Sm },

-  { "So", ucp_So },

-  { "Z",  128 + ucp_Z },

-  { "Zl", ucp_Zl },

-  { "Zp", ucp_Zp },

-  { "Zs", ucp_Zs }

-};

-

-const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);

-

-/* End of pcre_tables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function that tests a compiled pattern to

-see if it was compiled with the opposite endianness. If so, it uses an

-auxiliary local function to flip the appropriate bytes. */

-

-

-

-

-/*************************************************

-*         Flip bytes in an integer               *

-*************************************************/

-

-/* This function is called when the magic number in a regex doesn't match, in

-order to flip its bytes to see if we are dealing with a pattern that was

-compiled on a host of different endianness. If so, this function is used to

-flip other byte values.

-

-Arguments:

-  value        the number to flip

-  n            the number of bytes to flip (assumed to be 2 or 4)

-

-Returns:       the flipped value

-*/

-

-static long int

-byteflip(long int value, int n)

-{

-if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);

-return ((value & 0x000000ff) << 24) |

-       ((value & 0x0000ff00) <<  8) |

-       ((value & 0x00ff0000) >>  8) |

-       ((value & 0xff000000) >> 24);

-}

-

-

-

-/*************************************************

-*       Test for a byte-flipped compiled regex   *

-*************************************************/

-

-/* This function is called from pcre_exec(), pcre_dfa_exec(), and also from

-pcre_fullinfo(). Its job is to test whether the regex is byte-flipped - that

-is, it was compiled on a system of opposite endianness. The function is called

-only when the native MAGIC_NUMBER test fails. If the regex is indeed flipped,

-we flip all the relevant values into a different data block, and return it.

-

-Arguments:

-  re               points to the regex

-  study            points to study data, or NULL

-  internal_re      points to a new regex block

-  internal_study   points to a new study block

-

-Returns:           the new block if is is indeed a byte-flipped regex

-                   NULL if it is not

-*/

-

-EXPORT real_pcre *

-_pcre_try_flipped(const real_pcre *re, real_pcre *internal_re,

-  const pcre_study_data *study, pcre_study_data *internal_study)

-{

-if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)

-  return NULL;

-

-*internal_re = *re;           /* To copy other fields */

-internal_re->size = byteflip(re->size, sizeof(re->size));

-internal_re->options = byteflip(re->options, sizeof(re->options));

-internal_re->top_bracket =

-  (pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));

-internal_re->top_backref =

-  (pcre_uint16)byteflip(re->top_backref, sizeof(re->top_backref));

-internal_re->first_byte =

-  (pcre_uint16)byteflip(re->first_byte, sizeof(re->first_byte));

-internal_re->req_byte =

-  (pcre_uint16)byteflip(re->req_byte, sizeof(re->req_byte));

-internal_re->name_table_offset =

-  (pcre_uint16)byteflip(re->name_table_offset, sizeof(re->name_table_offset));

-internal_re->name_entry_size =

-  (pcre_uint16)byteflip(re->name_entry_size, sizeof(re->name_entry_size));

-internal_re->name_count =

-  (pcre_uint16)byteflip(re->name_count, sizeof(re->name_count));

-

-if (study != NULL)

-  {

-  *internal_study = *study;   /* To copy other fields */

-  internal_study->size = byteflip(study->size, sizeof(study->size));

-  internal_study->options = byteflip(study->options, sizeof(study->options));

-  }

-

-return internal_re;

-}

-

-/* End of pcre_tryflipped.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module compiles code for supporting the use of Unicode character

-properties. We use the (embryonic at the time of writing) UCP library, by

-including some of its files, copies of which have been put in the PCRE

-distribution. There is a macro in pcre_internal.h that changes the name

-ucp_findchar into _pcre_ucp_findchar. */

-

-

-

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-/* Copyright (c) University of Cambridge 2004 */

-

-/* This little library provides a fast way of obtaining the basic Unicode

-properties of a character, using a compact binary tree that occupies less than

-100K bytes.

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-/* Internal header file defining the layout of compact nodes in the tree. */

-

-typedef struct cnode {

-  unsigned short int f0;

-  unsigned short int f1;

-  unsigned short int f2;

-} cnode;

-

-/* Things for the f0 field */

-

-#define f0_leftexists   0x8000    /* Left child exists */

-#define f0_typemask     0x3f00    /* Type bits */

-#define f0_typeshift         8    /* Type shift */

-#define f0_chhmask      0x00ff    /* Character high bits */

-

-/* Things for the f2 field */

-

-#define f2_rightmask    0xf000    /* Mask for right offset bits */

-#define f2_rightshift       12    /* Shift for right offset */

-#define f2_casemask     0x0fff    /* Mask for case offset */

-

-/* The tree consists of a vector of structures of type cnode, with the root

-node as the first element. The three short ints (16-bits) are used as follows:

-

-(f0) (1) The 0x8000 bit of f0 is set if a left child exists. The child's node

-         is the next node in the vector.

-     (2) The 0x4000 bits of f0 is spare.

-     (3) The 0x3f00 bits of f0 contain the character type; this is a number

-         defined by the enumeration in ucp.h (e.g. ucp_Lu).

-     (4) The bottom 8 bits of f0 contain the most significant byte of the

-         character's 24-bit codepoint.

-

-(f1) (1) The f1 field contains the two least significant bytes of the

-         codepoint.

-

-(f2) (1) The 0xf000 bits of f2 contain zero if there is no right child of this

-         node. Otherwise, they contain one plus the exponent of the power of

-         two of the offset to the right node (e.g. a value of 3 means 8). The

-         units of the offset are node items.

-

-     (2) The 0x0fff bits of f2 contain the signed offset from this character to

-         its alternate cased value. They are zero if there is no such

-         character.

-

-

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

-||.|.| type (6) | ms char (8) ||  ls char (16)  ||....|  case offset (12)  ||

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

-  | |                                              |

-  | |-> spare                                      |

-  |                                        exponent of right

-  |-> left child exists                       child offset

-

-

-The upper/lower casing information is set only for characters that come in

-pairs. There are (at present) four non-one-to-one mappings in the Unicode data.

-These are ignored. They are:

-

-  1FBE Greek Prosgegrammeni (lower, with upper -> capital iota)

-  2126 Ohm

-  212A Kelvin

-  212B Angstrom

-

-Certainly for the last three, having an alternate case would seem to be a

-mistake. I don't know any Greek, so cannot comment on the first one.

-

-

-When searching the tree, proceed as follows:

-

-(1) Start at the first node.

-

-(2) Extract the character value from f1 and the bottom 8 bits of f0;

-

-(3) Compare with the character being sought. If equal, we are done.

-

-(4) If the test character is smaller, inspect the f0_leftexists flag. If it is

-    not set, the character is not in the tree. If it is set, move to the next

-    node, and go to (2).

-

-(5) If the test character is bigger, extract the f2_rightmask bits from f2, and

-    shift them right by f2_rightshift. If the result is zero, the character is

-    not in the tree. Otherwise, calculate the number of nodes to skip by

-    shifting the value 1 left by this number minus one. Go to (2).

-*/

-

-

-/* End of internal.h */

-/* This source module is automatically generated from the Unicode

-property table. See internal.h for a description of the layout. */

-

-static cnode ucp_table[] = {

-  { 0x9a00, 0x2f1f, 0xe000 },

-  { 0x8700, 0x1558, 0xd000 },

-  { 0x8700, 0x0a99, 0xc000 },

-  { 0x8500, 0x0435, 0xbfe0 },

-  { 0x8500, 0x01ff, 0xafff },

-  { 0x8500, 0x00ff, 0x9079 },

-  { 0x8000, 0x007f, 0x8000 },

-  { 0x9500, 0x003f, 0x7000 },

-  { 0x8000, 0x001f, 0x6000 },

-  { 0x8000, 0x000f, 0x5000 },

-  { 0x8000, 0x0007, 0x4000 },

-  { 0x8000, 0x0003, 0x3000 },

-  { 0x8000, 0x0001, 0x2000 },

-  { 0x0000, 0x0000, 0x0000 },

-  { 0x0000, 0x0002, 0x0000 },

-  { 0x8000, 0x0005, 0x2000 },

-  { 0x0000, 0x0004, 0x0000 },

-  { 0x0000, 0x0006, 0x0000 },

-  { 0x8000, 0x000b, 0x3000 },

-  { 0x8000, 0x0009, 0x2000 },

-  { 0x0000, 0x0008, 0x0000 },

-  { 0x0000, 0x000a, 0x0000 },

-  { 0x8000, 0x000d, 0x2000 },

-  { 0x0000, 0x000c, 0x0000 },

-  { 0x0000, 0x000e, 0x0000 },

-  { 0x8000, 0x0017, 0x4000 },

-  { 0x8000, 0x0013, 0x3000 },

-  { 0x8000, 0x0011, 0x2000 },

-  { 0x0000, 0x0010, 0x0000 },

-  { 0x0000, 0x0012, 0x0000 },

-  { 0x8000, 0x0015, 0x2000 },

-  { 0x0000, 0x0014, 0x0000 },

-  { 0x0000, 0x0016, 0x0000 },

-  { 0x8000, 0x001b, 0x3000 },

-  { 0x8000, 0x0019, 0x2000 },

-  { 0x0000, 0x0018, 0x0000 },

-  { 0x0000, 0x001a, 0x0000 },

-  { 0x8000, 0x001d, 0x2000 },

-  { 0x0000, 0x001c, 0x0000 },

-  { 0x0000, 0x001e, 0x0000 },

-  { 0x9500, 0x002f, 0x5000 },

-  { 0x9500, 0x0027, 0x4000 },

-  { 0x9500, 0x0023, 0x3000 },

-  { 0x9500, 0x0021, 0x2000 },

-  { 0x1d00, 0x0020, 0x0000 },

-  { 0x1500, 0x0022, 0x0000 },

-  { 0x9500, 0x0025, 0x2000 },

-  { 0x1700, 0x0024, 0x0000 },

-  { 0x1500, 0x0026, 0x0000 },

-  { 0x9900, 0x002b, 0x3000 },

-  { 0x9200, 0x0029, 0x2000 },

-  { 0x1600, 0x0028, 0x0000 },

-  { 0x1500, 0x002a, 0x0000 },

-  { 0x9100, 0x002d, 0x2000 },

-  { 0x1500, 0x002c, 0x0000 },

-  { 0x1500, 0x002e, 0x0000 },

-  { 0x8d00, 0x0037, 0x4000 },

-  { 0x8d00, 0x0033, 0x3000 },

-  { 0x8d00, 0x0031, 0x2000 },

-  { 0x0d00, 0x0030, 0x0000 },

-  { 0x0d00, 0x0032, 0x0000 },

-  { 0x8d00, 0x0035, 0x2000 },

-  { 0x0d00, 0x0034, 0x0000 },

-  { 0x0d00, 0x0036, 0x0000 },

-  { 0x9500, 0x003b, 0x3000 },

-  { 0x8d00, 0x0039, 0x2000 },

-  { 0x0d00, 0x0038, 0x0000 },

-  { 0x1500, 0x003a, 0x0000 },

-  { 0x9900, 0x003d, 0x2000 },

-  { 0x1900, 0x003c, 0x0000 },

-  { 0x1900, 0x003e, 0x0000 },

-  { 0x9000, 0x005f, 0x6000 },

-  { 0x8900, 0x004f, 0x5020 },

-  { 0x8900, 0x0047, 0x4020 },

-  { 0x8900, 0x0043, 0x3020 },

-  { 0x8900, 0x0041, 0x2020 },

-  { 0x1500, 0x0040, 0x0000 },

-  { 0x0900, 0x0042, 0x0020 },

-  { 0x8900, 0x0045, 0x2020 },

-  { 0x0900, 0x0044, 0x0020 },

-  { 0x0900, 0x0046, 0x0020 },

-  { 0x8900, 0x004b, 0x3020 },

-  { 0x8900, 0x0049, 0x2020 },

-  { 0x0900, 0x0048, 0x0020 },

-  { 0x0900, 0x004a, 0x0020 },

-  { 0x8900, 0x004d, 0x2020 },

-  { 0x0900, 0x004c, 0x0020 },

-  { 0x0900, 0x004e, 0x0020 },

-  { 0x8900, 0x0057, 0x4020 },

-  { 0x8900, 0x0053, 0x3020 },

-  { 0x8900, 0x0051, 0x2020 },

-  { 0x0900, 0x0050, 0x0020 },

-  { 0x0900, 0x0052, 0x0020 },

-  { 0x8900, 0x0055, 0x2020 },

-  { 0x0900, 0x0054, 0x0020 },

-  { 0x0900, 0x0056, 0x0020 },

-  { 0x9600, 0x005b, 0x3000 },

-  { 0x8900, 0x0059, 0x2020 },

-  { 0x0900, 0x0058, 0x0020 },

-  { 0x0900, 0x005a, 0x0020 },

-  { 0x9200, 0x005d, 0x2000 },

-  { 0x1500, 0x005c, 0x0000 },

-  { 0x1800, 0x005e, 0x0000 },

-  { 0x8500, 0x006f, 0x5fe0 },

-  { 0x8500, 0x0067, 0x4fe0 },

-  { 0x8500, 0x0063, 0x3fe0 },

-  { 0x8500, 0x0061, 0x2fe0 },

-  { 0x1800, 0x0060, 0x0000 },

-  { 0x0500, 0x0062, 0x0fe0 },

-  { 0x8500, 0x0065, 0x2fe0 },

-  { 0x0500, 0x0064, 0x0fe0 },

-  { 0x0500, 0x0066, 0x0fe0 },

-  { 0x8500, 0x006b, 0x3fe0 },

-  { 0x8500, 0x0069, 0x2fe0 },

-  { 0x0500, 0x0068, 0x0fe0 },

-  { 0x0500, 0x006a, 0x0fe0 },

-  { 0x8500, 0x006d, 0x2fe0 },

-  { 0x0500, 0x006c, 0x0fe0 },

-  { 0x0500, 0x006e, 0x0fe0 },

-  { 0x8500, 0x0077, 0x4fe0 },

-  { 0x8500, 0x0073, 0x3fe0 },

-  { 0x8500, 0x0071, 0x2fe0 },

-  { 0x0500, 0x0070, 0x0fe0 },

-  { 0x0500, 0x0072, 0x0fe0 },

-  { 0x8500, 0x0075, 0x2fe0 },

-  { 0x0500, 0x0074, 0x0fe0 },

-  { 0x0500, 0x0076, 0x0fe0 },

-  { 0x9600, 0x007b, 0x3000 },

-  { 0x8500, 0x0079, 0x2fe0 },

-  { 0x0500, 0x0078, 0x0fe0 },

-  { 0x0500, 0x007a, 0x0fe0 },

-  { 0x9200, 0x007d, 0x2000 },

-  { 0x1900, 0x007c, 0x0000 },

-  { 0x1900, 0x007e, 0x0000 },

-  { 0x9500, 0x00bf, 0x7000 },

-  { 0x8000, 0x009f, 0x6000 },

-  { 0x8000, 0x008f, 0x5000 },

-  { 0x8000, 0x0087, 0x4000 },

-  { 0x8000, 0x0083, 0x3000 },

-  { 0x8000, 0x0081, 0x2000 },

-  { 0x0000, 0x0080, 0x0000 },

-  { 0x0000, 0x0082, 0x0000 },

-  { 0x8000, 0x0085, 0x2000 },

-  { 0x0000, 0x0084, 0x0000 },

-  { 0x0000, 0x0086, 0x0000 },

-  { 0x8000, 0x008b, 0x3000 },

-  { 0x8000, 0x0089, 0x2000 },

-  { 0x0000, 0x0088, 0x0000 },

-  { 0x0000, 0x008a, 0x0000 },

-  { 0x8000, 0x008d, 0x2000 },

-  { 0x0000, 0x008c, 0x0000 },

-  { 0x0000, 0x008e, 0x0000 },

-  { 0x8000, 0x0097, 0x4000 },

-  { 0x8000, 0x0093, 0x3000 },

-  { 0x8000, 0x0091, 0x2000 },

-  { 0x0000, 0x0090, 0x0000 },

-  { 0x0000, 0x0092, 0x0000 },

-  { 0x8000, 0x0095, 0x2000 },

-  { 0x0000, 0x0094, 0x0000 },

-  { 0x0000, 0x0096, 0x0000 },

-  { 0x8000, 0x009b, 0x3000 },

-  { 0x8000, 0x0099, 0x2000 },

-  { 0x0000, 0x0098, 0x0000 },

-  { 0x0000, 0x009a, 0x0000 },

-  { 0x8000, 0x009d, 0x2000 },

-  { 0x0000, 0x009c, 0x0000 },

-  { 0x0000, 0x009e, 0x0000 },

-  { 0x9800, 0x00af, 0x5000 },

-  { 0x9a00, 0x00a7, 0x4000 },

-  { 0x9700, 0x00a3, 0x3000 },

-  { 0x9500, 0x00a1, 0x2000 },

-  { 0x1d00, 0x00a0, 0x0000 },

-  { 0x1700, 0x00a2, 0x0000 },

-  { 0x9700, 0x00a5, 0x2000 },

-  { 0x1700, 0x00a4, 0x0000 },

-  { 0x1a00, 0x00a6, 0x0000 },

-  { 0x9400, 0x00ab, 0x3000 },

-  { 0x9a00, 0x00a9, 0x2000 },

-  { 0x1800, 0x00a8, 0x0000 },

-  { 0x0500, 0x00aa, 0x0000 },

-  { 0x8100, 0x00ad, 0x2000 },

-  { 0x1900, 0x00ac, 0x0000 },

-  { 0x1a00, 0x00ae, 0x0000 },

-  { 0x9500, 0x00b7, 0x4000 },

-  { 0x8f00, 0x00b3, 0x3000 },

-  { 0x9900, 0x00b1, 0x2000 },

-  { 0x1a00, 0x00b0, 0x0000 },

-  { 0x0f00, 0x00b2, 0x0000 },

-  { 0x8500, 0x00b5, 0x22e7 },

-  { 0x1800, 0x00b4, 0x0000 },

-  { 0x1a00, 0x00b6, 0x0000 },

-  { 0x9300, 0x00bb, 0x3000 },

-  { 0x8f00, 0x00b9, 0x2000 },

-  { 0x1800, 0x00b8, 0x0000 },

-  { 0x0500, 0x00ba, 0x0000 },

-  { 0x8f00, 0x00bd, 0x2000 },

-  { 0x0f00, 0x00bc, 0x0000 },

-  { 0x0f00, 0x00be, 0x0000 },

-  { 0x8500, 0x00df, 0x6000 },

-  { 0x8900, 0x00cf, 0x5020 },

-  { 0x8900, 0x00c7, 0x4020 },

-  { 0x8900, 0x00c3, 0x3020 },

-  { 0x8900, 0x00c1, 0x2020 },

-  { 0x0900, 0x00c0, 0x0020 },

-  { 0x0900, 0x00c2, 0x0020 },

-  { 0x8900, 0x00c5, 0x2020 },

-  { 0x0900, 0x00c4, 0x0020 },

-  { 0x0900, 0x00c6, 0x0020 },

-  { 0x8900, 0x00cb, 0x3020 },

-  { 0x8900, 0x00c9, 0x2020 },

-  { 0x0900, 0x00c8, 0x0020 },

-  { 0x0900, 0x00ca, 0x0020 },

-  { 0x8900, 0x00cd, 0x2020 },

-  { 0x0900, 0x00cc, 0x0020 },

-  { 0x0900, 0x00ce, 0x0020 },

-  { 0x9900, 0x00d7, 0x4000 },

-  { 0x8900, 0x00d3, 0x3020 },

-  { 0x8900, 0x00d1, 0x2020 },

-  { 0x0900, 0x00d0, 0x0020 },

-  { 0x0900, 0x00d2, 0x0020 },

-  { 0x8900, 0x00d5, 0x2020 },

-  { 0x0900, 0x00d4, 0x0020 },

-  { 0x0900, 0x00d6, 0x0020 },

-  { 0x8900, 0x00db, 0x3020 },

-  { 0x8900, 0x00d9, 0x2020 },

-  { 0x0900, 0x00d8, 0x0020 },

-  { 0x0900, 0x00da, 0x0020 },

-  { 0x8900, 0x00dd, 0x2020 },

-  { 0x0900, 0x00dc, 0x0020 },

-  { 0x0900, 0x00de, 0x0020 },

-  { 0x8500, 0x00ef, 0x5fe0 },

-  { 0x8500, 0x00e7, 0x4fe0 },

-  { 0x8500, 0x00e3, 0x3fe0 },

-  { 0x8500, 0x00e1, 0x2fe0 },

-  { 0x0500, 0x00e0, 0x0fe0 },

-  { 0x0500, 0x00e2, 0x0fe0 },

-  { 0x8500, 0x00e5, 0x2fe0 },

-  { 0x0500, 0x00e4, 0x0fe0 },

-  { 0x0500, 0x00e6, 0x0fe0 },

-  { 0x8500, 0x00eb, 0x3fe0 },

-  { 0x8500, 0x00e9, 0x2fe0 },

-  { 0x0500, 0x00e8, 0x0fe0 },

-  { 0x0500, 0x00ea, 0x0fe0 },

-  { 0x8500, 0x00ed, 0x2fe0 },

-  { 0x0500, 0x00ec, 0x0fe0 },

-  { 0x0500, 0x00ee, 0x0fe0 },

-  { 0x9900, 0x00f7, 0x4000 },

-  { 0x8500, 0x00f3, 0x3fe0 },

-  { 0x8500, 0x00f1, 0x2fe0 },

-  { 0x0500, 0x00f0, 0x0fe0 },

-  { 0x0500, 0x00f2, 0x0fe0 },

-  { 0x8500, 0x00f5, 0x2fe0 },

-  { 0x0500, 0x00f4, 0x0fe0 },

-  { 0x0500, 0x00f6, 0x0fe0 },

-  { 0x8500, 0x00fb, 0x3fe0 },

-  { 0x8500, 0x00f9, 0x2fe0 },

-  { 0x0500, 0x00f8, 0x0fe0 },

-  { 0x0500, 0x00fa, 0x0fe0 },

-  { 0x8500, 0x00fd, 0x2fe0 },

-  { 0x0500, 0x00fc, 0x0fe0 },

-  { 0x0500, 0x00fe, 0x0fe0 },

-  { 0x8500, 0x017f, 0x8ed4 },

-  { 0x8900, 0x013f, 0x7001 },

-  { 0x8500, 0x011f, 0x6fff },

-  { 0x8500, 0x010f, 0x5fff },

-  { 0x8500, 0x0107, 0x4fff },

-  { 0x8500, 0x0103, 0x3fff },

-  { 0x8500, 0x0101, 0x2fff },

-  { 0x0900, 0x0100, 0x0001 },

-  { 0x0900, 0x0102, 0x0001 },

-  { 0x8500, 0x0105, 0x2fff },

-  { 0x0900, 0x0104, 0x0001 },

-  { 0x0900, 0x0106, 0x0001 },

-  { 0x8500, 0x010b, 0x3fff },

-  { 0x8500, 0x0109, 0x2fff },

-  { 0x0900, 0x0108, 0x0001 },

-  { 0x0900, 0x010a, 0x0001 },

-  { 0x8500, 0x010d, 0x2fff },

-  { 0x0900, 0x010c, 0x0001 },

-  { 0x0900, 0x010e, 0x0001 },

-  { 0x8500, 0x0117, 0x4fff },

-  { 0x8500, 0x0113, 0x3fff },

-  { 0x8500, 0x0111, 0x2fff },

-  { 0x0900, 0x0110, 0x0001 },

-  { 0x0900, 0x0112, 0x0001 },

-  { 0x8500, 0x0115, 0x2fff },

-  { 0x0900, 0x0114, 0x0001 },

-  { 0x0900, 0x0116, 0x0001 },

-  { 0x8500, 0x011b, 0x3fff },

-  { 0x8500, 0x0119, 0x2fff },

-  { 0x0900, 0x0118, 0x0001 },

-  { 0x0900, 0x011a, 0x0001 },

-  { 0x8500, 0x011d, 0x2fff },

-  { 0x0900, 0x011c, 0x0001 },

-  { 0x0900, 0x011e, 0x0001 },

-  { 0x8500, 0x012f, 0x5fff },

-  { 0x8500, 0x0127, 0x4fff },

-  { 0x8500, 0x0123, 0x3fff },

-  { 0x8500, 0x0121, 0x2fff },

-  { 0x0900, 0x0120, 0x0001 },

-  { 0x0900, 0x0122, 0x0001 },

-  { 0x8500, 0x0125, 0x2fff },

-  { 0x0900, 0x0124, 0x0001 },

-  { 0x0900, 0x0126, 0x0001 },

-  { 0x8500, 0x012b, 0x3fff },

-  { 0x8500, 0x0129, 0x2fff },

-  { 0x0900, 0x0128, 0x0001 },

-  { 0x0900, 0x012a, 0x0001 },

-  { 0x8500, 0x012d, 0x2fff },

-  { 0x0900, 0x012c, 0x0001 },

-  { 0x0900, 0x012e, 0x0001 },

-  { 0x8500, 0x0137, 0x4fff },

-  { 0x8500, 0x0133, 0x3fff },

-  { 0x8500, 0x0131, 0x2f18 },

-  { 0x0900, 0x0130, 0x0f39 },

-  { 0x0900, 0x0132, 0x0001 },

-  { 0x8500, 0x0135, 0x2fff },

-  { 0x0900, 0x0134, 0x0001 },

-  { 0x0900, 0x0136, 0x0001 },

-  { 0x8900, 0x013b, 0x3001 },

-  { 0x8900, 0x0139, 0x2001 },

-  { 0x0500, 0x0138, 0x0000 },

-  { 0x0500, 0x013a, 0x0fff },

-  { 0x8900, 0x013d, 0x2001 },

-  { 0x0500, 0x013c, 0x0fff },

-  { 0x0500, 0x013e, 0x0fff },

-  { 0x8500, 0x015f, 0x6fff },

-  { 0x8500, 0x014f, 0x5fff },

-  { 0x8900, 0x0147, 0x4001 },

-  { 0x8900, 0x0143, 0x3001 },

-  { 0x8900, 0x0141, 0x2001 },

-  { 0x0500, 0x0140, 0x0fff },

-  { 0x0500, 0x0142, 0x0fff },

-  { 0x8900, 0x0145, 0x2001 },

-  { 0x0500, 0x0144, 0x0fff },

-  { 0x0500, 0x0146, 0x0fff },

-  { 0x8500, 0x014b, 0x3fff },

-  { 0x8500, 0x0149, 0x2000 },

-  { 0x0500, 0x0148, 0x0fff },

-  { 0x0900, 0x014a, 0x0001 },

-  { 0x8500, 0x014d, 0x2fff },

-  { 0x0900, 0x014c, 0x0001 },

-  { 0x0900, 0x014e, 0x0001 },

-  { 0x8500, 0x0157, 0x4fff },

-  { 0x8500, 0x0153, 0x3fff },

-  { 0x8500, 0x0151, 0x2fff },

-  { 0x0900, 0x0150, 0x0001 },

-  { 0x0900, 0x0152, 0x0001 },

-  { 0x8500, 0x0155, 0x2fff },

-  { 0x0900, 0x0154, 0x0001 },

-  { 0x0900, 0x0156, 0x0001 },

-  { 0x8500, 0x015b, 0x3fff },

-  { 0x8500, 0x0159, 0x2fff },

-  { 0x0900, 0x0158, 0x0001 },

-  { 0x0900, 0x015a, 0x0001 },

-  { 0x8500, 0x015d, 0x2fff },

-  { 0x0900, 0x015c, 0x0001 },

-  { 0x0900, 0x015e, 0x0001 },

-  { 0x8500, 0x016f, 0x5fff },

-  { 0x8500, 0x0167, 0x4fff },

-  { 0x8500, 0x0163, 0x3fff },

-  { 0x8500, 0x0161, 0x2fff },

-  { 0x0900, 0x0160, 0x0001 },

-  { 0x0900, 0x0162, 0x0001 },

-  { 0x8500, 0x0165, 0x2fff },

-  { 0x0900, 0x0164, 0x0001 },

-  { 0x0900, 0x0166, 0x0001 },

-  { 0x8500, 0x016b, 0x3fff },

-  { 0x8500, 0x0169, 0x2fff },

-  { 0x0900, 0x0168, 0x0001 },

-  { 0x0900, 0x016a, 0x0001 },

-  { 0x8500, 0x016d, 0x2fff },

-  { 0x0900, 0x016c, 0x0001 },

-  { 0x0900, 0x016e, 0x0001 },

-  { 0x8500, 0x0177, 0x4fff },

-  { 0x8500, 0x0173, 0x3fff },

-  { 0x8500, 0x0171, 0x2fff },

-  { 0x0900, 0x0170, 0x0001 },

-  { 0x0900, 0x0172, 0x0001 },

-  { 0x8500, 0x0175, 0x2fff },

-  { 0x0900, 0x0174, 0x0001 },

-  { 0x0900, 0x0176, 0x0001 },

-  { 0x8900, 0x017b, 0x3001 },

-  { 0x8900, 0x0179, 0x2001 },

-  { 0x0900, 0x0178, 0x0f87 },

-  { 0x0500, 0x017a, 0x0fff },

-  { 0x8900, 0x017d, 0x2001 },

-  { 0x0500, 0x017c, 0x0fff },

-  { 0x0500, 0x017e, 0x0fff },

-  { 0x8500, 0x01bf, 0x7038 },

-  { 0x8900, 0x019f, 0x60d6 },

-  { 0x8900, 0x018f, 0x50ca },

-  { 0x8900, 0x0187, 0x4001 },

-  { 0x8500, 0x0183, 0x3fff },

-  { 0x8900, 0x0181, 0x20d2 },

-  { 0x0500, 0x0180, 0x0000 },

-  { 0x0900, 0x0182, 0x0001 },

-  { 0x8500, 0x0185, 0x2fff },

-  { 0x0900, 0x0184, 0x0001 },

-  { 0x0900, 0x0186, 0x00ce },

-  { 0x8900, 0x018b, 0x3001 },

-  { 0x8900, 0x0189, 0x20cd },

-  { 0x0500, 0x0188, 0x0fff },

-  { 0x0900, 0x018a, 0x00cd },

-  { 0x8500, 0x018d, 0x2000 },

-  { 0x0500, 0x018c, 0x0fff },

-  { 0x0900, 0x018e, 0x004f },

-  { 0x8900, 0x0197, 0x40d1 },

-  { 0x8900, 0x0193, 0x30cd },

-  { 0x8900, 0x0191, 0x2001 },

-  { 0x0900, 0x0190, 0x00cb },

-  { 0x0500, 0x0192, 0x0fff },

-  { 0x8500, 0x0195, 0x2061 },

-  { 0x0900, 0x0194, 0x00cf },

-  { 0x0900, 0x0196, 0x00d3 },

-  { 0x8500, 0x019b, 0x3000 },

-  { 0x8500, 0x0199, 0x2fff },

-  { 0x0900, 0x0198, 0x0001 },

-  { 0x0500, 0x019a, 0x0000 },

-  { 0x8900, 0x019d, 0x20d5 },

-  { 0x0900, 0x019c, 0x00d3 },

-  { 0x0500, 0x019e, 0x0082 },

-  { 0x8900, 0x01af, 0x5001 },

-  { 0x8900, 0x01a7, 0x4001 },

-  { 0x8500, 0x01a3, 0x3fff },

-  { 0x8500, 0x01a1, 0x2fff },

-  { 0x0900, 0x01a0, 0x0001 },

-  { 0x0900, 0x01a2, 0x0001 },

-  { 0x8500, 0x01a5, 0x2fff },

-  { 0x0900, 0x01a4, 0x0001 },

-  { 0x0900, 0x01a6, 0x00da },

-  { 0x8500, 0x01ab, 0x3000 },

-  { 0x8900, 0x01a9, 0x20da },

-  { 0x0500, 0x01a8, 0x0fff },

-  { 0x0500, 0x01aa, 0x0000 },

-  { 0x8500, 0x01ad, 0x2fff },

-  { 0x0900, 0x01ac, 0x0001 },

-  { 0x0900, 0x01ae, 0x00da },

-  { 0x8900, 0x01b7, 0x40db },

-  { 0x8900, 0x01b3, 0x3001 },

-  { 0x8900, 0x01b1, 0x20d9 },

-  { 0x0500, 0x01b0, 0x0fff },

-  { 0x0900, 0x01b2, 0x00d9 },

-  { 0x8900, 0x01b5, 0x2001 },

-  { 0x0500, 0x01b4, 0x0fff },

-  { 0x0500, 0x01b6, 0x0fff },

-  { 0x8700, 0x01bb, 0x3000 },

-  { 0x8500, 0x01b9, 0x2fff },

-  { 0x0900, 0x01b8, 0x0001 },

-  { 0x0500, 0x01ba, 0x0000 },

-  { 0x8500, 0x01bd, 0x2fff },

-  { 0x0900, 0x01bc, 0x0001 },

-  { 0x0500, 0x01be, 0x0000 },

-  { 0x8500, 0x01df, 0x6fff },

-  { 0x8900, 0x01cf, 0x5001 },

-  { 0x8900, 0x01c7, 0x4002 },

-  { 0x8700, 0x01c3, 0x3000 },

-  { 0x8700, 0x01c1, 0x2000 },

-  { 0x0700, 0x01c0, 0x0000 },

-  { 0x0700, 0x01c2, 0x0000 },

-  { 0x8800, 0x01c5, 0x2000 },

-  { 0x0900, 0x01c4, 0x0002 },

-  { 0x0500, 0x01c6, 0x0ffe },

-  { 0x8800, 0x01cb, 0x3000 },

-  { 0x8500, 0x01c9, 0x2ffe },

-  { 0x0800, 0x01c8, 0x0000 },

-  { 0x0900, 0x01ca, 0x0002 },

-  { 0x8900, 0x01cd, 0x2001 },

-  { 0x0500, 0x01cc, 0x0ffe },

-  { 0x0500, 0x01ce, 0x0fff },

-  { 0x8900, 0x01d7, 0x4001 },

-  { 0x8900, 0x01d3, 0x3001 },

-  { 0x8900, 0x01d1, 0x2001 },

-  { 0x0500, 0x01d0, 0x0fff },

-  { 0x0500, 0x01d2, 0x0fff },

-  { 0x8900, 0x01d5, 0x2001 },

-  { 0x0500, 0x01d4, 0x0fff },

-  { 0x0500, 0x01d6, 0x0fff },

-  { 0x8900, 0x01db, 0x3001 },

-  { 0x8900, 0x01d9, 0x2001 },

-  { 0x0500, 0x01d8, 0x0fff },

-  { 0x0500, 0x01da, 0x0fff },

-  { 0x8500, 0x01dd, 0x2fb1 },

-  { 0x0500, 0x01dc, 0x0fff },

-  { 0x0900, 0x01de, 0x0001 },

-  { 0x8500, 0x01ef, 0x5fff },

-  { 0x8500, 0x01e7, 0x4fff },

-  { 0x8500, 0x01e3, 0x3fff },

-  { 0x8500, 0x01e1, 0x2fff },

-  { 0x0900, 0x01e0, 0x0001 },

-  { 0x0900, 0x01e2, 0x0001 },

-  { 0x8500, 0x01e5, 0x2fff },

-  { 0x0900, 0x01e4, 0x0001 },

-  { 0x0900, 0x01e6, 0x0001 },

-  { 0x8500, 0x01eb, 0x3fff },

-  { 0x8500, 0x01e9, 0x2fff },

-  { 0x0900, 0x01e8, 0x0001 },

-  { 0x0900, 0x01ea, 0x0001 },

-  { 0x8500, 0x01ed, 0x2fff },

-  { 0x0900, 0x01ec, 0x0001 },

-  { 0x0900, 0x01ee, 0x0001 },

-  { 0x8900, 0x01f7, 0x4fc8 },

-  { 0x8500, 0x01f3, 0x3ffe },

-  { 0x8900, 0x01f1, 0x2002 },

-  { 0x0500, 0x01f0, 0x0000 },

-  { 0x0800, 0x01f2, 0x0000 },

-  { 0x8500, 0x01f5, 0x2fff },

-  { 0x0900, 0x01f4, 0x0001 },

-  { 0x0900, 0x01f6, 0x0f9f },

-  { 0x8500, 0x01fb, 0x3fff },

-  { 0x8500, 0x01f9, 0x2fff },

-  { 0x0900, 0x01f8, 0x0001 },

-  { 0x0900, 0x01fa, 0x0001 },

-  { 0x8500, 0x01fd, 0x2fff },

-  { 0x0900, 0x01fc, 0x0001 },

-  { 0x0900, 0x01fe, 0x0001 },

-  { 0x8c00, 0x0318, 0x9000 },

-  { 0x8500, 0x0298, 0x8000 },

-  { 0x8500, 0x0258, 0x7000 },

-  { 0x8500, 0x021f, 0x6fff },

-  { 0x8500, 0x020f, 0x5fff },

-  { 0x8500, 0x0207, 0x4fff },

-  { 0x8500, 0x0203, 0x3fff },

-  { 0x8500, 0x0201, 0x2fff },

-  { 0x0900, 0x0200, 0x0001 },

-  { 0x0900, 0x0202, 0x0001 },

-  { 0x8500, 0x0205, 0x2fff },

-  { 0x0900, 0x0204, 0x0001 },

-  { 0x0900, 0x0206, 0x0001 },

-  { 0x8500, 0x020b, 0x3fff },

-  { 0x8500, 0x0209, 0x2fff },

-  { 0x0900, 0x0208, 0x0001 },

-  { 0x0900, 0x020a, 0x0001 },

-  { 0x8500, 0x020d, 0x2fff },

-  { 0x0900, 0x020c, 0x0001 },

-  { 0x0900, 0x020e, 0x0001 },

-  { 0x8500, 0x0217, 0x4fff },

-  { 0x8500, 0x0213, 0x3fff },

-  { 0x8500, 0x0211, 0x2fff },

-  { 0x0900, 0x0210, 0x0001 },

-  { 0x0900, 0x0212, 0x0001 },

-  { 0x8500, 0x0215, 0x2fff },

-  { 0x0900, 0x0214, 0x0001 },

-  { 0x0900, 0x0216, 0x0001 },

-  { 0x8500, 0x021b, 0x3fff },

-  { 0x8500, 0x0219, 0x2fff },

-  { 0x0900, 0x0218, 0x0001 },

-  { 0x0900, 0x021a, 0x0001 },

-  { 0x8500, 0x021d, 0x2fff },

-  { 0x0900, 0x021c, 0x0001 },

-  { 0x0900, 0x021e, 0x0001 },

-  { 0x8500, 0x022f, 0x5fff },

-  { 0x8500, 0x0227, 0x4fff },

-  { 0x8500, 0x0223, 0x3fff },

-  { 0x8500, 0x0221, 0x2000 },

-  { 0x0900, 0x0220, 0x0f7e },

-  { 0x0900, 0x0222, 0x0001 },

-  { 0x8500, 0x0225, 0x2fff },

-  { 0x0900, 0x0224, 0x0001 },

-  { 0x0900, 0x0226, 0x0001 },

-  { 0x8500, 0x022b, 0x3fff },

-  { 0x8500, 0x0229, 0x2fff },

-  { 0x0900, 0x0228, 0x0001 },

-  { 0x0900, 0x022a, 0x0001 },

-  { 0x8500, 0x022d, 0x2fff },

-  { 0x0900, 0x022c, 0x0001 },

-  { 0x0900, 0x022e, 0x0001 },

-  { 0x8500, 0x0250, 0x4000 },

-  { 0x8500, 0x0233, 0x3fff },

-  { 0x8500, 0x0231, 0x2fff },

-  { 0x0900, 0x0230, 0x0001 },

-  { 0x0900, 0x0232, 0x0001 },

-  { 0x8500, 0x0235, 0x2000 },

-  { 0x0500, 0x0234, 0x0000 },

-  { 0x0500, 0x0236, 0x0000 },

-  { 0x8500, 0x0254, 0x3f32 },

-  { 0x8500, 0x0252, 0x2000 },

-  { 0x0500, 0x0251, 0x0000 },

-  { 0x0500, 0x0253, 0x0f2e },

-  { 0x8500, 0x0256, 0x2f33 },

-  { 0x0500, 0x0255, 0x0000 },

-  { 0x0500, 0x0257, 0x0f33 },

-  { 0x8500, 0x0278, 0x6000 },

-  { 0x8500, 0x0268, 0x5f2f },

-  { 0x8500, 0x0260, 0x4f33 },

-  { 0x8500, 0x025c, 0x3000 },

-  { 0x8500, 0x025a, 0x2000 },

-  { 0x0500, 0x0259, 0x0f36 },

-  { 0x0500, 0x025b, 0x0f35 },

-  { 0x8500, 0x025e, 0x2000 },

-  { 0x0500, 0x025d, 0x0000 },

-  { 0x0500, 0x025f, 0x0000 },

-  { 0x8500, 0x0264, 0x3000 },

-  { 0x8500, 0x0262, 0x2000 },

-  { 0x0500, 0x0261, 0x0000 },

-  { 0x0500, 0x0263, 0x0f31 },

-  { 0x8500, 0x0266, 0x2000 },

-  { 0x0500, 0x0265, 0x0000 },

-  { 0x0500, 0x0267, 0x0000 },

-  { 0x8500, 0x0270, 0x4000 },

-  { 0x8500, 0x026c, 0x3000 },

-  { 0x8500, 0x026a, 0x2000 },

-  { 0x0500, 0x0269, 0x0f2d },

-  { 0x0500, 0x026b, 0x0000 },

-  { 0x8500, 0x026e, 0x2000 },

-  { 0x0500, 0x026d, 0x0000 },

-  { 0x0500, 0x026f, 0x0f2d },

-  { 0x8500, 0x0274, 0x3000 },

-  { 0x8500, 0x0272, 0x2f2b },

-  { 0x0500, 0x0271, 0x0000 },

-  { 0x0500, 0x0273, 0x0000 },

-  { 0x8500, 0x0276, 0x2000 },

-  { 0x0500, 0x0275, 0x0f2a },

-  { 0x0500, 0x0277, 0x0000 },

-  { 0x8500, 0x0288, 0x5f26 },

-  { 0x8500, 0x0280, 0x4f26 },

-  { 0x8500, 0x027c, 0x3000 },

-  { 0x8500, 0x027a, 0x2000 },

-  { 0x0500, 0x0279, 0x0000 },

-  { 0x0500, 0x027b, 0x0000 },

-  { 0x8500, 0x027e, 0x2000 },

-  { 0x0500, 0x027d, 0x0000 },

-  { 0x0500, 0x027f, 0x0000 },

-  { 0x8500, 0x0284, 0x3000 },

-  { 0x8500, 0x0282, 0x2000 },

-  { 0x0500, 0x0281, 0x0000 },

-  { 0x0500, 0x0283, 0x0f26 },

-  { 0x8500, 0x0286, 0x2000 },

-  { 0x0500, 0x0285, 0x0000 },

-  { 0x0500, 0x0287, 0x0000 },

-  { 0x8500, 0x0290, 0x4000 },

-  { 0x8500, 0x028c, 0x3000 },

-  { 0x8500, 0x028a, 0x2f27 },

-  { 0x0500, 0x0289, 0x0000 },

-  { 0x0500, 0x028b, 0x0f27 },

-  { 0x8500, 0x028e, 0x2000 },

-  { 0x0500, 0x028d, 0x0000 },

-  { 0x0500, 0x028f, 0x0000 },

-  { 0x8500, 0x0294, 0x3000 },

-  { 0x8500, 0x0292, 0x2f25 },

-  { 0x0500, 0x0291, 0x0000 },

-  { 0x0500, 0x0293, 0x0000 },

-  { 0x8500, 0x0296, 0x2000 },

-  { 0x0500, 0x0295, 0x0000 },

-  { 0x0500, 0x0297, 0x0000 },

-  { 0x9800, 0x02d8, 0x7000 },

-  { 0x8600, 0x02b8, 0x6000 },

-  { 0x8500, 0x02a8, 0x5000 },

-  { 0x8500, 0x02a0, 0x4000 },

-  { 0x8500, 0x029c, 0x3000 },

-  { 0x8500, 0x029a, 0x2000 },

-  { 0x0500, 0x0299, 0x0000 },

-  { 0x0500, 0x029b, 0x0000 },

-  { 0x8500, 0x029e, 0x2000 },

-  { 0x0500, 0x029d, 0x0000 },

-  { 0x0500, 0x029f, 0x0000 },

-  { 0x8500, 0x02a4, 0x3000 },

-  { 0x8500, 0x02a2, 0x2000 },

-  { 0x0500, 0x02a1, 0x0000 },

-  { 0x0500, 0x02a3, 0x0000 },

-  { 0x8500, 0x02a6, 0x2000 },

-  { 0x0500, 0x02a5, 0x0000 },

-  { 0x0500, 0x02a7, 0x0000 },

-  { 0x8600, 0x02b0, 0x4000 },

-  { 0x8500, 0x02ac, 0x3000 },

-  { 0x8500, 0x02aa, 0x2000 },

-  { 0x0500, 0x02a9, 0x0000 },

-  { 0x0500, 0x02ab, 0x0000 },

-  { 0x8500, 0x02ae, 0x2000 },

-  { 0x0500, 0x02ad, 0x0000 },

-  { 0x0500, 0x02af, 0x0000 },

-  { 0x8600, 0x02b4, 0x3000 },

-  { 0x8600, 0x02b2, 0x2000 },

-  { 0x0600, 0x02b1, 0x0000 },

-  { 0x0600, 0x02b3, 0x0000 },

-  { 0x8600, 0x02b6, 0x2000 },

-  { 0x0600, 0x02b5, 0x0000 },

-  { 0x0600, 0x02b7, 0x0000 },

-  { 0x8600, 0x02c8, 0x5000 },

-  { 0x8600, 0x02c0, 0x4000 },

-  { 0x8600, 0x02bc, 0x3000 },

-  { 0x8600, 0x02ba, 0x2000 },

-  { 0x0600, 0x02b9, 0x0000 },

-  { 0x0600, 0x02bb, 0x0000 },

-  { 0x8600, 0x02be, 0x2000 },

-  { 0x0600, 0x02bd, 0x0000 },

-  { 0x0600, 0x02bf, 0x0000 },

-  { 0x9800, 0x02c4, 0x3000 },

-  { 0x9800, 0x02c2, 0x2000 },

-  { 0x0600, 0x02c1, 0x0000 },

-  { 0x1800, 0x02c3, 0x0000 },

-  { 0x8600, 0x02c6, 0x2000 },

-  { 0x1800, 0x02c5, 0x0000 },

-  { 0x0600, 0x02c7, 0x0000 },

-  { 0x8600, 0x02d0, 0x4000 },

-  { 0x8600, 0x02cc, 0x3000 },

-  { 0x8600, 0x02ca, 0x2000 },

-  { 0x0600, 0x02c9, 0x0000 },

-  { 0x0600, 0x02cb, 0x0000 },

-  { 0x8600, 0x02ce, 0x2000 },

-  { 0x0600, 0x02cd, 0x0000 },

-  { 0x0600, 0x02cf, 0x0000 },

-  { 0x9800, 0x02d4, 0x3000 },

-  { 0x9800, 0x02d2, 0x2000 },

-  { 0x0600, 0x02d1, 0x0000 },

-  { 0x1800, 0x02d3, 0x0000 },

-  { 0x9800, 0x02d6, 0x2000 },

-  { 0x1800, 0x02d5, 0x0000 },

-  { 0x1800, 0x02d7, 0x0000 },

-  { 0x9800, 0x02f8, 0x6000 },

-  { 0x9800, 0x02e8, 0x5000 },

-  { 0x8600, 0x02e0, 0x4000 },

-  { 0x9800, 0x02dc, 0x3000 },

-  { 0x9800, 0x02da, 0x2000 },

-  { 0x1800, 0x02d9, 0x0000 },

-  { 0x1800, 0x02db, 0x0000 },

-  { 0x9800, 0x02de, 0x2000 },

-  { 0x1800, 0x02dd, 0x0000 },

-  { 0x1800, 0x02df, 0x0000 },

-  { 0x8600, 0x02e4, 0x3000 },

-  { 0x8600, 0x02e2, 0x2000 },

-  { 0x0600, 0x02e1, 0x0000 },

-  { 0x0600, 0x02e3, 0x0000 },

-  { 0x9800, 0x02e6, 0x2000 },

-  { 0x1800, 0x02e5, 0x0000 },

-  { 0x1800, 0x02e7, 0x0000 },

-  { 0x9800, 0x02f0, 0x4000 },

-  { 0x9800, 0x02ec, 0x3000 },

-  { 0x9800, 0x02ea, 0x2000 },

-  { 0x1800, 0x02e9, 0x0000 },

-  { 0x1800, 0x02eb, 0x0000 },

-  { 0x8600, 0x02ee, 0x2000 },

-  { 0x1800, 0x02ed, 0x0000 },

-  { 0x1800, 0x02ef, 0x0000 },

-  { 0x9800, 0x02f4, 0x3000 },

-  { 0x9800, 0x02f2, 0x2000 },

-  { 0x1800, 0x02f1, 0x0000 },

-  { 0x1800, 0x02f3, 0x0000 },

-  { 0x9800, 0x02f6, 0x2000 },

-  { 0x1800, 0x02f5, 0x0000 },

-  { 0x1800, 0x02f7, 0x0000 },

-  { 0x8c00, 0x0308, 0x5000 },

-  { 0x8c00, 0x0300, 0x4000 },

-  { 0x9800, 0x02fc, 0x3000 },

-  { 0x9800, 0x02fa, 0x2000 },

-  { 0x1800, 0x02f9, 0x0000 },

-  { 0x1800, 0x02fb, 0x0000 },

-  { 0x9800, 0x02fe, 0x2000 },

-  { 0x1800, 0x02fd, 0x0000 },

-  { 0x1800, 0x02ff, 0x0000 },

-  { 0x8c00, 0x0304, 0x3000 },

-  { 0x8c00, 0x0302, 0x2000 },

-  { 0x0c00, 0x0301, 0x0000 },

-  { 0x0c00, 0x0303, 0x0000 },

-  { 0x8c00, 0x0306, 0x2000 },

-  { 0x0c00, 0x0305, 0x0000 },

-  { 0x0c00, 0x0307, 0x0000 },

-  { 0x8c00, 0x0310, 0x4000 },

-  { 0x8c00, 0x030c, 0x3000 },

-  { 0x8c00, 0x030a, 0x2000 },

-  { 0x0c00, 0x0309, 0x0000 },

-  { 0x0c00, 0x030b, 0x0000 },

-  { 0x8c00, 0x030e, 0x2000 },

-  { 0x0c00, 0x030d, 0x0000 },

-  { 0x0c00, 0x030f, 0x0000 },

-  { 0x8c00, 0x0314, 0x3000 },

-  { 0x8c00, 0x0312, 0x2000 },

-  { 0x0c00, 0x0311, 0x0000 },

-  { 0x0c00, 0x0313, 0x0000 },

-  { 0x8c00, 0x0316, 0x2000 },

-  { 0x0c00, 0x0315, 0x0000 },

-  { 0x0c00, 0x0317, 0x0000 },

-  { 0x8500, 0x03b0, 0x8000 },

-  { 0x8c00, 0x035d, 0x7000 },

-  { 0x8c00, 0x0338, 0x6000 },

-  { 0x8c00, 0x0328, 0x5000 },

-  { 0x8c00, 0x0320, 0x4000 },

-  { 0x8c00, 0x031c, 0x3000 },

-  { 0x8c00, 0x031a, 0x2000 },

-  { 0x0c00, 0x0319, 0x0000 },

-  { 0x0c00, 0x031b, 0x0000 },

-  { 0x8c00, 0x031e, 0x2000 },

-  { 0x0c00, 0x031d, 0x0000 },

-  { 0x0c00, 0x031f, 0x0000 },

-  { 0x8c00, 0x0324, 0x3000 },

-  { 0x8c00, 0x0322, 0x2000 },

-  { 0x0c00, 0x0321, 0x0000 },

-  { 0x0c00, 0x0323, 0x0000 },

-  { 0x8c00, 0x0326, 0x2000 },

-  { 0x0c00, 0x0325, 0x0000 },

-  { 0x0c00, 0x0327, 0x0000 },

-  { 0x8c00, 0x0330, 0x4000 },

-  { 0x8c00, 0x032c, 0x3000 },

-  { 0x8c00, 0x032a, 0x2000 },

-  { 0x0c00, 0x0329, 0x0000 },

-  { 0x0c00, 0x032b, 0x0000 },

-  { 0x8c00, 0x032e, 0x2000 },

-  { 0x0c00, 0x032d, 0x0000 },

-  { 0x0c00, 0x032f, 0x0000 },

-  { 0x8c00, 0x0334, 0x3000 },

-  { 0x8c00, 0x0332, 0x2000 },

-  { 0x0c00, 0x0331, 0x0000 },

-  { 0x0c00, 0x0333, 0x0000 },

-  { 0x8c00, 0x0336, 0x2000 },

-  { 0x0c00, 0x0335, 0x0000 },

-  { 0x0c00, 0x0337, 0x0000 },

-  { 0x8c00, 0x0348, 0x5000 },

-  { 0x8c00, 0x0340, 0x4000 },

-  { 0x8c00, 0x033c, 0x3000 },

-  { 0x8c00, 0x033a, 0x2000 },

-  { 0x0c00, 0x0339, 0x0000 },

-  { 0x0c00, 0x033b, 0x0000 },

-  { 0x8c00, 0x033e, 0x2000 },

-  { 0x0c00, 0x033d, 0x0000 },

-  { 0x0c00, 0x033f, 0x0000 },

-  { 0x8c00, 0x0344, 0x3000 },

-  { 0x8c00, 0x0342, 0x2000 },

-  { 0x0c00, 0x0341, 0x0000 },

-  { 0x0c00, 0x0343, 0x0000 },

-  { 0x8c00, 0x0346, 0x2000 },

-  { 0x0c00, 0x0345, 0x0000 },

-  { 0x0c00, 0x0347, 0x0000 },

-  { 0x8c00, 0x0350, 0x4000 },

-  { 0x8c00, 0x034c, 0x3000 },

-  { 0x8c00, 0x034a, 0x2000 },

-  { 0x0c00, 0x0349, 0x0000 },

-  { 0x0c00, 0x034b, 0x0000 },

-  { 0x8c00, 0x034e, 0x2000 },

-  { 0x0c00, 0x034d, 0x0000 },

-  { 0x0c00, 0x034f, 0x0000 },

-  { 0x8c00, 0x0354, 0x3000 },

-  { 0x8c00, 0x0352, 0x2000 },

-  { 0x0c00, 0x0351, 0x0000 },

-  { 0x0c00, 0x0353, 0x0000 },

-  { 0x8c00, 0x0356, 0x2000 },

-  { 0x0c00, 0x0355, 0x0000 },

-  { 0x0c00, 0x0357, 0x0000 },

-  { 0x8900, 0x038f, 0x603f },

-  { 0x8c00, 0x036d, 0x5000 },

-  { 0x8c00, 0x0365, 0x4000 },

-  { 0x8c00, 0x0361, 0x3000 },

-  { 0x8c00, 0x035f, 0x2000 },

-  { 0x0c00, 0x035e, 0x0000 },

-  { 0x0c00, 0x0360, 0x0000 },

-  { 0x8c00, 0x0363, 0x2000 },

-  { 0x0c00, 0x0362, 0x0000 },

-  { 0x0c00, 0x0364, 0x0000 },

-  { 0x8c00, 0x0369, 0x3000 },

-  { 0x8c00, 0x0367, 0x2000 },

-  { 0x0c00, 0x0366, 0x0000 },

-  { 0x0c00, 0x0368, 0x0000 },

-  { 0x8c00, 0x036b, 0x2000 },

-  { 0x0c00, 0x036a, 0x0000 },

-  { 0x0c00, 0x036c, 0x0000 },

-  { 0x9800, 0x0385, 0x4000 },

-  { 0x9800, 0x0375, 0x3000 },

-  { 0x8c00, 0x036f, 0x2000 },

-  { 0x0c00, 0x036e, 0x0000 },

-  { 0x1800, 0x0374, 0x0000 },

-  { 0x9500, 0x037e, 0x2000 },

-  { 0x0600, 0x037a, 0x0000 },

-  { 0x1800, 0x0384, 0x0000 },

-  { 0x8900, 0x0389, 0x3025 },

-  { 0x9500, 0x0387, 0x2000 },

-  { 0x0900, 0x0386, 0x0026 },

-  { 0x0900, 0x0388, 0x0025 },

-  { 0x8900, 0x038c, 0x2040 },

-  { 0x0900, 0x038a, 0x0025 },

-  { 0x0900, 0x038e, 0x003f },

-  { 0x8900, 0x039f, 0x5020 },

-  { 0x8900, 0x0397, 0x4020 },

-  { 0x8900, 0x0393, 0x3020 },

-  { 0x8900, 0x0391, 0x2020 },

-  { 0x0500, 0x0390, 0x0000 },

-  { 0x0900, 0x0392, 0x0020 },

-  { 0x8900, 0x0395, 0x2020 },

-  { 0x0900, 0x0394, 0x0020 },

-  { 0x0900, 0x0396, 0x0020 },

-  { 0x8900, 0x039b, 0x3020 },

-  { 0x8900, 0x0399, 0x2020 },

-  { 0x0900, 0x0398, 0x0020 },

-  { 0x0900, 0x039a, 0x0020 },

-  { 0x8900, 0x039d, 0x2020 },

-  { 0x0900, 0x039c, 0x0020 },

-  { 0x0900, 0x039e, 0x0020 },

-  { 0x8900, 0x03a8, 0x4020 },

-  { 0x8900, 0x03a4, 0x3020 },

-  { 0x8900, 0x03a1, 0x2020 },

-  { 0x0900, 0x03a0, 0x0020 },

-  { 0x0900, 0x03a3, 0x0020 },

-  { 0x8900, 0x03a6, 0x2020 },

-  { 0x0900, 0x03a5, 0x0020 },

-  { 0x0900, 0x03a7, 0x0020 },

-  { 0x8500, 0x03ac, 0x3fda },

-  { 0x8900, 0x03aa, 0x2020 },

-  { 0x0900, 0x03a9, 0x0020 },

-  { 0x0900, 0x03ab, 0x0020 },

-  { 0x8500, 0x03ae, 0x2fdb },

-  { 0x0500, 0x03ad, 0x0fdb },

-  { 0x0500, 0x03af, 0x0fdb },

-  { 0x8500, 0x03f1, 0x7fb0 },

-  { 0x8500, 0x03d1, 0x6fc7 },

-  { 0x8500, 0x03c0, 0x5fe0 },

-  { 0x8500, 0x03b8, 0x4fe0 },

-  { 0x8500, 0x03b4, 0x3fe0 },

-  { 0x8500, 0x03b2, 0x2fe0 },

-  { 0x0500, 0x03b1, 0x0fe0 },

-  { 0x0500, 0x03b3, 0x0fe0 },

-  { 0x8500, 0x03b6, 0x2fe0 },

-  { 0x0500, 0x03b5, 0x0fe0 },

-  { 0x0500, 0x03b7, 0x0fe0 },

-  { 0x8500, 0x03bc, 0x3fe0 },

-  { 0x8500, 0x03ba, 0x2fe0 },

-  { 0x0500, 0x03b9, 0x0fe0 },

-  { 0x0500, 0x03bb, 0x0fe0 },

-  { 0x8500, 0x03be, 0x2fe0 },

-  { 0x0500, 0x03bd, 0x0fe0 },

-  { 0x0500, 0x03bf, 0x0fe0 },

-  { 0x8500, 0x03c8, 0x4fe0 },

-  { 0x8500, 0x03c4, 0x3fe0 },

-  { 0x8500, 0x03c2, 0x2fe1 },

-  { 0x0500, 0x03c1, 0x0fe0 },

-  { 0x0500, 0x03c3, 0x0fe0 },

-  { 0x8500, 0x03c6, 0x2fe0 },

-  { 0x0500, 0x03c5, 0x0fe0 },

-  { 0x0500, 0x03c7, 0x0fe0 },

-  { 0x8500, 0x03cc, 0x3fc0 },

-  { 0x8500, 0x03ca, 0x2fe0 },

-  { 0x0500, 0x03c9, 0x0fe0 },

-  { 0x0500, 0x03cb, 0x0fe0 },

-  { 0x8500, 0x03ce, 0x2fc1 },

-  { 0x0500, 0x03cd, 0x0fc1 },

-  { 0x0500, 0x03d0, 0x0fc2 },

-  { 0x8500, 0x03e1, 0x5fff },

-  { 0x8500, 0x03d9, 0x4fff },

-  { 0x8500, 0x03d5, 0x3fd1 },

-  { 0x8900, 0x03d3, 0x2000 },

-  { 0x0900, 0x03d2, 0x0000 },

-  { 0x0900, 0x03d4, 0x0000 },

-  { 0x8500, 0x03d7, 0x2000 },

-  { 0x0500, 0x03d6, 0x0fca },

-  { 0x0900, 0x03d8, 0x0001 },

-  { 0x8500, 0x03dd, 0x3fff },

-  { 0x8500, 0x03db, 0x2fff },

-  { 0x0900, 0x03da, 0x0001 },

-  { 0x0900, 0x03dc, 0x0001 },

-  { 0x8500, 0x03df, 0x2fff },

-  { 0x0900, 0x03de, 0x0001 },

-  { 0x0900, 0x03e0, 0x0001 },

-  { 0x8500, 0x03e9, 0x4fff },

-  { 0x8500, 0x03e5, 0x3fff },

-  { 0x8500, 0x03e3, 0x2fff },

-  { 0x0900, 0x03e2, 0x0001 },

-  { 0x0900, 0x03e4, 0x0001 },

-  { 0x8500, 0x03e7, 0x2fff },

-  { 0x0900, 0x03e6, 0x0001 },

-  { 0x0900, 0x03e8, 0x0001 },

-  { 0x8500, 0x03ed, 0x3fff },

-  { 0x8500, 0x03eb, 0x2fff },

-  { 0x0900, 0x03ea, 0x0001 },

-  { 0x0900, 0x03ec, 0x0001 },

-  { 0x8500, 0x03ef, 0x2fff },

-  { 0x0900, 0x03ee, 0x0001 },

-  { 0x0500, 0x03f0, 0x0faa },

-  { 0x8900, 0x0415, 0x6020 },

-  { 0x8900, 0x0405, 0x5050 },

-  { 0x8900, 0x03f9, 0x4ff9 },

-  { 0x8500, 0x03f5, 0x3fa0 },

-  { 0x8500, 0x03f3, 0x2000 },

-  { 0x0500, 0x03f2, 0x0007 },

-  { 0x0900, 0x03f4, 0x0fc4 },

-  { 0x8900, 0x03f7, 0x2001 },

-  { 0x1900, 0x03f6, 0x0000 },

-  { 0x0500, 0x03f8, 0x0fff },

-  { 0x8900, 0x0401, 0x3050 },

-  { 0x8500, 0x03fb, 0x2fff },

-  { 0x0900, 0x03fa, 0x0001 },

-  { 0x0900, 0x0400, 0x0050 },

-  { 0x8900, 0x0403, 0x2050 },

-  { 0x0900, 0x0402, 0x0050 },

-  { 0x0900, 0x0404, 0x0050 },

-  { 0x8900, 0x040d, 0x4050 },

-  { 0x8900, 0x0409, 0x3050 },

-  { 0x8900, 0x0407, 0x2050 },

-  { 0x0900, 0x0406, 0x0050 },

-  { 0x0900, 0x0408, 0x0050 },

-  { 0x8900, 0x040b, 0x2050 },

-  { 0x0900, 0x040a, 0x0050 },

-  { 0x0900, 0x040c, 0x0050 },

-  { 0x8900, 0x0411, 0x3020 },

-  { 0x8900, 0x040f, 0x2050 },

-  { 0x0900, 0x040e, 0x0050 },

-  { 0x0900, 0x0410, 0x0020 },

-  { 0x8900, 0x0413, 0x2020 },

-  { 0x0900, 0x0412, 0x0020 },

-  { 0x0900, 0x0414, 0x0020 },

-  { 0x8900, 0x0425, 0x5020 },

-  { 0x8900, 0x041d, 0x4020 },

-  { 0x8900, 0x0419, 0x3020 },

-  { 0x8900, 0x0417, 0x2020 },

-  { 0x0900, 0x0416, 0x0020 },

-  { 0x0900, 0x0418, 0x0020 },

-  { 0x8900, 0x041b, 0x2020 },

-  { 0x0900, 0x041a, 0x0020 },

-  { 0x0900, 0x041c, 0x0020 },

-  { 0x8900, 0x0421, 0x3020 },

-  { 0x8900, 0x041f, 0x2020 },

-  { 0x0900, 0x041e, 0x0020 },

-  { 0x0900, 0x0420, 0x0020 },

-  { 0x8900, 0x0423, 0x2020 },

-  { 0x0900, 0x0422, 0x0020 },

-  { 0x0900, 0x0424, 0x0020 },

-  { 0x8900, 0x042d, 0x4020 },

-  { 0x8900, 0x0429, 0x3020 },

-  { 0x8900, 0x0427, 0x2020 },

-  { 0x0900, 0x0426, 0x0020 },

-  { 0x0900, 0x0428, 0x0020 },

-  { 0x8900, 0x042b, 0x2020 },

-  { 0x0900, 0x042a, 0x0020 },

-  { 0x0900, 0x042c, 0x0020 },

-  { 0x8500, 0x0431, 0x3fe0 },

-  { 0x8900, 0x042f, 0x2020 },

-  { 0x0900, 0x042e, 0x0020 },

-  { 0x0500, 0x0430, 0x0fe0 },

-  { 0x8500, 0x0433, 0x2fe0 },

-  { 0x0500, 0x0432, 0x0fe0 },

-  { 0x0500, 0x0434, 0x0fe0 },

-  { 0x8700, 0x06a4, 0xa000 },

-  { 0x8500, 0x0563, 0x9fd0 },

-  { 0x8900, 0x04b6, 0x8001 },

-  { 0x8500, 0x0475, 0x7fff },

-  { 0x8500, 0x0455, 0x6fb0 },

-  { 0x8500, 0x0445, 0x5fe0 },

-  { 0x8500, 0x043d, 0x4fe0 },

-  { 0x8500, 0x0439, 0x3fe0 },

-  { 0x8500, 0x0437, 0x2fe0 },

-  { 0x0500, 0x0436, 0x0fe0 },

-  { 0x0500, 0x0438, 0x0fe0 },

-  { 0x8500, 0x043b, 0x2fe0 },

-  { 0x0500, 0x043a, 0x0fe0 },

-  { 0x0500, 0x043c, 0x0fe0 },

-  { 0x8500, 0x0441, 0x3fe0 },

-  { 0x8500, 0x043f, 0x2fe0 },

-  { 0x0500, 0x043e, 0x0fe0 },

-  { 0x0500, 0x0440, 0x0fe0 },

-  { 0x8500, 0x0443, 0x2fe0 },

-  { 0x0500, 0x0442, 0x0fe0 },

-  { 0x0500, 0x0444, 0x0fe0 },

-  { 0x8500, 0x044d, 0x4fe0 },

-  { 0x8500, 0x0449, 0x3fe0 },

-  { 0x8500, 0x0447, 0x2fe0 },

-  { 0x0500, 0x0446, 0x0fe0 },

-  { 0x0500, 0x0448, 0x0fe0 },

-  { 0x8500, 0x044b, 0x2fe0 },

-  { 0x0500, 0x044a, 0x0fe0 },

-  { 0x0500, 0x044c, 0x0fe0 },

-  { 0x8500, 0x0451, 0x3fb0 },

-  { 0x8500, 0x044f, 0x2fe0 },

-  { 0x0500, 0x044e, 0x0fe0 },

-  { 0x0500, 0x0450, 0x0fb0 },

-  { 0x8500, 0x0453, 0x2fb0 },

-  { 0x0500, 0x0452, 0x0fb0 },

-  { 0x0500, 0x0454, 0x0fb0 },

-  { 0x8500, 0x0465, 0x5fff },

-  { 0x8500, 0x045d, 0x4fb0 },

-  { 0x8500, 0x0459, 0x3fb0 },

-  { 0x8500, 0x0457, 0x2fb0 },

-  { 0x0500, 0x0456, 0x0fb0 },

-  { 0x0500, 0x0458, 0x0fb0 },

-  { 0x8500, 0x045b, 0x2fb0 },

-  { 0x0500, 0x045a, 0x0fb0 },

-  { 0x0500, 0x045c, 0x0fb0 },

-  { 0x8500, 0x0461, 0x3fff },

-  { 0x8500, 0x045f, 0x2fb0 },

-  { 0x0500, 0x045e, 0x0fb0 },

-  { 0x0900, 0x0460, 0x0001 },

-  { 0x8500, 0x0463, 0x2fff },

-  { 0x0900, 0x0462, 0x0001 },

-  { 0x0900, 0x0464, 0x0001 },

-  { 0x8500, 0x046d, 0x4fff },

-  { 0x8500, 0x0469, 0x3fff },

-  { 0x8500, 0x0467, 0x2fff },

-  { 0x0900, 0x0466, 0x0001 },

-  { 0x0900, 0x0468, 0x0001 },

-  { 0x8500, 0x046b, 0x2fff },

-  { 0x0900, 0x046a, 0x0001 },

-  { 0x0900, 0x046c, 0x0001 },

-  { 0x8500, 0x0471, 0x3fff },

-  { 0x8500, 0x046f, 0x2fff },

-  { 0x0900, 0x046e, 0x0001 },

-  { 0x0900, 0x0470, 0x0001 },

-  { 0x8500, 0x0473, 0x2fff },

-  { 0x0900, 0x0472, 0x0001 },

-  { 0x0900, 0x0474, 0x0001 },

-  { 0x8900, 0x0496, 0x6001 },

-  { 0x8c00, 0x0485, 0x5000 },

-  { 0x8500, 0x047d, 0x4fff },

-  { 0x8500, 0x0479, 0x3fff },

-  { 0x8500, 0x0477, 0x2fff },

-  { 0x0900, 0x0476, 0x0001 },

-  { 0x0900, 0x0478, 0x0001 },

-  { 0x8500, 0x047b, 0x2fff },

-  { 0x0900, 0x047a, 0x0001 },

-  { 0x0900, 0x047c, 0x0001 },

-  { 0x8500, 0x0481, 0x3fff },

-  { 0x8500, 0x047f, 0x2fff },

-  { 0x0900, 0x047e, 0x0001 },

-  { 0x0900, 0x0480, 0x0001 },

-  { 0x8c00, 0x0483, 0x2000 },

-  { 0x1a00, 0x0482, 0x0000 },

-  { 0x0c00, 0x0484, 0x0000 },

-  { 0x8900, 0x048e, 0x4001 },

-  { 0x8900, 0x048a, 0x3001 },

-  { 0x8b00, 0x0488, 0x2000 },

-  { 0x0c00, 0x0486, 0x0000 },

-  { 0x0b00, 0x0489, 0x0000 },

-  { 0x8900, 0x048c, 0x2001 },

-  { 0x0500, 0x048b, 0x0fff },

-  { 0x0500, 0x048d, 0x0fff },

-  { 0x8900, 0x0492, 0x3001 },

-  { 0x8900, 0x0490, 0x2001 },

-  { 0x0500, 0x048f, 0x0fff },

-  { 0x0500, 0x0491, 0x0fff },

-  { 0x8900, 0x0494, 0x2001 },

-  { 0x0500, 0x0493, 0x0fff },

-  { 0x0500, 0x0495, 0x0fff },

-  { 0x8900, 0x04a6, 0x5001 },

-  { 0x8900, 0x049e, 0x4001 },

-  { 0x8900, 0x049a, 0x3001 },

-  { 0x8900, 0x0498, 0x2001 },

-  { 0x0500, 0x0497, 0x0fff },

-  { 0x0500, 0x0499, 0x0fff },

-  { 0x8900, 0x049c, 0x2001 },

-  { 0x0500, 0x049b, 0x0fff },

-  { 0x0500, 0x049d, 0x0fff },

-  { 0x8900, 0x04a2, 0x3001 },

-  { 0x8900, 0x04a0, 0x2001 },

-  { 0x0500, 0x049f, 0x0fff },

-  { 0x0500, 0x04a1, 0x0fff },

-  { 0x8900, 0x04a4, 0x2001 },

-  { 0x0500, 0x04a3, 0x0fff },

-  { 0x0500, 0x04a5, 0x0fff },

-  { 0x8900, 0x04ae, 0x4001 },

-  { 0x8900, 0x04aa, 0x3001 },

-  { 0x8900, 0x04a8, 0x2001 },

-  { 0x0500, 0x04a7, 0x0fff },

-  { 0x0500, 0x04a9, 0x0fff },

-  { 0x8900, 0x04ac, 0x2001 },

-  { 0x0500, 0x04ab, 0x0fff },

-  { 0x0500, 0x04ad, 0x0fff },

-  { 0x8900, 0x04b2, 0x3001 },

-  { 0x8900, 0x04b0, 0x2001 },

-  { 0x0500, 0x04af, 0x0fff },

-  { 0x0500, 0x04b1, 0x0fff },

-  { 0x8900, 0x04b4, 0x2001 },

-  { 0x0500, 0x04b3, 0x0fff },

-  { 0x0500, 0x04b5, 0x0fff },

-  { 0x8500, 0x04f9, 0x7fff },

-  { 0x8500, 0x04d7, 0x6fff },

-  { 0x8500, 0x04c6, 0x5fff },

-  { 0x8900, 0x04be, 0x4001 },

-  { 0x8900, 0x04ba, 0x3001 },

-  { 0x8900, 0x04b8, 0x2001 },

-  { 0x0500, 0x04b7, 0x0fff },

-  { 0x0500, 0x04b9, 0x0fff },

-  { 0x8900, 0x04bc, 0x2001 },

-  { 0x0500, 0x04bb, 0x0fff },

-  { 0x0500, 0x04bd, 0x0fff },

-  { 0x8500, 0x04c2, 0x3fff },

-  { 0x8900, 0x04c0, 0x2000 },

-  { 0x0500, 0x04bf, 0x0fff },

-  { 0x0900, 0x04c1, 0x0001 },

-  { 0x8500, 0x04c4, 0x2fff },

-  { 0x0900, 0x04c3, 0x0001 },

-  { 0x0900, 0x04c5, 0x0001 },

-  { 0x8500, 0x04ce, 0x4fff },

-  { 0x8500, 0x04ca, 0x3fff },

-  { 0x8500, 0x04c8, 0x2fff },

-  { 0x0900, 0x04c7, 0x0001 },

-  { 0x0900, 0x04c9, 0x0001 },

-  { 0x8500, 0x04cc, 0x2fff },

-  { 0x0900, 0x04cb, 0x0001 },

-  { 0x0900, 0x04cd, 0x0001 },

-  { 0x8500, 0x04d3, 0x3fff },

-  { 0x8500, 0x04d1, 0x2fff },

-  { 0x0900, 0x04d0, 0x0001 },

-  { 0x0900, 0x04d2, 0x0001 },

-  { 0x8500, 0x04d5, 0x2fff },

-  { 0x0900, 0x04d4, 0x0001 },

-  { 0x0900, 0x04d6, 0x0001 },

-  { 0x8500, 0x04e7, 0x5fff },

-  { 0x8500, 0x04df, 0x4fff },

-  { 0x8500, 0x04db, 0x3fff },

-  { 0x8500, 0x04d9, 0x2fff },

-  { 0x0900, 0x04d8, 0x0001 },

-  { 0x0900, 0x04da, 0x0001 },

-  { 0x8500, 0x04dd, 0x2fff },

-  { 0x0900, 0x04dc, 0x0001 },

-  { 0x0900, 0x04de, 0x0001 },

-  { 0x8500, 0x04e3, 0x3fff },

-  { 0x8500, 0x04e1, 0x2fff },

-  { 0x0900, 0x04e0, 0x0001 },

-  { 0x0900, 0x04e2, 0x0001 },

-  { 0x8500, 0x04e5, 0x2fff },

-  { 0x0900, 0x04e4, 0x0001 },

-  { 0x0900, 0x04e6, 0x0001 },

-  { 0x8500, 0x04ef, 0x4fff },

-  { 0x8500, 0x04eb, 0x3fff },

-  { 0x8500, 0x04e9, 0x2fff },

-  { 0x0900, 0x04e8, 0x0001 },

-  { 0x0900, 0x04ea, 0x0001 },

-  { 0x8500, 0x04ed, 0x2fff },

-  { 0x0900, 0x04ec, 0x0001 },

-  { 0x0900, 0x04ee, 0x0001 },

-  { 0x8500, 0x04f3, 0x3fff },

-  { 0x8500, 0x04f1, 0x2fff },

-  { 0x0900, 0x04f0, 0x0001 },

-  { 0x0900, 0x04f2, 0x0001 },

-  { 0x8500, 0x04f5, 0x2fff },

-  { 0x0900, 0x04f4, 0x0001 },

-  { 0x0900, 0x04f8, 0x0001 },

-  { 0x8900, 0x0540, 0x6030 },

-  { 0x8500, 0x050f, 0x5fff },

-  { 0x8500, 0x0507, 0x4fff },

-  { 0x8500, 0x0503, 0x3fff },

-  { 0x8500, 0x0501, 0x2fff },

-  { 0x0900, 0x0500, 0x0001 },

-  { 0x0900, 0x0502, 0x0001 },

-  { 0x8500, 0x0505, 0x2fff },

-  { 0x0900, 0x0504, 0x0001 },

-  { 0x0900, 0x0506, 0x0001 },

-  { 0x8500, 0x050b, 0x3fff },

-  { 0x8500, 0x0509, 0x2fff },

-  { 0x0900, 0x0508, 0x0001 },

-  { 0x0900, 0x050a, 0x0001 },

-  { 0x8500, 0x050d, 0x2fff },

-  { 0x0900, 0x050c, 0x0001 },

-  { 0x0900, 0x050e, 0x0001 },

-  { 0x8900, 0x0538, 0x4030 },

-  { 0x8900, 0x0534, 0x3030 },

-  { 0x8900, 0x0532, 0x2030 },

-  { 0x0900, 0x0531, 0x0030 },

-  { 0x0900, 0x0533, 0x0030 },

-  { 0x8900, 0x0536, 0x2030 },

-  { 0x0900, 0x0535, 0x0030 },

-  { 0x0900, 0x0537, 0x0030 },

-  { 0x8900, 0x053c, 0x3030 },

-  { 0x8900, 0x053a, 0x2030 },

-  { 0x0900, 0x0539, 0x0030 },

-  { 0x0900, 0x053b, 0x0030 },

-  { 0x8900, 0x053e, 0x2030 },

-  { 0x0900, 0x053d, 0x0030 },

-  { 0x0900, 0x053f, 0x0030 },

-  { 0x8900, 0x0550, 0x5030 },

-  { 0x8900, 0x0548, 0x4030 },

-  { 0x8900, 0x0544, 0x3030 },

-  { 0x8900, 0x0542, 0x2030 },

-  { 0x0900, 0x0541, 0x0030 },

-  { 0x0900, 0x0543, 0x0030 },

-  { 0x8900, 0x0546, 0x2030 },

-  { 0x0900, 0x0545, 0x0030 },

-  { 0x0900, 0x0547, 0x0030 },

-  { 0x8900, 0x054c, 0x3030 },

-  { 0x8900, 0x054a, 0x2030 },

-  { 0x0900, 0x0549, 0x0030 },

-  { 0x0900, 0x054b, 0x0030 },

-  { 0x8900, 0x054e, 0x2030 },

-  { 0x0900, 0x054d, 0x0030 },

-  { 0x0900, 0x054f, 0x0030 },

-  { 0x9500, 0x055a, 0x4000 },

-  { 0x8900, 0x0554, 0x3030 },

-  { 0x8900, 0x0552, 0x2030 },

-  { 0x0900, 0x0551, 0x0030 },

-  { 0x0900, 0x0553, 0x0030 },

-  { 0x8900, 0x0556, 0x2030 },

-  { 0x0900, 0x0555, 0x0030 },

-  { 0x0600, 0x0559, 0x0000 },

-  { 0x9500, 0x055e, 0x3000 },

-  { 0x9500, 0x055c, 0x2000 },

-  { 0x1500, 0x055b, 0x0000 },

-  { 0x1500, 0x055d, 0x0000 },

-  { 0x8500, 0x0561, 0x2fd0 },

-  { 0x1500, 0x055f, 0x0000 },

-  { 0x0500, 0x0562, 0x0fd0 },

-  { 0x9a00, 0x060f, 0x8000 },

-  { 0x8c00, 0x05ab, 0x7000 },

-  { 0x8500, 0x0583, 0x6fd0 },

-  { 0x8500, 0x0573, 0x5fd0 },

-  { 0x8500, 0x056b, 0x4fd0 },

-  { 0x8500, 0x0567, 0x3fd0 },

-  { 0x8500, 0x0565, 0x2fd0 },

-  { 0x0500, 0x0564, 0x0fd0 },

-  { 0x0500, 0x0566, 0x0fd0 },

-  { 0x8500, 0x0569, 0x2fd0 },

-  { 0x0500, 0x0568, 0x0fd0 },

-  { 0x0500, 0x056a, 0x0fd0 },

-  { 0x8500, 0x056f, 0x3fd0 },

-  { 0x8500, 0x056d, 0x2fd0 },

-  { 0x0500, 0x056c, 0x0fd0 },

-  { 0x0500, 0x056e, 0x0fd0 },

-  { 0x8500, 0x0571, 0x2fd0 },

-  { 0x0500, 0x0570, 0x0fd0 },

-  { 0x0500, 0x0572, 0x0fd0 },

-  { 0x8500, 0x057b, 0x4fd0 },

-  { 0x8500, 0x0577, 0x3fd0 },

-  { 0x8500, 0x0575, 0x2fd0 },

-  { 0x0500, 0x0574, 0x0fd0 },

-  { 0x0500, 0x0576, 0x0fd0 },

-  { 0x8500, 0x0579, 0x2fd0 },

-  { 0x0500, 0x0578, 0x0fd0 },

-  { 0x0500, 0x057a, 0x0fd0 },

-  { 0x8500, 0x057f, 0x3fd0 },

-  { 0x8500, 0x057d, 0x2fd0 },

-  { 0x0500, 0x057c, 0x0fd0 },

-  { 0x0500, 0x057e, 0x0fd0 },

-  { 0x8500, 0x0581, 0x2fd0 },

-  { 0x0500, 0x0580, 0x0fd0 },

-  { 0x0500, 0x0582, 0x0fd0 },

-  { 0x8c00, 0x059a, 0x5000 },

-  { 0x8c00, 0x0592, 0x4000 },

-  { 0x8500, 0x0587, 0x3000 },

-  { 0x8500, 0x0585, 0x2fd0 },

-  { 0x0500, 0x0584, 0x0fd0 },

-  { 0x0500, 0x0586, 0x0fd0 },

-  { 0x9100, 0x058a, 0x2000 },

-  { 0x1500, 0x0589, 0x0000 },

-  { 0x0c00, 0x0591, 0x0000 },

-  { 0x8c00, 0x0596, 0x3000 },

-  { 0x8c00, 0x0594, 0x2000 },

-  { 0x0c00, 0x0593, 0x0000 },

-  { 0x0c00, 0x0595, 0x0000 },

-  { 0x8c00, 0x0598, 0x2000 },

-  { 0x0c00, 0x0597, 0x0000 },

-  { 0x0c00, 0x0599, 0x0000 },

-  { 0x8c00, 0x05a3, 0x4000 },

-  { 0x8c00, 0x059e, 0x3000 },

-  { 0x8c00, 0x059c, 0x2000 },

-  { 0x0c00, 0x059b, 0x0000 },

-  { 0x0c00, 0x059d, 0x0000 },

-  { 0x8c00, 0x05a0, 0x2000 },

-  { 0x0c00, 0x059f, 0x0000 },

-  { 0x0c00, 0x05a1, 0x0000 },

-  { 0x8c00, 0x05a7, 0x3000 },

-  { 0x8c00, 0x05a5, 0x2000 },

-  { 0x0c00, 0x05a4, 0x0000 },

-  { 0x0c00, 0x05a6, 0x0000 },

-  { 0x8c00, 0x05a9, 0x2000 },

-  { 0x0c00, 0x05a8, 0x0000 },

-  { 0x0c00, 0x05aa, 0x0000 },

-  { 0x8700, 0x05d7, 0x6000 },

-  { 0x8c00, 0x05bc, 0x5000 },

-  { 0x8c00, 0x05b3, 0x4000 },

-  { 0x8c00, 0x05af, 0x3000 },

-  { 0x8c00, 0x05ad, 0x2000 },

-  { 0x0c00, 0x05ac, 0x0000 },

-  { 0x0c00, 0x05ae, 0x0000 },

-  { 0x8c00, 0x05b1, 0x2000 },

-  { 0x0c00, 0x05b0, 0x0000 },

-  { 0x0c00, 0x05b2, 0x0000 },

-  { 0x8c00, 0x05b7, 0x3000 },

-  { 0x8c00, 0x05b5, 0x2000 },

-  { 0x0c00, 0x05b4, 0x0000 },

-  { 0x0c00, 0x05b6, 0x0000 },

-  { 0x8c00, 0x05b9, 0x2000 },

-  { 0x0c00, 0x05b8, 0x0000 },

-  { 0x0c00, 0x05bb, 0x0000 },

-  { 0x8c00, 0x05c4, 0x4000 },

-  { 0x9500, 0x05c0, 0x3000 },

-  { 0x9500, 0x05be, 0x2000 },

-  { 0x0c00, 0x05bd, 0x0000 },

-  { 0x0c00, 0x05bf, 0x0000 },

-  { 0x8c00, 0x05c2, 0x2000 },

-  { 0x0c00, 0x05c1, 0x0000 },

-  { 0x1500, 0x05c3, 0x0000 },

-  { 0x8700, 0x05d3, 0x3000 },

-  { 0x8700, 0x05d1, 0x2000 },

-  { 0x0700, 0x05d0, 0x0000 },

-  { 0x0700, 0x05d2, 0x0000 },

-  { 0x8700, 0x05d5, 0x2000 },

-  { 0x0700, 0x05d4, 0x0000 },

-  { 0x0700, 0x05d6, 0x0000 },

-  { 0x8700, 0x05e7, 0x5000 },

-  { 0x8700, 0x05df, 0x4000 },

-  { 0x8700, 0x05db, 0x3000 },

-  { 0x8700, 0x05d9, 0x2000 },

-  { 0x0700, 0x05d8, 0x0000 },

-  { 0x0700, 0x05da, 0x0000 },

-  { 0x8700, 0x05dd, 0x2000 },

-  { 0x0700, 0x05dc, 0x0000 },

-  { 0x0700, 0x05de, 0x0000 },

-  { 0x8700, 0x05e3, 0x3000 },

-  { 0x8700, 0x05e1, 0x2000 },

-  { 0x0700, 0x05e0, 0x0000 },

-  { 0x0700, 0x05e2, 0x0000 },

-  { 0x8700, 0x05e5, 0x2000 },

-  { 0x0700, 0x05e4, 0x0000 },

-  { 0x0700, 0x05e6, 0x0000 },

-  { 0x9500, 0x05f4, 0x4000 },

-  { 0x8700, 0x05f0, 0x3000 },

-  { 0x8700, 0x05e9, 0x2000 },

-  { 0x0700, 0x05e8, 0x0000 },

-  { 0x0700, 0x05ea, 0x0000 },

-  { 0x8700, 0x05f2, 0x2000 },

-  { 0x0700, 0x05f1, 0x0000 },

-  { 0x1500, 0x05f3, 0x0000 },

-  { 0x8100, 0x0603, 0x3000 },

-  { 0x8100, 0x0601, 0x2000 },

-  { 0x0100, 0x0600, 0x0000 },

-  { 0x0100, 0x0602, 0x0000 },

-  { 0x9500, 0x060d, 0x2000 },

-  { 0x1500, 0x060c, 0x0000 },

-  { 0x1a00, 0x060e, 0x0000 },

-  { 0x8d00, 0x0664, 0x7000 },

-  { 0x8700, 0x0638, 0x6000 },

-  { 0x8700, 0x0628, 0x5000 },

-  { 0x9500, 0x061f, 0x4000 },

-  { 0x8c00, 0x0613, 0x3000 },

-  { 0x8c00, 0x0611, 0x2000 },

-  { 0x0c00, 0x0610, 0x0000 },

-  { 0x0c00, 0x0612, 0x0000 },

-  { 0x8c00, 0x0615, 0x2000 },

-  { 0x0c00, 0x0614, 0x0000 },

-  { 0x1500, 0x061b, 0x0000 },

-  { 0x8700, 0x0624, 0x3000 },

-  { 0x8700, 0x0622, 0x2000 },

-  { 0x0700, 0x0621, 0x0000 },

-  { 0x0700, 0x0623, 0x0000 },

-  { 0x8700, 0x0626, 0x2000 },

-  { 0x0700, 0x0625, 0x0000 },

-  { 0x0700, 0x0627, 0x0000 },

-  { 0x8700, 0x0630, 0x4000 },

-  { 0x8700, 0x062c, 0x3000 },

-  { 0x8700, 0x062a, 0x2000 },

-  { 0x0700, 0x0629, 0x0000 },

-  { 0x0700, 0x062b, 0x0000 },

-  { 0x8700, 0x062e, 0x2000 },

-  { 0x0700, 0x062d, 0x0000 },

-  { 0x0700, 0x062f, 0x0000 },

-  { 0x8700, 0x0634, 0x3000 },

-  { 0x8700, 0x0632, 0x2000 },

-  { 0x0700, 0x0631, 0x0000 },

-  { 0x0700, 0x0633, 0x0000 },

-  { 0x8700, 0x0636, 0x2000 },

-  { 0x0700, 0x0635, 0x0000 },

-  { 0x0700, 0x0637, 0x0000 },

-  { 0x8c00, 0x064d, 0x5000 },

-  { 0x8700, 0x0645, 0x4000 },

-  { 0x8700, 0x0641, 0x3000 },

-  { 0x8700, 0x063a, 0x2000 },

-  { 0x0700, 0x0639, 0x0000 },

-  { 0x0600, 0x0640, 0x0000 },

-  { 0x8700, 0x0643, 0x2000 },

-  { 0x0700, 0x0642, 0x0000 },

-  { 0x0700, 0x0644, 0x0000 },

-  { 0x8700, 0x0649, 0x3000 },

-  { 0x8700, 0x0647, 0x2000 },

-  { 0x0700, 0x0646, 0x0000 },

-  { 0x0700, 0x0648, 0x0000 },

-  { 0x8c00, 0x064b, 0x2000 },

-  { 0x0700, 0x064a, 0x0000 },

-  { 0x0c00, 0x064c, 0x0000 },

-  { 0x8c00, 0x0655, 0x4000 },

-  { 0x8c00, 0x0651, 0x3000 },

-  { 0x8c00, 0x064f, 0x2000 },

-  { 0x0c00, 0x064e, 0x0000 },

-  { 0x0c00, 0x0650, 0x0000 },

-  { 0x8c00, 0x0653, 0x2000 },

-  { 0x0c00, 0x0652, 0x0000 },

-  { 0x0c00, 0x0654, 0x0000 },

-  { 0x8d00, 0x0660, 0x3000 },

-  { 0x8c00, 0x0657, 0x2000 },

-  { 0x0c00, 0x0656, 0x0000 },

-  { 0x0c00, 0x0658, 0x0000 },

-  { 0x8d00, 0x0662, 0x2000 },

-  { 0x0d00, 0x0661, 0x0000 },

-  { 0x0d00, 0x0663, 0x0000 },

-  { 0x8700, 0x0684, 0x6000 },

-  { 0x8700, 0x0674, 0x5000 },

-  { 0x9500, 0x066c, 0x4000 },

-  { 0x8d00, 0x0668, 0x3000 },

-  { 0x8d00, 0x0666, 0x2000 },

-  { 0x0d00, 0x0665, 0x0000 },

-  { 0x0d00, 0x0667, 0x0000 },

-  { 0x9500, 0x066a, 0x2000 },

-  { 0x0d00, 0x0669, 0x0000 },

-  { 0x1500, 0x066b, 0x0000 },

-  { 0x8c00, 0x0670, 0x3000 },

-  { 0x8700, 0x066e, 0x2000 },

-  { 0x1500, 0x066d, 0x0000 },

-  { 0x0700, 0x066f, 0x0000 },

-  { 0x8700, 0x0672, 0x2000 },

-  { 0x0700, 0x0671, 0x0000 },

-  { 0x0700, 0x0673, 0x0000 },

-  { 0x8700, 0x067c, 0x4000 },

-  { 0x8700, 0x0678, 0x3000 },

-  { 0x8700, 0x0676, 0x2000 },

-  { 0x0700, 0x0675, 0x0000 },

-  { 0x0700, 0x0677, 0x0000 },

-  { 0x8700, 0x067a, 0x2000 },

-  { 0x0700, 0x0679, 0x0000 },

-  { 0x0700, 0x067b, 0x0000 },

-  { 0x8700, 0x0680, 0x3000 },

-  { 0x8700, 0x067e, 0x2000 },

-  { 0x0700, 0x067d, 0x0000 },

-  { 0x0700, 0x067f, 0x0000 },

-  { 0x8700, 0x0682, 0x2000 },

-  { 0x0700, 0x0681, 0x0000 },

-  { 0x0700, 0x0683, 0x0000 },

-  { 0x8700, 0x0694, 0x5000 },

-  { 0x8700, 0x068c, 0x4000 },

-  { 0x8700, 0x0688, 0x3000 },

-  { 0x8700, 0x0686, 0x2000 },

-  { 0x0700, 0x0685, 0x0000 },

-  { 0x0700, 0x0687, 0x0000 },

-  { 0x8700, 0x068a, 0x2000 },

-  { 0x0700, 0x0689, 0x0000 },

-  { 0x0700, 0x068b, 0x0000 },

-  { 0x8700, 0x0690, 0x3000 },

-  { 0x8700, 0x068e, 0x2000 },

-  { 0x0700, 0x068d, 0x0000 },

-  { 0x0700, 0x068f, 0x0000 },

-  { 0x8700, 0x0692, 0x2000 },

-  { 0x0700, 0x0691, 0x0000 },

-  { 0x0700, 0x0693, 0x0000 },

-  { 0x8700, 0x069c, 0x4000 },

-  { 0x8700, 0x0698, 0x3000 },

-  { 0x8700, 0x0696, 0x2000 },

-  { 0x0700, 0x0695, 0x0000 },

-  { 0x0700, 0x0697, 0x0000 },

-  { 0x8700, 0x069a, 0x2000 },

-  { 0x0700, 0x0699, 0x0000 },

-  { 0x0700, 0x069b, 0x0000 },

-  { 0x8700, 0x06a0, 0x3000 },

-  { 0x8700, 0x069e, 0x2000 },

-  { 0x0700, 0x069d, 0x0000 },

-  { 0x0700, 0x069f, 0x0000 },

-  { 0x8700, 0x06a2, 0x2000 },

-  { 0x0700, 0x06a1, 0x0000 },

-  { 0x0700, 0x06a3, 0x0000 },

-  { 0x8700, 0x0926, 0x9000 },

-  { 0x8700, 0x0725, 0x8000 },

-  { 0x8c00, 0x06e4, 0x7000 },

-  { 0x8700, 0x06c4, 0x6000 },

-  { 0x8700, 0x06b4, 0x5000 },

-  { 0x8700, 0x06ac, 0x4000 },

-  { 0x8700, 0x06a8, 0x3000 },

-  { 0x8700, 0x06a6, 0x2000 },

-  { 0x0700, 0x06a5, 0x0000 },

-  { 0x0700, 0x06a7, 0x0000 },

-  { 0x8700, 0x06aa, 0x2000 },

-  { 0x0700, 0x06a9, 0x0000 },

-  { 0x0700, 0x06ab, 0x0000 },

-  { 0x8700, 0x06b0, 0x3000 },

-  { 0x8700, 0x06ae, 0x2000 },

-  { 0x0700, 0x06ad, 0x0000 },

-  { 0x0700, 0x06af, 0x0000 },

-  { 0x8700, 0x06b2, 0x2000 },

-  { 0x0700, 0x06b1, 0x0000 },

-  { 0x0700, 0x06b3, 0x0000 },

-  { 0x8700, 0x06bc, 0x4000 },

-  { 0x8700, 0x06b8, 0x3000 },

-  { 0x8700, 0x06b6, 0x2000 },

-  { 0x0700, 0x06b5, 0x0000 },

-  { 0x0700, 0x06b7, 0x0000 },

-  { 0x8700, 0x06ba, 0x2000 },

-  { 0x0700, 0x06b9, 0x0000 },

-  { 0x0700, 0x06bb, 0x0000 },

-  { 0x8700, 0x06c0, 0x3000 },

-  { 0x8700, 0x06be, 0x2000 },

-  { 0x0700, 0x06bd, 0x0000 },

-  { 0x0700, 0x06bf, 0x0000 },

-  { 0x8700, 0x06c2, 0x2000 },

-  { 0x0700, 0x06c1, 0x0000 },

-  { 0x0700, 0x06c3, 0x0000 },

-  { 0x9500, 0x06d4, 0x5000 },

-  { 0x8700, 0x06cc, 0x4000 },

-  { 0x8700, 0x06c8, 0x3000 },

-  { 0x8700, 0x06c6, 0x2000 },

-  { 0x0700, 0x06c5, 0x0000 },

-  { 0x0700, 0x06c7, 0x0000 },

-  { 0x8700, 0x06ca, 0x2000 },

-  { 0x0700, 0x06c9, 0x0000 },

-  { 0x0700, 0x06cb, 0x0000 },

-  { 0x8700, 0x06d0, 0x3000 },

-  { 0x8700, 0x06ce, 0x2000 },

-  { 0x0700, 0x06cd, 0x0000 },

-  { 0x0700, 0x06cf, 0x0000 },

-  { 0x8700, 0x06d2, 0x2000 },

-  { 0x0700, 0x06d1, 0x0000 },

-  { 0x0700, 0x06d3, 0x0000 },

-  { 0x8c00, 0x06dc, 0x4000 },

-  { 0x8c00, 0x06d8, 0x3000 },

-  { 0x8c00, 0x06d6, 0x2000 },

-  { 0x0700, 0x06d5, 0x0000 },

-  { 0x0c00, 0x06d7, 0x0000 },

-  { 0x8c00, 0x06da, 0x2000 },

-  { 0x0c00, 0x06d9, 0x0000 },

-  { 0x0c00, 0x06db, 0x0000 },

-  { 0x8c00, 0x06e0, 0x3000 },

-  { 0x8b00, 0x06de, 0x2000 },

-  { 0x0100, 0x06dd, 0x0000 },

-  { 0x0c00, 0x06df, 0x0000 },

-  { 0x8c00, 0x06e2, 0x2000 },

-  { 0x0c00, 0x06e1, 0x0000 },

-  { 0x0c00, 0x06e3, 0x0000 },

-  { 0x9500, 0x0704, 0x6000 },

-  { 0x8d00, 0x06f4, 0x5000 },

-  { 0x8c00, 0x06ec, 0x4000 },

-  { 0x8c00, 0x06e8, 0x3000 },

-  { 0x8600, 0x06e6, 0x2000 },

-  { 0x0600, 0x06e5, 0x0000 },

-  { 0x0c00, 0x06e7, 0x0000 },

-  { 0x8c00, 0x06ea, 0x2000 },

-  { 0x1a00, 0x06e9, 0x0000 },

-  { 0x0c00, 0x06eb, 0x0000 },

-  { 0x8d00, 0x06f0, 0x3000 },

-  { 0x8700, 0x06ee, 0x2000 },

-  { 0x0c00, 0x06ed, 0x0000 },

-  { 0x0700, 0x06ef, 0x0000 },

-  { 0x8d00, 0x06f2, 0x2000 },

-  { 0x0d00, 0x06f1, 0x0000 },

-  { 0x0d00, 0x06f3, 0x0000 },

-  { 0x8700, 0x06fc, 0x4000 },

-  { 0x8d00, 0x06f8, 0x3000 },

-  { 0x8d00, 0x06f6, 0x2000 },

-  { 0x0d00, 0x06f5, 0x0000 },

-  { 0x0d00, 0x06f7, 0x0000 },

-  { 0x8700, 0x06fa, 0x2000 },

-  { 0x0d00, 0x06f9, 0x0000 },

-  { 0x0700, 0x06fb, 0x0000 },

-  { 0x9500, 0x0700, 0x3000 },

-  { 0x9a00, 0x06fe, 0x2000 },

-  { 0x1a00, 0x06fd, 0x0000 },

-  { 0x0700, 0x06ff, 0x0000 },

-  { 0x9500, 0x0702, 0x2000 },

-  { 0x1500, 0x0701, 0x0000 },

-  { 0x1500, 0x0703, 0x0000 },

-  { 0x8700, 0x0715, 0x5000 },

-  { 0x9500, 0x070c, 0x4000 },

-  { 0x9500, 0x0708, 0x3000 },

-  { 0x9500, 0x0706, 0x2000 },

-  { 0x1500, 0x0705, 0x0000 },

-  { 0x1500, 0x0707, 0x0000 },

-  { 0x9500, 0x070a, 0x2000 },

-  { 0x1500, 0x0709, 0x0000 },

-  { 0x1500, 0x070b, 0x0000 },

-  { 0x8c00, 0x0711, 0x3000 },

-  { 0x8100, 0x070f, 0x2000 },

-  { 0x1500, 0x070d, 0x0000 },

-  { 0x0700, 0x0710, 0x0000 },

-  { 0x8700, 0x0713, 0x2000 },

-  { 0x0700, 0x0712, 0x0000 },

-  { 0x0700, 0x0714, 0x0000 },

-  { 0x8700, 0x071d, 0x4000 },

-  { 0x8700, 0x0719, 0x3000 },

-  { 0x8700, 0x0717, 0x2000 },

-  { 0x0700, 0x0716, 0x0000 },

-  { 0x0700, 0x0718, 0x0000 },

-  { 0x8700, 0x071b, 0x2000 },

-  { 0x0700, 0x071a, 0x0000 },

-  { 0x0700, 0x071c, 0x0000 },

-  { 0x8700, 0x0721, 0x3000 },

-  { 0x8700, 0x071f, 0x2000 },

-  { 0x0700, 0x071e, 0x0000 },

-  { 0x0700, 0x0720, 0x0000 },

-  { 0x8700, 0x0723, 0x2000 },

-  { 0x0700, 0x0722, 0x0000 },

-  { 0x0700, 0x0724, 0x0000 },

-  { 0x8700, 0x0797, 0x7000 },

-  { 0x8c00, 0x0745, 0x6000 },

-  { 0x8c00, 0x0735, 0x5000 },

-  { 0x8700, 0x072d, 0x4000 },

-  { 0x8700, 0x0729, 0x3000 },

-  { 0x8700, 0x0727, 0x2000 },

-  { 0x0700, 0x0726, 0x0000 },

-  { 0x0700, 0x0728, 0x0000 },

-  { 0x8700, 0x072b, 0x2000 },

-  { 0x0700, 0x072a, 0x0000 },

-  { 0x0700, 0x072c, 0x0000 },

-  { 0x8c00, 0x0731, 0x3000 },

-  { 0x8700, 0x072f, 0x2000 },

-  { 0x0700, 0x072e, 0x0000 },

-  { 0x0c00, 0x0730, 0x0000 },

-  { 0x8c00, 0x0733, 0x2000 },

-  { 0x0c00, 0x0732, 0x0000 },

-  { 0x0c00, 0x0734, 0x0000 },

-  { 0x8c00, 0x073d, 0x4000 },

-  { 0x8c00, 0x0739, 0x3000 },

-  { 0x8c00, 0x0737, 0x2000 },

-  { 0x0c00, 0x0736, 0x0000 },

-  { 0x0c00, 0x0738, 0x0000 },

-  { 0x8c00, 0x073b, 0x2000 },

-  { 0x0c00, 0x073a, 0x0000 },

-  { 0x0c00, 0x073c, 0x0000 },

-  { 0x8c00, 0x0741, 0x3000 },

-  { 0x8c00, 0x073f, 0x2000 },

-  { 0x0c00, 0x073e, 0x0000 },

-  { 0x0c00, 0x0740, 0x0000 },

-  { 0x8c00, 0x0743, 0x2000 },

-  { 0x0c00, 0x0742, 0x0000 },

-  { 0x0c00, 0x0744, 0x0000 },

-  { 0x8700, 0x0787, 0x5000 },

-  { 0x8700, 0x074f, 0x4000 },

-  { 0x8c00, 0x0749, 0x3000 },

-  { 0x8c00, 0x0747, 0x2000 },

-  { 0x0c00, 0x0746, 0x0000 },

-  { 0x0c00, 0x0748, 0x0000 },

-  { 0x8700, 0x074d, 0x2000 },

-  { 0x0c00, 0x074a, 0x0000 },

-  { 0x0700, 0x074e, 0x0000 },

-  { 0x8700, 0x0783, 0x3000 },

-  { 0x8700, 0x0781, 0x2000 },

-  { 0x0700, 0x0780, 0x0000 },

-  { 0x0700, 0x0782, 0x0000 },

-  { 0x8700, 0x0785, 0x2000 },

-  { 0x0700, 0x0784, 0x0000 },

-  { 0x0700, 0x0786, 0x0000 },

-  { 0x8700, 0x078f, 0x4000 },

-  { 0x8700, 0x078b, 0x3000 },

-  { 0x8700, 0x0789, 0x2000 },

-  { 0x0700, 0x0788, 0x0000 },

-  { 0x0700, 0x078a, 0x0000 },

-  { 0x8700, 0x078d, 0x2000 },

-  { 0x0700, 0x078c, 0x0000 },

-  { 0x0700, 0x078e, 0x0000 },

-  { 0x8700, 0x0793, 0x3000 },

-  { 0x8700, 0x0791, 0x2000 },

-  { 0x0700, 0x0790, 0x0000 },

-  { 0x0700, 0x0792, 0x0000 },

-  { 0x8700, 0x0795, 0x2000 },

-  { 0x0700, 0x0794, 0x0000 },

-  { 0x0700, 0x0796, 0x0000 },

-  { 0x8700, 0x0906, 0x6000 },

-  { 0x8c00, 0x07a7, 0x5000 },

-  { 0x8700, 0x079f, 0x4000 },

-  { 0x8700, 0x079b, 0x3000 },

-  { 0x8700, 0x0799, 0x2000 },

-  { 0x0700, 0x0798, 0x0000 },

-  { 0x0700, 0x079a, 0x0000 },

-  { 0x8700, 0x079d, 0x2000 },

-  { 0x0700, 0x079c, 0x0000 },

-  { 0x0700, 0x079e, 0x0000 },

-  { 0x8700, 0x07a3, 0x3000 },

-  { 0x8700, 0x07a1, 0x2000 },

-  { 0x0700, 0x07a0, 0x0000 },

-  { 0x0700, 0x07a2, 0x0000 },

-  { 0x8700, 0x07a5, 0x2000 },

-  { 0x0700, 0x07a4, 0x0000 },

-  { 0x0c00, 0x07a6, 0x0000 },

-  { 0x8c00, 0x07af, 0x4000 },

-  { 0x8c00, 0x07ab, 0x3000 },

-  { 0x8c00, 0x07a9, 0x2000 },

-  { 0x0c00, 0x07a8, 0x0000 },

-  { 0x0c00, 0x07aa, 0x0000 },

-  { 0x8c00, 0x07ad, 0x2000 },

-  { 0x0c00, 0x07ac, 0x0000 },

-  { 0x0c00, 0x07ae, 0x0000 },

-  { 0x8c00, 0x0902, 0x3000 },

-  { 0x8700, 0x07b1, 0x2000 },

-  { 0x0c00, 0x07b0, 0x0000 },

-  { 0x0c00, 0x0901, 0x0000 },

-  { 0x8700, 0x0904, 0x2000 },

-  { 0x0a00, 0x0903, 0x0000 },

-  { 0x0700, 0x0905, 0x0000 },

-  { 0x8700, 0x0916, 0x5000 },

-  { 0x8700, 0x090e, 0x4000 },

-  { 0x8700, 0x090a, 0x3000 },

-  { 0x8700, 0x0908, 0x2000 },

-  { 0x0700, 0x0907, 0x0000 },

-  { 0x0700, 0x0909, 0x0000 },

-  { 0x8700, 0x090c, 0x2000 },

-  { 0x0700, 0x090b, 0x0000 },

-  { 0x0700, 0x090d, 0x0000 },

-  { 0x8700, 0x0912, 0x3000 },

-  { 0x8700, 0x0910, 0x2000 },

-  { 0x0700, 0x090f, 0x0000 },

-  { 0x0700, 0x0911, 0x0000 },

-  { 0x8700, 0x0914, 0x2000 },

-  { 0x0700, 0x0913, 0x0000 },

-  { 0x0700, 0x0915, 0x0000 },

-  { 0x8700, 0x091e, 0x4000 },

-  { 0x8700, 0x091a, 0x3000 },

-  { 0x8700, 0x0918, 0x2000 },

-  { 0x0700, 0x0917, 0x0000 },

-  { 0x0700, 0x0919, 0x0000 },

-  { 0x8700, 0x091c, 0x2000 },

-  { 0x0700, 0x091b, 0x0000 },

-  { 0x0700, 0x091d, 0x0000 },

-  { 0x8700, 0x0922, 0x3000 },

-  { 0x8700, 0x0920, 0x2000 },

-  { 0x0700, 0x091f, 0x0000 },

-  { 0x0700, 0x0921, 0x0000 },

-  { 0x8700, 0x0924, 0x2000 },

-  { 0x0700, 0x0923, 0x0000 },

-  { 0x0700, 0x0925, 0x0000 },

-  { 0x8c00, 0x09cd, 0x8000 },

-  { 0x8d00, 0x096d, 0x7000 },

-  { 0x8c00, 0x0948, 0x6000 },

-  { 0x8700, 0x0936, 0x5000 },

-  { 0x8700, 0x092e, 0x4000 },

-  { 0x8700, 0x092a, 0x3000 },

-  { 0x8700, 0x0928, 0x2000 },

-  { 0x0700, 0x0927, 0x0000 },

-  { 0x0700, 0x0929, 0x0000 },

-  { 0x8700, 0x092c, 0x2000 },

-  { 0x0700, 0x092b, 0x0000 },

-  { 0x0700, 0x092d, 0x0000 },

-  { 0x8700, 0x0932, 0x3000 },

-  { 0x8700, 0x0930, 0x2000 },

-  { 0x0700, 0x092f, 0x0000 },

-  { 0x0700, 0x0931, 0x0000 },

-  { 0x8700, 0x0934, 0x2000 },

-  { 0x0700, 0x0933, 0x0000 },

-  { 0x0700, 0x0935, 0x0000 },

-  { 0x8a00, 0x0940, 0x4000 },

-  { 0x8c00, 0x093c, 0x3000 },

-  { 0x8700, 0x0938, 0x2000 },

-  { 0x0700, 0x0937, 0x0000 },

-  { 0x0700, 0x0939, 0x0000 },

-  { 0x8a00, 0x093e, 0x2000 },

-  { 0x0700, 0x093d, 0x0000 },

-  { 0x0a00, 0x093f, 0x0000 },

-  { 0x8c00, 0x0944, 0x3000 },

-  { 0x8c00, 0x0942, 0x2000 },

-  { 0x0c00, 0x0941, 0x0000 },

-  { 0x0c00, 0x0943, 0x0000 },

-  { 0x8c00, 0x0946, 0x2000 },

-  { 0x0c00, 0x0945, 0x0000 },

-  { 0x0c00, 0x0947, 0x0000 },

-  { 0x8700, 0x095d, 0x5000 },

-  { 0x8c00, 0x0952, 0x4000 },

-  { 0x8a00, 0x094c, 0x3000 },

-  { 0x8a00, 0x094a, 0x2000 },

-  { 0x0a00, 0x0949, 0x0000 },

-  { 0x0a00, 0x094b, 0x0000 },

-  { 0x8700, 0x0950, 0x2000 },

-  { 0x0c00, 0x094d, 0x0000 },

-  { 0x0c00, 0x0951, 0x0000 },

-  { 0x8700, 0x0959, 0x3000 },

-  { 0x8c00, 0x0954, 0x2000 },

-  { 0x0c00, 0x0953, 0x0000 },

-  { 0x0700, 0x0958, 0x0000 },

-  { 0x8700, 0x095b, 0x2000 },

-  { 0x0700, 0x095a, 0x0000 },

-  { 0x0700, 0x095c, 0x0000 },

-  { 0x9500, 0x0965, 0x4000 },

-  { 0x8700, 0x0961, 0x3000 },

-  { 0x8700, 0x095f, 0x2000 },

-  { 0x0700, 0x095e, 0x0000 },

-  { 0x0700, 0x0960, 0x0000 },

-  { 0x8c00, 0x0963, 0x2000 },

-  { 0x0c00, 0x0962, 0x0000 },

-  { 0x1500, 0x0964, 0x0000 },

-  { 0x8d00, 0x0969, 0x3000 },

-  { 0x8d00, 0x0967, 0x2000 },

-  { 0x0d00, 0x0966, 0x0000 },

-  { 0x0d00, 0x0968, 0x0000 },

-  { 0x8d00, 0x096b, 0x2000 },

-  { 0x0d00, 0x096a, 0x0000 },

-  { 0x0d00, 0x096c, 0x0000 },

-  { 0x8700, 0x09a2, 0x6000 },

-  { 0x8700, 0x0990, 0x5000 },

-  { 0x8700, 0x0986, 0x4000 },

-  { 0x8c00, 0x0981, 0x3000 },

-  { 0x8d00, 0x096f, 0x2000 },

-  { 0x0d00, 0x096e, 0x0000 },

-  { 0x1500, 0x0970, 0x0000 },

-  { 0x8a00, 0x0983, 0x2000 },

-  { 0x0a00, 0x0982, 0x0000 },

-  { 0x0700, 0x0985, 0x0000 },

-  { 0x8700, 0x098a, 0x3000 },

-  { 0x8700, 0x0988, 0x2000 },

-  { 0x0700, 0x0987, 0x0000 },

-  { 0x0700, 0x0989, 0x0000 },

-  { 0x8700, 0x098c, 0x2000 },

-  { 0x0700, 0x098b, 0x0000 },

-  { 0x0700, 0x098f, 0x0000 },

-  { 0x8700, 0x099a, 0x4000 },

-  { 0x8700, 0x0996, 0x3000 },

-  { 0x8700, 0x0994, 0x2000 },

-  { 0x0700, 0x0993, 0x0000 },

-  { 0x0700, 0x0995, 0x0000 },

-  { 0x8700, 0x0998, 0x2000 },

-  { 0x0700, 0x0997, 0x0000 },

-  { 0x0700, 0x0999, 0x0000 },

-  { 0x8700, 0x099e, 0x3000 },

-  { 0x8700, 0x099c, 0x2000 },

-  { 0x0700, 0x099b, 0x0000 },

-  { 0x0700, 0x099d, 0x0000 },

-  { 0x8700, 0x09a0, 0x2000 },

-  { 0x0700, 0x099f, 0x0000 },

-  { 0x0700, 0x09a1, 0x0000 },

-  { 0x8700, 0x09b7, 0x5000 },

-  { 0x8700, 0x09ab, 0x4000 },

-  { 0x8700, 0x09a6, 0x3000 },

-  { 0x8700, 0x09a4, 0x2000 },

-  { 0x0700, 0x09a3, 0x0000 },

-  { 0x0700, 0x09a5, 0x0000 },

-  { 0x8700, 0x09a8, 0x2000 },

-  { 0x0700, 0x09a7, 0x0000 },

-  { 0x0700, 0x09aa, 0x0000 },

-  { 0x8700, 0x09af, 0x3000 },

-  { 0x8700, 0x09ad, 0x2000 },

-  { 0x0700, 0x09ac, 0x0000 },

-  { 0x0700, 0x09ae, 0x0000 },

-  { 0x8700, 0x09b2, 0x2000 },

-  { 0x0700, 0x09b0, 0x0000 },

-  { 0x0700, 0x09b6, 0x0000 },

-  { 0x8c00, 0x09c1, 0x4000 },

-  { 0x8700, 0x09bd, 0x3000 },

-  { 0x8700, 0x09b9, 0x2000 },

-  { 0x0700, 0x09b8, 0x0000 },

-  { 0x0c00, 0x09bc, 0x0000 },

-  { 0x8a00, 0x09bf, 0x2000 },

-  { 0x0a00, 0x09be, 0x0000 },

-  { 0x0a00, 0x09c0, 0x0000 },

-  { 0x8a00, 0x09c7, 0x3000 },

-  { 0x8c00, 0x09c3, 0x2000 },

-  { 0x0c00, 0x09c2, 0x0000 },

-  { 0x0c00, 0x09c4, 0x0000 },

-  { 0x8a00, 0x09cb, 0x2000 },

-  { 0x0a00, 0x09c8, 0x0000 },

-  { 0x0a00, 0x09cc, 0x0000 },

-  { 0x8700, 0x0a2b, 0x7000 },

-  { 0x8a00, 0x0a03, 0x6000 },

-  { 0x8d00, 0x09ed, 0x5000 },

-  { 0x8c00, 0x09e3, 0x4000 },

-  { 0x8700, 0x09df, 0x3000 },

-  { 0x8700, 0x09dc, 0x2000 },

-  { 0x0a00, 0x09d7, 0x0000 },

-  { 0x0700, 0x09dd, 0x0000 },

-  { 0x8700, 0x09e1, 0x2000 },

-  { 0x0700, 0x09e0, 0x0000 },

-  { 0x0c00, 0x09e2, 0x0000 },

-  { 0x8d00, 0x09e9, 0x3000 },

-  { 0x8d00, 0x09e7, 0x2000 },

-  { 0x0d00, 0x09e6, 0x0000 },

-  { 0x0d00, 0x09e8, 0x0000 },

-  { 0x8d00, 0x09eb, 0x2000 },

-  { 0x0d00, 0x09ea, 0x0000 },

-  { 0x0d00, 0x09ec, 0x0000 },

-  { 0x8f00, 0x09f5, 0x4000 },

-  { 0x8700, 0x09f1, 0x3000 },

-  { 0x8d00, 0x09ef, 0x2000 },

-  { 0x0d00, 0x09ee, 0x0000 },

-  { 0x0700, 0x09f0, 0x0000 },

-  { 0x9700, 0x09f3, 0x2000 },

-  { 0x1700, 0x09f2, 0x0000 },

-  { 0x0f00, 0x09f4, 0x0000 },

-  { 0x8f00, 0x09f9, 0x3000 },

-  { 0x8f00, 0x09f7, 0x2000 },

-  { 0x0f00, 0x09f6, 0x0000 },

-  { 0x0f00, 0x09f8, 0x0000 },

-  { 0x8c00, 0x0a01, 0x2000 },

-  { 0x1a00, 0x09fa, 0x0000 },

-  { 0x0c00, 0x0a02, 0x0000 },

-  { 0x8700, 0x0a1a, 0x5000 },

-  { 0x8700, 0x0a10, 0x4000 },

-  { 0x8700, 0x0a08, 0x3000 },

-  { 0x8700, 0x0a06, 0x2000 },

-  { 0x0700, 0x0a05, 0x0000 },

-  { 0x0700, 0x0a07, 0x0000 },

-  { 0x8700, 0x0a0a, 0x2000 },

-  { 0x0700, 0x0a09, 0x0000 },

-  { 0x0700, 0x0a0f, 0x0000 },

-  { 0x8700, 0x0a16, 0x3000 },

-  { 0x8700, 0x0a14, 0x2000 },

-  { 0x0700, 0x0a13, 0x0000 },

-  { 0x0700, 0x0a15, 0x0000 },

-  { 0x8700, 0x0a18, 0x2000 },

-  { 0x0700, 0x0a17, 0x0000 },

-  { 0x0700, 0x0a19, 0x0000 },

-  { 0x8700, 0x0a22, 0x4000 },

-  { 0x8700, 0x0a1e, 0x3000 },

-  { 0x8700, 0x0a1c, 0x2000 },

-  { 0x0700, 0x0a1b, 0x0000 },

-  { 0x0700, 0x0a1d, 0x0000 },

-  { 0x8700, 0x0a20, 0x2000 },

-  { 0x0700, 0x0a1f, 0x0000 },

-  { 0x0700, 0x0a21, 0x0000 },

-  { 0x8700, 0x0a26, 0x3000 },

-  { 0x8700, 0x0a24, 0x2000 },

-  { 0x0700, 0x0a23, 0x0000 },

-  { 0x0700, 0x0a25, 0x0000 },

-  { 0x8700, 0x0a28, 0x2000 },

-  { 0x0700, 0x0a27, 0x0000 },

-  { 0x0700, 0x0a2a, 0x0000 },

-  { 0x8d00, 0x0a6a, 0x6000 },

-  { 0x8c00, 0x0a41, 0x5000 },

-  { 0x8700, 0x0a35, 0x4000 },

-  { 0x8700, 0x0a2f, 0x3000 },

-  { 0x8700, 0x0a2d, 0x2000 },

-  { 0x0700, 0x0a2c, 0x0000 },

-  { 0x0700, 0x0a2e, 0x0000 },

-  { 0x8700, 0x0a32, 0x2000 },

-  { 0x0700, 0x0a30, 0x0000 },

-  { 0x0700, 0x0a33, 0x0000 },

-  { 0x8c00, 0x0a3c, 0x3000 },

-  { 0x8700, 0x0a38, 0x2000 },

-  { 0x0700, 0x0a36, 0x0000 },

-  { 0x0700, 0x0a39, 0x0000 },

-  { 0x8a00, 0x0a3f, 0x2000 },

-  { 0x0a00, 0x0a3e, 0x0000 },

-  { 0x0a00, 0x0a40, 0x0000 },

-  { 0x8700, 0x0a5a, 0x4000 },

-  { 0x8c00, 0x0a4b, 0x3000 },

-  { 0x8c00, 0x0a47, 0x2000 },

-  { 0x0c00, 0x0a42, 0x0000 },

-  { 0x0c00, 0x0a48, 0x0000 },

-  { 0x8c00, 0x0a4d, 0x2000 },

-  { 0x0c00, 0x0a4c, 0x0000 },

-  { 0x0700, 0x0a59, 0x0000 },

-  { 0x8d00, 0x0a66, 0x3000 },

-  { 0x8700, 0x0a5c, 0x2000 },

-  { 0x0700, 0x0a5b, 0x0000 },

-  { 0x0700, 0x0a5e, 0x0000 },

-  { 0x8d00, 0x0a68, 0x2000 },

-  { 0x0d00, 0x0a67, 0x0000 },

-  { 0x0d00, 0x0a69, 0x0000 },

-  { 0x8700, 0x0a87, 0x5000 },

-  { 0x8700, 0x0a72, 0x4000 },

-  { 0x8d00, 0x0a6e, 0x3000 },

-  { 0x8d00, 0x0a6c, 0x2000 },

-  { 0x0d00, 0x0a6b, 0x0000 },

-  { 0x0d00, 0x0a6d, 0x0000 },

-  { 0x8c00, 0x0a70, 0x2000 },

-  { 0x0d00, 0x0a6f, 0x0000 },

-  { 0x0c00, 0x0a71, 0x0000 },

-  { 0x8c00, 0x0a82, 0x3000 },

-  { 0x8700, 0x0a74, 0x2000 },

-  { 0x0700, 0x0a73, 0x0000 },

-  { 0x0c00, 0x0a81, 0x0000 },

-  { 0x8700, 0x0a85, 0x2000 },

-  { 0x0a00, 0x0a83, 0x0000 },

-  { 0x0700, 0x0a86, 0x0000 },

-  { 0x8700, 0x0a90, 0x4000 },

-  { 0x8700, 0x0a8b, 0x3000 },

-  { 0x8700, 0x0a89, 0x2000 },

-  { 0x0700, 0x0a88, 0x0000 },

-  { 0x0700, 0x0a8a, 0x0000 },

-  { 0x8700, 0x0a8d, 0x2000 },

-  { 0x0700, 0x0a8c, 0x0000 },

-  { 0x0700, 0x0a8f, 0x0000 },

-  { 0x8700, 0x0a95, 0x3000 },

-  { 0x8700, 0x0a93, 0x2000 },

-  { 0x0700, 0x0a91, 0x0000 },

-  { 0x0700, 0x0a94, 0x0000 },

-  { 0x8700, 0x0a97, 0x2000 },

-  { 0x0700, 0x0a96, 0x0000 },

-  { 0x0700, 0x0a98, 0x0000 },

-  { 0x8700, 0x10ef, 0xb000 },

-  { 0x8700, 0x0dc6, 0xa000 },

-  { 0x8700, 0x0c31, 0x9000 },

-  { 0x8700, 0x0b5f, 0x8000 },

-  { 0x8a00, 0x0b03, 0x7000 },

-  { 0x8a00, 0x0abe, 0x6000 },

-  { 0x8700, 0x0aaa, 0x5000 },

-  { 0x8700, 0x0aa1, 0x4000 },

-  { 0x8700, 0x0a9d, 0x3000 },

-  { 0x8700, 0x0a9b, 0x2000 },

-  { 0x0700, 0x0a9a, 0x0000 },

-  { 0x0700, 0x0a9c, 0x0000 },

-  { 0x8700, 0x0a9f, 0x2000 },

-  { 0x0700, 0x0a9e, 0x0000 },

-  { 0x0700, 0x0aa0, 0x0000 },

-  { 0x8700, 0x0aa5, 0x3000 },

-  { 0x8700, 0x0aa3, 0x2000 },

-  { 0x0700, 0x0aa2, 0x0000 },

-  { 0x0700, 0x0aa4, 0x0000 },

-  { 0x8700, 0x0aa7, 0x2000 },

-  { 0x0700, 0x0aa6, 0x0000 },

-  { 0x0700, 0x0aa8, 0x0000 },

-  { 0x8700, 0x0ab3, 0x4000 },

-  { 0x8700, 0x0aae, 0x3000 },

-  { 0x8700, 0x0aac, 0x2000 },

-  { 0x0700, 0x0aab, 0x0000 },

-  { 0x0700, 0x0aad, 0x0000 },

-  { 0x8700, 0x0ab0, 0x2000 },

-  { 0x0700, 0x0aaf, 0x0000 },

-  { 0x0700, 0x0ab2, 0x0000 },

-  { 0x8700, 0x0ab8, 0x3000 },

-  { 0x8700, 0x0ab6, 0x2000 },

-  { 0x0700, 0x0ab5, 0x0000 },

-  { 0x0700, 0x0ab7, 0x0000 },

-  { 0x8c00, 0x0abc, 0x2000 },

-  { 0x0700, 0x0ab9, 0x0000 },

-  { 0x0700, 0x0abd, 0x0000 },

-  { 0x8700, 0x0ae1, 0x5000 },

-  { 0x8c00, 0x0ac7, 0x4000 },

-  { 0x8c00, 0x0ac2, 0x3000 },

-  { 0x8a00, 0x0ac0, 0x2000 },

-  { 0x0a00, 0x0abf, 0x0000 },

-  { 0x0c00, 0x0ac1, 0x0000 },

-  { 0x8c00, 0x0ac4, 0x2000 },

-  { 0x0c00, 0x0ac3, 0x0000 },

-  { 0x0c00, 0x0ac5, 0x0000 },

-  { 0x8a00, 0x0acc, 0x3000 },

-  { 0x8a00, 0x0ac9, 0x2000 },

-  { 0x0c00, 0x0ac8, 0x0000 },

-  { 0x0a00, 0x0acb, 0x0000 },

-  { 0x8700, 0x0ad0, 0x2000 },

-  { 0x0c00, 0x0acd, 0x0000 },

-  { 0x0700, 0x0ae0, 0x0000 },

-  { 0x8d00, 0x0aeb, 0x4000 },

-  { 0x8d00, 0x0ae7, 0x3000 },

-  { 0x8c00, 0x0ae3, 0x2000 },

-  { 0x0c00, 0x0ae2, 0x0000 },

-  { 0x0d00, 0x0ae6, 0x0000 },

-  { 0x8d00, 0x0ae9, 0x2000 },

-  { 0x0d00, 0x0ae8, 0x0000 },

-  { 0x0d00, 0x0aea, 0x0000 },

-  { 0x8d00, 0x0aef, 0x3000 },

-  { 0x8d00, 0x0aed, 0x2000 },

-  { 0x0d00, 0x0aec, 0x0000 },

-  { 0x0d00, 0x0aee, 0x0000 },

-  { 0x8c00, 0x0b01, 0x2000 },

-  { 0x1700, 0x0af1, 0x0000 },

-  { 0x0a00, 0x0b02, 0x0000 },

-  { 0x8700, 0x0b28, 0x6000 },

-  { 0x8700, 0x0b18, 0x5000 },

-  { 0x8700, 0x0b0c, 0x4000 },

-  { 0x8700, 0x0b08, 0x3000 },

-  { 0x8700, 0x0b06, 0x2000 },

-  { 0x0700, 0x0b05, 0x0000 },

-  { 0x0700, 0x0b07, 0x0000 },

-  { 0x8700, 0x0b0a, 0x2000 },

-  { 0x0700, 0x0b09, 0x0000 },

-  { 0x0700, 0x0b0b, 0x0000 },

-  { 0x8700, 0x0b14, 0x3000 },

-  { 0x8700, 0x0b10, 0x2000 },

-  { 0x0700, 0x0b0f, 0x0000 },

-  { 0x0700, 0x0b13, 0x0000 },

-  { 0x8700, 0x0b16, 0x2000 },

-  { 0x0700, 0x0b15, 0x0000 },

-  { 0x0700, 0x0b17, 0x0000 },

-  { 0x8700, 0x0b20, 0x4000 },

-  { 0x8700, 0x0b1c, 0x3000 },

-  { 0x8700, 0x0b1a, 0x2000 },

-  { 0x0700, 0x0b19, 0x0000 },

-  { 0x0700, 0x0b1b, 0x0000 },

-  { 0x8700, 0x0b1e, 0x2000 },

-  { 0x0700, 0x0b1d, 0x0000 },

-  { 0x0700, 0x0b1f, 0x0000 },

-  { 0x8700, 0x0b24, 0x3000 },

-  { 0x8700, 0x0b22, 0x2000 },

-  { 0x0700, 0x0b21, 0x0000 },

-  { 0x0700, 0x0b23, 0x0000 },

-  { 0x8700, 0x0b26, 0x2000 },

-  { 0x0700, 0x0b25, 0x0000 },

-  { 0x0700, 0x0b27, 0x0000 },

-  { 0x8700, 0x0b3d, 0x5000 },

-  { 0x8700, 0x0b32, 0x4000 },

-  { 0x8700, 0x0b2d, 0x3000 },

-  { 0x8700, 0x0b2b, 0x2000 },

-  { 0x0700, 0x0b2a, 0x0000 },

-  { 0x0700, 0x0b2c, 0x0000 },

-  { 0x8700, 0x0b2f, 0x2000 },

-  { 0x0700, 0x0b2e, 0x0000 },

-  { 0x0700, 0x0b30, 0x0000 },

-  { 0x8700, 0x0b37, 0x3000 },

-  { 0x8700, 0x0b35, 0x2000 },

-  { 0x0700, 0x0b33, 0x0000 },

-  { 0x0700, 0x0b36, 0x0000 },

-  { 0x8700, 0x0b39, 0x2000 },

-  { 0x0700, 0x0b38, 0x0000 },

-  { 0x0c00, 0x0b3c, 0x0000 },

-  { 0x8a00, 0x0b48, 0x4000 },

-  { 0x8c00, 0x0b41, 0x3000 },

-  { 0x8c00, 0x0b3f, 0x2000 },

-  { 0x0a00, 0x0b3e, 0x0000 },

-  { 0x0a00, 0x0b40, 0x0000 },

-  { 0x8c00, 0x0b43, 0x2000 },

-  { 0x0c00, 0x0b42, 0x0000 },

-  { 0x0a00, 0x0b47, 0x0000 },

-  { 0x8c00, 0x0b56, 0x3000 },

-  { 0x8a00, 0x0b4c, 0x2000 },

-  { 0x0a00, 0x0b4b, 0x0000 },

-  { 0x0c00, 0x0b4d, 0x0000 },

-  { 0x8700, 0x0b5c, 0x2000 },

-  { 0x0a00, 0x0b57, 0x0000 },

-  { 0x0700, 0x0b5d, 0x0000 },

-  { 0x8d00, 0x0be7, 0x7000 },

-  { 0x8700, 0x0b9c, 0x6000 },

-  { 0x8700, 0x0b83, 0x5000 },

-  { 0x8d00, 0x0b6b, 0x4000 },

-  { 0x8d00, 0x0b67, 0x3000 },

-  { 0x8700, 0x0b61, 0x2000 },

-  { 0x0700, 0x0b60, 0x0000 },

-  { 0x0d00, 0x0b66, 0x0000 },

-  { 0x8d00, 0x0b69, 0x2000 },

-  { 0x0d00, 0x0b68, 0x0000 },

-  { 0x0d00, 0x0b6a, 0x0000 },

-  { 0x8d00, 0x0b6f, 0x3000 },

-  { 0x8d00, 0x0b6d, 0x2000 },

-  { 0x0d00, 0x0b6c, 0x0000 },

-  { 0x0d00, 0x0b6e, 0x0000 },

-  { 0x8700, 0x0b71, 0x2000 },

-  { 0x1a00, 0x0b70, 0x0000 },

-  { 0x0c00, 0x0b82, 0x0000 },

-  { 0x8700, 0x0b8f, 0x4000 },

-  { 0x8700, 0x0b88, 0x3000 },

-  { 0x8700, 0x0b86, 0x2000 },

-  { 0x0700, 0x0b85, 0x0000 },

-  { 0x0700, 0x0b87, 0x0000 },

-  { 0x8700, 0x0b8a, 0x2000 },

-  { 0x0700, 0x0b89, 0x0000 },

-  { 0x0700, 0x0b8e, 0x0000 },

-  { 0x8700, 0x0b94, 0x3000 },

-  { 0x8700, 0x0b92, 0x2000 },

-  { 0x0700, 0x0b90, 0x0000 },

-  { 0x0700, 0x0b93, 0x0000 },

-  { 0x8700, 0x0b99, 0x2000 },

-  { 0x0700, 0x0b95, 0x0000 },

-  { 0x0700, 0x0b9a, 0x0000 },

-  { 0x8700, 0x0bb7, 0x5000 },

-  { 0x8700, 0x0bae, 0x4000 },

-  { 0x8700, 0x0ba4, 0x3000 },

-  { 0x8700, 0x0b9f, 0x2000 },

-  { 0x0700, 0x0b9e, 0x0000 },

-  { 0x0700, 0x0ba3, 0x0000 },

-  { 0x8700, 0x0ba9, 0x2000 },

-  { 0x0700, 0x0ba8, 0x0000 },

-  { 0x0700, 0x0baa, 0x0000 },

-  { 0x8700, 0x0bb2, 0x3000 },

-  { 0x8700, 0x0bb0, 0x2000 },

-  { 0x0700, 0x0baf, 0x0000 },

-  { 0x0700, 0x0bb1, 0x0000 },

-  { 0x8700, 0x0bb4, 0x2000 },

-  { 0x0700, 0x0bb3, 0x0000 },

-  { 0x0700, 0x0bb5, 0x0000 },

-  { 0x8a00, 0x0bc6, 0x4000 },

-  { 0x8a00, 0x0bbf, 0x3000 },

-  { 0x8700, 0x0bb9, 0x2000 },

-  { 0x0700, 0x0bb8, 0x0000 },

-  { 0x0a00, 0x0bbe, 0x0000 },

-  { 0x8a00, 0x0bc1, 0x2000 },

-  { 0x0c00, 0x0bc0, 0x0000 },

-  { 0x0a00, 0x0bc2, 0x0000 },

-  { 0x8a00, 0x0bcb, 0x3000 },

-  { 0x8a00, 0x0bc8, 0x2000 },

-  { 0x0a00, 0x0bc7, 0x0000 },

-  { 0x0a00, 0x0bca, 0x0000 },

-  { 0x8c00, 0x0bcd, 0x2000 },

-  { 0x0a00, 0x0bcc, 0x0000 },

-  { 0x0a00, 0x0bd7, 0x0000 },

-  { 0x8700, 0x0c0f, 0x6000 },

-  { 0x9a00, 0x0bf7, 0x5000 },

-  { 0x8d00, 0x0bef, 0x4000 },

-  { 0x8d00, 0x0beb, 0x3000 },

-  { 0x8d00, 0x0be9, 0x2000 },

-  { 0x0d00, 0x0be8, 0x0000 },

-  { 0x0d00, 0x0bea, 0x0000 },

-  { 0x8d00, 0x0bed, 0x2000 },

-  { 0x0d00, 0x0bec, 0x0000 },

-  { 0x0d00, 0x0bee, 0x0000 },

-  { 0x9a00, 0x0bf3, 0x3000 },

-  { 0x8f00, 0x0bf1, 0x2000 },

-  { 0x0f00, 0x0bf0, 0x0000 },

-  { 0x0f00, 0x0bf2, 0x0000 },

-  { 0x9a00, 0x0bf5, 0x2000 },

-  { 0x1a00, 0x0bf4, 0x0000 },

-  { 0x1a00, 0x0bf6, 0x0000 },

-  { 0x8700, 0x0c06, 0x4000 },

-  { 0x8a00, 0x0c01, 0x3000 },

-  { 0x9700, 0x0bf9, 0x2000 },

-  { 0x1a00, 0x0bf8, 0x0000 },

-  { 0x1a00, 0x0bfa, 0x0000 },

-  { 0x8a00, 0x0c03, 0x2000 },

-  { 0x0a00, 0x0c02, 0x0000 },

-  { 0x0700, 0x0c05, 0x0000 },

-  { 0x8700, 0x0c0a, 0x3000 },

-  { 0x8700, 0x0c08, 0x2000 },

-  { 0x0700, 0x0c07, 0x0000 },

-  { 0x0700, 0x0c09, 0x0000 },

-  { 0x8700, 0x0c0c, 0x2000 },

-  { 0x0700, 0x0c0b, 0x0000 },

-  { 0x0700, 0x0c0e, 0x0000 },

-  { 0x8700, 0x0c20, 0x5000 },

-  { 0x8700, 0x0c18, 0x4000 },

-  { 0x8700, 0x0c14, 0x3000 },

-  { 0x8700, 0x0c12, 0x2000 },

-  { 0x0700, 0x0c10, 0x0000 },

-  { 0x0700, 0x0c13, 0x0000 },

-  { 0x8700, 0x0c16, 0x2000 },

-  { 0x0700, 0x0c15, 0x0000 },

-  { 0x0700, 0x0c17, 0x0000 },

-  { 0x8700, 0x0c1c, 0x3000 },

-  { 0x8700, 0x0c1a, 0x2000 },

-  { 0x0700, 0x0c19, 0x0000 },

-  { 0x0700, 0x0c1b, 0x0000 },

-  { 0x8700, 0x0c1e, 0x2000 },

-  { 0x0700, 0x0c1d, 0x0000 },

-  { 0x0700, 0x0c1f, 0x0000 },

-  { 0x8700, 0x0c28, 0x4000 },

-  { 0x8700, 0x0c24, 0x3000 },

-  { 0x8700, 0x0c22, 0x2000 },

-  { 0x0700, 0x0c21, 0x0000 },

-  { 0x0700, 0x0c23, 0x0000 },

-  { 0x8700, 0x0c26, 0x2000 },

-  { 0x0700, 0x0c25, 0x0000 },

-  { 0x0700, 0x0c27, 0x0000 },

-  { 0x8700, 0x0c2d, 0x3000 },

-  { 0x8700, 0x0c2b, 0x2000 },

-  { 0x0700, 0x0c2a, 0x0000 },

-  { 0x0700, 0x0c2c, 0x0000 },

-  { 0x8700, 0x0c2f, 0x2000 },

-  { 0x0700, 0x0c2e, 0x0000 },

-  { 0x0700, 0x0c30, 0x0000 },

-  { 0x8700, 0x0d0e, 0x8000 },

-  { 0x8700, 0x0ca1, 0x7000 },

-  { 0x8d00, 0x0c6c, 0x6000 },

-  { 0x8c00, 0x0c47, 0x5000 },

-  { 0x8c00, 0x0c3e, 0x4000 },

-  { 0x8700, 0x0c36, 0x3000 },

-  { 0x8700, 0x0c33, 0x2000 },

-  { 0x0700, 0x0c32, 0x0000 },

-  { 0x0700, 0x0c35, 0x0000 },

-  { 0x8700, 0x0c38, 0x2000 },

-  { 0x0700, 0x0c37, 0x0000 },

-  { 0x0700, 0x0c39, 0x0000 },

-  { 0x8a00, 0x0c42, 0x3000 },

-  { 0x8c00, 0x0c40, 0x2000 },

-  { 0x0c00, 0x0c3f, 0x0000 },

-  { 0x0a00, 0x0c41, 0x0000 },

-  { 0x8a00, 0x0c44, 0x2000 },

-  { 0x0a00, 0x0c43, 0x0000 },

-  { 0x0c00, 0x0c46, 0x0000 },

-  { 0x8700, 0x0c60, 0x4000 },

-  { 0x8c00, 0x0c4c, 0x3000 },

-  { 0x8c00, 0x0c4a, 0x2000 },

-  { 0x0c00, 0x0c48, 0x0000 },

-  { 0x0c00, 0x0c4b, 0x0000 },

-  { 0x8c00, 0x0c55, 0x2000 },

-  { 0x0c00, 0x0c4d, 0x0000 },

-  { 0x0c00, 0x0c56, 0x0000 },

-  { 0x8d00, 0x0c68, 0x3000 },

-  { 0x8d00, 0x0c66, 0x2000 },

-  { 0x0700, 0x0c61, 0x0000 },

-  { 0x0d00, 0x0c67, 0x0000 },

-  { 0x8d00, 0x0c6a, 0x2000 },

-  { 0x0d00, 0x0c69, 0x0000 },

-  { 0x0d00, 0x0c6b, 0x0000 },

-  { 0x8700, 0x0c90, 0x5000 },

-  { 0x8700, 0x0c87, 0x4000 },

-  { 0x8a00, 0x0c82, 0x3000 },

-  { 0x8d00, 0x0c6e, 0x2000 },

-  { 0x0d00, 0x0c6d, 0x0000 },

-  { 0x0d00, 0x0c6f, 0x0000 },

-  { 0x8700, 0x0c85, 0x2000 },

-  { 0x0a00, 0x0c83, 0x0000 },

-  { 0x0700, 0x0c86, 0x0000 },

-  { 0x8700, 0x0c8b, 0x3000 },

-  { 0x8700, 0x0c89, 0x2000 },

-  { 0x0700, 0x0c88, 0x0000 },

-  { 0x0700, 0x0c8a, 0x0000 },

-  { 0x8700, 0x0c8e, 0x2000 },

-  { 0x0700, 0x0c8c, 0x0000 },

-  { 0x0700, 0x0c8f, 0x0000 },

-  { 0x8700, 0x0c99, 0x4000 },

-  { 0x8700, 0x0c95, 0x3000 },

-  { 0x8700, 0x0c93, 0x2000 },

-  { 0x0700, 0x0c92, 0x0000 },

-  { 0x0700, 0x0c94, 0x0000 },

-  { 0x8700, 0x0c97, 0x2000 },

-  { 0x0700, 0x0c96, 0x0000 },

-  { 0x0700, 0x0c98, 0x0000 },

-  { 0x8700, 0x0c9d, 0x3000 },

-  { 0x8700, 0x0c9b, 0x2000 },

-  { 0x0700, 0x0c9a, 0x0000 },

-  { 0x0700, 0x0c9c, 0x0000 },

-  { 0x8700, 0x0c9f, 0x2000 },

-  { 0x0700, 0x0c9e, 0x0000 },

-  { 0x0700, 0x0ca0, 0x0000 },

-  { 0x8c00, 0x0cc6, 0x6000 },

-  { 0x8700, 0x0cb2, 0x5000 },

-  { 0x8700, 0x0caa, 0x4000 },

-  { 0x8700, 0x0ca5, 0x3000 },

-  { 0x8700, 0x0ca3, 0x2000 },

-  { 0x0700, 0x0ca2, 0x0000 },

-  { 0x0700, 0x0ca4, 0x0000 },

-  { 0x8700, 0x0ca7, 0x2000 },

-  { 0x0700, 0x0ca6, 0x0000 },

-  { 0x0700, 0x0ca8, 0x0000 },

-  { 0x8700, 0x0cae, 0x3000 },

-  { 0x8700, 0x0cac, 0x2000 },

-  { 0x0700, 0x0cab, 0x0000 },

-  { 0x0700, 0x0cad, 0x0000 },

-  { 0x8700, 0x0cb0, 0x2000 },

-  { 0x0700, 0x0caf, 0x0000 },

-  { 0x0700, 0x0cb1, 0x0000 },

-  { 0x8700, 0x0cbd, 0x4000 },

-  { 0x8700, 0x0cb7, 0x3000 },

-  { 0x8700, 0x0cb5, 0x2000 },

-  { 0x0700, 0x0cb3, 0x0000 },

-  { 0x0700, 0x0cb6, 0x0000 },

-  { 0x8700, 0x0cb9, 0x2000 },

-  { 0x0700, 0x0cb8, 0x0000 },

-  { 0x0c00, 0x0cbc, 0x0000 },

-  { 0x8a00, 0x0cc1, 0x3000 },

-  { 0x8c00, 0x0cbf, 0x2000 },

-  { 0x0a00, 0x0cbe, 0x0000 },

-  { 0x0a00, 0x0cc0, 0x0000 },

-  { 0x8a00, 0x0cc3, 0x2000 },

-  { 0x0a00, 0x0cc2, 0x0000 },

-  { 0x0a00, 0x0cc4, 0x0000 },

-  { 0x8d00, 0x0cea, 0x5000 },

-  { 0x8a00, 0x0cd6, 0x4000 },

-  { 0x8a00, 0x0ccb, 0x3000 },

-  { 0x8a00, 0x0cc8, 0x2000 },

-  { 0x0a00, 0x0cc7, 0x0000 },

-  { 0x0a00, 0x0cca, 0x0000 },

-  { 0x8c00, 0x0ccd, 0x2000 },

-  { 0x0c00, 0x0ccc, 0x0000 },

-  { 0x0a00, 0x0cd5, 0x0000 },

-  { 0x8d00, 0x0ce6, 0x3000 },

-  { 0x8700, 0x0ce0, 0x2000 },

-  { 0x0700, 0x0cde, 0x0000 },

-  { 0x0700, 0x0ce1, 0x0000 },

-  { 0x8d00, 0x0ce8, 0x2000 },

-  { 0x0d00, 0x0ce7, 0x0000 },

-  { 0x0d00, 0x0ce9, 0x0000 },

-  { 0x8700, 0x0d05, 0x4000 },

-  { 0x8d00, 0x0cee, 0x3000 },

-  { 0x8d00, 0x0cec, 0x2000 },

-  { 0x0d00, 0x0ceb, 0x0000 },

-  { 0x0d00, 0x0ced, 0x0000 },

-  { 0x8a00, 0x0d02, 0x2000 },

-  { 0x0d00, 0x0cef, 0x0000 },

-  { 0x0a00, 0x0d03, 0x0000 },

-  { 0x8700, 0x0d09, 0x3000 },

-  { 0x8700, 0x0d07, 0x2000 },

-  { 0x0700, 0x0d06, 0x0000 },

-  { 0x0700, 0x0d08, 0x0000 },

-  { 0x8700, 0x0d0b, 0x2000 },

-  { 0x0700, 0x0d0a, 0x0000 },

-  { 0x0700, 0x0d0c, 0x0000 },

-  { 0x8d00, 0x0d6c, 0x7000 },

-  { 0x8700, 0x0d30, 0x6000 },

-  { 0x8700, 0x0d1f, 0x5000 },

-  { 0x8700, 0x0d17, 0x4000 },

-  { 0x8700, 0x0d13, 0x3000 },

-  { 0x8700, 0x0d10, 0x2000 },

-  { 0x0700, 0x0d0f, 0x0000 },

-  { 0x0700, 0x0d12, 0x0000 },

-  { 0x8700, 0x0d15, 0x2000 },

-  { 0x0700, 0x0d14, 0x0000 },

-  { 0x0700, 0x0d16, 0x0000 },

-  { 0x8700, 0x0d1b, 0x3000 },

-  { 0x8700, 0x0d19, 0x2000 },

-  { 0x0700, 0x0d18, 0x0000 },

-  { 0x0700, 0x0d1a, 0x0000 },

-  { 0x8700, 0x0d1d, 0x2000 },

-  { 0x0700, 0x0d1c, 0x0000 },

-  { 0x0700, 0x0d1e, 0x0000 },

-  { 0x8700, 0x0d27, 0x4000 },

-  { 0x8700, 0x0d23, 0x3000 },

-  { 0x8700, 0x0d21, 0x2000 },

-  { 0x0700, 0x0d20, 0x0000 },

-  { 0x0700, 0x0d22, 0x0000 },

-  { 0x8700, 0x0d25, 0x2000 },

-  { 0x0700, 0x0d24, 0x0000 },

-  { 0x0700, 0x0d26, 0x0000 },

-  { 0x8700, 0x0d2c, 0x3000 },

-  { 0x8700, 0x0d2a, 0x2000 },

-  { 0x0700, 0x0d28, 0x0000 },

-  { 0x0700, 0x0d2b, 0x0000 },

-  { 0x8700, 0x0d2e, 0x2000 },

-  { 0x0700, 0x0d2d, 0x0000 },

-  { 0x0700, 0x0d2f, 0x0000 },

-  { 0x8a00, 0x0d46, 0x5000 },

-  { 0x8700, 0x0d38, 0x4000 },

-  { 0x8700, 0x0d34, 0x3000 },

-  { 0x8700, 0x0d32, 0x2000 },

-  { 0x0700, 0x0d31, 0x0000 },

-  { 0x0700, 0x0d33, 0x0000 },

-  { 0x8700, 0x0d36, 0x2000 },

-  { 0x0700, 0x0d35, 0x0000 },

-  { 0x0700, 0x0d37, 0x0000 },

-  { 0x8a00, 0x0d40, 0x3000 },

-  { 0x8a00, 0x0d3e, 0x2000 },

-  { 0x0700, 0x0d39, 0x0000 },

-  { 0x0a00, 0x0d3f, 0x0000 },

-  { 0x8c00, 0x0d42, 0x2000 },

-  { 0x0c00, 0x0d41, 0x0000 },

-  { 0x0c00, 0x0d43, 0x0000 },

-  { 0x8700, 0x0d60, 0x4000 },

-  { 0x8a00, 0x0d4b, 0x3000 },

-  { 0x8a00, 0x0d48, 0x2000 },

-  { 0x0a00, 0x0d47, 0x0000 },

-  { 0x0a00, 0x0d4a, 0x0000 },

-  { 0x8c00, 0x0d4d, 0x2000 },

-  { 0x0a00, 0x0d4c, 0x0000 },

-  { 0x0a00, 0x0d57, 0x0000 },

-  { 0x8d00, 0x0d68, 0x3000 },

-  { 0x8d00, 0x0d66, 0x2000 },

-  { 0x0700, 0x0d61, 0x0000 },

-  { 0x0d00, 0x0d67, 0x0000 },

-  { 0x8d00, 0x0d6a, 0x2000 },

-  { 0x0d00, 0x0d69, 0x0000 },

-  { 0x0d00, 0x0d6b, 0x0000 },

-  { 0x8700, 0x0da2, 0x6000 },

-  { 0x8700, 0x0d8f, 0x5000 },

-  { 0x8700, 0x0d87, 0x4000 },

-  { 0x8a00, 0x0d82, 0x3000 },

-  { 0x8d00, 0x0d6e, 0x2000 },

-  { 0x0d00, 0x0d6d, 0x0000 },

-  { 0x0d00, 0x0d6f, 0x0000 },

-  { 0x8700, 0x0d85, 0x2000 },

-  { 0x0a00, 0x0d83, 0x0000 },

-  { 0x0700, 0x0d86, 0x0000 },

-  { 0x8700, 0x0d8b, 0x3000 },

-  { 0x8700, 0x0d89, 0x2000 },

-  { 0x0700, 0x0d88, 0x0000 },

-  { 0x0700, 0x0d8a, 0x0000 },

-  { 0x8700, 0x0d8d, 0x2000 },

-  { 0x0700, 0x0d8c, 0x0000 },

-  { 0x0700, 0x0d8e, 0x0000 },

-  { 0x8700, 0x0d9a, 0x4000 },

-  { 0x8700, 0x0d93, 0x3000 },

-  { 0x8700, 0x0d91, 0x2000 },

-  { 0x0700, 0x0d90, 0x0000 },

-  { 0x0700, 0x0d92, 0x0000 },

-  { 0x8700, 0x0d95, 0x2000 },

-  { 0x0700, 0x0d94, 0x0000 },

-  { 0x0700, 0x0d96, 0x0000 },

-  { 0x8700, 0x0d9e, 0x3000 },

-  { 0x8700, 0x0d9c, 0x2000 },

-  { 0x0700, 0x0d9b, 0x0000 },

-  { 0x0700, 0x0d9d, 0x0000 },

-  { 0x8700, 0x0da0, 0x2000 },

-  { 0x0700, 0x0d9f, 0x0000 },

-  { 0x0700, 0x0da1, 0x0000 },

-  { 0x8700, 0x0db3, 0x5000 },

-  { 0x8700, 0x0daa, 0x4000 },

-  { 0x8700, 0x0da6, 0x3000 },

-  { 0x8700, 0x0da4, 0x2000 },

-  { 0x0700, 0x0da3, 0x0000 },

-  { 0x0700, 0x0da5, 0x0000 },

-  { 0x8700, 0x0da8, 0x2000 },

-  { 0x0700, 0x0da7, 0x0000 },

-  { 0x0700, 0x0da9, 0x0000 },

-  { 0x8700, 0x0dae, 0x3000 },

-  { 0x8700, 0x0dac, 0x2000 },

-  { 0x0700, 0x0dab, 0x0000 },

-  { 0x0700, 0x0dad, 0x0000 },

-  { 0x8700, 0x0db0, 0x2000 },

-  { 0x0700, 0x0daf, 0x0000 },

-  { 0x0700, 0x0db1, 0x0000 },

-  { 0x8700, 0x0dbb, 0x4000 },

-  { 0x8700, 0x0db7, 0x3000 },

-  { 0x8700, 0x0db5, 0x2000 },

-  { 0x0700, 0x0db4, 0x0000 },

-  { 0x0700, 0x0db6, 0x0000 },

-  { 0x8700, 0x0db9, 0x2000 },

-  { 0x0700, 0x0db8, 0x0000 },

-  { 0x0700, 0x0dba, 0x0000 },

-  { 0x8700, 0x0dc2, 0x3000 },

-  { 0x8700, 0x0dc0, 0x2000 },

-  { 0x0700, 0x0dbd, 0x0000 },

-  { 0x0700, 0x0dc1, 0x0000 },

-  { 0x8700, 0x0dc4, 0x2000 },

-  { 0x0700, 0x0dc3, 0x0000 },

-  { 0x0700, 0x0dc5, 0x0000 },

-  { 0x8700, 0x0f55, 0x9000 },

-  { 0x8700, 0x0ea5, 0x8000 },

-  { 0x8700, 0x0e2d, 0x7000 },

-  { 0x8700, 0x0e0d, 0x6000 },

-  { 0x8a00, 0x0ddf, 0x5000 },

-  { 0x8c00, 0x0dd6, 0x4000 },

-  { 0x8a00, 0x0dd1, 0x3000 },

-  { 0x8a00, 0x0dcf, 0x2000 },

-  { 0x0c00, 0x0dca, 0x0000 },

-  { 0x0a00, 0x0dd0, 0x0000 },

-  { 0x8c00, 0x0dd3, 0x2000 },

-  { 0x0c00, 0x0dd2, 0x0000 },

-  { 0x0c00, 0x0dd4, 0x0000 },

-  { 0x8a00, 0x0ddb, 0x3000 },

-  { 0x8a00, 0x0dd9, 0x2000 },

-  { 0x0a00, 0x0dd8, 0x0000 },

-  { 0x0a00, 0x0dda, 0x0000 },

-  { 0x8a00, 0x0ddd, 0x2000 },

-  { 0x0a00, 0x0ddc, 0x0000 },

-  { 0x0a00, 0x0dde, 0x0000 },

-  { 0x8700, 0x0e05, 0x4000 },

-  { 0x8700, 0x0e01, 0x3000 },

-  { 0x8a00, 0x0df3, 0x2000 },

-  { 0x0a00, 0x0df2, 0x0000 },

-  { 0x1500, 0x0df4, 0x0000 },

-  { 0x8700, 0x0e03, 0x2000 },

-  { 0x0700, 0x0e02, 0x0000 },

-  { 0x0700, 0x0e04, 0x0000 },

-  { 0x8700, 0x0e09, 0x3000 },

-  { 0x8700, 0x0e07, 0x2000 },

-  { 0x0700, 0x0e06, 0x0000 },

-  { 0x0700, 0x0e08, 0x0000 },

-  { 0x8700, 0x0e0b, 0x2000 },

-  { 0x0700, 0x0e0a, 0x0000 },

-  { 0x0700, 0x0e0c, 0x0000 },

-  { 0x8700, 0x0e1d, 0x5000 },

-  { 0x8700, 0x0e15, 0x4000 },

-  { 0x8700, 0x0e11, 0x3000 },

-  { 0x8700, 0x0e0f, 0x2000 },

-  { 0x0700, 0x0e0e, 0x0000 },

-  { 0x0700, 0x0e10, 0x0000 },

-  { 0x8700, 0x0e13, 0x2000 },

-  { 0x0700, 0x0e12, 0x0000 },

-  { 0x0700, 0x0e14, 0x0000 },

-  { 0x8700, 0x0e19, 0x3000 },

-  { 0x8700, 0x0e17, 0x2000 },

-  { 0x0700, 0x0e16, 0x0000 },

-  { 0x0700, 0x0e18, 0x0000 },

-  { 0x8700, 0x0e1b, 0x2000 },

-  { 0x0700, 0x0e1a, 0x0000 },

-  { 0x0700, 0x0e1c, 0x0000 },

-  { 0x8700, 0x0e25, 0x4000 },

-  { 0x8700, 0x0e21, 0x3000 },

-  { 0x8700, 0x0e1f, 0x2000 },

-  { 0x0700, 0x0e1e, 0x0000 },

-  { 0x0700, 0x0e20, 0x0000 },

-  { 0x8700, 0x0e23, 0x2000 },

-  { 0x0700, 0x0e22, 0x0000 },

-  { 0x0700, 0x0e24, 0x0000 },

-  { 0x8700, 0x0e29, 0x3000 },

-  { 0x8700, 0x0e27, 0x2000 },

-  { 0x0700, 0x0e26, 0x0000 },

-  { 0x0700, 0x0e28, 0x0000 },

-  { 0x8700, 0x0e2b, 0x2000 },

-  { 0x0700, 0x0e2a, 0x0000 },

-  { 0x0700, 0x0e2c, 0x0000 },

-  { 0x8d00, 0x0e51, 0x6000 },

-  { 0x8700, 0x0e41, 0x5000 },

-  { 0x8c00, 0x0e35, 0x4000 },

-  { 0x8c00, 0x0e31, 0x3000 },

-  { 0x8700, 0x0e2f, 0x2000 },

-  { 0x0700, 0x0e2e, 0x0000 },

-  { 0x0700, 0x0e30, 0x0000 },

-  { 0x8700, 0x0e33, 0x2000 },

-  { 0x0700, 0x0e32, 0x0000 },

-  { 0x0c00, 0x0e34, 0x0000 },

-  { 0x8c00, 0x0e39, 0x3000 },

-  { 0x8c00, 0x0e37, 0x2000 },

-  { 0x0c00, 0x0e36, 0x0000 },

-  { 0x0c00, 0x0e38, 0x0000 },

-  { 0x9700, 0x0e3f, 0x2000 },

-  { 0x0c00, 0x0e3a, 0x0000 },

-  { 0x0700, 0x0e40, 0x0000 },

-  { 0x8c00, 0x0e49, 0x4000 },

-  { 0x8700, 0x0e45, 0x3000 },

-  { 0x8700, 0x0e43, 0x2000 },

-  { 0x0700, 0x0e42, 0x0000 },

-  { 0x0700, 0x0e44, 0x0000 },

-  { 0x8c00, 0x0e47, 0x2000 },

-  { 0x0600, 0x0e46, 0x0000 },

-  { 0x0c00, 0x0e48, 0x0000 },

-  { 0x8c00, 0x0e4d, 0x3000 },

-  { 0x8c00, 0x0e4b, 0x2000 },

-  { 0x0c00, 0x0e4a, 0x0000 },

-  { 0x0c00, 0x0e4c, 0x0000 },

-  { 0x9500, 0x0e4f, 0x2000 },

-  { 0x0c00, 0x0e4e, 0x0000 },

-  { 0x0d00, 0x0e50, 0x0000 },

-  { 0x8700, 0x0e8a, 0x5000 },

-  { 0x8d00, 0x0e59, 0x4000 },

-  { 0x8d00, 0x0e55, 0x3000 },

-  { 0x8d00, 0x0e53, 0x2000 },

-  { 0x0d00, 0x0e52, 0x0000 },

-  { 0x0d00, 0x0e54, 0x0000 },

-  { 0x8d00, 0x0e57, 0x2000 },

-  { 0x0d00, 0x0e56, 0x0000 },

-  { 0x0d00, 0x0e58, 0x0000 },

-  { 0x8700, 0x0e82, 0x3000 },

-  { 0x9500, 0x0e5b, 0x2000 },

-  { 0x1500, 0x0e5a, 0x0000 },

-  { 0x0700, 0x0e81, 0x0000 },

-  { 0x8700, 0x0e87, 0x2000 },

-  { 0x0700, 0x0e84, 0x0000 },

-  { 0x0700, 0x0e88, 0x0000 },

-  { 0x8700, 0x0e9b, 0x4000 },

-  { 0x8700, 0x0e96, 0x3000 },

-  { 0x8700, 0x0e94, 0x2000 },

-  { 0x0700, 0x0e8d, 0x0000 },

-  { 0x0700, 0x0e95, 0x0000 },

-  { 0x8700, 0x0e99, 0x2000 },

-  { 0x0700, 0x0e97, 0x0000 },

-  { 0x0700, 0x0e9a, 0x0000 },

-  { 0x8700, 0x0e9f, 0x3000 },

-  { 0x8700, 0x0e9d, 0x2000 },

-  { 0x0700, 0x0e9c, 0x0000 },

-  { 0x0700, 0x0e9e, 0x0000 },

-  { 0x8700, 0x0ea2, 0x2000 },

-  { 0x0700, 0x0ea1, 0x0000 },

-  { 0x0700, 0x0ea3, 0x0000 },

-  { 0x9a00, 0x0f14, 0x7000 },

-  { 0x8d00, 0x0ed0, 0x6000 },

-  { 0x8c00, 0x0eb9, 0x5000 },

-  { 0x8c00, 0x0eb1, 0x4000 },

-  { 0x8700, 0x0ead, 0x3000 },

-  { 0x8700, 0x0eaa, 0x2000 },

-  { 0x0700, 0x0ea7, 0x0000 },

-  { 0x0700, 0x0eab, 0x0000 },

-  { 0x8700, 0x0eaf, 0x2000 },

-  { 0x0700, 0x0eae, 0x0000 },

-  { 0x0700, 0x0eb0, 0x0000 },

-  { 0x8c00, 0x0eb5, 0x3000 },

-  { 0x8700, 0x0eb3, 0x2000 },

-  { 0x0700, 0x0eb2, 0x0000 },

-  { 0x0c00, 0x0eb4, 0x0000 },

-  { 0x8c00, 0x0eb7, 0x2000 },

-  { 0x0c00, 0x0eb6, 0x0000 },

-  { 0x0c00, 0x0eb8, 0x0000 },

-  { 0x8700, 0x0ec4, 0x4000 },

-  { 0x8700, 0x0ec0, 0x3000 },

-  { 0x8c00, 0x0ebc, 0x2000 },

-  { 0x0c00, 0x0ebb, 0x0000 },

-  { 0x0700, 0x0ebd, 0x0000 },

-  { 0x8700, 0x0ec2, 0x2000 },

-  { 0x0700, 0x0ec1, 0x0000 },

-  { 0x0700, 0x0ec3, 0x0000 },

-  { 0x8c00, 0x0eca, 0x3000 },

-  { 0x8c00, 0x0ec8, 0x2000 },

-  { 0x0600, 0x0ec6, 0x0000 },

-  { 0x0c00, 0x0ec9, 0x0000 },

-  { 0x8c00, 0x0ecc, 0x2000 },

-  { 0x0c00, 0x0ecb, 0x0000 },

-  { 0x0c00, 0x0ecd, 0x0000 },

-  { 0x9500, 0x0f04, 0x5000 },

-  { 0x8d00, 0x0ed8, 0x4000 },

-  { 0x8d00, 0x0ed4, 0x3000 },

-  { 0x8d00, 0x0ed2, 0x2000 },

-  { 0x0d00, 0x0ed1, 0x0000 },

-  { 0x0d00, 0x0ed3, 0x0000 },

-  { 0x8d00, 0x0ed6, 0x2000 },

-  { 0x0d00, 0x0ed5, 0x0000 },

-  { 0x0d00, 0x0ed7, 0x0000 },

-  { 0x8700, 0x0f00, 0x3000 },

-  { 0x8700, 0x0edc, 0x2000 },

-  { 0x0d00, 0x0ed9, 0x0000 },

-  { 0x0700, 0x0edd, 0x0000 },

-  { 0x9a00, 0x0f02, 0x2000 },

-  { 0x1a00, 0x0f01, 0x0000 },

-  { 0x1a00, 0x0f03, 0x0000 },

-  { 0x9500, 0x0f0c, 0x4000 },

-  { 0x9500, 0x0f08, 0x3000 },

-  { 0x9500, 0x0f06, 0x2000 },

-  { 0x1500, 0x0f05, 0x0000 },

-  { 0x1500, 0x0f07, 0x0000 },

-  { 0x9500, 0x0f0a, 0x2000 },

-  { 0x1500, 0x0f09, 0x0000 },

-  { 0x1500, 0x0f0b, 0x0000 },

-  { 0x9500, 0x0f10, 0x3000 },

-  { 0x9500, 0x0f0e, 0x2000 },

-  { 0x1500, 0x0f0d, 0x0000 },

-  { 0x1500, 0x0f0f, 0x0000 },

-  { 0x9500, 0x0f12, 0x2000 },

-  { 0x1500, 0x0f11, 0x0000 },

-  { 0x1a00, 0x0f13, 0x0000 },

-  { 0x9a00, 0x0f34, 0x6000 },

-  { 0x8d00, 0x0f24, 0x5000 },

-  { 0x9a00, 0x0f1c, 0x4000 },

-  { 0x8c00, 0x0f18, 0x3000 },

-  { 0x9a00, 0x0f16, 0x2000 },

-  { 0x1a00, 0x0f15, 0x0000 },

-  { 0x1a00, 0x0f17, 0x0000 },

-  { 0x9a00, 0x0f1a, 0x2000 },

-  { 0x0c00, 0x0f19, 0x0000 },

-  { 0x1a00, 0x0f1b, 0x0000 },

-  { 0x8d00, 0x0f20, 0x3000 },

-  { 0x9a00, 0x0f1e, 0x2000 },

-  { 0x1a00, 0x0f1d, 0x0000 },

-  { 0x1a00, 0x0f1f, 0x0000 },

-  { 0x8d00, 0x0f22, 0x2000 },

-  { 0x0d00, 0x0f21, 0x0000 },

-  { 0x0d00, 0x0f23, 0x0000 },

-  { 0x8f00, 0x0f2c, 0x4000 },

-  { 0x8d00, 0x0f28, 0x3000 },

-  { 0x8d00, 0x0f26, 0x2000 },

-  { 0x0d00, 0x0f25, 0x0000 },

-  { 0x0d00, 0x0f27, 0x0000 },

-  { 0x8f00, 0x0f2a, 0x2000 },

-  { 0x0d00, 0x0f29, 0x0000 },

-  { 0x0f00, 0x0f2b, 0x0000 },

-  { 0x8f00, 0x0f30, 0x3000 },

-  { 0x8f00, 0x0f2e, 0x2000 },

-  { 0x0f00, 0x0f2d, 0x0000 },

-  { 0x0f00, 0x0f2f, 0x0000 },

-  { 0x8f00, 0x0f32, 0x2000 },

-  { 0x0f00, 0x0f31, 0x0000 },

-  { 0x0f00, 0x0f33, 0x0000 },

-  { 0x8700, 0x0f44, 0x5000 },

-  { 0x9600, 0x0f3c, 0x4000 },

-  { 0x9a00, 0x0f38, 0x3000 },

-  { 0x9a00, 0x0f36, 0x2000 },

-  { 0x0c00, 0x0f35, 0x0000 },

-  { 0x0c00, 0x0f37, 0x0000 },

-  { 0x9600, 0x0f3a, 0x2000 },

-  { 0x0c00, 0x0f39, 0x0000 },

-  { 0x1200, 0x0f3b, 0x0000 },

-  { 0x8700, 0x0f40, 0x3000 },

-  { 0x8a00, 0x0f3e, 0x2000 },

-  { 0x1200, 0x0f3d, 0x0000 },

-  { 0x0a00, 0x0f3f, 0x0000 },

-  { 0x8700, 0x0f42, 0x2000 },

-  { 0x0700, 0x0f41, 0x0000 },

-  { 0x0700, 0x0f43, 0x0000 },

-  { 0x8700, 0x0f4d, 0x4000 },

-  { 0x8700, 0x0f49, 0x3000 },

-  { 0x8700, 0x0f46, 0x2000 },

-  { 0x0700, 0x0f45, 0x0000 },

-  { 0x0700, 0x0f47, 0x0000 },

-  { 0x8700, 0x0f4b, 0x2000 },

-  { 0x0700, 0x0f4a, 0x0000 },

-  { 0x0700, 0x0f4c, 0x0000 },

-  { 0x8700, 0x0f51, 0x3000 },

-  { 0x8700, 0x0f4f, 0x2000 },

-  { 0x0700, 0x0f4e, 0x0000 },

-  { 0x0700, 0x0f50, 0x0000 },

-  { 0x8700, 0x0f53, 0x2000 },

-  { 0x0700, 0x0f52, 0x0000 },

-  { 0x0700, 0x0f54, 0x0000 },

-  { 0x8700, 0x1013, 0x8000 },

-  { 0x8c00, 0x0fa0, 0x7000 },

-  { 0x8c00, 0x0f7b, 0x6000 },

-  { 0x8700, 0x0f65, 0x5000 },

-  { 0x8700, 0x0f5d, 0x4000 },

-  { 0x8700, 0x0f59, 0x3000 },

-  { 0x8700, 0x0f57, 0x2000 },

-  { 0x0700, 0x0f56, 0x0000 },

-  { 0x0700, 0x0f58, 0x0000 },

-  { 0x8700, 0x0f5b, 0x2000 },

-  { 0x0700, 0x0f5a, 0x0000 },

-  { 0x0700, 0x0f5c, 0x0000 },

-  { 0x8700, 0x0f61, 0x3000 },

-  { 0x8700, 0x0f5f, 0x2000 },

-  { 0x0700, 0x0f5e, 0x0000 },

-  { 0x0700, 0x0f60, 0x0000 },

-  { 0x8700, 0x0f63, 0x2000 },

-  { 0x0700, 0x0f62, 0x0000 },

-  { 0x0700, 0x0f64, 0x0000 },

-  { 0x8c00, 0x0f73, 0x4000 },

-  { 0x8700, 0x0f69, 0x3000 },

-  { 0x8700, 0x0f67, 0x2000 },

-  { 0x0700, 0x0f66, 0x0000 },

-  { 0x0700, 0x0f68, 0x0000 },

-  { 0x8c00, 0x0f71, 0x2000 },

-  { 0x0700, 0x0f6a, 0x0000 },

-  { 0x0c00, 0x0f72, 0x0000 },

-  { 0x8c00, 0x0f77, 0x3000 },

-  { 0x8c00, 0x0f75, 0x2000 },

-  { 0x0c00, 0x0f74, 0x0000 },

-  { 0x0c00, 0x0f76, 0x0000 },

-  { 0x8c00, 0x0f79, 0x2000 },

-  { 0x0c00, 0x0f78, 0x0000 },

-  { 0x0c00, 0x0f7a, 0x0000 },

-  { 0x8700, 0x0f8b, 0x5000 },

-  { 0x8c00, 0x0f83, 0x4000 },

-  { 0x8a00, 0x0f7f, 0x3000 },

-  { 0x8c00, 0x0f7d, 0x2000 },

-  { 0x0c00, 0x0f7c, 0x0000 },

-  { 0x0c00, 0x0f7e, 0x0000 },

-  { 0x8c00, 0x0f81, 0x2000 },

-  { 0x0c00, 0x0f80, 0x0000 },

-  { 0x0c00, 0x0f82, 0x0000 },

-  { 0x8c00, 0x0f87, 0x3000 },

-  { 0x9500, 0x0f85, 0x2000 },

-  { 0x0c00, 0x0f84, 0x0000 },

-  { 0x0c00, 0x0f86, 0x0000 },

-  { 0x8700, 0x0f89, 0x2000 },

-  { 0x0700, 0x0f88, 0x0000 },

-  { 0x0700, 0x0f8a, 0x0000 },

-  { 0x8c00, 0x0f97, 0x4000 },

-  { 0x8c00, 0x0f93, 0x3000 },

-  { 0x8c00, 0x0f91, 0x2000 },

-  { 0x0c00, 0x0f90, 0x0000 },

-  { 0x0c00, 0x0f92, 0x0000 },

-  { 0x8c00, 0x0f95, 0x2000 },

-  { 0x0c00, 0x0f94, 0x0000 },

-  { 0x0c00, 0x0f96, 0x0000 },

-  { 0x8c00, 0x0f9c, 0x3000 },

-  { 0x8c00, 0x0f9a, 0x2000 },

-  { 0x0c00, 0x0f99, 0x0000 },

-  { 0x0c00, 0x0f9b, 0x0000 },

-  { 0x8c00, 0x0f9e, 0x2000 },

-  { 0x0c00, 0x0f9d, 0x0000 },

-  { 0x0c00, 0x0f9f, 0x0000 },

-  { 0x9a00, 0x0fc1, 0x6000 },

-  { 0x8c00, 0x0fb0, 0x5000 },

-  { 0x8c00, 0x0fa8, 0x4000 },

-  { 0x8c00, 0x0fa4, 0x3000 },

-  { 0x8c00, 0x0fa2, 0x2000 },

-  { 0x0c00, 0x0fa1, 0x0000 },

-  { 0x0c00, 0x0fa3, 0x0000 },

-  { 0x8c00, 0x0fa6, 0x2000 },

-  { 0x0c00, 0x0fa5, 0x0000 },

-  { 0x0c00, 0x0fa7, 0x0000 },

-  { 0x8c00, 0x0fac, 0x3000 },

-  { 0x8c00, 0x0faa, 0x2000 },

-  { 0x0c00, 0x0fa9, 0x0000 },

-  { 0x0c00, 0x0fab, 0x0000 },

-  { 0x8c00, 0x0fae, 0x2000 },

-  { 0x0c00, 0x0fad, 0x0000 },

-  { 0x0c00, 0x0faf, 0x0000 },

-  { 0x8c00, 0x0fb8, 0x4000 },

-  { 0x8c00, 0x0fb4, 0x3000 },

-  { 0x8c00, 0x0fb2, 0x2000 },

-  { 0x0c00, 0x0fb1, 0x0000 },

-  { 0x0c00, 0x0fb3, 0x0000 },

-  { 0x8c00, 0x0fb6, 0x2000 },

-  { 0x0c00, 0x0fb5, 0x0000 },

-  { 0x0c00, 0x0fb7, 0x0000 },

-  { 0x8c00, 0x0fbc, 0x3000 },

-  { 0x8c00, 0x0fba, 0x2000 },

-  { 0x0c00, 0x0fb9, 0x0000 },

-  { 0x0c00, 0x0fbb, 0x0000 },

-  { 0x9a00, 0x0fbf, 0x2000 },

-  { 0x1a00, 0x0fbe, 0x0000 },

-  { 0x1a00, 0x0fc0, 0x0000 },

-  { 0x8700, 0x1003, 0x5000 },

-  { 0x9a00, 0x0fc9, 0x4000 },

-  { 0x9a00, 0x0fc5, 0x3000 },

-  { 0x9a00, 0x0fc3, 0x2000 },

-  { 0x1a00, 0x0fc2, 0x0000 },

-  { 0x1a00, 0x0fc4, 0x0000 },

-  { 0x9a00, 0x0fc7, 0x2000 },

-  { 0x0c00, 0x0fc6, 0x0000 },

-  { 0x1a00, 0x0fc8, 0x0000 },

-  { 0x9a00, 0x0fcf, 0x3000 },

-  { 0x9a00, 0x0fcb, 0x2000 },

-  { 0x1a00, 0x0fca, 0x0000 },

-  { 0x1a00, 0x0fcc, 0x0000 },

-  { 0x8700, 0x1001, 0x2000 },

-  { 0x0700, 0x1000, 0x0000 },

-  { 0x0700, 0x1002, 0x0000 },

-  { 0x8700, 0x100b, 0x4000 },

-  { 0x8700, 0x1007, 0x3000 },

-  { 0x8700, 0x1005, 0x2000 },

-  { 0x0700, 0x1004, 0x0000 },

-  { 0x0700, 0x1006, 0x0000 },

-  { 0x8700, 0x1009, 0x2000 },

-  { 0x0700, 0x1008, 0x0000 },

-  { 0x0700, 0x100a, 0x0000 },

-  { 0x8700, 0x100f, 0x3000 },

-  { 0x8700, 0x100d, 0x2000 },

-  { 0x0700, 0x100c, 0x0000 },

-  { 0x0700, 0x100e, 0x0000 },

-  { 0x8700, 0x1011, 0x2000 },

-  { 0x0700, 0x1010, 0x0000 },

-  { 0x0700, 0x1012, 0x0000 },

-  { 0x8900, 0x10a5, 0x7000 },

-  { 0x8c00, 0x1039, 0x6000 },

-  { 0x8700, 0x1024, 0x5000 },

-  { 0x8700, 0x101b, 0x4000 },

-  { 0x8700, 0x1017, 0x3000 },

-  { 0x8700, 0x1015, 0x2000 },

-  { 0x0700, 0x1014, 0x0000 },

-  { 0x0700, 0x1016, 0x0000 },

-  { 0x8700, 0x1019, 0x2000 },

-  { 0x0700, 0x1018, 0x0000 },

-  { 0x0700, 0x101a, 0x0000 },

-  { 0x8700, 0x101f, 0x3000 },

-  { 0x8700, 0x101d, 0x2000 },

-  { 0x0700, 0x101c, 0x0000 },

-  { 0x0700, 0x101e, 0x0000 },

-  { 0x8700, 0x1021, 0x2000 },

-  { 0x0700, 0x1020, 0x0000 },

-  { 0x0700, 0x1023, 0x0000 },

-  { 0x8c00, 0x102e, 0x4000 },

-  { 0x8700, 0x1029, 0x3000 },

-  { 0x8700, 0x1026, 0x2000 },

-  { 0x0700, 0x1025, 0x0000 },

-  { 0x0700, 0x1027, 0x0000 },

-  { 0x8a00, 0x102c, 0x2000 },

-  { 0x0700, 0x102a, 0x0000 },

-  { 0x0c00, 0x102d, 0x0000 },

-  { 0x8c00, 0x1032, 0x3000 },

-  { 0x8c00, 0x1030, 0x2000 },

-  { 0x0c00, 0x102f, 0x0000 },

-  { 0x0a00, 0x1031, 0x0000 },

-  { 0x8c00, 0x1037, 0x2000 },

-  { 0x0c00, 0x1036, 0x0000 },

-  { 0x0a00, 0x1038, 0x0000 },

-  { 0x9500, 0x104f, 0x5000 },

-  { 0x8d00, 0x1047, 0x4000 },

-  { 0x8d00, 0x1043, 0x3000 },

-  { 0x8d00, 0x1041, 0x2000 },

-  { 0x0d00, 0x1040, 0x0000 },

-  { 0x0d00, 0x1042, 0x0000 },

-  { 0x8d00, 0x1045, 0x2000 },

-  { 0x0d00, 0x1044, 0x0000 },

-  { 0x0d00, 0x1046, 0x0000 },

-  { 0x9500, 0x104b, 0x3000 },

-  { 0x8d00, 0x1049, 0x2000 },

-  { 0x0d00, 0x1048, 0x0000 },

-  { 0x1500, 0x104a, 0x0000 },

-  { 0x9500, 0x104d, 0x2000 },

-  { 0x1500, 0x104c, 0x0000 },

-  { 0x1500, 0x104e, 0x0000 },

-  { 0x8a00, 0x1057, 0x4000 },

-  { 0x8700, 0x1053, 0x3000 },

-  { 0x8700, 0x1051, 0x2000 },

-  { 0x0700, 0x1050, 0x0000 },

-  { 0x0700, 0x1052, 0x0000 },

-  { 0x8700, 0x1055, 0x2000 },

-  { 0x0700, 0x1054, 0x0000 },

-  { 0x0a00, 0x1056, 0x0000 },

-  { 0x8900, 0x10a1, 0x3000 },

-  { 0x8c00, 0x1059, 0x2000 },

-  { 0x0c00, 0x1058, 0x0000 },

-  { 0x0900, 0x10a0, 0x0000 },

-  { 0x8900, 0x10a3, 0x2000 },

-  { 0x0900, 0x10a2, 0x0000 },

-  { 0x0900, 0x10a4, 0x0000 },

-  { 0x8900, 0x10c5, 0x6000 },

-  { 0x8900, 0x10b5, 0x5000 },

-  { 0x8900, 0x10ad, 0x4000 },

-  { 0x8900, 0x10a9, 0x3000 },

-  { 0x8900, 0x10a7, 0x2000 },

-  { 0x0900, 0x10a6, 0x0000 },

-  { 0x0900, 0x10a8, 0x0000 },

-  { 0x8900, 0x10ab, 0x2000 },

-  { 0x0900, 0x10aa, 0x0000 },

-  { 0x0900, 0x10ac, 0x0000 },

-  { 0x8900, 0x10b1, 0x3000 },

-  { 0x8900, 0x10af, 0x2000 },

-  { 0x0900, 0x10ae, 0x0000 },

-  { 0x0900, 0x10b0, 0x0000 },

-  { 0x8900, 0x10b3, 0x2000 },

-  { 0x0900, 0x10b2, 0x0000 },

-  { 0x0900, 0x10b4, 0x0000 },

-  { 0x8900, 0x10bd, 0x4000 },

-  { 0x8900, 0x10b9, 0x3000 },

-  { 0x8900, 0x10b7, 0x2000 },

-  { 0x0900, 0x10b6, 0x0000 },

-  { 0x0900, 0x10b8, 0x0000 },

-  { 0x8900, 0x10bb, 0x2000 },

-  { 0x0900, 0x10ba, 0x0000 },

-  { 0x0900, 0x10bc, 0x0000 },

-  { 0x8900, 0x10c1, 0x3000 },

-  { 0x8900, 0x10bf, 0x2000 },

-  { 0x0900, 0x10be, 0x0000 },

-  { 0x0900, 0x10c0, 0x0000 },

-  { 0x8900, 0x10c3, 0x2000 },

-  { 0x0900, 0x10c2, 0x0000 },

-  { 0x0900, 0x10c4, 0x0000 },

-  { 0x8700, 0x10df, 0x5000 },

-  { 0x8700, 0x10d7, 0x4000 },

-  { 0x8700, 0x10d3, 0x3000 },

-  { 0x8700, 0x10d1, 0x2000 },

-  { 0x0700, 0x10d0, 0x0000 },

-  { 0x0700, 0x10d2, 0x0000 },

-  { 0x8700, 0x10d5, 0x2000 },

-  { 0x0700, 0x10d4, 0x0000 },

-  { 0x0700, 0x10d6, 0x0000 },

-  { 0x8700, 0x10db, 0x3000 },

-  { 0x8700, 0x10d9, 0x2000 },

-  { 0x0700, 0x10d8, 0x0000 },

-  { 0x0700, 0x10da, 0x0000 },

-  { 0x8700, 0x10dd, 0x2000 },

-  { 0x0700, 0x10dc, 0x0000 },

-  { 0x0700, 0x10de, 0x0000 },

-  { 0x8700, 0x10e7, 0x4000 },

-  { 0x8700, 0x10e3, 0x3000 },

-  { 0x8700, 0x10e1, 0x2000 },

-  { 0x0700, 0x10e0, 0x0000 },

-  { 0x0700, 0x10e2, 0x0000 },

-  { 0x8700, 0x10e5, 0x2000 },

-  { 0x0700, 0x10e4, 0x0000 },

-  { 0x0700, 0x10e6, 0x0000 },

-  { 0x8700, 0x10eb, 0x3000 },

-  { 0x8700, 0x10e9, 0x2000 },

-  { 0x0700, 0x10e8, 0x0000 },

-  { 0x0700, 0x10ea, 0x0000 },

-  { 0x8700, 0x10ed, 0x2000 },

-  { 0x0700, 0x10ec, 0x0000 },

-  { 0x0700, 0x10ee, 0x0000 },

-  { 0x8700, 0x1322, 0xa000 },

-  { 0x8700, 0x1205, 0x9000 },

-  { 0x8700, 0x117a, 0x8000 },

-  { 0x8700, 0x1135, 0x7000 },

-  { 0x8700, 0x1115, 0x6000 },

-  { 0x8700, 0x1105, 0x5000 },

-  { 0x8700, 0x10f7, 0x4000 },

-  { 0x8700, 0x10f3, 0x3000 },

-  { 0x8700, 0x10f1, 0x2000 },

-  { 0x0700, 0x10f0, 0x0000 },

-  { 0x0700, 0x10f2, 0x0000 },

-  { 0x8700, 0x10f5, 0x2000 },

-  { 0x0700, 0x10f4, 0x0000 },

-  { 0x0700, 0x10f6, 0x0000 },

-  { 0x8700, 0x1101, 0x3000 },

-  { 0x9500, 0x10fb, 0x2000 },

-  { 0x0700, 0x10f8, 0x0000 },

-  { 0x0700, 0x1100, 0x0000 },

-  { 0x8700, 0x1103, 0x2000 },

-  { 0x0700, 0x1102, 0x0000 },

-  { 0x0700, 0x1104, 0x0000 },

-  { 0x8700, 0x110d, 0x4000 },

-  { 0x8700, 0x1109, 0x3000 },

-  { 0x8700, 0x1107, 0x2000 },

-  { 0x0700, 0x1106, 0x0000 },

-  { 0x0700, 0x1108, 0x0000 },

-  { 0x8700, 0x110b, 0x2000 },

-  { 0x0700, 0x110a, 0x0000 },

-  { 0x0700, 0x110c, 0x0000 },

-  { 0x8700, 0x1111, 0x3000 },

-  { 0x8700, 0x110f, 0x2000 },

-  { 0x0700, 0x110e, 0x0000 },

-  { 0x0700, 0x1110, 0x0000 },

-  { 0x8700, 0x1113, 0x2000 },

-  { 0x0700, 0x1112, 0x0000 },

-  { 0x0700, 0x1114, 0x0000 },

-  { 0x8700, 0x1125, 0x5000 },

-  { 0x8700, 0x111d, 0x4000 },

-  { 0x8700, 0x1119, 0x3000 },

-  { 0x8700, 0x1117, 0x2000 },

-  { 0x0700, 0x1116, 0x0000 },

-  { 0x0700, 0x1118, 0x0000 },

-  { 0x8700, 0x111b, 0x2000 },

-  { 0x0700, 0x111a, 0x0000 },

-  { 0x0700, 0x111c, 0x0000 },

-  { 0x8700, 0x1121, 0x3000 },

-  { 0x8700, 0x111f, 0x2000 },

-  { 0x0700, 0x111e, 0x0000 },

-  { 0x0700, 0x1120, 0x0000 },

-  { 0x8700, 0x1123, 0x2000 },

-  { 0x0700, 0x1122, 0x0000 },

-  { 0x0700, 0x1124, 0x0000 },

-  { 0x8700, 0x112d, 0x4000 },

-  { 0x8700, 0x1129, 0x3000 },

-  { 0x8700, 0x1127, 0x2000 },

-  { 0x0700, 0x1126, 0x0000 },

-  { 0x0700, 0x1128, 0x0000 },

-  { 0x8700, 0x112b, 0x2000 },

-  { 0x0700, 0x112a, 0x0000 },

-  { 0x0700, 0x112c, 0x0000 },

-  { 0x8700, 0x1131, 0x3000 },

-  { 0x8700, 0x112f, 0x2000 },

-  { 0x0700, 0x112e, 0x0000 },

-  { 0x0700, 0x1130, 0x0000 },

-  { 0x8700, 0x1133, 0x2000 },

-  { 0x0700, 0x1132, 0x0000 },

-  { 0x0700, 0x1134, 0x0000 },

-  { 0x8700, 0x1155, 0x6000 },

-  { 0x8700, 0x1145, 0x5000 },

-  { 0x8700, 0x113d, 0x4000 },

-  { 0x8700, 0x1139, 0x3000 },

-  { 0x8700, 0x1137, 0x2000 },

-  { 0x0700, 0x1136, 0x0000 },

-  { 0x0700, 0x1138, 0x0000 },

-  { 0x8700, 0x113b, 0x2000 },

-  { 0x0700, 0x113a, 0x0000 },

-  { 0x0700, 0x113c, 0x0000 },

-  { 0x8700, 0x1141, 0x3000 },

-  { 0x8700, 0x113f, 0x2000 },

-  { 0x0700, 0x113e, 0x0000 },

-  { 0x0700, 0x1140, 0x0000 },

-  { 0x8700, 0x1143, 0x2000 },

-  { 0x0700, 0x1142, 0x0000 },

-  { 0x0700, 0x1144, 0x0000 },

-  { 0x8700, 0x114d, 0x4000 },

-  { 0x8700, 0x1149, 0x3000 },

-  { 0x8700, 0x1147, 0x2000 },

-  { 0x0700, 0x1146, 0x0000 },

-  { 0x0700, 0x1148, 0x0000 },

-  { 0x8700, 0x114b, 0x2000 },

-  { 0x0700, 0x114a, 0x0000 },

-  { 0x0700, 0x114c, 0x0000 },

-  { 0x8700, 0x1151, 0x3000 },

-  { 0x8700, 0x114f, 0x2000 },

-  { 0x0700, 0x114e, 0x0000 },

-  { 0x0700, 0x1150, 0x0000 },

-  { 0x8700, 0x1153, 0x2000 },

-  { 0x0700, 0x1152, 0x0000 },

-  { 0x0700, 0x1154, 0x0000 },

-  { 0x8700, 0x116a, 0x5000 },

-  { 0x8700, 0x1162, 0x4000 },

-  { 0x8700, 0x1159, 0x3000 },

-  { 0x8700, 0x1157, 0x2000 },

-  { 0x0700, 0x1156, 0x0000 },

-  { 0x0700, 0x1158, 0x0000 },

-  { 0x8700, 0x1160, 0x2000 },

-  { 0x0700, 0x115f, 0x0000 },

-  { 0x0700, 0x1161, 0x0000 },

-  { 0x8700, 0x1166, 0x3000 },

-  { 0x8700, 0x1164, 0x2000 },

-  { 0x0700, 0x1163, 0x0000 },

-  { 0x0700, 0x1165, 0x0000 },

-  { 0x8700, 0x1168, 0x2000 },

-  { 0x0700, 0x1167, 0x0000 },

-  { 0x0700, 0x1169, 0x0000 },

-  { 0x8700, 0x1172, 0x4000 },

-  { 0x8700, 0x116e, 0x3000 },

-  { 0x8700, 0x116c, 0x2000 },

-  { 0x0700, 0x116b, 0x0000 },

-  { 0x0700, 0x116d, 0x0000 },

-  { 0x8700, 0x1170, 0x2000 },

-  { 0x0700, 0x116f, 0x0000 },

-  { 0x0700, 0x1171, 0x0000 },

-  { 0x8700, 0x1176, 0x3000 },

-  { 0x8700, 0x1174, 0x2000 },

-  { 0x0700, 0x1173, 0x0000 },

-  { 0x0700, 0x1175, 0x0000 },

-  { 0x8700, 0x1178, 0x2000 },

-  { 0x0700, 0x1177, 0x0000 },

-  { 0x0700, 0x1179, 0x0000 },

-  { 0x8700, 0x11bf, 0x7000 },

-  { 0x8700, 0x119a, 0x6000 },

-  { 0x8700, 0x118a, 0x5000 },

-  { 0x8700, 0x1182, 0x4000 },

-  { 0x8700, 0x117e, 0x3000 },

-  { 0x8700, 0x117c, 0x2000 },

-  { 0x0700, 0x117b, 0x0000 },

-  { 0x0700, 0x117d, 0x0000 },

-  { 0x8700, 0x1180, 0x2000 },

-  { 0x0700, 0x117f, 0x0000 },

-  { 0x0700, 0x1181, 0x0000 },

-  { 0x8700, 0x1186, 0x3000 },

-  { 0x8700, 0x1184, 0x2000 },

-  { 0x0700, 0x1183, 0x0000 },

-  { 0x0700, 0x1185, 0x0000 },

-  { 0x8700, 0x1188, 0x2000 },

-  { 0x0700, 0x1187, 0x0000 },

-  { 0x0700, 0x1189, 0x0000 },

-  { 0x8700, 0x1192, 0x4000 },

-  { 0x8700, 0x118e, 0x3000 },

-  { 0x8700, 0x118c, 0x2000 },

-  { 0x0700, 0x118b, 0x0000 },

-  { 0x0700, 0x118d, 0x0000 },

-  { 0x8700, 0x1190, 0x2000 },

-  { 0x0700, 0x118f, 0x0000 },

-  { 0x0700, 0x1191, 0x0000 },

-  { 0x8700, 0x1196, 0x3000 },

-  { 0x8700, 0x1194, 0x2000 },

-  { 0x0700, 0x1193, 0x0000 },

-  { 0x0700, 0x1195, 0x0000 },

-  { 0x8700, 0x1198, 0x2000 },

-  { 0x0700, 0x1197, 0x0000 },

-  { 0x0700, 0x1199, 0x0000 },

-  { 0x8700, 0x11af, 0x5000 },

-  { 0x8700, 0x11a2, 0x4000 },

-  { 0x8700, 0x119e, 0x3000 },

-  { 0x8700, 0x119c, 0x2000 },

-  { 0x0700, 0x119b, 0x0000 },

-  { 0x0700, 0x119d, 0x0000 },

-  { 0x8700, 0x11a0, 0x2000 },

-  { 0x0700, 0x119f, 0x0000 },

-  { 0x0700, 0x11a1, 0x0000 },

-  { 0x8700, 0x11ab, 0x3000 },

-  { 0x8700, 0x11a9, 0x2000 },

-  { 0x0700, 0x11a8, 0x0000 },

-  { 0x0700, 0x11aa, 0x0000 },

-  { 0x8700, 0x11ad, 0x2000 },

-  { 0x0700, 0x11ac, 0x0000 },

-  { 0x0700, 0x11ae, 0x0000 },

-  { 0x8700, 0x11b7, 0x4000 },

-  { 0x8700, 0x11b3, 0x3000 },

-  { 0x8700, 0x11b1, 0x2000 },

-  { 0x0700, 0x11b0, 0x0000 },

-  { 0x0700, 0x11b2, 0x0000 },

-  { 0x8700, 0x11b5, 0x2000 },

-  { 0x0700, 0x11b4, 0x0000 },

-  { 0x0700, 0x11b6, 0x0000 },

-  { 0x8700, 0x11bb, 0x3000 },

-  { 0x8700, 0x11b9, 0x2000 },

-  { 0x0700, 0x11b8, 0x0000 },

-  { 0x0700, 0x11ba, 0x0000 },

-  { 0x8700, 0x11bd, 0x2000 },

-  { 0x0700, 0x11bc, 0x0000 },

-  { 0x0700, 0x11be, 0x0000 },

-  { 0x8700, 0x11df, 0x6000 },

-  { 0x8700, 0x11cf, 0x5000 },

-  { 0x8700, 0x11c7, 0x4000 },

-  { 0x8700, 0x11c3, 0x3000 },

-  { 0x8700, 0x11c1, 0x2000 },

-  { 0x0700, 0x11c0, 0x0000 },

-  { 0x0700, 0x11c2, 0x0000 },

-  { 0x8700, 0x11c5, 0x2000 },

-  { 0x0700, 0x11c4, 0x0000 },

-  { 0x0700, 0x11c6, 0x0000 },

-  { 0x8700, 0x11cb, 0x3000 },

-  { 0x8700, 0x11c9, 0x2000 },

-  { 0x0700, 0x11c8, 0x0000 },

-  { 0x0700, 0x11ca, 0x0000 },

-  { 0x8700, 0x11cd, 0x2000 },

-  { 0x0700, 0x11cc, 0x0000 },

-  { 0x0700, 0x11ce, 0x0000 },

-  { 0x8700, 0x11d7, 0x4000 },

-  { 0x8700, 0x11d3, 0x3000 },

-  { 0x8700, 0x11d1, 0x2000 },

-  { 0x0700, 0x11d0, 0x0000 },

-  { 0x0700, 0x11d2, 0x0000 },

-  { 0x8700, 0x11d5, 0x2000 },

-  { 0x0700, 0x11d4, 0x0000 },

-  { 0x0700, 0x11d6, 0x0000 },

-  { 0x8700, 0x11db, 0x3000 },

-  { 0x8700, 0x11d9, 0x2000 },

-  { 0x0700, 0x11d8, 0x0000 },

-  { 0x0700, 0x11da, 0x0000 },

-  { 0x8700, 0x11dd, 0x2000 },

-  { 0x0700, 0x11dc, 0x0000 },

-  { 0x0700, 0x11de, 0x0000 },

-  { 0x8700, 0x11ef, 0x5000 },

-  { 0x8700, 0x11e7, 0x4000 },

-  { 0x8700, 0x11e3, 0x3000 },

-  { 0x8700, 0x11e1, 0x2000 },

-  { 0x0700, 0x11e0, 0x0000 },

-  { 0x0700, 0x11e2, 0x0000 },

-  { 0x8700, 0x11e5, 0x2000 },

-  { 0x0700, 0x11e4, 0x0000 },

-  { 0x0700, 0x11e6, 0x0000 },

-  { 0x8700, 0x11eb, 0x3000 },

-  { 0x8700, 0x11e9, 0x2000 },

-  { 0x0700, 0x11e8, 0x0000 },

-  { 0x0700, 0x11ea, 0x0000 },

-  { 0x8700, 0x11ed, 0x2000 },

-  { 0x0700, 0x11ec, 0x0000 },

-  { 0x0700, 0x11ee, 0x0000 },

-  { 0x8700, 0x11f7, 0x4000 },

-  { 0x8700, 0x11f3, 0x3000 },

-  { 0x8700, 0x11f1, 0x2000 },

-  { 0x0700, 0x11f0, 0x0000 },

-  { 0x0700, 0x11f2, 0x0000 },

-  { 0x8700, 0x11f5, 0x2000 },

-  { 0x0700, 0x11f4, 0x0000 },

-  { 0x0700, 0x11f6, 0x0000 },

-  { 0x8700, 0x1201, 0x3000 },

-  { 0x8700, 0x11f9, 0x2000 },

-  { 0x0700, 0x11f8, 0x0000 },

-  { 0x0700, 0x1200, 0x0000 },

-  { 0x8700, 0x1203, 0x2000 },

-  { 0x0700, 0x1202, 0x0000 },

-  { 0x0700, 0x1204, 0x0000 },

-  { 0x8700, 0x1292, 0x8000 },

-  { 0x8700, 0x1246, 0x7000 },

-  { 0x8700, 0x1226, 0x6000 },

-  { 0x8700, 0x1216, 0x5000 },

-  { 0x8700, 0x120e, 0x4000 },

-  { 0x8700, 0x120a, 0x3000 },

-  { 0x8700, 0x1208, 0x2000 },

-  { 0x0700, 0x1206, 0x0000 },

-  { 0x0700, 0x1209, 0x0000 },

-  { 0x8700, 0x120c, 0x2000 },

-  { 0x0700, 0x120b, 0x0000 },

-  { 0x0700, 0x120d, 0x0000 },

-  { 0x8700, 0x1212, 0x3000 },

-  { 0x8700, 0x1210, 0x2000 },

-  { 0x0700, 0x120f, 0x0000 },

-  { 0x0700, 0x1211, 0x0000 },

-  { 0x8700, 0x1214, 0x2000 },

-  { 0x0700, 0x1213, 0x0000 },

-  { 0x0700, 0x1215, 0x0000 },

-  { 0x8700, 0x121e, 0x4000 },

-  { 0x8700, 0x121a, 0x3000 },

-  { 0x8700, 0x1218, 0x2000 },

-  { 0x0700, 0x1217, 0x0000 },

-  { 0x0700, 0x1219, 0x0000 },

-  { 0x8700, 0x121c, 0x2000 },

-  { 0x0700, 0x121b, 0x0000 },

-  { 0x0700, 0x121d, 0x0000 },

-  { 0x8700, 0x1222, 0x3000 },

-  { 0x8700, 0x1220, 0x2000 },

-  { 0x0700, 0x121f, 0x0000 },

-  { 0x0700, 0x1221, 0x0000 },

-  { 0x8700, 0x1224, 0x2000 },

-  { 0x0700, 0x1223, 0x0000 },

-  { 0x0700, 0x1225, 0x0000 },

-  { 0x8700, 0x1236, 0x5000 },

-  { 0x8700, 0x122e, 0x4000 },

-  { 0x8700, 0x122a, 0x3000 },

-  { 0x8700, 0x1228, 0x2000 },

-  { 0x0700, 0x1227, 0x0000 },

-  { 0x0700, 0x1229, 0x0000 },

-  { 0x8700, 0x122c, 0x2000 },

-  { 0x0700, 0x122b, 0x0000 },

-  { 0x0700, 0x122d, 0x0000 },

-  { 0x8700, 0x1232, 0x3000 },

-  { 0x8700, 0x1230, 0x2000 },

-  { 0x0700, 0x122f, 0x0000 },

-  { 0x0700, 0x1231, 0x0000 },

-  { 0x8700, 0x1234, 0x2000 },

-  { 0x0700, 0x1233, 0x0000 },

-  { 0x0700, 0x1235, 0x0000 },

-  { 0x8700, 0x123e, 0x4000 },

-  { 0x8700, 0x123a, 0x3000 },

-  { 0x8700, 0x1238, 0x2000 },

-  { 0x0700, 0x1237, 0x0000 },

-  { 0x0700, 0x1239, 0x0000 },

-  { 0x8700, 0x123c, 0x2000 },

-  { 0x0700, 0x123b, 0x0000 },

-  { 0x0700, 0x123d, 0x0000 },

-  { 0x8700, 0x1242, 0x3000 },

-  { 0x8700, 0x1240, 0x2000 },

-  { 0x0700, 0x123f, 0x0000 },

-  { 0x0700, 0x1241, 0x0000 },

-  { 0x8700, 0x1244, 0x2000 },

-  { 0x0700, 0x1243, 0x0000 },

-  { 0x0700, 0x1245, 0x0000 },

-  { 0x8700, 0x126e, 0x6000 },

-  { 0x8700, 0x125c, 0x5000 },

-  { 0x8700, 0x1252, 0x4000 },

-  { 0x8700, 0x124c, 0x3000 },

-  { 0x8700, 0x124a, 0x2000 },

-  { 0x0700, 0x1248, 0x0000 },

-  { 0x0700, 0x124b, 0x0000 },

-  { 0x8700, 0x1250, 0x2000 },

-  { 0x0700, 0x124d, 0x0000 },

-  { 0x0700, 0x1251, 0x0000 },

-  { 0x8700, 0x1256, 0x3000 },

-  { 0x8700, 0x1254, 0x2000 },

-  { 0x0700, 0x1253, 0x0000 },

-  { 0x0700, 0x1255, 0x0000 },

-  { 0x8700, 0x125a, 0x2000 },

-  { 0x0700, 0x1258, 0x0000 },

-  { 0x0700, 0x125b, 0x0000 },

-  { 0x8700, 0x1266, 0x4000 },

-  { 0x8700, 0x1262, 0x3000 },

-  { 0x8700, 0x1260, 0x2000 },

-  { 0x0700, 0x125d, 0x0000 },

-  { 0x0700, 0x1261, 0x0000 },

-  { 0x8700, 0x1264, 0x2000 },

-  { 0x0700, 0x1263, 0x0000 },

-  { 0x0700, 0x1265, 0x0000 },

-  { 0x8700, 0x126a, 0x3000 },

-  { 0x8700, 0x1268, 0x2000 },

-  { 0x0700, 0x1267, 0x0000 },

-  { 0x0700, 0x1269, 0x0000 },

-  { 0x8700, 0x126c, 0x2000 },

-  { 0x0700, 0x126b, 0x0000 },

-  { 0x0700, 0x126d, 0x0000 },

-  { 0x8700, 0x127e, 0x5000 },

-  { 0x8700, 0x1276, 0x4000 },

-  { 0x8700, 0x1272, 0x3000 },

-  { 0x8700, 0x1270, 0x2000 },

-  { 0x0700, 0x126f, 0x0000 },

-  { 0x0700, 0x1271, 0x0000 },

-  { 0x8700, 0x1274, 0x2000 },

-  { 0x0700, 0x1273, 0x0000 },

-  { 0x0700, 0x1275, 0x0000 },

-  { 0x8700, 0x127a, 0x3000 },

-  { 0x8700, 0x1278, 0x2000 },

-  { 0x0700, 0x1277, 0x0000 },

-  { 0x0700, 0x1279, 0x0000 },

-  { 0x8700, 0x127c, 0x2000 },

-  { 0x0700, 0x127b, 0x0000 },

-  { 0x0700, 0x127d, 0x0000 },

-  { 0x8700, 0x1286, 0x4000 },

-  { 0x8700, 0x1282, 0x3000 },

-  { 0x8700, 0x1280, 0x2000 },

-  { 0x0700, 0x127f, 0x0000 },

-  { 0x0700, 0x1281, 0x0000 },

-  { 0x8700, 0x1284, 0x2000 },

-  { 0x0700, 0x1283, 0x0000 },

-  { 0x0700, 0x1285, 0x0000 },

-  { 0x8700, 0x128c, 0x3000 },

-  { 0x8700, 0x128a, 0x2000 },

-  { 0x0700, 0x1288, 0x0000 },

-  { 0x0700, 0x128b, 0x0000 },

-  { 0x8700, 0x1290, 0x2000 },

-  { 0x0700, 0x128d, 0x0000 },

-  { 0x0700, 0x1291, 0x0000 },

-  { 0x8700, 0x12dc, 0x7000 },

-  { 0x8700, 0x12b4, 0x6000 },

-  { 0x8700, 0x12a2, 0x5000 },

-  { 0x8700, 0x129a, 0x4000 },

-  { 0x8700, 0x1296, 0x3000 },

-  { 0x8700, 0x1294, 0x2000 },

-  { 0x0700, 0x1293, 0x0000 },

-  { 0x0700, 0x1295, 0x0000 },

-  { 0x8700, 0x1298, 0x2000 },

-  { 0x0700, 0x1297, 0x0000 },

-  { 0x0700, 0x1299, 0x0000 },

-  { 0x8700, 0x129e, 0x3000 },

-  { 0x8700, 0x129c, 0x2000 },

-  { 0x0700, 0x129b, 0x0000 },

-  { 0x0700, 0x129d, 0x0000 },

-  { 0x8700, 0x12a0, 0x2000 },

-  { 0x0700, 0x129f, 0x0000 },

-  { 0x0700, 0x12a1, 0x0000 },

-  { 0x8700, 0x12aa, 0x4000 },

-  { 0x8700, 0x12a6, 0x3000 },

-  { 0x8700, 0x12a4, 0x2000 },

-  { 0x0700, 0x12a3, 0x0000 },

-  { 0x0700, 0x12a5, 0x0000 },

-  { 0x8700, 0x12a8, 0x2000 },

-  { 0x0700, 0x12a7, 0x0000 },

-  { 0x0700, 0x12a9, 0x0000 },

-  { 0x8700, 0x12ae, 0x3000 },

-  { 0x8700, 0x12ac, 0x2000 },

-  { 0x0700, 0x12ab, 0x0000 },

-  { 0x0700, 0x12ad, 0x0000 },

-  { 0x8700, 0x12b2, 0x2000 },

-  { 0x0700, 0x12b0, 0x0000 },

-  { 0x0700, 0x12b3, 0x0000 },

-  { 0x8700, 0x12ca, 0x5000 },

-  { 0x8700, 0x12be, 0x4000 },

-  { 0x8700, 0x12ba, 0x3000 },

-  { 0x8700, 0x12b8, 0x2000 },

-  { 0x0700, 0x12b5, 0x0000 },

-  { 0x0700, 0x12b9, 0x0000 },

-  { 0x8700, 0x12bc, 0x2000 },

-  { 0x0700, 0x12bb, 0x0000 },

-  { 0x0700, 0x12bd, 0x0000 },

-  { 0x8700, 0x12c4, 0x3000 },

-  { 0x8700, 0x12c2, 0x2000 },

-  { 0x0700, 0x12c0, 0x0000 },

-  { 0x0700, 0x12c3, 0x0000 },

-  { 0x8700, 0x12c8, 0x2000 },

-  { 0x0700, 0x12c5, 0x0000 },

-  { 0x0700, 0x12c9, 0x0000 },

-  { 0x8700, 0x12d3, 0x4000 },

-  { 0x8700, 0x12ce, 0x3000 },

-  { 0x8700, 0x12cc, 0x2000 },

-  { 0x0700, 0x12cb, 0x0000 },

-  { 0x0700, 0x12cd, 0x0000 },

-  { 0x8700, 0x12d1, 0x2000 },

-  { 0x0700, 0x12d0, 0x0000 },

-  { 0x0700, 0x12d2, 0x0000 },

-  { 0x8700, 0x12d8, 0x3000 },

-  { 0x8700, 0x12d5, 0x2000 },

-  { 0x0700, 0x12d4, 0x0000 },

-  { 0x0700, 0x12d6, 0x0000 },

-  { 0x8700, 0x12da, 0x2000 },

-  { 0x0700, 0x12d9, 0x0000 },

-  { 0x0700, 0x12db, 0x0000 },

-  { 0x8700, 0x12fd, 0x6000 },

-  { 0x8700, 0x12ec, 0x5000 },

-  { 0x8700, 0x12e4, 0x4000 },

-  { 0x8700, 0x12e0, 0x3000 },

-  { 0x8700, 0x12de, 0x2000 },

-  { 0x0700, 0x12dd, 0x0000 },

-  { 0x0700, 0x12df, 0x0000 },

-  { 0x8700, 0x12e2, 0x2000 },

-  { 0x0700, 0x12e1, 0x0000 },

-  { 0x0700, 0x12e3, 0x0000 },

-  { 0x8700, 0x12e8, 0x3000 },

-  { 0x8700, 0x12e6, 0x2000 },

-  { 0x0700, 0x12e5, 0x0000 },

-  { 0x0700, 0x12e7, 0x0000 },

-  { 0x8700, 0x12ea, 0x2000 },

-  { 0x0700, 0x12e9, 0x0000 },

-  { 0x0700, 0x12eb, 0x0000 },

-  { 0x8700, 0x12f5, 0x4000 },

-  { 0x8700, 0x12f1, 0x3000 },

-  { 0x8700, 0x12ee, 0x2000 },

-  { 0x0700, 0x12ed, 0x0000 },

-  { 0x0700, 0x12f0, 0x0000 },

-  { 0x8700, 0x12f3, 0x2000 },

-  { 0x0700, 0x12f2, 0x0000 },

-  { 0x0700, 0x12f4, 0x0000 },

-  { 0x8700, 0x12f9, 0x3000 },

-  { 0x8700, 0x12f7, 0x2000 },

-  { 0x0700, 0x12f6, 0x0000 },

-  { 0x0700, 0x12f8, 0x0000 },

-  { 0x8700, 0x12fb, 0x2000 },

-  { 0x0700, 0x12fa, 0x0000 },

-  { 0x0700, 0x12fc, 0x0000 },

-  { 0x8700, 0x130d, 0x5000 },

-  { 0x8700, 0x1305, 0x4000 },

-  { 0x8700, 0x1301, 0x3000 },

-  { 0x8700, 0x12ff, 0x2000 },

-  { 0x0700, 0x12fe, 0x0000 },

-  { 0x0700, 0x1300, 0x0000 },

-  { 0x8700, 0x1303, 0x2000 },

-  { 0x0700, 0x1302, 0x0000 },

-  { 0x0700, 0x1304, 0x0000 },

-  { 0x8700, 0x1309, 0x3000 },

-  { 0x8700, 0x1307, 0x2000 },

-  { 0x0700, 0x1306, 0x0000 },

-  { 0x0700, 0x1308, 0x0000 },

-  { 0x8700, 0x130b, 0x2000 },

-  { 0x0700, 0x130a, 0x0000 },

-  { 0x0700, 0x130c, 0x0000 },

-  { 0x8700, 0x1319, 0x4000 },

-  { 0x8700, 0x1313, 0x3000 },

-  { 0x8700, 0x1310, 0x2000 },

-  { 0x0700, 0x130e, 0x0000 },

-  { 0x0700, 0x1312, 0x0000 },

-  { 0x8700, 0x1315, 0x2000 },

-  { 0x0700, 0x1314, 0x0000 },

-  { 0x0700, 0x1318, 0x0000 },

-  { 0x8700, 0x131d, 0x3000 },

-  { 0x8700, 0x131b, 0x2000 },

-  { 0x0700, 0x131a, 0x0000 },

-  { 0x0700, 0x131c, 0x0000 },

-  { 0x8700, 0x1320, 0x2000 },

-  { 0x0700, 0x131e, 0x0000 },

-  { 0x0700, 0x1321, 0x0000 },

-  { 0x8700, 0x1458, 0x9000 },

-  { 0x8700, 0x13cc, 0x8000 },

-  { 0x8d00, 0x1369, 0x7000 },

-  { 0x8700, 0x1342, 0x6000 },

-  { 0x8700, 0x1332, 0x5000 },

-  { 0x8700, 0x132a, 0x4000 },

-  { 0x8700, 0x1326, 0x3000 },

-  { 0x8700, 0x1324, 0x2000 },

-  { 0x0700, 0x1323, 0x0000 },

-  { 0x0700, 0x1325, 0x0000 },

-  { 0x8700, 0x1328, 0x2000 },

-  { 0x0700, 0x1327, 0x0000 },

-  { 0x0700, 0x1329, 0x0000 },

-  { 0x8700, 0x132e, 0x3000 },

-  { 0x8700, 0x132c, 0x2000 },

-  { 0x0700, 0x132b, 0x0000 },

-  { 0x0700, 0x132d, 0x0000 },

-  { 0x8700, 0x1330, 0x2000 },

-  { 0x0700, 0x132f, 0x0000 },

-  { 0x0700, 0x1331, 0x0000 },

-  { 0x8700, 0x133a, 0x4000 },

-  { 0x8700, 0x1336, 0x3000 },

-  { 0x8700, 0x1334, 0x2000 },

-  { 0x0700, 0x1333, 0x0000 },

-  { 0x0700, 0x1335, 0x0000 },

-  { 0x8700, 0x1338, 0x2000 },

-  { 0x0700, 0x1337, 0x0000 },

-  { 0x0700, 0x1339, 0x0000 },

-  { 0x8700, 0x133e, 0x3000 },

-  { 0x8700, 0x133c, 0x2000 },

-  { 0x0700, 0x133b, 0x0000 },

-  { 0x0700, 0x133d, 0x0000 },

-  { 0x8700, 0x1340, 0x2000 },

-  { 0x0700, 0x133f, 0x0000 },

-  { 0x0700, 0x1341, 0x0000 },

-  { 0x8700, 0x1353, 0x5000 },

-  { 0x8700, 0x134b, 0x4000 },

-  { 0x8700, 0x1346, 0x3000 },

-  { 0x8700, 0x1344, 0x2000 },

-  { 0x0700, 0x1343, 0x0000 },

-  { 0x0700, 0x1345, 0x0000 },

-  { 0x8700, 0x1349, 0x2000 },

-  { 0x0700, 0x1348, 0x0000 },

-  { 0x0700, 0x134a, 0x0000 },

-  { 0x8700, 0x134f, 0x3000 },

-  { 0x8700, 0x134d, 0x2000 },

-  { 0x0700, 0x134c, 0x0000 },

-  { 0x0700, 0x134e, 0x0000 },

-  { 0x8700, 0x1351, 0x2000 },

-  { 0x0700, 0x1350, 0x0000 },

-  { 0x0700, 0x1352, 0x0000 },

-  { 0x9500, 0x1361, 0x4000 },

-  { 0x8700, 0x1357, 0x3000 },

-  { 0x8700, 0x1355, 0x2000 },

-  { 0x0700, 0x1354, 0x0000 },

-  { 0x0700, 0x1356, 0x0000 },

-  { 0x8700, 0x1359, 0x2000 },

-  { 0x0700, 0x1358, 0x0000 },

-  { 0x0700, 0x135a, 0x0000 },

-  { 0x9500, 0x1365, 0x3000 },

-  { 0x9500, 0x1363, 0x2000 },

-  { 0x1500, 0x1362, 0x0000 },

-  { 0x1500, 0x1364, 0x0000 },

-  { 0x9500, 0x1367, 0x2000 },

-  { 0x1500, 0x1366, 0x0000 },

-  { 0x1500, 0x1368, 0x0000 },

-  { 0x8700, 0x13ac, 0x6000 },

-  { 0x8f00, 0x1379, 0x5000 },

-  { 0x8d00, 0x1371, 0x4000 },

-  { 0x8d00, 0x136d, 0x3000 },

-  { 0x8d00, 0x136b, 0x2000 },

-  { 0x0d00, 0x136a, 0x0000 },

-  { 0x0d00, 0x136c, 0x0000 },

-  { 0x8d00, 0x136f, 0x2000 },

-  { 0x0d00, 0x136e, 0x0000 },

-  { 0x0d00, 0x1370, 0x0000 },

-  { 0x8f00, 0x1375, 0x3000 },

-  { 0x8f00, 0x1373, 0x2000 },

-  { 0x0f00, 0x1372, 0x0000 },

-  { 0x0f00, 0x1374, 0x0000 },

-  { 0x8f00, 0x1377, 0x2000 },

-  { 0x0f00, 0x1376, 0x0000 },

-  { 0x0f00, 0x1378, 0x0000 },

-  { 0x8700, 0x13a4, 0x4000 },

-  { 0x8700, 0x13a0, 0x3000 },

-  { 0x8f00, 0x137b, 0x2000 },

-  { 0x0f00, 0x137a, 0x0000 },

-  { 0x0f00, 0x137c, 0x0000 },

-  { 0x8700, 0x13a2, 0x2000 },

-  { 0x0700, 0x13a1, 0x0000 },

-  { 0x0700, 0x13a3, 0x0000 },

-  { 0x8700, 0x13a8, 0x3000 },

-  { 0x8700, 0x13a6, 0x2000 },

-  { 0x0700, 0x13a5, 0x0000 },

-  { 0x0700, 0x13a7, 0x0000 },

-  { 0x8700, 0x13aa, 0x2000 },

-  { 0x0700, 0x13a9, 0x0000 },

-  { 0x0700, 0x13ab, 0x0000 },

-  { 0x8700, 0x13bc, 0x5000 },

-  { 0x8700, 0x13b4, 0x4000 },

-  { 0x8700, 0x13b0, 0x3000 },

-  { 0x8700, 0x13ae, 0x2000 },

-  { 0x0700, 0x13ad, 0x0000 },

-  { 0x0700, 0x13af, 0x0000 },

-  { 0x8700, 0x13b2, 0x2000 },

-  { 0x0700, 0x13b1, 0x0000 },

-  { 0x0700, 0x13b3, 0x0000 },

-  { 0x8700, 0x13b8, 0x3000 },

-  { 0x8700, 0x13b6, 0x2000 },

-  { 0x0700, 0x13b5, 0x0000 },

-  { 0x0700, 0x13b7, 0x0000 },

-  { 0x8700, 0x13ba, 0x2000 },

-  { 0x0700, 0x13b9, 0x0000 },

-  { 0x0700, 0x13bb, 0x0000 },

-  { 0x8700, 0x13c4, 0x4000 },

-  { 0x8700, 0x13c0, 0x3000 },

-  { 0x8700, 0x13be, 0x2000 },

-  { 0x0700, 0x13bd, 0x0000 },

-  { 0x0700, 0x13bf, 0x0000 },

-  { 0x8700, 0x13c2, 0x2000 },

-  { 0x0700, 0x13c1, 0x0000 },

-  { 0x0700, 0x13c3, 0x0000 },

-  { 0x8700, 0x13c8, 0x3000 },

-  { 0x8700, 0x13c6, 0x2000 },

-  { 0x0700, 0x13c5, 0x0000 },

-  { 0x0700, 0x13c7, 0x0000 },

-  { 0x8700, 0x13ca, 0x2000 },

-  { 0x0700, 0x13c9, 0x0000 },

-  { 0x0700, 0x13cb, 0x0000 },

-  { 0x8700, 0x1418, 0x7000 },

-  { 0x8700, 0x13ec, 0x6000 },

-  { 0x8700, 0x13dc, 0x5000 },

-  { 0x8700, 0x13d4, 0x4000 },

-  { 0x8700, 0x13d0, 0x3000 },

-  { 0x8700, 0x13ce, 0x2000 },

-  { 0x0700, 0x13cd, 0x0000 },

-  { 0x0700, 0x13cf, 0x0000 },

-  { 0x8700, 0x13d2, 0x2000 },

-  { 0x0700, 0x13d1, 0x0000 },

-  { 0x0700, 0x13d3, 0x0000 },

-  { 0x8700, 0x13d8, 0x3000 },

-  { 0x8700, 0x13d6, 0x2000 },

-  { 0x0700, 0x13d5, 0x0000 },

-  { 0x0700, 0x13d7, 0x0000 },

-  { 0x8700, 0x13da, 0x2000 },

-  { 0x0700, 0x13d9, 0x0000 },

-  { 0x0700, 0x13db, 0x0000 },

-  { 0x8700, 0x13e4, 0x4000 },

-  { 0x8700, 0x13e0, 0x3000 },

-  { 0x8700, 0x13de, 0x2000 },

-  { 0x0700, 0x13dd, 0x0000 },

-  { 0x0700, 0x13df, 0x0000 },

-  { 0x8700, 0x13e2, 0x2000 },

-  { 0x0700, 0x13e1, 0x0000 },

-  { 0x0700, 0x13e3, 0x0000 },

-  { 0x8700, 0x13e8, 0x3000 },

-  { 0x8700, 0x13e6, 0x2000 },

-  { 0x0700, 0x13e5, 0x0000 },

-  { 0x0700, 0x13e7, 0x0000 },

-  { 0x8700, 0x13ea, 0x2000 },

-  { 0x0700, 0x13e9, 0x0000 },

-  { 0x0700, 0x13eb, 0x0000 },

-  { 0x8700, 0x1408, 0x5000 },

-  { 0x8700, 0x13f4, 0x4000 },

-  { 0x8700, 0x13f0, 0x3000 },

-  { 0x8700, 0x13ee, 0x2000 },

-  { 0x0700, 0x13ed, 0x0000 },

-  { 0x0700, 0x13ef, 0x0000 },

-  { 0x8700, 0x13f2, 0x2000 },

-  { 0x0700, 0x13f1, 0x0000 },

-  { 0x0700, 0x13f3, 0x0000 },

-  { 0x8700, 0x1404, 0x3000 },

-  { 0x8700, 0x1402, 0x2000 },

-  { 0x0700, 0x1401, 0x0000 },

-  { 0x0700, 0x1403, 0x0000 },

-  { 0x8700, 0x1406, 0x2000 },

-  { 0x0700, 0x1405, 0x0000 },

-  { 0x0700, 0x1407, 0x0000 },

-  { 0x8700, 0x1410, 0x4000 },

-  { 0x8700, 0x140c, 0x3000 },

-  { 0x8700, 0x140a, 0x2000 },

-  { 0x0700, 0x1409, 0x0000 },

-  { 0x0700, 0x140b, 0x0000 },

-  { 0x8700, 0x140e, 0x2000 },

-  { 0x0700, 0x140d, 0x0000 },

-  { 0x0700, 0x140f, 0x0000 },

-  { 0x8700, 0x1414, 0x3000 },

-  { 0x8700, 0x1412, 0x2000 },

-  { 0x0700, 0x1411, 0x0000 },

-  { 0x0700, 0x1413, 0x0000 },

-  { 0x8700, 0x1416, 0x2000 },

-  { 0x0700, 0x1415, 0x0000 },

-  { 0x0700, 0x1417, 0x0000 },

-  { 0x8700, 0x1438, 0x6000 },

-  { 0x8700, 0x1428, 0x5000 },

-  { 0x8700, 0x1420, 0x4000 },

-  { 0x8700, 0x141c, 0x3000 },

-  { 0x8700, 0x141a, 0x2000 },

-  { 0x0700, 0x1419, 0x0000 },

-  { 0x0700, 0x141b, 0x0000 },

-  { 0x8700, 0x141e, 0x2000 },

-  { 0x0700, 0x141d, 0x0000 },

-  { 0x0700, 0x141f, 0x0000 },

-  { 0x8700, 0x1424, 0x3000 },

-  { 0x8700, 0x1422, 0x2000 },

-  { 0x0700, 0x1421, 0x0000 },

-  { 0x0700, 0x1423, 0x0000 },

-  { 0x8700, 0x1426, 0x2000 },

-  { 0x0700, 0x1425, 0x0000 },

-  { 0x0700, 0x1427, 0x0000 },

-  { 0x8700, 0x1430, 0x4000 },

-  { 0x8700, 0x142c, 0x3000 },

-  { 0x8700, 0x142a, 0x2000 },

-  { 0x0700, 0x1429, 0x0000 },

-  { 0x0700, 0x142b, 0x0000 },

-  { 0x8700, 0x142e, 0x2000 },

-  { 0x0700, 0x142d, 0x0000 },

-  { 0x0700, 0x142f, 0x0000 },

-  { 0x8700, 0x1434, 0x3000 },

-  { 0x8700, 0x1432, 0x2000 },

-  { 0x0700, 0x1431, 0x0000 },

-  { 0x0700, 0x1433, 0x0000 },

-  { 0x8700, 0x1436, 0x2000 },

-  { 0x0700, 0x1435, 0x0000 },

-  { 0x0700, 0x1437, 0x0000 },

-  { 0x8700, 0x1448, 0x5000 },

-  { 0x8700, 0x1440, 0x4000 },

-  { 0x8700, 0x143c, 0x3000 },

-  { 0x8700, 0x143a, 0x2000 },

-  { 0x0700, 0x1439, 0x0000 },

-  { 0x0700, 0x143b, 0x0000 },

-  { 0x8700, 0x143e, 0x2000 },

-  { 0x0700, 0x143d, 0x0000 },

-  { 0x0700, 0x143f, 0x0000 },

-  { 0x8700, 0x1444, 0x3000 },

-  { 0x8700, 0x1442, 0x2000 },

-  { 0x0700, 0x1441, 0x0000 },

-  { 0x0700, 0x1443, 0x0000 },

-  { 0x8700, 0x1446, 0x2000 },

-  { 0x0700, 0x1445, 0x0000 },

-  { 0x0700, 0x1447, 0x0000 },

-  { 0x8700, 0x1450, 0x4000 },

-  { 0x8700, 0x144c, 0x3000 },

-  { 0x8700, 0x144a, 0x2000 },

-  { 0x0700, 0x1449, 0x0000 },

-  { 0x0700, 0x144b, 0x0000 },

-  { 0x8700, 0x144e, 0x2000 },

-  { 0x0700, 0x144d, 0x0000 },

-  { 0x0700, 0x144f, 0x0000 },

-  { 0x8700, 0x1454, 0x3000 },

-  { 0x8700, 0x1452, 0x2000 },

-  { 0x0700, 0x1451, 0x0000 },

-  { 0x0700, 0x1453, 0x0000 },

-  { 0x8700, 0x1456, 0x2000 },

-  { 0x0700, 0x1455, 0x0000 },

-  { 0x0700, 0x1457, 0x0000 },

-  { 0x8700, 0x14d8, 0x8000 },

-  { 0x8700, 0x1498, 0x7000 },

-  { 0x8700, 0x1478, 0x6000 },

-  { 0x8700, 0x1468, 0x5000 },

-  { 0x8700, 0x1460, 0x4000 },

-  { 0x8700, 0x145c, 0x3000 },

-  { 0x8700, 0x145a, 0x2000 },

-  { 0x0700, 0x1459, 0x0000 },

-  { 0x0700, 0x145b, 0x0000 },

-  { 0x8700, 0x145e, 0x2000 },

-  { 0x0700, 0x145d, 0x0000 },

-  { 0x0700, 0x145f, 0x0000 },

-  { 0x8700, 0x1464, 0x3000 },

-  { 0x8700, 0x1462, 0x2000 },

-  { 0x0700, 0x1461, 0x0000 },

-  { 0x0700, 0x1463, 0x0000 },

-  { 0x8700, 0x1466, 0x2000 },

-  { 0x0700, 0x1465, 0x0000 },

-  { 0x0700, 0x1467, 0x0000 },

-  { 0x8700, 0x1470, 0x4000 },

-  { 0x8700, 0x146c, 0x3000 },

-  { 0x8700, 0x146a, 0x2000 },

-  { 0x0700, 0x1469, 0x0000 },

-  { 0x0700, 0x146b, 0x0000 },

-  { 0x8700, 0x146e, 0x2000 },

-  { 0x0700, 0x146d, 0x0000 },

-  { 0x0700, 0x146f, 0x0000 },

-  { 0x8700, 0x1474, 0x3000 },

-  { 0x8700, 0x1472, 0x2000 },

-  { 0x0700, 0x1471, 0x0000 },

-  { 0x0700, 0x1473, 0x0000 },

-  { 0x8700, 0x1476, 0x2000 },

-  { 0x0700, 0x1475, 0x0000 },

-  { 0x0700, 0x1477, 0x0000 },

-  { 0x8700, 0x1488, 0x5000 },

-  { 0x8700, 0x1480, 0x4000 },

-  { 0x8700, 0x147c, 0x3000 },

-  { 0x8700, 0x147a, 0x2000 },

-  { 0x0700, 0x1479, 0x0000 },

-  { 0x0700, 0x147b, 0x0000 },

-  { 0x8700, 0x147e, 0x2000 },

-  { 0x0700, 0x147d, 0x0000 },

-  { 0x0700, 0x147f, 0x0000 },

-  { 0x8700, 0x1484, 0x3000 },

-  { 0x8700, 0x1482, 0x2000 },

-  { 0x0700, 0x1481, 0x0000 },

-  { 0x0700, 0x1483, 0x0000 },

-  { 0x8700, 0x1486, 0x2000 },

-  { 0x0700, 0x1485, 0x0000 },

-  { 0x0700, 0x1487, 0x0000 },

-  { 0x8700, 0x1490, 0x4000 },

-  { 0x8700, 0x148c, 0x3000 },

-  { 0x8700, 0x148a, 0x2000 },

-  { 0x0700, 0x1489, 0x0000 },

-  { 0x0700, 0x148b, 0x0000 },

-  { 0x8700, 0x148e, 0x2000 },

-  { 0x0700, 0x148d, 0x0000 },

-  { 0x0700, 0x148f, 0x0000 },

-  { 0x8700, 0x1494, 0x3000 },

-  { 0x8700, 0x1492, 0x2000 },

-  { 0x0700, 0x1491, 0x0000 },

-  { 0x0700, 0x1493, 0x0000 },

-  { 0x8700, 0x1496, 0x2000 },

-  { 0x0700, 0x1495, 0x0000 },

-  { 0x0700, 0x1497, 0x0000 },

-  { 0x8700, 0x14b8, 0x6000 },

-  { 0x8700, 0x14a8, 0x5000 },

-  { 0x8700, 0x14a0, 0x4000 },

-  { 0x8700, 0x149c, 0x3000 },

-  { 0x8700, 0x149a, 0x2000 },

-  { 0x0700, 0x1499, 0x0000 },

-  { 0x0700, 0x149b, 0x0000 },

-  { 0x8700, 0x149e, 0x2000 },

-  { 0x0700, 0x149d, 0x0000 },

-  { 0x0700, 0x149f, 0x0000 },

-  { 0x8700, 0x14a4, 0x3000 },

-  { 0x8700, 0x14a2, 0x2000 },

-  { 0x0700, 0x14a1, 0x0000 },

-  { 0x0700, 0x14a3, 0x0000 },

-  { 0x8700, 0x14a6, 0x2000 },

-  { 0x0700, 0x14a5, 0x0000 },

-  { 0x0700, 0x14a7, 0x0000 },

-  { 0x8700, 0x14b0, 0x4000 },

-  { 0x8700, 0x14ac, 0x3000 },

-  { 0x8700, 0x14aa, 0x2000 },

-  { 0x0700, 0x14a9, 0x0000 },

-  { 0x0700, 0x14ab, 0x0000 },

-  { 0x8700, 0x14ae, 0x2000 },

-  { 0x0700, 0x14ad, 0x0000 },

-  { 0x0700, 0x14af, 0x0000 },

-  { 0x8700, 0x14b4, 0x3000 },

-  { 0x8700, 0x14b2, 0x2000 },

-  { 0x0700, 0x14b1, 0x0000 },

-  { 0x0700, 0x14b3, 0x0000 },

-  { 0x8700, 0x14b6, 0x2000 },

-  { 0x0700, 0x14b5, 0x0000 },

-  { 0x0700, 0x14b7, 0x0000 },

-  { 0x8700, 0x14c8, 0x5000 },

-  { 0x8700, 0x14c0, 0x4000 },

-  { 0x8700, 0x14bc, 0x3000 },

-  { 0x8700, 0x14ba, 0x2000 },

-  { 0x0700, 0x14b9, 0x0000 },

-  { 0x0700, 0x14bb, 0x0000 },

-  { 0x8700, 0x14be, 0x2000 },

-  { 0x0700, 0x14bd, 0x0000 },

-  { 0x0700, 0x14bf, 0x0000 },

-  { 0x8700, 0x14c4, 0x3000 },

-  { 0x8700, 0x14c2, 0x2000 },

-  { 0x0700, 0x14c1, 0x0000 },

-  { 0x0700, 0x14c3, 0x0000 },

-  { 0x8700, 0x14c6, 0x2000 },

-  { 0x0700, 0x14c5, 0x0000 },

-  { 0x0700, 0x14c7, 0x0000 },

-  { 0x8700, 0x14d0, 0x4000 },

-  { 0x8700, 0x14cc, 0x3000 },

-  { 0x8700, 0x14ca, 0x2000 },

-  { 0x0700, 0x14c9, 0x0000 },

-  { 0x0700, 0x14cb, 0x0000 },

-  { 0x8700, 0x14ce, 0x2000 },

-  { 0x0700, 0x14cd, 0x0000 },

-  { 0x0700, 0x14cf, 0x0000 },

-  { 0x8700, 0x14d4, 0x3000 },

-  { 0x8700, 0x14d2, 0x2000 },

-  { 0x0700, 0x14d1, 0x0000 },

-  { 0x0700, 0x14d3, 0x0000 },

-  { 0x8700, 0x14d6, 0x2000 },

-  { 0x0700, 0x14d5, 0x0000 },

-  { 0x0700, 0x14d7, 0x0000 },

-  { 0x8700, 0x1518, 0x7000 },

-  { 0x8700, 0x14f8, 0x6000 },

-  { 0x8700, 0x14e8, 0x5000 },

-  { 0x8700, 0x14e0, 0x4000 },

-  { 0x8700, 0x14dc, 0x3000 },

-  { 0x8700, 0x14da, 0x2000 },

-  { 0x0700, 0x14d9, 0x0000 },

-  { 0x0700, 0x14db, 0x0000 },

-  { 0x8700, 0x14de, 0x2000 },

-  { 0x0700, 0x14dd, 0x0000 },

-  { 0x0700, 0x14df, 0x0000 },

-  { 0x8700, 0x14e4, 0x3000 },

-  { 0x8700, 0x14e2, 0x2000 },

-  { 0x0700, 0x14e1, 0x0000 },

-  { 0x0700, 0x14e3, 0x0000 },

-  { 0x8700, 0x14e6, 0x2000 },

-  { 0x0700, 0x14e5, 0x0000 },

-  { 0x0700, 0x14e7, 0x0000 },

-  { 0x8700, 0x14f0, 0x4000 },

-  { 0x8700, 0x14ec, 0x3000 },

-  { 0x8700, 0x14ea, 0x2000 },

-  { 0x0700, 0x14e9, 0x0000 },

-  { 0x0700, 0x14eb, 0x0000 },

-  { 0x8700, 0x14ee, 0x2000 },

-  { 0x0700, 0x14ed, 0x0000 },

-  { 0x0700, 0x14ef, 0x0000 },

-  { 0x8700, 0x14f4, 0x3000 },

-  { 0x8700, 0x14f2, 0x2000 },

-  { 0x0700, 0x14f1, 0x0000 },

-  { 0x0700, 0x14f3, 0x0000 },

-  { 0x8700, 0x14f6, 0x2000 },

-  { 0x0700, 0x14f5, 0x0000 },

-  { 0x0700, 0x14f7, 0x0000 },

-  { 0x8700, 0x1508, 0x5000 },

-  { 0x8700, 0x1500, 0x4000 },

-  { 0x8700, 0x14fc, 0x3000 },

-  { 0x8700, 0x14fa, 0x2000 },

-  { 0x0700, 0x14f9, 0x0000 },

-  { 0x0700, 0x14fb, 0x0000 },

-  { 0x8700, 0x14fe, 0x2000 },

-  { 0x0700, 0x14fd, 0x0000 },

-  { 0x0700, 0x14ff, 0x0000 },

-  { 0x8700, 0x1504, 0x3000 },

-  { 0x8700, 0x1502, 0x2000 },

-  { 0x0700, 0x1501, 0x0000 },

-  { 0x0700, 0x1503, 0x0000 },

-  { 0x8700, 0x1506, 0x2000 },

-  { 0x0700, 0x1505, 0x0000 },

-  { 0x0700, 0x1507, 0x0000 },

-  { 0x8700, 0x1510, 0x4000 },

-  { 0x8700, 0x150c, 0x3000 },

-  { 0x8700, 0x150a, 0x2000 },

-  { 0x0700, 0x1509, 0x0000 },

-  { 0x0700, 0x150b, 0x0000 },

-  { 0x8700, 0x150e, 0x2000 },

-  { 0x0700, 0x150d, 0x0000 },

-  { 0x0700, 0x150f, 0x0000 },

-  { 0x8700, 0x1514, 0x3000 },

-  { 0x8700, 0x1512, 0x2000 },

-  { 0x0700, 0x1511, 0x0000 },

-  { 0x0700, 0x1513, 0x0000 },

-  { 0x8700, 0x1516, 0x2000 },

-  { 0x0700, 0x1515, 0x0000 },

-  { 0x0700, 0x1517, 0x0000 },

-  { 0x8700, 0x1538, 0x6000 },

-  { 0x8700, 0x1528, 0x5000 },

-  { 0x8700, 0x1520, 0x4000 },

-  { 0x8700, 0x151c, 0x3000 },

-  { 0x8700, 0x151a, 0x2000 },

-  { 0x0700, 0x1519, 0x0000 },

-  { 0x0700, 0x151b, 0x0000 },

-  { 0x8700, 0x151e, 0x2000 },

-  { 0x0700, 0x151d, 0x0000 },

-  { 0x0700, 0x151f, 0x0000 },

-  { 0x8700, 0x1524, 0x3000 },

-  { 0x8700, 0x1522, 0x2000 },

-  { 0x0700, 0x1521, 0x0000 },

-  { 0x0700, 0x1523, 0x0000 },

-  { 0x8700, 0x1526, 0x2000 },

-  { 0x0700, 0x1525, 0x0000 },

-  { 0x0700, 0x1527, 0x0000 },

-  { 0x8700, 0x1530, 0x4000 },

-  { 0x8700, 0x152c, 0x3000 },

-  { 0x8700, 0x152a, 0x2000 },

-  { 0x0700, 0x1529, 0x0000 },

-  { 0x0700, 0x152b, 0x0000 },

-  { 0x8700, 0x152e, 0x2000 },

-  { 0x0700, 0x152d, 0x0000 },

-  { 0x0700, 0x152f, 0x0000 },

-  { 0x8700, 0x1534, 0x3000 },

-  { 0x8700, 0x1532, 0x2000 },

-  { 0x0700, 0x1531, 0x0000 },

-  { 0x0700, 0x1533, 0x0000 },

-  { 0x8700, 0x1536, 0x2000 },

-  { 0x0700, 0x1535, 0x0000 },

-  { 0x0700, 0x1537, 0x0000 },

-  { 0x8700, 0x1548, 0x5000 },

-  { 0x8700, 0x1540, 0x4000 },

-  { 0x8700, 0x153c, 0x3000 },

-  { 0x8700, 0x153a, 0x2000 },

-  { 0x0700, 0x1539, 0x0000 },

-  { 0x0700, 0x153b, 0x0000 },

-  { 0x8700, 0x153e, 0x2000 },

-  { 0x0700, 0x153d, 0x0000 },

-  { 0x0700, 0x153f, 0x0000 },

-  { 0x8700, 0x1544, 0x3000 },

-  { 0x8700, 0x1542, 0x2000 },

-  { 0x0700, 0x1541, 0x0000 },

-  { 0x0700, 0x1543, 0x0000 },

-  { 0x8700, 0x1546, 0x2000 },

-  { 0x0700, 0x1545, 0x0000 },

-  { 0x0700, 0x1547, 0x0000 },

-  { 0x8700, 0x1550, 0x4000 },

-  { 0x8700, 0x154c, 0x3000 },

-  { 0x8700, 0x154a, 0x2000 },

-  { 0x0700, 0x1549, 0x0000 },

-  { 0x0700, 0x154b, 0x0000 },

-  { 0x8700, 0x154e, 0x2000 },

-  { 0x0700, 0x154d, 0x0000 },

-  { 0x0700, 0x154f, 0x0000 },

-  { 0x8700, 0x1554, 0x3000 },

-  { 0x8700, 0x1552, 0x2000 },

-  { 0x0700, 0x1551, 0x0000 },

-  { 0x0700, 0x1553, 0x0000 },

-  { 0x8700, 0x1556, 0x2000 },

-  { 0x0700, 0x1555, 0x0000 },

-  { 0x0700, 0x1557, 0x0000 },

-  { 0x9900, 0x22ae, 0xc000 },

-  { 0x8900, 0x1e24, 0xb001 },

-  { 0x8700, 0x17a2, 0xa000 },

-  { 0x8700, 0x1658, 0x9000 },

-  { 0x8700, 0x15d8, 0x8000 },

-  { 0x8700, 0x1598, 0x7000 },

-  { 0x8700, 0x1578, 0x6000 },

-  { 0x8700, 0x1568, 0x5000 },

-  { 0x8700, 0x1560, 0x4000 },

-  { 0x8700, 0x155c, 0x3000 },

-  { 0x8700, 0x155a, 0x2000 },

-  { 0x0700, 0x1559, 0x0000 },

-  { 0x0700, 0x155b, 0x0000 },

-  { 0x8700, 0x155e, 0x2000 },

-  { 0x0700, 0x155d, 0x0000 },

-  { 0x0700, 0x155f, 0x0000 },

-  { 0x8700, 0x1564, 0x3000 },

-  { 0x8700, 0x1562, 0x2000 },

-  { 0x0700, 0x1561, 0x0000 },

-  { 0x0700, 0x1563, 0x0000 },

-  { 0x8700, 0x1566, 0x2000 },

-  { 0x0700, 0x1565, 0x0000 },

-  { 0x0700, 0x1567, 0x0000 },

-  { 0x8700, 0x1570, 0x4000 },

-  { 0x8700, 0x156c, 0x3000 },

-  { 0x8700, 0x156a, 0x2000 },

-  { 0x0700, 0x1569, 0x0000 },

-  { 0x0700, 0x156b, 0x0000 },

-  { 0x8700, 0x156e, 0x2000 },

-  { 0x0700, 0x156d, 0x0000 },

-  { 0x0700, 0x156f, 0x0000 },

-  { 0x8700, 0x1574, 0x3000 },

-  { 0x8700, 0x1572, 0x2000 },

-  { 0x0700, 0x1571, 0x0000 },

-  { 0x0700, 0x1573, 0x0000 },

-  { 0x8700, 0x1576, 0x2000 },

-  { 0x0700, 0x1575, 0x0000 },

-  { 0x0700, 0x1577, 0x0000 },

-  { 0x8700, 0x1588, 0x5000 },

-  { 0x8700, 0x1580, 0x4000 },

-  { 0x8700, 0x157c, 0x3000 },

-  { 0x8700, 0x157a, 0x2000 },

-  { 0x0700, 0x1579, 0x0000 },

-  { 0x0700, 0x157b, 0x0000 },

-  { 0x8700, 0x157e, 0x2000 },

-  { 0x0700, 0x157d, 0x0000 },

-  { 0x0700, 0x157f, 0x0000 },

-  { 0x8700, 0x1584, 0x3000 },

-  { 0x8700, 0x1582, 0x2000 },

-  { 0x0700, 0x1581, 0x0000 },

-  { 0x0700, 0x1583, 0x0000 },

-  { 0x8700, 0x1586, 0x2000 },

-  { 0x0700, 0x1585, 0x0000 },

-  { 0x0700, 0x1587, 0x0000 },

-  { 0x8700, 0x1590, 0x4000 },

-  { 0x8700, 0x158c, 0x3000 },

-  { 0x8700, 0x158a, 0x2000 },

-  { 0x0700, 0x1589, 0x0000 },

-  { 0x0700, 0x158b, 0x0000 },

-  { 0x8700, 0x158e, 0x2000 },

-  { 0x0700, 0x158d, 0x0000 },

-  { 0x0700, 0x158f, 0x0000 },

-  { 0x8700, 0x1594, 0x3000 },

-  { 0x8700, 0x1592, 0x2000 },

-  { 0x0700, 0x1591, 0x0000 },

-  { 0x0700, 0x1593, 0x0000 },

-  { 0x8700, 0x1596, 0x2000 },

-  { 0x0700, 0x1595, 0x0000 },

-  { 0x0700, 0x1597, 0x0000 },

-  { 0x8700, 0x15b8, 0x6000 },

-  { 0x8700, 0x15a8, 0x5000 },

-  { 0x8700, 0x15a0, 0x4000 },

-  { 0x8700, 0x159c, 0x3000 },

-  { 0x8700, 0x159a, 0x2000 },

-  { 0x0700, 0x1599, 0x0000 },

-  { 0x0700, 0x159b, 0x0000 },

-  { 0x8700, 0x159e, 0x2000 },

-  { 0x0700, 0x159d, 0x0000 },

-  { 0x0700, 0x159f, 0x0000 },

-  { 0x8700, 0x15a4, 0x3000 },

-  { 0x8700, 0x15a2, 0x2000 },

-  { 0x0700, 0x15a1, 0x0000 },

-  { 0x0700, 0x15a3, 0x0000 },

-  { 0x8700, 0x15a6, 0x2000 },

-  { 0x0700, 0x15a5, 0x0000 },

-  { 0x0700, 0x15a7, 0x0000 },

-  { 0x8700, 0x15b0, 0x4000 },

-  { 0x8700, 0x15ac, 0x3000 },

-  { 0x8700, 0x15aa, 0x2000 },

-  { 0x0700, 0x15a9, 0x0000 },

-  { 0x0700, 0x15ab, 0x0000 },

-  { 0x8700, 0x15ae, 0x2000 },

-  { 0x0700, 0x15ad, 0x0000 },

-  { 0x0700, 0x15af, 0x0000 },

-  { 0x8700, 0x15b4, 0x3000 },

-  { 0x8700, 0x15b2, 0x2000 },

-  { 0x0700, 0x15b1, 0x0000 },

-  { 0x0700, 0x15b3, 0x0000 },

-  { 0x8700, 0x15b6, 0x2000 },

-  { 0x0700, 0x15b5, 0x0000 },

-  { 0x0700, 0x15b7, 0x0000 },

-  { 0x8700, 0x15c8, 0x5000 },

-  { 0x8700, 0x15c0, 0x4000 },

-  { 0x8700, 0x15bc, 0x3000 },

-  { 0x8700, 0x15ba, 0x2000 },

-  { 0x0700, 0x15b9, 0x0000 },

-  { 0x0700, 0x15bb, 0x0000 },

-  { 0x8700, 0x15be, 0x2000 },

-  { 0x0700, 0x15bd, 0x0000 },

-  { 0x0700, 0x15bf, 0x0000 },

-  { 0x8700, 0x15c4, 0x3000 },

-  { 0x8700, 0x15c2, 0x2000 },

-  { 0x0700, 0x15c1, 0x0000 },

-  { 0x0700, 0x15c3, 0x0000 },

-  { 0x8700, 0x15c6, 0x2000 },

-  { 0x0700, 0x15c5, 0x0000 },

-  { 0x0700, 0x15c7, 0x0000 },

-  { 0x8700, 0x15d0, 0x4000 },

-  { 0x8700, 0x15cc, 0x3000 },

-  { 0x8700, 0x15ca, 0x2000 },

-  { 0x0700, 0x15c9, 0x0000 },

-  { 0x0700, 0x15cb, 0x0000 },

-  { 0x8700, 0x15ce, 0x2000 },

-  { 0x0700, 0x15cd, 0x0000 },

-  { 0x0700, 0x15cf, 0x0000 },

-  { 0x8700, 0x15d4, 0x3000 },

-  { 0x8700, 0x15d2, 0x2000 },

-  { 0x0700, 0x15d1, 0x0000 },

-  { 0x0700, 0x15d3, 0x0000 },

-  { 0x8700, 0x15d6, 0x2000 },

-  { 0x0700, 0x15d5, 0x0000 },

-  { 0x0700, 0x15d7, 0x0000 },

-  { 0x8700, 0x1618, 0x7000 },

-  { 0x8700, 0x15f8, 0x6000 },

-  { 0x8700, 0x15e8, 0x5000 },

-  { 0x8700, 0x15e0, 0x4000 },

-  { 0x8700, 0x15dc, 0x3000 },

-  { 0x8700, 0x15da, 0x2000 },

-  { 0x0700, 0x15d9, 0x0000 },

-  { 0x0700, 0x15db, 0x0000 },

-  { 0x8700, 0x15de, 0x2000 },

-  { 0x0700, 0x15dd, 0x0000 },

-  { 0x0700, 0x15df, 0x0000 },

-  { 0x8700, 0x15e4, 0x3000 },

-  { 0x8700, 0x15e2, 0x2000 },

-  { 0x0700, 0x15e1, 0x0000 },

-  { 0x0700, 0x15e3, 0x0000 },

-  { 0x8700, 0x15e6, 0x2000 },

-  { 0x0700, 0x15e5, 0x0000 },

-  { 0x0700, 0x15e7, 0x0000 },

-  { 0x8700, 0x15f0, 0x4000 },

-  { 0x8700, 0x15ec, 0x3000 },

-  { 0x8700, 0x15ea, 0x2000 },

-  { 0x0700, 0x15e9, 0x0000 },

-  { 0x0700, 0x15eb, 0x0000 },

-  { 0x8700, 0x15ee, 0x2000 },

-  { 0x0700, 0x15ed, 0x0000 },

-  { 0x0700, 0x15ef, 0x0000 },

-  { 0x8700, 0x15f4, 0x3000 },

-  { 0x8700, 0x15f2, 0x2000 },

-  { 0x0700, 0x15f1, 0x0000 },

-  { 0x0700, 0x15f3, 0x0000 },

-  { 0x8700, 0x15f6, 0x2000 },

-  { 0x0700, 0x15f5, 0x0000 },

-  { 0x0700, 0x15f7, 0x0000 },

-  { 0x8700, 0x1608, 0x5000 },

-  { 0x8700, 0x1600, 0x4000 },

-  { 0x8700, 0x15fc, 0x3000 },

-  { 0x8700, 0x15fa, 0x2000 },

-  { 0x0700, 0x15f9, 0x0000 },

-  { 0x0700, 0x15fb, 0x0000 },

-  { 0x8700, 0x15fe, 0x2000 },

-  { 0x0700, 0x15fd, 0x0000 },

-  { 0x0700, 0x15ff, 0x0000 },

-  { 0x8700, 0x1604, 0x3000 },

-  { 0x8700, 0x1602, 0x2000 },

-  { 0x0700, 0x1601, 0x0000 },

-  { 0x0700, 0x1603, 0x0000 },

-  { 0x8700, 0x1606, 0x2000 },

-  { 0x0700, 0x1605, 0x0000 },

-  { 0x0700, 0x1607, 0x0000 },

-  { 0x8700, 0x1610, 0x4000 },

-  { 0x8700, 0x160c, 0x3000 },

-  { 0x8700, 0x160a, 0x2000 },

-  { 0x0700, 0x1609, 0x0000 },

-  { 0x0700, 0x160b, 0x0000 },

-  { 0x8700, 0x160e, 0x2000 },

-  { 0x0700, 0x160d, 0x0000 },

-  { 0x0700, 0x160f, 0x0000 },

-  { 0x8700, 0x1614, 0x3000 },

-  { 0x8700, 0x1612, 0x2000 },

-  { 0x0700, 0x1611, 0x0000 },

-  { 0x0700, 0x1613, 0x0000 },

-  { 0x8700, 0x1616, 0x2000 },

-  { 0x0700, 0x1615, 0x0000 },

-  { 0x0700, 0x1617, 0x0000 },

-  { 0x8700, 0x1638, 0x6000 },

-  { 0x8700, 0x1628, 0x5000 },

-  { 0x8700, 0x1620, 0x4000 },

-  { 0x8700, 0x161c, 0x3000 },

-  { 0x8700, 0x161a, 0x2000 },

-  { 0x0700, 0x1619, 0x0000 },

-  { 0x0700, 0x161b, 0x0000 },

-  { 0x8700, 0x161e, 0x2000 },

-  { 0x0700, 0x161d, 0x0000 },

-  { 0x0700, 0x161f, 0x0000 },

-  { 0x8700, 0x1624, 0x3000 },

-  { 0x8700, 0x1622, 0x2000 },

-  { 0x0700, 0x1621, 0x0000 },

-  { 0x0700, 0x1623, 0x0000 },

-  { 0x8700, 0x1626, 0x2000 },

-  { 0x0700, 0x1625, 0x0000 },

-  { 0x0700, 0x1627, 0x0000 },

-  { 0x8700, 0x1630, 0x4000 },

-  { 0x8700, 0x162c, 0x3000 },

-  { 0x8700, 0x162a, 0x2000 },

-  { 0x0700, 0x1629, 0x0000 },

-  { 0x0700, 0x162b, 0x0000 },

-  { 0x8700, 0x162e, 0x2000 },

-  { 0x0700, 0x162d, 0x0000 },

-  { 0x0700, 0x162f, 0x0000 },

-  { 0x8700, 0x1634, 0x3000 },

-  { 0x8700, 0x1632, 0x2000 },

-  { 0x0700, 0x1631, 0x0000 },

-  { 0x0700, 0x1633, 0x0000 },

-  { 0x8700, 0x1636, 0x2000 },

-  { 0x0700, 0x1635, 0x0000 },

-  { 0x0700, 0x1637, 0x0000 },

-  { 0x8700, 0x1648, 0x5000 },

-  { 0x8700, 0x1640, 0x4000 },

-  { 0x8700, 0x163c, 0x3000 },

-  { 0x8700, 0x163a, 0x2000 },

-  { 0x0700, 0x1639, 0x0000 },

-  { 0x0700, 0x163b, 0x0000 },

-  { 0x8700, 0x163e, 0x2000 },

-  { 0x0700, 0x163d, 0x0000 },

-  { 0x0700, 0x163f, 0x0000 },

-  { 0x8700, 0x1644, 0x3000 },

-  { 0x8700, 0x1642, 0x2000 },

-  { 0x0700, 0x1641, 0x0000 },

-  { 0x0700, 0x1643, 0x0000 },

-  { 0x8700, 0x1646, 0x2000 },

-  { 0x0700, 0x1645, 0x0000 },

-  { 0x0700, 0x1647, 0x0000 },

-  { 0x8700, 0x1650, 0x4000 },

-  { 0x8700, 0x164c, 0x3000 },

-  { 0x8700, 0x164a, 0x2000 },

-  { 0x0700, 0x1649, 0x0000 },

-  { 0x0700, 0x164b, 0x0000 },

-  { 0x8700, 0x164e, 0x2000 },

-  { 0x0700, 0x164d, 0x0000 },

-  { 0x0700, 0x164f, 0x0000 },

-  { 0x8700, 0x1654, 0x3000 },

-  { 0x8700, 0x1652, 0x2000 },

-  { 0x0700, 0x1651, 0x0000 },

-  { 0x0700, 0x1653, 0x0000 },

-  { 0x8700, 0x1656, 0x2000 },

-  { 0x0700, 0x1655, 0x0000 },

-  { 0x0700, 0x1657, 0x0000 },

-  { 0x8700, 0x16e4, 0x8000 },

-  { 0x8700, 0x16a4, 0x7000 },

-  { 0x8700, 0x1681, 0x6000 },

-  { 0x8700, 0x1668, 0x5000 },

-  { 0x8700, 0x1660, 0x4000 },

-  { 0x8700, 0x165c, 0x3000 },

-  { 0x8700, 0x165a, 0x2000 },

-  { 0x0700, 0x1659, 0x0000 },

-  { 0x0700, 0x165b, 0x0000 },

-  { 0x8700, 0x165e, 0x2000 },

-  { 0x0700, 0x165d, 0x0000 },

-  { 0x0700, 0x165f, 0x0000 },

-  { 0x8700, 0x1664, 0x3000 },

-  { 0x8700, 0x1662, 0x2000 },

-  { 0x0700, 0x1661, 0x0000 },

-  { 0x0700, 0x1663, 0x0000 },

-  { 0x8700, 0x1666, 0x2000 },

-  { 0x0700, 0x1665, 0x0000 },

-  { 0x0700, 0x1667, 0x0000 },

-  { 0x8700, 0x1670, 0x4000 },

-  { 0x8700, 0x166c, 0x3000 },

-  { 0x8700, 0x166a, 0x2000 },

-  { 0x0700, 0x1669, 0x0000 },

-  { 0x0700, 0x166b, 0x0000 },

-  { 0x9500, 0x166e, 0x2000 },

-  { 0x1500, 0x166d, 0x0000 },

-  { 0x0700, 0x166f, 0x0000 },

-  { 0x8700, 0x1674, 0x3000 },

-  { 0x8700, 0x1672, 0x2000 },

-  { 0x0700, 0x1671, 0x0000 },

-  { 0x0700, 0x1673, 0x0000 },

-  { 0x8700, 0x1676, 0x2000 },

-  { 0x0700, 0x1675, 0x0000 },

-  { 0x1d00, 0x1680, 0x0000 },

-  { 0x8700, 0x1691, 0x5000 },

-  { 0x8700, 0x1689, 0x4000 },

-  { 0x8700, 0x1685, 0x3000 },

-  { 0x8700, 0x1683, 0x2000 },

-  { 0x0700, 0x1682, 0x0000 },

-  { 0x0700, 0x1684, 0x0000 },

-  { 0x8700, 0x1687, 0x2000 },

-  { 0x0700, 0x1686, 0x0000 },

-  { 0x0700, 0x1688, 0x0000 },

-  { 0x8700, 0x168d, 0x3000 },

-  { 0x8700, 0x168b, 0x2000 },

-  { 0x0700, 0x168a, 0x0000 },

-  { 0x0700, 0x168c, 0x0000 },

-  { 0x8700, 0x168f, 0x2000 },

-  { 0x0700, 0x168e, 0x0000 },

-  { 0x0700, 0x1690, 0x0000 },

-  { 0x8700, 0x1699, 0x4000 },

-  { 0x8700, 0x1695, 0x3000 },

-  { 0x8700, 0x1693, 0x2000 },

-  { 0x0700, 0x1692, 0x0000 },

-  { 0x0700, 0x1694, 0x0000 },

-  { 0x8700, 0x1697, 0x2000 },

-  { 0x0700, 0x1696, 0x0000 },

-  { 0x0700, 0x1698, 0x0000 },

-  { 0x8700, 0x16a0, 0x3000 },

-  { 0x9600, 0x169b, 0x2000 },

-  { 0x0700, 0x169a, 0x0000 },

-  { 0x1200, 0x169c, 0x0000 },

-  { 0x8700, 0x16a2, 0x2000 },

-  { 0x0700, 0x16a1, 0x0000 },

-  { 0x0700, 0x16a3, 0x0000 },

-  { 0x8700, 0x16c4, 0x6000 },

-  { 0x8700, 0x16b4, 0x5000 },

-  { 0x8700, 0x16ac, 0x4000 },

-  { 0x8700, 0x16a8, 0x3000 },

-  { 0x8700, 0x16a6, 0x2000 },

-  { 0x0700, 0x16a5, 0x0000 },

-  { 0x0700, 0x16a7, 0x0000 },

-  { 0x8700, 0x16aa, 0x2000 },

-  { 0x0700, 0x16a9, 0x0000 },

-  { 0x0700, 0x16ab, 0x0000 },

-  { 0x8700, 0x16b0, 0x3000 },

-  { 0x8700, 0x16ae, 0x2000 },

-  { 0x0700, 0x16ad, 0x0000 },

-  { 0x0700, 0x16af, 0x0000 },

-  { 0x8700, 0x16b2, 0x2000 },

-  { 0x0700, 0x16b1, 0x0000 },

-  { 0x0700, 0x16b3, 0x0000 },

-  { 0x8700, 0x16bc, 0x4000 },

-  { 0x8700, 0x16b8, 0x3000 },

-  { 0x8700, 0x16b6, 0x2000 },

-  { 0x0700, 0x16b5, 0x0000 },

-  { 0x0700, 0x16b7, 0x0000 },

-  { 0x8700, 0x16ba, 0x2000 },

-  { 0x0700, 0x16b9, 0x0000 },

-  { 0x0700, 0x16bb, 0x0000 },

-  { 0x8700, 0x16c0, 0x3000 },

-  { 0x8700, 0x16be, 0x2000 },

-  { 0x0700, 0x16bd, 0x0000 },

-  { 0x0700, 0x16bf, 0x0000 },

-  { 0x8700, 0x16c2, 0x2000 },

-  { 0x0700, 0x16c1, 0x0000 },

-  { 0x0700, 0x16c3, 0x0000 },

-  { 0x8700, 0x16d4, 0x5000 },

-  { 0x8700, 0x16cc, 0x4000 },

-  { 0x8700, 0x16c8, 0x3000 },

-  { 0x8700, 0x16c6, 0x2000 },

-  { 0x0700, 0x16c5, 0x0000 },

-  { 0x0700, 0x16c7, 0x0000 },

-  { 0x8700, 0x16ca, 0x2000 },

-  { 0x0700, 0x16c9, 0x0000 },

-  { 0x0700, 0x16cb, 0x0000 },

-  { 0x8700, 0x16d0, 0x3000 },

-  { 0x8700, 0x16ce, 0x2000 },

-  { 0x0700, 0x16cd, 0x0000 },

-  { 0x0700, 0x16cf, 0x0000 },

-  { 0x8700, 0x16d2, 0x2000 },

-  { 0x0700, 0x16d1, 0x0000 },

-  { 0x0700, 0x16d3, 0x0000 },

-  { 0x8700, 0x16dc, 0x4000 },

-  { 0x8700, 0x16d8, 0x3000 },

-  { 0x8700, 0x16d6, 0x2000 },

-  { 0x0700, 0x16d5, 0x0000 },

-  { 0x0700, 0x16d7, 0x0000 },

-  { 0x8700, 0x16da, 0x2000 },

-  { 0x0700, 0x16d9, 0x0000 },

-  { 0x0700, 0x16db, 0x0000 },

-  { 0x8700, 0x16e0, 0x3000 },

-  { 0x8700, 0x16de, 0x2000 },

-  { 0x0700, 0x16dd, 0x0000 },

-  { 0x0700, 0x16df, 0x0000 },

-  { 0x8700, 0x16e2, 0x2000 },

-  { 0x0700, 0x16e1, 0x0000 },

-  { 0x0700, 0x16e3, 0x0000 },

-  { 0x8700, 0x1748, 0x7000 },

-  { 0x8c00, 0x1714, 0x6000 },

-  { 0x8700, 0x1703, 0x5000 },

-  { 0x9500, 0x16ec, 0x4000 },

-  { 0x8700, 0x16e8, 0x3000 },

-  { 0x8700, 0x16e6, 0x2000 },

-  { 0x0700, 0x16e5, 0x0000 },

-  { 0x0700, 0x16e7, 0x0000 },

-  { 0x8700, 0x16ea, 0x2000 },

-  { 0x0700, 0x16e9, 0x0000 },

-  { 0x1500, 0x16eb, 0x0000 },

-  { 0x8e00, 0x16f0, 0x3000 },

-  { 0x8e00, 0x16ee, 0x2000 },

-  { 0x1500, 0x16ed, 0x0000 },

-  { 0x0e00, 0x16ef, 0x0000 },

-  { 0x8700, 0x1701, 0x2000 },

-  { 0x0700, 0x1700, 0x0000 },

-  { 0x0700, 0x1702, 0x0000 },

-  { 0x8700, 0x170b, 0x4000 },

-  { 0x8700, 0x1707, 0x3000 },

-  { 0x8700, 0x1705, 0x2000 },

-  { 0x0700, 0x1704, 0x0000 },

-  { 0x0700, 0x1706, 0x0000 },

-  { 0x8700, 0x1709, 0x2000 },

-  { 0x0700, 0x1708, 0x0000 },

-  { 0x0700, 0x170a, 0x0000 },

-  { 0x8700, 0x1710, 0x3000 },

-  { 0x8700, 0x170e, 0x2000 },

-  { 0x0700, 0x170c, 0x0000 },

-  { 0x0700, 0x170f, 0x0000 },

-  { 0x8c00, 0x1712, 0x2000 },

-  { 0x0700, 0x1711, 0x0000 },

-  { 0x0c00, 0x1713, 0x0000 },

-  { 0x8700, 0x172f, 0x5000 },

-  { 0x8700, 0x1727, 0x4000 },

-  { 0x8700, 0x1723, 0x3000 },

-  { 0x8700, 0x1721, 0x2000 },

-  { 0x0700, 0x1720, 0x0000 },

-  { 0x0700, 0x1722, 0x0000 },

-  { 0x8700, 0x1725, 0x2000 },

-  { 0x0700, 0x1724, 0x0000 },

-  { 0x0700, 0x1726, 0x0000 },

-  { 0x8700, 0x172b, 0x3000 },

-  { 0x8700, 0x1729, 0x2000 },

-  { 0x0700, 0x1728, 0x0000 },

-  { 0x0700, 0x172a, 0x0000 },

-  { 0x8700, 0x172d, 0x2000 },

-  { 0x0700, 0x172c, 0x0000 },

-  { 0x0700, 0x172e, 0x0000 },

-  { 0x8700, 0x1740, 0x4000 },

-  { 0x8c00, 0x1733, 0x3000 },

-  { 0x8700, 0x1731, 0x2000 },

-  { 0x0700, 0x1730, 0x0000 },

-  { 0x0c00, 0x1732, 0x0000 },

-  { 0x9500, 0x1735, 0x2000 },

-  { 0x0c00, 0x1734, 0x0000 },

-  { 0x1500, 0x1736, 0x0000 },

-  { 0x8700, 0x1744, 0x3000 },

-  { 0x8700, 0x1742, 0x2000 },

-  { 0x0700, 0x1741, 0x0000 },

-  { 0x0700, 0x1743, 0x0000 },

-  { 0x8700, 0x1746, 0x2000 },

-  { 0x0700, 0x1745, 0x0000 },

-  { 0x0700, 0x1747, 0x0000 },

-  { 0x8700, 0x1782, 0x6000 },

-  { 0x8700, 0x1764, 0x5000 },

-  { 0x8700, 0x1750, 0x4000 },

-  { 0x8700, 0x174c, 0x3000 },

-  { 0x8700, 0x174a, 0x2000 },

-  { 0x0700, 0x1749, 0x0000 },

-  { 0x0700, 0x174b, 0x0000 },

-  { 0x8700, 0x174e, 0x2000 },

-  { 0x0700, 0x174d, 0x0000 },

-  { 0x0700, 0x174f, 0x0000 },

-  { 0x8700, 0x1760, 0x3000 },

-  { 0x8c00, 0x1752, 0x2000 },

-  { 0x0700, 0x1751, 0x0000 },

-  { 0x0c00, 0x1753, 0x0000 },

-  { 0x8700, 0x1762, 0x2000 },

-  { 0x0700, 0x1761, 0x0000 },

-  { 0x0700, 0x1763, 0x0000 },

-  { 0x8700, 0x176c, 0x4000 },

-  { 0x8700, 0x1768, 0x3000 },

-  { 0x8700, 0x1766, 0x2000 },

-  { 0x0700, 0x1765, 0x0000 },

-  { 0x0700, 0x1767, 0x0000 },

-  { 0x8700, 0x176a, 0x2000 },

-  { 0x0700, 0x1769, 0x0000 },

-  { 0x0700, 0x176b, 0x0000 },

-  { 0x8c00, 0x1772, 0x3000 },

-  { 0x8700, 0x176f, 0x2000 },

-  { 0x0700, 0x176e, 0x0000 },

-  { 0x0700, 0x1770, 0x0000 },

-  { 0x8700, 0x1780, 0x2000 },

-  { 0x0c00, 0x1773, 0x0000 },

-  { 0x0700, 0x1781, 0x0000 },

-  { 0x8700, 0x1792, 0x5000 },

-  { 0x8700, 0x178a, 0x4000 },

-  { 0x8700, 0x1786, 0x3000 },

-  { 0x8700, 0x1784, 0x2000 },

-  { 0x0700, 0x1783, 0x0000 },

-  { 0x0700, 0x1785, 0x0000 },

-  { 0x8700, 0x1788, 0x2000 },

-  { 0x0700, 0x1787, 0x0000 },

-  { 0x0700, 0x1789, 0x0000 },

-  { 0x8700, 0x178e, 0x3000 },

-  { 0x8700, 0x178c, 0x2000 },

-  { 0x0700, 0x178b, 0x0000 },

-  { 0x0700, 0x178d, 0x0000 },

-  { 0x8700, 0x1790, 0x2000 },

-  { 0x0700, 0x178f, 0x0000 },

-  { 0x0700, 0x1791, 0x0000 },

-  { 0x8700, 0x179a, 0x4000 },

-  { 0x8700, 0x1796, 0x3000 },

-  { 0x8700, 0x1794, 0x2000 },

-  { 0x0700, 0x1793, 0x0000 },

-  { 0x0700, 0x1795, 0x0000 },

-  { 0x8700, 0x1798, 0x2000 },

-  { 0x0700, 0x1797, 0x0000 },

-  { 0x0700, 0x1799, 0x0000 },

-  { 0x8700, 0x179e, 0x3000 },

-  { 0x8700, 0x179c, 0x2000 },

-  { 0x0700, 0x179b, 0x0000 },

-  { 0x0700, 0x179d, 0x0000 },

-  { 0x8700, 0x17a0, 0x2000 },

-  { 0x0700, 0x179f, 0x0000 },

-  { 0x0700, 0x17a1, 0x0000 },

-  { 0x8700, 0x1915, 0x9000 },

-  { 0x8700, 0x1837, 0x8000 },

-  { 0x8d00, 0x17e4, 0x7000 },

-  { 0x8a00, 0x17c2, 0x6000 },

-  { 0x8700, 0x17b2, 0x5000 },

-  { 0x8700, 0x17aa, 0x4000 },

-  { 0x8700, 0x17a6, 0x3000 },

-  { 0x8700, 0x17a4, 0x2000 },

-  { 0x0700, 0x17a3, 0x0000 },

-  { 0x0700, 0x17a5, 0x0000 },

-  { 0x8700, 0x17a8, 0x2000 },

-  { 0x0700, 0x17a7, 0x0000 },

-  { 0x0700, 0x17a9, 0x0000 },

-  { 0x8700, 0x17ae, 0x3000 },

-  { 0x8700, 0x17ac, 0x2000 },

-  { 0x0700, 0x17ab, 0x0000 },

-  { 0x0700, 0x17ad, 0x0000 },

-  { 0x8700, 0x17b0, 0x2000 },

-  { 0x0700, 0x17af, 0x0000 },

-  { 0x0700, 0x17b1, 0x0000 },

-  { 0x8c00, 0x17ba, 0x4000 },

-  { 0x8a00, 0x17b6, 0x3000 },

-  { 0x8100, 0x17b4, 0x2000 },

-  { 0x0700, 0x17b3, 0x0000 },

-  { 0x0100, 0x17b5, 0x0000 },

-  { 0x8c00, 0x17b8, 0x2000 },

-  { 0x0c00, 0x17b7, 0x0000 },

-  { 0x0c00, 0x17b9, 0x0000 },

-  { 0x8a00, 0x17be, 0x3000 },

-  { 0x8c00, 0x17bc, 0x2000 },

-  { 0x0c00, 0x17bb, 0x0000 },

-  { 0x0c00, 0x17bd, 0x0000 },

-  { 0x8a00, 0x17c0, 0x2000 },

-  { 0x0a00, 0x17bf, 0x0000 },

-  { 0x0a00, 0x17c1, 0x0000 },

-  { 0x8c00, 0x17d2, 0x5000 },

-  { 0x8c00, 0x17ca, 0x4000 },

-  { 0x8c00, 0x17c6, 0x3000 },

-  { 0x8a00, 0x17c4, 0x2000 },

-  { 0x0a00, 0x17c3, 0x0000 },

-  { 0x0a00, 0x17c5, 0x0000 },

-  { 0x8a00, 0x17c8, 0x2000 },

-  { 0x0a00, 0x17c7, 0x0000 },

-  { 0x0c00, 0x17c9, 0x0000 },

-  { 0x8c00, 0x17ce, 0x3000 },

-  { 0x8c00, 0x17cc, 0x2000 },

-  { 0x0c00, 0x17cb, 0x0000 },

-  { 0x0c00, 0x17cd, 0x0000 },

-  { 0x8c00, 0x17d0, 0x2000 },

-  { 0x0c00, 0x17cf, 0x0000 },

-  { 0x0c00, 0x17d1, 0x0000 },

-  { 0x9500, 0x17da, 0x4000 },

-  { 0x9500, 0x17d6, 0x3000 },

-  { 0x9500, 0x17d4, 0x2000 },

-  { 0x0c00, 0x17d3, 0x0000 },

-  { 0x1500, 0x17d5, 0x0000 },

-  { 0x9500, 0x17d8, 0x2000 },

-  { 0x0600, 0x17d7, 0x0000 },

-  { 0x1500, 0x17d9, 0x0000 },

-  { 0x8d00, 0x17e0, 0x3000 },

-  { 0x8700, 0x17dc, 0x2000 },

-  { 0x1700, 0x17db, 0x0000 },

-  { 0x0c00, 0x17dd, 0x0000 },

-  { 0x8d00, 0x17e2, 0x2000 },

-  { 0x0d00, 0x17e1, 0x0000 },

-  { 0x0d00, 0x17e3, 0x0000 },

-  { 0x8d00, 0x1811, 0x6000 },

-  { 0x9500, 0x1800, 0x5000 },

-  { 0x8f00, 0x17f2, 0x4000 },

-  { 0x8d00, 0x17e8, 0x3000 },

-  { 0x8d00, 0x17e6, 0x2000 },

-  { 0x0d00, 0x17e5, 0x0000 },

-  { 0x0d00, 0x17e7, 0x0000 },

-  { 0x8f00, 0x17f0, 0x2000 },

-  { 0x0d00, 0x17e9, 0x0000 },

-  { 0x0f00, 0x17f1, 0x0000 },

-  { 0x8f00, 0x17f6, 0x3000 },

-  { 0x8f00, 0x17f4, 0x2000 },

-  { 0x0f00, 0x17f3, 0x0000 },

-  { 0x0f00, 0x17f5, 0x0000 },

-  { 0x8f00, 0x17f8, 0x2000 },

-  { 0x0f00, 0x17f7, 0x0000 },

-  { 0x0f00, 0x17f9, 0x0000 },

-  { 0x9500, 0x1808, 0x4000 },

-  { 0x9500, 0x1804, 0x3000 },

-  { 0x9500, 0x1802, 0x2000 },

-  { 0x1500, 0x1801, 0x0000 },

-  { 0x1500, 0x1803, 0x0000 },

-  { 0x9100, 0x1806, 0x2000 },

-  { 0x1500, 0x1805, 0x0000 },

-  { 0x1500, 0x1807, 0x0000 },

-  { 0x8c00, 0x180c, 0x3000 },

-  { 0x9500, 0x180a, 0x2000 },

-  { 0x1500, 0x1809, 0x0000 },

-  { 0x0c00, 0x180b, 0x0000 },

-  { 0x9d00, 0x180e, 0x2000 },

-  { 0x0c00, 0x180d, 0x0000 },

-  { 0x0d00, 0x1810, 0x0000 },

-  { 0x8700, 0x1827, 0x5000 },

-  { 0x8d00, 0x1819, 0x4000 },

-  { 0x8d00, 0x1815, 0x3000 },

-  { 0x8d00, 0x1813, 0x2000 },

-  { 0x0d00, 0x1812, 0x0000 },

-  { 0x0d00, 0x1814, 0x0000 },

-  { 0x8d00, 0x1817, 0x2000 },

-  { 0x0d00, 0x1816, 0x0000 },

-  { 0x0d00, 0x1818, 0x0000 },

-  { 0x8700, 0x1823, 0x3000 },

-  { 0x8700, 0x1821, 0x2000 },

-  { 0x0700, 0x1820, 0x0000 },

-  { 0x0700, 0x1822, 0x0000 },

-  { 0x8700, 0x1825, 0x2000 },

-  { 0x0700, 0x1824, 0x0000 },

-  { 0x0700, 0x1826, 0x0000 },

-  { 0x8700, 0x182f, 0x4000 },

-  { 0x8700, 0x182b, 0x3000 },

-  { 0x8700, 0x1829, 0x2000 },

-  { 0x0700, 0x1828, 0x0000 },

-  { 0x0700, 0x182a, 0x0000 },

-  { 0x8700, 0x182d, 0x2000 },

-  { 0x0700, 0x182c, 0x0000 },

-  { 0x0700, 0x182e, 0x0000 },

-  { 0x8700, 0x1833, 0x3000 },

-  { 0x8700, 0x1831, 0x2000 },

-  { 0x0700, 0x1830, 0x0000 },

-  { 0x0700, 0x1832, 0x0000 },

-  { 0x8700, 0x1835, 0x2000 },

-  { 0x0700, 0x1834, 0x0000 },

-  { 0x0700, 0x1836, 0x0000 },

-  { 0x8700, 0x1877, 0x7000 },

-  { 0x8700, 0x1857, 0x6000 },

-  { 0x8700, 0x1847, 0x5000 },

-  { 0x8700, 0x183f, 0x4000 },

-  { 0x8700, 0x183b, 0x3000 },

-  { 0x8700, 0x1839, 0x2000 },

-  { 0x0700, 0x1838, 0x0000 },

-  { 0x0700, 0x183a, 0x0000 },

-  { 0x8700, 0x183d, 0x2000 },

-  { 0x0700, 0x183c, 0x0000 },

-  { 0x0700, 0x183e, 0x0000 },

-  { 0x8600, 0x1843, 0x3000 },

-  { 0x8700, 0x1841, 0x2000 },

-  { 0x0700, 0x1840, 0x0000 },

-  { 0x0700, 0x1842, 0x0000 },

-  { 0x8700, 0x1845, 0x2000 },

-  { 0x0700, 0x1844, 0x0000 },

-  { 0x0700, 0x1846, 0x0000 },

-  { 0x8700, 0x184f, 0x4000 },

-  { 0x8700, 0x184b, 0x3000 },

-  { 0x8700, 0x1849, 0x2000 },

-  { 0x0700, 0x1848, 0x0000 },

-  { 0x0700, 0x184a, 0x0000 },

-  { 0x8700, 0x184d, 0x2000 },

-  { 0x0700, 0x184c, 0x0000 },

-  { 0x0700, 0x184e, 0x0000 },

-  { 0x8700, 0x1853, 0x3000 },

-  { 0x8700, 0x1851, 0x2000 },

-  { 0x0700, 0x1850, 0x0000 },

-  { 0x0700, 0x1852, 0x0000 },

-  { 0x8700, 0x1855, 0x2000 },

-  { 0x0700, 0x1854, 0x0000 },

-  { 0x0700, 0x1856, 0x0000 },

-  { 0x8700, 0x1867, 0x5000 },

-  { 0x8700, 0x185f, 0x4000 },

-  { 0x8700, 0x185b, 0x3000 },

-  { 0x8700, 0x1859, 0x2000 },

-  { 0x0700, 0x1858, 0x0000 },

-  { 0x0700, 0x185a, 0x0000 },

-  { 0x8700, 0x185d, 0x2000 },

-  { 0x0700, 0x185c, 0x0000 },

-  { 0x0700, 0x185e, 0x0000 },

-  { 0x8700, 0x1863, 0x3000 },

-  { 0x8700, 0x1861, 0x2000 },

-  { 0x0700, 0x1860, 0x0000 },

-  { 0x0700, 0x1862, 0x0000 },

-  { 0x8700, 0x1865, 0x2000 },

-  { 0x0700, 0x1864, 0x0000 },

-  { 0x0700, 0x1866, 0x0000 },

-  { 0x8700, 0x186f, 0x4000 },

-  { 0x8700, 0x186b, 0x3000 },

-  { 0x8700, 0x1869, 0x2000 },

-  { 0x0700, 0x1868, 0x0000 },

-  { 0x0700, 0x186a, 0x0000 },

-  { 0x8700, 0x186d, 0x2000 },

-  { 0x0700, 0x186c, 0x0000 },

-  { 0x0700, 0x186e, 0x0000 },

-  { 0x8700, 0x1873, 0x3000 },

-  { 0x8700, 0x1871, 0x2000 },

-  { 0x0700, 0x1870, 0x0000 },

-  { 0x0700, 0x1872, 0x0000 },

-  { 0x8700, 0x1875, 0x2000 },

-  { 0x0700, 0x1874, 0x0000 },

-  { 0x0700, 0x1876, 0x0000 },

-  { 0x8700, 0x189f, 0x6000 },

-  { 0x8700, 0x188f, 0x5000 },

-  { 0x8700, 0x1887, 0x4000 },

-  { 0x8700, 0x1883, 0x3000 },

-  { 0x8700, 0x1881, 0x2000 },

-  { 0x0700, 0x1880, 0x0000 },

-  { 0x0700, 0x1882, 0x0000 },

-  { 0x8700, 0x1885, 0x2000 },

-  { 0x0700, 0x1884, 0x0000 },

-  { 0x0700, 0x1886, 0x0000 },

-  { 0x8700, 0x188b, 0x3000 },

-  { 0x8700, 0x1889, 0x2000 },

-  { 0x0700, 0x1888, 0x0000 },

-  { 0x0700, 0x188a, 0x0000 },

-  { 0x8700, 0x188d, 0x2000 },

-  { 0x0700, 0x188c, 0x0000 },

-  { 0x0700, 0x188e, 0x0000 },

-  { 0x8700, 0x1897, 0x4000 },

-  { 0x8700, 0x1893, 0x3000 },

-  { 0x8700, 0x1891, 0x2000 },

-  { 0x0700, 0x1890, 0x0000 },

-  { 0x0700, 0x1892, 0x0000 },

-  { 0x8700, 0x1895, 0x2000 },

-  { 0x0700, 0x1894, 0x0000 },

-  { 0x0700, 0x1896, 0x0000 },

-  { 0x8700, 0x189b, 0x3000 },

-  { 0x8700, 0x1899, 0x2000 },

-  { 0x0700, 0x1898, 0x0000 },

-  { 0x0700, 0x189a, 0x0000 },

-  { 0x8700, 0x189d, 0x2000 },

-  { 0x0700, 0x189c, 0x0000 },

-  { 0x0700, 0x189e, 0x0000 },

-  { 0x8700, 0x1905, 0x5000 },

-  { 0x8700, 0x18a7, 0x4000 },

-  { 0x8700, 0x18a3, 0x3000 },

-  { 0x8700, 0x18a1, 0x2000 },

-  { 0x0700, 0x18a0, 0x0000 },

-  { 0x0700, 0x18a2, 0x0000 },

-  { 0x8700, 0x18a5, 0x2000 },

-  { 0x0700, 0x18a4, 0x0000 },

-  { 0x0700, 0x18a6, 0x0000 },

-  { 0x8700, 0x1901, 0x3000 },

-  { 0x8c00, 0x18a9, 0x2000 },

-  { 0x0700, 0x18a8, 0x0000 },

-  { 0x0700, 0x1900, 0x0000 },

-  { 0x8700, 0x1903, 0x2000 },

-  { 0x0700, 0x1902, 0x0000 },

-  { 0x0700, 0x1904, 0x0000 },

-  { 0x8700, 0x190d, 0x4000 },

-  { 0x8700, 0x1909, 0x3000 },

-  { 0x8700, 0x1907, 0x2000 },

-  { 0x0700, 0x1906, 0x0000 },

-  { 0x0700, 0x1908, 0x0000 },

-  { 0x8700, 0x190b, 0x2000 },

-  { 0x0700, 0x190a, 0x0000 },

-  { 0x0700, 0x190c, 0x0000 },

-  { 0x8700, 0x1911, 0x3000 },

-  { 0x8700, 0x190f, 0x2000 },

-  { 0x0700, 0x190e, 0x0000 },

-  { 0x0700, 0x1910, 0x0000 },

-  { 0x8700, 0x1913, 0x2000 },

-  { 0x0700, 0x1912, 0x0000 },

-  { 0x0700, 0x1914, 0x0000 },

-  { 0x8500, 0x1d10, 0x8000 },

-  { 0x8700, 0x1963, 0x7000 },

-  { 0x9a00, 0x1940, 0x6000 },

-  { 0x8c00, 0x1928, 0x5000 },

-  { 0x8c00, 0x1920, 0x4000 },

-  { 0x8700, 0x1919, 0x3000 },

-  { 0x8700, 0x1917, 0x2000 },

-  { 0x0700, 0x1916, 0x0000 },

-  { 0x0700, 0x1918, 0x0000 },

-  { 0x8700, 0x191b, 0x2000 },

-  { 0x0700, 0x191a, 0x0000 },

-  { 0x0700, 0x191c, 0x0000 },

-  { 0x8a00, 0x1924, 0x3000 },

-  { 0x8c00, 0x1922, 0x2000 },

-  { 0x0c00, 0x1921, 0x0000 },

-  { 0x0a00, 0x1923, 0x0000 },

-  { 0x8a00, 0x1926, 0x2000 },

-  { 0x0a00, 0x1925, 0x0000 },

-  { 0x0c00, 0x1927, 0x0000 },

-  { 0x8a00, 0x1934, 0x4000 },

-  { 0x8a00, 0x1930, 0x3000 },

-  { 0x8a00, 0x192a, 0x2000 },

-  { 0x0a00, 0x1929, 0x0000 },

-  { 0x0a00, 0x192b, 0x0000 },

-  { 0x8c00, 0x1932, 0x2000 },

-  { 0x0a00, 0x1931, 0x0000 },

-  { 0x0a00, 0x1933, 0x0000 },

-  { 0x8a00, 0x1938, 0x3000 },

-  { 0x8a00, 0x1936, 0x2000 },

-  { 0x0a00, 0x1935, 0x0000 },

-  { 0x0a00, 0x1937, 0x0000 },

-  { 0x8c00, 0x193a, 0x2000 },

-  { 0x0c00, 0x1939, 0x0000 },

-  { 0x0c00, 0x193b, 0x0000 },

-  { 0x8700, 0x1953, 0x5000 },

-  { 0x8d00, 0x194b, 0x4000 },

-  { 0x8d00, 0x1947, 0x3000 },

-  { 0x9500, 0x1945, 0x2000 },

-  { 0x1500, 0x1944, 0x0000 },

-  { 0x0d00, 0x1946, 0x0000 },

-  { 0x8d00, 0x1949, 0x2000 },

-  { 0x0d00, 0x1948, 0x0000 },

-  { 0x0d00, 0x194a, 0x0000 },

-  { 0x8d00, 0x194f, 0x3000 },

-  { 0x8d00, 0x194d, 0x2000 },

-  { 0x0d00, 0x194c, 0x0000 },

-  { 0x0d00, 0x194e, 0x0000 },

-  { 0x8700, 0x1951, 0x2000 },

-  { 0x0700, 0x1950, 0x0000 },

-  { 0x0700, 0x1952, 0x0000 },

-  { 0x8700, 0x195b, 0x4000 },

-  { 0x8700, 0x1957, 0x3000 },

-  { 0x8700, 0x1955, 0x2000 },

-  { 0x0700, 0x1954, 0x0000 },

-  { 0x0700, 0x1956, 0x0000 },

-  { 0x8700, 0x1959, 0x2000 },

-  { 0x0700, 0x1958, 0x0000 },

-  { 0x0700, 0x195a, 0x0000 },

-  { 0x8700, 0x195f, 0x3000 },

-  { 0x8700, 0x195d, 0x2000 },

-  { 0x0700, 0x195c, 0x0000 },

-  { 0x0700, 0x195e, 0x0000 },

-  { 0x8700, 0x1961, 0x2000 },

-  { 0x0700, 0x1960, 0x0000 },

-  { 0x0700, 0x1962, 0x0000 },

-  { 0x9a00, 0x19f0, 0x6000 },

-  { 0x9a00, 0x19e0, 0x5000 },

-  { 0x8700, 0x196b, 0x4000 },

-  { 0x8700, 0x1967, 0x3000 },

-  { 0x8700, 0x1965, 0x2000 },

-  { 0x0700, 0x1964, 0x0000 },

-  { 0x0700, 0x1966, 0x0000 },

-  { 0x8700, 0x1969, 0x2000 },

-  { 0x0700, 0x1968, 0x0000 },

-  { 0x0700, 0x196a, 0x0000 },

-  { 0x8700, 0x1971, 0x3000 },

-  { 0x8700, 0x196d, 0x2000 },

-  { 0x0700, 0x196c, 0x0000 },

-  { 0x0700, 0x1970, 0x0000 },

-  { 0x8700, 0x1973, 0x2000 },

-  { 0x0700, 0x1972, 0x0000 },

-  { 0x0700, 0x1974, 0x0000 },

-  { 0x9a00, 0x19e8, 0x4000 },

-  { 0x9a00, 0x19e4, 0x3000 },

-  { 0x9a00, 0x19e2, 0x2000 },

-  { 0x1a00, 0x19e1, 0x0000 },

-  { 0x1a00, 0x19e3, 0x0000 },

-  { 0x9a00, 0x19e6, 0x2000 },

-  { 0x1a00, 0x19e5, 0x0000 },

-  { 0x1a00, 0x19e7, 0x0000 },

-  { 0x9a00, 0x19ec, 0x3000 },

-  { 0x9a00, 0x19ea, 0x2000 },

-  { 0x1a00, 0x19e9, 0x0000 },

-  { 0x1a00, 0x19eb, 0x0000 },

-  { 0x9a00, 0x19ee, 0x2000 },

-  { 0x1a00, 0x19ed, 0x0000 },

-  { 0x1a00, 0x19ef, 0x0000 },

-  { 0x8500, 0x1d00, 0x5000 },

-  { 0x9a00, 0x19f8, 0x4000 },

-  { 0x9a00, 0x19f4, 0x3000 },

-  { 0x9a00, 0x19f2, 0x2000 },

-  { 0x1a00, 0x19f1, 0x0000 },

-  { 0x1a00, 0x19f3, 0x0000 },

-  { 0x9a00, 0x19f6, 0x2000 },

-  { 0x1a00, 0x19f5, 0x0000 },

-  { 0x1a00, 0x19f7, 0x0000 },

-  { 0x9a00, 0x19fc, 0x3000 },

-  { 0x9a00, 0x19fa, 0x2000 },

-  { 0x1a00, 0x19f9, 0x0000 },

-  { 0x1a00, 0x19fb, 0x0000 },

-  { 0x9a00, 0x19fe, 0x2000 },

-  { 0x1a00, 0x19fd, 0x0000 },

-  { 0x1a00, 0x19ff, 0x0000 },

-  { 0x8500, 0x1d08, 0x4000 },

-  { 0x8500, 0x1d04, 0x3000 },

-  { 0x8500, 0x1d02, 0x2000 },

-  { 0x0500, 0x1d01, 0x0000 },

-  { 0x0500, 0x1d03, 0x0000 },

-  { 0x8500, 0x1d06, 0x2000 },

-  { 0x0500, 0x1d05, 0x0000 },

-  { 0x0500, 0x1d07, 0x0000 },

-  { 0x8500, 0x1d0c, 0x3000 },

-  { 0x8500, 0x1d0a, 0x2000 },

-  { 0x0500, 0x1d09, 0x0000 },

-  { 0x0500, 0x1d0b, 0x0000 },

-  { 0x8500, 0x1d0e, 0x2000 },

-  { 0x0500, 0x1d0d, 0x0000 },

-  { 0x0500, 0x1d0f, 0x0000 },

-  { 0x8600, 0x1d50, 0x7000 },

-  { 0x8600, 0x1d30, 0x6000 },

-  { 0x8500, 0x1d20, 0x5000 },

-  { 0x8500, 0x1d18, 0x4000 },

-  { 0x8500, 0x1d14, 0x3000 },

-  { 0x8500, 0x1d12, 0x2000 },

-  { 0x0500, 0x1d11, 0x0000 },

-  { 0x0500, 0x1d13, 0x0000 },

-  { 0x8500, 0x1d16, 0x2000 },

-  { 0x0500, 0x1d15, 0x0000 },

-  { 0x0500, 0x1d17, 0x0000 },

-  { 0x8500, 0x1d1c, 0x3000 },

-  { 0x8500, 0x1d1a, 0x2000 },

-  { 0x0500, 0x1d19, 0x0000 },

-  { 0x0500, 0x1d1b, 0x0000 },

-  { 0x8500, 0x1d1e, 0x2000 },

-  { 0x0500, 0x1d1d, 0x0000 },

-  { 0x0500, 0x1d1f, 0x0000 },

-  { 0x8500, 0x1d28, 0x4000 },

-  { 0x8500, 0x1d24, 0x3000 },

-  { 0x8500, 0x1d22, 0x2000 },

-  { 0x0500, 0x1d21, 0x0000 },

-  { 0x0500, 0x1d23, 0x0000 },

-  { 0x8500, 0x1d26, 0x2000 },

-  { 0x0500, 0x1d25, 0x0000 },

-  { 0x0500, 0x1d27, 0x0000 },

-  { 0x8600, 0x1d2c, 0x3000 },

-  { 0x8500, 0x1d2a, 0x2000 },

-  { 0x0500, 0x1d29, 0x0000 },

-  { 0x0500, 0x1d2b, 0x0000 },

-  { 0x8600, 0x1d2e, 0x2000 },

-  { 0x0600, 0x1d2d, 0x0000 },

-  { 0x0600, 0x1d2f, 0x0000 },

-  { 0x8600, 0x1d40, 0x5000 },

-  { 0x8600, 0x1d38, 0x4000 },

-  { 0x8600, 0x1d34, 0x3000 },

-  { 0x8600, 0x1d32, 0x2000 },

-  { 0x0600, 0x1d31, 0x0000 },

-  { 0x0600, 0x1d33, 0x0000 },

-  { 0x8600, 0x1d36, 0x2000 },

-  { 0x0600, 0x1d35, 0x0000 },

-  { 0x0600, 0x1d37, 0x0000 },

-  { 0x8600, 0x1d3c, 0x3000 },

-  { 0x8600, 0x1d3a, 0x2000 },

-  { 0x0600, 0x1d39, 0x0000 },

-  { 0x0600, 0x1d3b, 0x0000 },

-  { 0x8600, 0x1d3e, 0x2000 },

-  { 0x0600, 0x1d3d, 0x0000 },

-  { 0x0600, 0x1d3f, 0x0000 },

-  { 0x8600, 0x1d48, 0x4000 },

-  { 0x8600, 0x1d44, 0x3000 },

-  { 0x8600, 0x1d42, 0x2000 },

-  { 0x0600, 0x1d41, 0x0000 },

-  { 0x0600, 0x1d43, 0x0000 },

-  { 0x8600, 0x1d46, 0x2000 },

-  { 0x0600, 0x1d45, 0x0000 },

-  { 0x0600, 0x1d47, 0x0000 },

-  { 0x8600, 0x1d4c, 0x3000 },

-  { 0x8600, 0x1d4a, 0x2000 },

-  { 0x0600, 0x1d49, 0x0000 },

-  { 0x0600, 0x1d4b, 0x0000 },

-  { 0x8600, 0x1d4e, 0x2000 },

-  { 0x0600, 0x1d4d, 0x0000 },

-  { 0x0600, 0x1d4f, 0x0000 },

-  { 0x8900, 0x1e04, 0x6001 },

-  { 0x8600, 0x1d60, 0x5000 },

-  { 0x8600, 0x1d58, 0x4000 },

-  { 0x8600, 0x1d54, 0x3000 },

-  { 0x8600, 0x1d52, 0x2000 },

-  { 0x0600, 0x1d51, 0x0000 },

-  { 0x0600, 0x1d53, 0x0000 },

-  { 0x8600, 0x1d56, 0x2000 },

-  { 0x0600, 0x1d55, 0x0000 },

-  { 0x0600, 0x1d57, 0x0000 },

-  { 0x8600, 0x1d5c, 0x3000 },

-  { 0x8600, 0x1d5a, 0x2000 },

-  { 0x0600, 0x1d59, 0x0000 },

-  { 0x0600, 0x1d5b, 0x0000 },

-  { 0x8600, 0x1d5e, 0x2000 },

-  { 0x0600, 0x1d5d, 0x0000 },

-  { 0x0600, 0x1d5f, 0x0000 },

-  { 0x8500, 0x1d68, 0x4000 },

-  { 0x8500, 0x1d64, 0x3000 },

-  { 0x8500, 0x1d62, 0x2000 },

-  { 0x0600, 0x1d61, 0x0000 },

-  { 0x0500, 0x1d63, 0x0000 },

-  { 0x8500, 0x1d66, 0x2000 },

-  { 0x0500, 0x1d65, 0x0000 },

-  { 0x0500, 0x1d67, 0x0000 },

-  { 0x8900, 0x1e00, 0x3001 },

-  { 0x8500, 0x1d6a, 0x2000 },

-  { 0x0500, 0x1d69, 0x0000 },

-  { 0x0500, 0x1d6b, 0x0000 },

-  { 0x8900, 0x1e02, 0x2001 },

-  { 0x0500, 0x1e01, 0x0fff },

-  { 0x0500, 0x1e03, 0x0fff },

-  { 0x8900, 0x1e14, 0x5001 },

-  { 0x8900, 0x1e0c, 0x4001 },

-  { 0x8900, 0x1e08, 0x3001 },

-  { 0x8900, 0x1e06, 0x2001 },

-  { 0x0500, 0x1e05, 0x0fff },

-  { 0x0500, 0x1e07, 0x0fff },

-  { 0x8900, 0x1e0a, 0x2001 },

-  { 0x0500, 0x1e09, 0x0fff },

-  { 0x0500, 0x1e0b, 0x0fff },

-  { 0x8900, 0x1e10, 0x3001 },

-  { 0x8900, 0x1e0e, 0x2001 },

-  { 0x0500, 0x1e0d, 0x0fff },

-  { 0x0500, 0x1e0f, 0x0fff },

-  { 0x8900, 0x1e12, 0x2001 },

-  { 0x0500, 0x1e11, 0x0fff },

-  { 0x0500, 0x1e13, 0x0fff },

-  { 0x8900, 0x1e1c, 0x4001 },

-  { 0x8900, 0x1e18, 0x3001 },

-  { 0x8900, 0x1e16, 0x2001 },

-  { 0x0500, 0x1e15, 0x0fff },

-  { 0x0500, 0x1e17, 0x0fff },

-  { 0x8900, 0x1e1a, 0x2001 },

-  { 0x0500, 0x1e19, 0x0fff },

-  { 0x0500, 0x1e1b, 0x0fff },

-  { 0x8900, 0x1e20, 0x3001 },

-  { 0x8900, 0x1e1e, 0x2001 },

-  { 0x0500, 0x1e1d, 0x0fff },

-  { 0x0500, 0x1e1f, 0x0fff },

-  { 0x8900, 0x1e22, 0x2001 },

-  { 0x0500, 0x1e21, 0x0fff },

-  { 0x0500, 0x1e23, 0x0fff },

-  { 0x9600, 0x2045, 0xa000 },

-  { 0x8500, 0x1f32, 0x9008 },

-  { 0x8900, 0x1ea8, 0x8001 },

-  { 0x8900, 0x1e64, 0x7001 },

-  { 0x8900, 0x1e44, 0x6001 },

-  { 0x8900, 0x1e34, 0x5001 },

-  { 0x8900, 0x1e2c, 0x4001 },

-  { 0x8900, 0x1e28, 0x3001 },

-  { 0x8900, 0x1e26, 0x2001 },

-  { 0x0500, 0x1e25, 0x0fff },

-  { 0x0500, 0x1e27, 0x0fff },

-  { 0x8900, 0x1e2a, 0x2001 },

-  { 0x0500, 0x1e29, 0x0fff },

-  { 0x0500, 0x1e2b, 0x0fff },

-  { 0x8900, 0x1e30, 0x3001 },

-  { 0x8900, 0x1e2e, 0x2001 },

-  { 0x0500, 0x1e2d, 0x0fff },

-  { 0x0500, 0x1e2f, 0x0fff },

-  { 0x8900, 0x1e32, 0x2001 },

-  { 0x0500, 0x1e31, 0x0fff },

-  { 0x0500, 0x1e33, 0x0fff },

-  { 0x8900, 0x1e3c, 0x4001 },

-  { 0x8900, 0x1e38, 0x3001 },

-  { 0x8900, 0x1e36, 0x2001 },

-  { 0x0500, 0x1e35, 0x0fff },

-  { 0x0500, 0x1e37, 0x0fff },

-  { 0x8900, 0x1e3a, 0x2001 },

-  { 0x0500, 0x1e39, 0x0fff },

-  { 0x0500, 0x1e3b, 0x0fff },

-  { 0x8900, 0x1e40, 0x3001 },

-  { 0x8900, 0x1e3e, 0x2001 },

-  { 0x0500, 0x1e3d, 0x0fff },

-  { 0x0500, 0x1e3f, 0x0fff },

-  { 0x8900, 0x1e42, 0x2001 },

-  { 0x0500, 0x1e41, 0x0fff },

-  { 0x0500, 0x1e43, 0x0fff },

-  { 0x8900, 0x1e54, 0x5001 },

-  { 0x8900, 0x1e4c, 0x4001 },

-  { 0x8900, 0x1e48, 0x3001 },

-  { 0x8900, 0x1e46, 0x2001 },

-  { 0x0500, 0x1e45, 0x0fff },

-  { 0x0500, 0x1e47, 0x0fff },

-  { 0x8900, 0x1e4a, 0x2001 },

-  { 0x0500, 0x1e49, 0x0fff },

-  { 0x0500, 0x1e4b, 0x0fff },

-  { 0x8900, 0x1e50, 0x3001 },

-  { 0x8900, 0x1e4e, 0x2001 },

-  { 0x0500, 0x1e4d, 0x0fff },

-  { 0x0500, 0x1e4f, 0x0fff },

-  { 0x8900, 0x1e52, 0x2001 },

-  { 0x0500, 0x1e51, 0x0fff },

-  { 0x0500, 0x1e53, 0x0fff },

-  { 0x8900, 0x1e5c, 0x4001 },

-  { 0x8900, 0x1e58, 0x3001 },

-  { 0x8900, 0x1e56, 0x2001 },

-  { 0x0500, 0x1e55, 0x0fff },

-  { 0x0500, 0x1e57, 0x0fff },

-  { 0x8900, 0x1e5a, 0x2001 },

-  { 0x0500, 0x1e59, 0x0fff },

-  { 0x0500, 0x1e5b, 0x0fff },

-  { 0x8900, 0x1e60, 0x3001 },

-  { 0x8900, 0x1e5e, 0x2001 },

-  { 0x0500, 0x1e5d, 0x0fff },

-  { 0x0500, 0x1e5f, 0x0fff },

-  { 0x8900, 0x1e62, 0x2001 },

-  { 0x0500, 0x1e61, 0x0fff },

-  { 0x0500, 0x1e63, 0x0fff },

-  { 0x8900, 0x1e84, 0x6001 },

-  { 0x8900, 0x1e74, 0x5001 },

-  { 0x8900, 0x1e6c, 0x4001 },

-  { 0x8900, 0x1e68, 0x3001 },

-  { 0x8900, 0x1e66, 0x2001 },

-  { 0x0500, 0x1e65, 0x0fff },

-  { 0x0500, 0x1e67, 0x0fff },

-  { 0x8900, 0x1e6a, 0x2001 },

-  { 0x0500, 0x1e69, 0x0fff },

-  { 0x0500, 0x1e6b, 0x0fff },

-  { 0x8900, 0x1e70, 0x3001 },

-  { 0x8900, 0x1e6e, 0x2001 },

-  { 0x0500, 0x1e6d, 0x0fff },

-  { 0x0500, 0x1e6f, 0x0fff },

-  { 0x8900, 0x1e72, 0x2001 },

-  { 0x0500, 0x1e71, 0x0fff },

-  { 0x0500, 0x1e73, 0x0fff },

-  { 0x8900, 0x1e7c, 0x4001 },

-  { 0x8900, 0x1e78, 0x3001 },

-  { 0x8900, 0x1e76, 0x2001 },

-  { 0x0500, 0x1e75, 0x0fff },

-  { 0x0500, 0x1e77, 0x0fff },

-  { 0x8900, 0x1e7a, 0x2001 },

-  { 0x0500, 0x1e79, 0x0fff },

-  { 0x0500, 0x1e7b, 0x0fff },

-  { 0x8900, 0x1e80, 0x3001 },

-  { 0x8900, 0x1e7e, 0x2001 },

-  { 0x0500, 0x1e7d, 0x0fff },

-  { 0x0500, 0x1e7f, 0x0fff },

-  { 0x8900, 0x1e82, 0x2001 },

-  { 0x0500, 0x1e81, 0x0fff },

-  { 0x0500, 0x1e83, 0x0fff },

-  { 0x8900, 0x1e94, 0x5001 },

-  { 0x8900, 0x1e8c, 0x4001 },

-  { 0x8900, 0x1e88, 0x3001 },

-  { 0x8900, 0x1e86, 0x2001 },

-  { 0x0500, 0x1e85, 0x0fff },

-  { 0x0500, 0x1e87, 0x0fff },

-  { 0x8900, 0x1e8a, 0x2001 },

-  { 0x0500, 0x1e89, 0x0fff },

-  { 0x0500, 0x1e8b, 0x0fff },

-  { 0x8900, 0x1e90, 0x3001 },

-  { 0x8900, 0x1e8e, 0x2001 },

-  { 0x0500, 0x1e8d, 0x0fff },

-  { 0x0500, 0x1e8f, 0x0fff },

-  { 0x8900, 0x1e92, 0x2001 },

-  { 0x0500, 0x1e91, 0x0fff },

-  { 0x0500, 0x1e93, 0x0fff },

-  { 0x8900, 0x1ea0, 0x4001 },

-  { 0x8500, 0x1e98, 0x3000 },

-  { 0x8500, 0x1e96, 0x2000 },

-  { 0x0500, 0x1e95, 0x0fff },

-  { 0x0500, 0x1e97, 0x0000 },

-  { 0x8500, 0x1e9a, 0x2000 },

-  { 0x0500, 0x1e99, 0x0000 },

-  { 0x0500, 0x1e9b, 0x0fc5 },

-  { 0x8900, 0x1ea4, 0x3001 },

-  { 0x8900, 0x1ea2, 0x2001 },

-  { 0x0500, 0x1ea1, 0x0fff },

-  { 0x0500, 0x1ea3, 0x0fff },

-  { 0x8900, 0x1ea6, 0x2001 },

-  { 0x0500, 0x1ea5, 0x0fff },

-  { 0x0500, 0x1ea7, 0x0fff },

-  { 0x8900, 0x1ee8, 0x7001 },

-  { 0x8900, 0x1ec8, 0x6001 },

-  { 0x8900, 0x1eb8, 0x5001 },

-  { 0x8900, 0x1eb0, 0x4001 },

-  { 0x8900, 0x1eac, 0x3001 },

-  { 0x8900, 0x1eaa, 0x2001 },

-  { 0x0500, 0x1ea9, 0x0fff },

-  { 0x0500, 0x1eab, 0x0fff },

-  { 0x8900, 0x1eae, 0x2001 },

-  { 0x0500, 0x1ead, 0x0fff },

-  { 0x0500, 0x1eaf, 0x0fff },

-  { 0x8900, 0x1eb4, 0x3001 },

-  { 0x8900, 0x1eb2, 0x2001 },

-  { 0x0500, 0x1eb1, 0x0fff },

-  { 0x0500, 0x1eb3, 0x0fff },

-  { 0x8900, 0x1eb6, 0x2001 },

-  { 0x0500, 0x1eb5, 0x0fff },

-  { 0x0500, 0x1eb7, 0x0fff },

-  { 0x8900, 0x1ec0, 0x4001 },

-  { 0x8900, 0x1ebc, 0x3001 },

-  { 0x8900, 0x1eba, 0x2001 },

-  { 0x0500, 0x1eb9, 0x0fff },

-  { 0x0500, 0x1ebb, 0x0fff },

-  { 0x8900, 0x1ebe, 0x2001 },

-  { 0x0500, 0x1ebd, 0x0fff },

-  { 0x0500, 0x1ebf, 0x0fff },

-  { 0x8900, 0x1ec4, 0x3001 },

-  { 0x8900, 0x1ec2, 0x2001 },

-  { 0x0500, 0x1ec1, 0x0fff },

-  { 0x0500, 0x1ec3, 0x0fff },

-  { 0x8900, 0x1ec6, 0x2001 },

-  { 0x0500, 0x1ec5, 0x0fff },

-  { 0x0500, 0x1ec7, 0x0fff },

-  { 0x8900, 0x1ed8, 0x5001 },

-  { 0x8900, 0x1ed0, 0x4001 },

-  { 0x8900, 0x1ecc, 0x3001 },

-  { 0x8900, 0x1eca, 0x2001 },

-  { 0x0500, 0x1ec9, 0x0fff },

-  { 0x0500, 0x1ecb, 0x0fff },

-  { 0x8900, 0x1ece, 0x2001 },

-  { 0x0500, 0x1ecd, 0x0fff },

-  { 0x0500, 0x1ecf, 0x0fff },

-  { 0x8900, 0x1ed4, 0x3001 },

-  { 0x8900, 0x1ed2, 0x2001 },

-  { 0x0500, 0x1ed1, 0x0fff },

-  { 0x0500, 0x1ed3, 0x0fff },

-  { 0x8900, 0x1ed6, 0x2001 },

-  { 0x0500, 0x1ed5, 0x0fff },

-  { 0x0500, 0x1ed7, 0x0fff },

-  { 0x8900, 0x1ee0, 0x4001 },

-  { 0x8900, 0x1edc, 0x3001 },

-  { 0x8900, 0x1eda, 0x2001 },

-  { 0x0500, 0x1ed9, 0x0fff },

-  { 0x0500, 0x1edb, 0x0fff },

-  { 0x8900, 0x1ede, 0x2001 },

-  { 0x0500, 0x1edd, 0x0fff },

-  { 0x0500, 0x1edf, 0x0fff },

-  { 0x8900, 0x1ee4, 0x3001 },

-  { 0x8900, 0x1ee2, 0x2001 },

-  { 0x0500, 0x1ee1, 0x0fff },

-  { 0x0500, 0x1ee3, 0x0fff },

-  { 0x8900, 0x1ee6, 0x2001 },

-  { 0x0500, 0x1ee5, 0x0fff },

-  { 0x0500, 0x1ee7, 0x0fff },

-  { 0x8900, 0x1f0e, 0x6ff8 },

-  { 0x8900, 0x1ef8, 0x5001 },

-  { 0x8900, 0x1ef0, 0x4001 },

-  { 0x8900, 0x1eec, 0x3001 },

-  { 0x8900, 0x1eea, 0x2001 },

-  { 0x0500, 0x1ee9, 0x0fff },

-  { 0x0500, 0x1eeb, 0x0fff },

-  { 0x8900, 0x1eee, 0x2001 },

-  { 0x0500, 0x1eed, 0x0fff },

-  { 0x0500, 0x1eef, 0x0fff },

-  { 0x8900, 0x1ef4, 0x3001 },

-  { 0x8900, 0x1ef2, 0x2001 },

-  { 0x0500, 0x1ef1, 0x0fff },

-  { 0x0500, 0x1ef3, 0x0fff },

-  { 0x8900, 0x1ef6, 0x2001 },

-  { 0x0500, 0x1ef5, 0x0fff },

-  { 0x0500, 0x1ef7, 0x0fff },

-  { 0x8500, 0x1f06, 0x4008 },

-  { 0x8500, 0x1f02, 0x3008 },

-  { 0x8500, 0x1f00, 0x2008 },

-  { 0x0500, 0x1ef9, 0x0fff },

-  { 0x0500, 0x1f01, 0x0008 },

-  { 0x8500, 0x1f04, 0x2008 },

-  { 0x0500, 0x1f03, 0x0008 },

-  { 0x0500, 0x1f05, 0x0008 },

-  { 0x8900, 0x1f0a, 0x3ff8 },

-  { 0x8900, 0x1f08, 0x2ff8 },

-  { 0x0500, 0x1f07, 0x0008 },

-  { 0x0900, 0x1f09, 0x0ff8 },

-  { 0x8900, 0x1f0c, 0x2ff8 },

-  { 0x0900, 0x1f0b, 0x0ff8 },

-  { 0x0900, 0x1f0d, 0x0ff8 },

-  { 0x8500, 0x1f22, 0x5008 },

-  { 0x8900, 0x1f18, 0x4ff8 },

-  { 0x8500, 0x1f12, 0x3008 },

-  { 0x8500, 0x1f10, 0x2008 },

-  { 0x0900, 0x1f0f, 0x0ff8 },

-  { 0x0500, 0x1f11, 0x0008 },

-  { 0x8500, 0x1f14, 0x2008 },

-  { 0x0500, 0x1f13, 0x0008 },

-  { 0x0500, 0x1f15, 0x0008 },

-  { 0x8900, 0x1f1c, 0x3ff8 },

-  { 0x8900, 0x1f1a, 0x2ff8 },

-  { 0x0900, 0x1f19, 0x0ff8 },

-  { 0x0900, 0x1f1b, 0x0ff8 },

-  { 0x8500, 0x1f20, 0x2008 },

-  { 0x0900, 0x1f1d, 0x0ff8 },

-  { 0x0500, 0x1f21, 0x0008 },

-  { 0x8900, 0x1f2a, 0x4ff8 },

-  { 0x8500, 0x1f26, 0x3008 },

-  { 0x8500, 0x1f24, 0x2008 },

-  { 0x0500, 0x1f23, 0x0008 },

-  { 0x0500, 0x1f25, 0x0008 },

-  { 0x8900, 0x1f28, 0x2ff8 },

-  { 0x0500, 0x1f27, 0x0008 },

-  { 0x0900, 0x1f29, 0x0ff8 },

-  { 0x8900, 0x1f2e, 0x3ff8 },

-  { 0x8900, 0x1f2c, 0x2ff8 },

-  { 0x0900, 0x1f2b, 0x0ff8 },

-  { 0x0900, 0x1f2d, 0x0ff8 },

-  { 0x8500, 0x1f30, 0x2008 },

-  { 0x0900, 0x1f2f, 0x0ff8 },

-  { 0x0500, 0x1f31, 0x0008 },

-  { 0x9800, 0x1fbd, 0x8000 },

-  { 0x8500, 0x1f7a, 0x7070 },

-  { 0x8500, 0x1f56, 0x6000 },

-  { 0x8500, 0x1f42, 0x5008 },

-  { 0x8900, 0x1f3a, 0x4ff8 },

-  { 0x8500, 0x1f36, 0x3008 },

-  { 0x8500, 0x1f34, 0x2008 },

-  { 0x0500, 0x1f33, 0x0008 },

-  { 0x0500, 0x1f35, 0x0008 },

-  { 0x8900, 0x1f38, 0x2ff8 },

-  { 0x0500, 0x1f37, 0x0008 },

-  { 0x0900, 0x1f39, 0x0ff8 },

-  { 0x8900, 0x1f3e, 0x3ff8 },

-  { 0x8900, 0x1f3c, 0x2ff8 },

-  { 0x0900, 0x1f3b, 0x0ff8 },

-  { 0x0900, 0x1f3d, 0x0ff8 },

-  { 0x8500, 0x1f40, 0x2008 },

-  { 0x0900, 0x1f3f, 0x0ff8 },

-  { 0x0500, 0x1f41, 0x0008 },

-  { 0x8900, 0x1f4c, 0x4ff8 },

-  { 0x8900, 0x1f48, 0x3ff8 },

-  { 0x8500, 0x1f44, 0x2008 },

-  { 0x0500, 0x1f43, 0x0008 },

-  { 0x0500, 0x1f45, 0x0008 },

-  { 0x8900, 0x1f4a, 0x2ff8 },

-  { 0x0900, 0x1f49, 0x0ff8 },

-  { 0x0900, 0x1f4b, 0x0ff8 },

-  { 0x8500, 0x1f52, 0x3000 },

-  { 0x8500, 0x1f50, 0x2000 },

-  { 0x0900, 0x1f4d, 0x0ff8 },

-  { 0x0500, 0x1f51, 0x0008 },

-  { 0x8500, 0x1f54, 0x2000 },

-  { 0x0500, 0x1f53, 0x0008 },

-  { 0x0500, 0x1f55, 0x0008 },

-  { 0x8900, 0x1f6a, 0x5ff8 },

-  { 0x8500, 0x1f62, 0x4008 },

-  { 0x8900, 0x1f5d, 0x3ff8 },

-  { 0x8900, 0x1f59, 0x2ff8 },

-  { 0x0500, 0x1f57, 0x0008 },

-  { 0x0900, 0x1f5b, 0x0ff8 },

-  { 0x8500, 0x1f60, 0x2008 },

-  { 0x0900, 0x1f5f, 0x0ff8 },

-  { 0x0500, 0x1f61, 0x0008 },

-  { 0x8500, 0x1f66, 0x3008 },

-  { 0x8500, 0x1f64, 0x2008 },

-  { 0x0500, 0x1f63, 0x0008 },

-  { 0x0500, 0x1f65, 0x0008 },

-  { 0x8900, 0x1f68, 0x2ff8 },

-  { 0x0500, 0x1f67, 0x0008 },

-  { 0x0900, 0x1f69, 0x0ff8 },

-  { 0x8500, 0x1f72, 0x4056 },

-  { 0x8900, 0x1f6e, 0x3ff8 },

-  { 0x8900, 0x1f6c, 0x2ff8 },

-  { 0x0900, 0x1f6b, 0x0ff8 },

-  { 0x0900, 0x1f6d, 0x0ff8 },

-  { 0x8500, 0x1f70, 0x204a },

-  { 0x0900, 0x1f6f, 0x0ff8 },

-  { 0x0500, 0x1f71, 0x004a },

-  { 0x8500, 0x1f76, 0x3064 },

-  { 0x8500, 0x1f74, 0x2056 },

-  { 0x0500, 0x1f73, 0x0056 },

-  { 0x0500, 0x1f75, 0x0056 },

-  { 0x8500, 0x1f78, 0x2080 },

-  { 0x0500, 0x1f77, 0x0064 },

-  { 0x0500, 0x1f79, 0x0080 },

-  { 0x8800, 0x1f9c, 0x6000 },

-  { 0x8800, 0x1f8c, 0x5000 },

-  { 0x8500, 0x1f84, 0x4008 },

-  { 0x8500, 0x1f80, 0x3008 },

-  { 0x8500, 0x1f7c, 0x207e },

-  { 0x0500, 0x1f7b, 0x0070 },

-  { 0x0500, 0x1f7d, 0x007e },

-  { 0x8500, 0x1f82, 0x2008 },

-  { 0x0500, 0x1f81, 0x0008 },

-  { 0x0500, 0x1f83, 0x0008 },

-  { 0x8800, 0x1f88, 0x3000 },

-  { 0x8500, 0x1f86, 0x2008 },

-  { 0x0500, 0x1f85, 0x0008 },

-  { 0x0500, 0x1f87, 0x0008 },

-  { 0x8800, 0x1f8a, 0x2000 },

-  { 0x0800, 0x1f89, 0x0000 },

-  { 0x0800, 0x1f8b, 0x0000 },

-  { 0x8500, 0x1f94, 0x4008 },

-  { 0x8500, 0x1f90, 0x3008 },

-  { 0x8800, 0x1f8e, 0x2000 },

-  { 0x0800, 0x1f8d, 0x0000 },

-  { 0x0800, 0x1f8f, 0x0000 },

-  { 0x8500, 0x1f92, 0x2008 },

-  { 0x0500, 0x1f91, 0x0008 },

-  { 0x0500, 0x1f93, 0x0008 },

-  { 0x8800, 0x1f98, 0x3000 },

-  { 0x8500, 0x1f96, 0x2008 },

-  { 0x0500, 0x1f95, 0x0008 },

-  { 0x0500, 0x1f97, 0x0008 },

-  { 0x8800, 0x1f9a, 0x2000 },

-  { 0x0800, 0x1f99, 0x0000 },

-  { 0x0800, 0x1f9b, 0x0000 },

-  { 0x8800, 0x1fac, 0x5000 },

-  { 0x8500, 0x1fa4, 0x4008 },

-  { 0x8500, 0x1fa0, 0x3008 },

-  { 0x8800, 0x1f9e, 0x2000 },

-  { 0x0800, 0x1f9d, 0x0000 },

-  { 0x0800, 0x1f9f, 0x0000 },

-  { 0x8500, 0x1fa2, 0x2008 },

-  { 0x0500, 0x1fa1, 0x0008 },

-  { 0x0500, 0x1fa3, 0x0008 },

-  { 0x8800, 0x1fa8, 0x3000 },

-  { 0x8500, 0x1fa6, 0x2008 },

-  { 0x0500, 0x1fa5, 0x0008 },

-  { 0x0500, 0x1fa7, 0x0008 },

-  { 0x8800, 0x1faa, 0x2000 },

-  { 0x0800, 0x1fa9, 0x0000 },

-  { 0x0800, 0x1fab, 0x0000 },

-  { 0x8500, 0x1fb4, 0x4000 },

-  { 0x8500, 0x1fb0, 0x3008 },

-  { 0x8800, 0x1fae, 0x2000 },

-  { 0x0800, 0x1fad, 0x0000 },

-  { 0x0800, 0x1faf, 0x0000 },

-  { 0x8500, 0x1fb2, 0x2000 },

-  { 0x0500, 0x1fb1, 0x0008 },

-  { 0x0500, 0x1fb3, 0x0009 },

-  { 0x8900, 0x1fb9, 0x3ff8 },

-  { 0x8500, 0x1fb7, 0x2000 },

-  { 0x0500, 0x1fb6, 0x0000 },

-  { 0x0900, 0x1fb8, 0x0ff8 },

-  { 0x8900, 0x1fbb, 0x2fb6 },

-  { 0x0900, 0x1fba, 0x0fb6 },

-  { 0x0800, 0x1fbc, 0x0000 },

-  { 0x9d00, 0x2005, 0x7000 },

-  { 0x8500, 0x1fe1, 0x6008 },

-  { 0x9800, 0x1fce, 0x5000 },

-  { 0x8500, 0x1fc6, 0x4000 },

-  { 0x9800, 0x1fc1, 0x3000 },

-  { 0x9800, 0x1fbf, 0x2000 },

-  { 0x0500, 0x1fbe, 0x0000 },

-  { 0x1800, 0x1fc0, 0x0000 },

-  { 0x8500, 0x1fc3, 0x2009 },

-  { 0x0500, 0x1fc2, 0x0000 },

-  { 0x0500, 0x1fc4, 0x0000 },

-  { 0x8900, 0x1fca, 0x3faa },

-  { 0x8900, 0x1fc8, 0x2faa },

-  { 0x0500, 0x1fc7, 0x0000 },

-  { 0x0900, 0x1fc9, 0x0faa },

-  { 0x8800, 0x1fcc, 0x2000 },

-  { 0x0900, 0x1fcb, 0x0faa },

-  { 0x1800, 0x1fcd, 0x0000 },

-  { 0x8900, 0x1fd8, 0x4ff8 },

-  { 0x8500, 0x1fd2, 0x3000 },

-  { 0x8500, 0x1fd0, 0x2008 },

-  { 0x1800, 0x1fcf, 0x0000 },

-  { 0x0500, 0x1fd1, 0x0008 },

-  { 0x8500, 0x1fd6, 0x2000 },

-  { 0x0500, 0x1fd3, 0x0000 },

-  { 0x0500, 0x1fd7, 0x0000 },

-  { 0x9800, 0x1fdd, 0x3000 },

-  { 0x8900, 0x1fda, 0x2f9c },

-  { 0x0900, 0x1fd9, 0x0ff8 },

-  { 0x0900, 0x1fdb, 0x0f9c },

-  { 0x9800, 0x1fdf, 0x2000 },

-  { 0x1800, 0x1fde, 0x0000 },

-  { 0x0500, 0x1fe0, 0x0008 },

-  { 0x8500, 0x1ff3, 0x5009 },

-  { 0x8900, 0x1fe9, 0x4ff8 },

-  { 0x8500, 0x1fe5, 0x3007 },

-  { 0x8500, 0x1fe3, 0x2000 },

-  { 0x0500, 0x1fe2, 0x0000 },

-  { 0x0500, 0x1fe4, 0x0000 },

-  { 0x8500, 0x1fe7, 0x2000 },

-  { 0x0500, 0x1fe6, 0x0000 },

-  { 0x0900, 0x1fe8, 0x0ff8 },

-  { 0x9800, 0x1fed, 0x3000 },

-  { 0x8900, 0x1feb, 0x2f90 },

-  { 0x0900, 0x1fea, 0x0f90 },

-  { 0x0900, 0x1fec, 0x0ff9 },

-  { 0x9800, 0x1fef, 0x2000 },

-  { 0x1800, 0x1fee, 0x0000 },

-  { 0x0500, 0x1ff2, 0x0000 },

-  { 0x8800, 0x1ffc, 0x4000 },

-  { 0x8900, 0x1ff8, 0x3f80 },

-  { 0x8500, 0x1ff6, 0x2000 },

-  { 0x0500, 0x1ff4, 0x0000 },

-  { 0x0500, 0x1ff7, 0x0000 },

-  { 0x8900, 0x1ffa, 0x2f82 },

-  { 0x0900, 0x1ff9, 0x0f80 },

-  { 0x0900, 0x1ffb, 0x0f82 },

-  { 0x9d00, 0x2001, 0x3000 },

-  { 0x9800, 0x1ffe, 0x2000 },

-  { 0x1800, 0x1ffd, 0x0000 },

-  { 0x1d00, 0x2000, 0x0000 },

-  { 0x9d00, 0x2003, 0x2000 },

-  { 0x1d00, 0x2002, 0x0000 },

-  { 0x1d00, 0x2004, 0x0000 },

-  { 0x9500, 0x2025, 0x6000 },

-  { 0x9100, 0x2015, 0x5000 },

-  { 0x8100, 0x200d, 0x4000 },

-  { 0x9d00, 0x2009, 0x3000 },

-  { 0x9d00, 0x2007, 0x2000 },

-  { 0x1d00, 0x2006, 0x0000 },

-  { 0x1d00, 0x2008, 0x0000 },

-  { 0x9d00, 0x200b, 0x2000 },

-  { 0x1d00, 0x200a, 0x0000 },

-  { 0x0100, 0x200c, 0x0000 },

-  { 0x9100, 0x2011, 0x3000 },

-  { 0x8100, 0x200f, 0x2000 },

-  { 0x0100, 0x200e, 0x0000 },

-  { 0x1100, 0x2010, 0x0000 },

-  { 0x9100, 0x2013, 0x2000 },

-  { 0x1100, 0x2012, 0x0000 },

-  { 0x1100, 0x2014, 0x0000 },

-  { 0x9300, 0x201d, 0x4000 },

-  { 0x9300, 0x2019, 0x3000 },

-  { 0x9500, 0x2017, 0x2000 },

-  { 0x1500, 0x2016, 0x0000 },

-  { 0x1400, 0x2018, 0x0000 },

-  { 0x9400, 0x201b, 0x2000 },

-  { 0x1600, 0x201a, 0x0000 },

-  { 0x1400, 0x201c, 0x0000 },

-  { 0x9500, 0x2021, 0x3000 },

-  { 0x9400, 0x201f, 0x2000 },

-  { 0x1600, 0x201e, 0x0000 },

-  { 0x1500, 0x2020, 0x0000 },

-  { 0x9500, 0x2023, 0x2000 },

-  { 0x1500, 0x2022, 0x0000 },

-  { 0x1500, 0x2024, 0x0000 },

-  { 0x9500, 0x2035, 0x5000 },

-  { 0x8100, 0x202d, 0x4000 },

-  { 0x9c00, 0x2029, 0x3000 },

-  { 0x9500, 0x2027, 0x2000 },

-  { 0x1500, 0x2026, 0x0000 },

-  { 0x1b00, 0x2028, 0x0000 },

-  { 0x8100, 0x202b, 0x2000 },

-  { 0x0100, 0x202a, 0x0000 },

-  { 0x0100, 0x202c, 0x0000 },

-  { 0x9500, 0x2031, 0x3000 },

-  { 0x9d00, 0x202f, 0x2000 },

-  { 0x0100, 0x202e, 0x0000 },

-  { 0x1500, 0x2030, 0x0000 },

-  { 0x9500, 0x2033, 0x2000 },

-  { 0x1500, 0x2032, 0x0000 },

-  { 0x1500, 0x2034, 0x0000 },

-  { 0x9500, 0x203d, 0x4000 },

-  { 0x9400, 0x2039, 0x3000 },

-  { 0x9500, 0x2037, 0x2000 },

-  { 0x1500, 0x2036, 0x0000 },

-  { 0x1500, 0x2038, 0x0000 },

-  { 0x9500, 0x203b, 0x2000 },

-  { 0x1300, 0x203a, 0x0000 },

-  { 0x1500, 0x203c, 0x0000 },

-  { 0x9500, 0x2041, 0x3000 },

-  { 0x9000, 0x203f, 0x2000 },

-  { 0x1500, 0x203e, 0x0000 },

-  { 0x1000, 0x2040, 0x0000 },

-  { 0x9500, 0x2043, 0x2000 },

-  { 0x1500, 0x2042, 0x0000 },

-  { 0x1900, 0x2044, 0x0000 },

-  { 0x9900, 0x21ae, 0x9000 },

-  { 0x8900, 0x211a, 0x8000 },

-  { 0x9700, 0x20a7, 0x7000 },

-  { 0x8f00, 0x2076, 0x6000 },

-  { 0x9500, 0x2057, 0x5000 },

-  { 0x9500, 0x204d, 0x4000 },

-  { 0x9500, 0x2049, 0x3000 },

-  { 0x9500, 0x2047, 0x2000 },

-  { 0x1200, 0x2046, 0x0000 },

-  { 0x1500, 0x2048, 0x0000 },

-  { 0x9500, 0x204b, 0x2000 },

-  { 0x1500, 0x204a, 0x0000 },

-  { 0x1500, 0x204c, 0x0000 },

-  { 0x9500, 0x2051, 0x3000 },

-  { 0x9500, 0x204f, 0x2000 },

-  { 0x1500, 0x204e, 0x0000 },

-  { 0x1500, 0x2050, 0x0000 },

-  { 0x9500, 0x2053, 0x2000 },

-  { 0x1900, 0x2052, 0x0000 },

-  { 0x1000, 0x2054, 0x0000 },

-  { 0x8100, 0x206c, 0x4000 },

-  { 0x8100, 0x2062, 0x3000 },

-  { 0x8100, 0x2060, 0x2000 },

-  { 0x1d00, 0x205f, 0x0000 },

-  { 0x0100, 0x2061, 0x0000 },

-  { 0x8100, 0x206a, 0x2000 },

-  { 0x0100, 0x2063, 0x0000 },

-  { 0x0100, 0x206b, 0x0000 },

-  { 0x8f00, 0x2070, 0x3000 },

-  { 0x8100, 0x206e, 0x2000 },

-  { 0x0100, 0x206d, 0x0000 },

-  { 0x0100, 0x206f, 0x0000 },

-  { 0x8f00, 0x2074, 0x2000 },

-  { 0x0500, 0x2071, 0x0000 },

-  { 0x0f00, 0x2075, 0x0000 },

-  { 0x8f00, 0x2086, 0x5000 },

-  { 0x9200, 0x207e, 0x4000 },

-  { 0x9900, 0x207a, 0x3000 },

-  { 0x8f00, 0x2078, 0x2000 },

-  { 0x0f00, 0x2077, 0x0000 },

-  { 0x0f00, 0x2079, 0x0000 },

-  { 0x9900, 0x207c, 0x2000 },

-  { 0x1900, 0x207b, 0x0000 },

-  { 0x1600, 0x207d, 0x0000 },

-  { 0x8f00, 0x2082, 0x3000 },

-  { 0x8f00, 0x2080, 0x2000 },

-  { 0x0500, 0x207f, 0x0000 },

-  { 0x0f00, 0x2081, 0x0000 },

-  { 0x8f00, 0x2084, 0x2000 },

-  { 0x0f00, 0x2083, 0x0000 },

-  { 0x0f00, 0x2085, 0x0000 },

-  { 0x9200, 0x208e, 0x4000 },

-  { 0x9900, 0x208a, 0x3000 },

-  { 0x8f00, 0x2088, 0x2000 },

-  { 0x0f00, 0x2087, 0x0000 },

-  { 0x0f00, 0x2089, 0x0000 },

-  { 0x9900, 0x208c, 0x2000 },

-  { 0x1900, 0x208b, 0x0000 },

-  { 0x1600, 0x208d, 0x0000 },

-  { 0x9700, 0x20a3, 0x3000 },

-  { 0x9700, 0x20a1, 0x2000 },

-  { 0x1700, 0x20a0, 0x0000 },

-  { 0x1700, 0x20a2, 0x0000 },

-  { 0x9700, 0x20a5, 0x2000 },

-  { 0x1700, 0x20a4, 0x0000 },

-  { 0x1700, 0x20a6, 0x0000 },

-  { 0x8c00, 0x20e5, 0x6000 },

-  { 0x8c00, 0x20d5, 0x5000 },

-  { 0x9700, 0x20af, 0x4000 },

-  { 0x9700, 0x20ab, 0x3000 },

-  { 0x9700, 0x20a9, 0x2000 },

-  { 0x1700, 0x20a8, 0x0000 },

-  { 0x1700, 0x20aa, 0x0000 },

-  { 0x9700, 0x20ad, 0x2000 },

-  { 0x1700, 0x20ac, 0x0000 },

-  { 0x1700, 0x20ae, 0x0000 },

-  { 0x8c00, 0x20d1, 0x3000 },

-  { 0x9700, 0x20b1, 0x2000 },

-  { 0x1700, 0x20b0, 0x0000 },

-  { 0x0c00, 0x20d0, 0x0000 },

-  { 0x8c00, 0x20d3, 0x2000 },

-  { 0x0c00, 0x20d2, 0x0000 },

-  { 0x0c00, 0x20d4, 0x0000 },

-  { 0x8b00, 0x20dd, 0x4000 },

-  { 0x8c00, 0x20d9, 0x3000 },

-  { 0x8c00, 0x20d7, 0x2000 },

-  { 0x0c00, 0x20d6, 0x0000 },

-  { 0x0c00, 0x20d8, 0x0000 },

-  { 0x8c00, 0x20db, 0x2000 },

-  { 0x0c00, 0x20da, 0x0000 },

-  { 0x0c00, 0x20dc, 0x0000 },

-  { 0x8c00, 0x20e1, 0x3000 },

-  { 0x8b00, 0x20df, 0x2000 },

-  { 0x0b00, 0x20de, 0x0000 },

-  { 0x0b00, 0x20e0, 0x0000 },

-  { 0x8b00, 0x20e3, 0x2000 },

-  { 0x0b00, 0x20e2, 0x0000 },

-  { 0x0b00, 0x20e4, 0x0000 },

-  { 0x8500, 0x210a, 0x5000 },

-  { 0x8900, 0x2102, 0x4000 },

-  { 0x8c00, 0x20e9, 0x3000 },

-  { 0x8c00, 0x20e7, 0x2000 },

-  { 0x0c00, 0x20e6, 0x0000 },

-  { 0x0c00, 0x20e8, 0x0000 },

-  { 0x9a00, 0x2100, 0x2000 },

-  { 0x0c00, 0x20ea, 0x0000 },

-  { 0x1a00, 0x2101, 0x0000 },

-  { 0x9a00, 0x2106, 0x3000 },

-  { 0x9a00, 0x2104, 0x2000 },

-  { 0x1a00, 0x2103, 0x0000 },

-  { 0x1a00, 0x2105, 0x0000 },

-  { 0x9a00, 0x2108, 0x2000 },

-  { 0x0900, 0x2107, 0x0000 },

-  { 0x1a00, 0x2109, 0x0000 },

-  { 0x8900, 0x2112, 0x4000 },

-  { 0x8500, 0x210e, 0x3000 },

-  { 0x8900, 0x210c, 0x2000 },

-  { 0x0900, 0x210b, 0x0000 },

-  { 0x0900, 0x210d, 0x0000 },

-  { 0x8900, 0x2110, 0x2000 },

-  { 0x0500, 0x210f, 0x0000 },

-  { 0x0900, 0x2111, 0x0000 },

-  { 0x9a00, 0x2116, 0x3000 },

-  { 0x9a00, 0x2114, 0x2000 },

-  { 0x0500, 0x2113, 0x0000 },

-  { 0x0900, 0x2115, 0x0000 },

-  { 0x9a00, 0x2118, 0x2000 },

-  { 0x1a00, 0x2117, 0x0000 },

-  { 0x0900, 0x2119, 0x0000 },

-  { 0x8e00, 0x2162, 0x7000 },

-  { 0x9a00, 0x213a, 0x6000 },

-  { 0x8900, 0x212a, 0x5000 },

-  { 0x9a00, 0x2122, 0x4000 },

-  { 0x9a00, 0x211e, 0x3000 },

-  { 0x8900, 0x211c, 0x2000 },

-  { 0x0900, 0x211b, 0x0000 },

-  { 0x0900, 0x211d, 0x0000 },

-  { 0x9a00, 0x2120, 0x2000 },

-  { 0x1a00, 0x211f, 0x0000 },

-  { 0x1a00, 0x2121, 0x0000 },

-  { 0x8900, 0x2126, 0x3000 },

-  { 0x8900, 0x2124, 0x2000 },

-  { 0x1a00, 0x2123, 0x0000 },

-  { 0x1a00, 0x2125, 0x0000 },

-  { 0x8900, 0x2128, 0x2000 },

-  { 0x1a00, 0x2127, 0x0000 },

-  { 0x1a00, 0x2129, 0x0000 },

-  { 0x9a00, 0x2132, 0x4000 },

-  { 0x9a00, 0x212e, 0x3000 },

-  { 0x8900, 0x212c, 0x2000 },

-  { 0x0900, 0x212b, 0x0000 },

-  { 0x0900, 0x212d, 0x0000 },

-  { 0x8900, 0x2130, 0x2000 },

-  { 0x0500, 0x212f, 0x0000 },

-  { 0x0900, 0x2131, 0x0000 },

-  { 0x8700, 0x2136, 0x3000 },

-  { 0x8500, 0x2134, 0x2000 },

-  { 0x0900, 0x2133, 0x0000 },

-  { 0x0700, 0x2135, 0x0000 },

-  { 0x8700, 0x2138, 0x2000 },

-  { 0x0700, 0x2137, 0x0000 },

-  { 0x0500, 0x2139, 0x0000 },

-  { 0x9900, 0x214b, 0x5000 },

-  { 0x9900, 0x2143, 0x4000 },

-  { 0x8900, 0x213f, 0x3000 },

-  { 0x8500, 0x213d, 0x2000 },

-  { 0x1a00, 0x213b, 0x0000 },

-  { 0x0900, 0x213e, 0x0000 },

-  { 0x9900, 0x2141, 0x2000 },

-  { 0x1900, 0x2140, 0x0000 },

-  { 0x1900, 0x2142, 0x0000 },

-  { 0x8500, 0x2147, 0x3000 },

-  { 0x8900, 0x2145, 0x2000 },

-  { 0x1900, 0x2144, 0x0000 },

-  { 0x0500, 0x2146, 0x0000 },

-  { 0x8500, 0x2149, 0x2000 },

-  { 0x0500, 0x2148, 0x0000 },

-  { 0x1a00, 0x214a, 0x0000 },

-  { 0x8f00, 0x215a, 0x4000 },

-  { 0x8f00, 0x2156, 0x3000 },

-  { 0x8f00, 0x2154, 0x2000 },

-  { 0x0f00, 0x2153, 0x0000 },

-  { 0x0f00, 0x2155, 0x0000 },

-  { 0x8f00, 0x2158, 0x2000 },

-  { 0x0f00, 0x2157, 0x0000 },

-  { 0x0f00, 0x2159, 0x0000 },

-  { 0x8f00, 0x215e, 0x3000 },

-  { 0x8f00, 0x215c, 0x2000 },

-  { 0x0f00, 0x215b, 0x0000 },

-  { 0x0f00, 0x215d, 0x0000 },

-  { 0x8e00, 0x2160, 0x2000 },

-  { 0x0f00, 0x215f, 0x0000 },

-  { 0x0e00, 0x2161, 0x0000 },

-  { 0x8e00, 0x2182, 0x6000 },

-  { 0x8e00, 0x2172, 0x5000 },

-  { 0x8e00, 0x216a, 0x4000 },

-  { 0x8e00, 0x2166, 0x3000 },

-  { 0x8e00, 0x2164, 0x2000 },

-  { 0x0e00, 0x2163, 0x0000 },

-  { 0x0e00, 0x2165, 0x0000 },

-  { 0x8e00, 0x2168, 0x2000 },

-  { 0x0e00, 0x2167, 0x0000 },

-  { 0x0e00, 0x2169, 0x0000 },

-  { 0x8e00, 0x216e, 0x3000 },

-  { 0x8e00, 0x216c, 0x2000 },

-  { 0x0e00, 0x216b, 0x0000 },

-  { 0x0e00, 0x216d, 0x0000 },

-  { 0x8e00, 0x2170, 0x2000 },

-  { 0x0e00, 0x216f, 0x0000 },

-  { 0x0e00, 0x2171, 0x0000 },

-  { 0x8e00, 0x217a, 0x4000 },

-  { 0x8e00, 0x2176, 0x3000 },

-  { 0x8e00, 0x2174, 0x2000 },

-  { 0x0e00, 0x2173, 0x0000 },

-  { 0x0e00, 0x2175, 0x0000 },

-  { 0x8e00, 0x2178, 0x2000 },

-  { 0x0e00, 0x2177, 0x0000 },

-  { 0x0e00, 0x2179, 0x0000 },

-  { 0x8e00, 0x217e, 0x3000 },

-  { 0x8e00, 0x217c, 0x2000 },

-  { 0x0e00, 0x217b, 0x0000 },

-  { 0x0e00, 0x217d, 0x0000 },

-  { 0x8e00, 0x2180, 0x2000 },

-  { 0x0e00, 0x217f, 0x0000 },

-  { 0x0e00, 0x2181, 0x0000 },

-  { 0x9a00, 0x219e, 0x5000 },

-  { 0x9a00, 0x2196, 0x4000 },

-  { 0x9900, 0x2192, 0x3000 },

-  { 0x9900, 0x2190, 0x2000 },

-  { 0x0e00, 0x2183, 0x0000 },

-  { 0x1900, 0x2191, 0x0000 },

-  { 0x9900, 0x2194, 0x2000 },

-  { 0x1900, 0x2193, 0x0000 },

-  { 0x1a00, 0x2195, 0x0000 },

-  { 0x9900, 0x219a, 0x3000 },

-  { 0x9a00, 0x2198, 0x2000 },

-  { 0x1a00, 0x2197, 0x0000 },

-  { 0x1a00, 0x2199, 0x0000 },

-  { 0x9a00, 0x219c, 0x2000 },

-  { 0x1900, 0x219b, 0x0000 },

-  { 0x1a00, 0x219d, 0x0000 },

-  { 0x9900, 0x21a6, 0x4000 },

-  { 0x9a00, 0x21a2, 0x3000 },

-  { 0x9900, 0x21a0, 0x2000 },

-  { 0x1a00, 0x219f, 0x0000 },

-  { 0x1a00, 0x21a1, 0x0000 },

-  { 0x9a00, 0x21a4, 0x2000 },

-  { 0x1900, 0x21a3, 0x0000 },

-  { 0x1a00, 0x21a5, 0x0000 },

-  { 0x9a00, 0x21aa, 0x3000 },

-  { 0x9a00, 0x21a8, 0x2000 },

-  { 0x1a00, 0x21a7, 0x0000 },

-  { 0x1a00, 0x21a9, 0x0000 },

-  { 0x9a00, 0x21ac, 0x2000 },

-  { 0x1a00, 0x21ab, 0x0000 },

-  { 0x1a00, 0x21ad, 0x0000 },

-  { 0x9900, 0x222e, 0x8000 },

-  { 0x9a00, 0x21ee, 0x7000 },

-  { 0x9900, 0x21ce, 0x6000 },

-  { 0x9a00, 0x21be, 0x5000 },

-  { 0x9a00, 0x21b6, 0x4000 },

-  { 0x9a00, 0x21b2, 0x3000 },

-  { 0x9a00, 0x21b0, 0x2000 },

-  { 0x1a00, 0x21af, 0x0000 },

-  { 0x1a00, 0x21b1, 0x0000 },

-  { 0x9a00, 0x21b4, 0x2000 },

-  { 0x1a00, 0x21b3, 0x0000 },

-  { 0x1a00, 0x21b5, 0x0000 },

-  { 0x9a00, 0x21ba, 0x3000 },

-  { 0x9a00, 0x21b8, 0x2000 },

-  { 0x1a00, 0x21b7, 0x0000 },

-  { 0x1a00, 0x21b9, 0x0000 },

-  { 0x9a00, 0x21bc, 0x2000 },

-  { 0x1a00, 0x21bb, 0x0000 },

-  { 0x1a00, 0x21bd, 0x0000 },

-  { 0x9a00, 0x21c6, 0x4000 },

-  { 0x9a00, 0x21c2, 0x3000 },

-  { 0x9a00, 0x21c0, 0x2000 },

-  { 0x1a00, 0x21bf, 0x0000 },

-  { 0x1a00, 0x21c1, 0x0000 },

-  { 0x9a00, 0x21c4, 0x2000 },

-  { 0x1a00, 0x21c3, 0x0000 },

-  { 0x1a00, 0x21c5, 0x0000 },

-  { 0x9a00, 0x21ca, 0x3000 },

-  { 0x9a00, 0x21c8, 0x2000 },

-  { 0x1a00, 0x21c7, 0x0000 },

-  { 0x1a00, 0x21c9, 0x0000 },

-  { 0x9a00, 0x21cc, 0x2000 },

-  { 0x1a00, 0x21cb, 0x0000 },

-  { 0x1a00, 0x21cd, 0x0000 },

-  { 0x9a00, 0x21de, 0x5000 },

-  { 0x9a00, 0x21d6, 0x4000 },

-  { 0x9900, 0x21d2, 0x3000 },

-  { 0x9a00, 0x21d0, 0x2000 },

-  { 0x1900, 0x21cf, 0x0000 },

-  { 0x1a00, 0x21d1, 0x0000 },

-  { 0x9900, 0x21d4, 0x2000 },

-  { 0x1a00, 0x21d3, 0x0000 },

-  { 0x1a00, 0x21d5, 0x0000 },

-  { 0x9a00, 0x21da, 0x3000 },

-  { 0x9a00, 0x21d8, 0x2000 },

-  { 0x1a00, 0x21d7, 0x0000 },

-  { 0x1a00, 0x21d9, 0x0000 },

-  { 0x9a00, 0x21dc, 0x2000 },

-  { 0x1a00, 0x21db, 0x0000 },

-  { 0x1a00, 0x21dd, 0x0000 },

-  { 0x9a00, 0x21e6, 0x4000 },

-  { 0x9a00, 0x21e2, 0x3000 },

-  { 0x9a00, 0x21e0, 0x2000 },

-  { 0x1a00, 0x21df, 0x0000 },

-  { 0x1a00, 0x21e1, 0x0000 },

-  { 0x9a00, 0x21e4, 0x2000 },

-  { 0x1a00, 0x21e3, 0x0000 },

-  { 0x1a00, 0x21e5, 0x0000 },

-  { 0x9a00, 0x21ea, 0x3000 },

-  { 0x9a00, 0x21e8, 0x2000 },

-  { 0x1a00, 0x21e7, 0x0000 },

-  { 0x1a00, 0x21e9, 0x0000 },

-  { 0x9a00, 0x21ec, 0x2000 },

-  { 0x1a00, 0x21eb, 0x0000 },

-  { 0x1a00, 0x21ed, 0x0000 },

-  { 0x9900, 0x220e, 0x6000 },

-  { 0x9900, 0x21fe, 0x5000 },

-  { 0x9900, 0x21f6, 0x4000 },

-  { 0x9a00, 0x21f2, 0x3000 },

-  { 0x9a00, 0x21f0, 0x2000 },

-  { 0x1a00, 0x21ef, 0x0000 },

-  { 0x1a00, 0x21f1, 0x0000 },

-  { 0x9900, 0x21f4, 0x2000 },

-  { 0x1a00, 0x21f3, 0x0000 },

-  { 0x1900, 0x21f5, 0x0000 },

-  { 0x9900, 0x21fa, 0x3000 },

-  { 0x9900, 0x21f8, 0x2000 },

-  { 0x1900, 0x21f7, 0x0000 },

-  { 0x1900, 0x21f9, 0x0000 },

-  { 0x9900, 0x21fc, 0x2000 },

-  { 0x1900, 0x21fb, 0x0000 },

-  { 0x1900, 0x21fd, 0x0000 },

-  { 0x9900, 0x2206, 0x4000 },

-  { 0x9900, 0x2202, 0x3000 },

-  { 0x9900, 0x2200, 0x2000 },

-  { 0x1900, 0x21ff, 0x0000 },

-  { 0x1900, 0x2201, 0x0000 },

-  { 0x9900, 0x2204, 0x2000 },

-  { 0x1900, 0x2203, 0x0000 },

-  { 0x1900, 0x2205, 0x0000 },

-  { 0x9900, 0x220a, 0x3000 },

-  { 0x9900, 0x2208, 0x2000 },

-  { 0x1900, 0x2207, 0x0000 },

-  { 0x1900, 0x2209, 0x0000 },

-  { 0x9900, 0x220c, 0x2000 },

-  { 0x1900, 0x220b, 0x0000 },

-  { 0x1900, 0x220d, 0x0000 },

-  { 0x9900, 0x221e, 0x5000 },

-  { 0x9900, 0x2216, 0x4000 },

-  { 0x9900, 0x2212, 0x3000 },

-  { 0x9900, 0x2210, 0x2000 },

-  { 0x1900, 0x220f, 0x0000 },

-  { 0x1900, 0x2211, 0x0000 },

-  { 0x9900, 0x2214, 0x2000 },

-  { 0x1900, 0x2213, 0x0000 },

-  { 0x1900, 0x2215, 0x0000 },

-  { 0x9900, 0x221a, 0x3000 },

-  { 0x9900, 0x2218, 0x2000 },

-  { 0x1900, 0x2217, 0x0000 },

-  { 0x1900, 0x2219, 0x0000 },

-  { 0x9900, 0x221c, 0x2000 },

-  { 0x1900, 0x221b, 0x0000 },

-  { 0x1900, 0x221d, 0x0000 },

-  { 0x9900, 0x2226, 0x4000 },

-  { 0x9900, 0x2222, 0x3000 },

-  { 0x9900, 0x2220, 0x2000 },

-  { 0x1900, 0x221f, 0x0000 },

-  { 0x1900, 0x2221, 0x0000 },

-  { 0x9900, 0x2224, 0x2000 },

-  { 0x1900, 0x2223, 0x0000 },

-  { 0x1900, 0x2225, 0x0000 },

-  { 0x9900, 0x222a, 0x3000 },

-  { 0x9900, 0x2228, 0x2000 },

-  { 0x1900, 0x2227, 0x0000 },

-  { 0x1900, 0x2229, 0x0000 },

-  { 0x9900, 0x222c, 0x2000 },

-  { 0x1900, 0x222b, 0x0000 },

-  { 0x1900, 0x222d, 0x0000 },

-  { 0x9900, 0x226e, 0x7000 },

-  { 0x9900, 0x224e, 0x6000 },

-  { 0x9900, 0x223e, 0x5000 },

-  { 0x9900, 0x2236, 0x4000 },

-  { 0x9900, 0x2232, 0x3000 },

-  { 0x9900, 0x2230, 0x2000 },

-  { 0x1900, 0x222f, 0x0000 },

-  { 0x1900, 0x2231, 0x0000 },

-  { 0x9900, 0x2234, 0x2000 },

-  { 0x1900, 0x2233, 0x0000 },

-  { 0x1900, 0x2235, 0x0000 },

-  { 0x9900, 0x223a, 0x3000 },

-  { 0x9900, 0x2238, 0x2000 },

-  { 0x1900, 0x2237, 0x0000 },

-  { 0x1900, 0x2239, 0x0000 },

-  { 0x9900, 0x223c, 0x2000 },

-  { 0x1900, 0x223b, 0x0000 },

-  { 0x1900, 0x223d, 0x0000 },

-  { 0x9900, 0x2246, 0x4000 },

-  { 0x9900, 0x2242, 0x3000 },

-  { 0x9900, 0x2240, 0x2000 },

-  { 0x1900, 0x223f, 0x0000 },

-  { 0x1900, 0x2241, 0x0000 },

-  { 0x9900, 0x2244, 0x2000 },

-  { 0x1900, 0x2243, 0x0000 },

-  { 0x1900, 0x2245, 0x0000 },

-  { 0x9900, 0x224a, 0x3000 },

-  { 0x9900, 0x2248, 0x2000 },

-  { 0x1900, 0x2247, 0x0000 },

-  { 0x1900, 0x2249, 0x0000 },

-  { 0x9900, 0x224c, 0x2000 },

-  { 0x1900, 0x224b, 0x0000 },

-  { 0x1900, 0x224d, 0x0000 },

-  { 0x9900, 0x225e, 0x5000 },

-  { 0x9900, 0x2256, 0x4000 },

-  { 0x9900, 0x2252, 0x3000 },

-  { 0x9900, 0x2250, 0x2000 },

-  { 0x1900, 0x224f, 0x0000 },

-  { 0x1900, 0x2251, 0x0000 },

-  { 0x9900, 0x2254, 0x2000 },

-  { 0x1900, 0x2253, 0x0000 },

-  { 0x1900, 0x2255, 0x0000 },

-  { 0x9900, 0x225a, 0x3000 },

-  { 0x9900, 0x2258, 0x2000 },

-  { 0x1900, 0x2257, 0x0000 },

-  { 0x1900, 0x2259, 0x0000 },

-  { 0x9900, 0x225c, 0x2000 },

-  { 0x1900, 0x225b, 0x0000 },

-  { 0x1900, 0x225d, 0x0000 },

-  { 0x9900, 0x2266, 0x4000 },

-  { 0x9900, 0x2262, 0x3000 },

-  { 0x9900, 0x2260, 0x2000 },

-  { 0x1900, 0x225f, 0x0000 },

-  { 0x1900, 0x2261, 0x0000 },

-  { 0x9900, 0x2264, 0x2000 },

-  { 0x1900, 0x2263, 0x0000 },

-  { 0x1900, 0x2265, 0x0000 },

-  { 0x9900, 0x226a, 0x3000 },

-  { 0x9900, 0x2268, 0x2000 },

-  { 0x1900, 0x2267, 0x0000 },

-  { 0x1900, 0x2269, 0x0000 },

-  { 0x9900, 0x226c, 0x2000 },

-  { 0x1900, 0x226b, 0x0000 },

-  { 0x1900, 0x226d, 0x0000 },

-  { 0x9900, 0x228e, 0x6000 },

-  { 0x9900, 0x227e, 0x5000 },

-  { 0x9900, 0x2276, 0x4000 },

-  { 0x9900, 0x2272, 0x3000 },

-  { 0x9900, 0x2270, 0x2000 },

-  { 0x1900, 0x226f, 0x0000 },

-  { 0x1900, 0x2271, 0x0000 },

-  { 0x9900, 0x2274, 0x2000 },

-  { 0x1900, 0x2273, 0x0000 },

-  { 0x1900, 0x2275, 0x0000 },

-  { 0x9900, 0x227a, 0x3000 },

-  { 0x9900, 0x2278, 0x2000 },

-  { 0x1900, 0x2277, 0x0000 },

-  { 0x1900, 0x2279, 0x0000 },

-  { 0x9900, 0x227c, 0x2000 },

-  { 0x1900, 0x227b, 0x0000 },

-  { 0x1900, 0x227d, 0x0000 },

-  { 0x9900, 0x2286, 0x4000 },

-  { 0x9900, 0x2282, 0x3000 },

-  { 0x9900, 0x2280, 0x2000 },

-  { 0x1900, 0x227f, 0x0000 },

-  { 0x1900, 0x2281, 0x0000 },

-  { 0x9900, 0x2284, 0x2000 },

-  { 0x1900, 0x2283, 0x0000 },

-  { 0x1900, 0x2285, 0x0000 },

-  { 0x9900, 0x228a, 0x3000 },

-  { 0x9900, 0x2288, 0x2000 },

-  { 0x1900, 0x2287, 0x0000 },

-  { 0x1900, 0x2289, 0x0000 },

-  { 0x9900, 0x228c, 0x2000 },

-  { 0x1900, 0x228b, 0x0000 },

-  { 0x1900, 0x228d, 0x0000 },

-  { 0x9900, 0x229e, 0x5000 },

-  { 0x9900, 0x2296, 0x4000 },

-  { 0x9900, 0x2292, 0x3000 },

-  { 0x9900, 0x2290, 0x2000 },

-  { 0x1900, 0x228f, 0x0000 },

-  { 0x1900, 0x2291, 0x0000 },

-  { 0x9900, 0x2294, 0x2000 },

-  { 0x1900, 0x2293, 0x0000 },

-  { 0x1900, 0x2295, 0x0000 },

-  { 0x9900, 0x229a, 0x3000 },

-  { 0x9900, 0x2298, 0x2000 },

-  { 0x1900, 0x2297, 0x0000 },

-  { 0x1900, 0x2299, 0x0000 },

-  { 0x9900, 0x229c, 0x2000 },

-  { 0x1900, 0x229b, 0x0000 },

-  { 0x1900, 0x229d, 0x0000 },

-  { 0x9900, 0x22a6, 0x4000 },

-  { 0x9900, 0x22a2, 0x3000 },

-  { 0x9900, 0x22a0, 0x2000 },

-  { 0x1900, 0x229f, 0x0000 },

-  { 0x1900, 0x22a1, 0x0000 },

-  { 0x9900, 0x22a4, 0x2000 },

-  { 0x1900, 0x22a3, 0x0000 },

-  { 0x1900, 0x22a5, 0x0000 },

-  { 0x9900, 0x22aa, 0x3000 },

-  { 0x9900, 0x22a8, 0x2000 },

-  { 0x1900, 0x22a7, 0x0000 },

-  { 0x1900, 0x22a9, 0x0000 },

-  { 0x9900, 0x22ac, 0x2000 },

-  { 0x1900, 0x22ab, 0x0000 },

-  { 0x1900, 0x22ad, 0x0000 },

-  { 0x8f00, 0x2787, 0xb000 },

-  { 0x9a00, 0x250b, 0xa000 },

-  { 0x9900, 0x23ae, 0x9000 },

-  { 0x9a00, 0x232e, 0x8000 },

-  { 0x9900, 0x22ee, 0x7000 },

-  { 0x9900, 0x22ce, 0x6000 },

-  { 0x9900, 0x22be, 0x5000 },

-  { 0x9900, 0x22b6, 0x4000 },

-  { 0x9900, 0x22b2, 0x3000 },

-  { 0x9900, 0x22b0, 0x2000 },

-  { 0x1900, 0x22af, 0x0000 },

-  { 0x1900, 0x22b1, 0x0000 },

-  { 0x9900, 0x22b4, 0x2000 },

-  { 0x1900, 0x22b3, 0x0000 },

-  { 0x1900, 0x22b5, 0x0000 },

-  { 0x9900, 0x22ba, 0x3000 },

-  { 0x9900, 0x22b8, 0x2000 },

-  { 0x1900, 0x22b7, 0x0000 },

-  { 0x1900, 0x22b9, 0x0000 },

-  { 0x9900, 0x22bc, 0x2000 },

-  { 0x1900, 0x22bb, 0x0000 },

-  { 0x1900, 0x22bd, 0x0000 },

-  { 0x9900, 0x22c6, 0x4000 },

-  { 0x9900, 0x22c2, 0x3000 },

-  { 0x9900, 0x22c0, 0x2000 },

-  { 0x1900, 0x22bf, 0x0000 },

-  { 0x1900, 0x22c1, 0x0000 },

-  { 0x9900, 0x22c4, 0x2000 },

-  { 0x1900, 0x22c3, 0x0000 },

-  { 0x1900, 0x22c5, 0x0000 },

-  { 0x9900, 0x22ca, 0x3000 },

-  { 0x9900, 0x22c8, 0x2000 },

-  { 0x1900, 0x22c7, 0x0000 },

-  { 0x1900, 0x22c9, 0x0000 },

-  { 0x9900, 0x22cc, 0x2000 },

-  { 0x1900, 0x22cb, 0x0000 },

-  { 0x1900, 0x22cd, 0x0000 },

-  { 0x9900, 0x22de, 0x5000 },

-  { 0x9900, 0x22d6, 0x4000 },

-  { 0x9900, 0x22d2, 0x3000 },

-  { 0x9900, 0x22d0, 0x2000 },

-  { 0x1900, 0x22cf, 0x0000 },

-  { 0x1900, 0x22d1, 0x0000 },

-  { 0x9900, 0x22d4, 0x2000 },

-  { 0x1900, 0x22d3, 0x0000 },

-  { 0x1900, 0x22d5, 0x0000 },

-  { 0x9900, 0x22da, 0x3000 },

-  { 0x9900, 0x22d8, 0x2000 },

-  { 0x1900, 0x22d7, 0x0000 },

-  { 0x1900, 0x22d9, 0x0000 },

-  { 0x9900, 0x22dc, 0x2000 },

-  { 0x1900, 0x22db, 0x0000 },

-  { 0x1900, 0x22dd, 0x0000 },

-  { 0x9900, 0x22e6, 0x4000 },

-  { 0x9900, 0x22e2, 0x3000 },

-  { 0x9900, 0x22e0, 0x2000 },

-  { 0x1900, 0x22df, 0x0000 },

-  { 0x1900, 0x22e1, 0x0000 },

-  { 0x9900, 0x22e4, 0x2000 },

-  { 0x1900, 0x22e3, 0x0000 },

-  { 0x1900, 0x22e5, 0x0000 },

-  { 0x9900, 0x22ea, 0x3000 },

-  { 0x9900, 0x22e8, 0x2000 },

-  { 0x1900, 0x22e7, 0x0000 },

-  { 0x1900, 0x22e9, 0x0000 },

-  { 0x9900, 0x22ec, 0x2000 },

-  { 0x1900, 0x22eb, 0x0000 },

-  { 0x1900, 0x22ed, 0x0000 },

-  { 0x9a00, 0x230e, 0x6000 },

-  { 0x9900, 0x22fe, 0x5000 },

-  { 0x9900, 0x22f6, 0x4000 },

-  { 0x9900, 0x22f2, 0x3000 },

-  { 0x9900, 0x22f0, 0x2000 },

-  { 0x1900, 0x22ef, 0x0000 },

-  { 0x1900, 0x22f1, 0x0000 },

-  { 0x9900, 0x22f4, 0x2000 },

-  { 0x1900, 0x22f3, 0x0000 },

-  { 0x1900, 0x22f5, 0x0000 },

-  { 0x9900, 0x22fa, 0x3000 },

-  { 0x9900, 0x22f8, 0x2000 },

-  { 0x1900, 0x22f7, 0x0000 },

-  { 0x1900, 0x22f9, 0x0000 },

-  { 0x9900, 0x22fc, 0x2000 },

-  { 0x1900, 0x22fb, 0x0000 },

-  { 0x1900, 0x22fd, 0x0000 },

-  { 0x9a00, 0x2306, 0x4000 },

-  { 0x9a00, 0x2302, 0x3000 },

-  { 0x9a00, 0x2300, 0x2000 },

-  { 0x1900, 0x22ff, 0x0000 },

-  { 0x1a00, 0x2301, 0x0000 },

-  { 0x9a00, 0x2304, 0x2000 },

-  { 0x1a00, 0x2303, 0x0000 },

-  { 0x1a00, 0x2305, 0x0000 },

-  { 0x9900, 0x230a, 0x3000 },

-  { 0x9900, 0x2308, 0x2000 },

-  { 0x1a00, 0x2307, 0x0000 },

-  { 0x1900, 0x2309, 0x0000 },

-  { 0x9a00, 0x230c, 0x2000 },

-  { 0x1900, 0x230b, 0x0000 },

-  { 0x1a00, 0x230d, 0x0000 },

-  { 0x9a00, 0x231e, 0x5000 },

-  { 0x9a00, 0x2316, 0x4000 },

-  { 0x9a00, 0x2312, 0x3000 },

-  { 0x9a00, 0x2310, 0x2000 },

-  { 0x1a00, 0x230f, 0x0000 },

-  { 0x1a00, 0x2311, 0x0000 },

-  { 0x9a00, 0x2314, 0x2000 },

-  { 0x1a00, 0x2313, 0x0000 },

-  { 0x1a00, 0x2315, 0x0000 },

-  { 0x9a00, 0x231a, 0x3000 },

-  { 0x9a00, 0x2318, 0x2000 },

-  { 0x1a00, 0x2317, 0x0000 },

-  { 0x1a00, 0x2319, 0x0000 },

-  { 0x9a00, 0x231c, 0x2000 },

-  { 0x1a00, 0x231b, 0x0000 },

-  { 0x1a00, 0x231d, 0x0000 },

-  { 0x9a00, 0x2326, 0x4000 },

-  { 0x9a00, 0x2322, 0x3000 },

-  { 0x9900, 0x2320, 0x2000 },

-  { 0x1a00, 0x231f, 0x0000 },

-  { 0x1900, 0x2321, 0x0000 },

-  { 0x9a00, 0x2324, 0x2000 },

-  { 0x1a00, 0x2323, 0x0000 },

-  { 0x1a00, 0x2325, 0x0000 },

-  { 0x9200, 0x232a, 0x3000 },

-  { 0x9a00, 0x2328, 0x2000 },

-  { 0x1a00, 0x2327, 0x0000 },

-  { 0x1600, 0x2329, 0x0000 },

-  { 0x9a00, 0x232c, 0x2000 },

-  { 0x1a00, 0x232b, 0x0000 },

-  { 0x1a00, 0x232d, 0x0000 },

-  { 0x9a00, 0x236e, 0x7000 },

-  { 0x9a00, 0x234e, 0x6000 },

-  { 0x9a00, 0x233e, 0x5000 },

-  { 0x9a00, 0x2336, 0x4000 },

-  { 0x9a00, 0x2332, 0x3000 },

-  { 0x9a00, 0x2330, 0x2000 },

-  { 0x1a00, 0x232f, 0x0000 },

-  { 0x1a00, 0x2331, 0x0000 },

-  { 0x9a00, 0x2334, 0x2000 },

-  { 0x1a00, 0x2333, 0x0000 },

-  { 0x1a00, 0x2335, 0x0000 },

-  { 0x9a00, 0x233a, 0x3000 },

-  { 0x9a00, 0x2338, 0x2000 },

-  { 0x1a00, 0x2337, 0x0000 },

-  { 0x1a00, 0x2339, 0x0000 },

-  { 0x9a00, 0x233c, 0x2000 },

-  { 0x1a00, 0x233b, 0x0000 },

-  { 0x1a00, 0x233d, 0x0000 },

-  { 0x9a00, 0x2346, 0x4000 },

-  { 0x9a00, 0x2342, 0x3000 },

-  { 0x9a00, 0x2340, 0x2000 },

-  { 0x1a00, 0x233f, 0x0000 },

-  { 0x1a00, 0x2341, 0x0000 },

-  { 0x9a00, 0x2344, 0x2000 },

-  { 0x1a00, 0x2343, 0x0000 },

-  { 0x1a00, 0x2345, 0x0000 },

-  { 0x9a00, 0x234a, 0x3000 },

-  { 0x9a00, 0x2348, 0x2000 },

-  { 0x1a00, 0x2347, 0x0000 },

-  { 0x1a00, 0x2349, 0x0000 },

-  { 0x9a00, 0x234c, 0x2000 },

-  { 0x1a00, 0x234b, 0x0000 },

-  { 0x1a00, 0x234d, 0x0000 },

-  { 0x9a00, 0x235e, 0x5000 },

-  { 0x9a00, 0x2356, 0x4000 },

-  { 0x9a00, 0x2352, 0x3000 },

-  { 0x9a00, 0x2350, 0x2000 },

-  { 0x1a00, 0x234f, 0x0000 },

-  { 0x1a00, 0x2351, 0x0000 },

-  { 0x9a00, 0x2354, 0x2000 },

-  { 0x1a00, 0x2353, 0x0000 },

-  { 0x1a00, 0x2355, 0x0000 },

-  { 0x9a00, 0x235a, 0x3000 },

-  { 0x9a00, 0x2358, 0x2000 },

-  { 0x1a00, 0x2357, 0x0000 },

-  { 0x1a00, 0x2359, 0x0000 },

-  { 0x9a00, 0x235c, 0x2000 },

-  { 0x1a00, 0x235b, 0x0000 },

-  { 0x1a00, 0x235d, 0x0000 },

-  { 0x9a00, 0x2366, 0x4000 },

-  { 0x9a00, 0x2362, 0x3000 },

-  { 0x9a00, 0x2360, 0x2000 },

-  { 0x1a00, 0x235f, 0x0000 },

-  { 0x1a00, 0x2361, 0x0000 },

-  { 0x9a00, 0x2364, 0x2000 },

-  { 0x1a00, 0x2363, 0x0000 },

-  { 0x1a00, 0x2365, 0x0000 },

-  { 0x9a00, 0x236a, 0x3000 },

-  { 0x9a00, 0x2368, 0x2000 },

-  { 0x1a00, 0x2367, 0x0000 },

-  { 0x1a00, 0x2369, 0x0000 },

-  { 0x9a00, 0x236c, 0x2000 },

-  { 0x1a00, 0x236b, 0x0000 },

-  { 0x1a00, 0x236d, 0x0000 },

-  { 0x9a00, 0x238e, 0x6000 },

-  { 0x9a00, 0x237e, 0x5000 },

-  { 0x9a00, 0x2376, 0x4000 },

-  { 0x9a00, 0x2372, 0x3000 },

-  { 0x9a00, 0x2370, 0x2000 },

-  { 0x1a00, 0x236f, 0x0000 },

-  { 0x1a00, 0x2371, 0x0000 },

-  { 0x9a00, 0x2374, 0x2000 },

-  { 0x1a00, 0x2373, 0x0000 },

-  { 0x1a00, 0x2375, 0x0000 },

-  { 0x9a00, 0x237a, 0x3000 },

-  { 0x9a00, 0x2378, 0x2000 },

-  { 0x1a00, 0x2377, 0x0000 },

-  { 0x1a00, 0x2379, 0x0000 },

-  { 0x9900, 0x237c, 0x2000 },

-  { 0x1a00, 0x237b, 0x0000 },

-  { 0x1a00, 0x237d, 0x0000 },

-  { 0x9a00, 0x2386, 0x4000 },

-  { 0x9a00, 0x2382, 0x3000 },

-  { 0x9a00, 0x2380, 0x2000 },

-  { 0x1a00, 0x237f, 0x0000 },

-  { 0x1a00, 0x2381, 0x0000 },

-  { 0x9a00, 0x2384, 0x2000 },

-  { 0x1a00, 0x2383, 0x0000 },

-  { 0x1a00, 0x2385, 0x0000 },

-  { 0x9a00, 0x238a, 0x3000 },

-  { 0x9a00, 0x2388, 0x2000 },

-  { 0x1a00, 0x2387, 0x0000 },

-  { 0x1a00, 0x2389, 0x0000 },

-  { 0x9a00, 0x238c, 0x2000 },

-  { 0x1a00, 0x238b, 0x0000 },

-  { 0x1a00, 0x238d, 0x0000 },

-  { 0x9900, 0x239e, 0x5000 },

-  { 0x9a00, 0x2396, 0x4000 },

-  { 0x9a00, 0x2392, 0x3000 },

-  { 0x9a00, 0x2390, 0x2000 },

-  { 0x1a00, 0x238f, 0x0000 },

-  { 0x1a00, 0x2391, 0x0000 },

-  { 0x9a00, 0x2394, 0x2000 },

-  { 0x1a00, 0x2393, 0x0000 },

-  { 0x1a00, 0x2395, 0x0000 },

-  { 0x9a00, 0x239a, 0x3000 },

-  { 0x9a00, 0x2398, 0x2000 },

-  { 0x1a00, 0x2397, 0x0000 },

-  { 0x1a00, 0x2399, 0x0000 },

-  { 0x9900, 0x239c, 0x2000 },

-  { 0x1900, 0x239b, 0x0000 },

-  { 0x1900, 0x239d, 0x0000 },

-  { 0x9900, 0x23a6, 0x4000 },

-  { 0x9900, 0x23a2, 0x3000 },

-  { 0x9900, 0x23a0, 0x2000 },

-  { 0x1900, 0x239f, 0x0000 },

-  { 0x1900, 0x23a1, 0x0000 },

-  { 0x9900, 0x23a4, 0x2000 },

-  { 0x1900, 0x23a3, 0x0000 },

-  { 0x1900, 0x23a5, 0x0000 },

-  { 0x9900, 0x23aa, 0x3000 },

-  { 0x9900, 0x23a8, 0x2000 },

-  { 0x1900, 0x23a7, 0x0000 },

-  { 0x1900, 0x23a9, 0x0000 },

-  { 0x9900, 0x23ac, 0x2000 },

-  { 0x1900, 0x23ab, 0x0000 },

-  { 0x1900, 0x23ad, 0x0000 },

-  { 0x8f00, 0x248b, 0x8000 },

-  { 0x9a00, 0x241d, 0x7000 },

-  { 0x9a00, 0x23ce, 0x6000 },

-  { 0x9a00, 0x23be, 0x5000 },

-  { 0x9500, 0x23b6, 0x4000 },

-  { 0x9900, 0x23b2, 0x3000 },

-  { 0x9900, 0x23b0, 0x2000 },

-  { 0x1900, 0x23af, 0x0000 },

-  { 0x1900, 0x23b1, 0x0000 },

-  { 0x9600, 0x23b4, 0x2000 },

-  { 0x1900, 0x23b3, 0x0000 },

-  { 0x1200, 0x23b5, 0x0000 },

-  { 0x9a00, 0x23ba, 0x3000 },

-  { 0x9a00, 0x23b8, 0x2000 },

-  { 0x1a00, 0x23b7, 0x0000 },

-  { 0x1a00, 0x23b9, 0x0000 },

-  { 0x9a00, 0x23bc, 0x2000 },

-  { 0x1a00, 0x23bb, 0x0000 },

-  { 0x1a00, 0x23bd, 0x0000 },

-  { 0x9a00, 0x23c6, 0x4000 },

-  { 0x9a00, 0x23c2, 0x3000 },

-  { 0x9a00, 0x23c0, 0x2000 },

-  { 0x1a00, 0x23bf, 0x0000 },

-  { 0x1a00, 0x23c1, 0x0000 },

-  { 0x9a00, 0x23c4, 0x2000 },

-  { 0x1a00, 0x23c3, 0x0000 },

-  { 0x1a00, 0x23c5, 0x0000 },

-  { 0x9a00, 0x23ca, 0x3000 },

-  { 0x9a00, 0x23c8, 0x2000 },

-  { 0x1a00, 0x23c7, 0x0000 },

-  { 0x1a00, 0x23c9, 0x0000 },

-  { 0x9a00, 0x23cc, 0x2000 },

-  { 0x1a00, 0x23cb, 0x0000 },

-  { 0x1a00, 0x23cd, 0x0000 },

-  { 0x9a00, 0x240d, 0x5000 },

-  { 0x9a00, 0x2405, 0x4000 },

-  { 0x9a00, 0x2401, 0x3000 },

-  { 0x9a00, 0x23d0, 0x2000 },

-  { 0x1a00, 0x23cf, 0x0000 },

-  { 0x1a00, 0x2400, 0x0000 },

-  { 0x9a00, 0x2403, 0x2000 },

-  { 0x1a00, 0x2402, 0x0000 },

-  { 0x1a00, 0x2404, 0x0000 },

-  { 0x9a00, 0x2409, 0x3000 },

-  { 0x9a00, 0x2407, 0x2000 },

-  { 0x1a00, 0x2406, 0x0000 },

-  { 0x1a00, 0x2408, 0x0000 },

-  { 0x9a00, 0x240b, 0x2000 },

-  { 0x1a00, 0x240a, 0x0000 },

-  { 0x1a00, 0x240c, 0x0000 },

-  { 0x9a00, 0x2415, 0x4000 },

-  { 0x9a00, 0x2411, 0x3000 },

-  { 0x9a00, 0x240f, 0x2000 },

-  { 0x1a00, 0x240e, 0x0000 },

-  { 0x1a00, 0x2410, 0x0000 },

-  { 0x9a00, 0x2413, 0x2000 },

-  { 0x1a00, 0x2412, 0x0000 },

-  { 0x1a00, 0x2414, 0x0000 },

-  { 0x9a00, 0x2419, 0x3000 },

-  { 0x9a00, 0x2417, 0x2000 },

-  { 0x1a00, 0x2416, 0x0000 },

-  { 0x1a00, 0x2418, 0x0000 },

-  { 0x9a00, 0x241b, 0x2000 },

-  { 0x1a00, 0x241a, 0x0000 },

-  { 0x1a00, 0x241c, 0x0000 },

-  { 0x8f00, 0x246b, 0x6000 },

-  { 0x9a00, 0x2446, 0x5000 },

-  { 0x9a00, 0x2425, 0x4000 },

-  { 0x9a00, 0x2421, 0x3000 },

-  { 0x9a00, 0x241f, 0x2000 },

-  { 0x1a00, 0x241e, 0x0000 },

-  { 0x1a00, 0x2420, 0x0000 },

-  { 0x9a00, 0x2423, 0x2000 },

-  { 0x1a00, 0x2422, 0x0000 },

-  { 0x1a00, 0x2424, 0x0000 },

-  { 0x9a00, 0x2442, 0x3000 },

-  { 0x9a00, 0x2440, 0x2000 },

-  { 0x1a00, 0x2426, 0x0000 },

-  { 0x1a00, 0x2441, 0x0000 },

-  { 0x9a00, 0x2444, 0x2000 },

-  { 0x1a00, 0x2443, 0x0000 },

-  { 0x1a00, 0x2445, 0x0000 },

-  { 0x8f00, 0x2463, 0x4000 },

-  { 0x9a00, 0x244a, 0x3000 },

-  { 0x9a00, 0x2448, 0x2000 },

-  { 0x1a00, 0x2447, 0x0000 },

-  { 0x1a00, 0x2449, 0x0000 },

-  { 0x8f00, 0x2461, 0x2000 },

-  { 0x0f00, 0x2460, 0x0000 },

-  { 0x0f00, 0x2462, 0x0000 },

-  { 0x8f00, 0x2467, 0x3000 },

-  { 0x8f00, 0x2465, 0x2000 },

-  { 0x0f00, 0x2464, 0x0000 },

-  { 0x0f00, 0x2466, 0x0000 },

-  { 0x8f00, 0x2469, 0x2000 },

-  { 0x0f00, 0x2468, 0x0000 },

-  { 0x0f00, 0x246a, 0x0000 },

-  { 0x8f00, 0x247b, 0x5000 },

-  { 0x8f00, 0x2473, 0x4000 },

-  { 0x8f00, 0x246f, 0x3000 },

-  { 0x8f00, 0x246d, 0x2000 },

-  { 0x0f00, 0x246c, 0x0000 },

-  { 0x0f00, 0x246e, 0x0000 },

-  { 0x8f00, 0x2471, 0x2000 },

-  { 0x0f00, 0x2470, 0x0000 },

-  { 0x0f00, 0x2472, 0x0000 },

-  { 0x8f00, 0x2477, 0x3000 },

-  { 0x8f00, 0x2475, 0x2000 },

-  { 0x0f00, 0x2474, 0x0000 },

-  { 0x0f00, 0x2476, 0x0000 },

-  { 0x8f00, 0x2479, 0x2000 },

-  { 0x0f00, 0x2478, 0x0000 },

-  { 0x0f00, 0x247a, 0x0000 },

-  { 0x8f00, 0x2483, 0x4000 },

-  { 0x8f00, 0x247f, 0x3000 },

-  { 0x8f00, 0x247d, 0x2000 },

-  { 0x0f00, 0x247c, 0x0000 },

-  { 0x0f00, 0x247e, 0x0000 },

-  { 0x8f00, 0x2481, 0x2000 },

-  { 0x0f00, 0x2480, 0x0000 },

-  { 0x0f00, 0x2482, 0x0000 },

-  { 0x8f00, 0x2487, 0x3000 },

-  { 0x8f00, 0x2485, 0x2000 },

-  { 0x0f00, 0x2484, 0x0000 },

-  { 0x0f00, 0x2486, 0x0000 },

-  { 0x8f00, 0x2489, 0x2000 },

-  { 0x0f00, 0x2488, 0x0000 },

-  { 0x0f00, 0x248a, 0x0000 },

-  { 0x9a00, 0x24cb, 0x7000 },

-  { 0x9a00, 0x24ab, 0x6000 },

-  { 0x8f00, 0x249b, 0x5000 },

-  { 0x8f00, 0x2493, 0x4000 },

-  { 0x8f00, 0x248f, 0x3000 },

-  { 0x8f00, 0x248d, 0x2000 },

-  { 0x0f00, 0x248c, 0x0000 },

-  { 0x0f00, 0x248e, 0x0000 },

-  { 0x8f00, 0x2491, 0x2000 },

-  { 0x0f00, 0x2490, 0x0000 },

-  { 0x0f00, 0x2492, 0x0000 },

-  { 0x8f00, 0x2497, 0x3000 },

-  { 0x8f00, 0x2495, 0x2000 },

-  { 0x0f00, 0x2494, 0x0000 },

-  { 0x0f00, 0x2496, 0x0000 },

-  { 0x8f00, 0x2499, 0x2000 },

-  { 0x0f00, 0x2498, 0x0000 },

-  { 0x0f00, 0x249a, 0x0000 },

-  { 0x9a00, 0x24a3, 0x4000 },

-  { 0x9a00, 0x249f, 0x3000 },

-  { 0x9a00, 0x249d, 0x2000 },

-  { 0x1a00, 0x249c, 0x0000 },

-  { 0x1a00, 0x249e, 0x0000 },

-  { 0x9a00, 0x24a1, 0x2000 },

-  { 0x1a00, 0x24a0, 0x0000 },

-  { 0x1a00, 0x24a2, 0x0000 },

-  { 0x9a00, 0x24a7, 0x3000 },

-  { 0x9a00, 0x24a5, 0x2000 },

-  { 0x1a00, 0x24a4, 0x0000 },

-  { 0x1a00, 0x24a6, 0x0000 },

-  { 0x9a00, 0x24a9, 0x2000 },

-  { 0x1a00, 0x24a8, 0x0000 },

-  { 0x1a00, 0x24aa, 0x0000 },

-  { 0x9a00, 0x24bb, 0x5000 },

-  { 0x9a00, 0x24b3, 0x4000 },

-  { 0x9a00, 0x24af, 0x3000 },

-  { 0x9a00, 0x24ad, 0x2000 },

-  { 0x1a00, 0x24ac, 0x0000 },

-  { 0x1a00, 0x24ae, 0x0000 },

-  { 0x9a00, 0x24b1, 0x2000 },

-  { 0x1a00, 0x24b0, 0x0000 },

-  { 0x1a00, 0x24b2, 0x0000 },

-  { 0x9a00, 0x24b7, 0x3000 },

-  { 0x9a00, 0x24b5, 0x2000 },

-  { 0x1a00, 0x24b4, 0x0000 },

-  { 0x1a00, 0x24b6, 0x0000 },

-  { 0x9a00, 0x24b9, 0x2000 },

-  { 0x1a00, 0x24b8, 0x0000 },

-  { 0x1a00, 0x24ba, 0x0000 },

-  { 0x9a00, 0x24c3, 0x4000 },

-  { 0x9a00, 0x24bf, 0x3000 },

-  { 0x9a00, 0x24bd, 0x2000 },

-  { 0x1a00, 0x24bc, 0x0000 },

-  { 0x1a00, 0x24be, 0x0000 },

-  { 0x9a00, 0x24c1, 0x2000 },

-  { 0x1a00, 0x24c0, 0x0000 },

-  { 0x1a00, 0x24c2, 0x0000 },

-  { 0x9a00, 0x24c7, 0x3000 },

-  { 0x9a00, 0x24c5, 0x2000 },

-  { 0x1a00, 0x24c4, 0x0000 },

-  { 0x1a00, 0x24c6, 0x0000 },

-  { 0x9a00, 0x24c9, 0x2000 },

-  { 0x1a00, 0x24c8, 0x0000 },

-  { 0x1a00, 0x24ca, 0x0000 },

-  { 0x8f00, 0x24eb, 0x6000 },

-  { 0x9a00, 0x24db, 0x5000 },

-  { 0x9a00, 0x24d3, 0x4000 },

-  { 0x9a00, 0x24cf, 0x3000 },

-  { 0x9a00, 0x24cd, 0x2000 },

-  { 0x1a00, 0x24cc, 0x0000 },

-  { 0x1a00, 0x24ce, 0x0000 },

-  { 0x9a00, 0x24d1, 0x2000 },

-  { 0x1a00, 0x24d0, 0x0000 },

-  { 0x1a00, 0x24d2, 0x0000 },

-  { 0x9a00, 0x24d7, 0x3000 },

-  { 0x9a00, 0x24d5, 0x2000 },

-  { 0x1a00, 0x24d4, 0x0000 },

-  { 0x1a00, 0x24d6, 0x0000 },

-  { 0x9a00, 0x24d9, 0x2000 },

-  { 0x1a00, 0x24d8, 0x0000 },

-  { 0x1a00, 0x24da, 0x0000 },

-  { 0x9a00, 0x24e3, 0x4000 },

-  { 0x9a00, 0x24df, 0x3000 },

-  { 0x9a00, 0x24dd, 0x2000 },

-  { 0x1a00, 0x24dc, 0x0000 },

-  { 0x1a00, 0x24de, 0x0000 },

-  { 0x9a00, 0x24e1, 0x2000 },

-  { 0x1a00, 0x24e0, 0x0000 },

-  { 0x1a00, 0x24e2, 0x0000 },

-  { 0x9a00, 0x24e7, 0x3000 },

-  { 0x9a00, 0x24e5, 0x2000 },

-  { 0x1a00, 0x24e4, 0x0000 },

-  { 0x1a00, 0x24e6, 0x0000 },

-  { 0x9a00, 0x24e9, 0x2000 },

-  { 0x1a00, 0x24e8, 0x0000 },

-  { 0x0f00, 0x24ea, 0x0000 },

-  { 0x8f00, 0x24fb, 0x5000 },

-  { 0x8f00, 0x24f3, 0x4000 },

-  { 0x8f00, 0x24ef, 0x3000 },

-  { 0x8f00, 0x24ed, 0x2000 },

-  { 0x0f00, 0x24ec, 0x0000 },

-  { 0x0f00, 0x24ee, 0x0000 },

-  { 0x8f00, 0x24f1, 0x2000 },

-  { 0x0f00, 0x24f0, 0x0000 },

-  { 0x0f00, 0x24f2, 0x0000 },

-  { 0x8f00, 0x24f7, 0x3000 },

-  { 0x8f00, 0x24f5, 0x2000 },

-  { 0x0f00, 0x24f4, 0x0000 },

-  { 0x0f00, 0x24f6, 0x0000 },

-  { 0x8f00, 0x24f9, 0x2000 },

-  { 0x0f00, 0x24f8, 0x0000 },

-  { 0x0f00, 0x24fa, 0x0000 },

-  { 0x9a00, 0x2503, 0x4000 },

-  { 0x8f00, 0x24ff, 0x3000 },

-  { 0x8f00, 0x24fd, 0x2000 },

-  { 0x0f00, 0x24fc, 0x0000 },

-  { 0x0f00, 0x24fe, 0x0000 },

-  { 0x9a00, 0x2501, 0x2000 },

-  { 0x1a00, 0x2500, 0x0000 },

-  { 0x1a00, 0x2502, 0x0000 },

-  { 0x9a00, 0x2507, 0x3000 },

-  { 0x9a00, 0x2505, 0x2000 },

-  { 0x1a00, 0x2504, 0x0000 },

-  { 0x1a00, 0x2506, 0x0000 },

-  { 0x9a00, 0x2509, 0x2000 },

-  { 0x1a00, 0x2508, 0x0000 },

-  { 0x1a00, 0x250a, 0x0000 },

-  { 0x9a00, 0x260b, 0x9000 },

-  { 0x9a00, 0x258b, 0x8000 },

-  { 0x9a00, 0x254b, 0x7000 },

-  { 0x9a00, 0x252b, 0x6000 },

-  { 0x9a00, 0x251b, 0x5000 },

-  { 0x9a00, 0x2513, 0x4000 },

-  { 0x9a00, 0x250f, 0x3000 },

-  { 0x9a00, 0x250d, 0x2000 },

-  { 0x1a00, 0x250c, 0x0000 },

-  { 0x1a00, 0x250e, 0x0000 },

-  { 0x9a00, 0x2511, 0x2000 },

-  { 0x1a00, 0x2510, 0x0000 },

-  { 0x1a00, 0x2512, 0x0000 },

-  { 0x9a00, 0x2517, 0x3000 },

-  { 0x9a00, 0x2515, 0x2000 },

-  { 0x1a00, 0x2514, 0x0000 },

-  { 0x1a00, 0x2516, 0x0000 },

-  { 0x9a00, 0x2519, 0x2000 },

-  { 0x1a00, 0x2518, 0x0000 },

-  { 0x1a00, 0x251a, 0x0000 },

-  { 0x9a00, 0x2523, 0x4000 },

-  { 0x9a00, 0x251f, 0x3000 },

-  { 0x9a00, 0x251d, 0x2000 },

-  { 0x1a00, 0x251c, 0x0000 },

-  { 0x1a00, 0x251e, 0x0000 },

-  { 0x9a00, 0x2521, 0x2000 },

-  { 0x1a00, 0x2520, 0x0000 },

-  { 0x1a00, 0x2522, 0x0000 },

-  { 0x9a00, 0x2527, 0x3000 },

-  { 0x9a00, 0x2525, 0x2000 },

-  { 0x1a00, 0x2524, 0x0000 },

-  { 0x1a00, 0x2526, 0x0000 },

-  { 0x9a00, 0x2529, 0x2000 },

-  { 0x1a00, 0x2528, 0x0000 },

-  { 0x1a00, 0x252a, 0x0000 },

-  { 0x9a00, 0x253b, 0x5000 },

-  { 0x9a00, 0x2533, 0x4000 },

-  { 0x9a00, 0x252f, 0x3000 },

-  { 0x9a00, 0x252d, 0x2000 },

-  { 0x1a00, 0x252c, 0x0000 },

-  { 0x1a00, 0x252e, 0x0000 },

-  { 0x9a00, 0x2531, 0x2000 },

-  { 0x1a00, 0x2530, 0x0000 },

-  { 0x1a00, 0x2532, 0x0000 },

-  { 0x9a00, 0x2537, 0x3000 },

-  { 0x9a00, 0x2535, 0x2000 },

-  { 0x1a00, 0x2534, 0x0000 },

-  { 0x1a00, 0x2536, 0x0000 },

-  { 0x9a00, 0x2539, 0x2000 },

-  { 0x1a00, 0x2538, 0x0000 },

-  { 0x1a00, 0x253a, 0x0000 },

-  { 0x9a00, 0x2543, 0x4000 },

-  { 0x9a00, 0x253f, 0x3000 },

-  { 0x9a00, 0x253d, 0x2000 },

-  { 0x1a00, 0x253c, 0x0000 },

-  { 0x1a00, 0x253e, 0x0000 },

-  { 0x9a00, 0x2541, 0x2000 },

-  { 0x1a00, 0x2540, 0x0000 },

-  { 0x1a00, 0x2542, 0x0000 },

-  { 0x9a00, 0x2547, 0x3000 },

-  { 0x9a00, 0x2545, 0x2000 },

-  { 0x1a00, 0x2544, 0x0000 },

-  { 0x1a00, 0x2546, 0x0000 },

-  { 0x9a00, 0x2549, 0x2000 },

-  { 0x1a00, 0x2548, 0x0000 },

-  { 0x1a00, 0x254a, 0x0000 },

-  { 0x9a00, 0x256b, 0x6000 },

-  { 0x9a00, 0x255b, 0x5000 },

-  { 0x9a00, 0x2553, 0x4000 },

-  { 0x9a00, 0x254f, 0x3000 },

-  { 0x9a00, 0x254d, 0x2000 },

-  { 0x1a00, 0x254c, 0x0000 },

-  { 0x1a00, 0x254e, 0x0000 },

-  { 0x9a00, 0x2551, 0x2000 },

-  { 0x1a00, 0x2550, 0x0000 },

-  { 0x1a00, 0x2552, 0x0000 },

-  { 0x9a00, 0x2557, 0x3000 },

-  { 0x9a00, 0x2555, 0x2000 },

-  { 0x1a00, 0x2554, 0x0000 },

-  { 0x1a00, 0x2556, 0x0000 },

-  { 0x9a00, 0x2559, 0x2000 },

-  { 0x1a00, 0x2558, 0x0000 },

-  { 0x1a00, 0x255a, 0x0000 },

-  { 0x9a00, 0x2563, 0x4000 },

-  { 0x9a00, 0x255f, 0x3000 },

-  { 0x9a00, 0x255d, 0x2000 },

-  { 0x1a00, 0x255c, 0x0000 },

-  { 0x1a00, 0x255e, 0x0000 },

-  { 0x9a00, 0x2561, 0x2000 },

-  { 0x1a00, 0x2560, 0x0000 },

-  { 0x1a00, 0x2562, 0x0000 },

-  { 0x9a00, 0x2567, 0x3000 },

-  { 0x9a00, 0x2565, 0x2000 },

-  { 0x1a00, 0x2564, 0x0000 },

-  { 0x1a00, 0x2566, 0x0000 },

-  { 0x9a00, 0x2569, 0x2000 },

-  { 0x1a00, 0x2568, 0x0000 },

-  { 0x1a00, 0x256a, 0x0000 },

-  { 0x9a00, 0x257b, 0x5000 },

-  { 0x9a00, 0x2573, 0x4000 },

-  { 0x9a00, 0x256f, 0x3000 },

-  { 0x9a00, 0x256d, 0x2000 },

-  { 0x1a00, 0x256c, 0x0000 },

-  { 0x1a00, 0x256e, 0x0000 },

-  { 0x9a00, 0x2571, 0x2000 },

-  { 0x1a00, 0x2570, 0x0000 },

-  { 0x1a00, 0x2572, 0x0000 },

-  { 0x9a00, 0x2577, 0x3000 },

-  { 0x9a00, 0x2575, 0x2000 },

-  { 0x1a00, 0x2574, 0x0000 },

-  { 0x1a00, 0x2576, 0x0000 },

-  { 0x9a00, 0x2579, 0x2000 },

-  { 0x1a00, 0x2578, 0x0000 },

-  { 0x1a00, 0x257a, 0x0000 },

-  { 0x9a00, 0x2583, 0x4000 },

-  { 0x9a00, 0x257f, 0x3000 },

-  { 0x9a00, 0x257d, 0x2000 },

-  { 0x1a00, 0x257c, 0x0000 },

-  { 0x1a00, 0x257e, 0x0000 },

-  { 0x9a00, 0x2581, 0x2000 },

-  { 0x1a00, 0x2580, 0x0000 },

-  { 0x1a00, 0x2582, 0x0000 },

-  { 0x9a00, 0x2587, 0x3000 },

-  { 0x9a00, 0x2585, 0x2000 },

-  { 0x1a00, 0x2584, 0x0000 },

-  { 0x1a00, 0x2586, 0x0000 },

-  { 0x9a00, 0x2589, 0x2000 },

-  { 0x1a00, 0x2588, 0x0000 },

-  { 0x1a00, 0x258a, 0x0000 },

-  { 0x9a00, 0x25cb, 0x7000 },

-  { 0x9a00, 0x25ab, 0x6000 },

-  { 0x9a00, 0x259b, 0x5000 },

-  { 0x9a00, 0x2593, 0x4000 },

-  { 0x9a00, 0x258f, 0x3000 },

-  { 0x9a00, 0x258d, 0x2000 },

-  { 0x1a00, 0x258c, 0x0000 },

-  { 0x1a00, 0x258e, 0x0000 },

-  { 0x9a00, 0x2591, 0x2000 },

-  { 0x1a00, 0x2590, 0x0000 },

-  { 0x1a00, 0x2592, 0x0000 },

-  { 0x9a00, 0x2597, 0x3000 },

-  { 0x9a00, 0x2595, 0x2000 },

-  { 0x1a00, 0x2594, 0x0000 },

-  { 0x1a00, 0x2596, 0x0000 },

-  { 0x9a00, 0x2599, 0x2000 },

-  { 0x1a00, 0x2598, 0x0000 },

-  { 0x1a00, 0x259a, 0x0000 },

-  { 0x9a00, 0x25a3, 0x4000 },

-  { 0x9a00, 0x259f, 0x3000 },

-  { 0x9a00, 0x259d, 0x2000 },

-  { 0x1a00, 0x259c, 0x0000 },

-  { 0x1a00, 0x259e, 0x0000 },

-  { 0x9a00, 0x25a1, 0x2000 },

-  { 0x1a00, 0x25a0, 0x0000 },

-  { 0x1a00, 0x25a2, 0x0000 },

-  { 0x9a00, 0x25a7, 0x3000 },

-  { 0x9a00, 0x25a5, 0x2000 },

-  { 0x1a00, 0x25a4, 0x0000 },

-  { 0x1a00, 0x25a6, 0x0000 },

-  { 0x9a00, 0x25a9, 0x2000 },

-  { 0x1a00, 0x25a8, 0x0000 },

-  { 0x1a00, 0x25aa, 0x0000 },

-  { 0x9a00, 0x25bb, 0x5000 },

-  { 0x9a00, 0x25b3, 0x4000 },

-  { 0x9a00, 0x25af, 0x3000 },

-  { 0x9a00, 0x25ad, 0x2000 },

-  { 0x1a00, 0x25ac, 0x0000 },

-  { 0x1a00, 0x25ae, 0x0000 },

-  { 0x9a00, 0x25b1, 0x2000 },

-  { 0x1a00, 0x25b0, 0x0000 },

-  { 0x1a00, 0x25b2, 0x0000 },

-  { 0x9900, 0x25b7, 0x3000 },

-  { 0x9a00, 0x25b5, 0x2000 },

-  { 0x1a00, 0x25b4, 0x0000 },

-  { 0x1a00, 0x25b6, 0x0000 },

-  { 0x9a00, 0x25b9, 0x2000 },

-  { 0x1a00, 0x25b8, 0x0000 },

-  { 0x1a00, 0x25ba, 0x0000 },

-  { 0x9a00, 0x25c3, 0x4000 },

-  { 0x9a00, 0x25bf, 0x3000 },

-  { 0x9a00, 0x25bd, 0x2000 },

-  { 0x1a00, 0x25bc, 0x0000 },

-  { 0x1a00, 0x25be, 0x0000 },

-  { 0x9900, 0x25c1, 0x2000 },

-  { 0x1a00, 0x25c0, 0x0000 },

-  { 0x1a00, 0x25c2, 0x0000 },

-  { 0x9a00, 0x25c7, 0x3000 },

-  { 0x9a00, 0x25c5, 0x2000 },

-  { 0x1a00, 0x25c4, 0x0000 },

-  { 0x1a00, 0x25c6, 0x0000 },

-  { 0x9a00, 0x25c9, 0x2000 },

-  { 0x1a00, 0x25c8, 0x0000 },

-  { 0x1a00, 0x25ca, 0x0000 },

-  { 0x9a00, 0x25eb, 0x6000 },

-  { 0x9a00, 0x25db, 0x5000 },

-  { 0x9a00, 0x25d3, 0x4000 },

-  { 0x9a00, 0x25cf, 0x3000 },

-  { 0x9a00, 0x25cd, 0x2000 },

-  { 0x1a00, 0x25cc, 0x0000 },

-  { 0x1a00, 0x25ce, 0x0000 },

-  { 0x9a00, 0x25d1, 0x2000 },

-  { 0x1a00, 0x25d0, 0x0000 },

-  { 0x1a00, 0x25d2, 0x0000 },

-  { 0x9a00, 0x25d7, 0x3000 },

-  { 0x9a00, 0x25d5, 0x2000 },

-  { 0x1a00, 0x25d4, 0x0000 },

-  { 0x1a00, 0x25d6, 0x0000 },

-  { 0x9a00, 0x25d9, 0x2000 },

-  { 0x1a00, 0x25d8, 0x0000 },

-  { 0x1a00, 0x25da, 0x0000 },

-  { 0x9a00, 0x25e3, 0x4000 },

-  { 0x9a00, 0x25df, 0x3000 },

-  { 0x9a00, 0x25dd, 0x2000 },

-  { 0x1a00, 0x25dc, 0x0000 },

-  { 0x1a00, 0x25de, 0x0000 },

-  { 0x9a00, 0x25e1, 0x2000 },

-  { 0x1a00, 0x25e0, 0x0000 },

-  { 0x1a00, 0x25e2, 0x0000 },

-  { 0x9a00, 0x25e7, 0x3000 },

-  { 0x9a00, 0x25e5, 0x2000 },

-  { 0x1a00, 0x25e4, 0x0000 },

-  { 0x1a00, 0x25e6, 0x0000 },

-  { 0x9a00, 0x25e9, 0x2000 },

-  { 0x1a00, 0x25e8, 0x0000 },

-  { 0x1a00, 0x25ea, 0x0000 },

-  { 0x9900, 0x25fb, 0x5000 },

-  { 0x9a00, 0x25f3, 0x4000 },

-  { 0x9a00, 0x25ef, 0x3000 },

-  { 0x9a00, 0x25ed, 0x2000 },

-  { 0x1a00, 0x25ec, 0x0000 },

-  { 0x1a00, 0x25ee, 0x0000 },

-  { 0x9a00, 0x25f1, 0x2000 },

-  { 0x1a00, 0x25f0, 0x0000 },

-  { 0x1a00, 0x25f2, 0x0000 },

-  { 0x9a00, 0x25f7, 0x3000 },

-  { 0x9a00, 0x25f5, 0x2000 },

-  { 0x1a00, 0x25f4, 0x0000 },

-  { 0x1a00, 0x25f6, 0x0000 },

-  { 0x9900, 0x25f9, 0x2000 },

-  { 0x1900, 0x25f8, 0x0000 },

-  { 0x1900, 0x25fa, 0x0000 },

-  { 0x9a00, 0x2603, 0x4000 },

-  { 0x9900, 0x25ff, 0x3000 },

-  { 0x9900, 0x25fd, 0x2000 },

-  { 0x1900, 0x25fc, 0x0000 },

-  { 0x1900, 0x25fe, 0x0000 },

-  { 0x9a00, 0x2601, 0x2000 },

-  { 0x1a00, 0x2600, 0x0000 },

-  { 0x1a00, 0x2602, 0x0000 },

-  { 0x9a00, 0x2607, 0x3000 },

-  { 0x9a00, 0x2605, 0x2000 },

-  { 0x1a00, 0x2604, 0x0000 },

-  { 0x1a00, 0x2606, 0x0000 },

-  { 0x9a00, 0x2609, 0x2000 },

-  { 0x1a00, 0x2608, 0x0000 },

-  { 0x1a00, 0x260a, 0x0000 },

-  { 0x9a00, 0x268e, 0x8000 },

-  { 0x9a00, 0x264c, 0x7000 },

-  { 0x9a00, 0x262c, 0x6000 },

-  { 0x9a00, 0x261c, 0x5000 },

-  { 0x9a00, 0x2613, 0x4000 },

-  { 0x9a00, 0x260f, 0x3000 },

-  { 0x9a00, 0x260d, 0x2000 },

-  { 0x1a00, 0x260c, 0x0000 },

-  { 0x1a00, 0x260e, 0x0000 },

-  { 0x9a00, 0x2611, 0x2000 },

-  { 0x1a00, 0x2610, 0x0000 },

-  { 0x1a00, 0x2612, 0x0000 },

-  { 0x9a00, 0x2617, 0x3000 },

-  { 0x9a00, 0x2615, 0x2000 },

-  { 0x1a00, 0x2614, 0x0000 },

-  { 0x1a00, 0x2616, 0x0000 },

-  { 0x9a00, 0x261a, 0x2000 },

-  { 0x1a00, 0x2619, 0x0000 },

-  { 0x1a00, 0x261b, 0x0000 },

-  { 0x9a00, 0x2624, 0x4000 },

-  { 0x9a00, 0x2620, 0x3000 },

-  { 0x9a00, 0x261e, 0x2000 },

-  { 0x1a00, 0x261d, 0x0000 },

-  { 0x1a00, 0x261f, 0x0000 },

-  { 0x9a00, 0x2622, 0x2000 },

-  { 0x1a00, 0x2621, 0x0000 },

-  { 0x1a00, 0x2623, 0x0000 },

-  { 0x9a00, 0x2628, 0x3000 },

-  { 0x9a00, 0x2626, 0x2000 },

-  { 0x1a00, 0x2625, 0x0000 },

-  { 0x1a00, 0x2627, 0x0000 },

-  { 0x9a00, 0x262a, 0x2000 },

-  { 0x1a00, 0x2629, 0x0000 },

-  { 0x1a00, 0x262b, 0x0000 },

-  { 0x9a00, 0x263c, 0x5000 },

-  { 0x9a00, 0x2634, 0x4000 },

-  { 0x9a00, 0x2630, 0x3000 },

-  { 0x9a00, 0x262e, 0x2000 },

-  { 0x1a00, 0x262d, 0x0000 },

-  { 0x1a00, 0x262f, 0x0000 },

-  { 0x9a00, 0x2632, 0x2000 },

-  { 0x1a00, 0x2631, 0x0000 },

-  { 0x1a00, 0x2633, 0x0000 },

-  { 0x9a00, 0x2638, 0x3000 },

-  { 0x9a00, 0x2636, 0x2000 },

-  { 0x1a00, 0x2635, 0x0000 },

-  { 0x1a00, 0x2637, 0x0000 },

-  { 0x9a00, 0x263a, 0x2000 },

-  { 0x1a00, 0x2639, 0x0000 },

-  { 0x1a00, 0x263b, 0x0000 },

-  { 0x9a00, 0x2644, 0x4000 },

-  { 0x9a00, 0x2640, 0x3000 },

-  { 0x9a00, 0x263e, 0x2000 },

-  { 0x1a00, 0x263d, 0x0000 },

-  { 0x1a00, 0x263f, 0x0000 },

-  { 0x9a00, 0x2642, 0x2000 },

-  { 0x1a00, 0x2641, 0x0000 },

-  { 0x1a00, 0x2643, 0x0000 },

-  { 0x9a00, 0x2648, 0x3000 },

-  { 0x9a00, 0x2646, 0x2000 },

-  { 0x1a00, 0x2645, 0x0000 },

-  { 0x1a00, 0x2647, 0x0000 },

-  { 0x9a00, 0x264a, 0x2000 },

-  { 0x1a00, 0x2649, 0x0000 },

-  { 0x1a00, 0x264b, 0x0000 },

-  { 0x9a00, 0x266c, 0x6000 },

-  { 0x9a00, 0x265c, 0x5000 },

-  { 0x9a00, 0x2654, 0x4000 },

-  { 0x9a00, 0x2650, 0x3000 },

-  { 0x9a00, 0x264e, 0x2000 },

-  { 0x1a00, 0x264d, 0x0000 },

-  { 0x1a00, 0x264f, 0x0000 },

-  { 0x9a00, 0x2652, 0x2000 },

-  { 0x1a00, 0x2651, 0x0000 },

-  { 0x1a00, 0x2653, 0x0000 },

-  { 0x9a00, 0x2658, 0x3000 },

-  { 0x9a00, 0x2656, 0x2000 },

-  { 0x1a00, 0x2655, 0x0000 },

-  { 0x1a00, 0x2657, 0x0000 },

-  { 0x9a00, 0x265a, 0x2000 },

-  { 0x1a00, 0x2659, 0x0000 },

-  { 0x1a00, 0x265b, 0x0000 },

-  { 0x9a00, 0x2664, 0x4000 },

-  { 0x9a00, 0x2660, 0x3000 },

-  { 0x9a00, 0x265e, 0x2000 },

-  { 0x1a00, 0x265d, 0x0000 },

-  { 0x1a00, 0x265f, 0x0000 },

-  { 0x9a00, 0x2662, 0x2000 },

-  { 0x1a00, 0x2661, 0x0000 },

-  { 0x1a00, 0x2663, 0x0000 },

-  { 0x9a00, 0x2668, 0x3000 },

-  { 0x9a00, 0x2666, 0x2000 },

-  { 0x1a00, 0x2665, 0x0000 },

-  { 0x1a00, 0x2667, 0x0000 },

-  { 0x9a00, 0x266a, 0x2000 },

-  { 0x1a00, 0x2669, 0x0000 },

-  { 0x1a00, 0x266b, 0x0000 },

-  { 0x9a00, 0x267c, 0x5000 },

-  { 0x9a00, 0x2674, 0x4000 },

-  { 0x9a00, 0x2670, 0x3000 },

-  { 0x9a00, 0x266e, 0x2000 },

-  { 0x1a00, 0x266d, 0x0000 },

-  { 0x1900, 0x266f, 0x0000 },

-  { 0x9a00, 0x2672, 0x2000 },

-  { 0x1a00, 0x2671, 0x0000 },

-  { 0x1a00, 0x2673, 0x0000 },

-  { 0x9a00, 0x2678, 0x3000 },

-  { 0x9a00, 0x2676, 0x2000 },

-  { 0x1a00, 0x2675, 0x0000 },

-  { 0x1a00, 0x2677, 0x0000 },

-  { 0x9a00, 0x267a, 0x2000 },

-  { 0x1a00, 0x2679, 0x0000 },

-  { 0x1a00, 0x267b, 0x0000 },

-  { 0x9a00, 0x2686, 0x4000 },

-  { 0x9a00, 0x2682, 0x3000 },

-  { 0x9a00, 0x2680, 0x2000 },

-  { 0x1a00, 0x267d, 0x0000 },

-  { 0x1a00, 0x2681, 0x0000 },

-  { 0x9a00, 0x2684, 0x2000 },

-  { 0x1a00, 0x2683, 0x0000 },

-  { 0x1a00, 0x2685, 0x0000 },

-  { 0x9a00, 0x268a, 0x3000 },

-  { 0x9a00, 0x2688, 0x2000 },

-  { 0x1a00, 0x2687, 0x0000 },

-  { 0x1a00, 0x2689, 0x0000 },

-  { 0x9a00, 0x268c, 0x2000 },

-  { 0x1a00, 0x268b, 0x0000 },

-  { 0x1a00, 0x268d, 0x0000 },

-  { 0x9a00, 0x273f, 0x7000 },

-  { 0x9a00, 0x271e, 0x6000 },

-  { 0x9a00, 0x270e, 0x5000 },

-  { 0x9a00, 0x2703, 0x4000 },

-  { 0x9a00, 0x26a0, 0x3000 },

-  { 0x9a00, 0x2690, 0x2000 },

-  { 0x1a00, 0x268f, 0x0000 },

-  { 0x1a00, 0x2691, 0x0000 },

-  { 0x9a00, 0x2701, 0x2000 },

-  { 0x1a00, 0x26a1, 0x0000 },

-  { 0x1a00, 0x2702, 0x0000 },

-  { 0x9a00, 0x2708, 0x3000 },

-  { 0x9a00, 0x2706, 0x2000 },

-  { 0x1a00, 0x2704, 0x0000 },

-  { 0x1a00, 0x2707, 0x0000 },

-  { 0x9a00, 0x270c, 0x2000 },

-  { 0x1a00, 0x2709, 0x0000 },

-  { 0x1a00, 0x270d, 0x0000 },

-  { 0x9a00, 0x2716, 0x4000 },

-  { 0x9a00, 0x2712, 0x3000 },

-  { 0x9a00, 0x2710, 0x2000 },

-  { 0x1a00, 0x270f, 0x0000 },

-  { 0x1a00, 0x2711, 0x0000 },

-  { 0x9a00, 0x2714, 0x2000 },

-  { 0x1a00, 0x2713, 0x0000 },

-  { 0x1a00, 0x2715, 0x0000 },

-  { 0x9a00, 0x271a, 0x3000 },

-  { 0x9a00, 0x2718, 0x2000 },

-  { 0x1a00, 0x2717, 0x0000 },

-  { 0x1a00, 0x2719, 0x0000 },

-  { 0x9a00, 0x271c, 0x2000 },

-  { 0x1a00, 0x271b, 0x0000 },

-  { 0x1a00, 0x271d, 0x0000 },

-  { 0x9a00, 0x272f, 0x5000 },

-  { 0x9a00, 0x2726, 0x4000 },

-  { 0x9a00, 0x2722, 0x3000 },

-  { 0x9a00, 0x2720, 0x2000 },

-  { 0x1a00, 0x271f, 0x0000 },

-  { 0x1a00, 0x2721, 0x0000 },

-  { 0x9a00, 0x2724, 0x2000 },

-  { 0x1a00, 0x2723, 0x0000 },

-  { 0x1a00, 0x2725, 0x0000 },

-  { 0x9a00, 0x272b, 0x3000 },

-  { 0x9a00, 0x2729, 0x2000 },

-  { 0x1a00, 0x2727, 0x0000 },

-  { 0x1a00, 0x272a, 0x0000 },

-  { 0x9a00, 0x272d, 0x2000 },

-  { 0x1a00, 0x272c, 0x0000 },

-  { 0x1a00, 0x272e, 0x0000 },

-  { 0x9a00, 0x2737, 0x4000 },

-  { 0x9a00, 0x2733, 0x3000 },

-  { 0x9a00, 0x2731, 0x2000 },

-  { 0x1a00, 0x2730, 0x0000 },

-  { 0x1a00, 0x2732, 0x0000 },

-  { 0x9a00, 0x2735, 0x2000 },

-  { 0x1a00, 0x2734, 0x0000 },

-  { 0x1a00, 0x2736, 0x0000 },

-  { 0x9a00, 0x273b, 0x3000 },

-  { 0x9a00, 0x2739, 0x2000 },

-  { 0x1a00, 0x2738, 0x0000 },

-  { 0x1a00, 0x273a, 0x0000 },

-  { 0x9a00, 0x273d, 0x2000 },

-  { 0x1a00, 0x273c, 0x0000 },

-  { 0x1a00, 0x273e, 0x0000 },

-  { 0x9a00, 0x2767, 0x6000 },

-  { 0x9a00, 0x2751, 0x5000 },

-  { 0x9a00, 0x2747, 0x4000 },

-  { 0x9a00, 0x2743, 0x3000 },

-  { 0x9a00, 0x2741, 0x2000 },

-  { 0x1a00, 0x2740, 0x0000 },

-  { 0x1a00, 0x2742, 0x0000 },

-  { 0x9a00, 0x2745, 0x2000 },

-  { 0x1a00, 0x2744, 0x0000 },

-  { 0x1a00, 0x2746, 0x0000 },

-  { 0x9a00, 0x274b, 0x3000 },

-  { 0x9a00, 0x2749, 0x2000 },

-  { 0x1a00, 0x2748, 0x0000 },

-  { 0x1a00, 0x274a, 0x0000 },

-  { 0x9a00, 0x274f, 0x2000 },

-  { 0x1a00, 0x274d, 0x0000 },

-  { 0x1a00, 0x2750, 0x0000 },

-  { 0x9a00, 0x275d, 0x4000 },

-  { 0x9a00, 0x2759, 0x3000 },

-  { 0x9a00, 0x2756, 0x2000 },

-  { 0x1a00, 0x2752, 0x0000 },

-  { 0x1a00, 0x2758, 0x0000 },

-  { 0x9a00, 0x275b, 0x2000 },

-  { 0x1a00, 0x275a, 0x0000 },

-  { 0x1a00, 0x275c, 0x0000 },

-  { 0x9a00, 0x2763, 0x3000 },

-  { 0x9a00, 0x2761, 0x2000 },

-  { 0x1a00, 0x275e, 0x0000 },

-  { 0x1a00, 0x2762, 0x0000 },

-  { 0x9a00, 0x2765, 0x2000 },

-  { 0x1a00, 0x2764, 0x0000 },

-  { 0x1a00, 0x2766, 0x0000 },

-  { 0x8f00, 0x2777, 0x5000 },

-  { 0x9200, 0x276f, 0x4000 },

-  { 0x9200, 0x276b, 0x3000 },

-  { 0x9200, 0x2769, 0x2000 },

-  { 0x1600, 0x2768, 0x0000 },

-  { 0x1600, 0x276a, 0x0000 },

-  { 0x9200, 0x276d, 0x2000 },

-  { 0x1600, 0x276c, 0x0000 },

-  { 0x1600, 0x276e, 0x0000 },

-  { 0x9200, 0x2773, 0x3000 },

-  { 0x9200, 0x2771, 0x2000 },

-  { 0x1600, 0x2770, 0x0000 },

-  { 0x1600, 0x2772, 0x0000 },

-  { 0x9200, 0x2775, 0x2000 },

-  { 0x1600, 0x2774, 0x0000 },

-  { 0x0f00, 0x2776, 0x0000 },

-  { 0x8f00, 0x277f, 0x4000 },

-  { 0x8f00, 0x277b, 0x3000 },

-  { 0x8f00, 0x2779, 0x2000 },

-  { 0x0f00, 0x2778, 0x0000 },

-  { 0x0f00, 0x277a, 0x0000 },

-  { 0x8f00, 0x277d, 0x2000 },

-  { 0x0f00, 0x277c, 0x0000 },

-  { 0x0f00, 0x277e, 0x0000 },

-  { 0x8f00, 0x2783, 0x3000 },

-  { 0x8f00, 0x2781, 0x2000 },

-  { 0x0f00, 0x2780, 0x0000 },

-  { 0x0f00, 0x2782, 0x0000 },

-  { 0x8f00, 0x2785, 0x2000 },

-  { 0x0f00, 0x2784, 0x0000 },

-  { 0x0f00, 0x2786, 0x0000 },

-  { 0x9900, 0x29a0, 0xa000 },

-  { 0x9a00, 0x28a0, 0x9000 },

-  { 0x9a00, 0x2820, 0x8000 },

-  { 0x9900, 0x27dc, 0x7000 },

-  { 0x9a00, 0x27aa, 0x6000 },

-  { 0x9a00, 0x279a, 0x5000 },

-  { 0x8f00, 0x278f, 0x4000 },

-  { 0x8f00, 0x278b, 0x3000 },

-  { 0x8f00, 0x2789, 0x2000 },

-  { 0x0f00, 0x2788, 0x0000 },

-  { 0x0f00, 0x278a, 0x0000 },

-  { 0x8f00, 0x278d, 0x2000 },

-  { 0x0f00, 0x278c, 0x0000 },

-  { 0x0f00, 0x278e, 0x0000 },

-  { 0x8f00, 0x2793, 0x3000 },

-  { 0x8f00, 0x2791, 0x2000 },

-  { 0x0f00, 0x2790, 0x0000 },

-  { 0x0f00, 0x2792, 0x0000 },

-  { 0x9a00, 0x2798, 0x2000 },

-  { 0x1a00, 0x2794, 0x0000 },

-  { 0x1a00, 0x2799, 0x0000 },

-  { 0x9a00, 0x27a2, 0x4000 },

-  { 0x9a00, 0x279e, 0x3000 },

-  { 0x9a00, 0x279c, 0x2000 },

-  { 0x1a00, 0x279b, 0x0000 },

-  { 0x1a00, 0x279d, 0x0000 },

-  { 0x9a00, 0x27a0, 0x2000 },

-  { 0x1a00, 0x279f, 0x0000 },

-  { 0x1a00, 0x27a1, 0x0000 },

-  { 0x9a00, 0x27a6, 0x3000 },

-  { 0x9a00, 0x27a4, 0x2000 },

-  { 0x1a00, 0x27a3, 0x0000 },

-  { 0x1a00, 0x27a5, 0x0000 },

-  { 0x9a00, 0x27a8, 0x2000 },

-  { 0x1a00, 0x27a7, 0x0000 },

-  { 0x1a00, 0x27a9, 0x0000 },

-  { 0x9a00, 0x27bb, 0x5000 },

-  { 0x9a00, 0x27b3, 0x4000 },

-  { 0x9a00, 0x27ae, 0x3000 },

-  { 0x9a00, 0x27ac, 0x2000 },

-  { 0x1a00, 0x27ab, 0x0000 },

-  { 0x1a00, 0x27ad, 0x0000 },

-  { 0x9a00, 0x27b1, 0x2000 },

-  { 0x1a00, 0x27af, 0x0000 },

-  { 0x1a00, 0x27b2, 0x0000 },

-  { 0x9a00, 0x27b7, 0x3000 },

-  { 0x9a00, 0x27b5, 0x2000 },

-  { 0x1a00, 0x27b4, 0x0000 },

-  { 0x1a00, 0x27b6, 0x0000 },

-  { 0x9a00, 0x27b9, 0x2000 },

-  { 0x1a00, 0x27b8, 0x0000 },

-  { 0x1a00, 0x27ba, 0x0000 },

-  { 0x9900, 0x27d4, 0x4000 },

-  { 0x9900, 0x27d0, 0x3000 },

-  { 0x9a00, 0x27bd, 0x2000 },

-  { 0x1a00, 0x27bc, 0x0000 },

-  { 0x1a00, 0x27be, 0x0000 },

-  { 0x9900, 0x27d2, 0x2000 },

-  { 0x1900, 0x27d1, 0x0000 },

-  { 0x1900, 0x27d3, 0x0000 },

-  { 0x9900, 0x27d8, 0x3000 },

-  { 0x9900, 0x27d6, 0x2000 },

-  { 0x1900, 0x27d5, 0x0000 },

-  { 0x1900, 0x27d7, 0x0000 },

-  { 0x9900, 0x27da, 0x2000 },

-  { 0x1900, 0x27d9, 0x0000 },

-  { 0x1900, 0x27db, 0x0000 },

-  { 0x9a00, 0x2800, 0x6000 },

-  { 0x9900, 0x27f0, 0x5000 },

-  { 0x9900, 0x27e4, 0x4000 },

-  { 0x9900, 0x27e0, 0x3000 },

-  { 0x9900, 0x27de, 0x2000 },

-  { 0x1900, 0x27dd, 0x0000 },

-  { 0x1900, 0x27df, 0x0000 },

-  { 0x9900, 0x27e2, 0x2000 },

-  { 0x1900, 0x27e1, 0x0000 },

-  { 0x1900, 0x27e3, 0x0000 },

-  { 0x9600, 0x27e8, 0x3000 },

-  { 0x9600, 0x27e6, 0x2000 },

-  { 0x1900, 0x27e5, 0x0000 },

-  { 0x1200, 0x27e7, 0x0000 },

-  { 0x9600, 0x27ea, 0x2000 },

-  { 0x1200, 0x27e9, 0x0000 },

-  { 0x1200, 0x27eb, 0x0000 },

-  { 0x9900, 0x27f8, 0x4000 },

-  { 0x9900, 0x27f4, 0x3000 },

-  { 0x9900, 0x27f2, 0x2000 },

-  { 0x1900, 0x27f1, 0x0000 },

-  { 0x1900, 0x27f3, 0x0000 },

-  { 0x9900, 0x27f6, 0x2000 },

-  { 0x1900, 0x27f5, 0x0000 },

-  { 0x1900, 0x27f7, 0x0000 },

-  { 0x9900, 0x27fc, 0x3000 },

-  { 0x9900, 0x27fa, 0x2000 },

-  { 0x1900, 0x27f9, 0x0000 },

-  { 0x1900, 0x27fb, 0x0000 },

-  { 0x9900, 0x27fe, 0x2000 },

-  { 0x1900, 0x27fd, 0x0000 },

-  { 0x1900, 0x27ff, 0x0000 },

-  { 0x9a00, 0x2810, 0x5000 },

-  { 0x9a00, 0x2808, 0x4000 },

-  { 0x9a00, 0x2804, 0x3000 },

-  { 0x9a00, 0x2802, 0x2000 },

-  { 0x1a00, 0x2801, 0x0000 },

-  { 0x1a00, 0x2803, 0x0000 },

-  { 0x9a00, 0x2806, 0x2000 },

-  { 0x1a00, 0x2805, 0x0000 },

-  { 0x1a00, 0x2807, 0x0000 },

-  { 0x9a00, 0x280c, 0x3000 },

-  { 0x9a00, 0x280a, 0x2000 },

-  { 0x1a00, 0x2809, 0x0000 },

-  { 0x1a00, 0x280b, 0x0000 },

-  { 0x9a00, 0x280e, 0x2000 },

-  { 0x1a00, 0x280d, 0x0000 },

-  { 0x1a00, 0x280f, 0x0000 },

-  { 0x9a00, 0x2818, 0x4000 },

-  { 0x9a00, 0x2814, 0x3000 },

-  { 0x9a00, 0x2812, 0x2000 },

-  { 0x1a00, 0x2811, 0x0000 },

-  { 0x1a00, 0x2813, 0x0000 },

-  { 0x9a00, 0x2816, 0x2000 },

-  { 0x1a00, 0x2815, 0x0000 },

-  { 0x1a00, 0x2817, 0x0000 },

-  { 0x9a00, 0x281c, 0x3000 },

-  { 0x9a00, 0x281a, 0x2000 },

-  { 0x1a00, 0x2819, 0x0000 },

-  { 0x1a00, 0x281b, 0x0000 },

-  { 0x9a00, 0x281e, 0x2000 },

-  { 0x1a00, 0x281d, 0x0000 },

-  { 0x1a00, 0x281f, 0x0000 },

-  { 0x9a00, 0x2860, 0x7000 },

-  { 0x9a00, 0x2840, 0x6000 },

-  { 0x9a00, 0x2830, 0x5000 },

-  { 0x9a00, 0x2828, 0x4000 },

-  { 0x9a00, 0x2824, 0x3000 },

-  { 0x9a00, 0x2822, 0x2000 },

-  { 0x1a00, 0x2821, 0x0000 },

-  { 0x1a00, 0x2823, 0x0000 },

-  { 0x9a00, 0x2826, 0x2000 },

-  { 0x1a00, 0x2825, 0x0000 },

-  { 0x1a00, 0x2827, 0x0000 },

-  { 0x9a00, 0x282c, 0x3000 },

-  { 0x9a00, 0x282a, 0x2000 },

-  { 0x1a00, 0x2829, 0x0000 },

-  { 0x1a00, 0x282b, 0x0000 },

-  { 0x9a00, 0x282e, 0x2000 },

-  { 0x1a00, 0x282d, 0x0000 },

-  { 0x1a00, 0x282f, 0x0000 },

-  { 0x9a00, 0x2838, 0x4000 },

-  { 0x9a00, 0x2834, 0x3000 },

-  { 0x9a00, 0x2832, 0x2000 },

-  { 0x1a00, 0x2831, 0x0000 },

-  { 0x1a00, 0x2833, 0x0000 },

-  { 0x9a00, 0x2836, 0x2000 },

-  { 0x1a00, 0x2835, 0x0000 },

-  { 0x1a00, 0x2837, 0x0000 },

-  { 0x9a00, 0x283c, 0x3000 },

-  { 0x9a00, 0x283a, 0x2000 },

-  { 0x1a00, 0x2839, 0x0000 },

-  { 0x1a00, 0x283b, 0x0000 },

-  { 0x9a00, 0x283e, 0x2000 },

-  { 0x1a00, 0x283d, 0x0000 },

-  { 0x1a00, 0x283f, 0x0000 },

-  { 0x9a00, 0x2850, 0x5000 },

-  { 0x9a00, 0x2848, 0x4000 },

-  { 0x9a00, 0x2844, 0x3000 },

-  { 0x9a00, 0x2842, 0x2000 },

-  { 0x1a00, 0x2841, 0x0000 },

-  { 0x1a00, 0x2843, 0x0000 },

-  { 0x9a00, 0x2846, 0x2000 },

-  { 0x1a00, 0x2845, 0x0000 },

-  { 0x1a00, 0x2847, 0x0000 },

-  { 0x9a00, 0x284c, 0x3000 },

-  { 0x9a00, 0x284a, 0x2000 },

-  { 0x1a00, 0x2849, 0x0000 },

-  { 0x1a00, 0x284b, 0x0000 },

-  { 0x9a00, 0x284e, 0x2000 },

-  { 0x1a00, 0x284d, 0x0000 },

-  { 0x1a00, 0x284f, 0x0000 },

-  { 0x9a00, 0x2858, 0x4000 },

-  { 0x9a00, 0x2854, 0x3000 },

-  { 0x9a00, 0x2852, 0x2000 },

-  { 0x1a00, 0x2851, 0x0000 },

-  { 0x1a00, 0x2853, 0x0000 },

-  { 0x9a00, 0x2856, 0x2000 },

-  { 0x1a00, 0x2855, 0x0000 },

-  { 0x1a00, 0x2857, 0x0000 },

-  { 0x9a00, 0x285c, 0x3000 },

-  { 0x9a00, 0x285a, 0x2000 },

-  { 0x1a00, 0x2859, 0x0000 },

-  { 0x1a00, 0x285b, 0x0000 },

-  { 0x9a00, 0x285e, 0x2000 },

-  { 0x1a00, 0x285d, 0x0000 },

-  { 0x1a00, 0x285f, 0x0000 },

-  { 0x9a00, 0x2880, 0x6000 },

-  { 0x9a00, 0x2870, 0x5000 },

-  { 0x9a00, 0x2868, 0x4000 },

-  { 0x9a00, 0x2864, 0x3000 },

-  { 0x9a00, 0x2862, 0x2000 },

-  { 0x1a00, 0x2861, 0x0000 },

-  { 0x1a00, 0x2863, 0x0000 },

-  { 0x9a00, 0x2866, 0x2000 },

-  { 0x1a00, 0x2865, 0x0000 },

-  { 0x1a00, 0x2867, 0x0000 },

-  { 0x9a00, 0x286c, 0x3000 },

-  { 0x9a00, 0x286a, 0x2000 },

-  { 0x1a00, 0x2869, 0x0000 },

-  { 0x1a00, 0x286b, 0x0000 },

-  { 0x9a00, 0x286e, 0x2000 },

-  { 0x1a00, 0x286d, 0x0000 },

-  { 0x1a00, 0x286f, 0x0000 },

-  { 0x9a00, 0x2878, 0x4000 },

-  { 0x9a00, 0x2874, 0x3000 },

-  { 0x9a00, 0x2872, 0x2000 },

-  { 0x1a00, 0x2871, 0x0000 },

-  { 0x1a00, 0x2873, 0x0000 },

-  { 0x9a00, 0x2876, 0x2000 },

-  { 0x1a00, 0x2875, 0x0000 },

-  { 0x1a00, 0x2877, 0x0000 },

-  { 0x9a00, 0x287c, 0x3000 },

-  { 0x9a00, 0x287a, 0x2000 },

-  { 0x1a00, 0x2879, 0x0000 },

-  { 0x1a00, 0x287b, 0x0000 },

-  { 0x9a00, 0x287e, 0x2000 },

-  { 0x1a00, 0x287d, 0x0000 },

-  { 0x1a00, 0x287f, 0x0000 },

-  { 0x9a00, 0x2890, 0x5000 },

-  { 0x9a00, 0x2888, 0x4000 },

-  { 0x9a00, 0x2884, 0x3000 },

-  { 0x9a00, 0x2882, 0x2000 },

-  { 0x1a00, 0x2881, 0x0000 },

-  { 0x1a00, 0x2883, 0x0000 },

-  { 0x9a00, 0x2886, 0x2000 },

-  { 0x1a00, 0x2885, 0x0000 },

-  { 0x1a00, 0x2887, 0x0000 },

-  { 0x9a00, 0x288c, 0x3000 },

-  { 0x9a00, 0x288a, 0x2000 },

-  { 0x1a00, 0x2889, 0x0000 },

-  { 0x1a00, 0x288b, 0x0000 },

-  { 0x9a00, 0x288e, 0x2000 },

-  { 0x1a00, 0x288d, 0x0000 },

-  { 0x1a00, 0x288f, 0x0000 },

-  { 0x9a00, 0x2898, 0x4000 },

-  { 0x9a00, 0x2894, 0x3000 },

-  { 0x9a00, 0x2892, 0x2000 },

-  { 0x1a00, 0x2891, 0x0000 },

-  { 0x1a00, 0x2893, 0x0000 },

-  { 0x9a00, 0x2896, 0x2000 },

-  { 0x1a00, 0x2895, 0x0000 },

-  { 0x1a00, 0x2897, 0x0000 },

-  { 0x9a00, 0x289c, 0x3000 },

-  { 0x9a00, 0x289a, 0x2000 },

-  { 0x1a00, 0x2899, 0x0000 },

-  { 0x1a00, 0x289b, 0x0000 },

-  { 0x9a00, 0x289e, 0x2000 },

-  { 0x1a00, 0x289d, 0x0000 },

-  { 0x1a00, 0x289f, 0x0000 },

-  { 0x9900, 0x2920, 0x8000 },

-  { 0x9a00, 0x28e0, 0x7000 },

-  { 0x9a00, 0x28c0, 0x6000 },

-  { 0x9a00, 0x28b0, 0x5000 },

-  { 0x9a00, 0x28a8, 0x4000 },

-  { 0x9a00, 0x28a4, 0x3000 },

-  { 0x9a00, 0x28a2, 0x2000 },

-  { 0x1a00, 0x28a1, 0x0000 },

-  { 0x1a00, 0x28a3, 0x0000 },

-  { 0x9a00, 0x28a6, 0x2000 },

-  { 0x1a00, 0x28a5, 0x0000 },

-  { 0x1a00, 0x28a7, 0x0000 },

-  { 0x9a00, 0x28ac, 0x3000 },

-  { 0x9a00, 0x28aa, 0x2000 },

-  { 0x1a00, 0x28a9, 0x0000 },

-  { 0x1a00, 0x28ab, 0x0000 },

-  { 0x9a00, 0x28ae, 0x2000 },

-  { 0x1a00, 0x28ad, 0x0000 },

-  { 0x1a00, 0x28af, 0x0000 },

-  { 0x9a00, 0x28b8, 0x4000 },

-  { 0x9a00, 0x28b4, 0x3000 },

-  { 0x9a00, 0x28b2, 0x2000 },

-  { 0x1a00, 0x28b1, 0x0000 },

-  { 0x1a00, 0x28b3, 0x0000 },

-  { 0x9a00, 0x28b6, 0x2000 },

-  { 0x1a00, 0x28b5, 0x0000 },

-  { 0x1a00, 0x28b7, 0x0000 },

-  { 0x9a00, 0x28bc, 0x3000 },

-  { 0x9a00, 0x28ba, 0x2000 },

-  { 0x1a00, 0x28b9, 0x0000 },

-  { 0x1a00, 0x28bb, 0x0000 },

-  { 0x9a00, 0x28be, 0x2000 },

-  { 0x1a00, 0x28bd, 0x0000 },

-  { 0x1a00, 0x28bf, 0x0000 },

-  { 0x9a00, 0x28d0, 0x5000 },

-  { 0x9a00, 0x28c8, 0x4000 },

-  { 0x9a00, 0x28c4, 0x3000 },

-  { 0x9a00, 0x28c2, 0x2000 },

-  { 0x1a00, 0x28c1, 0x0000 },

-  { 0x1a00, 0x28c3, 0x0000 },

-  { 0x9a00, 0x28c6, 0x2000 },

-  { 0x1a00, 0x28c5, 0x0000 },

-  { 0x1a00, 0x28c7, 0x0000 },

-  { 0x9a00, 0x28cc, 0x3000 },

-  { 0x9a00, 0x28ca, 0x2000 },

-  { 0x1a00, 0x28c9, 0x0000 },

-  { 0x1a00, 0x28cb, 0x0000 },

-  { 0x9a00, 0x28ce, 0x2000 },

-  { 0x1a00, 0x28cd, 0x0000 },

-  { 0x1a00, 0x28cf, 0x0000 },

-  { 0x9a00, 0x28d8, 0x4000 },

-  { 0x9a00, 0x28d4, 0x3000 },

-  { 0x9a00, 0x28d2, 0x2000 },

-  { 0x1a00, 0x28d1, 0x0000 },

-  { 0x1a00, 0x28d3, 0x0000 },

-  { 0x9a00, 0x28d6, 0x2000 },

-  { 0x1a00, 0x28d5, 0x0000 },

-  { 0x1a00, 0x28d7, 0x0000 },

-  { 0x9a00, 0x28dc, 0x3000 },

-  { 0x9a00, 0x28da, 0x2000 },

-  { 0x1a00, 0x28d9, 0x0000 },

-  { 0x1a00, 0x28db, 0x0000 },

-  { 0x9a00, 0x28de, 0x2000 },

-  { 0x1a00, 0x28dd, 0x0000 },

-  { 0x1a00, 0x28df, 0x0000 },

-  { 0x9900, 0x2900, 0x6000 },

-  { 0x9a00, 0x28f0, 0x5000 },

-  { 0x9a00, 0x28e8, 0x4000 },

-  { 0x9a00, 0x28e4, 0x3000 },

-  { 0x9a00, 0x28e2, 0x2000 },

-  { 0x1a00, 0x28e1, 0x0000 },

-  { 0x1a00, 0x28e3, 0x0000 },

-  { 0x9a00, 0x28e6, 0x2000 },

-  { 0x1a00, 0x28e5, 0x0000 },

-  { 0x1a00, 0x28e7, 0x0000 },

-  { 0x9a00, 0x28ec, 0x3000 },

-  { 0x9a00, 0x28ea, 0x2000 },

-  { 0x1a00, 0x28e9, 0x0000 },

-  { 0x1a00, 0x28eb, 0x0000 },

-  { 0x9a00, 0x28ee, 0x2000 },

-  { 0x1a00, 0x28ed, 0x0000 },

-  { 0x1a00, 0x28ef, 0x0000 },

-  { 0x9a00, 0x28f8, 0x4000 },

-  { 0x9a00, 0x28f4, 0x3000 },

-  { 0x9a00, 0x28f2, 0x2000 },

-  { 0x1a00, 0x28f1, 0x0000 },

-  { 0x1a00, 0x28f3, 0x0000 },

-  { 0x9a00, 0x28f6, 0x2000 },

-  { 0x1a00, 0x28f5, 0x0000 },

-  { 0x1a00, 0x28f7, 0x0000 },

-  { 0x9a00, 0x28fc, 0x3000 },

-  { 0x9a00, 0x28fa, 0x2000 },

-  { 0x1a00, 0x28f9, 0x0000 },

-  { 0x1a00, 0x28fb, 0x0000 },

-  { 0x9a00, 0x28fe, 0x2000 },

-  { 0x1a00, 0x28fd, 0x0000 },

-  { 0x1a00, 0x28ff, 0x0000 },

-  { 0x9900, 0x2910, 0x5000 },

-  { 0x9900, 0x2908, 0x4000 },

-  { 0x9900, 0x2904, 0x3000 },

-  { 0x9900, 0x2902, 0x2000 },

-  { 0x1900, 0x2901, 0x0000 },

-  { 0x1900, 0x2903, 0x0000 },

-  { 0x9900, 0x2906, 0x2000 },

-  { 0x1900, 0x2905, 0x0000 },

-  { 0x1900, 0x2907, 0x0000 },

-  { 0x9900, 0x290c, 0x3000 },

-  { 0x9900, 0x290a, 0x2000 },

-  { 0x1900, 0x2909, 0x0000 },

-  { 0x1900, 0x290b, 0x0000 },

-  { 0x9900, 0x290e, 0x2000 },

-  { 0x1900, 0x290d, 0x0000 },

-  { 0x1900, 0x290f, 0x0000 },

-  { 0x9900, 0x2918, 0x4000 },

-  { 0x9900, 0x2914, 0x3000 },

-  { 0x9900, 0x2912, 0x2000 },

-  { 0x1900, 0x2911, 0x0000 },

-  { 0x1900, 0x2913, 0x0000 },

-  { 0x9900, 0x2916, 0x2000 },

-  { 0x1900, 0x2915, 0x0000 },

-  { 0x1900, 0x2917, 0x0000 },

-  { 0x9900, 0x291c, 0x3000 },

-  { 0x9900, 0x291a, 0x2000 },

-  { 0x1900, 0x2919, 0x0000 },

-  { 0x1900, 0x291b, 0x0000 },

-  { 0x9900, 0x291e, 0x2000 },

-  { 0x1900, 0x291d, 0x0000 },

-  { 0x1900, 0x291f, 0x0000 },

-  { 0x9900, 0x2960, 0x7000 },

-  { 0x9900, 0x2940, 0x6000 },

-  { 0x9900, 0x2930, 0x5000 },

-  { 0x9900, 0x2928, 0x4000 },

-  { 0x9900, 0x2924, 0x3000 },

-  { 0x9900, 0x2922, 0x2000 },

-  { 0x1900, 0x2921, 0x0000 },

-  { 0x1900, 0x2923, 0x0000 },

-  { 0x9900, 0x2926, 0x2000 },

-  { 0x1900, 0x2925, 0x0000 },

-  { 0x1900, 0x2927, 0x0000 },

-  { 0x9900, 0x292c, 0x3000 },

-  { 0x9900, 0x292a, 0x2000 },

-  { 0x1900, 0x2929, 0x0000 },

-  { 0x1900, 0x292b, 0x0000 },

-  { 0x9900, 0x292e, 0x2000 },

-  { 0x1900, 0x292d, 0x0000 },

-  { 0x1900, 0x292f, 0x0000 },

-  { 0x9900, 0x2938, 0x4000 },

-  { 0x9900, 0x2934, 0x3000 },

-  { 0x9900, 0x2932, 0x2000 },

-  { 0x1900, 0x2931, 0x0000 },

-  { 0x1900, 0x2933, 0x0000 },

-  { 0x9900, 0x2936, 0x2000 },

-  { 0x1900, 0x2935, 0x0000 },

-  { 0x1900, 0x2937, 0x0000 },

-  { 0x9900, 0x293c, 0x3000 },

-  { 0x9900, 0x293a, 0x2000 },

-  { 0x1900, 0x2939, 0x0000 },

-  { 0x1900, 0x293b, 0x0000 },

-  { 0x9900, 0x293e, 0x2000 },

-  { 0x1900, 0x293d, 0x0000 },

-  { 0x1900, 0x293f, 0x0000 },

-  { 0x9900, 0x2950, 0x5000 },

-  { 0x9900, 0x2948, 0x4000 },

-  { 0x9900, 0x2944, 0x3000 },

-  { 0x9900, 0x2942, 0x2000 },

-  { 0x1900, 0x2941, 0x0000 },

-  { 0x1900, 0x2943, 0x0000 },

-  { 0x9900, 0x2946, 0x2000 },

-  { 0x1900, 0x2945, 0x0000 },

-  { 0x1900, 0x2947, 0x0000 },

-  { 0x9900, 0x294c, 0x3000 },

-  { 0x9900, 0x294a, 0x2000 },

-  { 0x1900, 0x2949, 0x0000 },

-  { 0x1900, 0x294b, 0x0000 },

-  { 0x9900, 0x294e, 0x2000 },

-  { 0x1900, 0x294d, 0x0000 },

-  { 0x1900, 0x294f, 0x0000 },

-  { 0x9900, 0x2958, 0x4000 },

-  { 0x9900, 0x2954, 0x3000 },

-  { 0x9900, 0x2952, 0x2000 },

-  { 0x1900, 0x2951, 0x0000 },

-  { 0x1900, 0x2953, 0x0000 },

-  { 0x9900, 0x2956, 0x2000 },

-  { 0x1900, 0x2955, 0x0000 },

-  { 0x1900, 0x2957, 0x0000 },

-  { 0x9900, 0x295c, 0x3000 },

-  { 0x9900, 0x295a, 0x2000 },

-  { 0x1900, 0x2959, 0x0000 },

-  { 0x1900, 0x295b, 0x0000 },

-  { 0x9900, 0x295e, 0x2000 },

-  { 0x1900, 0x295d, 0x0000 },

-  { 0x1900, 0x295f, 0x0000 },

-  { 0x9900, 0x2980, 0x6000 },

-  { 0x9900, 0x2970, 0x5000 },

-  { 0x9900, 0x2968, 0x4000 },

-  { 0x9900, 0x2964, 0x3000 },

-  { 0x9900, 0x2962, 0x2000 },

-  { 0x1900, 0x2961, 0x0000 },

-  { 0x1900, 0x2963, 0x0000 },

-  { 0x9900, 0x2966, 0x2000 },

-  { 0x1900, 0x2965, 0x0000 },

-  { 0x1900, 0x2967, 0x0000 },

-  { 0x9900, 0x296c, 0x3000 },

-  { 0x9900, 0x296a, 0x2000 },

-  { 0x1900, 0x2969, 0x0000 },

-  { 0x1900, 0x296b, 0x0000 },

-  { 0x9900, 0x296e, 0x2000 },

-  { 0x1900, 0x296d, 0x0000 },

-  { 0x1900, 0x296f, 0x0000 },

-  { 0x9900, 0x2978, 0x4000 },

-  { 0x9900, 0x2974, 0x3000 },

-  { 0x9900, 0x2972, 0x2000 },

-  { 0x1900, 0x2971, 0x0000 },

-  { 0x1900, 0x2973, 0x0000 },

-  { 0x9900, 0x2976, 0x2000 },

-  { 0x1900, 0x2975, 0x0000 },

-  { 0x1900, 0x2977, 0x0000 },

-  { 0x9900, 0x297c, 0x3000 },

-  { 0x9900, 0x297a, 0x2000 },

-  { 0x1900, 0x2979, 0x0000 },

-  { 0x1900, 0x297b, 0x0000 },

-  { 0x9900, 0x297e, 0x2000 },

-  { 0x1900, 0x297d, 0x0000 },

-  { 0x1900, 0x297f, 0x0000 },

-  { 0x9200, 0x2990, 0x5000 },

-  { 0x9200, 0x2988, 0x4000 },

-  { 0x9200, 0x2984, 0x3000 },

-  { 0x9900, 0x2982, 0x2000 },

-  { 0x1900, 0x2981, 0x0000 },

-  { 0x1600, 0x2983, 0x0000 },

-  { 0x9200, 0x2986, 0x2000 },

-  { 0x1600, 0x2985, 0x0000 },

-  { 0x1600, 0x2987, 0x0000 },

-  { 0x9200, 0x298c, 0x3000 },

-  { 0x9200, 0x298a, 0x2000 },

-  { 0x1600, 0x2989, 0x0000 },

-  { 0x1600, 0x298b, 0x0000 },

-  { 0x9200, 0x298e, 0x2000 },

-  { 0x1600, 0x298d, 0x0000 },

-  { 0x1600, 0x298f, 0x0000 },

-  { 0x9200, 0x2998, 0x4000 },

-  { 0x9200, 0x2994, 0x3000 },

-  { 0x9200, 0x2992, 0x2000 },

-  { 0x1600, 0x2991, 0x0000 },

-  { 0x1600, 0x2993, 0x0000 },

-  { 0x9200, 0x2996, 0x2000 },

-  { 0x1600, 0x2995, 0x0000 },

-  { 0x1600, 0x2997, 0x0000 },

-  { 0x9900, 0x299c, 0x3000 },

-  { 0x9900, 0x299a, 0x2000 },

-  { 0x1900, 0x2999, 0x0000 },

-  { 0x1900, 0x299b, 0x0000 },

-  { 0x9900, 0x299e, 0x2000 },

-  { 0x1900, 0x299d, 0x0000 },

-  { 0x1900, 0x299f, 0x0000 },

-  { 0x9900, 0x2aa0, 0x9000 },

-  { 0x9900, 0x2a20, 0x8000 },

-  { 0x9900, 0x29e0, 0x7000 },

-  { 0x9900, 0x29c0, 0x6000 },

-  { 0x9900, 0x29b0, 0x5000 },

-  { 0x9900, 0x29a8, 0x4000 },

-  { 0x9900, 0x29a4, 0x3000 },

-  { 0x9900, 0x29a2, 0x2000 },

-  { 0x1900, 0x29a1, 0x0000 },

-  { 0x1900, 0x29a3, 0x0000 },

-  { 0x9900, 0x29a6, 0x2000 },

-  { 0x1900, 0x29a5, 0x0000 },

-  { 0x1900, 0x29a7, 0x0000 },

-  { 0x9900, 0x29ac, 0x3000 },

-  { 0x9900, 0x29aa, 0x2000 },

-  { 0x1900, 0x29a9, 0x0000 },

-  { 0x1900, 0x29ab, 0x0000 },

-  { 0x9900, 0x29ae, 0x2000 },

-  { 0x1900, 0x29ad, 0x0000 },

-  { 0x1900, 0x29af, 0x0000 },

-  { 0x9900, 0x29b8, 0x4000 },

-  { 0x9900, 0x29b4, 0x3000 },

-  { 0x9900, 0x29b2, 0x2000 },

-  { 0x1900, 0x29b1, 0x0000 },

-  { 0x1900, 0x29b3, 0x0000 },

-  { 0x9900, 0x29b6, 0x2000 },

-  { 0x1900, 0x29b5, 0x0000 },

-  { 0x1900, 0x29b7, 0x0000 },

-  { 0x9900, 0x29bc, 0x3000 },

-  { 0x9900, 0x29ba, 0x2000 },

-  { 0x1900, 0x29b9, 0x0000 },

-  { 0x1900, 0x29bb, 0x0000 },

-  { 0x9900, 0x29be, 0x2000 },

-  { 0x1900, 0x29bd, 0x0000 },

-  { 0x1900, 0x29bf, 0x0000 },

-  { 0x9900, 0x29d0, 0x5000 },

-  { 0x9900, 0x29c8, 0x4000 },

-  { 0x9900, 0x29c4, 0x3000 },

-  { 0x9900, 0x29c2, 0x2000 },

-  { 0x1900, 0x29c1, 0x0000 },

-  { 0x1900, 0x29c3, 0x0000 },

-  { 0x9900, 0x29c6, 0x2000 },

-  { 0x1900, 0x29c5, 0x0000 },

-  { 0x1900, 0x29c7, 0x0000 },

-  { 0x9900, 0x29cc, 0x3000 },

-  { 0x9900, 0x29ca, 0x2000 },

-  { 0x1900, 0x29c9, 0x0000 },

-  { 0x1900, 0x29cb, 0x0000 },

-  { 0x9900, 0x29ce, 0x2000 },

-  { 0x1900, 0x29cd, 0x0000 },

-  { 0x1900, 0x29cf, 0x0000 },

-  { 0x9600, 0x29d8, 0x4000 },

-  { 0x9900, 0x29d4, 0x3000 },

-  { 0x9900, 0x29d2, 0x2000 },

-  { 0x1900, 0x29d1, 0x0000 },

-  { 0x1900, 0x29d3, 0x0000 },

-  { 0x9900, 0x29d6, 0x2000 },

-  { 0x1900, 0x29d5, 0x0000 },

-  { 0x1900, 0x29d7, 0x0000 },

-  { 0x9900, 0x29dc, 0x3000 },

-  { 0x9600, 0x29da, 0x2000 },

-  { 0x1200, 0x29d9, 0x0000 },

-  { 0x1200, 0x29db, 0x0000 },

-  { 0x9900, 0x29de, 0x2000 },

-  { 0x1900, 0x29dd, 0x0000 },

-  { 0x1900, 0x29df, 0x0000 },

-  { 0x9900, 0x2a00, 0x6000 },

-  { 0x9900, 0x29f0, 0x5000 },

-  { 0x9900, 0x29e8, 0x4000 },

-  { 0x9900, 0x29e4, 0x3000 },

-  { 0x9900, 0x29e2, 0x2000 },

-  { 0x1900, 0x29e1, 0x0000 },

-  { 0x1900, 0x29e3, 0x0000 },

-  { 0x9900, 0x29e6, 0x2000 },

-  { 0x1900, 0x29e5, 0x0000 },

-  { 0x1900, 0x29e7, 0x0000 },

-  { 0x9900, 0x29ec, 0x3000 },

-  { 0x9900, 0x29ea, 0x2000 },

-  { 0x1900, 0x29e9, 0x0000 },

-  { 0x1900, 0x29eb, 0x0000 },

-  { 0x9900, 0x29ee, 0x2000 },

-  { 0x1900, 0x29ed, 0x0000 },

-  { 0x1900, 0x29ef, 0x0000 },

-  { 0x9900, 0x29f8, 0x4000 },

-  { 0x9900, 0x29f4, 0x3000 },

-  { 0x9900, 0x29f2, 0x2000 },

-  { 0x1900, 0x29f1, 0x0000 },

-  { 0x1900, 0x29f3, 0x0000 },

-  { 0x9900, 0x29f6, 0x2000 },

-  { 0x1900, 0x29f5, 0x0000 },

-  { 0x1900, 0x29f7, 0x0000 },

-  { 0x9600, 0x29fc, 0x3000 },

-  { 0x9900, 0x29fa, 0x2000 },

-  { 0x1900, 0x29f9, 0x0000 },

-  { 0x1900, 0x29fb, 0x0000 },

-  { 0x9900, 0x29fe, 0x2000 },

-  { 0x1200, 0x29fd, 0x0000 },

-  { 0x1900, 0x29ff, 0x0000 },

-  { 0x9900, 0x2a10, 0x5000 },

-  { 0x9900, 0x2a08, 0x4000 },

-  { 0x9900, 0x2a04, 0x3000 },

-  { 0x9900, 0x2a02, 0x2000 },

-  { 0x1900, 0x2a01, 0x0000 },

-  { 0x1900, 0x2a03, 0x0000 },

-  { 0x9900, 0x2a06, 0x2000 },

-  { 0x1900, 0x2a05, 0x0000 },

-  { 0x1900, 0x2a07, 0x0000 },

-  { 0x9900, 0x2a0c, 0x3000 },

-  { 0x9900, 0x2a0a, 0x2000 },

-  { 0x1900, 0x2a09, 0x0000 },

-  { 0x1900, 0x2a0b, 0x0000 },

-  { 0x9900, 0x2a0e, 0x2000 },

-  { 0x1900, 0x2a0d, 0x0000 },

-  { 0x1900, 0x2a0f, 0x0000 },

-  { 0x9900, 0x2a18, 0x4000 },

-  { 0x9900, 0x2a14, 0x3000 },

-  { 0x9900, 0x2a12, 0x2000 },

-  { 0x1900, 0x2a11, 0x0000 },

-  { 0x1900, 0x2a13, 0x0000 },

-  { 0x9900, 0x2a16, 0x2000 },

-  { 0x1900, 0x2a15, 0x0000 },

-  { 0x1900, 0x2a17, 0x0000 },

-  { 0x9900, 0x2a1c, 0x3000 },

-  { 0x9900, 0x2a1a, 0x2000 },

-  { 0x1900, 0x2a19, 0x0000 },

-  { 0x1900, 0x2a1b, 0x0000 },

-  { 0x9900, 0x2a1e, 0x2000 },

-  { 0x1900, 0x2a1d, 0x0000 },

-  { 0x1900, 0x2a1f, 0x0000 },

-  { 0x9900, 0x2a60, 0x7000 },

-  { 0x9900, 0x2a40, 0x6000 },

-  { 0x9900, 0x2a30, 0x5000 },

-  { 0x9900, 0x2a28, 0x4000 },

-  { 0x9900, 0x2a24, 0x3000 },

-  { 0x9900, 0x2a22, 0x2000 },

-  { 0x1900, 0x2a21, 0x0000 },

-  { 0x1900, 0x2a23, 0x0000 },

-  { 0x9900, 0x2a26, 0x2000 },

-  { 0x1900, 0x2a25, 0x0000 },

-  { 0x1900, 0x2a27, 0x0000 },

-  { 0x9900, 0x2a2c, 0x3000 },

-  { 0x9900, 0x2a2a, 0x2000 },

-  { 0x1900, 0x2a29, 0x0000 },

-  { 0x1900, 0x2a2b, 0x0000 },

-  { 0x9900, 0x2a2e, 0x2000 },

-  { 0x1900, 0x2a2d, 0x0000 },

-  { 0x1900, 0x2a2f, 0x0000 },

-  { 0x9900, 0x2a38, 0x4000 },

-  { 0x9900, 0x2a34, 0x3000 },

-  { 0x9900, 0x2a32, 0x2000 },

-  { 0x1900, 0x2a31, 0x0000 },

-  { 0x1900, 0x2a33, 0x0000 },

-  { 0x9900, 0x2a36, 0x2000 },

-  { 0x1900, 0x2a35, 0x0000 },

-  { 0x1900, 0x2a37, 0x0000 },

-  { 0x9900, 0x2a3c, 0x3000 },

-  { 0x9900, 0x2a3a, 0x2000 },

-  { 0x1900, 0x2a39, 0x0000 },

-  { 0x1900, 0x2a3b, 0x0000 },

-  { 0x9900, 0x2a3e, 0x2000 },

-  { 0x1900, 0x2a3d, 0x0000 },

-  { 0x1900, 0x2a3f, 0x0000 },

-  { 0x9900, 0x2a50, 0x5000 },

-  { 0x9900, 0x2a48, 0x4000 },

-  { 0x9900, 0x2a44, 0x3000 },

-  { 0x9900, 0x2a42, 0x2000 },

-  { 0x1900, 0x2a41, 0x0000 },

-  { 0x1900, 0x2a43, 0x0000 },

-  { 0x9900, 0x2a46, 0x2000 },

-  { 0x1900, 0x2a45, 0x0000 },

-  { 0x1900, 0x2a47, 0x0000 },

-  { 0x9900, 0x2a4c, 0x3000 },

-  { 0x9900, 0x2a4a, 0x2000 },

-  { 0x1900, 0x2a49, 0x0000 },

-  { 0x1900, 0x2a4b, 0x0000 },

-  { 0x9900, 0x2a4e, 0x2000 },

-  { 0x1900, 0x2a4d, 0x0000 },

-  { 0x1900, 0x2a4f, 0x0000 },

-  { 0x9900, 0x2a58, 0x4000 },

-  { 0x9900, 0x2a54, 0x3000 },

-  { 0x9900, 0x2a52, 0x2000 },

-  { 0x1900, 0x2a51, 0x0000 },

-  { 0x1900, 0x2a53, 0x0000 },

-  { 0x9900, 0x2a56, 0x2000 },

-  { 0x1900, 0x2a55, 0x0000 },

-  { 0x1900, 0x2a57, 0x0000 },

-  { 0x9900, 0x2a5c, 0x3000 },

-  { 0x9900, 0x2a5a, 0x2000 },

-  { 0x1900, 0x2a59, 0x0000 },

-  { 0x1900, 0x2a5b, 0x0000 },

-  { 0x9900, 0x2a5e, 0x2000 },

-  { 0x1900, 0x2a5d, 0x0000 },

-  { 0x1900, 0x2a5f, 0x0000 },

-  { 0x9900, 0x2a80, 0x6000 },

-  { 0x9900, 0x2a70, 0x5000 },

-  { 0x9900, 0x2a68, 0x4000 },

-  { 0x9900, 0x2a64, 0x3000 },

-  { 0x9900, 0x2a62, 0x2000 },

-  { 0x1900, 0x2a61, 0x0000 },

-  { 0x1900, 0x2a63, 0x0000 },

-  { 0x9900, 0x2a66, 0x2000 },

-  { 0x1900, 0x2a65, 0x0000 },

-  { 0x1900, 0x2a67, 0x0000 },

-  { 0x9900, 0x2a6c, 0x3000 },

-  { 0x9900, 0x2a6a, 0x2000 },

-  { 0x1900, 0x2a69, 0x0000 },

-  { 0x1900, 0x2a6b, 0x0000 },

-  { 0x9900, 0x2a6e, 0x2000 },

-  { 0x1900, 0x2a6d, 0x0000 },

-  { 0x1900, 0x2a6f, 0x0000 },

-  { 0x9900, 0x2a78, 0x4000 },

-  { 0x9900, 0x2a74, 0x3000 },

-  { 0x9900, 0x2a72, 0x2000 },

-  { 0x1900, 0x2a71, 0x0000 },

-  { 0x1900, 0x2a73, 0x0000 },

-  { 0x9900, 0x2a76, 0x2000 },

-  { 0x1900, 0x2a75, 0x0000 },

-  { 0x1900, 0x2a77, 0x0000 },

-  { 0x9900, 0x2a7c, 0x3000 },

-  { 0x9900, 0x2a7a, 0x2000 },

-  { 0x1900, 0x2a79, 0x0000 },

-  { 0x1900, 0x2a7b, 0x0000 },

-  { 0x9900, 0x2a7e, 0x2000 },

-  { 0x1900, 0x2a7d, 0x0000 },

-  { 0x1900, 0x2a7f, 0x0000 },

-  { 0x9900, 0x2a90, 0x5000 },

-  { 0x9900, 0x2a88, 0x4000 },

-  { 0x9900, 0x2a84, 0x3000 },

-  { 0x9900, 0x2a82, 0x2000 },

-  { 0x1900, 0x2a81, 0x0000 },

-  { 0x1900, 0x2a83, 0x0000 },

-  { 0x9900, 0x2a86, 0x2000 },

-  { 0x1900, 0x2a85, 0x0000 },

-  { 0x1900, 0x2a87, 0x0000 },

-  { 0x9900, 0x2a8c, 0x3000 },

-  { 0x9900, 0x2a8a, 0x2000 },

-  { 0x1900, 0x2a89, 0x0000 },

-  { 0x1900, 0x2a8b, 0x0000 },

-  { 0x9900, 0x2a8e, 0x2000 },

-  { 0x1900, 0x2a8d, 0x0000 },

-  { 0x1900, 0x2a8f, 0x0000 },

-  { 0x9900, 0x2a98, 0x4000 },

-  { 0x9900, 0x2a94, 0x3000 },

-  { 0x9900, 0x2a92, 0x2000 },

-  { 0x1900, 0x2a91, 0x0000 },

-  { 0x1900, 0x2a93, 0x0000 },

-  { 0x9900, 0x2a96, 0x2000 },

-  { 0x1900, 0x2a95, 0x0000 },

-  { 0x1900, 0x2a97, 0x0000 },

-  { 0x9900, 0x2a9c, 0x3000 },

-  { 0x9900, 0x2a9a, 0x2000 },

-  { 0x1900, 0x2a99, 0x0000 },

-  { 0x1900, 0x2a9b, 0x0000 },

-  { 0x9900, 0x2a9e, 0x2000 },

-  { 0x1900, 0x2a9d, 0x0000 },

-  { 0x1900, 0x2a9f, 0x0000 },

-  { 0x9a00, 0x2e92, 0x8000 },

-  { 0x9900, 0x2ae0, 0x7000 },

-  { 0x9900, 0x2ac0, 0x6000 },

-  { 0x9900, 0x2ab0, 0x5000 },

-  { 0x9900, 0x2aa8, 0x4000 },

-  { 0x9900, 0x2aa4, 0x3000 },

-  { 0x9900, 0x2aa2, 0x2000 },

-  { 0x1900, 0x2aa1, 0x0000 },

-  { 0x1900, 0x2aa3, 0x0000 },

-  { 0x9900, 0x2aa6, 0x2000 },

-  { 0x1900, 0x2aa5, 0x0000 },

-  { 0x1900, 0x2aa7, 0x0000 },

-  { 0x9900, 0x2aac, 0x3000 },

-  { 0x9900, 0x2aaa, 0x2000 },

-  { 0x1900, 0x2aa9, 0x0000 },

-  { 0x1900, 0x2aab, 0x0000 },

-  { 0x9900, 0x2aae, 0x2000 },

-  { 0x1900, 0x2aad, 0x0000 },

-  { 0x1900, 0x2aaf, 0x0000 },

-  { 0x9900, 0x2ab8, 0x4000 },

-  { 0x9900, 0x2ab4, 0x3000 },

-  { 0x9900, 0x2ab2, 0x2000 },

-  { 0x1900, 0x2ab1, 0x0000 },

-  { 0x1900, 0x2ab3, 0x0000 },

-  { 0x9900, 0x2ab6, 0x2000 },

-  { 0x1900, 0x2ab5, 0x0000 },

-  { 0x1900, 0x2ab7, 0x0000 },

-  { 0x9900, 0x2abc, 0x3000 },

-  { 0x9900, 0x2aba, 0x2000 },

-  { 0x1900, 0x2ab9, 0x0000 },

-  { 0x1900, 0x2abb, 0x0000 },

-  { 0x9900, 0x2abe, 0x2000 },

-  { 0x1900, 0x2abd, 0x0000 },

-  { 0x1900, 0x2abf, 0x0000 },

-  { 0x9900, 0x2ad0, 0x5000 },

-  { 0x9900, 0x2ac8, 0x4000 },

-  { 0x9900, 0x2ac4, 0x3000 },

-  { 0x9900, 0x2ac2, 0x2000 },

-  { 0x1900, 0x2ac1, 0x0000 },

-  { 0x1900, 0x2ac3, 0x0000 },

-  { 0x9900, 0x2ac6, 0x2000 },

-  { 0x1900, 0x2ac5, 0x0000 },

-  { 0x1900, 0x2ac7, 0x0000 },

-  { 0x9900, 0x2acc, 0x3000 },

-  { 0x9900, 0x2aca, 0x2000 },

-  { 0x1900, 0x2ac9, 0x0000 },

-  { 0x1900, 0x2acb, 0x0000 },

-  { 0x9900, 0x2ace, 0x2000 },

-  { 0x1900, 0x2acd, 0x0000 },

-  { 0x1900, 0x2acf, 0x0000 },

-  { 0x9900, 0x2ad8, 0x4000 },

-  { 0x9900, 0x2ad4, 0x3000 },

-  { 0x9900, 0x2ad2, 0x2000 },

-  { 0x1900, 0x2ad1, 0x0000 },

-  { 0x1900, 0x2ad3, 0x0000 },

-  { 0x9900, 0x2ad6, 0x2000 },

-  { 0x1900, 0x2ad5, 0x0000 },

-  { 0x1900, 0x2ad7, 0x0000 },

-  { 0x9900, 0x2adc, 0x3000 },

-  { 0x9900, 0x2ada, 0x2000 },

-  { 0x1900, 0x2ad9, 0x0000 },

-  { 0x1900, 0x2adb, 0x0000 },

-  { 0x9900, 0x2ade, 0x2000 },

-  { 0x1900, 0x2add, 0x0000 },

-  { 0x1900, 0x2adf, 0x0000 },

-  { 0x9a00, 0x2b00, 0x6000 },

-  { 0x9900, 0x2af0, 0x5000 },

-  { 0x9900, 0x2ae8, 0x4000 },

-  { 0x9900, 0x2ae4, 0x3000 },

-  { 0x9900, 0x2ae2, 0x2000 },

-  { 0x1900, 0x2ae1, 0x0000 },

-  { 0x1900, 0x2ae3, 0x0000 },

-  { 0x9900, 0x2ae6, 0x2000 },

-  { 0x1900, 0x2ae5, 0x0000 },

-  { 0x1900, 0x2ae7, 0x0000 },

-  { 0x9900, 0x2aec, 0x3000 },

-  { 0x9900, 0x2aea, 0x2000 },

-  { 0x1900, 0x2ae9, 0x0000 },

-  { 0x1900, 0x2aeb, 0x0000 },

-  { 0x9900, 0x2aee, 0x2000 },

-  { 0x1900, 0x2aed, 0x0000 },

-  { 0x1900, 0x2aef, 0x0000 },

-  { 0x9900, 0x2af8, 0x4000 },

-  { 0x9900, 0x2af4, 0x3000 },

-  { 0x9900, 0x2af2, 0x2000 },

-  { 0x1900, 0x2af1, 0x0000 },

-  { 0x1900, 0x2af3, 0x0000 },

-  { 0x9900, 0x2af6, 0x2000 },

-  { 0x1900, 0x2af5, 0x0000 },

-  { 0x1900, 0x2af7, 0x0000 },

-  { 0x9900, 0x2afc, 0x3000 },

-  { 0x9900, 0x2afa, 0x2000 },

-  { 0x1900, 0x2af9, 0x0000 },

-  { 0x1900, 0x2afb, 0x0000 },

-  { 0x9900, 0x2afe, 0x2000 },

-  { 0x1900, 0x2afd, 0x0000 },

-  { 0x1900, 0x2aff, 0x0000 },

-  { 0x9a00, 0x2e82, 0x5000 },

-  { 0x9a00, 0x2b08, 0x4000 },

-  { 0x9a00, 0x2b04, 0x3000 },

-  { 0x9a00, 0x2b02, 0x2000 },

-  { 0x1a00, 0x2b01, 0x0000 },

-  { 0x1a00, 0x2b03, 0x0000 },

-  { 0x9a00, 0x2b06, 0x2000 },

-  { 0x1a00, 0x2b05, 0x0000 },

-  { 0x1a00, 0x2b07, 0x0000 },

-  { 0x9a00, 0x2b0c, 0x3000 },

-  { 0x9a00, 0x2b0a, 0x2000 },

-  { 0x1a00, 0x2b09, 0x0000 },

-  { 0x1a00, 0x2b0b, 0x0000 },

-  { 0x9a00, 0x2e80, 0x2000 },

-  { 0x1a00, 0x2b0d, 0x0000 },

-  { 0x1a00, 0x2e81, 0x0000 },

-  { 0x9a00, 0x2e8a, 0x4000 },

-  { 0x9a00, 0x2e86, 0x3000 },

-  { 0x9a00, 0x2e84, 0x2000 },

-  { 0x1a00, 0x2e83, 0x0000 },

-  { 0x1a00, 0x2e85, 0x0000 },

-  { 0x9a00, 0x2e88, 0x2000 },

-  { 0x1a00, 0x2e87, 0x0000 },

-  { 0x1a00, 0x2e89, 0x0000 },

-  { 0x9a00, 0x2e8e, 0x3000 },

-  { 0x9a00, 0x2e8c, 0x2000 },

-  { 0x1a00, 0x2e8b, 0x0000 },

-  { 0x1a00, 0x2e8d, 0x0000 },

-  { 0x9a00, 0x2e90, 0x2000 },

-  { 0x1a00, 0x2e8f, 0x0000 },

-  { 0x1a00, 0x2e91, 0x0000 },

-  { 0x9a00, 0x2ed3, 0x7000 },

-  { 0x9a00, 0x2eb3, 0x6000 },

-  { 0x9a00, 0x2ea3, 0x5000 },

-  { 0x9a00, 0x2e9b, 0x4000 },

-  { 0x9a00, 0x2e96, 0x3000 },

-  { 0x9a00, 0x2e94, 0x2000 },

-  { 0x1a00, 0x2e93, 0x0000 },

-  { 0x1a00, 0x2e95, 0x0000 },

-  { 0x9a00, 0x2e98, 0x2000 },

-  { 0x1a00, 0x2e97, 0x0000 },

-  { 0x1a00, 0x2e99, 0x0000 },

-  { 0x9a00, 0x2e9f, 0x3000 },

-  { 0x9a00, 0x2e9d, 0x2000 },

-  { 0x1a00, 0x2e9c, 0x0000 },

-  { 0x1a00, 0x2e9e, 0x0000 },

-  { 0x9a00, 0x2ea1, 0x2000 },

-  { 0x1a00, 0x2ea0, 0x0000 },

-  { 0x1a00, 0x2ea2, 0x0000 },

-  { 0x9a00, 0x2eab, 0x4000 },

-  { 0x9a00, 0x2ea7, 0x3000 },

-  { 0x9a00, 0x2ea5, 0x2000 },

-  { 0x1a00, 0x2ea4, 0x0000 },

-  { 0x1a00, 0x2ea6, 0x0000 },

-  { 0x9a00, 0x2ea9, 0x2000 },

-  { 0x1a00, 0x2ea8, 0x0000 },

-  { 0x1a00, 0x2eaa, 0x0000 },

-  { 0x9a00, 0x2eaf, 0x3000 },

-  { 0x9a00, 0x2ead, 0x2000 },

-  { 0x1a00, 0x2eac, 0x0000 },

-  { 0x1a00, 0x2eae, 0x0000 },

-  { 0x9a00, 0x2eb1, 0x2000 },

-  { 0x1a00, 0x2eb0, 0x0000 },

-  { 0x1a00, 0x2eb2, 0x0000 },

-  { 0x9a00, 0x2ec3, 0x5000 },

-  { 0x9a00, 0x2ebb, 0x4000 },

-  { 0x9a00, 0x2eb7, 0x3000 },

-  { 0x9a00, 0x2eb5, 0x2000 },

-  { 0x1a00, 0x2eb4, 0x0000 },

-  { 0x1a00, 0x2eb6, 0x0000 },

-  { 0x9a00, 0x2eb9, 0x2000 },

-  { 0x1a00, 0x2eb8, 0x0000 },

-  { 0x1a00, 0x2eba, 0x0000 },

-  { 0x9a00, 0x2ebf, 0x3000 },

-  { 0x9a00, 0x2ebd, 0x2000 },

-  { 0x1a00, 0x2ebc, 0x0000 },

-  { 0x1a00, 0x2ebe, 0x0000 },

-  { 0x9a00, 0x2ec1, 0x2000 },

-  { 0x1a00, 0x2ec0, 0x0000 },

-  { 0x1a00, 0x2ec2, 0x0000 },

-  { 0x9a00, 0x2ecb, 0x4000 },

-  { 0x9a00, 0x2ec7, 0x3000 },

-  { 0x9a00, 0x2ec5, 0x2000 },

-  { 0x1a00, 0x2ec4, 0x0000 },

-  { 0x1a00, 0x2ec6, 0x0000 },

-  { 0x9a00, 0x2ec9, 0x2000 },

-  { 0x1a00, 0x2ec8, 0x0000 },

-  { 0x1a00, 0x2eca, 0x0000 },

-  { 0x9a00, 0x2ecf, 0x3000 },

-  { 0x9a00, 0x2ecd, 0x2000 },

-  { 0x1a00, 0x2ecc, 0x0000 },

-  { 0x1a00, 0x2ece, 0x0000 },

-  { 0x9a00, 0x2ed1, 0x2000 },

-  { 0x1a00, 0x2ed0, 0x0000 },

-  { 0x1a00, 0x2ed2, 0x0000 },

-  { 0x9a00, 0x2ef3, 0x6000 },

-  { 0x9a00, 0x2ee3, 0x5000 },

-  { 0x9a00, 0x2edb, 0x4000 },

-  { 0x9a00, 0x2ed7, 0x3000 },

-  { 0x9a00, 0x2ed5, 0x2000 },

-  { 0x1a00, 0x2ed4, 0x0000 },

-  { 0x1a00, 0x2ed6, 0x0000 },

-  { 0x9a00, 0x2ed9, 0x2000 },

-  { 0x1a00, 0x2ed8, 0x0000 },

-  { 0x1a00, 0x2eda, 0x0000 },

-  { 0x9a00, 0x2edf, 0x3000 },

-  { 0x9a00, 0x2edd, 0x2000 },

-  { 0x1a00, 0x2edc, 0x0000 },

-  { 0x1a00, 0x2ede, 0x0000 },

-  { 0x9a00, 0x2ee1, 0x2000 },

-  { 0x1a00, 0x2ee0, 0x0000 },

-  { 0x1a00, 0x2ee2, 0x0000 },

-  { 0x9a00, 0x2eeb, 0x4000 },

-  { 0x9a00, 0x2ee7, 0x3000 },

-  { 0x9a00, 0x2ee5, 0x2000 },

-  { 0x1a00, 0x2ee4, 0x0000 },

-  { 0x1a00, 0x2ee6, 0x0000 },

-  { 0x9a00, 0x2ee9, 0x2000 },

-  { 0x1a00, 0x2ee8, 0x0000 },

-  { 0x1a00, 0x2eea, 0x0000 },

-  { 0x9a00, 0x2eef, 0x3000 },

-  { 0x9a00, 0x2eed, 0x2000 },

-  { 0x1a00, 0x2eec, 0x0000 },

-  { 0x1a00, 0x2eee, 0x0000 },

-  { 0x9a00, 0x2ef1, 0x2000 },

-  { 0x1a00, 0x2ef0, 0x0000 },

-  { 0x1a00, 0x2ef2, 0x0000 },

-  { 0x9a00, 0x2f0f, 0x5000 },

-  { 0x9a00, 0x2f07, 0x4000 },

-  { 0x9a00, 0x2f03, 0x3000 },

-  { 0x9a00, 0x2f01, 0x2000 },

-  { 0x1a00, 0x2f00, 0x0000 },

-  { 0x1a00, 0x2f02, 0x0000 },

-  { 0x9a00, 0x2f05, 0x2000 },

-  { 0x1a00, 0x2f04, 0x0000 },

-  { 0x1a00, 0x2f06, 0x0000 },

-  { 0x9a00, 0x2f0b, 0x3000 },

-  { 0x9a00, 0x2f09, 0x2000 },

-  { 0x1a00, 0x2f08, 0x0000 },

-  { 0x1a00, 0x2f0a, 0x0000 },

-  { 0x9a00, 0x2f0d, 0x2000 },

-  { 0x1a00, 0x2f0c, 0x0000 },

-  { 0x1a00, 0x2f0e, 0x0000 },

-  { 0x9a00, 0x2f17, 0x4000 },

-  { 0x9a00, 0x2f13, 0x3000 },

-  { 0x9a00, 0x2f11, 0x2000 },

-  { 0x1a00, 0x2f10, 0x0000 },

-  { 0x1a00, 0x2f12, 0x0000 },

-  { 0x9a00, 0x2f15, 0x2000 },

-  { 0x1a00, 0x2f14, 0x0000 },

-  { 0x1a00, 0x2f16, 0x0000 },

-  { 0x9a00, 0x2f1b, 0x3000 },

-  { 0x9a00, 0x2f19, 0x2000 },

-  { 0x1a00, 0x2f18, 0x0000 },

-  { 0x1a00, 0x2f1a, 0x0000 },

-  { 0x9a00, 0x2f1d, 0x2000 },

-  { 0x1a00, 0x2f1c, 0x0000 },

-  { 0x1a00, 0x2f1e, 0x0000 },

-  { 0x8701, 0x00f0, 0xd000 },

-  { 0x8700, 0xa34d, 0xc000 },

-  { 0x9a00, 0x3391, 0xb000 },

-  { 0x8700, 0x3149, 0xa000 },

-  { 0x9500, 0x303d, 0x9000 },

-  { 0x9a00, 0x2f9f, 0x8000 },

-  { 0x9a00, 0x2f5f, 0x7000 },

-  { 0x9a00, 0x2f3f, 0x6000 },

-  { 0x9a00, 0x2f2f, 0x5000 },

-  { 0x9a00, 0x2f27, 0x4000 },

-  { 0x9a00, 0x2f23, 0x3000 },

-  { 0x9a00, 0x2f21, 0x2000 },

-  { 0x1a00, 0x2f20, 0x0000 },

-  { 0x1a00, 0x2f22, 0x0000 },

-  { 0x9a00, 0x2f25, 0x2000 },

-  { 0x1a00, 0x2f24, 0x0000 },

-  { 0x1a00, 0x2f26, 0x0000 },

-  { 0x9a00, 0x2f2b, 0x3000 },

-  { 0x9a00, 0x2f29, 0x2000 },

-  { 0x1a00, 0x2f28, 0x0000 },

-  { 0x1a00, 0x2f2a, 0x0000 },

-  { 0x9a00, 0x2f2d, 0x2000 },

-  { 0x1a00, 0x2f2c, 0x0000 },

-  { 0x1a00, 0x2f2e, 0x0000 },

-  { 0x9a00, 0x2f37, 0x4000 },

-  { 0x9a00, 0x2f33, 0x3000 },

-  { 0x9a00, 0x2f31, 0x2000 },

-  { 0x1a00, 0x2f30, 0x0000 },

-  { 0x1a00, 0x2f32, 0x0000 },

-  { 0x9a00, 0x2f35, 0x2000 },

-  { 0x1a00, 0x2f34, 0x0000 },

-  { 0x1a00, 0x2f36, 0x0000 },

-  { 0x9a00, 0x2f3b, 0x3000 },

-  { 0x9a00, 0x2f39, 0x2000 },

-  { 0x1a00, 0x2f38, 0x0000 },

-  { 0x1a00, 0x2f3a, 0x0000 },

-  { 0x9a00, 0x2f3d, 0x2000 },

-  { 0x1a00, 0x2f3c, 0x0000 },

-  { 0x1a00, 0x2f3e, 0x0000 },

-  { 0x9a00, 0x2f4f, 0x5000 },

-  { 0x9a00, 0x2f47, 0x4000 },

-  { 0x9a00, 0x2f43, 0x3000 },

-  { 0x9a00, 0x2f41, 0x2000 },

-  { 0x1a00, 0x2f40, 0x0000 },

-  { 0x1a00, 0x2f42, 0x0000 },

-  { 0x9a00, 0x2f45, 0x2000 },

-  { 0x1a00, 0x2f44, 0x0000 },

-  { 0x1a00, 0x2f46, 0x0000 },

-  { 0x9a00, 0x2f4b, 0x3000 },

-  { 0x9a00, 0x2f49, 0x2000 },

-  { 0x1a00, 0x2f48, 0x0000 },

-  { 0x1a00, 0x2f4a, 0x0000 },

-  { 0x9a00, 0x2f4d, 0x2000 },

-  { 0x1a00, 0x2f4c, 0x0000 },

-  { 0x1a00, 0x2f4e, 0x0000 },

-  { 0x9a00, 0x2f57, 0x4000 },

-  { 0x9a00, 0x2f53, 0x3000 },

-  { 0x9a00, 0x2f51, 0x2000 },

-  { 0x1a00, 0x2f50, 0x0000 },

-  { 0x1a00, 0x2f52, 0x0000 },

-  { 0x9a00, 0x2f55, 0x2000 },

-  { 0x1a00, 0x2f54, 0x0000 },

-  { 0x1a00, 0x2f56, 0x0000 },

-  { 0x9a00, 0x2f5b, 0x3000 },

-  { 0x9a00, 0x2f59, 0x2000 },

-  { 0x1a00, 0x2f58, 0x0000 },

-  { 0x1a00, 0x2f5a, 0x0000 },

-  { 0x9a00, 0x2f5d, 0x2000 },

-  { 0x1a00, 0x2f5c, 0x0000 },

-  { 0x1a00, 0x2f5e, 0x0000 },

-  { 0x9a00, 0x2f7f, 0x6000 },

-  { 0x9a00, 0x2f6f, 0x5000 },

-  { 0x9a00, 0x2f67, 0x4000 },

-  { 0x9a00, 0x2f63, 0x3000 },

-  { 0x9a00, 0x2f61, 0x2000 },

-  { 0x1a00, 0x2f60, 0x0000 },

-  { 0x1a00, 0x2f62, 0x0000 },

-  { 0x9a00, 0x2f65, 0x2000 },

-  { 0x1a00, 0x2f64, 0x0000 },

-  { 0x1a00, 0x2f66, 0x0000 },

-  { 0x9a00, 0x2f6b, 0x3000 },

-  { 0x9a00, 0x2f69, 0x2000 },

-  { 0x1a00, 0x2f68, 0x0000 },

-  { 0x1a00, 0x2f6a, 0x0000 },

-  { 0x9a00, 0x2f6d, 0x2000 },

-  { 0x1a00, 0x2f6c, 0x0000 },

-  { 0x1a00, 0x2f6e, 0x0000 },

-  { 0x9a00, 0x2f77, 0x4000 },

-  { 0x9a00, 0x2f73, 0x3000 },

-  { 0x9a00, 0x2f71, 0x2000 },

-  { 0x1a00, 0x2f70, 0x0000 },

-  { 0x1a00, 0x2f72, 0x0000 },

-  { 0x9a00, 0x2f75, 0x2000 },

-  { 0x1a00, 0x2f74, 0x0000 },

-  { 0x1a00, 0x2f76, 0x0000 },

-  { 0x9a00, 0x2f7b, 0x3000 },

-  { 0x9a00, 0x2f79, 0x2000 },

-  { 0x1a00, 0x2f78, 0x0000 },

-  { 0x1a00, 0x2f7a, 0x0000 },

-  { 0x9a00, 0x2f7d, 0x2000 },

-  { 0x1a00, 0x2f7c, 0x0000 },

-  { 0x1a00, 0x2f7e, 0x0000 },

-  { 0x9a00, 0x2f8f, 0x5000 },

-  { 0x9a00, 0x2f87, 0x4000 },

-  { 0x9a00, 0x2f83, 0x3000 },

-  { 0x9a00, 0x2f81, 0x2000 },

-  { 0x1a00, 0x2f80, 0x0000 },

-  { 0x1a00, 0x2f82, 0x0000 },

-  { 0x9a00, 0x2f85, 0x2000 },

-  { 0x1a00, 0x2f84, 0x0000 },

-  { 0x1a00, 0x2f86, 0x0000 },

-  { 0x9a00, 0x2f8b, 0x3000 },

-  { 0x9a00, 0x2f89, 0x2000 },

-  { 0x1a00, 0x2f88, 0x0000 },

-  { 0x1a00, 0x2f8a, 0x0000 },

-  { 0x9a00, 0x2f8d, 0x2000 },

-  { 0x1a00, 0x2f8c, 0x0000 },

-  { 0x1a00, 0x2f8e, 0x0000 },

-  { 0x9a00, 0x2f97, 0x4000 },

-  { 0x9a00, 0x2f93, 0x3000 },

-  { 0x9a00, 0x2f91, 0x2000 },

-  { 0x1a00, 0x2f90, 0x0000 },

-  { 0x1a00, 0x2f92, 0x0000 },

-  { 0x9a00, 0x2f95, 0x2000 },

-  { 0x1a00, 0x2f94, 0x0000 },

-  { 0x1a00, 0x2f96, 0x0000 },

-  { 0x9a00, 0x2f9b, 0x3000 },

-  { 0x9a00, 0x2f99, 0x2000 },

-  { 0x1a00, 0x2f98, 0x0000 },

-  { 0x1a00, 0x2f9a, 0x0000 },

-  { 0x9a00, 0x2f9d, 0x2000 },

-  { 0x1a00, 0x2f9c, 0x0000 },

-  { 0x1a00, 0x2f9e, 0x0000 },

-  { 0x9a00, 0x2ff9, 0x7000 },

-  { 0x9a00, 0x2fbf, 0x6000 },

-  { 0x9a00, 0x2faf, 0x5000 },

-  { 0x9a00, 0x2fa7, 0x4000 },

-  { 0x9a00, 0x2fa3, 0x3000 },

-  { 0x9a00, 0x2fa1, 0x2000 },

-  { 0x1a00, 0x2fa0, 0x0000 },

-  { 0x1a00, 0x2fa2, 0x0000 },

-  { 0x9a00, 0x2fa5, 0x2000 },

-  { 0x1a00, 0x2fa4, 0x0000 },

-  { 0x1a00, 0x2fa6, 0x0000 },

-  { 0x9a00, 0x2fab, 0x3000 },

-  { 0x9a00, 0x2fa9, 0x2000 },

-  { 0x1a00, 0x2fa8, 0x0000 },

-  { 0x1a00, 0x2faa, 0x0000 },

-  { 0x9a00, 0x2fad, 0x2000 },

-  { 0x1a00, 0x2fac, 0x0000 },

-  { 0x1a00, 0x2fae, 0x0000 },

-  { 0x9a00, 0x2fb7, 0x4000 },

-  { 0x9a00, 0x2fb3, 0x3000 },

-  { 0x9a00, 0x2fb1, 0x2000 },

-  { 0x1a00, 0x2fb0, 0x0000 },

-  { 0x1a00, 0x2fb2, 0x0000 },

-  { 0x9a00, 0x2fb5, 0x2000 },

-  { 0x1a00, 0x2fb4, 0x0000 },

-  { 0x1a00, 0x2fb6, 0x0000 },

-  { 0x9a00, 0x2fbb, 0x3000 },

-  { 0x9a00, 0x2fb9, 0x2000 },

-  { 0x1a00, 0x2fb8, 0x0000 },

-  { 0x1a00, 0x2fba, 0x0000 },

-  { 0x9a00, 0x2fbd, 0x2000 },

-  { 0x1a00, 0x2fbc, 0x0000 },

-  { 0x1a00, 0x2fbe, 0x0000 },

-  { 0x9a00, 0x2fcf, 0x5000 },

-  { 0x9a00, 0x2fc7, 0x4000 },

-  { 0x9a00, 0x2fc3, 0x3000 },

-  { 0x9a00, 0x2fc1, 0x2000 },

-  { 0x1a00, 0x2fc0, 0x0000 },

-  { 0x1a00, 0x2fc2, 0x0000 },

-  { 0x9a00, 0x2fc5, 0x2000 },

-  { 0x1a00, 0x2fc4, 0x0000 },

-  { 0x1a00, 0x2fc6, 0x0000 },

-  { 0x9a00, 0x2fcb, 0x3000 },

-  { 0x9a00, 0x2fc9, 0x2000 },

-  { 0x1a00, 0x2fc8, 0x0000 },

-  { 0x1a00, 0x2fca, 0x0000 },

-  { 0x9a00, 0x2fcd, 0x2000 },

-  { 0x1a00, 0x2fcc, 0x0000 },

-  { 0x1a00, 0x2fce, 0x0000 },

-  { 0x9a00, 0x2ff1, 0x4000 },

-  { 0x9a00, 0x2fd3, 0x3000 },

-  { 0x9a00, 0x2fd1, 0x2000 },

-  { 0x1a00, 0x2fd0, 0x0000 },

-  { 0x1a00, 0x2fd2, 0x0000 },

-  { 0x9a00, 0x2fd5, 0x2000 },

-  { 0x1a00, 0x2fd4, 0x0000 },

-  { 0x1a00, 0x2ff0, 0x0000 },

-  { 0x9a00, 0x2ff5, 0x3000 },

-  { 0x9a00, 0x2ff3, 0x2000 },

-  { 0x1a00, 0x2ff2, 0x0000 },

-  { 0x1a00, 0x2ff4, 0x0000 },

-  { 0x9a00, 0x2ff7, 0x2000 },

-  { 0x1a00, 0x2ff6, 0x0000 },

-  { 0x1a00, 0x2ff8, 0x0000 },

-  { 0x9600, 0x301d, 0x6000 },

-  { 0x9200, 0x300d, 0x5000 },

-  { 0x8600, 0x3005, 0x4000 },

-  { 0x9500, 0x3001, 0x3000 },

-  { 0x9a00, 0x2ffb, 0x2000 },

-  { 0x1a00, 0x2ffa, 0x0000 },

-  { 0x1d00, 0x3000, 0x0000 },

-  { 0x9500, 0x3003, 0x2000 },

-  { 0x1500, 0x3002, 0x0000 },

-  { 0x1a00, 0x3004, 0x0000 },

-  { 0x9200, 0x3009, 0x3000 },

-  { 0x8e00, 0x3007, 0x2000 },

-  { 0x0700, 0x3006, 0x0000 },

-  { 0x1600, 0x3008, 0x0000 },

-  { 0x9200, 0x300b, 0x2000 },

-  { 0x1600, 0x300a, 0x0000 },

-  { 0x1600, 0x300c, 0x0000 },

-  { 0x9200, 0x3015, 0x4000 },

-  { 0x9200, 0x3011, 0x3000 },

-  { 0x9200, 0x300f, 0x2000 },

-  { 0x1600, 0x300e, 0x0000 },

-  { 0x1600, 0x3010, 0x0000 },

-  { 0x9a00, 0x3013, 0x2000 },

-  { 0x1a00, 0x3012, 0x0000 },

-  { 0x1600, 0x3014, 0x0000 },

-  { 0x9200, 0x3019, 0x3000 },

-  { 0x9200, 0x3017, 0x2000 },

-  { 0x1600, 0x3016, 0x0000 },

-  { 0x1600, 0x3018, 0x0000 },

-  { 0x9200, 0x301b, 0x2000 },

-  { 0x1600, 0x301a, 0x0000 },

-  { 0x1100, 0x301c, 0x0000 },

-  { 0x8c00, 0x302d, 0x5000 },

-  { 0x8e00, 0x3025, 0x4000 },

-  { 0x8e00, 0x3021, 0x3000 },

-  { 0x9200, 0x301f, 0x2000 },

-  { 0x1200, 0x301e, 0x0000 },

-  { 0x1a00, 0x3020, 0x0000 },

-  { 0x8e00, 0x3023, 0x2000 },

-  { 0x0e00, 0x3022, 0x0000 },

-  { 0x0e00, 0x3024, 0x0000 },

-  { 0x8e00, 0x3029, 0x3000 },

-  { 0x8e00, 0x3027, 0x2000 },

-  { 0x0e00, 0x3026, 0x0000 },

-  { 0x0e00, 0x3028, 0x0000 },

-  { 0x8c00, 0x302b, 0x2000 },

-  { 0x0c00, 0x302a, 0x0000 },

-  { 0x0c00, 0x302c, 0x0000 },

-  { 0x8600, 0x3035, 0x4000 },

-  { 0x8600, 0x3031, 0x3000 },

-  { 0x8c00, 0x302f, 0x2000 },

-  { 0x0c00, 0x302e, 0x0000 },

-  { 0x1100, 0x3030, 0x0000 },

-  { 0x8600, 0x3033, 0x2000 },

-  { 0x0600, 0x3032, 0x0000 },

-  { 0x0600, 0x3034, 0x0000 },

-  { 0x8e00, 0x3039, 0x3000 },

-  { 0x9a00, 0x3037, 0x2000 },

-  { 0x1a00, 0x3036, 0x0000 },

-  { 0x0e00, 0x3038, 0x0000 },

-  { 0x8600, 0x303b, 0x2000 },

-  { 0x0e00, 0x303a, 0x0000 },

-  { 0x0700, 0x303c, 0x0000 },

-  { 0x8700, 0x30c0, 0x8000 },

-  { 0x8700, 0x307e, 0x7000 },

-  { 0x8700, 0x305e, 0x6000 },

-  { 0x8700, 0x304e, 0x5000 },

-  { 0x8700, 0x3046, 0x4000 },

-  { 0x8700, 0x3042, 0x3000 },

-  { 0x9a00, 0x303f, 0x2000 },

-  { 0x1a00, 0x303e, 0x0000 },

-  { 0x0700, 0x3041, 0x0000 },

-  { 0x8700, 0x3044, 0x2000 },

-  { 0x0700, 0x3043, 0x0000 },

-  { 0x0700, 0x3045, 0x0000 },

-  { 0x8700, 0x304a, 0x3000 },

-  { 0x8700, 0x3048, 0x2000 },

-  { 0x0700, 0x3047, 0x0000 },

-  { 0x0700, 0x3049, 0x0000 },

-  { 0x8700, 0x304c, 0x2000 },

-  { 0x0700, 0x304b, 0x0000 },

-  { 0x0700, 0x304d, 0x0000 },

-  { 0x8700, 0x3056, 0x4000 },

-  { 0x8700, 0x3052, 0x3000 },

-  { 0x8700, 0x3050, 0x2000 },

-  { 0x0700, 0x304f, 0x0000 },

-  { 0x0700, 0x3051, 0x0000 },

-  { 0x8700, 0x3054, 0x2000 },

-  { 0x0700, 0x3053, 0x0000 },

-  { 0x0700, 0x3055, 0x0000 },

-  { 0x8700, 0x305a, 0x3000 },

-  { 0x8700, 0x3058, 0x2000 },

-  { 0x0700, 0x3057, 0x0000 },

-  { 0x0700, 0x3059, 0x0000 },

-  { 0x8700, 0x305c, 0x2000 },

-  { 0x0700, 0x305b, 0x0000 },

-  { 0x0700, 0x305d, 0x0000 },

-  { 0x8700, 0x306e, 0x5000 },

-  { 0x8700, 0x3066, 0x4000 },

-  { 0x8700, 0x3062, 0x3000 },

-  { 0x8700, 0x3060, 0x2000 },

-  { 0x0700, 0x305f, 0x0000 },

-  { 0x0700, 0x3061, 0x0000 },

-  { 0x8700, 0x3064, 0x2000 },

-  { 0x0700, 0x3063, 0x0000 },

-  { 0x0700, 0x3065, 0x0000 },

-  { 0x8700, 0x306a, 0x3000 },

-  { 0x8700, 0x3068, 0x2000 },

-  { 0x0700, 0x3067, 0x0000 },

-  { 0x0700, 0x3069, 0x0000 },

-  { 0x8700, 0x306c, 0x2000 },

-  { 0x0700, 0x306b, 0x0000 },

-  { 0x0700, 0x306d, 0x0000 },

-  { 0x8700, 0x3076, 0x4000 },

-  { 0x8700, 0x3072, 0x3000 },

-  { 0x8700, 0x3070, 0x2000 },

-  { 0x0700, 0x306f, 0x0000 },

-  { 0x0700, 0x3071, 0x0000 },

-  { 0x8700, 0x3074, 0x2000 },

-  { 0x0700, 0x3073, 0x0000 },

-  { 0x0700, 0x3075, 0x0000 },

-  { 0x8700, 0x307a, 0x3000 },

-  { 0x8700, 0x3078, 0x2000 },

-  { 0x0700, 0x3077, 0x0000 },

-  { 0x0700, 0x3079, 0x0000 },

-  { 0x8700, 0x307c, 0x2000 },

-  { 0x0700, 0x307b, 0x0000 },

-  { 0x0700, 0x307d, 0x0000 },

-  { 0x9100, 0x30a0, 0x6000 },

-  { 0x8700, 0x308e, 0x5000 },

-  { 0x8700, 0x3086, 0x4000 },

-  { 0x8700, 0x3082, 0x3000 },

-  { 0x8700, 0x3080, 0x2000 },

-  { 0x0700, 0x307f, 0x0000 },

-  { 0x0700, 0x3081, 0x0000 },

-  { 0x8700, 0x3084, 0x2000 },

-  { 0x0700, 0x3083, 0x0000 },

-  { 0x0700, 0x3085, 0x0000 },

-  { 0x8700, 0x308a, 0x3000 },

-  { 0x8700, 0x3088, 0x2000 },

-  { 0x0700, 0x3087, 0x0000 },

-  { 0x0700, 0x3089, 0x0000 },

-  { 0x8700, 0x308c, 0x2000 },

-  { 0x0700, 0x308b, 0x0000 },

-  { 0x0700, 0x308d, 0x0000 },

-  { 0x8700, 0x3096, 0x4000 },

-  { 0x8700, 0x3092, 0x3000 },

-  { 0x8700, 0x3090, 0x2000 },

-  { 0x0700, 0x308f, 0x0000 },

-  { 0x0700, 0x3091, 0x0000 },

-  { 0x8700, 0x3094, 0x2000 },

-  { 0x0700, 0x3093, 0x0000 },

-  { 0x0700, 0x3095, 0x0000 },

-  { 0x9800, 0x309c, 0x3000 },

-  { 0x8c00, 0x309a, 0x2000 },

-  { 0x0c00, 0x3099, 0x0000 },

-  { 0x1800, 0x309b, 0x0000 },

-  { 0x8600, 0x309e, 0x2000 },

-  { 0x0600, 0x309d, 0x0000 },

-  { 0x0700, 0x309f, 0x0000 },

-  { 0x8700, 0x30b0, 0x5000 },

-  { 0x8700, 0x30a8, 0x4000 },

-  { 0x8700, 0x30a4, 0x3000 },

-  { 0x8700, 0x30a2, 0x2000 },

-  { 0x0700, 0x30a1, 0x0000 },

-  { 0x0700, 0x30a3, 0x0000 },

-  { 0x8700, 0x30a6, 0x2000 },

-  { 0x0700, 0x30a5, 0x0000 },

-  { 0x0700, 0x30a7, 0x0000 },

-  { 0x8700, 0x30ac, 0x3000 },

-  { 0x8700, 0x30aa, 0x2000 },

-  { 0x0700, 0x30a9, 0x0000 },

-  { 0x0700, 0x30ab, 0x0000 },

-  { 0x8700, 0x30ae, 0x2000 },

-  { 0x0700, 0x30ad, 0x0000 },

-  { 0x0700, 0x30af, 0x0000 },

-  { 0x8700, 0x30b8, 0x4000 },

-  { 0x8700, 0x30b4, 0x3000 },

-  { 0x8700, 0x30b2, 0x2000 },

-  { 0x0700, 0x30b1, 0x0000 },

-  { 0x0700, 0x30b3, 0x0000 },

-  { 0x8700, 0x30b6, 0x2000 },

-  { 0x0700, 0x30b5, 0x0000 },

-  { 0x0700, 0x30b7, 0x0000 },

-  { 0x8700, 0x30bc, 0x3000 },

-  { 0x8700, 0x30ba, 0x2000 },

-  { 0x0700, 0x30b9, 0x0000 },

-  { 0x0700, 0x30bb, 0x0000 },

-  { 0x8700, 0x30be, 0x2000 },

-  { 0x0700, 0x30bd, 0x0000 },

-  { 0x0700, 0x30bf, 0x0000 },

-  { 0x8700, 0x3105, 0x7000 },

-  { 0x8700, 0x30e0, 0x6000 },

-  { 0x8700, 0x30d0, 0x5000 },

-  { 0x8700, 0x30c8, 0x4000 },

-  { 0x8700, 0x30c4, 0x3000 },

-  { 0x8700, 0x30c2, 0x2000 },

-  { 0x0700, 0x30c1, 0x0000 },

-  { 0x0700, 0x30c3, 0x0000 },

-  { 0x8700, 0x30c6, 0x2000 },

-  { 0x0700, 0x30c5, 0x0000 },

-  { 0x0700, 0x30c7, 0x0000 },

-  { 0x8700, 0x30cc, 0x3000 },

-  { 0x8700, 0x30ca, 0x2000 },

-  { 0x0700, 0x30c9, 0x0000 },

-  { 0x0700, 0x30cb, 0x0000 },

-  { 0x8700, 0x30ce, 0x2000 },

-  { 0x0700, 0x30cd, 0x0000 },

-  { 0x0700, 0x30cf, 0x0000 },

-  { 0x8700, 0x30d8, 0x4000 },

-  { 0x8700, 0x30d4, 0x3000 },

-  { 0x8700, 0x30d2, 0x2000 },

-  { 0x0700, 0x30d1, 0x0000 },

-  { 0x0700, 0x30d3, 0x0000 },

-  { 0x8700, 0x30d6, 0x2000 },

-  { 0x0700, 0x30d5, 0x0000 },

-  { 0x0700, 0x30d7, 0x0000 },

-  { 0x8700, 0x30dc, 0x3000 },

-  { 0x8700, 0x30da, 0x2000 },

-  { 0x0700, 0x30d9, 0x0000 },

-  { 0x0700, 0x30db, 0x0000 },

-  { 0x8700, 0x30de, 0x2000 },

-  { 0x0700, 0x30dd, 0x0000 },

-  { 0x0700, 0x30df, 0x0000 },

-  { 0x8700, 0x30f0, 0x5000 },

-  { 0x8700, 0x30e8, 0x4000 },

-  { 0x8700, 0x30e4, 0x3000 },

-  { 0x8700, 0x30e2, 0x2000 },

-  { 0x0700, 0x30e1, 0x0000 },

-  { 0x0700, 0x30e3, 0x0000 },

-  { 0x8700, 0x30e6, 0x2000 },

-  { 0x0700, 0x30e5, 0x0000 },

-  { 0x0700, 0x30e7, 0x0000 },

-  { 0x8700, 0x30ec, 0x3000 },

-  { 0x8700, 0x30ea, 0x2000 },

-  { 0x0700, 0x30e9, 0x0000 },

-  { 0x0700, 0x30eb, 0x0000 },

-  { 0x8700, 0x30ee, 0x2000 },

-  { 0x0700, 0x30ed, 0x0000 },

-  { 0x0700, 0x30ef, 0x0000 },

-  { 0x8700, 0x30f8, 0x4000 },

-  { 0x8700, 0x30f4, 0x3000 },

-  { 0x8700, 0x30f2, 0x2000 },

-  { 0x0700, 0x30f1, 0x0000 },

-  { 0x0700, 0x30f3, 0x0000 },

-  { 0x8700, 0x30f6, 0x2000 },

-  { 0x0700, 0x30f5, 0x0000 },

-  { 0x0700, 0x30f7, 0x0000 },

-  { 0x8600, 0x30fc, 0x3000 },

-  { 0x8700, 0x30fa, 0x2000 },

-  { 0x0700, 0x30f9, 0x0000 },

-  { 0x1000, 0x30fb, 0x0000 },

-  { 0x8600, 0x30fe, 0x2000 },

-  { 0x0600, 0x30fd, 0x0000 },

-  { 0x0700, 0x30ff, 0x0000 },

-  { 0x8700, 0x3125, 0x6000 },

-  { 0x8700, 0x3115, 0x5000 },

-  { 0x8700, 0x310d, 0x4000 },

-  { 0x8700, 0x3109, 0x3000 },

-  { 0x8700, 0x3107, 0x2000 },

-  { 0x0700, 0x3106, 0x0000 },

-  { 0x0700, 0x3108, 0x0000 },

-  { 0x8700, 0x310b, 0x2000 },

-  { 0x0700, 0x310a, 0x0000 },

-  { 0x0700, 0x310c, 0x0000 },

-  { 0x8700, 0x3111, 0x3000 },

-  { 0x8700, 0x310f, 0x2000 },

-  { 0x0700, 0x310e, 0x0000 },

-  { 0x0700, 0x3110, 0x0000 },

-  { 0x8700, 0x3113, 0x2000 },

-  { 0x0700, 0x3112, 0x0000 },

-  { 0x0700, 0x3114, 0x0000 },

-  { 0x8700, 0x311d, 0x4000 },

-  { 0x8700, 0x3119, 0x3000 },

-  { 0x8700, 0x3117, 0x2000 },

-  { 0x0700, 0x3116, 0x0000 },

-  { 0x0700, 0x3118, 0x0000 },

-  { 0x8700, 0x311b, 0x2000 },

-  { 0x0700, 0x311a, 0x0000 },

-  { 0x0700, 0x311c, 0x0000 },

-  { 0x8700, 0x3121, 0x3000 },

-  { 0x8700, 0x311f, 0x2000 },

-  { 0x0700, 0x311e, 0x0000 },

-  { 0x0700, 0x3120, 0x0000 },

-  { 0x8700, 0x3123, 0x2000 },

-  { 0x0700, 0x3122, 0x0000 },

-  { 0x0700, 0x3124, 0x0000 },

-  { 0x8700, 0x3139, 0x5000 },

-  { 0x8700, 0x3131, 0x4000 },

-  { 0x8700, 0x3129, 0x3000 },

-  { 0x8700, 0x3127, 0x2000 },

-  { 0x0700, 0x3126, 0x0000 },

-  { 0x0700, 0x3128, 0x0000 },

-  { 0x8700, 0x312b, 0x2000 },

-  { 0x0700, 0x312a, 0x0000 },

-  { 0x0700, 0x312c, 0x0000 },

-  { 0x8700, 0x3135, 0x3000 },

-  { 0x8700, 0x3133, 0x2000 },

-  { 0x0700, 0x3132, 0x0000 },

-  { 0x0700, 0x3134, 0x0000 },

-  { 0x8700, 0x3137, 0x2000 },

-  { 0x0700, 0x3136, 0x0000 },

-  { 0x0700, 0x3138, 0x0000 },

-  { 0x8700, 0x3141, 0x4000 },

-  { 0x8700, 0x313d, 0x3000 },

-  { 0x8700, 0x313b, 0x2000 },

-  { 0x0700, 0x313a, 0x0000 },

-  { 0x0700, 0x313c, 0x0000 },

-  { 0x8700, 0x313f, 0x2000 },

-  { 0x0700, 0x313e, 0x0000 },

-  { 0x0700, 0x3140, 0x0000 },

-  { 0x8700, 0x3145, 0x3000 },

-  { 0x8700, 0x3143, 0x2000 },

-  { 0x0700, 0x3142, 0x0000 },

-  { 0x0700, 0x3144, 0x0000 },

-  { 0x8700, 0x3147, 0x2000 },

-  { 0x0700, 0x3146, 0x0000 },

-  { 0x0700, 0x3148, 0x0000 },

-  { 0x9a00, 0x3290, 0x9000 },

-  { 0x9a00, 0x3202, 0x8000 },

-  { 0x8700, 0x3189, 0x7000 },

-  { 0x8700, 0x3169, 0x6000 },

-  { 0x8700, 0x3159, 0x5000 },

-  { 0x8700, 0x3151, 0x4000 },

-  { 0x8700, 0x314d, 0x3000 },

-  { 0x8700, 0x314b, 0x2000 },

-  { 0x0700, 0x314a, 0x0000 },

-  { 0x0700, 0x314c, 0x0000 },

-  { 0x8700, 0x314f, 0x2000 },

-  { 0x0700, 0x314e, 0x0000 },

-  { 0x0700, 0x3150, 0x0000 },

-  { 0x8700, 0x3155, 0x3000 },

-  { 0x8700, 0x3153, 0x2000 },

-  { 0x0700, 0x3152, 0x0000 },

-  { 0x0700, 0x3154, 0x0000 },

-  { 0x8700, 0x3157, 0x2000 },

-  { 0x0700, 0x3156, 0x0000 },

-  { 0x0700, 0x3158, 0x0000 },

-  { 0x8700, 0x3161, 0x4000 },

-  { 0x8700, 0x315d, 0x3000 },

-  { 0x8700, 0x315b, 0x2000 },

-  { 0x0700, 0x315a, 0x0000 },

-  { 0x0700, 0x315c, 0x0000 },

-  { 0x8700, 0x315f, 0x2000 },

-  { 0x0700, 0x315e, 0x0000 },

-  { 0x0700, 0x3160, 0x0000 },

-  { 0x8700, 0x3165, 0x3000 },

-  { 0x8700, 0x3163, 0x2000 },

-  { 0x0700, 0x3162, 0x0000 },

-  { 0x0700, 0x3164, 0x0000 },

-  { 0x8700, 0x3167, 0x2000 },

-  { 0x0700, 0x3166, 0x0000 },

-  { 0x0700, 0x3168, 0x0000 },

-  { 0x8700, 0x3179, 0x5000 },

-  { 0x8700, 0x3171, 0x4000 },

-  { 0x8700, 0x316d, 0x3000 },

-  { 0x8700, 0x316b, 0x2000 },

-  { 0x0700, 0x316a, 0x0000 },

-  { 0x0700, 0x316c, 0x0000 },

-  { 0x8700, 0x316f, 0x2000 },

-  { 0x0700, 0x316e, 0x0000 },

-  { 0x0700, 0x3170, 0x0000 },

-  { 0x8700, 0x3175, 0x3000 },

-  { 0x8700, 0x3173, 0x2000 },

-  { 0x0700, 0x3172, 0x0000 },

-  { 0x0700, 0x3174, 0x0000 },

-  { 0x8700, 0x3177, 0x2000 },

-  { 0x0700, 0x3176, 0x0000 },

-  { 0x0700, 0x3178, 0x0000 },

-  { 0x8700, 0x3181, 0x4000 },

-  { 0x8700, 0x317d, 0x3000 },

-  { 0x8700, 0x317b, 0x2000 },

-  { 0x0700, 0x317a, 0x0000 },

-  { 0x0700, 0x317c, 0x0000 },

-  { 0x8700, 0x317f, 0x2000 },

-  { 0x0700, 0x317e, 0x0000 },

-  { 0x0700, 0x3180, 0x0000 },

-  { 0x8700, 0x3185, 0x3000 },

-  { 0x8700, 0x3183, 0x2000 },

-  { 0x0700, 0x3182, 0x0000 },

-  { 0x0700, 0x3184, 0x0000 },

-  { 0x8700, 0x3187, 0x2000 },

-  { 0x0700, 0x3186, 0x0000 },

-  { 0x0700, 0x3188, 0x0000 },

-  { 0x8700, 0x31aa, 0x6000 },

-  { 0x9a00, 0x319a, 0x5000 },

-  { 0x8f00, 0x3192, 0x4000 },

-  { 0x8700, 0x318d, 0x3000 },

-  { 0x8700, 0x318b, 0x2000 },

-  { 0x0700, 0x318a, 0x0000 },

-  { 0x0700, 0x318c, 0x0000 },

-  { 0x9a00, 0x3190, 0x2000 },

-  { 0x0700, 0x318e, 0x0000 },

-  { 0x1a00, 0x3191, 0x0000 },

-  { 0x9a00, 0x3196, 0x3000 },

-  { 0x8f00, 0x3194, 0x2000 },

-  { 0x0f00, 0x3193, 0x0000 },

-  { 0x0f00, 0x3195, 0x0000 },

-  { 0x9a00, 0x3198, 0x2000 },

-  { 0x1a00, 0x3197, 0x0000 },

-  { 0x1a00, 0x3199, 0x0000 },

-  { 0x8700, 0x31a2, 0x4000 },

-  { 0x9a00, 0x319e, 0x3000 },

-  { 0x9a00, 0x319c, 0x2000 },

-  { 0x1a00, 0x319b, 0x0000 },

-  { 0x1a00, 0x319d, 0x0000 },

-  { 0x8700, 0x31a0, 0x2000 },

-  { 0x1a00, 0x319f, 0x0000 },

-  { 0x0700, 0x31a1, 0x0000 },

-  { 0x8700, 0x31a6, 0x3000 },

-  { 0x8700, 0x31a4, 0x2000 },

-  { 0x0700, 0x31a3, 0x0000 },

-  { 0x0700, 0x31a5, 0x0000 },

-  { 0x8700, 0x31a8, 0x2000 },

-  { 0x0700, 0x31a7, 0x0000 },

-  { 0x0700, 0x31a9, 0x0000 },

-  { 0x8700, 0x31f2, 0x5000 },

-  { 0x8700, 0x31b2, 0x4000 },

-  { 0x8700, 0x31ae, 0x3000 },

-  { 0x8700, 0x31ac, 0x2000 },

-  { 0x0700, 0x31ab, 0x0000 },

-  { 0x0700, 0x31ad, 0x0000 },

-  { 0x8700, 0x31b0, 0x2000 },

-  { 0x0700, 0x31af, 0x0000 },

-  { 0x0700, 0x31b1, 0x0000 },

-  { 0x8700, 0x31b6, 0x3000 },

-  { 0x8700, 0x31b4, 0x2000 },

-  { 0x0700, 0x31b3, 0x0000 },

-  { 0x0700, 0x31b5, 0x0000 },

-  { 0x8700, 0x31f0, 0x2000 },

-  { 0x0700, 0x31b7, 0x0000 },

-  { 0x0700, 0x31f1, 0x0000 },

-  { 0x8700, 0x31fa, 0x4000 },

-  { 0x8700, 0x31f6, 0x3000 },

-  { 0x8700, 0x31f4, 0x2000 },

-  { 0x0700, 0x31f3, 0x0000 },

-  { 0x0700, 0x31f5, 0x0000 },

-  { 0x8700, 0x31f8, 0x2000 },

-  { 0x0700, 0x31f7, 0x0000 },

-  { 0x0700, 0x31f9, 0x0000 },

-  { 0x8700, 0x31fe, 0x3000 },

-  { 0x8700, 0x31fc, 0x2000 },

-  { 0x0700, 0x31fb, 0x0000 },

-  { 0x0700, 0x31fd, 0x0000 },

-  { 0x9a00, 0x3200, 0x2000 },

-  { 0x0700, 0x31ff, 0x0000 },

-  { 0x1a00, 0x3201, 0x0000 },

-  { 0x9a00, 0x3243, 0x7000 },

-  { 0x8f00, 0x3223, 0x6000 },

-  { 0x9a00, 0x3212, 0x5000 },

-  { 0x9a00, 0x320a, 0x4000 },

-  { 0x9a00, 0x3206, 0x3000 },

-  { 0x9a00, 0x3204, 0x2000 },

-  { 0x1a00, 0x3203, 0x0000 },

-  { 0x1a00, 0x3205, 0x0000 },

-  { 0x9a00, 0x3208, 0x2000 },

-  { 0x1a00, 0x3207, 0x0000 },

-  { 0x1a00, 0x3209, 0x0000 },

-  { 0x9a00, 0x320e, 0x3000 },

-  { 0x9a00, 0x320c, 0x2000 },

-  { 0x1a00, 0x320b, 0x0000 },

-  { 0x1a00, 0x320d, 0x0000 },

-  { 0x9a00, 0x3210, 0x2000 },

-  { 0x1a00, 0x320f, 0x0000 },

-  { 0x1a00, 0x3211, 0x0000 },

-  { 0x9a00, 0x321a, 0x4000 },

-  { 0x9a00, 0x3216, 0x3000 },

-  { 0x9a00, 0x3214, 0x2000 },

-  { 0x1a00, 0x3213, 0x0000 },

-  { 0x1a00, 0x3215, 0x0000 },

-  { 0x9a00, 0x3218, 0x2000 },

-  { 0x1a00, 0x3217, 0x0000 },

-  { 0x1a00, 0x3219, 0x0000 },

-  { 0x9a00, 0x321e, 0x3000 },

-  { 0x9a00, 0x321c, 0x2000 },

-  { 0x1a00, 0x321b, 0x0000 },

-  { 0x1a00, 0x321d, 0x0000 },

-  { 0x8f00, 0x3221, 0x2000 },

-  { 0x0f00, 0x3220, 0x0000 },

-  { 0x0f00, 0x3222, 0x0000 },

-  { 0x9a00, 0x3233, 0x5000 },

-  { 0x9a00, 0x322b, 0x4000 },

-  { 0x8f00, 0x3227, 0x3000 },

-  { 0x8f00, 0x3225, 0x2000 },

-  { 0x0f00, 0x3224, 0x0000 },

-  { 0x0f00, 0x3226, 0x0000 },

-  { 0x8f00, 0x3229, 0x2000 },

-  { 0x0f00, 0x3228, 0x0000 },

-  { 0x1a00, 0x322a, 0x0000 },

-  { 0x9a00, 0x322f, 0x3000 },

-  { 0x9a00, 0x322d, 0x2000 },

-  { 0x1a00, 0x322c, 0x0000 },

-  { 0x1a00, 0x322e, 0x0000 },

-  { 0x9a00, 0x3231, 0x2000 },

-  { 0x1a00, 0x3230, 0x0000 },

-  { 0x1a00, 0x3232, 0x0000 },

-  { 0x9a00, 0x323b, 0x4000 },

-  { 0x9a00, 0x3237, 0x3000 },

-  { 0x9a00, 0x3235, 0x2000 },

-  { 0x1a00, 0x3234, 0x0000 },

-  { 0x1a00, 0x3236, 0x0000 },

-  { 0x9a00, 0x3239, 0x2000 },

-  { 0x1a00, 0x3238, 0x0000 },

-  { 0x1a00, 0x323a, 0x0000 },

-  { 0x9a00, 0x323f, 0x3000 },

-  { 0x9a00, 0x323d, 0x2000 },

-  { 0x1a00, 0x323c, 0x0000 },

-  { 0x1a00, 0x323e, 0x0000 },

-  { 0x9a00, 0x3241, 0x2000 },

-  { 0x1a00, 0x3240, 0x0000 },

-  { 0x1a00, 0x3242, 0x0000 },

-  { 0x9a00, 0x326f, 0x6000 },

-  { 0x8f00, 0x325f, 0x5000 },

-  { 0x8f00, 0x3257, 0x4000 },

-  { 0x8f00, 0x3253, 0x3000 },

-  { 0x8f00, 0x3251, 0x2000 },

-  { 0x1a00, 0x3250, 0x0000 },

-  { 0x0f00, 0x3252, 0x0000 },

-  { 0x8f00, 0x3255, 0x2000 },

-  { 0x0f00, 0x3254, 0x0000 },

-  { 0x0f00, 0x3256, 0x0000 },

-  { 0x8f00, 0x325b, 0x3000 },

-  { 0x8f00, 0x3259, 0x2000 },

-  { 0x0f00, 0x3258, 0x0000 },

-  { 0x0f00, 0x325a, 0x0000 },

-  { 0x8f00, 0x325d, 0x2000 },

-  { 0x0f00, 0x325c, 0x0000 },

-  { 0x0f00, 0x325e, 0x0000 },

-  { 0x9a00, 0x3267, 0x4000 },

-  { 0x9a00, 0x3263, 0x3000 },

-  { 0x9a00, 0x3261, 0x2000 },

-  { 0x1a00, 0x3260, 0x0000 },

-  { 0x1a00, 0x3262, 0x0000 },

-  { 0x9a00, 0x3265, 0x2000 },

-  { 0x1a00, 0x3264, 0x0000 },

-  { 0x1a00, 0x3266, 0x0000 },

-  { 0x9a00, 0x326b, 0x3000 },

-  { 0x9a00, 0x3269, 0x2000 },

-  { 0x1a00, 0x3268, 0x0000 },

-  { 0x1a00, 0x326a, 0x0000 },

-  { 0x9a00, 0x326d, 0x2000 },

-  { 0x1a00, 0x326c, 0x0000 },

-  { 0x1a00, 0x326e, 0x0000 },

-  { 0x8f00, 0x3280, 0x5000 },

-  { 0x9a00, 0x3277, 0x4000 },

-  { 0x9a00, 0x3273, 0x3000 },

-  { 0x9a00, 0x3271, 0x2000 },

-  { 0x1a00, 0x3270, 0x0000 },

-  { 0x1a00, 0x3272, 0x0000 },

-  { 0x9a00, 0x3275, 0x2000 },

-  { 0x1a00, 0x3274, 0x0000 },

-  { 0x1a00, 0x3276, 0x0000 },

-  { 0x9a00, 0x327b, 0x3000 },

-  { 0x9a00, 0x3279, 0x2000 },

-  { 0x1a00, 0x3278, 0x0000 },

-  { 0x1a00, 0x327a, 0x0000 },

-  { 0x9a00, 0x327d, 0x2000 },

-  { 0x1a00, 0x327c, 0x0000 },

-  { 0x1a00, 0x327f, 0x0000 },

-  { 0x8f00, 0x3288, 0x4000 },

-  { 0x8f00, 0x3284, 0x3000 },

-  { 0x8f00, 0x3282, 0x2000 },

-  { 0x0f00, 0x3281, 0x0000 },

-  { 0x0f00, 0x3283, 0x0000 },

-  { 0x8f00, 0x3286, 0x2000 },

-  { 0x0f00, 0x3285, 0x0000 },

-  { 0x0f00, 0x3287, 0x0000 },

-  { 0x9a00, 0x328c, 0x3000 },

-  { 0x9a00, 0x328a, 0x2000 },

-  { 0x0f00, 0x3289, 0x0000 },

-  { 0x1a00, 0x328b, 0x0000 },

-  { 0x9a00, 0x328e, 0x2000 },

-  { 0x1a00, 0x328d, 0x0000 },

-  { 0x1a00, 0x328f, 0x0000 },

-  { 0x9a00, 0x3311, 0x8000 },

-  { 0x9a00, 0x32d0, 0x7000 },

-  { 0x9a00, 0x32b0, 0x6000 },

-  { 0x9a00, 0x32a0, 0x5000 },

-  { 0x9a00, 0x3298, 0x4000 },

-  { 0x9a00, 0x3294, 0x3000 },

-  { 0x9a00, 0x3292, 0x2000 },

-  { 0x1a00, 0x3291, 0x0000 },

-  { 0x1a00, 0x3293, 0x0000 },

-  { 0x9a00, 0x3296, 0x2000 },

-  { 0x1a00, 0x3295, 0x0000 },

-  { 0x1a00, 0x3297, 0x0000 },

-  { 0x9a00, 0x329c, 0x3000 },

-  { 0x9a00, 0x329a, 0x2000 },

-  { 0x1a00, 0x3299, 0x0000 },

-  { 0x1a00, 0x329b, 0x0000 },

-  { 0x9a00, 0x329e, 0x2000 },

-  { 0x1a00, 0x329d, 0x0000 },

-  { 0x1a00, 0x329f, 0x0000 },

-  { 0x9a00, 0x32a8, 0x4000 },

-  { 0x9a00, 0x32a4, 0x3000 },

-  { 0x9a00, 0x32a2, 0x2000 },

-  { 0x1a00, 0x32a1, 0x0000 },

-  { 0x1a00, 0x32a3, 0x0000 },

-  { 0x9a00, 0x32a6, 0x2000 },

-  { 0x1a00, 0x32a5, 0x0000 },

-  { 0x1a00, 0x32a7, 0x0000 },

-  { 0x9a00, 0x32ac, 0x3000 },

-  { 0x9a00, 0x32aa, 0x2000 },

-  { 0x1a00, 0x32a9, 0x0000 },

-  { 0x1a00, 0x32ab, 0x0000 },

-  { 0x9a00, 0x32ae, 0x2000 },

-  { 0x1a00, 0x32ad, 0x0000 },

-  { 0x1a00, 0x32af, 0x0000 },

-  { 0x9a00, 0x32c0, 0x5000 },

-  { 0x8f00, 0x32b8, 0x4000 },

-  { 0x8f00, 0x32b4, 0x3000 },

-  { 0x8f00, 0x32b2, 0x2000 },

-  { 0x0f00, 0x32b1, 0x0000 },

-  { 0x0f00, 0x32b3, 0x0000 },

-  { 0x8f00, 0x32b6, 0x2000 },

-  { 0x0f00, 0x32b5, 0x0000 },

-  { 0x0f00, 0x32b7, 0x0000 },

-  { 0x8f00, 0x32bc, 0x3000 },

-  { 0x8f00, 0x32ba, 0x2000 },

-  { 0x0f00, 0x32b9, 0x0000 },

-  { 0x0f00, 0x32bb, 0x0000 },

-  { 0x8f00, 0x32be, 0x2000 },

-  { 0x0f00, 0x32bd, 0x0000 },

-  { 0x0f00, 0x32bf, 0x0000 },

-  { 0x9a00, 0x32c8, 0x4000 },

-  { 0x9a00, 0x32c4, 0x3000 },

-  { 0x9a00, 0x32c2, 0x2000 },

-  { 0x1a00, 0x32c1, 0x0000 },

-  { 0x1a00, 0x32c3, 0x0000 },

-  { 0x9a00, 0x32c6, 0x2000 },

-  { 0x1a00, 0x32c5, 0x0000 },

-  { 0x1a00, 0x32c7, 0x0000 },

-  { 0x9a00, 0x32cc, 0x3000 },

-  { 0x9a00, 0x32ca, 0x2000 },

-  { 0x1a00, 0x32c9, 0x0000 },

-  { 0x1a00, 0x32cb, 0x0000 },

-  { 0x9a00, 0x32ce, 0x2000 },

-  { 0x1a00, 0x32cd, 0x0000 },

-  { 0x1a00, 0x32cf, 0x0000 },

-  { 0x9a00, 0x32f0, 0x6000 },

-  { 0x9a00, 0x32e0, 0x5000 },

-  { 0x9a00, 0x32d8, 0x4000 },

-  { 0x9a00, 0x32d4, 0x3000 },

-  { 0x9a00, 0x32d2, 0x2000 },

-  { 0x1a00, 0x32d1, 0x0000 },

-  { 0x1a00, 0x32d3, 0x0000 },

-  { 0x9a00, 0x32d6, 0x2000 },

-  { 0x1a00, 0x32d5, 0x0000 },

-  { 0x1a00, 0x32d7, 0x0000 },

-  { 0x9a00, 0x32dc, 0x3000 },

-  { 0x9a00, 0x32da, 0x2000 },

-  { 0x1a00, 0x32d9, 0x0000 },

-  { 0x1a00, 0x32db, 0x0000 },

-  { 0x9a00, 0x32de, 0x2000 },

-  { 0x1a00, 0x32dd, 0x0000 },

-  { 0x1a00, 0x32df, 0x0000 },

-  { 0x9a00, 0x32e8, 0x4000 },

-  { 0x9a00, 0x32e4, 0x3000 },

-  { 0x9a00, 0x32e2, 0x2000 },

-  { 0x1a00, 0x32e1, 0x0000 },

-  { 0x1a00, 0x32e3, 0x0000 },

-  { 0x9a00, 0x32e6, 0x2000 },

-  { 0x1a00, 0x32e5, 0x0000 },

-  { 0x1a00, 0x32e7, 0x0000 },

-  { 0x9a00, 0x32ec, 0x3000 },

-  { 0x9a00, 0x32ea, 0x2000 },

-  { 0x1a00, 0x32e9, 0x0000 },

-  { 0x1a00, 0x32eb, 0x0000 },

-  { 0x9a00, 0x32ee, 0x2000 },

-  { 0x1a00, 0x32ed, 0x0000 },

-  { 0x1a00, 0x32ef, 0x0000 },

-  { 0x9a00, 0x3301, 0x5000 },

-  { 0x9a00, 0x32f8, 0x4000 },

-  { 0x9a00, 0x32f4, 0x3000 },

-  { 0x9a00, 0x32f2, 0x2000 },

-  { 0x1a00, 0x32f1, 0x0000 },

-  { 0x1a00, 0x32f3, 0x0000 },

-  { 0x9a00, 0x32f6, 0x2000 },

-  { 0x1a00, 0x32f5, 0x0000 },

-  { 0x1a00, 0x32f7, 0x0000 },

-  { 0x9a00, 0x32fc, 0x3000 },

-  { 0x9a00, 0x32fa, 0x2000 },

-  { 0x1a00, 0x32f9, 0x0000 },

-  { 0x1a00, 0x32fb, 0x0000 },

-  { 0x9a00, 0x32fe, 0x2000 },

-  { 0x1a00, 0x32fd, 0x0000 },

-  { 0x1a00, 0x3300, 0x0000 },

-  { 0x9a00, 0x3309, 0x4000 },

-  { 0x9a00, 0x3305, 0x3000 },

-  { 0x9a00, 0x3303, 0x2000 },

-  { 0x1a00, 0x3302, 0x0000 },

-  { 0x1a00, 0x3304, 0x0000 },

-  { 0x9a00, 0x3307, 0x2000 },

-  { 0x1a00, 0x3306, 0x0000 },

-  { 0x1a00, 0x3308, 0x0000 },

-  { 0x9a00, 0x330d, 0x3000 },

-  { 0x9a00, 0x330b, 0x2000 },

-  { 0x1a00, 0x330a, 0x0000 },

-  { 0x1a00, 0x330c, 0x0000 },

-  { 0x9a00, 0x330f, 0x2000 },

-  { 0x1a00, 0x330e, 0x0000 },

-  { 0x1a00, 0x3310, 0x0000 },

-  { 0x9a00, 0x3351, 0x7000 },

-  { 0x9a00, 0x3331, 0x6000 },

-  { 0x9a00, 0x3321, 0x5000 },

-  { 0x9a00, 0x3319, 0x4000 },

-  { 0x9a00, 0x3315, 0x3000 },

-  { 0x9a00, 0x3313, 0x2000 },

-  { 0x1a00, 0x3312, 0x0000 },

-  { 0x1a00, 0x3314, 0x0000 },

-  { 0x9a00, 0x3317, 0x2000 },

-  { 0x1a00, 0x3316, 0x0000 },

-  { 0x1a00, 0x3318, 0x0000 },

-  { 0x9a00, 0x331d, 0x3000 },

-  { 0x9a00, 0x331b, 0x2000 },

-  { 0x1a00, 0x331a, 0x0000 },

-  { 0x1a00, 0x331c, 0x0000 },

-  { 0x9a00, 0x331f, 0x2000 },

-  { 0x1a00, 0x331e, 0x0000 },

-  { 0x1a00, 0x3320, 0x0000 },

-  { 0x9a00, 0x3329, 0x4000 },

-  { 0x9a00, 0x3325, 0x3000 },

-  { 0x9a00, 0x3323, 0x2000 },

-  { 0x1a00, 0x3322, 0x0000 },

-  { 0x1a00, 0x3324, 0x0000 },

-  { 0x9a00, 0x3327, 0x2000 },

-  { 0x1a00, 0x3326, 0x0000 },

-  { 0x1a00, 0x3328, 0x0000 },

-  { 0x9a00, 0x332d, 0x3000 },

-  { 0x9a00, 0x332b, 0x2000 },

-  { 0x1a00, 0x332a, 0x0000 },

-  { 0x1a00, 0x332c, 0x0000 },

-  { 0x9a00, 0x332f, 0x2000 },

-  { 0x1a00, 0x332e, 0x0000 },

-  { 0x1a00, 0x3330, 0x0000 },

-  { 0x9a00, 0x3341, 0x5000 },

-  { 0x9a00, 0x3339, 0x4000 },

-  { 0x9a00, 0x3335, 0x3000 },

-  { 0x9a00, 0x3333, 0x2000 },

-  { 0x1a00, 0x3332, 0x0000 },

-  { 0x1a00, 0x3334, 0x0000 },

-  { 0x9a00, 0x3337, 0x2000 },

-  { 0x1a00, 0x3336, 0x0000 },

-  { 0x1a00, 0x3338, 0x0000 },

-  { 0x9a00, 0x333d, 0x3000 },

-  { 0x9a00, 0x333b, 0x2000 },

-  { 0x1a00, 0x333a, 0x0000 },

-  { 0x1a00, 0x333c, 0x0000 },

-  { 0x9a00, 0x333f, 0x2000 },

-  { 0x1a00, 0x333e, 0x0000 },

-  { 0x1a00, 0x3340, 0x0000 },

-  { 0x9a00, 0x3349, 0x4000 },

-  { 0x9a00, 0x3345, 0x3000 },

-  { 0x9a00, 0x3343, 0x2000 },

-  { 0x1a00, 0x3342, 0x0000 },

-  { 0x1a00, 0x3344, 0x0000 },

-  { 0x9a00, 0x3347, 0x2000 },

-  { 0x1a00, 0x3346, 0x0000 },

-  { 0x1a00, 0x3348, 0x0000 },

-  { 0x9a00, 0x334d, 0x3000 },

-  { 0x9a00, 0x334b, 0x2000 },

-  { 0x1a00, 0x334a, 0x0000 },

-  { 0x1a00, 0x334c, 0x0000 },

-  { 0x9a00, 0x334f, 0x2000 },

-  { 0x1a00, 0x334e, 0x0000 },

-  { 0x1a00, 0x3350, 0x0000 },

-  { 0x9a00, 0x3371, 0x6000 },

-  { 0x9a00, 0x3361, 0x5000 },

-  { 0x9a00, 0x3359, 0x4000 },

-  { 0x9a00, 0x3355, 0x3000 },

-  { 0x9a00, 0x3353, 0x2000 },

-  { 0x1a00, 0x3352, 0x0000 },

-  { 0x1a00, 0x3354, 0x0000 },

-  { 0x9a00, 0x3357, 0x2000 },

-  { 0x1a00, 0x3356, 0x0000 },

-  { 0x1a00, 0x3358, 0x0000 },

-  { 0x9a00, 0x335d, 0x3000 },

-  { 0x9a00, 0x335b, 0x2000 },

-  { 0x1a00, 0x335a, 0x0000 },

-  { 0x1a00, 0x335c, 0x0000 },

-  { 0x9a00, 0x335f, 0x2000 },

-  { 0x1a00, 0x335e, 0x0000 },

-  { 0x1a00, 0x3360, 0x0000 },

-  { 0x9a00, 0x3369, 0x4000 },

-  { 0x9a00, 0x3365, 0x3000 },

-  { 0x9a00, 0x3363, 0x2000 },

-  { 0x1a00, 0x3362, 0x0000 },

-  { 0x1a00, 0x3364, 0x0000 },

-  { 0x9a00, 0x3367, 0x2000 },

-  { 0x1a00, 0x3366, 0x0000 },

-  { 0x1a00, 0x3368, 0x0000 },

-  { 0x9a00, 0x336d, 0x3000 },

-  { 0x9a00, 0x336b, 0x2000 },

-  { 0x1a00, 0x336a, 0x0000 },

-  { 0x1a00, 0x336c, 0x0000 },

-  { 0x9a00, 0x336f, 0x2000 },

-  { 0x1a00, 0x336e, 0x0000 },

-  { 0x1a00, 0x3370, 0x0000 },

-  { 0x9a00, 0x3381, 0x5000 },

-  { 0x9a00, 0x3379, 0x4000 },

-  { 0x9a00, 0x3375, 0x3000 },

-  { 0x9a00, 0x3373, 0x2000 },

-  { 0x1a00, 0x3372, 0x0000 },

-  { 0x1a00, 0x3374, 0x0000 },

-  { 0x9a00, 0x3377, 0x2000 },

-  { 0x1a00, 0x3376, 0x0000 },

-  { 0x1a00, 0x3378, 0x0000 },

-  { 0x9a00, 0x337d, 0x3000 },

-  { 0x9a00, 0x337b, 0x2000 },

-  { 0x1a00, 0x337a, 0x0000 },

-  { 0x1a00, 0x337c, 0x0000 },

-  { 0x9a00, 0x337f, 0x2000 },

-  { 0x1a00, 0x337e, 0x0000 },

-  { 0x1a00, 0x3380, 0x0000 },

-  { 0x9a00, 0x3389, 0x4000 },

-  { 0x9a00, 0x3385, 0x3000 },

-  { 0x9a00, 0x3383, 0x2000 },

-  { 0x1a00, 0x3382, 0x0000 },

-  { 0x1a00, 0x3384, 0x0000 },

-  { 0x9a00, 0x3387, 0x2000 },

-  { 0x1a00, 0x3386, 0x0000 },

-  { 0x1a00, 0x3388, 0x0000 },

-  { 0x9a00, 0x338d, 0x3000 },

-  { 0x9a00, 0x338b, 0x2000 },

-  { 0x1a00, 0x338a, 0x0000 },

-  { 0x1a00, 0x338c, 0x0000 },

-  { 0x9a00, 0x338f, 0x2000 },

-  { 0x1a00, 0x338e, 0x0000 },

-  { 0x1a00, 0x3390, 0x0000 },

-  { 0x8700, 0xa14d, 0xa000 },

-  { 0x8700, 0xa04d, 0x9000 },

-  { 0x9a00, 0x4dcf, 0x8000 },

-  { 0x9a00, 0x33d1, 0x7000 },

-  { 0x9a00, 0x33b1, 0x6000 },

-  { 0x9a00, 0x33a1, 0x5000 },

-  { 0x9a00, 0x3399, 0x4000 },

-  { 0x9a00, 0x3395, 0x3000 },

-  { 0x9a00, 0x3393, 0x2000 },

-  { 0x1a00, 0x3392, 0x0000 },

-  { 0x1a00, 0x3394, 0x0000 },

-  { 0x9a00, 0x3397, 0x2000 },

-  { 0x1a00, 0x3396, 0x0000 },

-  { 0x1a00, 0x3398, 0x0000 },

-  { 0x9a00, 0x339d, 0x3000 },

-  { 0x9a00, 0x339b, 0x2000 },

-  { 0x1a00, 0x339a, 0x0000 },

-  { 0x1a00, 0x339c, 0x0000 },

-  { 0x9a00, 0x339f, 0x2000 },

-  { 0x1a00, 0x339e, 0x0000 },

-  { 0x1a00, 0x33a0, 0x0000 },

-  { 0x9a00, 0x33a9, 0x4000 },

-  { 0x9a00, 0x33a5, 0x3000 },

-  { 0x9a00, 0x33a3, 0x2000 },

-  { 0x1a00, 0x33a2, 0x0000 },

-  { 0x1a00, 0x33a4, 0x0000 },

-  { 0x9a00, 0x33a7, 0x2000 },

-  { 0x1a00, 0x33a6, 0x0000 },

-  { 0x1a00, 0x33a8, 0x0000 },

-  { 0x9a00, 0x33ad, 0x3000 },

-  { 0x9a00, 0x33ab, 0x2000 },

-  { 0x1a00, 0x33aa, 0x0000 },

-  { 0x1a00, 0x33ac, 0x0000 },

-  { 0x9a00, 0x33af, 0x2000 },

-  { 0x1a00, 0x33ae, 0x0000 },

-  { 0x1a00, 0x33b0, 0x0000 },

-  { 0x9a00, 0x33c1, 0x5000 },

-  { 0x9a00, 0x33b9, 0x4000 },

-  { 0x9a00, 0x33b5, 0x3000 },

-  { 0x9a00, 0x33b3, 0x2000 },

-  { 0x1a00, 0x33b2, 0x0000 },

-  { 0x1a00, 0x33b4, 0x0000 },

-  { 0x9a00, 0x33b7, 0x2000 },

-  { 0x1a00, 0x33b6, 0x0000 },

-  { 0x1a00, 0x33b8, 0x0000 },

-  { 0x9a00, 0x33bd, 0x3000 },

-  { 0x9a00, 0x33bb, 0x2000 },

-  { 0x1a00, 0x33ba, 0x0000 },

-  { 0x1a00, 0x33bc, 0x0000 },

-  { 0x9a00, 0x33bf, 0x2000 },

-  { 0x1a00, 0x33be, 0x0000 },

-  { 0x1a00, 0x33c0, 0x0000 },

-  { 0x9a00, 0x33c9, 0x4000 },

-  { 0x9a00, 0x33c5, 0x3000 },

-  { 0x9a00, 0x33c3, 0x2000 },

-  { 0x1a00, 0x33c2, 0x0000 },

-  { 0x1a00, 0x33c4, 0x0000 },

-  { 0x9a00, 0x33c7, 0x2000 },

-  { 0x1a00, 0x33c6, 0x0000 },

-  { 0x1a00, 0x33c8, 0x0000 },

-  { 0x9a00, 0x33cd, 0x3000 },

-  { 0x9a00, 0x33cb, 0x2000 },

-  { 0x1a00, 0x33ca, 0x0000 },

-  { 0x1a00, 0x33cc, 0x0000 },

-  { 0x9a00, 0x33cf, 0x2000 },

-  { 0x1a00, 0x33ce, 0x0000 },

-  { 0x1a00, 0x33d0, 0x0000 },

-  { 0x9a00, 0x33f1, 0x6000 },

-  { 0x9a00, 0x33e1, 0x5000 },

-  { 0x9a00, 0x33d9, 0x4000 },

-  { 0x9a00, 0x33d5, 0x3000 },

-  { 0x9a00, 0x33d3, 0x2000 },

-  { 0x1a00, 0x33d2, 0x0000 },

-  { 0x1a00, 0x33d4, 0x0000 },

-  { 0x9a00, 0x33d7, 0x2000 },

-  { 0x1a00, 0x33d6, 0x0000 },

-  { 0x1a00, 0x33d8, 0x0000 },

-  { 0x9a00, 0x33dd, 0x3000 },

-  { 0x9a00, 0x33db, 0x2000 },

-  { 0x1a00, 0x33da, 0x0000 },

-  { 0x1a00, 0x33dc, 0x0000 },

-  { 0x9a00, 0x33df, 0x2000 },

-  { 0x1a00, 0x33de, 0x0000 },

-  { 0x1a00, 0x33e0, 0x0000 },

-  { 0x9a00, 0x33e9, 0x4000 },

-  { 0x9a00, 0x33e5, 0x3000 },

-  { 0x9a00, 0x33e3, 0x2000 },

-  { 0x1a00, 0x33e2, 0x0000 },

-  { 0x1a00, 0x33e4, 0x0000 },

-  { 0x9a00, 0x33e7, 0x2000 },

-  { 0x1a00, 0x33e6, 0x0000 },

-  { 0x1a00, 0x33e8, 0x0000 },

-  { 0x9a00, 0x33ed, 0x3000 },

-  { 0x9a00, 0x33eb, 0x2000 },

-  { 0x1a00, 0x33ea, 0x0000 },

-  { 0x1a00, 0x33ec, 0x0000 },

-  { 0x9a00, 0x33ef, 0x2000 },

-  { 0x1a00, 0x33ee, 0x0000 },

-  { 0x1a00, 0x33f0, 0x0000 },

-  { 0x8700, 0x4db5, 0x5000 },

-  { 0x9a00, 0x33f9, 0x4000 },

-  { 0x9a00, 0x33f5, 0x3000 },

-  { 0x9a00, 0x33f3, 0x2000 },

-  { 0x1a00, 0x33f2, 0x0000 },

-  { 0x1a00, 0x33f4, 0x0000 },

-  { 0x9a00, 0x33f7, 0x2000 },

-  { 0x1a00, 0x33f6, 0x0000 },

-  { 0x1a00, 0x33f8, 0x0000 },

-  { 0x9a00, 0x33fd, 0x3000 },

-  { 0x9a00, 0x33fb, 0x2000 },

-  { 0x1a00, 0x33fa, 0x0000 },

-  { 0x1a00, 0x33fc, 0x0000 },

-  { 0x9a00, 0x33ff, 0x2000 },

-  { 0x1a00, 0x33fe, 0x0000 },

-  { 0x0700, 0x3400, 0x0000 },

-  { 0x9a00, 0x4dc7, 0x4000 },

-  { 0x9a00, 0x4dc3, 0x3000 },

-  { 0x9a00, 0x4dc1, 0x2000 },

-  { 0x1a00, 0x4dc0, 0x0000 },

-  { 0x1a00, 0x4dc2, 0x0000 },

-  { 0x9a00, 0x4dc5, 0x2000 },

-  { 0x1a00, 0x4dc4, 0x0000 },

-  { 0x1a00, 0x4dc6, 0x0000 },

-  { 0x9a00, 0x4dcb, 0x3000 },

-  { 0x9a00, 0x4dc9, 0x2000 },

-  { 0x1a00, 0x4dc8, 0x0000 },

-  { 0x1a00, 0x4dca, 0x0000 },

-  { 0x9a00, 0x4dcd, 0x2000 },

-  { 0x1a00, 0x4dcc, 0x0000 },

-  { 0x1a00, 0x4dce, 0x0000 },

-  { 0x8700, 0xa00d, 0x7000 },

-  { 0x9a00, 0x4def, 0x6000 },

-  { 0x9a00, 0x4ddf, 0x5000 },

-  { 0x9a00, 0x4dd7, 0x4000 },

-  { 0x9a00, 0x4dd3, 0x3000 },

-  { 0x9a00, 0x4dd1, 0x2000 },

-  { 0x1a00, 0x4dd0, 0x0000 },

-  { 0x1a00, 0x4dd2, 0x0000 },

-  { 0x9a00, 0x4dd5, 0x2000 },

-  { 0x1a00, 0x4dd4, 0x0000 },

-  { 0x1a00, 0x4dd6, 0x0000 },

-  { 0x9a00, 0x4ddb, 0x3000 },

-  { 0x9a00, 0x4dd9, 0x2000 },

-  { 0x1a00, 0x4dd8, 0x0000 },

-  { 0x1a00, 0x4dda, 0x0000 },

-  { 0x9a00, 0x4ddd, 0x2000 },

-  { 0x1a00, 0x4ddc, 0x0000 },

-  { 0x1a00, 0x4dde, 0x0000 },

-  { 0x9a00, 0x4de7, 0x4000 },

-  { 0x9a00, 0x4de3, 0x3000 },

-  { 0x9a00, 0x4de1, 0x2000 },

-  { 0x1a00, 0x4de0, 0x0000 },

-  { 0x1a00, 0x4de2, 0x0000 },

-  { 0x9a00, 0x4de5, 0x2000 },

-  { 0x1a00, 0x4de4, 0x0000 },

-  { 0x1a00, 0x4de6, 0x0000 },

-  { 0x9a00, 0x4deb, 0x3000 },

-  { 0x9a00, 0x4de9, 0x2000 },

-  { 0x1a00, 0x4de8, 0x0000 },

-  { 0x1a00, 0x4dea, 0x0000 },

-  { 0x9a00, 0x4ded, 0x2000 },

-  { 0x1a00, 0x4dec, 0x0000 },

-  { 0x1a00, 0x4dee, 0x0000 },

-  { 0x9a00, 0x4dff, 0x5000 },

-  { 0x9a00, 0x4df7, 0x4000 },

-  { 0x9a00, 0x4df3, 0x3000 },

-  { 0x9a00, 0x4df1, 0x2000 },

-  { 0x1a00, 0x4df0, 0x0000 },

-  { 0x1a00, 0x4df2, 0x0000 },

-  { 0x9a00, 0x4df5, 0x2000 },

-  { 0x1a00, 0x4df4, 0x0000 },

-  { 0x1a00, 0x4df6, 0x0000 },

-  { 0x9a00, 0x4dfb, 0x3000 },

-  { 0x9a00, 0x4df9, 0x2000 },

-  { 0x1a00, 0x4df8, 0x0000 },

-  { 0x1a00, 0x4dfa, 0x0000 },

-  { 0x9a00, 0x4dfd, 0x2000 },

-  { 0x1a00, 0x4dfc, 0x0000 },

-  { 0x1a00, 0x4dfe, 0x0000 },

-  { 0x8700, 0xa005, 0x4000 },

-  { 0x8700, 0xa001, 0x3000 },

-  { 0x8700, 0x9fa5, 0x2000 },

-  { 0x0700, 0x4e00, 0x0000 },

-  { 0x0700, 0xa000, 0x0000 },

-  { 0x8700, 0xa003, 0x2000 },

-  { 0x0700, 0xa002, 0x0000 },

-  { 0x0700, 0xa004, 0x0000 },

-  { 0x8700, 0xa009, 0x3000 },

-  { 0x8700, 0xa007, 0x2000 },

-  { 0x0700, 0xa006, 0x0000 },

-  { 0x0700, 0xa008, 0x0000 },

-  { 0x8700, 0xa00b, 0x2000 },

-  { 0x0700, 0xa00a, 0x0000 },

-  { 0x0700, 0xa00c, 0x0000 },

-  { 0x8700, 0xa02d, 0x6000 },

-  { 0x8700, 0xa01d, 0x5000 },

-  { 0x8700, 0xa015, 0x4000 },

-  { 0x8700, 0xa011, 0x3000 },

-  { 0x8700, 0xa00f, 0x2000 },

-  { 0x0700, 0xa00e, 0x0000 },

-  { 0x0700, 0xa010, 0x0000 },

-  { 0x8700, 0xa013, 0x2000 },

-  { 0x0700, 0xa012, 0x0000 },

-  { 0x0700, 0xa014, 0x0000 },

-  { 0x8700, 0xa019, 0x3000 },

-  { 0x8700, 0xa017, 0x2000 },

-  { 0x0700, 0xa016, 0x0000 },

-  { 0x0700, 0xa018, 0x0000 },

-  { 0x8700, 0xa01b, 0x2000 },

-  { 0x0700, 0xa01a, 0x0000 },

-  { 0x0700, 0xa01c, 0x0000 },

-  { 0x8700, 0xa025, 0x4000 },

-  { 0x8700, 0xa021, 0x3000 },

-  { 0x8700, 0xa01f, 0x2000 },

-  { 0x0700, 0xa01e, 0x0000 },

-  { 0x0700, 0xa020, 0x0000 },

-  { 0x8700, 0xa023, 0x2000 },

-  { 0x0700, 0xa022, 0x0000 },

-  { 0x0700, 0xa024, 0x0000 },

-  { 0x8700, 0xa029, 0x3000 },

-  { 0x8700, 0xa027, 0x2000 },

-  { 0x0700, 0xa026, 0x0000 },

-  { 0x0700, 0xa028, 0x0000 },

-  { 0x8700, 0xa02b, 0x2000 },

-  { 0x0700, 0xa02a, 0x0000 },

-  { 0x0700, 0xa02c, 0x0000 },

-  { 0x8700, 0xa03d, 0x5000 },

-  { 0x8700, 0xa035, 0x4000 },

-  { 0x8700, 0xa031, 0x3000 },

-  { 0x8700, 0xa02f, 0x2000 },

-  { 0x0700, 0xa02e, 0x0000 },

-  { 0x0700, 0xa030, 0x0000 },

-  { 0x8700, 0xa033, 0x2000 },

-  { 0x0700, 0xa032, 0x0000 },

-  { 0x0700, 0xa034, 0x0000 },

-  { 0x8700, 0xa039, 0x3000 },

-  { 0x8700, 0xa037, 0x2000 },

-  { 0x0700, 0xa036, 0x0000 },

-  { 0x0700, 0xa038, 0x0000 },

-  { 0x8700, 0xa03b, 0x2000 },

-  { 0x0700, 0xa03a, 0x0000 },

-  { 0x0700, 0xa03c, 0x0000 },

-  { 0x8700, 0xa045, 0x4000 },

-  { 0x8700, 0xa041, 0x3000 },

-  { 0x8700, 0xa03f, 0x2000 },

-  { 0x0700, 0xa03e, 0x0000 },

-  { 0x0700, 0xa040, 0x0000 },

-  { 0x8700, 0xa043, 0x2000 },

-  { 0x0700, 0xa042, 0x0000 },

-  { 0x0700, 0xa044, 0x0000 },

-  { 0x8700, 0xa049, 0x3000 },

-  { 0x8700, 0xa047, 0x2000 },

-  { 0x0700, 0xa046, 0x0000 },

-  { 0x0700, 0xa048, 0x0000 },

-  { 0x8700, 0xa04b, 0x2000 },

-  { 0x0700, 0xa04a, 0x0000 },

-  { 0x0700, 0xa04c, 0x0000 },

-  { 0x8700, 0xa0cd, 0x8000 },

-  { 0x8700, 0xa08d, 0x7000 },

-  { 0x8700, 0xa06d, 0x6000 },

-  { 0x8700, 0xa05d, 0x5000 },

-  { 0x8700, 0xa055, 0x4000 },

-  { 0x8700, 0xa051, 0x3000 },

-  { 0x8700, 0xa04f, 0x2000 },

-  { 0x0700, 0xa04e, 0x0000 },

-  { 0x0700, 0xa050, 0x0000 },

-  { 0x8700, 0xa053, 0x2000 },

-  { 0x0700, 0xa052, 0x0000 },

-  { 0x0700, 0xa054, 0x0000 },

-  { 0x8700, 0xa059, 0x3000 },

-  { 0x8700, 0xa057, 0x2000 },

-  { 0x0700, 0xa056, 0x0000 },

-  { 0x0700, 0xa058, 0x0000 },

-  { 0x8700, 0xa05b, 0x2000 },

-  { 0x0700, 0xa05a, 0x0000 },

-  { 0x0700, 0xa05c, 0x0000 },

-  { 0x8700, 0xa065, 0x4000 },

-  { 0x8700, 0xa061, 0x3000 },

-  { 0x8700, 0xa05f, 0x2000 },

-  { 0x0700, 0xa05e, 0x0000 },

-  { 0x0700, 0xa060, 0x0000 },

-  { 0x8700, 0xa063, 0x2000 },

-  { 0x0700, 0xa062, 0x0000 },

-  { 0x0700, 0xa064, 0x0000 },

-  { 0x8700, 0xa069, 0x3000 },

-  { 0x8700, 0xa067, 0x2000 },

-  { 0x0700, 0xa066, 0x0000 },

-  { 0x0700, 0xa068, 0x0000 },

-  { 0x8700, 0xa06b, 0x2000 },

-  { 0x0700, 0xa06a, 0x0000 },

-  { 0x0700, 0xa06c, 0x0000 },

-  { 0x8700, 0xa07d, 0x5000 },

-  { 0x8700, 0xa075, 0x4000 },

-  { 0x8700, 0xa071, 0x3000 },

-  { 0x8700, 0xa06f, 0x2000 },

-  { 0x0700, 0xa06e, 0x0000 },

-  { 0x0700, 0xa070, 0x0000 },

-  { 0x8700, 0xa073, 0x2000 },

-  { 0x0700, 0xa072, 0x0000 },

-  { 0x0700, 0xa074, 0x0000 },

-  { 0x8700, 0xa079, 0x3000 },

-  { 0x8700, 0xa077, 0x2000 },

-  { 0x0700, 0xa076, 0x0000 },

-  { 0x0700, 0xa078, 0x0000 },

-  { 0x8700, 0xa07b, 0x2000 },

-  { 0x0700, 0xa07a, 0x0000 },

-  { 0x0700, 0xa07c, 0x0000 },

-  { 0x8700, 0xa085, 0x4000 },

-  { 0x8700, 0xa081, 0x3000 },

-  { 0x8700, 0xa07f, 0x2000 },

-  { 0x0700, 0xa07e, 0x0000 },

-  { 0x0700, 0xa080, 0x0000 },

-  { 0x8700, 0xa083, 0x2000 },

-  { 0x0700, 0xa082, 0x0000 },

-  { 0x0700, 0xa084, 0x0000 },

-  { 0x8700, 0xa089, 0x3000 },

-  { 0x8700, 0xa087, 0x2000 },

-  { 0x0700, 0xa086, 0x0000 },

-  { 0x0700, 0xa088, 0x0000 },

-  { 0x8700, 0xa08b, 0x2000 },

-  { 0x0700, 0xa08a, 0x0000 },

-  { 0x0700, 0xa08c, 0x0000 },

-  { 0x8700, 0xa0ad, 0x6000 },

-  { 0x8700, 0xa09d, 0x5000 },

-  { 0x8700, 0xa095, 0x4000 },

-  { 0x8700, 0xa091, 0x3000 },

-  { 0x8700, 0xa08f, 0x2000 },

-  { 0x0700, 0xa08e, 0x0000 },

-  { 0x0700, 0xa090, 0x0000 },

-  { 0x8700, 0xa093, 0x2000 },

-  { 0x0700, 0xa092, 0x0000 },

-  { 0x0700, 0xa094, 0x0000 },

-  { 0x8700, 0xa099, 0x3000 },

-  { 0x8700, 0xa097, 0x2000 },

-  { 0x0700, 0xa096, 0x0000 },

-  { 0x0700, 0xa098, 0x0000 },

-  { 0x8700, 0xa09b, 0x2000 },

-  { 0x0700, 0xa09a, 0x0000 },

-  { 0x0700, 0xa09c, 0x0000 },

-  { 0x8700, 0xa0a5, 0x4000 },

-  { 0x8700, 0xa0a1, 0x3000 },

-  { 0x8700, 0xa09f, 0x2000 },

-  { 0x0700, 0xa09e, 0x0000 },

-  { 0x0700, 0xa0a0, 0x0000 },

-  { 0x8700, 0xa0a3, 0x2000 },

-  { 0x0700, 0xa0a2, 0x0000 },

-  { 0x0700, 0xa0a4, 0x0000 },

-  { 0x8700, 0xa0a9, 0x3000 },

-  { 0x8700, 0xa0a7, 0x2000 },

-  { 0x0700, 0xa0a6, 0x0000 },

-  { 0x0700, 0xa0a8, 0x0000 },

-  { 0x8700, 0xa0ab, 0x2000 },

-  { 0x0700, 0xa0aa, 0x0000 },

-  { 0x0700, 0xa0ac, 0x0000 },

-  { 0x8700, 0xa0bd, 0x5000 },

-  { 0x8700, 0xa0b5, 0x4000 },

-  { 0x8700, 0xa0b1, 0x3000 },

-  { 0x8700, 0xa0af, 0x2000 },

-  { 0x0700, 0xa0ae, 0x0000 },

-  { 0x0700, 0xa0b0, 0x0000 },

-  { 0x8700, 0xa0b3, 0x2000 },

-  { 0x0700, 0xa0b2, 0x0000 },

-  { 0x0700, 0xa0b4, 0x0000 },

-  { 0x8700, 0xa0b9, 0x3000 },

-  { 0x8700, 0xa0b7, 0x2000 },

-  { 0x0700, 0xa0b6, 0x0000 },

-  { 0x0700, 0xa0b8, 0x0000 },

-  { 0x8700, 0xa0bb, 0x2000 },

-  { 0x0700, 0xa0ba, 0x0000 },

-  { 0x0700, 0xa0bc, 0x0000 },

-  { 0x8700, 0xa0c5, 0x4000 },

-  { 0x8700, 0xa0c1, 0x3000 },

-  { 0x8700, 0xa0bf, 0x2000 },

-  { 0x0700, 0xa0be, 0x0000 },

-  { 0x0700, 0xa0c0, 0x0000 },

-  { 0x8700, 0xa0c3, 0x2000 },

-  { 0x0700, 0xa0c2, 0x0000 },

-  { 0x0700, 0xa0c4, 0x0000 },

-  { 0x8700, 0xa0c9, 0x3000 },

-  { 0x8700, 0xa0c7, 0x2000 },

-  { 0x0700, 0xa0c6, 0x0000 },

-  { 0x0700, 0xa0c8, 0x0000 },

-  { 0x8700, 0xa0cb, 0x2000 },

-  { 0x0700, 0xa0ca, 0x0000 },

-  { 0x0700, 0xa0cc, 0x0000 },

-  { 0x8700, 0xa10d, 0x7000 },

-  { 0x8700, 0xa0ed, 0x6000 },

-  { 0x8700, 0xa0dd, 0x5000 },

-  { 0x8700, 0xa0d5, 0x4000 },

-  { 0x8700, 0xa0d1, 0x3000 },

-  { 0x8700, 0xa0cf, 0x2000 },

-  { 0x0700, 0xa0ce, 0x0000 },

-  { 0x0700, 0xa0d0, 0x0000 },

-  { 0x8700, 0xa0d3, 0x2000 },

-  { 0x0700, 0xa0d2, 0x0000 },

-  { 0x0700, 0xa0d4, 0x0000 },

-  { 0x8700, 0xa0d9, 0x3000 },

-  { 0x8700, 0xa0d7, 0x2000 },

-  { 0x0700, 0xa0d6, 0x0000 },

-  { 0x0700, 0xa0d8, 0x0000 },

-  { 0x8700, 0xa0db, 0x2000 },

-  { 0x0700, 0xa0da, 0x0000 },

-  { 0x0700, 0xa0dc, 0x0000 },

-  { 0x8700, 0xa0e5, 0x4000 },

-  { 0x8700, 0xa0e1, 0x3000 },

-  { 0x8700, 0xa0df, 0x2000 },

-  { 0x0700, 0xa0de, 0x0000 },

-  { 0x0700, 0xa0e0, 0x0000 },

-  { 0x8700, 0xa0e3, 0x2000 },

-  { 0x0700, 0xa0e2, 0x0000 },

-  { 0x0700, 0xa0e4, 0x0000 },

-  { 0x8700, 0xa0e9, 0x3000 },

-  { 0x8700, 0xa0e7, 0x2000 },

-  { 0x0700, 0xa0e6, 0x0000 },

-  { 0x0700, 0xa0e8, 0x0000 },

-  { 0x8700, 0xa0eb, 0x2000 },

-  { 0x0700, 0xa0ea, 0x0000 },

-  { 0x0700, 0xa0ec, 0x0000 },

-  { 0x8700, 0xa0fd, 0x5000 },

-  { 0x8700, 0xa0f5, 0x4000 },

-  { 0x8700, 0xa0f1, 0x3000 },

-  { 0x8700, 0xa0ef, 0x2000 },

-  { 0x0700, 0xa0ee, 0x0000 },

-  { 0x0700, 0xa0f0, 0x0000 },

-  { 0x8700, 0xa0f3, 0x2000 },

-  { 0x0700, 0xa0f2, 0x0000 },

-  { 0x0700, 0xa0f4, 0x0000 },

-  { 0x8700, 0xa0f9, 0x3000 },

-  { 0x8700, 0xa0f7, 0x2000 },

-  { 0x0700, 0xa0f6, 0x0000 },

-  { 0x0700, 0xa0f8, 0x0000 },

-  { 0x8700, 0xa0fb, 0x2000 },

-  { 0x0700, 0xa0fa, 0x0000 },

-  { 0x0700, 0xa0fc, 0x0000 },

-  { 0x8700, 0xa105, 0x4000 },

-  { 0x8700, 0xa101, 0x3000 },

-  { 0x8700, 0xa0ff, 0x2000 },

-  { 0x0700, 0xa0fe, 0x0000 },

-  { 0x0700, 0xa100, 0x0000 },

-  { 0x8700, 0xa103, 0x2000 },

-  { 0x0700, 0xa102, 0x0000 },

-  { 0x0700, 0xa104, 0x0000 },

-  { 0x8700, 0xa109, 0x3000 },

-  { 0x8700, 0xa107, 0x2000 },

-  { 0x0700, 0xa106, 0x0000 },

-  { 0x0700, 0xa108, 0x0000 },

-  { 0x8700, 0xa10b, 0x2000 },

-  { 0x0700, 0xa10a, 0x0000 },

-  { 0x0700, 0xa10c, 0x0000 },

-  { 0x8700, 0xa12d, 0x6000 },

-  { 0x8700, 0xa11d, 0x5000 },

-  { 0x8700, 0xa115, 0x4000 },

-  { 0x8700, 0xa111, 0x3000 },

-  { 0x8700, 0xa10f, 0x2000 },

-  { 0x0700, 0xa10e, 0x0000 },

-  { 0x0700, 0xa110, 0x0000 },

-  { 0x8700, 0xa113, 0x2000 },

-  { 0x0700, 0xa112, 0x0000 },

-  { 0x0700, 0xa114, 0x0000 },

-  { 0x8700, 0xa119, 0x3000 },

-  { 0x8700, 0xa117, 0x2000 },

-  { 0x0700, 0xa116, 0x0000 },

-  { 0x0700, 0xa118, 0x0000 },

-  { 0x8700, 0xa11b, 0x2000 },

-  { 0x0700, 0xa11a, 0x0000 },

-  { 0x0700, 0xa11c, 0x0000 },

-  { 0x8700, 0xa125, 0x4000 },

-  { 0x8700, 0xa121, 0x3000 },

-  { 0x8700, 0xa11f, 0x2000 },

-  { 0x0700, 0xa11e, 0x0000 },

-  { 0x0700, 0xa120, 0x0000 },

-  { 0x8700, 0xa123, 0x2000 },

-  { 0x0700, 0xa122, 0x0000 },

-  { 0x0700, 0xa124, 0x0000 },

-  { 0x8700, 0xa129, 0x3000 },

-  { 0x8700, 0xa127, 0x2000 },

-  { 0x0700, 0xa126, 0x0000 },

-  { 0x0700, 0xa128, 0x0000 },

-  { 0x8700, 0xa12b, 0x2000 },

-  { 0x0700, 0xa12a, 0x0000 },

-  { 0x0700, 0xa12c, 0x0000 },

-  { 0x8700, 0xa13d, 0x5000 },

-  { 0x8700, 0xa135, 0x4000 },

-  { 0x8700, 0xa131, 0x3000 },

-  { 0x8700, 0xa12f, 0x2000 },

-  { 0x0700, 0xa12e, 0x0000 },

-  { 0x0700, 0xa130, 0x0000 },

-  { 0x8700, 0xa133, 0x2000 },

-  { 0x0700, 0xa132, 0x0000 },

-  { 0x0700, 0xa134, 0x0000 },

-  { 0x8700, 0xa139, 0x3000 },

-  { 0x8700, 0xa137, 0x2000 },

-  { 0x0700, 0xa136, 0x0000 },

-  { 0x0700, 0xa138, 0x0000 },

-  { 0x8700, 0xa13b, 0x2000 },

-  { 0x0700, 0xa13a, 0x0000 },

-  { 0x0700, 0xa13c, 0x0000 },

-  { 0x8700, 0xa145, 0x4000 },

-  { 0x8700, 0xa141, 0x3000 },

-  { 0x8700, 0xa13f, 0x2000 },

-  { 0x0700, 0xa13e, 0x0000 },

-  { 0x0700, 0xa140, 0x0000 },

-  { 0x8700, 0xa143, 0x2000 },

-  { 0x0700, 0xa142, 0x0000 },

-  { 0x0700, 0xa144, 0x0000 },

-  { 0x8700, 0xa149, 0x3000 },

-  { 0x8700, 0xa147, 0x2000 },

-  { 0x0700, 0xa146, 0x0000 },

-  { 0x0700, 0xa148, 0x0000 },

-  { 0x8700, 0xa14b, 0x2000 },

-  { 0x0700, 0xa14a, 0x0000 },

-  { 0x0700, 0xa14c, 0x0000 },

-  { 0x8700, 0xa24d, 0x9000 },

-  { 0x8700, 0xa1cd, 0x8000 },

-  { 0x8700, 0xa18d, 0x7000 },

-  { 0x8700, 0xa16d, 0x6000 },

-  { 0x8700, 0xa15d, 0x5000 },

-  { 0x8700, 0xa155, 0x4000 },

-  { 0x8700, 0xa151, 0x3000 },

-  { 0x8700, 0xa14f, 0x2000 },

-  { 0x0700, 0xa14e, 0x0000 },

-  { 0x0700, 0xa150, 0x0000 },

-  { 0x8700, 0xa153, 0x2000 },

-  { 0x0700, 0xa152, 0x0000 },

-  { 0x0700, 0xa154, 0x0000 },

-  { 0x8700, 0xa159, 0x3000 },

-  { 0x8700, 0xa157, 0x2000 },

-  { 0x0700, 0xa156, 0x0000 },

-  { 0x0700, 0xa158, 0x0000 },

-  { 0x8700, 0xa15b, 0x2000 },

-  { 0x0700, 0xa15a, 0x0000 },

-  { 0x0700, 0xa15c, 0x0000 },

-  { 0x8700, 0xa165, 0x4000 },

-  { 0x8700, 0xa161, 0x3000 },

-  { 0x8700, 0xa15f, 0x2000 },

-  { 0x0700, 0xa15e, 0x0000 },

-  { 0x0700, 0xa160, 0x0000 },

-  { 0x8700, 0xa163, 0x2000 },

-  { 0x0700, 0xa162, 0x0000 },

-  { 0x0700, 0xa164, 0x0000 },

-  { 0x8700, 0xa169, 0x3000 },

-  { 0x8700, 0xa167, 0x2000 },

-  { 0x0700, 0xa166, 0x0000 },

-  { 0x0700, 0xa168, 0x0000 },

-  { 0x8700, 0xa16b, 0x2000 },

-  { 0x0700, 0xa16a, 0x0000 },

-  { 0x0700, 0xa16c, 0x0000 },

-  { 0x8700, 0xa17d, 0x5000 },

-  { 0x8700, 0xa175, 0x4000 },

-  { 0x8700, 0xa171, 0x3000 },

-  { 0x8700, 0xa16f, 0x2000 },

-  { 0x0700, 0xa16e, 0x0000 },

-  { 0x0700, 0xa170, 0x0000 },

-  { 0x8700, 0xa173, 0x2000 },

-  { 0x0700, 0xa172, 0x0000 },

-  { 0x0700, 0xa174, 0x0000 },

-  { 0x8700, 0xa179, 0x3000 },

-  { 0x8700, 0xa177, 0x2000 },

-  { 0x0700, 0xa176, 0x0000 },

-  { 0x0700, 0xa178, 0x0000 },

-  { 0x8700, 0xa17b, 0x2000 },

-  { 0x0700, 0xa17a, 0x0000 },

-  { 0x0700, 0xa17c, 0x0000 },

-  { 0x8700, 0xa185, 0x4000 },

-  { 0x8700, 0xa181, 0x3000 },

-  { 0x8700, 0xa17f, 0x2000 },

-  { 0x0700, 0xa17e, 0x0000 },

-  { 0x0700, 0xa180, 0x0000 },

-  { 0x8700, 0xa183, 0x2000 },

-  { 0x0700, 0xa182, 0x0000 },

-  { 0x0700, 0xa184, 0x0000 },

-  { 0x8700, 0xa189, 0x3000 },

-  { 0x8700, 0xa187, 0x2000 },

-  { 0x0700, 0xa186, 0x0000 },

-  { 0x0700, 0xa188, 0x0000 },

-  { 0x8700, 0xa18b, 0x2000 },

-  { 0x0700, 0xa18a, 0x0000 },

-  { 0x0700, 0xa18c, 0x0000 },

-  { 0x8700, 0xa1ad, 0x6000 },

-  { 0x8700, 0xa19d, 0x5000 },

-  { 0x8700, 0xa195, 0x4000 },

-  { 0x8700, 0xa191, 0x3000 },

-  { 0x8700, 0xa18f, 0x2000 },

-  { 0x0700, 0xa18e, 0x0000 },

-  { 0x0700, 0xa190, 0x0000 },

-  { 0x8700, 0xa193, 0x2000 },

-  { 0x0700, 0xa192, 0x0000 },

-  { 0x0700, 0xa194, 0x0000 },

-  { 0x8700, 0xa199, 0x3000 },

-  { 0x8700, 0xa197, 0x2000 },

-  { 0x0700, 0xa196, 0x0000 },

-  { 0x0700, 0xa198, 0x0000 },

-  { 0x8700, 0xa19b, 0x2000 },

-  { 0x0700, 0xa19a, 0x0000 },

-  { 0x0700, 0xa19c, 0x0000 },

-  { 0x8700, 0xa1a5, 0x4000 },

-  { 0x8700, 0xa1a1, 0x3000 },

-  { 0x8700, 0xa19f, 0x2000 },

-  { 0x0700, 0xa19e, 0x0000 },

-  { 0x0700, 0xa1a0, 0x0000 },

-  { 0x8700, 0xa1a3, 0x2000 },

-  { 0x0700, 0xa1a2, 0x0000 },

-  { 0x0700, 0xa1a4, 0x0000 },

-  { 0x8700, 0xa1a9, 0x3000 },

-  { 0x8700, 0xa1a7, 0x2000 },

-  { 0x0700, 0xa1a6, 0x0000 },

-  { 0x0700, 0xa1a8, 0x0000 },

-  { 0x8700, 0xa1ab, 0x2000 },

-  { 0x0700, 0xa1aa, 0x0000 },

-  { 0x0700, 0xa1ac, 0x0000 },

-  { 0x8700, 0xa1bd, 0x5000 },

-  { 0x8700, 0xa1b5, 0x4000 },

-  { 0x8700, 0xa1b1, 0x3000 },

-  { 0x8700, 0xa1af, 0x2000 },

-  { 0x0700, 0xa1ae, 0x0000 },

-  { 0x0700, 0xa1b0, 0x0000 },

-  { 0x8700, 0xa1b3, 0x2000 },

-  { 0x0700, 0xa1b2, 0x0000 },

-  { 0x0700, 0xa1b4, 0x0000 },

-  { 0x8700, 0xa1b9, 0x3000 },

-  { 0x8700, 0xa1b7, 0x2000 },

-  { 0x0700, 0xa1b6, 0x0000 },

-  { 0x0700, 0xa1b8, 0x0000 },

-  { 0x8700, 0xa1bb, 0x2000 },

-  { 0x0700, 0xa1ba, 0x0000 },

-  { 0x0700, 0xa1bc, 0x0000 },

-  { 0x8700, 0xa1c5, 0x4000 },

-  { 0x8700, 0xa1c1, 0x3000 },

-  { 0x8700, 0xa1bf, 0x2000 },

-  { 0x0700, 0xa1be, 0x0000 },

-  { 0x0700, 0xa1c0, 0x0000 },

-  { 0x8700, 0xa1c3, 0x2000 },

-  { 0x0700, 0xa1c2, 0x0000 },

-  { 0x0700, 0xa1c4, 0x0000 },

-  { 0x8700, 0xa1c9, 0x3000 },

-  { 0x8700, 0xa1c7, 0x2000 },

-  { 0x0700, 0xa1c6, 0x0000 },

-  { 0x0700, 0xa1c8, 0x0000 },

-  { 0x8700, 0xa1cb, 0x2000 },

-  { 0x0700, 0xa1ca, 0x0000 },

-  { 0x0700, 0xa1cc, 0x0000 },

-  { 0x8700, 0xa20d, 0x7000 },

-  { 0x8700, 0xa1ed, 0x6000 },

-  { 0x8700, 0xa1dd, 0x5000 },

-  { 0x8700, 0xa1d5, 0x4000 },

-  { 0x8700, 0xa1d1, 0x3000 },

-  { 0x8700, 0xa1cf, 0x2000 },

-  { 0x0700, 0xa1ce, 0x0000 },

-  { 0x0700, 0xa1d0, 0x0000 },

-  { 0x8700, 0xa1d3, 0x2000 },

-  { 0x0700, 0xa1d2, 0x0000 },

-  { 0x0700, 0xa1d4, 0x0000 },

-  { 0x8700, 0xa1d9, 0x3000 },

-  { 0x8700, 0xa1d7, 0x2000 },

-  { 0x0700, 0xa1d6, 0x0000 },

-  { 0x0700, 0xa1d8, 0x0000 },

-  { 0x8700, 0xa1db, 0x2000 },

-  { 0x0700, 0xa1da, 0x0000 },

-  { 0x0700, 0xa1dc, 0x0000 },

-  { 0x8700, 0xa1e5, 0x4000 },

-  { 0x8700, 0xa1e1, 0x3000 },

-  { 0x8700, 0xa1df, 0x2000 },

-  { 0x0700, 0xa1de, 0x0000 },

-  { 0x0700, 0xa1e0, 0x0000 },

-  { 0x8700, 0xa1e3, 0x2000 },

-  { 0x0700, 0xa1e2, 0x0000 },

-  { 0x0700, 0xa1e4, 0x0000 },

-  { 0x8700, 0xa1e9, 0x3000 },

-  { 0x8700, 0xa1e7, 0x2000 },

-  { 0x0700, 0xa1e6, 0x0000 },

-  { 0x0700, 0xa1e8, 0x0000 },

-  { 0x8700, 0xa1eb, 0x2000 },

-  { 0x0700, 0xa1ea, 0x0000 },

-  { 0x0700, 0xa1ec, 0x0000 },

-  { 0x8700, 0xa1fd, 0x5000 },

-  { 0x8700, 0xa1f5, 0x4000 },

-  { 0x8700, 0xa1f1, 0x3000 },

-  { 0x8700, 0xa1ef, 0x2000 },

-  { 0x0700, 0xa1ee, 0x0000 },

-  { 0x0700, 0xa1f0, 0x0000 },

-  { 0x8700, 0xa1f3, 0x2000 },

-  { 0x0700, 0xa1f2, 0x0000 },

-  { 0x0700, 0xa1f4, 0x0000 },

-  { 0x8700, 0xa1f9, 0x3000 },

-  { 0x8700, 0xa1f7, 0x2000 },

-  { 0x0700, 0xa1f6, 0x0000 },

-  { 0x0700, 0xa1f8, 0x0000 },

-  { 0x8700, 0xa1fb, 0x2000 },

-  { 0x0700, 0xa1fa, 0x0000 },

-  { 0x0700, 0xa1fc, 0x0000 },

-  { 0x8700, 0xa205, 0x4000 },

-  { 0x8700, 0xa201, 0x3000 },

-  { 0x8700, 0xa1ff, 0x2000 },

-  { 0x0700, 0xa1fe, 0x0000 },

-  { 0x0700, 0xa200, 0x0000 },

-  { 0x8700, 0xa203, 0x2000 },

-  { 0x0700, 0xa202, 0x0000 },

-  { 0x0700, 0xa204, 0x0000 },

-  { 0x8700, 0xa209, 0x3000 },

-  { 0x8700, 0xa207, 0x2000 },

-  { 0x0700, 0xa206, 0x0000 },

-  { 0x0700, 0xa208, 0x0000 },

-  { 0x8700, 0xa20b, 0x2000 },

-  { 0x0700, 0xa20a, 0x0000 },

-  { 0x0700, 0xa20c, 0x0000 },

-  { 0x8700, 0xa22d, 0x6000 },

-  { 0x8700, 0xa21d, 0x5000 },

-  { 0x8700, 0xa215, 0x4000 },

-  { 0x8700, 0xa211, 0x3000 },

-  { 0x8700, 0xa20f, 0x2000 },

-  { 0x0700, 0xa20e, 0x0000 },

-  { 0x0700, 0xa210, 0x0000 },

-  { 0x8700, 0xa213, 0x2000 },

-  { 0x0700, 0xa212, 0x0000 },

-  { 0x0700, 0xa214, 0x0000 },

-  { 0x8700, 0xa219, 0x3000 },

-  { 0x8700, 0xa217, 0x2000 },

-  { 0x0700, 0xa216, 0x0000 },

-  { 0x0700, 0xa218, 0x0000 },

-  { 0x8700, 0xa21b, 0x2000 },

-  { 0x0700, 0xa21a, 0x0000 },

-  { 0x0700, 0xa21c, 0x0000 },

-  { 0x8700, 0xa225, 0x4000 },

-  { 0x8700, 0xa221, 0x3000 },

-  { 0x8700, 0xa21f, 0x2000 },

-  { 0x0700, 0xa21e, 0x0000 },

-  { 0x0700, 0xa220, 0x0000 },

-  { 0x8700, 0xa223, 0x2000 },

-  { 0x0700, 0xa222, 0x0000 },

-  { 0x0700, 0xa224, 0x0000 },

-  { 0x8700, 0xa229, 0x3000 },

-  { 0x8700, 0xa227, 0x2000 },

-  { 0x0700, 0xa226, 0x0000 },

-  { 0x0700, 0xa228, 0x0000 },

-  { 0x8700, 0xa22b, 0x2000 },

-  { 0x0700, 0xa22a, 0x0000 },

-  { 0x0700, 0xa22c, 0x0000 },

-  { 0x8700, 0xa23d, 0x5000 },

-  { 0x8700, 0xa235, 0x4000 },

-  { 0x8700, 0xa231, 0x3000 },

-  { 0x8700, 0xa22f, 0x2000 },

-  { 0x0700, 0xa22e, 0x0000 },

-  { 0x0700, 0xa230, 0x0000 },

-  { 0x8700, 0xa233, 0x2000 },

-  { 0x0700, 0xa232, 0x0000 },

-  { 0x0700, 0xa234, 0x0000 },

-  { 0x8700, 0xa239, 0x3000 },

-  { 0x8700, 0xa237, 0x2000 },

-  { 0x0700, 0xa236, 0x0000 },

-  { 0x0700, 0xa238, 0x0000 },

-  { 0x8700, 0xa23b, 0x2000 },

-  { 0x0700, 0xa23a, 0x0000 },

-  { 0x0700, 0xa23c, 0x0000 },

-  { 0x8700, 0xa245, 0x4000 },

-  { 0x8700, 0xa241, 0x3000 },

-  { 0x8700, 0xa23f, 0x2000 },

-  { 0x0700, 0xa23e, 0x0000 },

-  { 0x0700, 0xa240, 0x0000 },

-  { 0x8700, 0xa243, 0x2000 },

-  { 0x0700, 0xa242, 0x0000 },

-  { 0x0700, 0xa244, 0x0000 },

-  { 0x8700, 0xa249, 0x3000 },

-  { 0x8700, 0xa247, 0x2000 },

-  { 0x0700, 0xa246, 0x0000 },

-  { 0x0700, 0xa248, 0x0000 },

-  { 0x8700, 0xa24b, 0x2000 },

-  { 0x0700, 0xa24a, 0x0000 },

-  { 0x0700, 0xa24c, 0x0000 },

-  { 0x8700, 0xa2cd, 0x8000 },

-  { 0x8700, 0xa28d, 0x7000 },

-  { 0x8700, 0xa26d, 0x6000 },

-  { 0x8700, 0xa25d, 0x5000 },

-  { 0x8700, 0xa255, 0x4000 },

-  { 0x8700, 0xa251, 0x3000 },

-  { 0x8700, 0xa24f, 0x2000 },

-  { 0x0700, 0xa24e, 0x0000 },

-  { 0x0700, 0xa250, 0x0000 },

-  { 0x8700, 0xa253, 0x2000 },

-  { 0x0700, 0xa252, 0x0000 },

-  { 0x0700, 0xa254, 0x0000 },

-  { 0x8700, 0xa259, 0x3000 },

-  { 0x8700, 0xa257, 0x2000 },

-  { 0x0700, 0xa256, 0x0000 },

-  { 0x0700, 0xa258, 0x0000 },

-  { 0x8700, 0xa25b, 0x2000 },

-  { 0x0700, 0xa25a, 0x0000 },

-  { 0x0700, 0xa25c, 0x0000 },

-  { 0x8700, 0xa265, 0x4000 },

-  { 0x8700, 0xa261, 0x3000 },

-  { 0x8700, 0xa25f, 0x2000 },

-  { 0x0700, 0xa25e, 0x0000 },

-  { 0x0700, 0xa260, 0x0000 },

-  { 0x8700, 0xa263, 0x2000 },

-  { 0x0700, 0xa262, 0x0000 },

-  { 0x0700, 0xa264, 0x0000 },

-  { 0x8700, 0xa269, 0x3000 },

-  { 0x8700, 0xa267, 0x2000 },

-  { 0x0700, 0xa266, 0x0000 },

-  { 0x0700, 0xa268, 0x0000 },

-  { 0x8700, 0xa26b, 0x2000 },

-  { 0x0700, 0xa26a, 0x0000 },

-  { 0x0700, 0xa26c, 0x0000 },

-  { 0x8700, 0xa27d, 0x5000 },

-  { 0x8700, 0xa275, 0x4000 },

-  { 0x8700, 0xa271, 0x3000 },

-  { 0x8700, 0xa26f, 0x2000 },

-  { 0x0700, 0xa26e, 0x0000 },

-  { 0x0700, 0xa270, 0x0000 },

-  { 0x8700, 0xa273, 0x2000 },

-  { 0x0700, 0xa272, 0x0000 },

-  { 0x0700, 0xa274, 0x0000 },

-  { 0x8700, 0xa279, 0x3000 },

-  { 0x8700, 0xa277, 0x2000 },

-  { 0x0700, 0xa276, 0x0000 },

-  { 0x0700, 0xa278, 0x0000 },

-  { 0x8700, 0xa27b, 0x2000 },

-  { 0x0700, 0xa27a, 0x0000 },

-  { 0x0700, 0xa27c, 0x0000 },

-  { 0x8700, 0xa285, 0x4000 },

-  { 0x8700, 0xa281, 0x3000 },

-  { 0x8700, 0xa27f, 0x2000 },

-  { 0x0700, 0xa27e, 0x0000 },

-  { 0x0700, 0xa280, 0x0000 },

-  { 0x8700, 0xa283, 0x2000 },

-  { 0x0700, 0xa282, 0x0000 },

-  { 0x0700, 0xa284, 0x0000 },

-  { 0x8700, 0xa289, 0x3000 },

-  { 0x8700, 0xa287, 0x2000 },

-  { 0x0700, 0xa286, 0x0000 },

-  { 0x0700, 0xa288, 0x0000 },

-  { 0x8700, 0xa28b, 0x2000 },

-  { 0x0700, 0xa28a, 0x0000 },

-  { 0x0700, 0xa28c, 0x0000 },

-  { 0x8700, 0xa2ad, 0x6000 },

-  { 0x8700, 0xa29d, 0x5000 },

-  { 0x8700, 0xa295, 0x4000 },

-  { 0x8700, 0xa291, 0x3000 },

-  { 0x8700, 0xa28f, 0x2000 },

-  { 0x0700, 0xa28e, 0x0000 },

-  { 0x0700, 0xa290, 0x0000 },

-  { 0x8700, 0xa293, 0x2000 },

-  { 0x0700, 0xa292, 0x0000 },

-  { 0x0700, 0xa294, 0x0000 },

-  { 0x8700, 0xa299, 0x3000 },

-  { 0x8700, 0xa297, 0x2000 },

-  { 0x0700, 0xa296, 0x0000 },

-  { 0x0700, 0xa298, 0x0000 },

-  { 0x8700, 0xa29b, 0x2000 },

-  { 0x0700, 0xa29a, 0x0000 },

-  { 0x0700, 0xa29c, 0x0000 },

-  { 0x8700, 0xa2a5, 0x4000 },

-  { 0x8700, 0xa2a1, 0x3000 },

-  { 0x8700, 0xa29f, 0x2000 },

-  { 0x0700, 0xa29e, 0x0000 },

-  { 0x0700, 0xa2a0, 0x0000 },

-  { 0x8700, 0xa2a3, 0x2000 },

-  { 0x0700, 0xa2a2, 0x0000 },

-  { 0x0700, 0xa2a4, 0x0000 },

-  { 0x8700, 0xa2a9, 0x3000 },

-  { 0x8700, 0xa2a7, 0x2000 },

-  { 0x0700, 0xa2a6, 0x0000 },

-  { 0x0700, 0xa2a8, 0x0000 },

-  { 0x8700, 0xa2ab, 0x2000 },

-  { 0x0700, 0xa2aa, 0x0000 },

-  { 0x0700, 0xa2ac, 0x0000 },

-  { 0x8700, 0xa2bd, 0x5000 },

-  { 0x8700, 0xa2b5, 0x4000 },

-  { 0x8700, 0xa2b1, 0x3000 },

-  { 0x8700, 0xa2af, 0x2000 },

-  { 0x0700, 0xa2ae, 0x0000 },

-  { 0x0700, 0xa2b0, 0x0000 },

-  { 0x8700, 0xa2b3, 0x2000 },

-  { 0x0700, 0xa2b2, 0x0000 },

-  { 0x0700, 0xa2b4, 0x0000 },

-  { 0x8700, 0xa2b9, 0x3000 },

-  { 0x8700, 0xa2b7, 0x2000 },

-  { 0x0700, 0xa2b6, 0x0000 },

-  { 0x0700, 0xa2b8, 0x0000 },

-  { 0x8700, 0xa2bb, 0x2000 },

-  { 0x0700, 0xa2ba, 0x0000 },

-  { 0x0700, 0xa2bc, 0x0000 },

-  { 0x8700, 0xa2c5, 0x4000 },

-  { 0x8700, 0xa2c1, 0x3000 },

-  { 0x8700, 0xa2bf, 0x2000 },

-  { 0x0700, 0xa2be, 0x0000 },

-  { 0x0700, 0xa2c0, 0x0000 },

-  { 0x8700, 0xa2c3, 0x2000 },

-  { 0x0700, 0xa2c2, 0x0000 },

-  { 0x0700, 0xa2c4, 0x0000 },

-  { 0x8700, 0xa2c9, 0x3000 },

-  { 0x8700, 0xa2c7, 0x2000 },

-  { 0x0700, 0xa2c6, 0x0000 },

-  { 0x0700, 0xa2c8, 0x0000 },

-  { 0x8700, 0xa2cb, 0x2000 },

-  { 0x0700, 0xa2ca, 0x0000 },

-  { 0x0700, 0xa2cc, 0x0000 },

-  { 0x8700, 0xa30d, 0x7000 },

-  { 0x8700, 0xa2ed, 0x6000 },

-  { 0x8700, 0xa2dd, 0x5000 },

-  { 0x8700, 0xa2d5, 0x4000 },

-  { 0x8700, 0xa2d1, 0x3000 },

-  { 0x8700, 0xa2cf, 0x2000 },

-  { 0x0700, 0xa2ce, 0x0000 },

-  { 0x0700, 0xa2d0, 0x0000 },

-  { 0x8700, 0xa2d3, 0x2000 },

-  { 0x0700, 0xa2d2, 0x0000 },

-  { 0x0700, 0xa2d4, 0x0000 },

-  { 0x8700, 0xa2d9, 0x3000 },

-  { 0x8700, 0xa2d7, 0x2000 },

-  { 0x0700, 0xa2d6, 0x0000 },

-  { 0x0700, 0xa2d8, 0x0000 },

-  { 0x8700, 0xa2db, 0x2000 },

-  { 0x0700, 0xa2da, 0x0000 },

-  { 0x0700, 0xa2dc, 0x0000 },

-  { 0x8700, 0xa2e5, 0x4000 },

-  { 0x8700, 0xa2e1, 0x3000 },

-  { 0x8700, 0xa2df, 0x2000 },

-  { 0x0700, 0xa2de, 0x0000 },

-  { 0x0700, 0xa2e0, 0x0000 },

-  { 0x8700, 0xa2e3, 0x2000 },

-  { 0x0700, 0xa2e2, 0x0000 },

-  { 0x0700, 0xa2e4, 0x0000 },

-  { 0x8700, 0xa2e9, 0x3000 },

-  { 0x8700, 0xa2e7, 0x2000 },

-  { 0x0700, 0xa2e6, 0x0000 },

-  { 0x0700, 0xa2e8, 0x0000 },

-  { 0x8700, 0xa2eb, 0x2000 },

-  { 0x0700, 0xa2ea, 0x0000 },

-  { 0x0700, 0xa2ec, 0x0000 },

-  { 0x8700, 0xa2fd, 0x5000 },

-  { 0x8700, 0xa2f5, 0x4000 },

-  { 0x8700, 0xa2f1, 0x3000 },

-  { 0x8700, 0xa2ef, 0x2000 },

-  { 0x0700, 0xa2ee, 0x0000 },

-  { 0x0700, 0xa2f0, 0x0000 },

-  { 0x8700, 0xa2f3, 0x2000 },

-  { 0x0700, 0xa2f2, 0x0000 },

-  { 0x0700, 0xa2f4, 0x0000 },

-  { 0x8700, 0xa2f9, 0x3000 },

-  { 0x8700, 0xa2f7, 0x2000 },

-  { 0x0700, 0xa2f6, 0x0000 },

-  { 0x0700, 0xa2f8, 0x0000 },

-  { 0x8700, 0xa2fb, 0x2000 },

-  { 0x0700, 0xa2fa, 0x0000 },

-  { 0x0700, 0xa2fc, 0x0000 },

-  { 0x8700, 0xa305, 0x4000 },

-  { 0x8700, 0xa301, 0x3000 },

-  { 0x8700, 0xa2ff, 0x2000 },

-  { 0x0700, 0xa2fe, 0x0000 },

-  { 0x0700, 0xa300, 0x0000 },

-  { 0x8700, 0xa303, 0x2000 },

-  { 0x0700, 0xa302, 0x0000 },

-  { 0x0700, 0xa304, 0x0000 },

-  { 0x8700, 0xa309, 0x3000 },

-  { 0x8700, 0xa307, 0x2000 },

-  { 0x0700, 0xa306, 0x0000 },

-  { 0x0700, 0xa308, 0x0000 },

-  { 0x8700, 0xa30b, 0x2000 },

-  { 0x0700, 0xa30a, 0x0000 },

-  { 0x0700, 0xa30c, 0x0000 },

-  { 0x8700, 0xa32d, 0x6000 },

-  { 0x8700, 0xa31d, 0x5000 },

-  { 0x8700, 0xa315, 0x4000 },

-  { 0x8700, 0xa311, 0x3000 },

-  { 0x8700, 0xa30f, 0x2000 },

-  { 0x0700, 0xa30e, 0x0000 },

-  { 0x0700, 0xa310, 0x0000 },

-  { 0x8700, 0xa313, 0x2000 },

-  { 0x0700, 0xa312, 0x0000 },

-  { 0x0700, 0xa314, 0x0000 },

-  { 0x8700, 0xa319, 0x3000 },

-  { 0x8700, 0xa317, 0x2000 },

-  { 0x0700, 0xa316, 0x0000 },

-  { 0x0700, 0xa318, 0x0000 },

-  { 0x8700, 0xa31b, 0x2000 },

-  { 0x0700, 0xa31a, 0x0000 },

-  { 0x0700, 0xa31c, 0x0000 },

-  { 0x8700, 0xa325, 0x4000 },

-  { 0x8700, 0xa321, 0x3000 },

-  { 0x8700, 0xa31f, 0x2000 },

-  { 0x0700, 0xa31e, 0x0000 },

-  { 0x0700, 0xa320, 0x0000 },

-  { 0x8700, 0xa323, 0x2000 },

-  { 0x0700, 0xa322, 0x0000 },

-  { 0x0700, 0xa324, 0x0000 },

-  { 0x8700, 0xa329, 0x3000 },

-  { 0x8700, 0xa327, 0x2000 },

-  { 0x0700, 0xa326, 0x0000 },

-  { 0x0700, 0xa328, 0x0000 },

-  { 0x8700, 0xa32b, 0x2000 },

-  { 0x0700, 0xa32a, 0x0000 },

-  { 0x0700, 0xa32c, 0x0000 },

-  { 0x8700, 0xa33d, 0x5000 },

-  { 0x8700, 0xa335, 0x4000 },

-  { 0x8700, 0xa331, 0x3000 },

-  { 0x8700, 0xa32f, 0x2000 },

-  { 0x0700, 0xa32e, 0x0000 },

-  { 0x0700, 0xa330, 0x0000 },

-  { 0x8700, 0xa333, 0x2000 },

-  { 0x0700, 0xa332, 0x0000 },

-  { 0x0700, 0xa334, 0x0000 },

-  { 0x8700, 0xa339, 0x3000 },

-  { 0x8700, 0xa337, 0x2000 },

-  { 0x0700, 0xa336, 0x0000 },

-  { 0x0700, 0xa338, 0x0000 },

-  { 0x8700, 0xa33b, 0x2000 },

-  { 0x0700, 0xa33a, 0x0000 },

-  { 0x0700, 0xa33c, 0x0000 },

-  { 0x8700, 0xa345, 0x4000 },

-  { 0x8700, 0xa341, 0x3000 },

-  { 0x8700, 0xa33f, 0x2000 },

-  { 0x0700, 0xa33e, 0x0000 },

-  { 0x0700, 0xa340, 0x0000 },

-  { 0x8700, 0xa343, 0x2000 },

-  { 0x0700, 0xa342, 0x0000 },

-  { 0x0700, 0xa344, 0x0000 },

-  { 0x8700, 0xa349, 0x3000 },

-  { 0x8700, 0xa347, 0x2000 },

-  { 0x0700, 0xa346, 0x0000 },

-  { 0x0700, 0xa348, 0x0000 },

-  { 0x8700, 0xa34b, 0x2000 },

-  { 0x0700, 0xa34a, 0x0000 },

-  { 0x0700, 0xa34c, 0x0000 },

-  { 0x8700, 0xfc4d, 0xb000 },

-  { 0x8700, 0xf97f, 0xa000 },

-  { 0x8700, 0xa44d, 0x9000 },

-  { 0x8700, 0xa3cd, 0x8000 },

-  { 0x8700, 0xa38d, 0x7000 },

-  { 0x8700, 0xa36d, 0x6000 },

-  { 0x8700, 0xa35d, 0x5000 },

-  { 0x8700, 0xa355, 0x4000 },

-  { 0x8700, 0xa351, 0x3000 },

-  { 0x8700, 0xa34f, 0x2000 },

-  { 0x0700, 0xa34e, 0x0000 },

-  { 0x0700, 0xa350, 0x0000 },

-  { 0x8700, 0xa353, 0x2000 },

-  { 0x0700, 0xa352, 0x0000 },

-  { 0x0700, 0xa354, 0x0000 },

-  { 0x8700, 0xa359, 0x3000 },

-  { 0x8700, 0xa357, 0x2000 },

-  { 0x0700, 0xa356, 0x0000 },

-  { 0x0700, 0xa358, 0x0000 },

-  { 0x8700, 0xa35b, 0x2000 },

-  { 0x0700, 0xa35a, 0x0000 },

-  { 0x0700, 0xa35c, 0x0000 },

-  { 0x8700, 0xa365, 0x4000 },

-  { 0x8700, 0xa361, 0x3000 },

-  { 0x8700, 0xa35f, 0x2000 },

-  { 0x0700, 0xa35e, 0x0000 },

-  { 0x0700, 0xa360, 0x0000 },

-  { 0x8700, 0xa363, 0x2000 },

-  { 0x0700, 0xa362, 0x0000 },

-  { 0x0700, 0xa364, 0x0000 },

-  { 0x8700, 0xa369, 0x3000 },

-  { 0x8700, 0xa367, 0x2000 },

-  { 0x0700, 0xa366, 0x0000 },

-  { 0x0700, 0xa368, 0x0000 },

-  { 0x8700, 0xa36b, 0x2000 },

-  { 0x0700, 0xa36a, 0x0000 },

-  { 0x0700, 0xa36c, 0x0000 },

-  { 0x8700, 0xa37d, 0x5000 },

-  { 0x8700, 0xa375, 0x4000 },

-  { 0x8700, 0xa371, 0x3000 },

-  { 0x8700, 0xa36f, 0x2000 },

-  { 0x0700, 0xa36e, 0x0000 },

-  { 0x0700, 0xa370, 0x0000 },

-  { 0x8700, 0xa373, 0x2000 },

-  { 0x0700, 0xa372, 0x0000 },

-  { 0x0700, 0xa374, 0x0000 },

-  { 0x8700, 0xa379, 0x3000 },

-  { 0x8700, 0xa377, 0x2000 },

-  { 0x0700, 0xa376, 0x0000 },

-  { 0x0700, 0xa378, 0x0000 },

-  { 0x8700, 0xa37b, 0x2000 },

-  { 0x0700, 0xa37a, 0x0000 },

-  { 0x0700, 0xa37c, 0x0000 },

-  { 0x8700, 0xa385, 0x4000 },

-  { 0x8700, 0xa381, 0x3000 },

-  { 0x8700, 0xa37f, 0x2000 },

-  { 0x0700, 0xa37e, 0x0000 },

-  { 0x0700, 0xa380, 0x0000 },

-  { 0x8700, 0xa383, 0x2000 },

-  { 0x0700, 0xa382, 0x0000 },

-  { 0x0700, 0xa384, 0x0000 },

-  { 0x8700, 0xa389, 0x3000 },

-  { 0x8700, 0xa387, 0x2000 },

-  { 0x0700, 0xa386, 0x0000 },

-  { 0x0700, 0xa388, 0x0000 },

-  { 0x8700, 0xa38b, 0x2000 },

-  { 0x0700, 0xa38a, 0x0000 },

-  { 0x0700, 0xa38c, 0x0000 },

-  { 0x8700, 0xa3ad, 0x6000 },

-  { 0x8700, 0xa39d, 0x5000 },

-  { 0x8700, 0xa395, 0x4000 },

-  { 0x8700, 0xa391, 0x3000 },

-  { 0x8700, 0xa38f, 0x2000 },

-  { 0x0700, 0xa38e, 0x0000 },

-  { 0x0700, 0xa390, 0x0000 },

-  { 0x8700, 0xa393, 0x2000 },

-  { 0x0700, 0xa392, 0x0000 },

-  { 0x0700, 0xa394, 0x0000 },

-  { 0x8700, 0xa399, 0x3000 },

-  { 0x8700, 0xa397, 0x2000 },

-  { 0x0700, 0xa396, 0x0000 },

-  { 0x0700, 0xa398, 0x0000 },

-  { 0x8700, 0xa39b, 0x2000 },

-  { 0x0700, 0xa39a, 0x0000 },

-  { 0x0700, 0xa39c, 0x0000 },

-  { 0x8700, 0xa3a5, 0x4000 },

-  { 0x8700, 0xa3a1, 0x3000 },

-  { 0x8700, 0xa39f, 0x2000 },

-  { 0x0700, 0xa39e, 0x0000 },

-  { 0x0700, 0xa3a0, 0x0000 },

-  { 0x8700, 0xa3a3, 0x2000 },

-  { 0x0700, 0xa3a2, 0x0000 },

-  { 0x0700, 0xa3a4, 0x0000 },

-  { 0x8700, 0xa3a9, 0x3000 },

-  { 0x8700, 0xa3a7, 0x2000 },

-  { 0x0700, 0xa3a6, 0x0000 },

-  { 0x0700, 0xa3a8, 0x0000 },

-  { 0x8700, 0xa3ab, 0x2000 },

-  { 0x0700, 0xa3aa, 0x0000 },

-  { 0x0700, 0xa3ac, 0x0000 },

-  { 0x8700, 0xa3bd, 0x5000 },

-  { 0x8700, 0xa3b5, 0x4000 },

-  { 0x8700, 0xa3b1, 0x3000 },

-  { 0x8700, 0xa3af, 0x2000 },

-  { 0x0700, 0xa3ae, 0x0000 },

-  { 0x0700, 0xa3b0, 0x0000 },

-  { 0x8700, 0xa3b3, 0x2000 },

-  { 0x0700, 0xa3b2, 0x0000 },

-  { 0x0700, 0xa3b4, 0x0000 },

-  { 0x8700, 0xa3b9, 0x3000 },

-  { 0x8700, 0xa3b7, 0x2000 },

-  { 0x0700, 0xa3b6, 0x0000 },

-  { 0x0700, 0xa3b8, 0x0000 },

-  { 0x8700, 0xa3bb, 0x2000 },

-  { 0x0700, 0xa3ba, 0x0000 },

-  { 0x0700, 0xa3bc, 0x0000 },

-  { 0x8700, 0xa3c5, 0x4000 },

-  { 0x8700, 0xa3c1, 0x3000 },

-  { 0x8700, 0xa3bf, 0x2000 },

-  { 0x0700, 0xa3be, 0x0000 },

-  { 0x0700, 0xa3c0, 0x0000 },

-  { 0x8700, 0xa3c3, 0x2000 },

-  { 0x0700, 0xa3c2, 0x0000 },

-  { 0x0700, 0xa3c4, 0x0000 },

-  { 0x8700, 0xa3c9, 0x3000 },

-  { 0x8700, 0xa3c7, 0x2000 },

-  { 0x0700, 0xa3c6, 0x0000 },

-  { 0x0700, 0xa3c8, 0x0000 },

-  { 0x8700, 0xa3cb, 0x2000 },

-  { 0x0700, 0xa3ca, 0x0000 },

-  { 0x0700, 0xa3cc, 0x0000 },

-  { 0x8700, 0xa40d, 0x7000 },

-  { 0x8700, 0xa3ed, 0x6000 },

-  { 0x8700, 0xa3dd, 0x5000 },

-  { 0x8700, 0xa3d5, 0x4000 },

-  { 0x8700, 0xa3d1, 0x3000 },

-  { 0x8700, 0xa3cf, 0x2000 },

-  { 0x0700, 0xa3ce, 0x0000 },

-  { 0x0700, 0xa3d0, 0x0000 },

-  { 0x8700, 0xa3d3, 0x2000 },

-  { 0x0700, 0xa3d2, 0x0000 },

-  { 0x0700, 0xa3d4, 0x0000 },

-  { 0x8700, 0xa3d9, 0x3000 },

-  { 0x8700, 0xa3d7, 0x2000 },

-  { 0x0700, 0xa3d6, 0x0000 },

-  { 0x0700, 0xa3d8, 0x0000 },

-  { 0x8700, 0xa3db, 0x2000 },

-  { 0x0700, 0xa3da, 0x0000 },

-  { 0x0700, 0xa3dc, 0x0000 },

-  { 0x8700, 0xa3e5, 0x4000 },

-  { 0x8700, 0xa3e1, 0x3000 },

-  { 0x8700, 0xa3df, 0x2000 },

-  { 0x0700, 0xa3de, 0x0000 },

-  { 0x0700, 0xa3e0, 0x0000 },

-  { 0x8700, 0xa3e3, 0x2000 },

-  { 0x0700, 0xa3e2, 0x0000 },

-  { 0x0700, 0xa3e4, 0x0000 },

-  { 0x8700, 0xa3e9, 0x3000 },

-  { 0x8700, 0xa3e7, 0x2000 },

-  { 0x0700, 0xa3e6, 0x0000 },

-  { 0x0700, 0xa3e8, 0x0000 },

-  { 0x8700, 0xa3eb, 0x2000 },

-  { 0x0700, 0xa3ea, 0x0000 },

-  { 0x0700, 0xa3ec, 0x0000 },

-  { 0x8700, 0xa3fd, 0x5000 },

-  { 0x8700, 0xa3f5, 0x4000 },

-  { 0x8700, 0xa3f1, 0x3000 },

-  { 0x8700, 0xa3ef, 0x2000 },

-  { 0x0700, 0xa3ee, 0x0000 },

-  { 0x0700, 0xa3f0, 0x0000 },

-  { 0x8700, 0xa3f3, 0x2000 },

-  { 0x0700, 0xa3f2, 0x0000 },

-  { 0x0700, 0xa3f4, 0x0000 },

-  { 0x8700, 0xa3f9, 0x3000 },

-  { 0x8700, 0xa3f7, 0x2000 },

-  { 0x0700, 0xa3f6, 0x0000 },

-  { 0x0700, 0xa3f8, 0x0000 },

-  { 0x8700, 0xa3fb, 0x2000 },

-  { 0x0700, 0xa3fa, 0x0000 },

-  { 0x0700, 0xa3fc, 0x0000 },

-  { 0x8700, 0xa405, 0x4000 },

-  { 0x8700, 0xa401, 0x3000 },

-  { 0x8700, 0xa3ff, 0x2000 },

-  { 0x0700, 0xa3fe, 0x0000 },

-  { 0x0700, 0xa400, 0x0000 },

-  { 0x8700, 0xa403, 0x2000 },

-  { 0x0700, 0xa402, 0x0000 },

-  { 0x0700, 0xa404, 0x0000 },

-  { 0x8700, 0xa409, 0x3000 },

-  { 0x8700, 0xa407, 0x2000 },

-  { 0x0700, 0xa406, 0x0000 },

-  { 0x0700, 0xa408, 0x0000 },

-  { 0x8700, 0xa40b, 0x2000 },

-  { 0x0700, 0xa40a, 0x0000 },

-  { 0x0700, 0xa40c, 0x0000 },

-  { 0x8700, 0xa42d, 0x6000 },

-  { 0x8700, 0xa41d, 0x5000 },

-  { 0x8700, 0xa415, 0x4000 },

-  { 0x8700, 0xa411, 0x3000 },

-  { 0x8700, 0xa40f, 0x2000 },

-  { 0x0700, 0xa40e, 0x0000 },

-  { 0x0700, 0xa410, 0x0000 },

-  { 0x8700, 0xa413, 0x2000 },

-  { 0x0700, 0xa412, 0x0000 },

-  { 0x0700, 0xa414, 0x0000 },

-  { 0x8700, 0xa419, 0x3000 },

-  { 0x8700, 0xa417, 0x2000 },

-  { 0x0700, 0xa416, 0x0000 },

-  { 0x0700, 0xa418, 0x0000 },

-  { 0x8700, 0xa41b, 0x2000 },

-  { 0x0700, 0xa41a, 0x0000 },

-  { 0x0700, 0xa41c, 0x0000 },

-  { 0x8700, 0xa425, 0x4000 },

-  { 0x8700, 0xa421, 0x3000 },

-  { 0x8700, 0xa41f, 0x2000 },

-  { 0x0700, 0xa41e, 0x0000 },

-  { 0x0700, 0xa420, 0x0000 },

-  { 0x8700, 0xa423, 0x2000 },

-  { 0x0700, 0xa422, 0x0000 },

-  { 0x0700, 0xa424, 0x0000 },

-  { 0x8700, 0xa429, 0x3000 },

-  { 0x8700, 0xa427, 0x2000 },

-  { 0x0700, 0xa426, 0x0000 },

-  { 0x0700, 0xa428, 0x0000 },

-  { 0x8700, 0xa42b, 0x2000 },

-  { 0x0700, 0xa42a, 0x0000 },

-  { 0x0700, 0xa42c, 0x0000 },

-  { 0x8700, 0xa43d, 0x5000 },

-  { 0x8700, 0xa435, 0x4000 },

-  { 0x8700, 0xa431, 0x3000 },

-  { 0x8700, 0xa42f, 0x2000 },

-  { 0x0700, 0xa42e, 0x0000 },

-  { 0x0700, 0xa430, 0x0000 },

-  { 0x8700, 0xa433, 0x2000 },

-  { 0x0700, 0xa432, 0x0000 },

-  { 0x0700, 0xa434, 0x0000 },

-  { 0x8700, 0xa439, 0x3000 },

-  { 0x8700, 0xa437, 0x2000 },

-  { 0x0700, 0xa436, 0x0000 },

-  { 0x0700, 0xa438, 0x0000 },

-  { 0x8700, 0xa43b, 0x2000 },

-  { 0x0700, 0xa43a, 0x0000 },

-  { 0x0700, 0xa43c, 0x0000 },

-  { 0x8700, 0xa445, 0x4000 },

-  { 0x8700, 0xa441, 0x3000 },

-  { 0x8700, 0xa43f, 0x2000 },

-  { 0x0700, 0xa43e, 0x0000 },

-  { 0x0700, 0xa440, 0x0000 },

-  { 0x8700, 0xa443, 0x2000 },

-  { 0x0700, 0xa442, 0x0000 },

-  { 0x0700, 0xa444, 0x0000 },

-  { 0x8700, 0xa449, 0x3000 },

-  { 0x8700, 0xa447, 0x2000 },

-  { 0x0700, 0xa446, 0x0000 },

-  { 0x0700, 0xa448, 0x0000 },

-  { 0x8700, 0xa44b, 0x2000 },

-  { 0x0700, 0xa44a, 0x0000 },

-  { 0x0700, 0xa44c, 0x0000 },

-  { 0x8300, 0xf8ff, 0x8000 },

-  { 0x9a00, 0xa490, 0x7000 },

-  { 0x8700, 0xa46d, 0x6000 },

-  { 0x8700, 0xa45d, 0x5000 },

-  { 0x8700, 0xa455, 0x4000 },

-  { 0x8700, 0xa451, 0x3000 },

-  { 0x8700, 0xa44f, 0x2000 },

-  { 0x0700, 0xa44e, 0x0000 },

-  { 0x0700, 0xa450, 0x0000 },

-  { 0x8700, 0xa453, 0x2000 },

-  { 0x0700, 0xa452, 0x0000 },

-  { 0x0700, 0xa454, 0x0000 },

-  { 0x8700, 0xa459, 0x3000 },

-  { 0x8700, 0xa457, 0x2000 },

-  { 0x0700, 0xa456, 0x0000 },

-  { 0x0700, 0xa458, 0x0000 },

-  { 0x8700, 0xa45b, 0x2000 },

-  { 0x0700, 0xa45a, 0x0000 },

-  { 0x0700, 0xa45c, 0x0000 },

-  { 0x8700, 0xa465, 0x4000 },

-  { 0x8700, 0xa461, 0x3000 },

-  { 0x8700, 0xa45f, 0x2000 },

-  { 0x0700, 0xa45e, 0x0000 },

-  { 0x0700, 0xa460, 0x0000 },

-  { 0x8700, 0xa463, 0x2000 },

-  { 0x0700, 0xa462, 0x0000 },

-  { 0x0700, 0xa464, 0x0000 },

-  { 0x8700, 0xa469, 0x3000 },

-  { 0x8700, 0xa467, 0x2000 },

-  { 0x0700, 0xa466, 0x0000 },

-  { 0x0700, 0xa468, 0x0000 },

-  { 0x8700, 0xa46b, 0x2000 },

-  { 0x0700, 0xa46a, 0x0000 },

-  { 0x0700, 0xa46c, 0x0000 },

-  { 0x8700, 0xa47d, 0x5000 },

-  { 0x8700, 0xa475, 0x4000 },

-  { 0x8700, 0xa471, 0x3000 },

-  { 0x8700, 0xa46f, 0x2000 },

-  { 0x0700, 0xa46e, 0x0000 },

-  { 0x0700, 0xa470, 0x0000 },

-  { 0x8700, 0xa473, 0x2000 },

-  { 0x0700, 0xa472, 0x0000 },

-  { 0x0700, 0xa474, 0x0000 },

-  { 0x8700, 0xa479, 0x3000 },

-  { 0x8700, 0xa477, 0x2000 },

-  { 0x0700, 0xa476, 0x0000 },

-  { 0x0700, 0xa478, 0x0000 },

-  { 0x8700, 0xa47b, 0x2000 },

-  { 0x0700, 0xa47a, 0x0000 },

-  { 0x0700, 0xa47c, 0x0000 },

-  { 0x8700, 0xa485, 0x4000 },

-  { 0x8700, 0xa481, 0x3000 },

-  { 0x8700, 0xa47f, 0x2000 },

-  { 0x0700, 0xa47e, 0x0000 },

-  { 0x0700, 0xa480, 0x0000 },

-  { 0x8700, 0xa483, 0x2000 },

-  { 0x0700, 0xa482, 0x0000 },

-  { 0x0700, 0xa484, 0x0000 },

-  { 0x8700, 0xa489, 0x3000 },

-  { 0x8700, 0xa487, 0x2000 },

-  { 0x0700, 0xa486, 0x0000 },

-  { 0x0700, 0xa488, 0x0000 },

-  { 0x8700, 0xa48b, 0x2000 },

-  { 0x0700, 0xa48a, 0x0000 },

-  { 0x0700, 0xa48c, 0x0000 },

-  { 0x9a00, 0xa4b0, 0x6000 },

-  { 0x9a00, 0xa4a0, 0x5000 },

-  { 0x9a00, 0xa498, 0x4000 },

-  { 0x9a00, 0xa494, 0x3000 },

-  { 0x9a00, 0xa492, 0x2000 },

-  { 0x1a00, 0xa491, 0x0000 },

-  { 0x1a00, 0xa493, 0x0000 },

-  { 0x9a00, 0xa496, 0x2000 },

-  { 0x1a00, 0xa495, 0x0000 },

-  { 0x1a00, 0xa497, 0x0000 },

-  { 0x9a00, 0xa49c, 0x3000 },

-  { 0x9a00, 0xa49a, 0x2000 },

-  { 0x1a00, 0xa499, 0x0000 },

-  { 0x1a00, 0xa49b, 0x0000 },

-  { 0x9a00, 0xa49e, 0x2000 },

-  { 0x1a00, 0xa49d, 0x0000 },

-  { 0x1a00, 0xa49f, 0x0000 },

-  { 0x9a00, 0xa4a8, 0x4000 },

-  { 0x9a00, 0xa4a4, 0x3000 },

-  { 0x9a00, 0xa4a2, 0x2000 },

-  { 0x1a00, 0xa4a1, 0x0000 },

-  { 0x1a00, 0xa4a3, 0x0000 },

-  { 0x9a00, 0xa4a6, 0x2000 },

-  { 0x1a00, 0xa4a5, 0x0000 },

-  { 0x1a00, 0xa4a7, 0x0000 },

-  { 0x9a00, 0xa4ac, 0x3000 },

-  { 0x9a00, 0xa4aa, 0x2000 },

-  { 0x1a00, 0xa4a9, 0x0000 },

-  { 0x1a00, 0xa4ab, 0x0000 },

-  { 0x9a00, 0xa4ae, 0x2000 },

-  { 0x1a00, 0xa4ad, 0x0000 },

-  { 0x1a00, 0xa4af, 0x0000 },

-  { 0x9a00, 0xa4c0, 0x5000 },

-  { 0x9a00, 0xa4b8, 0x4000 },

-  { 0x9a00, 0xa4b4, 0x3000 },

-  { 0x9a00, 0xa4b2, 0x2000 },

-  { 0x1a00, 0xa4b1, 0x0000 },

-  { 0x1a00, 0xa4b3, 0x0000 },

-  { 0x9a00, 0xa4b6, 0x2000 },

-  { 0x1a00, 0xa4b5, 0x0000 },

-  { 0x1a00, 0xa4b7, 0x0000 },

-  { 0x9a00, 0xa4bc, 0x3000 },

-  { 0x9a00, 0xa4ba, 0x2000 },

-  { 0x1a00, 0xa4b9, 0x0000 },

-  { 0x1a00, 0xa4bb, 0x0000 },

-  { 0x9a00, 0xa4be, 0x2000 },

-  { 0x1a00, 0xa4bd, 0x0000 },

-  { 0x1a00, 0xa4bf, 0x0000 },

-  { 0x8700, 0xd7a3, 0x4000 },

-  { 0x9a00, 0xa4c4, 0x3000 },

-  { 0x9a00, 0xa4c2, 0x2000 },

-  { 0x1a00, 0xa4c1, 0x0000 },

-  { 0x1a00, 0xa4c3, 0x0000 },

-  { 0x9a00, 0xa4c6, 0x2000 },

-  { 0x1a00, 0xa4c5, 0x0000 },

-  { 0x0700, 0xac00, 0x0000 },

-  { 0x8400, 0xdbff, 0x3000 },

-  { 0x8400, 0xdb7f, 0x2000 },

-  { 0x0400, 0xd800, 0x0000 },

-  { 0x0400, 0xdb80, 0x0000 },

-  { 0x8400, 0xdfff, 0x2000 },

-  { 0x0400, 0xdc00, 0x0000 },

-  { 0x0300, 0xe000, 0x0000 },

-  { 0x8700, 0xf93f, 0x7000 },

-  { 0x8700, 0xf91f, 0x6000 },

-  { 0x8700, 0xf90f, 0x5000 },

-  { 0x8700, 0xf907, 0x4000 },

-  { 0x8700, 0xf903, 0x3000 },

-  { 0x8700, 0xf901, 0x2000 },

-  { 0x0700, 0xf900, 0x0000 },

-  { 0x0700, 0xf902, 0x0000 },

-  { 0x8700, 0xf905, 0x2000 },

-  { 0x0700, 0xf904, 0x0000 },

-  { 0x0700, 0xf906, 0x0000 },

-  { 0x8700, 0xf90b, 0x3000 },

-  { 0x8700, 0xf909, 0x2000 },

-  { 0x0700, 0xf908, 0x0000 },

-  { 0x0700, 0xf90a, 0x0000 },

-  { 0x8700, 0xf90d, 0x2000 },

-  { 0x0700, 0xf90c, 0x0000 },

-  { 0x0700, 0xf90e, 0x0000 },

-  { 0x8700, 0xf917, 0x4000 },

-  { 0x8700, 0xf913, 0x3000 },

-  { 0x8700, 0xf911, 0x2000 },

-  { 0x0700, 0xf910, 0x0000 },

-  { 0x0700, 0xf912, 0x0000 },

-  { 0x8700, 0xf915, 0x2000 },

-  { 0x0700, 0xf914, 0x0000 },

-  { 0x0700, 0xf916, 0x0000 },

-  { 0x8700, 0xf91b, 0x3000 },

-  { 0x8700, 0xf919, 0x2000 },

-  { 0x0700, 0xf918, 0x0000 },

-  { 0x0700, 0xf91a, 0x0000 },

-  { 0x8700, 0xf91d, 0x2000 },

-  { 0x0700, 0xf91c, 0x0000 },

-  { 0x0700, 0xf91e, 0x0000 },

-  { 0x8700, 0xf92f, 0x5000 },

-  { 0x8700, 0xf927, 0x4000 },

-  { 0x8700, 0xf923, 0x3000 },

-  { 0x8700, 0xf921, 0x2000 },

-  { 0x0700, 0xf920, 0x0000 },

-  { 0x0700, 0xf922, 0x0000 },

-  { 0x8700, 0xf925, 0x2000 },

-  { 0x0700, 0xf924, 0x0000 },

-  { 0x0700, 0xf926, 0x0000 },

-  { 0x8700, 0xf92b, 0x3000 },

-  { 0x8700, 0xf929, 0x2000 },

-  { 0x0700, 0xf928, 0x0000 },

-  { 0x0700, 0xf92a, 0x0000 },

-  { 0x8700, 0xf92d, 0x2000 },

-  { 0x0700, 0xf92c, 0x0000 },

-  { 0x0700, 0xf92e, 0x0000 },

-  { 0x8700, 0xf937, 0x4000 },

-  { 0x8700, 0xf933, 0x3000 },

-  { 0x8700, 0xf931, 0x2000 },

-  { 0x0700, 0xf930, 0x0000 },

-  { 0x0700, 0xf932, 0x0000 },

-  { 0x8700, 0xf935, 0x2000 },

-  { 0x0700, 0xf934, 0x0000 },

-  { 0x0700, 0xf936, 0x0000 },

-  { 0x8700, 0xf93b, 0x3000 },

-  { 0x8700, 0xf939, 0x2000 },

-  { 0x0700, 0xf938, 0x0000 },

-  { 0x0700, 0xf93a, 0x0000 },

-  { 0x8700, 0xf93d, 0x2000 },

-  { 0x0700, 0xf93c, 0x0000 },

-  { 0x0700, 0xf93e, 0x0000 },

-  { 0x8700, 0xf95f, 0x6000 },

-  { 0x8700, 0xf94f, 0x5000 },

-  { 0x8700, 0xf947, 0x4000 },

-  { 0x8700, 0xf943, 0x3000 },

-  { 0x8700, 0xf941, 0x2000 },

-  { 0x0700, 0xf940, 0x0000 },

-  { 0x0700, 0xf942, 0x0000 },

-  { 0x8700, 0xf945, 0x2000 },

-  { 0x0700, 0xf944, 0x0000 },

-  { 0x0700, 0xf946, 0x0000 },

-  { 0x8700, 0xf94b, 0x3000 },

-  { 0x8700, 0xf949, 0x2000 },

-  { 0x0700, 0xf948, 0x0000 },

-  { 0x0700, 0xf94a, 0x0000 },

-  { 0x8700, 0xf94d, 0x2000 },

-  { 0x0700, 0xf94c, 0x0000 },

-  { 0x0700, 0xf94e, 0x0000 },

-  { 0x8700, 0xf957, 0x4000 },

-  { 0x8700, 0xf953, 0x3000 },

-  { 0x8700, 0xf951, 0x2000 },

-  { 0x0700, 0xf950, 0x0000 },

-  { 0x0700, 0xf952, 0x0000 },

-  { 0x8700, 0xf955, 0x2000 },

-  { 0x0700, 0xf954, 0x0000 },

-  { 0x0700, 0xf956, 0x0000 },

-  { 0x8700, 0xf95b, 0x3000 },

-  { 0x8700, 0xf959, 0x2000 },

-  { 0x0700, 0xf958, 0x0000 },

-  { 0x0700, 0xf95a, 0x0000 },

-  { 0x8700, 0xf95d, 0x2000 },

-  { 0x0700, 0xf95c, 0x0000 },

-  { 0x0700, 0xf95e, 0x0000 },

-  { 0x8700, 0xf96f, 0x5000 },

-  { 0x8700, 0xf967, 0x4000 },

-  { 0x8700, 0xf963, 0x3000 },

-  { 0x8700, 0xf961, 0x2000 },

-  { 0x0700, 0xf960, 0x0000 },

-  { 0x0700, 0xf962, 0x0000 },

-  { 0x8700, 0xf965, 0x2000 },

-  { 0x0700, 0xf964, 0x0000 },

-  { 0x0700, 0xf966, 0x0000 },

-  { 0x8700, 0xf96b, 0x3000 },

-  { 0x8700, 0xf969, 0x2000 },

-  { 0x0700, 0xf968, 0x0000 },

-  { 0x0700, 0xf96a, 0x0000 },

-  { 0x8700, 0xf96d, 0x2000 },

-  { 0x0700, 0xf96c, 0x0000 },

-  { 0x0700, 0xf96e, 0x0000 },

-  { 0x8700, 0xf977, 0x4000 },

-  { 0x8700, 0xf973, 0x3000 },

-  { 0x8700, 0xf971, 0x2000 },

-  { 0x0700, 0xf970, 0x0000 },

-  { 0x0700, 0xf972, 0x0000 },

-  { 0x8700, 0xf975, 0x2000 },

-  { 0x0700, 0xf974, 0x0000 },

-  { 0x0700, 0xf976, 0x0000 },

-  { 0x8700, 0xf97b, 0x3000 },

-  { 0x8700, 0xf979, 0x2000 },

-  { 0x0700, 0xf978, 0x0000 },

-  { 0x0700, 0xf97a, 0x0000 },

-  { 0x8700, 0xf97d, 0x2000 },

-  { 0x0700, 0xf97c, 0x0000 },

-  { 0x0700, 0xf97e, 0x0000 },

-  { 0x8700, 0xfb27, 0x9000 },

-  { 0x8700, 0xf9ff, 0x8000 },

-  { 0x8700, 0xf9bf, 0x7000 },

-  { 0x8700, 0xf99f, 0x6000 },

-  { 0x8700, 0xf98f, 0x5000 },

-  { 0x8700, 0xf987, 0x4000 },

-  { 0x8700, 0xf983, 0x3000 },

-  { 0x8700, 0xf981, 0x2000 },

-  { 0x0700, 0xf980, 0x0000 },

-  { 0x0700, 0xf982, 0x0000 },

-  { 0x8700, 0xf985, 0x2000 },

-  { 0x0700, 0xf984, 0x0000 },

-  { 0x0700, 0xf986, 0x0000 },

-  { 0x8700, 0xf98b, 0x3000 },

-  { 0x8700, 0xf989, 0x2000 },

-  { 0x0700, 0xf988, 0x0000 },

-  { 0x0700, 0xf98a, 0x0000 },

-  { 0x8700, 0xf98d, 0x2000 },

-  { 0x0700, 0xf98c, 0x0000 },

-  { 0x0700, 0xf98e, 0x0000 },

-  { 0x8700, 0xf997, 0x4000 },

-  { 0x8700, 0xf993, 0x3000 },

-  { 0x8700, 0xf991, 0x2000 },

-  { 0x0700, 0xf990, 0x0000 },

-  { 0x0700, 0xf992, 0x0000 },

-  { 0x8700, 0xf995, 0x2000 },

-  { 0x0700, 0xf994, 0x0000 },

-  { 0x0700, 0xf996, 0x0000 },

-  { 0x8700, 0xf99b, 0x3000 },

-  { 0x8700, 0xf999, 0x2000 },

-  { 0x0700, 0xf998, 0x0000 },

-  { 0x0700, 0xf99a, 0x0000 },

-  { 0x8700, 0xf99d, 0x2000 },

-  { 0x0700, 0xf99c, 0x0000 },

-  { 0x0700, 0xf99e, 0x0000 },

-  { 0x8700, 0xf9af, 0x5000 },

-  { 0x8700, 0xf9a7, 0x4000 },

-  { 0x8700, 0xf9a3, 0x3000 },

-  { 0x8700, 0xf9a1, 0x2000 },

-  { 0x0700, 0xf9a0, 0x0000 },

-  { 0x0700, 0xf9a2, 0x0000 },

-  { 0x8700, 0xf9a5, 0x2000 },

-  { 0x0700, 0xf9a4, 0x0000 },

-  { 0x0700, 0xf9a6, 0x0000 },

-  { 0x8700, 0xf9ab, 0x3000 },

-  { 0x8700, 0xf9a9, 0x2000 },

-  { 0x0700, 0xf9a8, 0x0000 },

-  { 0x0700, 0xf9aa, 0x0000 },

-  { 0x8700, 0xf9ad, 0x2000 },

-  { 0x0700, 0xf9ac, 0x0000 },

-  { 0x0700, 0xf9ae, 0x0000 },

-  { 0x8700, 0xf9b7, 0x4000 },

-  { 0x8700, 0xf9b3, 0x3000 },

-  { 0x8700, 0xf9b1, 0x2000 },

-  { 0x0700, 0xf9b0, 0x0000 },

-  { 0x0700, 0xf9b2, 0x0000 },

-  { 0x8700, 0xf9b5, 0x2000 },

-  { 0x0700, 0xf9b4, 0x0000 },

-  { 0x0700, 0xf9b6, 0x0000 },

-  { 0x8700, 0xf9bb, 0x3000 },

-  { 0x8700, 0xf9b9, 0x2000 },

-  { 0x0700, 0xf9b8, 0x0000 },

-  { 0x0700, 0xf9ba, 0x0000 },

-  { 0x8700, 0xf9bd, 0x2000 },

-  { 0x0700, 0xf9bc, 0x0000 },

-  { 0x0700, 0xf9be, 0x0000 },

-  { 0x8700, 0xf9df, 0x6000 },

-  { 0x8700, 0xf9cf, 0x5000 },

-  { 0x8700, 0xf9c7, 0x4000 },

-  { 0x8700, 0xf9c3, 0x3000 },

-  { 0x8700, 0xf9c1, 0x2000 },

-  { 0x0700, 0xf9c0, 0x0000 },

-  { 0x0700, 0xf9c2, 0x0000 },

-  { 0x8700, 0xf9c5, 0x2000 },

-  { 0x0700, 0xf9c4, 0x0000 },

-  { 0x0700, 0xf9c6, 0x0000 },

-  { 0x8700, 0xf9cb, 0x3000 },

-  { 0x8700, 0xf9c9, 0x2000 },

-  { 0x0700, 0xf9c8, 0x0000 },

-  { 0x0700, 0xf9ca, 0x0000 },

-  { 0x8700, 0xf9cd, 0x2000 },

-  { 0x0700, 0xf9cc, 0x0000 },

-  { 0x0700, 0xf9ce, 0x0000 },

-  { 0x8700, 0xf9d7, 0x4000 },

-  { 0x8700, 0xf9d3, 0x3000 },

-  { 0x8700, 0xf9d1, 0x2000 },

-  { 0x0700, 0xf9d0, 0x0000 },

-  { 0x0700, 0xf9d2, 0x0000 },

-  { 0x8700, 0xf9d5, 0x2000 },

-  { 0x0700, 0xf9d4, 0x0000 },

-  { 0x0700, 0xf9d6, 0x0000 },

-  { 0x8700, 0xf9db, 0x3000 },

-  { 0x8700, 0xf9d9, 0x2000 },

-  { 0x0700, 0xf9d8, 0x0000 },

-  { 0x0700, 0xf9da, 0x0000 },

-  { 0x8700, 0xf9dd, 0x2000 },

-  { 0x0700, 0xf9dc, 0x0000 },

-  { 0x0700, 0xf9de, 0x0000 },

-  { 0x8700, 0xf9ef, 0x5000 },

-  { 0x8700, 0xf9e7, 0x4000 },

-  { 0x8700, 0xf9e3, 0x3000 },

-  { 0x8700, 0xf9e1, 0x2000 },

-  { 0x0700, 0xf9e0, 0x0000 },

-  { 0x0700, 0xf9e2, 0x0000 },

-  { 0x8700, 0xf9e5, 0x2000 },

-  { 0x0700, 0xf9e4, 0x0000 },

-  { 0x0700, 0xf9e6, 0x0000 },

-  { 0x8700, 0xf9eb, 0x3000 },

-  { 0x8700, 0xf9e9, 0x2000 },

-  { 0x0700, 0xf9e8, 0x0000 },

-  { 0x0700, 0xf9ea, 0x0000 },

-  { 0x8700, 0xf9ed, 0x2000 },

-  { 0x0700, 0xf9ec, 0x0000 },

-  { 0x0700, 0xf9ee, 0x0000 },

-  { 0x8700, 0xf9f7, 0x4000 },

-  { 0x8700, 0xf9f3, 0x3000 },

-  { 0x8700, 0xf9f1, 0x2000 },

-  { 0x0700, 0xf9f0, 0x0000 },

-  { 0x0700, 0xf9f2, 0x0000 },

-  { 0x8700, 0xf9f5, 0x2000 },

-  { 0x0700, 0xf9f4, 0x0000 },

-  { 0x0700, 0xf9f6, 0x0000 },

-  { 0x8700, 0xf9fb, 0x3000 },

-  { 0x8700, 0xf9f9, 0x2000 },

-  { 0x0700, 0xf9f8, 0x0000 },

-  { 0x0700, 0xf9fa, 0x0000 },

-  { 0x8700, 0xf9fd, 0x2000 },

-  { 0x0700, 0xf9fc, 0x0000 },

-  { 0x0700, 0xf9fe, 0x0000 },

-  { 0x8700, 0xfa41, 0x7000 },

-  { 0x8700, 0xfa1f, 0x6000 },

-  { 0x8700, 0xfa0f, 0x5000 },

-  { 0x8700, 0xfa07, 0x4000 },

-  { 0x8700, 0xfa03, 0x3000 },

-  { 0x8700, 0xfa01, 0x2000 },

-  { 0x0700, 0xfa00, 0x0000 },

-  { 0x0700, 0xfa02, 0x0000 },

-  { 0x8700, 0xfa05, 0x2000 },

-  { 0x0700, 0xfa04, 0x0000 },

-  { 0x0700, 0xfa06, 0x0000 },

-  { 0x8700, 0xfa0b, 0x3000 },

-  { 0x8700, 0xfa09, 0x2000 },

-  { 0x0700, 0xfa08, 0x0000 },

-  { 0x0700, 0xfa0a, 0x0000 },

-  { 0x8700, 0xfa0d, 0x2000 },

-  { 0x0700, 0xfa0c, 0x0000 },

-  { 0x0700, 0xfa0e, 0x0000 },

-  { 0x8700, 0xfa17, 0x4000 },

-  { 0x8700, 0xfa13, 0x3000 },

-  { 0x8700, 0xfa11, 0x2000 },

-  { 0x0700, 0xfa10, 0x0000 },

-  { 0x0700, 0xfa12, 0x0000 },

-  { 0x8700, 0xfa15, 0x2000 },

-  { 0x0700, 0xfa14, 0x0000 },

-  { 0x0700, 0xfa16, 0x0000 },

-  { 0x8700, 0xfa1b, 0x3000 },

-  { 0x8700, 0xfa19, 0x2000 },

-  { 0x0700, 0xfa18, 0x0000 },

-  { 0x0700, 0xfa1a, 0x0000 },

-  { 0x8700, 0xfa1d, 0x2000 },

-  { 0x0700, 0xfa1c, 0x0000 },

-  { 0x0700, 0xfa1e, 0x0000 },

-  { 0x8700, 0xfa31, 0x5000 },

-  { 0x8700, 0xfa27, 0x4000 },

-  { 0x8700, 0xfa23, 0x3000 },

-  { 0x8700, 0xfa21, 0x2000 },

-  { 0x0700, 0xfa20, 0x0000 },

-  { 0x0700, 0xfa22, 0x0000 },

-  { 0x8700, 0xfa25, 0x2000 },

-  { 0x0700, 0xfa24, 0x0000 },

-  { 0x0700, 0xfa26, 0x0000 },

-  { 0x8700, 0xfa2b, 0x3000 },

-  { 0x8700, 0xfa29, 0x2000 },

-  { 0x0700, 0xfa28, 0x0000 },

-  { 0x0700, 0xfa2a, 0x0000 },

-  { 0x8700, 0xfa2d, 0x2000 },

-  { 0x0700, 0xfa2c, 0x0000 },

-  { 0x0700, 0xfa30, 0x0000 },

-  { 0x8700, 0xfa39, 0x4000 },

-  { 0x8700, 0xfa35, 0x3000 },

-  { 0x8700, 0xfa33, 0x2000 },

-  { 0x0700, 0xfa32, 0x0000 },

-  { 0x0700, 0xfa34, 0x0000 },

-  { 0x8700, 0xfa37, 0x2000 },

-  { 0x0700, 0xfa36, 0x0000 },

-  { 0x0700, 0xfa38, 0x0000 },

-  { 0x8700, 0xfa3d, 0x3000 },

-  { 0x8700, 0xfa3b, 0x2000 },

-  { 0x0700, 0xfa3a, 0x0000 },

-  { 0x0700, 0xfa3c, 0x0000 },

-  { 0x8700, 0xfa3f, 0x2000 },

-  { 0x0700, 0xfa3e, 0x0000 },

-  { 0x0700, 0xfa40, 0x0000 },

-  { 0x8700, 0xfa61, 0x6000 },

-  { 0x8700, 0xfa51, 0x5000 },

-  { 0x8700, 0xfa49, 0x4000 },

-  { 0x8700, 0xfa45, 0x3000 },

-  { 0x8700, 0xfa43, 0x2000 },

-  { 0x0700, 0xfa42, 0x0000 },

-  { 0x0700, 0xfa44, 0x0000 },

-  { 0x8700, 0xfa47, 0x2000 },

-  { 0x0700, 0xfa46, 0x0000 },

-  { 0x0700, 0xfa48, 0x0000 },

-  { 0x8700, 0xfa4d, 0x3000 },

-  { 0x8700, 0xfa4b, 0x2000 },

-  { 0x0700, 0xfa4a, 0x0000 },

-  { 0x0700, 0xfa4c, 0x0000 },

-  { 0x8700, 0xfa4f, 0x2000 },

-  { 0x0700, 0xfa4e, 0x0000 },

-  { 0x0700, 0xfa50, 0x0000 },

-  { 0x8700, 0xfa59, 0x4000 },

-  { 0x8700, 0xfa55, 0x3000 },

-  { 0x8700, 0xfa53, 0x2000 },

-  { 0x0700, 0xfa52, 0x0000 },

-  { 0x0700, 0xfa54, 0x0000 },

-  { 0x8700, 0xfa57, 0x2000 },

-  { 0x0700, 0xfa56, 0x0000 },

-  { 0x0700, 0xfa58, 0x0000 },

-  { 0x8700, 0xfa5d, 0x3000 },

-  { 0x8700, 0xfa5b, 0x2000 },

-  { 0x0700, 0xfa5a, 0x0000 },

-  { 0x0700, 0xfa5c, 0x0000 },

-  { 0x8700, 0xfa5f, 0x2000 },

-  { 0x0700, 0xfa5e, 0x0000 },

-  { 0x0700, 0xfa60, 0x0000 },

-  { 0x8500, 0xfb06, 0x5000 },

-  { 0x8700, 0xfa69, 0x4000 },

-  { 0x8700, 0xfa65, 0x3000 },

-  { 0x8700, 0xfa63, 0x2000 },

-  { 0x0700, 0xfa62, 0x0000 },

-  { 0x0700, 0xfa64, 0x0000 },

-  { 0x8700, 0xfa67, 0x2000 },

-  { 0x0700, 0xfa66, 0x0000 },

-  { 0x0700, 0xfa68, 0x0000 },

-  { 0x8500, 0xfb02, 0x3000 },

-  { 0x8500, 0xfb00, 0x2000 },

-  { 0x0700, 0xfa6a, 0x0000 },

-  { 0x0500, 0xfb01, 0x0000 },

-  { 0x8500, 0xfb04, 0x2000 },

-  { 0x0500, 0xfb03, 0x0000 },

-  { 0x0500, 0xfb05, 0x0000 },

-  { 0x8700, 0xfb1f, 0x4000 },

-  { 0x8500, 0xfb16, 0x3000 },

-  { 0x8500, 0xfb14, 0x2000 },

-  { 0x0500, 0xfb13, 0x0000 },

-  { 0x0500, 0xfb15, 0x0000 },

-  { 0x8700, 0xfb1d, 0x2000 },

-  { 0x0500, 0xfb17, 0x0000 },

-  { 0x0c00, 0xfb1e, 0x0000 },

-  { 0x8700, 0xfb23, 0x3000 },

-  { 0x8700, 0xfb21, 0x2000 },

-  { 0x0700, 0xfb20, 0x0000 },

-  { 0x0700, 0xfb22, 0x0000 },

-  { 0x8700, 0xfb25, 0x2000 },

-  { 0x0700, 0xfb24, 0x0000 },

-  { 0x0700, 0xfb26, 0x0000 },

-  { 0x8700, 0xfbac, 0x8000 },

-  { 0x8700, 0xfb6c, 0x7000 },

-  { 0x8700, 0xfb4c, 0x6000 },

-  { 0x8700, 0xfb38, 0x5000 },

-  { 0x8700, 0xfb2f, 0x4000 },

-  { 0x8700, 0xfb2b, 0x3000 },

-  { 0x9900, 0xfb29, 0x2000 },

-  { 0x0700, 0xfb28, 0x0000 },

-  { 0x0700, 0xfb2a, 0x0000 },

-  { 0x8700, 0xfb2d, 0x2000 },

-  { 0x0700, 0xfb2c, 0x0000 },

-  { 0x0700, 0xfb2e, 0x0000 },

-  { 0x8700, 0xfb33, 0x3000 },

-  { 0x8700, 0xfb31, 0x2000 },

-  { 0x0700, 0xfb30, 0x0000 },

-  { 0x0700, 0xfb32, 0x0000 },

-  { 0x8700, 0xfb35, 0x2000 },

-  { 0x0700, 0xfb34, 0x0000 },

-  { 0x0700, 0xfb36, 0x0000 },

-  { 0x8700, 0xfb43, 0x4000 },

-  { 0x8700, 0xfb3c, 0x3000 },

-  { 0x8700, 0xfb3a, 0x2000 },

-  { 0x0700, 0xfb39, 0x0000 },

-  { 0x0700, 0xfb3b, 0x0000 },

-  { 0x8700, 0xfb40, 0x2000 },

-  { 0x0700, 0xfb3e, 0x0000 },

-  { 0x0700, 0xfb41, 0x0000 },

-  { 0x8700, 0xfb48, 0x3000 },

-  { 0x8700, 0xfb46, 0x2000 },

-  { 0x0700, 0xfb44, 0x0000 },

-  { 0x0700, 0xfb47, 0x0000 },

-  { 0x8700, 0xfb4a, 0x2000 },

-  { 0x0700, 0xfb49, 0x0000 },

-  { 0x0700, 0xfb4b, 0x0000 },

-  { 0x8700, 0xfb5c, 0x5000 },

-  { 0x8700, 0xfb54, 0x4000 },

-  { 0x8700, 0xfb50, 0x3000 },

-  { 0x8700, 0xfb4e, 0x2000 },

-  { 0x0700, 0xfb4d, 0x0000 },

-  { 0x0700, 0xfb4f, 0x0000 },

-  { 0x8700, 0xfb52, 0x2000 },

-  { 0x0700, 0xfb51, 0x0000 },

-  { 0x0700, 0xfb53, 0x0000 },

-  { 0x8700, 0xfb58, 0x3000 },

-  { 0x8700, 0xfb56, 0x2000 },

-  { 0x0700, 0xfb55, 0x0000 },

-  { 0x0700, 0xfb57, 0x0000 },

-  { 0x8700, 0xfb5a, 0x2000 },

-  { 0x0700, 0xfb59, 0x0000 },

-  { 0x0700, 0xfb5b, 0x0000 },

-  { 0x8700, 0xfb64, 0x4000 },

-  { 0x8700, 0xfb60, 0x3000 },

-  { 0x8700, 0xfb5e, 0x2000 },

-  { 0x0700, 0xfb5d, 0x0000 },

-  { 0x0700, 0xfb5f, 0x0000 },

-  { 0x8700, 0xfb62, 0x2000 },

-  { 0x0700, 0xfb61, 0x0000 },

-  { 0x0700, 0xfb63, 0x0000 },

-  { 0x8700, 0xfb68, 0x3000 },

-  { 0x8700, 0xfb66, 0x2000 },

-  { 0x0700, 0xfb65, 0x0000 },

-  { 0x0700, 0xfb67, 0x0000 },

-  { 0x8700, 0xfb6a, 0x2000 },

-  { 0x0700, 0xfb69, 0x0000 },

-  { 0x0700, 0xfb6b, 0x0000 },

-  { 0x8700, 0xfb8c, 0x6000 },

-  { 0x8700, 0xfb7c, 0x5000 },

-  { 0x8700, 0xfb74, 0x4000 },

-  { 0x8700, 0xfb70, 0x3000 },

-  { 0x8700, 0xfb6e, 0x2000 },

-  { 0x0700, 0xfb6d, 0x0000 },

-  { 0x0700, 0xfb6f, 0x0000 },

-  { 0x8700, 0xfb72, 0x2000 },

-  { 0x0700, 0xfb71, 0x0000 },

-  { 0x0700, 0xfb73, 0x0000 },

-  { 0x8700, 0xfb78, 0x3000 },

-  { 0x8700, 0xfb76, 0x2000 },

-  { 0x0700, 0xfb75, 0x0000 },

-  { 0x0700, 0xfb77, 0x0000 },

-  { 0x8700, 0xfb7a, 0x2000 },

-  { 0x0700, 0xfb79, 0x0000 },

-  { 0x0700, 0xfb7b, 0x0000 },

-  { 0x8700, 0xfb84, 0x4000 },

-  { 0x8700, 0xfb80, 0x3000 },

-  { 0x8700, 0xfb7e, 0x2000 },

-  { 0x0700, 0xfb7d, 0x0000 },

-  { 0x0700, 0xfb7f, 0x0000 },

-  { 0x8700, 0xfb82, 0x2000 },

-  { 0x0700, 0xfb81, 0x0000 },

-  { 0x0700, 0xfb83, 0x0000 },

-  { 0x8700, 0xfb88, 0x3000 },

-  { 0x8700, 0xfb86, 0x2000 },

-  { 0x0700, 0xfb85, 0x0000 },

-  { 0x0700, 0xfb87, 0x0000 },

-  { 0x8700, 0xfb8a, 0x2000 },

-  { 0x0700, 0xfb89, 0x0000 },

-  { 0x0700, 0xfb8b, 0x0000 },

-  { 0x8700, 0xfb9c, 0x5000 },

-  { 0x8700, 0xfb94, 0x4000 },

-  { 0x8700, 0xfb90, 0x3000 },

-  { 0x8700, 0xfb8e, 0x2000 },

-  { 0x0700, 0xfb8d, 0x0000 },

-  { 0x0700, 0xfb8f, 0x0000 },

-  { 0x8700, 0xfb92, 0x2000 },

-  { 0x0700, 0xfb91, 0x0000 },

-  { 0x0700, 0xfb93, 0x0000 },

-  { 0x8700, 0xfb98, 0x3000 },

-  { 0x8700, 0xfb96, 0x2000 },

-  { 0x0700, 0xfb95, 0x0000 },

-  { 0x0700, 0xfb97, 0x0000 },

-  { 0x8700, 0xfb9a, 0x2000 },

-  { 0x0700, 0xfb99, 0x0000 },

-  { 0x0700, 0xfb9b, 0x0000 },

-  { 0x8700, 0xfba4, 0x4000 },

-  { 0x8700, 0xfba0, 0x3000 },

-  { 0x8700, 0xfb9e, 0x2000 },

-  { 0x0700, 0xfb9d, 0x0000 },

-  { 0x0700, 0xfb9f, 0x0000 },

-  { 0x8700, 0xfba2, 0x2000 },

-  { 0x0700, 0xfba1, 0x0000 },

-  { 0x0700, 0xfba3, 0x0000 },

-  { 0x8700, 0xfba8, 0x3000 },

-  { 0x8700, 0xfba6, 0x2000 },

-  { 0x0700, 0xfba5, 0x0000 },

-  { 0x0700, 0xfba7, 0x0000 },

-  { 0x8700, 0xfbaa, 0x2000 },

-  { 0x0700, 0xfba9, 0x0000 },

-  { 0x0700, 0xfbab, 0x0000 },

-  { 0x8700, 0xfc0d, 0x7000 },

-  { 0x8700, 0xfbed, 0x6000 },

-  { 0x8700, 0xfbdd, 0x5000 },

-  { 0x8700, 0xfbd5, 0x4000 },

-  { 0x8700, 0xfbb0, 0x3000 },

-  { 0x8700, 0xfbae, 0x2000 },

-  { 0x0700, 0xfbad, 0x0000 },

-  { 0x0700, 0xfbaf, 0x0000 },

-  { 0x8700, 0xfbd3, 0x2000 },

-  { 0x0700, 0xfbb1, 0x0000 },

-  { 0x0700, 0xfbd4, 0x0000 },

-  { 0x8700, 0xfbd9, 0x3000 },

-  { 0x8700, 0xfbd7, 0x2000 },

-  { 0x0700, 0xfbd6, 0x0000 },

-  { 0x0700, 0xfbd8, 0x0000 },

-  { 0x8700, 0xfbdb, 0x2000 },

-  { 0x0700, 0xfbda, 0x0000 },

-  { 0x0700, 0xfbdc, 0x0000 },

-  { 0x8700, 0xfbe5, 0x4000 },

-  { 0x8700, 0xfbe1, 0x3000 },

-  { 0x8700, 0xfbdf, 0x2000 },

-  { 0x0700, 0xfbde, 0x0000 },

-  { 0x0700, 0xfbe0, 0x0000 },

-  { 0x8700, 0xfbe3, 0x2000 },

-  { 0x0700, 0xfbe2, 0x0000 },

-  { 0x0700, 0xfbe4, 0x0000 },

-  { 0x8700, 0xfbe9, 0x3000 },

-  { 0x8700, 0xfbe7, 0x2000 },

-  { 0x0700, 0xfbe6, 0x0000 },

-  { 0x0700, 0xfbe8, 0x0000 },

-  { 0x8700, 0xfbeb, 0x2000 },

-  { 0x0700, 0xfbea, 0x0000 },

-  { 0x0700, 0xfbec, 0x0000 },

-  { 0x8700, 0xfbfd, 0x5000 },

-  { 0x8700, 0xfbf5, 0x4000 },

-  { 0x8700, 0xfbf1, 0x3000 },

-  { 0x8700, 0xfbef, 0x2000 },

-  { 0x0700, 0xfbee, 0x0000 },

-  { 0x0700, 0xfbf0, 0x0000 },

-  { 0x8700, 0xfbf3, 0x2000 },

-  { 0x0700, 0xfbf2, 0x0000 },

-  { 0x0700, 0xfbf4, 0x0000 },

-  { 0x8700, 0xfbf9, 0x3000 },

-  { 0x8700, 0xfbf7, 0x2000 },

-  { 0x0700, 0xfbf6, 0x0000 },

-  { 0x0700, 0xfbf8, 0x0000 },

-  { 0x8700, 0xfbfb, 0x2000 },

-  { 0x0700, 0xfbfa, 0x0000 },

-  { 0x0700, 0xfbfc, 0x0000 },

-  { 0x8700, 0xfc05, 0x4000 },

-  { 0x8700, 0xfc01, 0x3000 },

-  { 0x8700, 0xfbff, 0x2000 },

-  { 0x0700, 0xfbfe, 0x0000 },

-  { 0x0700, 0xfc00, 0x0000 },

-  { 0x8700, 0xfc03, 0x2000 },

-  { 0x0700, 0xfc02, 0x0000 },

-  { 0x0700, 0xfc04, 0x0000 },

-  { 0x8700, 0xfc09, 0x3000 },

-  { 0x8700, 0xfc07, 0x2000 },

-  { 0x0700, 0xfc06, 0x0000 },

-  { 0x0700, 0xfc08, 0x0000 },

-  { 0x8700, 0xfc0b, 0x2000 },

-  { 0x0700, 0xfc0a, 0x0000 },

-  { 0x0700, 0xfc0c, 0x0000 },

-  { 0x8700, 0xfc2d, 0x6000 },

-  { 0x8700, 0xfc1d, 0x5000 },

-  { 0x8700, 0xfc15, 0x4000 },

-  { 0x8700, 0xfc11, 0x3000 },

-  { 0x8700, 0xfc0f, 0x2000 },

-  { 0x0700, 0xfc0e, 0x0000 },

-  { 0x0700, 0xfc10, 0x0000 },

-  { 0x8700, 0xfc13, 0x2000 },

-  { 0x0700, 0xfc12, 0x0000 },

-  { 0x0700, 0xfc14, 0x0000 },

-  { 0x8700, 0xfc19, 0x3000 },

-  { 0x8700, 0xfc17, 0x2000 },

-  { 0x0700, 0xfc16, 0x0000 },

-  { 0x0700, 0xfc18, 0x0000 },

-  { 0x8700, 0xfc1b, 0x2000 },

-  { 0x0700, 0xfc1a, 0x0000 },

-  { 0x0700, 0xfc1c, 0x0000 },

-  { 0x8700, 0xfc25, 0x4000 },

-  { 0x8700, 0xfc21, 0x3000 },

-  { 0x8700, 0xfc1f, 0x2000 },

-  { 0x0700, 0xfc1e, 0x0000 },

-  { 0x0700, 0xfc20, 0x0000 },

-  { 0x8700, 0xfc23, 0x2000 },

-  { 0x0700, 0xfc22, 0x0000 },

-  { 0x0700, 0xfc24, 0x0000 },

-  { 0x8700, 0xfc29, 0x3000 },

-  { 0x8700, 0xfc27, 0x2000 },

-  { 0x0700, 0xfc26, 0x0000 },

-  { 0x0700, 0xfc28, 0x0000 },

-  { 0x8700, 0xfc2b, 0x2000 },

-  { 0x0700, 0xfc2a, 0x0000 },

-  { 0x0700, 0xfc2c, 0x0000 },

-  { 0x8700, 0xfc3d, 0x5000 },

-  { 0x8700, 0xfc35, 0x4000 },

-  { 0x8700, 0xfc31, 0x3000 },

-  { 0x8700, 0xfc2f, 0x2000 },

-  { 0x0700, 0xfc2e, 0x0000 },

-  { 0x0700, 0xfc30, 0x0000 },

-  { 0x8700, 0xfc33, 0x2000 },

-  { 0x0700, 0xfc32, 0x0000 },

-  { 0x0700, 0xfc34, 0x0000 },

-  { 0x8700, 0xfc39, 0x3000 },

-  { 0x8700, 0xfc37, 0x2000 },

-  { 0x0700, 0xfc36, 0x0000 },

-  { 0x0700, 0xfc38, 0x0000 },

-  { 0x8700, 0xfc3b, 0x2000 },

-  { 0x0700, 0xfc3a, 0x0000 },

-  { 0x0700, 0xfc3c, 0x0000 },

-  { 0x8700, 0xfc45, 0x4000 },

-  { 0x8700, 0xfc41, 0x3000 },

-  { 0x8700, 0xfc3f, 0x2000 },

-  { 0x0700, 0xfc3e, 0x0000 },

-  { 0x0700, 0xfc40, 0x0000 },

-  { 0x8700, 0xfc43, 0x2000 },

-  { 0x0700, 0xfc42, 0x0000 },

-  { 0x0700, 0xfc44, 0x0000 },

-  { 0x8700, 0xfc49, 0x3000 },

-  { 0x8700, 0xfc47, 0x2000 },

-  { 0x0700, 0xfc46, 0x0000 },

-  { 0x0700, 0xfc48, 0x0000 },

-  { 0x8700, 0xfc4b, 0x2000 },

-  { 0x0700, 0xfc4a, 0x0000 },

-  { 0x0700, 0xfc4c, 0x0000 },

-  { 0x8700, 0xfeac, 0xa000 },

-  { 0x8700, 0xfd5d, 0x9000 },

-  { 0x8700, 0xfccd, 0x8000 },

-  { 0x8700, 0xfc8d, 0x7000 },

-  { 0x8700, 0xfc6d, 0x6000 },

-  { 0x8700, 0xfc5d, 0x5000 },

-  { 0x8700, 0xfc55, 0x4000 },

-  { 0x8700, 0xfc51, 0x3000 },

-  { 0x8700, 0xfc4f, 0x2000 },

-  { 0x0700, 0xfc4e, 0x0000 },

-  { 0x0700, 0xfc50, 0x0000 },

-  { 0x8700, 0xfc53, 0x2000 },

-  { 0x0700, 0xfc52, 0x0000 },

-  { 0x0700, 0xfc54, 0x0000 },

-  { 0x8700, 0xfc59, 0x3000 },

-  { 0x8700, 0xfc57, 0x2000 },

-  { 0x0700, 0xfc56, 0x0000 },

-  { 0x0700, 0xfc58, 0x0000 },

-  { 0x8700, 0xfc5b, 0x2000 },

-  { 0x0700, 0xfc5a, 0x0000 },

-  { 0x0700, 0xfc5c, 0x0000 },

-  { 0x8700, 0xfc65, 0x4000 },

-  { 0x8700, 0xfc61, 0x3000 },

-  { 0x8700, 0xfc5f, 0x2000 },

-  { 0x0700, 0xfc5e, 0x0000 },

-  { 0x0700, 0xfc60, 0x0000 },

-  { 0x8700, 0xfc63, 0x2000 },

-  { 0x0700, 0xfc62, 0x0000 },

-  { 0x0700, 0xfc64, 0x0000 },

-  { 0x8700, 0xfc69, 0x3000 },

-  { 0x8700, 0xfc67, 0x2000 },

-  { 0x0700, 0xfc66, 0x0000 },

-  { 0x0700, 0xfc68, 0x0000 },

-  { 0x8700, 0xfc6b, 0x2000 },

-  { 0x0700, 0xfc6a, 0x0000 },

-  { 0x0700, 0xfc6c, 0x0000 },

-  { 0x8700, 0xfc7d, 0x5000 },

-  { 0x8700, 0xfc75, 0x4000 },

-  { 0x8700, 0xfc71, 0x3000 },

-  { 0x8700, 0xfc6f, 0x2000 },

-  { 0x0700, 0xfc6e, 0x0000 },

-  { 0x0700, 0xfc70, 0x0000 },

-  { 0x8700, 0xfc73, 0x2000 },

-  { 0x0700, 0xfc72, 0x0000 },

-  { 0x0700, 0xfc74, 0x0000 },

-  { 0x8700, 0xfc79, 0x3000 },

-  { 0x8700, 0xfc77, 0x2000 },

-  { 0x0700, 0xfc76, 0x0000 },

-  { 0x0700, 0xfc78, 0x0000 },

-  { 0x8700, 0xfc7b, 0x2000 },

-  { 0x0700, 0xfc7a, 0x0000 },

-  { 0x0700, 0xfc7c, 0x0000 },

-  { 0x8700, 0xfc85, 0x4000 },

-  { 0x8700, 0xfc81, 0x3000 },

-  { 0x8700, 0xfc7f, 0x2000 },

-  { 0x0700, 0xfc7e, 0x0000 },

-  { 0x0700, 0xfc80, 0x0000 },

-  { 0x8700, 0xfc83, 0x2000 },

-  { 0x0700, 0xfc82, 0x0000 },

-  { 0x0700, 0xfc84, 0x0000 },

-  { 0x8700, 0xfc89, 0x3000 },

-  { 0x8700, 0xfc87, 0x2000 },

-  { 0x0700, 0xfc86, 0x0000 },

-  { 0x0700, 0xfc88, 0x0000 },

-  { 0x8700, 0xfc8b, 0x2000 },

-  { 0x0700, 0xfc8a, 0x0000 },

-  { 0x0700, 0xfc8c, 0x0000 },

-  { 0x8700, 0xfcad, 0x6000 },

-  { 0x8700, 0xfc9d, 0x5000 },

-  { 0x8700, 0xfc95, 0x4000 },

-  { 0x8700, 0xfc91, 0x3000 },

-  { 0x8700, 0xfc8f, 0x2000 },

-  { 0x0700, 0xfc8e, 0x0000 },

-  { 0x0700, 0xfc90, 0x0000 },

-  { 0x8700, 0xfc93, 0x2000 },

-  { 0x0700, 0xfc92, 0x0000 },

-  { 0x0700, 0xfc94, 0x0000 },

-  { 0x8700, 0xfc99, 0x3000 },

-  { 0x8700, 0xfc97, 0x2000 },

-  { 0x0700, 0xfc96, 0x0000 },

-  { 0x0700, 0xfc98, 0x0000 },

-  { 0x8700, 0xfc9b, 0x2000 },

-  { 0x0700, 0xfc9a, 0x0000 },

-  { 0x0700, 0xfc9c, 0x0000 },

-  { 0x8700, 0xfca5, 0x4000 },

-  { 0x8700, 0xfca1, 0x3000 },

-  { 0x8700, 0xfc9f, 0x2000 },

-  { 0x0700, 0xfc9e, 0x0000 },

-  { 0x0700, 0xfca0, 0x0000 },

-  { 0x8700, 0xfca3, 0x2000 },

-  { 0x0700, 0xfca2, 0x0000 },

-  { 0x0700, 0xfca4, 0x0000 },

-  { 0x8700, 0xfca9, 0x3000 },

-  { 0x8700, 0xfca7, 0x2000 },

-  { 0x0700, 0xfca6, 0x0000 },

-  { 0x0700, 0xfca8, 0x0000 },

-  { 0x8700, 0xfcab, 0x2000 },

-  { 0x0700, 0xfcaa, 0x0000 },

-  { 0x0700, 0xfcac, 0x0000 },

-  { 0x8700, 0xfcbd, 0x5000 },

-  { 0x8700, 0xfcb5, 0x4000 },

-  { 0x8700, 0xfcb1, 0x3000 },

-  { 0x8700, 0xfcaf, 0x2000 },

-  { 0x0700, 0xfcae, 0x0000 },

-  { 0x0700, 0xfcb0, 0x0000 },

-  { 0x8700, 0xfcb3, 0x2000 },

-  { 0x0700, 0xfcb2, 0x0000 },

-  { 0x0700, 0xfcb4, 0x0000 },

-  { 0x8700, 0xfcb9, 0x3000 },

-  { 0x8700, 0xfcb7, 0x2000 },

-  { 0x0700, 0xfcb6, 0x0000 },

-  { 0x0700, 0xfcb8, 0x0000 },

-  { 0x8700, 0xfcbb, 0x2000 },

-  { 0x0700, 0xfcba, 0x0000 },

-  { 0x0700, 0xfcbc, 0x0000 },

-  { 0x8700, 0xfcc5, 0x4000 },

-  { 0x8700, 0xfcc1, 0x3000 },

-  { 0x8700, 0xfcbf, 0x2000 },

-  { 0x0700, 0xfcbe, 0x0000 },

-  { 0x0700, 0xfcc0, 0x0000 },

-  { 0x8700, 0xfcc3, 0x2000 },

-  { 0x0700, 0xfcc2, 0x0000 },

-  { 0x0700, 0xfcc4, 0x0000 },

-  { 0x8700, 0xfcc9, 0x3000 },

-  { 0x8700, 0xfcc7, 0x2000 },

-  { 0x0700, 0xfcc6, 0x0000 },

-  { 0x0700, 0xfcc8, 0x0000 },

-  { 0x8700, 0xfccb, 0x2000 },

-  { 0x0700, 0xfcca, 0x0000 },

-  { 0x0700, 0xfccc, 0x0000 },

-  { 0x8700, 0xfd0d, 0x7000 },

-  { 0x8700, 0xfced, 0x6000 },

-  { 0x8700, 0xfcdd, 0x5000 },

-  { 0x8700, 0xfcd5, 0x4000 },

-  { 0x8700, 0xfcd1, 0x3000 },

-  { 0x8700, 0xfccf, 0x2000 },

-  { 0x0700, 0xfcce, 0x0000 },

-  { 0x0700, 0xfcd0, 0x0000 },

-  { 0x8700, 0xfcd3, 0x2000 },

-  { 0x0700, 0xfcd2, 0x0000 },

-  { 0x0700, 0xfcd4, 0x0000 },

-  { 0x8700, 0xfcd9, 0x3000 },

-  { 0x8700, 0xfcd7, 0x2000 },

-  { 0x0700, 0xfcd6, 0x0000 },

-  { 0x0700, 0xfcd8, 0x0000 },

-  { 0x8700, 0xfcdb, 0x2000 },

-  { 0x0700, 0xfcda, 0x0000 },

-  { 0x0700, 0xfcdc, 0x0000 },

-  { 0x8700, 0xfce5, 0x4000 },

-  { 0x8700, 0xfce1, 0x3000 },

-  { 0x8700, 0xfcdf, 0x2000 },

-  { 0x0700, 0xfcde, 0x0000 },

-  { 0x0700, 0xfce0, 0x0000 },

-  { 0x8700, 0xfce3, 0x2000 },

-  { 0x0700, 0xfce2, 0x0000 },

-  { 0x0700, 0xfce4, 0x0000 },

-  { 0x8700, 0xfce9, 0x3000 },

-  { 0x8700, 0xfce7, 0x2000 },

-  { 0x0700, 0xfce6, 0x0000 },

-  { 0x0700, 0xfce8, 0x0000 },

-  { 0x8700, 0xfceb, 0x2000 },

-  { 0x0700, 0xfcea, 0x0000 },

-  { 0x0700, 0xfcec, 0x0000 },

-  { 0x8700, 0xfcfd, 0x5000 },

-  { 0x8700, 0xfcf5, 0x4000 },

-  { 0x8700, 0xfcf1, 0x3000 },

-  { 0x8700, 0xfcef, 0x2000 },

-  { 0x0700, 0xfcee, 0x0000 },

-  { 0x0700, 0xfcf0, 0x0000 },

-  { 0x8700, 0xfcf3, 0x2000 },

-  { 0x0700, 0xfcf2, 0x0000 },

-  { 0x0700, 0xfcf4, 0x0000 },

-  { 0x8700, 0xfcf9, 0x3000 },

-  { 0x8700, 0xfcf7, 0x2000 },

-  { 0x0700, 0xfcf6, 0x0000 },

-  { 0x0700, 0xfcf8, 0x0000 },

-  { 0x8700, 0xfcfb, 0x2000 },

-  { 0x0700, 0xfcfa, 0x0000 },

-  { 0x0700, 0xfcfc, 0x0000 },

-  { 0x8700, 0xfd05, 0x4000 },

-  { 0x8700, 0xfd01, 0x3000 },

-  { 0x8700, 0xfcff, 0x2000 },

-  { 0x0700, 0xfcfe, 0x0000 },

-  { 0x0700, 0xfd00, 0x0000 },

-  { 0x8700, 0xfd03, 0x2000 },

-  { 0x0700, 0xfd02, 0x0000 },

-  { 0x0700, 0xfd04, 0x0000 },

-  { 0x8700, 0xfd09, 0x3000 },

-  { 0x8700, 0xfd07, 0x2000 },

-  { 0x0700, 0xfd06, 0x0000 },

-  { 0x0700, 0xfd08, 0x0000 },

-  { 0x8700, 0xfd0b, 0x2000 },

-  { 0x0700, 0xfd0a, 0x0000 },

-  { 0x0700, 0xfd0c, 0x0000 },

-  { 0x8700, 0xfd2d, 0x6000 },

-  { 0x8700, 0xfd1d, 0x5000 },

-  { 0x8700, 0xfd15, 0x4000 },

-  { 0x8700, 0xfd11, 0x3000 },

-  { 0x8700, 0xfd0f, 0x2000 },

-  { 0x0700, 0xfd0e, 0x0000 },

-  { 0x0700, 0xfd10, 0x0000 },

-  { 0x8700, 0xfd13, 0x2000 },

-  { 0x0700, 0xfd12, 0x0000 },

-  { 0x0700, 0xfd14, 0x0000 },

-  { 0x8700, 0xfd19, 0x3000 },

-  { 0x8700, 0xfd17, 0x2000 },

-  { 0x0700, 0xfd16, 0x0000 },

-  { 0x0700, 0xfd18, 0x0000 },

-  { 0x8700, 0xfd1b, 0x2000 },

-  { 0x0700, 0xfd1a, 0x0000 },

-  { 0x0700, 0xfd1c, 0x0000 },

-  { 0x8700, 0xfd25, 0x4000 },

-  { 0x8700, 0xfd21, 0x3000 },

-  { 0x8700, 0xfd1f, 0x2000 },

-  { 0x0700, 0xfd1e, 0x0000 },

-  { 0x0700, 0xfd20, 0x0000 },

-  { 0x8700, 0xfd23, 0x2000 },

-  { 0x0700, 0xfd22, 0x0000 },

-  { 0x0700, 0xfd24, 0x0000 },

-  { 0x8700, 0xfd29, 0x3000 },

-  { 0x8700, 0xfd27, 0x2000 },

-  { 0x0700, 0xfd26, 0x0000 },

-  { 0x0700, 0xfd28, 0x0000 },

-  { 0x8700, 0xfd2b, 0x2000 },

-  { 0x0700, 0xfd2a, 0x0000 },

-  { 0x0700, 0xfd2c, 0x0000 },

-  { 0x8700, 0xfd3d, 0x5000 },

-  { 0x8700, 0xfd35, 0x4000 },

-  { 0x8700, 0xfd31, 0x3000 },

-  { 0x8700, 0xfd2f, 0x2000 },

-  { 0x0700, 0xfd2e, 0x0000 },

-  { 0x0700, 0xfd30, 0x0000 },

-  { 0x8700, 0xfd33, 0x2000 },

-  { 0x0700, 0xfd32, 0x0000 },

-  { 0x0700, 0xfd34, 0x0000 },

-  { 0x8700, 0xfd39, 0x3000 },

-  { 0x8700, 0xfd37, 0x2000 },

-  { 0x0700, 0xfd36, 0x0000 },

-  { 0x0700, 0xfd38, 0x0000 },

-  { 0x8700, 0xfd3b, 0x2000 },

-  { 0x0700, 0xfd3a, 0x0000 },

-  { 0x0700, 0xfd3c, 0x0000 },

-  { 0x8700, 0xfd55, 0x4000 },

-  { 0x8700, 0xfd51, 0x3000 },

-  { 0x9200, 0xfd3f, 0x2000 },

-  { 0x1600, 0xfd3e, 0x0000 },

-  { 0x0700, 0xfd50, 0x0000 },

-  { 0x8700, 0xfd53, 0x2000 },

-  { 0x0700, 0xfd52, 0x0000 },

-  { 0x0700, 0xfd54, 0x0000 },

-  { 0x8700, 0xfd59, 0x3000 },

-  { 0x8700, 0xfd57, 0x2000 },

-  { 0x0700, 0xfd56, 0x0000 },

-  { 0x0700, 0xfd58, 0x0000 },

-  { 0x8700, 0xfd5b, 0x2000 },

-  { 0x0700, 0xfd5a, 0x0000 },

-  { 0x0700, 0xfd5c, 0x0000 },

-  { 0x8c00, 0xfe09, 0x8000 },

-  { 0x8700, 0xfd9f, 0x7000 },

-  { 0x8700, 0xfd7d, 0x6000 },

-  { 0x8700, 0xfd6d, 0x5000 },

-  { 0x8700, 0xfd65, 0x4000 },

-  { 0x8700, 0xfd61, 0x3000 },

-  { 0x8700, 0xfd5f, 0x2000 },

-  { 0x0700, 0xfd5e, 0x0000 },

-  { 0x0700, 0xfd60, 0x0000 },

-  { 0x8700, 0xfd63, 0x2000 },

-  { 0x0700, 0xfd62, 0x0000 },

-  { 0x0700, 0xfd64, 0x0000 },

-  { 0x8700, 0xfd69, 0x3000 },

-  { 0x8700, 0xfd67, 0x2000 },

-  { 0x0700, 0xfd66, 0x0000 },

-  { 0x0700, 0xfd68, 0x0000 },

-  { 0x8700, 0xfd6b, 0x2000 },

-  { 0x0700, 0xfd6a, 0x0000 },

-  { 0x0700, 0xfd6c, 0x0000 },

-  { 0x8700, 0xfd75, 0x4000 },

-  { 0x8700, 0xfd71, 0x3000 },

-  { 0x8700, 0xfd6f, 0x2000 },

-  { 0x0700, 0xfd6e, 0x0000 },

-  { 0x0700, 0xfd70, 0x0000 },

-  { 0x8700, 0xfd73, 0x2000 },

-  { 0x0700, 0xfd72, 0x0000 },

-  { 0x0700, 0xfd74, 0x0000 },

-  { 0x8700, 0xfd79, 0x3000 },

-  { 0x8700, 0xfd77, 0x2000 },

-  { 0x0700, 0xfd76, 0x0000 },

-  { 0x0700, 0xfd78, 0x0000 },

-  { 0x8700, 0xfd7b, 0x2000 },

-  { 0x0700, 0xfd7a, 0x0000 },

-  { 0x0700, 0xfd7c, 0x0000 },

-  { 0x8700, 0xfd8d, 0x5000 },

-  { 0x8700, 0xfd85, 0x4000 },

-  { 0x8700, 0xfd81, 0x3000 },

-  { 0x8700, 0xfd7f, 0x2000 },

-  { 0x0700, 0xfd7e, 0x0000 },

-  { 0x0700, 0xfd80, 0x0000 },

-  { 0x8700, 0xfd83, 0x2000 },

-  { 0x0700, 0xfd82, 0x0000 },

-  { 0x0700, 0xfd84, 0x0000 },

-  { 0x8700, 0xfd89, 0x3000 },

-  { 0x8700, 0xfd87, 0x2000 },

-  { 0x0700, 0xfd86, 0x0000 },

-  { 0x0700, 0xfd88, 0x0000 },

-  { 0x8700, 0xfd8b, 0x2000 },

-  { 0x0700, 0xfd8a, 0x0000 },

-  { 0x0700, 0xfd8c, 0x0000 },

-  { 0x8700, 0xfd97, 0x4000 },

-  { 0x8700, 0xfd93, 0x3000 },

-  { 0x8700, 0xfd8f, 0x2000 },

-  { 0x0700, 0xfd8e, 0x0000 },

-  { 0x0700, 0xfd92, 0x0000 },

-  { 0x8700, 0xfd95, 0x2000 },

-  { 0x0700, 0xfd94, 0x0000 },

-  { 0x0700, 0xfd96, 0x0000 },

-  { 0x8700, 0xfd9b, 0x3000 },

-  { 0x8700, 0xfd99, 0x2000 },

-  { 0x0700, 0xfd98, 0x0000 },

-  { 0x0700, 0xfd9a, 0x0000 },

-  { 0x8700, 0xfd9d, 0x2000 },

-  { 0x0700, 0xfd9c, 0x0000 },

-  { 0x0700, 0xfd9e, 0x0000 },

-  { 0x8700, 0xfdbf, 0x6000 },

-  { 0x8700, 0xfdaf, 0x5000 },

-  { 0x8700, 0xfda7, 0x4000 },

-  { 0x8700, 0xfda3, 0x3000 },

-  { 0x8700, 0xfda1, 0x2000 },

-  { 0x0700, 0xfda0, 0x0000 },

-  { 0x0700, 0xfda2, 0x0000 },

-  { 0x8700, 0xfda5, 0x2000 },

-  { 0x0700, 0xfda4, 0x0000 },

-  { 0x0700, 0xfda6, 0x0000 },

-  { 0x8700, 0xfdab, 0x3000 },

-  { 0x8700, 0xfda9, 0x2000 },

-  { 0x0700, 0xfda8, 0x0000 },

-  { 0x0700, 0xfdaa, 0x0000 },

-  { 0x8700, 0xfdad, 0x2000 },

-  { 0x0700, 0xfdac, 0x0000 },

-  { 0x0700, 0xfdae, 0x0000 },

-  { 0x8700, 0xfdb7, 0x4000 },

-  { 0x8700, 0xfdb3, 0x3000 },

-  { 0x8700, 0xfdb1, 0x2000 },

-  { 0x0700, 0xfdb0, 0x0000 },

-  { 0x0700, 0xfdb2, 0x0000 },

-  { 0x8700, 0xfdb5, 0x2000 },

-  { 0x0700, 0xfdb4, 0x0000 },

-  { 0x0700, 0xfdb6, 0x0000 },

-  { 0x8700, 0xfdbb, 0x3000 },

-  { 0x8700, 0xfdb9, 0x2000 },

-  { 0x0700, 0xfdb8, 0x0000 },

-  { 0x0700, 0xfdba, 0x0000 },

-  { 0x8700, 0xfdbd, 0x2000 },

-  { 0x0700, 0xfdbc, 0x0000 },

-  { 0x0700, 0xfdbe, 0x0000 },

-  { 0x8700, 0xfdf7, 0x5000 },

-  { 0x8700, 0xfdc7, 0x4000 },

-  { 0x8700, 0xfdc3, 0x3000 },

-  { 0x8700, 0xfdc1, 0x2000 },

-  { 0x0700, 0xfdc0, 0x0000 },

-  { 0x0700, 0xfdc2, 0x0000 },

-  { 0x8700, 0xfdc5, 0x2000 },

-  { 0x0700, 0xfdc4, 0x0000 },

-  { 0x0700, 0xfdc6, 0x0000 },

-  { 0x8700, 0xfdf3, 0x3000 },

-  { 0x8700, 0xfdf1, 0x2000 },

-  { 0x0700, 0xfdf0, 0x0000 },

-  { 0x0700, 0xfdf2, 0x0000 },

-  { 0x8700, 0xfdf5, 0x2000 },

-  { 0x0700, 0xfdf4, 0x0000 },

-  { 0x0700, 0xfdf6, 0x0000 },

-  { 0x8c00, 0xfe01, 0x4000 },

-  { 0x8700, 0xfdfb, 0x3000 },

-  { 0x8700, 0xfdf9, 0x2000 },

-  { 0x0700, 0xfdf8, 0x0000 },

-  { 0x0700, 0xfdfa, 0x0000 },

-  { 0x9a00, 0xfdfd, 0x2000 },

-  { 0x1700, 0xfdfc, 0x0000 },

-  { 0x0c00, 0xfe00, 0x0000 },

-  { 0x8c00, 0xfe05, 0x3000 },

-  { 0x8c00, 0xfe03, 0x2000 },

-  { 0x0c00, 0xfe02, 0x0000 },

-  { 0x0c00, 0xfe04, 0x0000 },

-  { 0x8c00, 0xfe07, 0x2000 },

-  { 0x0c00, 0xfe06, 0x0000 },

-  { 0x0c00, 0xfe08, 0x0000 },

-  { 0x9900, 0xfe66, 0x7000 },

-  { 0x9500, 0xfe45, 0x6000 },

-  { 0x9600, 0xfe35, 0x5000 },

-  { 0x8c00, 0xfe21, 0x4000 },

-  { 0x8c00, 0xfe0d, 0x3000 },

-  { 0x8c00, 0xfe0b, 0x2000 },

-  { 0x0c00, 0xfe0a, 0x0000 },

-  { 0x0c00, 0xfe0c, 0x0000 },

-  { 0x8c00, 0xfe0f, 0x2000 },

-  { 0x0c00, 0xfe0e, 0x0000 },

-  { 0x0c00, 0xfe20, 0x0000 },

-  { 0x9100, 0xfe31, 0x3000 },

-  { 0x8c00, 0xfe23, 0x2000 },

-  { 0x0c00, 0xfe22, 0x0000 },

-  { 0x1500, 0xfe30, 0x0000 },

-  { 0x9000, 0xfe33, 0x2000 },

-  { 0x1100, 0xfe32, 0x0000 },

-  { 0x1000, 0xfe34, 0x0000 },

-  { 0x9600, 0xfe3d, 0x4000 },

-  { 0x9600, 0xfe39, 0x3000 },

-  { 0x9600, 0xfe37, 0x2000 },

-  { 0x1200, 0xfe36, 0x0000 },

-  { 0x1200, 0xfe38, 0x0000 },

-  { 0x9600, 0xfe3b, 0x2000 },

-  { 0x1200, 0xfe3a, 0x0000 },

-  { 0x1200, 0xfe3c, 0x0000 },

-  { 0x9600, 0xfe41, 0x3000 },

-  { 0x9600, 0xfe3f, 0x2000 },

-  { 0x1200, 0xfe3e, 0x0000 },

-  { 0x1200, 0xfe40, 0x0000 },

-  { 0x9600, 0xfe43, 0x2000 },

-  { 0x1200, 0xfe42, 0x0000 },

-  { 0x1200, 0xfe44, 0x0000 },

-  { 0x9500, 0xfe56, 0x5000 },

-  { 0x9000, 0xfe4d, 0x4000 },

-  { 0x9500, 0xfe49, 0x3000 },

-  { 0x9600, 0xfe47, 0x2000 },

-  { 0x1500, 0xfe46, 0x0000 },

-  { 0x1200, 0xfe48, 0x0000 },

-  { 0x9500, 0xfe4b, 0x2000 },

-  { 0x1500, 0xfe4a, 0x0000 },

-  { 0x1500, 0xfe4c, 0x0000 },

-  { 0x9500, 0xfe51, 0x3000 },

-  { 0x9000, 0xfe4f, 0x2000 },

-  { 0x1000, 0xfe4e, 0x0000 },

-  { 0x1500, 0xfe50, 0x0000 },

-  { 0x9500, 0xfe54, 0x2000 },

-  { 0x1500, 0xfe52, 0x0000 },

-  { 0x1500, 0xfe55, 0x0000 },

-  { 0x9200, 0xfe5e, 0x4000 },

-  { 0x9200, 0xfe5a, 0x3000 },

-  { 0x9100, 0xfe58, 0x2000 },

-  { 0x1500, 0xfe57, 0x0000 },

-  { 0x1600, 0xfe59, 0x0000 },

-  { 0x9200, 0xfe5c, 0x2000 },

-  { 0x1600, 0xfe5b, 0x0000 },

-  { 0x1600, 0xfe5d, 0x0000 },

-  { 0x9900, 0xfe62, 0x3000 },

-  { 0x9500, 0xfe60, 0x2000 },

-  { 0x1500, 0xfe5f, 0x0000 },

-  { 0x1500, 0xfe61, 0x0000 },

-  { 0x9900, 0xfe64, 0x2000 },

-  { 0x1100, 0xfe63, 0x0000 },

-  { 0x1900, 0xfe65, 0x0000 },

-  { 0x8700, 0xfe8c, 0x6000 },

-  { 0x8700, 0xfe7c, 0x5000 },

-  { 0x8700, 0xfe73, 0x4000 },

-  { 0x9500, 0xfe6b, 0x3000 },

-  { 0x9700, 0xfe69, 0x2000 },

-  { 0x1500, 0xfe68, 0x0000 },

-  { 0x1500, 0xfe6a, 0x0000 },

-  { 0x8700, 0xfe71, 0x2000 },

-  { 0x0700, 0xfe70, 0x0000 },

-  { 0x0700, 0xfe72, 0x0000 },

-  { 0x8700, 0xfe78, 0x3000 },

-  { 0x8700, 0xfe76, 0x2000 },

-  { 0x0700, 0xfe74, 0x0000 },

-  { 0x0700, 0xfe77, 0x0000 },

-  { 0x8700, 0xfe7a, 0x2000 },

-  { 0x0700, 0xfe79, 0x0000 },

-  { 0x0700, 0xfe7b, 0x0000 },

-  { 0x8700, 0xfe84, 0x4000 },

-  { 0x8700, 0xfe80, 0x3000 },

-  { 0x8700, 0xfe7e, 0x2000 },

-  { 0x0700, 0xfe7d, 0x0000 },

-  { 0x0700, 0xfe7f, 0x0000 },

-  { 0x8700, 0xfe82, 0x2000 },

-  { 0x0700, 0xfe81, 0x0000 },

-  { 0x0700, 0xfe83, 0x0000 },

-  { 0x8700, 0xfe88, 0x3000 },

-  { 0x8700, 0xfe86, 0x2000 },

-  { 0x0700, 0xfe85, 0x0000 },

-  { 0x0700, 0xfe87, 0x0000 },

-  { 0x8700, 0xfe8a, 0x2000 },

-  { 0x0700, 0xfe89, 0x0000 },

-  { 0x0700, 0xfe8b, 0x0000 },

-  { 0x8700, 0xfe9c, 0x5000 },

-  { 0x8700, 0xfe94, 0x4000 },

-  { 0x8700, 0xfe90, 0x3000 },

-  { 0x8700, 0xfe8e, 0x2000 },

-  { 0x0700, 0xfe8d, 0x0000 },

-  { 0x0700, 0xfe8f, 0x0000 },

-  { 0x8700, 0xfe92, 0x2000 },

-  { 0x0700, 0xfe91, 0x0000 },

-  { 0x0700, 0xfe93, 0x0000 },

-  { 0x8700, 0xfe98, 0x3000 },

-  { 0x8700, 0xfe96, 0x2000 },

-  { 0x0700, 0xfe95, 0x0000 },

-  { 0x0700, 0xfe97, 0x0000 },

-  { 0x8700, 0xfe9a, 0x2000 },

-  { 0x0700, 0xfe99, 0x0000 },

-  { 0x0700, 0xfe9b, 0x0000 },

-  { 0x8700, 0xfea4, 0x4000 },

-  { 0x8700, 0xfea0, 0x3000 },

-  { 0x8700, 0xfe9e, 0x2000 },

-  { 0x0700, 0xfe9d, 0x0000 },

-  { 0x0700, 0xfe9f, 0x0000 },

-  { 0x8700, 0xfea2, 0x2000 },

-  { 0x0700, 0xfea1, 0x0000 },

-  { 0x0700, 0xfea3, 0x0000 },

-  { 0x8700, 0xfea8, 0x3000 },

-  { 0x8700, 0xfea6, 0x2000 },

-  { 0x0700, 0xfea5, 0x0000 },

-  { 0x0700, 0xfea7, 0x0000 },

-  { 0x8700, 0xfeaa, 0x2000 },

-  { 0x0700, 0xfea9, 0x0000 },

-  { 0x0700, 0xfeab, 0x0000 },

-  { 0x8700, 0xffaf, 0x9000 },

-  { 0x8900, 0xff2f, 0x8020 },

-  { 0x8700, 0xfeec, 0x7000 },

-  { 0x8700, 0xfecc, 0x6000 },

-  { 0x8700, 0xfebc, 0x5000 },

-  { 0x8700, 0xfeb4, 0x4000 },

-  { 0x8700, 0xfeb0, 0x3000 },

-  { 0x8700, 0xfeae, 0x2000 },

-  { 0x0700, 0xfead, 0x0000 },

-  { 0x0700, 0xfeaf, 0x0000 },

-  { 0x8700, 0xfeb2, 0x2000 },

-  { 0x0700, 0xfeb1, 0x0000 },

-  { 0x0700, 0xfeb3, 0x0000 },

-  { 0x8700, 0xfeb8, 0x3000 },

-  { 0x8700, 0xfeb6, 0x2000 },

-  { 0x0700, 0xfeb5, 0x0000 },

-  { 0x0700, 0xfeb7, 0x0000 },

-  { 0x8700, 0xfeba, 0x2000 },

-  { 0x0700, 0xfeb9, 0x0000 },

-  { 0x0700, 0xfebb, 0x0000 },

-  { 0x8700, 0xfec4, 0x4000 },

-  { 0x8700, 0xfec0, 0x3000 },

-  { 0x8700, 0xfebe, 0x2000 },

-  { 0x0700, 0xfebd, 0x0000 },

-  { 0x0700, 0xfebf, 0x0000 },

-  { 0x8700, 0xfec2, 0x2000 },

-  { 0x0700, 0xfec1, 0x0000 },

-  { 0x0700, 0xfec3, 0x0000 },

-  { 0x8700, 0xfec8, 0x3000 },

-  { 0x8700, 0xfec6, 0x2000 },

-  { 0x0700, 0xfec5, 0x0000 },

-  { 0x0700, 0xfec7, 0x0000 },

-  { 0x8700, 0xfeca, 0x2000 },

-  { 0x0700, 0xfec9, 0x0000 },

-  { 0x0700, 0xfecb, 0x0000 },

-  { 0x8700, 0xfedc, 0x5000 },

-  { 0x8700, 0xfed4, 0x4000 },

-  { 0x8700, 0xfed0, 0x3000 },

-  { 0x8700, 0xfece, 0x2000 },

-  { 0x0700, 0xfecd, 0x0000 },

-  { 0x0700, 0xfecf, 0x0000 },

-  { 0x8700, 0xfed2, 0x2000 },

-  { 0x0700, 0xfed1, 0x0000 },

-  { 0x0700, 0xfed3, 0x0000 },

-  { 0x8700, 0xfed8, 0x3000 },

-  { 0x8700, 0xfed6, 0x2000 },

-  { 0x0700, 0xfed5, 0x0000 },

-  { 0x0700, 0xfed7, 0x0000 },

-  { 0x8700, 0xfeda, 0x2000 },

-  { 0x0700, 0xfed9, 0x0000 },

-  { 0x0700, 0xfedb, 0x0000 },

-  { 0x8700, 0xfee4, 0x4000 },

-  { 0x8700, 0xfee0, 0x3000 },

-  { 0x8700, 0xfede, 0x2000 },

-  { 0x0700, 0xfedd, 0x0000 },

-  { 0x0700, 0xfedf, 0x0000 },

-  { 0x8700, 0xfee2, 0x2000 },

-  { 0x0700, 0xfee1, 0x0000 },

-  { 0x0700, 0xfee3, 0x0000 },

-  { 0x8700, 0xfee8, 0x3000 },

-  { 0x8700, 0xfee6, 0x2000 },

-  { 0x0700, 0xfee5, 0x0000 },

-  { 0x0700, 0xfee7, 0x0000 },

-  { 0x8700, 0xfeea, 0x2000 },

-  { 0x0700, 0xfee9, 0x0000 },

-  { 0x0700, 0xfeeb, 0x0000 },

-  { 0x9500, 0xff0f, 0x6000 },

-  { 0x8700, 0xfefc, 0x5000 },

-  { 0x8700, 0xfef4, 0x4000 },

-  { 0x8700, 0xfef0, 0x3000 },

-  { 0x8700, 0xfeee, 0x2000 },

-  { 0x0700, 0xfeed, 0x0000 },

-  { 0x0700, 0xfeef, 0x0000 },

-  { 0x8700, 0xfef2, 0x2000 },

-  { 0x0700, 0xfef1, 0x0000 },

-  { 0x0700, 0xfef3, 0x0000 },

-  { 0x8700, 0xfef8, 0x3000 },

-  { 0x8700, 0xfef6, 0x2000 },

-  { 0x0700, 0xfef5, 0x0000 },

-  { 0x0700, 0xfef7, 0x0000 },

-  { 0x8700, 0xfefa, 0x2000 },

-  { 0x0700, 0xfef9, 0x0000 },

-  { 0x0700, 0xfefb, 0x0000 },

-  { 0x9500, 0xff07, 0x4000 },

-  { 0x9500, 0xff03, 0x3000 },

-  { 0x9500, 0xff01, 0x2000 },

-  { 0x0100, 0xfeff, 0x0000 },

-  { 0x1500, 0xff02, 0x0000 },

-  { 0x9500, 0xff05, 0x2000 },

-  { 0x1700, 0xff04, 0x0000 },

-  { 0x1500, 0xff06, 0x0000 },

-  { 0x9900, 0xff0b, 0x3000 },

-  { 0x9200, 0xff09, 0x2000 },

-  { 0x1600, 0xff08, 0x0000 },

-  { 0x1500, 0xff0a, 0x0000 },

-  { 0x9100, 0xff0d, 0x2000 },

-  { 0x1500, 0xff0c, 0x0000 },

-  { 0x1500, 0xff0e, 0x0000 },

-  { 0x9500, 0xff1f, 0x5000 },

-  { 0x8d00, 0xff17, 0x4000 },

-  { 0x8d00, 0xff13, 0x3000 },

-  { 0x8d00, 0xff11, 0x2000 },

-  { 0x0d00, 0xff10, 0x0000 },

-  { 0x0d00, 0xff12, 0x0000 },

-  { 0x8d00, 0xff15, 0x2000 },

-  { 0x0d00, 0xff14, 0x0000 },

-  { 0x0d00, 0xff16, 0x0000 },

-  { 0x9500, 0xff1b, 0x3000 },

-  { 0x8d00, 0xff19, 0x2000 },

-  { 0x0d00, 0xff18, 0x0000 },

-  { 0x1500, 0xff1a, 0x0000 },

-  { 0x9900, 0xff1d, 0x2000 },

-  { 0x1900, 0xff1c, 0x0000 },

-  { 0x1900, 0xff1e, 0x0000 },

-  { 0x8900, 0xff27, 0x4020 },

-  { 0x8900, 0xff23, 0x3020 },

-  { 0x8900, 0xff21, 0x2020 },

-  { 0x1500, 0xff20, 0x0000 },

-  { 0x0900, 0xff22, 0x0020 },

-  { 0x8900, 0xff25, 0x2020 },

-  { 0x0900, 0xff24, 0x0020 },

-  { 0x0900, 0xff26, 0x0020 },

-  { 0x8900, 0xff2b, 0x3020 },

-  { 0x8900, 0xff29, 0x2020 },

-  { 0x0900, 0xff28, 0x0020 },

-  { 0x0900, 0xff2a, 0x0020 },

-  { 0x8900, 0xff2d, 0x2020 },

-  { 0x0900, 0xff2c, 0x0020 },

-  { 0x0900, 0xff2e, 0x0020 },

-  { 0x8700, 0xff6f, 0x7000 },

-  { 0x8500, 0xff4f, 0x6fe0 },

-  { 0x9000, 0xff3f, 0x5000 },

-  { 0x8900, 0xff37, 0x4020 },

-  { 0x8900, 0xff33, 0x3020 },

-  { 0x8900, 0xff31, 0x2020 },

-  { 0x0900, 0xff30, 0x0020 },

-  { 0x0900, 0xff32, 0x0020 },

-  { 0x8900, 0xff35, 0x2020 },

-  { 0x0900, 0xff34, 0x0020 },

-  { 0x0900, 0xff36, 0x0020 },

-  { 0x9600, 0xff3b, 0x3000 },

-  { 0x8900, 0xff39, 0x2020 },

-  { 0x0900, 0xff38, 0x0020 },

-  { 0x0900, 0xff3a, 0x0020 },

-  { 0x9200, 0xff3d, 0x2000 },

-  { 0x1500, 0xff3c, 0x0000 },

-  { 0x1800, 0xff3e, 0x0000 },

-  { 0x8500, 0xff47, 0x4fe0 },

-  { 0x8500, 0xff43, 0x3fe0 },

-  { 0x8500, 0xff41, 0x2fe0 },

-  { 0x1800, 0xff40, 0x0000 },

-  { 0x0500, 0xff42, 0x0fe0 },

-  { 0x8500, 0xff45, 0x2fe0 },

-  { 0x0500, 0xff44, 0x0fe0 },

-  { 0x0500, 0xff46, 0x0fe0 },

-  { 0x8500, 0xff4b, 0x3fe0 },

-  { 0x8500, 0xff49, 0x2fe0 },

-  { 0x0500, 0xff48, 0x0fe0 },

-  { 0x0500, 0xff4a, 0x0fe0 },

-  { 0x8500, 0xff4d, 0x2fe0 },

-  { 0x0500, 0xff4c, 0x0fe0 },

-  { 0x0500, 0xff4e, 0x0fe0 },

-  { 0x9600, 0xff5f, 0x5000 },

-  { 0x8500, 0xff57, 0x4fe0 },

-  { 0x8500, 0xff53, 0x3fe0 },

-  { 0x8500, 0xff51, 0x2fe0 },

-  { 0x0500, 0xff50, 0x0fe0 },

-  { 0x0500, 0xff52, 0x0fe0 },

-  { 0x8500, 0xff55, 0x2fe0 },

-  { 0x0500, 0xff54, 0x0fe0 },

-  { 0x0500, 0xff56, 0x0fe0 },

-  { 0x9600, 0xff5b, 0x3000 },

-  { 0x8500, 0xff59, 0x2fe0 },

-  { 0x0500, 0xff58, 0x0fe0 },

-  { 0x0500, 0xff5a, 0x0fe0 },

-  { 0x9200, 0xff5d, 0x2000 },

-  { 0x1900, 0xff5c, 0x0000 },

-  { 0x1900, 0xff5e, 0x0000 },

-  { 0x8700, 0xff67, 0x4000 },

-  { 0x9200, 0xff63, 0x3000 },

-  { 0x9500, 0xff61, 0x2000 },

-  { 0x1200, 0xff60, 0x0000 },

-  { 0x1600, 0xff62, 0x0000 },

-  { 0x9000, 0xff65, 0x2000 },

-  { 0x1500, 0xff64, 0x0000 },

-  { 0x0700, 0xff66, 0x0000 },

-  { 0x8700, 0xff6b, 0x3000 },

-  { 0x8700, 0xff69, 0x2000 },

-  { 0x0700, 0xff68, 0x0000 },

-  { 0x0700, 0xff6a, 0x0000 },

-  { 0x8700, 0xff6d, 0x2000 },

-  { 0x0700, 0xff6c, 0x0000 },

-  { 0x0700, 0xff6e, 0x0000 },

-  { 0x8700, 0xff8f, 0x6000 },

-  { 0x8700, 0xff7f, 0x5000 },

-  { 0x8700, 0xff77, 0x4000 },

-  { 0x8700, 0xff73, 0x3000 },

-  { 0x8700, 0xff71, 0x2000 },

-  { 0x0600, 0xff70, 0x0000 },

-  { 0x0700, 0xff72, 0x0000 },

-  { 0x8700, 0xff75, 0x2000 },

-  { 0x0700, 0xff74, 0x0000 },

-  { 0x0700, 0xff76, 0x0000 },

-  { 0x8700, 0xff7b, 0x3000 },

-  { 0x8700, 0xff79, 0x2000 },

-  { 0x0700, 0xff78, 0x0000 },

-  { 0x0700, 0xff7a, 0x0000 },

-  { 0x8700, 0xff7d, 0x2000 },

-  { 0x0700, 0xff7c, 0x0000 },

-  { 0x0700, 0xff7e, 0x0000 },

-  { 0x8700, 0xff87, 0x4000 },

-  { 0x8700, 0xff83, 0x3000 },

-  { 0x8700, 0xff81, 0x2000 },

-  { 0x0700, 0xff80, 0x0000 },

-  { 0x0700, 0xff82, 0x0000 },

-  { 0x8700, 0xff85, 0x2000 },

-  { 0x0700, 0xff84, 0x0000 },

-  { 0x0700, 0xff86, 0x0000 },

-  { 0x8700, 0xff8b, 0x3000 },

-  { 0x8700, 0xff89, 0x2000 },

-  { 0x0700, 0xff88, 0x0000 },

-  { 0x0700, 0xff8a, 0x0000 },

-  { 0x8700, 0xff8d, 0x2000 },

-  { 0x0700, 0xff8c, 0x0000 },

-  { 0x0700, 0xff8e, 0x0000 },

-  { 0x8600, 0xff9f, 0x5000 },

-  { 0x8700, 0xff97, 0x4000 },

-  { 0x8700, 0xff93, 0x3000 },

-  { 0x8700, 0xff91, 0x2000 },

-  { 0x0700, 0xff90, 0x0000 },

-  { 0x0700, 0xff92, 0x0000 },

-  { 0x8700, 0xff95, 0x2000 },

-  { 0x0700, 0xff94, 0x0000 },

-  { 0x0700, 0xff96, 0x0000 },

-  { 0x8700, 0xff9b, 0x3000 },

-  { 0x8700, 0xff99, 0x2000 },

-  { 0x0700, 0xff98, 0x0000 },

-  { 0x0700, 0xff9a, 0x0000 },

-  { 0x8700, 0xff9d, 0x2000 },

-  { 0x0700, 0xff9c, 0x0000 },

-  { 0x0600, 0xff9e, 0x0000 },

-  { 0x8700, 0xffa7, 0x4000 },

-  { 0x8700, 0xffa3, 0x3000 },

-  { 0x8700, 0xffa1, 0x2000 },

-  { 0x0700, 0xffa0, 0x0000 },

-  { 0x0700, 0xffa2, 0x0000 },

-  { 0x8700, 0xffa5, 0x2000 },

-  { 0x0700, 0xffa4, 0x0000 },

-  { 0x0700, 0xffa6, 0x0000 },

-  { 0x8700, 0xffab, 0x3000 },

-  { 0x8700, 0xffa9, 0x2000 },

-  { 0x0700, 0xffa8, 0x0000 },

-  { 0x0700, 0xffaa, 0x0000 },

-  { 0x8700, 0xffad, 0x2000 },

-  { 0x0700, 0xffac, 0x0000 },

-  { 0x0700, 0xffae, 0x0000 },

-  { 0x8701, 0x004c, 0x8000 },

-  { 0x8701, 0x0008, 0x7000 },

-  { 0x8700, 0xffd6, 0x6000 },

-  { 0x8700, 0xffc2, 0x5000 },

-  { 0x8700, 0xffb7, 0x4000 },

-  { 0x8700, 0xffb3, 0x3000 },

-  { 0x8700, 0xffb1, 0x2000 },

-  { 0x0700, 0xffb0, 0x0000 },

-  { 0x0700, 0xffb2, 0x0000 },

-  { 0x8700, 0xffb5, 0x2000 },

-  { 0x0700, 0xffb4, 0x0000 },

-  { 0x0700, 0xffb6, 0x0000 },

-  { 0x8700, 0xffbb, 0x3000 },

-  { 0x8700, 0xffb9, 0x2000 },

-  { 0x0700, 0xffb8, 0x0000 },

-  { 0x0700, 0xffba, 0x0000 },

-  { 0x8700, 0xffbd, 0x2000 },

-  { 0x0700, 0xffbc, 0x0000 },

-  { 0x0700, 0xffbe, 0x0000 },

-  { 0x8700, 0xffcc, 0x4000 },

-  { 0x8700, 0xffc6, 0x3000 },

-  { 0x8700, 0xffc4, 0x2000 },

-  { 0x0700, 0xffc3, 0x0000 },

-  { 0x0700, 0xffc5, 0x0000 },

-  { 0x8700, 0xffca, 0x2000 },

-  { 0x0700, 0xffc7, 0x0000 },

-  { 0x0700, 0xffcb, 0x0000 },

-  { 0x8700, 0xffd2, 0x3000 },

-  { 0x8700, 0xffce, 0x2000 },

-  { 0x0700, 0xffcd, 0x0000 },

-  { 0x0700, 0xffcf, 0x0000 },

-  { 0x8700, 0xffd4, 0x2000 },

-  { 0x0700, 0xffd3, 0x0000 },

-  { 0x0700, 0xffd5, 0x0000 },

-  { 0x9900, 0xffec, 0x5000 },

-  { 0x9800, 0xffe3, 0x4000 },

-  { 0x8700, 0xffdc, 0x3000 },

-  { 0x8700, 0xffda, 0x2000 },

-  { 0x0700, 0xffd7, 0x0000 },

-  { 0x0700, 0xffdb, 0x0000 },

-  { 0x9700, 0xffe1, 0x2000 },

-  { 0x1700, 0xffe0, 0x0000 },

-  { 0x1900, 0xffe2, 0x0000 },

-  { 0x9a00, 0xffe8, 0x3000 },

-  { 0x9700, 0xffe5, 0x2000 },

-  { 0x1a00, 0xffe4, 0x0000 },

-  { 0x1700, 0xffe6, 0x0000 },

-  { 0x9900, 0xffea, 0x2000 },

-  { 0x1900, 0xffe9, 0x0000 },

-  { 0x1900, 0xffeb, 0x0000 },

-  { 0x8701, 0x0000, 0x4000 },

-  { 0x8100, 0xfffa, 0x3000 },

-  { 0x9a00, 0xffee, 0x2000 },

-  { 0x1a00, 0xffed, 0x0000 },

-  { 0x0100, 0xfff9, 0x0000 },

-  { 0x9a00, 0xfffc, 0x2000 },

-  { 0x0100, 0xfffb, 0x0000 },

-  { 0x1a00, 0xfffd, 0x0000 },

-  { 0x8701, 0x0004, 0x3000 },

-  { 0x8701, 0x0002, 0x2000 },

-  { 0x0701, 0x0001, 0x0000 },

-  { 0x0701, 0x0003, 0x0000 },

-  { 0x8701, 0x0006, 0x2000 },

-  { 0x0701, 0x0005, 0x0000 },

-  { 0x0701, 0x0007, 0x0000 },

-  { 0x8701, 0x002a, 0x6000 },

-  { 0x8701, 0x0019, 0x5000 },

-  { 0x8701, 0x0011, 0x4000 },

-  { 0x8701, 0x000d, 0x3000 },

-  { 0x8701, 0x000a, 0x2000 },

-  { 0x0701, 0x0009, 0x0000 },

-  { 0x0701, 0x000b, 0x0000 },

-  { 0x8701, 0x000f, 0x2000 },

-  { 0x0701, 0x000e, 0x0000 },

-  { 0x0701, 0x0010, 0x0000 },

-  { 0x8701, 0x0015, 0x3000 },

-  { 0x8701, 0x0013, 0x2000 },

-  { 0x0701, 0x0012, 0x0000 },

-  { 0x0701, 0x0014, 0x0000 },

-  { 0x8701, 0x0017, 0x2000 },

-  { 0x0701, 0x0016, 0x0000 },

-  { 0x0701, 0x0018, 0x0000 },

-  { 0x8701, 0x0021, 0x4000 },

-  { 0x8701, 0x001d, 0x3000 },

-  { 0x8701, 0x001b, 0x2000 },

-  { 0x0701, 0x001a, 0x0000 },

-  { 0x0701, 0x001c, 0x0000 },

-  { 0x8701, 0x001f, 0x2000 },

-  { 0x0701, 0x001e, 0x0000 },

-  { 0x0701, 0x0020, 0x0000 },

-  { 0x8701, 0x0025, 0x3000 },

-  { 0x8701, 0x0023, 0x2000 },

-  { 0x0701, 0x0022, 0x0000 },

-  { 0x0701, 0x0024, 0x0000 },

-  { 0x8701, 0x0028, 0x2000 },

-  { 0x0701, 0x0026, 0x0000 },

-  { 0x0701, 0x0029, 0x0000 },

-  { 0x8701, 0x003a, 0x5000 },

-  { 0x8701, 0x0032, 0x4000 },

-  { 0x8701, 0x002e, 0x3000 },

-  { 0x8701, 0x002c, 0x2000 },

-  { 0x0701, 0x002b, 0x0000 },

-  { 0x0701, 0x002d, 0x0000 },

-  { 0x8701, 0x0030, 0x2000 },

-  { 0x0701, 0x002f, 0x0000 },

-  { 0x0701, 0x0031, 0x0000 },

-  { 0x8701, 0x0036, 0x3000 },

-  { 0x8701, 0x0034, 0x2000 },

-  { 0x0701, 0x0033, 0x0000 },

-  { 0x0701, 0x0035, 0x0000 },

-  { 0x8701, 0x0038, 0x2000 },

-  { 0x0701, 0x0037, 0x0000 },

-  { 0x0701, 0x0039, 0x0000 },

-  { 0x8701, 0x0044, 0x4000 },

-  { 0x8701, 0x0040, 0x3000 },

-  { 0x8701, 0x003d, 0x2000 },

-  { 0x0701, 0x003c, 0x0000 },

-  { 0x0701, 0x003f, 0x0000 },

-  { 0x8701, 0x0042, 0x2000 },

-  { 0x0701, 0x0041, 0x0000 },

-  { 0x0701, 0x0043, 0x0000 },

-  { 0x8701, 0x0048, 0x3000 },

-  { 0x8701, 0x0046, 0x2000 },

-  { 0x0701, 0x0045, 0x0000 },

-  { 0x0701, 0x0047, 0x0000 },

-  { 0x8701, 0x004a, 0x2000 },

-  { 0x0701, 0x0049, 0x0000 },

-  { 0x0701, 0x004b, 0x0000 },

-  { 0x8701, 0x00b0, 0x7000 },

-  { 0x8701, 0x0090, 0x6000 },

-  { 0x8701, 0x0080, 0x5000 },

-  { 0x8701, 0x0056, 0x4000 },

-  { 0x8701, 0x0052, 0x3000 },

-  { 0x8701, 0x0050, 0x2000 },

-  { 0x0701, 0x004d, 0x0000 },

-  { 0x0701, 0x0051, 0x0000 },

-  { 0x8701, 0x0054, 0x2000 },

-  { 0x0701, 0x0053, 0x0000 },

-  { 0x0701, 0x0055, 0x0000 },

-  { 0x8701, 0x005a, 0x3000 },

-  { 0x8701, 0x0058, 0x2000 },

-  { 0x0701, 0x0057, 0x0000 },

-  { 0x0701, 0x0059, 0x0000 },

-  { 0x8701, 0x005c, 0x2000 },

-  { 0x0701, 0x005b, 0x0000 },

-  { 0x0701, 0x005d, 0x0000 },

-  { 0x8701, 0x0088, 0x4000 },

-  { 0x8701, 0x0084, 0x3000 },

-  { 0x8701, 0x0082, 0x2000 },

-  { 0x0701, 0x0081, 0x0000 },

-  { 0x0701, 0x0083, 0x0000 },

-  { 0x8701, 0x0086, 0x2000 },

-  { 0x0701, 0x0085, 0x0000 },

-  { 0x0701, 0x0087, 0x0000 },

-  { 0x8701, 0x008c, 0x3000 },

-  { 0x8701, 0x008a, 0x2000 },

-  { 0x0701, 0x0089, 0x0000 },

-  { 0x0701, 0x008b, 0x0000 },

-  { 0x8701, 0x008e, 0x2000 },

-  { 0x0701, 0x008d, 0x0000 },

-  { 0x0701, 0x008f, 0x0000 },

-  { 0x8701, 0x00a0, 0x5000 },

-  { 0x8701, 0x0098, 0x4000 },

-  { 0x8701, 0x0094, 0x3000 },

-  { 0x8701, 0x0092, 0x2000 },

-  { 0x0701, 0x0091, 0x0000 },

-  { 0x0701, 0x0093, 0x0000 },

-  { 0x8701, 0x0096, 0x2000 },

-  { 0x0701, 0x0095, 0x0000 },

-  { 0x0701, 0x0097, 0x0000 },

-  { 0x8701, 0x009c, 0x3000 },

-  { 0x8701, 0x009a, 0x2000 },

-  { 0x0701, 0x0099, 0x0000 },

-  { 0x0701, 0x009b, 0x0000 },

-  { 0x8701, 0x009e, 0x2000 },

-  { 0x0701, 0x009d, 0x0000 },

-  { 0x0701, 0x009f, 0x0000 },

-  { 0x8701, 0x00a8, 0x4000 },

-  { 0x8701, 0x00a4, 0x3000 },

-  { 0x8701, 0x00a2, 0x2000 },

-  { 0x0701, 0x00a1, 0x0000 },

-  { 0x0701, 0x00a3, 0x0000 },

-  { 0x8701, 0x00a6, 0x2000 },

-  { 0x0701, 0x00a5, 0x0000 },

-  { 0x0701, 0x00a7, 0x0000 },

-  { 0x8701, 0x00ac, 0x3000 },

-  { 0x8701, 0x00aa, 0x2000 },

-  { 0x0701, 0x00a9, 0x0000 },

-  { 0x0701, 0x00ab, 0x0000 },

-  { 0x8701, 0x00ae, 0x2000 },

-  { 0x0701, 0x00ad, 0x0000 },

-  { 0x0701, 0x00af, 0x0000 },

-  { 0x8701, 0x00d0, 0x6000 },

-  { 0x8701, 0x00c0, 0x5000 },

-  { 0x8701, 0x00b8, 0x4000 },

-  { 0x8701, 0x00b4, 0x3000 },

-  { 0x8701, 0x00b2, 0x2000 },

-  { 0x0701, 0x00b1, 0x0000 },

-  { 0x0701, 0x00b3, 0x0000 },

-  { 0x8701, 0x00b6, 0x2000 },

-  { 0x0701, 0x00b5, 0x0000 },

-  { 0x0701, 0x00b7, 0x0000 },

-  { 0x8701, 0x00bc, 0x3000 },

-  { 0x8701, 0x00ba, 0x2000 },

-  { 0x0701, 0x00b9, 0x0000 },

-  { 0x0701, 0x00bb, 0x0000 },

-  { 0x8701, 0x00be, 0x2000 },

-  { 0x0701, 0x00bd, 0x0000 },

-  { 0x0701, 0x00bf, 0x0000 },

-  { 0x8701, 0x00c8, 0x4000 },

-  { 0x8701, 0x00c4, 0x3000 },

-  { 0x8701, 0x00c2, 0x2000 },

-  { 0x0701, 0x00c1, 0x0000 },

-  { 0x0701, 0x00c3, 0x0000 },

-  { 0x8701, 0x00c6, 0x2000 },

-  { 0x0701, 0x00c5, 0x0000 },

-  { 0x0701, 0x00c7, 0x0000 },

-  { 0x8701, 0x00cc, 0x3000 },

-  { 0x8701, 0x00ca, 0x2000 },

-  { 0x0701, 0x00c9, 0x0000 },

-  { 0x0701, 0x00cb, 0x0000 },

-  { 0x8701, 0x00ce, 0x2000 },

-  { 0x0701, 0x00cd, 0x0000 },

-  { 0x0701, 0x00cf, 0x0000 },

-  { 0x8701, 0x00e0, 0x5000 },

-  { 0x8701, 0x00d8, 0x4000 },

-  { 0x8701, 0x00d4, 0x3000 },

-  { 0x8701, 0x00d2, 0x2000 },

-  { 0x0701, 0x00d1, 0x0000 },

-  { 0x0701, 0x00d3, 0x0000 },

-  { 0x8701, 0x00d6, 0x2000 },

-  { 0x0701, 0x00d5, 0x0000 },

-  { 0x0701, 0x00d7, 0x0000 },

-  { 0x8701, 0x00dc, 0x3000 },

-  { 0x8701, 0x00da, 0x2000 },

-  { 0x0701, 0x00d9, 0x0000 },

-  { 0x0701, 0x00db, 0x0000 },

-  { 0x8701, 0x00de, 0x2000 },

-  { 0x0701, 0x00dd, 0x0000 },

-  { 0x0701, 0x00df, 0x0000 },

-  { 0x8701, 0x00e8, 0x4000 },

-  { 0x8701, 0x00e4, 0x3000 },

-  { 0x8701, 0x00e2, 0x2000 },

-  { 0x0701, 0x00e1, 0x0000 },

-  { 0x0701, 0x00e3, 0x0000 },

-  { 0x8701, 0x00e6, 0x2000 },

-  { 0x0701, 0x00e5, 0x0000 },

-  { 0x0701, 0x00e7, 0x0000 },

-  { 0x8701, 0x00ec, 0x3000 },

-  { 0x8701, 0x00ea, 0x2000 },

-  { 0x0701, 0x00e9, 0x0000 },

-  { 0x0701, 0x00eb, 0x0000 },

-  { 0x8701, 0x00ee, 0x2000 },

-  { 0x0701, 0x00ed, 0x0000 },

-  { 0x0701, 0x00ef, 0x0000 },

-  { 0x8501, 0xd459, 0xb000 },

-  { 0x9a01, 0xd080, 0xa000 },

-  { 0x8701, 0x045f, 0x9000 },

-  { 0x8701, 0x0349, 0x8000 },

-  { 0x9a01, 0x013c, 0x7000 },

-  { 0x8f01, 0x0119, 0x6000 },

-  { 0x8f01, 0x0109, 0x5000 },

-  { 0x8701, 0x00f8, 0x4000 },

-  { 0x8701, 0x00f4, 0x3000 },

-  { 0x8701, 0x00f2, 0x2000 },

-  { 0x0701, 0x00f1, 0x0000 },

-  { 0x0701, 0x00f3, 0x0000 },

-  { 0x8701, 0x00f6, 0x2000 },

-  { 0x0701, 0x00f5, 0x0000 },

-  { 0x0701, 0x00f7, 0x0000 },

-  { 0x9501, 0x0101, 0x3000 },

-  { 0x8701, 0x00fa, 0x2000 },

-  { 0x0701, 0x00f9, 0x0000 },

-  { 0x1501, 0x0100, 0x0000 },

-  { 0x8f01, 0x0107, 0x2000 },

-  { 0x1a01, 0x0102, 0x0000 },

-  { 0x0f01, 0x0108, 0x0000 },

-  { 0x8f01, 0x0111, 0x4000 },

-  { 0x8f01, 0x010d, 0x3000 },

-  { 0x8f01, 0x010b, 0x2000 },

-  { 0x0f01, 0x010a, 0x0000 },

-  { 0x0f01, 0x010c, 0x0000 },

-  { 0x8f01, 0x010f, 0x2000 },

-  { 0x0f01, 0x010e, 0x0000 },

-  { 0x0f01, 0x0110, 0x0000 },

-  { 0x8f01, 0x0115, 0x3000 },

-  { 0x8f01, 0x0113, 0x2000 },

-  { 0x0f01, 0x0112, 0x0000 },

-  { 0x0f01, 0x0114, 0x0000 },

-  { 0x8f01, 0x0117, 0x2000 },

-  { 0x0f01, 0x0116, 0x0000 },

-  { 0x0f01, 0x0118, 0x0000 },

-  { 0x8f01, 0x0129, 0x5000 },

-  { 0x8f01, 0x0121, 0x4000 },

-  { 0x8f01, 0x011d, 0x3000 },

-  { 0x8f01, 0x011b, 0x2000 },

-  { 0x0f01, 0x011a, 0x0000 },

-  { 0x0f01, 0x011c, 0x0000 },

-  { 0x8f01, 0x011f, 0x2000 },

-  { 0x0f01, 0x011e, 0x0000 },

-  { 0x0f01, 0x0120, 0x0000 },

-  { 0x8f01, 0x0125, 0x3000 },

-  { 0x8f01, 0x0123, 0x2000 },

-  { 0x0f01, 0x0122, 0x0000 },

-  { 0x0f01, 0x0124, 0x0000 },

-  { 0x8f01, 0x0127, 0x2000 },

-  { 0x0f01, 0x0126, 0x0000 },

-  { 0x0f01, 0x0128, 0x0000 },

-  { 0x8f01, 0x0131, 0x4000 },

-  { 0x8f01, 0x012d, 0x3000 },

-  { 0x8f01, 0x012b, 0x2000 },

-  { 0x0f01, 0x012a, 0x0000 },

-  { 0x0f01, 0x012c, 0x0000 },

-  { 0x8f01, 0x012f, 0x2000 },

-  { 0x0f01, 0x012e, 0x0000 },

-  { 0x0f01, 0x0130, 0x0000 },

-  { 0x9a01, 0x0138, 0x3000 },

-  { 0x8f01, 0x0133, 0x2000 },

-  { 0x0f01, 0x0132, 0x0000 },

-  { 0x1a01, 0x0137, 0x0000 },

-  { 0x9a01, 0x013a, 0x2000 },

-  { 0x1a01, 0x0139, 0x0000 },

-  { 0x1a01, 0x013b, 0x0000 },

-  { 0x8701, 0x031c, 0x6000 },

-  { 0x8701, 0x030c, 0x5000 },

-  { 0x8701, 0x0304, 0x4000 },

-  { 0x8701, 0x0300, 0x3000 },

-  { 0x9a01, 0x013e, 0x2000 },

-  { 0x1a01, 0x013d, 0x0000 },

-  { 0x1a01, 0x013f, 0x0000 },

-  { 0x8701, 0x0302, 0x2000 },

-  { 0x0701, 0x0301, 0x0000 },

-  { 0x0701, 0x0303, 0x0000 },

-  { 0x8701, 0x0308, 0x3000 },

-  { 0x8701, 0x0306, 0x2000 },

-  { 0x0701, 0x0305, 0x0000 },

-  { 0x0701, 0x0307, 0x0000 },

-  { 0x8701, 0x030a, 0x2000 },

-  { 0x0701, 0x0309, 0x0000 },

-  { 0x0701, 0x030b, 0x0000 },

-  { 0x8701, 0x0314, 0x4000 },

-  { 0x8701, 0x0310, 0x3000 },

-  { 0x8701, 0x030e, 0x2000 },

-  { 0x0701, 0x030d, 0x0000 },

-  { 0x0701, 0x030f, 0x0000 },

-  { 0x8701, 0x0312, 0x2000 },

-  { 0x0701, 0x0311, 0x0000 },

-  { 0x0701, 0x0313, 0x0000 },

-  { 0x8701, 0x0318, 0x3000 },

-  { 0x8701, 0x0316, 0x2000 },

-  { 0x0701, 0x0315, 0x0000 },

-  { 0x0701, 0x0317, 0x0000 },

-  { 0x8701, 0x031a, 0x2000 },

-  { 0x0701, 0x0319, 0x0000 },

-  { 0x0701, 0x031b, 0x0000 },

-  { 0x8701, 0x0339, 0x5000 },

-  { 0x8701, 0x0331, 0x4000 },

-  { 0x8f01, 0x0321, 0x3000 },

-  { 0x8701, 0x031e, 0x2000 },

-  { 0x0701, 0x031d, 0x0000 },

-  { 0x0f01, 0x0320, 0x0000 },

-  { 0x8f01, 0x0323, 0x2000 },

-  { 0x0f01, 0x0322, 0x0000 },

-  { 0x0701, 0x0330, 0x0000 },

-  { 0x8701, 0x0335, 0x3000 },

-  { 0x8701, 0x0333, 0x2000 },

-  { 0x0701, 0x0332, 0x0000 },

-  { 0x0701, 0x0334, 0x0000 },

-  { 0x8701, 0x0337, 0x2000 },

-  { 0x0701, 0x0336, 0x0000 },

-  { 0x0701, 0x0338, 0x0000 },

-  { 0x8701, 0x0341, 0x4000 },

-  { 0x8701, 0x033d, 0x3000 },

-  { 0x8701, 0x033b, 0x2000 },

-  { 0x0701, 0x033a, 0x0000 },

-  { 0x0701, 0x033c, 0x0000 },

-  { 0x8701, 0x033f, 0x2000 },

-  { 0x0701, 0x033e, 0x0000 },

-  { 0x0701, 0x0340, 0x0000 },

-  { 0x8701, 0x0345, 0x3000 },

-  { 0x8701, 0x0343, 0x2000 },

-  { 0x0701, 0x0342, 0x0000 },

-  { 0x0701, 0x0344, 0x0000 },

-  { 0x8701, 0x0347, 0x2000 },

-  { 0x0701, 0x0346, 0x0000 },

-  { 0x0701, 0x0348, 0x0000 },

-  { 0x8901, 0x041f, 0x7028 },

-  { 0x9501, 0x039f, 0x6000 },

-  { 0x8701, 0x038e, 0x5000 },

-  { 0x8701, 0x0386, 0x4000 },

-  { 0x8701, 0x0382, 0x3000 },

-  { 0x8701, 0x0380, 0x2000 },

-  { 0x0e01, 0x034a, 0x0000 },

-  { 0x0701, 0x0381, 0x0000 },

-  { 0x8701, 0x0384, 0x2000 },

-  { 0x0701, 0x0383, 0x0000 },

-  { 0x0701, 0x0385, 0x0000 },

-  { 0x8701, 0x038a, 0x3000 },

-  { 0x8701, 0x0388, 0x2000 },

-  { 0x0701, 0x0387, 0x0000 },

-  { 0x0701, 0x0389, 0x0000 },

-  { 0x8701, 0x038c, 0x2000 },

-  { 0x0701, 0x038b, 0x0000 },

-  { 0x0701, 0x038d, 0x0000 },

-  { 0x8701, 0x0396, 0x4000 },

-  { 0x8701, 0x0392, 0x3000 },

-  { 0x8701, 0x0390, 0x2000 },

-  { 0x0701, 0x038f, 0x0000 },

-  { 0x0701, 0x0391, 0x0000 },

-  { 0x8701, 0x0394, 0x2000 },

-  { 0x0701, 0x0393, 0x0000 },

-  { 0x0701, 0x0395, 0x0000 },

-  { 0x8701, 0x039a, 0x3000 },

-  { 0x8701, 0x0398, 0x2000 },

-  { 0x0701, 0x0397, 0x0000 },

-  { 0x0701, 0x0399, 0x0000 },

-  { 0x8701, 0x039c, 0x2000 },

-  { 0x0701, 0x039b, 0x0000 },

-  { 0x0701, 0x039d, 0x0000 },

-  { 0x8901, 0x040f, 0x5028 },

-  { 0x8901, 0x0407, 0x4028 },

-  { 0x8901, 0x0403, 0x3028 },

-  { 0x8901, 0x0401, 0x2028 },

-  { 0x0901, 0x0400, 0x0028 },

-  { 0x0901, 0x0402, 0x0028 },

-  { 0x8901, 0x0405, 0x2028 },

-  { 0x0901, 0x0404, 0x0028 },

-  { 0x0901, 0x0406, 0x0028 },

-  { 0x8901, 0x040b, 0x3028 },

-  { 0x8901, 0x0409, 0x2028 },

-  { 0x0901, 0x0408, 0x0028 },

-  { 0x0901, 0x040a, 0x0028 },

-  { 0x8901, 0x040d, 0x2028 },

-  { 0x0901, 0x040c, 0x0028 },

-  { 0x0901, 0x040e, 0x0028 },

-  { 0x8901, 0x0417, 0x4028 },

-  { 0x8901, 0x0413, 0x3028 },

-  { 0x8901, 0x0411, 0x2028 },

-  { 0x0901, 0x0410, 0x0028 },

-  { 0x0901, 0x0412, 0x0028 },

-  { 0x8901, 0x0415, 0x2028 },

-  { 0x0901, 0x0414, 0x0028 },

-  { 0x0901, 0x0416, 0x0028 },

-  { 0x8901, 0x041b, 0x3028 },

-  { 0x8901, 0x0419, 0x2028 },

-  { 0x0901, 0x0418, 0x0028 },

-  { 0x0901, 0x041a, 0x0028 },

-  { 0x8901, 0x041d, 0x2028 },

-  { 0x0901, 0x041c, 0x0028 },

-  { 0x0901, 0x041e, 0x0028 },

-  { 0x8501, 0x043f, 0x6fd8 },

-  { 0x8501, 0x042f, 0x5fd8 },

-  { 0x8901, 0x0427, 0x4028 },

-  { 0x8901, 0x0423, 0x3028 },

-  { 0x8901, 0x0421, 0x2028 },

-  { 0x0901, 0x0420, 0x0028 },

-  { 0x0901, 0x0422, 0x0028 },

-  { 0x8901, 0x0425, 0x2028 },

-  { 0x0901, 0x0424, 0x0028 },

-  { 0x0901, 0x0426, 0x0028 },

-  { 0x8501, 0x042b, 0x3fd8 },

-  { 0x8501, 0x0429, 0x2fd8 },

-  { 0x0501, 0x0428, 0x0fd8 },

-  { 0x0501, 0x042a, 0x0fd8 },

-  { 0x8501, 0x042d, 0x2fd8 },

-  { 0x0501, 0x042c, 0x0fd8 },

-  { 0x0501, 0x042e, 0x0fd8 },

-  { 0x8501, 0x0437, 0x4fd8 },

-  { 0x8501, 0x0433, 0x3fd8 },

-  { 0x8501, 0x0431, 0x2fd8 },

-  { 0x0501, 0x0430, 0x0fd8 },

-  { 0x0501, 0x0432, 0x0fd8 },

-  { 0x8501, 0x0435, 0x2fd8 },

-  { 0x0501, 0x0434, 0x0fd8 },

-  { 0x0501, 0x0436, 0x0fd8 },

-  { 0x8501, 0x043b, 0x3fd8 },

-  { 0x8501, 0x0439, 0x2fd8 },

-  { 0x0501, 0x0438, 0x0fd8 },

-  { 0x0501, 0x043a, 0x0fd8 },

-  { 0x8501, 0x043d, 0x2fd8 },

-  { 0x0501, 0x043c, 0x0fd8 },

-  { 0x0501, 0x043e, 0x0fd8 },

-  { 0x8501, 0x044f, 0x5fd8 },

-  { 0x8501, 0x0447, 0x4fd8 },

-  { 0x8501, 0x0443, 0x3fd8 },

-  { 0x8501, 0x0441, 0x2fd8 },

-  { 0x0501, 0x0440, 0x0fd8 },

-  { 0x0501, 0x0442, 0x0fd8 },

-  { 0x8501, 0x0445, 0x2fd8 },

-  { 0x0501, 0x0444, 0x0fd8 },

-  { 0x0501, 0x0446, 0x0fd8 },

-  { 0x8501, 0x044b, 0x3fd8 },

-  { 0x8501, 0x0449, 0x2fd8 },

-  { 0x0501, 0x0448, 0x0fd8 },

-  { 0x0501, 0x044a, 0x0fd8 },

-  { 0x8501, 0x044d, 0x2fd8 },

-  { 0x0501, 0x044c, 0x0fd8 },

-  { 0x0501, 0x044e, 0x0fd8 },

-  { 0x8701, 0x0457, 0x4000 },

-  { 0x8701, 0x0453, 0x3000 },

-  { 0x8701, 0x0451, 0x2000 },

-  { 0x0701, 0x0450, 0x0000 },

-  { 0x0701, 0x0452, 0x0000 },

-  { 0x8701, 0x0455, 0x2000 },

-  { 0x0701, 0x0454, 0x0000 },

-  { 0x0701, 0x0456, 0x0000 },

-  { 0x8701, 0x045b, 0x3000 },

-  { 0x8701, 0x0459, 0x2000 },

-  { 0x0701, 0x0458, 0x0000 },

-  { 0x0701, 0x045a, 0x0000 },

-  { 0x8701, 0x045d, 0x2000 },

-  { 0x0701, 0x045c, 0x0000 },

-  { 0x0701, 0x045e, 0x0000 },

-  { 0x9a01, 0xd000, 0x8000 },

-  { 0x8d01, 0x04a1, 0x7000 },

-  { 0x8701, 0x047f, 0x6000 },

-  { 0x8701, 0x046f, 0x5000 },

-  { 0x8701, 0x0467, 0x4000 },

-  { 0x8701, 0x0463, 0x3000 },

-  { 0x8701, 0x0461, 0x2000 },

-  { 0x0701, 0x0460, 0x0000 },

-  { 0x0701, 0x0462, 0x0000 },

-  { 0x8701, 0x0465, 0x2000 },

-  { 0x0701, 0x0464, 0x0000 },

-  { 0x0701, 0x0466, 0x0000 },

-  { 0x8701, 0x046b, 0x3000 },

-  { 0x8701, 0x0469, 0x2000 },

-  { 0x0701, 0x0468, 0x0000 },

-  { 0x0701, 0x046a, 0x0000 },

-  { 0x8701, 0x046d, 0x2000 },

-  { 0x0701, 0x046c, 0x0000 },

-  { 0x0701, 0x046e, 0x0000 },

-  { 0x8701, 0x0477, 0x4000 },

-  { 0x8701, 0x0473, 0x3000 },

-  { 0x8701, 0x0471, 0x2000 },

-  { 0x0701, 0x0470, 0x0000 },

-  { 0x0701, 0x0472, 0x0000 },

-  { 0x8701, 0x0475, 0x2000 },

-  { 0x0701, 0x0474, 0x0000 },

-  { 0x0701, 0x0476, 0x0000 },

-  { 0x8701, 0x047b, 0x3000 },

-  { 0x8701, 0x0479, 0x2000 },

-  { 0x0701, 0x0478, 0x0000 },

-  { 0x0701, 0x047a, 0x0000 },

-  { 0x8701, 0x047d, 0x2000 },

-  { 0x0701, 0x047c, 0x0000 },

-  { 0x0701, 0x047e, 0x0000 },

-  { 0x8701, 0x048f, 0x5000 },

-  { 0x8701, 0x0487, 0x4000 },

-  { 0x8701, 0x0483, 0x3000 },

-  { 0x8701, 0x0481, 0x2000 },

-  { 0x0701, 0x0480, 0x0000 },

-  { 0x0701, 0x0482, 0x0000 },

-  { 0x8701, 0x0485, 0x2000 },

-  { 0x0701, 0x0484, 0x0000 },

-  { 0x0701, 0x0486, 0x0000 },

-  { 0x8701, 0x048b, 0x3000 },

-  { 0x8701, 0x0489, 0x2000 },

-  { 0x0701, 0x0488, 0x0000 },

-  { 0x0701, 0x048a, 0x0000 },

-  { 0x8701, 0x048d, 0x2000 },

-  { 0x0701, 0x048c, 0x0000 },

-  { 0x0701, 0x048e, 0x0000 },

-  { 0x8701, 0x0497, 0x4000 },

-  { 0x8701, 0x0493, 0x3000 },

-  { 0x8701, 0x0491, 0x2000 },

-  { 0x0701, 0x0490, 0x0000 },

-  { 0x0701, 0x0492, 0x0000 },

-  { 0x8701, 0x0495, 0x2000 },

-  { 0x0701, 0x0494, 0x0000 },

-  { 0x0701, 0x0496, 0x0000 },

-  { 0x8701, 0x049b, 0x3000 },

-  { 0x8701, 0x0499, 0x2000 },

-  { 0x0701, 0x0498, 0x0000 },

-  { 0x0701, 0x049a, 0x0000 },

-  { 0x8701, 0x049d, 0x2000 },

-  { 0x0701, 0x049c, 0x0000 },

-  { 0x0d01, 0x04a0, 0x0000 },

-  { 0x8701, 0x081a, 0x6000 },

-  { 0x8701, 0x080a, 0x5000 },

-  { 0x8d01, 0x04a9, 0x4000 },

-  { 0x8d01, 0x04a5, 0x3000 },

-  { 0x8d01, 0x04a3, 0x2000 },

-  { 0x0d01, 0x04a2, 0x0000 },

-  { 0x0d01, 0x04a4, 0x0000 },

-  { 0x8d01, 0x04a7, 0x2000 },

-  { 0x0d01, 0x04a6, 0x0000 },

-  { 0x0d01, 0x04a8, 0x0000 },

-  { 0x8701, 0x0803, 0x3000 },

-  { 0x8701, 0x0801, 0x2000 },

-  { 0x0701, 0x0800, 0x0000 },

-  { 0x0701, 0x0802, 0x0000 },

-  { 0x8701, 0x0805, 0x2000 },

-  { 0x0701, 0x0804, 0x0000 },

-  { 0x0701, 0x0808, 0x0000 },

-  { 0x8701, 0x0812, 0x4000 },

-  { 0x8701, 0x080e, 0x3000 },

-  { 0x8701, 0x080c, 0x2000 },

-  { 0x0701, 0x080b, 0x0000 },

-  { 0x0701, 0x080d, 0x0000 },

-  { 0x8701, 0x0810, 0x2000 },

-  { 0x0701, 0x080f, 0x0000 },

-  { 0x0701, 0x0811, 0x0000 },

-  { 0x8701, 0x0816, 0x3000 },

-  { 0x8701, 0x0814, 0x2000 },

-  { 0x0701, 0x0813, 0x0000 },

-  { 0x0701, 0x0815, 0x0000 },

-  { 0x8701, 0x0818, 0x2000 },

-  { 0x0701, 0x0817, 0x0000 },

-  { 0x0701, 0x0819, 0x0000 },

-  { 0x8701, 0x082a, 0x5000 },

-  { 0x8701, 0x0822, 0x4000 },

-  { 0x8701, 0x081e, 0x3000 },

-  { 0x8701, 0x081c, 0x2000 },

-  { 0x0701, 0x081b, 0x0000 },

-  { 0x0701, 0x081d, 0x0000 },

-  { 0x8701, 0x0820, 0x2000 },

-  { 0x0701, 0x081f, 0x0000 },

-  { 0x0701, 0x0821, 0x0000 },

-  { 0x8701, 0x0826, 0x3000 },

-  { 0x8701, 0x0824, 0x2000 },

-  { 0x0701, 0x0823, 0x0000 },

-  { 0x0701, 0x0825, 0x0000 },

-  { 0x8701, 0x0828, 0x2000 },

-  { 0x0701, 0x0827, 0x0000 },

-  { 0x0701, 0x0829, 0x0000 },

-  { 0x8701, 0x0832, 0x4000 },

-  { 0x8701, 0x082e, 0x3000 },

-  { 0x8701, 0x082c, 0x2000 },

-  { 0x0701, 0x082b, 0x0000 },

-  { 0x0701, 0x082d, 0x0000 },

-  { 0x8701, 0x0830, 0x2000 },

-  { 0x0701, 0x082f, 0x0000 },

-  { 0x0701, 0x0831, 0x0000 },

-  { 0x8701, 0x0837, 0x3000 },

-  { 0x8701, 0x0834, 0x2000 },

-  { 0x0701, 0x0833, 0x0000 },

-  { 0x0701, 0x0835, 0x0000 },

-  { 0x8701, 0x083c, 0x2000 },

-  { 0x0701, 0x0838, 0x0000 },

-  { 0x0701, 0x083f, 0x0000 },

-  { 0x9a01, 0xd040, 0x7000 },

-  { 0x9a01, 0xd020, 0x6000 },

-  { 0x9a01, 0xd010, 0x5000 },

-  { 0x9a01, 0xd008, 0x4000 },

-  { 0x9a01, 0xd004, 0x3000 },

-  { 0x9a01, 0xd002, 0x2000 },

-  { 0x1a01, 0xd001, 0x0000 },

-  { 0x1a01, 0xd003, 0x0000 },

-  { 0x9a01, 0xd006, 0x2000 },

-  { 0x1a01, 0xd005, 0x0000 },

-  { 0x1a01, 0xd007, 0x0000 },

-  { 0x9a01, 0xd00c, 0x3000 },

-  { 0x9a01, 0xd00a, 0x2000 },

-  { 0x1a01, 0xd009, 0x0000 },

-  { 0x1a01, 0xd00b, 0x0000 },

-  { 0x9a01, 0xd00e, 0x2000 },

-  { 0x1a01, 0xd00d, 0x0000 },

-  { 0x1a01, 0xd00f, 0x0000 },

-  { 0x9a01, 0xd018, 0x4000 },

-  { 0x9a01, 0xd014, 0x3000 },

-  { 0x9a01, 0xd012, 0x2000 },

-  { 0x1a01, 0xd011, 0x0000 },

-  { 0x1a01, 0xd013, 0x0000 },

-  { 0x9a01, 0xd016, 0x2000 },

-  { 0x1a01, 0xd015, 0x0000 },

-  { 0x1a01, 0xd017, 0x0000 },

-  { 0x9a01, 0xd01c, 0x3000 },

-  { 0x9a01, 0xd01a, 0x2000 },

-  { 0x1a01, 0xd019, 0x0000 },

-  { 0x1a01, 0xd01b, 0x0000 },

-  { 0x9a01, 0xd01e, 0x2000 },

-  { 0x1a01, 0xd01d, 0x0000 },

-  { 0x1a01, 0xd01f, 0x0000 },

-  { 0x9a01, 0xd030, 0x5000 },

-  { 0x9a01, 0xd028, 0x4000 },

-  { 0x9a01, 0xd024, 0x3000 },

-  { 0x9a01, 0xd022, 0x2000 },

-  { 0x1a01, 0xd021, 0x0000 },

-  { 0x1a01, 0xd023, 0x0000 },

-  { 0x9a01, 0xd026, 0x2000 },

-  { 0x1a01, 0xd025, 0x0000 },

-  { 0x1a01, 0xd027, 0x0000 },

-  { 0x9a01, 0xd02c, 0x3000 },

-  { 0x9a01, 0xd02a, 0x2000 },

-  { 0x1a01, 0xd029, 0x0000 },

-  { 0x1a01, 0xd02b, 0x0000 },

-  { 0x9a01, 0xd02e, 0x2000 },

-  { 0x1a01, 0xd02d, 0x0000 },

-  { 0x1a01, 0xd02f, 0x0000 },

-  { 0x9a01, 0xd038, 0x4000 },

-  { 0x9a01, 0xd034, 0x3000 },

-  { 0x9a01, 0xd032, 0x2000 },

-  { 0x1a01, 0xd031, 0x0000 },

-  { 0x1a01, 0xd033, 0x0000 },

-  { 0x9a01, 0xd036, 0x2000 },

-  { 0x1a01, 0xd035, 0x0000 },

-  { 0x1a01, 0xd037, 0x0000 },

-  { 0x9a01, 0xd03c, 0x3000 },

-  { 0x9a01, 0xd03a, 0x2000 },

-  { 0x1a01, 0xd039, 0x0000 },

-  { 0x1a01, 0xd03b, 0x0000 },

-  { 0x9a01, 0xd03e, 0x2000 },

-  { 0x1a01, 0xd03d, 0x0000 },

-  { 0x1a01, 0xd03f, 0x0000 },

-  { 0x9a01, 0xd060, 0x6000 },

-  { 0x9a01, 0xd050, 0x5000 },

-  { 0x9a01, 0xd048, 0x4000 },

-  { 0x9a01, 0xd044, 0x3000 },

-  { 0x9a01, 0xd042, 0x2000 },

-  { 0x1a01, 0xd041, 0x0000 },

-  { 0x1a01, 0xd043, 0x0000 },

-  { 0x9a01, 0xd046, 0x2000 },

-  { 0x1a01, 0xd045, 0x0000 },

-  { 0x1a01, 0xd047, 0x0000 },

-  { 0x9a01, 0xd04c, 0x3000 },

-  { 0x9a01, 0xd04a, 0x2000 },

-  { 0x1a01, 0xd049, 0x0000 },

-  { 0x1a01, 0xd04b, 0x0000 },

-  { 0x9a01, 0xd04e, 0x2000 },

-  { 0x1a01, 0xd04d, 0x0000 },

-  { 0x1a01, 0xd04f, 0x0000 },

-  { 0x9a01, 0xd058, 0x4000 },

-  { 0x9a01, 0xd054, 0x3000 },

-  { 0x9a01, 0xd052, 0x2000 },

-  { 0x1a01, 0xd051, 0x0000 },

-  { 0x1a01, 0xd053, 0x0000 },

-  { 0x9a01, 0xd056, 0x2000 },

-  { 0x1a01, 0xd055, 0x0000 },

-  { 0x1a01, 0xd057, 0x0000 },

-  { 0x9a01, 0xd05c, 0x3000 },

-  { 0x9a01, 0xd05a, 0x2000 },

-  { 0x1a01, 0xd059, 0x0000 },

-  { 0x1a01, 0xd05b, 0x0000 },

-  { 0x9a01, 0xd05e, 0x2000 },

-  { 0x1a01, 0xd05d, 0x0000 },

-  { 0x1a01, 0xd05f, 0x0000 },

-  { 0x9a01, 0xd070, 0x5000 },

-  { 0x9a01, 0xd068, 0x4000 },

-  { 0x9a01, 0xd064, 0x3000 },

-  { 0x9a01, 0xd062, 0x2000 },

-  { 0x1a01, 0xd061, 0x0000 },

-  { 0x1a01, 0xd063, 0x0000 },

-  { 0x9a01, 0xd066, 0x2000 },

-  { 0x1a01, 0xd065, 0x0000 },

-  { 0x1a01, 0xd067, 0x0000 },

-  { 0x9a01, 0xd06c, 0x3000 },

-  { 0x9a01, 0xd06a, 0x2000 },

-  { 0x1a01, 0xd069, 0x0000 },

-  { 0x1a01, 0xd06b, 0x0000 },

-  { 0x9a01, 0xd06e, 0x2000 },

-  { 0x1a01, 0xd06d, 0x0000 },

-  { 0x1a01, 0xd06f, 0x0000 },

-  { 0x9a01, 0xd078, 0x4000 },

-  { 0x9a01, 0xd074, 0x3000 },

-  { 0x9a01, 0xd072, 0x2000 },

-  { 0x1a01, 0xd071, 0x0000 },

-  { 0x1a01, 0xd073, 0x0000 },

-  { 0x9a01, 0xd076, 0x2000 },

-  { 0x1a01, 0xd075, 0x0000 },

-  { 0x1a01, 0xd077, 0x0000 },

-  { 0x9a01, 0xd07c, 0x3000 },

-  { 0x9a01, 0xd07a, 0x2000 },

-  { 0x1a01, 0xd079, 0x0000 },

-  { 0x1a01, 0xd07b, 0x0000 },

-  { 0x9a01, 0xd07e, 0x2000 },

-  { 0x1a01, 0xd07d, 0x0000 },

-  { 0x1a01, 0xd07f, 0x0000 },

-  { 0x9a01, 0xd18d, 0x9000 },

-  { 0x9a01, 0xd10a, 0x8000 },

-  { 0x9a01, 0xd0c0, 0x7000 },

-  { 0x9a01, 0xd0a0, 0x6000 },

-  { 0x9a01, 0xd090, 0x5000 },

-  { 0x9a01, 0xd088, 0x4000 },

-  { 0x9a01, 0xd084, 0x3000 },

-  { 0x9a01, 0xd082, 0x2000 },

-  { 0x1a01, 0xd081, 0x0000 },

-  { 0x1a01, 0xd083, 0x0000 },

-  { 0x9a01, 0xd086, 0x2000 },

-  { 0x1a01, 0xd085, 0x0000 },

-  { 0x1a01, 0xd087, 0x0000 },

-  { 0x9a01, 0xd08c, 0x3000 },

-  { 0x9a01, 0xd08a, 0x2000 },

-  { 0x1a01, 0xd089, 0x0000 },

-  { 0x1a01, 0xd08b, 0x0000 },

-  { 0x9a01, 0xd08e, 0x2000 },

-  { 0x1a01, 0xd08d, 0x0000 },

-  { 0x1a01, 0xd08f, 0x0000 },

-  { 0x9a01, 0xd098, 0x4000 },

-  { 0x9a01, 0xd094, 0x3000 },

-  { 0x9a01, 0xd092, 0x2000 },

-  { 0x1a01, 0xd091, 0x0000 },

-  { 0x1a01, 0xd093, 0x0000 },

-  { 0x9a01, 0xd096, 0x2000 },

-  { 0x1a01, 0xd095, 0x0000 },

-  { 0x1a01, 0xd097, 0x0000 },

-  { 0x9a01, 0xd09c, 0x3000 },

-  { 0x9a01, 0xd09a, 0x2000 },

-  { 0x1a01, 0xd099, 0x0000 },

-  { 0x1a01, 0xd09b, 0x0000 },

-  { 0x9a01, 0xd09e, 0x2000 },

-  { 0x1a01, 0xd09d, 0x0000 },

-  { 0x1a01, 0xd09f, 0x0000 },

-  { 0x9a01, 0xd0b0, 0x5000 },

-  { 0x9a01, 0xd0a8, 0x4000 },

-  { 0x9a01, 0xd0a4, 0x3000 },

-  { 0x9a01, 0xd0a2, 0x2000 },

-  { 0x1a01, 0xd0a1, 0x0000 },

-  { 0x1a01, 0xd0a3, 0x0000 },

-  { 0x9a01, 0xd0a6, 0x2000 },

-  { 0x1a01, 0xd0a5, 0x0000 },

-  { 0x1a01, 0xd0a7, 0x0000 },

-  { 0x9a01, 0xd0ac, 0x3000 },

-  { 0x9a01, 0xd0aa, 0x2000 },

-  { 0x1a01, 0xd0a9, 0x0000 },

-  { 0x1a01, 0xd0ab, 0x0000 },

-  { 0x9a01, 0xd0ae, 0x2000 },

-  { 0x1a01, 0xd0ad, 0x0000 },

-  { 0x1a01, 0xd0af, 0x0000 },

-  { 0x9a01, 0xd0b8, 0x4000 },

-  { 0x9a01, 0xd0b4, 0x3000 },

-  { 0x9a01, 0xd0b2, 0x2000 },

-  { 0x1a01, 0xd0b1, 0x0000 },

-  { 0x1a01, 0xd0b3, 0x0000 },

-  { 0x9a01, 0xd0b6, 0x2000 },

-  { 0x1a01, 0xd0b5, 0x0000 },

-  { 0x1a01, 0xd0b7, 0x0000 },

-  { 0x9a01, 0xd0bc, 0x3000 },

-  { 0x9a01, 0xd0ba, 0x2000 },

-  { 0x1a01, 0xd0b9, 0x0000 },

-  { 0x1a01, 0xd0bb, 0x0000 },

-  { 0x9a01, 0xd0be, 0x2000 },

-  { 0x1a01, 0xd0bd, 0x0000 },

-  { 0x1a01, 0xd0bf, 0x0000 },

-  { 0x9a01, 0xd0e0, 0x6000 },

-  { 0x9a01, 0xd0d0, 0x5000 },

-  { 0x9a01, 0xd0c8, 0x4000 },

-  { 0x9a01, 0xd0c4, 0x3000 },

-  { 0x9a01, 0xd0c2, 0x2000 },

-  { 0x1a01, 0xd0c1, 0x0000 },

-  { 0x1a01, 0xd0c3, 0x0000 },

-  { 0x9a01, 0xd0c6, 0x2000 },

-  { 0x1a01, 0xd0c5, 0x0000 },

-  { 0x1a01, 0xd0c7, 0x0000 },

-  { 0x9a01, 0xd0cc, 0x3000 },

-  { 0x9a01, 0xd0ca, 0x2000 },

-  { 0x1a01, 0xd0c9, 0x0000 },

-  { 0x1a01, 0xd0cb, 0x0000 },

-  { 0x9a01, 0xd0ce, 0x2000 },

-  { 0x1a01, 0xd0cd, 0x0000 },

-  { 0x1a01, 0xd0cf, 0x0000 },

-  { 0x9a01, 0xd0d8, 0x4000 },

-  { 0x9a01, 0xd0d4, 0x3000 },

-  { 0x9a01, 0xd0d2, 0x2000 },

-  { 0x1a01, 0xd0d1, 0x0000 },

-  { 0x1a01, 0xd0d3, 0x0000 },

-  { 0x9a01, 0xd0d6, 0x2000 },

-  { 0x1a01, 0xd0d5, 0x0000 },

-  { 0x1a01, 0xd0d7, 0x0000 },

-  { 0x9a01, 0xd0dc, 0x3000 },

-  { 0x9a01, 0xd0da, 0x2000 },

-  { 0x1a01, 0xd0d9, 0x0000 },

-  { 0x1a01, 0xd0db, 0x0000 },

-  { 0x9a01, 0xd0de, 0x2000 },

-  { 0x1a01, 0xd0dd, 0x0000 },

-  { 0x1a01, 0xd0df, 0x0000 },

-  { 0x9a01, 0xd0f0, 0x5000 },

-  { 0x9a01, 0xd0e8, 0x4000 },

-  { 0x9a01, 0xd0e4, 0x3000 },

-  { 0x9a01, 0xd0e2, 0x2000 },

-  { 0x1a01, 0xd0e1, 0x0000 },

-  { 0x1a01, 0xd0e3, 0x0000 },

-  { 0x9a01, 0xd0e6, 0x2000 },

-  { 0x1a01, 0xd0e5, 0x0000 },

-  { 0x1a01, 0xd0e7, 0x0000 },

-  { 0x9a01, 0xd0ec, 0x3000 },

-  { 0x9a01, 0xd0ea, 0x2000 },

-  { 0x1a01, 0xd0e9, 0x0000 },

-  { 0x1a01, 0xd0eb, 0x0000 },

-  { 0x9a01, 0xd0ee, 0x2000 },

-  { 0x1a01, 0xd0ed, 0x0000 },

-  { 0x1a01, 0xd0ef, 0x0000 },

-  { 0x9a01, 0xd102, 0x4000 },

-  { 0x9a01, 0xd0f4, 0x3000 },

-  { 0x9a01, 0xd0f2, 0x2000 },

-  { 0x1a01, 0xd0f1, 0x0000 },

-  { 0x1a01, 0xd0f3, 0x0000 },

-  { 0x9a01, 0xd100, 0x2000 },

-  { 0x1a01, 0xd0f5, 0x0000 },

-  { 0x1a01, 0xd101, 0x0000 },

-  { 0x9a01, 0xd106, 0x3000 },

-  { 0x9a01, 0xd104, 0x2000 },

-  { 0x1a01, 0xd103, 0x0000 },

-  { 0x1a01, 0xd105, 0x0000 },

-  { 0x9a01, 0xd108, 0x2000 },

-  { 0x1a01, 0xd107, 0x0000 },

-  { 0x1a01, 0xd109, 0x0000 },

-  { 0x9a01, 0xd14d, 0x7000 },

-  { 0x9a01, 0xd12d, 0x6000 },

-  { 0x9a01, 0xd11a, 0x5000 },

-  { 0x9a01, 0xd112, 0x4000 },

-  { 0x9a01, 0xd10e, 0x3000 },

-  { 0x9a01, 0xd10c, 0x2000 },

-  { 0x1a01, 0xd10b, 0x0000 },

-  { 0x1a01, 0xd10d, 0x0000 },

-  { 0x9a01, 0xd110, 0x2000 },

-  { 0x1a01, 0xd10f, 0x0000 },

-  { 0x1a01, 0xd111, 0x0000 },

-  { 0x9a01, 0xd116, 0x3000 },

-  { 0x9a01, 0xd114, 0x2000 },

-  { 0x1a01, 0xd113, 0x0000 },

-  { 0x1a01, 0xd115, 0x0000 },

-  { 0x9a01, 0xd118, 0x2000 },

-  { 0x1a01, 0xd117, 0x0000 },

-  { 0x1a01, 0xd119, 0x0000 },

-  { 0x9a01, 0xd122, 0x4000 },

-  { 0x9a01, 0xd11e, 0x3000 },

-  { 0x9a01, 0xd11c, 0x2000 },

-  { 0x1a01, 0xd11b, 0x0000 },

-  { 0x1a01, 0xd11d, 0x0000 },

-  { 0x9a01, 0xd120, 0x2000 },

-  { 0x1a01, 0xd11f, 0x0000 },

-  { 0x1a01, 0xd121, 0x0000 },

-  { 0x9a01, 0xd126, 0x3000 },

-  { 0x9a01, 0xd124, 0x2000 },

-  { 0x1a01, 0xd123, 0x0000 },

-  { 0x1a01, 0xd125, 0x0000 },

-  { 0x9a01, 0xd12b, 0x2000 },

-  { 0x1a01, 0xd12a, 0x0000 },

-  { 0x1a01, 0xd12c, 0x0000 },

-  { 0x9a01, 0xd13d, 0x5000 },

-  { 0x9a01, 0xd135, 0x4000 },

-  { 0x9a01, 0xd131, 0x3000 },

-  { 0x9a01, 0xd12f, 0x2000 },

-  { 0x1a01, 0xd12e, 0x0000 },

-  { 0x1a01, 0xd130, 0x0000 },

-  { 0x9a01, 0xd133, 0x2000 },

-  { 0x1a01, 0xd132, 0x0000 },

-  { 0x1a01, 0xd134, 0x0000 },

-  { 0x9a01, 0xd139, 0x3000 },

-  { 0x9a01, 0xd137, 0x2000 },

-  { 0x1a01, 0xd136, 0x0000 },

-  { 0x1a01, 0xd138, 0x0000 },

-  { 0x9a01, 0xd13b, 0x2000 },

-  { 0x1a01, 0xd13a, 0x0000 },

-  { 0x1a01, 0xd13c, 0x0000 },

-  { 0x9a01, 0xd145, 0x4000 },

-  { 0x9a01, 0xd141, 0x3000 },

-  { 0x9a01, 0xd13f, 0x2000 },

-  { 0x1a01, 0xd13e, 0x0000 },

-  { 0x1a01, 0xd140, 0x0000 },

-  { 0x9a01, 0xd143, 0x2000 },

-  { 0x1a01, 0xd142, 0x0000 },

-  { 0x1a01, 0xd144, 0x0000 },

-  { 0x9a01, 0xd149, 0x3000 },

-  { 0x9a01, 0xd147, 0x2000 },

-  { 0x1a01, 0xd146, 0x0000 },

-  { 0x1a01, 0xd148, 0x0000 },

-  { 0x9a01, 0xd14b, 0x2000 },

-  { 0x1a01, 0xd14a, 0x0000 },

-  { 0x1a01, 0xd14c, 0x0000 },

-  { 0x8a01, 0xd16d, 0x6000 },

-  { 0x9a01, 0xd15d, 0x5000 },

-  { 0x9a01, 0xd155, 0x4000 },

-  { 0x9a01, 0xd151, 0x3000 },

-  { 0x9a01, 0xd14f, 0x2000 },

-  { 0x1a01, 0xd14e, 0x0000 },

-  { 0x1a01, 0xd150, 0x0000 },

-  { 0x9a01, 0xd153, 0x2000 },

-  { 0x1a01, 0xd152, 0x0000 },

-  { 0x1a01, 0xd154, 0x0000 },

-  { 0x9a01, 0xd159, 0x3000 },

-  { 0x9a01, 0xd157, 0x2000 },

-  { 0x1a01, 0xd156, 0x0000 },

-  { 0x1a01, 0xd158, 0x0000 },

-  { 0x9a01, 0xd15b, 0x2000 },

-  { 0x1a01, 0xd15a, 0x0000 },

-  { 0x1a01, 0xd15c, 0x0000 },

-  { 0x8a01, 0xd165, 0x4000 },

-  { 0x9a01, 0xd161, 0x3000 },

-  { 0x9a01, 0xd15f, 0x2000 },

-  { 0x1a01, 0xd15e, 0x0000 },

-  { 0x1a01, 0xd160, 0x0000 },

-  { 0x9a01, 0xd163, 0x2000 },

-  { 0x1a01, 0xd162, 0x0000 },

-  { 0x1a01, 0xd164, 0x0000 },

-  { 0x8c01, 0xd169, 0x3000 },

-  { 0x8c01, 0xd167, 0x2000 },

-  { 0x0a01, 0xd166, 0x0000 },

-  { 0x0c01, 0xd168, 0x0000 },

-  { 0x9a01, 0xd16b, 0x2000 },

-  { 0x1a01, 0xd16a, 0x0000 },

-  { 0x1a01, 0xd16c, 0x0000 },

-  { 0x8c01, 0xd17d, 0x5000 },

-  { 0x8101, 0xd175, 0x4000 },

-  { 0x8a01, 0xd171, 0x3000 },

-  { 0x8a01, 0xd16f, 0x2000 },

-  { 0x0a01, 0xd16e, 0x0000 },

-  { 0x0a01, 0xd170, 0x0000 },

-  { 0x8101, 0xd173, 0x2000 },

-  { 0x0a01, 0xd172, 0x0000 },

-  { 0x0101, 0xd174, 0x0000 },

-  { 0x8101, 0xd179, 0x3000 },

-  { 0x8101, 0xd177, 0x2000 },

-  { 0x0101, 0xd176, 0x0000 },

-  { 0x0101, 0xd178, 0x0000 },

-  { 0x8c01, 0xd17b, 0x2000 },

-  { 0x0101, 0xd17a, 0x0000 },

-  { 0x0c01, 0xd17c, 0x0000 },

-  { 0x8c01, 0xd185, 0x4000 },

-  { 0x8c01, 0xd181, 0x3000 },

-  { 0x8c01, 0xd17f, 0x2000 },

-  { 0x0c01, 0xd17e, 0x0000 },

-  { 0x0c01, 0xd180, 0x0000 },

-  { 0x9a01, 0xd183, 0x2000 },

-  { 0x0c01, 0xd182, 0x0000 },

-  { 0x1a01, 0xd184, 0x0000 },

-  { 0x8c01, 0xd189, 0x3000 },

-  { 0x8c01, 0xd187, 0x2000 },

-  { 0x0c01, 0xd186, 0x0000 },

-  { 0x0c01, 0xd188, 0x0000 },

-  { 0x8c01, 0xd18b, 0x2000 },

-  { 0x0c01, 0xd18a, 0x0000 },

-  { 0x1a01, 0xd18c, 0x0000 },

-  { 0x9a01, 0xd32f, 0x8000 },

-  { 0x9a01, 0xd1cd, 0x7000 },

-  { 0x8c01, 0xd1ad, 0x6000 },

-  { 0x9a01, 0xd19d, 0x5000 },

-  { 0x9a01, 0xd195, 0x4000 },

-  { 0x9a01, 0xd191, 0x3000 },

-  { 0x9a01, 0xd18f, 0x2000 },

-  { 0x1a01, 0xd18e, 0x0000 },

-  { 0x1a01, 0xd190, 0x0000 },

-  { 0x9a01, 0xd193, 0x2000 },

-  { 0x1a01, 0xd192, 0x0000 },

-  { 0x1a01, 0xd194, 0x0000 },

-  { 0x9a01, 0xd199, 0x3000 },

-  { 0x9a01, 0xd197, 0x2000 },

-  { 0x1a01, 0xd196, 0x0000 },

-  { 0x1a01, 0xd198, 0x0000 },

-  { 0x9a01, 0xd19b, 0x2000 },

-  { 0x1a01, 0xd19a, 0x0000 },

-  { 0x1a01, 0xd19c, 0x0000 },

-  { 0x9a01, 0xd1a5, 0x4000 },

-  { 0x9a01, 0xd1a1, 0x3000 },

-  { 0x9a01, 0xd19f, 0x2000 },

-  { 0x1a01, 0xd19e, 0x0000 },

-  { 0x1a01, 0xd1a0, 0x0000 },

-  { 0x9a01, 0xd1a3, 0x2000 },

-  { 0x1a01, 0xd1a2, 0x0000 },

-  { 0x1a01, 0xd1a4, 0x0000 },

-  { 0x9a01, 0xd1a9, 0x3000 },

-  { 0x9a01, 0xd1a7, 0x2000 },

-  { 0x1a01, 0xd1a6, 0x0000 },

-  { 0x1a01, 0xd1a8, 0x0000 },

-  { 0x8c01, 0xd1ab, 0x2000 },

-  { 0x0c01, 0xd1aa, 0x0000 },

-  { 0x0c01, 0xd1ac, 0x0000 },

-  { 0x9a01, 0xd1bd, 0x5000 },

-  { 0x9a01, 0xd1b5, 0x4000 },

-  { 0x9a01, 0xd1b1, 0x3000 },

-  { 0x9a01, 0xd1af, 0x2000 },

-  { 0x1a01, 0xd1ae, 0x0000 },

-  { 0x1a01, 0xd1b0, 0x0000 },

-  { 0x9a01, 0xd1b3, 0x2000 },

-  { 0x1a01, 0xd1b2, 0x0000 },

-  { 0x1a01, 0xd1b4, 0x0000 },

-  { 0x9a01, 0xd1b9, 0x3000 },

-  { 0x9a01, 0xd1b7, 0x2000 },

-  { 0x1a01, 0xd1b6, 0x0000 },

-  { 0x1a01, 0xd1b8, 0x0000 },

-  { 0x9a01, 0xd1bb, 0x2000 },

-  { 0x1a01, 0xd1ba, 0x0000 },

-  { 0x1a01, 0xd1bc, 0x0000 },

-  { 0x9a01, 0xd1c5, 0x4000 },

-  { 0x9a01, 0xd1c1, 0x3000 },

-  { 0x9a01, 0xd1bf, 0x2000 },

-  { 0x1a01, 0xd1be, 0x0000 },

-  { 0x1a01, 0xd1c0, 0x0000 },

-  { 0x9a01, 0xd1c3, 0x2000 },

-  { 0x1a01, 0xd1c2, 0x0000 },

-  { 0x1a01, 0xd1c4, 0x0000 },

-  { 0x9a01, 0xd1c9, 0x3000 },

-  { 0x9a01, 0xd1c7, 0x2000 },

-  { 0x1a01, 0xd1c6, 0x0000 },

-  { 0x1a01, 0xd1c8, 0x0000 },

-  { 0x9a01, 0xd1cb, 0x2000 },

-  { 0x1a01, 0xd1ca, 0x0000 },

-  { 0x1a01, 0xd1cc, 0x0000 },

-  { 0x9a01, 0xd30f, 0x6000 },

-  { 0x9a01, 0xd1dd, 0x5000 },

-  { 0x9a01, 0xd1d5, 0x4000 },

-  { 0x9a01, 0xd1d1, 0x3000 },

-  { 0x9a01, 0xd1cf, 0x2000 },

-  { 0x1a01, 0xd1ce, 0x0000 },

-  { 0x1a01, 0xd1d0, 0x0000 },

-  { 0x9a01, 0xd1d3, 0x2000 },

-  { 0x1a01, 0xd1d2, 0x0000 },

-  { 0x1a01, 0xd1d4, 0x0000 },

-  { 0x9a01, 0xd1d9, 0x3000 },

-  { 0x9a01, 0xd1d7, 0x2000 },

-  { 0x1a01, 0xd1d6, 0x0000 },

-  { 0x1a01, 0xd1d8, 0x0000 },

-  { 0x9a01, 0xd1db, 0x2000 },

-  { 0x1a01, 0xd1da, 0x0000 },

-  { 0x1a01, 0xd1dc, 0x0000 },

-  { 0x9a01, 0xd307, 0x4000 },

-  { 0x9a01, 0xd303, 0x3000 },

-  { 0x9a01, 0xd301, 0x2000 },

-  { 0x1a01, 0xd300, 0x0000 },

-  { 0x1a01, 0xd302, 0x0000 },

-  { 0x9a01, 0xd305, 0x2000 },

-  { 0x1a01, 0xd304, 0x0000 },

-  { 0x1a01, 0xd306, 0x0000 },

-  { 0x9a01, 0xd30b, 0x3000 },

-  { 0x9a01, 0xd309, 0x2000 },

-  { 0x1a01, 0xd308, 0x0000 },

-  { 0x1a01, 0xd30a, 0x0000 },

-  { 0x9a01, 0xd30d, 0x2000 },

-  { 0x1a01, 0xd30c, 0x0000 },

-  { 0x1a01, 0xd30e, 0x0000 },

-  { 0x9a01, 0xd31f, 0x5000 },

-  { 0x9a01, 0xd317, 0x4000 },

-  { 0x9a01, 0xd313, 0x3000 },

-  { 0x9a01, 0xd311, 0x2000 },

-  { 0x1a01, 0xd310, 0x0000 },

-  { 0x1a01, 0xd312, 0x0000 },

-  { 0x9a01, 0xd315, 0x2000 },

-  { 0x1a01, 0xd314, 0x0000 },

-  { 0x1a01, 0xd316, 0x0000 },

-  { 0x9a01, 0xd31b, 0x3000 },

-  { 0x9a01, 0xd319, 0x2000 },

-  { 0x1a01, 0xd318, 0x0000 },

-  { 0x1a01, 0xd31a, 0x0000 },

-  { 0x9a01, 0xd31d, 0x2000 },

-  { 0x1a01, 0xd31c, 0x0000 },

-  { 0x1a01, 0xd31e, 0x0000 },

-  { 0x9a01, 0xd327, 0x4000 },

-  { 0x9a01, 0xd323, 0x3000 },

-  { 0x9a01, 0xd321, 0x2000 },

-  { 0x1a01, 0xd320, 0x0000 },

-  { 0x1a01, 0xd322, 0x0000 },

-  { 0x9a01, 0xd325, 0x2000 },

-  { 0x1a01, 0xd324, 0x0000 },

-  { 0x1a01, 0xd326, 0x0000 },

-  { 0x9a01, 0xd32b, 0x3000 },

-  { 0x9a01, 0xd329, 0x2000 },

-  { 0x1a01, 0xd328, 0x0000 },

-  { 0x1a01, 0xd32a, 0x0000 },

-  { 0x9a01, 0xd32d, 0x2000 },

-  { 0x1a01, 0xd32c, 0x0000 },

-  { 0x1a01, 0xd32e, 0x0000 },

-  { 0x8901, 0xd418, 0x7000 },

-  { 0x9a01, 0xd34f, 0x6000 },

-  { 0x9a01, 0xd33f, 0x5000 },

-  { 0x9a01, 0xd337, 0x4000 },

-  { 0x9a01, 0xd333, 0x3000 },

-  { 0x9a01, 0xd331, 0x2000 },

-  { 0x1a01, 0xd330, 0x0000 },

-  { 0x1a01, 0xd332, 0x0000 },

-  { 0x9a01, 0xd335, 0x2000 },

-  { 0x1a01, 0xd334, 0x0000 },

-  { 0x1a01, 0xd336, 0x0000 },

-  { 0x9a01, 0xd33b, 0x3000 },

-  { 0x9a01, 0xd339, 0x2000 },

-  { 0x1a01, 0xd338, 0x0000 },

-  { 0x1a01, 0xd33a, 0x0000 },

-  { 0x9a01, 0xd33d, 0x2000 },

-  { 0x1a01, 0xd33c, 0x0000 },

-  { 0x1a01, 0xd33e, 0x0000 },

-  { 0x9a01, 0xd347, 0x4000 },

-  { 0x9a01, 0xd343, 0x3000 },

-  { 0x9a01, 0xd341, 0x2000 },

-  { 0x1a01, 0xd340, 0x0000 },

-  { 0x1a01, 0xd342, 0x0000 },

-  { 0x9a01, 0xd345, 0x2000 },

-  { 0x1a01, 0xd344, 0x0000 },

-  { 0x1a01, 0xd346, 0x0000 },

-  { 0x9a01, 0xd34b, 0x3000 },

-  { 0x9a01, 0xd349, 0x2000 },

-  { 0x1a01, 0xd348, 0x0000 },

-  { 0x1a01, 0xd34a, 0x0000 },

-  { 0x9a01, 0xd34d, 0x2000 },

-  { 0x1a01, 0xd34c, 0x0000 },

-  { 0x1a01, 0xd34e, 0x0000 },

-  { 0x8901, 0xd408, 0x5000 },

-  { 0x8901, 0xd400, 0x4000 },

-  { 0x9a01, 0xd353, 0x3000 },

-  { 0x9a01, 0xd351, 0x2000 },

-  { 0x1a01, 0xd350, 0x0000 },

-  { 0x1a01, 0xd352, 0x0000 },

-  { 0x9a01, 0xd355, 0x2000 },

-  { 0x1a01, 0xd354, 0x0000 },

-  { 0x1a01, 0xd356, 0x0000 },

-  { 0x8901, 0xd404, 0x3000 },

-  { 0x8901, 0xd402, 0x2000 },

-  { 0x0901, 0xd401, 0x0000 },

-  { 0x0901, 0xd403, 0x0000 },

-  { 0x8901, 0xd406, 0x2000 },

-  { 0x0901, 0xd405, 0x0000 },

-  { 0x0901, 0xd407, 0x0000 },

-  { 0x8901, 0xd410, 0x4000 },

-  { 0x8901, 0xd40c, 0x3000 },

-  { 0x8901, 0xd40a, 0x2000 },

-  { 0x0901, 0xd409, 0x0000 },

-  { 0x0901, 0xd40b, 0x0000 },

-  { 0x8901, 0xd40e, 0x2000 },

-  { 0x0901, 0xd40d, 0x0000 },

-  { 0x0901, 0xd40f, 0x0000 },

-  { 0x8901, 0xd414, 0x3000 },

-  { 0x8901, 0xd412, 0x2000 },

-  { 0x0901, 0xd411, 0x0000 },

-  { 0x0901, 0xd413, 0x0000 },

-  { 0x8901, 0xd416, 0x2000 },

-  { 0x0901, 0xd415, 0x0000 },

-  { 0x0901, 0xd417, 0x0000 },

-  { 0x8901, 0xd438, 0x6000 },

-  { 0x8501, 0xd428, 0x5000 },

-  { 0x8501, 0xd420, 0x4000 },

-  { 0x8501, 0xd41c, 0x3000 },

-  { 0x8501, 0xd41a, 0x2000 },

-  { 0x0901, 0xd419, 0x0000 },

-  { 0x0501, 0xd41b, 0x0000 },

-  { 0x8501, 0xd41e, 0x2000 },

-  { 0x0501, 0xd41d, 0x0000 },

-  { 0x0501, 0xd41f, 0x0000 },

-  { 0x8501, 0xd424, 0x3000 },

-  { 0x8501, 0xd422, 0x2000 },

-  { 0x0501, 0xd421, 0x0000 },

-  { 0x0501, 0xd423, 0x0000 },

-  { 0x8501, 0xd426, 0x2000 },

-  { 0x0501, 0xd425, 0x0000 },

-  { 0x0501, 0xd427, 0x0000 },

-  { 0x8501, 0xd430, 0x4000 },

-  { 0x8501, 0xd42c, 0x3000 },

-  { 0x8501, 0xd42a, 0x2000 },

-  { 0x0501, 0xd429, 0x0000 },

-  { 0x0501, 0xd42b, 0x0000 },

-  { 0x8501, 0xd42e, 0x2000 },

-  { 0x0501, 0xd42d, 0x0000 },

-  { 0x0501, 0xd42f, 0x0000 },

-  { 0x8901, 0xd434, 0x3000 },

-  { 0x8501, 0xd432, 0x2000 },

-  { 0x0501, 0xd431, 0x0000 },

-  { 0x0501, 0xd433, 0x0000 },

-  { 0x8901, 0xd436, 0x2000 },

-  { 0x0901, 0xd435, 0x0000 },

-  { 0x0901, 0xd437, 0x0000 },

-  { 0x8901, 0xd448, 0x5000 },

-  { 0x8901, 0xd440, 0x4000 },

-  { 0x8901, 0xd43c, 0x3000 },

-  { 0x8901, 0xd43a, 0x2000 },

-  { 0x0901, 0xd439, 0x0000 },

-  { 0x0901, 0xd43b, 0x0000 },

-  { 0x8901, 0xd43e, 0x2000 },

-  { 0x0901, 0xd43d, 0x0000 },

-  { 0x0901, 0xd43f, 0x0000 },

-  { 0x8901, 0xd444, 0x3000 },

-  { 0x8901, 0xd442, 0x2000 },

-  { 0x0901, 0xd441, 0x0000 },

-  { 0x0901, 0xd443, 0x0000 },

-  { 0x8901, 0xd446, 0x2000 },

-  { 0x0901, 0xd445, 0x0000 },

-  { 0x0901, 0xd447, 0x0000 },

-  { 0x8501, 0xd450, 0x4000 },

-  { 0x8901, 0xd44c, 0x3000 },

-  { 0x8901, 0xd44a, 0x2000 },

-  { 0x0901, 0xd449, 0x0000 },

-  { 0x0901, 0xd44b, 0x0000 },

-  { 0x8501, 0xd44e, 0x2000 },

-  { 0x0901, 0xd44d, 0x0000 },

-  { 0x0501, 0xd44f, 0x0000 },

-  { 0x8501, 0xd454, 0x3000 },

-  { 0x8501, 0xd452, 0x2000 },

-  { 0x0501, 0xd451, 0x0000 },

-  { 0x0501, 0xd453, 0x0000 },

-  { 0x8501, 0xd457, 0x2000 },

-  { 0x0501, 0xd456, 0x0000 },

-  { 0x0501, 0xd458, 0x0000 },

-  { 0x8702, 0xf876, 0xb000 },

-  { 0x8901, 0xd670, 0xa000 },

-  { 0x8901, 0xd570, 0x9000 },

-  { 0x8901, 0xd4e4, 0x8000 },

-  { 0x8501, 0xd499, 0x7000 },

-  { 0x8901, 0xd479, 0x6000 },

-  { 0x8901, 0xd469, 0x5000 },

-  { 0x8501, 0xd461, 0x4000 },

-  { 0x8501, 0xd45d, 0x3000 },

-  { 0x8501, 0xd45b, 0x2000 },

-  { 0x0501, 0xd45a, 0x0000 },

-  { 0x0501, 0xd45c, 0x0000 },

-  { 0x8501, 0xd45f, 0x2000 },

-  { 0x0501, 0xd45e, 0x0000 },

-  { 0x0501, 0xd460, 0x0000 },

-  { 0x8501, 0xd465, 0x3000 },

-  { 0x8501, 0xd463, 0x2000 },

-  { 0x0501, 0xd462, 0x0000 },

-  { 0x0501, 0xd464, 0x0000 },

-  { 0x8501, 0xd467, 0x2000 },

-  { 0x0501, 0xd466, 0x0000 },

-  { 0x0901, 0xd468, 0x0000 },

-  { 0x8901, 0xd471, 0x4000 },

-  { 0x8901, 0xd46d, 0x3000 },

-  { 0x8901, 0xd46b, 0x2000 },

-  { 0x0901, 0xd46a, 0x0000 },

-  { 0x0901, 0xd46c, 0x0000 },

-  { 0x8901, 0xd46f, 0x2000 },

-  { 0x0901, 0xd46e, 0x0000 },

-  { 0x0901, 0xd470, 0x0000 },

-  { 0x8901, 0xd475, 0x3000 },

-  { 0x8901, 0xd473, 0x2000 },

-  { 0x0901, 0xd472, 0x0000 },

-  { 0x0901, 0xd474, 0x0000 },

-  { 0x8901, 0xd477, 0x2000 },

-  { 0x0901, 0xd476, 0x0000 },

-  { 0x0901, 0xd478, 0x0000 },

-  { 0x8501, 0xd489, 0x5000 },

-  { 0x8901, 0xd481, 0x4000 },

-  { 0x8901, 0xd47d, 0x3000 },

-  { 0x8901, 0xd47b, 0x2000 },

-  { 0x0901, 0xd47a, 0x0000 },

-  { 0x0901, 0xd47c, 0x0000 },

-  { 0x8901, 0xd47f, 0x2000 },

-  { 0x0901, 0xd47e, 0x0000 },

-  { 0x0901, 0xd480, 0x0000 },

-  { 0x8501, 0xd485, 0x3000 },

-  { 0x8501, 0xd483, 0x2000 },

-  { 0x0501, 0xd482, 0x0000 },

-  { 0x0501, 0xd484, 0x0000 },

-  { 0x8501, 0xd487, 0x2000 },

-  { 0x0501, 0xd486, 0x0000 },

-  { 0x0501, 0xd488, 0x0000 },

-  { 0x8501, 0xd491, 0x4000 },

-  { 0x8501, 0xd48d, 0x3000 },

-  { 0x8501, 0xd48b, 0x2000 },

-  { 0x0501, 0xd48a, 0x0000 },

-  { 0x0501, 0xd48c, 0x0000 },

-  { 0x8501, 0xd48f, 0x2000 },

-  { 0x0501, 0xd48e, 0x0000 },

-  { 0x0501, 0xd490, 0x0000 },

-  { 0x8501, 0xd495, 0x3000 },

-  { 0x8501, 0xd493, 0x2000 },

-  { 0x0501, 0xd492, 0x0000 },

-  { 0x0501, 0xd494, 0x0000 },

-  { 0x8501, 0xd497, 0x2000 },

-  { 0x0501, 0xd496, 0x0000 },

-  { 0x0501, 0xd498, 0x0000 },

-  { 0x8501, 0xd4c3, 0x6000 },

-  { 0x8901, 0xd4b1, 0x5000 },

-  { 0x8901, 0xd4a6, 0x4000 },

-  { 0x8901, 0xd49e, 0x3000 },

-  { 0x8501, 0xd49b, 0x2000 },

-  { 0x0501, 0xd49a, 0x0000 },

-  { 0x0901, 0xd49c, 0x0000 },

-  { 0x8901, 0xd4a2, 0x2000 },

-  { 0x0901, 0xd49f, 0x0000 },

-  { 0x0901, 0xd4a5, 0x0000 },

-  { 0x8901, 0xd4ac, 0x3000 },

-  { 0x8901, 0xd4aa, 0x2000 },

-  { 0x0901, 0xd4a9, 0x0000 },

-  { 0x0901, 0xd4ab, 0x0000 },

-  { 0x8901, 0xd4af, 0x2000 },

-  { 0x0901, 0xd4ae, 0x0000 },

-  { 0x0901, 0xd4b0, 0x0000 },

-  { 0x8501, 0xd4b9, 0x4000 },

-  { 0x8901, 0xd4b5, 0x3000 },

-  { 0x8901, 0xd4b3, 0x2000 },

-  { 0x0901, 0xd4b2, 0x0000 },

-  { 0x0901, 0xd4b4, 0x0000 },

-  { 0x8501, 0xd4b7, 0x2000 },

-  { 0x0501, 0xd4b6, 0x0000 },

-  { 0x0501, 0xd4b8, 0x0000 },

-  { 0x8501, 0xd4bf, 0x3000 },

-  { 0x8501, 0xd4bd, 0x2000 },

-  { 0x0501, 0xd4bb, 0x0000 },

-  { 0x0501, 0xd4be, 0x0000 },

-  { 0x8501, 0xd4c1, 0x2000 },

-  { 0x0501, 0xd4c0, 0x0000 },

-  { 0x0501, 0xd4c2, 0x0000 },

-  { 0x8901, 0xd4d4, 0x5000 },

-  { 0x8501, 0xd4cc, 0x4000 },

-  { 0x8501, 0xd4c8, 0x3000 },

-  { 0x8501, 0xd4c6, 0x2000 },

-  { 0x0501, 0xd4c5, 0x0000 },

-  { 0x0501, 0xd4c7, 0x0000 },

-  { 0x8501, 0xd4ca, 0x2000 },

-  { 0x0501, 0xd4c9, 0x0000 },

-  { 0x0501, 0xd4cb, 0x0000 },

-  { 0x8901, 0xd4d0, 0x3000 },

-  { 0x8501, 0xd4ce, 0x2000 },

-  { 0x0501, 0xd4cd, 0x0000 },

-  { 0x0501, 0xd4cf, 0x0000 },

-  { 0x8901, 0xd4d2, 0x2000 },

-  { 0x0901, 0xd4d1, 0x0000 },

-  { 0x0901, 0xd4d3, 0x0000 },

-  { 0x8901, 0xd4dc, 0x4000 },

-  { 0x8901, 0xd4d8, 0x3000 },

-  { 0x8901, 0xd4d6, 0x2000 },

-  { 0x0901, 0xd4d5, 0x0000 },

-  { 0x0901, 0xd4d7, 0x0000 },

-  { 0x8901, 0xd4da, 0x2000 },

-  { 0x0901, 0xd4d9, 0x0000 },

-  { 0x0901, 0xd4db, 0x0000 },

-  { 0x8901, 0xd4e0, 0x3000 },

-  { 0x8901, 0xd4de, 0x2000 },

-  { 0x0901, 0xd4dd, 0x0000 },

-  { 0x0901, 0xd4df, 0x0000 },

-  { 0x8901, 0xd4e2, 0x2000 },

-  { 0x0901, 0xd4e1, 0x0000 },

-  { 0x0901, 0xd4e3, 0x0000 },

-  { 0x8501, 0xd529, 0x7000 },

-  { 0x8901, 0xd504, 0x6000 },

-  { 0x8501, 0xd4f4, 0x5000 },

-  { 0x8501, 0xd4ec, 0x4000 },

-  { 0x8901, 0xd4e8, 0x3000 },

-  { 0x8901, 0xd4e6, 0x2000 },

-  { 0x0901, 0xd4e5, 0x0000 },

-  { 0x0901, 0xd4e7, 0x0000 },

-  { 0x8501, 0xd4ea, 0x2000 },

-  { 0x0901, 0xd4e9, 0x0000 },

-  { 0x0501, 0xd4eb, 0x0000 },

-  { 0x8501, 0xd4f0, 0x3000 },

-  { 0x8501, 0xd4ee, 0x2000 },

-  { 0x0501, 0xd4ed, 0x0000 },

-  { 0x0501, 0xd4ef, 0x0000 },

-  { 0x8501, 0xd4f2, 0x2000 },

-  { 0x0501, 0xd4f1, 0x0000 },

-  { 0x0501, 0xd4f3, 0x0000 },

-  { 0x8501, 0xd4fc, 0x4000 },

-  { 0x8501, 0xd4f8, 0x3000 },

-  { 0x8501, 0xd4f6, 0x2000 },

-  { 0x0501, 0xd4f5, 0x0000 },

-  { 0x0501, 0xd4f7, 0x0000 },

-  { 0x8501, 0xd4fa, 0x2000 },

-  { 0x0501, 0xd4f9, 0x0000 },

-  { 0x0501, 0xd4fb, 0x0000 },

-  { 0x8501, 0xd500, 0x3000 },

-  { 0x8501, 0xd4fe, 0x2000 },

-  { 0x0501, 0xd4fd, 0x0000 },

-  { 0x0501, 0xd4ff, 0x0000 },

-  { 0x8501, 0xd502, 0x2000 },

-  { 0x0501, 0xd501, 0x0000 },

-  { 0x0501, 0xd503, 0x0000 },

-  { 0x8901, 0xd518, 0x5000 },

-  { 0x8901, 0xd50f, 0x4000 },

-  { 0x8901, 0xd509, 0x3000 },

-  { 0x8901, 0xd507, 0x2000 },

-  { 0x0901, 0xd505, 0x0000 },

-  { 0x0901, 0xd508, 0x0000 },

-  { 0x8901, 0xd50d, 0x2000 },

-  { 0x0901, 0xd50a, 0x0000 },

-  { 0x0901, 0xd50e, 0x0000 },

-  { 0x8901, 0xd513, 0x3000 },

-  { 0x8901, 0xd511, 0x2000 },

-  { 0x0901, 0xd510, 0x0000 },

-  { 0x0901, 0xd512, 0x0000 },

-  { 0x8901, 0xd516, 0x2000 },

-  { 0x0901, 0xd514, 0x0000 },

-  { 0x0901, 0xd517, 0x0000 },

-  { 0x8501, 0xd521, 0x4000 },

-  { 0x8901, 0xd51c, 0x3000 },

-  { 0x8901, 0xd51a, 0x2000 },

-  { 0x0901, 0xd519, 0x0000 },

-  { 0x0901, 0xd51b, 0x0000 },

-  { 0x8501, 0xd51f, 0x2000 },

-  { 0x0501, 0xd51e, 0x0000 },

-  { 0x0501, 0xd520, 0x0000 },

-  { 0x8501, 0xd525, 0x3000 },

-  { 0x8501, 0xd523, 0x2000 },

-  { 0x0501, 0xd522, 0x0000 },

-  { 0x0501, 0xd524, 0x0000 },

-  { 0x8501, 0xd527, 0x2000 },

-  { 0x0501, 0xd526, 0x0000 },

-  { 0x0501, 0xd528, 0x0000 },

-  { 0x8901, 0xd54f, 0x6000 },

-  { 0x8901, 0xd539, 0x5000 },

-  { 0x8501, 0xd531, 0x4000 },

-  { 0x8501, 0xd52d, 0x3000 },

-  { 0x8501, 0xd52b, 0x2000 },

-  { 0x0501, 0xd52a, 0x0000 },

-  { 0x0501, 0xd52c, 0x0000 },

-  { 0x8501, 0xd52f, 0x2000 },

-  { 0x0501, 0xd52e, 0x0000 },

-  { 0x0501, 0xd530, 0x0000 },

-  { 0x8501, 0xd535, 0x3000 },

-  { 0x8501, 0xd533, 0x2000 },

-  { 0x0501, 0xd532, 0x0000 },

-  { 0x0501, 0xd534, 0x0000 },

-  { 0x8501, 0xd537, 0x2000 },

-  { 0x0501, 0xd536, 0x0000 },

-  { 0x0901, 0xd538, 0x0000 },

-  { 0x8901, 0xd543, 0x4000 },

-  { 0x8901, 0xd53e, 0x3000 },

-  { 0x8901, 0xd53c, 0x2000 },

-  { 0x0901, 0xd53b, 0x0000 },

-  { 0x0901, 0xd53d, 0x0000 },

-  { 0x8901, 0xd541, 0x2000 },

-  { 0x0901, 0xd540, 0x0000 },

-  { 0x0901, 0xd542, 0x0000 },

-  { 0x8901, 0xd54b, 0x3000 },

-  { 0x8901, 0xd546, 0x2000 },

-  { 0x0901, 0xd544, 0x0000 },

-  { 0x0901, 0xd54a, 0x0000 },

-  { 0x8901, 0xd54d, 0x2000 },

-  { 0x0901, 0xd54c, 0x0000 },

-  { 0x0901, 0xd54e, 0x0000 },

-  { 0x8501, 0xd560, 0x5000 },

-  { 0x8501, 0xd558, 0x4000 },

-  { 0x8501, 0xd554, 0x3000 },

-  { 0x8501, 0xd552, 0x2000 },

-  { 0x0901, 0xd550, 0x0000 },

-  { 0x0501, 0xd553, 0x0000 },

-  { 0x8501, 0xd556, 0x2000 },

-  { 0x0501, 0xd555, 0x0000 },

-  { 0x0501, 0xd557, 0x0000 },

-  { 0x8501, 0xd55c, 0x3000 },

-  { 0x8501, 0xd55a, 0x2000 },

-  { 0x0501, 0xd559, 0x0000 },

-  { 0x0501, 0xd55b, 0x0000 },

-  { 0x8501, 0xd55e, 0x2000 },

-  { 0x0501, 0xd55d, 0x0000 },

-  { 0x0501, 0xd55f, 0x0000 },

-  { 0x8501, 0xd568, 0x4000 },

-  { 0x8501, 0xd564, 0x3000 },

-  { 0x8501, 0xd562, 0x2000 },

-  { 0x0501, 0xd561, 0x0000 },

-  { 0x0501, 0xd563, 0x0000 },

-  { 0x8501, 0xd566, 0x2000 },

-  { 0x0501, 0xd565, 0x0000 },

-  { 0x0501, 0xd567, 0x0000 },

-  { 0x8901, 0xd56c, 0x3000 },

-  { 0x8501, 0xd56a, 0x2000 },

-  { 0x0501, 0xd569, 0x0000 },

-  { 0x0501, 0xd56b, 0x0000 },

-  { 0x8901, 0xd56e, 0x2000 },

-  { 0x0901, 0xd56d, 0x0000 },

-  { 0x0901, 0xd56f, 0x0000 },

-  { 0x8501, 0xd5f0, 0x8000 },

-  { 0x8901, 0xd5b0, 0x7000 },

-  { 0x8501, 0xd590, 0x6000 },

-  { 0x8901, 0xd580, 0x5000 },

-  { 0x8901, 0xd578, 0x4000 },

-  { 0x8901, 0xd574, 0x3000 },

-  { 0x8901, 0xd572, 0x2000 },

-  { 0x0901, 0xd571, 0x0000 },

-  { 0x0901, 0xd573, 0x0000 },

-  { 0x8901, 0xd576, 0x2000 },

-  { 0x0901, 0xd575, 0x0000 },

-  { 0x0901, 0xd577, 0x0000 },

-  { 0x8901, 0xd57c, 0x3000 },

-  { 0x8901, 0xd57a, 0x2000 },

-  { 0x0901, 0xd579, 0x0000 },

-  { 0x0901, 0xd57b, 0x0000 },

-  { 0x8901, 0xd57e, 0x2000 },

-  { 0x0901, 0xd57d, 0x0000 },

-  { 0x0901, 0xd57f, 0x0000 },

-  { 0x8501, 0xd588, 0x4000 },

-  { 0x8901, 0xd584, 0x3000 },

-  { 0x8901, 0xd582, 0x2000 },

-  { 0x0901, 0xd581, 0x0000 },

-  { 0x0901, 0xd583, 0x0000 },

-  { 0x8501, 0xd586, 0x2000 },

-  { 0x0901, 0xd585, 0x0000 },

-  { 0x0501, 0xd587, 0x0000 },

-  { 0x8501, 0xd58c, 0x3000 },

-  { 0x8501, 0xd58a, 0x2000 },

-  { 0x0501, 0xd589, 0x0000 },

-  { 0x0501, 0xd58b, 0x0000 },

-  { 0x8501, 0xd58e, 0x2000 },

-  { 0x0501, 0xd58d, 0x0000 },

-  { 0x0501, 0xd58f, 0x0000 },

-  { 0x8901, 0xd5a0, 0x5000 },

-  { 0x8501, 0xd598, 0x4000 },

-  { 0x8501, 0xd594, 0x3000 },

-  { 0x8501, 0xd592, 0x2000 },

-  { 0x0501, 0xd591, 0x0000 },

-  { 0x0501, 0xd593, 0x0000 },

-  { 0x8501, 0xd596, 0x2000 },

-  { 0x0501, 0xd595, 0x0000 },

-  { 0x0501, 0xd597, 0x0000 },

-  { 0x8501, 0xd59c, 0x3000 },

-  { 0x8501, 0xd59a, 0x2000 },

-  { 0x0501, 0xd599, 0x0000 },

-  { 0x0501, 0xd59b, 0x0000 },

-  { 0x8501, 0xd59e, 0x2000 },

-  { 0x0501, 0xd59d, 0x0000 },

-  { 0x0501, 0xd59f, 0x0000 },

-  { 0x8901, 0xd5a8, 0x4000 },

-  { 0x8901, 0xd5a4, 0x3000 },

-  { 0x8901, 0xd5a2, 0x2000 },

-  { 0x0901, 0xd5a1, 0x0000 },

-  { 0x0901, 0xd5a3, 0x0000 },

-  { 0x8901, 0xd5a6, 0x2000 },

-  { 0x0901, 0xd5a5, 0x0000 },

-  { 0x0901, 0xd5a7, 0x0000 },

-  { 0x8901, 0xd5ac, 0x3000 },

-  { 0x8901, 0xd5aa, 0x2000 },

-  { 0x0901, 0xd5a9, 0x0000 },

-  { 0x0901, 0xd5ab, 0x0000 },

-  { 0x8901, 0xd5ae, 0x2000 },

-  { 0x0901, 0xd5ad, 0x0000 },

-  { 0x0901, 0xd5af, 0x0000 },

-  { 0x8501, 0xd5d0, 0x6000 },

-  { 0x8501, 0xd5c0, 0x5000 },

-  { 0x8901, 0xd5b8, 0x4000 },

-  { 0x8901, 0xd5b4, 0x3000 },

-  { 0x8901, 0xd5b2, 0x2000 },

-  { 0x0901, 0xd5b1, 0x0000 },

-  { 0x0901, 0xd5b3, 0x0000 },

-  { 0x8901, 0xd5b6, 0x2000 },

-  { 0x0901, 0xd5b5, 0x0000 },

-  { 0x0901, 0xd5b7, 0x0000 },

-  { 0x8501, 0xd5bc, 0x3000 },

-  { 0x8501, 0xd5ba, 0x2000 },

-  { 0x0901, 0xd5b9, 0x0000 },

-  { 0x0501, 0xd5bb, 0x0000 },

-  { 0x8501, 0xd5be, 0x2000 },

-  { 0x0501, 0xd5bd, 0x0000 },

-  { 0x0501, 0xd5bf, 0x0000 },

-  { 0x8501, 0xd5c8, 0x4000 },

-  { 0x8501, 0xd5c4, 0x3000 },

-  { 0x8501, 0xd5c2, 0x2000 },

-  { 0x0501, 0xd5c1, 0x0000 },

-  { 0x0501, 0xd5c3, 0x0000 },

-  { 0x8501, 0xd5c6, 0x2000 },

-  { 0x0501, 0xd5c5, 0x0000 },

-  { 0x0501, 0xd5c7, 0x0000 },

-  { 0x8501, 0xd5cc, 0x3000 },

-  { 0x8501, 0xd5ca, 0x2000 },

-  { 0x0501, 0xd5c9, 0x0000 },

-  { 0x0501, 0xd5cb, 0x0000 },

-  { 0x8501, 0xd5ce, 0x2000 },

-  { 0x0501, 0xd5cd, 0x0000 },

-  { 0x0501, 0xd5cf, 0x0000 },

-  { 0x8901, 0xd5e0, 0x5000 },

-  { 0x8901, 0xd5d8, 0x4000 },

-  { 0x8901, 0xd5d4, 0x3000 },

-  { 0x8501, 0xd5d2, 0x2000 },

-  { 0x0501, 0xd5d1, 0x0000 },

-  { 0x0501, 0xd5d3, 0x0000 },

-  { 0x8901, 0xd5d6, 0x2000 },

-  { 0x0901, 0xd5d5, 0x0000 },

-  { 0x0901, 0xd5d7, 0x0000 },

-  { 0x8901, 0xd5dc, 0x3000 },

-  { 0x8901, 0xd5da, 0x2000 },

-  { 0x0901, 0xd5d9, 0x0000 },

-  { 0x0901, 0xd5db, 0x0000 },

-  { 0x8901, 0xd5de, 0x2000 },

-  { 0x0901, 0xd5dd, 0x0000 },

-  { 0x0901, 0xd5df, 0x0000 },

-  { 0x8901, 0xd5e8, 0x4000 },

-  { 0x8901, 0xd5e4, 0x3000 },

-  { 0x8901, 0xd5e2, 0x2000 },

-  { 0x0901, 0xd5e1, 0x0000 },

-  { 0x0901, 0xd5e3, 0x0000 },

-  { 0x8901, 0xd5e6, 0x2000 },

-  { 0x0901, 0xd5e5, 0x0000 },

-  { 0x0901, 0xd5e7, 0x0000 },

-  { 0x8901, 0xd5ec, 0x3000 },

-  { 0x8901, 0xd5ea, 0x2000 },

-  { 0x0901, 0xd5e9, 0x0000 },

-  { 0x0901, 0xd5eb, 0x0000 },

-  { 0x8501, 0xd5ee, 0x2000 },

-  { 0x0901, 0xd5ed, 0x0000 },

-  { 0x0501, 0xd5ef, 0x0000 },

-  { 0x8501, 0xd630, 0x7000 },

-  { 0x8901, 0xd610, 0x6000 },

-  { 0x8501, 0xd600, 0x5000 },

-  { 0x8501, 0xd5f8, 0x4000 },

-  { 0x8501, 0xd5f4, 0x3000 },

-  { 0x8501, 0xd5f2, 0x2000 },

-  { 0x0501, 0xd5f1, 0x0000 },

-  { 0x0501, 0xd5f3, 0x0000 },

-  { 0x8501, 0xd5f6, 0x2000 },

-  { 0x0501, 0xd5f5, 0x0000 },

-  { 0x0501, 0xd5f7, 0x0000 },

-  { 0x8501, 0xd5fc, 0x3000 },

-  { 0x8501, 0xd5fa, 0x2000 },

-  { 0x0501, 0xd5f9, 0x0000 },

-  { 0x0501, 0xd5fb, 0x0000 },

-  { 0x8501, 0xd5fe, 0x2000 },

-  { 0x0501, 0xd5fd, 0x0000 },

-  { 0x0501, 0xd5ff, 0x0000 },

-  { 0x8901, 0xd608, 0x4000 },

-  { 0x8501, 0xd604, 0x3000 },

-  { 0x8501, 0xd602, 0x2000 },

-  { 0x0501, 0xd601, 0x0000 },

-  { 0x0501, 0xd603, 0x0000 },

-  { 0x8501, 0xd606, 0x2000 },

-  { 0x0501, 0xd605, 0x0000 },

-  { 0x0501, 0xd607, 0x0000 },

-  { 0x8901, 0xd60c, 0x3000 },

-  { 0x8901, 0xd60a, 0x2000 },

-  { 0x0901, 0xd609, 0x0000 },

-  { 0x0901, 0xd60b, 0x0000 },

-  { 0x8901, 0xd60e, 0x2000 },

-  { 0x0901, 0xd60d, 0x0000 },

-  { 0x0901, 0xd60f, 0x0000 },

-  { 0x8901, 0xd620, 0x5000 },

-  { 0x8901, 0xd618, 0x4000 },

-  { 0x8901, 0xd614, 0x3000 },

-  { 0x8901, 0xd612, 0x2000 },

-  { 0x0901, 0xd611, 0x0000 },

-  { 0x0901, 0xd613, 0x0000 },

-  { 0x8901, 0xd616, 0x2000 },

-  { 0x0901, 0xd615, 0x0000 },

-  { 0x0901, 0xd617, 0x0000 },

-  { 0x8901, 0xd61c, 0x3000 },

-  { 0x8901, 0xd61a, 0x2000 },

-  { 0x0901, 0xd619, 0x0000 },

-  { 0x0901, 0xd61b, 0x0000 },

-  { 0x8901, 0xd61e, 0x2000 },

-  { 0x0901, 0xd61d, 0x0000 },

-  { 0x0901, 0xd61f, 0x0000 },

-  { 0x8501, 0xd628, 0x4000 },

-  { 0x8501, 0xd624, 0x3000 },

-  { 0x8501, 0xd622, 0x2000 },

-  { 0x0901, 0xd621, 0x0000 },

-  { 0x0501, 0xd623, 0x0000 },

-  { 0x8501, 0xd626, 0x2000 },

-  { 0x0501, 0xd625, 0x0000 },

-  { 0x0501, 0xd627, 0x0000 },

-  { 0x8501, 0xd62c, 0x3000 },

-  { 0x8501, 0xd62a, 0x2000 },

-  { 0x0501, 0xd629, 0x0000 },

-  { 0x0501, 0xd62b, 0x0000 },

-  { 0x8501, 0xd62e, 0x2000 },

-  { 0x0501, 0xd62d, 0x0000 },

-  { 0x0501, 0xd62f, 0x0000 },

-  { 0x8901, 0xd650, 0x6000 },

-  { 0x8901, 0xd640, 0x5000 },

-  { 0x8501, 0xd638, 0x4000 },

-  { 0x8501, 0xd634, 0x3000 },

-  { 0x8501, 0xd632, 0x2000 },

-  { 0x0501, 0xd631, 0x0000 },

-  { 0x0501, 0xd633, 0x0000 },

-  { 0x8501, 0xd636, 0x2000 },

-  { 0x0501, 0xd635, 0x0000 },

-  { 0x0501, 0xd637, 0x0000 },

-  { 0x8901, 0xd63c, 0x3000 },

-  { 0x8501, 0xd63a, 0x2000 },

-  { 0x0501, 0xd639, 0x0000 },

-  { 0x0501, 0xd63b, 0x0000 },

-  { 0x8901, 0xd63e, 0x2000 },

-  { 0x0901, 0xd63d, 0x0000 },

-  { 0x0901, 0xd63f, 0x0000 },

-  { 0x8901, 0xd648, 0x4000 },

-  { 0x8901, 0xd644, 0x3000 },

-  { 0x8901, 0xd642, 0x2000 },

-  { 0x0901, 0xd641, 0x0000 },

-  { 0x0901, 0xd643, 0x0000 },

-  { 0x8901, 0xd646, 0x2000 },

-  { 0x0901, 0xd645, 0x0000 },

-  { 0x0901, 0xd647, 0x0000 },

-  { 0x8901, 0xd64c, 0x3000 },

-  { 0x8901, 0xd64a, 0x2000 },

-  { 0x0901, 0xd649, 0x0000 },

-  { 0x0901, 0xd64b, 0x0000 },

-  { 0x8901, 0xd64e, 0x2000 },

-  { 0x0901, 0xd64d, 0x0000 },

-  { 0x0901, 0xd64f, 0x0000 },

-  { 0x8501, 0xd660, 0x5000 },

-  { 0x8501, 0xd658, 0x4000 },

-  { 0x8901, 0xd654, 0x3000 },

-  { 0x8901, 0xd652, 0x2000 },

-  { 0x0901, 0xd651, 0x0000 },

-  { 0x0901, 0xd653, 0x0000 },

-  { 0x8501, 0xd656, 0x2000 },

-  { 0x0901, 0xd655, 0x0000 },

-  { 0x0501, 0xd657, 0x0000 },

-  { 0x8501, 0xd65c, 0x3000 },

-  { 0x8501, 0xd65a, 0x2000 },

-  { 0x0501, 0xd659, 0x0000 },

-  { 0x0501, 0xd65b, 0x0000 },

-  { 0x8501, 0xd65e, 0x2000 },

-  { 0x0501, 0xd65d, 0x0000 },

-  { 0x0501, 0xd65f, 0x0000 },

-  { 0x8501, 0xd668, 0x4000 },

-  { 0x8501, 0xd664, 0x3000 },

-  { 0x8501, 0xd662, 0x2000 },

-  { 0x0501, 0xd661, 0x0000 },

-  { 0x0501, 0xd663, 0x0000 },

-  { 0x8501, 0xd666, 0x2000 },

-  { 0x0501, 0xd665, 0x0000 },

-  { 0x0501, 0xd667, 0x0000 },

-  { 0x8501, 0xd66c, 0x3000 },

-  { 0x8501, 0xd66a, 0x2000 },

-  { 0x0501, 0xd669, 0x0000 },

-  { 0x0501, 0xd66b, 0x0000 },

-  { 0x8501, 0xd66e, 0x2000 },

-  { 0x0501, 0xd66d, 0x0000 },

-  { 0x0501, 0xd66f, 0x0000 },

-  { 0x8501, 0xd774, 0x9000 },

-  { 0x8901, 0xd6f4, 0x8000 },

-  { 0x8901, 0xd6b4, 0x7000 },

-  { 0x8501, 0xd690, 0x6000 },

-  { 0x8901, 0xd680, 0x5000 },

-  { 0x8901, 0xd678, 0x4000 },

-  { 0x8901, 0xd674, 0x3000 },

-  { 0x8901, 0xd672, 0x2000 },

-  { 0x0901, 0xd671, 0x0000 },

-  { 0x0901, 0xd673, 0x0000 },

-  { 0x8901, 0xd676, 0x2000 },

-  { 0x0901, 0xd675, 0x0000 },

-  { 0x0901, 0xd677, 0x0000 },

-  { 0x8901, 0xd67c, 0x3000 },

-  { 0x8901, 0xd67a, 0x2000 },

-  { 0x0901, 0xd679, 0x0000 },

-  { 0x0901, 0xd67b, 0x0000 },

-  { 0x8901, 0xd67e, 0x2000 },

-  { 0x0901, 0xd67d, 0x0000 },

-  { 0x0901, 0xd67f, 0x0000 },

-  { 0x8901, 0xd688, 0x4000 },

-  { 0x8901, 0xd684, 0x3000 },

-  { 0x8901, 0xd682, 0x2000 },

-  { 0x0901, 0xd681, 0x0000 },

-  { 0x0901, 0xd683, 0x0000 },

-  { 0x8901, 0xd686, 0x2000 },

-  { 0x0901, 0xd685, 0x0000 },

-  { 0x0901, 0xd687, 0x0000 },

-  { 0x8501, 0xd68c, 0x3000 },

-  { 0x8501, 0xd68a, 0x2000 },

-  { 0x0901, 0xd689, 0x0000 },

-  { 0x0501, 0xd68b, 0x0000 },

-  { 0x8501, 0xd68e, 0x2000 },

-  { 0x0501, 0xd68d, 0x0000 },

-  { 0x0501, 0xd68f, 0x0000 },

-  { 0x8501, 0xd6a0, 0x5000 },

-  { 0x8501, 0xd698, 0x4000 },

-  { 0x8501, 0xd694, 0x3000 },

-  { 0x8501, 0xd692, 0x2000 },

-  { 0x0501, 0xd691, 0x0000 },

-  { 0x0501, 0xd693, 0x0000 },

-  { 0x8501, 0xd696, 0x2000 },

-  { 0x0501, 0xd695, 0x0000 },

-  { 0x0501, 0xd697, 0x0000 },

-  { 0x8501, 0xd69c, 0x3000 },

-  { 0x8501, 0xd69a, 0x2000 },

-  { 0x0501, 0xd699, 0x0000 },

-  { 0x0501, 0xd69b, 0x0000 },

-  { 0x8501, 0xd69e, 0x2000 },

-  { 0x0501, 0xd69d, 0x0000 },

-  { 0x0501, 0xd69f, 0x0000 },

-  { 0x8901, 0xd6ac, 0x4000 },

-  { 0x8901, 0xd6a8, 0x3000 },

-  { 0x8501, 0xd6a2, 0x2000 },

-  { 0x0501, 0xd6a1, 0x0000 },

-  { 0x0501, 0xd6a3, 0x0000 },

-  { 0x8901, 0xd6aa, 0x2000 },

-  { 0x0901, 0xd6a9, 0x0000 },

-  { 0x0901, 0xd6ab, 0x0000 },

-  { 0x8901, 0xd6b0, 0x3000 },

-  { 0x8901, 0xd6ae, 0x2000 },

-  { 0x0901, 0xd6ad, 0x0000 },

-  { 0x0901, 0xd6af, 0x0000 },

-  { 0x8901, 0xd6b2, 0x2000 },

-  { 0x0901, 0xd6b1, 0x0000 },

-  { 0x0901, 0xd6b3, 0x0000 },

-  { 0x8501, 0xd6d4, 0x6000 },

-  { 0x8501, 0xd6c4, 0x5000 },

-  { 0x8901, 0xd6bc, 0x4000 },

-  { 0x8901, 0xd6b8, 0x3000 },

-  { 0x8901, 0xd6b6, 0x2000 },

-  { 0x0901, 0xd6b5, 0x0000 },

-  { 0x0901, 0xd6b7, 0x0000 },

-  { 0x8901, 0xd6ba, 0x2000 },

-  { 0x0901, 0xd6b9, 0x0000 },

-  { 0x0901, 0xd6bb, 0x0000 },

-  { 0x8901, 0xd6c0, 0x3000 },

-  { 0x8901, 0xd6be, 0x2000 },

-  { 0x0901, 0xd6bd, 0x0000 },

-  { 0x0901, 0xd6bf, 0x0000 },

-  { 0x8501, 0xd6c2, 0x2000 },

-  { 0x1901, 0xd6c1, 0x0000 },

-  { 0x0501, 0xd6c3, 0x0000 },

-  { 0x8501, 0xd6cc, 0x4000 },

-  { 0x8501, 0xd6c8, 0x3000 },

-  { 0x8501, 0xd6c6, 0x2000 },

-  { 0x0501, 0xd6c5, 0x0000 },

-  { 0x0501, 0xd6c7, 0x0000 },

-  { 0x8501, 0xd6ca, 0x2000 },

-  { 0x0501, 0xd6c9, 0x0000 },

-  { 0x0501, 0xd6cb, 0x0000 },

-  { 0x8501, 0xd6d0, 0x3000 },

-  { 0x8501, 0xd6ce, 0x2000 },

-  { 0x0501, 0xd6cd, 0x0000 },

-  { 0x0501, 0xd6cf, 0x0000 },

-  { 0x8501, 0xd6d2, 0x2000 },

-  { 0x0501, 0xd6d1, 0x0000 },

-  { 0x0501, 0xd6d3, 0x0000 },

-  { 0x8901, 0xd6e4, 0x5000 },

-  { 0x8501, 0xd6dc, 0x4000 },

-  { 0x8501, 0xd6d8, 0x3000 },

-  { 0x8501, 0xd6d6, 0x2000 },

-  { 0x0501, 0xd6d5, 0x0000 },

-  { 0x0501, 0xd6d7, 0x0000 },

-  { 0x8501, 0xd6da, 0x2000 },

-  { 0x0501, 0xd6d9, 0x0000 },

-  { 0x1901, 0xd6db, 0x0000 },

-  { 0x8501, 0xd6e0, 0x3000 },

-  { 0x8501, 0xd6de, 0x2000 },

-  { 0x0501, 0xd6dd, 0x0000 },

-  { 0x0501, 0xd6df, 0x0000 },

-  { 0x8901, 0xd6e2, 0x2000 },

-  { 0x0501, 0xd6e1, 0x0000 },

-  { 0x0901, 0xd6e3, 0x0000 },

-  { 0x8901, 0xd6ec, 0x4000 },

-  { 0x8901, 0xd6e8, 0x3000 },

-  { 0x8901, 0xd6e6, 0x2000 },

-  { 0x0901, 0xd6e5, 0x0000 },

-  { 0x0901, 0xd6e7, 0x0000 },

-  { 0x8901, 0xd6ea, 0x2000 },

-  { 0x0901, 0xd6e9, 0x0000 },

-  { 0x0901, 0xd6eb, 0x0000 },

-  { 0x8901, 0xd6f0, 0x3000 },

-  { 0x8901, 0xd6ee, 0x2000 },

-  { 0x0901, 0xd6ed, 0x0000 },

-  { 0x0901, 0xd6ef, 0x0000 },

-  { 0x8901, 0xd6f2, 0x2000 },

-  { 0x0901, 0xd6f1, 0x0000 },

-  { 0x0901, 0xd6f3, 0x0000 },

-  { 0x8901, 0xd734, 0x7000 },

-  { 0x8501, 0xd714, 0x6000 },

-  { 0x8501, 0xd704, 0x5000 },

-  { 0x8501, 0xd6fc, 0x4000 },

-  { 0x8901, 0xd6f8, 0x3000 },

-  { 0x8901, 0xd6f6, 0x2000 },

-  { 0x0901, 0xd6f5, 0x0000 },

-  { 0x0901, 0xd6f7, 0x0000 },

-  { 0x8901, 0xd6fa, 0x2000 },

-  { 0x0901, 0xd6f9, 0x0000 },

-  { 0x1901, 0xd6fb, 0x0000 },

-  { 0x8501, 0xd700, 0x3000 },

-  { 0x8501, 0xd6fe, 0x2000 },

-  { 0x0501, 0xd6fd, 0x0000 },

-  { 0x0501, 0xd6ff, 0x0000 },

-  { 0x8501, 0xd702, 0x2000 },

-  { 0x0501, 0xd701, 0x0000 },

-  { 0x0501, 0xd703, 0x0000 },

-  { 0x8501, 0xd70c, 0x4000 },

-  { 0x8501, 0xd708, 0x3000 },

-  { 0x8501, 0xd706, 0x2000 },

-  { 0x0501, 0xd705, 0x0000 },

-  { 0x0501, 0xd707, 0x0000 },

-  { 0x8501, 0xd70a, 0x2000 },

-  { 0x0501, 0xd709, 0x0000 },

-  { 0x0501, 0xd70b, 0x0000 },

-  { 0x8501, 0xd710, 0x3000 },

-  { 0x8501, 0xd70e, 0x2000 },

-  { 0x0501, 0xd70d, 0x0000 },

-  { 0x0501, 0xd70f, 0x0000 },

-  { 0x8501, 0xd712, 0x2000 },

-  { 0x0501, 0xd711, 0x0000 },

-  { 0x0501, 0xd713, 0x0000 },

-  { 0x8901, 0xd724, 0x5000 },

-  { 0x8901, 0xd71c, 0x4000 },

-  { 0x8501, 0xd718, 0x3000 },

-  { 0x8501, 0xd716, 0x2000 },

-  { 0x1901, 0xd715, 0x0000 },

-  { 0x0501, 0xd717, 0x0000 },

-  { 0x8501, 0xd71a, 0x2000 },

-  { 0x0501, 0xd719, 0x0000 },

-  { 0x0501, 0xd71b, 0x0000 },

-  { 0x8901, 0xd720, 0x3000 },

-  { 0x8901, 0xd71e, 0x2000 },

-  { 0x0901, 0xd71d, 0x0000 },

-  { 0x0901, 0xd71f, 0x0000 },

-  { 0x8901, 0xd722, 0x2000 },

-  { 0x0901, 0xd721, 0x0000 },

-  { 0x0901, 0xd723, 0x0000 },

-  { 0x8901, 0xd72c, 0x4000 },

-  { 0x8901, 0xd728, 0x3000 },

-  { 0x8901, 0xd726, 0x2000 },

-  { 0x0901, 0xd725, 0x0000 },

-  { 0x0901, 0xd727, 0x0000 },

-  { 0x8901, 0xd72a, 0x2000 },

-  { 0x0901, 0xd729, 0x0000 },

-  { 0x0901, 0xd72b, 0x0000 },

-  { 0x8901, 0xd730, 0x3000 },

-  { 0x8901, 0xd72e, 0x2000 },

-  { 0x0901, 0xd72d, 0x0000 },

-  { 0x0901, 0xd72f, 0x0000 },

-  { 0x8901, 0xd732, 0x2000 },

-  { 0x0901, 0xd731, 0x0000 },

-  { 0x0901, 0xd733, 0x0000 },

-  { 0x8501, 0xd754, 0x6000 },

-  { 0x8501, 0xd744, 0x5000 },

-  { 0x8501, 0xd73c, 0x4000 },

-  { 0x8501, 0xd738, 0x3000 },

-  { 0x8501, 0xd736, 0x2000 },

-  { 0x1901, 0xd735, 0x0000 },

-  { 0x0501, 0xd737, 0x0000 },

-  { 0x8501, 0xd73a, 0x2000 },

-  { 0x0501, 0xd739, 0x0000 },

-  { 0x0501, 0xd73b, 0x0000 },

-  { 0x8501, 0xd740, 0x3000 },

-  { 0x8501, 0xd73e, 0x2000 },

-  { 0x0501, 0xd73d, 0x0000 },

-  { 0x0501, 0xd73f, 0x0000 },

-  { 0x8501, 0xd742, 0x2000 },

-  { 0x0501, 0xd741, 0x0000 },

-  { 0x0501, 0xd743, 0x0000 },

-  { 0x8501, 0xd74c, 0x4000 },

-  { 0x8501, 0xd748, 0x3000 },

-  { 0x8501, 0xd746, 0x2000 },

-  { 0x0501, 0xd745, 0x0000 },

-  { 0x0501, 0xd747, 0x0000 },

-  { 0x8501, 0xd74a, 0x2000 },

-  { 0x0501, 0xd749, 0x0000 },

-  { 0x0501, 0xd74b, 0x0000 },

-  { 0x8501, 0xd750, 0x3000 },

-  { 0x8501, 0xd74e, 0x2000 },

-  { 0x0501, 0xd74d, 0x0000 },

-  { 0x1901, 0xd74f, 0x0000 },

-  { 0x8501, 0xd752, 0x2000 },

-  { 0x0501, 0xd751, 0x0000 },

-  { 0x0501, 0xd753, 0x0000 },

-  { 0x8901, 0xd764, 0x5000 },

-  { 0x8901, 0xd75c, 0x4000 },

-  { 0x8901, 0xd758, 0x3000 },

-  { 0x8901, 0xd756, 0x2000 },

-  { 0x0501, 0xd755, 0x0000 },

-  { 0x0901, 0xd757, 0x0000 },

-  { 0x8901, 0xd75a, 0x2000 },

-  { 0x0901, 0xd759, 0x0000 },

-  { 0x0901, 0xd75b, 0x0000 },

-  { 0x8901, 0xd760, 0x3000 },

-  { 0x8901, 0xd75e, 0x2000 },

-  { 0x0901, 0xd75d, 0x0000 },

-  { 0x0901, 0xd75f, 0x0000 },

-  { 0x8901, 0xd762, 0x2000 },

-  { 0x0901, 0xd761, 0x0000 },

-  { 0x0901, 0xd763, 0x0000 },

-  { 0x8901, 0xd76c, 0x4000 },

-  { 0x8901, 0xd768, 0x3000 },

-  { 0x8901, 0xd766, 0x2000 },

-  { 0x0901, 0xd765, 0x0000 },

-  { 0x0901, 0xd767, 0x0000 },

-  { 0x8901, 0xd76a, 0x2000 },

-  { 0x0901, 0xd769, 0x0000 },

-  { 0x0901, 0xd76b, 0x0000 },

-  { 0x8501, 0xd770, 0x3000 },

-  { 0x8901, 0xd76e, 0x2000 },

-  { 0x0901, 0xd76d, 0x0000 },

-  { 0x1901, 0xd76f, 0x0000 },

-  { 0x8501, 0xd772, 0x2000 },

-  { 0x0501, 0xd771, 0x0000 },

-  { 0x0501, 0xd773, 0x0000 },

-  { 0x8d01, 0xd7f8, 0x8000 },

-  { 0x8501, 0xd7b4, 0x7000 },

-  { 0x8901, 0xd794, 0x6000 },

-  { 0x8501, 0xd784, 0x5000 },

-  { 0x8501, 0xd77c, 0x4000 },

-  { 0x8501, 0xd778, 0x3000 },

-  { 0x8501, 0xd776, 0x2000 },

-  { 0x0501, 0xd775, 0x0000 },

-  { 0x0501, 0xd777, 0x0000 },

-  { 0x8501, 0xd77a, 0x2000 },

-  { 0x0501, 0xd779, 0x0000 },

-  { 0x0501, 0xd77b, 0x0000 },

-  { 0x8501, 0xd780, 0x3000 },

-  { 0x8501, 0xd77e, 0x2000 },

-  { 0x0501, 0xd77d, 0x0000 },

-  { 0x0501, 0xd77f, 0x0000 },

-  { 0x8501, 0xd782, 0x2000 },

-  { 0x0501, 0xd781, 0x0000 },

-  { 0x0501, 0xd783, 0x0000 },

-  { 0x8501, 0xd78c, 0x4000 },

-  { 0x8501, 0xd788, 0x3000 },

-  { 0x8501, 0xd786, 0x2000 },

-  { 0x0501, 0xd785, 0x0000 },

-  { 0x0501, 0xd787, 0x0000 },

-  { 0x8501, 0xd78a, 0x2000 },

-  { 0x1901, 0xd789, 0x0000 },

-  { 0x0501, 0xd78b, 0x0000 },

-  { 0x8901, 0xd790, 0x3000 },

-  { 0x8501, 0xd78e, 0x2000 },

-  { 0x0501, 0xd78d, 0x0000 },

-  { 0x0501, 0xd78f, 0x0000 },

-  { 0x8901, 0xd792, 0x2000 },

-  { 0x0901, 0xd791, 0x0000 },

-  { 0x0901, 0xd793, 0x0000 },

-  { 0x8901, 0xd7a4, 0x5000 },

-  { 0x8901, 0xd79c, 0x4000 },

-  { 0x8901, 0xd798, 0x3000 },

-  { 0x8901, 0xd796, 0x2000 },

-  { 0x0901, 0xd795, 0x0000 },

-  { 0x0901, 0xd797, 0x0000 },

-  { 0x8901, 0xd79a, 0x2000 },

-  { 0x0901, 0xd799, 0x0000 },

-  { 0x0901, 0xd79b, 0x0000 },

-  { 0x8901, 0xd7a0, 0x3000 },

-  { 0x8901, 0xd79e, 0x2000 },

-  { 0x0901, 0xd79d, 0x0000 },

-  { 0x0901, 0xd79f, 0x0000 },

-  { 0x8901, 0xd7a2, 0x2000 },

-  { 0x0901, 0xd7a1, 0x0000 },

-  { 0x0901, 0xd7a3, 0x0000 },

-  { 0x8501, 0xd7ac, 0x4000 },

-  { 0x8901, 0xd7a8, 0x3000 },

-  { 0x8901, 0xd7a6, 0x2000 },

-  { 0x0901, 0xd7a5, 0x0000 },

-  { 0x0901, 0xd7a7, 0x0000 },

-  { 0x8501, 0xd7aa, 0x2000 },

-  { 0x1901, 0xd7a9, 0x0000 },

-  { 0x0501, 0xd7ab, 0x0000 },

-  { 0x8501, 0xd7b0, 0x3000 },

-  { 0x8501, 0xd7ae, 0x2000 },

-  { 0x0501, 0xd7ad, 0x0000 },

-  { 0x0501, 0xd7af, 0x0000 },

-  { 0x8501, 0xd7b2, 0x2000 },

-  { 0x0501, 0xd7b1, 0x0000 },

-  { 0x0501, 0xd7b3, 0x0000 },

-  { 0x8d01, 0xd7d8, 0x6000 },

-  { 0x8501, 0xd7c4, 0x5000 },

-  { 0x8501, 0xd7bc, 0x4000 },

-  { 0x8501, 0xd7b8, 0x3000 },

-  { 0x8501, 0xd7b6, 0x2000 },

-  { 0x0501, 0xd7b5, 0x0000 },

-  { 0x0501, 0xd7b7, 0x0000 },

-  { 0x8501, 0xd7ba, 0x2000 },

-  { 0x0501, 0xd7b9, 0x0000 },

-  { 0x0501, 0xd7bb, 0x0000 },

-  { 0x8501, 0xd7c0, 0x3000 },

-  { 0x8501, 0xd7be, 0x2000 },

-  { 0x0501, 0xd7bd, 0x0000 },

-  { 0x0501, 0xd7bf, 0x0000 },

-  { 0x8501, 0xd7c2, 0x2000 },

-  { 0x0501, 0xd7c1, 0x0000 },

-  { 0x1901, 0xd7c3, 0x0000 },

-  { 0x8d01, 0xd7d0, 0x4000 },

-  { 0x8501, 0xd7c8, 0x3000 },

-  { 0x8501, 0xd7c6, 0x2000 },

-  { 0x0501, 0xd7c5, 0x0000 },

-  { 0x0501, 0xd7c7, 0x0000 },

-  { 0x8d01, 0xd7ce, 0x2000 },

-  { 0x0501, 0xd7c9, 0x0000 },

-  { 0x0d01, 0xd7cf, 0x0000 },

-  { 0x8d01, 0xd7d4, 0x3000 },

-  { 0x8d01, 0xd7d2, 0x2000 },

-  { 0x0d01, 0xd7d1, 0x0000 },

-  { 0x0d01, 0xd7d3, 0x0000 },

-  { 0x8d01, 0xd7d6, 0x2000 },

-  { 0x0d01, 0xd7d5, 0x0000 },

-  { 0x0d01, 0xd7d7, 0x0000 },

-  { 0x8d01, 0xd7e8, 0x5000 },

-  { 0x8d01, 0xd7e0, 0x4000 },

-  { 0x8d01, 0xd7dc, 0x3000 },

-  { 0x8d01, 0xd7da, 0x2000 },

-  { 0x0d01, 0xd7d9, 0x0000 },

-  { 0x0d01, 0xd7db, 0x0000 },

-  { 0x8d01, 0xd7de, 0x2000 },

-  { 0x0d01, 0xd7dd, 0x0000 },

-  { 0x0d01, 0xd7df, 0x0000 },

-  { 0x8d01, 0xd7e4, 0x3000 },

-  { 0x8d01, 0xd7e2, 0x2000 },

-  { 0x0d01, 0xd7e1, 0x0000 },

-  { 0x0d01, 0xd7e3, 0x0000 },

-  { 0x8d01, 0xd7e6, 0x2000 },

-  { 0x0d01, 0xd7e5, 0x0000 },

-  { 0x0d01, 0xd7e7, 0x0000 },

-  { 0x8d01, 0xd7f0, 0x4000 },

-  { 0x8d01, 0xd7ec, 0x3000 },

-  { 0x8d01, 0xd7ea, 0x2000 },

-  { 0x0d01, 0xd7e9, 0x0000 },

-  { 0x0d01, 0xd7eb, 0x0000 },

-  { 0x8d01, 0xd7ee, 0x2000 },

-  { 0x0d01, 0xd7ed, 0x0000 },

-  { 0x0d01, 0xd7ef, 0x0000 },

-  { 0x8d01, 0xd7f4, 0x3000 },

-  { 0x8d01, 0xd7f2, 0x2000 },

-  { 0x0d01, 0xd7f1, 0x0000 },

-  { 0x0d01, 0xd7f3, 0x0000 },

-  { 0x8d01, 0xd7f6, 0x2000 },

-  { 0x0d01, 0xd7f5, 0x0000 },

-  { 0x0d01, 0xd7f7, 0x0000 },

-  { 0x8702, 0xf836, 0x7000 },

-  { 0x8702, 0xf816, 0x6000 },

-  { 0x8702, 0xf806, 0x5000 },

-  { 0x8702, 0x0000, 0x4000 },

-  { 0x8d01, 0xd7fc, 0x3000 },

-  { 0x8d01, 0xd7fa, 0x2000 },

-  { 0x0d01, 0xd7f9, 0x0000 },

-  { 0x0d01, 0xd7fb, 0x0000 },

-  { 0x8d01, 0xd7fe, 0x2000 },

-  { 0x0d01, 0xd7fd, 0x0000 },

-  { 0x0d01, 0xd7ff, 0x0000 },

-  { 0x8702, 0xf802, 0x3000 },

-  { 0x8702, 0xf800, 0x2000 },

-  { 0x0702, 0xa6d6, 0x0000 },

-  { 0x0702, 0xf801, 0x0000 },

-  { 0x8702, 0xf804, 0x2000 },

-  { 0x0702, 0xf803, 0x0000 },

-  { 0x0702, 0xf805, 0x0000 },

-  { 0x8702, 0xf80e, 0x4000 },

-  { 0x8702, 0xf80a, 0x3000 },

-  { 0x8702, 0xf808, 0x2000 },

-  { 0x0702, 0xf807, 0x0000 },

-  { 0x0702, 0xf809, 0x0000 },

-  { 0x8702, 0xf80c, 0x2000 },

-  { 0x0702, 0xf80b, 0x0000 },

-  { 0x0702, 0xf80d, 0x0000 },

-  { 0x8702, 0xf812, 0x3000 },

-  { 0x8702, 0xf810, 0x2000 },

-  { 0x0702, 0xf80f, 0x0000 },

-  { 0x0702, 0xf811, 0x0000 },

-  { 0x8702, 0xf814, 0x2000 },

-  { 0x0702, 0xf813, 0x0000 },

-  { 0x0702, 0xf815, 0x0000 },

-  { 0x8702, 0xf826, 0x5000 },

-  { 0x8702, 0xf81e, 0x4000 },

-  { 0x8702, 0xf81a, 0x3000 },

-  { 0x8702, 0xf818, 0x2000 },

-  { 0x0702, 0xf817, 0x0000 },

-  { 0x0702, 0xf819, 0x0000 },

-  { 0x8702, 0xf81c, 0x2000 },

-  { 0x0702, 0xf81b, 0x0000 },

-  { 0x0702, 0xf81d, 0x0000 },

-  { 0x8702, 0xf822, 0x3000 },

-  { 0x8702, 0xf820, 0x2000 },

-  { 0x0702, 0xf81f, 0x0000 },

-  { 0x0702, 0xf821, 0x0000 },

-  { 0x8702, 0xf824, 0x2000 },

-  { 0x0702, 0xf823, 0x0000 },

-  { 0x0702, 0xf825, 0x0000 },

-  { 0x8702, 0xf82e, 0x4000 },

-  { 0x8702, 0xf82a, 0x3000 },

-  { 0x8702, 0xf828, 0x2000 },

-  { 0x0702, 0xf827, 0x0000 },

-  { 0x0702, 0xf829, 0x0000 },

-  { 0x8702, 0xf82c, 0x2000 },

-  { 0x0702, 0xf82b, 0x0000 },

-  { 0x0702, 0xf82d, 0x0000 },

-  { 0x8702, 0xf832, 0x3000 },

-  { 0x8702, 0xf830, 0x2000 },

-  { 0x0702, 0xf82f, 0x0000 },

-  { 0x0702, 0xf831, 0x0000 },

-  { 0x8702, 0xf834, 0x2000 },

-  { 0x0702, 0xf833, 0x0000 },

-  { 0x0702, 0xf835, 0x0000 },

-  { 0x8702, 0xf856, 0x6000 },

-  { 0x8702, 0xf846, 0x5000 },

-  { 0x8702, 0xf83e, 0x4000 },

-  { 0x8702, 0xf83a, 0x3000 },

-  { 0x8702, 0xf838, 0x2000 },

-  { 0x0702, 0xf837, 0x0000 },

-  { 0x0702, 0xf839, 0x0000 },

-  { 0x8702, 0xf83c, 0x2000 },

-  { 0x0702, 0xf83b, 0x0000 },

-  { 0x0702, 0xf83d, 0x0000 },

-  { 0x8702, 0xf842, 0x3000 },

-  { 0x8702, 0xf840, 0x2000 },

-  { 0x0702, 0xf83f, 0x0000 },

-  { 0x0702, 0xf841, 0x0000 },

-  { 0x8702, 0xf844, 0x2000 },

-  { 0x0702, 0xf843, 0x0000 },

-  { 0x0702, 0xf845, 0x0000 },

-  { 0x8702, 0xf84e, 0x4000 },

-  { 0x8702, 0xf84a, 0x3000 },

-  { 0x8702, 0xf848, 0x2000 },

-  { 0x0702, 0xf847, 0x0000 },

-  { 0x0702, 0xf849, 0x0000 },

-  { 0x8702, 0xf84c, 0x2000 },

-  { 0x0702, 0xf84b, 0x0000 },

-  { 0x0702, 0xf84d, 0x0000 },

-  { 0x8702, 0xf852, 0x3000 },

-  { 0x8702, 0xf850, 0x2000 },

-  { 0x0702, 0xf84f, 0x0000 },

-  { 0x0702, 0xf851, 0x0000 },

-  { 0x8702, 0xf854, 0x2000 },

-  { 0x0702, 0xf853, 0x0000 },

-  { 0x0702, 0xf855, 0x0000 },

-  { 0x8702, 0xf866, 0x5000 },

-  { 0x8702, 0xf85e, 0x4000 },

-  { 0x8702, 0xf85a, 0x3000 },

-  { 0x8702, 0xf858, 0x2000 },

-  { 0x0702, 0xf857, 0x0000 },

-  { 0x0702, 0xf859, 0x0000 },

-  { 0x8702, 0xf85c, 0x2000 },

-  { 0x0702, 0xf85b, 0x0000 },

-  { 0x0702, 0xf85d, 0x0000 },

-  { 0x8702, 0xf862, 0x3000 },

-  { 0x8702, 0xf860, 0x2000 },

-  { 0x0702, 0xf85f, 0x0000 },

-  { 0x0702, 0xf861, 0x0000 },

-  { 0x8702, 0xf864, 0x2000 },

-  { 0x0702, 0xf863, 0x0000 },

-  { 0x0702, 0xf865, 0x0000 },

-  { 0x8702, 0xf86e, 0x4000 },

-  { 0x8702, 0xf86a, 0x3000 },

-  { 0x8702, 0xf868, 0x2000 },

-  { 0x0702, 0xf867, 0x0000 },

-  { 0x0702, 0xf869, 0x0000 },

-  { 0x8702, 0xf86c, 0x2000 },

-  { 0x0702, 0xf86b, 0x0000 },

-  { 0x0702, 0xf86d, 0x0000 },

-  { 0x8702, 0xf872, 0x3000 },

-  { 0x8702, 0xf870, 0x2000 },

-  { 0x0702, 0xf86f, 0x0000 },

-  { 0x0702, 0xf871, 0x0000 },

-  { 0x8702, 0xf874, 0x2000 },

-  { 0x0702, 0xf873, 0x0000 },

-  { 0x0702, 0xf875, 0x0000 },

-  { 0x8702, 0xf976, 0x9000 },

-  { 0x8702, 0xf8f6, 0x8000 },

-  { 0x8702, 0xf8b6, 0x7000 },

-  { 0x8702, 0xf896, 0x6000 },

-  { 0x8702, 0xf886, 0x5000 },

-  { 0x8702, 0xf87e, 0x4000 },

-  { 0x8702, 0xf87a, 0x3000 },

-  { 0x8702, 0xf878, 0x2000 },

-  { 0x0702, 0xf877, 0x0000 },

-  { 0x0702, 0xf879, 0x0000 },

-  { 0x8702, 0xf87c, 0x2000 },

-  { 0x0702, 0xf87b, 0x0000 },

-  { 0x0702, 0xf87d, 0x0000 },

-  { 0x8702, 0xf882, 0x3000 },

-  { 0x8702, 0xf880, 0x2000 },

-  { 0x0702, 0xf87f, 0x0000 },

-  { 0x0702, 0xf881, 0x0000 },

-  { 0x8702, 0xf884, 0x2000 },

-  { 0x0702, 0xf883, 0x0000 },

-  { 0x0702, 0xf885, 0x0000 },

-  { 0x8702, 0xf88e, 0x4000 },

-  { 0x8702, 0xf88a, 0x3000 },

-  { 0x8702, 0xf888, 0x2000 },

-  { 0x0702, 0xf887, 0x0000 },

-  { 0x0702, 0xf889, 0x0000 },

-  { 0x8702, 0xf88c, 0x2000 },

-  { 0x0702, 0xf88b, 0x0000 },

-  { 0x0702, 0xf88d, 0x0000 },

-  { 0x8702, 0xf892, 0x3000 },

-  { 0x8702, 0xf890, 0x2000 },

-  { 0x0702, 0xf88f, 0x0000 },

-  { 0x0702, 0xf891, 0x0000 },

-  { 0x8702, 0xf894, 0x2000 },

-  { 0x0702, 0xf893, 0x0000 },

-  { 0x0702, 0xf895, 0x0000 },

-  { 0x8702, 0xf8a6, 0x5000 },

-  { 0x8702, 0xf89e, 0x4000 },

-  { 0x8702, 0xf89a, 0x3000 },

-  { 0x8702, 0xf898, 0x2000 },

-  { 0x0702, 0xf897, 0x0000 },

-  { 0x0702, 0xf899, 0x0000 },

-  { 0x8702, 0xf89c, 0x2000 },

-  { 0x0702, 0xf89b, 0x0000 },

-  { 0x0702, 0xf89d, 0x0000 },

-  { 0x8702, 0xf8a2, 0x3000 },

-  { 0x8702, 0xf8a0, 0x2000 },

-  { 0x0702, 0xf89f, 0x0000 },

-  { 0x0702, 0xf8a1, 0x0000 },

-  { 0x8702, 0xf8a4, 0x2000 },

-  { 0x0702, 0xf8a3, 0x0000 },

-  { 0x0702, 0xf8a5, 0x0000 },

-  { 0x8702, 0xf8ae, 0x4000 },

-  { 0x8702, 0xf8aa, 0x3000 },

-  { 0x8702, 0xf8a8, 0x2000 },

-  { 0x0702, 0xf8a7, 0x0000 },

-  { 0x0702, 0xf8a9, 0x0000 },

-  { 0x8702, 0xf8ac, 0x2000 },

-  { 0x0702, 0xf8ab, 0x0000 },

-  { 0x0702, 0xf8ad, 0x0000 },

-  { 0x8702, 0xf8b2, 0x3000 },

-  { 0x8702, 0xf8b0, 0x2000 },

-  { 0x0702, 0xf8af, 0x0000 },

-  { 0x0702, 0xf8b1, 0x0000 },

-  { 0x8702, 0xf8b4, 0x2000 },

-  { 0x0702, 0xf8b3, 0x0000 },

-  { 0x0702, 0xf8b5, 0x0000 },

-  { 0x8702, 0xf8d6, 0x6000 },

-  { 0x8702, 0xf8c6, 0x5000 },

-  { 0x8702, 0xf8be, 0x4000 },

-  { 0x8702, 0xf8ba, 0x3000 },

-  { 0x8702, 0xf8b8, 0x2000 },

-  { 0x0702, 0xf8b7, 0x0000 },

-  { 0x0702, 0xf8b9, 0x0000 },

-  { 0x8702, 0xf8bc, 0x2000 },

-  { 0x0702, 0xf8bb, 0x0000 },

-  { 0x0702, 0xf8bd, 0x0000 },

-  { 0x8702, 0xf8c2, 0x3000 },

-  { 0x8702, 0xf8c0, 0x2000 },

-  { 0x0702, 0xf8bf, 0x0000 },

-  { 0x0702, 0xf8c1, 0x0000 },

-  { 0x8702, 0xf8c4, 0x2000 },

-  { 0x0702, 0xf8c3, 0x0000 },

-  { 0x0702, 0xf8c5, 0x0000 },

-  { 0x8702, 0xf8ce, 0x4000 },

-  { 0x8702, 0xf8ca, 0x3000 },

-  { 0x8702, 0xf8c8, 0x2000 },

-  { 0x0702, 0xf8c7, 0x0000 },

-  { 0x0702, 0xf8c9, 0x0000 },

-  { 0x8702, 0xf8cc, 0x2000 },

-  { 0x0702, 0xf8cb, 0x0000 },

-  { 0x0702, 0xf8cd, 0x0000 },

-  { 0x8702, 0xf8d2, 0x3000 },

-  { 0x8702, 0xf8d0, 0x2000 },

-  { 0x0702, 0xf8cf, 0x0000 },

-  { 0x0702, 0xf8d1, 0x0000 },

-  { 0x8702, 0xf8d4, 0x2000 },

-  { 0x0702, 0xf8d3, 0x0000 },

-  { 0x0702, 0xf8d5, 0x0000 },

-  { 0x8702, 0xf8e6, 0x5000 },

-  { 0x8702, 0xf8de, 0x4000 },

-  { 0x8702, 0xf8da, 0x3000 },

-  { 0x8702, 0xf8d8, 0x2000 },

-  { 0x0702, 0xf8d7, 0x0000 },

-  { 0x0702, 0xf8d9, 0x0000 },

-  { 0x8702, 0xf8dc, 0x2000 },

-  { 0x0702, 0xf8db, 0x0000 },

-  { 0x0702, 0xf8dd, 0x0000 },

-  { 0x8702, 0xf8e2, 0x3000 },

-  { 0x8702, 0xf8e0, 0x2000 },

-  { 0x0702, 0xf8df, 0x0000 },

-  { 0x0702, 0xf8e1, 0x0000 },

-  { 0x8702, 0xf8e4, 0x2000 },

-  { 0x0702, 0xf8e3, 0x0000 },

-  { 0x0702, 0xf8e5, 0x0000 },

-  { 0x8702, 0xf8ee, 0x4000 },

-  { 0x8702, 0xf8ea, 0x3000 },

-  { 0x8702, 0xf8e8, 0x2000 },

-  { 0x0702, 0xf8e7, 0x0000 },

-  { 0x0702, 0xf8e9, 0x0000 },

-  { 0x8702, 0xf8ec, 0x2000 },

-  { 0x0702, 0xf8eb, 0x0000 },

-  { 0x0702, 0xf8ed, 0x0000 },

-  { 0x8702, 0xf8f2, 0x3000 },

-  { 0x8702, 0xf8f0, 0x2000 },

-  { 0x0702, 0xf8ef, 0x0000 },

-  { 0x0702, 0xf8f1, 0x0000 },

-  { 0x8702, 0xf8f4, 0x2000 },

-  { 0x0702, 0xf8f3, 0x0000 },

-  { 0x0702, 0xf8f5, 0x0000 },

-  { 0x8702, 0xf936, 0x7000 },

-  { 0x8702, 0xf916, 0x6000 },

-  { 0x8702, 0xf906, 0x5000 },

-  { 0x8702, 0xf8fe, 0x4000 },

-  { 0x8702, 0xf8fa, 0x3000 },

-  { 0x8702, 0xf8f8, 0x2000 },

-  { 0x0702, 0xf8f7, 0x0000 },

-  { 0x0702, 0xf8f9, 0x0000 },

-  { 0x8702, 0xf8fc, 0x2000 },

-  { 0x0702, 0xf8fb, 0x0000 },

-  { 0x0702, 0xf8fd, 0x0000 },

-  { 0x8702, 0xf902, 0x3000 },

-  { 0x8702, 0xf900, 0x2000 },

-  { 0x0702, 0xf8ff, 0x0000 },

-  { 0x0702, 0xf901, 0x0000 },

-  { 0x8702, 0xf904, 0x2000 },

-  { 0x0702, 0xf903, 0x0000 },

-  { 0x0702, 0xf905, 0x0000 },

-  { 0x8702, 0xf90e, 0x4000 },

-  { 0x8702, 0xf90a, 0x3000 },

-  { 0x8702, 0xf908, 0x2000 },

-  { 0x0702, 0xf907, 0x0000 },

-  { 0x0702, 0xf909, 0x0000 },

-  { 0x8702, 0xf90c, 0x2000 },

-  { 0x0702, 0xf90b, 0x0000 },

-  { 0x0702, 0xf90d, 0x0000 },

-  { 0x8702, 0xf912, 0x3000 },

-  { 0x8702, 0xf910, 0x2000 },

-  { 0x0702, 0xf90f, 0x0000 },

-  { 0x0702, 0xf911, 0x0000 },

-  { 0x8702, 0xf914, 0x2000 },

-  { 0x0702, 0xf913, 0x0000 },

-  { 0x0702, 0xf915, 0x0000 },

-  { 0x8702, 0xf926, 0x5000 },

-  { 0x8702, 0xf91e, 0x4000 },

-  { 0x8702, 0xf91a, 0x3000 },

-  { 0x8702, 0xf918, 0x2000 },

-  { 0x0702, 0xf917, 0x0000 },

-  { 0x0702, 0xf919, 0x0000 },

-  { 0x8702, 0xf91c, 0x2000 },

-  { 0x0702, 0xf91b, 0x0000 },

-  { 0x0702, 0xf91d, 0x0000 },

-  { 0x8702, 0xf922, 0x3000 },

-  { 0x8702, 0xf920, 0x2000 },

-  { 0x0702, 0xf91f, 0x0000 },

-  { 0x0702, 0xf921, 0x0000 },

-  { 0x8702, 0xf924, 0x2000 },

-  { 0x0702, 0xf923, 0x0000 },

-  { 0x0702, 0xf925, 0x0000 },

-  { 0x8702, 0xf92e, 0x4000 },

-  { 0x8702, 0xf92a, 0x3000 },

-  { 0x8702, 0xf928, 0x2000 },

-  { 0x0702, 0xf927, 0x0000 },

-  { 0x0702, 0xf929, 0x0000 },

-  { 0x8702, 0xf92c, 0x2000 },

-  { 0x0702, 0xf92b, 0x0000 },

-  { 0x0702, 0xf92d, 0x0000 },

-  { 0x8702, 0xf932, 0x3000 },

-  { 0x8702, 0xf930, 0x2000 },

-  { 0x0702, 0xf92f, 0x0000 },

-  { 0x0702, 0xf931, 0x0000 },

-  { 0x8702, 0xf934, 0x2000 },

-  { 0x0702, 0xf933, 0x0000 },

-  { 0x0702, 0xf935, 0x0000 },

-  { 0x8702, 0xf956, 0x6000 },

-  { 0x8702, 0xf946, 0x5000 },

-  { 0x8702, 0xf93e, 0x4000 },

-  { 0x8702, 0xf93a, 0x3000 },

-  { 0x8702, 0xf938, 0x2000 },

-  { 0x0702, 0xf937, 0x0000 },

-  { 0x0702, 0xf939, 0x0000 },

-  { 0x8702, 0xf93c, 0x2000 },

-  { 0x0702, 0xf93b, 0x0000 },

-  { 0x0702, 0xf93d, 0x0000 },

-  { 0x8702, 0xf942, 0x3000 },

-  { 0x8702, 0xf940, 0x2000 },

-  { 0x0702, 0xf93f, 0x0000 },

-  { 0x0702, 0xf941, 0x0000 },

-  { 0x8702, 0xf944, 0x2000 },

-  { 0x0702, 0xf943, 0x0000 },

-  { 0x0702, 0xf945, 0x0000 },

-  { 0x8702, 0xf94e, 0x4000 },

-  { 0x8702, 0xf94a, 0x3000 },

-  { 0x8702, 0xf948, 0x2000 },

-  { 0x0702, 0xf947, 0x0000 },

-  { 0x0702, 0xf949, 0x0000 },

-  { 0x8702, 0xf94c, 0x2000 },

-  { 0x0702, 0xf94b, 0x0000 },

-  { 0x0702, 0xf94d, 0x0000 },

-  { 0x8702, 0xf952, 0x3000 },

-  { 0x8702, 0xf950, 0x2000 },

-  { 0x0702, 0xf94f, 0x0000 },

-  { 0x0702, 0xf951, 0x0000 },

-  { 0x8702, 0xf954, 0x2000 },

-  { 0x0702, 0xf953, 0x0000 },

-  { 0x0702, 0xf955, 0x0000 },

-  { 0x8702, 0xf966, 0x5000 },

-  { 0x8702, 0xf95e, 0x4000 },

-  { 0x8702, 0xf95a, 0x3000 },

-  { 0x8702, 0xf958, 0x2000 },

-  { 0x0702, 0xf957, 0x0000 },

-  { 0x0702, 0xf959, 0x0000 },

-  { 0x8702, 0xf95c, 0x2000 },

-  { 0x0702, 0xf95b, 0x0000 },

-  { 0x0702, 0xf95d, 0x0000 },

-  { 0x8702, 0xf962, 0x3000 },

-  { 0x8702, 0xf960, 0x2000 },

-  { 0x0702, 0xf95f, 0x0000 },

-  { 0x0702, 0xf961, 0x0000 },

-  { 0x8702, 0xf964, 0x2000 },

-  { 0x0702, 0xf963, 0x0000 },

-  { 0x0702, 0xf965, 0x0000 },

-  { 0x8702, 0xf96e, 0x4000 },

-  { 0x8702, 0xf96a, 0x3000 },

-  { 0x8702, 0xf968, 0x2000 },

-  { 0x0702, 0xf967, 0x0000 },

-  { 0x0702, 0xf969, 0x0000 },

-  { 0x8702, 0xf96c, 0x2000 },

-  { 0x0702, 0xf96b, 0x0000 },

-  { 0x0702, 0xf96d, 0x0000 },

-  { 0x8702, 0xf972, 0x3000 },

-  { 0x8702, 0xf970, 0x2000 },

-  { 0x0702, 0xf96f, 0x0000 },

-  { 0x0702, 0xf971, 0x0000 },

-  { 0x8702, 0xf974, 0x2000 },

-  { 0x0702, 0xf973, 0x0000 },

-  { 0x0702, 0xf975, 0x0000 },

-  { 0x810e, 0x0077, 0x9000 },

-  { 0x8702, 0xf9f6, 0x8000 },

-  { 0x8702, 0xf9b6, 0x7000 },

-  { 0x8702, 0xf996, 0x6000 },

-  { 0x8702, 0xf986, 0x5000 },

-  { 0x8702, 0xf97e, 0x4000 },

-  { 0x8702, 0xf97a, 0x3000 },

-  { 0x8702, 0xf978, 0x2000 },

-  { 0x0702, 0xf977, 0x0000 },

-  { 0x0702, 0xf979, 0x0000 },

-  { 0x8702, 0xf97c, 0x2000 },

-  { 0x0702, 0xf97b, 0x0000 },

-  { 0x0702, 0xf97d, 0x0000 },

-  { 0x8702, 0xf982, 0x3000 },

-  { 0x8702, 0xf980, 0x2000 },

-  { 0x0702, 0xf97f, 0x0000 },

-  { 0x0702, 0xf981, 0x0000 },

-  { 0x8702, 0xf984, 0x2000 },

-  { 0x0702, 0xf983, 0x0000 },

-  { 0x0702, 0xf985, 0x0000 },

-  { 0x8702, 0xf98e, 0x4000 },

-  { 0x8702, 0xf98a, 0x3000 },

-  { 0x8702, 0xf988, 0x2000 },

-  { 0x0702, 0xf987, 0x0000 },

-  { 0x0702, 0xf989, 0x0000 },

-  { 0x8702, 0xf98c, 0x2000 },

-  { 0x0702, 0xf98b, 0x0000 },

-  { 0x0702, 0xf98d, 0x0000 },

-  { 0x8702, 0xf992, 0x3000 },

-  { 0x8702, 0xf990, 0x2000 },

-  { 0x0702, 0xf98f, 0x0000 },

-  { 0x0702, 0xf991, 0x0000 },

-  { 0x8702, 0xf994, 0x2000 },

-  { 0x0702, 0xf993, 0x0000 },

-  { 0x0702, 0xf995, 0x0000 },

-  { 0x8702, 0xf9a6, 0x5000 },

-  { 0x8702, 0xf99e, 0x4000 },

-  { 0x8702, 0xf99a, 0x3000 },

-  { 0x8702, 0xf998, 0x2000 },

-  { 0x0702, 0xf997, 0x0000 },

-  { 0x0702, 0xf999, 0x0000 },

-  { 0x8702, 0xf99c, 0x2000 },

-  { 0x0702, 0xf99b, 0x0000 },

-  { 0x0702, 0xf99d, 0x0000 },

-  { 0x8702, 0xf9a2, 0x3000 },

-  { 0x8702, 0xf9a0, 0x2000 },

-  { 0x0702, 0xf99f, 0x0000 },

-  { 0x0702, 0xf9a1, 0x0000 },

-  { 0x8702, 0xf9a4, 0x2000 },

-  { 0x0702, 0xf9a3, 0x0000 },

-  { 0x0702, 0xf9a5, 0x0000 },

-  { 0x8702, 0xf9ae, 0x4000 },

-  { 0x8702, 0xf9aa, 0x3000 },

-  { 0x8702, 0xf9a8, 0x2000 },

-  { 0x0702, 0xf9a7, 0x0000 },

-  { 0x0702, 0xf9a9, 0x0000 },

-  { 0x8702, 0xf9ac, 0x2000 },

-  { 0x0702, 0xf9ab, 0x0000 },

-  { 0x0702, 0xf9ad, 0x0000 },

-  { 0x8702, 0xf9b2, 0x3000 },

-  { 0x8702, 0xf9b0, 0x2000 },

-  { 0x0702, 0xf9af, 0x0000 },

-  { 0x0702, 0xf9b1, 0x0000 },

-  { 0x8702, 0xf9b4, 0x2000 },

-  { 0x0702, 0xf9b3, 0x0000 },

-  { 0x0702, 0xf9b5, 0x0000 },

-  { 0x8702, 0xf9d6, 0x6000 },

-  { 0x8702, 0xf9c6, 0x5000 },

-  { 0x8702, 0xf9be, 0x4000 },

-  { 0x8702, 0xf9ba, 0x3000 },

-  { 0x8702, 0xf9b8, 0x2000 },

-  { 0x0702, 0xf9b7, 0x0000 },

-  { 0x0702, 0xf9b9, 0x0000 },

-  { 0x8702, 0xf9bc, 0x2000 },

-  { 0x0702, 0xf9bb, 0x0000 },

-  { 0x0702, 0xf9bd, 0x0000 },

-  { 0x8702, 0xf9c2, 0x3000 },

-  { 0x8702, 0xf9c0, 0x2000 },

-  { 0x0702, 0xf9bf, 0x0000 },

-  { 0x0702, 0xf9c1, 0x0000 },

-  { 0x8702, 0xf9c4, 0x2000 },

-  { 0x0702, 0xf9c3, 0x0000 },

-  { 0x0702, 0xf9c5, 0x0000 },

-  { 0x8702, 0xf9ce, 0x4000 },

-  { 0x8702, 0xf9ca, 0x3000 },

-  { 0x8702, 0xf9c8, 0x2000 },

-  { 0x0702, 0xf9c7, 0x0000 },

-  { 0x0702, 0xf9c9, 0x0000 },

-  { 0x8702, 0xf9cc, 0x2000 },

-  { 0x0702, 0xf9cb, 0x0000 },

-  { 0x0702, 0xf9cd, 0x0000 },

-  { 0x8702, 0xf9d2, 0x3000 },

-  { 0x8702, 0xf9d0, 0x2000 },

-  { 0x0702, 0xf9cf, 0x0000 },

-  { 0x0702, 0xf9d1, 0x0000 },

-  { 0x8702, 0xf9d4, 0x2000 },

-  { 0x0702, 0xf9d3, 0x0000 },

-  { 0x0702, 0xf9d5, 0x0000 },

-  { 0x8702, 0xf9e6, 0x5000 },

-  { 0x8702, 0xf9de, 0x4000 },

-  { 0x8702, 0xf9da, 0x3000 },

-  { 0x8702, 0xf9d8, 0x2000 },

-  { 0x0702, 0xf9d7, 0x0000 },

-  { 0x0702, 0xf9d9, 0x0000 },

-  { 0x8702, 0xf9dc, 0x2000 },

-  { 0x0702, 0xf9db, 0x0000 },

-  { 0x0702, 0xf9dd, 0x0000 },

-  { 0x8702, 0xf9e2, 0x3000 },

-  { 0x8702, 0xf9e0, 0x2000 },

-  { 0x0702, 0xf9df, 0x0000 },

-  { 0x0702, 0xf9e1, 0x0000 },

-  { 0x8702, 0xf9e4, 0x2000 },

-  { 0x0702, 0xf9e3, 0x0000 },

-  { 0x0702, 0xf9e5, 0x0000 },

-  { 0x8702, 0xf9ee, 0x4000 },

-  { 0x8702, 0xf9ea, 0x3000 },

-  { 0x8702, 0xf9e8, 0x2000 },

-  { 0x0702, 0xf9e7, 0x0000 },

-  { 0x0702, 0xf9e9, 0x0000 },

-  { 0x8702, 0xf9ec, 0x2000 },

-  { 0x0702, 0xf9eb, 0x0000 },

-  { 0x0702, 0xf9ed, 0x0000 },

-  { 0x8702, 0xf9f2, 0x3000 },

-  { 0x8702, 0xf9f0, 0x2000 },

-  { 0x0702, 0xf9ef, 0x0000 },

-  { 0x0702, 0xf9f1, 0x0000 },

-  { 0x8702, 0xf9f4, 0x2000 },

-  { 0x0702, 0xf9f3, 0x0000 },

-  { 0x0702, 0xf9f5, 0x0000 },

-  { 0x810e, 0x0037, 0x7000 },

-  { 0x8702, 0xfa16, 0x6000 },

-  { 0x8702, 0xfa06, 0x5000 },

-  { 0x8702, 0xf9fe, 0x4000 },

-  { 0x8702, 0xf9fa, 0x3000 },

-  { 0x8702, 0xf9f8, 0x2000 },

-  { 0x0702, 0xf9f7, 0x0000 },

-  { 0x0702, 0xf9f9, 0x0000 },

-  { 0x8702, 0xf9fc, 0x2000 },

-  { 0x0702, 0xf9fb, 0x0000 },

-  { 0x0702, 0xf9fd, 0x0000 },

-  { 0x8702, 0xfa02, 0x3000 },

-  { 0x8702, 0xfa00, 0x2000 },

-  { 0x0702, 0xf9ff, 0x0000 },

-  { 0x0702, 0xfa01, 0x0000 },

-  { 0x8702, 0xfa04, 0x2000 },

-  { 0x0702, 0xfa03, 0x0000 },

-  { 0x0702, 0xfa05, 0x0000 },

-  { 0x8702, 0xfa0e, 0x4000 },

-  { 0x8702, 0xfa0a, 0x3000 },

-  { 0x8702, 0xfa08, 0x2000 },

-  { 0x0702, 0xfa07, 0x0000 },

-  { 0x0702, 0xfa09, 0x0000 },

-  { 0x8702, 0xfa0c, 0x2000 },

-  { 0x0702, 0xfa0b, 0x0000 },

-  { 0x0702, 0xfa0d, 0x0000 },

-  { 0x8702, 0xfa12, 0x3000 },

-  { 0x8702, 0xfa10, 0x2000 },

-  { 0x0702, 0xfa0f, 0x0000 },

-  { 0x0702, 0xfa11, 0x0000 },

-  { 0x8702, 0xfa14, 0x2000 },

-  { 0x0702, 0xfa13, 0x0000 },

-  { 0x0702, 0xfa15, 0x0000 },

-  { 0x810e, 0x0027, 0x5000 },

-  { 0x810e, 0x0001, 0x4000 },

-  { 0x8702, 0xfa1a, 0x3000 },

-  { 0x8702, 0xfa18, 0x2000 },

-  { 0x0702, 0xfa17, 0x0000 },

-  { 0x0702, 0xfa19, 0x0000 },

-  { 0x8702, 0xfa1c, 0x2000 },

-  { 0x0702, 0xfa1b, 0x0000 },

-  { 0x0702, 0xfa1d, 0x0000 },

-  { 0x810e, 0x0023, 0x3000 },

-  { 0x810e, 0x0021, 0x2000 },

-  { 0x010e, 0x0020, 0x0000 },

-  { 0x010e, 0x0022, 0x0000 },

-  { 0x810e, 0x0025, 0x2000 },

-  { 0x010e, 0x0024, 0x0000 },

-  { 0x010e, 0x0026, 0x0000 },

-  { 0x810e, 0x002f, 0x4000 },

-  { 0x810e, 0x002b, 0x3000 },

-  { 0x810e, 0x0029, 0x2000 },

-  { 0x010e, 0x0028, 0x0000 },

-  { 0x010e, 0x002a, 0x0000 },

-  { 0x810e, 0x002d, 0x2000 },

-  { 0x010e, 0x002c, 0x0000 },

-  { 0x010e, 0x002e, 0x0000 },

-  { 0x810e, 0x0033, 0x3000 },

-  { 0x810e, 0x0031, 0x2000 },

-  { 0x010e, 0x0030, 0x0000 },

-  { 0x010e, 0x0032, 0x0000 },

-  { 0x810e, 0x0035, 0x2000 },

-  { 0x010e, 0x0034, 0x0000 },

-  { 0x010e, 0x0036, 0x0000 },

-  { 0x810e, 0x0057, 0x6000 },

-  { 0x810e, 0x0047, 0x5000 },

-  { 0x810e, 0x003f, 0x4000 },

-  { 0x810e, 0x003b, 0x3000 },

-  { 0x810e, 0x0039, 0x2000 },

-  { 0x010e, 0x0038, 0x0000 },

-  { 0x010e, 0x003a, 0x0000 },

-  { 0x810e, 0x003d, 0x2000 },

-  { 0x010e, 0x003c, 0x0000 },

-  { 0x010e, 0x003e, 0x0000 },

-  { 0x810e, 0x0043, 0x3000 },

-  { 0x810e, 0x0041, 0x2000 },

-  { 0x010e, 0x0040, 0x0000 },

-  { 0x010e, 0x0042, 0x0000 },

-  { 0x810e, 0x0045, 0x2000 },

-  { 0x010e, 0x0044, 0x0000 },

-  { 0x010e, 0x0046, 0x0000 },

-  { 0x810e, 0x004f, 0x4000 },

-  { 0x810e, 0x004b, 0x3000 },

-  { 0x810e, 0x0049, 0x2000 },

-  { 0x010e, 0x0048, 0x0000 },

-  { 0x010e, 0x004a, 0x0000 },

-  { 0x810e, 0x004d, 0x2000 },

-  { 0x010e, 0x004c, 0x0000 },

-  { 0x010e, 0x004e, 0x0000 },

-  { 0x810e, 0x0053, 0x3000 },

-  { 0x810e, 0x0051, 0x2000 },

-  { 0x010e, 0x0050, 0x0000 },

-  { 0x010e, 0x0052, 0x0000 },

-  { 0x810e, 0x0055, 0x2000 },

-  { 0x010e, 0x0054, 0x0000 },

-  { 0x010e, 0x0056, 0x0000 },

-  { 0x810e, 0x0067, 0x5000 },

-  { 0x810e, 0x005f, 0x4000 },

-  { 0x810e, 0x005b, 0x3000 },

-  { 0x810e, 0x0059, 0x2000 },

-  { 0x010e, 0x0058, 0x0000 },

-  { 0x010e, 0x005a, 0x0000 },

-  { 0x810e, 0x005d, 0x2000 },

-  { 0x010e, 0x005c, 0x0000 },

-  { 0x010e, 0x005e, 0x0000 },

-  { 0x810e, 0x0063, 0x3000 },

-  { 0x810e, 0x0061, 0x2000 },

-  { 0x010e, 0x0060, 0x0000 },

-  { 0x010e, 0x0062, 0x0000 },

-  { 0x810e, 0x0065, 0x2000 },

-  { 0x010e, 0x0064, 0x0000 },

-  { 0x010e, 0x0066, 0x0000 },

-  { 0x810e, 0x006f, 0x4000 },

-  { 0x810e, 0x006b, 0x3000 },

-  { 0x810e, 0x0069, 0x2000 },

-  { 0x010e, 0x0068, 0x0000 },

-  { 0x010e, 0x006a, 0x0000 },

-  { 0x810e, 0x006d, 0x2000 },

-  { 0x010e, 0x006c, 0x0000 },

-  { 0x010e, 0x006e, 0x0000 },

-  { 0x810e, 0x0073, 0x3000 },

-  { 0x810e, 0x0071, 0x2000 },

-  { 0x010e, 0x0070, 0x0000 },

-  { 0x010e, 0x0072, 0x0000 },

-  { 0x810e, 0x0075, 0x2000 },

-  { 0x010e, 0x0074, 0x0000 },

-  { 0x010e, 0x0076, 0x0000 },

-  { 0x8c0e, 0x0177, 0x8000 },

-  { 0x8c0e, 0x0137, 0x7000 },

-  { 0x8c0e, 0x0117, 0x6000 },

-  { 0x8c0e, 0x0107, 0x5000 },

-  { 0x810e, 0x007f, 0x4000 },

-  { 0x810e, 0x007b, 0x3000 },

-  { 0x810e, 0x0079, 0x2000 },

-  { 0x010e, 0x0078, 0x0000 },

-  { 0x010e, 0x007a, 0x0000 },

-  { 0x810e, 0x007d, 0x2000 },

-  { 0x010e, 0x007c, 0x0000 },

-  { 0x010e, 0x007e, 0x0000 },

-  { 0x8c0e, 0x0103, 0x3000 },

-  { 0x8c0e, 0x0101, 0x2000 },

-  { 0x0c0e, 0x0100, 0x0000 },

-  { 0x0c0e, 0x0102, 0x0000 },

-  { 0x8c0e, 0x0105, 0x2000 },

-  { 0x0c0e, 0x0104, 0x0000 },

-  { 0x0c0e, 0x0106, 0x0000 },

-  { 0x8c0e, 0x010f, 0x4000 },

-  { 0x8c0e, 0x010b, 0x3000 },

-  { 0x8c0e, 0x0109, 0x2000 },

-  { 0x0c0e, 0x0108, 0x0000 },

-  { 0x0c0e, 0x010a, 0x0000 },

-  { 0x8c0e, 0x010d, 0x2000 },

-  { 0x0c0e, 0x010c, 0x0000 },

-  { 0x0c0e, 0x010e, 0x0000 },

-  { 0x8c0e, 0x0113, 0x3000 },

-  { 0x8c0e, 0x0111, 0x2000 },

-  { 0x0c0e, 0x0110, 0x0000 },

-  { 0x0c0e, 0x0112, 0x0000 },

-  { 0x8c0e, 0x0115, 0x2000 },

-  { 0x0c0e, 0x0114, 0x0000 },

-  { 0x0c0e, 0x0116, 0x0000 },

-  { 0x8c0e, 0x0127, 0x5000 },

-  { 0x8c0e, 0x011f, 0x4000 },

-  { 0x8c0e, 0x011b, 0x3000 },

-  { 0x8c0e, 0x0119, 0x2000 },

-  { 0x0c0e, 0x0118, 0x0000 },

-  { 0x0c0e, 0x011a, 0x0000 },

-  { 0x8c0e, 0x011d, 0x2000 },

-  { 0x0c0e, 0x011c, 0x0000 },

-  { 0x0c0e, 0x011e, 0x0000 },

-  { 0x8c0e, 0x0123, 0x3000 },

-  { 0x8c0e, 0x0121, 0x2000 },

-  { 0x0c0e, 0x0120, 0x0000 },

-  { 0x0c0e, 0x0122, 0x0000 },

-  { 0x8c0e, 0x0125, 0x2000 },

-  { 0x0c0e, 0x0124, 0x0000 },

-  { 0x0c0e, 0x0126, 0x0000 },

-  { 0x8c0e, 0x012f, 0x4000 },

-  { 0x8c0e, 0x012b, 0x3000 },

-  { 0x8c0e, 0x0129, 0x2000 },

-  { 0x0c0e, 0x0128, 0x0000 },

-  { 0x0c0e, 0x012a, 0x0000 },

-  { 0x8c0e, 0x012d, 0x2000 },

-  { 0x0c0e, 0x012c, 0x0000 },

-  { 0x0c0e, 0x012e, 0x0000 },

-  { 0x8c0e, 0x0133, 0x3000 },

-  { 0x8c0e, 0x0131, 0x2000 },

-  { 0x0c0e, 0x0130, 0x0000 },

-  { 0x0c0e, 0x0132, 0x0000 },

-  { 0x8c0e, 0x0135, 0x2000 },

-  { 0x0c0e, 0x0134, 0x0000 },

-  { 0x0c0e, 0x0136, 0x0000 },

-  { 0x8c0e, 0x0157, 0x6000 },

-  { 0x8c0e, 0x0147, 0x5000 },

-  { 0x8c0e, 0x013f, 0x4000 },

-  { 0x8c0e, 0x013b, 0x3000 },

-  { 0x8c0e, 0x0139, 0x2000 },

-  { 0x0c0e, 0x0138, 0x0000 },

-  { 0x0c0e, 0x013a, 0x0000 },

-  { 0x8c0e, 0x013d, 0x2000 },

-  { 0x0c0e, 0x013c, 0x0000 },

-  { 0x0c0e, 0x013e, 0x0000 },

-  { 0x8c0e, 0x0143, 0x3000 },

-  { 0x8c0e, 0x0141, 0x2000 },

-  { 0x0c0e, 0x0140, 0x0000 },

-  { 0x0c0e, 0x0142, 0x0000 },

-  { 0x8c0e, 0x0145, 0x2000 },

-  { 0x0c0e, 0x0144, 0x0000 },

-  { 0x0c0e, 0x0146, 0x0000 },

-  { 0x8c0e, 0x014f, 0x4000 },

-  { 0x8c0e, 0x014b, 0x3000 },

-  { 0x8c0e, 0x0149, 0x2000 },

-  { 0x0c0e, 0x0148, 0x0000 },

-  { 0x0c0e, 0x014a, 0x0000 },

-  { 0x8c0e, 0x014d, 0x2000 },

-  { 0x0c0e, 0x014c, 0x0000 },

-  { 0x0c0e, 0x014e, 0x0000 },

-  { 0x8c0e, 0x0153, 0x3000 },

-  { 0x8c0e, 0x0151, 0x2000 },

-  { 0x0c0e, 0x0150, 0x0000 },

-  { 0x0c0e, 0x0152, 0x0000 },

-  { 0x8c0e, 0x0155, 0x2000 },

-  { 0x0c0e, 0x0154, 0x0000 },

-  { 0x0c0e, 0x0156, 0x0000 },

-  { 0x8c0e, 0x0167, 0x5000 },

-  { 0x8c0e, 0x015f, 0x4000 },

-  { 0x8c0e, 0x015b, 0x3000 },

-  { 0x8c0e, 0x0159, 0x2000 },

-  { 0x0c0e, 0x0158, 0x0000 },

-  { 0x0c0e, 0x015a, 0x0000 },

-  { 0x8c0e, 0x015d, 0x2000 },

-  { 0x0c0e, 0x015c, 0x0000 },

-  { 0x0c0e, 0x015e, 0x0000 },

-  { 0x8c0e, 0x0163, 0x3000 },

-  { 0x8c0e, 0x0161, 0x2000 },

-  { 0x0c0e, 0x0160, 0x0000 },

-  { 0x0c0e, 0x0162, 0x0000 },

-  { 0x8c0e, 0x0165, 0x2000 },

-  { 0x0c0e, 0x0164, 0x0000 },

-  { 0x0c0e, 0x0166, 0x0000 },

-  { 0x8c0e, 0x016f, 0x4000 },

-  { 0x8c0e, 0x016b, 0x3000 },

-  { 0x8c0e, 0x0169, 0x2000 },

-  { 0x0c0e, 0x0168, 0x0000 },

-  { 0x0c0e, 0x016a, 0x0000 },

-  { 0x8c0e, 0x016d, 0x2000 },

-  { 0x0c0e, 0x016c, 0x0000 },

-  { 0x0c0e, 0x016e, 0x0000 },

-  { 0x8c0e, 0x0173, 0x3000 },

-  { 0x8c0e, 0x0171, 0x2000 },

-  { 0x0c0e, 0x0170, 0x0000 },

-  { 0x0c0e, 0x0172, 0x0000 },

-  { 0x8c0e, 0x0175, 0x2000 },

-  { 0x0c0e, 0x0174, 0x0000 },

-  { 0x0c0e, 0x0176, 0x0000 },

-  { 0x8c0e, 0x01b7, 0x7000 },

-  { 0x8c0e, 0x0197, 0x6000 },

-  { 0x8c0e, 0x0187, 0x5000 },

-  { 0x8c0e, 0x017f, 0x4000 },

-  { 0x8c0e, 0x017b, 0x3000 },

-  { 0x8c0e, 0x0179, 0x2000 },

-  { 0x0c0e, 0x0178, 0x0000 },

-  { 0x0c0e, 0x017a, 0x0000 },

-  { 0x8c0e, 0x017d, 0x2000 },

-  { 0x0c0e, 0x017c, 0x0000 },

-  { 0x0c0e, 0x017e, 0x0000 },

-  { 0x8c0e, 0x0183, 0x3000 },

-  { 0x8c0e, 0x0181, 0x2000 },

-  { 0x0c0e, 0x0180, 0x0000 },

-  { 0x0c0e, 0x0182, 0x0000 },

-  { 0x8c0e, 0x0185, 0x2000 },

-  { 0x0c0e, 0x0184, 0x0000 },

-  { 0x0c0e, 0x0186, 0x0000 },

-  { 0x8c0e, 0x018f, 0x4000 },

-  { 0x8c0e, 0x018b, 0x3000 },

-  { 0x8c0e, 0x0189, 0x2000 },

-  { 0x0c0e, 0x0188, 0x0000 },

-  { 0x0c0e, 0x018a, 0x0000 },

-  { 0x8c0e, 0x018d, 0x2000 },

-  { 0x0c0e, 0x018c, 0x0000 },

-  { 0x0c0e, 0x018e, 0x0000 },

-  { 0x8c0e, 0x0193, 0x3000 },

-  { 0x8c0e, 0x0191, 0x2000 },

-  { 0x0c0e, 0x0190, 0x0000 },

-  { 0x0c0e, 0x0192, 0x0000 },

-  { 0x8c0e, 0x0195, 0x2000 },

-  { 0x0c0e, 0x0194, 0x0000 },

-  { 0x0c0e, 0x0196, 0x0000 },

-  { 0x8c0e, 0x01a7, 0x5000 },

-  { 0x8c0e, 0x019f, 0x4000 },

-  { 0x8c0e, 0x019b, 0x3000 },

-  { 0x8c0e, 0x0199, 0x2000 },

-  { 0x0c0e, 0x0198, 0x0000 },

-  { 0x0c0e, 0x019a, 0x0000 },

-  { 0x8c0e, 0x019d, 0x2000 },

-  { 0x0c0e, 0x019c, 0x0000 },

-  { 0x0c0e, 0x019e, 0x0000 },

-  { 0x8c0e, 0x01a3, 0x3000 },

-  { 0x8c0e, 0x01a1, 0x2000 },

-  { 0x0c0e, 0x01a0, 0x0000 },

-  { 0x0c0e, 0x01a2, 0x0000 },

-  { 0x8c0e, 0x01a5, 0x2000 },

-  { 0x0c0e, 0x01a4, 0x0000 },

-  { 0x0c0e, 0x01a6, 0x0000 },

-  { 0x8c0e, 0x01af, 0x4000 },

-  { 0x8c0e, 0x01ab, 0x3000 },

-  { 0x8c0e, 0x01a9, 0x2000 },

-  { 0x0c0e, 0x01a8, 0x0000 },

-  { 0x0c0e, 0x01aa, 0x0000 },

-  { 0x8c0e, 0x01ad, 0x2000 },

-  { 0x0c0e, 0x01ac, 0x0000 },

-  { 0x0c0e, 0x01ae, 0x0000 },

-  { 0x8c0e, 0x01b3, 0x3000 },

-  { 0x8c0e, 0x01b1, 0x2000 },

-  { 0x0c0e, 0x01b0, 0x0000 },

-  { 0x0c0e, 0x01b2, 0x0000 },

-  { 0x8c0e, 0x01b5, 0x2000 },

-  { 0x0c0e, 0x01b4, 0x0000 },

-  { 0x0c0e, 0x01b6, 0x0000 },

-  { 0x8c0e, 0x01d7, 0x6000 },

-  { 0x8c0e, 0x01c7, 0x5000 },

-  { 0x8c0e, 0x01bf, 0x4000 },

-  { 0x8c0e, 0x01bb, 0x3000 },

-  { 0x8c0e, 0x01b9, 0x2000 },

-  { 0x0c0e, 0x01b8, 0x0000 },

-  { 0x0c0e, 0x01ba, 0x0000 },

-  { 0x8c0e, 0x01bd, 0x2000 },

-  { 0x0c0e, 0x01bc, 0x0000 },

-  { 0x0c0e, 0x01be, 0x0000 },

-  { 0x8c0e, 0x01c3, 0x3000 },

-  { 0x8c0e, 0x01c1, 0x2000 },

-  { 0x0c0e, 0x01c0, 0x0000 },

-  { 0x0c0e, 0x01c2, 0x0000 },

-  { 0x8c0e, 0x01c5, 0x2000 },

-  { 0x0c0e, 0x01c4, 0x0000 },

-  { 0x0c0e, 0x01c6, 0x0000 },

-  { 0x8c0e, 0x01cf, 0x4000 },

-  { 0x8c0e, 0x01cb, 0x3000 },

-  { 0x8c0e, 0x01c9, 0x2000 },

-  { 0x0c0e, 0x01c8, 0x0000 },

-  { 0x0c0e, 0x01ca, 0x0000 },

-  { 0x8c0e, 0x01cd, 0x2000 },

-  { 0x0c0e, 0x01cc, 0x0000 },

-  { 0x0c0e, 0x01ce, 0x0000 },

-  { 0x8c0e, 0x01d3, 0x3000 },

-  { 0x8c0e, 0x01d1, 0x2000 },

-  { 0x0c0e, 0x01d0, 0x0000 },

-  { 0x0c0e, 0x01d2, 0x0000 },

-  { 0x8c0e, 0x01d5, 0x2000 },

-  { 0x0c0e, 0x01d4, 0x0000 },

-  { 0x0c0e, 0x01d6, 0x0000 },

-  { 0x8c0e, 0x01e7, 0x5000 },

-  { 0x8c0e, 0x01df, 0x4000 },

-  { 0x8c0e, 0x01db, 0x3000 },

-  { 0x8c0e, 0x01d9, 0x2000 },

-  { 0x0c0e, 0x01d8, 0x0000 },

-  { 0x0c0e, 0x01da, 0x0000 },

-  { 0x8c0e, 0x01dd, 0x2000 },

-  { 0x0c0e, 0x01dc, 0x0000 },

-  { 0x0c0e, 0x01de, 0x0000 },

-  { 0x8c0e, 0x01e3, 0x3000 },

-  { 0x8c0e, 0x01e1, 0x2000 },

-  { 0x0c0e, 0x01e0, 0x0000 },

-  { 0x0c0e, 0x01e2, 0x0000 },

-  { 0x8c0e, 0x01e5, 0x2000 },

-  { 0x0c0e, 0x01e4, 0x0000 },

-  { 0x0c0e, 0x01e6, 0x0000 },

-  { 0x8c0e, 0x01ef, 0x4000 },

-  { 0x8c0e, 0x01eb, 0x3000 },

-  { 0x8c0e, 0x01e9, 0x2000 },

-  { 0x0c0e, 0x01e8, 0x0000 },

-  { 0x0c0e, 0x01ea, 0x0000 },

-  { 0x8c0e, 0x01ed, 0x2000 },

-  { 0x0c0e, 0x01ec, 0x0000 },

-  { 0x0c0e, 0x01ee, 0x0000 },

-  { 0x830f, 0xfffd, 0x2000 },

-  { 0x030f, 0x0000, 0x0000 },

-  { 0x0310, 0x0000, 0x1000 },

-  { 0x0310, 0xfffd, 0x0000 },

-};

-

-

-/* In some environments, external functions have to be preceded by some magic.

-In my world (Unix), they do not. Use a macro to deal with this. */

-

-#ifndef EXPORT

-#define EXPORT

-#endif

-

-

-

-/*************************************************

-*         Search table and return data           *

-*************************************************/

-

-/* Two values are returned: the category is ucp_C, ucp_L, etc. The detailed

-character type is ucp_Lu, ucp_Nd, etc.

-

-Arguments:

-  c           the character value

-  type_ptr    the detailed character type is returned here

-  case_ptr    for letters, the opposite case is returned here, if there

-                is one, else zero

-

-Returns:      the character type category or -1 if not found

-*/

-

-EXPORT int

-ucp_findchar(const int c, int *type_ptr, int *case_ptr)

-{

-cnode *node = ucp_table;

-register int cc = c;

-int case_offset;

-

-for (;;)

-  {

-  register int d = node->f1 | ((node->f0 & f0_chhmask) << 16);

-  if (cc == d) break;

-  if (cc < d)

-    {

-    if ((node->f0 & f0_leftexists) == 0) return -1;

-    node ++;

-    }

-  else

-    {

-    register int roffset = (node->f2 & f2_rightmask) >> f2_rightshift;

-    if (roffset == 0) return -1;

-    node += 1 << (roffset - 1);

-    }

-  }

-

-switch ((*type_ptr = ((node->f0 & f0_typemask) >> f0_typeshift)))

-  {

-  case ucp_Cc:

-  case ucp_Cf:

-  case ucp_Cn:

-  case ucp_Co:

-  case ucp_Cs:

-  return ucp_C;

-  break;

-

-  case ucp_Ll:

-  case ucp_Lu:

-  case_offset = node->f2 & f2_casemask;

-  if ((case_offset & 0x0100) != 0) case_offset |= 0xfffff000;

-  *case_ptr = (case_offset == 0)? 0 : cc + case_offset;

-  return ucp_L;

-

-  case ucp_Lm:

-  case ucp_Lo:

-  case ucp_Lt:

-  *case_ptr = 0;

-  return ucp_L;

-  break;

-

-  case ucp_Mc:

-  case ucp_Me:

-  case ucp_Mn:

-  return ucp_M;

-  break;

-

-  case ucp_Nd:

-  case ucp_Nl:

-  case ucp_No:

-  return ucp_N;

-  break;

-

-  case ucp_Pc:

-  case ucp_Pd:

-  case ucp_Pe:

-  case ucp_Pf:

-  case ucp_Pi:

-  case ucp_Ps:

-  case ucp_Po:

-  return ucp_P;

-  break;

-

-  case ucp_Sc:

-  case ucp_Sk:

-  case ucp_Sm:

-  case ucp_So:

-  return ucp_S;

-  break;

-

-  case ucp_Zl:

-  case ucp_Zp:

-  case ucp_Zs:

-  return ucp_Z;

-  break;

-

-  default:         /* "Should never happen" */

-  return -1;

-  break;

-  }

-}

-

-/* End of ucp_findchar.c */

-

-

-/* End of pcre_ucp_findchar.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function for validating UTF-8 character

-strings. */

-

-

-

-

-/*************************************************

-*         Validate a UTF-8 string                *

-*************************************************/

-

-/* This function is called (optionally) at the start of compile or match, to

-validate that a supposed UTF-8 string is actually valid. The early check means

-that subsequent code can assume it is dealing with a valid string. The check

-can be turned off for maximum performance, but the consequences of supplying

-an invalid string are then undefined.

-

-Arguments:

-  string       points to the string

-  length       length of string, or -1 if the string is zero-terminated

-

-Returns:       < 0    if the string is a valid UTF-8 string

-               >= 0   otherwise; the value is the offset of the bad byte

-*/

-

-EXPORT int

-_pcre_valid_utf8(const uschar *string, int length)

-{

-register const uschar *p;

-

-if (length < 0)

-  {

-  for (p = string; *p != 0; p++);

-  length = p - string;

-  }

-

-for (p = string; length-- > 0; p++)

-  {

-  register int ab;

-  register int c = *p;

-  if (c < 128) continue;

-  if ((c & 0xc0) != 0xc0) return p - string;

-  ab = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */

-  if (length < ab) return p - string;

-  length -= ab;

-

-  /* Check top bits in the second byte */

-  if ((*(++p) & 0xc0) != 0x80) return p - string;

-

-  /* Check for overlong sequences for each different length */

-  switch (ab)

-    {

-    /* Check for xx00 000x */

-    case 1:

-    if ((c & 0x3e) == 0) return p - string;

-    continue;   /* We know there aren't any more bytes to check */

-

-    /* Check for 1110 0000, xx0x xxxx */

-    case 2:

-    if (c == 0xe0 && (*p & 0x20) == 0) return p - string;

-    break;

-

-    /* Check for 1111 0000, xx00 xxxx */

-    case 3:

-    if (c == 0xf0 && (*p & 0x30) == 0) return p - string;

-    break;

-

-    /* Check for 1111 1000, xx00 0xxx */

-    case 4:

-    if (c == 0xf8 && (*p & 0x38) == 0) return p - string;

-    break;

-

-    /* Check for leading 0xfe or 0xff, and then for 1111 1100, xx00 00xx */

-    case 5:

-    if (c == 0xfe || c == 0xff ||

-       (c == 0xfc && (*p & 0x3c) == 0)) return p - string;

-    break;

-    }

-

-  /* Check for valid bytes after the 2nd, if any; all must start 10 */

-  while (--ab > 0)

-    {

-    if ((*(++p) & 0xc0) != 0x80) return p - string;

-    }

-  }

-

-return -1;

-}

-

-/* End of pcre_valid_utf8.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_version(), which returns a

-string that identifies the PCRE version that is in use. */

-

-

-

-

-/*************************************************

-*          Return version string                 *

-*************************************************/

-

-#define STRING(a)  # a

-#define XSTRING(s) STRING(s)

-

-EXPORT const char *

-pcre_version(void)

-{

-return XSTRING(PCRE_MAJOR) "." XSTRING(PCRE_MINOR) " " XSTRING(PCRE_DATE);

-}

-

-/* End of pcre_version.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function that is used to match an extended

-class (one that contains characters whose values are > 255). It is used by both

-pcre_exec() and pcre_def_exec(). */

-

-

-

-

-/*************************************************

-*       Match character against an XCLASS        *

-*************************************************/

-

-/* This function is called to match a character against an extended class that

-might contain values > 255.

-

-Arguments:

-  c           the character

-  data        points to the flag byte of the XCLASS data

-

-Returns:      TRUE if character matches, else FALSE

-*/

-

-EXPORT BOOL

-_pcre_xclass(int c, const uschar *data)

-{

-int t;

-BOOL negated = (*data & XCL_NOT) != 0;

-

-/* Character values < 256 are matched against a bitmap, if one is present. If

-not, we still carry on, because there may be ranges that start below 256 in the

-additional data. */

-

-if (c < 256)

-  {

-  if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)

-    return !negated;   /* char found */

-  }

-

-/* First skip the bit map if present. Then match against the list of Unicode

-properties or large chars or ranges that end with a large char. We won't ever

-encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */

-

-if ((*data++ & XCL_MAP) != 0) data += 32;

-

-while ((t = *data++) != XCL_END)

-  {

-  int x, y;

-  if (t == XCL_SINGLE)

-    {

-    GETCHARINC(x, data);

-    if (c == x) return !negated;

-    }

-  else if (t == XCL_RANGE)

-    {

-    GETCHARINC(x, data);

-    GETCHARINC(y, data);

-    if (c >= x && c <= y) return !negated;

-    }

-

-#ifdef SUPPORT_UCP

-  else  /* XCL_PROP & XCL_NOTPROP */

-    {

-    int chartype, othercase;

-    int rqdtype = *data++;

-    int category = ucp_findchar(c, &chartype, &othercase);

-    if (rqdtype >= 128)

-      {

-      if ((rqdtype - 128 == category) == (t == XCL_PROP)) return !negated;

-      }

-    else

-      {

-      if ((rqdtype == chartype) == (t == XCL_PROP)) return !negated;

-      }

-    }

-#endif  /* SUPPORT_UCP */

-  }

-

-return negated;   /* char did not match */

-}

-

-/* End of pcre_xclass.c */

diff --git a/lib/oldwrappers/postgres.nim b/lib/oldwrappers/postgres.nim
deleted file mode 100755
index 4b43333d7..000000000
--- a/lib/oldwrappers/postgres.nim
+++ /dev/null
@@ -1,386 +0,0 @@
-# This module contains the definitions for structures and externs for
-# functions used by frontend postgres applications. It is based on
-# Postgresql's libpq-fe.h.
-#
-# It is for postgreSQL version 7.4 and higher with support for the v3.0
-# connection-protocol.
-#
-
-{.deadCodeElim: on.}
-
-when defined(windows):
-  const dllName = "pq.dll"
-elif defined(macosx):
-  const dllName = "libpq.dylib"
-else:
-  const dllName = "libpq.so(.5|)"
-  
-type
-  POid* = ptr Oid
-  Oid* = int32
-
-const 
-  ERROR_MSG_LENGTH* = 4096
-  CMDSTATUS_LEN* = 40
-
-type 
-  TSockAddr* = array[1..112, int8]
-  TPGresAttDesc*{.pure, final.} = object 
-    name*: cstring
-    adtid*: Oid
-    adtsize*: int
-
-  PPGresAttDesc* = ptr TPGresAttDesc
-  PPPGresAttDesc* = ptr PPGresAttDesc
-  TPGresAttValue*{.pure, final.} = object 
-    length*: int32
-    value*: cstring
-
-  PPGresAttValue* = ptr TPGresAttValue
-  PPPGresAttValue* = ptr PPGresAttValue
-  PExecStatusType* = ptr TExecStatusType
-  TExecStatusType* = enum 
-    PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, 
-    PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR
-  TPGlobjfuncs*{.pure, final.} = object 
-    fn_lo_open*: Oid
-    fn_lo_close*: Oid
-    fn_lo_creat*: Oid
-    fn_lo_unlink*: Oid
-    fn_lo_lseek*: Oid
-    fn_lo_tell*: Oid
-    fn_lo_read*: Oid
-    fn_lo_write*: Oid
-
-  PPGlobjfuncs* = ptr TPGlobjfuncs
-  PConnStatusType* = ptr TConnStatusType
-  TConnStatusType* = enum 
-    CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, 
-    CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, 
-    CONNECTION_SSL_STARTUP, CONNECTION_NEEDED
-  TPGconn* {.pure, final.} = object 
-    pghost*: cstring
-    pgtty*: cstring
-    pgport*: cstring
-    pgoptions*: cstring
-    dbName*: cstring
-    status*: TConnStatusType
-    errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char]
-    Pfin*: TFile
-    Pfout*: TFile
-    Pfdebug*: TFile
-    sock*: int32
-    laddr*: TSockAddr
-    raddr*: TSockAddr
-    salt*: array[0..(2) - 1, char]
-    asyncNotifyWaiting*: int32
-    notifyList*: pointer
-    pguser*: cstring
-    pgpass*: cstring
-    lobjfuncs*: PPGlobjfuncs
-
-  PPGconn* = ptr TPGconn
-  TPGresult* {.pure, final.} = object 
-    ntups*: int32
-    numAttributes*: int32
-    attDescs*: PPGresAttDesc
-    tuples*: PPPGresAttValue
-    tupArrSize*: int32
-    resultStatus*: TExecStatusType
-    cmdStatus*: array[0..(CMDSTATUS_LEN) - 1, char]
-    binary*: int32
-    conn*: PPGconn
-
-  PPGresult* = ptr TPGresult
-  PPostgresPollingStatusType* = ptr PostgresPollingStatusType
-  PostgresPollingStatusType* = enum 
-    PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING, 
-    PGRES_POLLING_OK, PGRES_POLLING_ACTIVE
-  PPGTransactionStatusType* = ptr PGTransactionStatusType
-  PGTransactionStatusType* = enum 
-    PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR, 
-    PQTRANS_UNKNOWN
-  PPGVerbosity* = ptr PGVerbosity
-  PGVerbosity* = enum 
-    PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE
-  PpgNotify* = ptr pgNotify
-  pgNotify* {.pure, final.} = object
-    relname*: cstring
-    be_pid*: int32
-    extra*: cstring
-
-  PQnoticeReceiver* = proc (arg: pointer, res: PPGresult){.cdecl.}
-  PQnoticeProcessor* = proc (arg: pointer, message: cstring){.cdecl.} 
-  Ppqbool* = ptr pqbool
-  pqbool* = char
-  P_PQprintOpt* = ptr PQprintOpt
-  PQprintOpt* {.pure, final.} = object
-    header*: pqbool
-    align*: pqbool
-    standard*: pqbool
-    html3*: pqbool
-    expanded*: pqbool
-    pager*: pqbool
-    fieldSep*: cstring
-    tableOpt*: cstring
-    caption*: cstring
-    fieldName*: ptr cstring
-
-  P_PQconninfoOption* = ptr PQconninfoOption
-  PQconninfoOption* {.pure, final.} = object
-    keyword*: cstring
-    envvar*: cstring
-    compiled*: cstring
-    val*: cstring
-    label*: cstring
-    dispchar*: cstring
-    dispsize*: int32
-
-  PPQArgBlock* = ptr PQArgBlock
-  PQArgBlock* {.pure, final.} = object  
-    length*: int32
-    isint*: int32
-    p*: pointer
-
-proc PQconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
-    importc: "PQconnectStart".}
-proc PQconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQconnectPoll".}
-
-proc PQconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
-    importc: "PQconnectdb".}
-proc PQsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring, 
-                   pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
-    cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
-
-proc PQsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn
-
-proc PQfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
-
-proc PQconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName, 
-    importc: "PQconndefaults".}
-
-proc PQconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName, 
-    importc: "PQconninfoFree".}
-
-proc PQresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQresetStart".}
-proc PQresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQresetPoll".}
-
-proc PQreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
-
-proc PQrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQrequestCancel".}
-
-proc PQdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
-proc PQuser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
-proc PQpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
-proc PQhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
-proc PQport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
-proc PQtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
-proc PQoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQoptions".}
-proc PQstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName, 
-    importc: "PQstatus".}
-proc PQtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQtransactionStatus".}
-proc PQparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQparameterStatus".}
-proc PQprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQprotocolVersion".}
-proc PQerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQerrorMessage".}
-proc PQsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                      importc: "PQsocket".}
-proc PQbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQbackendPID".}
-proc PQclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQclientEncoding".}
-proc PQsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQsetClientEncoding".}
-when defined(USE_SSL): 
-  # Get the SSL structure associated with a connection  
-  proc PQgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName, 
-                                       importc: "PQgetssl".}
-
-proc PQsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
-    cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
-
-proc PQtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName, 
-    importc: "PQtrace".}
-proc PQuntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
-
-proc PQsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, 
-                          arg: pointer): PQnoticeReceiver {.
-    cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
-proc PQsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor, 
-                           arg: pointer): PQnoticeProcessor{.
-    cdecl, dynlib: dllName, importc: "PQsetNoticeProcessor".}
-
-proc PQexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName, 
-    importc: "PQexec".}
-proc PQexecParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                   paramTypes: POid, paramValues: cstringArray, 
-                   paramLengths, paramFormats: ptr int32, 
-                   resultFormat: int32): PPGresult {.cdecl, dynlib: dllName, 
-    importc: "PQexecParams".}
-proc PQexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32, 
-                     paramValues: cstringArray, 
-                     paramLengths, paramFormats: ptr int32, 
-                     resultFormat: int32): PPGresult {.
-    cdecl, dynlib: dllName, importc: "PQexecPrepared".}
-
-proc PQsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName, 
-    importc: "PQsendQuery".}
-proc PQsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                        paramTypes: POid, paramValues: cstringArray, 
-                        paramLengths, paramFormats: ptr int32, 
-                        resultFormat: int32): int32 {.cdecl, dynlib: dllName, 
-    importc: "PQsendQueryParams".}
-proc PQsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32, 
-                          paramValues: cstringArray, 
-                          paramLengths, paramFormats: ptr int32, 
-                          resultFormat: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQsendQueryPrepared".}
-proc PQgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName, 
-    importc: "PQgetResult".}
-proc PQisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                      importc: "PQisBusy".}
-proc PQconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQconsumeInput".}
-
-proc PQnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName, 
-    importc: "PQnotifies".}
-
-proc PQputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQputCopyData".}
-proc PQputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQputCopyEnd".}
-proc PQgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQgetCopyData".}
-
-proc PQgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQgetline".}
-proc PQputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName, 
-    importc: "PQputline".}
-proc PQgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
-proc PQputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQputnbytes".}
-proc PQendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                       importc: "PQendcopy".}
-
-proc PQsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQsetnonblocking".}
-proc PQisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQisnonblocking".}
-
-proc PQflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
-
-proc PQfn*(conn: PPGconn, fnid: int32, result_buf, 
-           result_len: ptr int32, result_is_int: int32, args: PPQArgBlock, 
-           nargs: int32): PPGresult{.cdecl, dynlib: dllName, importc: "PQfn".}
-
-proc PQresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName, 
-    importc: "PQresultStatus".}
-proc PQresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQresStatus".}
-proc PQresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQresultErrorMessage".}
-proc PQresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQresultErrorField".}
-proc PQntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-                                        importc: "PQntuples".}
-proc PQnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-                                        importc: "PQnfields".}
-proc PQbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-    importc: "PQbinaryTuples".}
-proc PQfname*(res: PPGresult, field_num: int32): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQfname".}
-proc PQfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQfnumber".}
-proc PQftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "PQftable".}
-proc PQftablecol*(res: PPGresult, field_num: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQftablecol".}
-proc PQfformat*(res: PPGresult, field_num: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQfformat".}
-proc PQftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "PQftype".}
-proc PQfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQfsize".}
-proc PQfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQfmod".}
-proc PQcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQcmdStatus".}
-proc PQoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQoidStatus".}
-
-proc PQoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName, 
-                                       importc: "PQoidValue".}
-
-proc PQcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQcmdTuples".}
-proc PQgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
-    cdecl, dynlib: dllName, importc: "PQgetvalue".}
-proc PQgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetlength".}
-proc PQgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetisnull".}
-
-proc PQclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
-
-proc PQfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
-
-proc PQmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
-    cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
-
-proc PQescapeString*(till, `from`: cstring, len: int): int{.cdecl, 
-    dynlib: dllName, importc: "PQescapeString".}
-proc PQescapeBytea*(bintext: cstring, binlen: int, 
-                    bytealen: var int): cstring{.
-    cdecl, dynlib: dllName, importc: "PQescapeBytea".}
-proc PQunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQunescapeBytea".}
-
-proc PQprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl, 
-    dynlib: dllName, importc: "PQprint".}
-
-proc PQdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32, 
-                      fieldSep: cstring, printHeader: int32, quiet: int32){.
-    cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
-
-proc PQprintTuples*(res: PPGresult, fout: TFile, printAttName: int32, 
-                    terseOutput: int32, width: int32){.cdecl, dynlib: dllName, 
-    importc: "PQprintTuples".}
-
-proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "lo_open".}
-proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_close".}
-proc lo_read*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
-    cdecl, dynlib: dllName, importc: "lo_read".}
-proc lo_write*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
-    cdecl, dynlib: dllName, importc: "lo_write".}
-proc lo_lseek*(conn: PPGconn, fd: int32, offset: int32, whence: int32): int32{.
-    cdecl, dynlib: dllName, importc: "lo_lseek".}
-proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "lo_creat".}
-proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_tell".}
-proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_unlink".}
-proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName, 
-    importc: "lo_import".}
-proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "lo_export".}
-
-proc PQmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQmblen".}
-
-proc PQenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
-
-proc PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn = 
-  result = PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
-
diff --git a/lib/oldwrappers/python.nim b/lib/oldwrappers/python.nim
deleted file mode 100755
index ea9ef1fd5..000000000
--- a/lib/oldwrappers/python.nim
+++ /dev/null
@@ -1,1583 +0,0 @@
-#
-#    Light-weight binding for the Python interpreter
-#       (c) 2010 Andreas Rumpf 
-#    Based on 'PythonEngine' module by Dr. Dietmar Budelsky
-#
-#
-#************************************************************************
-#                                                                        
-# Module:  Unit 'PythonEngine'     Copyright (c) 1997                    
-#                                                                        
-# Version: 3.0                     Dr. Dietmar Budelsky                  
-# Sub-Version: 0.25                dbudelsky@web.de                      
-#                                  Germany                               
-#                                                                        
-#                                  Morgan Martinet                       
-#                                  4721 rue Brebeuf                      
-#                                  H2J 3L2 MONTREAL (QC)                 
-#                                  CANADA                                
-#                                  e-mail: mmm@free.fr                   
-#                                                                        
-#  look our page at: http://www.multimania.com/marat                     
-#************************************************************************
-#  Functionality:  Delphi Components that provide an interface to the    
-#                  Python language (see python.txt for more infos on     
-#                  Python itself).                                       
-#                                                                        
-#************************************************************************
-#  Contributors:                                                         
-#      Grzegorz Makarewicz (mak@mikroplan.com.pl)                        
-#      Andrew Robinson (andy@hps1.demon.co.uk)                           
-#      Mark Watts(mark_watts@hotmail.com)                                
-#      Olivier Deckmyn (olivier.deckmyn@mail.dotcom.fr)                  
-#      Sigve Tjora (public@tjora.no)                                     
-#      Mark Derricutt (mark@talios.com)                                  
-#      Igor E. Poteryaev (jah@mail.ru)                                   
-#      Yuri Filimonov (fil65@mail.ru)                                    
-#      Stefan Hoffmeister (Stefan.Hoffmeister@Econos.de)                 
-#************************************************************************
-# This source code is distributed with no WARRANTY, for no reason or use.
-# Everyone is allowed to use and change this code free for his own tasks 
-# and projects, as long as this header and its copyright text is intact. 
-# For changed versions of this code, which are public distributed the    
-# following additional conditions have to be fullfilled:                 
-# 1) The header has to contain a comment on the change and the author of 
-#    it.                                                                 
-# 2) A copy of the changed source has to be sent to the above E-Mail     
-#    address or my then valid address, if this is possible to the        
-#    author.                                                             
-# The second condition has the target to maintain an up to date central  
-# version of the component. If this condition is not acceptable for      
-# confidential or legal reasons, everyone is free to derive a component  
-# or to generate a diff file to my or other original sources.            
-# Dr. Dietmar Budelsky, 1997-11-17                                       
-#************************************************************************
-
-{.deadCodeElim: on.}
-
-import 
-  dynlib
-
-
-when defined(windows): 
-  const dllname = "python(26|25|24|23|22|21|20|16|15).dll"
-elif defined(macosx):
-  const dllname = "libpython(2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).dylib"
-else: 
-  const dllver = ".1"
-  const dllname = "libpython(2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).so" & dllver
-  
-const 
-  PYT_METHOD_BUFFER_INCREASE* = 10
-  PYT_MEMBER_BUFFER_INCREASE* = 10
-  PYT_GETSET_BUFFER_INCREASE* = 10
-  METH_VARARGS* = 0x0001
-  METH_KEYWORDS* = 0x0002 # Masks for the co_flags field of PyCodeObject
-  CO_OPTIMIZED* = 0x0001
-  CO_NEWLOCALS* = 0x0002
-  CO_VARARGS* = 0x0004
-  CO_VARKEYWORDS* = 0x0008
-
-type                          # Rich comparison opcodes introduced in version 2.1
-  TRichComparisonOpcode* = enum 
-    pyLT, pyLE, pyEQ, pyNE, pyGT, pyGE
-
-const
-  Py_TPFLAGS_HAVE_GETCHARBUFFER* = (1 shl 0) # PySequenceMethods contains sq_contains
-  Py_TPFLAGS_HAVE_SEQUENCE_IN* = (1 shl 1) # Objects which participate in garbage collection (see objimp.h)
-  Py_TPFLAGS_GC* = (1 shl 2)  # PySequenceMethods and PyNumberMethods contain in-place operators
-  Py_TPFLAGS_HAVE_INPLACEOPS* = (1 shl 3) # PyNumberMethods do their own coercion */
-  Py_TPFLAGS_CHECKTYPES* = (1 shl 4)
-  Py_TPFLAGS_HAVE_RICHCOMPARE* = (1 shl 5) # Objects which are weakly referencable if their tp_weaklistoffset is >0
-                                           # XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE?
-                                           # These both indicate a feature that appeared in the same alpha release.
-  Py_TPFLAGS_HAVE_WEAKREFS* = (1 shl 6) # tp_iter is defined
-  Py_TPFLAGS_HAVE_ITER* = (1 shl 7) # New members introduced by Python 2.2 exist
-  Py_TPFLAGS_HAVE_CLASS* = (1 shl 8) # Set if the type object is dynamically allocated
-  Py_TPFLAGS_HEAPTYPE* = (1 shl 9) # Set if the type allows subclassing
-  Py_TPFLAGS_BASETYPE* = (1 shl 10) # Set if the type is 'ready' -- fully initialized
-  Py_TPFLAGS_READY* = (1 shl 12) # Set while the type is being 'readied', to prevent recursive ready calls
-  Py_TPFLAGS_READYING* = (1 shl 13) # Objects support garbage collection (see objimp.h)
-  Py_TPFLAGS_HAVE_GC* = (1 shl 14)
-  Py_TPFLAGS_DEFAULT* = Py_TPFLAGS_HAVE_GETCHARBUFFER or
-      Py_TPFLAGS_HAVE_SEQUENCE_IN or Py_TPFLAGS_HAVE_INPLACEOPS or
-      Py_TPFLAGS_HAVE_RICHCOMPARE or Py_TPFLAGS_HAVE_WEAKREFS or
-      Py_TPFLAGS_HAVE_ITER or Py_TPFLAGS_HAVE_CLASS 
-
-type 
-  TPFlag* = enum 
-    tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfGC, tpfHaveInplaceOps, 
-    tpfCheckTypes, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 
-    tpfHaveClass, tpfHeapType, tpfBaseType, tpfReady, tpfReadying, tpfHaveGC
-  TPFlags* = set[TPFlag]
-
-const 
-  TPFLAGS_DEFAULT* = {tpfHaveGetCharBuffer, tpfHaveSequenceIn, 
-    tpfHaveInplaceOps, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 
-    tpfHaveClass}
-
-const # Python opcodes
-  single_input* = 256 
-  file_input* = 257
-  eval_input* = 258
-  funcdef* = 259
-  parameters* = 260
-  varargslist* = 261
-  fpdef* = 262
-  fplist* = 263
-  stmt* = 264
-  simple_stmt* = 265
-  small_stmt* = 266
-  expr_stmt* = 267
-  augassign* = 268
-  print_stmt* = 269
-  del_stmt* = 270
-  pass_stmt* = 271
-  flow_stmt* = 272
-  break_stmt* = 273
-  continue_stmt* = 274
-  return_stmt* = 275
-  raise_stmt* = 276
-  import_stmt* = 277
-  import_as_name* = 278
-  dotted_as_name* = 279
-  dotted_name* = 280
-  global_stmt* = 281
-  exec_stmt* = 282
-  assert_stmt* = 283
-  compound_stmt* = 284
-  if_stmt* = 285
-  while_stmt* = 286
-  for_stmt* = 287
-  try_stmt* = 288
-  except_clause* = 289
-  suite* = 290
-  test* = 291
-  and_test* = 291
-  not_test* = 293
-  comparison* = 294
-  comp_op* = 295
-  expr* = 296
-  xor_expr* = 297
-  and_expr* = 298
-  shift_expr* = 299
-  arith_expr* = 300
-  term* = 301
-  factor* = 302
-  power* = 303
-  atom* = 304
-  listmaker* = 305
-  lambdef* = 306
-  trailer* = 307
-  subscriptlist* = 308
-  subscript* = 309
-  sliceop* = 310
-  exprlist* = 311
-  testlist* = 312
-  dictmaker* = 313
-  classdef* = 314
-  arglist* = 315
-  argument* = 316
-  list_iter* = 317
-  list_for* = 318
-  list_if* = 319
-
-const 
-  T_SHORT* = 0
-  T_INT* = 1
-  T_LONG* = 2
-  T_FLOAT* = 3
-  T_DOUBLE* = 4
-  T_STRING* = 5
-  T_OBJECT* = 6
-  T_CHAR* = 7                 # 1-character string
-  T_BYTE* = 8                 # 8-bit signed int
-  T_UBYTE* = 9
-  T_USHORT* = 10
-  T_UINT* = 11
-  T_ULONG* = 12
-  T_STRING_INPLACE* = 13
-  T_OBJECT_EX* = 16 
-  READONLY* = 1
-  RO* = READONLY              # Shorthand 
-  READ_RESTRICTED* = 2
-  WRITE_RESTRICTED* = 4
-  RESTRICTED* = (READ_RESTRICTED or WRITE_RESTRICTED)
-
-type 
-  TPyMemberType* = enum 
-    mtShort, mtInt, mtLong, mtFloat, mtDouble, mtString, mtObject, mtChar, 
-    mtByte, mtUByte, mtUShort, mtUInt, mtULong, mtStringInplace, mtObjectEx
-  TPyMemberFlag* = enum 
-    mfDefault, mfReadOnly, mfReadRestricted, mfWriteRestricted, mfRestricted
-
-type 
-  PInt* = ptr int
-
-#  PLong* = ptr int32
-#  PFloat* = ptr float32
-#  PShort* = ptr int8
-  
-type 
-  PP_frozen* = ptr Pfrozen
-  P_frozen* = ptr Tfrozen
-  PPyObject* = ptr TPyObject
-  PPPyObject* = ptr PPyObject
-  PPPPyObject* = ptr PPPyObject
-  PPyIntObject* = ptr TPyIntObject
-  PPyTypeObject* = ptr TPyTypeObject
-  PPySliceObject* = ptr TPySliceObject
-  TPyCFunction* = proc (self, args: PPyObject): PPyObject{.cdecl.}
-  Tunaryfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Tbinaryfunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.}
-  Tternaryfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.}
-  Tinquiry* = proc (ob1: PPyObject): int{.cdecl.}
-  Tcoercion* = proc (ob1, ob2: PPPyObject): int{.cdecl.}
-  Tintargfunc* = proc (ob1: PPyObject, i: int): PPyObject{.cdecl.}
-  Tintintargfunc* = proc (ob1: PPyObject, i1, i2: int): PPyObject{.cdecl.}
-  Tintobjargproc* = proc (ob1: PPyObject, i: int, ob2: PPyObject): int{.cdecl.}
-  Tintintobjargproc* = proc (ob1: PPyObject, i1, i2: int, ob2: PPyObject): int{.
-      cdecl.}
-  Tobjobjargproc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.}
-  Tpydestructor* = proc (ob: PPyObject){.cdecl.}
-  Tprintfunc* = proc (ob: PPyObject, f: TFile, i: int): int{.cdecl.}
-  Tgetattrfunc* = proc (ob1: PPyObject, name: cstring): PPyObject{.cdecl.}
-  Tsetattrfunc* = proc (ob1: PPyObject, name: cstring, ob2: PPyObject): int{.
-      cdecl.}
-  Tcmpfunc* = proc (ob1, ob2: PPyObject): int{.cdecl.}
-  Treprfunc* = proc (ob: PPyObject): PPyObject{.cdecl.}
-  Thashfunc* = proc (ob: PPyObject): int32{.cdecl.}
-  Tgetattrofunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.}
-  Tsetattrofunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} 
-  Tgetreadbufferproc* = proc (ob1: PPyObject, i: int, p: Pointer): int{.cdecl.}
-  Tgetwritebufferproc* = proc (ob1: PPyObject, i: int, p: Pointer): int{.cdecl.}
-  Tgetsegcountproc* = proc (ob1: PPyObject, i: int): int{.cdecl.}
-  Tgetcharbufferproc* = proc (ob1: PPyObject, i: int, pstr: cstring): int{.cdecl.}
-  Tobjobjproc* = proc (ob1, ob2: PPyObject): int{.cdecl.}
-  Tvisitproc* = proc (ob1: PPyObject, p: Pointer): int{.cdecl.}
-  Ttraverseproc* = proc (ob1: PPyObject, prc: TVisitproc, p: Pointer): int{.
-      cdecl.}
-  Trichcmpfunc* = proc (ob1, ob2: PPyObject, i: int): PPyObject{.cdecl.}
-  Tgetiterfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Titernextfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Tdescrgetfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.}
-  Tdescrsetfunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.}
-  Tinitproc* = proc (self, args, kwds: PPyObject): int{.cdecl.}
-  Tnewfunc* = proc (subtype: PPyTypeObject, args, kwds: PPyObject): PPyObject{.
-      cdecl.}
-  Tallocfunc* = proc (self: PPyTypeObject, nitems: int): PPyObject{.cdecl.}
-  TPyNumberMethods*{.final.} = object 
-    nb_add*: Tbinaryfunc
-    nb_substract*: Tbinaryfunc
-    nb_multiply*: Tbinaryfunc
-    nb_divide*: Tbinaryfunc
-    nb_remainder*: Tbinaryfunc
-    nb_divmod*: Tbinaryfunc
-    nb_power*: Tternaryfunc
-    nb_negative*: Tunaryfunc
-    nb_positive*: Tunaryfunc
-    nb_absolute*: Tunaryfunc
-    nb_nonzero*: Tinquiry
-    nb_invert*: Tunaryfunc
-    nb_lshift*: Tbinaryfunc
-    nb_rshift*: Tbinaryfunc
-    nb_and*: Tbinaryfunc
-    nb_xor*: Tbinaryfunc
-    nb_or*: Tbinaryfunc
-    nb_coerce*: Tcoercion
-    nb_int*: Tunaryfunc
-    nb_long*: Tunaryfunc
-    nb_float*: Tunaryfunc
-    nb_oct*: Tunaryfunc
-    nb_hex*: Tunaryfunc       #/ jah 29-sep-2000: updated for python 2.0
-                              #/                   added from .h
-    nb_inplace_add*: Tbinaryfunc
-    nb_inplace_subtract*: Tbinaryfunc
-    nb_inplace_multiply*: Tbinaryfunc
-    nb_inplace_divide*: Tbinaryfunc
-    nb_inplace_remainder*: Tbinaryfunc
-    nb_inplace_power*: Tternaryfunc
-    nb_inplace_lshift*: Tbinaryfunc
-    nb_inplace_rshift*: Tbinaryfunc
-    nb_inplace_and*: Tbinaryfunc
-    nb_inplace_xor*: Tbinaryfunc
-    nb_inplace_or*: Tbinaryfunc # Added in release 2.2
-                                # The following require the Py_TPFLAGS_HAVE_CLASS flag
-    nb_floor_divide*: Tbinaryfunc
-    nb_true_divide*: Tbinaryfunc
-    nb_inplace_floor_divide*: Tbinaryfunc
-    nb_inplace_true_divide*: Tbinaryfunc
-
-  PPyNumberMethods* = ptr TPyNumberMethods
-  TPySequenceMethods*{.final.} = object 
-    sq_length*: Tinquiry
-    sq_concat*: Tbinaryfunc
-    sq_repeat*: Tintargfunc
-    sq_item*: Tintargfunc
-    sq_slice*: Tintintargfunc
-    sq_ass_item*: Tintobjargproc
-    sq_ass_slice*: Tintintobjargproc 
-    sq_contains*: Tobjobjproc
-    sq_inplace_concat*: Tbinaryfunc
-    sq_inplace_repeat*: Tintargfunc
-
-  PPySequenceMethods* = ptr TPySequenceMethods
-  TPyMappingMethods*{.final.} = object 
-    mp_length*: Tinquiry
-    mp_subscript*: Tbinaryfunc
-    mp_ass_subscript*: Tobjobjargproc
-
-  PPyMappingMethods* = ptr TPyMappingMethods 
-  TPyBufferProcs*{.final.} = object 
-    bf_getreadbuffer*: Tgetreadbufferproc
-    bf_getwritebuffer*: Tgetwritebufferproc
-    bf_getsegcount*: Tgetsegcountproc
-    bf_getcharbuffer*: Tgetcharbufferproc
-
-  PPyBufferProcs* = ptr TPyBufferProcs
-  TPy_complex*{.final.} = object 
-    float*: float64
-    imag*: float64
-
-  TPyObject*{.pure.} = object 
-    ob_refcnt*: int
-    ob_type*: PPyTypeObject
-
-  TPyIntObject* = object of TPyObject
-    ob_ival*: int32
-
-  PByte* = ptr int8
-  Tfrozen*{.final.} = object 
-    name*: cstring
-    code*: PByte
-    size*: int
-
-  TPySliceObject* = object of TPyObject
-    start*, stop*, step*: PPyObject
-
-  PPyMethodDef* = ptr TPyMethodDef
-  TPyMethodDef*{.final.} = object  # structmember.h
-    ml_name*: cstring
-    ml_meth*: TPyCFunction
-    ml_flags*: int
-    ml_doc*: cstring
-
-  PPyMemberDef* = ptr TPyMemberDef
-  TPyMemberDef*{.final.} = object  # descrobject.h
-                                   # Descriptors
-    name*: cstring
-    theType*: int
-    offset*: int
-    flags*: int
-    doc*: cstring
-
-  Tgetter* = proc (obj: PPyObject, context: Pointer): PPyObject{.cdecl.}
-  Tsetter* = proc (obj, value: PPyObject, context: Pointer): int{.cdecl.}
-  PPyGetSetDef* = ptr TPyGetSetDef
-  TPyGetSetDef*{.final.} = object 
-    name*: cstring
-    get*: Tgetter
-    setter*: Tsetter
-    doc*: cstring
-    closure*: Pointer
-
-  Twrapperfunc* = proc (self, args: PPyObject, wrapped: Pointer): PPyObject{.
-      cdecl.}
-  pwrapperbase* = ptr Twrapperbase
-  Twrapperbase*{.final.} = object  # Various kinds of descriptor objects
-                                   ##define PyDescr_COMMON \
-                                   #          PyObject_HEAD \
-                                   #          PyTypeObject *d_type; \
-                                   #          PyObject *d_name
-                                   #  
-    name*: cstring
-    wrapper*: Twrapperfunc
-    doc*: cstring
-
-  PPyDescrObject* = ptr TPyDescrObject
-  TPyDescrObject* = object of TPyObject
-    d_type*: PPyTypeObject
-    d_name*: PPyObject
-
-  PPyMethodDescrObject* = ptr TPyMethodDescrObject
-  TPyMethodDescrObject* = object of TPyDescrObject
-    d_method*: PPyMethodDef
-
-  PPyMemberDescrObject* = ptr TPyMemberDescrObject
-  TPyMemberDescrObject* = object of TPyDescrObject
-    d_member*: PPyMemberDef
-
-  PPyGetSetDescrObject* = ptr TPyGetSetDescrObject
-  TPyGetSetDescrObject* = object of TPyDescrObject
-    d_getset*: PPyGetSetDef
-
-  PPyWrapperDescrObject* = ptr TPyWrapperDescrObject
-  TPyWrapperDescrObject* = object of TPyDescrObject # object.h
-    d_base*: pwrapperbase
-    d_wrapped*: Pointer       # This can be any function pointer
-  
-  TPyTypeObject* = object of TPyObject
-    ob_size*: int             # Number of items in variable part
-    tp_name*: cstring         # For printing
-    tp_basicsize*, tp_itemsize*: int # For allocation
-                                     # Methods to implement standard operations
-    tp_dealloc*: Tpydestructor
-    tp_print*: Tprintfunc
-    tp_getattr*: Tgetattrfunc
-    tp_setattr*: Tsetattrfunc
-    tp_compare*: Tcmpfunc
-    tp_repr*: Treprfunc       # Method suites for standard classes
-    tp_as_number*: PPyNumberMethods
-    tp_as_sequence*: PPySequenceMethods
-    tp_as_mapping*: PPyMappingMethods # More standard operations (here for binary compatibility)
-    tp_hash*: Thashfunc
-    tp_call*: Tternaryfunc
-    tp_str*: Treprfunc
-    tp_getattro*: Tgetattrofunc
-    tp_setattro*: Tsetattrofunc #/ jah 29-sep-2000: updated for python 2.0
-                                # Functions to access object as input/output buffer
-    tp_as_buffer*: PPyBufferProcs # Flags to define presence of optional/expanded features
-    tp_flags*: int32
-    tp_doc*: cstring          # Documentation string
-                              # call function for all accessible objects
-    tp_traverse*: Ttraverseproc # delete references to contained objects
-    tp_clear*: Tinquiry       # rich comparisons
-    tp_richcompare*: Trichcmpfunc # weak reference enabler
-    tp_weaklistoffset*: int32 # Iterators
-    tp_iter*: Tgetiterfunc
-    tp_iternext*: Titernextfunc # Attribute descriptor and subclassing stuff
-    tp_methods*: PPyMethodDef
-    tp_members*: PPyMemberDef
-    tp_getset*: PPyGetSetDef
-    tp_base*: PPyTypeObject
-    tp_dict*: PPyObject
-    tp_descr_get*: Tdescrgetfunc
-    tp_descr_set*: Tdescrsetfunc
-    tp_dictoffset*: int32
-    tp_init*: Tinitproc
-    tp_alloc*: Tallocfunc
-    tp_new*: Tnewfunc
-    tp_free*: Tpydestructor   # Low-level free-memory routine
-    tp_is_gc*: Tinquiry       # For PyObject_IS_GC
-    tp_bases*: PPyObject
-    tp_mro*: PPyObject        # method resolution order
-    tp_cache*: PPyObject
-    tp_subclasses*: PPyObject
-    tp_weaklist*: PPyObject   #More spares
-    tp_xxx7*: pointer
-    tp_xxx8*: pointer
-
-  PPyMethodChain* = ptr TPyMethodChain
-  TPyMethodChain*{.final.} = object 
-    methods*: PPyMethodDef
-    link*: PPyMethodChain
-
-  PPyClassObject* = ptr TPyClassObject
-  TPyClassObject* = object of TPyObject
-    cl_bases*: PPyObject      # A tuple of class objects
-    cl_dict*: PPyObject       # A dictionary
-    cl_name*: PPyObject       # A string
-                              # The following three are functions or NULL
-    cl_getattr*: PPyObject
-    cl_setattr*: PPyObject
-    cl_delattr*: PPyObject
-
-  PPyInstanceObject* = ptr TPyInstanceObject
-  TPyInstanceObject* = object of TPyObject 
-    in_class*: PPyClassObject # The class object
-    in_dict*: PPyObject       # A dictionary
-  
-  PPyMethodObject* = ptr TPyMethodObject
-  TPyMethodObject* = object of TPyObject # Bytecode object, compile.h
-    im_func*: PPyObject       # The function implementing the method
-    im_self*: PPyObject       # The instance it is bound to, or NULL
-    im_class*: PPyObject      # The class that defined the method
-  
-  PPyCodeObject* = ptr TPyCodeObject
-  TPyCodeObject* = object of TPyObject # from pystate.h
-    co_argcount*: int         # #arguments, except *args
-    co_nlocals*: int          # #local variables
-    co_stacksize*: int        # #entries needed for evaluation stack
-    co_flags*: int            # CO_..., see below
-    co_code*: PPyObject       # instruction opcodes (it hides a PyStringObject)
-    co_consts*: PPyObject     # list (constants used)
-    co_names*: PPyObject      # list of strings (names used)
-    co_varnames*: PPyObject   # tuple of strings (local variable names)
-    co_freevars*: PPyObject   # tuple of strings (free variable names)
-    co_cellvars*: PPyObject   # tuple of strings (cell variable names)
-                              # The rest doesn't count for hash/cmp
-    co_filename*: PPyObject   # string (where it was loaded from)
-    co_name*: PPyObject       # string (name, for reference)
-    co_firstlineno*: int      # first source line number
-    co_lnotab*: PPyObject     # string (encoding addr<->lineno mapping)
-  
-  PPyInterpreterState* = ptr TPyInterpreterState
-  PPyThreadState* = ptr TPyThreadState
-  PPyFrameObject* = ptr TPyFrameObject # Interpreter environments
-  TPyInterpreterState*{.final.} = object  # Thread specific information
-    next*: PPyInterpreterState
-    tstate_head*: PPyThreadState
-    modules*: PPyObject
-    sysdict*: PPyObject
-    builtins*: PPyObject
-    checkinterval*: int
-
-  TPyThreadState*{.final.} = object  # from frameobject.h
-    next*: PPyThreadState
-    interp*: PPyInterpreterState
-    frame*: PPyFrameObject
-    recursion_depth*: int
-    ticker*: int
-    tracing*: int
-    sys_profilefunc*: PPyObject
-    sys_tracefunc*: PPyObject
-    curexc_type*: PPyObject
-    curexc_value*: PPyObject
-    curexc_traceback*: PPyObject
-    exc_type*: PPyObject
-    exc_value*: PPyObject
-    exc_traceback*: PPyObject
-    dict*: PPyObject
-
-  PPyTryBlock* = ptr TPyTryBlock
-  TPyTryBlock*{.final.} = object 
-    b_type*: int              # what kind of block this is
-    b_handler*: int           # where to jump to find handler
-    b_level*: int             # value stack level to pop to
-  
-  CO_MAXBLOCKS* = range[0..19]
-  TPyFrameObject* = object of TPyObject # start of the VAR_HEAD of an object
-                                        # From traceback.c
-    ob_size*: int             # Number of items in variable part
-                              # End of the Head of an object
-    f_back*: PPyFrameObject   # previous frame, or NULL
-    f_code*: PPyCodeObject    # code segment
-    f_builtins*: PPyObject    # builtin symbol table (PyDictObject)
-    f_globals*: PPyObject     # global symbol table (PyDictObject)
-    f_locals*: PPyObject      # local symbol table (PyDictObject)
-    f_valuestack*: PPPyObject # points after the last local
-                              # Next free slot in f_valuestack. Frame creation sets to f_valuestack.
-                              # Frame evaluation usually NULLs it, but a frame that yields sets it
-                              # to the current stack top. 
-    f_stacktop*: PPPyObject
-    f_trace*: PPyObject       # Trace function
-    f_exc_type*, f_exc_value*, f_exc_traceback*: PPyObject
-    f_tstate*: PPyThreadState
-    f_lasti*: int             # Last instruction if called
-    f_lineno*: int            # Current line number
-    f_restricted*: int        # Flag set if restricted operations
-                              # in this scope
-    f_iblock*: int            # index in f_blockstack
-    f_blockstack*: array[CO_MAXBLOCKS, TPyTryBlock] # for try and loop blocks
-    f_nlocals*: int           # number of locals
-    f_ncells*: int
-    f_nfreevars*: int
-    f_stacksize*: int         # size of value stack
-    f_localsplus*: array[0..0, PPyObject] # locals+stack, dynamically sized
-  
-  PPyTraceBackObject* = ptr TPyTraceBackObject
-  TPyTraceBackObject* = object of TPyObject # Parse tree node interface
-    tb_next*: PPyTraceBackObject
-    tb_frame*: PPyFrameObject
-    tb_lasti*: int
-    tb_lineno*: int
-
-  PNode* = ptr Tnode
-  Tnode*{.final.} = object    # From weakrefobject.h
-    n_type*: int16
-    n_str*: cstring
-    n_lineno*: int16
-    n_nchildren*: int16
-    n_child*: PNode
-
-  PPyWeakReference* = ptr TPyWeakReference
-  TPyWeakReference* = object of TPyObject 
-    wr_object*: PPyObject
-    wr_callback*: PPyObject
-    hash*: int32
-    wr_prev*: PPyWeakReference
-    wr_next*: PPyWeakReference
-
-
-const                         
-  PyDateTime_DATE_DATASIZE* = 4 # # of bytes for year, month, and day
-  PyDateTime_TIME_DATASIZE* = 6 # # of bytes for hour, minute, second, and usecond
-  PyDateTime_DATETIME_DATASIZE* = 10 # # of bytes for year, month, 
-                                     # day, hour, minute, second, and usecond. 
-
-type 
-  TPyDateTime_Delta* = object of TPyObject
-    hashcode*: int            # -1 when unknown
-    days*: int                # -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS
-    seconds*: int             # 0 <= seconds < 24*3600 is invariant
-    microseconds*: int        # 0 <= microseconds < 1000000 is invariant
-  
-  PPyDateTime_Delta* = ptr TPyDateTime_Delta
-  TPyDateTime_TZInfo* = object of TPyObject # a pure abstract base clase
-  PPyDateTime_TZInfo* = ptr TPyDateTime_TZInfo 
-  TPyDateTime_BaseTZInfo* = object of TPyObject
-    hashcode*: int
-    hastzinfo*: bool          # boolean flag
-  
-  PPyDateTime_BaseTZInfo* = ptr TPyDateTime_BaseTZInfo 
-  TPyDateTime_BaseTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_TIME_DATASIZE), int8]
-
-  PPyDateTime_BaseTime* = ptr TPyDateTime_BaseTime
-  TPyDateTime_Time* = object of TPyDateTime_BaseTime # hastzinfo true
-    tzinfo*: PPyObject
-
-  PPyDateTime_Time* = ptr TPyDateTime_Time 
-  TPyDateTime_Date* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATE_DATASIZE), int8]
-
-  PPyDateTime_Date* = ptr TPyDateTime_Date 
-  TPyDateTime_BaseDateTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8]
-
-  PPyDateTime_BaseDateTime* = ptr TPyDateTime_BaseDateTime
-  TPyDateTime_DateTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8]
-    tzinfo*: PPyObject
-
-  PPyDateTime_DateTime* = ptr TPyDateTime_DateTime 
-
-#----------------------------------------------------#
-#                                                    #
-#         New exception classes                      #
-#                                                    #
-#----------------------------------------------------#
-
-#
-#  // Python's exceptions
-#  EPythonError   = object(Exception)
-#      EName: String;
-#      EValue: String;
-#  end;
-#  EPyExecError   = object(EPythonError)
-#  end;
-#
-#  // Standard exception classes of Python
-#
-#/// jah 29-sep-2000: updated for python 2.0
-#///                   base classes updated according python documentation
-#
-#{ Hierarchy of Python exceptions, Python 2.3, copied from <INSTALL>\Python\exceptions.c
-#
-#Exception\n\
-# |\n\
-# +-- SystemExit\n\
-# +-- StopIteration\n\
-# +-- StandardError\n\
-# |    |\n\
-# |    +-- KeyboardInterrupt\n\
-# |    +-- ImportError\n\
-# |    +-- EnvironmentError\n\
-# |    |    |\n\
-# |    |    +-- IOError\n\
-# |    |    +-- OSError\n\
-# |    |         |\n\
-# |    |         +-- WindowsError\n\
-# |    |         +-- VMSError\n\
-# |    |\n\
-# |    +-- EOFError\n\
-# |    +-- RuntimeError\n\
-# |    |    |\n\
-# |    |    +-- NotImplementedError\n\
-# |    |\n\
-# |    +-- NameError\n\
-# |    |    |\n\
-# |    |    +-- UnboundLocalError\n\
-# |    |\n\
-# |    +-- AttributeError\n\
-# |    +-- SyntaxError\n\
-# |    |    |\n\
-# |    |    +-- IndentationError\n\
-# |    |         |\n\
-# |    |         +-- TabError\n\
-# |    |\n\
-# |    +-- TypeError\n\
-# |    +-- AssertionError\n\
-# |    +-- LookupError\n\
-# |    |    |\n\
-# |    |    +-- IndexError\n\
-# |    |    +-- KeyError\n\
-# |    |\n\
-# |    +-- ArithmeticError\n\
-# |    |    |\n\
-# |    |    +-- OverflowError\n\
-# |    |    +-- ZeroDivisionError\n\
-# |    |    +-- FloatingPointError\n\
-# |    |\n\
-# |    +-- ValueError\n\
-# |    |    |\n\
-# |    |    +-- UnicodeError\n\
-# |    |        |\n\
-# |    |        +-- UnicodeEncodeError\n\
-# |    |        +-- UnicodeDecodeError\n\
-# |    |        +-- UnicodeTranslateError\n\
-# |    |\n\
-# |    +-- ReferenceError\n\
-# |    +-- SystemError\n\
-# |    +-- MemoryError\n\
-# |\n\
-# +---Warning\n\
-#      |\n\
-#      +-- UserWarning\n\
-#      +-- DeprecationWarning\n\
-#      +-- PendingDeprecationWarning\n\
-#      +-- SyntaxWarning\n\
-#      +-- OverflowWarning\n\
-#      +-- RuntimeWarning\n\
-#      +-- FutureWarning"
-#}
-#   EPyException = class (EPythonError);
-#   EPyStandardError = class (EPyException);
-#   EPyArithmeticError = class (EPyStandardError);
-#   EPyLookupError = class (EPyStandardError);
-#   EPyAssertionError = class (EPyStandardError);
-#   EPyAttributeError = class (EPyStandardError);
-#   EPyEOFError = class (EPyStandardError);
-#   EPyFloatingPointError = class (EPyArithmeticError);
-#   EPyEnvironmentError = class (EPyStandardError);
-#   EPyIOError = class (EPyEnvironmentError);
-#   EPyOSError = class (EPyEnvironmentError);
-#   EPyImportError = class (EPyStandardError);
-#   EPyIndexError = class (EPyLookupError);
-#   EPyKeyError = class (EPyLookupError);
-#   EPyKeyboardInterrupt = class (EPyStandardError);
-#   EPyMemoryError = class (EPyStandardError);
-#   EPyNameError = class (EPyStandardError);
-#   EPyOverflowError = class (EPyArithmeticError);
-#   EPyRuntimeError = class (EPyStandardError);
-#   EPyNotImplementedError = class (EPyRuntimeError);
-#   EPySyntaxError = class (EPyStandardError)
-#   public
-#      EFileName: string;
-#      ELineStr: string;
-#      ELineNumber: Integer;
-#      EOffset: Integer;
-#   end;
-#   EPyIndentationError = class (EPySyntaxError);
-#   EPyTabError = class (EPyIndentationError);
-#   EPySystemError = class (EPyStandardError);
-#   EPySystemExit = class (EPyException);
-#   EPyTypeError = class (EPyStandardError);
-#   EPyUnboundLocalError = class (EPyNameError);
-#   EPyValueError = class (EPyStandardError);
-#   EPyUnicodeError = class (EPyValueError);
-#   UnicodeEncodeError = class (EPyUnicodeError);
-#   UnicodeDecodeError = class (EPyUnicodeError);
-#   UnicodeTranslateError = class (EPyUnicodeError);
-#   EPyZeroDivisionError = class (EPyArithmeticError);
-#   EPyStopIteration = class(EPyException);
-#   EPyWarning = class (EPyException);
-#   EPyUserWarning = class (EPyWarning);
-#   EPyDeprecationWarning = class (EPyWarning);
-#   PendingDeprecationWarning = class (EPyWarning);
-#   FutureWarning = class (EPyWarning);
-#   EPySyntaxWarning = class (EPyWarning);
-#   EPyOverflowWarning = class (EPyWarning);
-#   EPyRuntimeWarning = class (EPyWarning);
-#   EPyReferenceError = class (EPyStandardError);
-#
-
-var 
-  PyArg_Parse*: proc (args: PPyObject, format: cstring): int{.cdecl, varargs.} 
-  PyArg_ParseTuple*: proc (args: PPyObject, format: cstring, x1: Pointer = nil, 
-                           x2: Pointer = nil, x3: Pointer = nil): int{.cdecl, varargs.} 
-  Py_BuildValue*: proc (format: cstring): PPyObject{.cdecl, varargs.} 
-  PyCode_Addr2Line*: proc (co: PPyCodeObject, addrq: int): int{.cdecl.}
-  DLL_Py_GetBuildInfo*: proc (): cstring{.cdecl.}
-
-var
-  Py_DebugFlag*: PInt
-  Py_VerboseFlag*: PInt
-  Py_InteractiveFlag*: PInt
-  Py_OptimizeFlag*: PInt
-  Py_NoSiteFlag*: PInt
-  Py_UseClassExceptionsFlag*: PInt
-  Py_FrozenFlag*: PInt
-  Py_TabcheckFlag*: PInt
-  Py_UnicodeFlag*: PInt
-  Py_IgnoreEnvironmentFlag*: PInt
-  Py_DivisionWarningFlag*: PInt 
-  #_PySys_TraceFunc:    PPPyObject;
-  #_PySys_ProfileFunc: PPPPyObject;
-  PyImport_FrozenModules*: PP_frozen
-  Py_None*: PPyObject
-  Py_Ellipsis*: PPyObject
-  Py_False*: PPyIntObject
-  Py_True*: PPyIntObject
-  Py_NotImplemented*: PPyObject
-  PyExc_AttributeError*: PPPyObject
-  PyExc_EOFError*: PPPyObject
-  PyExc_IOError*: PPPyObject
-  PyExc_ImportError*: PPPyObject
-  PyExc_IndexError*: PPPyObject
-  PyExc_KeyError*: PPPyObject
-  PyExc_KeyboardInterrupt*: PPPyObject
-  PyExc_MemoryError*: PPPyObject
-  PyExc_NameError*: PPPyObject
-  PyExc_OverflowError*: PPPyObject
-  PyExc_RuntimeError*: PPPyObject
-  PyExc_SyntaxError*: PPPyObject
-  PyExc_SystemError*: PPPyObject
-  PyExc_SystemExit*: PPPyObject
-  PyExc_TypeError*: PPPyObject
-  PyExc_ValueError*: PPPyObject
-  PyExc_ZeroDivisionError*: PPPyObject
-  PyExc_ArithmeticError*: PPPyObject
-  PyExc_Exception*: PPPyObject
-  PyExc_FloatingPointError*: PPPyObject
-  PyExc_LookupError*: PPPyObject
-  PyExc_StandardError*: PPPyObject
-  PyExc_AssertionError*: PPPyObject
-  PyExc_EnvironmentError*: PPPyObject
-  PyExc_IndentationError*: PPPyObject
-  PyExc_MemoryErrorInst*: PPPyObject
-  PyExc_NotImplementedError*: PPPyObject
-  PyExc_OSError*: PPPyObject
-  PyExc_TabError*: PPPyObject
-  PyExc_UnboundLocalError*: PPPyObject
-  PyExc_UnicodeError*: PPPyObject
-  PyExc_Warning*: PPPyObject
-  PyExc_DeprecationWarning*: PPPyObject
-  PyExc_RuntimeWarning*: PPPyObject
-  PyExc_SyntaxWarning*: PPPyObject
-  PyExc_UserWarning*: PPPyObject
-  PyExc_OverflowWarning*: PPPyObject
-  PyExc_ReferenceError*: PPPyObject
-  PyExc_StopIteration*: PPPyObject
-  PyExc_FutureWarning*: PPPyObject
-  PyExc_PendingDeprecationWarning*: PPPyObject
-  PyExc_UnicodeDecodeError*: PPPyObject
-  PyExc_UnicodeEncodeError*: PPPyObject
-  PyExc_UnicodeTranslateError*: PPPyObject
-  PyType_Type*: PPyTypeObject
-  PyCFunction_Type*: PPyTypeObject
-  PyCObject_Type*: PPyTypeObject
-  PyClass_Type*: PPyTypeObject
-  PyCode_Type*: PPyTypeObject
-  PyComplex_Type*: PPyTypeObject
-  PyDict_Type*: PPyTypeObject
-  PyFile_Type*: PPyTypeObject
-  PyFloat_Type*: PPyTypeObject
-  PyFrame_Type*: PPyTypeObject
-  PyFunction_Type*: PPyTypeObject
-  PyInstance_Type*: PPyTypeObject
-  PyInt_Type*: PPyTypeObject
-  PyList_Type*: PPyTypeObject
-  PyLong_Type*: PPyTypeObject
-  PyMethod_Type*: PPyTypeObject
-  PyModule_Type*: PPyTypeObject
-  PyObject_Type*: PPyTypeObject
-  PyRange_Type*: PPyTypeObject
-  PySlice_Type*: PPyTypeObject
-  PyString_Type*: PPyTypeObject
-  PyTuple_Type*: PPyTypeObject
-  PyBaseObject_Type*: PPyTypeObject
-  PyBuffer_Type*: PPyTypeObject
-  PyCallIter_Type*: PPyTypeObject
-  PyCell_Type*: PPyTypeObject
-  PyClassMethod_Type*: PPyTypeObject
-  PyProperty_Type*: PPyTypeObject
-  PySeqIter_Type*: PPyTypeObject
-  PyStaticMethod_Type*: PPyTypeObject
-  PySuper_Type*: PPyTypeObject
-  PySymtableEntry_Type*: PPyTypeObject
-  PyTraceBack_Type*: PPyTypeObject
-  PyUnicode_Type*: PPyTypeObject
-  PyWrapperDescr_Type*: PPyTypeObject
-  PyBaseString_Type*: PPyTypeObject
-  PyBool_Type*: PPyTypeObject
-  PyEnum_Type*: PPyTypeObject
-
-  #PyArg_GetObject: proc(args: PPyObject; nargs, i: integer; p_a: PPPyObject): integer; cdecl;
-  #PyArg_GetLong: proc(args: PPyObject; nargs, i: integer; p_a: PLong): integer; cdecl;
-  #PyArg_GetShort: proc(args: PPyObject; nargs, i: integer; p_a: PShort): integer; cdecl;
-  #PyArg_GetFloat: proc(args: PPyObject; nargs, i: integer; p_a: PFloat): integer; cdecl;
-  #PyArg_GetString: proc(args: PPyObject; nargs, i: integer; p_a: PString): integer; cdecl;
-  #PyArgs_VaParse:  proc (args: PPyObject; format: PChar; 
-  #                          va_list: array of const): integer; cdecl;
-  # Does not work!
-  # Py_VaBuildValue: proc (format: PChar; va_list: array of const): PPyObject; cdecl;
-  #PyBuiltin_Init: proc; cdecl;
-proc PyComplex_FromCComplex*(c: TPy_complex): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_FromDoubles*(realv, imag: float64): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_RealAsDouble*(op: PPyObject): float64{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_ImagAsDouble*(op: PPyObject): float64{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_AsCComplex*(op: PPyObject): TPy_complex{.cdecl, importc, dynlib: dllname.}
-proc PyCFunction_GetFunction*(ob: PPyObject): Pointer{.cdecl, importc, dynlib: dllname.}
-proc PyCFunction_GetSelf*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyCallable_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyCObject_FromVoidPtr*(cobj, destruct: Pointer): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyCObject_AsVoidPtr*(ob: PPyObject): Pointer{.cdecl, importc, dynlib: dllname.}
-proc PyClass_New*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyClass_IsSubclass*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc Py_InitModule4*(name: cstring, methods: PPyMethodDef, doc: cstring, 
-                         passthrough: PPyObject, Api_Version: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyErr_BadArgument*(): int{.cdecl, importc, dynlib: dllname.}
-proc PyErr_BadInternalCall*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_CheckSignals*(): int{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Clear*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_Fetch*(errtype, errvalue, errtraceback: PPPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_NoMemory*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Occurred*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Print*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_Restore*(errtype, errvalue, errtraceback: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetFromErrno*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetNone*(value: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetObject*(ob1, ob2: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetString*(ErrorObject: PPyObject, text: cstring){.cdecl, importc, dynlib: dllname.}
-proc PyImport_GetModuleDict*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyInt_FromLong*(x: int32): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc Py_Initialize*(){.cdecl, importc, dynlib: dllname.}
-proc Py_Exit*(RetVal: int){.cdecl, importc, dynlib: dllname.}
-proc PyEval_GetBuiltins*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_GetItem*(mp, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_SetItem*(mp, key, item: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_DelItem*(mp, key: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Clear*(mp: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyDict_Next*(mp: PPyObject, pos: PInt, key, value: PPPyObject): int{.
-      cdecl, importc, dynlib: dllname.}
-proc PyDict_Keys*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Values*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Items*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Size*(mp: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_DelItemString*(dp: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_New*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_GetItemString*(dp: PPyObject, key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_SetItemString*(dp: PPyObject, key: cstring, item: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}
-proc PyDictProxy_New*(obj: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyModule_GetDict*(module: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_Str*(v: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyRun_String*(str: cstring, start: int, globals: PPyObject, 
-                       locals: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyRun_SimpleString*(str: cstring): int{.cdecl, importc, dynlib: dllname.}
-proc PyString_AsString*(ob: PPyObject): cstring{.cdecl, importc, dynlib: dllname.}
-proc PyString_FromString*(str: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PySys_SetArgv*(argc: int, argv: cstringArray){.cdecl, importc, dynlib: dllname.} 
-  #+ means, Grzegorz or me has tested his non object version of this function
-  #+
-proc PyCFunction_New*(md: PPyMethodDef, ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyEval_CallObject*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_CallObjectWithKeywords*(ob1, ob2, ob3: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyEval_GetFrame*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetGlobals*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetLocals*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetOwner*(): PPyObject {.cdecl, importc, dynlib: dllname.}
-proc PyEval_GetRestricted*(): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_InitThreads*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_RestoreThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_SaveThread*(): PPyThreadState{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_FromString*(pc1, pc2: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_GetLine*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_Name*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_SetBufSize*(ob: PPyObject, i: int){.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_SoftSpace*(ob: PPyObject, i: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_WriteObject*(ob1, ob2: PPyObject, i: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_WriteString*(s: cstring, ob: PPyObject){.cdecl, importc, dynlib: dllname.} #+
-proc PyFloat_AsDouble*(ob: PPyObject): float64{.cdecl, importc, dynlib: dllname.} #+
-proc PyFloat_FromDouble*(db: float64): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_GetCode*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_GetGlobals*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_New*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_AddModule*(name: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_Cleanup*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_GetMagicNumber*(): int32{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_ImportFrozenModule*(key: cstring): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_ImportModule*(name: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_Import*(name: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-                                                               
-proc PyImport_Init*() {.cdecl, importc, dynlib: dllname.}
-proc PyImport_ReloadModule*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyInstance_New*(obClass, obArg, obKW: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyInt_AsLong*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Append*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_AsTuple*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyList_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Insert*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Reverse*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_SetItem*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_SetSlice*(ob: PPyObject, i1, i2: int, ob2: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #+
-proc PyList_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Sort*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsDouble*(ob: PPyObject): float64{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_AsLong*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_FromDouble*(db: float64): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_FromLong*(L: int32): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromString*(pc: cstring, ppc: var cstring, i: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyLong_FromUnsignedLong*(val: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsUnsignedLong*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromUnicode*(ob: PPyObject, a, b: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromLongLong*(val: Int64): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsLongLong*(ob: PPyObject): Int64{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_GetItemString*(ob: PPyObject, key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_HasKey*(ob, key: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_HasKeyString*(ob: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_SetItemString*(ob: PPyObject, key: cstring, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyMethod_Class*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_Function*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_New*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_Self*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyModule_GetName*(ob: PPyObject): cstring{.cdecl, importc, dynlib: dllname.} #-
-proc PyModule_New*(key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Absolute*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Add*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_And*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Coerce*(ob1, ob2: var PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Divide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_FloorDivide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_TrueDivide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Divmod*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Float*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Int*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Invert*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Long*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Lshift*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Multiply*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Negative*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Or*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Positive*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Power*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Remainder*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Rshift*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Subtract*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Xor*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyOS_InitInterrupts*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyOS_InterruptOccurred*(): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_CallObject*(ob, args: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Compare*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GetAttr*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyObject_GetAttrString*(ob: PPyObject, c: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GetItem*(ob, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_DelItem*(ob, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_HasAttrString*(ob: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Hash*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsTrue*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Repr*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_SetAttr*(ob1, ob2, ob3: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_SetAttrString*(ob: PPyObject, key: cstring, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyObject_SetItem*(ob1, ob2, ob3: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Init*(ob: PPyObject, t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_InitVar*(ob: PPyObject, t: PPyTypeObject, size: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyObject_New*(t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_NewVar*(t: PPyTypeObject, size: int): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_Free*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsInstance*(inst, cls: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsSubclass*(derived, cls: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyObject_GenericGetAttr*(obj, name: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_GenericSetAttr*(obj, name, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Malloc*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_New*(t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_NewVar*(t: PPyTypeObject, size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Resize*(t: PPyObject, newsize: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Del*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Track*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_UnTrack*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyRange_New*(l1, l2, l3: int32, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Concat*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Count*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_In*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Index*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Repeat*(ob: PPyObject, count: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_SetItem*(ob: PPyObject, i: int, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySequence_SetSlice*(ob: PPyObject, i1, i2: int, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySequence_DelSlice*(ob: PPyObject, i1, i2: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Tuple*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Contains*(ob, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySlice_GetIndices*(ob: PPySliceObject, len: int, 
-                             start, stop, step: var int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySlice_GetIndicesEx*(ob: PPySliceObject, len: int, 
-                               start, stop, step, slicelength: var int): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySlice_New*(start, stop, step: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Concat*(ob1: var PPyObject, ob2: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyString_ConcatAndDel*(ob1: var PPyObject, ob2: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Format*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_FromStringAndSize*(s: cstring, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_DecodeEscape*(s: cstring, length: int, errors: cstring, 
-                                unicode: int, recode_encoding: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyString_Repr*(ob: PPyObject, smartquotes: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PySys_GetObject*(s: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} 
-#-
-#PySys_Init:procedure; cdecl, importc, dynlib: dllname;
-#-
-proc PySys_SetObject*(s: cstring, ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySys_SetPath*(path: cstring){.cdecl, importc, dynlib: dllname.} #-
-#PyTraceBack_Fetch:function:PPyObject; cdecl, importc, dynlib: dllname;
-#-
-proc PyTraceBack_Here*(p: pointer): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyTraceBack_Print*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-#PyTraceBack_Store:function (ob:PPyObject):integer; cdecl, importc, dynlib: dllname;
-#+
-proc PyTuple_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyTuple_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_SetItem*(ob: PPyObject, key: int, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyType_IsSubtype*(a, b: PPyTypeObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyType_GenericAlloc*(atype: PPyTypeObject, nitems: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyType_GenericNew*(atype: PPyTypeObject, args, kwds: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyType_Ready*(atype: PPyTypeObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyUnicode_FromWideChar*(w: pointer, size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyUnicode_AsWideChar*(unicode: PPyObject, w: pointer, size: int): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyUnicode_FromOrdinal*(ordinal: int): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_GetObject*(theRef: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_NewProxy*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_NewRef*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWrapper_New*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyBool_FromLong*(ok: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc Py_AtExit*(prc: proc ()): int{.cdecl, importc, dynlib: dllname.} #-
-#Py_Cleanup:procedure; cdecl, importc, dynlib: dllname;
-#-
-proc Py_CompileString*(s1, s2: cstring, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc Py_FatalError*(s: cstring){.cdecl, importc, dynlib: dllname.} #-
-proc Py_FindMethod*(md: PPyMethodDef, ob: PPyObject, key: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_FindMethodInChain*(mc: PPyMethodChain, ob: PPyObject, key: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_FlushLine*(){.cdecl, importc, dynlib: dllname.} #+
-proc Py_Finalize*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_ExceptionMatches*(exc: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_GivenExceptionMatches*(raised_exc, exc: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_EvalCode*(co: PPyCodeObject, globals, locals: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #+
-proc Py_GetVersion*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetCopyright*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetExecPrefix*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetPath*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetPrefix*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetProgramName*(): cstring{.cdecl, importc, dynlib: dllname.} #-
-proc PyParser_SimpleParseString*(str: cstring, start: int): PNode{.cdecl, importc, dynlib: dllname.} #-
-proc PyNode_Free*(n: PNode){.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_NewException*(name: cstring, base, dict: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_Malloc*(size: int): Pointer {.cdecl, importc, dynlib: dllname.}
-proc PyMem_Malloc*(size: int): Pointer {.cdecl, importc, dynlib: dllname.}
-proc PyObject_CallMethod*(obj: PPyObject, theMethod, 
-                              format: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc Py_SetProgramName*(name: cstring){.cdecl, importc, dynlib: dllname.}
-proc Py_IsInitialized*(): int{.cdecl, importc, dynlib: dllname.}
-proc Py_GetProgramFullPath*(): cstring{.cdecl, importc, dynlib: dllname.}
-proc Py_NewInterpreter*(): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc Py_EndInterpreter*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyEval_AcquireLock*(){.cdecl, importc, dynlib: dllname.}
-proc PyEval_ReleaseLock*(){.cdecl, importc, dynlib: dllname.}
-proc PyEval_AcquireThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyEval_ReleaseThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_New*(): PPyInterpreterState{.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_Clear*(interp: PPyInterpreterState){.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_Delete*(interp: PPyInterpreterState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_New*(interp: PPyInterpreterState): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Clear*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Delete*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Get*(): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Swap*(tstate: PPyThreadState): PPyThreadState{.cdecl, importc, dynlib: dllname.} 
-
-#Further exported Objects, may be implemented later
-#
-#    PyCode_New: Pointer;
-#    PyErr_SetInterrupt: Pointer;
-#    PyFile_AsFile: Pointer;
-#    PyFile_FromFile: Pointer;
-#    PyFloat_AsString: Pointer;
-#    PyFrame_BlockPop: Pointer;
-#    PyFrame_BlockSetup: Pointer;
-#    PyFrame_ExtendStack: Pointer;
-#    PyFrame_FastToLocals: Pointer;
-#    PyFrame_LocalsToFast: Pointer;
-#    PyFrame_New: Pointer;
-#    PyGrammar_AddAccelerators: Pointer;
-#    PyGrammar_FindDFA: Pointer;
-#    PyGrammar_LabelRepr: Pointer;
-#    PyInstance_DoBinOp: Pointer;
-#    PyInt_GetMax: Pointer;
-#    PyMarshal_Init: Pointer;
-#    PyMarshal_ReadLongFromFile: Pointer;
-#    PyMarshal_ReadObjectFromFile: Pointer;
-#    PyMarshal_ReadObjectFromString: Pointer;
-#    PyMarshal_WriteLongToFile: Pointer;
-#    PyMarshal_WriteObjectToFile: Pointer;
-#    PyMember_Get: Pointer;
-#    PyMember_Set: Pointer;
-#    PyNode_AddChild: Pointer;
-#    PyNode_Compile: Pointer;
-#    PyNode_New: Pointer;
-#    PyOS_GetLastModificationTime: Pointer;
-#    PyOS_Readline: Pointer;
-#    PyOS_strtol: Pointer;
-#    PyOS_strtoul: Pointer;
-#    PyObject_CallFunction: Pointer;
-#    PyObject_CallMethod: Pointer;
-#    PyObject_Print: Pointer;
-#    PyParser_AddToken: Pointer;
-#    PyParser_Delete: Pointer;
-#    PyParser_New: Pointer;
-#    PyParser_ParseFile: Pointer;
-#    PyParser_ParseString: Pointer;
-#    PyParser_SimpleParseFile: Pointer;
-#    PyRun_AnyFile: Pointer;
-#    PyRun_File: Pointer;
-#    PyRun_InteractiveLoop: Pointer;
-#    PyRun_InteractiveOne: Pointer;
-#    PyRun_SimpleFile: Pointer;
-#    PySys_GetFile: Pointer;
-#    PyToken_OneChar: Pointer;
-#    PyToken_TwoChars: Pointer;
-#    PyTokenizer_Free: Pointer;
-#    PyTokenizer_FromFile: Pointer;
-#    PyTokenizer_FromString: Pointer;
-#    PyTokenizer_Get: Pointer;
-#    Py_Main: Pointer;
-#    _PyObject_NewVar: Pointer;
-#    _PyParser_Grammar: Pointer;
-#    _PyParser_TokenNames: Pointer;
-#    _PyThread_Started: Pointer;
-#    _Py_c_diff: Pointer;
-#    _Py_c_neg: Pointer;
-#    _Py_c_pow: Pointer;
-#    _Py_c_prod: Pointer;
-#    _Py_c_quot: Pointer;
-#    _Py_c_sum: Pointer;
-#
-
-# This function handles all cardinals, pointer types (with no adjustment of pointers!)
-# (Extended) floats, which are handled as Python doubles and currencies, handled
-# as (normalized) Python doubles.
-proc PyImport_ExecCodeModule*(name: String, codeobject: PPyObject): PPyObject
-proc PyString_Check*(obj: PPyObject): bool
-proc PyString_CheckExact*(obj: PPyObject): bool
-proc PyFloat_Check*(obj: PPyObject): bool
-proc PyFloat_CheckExact*(obj: PPyObject): bool
-proc PyInt_Check*(obj: PPyObject): bool
-proc PyInt_CheckExact*(obj: PPyObject): bool
-proc PyLong_Check*(obj: PPyObject): bool
-proc PyLong_CheckExact*(obj: PPyObject): bool
-proc PyTuple_Check*(obj: PPyObject): bool
-proc PyTuple_CheckExact*(obj: PPyObject): bool
-proc PyInstance_Check*(obj: PPyObject): bool
-proc PyClass_Check*(obj: PPyObject): bool
-proc PyMethod_Check*(obj: PPyObject): bool
-proc PyList_Check*(obj: PPyObject): bool
-proc PyList_CheckExact*(obj: PPyObject): bool
-proc PyDict_Check*(obj: PPyObject): bool
-proc PyDict_CheckExact*(obj: PPyObject): bool
-proc PyModule_Check*(obj: PPyObject): bool
-proc PyModule_CheckExact*(obj: PPyObject): bool
-proc PySlice_Check*(obj: PPyObject): bool
-proc PyFunction_Check*(obj: PPyObject): bool
-proc PyUnicode_Check*(obj: PPyObject): bool
-proc PyUnicode_CheckExact*(obj: PPyObject): bool
-proc PyType_IS_GC*(t: PPyTypeObject): bool
-proc PyObject_IS_GC*(obj: PPyObject): bool
-proc PyBool_Check*(obj: PPyObject): bool
-proc PyBaseString_Check*(obj: PPyObject): bool
-proc PyEnum_Check*(obj: PPyObject): bool
-proc PyObject_TypeCheck*(obj: PPyObject, t: PPyTypeObject): bool
-proc Py_InitModule*(name: cstring, md: PPyMethodDef): PPyObject
-proc PyType_HasFeature*(AType: PPyTypeObject, AFlag: int): bool
-# implementation
-
-proc Py_INCREF*(op: PPyObject) {.inline.} = 
-  Inc(op.ob_refcnt)
-
-proc Py_DECREF*(op: PPyObject) {.inline.} = 
-  Dec(op.ob_refcnt)
-  if op.ob_refcnt == 0: 
-    op.ob_type.tp_dealloc(op)
-
-proc Py_XINCREF*(op: PPyObject) {.inline.} = 
-  if op != nil: Py_INCREF(op)
-  
-proc Py_XDECREF*(op: PPyObject) {.inline.} = 
-  if op != nil: Py_DECREF(op)
-  
-proc PyImport_ExecCodeModule(name: string, codeobject: PPyObject): PPyObject = 
-  var m, d, v, modules: PPyObject
-  m = PyImport_AddModule(cstring(name))
-  if m == nil: 
-    return nil
-  d = PyModule_GetDict(m)
-  if PyDict_GetItemString(d, "__builtins__") == nil: 
-    if PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()) != 0: 
-      return nil
-  if PyDict_SetItemString(d, "__file__", 
-                          PPyCodeObject(codeobject).co_filename) != 0: 
-    PyErr_Clear() # Not important enough to report
-  v = PyEval_EvalCode(PPyCodeObject(codeobject), d, d) # XXX owner ?
-  if v == nil: 
-    return nil
-  Py_XDECREF(v)
-  modules = PyImport_GetModuleDict()
-  if PyDict_GetItemString(modules, cstring(name)) == nil: 
-    PyErr_SetString(PyExc_ImportError^ , cstring(
-        "Loaded module " & name & "not found in sys.modules"))
-    return nil
-  Py_XINCREF(m)
-  Result = m
-
-proc PyString_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyString_Type)
-
-proc PyString_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyString_Type)
-
-proc PyFloat_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyFloat_Type)
-
-proc PyFloat_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyFloat_Type)
-
-proc PyInt_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyInt_Type)
-
-proc PyInt_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyInt_Type)
-
-proc PyLong_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyLong_Type)
-
-proc PyLong_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyLong_Type)
-
-proc PyTuple_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyTuple_Type)
-
-proc PyTuple_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyTuple_Type)
-
-proc PyInstance_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyInstance_Type)
-
-proc PyClass_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyClass_Type)
-
-proc PyMethod_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyMethod_Type)
-
-proc PyList_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyList_Type)
-
-proc PyList_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyList_Type)
-
-proc PyDict_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyDict_Type)
-
-proc PyDict_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyDict_Type)
-
-proc PyModule_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyModule_Type)
-
-proc PyModule_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyModule_Type)
-
-proc PySlice_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PySlice_Type)
-
-proc PyFunction_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and
-      ((obj.ob_type == PyCFunction_Type) or
-      (obj.ob_type == PyFunction_Type))
-
-proc PyUnicode_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyUnicode_Type)
-
-proc PyUnicode_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyUnicode_Type)
-
-proc PyType_IS_GC(t: PPyTypeObject): bool = 
-  Result = PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC)
-
-proc PyObject_IS_GC(obj: PPyObject): bool = 
-  Result = PyType_IS_GC(obj.ob_type) and
-      ((obj.ob_type.tp_is_gc == nil) or (obj.ob_type.tp_is_gc(obj) == 1))
-
-proc PyBool_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyBool_Type)
-
-proc PyBaseString_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyBaseString_Type)
-
-proc PyEnum_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyEnum_Type)
-
-proc PyObject_TypeCheck(obj: PPyObject, t: PPyTypeObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == t)
-  if not Result and (obj != nil) and (t != nil): 
-    Result = PyType_IsSubtype(obj.ob_type, t) == 1
-  
-proc Py_InitModule(name: cstring, md: PPyMethodDef): PPyObject = 
-  result = Py_InitModule4(name, md, nil, nil, 1012)
-
-proc PyType_HasFeature(AType: PPyTypeObject, AFlag: int): bool = 
-  #(((t)->tp_flags & (f)) != 0)
-  Result = (AType.tp_flags and AFlag) != 0
-
-proc init(lib: TLibHandle) = 
-  Py_DebugFlag = cast[PInt](symAddr(lib, "Py_DebugFlag"))
-  Py_VerboseFlag = cast[PInt](symAddr(lib, "Py_VerboseFlag"))
-  Py_InteractiveFlag = cast[PInt](symAddr(lib, "Py_InteractiveFlag"))
-  Py_OptimizeFlag = cast[PInt](symAddr(lib, "Py_OptimizeFlag"))
-  Py_NoSiteFlag = cast[PInt](symAddr(lib, "Py_NoSiteFlag"))
-  Py_UseClassExceptionsFlag = cast[PInt](symAddr(lib, "Py_UseClassExceptionsFlag"))
-  Py_FrozenFlag = cast[PInt](symAddr(lib, "Py_FrozenFlag"))
-  Py_TabcheckFlag = cast[PInt](symAddr(lib, "Py_TabcheckFlag"))
-  Py_UnicodeFlag = cast[PInt](symAddr(lib, "Py_UnicodeFlag"))
-  Py_IgnoreEnvironmentFlag = cast[PInt](symAddr(lib, "Py_IgnoreEnvironmentFlag"))
-  Py_DivisionWarningFlag = cast[PInt](symAddr(lib, "Py_DivisionWarningFlag"))
-  Py_None = cast[PPyObject](symAddr(lib, "_Py_NoneStruct"))
-  Py_Ellipsis = cast[PPyObject](symAddr(lib, "_Py_EllipsisObject"))
-  Py_False = cast[PPyIntObject](symAddr(lib, "_Py_ZeroStruct"))
-  Py_True = cast[PPyIntObject](symAddr(lib, "_Py_TrueStruct"))
-  Py_NotImplemented = cast[PPyObject](symAddr(lib, "_Py_NotImplementedStruct"))
-  PyImport_FrozenModules = cast[PP_frozen](symAddr(lib, "PyImport_FrozenModules"))
-  PyExc_AttributeError = cast[PPPyObject](symAddr(lib, "PyExc_AttributeError"))
-  PyExc_EOFError = cast[PPPyObject](symAddr(lib, "PyExc_EOFError"))
-  PyExc_IOError = cast[PPPyObject](symAddr(lib, "PyExc_IOError"))
-  PyExc_ImportError = cast[PPPyObject](symAddr(lib, "PyExc_ImportError"))
-  PyExc_IndexError = cast[PPPyObject](symAddr(lib, "PyExc_IndexError"))
-  PyExc_KeyError = cast[PPPyObject](symAddr(lib, "PyExc_KeyError"))
-  PyExc_KeyboardInterrupt = cast[PPPyObject](symAddr(lib, "PyExc_KeyboardInterrupt"))
-  PyExc_MemoryError = cast[PPPyObject](symAddr(lib, "PyExc_MemoryError"))
-  PyExc_NameError = cast[PPPyObject](symAddr(lib, "PyExc_NameError"))
-  PyExc_OverflowError = cast[PPPyObject](symAddr(lib, "PyExc_OverflowError"))
-  PyExc_RuntimeError = cast[PPPyObject](symAddr(lib, "PyExc_RuntimeError"))
-  PyExc_SyntaxError = cast[PPPyObject](symAddr(lib, "PyExc_SyntaxError"))
-  PyExc_SystemError = cast[PPPyObject](symAddr(lib, "PyExc_SystemError"))
-  PyExc_SystemExit = cast[PPPyObject](symAddr(lib, "PyExc_SystemExit"))
-  PyExc_TypeError = cast[PPPyObject](symAddr(lib, "PyExc_TypeError"))
-  PyExc_ValueError = cast[PPPyObject](symAddr(lib, "PyExc_ValueError"))
-  PyExc_ZeroDivisionError = cast[PPPyObject](symAddr(lib, "PyExc_ZeroDivisionError"))
-  PyExc_ArithmeticError = cast[PPPyObject](symAddr(lib, "PyExc_ArithmeticError"))
-  PyExc_Exception = cast[PPPyObject](symAddr(lib, "PyExc_Exception"))
-  PyExc_FloatingPointError = cast[PPPyObject](symAddr(lib, "PyExc_FloatingPointError"))
-  PyExc_LookupError = cast[PPPyObject](symAddr(lib, "PyExc_LookupError"))
-  PyExc_StandardError = cast[PPPyObject](symAddr(lib, "PyExc_StandardError"))
-  PyExc_AssertionError = cast[PPPyObject](symAddr(lib, "PyExc_AssertionError"))
-  PyExc_EnvironmentError = cast[PPPyObject](symAddr(lib, "PyExc_EnvironmentError"))
-  PyExc_IndentationError = cast[PPPyObject](symAddr(lib, "PyExc_IndentationError"))
-  PyExc_MemoryErrorInst = cast[PPPyObject](symAddr(lib, "PyExc_MemoryErrorInst"))
-  PyExc_NotImplementedError = cast[PPPyObject](symAddr(lib, "PyExc_NotImplementedError"))
-  PyExc_OSError = cast[PPPyObject](symAddr(lib, "PyExc_OSError"))
-  PyExc_TabError = cast[PPPyObject](symAddr(lib, "PyExc_TabError"))
-  PyExc_UnboundLocalError = cast[PPPyObject](symAddr(lib, "PyExc_UnboundLocalError"))
-  PyExc_UnicodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeError"))
-  PyExc_Warning = cast[PPPyObject](symAddr(lib, "PyExc_Warning"))
-  PyExc_DeprecationWarning = cast[PPPyObject](symAddr(lib, "PyExc_DeprecationWarning"))
-  PyExc_RuntimeWarning = cast[PPPyObject](symAddr(lib, "PyExc_RuntimeWarning"))
-  PyExc_SyntaxWarning = cast[PPPyObject](symAddr(lib, "PyExc_SyntaxWarning"))
-  PyExc_UserWarning = cast[PPPyObject](symAddr(lib, "PyExc_UserWarning"))
-  PyExc_OverflowWarning = cast[PPPyObject](symAddr(lib, "PyExc_OverflowWarning"))
-  PyExc_ReferenceError = cast[PPPyObject](symAddr(lib, "PyExc_ReferenceError"))
-  PyExc_StopIteration = cast[PPPyObject](symAddr(lib, "PyExc_StopIteration"))
-  PyExc_FutureWarning = cast[PPPyObject](symAddr(lib, "PyExc_FutureWarning"))
-  PyExc_PendingDeprecationWarning = cast[PPPyObject](symAddr(lib, 
-      "PyExc_PendingDeprecationWarning"))
-  PyExc_UnicodeDecodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeDecodeError"))
-  PyExc_UnicodeEncodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeEncodeError"))
-  PyExc_UnicodeTranslateError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeTranslateError"))
-  PyType_Type = cast[PPyTypeObject](symAddr(lib, "PyType_Type"))
-  PyCFunction_Type = cast[PPyTypeObject](symAddr(lib, "PyCFunction_Type"))
-  PyCObject_Type = cast[PPyTypeObject](symAddr(lib, "PyCObject_Type"))
-  PyClass_Type = cast[PPyTypeObject](symAddr(lib, "PyClass_Type"))
-  PyCode_Type = cast[PPyTypeObject](symAddr(lib, "PyCode_Type"))
-  PyComplex_Type = cast[PPyTypeObject](symAddr(lib, "PyComplex_Type"))
-  PyDict_Type = cast[PPyTypeObject](symAddr(lib, "PyDict_Type"))
-  PyFile_Type = cast[PPyTypeObject](symAddr(lib, "PyFile_Type"))
-  PyFloat_Type = cast[PPyTypeObject](symAddr(lib, "PyFloat_Type"))
-  PyFrame_Type = cast[PPyTypeObject](symAddr(lib, "PyFrame_Type"))
-  PyFunction_Type = cast[PPyTypeObject](symAddr(lib, "PyFunction_Type"))
-  PyInstance_Type = cast[PPyTypeObject](symAddr(lib, "PyInstance_Type"))
-  PyInt_Type = cast[PPyTypeObject](symAddr(lib, "PyInt_Type"))
-  PyList_Type = cast[PPyTypeObject](symAddr(lib, "PyList_Type"))
-  PyLong_Type = cast[PPyTypeObject](symAddr(lib, "PyLong_Type"))
-  PyMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyMethod_Type"))
-  PyModule_Type = cast[PPyTypeObject](symAddr(lib, "PyModule_Type"))
-  PyObject_Type = cast[PPyTypeObject](symAddr(lib, "PyObject_Type"))
-  PyRange_Type = cast[PPyTypeObject](symAddr(lib, "PyRange_Type"))
-  PySlice_Type = cast[PPyTypeObject](symAddr(lib, "PySlice_Type"))
-  PyString_Type = cast[PPyTypeObject](symAddr(lib, "PyString_Type"))
-  PyTuple_Type = cast[PPyTypeObject](symAddr(lib, "PyTuple_Type"))
-  PyUnicode_Type = cast[PPyTypeObject](symAddr(lib, "PyUnicode_Type"))
-  PyBaseObject_Type = cast[PPyTypeObject](symAddr(lib, "PyBaseObject_Type"))
-  PyBuffer_Type = cast[PPyTypeObject](symAddr(lib, "PyBuffer_Type"))
-  PyCallIter_Type = cast[PPyTypeObject](symAddr(lib, "PyCallIter_Type"))
-  PyCell_Type = cast[PPyTypeObject](symAddr(lib, "PyCell_Type"))
-  PyClassMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyClassMethod_Type"))
-  PyProperty_Type = cast[PPyTypeObject](symAddr(lib, "PyProperty_Type"))
-  PySeqIter_Type = cast[PPyTypeObject](symAddr(lib, "PySeqIter_Type"))
-  PyStaticMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyStaticMethod_Type"))
-  PySuper_Type = cast[PPyTypeObject](symAddr(lib, "PySuper_Type"))
-  PySymtableEntry_Type = cast[PPyTypeObject](symAddr(lib, "PySymtableEntry_Type"))
-  PyTraceBack_Type = cast[PPyTypeObject](symAddr(lib, "PyTraceBack_Type"))
-  PyWrapperDescr_Type = cast[PPyTypeObject](symAddr(lib, "PyWrapperDescr_Type"))
-  PyBaseString_Type = cast[PPyTypeObject](symAddr(lib, "PyBaseString_Type"))
-  PyBool_Type = cast[PPyTypeObject](symAddr(lib, "PyBool_Type"))
-  PyEnum_Type = cast[PPyTypeObject](symAddr(lib, "PyEnum_Type"))
-
-# Unfortunately we have to duplicate the loading mechanism here, because Nimrod
-# does not support variables from dynamic libraries. Well designed API's don't
-# require this anyway. Python is an exception.
-
-var
-  lib: TLibHandle
-
-when defined(windows): 
-  const
-    LibNames = ["python26.dll", "python25.dll", 
-      "python24.dll", "python23.dll", "python22.dll", "python21.dll", 
-      "python20.dll", "python16.dll", "python15.dll"]
-elif defined(macosx):
-  const
-    LibNames = ["libpython2.6.dylib", "libpython2.5.dylib", 
-      "libpython2.4.dylib", "libpython2.3.dylib", "libpython2.2.dylib", 
-      "libpython2.1.dylib", "libpython2.0.dylib",
-      "libpython1.6.dylib", "libpython1.5.dylib"]
-else: 
-  const
-    LibNames = ["libpython2.6.so" & dllver, 
-      "libpython2.5.so" & dllver, 
-      "libpython2.4.so" & dllver, 
-      "libpython2.3.so" & dllver, 
-      "libpython2.2.so" & dllver, 
-      "libpython2.1.so" & dllver, 
-      "libpython2.0.so" & dllver,
-      "libpython1.6.so" & dllver, 
-      "libpython1.5.so" & dllver]
-  
-for libName in items(libNames): 
-  lib = loadLib(libName)
-  if lib != nil: break
-
-if lib == nil: quit("could not load python library")
-init(lib)
-
diff --git a/lib/oldwrappers/sdl/sdl.nim b/lib/oldwrappers/sdl/sdl.nim
deleted file mode 100755
index 7d2b6ba26..000000000
--- a/lib/oldwrappers/sdl/sdl.nim
+++ /dev/null
@@ -1,2522 +0,0 @@
-
-#******************************************************************************
-#
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
-#             Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997-2004  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL.h
-#                          SDL_main.h
-#                          SDL_types.h
-#                          SDL_rwops.h
-#                          SDL_timer.h
-#                          SDL_audio.h
-#                          SDL_cdrom.h
-#                          SDL_joystick.h
-#                          SDL_mouse.h
-#                          SDL_keyboard.h
-#                          SDL_events.h
-#                          SDL_video.h
-#                          SDL_byteorder.h
-#                          SDL_version.h
-#                          SDL_active.h
-#                          SDL_thread.h
-#                          SDL_mutex .h
-#                          SDL_getenv.h
-#                          SDL_loadso.h
-#
-# The initial developer of this Pascal code was :
-# Dominique Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominique Louis are
-# Copyright (C) 2000 - 2004 Dominique Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so
-#   They are available from...
-#   http://www.libsdl.org .
-#
-# Programming Notes
-# -----------------
-#
-#
-#
-#
-# Revision History
-# ----------------
-#   May      08 2001 - DL : Added Keyboard  State Array ( See demos for how to
-#                           use )
-#                           PKeyStateArr = ^TKeyStateArr;
-#                           TKeyStateArr = array[0..65000] of UInt8;
-#                           As most games will need it.
-#
-#   April    02 2001 - DL : Added SDL_getenv.h definitions and tested version
-#                           1.2.0 compatability.
-#
-#   March    13 2001 - MT : Added Linux compatibility.
-#
-#   March    10 2001 - MT : Added externalsyms for DEFINES
-#                           Changed the license header
-#
-#   March    09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem
-#
-#   March    01 2001 - DL : Update conversion of version 1.1.8
-#
-#   July     22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions
-#                           from Matthias Thoma and Eric Grange.
-#
-#   October  12 2001 - DL : Various changes as suggested by Matthias Thoma and
-#                           David Acklam
-#
-#   October  24 2001 - DL : Added FreePascal support as per suggestions from
-#                           Dean Ellis.
-#
-#   October  27 2001 - DL : Added SDL_BUTTON macro
-#
-#  November  08 2001 - DL : Bug fix as pointed out by Puthoon.
-#
-#  November  29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon
-#                           Rushton.
-#
-#  November  30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton.
-#
-#  December  11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in
-#                           Components
-#
-#  January   05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias
-#                           Thoma and also made sure the _getenv from
-#                           MSVCRT.DLL uses the right calling convention
-#
-#  January   25 2002 - DL : Updated conversion of SDL_AddTimer &
-#                           SDL_RemoveTimer as per suggestions from Matthias
-#                           Thoma.
-#
-#  January   27 2002 - DL : Commented out exported function putenv and getenv
-#                           So that developers get used to using SDL_putenv
-#                           SDL_getenv, as they are more portable
-#
-#  March     05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users.
-#
-#  October   23 2002 - DL : Added Delphi 3 Define of Win32.
-#                           If you intend to you Delphi 3...
-#                           ( which is officially unsupported ) make sure you
-#                           remove references to $EXTERNALSYM in this and other
-#                           SDL files.
-#
-# November  29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was
-#                          pointed out by Todd Lang
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#
-#  Revision 1.31  2007/05/29 21:30:48  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.30  2007/05/29 19:31:03  savage
-#  Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold)
-#
-#  Revision 1.29  2007/05/20 20:29:11  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.26  2007/02/11 13:38:04  savage
-#  Added Nintendo DS support - Thanks Dean.
-#
-#  Revision 1.25  2006/12/02 00:12:52  savage
-#  Updated to latest version
-#
-#  Revision 1.24  2006/05/18 21:10:04  savage
-#  Added 1.2.10 Changes
-#
-#  Revision 1.23  2005/12/04 23:17:52  drellis
-#  Added declaration of SInt8 and PSInt8
-#
-#  Revision 1.22  2005/05/24 21:59:03  savage
-#  Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis.
-#
-#  Revision 1.21  2005/05/22 18:42:31  savage
-#  Changes as suggested by Michalis Kamburelis. Thanks again.
-#
-#  Revision 1.20  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.19  2005/01/05 01:47:06  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.18  2005/01/04 23:14:41  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.17  2005/01/03 18:40:59  savage
-#  Updated Version number to reflect latest one
-#
-#  Revision 1.16  2005/01/01 02:02:06  savage
-#  Updated to v1.2.8
-#
-#  Revision 1.15  2004/12/24 18:57:11  savage
-#  forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
-#
-#  Revision 1.14  2004/12/23 23:42:18  savage
-#  Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
-#
-#  Revision 1.13  2004/09/30 22:31:59  savage
-#  Updated with slightly different header comments
-#
-#  Revision 1.12  2004/09/12 21:52:58  savage
-#  Slight changes to fix some issues with the sdl classes.
-#
-#  Revision 1.11  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.10  2004/07/20 23:57:33  savage
-#  Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
-#  In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
-#
-#  Revision 1.9  2004/07/03 22:07:22  savage
-#  Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
-#
-#  Revision 1.8  2004/05/10 14:10:03  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.7  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.6  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.5  2004/02/22 15:32:10  savage
-#  SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
-#
-#  Revision 1.4  2004/02/21 23:24:29  savage
-#  SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
-#
-#  Revision 1.3  2004/02/18 22:35:51  savage
-#  Brought sdl.pas up to 1.2.7 compatability
-#  Thus...
-#  Added SDL_GL_STEREO,
-#      SDL_GL_MULTISAMPLEBUFFERS,
-#      SDL_GL_MULTISAMPLESAMPLES
-#
-#  Add DLL/Shared object functions
-#  function SDL_LoadObject( const sofile : PChar ) : Pointer;
-#
-#  function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
-#
-#  procedure SDL_UnloadObject( handle : Pointer );
-#
-#  Added function to create RWops from const memory: SDL_RWFromConstMem()
-#  function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
-#
-#  Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
-#
-#  Revision 1.2  2004/02/17 21:37:12  savage
-#  Tidying up of units
-#
-#  Revision 1.1  2004/02/05 00:08:20  savage
-#  Module 1.0 release
-#
-#
-
-{.deadCodeElim: on.}
-
-when defined(windows):
-  const SDLLibName = "SDL.dll"
-elif defined(macosx):
-  const SDLLibName = "libSDL-1.2.0.dylib"
-else:
-  const SDLLibName = "libSDL.so"
-
-const
-  SDL_MAJOR_VERSION* = 1'i8
-  SDL_MINOR_VERSION* = 2'i8
-  SDL_PATCHLEVEL* = 11'i8        # SDL.h constants
-  SDL_INIT_TIMER* = 0x00000001
-  SDL_INIT_AUDIO* = 0x00000010
-  SDL_INIT_VIDEO* = 0x00000020
-  SDL_INIT_CDROM* = 0x00000100
-  SDL_INIT_JOYSTICK* = 0x00000200
-  SDL_INIT_NOPARACHUTE* = 0x00100000 # Don't catch fatal signals
-  SDL_INIT_EVENTTHREAD* = 0x01000000 # Not supported on all OS's
-  SDL_INIT_EVERYTHING* = 0x0000FFFF # SDL_error.h constants
-  ERR_MAX_STRLEN* = 128
-  ERR_MAX_ARGS* = 5           # SDL_types.h constants
-  SDL_PRESSED* = 0x00000001
-  SDL_RELEASED* = 0x00000000  # SDL_timer.h constants
-                              # This is the OS scheduler timeslice, in milliseconds
-  SDL_TIMESLICE* = 10         # This is the maximum resolution of the SDL timer on all platforms
-  TIMER_RESOLUTION* = 10      # Experimentally determined
-                              # SDL_audio.h constants
-  AUDIO_U8* = 0x00000008      # Unsigned 8-bit samples
-  AUDIO_S8* = 0x00008008      # Signed 8-bit samples
-  AUDIO_U16LSB* = 0x00000010  # Unsigned 16-bit samples
-  AUDIO_S16LSB* = 0x00008010  # Signed 16-bit samples
-  AUDIO_U16MSB* = 0x00001010  # As above, but big-endian byte order
-  AUDIO_S16MSB* = 0x00009010  # As above, but big-endian byte order
-  AUDIO_U16* = AUDIO_U16LSB
-  AUDIO_S16* = AUDIO_S16LSB   # SDL_cdrom.h constants
-                              # The maximum number of CD-ROM tracks on a disk
-  SDL_MAX_TRACKS* = 99        # The types of CD-ROM track possible
-  SDL_AUDIO_TRACK* = 0x00000000
-  SDL_DATA_TRACK* = 0x00000004 # Conversion functions from frames to Minute/Second/Frames and vice versa
-  CD_FPS* = 75                # SDL_byteorder.h constants
-                              # The two types of endianness
-  SDL_LIL_ENDIAN* = 1234
-  SDL_BIG_ENDIAN* = 4321
-
-when cpuEndian == littleEndian:
-  const
-    SDL_BYTEORDER* = SDL_LIL_ENDIAN # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16LSB
-    AUDIO_S16SYS* = AUDIO_S16LSB
-else:
-  const
-    SDL_BYTEORDER* = SDL_BIG_ENDIAN # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16MSB
-    AUDIO_S16SYS* = AUDIO_S16MSB
-const
-  SDL_MIX_MAXVOLUME* = 128    # SDL_joystick.h constants
-  MAX_JOYSTICKS* = 2          # only 2 are supported in the multimedia API
-  MAX_AXES* = 6               # each joystick can have up to 6 axes
-  MAX_BUTTONS* = 32           # and 32 buttons
-  AXIS_MIN* = - 32768         # minimum value for axis coordinate
-  AXIS_MAX* = 32767           # maximum value for axis coordinate
-  JOY_AXIS_THRESHOLD* = (toFloat((AXIS_MAX) - (AXIS_MIN)) / 100.0) # 1% motion
-  SDL_HAT_CENTERED* = 0x00000000
-  SDL_HAT_UP* = 0x00000001
-  SDL_HAT_RIGHT* = 0x00000002
-  SDL_HAT_DOWN* = 0x00000004
-  SDL_HAT_LEFT* = 0x00000008
-  SDL_HAT_RIGHTUP* = SDL_HAT_RIGHT or SDL_HAT_UP
-  SDL_HAT_RIGHTDOWN* = SDL_HAT_RIGHT or SDL_HAT_DOWN
-  SDL_HAT_LEFTUP* = SDL_HAT_LEFT or SDL_HAT_UP
-  SDL_HAT_LEFTDOWN* = SDL_HAT_LEFT or SDL_HAT_DOWN # SDL_events.h constants
-
-type
-  TSDL_EventKind* = enum        # kind of an SDL event
-    SDL_NOEVENT = 0,            # Unused (do not remove)
-    SDL_ACTIVEEVENT = 1,        # Application loses/gains visibility
-    SDL_KEYDOWN = 2,            # Keys pressed
-    SDL_KEYUP = 3,              # Keys released
-    SDL_MOUSEMOTION = 4,        # Mouse moved
-    SDL_MOUSEBUTTONDOWN = 5,    # Mouse button pressed
-    SDL_MOUSEBUTTONUP = 6,      # Mouse button released
-    SDL_JOYAXISMOTION = 7,      # Joystick axis motion
-    SDL_JOYBALLMOTION = 8,      # Joystick trackball motion
-    SDL_JOYHATMOTION = 9,       # Joystick hat position change
-    SDL_JOYBUTTONDOWN = 10,     # Joystick button pressed
-    SDL_JOYBUTTONUP = 11,       # Joystick button released
-    SDL_QUITEV = 12,            # User-requested quit ( Changed due to procedure conflict )
-    SDL_SYSWMEVENT = 13,        # System specific event
-    SDL_EVENT_RESERVEDA = 14,   # Reserved for future use..
-    SDL_EVENT_RESERVED = 15,    # Reserved for future use..
-    SDL_VIDEORESIZE = 16,       # User resized video mode
-    SDL_VIDEOEXPOSE = 17,       # Screen needs to be redrawn
-    SDL_EVENT_RESERVED2 = 18,   # Reserved for future use..
-    SDL_EVENT_RESERVED3 = 19,   # Reserved for future use..
-    SDL_EVENT_RESERVED4 = 20,   # Reserved for future use..
-    SDL_EVENT_RESERVED5 = 21,   # Reserved for future use..
-    SDL_EVENT_RESERVED6 = 22,   # Reserved for future use..
-    SDL_EVENT_RESERVED7 = 23,   # Reserved for future use..
-                                # Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
-    SDL_USEREVENT = 24 # This last event is only for bounding internal arrays
-                       # It is the number of bits in the event mask datatype -- UInt32
-
-const
-  SDL_NUMEVENTS* = 32
-  SDL_ALLEVENTS* = 0xFFFFFFFF
-  SDL_ACTIVEEVENTMASK* = 1 shl ord(SDL_ACTIVEEVENT)
-  SDL_KEYDOWNMASK* = 1 shl ord(SDL_KEYDOWN)
-  SDL_KEYUPMASK* = 1 shl ord(SDL_KEYUP)
-  SDL_MOUSEMOTIONMASK* = 1 shl ord(SDL_MOUSEMOTION)
-  SDL_MOUSEBUTTONDOWNMASK* = 1 shl ord(SDL_MOUSEBUTTONDOWN)
-  SDL_MOUSEBUTTONUPMASK* = 1 shl ord(SDL_MOUSEBUTTONUP)
-  SDL_MOUSEEVENTMASK* = 1 shl ord(SDL_MOUSEMOTION) or 1 shl ord(SDL_MOUSEBUTTONDOWN) or
-      1 shl ord(SDL_MOUSEBUTTONUP)
-  SDL_JOYAXISMOTIONMASK* = 1 shl ord(SDL_JOYAXISMOTION)
-  SDL_JOYBALLMOTIONMASK* = 1 shl ord(SDL_JOYBALLMOTION)
-  SDL_JOYHATMOTIONMASK* = 1 shl ord(SDL_JOYHATMOTION)
-  SDL_JOYBUTTONDOWNMASK* = 1 shl ord(SDL_JOYBUTTONDOWN)
-  SDL_JOYBUTTONUPMASK* = 1 shl ord(SDL_JOYBUTTONUP)
-  SDL_JOYEVENTMASK* = 1 shl ord(SDL_JOYAXISMOTION) or 1 shl ord(SDL_JOYBALLMOTION) or
-      1 shl ord(SDL_JOYHATMOTION) or 1 shl ord(SDL_JOYBUTTONDOWN) or
-      1 shl ord(SDL_JOYBUTTONUP)
-  SDL_VIDEORESIZEMASK* = 1 shl ord(SDL_VIDEORESIZE)
-  SDL_QUITMASK* = 1 shl ord(SDL_QUITEV)
-  SDL_SYSWMEVENTMASK* = 1 shl ord(SDL_SYSWMEVENT)
-  SDL_QUERY* = - 1
-  SDL_IGNORE* = 0
-  SDL_DISABLE* = 0
-  SDL_ENABLE* = 1             #SDL_keyboard.h constants
-                              # This is the mask which refers to all hotkey bindings
-  SDL_ALL_HOTKEYS* = 0xFFFFFFFF # Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
-                                #  'delay' is the initial delay in ms between the time when a key is
-                                #  pressed, and keyboard repeat begins.
-                                #  'interval' is the time in ms between keyboard repeat events.
-  SDL_DEFAULT_REPEAT_DELAY* = 500
-  SDL_DEFAULT_REPEAT_INTERVAL* = 30 # The keyboard syms have been cleverly chosen to map to ASCII
-  SDLK_UNKNOWN* = 0
-  SDLK_FIRST* = 0
-  SDLK_BACKSPACE* = 8
-  SDLK_TAB* = 9
-  SDLK_CLEAR* = 12
-  SDLK_RETURN* = 13
-  SDLK_PAUSE* = 19
-  SDLK_ESCAPE* = 27
-  SDLK_SPACE* = 32
-  SDLK_EXCLAIM* = 33
-  SDLK_QUOTEDBL* = 34
-  SDLK_HASH* = 35
-  SDLK_DOLLAR* = 36
-  SDLK_AMPERSAND* = 38
-  SDLK_QUOTE* = 39
-  SDLK_LEFTPAREN* = 40
-  SDLK_RIGHTPAREN* = 41
-  SDLK_ASTERISK* = 42
-  SDLK_PLUS* = 43
-  SDLK_COMMA* = 44
-  SDLK_MINUS* = 45
-  SDLK_PERIOD* = 46
-  SDLK_SLASH* = 47
-  SDLK_0* = 48
-  SDLK_1* = 49
-  SDLK_2* = 50
-  SDLK_3* = 51
-  SDLK_4* = 52
-  SDLK_5* = 53
-  SDLK_6* = 54
-  SDLK_7* = 55
-  SDLK_8* = 56
-  SDLK_9* = 57
-  SDLK_COLON* = 58
-  SDLK_SEMICOLON* = 59
-  SDLK_LESS* = 60
-  SDLK_EQUALS* = 61
-  SDLK_GREATER* = 62
-  SDLK_QUESTION* = 63
-  SDLK_AT* = 64               # Skip uppercase letters
-  SDLK_LEFTBRACKET* = 91
-  SDLK_BACKSLASH* = 92
-  SDLK_RIGHTBRACKET* = 93
-  SDLK_CARET* = 94
-  SDLK_UNDERSCORE* = 95
-  SDLK_BACKQUOTE* = 96
-  SDLK_a* = 97
-  SDLK_b* = 98
-  SDLK_c* = 99
-  SDLK_d* = 100
-  SDLK_e* = 101
-  SDLK_f* = 102
-  SDLK_g* = 103
-  SDLK_h* = 104
-  SDLK_i* = 105
-  SDLK_j* = 106
-  SDLK_k* = 107
-  SDLK_l* = 108
-  SDLK_m* = 109
-  SDLK_n* = 110
-  SDLK_o* = 111
-  SDLK_p* = 112
-  SDLK_q* = 113
-  SDLK_r* = 114
-  SDLK_s* = 115
-  SDLK_t* = 116
-  SDLK_u* = 117
-  SDLK_v* = 118
-  SDLK_w* = 119
-  SDLK_x* = 120
-  SDLK_y* = 121
-  SDLK_z* = 122
-  SDLK_DELETE* = 127          # End of ASCII mapped keysyms
-                              # International keyboard syms
-  SDLK_WORLD_0* = 160         # 0xA0
-  SDLK_WORLD_1* = 161
-  SDLK_WORLD_2* = 162
-  SDLK_WORLD_3* = 163
-  SDLK_WORLD_4* = 164
-  SDLK_WORLD_5* = 165
-  SDLK_WORLD_6* = 166
-  SDLK_WORLD_7* = 167
-  SDLK_WORLD_8* = 168
-  SDLK_WORLD_9* = 169
-  SDLK_WORLD_10* = 170
-  SDLK_WORLD_11* = 171
-  SDLK_WORLD_12* = 172
-  SDLK_WORLD_13* = 173
-  SDLK_WORLD_14* = 174
-  SDLK_WORLD_15* = 175
-  SDLK_WORLD_16* = 176
-  SDLK_WORLD_17* = 177
-  SDLK_WORLD_18* = 178
-  SDLK_WORLD_19* = 179
-  SDLK_WORLD_20* = 180
-  SDLK_WORLD_21* = 181
-  SDLK_WORLD_22* = 182
-  SDLK_WORLD_23* = 183
-  SDLK_WORLD_24* = 184
-  SDLK_WORLD_25* = 185
-  SDLK_WORLD_26* = 186
-  SDLK_WORLD_27* = 187
-  SDLK_WORLD_28* = 188
-  SDLK_WORLD_29* = 189
-  SDLK_WORLD_30* = 190
-  SDLK_WORLD_31* = 191
-  SDLK_WORLD_32* = 192
-  SDLK_WORLD_33* = 193
-  SDLK_WORLD_34* = 194
-  SDLK_WORLD_35* = 195
-  SDLK_WORLD_36* = 196
-  SDLK_WORLD_37* = 197
-  SDLK_WORLD_38* = 198
-  SDLK_WORLD_39* = 199
-  SDLK_WORLD_40* = 200
-  SDLK_WORLD_41* = 201
-  SDLK_WORLD_42* = 202
-  SDLK_WORLD_43* = 203
-  SDLK_WORLD_44* = 204
-  SDLK_WORLD_45* = 205
-  SDLK_WORLD_46* = 206
-  SDLK_WORLD_47* = 207
-  SDLK_WORLD_48* = 208
-  SDLK_WORLD_49* = 209
-  SDLK_WORLD_50* = 210
-  SDLK_WORLD_51* = 211
-  SDLK_WORLD_52* = 212
-  SDLK_WORLD_53* = 213
-  SDLK_WORLD_54* = 214
-  SDLK_WORLD_55* = 215
-  SDLK_WORLD_56* = 216
-  SDLK_WORLD_57* = 217
-  SDLK_WORLD_58* = 218
-  SDLK_WORLD_59* = 219
-  SDLK_WORLD_60* = 220
-  SDLK_WORLD_61* = 221
-  SDLK_WORLD_62* = 222
-  SDLK_WORLD_63* = 223
-  SDLK_WORLD_64* = 224
-  SDLK_WORLD_65* = 225
-  SDLK_WORLD_66* = 226
-  SDLK_WORLD_67* = 227
-  SDLK_WORLD_68* = 228
-  SDLK_WORLD_69* = 229
-  SDLK_WORLD_70* = 230
-  SDLK_WORLD_71* = 231
-  SDLK_WORLD_72* = 232
-  SDLK_WORLD_73* = 233
-  SDLK_WORLD_74* = 234
-  SDLK_WORLD_75* = 235
-  SDLK_WORLD_76* = 236
-  SDLK_WORLD_77* = 237
-  SDLK_WORLD_78* = 238
-  SDLK_WORLD_79* = 239
-  SDLK_WORLD_80* = 240
-  SDLK_WORLD_81* = 241
-  SDLK_WORLD_82* = 242
-  SDLK_WORLD_83* = 243
-  SDLK_WORLD_84* = 244
-  SDLK_WORLD_85* = 245
-  SDLK_WORLD_86* = 246
-  SDLK_WORLD_87* = 247
-  SDLK_WORLD_88* = 248
-  SDLK_WORLD_89* = 249
-  SDLK_WORLD_90* = 250
-  SDLK_WORLD_91* = 251
-  SDLK_WORLD_92* = 252
-  SDLK_WORLD_93* = 253
-  SDLK_WORLD_94* = 254
-  SDLK_WORLD_95* = 255        # 0xFF
-                              # Numeric keypad
-  SDLK_KP0* = 256
-  SDLK_KP1* = 257
-  SDLK_KP2* = 258
-  SDLK_KP3* = 259
-  SDLK_KP4* = 260
-  SDLK_KP5* = 261
-  SDLK_KP6* = 262
-  SDLK_KP7* = 263
-  SDLK_KP8* = 264
-  SDLK_KP9* = 265
-  SDLK_KP_PERIOD* = 266
-  SDLK_KP_DIVIDE* = 267
-  SDLK_KP_MULTIPLY* = 268
-  SDLK_KP_MINUS* = 269
-  SDLK_KP_PLUS* = 270
-  SDLK_KP_ENTER* = 271
-  SDLK_KP_EQUALS* = 272       # Arrows + Home/End pad
-  SDLK_UP* = 273
-  SDLK_DOWN* = 274
-  SDLK_RIGHT* = 275
-  SDLK_LEFT* = 276
-  SDLK_INSERT* = 277
-  SDLK_HOME* = 278
-  SDLK_END* = 279
-  SDLK_PAGEUP* = 280
-  SDLK_PAGEDOWN* = 281        # Function keys
-  SDLK_F1* = 282
-  SDLK_F2* = 283
-  SDLK_F3* = 284
-  SDLK_F4* = 285
-  SDLK_F5* = 286
-  SDLK_F6* = 287
-  SDLK_F7* = 288
-  SDLK_F8* = 289
-  SDLK_F9* = 290
-  SDLK_F10* = 291
-  SDLK_F11* = 292
-  SDLK_F12* = 293
-  SDLK_F13* = 294
-  SDLK_F14* = 295
-  SDLK_F15* = 296             # Key state modifier keys
-  SDLK_NUMLOCK* = 300
-  SDLK_CAPSLOCK* = 301
-  SDLK_SCROLLOCK* = 302
-  SDLK_RSHIFT* = 303
-  SDLK_LSHIFT* = 304
-  SDLK_RCTRL* = 305
-  SDLK_LCTRL* = 306
-  SDLK_RALT* = 307
-  SDLK_LALT* = 308
-  SDLK_RMETA* = 309
-  SDLK_LMETA* = 310
-  SDLK_LSUPER* = 311          # Left "Windows" key
-  SDLK_RSUPER* = 312          # Right "Windows" key
-  SDLK_MODE* = 313            # "Alt Gr" key
-  SDLK_COMPOSE* = 314         # Multi-key compose key
-                              # Miscellaneous function keys
-  SDLK_HELP* = 315
-  SDLK_PRINT* = 316
-  SDLK_SYSREQ* = 317
-  SDLK_BREAK* = 318
-  SDLK_MENU* = 319
-  SDLK_POWER* = 320           # Power Macintosh power key
-  SDLK_EURO* = 321            # Some european keyboards
-  SDLK_GP2X_UP* = 0
-  SDLK_GP2X_UPLEFT* = 1
-  SDLK_GP2X_LEFT* = 2
-  SDLK_GP2X_DOWNLEFT* = 3
-  SDLK_GP2X_DOWN* = 4
-  SDLK_GP2X_DOWNRIGHT* = 5
-  SDLK_GP2X_RIGHT* = 6
-  SDLK_GP2X_UPRIGHT* = 7
-  SDLK_GP2X_START* = 8
-  SDLK_GP2X_SELECT* = 9
-  SDLK_GP2X_L* = 10
-  SDLK_GP2X_R* = 11
-  SDLK_GP2X_A* = 12
-  SDLK_GP2X_B* = 13
-  SDLK_GP2X_Y* = 14
-  SDLK_GP2X_X* = 15
-  SDLK_GP2X_VOLUP* = 16
-  SDLK_GP2X_VOLDOWN* = 17
-  SDLK_GP2X_CLICK* = 18
-
-const                         # Enumeration of valid key mods (possibly OR'd together)
-  KMOD_NONE* = 0x00000000
-  KMOD_LSHIFT* = 0x00000001
-  KMOD_RSHIFT* = 0x00000002
-  KMOD_LCTRL* = 0x00000040
-  KMOD_RCTRL* = 0x00000080
-  KMOD_LALT* = 0x00000100
-  KMOD_RALT* = 0x00000200
-  KMOD_LMETA* = 0x00000400
-  KMOD_RMETA* = 0x00000800
-  KMOD_NUM* = 0x00001000
-  KMOD_CAPS* = 0x00002000
-  KMOD_MODE* = 44000
-  KMOD_RESERVED* = 0x00008000
-  KMOD_CTRL* = (KMOD_LCTRL or KMOD_RCTRL)
-  KMOD_SHIFT* = (KMOD_LSHIFT or KMOD_RSHIFT)
-  KMOD_ALT* = (KMOD_LALT or KMOD_RALT)
-  KMOD_META* = (KMOD_LMETA or KMOD_RMETA) #SDL_video.h constants
-                                          # Transparency definitions: These define alpha as the opacity of a surface */
-  SDL_ALPHA_OPAQUE* = 255
-  SDL_ALPHA_TRANSPARENT* = 0 # These are the currently supported flags for the SDL_surface
-                             # Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
-  SDL_SWSURFACE* = 0x00000000 # Surface is in system memory
-  SDL_HWSURFACE* = 0x00000001 # Surface is in video memory
-  SDL_ASYNCBLIT* = 0x00000004 # Use asynchronous blits if possible
-                              # Available for SDL_SetVideoMode()
-  SDL_ANYFORMAT* = 0x10000000 # Allow any video depth/pixel-format
-  SDL_HWPALETTE* = 0x20000000 # Surface has exclusive palette
-  SDL_DOUBLEBUF* = 0x40000000 # Set up double-buffered video mode
-  SDL_FULLSCREEN* = 0x80000000 # Surface is a full screen display
-  SDL_OPENGL* = 0x00000002    # Create an OpenGL rendering context
-  SDL_OPENGLBLIT* = 0x00000002 # Create an OpenGL rendering context
-  SDL_RESIZABLE* = 0x00000010 # This video mode may be resized
-  SDL_NOFRAME* = 0x00000020   # No window caption or edge frame
-                              # Used internally (read-only)
-  SDL_HWACCEL* = 0x00000100   # Blit uses hardware acceleration
-  SDL_SRCCOLORKEY* = 0x00001000 # Blit uses a source color key
-  SDL_RLEACCELOK* = 0x00002000 # Private flag
-  SDL_RLEACCEL* = 0x00004000  # Colorkey blit is RLE accelerated
-  SDL_SRCALPHA* = 0x00010000  # Blit uses source alpha blending
-  SDL_SRCCLIPPING* = 0x00100000 # Blit uses source clipping
-  SDL_PREALLOC* = 0x01000000 # Surface uses preallocated memory
-                             # The most common video overlay formats.
-                             #    For an explanation of these pixel formats, see:
-                             #    http://www.webartz.com/fourcc/indexyuv.htm
-                             #
-                             #   For information on the relationship between color spaces, see:
-                             #
-                             #   http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
-  SDL_YV12_OVERLAY* = 0x32315659 # Planar mode: Y + V + U  (3 planes)
-  SDL_IYUV_OVERLAY* = 0x56555949 # Planar mode: Y + U + V  (3 planes)
-  SDL_YUY2_OVERLAY* = 0x32595559 # Packed mode: Y0+U0+Y1+V0 (1 plane)
-  SDL_UYVY_OVERLAY* = 0x59565955 # Packed mode: U0+Y0+V0+Y1 (1 plane)
-  SDL_YVYU_OVERLAY* = 0x55595659 # Packed mode: Y0+V0+Y1+U0 (1 plane)
-                                 # flags for SDL_SetPalette()
-  SDL_LOGPAL* = 0x00000001
-  SDL_PHYSPAL* = 0x00000002 #SDL_mouse.h constants
-                            # Used as a mask when testing buttons in buttonstate
-                            #    Button 1:	Left mouse button
-                            #    Button 2:	Middle mouse button
-                            #    Button 3:	Right mouse button
-                            #    Button 4:	Mouse Wheel Up
-                            #    Button 5:	Mouse Wheel Down
-                            #
-  SDL_BUTTON_LEFT* = 1
-  SDL_BUTTON_MIDDLE* = 2
-  SDL_BUTTON_RIGHT* = 3
-  SDL_BUTTON_WHEELUP* = 4
-  SDL_BUTTON_WHEELDOWN* = 5
-  SDL_BUTTON_LMASK* = SDL_PRESSED shl (SDL_BUTTON_LEFT - 1)
-  SDL_BUTTON_MMASK* = SDL_PRESSED shl (SDL_BUTTON_MIDDLE - 1)
-  SDL_BUTTON_RMask* = SDL_PRESSED shl (SDL_BUTTON_RIGHT - 1) # SDL_active.h constants
-                                                             # The available application states
-  SDL_APPMOUSEFOCUS* = 0x00000001 # The app has mouse coverage
-  SDL_APPINPUTFOCUS* = 0x00000002 # The app has input focus
-  SDL_APPACTIVE* = 0x00000004 # The application is active
-                              # SDL_mutex.h constants
-                              # Synchronization functions which can time out return this value
-                              #  they time out.
-  SDL_MUTEX_TIMEDOUT* = 1     # This is the timeout value which corresponds to never time out
-  SDL_MUTEX_MAXWAIT* = not int(0)
-  SDL_GRAB_QUERY* = - 1
-  SDL_GRAB_OFF* = 0
-  SDL_GRAB_ON* = 1            #SDL_GRAB_FULLSCREEN // Used internally
-
-type
-  THandle* = int              #SDL_types.h types
-                              # Basic data types
-  TSDL_Bool* = enum
-    SDL_FALSE, SDL_TRUE
-  PUInt8Array* = ptr TUInt8Array
-  PUInt8* = ptr UInt8
-  PPUInt8* = ptr PUInt8
-  UInt8* = int8
-  TUInt8Array* = array[0..high(int) shr 1, UInt8]
-  PUInt16* = ptr UInt16
-  UInt16* = int16
-  PSInt8* = ptr SInt8
-  SInt8* = int8
-  PSInt16* = ptr SInt16
-  SInt16* = int16
-  PUInt32* = ptr UInt32
-  UInt32* = int
-  SInt32* = int
-  PInt* = ptr int
-  PShortInt* = ptr int8
-  PUInt64* = ptr UInt64
-  UInt64*{.final.} = object
-    hi*: UInt32
-    lo*: UInt32
-
-  PSInt64* = ptr SInt64
-  SInt64*{.final.} = object
-    hi*: UInt32
-    lo*: UInt32
-
-  TSDL_GrabMode* = int        # SDL_error.h types
-  TSDL_errorcode* = enum
-    SDL_ENOMEM, SDL_EFREAD, SDL_EFWRITE, SDL_EFSEEK, SDL_LASTERROR
-  SDL_errorcode* = TSDL_errorcode
-  TArg*{.final.} = object
-    buf*: array[0..ERR_MAX_STRLEN - 1, int8]
-
-  PSDL_error* = ptr TSDL_error
-  TSDL_error*{.final.} = object  # This is a numeric value corresponding to the current error
-                                 # SDL_rwops.h types
-                                 # This is the read/write operation structure -- very basic
-                                 # some helper types to handle the unions
-                                 # "packed" is only guessed
-    error*: int # This is a key used to index into a language hashtable containing
-                #       internationalized versions of the SDL error messages.  If the key
-                #       is not in the hashtable, or no hashtable is available, the key is
-                #       used directly as an error message format string.
-    key*: array[0..ERR_MAX_STRLEN - 1, int8] # These are the arguments for the error functions
-    argc*: int
-    args*: array[0..ERR_MAX_ARGS - 1, TArg]
-
-  TStdio*{.final.} = object
-    autoclose*: int           # FILE * is only defined in Kylix so we use a simple Pointer
-    fp*: Pointer
-
-  TMem*{.final.} = object
-    base*: PUInt8
-    here*: PUInt8
-    stop*: PUInt8
-
-  TUnknown*{.final.} = object  # first declare the pointer type
-    data1*: Pointer
-
-  PSDL_RWops* = ptr TSDL_RWops # now the pointer to function types
-  TSeek* = proc (context: PSDL_RWops, offset: int, whence: int): int{.cdecl.}
-  TRead* = proc (context: PSDL_RWops, thePtr: Pointer, size: int, maxnum: int): int{.
-      cdecl.}
-  TWrite* = proc (context: PSDL_RWops, thePtr: Pointer, size: int, num: int): int{.
-      cdecl.}
-  TClose* = proc (context: PSDL_RWops): int{.cdecl.} # the variant record itself
-  trange010 = range[0..2]
-  TSDL_RWops*{.final.} = object
-    seek*: TSeek
-    read*: TRead
-    write*: TWrite
-    closeFile*: TClose        # a keyword as name is not allowed
-                              # be warned! structure alignment may arise at this point
-    case theType*: trange010
-    of trange010(0):
-      stdio*: TStdio
-    of trange010(1):
-      mem*: TMem
-    of trange010(2):
-      unknown*: TUnknown
-
-
-  SDL_RWops* = TSDL_RWops     # SDL_timer.h types
-                              # Function prototype for the timer callback function
-  TSDL_TimerCallback* = proc (interval: UInt32): UInt32{.cdecl.} # New timer API, supports multiple timers
-                                                                 #   Written by Stephane Peter
-                                                                 #   <megastep@lokigames.com>
-                                                                 # Function prototype for the new timer callback function.
-                                                                 #   The callback function is passed the current timer interval and returns
-                                                                 #   the next timer interval.  If the returned value is the same as the one
-                                                                 #   passed in, the periodic alarm continues, otherwise a new alarm is
-                                                                 #   scheduled.  If the callback returns 0, the periodic alarm is cancelled.
-  TSDL_NewTimerCallback* = proc (interval: UInt32, param: Pointer): UInt32{.
-      cdecl.}                 # Definition of the timer ID type
-  PSDL_TimerID* = ptr TSDL_TimerID
-  TSDL_TimerID*{.final.} = object
-    interval*: UInt32
-    callback*: TSDL_NewTimerCallback
-    param*: Pointer
-    last_alarm*: UInt32
-    next*: PSDL_TimerID
-
-  TSDL_AudioSpecCallback* = proc (userdata: Pointer, stream: PUInt8, length: int){.
-      cdecl.}                 # SDL_audio.h types
-                              # The calculated values in this structure are calculated by SDL_OpenAudio()
-  PSDL_AudioSpec* = ptr TSDL_AudioSpec
-  TSDL_AudioSpec*{.final.} = object  # A structure to hold a set of audio conversion filters and buffers
-    freq*: int                # DSP frequency -- samples per second
-    format*: UInt16           # Audio data format
-    channels*: UInt8          # Number of channels: 1 mono, 2 stereo
-    silence*: UInt8           # Audio buffer silence value (calculated)
-    samples*: UInt16          # Audio buffer size in samples
-    padding*: UInt16          # Necessary for some compile environments
-    size*: UInt32 # Audio buffer size in bytes (calculated)
-                  # This function is called when the audio device needs more data.
-                  #      'stream' is a pointer to the audio data buffer
-                  #      'len' is the length of that buffer in bytes.
-                  #      Once the callback returns, the buffer will no longer be valid.
-                  #      Stereo samples are stored in a LRLRLR ordering.
-    callback*: TSDL_AudioSpecCallback
-    userdata*: Pointer
-
-  PSDL_AudioCVT* = ptr TSDL_AudioCVT
-  PSDL_AudioCVTFilter* = ptr TSDL_AudioCVTFilter
-  TSDL_AudioCVTFilter*{.final.} = object
-    cvt*: PSDL_AudioCVT
-    format*: UInt16
-
-  PSDL_AudioCVTFilterArray* = ptr TSDL_AudioCVTFilterArray
-  TSDL_AudioCVTFilterArray* = array[0..9, PSDL_AudioCVTFilter]
-  TSDL_AudioCVT*{.final.} = object
-    needed*: int              # Set to 1 if conversion possible
-    src_format*: UInt16       # Source audio format
-    dst_format*: UInt16       # Target audio format
-    rate_incr*: float64       # Rate conversion increment
-    buf*: PUInt8              # Buffer to hold entire audio data
-    length*: int              # Length of original audio buffer
-    len_cvt*: int             # Length of converted audio buffer
-    len_mult*: int            # buffer must be len*len_mult big
-    len_ratio*: float64       # Given len, final size is len*len_ratio
-    filters*: TSDL_AudioCVTFilterArray
-    filter_index*: int        # Current audio conversion function
-
-  TSDL_Audiostatus* = enum    # SDL_cdrom.h types
-    SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED
-  TSDL_CDStatus* = enum
-    CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED
-  PSDL_CDTrack* = ptr TSDL_CDTrack
-  TSDL_CDTrack*{.final.} = object  # This structure is only current as of the last call to SDL_CDStatus()
-    id*: UInt8                # Track number
-    theType*: UInt8           # Data or audio track
-    unused*: UInt16
-    len*: UInt32              # Length, in frames, of this track
-    offset*: UInt32           # Offset, in frames, from start of disk
-
-  PSDL_CD* = ptr TSDL_CD
-  TSDL_CD*{.final.} = object  #SDL_joystick.h types
-    id*: int                  # Private drive identifier
-    status*: TSDL_CDStatus    # Current drive status
-                              # The rest of this structure is only valid if there's a CD in drive
-    numtracks*: int           # Number of tracks on disk
-    cur_track*: int           # Current track position
-    cur_frame*: int           # Current frame offset within current track
-    track*: array[0..SDL_MAX_TRACKS, TSDL_CDTrack]
-
-  PTransAxis* = ptr TTransAxis
-  TTransAxis*{.final.} = object  # The private structure used to keep track of a joystick
-    offset*: int
-    scale*: float32
-
-  PJoystick_hwdata* = ptr TJoystick_hwdata
-  TJoystick_hwdata*{.final.} = object  # joystick ID
-    id*: int                  # values used to translate device-specific coordinates into  SDL-standard ranges
-    transaxis*: array[0..5, TTransAxis]
-
-  PBallDelta* = ptr TBallDelta
-  TBallDelta*{.final.} = object  # Current ball motion deltas
-                                 # The SDL joystick structure
-    dx*: int
-    dy*: int
-
-  PSDL_Joystick* = ptr TSDL_Joystick
-  TSDL_Joystick*{.final.} = object  # SDL_verion.h types
-    index*: UInt8             # Device index
-    name*: cstring            # Joystick name - system dependent
-    naxes*: int               # Number of axis controls on the joystick
-    axes*: PUInt16            # Current axis states
-    nhats*: int               # Number of hats on the joystick
-    hats*: PUInt8             # Current hat states
-    nballs*: int              # Number of trackballs on the joystick
-    balls*: PBallDelta        # Current ball motion deltas
-    nbuttons*: int            # Number of buttons on the joystick
-    buttons*: PUInt8          # Current button states
-    hwdata*: PJoystick_hwdata # Driver dependent information
-    ref_count*: int           # Reference count for multiple opens
-
-  PSDL_version* = ptr TSDL_version
-  TSDL_version*{.final.} = object  # SDL_keyboard.h types
-    major*: UInt8
-    minor*: UInt8
-    patch*: UInt8
-
-  TSDLKey* = int32
-  TSDLMod* = int32
-  PSDL_KeySym* = ptr TSDL_KeySym
-  TSDL_KeySym*{.final.} = object  # SDL_events.h types
-                                  #Checks the event queue for messages and optionally returns them.
-                                  #   If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-                                  #   the back of the event queue.
-                                  #   If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-                                  #   of the event queue, matching 'mask', will be returned and will not
-                                  #   be removed from the queue.
-                                  #   If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-                                  #   of the event queue, matching 'mask', will be returned and will be
-                                  #   removed from the queue.
-                                  #   This function returns the number of events actually stored, or -1
-                                  #   if there was an error.  This function is thread-safe.
-    scancode*: UInt8          # hardware specific scancode
-    sym*: TSDLKey             # SDL virtual keysym
-    modifier*: TSDLMod        # current key modifiers
-    unicode*: UInt16          # translated character
-
-  TSDL_EventAction* = enum    # Application visibility event structure
-    SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT
-  TSDL_ActiveEvent*{.final.} = object  # SDL_ACTIVEEVENT
-                                       # Keyboard event structure
-    gain*: UInt8              # Whether given states were gained or lost (1/0)
-    state*: UInt8             # A mask of the focus states
-
-  TSDL_KeyboardEvent*{.final.} = object  # SDL_KEYDOWN or SDL_KEYUP
-                                         # Mouse motion event structure
-    which*: UInt8             # The keyboard device index
-    state*: UInt8             # SDL_PRESSED or SDL_RELEASED
-    keysym*: TSDL_KeySym
-
-  TSDL_MouseMotionEvent*{.final.} = object  # SDL_MOUSEMOTION
-                                            # Mouse button event structure
-    which*: UInt8             # The mouse device index
-    state*: UInt8             # The current button state
-    x*, y*: UInt16            # The X/Y coordinates of the mouse
-    xrel*: SInt16             # The relative motion in the X direction
-    yrel*: SInt16             # The relative motion in the Y direction
-
-  TSDL_MouseButtonEvent*{.final.} = object  # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
-                                            # Joystick axis motion event structure
-    which*: UInt8             # The mouse device index
-    button*: UInt8            # The mouse button index
-    state*: UInt8             # SDL_PRESSED or SDL_RELEASED
-    x*: UInt16                # The X coordinates of the mouse at press time
-    y*: UInt16                # The Y coordinates of the mouse at press time
-
-  TSDL_JoyAxisEvent*{.final.} = object  # SDL_JOYAXISMOTION
-                                        # Joystick trackball motion event structure
-    which*: UInt8             # The joystick device index
-    axis*: UInt8              # The joystick axis index
-    value*: SInt16            # The axis value (range: -32768 to 32767)
-
-  TSDL_JoyBallEvent*{.final.} = object  # SDL_JOYAVBALLMOTION
-                                        # Joystick hat position change event structure
-    which*: UInt8             # The joystick device index
-    ball*: UInt8              # The joystick trackball index
-    xrel*: SInt16             # The relative motion in the X direction
-    yrel*: SInt16             # The relative motion in the Y direction
-
-  TSDL_JoyHatEvent*{.final.} = object  # SDL_JOYHATMOTION */
-                                       # Joystick button event structure
-    which*: UInt8             # The joystick device index */
-    hat*: UInt8               # The joystick hat index */
-    value*: UInt8             # The hat position value:
-                              #                    8   1   2
-                              #                    7   0   3
-                              #                    6   5   4
-                              #                    Note that zero means the POV is centered.
-
-  TSDL_JoyButtonEvent*{.final.} = object  # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
-                                          # The "window resized" event
-                                          #    When you get this event, you are responsible for setting a new video
-                                          #    mode with the new width and height.
-    which*: UInt8             # The joystick device index
-    button*: UInt8            # The joystick button index
-    state*: UInt8             # SDL_PRESSED or SDL_RELEASED
-
-  TSDL_ResizeEvent*{.final.} = object  # SDL_VIDEORESIZE
-                                       # A user-defined event type
-    w*: int                   # New width
-    h*: int                   # New height
-
-  PSDL_UserEvent* = ptr TSDL_UserEvent
-  TSDL_UserEvent*{.final.} = object  # SDL_USEREVENT through SDL_NUMEVENTS-1
-    code*: int                # User defined event code */
-    data1*: Pointer           # User defined data pointer */
-    data2*: Pointer           # User defined data pointer */
-
-
-when defined(Unix):
-  type                        #These are the various supported subsystems under UNIX
-    TSDL_SysWm* = enum
-      SDL_SYSWM_X11
-# The windows custom event structure
-
-when defined(WINDOWS):
-  type
-    PSDL_SysWMmsg* = ptr TSDL_SysWMmsg
-    TSDL_SysWMmsg*{.final.} = object
-      version*: TSDL_version
-      hwnd*: THandle          # The window for the message
-      msg*: int               # The type of message
-      w_Param*: int32         # WORD message parameter
-      lParam*: int32          # LONG message parameter
-
-elif defined(Unix):
-  type                      # The Linux custom event structure
-    PSDL_SysWMmsg* = ptr TSDL_SysWMmsg
-    TSDL_SysWMmsg*{.final.} = object
-      version*: TSDL_version
-      subsystem*: TSDL_SysWm
-      when false:
-        event*: TXEvent
-else:
-  type                      # The generic custom event structure
-    PSDL_SysWMmsg* = ptr TSDL_SysWMmsg
-    TSDL_SysWMmsg*{.final.} = object
-      version*: TSDL_version
-      data*: int
-
-# The Windows custom window manager information structure
-
-when defined(WINDOWS):
-  type
-    PSDL_SysWMinfo* = ptr TSDL_SysWMinfo
-    TSDL_SysWMinfo*{.final.} = object
-      version*: TSDL_version
-      window*: THandle        # The display window
-
-elif defined(Unix):
-  type
-    TX11*{.final.} = object
-      when false:
-        display*: PDisplay # The X11 display
-        window*: TWindow # The X11 display window
-                         # These locking functions should be called around
-                         # any X11 functions using the display variable.
-                         # They lock the event thread, so should not be
-                         # called around event functions or from event filters.
-        lock_func*: Pointer
-        unlock_func*: Pointer # Introduced in SDL 1.0.2
-        fswindow*: TWindow    # The X11 fullscreen window
-        wmwindow*: TWindow    # The X11 managed input window
-
-  type
-    PSDL_SysWMinfo* = ptr TSDL_SysWMinfo
-    TSDL_SysWMinfo*{.final.} = object
-      version*: TSDL_version
-      subsystem*: TSDL_SysWm
-      X11*: TX11
-else:
-  type  # The generic custom window manager information structure
-    PSDL_SysWMinfo* = ptr TSDL_SysWMinfo
-    TSDL_SysWMinfo*{.final.} = object
-      version*: TSDL_version
-      data*: int
-
-type
-  PSDL_SysWMEvent* = ptr TSDL_SysWMEvent
-  TSDL_SysWMEvent*{.final.} = object
-    msg*: PSDL_SysWMmsg
-
-  PSDL_Event* = ptr TSDL_Event
-  TSDL_Event*{.final.} = object  # This function sets up a filter to process all events before they
-                                 #  change internal state and are posted to the internal event queue.
-                                 #
-                                 #  The filter is protypted as:
-    case theType*: TSDL_EventKind      # SDL_NOEVENT, SDL_QUITEV: ();
-    of SDL_ACTIVEEVENT:
-      active*: TSDL_ActiveEvent
-    of SDL_KEYDOWN, SDL_KEYUP:
-      key*: TSDL_KeyboardEvent
-    of SDL_MOUSEMOTION:
-      motion*: TSDL_MouseMotionEvent
-    of SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP:
-      button*: TSDL_MouseButtonEvent
-    of SDL_JOYAXISMOTION:
-      jaxis*: TSDL_JoyAxisEvent
-    of SDL_JOYBALLMOTION:
-      jball*: TSDL_JoyBallEvent
-    of SDL_JOYHATMOTION:
-      jhat*: TSDL_JoyHatEvent
-    of SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP:
-      jbutton*: TSDL_JoyButtonEvent
-    of SDL_VIDEORESIZE:
-      resize*: TSDL_ResizeEvent
-    of SDL_USEREVENT:
-      user*: TSDL_UserEvent
-    of SDL_SYSWMEVENT:
-      syswm*: TSDL_SysWMEvent
-    else:
-      nil
-
-  TSDL_EventFilter* = proc (event: PSDL_Event): int{.cdecl.} # SDL_video.h types
-                                                             # Useful data types
-  PPSDL_Rect* = ptr PSDL_Rect
-  PSDL_Rect* = ptr TSDL_Rect
-  TSDL_Rect*{.final.} = object
-    x*, y*: SInt16
-    w*, h*: UInt16
-
-  SDL_Rect* = TSDL_Rect
-  PSDL_Color* = ptr TSDL_Color
-  TSDL_Color*{.final.} = object
-    r*: UInt8
-    g*: UInt8
-    b*: UInt8
-    unused*: UInt8
-
-  PSDL_ColorArray* = ptr TSDL_ColorArray
-  TSDL_ColorArray* = array[0..65000, TSDL_Color]
-  PSDL_Palette* = ptr TSDL_Palette
-  TSDL_Palette*{.final.} = object  # Everything in the pixel format structure is read-only
-    ncolors*: int
-    colors*: PSDL_ColorArray
-
-  PSDL_PixelFormat* = ptr TSDL_PixelFormat
-  TSDL_PixelFormat*{.final.} = object  # The structure passed to the low level blit functions
-    palette*: PSDL_Palette
-    BitsPerPixel*: UInt8
-    BytesPerPixel*: UInt8
-    Rloss*: UInt8
-    Gloss*: UInt8
-    Bloss*: UInt8
-    Aloss*: UInt8
-    Rshift*: UInt8
-    Gshift*: UInt8
-    Bshift*: UInt8
-    Ashift*: UInt8
-    RMask*: UInt32
-    GMask*: UInt32
-    BMask*: UInt32
-    AMask*: UInt32
-    colorkey*: UInt32         # RGB color key information
-    alpha*: UInt8             # Alpha value information (per-surface alpha)
-
-  PSDL_BlitInfo* = ptr TSDL_BlitInfo
-  TSDL_BlitInfo*{.final.} = object  # typedef for private surface blitting functions
-    s_pixels*: PUInt8
-    s_width*: int
-    s_height*: int
-    s_skip*: int
-    d_pixels*: PUInt8
-    d_width*: int
-    d_height*: int
-    d_skip*: int
-    aux_data*: Pointer
-    src*: PSDL_PixelFormat
-    table*: PUInt8
-    dst*: PSDL_PixelFormat
-
-  PSDL_Surface* = ptr TSDL_Surface
-  TSDL_Blit* = proc (src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface,
-                     dstrect: PSDL_Rect): int{.cdecl.}
-  TSDL_Surface*{.final.} = object  # Useful for determining the video hardware capabilities
-    flags*: UInt32            # Read-only
-    format*: PSDL_PixelFormat # Read-only
-    w*, h*: int               # Read-only
-    pitch*: UInt16            # Read-only
-    pixels*: Pointer          # Read-write
-    offset*: int              # Private
-    hwdata*: Pointer          #TPrivate_hwdata;  Hardware-specific surface info
-                              # clipping information:
-    clip_rect*: TSDL_Rect     # Read-only
-    unused1*: UInt32          # for binary compatibility
-                              # Allow recursive locks
-    locked*: UInt32           # Private
-                              # info for fast blit mapping to other surfaces
-    Blitmap*: Pointer         # PSDL_BlitMap; //   Private
-                              # format version, bumped at every change to invalidate blit maps
-    format_version*: int      # Private
-    refcount*: int
-
-  PSDL_VideoInfo* = ptr TSDL_VideoInfo
-  TSDL_VideoInfo*{.final.} = object  # The YUV hardware video overlay
-    hw_available*: UInt8 # Hardware and WindowManager flags in first 2 bits ( see below )
-                         #hw_available: 1; // Can you create hardware surfaces
-                         #    wm_available: 1; // Can you talk to a window manager?
-                         #    UnusedBits1: 6;
-    blit_hw*: UInt8 # Blit Hardware flags. See below for which bits do what
-                    #UnusedBits2: 1;
-                    #    blit_hw: 1; // Flag:UInt32  Accelerated blits HW --> HW
-                    #    blit_hw_CC: 1; // Flag:UInt32  Accelerated blits with Colorkey
-                    #    blit_hw_A: 1; // Flag:UInt32  Accelerated blits with Alpha
-                    #    blit_sw: 1; // Flag:UInt32  Accelerated blits SW --> HW
-                    #    blit_sw_CC: 1; // Flag:UInt32  Accelerated blits with Colorkey
-                    #    blit_sw_A: 1; // Flag:UInt32  Accelerated blits with Alpha
-                    #    blit_fill: 1; // Flag:UInt32  Accelerated color fill
-    UnusedBits3*: UInt8       # Unused at this point
-    video_mem*: UInt32        # The total amount of video memory (in K)
-    vfmt*: PSDL_PixelFormat   # Value: The format of the video surface
-    current_w*: SInt32        # Value: The current video mode width
-    current_h*: SInt32        # Value: The current video mode height
-
-  PSDL_Overlay* = ptr TSDL_Overlay
-  TSDL_Overlay*{.final.} = object  # Public enumeration for setting the OpenGL window attributes.
-    format*: UInt32           # Overlay format
-    w*, h*: int               # Width and height of overlay
-    planes*: int              # Number of planes in the overlay. Usually either 1 or 3
-    pitches*: PUInt16         # An array of pitches, one for each plane. Pitch is the length of a row in bytes.
-    pixels*: PPUInt8          # An array of pointers to the data of each plane. The overlay should be locked before these pointers are used.
-    hw_overlay*: UInt32       # This will be set to 1 if the overlay is hardware accelerated.
-
-  TSDL_GLAttr* = enum
-    SDL_GL_RED_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_ALPHA_SIZE,
-    SDL_GL_BUFFER_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_DEPTH_SIZE,
-    SDL_GL_STENCIL_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ACCUM_GREEN_SIZE,
-    SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_STEREO,
-    SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES,
-    SDL_GL_ACCELERATED_VISUAL, SDL_GL_SWAP_CONTROL
-  PSDL_Cursor* = ptr TSDL_Cursor
-  TSDL_Cursor*{.final.} = object  # SDL_mutex.h types
-    area*: TSDL_Rect          # The area of the mouse cursor
-    hot_x*, hot_y*: SInt16    # The "tip" of the cursor
-    data*: PUInt8             # B/W cursor data
-    mask*: PUInt8             # B/W cursor mask
-    save*: array[1..2, PUInt8] # Place to save cursor area
-    wm_cursor*: Pointer       # Window-manager cursor
-
-
-type
-  PSDL_Mutex* = ptr TSDL_Mutex
-  TSDL_Mutex*{.final.} = object
-  PSDL_semaphore* = ptr TSDL_semaphore
-  TSDL_semaphore*{.final.} = object
-  PSDL_Sem* = ptr TSDL_Sem
-  TSDL_Sem* = TSDL_Semaphore
-  PSDL_Cond* = ptr TSDL_Cond
-  TSDL_Cond*{.final.} = object  # SDL_thread.h types
-
-when defined(WINDOWS):
-  type
-    TSYS_ThreadHandle* = THandle
-when defined(Unix):
-  type
-    TSYS_ThreadHandle* = pointer
-type                          # This is the system-independent thread info structure
-  PSDL_Thread* = ptr TSDL_Thread
-  TSDL_Thread*{.final.} = object  # Helper Types
-                                  # Keyboard  State Array ( See demos for how to use )
-    threadid*: UInt32
-    handle*: TSYS_ThreadHandle
-    status*: int
-    errbuf*: TSDL_Error
-    data*: Pointer
-
-  PKeyStateArr* = ptr TKeyStateArr
-  TKeyStateArr* = array[0..65000, UInt8] # Types required so we don't need to use Windows.pas
-  PInteger* = ptr int
-  PByte* = ptr int8
-  PWord* = ptr int16
-  PLongWord* = ptr int32      # General arrays
-  PByteArray* = ptr TByteArray
-  TByteArray* = array[0..32767, int8]
-  PWordArray* = ptr TWordArray
-  TWordArray* = array[0..16383, int16] # Generic procedure pointer
-  TProcedure* = proc () #------------------------------------------------------------------------------
-                        # initialization
-                        #------------------------------------------------------------------------------
-                        # This function loads the SDL dynamically linked library and initializes
-                        #  the subsystems specified by 'flags' (and those satisfying dependencies)
-                        #  Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
-                        #  signal handlers for some commonly ignored fatal signals (like SIGSEGV)
-
-proc SDL_Init*(flags: UInt32): int{.cdecl, importc, dynlib: SDLLibName.}
-  # This function initializes specific SDL subsystems
-proc SDL_InitSubSystem*(flags: UInt32): int{.cdecl, importc, dynlib: SDLLibName.}
-  # This function cleans up specific SDL subsystems
-proc SDL_QuitSubSystem*(flags: UInt32){.cdecl, importc, dynlib: SDLLibName.}
-  # This function returns mask of the specified subsystems which have
-  #  been initialized.
-  #  If 'flags' is 0, it returns a mask of all initialized subsystems.
-proc SDL_WasInit*(flags: UInt32): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # This function cleans up all initialized subsystems and unloads the
-  #  dynamically linked library.  You should call it upon all exit conditions.
-proc SDL_Quit*(){.cdecl, importc, dynlib: SDLLibName.}
-when defined(WINDOWS):
-  # This should be called from your WinMain() function, if any
-  proc SDL_RegisterApp*(name: cstring, style: UInt32, h_Inst: Pointer): int{.
-      cdecl, importc, dynlib: SDLLibName.}
-#------------------------------------------------------------------------------
-# types
-#------------------------------------------------------------------------------
-# The number of elements in a table
-
-proc SDL_TableSize*(table: cstring): int
-  #------------------------------------------------------------------------------
-  # error-handling
-  #------------------------------------------------------------------------------
-  # Public functions
-proc SDL_GetError*(): cstring{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_SetError*(fmt: cstring){.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_ClearError*(){.cdecl, importc, dynlib: SDLLibName.}
-when not(defined(WINDOWS)):
-  proc SDL_Error*(Code: TSDL_errorcode){.cdecl, importc, dynlib: SDLLibName.}
-# Private error message function - used internally
-
-proc SDL_OutOfMemory*()
-  #------------------------------------------------------------------------------
-  # io handling
-  #------------------------------------------------------------------------------
-  # Functions to create SDL_RWops structures from various data sources
-proc SDL_RWFromFile*(filename, mode: cstring): PSDL_RWops{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_FreeRW*(area: PSDL_RWops){.cdecl, importc, dynlib: SDLLibName.}
-  #fp is FILE *fp ???
-proc SDL_RWFromFP*(fp: Pointer, autoclose: int): PSDL_RWops{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_RWFromMem*(mem: Pointer, size: int): PSDL_RWops{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_RWFromConstMem*(mem: Pointer, size: int): PSDL_RWops{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_AllocRW*(): PSDL_RWops{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_RWSeek*(context: PSDL_RWops, offset: int, whence: int): int
-proc SDL_RWTell*(context: PSDL_RWops): int
-proc SDL_RWRead*(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int
-proc SDL_RWWrite*(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int
-proc SDL_RWClose*(context: PSDL_RWops): int
-  #------------------------------------------------------------------------------
-  # time-handling
-  #------------------------------------------------------------------------------
-  # Get the number of milliseconds since the SDL library initialization.
-  # Note that this value wraps if the program runs for more than ~49 days.
-proc SDL_GetTicks*(): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # Wait a specified number of milliseconds before returning
-proc SDL_Delay*(msec: UInt32){.cdecl, importc, dynlib: SDLLibName.}
-  # Add a new timer to the pool of timers already running.
-  # Returns a timer ID, or NULL when an error occurs.
-proc SDL_AddTimer*(interval: UInt32, callback: TSDL_NewTimerCallback,
-                   param: Pointer): PSDL_TimerID{.cdecl, importc, dynlib: SDLLibName.}
-  # Remove one of the multiple timers knowing its ID.
-  # Returns a boolean value indicating success.
-proc SDL_RemoveTimer*(t: PSDL_TimerID): TSDL_Bool{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_SetTimer*(interval: UInt32, callback: TSDL_TimerCallback): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # audio-routines
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the audio driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-proc SDL_AudioInit*(driver_name: cstring): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_AudioQuit*(){.cdecl, importc, dynlib: SDLLibName.}
-  # This function fills the given character buffer with the name of the
-  #  current audio driver, and returns a Pointer to it if the audio driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc SDL_AudioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # This function opens the audio device with the desired parameters, and
-  #  returns 0 if successful, placing the actual hardware parameters in the
-  #  structure pointed to by 'obtained'.  If 'obtained' is NULL, the audio
-  #  data passed to the callback function will be guaranteed to be in the
-  #  requested format, and will be automatically converted to the hardware
-  #  audio format if necessary.  This function returns -1 if it failed
-  #  to open the audio device, or couldn't set up the audio thread.
-  #
-  #  When filling in the desired audio spec structure,
-  #   'desired->freq' should be the desired audio frequency in samples-per-second.
-  #   'desired->format' should be the desired audio format.
-  #   'desired->samples' is the desired size of the audio buffer, in samples.
-  #      This number should be a power of two, and may be adjusted by the audio
-  #      driver to a value more suitable for the hardware.  Good values seem to
-  #      range between 512 and 8096 inclusive, depending on the application and
-  #      CPU speed.  Smaller values yield faster response time, but can lead
-  #      to underflow if the application is doing heavy processing and cannot
-  #      fill the audio buffer in time.  A stereo sample consists of both right
-  #      and left channels in LR ordering.
-  #      Note that the number of samples is directly related to time by the
-  #      following formula:  ms = (samples*1000)/freq
-  #   'desired->size' is the size in bytes of the audio buffer, and is
-  #      calculated by SDL_OpenAudio().
-  #   'desired->silence' is the value used to set the buffer to silence,
-  #      and is calculated by SDL_OpenAudio().
-  #   'desired->callback' should be set to a function that will be called
-  #      when the audio device is ready for more data.  It is passed a pointer
-  #      to the audio buffer, and the length in bytes of the audio buffer.
-  #      This function usually runs in a separate thread, and so you should
-  #      protect data structures that it accesses by calling SDL_LockAudio()
-  #      and SDL_UnlockAudio() in your code.
-  #   'desired->userdata' is passed as the first parameter to your callback
-  #      function.
-  #
-  #  The audio device starts out playing silence when it's opened, and should
-  #  be enabled for playing by calling SDL_PauseAudio(0) when you are ready
-  #  for your audio callback function to be called.  Since the audio driver
-  #  may modify the requested size of the audio buffer, you should allocate
-  #  any local mixing buffers after you open the audio device.
-proc SDL_OpenAudio*(desired, obtained: PSDL_AudioSpec): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the current audio state:
-proc SDL_GetAudioStatus*(): TSDL_Audiostatus{.cdecl, importc, dynlib: SDLLibName.}
-  # This function pauses and unpauses the audio callback processing.
-  #  It should be called with a parameter of 0 after opening the audio
-  #  device to start playing sound.  This is so you can safely initialize
-  #  data for your callback function after opening the audio device.
-  #  Silence will be written to the audio device during the pause.
-proc SDL_PauseAudio*(pause_on: int){.cdecl, importc, dynlib: SDLLibName.}
-  # This function loads a WAVE from the data source, automatically freeing
-  #  that source if 'freesrc' is non-zero.  For example, to load a WAVE file,
-  #  you could do:
-  #  SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
-  #
-  #  If this function succeeds, it returns the given SDL_AudioSpec,
-  #  filled with the audio data format of the wave data, and sets
-  #  'audio_buf' to a malloc()'d buffer containing the audio data,
-  #  and sets 'audio_len' to the length of that audio buffer, in bytes.
-  #  You need to free the audio buffer with SDL_FreeWAV() when you are
-  #  done with it.
-  #
-  #  This function returns NULL and sets the SDL error message if the
-  #  wave file cannot be opened, uses an unknown data format, or is
-  #  corrupt.  Currently raw and MS-ADPCM WAVE files are supported.
-proc SDL_LoadWAV_RW*(src: PSDL_RWops, freesrc: int, spec: PSDL_AudioSpec,
-                     audio_buf: PUInt8, audiolen: PUInt32): PSDL_AudioSpec{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Compatibility convenience function -- loads a WAV from a file
-proc SDL_LoadWAV*(filename: cstring, spec: PSDL_AudioSpec, audio_buf: PUInt8,
-                  audiolen: PUInt32): PSDL_AudioSpec
-  # This function frees data previously allocated with SDL_LoadWAV_RW()
-proc SDL_FreeWAV*(audio_buf: PUInt8){.cdecl, importc, dynlib: SDLLibName.}
-  # This function takes a source format and rate and a destination format
-  #  and rate, and initializes the 'cvt' structure with information needed
-  #  by SDL_ConvertAudio() to convert a buffer of audio data from one format
-  #  to the other.
-  #  This function returns 0, or -1 if there was an error.
-proc SDL_BuildAudioCVT*(cvt: PSDL_AudioCVT, src_format: UInt16,
-                        src_channels: UInt8, src_rate: int, dst_format: UInt16,
-                        dst_channels: UInt8, dst_rate: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
-  #  created an audio buffer cvt->buf, and filled it with cvt->len bytes of
-  #  audio data in the source format, this function will convert it in-place
-  #  to the desired format.
-  #  The data conversion may expand the size of the audio data, so the buffer
-  #  cvt->buf should be allocated after the cvt structure is initialized by
-  #  SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
-proc SDL_ConvertAudio*(cvt: PSDL_AudioCVT): int{.cdecl, importc, dynlib: SDLLibName.}
-  # This takes two audio buffers of the playing audio format and mixes
-  #  them, performing addition, volume adjustment, and overflow clipping.
-  #  The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
-  #  for full audio volume.  Note this does not change hardware volume.
-  #  This is provided for convenience -- you can mix your own audio data.
-proc SDL_MixAudio*(dst, src: PUInt8, length: UInt32, volume: int){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # The lock manipulated by these functions protects the callback function.
-  #  During a LockAudio/UnlockAudio pair, you can be guaranteed that the
-  #  callback function is not running.  Do not call these from the callback
-  #  function or you will cause deadlock.
-proc SDL_LockAudio*(){.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_UnlockAudio*(){.cdecl, importc, dynlib: SDLLibName.}
-  # This function shuts down audio processing and closes the audio device.
-proc SDL_CloseAudio*(){.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # CD-routines
-  #------------------------------------------------------------------------------
-  # Returns the number of CD-ROM drives on the system, or -1 if
-  #  SDL_Init() has not been called with the SDL_INIT_CDROM flag.
-proc SDL_CDNumDrives*(): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Returns a human-readable, system-dependent identifier for the CD-ROM.
-  #   Example:
-  #   "/dev/cdrom"
-  #   "E:"
-  #   "/dev/disk/ide/1/master"
-proc SDL_CDName*(drive: int): cstring{.cdecl, importc, dynlib: SDLLibName.}
-  # Opens a CD-ROM drive for access.  It returns a drive handle on success,
-  #  or NULL if the drive was invalid or busy.  This newly opened CD-ROM
-  #  becomes the default CD used when other CD functions are passed a NULL
-  #  CD-ROM handle.
-  #  Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
-proc SDL_CDOpen*(drive: int): PSDL_CD{.cdecl, importc, dynlib: SDLLibName.}
-  # This function returns the current status of the given drive.
-  #  If the drive has a CD in it, the table of contents of the CD and current
-  #  play position of the CD will be stored in the SDL_CD structure.
-proc SDL_CDStatus*(cdrom: PSDL_CD): TSDL_CDStatus{.cdecl, importc, dynlib: SDLLibName.}
-  #  Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
-  #   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play
-  #   until the end of the CD.  This function will skip data tracks.
-  #   This function should only be called after calling SDL_CDStatus() to
-  #   get track information about the CD.
-  #
-  #   For example:
-  #   // Play entire CD:
-  #  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
-  #   // Play last track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #   begin
-  #    SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
-  #   end;
-  #
-  #   // Play first and second track and 10 seconds of third track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
-  #
-  #   This function returns 0, or -1 if there was an error.
-proc SDL_CDPlayTracks*(cdrom: PSDL_CD, start_track: int, start_frame: int,
-                       ntracks: int, nframes: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #  Play the given CD starting at 'start' frame for 'length' frames.
-  #   It returns 0, or -1 if there was an error.
-proc SDL_CDPlay*(cdrom: PSDL_CD, start: int, len: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Pause play -- returns 0, or -1 on error
-proc SDL_CDPause*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Resume play -- returns 0, or -1 on error
-proc SDL_CDResume*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Stop play -- returns 0, or -1 on error
-proc SDL_CDStop*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Eject CD-ROM -- returns 0, or -1 on error
-proc SDL_CDEject*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Closes the handle for the CD-ROM drive
-proc SDL_CDClose*(cdrom: PSDL_CD){.cdecl, importc, dynlib: SDLLibName.}
-  # Given a status, returns true if there's a disk in the drive
-proc SDL_CDInDrive*(status: TSDL_CDStatus): bool
-  # Conversion functions from frames to Minute/Second/Frames and vice versa
-proc FRAMES_TO_MSF*(frames: int, M: var int, S: var int, F: var int)
-proc MSF_TO_FRAMES*(M: int, S: int, F: int): int
-  #------------------------------------------------------------------------------
-  # JoyStick-routines
-  #------------------------------------------------------------------------------
-  # Count the number of joysticks attached to the system
-proc SDL_NumJoysticks*(): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the implementation dependent name of a joystick.
-  #  This can be called before any joysticks are opened.
-  #  If no name can be found, this function returns NULL.
-proc SDL_JoystickName*(index: int): cstring{.cdecl, importc, dynlib: SDLLibName.}
-  # Open a joystick for use - the index passed as an argument refers to
-  #  the N'th joystick on the system.  This index is the value which will
-  #  identify this joystick in future joystick events.
-  #
-  #  This function returns a joystick identifier, or NULL if an error occurred.
-proc SDL_JoystickOpen*(index: int): PSDL_Joystick{.cdecl, importc, dynlib: SDLLibName.}
-  # Returns 1 if the joystick has been opened, or 0 if it has not.
-proc SDL_JoystickOpened*(index: int): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the device index of an opened joystick.
-proc SDL_JoystickIndex*(joystick: PSDL_Joystick): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the number of general axis controls on a joystick
-proc SDL_JoystickNumAxes*(joystick: PSDL_Joystick): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the number of trackballs on a joystick
-  #  Joystick trackballs have only relative motion events associated
-  #  with them and their state cannot be polled.
-proc SDL_JoystickNumBalls*(joystick: PSDL_Joystick): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the number of POV hats on a joystick
-proc SDL_JoystickNumHats*(joystick: PSDL_Joystick): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the number of buttons on a joystick
-proc SDL_JoystickNumButtons*(joystick: PSDL_Joystick): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Update the current state of the open joysticks.
-  #  This is called automatically by the event loop if any joystick
-  #  events are enabled.
-proc SDL_JoystickUpdate*(){.cdecl, importc, dynlib: SDLLibName.}
-  # Enable/disable joystick event polling.
-  #  If joystick events are disabled, you must call SDL_JoystickUpdate()
-  #  yourself and check the state of the joystick when you want joystick
-  #  information.
-  #  The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
-proc SDL_JoystickEventState*(state: int): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the current state of an axis control on a joystick
-  #  The state is a value ranging from -32768 to 32767.
-  #  The axis indices start at index 0.
-proc SDL_JoystickGetAxis*(joystick: PSDL_Joystick, axis: int): SInt16{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # The hat indices start at index 0.
-proc SDL_JoystickGetHat*(joystick: PSDL_Joystick, hat: int): UInt8{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the ball axis change since the last poll
-  #  This returns 0, or -1 if you passed it invalid parameters.
-  #  The ball indices start at index 0.
-proc SDL_JoystickGetBall*(joystick: PSDL_Joystick, ball: int, dx: var int,
-                          dy: var int): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the current state of a button on a joystick
-  #  The button indices start at index 0.
-proc SDL_JoystickGetButton*(joystick: PSDL_Joystick, Button: int): UInt8{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Close a joystick previously opened with SDL_JoystickOpen()
-proc SDL_JoystickClose*(joystick: PSDL_Joystick){.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # event-handling
-  #------------------------------------------------------------------------------
-  # Pumps the event loop, gathering events from the input devices.
-  #  This function updates the event queue and internal input device state.
-  #  This should only be run in the thread that sets the video mode.
-proc SDL_PumpEvents*(){.cdecl, importc, dynlib: SDLLibName.}
-  # Checks the event queue for messages and optionally returns them.
-  #  If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-  #  the back of the event queue.
-  #  If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will not
-  #  be removed from the queue.
-  #  If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will be
-  #  removed from the queue.
-  #  This function returns the number of events actually stored, or -1
-  #  if there was an error.  This function is thread-safe.
-proc SDL_PeepEvents*(events: PSDL_Event, numevents: int,
-                     action: TSDL_eventaction, mask: UInt32): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Polls for currently pending events, and returns 1 if there are any pending
-  #   events, or 0 if there are none available.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc SDL_PollEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.}
-  #  Waits indefinitely for the next available event, returning 1, or 0 if there
-  #   was an error while waiting for events.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc SDL_WaitEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_PushEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.}
-  # If the filter returns 1, then the event will be added to the internal queue.
-  #  If it returns 0, then the event will be dropped from the queue, but the
-  #  internal state will still be updated.  This allows selective filtering of
-  #  dynamically arriving events.
-  #
-  #  WARNING:  Be very careful of what you do in the event filter function, as
-  #            it may run in a different thread!
-  #
-  #  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
-  #  event filter is only called when the window manager desires to close the
-  #  application window.  If the event filter returns 1, then the window will
-  #  be closed, otherwise the window will remain open if possible.
-  #  If the quit event is generated by an interrupt signal, it will bypass the
-  #  internal queue and be delivered to the application at the next event poll.
-proc SDL_SetEventFilter*(filter: TSDL_EventFilter){.cdecl, importc, dynlib: SDLLibName.}
-  # Return the current event filter - can be used to "chain" filters.
-  #  If there is no event filter set, this function returns NULL.
-proc SDL_GetEventFilter*(): TSDL_EventFilter{.cdecl, importc, dynlib: SDLLibName.}
-  # This function allows you to set the state of processing certain events.
-  #  If 'state' is set to SDL_IGNORE, that event will be automatically dropped
-  #  from the event queue and will not event be filtered.
-  #  If 'state' is set to SDL_ENABLE, that event will be processed normally.
-  #  If 'state' is set to SDL_QUERY, SDL_EventState() will return the
-  #  current processing state of the specified event.
-proc SDL_EventState*(theType: UInt8, state: int): UInt8{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # Version Routines
-  #------------------------------------------------------------------------------
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library.
-proc SDL_VERSION*(X: var TSDL_Version)
-  # This macro turns the version numbers into a numeric value:
-  #   (1,2,3) -> (1203)
-  #   This assumes that there will never be more than 100 patchlevels
-proc SDL_VERSIONNUM*(X, Y, Z: int): int
-  # This is the version number macro for the current SDL version
-proc SDL_COMPILEDVERSION*(): int
-  # This macro will evaluate to true if compiled with SDL at least X.Y.Z
-proc SDL_VERSION_ATLEAST*(X: int, Y: int, Z: int): bool
-  # This function gets the version of the dynamically linked SDL library.
-  #  it should NOT be used to fill a version structure, instead you should
-  #  use the SDL_Version() macro.
-proc SDL_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # video
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the video driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-  #
-  #  SDL_VideoInit() initializes the video subsystem -- sets up a connection
-  #  to the window manager, etc, and determines the current video mode and
-  #  pixel format, but does not initialize a window or graphics mode.
-  #  Note that event handling is activated by this routine.
-  #
-  #  If you use both sound and video in your application, you need to call
-  #  SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
-  #  you won't be able to set full-screen display modes.
-proc SDL_VideoInit*(driver_name: cstring, flags: UInt32): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_VideoQuit*(){.cdecl, importc, dynlib: SDLLibName.}
-  # This function fills the given character buffer with the name of the
-  #  video driver, and returns a pointer to it if the video driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc SDL_VideoDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # This function returns a pointer to the current display surface.
-  #  If SDL is doing format conversion on the display surface, this
-  #  function returns the publicly visible surface, not the real video
-  #  surface.
-proc SDL_GetVideoSurface*(): PSDL_Surface{.cdecl, importc, dynlib: SDLLibName.}
-  # This function returns a read-only pointer to information about the
-  #  video hardware.  If this is called before SDL_SetVideoMode(), the 'vfmt'
-  #  member of the returned structure will contain the pixel format of the
-  #  "best" video mode.
-proc SDL_GetVideoInfo*(): PSDL_VideoInfo{.cdecl, importc, dynlib: SDLLibName.}
-  # Check to see if a particular video mode is supported.
-  #  It returns 0 if the requested mode is not supported under any bit depth,
-  #  or returns the bits-per-pixel of the closest available mode with the
-  #  given width and height.  If this bits-per-pixel is different from the
-  #  one used when setting the video mode, SDL_SetVideoMode() will succeed,
-  #  but will emulate the requested bits-per-pixel with a shadow surface.
-  #
-  #  The arguments to SDL_VideoModeOK() are the same ones you would pass to
-  #  SDL_SetVideoMode()
-proc SDL_VideoModeOK*(width, height, bpp: int, flags: UInt32): int{.cdecl,
-    importc, importc, dynlib: SDLLibName.}
-  # Return a pointer to an array of available screen dimensions for the
-  #  given format and video flags, sorted largest to smallest.  Returns
-  #  NULL if there are no dimensions available for a particular format,
-  #  or (SDL_Rect **)-1 if any dimension is okay for the given format.
-  #
-  #  if 'format' is NULL, the mode list will be for the format given
-  #  by SDL_GetVideoInfo( ) - > vfmt
-proc SDL_ListModes*(format: PSDL_PixelFormat, flags: UInt32): PPSDL_Rect{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Set up a video mode with the specified width, height and bits-per-pixel.
-  #
-  #  If 'bpp' is 0, it is treated as the current display bits per pixel.
-  #
-  #  If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
-  #  requested bits-per-pixel, but will return whatever video pixel format is
-  #  available.  The default is to emulate the requested pixel format if it
-  #  is not natively available.
-  #
-  #  If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
-  #  video memory, if possible, and you may have to call SDL_LockSurface()
-  #  in order to access the raw framebuffer.  Otherwise, the video surface
-  #  will be created in system memory.
-  #
-  #  If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
-  #  updates asynchronously, but you must always lock before accessing pixels.
-  #  SDL will wait for updates to complete before returning from the lock.
-  #
-  #  If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
-  #  that the colors set by SDL_SetColors() will be the colors you get.
-  #  Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
-  #  of the colors exactly the way they are requested, and you should look
-  #  at the video surface structure to determine the actual palette.
-  #  If SDL cannot guarantee that the colors you request can be set,
-  #  i.e. if the colormap is shared, then the video surface may be created
-  #  under emulation in system memory, overriding the SDL_HWSURFACE flag.
-  #
-  #  If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
-  #  a fullscreen video mode.  The default is to create a windowed mode
-  #  if the current graphics system has a window manager.
-  #  If the SDL library is able to set a fullscreen video mode, this flag
-  #  will be set in the surface that is returned.
-  #
-  #  If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
-  #  two surfaces in video memory and swap between them when you call
-  #  SDL_Flip().  This is usually slower than the normal single-buffering
-  #  scheme, but prevents "tearing" artifacts caused by modifying video
-  #  memory while the monitor is refreshing.  It should only be used by
-  #  applications that redraw the entire screen on every update.
-  #
-  #  This function returns the video framebuffer surface, or NULL if it fails.
-proc SDL_SetVideoMode*(width, height, bpp: int, flags: UInt32): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Makes sure the given list of rectangles is updated on the given screen.
-  #  If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
-  #  screen.
-  #  These functions should not be called while 'screen' is locked.
-proc SDL_UpdateRects*(screen: PSDL_Surface, numrects: int, rects: PSDL_Rect){.
-    cdecl, importc, dynlib: SDLLibName.}
-proc SDL_UpdateRect*(screen: PSDL_Surface, x, y: SInt32, w, h: UInt32){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # On hardware that supports double-buffering, this function sets up a flip
-  #  and returns.  The hardware will wait for vertical retrace, and then swap
-  #  video buffers before the next video surface blit or lock will return.
-  #  On hardware that doesn not support double-buffering, this is equivalent
-  #  to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
-  #  The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
-  #  setting the video mode for this function to perform hardware flipping.
-  #  This function returns 0 if successful, or -1 if there was an error.
-proc SDL_Flip*(screen: PSDL_Surface): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Set the gamma correction for each of the color channels.
-  #  The gamma values range (approximately) between 0.1 and 10.0
-  #
-  #  If this function isn't supported directly by the hardware, it will
-  #  be emulated using gamma ramps, if available.  If successful, this
-  #  function returns 0, otherwise it returns -1.
-proc SDL_SetGamma*(redgamma: float32, greengamma: float32, bluegamma: float32): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Set the gamma translation table for the red, green, and blue channels
-  #  of the video hardware.  Each table is an array of 256 16-bit quantities,
-  #  representing a mapping between the input and output for that channel.
-  #  The input is the index into the array, and the output is the 16-bit
-  #  gamma value at that index, scaled to the output color precision.
-  #
-  #  You may pass NULL for any of the channels to leave it unchanged.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc SDL_SetGammaRamp*(redtable: PUInt16, greentable: PUInt16,
-                       bluetable: PUInt16): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Retrieve the current values of the gamma translation tables.
-  #
-  #  You must pass in valid pointers to arrays of 256 16-bit quantities.
-  #  Any of the pointers may be NULL to ignore that channel.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc SDL_GetGammaRamp*(redtable: PUInt16, greentable: PUInt16,
-                       bluetable: PUInt16): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Sets a portion of the colormap for the given 8-bit surface.  If 'surface'
-  #  is not a palettized surface, this function does nothing, returning 0.
-  #  If all of the colors were set as passed to SDL_SetColors(), it will
-  #  return 1.  If not all the color entries were set exactly as given,
-  #  it will return 0, and you should look at the surface palette to
-  #  determine the actual color palette.
-  #
-  #  When 'surface' is the surface associated with the current display, the
-  #  display colormap will be updated with the requested colors.  If
-  #  SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
-  #  will always return 1, and the palette is guaranteed to be set the way
-  #  you desire, even if the window colormap has to be warped or run under
-  #  emulation.
-proc SDL_SetColors*(surface: PSDL_Surface, colors: PSDL_Color, firstcolor: int,
-                    ncolors: int): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Sets a portion of the colormap for a given 8-bit surface.
-  #  'flags' is one or both of:
-  #  SDL_LOGPAL  -- set logical palette, which controls how blits are mapped
-  #                 to/from the surface,
-  #  SDL_PHYSPAL -- set physical palette, which controls how pixels look on
-  #                 the screen
-  #  Only screens have physical palettes. Separate change of physical/logical
-  #  palettes is only possible if the screen has SDL_HWPALETTE set.
-  #
-  #  The return value is 1 if all colours could be set as requested, and 0
-  #  otherwise.
-  #
-  #  SDL_SetColors() is equivalent to calling this function with
-  #  flags = (SDL_LOGPAL or SDL_PHYSPAL).
-proc SDL_SetPalette*(surface: PSDL_Surface, flags: int, colors: PSDL_Color,
-                     firstcolor: int, ncolors: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Maps an RGB triple to an opaque pixel value for a given pixel format
-proc SDL_MapRGB*(format: PSDL_PixelFormat, r: UInt8, g: UInt8, b: UInt8): UInt32{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Maps an RGBA quadruple to a pixel value for a given pixel format
-proc SDL_MapRGBA*(format: PSDL_PixelFormat, r: UInt8, g: UInt8, b: UInt8,
-                  a: UInt8): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # Maps a pixel value into the RGB components for a given pixel format
-proc SDL_GetRGB*(pixel: UInt32, fmt: PSDL_PixelFormat, r: PUInt8, g: PUInt8,
-                 b: PUInt8){.cdecl, importc, dynlib: SDLLibName.}
-  # Maps a pixel value into the RGBA components for a given pixel format
-proc SDL_GetRGBA*(pixel: UInt32, fmt: PSDL_PixelFormat, r: PUInt8, g: PUInt8,
-                  b: PUInt8, a: PUInt8){.cdecl, importc, dynlib: SDLLibName.}
-  # Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
-  #  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
-  #  If the depth is greater than 8 bits, the pixel format is set using the
-  #  flags '[RGB]mask'.
-  #  If the function runs out of memory, it will return NULL.
-  #
-  #  The 'flags' tell what kind of surface to create.
-  #  SDL_SWSURFACE means that the surface should be created in system memory.
-  #  SDL_HWSURFACE means that the surface should be created in video memory,
-  #  with the same format as the display surface.  This is useful for surfaces
-  #  that will not change much, to take advantage of hardware acceleration
-  #  when being blitted to the display surface.
-  #  SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
-  #  this surface, but you must always lock it before accessing the pixels.
-  #  SDL will wait for current blits to finish before returning from the lock.
-  #  SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
-  #  If the hardware supports acceleration of colorkey blits between
-  #  two surfaces in video memory, SDL will try to place the surface in
-  #  video memory. If this isn't possible or if there is no hardware
-  #  acceleration available, the surface will be placed in system memory.
-  #  SDL_SRCALPHA means that the surface will be used for alpha blits and
-  #  if the hardware supports hardware acceleration of alpha blits between
-  #  two surfaces in video memory, to place the surface in video memory
-  #  if possible, otherwise it will be placed in system memory.
-  #  If the surface is created in video memory, blits will be _much_ faster,
-  #  but the surface format must be identical to the video surface format,
-  #  and the only way to access the pixels member of the surface is to use
-  #  the SDL_LockSurface() and SDL_UnlockSurface() calls.
-  #  If the requested surface actually resides in video memory, SDL_HWSURFACE
-  #  will be set in the flags member of the returned surface.  If for some
-  #  reason the surface could not be placed in video memory, it will not have
-  #  the SDL_HWSURFACE flag set, and will be created in system memory instead.
-proc SDL_AllocSurface*(flags: UInt32, width, height, depth: int,
-                       RMask, GMask, BMask, AMask: UInt32): PSDL_Surface
-proc SDL_CreateRGBSurface*(flags: UInt32, width, height, depth: int,
-                           RMask, GMask, BMask, AMask: UInt32): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLLibName.}
-proc SDL_CreateRGBSurfaceFrom*(pixels: Pointer,
-                               width, height, depth, pitch: int,
-                               RMask, GMask, BMask, AMask: UInt32): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLLibName.}
-proc SDL_FreeSurface*(surface: PSDL_Surface){.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_MustLock*(Surface: PSDL_Surface): bool
-  # SDL_LockSurface() sets up a surface for directly accessing the pixels.
-  #  Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
-  #  to and read from 'surface->pixels', using the pixel format stored in
-  #  'surface->format'.  Once you are done accessing the surface, you should
-  #  use SDL_UnlockSurface() to release it.
-  #
-  #  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
-  #  to 0, then you can read and write to the surface at any time, and the
-  #  pixel format of the surface will not change.  In particular, if the
-  #  SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
-  #  will not need to lock the display surface before accessing it.
-  #
-  #  No operating system or library calls should be made between lock/unlock
-  #  pairs, as critical system locks may be held during this time.
-  #
-  #  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
-proc SDL_LockSurface*(surface: PSDL_Surface): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_UnlockSurface*(surface: PSDL_Surface){.cdecl, importc, dynlib: SDLLibName.}
-  # Load a surface from a seekable SDL data source (memory or file.)
-  #  If 'freesrc' is non-zero, the source will be closed after being read.
-  #  Returns the new surface, or NULL if there was an error.
-  #  The new surface should be freed with SDL_FreeSurface().
-proc SDL_LoadBMP_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Convenience macro -- load a surface from a file
-proc SDL_LoadBMP*(filename: cstring): PSDL_Surface
-  # Save a surface to a seekable SDL data source (memory or file.)
-  #  If 'freedst' is non-zero, the source will be closed after being written.
-  #  Returns 0 if successful or -1 if there was an error.
-proc SDL_SaveBMP_RW*(surface: PSDL_Surface, dst: PSDL_RWops, freedst: int): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Convenience macro -- save a surface to a file
-proc SDL_SaveBMP*(surface: PSDL_Surface, filename: cstring): int
-  # Sets the color key (transparent pixel) in a blittable surface.
-  #  If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
-  #  'key' will be the transparent pixel in the source image of a blit.
-  #  SDL_RLEACCEL requests RLE acceleration for the surface if present,
-  #  and removes RLE acceleration if absent.
-  #  If 'flag' is 0, this function clears any current color key.
-  #  This function returns 0, or -1 if there was an error.
-proc SDL_SetColorKey*(surface: PSDL_Surface, flag, key: UInt32): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # This function sets the alpha value for the entire surface, as opposed to
-  #  using the alpha component of each pixel. This value measures the range
-  #  of transparency of the surface, 0 being completely transparent to 255
-  #  being completely opaque. An 'alpha' value of 255 causes blits to be
-  #  opaque, the source pixels copied to the destination (the default). Note
-  #  that per-surface alpha can be combined with colorkey transparency.
-  #
-  #  If 'flag' is 0, alpha blending is disabled for the surface.
-  #  If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
-  #  OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
-  #  surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
-proc SDL_SetAlpha*(surface: PSDL_Surface, flag: UInt32, alpha: UInt8): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Sets the clipping rectangle for the destination surface in a blit.
-  #
-  #  If the clip rectangle is NULL, clipping will be disabled.
-  #  If the clip rectangle doesn't intersect the surface, the function will
-  #  return SDL_FALSE and blits will be completely clipped.  Otherwise the
-  #  function returns SDL_TRUE and blits to the surface will be clipped to
-  #  the intersection of the surface area and the clipping rectangle.
-  #
-  #  Note that blits are automatically clipped to the edges of the source
-  #  and destination surfaces.
-proc SDL_SetClipRect*(surface: PSDL_Surface, rect: PSDL_Rect){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Gets the clipping rectangle for the destination surface in a blit.
-  #  'rect' must be a pointer to a valid rectangle which will be filled
-  #  with the correct values.
-proc SDL_GetClipRect*(surface: PSDL_Surface, rect: PSDL_Rect){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Creates a new surface of the specified format, and then copies and maps
-  #  the given surface to it so the blit of the converted surface will be as
-  #  fast as possible.  If this function fails, it returns NULL.
-  #
-  #  The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
-  #  semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
-  #  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
-  #  surface.
-  #
-  #  This function is used internally by SDL_DisplayFormat().
-proc SDL_ConvertSurface*(src: PSDL_Surface, fmt: PSDL_PixelFormat, flags: UInt32): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLLibName.}
-  #
-  #  This performs a fast blit from the source surface to the destination
-  #  surface.  It assumes that the source and destination rectangles are
-  #  the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
-  #  surface (src or dst) is copied.  The final blit rectangles are saved
-  #  in 'srcrect' and 'dstrect' after all clipping is performed.
-  #  If the blit is successful, it returns 0, otherwise it returns -1.
-  #
-  #  The blit function should not be called on a locked surface.
-  #
-  #  The blit semantics for surfaces with and without alpha and colorkey
-  #  are defined as follows:
-  #
-  #  RGBA->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using alpha-channel).
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value);
-  #   set destination alpha to opaque.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB, set destination alpha to opaque.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  RGBA->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source alpha channel) the RGB values;
-  #   leave destination alpha untouched. [Note: is this correct?]
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy all of RGBA to the destination.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value).
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  If either of the surfaces were in video memory, and the blit returns -2,
-  #  the video memory was lost, so it should be reloaded with artwork and
-  #  re-blitted:
-  #  while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
-  #  begin
-  #  while ( SDL_LockSurface(image) < 0 ) do
-  #   Sleep(10);
-  #  -- Write image pixels to image->pixels --
-  #  SDL_UnlockSurface(image);
-  # end;
-  #
-  #  This happens under DirectX 5.0 when the system switches away from your
-  #  fullscreen application.  The lock will also fail until you have access
-  #  to the video memory again.
-  # You should call SDL_BlitSurface() unless you know exactly how SDL
-  #   blitting works internally and how to use the other blit functions.
-proc SDL_BlitSurface*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface,
-                      dstrect: PSDL_Rect): int
-  #  This is the public blit function, SDL_BlitSurface(), and it performs
-  #   rectangle validation and clipping before passing it to SDL_LowerBlit()
-proc SDL_UpperBlit*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface,
-                    dstrect: PSDL_Rect): int{.cdecl, importc, dynlib: SDLLibName.}
-  # This is a semi-private blit function and it performs low-level surface
-  #  blitting only.
-proc SDL_LowerBlit*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface,
-                    dstrect: PSDL_Rect): int{.cdecl, importc, dynlib: SDLLibName.}
-  # This function performs a fast fill of the given rectangle with 'color'
-  #  The given rectangle is clipped to the destination surface clip area
-  #  and the final fill rectangle is saved in the passed in pointer.
-  #  If 'dstrect' is NULL, the whole surface will be filled with 'color'
-  #  The color should be a pixel of the format used by the surface, and
-  #  can be generated by the SDL_MapRGB() function.
-  #  This function returns 0 on success, or -1 on error.
-proc SDL_FillRect*(dst: PSDL_Surface, dstrect: PSDL_Rect, color: UInt32): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer, suitable for fast
-  #  blitting onto the display surface.  It calls SDL_ConvertSurface()
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc SDL_DisplayFormat*(surface: PSDL_Surface): PSDL_Surface{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer (if possible),
-  #  suitable for fast alpha blitting onto the display surface.
-  #  The new surface will always have an alpha channel.
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc SDL_DisplayFormatAlpha*(surface: PSDL_Surface): PSDL_Surface{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  #* YUV video surface overlay functions                                       */
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  # This function creates a video output overlay
-  #  Calling the returned surface an overlay is something of a misnomer because
-  #  the contents of the display surface underneath the area where the overlay
-  #  is shown is undefined - it may be overwritten with the converted YUV data.
-proc SDL_CreateYUVOverlay*(width: int, height: int, format: UInt32,
-                           display: PSDL_Surface): PSDL_Overlay{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Lock an overlay for direct access, and unlock it when you are done
-proc SDL_LockYUVOverlay*(Overlay: PSDL_Overlay): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_UnlockYUVOverlay*(Overlay: PSDL_Overlay){.cdecl, importc, dynlib: SDLLibName.}
-  # Blit a video overlay to the display surface.
-  #  The contents of the video surface underneath the blit destination are
-  #  not defined.
-  #  The width and height of the destination rectangle may be different from
-  #  that of the overlay, but currently only 2x scaling is supported.
-proc SDL_DisplayYUVOverlay*(Overlay: PSDL_Overlay, dstrect: PSDL_Rect): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Free a video overlay
-proc SDL_FreeYUVOverlay*(Overlay: PSDL_Overlay){.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # OpenGL Routines
-  #------------------------------------------------------------------------------
-  # Dynamically load a GL driver, if SDL is built with dynamic GL.
-  #
-  #  SDL links normally with the OpenGL library on your system by default,
-  #  but you can compile it to dynamically load the GL driver at runtime.
-  #  If you do this, you need to retrieve all of the GL functions used in
-  #  your program from the dynamic library using SDL_GL_GetProcAddress().
-  #
-  #  This is disabled in default builds of SDL.
-proc SDL_GL_LoadLibrary*(filename: cstring): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the address of a GL function (for extension functions)
-proc SDL_GL_GetProcAddress*(procname: cstring): Pointer{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Set an attribute of the OpenGL subsystem before intialization.
-proc SDL_GL_SetAttribute*(attr: TSDL_GLAttr, value: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get an attribute of the OpenGL subsystem from the windowing
-  #  interface, such as glX. This is of course different from getting
-  #  the values from SDL's internal OpenGL subsystem, which only
-  #  stores the values you request before initialization.
-  #
-  #  Developers should track the values they pass into SDL_GL_SetAttribute
-  #  themselves if they want to retrieve these values.
-proc SDL_GL_GetAttribute*(attr: TSDL_GLAttr, value: var int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Swap the OpenGL buffers, if double-buffering is supported.
-proc SDL_GL_SwapBuffers*(){.cdecl, importc, dynlib: SDLLibName.}
-  # Internal functions that should not be called unless you have read
-  #  and understood the source code for these functions.
-proc SDL_GL_UpdateRects*(numrects: int, rects: PSDL_Rect){.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_GL_Lock*(){.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_GL_Unlock*(){.cdecl, importc, dynlib: SDLLibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  #* These functions allow interaction with the window manager, if any.        *
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Sets/Gets the title and icon text of the display window
-proc SDL_WM_GetCaption*(title: var cstring, icon: var cstring){.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_WM_SetCaption*(title: cstring, icon: cstring){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Sets the icon for the display window.
-  #  This function must be called before the first call to SDL_SetVideoMode().
-  #  It takes an icon surface, and a mask in MSB format.
-  #  If 'mask' is NULL, the entire icon surface will be used as the icon.
-proc SDL_WM_SetIcon*(icon: PSDL_Surface, mask: UInt8){.cdecl, importc, dynlib: SDLLibName.}
-  # This function iconifies the window, and returns 1 if it succeeded.
-  #  If the function succeeds, it generates an SDL_APPACTIVE loss event.
-  #  This function is a noop and returns 0 in non-windowed environments.
-proc SDL_WM_IconifyWindow*(): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Toggle fullscreen mode without changing the contents of the screen.
-  #  If the display surface does not require locking before accessing
-  #  the pixel information, then the memory pointers will not change.
-  #
-  #  If this function was able to toggle fullscreen mode (change from
-  #  running in a window to fullscreen, or vice-versa), it will return 1.
-  #  If it is not implemented, or fails, it returns 0.
-  #
-  #  The next call to SDL_SetVideoMode() will set the mode fullscreen
-  #  attribute based on the flags parameter - if SDL_FULLSCREEN is not
-  #  set, then the display will be windowed by default where supported.
-  #
-  #  This is currently only implemented in the X11 video driver.
-proc SDL_WM_ToggleFullScreen*(surface: PSDL_Surface): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Grabbing means that the mouse is confined to the application window,
-  #  and nearly all keyboard input is passed directly to the application,
-  #  and not interpreted by a window manager, if any.
-proc SDL_WM_GrabInput*(mode: TSDL_GrabMode): TSDL_GrabMode{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # mouse-routines
-  #------------------------------------------------------------------------------
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  current mouse cursor position.  You can pass NULL for either x or y.
-proc SDL_GetMouseState*(x: var int, y: var int): UInt8{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  mouse deltas since the last call to SDL_GetRelativeMouseState().
-proc SDL_GetRelativeMouseState*(x: var int, y: var int): UInt8{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Set the position of the mouse cursor (generates a mouse motion event)
-proc SDL_WarpMouse*(x, y: UInt16){.cdecl, importc, dynlib: SDLLibName.}
-  # Create a cursor using the specified data and mask (in MSB format).
-  #  The cursor width must be a multiple of 8 bits.
-  #
-  #  The cursor is created in black and white according to the following:
-  #  data  mask    resulting pixel on screen
-  #   0     1       White
-  #   1     1       Black
-  #   0     0       Transparent
-  #   1     0       Inverted color if possible, black if not.
-  #
-  #  Cursors created with this function must be freed with SDL_FreeCursor().
-proc SDL_CreateCursor*(data, mask: PUInt8, w, h, hot_x, hot_y: int): PSDL_Cursor{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # Set the currently active cursor to the specified one.
-  #  If the cursor is currently visible, the change will be immediately
-  #  represented on the display.
-proc SDL_SetCursor*(cursor: PSDL_Cursor){.cdecl, importc, dynlib: SDLLibName.}
-  # Returns the currently active cursor.
-proc SDL_GetCursor*(): PSDL_Cursor{.cdecl, importc, dynlib: SDLLibName.}
-  # Deallocates a cursor created with SDL_CreateCursor().
-proc SDL_FreeCursor*(cursor: PSDL_Cursor){.cdecl, importc, dynlib: SDLLibName.}
-  # Toggle whether or not the cursor is shown on the screen.
-  #  The cursor start off displayed, but can be turned off.
-  #  SDL_ShowCursor() returns 1 if the cursor was being displayed
-  #  before the call, or 0 if it was not.  You can query the current
-  #  state by passing a 'toggle' value of -1.
-proc SDL_ShowCursor*(toggle: int): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_BUTTON*(Button: int): int
-  #------------------------------------------------------------------------------
-  # Keyboard-routines
-  #------------------------------------------------------------------------------
-  # Enable/Disable UNICODE translation of keyboard input.
-  #  This translation has some overhead, so translation defaults off.
-  #  If 'enable' is 1, translation is enabled.
-  #  If 'enable' is 0, translation is disabled.
-  #  If 'enable' is -1, the translation state is not changed.
-  #  It returns the previous state of keyboard translation.
-proc SDL_EnableUNICODE*(enable: int): int{.cdecl, importc, dynlib: SDLLibName.}
-  # If 'delay' is set to 0, keyboard repeat is disabled.
-proc SDL_EnableKeyRepeat*(delay: int, interval: int): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-proc SDL_GetKeyRepeat*(delay: PInteger, interval: PInteger){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get a snapshot of the current state of the keyboard.
-  #  Returns an array of keystates, indexed by the SDLK_* syms.
-  #  Used:
-  #
-  #  UInt8 *keystate = SDL_GetKeyState(NULL);
-  #  if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed
-proc SDL_GetKeyState*(numkeys: PInt): PUInt8{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the current key modifier state
-proc SDL_GetModState*(): TSDLMod{.cdecl, importc, dynlib: SDLLibName.}
-  # Set the current key modifier state
-  #  This does not change the keyboard state, only the key modifier flags.
-proc SDL_SetModState*(modstate: TSDLMod){.cdecl, importc, dynlib: SDLLibName.}
-  # Get the name of an SDL virtual keysym
-proc SDL_GetKeyName*(key: TSDLKey): cstring{.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # Active Routines
-  #------------------------------------------------------------------------------
-  # This function returns the current state of the application, which is a
-  #  bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
-  #  SDL_APPACTIVE.  If SDL_APPACTIVE is set, then the user is able to
-  #  see your application, otherwise it has been iconified or disabled.
-proc SDL_GetAppState*(): UInt8{.cdecl, importc, dynlib: SDLLibName.}
-  # Mutex functions
-  # Create a mutex, initialized unlocked
-proc SDL_CreateMutex*(): PSDL_Mutex{.cdecl, importc, dynlib: SDLLibName.}
-  # Lock the mutex  (Returns 0, or -1 on error)
-proc SDL_mutexP*(mutex: PSDL_mutex): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_LockMutex*(mutex: PSDL_mutex): int
-  # Unlock the mutex  (Returns 0, or -1 on error)
-proc SDL_mutexV*(mutex: PSDL_mutex): int{.cdecl, importc, dynlib: SDLLibName.}
-proc SDL_UnlockMutex*(mutex: PSDL_mutex): int
-  # Destroy a mutex
-proc SDL_DestroyMutex*(mutex: PSDL_mutex){.cdecl, importc, dynlib: SDLLibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Semaphore functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a semaphore, initialized with value, returns NULL on failure.
-proc SDL_CreateSemaphore*(initial_value: UInt32): PSDL_Sem{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Destroy a semaphore
-proc SDL_DestroySemaphore*(sem: PSDL_sem){.cdecl, importc, dynlib: SDLLibName.}
-  # This function suspends the calling thread until the semaphore pointed
-  #  to by sem has a positive count. It then atomically decreases the semaphore
-  #  count.
-proc SDL_SemWait*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
-  #   SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
-proc SDL_SemTryWait*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
-  #   the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
-  #   the allotted time, and -1 on error.
-  #   On some platforms this function is implemented by looping with a delay
-  #   of 1 ms, and so should be avoided if possible.
-proc SDL_SemWaitTimeout*(sem: PSDL_sem, ms: UInt32): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Atomically increases the semaphore's count (not blocking), returns 0,
-  #   or -1 on error.
-proc SDL_SemPost*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Returns the current count of the semaphore
-proc SDL_SemValue*(sem: PSDL_sem): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a condition variable
-proc SDL_CreateCond*(): PSDL_Cond{.cdecl, importc, dynlib: SDLLibName.}
-  # Destroy a condition variable
-proc SDL_DestroyCond*(cond: PSDL_Cond){.cdecl, importc, dynlib: SDLLibName.}
-  # Restart one of the threads that are waiting on the condition variable,
-  #   returns 0 or -1 on error.
-proc SDL_CondSignal*(cond: PSDL_cond): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Restart all threads that are waiting on the condition variable,
-  #  returns 0 or -1 on error.
-proc SDL_CondBroadcast*(cond: PSDL_cond): int{.cdecl, importc, dynlib: SDLLibName.}
-  # Wait on the condition variable, unlocking the provided mutex.
-  #  The mutex must be locked before entering this function!
-  #  Returns 0 when it is signaled, or -1 on error.
-proc SDL_CondWait*(cond: PSDL_cond, mut: PSDL_mutex): int{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Waits for at most 'ms' milliseconds, and returns 0 if the condition
-  #  variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
-  #  signaled in the allotted time, and -1 on error.
-  #  On some platforms this function is implemented by looping with a delay
-  #  of 1 ms, and so should be avoided if possible.
-proc SDL_CondWaitTimeout*(cond: PSDL_cond, mut: PSDL_mutex, ms: UInt32): int{.
-    cdecl, importc, dynlib: SDLLibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a thread
-proc SDL_CreateThread*(fn: PInt, data: Pointer): PSDL_Thread{.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Get the 32-bit thread identifier for the current thread
-proc SDL_ThreadID*(): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # Get the 32-bit thread identifier for the specified thread,
-  #  equivalent to SDL_ThreadID() if the specified thread is NULL.
-proc SDL_GetThreadID*(thread: PSDL_Thread): UInt32{.cdecl, importc, dynlib: SDLLibName.}
-  # Wait for a thread to finish.
-  #  The return code for the thread function is placed in the area
-  #  pointed to by 'status', if 'status' is not NULL.
-proc SDL_WaitThread*(thread: PSDL_Thread, status: var int){.cdecl,
-    importc, dynlib: SDLLibName.}
-  # Forcefully kill a thread without worrying about its state
-proc SDL_KillThread*(thread: PSDL_Thread){.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  # Get Environment Routines
-  #------------------------------------------------------------------------------
-  #*
-  # * This function gives you custom hooks into the window manager information.
-  # * It fills the structure pointed to by 'info' with custom information and
-  # * returns 1 if the function is implemented.  If it's not implemented, or
-  # * the version member of the 'info' structure is invalid, it returns 0.
-  # *
-proc SDL_GetWMInfo*(info: PSDL_SysWMinfo): int{.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-  #SDL_loadso.h
-  #* This function dynamically loads a shared object and returns a pointer
-  # * to the object handle (or NULL if there was an error).
-  # * The 'sofile' parameter is a system dependent name of the object file.
-  # *
-proc SDL_LoadObject*(sofile: cstring): Pointer{.cdecl, importc, dynlib: SDLLibName.}
-  #* Given an object handle, this function looks up the address of the
-  # * named function in the shared object and returns it.  This address
-  # * is no longer valid after calling SDL_UnloadObject().
-  # *
-proc SDL_LoadFunction*(handle: Pointer, name: cstring): Pointer{.cdecl,
-    importc, dynlib: SDLLibName.}
-  #* Unload a shared object from memory *
-proc SDL_UnloadObject*(handle: Pointer){.cdecl, importc, dynlib: SDLLibName.}
-  #------------------------------------------------------------------------------
-proc SDL_Swap32*(D: Uint32): Uint32
-  # Bitwise Checking functions
-proc IsBitOn*(value: int, bit: int8): bool
-proc TurnBitOn*(value: int, bit: int8): int
-proc TurnBitOff*(value: int, bit: int8): int
-# implementation
-
-proc SDL_TABLESIZE(table: cstring): int =
-  Result = SizeOf(table) div SizeOf(table[0])
-
-proc SDL_OutOfMemory() =
-  when not(defined(WINDOWS)): SDL_Error(SDL_ENOMEM)
-
-proc SDL_RWSeek(context: PSDL_RWops, offset: int, whence: int): int =
-  Result = context.seek(context, offset, whence)
-
-proc SDL_RWTell(context: PSDL_RWops): int =
-  Result = context.seek(context, 0, 1)
-
-proc SDL_RWRead(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int =
-  Result = context.read(context, theptr, size, n)
-
-proc SDL_RWWrite(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int =
-  Result = context.write(context, theptr, size, n)
-
-proc SDL_RWClose(context: PSDL_RWops): int =
-  Result = context.closeFile(context)
-
-proc SDL_LoadWAV(filename: cstring, spec: PSDL_AudioSpec, audio_buf: PUInt8,
-                 audiolen: PUInt32): PSDL_AudioSpec =
-  Result = SDL_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1, spec, audio_buf,
-                          audiolen)
-
-proc SDL_CDInDrive(status: TSDL_CDStatus): bool =
-  Result = ord(status) > ord(CD_ERROR)
-
-proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) =
-  var value: int
-  value = frames
-  F = value mod CD_FPS
-  value = value div CD_FPS
-  S = value mod 60
-  value = value div 60
-  M = value
-
-proc MSF_TO_FRAMES(M: int, S: int, F: int): int =
-  Result = M * 60 * CD_FPS + S * CD_FPS + F
-
-proc SDL_VERSION(X: var TSDL_Version) =
-  X.major = SDL_MAJOR_VERSION
-  X.minor = SDL_MINOR_VERSION
-  X.patch = SDL_PATCHLEVEL
-
-proc SDL_VERSIONNUM(X, Y, Z: int): int =
-  Result = X * 1000 + Y * 100 + Z
-
-proc SDL_COMPILEDVERSION(): int =
-  Result = SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
-
-proc SDL_VERSION_ATLEAST(X, Y, Z: int): bool =
-  Result = (SDL_COMPILEDVERSION() >= SDL_VERSIONNUM(X, Y, Z))
-
-proc SDL_LoadBMP(filename: cstring): PSDL_Surface =
-  Result = SDL_LoadBMP_RW(SDL_RWFromFile(filename, "rb"), 1)
-
-proc SDL_SaveBMP(surface: PSDL_Surface, filename: cstring): int =
-  Result = SDL_SaveBMP_RW(surface, SDL_RWFromFile(filename, "wb"), 1)
-
-proc SDL_BlitSurface(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface,
-                     dstrect: PSDL_Rect): int =
-  Result = SDL_UpperBlit(src, srcrect, dst, dstrect)
-
-proc SDL_AllocSurface(flags: UInt32, width, height, depth: int,
-                      RMask, GMask, BMask, AMask: UInt32): PSDL_Surface =
-  Result = SDL_CreateRGBSurface(flags, width, height, depth, RMask, GMask,
-                                BMask, AMask)
-
-proc SDL_MustLock(Surface: PSDL_Surface): bool =
-  Result = ((surface^ .offset != 0) or
-      ((surface^ .flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) !=
-      0))
-
-proc SDL_LockMutex(mutex: PSDL_mutex): int =
-  Result = SDL_mutexP(mutex)
-
-proc SDL_UnlockMutex(mutex: PSDL_mutex): int =
-  Result = SDL_mutexV(mutex)
-
-proc SDL_BUTTON(Button: int): int =
-  Result = SDL_PRESSED shl (Button - 1)
-
-proc SDL_Swap32(D: Uint32): Uint32 =
-  Result = ((D shl 24) or ((D shl 8) and 0x00FF0000) or
-      ((D shr 8) and 0x0000FF00) or (D shr 24))
-
-proc IsBitOn(value: int, bit: int8): bool =
-  result = ((value and (1 shl ze(bit))) != 0)
-
-proc TurnBitOn(value: int, bit: int8): int =
-  result = (value or (1 shl ze(bit)))
-
-proc TurnBitOff(value: int, bit: int8): int =
-  result = (value and not (1 shl ze(bit)))
diff --git a/lib/oldwrappers/sdl/sdl_gfx.nim b/lib/oldwrappers/sdl/sdl_gfx.nim
deleted file mode 100755
index 8ae8eca0b..000000000
--- a/lib/oldwrappers/sdl/sdl_gfx.nim
+++ /dev/null
@@ -1,421 +0,0 @@
-
-#
-#  $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
-#
-#
-#
-#  $Log: sdl_gfx.pas,v $
-#  Revision 1.3  2007/05/29 21:31:04  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.2  2007/05/20 20:30:18  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.1  2005/01/03 19:08:32  savage
-#  Header for the SDL_Gfx library.
-#
-#
-#
-#
-
-import
-  sdl
-
-when defined(windows):
-  const SDLgfxLibName = "SDL_gfx.dll"
-elif defined(macosx):
-  const SDLgfxLibName = "libSDL_gfx.dylib"
-else:
-  const SDLgfxLibName = "libSDL_gfx.so"
-
-const                         # Some rates in Hz
-  FPS_UPPER_LIMIT* = 200
-  FPS_LOWER_LIMIT* = 1
-  FPS_DEFAULT* = 30           # ---- Defines
-  SMOOTHING_OFF* = 0
-  SMOOTHING_ON* = 1
-
-type 
-  PFPSmanager* = ptr TFPSmanager
-  TFPSmanager*{.final.} = object  # ---- Structures
-    framecount*: Uint32
-    rateticks*: float32
-    lastticks*: Uint32
-    rate*: Uint32
-
-  PColorRGBA* = ptr TColorRGBA
-  TColorRGBA*{.final.} = object 
-    r*: Uint8
-    g*: Uint8
-    b*: Uint8
-    a*: Uint8
-
-  PColorY* = ptr TColorY
-  TColorY*{.final.} = object  #
-                              #
-                              # SDL_framerate: framerate manager
-                              #
-                              # LGPL (c) A. Schiffler
-                              #
-                              #
-    y*: Uint8
-
-
-proc SDL_initFramerate*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
-proc SDL_setFramerate*(manager: PFPSmanager, rate: int): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc SDL_getFramerate*(manager: PFPSmanager): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc SDL_framerateDelay*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.}
-  #
-  #
-  # SDL_gfxPrimitives: graphics primitives for SDL
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Note: all ___Color routines expect the color to be in format 0xRRGGBBAA 
-  # Pixel 
-proc pixelColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, color: Uint32): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-proc pixelRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Uint8, g: Uint8, 
-                b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Horizontal line 
-proc hlineColor*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, 
-                 color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc hlineRGBA*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, r: Uint8, 
-                g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Vertical line 
-proc vlineColor*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, 
-                 color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc vlineRGBA*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, r: Uint8, 
-                g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Rectangle 
-proc rectangleColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                     y2: Sint16, color: Uint32): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc rectangleRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                    y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Filled rectangle (Box) 
-proc boxColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-               y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc boxRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16, 
-              r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Line 
-proc lineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc lineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-               y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # AA Line 
-proc aalineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                  y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc aalineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                 y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Circle 
-proc circleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, 
-                  color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc circleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8, 
-                 g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # AA Circle 
-proc aacircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, 
-                    color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc aacircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-                   r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Filled Circle 
-proc filledCircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, 
-                        color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc filledCircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-                       r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Ellipse 
-proc ellipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, 
-                   ry: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc ellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, 
-                  ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # AA Ellipse 
-proc aaellipseColor*(dst: PSDL_Surface, xc: Sint16, yc: Sint16, rx: Sint16, 
-                     ry: Sint16, color: Uint32): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc aaellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, 
-                    ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Filled Ellipse 
-proc filledEllipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, 
-                         ry: Sint16, color: Uint32): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc filledEllipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, 
-                        ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Pie
-proc pieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-               start: Sint16, finish: Sint16, color: Uint32): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc pieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-              start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8, 
-              a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Filled Pie
-proc filledPieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-                     start: Sint16, finish: Sint16, color: Uint32): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc filledPieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, 
-                    start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8, 
-                    a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Trigon
-proc trigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                  y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-proc trigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                 y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, 
-                 b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # AA-Trigon
-proc aatrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                    y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-proc aatrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                   y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, 
-                   b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Filled Trigon
-proc filledTrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                        y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-proc filledTrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, 
-                       y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, 
-                       b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Polygon
-proc polygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, 
-                   color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc polygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, r: Uint8, 
-                  g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # AA-Polygon
-proc aapolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, 
-                     color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc aapolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, 
-                    r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Filled Polygon
-proc filledPolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, 
-                         color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc filledPolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, 
-                        r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Bezier
-  # s = number of steps
-proc bezierColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int, 
-                  color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc bezierRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int, 
-                 r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Characters/Strings
-proc characterColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, 
-                     color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc characterRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, r: Uint8, 
-                    g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc stringColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, 
-                  color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc stringRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, r: Uint8, 
-                 g: Uint8, b: Uint8, a: Uint8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: int, ch: int){.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #
-  #
-  # SDL_imageFilter - bytes-image "filter" routines
-  # (uses inline x86 MMX optimizations if available)
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Comments:                                                                           
-  #  1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. 
-  #  2.) Data that is not within an 8 byte boundary is processed using the C routine.   
-  #  3.) Convolution routines do not have C routines at this time.                      
-  # Detect MMX capability in CPU
-proc SDL_imageFilterMMXdetect*(): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  # Force use of MMX off (or turn possible use back on)
-proc SDL_imageFilterMMXoff*(){.cdecl, importc, dynlib: SDLgfxLibName.}
-proc SDL_imageFilterMMXon*(){.cdecl, importc, dynlib: SDLgfxLibName.}
-  #
-  # All routines return:
-  #   0   OK
-  #  -1   Error (internal error, parameter error)
-  #
-  #  SDL_imageFilterAdd: D = saturation255(S1 + S2)
-proc SDL_imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMean: D = S1/2 + S2/2
-proc SDL_imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterSub: D = saturation0(S1 - S2)
-proc SDL_imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterAbsDiff: D = | S1 - S2 |
-proc SDL_imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                             len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMult: D = saturation(S1 * S2)
-proc SDL_imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMultNor: D = S1 * S2   (non-MMX)
-proc SDL_imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                             len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
-proc SDL_imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                                len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
-proc SDL_imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                                len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterBitAnd: D = S1 & S2
-proc SDL_imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                            len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterBitOr: D = S1 | S2
-proc SDL_imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterDiv: D = S1 / S2   (non-MMX)
-proc SDL_imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterBitNegation: D = !S
-proc SDL_imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterAddByte: D = saturation255(S + C)
-proc SDL_imageFilterAddByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
-proc SDL_imageFilterAddUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
-proc SDL_imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: int, 
-                                   C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterSubByte: D = saturation0(S - C)
-proc SDL_imageFilterSubByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
-proc SDL_imageFilterSubUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftRight: D = saturation0(S >> N)
-proc SDL_imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
-proc SDL_imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: int, 
-                                    N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterMultByByte: D = saturation255(S * C)
-proc SDL_imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
-proc SDL_imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring, 
-    len: int, N: char, C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftLeftByte: D = (S << N)
-proc SDL_imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: int, 
-                                   N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
-proc SDL_imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: int, 
-                                   N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterShiftLeft: D = saturation255(S << N)
-proc SDL_imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
-proc SDL_imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring, 
-    len: int, T: char): int{.cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
-proc SDL_imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: int, 
-                                 Tmin: int8, Tmax: int8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
-proc SDL_imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: int, 
-                                     Cmin: int, Cmax: int, Nmin: int, Nmax: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! 
-  #  SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
-proc SDL_imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterSobelX: Dij = saturation255( ... )
-proc SDL_imageFilterSobelX*(Src: cstring, Dest: cstring, rows: int, columns: int): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  #  SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
-proc SDL_imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: int, 
-                                      columns: int, NRightShift: char): int{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Align/restore stack to 32 byte boundary -- Functionality untested! --
-proc SDL_imageFilterAlignStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
-proc SDL_imageFilterRestoreStack*(){.cdecl, importc, dynlib: SDLgfxLibName.}
-  #
-  #
-  # SDL_rotozoom - rotozoomer
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # 
-  # 
-  # rotozoomSurface()
-  #
-  # Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc rotozoomSurface*(src: PSDL_Surface, angle: float64, zoom: float64, 
-                      smooth: int): PSDL_Surface{.cdecl, importc, dynlib: SDLgfxLibName.}
-proc rotozoomSurfaceXY*(src: PSDL_Surface, angle: float64, zoomx: float64, 
-                        zoomy: float64, smooth: int): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-  # Returns the size of the target surface for a rotozoomSurface() call 
-proc rotozoomSurfaceSize*(width: int, height: int, angle: float64, 
-                          zoom: float64, dstwidth: var int, dstheight: var int){.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-proc rotozoomSurfaceSizeXY*(width: int, height: int, angle: float64, 
-                            zoomx: float64, zoomy: float64, dstwidth: var int, 
-                            dstheight: var int){.cdecl, importc, dynlib: SDLgfxLibName.}
-  #
-  #
-  # zoomSurface()
-  #
-  # Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc zoomSurface*(src: PSDL_Surface, zoomx: float64, zoomy: float64, smooth: int): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLgfxLibName.}
-  # Returns the size of the target surface for a zoomSurface() call 
-proc zoomSurfaceSize*(width: int, height: int, zoomx: float64, zoomy: float64, 
-                      dstwidth: var int, dstheight: var int){.cdecl, 
-    importc, dynlib: SDLgfxLibName.}
-# implementation
diff --git a/lib/oldwrappers/sdl/sdl_image.nim b/lib/oldwrappers/sdl/sdl_image.nim
deleted file mode 100755
index a15afd575..000000000
--- a/lib/oldwrappers/sdl/sdl_image.nim
+++ /dev/null
@@ -1,227 +0,0 @@
-
-#
-#  $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
-#  
-#
-#******************************************************************************
-#                                                                              
-#       Borland Delphi SDL_Image - An example image loading library for use    
-#                                  with SDL                                    
-#       Conversion of the Simple DirectMedia Layer Image Headers               
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_image.h                                         
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Dominique Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#   A simple library to load images of various formats as SDL surfaces         
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas in your search path.                                               
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#   See the Aliens Demo on how to make use of this libaray                     
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April    02 2001 - MT : Initial Translation                                
-#                                                                              
-#   May      08 2001 - DL : Added ExternalSym derectives and copyright header  
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_image.pas,v $
-#  Revision 1.14  2007/05/29 21:31:13  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.13  2007/05/20 20:30:54  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.12  2006/12/02 00:14:40  savage
-#  Updated to latest version
-#
-#  Revision 1.11  2005/04/10 18:22:59  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.10  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.9  2005/01/05 01:47:07  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.8  2005/01/04 23:14:44  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.7  2005/01/01 02:03:12  savage
-#  Updated to v1.2.4
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows):
-  const SDL_ImageLibName = "SDL_Image.dll"
-elif defined(macosx):
-  const SDL_ImageLibName = "libSDL_image-1.2.0.dylib"
-else:
-  const SDL_ImageLibName = "libSDL_image.so"
-
-const
-  SDL_IMAGE_MAJOR_VERSION* = 1'i8
-  SDL_IMAGE_MINOR_VERSION* = 2'i8
-  SDL_IMAGE_PATCHLEVEL* = 5'i8
-  
-# This macro can be used to fill a version structure with the compile-time
-#  version of the SDL_image library. 
-
-proc SDL_IMAGE_VERSION*(X: var TSDL_Version)
-  # This function gets the version of the dynamically linked SDL_image library.
-  #   it should NOT be used to fill a version structure, instead you should
-  #   use the SDL_IMAGE_VERSION() macro.
-  # 
-proc IMG_Linked_Version*(): PSDL_version{.importc, dynlib: SDL_ImageLibName.}
-  # Load an image from an SDL data source.
-  #   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
-  #
-  #   If the image format supports a transparent pixel, SDL will set the
-  #   colorkey for the surface.  You can enable RLE acceleration on the
-  #   surface afterwards by calling:
-  #        SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
-  #
-proc IMG_LoadTyped_RW*(src: PSDL_RWops, freesrc: int, theType: cstring): PSDL_Surface{.
-    cdecl, importc, dynlib: SDL_ImageLibName.}
-  # Convenience functions 
-proc IMG_Load*(theFile: cstring): PSDL_Surface{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_Load_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-  # Invert the alpha of a surface for use with OpenGL
-  #  This function is now a no-op, and only provided for backwards compatibility. 
-proc IMG_InvertAlpha*(theOn: int): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-  # Functions to detect a file type, given a seekable source 
-proc IMG_isBMP*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isGIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isJPG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isLBM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isPCX*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isPNG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isPNM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isTIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isXCF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isXPM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-proc IMG_isXV*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.}
-  # Individual loading functions 
-proc IMG_LoadBMP_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadGIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadJPG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadLBM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadPCX_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadPNM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadPNG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadTGA_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadTIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadXCF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadXPM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_LoadXV_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDL_ImageLibName.}
-  # Error Macros 
-  # We'll use SDL for reporting errors 
-proc IMG_SetError*(fmt: cstring)
-proc IMG_GetError*(): cstring
-# implementation
-
-proc SDL_IMAGE_VERSION(X: var TSDL_Version) = 
-  X.major = SDL_IMAGE_MAJOR_VERSION
-  X.minor = SDL_IMAGE_MINOR_VERSION
-  X.patch = SDL_IMAGE_PATCHLEVEL
-
-proc IMG_SetError(fmt: cstring) = 
-  SDL_SetError(fmt)
-
-proc IMG_GetError(): cstring = 
-  result = SDL_GetError()
diff --git a/lib/oldwrappers/sdl/sdl_mixer.nim b/lib/oldwrappers/sdl/sdl_mixer.nim
deleted file mode 100755
index a17ef09d4..000000000
--- a/lib/oldwrappers/sdl/sdl_mixer.nim
+++ /dev/null
@@ -1,737 +0,0 @@
-
-#******************************************************************************
-#
-#  $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
-#
-#
-#
-#       Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
-#       Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL_mixer.h
-#                          music_cmd.h
-#                          wavestream.h
-#                          timidity.h
-#                          playmidi.h
-#                          music_ogg.h
-#                          mikmod.h
-#
-# The initial developer of this Pascal code was :
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominqiue Louis are
-# Copyright (C) 2000 - 2001 Dominqiue Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   SDL.pas & SMPEG.pas somewhere within your search path.
-#
-# Programming Notes
-# -----------------
-#   See the Aliens Demo to see how this library is used
-#
-# Revision History
-# ----------------
-#   April    02 2001 - DL : Initial Translation
-#
-#  February  02 2002 - DL : Update to version 1.2.1
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#  $Log: sdl_mixer.pas,v $
-#  Revision 1.18  2007/05/29 21:31:44  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.17  2007/05/20 20:31:17  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.16  2006/12/02 00:16:17  savage
-#  Updated to latest version
-#
-#  Revision 1.15  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.14  2005/02/24 20:20:07  savage
-#  Changed definition of MusicType and added GetMusicType function
-#
-#  Revision 1.13  2005/01/05 01:47:09  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.12  2005/01/04 23:14:56  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.11  2005/01/01 02:05:19  savage
-#  Updated to v1.2.6
-#
-#  Revision 1.10  2004/09/12 21:45:17  savage
-#  Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
-#
-#  Revision 1.9  2004/08/27 21:48:24  savage
-#  IFDEFed out Smpeg support on MacOS X
-#
-#  Revision 1.8  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.7  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.6  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.5  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.4  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.3  2004/03/31 10:05:08  savage
-#  Better defines for Endianess under FreePascal and Borland compilers.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import
-  sdl, smpeg
-
-when defined(windows):
-  const SDL_MixerLibName = "SDL_mixer.dll"
-elif defined(macosx):
-  const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else:
-  const SDL_MixerLibName = "libSDL_mixer.so"
-
-const
-  SDL_MIXER_MAJOR_VERSION* = 1'i8
-  SDL_MIXER_MINOR_VERSION* = 2'i8
-  SDL_MIXER_PATCHLEVEL* = 7'i8   # Backwards compatibility
-  MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
-  MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
-  MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
-                                         # The default mixer has 8 simultaneous mixing channels
-  MIX_CHANNELS* = 8           # Good default values for a PC soundcard
-  MIX_DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32):
-  const
-    MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
-else:
-  const
-    MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
-const
-  MIX_DEFAULT_CHANNELS* = 2
-  MIX_MAX_VOLUME* = 128       # Volume of a chunk
-  PATH_MAX* = 255             # mikmod.h constants
-                              #*
-                              #  * Library version
-                              #  *
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr TMusicCMD
-  TMusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr TWAVStream
-  TWAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: Pointer
-    start*: int32
-    stop*: int32
-    cvt*: TSDL_AudioCVT
-
-  PMidiEvent* = ptr TMidiEvent
-  TMidiEvent*{.final.} = object
-    time*: int32
-    channel*: uint8
-    typ*: uint8
-    a*: uint8
-    b*: uint8
-
-  PMidiSong* = ptr TMidiSong
-  TMidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr TOGG_Music
-  TOGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: int
-    volume*: int              #vf: OggVorbis_File;
-    section*: int
-    cvt*: TSDL_AudioCVT
-    len_available*: int
-    snd_available*: PUint8
-
-  TErrorEnum* = enum
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr TMODULE
-  TMODULE*{.final.} = object
-  PUNIMOD* = ptr TUNIMOD
-  TUNIMOD* = TMODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk
-  PMix_Chunk* = ptr TMix_Chunk
-  TMix_Chunk*{.final.} = object
-    allocated*: int
-    abuf*: PUint8
-    alen*: Uint32
-    volume*: Uint8            # Per-sample volume, 0-128
-
-  Mix_Chunk* = TMix_Chunk     # The different fading types supported
-  TMix_Fading* = enum
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  Mix_Fading* = TMix_Fading
-  TMix_MusicType* = enum
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
-  Mix_MusicType* = TMix_MusicType #
-                                  #  TMusicUnion = record
-                                  #    case XXX: Byte of
-                                  #      0 : ( cmd : PMusicCMD );
-                                  #      1 : ( wave : PWAVStream );
-                                  #      2 : ( module : PUNIMOD );
-                                  #      3 : ( midi : TMidiSong );
-                                  #      4 : ( ogg : POGG_music );
-                                  #      {$IFNDEF DARWIN}
-                                  #      5 : ( mp3 : PSMPEG );
-                                  #      {$ENDIF}
-                                  #  end;
-  PMix_Music* = ptr TMix_Music
-  TMix_Music*{.final.} = object  # The internal format for a music chunk interpreted via mikmod
-    typ*: TMix_MusicType      # other fields are not aviable
-                              #    data : TMusicUnion;
-                              #    fading : TMix_Fading;
-                              #    fade_volume : integer;
-                              #    fade_step : integer;
-                              #    fade_steps : integer;
-                              #    error : integer;
-
-  TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library.
-
-proc SDL_MIXER_VERSION*(X: var TSDL_Version)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro.
-proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Open the mixer with a certain audio format
-proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
-                    chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  #
-proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  #
-proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
-    cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file
-proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
-proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer
-proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Free an audio chunk previously loaded
-proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  #
-proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  #
-proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Get a pointer to the user data for the current music hook
-proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type
-  TChannel_finished* = proc (channel: int){.cdecl.}
-
-proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-const
-  MIX_CHANNEL_POST* = - 2
-    # This is the format of a special effect callback:
-    #      myeffect(int chan, void *stream, int len, void *udata);
-    #
-    #    (chan) is the channel number that your effect is affecting. (stream) is
-    #     the buffer of data to work upon. (len) is the size of (stream), and
-    #     (udata) is a user-defined bit of data, which you pass as the last arg of
-    #     Mix_RegisterEffect(), and is passed back unmolested to your callback.
-    #     Your effect changes the contents of (stream) based on whatever parameters
-    #     are significant, or just leaves it be, if you prefer. You can do whatever
-    #     you like to the buffer, though, and it will continue in its changed state
-    #     down the mixing pipeline, through any other effect functions, then finally
-    #     to be mixed with the rest of the channels and music for the final output
-    #     stream.
-    #
-
-type
-  TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
-                           udata: Pointer): Pointer{.cdecl.}
-    #   * This is a callback that signifies that a channel has finished all its
-    #   *  loops and has completed playback. This gets called if the buffer
-    #   *  plays out normally, or if you call Mix_HaltChannel(), implicitly stop
-    #   *  a channel via Mix_AllocateChannels(), or unregister a callback while
-    #   *  it's still playing.
-  TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
-    #* Register a special effect function. At mixing time, the channel data is
-    #  *  copied into a buffer and passed through each registered effect function.
-    #  *  After it passes through all the functions, it is mixed into the final
-    #  *  output stream. The copy to buffer is performed once, then each effect
-    #  *  function performs on the output of the previous effect. Understand that
-    #  *  this extra copy to a buffer is not performed if there are no effects
-    #  *  registered for a given chunk, which saves CPU cycles, and any given
-    #  *  effect will be extra cycles, too, so it is crucial that your code run
-    #  *  fast. Also note that the data that your function is given is in the
-    #  *  format of the sound device, and not the format you gave to Mix_OpenAudio(),
-    #  *  although they may in reality be the same. This is an unfortunate but
-    #  *  necessary speed concern. Use Mix_QuerySpec() to determine if you can
-    #  *  handle the data before you register your effect, and take appropriate
-    #  *  actions.
-    #  * You may also specify a callback (Mix_EffectDone_t) that is called when
-    #  *  the channel finishes playing. This gives you a more fine-grained control
-    #  *  than Mix_ChannelFinished(), in case you need to free effect-specific
-    #  *  resources, etc. If you don't need this, you can specify NULL.
-    #  * You may set the callbacks before or after calling Mix_PlayChannel().
-    #  * Things like Mix_SetPanning() are just internal special effect functions,
-    #  *  so if you are using that, you've already incurred the overhead of a copy
-    #  *  to a separate buffer, and that these effects will be in the queue with
-    #  *  any functions you've registered. The list of registered effects for a
-    #  *  channel is reset when a chunk finishes playing, so you need to explicitly
-    #  *  set them with each call to Mix_PlayChannel*().
-    #  * You may also register a special effect function that is to be run after
-    #  *  final mixing occurs. The rules for these callbacks are identical to those
-    #  *  in Mix_RegisterEffect, but they are run after all the channels and the
-    #  *  music have been mixed into a single stream, whereas channel-specific
-    #  *  effects run on a given channel before any other mixing occurs. These
-    #  *  global effect callbacks are call "posteffects". Posteffects only have
-    #  *  their Mix_EffectDone_t function called when they are unregistered (since
-    #  *  the main output stream is never "done" in the same sense as a channel).
-    #  *  You must unregister them manually when you've had enough. Your callback
-    #  *  will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
-    #  *  processing is considered a posteffect.
-    #  *
-    #  * After all these effects have finished processing, the callback registered
-    #  *  through Mix_SetPostMix() runs, and then the stream goes to the audio
-    #  *  device.
-    #  *
-    #  * returns zero if error (no such channel), nonzero if added.
-    #  *  Error messages can be retrieved from Mix_GetError().
-    #  *
-
-proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
-                         arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #* You may not need to call this explicitly, unless you need to stop an
-  # *  effect from processing in the middle of a chunk's playback.
-  # * Posteffects are never implicitly unregistered as they are for channels,
-  # *  but they may be explicitly unregistered through this function by
-  # *  specifying MIX_CHANNEL_POST for a channel.
-  # * returns zero if error (no such channel or effect), nonzero if removed.
-  # *  Error messages can be retrieved from Mix_GetError().
-  # *
-proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  #* You may not need to call this explicitly, unless you need to stop all
-  #  * effects from processing in the middle of a chunk's playback. Note that
-  #  * this will also shut off some internal effect processing, since
-  #  * Mix_SetPanning( ) and others may use this API under the hood.This is
-  #  * called internally when a channel completes playback.
-  #  * Posteffects are never implicitly unregistered as they are for channels,
-  #  * but they may be explicitly unregistered through this function by
-  #  * specifying MIX_CHANNEL_POST for a channel.
-  #  * returns zero if error( no such channel ), nonzero if all effects removed.
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  *
-proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-const
-  MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
-    #  * These are the internally - defined mixing effects.They use the same API that
-    #  * effects defined in the application use, but are provided here as a
-    #  * convenience.Some effects can reduce their quality or use more memory in
-    #  * the name of speed; to enable this, make sure the environment variable
-    #  * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
-    #  * Mix_OpenAudio( ).
-    #  *
-    #* set the panning of a channel.The left and right channels are specified
-    #  * as integers between 0 and 255, quietest to loudest, respectively.
-    #  *
-    #  * Technically, this is just individual volume control for a sample with
-    #  * two( stereo )channels, so it can be used for more than just panning.
-    #  * if you want real panning, call it like this :
-    #  *
-    #  * Mix_SetPanning( channel, left, 255 - left );
-    #  *
-    #  * ...which isn't so hard.
-    #  *
-    #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-    #  * the panning will be done to the final mixed stream before passing it on
-    #  * to the audio device.
-    #  *
-    #  * This uses the Mix_RegisterEffect( )API internally, and returns without
-    #  * registering the effect function if the audio device is not configured
-    #  * for stereo output.Setting both( left ) and ( right ) to 255 causes this
-    #  * effect to be unregistered, since that is the data's normal state.
-    #  *
-    #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-    #  * nonzero if panning effect enabled.Note that an audio device in mono
-    #  * mode is a no - op, but this call will return successful in that case .
-    #  * Error messages can be retrieved from Mix_GetError( ).
-    #  *
-
-proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # * set the position ofa channel.( angle ) is an integer from 0 to 360, that
-  #    * specifies the location of the sound in relation to the listener.( angle )
-  #    * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
-  #    * Angle 0 is due north, and rotates clockwise as the value increases.
-  #    * for efficiency, the precision of this effect may be limited( angles 1
-  #    * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
-  #    * ( distance ) is an integer between 0 and 255 that specifies the space
-  #    * between the sound and the listener.The larger the number, the further
-  #    * away the sound is .Using 255 does not guarantee that the channel will be
-  #    * culled from the mixing process or be completely silent.For efficiency,
-  #    * the precision of this effect may be limited( distance 0 through 5 might
-  #    * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
-  #    * and ( distance ) to 0 unregisters this effect, since the data would be
-  #    * unchanged.
-  #    *
-  #    * if you need more precise positional audio, consider using OpenAL for
-  #    * spatialized effects instead of SDL_mixer.This is only meant to be a
-  #    * basic effect for simple "3D" games.
-  #    *
-  #    * if the audio device is configured for mono output, then you won't get
-  #    * any effectiveness from the angle; however, distance attenuation on the
-  #  * channel will still occur.While this effect will function with stereo
-  #  * voices, it makes more sense to use voices with only one channel of sound,
-  #  * so when they are mixed through this effect, the positioning will sound
-  #  * correct.You can convert them to mono through SDL before giving them to
-  #  * the mixer in the first place if you like.
-  #  *
-  #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #  * the positioning will be done to the final mixed stream before passing it
-  #  * on to the audio device.
-  #  *
-  #  * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if position effect is enabled.
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  *
-proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  #* set the "distance" of a channel.( distance ) is an integer from 0 to 255
-  #  * that specifies the location of the sound in relation to the listener.
-  #  * Distance 0 is overlapping the listener, and 255 is as far away as possible
-  #  * A distance of 255 does not guarantee silence; in such a case , you might
-  #  * want to try changing the chunk's volume, or just cull the sample from the
-  #  * mixing process with Mix_HaltChannel( ).
-  #    * for efficiency, the precision of this effect may be limited( distances 1
-  #    * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
-  #    * ( distance ) is an integer between 0 and 255 that specifies the space
-  #    * between the sound and the listener.The larger the number, the further
-  #    * away the sound is .
-  #    * Setting( distance ) to 0 unregisters this effect, since the data would be
-  #    * unchanged.
-  #    * if you need more precise positional audio, consider using OpenAL for
-  #    * spatialized effects instead of SDL_mixer.This is only meant to be a
-  #    * basic effect for simple "3D" games.
-  #    *
-  #    * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #    * the distance attenuation will be done to the final mixed stream before
-  #    * passing it on to the audio device.
-  #    *
-  #  * This uses the Mix_RegisterEffect( )API internally.
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if position effect is enabled.
-  #    * Error messages can be retrieved from Mix_GetError( ).
-  #    *
-proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # *
-  #    * !!! FIXME : Haven't implemented, since the effect goes past the
-  #  * end of the sound buffer.Will have to think about this.
-  #  * - -ryan.
-  #  * /
-  #  { if 0
-  #  { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
-  #  * of echo to mix.0 is no echo, 255 is infinite( and probably not
-  #  * what you want ).
-  #  *
-  #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #  * the reverbing will be done to the final mixed stream before passing it on
-  #  * to the audio device.
-  #  *
-  #  * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
-  #  * of zero, the effect is unregistered, as the data is already in that state.
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if reversing effect is enabled.
-  #    * Error messages can be retrieved from Mix_GetError( ).
-  #    *
-  #    extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
-  #  #E ndif
-  # * Causes a channel to reverse its stereo.This is handy if the user has his
-  #    * speakers hooked up backwards, or you would like to have a minor bit of
-  #  * psychedelia in your sound code. : )Calling this function with ( flip )
-  #  * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
-  #  * the effect is unregistered.
-  #  *
-  #  * This uses the Mix_RegisterEffect( )API internally, and thus is probably
-  #  * more CPU intensive than having the user just plug in his speakers
-  #  * correctly.Mix_SetReverseStereo( )returns without registering the effect
-  #  * function if the audio device is not configured for stereo output.
-  #  *
-  #  * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
-  #  * on the final mixed stream before sending it on to the audio device( a
-  #  * posteffect ).
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if reversing effect is enabled.Note that an audio device in mono
-  #  * mode is a no - op, but this call will return successful in that case .
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  *
-proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # end of effects API. - -ryan. *
-  # Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
-  #   them dynamically to the next sample if requested with a -1 value below.
-  #   Returns the number of reserved channels.
-  #
-proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Channel grouping functions
-  # Attach a tag to a channel. A tag can be assigned to several mixer
-  #   channels, to form groups of channels.
-  #   If 'tag' is -1, the tag is removed (actually -1 is the tag used to
-  #   represent the group of all the channels).
-  #   Returns true if everything was OK.
-  #
-proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Assign several consecutive channels to a group
-proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Finds the first available channel in a group of channels
-proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Returns the number of channels in a group. This is also a subtle
-  #   way to get the total number of channels when 'tag' is -1
-  #
-proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Finds the "oldest" sample playing in a group of channels
-proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Finds the "most recent" (i.e. last) sample playing in a group of channels
-proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # The same as above, but the sound is played at most 'ticks' milliseconds
-proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
-                           ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Play an audio chunk on a specific channel.
-  #   If the specified channel is -1, play on the first free channel.
-  #   If 'loops' is greater than zero, loop the sound that many times.
-  #   If 'loops' is -1, loop inifinitely (~65000 times).
-  #   Returns which channel was used to play the sound.
-  #
-proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
-proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
-proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
-                             ms: int, ticks: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
-  # Set the volume in the range of 0-128 of a specific channel or chunk.
-  #   If the specified channel is -1, set volume for all channels.
-  #   Returns the original volume.
-  #   If the specified volume is -1, just return the current volume.
-  #
-proc Mix_Volume*(channel: int, volume: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Halt playing of a particular channel
-proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Change the expiration delay for a particular channel.
-  #   The sample will stop playing after the 'ticks' milliseconds have elapsed,
-  #   or remove the expiration if 'ticks' is -1
-  #
-proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Halt a channel, fading it out progressively till it's silent
-  #   The ms parameter indicates the number of milliseconds the fading
-  #   will take.
-  #
-proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Query the fading status of a channel
-proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Pause/Resume a particular channel
-proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Pause/Resume the music stream
-proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Set the current position in the music stream.
-  #  This returns 0 if successful, or -1 if it failed or isn't implemented.
-  #  This function is only implemented for MOD music formats (set pattern
-  #  order number) and for OGG music (set position in seconds), at the
-  #  moment.
-  #
-proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
-    importc, dynlib: SDL_MixerLibName.}
-  # Check the status of a specific channel.
-  #   If the specified channel is -1, check all channels.
-  #
-proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Stop music and set external music playback command
-proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Synchro value is set by MikMod from modules while playing
-proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #
-  #  Get the Mix_Chunk currently associated with a mixer channel
-  #    Returns nil if it's an invalid channel, or there's no chunk associated.
-  #
-proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Close the mixer, halting all playing audio
-proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # We'll use SDL for reporting errors
-proc Mix_SetError*(fmt: cstring)
-proc Mix_GetError*(): cstring
-# implementation
-
-proc SDL_MIXER_VERSION(X: var TSDL_version) =
-  X.major = SDL_MIXER_MAJOR_VERSION
-  X.minor = SDL_MIXER_MINOR_VERSION
-  X.patch = SDL_MIXER_PATCHLEVEL
-
-proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
-  result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
-
-proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
-  result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
-
-proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
-  result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
-proc Mix_SetError(fmt: cstring) =
-  SDL_SetError(fmt)
-
-proc Mix_GetError(): cstring =
-  result = SDL_GetError()
diff --git a/lib/oldwrappers/sdl/sdl_mixer_nosmpeg.nim b/lib/oldwrappers/sdl/sdl_mixer_nosmpeg.nim
deleted file mode 100755
index 879867607..000000000
--- a/lib/oldwrappers/sdl/sdl_mixer_nosmpeg.nim
+++ /dev/null
@@ -1,572 +0,0 @@
-
-#******************************************************************************
-# Copy of SDL_Mixer without smpeg dependency and mp3 support                    
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows):
-  const SDL_MixerLibName = "SDL_mixer.dll"
-elif defined(macosx):
-  const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else:
-  const SDL_MixerLibName = "libSDL_mixer.so"
-
-const                    
-  SDL_MIXER_MAJOR_VERSION* = 1'i8
-  SDL_MIXER_MINOR_VERSION* = 2'i8
-  SDL_MIXER_PATCHLEVEL* = 7'i8   # Backwards compatibility
-  MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION
-  MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION
-  MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants
-                                         # The default mixer has 8 simultaneous mixing channels 
-  MIX_CHANNELS* = 8           # Good default values for a PC soundcard 
-  MIX_DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32): 
-  const 
-    MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
-else: 
-  const 
-    MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
-const 
-  MIX_DEFAULT_CHANNELS* = 2
-  MIX_MAX_VOLUME* = 128       # Volume of a chunk 
-  PATH_MAX* = 255             # mikmod.h constants
-                              #*
-                              #  * Library version
-                              #  *
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr TMusicCMD
-  TMusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr TWAVStream
-  TWAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: Pointer
-    start*: int32
-    stop*: int32
-    cvt*: TSDL_AudioCVT
-
-  PMidiEvent* = ptr TMidiEvent
-  TMidiEvent*{.final.} = object 
-    time*: int32
-    channel*: uint8
-    typ*: uint8
-    a*: uint8
-    b*: uint8
-
-  PMidiSong* = ptr TMidiSong
-  TMidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr TOGG_Music
-  TOGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: int
-    volume*: int              #vf: OggVorbis_File;
-    section*: int
-    cvt*: TSDL_AudioCVT
-    len_available*: int
-    snd_available*: PUint8
-
-  TErrorEnum* = enum 
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, 
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, 
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, 
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, 
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, 
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, 
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, 
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, 
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, 
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, 
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, 
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, 
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, 
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, 
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, 
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, 
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, 
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, 
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr TMODULE
-  TMODULE*{.final.} = object 
-  PUNIMOD* = ptr TUNIMOD
-  TUNIMOD* = TMODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk 
-  PMix_Chunk* = ptr TMix_Chunk
-  TMix_Chunk*{.final.} = object 
-    allocated*: int
-    abuf*: PUint8
-    alen*: Uint32
-    volume*: Uint8            # Per-sample volume, 0-128 
-  
-  Mix_Chunk* = TMix_Chunk     # The different fading types supported 
-  TMix_Fading* = enum 
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  Mix_Fading* = TMix_Fading
-  TMix_MusicType* = enum 
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
-  PMix_Music* = ptr TMix_Music
-  TMix_Music*{.final.} = object 
-    typ*: TMix_MusicType
-
-  TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library. 
-
-proc SDL_MIXER_VERSION*(X: var TSDL_Version)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro. 
-proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Open the mixer with a certain audio format 
-proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, 
-                    chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  # 
-proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  # 
-proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
-    cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file 
-proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
-proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer 
-proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Free an audio chunk previously loaded 
-proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  # 
-proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  # 
-proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Get a pointer to the user data for the current music hook 
-proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type 
-  TChannel_finished* = proc (channel: int){.cdecl.}
-
-proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-const 
-  MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback:
-                          #   *
-                          #   *   myeffect(int chan, void *stream, int len, void *udata);
-                          #   *
-                          #   * (chan) is the channel number that your effect is affecting. (stream) is
-                          #   *  the buffer of data to work upon. (len) is the size of (stream), and
-                          #   *  (udata) is a user-defined bit of data, which you pass as the last arg of
-                          #   *  Mix_RegisterEffect(), and is passed back unmolested to your callback.
-                          #   *  Your effect changes the contents of (stream) based on whatever parameters
-                          #   *  are significant, or just leaves it be, if you prefer. You can do whatever
-                          #   *  you like to the buffer, though, and it will continue in its changed state
-                          #   *  down the mixing pipeline, through any other effect functions, then finally
-                          #   *  to be mixed with the rest of the channels and music for the final output
-                          #   *  stream.
-                          #   *
-
-type 
-  TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, 
-                           udata: Pointer): Pointer{.cdecl.} 
-    #   * This is a callback that signifies that a channel has finished all its
-    #   *  loops and has completed playback. This gets called if the buffer
-    #   *  plays out normally, or if you call Mix_HaltChannel(), implicitly stop
-    #   *  a channel via Mix_AllocateChannels(), or unregister a callback while
-    #   *  it's still playing.
-  TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
-    #* Register a special effect function. At mixing time, the channel data is
-    #  *  copied into a buffer and passed through each registered effect function.
-    #  *  After it passes through all the functions, it is mixed into the final
-    #  *  output stream. The copy to buffer is performed once, then each effect
-    #  *  function performs on the output of the previous effect. Understand that
-    #  *  this extra copy to a buffer is not performed if there are no effects
-    #  *  registered for a given chunk, which saves CPU cycles, and any given
-    #  *  effect will be extra cycles, too, so it is crucial that your code run
-    #  *  fast. Also note that the data that your function is given is in the
-    #  *  format of the sound device, and not the format you gave to Mix_OpenAudio(),
-    #  *  although they may in reality be the same. This is an unfortunate but
-    #  *  necessary speed concern. Use Mix_QuerySpec() to determine if you can
-    #  *  handle the data before you register your effect, and take appropriate
-    #  *  actions.
-    #  * You may also specify a callback (Mix_EffectDone_t) that is called when
-    #  *  the channel finishes playing. This gives you a more fine-grained control
-    #  *  than Mix_ChannelFinished(), in case you need to free effect-specific
-    #  *  resources, etc. If you don't need this, you can specify NULL.
-    #  * You may set the callbacks before or after calling Mix_PlayChannel().
-    #  * Things like Mix_SetPanning() are just internal special effect functions,
-    #  *  so if you are using that, you've already incurred the overhead of a copy
-    #  *  to a separate buffer, and that these effects will be in the queue with
-    #  *  any functions you've registered. The list of registered effects for a
-    #  *  channel is reset when a chunk finishes playing, so you need to explicitly
-    #  *  set them with each call to Mix_PlayChannel*().
-    #  * You may also register a special effect function that is to be run after
-    #  *  final mixing occurs. The rules for these callbacks are identical to those
-    #  *  in Mix_RegisterEffect, but they are run after all the channels and the
-    #  *  music have been mixed into a single stream, whereas channel-specific
-    #  *  effects run on a given channel before any other mixing occurs. These
-    #  *  global effect callbacks are call "posteffects". Posteffects only have
-    #  *  their Mix_EffectDone_t function called when they are unregistered (since
-    #  *  the main output stream is never "done" in the same sense as a channel).
-    #  *  You must unregister them manually when you've had enough. Your callback
-    #  *  will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
-    #  *  processing is considered a posteffect.
-    #  *
-    #  * After all these effects have finished processing, the callback registered
-    #  *  through Mix_SetPostMix() runs, and then the stream goes to the audio
-    #  *  device.
-    #  *
-    #  * returns zero if error (no such channel), nonzero if added.
-    #  *  Error messages can be retrieved from Mix_GetError().
-
-proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone, 
-                         arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #* You may not need to call this explicitly, unless you need to stop an
-  # *  effect from processing in the middle of a chunk's playback.
-  # * Posteffects are never implicitly unregistered as they are for channels,
-  # *  but they may be explicitly unregistered through this function by
-  # *  specifying MIX_CHANNEL_POST for a channel.
-  # * returns zero if error (no such channel or effect), nonzero if removed.
-  # *  Error messages can be retrieved from Mix_GetError().
-  # *
-proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  #* You may not need to call this explicitly, unless you need to stop all
-  #  * effects from processing in the middle of a chunk's playback. Note that
-  #  * this will also shut off some internal effect processing, since
-  #  * Mix_SetPanning( ) and others may use this API under the hood.This is
-  #  * called internally when a channel completes playback.
-  #  * Posteffects are never implicitly unregistered as they are for channels,
-  #  * but they may be explicitly unregistered through this function by
-  #  * specifying MIX_CHANNEL_POST for a channel.
-  #  * returns zero if error( no such channel ), nonzero if all effects removed.
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  *
-proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-const 
-  MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" 
-    #  * These are the internally - defined mixing effects.They use the same API that
-    #  * effects defined in the application use, but are provided here as a
-    #  * convenience.Some effects can reduce their quality or use more memory in
-    #  * the name of speed; to enable this, make sure the environment variable
-    #  * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
-    #  * Mix_OpenAudio( ).
-    #  * 
-    #* set the panning of a channel.The left and right channels are specified
-    #  * as integers between 0 and 255, quietest to loudest, respectively.
-    #  *
-    #  * Technically, this is just individual volume control for a sample with
-    #  * two( stereo )channels, so it can be used for more than just panning.
-    #  * if you want real panning, call it like this :
-    #  *
-    #  * Mix_SetPanning( channel, left, 255 - left );
-    #  *
-    #  * ...which isn't so hard.
-    #  *
-    #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-    #  * the panning will be done to the final mixed stream before passing it on
-    #  * to the audio device.
-    #  *
-    #  * This uses the Mix_RegisterEffect( )API internally, and returns without
-    #  * registering the effect function if the audio device is not configured
-    #  * for stereo output.Setting both( left ) and ( right ) to 255 causes this
-    #  * effect to be unregistered, since that is the data's normal state.
-    #  *
-    #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-    #  * nonzero if panning effect enabled.Note that an audio device in mono
-    #  * mode is a no - op, but this call will return successful in that case .
-    #  * Error messages can be retrieved from Mix_GetError( ).
-                                               
-
-proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # * set the position ofa channel.( angle ) is an integer from 0 to 360, that
-  #    * specifies the location of the sound in relation to the listener.( angle )
-  #    * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
-  #    * Angle 0 is due north, and rotates clockwise as the value increases.
-  #    * for efficiency, the precision of this effect may be limited( angles 1
-  #    * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
-  #    * ( distance ) is an integer between 0 and 255 that specifies the space
-  #    * between the sound and the listener.The larger the number, the further
-  #    * away the sound is .Using 255 does not guarantee that the channel will be
-  #    * culled from the mixing process or be completely silent.For efficiency,
-  #    * the precision of this effect may be limited( distance 0 through 5 might
-  #    * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
-  #    * and ( distance ) to 0 unregisters this effect, since the data would be
-  #    * unchanged.
-  #    *
-  #    * if you need more precise positional audio, consider using OpenAL for
-  #    * spatialized effects instead of SDL_mixer.This is only meant to be a
-  #    * basic effect for simple "3D" games.
-  #    *
-  #    * if the audio device is configured for mono output, then you won't get
-  #    * any effectiveness from the angle; however, distance attenuation on the
-  #  * channel will still occur.While this effect will function with stereo
-  #  * voices, it makes more sense to use voices with only one channel of sound,
-  #  * so when they are mixed through this effect, the positioning will sound
-  #  * correct.You can convert them to mono through SDL before giving them to
-  #  * the mixer in the first place if you like.
-  #  *
-  #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #  * the positioning will be done to the final mixed stream before passing it
-  #  * on to the audio device.
-  #  *
-  #  * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if position effect is enabled.
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  * 
-proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  #* set the "distance" of a channel.( distance ) is an integer from 0 to 255
-  #  * that specifies the location of the sound in relation to the listener.
-  #  * Distance 0 is overlapping the listener, and 255 is as far away as possible
-  #  * A distance of 255 does not guarantee silence; in such a case , you might
-  #  * want to try changing the chunk's volume, or just cull the sample from the
-  #  * mixing process with Mix_HaltChannel( ).
-  #    * for efficiency, the precision of this effect may be limited( distances 1
-  #    * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
-  #    * ( distance ) is an integer between 0 and 255 that specifies the space
-  #    * between the sound and the listener.The larger the number, the further
-  #    * away the sound is .
-  #    * Setting( distance ) to 0 unregisters this effect, since the data would be
-  #    * unchanged.
-  #    * if you need more precise positional audio, consider using OpenAL for
-  #    * spatialized effects instead of SDL_mixer.This is only meant to be a
-  #    * basic effect for simple "3D" games.
-  #    *
-  #    * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #    * the distance attenuation will be done to the final mixed stream before
-  #    * passing it on to the audio device.
-  #    *
-  #  * This uses the Mix_RegisterEffect( )API internally.
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if position effect is enabled.
-  #    * Error messages can be retrieved from Mix_GetError( ).
-  #    * 
-proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # *
-  #    * !!! FIXME : Haven't implemented, since the effect goes past the
-  #  * end of the sound buffer.Will have to think about this.
-  #  * - -ryan.
-  #  * /
-  #  { if 0
-  #  { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
-  #  * of echo to mix.0 is no echo, 255 is infinite( and probably not
-  #  * what you want ).
-  #  *
-  #  * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
-  #  * the reverbing will be done to the final mixed stream before passing it on
-  #  * to the audio device.
-  #  *
-  #  * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
-  #  * of zero, the effect is unregistered, as the data is already in that state.
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if reversing effect is enabled.
-  #    * Error messages can be retrieved from Mix_GetError( ).
-  #    *
-  #    extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
-  #  #E ndif
-  # * Causes a channel to reverse its stereo.This is handy if the user has his
-  #    * speakers hooked up backwards, or you would like to have a minor bit of
-  #  * psychedelia in your sound code. : )Calling this function with ( flip )
-  #  * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
-  #  * the effect is unregistered.
-  #  *
-  #  * This uses the Mix_RegisterEffect( )API internally, and thus is probably
-  #  * more CPU intensive than having the user just plug in his speakers
-  #  * correctly.Mix_SetReverseStereo( )returns without registering the effect
-  #  * function if the audio device is not configured for stereo output.
-  #  *
-  #  * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
-  #  * on the final mixed stream before sending it on to the audio device( a
-  #  * posteffect ).
-  #  *
-  #  * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
-  #  * nonzero if reversing effect is enabled.Note that an audio device in mono
-  #  * mode is a no - op, but this call will return successful in that case .
-  #  * Error messages can be retrieved from Mix_GetError( ).
-  #  * 
-proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # end of effects API. - -ryan. *
-  # Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
-  #   them dynamically to the next sample if requested with a -1 value below.
-  #   Returns the number of reserved channels.
-  # 
-proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Channel grouping functions 
-  # Attach a tag to a channel. A tag can be assigned to several mixer
-  #   channels, to form groups of channels.
-  #   If 'tag' is -1, the tag is removed (actually -1 is the tag used to
-  #   represent the group of all the channels).
-  #   Returns true if everything was OK.
-  # 
-proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Assign several consecutive channels to a group 
-proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Finds the first available channel in a group of channels 
-proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Returns the number of channels in a group. This is also a subtle
-  #   way to get the total number of channels when 'tag' is -1
-  # 
-proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Finds the "oldest" sample playing in a group of channels 
-proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Finds the "most recent" (i.e. last) sample playing in a group of channels 
-proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # The same as above, but the sound is played at most 'ticks' milliseconds 
-proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, 
-                           ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Play an audio chunk on a specific channel.
-  #   If the specified channel is -1, play on the first free channel.
-  #   If 'loops' is greater than zero, loop the sound that many times.
-  #   If 'loops' is -1, loop inifinitely (~65000 times).
-  #   Returns which channel was used to play the sound.
-  #
-proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
-proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions 
-proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, 
-                             ms: int, ticks: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
-  # Set the volume in the range of 0-128 of a specific channel or chunk.
-  #   If the specified channel is -1, set volume for all channels.
-  #   Returns the original volume.
-  #   If the specified volume is -1, just return the current volume.
-  #
-proc Mix_Volume*(channel: int, volume: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Halt playing of a particular channel 
-proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Change the expiration delay for a particular channel.
-  #   The sample will stop playing after the 'ticks' milliseconds have elapsed,
-  #   or remove the expiration if 'ticks' is -1
-  #
-proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Halt a channel, fading it out progressively till it's silent
-  #   The ms parameter indicates the number of milliseconds the fading
-  #   will take.
-  # 
-proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Query the fading status of a channel 
-proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Pause/Resume a particular channel 
-proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Pause/Resume the music stream 
-proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Set the current position in the music stream.
-  #  This returns 0 if successful, or -1 if it failed or isn't implemented.
-  #  This function is only implemented for MOD music formats (set pattern
-  #  order number) and for OGG music (set position in seconds), at the
-  #  moment.
-  #
-proc Mix_SetMusicPosition*(position: float64): int{.cdecl, 
-    importc, dynlib: SDL_MixerLibName.}
-  # Check the status of a specific channel.
-  #   If the specified channel is -1, check all channels.
-  #
-proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Stop music and set external music playback command 
-proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Synchro value is set by MikMod from modules while playing 
-proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  #
-  #  Get the Mix_Chunk currently associated with a mixer channel
-  #    Returns nil if it's an invalid channel, or there's no chunk associated.
-  #
-proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # Close the mixer, halting all playing audio 
-proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.}
-  # We'll use SDL for reporting errors 
-proc Mix_SetError*(fmt: cstring)
-proc Mix_GetError*(): cstring
-# implementation
-
-proc SDL_MIXER_VERSION(X: var TSDL_version) = 
-  X.major = SDL_MIXER_MAJOR_VERSION
-  X.minor = SDL_MIXER_MINOR_VERSION
-  X.patch = SDL_MIXER_PATCHLEVEL
-
-proc Mix_LoadWAV(filename: cstring): PMix_Chunk = 
-  result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1)
-
-proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = 
-  result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
-
-proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = 
-  result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
-proc Mix_SetError(fmt: cstring) = 
-  SDL_SetError(fmt)
-
-proc Mix_GetError(): cstring = 
-  result = SDL_GetError()
diff --git a/lib/oldwrappers/sdl/sdl_net.nim b/lib/oldwrappers/sdl/sdl_net.nim
deleted file mode 100755
index f27a674ae..000000000
--- a/lib/oldwrappers/sdl/sdl_net.nim
+++ /dev/null
@@ -1,431 +0,0 @@
-
-#******************************************************************************
-#
-#  $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
-#
-#
-#                                                                              
-#       Borland Delphi SDL_Net - A x-platform network library for use with SDL.
-#       Conversion of the Simple DirectMedia Layer Network Headers             
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_net.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas somehere in your search path                                       
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April   09 2001 - DL : Initial Translation                                 
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_net.pas,v $
-#  Revision 1.7  2005/01/01 02:14:21  savage
-#  Updated to v1.2.5
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#
-#
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows):
-  const SDLNetLibName = "SDL_net.dll"
-elif defined(macosx):
-  const SDLNetLibName = "libSDL_net.dylib"
-else:
-  const SDLNetLibName = "libSDL_net.so"
-
-const                         #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
-  SDL_NET_MAJOR_VERSION* = 1'i8
-  SDL_NET_MINOR_VERSION* = 2'i8
-  SDL_NET_PATCHLEVEL* = 5'i8  # SDL_Net.h constants
-                              #* Resolve a host name and port to an IP address in network form.
-                              #   If the function succeeds, it will return 0.
-                              #   If the host couldn't be resolved, the host portion of the returned
-                              #   address will be INADDR_NONE, and the function will return -1.
-                              #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-                              # *
-  INADDR_ANY* = 0x00000000
-  INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
-                            #* UDP network API                                                     *
-                            #***********************************************************************
-                            #* The maximum channels on a a UDP socket *
-  SDLNET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
-  SDLNET_MAX_UDPADDRESSES* = 4
-
-type  # SDL_net.h types
-      #***********************************************************************
-      #* IPv4 hostname resolution API                                        *
-      #***********************************************************************
-  PIPAddress* = ptr TIPAddress
-  TIPAddress*{.final.} = object  #* TCP network API                                                     
-    host*: Uint32             # 32-bit IPv4 host address */
-    port*: Uint16             # 16-bit protocol port */
-  
-  PTCPSocket* = ptr TTCPSocket
-  TTCPSocket*{.final.} = object  #***********************************************************************
-                                 #* UDP network API                                                     *
-                                 #***********************************************************************
-    ready*: int
-    channel*: int
-    remoteAddress*: TIPaddress
-    localAddress*: TIPaddress
-    sflag*: int
-
-  PUDP_Channel* = ptr TUDP_Channel
-  TUDP_Channel*{.final.} = object 
-    numbound*: int
-    address*: array[0..SDLNET_MAX_UDPADDRESSES - 1, TIPAddress]
-
-  PUDPSocket* = ptr TUDPSocket
-  TUDPSocket*{.final.} = object 
-    ready*: int
-    channel*: int
-    address*: TIPAddress
-    binding*: array[0..SDLNET_MAX_UDPCHANNELS - 1, TUDP_Channel]
-
-  PUDPpacket* = ptr TUDPpacket
-  PPUDPpacket* = ptr PUDPpacket
-  TUDPpacket*{.final.} = object  #***********************************************************************
-                                 #* Hooks for checking sockets for available data                       *
-                                 #***********************************************************************
-    channel*: int             #* The src/dst channel of the packet *
-    data*: PUint8             #* The packet data *
-    length*: int              #* The length of the packet data *
-    maxlen*: int              #* The size of the data buffer *
-    status*: int              #* packet status after sending *
-    address*: TIPAddress      #* The source/dest address of an incoming/outgoing packet *
-  
-  PSDLNet_Socket* = ptr TSDLNet_Socket
-  TSDLNet_Socket*{.final.} = object 
-    ready*: int
-    channel*: int
-
-  PSDLNet_SocketSet* = ptr TSDLNet_SocketSet
-  TSDLNet_SocketSet*{.final.} = object  #* Any network socket can be safely cast to this socket type *
-    numsockets*: int
-    maxsockets*: int
-    sockets*: PSDLNet_Socket
-
-  PSDLNet_GenericSocket* = ptr TSDLNet_GenericSocket
-  TSDLNet_GenericSocket*{.final.} = object  # This macro can be used to fill a version structure with the compile-time
-                                            #  version of the SDL_net library. 
-    ready*: int
-
-
-proc SDL_NET_VERSION*(X: var TSDL_version)
-  #* Initialize/Cleanup the network API
-  #   SDL must be initialized before calls to functions in this library,
-  #   because this library uses utility functions from the SDL library.
-  #*
-proc SDLNet_Init*(): int{.cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_Quit*(){.cdecl, importc, dynlib: SDLNetLibName.}
-  #* Resolve a host name and port to an IP address in network form.
-  #   If the function succeeds, it will return 0.
-  #   If the host couldn't be resolved, the host portion of the returned
-  #   address will be INADDR_NONE, and the function will return -1.
-  #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-  # *
-proc SDLNet_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* Resolve an ip address to a host name in canonical form.
-  #   If the ip couldn't be resolved, this function returns NULL,
-  #   otherwise a pointer to a static buffer containing the hostname
-  #   is returned.  Note that this function is not thread-safe.
-  #*
-proc SDLNet_ResolveIP*(ip: var TIPaddress): cstring{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #***********************************************************************
-  #* TCP network API                                                     *
-  #***********************************************************************
-  #* Open a TCP network socket
-  #   If ip.host is INADDR_NONE, this creates a local server socket on the
-  #   given port, otherwise a TCP connection to the remote host and port is
-  #   attempted.  The address passed in should already be swapped to network
-  #   byte order (addresses returned from SDLNet_ResolveHost() are already
-  #   in the correct form).
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc SDLNet_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Accept an incoming connection on the given server socket.
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc SDLNet_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Get the IP address of the remote system associated with the socket.
-  #   If the socket is a server socket, this function returns NULL.
-  #*
-proc SDLNet_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Send 'len' bytes of 'data' over the non-server socket 'sock'
-  #   This function returns the actual amount of data sent.  If the return value
-  #   is less than the amount of data sent, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc SDLNet_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
-  #   and store them in the buffer pointed to by 'data'.
-  #   This function returns the actual amount of data received.  If the return
-  #   value is less than or equal to zero, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc SDLNet_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Close a TCP network socket *
-proc SDLNet_TCP_Close*(sock: PTCPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
-  #***********************************************************************
-  #* UDP network API                                                     *
-  #***********************************************************************
-  #* Allocate/resize/free a single UDP packet 'size' bytes long.
-  #   The new packet is returned, or NULL if the function ran out of memory.
-  # *
-proc SDLNet_AllocPacket*(size: int): PUDPpacket{.cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-proc SDLNet_FreePacket*(packet: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
-  #* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
-  #   each 'size' bytes long.
-  #   A pointer to the first packet in the array is returned, or NULL if the
-  #   function ran out of memory.
-  # *
-proc SDLNet_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-proc SDLNet_FreePacketV*(packetV: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.}
-  #* Open a UDP network socket
-  #   If 'port' is non-zero, the UDP socket is bound to a local port.
-  #   This allows other systems to send to this socket via a known port.
-  #*
-proc SDLNet_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc, dynlib: SDLNetLibName.}
-  #* Bind the address 'address' to the requested channel on the UDP socket.
-  #   If the channel is -1, then the first unbound channel will be bound with
-  #   the given address as it's primary address.
-  #   If the channel is already bound, this new address will be added to the
-  #   list of valid source addresses for packets arriving on the channel.
-  #   If the channel is not already bound, then the address becomes the primary
-  #   address, to which all outbound packets on the channel are sent.
-  #   This function returns the channel which was bound, or -1 on error.
-  #*
-proc SDLNet_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* Unbind all addresses from the given channel *
-proc SDLNet_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Get the primary IP address of the remote system associated with the
-  #   socket and channel.  If the channel is -1, then the primary IP port
-  #   of the UDP socket is returned -- this is only meaningful for sockets
-  #   opened with a specific port.
-  #   If the channel is not bound and not -1, this function returns NULL.
-  # *
-proc SDLNet_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* Send a vector of packets to the the channels specified within the packet.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   Each packet will be updated with the status of the packet after it has
-  #   been sent, -1 if the packet send failed.
-  #   This function returns the number of packets sent.
-  #*
-proc SDLNet_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* Send a single packet to the specified channel.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   The packet will be updated with the status of the packet after it has
-  #   been sent.
-  #   This function returns 1 if the packet was sent, or 0 on error.
-  #*
-proc SDLNet_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* Receive a vector of pending packets from the UDP socket.
-  #   The returned packets contain the source address and the channel they arrived
-  #   on.  If they did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc SDLNet_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Receive a single packet from the UDP socket.
-  #   The returned packet contains the source address and the channel it arrived
-  #   on.  If it did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc SDLNet_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Close a UDP network socket *
-proc SDLNet_UDP_Close*(sock: PUDPsocket){.cdecl, importc, dynlib: SDLNetLibName.}
-  #***********************************************************************
-  #* Hooks for checking sockets for available data                       *
-  #***********************************************************************
-  #* Allocate a socket set for use with SDLNet_CheckSockets()
-  #   This returns a socket set for up to 'maxsockets' sockets, or NULL if
-  #   the function ran out of memory.
-  # *
-proc SDLNet_AllocSocketSet*(maxsockets: int): PSDLNet_SocketSet{.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #* Add a socket to a set of sockets to be checked for available data *
-proc SDLNet_AddSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_TCP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
-proc SDLNet_UDP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
-  #* Remove a socket from a set of sockets to be checked for available data *
-proc SDLNet_DelSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_TCP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int
-  # SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-proc SDLNet_UDP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int
-  #SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-  #* This function checks to see if data is available for reading on the
-  #   given set of sockets.  If 'timeout' is 0, it performs a quick poll,
-  #   otherwise the function returns when either data is available for
-  #   reading, or the timeout in milliseconds has elapsed, which ever occurs
-  #   first.  This function returns the number of sockets ready for reading,
-  #   or -1 if there was an error with the select() system call.
-  #*
-proc SDLNet_CheckSockets*(theSet: PSDLNet_SocketSet, timeout: Sint32): int{.
-    cdecl, importc, dynlib: SDLNetLibName.}
-  #* After calling SDLNet_CheckSockets(), you can use this function on a
-  #   socket that was in the socket set, to find out if data is available
-  #   for reading.
-  #*
-proc SDLNet_SocketReady*(sock: PSDLNet_GenericSocket): bool
-  #* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
-proc SDLNet_FreeSocketSet*(theSet: PSDLNet_SocketSet){.cdecl, 
-    importc, dynlib: SDLNetLibName.}
-  #***********************************************************************
-  #* Platform-independent data conversion functions                      *
-  #***********************************************************************
-  #* Write a 16/32 bit value to network packet buffer *
-proc SDLNet_Write16*(value: Uint16, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_Write32*(value: Uint32, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.}
-  #* Read a 16/32 bit value from network packet buffer *
-proc SDLNet_Read16*(area: Pointer): Uint16{.cdecl, importc, dynlib: SDLNetLibName.}
-proc SDLNet_Read32*(area: Pointer): Uint32{.cdecl, importc, dynlib: SDLNetLibName.}
-  #***********************************************************************
-  #* Error reporting functions                                           *
-  #***********************************************************************
-  #* We'll use SDL's functions for error reporting *
-proc SDLNet_SetError*(fmt: cstring)
-proc SDLNet_GetError*(): cstring
-# implementation
-
-proc SDL_NET_VERSION(X: var TSDL_version) = 
-  X.major = SDL_NET_MAJOR_VERSION
-  X.minor = SDL_NET_MINOR_VERSION
-  X.patch = SDL_NET_PATCHLEVEL
-
-proc SDLNet_TCP_AddSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int = 
-  result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
-
-proc SDLNet_UDP_AddSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int = 
-  result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock))
-
-proc SDLNet_TCP_DelSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int = 
-  result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
-
-proc SDLNet_UDP_DelSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int = 
-  result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock))
-
-proc SDLNet_SocketReady(sock: PSDLNet_GenericSocket): bool = 
-  result = ((sock != nil) and (sock.ready == 1))
-
-proc SDLNet_SetError(fmt: cstring) = 
-  SDL_SetError(fmt)
-
-proc SDLNet_GetError(): cstring = 
-  result = SDL_GetError()
diff --git a/lib/oldwrappers/sdl/sdl_ttf.nim b/lib/oldwrappers/sdl/sdl_ttf.nim
deleted file mode 100755
index 724c2f634..000000000
--- a/lib/oldwrappers/sdl/sdl_ttf.nim
+++ /dev/null
@@ -1,346 +0,0 @@
-
-#
-#  $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
-#
-#
-#******************************************************************************
-#                                                                              
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer          
-#       Conversion of the Simple DirectMedia Layer Headers                     
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_ttf.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so          
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid        
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_ttf.pas,v $
-#  Revision 1.18  2007/06/01 11:16:33  savage
-#  Added IFDEF UNIX for Workaround.
-#
-#  Revision 1.17  2007/06/01 08:38:21  savage
-#  Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
-#
-#  Revision 1.16  2007/05/29 21:32:14  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.15  2007/05/20 20:32:45  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.14  2006/12/02 00:19:01  savage
-#  Updated to latest version
-#
-#  Revision 1.13  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.12  2005/01/05 01:47:14  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.11  2005/01/04 23:14:57  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.10  2005/01/02 19:07:32  savage
-#  Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
-#
-#  Revision 1.9  2005/01/01 02:15:20  savage
-#  Updated to v2.0.7
-#
-#  Revision 1.8  2004/10/07 21:02:32  savage
-#  Fix for FPC
-#
-#  Revision 1.7  2004/09/30 22:39:50  savage
-#  Added a true type font class which contains a wrap text function.
-#  Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:24  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#  
-#
-#******************************************************************************
-#
-#  Define this to workaround a known bug in some freetype versions.
-#  The error manifests as TTF_RenderGlyph_Solid returning nil (error)
-#  and error message (in SDL_Error) is
-#  "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
-#  See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
-#
-
-import sdl
-
-when defined(windows):
-  const SDLttfLibName = "SDL_ttf.dll"
-elif defined(macosx):
-  const SDLttfLibName = "libSDL_ttf-2.0.0.dylib"
-else:
-  const SDLttfLibName = "libSDL_ttf.so"
-
-const
-  SDL_TTF_MAJOR_VERSION* = 2'i8
-  SDL_TTF_MINOR_VERSION* = 0'i8
-  SDL_TTF_PATCHLEVEL* = 8'i8     # Backwards compatibility
-  TTF_MAJOR_VERSION* = SDL_TTF_MAJOR_VERSION
-  TTF_MINOR_VERSION* = SDL_TTF_MINOR_VERSION
-  TTF_PATCHLEVEL* = SDL_TTF_PATCHLEVEL #*
-                                       #   Set and retrieve the font style
-                                       #   This font style is implemented by modifying the font glyphs, and
-                                       #   doesn't reflect any inherent properties of the truetype font file.
-                                       #*
-  TTF_STYLE_NORMAL* = 0x00000000
-  TTF_STYLE_BOLD* = 0x00000001
-  TTF_STYLE_ITALIC* = 0x00000002
-  TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
-  UNICODE_BOM_NATIVE* = 0x0000FEFF
-  UNICODE_BOM_SWAPPED* = 0x0000FFFE
-
-type 
-  PTTF_Font* = ptr TTTF_font
-  TTTF_Font*{.final.} = object  # This macro can be used to fill a version structure with the compile-time
-                                #  version of the SDL_ttf library. 
-
-proc SDL_TTF_VERSION*(X: var TSDL_version)
-  # This function gets the version of the dynamically linked SDL_ttf library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_TTF_VERSION() macro. 
-proc TTF_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLttfLibName.}
-  # This function tells the library whether UNICODE text is generally
-  #   byteswapped.  A UNICODE BOM character in a string will override
-  #   this setting for the remainder of that string.
-  #
-proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl, importc, dynlib: SDLttfLibName.}
-  #returns 0 on succes, -1 if error occurs
-proc TTF_Init*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  #
-  # Open a font file and create a font of the specified point size.
-  # Some .fon fonts will have several sizes embedded in the file, so the
-  # point size becomes the index of choosing which size.  If the value
-  # is too high, the last indexed size will be the default.
-  #
-proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_OpenFontRW*(src: PSDL_RWops, freesrc: int, ptsize: int): PTTF_Font{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_OpenFontIndexRW*(src: PSDL_RWops, freesrc: int, ptsize: int, 
-                          index: int32): PTTF_Font{.cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-  # Get the total height of the font - usually equal to point size 
-proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the offset from the baseline to the top of the font
-  #   This is a positive value, relative to the baseline.
-  #
-proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the offset from the baseline to the bottom of the font
-  #   This is a negative value, relative to the baseline.
-  #
-proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the recommended spacing between lines of text for this font 
-proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the number of faces of the font 
-proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the font face attributes, if any 
-proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-  # Get the metrics (dimensions) of a glyph 
-proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int, 
-                       maxx: var int, miny: var int, maxy: var int, 
-                       advance: var int): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # Get the dimensions of a rendered string of text 
-proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-  #
-  #Create an 8-bit palettized surface and render the given glyph at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.  The glyph is rendered without any padding or
-  #   centering in the X direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color, 
-                            bg: TSDL_Color): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color, 
-                            bg: TSDL_Color): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TSDL_Color, 
-                               bg: TSDL_Color): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-  # Create an 8-bit palettized surface and render the given glyph at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color, 
-                             bg: TSDL_Color): PSDL_Surface{.cdecl, 
-    importc, dynlib: SDLttfLibName.}
-  # Create a 32-bit ARGB surface and render the given text at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-  # Create a 32-bit ARGB surface and render the given glyph at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{.
-    cdecl, importc, dynlib: SDLttfLibName.}
-  # For compatibility with previous versions, here are the old functions 
-  ##define TTF_RenderText(font, text, fg, bg)
-  #	TTF_RenderText_Shaded(font, text, fg, bg)
-  ##define TTF_RenderUTF8(font, text, fg, bg)	
-  #	TTF_RenderUTF8_Shaded(font, text, fg, bg)
-  ##define TTF_RenderUNICODE(font, text, fg, bg)	
-  #	TTF_RenderUNICODE_Shaded(font, text, fg, bg)
-  # Close an opened font file 
-proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc, dynlib: SDLttfLibName.}
-  #De-initialize TTF engine
-proc TTF_Quit*(){.cdecl, importc, dynlib: SDLttfLibName.}
-  # Check if the TTF engine is initialized
-proc TTF_WasInit*(): int{.cdecl, importc, dynlib: SDLttfLibName.}
-  # We'll use SDL for reporting errors
-proc TTF_SetError*(fmt: cstring)
-proc TTF_GetError*(): cstring
-# implementation
-
-proc SDL_TTF_VERSION(X: var TSDL_version) = 
-  X.major = SDL_TTF_MAJOR_VERSION
-  X.minor = SDL_TTF_MINOR_VERSION
-  X.patch = SDL_TTF_PATCHLEVEL
-
-proc TTF_SetError(fmt: cstring) = 
-  SDL_SetError(fmt)
-
-proc TTF_GetError(): cstring = 
-  result = SDL_GetError()
-
-when not(defined(Workaround_TTF_RenderText_Solid)): 
-  proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{.
-      cdecl, importc, dynlib: SDLttfLibName.}
-else: 
-  proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface = 
-    var Black: TSDL_Color # initialized to zero
-    Result = TTF_RenderText_Shaded(font, text, fg, Black)
diff --git a/lib/oldwrappers/sdl/smpeg.nim b/lib/oldwrappers/sdl/smpeg.nim
deleted file mode 100755
index 733a3fcf9..000000000
--- a/lib/oldwrappers/sdl/smpeg.nim
+++ /dev/null
@@ -1,319 +0,0 @@
-
-#******************************************************************************
-#
-#  $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
-#  
-#
-#                                                                              
-#       Borland Delphi SMPEG - SDL MPEG Player Library                         
-#       Conversion of the SMPEG - SDL MPEG Player Library                      
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : smpeg.h                                             
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL-1.2.so.0    
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   May      08 2001 - MT : Initial conversion                                 
-#                                                                              
-#   October  12 2001 - DA : Various changes as suggested by David Acklam       
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                          Fixed all invalid calls to DLL.                     
-#                          Changed constant names to:                          
-#                          const                                               
-#                          STATUS_SMPEG_ERROR = -1;                            
-#                          STATUS_SMPEG_STOPPED = 0;                           
-#                          STATUS_SMPEG_PLAYING = 1;                           
-#                          because SMPEG_ERROR is a function (_SMPEG_error     
-#                          isn't correct), and cannot be two elements with the 
-#                          same name                                           
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: smpeg.pas,v $
-#  Revision 1.7  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.6  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.5  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.4  2004/04/02 10:40:55  savage
-#  Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.3  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#  
-#
-#******************************************************************************
-
-import
-  sdl
-
-when defined(windows):
-  const SmpegLibName = "smpeg.dll"
-elif defined(macosx):
-  const SmpegLibName = "libsmpeg.dylib"
-else:
-  const SmpegLibName = "libsmpeg.so"
-
-const 
-  SMPEG_FILTER_INFO_MB_ERROR* = 1
-  SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG 
-
-type 
-  SMPEG_FilterInfo*{.final.} = object 
-    yuv_mb_square_error*: PUint16
-    yuv_pixel_square_error*: PUint16
-
-  TSMPEG_FilterInfo* = SMPEG_FilterInfo
-  PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition 
-  PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter 
-  TSMPEG_FilterCallback* = proc (dest, source: PSDL_Overlay, region: PSDL_Rect, 
-                                 filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
-      cdecl.}
-  TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter 
-                                                                         # definition itself 
-  TSMPEG_Filter*{.final.} = object  # The null filter (default). It simply copies the source rectangle to the video overlay. 
-    flags*: Uint32
-    data*: Pointer
-    callback*: TSMPEG_FilterCallback
-    destroy*: TSMPEG_FilterDestroy
-
-
-proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
-  # The bilinear filter. A basic low-pass filter that will produce a smoother image. 
-proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
-  # The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness 
-proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.}
-  #------------------------------------------------------------------------------
-  # SMPEG.h
-  #------------------------------------------------------------------------------
-const 
-  SMPEG_MAJOR_VERSION* = 0'i8
-  SMPEG_MINOR_VERSION* = 4'i8
-  SMPEG_PATCHLEVEL* = 2'i8
-
-type 
-  SMPEG_version*{.final.} = object 
-    major*: UInt8
-    minor*: UInt8
-    patch*: UInt8
-
-  TSMPEG_version* = SMPEG_version
-  PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
-  TSMPEG*{.final.} = object 
-  PSMPEG* = ptr TSMPEG        # Used to get information about the SMPEG object 
-  TSMPEG_Info*{.final.} = object 
-    has_audio*: int
-    has_video*: int
-    width*: int
-    height*: int
-    current_frame*: int
-    current_fps*: float64
-    audio_string*: array[0..79, char]
-    audio_current_frame*: int
-    current_offset*: UInt32
-    total_size*: UInt32
-    current_time*: float64
-    total_time*: float64
-
-  PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes 
-
-const 
-  STATUS_SMPEG_ERROR* = - 1
-  STATUS_SMPEG_STOPPED* = 0
-  STATUS_SMPEG_PLAYING* = 1
-
-type 
-  TSMPEGstatus* = int
-  PSMPEGstatus* = ptr int     # Matches the declaration of SDL_UpdateRect() 
-  TSMPEG_DisplayCallback* = proc (dst: PSDL_Surface, x, y: int, w, h: int): Pointer{.
-      cdecl.} # Create a new SMPEG object from an MPEG file.
-              #  On return, if 'info' is not NULL, it will be filled with information
-              #  about the MPEG object.
-              #  This function returns a new SMPEG object.  Use SMPEG_error() to find out
-              #  whether or not there was a problem building the MPEG stream.
-              #  The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
-              #  subsystem. If not, you will have to use the SMPEG_playaudio() function below
-              #  to extract the decoded data. 
-
-proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
-    cdecl, importc, dynlib: SmpegLibName.}
-  # The same as above for a file descriptor 
-proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
-    cdecl, importc, dynlib: SmpegLibName.}
-  #  The same as above but for a raw chunk of data.  SMPEG makes a copy of the
-  #   data, so the application is free to delete after a successful call to this
-  #   function. 
-proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{.
-    cdecl, importc, dynlib: SmpegLibName.}
-  # Get current information about an SMPEG object 
-proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  #procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer);
-  #cdecl; external  SmpegLibName;
-  # Enable or disable audio playback in MPEG stream 
-proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Enable or disable video playback in MPEG stream 
-proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Delete an SMPEG object 
-proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
-  # Get the current status of an SMPEG object 
-proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc, dynlib: SmpegLibName.}
-  # status
-  # Set the audio volume of an MPEG stream, in the range 0-100 
-proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Set the destination surface for MPEG video playback
-  #  'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
-  #  'callback' is a function called when an area of 'dst' needs to be updated.
-  #  If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. 
-proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSDL_Surface, surfLock: PSDL_mutex, 
-                       callback: TSMPEG_DisplayCallback){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Set or clear looping play on an SMPEG object 
-proc SMPEG_loop*(mpeg: PSMPEG, repeat: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Scale pixel display on an SMPEG object 
-proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc, dynlib: SmpegLibName.}
-proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool)
-  # Move the video display area within the destination surface 
-proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Set the region of the video to be shown 
-proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Play an SMPEG object 
-proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
-  # Pause/Resume playback of an SMPEG object
-proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
-  # Stop playback of an SMPEG object 
-proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
-  # Rewind the play position of an SMPEG object to the beginning of the MPEG 
-proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.}
-  # Seek 'bytes' bytes in the MPEG stream 
-proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc, dynlib: SmpegLibName.}
-  # Skip 'seconds' seconds in the MPEG stream 
-proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc, dynlib: SmpegLibName.}
-  # Render a particular frame in the MPEG video
-  #   API CHANGE: This function no longer takes a target surface and position.
-  #               Use SMPEG_setdisplay() and SMPEG_move() to set this information. 
-proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Render the last frame of an MPEG video 
-proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSDL_Surface, x, y: int){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Set video filter 
-proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Return NULL if there is no error in the MPEG stream, or an error message
-  #   if there was a fatal error in the MPEG stream for the SMPEG object. 
-proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc, dynlib: SmpegLibName.}
-  # Exported callback function for audio playback.
-  #   The function takes a buffer and the amount of data to fill, and returns
-  #   the amount of data in bytes that was actually written.  This will be the
-  #   amount requested unless the MPEG audio has finished.
-  #
-proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer 
-proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Get the best SDL audio spec for the audio stream 
-proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PSDL_AudioSpec): int{.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # Inform SMPEG of the actual SDL audio spec used for sound playback 
-proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PSDL_AudioSpec){.cdecl, 
-    importc, dynlib: SmpegLibName.}
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library. 
-proc SMPEG_GETVERSION*(X: var TSMPEG_version)
-# implementation
-
-proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) = 
-  if doubleit: SMPEG_scale(mpeg, 2)
-  else: SMPEG_scale(mpeg, 1)
-  
-proc SMPEG_GETVERSION(X: var TSMPEG_version) = 
-  X.major = SMPEG_MAJOR_VERSION
-  X.minor = SMPEG_MINOR_VERSION
-  X.patch = SMPEG_PATCHLEVEL
diff --git a/lib/oldwrappers/sqlite3.nim b/lib/oldwrappers/sqlite3.nim
deleted file mode 100755
index 7dd33f296..000000000
--- a/lib/oldwrappers/sqlite3.nim
+++ /dev/null
@@ -1,376 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-{.deadCodeElim: on.}
-
-when defined(windows): 
-  const Sqlite3Lib = "sqlite3.dll"
-elif defined(macosx):
-  const Sqlite3Lib = "sqlite-3.6.13.dylib"
-else: 
-  const Sqlite3Lib = "libsqlite3.so"
-
-const 
-  SQLITE_INTEGER* = 1
-  SQLITE_FLOAT* = 2
-  SQLITE_BLOB* = 4
-  SQLITE_NULL* = 5
-  SQLITE_TEXT* = 3
-  SQLITE3_TEXT* = 3
-  SQLITE_UTF8* = 1
-  SQLITE_UTF16LE* = 2
-  SQLITE_UTF16BE* = 3         # Use native byte order  
-  SQLITE_UTF16* = 4           # sqlite3_create_function only  
-  SQLITE_ANY* = 5             #sqlite_exec return values
-  SQLITE_OK* = 0
-  SQLITE_ERROR* = 1           # SQL error or missing database  
-  SQLITE_INTERNAL* = 2        # An internal logic error in SQLite  
-  SQLITE_PERM* = 3            # Access permission denied  
-  SQLITE_ABORT* = 4           # Callback routine requested an abort  
-  SQLITE_BUSY* = 5            # The database file is locked  
-  SQLITE_LOCKED* = 6          # A table in the database is locked  
-  SQLITE_NOMEM* = 7           # A malloc() failed  
-  SQLITE_READONLY* = 8        # Attempt to write a readonly database  
-  SQLITE_INTERRUPT* = 9       # Operation terminated by sqlite3_interrupt() 
-  SQLITE_IOERR* = 10          # Some kind of disk I/O error occurred  
-  SQLITE_CORRUPT* = 11        # The database disk image is malformed  
-  SQLITE_NOTFOUND* = 12       # (Internal Only) Table or record not found  
-  SQLITE_FULL* = 13           # Insertion failed because database is full  
-  SQLITE_CANTOPEN* = 14       # Unable to open the database file  
-  SQLITE_PROTOCOL* = 15       # Database lock protocol error  
-  SQLITE_EMPTY* = 16          # Database is empty  
-  SQLITE_SCHEMA* = 17         # The database schema changed  
-  SQLITE_TOOBIG* = 18         # Too much data for one row of a table  
-  SQLITE_CONSTRAINT* = 19     # Abort due to contraint violation  
-  SQLITE_MISMATCH* = 20       # Data type mismatch  
-  SQLITE_MISUSE* = 21         # Library used incorrectly  
-  SQLITE_NOLFS* = 22          # Uses OS features not supported on host  
-  SQLITE_AUTH* = 23           # Authorization denied  
-  SQLITE_FORMAT* = 24         # Auxiliary database format error  
-  SQLITE_RANGE* = 25          # 2nd parameter to sqlite3_bind out of range  
-  SQLITE_NOTADB* = 26         # File opened that is not a database file  
-  SQLITE_ROW* = 100           # sqlite3_step() has another row ready  
-  SQLITE_DONE* = 101          # sqlite3_step() has finished executing  
-  SQLITE_COPY* = 0
-  SQLITE_CREATE_INDEX* = 1
-  SQLITE_CREATE_TABLE* = 2
-  SQLITE_CREATE_TEMP_INDEX* = 3
-  SQLITE_CREATE_TEMP_TABLE* = 4
-  SQLITE_CREATE_TEMP_TRIGGER* = 5
-  SQLITE_CREATE_TEMP_VIEW* = 6
-  SQLITE_CREATE_TRIGGER* = 7
-  SQLITE_CREATE_VIEW* = 8
-  SQLITE_DELETE* = 9
-  SQLITE_DROP_INDEX* = 10
-  SQLITE_DROP_TABLE* = 11
-  SQLITE_DROP_TEMP_INDEX* = 12
-  SQLITE_DROP_TEMP_TABLE* = 13
-  SQLITE_DROP_TEMP_TRIGGER* = 14
-  SQLITE_DROP_TEMP_VIEW* = 15
-  SQLITE_DROP_TRIGGER* = 16
-  SQLITE_DROP_VIEW* = 17
-  SQLITE_INSERT* = 18
-  SQLITE_PRAGMA* = 19
-  SQLITE_READ* = 20
-  SQLITE_SELECT* = 21
-  SQLITE_TRANSACTION* = 22
-  SQLITE_UPDATE* = 23
-  SQLITE_ATTACH* = 24
-  SQLITE_DETACH* = 25
-  SQLITE_ALTER_TABLE* = 26
-  SQLITE_REINDEX* = 27
-  SQLITE_DENY* = 1
-  SQLITE_IGNORE* = 2          # Original from sqlite3.h: 
-                              ##define SQLITE_STATIC      ((void(*)(void *))0)
-                              ##define SQLITE_TRANSIENT   ((void(*)(void *))-1)
-
-const 
-  SQLITE_STATIC* = nil
-  SQLITE_TRANSIENT* = cast[pointer](-1)
-
-type 
-  sqlite_int64* = int64
-  PPPChar* = ptr ptr cstring
-  TSqlite3 {.pure, final.} = object
-  Psqlite3* = ptr TSqlite3
-  PPSqlite3* = ptr PSqlite3
-  TSqlLite3Context {.pure, final.} = object
-  Psqlite3_context* = ptr TSqlLite3Context
-  Tsqlite3_stmt {.pure, final.} = object
-  Psqlite3_stmt* = ptr TSqlite3_stmt
-  PPsqlite3_stmt* = ptr Psqlite3_stmt
-  Tsqlite3_value {.pure, final.} = object
-  Psqlite3_value* = ptr Tsqlite3_value
-  PPsqlite3_value* = ptr Psqlite3_value #Callback function types
-                                        #Notice that most functions 
-                                        #were named using as prefix the 
-                                        #function name that uses them,
-                                        #rather than describing their functions  
-  Tsqlite3_callback* = proc (para1: pointer, para2: int32, para3, 
-                             para4: cstringArray): int32{.cdecl.}
-  Tbind_destructor_func* = proc (para1: pointer){.cdecl.}
-  Tcreate_function_step_func* = proc (para1: Psqlite3_context, para2: int32, 
-                                     para3: PPsqlite3_value){.cdecl.}
-  Tcreate_function_func_func* = proc (para1: Psqlite3_context, para2: int32, 
-                                     para3: PPsqlite3_value){.cdecl.}
-  Tcreate_function_final_func* = proc (para1: Psqlite3_context){.cdecl.}
-  Tsqlite3_result_func* = proc (para1: pointer){.cdecl.}
-  Tsqlite3_create_collation_func* = proc (para1: pointer, para2: int32, 
-      para3: pointer, para4: int32, para5: pointer): int32{.cdecl.}
-  Tsqlite3_collation_needed_func* = proc (para1: pointer, para2: Psqlite3, 
-      eTextRep: int32, para4: cstring){.cdecl.}
-
-proc sqlite3_close*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_close".}
-proc sqlite3_exec*(para1: Psqlite3, sql: cstring, para3: Tsqlite3_callback, 
-                   para4: pointer, errmsg: var cstring): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_exec".}
-proc sqlite3_last_insert_rowid*(para1: Psqlite3): sqlite_int64{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_last_insert_rowid".}
-proc sqlite3_changes*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_changes".}
-proc sqlite3_total_changes*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_total_changes".}
-proc sqlite3_interrupt*(para1: Psqlite3){.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_interrupt".}
-proc sqlite3_complete*(sql: cstring): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_complete".}
-proc sqlite3_complete16*(sql: pointer): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_complete16".}
-proc sqlite3_busy_handler*(para1: Psqlite3, 
-    para2: proc (para1: pointer, para2: int32): int32 {.cdecl.}, 
-    para3: pointer): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_busy_handler".}
-proc sqlite3_busy_timeout*(para1: Psqlite3, ms: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_busy_timeout".}
-proc sqlite3_get_table*(para1: Psqlite3, sql: cstring, resultp: var cstringArray, 
-                        nrow, ncolumn: var cint, errmsg: ptr cstring): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_get_table".}
-proc sqlite3_free_table*(result: cstringArray){.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_free_table".}
-  # Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
-  # function sqlite3_mprintf(_para1:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf';
-proc sqlite3_mprintf*(para1: cstring): cstring{.cdecl, varargs, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_mprintf".}
-  #function sqlite3_vmprintf(_para1:Pchar; _para2:va_list):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_vmprintf';
-proc sqlite3_free*(z: cstring){.cdecl, dynlib: Sqlite3Lib, 
-                                importc: "sqlite3_free".}
-  #function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf';
-proc sqlite3_snprintf*(para1: int32, para2: cstring, para3: cstring): cstring{.
-    cdecl, dynlib: Sqlite3Lib, varargs, importc: "sqlite3_snprintf".}
-proc sqlite3_set_authorizer*(para1: Psqlite3, 
-                             xAuth: proc (para1: pointer, para2: int32, 
-                                      para3: cstring, para4: cstring, 
-                                      para5: cstring, 
-                                      para6: cstring): int32{.cdecl.}, 
-                             pUserData: pointer): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_set_authorizer".}
-proc sqlite3_trace*(para1: Psqlite3, 
-                    xTrace: proc (para1: pointer, para2: cstring){.cdecl.}, 
-                    para3: pointer): pointer{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_trace".}
-proc sqlite3_progress_handler*(para1: Psqlite3, para2: int32, 
-                               para3: proc (para1: pointer): int32 {.cdecl.}, 
-                               para4: pointer){.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_progress_handler".}
-proc sqlite3_commit_hook*(para1: Psqlite3, 
-                          para2: proc (para1: pointer): int32{.cdecl.}, 
-                          para3: pointer): pointer{.cdecl, dynlib: Sqlite3Lib,
-    importc: "sqlite3_commit_hook".}
-proc sqlite3_open*(filename: cstring, ppDb: var Psqlite3): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_open".}
-proc sqlite3_open16*(filename: pointer, ppDb: var Psqlite3): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_open16".}
-proc sqlite3_errcode*(db: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_errcode".}
-proc sqlite3_errmsg*(para1: Psqlite3): cstring{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_errmsg".}
-proc sqlite3_errmsg16*(para1: Psqlite3): pointer{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_errmsg16".}
-proc sqlite3_prepare*(db: Psqlite3, zSql: cstring, nBytes: int32, 
-                      ppStmt: PPsqlite3_stmt, pzTail: ptr cstring): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_prepare".}
-proc sqlite3_prepare16*(db: Psqlite3, zSql: pointer, nBytes: int32, 
-                        ppStmt: PPsqlite3_stmt, pzTail: var pointer): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_prepare16".}
-proc sqlite3_bind_blob*(para1: Psqlite3_stmt, para2: int32, para3: pointer, 
-                        n: int32, para5: Tbind_destructor_func): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_blob".}
-proc sqlite3_bind_double*(para1: Psqlite3_stmt, para2: int32, para3: float64): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_double".}
-proc sqlite3_bind_int*(para1: Psqlite3_stmt, para2: int32, para3: int32): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_int".}
-proc sqlite3_bind_int64*(para1: Psqlite3_stmt, para2: int32, para3: sqlite_int64): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_int64".}
-proc sqlite3_bind_null*(para1: Psqlite3_stmt, para2: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_null".}
-proc sqlite3_bind_text*(para1: Psqlite3_stmt, para2: int32, para3: cstring, 
-                        n: int32, para5: Tbind_destructor_func): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_text".}
-proc sqlite3_bind_text16*(para1: Psqlite3_stmt, para2: int32, para3: pointer, 
-                          para4: int32, para5: Tbind_destructor_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_text16".}
-  #function sqlite3_bind_value(_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_value';
-  #These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
-  #It's the c world man ;-)
-proc sqlite3_bind_blob*(para1: Psqlite3_stmt, para2: int32, para3: pointer, 
-                        n: int32, para5: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_blob".}
-proc sqlite3_bind_text*(para1: Psqlite3_stmt, para2: int32, para3: cstring, 
-                        n: int32, para5: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_text".}
-proc sqlite3_bind_text16*(para1: Psqlite3_stmt, para2: int32, para3: pointer, 
-                          para4: int32, para5: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_text16".}
-proc sqlite3_bind_parameter_count*(para1: Psqlite3_stmt): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_count".}
-proc sqlite3_bind_parameter_name*(para1: Psqlite3_stmt, para2: int32): cstring{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_name".}
-proc sqlite3_bind_parameter_index*(para1: Psqlite3_stmt, zName: cstring): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_index".}
-  #function sqlite3_clear_bindings(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_clear_bindings';
-proc sqlite3_column_count*(pStmt: Psqlite3_stmt): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_count".}
-proc sqlite3_column_name*(para1: Psqlite3_stmt, para2: int32): cstring{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_name".}
-proc sqlite3_column_name16*(para1: Psqlite3_stmt, para2: int32): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_name16".}
-proc sqlite3_column_decltype*(para1: Psqlite3_stmt, i: int32): cstring{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_decltype".}
-proc sqlite3_column_decltype16*(para1: Psqlite3_stmt, para2: int32): pointer{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_column_decltype16".}
-proc sqlite3_step*(para1: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_step".}
-proc sqlite3_data_count*(pStmt: Psqlite3_stmt): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_data_count".}
-proc sqlite3_column_blob*(para1: Psqlite3_stmt, iCol: int32): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_blob".}
-proc sqlite3_column_bytes*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_bytes".}
-proc sqlite3_column_bytes16*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_bytes16".}
-proc sqlite3_column_double*(para1: Psqlite3_stmt, iCol: int32): float64{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_double".}
-proc sqlite3_column_int*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_int".}
-proc sqlite3_column_int64*(para1: Psqlite3_stmt, iCol: int32): sqlite_int64{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_column_int64".}
-proc sqlite3_column_text*(para1: Psqlite3_stmt, iCol: int32): cstring{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_text".}
-proc sqlite3_column_text16*(para1: Psqlite3_stmt, iCol: int32): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_text16".}
-proc sqlite3_column_type*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_column_type".}
-proc sqlite3_finalize*(pStmt: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_finalize".}
-proc sqlite3_reset*(pStmt: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_reset".}
-proc sqlite3_create_function*(para1: Psqlite3, zFunctionName: cstring, 
-                              nArg: int32, eTextRep: int32, para5: pointer, 
-                              xFunc: Tcreate_function_func_func, 
-                              xStep: Tcreate_function_step_func, 
-                              xFinal: Tcreate_function_final_func): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_create_function".}
-proc sqlite3_create_function16*(para1: Psqlite3, zFunctionName: pointer, 
-                                nArg: int32, eTextRep: int32, para5: pointer, 
-                                xFunc: Tcreate_function_func_func, 
-                                xStep: Tcreate_function_step_func, 
-                                xFinal: Tcreate_function_final_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_function16".}
-proc sqlite3_aggregate_count*(para1: Psqlite3_context): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_aggregate_count".}
-proc sqlite3_value_blob*(para1: Psqlite3_value): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_blob".}
-proc sqlite3_value_bytes*(para1: Psqlite3_value): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_bytes".}
-proc sqlite3_value_bytes16*(para1: Psqlite3_value): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_bytes16".}
-proc sqlite3_value_double*(para1: Psqlite3_value): float64{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_double".}
-proc sqlite3_value_int*(para1: Psqlite3_value): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_int".}
-proc sqlite3_value_int64*(para1: Psqlite3_value): sqlite_int64{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_int64".}
-proc sqlite3_value_text*(para1: Psqlite3_value): cstring{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_text".}
-proc sqlite3_value_text16*(para1: Psqlite3_value): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_text16".}
-proc sqlite3_value_text16le*(para1: Psqlite3_value): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_text16le".}
-proc sqlite3_value_text16be*(para1: Psqlite3_value): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_text16be".}
-proc sqlite3_value_type*(para1: Psqlite3_value): int32{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_value_type".}
-proc sqlite3_aggregate_context*(para1: Psqlite3_context, nBytes: int32): pointer{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_aggregate_context".}
-proc sqlite3_user_data*(para1: Psqlite3_context): pointer{.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_user_data".}
-proc sqlite3_get_auxdata*(para1: Psqlite3_context, para2: int32): pointer{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_get_auxdata".}
-proc sqlite3_set_auxdata*(para1: Psqlite3_context, para2: int32, para3: pointer, 
-                          para4: proc (para1: pointer) {.cdecl.}){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_set_auxdata".}
-proc sqlite3_result_blob*(para1: Psqlite3_context, para2: pointer, para3: int32, 
-                          para4: Tsqlite3_result_func){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_blob".}
-proc sqlite3_result_double*(para1: Psqlite3_context, para2: float64){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_double".}
-proc sqlite3_result_error*(para1: Psqlite3_context, para2: cstring, para3: int32){.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_result_error".}
-proc sqlite3_result_error16*(para1: Psqlite3_context, para2: pointer, 
-                             para3: int32){.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_result_error16".}
-proc sqlite3_result_int*(para1: Psqlite3_context, para2: int32){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_int".}
-proc sqlite3_result_int64*(para1: Psqlite3_context, para2: sqlite_int64){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_int64".}
-proc sqlite3_result_null*(para1: Psqlite3_context){.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_result_null".}
-proc sqlite3_result_text*(para1: Psqlite3_context, para2: cstring, para3: int32, 
-                          para4: Tsqlite3_result_func){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_text".}
-proc sqlite3_result_text16*(para1: Psqlite3_context, para2: pointer, 
-                            para3: int32, para4: Tsqlite3_result_func){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_text16".}
-proc sqlite3_result_text16le*(para1: Psqlite3_context, para2: pointer, 
-                              para3: int32, para4: Tsqlite3_result_func){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_text16le".}
-proc sqlite3_result_text16be*(para1: Psqlite3_context, para2: pointer, 
-                              para3: int32, para4: Tsqlite3_result_func){.cdecl, 
-    dynlib: Sqlite3Lib, importc: "sqlite3_result_text16be".}
-proc sqlite3_result_value*(para1: Psqlite3_context, para2: Psqlite3_value){.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_result_value".}
-proc sqlite3_create_collation*(para1: Psqlite3, zName: cstring, eTextRep: int32, 
-                               para4: pointer, 
-                               xCompare: Tsqlite3_create_collation_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_collation".}
-proc sqlite3_create_collation16*(para1: Psqlite3, zName: cstring, 
-                                 eTextRep: int32, para4: pointer, 
-                                 xCompare: Tsqlite3_create_collation_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_collation16".}
-proc sqlite3_collation_needed*(para1: Psqlite3, para2: pointer, 
-                               para3: Tsqlite3_collation_needed_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_collation_needed".}
-proc sqlite3_collation_needed16*(para1: Psqlite3, para2: pointer, 
-                                 para3: Tsqlite3_collation_needed_func): int32{.
-    cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_collation_needed16".}
-proc sqlite3_libversion*(): cstring{.cdecl, dynlib: Sqlite3Lib, 
-                                     importc: "sqlite3_libversion".}
-  #Alias for allowing better code portability (win32 is not working with external variables) 
-proc sqlite3_version*(): cstring{.cdecl, dynlib: Sqlite3Lib, 
-                                  importc: "sqlite3_libversion".}
-  # Not published functions
-proc sqlite3_libversion_number*(): int32{.cdecl, dynlib: Sqlite3Lib, 
-    importc: "sqlite3_libversion_number".}
-  #function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_key';
-  #function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_rekey';
-  #function sqlite3_sleep(_para1:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_sleep';
-  #function sqlite3_expired(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_expired';
-  #function sqlite3_global_recover:longint;cdecl; external Sqlite3Lib name 'sqlite3_global_recover';
-# implementation
diff --git a/lib/oldwrappers/tcl.nim b/lib/oldwrappers/tcl.nim
deleted file mode 100755
index 813714ecd..000000000
--- a/lib/oldwrappers/tcl.nim
+++ /dev/null
@@ -1,857 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module is a wrapper for the TCL programming language.
-
-#
-#  tcl.h --
-# 
-#  This header file describes the externally-visible facilities of the Tcl
-#  interpreter.
-# 
-#  Translated to Pascal Copyright (c) 2002 by Max Artemev
-#  aka Bert Raccoon (bert@furry.ru, bert_raccoon@freemail.ru)
-# 
-# 
-#  Copyright (c) 1998-2000 by Scriptics Corporation.
-#  Copyright (c) 1994-1998 Sun Microsystems, Inc.
-#  Copyright (c) 1993-1996 Lucent Technologies.
-#  Copyright (c) 1987-1994 John Ousterhout, The Regents of the
-#                          University of California, Berkeley.
-# 
-#  ***********************************************************************
-#  This program 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.
-#  ***********************************************************************
-# 
-
-{.deadCodeElim: on.}
-
-when defined(WIN32): 
-  const dllName = "tcl(85|84|83|82|81|80).dll"
-elif defined(macosx): 
-  const dllName = "libtcl(8.5|8.4|8.3|8.2|8.1).dynlib"
-else:
-  const dllName = "libtcl(8.5|8.4|8.3|8.2|8.1).so.(1|0)"
-
-const 
-  TCL_DESTROYED* = 0xDEADDEAD
-  TCL_OK* = 0
-  TCL_ERROR* = 1
-  TCL_RETURN* = 2
-  TCL_BREAK* = 3
-  TCL_CONTINUE* = 4
-  TCL_RESULT_SIZE* = 200
-  MAX_ARGV* = 0x00007FFF
-  TCL_VERSION_MAJOR* = 0
-  TCL_VERSION_MINOR* = 0
-  TCL_NO_EVAL* = 0x00010000
-  TCL_EVAL_GLOBAL* = 0x00020000 # Flag values passed to variable-related procedures. *
-  TCL_GLOBAL_ONLY* = 1
-  TCL_NAMESPACE_ONLY* = 2
-  TCL_APPEND_VALUE* = 4
-  TCL_LIST_ELEMENT* = 8
-  TCL_TRACE_READS* = 0x00000010
-  TCL_TRACE_WRITES* = 0x00000020
-  TCL_TRACE_UNSETS* = 0x00000040
-  TCL_TRACE_DESTROYED* = 0x00000080
-  TCL_INTERP_DESTROYED* = 0x00000100
-  TCL_LEAVE_ERR_MSG* = 0x00000200
-  TCL_PARSE_PART1* = 0x00000400 # Types for linked variables: *
-  TCL_LINK_INT* = 1
-  TCL_LINK_DOUBLE* = 2
-  TCL_LINK_BOOLEAN* = 3
-  TCL_LINK_STRING* = 4
-  TCL_LINK_READ_ONLY* = 0x00000080
-  TCL_SMALL_HASH_TABLE* = 4   # Hash Table *
-  TCL_STRING_KEYS* = 0
-  TCL_ONE_WORD_KEYS* = 1      # Const/enums Tcl_QueuePosition *
-                              # typedef enum {
-  TCL_QUEUE_TAIL* = 0
-  TCL_QUEUE_HEAD* = 1
-  TCL_QUEUE_MARK* = 2         #} Tcl_QueuePosition;
-                              # Event Flags
-  TCL_DONT_WAIT* = 1 shl 1
-  TCL_WINDOW_EVENTS* = 1 shl 2
-  TCL_FILE_EVENTS* = 1 shl 3
-  TCL_TIMER_EVENTS* = 1 shl 4
-  TCL_IDLE_EVENTS* = 1 shl 5  # WAS 0x10 ???? *
-  TCL_ALL_EVENTS* = not TCL_DONT_WAIT 
-
-  TCL_VOLATILE* = 1
-  TCL_STATIC* = 0
-  TCL_DYNAMIC* = 3            # Channel
-  TCL_STDIN* = 1 shl 1
-  TCL_STDOUT* = 1 shl 2
-  TCL_STDERR* = 1 shl 3
-  TCL_ENFORCE_MODE* = 1 shl 4
-  TCL_READABLE* = 1 shl 1
-  TCL_WRITABLE* = 1 shl 2
-  TCL_EXCEPTION* = 1 shl 3    # POSIX *
-  EPERM* = 1 # Operation not permitted; only the owner of the file (or other
-             # resource) or processes with special privileges can perform the
-             # operation.
-             #
-  ENOENT* = 2 # No such file or directory.  This is a "file doesn't exist" error
-              # for ordinary files that are referenced in contexts where they are
-              # expected to already exist.
-              #
-  ESRCH* = 3                  # No process matches the specified process ID. *
-  EINTR* = 4 # Interrupted function call; an asynchronous signal occurred and
-             # prevented completion of the call.  When this happens, you should
-             # try the call again.
-             #
-  EIO* = 5                    # Input/output error; usually used for physical read or write errors. *
-  ENXIO* = 6 # No such device or address.  The system tried to use the device
-             # represented by a file you specified, and it couldn't find the
-             # device.  This can mean that the device file was installed
-             # incorrectly, or that the physical device is missing or not
-             # correctly attached to the computer.
-             #
-  E2BIG* = 7 # Argument list too long; used when the arguments passed to a new
-             # program being executed with one of the `exec' functions (*note
-             # Executing a File::.) occupy too much memory space.  This condition
-             # never arises in the GNU system.
-             #
-  ENOEXEC* = 8 # Invalid executable file format.  This condition is detected by the
-               # `exec' functions; see *Note Executing a File::.
-               #
-  EBADF* = 9 # Bad file descriptor; for example, I/O on a descriptor that has been
-             # closed or reading from a descriptor open only for writing (or vice
-             # versa).
-             #
-  ECHILD* = 10 # There are no child processes.  This error happens on operations
-               # that are supposed to manipulate child processes, when there aren't
-               # any processes to manipulate.
-               #
-  EDEADLK* = 11 # Deadlock avoided; allocating a system resource would have resulted
-                # in a deadlock situation.  The system does not guarantee that it
-                # will notice all such situations.  This error means you got lucky
-                # and the system noticed; it might just hang.  *Note File Locks::,
-                # for an example.
-                #
-  ENOMEM* = 12 # No memory available.  The system cannot allocate more virtual
-               # memory because its capacity is full.
-               #
-  EACCES* = 13 # Permission denied; the file permissions do not allow the attempted
-               # operation.
-               #
-  EFAULT* = 14 # Bad address; an invalid pointer was detected.  In the GNU system,
-               # this error never happens; you get a signal instead.
-               #
-  ENOTBLK* = 15 # A file that isn't a block special file was given in a situation
-                # that requires one.  For example, trying to mount an ordinary file
-                # as a file system in Unix gives this error.
-                #
-  EBUSY* = 16 # Resource busy; a system resource that can't be shared is already
-              # in use.  For example, if you try to delete a file that is the root
-              # of a currently mounted filesystem, you get this error.
-              #
-  EEXIST* = 17 # File exists; an existing file was specified in a context where it
-               # only makes sense to specify a new file.
-               #
-  EXDEV* = 18 # An attempt to make an improper link across file systems was
-              # detected.  This happens not only when you use `link' (*note Hard
-              # Links::.) but also when you rename a file with `rename' (*note
-              # Renaming Files::.).
-              #
-  ENODEV* = 19 # The wrong type of device was given to a function that expects a
-               # particular sort of device.
-               #
-  ENOTDIR* = 20 # A file that isn't a directory was specified when a directory is
-                # required.
-                #
-  EISDIR* = 21 # File is a directory; you cannot open a directory for writing, or
-               # create or remove hard links to it.
-               #
-  EINVAL* = 22 # Invalid argument.  This is used to indicate various kinds of
-               # problems with passing the wrong argument to a library function.
-               #
-  EMFILE* = 24 # The current process has too many files open and can't open any
-               # more.  Duplicate descriptors do count toward this limit.
-               #
-               # In BSD and GNU, the number of open files is controlled by a
-               # resource limit that can usually be increased.  If you get this
-               # error, you might want to increase the `RLIMIT_NOFILE' limit or
-               # make it unlimited; *note Limits on Resources::..
-               #
-  ENFILE* = 23 # There are too many distinct file openings in the entire system.
-               # Note that any number of linked channels count as just one file
-               # opening; see *Note Linked Channels::.  This error never occurs in
-               # the GNU system.
-               #
-  ENOTTY* = 25 # Inappropriate I/O control operation, such as trying to set terminal
-               # modes on an ordinary file.
-               #
-  ETXTBSY* = 26 # An attempt to execute a file that is currently open for writing, or
-                # write to a file that is currently being executed.  Often using a
-                # debugger to run a program is considered having it open for writing
-                # and will cause this error.  (The name stands for "text file
-                # busy".)  This is not an error in the GNU system; the text is
-                # copied as necessary.
-                #
-  EFBIG* = 27 # File too big; the size of a file would be larger than allowed by
-              # the system.
-              #
-  ENOSPC* = 28 # No space left on device; write operation on a file failed because
-               # the disk is full.
-               #
-  ESPIPE* = 29                # Invalid seek operation (such as on a pipe).  *
-  EROFS* = 30                 # An attempt was made to modify something on a read-only file system.  *
-  EMLINK* = 31 # Too many links; the link count of a single file would become too
-               # large.  `rename' can cause this error if the file being renamed
-               # already has as many links as it can take (*note Renaming Files::.).
-               #
-  EPIPE* = 32 # Broken pipe; there is no process reading from the other end of a
-              # pipe.  Every library function that returns this error code also
-              # generates a `SIGPIPE' signal; this signal terminates the program
-              # if not handled or blocked.  Thus, your program will never actually
-              # see `EPIPE' unless it has handled or blocked `SIGPIPE'.
-              #
-  EDOM* = 33 # Domain error; used by mathematical functions when an argument
-             # value does not fall into the domain over which the function is
-             # defined.
-             #
-  ERANGE* = 34 # Range error; used by mathematical functions when the result value
-               # is not representable because of overflow or underflow.
-               #
-  EAGAIN* = 35 # Resource temporarily unavailable; the call might work if you try
-               # again later.  The macro `EWOULDBLOCK' is another name for `EAGAIN';
-               # they are always the same in the GNU C library.
-               #
-  EWOULDBLOCK* = EAGAIN # In the GNU C library, this is another name for `EAGAIN' (above).
-                        # The values are always the same, on every operating system.
-                        # C libraries in many older Unix systems have `EWOULDBLOCK' as a
-                        # separate error code.
-                        #
-  EINPROGRESS* = 36 # An operation that cannot complete immediately was initiated on an
-                    # object that has non-blocking mode selected.  Some functions that
-                    # must always block (such as `connect'; *note Connecting::.) never
-                    # return `EAGAIN'.  Instead, they return `EINPROGRESS' to indicate
-                    # that the operation has begun and will take some time.  Attempts to
-                    # manipulate the object before the call completes return `EALREADY'.
-                    # You can use the `select' function to find out when the pending
-                    # operation has completed; *note Waiting for I/O::..
-                    #
-  EALREADY* = 37 # An operation is already in progress on an object that has
-                 # non-blocking mode selected.
-                 #
-  ENOTSOCK* = 38              # A file that isn't a socket was specified when a socket is required.  *
-  EDESTADDRREQ* = 39 # No default destination address was set for the socket.  You get
-                     # this error when you try to transmit data over a connectionless
-                     # socket, without first specifying a destination for the data with
-                     # `connect'.
-                     #
-  EMSGSIZE* = 40 # The size of a message sent on a socket was larger than the
-                 # supported maximum size.
-                 #
-  EPROTOTYPE* = 41 # The socket type does not support the requested communications
-                   # protocol.
-                   #
-  ENOPROTOOPT* = 42 # You specified a socket option that doesn't make sense for the
-                    # particular protocol being used by the socket.  *Note Socket
-                    # Options::.
-                    #
-  EPROTONOSUPPORT* = 43 # The socket domain does not support the requested communications
-                        # protocol (perhaps because the requested protocol is completely
-                        # invalid.) *Note Creating a Socket::.
-                        #
-  ESOCKTNOSUPPORT* = 44       # The socket type is not supported.  *
-  EOPNOTSUPP* = 45 # The operation you requested is not supported.  Some socket
-                   # functions don't make sense for all types of sockets, and others
-                   # may not be implemented for all communications protocols.  In the
-                   # GNU system, this error can happen for many calls when the object
-                   # does not support the particular operation; it is a generic
-                   # indication that the server knows nothing to do for that call.
-                   #
-  EPFNOSUPPORT* = 46 # The socket communications protocol family you requested is not
-                     # supported.
-                     #
-  EAFNOSUPPORT* = 47 # The address family specified for a socket is not supported; it is
-                     # inconsistent with the protocol being used on the socket.  *Note
-                     # Sockets::.
-                     #
-  EADDRINUSE* = 48 # The requested socket address is already in use.  *Note Socket
-                   # Addresses::.
-                   #
-  EADDRNOTAVAIL* = 49 # The requested socket address is not available; for example, you
-                      # tried to give a socket a name that doesn't match the local host
-                      # name.  *Note Socket Addresses::.
-                      #
-  ENETDOWN* = 50              # A socket operation failed because the network was down.  *
-  ENETUNREACH* = 51 # A socket operation failed because the subnet containing the remote
-                    # host was unreachable.
-                    #
-  ENETRESET* = 52             # A network connection was reset because the remote host crashed.  *
-  ECONNABORTED* = 53          # A network connection was aborted locally. *
-  ECONNRESET* = 54 # A network connection was closed for reasons outside the control of
-                   # the local host, such as by the remote machine rebooting or an
-                   # unrecoverable protocol violation.
-                   #
-  ENOBUFS* = 55 # The kernel's buffers for I/O operations are all in use.  In GNU,
-                # this error is always synonymous with `ENOMEM'; you may get one or
-                # the other from network operations.
-                #
-  EISCONN* = 56 # You tried to connect a socket that is already connected.  *Note
-                # Connecting::.
-                #
-  ENOTCONN* = 57 # The socket is not connected to anything.  You get this error when
-                 # you try to transmit data over a socket, without first specifying a
-                 # destination for the data.  For a connectionless socket (for
-                 # datagram protocols, such as UDP), you get `EDESTADDRREQ' instead.
-                 #
-  ESHUTDOWN* = 58             # The socket has already been shut down.  *
-  ETOOMANYREFS* = 59          # ???  *
-  ETIMEDOUT* = 60 # A socket operation with a specified timeout received no response
-                  # during the timeout period.
-                  #
-  ECONNREFUSED* = 61 # A remote host refused to allow the network connection (typically
-                     # because it is not running the requested service).
-                     #
-  ELOOP* = 62 # Too many levels of symbolic links were encountered in looking up a
-              # file name.  This often indicates a cycle of symbolic links.
-              #
-  ENAMETOOLONG* = 63 # Filename too long (longer than `PATH_MAX'; *note Limits for
-                     # Files::.) or host name too long (in `gethostname' or
-                     # `sethostname'; *note Host Identification::.).
-                     #
-  EHOSTDOWN* = 64             # The remote host for a requested network connection is down.  *
-  EHOSTUNREACH* = 65 # The remote host for a requested network connection is not
-                     # reachable.
-                     #
-  ENOTEMPTY* = 66 # Directory not empty, where an empty directory was expected.
-                  # Typically, this error occurs when you are trying to delete a
-                  # directory.
-                  #
-  EPROCLIM* = 67 # This means that the per-user limit on new process would be
-                 # exceeded by an attempted `fork'.  *Note Limits on Resources::, for
-                 # details on the `RLIMIT_NPROC' limit.
-                 #
-  EUSERS* = 68                # The file quota system is confused because there are too many users.  *
-  EDQUOT* = 69                # The user's disk quota was exceeded.  *
-  ESTALE* = 70 # Stale NFS file handle.  This indicates an internal confusion in
-               # the NFS system which is due to file system rearrangements on the
-               # server host.  Repairing this condition usually requires unmounting
-               # and remounting the NFS file system on the local host.
-               #
-  EREMOTE* = 71 # An attempt was made to NFS-mount a remote file system with a file
-                # name that already specifies an NFS-mounted file.  (This is an
-                # error on some operating systems, but we expect it to work properly
-                # on the GNU system, making this error code impossible.)
-                #
-  EBADRPC* = 72               # ???  *
-  ERPCMISMATCH* = 73          # ???  *
-  EPROGUNAVAIL* = 74          # ???  *
-  EPROGMISMATCH* = 75         # ???  *
-  EPROCUNAVAIL* = 76          # ???  *
-  ENOLCK* = 77 # No locks available.  This is used by the file locking facilities;
-               # see *Note File Locks::.  This error is never generated by the GNU
-               # system, but it can result from an operation to an NFS server
-               # running another operating system.
-               #
-  ENOSYS* = 78 # Function not implemented.  Some functions have commands or options
-               # defined that might not be supported in all implementations, and
-               # this is the kind of error you get if you request them and they are
-               # not supported.
-               #
-  EFTYPE* = 79 # Inappropriate file type or format.  The file was the wrong type
-               # for the operation, or a data file had the wrong format.
-               # On some systems `chmod' returns this error if you try to set the
-               # sticky bit on a non-directory file; *note Setting Permissions::..
-               #
-
-type 
-  Tcl_Argv* = cstringArray
-  Tcl_ClientData* = pointer
-  Tcl_FreeProc* = proc (theBlock: pointer){.cdecl.}
-  PTcl_Interp* = ptr Tcl_Interp
-  Tcl_Interp*{.final.} = object  #  Event Definitions  *
-    result*: cstring # Do not access this directly. Use
-                     #                          * Tcl_GetStringResult since result
-                     #                          * may be pointing to an object
-                     #                          *
-    freeProc*: Tcl_FreeProc
-    errorLine*: int
-
-  TTcl_EventSetupProc* = proc (clientData: Tcl_ClientData, flags: int){.cdecl.}
-  TTcl_EventCheckProc* = TTcl_EventSetupProc
-  PTcl_Event* = ptr Tcl_Event
-  TTcl_EventProc* = proc (evPtr: PTcl_Event, flags: int): int{.cdecl.}
-  Tcl_Event*{.final.} = object 
-    prc*: TTcl_EventProc
-    nextPtr*: PTcl_Event
-    ClientData*: TObject      # ClientData is just pointer.*
-  
-  PTcl_Time* = ptr Tcl_Time
-  Tcl_Time*{.final.} = object 
-    sec*: int32               # Seconds. * 
-    usec*: int32              # Microseconds. * 
-  
-  Tcl_TimerToken* = pointer
-  PInteger* = ptr int
-  PTcl_HashTable* = pointer
-  PTcl_HashEntry* = ptr Tcl_HashEntry
-  PPTcl_HashEntry* = ptr PTcl_HashEntry
-  Tcl_HashEntry*{.final.} = object  
-    nextPtr*: PTcl_HashEntry
-    tablePtr*: PTcl_HashTable
-    bucketPtr*: PPTcl_HashEntry
-    clientData*: Tcl_ClientData
-    key*: cstring
-
-  Tcl_HashFindProc* = proc (tablePtr: PTcl_HashTable, key: cstring): PTcl_HashEntry{.
-      cdecl.}
-  Tcl_HashCreateProc* = proc (tablePtr: PTcl_HashTable, key: cstring, 
-                              newPtr: PInteger): PTcl_HashEntry{.cdecl.}
-  PHashTable* = ptr Tcl_HashTable
-  Tcl_HashTable*{.final.} = object 
-    buckets*: ppTcl_HashEntry
-    staticBuckets*: array[0..TCL_SMALL_HASH_TABLE - 1, PTcl_HashEntry]
-    numBuckets*: int
-    numEntries*: int
-    rebuildSize*: int
-    downShift*: int
-    mask*: int
-    keyType*: int
-    findProc*: Tcl_HashFindProc
-    createProc*: Tcl_HashCreateProc
-
-  PTcl_HashSearch* = ptr Tcl_HashSearch
-  Tcl_HashSearch*{.final.} = object 
-    tablePtr*: PTcl_HashTable
-    nextIndex*: int
-    nextEntryPtr*: PTcl_HashEntry
-
-  TTclAppInitProc* = proc (interp: pTcl_Interp): int{.cdecl.}
-  TTclPackageInitProc* = proc (interp: pTcl_Interp): int{.cdecl.}
-  TTclCmdProc* = proc (clientData: Tcl_ClientData, interp: pTcl_Interp, 
-                       argc: int, argv: Tcl_Argv): int{.cdecl.}
-  TTclVarTraceProc* = proc (clientData: Tcl_ClientData, interp: pTcl_Interp, 
-                            varName: cstring, elemName: cstring, flags: int): cstring{.
-      cdecl.}
-  TTclFreeProc* = proc (theBlock: pointer){.cdecl.}
-  TTclInterpDeleteProc* = proc (clientData: Tcl_ClientData, interp: pTcl_Interp){.
-      cdecl.}
-  TTclCmdDeleteProc* = proc (clientData: Tcl_ClientData){.cdecl.}
-  TTclNamespaceDeleteProc* = proc (clientData: Tcl_ClientData){.cdecl.}
-
-const 
-  TCL_DSTRING_STATIC_SIZE* = 200
-
-type 
-  PTcl_DString* = ptr Tcl_DString
-  Tcl_DString*{.final.} = object 
-    str*: cstring
-    len*: int
-    spaceAvl*: int
-    staticSpace*: array[0..TCL_DSTRING_STATIC_SIZE - 1, char]
-
-  PTcl_Channel* = ptr Tcl_Channel
-  Tcl_Channel*{.final.} = object 
-  TTclDriverBlockModeProc* = proc (instanceData: Tcl_ClientData, mode: int): int{.
-      cdecl.}
-  TTclDriverCloseProc* = proc (instanceData: Tcl_ClientData, interp: PTcl_Interp): int{.
-      cdecl.}
-  TTclDriverInputProc* = proc (instanceData: Tcl_ClientData, buf: cstring, 
-                               toRead: int, errorCodePtr: PInteger): int{.cdecl.}
-  TTclDriverOutputProc* = proc (instanceData: Tcl_ClientData, buf: cstring, 
-                                toWrite: int, errorCodePtr: PInteger): int{.
-      cdecl.}
-  TTclDriverSeekProc* = proc (instanceData: Tcl_ClientData, offset: int32, 
-                              mode: int, errorCodePtr: PInteger): int{.cdecl.}
-  TTclDriverSetOptionProc* = proc (instanceData: Tcl_ClientData, 
-                                   interp: PTcl_Interp, optionName: cstring, 
-                                   value: cstring): int{.cdecl.}
-  TTclDriverGetOptionProc* = proc (instanceData: Tcl_ClientData, 
-                                   interp: pTcl_Interp, optionName: cstring, 
-                                   dsPtr: PTcl_DString): int{.cdecl.}
-  TTclDriverWatchProc* = proc (instanceData: Tcl_ClientData, mask: int){.cdecl.}
-  TTclDriverGetHandleProc* = proc (instanceData: Tcl_ClientData, direction: int, 
-                                   handlePtr: var Tcl_ClientData): int{.cdecl.}
-  PTcl_ChannelType* = ptr Tcl_ChannelType
-  Tcl_ChannelType*{.final.} = object 
-    typeName*: cstring
-    blockModeProc*: TTclDriverBlockModeProc
-    closeProc*: TTclDriverCloseProc
-    inputProc*: TTclDriverInputProc
-    ouputProc*: TTclDriverOutputProc
-    seekProc*: TTclDriverSeekProc
-    setOptionProc*: TTclDriverSetOptionProc
-    getOptionProc*: TTclDriverGetOptionProc
-    watchProc*: TTclDriverWatchProc
-    getHandleProc*: TTclDriverGetHandleProc
-
-  TTclChannelProc* = proc (clientData: Tcl_ClientData, mask: int){.cdecl.}
-  PTcl_Obj* = ptr Tcl_Obj
-  PPTcl_Obj* = ptr PTcl_Obj
-  Tcl_Obj*{.final.} = object 
-    refCount*: int            # ...
-  
-  TTclObjCmdProc* = proc (clientData: Tcl_ClientData, interp: PTcl_Interp, 
-                          objc: int, PPObj: PPTcl_Obj): int{.cdecl.}
-  PTcl_Namespace* = ptr Tcl_Namespace
-  Tcl_Namespace*{.final.} = object 
-    name*: cstring
-    fullName*: cstring
-    clientData*: Tcl_ClientData
-    deleteProc*: TTclNamespaceDeleteProc
-    parentPtr*: PTcl_Namespace
-
-  PTcl_CallFrame* = ptr Tcl_CallFrame
-  Tcl_CallFrame*{.final.} = object 
-    nsPtr*: PTcl_Namespace
-    dummy1*: int
-    dummy2*: int
-    dummy3*: cstring
-    dummy4*: cstring
-    dummy5*: cstring
-    dummy6*: int
-    dummy7*: cstring
-    dummy8*: cstring
-    dummy9*: int
-    dummy10*: cstring
-
-  PTcl_CmdInfo* = ptr Tcl_CmdInfo
-  Tcl_CmdInfo*{.final.} = object 
-    isNativeObjectProc*: int
-    objProc*: TTclObjCmdProc
-    objClientData*: Tcl_ClientData
-    prc*: TTclCmdProc
-    clientData*: Tcl_ClientData
-    deleteProc*: TTclCmdDeleteProc
-    deleteData*: Tcl_ClientData
-    namespacePtr*: pTcl_Namespace
-
-  pTcl_Command* = ptr Tcl_Command
-  Tcl_Command*{.final.} = object  #       hPtr            : pTcl_HashEntry;
-                                  #        nsPtr           : pTcl_Namespace;
-                                  #        refCount        : integer;
-                                  #        isCmdEpoch      : integer;
-                                  #        compileProc     : pointer;
-                                  #        objProc         : pointer;
-                                  #        objClientData   : Tcl_ClientData;
-                                  #        proc            : pointer;
-                                  #        clientData      : Tcl_ClientData;
-                                  #        deleteProc      : TTclCmdDeleteProc;
-                                  #        deleteData      : Tcl_ClientData;
-                                  #        deleted         : integer;
-                                  #        importRefPtr    : pointer;
-                                  #
-
-type 
-  TTclPanicProc* = proc (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: cstring){.
-      cdecl.}                 # 1/15/97 orig. Tcl style
-  TTclClientDataProc* = proc (clientData: Tcl_ClientData){.cdecl.}
-  TTclIdleProc* = proc (clientData: Tcl_ClientData){.cdecl.}
-  TTclTimerProc* = TTclIdleProc
-  TTclCreateCloseHandler* = proc (channel: pTcl_Channel, 
-                                  prc: TTclClientDataProc, 
-                                  clientData: Tcl_ClientData){.cdecl.}
-  TTclDeleteCloseHandler* = TTclCreateCloseHandler
-  TTclEventDeleteProc* = proc (evPtr: pTcl_Event, clientData: Tcl_ClientData): int{.
-      cdecl.}
-
-proc Tcl_Alloc*(size: int): cstring{.cdecl, dynlib: dllName, importc.}
-proc Tcl_CreateInterp*(): pTcl_Interp{.cdecl, dynlib: dllName, importc.}
-proc Tcl_DeleteInterp*(interp: pTcl_Interp){.cdecl, dynlib: dllName, importc.}
-proc Tcl_ResetResult*(interp: pTcl_Interp){.cdecl, dynlib: dllName, importc.}
-proc Tcl_Eval*(interp: pTcl_Interp, script: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_EvalFile*(interp: pTcl_Interp, filename: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_AddErrorInfo*(interp: pTcl_Interp, message: cstring){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_BackgroundError*(interp: pTcl_Interp){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_CreateCommand*(interp: pTcl_Interp, name: cstring, 
-                        cmdProc: TTclCmdProc, clientData: Tcl_ClientData, 
-                        deleteProc: TTclCmdDeleteProc): pTcl_Command{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DeleteCommand*(interp: pTcl_Interp, name: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CallWhenDeleted*(interp: pTcl_Interp, prc: TTclInterpDeleteProc, 
-                          clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DontCallWhenDeleted*(interp: pTcl_Interp, prc: TTclInterpDeleteProc, 
-                              clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CommandComplete*(cmd: cstring): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_LinkVar*(interp: pTcl_Interp, varName: cstring, varAddr: pointer, 
-                  typ: int): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_UnlinkVar*(interp: pTcl_Interp, varName: cstring){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_TraceVar*(interp: pTcl_Interp, varName: cstring, flags: int, 
-                   prc: TTclVarTraceProc, clientData: Tcl_ClientData): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_TraceVar2*(interp: pTcl_Interp, varName: cstring, elemName: cstring, 
-                    flags: int, prc: TTclVarTraceProc, 
-                    clientData: Tcl_ClientData): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_UntraceVar*(interp: pTcl_Interp, varName: cstring, flags: int, 
-                     prc: TTclVarTraceProc, clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_UntraceVar2*(interp: pTcl_Interp, varName: cstring, elemName: cstring, 
-                      flags: int, prc: TTclVarTraceProc, 
-                      clientData: Tcl_ClientData){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_GetVar*(interp: pTcl_Interp, varName: cstring, flags: int): cstring{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GetVar2*(interp: pTcl_Interp, varName: cstring, elemName: cstring, 
-                  flags: int): cstring{.cdecl, dynlib: dllName, importc.}
-proc Tcl_SetVar*(interp: pTcl_Interp, varName: cstring, newValue: cstring, 
-                 flags: int): cstring{.cdecl, dynlib: dllName, importc.}
-proc Tcl_SetVar2*(interp: pTcl_Interp, varName: cstring, elemName: cstring, 
-                  newValue: cstring, flags: int): cstring{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_UnsetVar*(interp: pTcl_Interp, varName: cstring, flags: int): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_UnsetVar2*(interp: pTcl_Interp, varName: cstring, elemName: cstring, 
-                    flags: int): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_SetResult*(interp: pTcl_Interp, newValue: cstring, 
-                    freeProc: TTclFreeProc){.cdecl, dynlib: dllName, importc.}
-proc Tcl_FirstHashEntry*(hashTbl: pTcl_HashTable, searchInfo: var Tcl_HashSearch): pTcl_HashEntry{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_NextHashEntry*(searchInfo: var Tcl_HashSearch): pTcl_HashEntry{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_InitHashTable*(hashTbl: pTcl_HashTable, keyType: int){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_StringMatch*(str: cstring, pattern: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-
-proc Tcl_GetErrno*(): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_SetErrno*(val: int){.cdecl, dynlib: dllName, importc.}
-proc Tcl_SetPanicProc*(prc: TTclPanicProc){.cdecl, dynlib: dllName, importc.}
-proc Tcl_PkgProvide*(interp: pTcl_Interp, name: cstring, version: cstring): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_StaticPackage*(interp: pTcl_Interp, pkgName: cstring, 
-                        initProc: TTclPackageInitProc, 
-                        safeInitProc: TTclPackageInitProc){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CreateEventSource*(setupProc: TTcl_EventSetupProc, 
-                            checkProc: TTcl_EventCheckProc, 
-                            clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DeleteEventSource*(setupProc: TTcl_EventSetupProc, 
-                            checkProc: TTcl_EventCheckProc, 
-                            clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_QueueEvent*(evPtr: pTcl_Event, pos: int){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_SetMaxBlockTime*(timePtr: pTcl_Time){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_DeleteEvents*(prc: TTclEventDeleteProc, clientData: Tcl_ClientData){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_DoOneEvent*(flags: int): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_DoWhenIdle*(prc: TTclIdleProc, clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CancelIdleCall*(prc: TTclIdleProc, clientData: Tcl_ClientData){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CreateTimerHandler*(milliseconds: int, prc: TTclTimerProc, 
-                             clientData: Tcl_ClientData): Tcl_TimerToken{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DeleteTimerHandler*(token: Tcl_TimerToken){.cdecl, dynlib: dllName, 
-    importc.}
-  #    procedure Tcl_CreateModalTimeout(milliseconds: integer; prc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external dllName;
-  #    procedure Tcl_DeleteModalTimeout(prc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external dllName;
-proc Tcl_SplitList*(interp: pTcl_Interp, list: cstring, argcPtr: var int, 
-                    argvPtr: var Tcl_Argv): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_Merge*(argc: int, argv: Tcl_Argv): cstring{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_Free*(p: cstring){.cdecl, dynlib: dllName, importc.}
-proc Tcl_Init*(interp: pTcl_Interp): int{.cdecl, dynlib: dllName, importc.}
-  #    procedure Tcl_InterpDeleteProc(clientData: Tcl_ClientData; interp: pTcl_Interp); cdecl; external dllName;
-proc Tcl_GetAssocData*(interp: pTcl_Interp, key: cstring, 
-                       prc: var TTclInterpDeleteProc): Tcl_ClientData{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DeleteAssocData*(interp: pTcl_Interp, key: cstring){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_SetAssocData*(interp: pTcl_Interp, key: cstring, 
-                       prc: TTclInterpDeleteProc, clientData: Tcl_ClientData){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_IsSafe*(interp: pTcl_Interp): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_MakeSafe*(interp: pTcl_Interp): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_CreateSlave*(interp: pTcl_Interp, slaveName: cstring, isSafe: int): pTcl_Interp{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GetSlave*(interp: pTcl_Interp, slaveName: cstring): pTcl_Interp{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GetMaster*(interp: pTcl_Interp): pTcl_Interp{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GetInterpPath*(askingInterp: pTcl_Interp, slaveInterp: pTcl_Interp): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_CreateAlias*(slaveInterp: pTcl_Interp, srcCmd: cstring, 
-                      targetInterp: pTcl_Interp, targetCmd: cstring, argc: int, 
-                      argv: Tcl_Argv): int{.cdecl, dynlib: dllName, importc.}
-proc Tcl_GetAlias*(interp: pTcl_Interp, srcCmd: cstring, 
-                   targetInterp: var pTcl_Interp, targetCmd: var cstring, 
-                   argc: var int, argv: var Tcl_Argv): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_ExposeCommand*(interp: pTcl_Interp, hiddenCmdName: cstring, 
-                        cmdName: cstring): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_HideCommand*(interp: pTcl_Interp, cmdName: cstring, 
-                      hiddenCmdName: cstring): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_EventuallyFree*(clientData: Tcl_ClientData, freeProc: TTclFreeProc){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_Preserve*(clientData: Tcl_ClientData){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_Release*(clientData: Tcl_ClientData){.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_InterpDeleted*(interp: pTcl_Interp): int{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_GetCommandInfo*(interp: pTcl_Interp, cmdName: cstring, 
-                         info: var Tcl_CmdInfo): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_SetCommandInfo*(interp: pTcl_Interp, cmdName: cstring, 
-                         info: var Tcl_CmdInfo): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_FindExecutable*(path: cstring){.cdecl, dynlib: dllName, importc.}
-proc Tcl_GetStringResult*(interp: pTcl_Interp): cstring{.cdecl, 
-    dynlib: dllName, importc.}
-  #v1.0
-proc Tcl_FindCommand*(interp: pTcl_Interp, cmdName: cstring, 
-                      contextNsPtr: pTcl_Namespace, flags: int): Tcl_Command{.
-    cdecl, dynlib: dllName, importc.}
-  #v1.0
-proc Tcl_DeleteCommandFromToken*(interp: pTcl_Interp, cmd: pTcl_Command): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_CreateNamespace*(interp: pTcl_Interp, name: cstring, 
-                          clientData: Tcl_ClientData, 
-                          deleteProc: TTclNamespaceDeleteProc): pTcl_Namespace{.
-    cdecl, dynlib: dllName, importc.}
-  #v1.0
-proc Tcl_DeleteNamespace*(namespacePtr: pTcl_Namespace){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_FindNamespace*(interp: pTcl_Interp, name: cstring, 
-                        contextNsPtr: pTcl_Namespace, flags: int): pTcl_Namespace{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_Export*(interp: pTcl_Interp, namespacePtr: pTcl_Namespace, 
-                 pattern: cstring, resetListFirst: int): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_Import*(interp: pTcl_Interp, namespacePtr: pTcl_Namespace, 
-                 pattern: cstring, allowOverwrite: int): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GetCurrentNamespace*(interp: pTcl_Interp): pTcl_Namespace{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GetGlobalNamespace*(interp: pTcl_Interp): pTcl_Namespace{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_PushCallFrame*(interp: pTcl_Interp, callFramePtr: var Tcl_CallFrame, 
-                        namespacePtr: pTcl_Namespace, isProcCallFrame: int): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_PopCallFrame*(interp: pTcl_Interp){.cdecl, dynlib: dllName, importc.}
-proc Tcl_VarEval*(interp: pTcl_Interp): int{.cdecl, varargs, 
-    dynlib: dllName, importc.}
-  # For TkConsole.c *
-proc Tcl_RecordAndEval*(interp: pTcl_Interp, cmd: cstring, flags: int): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GlobalEval*(interp: pTcl_Interp, command: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_DStringFree*(dsPtr: pTcl_DString){.cdecl, dynlib: dllName, importc.}
-proc Tcl_DStringAppend*(dsPtr: pTcl_DString, str: cstring, length: int): cstring{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_DStringAppendElement*(dsPtr: pTcl_DString, str: cstring): cstring{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_DStringInit*(dsPtr: pTcl_DString){.cdecl, dynlib: dllName, importc.}
-proc Tcl_AppendResult*(interp: pTcl_Interp){.cdecl, varargs, 
-    dynlib: dllName, importc.}
-  # actually a "C" var array
-proc Tcl_SetStdChannel*(channel: pTcl_Channel, typ: int){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_SetChannelOption*(interp: pTcl_Interp, chan: pTcl_Channel, 
-                           optionName: cstring, newValue: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GetChannelOption*(interp: pTcl_Interp, chan: pTcl_Channel, 
-                           optionName: cstring, dsPtr: pTcl_DString): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_CreateChannel*(typePtr: pTcl_ChannelType, chanName: cstring, 
-                        instanceData: Tcl_ClientData, mask: int): pTcl_Channel{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_RegisterChannel*(interp: pTcl_Interp, channel: pTcl_Channel){.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_UnregisterChannel*(interp: pTcl_Interp, channel: pTcl_Channel): int{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_CreateChannelHandler*(chan: pTcl_Channel, mask: int, 
-                               prc: TTclChannelProc, clientData: Tcl_ClientData){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GetChannel*(interp: pTcl_Interp, chanName: cstring, modePtr: pInteger): pTcl_Channel{.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GetStdChannel*(typ: int): pTcl_Channel{.cdecl, dynlib: dllName, 
-    importc.}
-proc Tcl_Gets*(chan: pTcl_Channel, dsPtr: pTcl_DString): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_Write*(chan: pTcl_Channel, s: cstring, slen: int): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_Flush*(chan: pTcl_Channel): int{.cdecl, dynlib: dllName, importc.}
-  #    TclWinLoadLibrary      = function(name: PChar): HMODULE; cdecl; external dllName;
-proc Tcl_CreateExitHandler*(prc: TTclClientDataProc, clientData: Tcl_ClientData){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_DeleteExitHandler*(prc: TTclClientDataProc, clientData: Tcl_ClientData){.
-    cdecl, dynlib: dllName, importc.}
-proc Tcl_GetStringFromObj*(pObj: pTcl_Obj, pLen: pInteger): cstring{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_CreateObjCommand*(interp: pTcl_Interp, name: cstring, 
-                           cmdProc: TTclObjCmdProc, clientData: Tcl_ClientData, 
-                           deleteProc: TTclCmdDeleteProc): pTcl_Command{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_NewStringObj*(bytes: cstring, length: int): pTcl_Obj{.cdecl, 
-    dynlib: dllName, importc.}
-  #    procedure TclFreeObj(pObj: pTcl_Obj); cdecl; external dllName;
-proc Tcl_EvalObj*(interp: pTcl_Interp, pObj: pTcl_Obj): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc Tcl_GlobalEvalObj*(interp: pTcl_Interp, pObj: pTcl_Obj): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc TclRegComp*(exp: cstring): pointer{.cdecl, dynlib: dllName, importc.}
-proc TclRegExec*(prog: pointer, str: cstring, start: cstring): int{.cdecl, 
-    dynlib: dllName, importc.}
-proc TclRegError*(msg: cstring){.cdecl, dynlib: dllName, importc.}
-proc TclGetRegError*(): cstring{.cdecl, dynlib: dllName, importc.}
-proc Tcl_RegExpRange*(prog: pointer, index: int, head: var cstring, 
-                      tail: var cstring){.cdecl, dynlib: dllName, importc.}
-
-proc Tcl_GetCommandTable*(interp: pTcl_Interp): pHashTable =
-  if interp != nil: 
-    result = cast[pHashTable](cast[int](interp) + sizeof(Tcl_Interp) + 
-      sizeof(pointer))
-
-proc Tcl_CreateHashEntry*(tablePtr: pTcl_HashTable, key: cstring, 
-                          newPtr: pInteger): pTcl_HashEntry =
-  result = cast[pHashTable](tablePtr).createProc(tablePtr, key, newPtr)
-                          
-proc Tcl_FindHashEntry*(tablePtr: pTcl_HashTable, 
-                        key: cstring): pTcl_HashEntry =
-  result = cast[pHashTable](tablePtr).findProc(tablePtr, key)
-
-proc Tcl_SetHashValue*(h: pTcl_HashEntry, clientData: Tcl_ClientData) =
-  h.clientData = clientData
-
-proc Tcl_GetHashValue*(h: pTcl_HashEntry): Tcl_ClientData =
-  result = h.clientData
-
-proc Tcl_IncrRefCount*(pObj: pTcl_Obj) =
-  inc(pObj.refCount)
-
-proc Tcl_DecrRefCount*(pObj: pTcl_Obj) =
-  dec(pObj.refCount)
-  if pObj.refCount <= 0: 
-    dealloc(pObj)
-
-proc Tcl_IsShared*(pObj: pTcl_Obj): bool = 
-  return pObj.refCount > 1
-
-proc Tcl_GetHashKey*(hashTbl: pTcl_HashTable, 
-                     hashEntry: pTcl_HashEntry): cstring = 
-  if hashTbl == nil or hashEntry == nil: 
-    result = nil
-  else: 
-    result = hashEntry.key
-  
diff --git a/lib/oldwrappers/x11/cursorfont.nim b/lib/oldwrappers/x11/cursorfont.nim
deleted file mode 100755
index b262ad7c1..000000000
--- a/lib/oldwrappers/x11/cursorfont.nim
+++ /dev/null
@@ -1,110 +0,0 @@
-# $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ 
-#
-#
-#Copyright 1987, 1998  The Open Group
-#
-#Permission to use, copy, modify, distribute, and sell this software and its
-#documentation for any purpose is hereby granted without fee, provided that
-#the above copyright notice appear in all copies and that both that
-#copyright notice and this permission notice appear in supporting
-#documentation.
-#
-#The above copyright notice and this permission notice shall be included
-#in all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-#OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of The Open Group shall
-#not be used in advertising or otherwise to promote the sale, use or
-#other dealings in this Software without prior written authorization
-#from The Open Group.
-#
-#
-
-const 
-  XC_num_glyphs* = 154
-  XC_X_cursor* = 0
-  XC_arrow* = 2
-  XC_based_arrow_down* = 4
-  XC_based_arrow_up* = 6
-  XC_boat* = 8
-  XC_bogosity* = 10
-  XC_bottom_left_corner* = 12
-  XC_bottom_right_corner* = 14
-  XC_bottom_side* = 16
-  XC_bottom_tee* = 18
-  XC_box_spiral* = 20
-  XC_center_ptr* = 22
-  XC_circle* = 24
-  XC_clock* = 26
-  XC_coffee_mug* = 28
-  XC_cross* = 30
-  XC_cross_reverse* = 32
-  XC_crosshair* = 34
-  XC_diamond_cross* = 36
-  XC_dot* = 38
-  XC_dotbox* = 40
-  XC_double_arrow* = 42
-  XC_draft_large* = 44
-  XC_draft_small* = 46
-  XC_draped_box* = 48
-  XC_exchange* = 50
-  XC_fleur* = 52
-  XC_gobbler* = 54
-  XC_gumby* = 56
-  XC_hand1* = 58
-  XC_hand2* = 60
-  XC_heart* = 62
-  XC_icon* = 64
-  XC_iron_cross* = 66
-  XC_left_ptr* = 68
-  XC_left_side* = 70
-  XC_left_tee* = 72
-  XC_leftbutton* = 74
-  XC_ll_angle* = 76
-  XC_lr_angle* = 78
-  XC_man* = 80
-  XC_middlebutton* = 82
-  XC_mouse* = 84
-  XC_pencil* = 86
-  XC_pirate* = 88
-  XC_plus* = 90
-  XC_question_arrow* = 92
-  XC_right_ptr* = 94
-  XC_right_side* = 96
-  XC_right_tee* = 98
-  XC_rightbutton* = 100
-  XC_rtl_logo* = 102
-  XC_sailboat* = 104
-  XC_sb_down_arrow* = 106
-  XC_sb_h_double_arrow* = 108
-  XC_sb_left_arrow* = 110
-  XC_sb_right_arrow* = 112
-  XC_sb_up_arrow* = 114
-  XC_sb_v_double_arrow* = 116
-  XC_shuttle* = 118
-  XC_sizing* = 120
-  XC_spider* = 122
-  XC_spraycan* = 124
-  XC_star* = 126
-  XC_target* = 128
-  XC_tcross* = 130
-  XC_top_left_arrow* = 132
-  XC_top_left_corner* = 134
-  XC_top_right_corner* = 136
-  XC_top_side* = 138
-  XC_top_tee* = 140
-  XC_trek* = 142
-  XC_ul_angle* = 144
-  XC_umbrella* = 146
-  XC_ur_angle* = 148
-  XC_watch* = 150
-  XC_xterm* = 152
-
-# implementation
diff --git a/lib/oldwrappers/x11/keysym.nim b/lib/oldwrappers/x11/keysym.nim
deleted file mode 100755
index b1fe13b80..000000000
--- a/lib/oldwrappers/x11/keysym.nim
+++ /dev/null
@@ -1,1925 +0,0 @@
-#
-#Converted from X11/keysym.h and X11/keysymdef.h
-#
-#Capital letter consts renamed from XK_... to XKc_...
-# (since Pascal isn't case-sensitive)
-#
-#i.e.
-#C      Pascal
-#XK_a   XK_a
-#XK_A   XKc_A
-#
-
-#* default keysyms *
-
-const 
-  XK_VoidSymbol* = 0x00FFFFFF # void symbol 
-
-when defined(XK_MISCELLANY) or true: 
-  const
-    #*
-    # * TTY Functions, cleverly chosen to map to ascii, for convenience of
-    # * programming, but could have been arbitrary (at the cost of lookup
-    # * tables in client code.
-    # *
-    XK_BackSpace* = 0x0000FF08  # back space, back char 
-    XK_Tab* = 0x0000FF09
-    XK_Linefeed* = 0x0000FF0A   # Linefeed, LF 
-    XK_Clear* = 0x0000FF0B
-    XK_Return* = 0x0000FF0D     # Return, enter 
-    XK_Pause* = 0x0000FF13      # Pause, hold 
-    XK_Scroll_Lock* = 0x0000FF14
-    XK_Sys_Req* = 0x0000FF15
-    XK_Escape* = 0x0000FF1B
-    XK_Delete* = 0x0000FFFF     # Delete, rubout 
-                                # International & multi-key character composition 
-    XK_Multi_key* = 0x0000FF20  # Multi-key character compose 
-    XK_Codeinput* = 0x0000FF37
-    XK_SingleCandidate* = 0x0000FF3C
-    XK_MultipleCandidate* = 0x0000FF3D
-    XK_PreviousCandidate* = 0x0000FF3E # Japanese keyboard support 
-    XK_Kanji* = 0x0000FF21      # Kanji, Kanji convert 
-    XK_Muhenkan* = 0x0000FF22   # Cancel Conversion 
-    XK_Henkan_Mode* = 0x0000FF23 # Start/Stop Conversion 
-    XK_Henkan* = 0x0000FF23     # Alias for Henkan_Mode 
-    XK_Romaji* = 0x0000FF24     # to Romaji 
-    XK_Hiragana* = 0x0000FF25   # to Hiragana 
-    XK_Katakana* = 0x0000FF26   # to Katakana 
-    XK_Hiragana_Katakana* = 0x0000FF27 # Hiragana/Katakana toggle 
-    XK_Zenkaku* = 0x0000FF28    # to Zenkaku 
-    XK_Hankaku* = 0x0000FF29    # to Hankaku 
-    XK_Zenkaku_Hankaku* = 0x0000FF2A # Zenkaku/Hankaku toggle 
-    XK_Touroku* = 0x0000FF2B    # Add to Dictionary 
-    XK_Massyo* = 0x0000FF2C     # Delete from Dictionary 
-    XK_Kana_Lock* = 0x0000FF2D  # Kana Lock 
-    XK_Kana_Shift* = 0x0000FF2E # Kana Shift 
-    XK_Eisu_Shift* = 0x0000FF2F # Alphanumeric Shift 
-    XK_Eisu_toggle* = 0x0000FF30 # Alphanumeric toggle 
-    XK_Kanji_Bangou* = 0x0000FF37 # Codeinput 
-    XK_Zen_Koho* = 0x0000FF3D   # Multiple/All Candidate(s) 
-    XK_Mae_Koho* = 0x0000FF3E   # Previous Candidate 
-                                # = $FF31 thru = $FF3F are under XK_KOREAN 
-                                # Cursor control & motion 
-    XK_Home* = 0x0000FF50
-    XK_Left* = 0x0000FF51       # Move left, left arrow 
-    XK_Up* = 0x0000FF52         # Move up, up arrow 
-    XK_Right* = 0x0000FF53      # Move right, right arrow 
-    XK_Down* = 0x0000FF54       # Move down, down arrow 
-    XK_Prior* = 0x0000FF55      # Prior, previous 
-    XK_Page_Up* = 0x0000FF55
-    XK_Next* = 0x0000FF56       # Next 
-    XK_Page_Down* = 0x0000FF56
-    XK_End* = 0x0000FF57        # EOL 
-    XK_Begin* = 0x0000FF58      # BOL 
-                                # Misc Functions 
-    XK_Select* = 0x0000FF60     # Select, mark 
-    XK_Print* = 0x0000FF61
-    XK_Execute* = 0x0000FF62    # Execute, run, do 
-    XK_Insert* = 0x0000FF63     # Insert, insert here 
-    XK_Undo* = 0x0000FF65       # Undo, oops 
-    XK_Redo* = 0x0000FF66       # redo, again 
-    XK_Menu* = 0x0000FF67
-    XK_Find* = 0x0000FF68       # Find, search 
-    XK_Cancel* = 0x0000FF69     # Cancel, stop, abort, exit 
-    XK_Help* = 0x0000FF6A       # Help 
-    XK_Break* = 0x0000FF6B
-    XK_Mode_switch* = 0x0000FF7E # Character set switch 
-    XK_script_switch* = 0x0000FF7E # Alias for mode_switch 
-    XK_Num_Lock* = 0x0000FF7F   # Keypad Functions, keypad numbers cleverly chosen to map to ascii 
-    XK_KP_Space* = 0x0000FF80   # space 
-    XK_KP_Tab* = 0x0000FF89
-    XK_KP_Enter* = 0x0000FF8D   # enter 
-    XK_KP_F1* = 0x0000FF91      # PF1, KP_A, ... 
-    XK_KP_F2* = 0x0000FF92
-    XK_KP_F3* = 0x0000FF93
-    XK_KP_F4* = 0x0000FF94
-    XK_KP_Home* = 0x0000FF95
-    XK_KP_Left* = 0x0000FF96
-    XK_KP_Up* = 0x0000FF97
-    XK_KP_Right* = 0x0000FF98
-    XK_KP_Down* = 0x0000FF99
-    XK_KP_Prior* = 0x0000FF9A
-    XK_KP_Page_Up* = 0x0000FF9A
-    XK_KP_Next* = 0x0000FF9B
-    XK_KP_Page_Down* = 0x0000FF9B
-    XK_KP_End* = 0x0000FF9C
-    XK_KP_Begin* = 0x0000FF9D
-    XK_KP_Insert* = 0x0000FF9E
-    XK_KP_Delete* = 0x0000FF9F
-    XK_KP_Equal* = 0x0000FFBD   # equals 
-    XK_KP_Multiply* = 0x0000FFAA
-    XK_KP_Add* = 0x0000FFAB
-    XK_KP_Separator* = 0x0000FFAC # separator, often comma 
-    XK_KP_Subtract* = 0x0000FFAD
-    XK_KP_Decimal* = 0x0000FFAE
-    XK_KP_Divide* = 0x0000FFAF
-    XK_KP_0* = 0x0000FFB0
-    XK_KP_1* = 0x0000FFB1
-    XK_KP_2* = 0x0000FFB2
-    XK_KP_3* = 0x0000FFB3
-    XK_KP_4* = 0x0000FFB4
-    XK_KP_5* = 0x0000FFB5
-    XK_KP_6* = 0x0000FFB6
-    XK_KP_7* = 0x0000FFB7
-    XK_KP_8* = 0x0000FFB8
-    XK_KP_9* = 0x0000FFB9 #*
-                          # * Auxilliary Functions; note the duplicate definitions for left and right
-                          # * function keys;  Sun keyboards and a few other manufactures have such
-                          # * function key groups on the left and/or right sides of the keyboard.
-                          # * We've not found a keyboard with more than 35 function keys total.
-                          # *
-    XK_F1* = 0x0000FFBE
-    XK_F2* = 0x0000FFBF
-    XK_F3* = 0x0000FFC0
-    XK_F4* = 0x0000FFC1
-    XK_F5* = 0x0000FFC2
-    XK_F6* = 0x0000FFC3
-    XK_F7* = 0x0000FFC4
-    XK_F8* = 0x0000FFC5
-    XK_F9* = 0x0000FFC6
-    XK_F10* = 0x0000FFC7
-    XK_F11* = 0x0000FFC8
-    XK_L1* = 0x0000FFC8
-    XK_F12* = 0x0000FFC9
-    XK_L2* = 0x0000FFC9
-    XK_F13* = 0x0000FFCA
-    XK_L3* = 0x0000FFCA
-    XK_F14* = 0x0000FFCB
-    XK_L4* = 0x0000FFCB
-    XK_F15* = 0x0000FFCC
-    XK_L5* = 0x0000FFCC
-    XK_F16* = 0x0000FFCD
-    XK_L6* = 0x0000FFCD
-    XK_F17* = 0x0000FFCE
-    XK_L7* = 0x0000FFCE
-    XK_F18* = 0x0000FFCF
-    XK_L8* = 0x0000FFCF
-    XK_F19* = 0x0000FFD0
-    XK_L9* = 0x0000FFD0
-    XK_F20* = 0x0000FFD1
-    XK_L10* = 0x0000FFD1
-    XK_F21* = 0x0000FFD2
-    XK_R1* = 0x0000FFD2
-    XK_F22* = 0x0000FFD3
-    XK_R2* = 0x0000FFD3
-    XK_F23* = 0x0000FFD4
-    XK_R3* = 0x0000FFD4
-    XK_F24* = 0x0000FFD5
-    XK_R4* = 0x0000FFD5
-    XK_F25* = 0x0000FFD6
-    XK_R5* = 0x0000FFD6
-    XK_F26* = 0x0000FFD7
-    XK_R6* = 0x0000FFD7
-    XK_F27* = 0x0000FFD8
-    XK_R7* = 0x0000FFD8
-    XK_F28* = 0x0000FFD9
-    XK_R8* = 0x0000FFD9
-    XK_F29* = 0x0000FFDA
-    XK_R9* = 0x0000FFDA
-    XK_F30* = 0x0000FFDB
-    XK_R10* = 0x0000FFDB
-    XK_F31* = 0x0000FFDC
-    XK_R11* = 0x0000FFDC
-    XK_F32* = 0x0000FFDD
-    XK_R12* = 0x0000FFDD
-    XK_F33* = 0x0000FFDE
-    XK_R13* = 0x0000FFDE
-    XK_F34* = 0x0000FFDF
-    XK_R14* = 0x0000FFDF
-    XK_F35* = 0x0000FFE0
-    XK_R15* = 0x0000FFE0        # Modifiers 
-    XK_Shift_L* = 0x0000FFE1    # Left shift 
-    XK_Shift_R* = 0x0000FFE2    # Right shift 
-    XK_Control_L* = 0x0000FFE3  # Left control 
-    XK_Control_R* = 0x0000FFE4  # Right control 
-    XK_Caps_Lock* = 0x0000FFE5  # Caps lock 
-    XK_Shift_Lock* = 0x0000FFE6 # Shift lock 
-    XK_Meta_L* = 0x0000FFE7     # Left meta 
-    XK_Meta_R* = 0x0000FFE8     # Right meta 
-    XK_Alt_L* = 0x0000FFE9      # Left alt 
-    XK_Alt_R* = 0x0000FFEA      # Right alt 
-    XK_Super_L* = 0x0000FFEB    # Left super 
-    XK_Super_R* = 0x0000FFEC    # Right super 
-    XK_Hyper_L* = 0x0000FFED    # Left hyper 
-    XK_Hyper_R* = 0x0000FFEE    # Right hyper 
-# XK_MISCELLANY 
-#*
-# * ISO 9995 Function and Modifier Keys
-# * Byte 3 = = $FE
-# *
-
-when defined(XK_XKB_KEYS) or true: 
-  const
-    XK_ISO_Lock* = 0x0000FE01
-    XK_ISO_Level2_Latch* = 0x0000FE02
-    XK_ISO_Level3_Shift* = 0x0000FE03
-    XK_ISO_Level3_Latch* = 0x0000FE04
-    XK_ISO_Level3_Lock* = 0x0000FE05
-    XK_ISO_Group_Shift* = 0x0000FF7E # Alias for mode_switch 
-    XK_ISO_Group_Latch* = 0x0000FE06
-    XK_ISO_Group_Lock* = 0x0000FE07
-    XK_ISO_Next_Group* = 0x0000FE08
-    XK_ISO_Next_Group_Lock* = 0x0000FE09
-    XK_ISO_Prev_Group* = 0x0000FE0A
-    XK_ISO_Prev_Group_Lock* = 0x0000FE0B
-    XK_ISO_First_Group* = 0x0000FE0C
-    XK_ISO_First_Group_Lock* = 0x0000FE0D
-    XK_ISO_Last_Group* = 0x0000FE0E
-    XK_ISO_Last_Group_Lock* = 0x0000FE0F
-    XK_ISO_Left_Tab* = 0x0000FE20
-    XK_ISO_Move_Line_Up* = 0x0000FE21
-    XK_ISO_Move_Line_Down* = 0x0000FE22
-    XK_ISO_Partial_Line_Up* = 0x0000FE23
-    XK_ISO_Partial_Line_Down* = 0x0000FE24
-    XK_ISO_Partial_Space_Left* = 0x0000FE25
-    XK_ISO_Partial_Space_Right* = 0x0000FE26
-    XK_ISO_Set_Margin_Left* = 0x0000FE27
-    XK_ISO_Set_Margin_Right* = 0x0000FE28
-    XK_ISO_Release_Margin_Left* = 0x0000FE29
-    XK_ISO_Release_Margin_Right* = 0x0000FE2A
-    XK_ISO_Release_Both_Margins* = 0x0000FE2B
-    XK_ISO_Fast_Cursor_Left* = 0x0000FE2C
-    XK_ISO_Fast_Cursor_Right* = 0x0000FE2D
-    XK_ISO_Fast_Cursor_Up* = 0x0000FE2E
-    XK_ISO_Fast_Cursor_Down* = 0x0000FE2F
-    XK_ISO_Continuous_Underline* = 0x0000FE30
-    XK_ISO_Discontinuous_Underline* = 0x0000FE31
-    XK_ISO_Emphasize* = 0x0000FE32
-    XK_ISO_Center_Object* = 0x0000FE33
-    XK_ISO_Enter* = 0x0000FE34
-    XK_dead_grave* = 0x0000FE50
-    XK_dead_acute* = 0x0000FE51
-    XK_dead_circumflex* = 0x0000FE52
-    XK_dead_tilde* = 0x0000FE53
-    XK_dead_macron* = 0x0000FE54
-    XK_dead_breve* = 0x0000FE55
-    XK_dead_abovedot* = 0x0000FE56
-    XK_dead_diaeresis* = 0x0000FE57
-    XK_dead_abovering* = 0x0000FE58
-    XK_dead_doubleacute* = 0x0000FE59
-    XK_dead_caron* = 0x0000FE5A
-    XK_dead_cedilla* = 0x0000FE5B
-    XK_dead_ogonek* = 0x0000FE5C
-    XK_dead_iota* = 0x0000FE5D
-    XK_dead_voiced_sound* = 0x0000FE5E
-    XK_dead_semivoiced_sound* = 0x0000FE5F
-    XK_dead_belowdot* = 0x0000FE60
-    XK_dead_hook* = 0x0000FE61
-    XK_dead_horn* = 0x0000FE62
-    XK_First_Virtual_Screen* = 0x0000FED0
-    XK_Prev_Virtual_Screen* = 0x0000FED1
-    XK_Next_Virtual_Screen* = 0x0000FED2
-    XK_Last_Virtual_Screen* = 0x0000FED4
-    XK_Terminate_Server* = 0x0000FED5
-    XK_AccessX_Enable* = 0x0000FE70
-    XK_AccessX_Feedback_Enable* = 0x0000FE71
-    XK_RepeatKeys_Enable* = 0x0000FE72
-    XK_SlowKeys_Enable* = 0x0000FE73
-    XK_BounceKeys_Enable* = 0x0000FE74
-    XK_StickyKeys_Enable* = 0x0000FE75
-    XK_MouseKeys_Enable* = 0x0000FE76
-    XK_MouseKeys_Accel_Enable* = 0x0000FE77
-    XK_Overlay1_Enable* = 0x0000FE78
-    XK_Overlay2_Enable* = 0x0000FE79
-    XK_AudibleBell_Enable* = 0x0000FE7A
-    XK_Pointer_Left* = 0x0000FEE0
-    XK_Pointer_Right* = 0x0000FEE1
-    XK_Pointer_Up* = 0x0000FEE2
-    XK_Pointer_Down* = 0x0000FEE3
-    XK_Pointer_UpLeft* = 0x0000FEE4
-    XK_Pointer_UpRight* = 0x0000FEE5
-    XK_Pointer_DownLeft* = 0x0000FEE6
-    XK_Pointer_DownRight* = 0x0000FEE7
-    XK_Pointer_Button_Dflt* = 0x0000FEE8
-    XK_Pointer_Button1* = 0x0000FEE9
-    XK_Pointer_Button2* = 0x0000FEEA
-    XK_Pointer_Button3* = 0x0000FEEB
-    XK_Pointer_Button4* = 0x0000FEEC
-    XK_Pointer_Button5* = 0x0000FEED
-    XK_Pointer_DblClick_Dflt* = 0x0000FEEE
-    XK_Pointer_DblClick1* = 0x0000FEEF
-    XK_Pointer_DblClick2* = 0x0000FEF0
-    XK_Pointer_DblClick3* = 0x0000FEF1
-    XK_Pointer_DblClick4* = 0x0000FEF2
-    XK_Pointer_DblClick5* = 0x0000FEF3
-    XK_Pointer_Drag_Dflt* = 0x0000FEF4
-    XK_Pointer_Drag1* = 0x0000FEF5
-    XK_Pointer_Drag2* = 0x0000FEF6
-    XK_Pointer_Drag3* = 0x0000FEF7
-    XK_Pointer_Drag4* = 0x0000FEF8
-    XK_Pointer_Drag5* = 0x0000FEFD
-    XK_Pointer_EnableKeys* = 0x0000FEF9
-    XK_Pointer_Accelerate* = 0x0000FEFA
-    XK_Pointer_DfltBtnNext* = 0x0000FEFB
-    XK_Pointer_DfltBtnPrev* = 0x0000FEFC
-  #*
-  # * 3270 Terminal Keys
-  # * Byte 3 = = $FD
-  # *
-
-when defined(XK_3270) or true: 
-  const
-    XK_3270_Duplicate* = 0x0000FD01
-    XK_3270_FieldMark* = 0x0000FD02
-    XK_3270_Right2* = 0x0000FD03
-    XK_3270_Left2* = 0x0000FD04
-    XK_3270_BackTab* = 0x0000FD05
-    XK_3270_EraseEOF* = 0x0000FD06
-    XK_3270_EraseInput* = 0x0000FD07
-    XK_3270_Reset* = 0x0000FD08
-    XK_3270_Quit* = 0x0000FD09
-    XK_3270_PA1* = 0x0000FD0A
-    XK_3270_PA2* = 0x0000FD0B
-    XK_3270_PA3* = 0x0000FD0C
-    XK_3270_Test* = 0x0000FD0D
-    XK_3270_Attn* = 0x0000FD0E
-    XK_3270_CursorBlink* = 0x0000FD0F
-    XK_3270_AltCursor* = 0x0000FD10
-    XK_3270_KeyClick* = 0x0000FD11
-    XK_3270_Jump* = 0x0000FD12
-    XK_3270_Ident* = 0x0000FD13
-    XK_3270_Rule* = 0x0000FD14
-    XK_3270_Copy* = 0x0000FD15
-    XK_3270_Play* = 0x0000FD16
-    XK_3270_Setup* = 0x0000FD17
-    XK_3270_Record* = 0x0000FD18
-    XK_3270_ChangeScreen* = 0x0000FD19
-    XK_3270_DeleteWord* = 0x0000FD1A
-    XK_3270_ExSelect* = 0x0000FD1B
-    XK_3270_CursorSelect* = 0x0000FD1C
-    XK_3270_PrintScreen* = 0x0000FD1D
-    XK_3270_Enter* = 0x0000FD1E
-#*
-# *  Latin 1
-# *  Byte 3 = 0
-# *
-
-when defined(XK_LATIN1) or true: 
-  const
-    XK_space* = 0x00000020
-    XK_exclam* = 0x00000021
-    XK_quotedbl* = 0x00000022
-    XK_numbersign* = 0x00000023
-    XK_dollar* = 0x00000024
-    XK_percent* = 0x00000025
-    XK_ampersand* = 0x00000026
-    XK_apostrophe* = 0x00000027
-    XK_quoteright* = 0x00000027 # deprecated 
-    XK_parenleft* = 0x00000028
-    XK_parenright* = 0x00000029
-    XK_asterisk* = 0x0000002A
-    XK_plus* = 0x0000002B
-    XK_comma* = 0x0000002C
-    XK_minus* = 0x0000002D
-    XK_period* = 0x0000002E
-    XK_slash* = 0x0000002F
-    XK_0* = 0x00000030
-    XK_1* = 0x00000031
-    XK_2* = 0x00000032
-    XK_3* = 0x00000033
-    XK_4* = 0x00000034
-    XK_5* = 0x00000035
-    XK_6* = 0x00000036
-    XK_7* = 0x00000037
-    XK_8* = 0x00000038
-    XK_9* = 0x00000039
-    XK_colon* = 0x0000003A
-    XK_semicolon* = 0x0000003B
-    XK_less* = 0x0000003C
-    XK_equal* = 0x0000003D
-    XK_greater* = 0x0000003E
-    XK_question* = 0x0000003F
-    XK_at* = 0x00000040
-    XKc_A* = 0x00000041
-    XKc_B* = 0x00000042
-    XKc_C* = 0x00000043
-    XKc_D* = 0x00000044
-    XKc_E* = 0x00000045
-    XKc_F* = 0x00000046
-    XKc_G* = 0x00000047
-    XKc_H* = 0x00000048
-    XKc_I* = 0x00000049
-    XKc_J* = 0x0000004A
-    XKc_K* = 0x0000004B
-    XKc_L* = 0x0000004C
-    XKc_M* = 0x0000004D
-    XKc_N* = 0x0000004E
-    XKc_O* = 0x0000004F
-    XKc_P* = 0x00000050
-    XKc_Q* = 0x00000051
-    XKc_R* = 0x00000052
-    XKc_S* = 0x00000053
-    XKc_T* = 0x00000054
-    XKc_U* = 0x00000055
-    XKc_V* = 0x00000056
-    XKc_W* = 0x00000057
-    XKc_X* = 0x00000058
-    XKc_Y* = 0x00000059
-    XKc_Z* = 0x0000005A
-    XK_bracketleft* = 0x0000005B
-    XK_backslash* = 0x0000005C
-    XK_bracketright* = 0x0000005D
-    XK_asciicircum* = 0x0000005E
-    XK_underscore* = 0x0000005F
-    XK_grave* = 0x00000060
-    XK_quoteleft* = 0x00000060  # deprecated 
-    XK_a* = 0x00000061
-    XK_b* = 0x00000062
-    XK_c* = 0x00000063
-    XK_d* = 0x00000064
-    XK_e* = 0x00000065
-    XK_f* = 0x00000066
-    XK_g* = 0x00000067
-    XK_h* = 0x00000068
-    XK_i* = 0x00000069
-    XK_j* = 0x0000006A
-    XK_k* = 0x0000006B
-    XK_l* = 0x0000006C
-    XK_m* = 0x0000006D
-    XK_n* = 0x0000006E
-    XK_o* = 0x0000006F
-    XK_p* = 0x00000070
-    XK_q* = 0x00000071
-    XK_r* = 0x00000072
-    XK_s* = 0x00000073
-    XK_t* = 0x00000074
-    XK_u* = 0x00000075
-    XK_v* = 0x00000076
-    XK_w* = 0x00000077
-    XK_x* = 0x00000078
-    XK_y* = 0x00000079
-    XK_z* = 0x0000007A
-    XK_braceleft* = 0x0000007B
-    XK_bar* = 0x0000007C
-    XK_braceright* = 0x0000007D
-    XK_asciitilde* = 0x0000007E
-    XK_nobreakspace* = 0x000000A0
-    XK_exclamdown* = 0x000000A1
-    XK_cent* = 0x000000A2
-    XK_sterling* = 0x000000A3
-    XK_currency* = 0x000000A4
-    XK_yen* = 0x000000A5
-    XK_brokenbar* = 0x000000A6
-    XK_section* = 0x000000A7
-    XK_diaeresis* = 0x000000A8
-    XK_copyright* = 0x000000A9
-    XK_ordfeminine* = 0x000000AA
-    XK_guillemotleft* = 0x000000AB # left angle quotation mark 
-    XK_notsign* = 0x000000AC
-    XK_hyphen* = 0x000000AD
-    XK_registered* = 0x000000AE
-    XK_macron* = 0x000000AF
-    XK_degree* = 0x000000B0
-    XK_plusminus* = 0x000000B1
-    XK_twosuperior* = 0x000000B2
-    XK_threesuperior* = 0x000000B3
-    XK_acute* = 0x000000B4
-    XK_mu* = 0x000000B5
-    XK_paragraph* = 0x000000B6
-    XK_periodcentered* = 0x000000B7
-    XK_cedilla* = 0x000000B8
-    XK_onesuperior* = 0x000000B9
-    XK_masculine* = 0x000000BA
-    XK_guillemotright* = 0x000000BB # right angle quotation mark 
-    XK_onequarter* = 0x000000BC
-    XK_onehalf* = 0x000000BD
-    XK_threequarters* = 0x000000BE
-    XK_questiondown* = 0x000000BF
-    XKc_Agrave* = 0x000000C0
-    XKc_Aacute* = 0x000000C1
-    XKc_Acircumflex* = 0x000000C2
-    XKc_Atilde* = 0x000000C3
-    XKc_Adiaeresis* = 0x000000C4
-    XKc_Aring* = 0x000000C5
-    XKc_AE* = 0x000000C6
-    XKc_Ccedilla* = 0x000000C7
-    XKc_Egrave* = 0x000000C8
-    XKc_Eacute* = 0x000000C9
-    XKc_Ecircumflex* = 0x000000CA
-    XKc_Ediaeresis* = 0x000000CB
-    XKc_Igrave* = 0x000000CC
-    XKc_Iacute* = 0x000000CD
-    XKc_Icircumflex* = 0x000000CE
-    XKc_Idiaeresis* = 0x000000CF
-    XKc_ETH* = 0x000000D0
-    XKc_Ntilde* = 0x000000D1
-    XKc_Ograve* = 0x000000D2
-    XKc_Oacute* = 0x000000D3
-    XKc_Ocircumflex* = 0x000000D4
-    XKc_Otilde* = 0x000000D5
-    XKc_Odiaeresis* = 0x000000D6
-    XK_multiply* = 0x000000D7
-    XKc_Ooblique* = 0x000000D8
-    XKc_Oslash* = XKc_Ooblique
-    XKc_Ugrave* = 0x000000D9
-    XKc_Uacute* = 0x000000DA
-    XKc_Ucircumflex* = 0x000000DB
-    XKc_Udiaeresis* = 0x000000DC
-    XKc_Yacute* = 0x000000DD
-    XKc_THORN* = 0x000000DE
-    XK_ssharp* = 0x000000DF
-    XK_agrave* = 0x000000E0
-    XK_aacute* = 0x000000E1
-    XK_acircumflex* = 0x000000E2
-    XK_atilde* = 0x000000E3
-    XK_adiaeresis* = 0x000000E4
-    XK_aring* = 0x000000E5
-    XK_ae* = 0x000000E6
-    XK_ccedilla* = 0x000000E7
-    XK_egrave* = 0x000000E8
-    XK_eacute* = 0x000000E9
-    XK_ecircumflex* = 0x000000EA
-    XK_ediaeresis* = 0x000000EB
-    XK_igrave* = 0x000000EC
-    XK_iacute* = 0x000000ED
-    XK_icircumflex* = 0x000000EE
-    XK_idiaeresis* = 0x000000EF
-    XK_eth* = 0x000000F0
-    XK_ntilde* = 0x000000F1
-    XK_ograve* = 0x000000F2
-    XK_oacute* = 0x000000F3
-    XK_ocircumflex* = 0x000000F4
-    XK_otilde* = 0x000000F5
-    XK_odiaeresis* = 0x000000F6
-    XK_division* = 0x000000F7
-    XK_oslash* = 0x000000F8
-    XK_ooblique* = XK_oslash
-    XK_ugrave* = 0x000000F9
-    XK_uacute* = 0x000000FA
-    XK_ucircumflex* = 0x000000FB
-    XK_udiaeresis* = 0x000000FC
-    XK_yacute* = 0x000000FD
-    XK_thorn* = 0x000000FE
-    XK_ydiaeresis* = 0x000000FF
-# XK_LATIN1 
-#*
-# *   Latin 2
-# *   Byte 3 = 1
-# *
-
-when defined(XK_LATIN2) or true: 
-  const
-    XKc_Aogonek* = 0x000001A1
-    XK_breve* = 0x000001A2
-    XKc_Lstroke* = 0x000001A3
-    XKc_Lcaron* = 0x000001A5
-    XKc_Sacute* = 0x000001A6
-    XKc_Scaron* = 0x000001A9
-    XKc_Scedilla* = 0x000001AA
-    XKc_Tcaron* = 0x000001AB
-    XKc_Zacute* = 0x000001AC
-    XKc_Zcaron* = 0x000001AE
-    XKc_Zabovedot* = 0x000001AF
-    XK_aogonek* = 0x000001B1
-    XK_ogonek* = 0x000001B2
-    XK_lstroke* = 0x000001B3
-    XK_lcaron* = 0x000001B5
-    XK_sacute* = 0x000001B6
-    XK_caron* = 0x000001B7
-    XK_scaron* = 0x000001B9
-    XK_scedilla* = 0x000001BA
-    XK_tcaron* = 0x000001BB
-    XK_zacute* = 0x000001BC
-    XK_doubleacute* = 0x000001BD
-    XK_zcaron* = 0x000001BE
-    XK_zabovedot* = 0x000001BF
-    XKc_Racute* = 0x000001C0
-    XKc_Abreve* = 0x000001C3
-    XKc_Lacute* = 0x000001C5
-    XKc_Cacute* = 0x000001C6
-    XKc_Ccaron* = 0x000001C8
-    XKc_Eogonek* = 0x000001CA
-    XKc_Ecaron* = 0x000001CC
-    XKc_Dcaron* = 0x000001CF
-    XKc_Dstroke* = 0x000001D0
-    XKc_Nacute* = 0x000001D1
-    XKc_Ncaron* = 0x000001D2
-    XKc_Odoubleacute* = 0x000001D5
-    XKc_Rcaron* = 0x000001D8
-    XKc_Uring* = 0x000001D9
-    XKc_Udoubleacute* = 0x000001DB
-    XKc_Tcedilla* = 0x000001DE
-    XK_racute* = 0x000001E0
-    XK_abreve* = 0x000001E3
-    XK_lacute* = 0x000001E5
-    XK_cacute* = 0x000001E6
-    XK_ccaron* = 0x000001E8
-    XK_eogonek* = 0x000001EA
-    XK_ecaron* = 0x000001EC
-    XK_dcaron* = 0x000001EF
-    XK_dstroke* = 0x000001F0
-    XK_nacute* = 0x000001F1
-    XK_ncaron* = 0x000001F2
-    XK_odoubleacute* = 0x000001F5
-    XK_udoubleacute* = 0x000001FB
-    XK_rcaron* = 0x000001F8
-    XK_uring* = 0x000001F9
-    XK_tcedilla* = 0x000001FE
-    XK_abovedot* = 0x000001FF
-# XK_LATIN2 
-#*
-# *   Latin 3
-# *   Byte 3 = 2
-# *
-
-when defined(XK_LATIN3) or true: 
-  const
-    XKc_Hstroke* = 0x000002A1
-    XKc_Hcircumflex* = 0x000002A6
-    XKc_Iabovedot* = 0x000002A9
-    XKc_Gbreve* = 0x000002AB
-    XKc_Jcircumflex* = 0x000002AC
-    XK_hstroke* = 0x000002B1
-    XK_hcircumflex* = 0x000002B6
-    XK_idotless* = 0x000002B9
-    XK_gbreve* = 0x000002BB
-    XK_jcircumflex* = 0x000002BC
-    XKc_Cabovedot* = 0x000002C5
-    XKc_Ccircumflex* = 0x000002C6
-    XKc_Gabovedot* = 0x000002D5
-    XKc_Gcircumflex* = 0x000002D8
-    XKc_Ubreve* = 0x000002DD
-    XKc_Scircumflex* = 0x000002DE
-    XK_cabovedot* = 0x000002E5
-    XK_ccircumflex* = 0x000002E6
-    XK_gabovedot* = 0x000002F5
-    XK_gcircumflex* = 0x000002F8
-    XK_ubreve* = 0x000002FD
-    XK_scircumflex* = 0x000002FE
-# XK_LATIN3 
-#*
-# *   Latin 4
-# *   Byte 3 = 3
-# *
-
-when defined(XK_LATIN4) or true: 
-  const
-    XK_kra* = 0x000003A2
-    XK_kappa* = 0x000003A2      # deprecated 
-    XKc_Rcedilla* = 0x000003A3
-    XKc_Itilde* = 0x000003A5
-    XKc_Lcedilla* = 0x000003A6
-    XKc_Emacron* = 0x000003AA
-    XKc_Gcedilla* = 0x000003AB
-    XKc_Tslash* = 0x000003AC
-    XK_rcedilla* = 0x000003B3
-    XK_itilde* = 0x000003B5
-    XK_lcedilla* = 0x000003B6
-    XK_emacron* = 0x000003BA
-    XK_gcedilla* = 0x000003BB
-    XK_tslash* = 0x000003BC
-    XKc_ENG* = 0x000003BD
-    XK_eng* = 0x000003BF
-    XKc_Amacron* = 0x000003C0
-    XKc_Iogonek* = 0x000003C7
-    XKc_Eabovedot* = 0x000003CC
-    XKc_Imacron* = 0x000003CF
-    XKc_Ncedilla* = 0x000003D1
-    XKc_Omacron* = 0x000003D2
-    XKc_Kcedilla* = 0x000003D3
-    XKc_Uogonek* = 0x000003D9
-    XKc_Utilde* = 0x000003DD
-    XKc_Umacron* = 0x000003DE
-    XK_amacron* = 0x000003E0
-    XK_iogonek* = 0x000003E7
-    XK_eabovedot* = 0x000003EC
-    XK_imacron* = 0x000003EF
-    XK_ncedilla* = 0x000003F1
-    XK_omacron* = 0x000003F2
-    XK_kcedilla* = 0x000003F3
-    XK_uogonek* = 0x000003F9
-    XK_utilde* = 0x000003FD
-    XK_umacron* = 0x000003FE
-# XK_LATIN4 
-#*
-# * Latin-8
-# * Byte 3 = 18
-# *
-
-when defined(XK_LATIN8) or true: 
-  const
-    XKc_Babovedot* = 0x000012A1
-    XK_babovedot* = 0x000012A2
-    XKc_Dabovedot* = 0x000012A6
-    XKc_Wgrave* = 0x000012A8
-    XKc_Wacute* = 0x000012AA
-    XK_dabovedot* = 0x000012AB
-    XKc_Ygrave* = 0x000012AC
-    XKc_Fabovedot* = 0x000012B0
-    XK_fabovedot* = 0x000012B1
-    XKc_Mabovedot* = 0x000012B4
-    XK_mabovedot* = 0x000012B5
-    XKc_Pabovedot* = 0x000012B7
-    XK_wgrave* = 0x000012B8
-    XK_pabovedot* = 0x000012B9
-    XK_wacute* = 0x000012BA
-    XKc_Sabovedot* = 0x000012BB
-    XK_ygrave* = 0x000012BC
-    XKc_Wdiaeresis* = 0x000012BD
-    XK_wdiaeresis* = 0x000012BE
-    XK_sabovedot* = 0x000012BF
-    XKc_Wcircumflex* = 0x000012D0
-    XKc_Tabovedot* = 0x000012D7
-    XKc_Ycircumflex* = 0x000012DE
-    XK_wcircumflex* = 0x000012F0
-    XK_tabovedot* = 0x000012F7
-    XK_ycircumflex* = 0x000012FE
-# XK_LATIN8 
-#*
-# * Latin-9 (a.k.a. Latin-0)
-# * Byte 3 = 19
-# *
-
-when defined(XK_LATIN9) or true: 
-  const
-    XKc_OE* = 0x000013BC
-    XK_oe* = 0x000013BD
-    XKc_Ydiaeresis* = 0x000013BE
-# XK_LATIN9 
-#*
-# * Katakana
-# * Byte 3 = 4
-# *
-
-when defined(XK_KATAKANA) or true: 
-  const
-    XK_overline* = 0x0000047E
-    XK_kana_fullstop* = 0x000004A1
-    XK_kana_openingbracket* = 0x000004A2
-    XK_kana_closingbracket* = 0x000004A3
-    XK_kana_comma* = 0x000004A4
-    XK_kana_conjunctive* = 0x000004A5
-    XK_kana_middledot* = 0x000004A5 # deprecated 
-    XKc_kana_WO* = 0x000004A6
-    XK_kana_a* = 0x000004A7
-    XK_kana_i* = 0x000004A8
-    XK_kana_u* = 0x000004A9
-    XK_kana_e* = 0x000004AA
-    XK_kana_o* = 0x000004AB
-    XK_kana_ya* = 0x000004AC
-    XK_kana_yu* = 0x000004AD
-    XK_kana_yo* = 0x000004AE
-    XK_kana_tsu* = 0x000004AF
-    XK_kana_tu* = 0x000004AF    # deprecated 
-    XK_prolongedsound* = 0x000004B0
-    XKc_kana_A* = 0x000004B1
-    XKc_kana_I* = 0x000004B2
-    XKc_kana_U* = 0x000004B3
-    XKc_kana_E* = 0x000004B4
-    XKc_kana_O* = 0x000004B5
-    XKc_kana_KA* = 0x000004B6
-    XKc_kana_KI* = 0x000004B7
-    XKc_kana_KU* = 0x000004B8
-    XKc_kana_KE* = 0x000004B9
-    XKc_kana_KO* = 0x000004BA
-    XKc_kana_SA* = 0x000004BB
-    XKc_kana_SHI* = 0x000004BC
-    XKc_kana_SU* = 0x000004BD
-    XKc_kana_SE* = 0x000004BE
-    XKc_kana_SO* = 0x000004BF
-    XKc_kana_TA* = 0x000004C0
-    XKc_kana_CHI* = 0x000004C1
-    XKc_kana_TI* = 0x000004C1   # deprecated 
-    XKc_kana_TSU* = 0x000004C2
-    XKc_kana_TU* = 0x000004C2   # deprecated 
-    XKc_kana_TE* = 0x000004C3
-    XKc_kana_TO* = 0x000004C4
-    XKc_kana_NA* = 0x000004C5
-    XKc_kana_NI* = 0x000004C6
-    XKc_kana_NU* = 0x000004C7
-    XKc_kana_NE* = 0x000004C8
-    XKc_kana_NO* = 0x000004C9
-    XKc_kana_HA* = 0x000004CA
-    XKc_kana_HI* = 0x000004CB
-    XKc_kana_FU* = 0x000004CC
-    XKc_kana_HU* = 0x000004CC   # deprecated 
-    XKc_kana_HE* = 0x000004CD
-    XKc_kana_HO* = 0x000004CE
-    XKc_kana_MA* = 0x000004CF
-    XKc_kana_MI* = 0x000004D0
-    XKc_kana_MU* = 0x000004D1
-    XKc_kana_ME* = 0x000004D2
-    XKc_kana_MO* = 0x000004D3
-    XKc_kana_YA* = 0x000004D4
-    XKc_kana_YU* = 0x000004D5
-    XKc_kana_YO* = 0x000004D6
-    XKc_kana_RA* = 0x000004D7
-    XKc_kana_RI* = 0x000004D8
-    XKc_kana_RU* = 0x000004D9
-    XKc_kana_RE* = 0x000004DA
-    XKc_kana_RO* = 0x000004DB
-    XKc_kana_WA* = 0x000004DC
-    XKc_kana_N* = 0x000004DD
-    XK_voicedsound* = 0x000004DE
-    XK_semivoicedsound* = 0x000004DF
-    XK_kana_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_KATAKANA 
-#*
-# *  Arabic
-# *  Byte 3 = 5
-# *
-
-when defined(XK_ARABIC) or true: 
-  const
-    XK_Farsi_0* = 0x00000590
-    XK_Farsi_1* = 0x00000591
-    XK_Farsi_2* = 0x00000592
-    XK_Farsi_3* = 0x00000593
-    XK_Farsi_4* = 0x00000594
-    XK_Farsi_5* = 0x00000595
-    XK_Farsi_6* = 0x00000596
-    XK_Farsi_7* = 0x00000597
-    XK_Farsi_8* = 0x00000598
-    XK_Farsi_9* = 0x00000599
-    XK_Arabic_percent* = 0x000005A5
-    XK_Arabic_superscript_alef* = 0x000005A6
-    XK_Arabic_tteh* = 0x000005A7
-    XK_Arabic_peh* = 0x000005A8
-    XK_Arabic_tcheh* = 0x000005A9
-    XK_Arabic_ddal* = 0x000005AA
-    XK_Arabic_rreh* = 0x000005AB
-    XK_Arabic_comma* = 0x000005AC
-    XK_Arabic_fullstop* = 0x000005AE
-    XK_Arabic_0* = 0x000005B0
-    XK_Arabic_1* = 0x000005B1
-    XK_Arabic_2* = 0x000005B2
-    XK_Arabic_3* = 0x000005B3
-    XK_Arabic_4* = 0x000005B4
-    XK_Arabic_5* = 0x000005B5
-    XK_Arabic_6* = 0x000005B6
-    XK_Arabic_7* = 0x000005B7
-    XK_Arabic_8* = 0x000005B8
-    XK_Arabic_9* = 0x000005B9
-    XK_Arabic_semicolon* = 0x000005BB
-    XK_Arabic_question_mark* = 0x000005BF
-    XK_Arabic_hamza* = 0x000005C1
-    XK_Arabic_maddaonalef* = 0x000005C2
-    XK_Arabic_hamzaonalef* = 0x000005C3
-    XK_Arabic_hamzaonwaw* = 0x000005C4
-    XK_Arabic_hamzaunderalef* = 0x000005C5
-    XK_Arabic_hamzaonyeh* = 0x000005C6
-    XK_Arabic_alef* = 0x000005C7
-    XK_Arabic_beh* = 0x000005C8
-    XK_Arabic_tehmarbuta* = 0x000005C9
-    XK_Arabic_teh* = 0x000005CA
-    XK_Arabic_theh* = 0x000005CB
-    XK_Arabic_jeem* = 0x000005CC
-    XK_Arabic_hah* = 0x000005CD
-    XK_Arabic_khah* = 0x000005CE
-    XK_Arabic_dal* = 0x000005CF
-    XK_Arabic_thal* = 0x000005D0
-    XK_Arabic_ra* = 0x000005D1
-    XK_Arabic_zain* = 0x000005D2
-    XK_Arabic_seen* = 0x000005D3
-    XK_Arabic_sheen* = 0x000005D4
-    XK_Arabic_sad* = 0x000005D5
-    XK_Arabic_dad* = 0x000005D6
-    XK_Arabic_tah* = 0x000005D7
-    XK_Arabic_zah* = 0x000005D8
-    XK_Arabic_ain* = 0x000005D9
-    XK_Arabic_ghain* = 0x000005DA
-    XK_Arabic_tatweel* = 0x000005E0
-    XK_Arabic_feh* = 0x000005E1
-    XK_Arabic_qaf* = 0x000005E2
-    XK_Arabic_kaf* = 0x000005E3
-    XK_Arabic_lam* = 0x000005E4
-    XK_Arabic_meem* = 0x000005E5
-    XK_Arabic_noon* = 0x000005E6
-    XK_Arabic_ha* = 0x000005E7
-    XK_Arabic_heh* = 0x000005E7 # deprecated 
-    XK_Arabic_waw* = 0x000005E8
-    XK_Arabic_alefmaksura* = 0x000005E9
-    XK_Arabic_yeh* = 0x000005EA
-    XK_Arabic_fathatan* = 0x000005EB
-    XK_Arabic_dammatan* = 0x000005EC
-    XK_Arabic_kasratan* = 0x000005ED
-    XK_Arabic_fatha* = 0x000005EE
-    XK_Arabic_damma* = 0x000005EF
-    XK_Arabic_kasra* = 0x000005F0
-    XK_Arabic_shadda* = 0x000005F1
-    XK_Arabic_sukun* = 0x000005F2
-    XK_Arabic_madda_above* = 0x000005F3
-    XK_Arabic_hamza_above* = 0x000005F4
-    XK_Arabic_hamza_below* = 0x000005F5
-    XK_Arabic_jeh* = 0x000005F6
-    XK_Arabic_veh* = 0x000005F7
-    XK_Arabic_keheh* = 0x000005F8
-    XK_Arabic_gaf* = 0x000005F9
-    XK_Arabic_noon_ghunna* = 0x000005FA
-    XK_Arabic_heh_doachashmee* = 0x000005FB
-    XK_Farsi_yeh* = 0x000005FC
-    XK_Arabic_farsi_yeh* = XK_Farsi_yeh
-    XK_Arabic_yeh_baree* = 0x000005FD
-    XK_Arabic_heh_goal* = 0x000005FE
-    XK_Arabic_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_ARABIC 
-#*
-# * Cyrillic
-# * Byte 3 = 6
-# *
-
-when defined(XK_CYRILLIC) or true: 
-  const
-    XKc_Cyrillic_GHE_bar* = 0x00000680
-    XK_Cyrillic_ghe_bar* = 0x00000690
-    XKc_Cyrillic_ZHE_descender* = 0x00000681
-    XK_Cyrillic_zhe_descender* = 0x00000691
-    XKc_Cyrillic_KA_descender* = 0x00000682
-    XK_Cyrillic_ka_descender* = 0x00000692
-    XKc_Cyrillic_KA_vertstroke* = 0x00000683
-    XK_Cyrillic_ka_vertstroke* = 0x00000693
-    XKc_Cyrillic_EN_descender* = 0x00000684
-    XK_Cyrillic_en_descender* = 0x00000694
-    XKc_Cyrillic_U_straight* = 0x00000685
-    XK_Cyrillic_u_straight* = 0x00000695
-    XKc_Cyrillic_U_straight_bar* = 0x00000686
-    XK_Cyrillic_u_straight_bar* = 0x00000696
-    XKc_Cyrillic_HA_descender* = 0x00000687
-    XK_Cyrillic_ha_descender* = 0x00000697
-    XKc_Cyrillic_CHE_descender* = 0x00000688
-    XK_Cyrillic_che_descender* = 0x00000698
-    XKc_Cyrillic_CHE_vertstroke* = 0x00000689
-    XK_Cyrillic_che_vertstroke* = 0x00000699
-    XKc_Cyrillic_SHHA* = 0x0000068A
-    XK_Cyrillic_shha* = 0x0000069A
-    XKc_Cyrillic_SCHWA* = 0x0000068C
-    XK_Cyrillic_schwa* = 0x0000069C
-    XKc_Cyrillic_I_macron* = 0x0000068D
-    XK_Cyrillic_i_macron* = 0x0000069D
-    XKc_Cyrillic_O_bar* = 0x0000068E
-    XK_Cyrillic_o_bar* = 0x0000069E
-    XKc_Cyrillic_U_macron* = 0x0000068F
-    XK_Cyrillic_u_macron* = 0x0000069F
-    XK_Serbian_dje* = 0x000006A1
-    XK_Macedonia_gje* = 0x000006A2
-    XK_Cyrillic_io* = 0x000006A3
-    XK_Ukrainian_ie* = 0x000006A4
-    XK_Ukranian_je* = 0x000006A4 # deprecated 
-    XK_Macedonia_dse* = 0x000006A5
-    XK_Ukrainian_i* = 0x000006A6
-    XK_Ukranian_i* = 0x000006A6 # deprecated 
-    XK_Ukrainian_yi* = 0x000006A7
-    XK_Ukranian_yi* = 0x000006A7 # deprecated 
-    XK_Cyrillic_je* = 0x000006A8
-    XK_Serbian_je* = 0x000006A8 # deprecated 
-    XK_Cyrillic_lje* = 0x000006A9
-    XK_Serbian_lje* = 0x000006A9 # deprecated 
-    XK_Cyrillic_nje* = 0x000006AA
-    XK_Serbian_nje* = 0x000006AA # deprecated 
-    XK_Serbian_tshe* = 0x000006AB
-    XK_Macedonia_kje* = 0x000006AC
-    XK_Ukrainian_ghe_with_upturn* = 0x000006AD
-    XK_Byelorussian_shortu* = 0x000006AE
-    XK_Cyrillic_dzhe* = 0x000006AF
-    XK_Serbian_dze* = 0x000006AF # deprecated 
-    XK_numerosign* = 0x000006B0
-    XKc_Serbian_DJE* = 0x000006B1
-    XKc_Macedonia_GJE* = 0x000006B2
-    XKc_Cyrillic_IO* = 0x000006B3
-    XKc_Ukrainian_IE* = 0x000006B4
-    XKc_Ukranian_JE* = 0x000006B4 # deprecated 
-    XKc_Macedonia_DSE* = 0x000006B5
-    XKc_Ukrainian_I* = 0x000006B6
-    XKc_Ukranian_I* = 0x000006B6 # deprecated 
-    XKc_Ukrainian_YI* = 0x000006B7
-    XKc_Ukranian_YI* = 0x000006B7 # deprecated 
-    XKc_Cyrillic_JE* = 0x000006B8
-    XKc_Serbian_JE* = 0x000006B8 # deprecated 
-    XKc_Cyrillic_LJE* = 0x000006B9
-    XKc_Serbian_LJE* = 0x000006B9 # deprecated 
-    XKc_Cyrillic_NJE* = 0x000006BA
-    XKc_Serbian_NJE* = 0x000006BA # deprecated 
-    XKc_Serbian_TSHE* = 0x000006BB
-    XKc_Macedonia_KJE* = 0x000006BC
-    XKc_Ukrainian_GHE_WITH_UPTURN* = 0x000006BD
-    XKc_Byelorussian_SHORTU* = 0x000006BE
-    XKc_Cyrillic_DZHE* = 0x000006BF
-    XKc_Serbian_DZE* = 0x000006BF # deprecated 
-    XK_Cyrillic_yu* = 0x000006C0
-    XK_Cyrillic_a* = 0x000006C1
-    XK_Cyrillic_be* = 0x000006C2
-    XK_Cyrillic_tse* = 0x000006C3
-    XK_Cyrillic_de* = 0x000006C4
-    XK_Cyrillic_ie* = 0x000006C5
-    XK_Cyrillic_ef* = 0x000006C6
-    XK_Cyrillic_ghe* = 0x000006C7
-    XK_Cyrillic_ha* = 0x000006C8
-    XK_Cyrillic_i* = 0x000006C9
-    XK_Cyrillic_shorti* = 0x000006CA
-    XK_Cyrillic_ka* = 0x000006CB
-    XK_Cyrillic_el* = 0x000006CC
-    XK_Cyrillic_em* = 0x000006CD
-    XK_Cyrillic_en* = 0x000006CE
-    XK_Cyrillic_o* = 0x000006CF
-    XK_Cyrillic_pe* = 0x000006D0
-    XK_Cyrillic_ya* = 0x000006D1
-    XK_Cyrillic_er* = 0x000006D2
-    XK_Cyrillic_es* = 0x000006D3
-    XK_Cyrillic_te* = 0x000006D4
-    XK_Cyrillic_u* = 0x000006D5
-    XK_Cyrillic_zhe* = 0x000006D6
-    XK_Cyrillic_ve* = 0x000006D7
-    XK_Cyrillic_softsign* = 0x000006D8
-    XK_Cyrillic_yeru* = 0x000006D9
-    XK_Cyrillic_ze* = 0x000006DA
-    XK_Cyrillic_sha* = 0x000006DB
-    XK_Cyrillic_e* = 0x000006DC
-    XK_Cyrillic_shcha* = 0x000006DD
-    XK_Cyrillic_che* = 0x000006DE
-    XK_Cyrillic_hardsign* = 0x000006DF
-    XKc_Cyrillic_YU* = 0x000006E0
-    XKc_Cyrillic_A* = 0x000006E1
-    XKc_Cyrillic_BE* = 0x000006E2
-    XKc_Cyrillic_TSE* = 0x000006E3
-    XKc_Cyrillic_DE* = 0x000006E4
-    XKc_Cyrillic_IE* = 0x000006E5
-    XKc_Cyrillic_EF* = 0x000006E6
-    XKc_Cyrillic_GHE* = 0x000006E7
-    XKc_Cyrillic_HA* = 0x000006E8
-    XKc_Cyrillic_I* = 0x000006E9
-    XKc_Cyrillic_SHORTI* = 0x000006EA
-    XKc_Cyrillic_KA* = 0x000006EB
-    XKc_Cyrillic_EL* = 0x000006EC
-    XKc_Cyrillic_EM* = 0x000006ED
-    XKc_Cyrillic_EN* = 0x000006EE
-    XKc_Cyrillic_O* = 0x000006EF
-    XKc_Cyrillic_PE* = 0x000006F0
-    XKc_Cyrillic_YA* = 0x000006F1
-    XKc_Cyrillic_ER* = 0x000006F2
-    XKc_Cyrillic_ES* = 0x000006F3
-    XKc_Cyrillic_TE* = 0x000006F4
-    XKc_Cyrillic_U* = 0x000006F5
-    XKc_Cyrillic_ZHE* = 0x000006F6
-    XKc_Cyrillic_VE* = 0x000006F7
-    XKc_Cyrillic_SOFTSIGN* = 0x000006F8
-    XKc_Cyrillic_YERU* = 0x000006F9
-    XKc_Cyrillic_ZE* = 0x000006FA
-    XKc_Cyrillic_SHA* = 0x000006FB
-    XKc_Cyrillic_E* = 0x000006FC
-    XKc_Cyrillic_SHCHA* = 0x000006FD
-    XKc_Cyrillic_CHE* = 0x000006FE
-    XKc_Cyrillic_HARDSIGN* = 0x000006FF
-# XK_CYRILLIC 
-#*
-# * Greek
-# * Byte 3 = 7
-# *
-
-when defined(XK_GREEK) or true: 
-  const
-    XKc_Greek_ALPHAaccent* = 0x000007A1
-    XKc_Greek_EPSILONaccent* = 0x000007A2
-    XKc_Greek_ETAaccent* = 0x000007A3
-    XKc_Greek_IOTAaccent* = 0x000007A4
-    XKc_Greek_IOTAdieresis* = 0x000007A5
-    XKc_Greek_IOTAdiaeresis* = XKc_Greek_IOTAdieresis # old typo 
-    XKc_Greek_OMICRONaccent* = 0x000007A7
-    XKc_Greek_UPSILONaccent* = 0x000007A8
-    XKc_Greek_UPSILONdieresis* = 0x000007A9
-    XKc_Greek_OMEGAaccent* = 0x000007AB
-    XK_Greek_accentdieresis* = 0x000007AE
-    XK_Greek_horizbar* = 0x000007AF
-    XK_Greek_alphaaccent* = 0x000007B1
-    XK_Greek_epsilonaccent* = 0x000007B2
-    XK_Greek_etaaccent* = 0x000007B3
-    XK_Greek_iotaaccent* = 0x000007B4
-    XK_Greek_iotadieresis* = 0x000007B5
-    XK_Greek_iotaaccentdieresis* = 0x000007B6
-    XK_Greek_omicronaccent* = 0x000007B7
-    XK_Greek_upsilonaccent* = 0x000007B8
-    XK_Greek_upsilondieresis* = 0x000007B9
-    XK_Greek_upsilonaccentdieresis* = 0x000007BA
-    XK_Greek_omegaaccent* = 0x000007BB
-    XKc_Greek_ALPHA* = 0x000007C1
-    XKc_Greek_BETA* = 0x000007C2
-    XKc_Greek_GAMMA* = 0x000007C3
-    XKc_Greek_DELTA* = 0x000007C4
-    XKc_Greek_EPSILON* = 0x000007C5
-    XKc_Greek_ZETA* = 0x000007C6
-    XKc_Greek_ETA* = 0x000007C7
-    XKc_Greek_THETA* = 0x000007C8
-    XKc_Greek_IOTA* = 0x000007C9
-    XKc_Greek_KAPPA* = 0x000007CA
-    XKc_Greek_LAMDA* = 0x000007CB
-    XKc_Greek_LAMBDA* = 0x000007CB
-    XKc_Greek_MU* = 0x000007CC
-    XKc_Greek_NU* = 0x000007CD
-    XKc_Greek_XI* = 0x000007CE
-    XKc_Greek_OMICRON* = 0x000007CF
-    XKc_Greek_PI* = 0x000007D0
-    XKc_Greek_RHO* = 0x000007D1
-    XKc_Greek_SIGMA* = 0x000007D2
-    XKc_Greek_TAU* = 0x000007D4
-    XKc_Greek_UPSILON* = 0x000007D5
-    XKc_Greek_PHI* = 0x000007D6
-    XKc_Greek_CHI* = 0x000007D7
-    XKc_Greek_PSI* = 0x000007D8
-    XKc_Greek_OMEGA* = 0x000007D9
-    XK_Greek_alpha* = 0x000007E1
-    XK_Greek_beta* = 0x000007E2
-    XK_Greek_gamma* = 0x000007E3
-    XK_Greek_delta* = 0x000007E4
-    XK_Greek_epsilon* = 0x000007E5
-    XK_Greek_zeta* = 0x000007E6
-    XK_Greek_eta* = 0x000007E7
-    XK_Greek_theta* = 0x000007E8
-    XK_Greek_iota* = 0x000007E9
-    XK_Greek_kappa* = 0x000007EA
-    XK_Greek_lamda* = 0x000007EB
-    XK_Greek_lambda* = 0x000007EB
-    XK_Greek_mu* = 0x000007EC
-    XK_Greek_nu* = 0x000007ED
-    XK_Greek_xi* = 0x000007EE
-    XK_Greek_omicron* = 0x000007EF
-    XK_Greek_pi* = 0x000007F0
-    XK_Greek_rho* = 0x000007F1
-    XK_Greek_sigma* = 0x000007F2
-    XK_Greek_finalsmallsigma* = 0x000007F3
-    XK_Greek_tau* = 0x000007F4
-    XK_Greek_upsilon* = 0x000007F5
-    XK_Greek_phi* = 0x000007F6
-    XK_Greek_chi* = 0x000007F7
-    XK_Greek_psi* = 0x000007F8
-    XK_Greek_omega* = 0x000007F9
-    XK_Greek_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_GREEK 
-#*
-# * Technical
-# * Byte 3 = 8
-# *
-
-when defined(XK_TECHNICAL) or true: 
-  const
-    XK_leftradical* = 0x000008A1
-    XK_topleftradical* = 0x000008A2
-    XK_horizconnector* = 0x000008A3
-    XK_topintegral* = 0x000008A4
-    XK_botintegral* = 0x000008A5
-    XK_vertconnector* = 0x000008A6
-    XK_topleftsqbracket* = 0x000008A7
-    XK_botleftsqbracket* = 0x000008A8
-    XK_toprightsqbracket* = 0x000008A9
-    XK_botrightsqbracket* = 0x000008AA
-    XK_topleftparens* = 0x000008AB
-    XK_botleftparens* = 0x000008AC
-    XK_toprightparens* = 0x000008AD
-    XK_botrightparens* = 0x000008AE
-    XK_leftmiddlecurlybrace* = 0x000008AF
-    XK_rightmiddlecurlybrace* = 0x000008B0
-    XK_topleftsummation* = 0x000008B1
-    XK_botleftsummation* = 0x000008B2
-    XK_topvertsummationconnector* = 0x000008B3
-    XK_botvertsummationconnector* = 0x000008B4
-    XK_toprightsummation* = 0x000008B5
-    XK_botrightsummation* = 0x000008B6
-    XK_rightmiddlesummation* = 0x000008B7
-    XK_lessthanequal* = 0x000008BC
-    XK_notequal* = 0x000008BD
-    XK_greaterthanequal* = 0x000008BE
-    XK_integral* = 0x000008BF
-    XK_therefore* = 0x000008C0
-    XK_variation* = 0x000008C1
-    XK_infinity* = 0x000008C2
-    XK_nabla* = 0x000008C5
-    XK_approximate* = 0x000008C8
-    XK_similarequal* = 0x000008C9
-    XK_ifonlyif* = 0x000008CD
-    XK_implies* = 0x000008CE
-    XK_identical* = 0x000008CF
-    XK_radical* = 0x000008D6
-    XK_includedin* = 0x000008DA
-    XK_includes* = 0x000008DB
-    XK_intersection* = 0x000008DC
-    XK_union* = 0x000008DD
-    XK_logicaland* = 0x000008DE
-    XK_logicalor* = 0x000008DF
-    XK_partialderivative* = 0x000008EF
-    XK_function* = 0x000008F6
-    XK_leftarrow* = 0x000008FB
-    XK_uparrow* = 0x000008FC
-    XK_rightarrow* = 0x000008FD
-    XK_downarrow* = 0x000008FE
-# XK_TECHNICAL 
-#*
-# *  Special
-# *  Byte 3 = 9
-# *
-
-when defined(XK_SPECIAL): 
-  const
-    XK_blank* = 0x000009DF
-    XK_soliddiamond* = 0x000009E0
-    XK_checkerboard* = 0x000009E1
-    XK_ht* = 0x000009E2
-    XK_ff* = 0x000009E3
-    XK_cr* = 0x000009E4
-    XK_lf* = 0x000009E5
-    XK_nl* = 0x000009E8
-    XK_vt* = 0x000009E9
-    XK_lowrightcorner* = 0x000009EA
-    XK_uprightcorner* = 0x000009EB
-    XK_upleftcorner* = 0x000009EC
-    XK_lowleftcorner* = 0x000009ED
-    XK_crossinglines* = 0x000009EE
-    XK_horizlinescan1* = 0x000009EF
-    XK_horizlinescan3* = 0x000009F0
-    XK_horizlinescan5* = 0x000009F1
-    XK_horizlinescan7* = 0x000009F2
-    XK_horizlinescan9* = 0x000009F3
-    XK_leftt* = 0x000009F4
-    XK_rightt* = 0x000009F5
-    XK_bott* = 0x000009F6
-    XK_topt* = 0x000009F7
-    XK_vertbar* = 0x000009F8
-# XK_SPECIAL 
-#*
-# *  Publishing
-# *  Byte 3 = a
-# *
-
-when defined(XK_PUBLISHING) or true: 
-  const
-    XK_emspace* = 0x00000AA1
-    XK_enspace* = 0x00000AA2
-    XK_em3space* = 0x00000AA3
-    XK_em4space* = 0x00000AA4
-    XK_digitspace* = 0x00000AA5
-    XK_punctspace* = 0x00000AA6
-    XK_thinspace* = 0x00000AA7
-    XK_hairspace* = 0x00000AA8
-    XK_emdash* = 0x00000AA9
-    XK_endash* = 0x00000AAA
-    XK_signifblank* = 0x00000AAC
-    XK_ellipsis* = 0x00000AAE
-    XK_doubbaselinedot* = 0x00000AAF
-    XK_onethird* = 0x00000AB0
-    XK_twothirds* = 0x00000AB1
-    XK_onefifth* = 0x00000AB2
-    XK_twofifths* = 0x00000AB3
-    XK_threefifths* = 0x00000AB4
-    XK_fourfifths* = 0x00000AB5
-    XK_onesixth* = 0x00000AB6
-    XK_fivesixths* = 0x00000AB7
-    XK_careof* = 0x00000AB8
-    XK_figdash* = 0x00000ABB
-    XK_leftanglebracket* = 0x00000ABC
-    XK_decimalpoint* = 0x00000ABD
-    XK_rightanglebracket* = 0x00000ABE
-    XK_marker* = 0x00000ABF
-    XK_oneeighth* = 0x00000AC3
-    XK_threeeighths* = 0x00000AC4
-    XK_fiveeighths* = 0x00000AC5
-    XK_seveneighths* = 0x00000AC6
-    XK_trademark* = 0x00000AC9
-    XK_signaturemark* = 0x00000ACA
-    XK_trademarkincircle* = 0x00000ACB
-    XK_leftopentriangle* = 0x00000ACC
-    XK_rightopentriangle* = 0x00000ACD
-    XK_emopencircle* = 0x00000ACE
-    XK_emopenrectangle* = 0x00000ACF
-    XK_leftsinglequotemark* = 0x00000AD0
-    XK_rightsinglequotemark* = 0x00000AD1
-    XK_leftdoublequotemark* = 0x00000AD2
-    XK_rightdoublequotemark* = 0x00000AD3
-    XK_prescription* = 0x00000AD4
-    XK_minutes* = 0x00000AD6
-    XK_seconds* = 0x00000AD7
-    XK_latincross* = 0x00000AD9
-    XK_hexagram* = 0x00000ADA
-    XK_filledrectbullet* = 0x00000ADB
-    XK_filledlefttribullet* = 0x00000ADC
-    XK_filledrighttribullet* = 0x00000ADD
-    XK_emfilledcircle* = 0x00000ADE
-    XK_emfilledrect* = 0x00000ADF
-    XK_enopencircbullet* = 0x00000AE0
-    XK_enopensquarebullet* = 0x00000AE1
-    XK_openrectbullet* = 0x00000AE2
-    XK_opentribulletup* = 0x00000AE3
-    XK_opentribulletdown* = 0x00000AE4
-    XK_openstar* = 0x00000AE5
-    XK_enfilledcircbullet* = 0x00000AE6
-    XK_enfilledsqbullet* = 0x00000AE7
-    XK_filledtribulletup* = 0x00000AE8
-    XK_filledtribulletdown* = 0x00000AE9
-    XK_leftpointer* = 0x00000AEA
-    XK_rightpointer* = 0x00000AEB
-    XK_club* = 0x00000AEC
-    XK_diamond* = 0x00000AED
-    XK_heart* = 0x00000AEE
-    XK_maltesecross* = 0x00000AF0
-    XK_dagger* = 0x00000AF1
-    XK_doubledagger* = 0x00000AF2
-    XK_checkmark* = 0x00000AF3
-    XK_ballotcross* = 0x00000AF4
-    XK_musicalsharp* = 0x00000AF5
-    XK_musicalflat* = 0x00000AF6
-    XK_malesymbol* = 0x00000AF7
-    XK_femalesymbol* = 0x00000AF8
-    XK_telephone* = 0x00000AF9
-    XK_telephonerecorder* = 0x00000AFA
-    XK_phonographcopyright* = 0x00000AFB
-    XK_caret* = 0x00000AFC
-    XK_singlelowquotemark* = 0x00000AFD
-    XK_doublelowquotemark* = 0x00000AFE
-    XK_cursor* = 0x00000AFF
-# XK_PUBLISHING 
-#*
-# *  APL
-# *  Byte 3 = b
-# *
-
-when defined(XK_APL) or true: 
-  const
-    XK_leftcaret* = 0x00000BA3
-    XK_rightcaret* = 0x00000BA6
-    XK_downcaret* = 0x00000BA8
-    XK_upcaret* = 0x00000BA9
-    XK_overbar* = 0x00000BC0
-    XK_downtack* = 0x00000BC2
-    XK_upshoe* = 0x00000BC3
-    XK_downstile* = 0x00000BC4
-    XK_underbar* = 0x00000BC6
-    XK_jot* = 0x00000BCA
-    XK_quad* = 0x00000BCC
-    XK_uptack* = 0x00000BCE
-    XK_circle* = 0x00000BCF
-    XK_upstile* = 0x00000BD3
-    XK_downshoe* = 0x00000BD6
-    XK_rightshoe* = 0x00000BD8
-    XK_leftshoe* = 0x00000BDA
-    XK_lefttack* = 0x00000BDC
-    XK_righttack* = 0x00000BFC
-# XK_APL 
-#*
-# * Hebrew
-# * Byte 3 = c
-# *
-
-when defined(XK_HEBREW) or true: 
-  const
-    XK_hebrew_doublelowline* = 0x00000CDF
-    XK_hebrew_aleph* = 0x00000CE0
-    XK_hebrew_bet* = 0x00000CE1
-    XK_hebrew_beth* = 0x00000CE1 # deprecated 
-    XK_hebrew_gimel* = 0x00000CE2
-    XK_hebrew_gimmel* = 0x00000CE2 # deprecated 
-    XK_hebrew_dalet* = 0x00000CE3
-    XK_hebrew_daleth* = 0x00000CE3 # deprecated 
-    XK_hebrew_he* = 0x00000CE4
-    XK_hebrew_waw* = 0x00000CE5
-    XK_hebrew_zain* = 0x00000CE6
-    XK_hebrew_zayin* = 0x00000CE6 # deprecated 
-    XK_hebrew_chet* = 0x00000CE7
-    XK_hebrew_het* = 0x00000CE7 # deprecated 
-    XK_hebrew_tet* = 0x00000CE8
-    XK_hebrew_teth* = 0x00000CE8 # deprecated 
-    XK_hebrew_yod* = 0x00000CE9
-    XK_hebrew_finalkaph* = 0x00000CEA
-    XK_hebrew_kaph* = 0x00000CEB
-    XK_hebrew_lamed* = 0x00000CEC
-    XK_hebrew_finalmem* = 0x00000CED
-    XK_hebrew_mem* = 0x00000CEE
-    XK_hebrew_finalnun* = 0x00000CEF
-    XK_hebrew_nun* = 0x00000CF0
-    XK_hebrew_samech* = 0x00000CF1
-    XK_hebrew_samekh* = 0x00000CF1 # deprecated 
-    XK_hebrew_ayin* = 0x00000CF2
-    XK_hebrew_finalpe* = 0x00000CF3
-    XK_hebrew_pe* = 0x00000CF4
-    XK_hebrew_finalzade* = 0x00000CF5
-    XK_hebrew_finalzadi* = 0x00000CF5 # deprecated 
-    XK_hebrew_zade* = 0x00000CF6
-    XK_hebrew_zadi* = 0x00000CF6 # deprecated 
-    XK_hebrew_qoph* = 0x00000CF7
-    XK_hebrew_kuf* = 0x00000CF7 # deprecated 
-    XK_hebrew_resh* = 0x00000CF8
-    XK_hebrew_shin* = 0x00000CF9
-    XK_hebrew_taw* = 0x00000CFA
-    XK_hebrew_taf* = 0x00000CFA # deprecated 
-    XK_Hebrew_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_HEBREW 
-#*
-# * Thai
-# * Byte 3 = d
-# *
-
-when defined(XK_THAI) or true: 
-  const
-    XK_Thai_kokai* = 0x00000DA1
-    XK_Thai_khokhai* = 0x00000DA2
-    XK_Thai_khokhuat* = 0x00000DA3
-    XK_Thai_khokhwai* = 0x00000DA4
-    XK_Thai_khokhon* = 0x00000DA5
-    XK_Thai_khorakhang* = 0x00000DA6
-    XK_Thai_ngongu* = 0x00000DA7
-    XK_Thai_chochan* = 0x00000DA8
-    XK_Thai_choching* = 0x00000DA9
-    XK_Thai_chochang* = 0x00000DAA
-    XK_Thai_soso* = 0x00000DAB
-    XK_Thai_chochoe* = 0x00000DAC
-    XK_Thai_yoying* = 0x00000DAD
-    XK_Thai_dochada* = 0x00000DAE
-    XK_Thai_topatak* = 0x00000DAF
-    XK_Thai_thothan* = 0x00000DB0
-    XK_Thai_thonangmontho* = 0x00000DB1
-    XK_Thai_thophuthao* = 0x00000DB2
-    XK_Thai_nonen* = 0x00000DB3
-    XK_Thai_dodek* = 0x00000DB4
-    XK_Thai_totao* = 0x00000DB5
-    XK_Thai_thothung* = 0x00000DB6
-    XK_Thai_thothahan* = 0x00000DB7
-    XK_Thai_thothong* = 0x00000DB8
-    XK_Thai_nonu* = 0x00000DB9
-    XK_Thai_bobaimai* = 0x00000DBA
-    XK_Thai_popla* = 0x00000DBB
-    XK_Thai_phophung* = 0x00000DBC
-    XK_Thai_fofa* = 0x00000DBD
-    XK_Thai_phophan* = 0x00000DBE
-    XK_Thai_fofan* = 0x00000DBF
-    XK_Thai_phosamphao* = 0x00000DC0
-    XK_Thai_moma* = 0x00000DC1
-    XK_Thai_yoyak* = 0x00000DC2
-    XK_Thai_rorua* = 0x00000DC3
-    XK_Thai_ru* = 0x00000DC4
-    XK_Thai_loling* = 0x00000DC5
-    XK_Thai_lu* = 0x00000DC6
-    XK_Thai_wowaen* = 0x00000DC7
-    XK_Thai_sosala* = 0x00000DC8
-    XK_Thai_sorusi* = 0x00000DC9
-    XK_Thai_sosua* = 0x00000DCA
-    XK_Thai_hohip* = 0x00000DCB
-    XK_Thai_lochula* = 0x00000DCC
-    XK_Thai_oang* = 0x00000DCD
-    XK_Thai_honokhuk* = 0x00000DCE
-    XK_Thai_paiyannoi* = 0x00000DCF
-    XK_Thai_saraa* = 0x00000DD0
-    XK_Thai_maihanakat* = 0x00000DD1
-    XK_Thai_saraaa* = 0x00000DD2
-    XK_Thai_saraam* = 0x00000DD3
-    XK_Thai_sarai* = 0x00000DD4
-    XK_Thai_saraii* = 0x00000DD5
-    XK_Thai_saraue* = 0x00000DD6
-    XK_Thai_sarauee* = 0x00000DD7
-    XK_Thai_sarau* = 0x00000DD8
-    XK_Thai_sarauu* = 0x00000DD9
-    XK_Thai_phinthu* = 0x00000DDA
-    XK_Thai_maihanakat_maitho* = 0x00000DDE
-    XK_Thai_baht* = 0x00000DDF
-    XK_Thai_sarae* = 0x00000DE0
-    XK_Thai_saraae* = 0x00000DE1
-    XK_Thai_sarao* = 0x00000DE2
-    XK_Thai_saraaimaimuan* = 0x00000DE3
-    XK_Thai_saraaimaimalai* = 0x00000DE4
-    XK_Thai_lakkhangyao* = 0x00000DE5
-    XK_Thai_maiyamok* = 0x00000DE6
-    XK_Thai_maitaikhu* = 0x00000DE7
-    XK_Thai_maiek* = 0x00000DE8
-    XK_Thai_maitho* = 0x00000DE9
-    XK_Thai_maitri* = 0x00000DEA
-    XK_Thai_maichattawa* = 0x00000DEB
-    XK_Thai_thanthakhat* = 0x00000DEC
-    XK_Thai_nikhahit* = 0x00000DED
-    XK_Thai_leksun* = 0x00000DF0
-    XK_Thai_leknung* = 0x00000DF1
-    XK_Thai_leksong* = 0x00000DF2
-    XK_Thai_leksam* = 0x00000DF3
-    XK_Thai_leksi* = 0x00000DF4
-    XK_Thai_lekha* = 0x00000DF5
-    XK_Thai_lekhok* = 0x00000DF6
-    XK_Thai_lekchet* = 0x00000DF7
-    XK_Thai_lekpaet* = 0x00000DF8
-    XK_Thai_lekkao* = 0x00000DF9
-# XK_THAI 
-#*
-# *   Korean
-# *   Byte 3 = e
-# *
-
-when defined(XK_KOREAN) or true: 
-  const
-    XK_Hangul* = 0x0000FF31     # Hangul start/stop(toggle) 
-    XK_Hangul_Start* = 0x0000FF32 # Hangul start 
-    XK_Hangul_End* = 0x0000FF33 # Hangul end, English start 
-    XK_Hangul_Hanja* = 0x0000FF34 # Start Hangul->Hanja Conversion 
-    XK_Hangul_Jamo* = 0x0000FF35 # Hangul Jamo mode 
-    XK_Hangul_Romaja* = 0x0000FF36 # Hangul Romaja mode 
-    XK_Hangul_Codeinput* = 0x0000FF37 # Hangul code input mode 
-    XK_Hangul_Jeonja* = 0x0000FF38 # Jeonja mode 
-    XK_Hangul_Banja* = 0x0000FF39 # Banja mode 
-    XK_Hangul_PreHanja* = 0x0000FF3A # Pre Hanja conversion 
-    XK_Hangul_PostHanja* = 0x0000FF3B # Post Hanja conversion 
-    XK_Hangul_SingleCandidate* = 0x0000FF3C # Single candidate 
-    XK_Hangul_MultipleCandidate* = 0x0000FF3D # Multiple candidate 
-    XK_Hangul_PreviousCandidate* = 0x0000FF3E # Previous candidate 
-    XK_Hangul_Special* = 0x0000FF3F # Special symbols 
-    XK_Hangul_switch* = 0x0000FF7E # Alias for mode_switch 
-                                   # Hangul Consonant Characters 
-    XK_Hangul_Kiyeog* = 0x00000EA1
-    XK_Hangul_SsangKiyeog* = 0x00000EA2
-    XK_Hangul_KiyeogSios* = 0x00000EA3
-    XK_Hangul_Nieun* = 0x00000EA4
-    XK_Hangul_NieunJieuj* = 0x00000EA5
-    XK_Hangul_NieunHieuh* = 0x00000EA6
-    XK_Hangul_Dikeud* = 0x00000EA7
-    XK_Hangul_SsangDikeud* = 0x00000EA8
-    XK_Hangul_Rieul* = 0x00000EA9
-    XK_Hangul_RieulKiyeog* = 0x00000EAA
-    XK_Hangul_RieulMieum* = 0x00000EAB
-    XK_Hangul_RieulPieub* = 0x00000EAC
-    XK_Hangul_RieulSios* = 0x00000EAD
-    XK_Hangul_RieulTieut* = 0x00000EAE
-    XK_Hangul_RieulPhieuf* = 0x00000EAF
-    XK_Hangul_RieulHieuh* = 0x00000EB0
-    XK_Hangul_Mieum* = 0x00000EB1
-    XK_Hangul_Pieub* = 0x00000EB2
-    XK_Hangul_SsangPieub* = 0x00000EB3
-    XK_Hangul_PieubSios* = 0x00000EB4
-    XK_Hangul_Sios* = 0x00000EB5
-    XK_Hangul_SsangSios* = 0x00000EB6
-    XK_Hangul_Ieung* = 0x00000EB7
-    XK_Hangul_Jieuj* = 0x00000EB8
-    XK_Hangul_SsangJieuj* = 0x00000EB9
-    XK_Hangul_Cieuc* = 0x00000EBA
-    XK_Hangul_Khieuq* = 0x00000EBB
-    XK_Hangul_Tieut* = 0x00000EBC
-    XK_Hangul_Phieuf* = 0x00000EBD
-    XK_Hangul_Hieuh* = 0x00000EBE # Hangul Vowel Characters 
-    XK_Hangul_A* = 0x00000EBF
-    XK_Hangul_AE* = 0x00000EC0
-    XK_Hangul_YA* = 0x00000EC1
-    XK_Hangul_YAE* = 0x00000EC2
-    XK_Hangul_EO* = 0x00000EC3
-    XK_Hangul_E* = 0x00000EC4
-    XK_Hangul_YEO* = 0x00000EC5
-    XK_Hangul_YE* = 0x00000EC6
-    XK_Hangul_O* = 0x00000EC7
-    XK_Hangul_WA* = 0x00000EC8
-    XK_Hangul_WAE* = 0x00000EC9
-    XK_Hangul_OE* = 0x00000ECA
-    XK_Hangul_YO* = 0x00000ECB
-    XK_Hangul_U* = 0x00000ECC
-    XK_Hangul_WEO* = 0x00000ECD
-    XK_Hangul_WE* = 0x00000ECE
-    XK_Hangul_WI* = 0x00000ECF
-    XK_Hangul_YU* = 0x00000ED0
-    XK_Hangul_EU* = 0x00000ED1
-    XK_Hangul_YI* = 0x00000ED2
-    XK_Hangul_I* = 0x00000ED3   # Hangul syllable-final (JongSeong) Characters 
-    XK_Hangul_J_Kiyeog* = 0x00000ED4
-    XK_Hangul_J_SsangKiyeog* = 0x00000ED5
-    XK_Hangul_J_KiyeogSios* = 0x00000ED6
-    XK_Hangul_J_Nieun* = 0x00000ED7
-    XK_Hangul_J_NieunJieuj* = 0x00000ED8
-    XK_Hangul_J_NieunHieuh* = 0x00000ED9
-    XK_Hangul_J_Dikeud* = 0x00000EDA
-    XK_Hangul_J_Rieul* = 0x00000EDB
-    XK_Hangul_J_RieulKiyeog* = 0x00000EDC
-    XK_Hangul_J_RieulMieum* = 0x00000EDD
-    XK_Hangul_J_RieulPieub* = 0x00000EDE
-    XK_Hangul_J_RieulSios* = 0x00000EDF
-    XK_Hangul_J_RieulTieut* = 0x00000EE0
-    XK_Hangul_J_RieulPhieuf* = 0x00000EE1
-    XK_Hangul_J_RieulHieuh* = 0x00000EE2
-    XK_Hangul_J_Mieum* = 0x00000EE3
-    XK_Hangul_J_Pieub* = 0x00000EE4
-    XK_Hangul_J_PieubSios* = 0x00000EE5
-    XK_Hangul_J_Sios* = 0x00000EE6
-    XK_Hangul_J_SsangSios* = 0x00000EE7
-    XK_Hangul_J_Ieung* = 0x00000EE8
-    XK_Hangul_J_Jieuj* = 0x00000EE9
-    XK_Hangul_J_Cieuc* = 0x00000EEA
-    XK_Hangul_J_Khieuq* = 0x00000EEB
-    XK_Hangul_J_Tieut* = 0x00000EEC
-    XK_Hangul_J_Phieuf* = 0x00000EED
-    XK_Hangul_J_Hieuh* = 0x00000EEE # Ancient Hangul Consonant Characters 
-    XK_Hangul_RieulYeorinHieuh* = 0x00000EEF
-    XK_Hangul_SunkyeongeumMieum* = 0x00000EF0
-    XK_Hangul_SunkyeongeumPieub* = 0x00000EF1
-    XK_Hangul_PanSios* = 0x00000EF2
-    XK_Hangul_KkogjiDalrinIeung* = 0x00000EF3
-    XK_Hangul_SunkyeongeumPhieuf* = 0x00000EF4
-    XK_Hangul_YeorinHieuh* = 0x00000EF5 # Ancient Hangul Vowel Characters 
-    XK_Hangul_AraeA* = 0x00000EF6
-    XK_Hangul_AraeAE* = 0x00000EF7 # Ancient Hangul syllable-final (JongSeong) Characters 
-    XK_Hangul_J_PanSios* = 0x00000EF8
-    XK_Hangul_J_KkogjiDalrinIeung* = 0x00000EF9
-    XK_Hangul_J_YeorinHieuh* = 0x00000EFA # Korean currency symbol 
-    XK_Korean_Won* = 0x00000EFF
-# XK_KOREAN 
-#*
-# *   Armenian
-# *   Byte 3 = = $14
-# *
-
-when defined(XK_ARMENIAN) or true: 
-  const
-    XK_Armenian_eternity* = 0x000014A1
-    XK_Armenian_ligature_ew* = 0x000014A2
-    XK_Armenian_full_stop* = 0x000014A3
-    XK_Armenian_verjaket* = 0x000014A3
-    XK_Armenian_parenright* = 0x000014A4
-    XK_Armenian_parenleft* = 0x000014A5
-    XK_Armenian_guillemotright* = 0x000014A6
-    XK_Armenian_guillemotleft* = 0x000014A7
-    XK_Armenian_em_dash* = 0x000014A8
-    XK_Armenian_dot* = 0x000014A9
-    XK_Armenian_mijaket* = 0x000014A9
-    XK_Armenian_separation_mark* = 0x000014AA
-    XK_Armenian_but* = 0x000014AA
-    XK_Armenian_comma* = 0x000014AB
-    XK_Armenian_en_dash* = 0x000014AC
-    XK_Armenian_hyphen* = 0x000014AD
-    XK_Armenian_yentamna* = 0x000014AD
-    XK_Armenian_ellipsis* = 0x000014AE
-    XK_Armenian_exclam* = 0x000014AF
-    XK_Armenian_amanak* = 0x000014AF
-    XK_Armenian_accent* = 0x000014B0
-    XK_Armenian_shesht* = 0x000014B0
-    XK_Armenian_question* = 0x000014B1
-    XK_Armenian_paruyk* = 0x000014B1
-    XKc_Armenian_AYB* = 0x000014B2
-    XK_Armenian_ayb* = 0x000014B3
-    XKc_Armenian_BEN* = 0x000014B4
-    XK_Armenian_ben* = 0x000014B5
-    XKc_Armenian_GIM* = 0x000014B6
-    XK_Armenian_gim* = 0x000014B7
-    XKc_Armenian_DA* = 0x000014B8
-    XK_Armenian_da* = 0x000014B9
-    XKc_Armenian_YECH* = 0x000014BA
-    XK_Armenian_yech* = 0x000014BB
-    XKc_Armenian_ZA* = 0x000014BC
-    XK_Armenian_za* = 0x000014BD
-    XKc_Armenian_E* = 0x000014BE
-    XK_Armenian_e* = 0x000014BF
-    XKc_Armenian_AT* = 0x000014C0
-    XK_Armenian_at* = 0x000014C1
-    XKc_Armenian_TO* = 0x000014C2
-    XK_Armenian_to* = 0x000014C3
-    XKc_Armenian_ZHE* = 0x000014C4
-    XK_Armenian_zhe* = 0x000014C5
-    XKc_Armenian_INI* = 0x000014C6
-    XK_Armenian_ini* = 0x000014C7
-    XKc_Armenian_LYUN* = 0x000014C8
-    XK_Armenian_lyun* = 0x000014C9
-    XKc_Armenian_KHE* = 0x000014CA
-    XK_Armenian_khe* = 0x000014CB
-    XKc_Armenian_TSA* = 0x000014CC
-    XK_Armenian_tsa* = 0x000014CD
-    XKc_Armenian_KEN* = 0x000014CE
-    XK_Armenian_ken* = 0x000014CF
-    XKc_Armenian_HO* = 0x000014D0
-    XK_Armenian_ho* = 0x000014D1
-    XKc_Armenian_DZA* = 0x000014D2
-    XK_Armenian_dza* = 0x000014D3
-    XKc_Armenian_GHAT* = 0x000014D4
-    XK_Armenian_ghat* = 0x000014D5
-    XKc_Armenian_TCHE* = 0x000014D6
-    XK_Armenian_tche* = 0x000014D7
-    XKc_Armenian_MEN* = 0x000014D8
-    XK_Armenian_men* = 0x000014D9
-    XKc_Armenian_HI* = 0x000014DA
-    XK_Armenian_hi* = 0x000014DB
-    XKc_Armenian_NU* = 0x000014DC
-    XK_Armenian_nu* = 0x000014DD
-    XKc_Armenian_SHA* = 0x000014DE
-    XK_Armenian_sha* = 0x000014DF
-    XKc_Armenian_VO* = 0x000014E0
-    XK_Armenian_vo* = 0x000014E1
-    XKc_Armenian_CHA* = 0x000014E2
-    XK_Armenian_cha* = 0x000014E3
-    XKc_Armenian_PE* = 0x000014E4
-    XK_Armenian_pe* = 0x000014E5
-    XKc_Armenian_JE* = 0x000014E6
-    XK_Armenian_je* = 0x000014E7
-    XKc_Armenian_RA* = 0x000014E8
-    XK_Armenian_ra* = 0x000014E9
-    XKc_Armenian_SE* = 0x000014EA
-    XK_Armenian_se* = 0x000014EB
-    XKc_Armenian_VEV* = 0x000014EC
-    XK_Armenian_vev* = 0x000014ED
-    XKc_Armenian_TYUN* = 0x000014EE
-    XK_Armenian_tyun* = 0x000014EF
-    XKc_Armenian_RE* = 0x000014F0
-    XK_Armenian_re* = 0x000014F1
-    XKc_Armenian_TSO* = 0x000014F2
-    XK_Armenian_tso* = 0x000014F3
-    XKc_Armenian_VYUN* = 0x000014F4
-    XK_Armenian_vyun* = 0x000014F5
-    XKc_Armenian_PYUR* = 0x000014F6
-    XK_Armenian_pyur* = 0x000014F7
-    XKc_Armenian_KE* = 0x000014F8
-    XK_Armenian_ke* = 0x000014F9
-    XKc_Armenian_O* = 0x000014FA
-    XK_Armenian_o* = 0x000014FB
-    XKc_Armenian_FE* = 0x000014FC
-    XK_Armenian_fe* = 0x000014FD
-    XK_Armenian_apostrophe* = 0x000014FE
-    XK_Armenian_section_sign* = 0x000014FF
-# XK_ARMENIAN 
-#*
-# *   Georgian
-# *   Byte 3 = = $15
-# *
-
-when defined(XK_GEORGIAN) or true: 
-  const
-    XK_Georgian_an* = 0x000015D0
-    XK_Georgian_ban* = 0x000015D1
-    XK_Georgian_gan* = 0x000015D2
-    XK_Georgian_don* = 0x000015D3
-    XK_Georgian_en* = 0x000015D4
-    XK_Georgian_vin* = 0x000015D5
-    XK_Georgian_zen* = 0x000015D6
-    XK_Georgian_tan* = 0x000015D7
-    XK_Georgian_in* = 0x000015D8
-    XK_Georgian_kan* = 0x000015D9
-    XK_Georgian_las* = 0x000015DA
-    XK_Georgian_man* = 0x000015DB
-    XK_Georgian_nar* = 0x000015DC
-    XK_Georgian_on* = 0x000015DD
-    XK_Georgian_par* = 0x000015DE
-    XK_Georgian_zhar* = 0x000015DF
-    XK_Georgian_rae* = 0x000015E0
-    XK_Georgian_san* = 0x000015E1
-    XK_Georgian_tar* = 0x000015E2
-    XK_Georgian_un* = 0x000015E3
-    XK_Georgian_phar* = 0x000015E4
-    XK_Georgian_khar* = 0x000015E5
-    XK_Georgian_ghan* = 0x000015E6
-    XK_Georgian_qar* = 0x000015E7
-    XK_Georgian_shin* = 0x000015E8
-    XK_Georgian_chin* = 0x000015E9
-    XK_Georgian_can* = 0x000015EA
-    XK_Georgian_jil* = 0x000015EB
-    XK_Georgian_cil* = 0x000015EC
-    XK_Georgian_char* = 0x000015ED
-    XK_Georgian_xan* = 0x000015EE
-    XK_Georgian_jhan* = 0x000015EF
-    XK_Georgian_hae* = 0x000015F0
-    XK_Georgian_he* = 0x000015F1
-    XK_Georgian_hie* = 0x000015F2
-    XK_Georgian_we* = 0x000015F3
-    XK_Georgian_har* = 0x000015F4
-    XK_Georgian_hoe* = 0x000015F5
-    XK_Georgian_fi* = 0x000015F6
-# XK_GEORGIAN 
-#*
-# * Azeri (and other Turkic or Caucasian languages of ex-USSR)
-# * Byte 3 = = $16
-# *
-
-when defined(XK_CAUCASUS) or true: 
-  # latin 
-  const
-    XKc_Ccedillaabovedot* = 0x000016A2
-    XKc_Xabovedot* = 0x000016A3
-    XKc_Qabovedot* = 0x000016A5
-    XKc_Ibreve* = 0x000016A6
-    XKc_IE* = 0x000016A7
-    XKc_UO* = 0x000016A8
-    XKc_Zstroke* = 0x000016A9
-    XKc_Gcaron* = 0x000016AA
-    XKc_Obarred* = 0x000016AF
-    XK_ccedillaabovedot* = 0x000016B2
-    XK_xabovedot* = 0x000016B3
-    XKc_Ocaron* = 0x000016B4
-    XK_qabovedot* = 0x000016B5
-    XK_ibreve* = 0x000016B6
-    XK_ie* = 0x000016B7
-    XK_uo* = 0x000016B8
-    XK_zstroke* = 0x000016B9
-    XK_gcaron* = 0x000016BA
-    XK_ocaron* = 0x000016BD
-    XK_obarred* = 0x000016BF
-    XKc_SCHWA* = 0x000016C6
-    XK_schwa* = 0x000016F6 # those are not really Caucasus, but I put them here for now 
-                           # For Inupiak 
-    XKc_Lbelowdot* = 0x000016D1
-    XKc_Lstrokebelowdot* = 0x000016D2
-    XK_lbelowdot* = 0x000016E1
-    XK_lstrokebelowdot* = 0x000016E2 # For Guarani 
-    XKc_Gtilde* = 0x000016D3
-    XK_gtilde* = 0x000016E3
-# XK_CAUCASUS 
-#*
-# *   Vietnamese
-# *   Byte 3 = = $1e
-# *
-
-when defined(XK_VIETNAMESE) or true:
-  const 
-    XKc_Abelowdot* = 0x00001EA0
-    XK_abelowdot* = 0x00001EA1
-    XKc_Ahook* = 0x00001EA2
-    XK_ahook* = 0x00001EA3
-    XKc_Acircumflexacute* = 0x00001EA4
-    XK_acircumflexacute* = 0x00001EA5
-    XKc_Acircumflexgrave* = 0x00001EA6
-    XK_acircumflexgrave* = 0x00001EA7
-    XKc_Acircumflexhook* = 0x00001EA8
-    XK_acircumflexhook* = 0x00001EA9
-    XKc_Acircumflextilde* = 0x00001EAA
-    XK_acircumflextilde* = 0x00001EAB
-    XKc_Acircumflexbelowdot* = 0x00001EAC
-    XK_acircumflexbelowdot* = 0x00001EAD
-    XKc_Abreveacute* = 0x00001EAE
-    XK_abreveacute* = 0x00001EAF
-    XKc_Abrevegrave* = 0x00001EB0
-    XK_abrevegrave* = 0x00001EB1
-    XKc_Abrevehook* = 0x00001EB2
-    XK_abrevehook* = 0x00001EB3
-    XKc_Abrevetilde* = 0x00001EB4
-    XK_abrevetilde* = 0x00001EB5
-    XKc_Abrevebelowdot* = 0x00001EB6
-    XK_abrevebelowdot* = 0x00001EB7
-    XKc_Ebelowdot* = 0x00001EB8
-    XK_ebelowdot* = 0x00001EB9
-    XKc_Ehook* = 0x00001EBA
-    XK_ehook* = 0x00001EBB
-    XKc_Etilde* = 0x00001EBC
-    XK_etilde* = 0x00001EBD
-    XKc_Ecircumflexacute* = 0x00001EBE
-    XK_ecircumflexacute* = 0x00001EBF
-    XKc_Ecircumflexgrave* = 0x00001EC0
-    XK_ecircumflexgrave* = 0x00001EC1
-    XKc_Ecircumflexhook* = 0x00001EC2
-    XK_ecircumflexhook* = 0x00001EC3
-    XKc_Ecircumflextilde* = 0x00001EC4
-    XK_ecircumflextilde* = 0x00001EC5
-    XKc_Ecircumflexbelowdot* = 0x00001EC6
-    XK_ecircumflexbelowdot* = 0x00001EC7
-    XKc_Ihook* = 0x00001EC8
-    XK_ihook* = 0x00001EC9
-    XKc_Ibelowdot* = 0x00001ECA
-    XK_ibelowdot* = 0x00001ECB
-    XKc_Obelowdot* = 0x00001ECC
-    XK_obelowdot* = 0x00001ECD
-    XKc_Ohook* = 0x00001ECE
-    XK_ohook* = 0x00001ECF
-    XKc_Ocircumflexacute* = 0x00001ED0
-    XK_ocircumflexacute* = 0x00001ED1
-    XKc_Ocircumflexgrave* = 0x00001ED2
-    XK_ocircumflexgrave* = 0x00001ED3
-    XKc_Ocircumflexhook* = 0x00001ED4
-    XK_ocircumflexhook* = 0x00001ED5
-    XKc_Ocircumflextilde* = 0x00001ED6
-    XK_ocircumflextilde* = 0x00001ED7
-    XKc_Ocircumflexbelowdot* = 0x00001ED8
-    XK_ocircumflexbelowdot* = 0x00001ED9
-    XKc_Ohornacute* = 0x00001EDA
-    XK_ohornacute* = 0x00001EDB
-    XKc_Ohorngrave* = 0x00001EDC
-    XK_ohorngrave* = 0x00001EDD
-    XKc_Ohornhook* = 0x00001EDE
-    XK_ohornhook* = 0x00001EDF
-    XKc_Ohorntilde* = 0x00001EE0
-    XK_ohorntilde* = 0x00001EE1
-    XKc_Ohornbelowdot* = 0x00001EE2
-    XK_ohornbelowdot* = 0x00001EE3
-    XKc_Ubelowdot* = 0x00001EE4
-    XK_ubelowdot* = 0x00001EE5
-    XKc_Uhook* = 0x00001EE6
-    XK_uhook* = 0x00001EE7
-    XKc_Uhornacute* = 0x00001EE8
-    XK_uhornacute* = 0x00001EE9
-    XKc_Uhorngrave* = 0x00001EEA
-    XK_uhorngrave* = 0x00001EEB
-    XKc_Uhornhook* = 0x00001EEC
-    XK_uhornhook* = 0x00001EED
-    XKc_Uhorntilde* = 0x00001EEE
-    XK_uhorntilde* = 0x00001EEF
-    XKc_Uhornbelowdot* = 0x00001EF0
-    XK_uhornbelowdot* = 0x00001EF1
-    XKc_Ybelowdot* = 0x00001EF4
-    XK_ybelowdot* = 0x00001EF5
-    XKc_Yhook* = 0x00001EF6
-    XK_yhook* = 0x00001EF7
-    XKc_Ytilde* = 0x00001EF8
-    XK_ytilde* = 0x00001EF9
-    XKc_Ohorn* = 0x00001EFA     # U+01a0 
-    XK_ohorn* = 0x00001EFB      # U+01a1 
-    XKc_Uhorn* = 0x00001EFC     # U+01af 
-    XK_uhorn* = 0x00001EFD      # U+01b0 
-    XK_combining_tilde* = 0x00001E9F # U+0303 
-    XK_combining_grave* = 0x00001EF2 # U+0300 
-    XK_combining_acute* = 0x00001EF3 # U+0301 
-    XK_combining_hook* = 0x00001EFE # U+0309 
-    XK_combining_belowdot* = 0x00001EFF # U+0323 
-# XK_VIETNAMESE 
-
-when defined(XK_CURRENCY) or true: 
-  const
-    XK_EcuSign* = 0x000020A0
-    XK_ColonSign* = 0x000020A1
-    XK_CruzeiroSign* = 0x000020A2
-    XK_FFrancSign* = 0x000020A3
-    XK_LiraSign* = 0x000020A4
-    XK_MillSign* = 0x000020A5
-    XK_NairaSign* = 0x000020A6
-    XK_PesetaSign* = 0x000020A7
-    XK_RupeeSign* = 0x000020A8
-    XK_WonSign* = 0x000020A9
-    XK_NewSheqelSign* = 0x000020AA
-    XK_DongSign* = 0x000020AB
-    XK_EuroSign* = 0x000020AC
-# implementation
diff --git a/lib/oldwrappers/x11/x.nim b/lib/oldwrappers/x11/x.nim
deleted file mode 100755
index aa6e7f821..000000000
--- a/lib/oldwrappers/x11/x.nim
+++ /dev/null
@@ -1,399 +0,0 @@
-
-#
-#  Automatically converted by H2Pas 0.99.15 from x.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    x.h
-#
-# Pointers to basic pascal types, inserted by h2pas conversion program.
-
-const 
-  X_PROTOCOL* = 11
-  X_PROTOCOL_REVISION* = 0
-
-type
-  culong* = int
-  cuchar* = char
-  PXID* = ptr TXID
-  TXID* = culong
-  PMask* = ptr TMask
-  TMask* = culong
-  PPAtom* = ptr PAtom
-  PAtom* = ptr TAtom
-  TAtom* = culong
-  PVisualID* = ptr TVisualID
-  TVisualID* = culong
-  PTime* = ptr TTime
-  TTime* = culong
-  PPWindow* = ptr PWindow
-  PWindow* = ptr TWindow
-  TWindow* = TXID
-  PDrawable* = ptr TDrawable
-  TDrawable* = TXID
-  PFont* = ptr TFont
-  TFont* = TXID
-  PPixmap* = ptr TPixmap
-  TPixmap* = TXID
-  PCursor* = ptr TCursor
-  TCursor* = TXID
-  PColormap* = ptr TColormap
-  TColormap* = TXID
-  PGContext* = ptr TGContext
-  TGContext* = TXID
-  PKeySym* = ptr TKeySym
-  TKeySym* = TXID
-  PKeyCode* = ptr TKeyCode
-  TKeyCode* = cuchar
-
-const 
-  None* = 0
-  ParentRelative* = 1
-  CopyFromParent* = 0
-  PointerWindow* = 0
-  InputFocus* = 1
-  PointerRoot* = 1
-  AnyPropertyType* = 0
-  AnyKey* = 0
-  AnyButton* = 0
-  AllTemporary* = 0
-  CurrentTime* = 0
-  NoSymbol* = 0
-  NoEventMask* = 0
-  KeyPressMask* = 1 shl 0
-  KeyReleaseMask* = 1 shl 1
-  ButtonPressMask* = 1 shl 2
-  ButtonReleaseMask* = 1 shl 3
-  EnterWindowMask* = 1 shl 4
-  LeaveWindowMask* = 1 shl 5
-  PointerMotionMask* = 1 shl 6
-  PointerMotionHintMask* = 1 shl 7
-  Button1MotionMask* = 1 shl 8
-  Button2MotionMask* = 1 shl 9
-  Button3MotionMask* = 1 shl 10
-  Button4MotionMask* = 1 shl 11
-  Button5MotionMask* = 1 shl 12
-  ButtonMotionMask* = 1 shl 13
-  KeymapStateMask* = 1 shl 14
-  ExposureMask* = 1 shl 15
-  VisibilityChangeMask* = 1 shl 16
-  StructureNotifyMask* = 1 shl 17
-  ResizeRedirectMask* = 1 shl 18
-  SubstructureNotifyMask* = 1 shl 19
-  SubstructureRedirectMask* = 1 shl 20
-  FocusChangeMask* = 1 shl 21
-  PropertyChangeMask* = 1 shl 22
-  ColormapChangeMask* = 1 shl 23
-  OwnerGrabButtonMask* = 1 shl 24
-  KeyPress* = 2
-  KeyRelease* = 3
-  ButtonPress* = 4
-  ButtonRelease* = 5
-  MotionNotify* = 6
-  EnterNotify* = 7
-  LeaveNotify* = 8
-  FocusIn* = 9
-  FocusOut* = 10
-  KeymapNotify* = 11
-  Expose* = 12
-  GraphicsExpose* = 13
-  NoExpose* = 14
-  VisibilityNotify* = 15
-  CreateNotify* = 16
-  DestroyNotify* = 17
-  UnmapNotify* = 18
-  MapNotify* = 19
-  MapRequest* = 20
-  ReparentNotify* = 21
-  ConfigureNotify* = 22
-  ConfigureRequest* = 23
-  GravityNotify* = 24
-  ResizeRequest* = 25
-  CirculateNotify* = 26
-  CirculateRequest* = 27
-  PropertyNotify* = 28
-  SelectionClear* = 29
-  SelectionRequest* = 30
-  SelectionNotify* = 31
-  ColormapNotify* = 32
-  ClientMessage* = 33
-  MappingNotify* = 34
-  LASTEvent* = 35
-  ShiftMask* = 1 shl 0
-  LockMask* = 1 shl 1
-  ControlMask* = 1 shl 2
-  Mod1Mask* = 1 shl 3
-  Mod2Mask* = 1 shl 4
-  Mod3Mask* = 1 shl 5
-  Mod4Mask* = 1 shl 6
-  Mod5Mask* = 1 shl 7
-  ShiftMapIndex* = 0
-  LockMapIndex* = 1
-  ControlMapIndex* = 2
-  Mod1MapIndex* = 3
-  Mod2MapIndex* = 4
-  Mod3MapIndex* = 5
-  Mod4MapIndex* = 6
-  Mod5MapIndex* = 7
-  Button1Mask* = 1 shl 8
-  Button2Mask* = 1 shl 9
-  Button3Mask* = 1 shl 10
-  Button4Mask* = 1 shl 11
-  Button5Mask* = 1 shl 12
-  AnyModifier* = 1 shl 15
-  Button1* = 1
-  Button2* = 2
-  Button3* = 3
-  Button4* = 4
-  Button5* = 5
-  NotifyNormal* = 0
-  NotifyGrab* = 1
-  NotifyUngrab* = 2
-  NotifyWhileGrabbed* = 3
-  NotifyHint* = 1
-  NotifyAncestor* = 0
-  NotifyVirtual* = 1
-  NotifyInferior* = 2
-  NotifyNonlinear* = 3
-  NotifyNonlinearVirtual* = 4
-  NotifyPointer* = 5
-  NotifyPointerRoot* = 6
-  NotifyDetailNone* = 7
-  VisibilityUnobscured* = 0
-  VisibilityPartiallyObscured* = 1
-  VisibilityFullyObscured* = 2
-  PlaceOnTop* = 0
-  PlaceOnBottom* = 1
-  FamilyInternet* = 0
-  FamilyDECnet* = 1
-  FamilyChaos* = 2
-  FamilyInternet6* = 6
-  FamilyServerInterpreted* = 5
-  PropertyNewValue* = 0
-  PropertyDelete* = 1
-  ColormapUninstalled* = 0
-  ColormapInstalled* = 1
-  GrabModeSync* = 0
-  GrabModeAsync* = 1
-  GrabSuccess* = 0
-  AlreadyGrabbed* = 1
-  GrabInvalidTime* = 2
-  GrabNotViewable* = 3
-  GrabFrozen* = 4
-  AsyncPointer* = 0
-  SyncPointer* = 1
-  ReplayPointer* = 2
-  AsyncKeyboard* = 3
-  SyncKeyboard* = 4
-  ReplayKeyboard* = 5
-  AsyncBoth* = 6
-  SyncBoth* = 7
-  RevertToNone* = None
-  RevertToPointerRoot* = PointerRoot
-  RevertToParent* = 2
-  Success* = 0
-  BadRequest* = 1
-  BadValue* = 2
-  BadWindow* = 3
-  BadPixmap* = 4
-  BadAtom* = 5
-  BadCursor* = 6
-  BadFont* = 7
-  BadMatch* = 8
-  BadDrawable* = 9
-  BadAccess* = 10
-  BadAlloc* = 11
-  BadColor* = 12
-  BadGC* = 13
-  BadIDChoice* = 14
-  BadName* = 15
-  BadLength* = 16
-  BadImplementation* = 17
-  FirstExtensionError* = 128
-  LastExtensionError* = 255
-  InputOutput* = 1
-  InputOnly* = 2
-  CWBackPixmap* = 1 shl 0
-  CWBackPixel* = 1 shl 1
-  CWBorderPixmap* = 1 shl 2
-  CWBorderPixel* = 1 shl 3
-  CWBitGravity* = 1 shl 4
-  CWWinGravity* = 1 shl 5
-  CWBackingStore* = 1 shl 6
-  CWBackingPlanes* = 1 shl 7
-  CWBackingPixel* = 1 shl 8
-  CWOverrideRedirect* = 1 shl 9
-  CWSaveUnder* = 1 shl 10
-  CWEventMask* = 1 shl 11
-  CWDontPropagate* = 1 shl 12
-  CWColormap* = 1 shl 13
-  CWCursor* = 1 shl 14
-  CWX* = 1 shl 0
-  CWY* = 1 shl 1
-  CWWidth* = 1 shl 2
-  CWHeight* = 1 shl 3
-  CWBorderWidth* = 1 shl 4
-  CWSibling* = 1 shl 5
-  CWStackMode* = 1 shl 6
-  ForgetGravity* = 0
-  NorthWestGravity* = 1
-  NorthGravity* = 2
-  NorthEastGravity* = 3
-  WestGravity* = 4
-  CenterGravity* = 5
-  EastGravity* = 6
-  SouthWestGravity* = 7
-  SouthGravity* = 8
-  SouthEastGravity* = 9
-  StaticGravity* = 10
-  UnmapGravity* = 0
-  NotUseful* = 0
-  WhenMapped* = 1
-  Always* = 2
-  IsUnmapped* = 0
-  IsUnviewable* = 1
-  IsViewable* = 2
-  SetModeInsert* = 0
-  SetModeDelete* = 1
-  DestroyAll* = 0
-  RetainPermanent* = 1
-  RetainTemporary* = 2
-  Above* = 0
-  Below* = 1
-  TopIf* = 2
-  BottomIf* = 3
-  Opposite* = 4
-  RaiseLowest* = 0
-  LowerHighest* = 1
-  PropModeReplace* = 0
-  PropModePrepend* = 1
-  PropModeAppend* = 2
-  GXclear* = 0x00000000
-  GXand* = 0x00000001
-  GXandReverse* = 0x00000002
-  GXcopy* = 0x00000003
-  GXandInverted* = 0x00000004
-  GXnoop* = 0x00000005
-  GXxor* = 0x00000006
-  GXor* = 0x00000007
-  GXnor* = 0x00000008
-  GXequiv* = 0x00000009
-  GXinvert* = 0x0000000A
-  GXorReverse* = 0x0000000B
-  GXcopyInverted* = 0x0000000C
-  GXorInverted* = 0x0000000D
-  GXnand* = 0x0000000E
-  GXset* = 0x0000000F
-  LineSolid* = 0
-  LineOnOffDash* = 1
-  LineDoubleDash* = 2
-  CapNotLast* = 0
-  CapButt* = 1
-  CapRound* = 2
-  CapProjecting* = 3
-  JoinMiter* = 0
-  JoinRound* = 1
-  JoinBevel* = 2
-  FillSolid* = 0
-  FillTiled* = 1
-  FillStippled* = 2
-  FillOpaqueStippled* = 3
-  EvenOddRule* = 0
-  WindingRule* = 1
-  ClipByChildren* = 0
-  IncludeInferiors* = 1
-  Unsorted* = 0
-  YSorted* = 1
-  YXSorted* = 2
-  YXBanded* = 3
-  CoordModeOrigin* = 0
-  CoordModePrevious* = 1
-  Complex* = 0
-  Nonconvex* = 1
-  Convex* = 2
-  ArcChord* = 0
-  ArcPieSlice* = 1
-  GCFunction* = 1 shl 0
-  GCPlaneMask* = 1 shl 1
-  GCForeground* = 1 shl 2
-  GCBackground* = 1 shl 3
-  GCLineWidth* = 1 shl 4
-  GCLineStyle* = 1 shl 5
-  GCCapStyle* = 1 shl 6
-  GCJoinStyle* = 1 shl 7
-  GCFillStyle* = 1 shl 8
-  GCFillRule* = 1 shl 9
-  GCTile* = 1 shl 10
-  GCStipple* = 1 shl 11
-  GCTileStipXOrigin* = 1 shl 12
-  GCTileStipYOrigin* = 1 shl 13
-  GCFont* = 1 shl 14
-  GCSubwindowMode* = 1 shl 15
-  GCGraphicsExposures* = 1 shl 16
-  GCClipXOrigin* = 1 shl 17
-  GCClipYOrigin* = 1 shl 18
-  GCClipMask* = 1 shl 19
-  GCDashOffset* = 1 shl 20
-  GCDashList* = 1 shl 21
-  GCArcMode* = 1 shl 22
-  GCLastBit* = 22
-  FontLeftToRight* = 0
-  FontRightToLeft* = 1
-  FontChange* = 255
-  XYBitmap* = 0
-  XYPixmap* = 1
-  ZPixmap* = 2
-  AllocNone* = 0
-  AllocAll* = 1
-  DoRed* = 1 shl 0
-  DoGreen* = 1 shl 1
-  DoBlue* = 1 shl 2
-  CursorShape* = 0
-  TileShape* = 1
-  StippleShape* = 2
-  AutoRepeatModeOff* = 0
-  AutoRepeatModeOn* = 1
-  AutoRepeatModeDefault* = 2
-  LedModeOff* = 0
-  LedModeOn* = 1
-  KBKeyClickPercent* = 1 shl 0
-  KBBellPercent* = 1 shl 1
-  KBBellPitch* = 1 shl 2
-  KBBellDuration* = 1 shl 3
-  KBLed* = 1 shl 4
-  KBLedMode* = 1 shl 5
-  KBKey* = 1 shl 6
-  KBAutoRepeatMode* = 1 shl 7
-  MappingSuccess* = 0
-  MappingBusy* = 1
-  MappingFailed* = 2
-  MappingModifier* = 0
-  MappingKeyboard* = 1
-  MappingPointer* = 2
-  DontPreferBlanking* = 0
-  PreferBlanking* = 1
-  DefaultBlanking* = 2
-  DisableScreenSaver* = 0
-  DisableScreenInterval* = 0
-  DontAllowExposures* = 0
-  AllowExposures* = 1
-  DefaultExposures* = 2
-  ScreenSaverReset* = 0
-  ScreenSaverActive* = 1
-  HostInsert* = 0
-  HostDelete* = 1
-  EnableAccess* = 1
-  DisableAccess* = 0
-  StaticGray* = 0
-  GrayScale* = 1
-  StaticColor* = 2
-  PseudoColor* = 3
-  TrueColor* = 4
-  DirectColor* = 5
-  LSBFirst* = 0
-  MSBFirst* = 1
-
-# implementation
diff --git a/lib/oldwrappers/x11/xatom.nim b/lib/oldwrappers/x11/xatom.nim
deleted file mode 100755
index b2e1dca91..000000000
--- a/lib/oldwrappers/x11/xatom.nim
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# THIS IS A GENERATED FILE
-#
-# Do not change!  Changing this file implies a protocol change!
-#
-
-import  
-  X
-
-const 
-  XA_PRIMARY* = TAtom(1)
-  XA_SECONDARY* = TAtom(2)
-  XA_ARC* = TAtom(3)
-  XA_ATOM* = TAtom(4)
-  XA_BITMAP* = TAtom(5)
-  XA_CARDINAL* = TAtom(6)
-  XA_COLORMAP* = TAtom(7)
-  XA_CURSOR* = TAtom(8)
-  XA_CUT_BUFFER0* = TAtom(9)
-  XA_CUT_BUFFER1* = TAtom(10)
-  XA_CUT_BUFFER2* = TAtom(11)
-  XA_CUT_BUFFER3* = TAtom(12)
-  XA_CUT_BUFFER4* = TAtom(13)
-  XA_CUT_BUFFER5* = TAtom(14)
-  XA_CUT_BUFFER6* = TAtom(15)
-  XA_CUT_BUFFER7* = TAtom(16)
-  XA_DRAWABLE* = TAtom(17)
-  XA_FONT* = TAtom(18)
-  XA_INTEGER* = TAtom(19)
-  XA_PIXMAP* = TAtom(20)
-  XA_POINT* = TAtom(21)
-  XA_RECTANGLE* = TAtom(22)
-  XA_RESOURCE_MANAGER* = TAtom(23)
-  XA_RGB_COLOR_MAP* = TAtom(24)
-  XA_RGB_BEST_MAP* = TAtom(25)
-  XA_RGB_BLUE_MAP* = TAtom(26)
-  XA_RGB_DEFAULT_MAP* = TAtom(27)
-  XA_RGB_GRAY_MAP* = TAtom(28)
-  XA_RGB_GREEN_MAP* = TAtom(29)
-  XA_RGB_RED_MAP* = TAtom(30)
-  XA_STRING* = TAtom(31)
-  XA_VISUALID* = TAtom(32)
-  XA_WINDOW* = TAtom(33)
-  XA_WM_COMMAND* = TAtom(34)
-  XA_WM_HINTS* = TAtom(35)
-  XA_WM_CLIENT_MACHINE* = TAtom(36)
-  XA_WM_ICON_NAME* = TAtom(37)
-  XA_WM_ICON_SIZE* = TAtom(38)
-  XA_WM_NAME* = TAtom(39)
-  XA_WM_NORMAL_HINTS* = TAtom(40)
-  XA_WM_SIZE_HINTS* = TAtom(41)
-  XA_WM_ZOOM_HINTS* = TAtom(42)
-  XA_MIN_SPACE* = TAtom(43)
-  XA_NORM_SPACE* = TAtom(44)
-  XA_MAX_SPACE* = TAtom(45)
-  XA_END_SPACE* = TAtom(46)
-  XA_SUPERSCRIPT_X* = TAtom(47)
-  XA_SUPERSCRIPT_Y* = TAtom(48)
-  XA_SUBSCRIPT_X* = TAtom(49)
-  XA_SUBSCRIPT_Y* = TAtom(50)
-  XA_UNDERLINE_POSITION* = TAtom(51)
-  XA_UNDERLINE_THICKNESS* = TAtom(52)
-  XA_STRIKEOUT_ASCENT* = TAtom(53)
-  XA_STRIKEOUT_DESCENT* = TAtom(54)
-  XA_ITALIC_ANGLE* = TAtom(55)
-  XA_X_HEIGHT* = TAtom(56)
-  XA_QUAD_WIDTH* = TAtom(57)
-  XA_WEIGHT* = TAtom(58)
-  XA_POINT_SIZE* = TAtom(59)
-  XA_RESOLUTION* = TAtom(60)
-  XA_COPYRIGHT* = TAtom(61)
-  XA_NOTICE* = TAtom(62)
-  XA_FONT_NAME* = TAtom(63)
-  XA_FAMILY_NAME* = TAtom(64)
-  XA_FULL_NAME* = TAtom(65)
-  XA_CAP_HEIGHT* = TAtom(66)
-  XA_WM_CLASS* = TAtom(67)
-  XA_WM_TRANSIENT_FOR* = TAtom(68)
-  XA_LAST_PREDEFINED* = TAtom(68)
-
-# implementation
diff --git a/lib/oldwrappers/x11/xcms.nim b/lib/oldwrappers/x11/xcms.nim
deleted file mode 100755
index 57aad6ae0..000000000
--- a/lib/oldwrappers/x11/xcms.nim
+++ /dev/null
@@ -1,396 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "X11" 
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xcms.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xcms.h
-#
-
-const 
-  XcmsFailure* = 0
-  XcmsSuccess* = 1
-  XcmsSuccessWithCompression* = 2
-
-type 
-  PXcmsColorFormat* = ptr TXcmsColorFormat
-  TXcmsColorFormat* = int32
-
-proc XcmsUndefinedFormat*(): TXcmsColorFormat
-proc XcmsCIEXYZFormat*(): TXcmsColorFormat
-proc XcmsCIEuvYFormat*(): TXcmsColorFormat
-proc XcmsCIExyYFormat*(): TXcmsColorFormat
-proc XcmsCIELabFormat*(): TXcmsColorFormat
-proc XcmsCIELuvFormat*(): TXcmsColorFormat
-proc XcmsTekHVCFormat*(): TXcmsColorFormat
-proc XcmsRGBFormat*(): TXcmsColorFormat
-proc XcmsRGBiFormat*(): TXcmsColorFormat
-const 
-  XcmsInitNone* = 0x00000000
-  XcmsInitSuccess* = 0x00000001
-  XcmsInitFailure* = 0x000000FF
-
-when defined(MACROS): 
-  proc DisplayOfCCC*(ccc: int32): int32
-  proc ScreenNumberOfCCC*(ccc: int32): int32
-  proc VisualOfCCC*(ccc: int32): int32
-  proc ClientWhitePointOfCCC*(ccc: int32): int32
-  proc ScreenWhitePointOfCCC*(ccc: int32): int32
-  proc FunctionSetOfCCC*(ccc: int32): int32
-type 
-  PXcmsFloat* = ptr TXcmsFloat
-  TXcmsFloat* = float64
-  PXcmsRGB* = ptr TXcmsRGB
-  TXcmsRGB*{.final.} = object 
-    red*: int16
-    green*: int16
-    blue*: int16
-
-  PXcmsRGBi* = ptr TXcmsRGBi
-  TXcmsRGBi*{.final.} = object 
-    red*: TXcmsFloat
-    green*: TXcmsFloat
-    blue*: TXcmsFloat
-
-  PXcmsCIEXYZ* = ptr TXcmsCIEXYZ
-  TXcmsCIEXYZ*{.final.} = object 
-    X*: TXcmsFloat
-    Y*: TXcmsFloat
-    Z*: TXcmsFloat
-
-  PXcmsCIEuvY* = ptr TXcmsCIEuvY
-  TXcmsCIEuvY*{.final.} = object 
-    u_prime*: TXcmsFloat
-    v_prime*: TXcmsFloat
-    Y*: TXcmsFloat
-
-  PXcmsCIExyY* = ptr TXcmsCIExyY
-  TXcmsCIExyY*{.final.} = object 
-    x*: TXcmsFloat
-    y*: TXcmsFloat
-    theY*: TXcmsFloat
-
-  PXcmsCIELab* = ptr TXcmsCIELab
-  TXcmsCIELab*{.final.} = object 
-    L_star*: TXcmsFloat
-    a_star*: TXcmsFloat
-    b_star*: TXcmsFloat
-
-  PXcmsCIELuv* = ptr TXcmsCIELuv
-  TXcmsCIELuv*{.final.} = object 
-    L_star*: TXcmsFloat
-    u_star*: TXcmsFloat
-    v_star*: TXcmsFloat
-
-  PXcmsTekHVC* = ptr TXcmsTekHVC
-  TXcmsTekHVC*{.final.} = object 
-    H*: TXcmsFloat
-    V*: TXcmsFloat
-    C*: TXcmsFloat
-
-  PXcmsPad* = ptr TXcmsPad
-  TXcmsPad*{.final.} = object 
-    pad0*: TXcmsFloat
-    pad1*: TXcmsFloat
-    pad2*: TXcmsFloat
-    pad3*: TXcmsFloat
-
-  PXcmsColor* = ptr TXcmsColor
-  TXcmsColor*{.final.} = object  # spec : record
-                                 #            case longint of
-                                 #               0 : ( RGB : TXcmsRGB );
-                                 #               1 : ( RGBi : TXcmsRGBi );
-                                 #               2 : ( CIEXYZ : TXcmsCIEXYZ );
-                                 #               3 : ( CIEuvY : TXcmsCIEuvY );
-                                 #               4 : ( CIExyY : TXcmsCIExyY );
-                                 #               5 : ( CIELab : TXcmsCIELab );
-                                 #               6 : ( CIELuv : TXcmsCIELuv );
-                                 #               7 : ( TekHVC : TXcmsTekHVC );
-                                 #               8 : ( Pad : TXcmsPad ); 
-                                 #            end; 
-    pad*: TXcmsPad
-    pixel*: int32
-    format*: TXcmsColorFormat
-
-  PXcmsPerScrnInfo* = ptr TXcmsPerScrnInfo
-  TXcmsPerScrnInfo*{.final.} = object 
-    screenWhitePt*: TXcmsColor
-    functionSet*: TXPointer
-    screenData*: TXPointer
-    state*: int8
-    pad*: array[0..2, char]
-
-  PXcmsCCC* = ptr TXcmsCCC
-  TXcmsCompressionProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, 
-                                para3: int32, para4: int32, para5: PBool): TStatus{.
-      cdecl.}
-  TXcmsWhiteAdjustProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, 
-                                para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-      cdecl.}
-  TXcmsCCC*{.final.} = object 
-    dpy*: PDisplay
-    screenNumber*: int32
-    visual*: PVisual
-    clientWhitePt*: TXcmsColor
-    gamutCompProc*: TXcmsCompressionProc
-    gamutCompClientData*: TXPointer
-    whitePtAdjProc*: TXcmsWhiteAdjustProc
-    whitePtAdjClientData*: TXPointer
-    pPerScrnInfo*: PXcmsPerScrnInfo
-
-  TXcmsCCCRec* = TXcmsCCC
-  PXcmsCCCRec* = ptr TXcmsCCCRec
-  TXcmsScreenInitProc* = proc (para1: PDisplay, para2: int32, 
-                               para3: PXcmsPerScrnInfo): TStatus{.cdecl.}
-  TXcmsScreenFreeProc* = proc (para1: TXPointer){.cdecl.}
-  TXcmsConversionProc* = proc (){.cdecl.}
-  PXcmsFuncListPtr* = ptr TXcmsFuncListPtr
-  TXcmsFuncListPtr* = TXcmsConversionProc
-  TXcmsParseStringProc* = proc (para1: cstring, para2: PXcmsColor): int32{.cdecl.}
-  PXcmsColorSpace* = ptr TXcmsColorSpace
-  TXcmsColorSpace*{.final.} = object 
-    prefix*: cstring
-    id*: TXcmsColorFormat
-    parseString*: TXcmsParseStringProc
-    to_CIEXYZ*: TXcmsFuncListPtr
-    from_CIEXYZ*: TXcmsFuncListPtr
-    inverse_flag*: int32
-
-  PXcmsFunctionSet* = ptr TXcmsFunctionSet
-  TXcmsFunctionSet*{.final.} = object  # error
-                                       #extern Status XcmsAddColorSpace (
-                                       #in declaration at line 323 
-    DDColorSpaces*: ptr PXcmsColorSpace
-    screenInitProc*: TXcmsScreenInitProc
-    screenFreeProc*: TXcmsScreenFreeProc
-
-
-proc XcmsAddFunctionSet*(para1: PXcmsFunctionSet): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsAllocColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                     para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                          para4: PXcmsColor, para5: PXcmsColor, 
-                          para6: TXcmsColorFormat): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCCCOfColormap*(para1: PDisplay, para2: TColormap): TXcmsCCC{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipLab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELabQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIELabWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvClipLuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvClipuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIELab*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIExyY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToCIELuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToTekHVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIExyYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsClientWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsConvertColors*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: TXcmsColorFormat, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCreateCCC*(para1: PDisplay, para2: int32, para3: PVisual, 
-                    para4: PXcmsColor, para5: TXcmsCompressionProc, 
-                    para6: TXPointer, para7: TXcmsWhiteAdjustProc, 
-                    para8: TXPointer): TXcmsCCC{.cdecl, dynlib: libX11, importc.}
-proc XcmsDefaultCCC*(para1: PDisplay, para2: int32): TXcmsCCC{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsDisplayOfCCC*(para1: TXcmsCCC): PDisplay{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsFormatOfPrefix*(para1: cstring): TXcmsColorFormat{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsFreeCCC*(para1: TXcmsCCC){.cdecl, dynlib: libX11, importc.}
-proc XcmsLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                      para4: PXcmsColor, para5: PXcmsColor, 
-                      para6: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsPrefixOfFormat*(para1: TXcmsColorFormat): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsQueryBlack*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryBlue*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                     para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsQueryColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                      para4: int32, para5: TXcmsColorFormat): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsQueryGreen*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryRed*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryWhite*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsRGBiToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsRGBiToRGB*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                    para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsRGBToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                    para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsScreenNumberOfCCC*(para1: TXcmsCCC): int32{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsScreenWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetCCCOfColormap*(para1: PDisplay, para2: TColormap, para3: TXcmsCCC): TXcmsCCC{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsSetCompressionProc*(para1: TXcmsCCC, para2: TXcmsCompressionProc, 
-                             para3: TXPointer): TXcmsCompressionProc{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetWhiteAdjustProc*(para1: TXcmsCCC, para2: TXcmsWhiteAdjustProc, 
-                             para3: TXPointer): TXcmsWhiteAdjustProc{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetWhitePoint*(para1: TXcmsCCC, para2: PXcmsColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsStoreColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsStoreColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipV*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCQueryMaxV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCQueryMaxVC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMaxVSamples*(para1: TXcmsCCC, para2: TXcmsFloat, 
-                                 para3: PXcmsColor, para4: int32): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMinV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsVisualOfCCC*(para1: TXcmsCCC): PVisual{.cdecl, dynlib: libX11, importc.}
-# implementation
-
-proc XcmsUndefinedFormat(): TXcmsColorFormat = 
-  result = 0x00000000'i32
-
-proc XcmsCIEXYZFormat(): TXcmsColorFormat = 
-  result = 0x00000001'i32
-
-proc XcmsCIEuvYFormat(): TXcmsColorFormat = 
-  result = 0x00000002'i32
-
-proc XcmsCIExyYFormat(): TXcmsColorFormat = 
-  result = 0x00000003'i32
-
-proc XcmsCIELabFormat(): TXcmsColorFormat = 
-  result = 0x00000004'i32
-
-proc XcmsCIELuvFormat(): TXcmsColorFormat = 
-  result = 0x00000005'i32
-
-proc XcmsTekHVCFormat(): TXcmsColorFormat = 
-  result = 0x00000006'i32
-
-proc XcmsRGBFormat(): TXcmsColorFormat = 
-  result = 0x80000000'i32
-
-proc XcmsRGBiFormat(): TXcmsColorFormat = 
-  result = 0x80000001'i32
-
-when defined(MACROS): 
-  proc DisplayOfCCC(ccc: int32): int32 = 
-    result = ccc.dpy
-
-  proc ScreenNumberOfCCC(ccc: int32): int32 = 
-    result = ccc.screenNumber
-
-  proc VisualOfCCC(ccc: int32): int32 = 
-    result = ccc.visual
-
-  proc ClientWhitePointOfCCC(ccc: int32): int32 = 
-    result = addr(ccc.clientWhitePt)
-
-  proc ScreenWhitePointOfCCC(ccc: int32): int32 = 
-    result = addr(ccc.pPerScrnInfo.screenWhitePt)
-
-  proc FunctionSetOfCCC(ccc: int32): int32 = 
-    result = ccc.pPerScrnInfo.functionSet
diff --git a/lib/oldwrappers/x11/xf86dga.nim b/lib/oldwrappers/x11/xf86dga.nim
deleted file mode 100755
index 376f11861..000000000
--- a/lib/oldwrappers/x11/xf86dga.nim
+++ /dev/null
@@ -1,235 +0,0 @@
-#
-#   Copyright (c) 1999  XFree86 Inc
-#
-# $XFree86: xc/include/extensions/xf86dga.h,v 3.20 1999/10/13 04:20:48 dawes Exp $ 
-
-import 
-  x, xlib
-
-const 
-  libXxf86dga* = "libXxf86dga.so"
-
-#type 
-#  cfloat* = float32
-
-# $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $ 
-#
-#
-#Copyright (c) 1995  Jon Tombs
-#Copyright (c) 1995  XFree86 Inc
-#
-#
-#************************************************************************
-#
-#   THIS IS THE OLD DGA API AND IS OBSOLETE.  PLEASE DO NOT USE IT ANYMORE
-#
-#************************************************************************
-
-type 
-  PPcchar* = ptr ptr cstring
-
-const 
-  X_XF86DGAQueryVersion* = 0
-  X_XF86DGAGetVideoLL* = 1
-  X_XF86DGADirectVideo* = 2
-  X_XF86DGAGetViewPortSize* = 3
-  X_XF86DGASetViewPort* = 4
-  X_XF86DGAGetVidPage* = 5
-  X_XF86DGASetVidPage* = 6
-  X_XF86DGAInstallColormap* = 7
-  X_XF86DGAQueryDirectVideo* = 8
-  X_XF86DGAViewPortChanged* = 9
-  XF86DGADirectPresent* = 0x00000001
-  XF86DGADirectGraphics* = 0x00000002
-  XF86DGADirectMouse* = 0x00000004
-  XF86DGADirectKeyb* = 0x00000008
-  XF86DGAHasColormap* = 0x00000100
-  XF86DGADirectColormap* = 0x00000200
-
-proc XF86DGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, 
-                          minorVersion: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XF86DGAQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVideoLL*(dpy: PDisplay, screen: cint, base_addr: Pcint, 
-                        width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVideo*(dpy: PDisplay, screen: cint, base_addr: PPcchar, 
-                      width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGADirectVideo*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGADirectVideoLL*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetViewPortSize*(dpy: PDisplay, screen: cint, width: Pcint, 
-                             height: Pcint): TStatus{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XF86DGASetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVidPage*(dpy: PDisplay, screen: cint, vid_page: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGASetVidPage*(dpy: PDisplay, screen: cint, vid_page: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAInstallColormap*(dpy: PDisplay, screen: cint, Colormap: TColormap): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAForkApp*(screen: cint): cint{.CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAQueryDirectVideo*(dpy: PDisplay, screen: cint, flags: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAViewPortChanged*(dpy: PDisplay, screen: cint, n: cint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-const 
-  X_XDGAQueryVersion* = 0     # 1 through 9 are in xf86dga1.pp 
-                              # 10 and 11 are reserved to avoid conflicts with rogue DGA extensions 
-  X_XDGAQueryModes* = 12
-  X_XDGASetMode* = 13
-  X_XDGASetViewport* = 14
-  X_XDGAInstallColormap* = 15
-  X_XDGASelectInput* = 16
-  X_XDGAFillRectangle* = 17
-  X_XDGACopyArea* = 18
-  X_XDGACopyTransparentArea* = 19
-  X_XDGAGetViewportStatus* = 20
-  X_XDGASync* = 21
-  X_XDGAOpenFramebuffer* = 22
-  X_XDGACloseFramebuffer* = 23
-  X_XDGASetClientVersion* = 24
-  X_XDGAChangePixmapMode* = 25
-  X_XDGACreateColormap* = 26
-  XDGAConcurrentAccess* = 0x00000001
-  XDGASolidFillRect* = 0x00000002
-  XDGABlitRect* = 0x00000004
-  XDGABlitTransRect* = 0x00000008
-  XDGAPixmap* = 0x00000010
-  XDGAInterlaced* = 0x00010000
-  XDGADoublescan* = 0x00020000
-  XDGAFlipImmediate* = 0x00000001
-  XDGAFlipRetrace* = 0x00000002
-  XDGANeedRoot* = 0x00000001
-  XF86DGANumberEvents* = 7
-  XDGAPixmapModeLarge* = 0
-  XDGAPixmapModeSmall* = 1
-  XF86DGAClientNotLocal* = 0
-  XF86DGANoDirectVideoMode* = 1
-  XF86DGAScreenNotActive* = 2
-  XF86DGADirectNotActivated* = 3
-  XF86DGAOperationNotSupported* = 4
-  XF86DGANumberErrors* = (XF86DGAOperationNotSupported + 1)
-
-type 
-  PXDGAMode* = ptr TXDGAMode
-  TXDGAMode*{.final.} = object 
-    num*: cint                # A unique identifier for the mode (num > 0) 
-    name*: cstring            # name of mode given in the XF86Config 
-    verticalRefresh*: cfloat
-    flags*: cint              # DGA_CONCURRENT_ACCESS, etc... 
-    imageWidth*: cint         # linear accessible portion (pixels) 
-    imageHeight*: cint
-    pixmapWidth*: cint        # Xlib accessible portion (pixels) 
-    pixmapHeight*: cint       # both fields ignored if no concurrent access 
-    bytesPerScanline*: cint
-    byteOrder*: cint          # MSBFirst, LSBFirst 
-    depth*: cint
-    bitsPerPixel*: cint
-    redMask*: culong
-    greenMask*: culong
-    blueMask*: culong
-    visualClass*: cshort
-    viewportWidth*: cint
-    viewportHeight*: cint
-    xViewportStep*: cint      # viewport position granularity 
-    yViewportStep*: cint
-    maxViewportX*: cint       # max viewport origin 
-    maxViewportY*: cint
-    viewportFlags*: cint      # types of page flipping possible 
-    reserved1*: cint
-    reserved2*: cint
-
-  PXDGADevice* = ptr TXDGADevice
-  TXDGADevice*{.final.} = object 
-    mode*: TXDGAMode
-    data*: Pcuchar
-    pixmap*: TPixmap
-
-  PXDGAButtonEvent* = ptr TXDGAButtonEvent
-  TXDGAButtonEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    button*: cuint
-
-  PXDGAKeyEvent* = ptr TXDGAKeyEvent
-  TXDGAKeyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    keycode*: cuint
-
-  PXDGAMotionEvent* = ptr TXDGAMotionEvent
-  TXDGAMotionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    dx*: cint
-    dy*: cint
-
-  PXDGAEvent* = ptr TXDGAEvent
-  TXDGAEvent*{.final.} = object 
-    pad*: array[0..23, clong] # sorry you have to cast if you want access
-                              #Case LongInt Of
-                              #      0 : (_type : cint);
-                              #      1 : (xbutton : TXDGAButtonEvent);
-                              #      2 : (xkey : TXDGAKeyEvent);
-                              #      3 : (xmotion : TXDGAMotionEvent);
-                              #      4 : (pad : Array[0..23] Of clong);
-  
-
-proc XDGAQueryExtension*(dpy: PDisplay, eventBase: Pcint, erroBase: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, minorVersion: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAQueryModes*(dpy: PDisplay, screen: cint, num: Pcint): PXDGAMode{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASetMode*(dpy: PDisplay, screen: cint, mode: cint): PXDGADevice{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAOpenFramebuffer*(dpy: PDisplay, screen: cint): TBool{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACloseFramebuffer*(dpy: PDisplay, screen: cint){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASetViewport*(dpy: PDisplay, screen: cint, x: cint, y: cint, flags: cint){.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAInstallColormap*(dpy: PDisplay, screen: cint, cmap: TColormap){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACreateColormap*(dpy: PDisplay, screen: cint, device: PXDGADevice, 
-                         alloc: cint): TColormap{.CDecl, dynlib: libXxf86dga, 
-    importc.}
-proc XDGASelectInput*(dpy: PDisplay, screen: cint, event_mask: clong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAFillRectangle*(dpy: PDisplay, screen: cint, x: cint, y: cint, 
-                        width: cuint, height: cuint, color: culong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACopyArea*(dpy: PDisplay, screen: cint, srcx: cint, srcy: cint, 
-                   width: cuint, height: cuint, dstx: cint, dsty: cint){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACopyTransparentArea*(dpy: PDisplay, screen: cint, srcx: cint, 
-                              srcy: cint, width: cuint, height: cuint, 
-                              dstx: cint, dsty: cint, key: culong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAGetViewportStatus*(dpy: PDisplay, screen: cint): cint{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASync*(dpy: PDisplay, screen: cint){.CDecl, dynlib: libXxf86dga, importc.}
-proc XDGASetClientVersion*(dpy: PDisplay): TBool{.CDecl, dynlib: libXxf86dga, 
-    importc.}
-proc XDGAChangePixmapMode*(dpy: PDisplay, screen: cint, x: Pcint, y: Pcint, 
-                           mode: cint){.CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAKeyEventToXKeyEvent*(dk: PXDGAKeyEvent, xk: PXKeyEvent){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-# implementation
diff --git a/lib/oldwrappers/x11/xf86vmode.nim b/lib/oldwrappers/x11/xf86vmode.nim
deleted file mode 100755
index 18a922cab..000000000
--- a/lib/oldwrappers/x11/xf86vmode.nim
+++ /dev/null
@@ -1,229 +0,0 @@
-# $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $ 
-#
-#
-#Copyright 1995  Kaleb S. KEITHLEY
-#
-#Permission is hereby granted, free of charge, to any person obtaining
-#a copy of this software and associated documentation files (the
-#"Software"), to deal in the Software without restriction, including
-#without limitation the rights to use, copy, modify, merge, publish,
-#distribute, sublicense, and/or sell copies of the Software, and to
-#permit persons to whom the Software is furnished to do so, subject to
-#the following conditions:
-#
-#The above copyright notice and this permission notice shall be
-#included in all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES 
-#OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-#OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of Kaleb S. KEITHLEY 
-#shall not be used in advertising or otherwise to promote the sale, use 
-#or other dealings in this Software without prior written authorization
-#from Kaleb S. KEITHLEY
-#
-#
-# $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $ 
-# THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION 
-
-import 
-  x, xlib
-
-const 
-  libXxf86vm* = "libXxf86vm.so"
-
-type 
-  PINT32* = ptr int32
-
-const 
-  X_XF86VidModeQueryVersion* = 0
-  X_XF86VidModeGetModeLine* = 1
-  X_XF86VidModeModModeLine* = 2
-  X_XF86VidModeSwitchMode* = 3
-  X_XF86VidModeGetMonitor* = 4
-  X_XF86VidModeLockModeSwitch* = 5
-  X_XF86VidModeGetAllModeLines* = 6
-  X_XF86VidModeAddModeLine* = 7
-  X_XF86VidModeDeleteModeLine* = 8
-  X_XF86VidModeValidateModeLine* = 9
-  X_XF86VidModeSwitchToMode* = 10
-  X_XF86VidModeGetViewPort* = 11
-  X_XF86VidModeSetViewPort* = 12 # new for version 2.x of this extension 
-  X_XF86VidModeGetDotClocks* = 13
-  X_XF86VidModeSetClientVersion* = 14
-  X_XF86VidModeSetGamma* = 15
-  X_XF86VidModeGetGamma* = 16
-  X_XF86VidModeGetGammaRamp* = 17
-  X_XF86VidModeSetGammaRamp* = 18
-  X_XF86VidModeGetGammaRampSize* = 19
-  X_XF86VidModeGetPermissions* = 20
-  CLKFLAG_PROGRAMABLE* = 1
-
-when defined(XF86VIDMODE_EVENTS): 
-  const 
-    XF86VidModeNotify* = 0
-    XF86VidModeNumberEvents* = (XF86VidModeNotify + 1)
-    XF86VidModeNotifyMask* = 0x00000001
-    XF86VidModeNonEvent* = 0
-    XF86VidModeModeChange* = 1
-else: 
-  const 
-    XF86VidModeNumberEvents* = 0
-const 
-  XF86VidModeBadClock* = 0
-  XF86VidModeBadHTimings* = 1
-  XF86VidModeBadVTimings* = 2
-  XF86VidModeModeUnsuitable* = 3
-  XF86VidModeExtensionDisabled* = 4
-  XF86VidModeClientNotLocal* = 5
-  XF86VidModeZoomLocked* = 6
-  XF86VidModeNumberErrors* = (XF86VidModeZoomLocked + 1)
-  XF86VM_READ_PERMISSION* = 1
-  XF86VM_WRITE_PERMISSION* = 2
-
-type 
-  PXF86VidModeModeLine* = ptr TXF86VidModeModeLine
-  TXF86VidModeModeLine*{.final.} = object 
-    hdisplay*: cushort
-    hsyncstart*: cushort
-    hsyncend*: cushort
-    htotal*: cushort
-    hskew*: cushort
-    vdisplay*: cushort
-    vsyncstart*: cushort
-    vsyncend*: cushort
-    vtotal*: cushort
-    flags*: cuint
-    privsize*: cint
-    c_private*: PINT32
-
-  PPPXF86VidModeModeInfo* = ptr PPXF86VidModeModeInfo
-  PPXF86VidModeModeInfo* = ptr PXF86VidModeModeInfo
-  PXF86VidModeModeInfo* = ptr TXF86VidModeModeInfo
-  TXF86VidModeModeInfo*{.final.} = object 
-    dotclock*: cuint
-    hdisplay*: cushort
-    hsyncstart*: cushort
-    hsyncend*: cushort
-    htotal*: cushort
-    hskew*: cushort
-    vdisplay*: cushort
-    vsyncstart*: cushort
-    vsyncend*: cushort
-    vtotal*: cushort
-    flags*: cuint
-    privsize*: cint
-    c_private*: PINT32
-
-  PXF86VidModeSyncRange* = ptr TXF86VidModeSyncRange
-  TXF86VidModeSyncRange*{.final.} = object 
-    hi*: cfloat
-    lo*: cfloat
-
-  PXF86VidModeMonitor* = ptr TXF86VidModeMonitor
-  TXF86VidModeMonitor*{.final.} = object 
-    vendor*: cstring
-    model*: cstring
-    EMPTY*: cfloat
-    nhsync*: cuchar
-    hsync*: PXF86VidModeSyncRange
-    nvsync*: cuchar
-    vsync*: PXF86VidModeSyncRange
-
-  PXF86VidModeNotifyEvent* = ptr TXF86VidModeNotifyEvent
-  TXF86VidModeNotifyEvent*{.final.} = object 
-    theType*: cint            # of event 
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent req 
-    display*: PDisplay        # Display the event was read from 
-    root*: TWindow            # root window of event screen 
-    state*: cint              # What happened 
-    kind*: cint               # What happened 
-    forced*: TBool            # extents of new region 
-    time*: TTime              # event timestamp 
-  
-  PXF86VidModeGamma* = ptr TXF86VidModeGamma
-  TXF86VidModeGamma*{.final.} = object 
-    red*: cfloat              # Red Gamma value 
-    green*: cfloat            # Green Gamma value 
-    blue*: cfloat             # Blue Gamma value 
-  
-
-when defined(MACROS): 
-  proc XF86VidModeSelectNextMode*(disp: PDisplay, scr: cint): TBool
-  proc XF86VidModeSelectPrevMode*(disp: PDisplay, scr: cint): TBool
-proc XF86VidModeQueryVersion*(dpy: PDisplay, majorVersion: Pcint, 
-                              minorVersion: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeQueryExtension*(dpy: PDisplay, event_base: Pcint, 
-                                error_base: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetClientVersion*(dpy: PDisplay): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetModeLine*(dpy: PDisplay, screen: cint, dotclock: Pcint, 
-                             modeline: PXF86VidModeModeLine): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetAllModeLines*(dpy: PDisplay, screen: cint, modecount: Pcint, 
-                                 modelinesPtr: PPPXF86VidModeModeInfo): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeAddModeLine*(dpy: PDisplay, screen: cint, 
-                             new_modeline: PXF86VidModeModeInfo, 
-                             after_modeline: PXF86VidModeModeInfo): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeDeleteModeLine*(dpy: PDisplay, screen: cint, 
-                                modeline: PXF86VidModeModeInfo): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeModModeLine*(dpy: PDisplay, screen: cint, 
-                             modeline: PXF86VidModeModeLine): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeValidateModeLine*(dpy: PDisplay, screen: cint, 
-                                  modeline: PXF86VidModeModeInfo): TStatus{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSwitchMode*(dpy: PDisplay, screen: cint, zoom: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSwitchToMode*(dpy: PDisplay, screen: cint, 
-                              modeline: PXF86VidModeModeInfo): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeLockModeSwitch*(dpy: PDisplay, screen: cint, lock: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetMonitor*(dpy: PDisplay, screen: cint, 
-                            monitor: PXF86VidModeMonitor): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetViewPort*(dpy: PDisplay, screen: cint, x_return: Pcint, 
-                             y_return: Pcint): TBool{.CDecl, dynlib: libXxf86vm, 
-    importc.}
-proc XF86VidModeSetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetDotClocks*(dpy: PDisplay, screen: cint, flags_return: Pcint, 
-                              number_of_clocks_return: Pcint, 
-                              max_dot_clock_return: Pcint, clocks_return: PPcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, 
-                              red_array: Pcushort, green_array: Pcushort, 
-                              blue_array: Pcushort): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, 
-                              red_array: Pcushort, green_array: Pcushort, 
-                              blue_array: Pcushort): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGammaRampSize*(dpy: PDisplay, screen: cint, size: Pcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetPermissions*(dpy: PDisplay, screen: cint, permissions: Pcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-# implementation
-
-when defined(MACROS): 
-  proc XF86VidModeSelectNextMode(disp: PDisplay, scr: cint): TBool = 
-    XF86VidModeSelectNextMode = XF86VidModeSwitchMode(disp, scr, 1)
-
-  proc XF86VidModeSelectPrevMode(disp: PDisplay, scr: cint): TBool = 
-    XF86VidModeSelectPrevMode = XF86VidModeSwitchMode(disp, scr, - 1)
diff --git a/lib/oldwrappers/x11/xi.nim b/lib/oldwrappers/x11/xi.nim
deleted file mode 100755
index d1b9f7846..000000000
--- a/lib/oldwrappers/x11/xi.nim
+++ /dev/null
@@ -1,307 +0,0 @@
-#
-# $Xorg: XI.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $
-#
-#************************************************************
-#
-#Copyright 1989, 1998  The Open Group
-#
-#Permission to use, copy, modify, distribute, and sell this software and its
-#documentation for any purpose is hereby granted without fee, provided that
-#the above copyright notice appear in all copies and that both that
-#copyright notice and this permission notice appear in supporting
-#documentation.
-#
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-#OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-#AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of The Open Group shall not be
-#used in advertising or otherwise to promote the sale, use or other dealings
-#in this Software without prior written authorization from The Open Group.
-#
-#Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its
-#documentation for any purpose and without fee is hereby granted,
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in
-#supporting documentation, and that the name of Hewlett-Packard not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.
-#
-#HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#********************************************************/
-# $XFree86: xc/include/extensions/XI.h,v 1.5 2001/12/14 19:53:28 dawes Exp $
-#
-# Definitions used by the server, library and client
-#
-#        Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Histroy:
-#        2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and chnaged it to
-#                     "reocrd" only.
-#        2004/10/07 - Removed the "uses X;" line. The unit does not need it.
-#        2004/10/03 - Conversion from C header to Pascal unit.
-#
-
-const 
-  sz_xGetExtensionVersionReq* = 8
-  sz_xGetExtensionVersionReply* = 32
-  sz_xListInputDevicesReq* = 4
-  sz_xListInputDevicesReply* = 32
-  sz_xOpenDeviceReq* = 8
-  sz_xOpenDeviceReply* = 32
-  sz_xCloseDeviceReq* = 8
-  sz_xSetDeviceModeReq* = 8
-  sz_xSetDeviceModeReply* = 32
-  sz_xSelectExtensionEventReq* = 12
-  sz_xGetSelectedExtensionEventsReq* = 8
-  sz_xGetSelectedExtensionEventsReply* = 32
-  sz_xChangeDeviceDontPropagateListReq* = 12
-  sz_xGetDeviceDontPropagateListReq* = 8
-  sz_xGetDeviceDontPropagateListReply* = 32
-  sz_xGetDeviceMotionEventsReq* = 16
-  sz_xGetDeviceMotionEventsReply* = 32
-  sz_xChangeKeyboardDeviceReq* = 8
-  sz_xChangeKeyboardDeviceReply* = 32
-  sz_xChangePointerDeviceReq* = 8
-  sz_xChangePointerDeviceReply* = 32
-  sz_xGrabDeviceReq* = 20
-  sz_xGrabDeviceReply* = 32
-  sz_xUngrabDeviceReq* = 12
-  sz_xGrabDeviceKeyReq* = 20
-  sz_xGrabDeviceKeyReply* = 32
-  sz_xUngrabDeviceKeyReq* = 16
-  sz_xGrabDeviceButtonReq* = 20
-  sz_xGrabDeviceButtonReply* = 32
-  sz_xUngrabDeviceButtonReq* = 16
-  sz_xAllowDeviceEventsReq* = 12
-  sz_xGetDeviceFocusReq* = 8
-  sz_xGetDeviceFocusReply* = 32
-  sz_xSetDeviceFocusReq* = 16
-  sz_xGetFeedbackControlReq* = 8
-  sz_xGetFeedbackControlReply* = 32
-  sz_xChangeFeedbackControlReq* = 12
-  sz_xGetDeviceKeyMappingReq* = 8
-  sz_xGetDeviceKeyMappingReply* = 32
-  sz_xChangeDeviceKeyMappingReq* = 8
-  sz_xGetDeviceModifierMappingReq* = 8
-  sz_xSetDeviceModifierMappingReq* = 8
-  sz_xSetDeviceModifierMappingReply* = 32
-  sz_xGetDeviceButtonMappingReq* = 8
-  sz_xGetDeviceButtonMappingReply* = 32
-  sz_xSetDeviceButtonMappingReq* = 8
-  sz_xSetDeviceButtonMappingReply* = 32
-  sz_xQueryDeviceStateReq* = 8
-  sz_xQueryDeviceStateReply* = 32
-  sz_xSendExtensionEventReq* = 16
-  sz_xDeviceBellReq* = 8
-  sz_xSetDeviceValuatorsReq* = 8
-  sz_xSetDeviceValuatorsReply* = 32
-  sz_xGetDeviceControlReq* = 8
-  sz_xGetDeviceControlReply* = 32
-  sz_xChangeDeviceControlReq* = 8
-  sz_xChangeDeviceControlReply* = 32
-
-const 
-  INAME* = "XInputExtension"
-
-const 
-  XI_KEYBOARD* = "KEYBOARD"
-  XI_MOUSE* = "MOUSE"
-  XI_TABLET* = "TABLET"
-  XI_TOUCHSCREEN* = "TOUCHSCREEN"
-  XI_TOUCHPAD* = "TOUCHPAD"
-  XI_BARCODE* = "BARCODE"
-  XI_BUTTONBOX* = "BUTTONBOX"
-  XI_KNOB_BOX* = "KNOB_BOX"
-  XI_ONE_KNOB* = "ONE_KNOB"
-  XI_NINE_KNOB* = "NINE_KNOB"
-  XI_TRACKBALL* = "TRACKBALL"
-  XI_QUADRATURE* = "QUADRATURE"
-  XI_ID_MODULE* = "ID_MODULE"
-  XI_SPACEBALL* = "SPACEBALL"
-  XI_DATAGLOVE* = "DATAGLOVE"
-  XI_EYETRACKER* = "EYETRACKER"
-  XI_CURSORKEYS* = "CURSORKEYS"
-  XI_FOOTMOUSE* = "FOOTMOUSE"
-
-const 
-  Dont_Check* = 0
-  XInput_Initial_Release* = 1
-  XInput_Add_XDeviceBell* = 2
-  XInput_Add_XSetDeviceValuators* = 3
-  XInput_Add_XChangeDeviceControl* = 4
-
-const 
-  XI_Absent* = 0
-  XI_Present* = 1
-
-const 
-  XI_Initial_Release_Major* = 1
-  XI_Initial_Release_Minor* = 0
-
-const 
-  XI_Add_XDeviceBell_Major* = 1
-  XI_Add_XDeviceBell_Minor* = 1
-
-const 
-  XI_Add_XSetDeviceValuators_Major* = 1
-  XI_Add_XSetDeviceValuators_Minor* = 2
-
-const 
-  XI_Add_XChangeDeviceControl_Major* = 1
-  XI_Add_XChangeDeviceControl_Minor* = 3
-
-const 
-  DEVICE_RESOLUTION* = 1
-
-const 
-  NoSuchExtension* = 1
-
-const 
-  COUNT* = 0
-  CREATE* = 1
-
-const 
-  NewPointer* = 0
-  NewKeyboard* = 1
-
-const 
-  XPOINTER* = 0
-  XKEYBOARD* = 1
-
-const 
-  UseXKeyboard* = 0x000000FF
-
-const 
-  IsXPointer* = 0
-  IsXKeyboard* = 1
-  IsXExtensionDevice* = 2
-
-const 
-  AsyncThisDevice* = 0
-  SyncThisDevice* = 1
-  ReplayThisDevice* = 2
-  AsyncOtherDevices* = 3
-  AsyncAll* = 4
-  SyncAll* = 5
-
-const 
-  FollowKeyboard* = 3
-  RevertToFollowKeyboard* = 3
-
-const 
-  DvAccelNum* = int(1) shl 0
-  DvAccelDenom* = int(1) shl 1
-  DvThreshold* = int(1) shl 2
-
-const 
-  DvKeyClickPercent* = int(1) shl 0
-  DvPercent* = int(1) shl 1
-  DvPitch* = int(1) shl 2
-  DvDuration* = int(1) shl 3
-  DvLed* = int(1) shl 4
-  DvLedMode* = int(1) shl 5
-  DvKey* = int(1) shl 6
-  DvAutoRepeatMode* = 1 shl 7
-
-const 
-  DvString* = int(1) shl 0
-
-const 
-  DvInteger* = int(1) shl 0
-
-const 
-  DeviceMode* = int(1) shl 0
-  Relative* = 0
-  Absolute* = 1               # Merged from Metrolink tree for XINPUT stuff 
-  TS_Raw* = 57
-  TS_Scaled* = 58
-  SendCoreEvents* = 59
-  DontSendCoreEvents* = 60    # End of merged section 
-
-const 
-  ProximityState* = int(1) shl 1
-  InProximity* = int(0) shl 1
-  OutOfProximity* = int(1) shl 1
-
-const 
-  AddToList* = 0
-  DeleteFromList* = 1
-
-const 
-  KeyClass* = 0
-  ButtonClass* = 1
-  ValuatorClass* = 2
-  FeedbackClass* = 3
-  ProximityClass* = 4
-  FocusClass* = 5
-  OtherClass* = 6
-
-const 
-  KbdFeedbackClass* = 0
-  PtrFeedbackClass* = 1
-  StringFeedbackClass* = 2
-  IntegerFeedbackClass* = 3
-  LedFeedbackClass* = 4
-  BellFeedbackClass* = 5
-
-const 
-  devicePointerMotionHint* = 0
-  deviceButton1Motion* = 1
-  deviceButton2Motion* = 2
-  deviceButton3Motion* = 3
-  deviceButton4Motion* = 4
-  deviceButton5Motion* = 5
-  deviceButtonMotion* = 6
-  deviceButtonGrab* = 7
-  deviceOwnerGrabButton* = 8
-  noExtensionEvent* = 9
-
-const 
-  XI_BadDevice* = 0
-  XI_BadEvent* = 1
-  XI_BadMode* = 2
-  XI_DeviceBusy* = 3
-  XI_BadClass* = 4 # Make XEventClass be a CARD32 for 64 bit servers.  Don't affect client
-                   #  definition of XEventClass since that would be a library interface change.
-                   #  See the top of X.h for more _XSERVER64 magic.
-                   #
-
-when defined(XSERVER64): 
-  type 
-    XEventClass* = CARD32
-else: 
-  type 
-    XEventClass* = int32
-#******************************************************************
-# *
-# * Extension version structure.
-# *
-# 
-
-type 
-  PXExtensionVersion* = ptr TXExtensionVersion
-  TXExtensionVersion*{.final.} = object 
-    present*: int16
-    major_version*: int16
-    minor_version*: int16
-
-
-# implementation
diff --git a/lib/oldwrappers/x11/xinerama.nim b/lib/oldwrappers/x11/xinerama.nim
deleted file mode 100755
index 96f5d7da3..000000000
--- a/lib/oldwrappers/x11/xinerama.nim
+++ /dev/null
@@ -1,25 +0,0 @@
-# Converted from X11/Xinerama.h 
-import                        
-  xlib
-
-const
-  xineramaLib = "libXinerama.so"
-
-type 
-  PXineramaScreenInfo* = ptr TXineramaScreenInfo
-  TXineramaScreenInfo*{.final.} = object 
-    screen_number*: cint
-    x_org*: int16
-    y_org*: int16
-    width*: int16
-    height*: int16
-
-
-proc XineramaQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
-    cdecl, dynlib: xineramaLib, importc.}
-proc XineramaQueryVersion*(dpy: PDisplay, major: Pcint, minor: Pcint): TStatus{.
-    cdecl, dynlib: xineramaLib, importc.}
-proc XineramaIsActive*(dpy: PDisplay): TBool{.cdecl, dynlib: xineramaLib, importc.}
-proc XineramaQueryScreens*(dpy: PDisplay, number: Pcint): PXineramaScreenInfo{.
-    cdecl, dynlib: xineramaLib, importc.}
-
diff --git a/lib/oldwrappers/x11/xkb.nim b/lib/oldwrappers/x11/xkb.nim
deleted file mode 100755
index f1b0448a8..000000000
--- a/lib/oldwrappers/x11/xkb.nim
+++ /dev/null
@@ -1,2409 +0,0 @@
-#
-# $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-# $Xorg: XKBstr.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-# $Xorg: XKBgeom.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-#
-#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-#
-#Permission to use, copy, modify, and distribute this
-#software and its documentation for any purpose and without
-#fee is hereby granted, provided that the above copyright
-#notice appear in all copies and that both that copyright
-#notice and this permission notice appear in supporting
-#documentation, and that the name of Silicon Graphics not be
-#used in advertising or publicity pertaining to distribution
-#of the software without specific prior written permission.
-#Silicon Graphics makes no representation about the suitability
-#of this software for any purpose. It is provided "as is"
-#without any express or implied warranty.
-#
-#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-#THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-#********************************************************
-# $XFree86: xc/include/extensions/XKB.h,v 1.5 2002/11/20 04:49:01 dawes Exp $
-# $XFree86: xc/include/extensions/XKBgeom.h,v 3.9 2002/09/18 17:11:40 tsi Exp $
-#
-# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Thanks:
-#         I want to thanks to oliebol for putting up with all of the problems that was found
-#         while translating this code. ;)
-#
-#         I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
-#         wierd questions ;)
-#
-#         Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
-#         understanding some of the problems I had converting this headers and pointing me to resources
-#         that helped translating this headers.
-#
-# Ido
-#
-#History:
-#        2004/10/15           - Fixed a bug of accessing second based records by removing "paced record" and
-#                               chnaged it to "reocrd" only.
-#        2004/10/04 - 06      - Convertion from the c header of XKBgeom.h.
-#        2004/10/03           - Removed the XKBstr_UNIT compiler decleration. Afther the joined files,
-#                                                                                     There is no need for it anymore.
-#                                                                             - There is a need to define (for now) XKBgeom (compiler define) in order
-#                                                                               to use the code of it. At this moment, I did not yet converted it to Pascal.
-#
-#        2004/09/17 - 10/04   - Convertion from the c header of XKBstr.
-#
-#        2004/10/03           - Joined xkbstr.pas into xkb.pas because of the circular calls problems.
-#                             - Added the history of xkbstr.pas above this addition.
-#
-#        2004/09/17           - Fixed a wrong convertion number of XkbPerKeyBitArraySize, insted
-#                               of float, it's now converted into integer (as it should have been).
-#
-#        2004/09/15 - 16      - Convertion from the c header of XKB.h.
-#
-
-import 
-  X, Xlib
-
-proc XkbCharToInt*(v: int8): int16
-proc XkbIntTo2Chars*(i: int16, h, L: var int8)
-proc Xkb2CharsToInt*(h, L: int8): int16
-  #
-  #          Common data structures and access macros
-  #        
-type
-  PWord* = ptr array[0..64_000, int16]
-  PByte* = ptr byte
-  PXkbStatePtr* = ptr TXkbStateRec
-  TXkbStateRec*{.final.} = object 
-    group*: int8
-    locked_group*: int8
-    base_group*: int16
-    latched_group*: int16
-    mods*: int8
-    base_mods*: int8
-    latched_mods*: int8
-    locked_mods*: int8
-    compat_state*: int8
-    grab_mods*: int8
-    compat_grab_mods*: int8
-    lookup_mods*: int8
-    compat_lookup_mods*: int8
-    ptr_buttons*: int16
-
-
-proc XkbModLocks*(s: PXkbStatePtr): int8
-proc XkbStateMods*(s: PXkbStatePtr): int16
-proc XkbGroupLock*(s: PXkbStatePtr): int8
-proc XkbStateGroup*(s: PXkbStatePtr): int16
-proc XkbStateFieldFromRec*(s: PXkbStatePtr): int
-proc XkbGrabStateFromRec*(s: PXkbStatePtr): int
-type 
-  PXkbModsPtr* = ptr TXkbModsRec
-  TXkbModsRec*{.final.} = object 
-    mask*: int8               # effective mods
-    real_mods*: int8
-    vmods*: int16
-
-
-type 
-  PXkbKTMapEntryPtr* = ptr TXkbKTMapEntryRec
-  TXkbKTMapEntryRec*{.final.} = object 
-    active*: bool
-    level*: int8
-    mods*: TXkbModsRec
-
-
-type 
-  PXkbKeyTypePtr* = ptr TXkbKeyTypeRec
-  TXkbKeyTypeRec*{.final.} = object 
-    mods*: TXkbModsRec
-    num_levels*: int8
-    map_count*: int8
-    map*: PXkbKTMapEntryPtr
-    preserve*: PXkbModsPtr
-    name*: TAtom
-    level_names*: TAtom
-
-
-proc XkbNumGroups*(g: int16): int16
-proc XkbOutOfRangeGroupInfo*(g: int16): int16
-proc XkbOutOfRangeGroupAction*(g: int16): int16
-proc XkbOutOfRangeGroupNumber*(g: int16): int16
-proc XkbSetGroupInfo*(g, w, n: int16): int16
-proc XkbSetNumGroups*(g, n: int16): int16
-  #
-  #          Structures and access macros used primarily by the server
-  #        
-type 
-  PXkbBehavior* = ptr TXkbBehavior
-  TXkbBehavior*{.final.} = object 
-    theType*: int8
-    data*: int8
-
-
-type 
-  PXkbModAction* = ptr TXkbModAction
-  TXkbModAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    mask*: int8
-    real_mods*: int8
-    vmods1*: int8
-    vmods2*: int8
-
-
-proc XkbModActionVMods*(a: PXkbModAction): int16
-proc XkbSetModActionVMods*(a: PXkbModAction, v: int8)
-type 
-  PXkbGroupAction* = ptr TXkbGroupAction
-  TXkbGroupAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    group_XXX*: int8
-
-
-proc XkbSAGroup*(a: PXkbGroupAction): int8
-proc XkbSASetGroupProc*(a: PXkbGroupAction, g: int8)
-type 
-  PXkbISOAction* = ptr TXkbISOAction
-  TXkbISOAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    mask*: int8
-    real_mods*: int8
-    group_XXX*: int8
-    affect*: int8
-    vmods1*: int8
-    vmods2*: int8
-
-
-type 
-  PXkbPtrAction* = ptr TXkbPtrAction
-  TXkbPtrAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    high_XXX*: int8
-    low_XXX*: int8
-    high_YYY*: int8
-    low_YYY*: int8
-
-
-proc XkbPtrActionX*(a: PXkbPtrAction): int16
-proc XkbPtrActionY*(a: PXkbPtrAction): int16
-proc XkbSetPtrActionX*(a: PXkbPtrAction, x: int8)
-proc XkbSetPtrActionY*(a: PXkbPtrAction, y: int8)
-type 
-  PXkbPtrBtnAction* = ptr TXkbPtrBtnAction
-  TXkbPtrBtnAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    count*: int8
-    button*: int8
-
-
-type 
-  PXkbPtrDfltAction* = ptr TXkbPtrDfltAction
-  TXkbPtrDfltAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    affect*: int8
-    valueXXX*: int8
-
-
-proc XkbSAPtrDfltValue*(a: PXkbPtrDfltAction): int8
-proc XkbSASetPtrDfltValue*(a: PXkbPtrDfltAction, c: pointer)
-type 
-  PXkbSwitchScreenAction* = ptr TXkbSwitchScreenAction
-  TXkbSwitchScreenAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    screenXXX*: int8
-
-
-proc XkbSAScreen*(a: PXkbSwitchScreenAction): int8
-proc XkbSASetScreen*(a: PXkbSwitchScreenAction, s: pointer)
-type 
-  PXkbCtrlsAction* = ptr TXkbCtrlsAction
-  TXkbCtrlsAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    ctrls3*: int8
-    ctrls2*: int8
-    ctrls1*: int8
-    ctrls0*: int8
-
-
-proc XkbActionSetCtrls*(a: PXkbCtrlsAction, c: int8)
-proc XkbActionCtrls*(a: PXkbCtrlsAction): int16
-type 
-  PXkbMessageAction* = ptr TXkbMessageAction
-  TXkbMessageAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    message*: array[0..5, char]
-
-
-type 
-  PXkbRedirectKeyAction* = ptr TXkbRedirectKeyAction
-  TXkbRedirectKeyAction*{.final.} = object 
-    theType*: int8
-    new_key*: int8
-    mods_mask*: int8
-    mods*: int8
-    vmods_mask0*: int8
-    vmods_mask1*: int8
-    vmods0*: int8
-    vmods1*: int8
-
-
-proc XkbSARedirectVMods*(a: PXkbRedirectKeyAction): int16
-proc XkbSARedirectSetVMods*(a: PXkbRedirectKeyAction, m: int8)
-proc XkbSARedirectVModsMask*(a: PXkbRedirectKeyAction): int16
-proc XkbSARedirectSetVModsMask*(a: PXkbRedirectKeyAction, m: int8)
-type 
-  PXkbDeviceBtnAction* = ptr TXkbDeviceBtnAction
-  TXkbDeviceBtnAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    count*: int8
-    button*: int8
-    device*: int8
-
-
-type 
-  PXkbDeviceValuatorAction* = ptr TXkbDeviceValuatorAction
-  TXkbDeviceValuatorAction*{.final.} = object  #
-                                               #      Macros to classify key actions
-                                               #                
-    theType*: int8
-    device*: int8
-    v1_what*: int8
-    v1_ndx*: int8
-    v1_value*: int8
-    v2_what*: int8
-    v2_ndx*: int8
-    v2_value*: int8
-
-
-const 
-  XkbAnyActionDataSize* = 7
-
-type 
-  PXkbAnyAction* = ptr TXkbAnyAction
-  TXkbAnyAction*{.final.} = object 
-    theType*: int8
-    data*: array[0..XkbAnyActionDataSize - 1, int8]
-
-
-proc XkbIsModAction*(a: PXkbAnyAction): bool
-proc XkbIsGroupAction*(a: PXkbAnyAction): bool
-proc XkbIsPtrAction*(a: PXkbAnyAction): bool
-type 
-  PXkbAction* = ptr TXkbAction
-  TXkbAction*{.final.} = object  #
-                                 #      XKB request codes, used in:
-                                 #      -  xkbReqType field of all requests
-                                 #      -  requestMinor field of some events
-                                 #                
-    any*: TXkbAnyAction
-    mods*: TXkbModAction
-    group*: TXkbGroupAction
-    iso*: TXkbISOAction
-    thePtr*: TXkbPtrAction
-    btn*: TXkbPtrBtnAction
-    dflt*: TXkbPtrDfltAction
-    screen*: TXkbSwitchScreenAction
-    ctrls*: TXkbCtrlsAction
-    msg*: TXkbMessageAction
-    redirect*: TXkbRedirectKeyAction
-    devbtn*: TXkbDeviceBtnAction
-    devval*: TXkbDeviceValuatorAction
-    theType*: int8
-
-
-const 
-  X_kbUseExtension* = 0
-  X_kbSelectEvents* = 1
-  X_kbBell* = 3
-  X_kbGetState* = 4
-  X_kbLatchLockState* = 5
-  X_kbGetControls* = 6
-  X_kbSetControls* = 7
-  X_kbGetMap* = 8
-  X_kbSetMap* = 9
-  X_kbGetCompatMap* = 10
-  X_kbSetCompatMap* = 11
-  X_kbGetIndicatorState* = 12
-  X_kbGetIndicatorMap* = 13
-  X_kbSetIndicatorMap* = 14
-  X_kbGetNamedIndicator* = 15
-  X_kbSetNamedIndicator* = 16
-  X_kbGetNames* = 17
-  X_kbSetNames* = 18
-  X_kbGetGeometry* = 19
-  X_kbSetGeometry* = 20
-  X_kbPerClientFlags* = 21
-  X_kbListComponents* = 22
-  X_kbGetKbdByName* = 23
-  X_kbGetDeviceInfo* = 24
-  X_kbSetDeviceInfo* = 25
-  X_kbSetDebuggingFlags* = 101 #
-                               #      In the X sense, XKB reports only one event.
-                               #      The type field of all XKB events is XkbEventCode
-                               #                
-
-const 
-  XkbEventCode* = 0
-  XkbNumberEvents* = XkbEventCode + 1 #
-                                      #      XKB has a minor event code so it can use one X event code for
-                                      #      multiple purposes.
-                                      #       - reported in the xkbType field of all XKB events.
-                                      #       - XkbSelectEventDetails: Indicates the event for which event details
-                                      #         are being changed
-                                      #                
-
-const 
-  XkbNewKeyboardNotify* = 0
-  XkbMapNotify* = 1
-  XkbStateNotify* = 2
-  XkbControlsNotify* = 3
-  XkbIndicatorStateNotify* = 4
-  XkbIndicatorMapNotify* = 5
-  XkbNamesNotify* = 6
-  XkbCompatMapNotify* = 7
-  XkbBellNotify* = 8
-  XkbActionMessage* = 9
-  XkbAccessXNotify* = 10
-  XkbExtensionDeviceNotify* = 11 #
-                                 #      Event Mask:
-                                 #       - XkbSelectEvents:  Specifies event interest.
-                                 #    
-
-const 
-  XkbNewKeyboardNotifyMask* = int(1) shl 0
-  XkbMapNotifyMask* = int(1) shl 1
-  XkbStateNotifyMask* = int(1) shl 2
-  XkbControlsNotifyMask* = int(1) shl 3
-  XkbIndicatorStateNotifyMask* = int(1) shl 4
-  XkbIndicatorMapNotifyMask* = int(1) shl 5
-  XkbNamesNotifyMask* = int(1) shl 6
-  XkbCompatMapNotifyMask* = int(1) shl 7
-  XkbBellNotifyMask* = int(1) shl 8
-  XkbActionMessageMask* = int(1) shl 9
-  XkbAccessXNotifyMask* = int(1) shl 10
-  XkbExtensionDeviceNotifyMask* = int(1) shl 11
-  XkbAllEventsMask* = 0x00000FFF #
-                                 #      NewKeyboardNotify event details:
-                                 #    
-
-const 
-  XkbNKN_KeycodesMask* = int(1) shl 0
-  XkbNKN_GeometryMask* = int(1) shl 1
-  XkbNKN_DeviceIDMask* = int(1) shl 2
-  XkbAllNewKeyboardEventsMask* = 0x00000007 #
-                                            #      AccessXNotify event types:
-                                            #       - The 'what' field of AccessXNotify events reports the
-                                            #         reason that the event was generated.
-                                            #                
-
-const 
-  XkbAXN_SKPress* = 0
-  XkbAXN_SKAccept* = 1
-  XkbAXN_SKReject* = 2
-  XkbAXN_SKRelease* = 3
-  XkbAXN_BKAccept* = 4
-  XkbAXN_BKReject* = 5
-  XkbAXN_AXKWarning* = 6 #
-                         #      AccessXNotify details:
-                         #      - Used as an event detail mask to limit the conditions under which
-                         #        AccessXNotify events are reported
-                         #                
-
-const 
-  XkbAXN_SKPressMask* = int(1) shl 0
-  XkbAXN_SKAcceptMask* = int(1) shl 1
-  XkbAXN_SKRejectMask* = int(1) shl 2
-  XkbAXN_SKReleaseMask* = int(1) shl 3
-  XkbAXN_BKAcceptMask* = int(1) shl 4
-  XkbAXN_BKRejectMask* = int(1) shl 5
-  XkbAXN_AXKWarningMask* = int(1) shl 6
-  XkbAllAccessXEventsMask* = 0x0000000F #
-                                        #      State detail mask:
-                                        #       - The 'changed' field of StateNotify events reports which of
-                                        #         the keyboard state components have changed.
-                                        #       - Used as an event detail mask to limit the conditions under
-                                        #         which StateNotify events are reported.
-                                        #                
-
-const 
-  XkbModifierStateMask* = int(1) shl 0
-  XkbModifierBaseMask* = int(1) shl 1
-  XkbModifierLatchMask* = int(1) shl 2
-  XkbModifierLockMask* = int(1) shl 3
-  XkbGroupStateMask* = int(1) shl 4
-  XkbGroupBaseMask* = int(1) shl 5
-  XkbGroupLatchMask* = int(1) shl 6
-  XkbGroupLockMask* = int(1) shl 7
-  XkbCompatStateMask* = int(1) shl 8
-  XkbGrabModsMask* = int(1) shl 9
-  XkbCompatGrabModsMask* = int(1) shl 10
-  XkbLookupModsMask* = int(1) shl 11
-  XkbCompatLookupModsMask* = int(1) shl 12
-  XkbPointerButtonMask* = int(1) shl 13
-  XkbAllStateComponentsMask* = 0x00003FFF #
-                                          #      Controls detail masks:
-                                          #       The controls specified in XkbAllControlsMask:
-                                          #       - The 'changed' field of ControlsNotify events reports which of
-                                          #         the keyboard controls have changed.
-                                          #       - The 'changeControls' field of the SetControls request specifies
-                                          #         the controls for which values are to be changed.
-                                          #       - Used as an event detail mask to limit the conditions under
-                                          #         which ControlsNotify events are reported.
-                                          #
-                                          #       The controls specified in the XkbAllBooleanCtrlsMask:
-                                          #       - The 'enabledControls' field of ControlsNotify events reports the
-                                          #         current status of the boolean controls.
-                                          #       - The 'enabledControlsChanges' field of ControlsNotify events reports
-                                          #         any boolean controls that have been turned on or off.
-                                          #       - The 'affectEnabledControls' and 'enabledControls' fields of the
-                                          #         kbSetControls request change the set of enabled controls.
-                                          #       - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of
-                                          #         an XkbControlsRec specify the controls to be changed if the keyboard
-                                          #         times out and the values to which they should be changed.
-                                          #       - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags
-                                          #         request specifies the specify the controls to be reset when the
-                                          #         client exits and the values to which they should be reset.
-                                          #       - The 'ctrls' field of an indicator map specifies the controls
-                                          #         that drive the indicator.
-                                          #       - Specifies the boolean controls affected by the SetControls and
-                                          #         LockControls key actions.
-                                          #                
-
-const 
-  XkbRepeatKeysMask* = int(1) shl 0
-  XkbSlowKeysMask* = int(1) shl 1
-  XkbBounceKeysMask* = int(1) shl 2
-  XkbStickyKeysMask* = int(1) shl 3
-  XkbMouseKeysMask* = int(1) shl 4
-  XkbMouseKeysAccelMask* = int(1) shl 5
-  XkbAccessXKeysMask* = int(1) shl 6
-  XkbAccessXTimeoutMask* = int(1) shl 7
-  XkbAccessXFeedbackMask* = int(1) shl 8
-  XkbAudibleBellMask* = int(1) shl 9
-  XkbOverlay1Mask* = int(1) shl 10
-  XkbOverlay2Mask* = int(1) shl 11
-  XkbIgnoreGroupLockMask* = int(1) shl 12
-  XkbGroupsWrapMask* = int(1) shl 27
-  XkbInternalModsMask* = int(1) shl 28
-  XkbIgnoreLockModsMask* = int(1) shl 29
-  XkbPerKeyRepeatMask* = int(1) shl 30
-  XkbControlsEnabledMask* = int(1) shl 31
-  XkbAccessXOptionsMask* = XkbStickyKeysMask or XkbAccessXFeedbackMask
-  XkbAllBooleanCtrlsMask* = 0x00001FFF
-  XkbAllControlsMask* = 0xF8001FFF #
-                                   #      Compatibility Map Compontents:
-                                   #       - Specifies the components to be allocated in XkbAllocCompatMap.
-                                   #                
-
-const 
-  XkbSymInterpMask* = 1 shl 0
-  XkbGroupCompatMask* = 1 shl 1
-  XkbAllCompatMask* = 0x00000003 #
-                                 #      Assorted constants and limits.
-                                 #                
-
-const 
-  XkbAllIndicatorsMask* = 0xFFFFFFFF #
-                                     #      Map components masks:
-                                     #      Those in AllMapComponentsMask:
-                                     #       - Specifies the individual fields to be loaded or changed for the
-                                     #         GetMap and SetMap requests.
-                                     #      Those in ClientInfoMask:
-                                     #       - Specifies the components to be allocated by XkbAllocClientMap.
-                                     #      Those in ServerInfoMask:
-                                     #       - Specifies the components to be allocated by XkbAllocServerMap.
-                                     #                
-
-const 
-  XkbKeyTypesMask* = 1 shl 0
-  XkbKeySymsMask* = 1 shl 1
-  XkbModifierMapMask* = 1 shl 2
-  XkbExplicitComponentsMask* = 1 shl 3
-  XkbKeyActionsMask* = 1 shl 4
-  XkbKeyBehaviorsMask* = 1 shl 5
-  XkbVirtualModsMask* = 1 shl 6
-  XkbVirtualModMapMask* = 1 shl 7
-  XkbAllClientInfoMask* = XkbKeyTypesMask or XkbKeySymsMask or
-      XkbModifierMapMask
-  XkbAllServerInfoMask* = XkbExplicitComponentsMask or XkbKeyActionsMask or
-      XkbKeyBehaviorsMask or XkbVirtualModsMask or XkbVirtualModMapMask
-  XkbAllMapComponentsMask* = XkbAllClientInfoMask or XkbAllServerInfoMask #
-                                                                          #      Names component mask:
-                                                                          #       - Specifies the names to be loaded or changed for the GetNames and
-                                                                          #         SetNames requests.
-                                                                          #       - Specifies the names that have changed in a NamesNotify event.
-                                                                          #       - Specifies the names components to be allocated by XkbAllocNames.
-                                                                          #                
-
-const 
-  XkbKeycodesNameMask* = 1 shl 0
-  XkbGeometryNameMask* = 1 shl 1
-  XkbSymbolsNameMask* = 1 shl 2
-  XkbPhysSymbolsNameMask* = 1 shl 3
-  XkbTypesNameMask* = 1 shl 4
-  XkbCompatNameMask* = 1 shl 5
-  XkbKeyTypeNamesMask* = 1 shl 6
-  XkbKTLevelNamesMask* = 1 shl 7
-  XkbIndicatorNamesMask* = 1 shl 8
-  XkbKeyNamesMask* = 1 shl 9
-  XkbKeyAliasesMask* = 1 shl 10
-  XkbVirtualModNamesMask* = 1 shl 11
-  XkbGroupNamesMask* = 1 shl 12
-  XkbRGNamesMask* = 1 shl 13
-  XkbComponentNamesMask* = 0x0000003F
-  XkbAllNamesMask* = 0x00003FFF #
-                                #      Miscellaneous event details:
-                                #      - event detail masks for assorted events that don't reall
-                                #        have any details.
-                                #                
-
-const 
-  XkbAllStateEventsMask* = XkbAllStateComponentsMask
-  XkbAllMapEventsMask* = XkbAllMapComponentsMask
-  XkbAllControlEventsMask* = XkbAllControlsMask
-  XkbAllIndicatorEventsMask* = XkbAllIndicatorsMask
-  XkbAllNameEventsMask* = XkbAllNamesMask
-  XkbAllCompatMapEventsMask* = XkbAllCompatMask
-  XkbAllBellEventsMask* = int(1) shl 0
-  XkbAllActionMessagesMask* = int(1) shl 0 #
-                                           #      XKB reports one error:  BadKeyboard
-                                           #      A further reason for the error is encoded into to most significant
-                                           #      byte of the resourceID for the error:
-                                           #         XkbErr_BadDevice - the device in question was not found
-                                           #         XkbErr_BadClass  - the device was found but it doesn't belong to
-                                           #                            the appropriate class.
-                                           #         XkbErr_BadId     - the device was found and belongs to the right
-                                           #                            class, but not feedback with a matching id was
-                                           #                            found.
-                                           #      The low byte of the resourceID for this error contains the device
-                                           #      id, class specifier or feedback id that failed.
-                                           #                
-
-const 
-  XkbKeyboard* = 0
-  XkbNumberErrors* = 1
-  XkbErr_BadDevice* = 0x000000FF
-  XkbErr_BadClass* = 0x000000FE
-  XkbErr_BadId* = 0x000000FD #
-                             #      Keyboard Components Mask:
-                             #      - Specifies the components that follow a GetKeyboardByNameReply
-                             #                
-
-const 
-  XkbClientMapMask* = int(1) shl 0
-  XkbServerMapMask* = int(1) shl 1
-  XkbCompatMapMask* = int(1) shl 2
-  XkbIndicatorMapMask* = int(1) shl 3
-  XkbNamesMask* = int(1) shl 4
-  XkbGeometryMask* = int(1) shl 5
-  XkbControlsMask* = int(1) shl 6
-  XkbAllComponentsMask* = 0x0000007F #
-                                     #      AccessX Options Mask
-                                     #       - The 'accessXOptions' field of an XkbControlsRec specifies the
-                                     #         AccessX options that are currently in effect.
-                                     #       - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'
-                                     #         fields of an XkbControlsRec specify the Access X options to be
-                                     #         changed if the keyboard times out and the values to which they
-                                     #         should be changed.
-                                     #                
-
-const 
-  XkbAX_SKPressFBMask* = int(1) shl 0
-  XkbAX_SKAcceptFBMask* = int(1) shl 1
-  XkbAX_FeatureFBMask* = int(1) shl 2
-  XkbAX_SlowWarnFBMask* = int(1) shl 3
-  XkbAX_IndicatorFBMask* = int(1) shl 4
-  XkbAX_StickyKeysFBMask* = int(1) shl 5
-  XkbAX_TwoKeysMask* = int(1) shl 6
-  XkbAX_LatchToLockMask* = int(1) shl 7
-  XkbAX_SKReleaseFBMask* = int(1) shl 8
-  XkbAX_SKRejectFBMask* = int(1) shl 9
-  XkbAX_BKRejectFBMask* = int(1) shl 10
-  XkbAX_DumbBellFBMask* = int(1) shl 11
-  XkbAX_FBOptionsMask* = 0x00000F3F
-  XkbAX_SKOptionsMask* = 0x000000C0
-  XkbAX_AllOptionsMask* = 0x00000FFF #
-                                     #      XkbUseCoreKbd is used to specify the core keyboard without having
-                                     #                        to look up its X input extension identifier.
-                                     #      XkbUseCorePtr is used to specify the core pointer without having
-                                     #                        to look up its X input extension identifier.
-                                     #      XkbDfltXIClass is used to specify "don't care" any place that the
-                                     #                        XKB protocol is looking for an X Input Extension
-                                     #                        device class.
-                                     #      XkbDfltXIId is used to specify "don't care" any place that the
-                                     #                        XKB protocol is looking for an X Input Extension
-                                     #                        feedback identifier.
-                                     #      XkbAllXIClasses is used to get information about all device indicators,
-                                     #                        whether they're part of the indicator feedback class
-                                     #                        or the keyboard feedback class.
-                                     #      XkbAllXIIds is used to get information about all device indicator
-                                     #                        feedbacks without having to list them.
-                                     #      XkbXINone is used to indicate that no class or id has been specified.
-                                     #      XkbLegalXILedClass(c)  True if 'c' specifies a legal class with LEDs
-                                     #      XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells
-                                     #      XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device
-                                     #      XkbExplicitXIClass(c)  True if 'c' explicitly specifies a device class
-                                     #      XkbExplicitXIId(c)     True if 'i' explicitly specifies a device id
-                                     #      XkbSingleXIClass(c)    True if 'c' specifies exactly one device class,
-                                     #                             including the default.
-                                     #      XkbSingleXIId(i)       True if 'i' specifies exactly one device
-                                     #                              identifier, including the default.
-                                     #                
-
-const 
-  XkbUseCoreKbd* = 0x00000100
-  XkbUseCorePtr* = 0x00000200
-  XkbDfltXIClass* = 0x00000300
-  XkbDfltXIId* = 0x00000400
-  XkbAllXIClasses* = 0x00000500
-  XkbAllXIIds* = 0x00000600
-  XkbXINone* = 0x0000FF00
-
-proc XkbLegalXILedClass*(c: int): bool
-proc XkbLegalXIBellClass*(c: int): bool
-proc XkbExplicitXIDevice*(c: int): bool
-proc XkbExplicitXIClass*(c: int): bool
-proc XkbExplicitXIId*(c: int): bool
-proc XkbSingleXIClass*(c: int): bool
-proc XkbSingleXIId*(c: int): bool
-const 
-  XkbNoModifier* = 0x000000FF
-  XkbNoShiftLevel* = 0x000000FF
-  XkbNoShape* = 0x000000FF
-  XkbNoIndicator* = 0x000000FF
-  XkbNoModifierMask* = 0
-  XkbAllModifiersMask* = 0x000000FF
-  XkbAllVirtualModsMask* = 0x0000FFFF
-  XkbNumKbdGroups* = 4
-  XkbMaxKbdGroup* = XkbNumKbdGroups - 1
-  XkbMaxMouseKeysBtn* = 4 #
-                          #      Group Index and Mask:
-                          #       - Indices into the kt_index array of a key type.
-                          #       - Mask specifies types to be changed for XkbChangeTypesOfKey
-                          #    
-
-const 
-  XkbGroup1Index* = 0
-  XkbGroup2Index* = 1
-  XkbGroup3Index* = 2
-  XkbGroup4Index* = 3
-  XkbAnyGroup* = 254
-  XkbAllGroups* = 255
-  XkbGroup1Mask* = 1 shl 0
-  XkbGroup2Mask* = 1 shl 1
-  XkbGroup3Mask* = 1 shl 2
-  XkbGroup4Mask* = 1 shl 3
-  XkbAnyGroupMask* = 1 shl 7
-  XkbAllGroupsMask* = 0x0000000F #
-                                 #      BuildCoreState: Given a keyboard group and a modifier state,
-                                 #                      construct the value to be reported an event.
-                                 #      GroupForCoreState:  Given the state reported in an event,
-                                 #                      determine the keyboard group.
-                                 #      IsLegalGroup:   Returns TRUE if 'g' is a valid group index.
-                                 #                
-
-proc XkbBuildCoreState*(m, g: int): int
-proc XkbGroupForCoreState*(s: int): int
-proc XkbIsLegalGroup*(g: int): bool
-  #
-  #      GroupsWrap values:
-  #       - The 'groupsWrap' field of an XkbControlsRec specifies the
-  #         treatment of out of range groups.
-  #       - Bits 6 and 7 of the group info field of a key symbol map
-  #         specify the interpretation of out of range groups for the
-  #         corresponding key.
-  #                
-const 
-  XkbWrapIntoRange* = 0x00000000
-  XkbClampIntoRange* = 0x00000040
-  XkbRedirectIntoRange* = 0x00000080 #
-                                     #      Action flags:  Reported in the 'flags' field of most key actions.
-                                     #      Interpretation depends on the type of the action; not all actions
-                                     #      accept all flags.
-                                     #
-                                     #      Option                    Used for Actions
-                                     #      ------                    ----------------
-                                     #      ClearLocks                SetMods, LatchMods, SetGroup, LatchGroup
-                                     #      LatchToLock               SetMods, LatchMods, SetGroup, LatchGroup
-                                     #      LockNoLock                LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
-                                     #      LockNoUnlock              LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
-                                     #      UseModMapMods             SetMods, LatchMods, LockMods, ISOLock
-                                     #      GroupAbsolute             SetGroup, LatchGroup, LockGroup, ISOLock
-                                     #      UseDfltButton             PtrBtn, LockPtrBtn
-                                     #      NoAcceleration            MovePtr
-                                     #      MoveAbsoluteX             MovePtr
-                                     #      MoveAbsoluteY             MovePtr
-                                     #      ISODfltIsGroup            ISOLock
-                                     #      ISONoAffectMods           ISOLock
-                                     #      ISONoAffectGroup          ISOLock
-                                     #      ISONoAffectPtr            ISOLock
-                                     #      ISONoAffectCtrls          ISOLock
-                                     #      MessageOnPress            ActionMessage
-                                     #      MessageOnRelease          ActionMessage
-                                     #      MessageGenKeyEvent        ActionMessage
-                                     #      AffectDfltBtn             SetPtrDflt
-                                     #      DfltBtnAbsolute           SetPtrDflt
-                                     #      SwitchApplication SwitchScreen
-                                     #      SwitchAbsolute            SwitchScreen
-                                     #                
-
-const 
-  XkbSA_ClearLocks* = int(1) shl 0
-  XkbSA_LatchToLock* = int(1) shl 1
-  XkbSA_LockNoLock* = int(1) shl 0
-  XkbSA_LockNoUnlock* = int(1) shl 1
-  XkbSA_UseModMapMods* = int(1) shl 2
-  XkbSA_GroupAbsolute* = int(1) shl 2
-  XkbSA_UseDfltButton* = 0
-  XkbSA_NoAcceleration* = int(1) shl 0
-  XkbSA_MoveAbsoluteX* = int(1) shl 1
-  XkbSA_MoveAbsoluteY* = int(1) shl 2
-  XkbSA_ISODfltIsGroup* = int(1) shl 7
-  XkbSA_ISONoAffectMods* = int(1) shl 6
-  XkbSA_ISONoAffectGroup* = int(1) shl 5
-  XkbSA_ISONoAffectPtr* = int(1) shl 4
-  XkbSA_ISONoAffectCtrls* = int(1) shl 3
-  XkbSA_ISOAffectMask* = 0x00000078
-  XkbSA_MessageOnPress* = int(1) shl 0
-  XkbSA_MessageOnRelease* = int(1) shl 1
-  XkbSA_MessageGenKeyEvent* = int(1) shl 2
-  XkbSA_AffectDfltBtn* = 1
-  XkbSA_DfltBtnAbsolute* = int(1) shl 2
-  XkbSA_SwitchApplication* = int(1) shl 0
-  XkbSA_SwitchAbsolute* = int(1) shl 2 #
-                                       #      The following values apply to the SA_DeviceValuator
-                                       #      action only.  Valuator operations specify the action
-                                       #      to be taken.   Values specified in the action are
-                                       #      multiplied by 2^scale before they are applied.
-                                       #                
-
-const 
-  XkbSA_IgnoreVal* = 0x00000000
-  XkbSA_SetValMin* = 0x00000010
-  XkbSA_SetValCenter* = 0x00000020
-  XkbSA_SetValMax* = 0x00000030
-  XkbSA_SetValRelative* = 0x00000040
-  XkbSA_SetValAbsolute* = 0x00000050
-  XkbSA_ValOpMask* = 0x00000070
-  XkbSA_ValScaleMask* = 0x00000007
-
-proc XkbSA_ValOp*(a: int): int
-proc XkbSA_ValScale*(a: int): int
-  #
-  #      Action types: specifies the type of a key action.  Reported in the
-  #      type field of all key actions.
-  #                
-const 
-  XkbSA_NoAction* = 0x00000000
-  XkbSA_SetMods* = 0x00000001
-  XkbSA_LatchMods* = 0x00000002
-  XkbSA_LockMods* = 0x00000003
-  XkbSA_SetGroup* = 0x00000004
-  XkbSA_LatchGroup* = 0x00000005
-  XkbSA_LockGroup* = 0x00000006
-  XkbSA_MovePtr* = 0x00000007
-  XkbSA_PtrBtn* = 0x00000008
-  XkbSA_LockPtrBtn* = 0x00000009
-  XkbSA_SetPtrDflt* = 0x0000000A
-  XkbSA_ISOLock* = 0x0000000B
-  XkbSA_Terminate* = 0x0000000C
-  XkbSA_SwitchScreen* = 0x0000000D
-  XkbSA_SetControls* = 0x0000000E
-  XkbSA_LockControls* = 0x0000000F
-  XkbSA_ActionMessage* = 0x00000010
-  XkbSA_RedirectKey* = 0x00000011
-  XkbSA_DeviceBtn* = 0x00000012
-  XkbSA_LockDeviceBtn* = 0x00000013
-  XkbSA_DeviceValuator* = 0x00000014
-  XkbSA_LastAction* = XkbSA_DeviceValuator
-  XkbSA_NumActions* = XkbSA_LastAction + 1
-
-const 
-  XkbSA_XFree86Private* = 0x00000086
-#
-#      Specifies the key actions that clear latched groups or modifiers.
-#                
-
-const  ##define        XkbSA_BreakLatch \
-       #        ((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\
-       #        (1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\
-       #        (1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\
-       #        (1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))
-       #
-  XkbSA_BreakLatch* = (1 shl XkbSA_PtrBtn) or (1 shl XkbSA_LockPtrBtn) or
-      (1 shl XkbSA_Terminate) or (1 shl XkbSA_SwitchScreen) or
-      (1 shl XkbSA_SetControls) or (1 shl XkbSA_LockControls) or
-      (1 shl XkbSA_ActionMessage) or (1 shl XkbSA_RedirectKey) or
-      (1 shl XkbSA_DeviceBtn) or (1 shl XkbSA_LockDeviceBtn) #
-                                                             #      Key Behavior Qualifier:
-                                                             #         KB_Permanent indicates that the behavior describes an unalterable
-                                                             #         characteristic of the keyboard, not an XKB software-simulation of
-                                                             #         the listed behavior.
-                                                             #      Key Behavior Types:
-                                                             #         Specifies the behavior of the underlying key.
-                                                             #                
-
-const 
-  XkbKB_Permanent* = 0x00000080
-  XkbKB_OpMask* = 0x0000007F
-  XkbKB_Default* = 0x00000000
-  XkbKB_Lock* = 0x00000001
-  XkbKB_RadioGroup* = 0x00000002
-  XkbKB_Overlay1* = 0x00000003
-  XkbKB_Overlay2* = 0x00000004
-  XkbKB_RGAllowNone* = 0x00000080 #
-                                  #      Various macros which describe the range of legal keycodes.
-                                  #                
-
-const 
-  XkbMinLegalKeyCode* = 8
-  XkbMaxLegalKeyCode* = 255
-  XkbMaxKeyCount* = XkbMaxLegalKeyCode - XkbMinLegalKeyCode + 1
-  XkbPerKeyBitArraySize* = (XkbMaxLegalKeyCode + 1) div 8
-
-proc XkbIsLegalKeycode*(k: int): bool
-type 
-  PXkbControlsPtr* = ptr TXkbControlsRec
-  TXkbControlsRec*{.final.} = object 
-    mk_dflt_btn*: int8
-    num_groups*: int8
-    groups_wrap*: int8
-    internal*: TXkbModsRec
-    ignore_lock*: TXkbModsRec
-    enabled_ctrls*: int16
-    repeat_delay*: int16
-    repeat_interval*: int16
-    slow_keys_delay*: int16
-    debounce_delay*: int16
-    mk_delay*: int16
-    mk_interval*: int16
-    mk_time_to_max*: int16
-    mk_max_speed*: int16
-    mk_curve*: int16
-    ax_options*: int16
-    ax_timeout*: int16
-    axt_opts_mask*: int16
-    axt_opts_values*: int16
-    axt_ctrls_mask*: int16
-    axt_ctrls_values*: int16
-    per_key_repeat*: array[0..XkbPerKeyBitArraySize - 1, int8]
-
-
-proc XkbAX_AnyFeedback*(c: PXkbControlsPtr): int16
-proc XkbAX_NeedOption*(c: PXkbControlsPtr, w: int16): int16
-proc XkbAX_NeedFeedback*(c: PXkbControlsPtr, w: int16): bool
-  #
-  #      Assorted constants and limits.
-  #                
-const 
-  XkbNumModifiers* = 8
-  XkbNumVirtualMods* = 16
-  XkbNumIndicators* = 32
-  XkbMaxRadioGroups* = 32
-  XkbAllRadioGroupsMask* = 0xFFFFFFFF
-  XkbMaxShiftLevel* = 63
-  XkbMaxSymsPerKey* = XkbMaxShiftLevel * XkbNumKbdGroups
-  XkbRGMaxMembers* = 12
-  XkbActionMessageLength* = 6
-  XkbKeyNameLength* = 4
-  XkbMaxRedirectCount* = 8
-  XkbGeomPtsPerMM* = 10
-  XkbGeomMaxColors* = 32
-  XkbGeomMaxLabelColors* = 3
-  XkbGeomMaxPriority* = 255
-
-type 
-  PXkbServerMapPtr* = ptr TXkbServerMapRec
-  TXkbServerMapRec*{.final.} = object 
-    num_acts*: int16
-    size_acts*: int16
-    acts*: ptr array[0..0xfff, TXkbAction]
-    behaviors*: PXkbBehavior
-    key_acts*: PWord
-    explicit*: PByte
-    vmods*: array[0..XkbNumVirtualMods - 1, int8]
-    vmodmap*: PWord
-
-
-proc XkbSMKeyActionsPtr*(m: PXkbServerMapPtr, k: int16): PXkbAction
-  #
-  #          Structures and access macros used primarily by clients
-  #        
-type 
-  PXkbSymMapPtr* = ptr TXkbSymMapRec
-  TXkbSymMapRec*{.final.} = object 
-    kt_index*: array[0..XkbNumKbdGroups - 1, int8]
-    group_info*: int8
-    width*: int8
-    offset*: int8
-
-
-type 
-  PXkbClientMapPtr* = ptr TXkbClientMapRec
-  TXkbClientMapRec*{.final.} = object 
-    size_types*: int8
-    num_types*: int8
-    types*: ptr array[0..0xffff, TXkbKeyTypeRec]
-    size_syms*: int16
-    num_syms*: int16
-    syms*: ptr array[0..0xffff, TKeySym]
-    key_sym_map*: ptr array[0..0xffff, TXkbSymMapRec]
-    modmap*: PByte
-
-
-proc XkbCMKeyGroupInfo*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyNumGroups*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyGroupWidth*(m: PXkbClientMapPtr, k: int16, g: int8): int8
-proc XkbCMKeyGroupsWidth*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyTypeIndex*(m: PXkbClientMapPtr, k: int16, g: int8): int8
-proc XkbCMKeyType*(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr
-proc XkbCMKeyNumSyms*(m: PXkbClientMapPtr, k: int16): int16
-proc XkbCMKeySymsOffset*(m: PXkbClientMapPtr, k: int16): int8
-  #
-  #          Compatibility structures and access macros
-  #        
-type 
-  PXkbSymInterpretPtr* = ptr TXkbSymInterpretRec
-  TXkbSymInterpretRec*{.final.} = object 
-    sym*: TKeySym
-    flags*: int8
-    match*: int8
-    mods*: int8
-    virtual_mod*: int8
-    act*: TXkbAnyAction
-
-
-type 
-  PXkbCompatMapPtr* = ptr TXkbCompatMapRec
-  TXkbCompatMapRec*{.final.} = object 
-    sym_interpret*: PXkbSymInterpretPtr
-    groups*: array[0..XkbNumKbdGroups - 1, TXkbModsRec]
-    num_si*: int16
-    size_si*: int16
-
-
-type 
-  PXkbIndicatorMapPtr* = ptr TXkbIndicatorMapRec
-  TXkbIndicatorMapRec*{.final.} = object 
-    flags*: int8
-    which_groups*: int8
-    groups*: int8
-    which_mods*: int8
-    mods*: TXkbModsRec
-    ctrls*: int16
-
-
-proc XkbIM_IsAuto*(i: PXkbIndicatorMapPtr): bool
-proc XkbIM_InUse*(i: PXkbIndicatorMapPtr): bool
-type 
-  PXkbIndicatorPtr* = ptr TXkbIndicatorRec
-  TXkbIndicatorRec*{.final.} = object 
-    phys_indicators*: int32
-    maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
-
-
-type 
-  PXkbKeyNamePtr* = ptr TXkbKeyNameRec
-  TXkbKeyNameRec*{.final.} = object 
-    name*: array[0..XkbKeyNameLength - 1, Char]
-
-
-type 
-  PXkbKeyAliasPtr* = ptr TXkbKeyAliasRec
-  TXkbKeyAliasRec*{.final.} = object  #
-                                      #          Names for everything
-                                      #        
-    float*: array[0..XkbKeyNameLength - 1, Char]
-    alias*: array[0..XkbKeyNameLength - 1, Char]
-
-
-type 
-  PXkbNamesPtr* = ptr TXkbNamesRec
-  TXkbNamesRec*{.final.} = object  #
-                                   #      Key Type index and mask for the four standard key types.
-                                   #                
-    keycodes*: TAtom
-    geometry*: TAtom
-    symbols*: TAtom
-    types*: TAtom
-    compat*: TAtom
-    vmods*: array[0..XkbNumVirtualMods - 1, TAtom]
-    indicators*: array[0..XkbNumIndicators - 1, TAtom]
-    groups*: array[0..XkbNumKbdGroups - 1, TAtom]
-    keys*: PXkbKeyNamePtr
-    key_aliases*: PXkbKeyAliasPtr
-    radio_groups*: PAtom
-    phys_symbols*: TAtom
-    num_keys*: int8
-    num_key_aliases*: int8
-    num_rg*: int16
-
-
-const 
-  XkbOneLevelIndex* = 0
-  XkbTwoLevelIndex* = 1
-  XkbAlphabeticIndex* = 2
-  XkbKeypadIndex* = 3
-  XkbLastRequiredType* = XkbKeypadIndex
-  XkbNumRequiredTypes* = XkbLastRequiredType + 1
-  XkbMaxKeyTypes* = 255
-  XkbOneLevelMask* = 1 shl 0
-  XkbTwoLevelMask* = 1 shl 1
-  XkbAlphabeticMask* = 1 shl 2
-  XkbKeypadMask* = 1 shl 3
-  XkbAllRequiredTypes* = 0x0000000F
-
-proc XkbShiftLevel*(n: int8): int8
-proc XkbShiftLevelMask*(n: int8): int8
-  #
-  #      Extension name and version information
-  #                
-const 
-  XkbName* = "XKEYBOARD"
-  XkbMajorVersion* = 1
-  XkbMinorVersion* = 0 #
-                       #      Explicit map components:
-                       #       - Used in the 'explicit' field of an XkbServerMap.  Specifies
-                       #         the keyboard components that should _not_ be updated automatically
-                       #         in response to core protocol keyboard mapping requests.
-                       #                
-
-const 
-  XkbExplicitKeyTypesMask* = 0x0000000F
-  XkbExplicitKeyType1Mask* = 1 shl 0
-  XkbExplicitKeyType2Mask* = 1 shl 1
-  XkbExplicitKeyType3Mask* = 1 shl 2
-  XkbExplicitKeyType4Mask* = 1 shl 3
-  XkbExplicitInterpretMask* = 1 shl 4
-  XkbExplicitAutoRepeatMask* = 1 shl 5
-  XkbExplicitBehaviorMask* = 1 shl 6
-  XkbExplicitVModMapMask* = 1 shl 7
-  XkbAllExplicitMask* = 0x000000FF #
-                                   #      Symbol interpretations flags:
-                                   #       - Used in the flags field of a symbol interpretation
-                                   #                
-
-const 
-  XkbSI_AutoRepeat* = 1 shl 0
-  XkbSI_LockingKey* = 1 shl 1 #
-                              #      Symbol interpretations match specification:
-                              #       - Used in the match field of a symbol interpretation to specify
-                              #         the conditions under which an interpretation is used.
-                              #                
-
-const 
-  XkbSI_LevelOneOnly* = 0x00000080
-  XkbSI_OpMask* = 0x0000007F
-  XkbSI_NoneOf* = 0
-  XkbSI_AnyOfOrNone* = 1
-  XkbSI_AnyOf* = 2
-  XkbSI_AllOf* = 3
-  XkbSI_Exactly* = 4 #
-                     #      Indicator map flags:
-                     #       - Used in the flags field of an indicator map to indicate the
-                     #         conditions under which and indicator can be changed and the
-                     #         effects of changing the indicator.
-                     #                
-
-const 
-  XkbIM_NoExplicit* = int(1) shl 7
-  XkbIM_NoAutomatic* = int(1) shl 6
-  XkbIM_LEDDrivesKB* = int(1) shl 5 #
-                                    #      Indicator map component specifications:
-                                    #       - Used by the 'which_groups' and 'which_mods' fields of an indicator
-                                    #         map to specify which keyboard components should be used to drive
-                                    #         the indicator.
-                                    #                
-
-const 
-  XkbIM_UseBase* = int(1) shl 0
-  XkbIM_UseLatched* = int(1) shl 1
-  XkbIM_UseLocked* = int(1) shl 2
-  XkbIM_UseEffective* = int(1) shl 3
-  XkbIM_UseCompat* = int(1) shl 4
-  XkbIM_UseNone* = 0
-  XkbIM_UseAnyGroup* = XkbIM_UseBase or XkbIM_UseLatched or XkbIM_UseLocked or
-      XkbIM_UseEffective
-  XkbIM_UseAnyMods* = XkbIM_UseAnyGroup or XkbIM_UseCompat #
-                                                           #      GetByName components:
-                                                           #       - Specifies desired or necessary components to GetKbdByName request.
-                                                           #       - Reports the components that were found in a GetKbdByNameReply
-                                                           #                
-
-const 
-  XkbGBN_TypesMask* = int(1) shl 0
-  XkbGBN_CompatMapMask* = int(1) shl 1
-  XkbGBN_ClientSymbolsMask* = int(1) shl 2
-  XkbGBN_ServerSymbolsMask* = int(1) shl 3
-  XkbGBN_SymbolsMask* = XkbGBN_ClientSymbolsMask or XkbGBN_ServerSymbolsMask
-  XkbGBN_IndicatorMapMask* = int(1) shl 4
-  XkbGBN_KeyNamesMask* = int(1) shl 5
-  XkbGBN_GeometryMask* = int(1) shl 6
-  XkbGBN_OtherNamesMask* = int(1) shl 7
-  XkbGBN_AllComponentsMask* = 0x000000FF #
-                                         #       ListComponents flags
-                                         #                        
-
-const 
-  XkbLC_Hidden* = int(1) shl 0
-  XkbLC_Default* = int(1) shl 1
-  XkbLC_Partial* = int(1) shl 2
-  XkbLC_AlphanumericKeys* = int(1) shl 8
-  XkbLC_ModifierKeys* = int(1) shl 9
-  XkbLC_KeypadKeys* = int(1) shl 10
-  XkbLC_FunctionKeys* = int(1) shl 11
-  XkbLC_AlternateGroup* = int(1) shl 12 #
-                                        #      X Input Extension Interactions
-                                        #      - Specifies the possible interactions between XKB and the X input
-                                        #        extension
-                                        #      - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)
-                                        #        XKB information about an extension device.
-                                        #      - Reports the list of supported optional features in the reply to
-                                        #        XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.
-                                        #      XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify
-                                        #      events to indicate an attempt to use an unsupported feature.
-                                        #                
-
-const 
-  XkbXI_KeyboardsMask* = int(1) shl 0
-  XkbXI_ButtonActionsMask* = int(1) shl 1
-  XkbXI_IndicatorNamesMask* = int(1) shl 2
-  XkbXI_IndicatorMapsMask* = int(1) shl 3
-  XkbXI_IndicatorStateMask* = int(1) shl 4
-  XkbXI_UnsupportedFeatureMask* = int(1) shl 15
-  XkbXI_AllFeaturesMask* = 0x0000001F
-  XkbXI_AllDeviceFeaturesMask* = 0x0000001E
-  XkbXI_IndicatorsMask* = 0x0000001C
-  XkbAllExtensionDeviceEventsMask* = 0x0000801F #
-                                                #      Per-Client Flags:
-                                                #       - Specifies flags to be changed by the PerClientFlags request.
-                                                #                
-
-const 
-  XkbPCF_DetectableAutoRepeatMask* = int(1) shl 0
-  XkbPCF_GrabsUseXKBStateMask* = int(1) shl 1
-  XkbPCF_AutoResetControlsMask* = int(1) shl 2
-  XkbPCF_LookupStateWhenGrabbed* = int(1) shl 3
-  XkbPCF_SendEventUsesXKBState* = int(1) shl 4
-  XkbPCF_AllFlagsMask* = 0x0000001F #
-                                    #      Debugging flags and controls
-                                    #                
-
-const 
-  XkbDF_DisableLocks* = 1 shl 0
-
-type 
-  PXkbPropertyPtr* = ptr TXkbPropertyRec
-  TXkbPropertyRec*{.final.} = object 
-    name*: cstring
-    value*: cstring
-
-
-type 
-  PXkbColorPtr* = ptr TXkbColorRec
-  TXkbColorRec*{.final.} = object 
-    pixel*: int16
-    spec*: cstring
-
-
-type 
-  PXkbPointPtr* = ptr TXkbPointRec
-  TXkbPointRec*{.final.} = object 
-    x*: int16
-    y*: int16
-
-
-type 
-  PXkbBoundsPtr* = ptr TXkbBoundsRec
-  TXkbBoundsRec*{.final.} = object 
-    x1*: int16
-    y1*: int16
-    x2*: int16
-    y2*: int16
-
-
-proc XkbBoundsWidth*(b: PXkbBoundsPtr): int16
-proc XkbBoundsHeight*(b: PXkbBoundsPtr): int16
-type 
-  PXkbOutlinePtr* = ptr TXkbOutlineRec
-  TXkbOutlineRec*{.final.} = object 
-    num_points*: int16
-    sz_points*: int16
-    corner_radius*: int16
-    points*: PXkbPointPtr
-
-
-type 
-  PXkbShapePtr* = ptr TXkbShapeRec
-  TXkbShapeRec*{.final.} = object 
-    name*: TAtom
-    num_outlines*: int16
-    sz_outlines*: int16
-    outlines*: ptr array [0..0xffff, TXkbOutlineRec]
-    approx*: ptr array[0..0xffff, TXkbOutlineRec]
-    primary*: ptr array[0..0xffff, TXkbOutlineRec]
-    bounds*: TXkbBoundsRec
-
-
-proc XkbOutlineIndex*(s: PXkbShapePtr, o: PXkbOutlinePtr): int32
-type 
-  PXkbShapeDoodadPtr* = ptr TXkbShapeDoodadRec
-  TXkbShapeDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    color_ndx*: int16
-    shape_ndx*: int16
-
-
-type 
-  PXkbTextDoodadPtr* = ptr TXkbTextDoodadRec
-  TXkbTextDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    width*: int16
-    height*: int16
-    color_ndx*: int16
-    text*: cstring
-    font*: cstring
-
-
-type 
-  PXkbIndicatorDoodadPtr* = ptr TXkbIndicatorDoodadRec
-  TXkbIndicatorDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    shape_ndx*: int16
-    on_color_ndx*: int16
-    off_color_ndx*: int16
-
-
-type 
-  PXkbLogoDoodadPtr* = ptr TXkbLogoDoodadRec
-  TXkbLogoDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    color_ndx*: int16
-    shape_ndx*: int16
-    logo_name*: cstring
-
-
-type 
-  PXkbAnyDoodadPtr* = ptr TXkbAnyDoodadRec
-  TXkbAnyDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-
-
-type 
-  PXkbDoodadPtr* = ptr TXkbDoodadRec
-  TXkbDoodadRec*{.final.} = object 
-    any*: TXkbAnyDoodadRec
-    shape*: TXkbShapeDoodadRec
-    text*: TXkbTextDoodadRec
-    indicator*: TXkbIndicatorDoodadRec
-    logo*: TXkbLogoDoodadRec
-
-
-const 
-  XkbUnknownDoodad* = 0
-  XkbOutlineDoodad* = 1
-  XkbSolidDoodad* = 2
-  XkbTextDoodad* = 3
-  XkbIndicatorDoodad* = 4
-  XkbLogoDoodad* = 5
-
-type 
-  PXkbKeyPtr* = ptr TXkbKeyRec
-  TXkbKeyRec*{.final.} = object 
-    name*: TXkbKeyNameRec
-    gap*: int16
-    shape_ndx*: int8
-    color_ndx*: int8
-
-
-type 
-  PXkbRowPtr* = ptr TXkbRowRec
-  TXkbRowRec*{.final.} = object 
-    top*: int16
-    left*: int16
-    num_keys*: int16
-    sz_keys*: int16
-    vertical*: int16
-    Keys*: PXkbKeyPtr
-    bounds*: TXkbBoundsRec
-
-
-type 
-  PXkbOverlayPtr* = ptr TXkbOverlayRec #forward for TXkbSectionRec use.
-                                       #Do not add more "type"
-  PXkbSectionPtr* = ptr TXkbSectionRec
-  TXkbSectionRec*{.final.} = object  #Do not add more "type"
-    name*: TAtom
-    priority*: int8
-    top*: int16
-    left*: int16
-    width*: int16
-    height*: int16
-    angle*: int16
-    num_rows*: int16
-    num_doodads*: int16
-    num_overlays*: int16
-    rows*: PXkbRowPtr
-    doodads*: PXkbDoodadPtr
-    bounds*: TXkbBoundsRec
-    overlays*: PXkbOverlayPtr
-
-  PXkbOverlayKeyPtr* = ptr TXkbOverlayKeyRec
-  TXkbOverlayKeyRec*{.final.} = object  #Do not add more "type"
-    over*: TXkbKeyNameRec
-    under*: TXkbKeyNameRec
-
-  PXkbOverlayRowPtr* = ptr TXkbOverlayRowRec
-  TXkbOverlayRowRec*{.final.} = object  #Do not add more "type"
-    row_under*: int16
-    num_keys*: int16
-    sz_keys*: int16
-    keys*: PXkbOverlayKeyPtr
-
-  TXkbOverlayRec*{.final.} = object 
-    name*: TAtom
-    section_under*: PXkbSectionPtr
-    num_rows*: int16
-    sz_rows*: int16
-    rows*: PXkbOverlayRowPtr
-    bounds*: PXkbBoundsPtr
-
-
-type 
-  PXkbGeometryRec* = ptr TXkbGeometryRec
-  PXkbGeometryPtr* = PXkbGeometryRec
-  TXkbGeometryRec*{.final.} = object 
-    name*: TAtom
-    width_mm*: int16
-    height_mm*: int16
-    label_font*: cstring
-    label_color*: PXkbColorPtr
-    base_color*: PXkbColorPtr
-    sz_properties*: int16
-    sz_colors*: int16
-    sz_shapes*: int16
-    sz_sections*: int16
-    sz_doodads*: int16
-    sz_key_aliases*: int16
-    num_properties*: int16
-    num_colors*: int16
-    num_shapes*: int16
-    num_sections*: int16
-    num_doodads*: int16
-    num_key_aliases*: int16
-    properties*: ptr array[0..0xffff, TXkbPropertyRec]
-    colors*: ptr array[0..0xffff, TXkbColorRec]
-    shapes*: ptr array[0..0xffff, TXkbShapeRec]
-    sections*: ptr array[0..0xffff, TXkbSectionRec]
-    key_aliases*: ptr array[0..0xffff, TXkbKeyAliasRec]
-
-
-const 
-  XkbGeomPropertiesMask* = 1 shl 0
-  XkbGeomColorsMask* = 1 shl 1
-  XkbGeomShapesMask* = 1 shl 2
-  XkbGeomSectionsMask* = 1 shl 3
-  XkbGeomDoodadsMask* = 1 shl 4
-  XkbGeomKeyAliasesMask* = 1 shl 5
-  XkbGeomAllMask* = 0x0000003F
-
-type 
-  PXkbGeometrySizesPtr* = ptr TXkbGeometrySizesRec
-  TXkbGeometrySizesRec*{.final.} = object  #
-                                           #          Tie it all together into one big keyboard description
-                                           #        
-    which*: int16
-    num_properties*: int16
-    num_colors*: int16
-    num_shapes*: int16
-    num_sections*: int16
-    num_doodads*: int16
-    num_key_aliases*: int16
-
-
-type 
-  PXkbDescPtr* = ptr TXkbDescRec
-  TXkbDescRec*{.final.} = object 
-    dpy*: PDisplay
-    flags*: int16
-    device_spec*: int16
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    ctrls*: PXkbControlsPtr
-    server*: PXkbServerMapPtr
-    map*: PXkbClientMapPtr
-    indicators*: PXkbIndicatorPtr
-    names*: PXkbNamesPtr
-    compat*: PXkbCompatMapPtr
-    geom*: PXkbGeometryPtr
-
-
-proc XkbKeyKeyTypeIndex*(d: PXkbDescPtr, k: int16, g: int8): int8
-proc XkbKeyKeyType*(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr
-proc XkbKeyGroupWidth*(d: PXkbDescPtr, k: int16, g: int8): int8
-proc XkbKeyGroupsWidth*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyGroupInfo*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyNumGroups*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyNumSyms*(d: PXkbDescPtr, k: int16): int16
-proc XkbKeySym*(d: PXkbDescPtr, k: int16, n: int16): TKeySym
-proc XkbKeySymEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym
-proc XkbKeyAction*(d: PXkbDescPtr, k: int16, n: int16): PXkbAction
-proc XkbKeyActionEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8
-proc XkbKeyHasActions*(d: PXkbDescPtr, k: int16): bool
-proc XkbKeyNumActions*(d: PXkbDescPtr, k: int16): int16
-proc XkbKeyActionsPtr*(d: PXkbDescPtr, k: int16): PXkbAction
-proc XkbKeycodeInRange*(d: PXkbDescPtr, k: int16): bool
-proc XkbNumKeys*(d: PXkbDescPtr): int8
-  #
-  #          The following structures can be used to track changes
-  #          to a keyboard device
-  #        
-type 
-  PXkbMapChangesPtr* = ptr TXkbMapChangesRec
-  TXkbMapChangesRec*{.final.} = object 
-    changed*: int16
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    first_type*: int8
-    num_types*: int8
-    first_key_sym*: TKeyCode
-    num_key_syms*: int8
-    first_key_act*: TKeyCode
-    num_key_acts*: int8
-    first_key_behavior*: TKeyCode
-    num_key_behaviors*: int8
-    first_key_explicit*: TKeyCode
-    num_key_explicit*: int8
-    first_modmap_key*: TKeyCode
-    num_modmap_keys*: int8
-    first_vmodmap_key*: TKeyCode
-    num_vmodmap_keys*: int8
-    pad*: int8
-    vmods*: int16
-
-
-type 
-  PXkbControlsChangesPtr* = ptr TXkbControlsChangesRec
-  TXkbControlsChangesRec*{.final.} = object 
-    changed_ctrls*: int16
-    enabled_ctrls_changes*: int16
-    num_groups_changed*: bool
-
-
-type 
-  PXkbIndicatorChangesPtr* = ptr TXkbIndicatorChangesRec
-  TXkbIndicatorChangesRec*{.final.} = object 
-    state_changes*: int16
-    map_changes*: int16
-
-
-type 
-  PXkbNameChangesPtr* = ptr TXkbNameChangesRec
-  TXkbNameChangesRec*{.final.} = object 
-    changed*: int16
-    first_type*: int8
-    num_types*: int8
-    first_lvl*: int8
-    num_lvls*: int8
-    num_aliases*: int8
-    num_rg*: int8
-    first_key*: int8
-    num_keys*: int8
-    changed_vmods*: int16
-    changed_indicators*: int32
-    changed_groups*: int8
-
-
-type 
-  PXkbCompatChangesPtr* = ptr TXkbCompatChangesRec
-  TXkbCompatChangesRec*{.final.} = object 
-    changed_groups*: int8
-    first_si*: int16
-    num_si*: int16
-
-
-type 
-  PXkbChangesPtr* = ptr TXkbChangesRec
-  TXkbChangesRec*{.final.} = object  #
-                                     #          These data structures are used to construct a keymap from
-                                     #          a set of components or to list components in the server
-                                     #          database.
-                                     #        
-    device_spec*: int16
-    state_changes*: int16
-    map*: TXkbMapChangesRec
-    ctrls*: TXkbControlsChangesRec
-    indicators*: TXkbIndicatorChangesRec
-    names*: TXkbNameChangesRec
-    compat*: TXkbCompatChangesRec
-
-
-type 
-  PXkbComponentNamesPtr* = ptr TXkbComponentNamesRec
-  TXkbComponentNamesRec*{.final.} = object 
-    keymap*: ptr int16
-    keycodes*: ptr int16
-    types*: ptr int16
-    compat*: ptr int16
-    symbols*: ptr int16
-    geometry*: ptr int16
-
-
-type 
-  PXkbComponentNamePtr* = ptr TXkbComponentNameRec
-  TXkbComponentNameRec*{.final.} = object 
-    flags*: int16
-    name*: cstring
-
-
-type 
-  PXkbComponentListPtr* = ptr TXkbComponentListRec
-  TXkbComponentListRec*{.final.} = object  #
-                                           #          The following data structures describe and track changes to a
-                                           #          non-keyboard extension device
-                                           #        
-    num_keymaps*: int16
-    num_keycodes*: int16
-    num_types*: int16
-    num_compat*: int16
-    num_symbols*: int16
-    num_geometry*: int16
-    keymaps*: PXkbComponentNamePtr
-    keycodes*: PXkbComponentNamePtr
-    types*: PXkbComponentNamePtr
-    compat*: PXkbComponentNamePtr
-    symbols*: PXkbComponentNamePtr
-    geometry*: PXkbComponentNamePtr
-
-
-type 
-  PXkbDeviceLedInfoPtr* = ptr TXkbDeviceLedInfoRec
-  TXkbDeviceLedInfoRec*{.final.} = object 
-    led_class*: int16
-    led_id*: int16
-    phys_indicators*: int16
-    maps_present*: int16
-    names_present*: int16
-    state*: int16
-    names*: array[0..XkbNumIndicators - 1, TAtom]
-    maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
-
-
-type 
-  PXkbDeviceInfoPtr* = ptr TXkbDeviceInfoRec
-  TXkbDeviceInfoRec*{.final.} = object 
-    name*: cstring
-    theType*: TAtom
-    device_spec*: int16
-    has_own_state*: bool
-    supported*: int16
-    unsupported*: int16
-    num_btns*: int16
-    btn_acts*: PXkbAction
-    sz_leds*: int16
-    num_leds*: int16
-    dflt_kbd_fb*: int16
-    dflt_led_fb*: int16
-    leds*: PXkbDeviceLedInfoPtr
-
-
-proc XkbXI_DevHasBtnActs*(d: PXkbDeviceInfoPtr): bool
-proc XkbXI_LegalDevBtn*(d: PXkbDeviceInfoPtr, b: int16): bool
-proc XkbXI_DevHasLeds*(d: PXkbDeviceInfoPtr): bool
-type 
-  PXkbDeviceLedChangesPtr* = ptr TXkbDeviceLedChangesRec
-  TXkbDeviceLedChangesRec*{.final.} = object 
-    led_class*: int16
-    led_id*: int16
-    defined*: int16           #names or maps changed
-    next*: PXkbDeviceLedChangesPtr
-
-
-type 
-  PXkbDeviceChangesPtr* = ptr TXkbDeviceChangesRec
-  TXkbDeviceChangesRec*{.final.} = object 
-    changed*: int16
-    first_btn*: int16
-    num_btns*: int16
-    leds*: TXkbDeviceLedChangesRec
-
-
-proc XkbShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr
-proc XkbShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr
-proc XkbSetShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                             c: PXkbColorPtr)
-proc XkbSetShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                             s: PXkbShapePtr)
-proc XkbTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr
-proc XkbSetTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, 
-                            c: PXkbColorPtr)
-proc XkbIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr
-proc XkbIndicatorDoodadOnColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
-proc XkbIndicatorDoodadOffColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
-proc XkbSetIndicatorDoodadOnColor*(g: PXkbGeometryPtr, 
-                                   d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
-proc XkbSetIndicatorDoodadOffColor*(g: PXkbGeometryPtr, 
-                                    d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
-proc XkbSetIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                 s: PXkbShapeDoodadPtr)
-proc XkbLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr
-proc XkbLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr
-proc XkbSetLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                            c: PXkbColorPtr)
-proc XkbSetLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                            s: PXkbShapeDoodadPtr)
-proc XkbKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr
-proc XkbKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr
-proc XkbSetKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr)
-proc XkbSetKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr)
-proc XkbGeomColorIndex*(g: PXkbGeometryPtr, c: PXkbColorPtr): int32
-proc XkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, value: cstring): PXkbPropertyPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomProperty".}
-proc XkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-proc XkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
-proc XkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
-proc XkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, sz_outlines: int16): PXkbShapePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomShape".}
-proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbAddGeomKey".}
-proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbAddGeomRow".}
-proc XkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, 
-                        sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
-proc XkbAddGeomOverlay*(section: PXkbSectionPtr, name: TAtom, sz_rows: int16): PXkbOverlayPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOverlay".}
-proc XkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, 
-                           sz_keys: int16): PXkbOverlayRowPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
-proc XkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                           over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-proc XkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                       name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbAddGeomDoodad".}
-proc XkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                            freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomKeyAliases".}
-proc XkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomColors".}
-proc XkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, freeAll: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeomDoodads".}
-proc XkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                            freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomProperties".}
-proc XkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOverlayKeys".}
-proc XkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, 
-                             count: int16, freeAll: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
-proc XkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOverlays".}
-proc XkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, freeAll: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeomKeys".}
-proc XkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, 
-                      freeAll: bool){.cdecl, dynlib: libX11, 
-                                      importc: "XkbFreeGeomRows".}
-proc XkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomSections".}
-proc XkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomPoints".}
-proc XkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOutlines".}
-proc XkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomShapes".}
-proc XkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
-proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomProps".}
-proc XkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
-proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomColors".}
-proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomShapes".}
-proc XkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
-proc XkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
-proc XkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
-proc XkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
-proc XkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
-proc XkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
-proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomOutlines".}
-proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomRows".}
-proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomPoints".}
-proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomKeys".}
-proc XkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
-proc XkbSetGeometryProc*(dpy: PDisplay, deviceSpec: int16, geom: PXkbGeometryPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbSetGeometry".}
-proc XkbComputeShapeTop*(shape: PXkbShapePtr, bounds: PXkbBoundsPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbComputeShapeTop".}
-proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeShapeBounds".}
-proc XkbComputeRowBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                          row: PXkbRowPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeRowBounds".}
-proc XkbComputeSectionBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbComputeSectionBounds".}
-proc XkbFindOverlayForKey*(geom: PXkbGeometryPtr, wanted: PXkbSectionPtr, 
-                           under: cstring): cstring{.cdecl, dynlib: libX11, 
-    importc: "XkbFindOverlayForKey".}
-proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetGeometry".}
-proc XkbGetNamedGeometry*(dpy: PDisplay, xkb: PXkbDescPtr, name: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetNamedGeometry".}
-when defined(XKB_IN_SERVER): 
-  proc SrvXkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, 
-                              float: cstring): PXkbKeyAliasPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-  proc SrvXkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
-  proc SrvXkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                            name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, 
-      importc: "XkbAddGeomDoodad".}
-  proc SrvXkbAddGeomKey*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-  proc SrvXkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
-  proc SrvXkbAddGeomOverlay*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                             over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-  proc SrvXkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, 
-                                sz_keys: int16): PXkbOverlayRowPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
-  proc SrvXkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                                over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-  proc SrvXkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, 
-                              value: cstring): PXkbPropertyPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomProperty".}
-  proc SrvXkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomRow".}
-  proc SrvXkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, 
-                             sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
-  proc SrvXkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, 
-                           sz_outlines: int16): PXkbShapePtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomShape".}
-  proc SrvXkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
-  proc SrvXkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomColors".}
-  proc SrvXkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
-  proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, 
-      dynlib: libX11, importc: "XkbAllocGeomKeys".}
-  proc SrvXkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOutlines".}
-  proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, 
-      dynlib: libX11, importc: "XkbAllocGeomPoints".}
-  proc SrvXkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomProps".}
-  proc SrvXkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomRows".}
-  proc SrvXkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
-  proc SrvXkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
-  proc SrvXkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
-  proc SrvXkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
-  proc SrvXkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
-  proc SrvXkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomShapes".}
-  proc SrvXkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
-  proc SrvXkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, 
-                                 count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomKeyAliases".}
-  proc SrvXkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomColors".}
-  proc SrvXkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, 
-                              freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomDoodads".}
-  proc SrvXkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, 
-                                 count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomProperties".}
-  proc SrvXkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, 
-                                  count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlayKeys".}
-  proc SrvXkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, 
-                                  count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
-  proc SrvXkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, 
-                               count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlays".}
-  proc SrvXkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, 
-                           freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomKeys".}
-  proc SrvXkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, 
-                           freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomRows".}
-  proc SrvXkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, 
-                               count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomSections".}
-  proc SrvXkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, 
-                             count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomPoints".}
-  proc SrvXkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, 
-                               freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomOutlines".}
-  proc SrvXkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomShapes".}
-  proc SrvXkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
-      cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
-# implementation
-
-import                        #************************************ xkb ************************************
-  xi
-
-proc XkbLegalXILedClass(c: int): bool = 
-  ##define XkbLegalXILedClass(c) (((c)==KbdFeedbackClass)||((c)==LedFeedbackClass)||
-  #                                ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
-  Result = (c == KbdFeedbackClass) or (c == LedFeedbackClass) or
-      (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
-
-proc XkbLegalXIBellClass(c: int): bool = 
-  ##define XkbLegalXIBellClass(c) (((c)==KbdFeedbackClass)||((c)==BellFeedbackClass)||
-  #                                 ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
-  Result = (c == KbdFeedbackClass) or (c == BellFeedbackClass) or
-      (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
-
-proc XkbExplicitXIDevice(c: int): bool = 
-  ##define XkbExplicitXIDevice(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbExplicitXIClass(c: int): bool = 
-  ##define XkbExplicitXIClass(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbExplicitXIId(c: int): bool = 
-  ##define XkbExplicitXIId(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbSingleXIClass(c: int): bool = 
-  ##define XkbSingleXIClass(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))
-  Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIClass)
-
-proc XkbSingleXIId(c: int): bool = 
-  ##define XkbSingleXIId(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIId))
-  Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIId)
-
-proc XkbBuildCoreState(m, g: int): int = 
-  ##define XkbBuildCoreState(m,g) ((((g)&0x3)<<13)|((m)&0xff))
-  Result = ((g and 0x00000003) shl 13) or (m and 0x000000FF)
-
-proc XkbGroupForCoreState(s: int): int = 
-  ##define XkbGroupForCoreState(s) (((s)>>13)&0x3)
-  Result = (s shr 13) and 0x00000003
-
-proc XkbIsLegalGroup(g: int): bool = 
-  ##define XkbIsLegalGroup(g) (((g)>=0)&&((g)<XkbNumKbdGroups))
-  Result = (g >= 0) and (g < XkbNumKbdGroups)
-
-proc XkbSA_ValOp(a: int): int = 
-  ##define XkbSA_ValOp(a) ((a)&XkbSA_ValOpMask)
-  Result = a and XkbSA_ValOpMask
-
-proc XkbSA_ValScale(a: int): int = 
-  ##define XkbSA_ValScale(a) ((a)&XkbSA_ValScaleMask)
-  Result = a and XkbSA_ValScaleMask
-
-proc XkbIsModAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsModAction(a) (((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))
-  Result = (ze(a.theType) >= XkbSA_SetMods) and (ze(a.theType) <= XkbSA_LockMods)
-
-proc XkbIsGroupAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsGroupAction(a) (((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))
-  Result = (ze(a.theType) >= XkbSA_SetGroup) or (ze(a.theType) <= XkbSA_LockGroup)
-
-proc XkbIsPtrAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsPtrAction(a) (((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))
-  Result = (ze(a.theType) >= XkbSA_MovePtr) and
-      (ze(a.theType) <= XkbSA_SetPtrDflt)
-
-proc XkbIsLegalKeycode(k: int): bool = 
-  ##define        XkbIsLegalKeycode(k)    (((k)>=XkbMinLegalKeyCode)&&((k)<=XkbMaxLegalKeyCode))
-  Result = (k >= XkbMinLegalKeyCode) and (k <= XkbMaxLegalKeyCode)
-
-proc XkbShiftLevel(n: int8): int8 = 
-  ##define XkbShiftLevel(n) ((n)-1)
-  Result = n - 1'i8
-
-proc XkbShiftLevelMask(n: int8): int8 = 
-  ##define XkbShiftLevelMask(n) (1<<((n)-1))
-  Result = 1'i8 shl (n - 1'i8)
-
-proc XkbCharToInt(v: int8): int16 = 
-  ##define XkbCharToInt(v) ((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))
-  if ((v and 0x80'i8) != 0'i8): Result = v or (not 0xFF'i16)
-  else: Result = int16(v and 0x7F'i8)
-  
-proc XkbIntTo2Chars(i: int16, h, L: var int8) = 
-  ##define XkbIntTo2Chars(i,h,l) (((h)=((i>>8)&0xff)),((l)=((i)&0xff)))
-  h = toU8((i shr 8'i16) and 0x00FF'i16)
-  L = toU8(i and 0xFF'i16)
-
-proc Xkb2CharsToInt(h, L: int8): int16 = 
-  when defined(cpu64): 
-    ##define Xkb2CharsToInt(h,l) ((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)): (int)(((h)<<8)|(l)&0x7fff))
-    if (h and 0x80'i8) != 0'i8: 
-      Result = toU16((ze(h) shl 8) or ze(L) or not 0x0000FFFF)
-    else: 
-      Result = toU16((ze(h) shl 8) or ze(L) and 0x00007FFF)
-  else: 
-    ##define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l)))
-    Result = toU16(ze(h) shl 8 or ze(L))
-
-proc XkbModLocks(s: PXkbStatePtr): int8 = 
-  ##define XkbModLocks(s) ((s)->locked_mods)
-  Result = s.locked_mods
-
-proc XkbStateMods(s: PXkbStatePtr): int16 = 
-  ##define XkbStateMods(s) ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))
-  Result = s.base_mods or s.latched_mods or XkbModLocks(s)
-
-proc XkbGroupLock(s: PXkbStatePtr): int8 = 
-  ##define XkbGroupLock(s) ((s)->locked_group)
-  Result = s.locked_group
-
-proc XkbStateGroup(s: PXkbStatePtr): int16 = 
-  ##define XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))
-  Result = S.base_group + (s.latched_group) + XkbGroupLock(s)
-
-proc XkbStateFieldFromRec(s: PXkbStatePtr): int = 
-  ##define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group)
-  Result = XkbBuildCoreState(s.lookup_mods, s.group)
-
-proc XkbGrabStateFromRec(s: PXkbStatePtr): int = 
-  ##define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group)
-  Result = XkbBuildCoreState(s.grab_mods, s.group)
-
-proc XkbNumGroups(g: int16): int16 = 
-  ##define XkbNumGroups(g) ((g)&0x0f)
-  Result = g and 0x0000000F'i16
-
-proc XkbOutOfRangeGroupInfo(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)
-  Result = g and 0x000000F0'i16
-
-proc XkbOutOfRangeGroupAction(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupAction(g) ((g)&0xc0)
-  Result = g and 0x000000C0'i16
-
-proc XkbOutOfRangeGroupNumber(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)
-  Result = (g and 0x00000030'i16) shr 4'i16
-
-proc XkbSetGroupInfo(g, w, n: int16): int16 = 
-  ##define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))
-  Result = (w and 0x000000C0'i16) or 
-    ((n and 3'i16) shl 4'i16) or (g and 0x0000000F'i16)
-
-proc XkbSetNumGroups(g, n: int16): int16 = 
-  ##define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))
-  Result = (g and 0x000000F0'i16) or (n and 0x0000000F'i16)
-
-proc XkbModActionVMods(a: PXkbModAction): int16 = 
-  ##define XkbModActionVMods(a) ((short)(((a)->vmods1<<8)|((a)->vmods2)))
-  Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods2))
-
-proc XkbSetModActionVMods(a: PXkbModAction, v: int8) = 
-  ##define XkbSetModActionVMods(a,v) (((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))
-  a.vmods1 = toU8((ze(v) shr 8) and 0x000000FF)
-  a.vmods2 = toU8(ze(v) and 0x000000FF)
-
-proc XkbSAGroup(a: PXkbGroupAction): int8 = 
-  ##define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX))
-  Result = int8(XkbCharToInt(a.group_XXX))
-
-proc XkbSASetGroupProc(a: PXkbGroupAction, g: int8) = 
-  ##define XkbSASetGroup(a,g) ((a)->group_XXX=(g))
-  a.group_XXX = g
-
-proc XkbPtrActionX(a: PXkbPtrAction): int16 = 
-  ##define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX))
-  Result = int16(Xkb2CharsToInt(a.high_XXX, a.low_XXX))
-
-proc XkbPtrActionY(a: PXkbPtrAction): int16 = 
-  ##define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY))
-  Result = int16(Xkb2CharsToInt(a.high_YYY, a.low_YYY))
-
-proc XkbSetPtrActionX(a: PXkbPtrAction, x: int8) = 
-  ##define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX))
-  XkbIntTo2Chars(x, a.high_XXX, a.low_XXX)
-
-proc XkbSetPtrActionY(a: PXkbPtrAction, y: int8) = 
-  ##define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY))
-  XkbIntTo2Chars(y, a.high_YYY, a.low_YYY)
-
-proc XkbSAPtrDfltValue(a: PXkbPtrDfltAction): int8 = 
-  ##define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX))
-  Result = int8(XkbCharToInt(a.valueXXX))
-
-proc XkbSASetPtrDfltValue(a: PXkbPtrDfltAction, c: pointer) = 
-  ##define XkbSASetPtrDfltValue(a,c) ((a)->valueXXX= ((c)&0xff))
-  a.valueXXX = toU8(cast[int](c))
-
-proc XkbSAScreen(a: PXkbSwitchScreenAction): int8 = 
-  ##define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX))
-  Result = toU8(XkbCharToInt(a.screenXXX))
-
-proc XkbSASetScreen(a: PXkbSwitchScreenAction, s: pointer) = 
-  ##define XkbSASetScreen(a,s) ((a)->screenXXX= ((s)&0xff))
-  a.screenXXX = toU8(cast[int](s))
-
-proc XkbActionSetCtrls(a: PXkbCtrlsAction, c: int8) = 
-  ##define XkbActionSetCtrls(a,c) (((a)->ctrls3=(((c)>>24)&0xff)),((a)->ctrls2=(((c)>>16)&0xff)),
-  #                                 ((a)->ctrls1=(((c)>>8)&0xff)),((a)->ctrls0=((c)&0xff)))        
-  a.ctrls3 = toU8((ze(c) shr 24) and 0x000000FF)
-  a.ctrls2 = toU8((ze(c) shr 16) and 0x000000FF)
-  a.ctrls1 = toU8((ze(c) shr 8) and 0x000000FF)
-  a.ctrls0 = toU8(ze(c) and 0x000000FF)
-
-proc XkbActionCtrls(a: PXkbCtrlsAction): int16 = 
-  ##define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|(((unsigned int)(a)->ctrls2)<<16)|
-  #                            (((unsigned int)(a)->ctrls1)<<8)|((unsigned int)((a)->ctrls0)))      
-  Result = toU16((ze(a.ctrls3) shl 24) or (ze(a.ctrls2) shl 16) or 
-     (ze(a.ctrls1) shl 8) or ze(a.ctrls0))
-
-proc XkbSARedirectVMods(a: PXkbRedirectKeyAction): int16 = 
-  ##define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|((unsigned int)(a)->vmods0))
-  Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods0))
-
-proc XkbSARedirectSetVMods(a: PXkbRedirectKeyAction, m: int8) = 
-  ##define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
-  a.vmods_mask1 = toU8((ze(m) shr 8) and 0x000000FF)
-  a.vmods_mask0 = toU8(ze(m) or 0x000000FF)
-
-proc XkbSARedirectVModsMask(a: PXkbRedirectKeyAction): int16 = 
-  ##define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|
-  #                                     ((unsigned int)(a)->vmods_mask0))
-  Result = toU16((ze(a.vmods_mask1) shl 8) or ze(a.vmods_mask0))
-
-proc XkbSARedirectSetVModsMask(a: PXkbRedirectKeyAction, m: int8) = 
-  ##define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
-  a.vmods_mask1 = toU8(ze(m) shr 8 and 0x000000FF)
-  a.vmods_mask0 = toU8(ze(m) and 0x000000FF)
-
-proc XkbAX_AnyFeedback(c: PXkbControlsPtr): int16 = 
-  ##define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask)
-  Result = toU16(ze(c.enabled_ctrls) and XkbAccessXFeedbackMask)
-
-proc XkbAX_NeedOption(c: PXkbControlsPtr, w: int16): int16 = 
-  ##define XkbAX_NeedOption(c,w) ((c)->ax_options&(w))
-  Result = toU16(ze(c.ax_options) and ze(w))
-
-proc XkbAX_NeedFeedback(c: PXkbControlsPtr, w: int16): bool = 
-  ##define XkbAX_NeedFeedback(c,w) (XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))
-  Result = (XkbAX_AnyFeedback(c) > 0'i16) and (XkbAX_NeedOption(c, w) > 0'i16)
-
-proc XkbSMKeyActionsPtr(m: PXkbServerMapPtr, k: int16): PXkbAction = 
-  ##define XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])
-  Result = addr(m.acts[ze(m.key_acts[ze(k)])])
-
-proc XkbCMKeyGroupInfo(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeyGroupInfo(m,k) ((m)->key_sym_map[k].group_info)
-  Result = m.key_sym_map[ze(k)].group_info
-
-proc XkbCMKeyNumGroups(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeyNumGroups(m,k) (XkbNumGroups((m)->key_sym_map[k].group_info))
-  Result = toU8(XkbNumGroups(m.key_sym_map[ze(k)].group_info))
-
-proc XkbCMKeyGroupWidth(m: PXkbClientMapPtr, k: int16, g: int8): int8 = 
-  ##define XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)
-  Result = XkbCMKeyType(m, k, g).num_levels
-
-proc XkbCMKeyGroupsWidth(m: PXkbClientMapPtr, K: int16): int8 = 
-  ##define XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)
-  Result = m.key_sym_map[ze(k)].width
-
-proc XkbCMKeyTypeIndex(m: PXkbClientMapPtr, k: int16, g: int8): int8 = 
-  ##define XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])
-  Result = m.key_sym_map[ze(k)].kt_index[ze(g) and 0x00000003]
-
-proc XkbCMKeyType(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr = 
-  ##define XkbCMKeyType(m,k,g) (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])
-  Result = addr(m.types[ze(XkbCMKeyTypeIndex(m, k, g))])
-
-proc XkbCMKeyNumSyms(m: PXkbClientMapPtr, k: int16): int16 = 
-  ##define XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))
-  Result = toU16(ze(XkbCMKeyGroupsWidth(m, k)) or ze(XkbCMKeyNumGroups(m, k)))
-
-proc XkbCMKeySymsOffset(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeySymsOffset(m,k) ((m)->key_sym_map[k].offset)
-  Result = m.key_sym_map[ze(k)].offset
-
-proc XkbCMKeySymsPtr*(m: PXkbClientMapPtr, k: int16): PKeySym = 
-  ##define XkbCMKeySymsPtr(m,k) (&(m)->syms[XkbCMKeySymsOffset(m,k)])
-  Result = addr(m.syms[ze(XkbCMKeySymsOffset(m, k))])
-
-proc XkbIM_IsAuto(i: PXkbIndicatorMapPtr): bool = 
-  ##define XkbIM_IsAuto(i) ((((i)->flags&XkbIM_NoAutomatic)==0)&&(((i)->which_groups&&(i)->groups)||
-  #                           ((i)->which_mods&&(i)->mods.mask)||  ((i)->ctrls)))
-  Result = ((ze(i.flags) and XkbIM_NoAutomatic) == 0) and
-      (((i.which_groups > 0'i8) and (i.groups > 0'i8)) or
-      ((i.which_mods > 0'i8) and (i.mods.mask > 0'i8)) or (i.ctrls > 0'i8))
-
-proc XkbIM_InUse(i: PXkbIndicatorMapPtr): bool = 
-  ##define XkbIM_InUse(i) (((i)->flags)||((i)->which_groups)||((i)->which_mods)||((i)->ctrls)) 
-  Result = (i.flags > 0'i8) or (i.which_groups > 0'i8) or (i.which_mods > 0'i8) or
-      (i.ctrls > 0'i8)
-
-proc XkbKeyKeyTypeIndex(d: PXkbDescPtr, k: int16, g: int8): int8 = 
-  ##define XkbKeyKeyTypeIndex(d,k,g)      (XkbCMKeyTypeIndex((d)->map,k,g))
-  Result = XkbCMKeyTypeIndex(d.map, k, g)
-
-proc XkbKeyKeyType(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr = 
-  ##define XkbKeyKeyType(d,k,g) (XkbCMKeyType((d)->map,k,g))
-  Result = XkbCMKeyType(d.map, k, g)
-
-proc XkbKeyGroupWidth(d: PXkbDescPtr, k: int16, g: int8): int8 = 
-  ##define XkbKeyGroupWidth(d,k,g) (XkbCMKeyGroupWidth((d)->map,k,g))
-  Result = XkbCMKeyGroupWidth(d.map, k, g)
-
-proc XkbKeyGroupsWidth(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyGroupsWidth(d,k) (XkbCMKeyGroupsWidth((d)->map,k))
-  Result = XkbCMKeyGroupsWidth(d.map, k)
-
-proc XkbKeyGroupInfo(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k)))
-  Result = XkbCMKeyGroupInfo(d.map, k)
-
-proc XkbKeyNumGroups(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k)))
-  Result = XkbCMKeyNumGroups(d.map, k)
-
-proc XkbKeyNumSyms(d: PXkbDescPtr, k: int16): int16 = 
-  ##define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k)))
-  Result = XkbCMKeyNumSyms(d.map, k)
-
-proc XkbKeySymsPtr*(d: PXkbDescPtr, k: int16): PKeySym = 
-  ##define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k)))
-  Result = XkbCMKeySymsPtr(d.map, k)
-
-proc XkbKeySym(d: PXkbDescPtr, k: int16, n: int16): TKeySym = 
-  ##define XkbKeySym(d,k,n) (XkbKeySymsPtr(d,k)[n])
-  Result = cast[ptr array[0..0xffff, TKeySym]](XkbKeySymsPtr(d, k))[ze(n)] # XXX: this seems strange!
-
-proc XkbKeySymEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym = 
-  ##define XkbKeySymEntry(d,k,sl,g) (XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))
-  Result = XkbKeySym(d, k, toU16(ze(XkbKeyGroupsWidth(d, k)) * ze(g) + ze(sl)))
-
-proc XkbKeyAction(d: PXkbDescPtr, k: int16, n: int16): PXkbAction = 
-  ##define XkbKeyAction(d,k,n) (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)
-  #if (XkbKeyHasActions(d, k)): 
-  #  Result = XkbKeyActionsPtr(d, k)[ze(n)] #Buggy !!!
-  assert(false)
-  result = nil
-  
-proc XkbKeyActionEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8 = 
-  ##define XkbKeyActionEntry(d,k,sl,g) (XkbKeyHasActions(d,k) ?
-  #                                      XkbKeyAction(d, k, ((XkbKeyGroupsWidth(d, k) * (g))+(sl))):NULL)
-  if XkbKeyHasActions(d, k): 
-    Result = XkbKeyGroupsWidth(d, k) *% g +% toU8(sl)
-  else: 
-    Result = 0'i8
-  
-proc XkbKeyHasActions(d: PXkbDescPtr, k: int16): bool = 
-  ##define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0)
-  Result = d.server.key_acts[ze(k)] != 0'i16
-
-proc XkbKeyNumActions(d: PXkbDescPtr, k: int16): int16 = 
-  ##define XkbKeyNumActions(d,k) (XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)
-  if (XkbKeyHasActions(d, k)): Result = XkbKeyNumSyms(d, k)
-  else: Result = 1'i16
-  
-proc XkbKeyActionsPtr(d: PXkbDescPtr, k: int16): PXkbAction = 
-  ##define XkbKeyActionsPtr(d,k) (XkbSMKeyActionsPtr((d)->server,k))
-  Result = XkbSMKeyActionsPtr(d.server, k)
-
-proc XkbKeycodeInRange(d: PXkbDescPtr, k: int16): bool = 
-  ##define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&& ((k)<=(d)->max_key_code))
-  Result = (char(toU8(k)) >= d.min_key_code) and (char(toU8(k)) <= d.max_key_code)
-
-proc XkbNumKeys(d: PXkbDescPtr): int8 = 
-  ##define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1)
-  Result = toU8(ord(d.max_key_code) - ord(d.min_key_code) + 1)
-
-proc XkbXI_DevHasBtnActs(d: PXkbDeviceInfoPtr): bool = 
-  ##define XkbXI_DevHasBtnActs(d) (((d)->num_btns>0)&&((d)->btn_acts!=NULL))
-  Result = (d.num_btns > 0'i16) and (not (d.btn_acts == nil))
-
-proc XkbXI_LegalDevBtn(d: PXkbDeviceInfoPtr, b: int16): bool = 
-  ##define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))
-  Result = XkbXI_DevHasBtnActs(d) and (b <% d.num_btns)
-
-proc XkbXI_DevHasLeds(d: PXkbDeviceInfoPtr): bool = 
-  ##define XkbXI_DevHasLeds(d) (((d)->num_leds>0)&&((d)->leds!=NULL))
-  Result = (d.num_leds > 0'i16) and (not (d.leds == nil))
-
-proc XkbBoundsWidth(b: PXkbBoundsPtr): int16 = 
-  ##define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
-  Result = (b.x2) - b.x1
-
-proc XkbBoundsHeight(b: PXkbBoundsPtr): int16 = 
-  ##define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
-  Result = (b.y2) - b.y1
-
-proc XkbOutlineIndex(s: PXkbShapePtr, o: PXkbOutlinePtr): int32 = 
-  ##define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
-  Result = int32((cast[TAddress](o) - cast[TAddress](addr(s.outlines[0]))) div sizeof(PXkbOutlinePtr))
-
-proc XkbShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr = 
-  ##define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr((g.colors[ze(d.color_ndx)]))
-
-proc XkbShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr = 
-  ##define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = addr(g.shapes[ze(d.shape_ndx)])
-
-proc XkbSetShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                            c: PXkbColorPtr) = 
-  ##define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                            s: PXkbShapePtr) = 
-  ##define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr = 
-  ##define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr(g.colors[ze(d.color_ndx)])
-
-proc XkbSetTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, 
-                           c: PXkbColorPtr) = 
-  ##define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr = 
-  ##define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
-
-proc XkbIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = 
-  ##define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
-  Result = addr(g.colors[ze(d.on_color_ndx)])
-
-proc XkbIndicatorDoodadOffColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = 
-  ##define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
-  Result = addr(g.colors[ze(d.off_color_ndx)])
-
-proc XkbSetIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                  c: PXkbColorPtr) = 
-  ##define XkbSetIndicatorDoodadOnColor(g,d,c) ((d)->on_color_ndx= (c)-&(g)->colors[0])
-  d.on_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetIndicatorDoodadOffColor(g: PXkbGeometryPtr, 
-                                   d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) = 
-  ##define        XkbSetIndicatorDoodadOffColor(g,d,c) ((d)->off_color_ndx= (c)-&(g)->colors[0])
-  d.off_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
-
-proc XkbSetIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetIndicatorDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - (cast[TAddress](addr(g.shapes[0])))) div sizeof(TXkbShapeRec))
-
-proc XkbLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr = 
-  ##define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr(g.colors[ze(d.color_ndx)])
-
-proc XkbLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr = 
-  ##define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
-
-proc XkbSetLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                           c: PXkbColorPtr) = 
-  ##define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                           s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr = 
-  ##define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(k.shape_ndx)]))
-
-proc XkbKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr = 
-  ##define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
-  Result = addr(g.colors[ze(k.color_ndx)])
-
-proc XkbSetKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
-  k.shape_ndx = toU8((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbSetKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr) = 
-  ##define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
-  k.color_ndx = toU8((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
-
-proc XkbGeomColorIndex(g: PXkbGeometryPtr, c: PXkbColorPtr): int32 = 
-  ##define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
-  Result = toU16((cast[TAddress](c) - (cast[TAddress](addr(g.colors[0])))) div sizeof(TxkbColorRec))
diff --git a/lib/oldwrappers/x11/xkblib.nim b/lib/oldwrappers/x11/xkblib.nim
deleted file mode 100755
index 92d438a60..000000000
--- a/lib/oldwrappers/x11/xkblib.nim
+++ /dev/null
@@ -1,699 +0,0 @@
-# $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $
-#************************************************************
-#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-#
-#Permission to use, copy, modify, and distribute this
-#software and its documentation for any purpose and without
-#fee is hereby granted, provided that the above copyright
-#notice appear in all copies and that both that copyright
-#notice and this permission notice appear in supporting
-#documentation, and that the name of Silicon Graphics not be
-#used in advertising or publicity pertaining to distribution
-#of the software without specific prior written permission.
-#Silicon Graphics makes no representation about the suitability
-#of this software for any purpose. It is provided "as is"
-#without any express or implied warranty.
-#
-#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE,
-#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-#THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-#********************************************************/
-# $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $
-#
-# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Thanks:
-#         I want to thanks to oliebol for putting up with all of the problems that was found
-#         while translating this code. ;)
-#
-#         I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
-#         wierd questions ;)
-#
-#         Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
-#         understanding some of the problems I had converting this headers and pointing me to resources
-#         that helped translating this headers.
-#
-# Ido
-#
-#History:
-#        2004/10/15        - Fixed a bug of accessing second based records by removing "paced record" and
-#                            chnaged it to "reocrd" only.
-#        2004/10/10        - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call.
-#        2004/10/06 - 09   - Convertion `from` the c header of XKBlib.h
-#
-#
-
-import 
-  X, Xlib, XKB
-
-type 
-  PXkbAnyEvent* = ptr TXkbAnyEvent
-  TXkbAnyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds;
-    xkb_type*: int16          # XKB event minor code
-    device*: int16            # device ID
-  
-
-type 
-  PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent
-  TXkbNewKeyboardNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbNewKeyboardNotify
-    device*: int16            # device ID
-    old_device*: int16        # device ID of previous keyboard
-    min_key_code*: int16      # minimum key code
-    max_key_code*: int16      # maximum key code
-    old_min_key_code*: int16  # min key code of previous kbd
-    old_max_key_code*: int16  # max key code of previous kbd
-    changed*: int16           # changed aspects of the keyboard
-    req_major*: int8          # major and minor opcode of req
-    req_minor*: int8          # that caused change, if applicable
-  
-
-type 
-  PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent
-  TXkbMapNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbMapNotify
-    device*: int16            # device ID
-    changed*: int16           # fields which have been changed
-    flags*: int16             # reserved
-    first_type*: int16        # first changed key type
-    num_types*: int16         # number of changed key types
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    first_key_sym*: TKeyCode
-    first_key_act*: TKeyCode
-    first_key_behavior*: TKeyCode
-    first_key_explicit*: TKeyCode
-    first_modmap_key*: TKeyCode
-    first_vmodmap_key*: TKeyCode
-    num_key_syms*: int16
-    num_key_acts*: int16
-    num_key_behaviors*: int16
-    num_key_explicit*: int16
-    num_modmap_keys*: int16
-    num_vmodmap_keys*: int16
-    vmods*: int16             # mask of changed virtual mods
-  
-
-type 
-  PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent
-  TXkbStateNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbStateNotify
-    device*: int16            # device ID
-    changed*: int16           # mask of changed state components
-    group*: int16             # keyboard group
-    base_group*: int16        # base keyboard group
-    latched_group*: int16     # latched keyboard group
-    locked_group*: int16      # locked keyboard group
-    mods*: int16              # modifier state
-    base_mods*: int16         # base modifier state
-    latched_mods*: int16      # latched modifiers
-    locked_mods*: int16       # locked modifiers
-    compat_state*: int16      # compatibility state
-    grab_mods*: int8          # mods used for grabs
-    compat_grab_mods*: int8   # grab mods for non-XKB clients
-    lookup_mods*: int8        # mods sent to clients
-    compat_lookup_mods*: int8 # mods sent to non-XKB clients
-    ptr_buttons*: int16       # pointer button state
-    keycode*: TKeyCode        # keycode that caused the change
-    event_type*: int8         # KeyPress or KeyRelease
-    req_major*: int8          # Major opcode of request
-    req_minor*: int8          # Minor opcode of request
-  
-
-type 
-  PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent
-  TXkbControlsNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbControlsNotify
-    device*: int16            # device ID
-    changed_ctrls*: int16     # controls with changed sub-values
-    enabled_ctrls*: int16     # controls currently enabled
-    enabled_ctrl_changes*: int16 # controls just {en,dis}abled
-    num_groups*: int16        # total groups on keyboard
-    keycode*: TKeyCode        # key that caused change or 0
-    event_type*: int8         # type of event that caused change
-    req_major*: int8          # if keycode==0, major and minor
-    req_minor*: int8          # opcode of req that caused change
-  
-
-type 
-  PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent
-  TXkbIndicatorNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbIndicatorNotify
-    device*: int16            # device
-    changed*: int16           # indicators with new state or map
-    state*: int16             # current state of all indicators
-  
-
-type 
-  PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent
-  TXkbNamesNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbNamesNotify
-    device*: int16            # device ID
-    changed*: int32           # names that have changed
-    first_type*: int16        # first key type with new name
-    num_types*: int16         # number of key types with new names
-    first_lvl*: int16         # first key type new new level names
-    num_lvls*: int16          # # of key types w/new level names
-    num_aliases*: int16       # total number of key aliases
-    num_radio_groups*: int16  # total number of radio groups
-    changed_vmods*: int16     # virtual modifiers with new names
-    changed_groups*: int16    # groups with new names
-    changed_indicators*: int16 # indicators with new names
-    first_key*: int16         # first key with new name
-    num_keys*: int16          # number of keys with new names
-  
-
-type 
-  PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent
-  TXkbCompatMapNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbCompatMapNotify
-    device*: int16            # device ID
-    changed_groups*: int16    # groups with new compat maps
-    first_si*: int16          # first new symbol interp
-    num_si*: int16            # number of new symbol interps
-    num_total_si*: int16      # total # of symbol interps
-  
-
-type 
-  PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent
-  TXkbBellNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbBellNotify
-    device*: int16            # device ID
-    percent*: int16           # requested volume as a % of maximum
-    pitch*: int16             # requested pitch in Hz
-    duration*: int16          # requested duration in useconds
-    bell_class*: int16        # (input extension) feedback class
-    bell_id*: int16           # (input extension) ID of feedback
-    name*: TAtom              # "name" of requested bell
-    window*: TWindow          # window associated with event
-    event_only*: bool         # "event only" requested
-  
-
-type 
-  PXkbActionMessageEvent* = ptr TXkbActionMessageEvent
-  TXkbActionMessageEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbActionMessage
-    device*: int16            # device ID
-    keycode*: TKeyCode        # key that generated the event
-    press*: bool              # true if act caused by key press
-    key_event_follows*: bool  # true if key event also generated
-    group*: int16             # effective group
-    mods*: int16              # effective mods
-    message*: array[0..XkbActionMessageLength, Char] # message -- leave space for NUL
-  
-
-type 
-  PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent
-  TXkbAccessXNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbAccessXNotify
-    device*: int16            # device ID
-    detail*: int16            # XkbAXN_*
-    keycode*: int16           # key of event
-    sk_delay*: int16          # current slow keys delay
-    debounce_delay*: int16    # current debounce delay
-  
-
-type 
-  PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent
-  TXkbExtensionDeviceNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbExtensionDeviceNotify
-    device*: int16            # device ID
-    reason*: int16            # reason for the event
-    supported*: int16         # mask of supported features
-    unsupported*: int16       # mask of unsupported features
-                              # that some app tried to use
-    first_btn*: int16         # first button that changed
-    num_btns*: int16          # range of buttons changed
-    leds_defined*: int16      # indicators with names or maps
-    led_state*: int16         # current state of the indicators
-    led_class*: int16         # feedback class for led changes
-    led_id*: int16            # feedback id for led changes
-  
-
-type 
-  PXkbEvent* = ptr TXkbEvent
-  TXkbEvent*{.final.} = object 
-    theType*: int16
-    any*: TXkbAnyEvent
-    new_kbd*: TXkbNewKeyboardNotifyEvent
-    map*: TXkbMapNotifyEvent
-    state*: TXkbStateNotifyEvent
-    ctrls*: TXkbControlsNotifyEvent
-    indicators*: TXkbIndicatorNotifyEvent
-    names*: TXkbNamesNotifyEvent
-    compat*: TXkbCompatMapNotifyEvent
-    bell*: TXkbBellNotifyEvent
-    message*: TXkbActionMessageEvent
-    accessx*: TXkbAccessXNotifyEvent
-    device*: TXkbExtensionDeviceNotifyEvent
-    core*: TXEvent
-
-
-type
-  PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec
-  TXkbKbdDpyStateRec*{.final.} = object  # XkbOpenDisplay error codes 
-
-const 
-  XkbOD_Success* = 0
-  XkbOD_BadLibraryVersion* = 1
-  XkbOD_ConnectionRefused* = 2
-  XkbOD_NonXkbServer* = 3
-  XkbOD_BadServerVersion* = 4 # Values for XlibFlags 
-
-const 
-  XkbLC_ForceLatin1Lookup* = 1 shl 0
-  XkbLC_ConsumeLookupMods* = 1 shl 1
-  XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2
-  XkbLC_IgnoreNewKeyboards* = 1 shl 3
-  XkbLC_ControlFallback* = 1 shl 4
-  XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29
-  XkbLC_ComposeLED* = 1 shl 30
-  XkbLC_BeepOnComposeFail* = 1 shl 31
-  XkbLC_AllComposeControls* = 0xC0000000
-  XkbLC_AllControls* = 0xC000001F
-
-proc XkbIgnoreExtension*(ignore: bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbIgnoreExtension".}
-proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn, 
-                                    reason: ptr int16): PDisplay{.cdecl, 
-    dynlib: libX11, importc: "XkbOpenDisplay".}
-proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn, 
-                                       errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbQueryExtension".}
-proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbUseExtension".}
-proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLibraryVersion".}
-proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbSetXlibControls".}
-proc XkbGetXlibControls*(dpy: PDisplay): int16{.cdecl, dynlib: libX11, 
-    importc: "XkbGetXlibControls".}
-type 
-  TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{.
-      cdecl.}
-
-type 
-  TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
-
-proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
-    cdecl, dynlib: libX11, importc: "XkbSetAtomFuncs".}
-proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
-    cdecl, dynlib: libX11, importc: "XkbKeycodeToKeysym".}
-proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbKeysymToModifiers".}
-proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode, 
-                      modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLookupKeySym".}
-proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16, 
-                          buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
-    cdecl, dynlib: libX11, importc: "XkbLookupKeyBinding".}
-proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode, 
-                          modifiers, modifiers_return: int16, 
-                          keysym_return: PKeySym): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbTranslateKeyCode".}
-proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16, 
-                         buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
-    cdecl, dynlib: libX11, importc: "XkbTranslateKeySym".}
-proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetAutoRepeatRate".}
-proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16, 
-                           delayRtrn, intervalRtrn: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetAutoRepeatRate".}
-proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbChangeEnabledControls".}
-proc XkbDeviceBell*(dpy: PDisplay, win: TWindow, 
-                    deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbDeviceBell".}
-proc XkbForceDeviceBell*(dpy: PDisplay, 
-                         deviceSpec, bellClass, bellID, percent: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbForceDeviceBell".}
-proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow, 
-                         deviceSpec, bellClass, bellID, percent: int16, 
-                         name: TAtom): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbDeviceBellEvent".}
-proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbBell".}
-proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbForceBell".}
-proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbBellEvent".}
-proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSelectEvents".}
-proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16, 
-                            affect, details: int32): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSelectEventDetails".}
-proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent, 
-                        wanted: int16){.cdecl, dynlib: libX11, 
-                                        importc: "XkbNoteMapChanges".}
-proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent, 
-                         wanted: int16){.cdecl, dynlib: libX11, 
-    importc: "XkbNoteNameChanges".}
-proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetIndicatorState".}
-proc XkbGetDeviceIndicatorState*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 pStateRtrn: PWord): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceIndicatorState".}
-proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetIndicatorMap".}
-proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetIndicatorMap".}
-proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
-proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
-proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr, 
-                                c: PXkbIndicatorChangesPtr): TStatus
-proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr, 
-                             c: PXkbIndicatorChangesPtr): bool
-proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16, 
-                           pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr, 
-                           pRealRtrn: ptr bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbGetNamedIndicator".}
-proc XkbGetNamedDeviceIndicator*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 name: TAtom, pNdxRtrn: ptr int16, 
-                                 pStateRtrn: ptr bool, 
-                                 pMapRtrn: PXkbIndicatorMapPtr, 
-                                 pRealRtrn: ptr bool): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetNamedDeviceIndicator".}
-proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom, 
-                           changeState, state, createNewMap: bool, 
-                           pMap: PXkbIndicatorMapPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetNamedIndicator".}
-proc XkbSetNamedDeviceIndicator*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 name: TAtom, 
-                                 changeState, state, createNewMap: bool, 
-                                 pMap: PXkbIndicatorMapPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetNamedDeviceIndicator".}
-proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLockModifiers".}
-proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLatchModifiers".}
-proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLockGroup".}
-proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLatchGroup".}
-proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal, 
-    realValues, affectVirtual, virtualValues: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetServerInternalMods".}
-proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues, 
-    affectVirtual, virtualValues: int16): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetIgnoreLockMods".}
-proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbVirtualModsToReal".}
-proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr, 
-                             map_rtrn: PByte): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeEffectiveMap".}
-proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbInitCanonicalKeyTypes".}
-proc XkbAllocKeyboard*(): PXkbDescPtr{.cdecl, dynlib: libX11, 
-                                       importc: "XkbAllocKeyboard".}
-proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeKeyboard".}
-proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocClientMap".}
-proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocServerMap".}
-proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeClientMap".}
-proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeServerMap".}
-proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16, 
-                    want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddKeyType".}
-proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbAllocIndicatorMaps".}
-proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeIndicatorMaps".}
-proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbGetMap".}
-proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetUpdatedMap".}
-proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr, 
-                       changes: PXkbMapChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetMapChanges".}
-proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbRefreshKeyboardMapping".}
-proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyTypes".}
-proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeySyms".}
-proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyActions".}
-proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16, 
-                         desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyBehaviors".}
-proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetVirtualMods".}
-proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16, 
-                                  desc: PXkbDescPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetKeyExplicitComponents".}
-proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16, 
-                           desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyModifierMap".}
-proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocControls".}
-proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeControls".}
-proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetControls".}
-proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetControls".}
-proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr, 
-                             new: PXkbControlsNotifyEvent, wanted: int16){.
-    cdecl, dynlib: libX11, importc: "XkbNoteControlsChanges".}
-proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr, 
-                            c: PXkbControlsChangesPtr): TStatus
-proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool
-proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocCompatMap".}
-proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeCompatMap".}
-proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetCompatMap".}
-proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr, 
-                      updateActions: bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetCompatMap".}
-proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr, 
-                         updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddSymInterpret".}
-proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16, 
-                    nTotalRG, nTotalAliases: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocNames".}
-proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetNames".}
-proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16, 
-                  desc: PXkbDescPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetNames".}
-proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr, 
-                     changes: PXkbNameChangesPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbChangeNames".}
-proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeNames".}
-proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetState".}
-proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetMap".}
-proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbChangeMap".}
-proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool, 
-                                 supported: ptr bool): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDetectableAutoRepeat".}
-proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
-    cdecl, dynlib: libX11, importc: "XkbGetDetectableAutoRepeat".}
-proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16, 
-                              auto_ctrls, auto_values: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetAutoResetControls".}
-proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbGetAutoResetControls".}
-proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetPerClientControls".}
-proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetPerClientControls".}
-proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbCopyKeyType".}
-proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbCopyKeyTypes".}
-proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16, 
-                       want_preserve: bool, new_num_lvls: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeyType".}
-proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeySyms".}
-proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeyActions".}
-proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16, 
-                          groups: int16, newTypes: ptr int16, 
-                          pChanges: PXkbMapChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbChangeTypesOfKey".}
-    
-proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16, 
-                        ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
-    cdecl, dynlib: libX11, importc: "XkbListComponents".}
-proc XkbFreeComponentList*(list: PXkbComponentListPtr){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeComponentList".}
-proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyboard".}
-proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16, 
-                           names: PXkbComponentNamesPtr, want, need: int16, 
-                           load: bool): PXkbDescPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyboardByName".}
-    
-proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr, 
-                                map_width: int16,  # keyboard device
-                                core_syms: PKeySym,  # always mapWidth symbols
-                                protected: int16,  # explicit key types
-                                types_inout: ptr int16,  # always four type indices
-                                xkb_syms_rtrn: PKeySym): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbKeyTypesForCoreSymbols".}
-  # must have enough space
-proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr,  
-                             key: TKeyCode,  # key to be updated
-                             changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbApplyCompatMapToKey".}
-  # resulting changes to map
-proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr,  
-                           first_key: TKeyCode,  # first changed key
-                           num_keys,
-                           map_width: int16, 
-                           core_keysyms: PKeySym,  # symbols `from` core keymap
-                           changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbUpdateMapFromCore".}
-
-proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddDeviceLedInfo".}
-proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbResizeDeviceButtonActions".}
-proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAllocDeviceInfo".}
-proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeDeviceInfo".}
-proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr, 
-                           new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
-    cdecl, dynlib: libX11, importc: "XkbNoteDeviceChanges".}
-proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbGetDeviceInfo".}
-proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                              changes: PXkbDeviceChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceInfoChanges".}
-proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                                all: bool, first, nBtns: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceButtonActions".}
-proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                          ledClass, ledId, which: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceLedInfo".}
-proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetDeviceInfo".}
-proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr, 
-                          changes: PXkbDeviceChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbChangeDeviceInfo".}
-proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                          ledClass, ledID, which: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDeviceLedInfo".}
-proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                                first, nBtns: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDeviceButtonActions".}
-
-proc XkbToControl*(c: int8): int8{.cdecl, dynlib: libX11, 
-                                   importc: "XkbToControl".}
-
-proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring, 
-                           ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetDebuggingFlags".}
-proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16, 
-                                changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbApplyVirtualModChanges".}
-
-# implementation
-
-proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = 
-  ##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w)))
-  o.map_changes = o.map_changes or (n.map_changes and w)
-
-proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = 
-  ##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w)))
-  o.state_changes = o.state_changes or (n.state_changes and (w))
-
-proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr, 
-                               c: PXkbIndicatorChangesPtr): TStatus = 
-  ##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x)
-  Result = XkbGetIndicatorMap(d, c.map_changes, x)
-
-proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr, 
-                            c: PXkbIndicatorChangesPtr): bool = 
-  ##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x))
-  Result = XkbSetIndicatorMap(d, c.map_changes, x)
-
-proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr, 
-                           c: PXkbControlsChangesPtr): TStatus = 
-  ##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
-  Result = XkbGetControls(d, c.changed_ctrls, x)
-
-proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool = 
-  ##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
-  Result = XkbSetControls(d, c.changed_ctrls, x)
diff --git a/lib/oldwrappers/x11/xlib.nim b/lib/oldwrappers/x11/xlib.nim
deleted file mode 100755
index 19ebda9e0..000000000
--- a/lib/oldwrappers/x11/xlib.nim
+++ /dev/null
@@ -1,2218 +0,0 @@
-
-import 
-  x
-
-const 
-  libX11* = "libX11.so"
-
-type
-  cuint* = cint
-  cunsigned* = cint
-  cushort* = int16
-  Pcint* = ptr cint
-  PPcint* = ptr Pcint
-  PPcuchar* = ptr ptr cuchar
-  PWideChar* = ptr int16
-  PPChar* = ptr cstring
-  PPPChar* = ptr ptr cstring
-  Pculong* = ptr int
-  Pcuchar* = cstring
-  Pcuint* = ptr cint
-  Pcushort* = ptr int16
-#  Automatically converted by H2Pas 0.99.15 from xlib.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xlib.h
-
-const 
-  XlibSpecificationRelease* = 6
-
-type 
-  PXPointer* = ptr TXPointer
-  TXPointer* = ptr char
-  PBool* = ptr TBool
-  TBool* = int           #cint?
-  PStatus* = ptr TStatus
-  TStatus* = cint
-
-const 
-  QueuedAlready* = 0
-  QueuedAfterReading* = 1
-  QueuedAfterFlush* = 2
-
-type 
-  PPXExtData* = ptr PXExtData
-  PXExtData* = ptr TXExtData
-  TXExtData*{.final.} = object 
-    number*: cint
-    next*: PXExtData
-    free_private*: proc (extension: PXExtData): cint{.cdecl.}
-    private_data*: TXPointer
-
-  PXExtCodes* = ptr TXExtCodes
-  TXExtCodes*{.final.} = object 
-    extension*: cint
-    major_opcode*: cint
-    first_event*: cint
-    first_error*: cint
-
-  PXPixmapFormatValues* = ptr TXPixmapFormatValues
-  TXPixmapFormatValues*{.final.} = object 
-    depth*: cint
-    bits_per_pixel*: cint
-    scanline_pad*: cint
-
-  PXGCValues* = ptr TXGCValues
-  TXGCValues*{.final.} = object 
-    function*: cint
-    plane_mask*: culong
-    foreground*: culong
-    background*: culong
-    line_width*: cint
-    line_style*: cint
-    cap_style*: cint
-    join_style*: cint
-    fill_style*: cint
-    fill_rule*: cint
-    arc_mode*: cint
-    tile*: TPixmap
-    stipple*: TPixmap
-    ts_x_origin*: cint
-    ts_y_origin*: cint
-    font*: TFont
-    subwindow_mode*: cint
-    graphics_exposures*: TBool
-    clip_x_origin*: cint
-    clip_y_origin*: cint
-    clip_mask*: TPixmap
-    dash_offset*: cint
-    dashes*: cchar
-
-  PXGC* = ptr TXGC
-  TXGC*{.final.} = object 
-  TGC* = PXGC
-  PGC* = ptr TGC
-  PVisual* = ptr TVisual
-  TVisual*{.final.} = object 
-    ext_data*: PXExtData
-    visualid*: TVisualID
-    c_class*: cint
-    red_mask*, green_mask*, blue_mask*: culong
-    bits_per_rgb*: cint
-    map_entries*: cint
-
-  PDepth* = ptr TDepth
-  TDepth*{.final.} = object 
-    depth*: cint
-    nvisuals*: cint
-    visuals*: PVisual
-
-  PXDisplay* = ptr TXDisplay
-  TXDisplay*{.final.} = object 
-  PScreen* = ptr TScreen
-  TScreen*{.final.} = object 
-    ext_data*: PXExtData
-    display*: PXDisplay
-    root*: TWindow
-    width*, height*: cint
-    mwidth*, mheight*: cint
-    ndepths*: cint
-    depths*: PDepth
-    root_depth*: cint
-    root_visual*: PVisual
-    default_gc*: TGC
-    cmap*: TColormap
-    white_pixel*: culong
-    black_pixel*: culong
-    max_maps*, min_maps*: cint
-    backing_store*: cint
-    save_unders*: TBool
-    root_input_mask*: clong
-
-  PScreenFormat* = ptr TScreenFormat
-  TScreenFormat*{.final.} = object 
-    ext_data*: PXExtData
-    depth*: cint
-    bits_per_pixel*: cint
-    scanline_pad*: cint
-
-  PXSetWindowAttributes* = ptr TXSetWindowAttributes
-  TXSetWindowAttributes*{.final.} = object 
-    background_pixmap*: TPixmap
-    background_pixel*: culong
-    border_pixmap*: TPixmap
-    border_pixel*: culong
-    bit_gravity*: cint
-    win_gravity*: cint
-    backing_store*: cint
-    backing_planes*: culong
-    backing_pixel*: culong
-    save_under*: TBool
-    event_mask*: clong
-    do_not_propagate_mask*: clong
-    override_redirect*: TBool
-    colormap*: TColormap
-    cursor*: TCursor
-
-  PXWindowAttributes* = ptr TXWindowAttributes
-  TXWindowAttributes*{.final.} = object 
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    depth*: cint
-    visual*: PVisual
-    root*: TWindow
-    c_class*: cint
-    bit_gravity*: cint
-    win_gravity*: cint
-    backing_store*: cint
-    backing_planes*: culong
-    backing_pixel*: culong
-    save_under*: TBool
-    colormap*: TColormap
-    map_installed*: TBool
-    map_state*: cint
-    all_event_masks*: clong
-    your_event_mask*: clong
-    do_not_propagate_mask*: clong
-    override_redirect*: TBool
-    screen*: PScreen
-
-  PXHostAddress* = ptr TXHostAddress
-  TXHostAddress*{.final.} = object 
-    family*: cint
-    len*: cint
-    address*: cstring
-
-  PXServerInterpretedAddress* = ptr TXServerInterpretedAddress
-  TXServerInterpretedAddress*{.final.} = object 
-    typelength*: cint
-    valuelength*: cint
-    theType*: cstring
-    value*: cstring
-
-  PXImage* = ptr TXImage
-  TF*{.final.} = object 
-    create_image*: proc (para1: PXDisplay, para2: PVisual, para3: cuint, 
-                         para4: cint, para5: cint, para6: cstring, para7: cuint, 
-                         para8: cuint, para9: cint, para10: cint): PXImage{.
-        cdecl.}
-    destroy_image*: proc (para1: PXImage): cint{.cdecl.}
-    get_pixel*: proc (para1: PXImage, para2: cint, para3: cint): culong{.cdecl.}
-    put_pixel*: proc (para1: PXImage, para2: cint, para3: cint, para4: culong): cint{.
-        cdecl.}
-    sub_image*: proc (para1: PXImage, para2: cint, para3: cint, para4: cuint, 
-                      para5: cuint): PXImage{.cdecl.}
-    add_pixel*: proc (para1: PXImage, para2: clong): cint{.cdecl.}
-
-  TXImage*{.final.} = object 
-    width*, height*: cint
-    xoffset*: cint
-    format*: cint
-    data*: cstring
-    byte_order*: cint
-    bitmap_unit*: cint
-    bitmap_bit_order*: cint
-    bitmap_pad*: cint
-    depth*: cint
-    bytes_per_line*: cint
-    bits_per_pixel*: cint
-    red_mask*: culong
-    green_mask*: culong
-    blue_mask*: culong
-    obdata*: TXPointer
-    f*: TF
-
-  PXWindowChanges* = ptr TXWindowChanges
-  TXWindowChanges*{.final.} = object 
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    sibling*: TWindow
-    stack_mode*: cint
-
-  PXColor* = ptr TXColor
-  TXColor*{.final.} = object 
-    pixel*: culong
-    red*, green*, blue*: cushort
-    flags*: cchar
-    pad*: cchar
-
-  PXSegment* = ptr TXSegment
-  TXSegment*{.final.} = object 
-    x1*, y1*, x2*, y2*: cshort
-
-  PXPoint* = ptr TXPoint
-  TXPoint*{.final.} = object 
-    x*, y*: cshort
-
-  PXRectangle* = ptr TXRectangle
-  TXRectangle*{.final.} = object 
-    x*, y*: cshort
-    width*, height*: cushort
-
-  PXArc* = ptr TXArc
-  TXArc*{.final.} = object 
-    x*, y*: cshort
-    width*, height*: cushort
-    angle1*, angle2*: cshort
-
-  PXKeyboardControl* = ptr TXKeyboardControl
-  TXKeyboardControl*{.final.} = object 
-    key_click_percent*: cint
-    bell_percent*: cint
-    bell_pitch*: cint
-    bell_duration*: cint
-    led*: cint
-    led_mode*: cint
-    key*: cint
-    auto_repeat_mode*: cint
-
-  PXKeyboardState* = ptr TXKeyboardState
-  TXKeyboardState*{.final.} = object 
-    key_click_percent*: cint
-    bell_percent*: cint
-    bell_pitch*, bell_duration*: cuint
-    led_mask*: culong
-    global_auto_repeat*: cint
-    auto_repeats*: array[0..31, cchar]
-
-  PXTimeCoord* = ptr TXTimeCoord
-  TXTimeCoord*{.final.} = object 
-    time*: TTime
-    x*, y*: cshort
-
-  PXModifierKeymap* = ptr TXModifierKeymap
-  TXModifierKeymap*{.final.} = object 
-    max_keypermod*: cint
-    modifiermap*: PKeyCode
-
-  PDisplay* = ptr TDisplay
-  TDisplay* = TXDisplay
-  PXPrivate* = ptr TXPrivate
-  TXPrivate*{.final.} = object 
-  PXrmHashBucketRec* = ptr TXrmHashBucketRec
-  TXrmHashBucketRec*{.final.} = object 
-  PXPrivDisplay* = ptr TXPrivDisplay
-  TXPrivDisplay*{.final.} = object 
-    ext_data*: PXExtData
-    private1*: PXPrivate
-    fd*: cint
-    private2*: cint
-    proto_major_version*: cint
-    proto_minor_version*: cint
-    vendor*: cstring
-    private3*: TXID
-    private4*: TXID
-    private5*: TXID
-    private6*: cint
-    resource_alloc*: proc (para1: PXDisplay): TXID{.cdecl.}
-    byte_order*: cint
-    bitmap_unit*: cint
-    bitmap_pad*: cint
-    bitmap_bit_order*: cint
-    nformats*: cint
-    pixmap_format*: PScreenFormat
-    private8*: cint
-    release*: cint
-    private9*, private10*: PXPrivate
-    qlen*: cint
-    last_request_read*: culong
-    request*: culong
-    private11*: TXPointer
-    private12*: TXPointer
-    private13*: TXPointer
-    private14*: TXPointer
-    max_request_size*: cunsigned
-    db*: PXrmHashBucketRec
-    private15*: proc (para1: PXDisplay): cint{.cdecl.}
-    display_name*: cstring
-    default_screen*: cint
-    nscreens*: cint
-    screens*: PScreen
-    motion_buffer*: culong
-    private16*: culong
-    min_keycode*: cint
-    max_keycode*: cint
-    private17*: TXPointer
-    private18*: TXPointer
-    private19*: cint
-    xdefaults*: cstring
-
-  PXKeyEvent* = ptr TXKeyEvent
-  TXKeyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    keycode*: cuint
-    same_screen*: TBool
-
-  PXKeyPressedEvent* = ptr TXKeyPressedEvent
-  TXKeyPressedEvent* = TXKeyEvent
-  PXKeyReleasedEvent* = ptr TXKeyReleasedEvent
-  TXKeyReleasedEvent* = TXKeyEvent
-  PXButtonEvent* = ptr TXButtonEvent
-  TXButtonEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    button*: cuint
-    same_screen*: TBool
-
-  PXButtonPressedEvent* = ptr TXButtonPressedEvent
-  TXButtonPressedEvent* = TXButtonEvent
-  PXButtonReleasedEvent* = ptr TXButtonReleasedEvent
-  TXButtonReleasedEvent* = TXButtonEvent
-  PXMotionEvent* = ptr TXMotionEvent
-  TXMotionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    is_hint*: cchar
-    same_screen*: TBool
-
-  PXPointerMovedEvent* = ptr TXPointerMovedEvent
-  TXPointerMovedEvent* = TXMotionEvent
-  PXCrossingEvent* = ptr TXCrossingEvent
-  TXCrossingEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    mode*: cint
-    detail*: cint
-    same_screen*: TBool
-    focus*: TBool
-    state*: cuint
-
-  PXEnterWindowEvent* = ptr TXEnterWindowEvent
-  TXEnterWindowEvent* = TXCrossingEvent
-  PXLeaveWindowEvent* = ptr TXLeaveWindowEvent
-  TXLeaveWindowEvent* = TXCrossingEvent
-  PXFocusChangeEvent* = ptr TXFocusChangeEvent
-  TXFocusChangeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    mode*: cint
-    detail*: cint
-
-  PXFocusInEvent* = ptr TXFocusInEvent
-  TXFocusInEvent* = TXFocusChangeEvent
-  PXFocusOutEvent* = ptr TXFocusOutEvent
-  TXFocusOutEvent* = TXFocusChangeEvent
-  PXKeymapEvent* = ptr TXKeymapEvent
-  TXKeymapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    key_vector*: array[0..31, cchar]
-
-  PXExposeEvent* = ptr TXExposeEvent
-  TXExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    count*: cint
-
-  PXGraphicsExposeEvent* = ptr TXGraphicsExposeEvent
-  TXGraphicsExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    x*, y*: cint
-    width*, height*: cint
-    count*: cint
-    major_code*: cint
-    minor_code*: cint
-
-  PXNoExposeEvent* = ptr TXNoExposeEvent
-  TXNoExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    major_code*: cint
-    minor_code*: cint
-
-  PXVisibilityEvent* = ptr TXVisibilityEvent
-  TXVisibilityEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    state*: cint
-
-  PXCreateWindowEvent* = ptr TXCreateWindowEvent
-  TXCreateWindowEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    override_redirect*: TBool
-
-  PXDestroyWindowEvent* = ptr TXDestroyWindowEvent
-  TXDestroyWindowEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-
-  PXUnmapEvent* = ptr TXUnmapEvent
-  TXUnmapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    from_configure*: TBool
-
-  PXMapEvent* = ptr TXMapEvent
-  TXMapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    override_redirect*: TBool
-
-  PXMapRequestEvent* = ptr TXMapRequestEvent
-  TXMapRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-
-  PXReparentEvent* = ptr TXReparentEvent
-  TXReparentEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    parent*: TWindow
-    x*, y*: cint
-    override_redirect*: TBool
-
-  PXConfigureEvent* = ptr TXConfigureEvent
-  TXConfigureEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    above*: TWindow
-    override_redirect*: TBool
-
-  PXGravityEvent* = ptr TXGravityEvent
-  TXGravityEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    x*, y*: cint
-
-  PXResizeRequestEvent* = ptr TXResizeRequestEvent
-  TXResizeRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    width*, height*: cint
-
-  PXConfigureRequestEvent* = ptr TXConfigureRequestEvent
-  TXConfigureRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    above*: TWindow
-    detail*: cint
-    value_mask*: culong
-
-  PXCirculateEvent* = ptr TXCirculateEvent
-  TXCirculateEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    place*: cint
-
-  PXCirculateRequestEvent* = ptr TXCirculateRequestEvent
-  TXCirculateRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    place*: cint
-
-  PXPropertyEvent* = ptr TXPropertyEvent
-  TXPropertyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    atom*: TAtom
-    time*: TTime
-    state*: cint
-
-  PXSelectionClearEvent* = ptr TXSelectionClearEvent
-  TXSelectionClearEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    selection*: TAtom
-    time*: TTime
-
-  PXSelectionRequestEvent* = ptr TXSelectionRequestEvent
-  TXSelectionRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    owner*: TWindow
-    requestor*: TWindow
-    selection*: TAtom
-    target*: TAtom
-    property*: TAtom
-    time*: TTime
-
-  PXSelectionEvent* = ptr TXSelectionEvent
-  TXSelectionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    requestor*: TWindow
-    selection*: TAtom
-    target*: TAtom
-    property*: TAtom
-    time*: TTime
-
-  PXColormapEvent* = ptr TXColormapEvent
-  TXColormapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    colormap*: TColormap
-    c_new*: TBool
-    state*: cint
-
-  PXClientMessageEvent* = ptr TXClientMessageEvent
-  TXClientMessageEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    message_type*: TAtom
-    format*: cint
-    data*: array[0..19, char]
-
-  PXMappingEvent* = ptr TXMappingEvent
-  TXMappingEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    request*: cint
-    first_keycode*: cint
-    count*: cint
-
-  PXErrorEvent* = ptr TXErrorEvent
-  TXErrorEvent*{.final.} = object 
-    theType*: cint
-    display*: PDisplay
-    resourceid*: TXID
-    serial*: culong
-    error_code*: cuchar
-    request_code*: cuchar
-    minor_code*: cuchar
-
-  PXAnyEvent* = ptr TXAnyEvent
-  TXAnyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-
-  PXEvent* = ptr TXEvent
-  TXEvent*{.final.} = object 
-    theType*: cint
-    pad*: array[0..22, clong] #
-                              #       case longint of
-                              #          0 : ( theType : cint );
-                              #          1 : ( xany : TXAnyEvent );
-                              #          2 : ( xkey : TXKeyEvent );
-                              #          3 : ( xbutton : TXButtonEvent );
-                              #          4 : ( xmotion : TXMotionEvent );
-                              #          5 : ( xcrossing : TXCrossingEvent );
-                              #          6 : ( xfocus : TXFocusChangeEvent );
-                              #          7 : ( xexpose : TXExposeEvent );
-                              #          8 : ( xgraphicsexpose : TXGraphicsExposeEvent );
-                              #          9 : ( xnoexpose : TXNoExposeEvent );
-                              #          10 : ( xvisibility : TXVisibilityEvent );
-                              #          11 : ( xcreatewindow : TXCreateWindowEvent );
-                              #          12 : ( xdestroywindow : TXDestroyWindowEvent );
-                              #          13 : ( xunmap : TXUnmapEvent );
-                              #          14 : ( xmap : TXMapEvent );
-                              #          15 : ( xmaprequest : TXMapRequestEvent );
-                              #          16 : ( xreparent : TXReparentEvent );
-                              #          17 : ( xconfigure : TXConfigureEvent );
-                              #          18 : ( xgravity : TXGravityEvent );
-                              #          19 : ( xresizerequest : TXResizeRequestEvent );
-                              #          20 : ( xconfigurerequest : TXConfigureRequestEvent );
-                              #          21 : ( xcirculate : TXCirculateEvent );
-                              #          22 : ( xcirculaterequest : TXCirculateRequestEvent );
-                              #          23 : ( xproperty : TXPropertyEvent );
-                              #          24 : ( xselectionclear : TXSelectionClearEvent );
-                              #          25 : ( xselectionrequest : TXSelectionRequestEvent );
-                              #          26 : ( xselection : TXSelectionEvent );
-                              #          27 : ( xcolormap : TXColormapEvent );
-                              #          28 : ( xclient : TXClientMessageEvent );
-                              #          29 : ( xmapping : TXMappingEvent );
-                              #          30 : ( xerror : TXErrorEvent );
-                              #          31 : ( xkeymap : TXKeymapEvent );
-                              #          32 : ( pad : array[0..23] of clong );
-                              #          
-  
-
-type 
-  PXCharStruct* = ptr TXCharStruct
-  TXCharStruct*{.final.} = object 
-    lbearing*: cshort
-    rbearing*: cshort
-    width*: cshort
-    ascent*: cshort
-    descent*: cshort
-    attributes*: cushort
-
-  PXFontProp* = ptr TXFontProp
-  TXFontProp*{.final.} = object 
-    name*: TAtom
-    card32*: culong
-
-  PPPXFontStruct* = ptr PPXFontStruct
-  PPXFontStruct* = ptr PXFontStruct
-  PXFontStruct* = ptr TXFontStruct
-  TXFontStruct*{.final.} = object 
-    ext_data*: PXExtData
-    fid*: TFont
-    direction*: cunsigned
-    min_char_or_byte2*: cunsigned
-    max_char_or_byte2*: cunsigned
-    min_byte1*: cunsigned
-    max_byte1*: cunsigned
-    all_chars_exist*: TBool
-    default_char*: cunsigned
-    n_properties*: cint
-    properties*: PXFontProp
-    min_bounds*: TXCharStruct
-    max_bounds*: TXCharStruct
-    per_char*: PXCharStruct
-    ascent*: cint
-    descent*: cint
-
-  PXTextItem* = ptr TXTextItem
-  TXTextItem*{.final.} = object 
-    chars*: cstring
-    nchars*: cint
-    delta*: cint
-    font*: TFont
-
-  PXChar2b* = ptr TXChar2b
-  TXChar2b*{.final.} = object 
-    byte1*: cuchar
-    byte2*: cuchar
-
-  PXTextItem16* = ptr TXTextItem16
-  TXTextItem16*{.final.} = object 
-    chars*: PXChar2b
-    nchars*: cint
-    delta*: cint
-    font*: TFont
-
-  PXEDataObject* = ptr TXEDataObject
-  TXEDataObject*{.final.} = object 
-    display*: PDisplay        #case longint of
-                              #          0 : ( display : PDisplay );
-                              #          1 : ( gc : TGC );
-                              #          2 : ( visual : PVisual );
-                              #          3 : ( screen : PScreen );
-                              #          4 : ( pixmap_format : PScreenFormat );
-                              #          5 : ( font : PXFontStruct );
-  
-  PXFontSetExtents* = ptr TXFontSetExtents
-  TXFontSetExtents*{.final.} = object 
-    max_ink_extent*: TXRectangle
-    max_logical_extent*: TXRectangle
-
-  PXOM* = ptr TXOM
-  TXOM*{.final.} = object 
-  PXOC* = ptr TXOC
-  TXOC*{.final.} = object 
-  TXFontSet* = PXOC
-  PXFontSet* = ptr TXFontSet
-  PXmbTextItem* = ptr TXmbTextItem
-  TXmbTextItem*{.final.} = object 
-    chars*: cstring
-    nchars*: cint
-    delta*: cint
-    font_set*: TXFontSet
-
-  PXwcTextItem* = ptr TXwcTextItem
-  TXwcTextItem*{.final.} = object 
-    chars*: PWideChar         #wchar_t*
-    nchars*: cint
-    delta*: cint
-    font_set*: TXFontSet
-
-
-const 
-  XNRequiredCharSet* = "requiredCharSet"
-  XNQueryOrientation* = "queryOrientation"
-  XNBaseFontName* = "baseFontName"
-  XNOMAutomatic* = "omAutomatic"
-  XNMissingCharSet* = "missingCharSet"
-  XNDefaultString* = "defaultString"
-  XNOrientation* = "orientation"
-  XNDirectionalDependentDrawing* = "directionalDependentDrawing"
-  XNContextualDrawing* = "contextualDrawing"
-  XNFontInfo* = "fontInfo"
-
-type 
-  PXOMCharSetList* = ptr TXOMCharSetList
-  TXOMCharSetList*{.final.} = object 
-    charset_count*: cint
-    charset_list*: PPChar
-
-  PXOrientation* = ptr TXOrientation
-  TXOrientation* = enum 
-    XOMOrientation_LTR_TTB, XOMOrientation_RTL_TTB, XOMOrientation_TTB_LTR, 
-    XOMOrientation_TTB_RTL, XOMOrientation_Context
-  PXOMOrientation* = ptr TXOMOrientation
-  TXOMOrientation*{.final.} = object 
-    num_orientation*: cint
-    orientation*: PXOrientation
-
-  PXOMFontInfo* = ptr TXOMFontInfo
-  TXOMFontInfo*{.final.} = object 
-    num_font*: cint
-    font_struct_list*: ptr PXFontStruct
-    font_name_list*: PPChar
-
-  PXIM* = ptr TXIM
-  TXIM*{.final.} = object 
-  PXIC* = ptr TXIC
-  TXIC*{.final.} = object 
-  TXIMProc* = proc (para1: TXIM, para2: TXPointer, para3: TXPointer){.cdecl.}
-  TXICProc* = proc (para1: TXIC, para2: TXPointer, para3: TXPointer): TBool{.
-      cdecl.}
-  TXIDProc* = proc (para1: PDisplay, para2: TXPointer, para3: TXPointer){.cdecl.}
-  PXIMStyle* = ptr TXIMStyle
-  TXIMStyle* = culong
-  PXIMStyles* = ptr TXIMStyles
-  TXIMStyles*{.final.} = object 
-    count_styles*: cushort
-    supported_styles*: PXIMStyle
-
-
-const 
-  XIMPreeditArea* = 0x00000001
-  XIMPreeditCallbacks* = 0x00000002
-  XIMPreeditPosition* = 0x00000004
-  XIMPreeditNothing* = 0x00000008
-  XIMPreeditNone* = 0x00000010
-  XIMStatusArea* = 0x00000100
-  XIMStatusCallbacks* = 0x00000200
-  XIMStatusNothing* = 0x00000400
-  XIMStatusNone* = 0x00000800
-  XNVaNestedList* = "XNVaNestedList"
-  XNQueryInputStyle* = "queryInputStyle"
-  XNClientWindow* = "clientWindow"
-  XNInputStyle* = "inputStyle"
-  XNFocusWindow* = "focusWindow"
-  XNResourceName* = "resourceName"
-  XNResourceClass* = "resourceClass"
-  XNGeometryCallback* = "geometryCallback"
-  XNDestroyCallback* = "destroyCallback"
-  XNFilterEvents* = "filterEvents"
-  XNPreeditStartCallback* = "preeditStartCallback"
-  XNPreeditDoneCallback* = "preeditDoneCallback"
-  XNPreeditDrawCallback* = "preeditDrawCallback"
-  XNPreeditCaretCallback* = "preeditCaretCallback"
-  XNPreeditStateNotifyCallback* = "preeditStateNotifyCallback"
-  XNPreeditAttributes* = "preeditAttributes"
-  XNStatusStartCallback* = "statusStartCallback"
-  XNStatusDoneCallback* = "statusDoneCallback"
-  XNStatusDrawCallback* = "statusDrawCallback"
-  XNStatusAttributes* = "statusAttributes"
-  XNArea* = "area"
-  XNAreaNeeded* = "areaNeeded"
-  XNSpotLocation* = "spotLocation"
-  XNColormap* = "colorMap"
-  XNStdColormap* = "stdColorMap"
-  XNForeground* = "foreground"
-  XNBackground* = "background"
-  XNBackgroundPixmap* = "backgroundPixmap"
-  XNFontSet* = "fontSet"
-  XNLineSpace* = "lineSpace"
-  XNCursor* = "cursor"
-  XNQueryIMValuesList* = "queryIMValuesList"
-  XNQueryICValuesList* = "queryICValuesList"
-  XNVisiblePosition* = "visiblePosition"
-  XNR6PreeditCallback* = "r6PreeditCallback"
-  XNStringConversionCallback* = "stringConversionCallback"
-  XNStringConversion* = "stringConversion"
-  XNResetState* = "resetState"
-  XNHotKey* = "hotKey"
-  XNHotKeyState* = "hotKeyState"
-  XNPreeditState* = "preeditState"
-  XNSeparatorofNestedList* = "separatorofNestedList"
-  XBufferOverflow* = - (1)
-  XLookupNone* = 1
-  XLookupChars* = 2
-  XLookupKeySymVal* = 3
-  XLookupBoth* = 4
-
-type 
-  PXVaNestedList* = ptr TXVaNestedList
-  TXVaNestedList* = pointer
-  PXIMCallback* = ptr TXIMCallback
-  TXIMCallback*{.final.} = object 
-    client_data*: TXPointer
-    callback*: TXIMProc
-
-  PXICCallback* = ptr TXICCallback
-  TXICCallback*{.final.} = object 
-    client_data*: TXPointer
-    callback*: TXICProc
-
-  PXIMFeedback* = ptr TXIMFeedback
-  TXIMFeedback* = culong
-
-const 
-  XIMReverse* = 1
-  XIMUnderline* = 1 shl 1
-  XIMHighlight* = 1 shl 2
-  XIMPrimary* = 1 shl 5
-  XIMSecondary* = 1 shl 6
-  XIMTertiary* = 1 shl 7
-  XIMVisibleToForward* = 1 shl 8
-  XIMVisibleToBackword* = 1 shl 9
-  XIMVisibleToCenter* = 1 shl 10
-
-type 
-  PXIMText* = ptr TXIMText
-  TXIMText*{.final.} = object 
-    len*: cushort
-    feedback*: PXIMFeedback
-    encoding_is_wchar*: TBool
-    multi_byte*: cstring
-
-  PXIMPreeditState* = ptr TXIMPreeditState
-  TXIMPreeditState* = culong
-
-const 
-  XIMPreeditUnKnown* = 0
-  XIMPreeditEnable* = 1
-  XIMPreeditDisable* = 1 shl 1
-
-type 
-  PXIMPreeditStateNotifyCallbackStruct* = ptr TXIMPreeditStateNotifyCallbackStruct
-  TXIMPreeditStateNotifyCallbackStruct*{.final.} = object 
-    state*: TXIMPreeditState
-
-  PXIMResetState* = ptr TXIMResetState
-  TXIMResetState* = culong
-
-const 
-  XIMInitialState* = 1
-  XIMPreserveState* = 1 shl 1
-
-type 
-  PXIMStringConversionFeedback* = ptr TXIMStringConversionFeedback
-  TXIMStringConversionFeedback* = culong
-
-const 
-  XIMStringConversionLeftEdge* = 0x00000001
-  XIMStringConversionRightEdge* = 0x00000002
-  XIMStringConversionTopEdge* = 0x00000004
-  XIMStringConversionBottomEdge* = 0x00000008
-  XIMStringConversionConcealed* = 0x00000010
-  XIMStringConversionWrapped* = 0x00000020
-
-type 
-  PXIMStringConversionText* = ptr TXIMStringConversionText
-  TXIMStringConversionText*{.final.} = object 
-    len*: cushort
-    feedback*: PXIMStringConversionFeedback
-    encoding_is_wchar*: TBool
-    mbs*: cstring
-
-  PXIMStringConversionPosition* = ptr TXIMStringConversionPosition
-  TXIMStringConversionPosition* = cushort
-  PXIMStringConversionType* = ptr TXIMStringConversionType
-  TXIMStringConversionType* = cushort
-
-const 
-  XIMStringConversionBuffer* = 0x00000001
-  XIMStringConversionLine* = 0x00000002
-  XIMStringConversionWord* = 0x00000003
-  XIMStringConversionChar* = 0x00000004
-
-type 
-  PXIMStringConversionOperation* = ptr TXIMStringConversionOperation
-  TXIMStringConversionOperation* = cushort
-
-const 
-  XIMStringConversionSubstitution* = 0x00000001
-  XIMStringConversionRetrieval* = 0x00000002
-
-type 
-  PXIMCaretDirection* = ptr TXIMCaretDirection
-  TXIMCaretDirection* = enum 
-    XIMForwardChar, XIMBackwardChar, XIMForwardWord, XIMBackwardWord, 
-    XIMCaretUp, XIMCaretDown, XIMNextLine, XIMPreviousLine, XIMLineStart, 
-    XIMLineEnd, XIMAbsolutePosition, XIMDontChange
-  PXIMStringConversionCallbackStruct* = ptr TXIMStringConversionCallbackStruct
-  TXIMStringConversionCallbackStruct*{.final.} = object 
-    position*: TXIMStringConversionPosition
-    direction*: TXIMCaretDirection
-    operation*: TXIMStringConversionOperation
-    factor*: cushort
-    text*: PXIMStringConversionText
-
-  PXIMPreeditDrawCallbackStruct* = ptr TXIMPreeditDrawCallbackStruct
-  TXIMPreeditDrawCallbackStruct*{.final.} = object 
-    caret*: cint
-    chg_first*: cint
-    chg_length*: cint
-    text*: PXIMText
-
-  PXIMCaretStyle* = ptr TXIMCaretStyle
-  TXIMCaretStyle* = enum 
-    XIMIsInvisible, XIMIsPrimary, XIMIsSecondary
-  PXIMPreeditCaretCallbackStruct* = ptr TXIMPreeditCaretCallbackStruct
-  TXIMPreeditCaretCallbackStruct*{.final.} = object 
-    position*: cint
-    direction*: TXIMCaretDirection
-    style*: TXIMCaretStyle
-
-  PXIMStatusDataType* = ptr TXIMStatusDataType
-  TXIMStatusDataType* = enum 
-    XIMTextType, XIMBitmapType
-  PXIMStatusDrawCallbackStruct* = ptr TXIMStatusDrawCallbackStruct
-  TXIMStatusDrawCallbackStruct*{.final.} = object 
-    theType*: TXIMStatusDataType
-    bitmap*: TPixmap
-
-  PXIMHotKeyTrigger* = ptr TXIMHotKeyTrigger
-  TXIMHotKeyTrigger*{.final.} = object 
-    keysym*: TKeySym
-    modifier*: cint
-    modifier_mask*: cint
-
-  PXIMHotKeyTriggers* = ptr TXIMHotKeyTriggers
-  TXIMHotKeyTriggers*{.final.} = object 
-    num_hot_key*: cint
-    key*: PXIMHotKeyTrigger
-
-  PXIMHotKeyState* = ptr TXIMHotKeyState
-  TXIMHotKeyState* = culong
-
-const 
-  XIMHotKeyStateON* = 0x00000001
-  XIMHotKeyStateOFF* = 0x00000002
-
-type 
-  PXIMValuesList* = ptr TXIMValuesList
-  TXIMValuesList*{.final.} = object 
-    count_values*: cushort
-    supported_values*: PPChar
-
-
-type 
-  funcdisp* = proc (display: PDisplay): cint{.cdecl.}
-  funcifevent* = proc (display: PDisplay, event: PXEvent, p: TXPointer): TBool{.
-      cdecl.}
-  chararr32* = array[0..31, char]
-
-const 
-  AllPlanes*: culong = culong(not 0)
-
-proc XLoadQueryFont*(para1: PDisplay, para2: cstring): PXFontStruct{.cdecl, 
-    dynlib: libX11, importc.}
-proc XQueryFont*(para1: PDisplay, para2: TXID): PXFontStruct{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetMotionEvents*(para1: PDisplay, para2: TWindow, para3: TTime, 
-                       para4: TTime, para5: Pcint): PXTimeCoord{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDeleteModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, 
-                              para3: cint): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetModifierMapping*(para1: PDisplay): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInsertModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, 
-                              para3: cint): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XNewModifiermap*(para1: cint): PXModifierKeymap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, para4: cint, 
-                   para5: cint, para6: cstring, para7: cuint, para8: cuint, 
-                   para9: cint, para10: cint): PXImage{.cdecl, dynlib: libX11, 
-    importc.}
-proc XInitImage*(para1: PXImage): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, 
-                para5: cuint, para6: cuint, para7: culong, para8: cint): PXImage{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetSubImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, 
-                   para5: cuint, para6: cuint, para7: culong, para8: cint, 
-                   para9: PXImage, para10: cint, para11: cint): PXImage{.cdecl, 
-    dynlib: libX11, importc.}
-proc XOpenDisplay*(para1: cstring): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XrmInitialize*(){.cdecl, dynlib: libX11, importc.}
-proc XFetchBytes*(para1: PDisplay, para2: Pcint): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFetchBuffer*(para1: PDisplay, para2: Pcint, para3: cint): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetAtomName*(para1: PDisplay, para2: TAtom): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetAtomNames*(para1: PDisplay, para2: PAtom, para3: cint, para4: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetDefault*(para1: PDisplay, para2: cstring, para3: cstring): cstring{.
-    cdecl, dynlib: libX11, importc.}
-proc XDisplayName*(para1: cstring): cstring{.cdecl, dynlib: libX11, importc.}
-proc XKeysymToString*(para1: TKeySym): cstring{.cdecl, dynlib: libX11, importc.}
-proc XSynchronize*(para1: PDisplay, para2: TBool): funcdisp{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetAfterFunction*(para1: PDisplay, para2: funcdisp): funcdisp{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInternAtom*(para1: PDisplay, para2: cstring, para3: TBool): TAtom{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInternAtoms*(para1: PDisplay, para2: PPchar, para3: cint, para4: TBool, 
-                   para5: PAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XCopyColormapAndFree*(para1: PDisplay, para2: TColormap): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreateColormap*(para1: PDisplay, para2: TWindow, para3: PVisual, 
-                      para4: cint): TColormap{.cdecl, dynlib: libX11, importc.}
-proc XCreatePixmapCursor*(para1: PDisplay, para2: TPixmap, para3: TPixmap, 
-                          para4: PXColor, para5: PXColor, para6: cuint, 
-                          para7: cuint): TCursor{.cdecl, dynlib: libX11, importc.}
-proc XCreateGlyphCursor*(para1: PDisplay, para2: TFont, para3: TFont, 
-                         para4: cuint, para5: cuint, para6: PXColor, 
-                         para7: PXColor): TCursor{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateFontCursor*(para1: PDisplay, para2: cuint): TCursor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLoadFont*(para1: PDisplay, para2: cstring): TFont{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateGC*(para1: PDisplay, para2: TDrawable, para3: culong, 
-                para4: PXGCValues): TGC{.cdecl, dynlib: libX11, importc.}
-proc XGContextFromGC*(para1: TGC): TGContext{.cdecl, dynlib: libX11, importc.}
-proc XFlushGC*(para1: PDisplay, para2: TGC){.cdecl, dynlib: libX11, importc.}
-proc XCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                    para4: cuint, para5: cuint): TPixmap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateBitmapFromData*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                            para4: cuint, para5: cuint): TPixmap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreatePixmapFromBitmapData*(para1: PDisplay, para2: TDrawable, 
-                                  para3: cstring, para4: cuint, para5: cuint, 
-                                  para6: culong, para7: culong, para8: cuint): TPixmap{.
-    cdecl, dynlib: libX11, importc.}
-proc XCreateSimpleWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                          para4: cint, para5: cuint, para6: cuint, para7: cuint, 
-                          para8: culong, para9: culong): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetSelectionOwner*(para1: PDisplay, para2: TAtom): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreateWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, 
-                    para5: cuint, para6: cuint, para7: cuint, para8: cint, 
-                    para9: cuint, para10: PVisual, para11: culong, 
-                    para12: PXSetWindowAttributes): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListInstalledColormaps*(para1: PDisplay, para2: TWindow, para3: Pcint): PColormap{.
-    cdecl, dynlib: libX11, importc.}
-proc XListFonts*(para1: PDisplay, para2: cstring, para3: cint, para4: Pcint): PPChar{.
-    cdecl, dynlib: libX11, importc.}
-proc XListFontsWithInfo*(para1: PDisplay, para2: cstring, para3: cint, 
-                         para4: Pcint, para5: PPXFontStruct): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetFontPath*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListExtensions*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListProperties*(para1: PDisplay, para2: TWindow, para3: Pcint): PAtom{.
-    cdecl, dynlib: libX11, importc.}
-proc XListHosts*(para1: PDisplay, para2: Pcint, para3: PBool): PXHostAddress{.
-    cdecl, dynlib: libX11, importc.}
-proc XKeycodeToKeysym*(para1: PDisplay, para2: TKeyCode, para3: cint): TKeySym{.
-    cdecl, dynlib: libX11, importc.}
-proc XLookupKeysym*(para1: PXKeyEvent, para2: cint): TKeySym{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetKeyboardMapping*(para1: PDisplay, para2: TKeyCode, para3: cint, 
-                          para4: Pcint): PKeySym{.cdecl, dynlib: libX11, importc.}
-proc XStringToKeysym*(para1: cstring): TKeySym{.cdecl, dynlib: libX11, importc.}
-proc XMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, importc.}
-proc XExtendedMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XResourceManagerString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XScreenResourceString*(para1: PScreen): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayMotionBufferSize*(para1: PDisplay): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XVisualIDFromVisual*(para1: PVisual): TVisualID{.cdecl, dynlib: libX11, 
-    importc.}
-proc XInitThreads*(): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XLockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.}
-proc XUnlockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.}
-proc XInitExtension*(para1: PDisplay, para2: cstring): PXExtCodes{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddExtension*(para1: PDisplay): PXExtCodes{.cdecl, dynlib: libX11, importc.}
-proc XFindOnExtensionList*(para1: PPXExtData, para2: cint): PXExtData{.cdecl, 
-    dynlib: libX11, importc.}
-proc XEHeadOfExtensionList*(para1: TXEDataObject): PPXExtData{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRootWindow*(para1: PDisplay, para2: cint): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultRootWindow*(para1: PDisplay): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRootWindowOfScreen*(para1: PScreen): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultVisual*(para1: PDisplay, para2: cint): PVisual{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultVisualOfScreen*(para1: PScreen): PVisual{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultGC*(para1: PDisplay, para2: cint): TGC{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultGCOfScreen*(para1: PScreen): TGC{.cdecl, dynlib: libX11, importc.}
-proc XBlackPixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XWhitePixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllPlanes*(): culong{.cdecl, dynlib: libX11, importc.}
-proc XBlackPixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XWhitePixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XNextRequest*(para1: PDisplay): culong{.cdecl, dynlib: libX11, importc.}
-proc XLastKnownRequestProcessed*(para1: PDisplay): culong{.cdecl, 
-    dynlib: libX11, importc.}
-proc XServerVendor*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDisplayString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDefaultColormap*(para1: PDisplay, para2: cint): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultColormapOfScreen*(para1: PScreen): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDisplayOfScreen*(para1: PScreen): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XScreenOfDisplay*(para1: PDisplay, para2: cint): PScreen{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultScreenOfDisplay*(para1: PDisplay): PScreen{.cdecl, dynlib: libX11, 
-    importc.}
-proc XEventMaskOfScreen*(para1: PScreen): clong{.cdecl, dynlib: libX11, importc.}
-proc XScreenNumberOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  TXErrorHandler* = proc (para1: PDisplay, para2: PXErrorEvent): cint{.cdecl.}
-
-proc XSetErrorHandler*(para1: TXErrorHandler): TXErrorHandler{.cdecl, 
-    dynlib: libX11, importc.}
-type 
-  TXIOErrorHandler* = proc (para1: PDisplay): cint{.cdecl.}
-
-proc XSetIOErrorHandler*(para1: TXIOErrorHandler): TXIOErrorHandler{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListPixmapFormats*(para1: PDisplay, para2: Pcint): PXPixmapFormatValues{.
-    cdecl, dynlib: libX11, importc.}
-proc XListDepths*(para1: PDisplay, para2: cint, para3: Pcint): Pcint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XReconfigureWMWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                           para4: cuint, para5: PXWindowChanges): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PPAtom, 
-                      para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PAtom, para4: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XIconifyWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XWithdrawWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetCommand*(para1: PDisplay, para2: TWindow, para3: PPPchar, para4: Pcint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PPWindow, 
-                            para4: Pcint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                            para4: cint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeStringList*(para1: PPchar){.cdecl, dynlib: libX11, importc.}
-proc XSetTransientForHint*(para1: PDisplay, para2: TWindow, para3: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XActivateScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAddHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XAddToExtensionList*(para1: PPXExtData, para2: PXExtData): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddToSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAllocColor*(para1: PDisplay, para2: TColormap, para3: PXColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XAllocColorCells*(para1: PDisplay, para2: TColormap, para3: TBool, 
-                       para4: Pculong, para5: cuint, para6: Pculong, 
-                       para7: cuint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XAllocColorPlanes*(para1: PDisplay, para2: TColormap, para3: TBool, 
-                        para4: Pculong, para5: cint, para6: cint, para7: cint, 
-                        para8: cint, para9: Pculong, para10: Pculong, 
-                        para11: Pculong): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                       para4: PXColor, para5: PXColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAllowEvents*(para1: PDisplay, para2: cint, para3: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAutoRepeatOff*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XAutoRepeatOn*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBell*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapBitOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapPad*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapUnit*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XCellsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XChangeActivePointerGrab*(para1: PDisplay, para2: cuint, para3: TCursor, 
-                               para4: TTime): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XChangeGC*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XChangeKeyboardControl*(para1: PDisplay, para2: culong, 
-                             para3: PXKeyboardControl): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeKeyboardMapping*(para1: PDisplay, para2: cint, para3: cint, 
-                             para4: PKeySym, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangePointerControl*(para1: PDisplay, para2: TBool, para3: TBool, 
-                            para4: cint, para5: cint, para6: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, 
-                      para4: TAtom, para5: cint, para6: cint, para7: Pcuchar, 
-                      para8: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XChangeSaveSet*(para1: PDisplay, para2: TWindow, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeWindowAttributes*(para1: PDisplay, para2: TWindow, para3: culong, 
-                              para4: PXSetWindowAttributes): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCheckIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-                    para4: TXPointer): TBool{.cdecl, dynlib: libX11, importc.}
-proc XCheckMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XCheckTypedEvent*(para1: PDisplay, para2: cint, para3: PXEvent): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XCheckTypedWindowEvent*(para1: PDisplay, para2: TWindow, para3: cint, 
-                             para4: PXEvent): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCheckWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, 
-                        para4: PXEvent): TBool{.cdecl, dynlib: libX11, importc.}
-proc XCirculateSubwindows*(para1: PDisplay, para2: TWindow, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCirculateSubwindowsDown*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCirculateSubwindowsUp*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XClearArea*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, 
-                 para5: cuint, para6: cuint, para7: TBool): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XClearWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCloseDisplay*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XConfigureWindow*(para1: PDisplay, para2: TWindow, para3: cuint, 
-                       para4: PXWindowChanges): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XConnectionNumber*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XConvertSelection*(para1: PDisplay, para2: TAtom, para3: TAtom, 
-                        para4: TAtom, para5: TWindow, para6: TTime): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCopyArea*(para1: PDisplay, para2: TDrawable, para3: TDrawable, para4: TGC, 
-                para5: cint, para6: cint, para7: cuint, para8: cuint, 
-                para9: cint, para10: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XCopyGC*(para1: PDisplay, para2: TGC, para3: culong, para4: TGC): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCopyPlane*(para1: PDisplay, para2: TDrawable, para3: TDrawable, 
-                 para4: TGC, para5: cint, para6: cint, para7: cuint, 
-                 para8: cuint, para9: cint, para10: cint, para11: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDefaultDepth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultDepthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultScreen*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XDefineCursor*(para1: PDisplay, para2: TWindow, para3: TCursor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDeleteProperty*(para1: PDisplay, para2: TWindow, para3: TAtom): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDestroyWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDestroySubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDoesBackingStore*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XDoesSaveUnders*(para1: PScreen): TBool{.cdecl, dynlib: libX11, importc.}
-proc XDisableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayCells*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayHeight*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayHeightMM*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDisplayKeycodes*(para1: PDisplay, para2: Pcint, para3: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDisplayPlanes*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayWidth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayWidthMM*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-               para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, 
-                para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                       para4: cint, para5: cint, para6: cstring, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawImageString16*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                         para4: cint, para5: cint, para6: PXChar2b, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawLine*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                para5: cint, para6: cint, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawLines*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, 
-                 para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawPoint*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                 para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawPoints*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, 
-                  para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDrawRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                     para5: cint, para6: cuint, para7: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                      para4: PXRectangle, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawSegments*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                    para4: PXSegment, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDrawString*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: cstring, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawString16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                    para5: cint, para6: PXChar2b, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                para5: cint, para6: PXTextItem, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawText16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXTextItem16, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XEnableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XEventsQueued*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFetchName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-               para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, 
-                para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XFillPolygon*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                   para4: PXPoint, para5: cint, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                     para5: cint, para6: cuint, para7: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFillRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                      para4: PXRectangle, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFlush*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XForceScreenSaver*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFree*(para1: pointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeColors*(para1: PDisplay, para2: TColormap, para3: Pculong, 
-                  para4: cint, para5: culong): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeCursor*(para1: PDisplay, para2: TCursor): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeExtensionList*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeFont*(para1: PDisplay, para2: PXFontStruct): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeFontInfo*(para1: PPchar, para2: PXFontStruct, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFreeFontNames*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeFontPath*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeGC*(para1: PDisplay, para2: TGC): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeModifiermap*(para1: PXModifierKeymap): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreePixmap*(para1: PDisplay, para2: TPixmap): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, 
-                para5: cuint, para6: cuint, para7: cuint, para8: cint, 
-                para9: cint, para10: Pcint, para11: Pcint, para12: Pcint, 
-                para13: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetErrorDatabaseText*(para1: PDisplay, para2: cstring, para3: cstring, 
-                            para4: cstring, para5: cstring, para6: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetErrorText*(para1: PDisplay, para2: cint, para3: cstring, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetFontProperty*(para1: PXFontStruct, para2: TAtom, para3: Pculong): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetGCValues*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetGeometry*(para1: PDisplay, para2: TDrawable, para3: PWindow, 
-                   para4: Pcint, para5: Pcint, para6: Pcuint, para7: Pcuint, 
-                   para8: Pcuint, para9: Pcuint): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetIconName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetInputFocus*(para1: PDisplay, para2: PWindow, para3: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetKeyboardControl*(para1: PDisplay, para2: PXKeyboardState): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetPointerControl*(para1: PDisplay, para2: Pcint, para3: Pcint, 
-                         para4: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetScreenSaver*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: Pcint, 
-                      para5: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetTransientForHint*(para1: PDisplay, para2: TWindow, para3: PWindow): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWindowProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, 
-                         para4: clong, para5: clong, para6: TBool, para7: TAtom, 
-                         para8: PAtom, para9: Pcint, para10: Pculong, 
-                         para11: Pculong, para12: PPcuchar): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetWindowAttributes*(para1: PDisplay, para2: TWindow, 
-                           para3: PXWindowAttributes): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow, 
-                  para5: TBool, para6: cuint, para7: cint, para8: cint, 
-                  para9: TWindow, para10: TCursor): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow, 
-               para5: TBool, para6: cint, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGrabKeyboard*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cint, 
-                    para5: cint, para6: TTime): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGrabPointer*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cuint, 
-                   para5: cint, para6: cint, para7: TWindow, para8: TCursor, 
-                   para9: TTime): cint{.cdecl, dynlib: libX11, importc.}
-proc XGrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XHeightMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XHeightOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-               para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XImageByteOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XInstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XKeysymToKeycode*(para1: PDisplay, para2: TKeySym): TKeyCode{.cdecl, 
-    dynlib: libX11, importc.}
-proc XKillClient*(para1: PDisplay, para2: TXID): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                   para4: PXColor, para5: PXColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLowerWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMapRaised*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XMapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMaxCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XMinCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XMoveResizeWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                        para4: cint, para5: cuint, para6: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMoveWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XNextEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XNoOp*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XParseColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                  para4: PXColor): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XParseGeometry*(para1: cstring, para2: Pcint, para3: Pcint, para4: Pcuint, 
-                     para5: Pcuint): cint{.cdecl, dynlib: libX11, importc.}
-proc XPeekEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XPeekIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-                   para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XPending*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XPlanesOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XProtocolRevision*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XProtocolVersion*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XPutBackEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXImage, 
-                para5: cint, para6: cint, para7: cint, para8: cint, 
-                para9: cuint, para10: cuint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQLength*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XQueryBestCursor*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                       para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestSize*(para1: PDisplay, para2: cint, para3: TDrawable, 
-                     para4: cuint, para5: cuint, para6: Pcuint, para7: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestStipple*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                        para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestTile*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                     para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryColors*(para1: PDisplay, para2: TColormap, para3: PXColor, 
-                   para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XQueryExtension*(para1: PDisplay, para2: cstring, para3: Pcint, 
-                      para4: Pcint, para5: Pcint): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-  #?
-proc XQueryKeymap*(para1: PDisplay, para2: chararr32): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XQueryPointer*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                    para4: PWindow, para5: Pcint, para6: Pcint, para7: Pcint, 
-                    para8: Pcint, para9: Pcuint): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTextExtents*(para1: PDisplay, para2: TXID, para3: cstring, 
-                        para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, 
-                        para8: PXCharStruct): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTextExtents16*(para1: PDisplay, para2: TXID, para3: PXChar2b, 
-                          para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, 
-                          para8: PXCharStruct): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTree*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                 para4: PWindow, para5: PPWindow, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XRaiseWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XReadBitmapFile*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                      para4: Pcuint, para5: Pcuint, para6: PPixmap, 
-                      para7: Pcint, para8: Pcint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XReadBitmapFileData*(para1: cstring, para2: Pcuint, para3: Pcuint, 
-                          para4: PPcuchar, para5: Pcint, para6: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRebindKeysym*(para1: PDisplay, para2: TKeySym, para3: PKeySym, 
-                    para4: cint, para5: Pcuchar, para6: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRecolorCursor*(para1: PDisplay, para2: TCursor, para3: PXColor, 
-                     para4: PXColor): cint{.cdecl, dynlib: libX11, importc.}
-proc XRefreshKeyboardMapping*(para1: PXMappingEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveFromSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XReparentWindow*(para1: PDisplay, para2: TWindow, para3: TWindow, 
-                      para4: cint, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XResetScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XResizeWindow*(para1: PDisplay, para2: TWindow, para3: cuint, para4: cuint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRestackWindows*(para1: PDisplay, para2: PWindow, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRotateBuffers*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRotateWindowProperties*(para1: PDisplay, para2: TWindow, para3: PAtom, 
-                              para4: cint, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XScreenCount*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XSelectInput*(para1: PDisplay, para2: TWindow, para3: clong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSendEvent*(para1: PDisplay, para2: TWindow, para3: TBool, para4: clong, 
-                 para5: PXEvent): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetAccessControl*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetArcMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetBackground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetClipMask*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetClipOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetClipRectangles*(para1: PDisplay, para2: TGC, para3: cint, para4: cint, 
-                         para5: PXRectangle, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetCloseDownMode*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetCommand*(para1: PDisplay, para2: TWindow, para3: PPchar, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetDashes*(para1: PDisplay, para2: TGC, para3: cint, para4: cstring, 
-                 para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetFillRule*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFillStyle*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFont*(para1: PDisplay, para2: TGC, para3: TFont): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFontPath*(para1: PDisplay, para2: PPchar, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetForeground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFunction*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetGraphicsExposures*(para1: PDisplay, para2: TGC, para3: TBool): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetIconName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetInputFocus*(para1: PDisplay, para2: TWindow, para3: cint, para4: TTime): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetLineAttributes*(para1: PDisplay, para2: TGC, para3: cuint, para4: cint, 
-                         para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetModifierMapping*(para1: PDisplay, para2: PXModifierKeymap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetPlaneMask*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetScreenSaver*(para1: PDisplay, para2: cint, para3: cint, para4: cint, 
-                      para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetSelectionOwner*(para1: PDisplay, para2: TAtom, para3: TWindow, 
-                         para4: TTime): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetState*(para1: PDisplay, para2: TGC, para3: culong, para4: culong, 
-                para5: cint, para6: culong): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetStipple*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetSubwindowMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetTSOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetTile*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetWindowBackground*(para1: PDisplay, para2: TWindow, para3: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBackgroundPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorder*(para1: PDisplay, para2: TWindow, para3: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorderPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorderWidth*(para1: PDisplay, para2: TWindow, para3: cuint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowColormap*(para1: PDisplay, para2: TWindow, para3: TColormap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreBuffer*(para1: PDisplay, para2: cstring, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreBytes*(para1: PDisplay, para2: cstring, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStoreColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreColors*(para1: PDisplay, para2: TColormap, para3: PXColor, 
-                   para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XStoreName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStoreNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                       para4: culong, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSync*(para1: PDisplay, para2: TBool): cint{.cdecl, dynlib: libX11, importc.}
-proc XTextExtents*(para1: PXFontStruct, para2: cstring, para3: cint, 
-                   para4: Pcint, para5: Pcint, para6: Pcint, para7: PXCharStruct): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XTextExtents16*(para1: PXFontStruct, para2: PXChar2b, para3: cint, 
-                     para4: Pcint, para5: Pcint, para6: Pcint, 
-                     para7: PXCharStruct): cint{.cdecl, dynlib: libX11, importc.}
-proc XTextWidth*(para1: PXFontStruct, para2: cstring, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XTextWidth16*(para1: PXFontStruct, para2: PXChar2b, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XTranslateCoordinates*(para1: PDisplay, para2: TWindow, para3: TWindow, 
-                            para4: cint, para5: cint, para6: Pcint, 
-                            para7: Pcint, para8: PWindow): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUndefineCursor*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUngrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUngrabKeyboard*(para1: PDisplay, para2: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabPointer*(para1: PDisplay, para2: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XUninstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnloadFont*(para1: PDisplay, para2: TFont): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XUnmapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnmapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XVendorRelease*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XWarpPointer*(para1: PDisplay, para2: TWindow, para3: TWindow, para4: cint, 
-                   para5: cint, para6: cuint, para7: cuint, para8: cint, 
-                   para9: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XWidthMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XWidthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, para4: PXEvent): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XWriteBitmapFile*(para1: PDisplay, para2: cstring, para3: TPixmap, 
-                       para4: cuint, para5: cuint, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSupportsLocale*(): TBool{.cdecl, dynlib: libX11, importc.}
-proc XSetLocaleModifiers*(para1: cstring): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XOpenOM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, 
-              para4: cstring): TXOM{.cdecl, dynlib: libX11, importc.}
-proc XCloseOM*(para1: TXOM): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayOfOM*(para1: TXOM): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XLocaleOfOM*(para1: TXOM): cstring{.cdecl, dynlib: libX11, importc.}
-proc XCreateOC*(para1: TXOM): TXOC{.varargs, cdecl, dynlib: libX11, importc.}
-proc XDestroyOC*(para1: TXOC){.cdecl, dynlib: libX11, importc.}
-proc XOMOfOC*(para1: TXOC): TXOM{.cdecl, dynlib: libX11, importc.}
-proc XSetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateFontSet*(para1: PDisplay, para2: cstring, para3: PPPchar, 
-                     para4: Pcint, para5: PPchar): TXFontSet{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeFontSet*(para1: PDisplay, para2: TXFontSet){.cdecl, dynlib: libX11, 
-    importc.}
-proc XFontsOfFontSet*(para1: TXFontSet, para2: PPPXFontStruct, para3: PPPchar): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XBaseFontNameListOfFontSet*(para1: TXFontSet): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLocaleOfFontSet*(para1: TXFontSet): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XContextDependentDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDirectionalDependentDrawing*(para1: TXFontSet): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XContextualDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XExtentsOfFontSet*(para1: TXFontSet): PXFontSetExtents{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbTextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextEscapement*(para1: TXFontSet, para2: PWideChar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XmbTextExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                     para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcTextExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, 
-                     para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8TextExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                       para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbTextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                            para4: PXRectangle, para5: PXRectangle, para6: cint, 
-                            para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextPerCharExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, 
-                            para4: PXRectangle, para5: PXRectangle, para6: cint, 
-                            para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                              para4: PXRectangle, para5: PXRectangle, 
-                              para6: cint, para7: Pcint, para8: PXRectangle, 
-                              para9: PXRectangle): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXwcTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8DrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                    para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                    para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                    para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XwcDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                    para4: TGC, para5: cint, para6: cint, para7: PWideChar, 
-                    para8: cint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8DrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                      para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                      para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XmbDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                         para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                         para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XwcDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                         para4: TGC, para5: cint, para6: cint, para7: PWideChar, 
-                         para8: cint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8DrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                           para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                           para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XOpenIM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, 
-              para4: cstring): TXIM{.cdecl, dynlib: libX11, importc.}
-proc XCloseIM*(para1: TXIM): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XSetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayOfIM*(para1: TXIM): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XLocaleOfIM*(para1: TXIM): cstring{.cdecl, dynlib: libX11, importc.}
-proc XCreateIC*(para1: TXIM): TXIC{.varargs, cdecl, dynlib: libX11, importc.}
-proc XDestroyIC*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XSetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XUnsetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XwcResetIC*(para1: TXIC): PWideChar{.cdecl, dynlib: libX11, importc.}
-proc XmbResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.}
-proc Xutf8ResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.}
-proc XSetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XIMOfIC*(para1: TXIC): TXIM{.cdecl, dynlib: libX11, importc.}
-proc XFilterEvent*(para1: PXEvent, para2: TWindow): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, 
-                      para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: PWideChar, 
-                      para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8LookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, 
-                        para4: cint, para5: PKeySym, para6: PStatus): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XVaCreateNestedList*(unused: cint): TXVaNestedList{.varargs, cdecl, 
-    dynlib: libX11, importc.}
-proc XRegisterIMInstantiateCallback*(para1: PDisplay, para2: PXrmHashBucketRec, 
-                                     para3: cstring, para4: cstring, 
-                                     para5: TXIDProc, para6: TXPointer): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XUnregisterIMInstantiateCallback*(para1: PDisplay, 
-                                       para2: PXrmHashBucketRec, para3: cstring, 
-                                       para4: cstring, para5: TXIDProc, 
-                                       para6: TXPointer): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-type 
-  TXConnectionWatchProc* = proc (para1: PDisplay, para2: TXPointer, para3: cint, 
-                                 para4: TBool, para5: PXPointer){.cdecl.}
-
-proc XInternalConnectionNumbers*(para1: PDisplay, para2: PPcint, para3: Pcint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XProcessInternalConnection*(para1: PDisplay, para2: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, 
-                          para3: TXPointer): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRemoveConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, 
-                             para3: TXPointer){.cdecl, dynlib: libX11, importc.}
-proc XSetAuthorization*(para1: cstring, para2: cint, para3: cstring, para4: cint){.
-    cdecl, dynlib: libX11, importc.}
-  #
-  #  _Xmbtowc?
-  #  _Xwctomb?
-  #
-when defined(MACROS): 
-  proc ConnectionNumber*(dpy: PDisplay): cint
-  proc RootWindow*(dpy: PDisplay, scr: cint): TWindow
-  proc DefaultScreen*(dpy: PDisplay): cint
-  proc DefaultRootWindow*(dpy: PDisplay): TWindow
-  proc DefaultVisual*(dpy: PDisplay, scr: cint): PVisual
-  proc DefaultGC*(dpy: PDisplay, scr: cint): TGC
-  proc BlackPixel*(dpy: PDisplay, scr: cint): culong
-  proc WhitePixel*(dpy: PDisplay, scr: cint): culong
-  proc QLength*(dpy: PDisplay): cint
-  proc DisplayWidth*(dpy: PDisplay, scr: cint): cint
-  proc DisplayHeight*(dpy: PDisplay, scr: cint): cint
-  proc DisplayWidthMM*(dpy: PDisplay, scr: cint): cint
-  proc DisplayHeightMM*(dpy: PDisplay, scr: cint): cint
-  proc DisplayPlanes*(dpy: PDisplay, scr: cint): cint
-  proc DisplayCells*(dpy: PDisplay, scr: cint): cint
-  proc ScreenCount*(dpy: PDisplay): cint
-  proc ServerVendor*(dpy: PDisplay): cstring
-  proc ProtocolVersion*(dpy: PDisplay): cint
-  proc ProtocolRevision*(dpy: PDisplay): cint
-  proc VendorRelease*(dpy: PDisplay): cint
-  proc DisplayString*(dpy: PDisplay): cstring
-  proc DefaultDepth*(dpy: PDisplay, scr: cint): cint
-  proc DefaultColormap*(dpy: PDisplay, scr: cint): TColormap
-  proc BitmapUnit*(dpy: PDisplay): cint
-  proc BitmapBitOrder*(dpy: PDisplay): cint
-  proc BitmapPad*(dpy: PDisplay): cint
-  proc ImageByteOrder*(dpy: PDisplay): cint
-  proc NextRequest*(dpy: PDisplay): culong
-  proc LastKnownRequestProcessed*(dpy: PDisplay): culong
-  proc ScreenOfDisplay*(dpy: PDisplay, scr: cint): PScreen
-  proc DefaultScreenOfDisplay*(dpy: PDisplay): PScreen
-  proc DisplayOfScreen*(s: PScreen): PDisplay
-  proc RootWindowOfScreen*(s: PScreen): TWindow
-  proc BlackPixelOfScreen*(s: PScreen): culong
-  proc WhitePixelOfScreen*(s: PScreen): culong
-  proc DefaultColormapOfScreen*(s: PScreen): TColormap
-  proc DefaultDepthOfScreen*(s: PScreen): cint
-  proc DefaultGCOfScreen*(s: PScreen): TGC
-  proc DefaultVisualOfScreen*(s: PScreen): PVisual
-  proc WidthOfScreen*(s: PScreen): cint
-  proc HeightOfScreen*(s: PScreen): cint
-  proc WidthMMOfScreen*(s: PScreen): cint
-  proc HeightMMOfScreen*(s: PScreen): cint
-  proc PlanesOfScreen*(s: PScreen): cint
-  proc CellsOfScreen*(s: PScreen): cint
-  proc MinCmapsOfScreen*(s: PScreen): cint
-  proc MaxCmapsOfScreen*(s: PScreen): cint
-  proc DoesSaveUnders*(s: PScreen): TBool
-  proc DoesBackingStore*(s: PScreen): cint
-  proc EventMaskOfScreen*(s: PScreen): clong
-  proc XAllocID*(dpy: PDisplay): TXID
-# implementation
-
-when defined(MACROS): 
-  proc ConnectionNumber(dpy: PDisplay): cint = 
-    ConnectionNumber = (PXPrivDisplay(dpy))^ .fd
-
-  proc RootWindow(dpy: PDisplay, scr: cint): TWindow = 
-    RootWindow = (ScreenOfDisplay(dpy, scr))^ .root
-
-  proc DefaultScreen(dpy: PDisplay): cint = 
-    DefaultScreen = (PXPrivDisplay(dpy))^ .default_screen
-
-  proc DefaultRootWindow(dpy: PDisplay): TWindow = 
-    DefaultRootWindow = (ScreenOfDisplay(dpy, DefaultScreen(dpy)))^ .root
-
-  proc DefaultVisual(dpy: PDisplay, scr: cint): PVisual = 
-    DefaultVisual = (ScreenOfDisplay(dpy, scr))^ .root_visual
-
-  proc DefaultGC(dpy: PDisplay, scr: cint): TGC = 
-    DefaultGC = (ScreenOfDisplay(dpy, scr))^ .default_gc
-
-  proc BlackPixel(dpy: PDisplay, scr: cint): culong = 
-    BlackPixel = (ScreenOfDisplay(dpy, scr))^ .black_pixel
-
-  proc WhitePixel(dpy: PDisplay, scr: cint): culong = 
-    WhitePixel = (ScreenOfDisplay(dpy, scr))^ .white_pixel
-
-  proc QLength(dpy: PDisplay): cint = 
-    QLength = (PXPrivDisplay(dpy))^ .qlen
-
-  proc DisplayWidth(dpy: PDisplay, scr: cint): cint = 
-    DisplayWidth = (ScreenOfDisplay(dpy, scr))^ .width
-
-  proc DisplayHeight(dpy: PDisplay, scr: cint): cint = 
-    DisplayHeight = (ScreenOfDisplay(dpy, scr))^ .height
-
-  proc DisplayWidthMM(dpy: PDisplay, scr: cint): cint = 
-    DisplayWidthMM = (ScreenOfDisplay(dpy, scr))^ .mwidth
-
-  proc DisplayHeightMM(dpy: PDisplay, scr: cint): cint = 
-    DisplayHeightMM = (ScreenOfDisplay(dpy, scr))^ .mheight
-
-  proc DisplayPlanes(dpy: PDisplay, scr: cint): cint = 
-    DisplayPlanes = (ScreenOfDisplay(dpy, scr))^ .root_depth
-
-  proc DisplayCells(dpy: PDisplay, scr: cint): cint = 
-    DisplayCells = (DefaultVisual(dpy, scr))^ .map_entries
-
-  proc ScreenCount(dpy: PDisplay): cint = 
-    ScreenCount = (PXPrivDisplay(dpy))^ .nscreens
-
-  proc ServerVendor(dpy: PDisplay): cstring = 
-    ServerVendor = (PXPrivDisplay(dpy))^ .vendor
-
-  proc ProtocolVersion(dpy: PDisplay): cint = 
-    ProtocolVersion = (PXPrivDisplay(dpy))^ .proto_major_version
-
-  proc ProtocolRevision(dpy: PDisplay): cint = 
-    ProtocolRevision = (PXPrivDisplay(dpy))^ .proto_minor_version
-
-  proc VendorRelease(dpy: PDisplay): cint = 
-    VendorRelease = (PXPrivDisplay(dpy))^ .release
-
-  proc DisplayString(dpy: PDisplay): cstring = 
-    DisplayString = (PXPrivDisplay(dpy))^ .display_name
-
-  proc DefaultDepth(dpy: PDisplay, scr: cint): cint = 
-    DefaultDepth = (ScreenOfDisplay(dpy, scr))^ .root_depth
-
-  proc DefaultColormap(dpy: PDisplay, scr: cint): TColormap = 
-    DefaultColormap = (ScreenOfDisplay(dpy, scr))^ .cmap
-
-  proc BitmapUnit(dpy: PDisplay): cint = 
-    BitmapUnit = (PXPrivDisplay(dpy))^ .bitmap_unit
-
-  proc BitmapBitOrder(dpy: PDisplay): cint = 
-    BitmapBitOrder = (PXPrivDisplay(dpy))^ .bitmap_bit_order
-
-  proc BitmapPad(dpy: PDisplay): cint = 
-    BitmapPad = (PXPrivDisplay(dpy))^ .bitmap_pad
-
-  proc ImageByteOrder(dpy: PDisplay): cint = 
-    ImageByteOrder = (PXPrivDisplay(dpy))^ .byte_order
-
-  proc NextRequest(dpy: PDisplay): culong = 
-    NextRequest = ((PXPrivDisplay(dpy))^ .request) + 1
-
-  proc LastKnownRequestProcessed(dpy: PDisplay): culong = 
-    LastKnownRequestProcessed = (PXPrivDisplay(dpy))^ .last_request_read
-
-  proc ScreenOfDisplay(dpy: PDisplay, scr: cint): PScreen = 
-    ScreenOfDisplay = addr((((PXPrivDisplay(dpy))^ .screens)[scr]))
-
-  proc DefaultScreenOfDisplay(dpy: PDisplay): PScreen = 
-    DefaultScreenOfDisplay = ScreenOfDisplay(dpy, DefaultScreen(dpy))
-
-  proc DisplayOfScreen(s: PScreen): PDisplay = 
-    DisplayOfScreen = s^ .display
-
-  proc RootWindowOfScreen(s: PScreen): TWindow = 
-    RootWindowOfScreen = s^ .root
-
-  proc BlackPixelOfScreen(s: PScreen): culong = 
-    BlackPixelOfScreen = s^ .black_pixel
-
-  proc WhitePixelOfScreen(s: PScreen): culong = 
-    WhitePixelOfScreen = s^ .white_pixel
-
-  proc DefaultColormapOfScreen(s: PScreen): TColormap = 
-    DefaultColormapOfScreen = s^ .cmap
-
-  proc DefaultDepthOfScreen(s: PScreen): cint = 
-    DefaultDepthOfScreen = s^ .root_depth
-
-  proc DefaultGCOfScreen(s: PScreen): TGC = 
-    DefaultGCOfScreen = s^ .default_gc
-
-  proc DefaultVisualOfScreen(s: PScreen): PVisual = 
-    DefaultVisualOfScreen = s^ .root_visual
-
-  proc WidthOfScreen(s: PScreen): cint = 
-    WidthOfScreen = s^ .width
-
-  proc HeightOfScreen(s: PScreen): cint = 
-    HeightOfScreen = s^ .height
-
-  proc WidthMMOfScreen(s: PScreen): cint = 
-    WidthMMOfScreen = s^ .mwidth
-
-  proc HeightMMOfScreen(s: PScreen): cint = 
-    HeightMMOfScreen = s^ .mheight
-
-  proc PlanesOfScreen(s: PScreen): cint = 
-    PlanesOfScreen = s^ .root_depth
-
-  proc CellsOfScreen(s: PScreen): cint = 
-    CellsOfScreen = (DefaultVisualOfScreen(s))^ .map_entries
-
-  proc MinCmapsOfScreen(s: PScreen): cint = 
-    MinCmapsOfScreen = s^ .min_maps
-
-  proc MaxCmapsOfScreen(s: PScreen): cint = 
-    MaxCmapsOfScreen = s^ .max_maps
-
-  proc DoesSaveUnders(s: PScreen): TBool = 
-    DoesSaveUnders = s^ .save_unders
-
-  proc DoesBackingStore(s: PScreen): cint = 
-    DoesBackingStore = s^ .backing_store
-
-  proc EventMaskOfScreen(s: PScreen): clong = 
-    EventMaskOfScreen = s^ .root_input_mask
-
-  proc XAllocID(dpy: PDisplay): TXID = 
-    XAllocID = (PXPrivDisplay(dpy))^ .resource_alloc(dpy)
diff --git a/lib/oldwrappers/x11/xrandr.nim b/lib/oldwrappers/x11/xrandr.nim
deleted file mode 100755
index ee6f1705b..000000000
--- a/lib/oldwrappers/x11/xrandr.nim
+++ /dev/null
@@ -1,194 +0,0 @@
-#
-#  $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
-# 
-#  Copyright (C) 2000 Compaq Computer Corporation, Inc.
-#  Copyright (C) 2002 Hewlett-Packard Company, Inc.
-# 
-#  Permission to use, copy, modify, distribute, and sell this software and its
-#  documentation for any purpose is hereby granted without fee, provided that
-#  the above copyright notice appear in all copies and that both that
-#  copyright notice and this permission notice appear in supporting
-#  documentation, and that the name of Compaq not be used in advertising or
-#  publicity pertaining to distribution of the software without specific,
-#  written prior permission.  HP makes no representations about the
-#  suitability of this software for any purpose.  It is provided "as is"
-#  without express or implied warranty.
-# 
-#  HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
-#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-#  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-#  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
-#  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# 
-#  Author:  Jim Gettys, HP Labs, HP.
-#
-
-import 
-  x, xlib
-
-const 
-  libXrandr* = "libXrandr.so"
-  
-# * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $
-# *
-# * Copyright (C) 2000, Compaq Computer Corporation, 
-# * Copyright (C) 2002, Hewlett Packard, Inc.
-# *
-# * Permission to use, copy, modify, distribute, and sell this software and its
-# * documentation for any purpose is hereby granted without fee, provided that
-# * the above copyright notice appear in all copies and that both that
-# * copyright notice and this permission notice appear in supporting
-# * documentation, and that the name of Compaq or HP not be used in advertising
-# * or publicity pertaining to distribution of the software without specific,
-# * written prior permission.  HP makes no representations about the
-# * suitability of this software for any purpose.  It is provided "as is"
-# * without express or implied warranty.
-# *
-# * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
-# * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-# * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
-# * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# *
-# * Author:  Jim Gettys, HP Labs, Hewlett-Packard, Inc.
-# *
-
-type 
-  PRotation* = ptr TRotation
-  TRotation* = cushort
-  PSizeID* = ptr TSizeID
-  TSizeID* = cushort
-  PSubpixelOrder* = ptr TSubpixelOrder
-  TSubpixelOrder* = cushort
-
-const 
-  RANDR_NAME* = "RANDR"
-  RANDR_MAJOR* = 1
-  RANDR_MINOR* = 1
-  RRNumberErrors* = 0
-  RRNumberEvents* = 1
-  constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately 
-  X_RROldGetScreenInfo* = 1
-  X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id 
-  constX_RRSetScreenConfig* = 2
-  X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated 
-  constX_RRSelectInput* = 4
-  constX_RRGetScreenInfo* = 5      # used in XRRSelectInput 
-  RRScreenChangeNotifyMask* = 1 shl 0
-  RRScreenChangeNotify* = 0   # used in the rotation field; rotation and reflection in 0.1 proto. 
-  RR_Rotate_0* = 1
-  RR_Rotate_90* = 2
-  RR_Rotate_180* = 4
-  RR_Rotate_270* = 8          # new in 1.0 protocol, to allow reflection of screen 
-  RR_Reflect_X* = 16
-  RR_Reflect_Y* = 32
-  RRSetConfigSuccess* = 0
-  RRSetConfigInvalidConfigTime* = 1
-  RRSetConfigInvalidTime* = 2
-  RRSetConfigFailed* = 3
-
-type 
-  PXRRScreenSize* = ptr TXRRScreenSize
-  TXRRScreenSize*{.final.} = object  #
-                                     #   Events.
-                                     #
-    width*, height*: cint
-    mwidth*, mheight*: cint
-
-  TXRRScreenChangeNotifyEvent*{.final.} = object  # internal representation is private to the library 
-    typ*: cint                # event base 
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    window*: TWindow          # window which selected for this event 
-    root*: TWindow            # Root window for changed screen 
-    timestamp*: TTime         # when the screen change occurred 
-    config_timestamp*: TTime  # when the last configuration change 
-    size_index*: TSizeID
-    subpixel_order*: TSubpixelOrder
-    rotation*: TRotation
-    width*: cint
-    height*: cint
-    mwidth*: cint
-    mheight*: cint
-
-  PXRRScreenConfiguration* = ptr TXRRScreenConfiguration
-  TXRRScreenConfiguration*{.final.} = object 
-
-proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint, 
-                      minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr, 
-    importc.}
-proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  Note that screen configuration changes are only permitted if the client can
-  #  prove it has up to date configuration information.  We are trying to
-  #  insist that it become possible for screens to change dynamically, so
-  #  we want to ensure the client knows what it is talking about when requesting
-  #  changes.
-  #
-proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration, 
-                         draw: TDrawable, size_index: cint, rotation: TRotation, 
-                         timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr, 
-    importc.}
-  # added in v1.1, sorry for the lame name 
-proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration, 
-                                draw: TDrawable, size_index: cint, 
-                                rotation: TRotation, rate: cshort, 
-                                timestamp: TTime): TStatus{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigRotations*(config: PXRRScreenConfiguration, 
-                         current_rotation: PRotation): TRotation{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint, 
-                     nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration, 
-                                    rotation: PRotation): TSizeID{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  returns the screen configuration for the specified screen; does a lazy
-  #  evalution to delay getting the information, and caches the result.
-  #  These routines should be used in preference to XRRGetScreenInfo
-  #  to avoid unneeded round trips to the X server.  These are new
-  #  in protocol version 0.1.
-  #
-proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  the following are always safe to call, even if RandR is not implemented 
-  #  on a screen 
-  #
-proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{.
-    cdecl, dynlib: libXrandr, importc.}
-  #
-  #  intended to take RRScreenChangeNotify,  or 
-  #  ConfigureNotify (on the root window)
-  #  returns 1 if it is an event type it understands, 0 if not
-  #
-proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr, 
-    importc.}
-# implementation
diff --git a/lib/oldwrappers/x11/xrender.nim b/lib/oldwrappers/x11/xrender.nim
deleted file mode 100755
index 7b85fc9a7..000000000
--- a/lib/oldwrappers/x11/xrender.nim
+++ /dev/null
@@ -1,231 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xrender.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xrender.h
-#
-
-type 
-  PGlyph* = ptr TGlyph
-  TGlyph* = int32
-  PGlyphSet* = ptr TGlyphSet
-  TGlyphSet* = int32
-  PPicture* = ptr TPicture
-  TPicture* = int32
-  PPictFormat* = ptr TPictFormat
-  TPictFormat* = int32
-
-const 
-  RENDER_NAME* = "RENDER"
-  RENDER_MAJOR* = 0
-  RENDER_MINOR* = 0
-  constX_RenderQueryVersion* = 0
-  X_RenderQueryPictFormats* = 1
-  X_RenderQueryPictIndexValues* = 2
-  X_RenderQueryDithers* = 3
-  constX_RenderCreatePicture* = 4
-  constX_RenderChangePicture* = 5
-  X_RenderSetPictureClipRectangles* = 6
-  constX_RenderFreePicture* = 7
-  constX_RenderComposite* = 8
-  X_RenderScale* = 9
-  X_RenderTrapezoids* = 10
-  X_RenderTriangles* = 11
-  X_RenderTriStrip* = 12
-  X_RenderTriFan* = 13
-  X_RenderColorTrapezoids* = 14
-  X_RenderColorTriangles* = 15
-  X_RenderTransform* = 16
-  constX_RenderCreateGlyphSet* = 17
-  constX_RenderReferenceGlyphSet* = 18
-  constX_RenderFreeGlyphSet* = 19
-  constX_RenderAddGlyphs* = 20
-  constX_RenderAddGlyphsFromPicture* = 21
-  constX_RenderFreeGlyphs* = 22
-  constX_RenderCompositeGlyphs8* = 23
-  constX_RenderCompositeGlyphs16* = 24
-  constX_RenderCompositeGlyphs32* = 25
-  BadPictFormat* = 0
-  BadPicture* = 1
-  BadPictOp* = 2
-  BadGlyphSet* = 3
-  BadGlyph* = 4
-  RenderNumberErrors* = BadGlyph + 1
-  PictTypeIndexed* = 0
-  PictTypeDirect* = 1
-  PictOpClear* = 0
-  PictOpSrc* = 1
-  PictOpDst* = 2
-  PictOpOver* = 3
-  PictOpOverReverse* = 4
-  PictOpIn* = 5
-  PictOpInReverse* = 6
-  PictOpOut* = 7
-  PictOpOutReverse* = 8
-  PictOpAtop* = 9
-  PictOpAtopReverse* = 10
-  PictOpXor* = 11
-  PictOpAdd* = 12
-  PictOpSaturate* = 13
-  PictOpMaximum* = 13
-  PolyEdgeSharp* = 0
-  PolyEdgeSmooth* = 1
-  PolyModePrecise* = 0
-  PolyModeImprecise* = 1
-  CPRepeat* = 1 shl 0
-  CPAlphaMap* = 1 shl 1
-  CPAlphaXOrigin* = 1 shl 2
-  CPAlphaYOrigin* = 1 shl 3
-  CPClipXOrigin* = 1 shl 4
-  CPClipYOrigin* = 1 shl 5
-  CPClipMask* = 1 shl 6
-  CPGraphicsExposure* = 1 shl 7
-  CPSubwindowMode* = 1 shl 8
-  CPPolyEdge* = 1 shl 9
-  CPPolyMode* = 1 shl 10
-  CPDither* = 1 shl 11
-  CPLastBit* = 11
-
-type 
-  PXRenderDirectFormat* = ptr TXRenderDirectFormat
-  TXRenderDirectFormat*{.final.} = object 
-    red*: int16
-    redMask*: int16
-    green*: int16
-    greenMask*: int16
-    blue*: int16
-    blueMask*: int16
-    alpha*: int16
-    alphaMask*: int16
-
-  PXRenderPictFormat* = ptr TXRenderPictFormat
-  TXRenderPictFormat*{.final.} = object 
-    id*: TPictFormat
-    thetype*: int32
-    depth*: int32
-    direct*: TXRenderDirectFormat
-    colormap*: TColormap
-
-
-const 
-  PictFormatID* = 1 shl 0
-  PictFormatType* = 1 shl 1
-  PictFormatDepth* = 1 shl 2
-  PictFormatRed* = 1 shl 3
-  PictFormatRedMask* = 1 shl 4
-  PictFormatGreen* = 1 shl 5
-  PictFormatGreenMask* = 1 shl 6
-  PictFormatBlue* = 1 shl 7
-  PictFormatBlueMask* = 1 shl 8
-  PictFormatAlpha* = 1 shl 9
-  PictFormatAlphaMask* = 1 shl 10
-  PictFormatColormap* = 1 shl 11
-
-type 
-  PXRenderVisual* = ptr TXRenderVisual
-  TXRenderVisual*{.final.} = object 
-    visual*: PVisual
-    format*: PXRenderPictFormat
-
-  PXRenderDepth* = ptr TXRenderDepth
-  TXRenderDepth*{.final.} = object 
-    depth*: int32
-    nvisuals*: int32
-    visuals*: PXRenderVisual
-
-  PXRenderScreen* = ptr TXRenderScreen
-  TXRenderScreen*{.final.} = object 
-    depths*: PXRenderDepth
-    ndepths*: int32
-    fallback*: PXRenderPictFormat
-
-  PXRenderInfo* = ptr TXRenderInfo
-  TXRenderInfo*{.final.} = object 
-    format*: PXRenderPictFormat
-    nformat*: int32
-    screen*: PXRenderScreen
-    nscreen*: int32
-    depth*: PXRenderDepth
-    ndepth*: int32
-    visual*: PXRenderVisual
-    nvisual*: int32
-
-  PXRenderPictureAttributes* = ptr TXRenderPictureAttributes
-  TXRenderPictureAttributes*{.final.} = object 
-    repeat*: TBool
-    alpha_map*: TPicture
-    alpha_x_origin*: int32
-    alpha_y_origin*: int32
-    clip_x_origin*: int32
-    clip_y_origin*: int32
-    clip_mask*: TPixmap
-    graphics_exposures*: TBool
-    subwindow_mode*: int32
-    poly_edge*: int32
-    poly_mode*: int32
-    dither*: TAtom
-
-  PXGlyphInfo* = ptr TXGlyphInfo
-  TXGlyphInfo*{.final.} = object 
-    width*: int16
-    height*: int16
-    x*: int16
-    y*: int16
-    xOff*: int16
-    yOff*: int16
-
-
-proc XRenderQueryExtension*(dpy: PDisplay, event_basep: ptr int32, 
-                            error_basep: ptr int32): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderQueryVersion*(dpy: PDisplay, major_versionp: ptr int32, 
-                          minor_versionp: ptr int32): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRenderFindVisualFormat*(dpy: PDisplay, visual: PVisual): PXRenderPictFormat{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderFindFormat*(dpy: PDisplay, mask: int32, 
-                        `template`: PXRenderPictFormat, count: int32): PXRenderPictFormat{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderCreatePicture*(dpy: PDisplay, drawable: TDrawable, 
-                           format: PXRenderPictFormat, valuemask: int32, 
-                           attributes: PXRenderPictureAttributes): TPicture{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderChangePicture*(dpy: PDisplay, picture: TPicture, valuemask: int32, 
-                           attributes: PXRenderPictureAttributes){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderComposite*(dpy: PDisplay, op: int32, src: TPicture, mask: TPicture, 
-                       dst: TPicture, src_x: int32, src_y: int32, mask_x: int32, 
-                       mask_y: int32, dst_x: int32, dst_y: int32, width: int32, 
-                       height: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderCreateGlyphSet*(dpy: PDisplay, format: PXRenderPictFormat): TGlyphSet{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderReferenceGlyphSet*(dpy: PDisplay, existing: TGlyphSet): TGlyphSet{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderAddGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, 
-                       glyphs: PXGlyphInfo, nglyphs: int32, images: cstring, 
-                       nbyte_images: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderFreeGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, 
-                        nglyphs: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderCompositeString8*(dpy: PDisplay, op: int32, src: TPicture, 
-                              dst: TPicture, maskFormat: PXRenderPictFormat, 
-                              glyphset: TGlyphSet, xSrc: int32, ySrc: int32, 
-                              xDst: int32, yDst: int32, str: cstring, 
-                              nchar: int32){.cdecl, dynlib: libX11, importc.}
-# implementation
diff --git a/lib/oldwrappers/x11/xresource.nim b/lib/oldwrappers/x11/xresource.nim
deleted file mode 100755
index ddb2a89c2..000000000
--- a/lib/oldwrappers/x11/xresource.nim
+++ /dev/null
@@ -1,200 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xresource.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xresource.h
-#
-
-proc Xpermalloc*(para1: int32): cstring{.cdecl, dynlib: libX11, importc.}
-type 
-  PXrmQuark* = ptr TXrmQuark
-  TXrmQuark* = int32
-  TXrmQuarkList* = PXrmQuark
-  PXrmQuarkList* = ptr TXrmQuarkList
-
-proc NULLQUARK*(): TXrmQuark
-type 
-  PXrmString* = ptr TXrmString
-  TXrmString* = ptr char
-
-proc NULLSTRING*(): TXrmString
-proc XrmStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmPermStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmQuarkToString*(para1: TXrmQuark): TXrmString{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmUniqueQuark*(): TXrmQuark{.cdecl, dynlib: libX11, importc.}
-when defined(MACROS): 
-  proc XrmStringsEqual*(a1, a2: cstring): bool
-type 
-  PXrmBinding* = ptr TXrmBinding
-  TXrmBinding* = enum 
-    XrmBindTightly, XrmBindLoosely
-  TXrmBindingList* = PXrmBinding
-  PXrmBindingList* = ptr TXrmBindingList
-
-proc XrmStringToQuarkList*(para1: cstring, para2: TXrmQuarkList){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmStringToBindingQuarkList*(para1: cstring, para2: TXrmBindingList, 
-                                  para3: TXrmQuarkList){.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  PXrmName* = ptr TXrmName
-  TXrmName* = TXrmQuark
-  PXrmNameList* = ptr TXrmNameList
-  TXrmNameList* = TXrmQuarkList
-
-when defined(MACROS): 
-  proc XrmNameToString*(name: int32): TXrmString
-  proc XrmStringToName*(str: cstring): int32
-  proc XrmStringToNameList*(str: cstring, name: PXrmQuark)
-type 
-  PXrmClass* = ptr TXrmClass
-  TXrmClass* = TXrmQuark
-  PXrmClassList* = ptr TXrmClassList
-  TXrmClassList* = TXrmQuarkList
-
-when defined(MACROS): 
-  proc XrmClassToString*(c_class: int32): TXrmString
-  proc XrmStringToClass*(c_class: cstring): int32
-  proc XrmStringToClassList*(str: cstring, c_class: PXrmQuark)
-type 
-  PXrmRepresentation* = ptr TXrmRepresentation
-  TXrmRepresentation* = TXrmQuark
-
-when defined(MACROS): 
-  proc XrmStringToRepresentation*(str: cstring): int32
-  proc XrmRepresentationToString*(thetype: int32): TXrmString
-type 
-  PXrmValue* = ptr TXrmValue
-  TXrmValue*{.final.} = object 
-    size*: int32
-    address*: TXPointer
-
-  TXrmValuePtr* = PXrmValue
-  PXrmValuePtr* = ptr TXrmValuePtr
-  PXrmHashBucketRec* = ptr TXrmHashBucketRec
-  TXrmHashBucketRec*{.final.} = object 
-  TXrmHashBucket* = PXrmHashBucketRec
-  PXrmHashBucket* = ptr TXrmHashBucket
-  PXrmHashTable* = ptr TXrmHashTable
-  TXrmHashTable* = ptr TXrmHashBucket
-  TXrmDatabase* = PXrmHashBucketRec
-  PXrmDatabase* = ptr TXrmDatabase
-
-proc XrmDestroyDatabase*(para1: TXrmDatabase){.cdecl, dynlib: libX11, importc.}
-proc XrmQPutResource*(para1: PXrmDatabase, para2: TXrmBindingList, 
-                      para3: TXrmQuarkList, para4: TXrmRepresentation, 
-                      para5: PXrmValue){.cdecl, dynlib: libX11, importc.}
-proc XrmPutResource*(para1: PXrmDatabase, para2: cstring, para3: cstring, 
-                     para4: PXrmValue){.cdecl, dynlib: libX11, importc.}
-proc XrmQPutStringResource*(para1: PXrmDatabase, para2: TXrmBindingList, 
-                            para3: TXrmQuarkList, para4: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmPutStringResource*(para1: PXrmDatabase, para2: cstring, para3: cstring){.
-    cdecl, dynlib: libX11, importc.}
-proc XrmPutLineResource*(para1: PXrmDatabase, para2: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmQGetResource*(para1: TXrmDatabase, para2: TXrmNameList, 
-                      para3: TXrmClassList, para4: PXrmRepresentation, 
-                      para5: PXrmValue): TBool{.cdecl, dynlib: libX11, importc.}
-proc XrmGetResource*(para1: TXrmDatabase, para2: cstring, para3: cstring, 
-                     para4: PPchar, para5: PXrmValue): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-  # There is no definition of TXrmSearchList 
-  #function XrmQGetSearchList(para1:TXrmDatabase; para2:TXrmNameList; para3:TXrmClassList; para4:TXrmSearchList; para5:longint):TBool;cdecl;external libX11;
-  #function XrmQGetSearchResource(para1:TXrmSearchList; para2:TXrmName; para3:TXrmClass; para4:PXrmRepresentation; para5:PXrmValue):TBool;cdecl;external libX11;
-proc XrmSetDatabase*(para1: PDisplay, para2: TXrmDatabase){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmGetDatabase*(para1: PDisplay): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmGetFileDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmCombineFileDatabase*(para1: cstring, para2: PXrmDatabase, para3: TBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XrmGetStringDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmPutFileDatabase*(para1: TXrmDatabase, para2: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmMergeDatabases*(para1: TXrmDatabase, para2: PXrmDatabase){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmCombineDatabase*(para1: TXrmDatabase, para2: PXrmDatabase, para3: TBool){.
-    cdecl, dynlib: libX11, importc.}
-const 
-  XrmEnumAllLevels* = 0
-  XrmEnumOneLevel* = 1
-
-type 
-  funcbool* = proc (): TBool
-
-proc XrmEnumerateDatabase*(para1: TXrmDatabase, para2: TXrmNameList, 
-                           para3: TXrmClassList, para4: int32, para5: funcbool, 
-                           para6: TXPointer): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmLocaleOfDatabase*(para1: TXrmDatabase): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  PXrmOptionKind* = ptr TXrmOptionKind
-  TXrmOptionKind* = enum 
-    XrmoptionNoArg, XrmoptionIsArg, XrmoptionStickyArg, XrmoptionSepArg, 
-    XrmoptionResArg, XrmoptionSkipArg, XrmoptionSkipLine, XrmoptionSkipNArgs
-  PXrmOptionDescRec* = ptr TXrmOptionDescRec
-  TXrmOptionDescRec*{.final.} = object 
-    option*: cstring
-    specifier*: cstring
-    argKind*: TXrmOptionKind
-    value*: TXPointer
-
-  TXrmOptionDescList* = PXrmOptionDescRec
-  PXrmOptionDescList* = ptr TXrmOptionDescList
-
-proc XrmParseCommand*(para1: PXrmDatabase, para2: TXrmOptionDescList, 
-                      para3: int32, para4: cstring, para5: ptr int32, 
-                      para6: PPchar){.cdecl, dynlib: libX11, importc.}
-# implementation
-
-proc NULLQUARK(): TXrmQuark = 
-  result = TXrmQuark(0)
-
-proc NULLSTRING(): TXrmString = 
-  result = nil
-
-when defined(MACROS): 
-  proc XrmStringsEqual(a1, a2: cstring): bool = 
-    result = (strcomp(a1, a2)) == 0
-
-  proc XrmNameToString(name: int32): TXrmString = 
-    result = XrmQuarkToString(name)
-
-  proc XrmStringToName(str: cstring): int32 = 
-    result = XrmStringToQuark(str)
-
-  proc XrmStringToNameList(str: cstring, name: PXrmQuark) = 
-    XrmStringToQuarkList(str, name)
-
-  proc XrmClassToString(c_class: int32): TXrmString = 
-    result = XrmQuarkToString(c_class)
-
-  proc XrmStringToClass(c_class: cstring): int32 = 
-    result = XrmStringToQuark(c_class)
-
-  proc XrmStringToClassList(str: cstring, c_class: PXrmQuark) = 
-    XrmStringToQuarkList(str, c_class)
-
-  proc XrmStringToRepresentation(str: cstring): int32 = 
-    result = XrmStringToQuark(str)
-
-  proc XrmRepresentationToString(thetype: int32): TXrmString = 
-    result = XrmQuarkToString(thetype)
diff --git a/lib/oldwrappers/x11/xshm.nim b/lib/oldwrappers/x11/xshm.nim
deleted file mode 100755
index e56bd87b1..000000000
--- a/lib/oldwrappers/x11/xshm.nim
+++ /dev/null
@@ -1,77 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xshm.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xshm.h
-#
-
-const 
-  constX_ShmQueryVersion* = 0
-  constX_ShmAttach* = 1
-  constX_ShmDetach* = 2
-  constX_ShmPutImage* = 3
-  constX_ShmGetImage* = 4
-  constX_ShmCreatePixmap* = 5
-  ShmCompletion* = 0
-  ShmNumberEvents* = ShmCompletion + 1
-  BadShmSeg* = 0
-  ShmNumberErrors* = BadShmSeg + 1
-
-type 
-  PShmSeg* = ptr TShmSeg
-  TShmSeg* = culong
-  PXShmCompletionEvent* = ptr TXShmCompletionEvent
-  TXShmCompletionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    major_code*: cint
-    minor_code*: cint
-    shmseg*: TShmSeg
-    offset*: culong
-
-  PXShmSegmentInfo* = ptr TXShmSegmentInfo
-  TXShmSegmentInfo*{.final.} = object 
-    shmseg*: TShmSeg
-    shmid*: cint
-    shmaddr*: cstring
-    readOnly*: TBool
-
-
-proc XShmQueryExtension*(para1: PDisplay): TBool{.cdecl, dynlib: libX11, importc.}
-proc XShmGetEventBase*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XShmQueryVersion*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: PBool): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XShmPixmapFormat*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XShmAttach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmDetach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                   para4: PXImage, para5: cint, para6: cint, para7: cint, 
-                   para8: cint, para9: cuint, para10: cuint, para11: TBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XShmGetImage*(para1: PDisplay, para2: TDrawable, para3: PXImage, 
-                   para4: cint, para5: cint, para6: culong): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, 
-                      para4: cint, para5: cstring, para6: PXShmSegmentInfo, 
-                      para7: cuint, para8: cuint): PXImage{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                       para4: PXShmSegmentInfo, para5: cuint, para6: cuint, 
-                       para7: cuint): TPixmap{.cdecl, dynlib: libX11, importc.}
-# implementation
diff --git a/lib/oldwrappers/x11/xutil.nim b/lib/oldwrappers/x11/xutil.nim
deleted file mode 100755
index 563702123..000000000
--- a/lib/oldwrappers/x11/xutil.nim
+++ /dev/null
@@ -1,412 +0,0 @@
-
-import 
-  x, xlib, keysym
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xutil.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xutil.h
-#
-
-const 
-  NoValue* = 0x00000000
-  XValue* = 0x00000001
-  YValue* = 0x00000002
-  WidthValue* = 0x00000004
-  HeightValue* = 0x00000008
-  AllValues* = 0x0000000F
-  XNegative* = 0x00000010
-  YNegative* = 0x00000020
-
-type 
-  TCPoint*{.final.} = object 
-    x*: cint
-    y*: cint
-
-  PXSizeHints* = ptr TXSizeHints
-  TXSizeHints*{.final.} = object 
-    flags*: clong
-    x*, y*: cint
-    width*, height*: cint
-    min_width*, min_height*: cint
-    max_width*, max_height*: cint
-    width_inc*, height_inc*: cint
-    min_aspect*, max_aspect*: TCPoint
-    base_width*, base_height*: cint
-    win_gravity*: cint
-
-
-const 
-  USPosition* = 1 shl 0
-  USSize* = 1 shl 1
-  PPosition* = 1 shl 2
-  PSize* = 1 shl 3
-  PMinSize* = 1 shl 4
-  PMaxSize* = 1 shl 5
-  PResizeInc* = 1 shl 6
-  PAspect* = 1 shl 7
-  PBaseSize* = 1 shl 8
-  PWinGravity* = 1 shl 9
-  PAllHints* = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or
-      PAspect
-
-type 
-  PXWMHints* = ptr TXWMHints
-  TXWMHints*{.final.} = object 
-    flags*: clong
-    input*: TBool
-    initial_state*: cint
-    icon_pixmap*: TPixmap
-    icon_window*: TWindow
-    icon_x*, icon_y*: cint
-    icon_mask*: TPixmap
-    window_group*: TXID
-
-
-const 
-  InputHint* = 1 shl 0
-  StateHint* = 1 shl 1
-  IconPixmapHint* = 1 shl 2
-  IconWindowHint* = 1 shl 3
-  IconPositionHint* = 1 shl 4
-  IconMaskHint* = 1 shl 5
-  WindowGroupHint* = 1 shl 6
-  AllHints* = InputHint or StateHint or IconPixmapHint or IconWindowHint or
-      IconPositionHint or IconMaskHint or WindowGroupHint
-  XUrgencyHint* = 1 shl 8
-  WithdrawnState* = 0
-  NormalState* = 1
-  IconicState* = 3
-  DontCareState* = 0
-  ZoomState* = 2
-  InactiveState* = 4
-
-type 
-  PXTextProperty* = ptr TXTextProperty
-  TXTextProperty*{.final.} = object 
-    value*: pcuchar
-    encoding*: TAtom
-    format*: cint
-    nitems*: culong
-
-
-const 
-  XNoMemory* = - 1
-  XLocaleNotSupported* = - 2
-  XConverterNotFound* = - 3
-
-type 
-  PXICCEncodingStyle* = ptr TXICCEncodingStyle
-  TXICCEncodingStyle* = enum 
-    XStringStyle, XCompoundTextStyle, XTextStyle, XStdICCTextStyle, 
-    XUTF8StringStyle
-  PPXIconSize* = ptr PXIconSize
-  PXIconSize* = ptr TXIconSize
-  TXIconSize*{.final.} = object 
-    min_width*, min_height*: cint
-    max_width*, max_height*: cint
-    width_inc*, height_inc*: cint
-
-  PXClassHint* = ptr TXClassHint
-  TXClassHint*{.final.} = object 
-    res_name*: cstring
-    res_class*: cstring
-
-
-type 
-  PXComposeStatus* = ptr TXComposeStatus
-  TXComposeStatus*{.final.} = object 
-    compose_ptr*: TXPointer
-    chars_matched*: cint
-
-
-type 
-  PXRegion* = ptr TXRegion
-  TXRegion*{.final.} = object 
-  TRegion* = PXRegion
-  PRegion* = ptr TRegion
-
-const 
-  RectangleOut* = 0
-  RectangleIn* = 1
-  RectanglePart* = 2
-
-type 
-  PXVisualInfo* = ptr TXVisualInfo
-  TXVisualInfo*{.final.} = object 
-    visual*: PVisual
-    visualid*: TVisualID
-    screen*: cint
-    depth*: cint
-    class*: cint
-    red_mask*: culong
-    green_mask*: culong
-    blue_mask*: culong
-    colormap_size*: cint
-    bits_per_rgb*: cint
-
-
-const 
-  VisualNoMask* = 0x00000000
-  VisualIDMask* = 0x00000001
-  VisualScreenMask* = 0x00000002
-  VisualDepthMask* = 0x00000004
-  VisualClassMask* = 0x00000008
-  VisualRedMaskMask* = 0x00000010
-  VisualGreenMaskMask* = 0x00000020
-  VisualBlueMaskMask* = 0x00000040
-  VisualColormapSizeMask* = 0x00000080
-  VisualBitsPerRGBMask* = 0x00000100
-  VisualAllMask* = 0x000001FF
-
-type 
-  PPXStandardColormap* = ptr PXStandardColormap
-  PXStandardColormap* = ptr TXStandardColormap
-  TXStandardColormap*{.final.} = object 
-    colormap*: TColormap
-    red_max*: culong
-    red_mult*: culong
-    green_max*: culong
-    green_mult*: culong
-    blue_max*: culong
-    blue_mult*: culong
-    base_pixel*: culong
-    visualid*: TVisualID
-    killid*: TXID
-
-
-const 
-  BitmapSuccess* = 0
-  BitmapOpenFailed* = 1
-  BitmapFileInvalid* = 2
-  BitmapNoMemory* = 3
-  XCSUCCESS* = 0
-  XCNOMEM* = 1
-  XCNOENT* = 2
-  ReleaseByFreeingColormap*: TXID = TXID(1)
-
-type 
-  PXContext* = ptr TXContext
-  TXContext* = cint
-
-proc XAllocClassHint*(): PXClassHint{.cdecl, dynlib: libX11, importc.}
-proc XAllocIconSize*(): PXIconSize{.cdecl, dynlib: libX11, importc.}
-proc XAllocSizeHints*(): PXSizeHints{.cdecl, dynlib: libX11, importc.}
-proc XAllocStandardColormap*(): PXStandardColormap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllocWMHints*(): PXWMHints{.cdecl, dynlib: libX11, importc.}
-proc XClipBox*(para1: TRegion, para2: PXRectangle): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateRegion*(): TRegion{.cdecl, dynlib: libX11, importc.}
-proc XDefaultString*(): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDeleteContext*(para1: PDisplay, para2: TXID, para3: TXContext): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDestroyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
-proc XEmptyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
-proc XEqualRegion*(para1: TRegion, para2: TRegion): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFindContext*(para1: PDisplay, para2: TXID, para3: TXContext, 
-                   para4: PXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetIconSizes*(para1: PDisplay, para2: TWindow, para3: PPXIconSize, 
-                    para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetRGBColormaps*(para1: PDisplay, para2: TWindow, 
-                       para3: PPXStandardColormap, para4: Pcint, para5: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                    para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetStandardColormap*(para1: PDisplay, para2: TWindow, 
-                           para3: PXStandardColormap, para4: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetVisualInfo*(para1: PDisplay, para2: clong, para3: PXVisualInfo, 
-                     para4: Pcint): PXVisualInfo{.cdecl, dynlib: libX11, importc.}
-proc XGetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMHints*(para1: PDisplay, para2: TWindow): PXWMHints{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                        para4: ptr int): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                      para4: ptr int, para5: TAtom): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XIntersectRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XConvertCase*(para1: TKeySym, para2: PKeySym, para3: PKeySym){.cdecl, 
-    dynlib: libX11, importc.}
-proc XLookupString*(para1: PXKeyEvent, para2: cstring, para3: cint, 
-                    para4: PKeySym, para5: PXComposeStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMatchVisualInfo*(para1: PDisplay, para2: cint, para3: cint, para4: cint, 
-                       para5: PXVisualInfo): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XOffsetRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPointInRegion*(para1: TRegion, para2: cint, para3: cint): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPolygonRegion*(para1: PXPoint, para2: cint, para3: cint): TRegion{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRectInRegion*(para1: TRegion, para2: cint, para3: cint, para4: cuint, 
-                    para5: cuint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSaveContext*(para1: PDisplay, para2: TXID, para3: TXContext, 
-                   para4: cstring): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetIconSizes*(para1: PDisplay, para2: TWindow, para3: PXIconSize, 
-                    para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetRGBColormaps*(para1: PDisplay, para2: TWindow, 
-                       para3: PXStandardColormap, para4: cint, para5: TAtom){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                    para4: TAtom): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetStandardProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                             para4: cstring, para5: TPixmap, para6: PPchar, 
-                             para7: cint, para8: PXSizeHints): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: TAtom){.cdecl, dynlib: libX11, importc.}
-proc XSetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMHints*(para1: PDisplay, para2: TWindow, para3: PXWMHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMProperties*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: PXTextProperty, para5: PPchar, para6: cint, 
-                       para7: PXSizeHints, para8: PXWMHints, para9: PXClassHint){.
-    cdecl, dynlib: libX11, importc.}
-proc XmbSetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                         para4: cstring, para5: PPchar, para6: cint, 
-                         para7: PXSizeHints, para8: PXWMHints, 
-                         para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8SetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                           para4: cstring, para5: PPchar, para6: cint, 
-                           para7: PXSizeHints, para8: PXWMHints, 
-                           para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
-proc XSetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                      para4: TAtom){.cdecl, dynlib: libX11, importc.}
-proc XSetRegion*(para1: PDisplay, para2: TGC, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetStandardColormap*(para1: PDisplay, para2: TWindow, 
-                           para3: PXStandardColormap, para4: TAtom){.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XShrinkRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStringListToTextProperty*(para1: PPchar, para2: cint, 
-                                para3: PXTextProperty): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSubtractRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XmbTextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, 
-                                para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextListToTextProperty*(para1: PDisplay, para2: ptr ptr int16, para3: cint, 
-                                para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, 
-                                  para4: TXICCEncodingStyle, 
-                                  para5: PXTextProperty): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcFreeStringList*(para1: ptr ptr int16){.cdecl, dynlib: libX11, importc.}
-proc XTextPropertyToStringList*(para1: PXTextProperty, para2: PPPchar, 
-                                para3: Pcint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XmbTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                para3: PPPchar, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                para3: ptr ptr ptr int16, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8TextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                  para3: PPPchar, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnionRectWithRegion*(para1: PXRectangle, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUnionRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, 
-                  para5: cuint, para6: PXSizeHints, para7: Pcint, para8: Pcint, 
-                  para9: Pcint, para10: Pcint, para11: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-when defined(MACROS): 
-  proc XDestroyImage*(ximage: PXImage): cint
-  proc XGetPixel*(ximage: PXImage, x, y: cint): culong
-  proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint
-  proc XSubImage*(ximage: PXImage, x, y: cint, width, height: cuint): PXImage
-  proc XAddPixel*(ximage: PXImage, value: clong): cint
-  proc IsKeypadKey*(keysym: TKeySym): bool
-  proc IsPrivateKeypadKey*(keysym: TKeySym): bool
-  proc IsCursorKey*(keysym: TKeySym): bool
-  proc IsPFKey*(keysym: TKeySym): bool
-  proc IsFunctionKey*(keysym: TKeySym): bool
-  proc IsMiscFunctionKey*(keysym: TKeySym): bool
-  proc IsModifierKey*(keysym: TKeySym): bool
-    #function XUniqueContext : TXContext;
-    #function XStringToContext(_string : Pchar) : TXContext;
-# implementation
-
-when defined(MACROS): 
-  proc XDestroyImage(ximage: PXImage): cint = 
-    XDestroyImage = ximage^ .f.destroy_image(ximage)
-
-  proc XGetPixel(ximage: PXImage, x, y: cint): culong = 
-    XGetPixel = ximage^ .f.get_pixel(ximage, x, y)
-
-  proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint = 
-    XPutPixel = ximage^ .f.put_pixel(ximage, x, y, pixel)
-
-  proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage = 
-    XSubImage = ximage^ .f.sub_image(ximage, x, y, width, height)
-
-  proc XAddPixel(ximage: PXImage, value: clong): cint = 
-    XAddPixel = ximage^ .f.add_pixel(ximage, value)
-
-  proc IsKeypadKey(keysym: TKeySym): bool = 
-    IsKeypadKey = (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal)
-
-  proc IsPrivateKeypadKey(keysym: TKeySym): bool = 
-    IsPrivateKeypadKey = (keysym >= 0x11000000) and (keysym <= 0x1100FFFF)
-
-  proc IsCursorKey(keysym: TKeySym): bool = 
-    IsCursorKey = (keysym >= XK_Home) and (keysym < XK_Select)
-
-  proc IsPFKey(keysym: TKeySym): bool = 
-    IsPFKey = (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4)
-
-  proc IsFunctionKey(keysym: TKeySym): bool = 
-    IsFunctionKey = (keysym >= XK_F1) and (keysym <= XK_F35)
-
-  proc IsMiscFunctionKey(keysym: TKeySym): bool = 
-    IsMiscFunctionKey = (keysym >= XK_Select) and (keysym <= XK_Break)
-
-  proc IsModifierKey(keysym: TKeySym): bool = 
-    IsModifierKey = ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or
-        (keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock)
diff --git a/lib/oldwrappers/x11/xv.nim b/lib/oldwrappers/x11/xv.nim
deleted file mode 100755
index 45ab61418..000000000
--- a/lib/oldwrappers/x11/xv.nim
+++ /dev/null
@@ -1,84 +0,0 @@
-#***********************************************************
-#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
-#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its 
-#documentation for any purpose and without fee is hereby granted, 
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in 
-#supporting documentation, and that the names of Digital or MIT not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.  
-#
-#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#******************************************************************
-# $XFree86: xc/include/extensions/Xv.h,v 1.3 1999/05/23 06:33:22 dawes Exp $ 
-
-import 
-  x
-
-const 
-  XvName* = "libXVideo.so"
-  XvVersion* = 2
-  XvRevision* = 2             # Symbols 
-
-type 
-  TXvPortID* = TXID
-  TXvEncodingID* = TXID
-
-const 
-  XvNone* = 0
-  XvInput* = 0
-  XvOutput* = 1
-  XvInputMask* = 1 shl XvInput
-  XvOutputMask* = 1 shl XvOutput
-  XvVideoMask* = 0x00000004
-  XvStillMask* = 0x00000008
-  XvImageMask* = 0x00000010   # These two are not client viewable 
-  XvPixmapMask* = 0x00010000
-  XvWindowMask* = 0x00020000
-  XvGettable* = 0x00000001
-  XvSettable* = 0x00000002
-  XvRGB* = 0
-  XvYUV* = 1
-  XvPacked* = 0
-  XvPlanar* = 1
-  XvTopToBottom* = 0
-  XvBottomToTop* = 1          # Events 
-  XvVideoNotify* = 0
-  XvPortNotify* = 1
-  XvNumEvents* = 2            # Video Notify Reasons 
-  XvStarted* = 0
-  XvStopped* = 1
-  XvBusy* = 2
-  XvPreempted* = 3
-  XvHardError* = 4
-  XvLastReason* = 4
-  XvNumReasons* = XvLastReason + 1
-  XvStartedMask* = 1 shl XvStarted
-  XvStoppedMask* = 1 shl XvStopped
-  XvBusyMask* = 1 shl XvBusy
-  XvPreemptedMask* = 1 shl XvPreempted
-  XvHardErrorMask* = 1 shl XvHardError
-  XvAnyReasonMask* = (1 shl XvNumReasons) - 1
-  XvNoReasonMask* = 0         # Errors 
-  XvBadPort* = 0
-  XvBadEncoding* = 1
-  XvBadControl* = 2
-  XvNumErrors* = 3            # Status 
-  XvBadExtension* = 1
-  XvAlreadyGrabbed* = 2
-  XvInvalidTime* = 3
-  XvBadReply* = 4
-  XvBadAlloc* = 5
-
-# implementation
diff --git a/lib/oldwrappers/x11/xvlib.nim b/lib/oldwrappers/x11/xvlib.nim
deleted file mode 100755
index 19fd0d000..000000000
--- a/lib/oldwrappers/x11/xvlib.nim
+++ /dev/null
@@ -1,234 +0,0 @@
-#***********************************************************
-#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
-#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its 
-#documentation for any purpose and without fee is hereby granted, 
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in 
-#supporting documentation, and that the names of Digital or MIT not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.  
-#
-#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#******************************************************************
-# $XFree86: xc/include/extensions/Xvlib.h,v 1.3 1999/12/11 19:28:48 mvojkovi Exp $ 
-#*
-#** File: 
-#**
-#**   Xvlib.h --- Xv library public header file
-#**
-#** Author: 
-#**
-#**   David Carver (Digital Workstation Engineering/Project Athena)
-#**
-#** Revisions:
-#**
-#**   26.06.91 Carver
-#**     - changed XvFreeAdaptors to XvFreeAdaptorInfo
-#**     - changed XvFreeEncodings to XvFreeEncodingInfo
-#**
-#**   11.06.91 Carver
-#**     - changed SetPortControl to SetPortAttribute
-#**     - changed GetPortControl to GetPortAttribute
-#**     - changed QueryBestSize
-#**
-#**   05.15.91 Carver
-#**     - version 2.0 upgrade
-#**
-#**   01.24.91 Carver
-#**     - version 1.4 upgrade
-#**
-#*
-
-import 
-  x, xlib, xshm, xv
-
-const 
-  libXv* = "libXv.so"
-
-type 
-  PXvRational* = ptr TXvRational
-  TXvRational*{.final.} = object 
-    numerator*: cint
-    denominator*: cint
-
-  PXvAttribute* = ptr TXvAttribute
-  TXvAttribute*{.final.} = object 
-    flags*: cint              # XvGettable, XvSettable 
-    min_value*: cint
-    max_value*: cint
-    name*: cstring
-
-  PPXvEncodingInfo* = ptr PXvEncodingInfo
-  PXvEncodingInfo* = ptr TXvEncodingInfo
-  TXvEncodingInfo*{.final.} = object 
-    encoding_id*: TXvEncodingID
-    name*: cstring
-    width*: culong
-    height*: culong
-    rate*: TXvRational
-    num_encodings*: culong
-
-  PXvFormat* = ptr TXvFormat
-  TXvFormat*{.final.} = object 
-    depth*: cchar
-    visual_id*: culong
-
-  PPXvAdaptorInfo* = ptr PXvAdaptorInfo
-  PXvAdaptorInfo* = ptr TXvAdaptorInfo
-  TXvAdaptorInfo*{.final.} = object 
-    base_id*: TXvPortID
-    num_ports*: culong
-    thetype*: cchar
-    name*: cstring
-    num_formats*: culong
-    formats*: PXvFormat
-    num_adaptors*: culong
-
-  PXvVideoNotifyEvent* = ptr TXvVideoNotifyEvent
-  TXvVideoNotifyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    drawable*: TDrawable      # drawable 
-    reason*: culong           # what generated this event 
-    port_id*: TXvPortID       # what port 
-    time*: TTime              # milliseconds 
-  
-  PXvPortNotifyEvent* = ptr TXvPortNotifyEvent
-  TXvPortNotifyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    port_id*: TXvPortID       # what port 
-    time*: TTime              # milliseconds 
-    attribute*: TAtom         # atom that identifies attribute 
-    value*: clong             # value of attribute 
-  
-  PXvEvent* = ptr TXvEvent
-  TXvEvent*{.final.} = object 
-    pad*: array[0..23, clong] #case longint of
-                              #      0 : (
-                              #            theType : cint;
-                              #	  );
-                              #      1 : (
-                              #            xvvideo : TXvVideoNotifyEvent;
-                              #          );
-                              #      2 : (
-                              #            xvport : TXvPortNotifyEvent;
-                              #          );
-                              #      3 : (
-                              #            
-                              #          );
-  
-  PXvImageFormatValues* = ptr TXvImageFormatValues
-  TXvImageFormatValues*{.final.} = object 
-    id*: cint                 # Unique descriptor for the format 
-    theType*: cint            # XvRGB, XvYUV 
-    byte_order*: cint         # LSBFirst, MSBFirst 
-    guid*: array[0..15, cchar] # Globally Unique IDentifier 
-    bits_per_pixel*: cint
-    format*: cint             # XvPacked, XvPlanar 
-    num_planes*: cint         # for RGB formats only 
-    depth*: cint
-    red_mask*: cuint
-    green_mask*: cuint
-    blue_mask*: cuint         # for YUV formats only 
-    y_sample_bits*: cuint
-    u_sample_bits*: cuint
-    v_sample_bits*: cuint
-    horz_y_period*: cuint
-    horz_u_period*: cuint
-    horz_v_period*: cuint
-    vert_y_period*: cuint
-    vert_u_period*: cuint
-    vert_v_period*: cuint
-    component_order*: array[0..31, char] # eg. UYVY 
-    scanline_order*: cint     # XvTopToBottom, XvBottomToTop 
-  
-  PXvImage* = ptr TXvImage
-  TXvImage*{.final.} = object 
-    id*: cint
-    width*, height*: cint
-    data_size*: cint          # bytes 
-    num_planes*: cint
-    pitches*: pcint           # bytes 
-    offsets*: pcint           # bytes 
-    data*: pointer
-    obdata*: TXPointer
-
-
-proc XvQueryExtension*(display: PDisplay, p_version, p_revision, p_requestBase, 
-    p_eventBase, p_errorBase: pcuint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvQueryAdaptors*(display: PDisplay, window: TWindow, p_nAdaptors: pcuint, 
-                      p_pAdaptors: PPXvAdaptorInfo): cint{.cdecl, dynlib: libXv, 
-    importc.}
-proc XvQueryEncodings*(display: PDisplay, port: TXvPortID, p_nEncoding: pcuint, 
-                       p_pEncoding: PPXvEncodingInfo): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvPutVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvPutStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGetVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGetStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvStopVideo*(display: PDisplay, port: TXvPortID, drawable: TDrawable): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvUngrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSelectVideoNotify*(display: PDisplay, drawable: TDrawable, onoff: TBool): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSelectPortNotify*(display: PDisplay, port: TXvPortID, onoff: TBool): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, 
-                         value: cint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvGetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, 
-                         p_value: pcint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvQueryBestSize*(display: PDisplay, port: TXvPortID, motion: TBool, 
-                      vid_w, vid_h, drw_w, drw_h: cuint, 
-                      p_actual_width, p_actual_height: pcuint): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvQueryPortAttributes*(display: PDisplay, port: TXvPortID, number: pcint): PXvAttribute{.
-    cdecl, dynlib: libXv, importc.}
-proc XvFreeAdaptorInfo*(adaptors: PXvAdaptorInfo){.cdecl, dynlib: libXv, importc.}
-proc XvFreeEncodingInfo*(encodings: PXvEncodingInfo){.cdecl, dynlib: libXv, 
-    importc.}
-proc XvListImageFormats*(display: PDisplay, port_id: TXvPortID, 
-                         count_return: pcint): PXvImageFormatValues{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvCreateImage*(display: PDisplay, port: TXvPortID, id: cint, data: pointer, 
-                    width, height: cint): PXvImage{.cdecl, dynlib: libXv, 
-    importc.}
-proc XvPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, 
-                 image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, 
-                 dest_x, dest_y: cint, dest_w, dest_h: cuint): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvShmPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, 
-                    image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, 
-                    dest_x, dest_y: cint, dest_w, dest_h: cuint, 
-                    send_event: TBool): cint{.cdecl, dynlib: libXv, importc.}
-proc XvShmCreateImage*(display: PDisplay, port: TXvPortID, id: cint, 
-                       data: pointer, width, height: cint, 
-                       shminfo: PXShmSegmentInfo): PXvImage{.cdecl, 
-    dynlib: libXv, importc.}
-# implementation
diff --git a/lib/oldwrappers/zip/libzip.nim b/lib/oldwrappers/zip/libzip.nim
deleted file mode 100755
index 2f8abc46c..000000000
--- a/lib/oldwrappers/zip/libzip.nim
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by
-## Dieter Baron and Thomas Klausner. However, this does not need any external
-## library (DLL, lib*.so), as the source for this library is included and
-## compiled with this interface.
-
-#
-#  zip.h -- exported declarations.
-#  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-#
-#  This file is part of libzip, a library to manipulate ZIP archives.
-#  The authors can be contacted at <libzip@nih.at>
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#  3. The names of the authors may not be used to endorse or promote
-#     products derived from this software without specific prior
-#     written permission.
-# 
-#  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-#  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-#  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-#  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-import times
-
-{.compile: "libzip_all.c".}
-when defined(unix):
-  {.passl: "-lz".}
-
-type 
-  Tzip_source_cmd* = int32
-
-  Tzip_source_callback* = proc (state: pointer, data: pointer, length: int, 
-                                cmd: Tzip_source_cmd): int {.cdecl.}
-  Pzip_stat* = ptr Tzip_stat
-  Tzip_stat* {.final, pure.} = object 
-    name*: cstring            ## name of the file  
-    index*: int32             ## index within archive  
-    crc*: int32               ## crc of file data  
-    mtime*: TTime             ## modification time  
-    size*: int                ## size of file (uncompressed)  
-    comp_size*: int           ## size of file (compressed)  
-    comp_method*: int16       ## compression method used  
-    encryption_method*: int16 ## encryption method used  
-  
-  Tzip {.final, pure.} = object
-  Tzip_source {.final, pure.} = object 
-  Tzip_file {.final, pure.} = object
-
-  Pzip* = ptr Tzip ## represents a zip archive
-  Pzip_file* = ptr Tzip_file ## represents a file within an archive
-  Pzip_source* = ptr Tzip_source ## represents a source for an archive
-
-
-# flags for zip_name_locate, zip_fopen, zip_stat, ...  
-const 
-  ZIP_CREATE* = 1'i32
-  ZIP_EXCL* = 2'i32
-  ZIP_CHECKCONS* = 4'i32 
-  ZIP_FL_NOCASE* = 1'i32        ## ignore case on name lookup  
-  ZIP_FL_NODIR* = 2'i32         ## ignore directory component  
-  ZIP_FL_COMPRESSED* = 4'i32    ## read compressed data  
-  ZIP_FL_UNCHANGED* = 8'i32     ## use original data, ignoring changes  
-  ZIP_FL_RECOMPRESS* = 16'i32   ## force recompression of data  
-
-const  # archive global flags flags  
-  ZIP_AFL_TORRENT* = 1'i32      ##  torrent zipped  
-
-const # libzip error codes  
-  ZIP_ER_OK* = 0'i32            ## N No error  
-  ZIP_ER_MULTIDISK* = 1'i32     ## N Multi-disk zip archives not supported  
-  ZIP_ER_RENAME* = 2'i32        ## S Renaming temporary file failed  
-  ZIP_ER_CLOSE* = 3'i32         ## S Closing zip archive failed  
-  ZIP_ER_SEEK* = 4'i32          ## S Seek error  
-  ZIP_ER_READ* = 5'i32          ## S Read error  
-  ZIP_ER_WRITE* = 6'i32         ## S Write error  
-  ZIP_ER_CRC* = 7'i32           ## N CRC error  
-  ZIP_ER_ZIPCLOSED* = 8'i32     ## N Containing zip archive was closed  
-  ZIP_ER_NOENT* = 9'i32         ## N No such file  
-  ZIP_ER_EXISTS* = 10'i32       ## N File already exists  
-  ZIP_ER_OPEN* = 11'i32         ## S Can't open file  
-  ZIP_ER_TMPOPEN* = 12'i32      ## S Failure to create temporary file  
-  ZIP_ER_ZLIB* = 13'i32         ## Z Zlib error  
-  ZIP_ER_MEMORY* = 14'i32       ## N Malloc failure  
-  ZIP_ER_CHANGED* = 15'i32      ## N Entry has been changed  
-  ZIP_ER_COMPNOTSUPP* = 16'i32  ## N Compression method not supported  
-  ZIP_ER_EOF* = 17'i32          ## N Premature EOF  
-  ZIP_ER_INVAL* = 18'i32        ## N Invalid argument  
-  ZIP_ER_NOZIP* = 19'i32        ## N Not a zip archive  
-  ZIP_ER_INTERNAL* = 20'i32     ## N Internal error  
-  ZIP_ER_INCONS* = 21'i32       ## N Zip archive inconsistent  
-  ZIP_ER_REMOVE* = 22'i32       ## S Can't remove file  
-  ZIP_ER_DELETED* = 23'i32      ## N Entry has been deleted  
-   
-const # type of system error value  
-  ZIP_ET_NONE* = 0'i32          ## sys_err unused  
-  ZIP_ET_SYS* = 1'i32           ## sys_err is errno  
-  ZIP_ET_ZLIB* = 2'i32          ## sys_err is zlib error code  
-
-const # compression methods  
-  ZIP_CM_DEFAULT* = -1'i32      ## better of deflate or store  
-  ZIP_CM_STORE* = 0'i32         ## stored (uncompressed)  
-  ZIP_CM_SHRINK* = 1'i32        ## shrunk  
-  ZIP_CM_REDUCE_1* = 2'i32      ## reduced with factor 1  
-  ZIP_CM_REDUCE_2* = 3'i32      ## reduced with factor 2  
-  ZIP_CM_REDUCE_3* = 4'i32      ## reduced with factor 3  
-  ZIP_CM_REDUCE_4* = 5'i32      ## reduced with factor 4  
-  ZIP_CM_IMPLODE* = 6'i32       ## imploded  
-                                ## 7 - Reserved for Tokenizing compression algorithm  
-  ZIP_CM_DEFLATE* = 8'i32       ## deflated  
-  ZIP_CM_DEFLATE64* = 9'i32     ## deflate64  
-  ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding  
-                                  ## 11 - Reserved by PKWARE  
-  ZIP_CM_BZIP2* = 12'i32        ## compressed using BZIP2 algorithm  
-                                ## 13 - Reserved by PKWARE  
-  ZIP_CM_LZMA* = 14'i32         ## LZMA (EFS)  
-                                ## 15-17 - Reserved by PKWARE  
-  ZIP_CM_TERSE* = 18'i32        ## compressed using IBM TERSE (new)  
-  ZIP_CM_LZ77* = 19'i32         ## IBM LZ77 z Architecture (PFS)  
-  ZIP_CM_WAVPACK* = 97'i32      ## WavPack compressed data  
-  ZIP_CM_PPMD* = 98'i32         ## PPMd version I, Rev 1  
-
-const  # encryption methods                              
-  ZIP_EM_NONE* = 0'i32            ## not encrypted  
-  ZIP_EM_TRAD_PKWARE* = 1'i32     ## traditional PKWARE encryption 
-
-const 
-  ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm  
-
-const 
-  ZIP_SOURCE_OPEN* = 0'i32        ## prepare for reading  
-  ZIP_SOURCE_READ* = 1'i32        ## read data  
-  ZIP_SOURCE_CLOSE* = 2'i32       ## reading is done  
-  ZIP_SOURCE_STAT* = 3'i32        ## get meta information  
-  ZIP_SOURCE_ERROR* = 4'i32       ## get error information  
-  constZIP_SOURCE_FREE* = 5'i32   ## cleanup and free resources  
-
-proc zip_add*(para1: Pzip, para2: cstring, para3: Pzip_source): int32 {.cdecl, 
-    importc: "zip_add".}
-proc zip_add_dir*(para1: Pzip, para2: cstring): int32 {.cdecl,  
-    importc: "zip_add_dir".}
-proc zip_close*(para1: Pzip) {.cdecl, importc: "zip_close".}
-proc zip_delete*(para1: Pzip, para2: int32): int32 {.cdecl,
-    importc: "zip_delete".}
-proc zip_error_clear*(para1: Pzip) {.cdecl, importc: "zip_error_clear".}
-proc zip_error_get*(para1: Pzip, para2: ptr int32, para3: ptr int32) {.cdecl, 
-    importc: "zip_error_get".}
-proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl,  
-    importc: "zip_error_get_sys_type".}
-proc zip_error_to_str*(para1: cstring, para2: int, para3: int32, 
-                       para4: int32): int32 {.cdecl,
-    importc: "zip_error_to_str".}
-proc zip_fclose*(para1: Pzip_file) {.cdecl,
-    importc: "zip_fclose".}
-proc zip_file_error_clear*(para1: Pzip_file) {.cdecl, 
-    importc: "zip_file_error_clear".}
-proc zip_file_error_get*(para1: Pzip_file, para2: ptr int32, para3: ptr int32) {.
-    cdecl, importc: "zip_file_error_get".}
-proc zip_file_strerror*(para1: Pzip_file): cstring {.cdecl,
-    importc: "zip_file_strerror".}
-proc zip_fopen*(para1: Pzip, para2: cstring, para3: int32): Pzip_file {.cdecl, 
-    importc: "zip_fopen".}
-proc zip_fopen_index*(para1: Pzip, para2: int32, para3: int32): Pzip_file {.
-    cdecl, importc: "zip_fopen_index".}
-proc zip_fread*(para1: Pzip_file, para2: pointer, para3: int): int {.
-    cdecl, importc: "zip_fread".}
-proc zip_get_archive_comment*(para1: Pzip, para2: ptr int32, para3: int32): cstring {.
-    cdecl, importc: "zip_get_archive_comment".}
-proc zip_get_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
-    cdecl, importc: "zip_get_archive_flag".}
-proc zip_get_file_comment*(para1: Pzip, para2: int32, para3: ptr int32, 
-                           para4: int32): cstring {.cdecl, 
-    importc: "zip_get_file_comment".}
-proc zip_get_name*(para1: Pzip, para2: int32, para3: int32): cstring {.cdecl, 
-    importc: "zip_get_name".}
-proc zip_get_num_files*(para1: Pzip): int32 {.cdecl,
-    importc: "zip_get_num_files".}
-proc zip_name_locate*(para1: Pzip, para2: cstring, para3: int32): int32 {.cdecl, 
-    importc: "zip_name_locate".}
-proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): Pzip {.cdecl, 
-    importc: "zip_open".}
-proc zip_rename*(para1: Pzip, para2: int32, para3: cstring): int32 {.cdecl, 
-    importc: "zip_rename".}
-proc zip_replace*(para1: Pzip, para2: int32, para3: Pzip_source): int32 {.cdecl, 
-    importc: "zip_replace".}
-proc zip_set_archive_comment*(para1: Pzip, para2: cstring, para3: int32): int32 {.
-    cdecl, importc: "zip_set_archive_comment".}
-proc zip_set_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
-    cdecl, importc: "zip_set_archive_flag".}
-proc zip_set_file_comment*(para1: Pzip, para2: int32, para3: cstring, 
-                           para4: int32): int32 {.cdecl, 
-    importc: "zip_set_file_comment".}
-proc zip_source_buffer*(para1: Pzip, para2: pointer, para3: int, para4: int32): Pzip_source {.
-    cdecl, importc: "zip_source_buffer".}
-proc zip_source_file*(para1: Pzip, para2: cstring, para3: int, para4: int): Pzip_source {.
-    cdecl, importc: "zip_source_file".}
-proc zip_source_filep*(para1: Pzip, para2: TFile, para3: int, para4: int): Pzip_source {.
-    cdecl, importc: "zip_source_filep".}
-proc zip_source_free*(para1: Pzip_source) {.cdecl, 
-    importc: "zip_source_free".}
-proc zip_source_function*(para1: Pzip, para2: Tzip_source_callback, 
-                          para3: pointer): Pzip_source {.cdecl, 
-    importc: "zip_source_function".}
-proc zip_source_zip*(para1: Pzip, para2: Pzip, para3: int32, para4: int32, 
-                     para5: int, para6: int): Pzip_source {.cdecl, 
-    importc: "zip_source_zip".}
-proc zip_stat*(para1: Pzip, para2: cstring, para3: int32, para4: Pzip_stat): int32 {.
-    cdecl, importc: "zip_stat".}
-proc zip_stat_index*(para1: Pzip, para2: int32, para3: int32, para4: Pzip_stat): int32 {.
-    cdecl, importc: "zip_stat_index".}
-proc zip_stat_init*(para1: Pzip_stat) {.cdecl, importc: "zip_stat_init".}
-proc zip_strerror*(para1: Pzip): cstring {.cdecl, importc: "zip_strerror".}
-proc zip_unchange*(para1: Pzip, para2: int32): int32 {.cdecl,
-    importc: "zip_unchange".}
-proc zip_unchange_all*(para1: Pzip): int32 {.cdecl, importc: "zip_unchange_all".}
-proc zip_unchange_archive*(para1: Pzip): int32 {.cdecl, 
-    importc: "zip_unchange_archive".}
diff --git a/lib/oldwrappers/zip/libzip_all.c b/lib/oldwrappers/zip/libzip_all.c
deleted file mode 100755
index 797374b29..000000000
--- a/lib/oldwrappers/zip/libzip_all.c
+++ /dev/null
@@ -1,4189 +0,0 @@
-/*
-  zipint.h -- internal declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <zlib.h>
-
-/*
-#ifdef _MSC_VER
-#define ZIP_EXTERN __declspec(dllimport)
-#endif
-*/
-
-/*
-  zip.h -- exported declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#ifndef ZIP_EXTERN
-#define ZIP_EXTERN
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <time.h>
-
-/* flags for zip_open */
-
-#define ZIP_CREATE           1
-#define ZIP_EXCL             2
-#define ZIP_CHECKCONS        4
-
-
-/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
-
-#define ZIP_FL_NOCASE                1 /* ignore case on name lookup */
-#define ZIP_FL_NODIR                2 /* ignore directory component */
-#define ZIP_FL_COMPRESSED        4 /* read compressed data */
-#define ZIP_FL_UNCHANGED        8 /* use original data, ignoring changes */
-#define ZIP_FL_RECOMPRESS      16 /* force recompression of data */
-
-/* archive global flags flags */
-
-#define ZIP_AFL_TORRENT                1 /* torrent zipped */
-
-/* libzip error codes */
-
-#define ZIP_ER_OK             0  /* N No error */
-#define ZIP_ER_MULTIDISK      1  /* N Multi-disk zip archives not supported */
-#define ZIP_ER_RENAME         2  /* S Renaming temporary file failed */
-#define ZIP_ER_CLOSE          3  /* S Closing zip archive failed */
-#define ZIP_ER_SEEK           4  /* S Seek error */
-#define ZIP_ER_READ           5  /* S Read error */
-#define ZIP_ER_WRITE          6  /* S Write error */
-#define ZIP_ER_CRC            7  /* N CRC error */
-#define ZIP_ER_ZIPCLOSED      8  /* N Containing zip archive was closed */
-#define ZIP_ER_NOENT          9  /* N No such file */
-#define ZIP_ER_EXISTS        10  /* N File already exists */
-#define ZIP_ER_OPEN          11  /* S Can't open file */
-#define ZIP_ER_TMPOPEN       12  /* S Failure to create temporary file */
-#define ZIP_ER_ZLIB          13  /* Z Zlib error */
-#define ZIP_ER_MEMORY        14  /* N Malloc failure */
-#define ZIP_ER_CHANGED       15  /* N Entry has been changed */
-#define ZIP_ER_COMPNOTSUPP   16  /* N Compression method not supported */
-#define ZIP_ER_EOF           17  /* N Premature EOF */
-#define ZIP_ER_INVAL         18  /* N Invalid argument */
-#define ZIP_ER_NOZIP         19  /* N Not a zip archive */
-#define ZIP_ER_INTERNAL      20  /* N Internal error */
-#define ZIP_ER_INCONS        21  /* N Zip archive inconsistent */
-#define ZIP_ER_REMOVE        22  /* S Can't remove file */
-#define ZIP_ER_DELETED       23  /* N Entry has been deleted */
-
-
-/* type of system error value */
-
-#define ZIP_ET_NONE              0  /* sys_err unused */
-#define ZIP_ET_SYS              1  /* sys_err is errno */
-#define ZIP_ET_ZLIB              2  /* sys_err is zlib error code */
-
-/* compression methods */
-
-#define ZIP_CM_DEFAULT              -1  /* better of deflate or store */
-#define ZIP_CM_STORE               0  /* stored (uncompressed) */
-#define ZIP_CM_SHRINK               1  /* shrunk */
-#define ZIP_CM_REDUCE_1               2  /* reduced with factor 1 */
-#define ZIP_CM_REDUCE_2               3  /* reduced with factor 2 */
-#define ZIP_CM_REDUCE_3               4  /* reduced with factor 3 */
-#define ZIP_CM_REDUCE_4               5  /* reduced with factor 4 */
-#define ZIP_CM_IMPLODE               6  /* imploded */
-/* 7 - Reserved for Tokenizing compression algorithm */
-#define ZIP_CM_DEFLATE               8  /* deflated */
-#define ZIP_CM_DEFLATE64       9  /* deflate64 */
-#define ZIP_CM_PKWARE_IMPLODE 10  /* PKWARE imploding */
-/* 11 - Reserved by PKWARE */
-#define ZIP_CM_BZIP2          12  /* compressed using BZIP2 algorithm */
-/* 13 - Reserved by PKWARE */
-#define ZIP_CM_LZMA              14  /* LZMA (EFS) */
-/* 15-17 - Reserved by PKWARE */
-#define ZIP_CM_TERSE              18  /* compressed using IBM TERSE (new) */
-#define ZIP_CM_LZ77           19  /* IBM LZ77 z Architecture (PFS) */
-#define ZIP_CM_WAVPACK              97  /* WavPack compressed data */
-#define ZIP_CM_PPMD              98  /* PPMd version I, Rev 1 */
-
-/* encryption methods */
-
-#define ZIP_EM_NONE               0  /* not encrypted */
-#define ZIP_EM_TRAD_PKWARE     1  /* traditional PKWARE encryption */
-#if 0 /* Strong Encryption Header not parsed yet */
-#define ZIP_EM_DES        0x6601  /* strong encryption: DES */
-#define ZIP_EM_RC2_OLD    0x6602  /* strong encryption: RC2, version < 5.2 */
-#define ZIP_EM_3DES_168   0x6603
-#define ZIP_EM_3DES_112   0x6609
-#define ZIP_EM_AES_128    0x660e
-#define ZIP_EM_AES_192    0x660f
-#define ZIP_EM_AES_256    0x6610
-#define ZIP_EM_RC2        0x6702  /* strong encryption: RC2, version >= 5.2 */
-#define ZIP_EM_RC4        0x6801
-#endif
-#define ZIP_EM_UNKNOWN    0xffff  /* unknown algorithm */
-
-typedef long myoff_t; /* XXX: 64 bit support */
-
-enum zip_source_cmd {
-    ZIP_SOURCE_OPEN,        /* prepare for reading */
-    ZIP_SOURCE_READ,         /* read data */
-    ZIP_SOURCE_CLOSE,        /* reading is done */
-    ZIP_SOURCE_STAT,        /* get meta information */
-    ZIP_SOURCE_ERROR,        /* get error information */
-    ZIP_SOURCE_FREE        /* cleanup and free resources */
-};
-
-typedef ssize_t (*zip_source_callback)(void *state, void *data,
-                                       size_t len, enum zip_source_cmd cmd);
-
-struct zip_stat {
-    const char *name;                        /* name of the file */
-    int index;                                /* index within archive */
-    unsigned int crc;                        /* crc of file data */
-    time_t mtime;                        /* modification time */
-    myoff_t size;                                /* size of file (uncompressed) */
-    myoff_t comp_size;                        /* size of file (compressed) */
-    unsigned short comp_method;                /* compression method used */
-    unsigned short encryption_method;        /* encryption method used */
-};
-
-struct zip;
-struct zip_file;
-struct zip_source;
-
-
-ZIP_EXTERN int zip_add(struct zip *, const char *, struct zip_source *);
-ZIP_EXTERN int zip_add_dir(struct zip *, const char *);
-ZIP_EXTERN int zip_close(struct zip *);
-ZIP_EXTERN int zip_delete(struct zip *, int);
-ZIP_EXTERN void zip_error_clear(struct zip *);
-ZIP_EXTERN void zip_error_get(struct zip *, int *, int *);
-ZIP_EXTERN int zip_error_get_sys_type(int);
-ZIP_EXTERN int zip_error_to_str(char *, size_t, int, int);
-ZIP_EXTERN int zip_fclose(struct zip_file *);
-ZIP_EXTERN void zip_file_error_clear(struct zip_file *);
-ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *);
-ZIP_EXTERN const char *zip_file_strerror(struct zip_file *);
-ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, int);
-ZIP_EXTERN struct zip_file *zip_fopen_index(struct zip *, int, int);
-ZIP_EXTERN ssize_t zip_fread(struct zip_file *, void *, size_t);
-ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, int);
-ZIP_EXTERN int zip_get_archive_flag(struct zip *, int, int);
-ZIP_EXTERN const char *zip_get_file_comment(struct zip *, int, int *, int);
-ZIP_EXTERN const char *zip_get_name(struct zip *, int, int);
-ZIP_EXTERN int zip_get_num_files(struct zip *);
-ZIP_EXTERN int zip_name_locate(struct zip *, const char *, int);
-ZIP_EXTERN struct zip *zip_open(const char *, int, int *);
-ZIP_EXTERN int zip_rename(struct zip *, int, const char *);
-ZIP_EXTERN int zip_replace(struct zip *, int, struct zip_source *);
-ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, int);
-ZIP_EXTERN int zip_set_archive_flag(struct zip *, int, int);
-ZIP_EXTERN int zip_set_file_comment(struct zip *, int, const char *, int);
-ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *,
-                                                myoff_t, int);
-ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *,
-                                              myoff_t, myoff_t);
-ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *,
-                                               myoff_t, myoff_t);
-ZIP_EXTERN void zip_source_free(struct zip_source *);
-ZIP_EXTERN struct zip_source *zip_source_function(struct zip *,
-                                                  zip_source_callback, void *);
-ZIP_EXTERN struct zip_source *zip_source_zip(struct zip *, struct zip *,
-                                             int, int, myoff_t, myoff_t);
-ZIP_EXTERN int zip_stat(struct zip *, const char *, int, struct zip_stat *);
-ZIP_EXTERN int zip_stat_index(struct zip *, int, int, struct zip_stat *);
-ZIP_EXTERN void zip_stat_init(struct zip_stat *);
-ZIP_EXTERN const char *zip_strerror(struct zip *);
-ZIP_EXTERN int zip_unchange(struct zip *, int);
-ZIP_EXTERN int zip_unchange_all(struct zip *);
-ZIP_EXTERN int zip_unchange_archive(struct zip *);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
-   */
-/* #undef HAVE_DECL_TZNAME */
-
-#define HAVE_CONFIG_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `fseeko' function. */
-#define HAVE_FSEEKO 1
-
-/* Define to 1 if you have the `ftello' function. */
-#define HAVE_FTELLO 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `z' library (-lz). */
-#define HAVE_LIBZ 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mkstemp' function. */
-#define HAVE_MKSTEMP 1
-
-/* Define to 1 if you have the `MoveFileExA' function. */
-/* #undef HAVE_MOVEFILEEXA */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if `tm_zone' is member of `struct tm'. */
-#define HAVE_STRUCT_TM_TM_ZONE 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
-   `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#define HAVE_TM_ZONE 1
-
-/* Define to 1 if you don't have `tm_zone' but do have the external array
-   `tzname'. */
-/* #undef HAVE_TZNAME */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Name of package */
-#define PACKAGE "libzip"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "libzip@nih.at"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libzip"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libzip 0.9"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libzip"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.9"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-/* #undef TM_IN_SYS_TIME */
-
-/* Version number of package */
-#define VERSION "0.9"
-
-
-#ifndef HAVE_MKSTEMP
-int _zip_mkstemp(char *);
-#define mkstemp _zip_mkstemp
-#endif
-
-#ifdef HAVE_MOVEFILEEXA
-#include <windows.h>
-#define _zip_rename(s, t)                                                \
-        (!MoveFileExA((s), (t),                                                \
-                     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
-#else
-#define _zip_rename        rename
-#endif
-
-#ifndef HAVE_FSEEKO
-#define fseeko(s, o, w)        (fseek((s), (long int)(o), (w)))
-#endif
-#ifndef HAVE_FTELLO
-#define ftello(s)        ((long)ftell((s)))
-#endif
-
-
-#define CENTRAL_MAGIC "PK\1\2"
-#define LOCAL_MAGIC   "PK\3\4"
-#define EOCD_MAGIC    "PK\5\6"
-#define DATADES_MAGIC "PK\7\8"
-#define TORRENT_SIG        "TORRENTZIPPED-"
-#define TORRENT_SIG_LEN        14
-#define TORRENT_CRC_LEN 8
-#define TORRENT_MEM_LEVEL        8
-#define CDENTRYSIZE         46u
-#define LENTRYSIZE          30
-#define MAXCOMLEN        65536
-#define EOCDLEN             22
-#define CDBUFSIZE       (MAXCOMLEN+EOCDLEN)
-#define BUFSIZE                8192
-
-
-/* state of change of a file in zip archive */
-
-enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
-                 ZIP_ST_ADDED, ZIP_ST_RENAMED };
-
-/* constants for struct zip_file's member flags */
-
-#define ZIP_ZF_EOF        1 /* EOF reached */
-#define ZIP_ZF_DECOMP        2 /* decompress data */
-#define ZIP_ZF_CRC        4 /* compute and compare CRC */
-
-/* directory entry: general purpose bit flags */
-
-#define ZIP_GPBF_ENCRYPTED                0x0001        /* is encrypted */
-#define ZIP_GPBF_DATA_DESCRIPTOR        0x0008        /* crc/size after file data */
-#define ZIP_GPBF_STRONG_ENCRYPTION        0x0040  /* uses strong encryption */
-
-/* error information */
-
-struct zip_error {
-    int zip_err;        /* libzip error code (ZIP_ER_*) */
-    int sys_err;        /* copy of errno (E*) or zlib error code */
-    char *str;                /* string representation or NULL */
-};
-
-/* zip archive, part of API */
-
-struct zip {
-    char *zn;                        /* file name */
-    FILE *zp;                        /* file */
-    struct zip_error error;        /* error information */
-
-    unsigned int flags;                /* archive global flags */
-    unsigned int ch_flags;        /* changed archive global flags */
-
-    struct zip_cdir *cdir;        /* central directory */
-    char *ch_comment;                /* changed archive comment */
-    int ch_comment_len;                /* length of changed zip archive
-                                 * comment, -1 if unchanged */
-    int nentry;                        /* number of entries */
-    int nentry_alloc;                /* number of entries allocated */
-    struct zip_entry *entry;        /* entries */
-    int nfile;                        /* number of opened files within archive */
-    int nfile_alloc;                /* number of files allocated */
-    struct zip_file **file;        /* opened files within archive */
-};
-
-/* file in zip archive, part of API */
-
-struct zip_file {
-    struct zip *za;                /* zip archive containing this file */
-    struct zip_error error;        /* error information */
-    int flags;                        /* -1: eof, >0: error */
-
-    int method;                        /* compression method */
-    myoff_t fpos;                        /* position within zip file (fread/fwrite) */
-    unsigned long bytes_left;        /* number of bytes left to read */
-    unsigned long cbytes_left;  /* number of bytes of compressed data left */
-    
-    unsigned long crc;                /* CRC so far */
-    unsigned long crc_orig;        /* CRC recorded in archive */
-    
-    char *buffer;
-    z_stream *zstr;
-};
-
-/* zip archive directory entry (central or local) */
-
-struct zip_dirent {
-    unsigned short version_madeby;        /* (c)  version of creator */
-    unsigned short version_needed;        /* (cl) version needed to extract */
-    unsigned short bitflags;                /* (cl) general purpose bit flag */
-    unsigned short comp_method;                /* (cl) compression method used */
-    time_t last_mod;                        /* (cl) time of last modification */
-    unsigned int crc;                        /* (cl) CRC-32 of uncompressed data */
-    unsigned int comp_size;                /* (cl) size of commpressed data */
-    unsigned int uncomp_size;                /* (cl) size of uncommpressed data */
-    char *filename;                        /* (cl) file name (NUL-terminated) */
-    unsigned short filename_len;        /* (cl) length of filename (w/o NUL) */
-    char *extrafield;                        /* (cl) extra field */
-    unsigned short extrafield_len;        /* (cl) length of extra field */
-    char *comment;                        /* (c)  file comment */
-    unsigned short comment_len;                /* (c)  length of file comment */
-    unsigned short disk_number;                /* (c)  disk number start */
-    unsigned short int_attrib;                /* (c)  internal file attributes */
-    unsigned int ext_attrib;                /* (c)  external file attributes */
-    unsigned int offset;                /* (c)  offset of local header  */
-};
-
-/* zip archive central directory */
-
-struct zip_cdir {
-    struct zip_dirent *entry;        /* directory entries */
-    int nentry;                        /* number of entries */
-
-    unsigned int size;                /* size of central direcotry */
-    unsigned int offset;        /* offset of central directory in file */
-    char *comment;                /* zip archive comment */
-    unsigned short comment_len;        /* length of zip archive comment */
-};
-
-
-
-struct zip_source {
-    zip_source_callback f;
-    void *ud;
-};
-
-/* entry in zip archive directory */
-
-struct zip_entry {
-    enum zip_state state;
-    struct zip_source *source;
-    char *ch_filename;
-    char *ch_comment;
-    int ch_comment_len;
-};
-
-
-
-extern const char * const _zip_err_str[];
-extern const int _zip_nerr_str;
-extern const int _zip_err_type[];
-
-
-
-#define ZIP_ENTRY_DATA_CHANGED(x)        \
-                        ((x)->state == ZIP_ST_REPLACED  \
-                         || (x)->state == ZIP_ST_ADDED)
-
-
-
-int _zip_cdir_compute_crc(struct zip *, uLong *);
-void _zip_cdir_free(struct zip_cdir *);
-struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
-int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
-
-void _zip_dirent_finalize(struct zip_dirent *);
-void _zip_dirent_init(struct zip_dirent *);
-int _zip_dirent_read(struct zip_dirent *, FILE *,
-                     unsigned char **, unsigned int, int, struct zip_error *);
-void _zip_dirent_torrent_normalize(struct zip_dirent *);
-int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
-
-void _zip_entry_free(struct zip_entry *);
-void _zip_entry_init(struct zip *, int);
-struct zip_entry *_zip_entry_new(struct zip *);
-
-void _zip_error_clear(struct zip_error *);
-void _zip_error_copy(struct zip_error *, struct zip_error *);
-void _zip_error_fini(struct zip_error *);
-void _zip_error_get(struct zip_error *, int *, int *);
-void _zip_error_init(struct zip_error *);
-void _zip_error_set(struct zip_error *, int, int);
-const char *_zip_error_strerror(struct zip_error *);
-
-int _zip_file_fillbuf(void *, size_t, struct zip_file *);
-unsigned int _zip_file_get_offset(struct zip *, int);
-
-int _zip_filerange_crc(FILE *, myoff_t, myoff_t, uLong *, struct zip_error *);
-
-struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
-                                         myoff_t, myoff_t);
-
-void _zip_free(struct zip *);
-const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
-int _zip_local_header_read(struct zip *, int);
-void *_zip_memdup(const void *, size_t, struct zip_error *);
-int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
-struct zip *_zip_new(struct zip_error *);
-unsigned short _zip_read2(unsigned char **);
-unsigned int _zip_read4(unsigned char **);
-int _zip_replace(struct zip *, int, const char *, struct zip_source *);
-int _zip_set_name(struct zip *, int, const char *);
-int _zip_unchange(struct zip *, int, int);
-void _zip_unchange_data(struct zip_entry *);
-
-         
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-const char *
-_zip_error_strerror(struct zip_error *err)
-{
-    const char *zs, *ss;
-    char buf[128], *s;
-
-    _zip_error_fini(err);
-
-    if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
-        sprintf(buf, "Unknown error %d", err->zip_err);
-        zs = NULL;
-        ss = buf;
-    }
-    else {
-        zs = _zip_err_str[err->zip_err];
-        
-        switch (_zip_err_type[err->zip_err]) {
-        case ZIP_ET_SYS:
-            ss = strerror(err->sys_err);
-            break;
-
-        case ZIP_ET_ZLIB:
-            ss = zError(err->sys_err);
-            break;
-
-        default:
-            ss = NULL;
-        }
-    }
-
-    if (ss == NULL)
-        return zs;
-    else {
-        if ((s=(char *)malloc(strlen(ss)
-                              + (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
-            return _zip_err_str[ZIP_ER_MEMORY];
-        
-        sprintf(s, "%s%s%s",
-                (zs ? zs : ""),
-                (zs ? ": " : ""),
-                ss);
-        err->str = s;
-
-        return s;
-    }
-}
-
-#include <stdlib.h>
-
-
-
-void
-_zip_error_clear(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-}
-
-
-
-void
-_zip_error_copy(struct zip_error *dst, struct zip_error *src)
-{
-    dst->zip_err = src->zip_err;
-    dst->sys_err = src->sys_err;
-}
-
-
-
-void
-_zip_error_fini(struct zip_error *err)
-{
-    free(err->str);
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_get(struct zip_error *err, int *zep, int *sep)
-{
-    if (zep)
-        *zep = err->zip_err;
-    if (sep) {
-        if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
-            *sep = err->sys_err;
-        else
-            *sep = 0;
-    }
-}
-
-
-
-void
-_zip_error_init(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_set(struct zip_error *err, int ze, int se)
-{
-    if (err) {
-        err->zip_err = ze;
-        err->sys_err = se;
-    }
-}
-
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-
-
-int
-_zip_mkstemp(char *path)
-{
-        int fd;   
-        char *start, *trv;
-        struct stat sbuf;
-        pid_t pid;
-
-        /* To guarantee multiple calls generate unique names even if
-           the file is not created. 676 different possibilities with 7
-           or more X's, 26 with 6 or less. */
-        static char xtra[2] = "aa";
-        int xcnt = 0;
-
-        pid = getpid();
-
-        /* Move to end of path and count trailing X's. */
-        for (trv = path; *trv; ++trv)
-                if (*trv == 'X')
-                        xcnt++;
-                else
-                        xcnt = 0;        
-
-        /* Use at least one from xtra.  Use 2 if more than 6 X's. */
-        if (*(trv - 1) == 'X')
-                *--trv = xtra[0];
-        if (xcnt > 6 && *(trv - 1) == 'X')
-                *--trv = xtra[1];
-
-        /* Set remaining X's to pid digits with 0's to the left. */
-        while (*--trv == 'X') {
-                *trv = (pid % 10) + '0';
-                pid /= 10;
-        }
-
-        /* update xtra for next call. */
-        if (xtra[0] != 'z')
-                xtra[0]++;
-        else {
-                xtra[0] = 'a';
-                if (xtra[1] != 'z')
-                        xtra[1]++;
-                else
-                        xtra[1] = 'a';
-        }
-
-        /*
-         * check the target directory; if you have six X's and it
-         * doesn't exist this runs for a *very* long time.
-         */
-        for (start = trv + 1;; --trv) {
-                if (trv <= path)
-                        break;
-                if (*trv == '/') {
-                        *trv = '\0';
-                        if (stat(path, &sbuf))
-                                return (0);
-                        if (!S_ISDIR(sbuf.st_mode)) {
-                                errno = ENOTDIR;
-                                return (0);
-                        }
-                        *trv = '/';
-                        break;
-                }
-        }
-
-        for (;;) {
-                if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0)
-                        return (fd);
-                if (errno != EEXIST)
-                        return (0);
-
-                /* tricky little algorithm for backward compatibility */
-                for (trv = start;;) {
-                        if (!*trv)
-                                return (0);
-                        if (*trv == 'z')
-                                *trv++ = 'a';
-                        else {
-                                if (isdigit((unsigned char)*trv))
-                                        *trv = 'a';
-                                else
-                                        ++*trv;
-                                break;
-                        }
-                }
-        }
-        /*NOTREACHED*/
-}
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-static time_t _zip_d2u_time(int, int);
-static char *_zip_readfpstr(FILE *, unsigned int, int, struct zip_error *);
-static char *_zip_readstr(unsigned char **, int, int, struct zip_error *);
-static void _zip_u2d_time(time_t, unsigned short *, unsigned short *);
-static void _zip_write2(unsigned short, FILE *);
-static void _zip_write4(unsigned int, FILE *);
-
-
-
-void
-_zip_cdir_free(struct zip_cdir *cd)
-{
-    int i;
-
-    if (!cd)
-        return;
-
-    for (i=0; i<cd->nentry; i++)
-        _zip_dirent_finalize(cd->entry+i);
-    free(cd->comment);
-    free(cd->entry);
-    free(cd);
-}
-
-
-
-struct zip_cdir *
-_zip_cdir_new(int nentry, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    
-    if ((cd=(struct zip_cdir *)malloc(sizeof(*cd))) == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if ((cd->entry=(struct zip_dirent *)malloc(sizeof(*(cd->entry))*nentry))
-        == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        free(cd);
-        return NULL;
-    }
-
-    /* entries must be initialized by caller */
-
-    cd->nentry = nentry;
-    cd->size = cd->offset = 0;
-    cd->comment = NULL;
-    cd->comment_len = 0;
-
-    return cd;
-}
-
-
-
-int
-_zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error)
-{
-    int i;
-
-    cd->offset = ftello(fp);
-
-    for (i=0; i<cd->nentry; i++) {
-        if (_zip_dirent_write(cd->entry+i, fp, 0, error) != 0)
-            return -1;
-    }
-
-    cd->size = ftello(fp) - cd->offset;
-    
-    /* clearerr(fp); */
-    fwrite(EOCD_MAGIC, 1, 4, fp);
-    _zip_write4(0, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write4(cd->size, fp);
-    _zip_write4(cd->offset, fp);
-    _zip_write2(cd->comment_len, fp);
-    fwrite(cd->comment, 1, cd->comment_len, fp);
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-void
-_zip_dirent_finalize(struct zip_dirent *zde)
-{
-    free(zde->filename);
-    zde->filename = NULL;
-    free(zde->extrafield);
-    zde->extrafield = NULL;
-    free(zde->comment);
-    zde->comment = NULL;
-}
-
-
-
-void
-_zip_dirent_init(struct zip_dirent *de)
-{
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 0;
-    de->comp_method = 0;
-    de->last_mod = 0;
-    de->crc = 0;
-    de->comp_size = 0;
-    de->uncomp_size = 0;
-    de->filename = NULL;
-    de->filename_len = 0;
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    de->comment = NULL;
-    de->comment_len = 0;
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-}
-
-
-
-/* _zip_dirent_read(zde, fp, bufp, left, localp, error):
-   Fills the zip directory entry zde.
-
-   If bufp is non-NULL, data is taken from there and bufp is advanced
-   by the amount of data used; no more than left bytes are used.
-   Otherwise data is read from fp as needed.
-
-   If localp != 0, it reads a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_read(struct zip_dirent *zde, FILE *fp,
-                 unsigned char **bufp, unsigned int left, int localp,
-                 struct zip_error *error)
-{
-    unsigned char buf[CDENTRYSIZE];
-    unsigned char *cur;
-    unsigned short dostime, dosdate;
-    unsigned int size;
-
-    if (localp)
-        size = LENTRYSIZE;
-    else
-        size = CDENTRYSIZE;
-    
-    if (bufp) {
-        /* use data from buffer */
-        cur = *bufp;
-        if (left < size) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-    }
-    else {
-        /* read entry from disk */
-        if ((fread(buf, 1, size, fp)<size)) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        left = size;
-        cur = buf;
-    }
-
-    if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return -1;
-    }
-    cur += 4;
-
-    
-    /* convert buffercontents to zip_dirent */
-    
-    if (!localp)
-        zde->version_madeby = _zip_read2(&cur);
-    else
-        zde->version_madeby = 0;
-    zde->version_needed = _zip_read2(&cur);
-    zde->bitflags = _zip_read2(&cur);
-    zde->comp_method = _zip_read2(&cur);
-    
-    /* convert to time_t */
-    dostime = _zip_read2(&cur);
-    dosdate = _zip_read2(&cur);
-    zde->last_mod = _zip_d2u_time(dostime, dosdate);
-    
-    zde->crc = _zip_read4(&cur);
-    zde->comp_size = _zip_read4(&cur);
-    zde->uncomp_size = _zip_read4(&cur);
-    
-    zde->filename_len = _zip_read2(&cur);
-    zde->extrafield_len = _zip_read2(&cur);
-    
-    if (localp) {
-        zde->comment_len = 0;
-        zde->disk_number = 0;
-        zde->int_attrib = 0;
-        zde->ext_attrib = 0;
-        zde->offset = 0;
-    } else {
-        zde->comment_len = _zip_read2(&cur);
-        zde->disk_number = _zip_read2(&cur);
-        zde->int_attrib = _zip_read2(&cur);
-        zde->ext_attrib = _zip_read4(&cur);
-        zde->offset = _zip_read4(&cur);
-    }
-
-    zde->filename = NULL;
-    zde->extrafield = NULL;
-    zde->comment = NULL;
-
-    if (bufp) {
-        if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len
-                                  +zde->comment_len)) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-
-        if (zde->filename_len) {
-            zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readstr(&cur, zde->extrafield_len, 0,
-                                           error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readstr(&cur, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-    else {
-        if (zde->filename_len) {
-            zde->filename = _zip_readfpstr(fp, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readfpstr(fp, zde->extrafield_len, 0,
-                                             error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readfpstr(fp, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-
-    if (bufp)
-      *bufp = cur;
-
-    return 0;
-}
-
-
-
-/* _zip_dirent_torrent_normalize(de);
-   Set values suitable for torrentzip.
-*/
-
-void
-_zip_dirent_torrent_normalize(struct zip_dirent *de)
-{
-    static struct tm torrenttime;
-    static time_t last_mod = 0;
-
-    if (last_mod == 0) {
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time_t now;
-        struct tm *l;
-#endif
-
-        torrenttime.tm_sec = 0;
-        torrenttime.tm_min = 32;
-        torrenttime.tm_hour = 23;
-        torrenttime.tm_mday = 24;
-        torrenttime.tm_mon = 11;
-        torrenttime.tm_year = 96;
-        torrenttime.tm_wday = 0;
-        torrenttime.tm_yday = 0;
-        torrenttime.tm_isdst = 0;
-
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time(&now);
-        l = localtime(&now);
-        torrenttime.tm_gmtoff = l->tm_gmtoff;
-        torrenttime.tm_zone = l->tm_zone;
-#endif
-
-        last_mod = mktime(&torrenttime);
-    }
-    
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 2; /* maximum compression */
-    de->comp_method = ZIP_CM_DEFLATE;
-    de->last_mod = last_mod;
-
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-
-    free(de->extrafield);
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    free(de->comment);
-    de->comment = NULL;
-    de->comment_len = 0;
-}
-
-
-
-/* _zip_dirent_write(zde, fp, localp, error):
-   Writes zip directory entry zde to file fp.
-
-   If localp != 0, it writes a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp,
-                  struct zip_error *error)
-{
-    unsigned short dostime, dosdate;
-
-    fwrite(localp ? LOCAL_MAGIC : CENTRAL_MAGIC, 1, 4, fp);
-
-    if (!localp)
-        _zip_write2(zde->version_madeby, fp);
-    _zip_write2(zde->version_needed, fp);
-    _zip_write2(zde->bitflags, fp);
-    _zip_write2(zde->comp_method, fp);
-
-    _zip_u2d_time(zde->last_mod, &dostime, &dosdate);
-    _zip_write2(dostime, fp);
-    _zip_write2(dosdate, fp);
-    
-    _zip_write4(zde->crc, fp);
-    _zip_write4(zde->comp_size, fp);
-    _zip_write4(zde->uncomp_size, fp);
-    
-    _zip_write2(zde->filename_len, fp);
-    _zip_write2(zde->extrafield_len, fp);
-    
-    if (!localp) {
-        _zip_write2(zde->comment_len, fp);
-        _zip_write2(zde->disk_number, fp);
-        _zip_write2(zde->int_attrib, fp);
-        _zip_write4(zde->ext_attrib, fp);
-        _zip_write4(zde->offset, fp);
-    }
-
-    if (zde->filename_len)
-        fwrite(zde->filename, 1, zde->filename_len, fp);
-
-    if (zde->extrafield_len)
-        fwrite(zde->extrafield, 1, zde->extrafield_len, fp);
-
-    if (!localp) {
-        if (zde->comment_len)
-            fwrite(zde->comment, 1, zde->comment_len, fp);
-    }
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static time_t
-_zip_d2u_time(int dtime, int ddate)
-{
-    struct tm *tm;
-    time_t now;
-
-    now = time(NULL);
-    tm = localtime(&now);
-    /* let mktime decide if DST is in effect */
-    tm->tm_isdst = -1;
-    
-    tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
-    tm->tm_mon = ((ddate>>5)&15) - 1;
-    tm->tm_mday = ddate&31;
-
-    tm->tm_hour = (dtime>>11)&31;
-    tm->tm_min = (dtime>>5)&63;
-    tm->tm_sec = (dtime<<1)&62;
-
-    return mktime(tm);
-}
-
-
-
-unsigned short
-_zip_read2(unsigned char **a)
-{
-    unsigned short ret;
-
-    ret = (*a)[0]+((*a)[1]<<8);
-    *a += 2;
-
-    return ret;
-}
-
-
-
-unsigned int
-_zip_read4(unsigned char **a)
-{
-    unsigned int ret;
-
-    ret = ((((((*a)[3]<<8)+(*a)[2])<<8)+(*a)[1])<<8)+(*a)[0];
-    *a += 4;
-
-    return ret;
-}
-
-
-
-static char *
-_zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if (fread(r, 1, len, fp)<len) {
-        free(r);
-        _zip_error_set(error, ZIP_ER_READ, errno);
-        return NULL;
-    }
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-    
-    return r;
-}
-
-
-
-static char *
-_zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    memcpy(r, *buf, len);
-    *buf += len;
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-
-    return r;
-}
-
-
-
-static void
-_zip_write2(unsigned short i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-
-    return;
-}
-
-
-
-static void
-_zip_write4(unsigned int i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-    putc((i>>16)&0xff, fp);
-    putc((i>>24)&0xff, fp);
-    
-    return;
-}
-
-
-
-static void
-_zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate)
-{
-    struct tm *tm;
-
-    tm = localtime(&time);
-    *ddate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5)
-        + tm->tm_mday;
-    *dtime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5)
-        + ((tm->tm_sec)>>1);
-
-    return;
-}
-
-
-
-ZIP_EXTERN int
-zip_delete(struct zip *za, int idx)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    /* allow duplicate file names, because the file will
-     * be removed directly afterwards */
-    if (_zip_unchange(za, idx, 1) != 0)
-        return -1;
-
-    za->entry[idx].state = ZIP_ST_DELETED;
-
-    return 0;
-}
-
-
-
-ZIP_EXTERN void
-zip_error_clear(struct zip *za)
-{
-    _zip_error_clear(&za->error);
-}
-
-
-ZIP_EXTERN int
-zip_add(struct zip *za, const char *name, struct zip_source *source)
-{
-    if (name == NULL || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-        
-    return _zip_replace(za, -1, name, source);
-}
-
-
-ZIP_EXTERN int
-zip_error_get_sys_type(int ze)
-{
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return 0;
-
-    return _zip_err_type[ze];
-}
-
-
-ZIP_EXTERN void
-zip_error_get(struct zip *za, int *zep, int *sep)
-{
-    _zip_error_get(&za->error, zep, sep);
-}
-
-
-const char * const _zip_err_str[] = {
-    "No error",
-    "Multi-disk zip archives not supported",
-    "Renaming temporary file failed",
-    "Closing zip archive failed",
-    "Seek error",
-    "Read error",
-    "Write error",
-    "CRC error",
-    "Containing zip archive was closed",
-    "No such file",
-    "File already exists",
-    "Can't open file",
-    "Failure to create temporary file",
-    "Zlib error",
-    "Malloc failure",
-    "Entry has been changed",
-    "Compression method not supported",
-    "Premature EOF",
-    "Invalid argument",
-    "Not a zip archive",
-    "Internal error",
-    "Zip archive inconsistent",
-    "Can't remove file",
-    "Entry has been deleted",
-};
-
-const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
-
-#define N ZIP_ET_NONE
-#define S ZIP_ET_SYS
-#define Z ZIP_ET_ZLIB
-
-const int _zip_err_type[] = {
-    N,
-    N,
-    S,
-    S,
-    S,
-    S,
-    S,
-    N,
-    N,
-    N,
-    N,
-    S,
-    S,
-    Z,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    S,
-    N,
-};
-
-
-struct zip_entry *
-_zip_entry_new(struct zip *za)
-{
-    struct zip_entry *ze;
-    if (!za) {
-        ze = (struct zip_entry *)malloc(sizeof(struct zip_entry));
-        if (!ze) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return NULL;
-        }
-    }
-    else {
-        if (za->nentry >= za->nentry_alloc-1) {
-            za->nentry_alloc += 16;
-            za->entry = (struct zip_entry *)realloc(za->entry,
-                                                    sizeof(struct zip_entry)
-                                                    * za->nentry_alloc);
-            if (!za->entry) {
-                _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-                return NULL;
-            }
-        }
-        ze = za->entry+za->nentry;
-    }
-
-    ze->state = ZIP_ST_UNCHANGED;
-
-    ze->ch_filename = NULL;
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-    ze->source = NULL;
-
-    if (za)
-        za->nentry++;
-
-    return ze;
-}
-
-
-void
-_zip_entry_free(struct zip_entry *ze)
-{
-    free(ze->ch_filename);
-    ze->ch_filename = NULL;
-    free(ze->ch_comment);
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-
-    _zip_unchange_data(ze);
-}
-
-
-static int add_data(struct zip *, struct zip_source *, struct zip_dirent *,
-                    FILE *);
-static int add_data_comp(zip_source_callback, void *, struct zip_stat *,
-                         FILE *, struct zip_error *);
-static int add_data_uncomp(struct zip *, zip_source_callback, void *,
-                           struct zip_stat *, FILE *);
-static void ch_set_error(struct zip_error *, zip_source_callback, void *);
-static int copy_data(FILE *, myoff_t, FILE *, struct zip_error *);
-static int write_cdir(struct zip *, struct zip_cdir *, FILE *);
-static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *);
-static int _zip_changed(struct zip *, int *);
-static char *_zip_create_temp_output(struct zip *, FILE **);
-static int _zip_torrentzip_cmp(const void *, const void *);
-
-
-
-struct filelist {
-    int idx;
-    const char *name;
-};
-
-
-
-ZIP_EXTERN int
-zip_close(struct zip *za)
-{
-    int survivors;
-    int i, j, error;
-    char *temp;
-    FILE *out;
-    mode_t mask;
-    struct zip_cdir *cd;
-    struct zip_dirent de;
-    struct filelist *filelist;
-    int reopen_on_error;
-    int new_torrentzip;
-
-    reopen_on_error = 0;
-
-    if (za == NULL)
-        return -1;
-
-    if (!_zip_changed(za, &survivors)) {
-        _zip_free(za);
-        return 0;
-    }
-
-    /* don't create zip files with no entries */
-    if (survivors == 0) {
-        if (za->zn && za->zp) {
-            if (remove(za->zn) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_REMOVE, errno);
-                return -1;
-            }
-        }
-        _zip_free(za);
-        return 0;
-    }               
-
-    if ((filelist=(struct filelist *)malloc(sizeof(filelist[0])*survivors))
-        == NULL)
-        return -1;
-
-    if ((cd=_zip_cdir_new(survivors, &za->error)) == NULL) {
-        free(filelist);
-        return -1;
-    }
-
-    for (i=0; i<survivors; i++)
-        _zip_dirent_init(&cd->entry[i]);
-
-    /* archive comment is special for torrentzip */
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
-        cd->comment = _zip_memdup(TORRENT_SIG "XXXXXXXX",
-                                  TORRENT_SIG_LEN + TORRENT_CRC_LEN,
-                                  &za->error);
-        if (cd->comment == NULL) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-        cd->comment_len = TORRENT_SIG_LEN + TORRENT_CRC_LEN;
-    }
-    else if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, ZIP_FL_UNCHANGED) == 0) {
-        if (_zip_cdir_set_comment(cd, za) == -1) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-    }
-
-    if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
-        _zip_cdir_free(cd);
-        return -1;
-    }
-
-
-    /* create list of files with index into original archive  */
-    for (i=j=0; i<za->nentry; i++) {
-        if (za->entry[i].state == ZIP_ST_DELETED)
-            continue;
-
-        filelist[j].idx = i;
-        filelist[j].name = zip_get_name(za, i, 0);
-        j++;
-    }
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        qsort(filelist, survivors, sizeof(filelist[0]),
-              _zip_torrentzip_cmp);
-
-    new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
-                      && zip_get_archive_flag(za, ZIP_AFL_TORRENT,
-                                              ZIP_FL_UNCHANGED) == 0);
-    error = 0;
-    for (j=0; j<survivors; j++) {
-        i = filelist[j].idx;
-
-        /* create new local directory entry */
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            _zip_dirent_init(&de);
-
-            if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-                _zip_dirent_torrent_normalize(&de);
-                
-            /* use it as central directory entry */
-            memcpy(cd->entry+j, &de, sizeof(cd->entry[j]));
-
-            /* set/update file name */
-            if (za->entry[i].ch_filename == NULL) {
-                if (za->entry[i].state == ZIP_ST_ADDED) {
-                    de.filename = strdup("-");
-                    de.filename_len = 1;
-                    cd->entry[j].filename = "-";
-                }
-                else {
-                    de.filename = strdup(za->cdir->entry[i].filename);
-                    de.filename_len = strlen(de.filename);
-                    cd->entry[j].filename = za->cdir->entry[i].filename;
-                    cd->entry[j].filename_len = de.filename_len;
-                }
-            }
-        }
-        else {
-            /* copy existing directory entries */
-            if (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-                error = 1;
-                break;
-            }
-            if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) {
-                error = 1;
-                break;
-            }
-            if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
-                de.crc = za->cdir->entry[i].crc;
-                de.comp_size = za->cdir->entry[i].comp_size;
-                de.uncomp_size = za->cdir->entry[i].uncomp_size;
-                de.bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
-            }
-            memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j]));
-        }
-
-        if (za->entry[i].ch_filename) {
-            free(de.filename);
-            if ((de.filename=strdup(za->entry[i].ch_filename)) == NULL) {
-                error = 1;
-                break;
-            }
-            de.filename_len = strlen(de.filename);
-            cd->entry[j].filename = za->entry[i].ch_filename;
-            cd->entry[j].filename_len = de.filename_len;
-        }
-
-        if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0
-            && za->entry[i].ch_comment_len != -1) {
-            /* as the rest of cd entries, its malloc/free is done by za */
-            cd->entry[j].comment = za->entry[i].ch_comment;
-            cd->entry[j].comment_len = za->entry[i].ch_comment_len;
-        }
-
-        cd->entry[j].offset = ftello(out);
-
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            struct zip_source *zs;
-
-            zs = NULL;
-            if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) {
-                if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1))
-                    == NULL) {
-                    error = 1;
-                    break;
-                }
-            }
-
-            if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) {
-                error = 1;
-                break;
-            }
-            cd->entry[j].last_mod = de.last_mod;
-            cd->entry[j].comp_method = de.comp_method;
-            cd->entry[j].comp_size = de.comp_size;
-            cd->entry[j].uncomp_size = de.uncomp_size;
-            cd->entry[j].crc = de.crc;
-        }
-        else {
-            if (_zip_dirent_write(&de, out, 1, &za->error) < 0) {
-                error = 1;
-                break;
-            }
-            /* we just read the local dirent, file is at correct position */
-            if (copy_data(za->zp, cd->entry[j].comp_size, out,
-                          &za->error) < 0) {
-                error = 1;
-                break;
-            }
-        }
-
-        _zip_dirent_finalize(&de);
-    }
-
-    if (!error) {
-        if (write_cdir(za, cd, out) < 0)
-            error = 1;
-    }
-   
-    /* pointers in cd entries are owned by za */
-    cd->nentry = 0;
-    _zip_cdir_free(cd);
-
-    if (error) {
-        _zip_dirent_finalize(&de);
-        fclose(out);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-
-    if (fclose(out) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_CLOSE, errno);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-    
-    if (za->zp) {
-        fclose(za->zp);
-        za->zp = NULL;
-        reopen_on_error = 1;
-    }
-    if (_zip_rename(temp, za->zn) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_RENAME, errno);
-        remove(temp);
-        free(temp);
-        if (reopen_on_error) {
-            /* ignore errors, since we're already in an error case */
-            za->zp = fopen(za->zn, "rb");
-        }
-        return -1;
-    }
-    mask = umask(0);
-    umask(mask);
-    chmod(za->zn, 0666&~mask);
-
-    _zip_free(za);
-    free(temp);
-    
-    return 0;
-}
-
-
-
-static int
-add_data(struct zip *za, struct zip_source *zs, struct zip_dirent *de, FILE *ft)
-{
-    myoff_t offstart, offend;
-    zip_source_callback cb;
-    void *ud;
-    struct zip_stat st;
-    
-    cb = zs->f;
-    ud = zs->ud;
-
-    if (cb(ud, &st, sizeof(st), ZIP_SOURCE_STAT) < (ssize_t)sizeof(st)) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_OPEN) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offstart = ftello(ft);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-
-    if (st.comp_method != ZIP_CM_STORE) {
-        if (add_data_comp(cb, ud, &st, ft, &za->error) < 0)
-            return -1;
-    }
-    else {
-        if (add_data_uncomp(za, cb, ud, &st, ft) < 0)
-            return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_CLOSE) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offend = ftello(ft);
-
-    if (fseeko(ft, offstart, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    
-    de->last_mod = st.mtime;
-    de->comp_method = st.comp_method;
-    de->crc = st.crc;
-    de->uncomp_size = st.size;
-    de->comp_size = st.comp_size;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        _zip_dirent_torrent_normalize(de);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-    
-    if (fseeko(ft, offend, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-add_data_comp(zip_source_callback cb, void *ud, struct zip_stat *st,FILE *ft,
-              struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    ssize_t n;
-
-    st->comp_size = 0;
-    while ((n=cb(ud, buf, sizeof(buf), ZIP_SOURCE_READ)) > 0) {
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        st->comp_size += n;
-    }
-    if (n < 0) {
-        ch_set_error(error, cb, ud);
-        return -1;
-    }        
-
-    return 0;
-}
-
-
-
-static int
-add_data_uncomp(struct zip *za, zip_source_callback cb, void *ud,
-                struct zip_stat *st, FILE *ft)
-{
-    char b1[BUFSIZE], b2[BUFSIZE];
-    int end, flush, ret;
-    ssize_t n;
-    size_t n2;
-    z_stream zstr;
-    int mem_level;
-
-    st->comp_method = ZIP_CM_DEFLATE;
-    st->comp_size = st->size = 0;
-    st->crc = crc32(0, NULL, 0);
-
-    zstr.zalloc = Z_NULL;
-    zstr.zfree = Z_NULL;
-    zstr.opaque = NULL;
-    zstr.avail_in = 0;
-    zstr.avail_out = 0;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        mem_level = TORRENT_MEM_LEVEL;
-    else
-        mem_level = MAX_MEM_LEVEL;
-
-    /* -MAX_WBITS: undocumented feature of zlib to _not_ write a zlib header */
-    deflateInit2(&zstr, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, mem_level,
-                 Z_DEFAULT_STRATEGY);
-
-    zstr.next_out = (Bytef *)b2;
-    zstr.avail_out = sizeof(b2);
-    zstr.avail_in = 0;
-
-    flush = 0;
-    end = 0;
-    while (!end) {
-        if (zstr.avail_in == 0 && !flush) {
-            if ((n=cb(ud, b1, sizeof(b1), ZIP_SOURCE_READ)) < 0) {
-                ch_set_error(&za->error, cb, ud);
-                deflateEnd(&zstr);
-                return -1;
-            }
-            if (n > 0) {
-                zstr.avail_in = n;
-                zstr.next_in = (Bytef *)b1;
-                st->size += n;
-                st->crc = crc32(st->crc, (Bytef *)b1, n);
-            }
-            else
-                flush = Z_FINISH;
-        }
-
-        ret = deflate(&zstr, flush);
-        if (ret != Z_OK && ret != Z_STREAM_END) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-        
-        if (zstr.avail_out != sizeof(b2)) {
-            n2 = sizeof(b2) - zstr.avail_out;
-            
-            if (fwrite(b2, 1, n2, ft) != n2) {
-                _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-                return -1;
-            }
-        
-            zstr.next_out = (Bytef *)b2;
-            zstr.avail_out = sizeof(b2);
-            st->comp_size += n2;
-        }
-
-        if (ret == Z_STREAM_END) {
-            deflateEnd(&zstr);
-            end = 1;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static void
-ch_set_error(struct zip_error *error, zip_source_callback cb, void *ud)
-{
-    int e[2];
-
-    if ((cb(ud, e, sizeof(e), ZIP_SOURCE_ERROR)) < (ssize_t)sizeof(e)) {
-        error->zip_err = ZIP_ER_INTERNAL;
-        error->sys_err = 0;
-    }
-    else {
-        error->zip_err = e[0];
-        error->sys_err = e[1];
-    }
-}
-
-
-
-static int
-copy_data(FILE *fs, myoff_t len, FILE *ft, struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    int n, nn;
-
-    if (len == 0)
-        return 0;
-
-    while (len > 0) {
-        nn = len > sizeof(buf) ? sizeof(buf) : len;
-        if ((n=fread(buf, 1, nn, fs)) < 0) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        else if (n == 0) {
-            _zip_error_set(error, ZIP_ER_EOF, 0);
-            return -1;
-        }
-
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        len -= n;
-    }
-
-    return 0;
-}
-
-
-
-static int
-write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out)
-{
-    myoff_t offset;
-    uLong crc;
-    char buf[TORRENT_CRC_LEN+1];
-    
-    if (_zip_cdir_write(cd, out, &za->error) < 0)
-        return -1;
-    
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0)
-        return 0;
-
-
-    /* fix up torrentzip comment */
-
-    offset = ftello(out);
-
-    if (_zip_filerange_crc(out, cd->offset, cd->size, &crc, &za->error) < 0)
-        return -1;
-
-    snprintf(buf, sizeof(buf), "%08lX", (long)crc);
-
-    if (fseeko(out, offset-TORRENT_CRC_LEN, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    if (fwrite(buf, TORRENT_CRC_LEN, 1, out) != 1) {
-        _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src)
-{
-    if (src->ch_comment_len != -1) {
-        dest->comment = _zip_memdup(src->ch_comment,
-                                    src->ch_comment_len, &src->error);
-        if (dest->comment == NULL)
-            return -1;
-        dest->comment_len = src->ch_comment_len;
-    } else {
-        if (src->cdir && src->cdir->comment) {
-            dest->comment = _zip_memdup(src->cdir->comment,
-                                        src->cdir->comment_len, &src->error);
-            if (dest->comment == NULL)
-                return -1;
-            dest->comment_len = src->cdir->comment_len;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_changed(struct zip *za, int *survivorsp)
-{
-    int changed, i, survivors;
-
-    changed = survivors = 0;
-
-    if (za->ch_comment_len != -1
-        || za->ch_flags != za->flags)
-        changed = 1;
-
-    for (i=0; i<za->nentry; i++) {
-        if ((za->entry[i].state != ZIP_ST_UNCHANGED)
-            || (za->entry[i].ch_comment_len != -1))
-            changed = 1;
-        if (za->entry[i].state != ZIP_ST_DELETED)
-            survivors++;
-    }
-
-    *survivorsp = survivors;
-
-    return changed;
-}
-
-
-
-static char *
-_zip_create_temp_output(struct zip *za, FILE **outp)
-{
-    char *temp;
-    int tfd;
-    FILE *tfp;
-    
-    if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    sprintf(temp, "%s.XXXXXX", za->zn);
-
-    if ((tfd=mkstemp(temp)) == -1) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        free(temp);
-        return NULL;
-    }
-    
-    if ((tfp=fdopen(tfd, "r+b")) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        close(tfd);
-        remove(temp);
-        free(temp);
-        return NULL;
-    }
-
-    *outp = tfp;
-    return temp;
-}
-
-
-
-static int
-_zip_torrentzip_cmp(const void *a, const void *b)
-{
-    return strcasecmp(((const struct filelist *)a)->name,
-                      ((const struct filelist *)b)->name);
-}
-
-
-
-ZIP_EXTERN int
-zip_add_dir(struct zip *za, const char *name)
-{
-    int len, ret;
-    char *s;
-    struct zip_source *source;
-
-    if (name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    s = NULL;
-    len = strlen(name);
-
-    if (name[len-1] != '/') {
-        if ((s=(char *)malloc(len+2)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return -1;
-        }
-        strcpy(s, name);
-        s[len] = '/';
-        s[len+1] = '\0';
-    }
-
-    if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
-        free(s);
-        return -1;
-    }
-        
-    ret = _zip_replace(za, -1, s ? s : name, source);
-
-    free(s);
-    if (ret < 0)
-        zip_source_free(source);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_error_to_str(char *buf, size_t len, int ze, int se)
-{
-    const char *zs, *ss;
-
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return snprintf(buf, len, "Unknown error %d", ze);
-
-    zs = _zip_err_str[ze];
-        
-    switch (_zip_err_type[ze]) {
-    case ZIP_ET_SYS:
-        ss = strerror(se);
-        break;
-        
-    case ZIP_ET_ZLIB:
-        ss = zError(se);
-        break;
-        
-    default:
-        ss = NULL;
-    }
-
-    return snprintf(buf, len, "%s%s%s",
-                    zs, (ss ? ": " : ""), (ss ? ss : ""));
-}
-
-
-ZIP_EXTERN void
-zip_file_error_clear(struct zip_file *zf)
-{
-    _zip_error_clear(&zf->error);
-}
-
-
-ZIP_EXTERN int
-zip_fclose(struct zip_file *zf)
-{
-    int i, ret;
-    
-    if (zf->zstr)
-        inflateEnd(zf->zstr);
-    free(zf->buffer);
-    free(zf->zstr);
-
-    for (i=0; i<zf->za->nfile; i++) {
-        if (zf->za->file[i] == zf) {
-            zf->za->file[i] = zf->za->file[zf->za->nfile-1];
-            zf->za->nfile--;
-            break;
-        }
-    }
-
-    ret = 0;
-    if (zf->error.zip_err)
-        ret = zf->error.zip_err;
-    else if ((zf->flags & ZIP_ZF_CRC) && (zf->flags & ZIP_ZF_EOF)) {
-        /* if EOF, compare CRC */
-        if (zf->crc_orig != zf->crc)
-            ret = ZIP_ER_CRC;
-    }
-
-    free(zf);
-    return ret;
-}
-
-
-int
-_zip_filerange_crc(FILE *fp, myoff_t start, myoff_t len, uLong *crcp,
-                   struct zip_error *errp)
-{
-    Bytef buf[BUFSIZE];
-    size_t n;
-
-    *crcp = crc32(0L, Z_NULL, 0);
-
-    if (fseeko(fp, start, SEEK_SET) != 0) {
-        _zip_error_set(errp, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    
-    while (len > 0) {
-        n = len > BUFSIZE ? BUFSIZE : len;
-        if ((n=fread(buf, 1, n, fp)) <= 0) {
-            _zip_error_set(errp, ZIP_ER_READ, errno);
-            return -1;
-        }
-
-        *crcp = crc32(*crcp, buf, n);
-
-        len-= n;
-    }
-
-    return 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_file_strerror(struct zip_file *zf)
-{
-    return _zip_error_strerror(&zf->error);
-}
-
-
-/* _zip_file_get_offset(za, ze):
-   Returns the offset of the file data for entry ze.
-
-   On error, fills in za->error and returns 0.
-*/
-
-unsigned int
-_zip_file_get_offset(struct zip *za, int idx)
-{
-    struct zip_dirent de;
-    unsigned int offset;
-
-    offset = za->cdir->entry[idx].offset;
-
-    if (fseeko(za->zp, offset, SEEK_SET) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return 0;
-    }
-
-    if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0)
-        return 0;
-
-    offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
-
-    _zip_dirent_finalize(&de);
-
-    return offset;
-}
-
-
-ZIP_EXTERN void
-zip_file_error_get(struct zip_file *zf, int *zep, int *sep)
-{
-    _zip_error_get(&zf->error, zep, sep);
-}
-
-
-static struct zip_file *_zip_file_new(struct zip *za);
-
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen_index(struct zip *za, int fileno, int flags)
-{
-    int len, ret;
-    int zfflags;
-    struct zip_file *zf;
-
-    if ((fileno < 0) || (fileno >= za->nentry)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+fileno)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (fileno >= za->cdir->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    zfflags = 0;
-    switch (za->cdir->entry[fileno].comp_method) {
-    case ZIP_CM_STORE:
-        zfflags |= ZIP_ZF_CRC;
-        break;
-
-    case ZIP_CM_DEFLATE:
-        if ((flags & ZIP_FL_COMPRESSED) == 0)
-            zfflags |= ZIP_ZF_CRC | ZIP_ZF_DECOMP;
-        break;
-    default:
-        if ((flags & ZIP_FL_COMPRESSED) == 0) {
-            _zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
-            return NULL;
-        }
-        break;
-    }
-
-    zf = _zip_file_new(za);
-
-    zf->flags = zfflags;
-    /* zf->name = za->cdir->entry[fileno].filename; */
-    zf->method = za->cdir->entry[fileno].comp_method;
-    zf->bytes_left = za->cdir->entry[fileno].uncomp_size;
-    zf->cbytes_left = za->cdir->entry[fileno].comp_size;
-    zf->crc_orig = za->cdir->entry[fileno].crc;
-
-    if ((zf->fpos=_zip_file_get_offset(za, fileno)) == 0) {
-        zip_fclose(zf);
-        return NULL;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0)
-        zf->bytes_left = zf->cbytes_left;
-    else {
-        if ((zf->buffer=(char *)malloc(BUFSIZE)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-
-        len = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-        if (len <= 0) {
-            _zip_error_copy(&za->error, &zf->error);
-            zip_fclose(zf);
-        return NULL;
-        }
-
-        if ((zf->zstr = (z_stream *)malloc(sizeof(z_stream))) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-        zf->zstr->zalloc = Z_NULL;
-        zf->zstr->zfree = Z_NULL;
-        zf->zstr->opaque = NULL;
-        zf->zstr->next_in = (Bytef *)zf->buffer;
-        zf->zstr->avail_in = len;
-        
-        /* negative value to tell zlib that there is no header */
-        if ((ret=inflateInit2(zf->zstr, -MAX_WBITS)) != Z_OK) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            zip_fclose(zf);
-            return NULL;
-        }
-    }
-    
-    return zf;
-}
-
-
-
-int
-_zip_file_fillbuf(void *buf, size_t buflen, struct zip_file *zf)
-{
-    int i, j;
-
-    if (zf->error.zip_err != ZIP_ER_OK)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || zf->cbytes_left <= 0 || buflen <= 0)
-        return 0;
-    
-    if (fseeko(zf->za->zp, zf->fpos, SEEK_SET) < 0) {
-        _zip_error_set(&zf->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    if (buflen < zf->cbytes_left)
-        i = buflen;
-    else
-        i = zf->cbytes_left;
-
-    j = fread(buf, 1, i, zf->za->zp);
-    if (j == 0) {
-        _zip_error_set(&zf->error, ZIP_ER_EOF, 0);
-        j = -1;
-    }
-    else if (j < 0)
-        _zip_error_set(&zf->error, ZIP_ER_READ, errno);
-    else {
-        zf->fpos += j;
-        zf->cbytes_left -= j;
-    }
-
-    return j;        
-}
-
-
-
-static struct zip_file *
-_zip_file_new(struct zip *za)
-{
-    struct zip_file *zf, **file;
-    int n;
-
-    if ((zf=(struct zip_file *)malloc(sizeof(struct zip_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    if (za->nfile >= za->nfile_alloc-1) {
-        n = za->nfile_alloc + 10;
-        file = (struct zip_file **)realloc(za->file,
-                                           n*sizeof(struct zip_file *));
-        if (file == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(zf);
-            return NULL;
-        }
-        za->nfile_alloc = n;
-        za->file = file;
-    }
-
-    za->file[za->nfile++] = zf;
-
-    zf->za = za;
-    _zip_error_init(&zf->error);
-    zf->flags = 0;
-    zf->crc = crc32(0L, Z_NULL, 0);
-    zf->crc_orig = 0;
-    zf->method = -1;
-    zf->bytes_left = zf->cbytes_left = 0;
-    zf->fpos = 0;
-    zf->buffer = NULL;
-    zf->zstr = NULL;
-
-    return zf;
-}
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen(struct zip *za, const char *fname, int flags)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return NULL;
-
-    return zip_fopen_index(za, idx, flags);
-}
-
-
-ZIP_EXTERN int
-zip_set_file_comment(struct zip *za, int idx, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (idx < 0 || idx >= za->nentry
-        || len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = tmpcom;
-    za->entry[idx].ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_file(struct zip *za, const char *fname, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (fname == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, fname, NULL, start, len);
-}
-
-
-struct read_data {
-    const char *buf, *data, *end;
-    time_t mtime;
-    int freep;
-};
-
-static ssize_t read_data(void *state, void *data, size_t len,
-                         enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_buffer(struct zip *za, const void *data, myoff_t len, int freep)
-{
-    struct read_data *f;
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if (len < 0 || (data == NULL && len > 0)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_data *)malloc(sizeof(*f))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->data = (const char *)data;
-    f->end = ((const char *)data)+len;
-    f->freep = freep;
-    f->mtime = time(NULL);
-    
-    if ((zs=zip_source_function(za, read_data, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_data *z;
-    char *buf;
-    size_t n;
-
-    z = (struct read_data *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        z->buf = z->data;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        n = z->end - z->buf;
-        if (n > len)
-            n = len;
-
-        if (n) {
-            memcpy(buf, z->buf, n);
-            z->buf += n;
-        }
-
-        return n;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = z->mtime;
-            st->size = z->end - z->data;
-            
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            e[0] = e[1] = 0;
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        if (z->freep) {
-            free((void *)z->data);
-            z->data = NULL;
-        }
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-int
-_zip_set_name(struct zip *za, int idx, const char *name)
-{
-    char *s;
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry || name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((i=_zip_name_locate(za, name, 0, NULL)) != -1 && i != idx) {
-        _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-        return -1;
-    }
-
-    /* no effective name change */
-    if (i == idx)
-        return 0;
-    
-    if ((s=strdup(name)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return -1;
-    }
-    
-    if (za->entry[idx].state == ZIP_ST_UNCHANGED) 
-        za->entry[idx].state = ZIP_ST_RENAMED;
-
-    free(za->entry[idx].ch_filename);
-    za->entry[idx].ch_filename = s;
-
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_flag(struct zip *za, int flag, int value)
-{
-    if (value)
-        za->ch_flags |= flag;
-    else
-        za->ch_flags &= ~flag;
-
-    return 0;
-}
-
-
-void
-_zip_unchange_data(struct zip_entry *ze)
-{
-    if (ze->source) {
-        (void)ze->source->f(ze->source->ud, NULL, 0, ZIP_SOURCE_FREE);
-        free(ze->source);
-        ze->source = NULL;
-    }
-    
-    ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED;
-}
-
-
-ZIP_EXTERN int
-zip_unchange_archive(struct zip *za)
-{
-    free(za->ch_comment);
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-
-    za->ch_flags = za->flags;
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange(struct zip *za, int idx)
-{
-    return _zip_unchange(za, idx, 0);
-}
-
-
-
-int
-_zip_unchange(struct zip *za, int idx, int allow_duplicates)
-{
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (za->entry[idx].ch_filename) {
-        if (!allow_duplicates) {
-            i = _zip_name_locate(za,
-                         _zip_get_name(za, idx, ZIP_FL_UNCHANGED, NULL),
-                                 0, NULL);
-            if (i != -1 && i != idx) {
-                _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-                return -1;
-            }
-        }
-
-        free(za->entry[idx].ch_filename);
-        za->entry[idx].ch_filename = NULL;
-    }
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = NULL;
-    za->entry[idx].ch_comment_len = -1;
-
-    _zip_unchange_data(za->entry+idx);
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange_all(struct zip *za)
-{
-    int ret, i;
-
-    ret = 0;
-    for (i=0; i<za->nentry; i++)
-        ret |= _zip_unchange(za, i, 1);
-
-    ret |= zip_unchange_archive(za);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_comment(struct zip *za, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->ch_comment);
-    za->ch_comment = tmpcom;
-    za->ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_replace(struct zip *za, int idx, struct zip_source *source)
-{
-    if (idx < 0 || idx >= za->nentry || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (_zip_replace(za, idx, NULL, source) == -1)
-        return -1;
-
-    return 0;
-}
-
-
-
-
-int
-_zip_replace(struct zip *za, int idx, const char *name,
-             struct zip_source *source)
-{
-    if (idx == -1) {
-        if (_zip_entry_new(za) == NULL)
-            return -1;
-
-        idx = za->nentry - 1;
-    }
-    
-    _zip_unchange_data(za->entry+idx);
-
-    if (name && _zip_set_name(za, idx, name) != 0)
-        return -1;
-    
-    za->entry[idx].state = ((za->cdir == NULL || idx >= za->cdir->nentry)
-                            ? ZIP_ST_ADDED : ZIP_ST_REPLACED);
-    za->entry[idx].source = source;
-
-    return idx;
-}
-
-
-ZIP_EXTERN int
-zip_rename(struct zip *za, int idx, const char *name)
-{
-    const char *old_name;
-    int old_is_dir, new_is_dir;
-    
-    if (idx >= za->nentry || idx < 0 || name[0] == '\0') {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((old_name=zip_get_name(za, idx, 0)) == NULL)
-        return -1;
-                                                                    
-    new_is_dir = (name[strlen(name)-1] == '/');
-    old_is_dir = (old_name[strlen(old_name)-1] == '/');
-
-    if (new_is_dir != old_is_dir) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    return _zip_set_name(za, idx, name);
-}
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void set_error(int *, struct zip_error *, int);
-static struct zip *_zip_allocate_new(const char *, int *);
-static int _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *);
-static void _zip_check_torrentzip(struct zip *);
-static struct zip_cdir *_zip_find_central_dir(FILE *, int, int *, myoff_t);
-static int _zip_file_exists(const char *, int, int *);
-static int _zip_headercomp(struct zip_dirent *, int,
-                           struct zip_dirent *, int);
-static unsigned char *_zip_memmem(const unsigned char *, int,
-                                  const unsigned char *, int);
-static struct zip_cdir *_zip_readcdir(FILE *, unsigned char *, unsigned char *,
-                                 int, int, struct zip_error *);
-
-
-
-ZIP_EXTERN struct zip *
-zip_open(const char *fn, int flags, int *zep)
-{
-    FILE *fp;
-    struct zip *za;
-    struct zip_cdir *cdir;
-    int i;
-    myoff_t len;
-    
-    switch (_zip_file_exists(fn, flags, zep)) {
-    case -1:
-        return NULL;
-    case 0:
-        return _zip_allocate_new(fn, zep);
-    default:
-        break;
-    }
-
-    if ((fp=fopen(fn, "rb")) == NULL) {
-        set_error(zep, NULL, ZIP_ER_OPEN);
-        return NULL;
-    }
-
-    fseeko(fp, 0, SEEK_END);
-    len = ftello(fp);
-
-    /* treat empty files as empty archives */
-    if (len == 0) {
-        if ((za=_zip_allocate_new(fn, zep)) == NULL)
-            fclose(fp);
-        else
-            za->zp = fp;
-        return za;
-    }
-
-    cdir = _zip_find_central_dir(fp, flags, zep, len);
-    if (cdir == NULL) {
-        fclose(fp);
-        return NULL;
-    }
-
-    if ((za=_zip_allocate_new(fn, zep)) == NULL) {
-        _zip_cdir_free(cdir);
-        fclose(fp);
-        return NULL;
-    }
-
-    za->cdir = cdir;
-    za->zp = fp;
-
-    if ((za->entry=(struct zip_entry *)malloc(sizeof(*(za->entry))
-                                              * cdir->nentry)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        _zip_free(za);
-        return NULL;
-    }
-    for (i=0; i<cdir->nentry; i++)
-        _zip_entry_new(za);
-
-    _zip_check_torrentzip(za);
-    za->ch_flags = za->flags;
-
-    return za;
-}
-
-
-
-static void
-set_error(int *zep, struct zip_error *err, int ze)
-{
-    int se;
-
-    if (err) {
-        _zip_error_get(err, &ze, &se);
-        if (zip_error_get_sys_type(ze) == ZIP_ET_SYS)
-            errno = se;
-    }
-
-    if (zep)
-        *zep = ze;
-}
-
-
-
-/* _zip_readcdir:
-   tries to find a valid end-of-central-directory at the beginning of
-   buf, and then the corresponding central directory entries.
-   Returns a struct zip_cdir which contains the central directory 
-   entries, or NULL if unsuccessful. */
-
-static struct zip_cdir *
-_zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
-              int flags, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    unsigned char *cdp, **bufp;
-    int i, comlen, nentry;
-
-    comlen = buf + buflen - eocd - EOCDLEN;
-    if (comlen < 0) {
-        /* not enough bytes left for comment */
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    /* check for end-of-central-dir magic */
-    if (memcmp(eocd, EOCD_MAGIC, 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    if (memcmp(eocd+4, "\0\0\0\0", 4) != 0) {
-        _zip_error_set(error, ZIP_ER_MULTIDISK, 0);
-        return NULL;
-    }
-
-    cdp = eocd + 8;
-    /* number of cdir-entries on this disk */
-    i = _zip_read2(&cdp);
-    /* number of cdir-entries */
-    nentry = _zip_read2(&cdp);
-
-    if ((cd=_zip_cdir_new(nentry, error)) == NULL)
-        return NULL;
-
-    cd->size = _zip_read4(&cdp);
-    cd->offset = _zip_read4(&cdp);
-    cd->comment = NULL;
-    cd->comment_len = _zip_read2(&cdp);
-
-    if ((comlen < cd->comment_len) || (cd->nentry != i)) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        free(cd);
-        return NULL;
-    }
-    if ((flags & ZIP_CHECKCONS) && comlen != cd->comment_len) {
-        _zip_error_set(error, ZIP_ER_INCONS, 0);
-        free(cd);
-        return NULL;
-    }
-
-    if (cd->comment_len) {
-        if ((cd->comment=(char *)_zip_memdup(eocd+EOCDLEN,
-                                             cd->comment_len, error))
-            == NULL) {
-            free(cd);
-            return NULL;
-        }
-    }
-
-    cdp = eocd;
-    if (cd->size < (unsigned int)(eocd-buf)) {
-        /* if buffer already read in, use it */
-        cdp = eocd - cd->size;
-        bufp = &cdp;
-    }
-    else {
-        /* go to start of cdir and read it entry by entry */
-        bufp = NULL;
-        clearerr(fp);
-        fseeko(fp, cd->offset, SEEK_SET);
-        /* possible consistency check: cd->offset =
-           len-(cd->size+cd->comment_len+EOCDLEN) ? */
-        if (ferror(fp) || ((unsigned long)ftello(fp) != cd->offset)) {
-            /* seek error or offset of cdir wrong */
-            if (ferror(fp))
-                _zip_error_set(error, ZIP_ER_SEEK, errno);
-            else
-                _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            free(cd);
-            return NULL;
-        }
-    }
-
-    for (i=0; i<cd->nentry; i++) {
-        if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0,
-                              error)) < 0) {
-            cd->nentry = i;
-            _zip_cdir_free(cd);
-            return NULL;
-        }
-    }
-    
-    return cd;
-}
-
-
-
-/* _zip_checkcons:
-   Checks the consistency of the central directory by comparing central
-   directory entries with local headers and checking for plausible
-   file and header offsets. Returns -1 if not plausible, else the
-   difference between the lowest and the highest fileposition reached */
-
-static int
-_zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error)
-{
-    int i;
-    unsigned int min, max, j;
-    struct zip_dirent temp;
-
-    if (cd->nentry) {
-        max = cd->entry[0].offset;
-        min = cd->entry[0].offset;
-    }
-    else
-        min = max = 0;
-
-    for (i=0; i<cd->nentry; i++) {
-        if (cd->entry[i].offset < min)
-            min = cd->entry[i].offset;
-        if (min > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        j = cd->entry[i].offset + cd->entry[i].comp_size
-            + cd->entry[i].filename_len + LENTRYSIZE;
-        if (j > max)
-            max = j;
-        if (max > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        if (fseeko(fp, cd->entry[i].offset, SEEK_SET) != 0) {
-            _zip_error_set(error, ZIP_ER_SEEK, 0);
-            return -1;
-        }
-        
-        if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1)
-            return -1;
-        
-        if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) {
-            _zip_error_set(error, ZIP_ER_INCONS, 0);
-            _zip_dirent_finalize(&temp);
-            return -1;
-        }
-        _zip_dirent_finalize(&temp);
-    }
-
-    return max - min;
-}
-
-
-
-/* _zip_check_torrentzip:
-   check wether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
-
-static void
-_zip_check_torrentzip(struct zip *za)
-{
-    uLong crc_got, crc_should;
-    char buf[8+1];
-    char *end;
-
-    if (za->zp == NULL || za->cdir == NULL)
-        return;
-
-    if (za->cdir->comment_len != TORRENT_SIG_LEN+8
-        || strncmp(za->cdir->comment, TORRENT_SIG, TORRENT_SIG_LEN) != 0)
-        return;
-
-    memcpy(buf, za->cdir->comment+TORRENT_SIG_LEN, 8);
-    buf[8] = '\0';
-    errno = 0;
-    crc_should = strtoul(buf, &end, 16);
-    if ((crc_should == UINT_MAX && errno != 0) || (end && *end))
-        return;
-
-    if (_zip_filerange_crc(za->zp, za->cdir->offset, za->cdir->size,
-                           &crc_got, NULL) < 0)
-        return;
-
-    if (crc_got == crc_should)
-        za->flags |= ZIP_AFL_TORRENT;
-}
-
-
-
-
-/* _zip_headercomp:
-   compares two headers h1 and h2; if they are local headers, set
-   local1p or local2p respectively to 1, else 0. Return 0 if they
-   are identical, -1 if not. */
-
-static int
-_zip_headercomp(struct zip_dirent *h1, int local1p, struct zip_dirent *h2,
-           int local2p)
-{
-    if ((h1->version_needed != h2->version_needed)
-#if 0
-        /* some zip-files have different values in local
-           and global headers for the bitflags */
-        || (h1->bitflags != h2->bitflags)
-#endif
-        || (h1->comp_method != h2->comp_method)
-        || (h1->last_mod != h2->last_mod)
-        || (h1->filename_len != h2->filename_len)
-        || !h1->filename || !h2->filename
-        || strcmp(h1->filename, h2->filename))
-        return -1;
-
-    /* check that CRC and sizes are zero if data descriptor is used */
-    if ((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local1p
-        && (h1->crc != 0
-            || h1->comp_size != 0
-            || h1->uncomp_size != 0))
-        return -1;
-    if ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local2p
-        && (h2->crc != 0
-            || h2->comp_size != 0
-            || h2->uncomp_size != 0))
-        return -1;
-    
-    /* check that CRC and sizes are equal if no data descriptor is used */
-    if (((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local1p == 0)
-        && ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local2p == 0)) {
-        if ((h1->crc != h2->crc)
-            || (h1->comp_size != h2->comp_size)
-            || (h1->uncomp_size != h2->uncomp_size))
-            return -1;
-    }
-    
-    if ((local1p == local2p)
-        && ((h1->extrafield_len != h2->extrafield_len)
-            || (h1->extrafield_len && h2->extrafield
-                && memcmp(h1->extrafield, h2->extrafield,
-                          h1->extrafield_len))))
-        return -1;
-
-    /* if either is local, nothing more to check */
-    if (local1p || local2p)
-        return 0;
-
-    if ((h1->version_madeby != h2->version_madeby)
-        || (h1->disk_number != h2->disk_number)
-        || (h1->int_attrib != h2->int_attrib)
-        || (h1->ext_attrib != h2->ext_attrib)
-        || (h1->offset != h2->offset)
-        || (h1->comment_len != h2->comment_len)
-        || (h1->comment_len && h2->comment
-            && memcmp(h1->comment, h2->comment, h1->comment_len)))
-        return -1;
-
-    return 0;
-}
-
-
-
-static struct zip *
-_zip_allocate_new(const char *fn, int *zep)
-{
-    struct zip *za;
-    struct zip_error error;
-
-    if ((za=_zip_new(&error)) == NULL) {
-        set_error(zep, &error, 0);
-        return NULL;
-    }
-        
-    za->zn = strdup(fn);
-    if (!za->zn) {
-        _zip_free(za);
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-    return za;
-}
-
-
-
-static int
-_zip_file_exists(const char *fn, int flags, int *zep)
-{
-    struct stat st;
-
-    if (fn == NULL) {
-        set_error(zep, NULL, ZIP_ER_INVAL);
-        return -1;
-    }
-    
-    if (stat(fn, &st) != 0) {
-        if (flags & ZIP_CREATE)
-            return 0;
-        else {
-            set_error(zep, NULL, ZIP_ER_OPEN);
-            return -1;
-        }
-    }
-    else if ((flags & ZIP_EXCL)) {
-        set_error(zep, NULL, ZIP_ER_EXISTS);
-        return -1;
-    }
-    /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
-       just like open() */
-
-    return 1;
-}
-
-
-
-static struct zip_cdir *
-_zip_find_central_dir(FILE *fp, int flags, int *zep, myoff_t len)
-{
-    struct zip_cdir *cdir, *cdirnew;
-    unsigned char *buf, *match;
-    int a, best, buflen, i;
-    struct zip_error zerr;
-
-    i = fseeko(fp, -(len < CDBUFSIZE ? len : CDBUFSIZE), SEEK_END);
-    if (i == -1 && errno != EFBIG) {
-        /* seek before start of file on my machine */
-        set_error(zep, NULL, ZIP_ER_SEEK);
-        return NULL;
-    }
-
-    /* 64k is too much for stack */
-    if ((buf=(unsigned char *)malloc(CDBUFSIZE)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-
-    clearerr(fp);
-    buflen = fread(buf, 1, CDBUFSIZE, fp);
-
-    if (ferror(fp)) {
-        set_error(zep, NULL, ZIP_ER_READ);
-        free(buf);
-        return NULL;
-    }
-    
-    best = -1;
-    cdir = NULL;
-    match = buf;
-    _zip_error_set(&zerr, ZIP_ER_NOZIP, 0);
-
-    while ((match=_zip_memmem(match, buflen-(match-buf)-18,
-                              (const unsigned char *)EOCD_MAGIC, 4))!=NULL) {
-        /* found match -- check, if good */
-        /* to avoid finding the same match all over again */
-        match++;
-        if ((cdirnew=_zip_readcdir(fp, buf, match-1, buflen, flags,
-                                   &zerr)) == NULL)
-            continue;
-
-        if (cdir) {
-            if (best <= 0)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            a = _zip_checkcons(fp, cdirnew, &zerr);
-            if (best < a) {
-                _zip_cdir_free(cdir);
-                cdir = cdirnew;
-                best = a;
-            }
-            else
-                _zip_cdir_free(cdirnew);
-        }
-        else {
-            cdir = cdirnew;
-            if (flags & ZIP_CHECKCONS)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            else
-                best = 0;
-        }
-        cdirnew = NULL;
-    }
-
-    free(buf);
-    
-    if (best < 0) {
-        set_error(zep, &zerr, 0);
-        _zip_cdir_free(cdir);
-        return NULL;
-    }
-
-    return cdir;
-}
-
-
-
-static unsigned char *
-_zip_memmem(const unsigned char *big, int biglen, const unsigned char *little, 
-       int littlelen)
-{
-    const unsigned char *p;
-    
-    if ((biglen < littlelen) || (littlelen == 0))
-        return NULL;
-    p = big-1;
-    while ((p=(const unsigned char *)
-                memchr(p+1, little[0], (size_t)(big-(p+1)+biglen-littlelen+1)))
-           != NULL) {
-        if (memcmp(p+1, little+1, littlelen-1)==0)
-            return (unsigned char *)p;
-    }
-
-    return NULL;
-}
-
-
-/* _zip_new:
-   creates a new zipfile struct, and sets the contents to zero; returns
-   the new struct. */
-
-struct zip *
-_zip_new(struct zip_error *error)
-{
-    struct zip *za;
-
-    za = (struct zip *)malloc(sizeof(struct zip));
-    if (!za) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    za->zn = NULL;
-    za->zp = NULL;
-    _zip_error_init(&za->error);
-    za->cdir = NULL;
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-    za->nentry = za->nentry_alloc = 0;
-    za->entry = NULL;
-    za->nfile = za->nfile_alloc = 0;
-    za->file = NULL;
-    za->flags = za->ch_flags = 0;
-    
-    return za;
-}
-
-
-void *
-_zip_memdup(const void *mem, size_t len, struct zip_error *error)
-{
-    void *ret;
-
-    ret = malloc(len);
-    if (!ret) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    memcpy(ret, mem, len);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_get_num_files(struct zip *za)
-{
-    if (za == NULL)
-        return -1;
-
-    return za->nentry;
-}
-
-ZIP_EXTERN const char *
-zip_get_name(struct zip *za, int idx, int flags)
-{
-    return _zip_get_name(za, idx, flags, &za->error);
-}
-
-
-
-const char *
-_zip_get_name(struct zip *za, int idx, int flags, struct zip_error *error)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0) {
-        if (za->entry[idx].state == ZIP_ST_DELETED) {
-            _zip_error_set(error, ZIP_ER_DELETED, 0);
-            return NULL;
-        }
-        if (za->entry[idx].ch_filename)
-            return za->entry[idx].ch_filename;
-    }
-
-    if (za->cdir == NULL || idx >= za->cdir->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-    
-    return za->cdir->entry[idx].filename;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_file_comment(struct zip *za, int idx, int *lenp, int flags)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->entry[idx].ch_comment_len == -1)) {
-        if (lenp != NULL)
-            *lenp = za->cdir->entry[idx].comment_len;
-        return za->cdir->entry[idx].comment;
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->entry[idx].ch_comment_len;
-    return za->entry[idx].ch_comment;
-}
-
-
-ZIP_EXTERN int
-zip_get_archive_flag(struct zip *za, int flag, int flags)
-{
-    int fl;
-
-    fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags;
-
-    return (fl & flag) ? 1 : 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_archive_comment(struct zip *za, int *lenp, int flags)
-{
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->ch_comment_len == -1)) {
-        if (za->cdir) {
-            if (lenp != NULL)
-                *lenp = za->cdir->comment_len;
-            return za->cdir->comment;
-        }
-        else {
-            if (lenp != NULL)
-                *lenp = -1;
-            return NULL;
-        }
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->ch_comment_len;
-    return za->ch_comment;
-}
-
-
-/* _zip_free:
-   frees the space allocated to a zipfile struct, and closes the
-   corresponding file. */
-
-void
-_zip_free(struct zip *za)
-{
-    int i;
-
-    if (za == NULL)
-        return;
-
-    if (za->zn)
-        free(za->zn);
-
-    if (za->zp)
-        fclose(za->zp);
-
-    _zip_cdir_free(za->cdir);
-
-    if (za->entry) {
-        for (i=0; i<za->nentry; i++) {
-            _zip_entry_free(za->entry+i);
-        }
-        free(za->entry);
-    }
-
-    for (i=0; i<za->nfile; i++) {
-        if (za->file[i]->error.zip_err == ZIP_ER_OK) {
-            _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
-            za->file[i]->za = NULL;
-        }
-    }
-
-    free(za->file);
-    
-    free(za);
-
-    return;
-}
-
-
-ZIP_EXTERN ssize_t
-zip_fread(struct zip_file *zf, void *outbuf, size_t toread)
-{
-    int ret;
-    size_t out_before, len;
-    int i;
-
-    if (!zf)
-        return -1;
-
-    if (zf->error.zip_err != 0)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || (toread == 0))
-        return 0;
-
-    if (zf->bytes_left == 0) {
-        zf->flags |= ZIP_ZF_EOF;
-        if (zf->flags & ZIP_ZF_CRC) {
-            if (zf->crc != zf->crc_orig) {
-                _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
-                return -1;
-            }
-        }
-        return 0;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0) {
-        ret = _zip_file_fillbuf(outbuf, toread, zf);
-        if (ret > 0) {
-            if (zf->flags & ZIP_ZF_CRC)
-                zf->crc = crc32(zf->crc, (Bytef *)outbuf, ret);
-            zf->bytes_left -= ret;
-        }
-        return ret;
-    }
-    
-    zf->zstr->next_out = (Bytef *)outbuf;
-    zf->zstr->avail_out = toread;
-    out_before = zf->zstr->total_out;
-    
-    /* endless loop until something has been accomplished */
-    for (;;) {
-        ret = inflate(zf->zstr, Z_SYNC_FLUSH);
-
-        switch (ret) {
-        case Z_OK:
-        case Z_STREAM_END:
-            /* all ok */
-            /* Z_STREAM_END probably won't happen, since we didn't
-               have a header */
-            len = zf->zstr->total_out - out_before;
-            if (len >= zf->bytes_left || len >= toread) {
-                if (zf->flags & ZIP_ZF_CRC)
-                    zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
-                zf->bytes_left -= len;
-                return len;
-            }
-            break;
-
-        case Z_BUF_ERROR:
-            if (zf->zstr->avail_in == 0) {
-                i = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-                if (i == 0) {
-                    _zip_error_set(&zf->error, ZIP_ER_INCONS, 0);
-                    return -1;
-                }
-                else if (i < 0)
-                    return -1;
-                zf->zstr->next_in = (Bytef *)zf->buffer;
-                zf->zstr->avail_in = i;
-                continue;
-            }
-            /* fallthrough */
-        case Z_NEED_DICT:
-        case Z_DATA_ERROR:
-        case Z_STREAM_ERROR:
-        case Z_MEM_ERROR:
-            _zip_error_set(&zf->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-    }
-}
-
-
-ZIP_EXTERN const char *
-zip_strerror(struct zip *za)
-{
-    return _zip_error_strerror(&za->error);
-}
-
-
-ZIP_EXTERN void
-zip_stat_init(struct zip_stat *st)
-{
-    st->name = NULL;
-    st->index = -1;
-    st->crc = 0;
-    st->mtime = (time_t)-1;
-    st->size = -1;
-    st->comp_size = -1;
-    st->comp_method = ZIP_CM_STORE;
-    st->encryption_method = ZIP_EM_NONE;
-}
-
-
-ZIP_EXTERN int
-zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st)
-{
-    const char *name;
-    
-    if (index < 0 || index >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((name=zip_get_name(za, index, flags)) == NULL)
-        return -1;
-    
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+index)) {
-        if (za->entry[index].source->f(za->entry[index].source->ud,
-                                     st, sizeof(*st), ZIP_SOURCE_STAT) < 0) {
-            _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-            return -1;
-        }
-    }
-    else {
-        if (za->cdir == NULL || index >= za->cdir->nentry) {
-            _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-            return -1;
-        }
-        
-        st->crc = za->cdir->entry[index].crc;
-        st->size = za->cdir->entry[index].uncomp_size;
-        st->mtime = za->cdir->entry[index].last_mod;
-        st->comp_size = za->cdir->entry[index].comp_size;
-        st->comp_method = za->cdir->entry[index].comp_method;
-        if (za->cdir->entry[index].bitflags & ZIP_GPBF_ENCRYPTED) {
-            if (za->cdir->entry[index].bitflags & ZIP_GPBF_STRONG_ENCRYPTION) {
-                /* XXX */
-                st->encryption_method = ZIP_EM_UNKNOWN;
-            }
-            else
-                st->encryption_method = ZIP_EM_TRAD_PKWARE;
-        }
-        else
-            st->encryption_method = ZIP_EM_NONE;
-        /* st->bitflags = za->cdir->entry[index].bitflags; */
-    }
-
-    st->index = index;
-    st->name = name;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_stat(struct zip *za, const char *fname, int flags, struct zip_stat *st)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return -1;
-
-    return zip_stat_index(za, idx, flags, st);
-}
-
-
-struct read_zip {
-    struct zip_file *zf;
-    struct zip_stat st;
-    myoff_t off, len;
-};
-
-static ssize_t read_zip(void *st, void *data, size_t len,
-                        enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_zip(struct zip *za, struct zip *srcza, int srcidx, int flags,
-               myoff_t start, myoff_t len)
-{
-    struct zip_error error;
-    struct zip_source *zs;
-    struct read_zip *p;
-
-    /* XXX: ZIP_FL_RECOMPRESS */
-
-    if (za == NULL)
-        return NULL;
-
-    if (srcza == NULL || start < 0 || len < -1 || srcidx < 0 || srcidx >= srcza->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(srcza->entry+srcidx)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (len == 0)
-        len = -1;
-
-    if (start == 0 && len == -1 && (flags & ZIP_FL_RECOMPRESS) == 0)
-        flags |= ZIP_FL_COMPRESSED;
-    else
-        flags &= ~ZIP_FL_COMPRESSED;
-
-    if ((p=(struct read_zip *)malloc(sizeof(*p))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-        
-    _zip_error_copy(&error, &srcza->error);
-        
-    if (zip_stat_index(srcza, srcidx, flags, &p->st) < 0
-        || (p->zf=zip_fopen_index(srcza, srcidx, flags)) == NULL) {
-        free(p);
-        _zip_error_copy(&za->error, &srcza->error);
-        _zip_error_copy(&srcza->error, &error);
-        
-        return NULL;
-    }
-    p->off = start;
-    p->len = len;
-
-    if ((flags & ZIP_FL_COMPRESSED) == 0) {
-        p->st.size = p->st.comp_size = len;
-        p->st.comp_method = ZIP_CM_STORE;
-        p->st.crc = 0;
-    }
-    
-    if ((zs=zip_source_function(za, read_zip, p)) == NULL) {
-        free(p);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_zip(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_zip *z;
-    char b[8192], *buf;
-    int i, n;
-
-    z = (struct read_zip *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        for (n=0; n<z->off; n+= i) {
-            i = (z->off-n > sizeof(b) ? sizeof(b) : z->off-n);
-            if ((i=zip_fread(z->zf, b, i)) < 0) {
-                zip_fclose(z->zf);
-                z->zf = NULL;
-                return -1;
-            }
-        }
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->len != -1)
-            n = len > z->len ? z->len : len;
-        else
-            n = len;
-        
-
-        if ((i=zip_fread(z->zf, buf, n)) < 0)
-            return -1;
-
-        if (z->len != -1)
-            z->len -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        if (len < sizeof(z->st))
-            return -1;
-        len = sizeof(z->st);
-
-        memcpy(data, &z->st, len);
-        return len;
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            zip_file_error_get(z->zf, e, e+1);
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        zip_fclose(z->zf);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_function(struct zip *za, zip_source_callback zcb, void *ud)
-{
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if ((zs=(struct zip_source *)malloc(sizeof(*zs))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    zs->f = zcb;
-    zs->ud = ud;
-    
-    return zs;
-}
-
-
-ZIP_EXTERN void
-zip_source_free(struct zip_source *source)
-{
-    if (source == NULL)
-        return;
-
-    (void)source->f(source->ud, NULL, 0, ZIP_SOURCE_FREE);
-
-    free(source);
-}
-
-
-struct read_file {
-    char *fname;        /* name of file to copy from */
-    FILE *f;                /* file to copy from */
-    myoff_t off;                /* start offset of */
-    myoff_t len;                /* lengt of data to copy */
-    myoff_t remain;        /* bytes remaining to be copied */
-    int e[2];                /* error codes */
-};
-
-static ssize_t read_file(void *state, void *data, size_t len,
-                     enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_filep(struct zip *za, FILE *file, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (file == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, NULL, file, start, len);
-}
-
-
-
-struct zip_source *
-_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file,
-                      myoff_t start, myoff_t len)
-{
-    struct read_file *f;
-    struct zip_source *zs;
-
-    if (file == NULL && fname == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->fname = NULL;
-    if (fname) {
-        if ((f->fname=strdup(fname)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(f);
-            return NULL;
-        }
-    }
-    f->f = file;
-    f->off = start;
-    f->len = (len ? len : -1);
-    
-    if ((zs=zip_source_function(za, read_file, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_file(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_file *z;
-    char *buf;
-    int i, n;
-
-    z = (struct read_file *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        if (z->fname) {
-            if ((z->f=fopen(z->fname, "rb")) == NULL) {
-                z->e[0] = ZIP_ER_OPEN;
-                z->e[1] = errno;
-                return -1;
-            }
-        }
-
-        if (fseeko(z->f, z->off, SEEK_SET) < 0) {
-            z->e[0] = ZIP_ER_SEEK;
-            z->e[1] = errno;
-            return -1;
-        }
-        z->remain = z->len;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->remain != -1)
-            n = len > z->remain ? z->remain : len;
-        else
-            n = len;
-        
-        if ((i=fread(buf, 1, n, z->f)) < 0) {
-            z->e[0] = ZIP_ER_READ;
-            z->e[1] = errno;
-            return -1;
-        }
-
-        if (z->remain != -1)
-            z->remain -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        if (z->fname) {
-            fclose(z->f);
-            z->f = NULL;
-        }
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            struct stat fst;
-            int err;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            if (z->f)
-                err = fstat(fileno(z->f), &fst);
-            else
-                err = stat(z->fname, &fst);
-
-            if (err != 0) {
-                z->e[0] = ZIP_ER_READ; /* best match */
-                z->e[1] = errno;
-                return -1;
-            }
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = fst.st_mtime;
-            if (z->len != -1)
-                st->size = z->len;
-            else if ((fst.st_mode&S_IFMT) == S_IFREG)
-                st->size = fst.st_size;
-
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        if (len < sizeof(int)*2)
-            return -1;
-
-        memcpy(data, z->e, sizeof(int)*2);
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        free(z->fname);
-        if (z->f)
-            fclose(z->f);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN int
-zip_name_locate(struct zip *za, const char *fname, int flags)
-{
-    return _zip_name_locate(za, fname, flags, &za->error);
-}
-
-
-
-int
-_zip_name_locate(struct zip *za, const char *fname, int flags,
-                 struct zip_error *error)
-{
-    int (*cmp)(const char *, const char *);
-    const char *fn, *p;
-    int i, n;
-
-    if (fname == NULL) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-    
-    cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
-
-    n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
-    for (i=0; i<n; i++) {
-        if (flags & ZIP_FL_UNCHANGED)
-            fn = za->cdir->entry[i].filename;
-        else
-            fn = _zip_get_name(za, i, flags, error);
-
-        /* newly added (partially filled) entry */
-        if (fn == NULL)
-            continue;
-        
-        if (flags & ZIP_FL_NODIR) {
-            p = strrchr(fn, '/');
-            if (p)
-                fn = p+1;
-        }
-
-        if (cmp(fname, fn) == 0)
-            return i;
-    }
-
-    _zip_error_set(error, ZIP_ER_NOENT, 0);
-    return -1;
-}
-
diff --git a/lib/oldwrappers/zip/zlib.nim b/lib/oldwrappers/zip/zlib.nim
deleted file mode 100755
index 9b49b9663..000000000
--- a/lib/oldwrappers/zip/zlib.nim
+++ /dev/null
@@ -1,181 +0,0 @@
-# Converted from Pascal
-
-## Interface to the zlib http://www.zlib.net/ compression library.
-
-when defined(windows):
-  const libz = "zlib1.dll"
-elif defined(macosx):
-  const libz = "libz.dylib"
-else:
-  const libz = "libz.so"
-
-type
-  Uint* = int32
-  Ulong* = int
-  Ulongf* = int
-  Pulongf* = ptr Ulongf
-  z_off_t* = int32
-  pbyte* = cstring
-  pbytef* = cstring
-  TAllocfunc* = proc (p: pointer, items: uInt, size: uInt): pointer{.cdecl.}
-  TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
-  TInternalState*{.final, pure.} = object 
-  PInternalState* = ptr TInternalstate
-  TZStream*{.final, pure.} = object 
-    next_in*: pbytef
-    avail_in*: uInt
-    total_in*: uLong
-    next_out*: pbytef
-    avail_out*: uInt
-    total_out*: uLong
-    msg*: pbytef
-    state*: PInternalState
-    zalloc*: TAllocFunc
-    zfree*: TFreeFunc
-    opaque*: pointer
-    data_type*: int32
-    adler*: uLong
-    reserved*: uLong
-
-  TZStreamRec* = TZStream
-  PZstream* = ptr TZStream
-  gzFile* = pointer
-
-const 
-  Z_NO_FLUSH* = 0
-  Z_PARTIAL_FLUSH* = 1
-  Z_SYNC_FLUSH* = 2
-  Z_FULL_FLUSH* = 3
-  Z_FINISH* = 4
-  Z_OK* = 0
-  Z_STREAM_END* = 1
-  Z_NEED_DICT* = 2
-  Z_ERRNO* = -1
-  Z_STREAM_ERROR* = -2
-  Z_DATA_ERROR* = -3
-  Z_MEM_ERROR* = -4
-  Z_BUF_ERROR* = -5
-  Z_VERSION_ERROR* = -6
-  Z_NO_COMPRESSION* = 0
-  Z_BEST_SPEED* = 1
-  Z_BEST_COMPRESSION* = 9
-  Z_DEFAULT_COMPRESSION* = -1
-  Z_FILTERED* = 1
-  Z_HUFFMAN_ONLY* = 2
-  Z_DEFAULT_STRATEGY* = 0
-  Z_BINARY* = 0
-  Z_ASCII* = 1
-  Z_UNKNOWN* = 2
-  Z_DEFLATED* = 8
-  Z_NULL* = 0
-
-proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".}
-proc deflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflate".}
-proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateEnd".}
-proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflate".}
-proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateEnd".}
-proc deflateSetDictionary*(strm: var TZStream, dictionary: pbytef, 
-                           dictLength: uInt): int32{.cdecl, dynlib: libz, 
-    importc: "deflateSetDictionary".}
-proc deflateCopy*(dest, source: var TZstream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateCopy".}
-proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateReset".}
-proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{.
-    cdecl, dynlib: libz, importc: "deflateParams".}
-proc inflateSetDictionary*(strm: var TZStream, dictionary: pbytef, 
-                           dictLength: uInt): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSetDictionary".}
-proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSync".}
-proc inflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateReset".}
-proc compress*(dest: pbytef, destLen: puLongf, source: pbytef, sourceLen: uLong): cint{.
-    cdecl, dynlib: libz, importc: "compress".}
-proc compress2*(dest: pbytef, destLen: puLongf, source: pbytef, 
-                sourceLen: uLong, level: cint): cint{.cdecl, dynlib: libz, 
-    importc: "compress2".}
-proc uncompress*(dest: pbytef, destLen: puLongf, source: pbytef, 
-                 sourceLen: uLong): cint{.cdecl, dynlib: libz, 
-    importc: "uncompress".}
-proc gzopen*(path: cstring, mode: cstring): gzFile{.cdecl, dynlib: libz, 
-    importc: "gzopen".}
-proc gzdopen*(fd: int32, mode: cstring): gzFile{.cdecl, dynlib: libz, 
-    importc: "gzdopen".}
-proc gzsetparams*(thefile: gzFile, level: int32, strategy: int32): int32{.cdecl, 
-    dynlib: libz, importc: "gzsetparams".}
-proc gzread*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzread".}
-proc gzwrite*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzwrite".}
-proc gzprintf*(thefile: gzFile, format: pbytef): int32{.varargs, cdecl, 
-    dynlib: libz, importc: "gzprintf".}
-proc gzputs*(thefile: gzFile, s: pbytef): int32{.cdecl, dynlib: libz, 
-    importc: "gzputs".}
-proc gzgets*(thefile: gzFile, buf: pbytef, length: int32): pbytef{.cdecl, 
-    dynlib: libz, importc: "gzgets".}
-proc gzputc*(thefile: gzFile, c: char): char{.cdecl, dynlib: libz, 
-    importc: "gzputc".}
-proc gzgetc*(thefile: gzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".}
-proc gzflush*(thefile: gzFile, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "gzflush".}
-proc gzseek*(thefile: gzFile, offset: z_off_t, whence: int32): z_off_t{.cdecl, 
-    dynlib: libz, importc: "gzseek".}
-proc gzrewind*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
-proc gztell*(thefile: gzFile): z_off_t{.cdecl, dynlib: libz, importc: "gztell".}
-proc gzeof*(thefile: gzFile): int {.cdecl, dynlib: libz, importc: "gzeof".}
-proc gzclose*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".}
-proc gzerror*(thefile: gzFile, errnum: var int32): pbytef{.cdecl, dynlib: libz, 
-    importc: "gzerror".}
-proc adler32*(adler: uLong, buf: pbytef, length: uInt): uLong{.cdecl, 
-    dynlib: libz, importc: "adler32".}
-proc crc32*(crc: uLong, buf: pbytef, length: uInt): uLong{.cdecl, dynlib: libz, 
-    importc: "crc32".}
-proc deflateInitu*(strm: var TZStream, level: int32, version: cstring, 
-                   stream_size: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflateInit_".}
-proc inflateInitu*(strm: var TZStream, version: cstring,
-                   stream_size: int32): int32 {.
-    cdecl, dynlib: libz, importc: "inflateInit_".}
-proc deflateInit*(strm: var TZStream, level: int32): int32
-proc inflateInit*(strm: var TZStream): int32
-proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32, 
-                    windowBits: int32, memLevel: int32, strategy: int32, 
-                    version: cstring, stream_size: int32): int32 {.cdecl, 
-                    dynlib: libz, importc: "deflateInit2_".}
-proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring, 
-                    stream_size: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflateInit2_".}
-proc deflateInit2*(strm: var TZStream, 
-                   level, `method`, windowBits, memLevel,
-                   strategy: int32): int32
-proc inflateInit2*(strm: var TZStream, windowBits: int32): int32
-proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
-proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSyncPoint".}
-proc get_crc_table*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
-
-proc deflateInit(strm: var TZStream, level: int32): int32 = 
-  result = deflateInitu(strm, level, ZLIB_VERSION(), sizeof(TZStream))
-
-proc inflateInit(strm: var TZStream): int32 = 
-  result = inflateInitu(strm, ZLIB_VERSION(), sizeof(TZStream))
-
-proc deflateInit2(strm: var TZStream, 
-                  level, `method`, windowBits, memLevel,
-                  strategy: int32): int32 = 
-  result = deflateInit2u(strm, level, `method`, windowBits, memLevel, 
-                         strategy, ZLIB_VERSION(), sizeof(TZStream))
-
-proc inflateInit2(strm: var TZStream, windowBits: int32): int32 = 
-  result = inflateInit2u(strm, windowBits, ZLIB_VERSION(), sizeof(TZStream))
-
-proc zlibAllocMem*(AppData: Pointer, Items, Size: int): Pointer {.cdecl.} = 
-  result = Alloc(Items * Size)
-
-proc zlibFreeMem*(AppData, `Block`: Pointer) {.cdecl.} = 
-  dealloc(`Block`)
diff --git a/lib/oldwrappers/zip/zzip.nim b/lib/oldwrappers/zip/zzip.nim
deleted file mode 100755
index a656322ee..000000000
--- a/lib/oldwrappers/zip/zzip.nim
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module is an interface to the zzip library. 
-
-#   Author: 
-#   Guido Draheim <guidod@gmx.de>
-#   Tomi Ollila <Tomi.Ollila@iki.fi>
-#   Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
-#          All rights reserved, 
-#             usage allowed under the restrictions of the
-#         Lesser GNU General Public License 
-#             or alternatively the restrictions 
-#             of the Mozilla Public License 1.1
-
-when defined(windows):
-  const
-    dllname = "zzip.dll"
-else:
-  const 
-    dllname = "libzzip.so"
-
-type 
-  TZZipError* = int32
-const
-  ZZIP_ERROR* = -4096'i32
-  ZZIP_NO_ERROR* = 0'i32            # no error, may be used if user sets it.
-  ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32  # out of memory  
-  ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32  # failed to open zipfile, see errno for details 
-  ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32  # failed to fstat zipfile, see errno for details
-  ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32  # failed to lseek zipfile, see errno for details
-  ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32  # failed to read zipfile, see errno for details  
-  ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32
-  ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32
-  ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32
-  ZZIP_ENOENT* = ZZIP_ERROR - 28'i32
-  ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32
-  ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32
-  ZZIP_UNDEF* = ZZIP_ERROR - 32'i32
-  ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32
-
-  ZZIP_CASELESS* = 1'i32 shl 12'i32
-  ZZIP_NOPATHS* = 1'i32 shl 13'i32
-  ZZIP_PREFERZIP* = 1'i32 shl 14'i32
-  ZZIP_ONLYZIP* = 1'i32 shl 16'i32
-  ZZIP_FACTORY* = 1'i32 shl 17'i32
-  ZZIP_ALLOWREAL* = 1'i32 shl 18'i32
-  ZZIP_THREADED* = 1'i32 shl 19'i32
-  
-type
-  TZZipDir* {.final, pure.} = object
-  TZZipFile* {.final, pure.} = object
-  TZZipPluginIO* {.final, pure.} = object
-
-  TZZipDirent* {.final, pure.} = object  
-    d_compr*: int32  ## compression method
-    d_csize*: int32  ## compressed size  
-    st_size*: int32  ## file size / decompressed size
-    d_name*: cstring ## file name / strdupped name
-
-  TZZipStat* = TZZipDirent    
-
-proc zzip_strerror*(errcode: int32): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror".}
-proc zzip_strerror_of*(dir: ptr TZZipDir): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror_of".}
-proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_errno".}
-
-proc zzip_geterror*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_error".}
-proc zzip_seterror*(dir: ptr TZZipDir, errcode: int32) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seterror".}
-proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname, 
-    importc: "zzip_compr_str".}
-proc zzip_dirhandle*(fp: ptr TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirhandle".}
-proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirfd".}
-proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_real".}
-proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_real".}
-proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname, 
-    importc: "zzip_realdir".}
-proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_realfd".}
-
-proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_alloc".}
-proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_free".}
-
-proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_fdopen".}
-proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open".}
-proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_close".}
-proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_read".}
-
-proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_opendir".}
-proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_closedir".}
-proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname, 
-    importc: "zzip_readdir".}
-proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-                                      importc: "zzip_rewinddir".}
-proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_telldir".}
-proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seekdir".}
-
-proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_file_open".}
-proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_close".}
-proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_file_read".}
-proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open".}
-proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_close".}
-proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_read".}
-
-proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_freopen".}
-proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_fopen".}
-proc zzip_fread*(p: pointer, size: int, nmemb: int, 
-                 file: ptr TZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_fread".}
-proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_fclose".}
-
-proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_rewind".}
-proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {.
-    cdecl, dynlib: dllname, importc: "zzip_seek".}
-proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_tell".}
-
-proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat, 
-                    flags: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_stat".}
-proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_file_stat".}
-proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_fstat".}
-
-proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring, 
-                          o_flags: int32, o_modes: int32, ext: cstringArray, 
-                          io: ptr TZZipPluginIO): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open_shared_io".}
-proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32, 
-                       ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
-proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, 
-                          ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
-proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, 
-                           ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}
diff --git a/lib/packages/docutils/dochelpers.nim b/lib/packages/docutils/dochelpers.nim
new file mode 100644
index 000000000..0a41d85b5
--- /dev/null
+++ b/lib/packages/docutils/dochelpers.nim
@@ -0,0 +1,298 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2021 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Integration helpers between ``docgen.nim`` and ``rst.nim``.
+##
+## Function `toLangSymbol(linkText)`_ produces a signature `docLink` of
+## `type LangSymbol`_ in ``rst.nim``, while `match(generated, docLink)`_
+## matches it with `generated`, produced from `PNode` by ``docgen.rst``.
+
+import rstast
+import std/strutils
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+
+type
+  LangSymbol* = object       ## symbol signature in Nim
+    symKind*: string           ## "proc", "const", "type", etc
+    symTypeKind*: string       ## ""|enum|object|tuple -
+                               ## valid only when `symKind == "type"`
+    name*: string              ## plain symbol name without any parameters
+    generics*: string          ## generic parameters (without brackets)
+    isGroup*: bool             ## is LangSymbol a group with overloads?
+    # the following fields are valid iff `isGroup` == false
+    # (always false when parsed by `toLangSymbol` because link like foo_
+    # can point to just a single symbol foo, e.g. proc).
+    parametersProvided*: bool  ## to disambiguate `proc f`_ and `proc f()`_
+    parameters*: seq[tuple[name: string, `type`: string]]
+                               ## name-type seq, e.g. for proc
+    outType*: string           ## result type, e.g. for proc
+
+proc `$`*(s: LangSymbol): string =  # for debug
+  ("(symkind=$1, symTypeKind=$2, name=$3, generics=$4, isGroup=$5, " &
+   "parametersProvided=$6, parameters=$7, outType=$8)") % [
+      s.symKind, s.symTypeKind , s.name, s.generics, $s.isGroup,
+      $s.parametersProvided, $s.parameters, s.outType]
+
+func nimIdentBackticksNormalize*(s: string): string =
+  ## Normalizes the string `s` as a Nim identifier.
+  ##
+  ## Unlike `nimIdentNormalize` removes spaces and backticks.
+  ##
+  ## .. Warning:: No checking (e.g. that identifiers cannot start from
+  ##    digits or '_', or that number of backticks is even) is performed.
+  runnableExamples:
+    doAssert nimIdentBackticksNormalize("Foo_bar") == "Foobar"
+    doAssert nimIdentBackticksNormalize("FoO BAr") == "Foobar"
+    doAssert nimIdentBackticksNormalize("`Foo BAR`") == "Foobar"
+    doAssert nimIdentBackticksNormalize("` Foo BAR `") == "Foobar"
+    # not a valid identifier:
+    doAssert nimIdentBackticksNormalize("`_x_y`") == "_xy"
+  result = newString(s.len)
+  var firstChar = true
+  var j = 0
+  for i in 0..len(s) - 1:
+    if s[i] in {'A'..'Z'}:
+      if not firstChar:  # to lowercase
+        result[j] = chr(ord(s[i]) + (ord('a') - ord('A')))
+      else:
+        result[j] = s[i]
+        firstChar = false
+      inc j
+    elif s[i] notin {'_', ' ', '`'}:
+      result[j] = s[i]
+      inc j
+      firstChar = false
+    elif s[i] == '_' and firstChar:
+      result[j] = '_'
+      inc j
+      firstChar = false
+    else: discard  # just omit '`' or ' '
+  if j != s.len: setLen(result, j)
+
+proc langSymbolGroup*(kind: string, name: string): LangSymbol =
+  if kind notin ["proc", "func", "macro", "method", "iterator",
+                 "template", "converter"]:
+    raise newException(ValueError, "unknown symbol kind $1" % [kind])
+  result = LangSymbol(symKind: kind, name: name, isGroup: true)
+
+proc toLangSymbol*(linkText: PRstNode): LangSymbol =
+  ## Parses `linkText` into a more structured form using a state machine.
+  ##
+  ## This proc is designed to allow link syntax with operators even
+  ## without escaped backticks inside:
+  ##   
+  ##     `proc *`_
+  ##     `proc []`_
+  ##
+  ## This proc should be kept in sync with the `renderTypes` proc from
+  ## ``compiler/typesrenderer.nim``.
+  template fail(msg: string) =
+    raise newException(ValueError, msg)
+  if linkText.kind notin {rnRstRef, rnInner}:
+    fail("toLangSymbol: wrong input kind " & $linkText.kind)
+
+  const NimDefs = ["proc", "func", "macro", "method", "iterator",
+                   "template", "converter", "const", "type", "var",
+                   "enum", "object", "tuple", "module"]
+  template resolveSymKind(x: string) =
+    if x in ["enum", "object", "tuple"]:
+      result.symKind = "type"
+      result.symTypeKind = x
+    else:
+      result.symKind = x
+  type
+    State = enum
+      inBeginning
+      afterSymKind
+      beforeSymbolName  # auxiliary state to catch situations like `proc []`_ after space
+      atSymbolName
+      afterSymbolName
+      genericsPar
+      parameterName
+      parameterType
+      outType
+  var state = inBeginning
+  var curIdent = ""
+  template flushIdent() =
+    if curIdent != "":
+      case state
+      of inBeginning:  fail("incorrect state inBeginning")
+      of afterSymKind:  resolveSymKind curIdent
+      of beforeSymbolName:  fail("incorrect state beforeSymbolName")
+      of atSymbolName: result.name = curIdent.nimIdentBackticksNormalize
+      of afterSymbolName: fail("incorrect state afterSymbolName")
+      of genericsPar: result.generics = curIdent
+      of parameterName: result.parameters.add (curIdent, "")
+      of parameterType:
+        for a in countdown(result.parameters.len - 1, 0):
+          if result.parameters[a].`type` == "":
+            result.parameters[a].`type` = curIdent
+      of outType: result.outType = curIdent
+      curIdent = ""
+  var parens = 0
+  let L = linkText.sons.len
+  template s(i: int): string = linkText.sons[i].text
+  var i = 0
+  template nextState =
+    case s(i)
+    of " ":
+      if state == afterSymKind:
+        flushIdent
+        state = beforeSymbolName
+    of "`":
+      curIdent.add "`"
+      inc i
+      while i < L:  # add contents between ` ` as a whole
+        curIdent.add s(i)
+        if s(i) == "`":
+          break
+        inc i
+      curIdent = curIdent.nimIdentBackticksNormalize
+      if state in {inBeginning, afterSymKind, beforeSymbolName}:
+        state = atSymbolName
+        flushIdent
+        state = afterSymbolName
+    of "[":
+      if state notin {inBeginning, afterSymKind, beforeSymbolName}:
+        inc parens
+      if state in {inBeginning, afterSymKind, beforeSymbolName}:
+        state = atSymbolName
+        curIdent.add s(i)
+      elif state in {atSymbolName, afterSymbolName} and parens == 1:
+        flushIdent
+        state = genericsPar
+        curIdent.add s(i)
+      else: curIdent.add s(i)
+    of "]":
+      if state notin {inBeginning, afterSymKind, beforeSymbolName, atSymbolName}:
+        dec parens
+      if state == genericsPar and parens == 0:
+        curIdent.add s(i)
+        flushIdent
+      else: curIdent.add s(i)
+    of "(":
+      inc parens
+      if state in {inBeginning, afterSymKind, beforeSymbolName}:
+        result.parametersProvided = true
+        state = atSymbolName
+        flushIdent
+        state = parameterName
+      elif state in {atSymbolName, afterSymbolName, genericsPar} and parens == 1:
+        result.parametersProvided = true
+        flushIdent
+        state = parameterName
+      else: curIdent.add s(i)
+    of ")":
+      dec parens
+      if state in {parameterName, parameterType} and parens == 0:
+        flushIdent
+        state = outType
+      else: curIdent.add s(i)
+    of "{":  # remove pragmas
+      while i < L:
+        if s(i) == "}":
+          break
+        inc i
+    of ",", ";":
+      if state in {parameterName, parameterType} and parens == 1:
+        flushIdent
+        state = parameterName
+      else: curIdent.add s(i)
+    of "*":  # skip export symbol
+      if state == atSymbolName:
+        flushIdent
+        state = afterSymbolName
+      elif state == afterSymbolName:
+        discard
+      else: curIdent.add "*"
+    of ":":
+      if state == outType: discard
+      elif state == parameterName:
+        flushIdent
+        state = parameterType
+      else: curIdent.add ":"
+    else:
+      let isPostfixSymKind = i > 0 and i == L - 1 and
+          result.symKind == "" and s(i) in NimDefs
+      if isPostfixSymKind:  # for links like `foo proc`_
+        resolveSymKind s(i)
+      else:
+        case state
+        of inBeginning:
+          if s(i) in NimDefs:
+            state = afterSymKind
+          else:
+            state = atSymbolName
+          curIdent.add s(i)
+        of afterSymKind, beforeSymbolName:
+          state = atSymbolName
+          curIdent.add s(i)
+        of parameterType:
+          case s(i)
+          of "ref": curIdent.add "ref."
+          of "ptr": curIdent.add "ptr."
+          of "var": discard
+          else: curIdent.add s(i).nimIdentBackticksNormalize
+        of atSymbolName:
+          curIdent.add s(i)
+        else:
+          curIdent.add s(i).nimIdentBackticksNormalize
+  while i < L:
+    nextState
+    inc i
+  if state == afterSymKind:  # treat `type`_ as link to symbol `type`
+    state = atSymbolName
+  flushIdent
+  result.isGroup = false
+
+proc match*(generated: LangSymbol, docLink: LangSymbol): bool =
+  ## Returns true if `generated` can be a target for `docLink`.
+  ## If `generated` is an overload group then only `symKind` and `name`
+  ## are compared for success.
+  result = true
+  if docLink.symKind != "":
+    if generated.symKind == "proc":
+      result = docLink.symKind in ["proc", "func"]
+    else:
+      result = generated.symKind == docLink.symKind
+      if result and docLink.symKind == "type" and docLink.symTypeKind != "":
+        result = generated.symTypeKind == docLink.symTypeKind
+    if not result: return
+  result = generated.name == docLink.name
+  if not result: return
+  if generated.isGroup:
+    # if `()` were added then it's not a reference to the whole group:
+    return not docLink.parametersProvided
+  if docLink.generics != "":
+    result = generated.generics == docLink.generics
+    if not result: return
+  if docLink.outType != "":
+    result = generated.outType == docLink.outType
+    if not result: return
+  if docLink.parametersProvided:
+    result = generated.parameters.len == docLink.parameters.len
+    if not result: return
+    var onlyType = false
+    for i in 0 ..< generated.parameters.len:
+      let g = generated.parameters[i]
+      let d = docLink.parameters[i]
+      if i == 0:
+        if g.`type` == d.name:
+          onlyType = true  # only types, not names, are provided in `docLink`
+      if onlyType:
+        result = g.`type` == d.name
+      else:
+        if d.`type` != "":
+          result = g.`type` == d.`type`
+          if not result: return
+        result = g.name == d.name
+      if not result: return
diff --git a/lib/packages/docutils/docutils.nimble.old b/lib/packages/docutils/docutils.nimble.old
new file mode 100644
index 000000000..f97c3bdde
--- /dev/null
+++ b/lib/packages/docutils/docutils.nimble.old
@@ -0,0 +1,7 @@
+# xxx disabled this as this isn't really a nimble package and it affects logic
+# used to compute canonical imports, refs https://github.com/nim-lang/Nim/pull/16999#issuecomment-805442914
+
+version       = "0.10.0"
+author        = "Andreas Rumpf"
+description   = "Nim's reStructuredText processor."
+license       = "MIT"
diff --git a/lib/packages/docutils/highlite.nim b/lib/packages/docutils/highlite.nim
new file mode 100644
index 000000000..f8376f46c
--- /dev/null
+++ b/lib/packages/docutils/highlite.nim
@@ -0,0 +1,1039 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Source highlighter for programming or markup languages.
+## Currently only few languages are supported, other languages may be added.
+## The interface supports one language nested in another.
+##
+## You can use this to build your own syntax highlighting, check this example:
+##
+##   ```Nim
+##   let code = """for x in $int.high: echo x.ord mod 2 == 0"""
+##   var toknizr: GeneralTokenizer
+##   initGeneralTokenizer(toknizr, code)
+##   while true:
+##     getNextToken(toknizr, langNim)
+##     case toknizr.kind
+##     of gtEof: break  # End Of File (or string)
+##     of gtWhitespace:
+##       echo gtWhitespace # Maybe you want "visible" whitespaces?.
+##       echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
+##     of gtOperator:
+##       echo gtOperator # Maybe you want Operators to use a specific color?.
+##       echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
+##     # of gtSomeSymbol: syntaxHighlight("Comic Sans", "bold", "99px", "pink")
+##     else:
+##       echo toknizr.kind # All the kinds of tokens can be processed here.
+##       echo substr(code, toknizr.start, toknizr.length + toknizr.start - 1)
+##   ```
+##
+## The proc `getSourceLanguage` can get the language `enum` from a string:
+##   ```Nim
+##   for l in ["C", "c++", "jAvA", "Nim", "c#"]: echo getSourceLanguage(l)
+##   ```
+##
+## There is also a `Cmd` pseudo-language supported, which is a simple generic
+## shell/cmdline tokenizer (UNIX shell/Powershell/Windows Command):
+## no escaping, no programming language constructs besides variable definition
+## at the beginning of line. It supports these operators:
+##   ```Cmd
+##   &  &&  |  ||  (  )  ''  ""  ;  # for comments
+##   ```
+##
+## Instead of escaping always use quotes like here
+## `nimgrep --ext:'nim|nims' file.name`:cmd: shows how to input ``|``.
+## Any argument that contains ``.`` or ``/`` or ``\`` will be treated
+## as a file or directory.
+##
+## In addition to `Cmd` there is also `Console` language for
+## displaying interactive sessions.
+## Lines with a command should start with ``$``, other lines are considered
+## as program output.
+
+import
+  std/strutils
+from std/algorithm import binarySearch
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+
+type
+  SourceLanguage* = enum
+    langNone, langNim, langCpp, langCsharp, langC, langJava,
+    langYaml, langPython, langCmd, langConsole
+  TokenClass* = enum
+    gtEof, gtNone, gtWhitespace, gtDecNumber, gtBinNumber, gtHexNumber,
+    gtOctNumber, gtFloatNumber, gtIdentifier, gtKeyword, gtStringLit,
+    gtLongStringLit, gtCharLit, gtEscapeSequence, # escape sequence like \xff
+    gtOperator, gtPunctuation, gtComment, gtLongComment, gtRegularExpression,
+    gtTagStart, gtTagEnd, gtKey, gtValue, gtRawData, gtAssembler,
+    gtPreprocessor, gtDirective, gtCommand, gtRule, gtHyperlink, gtLabel,
+    gtReference, gtPrompt, gtProgramOutput, gtProgram, gtOption, gtOther
+  GeneralTokenizer* = object of RootObj
+    kind*: TokenClass
+    start*, length*: int
+    buf: cstring
+    pos: int
+    state: TokenClass
+    lang: SourceLanguage
+
+const
+  sourceLanguageToStr*: array[SourceLanguage, string] = ["none",
+    "Nim", "C++", "C#", "C", "Java", "Yaml", "Python", "Cmd", "Console"]
+  sourceLanguageToAlpha*: array[SourceLanguage, string] = ["none",
+    "Nim", "cpp", "csharp", "C", "Java", "Yaml", "Python", "Cmd", "Console"]
+    ## list of languages spelled with alpabetic characters
+  tokenClassToStr*: array[TokenClass, string] = ["Eof", "None", "Whitespace",
+    "DecNumber", "BinNumber", "HexNumber", "OctNumber", "FloatNumber",
+    "Identifier", "Keyword", "StringLit", "LongStringLit", "CharLit",
+    "EscapeSequence", "Operator", "Punctuation", "Comment", "LongComment",
+    "RegularExpression", "TagStart", "TagEnd", "Key", "Value", "RawData",
+    "Assembler", "Preprocessor", "Directive", "Command", "Rule", "Hyperlink",
+    "Label", "Reference", "Prompt", "ProgramOutput",
+    # start from lower-case if there is a corresponding RST role (see rst.nim)
+    "program", "option",
+    "Other"]
+
+  # The following list comes from doc/keywords.txt, make sure it is
+  # synchronized with this array by running the module itself as a test case.
+  nimKeywords = ["addr", "and", "as", "asm", "bind", "block",
+    "break", "case", "cast", "concept", "const", "continue", "converter",
+    "defer", "discard", "distinct", "div", "do",
+    "elif", "else", "end", "enum", "except", "export",
+    "finally", "for", "from", "func",
+    "if", "import", "in", "include",
+    "interface", "is", "isnot", "iterator", "let", "macro", "method",
+    "mixin", "mod", "nil", "not", "notin", "object", "of", "or", "out", "proc",
+    "ptr", "raise", "ref", "return", "shl", "shr", "static",
+    "template", "try", "tuple", "type", "using", "var", "when", "while",
+    "xor", "yield"]
+
+proc getSourceLanguage*(name: string): SourceLanguage =
+  for i in succ(low(SourceLanguage)) .. high(SourceLanguage):
+    if cmpIgnoreStyle(name, sourceLanguageToStr[i]) == 0:
+      return i
+    if cmpIgnoreStyle(name, sourceLanguageToAlpha[i]) == 0:
+      return i
+  result = langNone
+
+proc initGeneralTokenizer*(g: var GeneralTokenizer, buf: cstring) =
+  g.buf = buf
+  g.kind = low(TokenClass)
+  g.start = 0
+  g.length = 0
+  g.state = low(TokenClass)
+  g.lang = low(SourceLanguage)
+  g.pos = 0
+
+proc initGeneralTokenizer*(g: var GeneralTokenizer, buf: string) =
+  initGeneralTokenizer(g, cstring(buf))
+
+proc deinitGeneralTokenizer*(g: var GeneralTokenizer) =
+  discard
+
+proc nimGetKeyword(id: string): TokenClass =
+  for k in nimKeywords:
+    if cmpIgnoreStyle(id, k) == 0: return gtKeyword
+  result = gtIdentifier
+  when false:
+    var i = getIdent(id)
+    if (i.id >= ord(tokKeywordLow) - ord(tkSymbol)) and
+        (i.id <= ord(tokKeywordHigh) - ord(tkSymbol)):
+      result = gtKeyword
+    else:
+      result = gtIdentifier
+
+proc nimNumberPostfix(g: var GeneralTokenizer, position: int): int =
+  var pos = position
+  if g.buf[pos] == '\'':
+    inc(pos)
+    case g.buf[pos]
+    of 'f', 'F':
+      g.kind = gtFloatNumber
+      inc(pos)
+      if g.buf[pos] in {'0'..'9'}: inc(pos)
+      if g.buf[pos] in {'0'..'9'}: inc(pos)
+    of 'i', 'I':
+      inc(pos)
+      if g.buf[pos] in {'0'..'9'}: inc(pos)
+      if g.buf[pos] in {'0'..'9'}: inc(pos)
+    else:
+      discard
+  result = pos
+
+proc nimNumber(g: var GeneralTokenizer, position: int): int =
+  const decChars = {'0'..'9', '_'}
+  var pos = position
+  g.kind = gtDecNumber
+  while g.buf[pos] in decChars: inc(pos)
+  if g.buf[pos] == '.':
+    g.kind = gtFloatNumber
+    inc(pos)
+    while g.buf[pos] in decChars: inc(pos)
+  if g.buf[pos] in {'e', 'E'}:
+    g.kind = gtFloatNumber
+    inc(pos)
+    if g.buf[pos] in {'+', '-'}: inc(pos)
+    while g.buf[pos] in decChars: inc(pos)
+  result = nimNumberPostfix(g, pos)
+
+const
+  OpChars  = {'+', '-', '*', '/', '\\', '<', '>', '!', '?', '^', '.',
+              '|', '=', '%', '&', '$', '@', '~', ':'}
+
+proc isKeyword(x: openArray[string], y: string): int =
+  binarySearch(x, y)
+
+proc nimNextToken(g: var GeneralTokenizer, keywords: openArray[string] = @[]) =
+  const
+    hexChars = {'0'..'9', 'A'..'F', 'a'..'f', '_'}
+    octChars = {'0'..'7', '_'}
+    binChars = {'0'..'1', '_'}
+    SymChars = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'}
+  var pos = g.pos
+  g.start = g.pos
+  if g.state == gtStringLit:
+    if g.buf[pos] == '\\':
+      g.kind = gtEscapeSequence
+      inc(pos)
+      case g.buf[pos]
+      of 'x', 'X':
+        inc(pos)
+        if g.buf[pos] in hexChars: inc(pos)
+        if g.buf[pos] in hexChars: inc(pos)
+      of '0'..'9':
+        while g.buf[pos] in {'0'..'9'}: inc(pos)
+      of '\0':
+        g.state = gtNone
+      else: inc(pos)
+    else:
+      g.kind = gtStringLit
+      while true:
+        case g.buf[pos]
+        of '\\':
+          break
+        of '\0', '\r', '\n':
+          g.state = gtNone
+          break
+        of '\"':
+          inc(pos)
+          g.state = gtNone
+          break
+        else: inc(pos)
+  else:
+    case g.buf[pos]
+    of ' ', '\t'..'\r':
+      g.kind = gtWhitespace
+      while g.buf[pos] in {' ', '\t'..'\r'}: inc(pos)
+    of '#':
+      g.kind = gtComment
+      inc(pos)
+      var isDoc = false
+      if g.buf[pos] == '#':
+        inc(pos)
+        isDoc = true
+      if g.buf[pos] == '[' and g.lang == langNim:
+        g.kind = gtLongComment
+        var nesting = 0
+        while true:
+          case g.buf[pos]
+          of '\0': break
+          of '#':
+            if isDoc:
+              if g.buf[pos+1] == '#' and g.buf[pos+2] == '[':
+                inc nesting
+            elif g.buf[pos+1] == '[':
+              inc nesting
+            inc pos
+          of ']':
+            if isDoc:
+              if g.buf[pos+1] == '#' and g.buf[pos+2] == '#':
+                if nesting == 0:
+                  inc(pos, 3)
+                  break
+                dec nesting
+            elif g.buf[pos+1] == '#':
+              if nesting == 0:
+                inc(pos, 2)
+                break
+              dec nesting
+            inc pos
+          else:
+            inc pos
+      else:
+        while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+    of 'a'..'z', 'A'..'Z', '_', '\x80'..'\xFF':
+      var id = ""
+      while g.buf[pos] in SymChars + {'_'}:
+        add(id, g.buf[pos])
+        inc(pos)
+      if (g.buf[pos] == '\"'):
+        if (g.buf[pos + 1] == '\"') and (g.buf[pos + 2] == '\"'):
+          inc(pos, 3)
+          g.kind = gtLongStringLit
+          while true:
+            case g.buf[pos]
+            of '\0':
+              break
+            of '\"':
+              inc(pos)
+              if g.buf[pos] == '\"' and g.buf[pos+1] == '\"' and
+                  g.buf[pos+2] != '\"':
+                inc(pos, 2)
+                break
+            else: inc(pos)
+        else:
+          g.kind = gtRawData
+          inc(pos)
+          while not (g.buf[pos] in {'\0', '\n', '\r'}):
+            if g.buf[pos] == '"' and g.buf[pos+1] != '"': break
+            inc(pos)
+          if g.buf[pos] == '\"': inc(pos)
+      else:
+        if g.lang == langNim:
+          g.kind = nimGetKeyword(id)
+        elif isKeyword(keywords, id) >= 0:
+          g.kind = gtKeyword
+    of '0':
+      inc(pos)
+      case g.buf[pos]
+      of 'b', 'B':
+        g.kind = gtBinNumber
+        inc(pos)
+        while g.buf[pos] in binChars: inc(pos)
+        pos = nimNumberPostfix(g, pos)
+      of 'x', 'X':
+        g.kind = gtHexNumber
+        inc(pos)
+        while g.buf[pos] in hexChars: inc(pos)
+        pos = nimNumberPostfix(g, pos)
+      of 'o', 'O':
+        g.kind = gtOctNumber
+        inc(pos)
+        while g.buf[pos] in octChars: inc(pos)
+        pos = nimNumberPostfix(g, pos)
+      else: pos = nimNumber(g, pos)
+    of '1'..'9':
+      pos = nimNumber(g, pos)
+    of '\'':
+      inc(pos)
+      if g.kind != gtPunctuation:
+        g.kind = gtCharLit
+        while true:
+          case g.buf[pos]
+          of '\0', '\r', '\n':
+            break
+          of '\'':
+            inc(pos)
+            break
+          of '\\':
+            inc(pos, 2)
+          else: inc(pos)
+    of '\"':
+      inc(pos)
+      if (g.buf[pos] == '\"') and (g.buf[pos + 1] == '\"'):
+        inc(pos, 2)
+        g.kind = gtLongStringLit
+        while true:
+          case g.buf[pos]
+          of '\0':
+            break
+          of '\"':
+            inc(pos)
+            if g.buf[pos] == '\"' and g.buf[pos+1] == '\"' and
+                g.buf[pos+2] != '\"':
+              inc(pos, 2)
+              break
+          else: inc(pos)
+      else:
+        g.kind = gtStringLit
+        while true:
+          case g.buf[pos]
+          of '\0', '\r', '\n':
+            break
+          of '\"':
+            inc(pos)
+            break
+          of '\\':
+            g.state = g.kind
+            break
+          else: inc(pos)
+    of '(', ')', '[', ']', '{', '}', '`', ':', ',', ';':
+      inc(pos)
+      g.kind = gtPunctuation
+    of '\0':
+      g.kind = gtEof
+    else:
+      if g.buf[pos] in OpChars:
+        g.kind = gtOperator
+        while g.buf[pos] in OpChars: inc(pos)
+      else:
+        inc(pos)
+        g.kind = gtNone
+  g.length = pos - g.pos
+  if g.kind != gtEof and g.state != gtNone and g.length <= 0:
+    assert false, "nimNextToken: produced an empty token"
+  g.pos = pos
+
+proc generalNumber(g: var GeneralTokenizer, position: int): int =
+  const decChars = {'0'..'9'}
+  var pos = position
+  g.kind = gtDecNumber
+  while g.buf[pos] in decChars: inc(pos)
+  if g.buf[pos] == '.':
+    g.kind = gtFloatNumber
+    inc(pos)
+    while g.buf[pos] in decChars: inc(pos)
+  if g.buf[pos] in {'e', 'E'}:
+    g.kind = gtFloatNumber
+    inc(pos)
+    if g.buf[pos] in {'+', '-'}: inc(pos)
+    while g.buf[pos] in decChars: inc(pos)
+  result = pos
+
+proc generalStrLit(g: var GeneralTokenizer, position: int): int =
+  const
+    decChars = {'0'..'9'}
+    hexChars = {'0'..'9', 'A'..'F', 'a'..'f'}
+  var pos = position
+  g.kind = gtStringLit
+  var c = g.buf[pos]
+  inc(pos)                    # skip " or '
+  while true:
+    case g.buf[pos]
+    of '\0':
+      break
+    of '\\':
+      inc(pos)
+      case g.buf[pos]
+      of '\0':
+        break
+      of '0'..'9':
+        while g.buf[pos] in decChars: inc(pos)
+      of 'x', 'X':
+        inc(pos)
+        if g.buf[pos] in hexChars: inc(pos)
+        if g.buf[pos] in hexChars: inc(pos)
+      else: inc(pos, 2)
+    else:
+      if g.buf[pos] == c:
+        inc(pos)
+        break
+      else:
+        inc(pos)
+  result = pos
+
+type
+  TokenizerFlag = enum
+    hasPreprocessor, hasNestedComments
+  TokenizerFlags = set[TokenizerFlag]
+
+proc clikeNextToken(g: var GeneralTokenizer, keywords: openArray[string],
+                    flags: TokenizerFlags) =
+  const
+    hexChars = {'0'..'9', 'A'..'F', 'a'..'f'}
+    octChars = {'0'..'7'}
+    binChars = {'0'..'1'}
+    symChars = {'A'..'Z', 'a'..'z', '0'..'9', '_', '\x80'..'\xFF'}
+  var pos = g.pos
+  g.start = g.pos
+  if g.state == gtStringLit:
+    g.kind = gtStringLit
+    while true:
+      case g.buf[pos]
+      of '\\':
+        g.kind = gtEscapeSequence
+        inc(pos)
+        case g.buf[pos]
+        of 'x', 'X':
+          inc(pos)
+          if g.buf[pos] in hexChars: inc(pos)
+          if g.buf[pos] in hexChars: inc(pos)
+        of '0'..'9':
+          while g.buf[pos] in {'0'..'9'}: inc(pos)
+        of '\0':
+          g.state = gtNone
+        else: inc(pos)
+        break
+      of '\0', '\r', '\n':
+        g.state = gtNone
+        break
+      of '\"':
+        inc(pos)
+        g.state = gtNone
+        break
+      else: inc(pos)
+  else:
+    case g.buf[pos]
+    of ' ', '\t'..'\r':
+      g.kind = gtWhitespace
+      while g.buf[pos] in {' ', '\t'..'\r'}: inc(pos)
+    of '/':
+      inc(pos)
+      if g.buf[pos] == '/':
+        g.kind = gtComment
+        while not (g.buf[pos] in {'\0', '\n', '\r'}): inc(pos)
+      elif g.buf[pos] == '*':
+        g.kind = gtLongComment
+        var nested = 0
+        inc(pos)
+        while true:
+          case g.buf[pos]
+          of '*':
+            inc(pos)
+            if g.buf[pos] == '/':
+              inc(pos)
+              if nested == 0: break
+          of '/':
+            inc(pos)
+            if g.buf[pos] == '*':
+              inc(pos)
+              if hasNestedComments in flags: inc(nested)
+          of '\0':
+            break
+          else: inc(pos)
+      else:
+        g.kind = gtOperator
+        while g.buf[pos] in OpChars: inc(pos)
+    of '#':
+      inc(pos)
+      if hasPreprocessor in flags:
+        g.kind = gtPreprocessor
+        while g.buf[pos] in {' ', '\t'}: inc(pos)
+        while g.buf[pos] in symChars: inc(pos)
+      else:
+        g.kind = gtOperator
+    of 'a'..'z', 'A'..'Z', '_', '\x80'..'\xFF':
+      var id = ""
+      while g.buf[pos] in symChars:
+        add(id, g.buf[pos])
+        inc(pos)
+      if isKeyword(keywords, id) >= 0: g.kind = gtKeyword
+      else: g.kind = gtIdentifier
+    of '0':
+      inc(pos)
+      case g.buf[pos]
+      of 'b', 'B':
+        inc(pos)
+        while g.buf[pos] in binChars: inc(pos)
+        if g.buf[pos] in {'A'..'Z', 'a'..'z'}: inc(pos)
+      of 'x', 'X':
+        inc(pos)
+        while g.buf[pos] in hexChars: inc(pos)
+        if g.buf[pos] in {'A'..'Z', 'a'..'z'}: inc(pos)
+      of '0'..'7':
+        inc(pos)
+        while g.buf[pos] in octChars: inc(pos)
+        if g.buf[pos] in {'A'..'Z', 'a'..'z'}: inc(pos)
+      else:
+        pos = generalNumber(g, pos)
+        if g.buf[pos] in {'A'..'Z', 'a'..'z'}: inc(pos)
+    of '1'..'9':
+      pos = generalNumber(g, pos)
+      if g.buf[pos] in {'A'..'Z', 'a'..'z'}: inc(pos)
+    of '\'':
+      pos = generalStrLit(g, pos)
+      g.kind = gtCharLit
+    of '\"':
+      inc(pos)
+      g.kind = gtStringLit
+      while true:
+        case g.buf[pos]
+        of '\0':
+          break
+        of '\"':
+          inc(pos)
+          break
+        of '\\':
+          g.state = g.kind
+          break
+        else: inc(pos)
+    of '(', ')', '[', ']', '{', '}', ':', ',', ';', '.':
+      inc(pos)
+      g.kind = gtPunctuation
+    of '\0':
+      g.kind = gtEof
+    else:
+      if g.buf[pos] in OpChars:
+        g.kind = gtOperator
+        while g.buf[pos] in OpChars: inc(pos)
+      else:
+        inc(pos)
+        g.kind = gtNone
+  g.length = pos - g.pos
+  if g.kind != gtEof and g.length <= 0:
+    assert false, "clikeNextToken: produced an empty token"
+  g.pos = pos
+
+proc cNextToken(g: var GeneralTokenizer) =
+  const
+    keywords: array[0..36, string] = ["_Bool", "_Complex", "_Imaginary", "auto",
+      "break", "case", "char", "const", "continue", "default", "do", "double",
+      "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int",
+      "long", "register", "restrict", "return", "short", "signed", "sizeof",
+      "static", "struct", "switch", "typedef", "union", "unsigned", "void",
+      "volatile", "while"]
+  clikeNextToken(g, keywords, {hasPreprocessor})
+
+proc cppNextToken(g: var GeneralTokenizer) =
+  const
+    keywords: array[0..47, string] = ["asm", "auto", "break", "case", "catch",
+      "char", "class", "const", "continue", "default", "delete", "do", "double",
+      "else", "enum", "extern", "float", "for", "friend", "goto", "if",
+      "inline", "int", "long", "new", "operator", "private", "protected",
+      "public", "register", "return", "short", "signed", "sizeof", "static",
+      "struct", "switch", "template", "this", "throw", "try", "typedef",
+      "union", "unsigned", "virtual", "void", "volatile", "while"]
+  clikeNextToken(g, keywords, {hasPreprocessor})
+
+proc csharpNextToken(g: var GeneralTokenizer) =
+  const
+    keywords: array[0..76, string] = ["abstract", "as", "base", "bool", "break",
+      "byte", "case", "catch", "char", "checked", "class", "const", "continue",
+      "decimal", "default", "delegate", "do", "double", "else", "enum", "event",
+      "explicit", "extern", "false", "finally", "fixed", "float", "for",
+      "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal",
+      "is", "lock", "long", "namespace", "new", "null", "object", "operator",
+      "out", "override", "params", "private", "protected", "public", "readonly",
+      "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc",
+      "static", "string", "struct", "switch", "this", "throw", "true", "try",
+      "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using",
+      "virtual", "void", "volatile", "while"]
+  clikeNextToken(g, keywords, {hasPreprocessor})
+
+proc javaNextToken(g: var GeneralTokenizer) =
+  const
+    keywords: array[0..52, string] = ["abstract", "assert", "boolean", "break",
+      "byte", "case", "catch", "char", "class", "const", "continue", "default",
+      "do", "double", "else", "enum", "extends", "false", "final", "finally",
+      "float", "for", "goto", "if", "implements", "import", "instanceof", "int",
+      "interface", "long", "native", "new", "null", "package", "private",
+      "protected", "public", "return", "short", "static", "strictfp", "super",
+      "switch", "synchronized", "this", "throw", "throws", "transient", "true",
+      "try", "void", "volatile", "while"]
+  clikeNextToken(g, keywords, {})
+
+proc yamlPlainStrLit(g: var GeneralTokenizer, pos: var int) =
+  g.kind = gtStringLit
+  while g.buf[pos] notin {'\0', '\t'..'\r', ',', ']', '}'}:
+    if g.buf[pos] == ':' and
+        g.buf[pos + 1] in {'\0', '\t'..'\r', ' '}:
+      break
+    inc(pos)
+
+proc yamlPossibleNumber(g: var GeneralTokenizer, pos: var int) =
+  g.kind = gtNone
+  if g.buf[pos] == '-': inc(pos)
+  if g.buf[pos] == '0': inc(pos)
+  elif g.buf[pos] in '1'..'9':
+    inc(pos)
+    while g.buf[pos] in {'0'..'9'}: inc(pos)
+  else: yamlPlainStrLit(g, pos)
+  if g.kind == gtNone:
+    if g.buf[pos] in {'\0', '\t'..'\r', ' ', ',', ']', '}'}:
+      g.kind = gtDecNumber
+    elif g.buf[pos] == '.':
+      inc(pos)
+      if g.buf[pos] notin {'0'..'9'}: yamlPlainStrLit(g, pos)
+      else:
+        while g.buf[pos] in {'0'..'9'}: inc(pos)
+        if g.buf[pos] in {'\0', '\t'..'\r', ' ', ',', ']', '}'}:
+          g.kind = gtFloatNumber
+    if g.kind == gtNone:
+      if g.buf[pos] in {'e', 'E'}:
+        inc(pos)
+        if g.buf[pos] in {'-', '+'}: inc(pos)
+        if g.buf[pos] notin {'0'..'9'}: yamlPlainStrLit(g, pos)
+        else:
+          while g.buf[pos] in {'0'..'9'}: inc(pos)
+          if g.buf[pos] in {'\0', '\t'..'\r', ' ', ',', ']', '}'}:
+            g.kind = gtFloatNumber
+          else: yamlPlainStrLit(g, pos)
+      else: yamlPlainStrLit(g, pos)
+  while g.buf[pos] notin {'\0', ',', ']', '}', '\n', '\r'}:
+    inc(pos)
+    if g.buf[pos] notin {'\t'..'\r', ' ', ',', ']', '}'}:
+      yamlPlainStrLit(g, pos)
+      break
+  # theoretically, we would need to parse indentation (like with block scalars)
+  # because of possible multiline flow scalars that start with number-like
+  # content, but that is far too troublesome. I think it is fine that the
+  # highlighter is sloppy here.
+
+proc yamlNextToken(g: var GeneralTokenizer) =
+  const
+    hexChars = {'0'..'9', 'A'..'F', 'a'..'f'}
+  var pos = g.pos
+  g.start = g.pos
+  if g.state == gtStringLit:
+    g.kind = gtStringLit
+    while true:
+      case g.buf[pos]
+      of '\\':
+        if pos != g.pos: break
+        g.kind = gtEscapeSequence
+        inc(pos)
+        case g.buf[pos]
+        of 'x':
+          inc(pos)
+          for i in 1..2:
+            if g.buf[pos] in hexChars: inc(pos)
+          break
+        of 'u':
+          inc(pos)
+          for i in 1..4:
+            if g.buf[pos] in hexChars: inc(pos)
+          break
+        of 'U':
+          inc(pos)
+          for i in 1..8:
+            if g.buf[pos] in hexChars: inc(pos)
+          break
+        else: inc(pos)
+        break
+      of '\0':
+        g.state = gtOther
+        break
+      of '\"':
+        inc(pos)
+        g.state = gtOther
+        break
+      else: inc(pos)
+  elif g.state == gtCharLit:
+    # abusing gtCharLit as single-quoted string lit
+    g.kind = gtStringLit
+    inc(pos) # skip the starting '
+    while true:
+      case g.buf[pos]
+      of '\'':
+        inc(pos)
+        if g.buf[pos] == '\'':
+          inc(pos)
+          g.kind = gtEscapeSequence
+        else: g.state = gtOther
+        break
+      else: inc(pos)
+  elif g.state == gtCommand:
+    # gtCommand means 'block scalar header'
+    case g.buf[pos]
+    of ' ', '\t':
+      g.kind = gtWhitespace
+      while g.buf[pos] in {' ', '\t'}: inc(pos)
+    of '#':
+      g.kind = gtComment
+      while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+    of '\n', '\r': discard
+    else:
+      # illegal here. just don't parse a block scalar
+      g.kind = gtNone
+      g.state = gtOther
+    if g.buf[pos] in {'\n', '\r'} and g.state == gtCommand:
+      g.state = gtLongStringLit
+  elif g.state == gtLongStringLit:
+    # beware, this is the only token where we actually have to parse
+    # indentation.
+
+    g.kind = gtLongStringLit
+    # first, we have to find the parent indentation of the block scalar, so that
+    # we know when to stop
+    assert g.buf[pos] in {'\n', '\r'}
+    var lookbehind = pos - 1
+    var headerStart = -1
+    while lookbehind >= 0 and g.buf[lookbehind] notin {'\n', '\r'}:
+      if headerStart == -1 and g.buf[lookbehind] in {'|', '>'}:
+        headerStart = lookbehind
+      dec(lookbehind)
+    assert headerStart != -1
+    var indentation = 1
+    while g.buf[lookbehind + indentation] == ' ': inc(indentation)
+    if g.buf[lookbehind + indentation] in {'|', '>'}:
+      # when the header is alone in a line, this line does not show the parent's
+      # indentation, so we must go further. search the first previous line with
+      # non-whitespace content.
+      while lookbehind >= 0 and g.buf[lookbehind] in {'\n', '\r'}:
+        dec(lookbehind)
+        while lookbehind >= 0 and
+            g.buf[lookbehind] in {' ', '\t'}: dec(lookbehind)
+      # now, find the beginning of the line...
+      while lookbehind >= 0 and g.buf[lookbehind] notin {'\n', '\r'}:
+        dec(lookbehind)
+      # ... and its indentation
+      indentation = 1
+      while g.buf[lookbehind + indentation] == ' ': inc(indentation)
+    if lookbehind == -1: indentation = 0 # top level
+    elif g.buf[lookbehind + 1] == '-' and g.buf[lookbehind + 2] == '-' and
+        g.buf[lookbehind + 3] == '-' and
+        g.buf[lookbehind + 4] in {'\t'..'\r', ' '}:
+      # this is a document start, therefore, we are at top level
+      indentation = 0
+    # because lookbehind was at newline char when calculating indentation, we're
+    # off by one. fix that. top level's parent will have indentation of -1.
+    let parentIndentation = indentation - 1
+
+    # find first content
+    while g.buf[pos] in {' ', '\n', '\r'}:
+      if g.buf[pos] == ' ': inc(indentation)
+      else: indentation = 0
+      inc(pos)
+    var minIndentation = indentation
+
+    # for stupid edge cases, we must check whether an explicit indentation depth
+    # is given at the header.
+    while g.buf[headerStart] in {'>', '|', '+', '-'}: inc(headerStart)
+    if g.buf[headerStart] in {'0'..'9'}:
+      minIndentation = min(minIndentation, ord(g.buf[headerStart]) - ord('0'))
+
+    # process content lines
+    while indentation > parentIndentation and g.buf[pos] != '\0':
+      if (indentation < minIndentation and g.buf[pos] == '#') or
+          (indentation == 0 and g.buf[pos] == '.' and g.buf[pos + 1] == '.' and
+          g.buf[pos + 2] == '.' and
+          g.buf[pos + 3] in {'\0', '\t'..'\r', ' '}):
+        # comment after end of block scalar, or end of document
+        break
+      minIndentation = min(indentation, minIndentation)
+      while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+      while g.buf[pos] in {' ', '\n', '\r'}:
+        if g.buf[pos] == ' ': inc(indentation)
+        else: indentation = 0
+        inc(pos)
+
+    g.state = gtOther
+  elif g.state == gtOther:
+    # gtOther means 'inside YAML document'
+    case g.buf[pos]
+    of ' ', '\t'..'\r':
+      g.kind = gtWhitespace
+      while g.buf[pos] in {' ', '\t'..'\r'}: inc(pos)
+    of '#':
+      g.kind = gtComment
+      inc(pos)
+      while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+    of '-':
+      inc(pos)
+      if g.buf[pos] in {'\0', ' ', '\t'..'\r'}:
+        g.kind = gtPunctuation
+      elif g.buf[pos] == '-' and
+          (pos == 1 or g.buf[pos - 2] in {'\n', '\r'}): # start of line
+        inc(pos)
+        if g.buf[pos] == '-' and g.buf[pos + 1] in {'\0', '\t'..'\r', ' '}:
+          inc(pos)
+          g.kind = gtKeyword
+        else: yamlPossibleNumber(g, pos)
+      else: yamlPossibleNumber(g, pos)
+    of '.':
+      if pos == 0 or g.buf[pos - 1] in {'\n', '\r'}:
+        inc(pos)
+        for i in 1..2:
+          if g.buf[pos] != '.': break
+          inc(pos)
+        if pos == g.start + 3:
+          g.kind = gtKeyword
+          g.state = gtNone
+        else: yamlPlainStrLit(g, pos)
+      else: yamlPlainStrLit(g, pos)
+    of '?':
+      inc(pos)
+      if g.buf[pos] in {'\0', ' ', '\t'..'\r'}:
+        g.kind = gtPunctuation
+      else: yamlPlainStrLit(g, pos)
+    of ':':
+      inc(pos)
+      if g.buf[pos] in {'\0', '\t'..'\r', ' ', '\'', '\"'} or
+          (pos > 0 and g.buf[pos - 2] in {'}', ']', '\"', '\''}):
+        g.kind = gtPunctuation
+      else: yamlPlainStrLit(g, pos)
+    of '[', ']', '{', '}', ',':
+      inc(pos)
+      g.kind = gtPunctuation
+    of '\"':
+      inc(pos)
+      g.state = gtStringLit
+      g.kind = gtStringLit
+    of '\'':
+      g.state = gtCharLit
+      g.kind = gtNone
+    of '!':
+      g.kind = gtTagStart
+      inc(pos)
+      if g.buf[pos] == '<':
+        # literal tag (e.g. `!<tag:yaml.org,2002:str>`)
+        while g.buf[pos] notin {'\0', '>', '\t'..'\r', ' '}: inc(pos)
+        if g.buf[pos] == '>': inc(pos)
+      else:
+        while g.buf[pos] in {'A'..'Z', 'a'..'z', '0'..'9', '-'}: inc(pos)
+        case g.buf[pos]
+        of '!':
+          # prefixed tag (e.g. `!!str`)
+          inc(pos)
+          while g.buf[pos] notin
+              {'\0', '\t'..'\r', ' ', ',', '[', ']', '{', '}'}: inc(pos)
+        of '\0', '\t'..'\r', ' ': discard
+        else:
+          # local tag (e.g. `!nim:system:int`)
+          while g.buf[pos] notin {'\0', '\t'..'\r', ' '}: inc(pos)
+    of '&':
+      g.kind = gtLabel
+      while g.buf[pos] notin {'\0', '\t'..'\r', ' '}: inc(pos)
+    of '*':
+      g.kind = gtReference
+      while g.buf[pos] notin {'\0', '\t'..'\r', ' '}: inc(pos)
+    of '|', '>':
+      # this can lead to incorrect tokenization when | or > appear inside flow
+      # content. checking whether we're inside flow content is not
+      # chomsky type-3, so we won't do that here.
+      g.kind = gtCommand
+      g.state = gtCommand
+      inc(pos)
+      while g.buf[pos] in {'0'..'9', '+', '-'}: inc(pos)
+    of '0'..'9': yamlPossibleNumber(g, pos)
+    of '\0': g.kind = gtEof
+    else: yamlPlainStrLit(g, pos)
+  else:
+    # outside document
+    case g.buf[pos]
+    of '%':
+      if pos == 0 or g.buf[pos - 1] in {'\n', '\r'}:
+        g.kind = gtDirective
+        while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+      else:
+        g.state = gtOther
+        yamlPlainStrLit(g, pos)
+    of ' ', '\t'..'\r':
+      g.kind = gtWhitespace
+      while g.buf[pos] in {' ', '\t'..'\r'}: inc(pos)
+    of '#':
+      g.kind = gtComment
+      while g.buf[pos] notin {'\0', '\n', '\r'}: inc(pos)
+    of '\0': g.kind = gtEof
+    else:
+      g.kind = gtNone
+      g.state = gtOther
+  g.length = pos - g.pos
+  g.pos = pos
+
+proc pythonNextToken(g: var GeneralTokenizer) =
+  const
+    keywords: array[0..34, string] = [
+      "False", "None", "True", "and", "as", "assert", "async", "await",
+      "break", "class", "continue", "def", "del", "elif", "else", "except",
+      "finally", "for", "from", "global", "if", "import", "in", "is", "lambda",
+      "nonlocal", "not", "or", "pass", "raise", "return", "try", "while",
+      "with", "yield"]
+  nimNextToken(g, keywords)
+
+proc cmdNextToken(g: var GeneralTokenizer, dollarPrompt = false) =
+  var pos = g.pos
+  g.start = g.pos
+  if g.state == low(TokenClass):
+    g.state = if dollarPrompt: gtPrompt else: gtProgram
+  case g.buf[pos]
+  of ' ', '\t'..'\r':
+    g.kind = gtWhitespace
+    while g.buf[pos] in {' ', '\t'..'\r'}:
+      if g.buf[pos] == '\n':
+        g.state = if dollarPrompt: gtPrompt else: gtProgram
+      inc(pos)
+  of '\'', '"':
+    g.kind = gtOption
+    let q = g.buf[pos]
+    inc(pos)
+    while g.buf[pos] notin {q, '\0'}:
+      inc(pos)
+    if g.buf[pos] == q: inc(pos)
+  of '#':
+    g.kind = gtComment
+    while g.buf[pos] notin {'\n', '\0'}:
+      inc(pos)
+  of '&', '|':
+    g.kind = gtOperator
+    inc(pos)
+    if g.buf[pos] == g.buf[pos-1]: inc(pos)
+    g.state = gtProgram
+  of '(':
+    g.kind = gtOperator
+    g.state = gtProgram
+    inc(pos)
+  of ')':
+    g.kind = gtOperator
+    inc(pos)
+  of ';':
+    g.state = gtProgram
+    g.kind = gtOperator
+    inc(pos)
+  of '\0': g.kind = gtEof
+  elif dollarPrompt and g.state == gtPrompt:
+    if g.buf[pos] == '$' and g.buf[pos+1] in {' ', '\t'}:
+      g.kind = gtPrompt
+      inc pos, 2
+      g.state = gtProgram
+    else:
+      g.kind = gtProgramOutput
+      while g.buf[pos] notin {'\n', '\0'}:
+        inc(pos)
+  else:
+    if g.state == gtProgram:
+      g.kind = gtProgram
+      g.state = gtOption
+    else:
+      g.kind = gtOption
+    while g.buf[pos] notin {' ', '\t'..'\r', '&', '|', '(', ')', '\'', '"', '\0'}:
+      if g.buf[pos] == ';' and g.buf[pos+1] == ' ':
+        # (check space because ';' can be used inside arguments in Win bat)
+        break
+      if g.kind == gtOption and g.buf[pos] in {'/', '\\', '.'}:
+        g.kind = gtIdentifier  # for file/dir name
+      elif g.kind == gtProgram and g.buf[pos] == '=':
+        g.kind = gtIdentifier  # for env variable setting at beginning of line
+        g.state = gtProgram
+      inc(pos)
+  g.length = pos - g.pos
+  g.pos = pos
+
+proc getNextToken*(g: var GeneralTokenizer, lang: SourceLanguage) =
+  g.lang = lang
+  case lang
+  of langNone: assert false
+  of langNim: nimNextToken(g)
+  of langCpp: cppNextToken(g)
+  of langCsharp: csharpNextToken(g)
+  of langC: cNextToken(g)
+  of langJava: javaNextToken(g)
+  of langYaml: yamlNextToken(g)
+  of langPython: pythonNextToken(g)
+  of langCmd: cmdNextToken(g)
+  of langConsole: cmdNextToken(g, dollarPrompt=true)
+
+proc tokenize*(text: string, lang: SourceLanguage): seq[(string, TokenClass)] =
+  var g: GeneralTokenizer
+  initGeneralTokenizer(g, text)
+  var prevPos = 0
+  while true:
+    getNextToken(g, lang)
+    if g.kind == gtEof:
+      break
+    var s = text[prevPos ..< g.pos]
+    result.add (s, g.kind)
+    prevPos = g.pos
+
+when isMainModule:
+  var keywords: seq[string]
+  # Try to work running in both the subdir or at the root.
+  for filename in ["doc/keywords.txt", "../../../doc/keywords.txt"]:
+    try:
+      let input = readFile(filename)
+      keywords = input.splitWhitespace()
+      break
+    except:
+      echo filename, " not found"
+  doAssert(keywords.len > 0, "Couldn't read any keywords.txt file!")
+  for i in 0..min(keywords.len, nimKeywords.len)-1:
+    doAssert keywords[i] == nimKeywords[i], "Unexpected keyword"
+  doAssert keywords.len == nimKeywords.len, "No matching lengths"
diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim
new file mode 100644
index 000000000..706c50689
--- /dev/null
+++ b/lib/packages/docutils/rst.nim
@@ -0,0 +1,3886 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a `reStructuredText`:idx: (RST) and
+## `Markdown`:idx: parser.
+## User's manual on supported markup syntax and command line usage can be
+## found in [Nim-flavored Markdown and reStructuredText](markdown_rst.html).
+##
+## * See also [Nim DocGen Tools Guide](docgen.html) for handling of
+##   ``.nim`` files.
+## * See also [packages/docutils/rstgen module](rstgen.html) to know how to
+##   generate HTML or Latex strings (for embedding them into custom documents).
+##
+## Choice between Markdown and RST as well as optional additional features are
+## turned on by passing ``options:`` [RstParseOptions] to [proc rstParse].
+
+import
+  std/[os, strutils, enumutils, algorithm, lists, sequtils,
+  tables, strscans]
+import dochelpers, rstidx, rstast
+import std/private/miscdollars
+from highlite import SourceLanguage, getSourceLanguage
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+
+type
+  RstParseOption* = enum     ## options for the RST parser
+    roSupportSmilies,         ## make the RST parser support smilies like ``:)``
+    roSupportRawDirective,    ## support the ``raw`` directive (don't support
+                              ## it for sandboxing)
+    roSupportMarkdown,        ## support additional features of Markdown
+    roPreferMarkdown,         ## parse as Markdown (keeping RST as "extension"
+                              ## to Markdown) -- implies `roSupportMarkdown`
+    roNimFile                 ## set for Nim files where default interpreted
+                              ## text role should be :nim:
+    roSandboxDisabled         ## this option enables certain options
+                              ## (e.g. raw, include, importdoc)
+                              ## which are disabled by default as they can
+                              ## enable users to read arbitrary data and
+                              ## perform XSS if the parser is used in a web
+                              ## app.
+
+  RstParseOptions* = set[RstParseOption]
+
+  MsgClass* = enum
+    mcHint = "Hint",
+    mcWarning = "Warning",
+    mcError = "Error"
+
+  # keep the order in sync with compiler/docgen.nim and compiler/lineinfos.nim:
+  MsgKind* = enum          ## the possible messages
+    meCannotOpenFile = "cannot open '$1'",
+    meExpected = "'$1' expected",
+    meMissingClosing = "$1",
+    meGridTableNotImplemented = "grid table is not implemented",
+    meMarkdownIllformedTable = "illformed delimiter row of a Markdown table",
+    meIllformedTable = "Illformed table: $1",
+    meNewSectionExpected = "new section expected $1",
+    meGeneralParseError = "general parse error",
+    meInvalidDirective = "invalid directive: '$1'",
+    meInvalidField = "invalid field: $1",
+    meFootnoteMismatch = "mismatch in number of footnotes and their refs: $1",
+    mwRedefinitionOfLabel = "redefinition of label '$1'",
+    mwUnknownSubstitution = "unknown substitution '$1'",
+    mwAmbiguousLink = "ambiguous doc link $1",
+    mwBrokenLink = "broken link '$1'",
+    mwUnsupportedLanguage = "language '$1' not supported",
+    mwUnsupportedField = "field '$1' not supported",
+    mwRstStyle = "RST style: $1",
+    mwUnusedImportdoc = "importdoc for '$1' is not used",
+    meSandboxedDirective = "disabled directive: '$1'",
+
+  MsgHandler* = proc (filename: string, line, col: int, msgKind: MsgKind,
+                       arg: string) {.closure, gcsafe.} ## what to do in case of an error
+  FindFileHandler* = proc (filename: string): string {.closure, gcsafe.}
+  FindRefFileHandler* =
+    proc (targetRelPath: string):
+         tuple[targetPath: string, linkRelPath: string] {.closure, gcsafe.}
+    ## returns where .html or .idx file should be found by its relative path;
+    ## `linkRelPath` is a prefix to be added before a link anchor from such file
+
+proc rstnodeToRefname*(n: PRstNode): string
+proc addNodes*(n: PRstNode): string
+proc getFieldValue*(n: PRstNode, fieldname: string): string {.gcsafe.}
+proc getArgument*(n: PRstNode): string
+
+# ----------------------------- scanner part --------------------------------
+
+const
+  SymChars: set[char] = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'}
+  SmileyStartChars: set[char] = {':', ';', '8'}
+  Smilies = {
+    ":D": "icon_e_biggrin",
+    ":-D": "icon_e_biggrin",
+    ":)": "icon_e_smile",
+    ":-)": "icon_e_smile",
+    ";)": "icon_e_wink",
+    ";-)": "icon_e_wink",
+    ":(": "icon_e_sad",
+    ":-(": "icon_e_sad",
+    ":o": "icon_e_surprised",
+    ":-o": "icon_e_surprised",
+    ":shock:": "icon_eek",
+    ":?": "icon_e_confused",
+    ":-?": "icon_e_confused",
+    ":-/": "icon_e_confused",
+
+    "8-)": "icon_cool",
+
+    ":lol:": "icon_lol",
+    ":x": "icon_mad",
+    ":-x": "icon_mad",
+    ":P": "icon_razz",
+    ":-P": "icon_razz",
+    ":oops:": "icon_redface",
+    ":cry:": "icon_cry",
+    ":evil:": "icon_evil",
+    ":twisted:": "icon_twisted",
+    ":roll:": "icon_rolleyes",
+    ":!:": "icon_exclaim",
+
+    ":?:": "icon_question",
+    ":idea:": "icon_idea",
+    ":arrow:": "icon_arrow",
+    ":|": "icon_neutral",
+    ":-|": "icon_neutral",
+    ":mrgreen:": "icon_mrgreen",
+    ":geek:": "icon_e_geek",
+    ":ugeek:": "icon_e_ugeek"
+  }
+  SandboxDirAllowlist = [
+    "image", "code", "code-block", "admonition", "attention", "caution",
+    "container", "contents", "danger", "default-role", "error", "figure",
+    "hint", "important", "index", "note", "role", "tip", "title", "warning"]
+
+type
+  TokType = enum
+    tkEof, tkIndent,
+    tkWhite, tkWord,
+    tkAdornment,              # used for chapter adornment, transitions and
+                              # horizontal table borders
+    tkPunct,                  # one or many punctuation characters
+    tkOther
+  Token = object              # a RST token
+    kind*: TokType            # the type of the token
+    ival*: int                # the indentation or parsed integer value
+    symbol*: string           # the parsed symbol as string
+    line*, col*: int          # line and column of the token
+
+  TokenSeq = seq[Token]
+  Lexer = object of RootObj
+    buf*: cstring
+    bufpos*: int
+    line*, col*, baseIndent*: int
+    adornmentLine*: bool
+    escapeNext*: bool
+
+proc getThing(L: var Lexer, tok: var Token, s: set[char]) =
+  tok.kind = tkWord
+  tok.line = L.line
+  tok.col = L.col
+  var pos = L.bufpos
+  while true:
+    tok.symbol.add(L.buf[pos])
+    inc pos
+    if L.buf[pos] notin s: break
+  inc L.col, pos - L.bufpos
+  L.bufpos = pos
+
+proc isCurrentLineAdornment(L: var Lexer): bool =
+  var pos = L.bufpos
+  let c = L.buf[pos]
+  while true:
+    inc pos
+    if L.buf[pos] in {'\c', '\l', '\0'}:
+      break
+    if c == '+':  # grid table
+      if L.buf[pos] notin {'-', '=', '+'}:
+        return false
+    else:  # section adornment or table horizontal border
+      if L.buf[pos] notin {c, ' ', '\t', '\v', '\f'}:
+        return false
+  result = true
+
+proc getPunctAdornment(L: var Lexer, tok: var Token) =
+  if L.adornmentLine:
+    tok.kind = tkAdornment
+  else:
+    tok.kind = tkPunct
+  tok.line = L.line
+  tok.col = L.col
+  var pos = L.bufpos
+  let c = L.buf[pos]
+  if not L.escapeNext and (c != '\\' or L.adornmentLine):
+    while true:
+      tok.symbol.add(L.buf[pos])
+      inc pos
+      if L.buf[pos] != c: break
+  elif L.escapeNext:
+    tok.symbol.add(L.buf[pos])
+    inc pos
+  else:  # not L.escapeNext and c == '\\' and not L.adornmentLine
+    tok.symbol.add '\\'
+    inc pos
+    L.escapeNext = true
+  inc L.col, pos - L.bufpos
+  L.bufpos = pos
+  if tok.symbol == "\\": tok.kind = tkPunct
+    # nim extension: standalone \ can not be adornment
+
+proc getBracket(L: var Lexer, tok: var Token) =
+  tok.kind = tkPunct
+  tok.line = L.line
+  tok.col = L.col
+  tok.symbol.add(L.buf[L.bufpos])
+  inc L.col
+  inc L.bufpos
+
+proc getIndentAux(L: var Lexer, start: int): int =
+  var pos = start
+  # skip the newline (but include it in the token!)
+  if L.buf[pos] == '\r':
+    if L.buf[pos + 1] == '\n': inc pos, 2
+    else: inc pos
+  elif L.buf[pos] == '\n':
+    inc pos
+  while true:
+    case L.buf[pos]
+    of ' ', '\v', '\f':
+      inc pos
+      inc result
+    of '\t':
+      inc pos
+      result = result - (result mod 8) + 8
+    else:
+      break                   # EndOfFile also leaves the loop
+  if L.buf[pos] == '\0':
+    result = 0
+  elif L.buf[pos] == '\n' or L.buf[pos] == '\r':
+    # look at the next line for proper indentation:
+    result = getIndentAux(L, pos)
+  L.bufpos = pos              # no need to set back buf
+
+proc getIndent(L: var Lexer, tok: var Token) =
+  tok.col = 0
+  tok.kind = tkIndent         # skip the newline (but include it in the token!)
+  tok.ival = getIndentAux(L, L.bufpos)
+  inc L.line
+  tok.line = L.line
+  L.col = tok.ival
+  tok.ival = max(tok.ival - L.baseIndent, 0)
+  tok.symbol = "\n" & spaces(tok.ival)
+
+proc rawGetTok(L: var Lexer, tok: var Token) =
+  tok.symbol = ""
+  tok.ival = 0
+  if L.col == 0:
+    L.adornmentLine = false
+  var c = L.buf[L.bufpos]
+  case c
+  of 'a'..'z', 'A'..'Z', '\x80'..'\xFF', '0'..'9':
+    getThing(L, tok, SymChars)
+  of ' ', '\t', '\v', '\f':
+    getThing(L, tok, {' ', '\t'})
+    tok.kind = tkWhite
+    if L.buf[L.bufpos] in {'\r', '\n'}:
+      rawGetTok(L, tok)       # ignore spaces before \n
+  of '\r', '\n':
+    getIndent(L, tok)
+    L.adornmentLine = false
+  of '!', '\"', '#', '$', '%', '&', '\'',  '*', '+', ',', '-', '.',
+     '/', ':', ';', '<', '=', '>', '?', '@', '\\', '^', '_', '`',
+     '|', '~':
+    if L.col == 0:
+      L.adornmentLine = L.isCurrentLineAdornment()
+    getPunctAdornment(L, tok)
+  of '(', ')', '[', ']', '{', '}':
+    getBracket(L, tok)
+  else:
+    tok.line = L.line
+    tok.col = L.col
+    if c == '\0':
+      tok.kind = tkEof
+    else:
+      tok.kind = tkOther
+      tok.symbol.add(c)
+      inc L.bufpos
+      inc L.col
+  tok.col = max(tok.col - L.baseIndent, 0)
+
+proc getTokens(buffer: string, tokens: var TokenSeq) =
+  var L: Lexer
+  var length = tokens.len
+  L.buf = cstring(buffer)
+  L.line = 0                  # skip UTF-8 BOM
+  if L.buf[0] == '\xEF' and L.buf[1] == '\xBB' and L.buf[2] == '\xBF':
+    inc L.bufpos, 3
+  while true:
+    inc length
+    setLen(tokens, length)
+    let toEscape = L.escapeNext
+    rawGetTok(L, tokens[length - 1])
+    if toEscape: L.escapeNext = false
+    if tokens[length - 1].kind == tkEof: break
+  if tokens[0].kind == tkWhite:
+    # BUGFIX
+    tokens[0].ival = tokens[0].symbol.len
+    tokens[0].kind = tkIndent
+
+type
+  LevelInfo = object
+    symbol: char         # adornment character
+    hasOverline: bool    # has also overline (besides underline)?
+    line: int            # the last line of this style occurrence
+                         # (for error message)
+    hasPeers: bool       # has headings on the same level of hierarchy?
+  LiteralBlockKind = enum  # RST-style literal blocks after `::`
+    lbNone,
+    lbIndentedLiteralBlock,
+    lbQuotedLiteralBlock
+  LevelMap = seq[LevelInfo]   # Saves for each possible title adornment
+                              # style its level in the current document.
+  SubstitutionKind = enum
+    rstSubstitution = "substitution",
+    hyperlinkAlias = "hyperlink alias",
+    implicitHyperlinkAlias = "implicitly-generated hyperlink alias"
+  Substitution = object
+    kind*: SubstitutionKind
+    key*: string
+    value*: PRstNode
+    info*: TLineInfo   # place where the substitution was defined
+  AnchorRule = enum
+    arInternalRst,  ## For automatically generated RST anchors (from
+                    ## headings, footnotes, inline internal targets):
+                    ## case-insensitive, 1-space-significant (by RST spec)
+    arExternalRst,  ## For external .nim doc comments or .rst/.md
+    arNim   ## For anchors generated by ``docgen.nim``: Nim-style case
+            ## sensitivity, etc. (see `proc normalizeNimName`_ for details)
+    arHyperlink,  ## For links with manually set anchors in
+                  ## form `text <pagename.html#anchor>`_
+  RstAnchorKind = enum
+    manualDirectiveAnchor = "manual directive anchor",
+    manualInlineAnchor = "manual inline anchor",
+    footnoteAnchor = "footnote anchor",
+    headlineAnchor = "implicitly-generated headline anchor"
+  AnchorSubst = object
+    info: TLineInfo         # the file where the anchor was defined
+    priority: int
+    case kind: range[arInternalRst .. arNim]
+    of arInternalRst:
+      anchorType: RstAnchorKind
+      target: PRstNode
+    of arExternalRst:
+      anchorTypeExt: RstAnchorKind
+      refnameExt: string
+    of arNim:
+      module: FileIndex     # anchor's module (generally not the same as file)
+      tooltip: string       # displayed tooltip for Nim-generated anchors
+      langSym: LangSymbol
+      refname: string     # A reference name that will be inserted directly
+                          # into HTML/Latex.
+      external: bool
+  AnchorSubstTable = Table[string, seq[AnchorSubst]]
+                         # use `seq` to account for duplicate anchors
+  FootnoteType = enum
+    fnManualNumber,     # manually numbered footnote like [3]
+    fnAutoNumber,       # auto-numbered footnote [#]
+    fnAutoNumberLabel,  # auto-numbered with label [#label]
+    fnAutoSymbol,       # auto-symbol footnote [*]
+    fnCitation          # simple text label like [citation2021]
+  FootnoteSubst = tuple
+    kind: FootnoteType  # discriminator
+    number: int         # valid for fnManualNumber (always) and fnAutoNumber,
+                        # fnAutoNumberLabel after resolveSubs is called
+    autoNumIdx: int     # order of occurrence: fnAutoNumber, fnAutoNumberLabel
+    autoSymIdx: int     # order of occurrence: fnAutoSymbol
+    label: string       # valid for fnAutoNumberLabel
+  RstFileTable* = object
+    filenameToIdx*: Table[string, FileIndex]
+    idxToFilename*: seq[string]
+  ImportdocInfo = object
+    used: bool             # was this import used?
+    fromInfo: TLineInfo    # place of `.. importdoc::` directive
+    idxPath: string        # full path to ``.idx`` file
+    linkRelPath: string    # prefix before target anchor
+    title: string          # document title obtained from ``.idx``
+  RstSharedState = object
+    options*: RstParseOptions   # parsing options
+    hLevels: LevelMap           # hierarchy of heading styles
+    hTitleCnt: int              # =0 if no title, =1 if only main title,
+                                # =2 if both title and subtitle are present
+    hCurLevel: int              # current section level
+    currRole: string            # current interpreted text role
+    currRoleKind: RstNodeKind   # ... and its node kind
+    subs: seq[Substitution]     # substitutions
+    refs*: seq[Substitution]    # references
+    anchors*: AnchorSubstTable
+                                # internal target substitutions
+    lineFootnoteNum: seq[TLineInfo]     # footnote line, auto numbers .. [#]
+    lineFootnoteNumRef: seq[TLineInfo]  # footnote line, their reference [#]_
+    currFootnoteNumRef: int             # ... their counter for `resolveSubs`
+    lineFootnoteSym: seq[TLineInfo]     # footnote line, auto symbols .. [*]
+    lineFootnoteSymRef: seq[TLineInfo]  # footnote line, their reference [*]_
+    currFootnoteSymRef: int             # ... their counter for `resolveSubs`
+    footnotes: seq[FootnoteSubst] # correspondence b/w footnote label,
+                                  # number, order of occurrence
+    msgHandler: MsgHandler      # How to handle errors.
+    findFile: FindFileHandler   # How to find files for include.
+    findRefFile: FindRefFileHandler
+                                # How to find files imported by importdoc.
+    filenames*: RstFileTable    # map file name <-> FileIndex (for storing
+                                # file names for warnings after 1st stage)
+    currFileIdx*: FileIndex     # current index in `filenames`
+    tocPart*: seq[PRstNode]     # all the headings of a document
+    hasToc*: bool
+    idxImports*: Table[string, ImportdocInfo]
+                                # map `importdoc`ed filename -> it's info
+    nimFileImported*: bool      # Was any ``.nim`` module `importdoc`ed ?
+
+  PRstSharedState* = ref RstSharedState
+  ManualAnchor = object
+    alias: string     # a (short) name that can substitute the `anchor`
+    anchor: string    # anchor = id = refname
+    info: TLineInfo
+  RstParser = object of RootObj
+    idx*: int
+    tok*: TokenSeq
+    s*: PRstSharedState
+    indentStack*: seq[int]
+    line*, col*: int            ## initial line/column of whole text or
+                                ## documenation fragment that will be added
+                                ## in case of error/warning reporting to
+                                ## (relative) line/column of the token.
+    curAnchors*: seq[ManualAnchor]
+                                ## seq to accumulate aliases for anchors:
+                                ## because RST can have >1 alias per 1 anchor
+
+  EParseError* = object of ValueError
+  SectionParser = proc (p: var RstParser): PRstNode {.nimcall, gcsafe.}
+
+const
+  LineRstInit* = 1  ## Initial line number for standalone RST text
+  ColRstInit* = 0   ## Initial column number for standalone RST text
+                    ## (Nim global reporting adds ColOffset=1)
+  ColRstOffset* = 1 ## 1: a replica of ColOffset for internal use
+
+template currentTok(p: RstParser): Token = p.tok[p.idx]
+template prevTok(p: RstParser): Token = p.tok[p.idx - 1]
+template nextTok(p: RstParser): Token = p.tok[p.idx + 1]
+
+proc whichMsgClass*(k: MsgKind): MsgClass =
+  ## returns which message class `k` belongs to.
+  case k.symbolName[1]
+  of 'e', 'E': result = mcError
+  of 'w', 'W': result = mcWarning
+  of 'h', 'H': result = mcHint
+  else: assert false, "msgkind does not fit naming scheme"
+
+proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind,
+                        arg: string) =
+  let mc = msgkind.whichMsgClass
+  let a = $msgkind % arg
+  var message: string
+  toLocation(message, filename, line, col + ColRstOffset)
+  message.add " $1: $2" % [$mc, a]
+  if mc == mcError: raise newException(EParseError, message)
+  else: writeLine(stdout, message)
+
+proc defaultFindFile*(filename: string): string =
+  if fileExists(filename): result = filename
+  else: result = ""
+
+proc defaultFindRefFile*(filename: string): (string, string) =
+  (filename, "")
+
+proc defaultRole(options: RstParseOptions): string =
+  if roNimFile in options: "nim" else: "literal"
+
+proc whichRoleAux(sym: string): RstNodeKind =
+  let r = sym.toLowerAscii
+  case r
+  of "idx": result = rnIdx
+  of "literal": result = rnInlineLiteral
+  of "strong": result = rnStrongEmphasis
+  of "emphasis": result = rnEmphasis
+  of "sub", "subscript": result = rnSub
+  of "sup", "superscript": result = rnSup
+  # literal and code are the same in our implementation
+  of "code": result = rnInlineLiteral
+  of "program", "option", "tok": result = rnCodeFragment
+  # c++ currently can be spelled only as cpp, c# only as csharp
+  elif getSourceLanguage(r) != langNone:
+    result = rnInlineCode
+  else:  # unknown role
+    result = rnUnknownRole
+
+proc len(filenames: RstFileTable): int = filenames.idxToFilename.len
+
+proc addFilename*(s: PRstSharedState, file1: string): FileIndex =
+  ## Returns index of filename, adding it if it has not been used before
+  let nextIdx = s.filenames.len.FileIndex
+  result = getOrDefault(s.filenames.filenameToIdx, file1, default = nextIdx)
+  if result == nextIdx:
+    s.filenames.filenameToIdx[file1] = result
+    s.filenames.idxToFilename.add file1
+
+proc setCurrFilename*(s: PRstSharedState, file1: string) =
+  s.currFileIdx = addFilename(s, file1)
+
+proc getFilename(filenames: RstFileTable, fid: FileIndex): string =
+  doAssert(0 <= fid.int and fid.int < filenames.len,
+      "incorrect FileIndex $1 (range 0..$2)" % [
+        $fid.int, $(filenames.len - 1)])
+  result = filenames.idxToFilename[fid.int]
+
+proc getFilename(s: PRstSharedState, subst: AnchorSubst): string =
+  getFilename(s.filenames, subst.info.fileIndex)
+
+proc getModule(s: PRstSharedState, subst: AnchorSubst): string =
+  result = getFilename(s.filenames, subst.module)
+
+proc currFilename(s: PRstSharedState): string =
+  getFilename(s.filenames, s.currFileIdx)
+
+proc newRstSharedState*(options: RstParseOptions,
+                        filename: string,
+                        findFile: FindFileHandler,
+                        findRefFile: FindRefFileHandler,
+                        msgHandler: MsgHandler,
+                        hasToc: bool): PRstSharedState =
+  let r = defaultRole(options)
+  result = PRstSharedState(
+      currRole: r,
+      currRoleKind: whichRoleAux(r),
+      options: options,
+      msgHandler: if not isNil(msgHandler): msgHandler else: defaultMsgHandler,
+      findFile: if not isNil(findFile): findFile else: defaultFindFile,
+      findRefFile:
+        if not isNil(findRefFile): findRefFile
+        else: defaultFindRefFile,
+      hasToc: hasToc
+  )
+  setCurrFilename(result, filename)
+
+proc curLine(p: RstParser): int = p.line + currentTok(p).line
+
+proc findRelativeFile(p: RstParser; filename: string): string =
+  result = p.s.currFilename.splitFile.dir / filename
+  if not fileExists(result):
+    result = p.s.findFile(filename)
+
+proc rstMessage(p: RstParser, msgKind: MsgKind, arg: string) =
+  p.s.msgHandler(p.s.currFilename, curLine(p),
+                             p.col + currentTok(p).col, msgKind, arg)
+
+proc rstMessage(s: PRstSharedState, msgKind: MsgKind, arg: string) =
+  s.msgHandler(s.currFilename, LineRstInit, ColRstInit, msgKind, arg)
+
+proc rstMessage(s: PRstSharedState, msgKind: MsgKind, arg: string;
+                line, col: int) =
+  s.msgHandler(s.currFilename, line, col, msgKind, arg)
+
+proc rstMessage(s: PRstSharedState, filename: string, msgKind: MsgKind,
+                arg: string) =
+  s.msgHandler(filename, LineRstInit, ColRstInit, msgKind, arg)
+
+proc rstMessage*(filenames: RstFileTable, f: MsgHandler,
+                 info: TLineInfo, msgKind: MsgKind, arg: string) =
+  ## Print warnings using `info`, i.e. in 2nd-pass warnings for
+  ## footnotes/substitutions/references or from ``rstgen.nim``.
+  let file = getFilename(filenames, info.fileIndex)
+  f(file, info.line.int, info.col.int, msgKind, arg)
+
+proc rstMessage(p: RstParser, msgKind: MsgKind, arg: string, line, col: int) =
+  p.s.msgHandler(p.s.currFilename, p.line + line,
+                             p.col + col, msgKind, arg)
+
+proc rstMessage(p: RstParser, msgKind: MsgKind) =
+  p.s.msgHandler(p.s.currFilename, curLine(p),
+                             p.col + currentTok(p).col, msgKind,
+                             currentTok(p).symbol)
+
+# Functions `isPureRst` & `stopOrWarn` address differences between
+# Markdown and RST:
+# * Markdown always tries to continue working. If it is really impossible
+#   to parse a markup element, its proc just returns `nil` and parsing
+#   continues for it as for normal text paragraph.
+#   The downside is that real mistakes/typos are often silently ignored.
+#   The same applies to legacy `RstMarkdown` mode for nimforum.
+# * RST really signals errors. The downside is that it's more intrusive -
+#   the user must escape special syntax with \ explicitly.
+#
+# TODO: we need to apply this strategy to all markup elements eventually.
+
+func isPureRst(p: RstParser): bool = roSupportMarkdown notin p.s.options
+func isRst(p: RstParser): bool = roPreferMarkdown notin p.s.options
+func isMd(p: RstParser): bool = roPreferMarkdown in p.s.options
+func isMd(s: PRstSharedState): bool = roPreferMarkdown in s.options
+
+proc stopOrWarn(p: RstParser, errorType: MsgKind, arg: string) =
+  let realMsgKind = if isPureRst(p): errorType else: mwRstStyle
+  rstMessage(p, realMsgKind, arg)
+
+proc stopOrWarn(p: RstParser, errorType: MsgKind, arg: string, line, col: int) =
+  let realMsgKind = if isPureRst(p): errorType else: mwRstStyle
+  rstMessage(p, realMsgKind, arg, line, col)
+
+proc currInd(p: RstParser): int =
+  result = p.indentStack[high(p.indentStack)]
+
+proc pushInd(p: var RstParser, ind: int) =
+  p.indentStack.add(ind)
+
+proc popInd(p: var RstParser) =
+  if p.indentStack.len > 1: setLen(p.indentStack, p.indentStack.len - 1)
+
+# Working with indentation in rst.nim
+# -----------------------------------
+#
+# Every line break has an associated tkIndent.
+# The tokenizer writes back the first column of next non-blank line
+# in all preceeding tkIndent tokens to the `ival` field of tkIndent.
+#
+# RST document is separated into body elements (B.E.), every of which
+# has a dedicated handler proc (or block of logic when B.E. is a block quote)
+# that should follow the next rule:
+#   Every B.E. handler proc should finish at tkIndent (newline)
+#   after its B.E. finishes.
+#   Then its callers (which is `parseSection` or another B.E. handler)
+#   check for tkIndent ival (without necessity to advance `p.idx`)
+#   and decide themselves whether they continue processing or also stop.
+#
+# An example::
+#
+#   L    RST text fragment                  indentation
+#     +--------------------+
+#   1 |                    | <- (empty line at the start of file) no tokens
+#   2 |First paragraph.    | <- tkIndent has ival=0, and next tkWord has col=0
+#   3 |                    | <- tkIndent has ival=0
+#   4 |* bullet item and   | <- tkIndent has ival=0, and next tkPunct has col=0
+#   5 |  its continuation  | <- tkIndent has ival=2, and next tkWord has col=2
+#   6 |                    | <- tkIndent has ival=4
+#   7 |    Block quote     | <- tkIndent has ival=4, and next tkWord has col=4
+#   8 |                    | <- tkIndent has ival=0
+#   9 |                    | <- tkIndent has ival=0
+#   10|Final paragraph     | <- tkIndent has ival=0, and tkWord has col=0
+#     +--------------------+
+#    C:01234
+#
+# Here parser starts with initial `indentStack=[0]` and then calls the
+# 1st `parseSection`:
+#
+#   - `parseSection` calls `parseParagraph` and "First paragraph" is parsed
+#   - bullet list handler is started at reaching ``*`` (L4 C0), it
+#     starts bullet item logic (L4 C2), which calls `pushInd(p, ind=2)`,
+#     then calls `parseSection` (2nd call, nested) which parses
+#     paragraph "bullet list and its continuation" and then starts
+#     a block quote logic (L7 C4).
+#     The block quote logic calls calls `pushInd(p, ind=4)` and
+#     calls `parseSection` again, so a (simplified) sequence of calls now is::
+#
+#       parseSection -> parseBulletList ->
+#         parseSection (+block quote logic) -> parseSection
+#
+#     3rd `parseSection` finishes, block quote logic calls `popInd(p)`,
+#     it returns to bullet item logic, which sees that next tkIndent has
+#     ival=0 and stops there since the required indentation for a bullet item
+#     is 2 and 0<2; the bullet item logic calls `popInd(p)`.
+#     Then bullet list handler checks that next tkWord (L10 C0) has the
+#     right indentation but does not have ``*`` so stops at tkIndent (L10).
+#   - 1st `parseSection` invocation calls `parseParagraph` and the
+#     "Final paragraph" is parsed.
+#
+# If a B.E. handler has advanced `p.idx` past tkIndent to check
+# whether it should continue its processing or not, and decided not to,
+# then this B.E. handler should step back (e.g. do `dec p.idx`).
+
+proc initParser(p: var RstParser, sharedState: PRstSharedState) =
+  p.indentStack = @[0]
+  p.tok = @[]
+  p.idx = 0
+  p.col = ColRstInit
+  p.line = LineRstInit
+  p.s = sharedState
+
+proc addNodesAux(n: PRstNode, result: var string) =
+  if n == nil:
+    return
+  if n.kind == rnLeaf:
+    result.add(n.text)
+  else:
+    for i in 0 ..< n.len: addNodesAux(n.sons[i], result)
+
+proc addNodes(n: PRstNode): string =
+  n.addNodesAux(result)
+
+proc linkName(n: PRstNode): string =
+  ## Returns a normalized reference name, see:
+  ## https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#reference-names
+  n.addNodes.toLowerAscii
+
+proc rstnodeToRefnameAux(n: PRstNode, r: var string, b: var bool) =
+  template special(s) =
+    if b:
+      r.add('-')
+      b = false
+    r.add(s)
+
+  if n == nil: return
+  if n.kind == rnLeaf:
+    for i in 0 ..< n.text.len:
+      case n.text[i]
+      of '0'..'9':
+        if b:
+          r.add('-')
+          b = false
+        if r.len == 0: r.add('Z')
+        r.add(n.text[i])
+      of 'a'..'z', '\128'..'\255':
+        if b:
+          r.add('-')
+          b = false
+        r.add(n.text[i])
+      of 'A'..'Z':
+        if b:
+          r.add('-')
+          b = false
+        r.add(chr(ord(n.text[i]) - ord('A') + ord('a')))
+      of '$': special "dollar"
+      of '%': special "percent"
+      of '&': special "amp"
+      of '^': special "roof"
+      of '!': special "emark"
+      of '?': special "qmark"
+      of '*': special "star"
+      of '+': special "plus"
+      of '-': special "minus"
+      of '/': special "slash"
+      of '\\': special "backslash"
+      of '=': special "eq"
+      of '<': special "lt"
+      of '>': special "gt"
+      of '~': special "tilde"
+      of ':': special "colon"
+      of '.': special "dot"
+      of '@': special "at"
+      of '|': special "bar"
+      else:
+        if r.len > 0: b = true
+  else:
+    for i in 0 ..< n.len: rstnodeToRefnameAux(n.sons[i], r, b)
+
+proc rstnodeToRefname(n: PRstNode): string =
+  var b = false
+  rstnodeToRefnameAux(n, result, b)
+
+proc findSub(s: PRstSharedState, n: PRstNode): int =
+  var key = addNodes(n)
+  # the spec says: if no exact match, try one without case distinction:
+  for i in countup(0, high(s.subs)):
+    if key == s.subs[i].key:
+      return i
+  for i in countup(0, high(s.subs)):
+    if cmpIgnoreStyle(key, s.subs[i].key) == 0:
+      return i
+  result = -1
+
+proc lineInfo(p: RstParser, iTok: int): TLineInfo =
+  result.col = int16(p.col + p.tok[iTok].col)
+  result.line = uint16(p.line + p.tok[iTok].line)
+  result.fileIndex = p.s.currFileIdx
+
+proc lineInfo(p: RstParser): TLineInfo = lineInfo(p, p.idx)
+# TODO: we need this simplification because we don't preserve exact starting
+# token of currently parsed element:
+proc prevLineInfo(p: RstParser): TLineInfo = lineInfo(p, p.idx-1)
+
+proc setSub(p: var RstParser, key: string, value: PRstNode) =
+  var length = p.s.subs.len
+  for i in 0 ..< length:
+    if key == p.s.subs[i].key:
+      p.s.subs[i].value = value
+      return
+  p.s.subs.add(Substitution(key: key, value: value, info: prevLineInfo(p)))
+
+proc setRef(p: var RstParser, key: string, value: PRstNode,
+            refType: SubstitutionKind) =
+  var length = p.s.refs.len
+  for i in 0 ..< length:
+    if key == p.s.refs[i].key:
+      if p.s.refs[i].value.addNodes != value.addNodes:
+        rstMessage(p, mwRedefinitionOfLabel, key)
+      p.s.refs[i].value = value
+      return
+  p.s.refs.add(Substitution(kind: refType, key: key, value: value,
+                            info: prevLineInfo(p)))
+
+proc findRef(s: PRstSharedState, key: string): seq[Substitution] =
+  for i in countup(0, high(s.refs)):
+    if key == s.refs[i].key:
+      result.add s.refs[i]
+
+# Ambiguity in links: we don't follow procedure of removing implicit targets
+# defined in https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#implicit-hyperlink-targets
+# Instead we just give explicit links a higher priority than to implicit ones
+# and report ambiguities as warnings. Hopefully it is easy to remove
+# ambiguities manually. Nim auto-generated links from ``docgen.nim``
+# have lowest priority: 1 (for procs) and below for other symbol types.
+
+proc refPriority(k: SubstitutionKind): int =
+  case k
+  of rstSubstitution: result = 8
+  of hyperlinkAlias: result = 7
+  of implicitHyperlinkAlias: result = 2
+
+proc internalRefPriority(k: RstAnchorKind): int =
+  case k
+  of manualDirectiveAnchor: result = 6
+  of manualInlineAnchor: result = 5
+  of footnoteAnchor: result = 4
+  of headlineAnchor: result = 3
+
+proc `$`(subst: AnchorSubst): string =  # for debug
+  let s =
+    case subst.kind
+    of arInternalRst: "type=" & $subst.anchorType
+    of arExternalRst: "type=" & $subst.anchorTypeExt
+    of arNim: "langsym=" & $subst.langSym
+  result = "(kind=$1, priority=$2, $3)" % [$subst.kind, $subst.priority, s]
+
+proc addAnchorRst(p: var RstParser, name: string, target: PRstNode,
+                  anchorType: RstAnchorKind) =
+  ## Associates node `target` (which has field `anchor`) with an
+  ## alias `name` and updates the corresponding aliases in `p.curAnchors`.
+  let prio = internalRefPriority(anchorType)
+  for a in p.curAnchors:
+    p.s.anchors.mgetOrPut(a.alias, newSeq[AnchorSubst]()).add(
+        AnchorSubst(kind: arInternalRst, target: target, priority: prio,
+                    info: a.info, anchorType: manualDirectiveAnchor))
+  if name != "":
+    p.s.anchors.mgetOrPut(name, newSeq[AnchorSubst]()).add(
+        AnchorSubst(kind: arInternalRst, target: target, priority: prio,
+                    info: prevLineInfo(p), anchorType: anchorType))
+  p.curAnchors.setLen 0
+
+proc addAnchorExtRst(s: var PRstSharedState, key: string, refn: string,
+                  anchorType: RstAnchorKind, info: TLineInfo) =
+  let name = key.toLowerAscii
+  let prio = internalRefPriority(anchorType)
+  s.anchors.mgetOrPut(name, newSeq[AnchorSubst]()).add(
+      AnchorSubst(kind: arExternalRst, refnameExt: refn, priority: prio,
+                  info: info,
+                  anchorTypeExt: anchorType))
+
+proc addAnchorNim*(s: var PRstSharedState, external: bool, refn: string, tooltip: string,
+                   langSym: LangSymbol, priority: int,
+                   info: TLineInfo, module: FileIndex) =
+  ## Adds an anchor `refn`, which follows
+  ## the rule `arNim` (i.e. a symbol in ``*.nim`` file)
+  s.anchors.mgetOrPut(langSym.name, newSeq[AnchorSubst]()).add(
+      AnchorSubst(kind: arNim, external: external, refname: refn, langSym: langSym,
+                  tooltip: tooltip, priority: priority,
+                  info: info))
+
+proc findMainAnchorNim(s: PRstSharedState, signature: PRstNode,
+                       info: TLineInfo):
+                      seq[AnchorSubst] =
+  var langSym: LangSymbol
+  try:
+    langSym = toLangSymbol(signature)
+  except ValueError:  # parsing failed, not a Nim symbol
+    return
+  let substitutions = s.anchors.getOrDefault(langSym.name,
+                                             newSeq[AnchorSubst]())
+  if substitutions.len == 0:
+    return
+  # logic to select only groups instead of concrete symbols
+  # with overloads, note that the same symbol can be defined
+  # in multiple modules and `importdoc`ed:
+  type GroupKey = tuple[symKind: string, origModule: string]
+  # map (symKind, file) (like "proc", "os.nim") -> found symbols/groups:
+  var found: Table[GroupKey, seq[AnchorSubst]]
+  for subst in substitutions:
+    if subst.kind == arNim:
+      if match(subst.langSym, langSym):
+        let key: GroupKey = (subst.langSym.symKind, getModule(s, subst))
+        found.mgetOrPut(key, newSeq[AnchorSubst]()).add subst
+  for key, sList in found:
+    if sList.len == 1:
+      result.add sList[0]
+    else:  # > 1, there are overloads, potential ambiguity in this `symKind`
+      if langSym.parametersProvided:
+        # there are non-group signatures, select only them
+        for s in sList:
+          if not s.langSym.isGroup:
+            result.add s
+      else:  # when there are many overloads a link like foo_ points to all
+             # of them, so selecting the group
+        var foundGroup = false
+        for s in sList:
+          if s.langSym.isGroup:
+            result.add s
+            foundGroup = true
+            break
+        doAssert(foundGroup,
+                 "docgen has not generated the group for $1 (file $2)" % [
+                 langSym.name, getModule(s, sList[0]) ])
+
+proc findMainAnchorRst(s: PRstSharedState, linkText: string, info: TLineInfo):
+                      seq[AnchorSubst] =
+  let name = linkText.toLowerAscii
+  let substitutions = s.anchors.getOrDefault(name, newSeq[AnchorSubst]())
+  for s in substitutions:
+    if s.kind in {arInternalRst, arExternalRst}:
+      result.add s
+
+proc addFootnoteNumManual(p: var RstParser, num: int) =
+  ## add manually-numbered footnote
+  for fnote in p.s.footnotes:
+    if fnote.number == num:
+      rstMessage(p, mwRedefinitionOfLabel, $num)
+      return
+  p.s.footnotes.add((fnManualNumber, num, -1, -1, $num))
+
+proc addFootnoteNumAuto(p: var RstParser, label: string) =
+  ## add auto-numbered footnote.
+  ## Empty label [#] means it'll be resolved by the occurrence.
+  if label == "":  # simple auto-numbered [#]
+    p.s.lineFootnoteNum.add lineInfo(p)
+    p.s.footnotes.add((fnAutoNumber, -1, p.s.lineFootnoteNum.len, -1, label))
+  else:           # auto-numbered with label [#label]
+    for fnote in p.s.footnotes:
+      if fnote.label == label:
+        rstMessage(p, mwRedefinitionOfLabel, label)
+        return
+    p.s.footnotes.add((fnAutoNumberLabel, -1, -1, -1, label))
+
+proc addFootnoteSymAuto(p: var RstParser) =
+  p.s.lineFootnoteSym.add lineInfo(p)
+  p.s.footnotes.add((fnAutoSymbol, -1, -1, p.s.lineFootnoteSym.len, ""))
+
+proc orderFootnotes(s: PRstSharedState) =
+  ## numerate auto-numbered footnotes taking into account that all
+  ## manually numbered ones always have preference.
+  ## Save the result back to `s.footnotes`.
+
+  # Report an error if found any mismatch in number of automatic footnotes
+  proc listFootnotes(locations: seq[TLineInfo]): string =
+    var lines: seq[string]
+    for info in locations:
+      if s.filenames.len > 1:
+        let file = getFilename(s.filenames, info.fileIndex)
+        lines.add file & ":"
+      else:  # no need to add file name here if there is only 1
+        lines.add ""
+      lines[^1].add $info.line
+    result.add $lines.len & " (lines " & join(lines, ", ") & ")"
+  if s.lineFootnoteNum.len != s.lineFootnoteNumRef.len:
+    rstMessage(s, meFootnoteMismatch,
+      "$1 != $2" % [listFootnotes(s.lineFootnoteNum),
+                    listFootnotes(s.lineFootnoteNumRef)] &
+        " for auto-numbered footnotes")
+  if s.lineFootnoteSym.len != s.lineFootnoteSymRef.len:
+    rstMessage(s, meFootnoteMismatch,
+      "$1 != $2" % [listFootnotes(s.lineFootnoteSym),
+                    listFootnotes(s.lineFootnoteSymRef)] &
+        " for auto-symbol footnotes")
+
+  var result: seq[FootnoteSubst]
+  var manuallyN, autoN, autoSymbol: seq[FootnoteSubst]
+  for fs in s.footnotes:
+    if fs.kind == fnManualNumber: manuallyN.add fs
+    elif fs.kind in {fnAutoNumber, fnAutoNumberLabel}: autoN.add fs
+    else: autoSymbol.add fs
+
+  if autoN.len == 0:
+    result = manuallyN
+  else:
+    # fill gaps between manually numbered footnotes in ascending order
+    manuallyN.sort()  # sort by number - its first field
+    var lst = initSinglyLinkedList[FootnoteSubst]()
+    for elem in manuallyN: lst.append(elem)
+    var firstAuto = 0
+    if lst.head == nil or lst.head.value.number != 1:
+      # no manual footnote [1], start numeration from 1 for auto-numbered
+      lst.prepend (autoN[0].kind, 1, autoN[0].autoNumIdx, -1, autoN[0].label)
+      firstAuto = 1
+    var curNode = lst.head
+    var nextNode: SinglyLinkedNode[FootnoteSubst]
+    # go simultaneously through `autoN` and `lst` looking for gaps
+    for (kind, x, autoNumIdx, y, label) in autoN[firstAuto .. ^1]:
+      while (nextNode = curNode.next; nextNode != nil):
+        if nextNode.value.number - curNode.value.number > 1:
+          # gap found, insert new node `n` between curNode and nextNode:
+          var n = newSinglyLinkedNode((kind, curNode.value.number + 1,
+                                       autoNumIdx, -1, label))
+          curNode.next = n
+          n.next = nextNode
+          curNode = n
+          break
+        else:
+          curNode = nextNode
+      if nextNode == nil:  # no gap found, just append
+        lst.append (kind, curNode.value.number + 1, autoNumIdx, -1, label)
+        curNode = lst.tail
+    result = lst.toSeq
+
+  # we use ASCII symbols instead of those recommended in RST specification:
+  const footnoteAutoSymbols = ["*", "^", "+", "=", "~", "$", "@", "%", "&"]
+  for fs in autoSymbol:
+    # assignment order: *, **, ***, ^, ^^, ^^^, ... &&&, ****, *****, ...
+    let i = fs.autoSymIdx - 1
+    let symbolNum = (i div 3) mod footnoteAutoSymbols.len
+    let nSymbols = (1 + i mod 3) + 3 * (i div (3 * footnoteAutoSymbols.len))
+    let label = footnoteAutoSymbols[symbolNum].repeat(nSymbols)
+    result.add((fs.kind, -1, -1, fs.autoSymIdx, label))
+
+  s.footnotes = result
+
+proc getFootnoteNum(s: PRstSharedState, label: string): int =
+  ## get number from label. Must be called after `orderFootnotes`.
+  result = -1
+  for fnote in s.footnotes:
+    if fnote.label == label:
+      return fnote.number
+
+proc getFootnoteNum(s: PRstSharedState, order: int): int =
+  ## get number from occurrence. Must be called after `orderFootnotes`.
+  result = -1
+  for fnote in s.footnotes:
+    if fnote.autoNumIdx == order:
+      return fnote.number
+
+proc getAutoSymbol(s: PRstSharedState, order: int): string =
+  ## get symbol from occurrence of auto-symbol footnote.
+  result = "???"
+  for fnote in s.footnotes:
+    if fnote.autoSymIdx == order:
+      return fnote.label
+
+proc newRstNodeA(p: var RstParser, kind: RstNodeKind): PRstNode =
+  ## create node and consume the current anchor
+  result = newRstNode(kind)
+  if p.curAnchors.len > 0:
+    result.anchor = p.curAnchors[0].anchor
+    addAnchorRst(p, "", result, manualDirectiveAnchor)
+
+template newLeaf(s: string): PRstNode = newRstLeaf(s)
+
+proc newLeaf(p: var RstParser): PRstNode =
+  result = newLeaf(currentTok(p).symbol)
+
+proc validRefnamePunct(x: string): bool =
+  ## https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#reference-names
+  x.len == 1 and x[0] in {'-', '_', '.', ':', '+'}
+
+func getRefnameIdx(p: RstParser, startIdx: int): int =
+  ## Gets last token index of a refname ("word" in RST terminology):
+  ##
+  ##   reference names are single words consisting of alphanumerics plus
+  ##   isolated (no two adjacent) internal hyphens, underscores, periods,
+  ##   colons and plus signs; no whitespace or other characters are allowed.
+  ##
+  ## Refnames are used for:
+  ## - reference names
+  ## - role names
+  ## - directive names
+  ## - footnote labels
+  ##
+  # TODO: use this func in all other relevant places
+  var j = startIdx
+  if p.tok[j].kind == tkWord:
+    inc j
+    while p.tok[j].kind == tkPunct and validRefnamePunct(p.tok[j].symbol) and
+        p.tok[j+1].kind == tkWord:
+      inc j, 2
+  result = j - 1
+
+func getRefname(p: RstParser, startIdx: int): (string, int) =
+  let lastIdx = getRefnameIdx(p, startIdx)
+  result[1] = lastIdx
+  for j in startIdx..lastIdx:
+    result[0].add p.tok[j].symbol
+
+proc getReferenceName(p: var RstParser, endStr: string): PRstNode =
+  var res = newRstNode(rnInner)
+  while true:
+    case currentTok(p).kind
+    of tkWord, tkOther, tkWhite:
+      res.add(newLeaf(p))
+    of tkPunct:
+      if currentTok(p).symbol == endStr:
+        inc p.idx
+        break
+      else:
+        res.add(newLeaf(p))
+    else:
+      rstMessage(p, meExpected, endStr)
+      break
+    inc p.idx
+  result = res
+
+proc untilEol(p: var RstParser): PRstNode =
+  result = newRstNode(rnInner)
+  while currentTok(p).kind notin {tkIndent, tkEof}:
+    result.add(newLeaf(p))
+    inc p.idx
+
+proc expect(p: var RstParser, tok: string) =
+  if currentTok(p).symbol == tok: inc p.idx
+  else: rstMessage(p, meExpected, tok)
+
+proc inlineMarkdownEnd(p: RstParser): bool =
+  result = prevTok(p).kind notin {tkIndent, tkWhite}
+  ## (For a special case of ` we don't allow spaces surrounding it
+  ## unlike original Markdown because this behavior confusing/useless)
+
+proc inlineRstEnd(p: RstParser): bool =
+  # rst rules: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+  # Rule 2:
+  result = prevTok(p).kind notin {tkIndent, tkWhite}
+  if not result: return
+  # Rule 7:
+  result = nextTok(p).kind in {tkIndent, tkWhite, tkEof} or
+      nextTok(p).symbol[0] in
+      {'\'', '\"', ')', ']', '}', '>', '-', '/', '\\', ':', '.', ',', ';', '!', '?', '_'}
+
+proc isInlineMarkupEnd(p: RstParser, markup: string, exact: bool): bool =
+  if exact:
+    result = currentTok(p).symbol == markup
+  else:
+    result = currentTok(p).symbol.endsWith markup
+    if (not result) and markup == "``":
+      # check that escaping may have splitted `` to 2 tokens ` and `
+      result = currentTok(p).symbol == "`" and prevTok(p).symbol == "`"
+  if not result: return
+  # surroundings check
+  if markup in ["_", "__"]:
+    result = inlineRstEnd(p)
+  else:
+    if roPreferMarkdown in p.s.options: result = inlineMarkdownEnd(p)
+    else: result = inlineRstEnd(p)
+
+proc rstRuleSurround(p: RstParser): bool =
+  result = true
+  # Rules 4 & 5:
+  if p.idx > 0:
+    var d: char
+    var c = prevTok(p).symbol[0]
+    case c
+    of '\'', '\"': d = c
+    of '(': d = ')'
+    of '[': d = ']'
+    of '{': d = '}'
+    of '<': d = '>'
+    else: d = '\0'
+    if d != '\0': result = nextTok(p).symbol[0] != d
+
+proc inlineMarkdownStart(p: RstParser): bool =
+  result = nextTok(p).kind notin {tkIndent, tkWhite, tkEof}
+  if not result: return
+  # this rst rule is really nice, let us use it in Markdown mode too.
+  result = rstRuleSurround(p)
+
+proc inlineRstStart(p: RstParser): bool =
+  ## rst rules: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+  # Rule 6
+  result = p.idx == 0 or prevTok(p).kind in {tkIndent, tkWhite} or
+      prevTok(p).symbol[0] in {'\'', '\"', '(', '[', '{', '<', '-', '/', ':', '_'}
+  if not result: return
+  # Rule 1:
+  result = nextTok(p).kind notin {tkIndent, tkWhite, tkEof}
+  if not result: return
+  result = rstRuleSurround(p)
+
+proc isInlineMarkupStart(p: RstParser, markup: string): bool =
+  if markup != "_`":
+    result = currentTok(p).symbol == markup
+  else:  # _` is a 2 token case
+    result = currentTok(p).symbol == "_" and nextTok(p).symbol == "`"
+  if not result: return
+  # surroundings check
+  if markup in ["_", "__", "[", "|"]:
+    # Note: we require space/punctuation even before [markdown link](...)
+    result = inlineRstStart(p)
+  else:
+    if roPreferMarkdown in p.s.options: result = inlineMarkdownStart(p)
+    else: result = inlineRstStart(p)
+
+proc match(p: RstParser, start: int, expr: string): bool =
+  # regular expressions are:
+  # special char     exact match
+  # 'w'              tkWord
+  # ' '              tkWhite
+  # 'a'              tkAdornment
+  # 'i'              tkIndent
+  # 'I'              tkIndent or tkEof
+  # 'p'              tkPunct
+  # 'T'              always true
+  # 'E'              whitespace, indent or eof
+  # 'e'              any enumeration sequence or '#' (for enumeration lists)
+  # 'x'              a..z or '#' (for enumeration lists)
+  # 'n'              0..9 or '#' (for enumeration lists)
+  var i = 0
+  var j = start
+  var last = expr.len - 1
+  while i <= last:
+    case expr[i]
+    of 'w':
+      let lastIdx = getRefnameIdx(p, j)
+      result = lastIdx >= j
+      if result: j = lastIdx
+    of ' ': result = p.tok[j].kind == tkWhite
+    of 'i': result = p.tok[j].kind == tkIndent
+    of 'I': result = p.tok[j].kind in {tkIndent, tkEof}
+    of 'p': result = p.tok[j].kind == tkPunct
+    of 'a': result = p.tok[j].kind == tkAdornment
+    of 'o': result = p.tok[j].kind == tkOther
+    of 'T': result = true
+    of 'E': result = p.tok[j].kind in {tkEof, tkWhite, tkIndent}
+    of 'e', 'x', 'n':
+      result = p.tok[j].kind == tkWord or p.tok[j].symbol == "#"
+      if result:
+        case p.tok[j].symbol[0]
+        of '#': result = true
+        of 'a'..'z', 'A'..'Z':
+          result = expr[i] in {'e', 'x'} and p.tok[j].symbol.len == 1
+        of '0'..'9':
+          result = expr[i] in {'e', 'n'} and
+                     allCharsInSet(p.tok[j].symbol, {'0'..'9'})
+        else: result = false
+    else:
+      var c = expr[i]
+      var length = 0
+      while i <= last and expr[i] == c:
+        inc i
+        inc length
+      dec i
+      result = p.tok[j].kind in {tkPunct, tkAdornment} and
+          p.tok[j].symbol.len == length and p.tok[j].symbol[0] == c
+    if not result: return
+    inc j
+    inc i
+  result = true
+
+proc safeProtocol*(linkStr: var string): string =
+  # Returns link's protocol and, if it's not safe, clears `linkStr`
+  result = ""
+  if scanf(linkStr, "$w:", result):
+    # if it has a protocol at all, ensure that it's not 'javascript:' or worse:
+    if cmpIgnoreCase(result, "http") == 0 or
+        cmpIgnoreCase(result, "https") == 0 or
+        cmpIgnoreCase(result, "ftp") == 0:
+      discard "it's fine"
+    else:
+      linkStr = ""
+
+proc fixupEmbeddedRef(p: var RstParser, n, a, b: PRstNode): bool =
+  # Returns `true` if the link belongs to an allowed protocol
+  var sep = - 1
+  for i in countdown(n.len - 2, 0):
+    if n.sons[i].text == "<":
+      sep = i
+      break
+  var incr = if sep > 0 and n.sons[sep - 1].text[0] == ' ': 2 else: 1
+  for i in countup(0, sep - incr): a.add(n.sons[i])
+  var linkStr = ""
+  for i in countup(sep + 1, n.len - 2): linkStr.add(n.sons[i].addNodes)
+  if linkStr != "":
+    let protocol = safeProtocol(linkStr)
+    result = linkStr != ""
+    if not result:
+      rstMessage(p, mwBrokenLink, protocol,
+                 p.tok[p.idx-3].line, p.tok[p.idx-3].col)
+  b.add newLeaf(linkStr)
+
+proc whichRole(p: RstParser, sym: string): RstNodeKind =
+  result = whichRoleAux(sym)
+  if result == rnUnknownRole:
+    rstMessage(p, mwUnsupportedLanguage, sym)
+
+proc toInlineCode(n: PRstNode, language: string): PRstNode =
+  ## Creates rnInlineCode and attaches `n` contents as code (in 3rd son).
+  result = newRstNode(rnInlineCode, info=n.info)
+  let args = newRstNode(rnDirArg)
+  var lang = language
+  if language == "cpp": lang = "c++"
+  elif language == "csharp": lang = "c#"
+  args.add newLeaf(lang)
+  result.add args
+  result.add PRstNode(nil)
+  var lb = newRstNode(rnLiteralBlock)
+  var s: string
+  for i in n.sons:
+    assert i.kind == rnLeaf
+    s.add i.text
+  lb.add newLeaf(s)
+  result.add lb
+
+proc toOtherRole(n: PRstNode, kind: RstNodeKind, roleName: string): PRstNode =
+  let newN = newRstNode(rnInner, n.sons)
+  let newSons = @[newN, newLeaf(roleName)]
+  result = newRstNode(kind, newSons)
+
+proc parsePostfix(p: var RstParser, n: PRstNode): PRstNode =
+  ## Finalizes node `n` that was tentatively determined as interpreted text.
+  var newKind = n.kind
+  var newSons = n.sons
+
+  proc finalizeInterpreted(node: PRstNode, newKind: RstNodeKind,
+                           newSons: seq[PRstNode], roleName: string):
+                          PRstNode {.nimcall.} =
+    # fixes interpreted text (`x` or `y`:role:) to proper internal AST format
+    if newKind in {rnUnknownRole, rnCodeFragment}:
+      result = node.toOtherRole(newKind, roleName)
+    elif newKind == rnInlineCode:
+      result = node.toInlineCode(language=roleName)
+    else:
+      result = newRstNode(newKind, newSons)
+
+  if isInlineMarkupEnd(p, "_", exact=true) or
+      isInlineMarkupEnd(p, "__", exact=true):
+    inc p.idx
+    if p.tok[p.idx-2].symbol == "`" and p.tok[p.idx-3].symbol == ">":
+      var a = newRstNode(rnInner)
+      var b = newRstNode(rnInner)
+      if fixupEmbeddedRef(p, n, a, b):
+        if a.len == 0:  # e.g. `<a_named_relative_link>`_
+          newKind = rnStandaloneHyperlink
+          newSons = @[b]
+        else:  # e.g. `link title <http://site>`_
+          newKind = rnHyperlink
+          newSons = @[a, b]
+          setRef(p, rstnodeToRefname(a), b, implicitHyperlinkAlias)
+      else:  # include as plain text, not a link
+        newKind = rnInner
+        newSons = n.sons
+      result = newRstNode(newKind, newSons)
+    else:  # some link that will be resolved in `resolveSubs`
+      newKind = rnRstRef
+      result = newRstNode(newKind, sons=newSons, info=n.info)
+  elif match(p, p.idx, ":w:"):
+    # a role:
+    let (roleName, lastIdx) = getRefname(p, p.idx+1)
+    newKind = whichRole(p, roleName)
+    result = n.finalizeInterpreted(newKind, newSons, roleName)
+    p.idx = lastIdx + 2
+  else:
+    result = n.finalizeInterpreted(p.s.currRoleKind, newSons, p.s.currRole)
+
+proc matchVerbatim(p: RstParser, start: int, expr: string): int =
+  result = start
+  var j = 0
+  while j < expr.len and result < p.tok.len and
+        continuesWith(expr, p.tok[result].symbol, j):
+    inc j, p.tok[result].symbol.len
+    inc result
+  if j < expr.len: result = 0
+
+proc parseSmiley(p: var RstParser): PRstNode =
+  if currentTok(p).symbol[0] notin SmileyStartChars: return
+  for key, val in items(Smilies):
+    let m = matchVerbatim(p, p.idx, key)
+    if m > 0:
+      p.idx = m
+      result = newRstNode(rnSmiley)
+      result.text = val
+      return
+
+proc isUrl(p: RstParser, i: int): bool =
+  result = p.tok[i+1].symbol == ":" and p.tok[i+2].symbol == "//" and
+    p.tok[i+3].kind == tkWord and
+    p.tok[i].symbol in ["http", "https", "ftp", "telnet", "file"]
+
+proc checkParen(token: Token, parensStack: var seq[char]): bool {.inline.} =
+  ## Returns `true` iff `token` is a closing parenthesis for some
+  ## previous opening parenthesis saved in `parensStack`.
+  ## This is according Markdown balanced parentheses rule
+  ## (https://spec.commonmark.org/0.29/#link-destination)
+  ## to allow links like
+  ## https://en.wikipedia.org/wiki/APL_(programming_language),
+  ## we use it for RST also.
+  result = false
+  if token.kind == tkPunct:
+    let c = token.symbol[0]
+    if c in {'(', '[', '{'}:  # push
+      parensStack.add c
+    elif c in {')', ']', '}'}:  # try pop
+      # a case like ([) inside a link is allowed and [ is also `pop`ed:
+      for i in countdown(parensStack.len - 1, 0):
+        if (parensStack[i] == '(' and c == ')' or
+            parensStack[i] == '[' and c == ']' or
+            parensStack[i] == '{' and c == '}'):
+          parensStack.setLen i
+          result = true
+          break
+
+proc parseUrl(p: var RstParser): PRstNode =
+  ## https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#standalone-hyperlinks
+  result = newRstNode(rnStandaloneHyperlink)
+  var lastIdx = p.idx
+  var closedParenIdx = p.idx - 1  # for balanced parens rule
+  var parensStack: seq[char]
+  while p.tok[lastIdx].kind in {tkWord, tkPunct, tkOther}:
+    let isClosing = checkParen(p.tok[lastIdx], parensStack)
+    if isClosing:
+      closedParenIdx = lastIdx
+    inc lastIdx
+  dec lastIdx
+  # standalone URL can not end with punctuation in RST
+  while lastIdx > closedParenIdx and p.tok[lastIdx].kind == tkPunct and
+      p.tok[lastIdx].symbol != "/":
+    dec lastIdx
+  var s = ""
+  for i in p.idx .. lastIdx: s.add p.tok[i].symbol
+  result.add s
+  p.idx = lastIdx + 1
+
+proc parseWordOrRef(p: var RstParser, father: PRstNode) =
+  ## Parses a normal word or may be a reference or URL.
+  if nextTok(p).kind != tkPunct:  # <- main path, a normal word
+    father.add newLeaf(p)
+    inc p.idx
+  elif isUrl(p, p.idx):           # URL http://something
+    father.add parseUrl(p)
+  else:
+    # check for reference (probably, long one like some.ref.with.dots_ )
+    var saveIdx = p.idx
+    var reference: PRstNode = nil
+    inc p.idx
+    while currentTok(p).kind in {tkWord, tkPunct}:
+      if currentTok(p).kind == tkPunct:
+        if isInlineMarkupEnd(p, "_", exact=true):
+          reference = newRstNode(rnRstRef, info=lineInfo(p, saveIdx))
+          break
+        if not validRefnamePunct(currentTok(p).symbol):
+          break
+      inc p.idx
+    if reference != nil:
+      for i in saveIdx..p.idx-1: reference.add newLeaf(p.tok[i].symbol)
+      father.add reference
+      inc p.idx  # skip final _
+    else:  # 1 normal word
+      father.add newLeaf(p.tok[saveIdx].symbol)
+      p.idx = saveIdx + 1
+
+proc parseBackslash(p: var RstParser, father: PRstNode) =
+  assert(currentTok(p).kind == tkPunct)
+  if currentTok(p).symbol == "\\":
+    # XXX: Unicode?
+    inc p.idx
+    if currentTok(p).kind != tkWhite: father.add(newLeaf(p))
+    if currentTok(p).kind != tkEof: inc p.idx
+  else:
+    father.add(newLeaf(p))
+    inc p.idx
+
+proc parseUntil(p: var RstParser, father: PRstNode, postfix: string,
+                interpretBackslash: bool) =
+  let
+    line = currentTok(p).line
+    col = currentTok(p).col
+  inc p.idx
+  while true:
+    case currentTok(p).kind
+    of tkPunct:
+      if isInlineMarkupEnd(p, postfix, exact=false):
+        let l = currentTok(p).symbol.len
+        if l > postfix.len:
+          # handle cases like *emphasis with stars****. (It's valid RST!)
+          father.add newLeaf(currentTok(p).symbol[0 ..< l - postfix.len])
+        elif postfix == "``" and currentTok(p).symbol == "`" and
+            prevTok(p).symbol == "`":
+          # handle cases like ``literal\`` - delete ` already added after \
+          father.sons.setLen(father.sons.len - 1)
+        inc p.idx
+        break
+      else:
+        if postfix == "`":
+          if currentTok(p).symbol == "\\":
+            if nextTok(p).symbol == "\\":
+              father.add newLeaf("\\")
+              father.add newLeaf("\\")
+              inc p.idx, 2
+            elif nextTok(p).symbol == "`":  # escape `
+              father.add newLeaf("`")
+              inc p.idx, 2
+            else:
+              father.add newLeaf("\\")
+              inc p.idx
+          else:
+            father.add(newLeaf(p))
+            inc p.idx
+        else:
+          if interpretBackslash:
+            parseBackslash(p, father)
+          else:
+            father.add(newLeaf(p))
+            inc p.idx
+    of tkAdornment, tkWord, tkOther:
+      father.add(newLeaf(p))
+      inc p.idx
+    of tkIndent:
+      father.add newLeaf(" ")
+      inc p.idx
+      if currentTok(p).kind == tkIndent:
+        rstMessage(p, meExpected, postfix, line, col)
+        break
+    of tkWhite:
+      father.add newLeaf(" ")
+      inc p.idx
+    else: rstMessage(p, meExpected, postfix, line, col)
+
+proc parseMarkdownCodeblockFields(p: var RstParser): PRstNode =
+  ## Parses additional (after language string) code block parameters
+  ## in a format *suggested* in the `CommonMark Spec`_ with handling of `"`.
+  if currentTok(p).kind == tkIndent:
+    result = nil
+  else:
+    result = newRstNode(rnFieldList)
+  while currentTok(p).kind notin {tkIndent, tkEof}:
+    if currentTok(p).kind == tkWhite:
+      inc p.idx
+    else:
+      let field = newRstNode(rnField)
+      var fieldName = ""
+      while currentTok(p).kind notin {tkWhite, tkIndent, tkEof} and
+            currentTok(p).symbol != "=":
+        fieldName.add currentTok(p).symbol
+        inc p.idx
+      field.add(newRstNode(rnFieldName, @[newLeaf(fieldName)]))
+      if currentTok(p).kind == tkWhite: inc p.idx
+      let fieldBody = newRstNode(rnFieldBody)
+      if currentTok(p).symbol == "=":
+        inc p.idx
+        if currentTok(p).kind == tkWhite: inc p.idx
+        var fieldValue = ""
+        if currentTok(p).symbol == "\"":
+          while true:
+            fieldValue.add currentTok(p).symbol
+            inc p.idx
+            if currentTok(p).kind == tkEof:
+              rstMessage(p, meExpected, "\"")
+            elif currentTok(p).symbol == "\"":
+              fieldValue.add "\""
+              inc p.idx
+              break
+        else:
+          while currentTok(p).kind notin {tkWhite, tkIndent, tkEof}:
+            fieldValue.add currentTok(p).symbol
+            inc p.idx
+        fieldBody.add newLeaf(fieldValue)
+      field.add(fieldBody)
+      result.add(field)
+
+proc mayLoadFile(p: RstParser, result: var PRstNode) =
+  var filename = strip(getFieldValue(result, "file"),
+                       chars = Whitespace + {'"'})
+  if filename != "":
+    if roSandboxDisabled notin p.s.options:
+      let tok = p.tok[p.idx-2]
+      rstMessage(p, meSandboxedDirective, "file", tok.line, tok.col)
+    var path = p.findRelativeFile(filename)
+    if path == "": rstMessage(p, meCannotOpenFile, filename)
+    var n = newRstNode(rnLiteralBlock)
+    n.add newLeaf(readFile(path))
+    result.sons[2] = n
+
+proc defaultCodeLangNim(p: RstParser, result: var PRstNode) =
+  # Create a field block if the input block didn't have any.
+  if result.sons[1].isNil: result.sons[1] = newRstNode(rnFieldList)
+  assert result.sons[1].kind == rnFieldList
+  # Hook the extra field and specify the Nim language as value.
+  var extraNode = newRstNode(rnField, info=lineInfo(p))
+  extraNode.add(newRstNode(rnFieldName))
+  extraNode.add(newRstNode(rnFieldBody))
+  extraNode.sons[0].add newLeaf("default-language")
+  extraNode.sons[1].add newLeaf("Nim")
+  result.sons[1].add(extraNode)
+
+proc parseMarkdownCodeblock(p: var RstParser): PRstNode =
+  result = newRstNodeA(p, rnCodeBlock)
+  result.sons.setLen(3)
+  let line = curLine(p)
+  let baseCol = currentTok(p).col
+  let baseSym = currentTok(p).symbol  # usually just ```
+  inc p.idx
+  result.info = lineInfo(p)
+  var args = newRstNode(rnDirArg)
+  if currentTok(p).kind == tkWord:
+    args.add(newLeaf(p))
+    inc p.idx
+    result.sons[1] = parseMarkdownCodeblockFields(p)
+    mayLoadFile(p, result)
+  else:
+    args = nil
+  var n = newLeaf("")
+  var isFirstLine = true
+  while true:
+    if currentTok(p).kind == tkEof:
+      rstMessage(p, meMissingClosing,
+                 "$1 (started at line $2)" % [baseSym, $line])
+      break
+    elif nextTok(p).kind in {tkPunct, tkAdornment} and
+         nextTok(p).symbol[0] == baseSym[0] and
+         nextTok(p).symbol.len >= baseSym.len:
+      inc p.idx, 2
+      break
+    elif currentTok(p).kind == tkIndent:
+      if not isFirstLine:
+        n.text.add "\n"
+      if currentTok(p).ival > baseCol:
+        n.text.add " ".repeat(currentTok(p).ival - baseCol)
+      elif currentTok(p).ival < baseCol:
+        rstMessage(p, mwRstStyle,
+                   "unexpected de-indentation in Markdown code block")
+      inc p.idx
+    else:
+      n.text.add(currentTok(p).symbol)
+      inc p.idx
+    isFirstLine = false
+  result.sons[0] = args
+  if result.sons[2] == nil:
+    var lb = newRstNode(rnLiteralBlock)
+    lb.add(n)
+    result.sons[2] = lb
+  if result.sons[0].isNil and roNimFile in p.s.options:
+    defaultCodeLangNim(p, result)
+
+proc parseMarkdownLink(p: var RstParser; father: PRstNode): bool =
+  # Parses Markdown link. If it's Pandoc auto-link then its second
+  # son (target) will be in tokenized format (rnInner with leafs).
+  var desc = newRstNode(rnInner)
+  var i = p.idx
+
+  var parensStack: seq[char]
+  template parse(endToken, dest) =
+    parensStack.setLen 0
+    inc i # skip begin token
+    while true:
+      if p.tok[i].kind == tkEof: return false
+      if p.tok[i].kind == tkIndent and p.tok[i+1].kind == tkIndent:
+        return false
+      let isClosing = checkParen(p.tok[i], parensStack)
+      if p.tok[i].symbol == endToken and not isClosing:
+        break
+      let symbol = if p.tok[i].kind == tkIndent: " " else: p.tok[i].symbol
+      when dest is string: dest.add symbol
+      else: dest.add newLeaf(symbol)
+      inc i
+    inc i # skip end token
+
+  parse("]", desc)
+  if p.tok[i].symbol == "(":
+    var link = ""
+    let linkIdx = i + 1
+    parse(")", link)
+    # only commit if we detected no syntax error:
+    let protocol = safeProtocol(link)
+    if link == "":
+      result = false
+      rstMessage(p, mwBrokenLink, protocol,
+                 p.tok[linkIdx].line, p.tok[linkIdx].col)
+    else:
+      let child = newRstNode(rnHyperlink)
+      child.add newLeaf(desc.addNodes)
+      child.add link
+      father.add child
+      p.idx = i
+      result = true
+  elif roPreferMarkdown in p.s.options:
+    # Use Pandoc's implicit_header_references extension
+    var n = newRstNode(rnPandocRef)
+    if p.tok[i].symbol == "[":
+      var link = newRstNode(rnInner)
+      let targetIdx = i + 1
+      parse("]", link)
+      n.add desc
+      if link.len != 0:  # [description][target]
+        n.add link
+        n.info = lineInfo(p, targetIdx)
+      else:              # [description=target][]
+        n.add desc
+        n.info = lineInfo(p, p.idx + 1)
+    else:                # [description=target]
+      n.add desc
+      n.add desc  # target is the same as description
+      n.info = lineInfo(p, p.idx + 1)
+    father.add n
+    p.idx = i
+    result = true
+  else:
+    result = false
+
+proc getRstFootnoteType(label: PRstNode): (FootnoteType, int) =
+  if label.sons.len >= 1 and label.sons[0].kind == rnLeaf and
+      label.sons[0].text == "#":
+    if label.sons.len == 1:
+      result = (fnAutoNumber, -1)
+    else:
+      result = (fnAutoNumberLabel, -1)
+  elif label.len == 1 and label.sons[0].kind == rnLeaf and
+       label.sons[0].text == "*":
+    result = (fnAutoSymbol, -1)
+  elif label.len == 1 and label.sons[0].kind == rnLeaf:
+    try:
+      result = (fnManualNumber, parseInt(label.sons[0].text))
+    except ValueError:
+      result = (fnCitation, -1)
+  else:
+    result = (fnCitation, -1)
+
+proc getMdFootnoteType(label: PRstNode): (FootnoteType, int) =
+  try:
+    result = (fnManualNumber, parseInt(label.sons[0].text))
+  except ValueError:
+    result = (fnAutoNumberLabel, -1)
+
+proc getFootnoteType(s: PRstSharedState, label: PRstNode): (FootnoteType, int) =
+  ## Returns footnote/citation type and manual number (if present).
+  if isMd(s): getMdFootnoteType(label)
+  else: getRstFootnoteType(label)
+
+proc parseRstFootnoteName(p: var RstParser, reference: bool): PRstNode =
+  ## parse footnote/citation label. Precondition: start at `[`.
+  ## Label text should be valid ref. name symbol, otherwise nil is returned.
+  var i = p.idx + 1
+  result = newRstNode(rnInner)
+  while true:
+    if p.tok[i].kind in {tkEof, tkIndent, tkWhite}:
+      return nil
+    if p.tok[i].kind == tkPunct:
+      case p.tok[i].symbol:
+      of "]":
+        if i > p.idx + 1 and (not reference or (p.tok[i+1].kind == tkPunct and p.tok[i+1].symbol == "_")):
+          inc i                # skip ]
+          if reference: inc i  # skip _
+          break  # to succeed, it's a footnote/citation indeed
+        else:
+          return nil
+      of "#":
+        if i != p.idx + 1:
+          return nil
+      of "*":
+        if i != p.idx + 1 and p.tok[i].kind != tkPunct and p.tok[i+1].symbol != "]":
+          return nil
+      else:
+        if not validRefnamePunct(p.tok[i].symbol):
+          return nil
+    result.add newLeaf(p.tok[i].symbol)
+    inc i
+  p.idx = i
+
+proc isMdFootnoteName(p: RstParser, reference: bool): bool =
+  ## Pandoc Markdown footnote extension.
+  let j = p.idx
+  result = p.tok[j].symbol == "[" and p.tok[j+1].symbol == "^" and
+           p.tok[j+2].kind == tkWord
+
+proc parseMdFootnoteName(p: var RstParser, reference: bool): PRstNode =
+  if isMdFootnoteName(p, reference):
+    result = newRstNode(rnInner)
+    var j = p.idx + 2
+    while p.tok[j].kind in {tkWord, tkOther} or
+        validRefnamePunct(p.tok[j].symbol):
+      result.add newLeaf(p.tok[j].symbol)
+      inc j
+    if j == p.idx + 2:
+      return nil
+    if p.tok[j].symbol == "]":
+      if reference:
+        p.idx = j + 1  # skip ]
+      else:
+        if p.tok[j+1].symbol == ":":
+          p.idx = j + 2  # skip ]:
+        else:
+          result = nil
+    else:
+      result = nil
+  else:
+    result = nil
+
+proc parseFootnoteName(p: var RstParser, reference: bool): PRstNode =
+  if isMd(p): parseMdFootnoteName(p, reference)
+  else:
+    if isInlineMarkupStart(p, "["): parseRstFootnoteName(p, reference)
+    else: nil
+
+proc isMarkdownCodeBlock(p: RstParser, idx: int): bool =
+  let tok = p.tok[idx]
+  template allowedSymbol: bool =
+    (tok.symbol[0] == '`' or
+      roPreferMarkdown in p.s.options and tok.symbol[0] == '~')
+  result = (roSupportMarkdown in p.s.options and
+            tok.kind in {tkPunct, tkAdornment} and
+            allowedSymbol and
+            tok.symbol.len >= 3)
+
+proc isMarkdownCodeBlock(p: RstParser): bool =
+  isMarkdownCodeBlock(p, p.idx)
+
+proc parseInline(p: var RstParser, father: PRstNode) =
+  var n: PRstNode  # to be used in `if` condition
+  let saveIdx = p.idx
+  case currentTok(p).kind
+  of tkPunct:
+    if isInlineMarkupStart(p, "***"):
+      var n = newRstNode(rnTripleEmphasis)
+      parseUntil(p, n, "***", true)
+      father.add(n)
+    elif isInlineMarkupStart(p, "**"):
+      var n = newRstNode(rnStrongEmphasis)
+      parseUntil(p, n, "**", true)
+      father.add(n)
+    elif isInlineMarkupStart(p, "*"):
+      var n = newRstNode(rnEmphasis)
+      parseUntil(p, n, "*", true)
+      father.add(n)
+    elif isInlineMarkupStart(p, "_`"):
+      var n = newRstNode(rnInlineTarget)
+      inc p.idx
+      parseUntil(p, n, "`", false)
+      n.anchor = rstnodeToRefname(n)
+      addAnchorRst(p, name = linkName(n), target = n,
+                   anchorType=manualInlineAnchor)
+      father.add(n)
+    elif isMarkdownCodeBlock(p):
+      father.add(parseMarkdownCodeblock(p))
+    elif isInlineMarkupStart(p, "``"):
+      var n = newRstNode(rnInlineLiteral)
+      parseUntil(p, n, "``", false)
+      father.add(n)
+    elif match(p, p.idx, ":w:") and
+        (var lastIdx = getRefnameIdx(p, p.idx + 1);
+         p.tok[lastIdx+2].symbol == "`"):
+      let (roleName, _) = getRefname(p, p.idx+1)
+      let k = whichRole(p, roleName)
+      var n = newRstNode(k)
+      p.idx = lastIdx + 2
+      if k == rnInlineCode:
+        n = n.toInlineCode(language=roleName)
+      parseUntil(p, n, "`", false) # bug #17260
+      if k in {rnUnknownRole, rnCodeFragment}:
+        n = n.toOtherRole(k, roleName)
+      father.add(n)
+    elif isInlineMarkupStart(p, "`"):
+      var n = newRstNode(rnInterpretedText, info=lineInfo(p, p.idx+1))
+      parseUntil(p, n, "`", false) # bug #17260
+      n = parsePostfix(p, n)
+      father.add(n)
+    elif isInlineMarkupStart(p, "|"):
+      var n = newRstNode(rnSubstitutionReferences, info=lineInfo(p, p.idx+1))
+      parseUntil(p, n, "|", false)
+      father.add(n)
+    elif currentTok(p).symbol == "[" and nextTok(p).symbol != "[" and
+         (n = parseFootnoteName(p, reference=true); n != nil):
+      var nn = newRstNode(rnFootnoteRef)
+      nn.info = lineInfo(p, saveIdx+1)
+      nn.add n
+      let (fnType, _) = getFootnoteType(p.s, n)
+      case fnType
+      of fnAutoSymbol:
+        p.s.lineFootnoteSymRef.add lineInfo(p)
+      of fnAutoNumber:
+        p.s.lineFootnoteNumRef.add lineInfo(p)
+      else: discard
+      father.add(nn)
+    elif roSupportMarkdown in p.s.options and
+        currentTok(p).symbol == "[" and nextTok(p).symbol != "[" and
+        parseMarkdownLink(p, father):
+      discard "parseMarkdownLink already processed it"
+    else:
+      if roSupportSmilies in p.s.options:
+        let n = parseSmiley(p)
+        if n != nil:
+          father.add(n)
+          return
+      parseBackslash(p, father)
+  of tkWord:
+    if roSupportSmilies in p.s.options:
+      let n = parseSmiley(p)
+      if n != nil:
+        father.add(n)
+        return
+    parseWordOrRef(p, father)
+  of tkAdornment, tkOther, tkWhite:
+    if isMarkdownCodeBlock(p):
+      father.add(parseMarkdownCodeblock(p))
+      return
+    if roSupportSmilies in p.s.options:
+      let n = parseSmiley(p)
+      if n != nil:
+        father.add(n)
+        return
+    father.add(newLeaf(p))
+    inc p.idx
+  else: discard
+
+proc getDirective(p: var RstParser): string =
+  result = ""
+  if currentTok(p).kind == tkWhite:
+    let (name, lastIdx) = getRefname(p, p.idx + 1)
+    let afterIdx = lastIdx + 1
+    if name.len > 0:
+      if p.tok[afterIdx].symbol == "::":
+        result = name
+        p.idx = afterIdx + 1
+        if currentTok(p).kind == tkWhite:
+          inc p.idx
+        elif currentTok(p).kind != tkIndent:
+          rstMessage(p, mwRstStyle,
+              "whitespace or newline expected after directive " & name)
+        result = result.toLowerAscii()
+      elif p.tok[afterIdx].symbol == ":":
+        rstMessage(p, mwRstStyle,
+            "double colon :: may be missing at end of '" & name & "'",
+            p.tok[afterIdx].line, p.tok[afterIdx].col)
+      elif p.tok[afterIdx].kind == tkPunct and p.tok[afterIdx].symbol[0] == ':':
+        rstMessage(p, mwRstStyle,
+            "too many colons for a directive (should be ::)",
+            p.tok[afterIdx].line, p.tok[afterIdx].col)
+
+proc parseComment(p: var RstParser, col: int): PRstNode =
+  if currentTok(p).kind != tkEof and nextTok(p).kind == tkIndent:
+    inc p.idx              # empty comment
+  else:
+    while currentTok(p).kind != tkEof:
+      if currentTok(p).kind == tkIndent and currentTok(p).ival > col or
+         currentTok(p).kind != tkIndent and currentTok(p).col > col:
+        inc p.idx
+      else:
+        break
+  result = nil
+
+proc parseLine(p: var RstParser, father: PRstNode) =
+  while true:
+    case currentTok(p).kind
+    of tkWhite, tkWord, tkOther, tkPunct: parseInline(p, father)
+    else: break
+
+proc parseUntilNewline(p: var RstParser, father: PRstNode) =
+  while true:
+    case currentTok(p).kind
+    of tkWhite, tkWord, tkAdornment, tkOther, tkPunct: parseInline(p, father)
+    of tkEof, tkIndent: break
+
+proc parseSection(p: var RstParser, result: PRstNode) {.gcsafe.}
+
+proc tokenAfterNewline(p: RstParser, start: int): int =
+  result = start
+  while true:
+    case p.tok[result].kind
+    of tkEof:
+      break
+    of tkIndent:
+      inc result
+      break
+    else: inc result
+
+proc tokenAfterNewline(p: RstParser): int {.inline.} =
+  result = tokenAfterNewline(p, p.idx)
+
+proc getWrappableIndent(p: RstParser): int =
+  ## Gets baseline indentation for bodies of field lists and directives.
+  ## Handles situations like this (with possible de-indent in [case.3])::
+  ##
+  ##   :field:   definition                                          [case.1]
+  ##
+  ##   currInd   currentTok(p).col
+  ##   |         |
+  ##   v         v
+  ##
+  ##   .. Note:: defItem:                                            [case.2]
+  ##                 definition
+  ##
+  ##                 ^
+  ##                 |
+  ##                 nextIndent
+  ##
+  ##   .. Note:: - point1                                            [case.3]
+  ##       - point 2
+  ##
+  ##       ^
+  ##       |
+  ##       nextIndent
+  if currentTok(p).kind == tkIndent:
+    result = currentTok(p).ival
+  else:
+    var nextIndent = p.tok[tokenAfterNewline(p)-1].ival
+    if nextIndent <= currInd(p):          # parse only this line     [case.1]
+      result = currentTok(p).col
+    elif nextIndent >= currentTok(p).col: # may be a definition list [case.2]
+      result = currentTok(p).col
+    else:
+      result = nextIndent                 # allow parsing next lines [case.3]
+
+proc getMdBlockIndent(p: RstParser): int =
+  ## Markdown version of `getWrappableIndent`.
+  if currentTok(p).kind == tkIndent:
+    result = currentTok(p).ival
+  else:
+    var nextIndent = p.tok[tokenAfterNewline(p)-1].ival
+    # TODO: Markdown-compliant definition should allow nextIndent == currInd(p):
+    if nextIndent <= currInd(p):           # parse only this line
+      result = currentTok(p).col
+    else:
+      result = nextIndent                 # allow parsing next lines [case.3]
+
+proc indFollows(p: RstParser): bool =
+  result = currentTok(p).kind == tkIndent and currentTok(p).ival > currInd(p)
+
+proc parseBlockContent(p: var RstParser, father: var PRstNode,
+                       contentParser: SectionParser): bool {.gcsafe.} =
+  ## parse the final content part of explicit markup blocks (directives,
+  ## footnotes, etc). Returns true if succeeded.
+  if currentTok(p).kind != tkIndent or indFollows(p):
+    let blockIndent = getWrappableIndent(p)
+    pushInd(p, blockIndent)
+    let content = contentParser(p)
+    popInd(p)
+    father.add content
+    result = true
+
+proc parseSectionWrapper(p: var RstParser): PRstNode =
+  result = newRstNode(rnInner)
+  parseSection(p, result)
+  while result.kind == rnInner and result.len == 1:
+    result = result.sons[0]
+
+proc parseField(p: var RstParser): PRstNode =
+  ## Returns a parsed rnField node.
+  ##
+  ## rnField nodes have two children nodes, a rnFieldName and a rnFieldBody.
+  result = newRstNode(rnField, info=lineInfo(p))
+  var col = currentTok(p).col
+  var fieldname = newRstNode(rnFieldName)
+  parseUntil(p, fieldname, ":", false)
+  var fieldbody = newRstNode(rnFieldBody)
+  if currentTok(p).kind == tkWhite: inc p.idx
+  let indent = getWrappableIndent(p)
+  if indent > col:
+    pushInd(p, indent)
+    parseSection(p, fieldbody)
+    popInd(p)
+  result.add(fieldname)
+  result.add(fieldbody)
+
+proc parseFields(p: var RstParser): PRstNode =
+  ## Parses fields for a section or directive block.
+  ##
+  ## This proc may return nil if the parsing doesn't find anything of value,
+  ## otherwise it will return a node of rnFieldList type with children.
+  result = nil
+  var atStart = p.idx == 0 and p.tok[0].symbol == ":"
+  if currentTok(p).kind == tkIndent and nextTok(p).symbol == ":" or
+      atStart:
+    var col = if atStart: currentTok(p).col else: currentTok(p).ival
+    result = newRstNodeA(p, rnFieldList)
+    if not atStart: inc p.idx
+    while true:
+      result.add(parseField(p))
+      if currentTok(p).kind == tkIndent and currentTok(p).ival == col and
+          nextTok(p).symbol == ":":
+        inc p.idx
+      else:
+        break
+
+proc getFieldValue*(n: PRstNode): string =
+  ## Returns the value of a specific ``rnField`` node.
+  ##
+  ## This proc will assert if the node is not of the expected type. The empty
+  ## string will be returned as a minimum. Any value in the rst will be
+  ## stripped form leading/trailing whitespace.
+  assert n.kind == rnField
+  assert n.len == 2
+  assert n.sons[0].kind == rnFieldName
+  assert n.sons[1].kind == rnFieldBody
+  result = addNodes(n.sons[1]).strip
+
+proc getFieldValue(n: PRstNode, fieldname: string): string =
+  if n.sons[1] == nil: return
+  if n.sons[1].kind != rnFieldList:
+    #InternalError("getFieldValue (2): " & $n.sons[1].kind)
+    # We don't like internal errors here anymore as that would break the forum!
+    return
+  for i in 0 ..< n.sons[1].len:
+    var f = n.sons[1].sons[i]
+    if cmpIgnoreStyle(addNodes(f.sons[0]), fieldname) == 0:
+      result = addNodes(f.sons[1])
+      if result == "": result = "\x01\x01" # indicates that the field exists
+      return
+
+proc getArgument(n: PRstNode): string =
+  if n.sons[0] == nil: result = ""
+  else: result = addNodes(n.sons[0])
+
+proc parseDotDot(p: var RstParser): PRstNode {.gcsafe.}
+proc parseLiteralBlock(p: var RstParser): PRstNode =
+  result = newRstNodeA(p, rnLiteralBlock)
+  var n = newLeaf("")
+  if currentTok(p).kind == tkIndent:
+    var indent = currentTok(p).ival
+    while currentTok(p).kind == tkIndent: inc p.idx  # skip blank lines
+    while true:
+      case currentTok(p).kind
+      of tkEof:
+        break
+      of tkIndent:
+        if currentTok(p).ival < indent:
+          break
+        else:
+          n.text.add("\n")
+          n.text.add(spaces(currentTok(p).ival - indent))
+          inc p.idx
+      else:
+        n.text.add(currentTok(p).symbol)
+        inc p.idx
+  else:
+    while currentTok(p).kind notin {tkIndent, tkEof}:
+      n.text.add(currentTok(p).symbol)
+      inc p.idx
+  result.add(n)
+
+proc parseQuotedLiteralBlock(p: var RstParser): PRstNode =
+  result = newRstNodeA(p, rnLiteralBlock)
+  var n = newLeaf("")
+  if currentTok(p).kind == tkIndent:
+    var indent = currInd(p)
+    while currentTok(p).kind == tkIndent: inc p.idx  # skip blank lines
+    var quoteSym = currentTok(p).symbol[0]
+    while true:
+      case currentTok(p).kind
+      of tkEof:
+        break
+      of tkIndent:
+        if currentTok(p).ival < indent:
+          break
+        elif currentTok(p).ival == indent:
+          if nextTok(p).kind == tkPunct and nextTok(p).symbol[0] == quoteSym:
+            n.text.add("\n")
+            inc p.idx
+          elif nextTok(p).kind == tkIndent:
+            break
+          else:
+            rstMessage(p, mwRstStyle, "no newline after quoted literal block")
+            break
+        else:
+          rstMessage(p, mwRstStyle,
+                     "unexpected indentation in quoted literal block")
+          break
+      else:
+        n.text.add(currentTok(p).symbol)
+        inc p.idx
+  result.add(n)
+
+proc parseRstLiteralBlock(p: var RstParser, kind: LiteralBlockKind): PRstNode =
+  if kind == lbIndentedLiteralBlock:
+    result = parseLiteralBlock(p)
+  else:
+    result = parseQuotedLiteralBlock(p)
+
+proc getLevel(p: var RstParser, c: char, hasOverline: bool): int =
+  ## Returns (preliminary) heading level corresponding to `c` and
+  ## `hasOverline`. If level does not exist, add it first.
+  for i, hType in p.s.hLevels:
+    if hType.symbol == c and hType.hasOverline == hasOverline:
+      p.s.hLevels[i].line = curLine(p)
+      p.s.hLevels[i].hasPeers = true
+      return i
+  p.s.hLevels.add LevelInfo(symbol: c, hasOverline: hasOverline,
+                            line: curLine(p), hasPeers: false)
+  result = p.s.hLevels.len - 1
+
+proc countTitles(s: PRstSharedState, n: PRstNode) =
+  ## Fill `s.hTitleCnt`
+  if n == nil: return
+  for node in n.sons:
+    if node != nil:
+      if node.kind notin {rnOverline, rnSubstitutionDef, rnDefaultRole}:
+        break
+      if node.kind == rnOverline:
+        if s.hLevels[s.hTitleCnt].hasPeers:
+          break
+        inc s.hTitleCnt
+        if s.hTitleCnt >= 2:
+          break
+
+proc isAdornmentHeadline(p: RstParser, adornmentIdx: int): bool =
+  ## check that underline/overline length is enough for the heading.
+  ## No support for Unicode.
+  if p.tok[adornmentIdx].symbol in ["::", "..", "|"]:
+    return false
+  if isMarkdownCodeBlock(p, adornmentIdx):
+    return false
+  var headlineLen = 0
+  var failure = ""
+  if p.idx < adornmentIdx:  # check for underline
+    if p.idx > 0:
+      headlineLen = currentTok(p).col - p.tok[adornmentIdx].col
+    if headlineLen > 0:
+      rstMessage(p, mwRstStyle, "indentation of heading text allowed" &
+          " only for overline titles")
+    for i in p.idx ..< adornmentIdx-1:  # adornmentIdx-1 is a linebreak
+      headlineLen += p.tok[i].symbol.len
+    result = p.tok[adornmentIdx].symbol.len >= headlineLen and headlineLen != 0
+    if not result:
+      failure = "(underline '" & p.tok[adornmentIdx].symbol & "' is too short)"
+  else:  # p.idx == adornmentIdx, at overline. Check overline and underline
+    var i = p.idx + 2
+    headlineLen = p.tok[i].col - p.tok[adornmentIdx].col
+    while p.tok[i].kind notin {tkEof, tkIndent}:
+      headlineLen += p.tok[i].symbol.len
+      inc i
+    if p.tok[i].kind == tkIndent and
+       p.tok[i+1].kind == tkAdornment and
+       p.tok[i+1].symbol[0] == p.tok[adornmentIdx].symbol[0]:
+      result = p.tok[adornmentIdx].symbol.len >= headlineLen and
+           headlineLen != 0
+      if result:
+        result = p.tok[i+1].symbol == p.tok[adornmentIdx].symbol
+        if not result:
+          failure = "(underline '" & p.tok[i+1].symbol & "' does not match " &
+              "overline '" & p.tok[adornmentIdx].symbol & "')"
+      else:
+        failure = "(overline '" & p.tok[adornmentIdx].symbol & "' is too short)"
+    else:  # it's not overline/underline section, not reporting error
+      return false
+  if not result:
+    rstMessage(p, meNewSectionExpected, failure)
+
+proc isLineBlock(p: RstParser): bool =
+  var j = tokenAfterNewline(p)
+  result = currentTok(p).col == p.tok[j].col and p.tok[j].symbol == "|" or
+      p.tok[j].col > currentTok(p).col or
+      p.tok[j].symbol == "\n"
+
+proc isMarkdownBlockQuote(p: RstParser): bool =
+  result = currentTok(p).symbol[0] == '>'
+
+proc whichRstLiteralBlock(p: RstParser): LiteralBlockKind =
+  ## Checks that the following tokens are either Indented Literal Block or
+  ## Quoted Literal Block (which is not quite the same as Markdown quote block).
+  ## https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#quoted-literal-blocks
+  if currentTok(p).symbol == "::" and nextTok(p).kind == tkIndent:
+    if currInd(p) > nextTok(p).ival:
+      result = lbNone
+    if currInd(p) < nextTok(p).ival:
+      result = lbIndentedLiteralBlock
+    elif currInd(p) == nextTok(p).ival:
+      var i = p.idx + 1
+      while p.tok[i].kind == tkIndent: inc i
+      const validQuotingCharacters = {
+          '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-',
+          '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^',
+          '_', '`', '{', '|', '}', '~'}
+      if p.tok[i].kind in {tkPunct, tkAdornment} and
+          p.tok[i].symbol[0] in validQuotingCharacters:
+        result = lbQuotedLiteralBlock
+      else:
+        result = lbNone
+  else:
+    result = lbNone
+
+proc predNL(p: RstParser): bool =
+  result = true
+  if p.idx > 0:
+    result = prevTok(p).kind == tkIndent and
+        prevTok(p).ival == currInd(p)
+
+proc isDefList(p: RstParser): bool =
+  var j = tokenAfterNewline(p)
+  result = currentTok(p).col < p.tok[j].col and
+      p.tok[j].kind in {tkWord, tkOther, tkPunct} and
+      p.tok[j - 2].symbol != "::"
+
+proc `$`(t: Token): string =  # for debugging only
+  result = "(" & $t.kind & " line=" & $t.line & " col=" & $t.col
+  if t.kind == tkIndent: result = result & " ival=" & $t.ival & ")"
+  else: result = result & " symbol=" & t.symbol & ")"
+
+proc skipNewlines(p: RstParser, j: int): int =
+  result = j
+  while p.tok[result].kind != tkEof and p.tok[result].kind == tkIndent:
+    inc result  # skip blank lines
+
+proc skipNewlines(p: var RstParser) =
+  p.idx = skipNewlines(p, p.idx)
+
+const maxMdRelInd = 3  ## In Markdown: maximum indentation that does not yet
+                       ## make the indented block a code
+
+proc isMdRelInd(outerInd, nestedInd: int): bool =
+  result = outerInd <= nestedInd and nestedInd <= outerInd + maxMdRelInd
+
+proc isMdDefBody(p: RstParser, j: int, termCol: int): bool =
+  let defCol = p.tok[j].col
+  result = p.tok[j].symbol == ":" and
+    isMdRelInd(termCol, defCol) and
+    p.tok[j+1].kind == tkWhite and
+    p.tok[j+2].kind in {tkWord, tkOther, tkPunct}
+
+proc isMdDefListItem(p: RstParser, idx: int): bool =
+  var j = tokenAfterNewline(p, idx)
+  j = skipNewlines(p, j)
+  let termCol = p.tok[j].col
+  result = isMdRelInd(currInd(p), termCol) and
+      isMdDefBody(p, j, termCol)
+
+proc isOptionList(p: RstParser): bool =
+  result = match(p, p.idx, "-w") or match(p, p.idx, "--w") or
+           match(p, p.idx, "/w") or match(p, p.idx, "//w")
+
+proc isMarkdownHeadlinePattern(s: string): bool =
+  if s.len >= 1 and s.len <= 6:
+    for c in s:
+      if c != '#': return false
+    result = true
+
+proc isMarkdownHeadline(p: RstParser): bool =
+  if roSupportMarkdown in p.s.options:
+    if isMarkdownHeadlinePattern(currentTok(p).symbol) and nextTok(p).kind == tkWhite:
+      if p.tok[p.idx+2].kind in {tkWord, tkOther, tkPunct}:
+        result = true
+
+proc findPipe(p: RstParser, start: int): bool =
+  var i = start
+  while true:
+    if p.tok[i].symbol == "|": return true
+    if p.tok[i].kind in {tkIndent, tkEof}: return false
+    inc i
+
+proc whichSection(p: RstParser): RstNodeKind =
+  if currentTok(p).kind in {tkAdornment, tkPunct}:
+    # for punctuation sequences that can be both tkAdornment and tkPunct
+    if isMarkdownCodeBlock(p):
+      return rnCodeBlock
+    elif isRst(p) and currentTok(p).symbol == "::":
+      return rnLiteralBlock
+    elif currentTok(p).symbol == ".."  and
+       nextTok(p).kind in {tkWhite, tkIndent}:
+     return rnDirective
+  case currentTok(p).kind
+  of tkAdornment:
+    if match(p, p.idx + 1, "iI") and currentTok(p).symbol.len >= 4:
+      result = rnTransition
+    elif match(p, p.idx, "+a+"):
+      result = rnGridTable
+      rstMessage(p, meGridTableNotImplemented)
+    elif match(p, p.idx + 1, " a"): result = rnTable
+    elif currentTok(p).symbol == "|" and isLineBlock(p):
+      result = rnLineBlock
+    elif roSupportMarkdown in p.s.options and isMarkdownBlockQuote(p):
+      result = rnMarkdownBlockQuote
+    elif (match(p, p.idx + 1, "i") and not match(p, p.idx + 2, "I")) and
+         isAdornmentHeadline(p, p.idx):
+      result = rnOverline
+    else:
+      result = rnParagraph
+  of tkPunct:
+    if isMarkdownHeadline(p):
+      result = rnMarkdownHeadline
+    elif roSupportMarkdown in p.s.options and predNL(p) and
+        match(p, p.idx, "| w") and findPipe(p, p.idx+3):
+      result = rnMarkdownTable
+    elif isMd(p) and isMdFootnoteName(p, reference=false):
+      result = rnFootnote
+    elif currentTok(p).symbol == "|" and isLineBlock(p):
+      result = rnLineBlock
+    elif roSupportMarkdown in p.s.options and isMarkdownBlockQuote(p):
+      result = rnMarkdownBlockQuote
+    elif match(p, tokenAfterNewline(p), "aI") and
+        isAdornmentHeadline(p, tokenAfterNewline(p)):
+      result = rnHeadline
+    elif currentTok(p).symbol in ["+", "*", "-"] and nextTok(p).kind == tkWhite:
+      result = rnBulletList
+    elif match(p, p.idx, ":w:E"):
+      # (currentTok(p).symbol == ":")
+      result = rnFieldList
+    elif match(p, p.idx, "(e) ") or match(p, p.idx, "e) ") or
+         match(p, p.idx, "e. "):
+      result = rnEnumList
+    elif isOptionList(p):
+      result = rnOptionList
+    elif isRst(p) and isDefList(p):
+      result = rnDefList
+    elif isMd(p) and isMdDefListItem(p, p.idx):
+      result = rnMdDefList
+    else:
+      result = rnParagraph
+  of tkWord, tkOther, tkWhite:
+    let tokIdx = tokenAfterNewline(p)
+    if match(p, tokIdx, "aI"):
+      if isAdornmentHeadline(p, tokIdx): result = rnHeadline
+      else: result = rnParagraph
+    elif match(p, p.idx, "e) ") or match(p, p.idx, "e. "): result = rnEnumList
+    elif isRst(p) and isDefList(p): result = rnDefList
+    elif isMd(p) and isMdDefListItem(p, p.idx):
+      result = rnMdDefList
+    else: result = rnParagraph
+  else: result = rnLeaf
+
+proc parseLineBlock(p: var RstParser): PRstNode =
+  ## Returns rnLineBlock with all sons of type rnLineBlockItem
+  result = nil
+  if nextTok(p).kind in {tkWhite, tkIndent}:
+    var col = currentTok(p).col
+    result = newRstNodeA(p, rnLineBlock)
+    while true:
+      var item = newRstNode(rnLineBlockItem)
+      if nextTok(p).kind == tkWhite:
+        if nextTok(p).symbol.len > 1:  # pass additional indentation after '| '
+          item.lineIndent = nextTok(p).symbol
+        inc p.idx, 2
+        pushInd(p, p.tok[p.idx].col)
+        parseSection(p, item)
+        popInd(p)
+      else:  # tkIndent => add an empty line
+        item.lineIndent = "\n"
+        inc p.idx, 1
+      result.add(item)
+      if currentTok(p).kind == tkIndent and currentTok(p).ival == col and
+          nextTok(p).symbol == "|" and
+          p.tok[p.idx + 2].kind in {tkWhite, tkIndent}:
+        inc p.idx, 1
+      else:
+        break
+
+proc parseDoc(p: var RstParser): PRstNode {.gcsafe.}
+
+proc getQuoteSymbol(p: RstParser, idx: int): tuple[sym: string, depth: int, tokens: int] =
+  result = ("", 0, 0)
+  var i = idx
+  result.sym &= p.tok[i].symbol
+  result.depth += p.tok[i].symbol.len
+  inc result.tokens
+  inc i
+  while p.tok[i].kind == tkWhite and i+1 < p.tok.len and
+        p.tok[i+1].kind == tkPunct and p.tok[i+1].symbol[0] == '>':
+    result.sym &= p.tok[i].symbol
+    result.sym &= p.tok[i+1].symbol
+    result.depth += p.tok[i+1].symbol.len
+    inc result.tokens, 2
+    inc i, 2
+
+proc parseMarkdownQuoteSegment(p: var RstParser, curSym: string, col: int):
+                              PRstNode =
+  ## We define *segment* as a group of lines that starts with exactly the
+  ## same quote symbol. If the following lines don't contain any `>` (*lazy*
+  ## continuation) they considered as continuation of the current segment.
+  var q: RstParser  # to delete `>` at a start of line and then parse normally
+  initParser(q, p.s)
+  q.col = p.col
+  q.line = p.line
+  var minCol = int.high  # minimum colum num in the segment
+  while true:  # move tokens of segment from `p` to `q` skipping `curSym`
+    case currentTok(p).kind
+    of tkEof:
+      break
+    of tkIndent:
+      if nextTok(p).kind in {tkIndent, tkEof}:
+        break
+      else:
+        if nextTok(p).symbol[0] == '>':
+          var (quoteSym, _, quoteTokens) = getQuoteSymbol(p, p.idx + 1)
+          if quoteSym == curSym:  # the segment continues
+            var iTok = tokenAfterNewline(p, p.idx+1)
+            if p.tok[iTok].kind notin {tkEof, tkIndent} and
+                p.tok[iTok].symbol[0] != '>':
+              rstMessage(p, mwRstStyle,
+                  "two or more quoted lines are followed by unquoted line " &
+                  $(curLine(p) + 1))
+              break
+            q.tok.add currentTok(p)
+            var ival = currentTok(p).ival + quoteSym.len
+            inc p.idx, (1 + quoteTokens)  # skip newline and > > >
+            if currentTok(p).kind == tkWhite:
+              ival += currentTok(p).symbol.len
+              inc p.idx
+            # fix up previous `tkIndent`s to ival (as if >>> were not there)
+            var j = q.tok.len - 1
+            while j >= 0 and q.tok[j].kind == tkIndent:
+              q.tok[j].ival = ival
+              dec j
+          else:  # next segment started
+            break
+        elif currentTok(p).ival < col:
+          break
+        else:  # the segment continues, a case like:
+               # > beginning
+               # continuation
+          q.tok.add currentTok(p)
+          inc p.idx
+    else:
+      if currentTok(p).col < minCol: minCol = currentTok(p).col
+      q.tok.add currentTok(p)
+      inc p.idx
+  q.indentStack = @[minCol]
+  # if initial indentation `minCol` is > 0 then final newlines
+  # should be omitted so that parseDoc could advance to the end of tokens:
+  var j = q.tok.len - 1
+  while q.tok[j].kind == tkIndent: dec j
+  q.tok.setLen (j+1)
+  q.tok.add Token(kind: tkEof, line: currentTok(p).line)
+  result = parseDoc(q)
+
+proc parseMarkdownBlockQuote(p: var RstParser): PRstNode =
+  var (curSym, quotationDepth, quoteTokens) = getQuoteSymbol(p, p.idx)
+  let col = currentTok(p).col
+  result = newRstNodeA(p, rnMarkdownBlockQuote)
+  inc p.idx, quoteTokens  # skip first >
+  while true:
+    var item = newRstNode(rnMarkdownBlockQuoteItem)
+    item.quotationDepth = quotationDepth
+    if currentTok(p).kind == tkWhite: inc p.idx
+    item.add parseMarkdownQuoteSegment(p, curSym, col)
+    result.add(item)
+    if currentTok(p).kind == tkIndent and currentTok(p).ival == col and
+        nextTok(p).kind != tkEof and nextTok(p).symbol[0] == '>':
+      (curSym, quotationDepth, quoteTokens) = getQuoteSymbol(p, p.idx + 1)
+      inc p.idx, (1 + quoteTokens)  # skip newline and > > >
+    else:
+      break
+
+proc parseParagraph(p: var RstParser, result: PRstNode) =
+  while true:
+    case currentTok(p).kind
+    of tkIndent:
+      if nextTok(p).kind == tkIndent:
+        inc p.idx
+        break  # blank line breaks paragraph for both Md & Rst
+      elif currentTok(p).ival == currInd(p) or (
+          isMd(p) and currentTok(p).ival > currInd(p)):
+          # (Md allows adding additional indentation inside paragraphs)
+        inc p.idx
+        case whichSection(p)
+        of rnParagraph, rnLeaf, rnHeadline, rnMarkdownHeadline,
+            rnOverline, rnDirective:
+          result.add newLeaf(" ")
+        of rnLineBlock:
+          result.addIfNotNil(parseLineBlock(p))
+        of rnMarkdownBlockQuote:
+          result.addIfNotNil(parseMarkdownBlockQuote(p))
+        else:
+          dec p.idx  # allow subsequent block to be parsed as another section
+          break
+      else:
+        break
+    of tkPunct:
+      if isRst(p) and (
+          let literalBlockKind = whichRstLiteralBlock(p);
+          literalBlockKind != lbNone):
+        result.add newLeaf(":")
+        inc p.idx            # skip '::'
+        result.add(parseRstLiteralBlock(p, literalBlockKind))
+        break
+      else:
+        parseInline(p, result)
+    of tkWhite, tkWord, tkAdornment, tkOther:
+      parseInline(p, result)
+    else: break
+
+proc checkHeadingHierarchy(p: RstParser, lvl: int) =
+  if lvl - p.s.hCurLevel > 1:  # broken hierarchy!
+    proc descr(l: int): string =
+      (if p.s.hLevels[l].hasOverline: "overline " else: "underline ") &
+      repeat(p.s.hLevels[l].symbol, 5)
+    var msg = "(section level inconsistent: "
+    msg.add descr(lvl) & " unexpectedly found, " &
+      "while the following intermediate section level(s) are missing on lines "
+    msg.add $p.s.hLevels[p.s.hCurLevel].line & ".." & $curLine(p) & ":"
+    for l in p.s.hCurLevel+1 .. lvl-1:
+      msg.add " " & descr(l)
+      if l != lvl-1: msg.add ","
+    rstMessage(p, meNewSectionExpected, msg & ")")
+
+proc parseHeadline(p: var RstParser): PRstNode =
+  if isMarkdownHeadline(p):
+    result = newRstNode(rnMarkdownHeadline)
+    # Note that level hierarchy is not checked for markdown headings
+    result.level = currentTok(p).symbol.len
+    assert(nextTok(p).kind == tkWhite)
+    inc p.idx, 2
+    parseUntilNewline(p, result)
+  else:
+    result = newRstNode(rnHeadline)
+    parseUntilNewline(p, result)
+    assert(currentTok(p).kind == tkIndent)
+    assert(nextTok(p).kind == tkAdornment)
+    var c = nextTok(p).symbol[0]
+    inc p.idx, 2
+    result.level = getLevel(p, c, hasOverline=false)
+    checkHeadingHierarchy(p, result.level)
+    p.s.hCurLevel = result.level
+  addAnchorRst(p, linkName(result), result, anchorType=headlineAnchor)
+  p.s.tocPart.add result
+
+proc parseOverline(p: var RstParser): PRstNode =
+  var c = currentTok(p).symbol[0]
+  inc p.idx, 2
+  result = newRstNode(rnOverline)
+  while true:
+    parseUntilNewline(p, result)
+    if currentTok(p).kind == tkIndent:
+      inc p.idx
+      if prevTok(p).ival > currInd(p):
+        result.add newLeaf(" ")
+      else:
+        break
+    else:
+      break
+  result.level = getLevel(p, c, hasOverline=true)
+  checkHeadingHierarchy(p, result.level)
+  p.s.hCurLevel = result.level
+  if currentTok(p).kind == tkAdornment:
+    inc p.idx
+    if currentTok(p).kind == tkIndent: inc p.idx
+  addAnchorRst(p, linkName(result), result, anchorType=headlineAnchor)
+  p.s.tocPart.add result
+
+proc fixHeadlines(s: PRstSharedState) =
+  # Fix up section levels depending on presence of a title and subtitle:
+  for n in s.tocPart:
+    if n.kind in {rnHeadline, rnOverline}:
+      if s.hTitleCnt == 2:
+        if n.level == 1:    # it's the subtitle
+          n.level = 0
+        elif n.level >= 2:  # normal sections, start numbering from 1
+          n.level -= 1
+      elif s.hTitleCnt == 0:
+        n.level += 1
+  # Set headline anchors:
+  for iHeading in 0 .. s.tocPart.high:
+    let n: PRstNode = s.tocPart[iHeading]
+    if n.level >= 1:
+      n.anchor = rstnodeToRefname(n)
+      # Fix anchors for uniqueness if `.. contents::` is present
+      if s.hasToc:
+        # Find the last higher level section for unique reference name
+        var sectionPrefix = ""
+        for i in countdown(iHeading - 1, 0):
+          if s.tocPart[i].level >= 1 and s.tocPart[i].level < n.level:
+            sectionPrefix = rstnodeToRefname(s.tocPart[i]) & "-"
+            break
+        if sectionPrefix != "":
+          n.anchor = sectionPrefix & n.anchor
+  s.tocPart.setLen 0
+
+type
+  ColSpec = object
+    start, stop: int
+  RstCols = seq[ColSpec]
+  ColumnLimits = tuple  # for Markdown
+    first, last: int
+  ColSeq = seq[ColumnLimits]
+
+proc tokStart(p: RstParser, idx: int): int =
+  result = p.tok[idx].col
+
+proc tokStart(p: RstParser): int =
+  result = tokStart(p, p.idx)
+
+proc tokEnd(p: RstParser, idx: int): int =
+  result = p.tok[idx].col + p.tok[idx].symbol.len - 1
+
+proc tokEnd(p: RstParser): int =
+  result = tokEnd(p, p.idx)
+
+proc getColumns(p: RstParser, cols: var RstCols, startIdx: int): int =
+  # Fills table column specification (or separator) `cols` and returns
+  # the next parser index after it.
+  var L = 0
+  result = startIdx
+  while true:
+    inc L
+    setLen(cols, L)
+    cols[L - 1].start = tokStart(p, result)
+    cols[L - 1].stop = tokEnd(p, result)
+    assert(p.tok[result].kind == tkAdornment)
+    inc result
+    if p.tok[result].kind != tkWhite: break
+    inc result
+    if p.tok[result].kind != tkAdornment: break
+  if p.tok[result].kind == tkIndent: inc result
+
+proc checkColumns(p: RstParser, cols: RstCols) =
+  var i = p.idx
+  if p.tok[i].symbol[0] != '=':
+    stopOrWarn(p, meIllformedTable,
+               "only tables with `=` columns specification are allowed")
+  for col in 0 ..< cols.len:
+    if tokEnd(p, i) != cols[col].stop:
+      stopOrWarn(p, meIllformedTable,
+                 "end of table column #$1 should end at position $2" % [
+                   $(col+1), $(cols[col].stop+ColRstOffset)],
+                 p.tok[i].line, tokEnd(p, i))
+    inc i
+    if col == cols.len - 1:
+      if p.tok[i].kind == tkWhite:
+        inc i
+      if p.tok[i].kind notin {tkIndent, tkEof}:
+        stopOrWarn(p, meIllformedTable, "extraneous column specification")
+    elif p.tok[i].kind == tkWhite:
+      inc i
+    else:
+      stopOrWarn(p, meIllformedTable,
+                 "no enough table columns", p.tok[i].line, p.tok[i].col)
+
+proc getSpans(p: RstParser, nextLine: int,
+              cols: RstCols, unitedCols: RstCols): seq[int] =
+  ## Calculates how many columns a joined cell occupies.
+  if unitedCols.len > 0:
+    result = newSeq[int](unitedCols.len)
+    var
+      iCell = 0
+      jCell = 0
+      uCell = 0
+    while jCell < cols.len:
+      if cols[jCell].stop < unitedCols[uCell].stop:
+        inc jCell
+      elif cols[jCell].stop == unitedCols[uCell].stop:
+        result[uCell] = jCell - iCell + 1
+        iCell = jCell + 1
+        jCell = jCell + 1
+        inc uCell
+      else:
+        rstMessage(p, meIllformedTable,
+                   "spanning underline does not match main table columns",
+                   p.tok[nextLine].line, p.tok[nextLine].col)
+
+proc parseSimpleTableRow(p: var RstParser, cols: RstCols, colChar: char): PRstNode =
+  ## Parses 1 row in RST simple table.
+  # Consider that columns may be spanning (united by using underline like ----):
+  let nextLine = tokenAfterNewline(p)
+  var unitedCols: RstCols
+  var afterSpan: int
+  if p.tok[nextLine].kind == tkAdornment and p.tok[nextLine].symbol[0] == '-':
+    afterSpan = getColumns(p, unitedCols, nextLine)
+    if unitedCols == cols and p.tok[nextLine].symbol[0] == colChar:
+      # legacy rst.nim compat.: allow punctuation like `----` in main boundaries
+      afterSpan = nextLine
+      unitedCols.setLen 0
+  else:
+    afterSpan = nextLine
+  template colEnd(i): int =
+    if i == cols.len - 1: high(int)  # last column has no limit
+    elif unitedCols.len > 0: unitedCols[i].stop else: cols[i].stop
+  template colStart(i): int =
+    if unitedCols.len > 0: unitedCols[i].start else: cols[i].start
+  var row = newSeq[string](if unitedCols.len > 0: unitedCols.len else: cols.len)
+  var spans: seq[int] = getSpans(p, nextLine, cols, unitedCols)
+
+  let line = currentTok(p).line
+  # Iterate over the lines a single cell may span:
+  while true:
+    var nCell = 0
+    # distribute tokens between cells in the current line:
+    while currentTok(p).kind notin {tkIndent, tkEof}:
+      if tokEnd(p) <= colEnd(nCell):
+        if tokStart(p) < colStart(nCell):
+          if currentTok(p).kind != tkWhite:
+            stopOrWarn(p, meIllformedTable,
+                       "this word crosses table column from the left")
+            row[nCell].add(currentTok(p).symbol)
+        else:
+          row[nCell].add(currentTok(p).symbol)
+        inc p.idx
+      else:
+        if tokStart(p) < colEnd(nCell) and currentTok(p).kind != tkWhite:
+          stopOrWarn(p, meIllformedTable,
+                     "this word crosses table column from the right")
+          row[nCell].add(currentTok(p).symbol)
+          inc p.idx
+        inc nCell
+    if currentTok(p).kind == tkIndent: inc p.idx
+    if tokEnd(p) <= colEnd(0): break
+    # Continued current cells because the 1st column is empty.
+    if currentTok(p).kind in {tkEof, tkAdornment}:
+      break
+    for nCell in countup(1, high(row)): row[nCell].add('\n')
+  result = newRstNode(rnTableRow)
+  var q: RstParser
+  for uCell in 0 ..< row.len:
+    initParser(q, p.s)
+    q.col = colStart(uCell)
+    q.line = line - 1
+    getTokens(row[uCell], q.tok)
+    let cell = newRstNode(rnTableDataCell)
+    cell.span = if spans.len == 0: 0 else: spans[uCell]
+    cell.add(parseDoc(q))
+    result.add(cell)
+  if afterSpan > p.idx:
+    p.idx = afterSpan
+
+proc parseSimpleTable(p: var RstParser): PRstNode =
+  var cols: RstCols
+  result = newRstNodeA(p, rnTable)
+  let startIdx = getColumns(p, cols, p.idx)
+  let colChar = currentTok(p).symbol[0]
+  checkColumns(p, cols)
+  p.idx = startIdx
+  result.colCount = cols.len
+  while true:
+    if currentTok(p).kind == tkAdornment:
+      checkColumns(p, cols)
+      p.idx = tokenAfterNewline(p)
+      if currentTok(p).kind in {tkEof, tkIndent}:
+        # skip last adornment line:
+        break
+      if result.sons.len > 0: result.sons[^1].endsHeader = true
+      # fix rnTableDataCell -> rnTableHeaderCell for previous table rows:
+      for nRow in 0 ..< result.sons.len:
+        for nCell in 0 ..< result.sons[nRow].len:
+          template cell: PRstNode = result.sons[nRow].sons[nCell]
+          cell = PRstNode(kind: rnTableHeaderCell, sons: cell.sons,
+                          span: cell.span, anchor: cell.anchor)
+    if currentTok(p).kind == tkEof: break
+    let tabRow = parseSimpleTableRow(p, cols, colChar)
+    result.add tabRow
+
+proc readTableRow(p: var RstParser): ColSeq =
+  if currentTok(p).symbol == "|": inc p.idx
+  while currentTok(p).kind notin {tkIndent, tkEof}:
+    var limits: ColumnLimits
+    limits.first = p.idx
+    while currentTok(p).kind notin {tkIndent, tkEof}:
+      if currentTok(p).symbol == "|" and prevTok(p).symbol != "\\": break
+      inc p.idx
+    limits.last = p.idx
+    result.add(limits)
+    if currentTok(p).kind in {tkIndent, tkEof}: break
+    inc p.idx
+  p.idx = tokenAfterNewline(p)
+
+proc getColContents(p: var RstParser, colLim: ColumnLimits): string =
+  for i in colLim.first ..< colLim.last:
+    result.add(p.tok[i].symbol)
+  result.strip
+
+proc isValidDelimiterRow(p: var RstParser, colNum: int): bool =
+  let row = readTableRow(p)
+  if row.len != colNum: return false
+  for limits in row:
+    let content = getColContents(p, limits)
+    if content.len < 3 or not (content.startsWith("--") or content.startsWith(":-")):
+      return false
+  return true
+
+proc parseMarkdownTable(p: var RstParser): PRstNode =
+  var
+    row: ColSeq
+    a, b: PRstNode
+    q: RstParser
+  result = newRstNodeA(p, rnMarkdownTable)
+
+  proc parseRow(p: var RstParser, cellKind: RstNodeKind, result: PRstNode) =
+    row = readTableRow(p)
+    if result.colCount == 0: result.colCount = row.len # table header
+    elif row.len < result.colCount: row.setLen(result.colCount)
+    a = newRstNode(rnTableRow)
+    for j in 0 ..< result.colCount:
+      b = newRstNode(cellKind)
+      initParser(q, p.s)
+      q.col = p.col
+      q.line = currentTok(p).line - 1
+      getTokens(getColContents(p, row[j]), q.tok)
+      b.add(parseDoc(q))
+      a.add(b)
+    result.add(a)
+
+  parseRow(p, rnTableHeaderCell, result)
+  if not isValidDelimiterRow(p, result.colCount):
+    rstMessage(p, meMarkdownIllformedTable)
+  while predNL(p) and currentTok(p).symbol == "|":
+    parseRow(p, rnTableDataCell, result)
+
+proc parseTransition(p: var RstParser): PRstNode =
+  result = newRstNodeA(p, rnTransition)
+  inc p.idx
+  if currentTok(p).kind == tkIndent: inc p.idx
+  if currentTok(p).kind == tkIndent: inc p.idx
+
+proc parseBulletList(p: var RstParser): PRstNode =
+  result = nil
+  if nextTok(p).kind == tkWhite:
+    var bullet = currentTok(p).symbol
+    var col = currentTok(p).col
+    result = newRstNodeA(p, rnBulletList)
+    pushInd(p, p.tok[p.idx + 2].col)
+    inc p.idx, 2
+    while true:
+      var item = newRstNode(rnBulletItem)
+      parseSection(p, item)
+      result.add(item)
+      if currentTok(p).kind == tkIndent and currentTok(p).ival == col and
+          nextTok(p).symbol == bullet and
+          p.tok[p.idx + 2].kind == tkWhite:
+        inc p.idx, 3
+      else:
+        break
+    popInd(p)
+
+proc parseOptionList(p: var RstParser): PRstNode =
+  result = newRstNodeA(p, rnOptionList)
+  let col = currentTok(p).col
+  var order = 1
+  while true:
+    if currentTok(p).col == col and isOptionList(p):
+      var a = newRstNode(rnOptionGroup)
+      var b = newRstNode(rnDescription)
+      var c = newRstNode(rnOptionListItem)
+      if match(p, p.idx, "//w"): inc p.idx
+      while currentTok(p).kind notin {tkIndent, tkEof}:
+        if currentTok(p).kind == tkWhite and currentTok(p).symbol.len > 1:
+          inc p.idx
+          break
+        a.add(newLeaf(p))
+        inc p.idx
+      var j = tokenAfterNewline(p)
+      if j > 0 and p.tok[j - 1].kind == tkIndent and p.tok[j - 1].ival > currInd(p):
+        pushInd(p, p.tok[j - 1].ival)
+        parseSection(p, b)
+        popInd(p)
+      else:
+        parseLine(p, b)
+      while currentTok(p).kind == tkIndent: inc p.idx
+      c.add(a)
+      c.add(b)
+      c.order = order; inc order
+      result.add(c)
+    else:
+      if currentTok(p).kind != tkEof: dec p.idx  # back to tkIndent
+      break
+
+proc parseMdDefinitionList(p: var RstParser): PRstNode =
+  ## Parses (Pandoc/kramdown/PHPextra) Markdown definition lists.
+  result = newRstNodeA(p, rnMdDefList)
+  let termCol = currentTok(p).col
+  while true:
+    var item = newRstNode(rnDefItem)
+    var term = newRstNode(rnDefName)
+    parseLine(p, term)
+    skipNewlines(p)
+    inc p.idx, 2  # skip ":" and space
+    item.add(term)
+    while true:
+      var def = newRstNode(rnDefBody)
+      let indent = getMdBlockIndent(p)
+      pushInd(p, indent)
+      parseSection(p, def)
+      popInd(p)
+      item.add(def)
+      let j = skipNewlines(p, p.idx)
+      if isMdDefBody(p, j, termCol):  # parse next definition body
+        p.idx = j + 2  # skip ":" and space
+      else:
+        break
+    result.add(item)
+    let j = skipNewlines(p, p.idx)
+    if p.tok[j].col == termCol and isMdDefListItem(p, j):
+      p.idx = j  # parse next item
+    else:
+      break
+
+proc parseDefinitionList(p: var RstParser): PRstNode =
+  result = nil
+  var j = tokenAfterNewline(p) - 1
+  if j >= 1 and p.tok[j].kind == tkIndent and
+      p.tok[j].ival > currInd(p) and p.tok[j - 1].symbol != "::":
+    var col = currentTok(p).col
+    result = newRstNodeA(p, rnDefList)
+    while true:
+      if isOptionList(p):
+        break  # option list has priority over def.list
+      j = p.idx
+      var a = newRstNode(rnDefName)
+      parseLine(p, a)
+      if currentTok(p).kind == tkIndent and
+          currentTok(p).ival > currInd(p) and
+          nextTok(p).symbol != "::" and
+          nextTok(p).kind notin {tkIndent, tkEof}:
+        pushInd(p, currentTok(p).ival)
+        var b = newRstNode(rnDefBody)
+        parseSection(p, b)
+        var c = newRstNode(rnDefItem)
+        c.add(a)
+        c.add(b)
+        result.add(c)
+        popInd(p)
+      else:
+        p.idx = j
+        break
+      if currentTok(p).kind == tkIndent and currentTok(p).ival == col:
+        inc p.idx
+        j = tokenAfterNewline(p) - 1
+        if j >= 1 and p.tok[j].kind == tkIndent and p.tok[j].ival > col and
+            p.tok[j-1].symbol != "::" and p.tok[j+1].kind != tkIndent:
+          discard
+        else:
+          break
+    if result.len == 0: result = nil
+
+proc parseEnumList(p: var RstParser): PRstNode =
+  const
+    wildcards: array[0..5, string] = ["(n) ", "n) ", "n. ",
+                                      "(x) ", "x) ", "x. "]
+      # enumerator patterns, where 'x' means letter and 'n' means number
+    wildToken: array[0..5, int] = [4, 3, 3, 4, 3, 3]  # number of tokens
+    wildIndex: array[0..5, int] = [1, 0, 0, 1, 0, 0]
+      # position of enumeration sequence (number/letter) in enumerator
+  let col = currentTok(p).col
+  var w = 0
+  while w < wildcards.len:
+    if match(p, p.idx, wildcards[w]): break
+    inc w
+  assert w < wildcards.len
+
+  proc checkAfterNewline(p: RstParser, report: bool): bool =
+    ## If no indentation on the next line then parse as a normal paragraph
+    ## according to the RST spec. And report a warning with suggestions
+    let j = tokenAfterNewline(p, start=p.idx+1)
+    let requiredIndent = p.tok[p.idx+wildToken[w]].col
+    if p.tok[j].kind notin {tkIndent, tkEof} and
+        p.tok[j].col < requiredIndent and
+        (p.tok[j].col > col or
+          (p.tok[j].col == col and not match(p, j, wildcards[w]))):
+      if report:
+        let n = p.line + p.tok[j].line
+        let msg = "\n" & """
+          not enough indentation on line $2
+            (should be at column $3 if it's a continuation of enum. list),
+          or no blank line after line $1 (if it should be the next paragraph),
+          or no escaping \ at the beginning of line $1
+            (if lines $1..$2 are a normal paragraph, not enum. list)""".dedent
+        let c = p.col + requiredIndent + ColRstOffset
+        rstMessage(p, mwRstStyle, msg % [$(n-1), $n, $c],
+                   p.tok[j].line, p.tok[j].col)
+      result = false
+    else:
+      result = true
+
+  if not checkAfterNewline(p, report = true):
+    return nil
+  result = newRstNodeA(p, rnEnumList)
+  let autoEnums = if roSupportMarkdown in p.s.options: @["#", "1"] else: @["#"]
+  var prevAE = ""  # so as not allow mixing auto-enumerators `1` and `#`
+  var curEnum = 1
+  for i in 0 ..< wildToken[w]-1:  # add first enumerator with (, ), and .
+    if p.tok[p.idx + i].symbol == "#":
+      prevAE = "#"
+      result.labelFmt.add "1"
+    else:
+      result.labelFmt.add p.tok[p.idx + i].symbol
+  var prevEnum = p.tok[p.idx + wildIndex[w]].symbol
+  inc p.idx, wildToken[w]
+  while true:
+    var item = newRstNode(rnEnumItem)
+    pushInd(p, currentTok(p).col)
+    parseSection(p, item)
+    popInd(p)
+    result.add(item)
+    if currentTok(p).kind == tkIndent and currentTok(p).ival == col and
+        match(p, p.idx+1, wildcards[w]):
+      # don't report to avoid duplication of warning since for
+      # subsequent enum. items parseEnumList will be called second time:
+      if not checkAfterNewline(p, report = false):
+        break
+      let enumerator = p.tok[p.idx + 1 + wildIndex[w]].symbol
+      # check that it's in sequence: enumerator == next(prevEnum)
+      if "n" in wildcards[w]:  # arabic numeral
+        let prevEnumI = try: parseInt(prevEnum) except ValueError: 1
+        if enumerator in autoEnums:
+          if prevAE != "" and enumerator != prevAE:
+            break
+          prevAE = enumerator
+          curEnum = prevEnumI + 1
+        else: curEnum = (try: parseInt(enumerator) except ValueError: 1)
+        if curEnum - prevEnumI != 1:
+          break
+        prevEnum = enumerator
+      else:  # a..z
+        let prevEnumI = ord(prevEnum[0])
+        if enumerator == "#": curEnum = prevEnumI + 1
+        else: curEnum = ord(enumerator[0])
+        if curEnum - prevEnumI != 1:
+          break
+        prevEnum = $chr(curEnum)
+      inc p.idx, 1 + wildToken[w]
+    else:
+      break
+
+proc prefix(ftnType: FootnoteType): string =
+  case ftnType
+  of fnManualNumber: result = "footnote-"
+  of fnAutoNumber: result = "footnoteauto-"
+  of fnAutoNumberLabel: result = "footnote-"
+  of fnAutoSymbol: result = "footnotesym-"
+  of fnCitation: result = "citation-"
+
+proc parseFootnote(p: var RstParser): PRstNode {.gcsafe.} =
+  ## Parses footnotes and citations, always returns 2 sons:
+  ##
+  ## 1) footnote label, always containing rnInner with 1 or more sons
+  ## 2) footnote body, which may be nil
+  var label: PRstNode
+  if isRst(p):
+    inc p.idx  # skip space after `..`
+  label = parseFootnoteName(p, reference=false)
+  if label == nil:
+    if isRst(p):
+      dec p.idx
+    return nil
+  result = newRstNode(rnFootnote)
+  result.add label
+  let (fnType, i) = getFootnoteType(p.s, label)
+  var name = ""
+  var anchor = fnType.prefix
+  case fnType
+  of fnManualNumber:
+    addFootnoteNumManual(p, i)
+    anchor.add $i
+  of fnAutoNumber, fnAutoNumberLabel:
+    name = rstnodeToRefname(label)
+    addFootnoteNumAuto(p, name)
+    if fnType == fnAutoNumberLabel:
+      anchor.add name
+    else:  # fnAutoNumber
+      result.order = p.s.lineFootnoteNum.len
+      anchor.add $result.order
+  of fnAutoSymbol:
+    addFootnoteSymAuto(p)
+    result.order = p.s.lineFootnoteSym.len
+    anchor.add $p.s.lineFootnoteSym.len
+  of fnCitation:
+    anchor.add rstnodeToRefname(label)
+  addAnchorRst(p, anchor, target = result, anchorType = footnoteAnchor)
+  result.anchor = anchor
+  if currentTok(p).kind == tkWhite: inc p.idx
+  discard parseBlockContent(p, result, parseSectionWrapper)
+  if result.len < 2:
+    result.add nil
+
+proc sonKind(father: PRstNode, i: int): RstNodeKind =
+  result = rnLeaf
+  if i < father.len: result = father.sons[i].kind
+
+proc parseSection(p: var RstParser, result: PRstNode) =
+  ## parse top-level RST elements: sections, transitions and body elements.
+  while true:
+    var leave = false
+    assert(p.idx >= 0)
+    while currentTok(p).kind == tkIndent:
+      if currInd(p) == currentTok(p).ival:
+        inc p.idx
+      elif currentTok(p).ival > currInd(p):
+        if roPreferMarkdown in p.s.options:  # Markdown => normal paragraphs
+          if currentTok(p).ival - currInd(p) >= 4:
+            result.add parseLiteralBlock(p)
+          else:
+            pushInd(p, currentTok(p).ival)
+            parseSection(p, result)
+            popInd(p)
+        else:  # RST mode => block quotes
+          pushInd(p, currentTok(p).ival)
+          var a = newRstNodeA(p, rnBlockQuote)
+          parseSection(p, a)
+          result.add(a)
+          popInd(p)
+      else:
+        while currentTok(p).kind != tkEof and nextTok(p).kind == tkIndent:
+          inc p.idx  # skip blank lines
+        leave = true
+        break
+    if leave or currentTok(p).kind == tkEof: break
+    var a: PRstNode = nil
+    var k = whichSection(p)
+    case k
+    of rnLiteralBlock:
+      inc p.idx              # skip '::'
+      a = parseLiteralBlock(p)
+    of rnBulletList: a = parseBulletList(p)
+    of rnLineBlock: a = parseLineBlock(p)
+    of rnMarkdownBlockQuote: a = parseMarkdownBlockQuote(p)
+    of rnDirective: a = parseDotDot(p)
+    of rnFootnote: a = parseFootnote(p)
+    of rnEnumList: a = parseEnumList(p)
+    of rnLeaf: rstMessage(p, meNewSectionExpected, "(syntax error)")
+    of rnParagraph: discard
+    of rnDefList: a = parseDefinitionList(p)
+    of rnMdDefList: a = parseMdDefinitionList(p)
+    of rnFieldList:
+      if p.idx > 0: dec p.idx
+      a = parseFields(p)
+    of rnTransition: a = parseTransition(p)
+    of rnHeadline, rnMarkdownHeadline: a = parseHeadline(p)
+    of rnOverline: a = parseOverline(p)
+    of rnTable: a = parseSimpleTable(p)
+    of rnMarkdownTable: a = parseMarkdownTable(p)
+    of rnOptionList: a = parseOptionList(p)
+    else:
+      #InternalError("rst.parseSection()")
+      discard
+    if a == nil and k != rnDirective:
+      a = newRstNodeA(p, rnParagraph)
+      parseParagraph(p, a)
+    result.addIfNotNil(a)
+  if sonKind(result, 0) == rnParagraph and sonKind(result, 1) != rnParagraph:
+    result.sons[0] = newRstNode(rnInner, result.sons[0].sons,
+                                anchor=result.sons[0].anchor)
+
+proc parseDoc(p: var RstParser): PRstNode =
+  result = parseSectionWrapper(p)
+  if currentTok(p).kind != tkEof:
+    rstMessage(p, meGeneralParseError)
+
+type
+  DirFlag = enum
+    hasArg, hasOptions, argIsFile, argIsWord
+  DirFlags = set[DirFlag]
+
+proc parseDirective(p: var RstParser, k: RstNodeKind, flags: DirFlags): PRstNode =
+  ## Parses arguments and options for a directive block.
+  ##
+  ## A directive block will always have three sons: the arguments for the
+  ## directive (rnDirArg), the options (rnFieldList) and the directive
+  ## content block. This proc parses the two first nodes, the 3rd is left to
+  ## the outer `parseDirective` call.
+  ##
+  ## Both rnDirArg and rnFieldList children nodes might be nil, so you need to
+  ## check them before accessing.
+  result = newRstNodeA(p, k)
+  if k == rnCodeBlock: result.info = lineInfo(p)
+  var args: PRstNode = nil
+  var options: PRstNode = nil
+  if hasArg in flags:
+    args = newRstNode(rnDirArg)
+    if argIsFile in flags:
+      while true:
+        case currentTok(p).kind
+        of tkWord, tkOther, tkPunct, tkAdornment:
+          args.add(newLeaf(p))
+          inc p.idx
+        else: break
+    elif argIsWord in flags:
+      while currentTok(p).kind == tkWhite: inc p.idx
+      if currentTok(p).kind == tkWord:
+        args.add(newLeaf(p))
+        inc p.idx
+      else:
+        args = nil
+    else:
+      parseLine(p, args)
+  result.add(args)
+  if hasOptions in flags:
+    if currentTok(p).kind == tkIndent and currentTok(p).ival > currInd(p) and
+        nextTok(p).symbol == ":":
+      pushInd(p, currentTok(p).ival)
+      options = parseFields(p)
+      popInd(p)
+  result.add(options)
+
+proc parseDirective(p: var RstParser, k: RstNodeKind, flags: DirFlags,
+                    contentParser: SectionParser): PRstNode =
+  ## A helper proc that does main work for specific directive procs.
+  ## Always returns a generic rnDirective tree with these 3 children:
+  ##
+  ## 1) rnDirArg
+  ## 2) rnFieldList
+  ## 3) a node returned by `contentParser`.
+  ##
+  ## .. warning:: Any of the 3 children may be nil.
+  result = parseDirective(p, k, flags)
+  if not isNil(contentParser) and
+      parseBlockContent(p, result, contentParser):
+    discard "result is updated by parseBlockContent"
+  else:
+    result.add(PRstNode(nil))
+
+proc parseDirBody(p: var RstParser, contentParser: SectionParser): PRstNode =
+  if indFollows(p):
+    pushInd(p, currentTok(p).ival)
+    result = contentParser(p)
+    popInd(p)
+
+proc dirInclude(p: var RstParser): PRstNode =
+  ##
+  ## The following options are recognized:
+  ##
+  ## :start-after: text to find in the external data file
+  ##
+  ##     Only the content after the first occurrence of the specified
+  ##     text will be included. If text is not found inclusion will
+  ##     start from beginning of the file
+  ##
+  ## :end-before: text to find in the external data file
+  ##
+  ##     Only the content before the first occurrence of the specified
+  ##     text (but after any after text) will be included. If text is
+  ##     not found inclusion will happen until the end of the file.
+  #literal : flag (empty)
+  #    The entire included text is inserted into the document as a single
+  #    literal block (useful for program listings).
+  #encoding : name of text encoding
+  #    The text encoding of the external data file. Defaults to the document's
+  #    encoding (if specified).
+  #
+  result = nil
+  var n = parseDirective(p, rnDirective, {hasArg, argIsFile, hasOptions}, nil)
+  var filename = strip(addNodes(n.sons[0]))
+  var path = p.findRelativeFile(filename)
+  if path == "":
+    rstMessage(p, meCannotOpenFile, filename)
+  else:
+    # XXX: error handling; recursive file inclusion!
+    if getFieldValue(n, "literal") != "":
+      result = newRstNode(rnLiteralBlock)
+      result.add newLeaf(readFile(path))
+    else:
+      let inputString = readFile(path)
+      let startPosition =
+        block:
+          let searchFor = n.getFieldValue("start-after").strip()
+          if searchFor != "":
+            let pos = inputString.find(searchFor)
+            if pos != -1: pos + searchFor.len
+            else: 0
+          else:
+            0
+
+      let endPosition =
+        block:
+          let searchFor = n.getFieldValue("end-before").strip()
+          if searchFor != "":
+            let pos = inputString.find(searchFor, start = startPosition)
+            if pos != -1: pos - 1
+            else: 0
+          else:
+            inputString.len - 1
+
+      var q: RstParser
+      initParser(q, p.s)
+      let saveFileIdx = p.s.currFileIdx
+      setCurrFilename(p.s, path)
+      getTokens(
+        inputString[startPosition..endPosition],
+        q.tok)
+      # workaround a GCC bug; more like the interior pointer bug?
+      #if find(q.tok[high(q.tok)].symbol, "\0\x01\x02") > 0:
+      #  InternalError("Too many binary zeros in include file")
+      result = parseDoc(q)
+      p.s.currFileIdx = saveFileIdx
+
+proc dirCodeBlock(p: var RstParser, nimExtension = false): PRstNode =
+  ## Parses a code block.
+  ##
+  ## Code blocks are rnDirective trees with a `kind` of rnCodeBlock. See the
+  ## description of ``parseDirective`` for further structure information.
+  ##
+  ## Code blocks can come in two forms, the standard `code directive
+  ## <http://docutils.sourceforge.net/docs/ref/rst/directives.html#code>`_ and
+  ## the nim extension ``.. code-block::``. If the block is an extension, we
+  ## want the default language syntax highlighting to be Nim, so we create a
+  ## fake internal field to communicate with the generator. The field is named
+  ## ``default-language``, which is unlikely to collide with a field specified
+  ## by any random rst input file.
+  ##
+  ## As an extension this proc will process the ``file`` extension field and if
+  ## present will replace the code block with the contents of the referenced
+  ## file. This behaviour is disabled in sandboxed mode and can be re-enabled
+  ## with the `roSandboxDisabled` flag.
+  result = parseDirective(p, rnCodeBlock, {hasArg, hasOptions}, parseLiteralBlock)
+  mayLoadFile(p, result)
+
+  # Extend the field block if we are using our custom Nim extension.
+  if nimExtension:
+    defaultCodeLangNim(p, result)
+
+proc dirContainer(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnContainer, {hasArg}, parseSectionWrapper)
+  assert(result.len == 3)
+
+proc dirImage(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnImage, {hasOptions, hasArg, argIsFile}, nil)
+
+proc dirFigure(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnFigure, {hasOptions, hasArg, argIsFile},
+                          parseSectionWrapper)
+
+proc dirTitle(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnTitle, {hasArg}, nil)
+
+proc dirContents(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnContents, {hasArg}, nil)
+  p.s.hasToc = true
+
+proc dirIndex(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnIndex, {}, parseSectionWrapper)
+
+proc dirAdmonition(p: var RstParser, d: string): PRstNode =
+  result = parseDirective(p, rnAdmonition, {}, parseSectionWrapper)
+  result.adType = d
+
+proc dirDefaultRole(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnDefaultRole, {hasArg}, nil)
+  if result.sons[0].len == 0: p.s.currRole = defaultRole(p.s.options)
+  else:
+    assert result.sons[0].sons[0].kind == rnLeaf
+    p.s.currRole = result.sons[0].sons[0].text
+  p.s.currRoleKind = whichRole(p, p.s.currRole)
+
+proc dirRole(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnDirective, {hasArg, hasOptions}, nil)
+  # just check that language is supported, TODO: real role association
+  let lang = getFieldValue(result, "language").strip
+  if lang != "" and getSourceLanguage(lang) == langNone:
+    rstMessage(p, mwUnsupportedLanguage, lang)
+
+proc dirRawAux(p: var RstParser, result: var PRstNode, kind: RstNodeKind,
+               contentParser: SectionParser) =
+  var filename = getFieldValue(result, "file")
+  if filename.len > 0:
+    var path = p.findRelativeFile(filename)
+    if path.len == 0:
+      rstMessage(p, meCannotOpenFile, filename)
+    else:
+      var f = readFile(path)
+      result = newRstNode(kind)
+      result.add newLeaf(f)
+  else:
+    result = newRstNode(kind, result.sons)
+    result.add(parseDirBody(p, contentParser))
+
+proc dirRaw(p: var RstParser): PRstNode =
+  #
+  #The following options are recognized:
+  #
+  #file : string (newlines removed)
+  #    The local filesystem path of a raw data file to be included.
+  #
+  # html
+  # latex
+  result = parseDirective(p, rnDirective, {hasOptions, hasArg, argIsWord})
+  if result.sons[0] != nil:
+    if cmpIgnoreCase(result.sons[0].sons[0].text, "html") == 0:
+      dirRawAux(p, result, rnRawHtml, parseLiteralBlock)
+    elif cmpIgnoreCase(result.sons[0].sons[0].text, "latex") == 0:
+      dirRawAux(p, result, rnRawLatex, parseLiteralBlock)
+    else:
+      rstMessage(p, meInvalidDirective, result.sons[0].sons[0].text)
+  else:
+    dirRawAux(p, result, rnRaw, parseSectionWrapper)
+
+proc dirImportdoc(p: var RstParser): PRstNode =
+  result = parseDirective(p, rnDirective, {}, parseLiteralBlock)
+  assert result.sons[2].kind == rnLiteralBlock
+  assert result.sons[2].sons[0].kind == rnLeaf
+  let filenames: seq[string] = split(result.sons[2].sons[0].text, seps = {','})
+  proc rmSpaces(s: string): string = s.split.join("")
+  for origFilename in filenames:
+    p.s.idxImports[origFilename.rmSpaces] = ImportdocInfo(fromInfo: lineInfo(p))
+
+proc selectDir(p: var RstParser, d: string): PRstNode =
+  result = nil
+  let tok = p.tok[p.idx-2] # report on directive in ".. directive::"
+  if roSandboxDisabled notin p.s.options:
+    if d notin SandboxDirAllowlist:
+      rstMessage(p, meSandboxedDirective, d, tok.line, tok.col)
+
+  case d
+  of "admonition", "attention", "caution": result = dirAdmonition(p, d)
+  of "code": result = dirCodeBlock(p)
+  of "code-block": result = dirCodeBlock(p, nimExtension = true)
+  of "container": result = dirContainer(p)
+  of "contents": result = dirContents(p)
+  of "danger": result = dirAdmonition(p, d)
+  of "default-role": result = dirDefaultRole(p)
+  of "error": result = dirAdmonition(p, d)
+  of "figure": result = dirFigure(p)
+  of "hint": result = dirAdmonition(p, d)
+  of "image": result = dirImage(p)
+  of "important": result = dirAdmonition(p, d)
+  of "importdoc": result = dirImportdoc(p)
+  of "include": result = dirInclude(p)
+  of "index": result = dirIndex(p)
+  of "note": result = dirAdmonition(p, d)
+  of "raw":
+    if roSupportRawDirective in p.s.options:
+      result = dirRaw(p)
+    else:
+      rstMessage(p, meInvalidDirective, d)
+  of "role": result = dirRole(p)
+  of "tip": result = dirAdmonition(p, d)
+  of "title": result = dirTitle(p)
+  of "warning": result = dirAdmonition(p, d)
+  else:
+    rstMessage(p, meInvalidDirective, d, tok.line, tok.col)
+
+proc parseDotDot(p: var RstParser): PRstNode =
+  # parse "explicit markup blocks"
+  result = nil
+  var n: PRstNode  # to store result, workaround for bug 16855
+  var col = currentTok(p).col
+  inc p.idx
+  var d = getDirective(p)
+  if d != "":
+    pushInd(p, col)
+    result = selectDir(p, d)
+    popInd(p)
+  elif match(p, p.idx, " _"):
+    # hyperlink target:
+    inc p.idx, 2
+    var ending = ":"
+    if currentTok(p).symbol == "`":
+      inc p.idx
+      ending = "`"
+    var a = getReferenceName(p, ending)
+    if ending == "`":
+      if currentTok(p).symbol == ":":
+        inc p.idx
+      else:
+        rstMessage(p, meExpected, ":")
+    if currentTok(p).kind == tkWhite: inc p.idx
+    var b = untilEol(p)
+    if len(b) == 0:  # set internal anchor
+      p.curAnchors.add ManualAnchor(
+        alias: linkName(a), anchor: rstnodeToRefname(a), info: prevLineInfo(p)
+      )
+    else:  # external hyperlink
+      setRef(p, rstnodeToRefname(a), b, refType=hyperlinkAlias)
+  elif match(p, p.idx, " |"):
+    # substitution definitions:
+    inc p.idx, 2
+    var a = getReferenceName(p, "|")
+    var b: PRstNode
+    if currentTok(p).kind == tkWhite: inc p.idx
+    if cmpIgnoreStyle(currentTok(p).symbol, "replace") == 0:
+      inc p.idx
+      expect(p, "::")
+      b = untilEol(p)
+    elif cmpIgnoreStyle(currentTok(p).symbol, "image") == 0:
+      inc p.idx
+      b = dirImage(p)
+    else:
+      rstMessage(p, meInvalidDirective, currentTok(p).symbol)
+    setSub(p, addNodes(a), b)
+  elif match(p, p.idx, " [") and
+      (n = parseFootnote(p); n != nil):
+    result = n
+  else:
+    result = parseComment(p, col)
+
+proc rstParsePass1*(fragment: string,
+                    line, column: int,
+                    sharedState: PRstSharedState): PRstNode =
+  ## Parses an RST `fragment`.
+  ## The result should be further processed by
+  ## preparePass2_ and resolveSubs_ (which is pass 2).
+  var p: RstParser
+  initParser(p, sharedState)
+  p.line = line
+  p.col = column
+  getTokens(fragment, p.tok)
+  result = parseDoc(p)
+
+proc extractLinkEnd(x: string): string =
+  ## From links like `path/to/file.html#/%` extract `file.html#/%`.
+  let i = find(x, '#')
+  let last =
+    if i >= 0: i
+    else: x.len - 1
+  let j = rfind(x, '/', start=0, last=last)
+  if j >= 0:
+    result = x[j+1 .. ^1]
+  else:
+    result = x
+
+proc loadIdxFile(s: var PRstSharedState, origFilename: string) =
+  doAssert roSandboxDisabled in s.options
+  var info: TLineInfo
+  info.fileIndex = addFilename(s, origFilename)
+  var (dir, basename, ext) = origFilename.splitFile
+  if ext notin [".md", ".rst", ".nim", ""]:
+    rstMessage(s.filenames, s.msgHandler, s.idxImports[origFilename].fromInfo,
+               meCannotOpenFile, origFilename & ": unknown extension")
+  let idxFilename = dir / basename & ".idx"
+  let (idxPath, linkRelPath) = s.findRefFile(idxFilename)
+  s.idxImports[origFilename].linkRelPath = linkRelPath
+  var
+    fileEntries: seq[IndexEntry]
+    title: IndexEntry
+  try:
+    (fileEntries, title) = parseIdxFile(idxPath)
+  except IOError:
+    rstMessage(s.filenames, s.msgHandler, s.idxImports[origFilename].fromInfo,
+               meCannotOpenFile, idxPath)
+  except ValueError as e:
+    s.msgHandler(idxPath, LineRstInit, ColRstInit, meInvalidField, e.msg)
+
+  var isMarkup = false  # for sanity check to avoid mixing .md <-> .nim
+  for entry in fileEntries:
+    # Though target .idx already has inside it the path to HTML relative
+    # project's root, we won't rely on it and use `linkRelPath` instead.
+    let refn = extractLinkEnd(entry.link)
+    # select either markup (rst/md) or Nim cases:
+    if entry.kind in {ieMarkupTitle, ieNimTitle}:
+      s.idxImports[origFilename].title = entry.keyword
+    case entry.kind
+    of ieIdxRole, ieHeading, ieMarkupTitle:
+      if ext == ".nim" and entry.kind == ieMarkupTitle:
+        rstMessage(s, idxPath, meInvalidField,
+                   $ieMarkupTitle & " in supposedly .nim-derived file")
+      if entry.kind == ieMarkupTitle:
+        isMarkup = true
+      info.line = entry.line.uint16
+      addAnchorExtRst(s, key = entry.keyword, refn = refn,
+                      anchorType = headlineAnchor, info=info)
+    of ieNim, ieNimGroup, ieNimTitle:
+      if ext in [".md", ".rst"] or isMarkup:
+        rstMessage(s, idxPath, meInvalidField,
+                   $entry.kind & " in supposedly markup-derived file")
+      s.nimFileImported = true
+      var langSym: LangSymbol
+      if entry.kind in {ieNim, ieNimTitle}:
+        var q: RstParser
+        initParser(q, s)
+        info.line = entry.line.uint16
+        setLen(q.tok, 0)
+        q.idx = 0
+        getTokens(entry.linkTitle, q.tok)
+        var sons = newSeq[PRstNode](q.tok.len)
+        for i in 0 ..< q.tok.len: sons[i] = newLeaf(q.tok[i].symbol)
+        let linkTitle = newRstNode(rnInner, sons)
+        langSym = linkTitle.toLangSymbol
+      else:  # entry.kind == ieNimGroup
+        langSym = langSymbolGroup(kind=entry.linkTitle, name=entry.keyword)
+      addAnchorNim(s, external = true, refn = refn, tooltip = entry.linkDesc,
+                   langSym = langSym, priority = -4, # lowest
+                   info = info, module = info.fileIndex)
+  doAssert s.idxImports[origFilename].title != ""
+
+proc preparePass2*(s: var PRstSharedState, mainNode: PRstNode, importdoc = true) =
+  ## Records titles in node `mainNode` and orders footnotes.
+  countTitles(s, mainNode)
+  fixHeadlines(s)
+  orderFootnotes(s)
+  if importdoc:
+    for origFilename in s.idxImports.keys:
+      loadIdxFile(s, origFilename)
+
+proc resolveLink(s: PRstSharedState, n: PRstNode) : PRstNode =
+  # Associate this link alias with its target and change node kind to
+  # rnHyperlink or rnInternalRef appropriately.
+  var desc, alias: PRstNode
+  if n.kind == rnPandocRef:  # link like [desc][alias]
+    desc = n.sons[0]
+    alias = n.sons[1]
+  else:  # n.kind == rnRstRef, link like `desc=alias`_
+    desc = n
+    alias = n
+  type LinkDef = object
+    ar: AnchorRule
+    priority: int
+    tooltip: string
+    target: PRstNode
+    info: TLineInfo
+    externFilename: string
+      # when external anchor: origin filename where anchor was defined
+    isTitle: bool
+  proc cmp(x, y: LinkDef): int =
+    result = cmp(x.priority, y.priority)
+    if result == 0:
+      result = cmp(x.target, y.target)
+  var foundLinks: seq[LinkDef]
+  let refn = rstnodeToRefname(alias)
+  var hyperlinks = findRef(s, refn)
+  for y in hyperlinks:
+    foundLinks.add LinkDef(ar: arHyperlink, priority: refPriority(y.kind),
+                           target: y.value, info: y.info,
+                           tooltip: "(" & $y.kind & ")")
+  let substRst = findMainAnchorRst(s, alias.addNodes, n.info)
+  template getExternFilename(subst: AnchorSubst): string =
+    if subst.kind == arExternalRst or
+        (subst.kind == arNim and subst.external):
+      getFilename(s, subst)
+    else: ""
+  for subst in substRst:
+    var refname, fullRefname: string
+    if subst.kind == arInternalRst:
+      refname = subst.target.anchor
+      fullRefname = refname
+    else:  # arExternalRst
+      refname = subst.refnameExt
+      fullRefname = s.idxImports[getFilename(s, subst)].linkRelPath &
+                      "/" & refname
+    let anchorType =
+      if subst.kind == arInternalRst: subst.anchorType
+      else: subst.anchorTypeExt  # arExternalRst
+    foundLinks.add LinkDef(ar: subst.kind, priority: subst.priority,
+                           target: newLeaf(fullRefname),
+                           info: subst.info,
+                           externFilename: getExternFilename(subst),
+                           isTitle: isDocumentationTitle(refname),
+                           tooltip: "(" & $anchorType & ")")
+  # find anchors automatically generated from Nim symbols
+  if roNimFile in s.options or s.nimFileImported:
+    let substNim = findMainAnchorNim(s, signature=alias, n.info)
+    for subst in substNim:
+      let fullRefname =
+        if subst.external:
+          s.idxImports[getFilename(s, subst)].linkRelPath &
+              "/" & subst.refname
+        else: subst.refname
+      foundLinks.add LinkDef(ar: subst.kind, priority: subst.priority,
+                             target: newLeaf(fullRefname),
+                             externFilename: getExternFilename(subst),
+                             isTitle: isDocumentationTitle(subst.refname),
+                             info: subst.info, tooltip: subst.tooltip)
+  foundLinks.sort(cmp = cmp, order = Descending)
+  let aliasStr = addNodes(alias)
+  if foundLinks.len >= 1:
+    if foundLinks[0].externFilename != "":
+      s.idxImports[foundLinks[0].externFilename].used = true
+    let kind = if foundLinks[0].ar in {arHyperlink, arExternalRst}: rnHyperlink
+               elif foundLinks[0].ar == arNim:
+                 if foundLinks[0].externFilename == "": rnNimdocRef
+                 else: rnHyperlink
+               else: rnInternalRef
+    result = newRstNode(kind)
+    let documentName =  # filename without ext for `.nim`, title for `.md`
+      if foundLinks[0].ar == arNim:
+        changeFileExt(foundLinks[0].externFilename.extractFilename, "")
+      elif foundLinks[0].externFilename != "":
+        s.idxImports[foundLinks[0].externFilename].title
+      else: foundLinks[0].externFilename.extractFilename
+    let linkText =
+      if foundLinks[0].externFilename != "":
+        if foundLinks[0].isTitle: newLeaf(addNodes(desc))
+        else: newLeaf(documentName & ": " & addNodes(desc))
+      else:
+        newRstNode(rnInner, desc.sons)
+    result.sons = @[linkText, foundLinks[0].target]
+    if kind == rnNimdocRef: result.tooltip = foundLinks[0].tooltip
+    if foundLinks.len > 1:  # report ambiguous link
+      var targets = newSeq[string]()
+      for l in foundLinks:
+        var t = "    "
+        if s.filenames.len > 1:
+          t.add getFilename(s.filenames, l.info.fileIndex)
+        let n = l.info.line
+        let c = l.info.col + ColRstOffset
+        t.add "($1, $2): $3" % [$n, $c, l.tooltip]
+        targets.add t
+      rstMessage(s.filenames, s.msgHandler, n.info, mwAmbiguousLink,
+                 "`$1`\n  clash:\n$2" % [
+                   aliasStr, targets.join("\n")])
+  else:  # nothing found
+    result = n
+    rstMessage(s.filenames, s.msgHandler, n.info, mwBrokenLink, aliasStr)
+
+proc resolveSubs*(s: PRstSharedState, n: PRstNode): PRstNode =
+  ## Makes pass 2 of RST parsing.
+  ## Resolves substitutions and anchor aliases, groups footnotes.
+  ## Takes input node `n` and returns the same node with recursive
+  ## substitutions in `n.sons` to `result`.
+  result = n
+  if n == nil: return
+  case n.kind
+  of rnSubstitutionReferences:
+    var x = findSub(s, n)
+    if x >= 0:
+      result = s.subs[x].value
+    else:
+      var key = addNodes(n)
+      var e = getEnv(key)
+      if e != "": result = newLeaf(e)
+      else: rstMessage(s.filenames, s.msgHandler, n.info,
+                       mwUnknownSubstitution, key)
+  of rnRstRef, rnPandocRef:
+    result = resolveLink(s, n)
+  of rnFootnote:
+    var (fnType, num) = getFootnoteType(s, n.sons[0])
+    case fnType
+    of fnManualNumber, fnCitation:
+      discard "no need to alter fixed text"
+    of fnAutoNumberLabel, fnAutoNumber:
+      if fnType == fnAutoNumberLabel:
+        let labelR = rstnodeToRefname(n.sons[0])
+        num = getFootnoteNum(s, labelR)
+      else:
+        num = getFootnoteNum(s, n.order)
+      var nn = newRstNode(rnInner)
+      nn.add newLeaf($num)
+      result.sons[0] = nn
+    of fnAutoSymbol:
+      let sym = getAutoSymbol(s, n.order)
+      n.sons[0].sons[0].text = sym
+    n.sons[1] = resolveSubs(s, n.sons[1])
+  of rnFootnoteRef:
+    var (fnType, num) = getFootnoteType(s, n.sons[0])
+    template addLabel(number: int | string) =
+      var nn = newRstNode(rnInner)
+      nn.add newLeaf($number)
+      result.add(nn)
+    var refn = fnType.prefix
+    # create new rnFootnoteRef, add final label, and finalize target refn:
+    result = newRstNode(rnFootnoteRef, info = n.info)
+    case fnType
+    of fnManualNumber:
+      addLabel num
+      refn.add $num
+    of fnAutoNumber:
+      inc s.currFootnoteNumRef
+      addLabel getFootnoteNum(s, s.currFootnoteNumRef)
+      refn.add $s.currFootnoteNumRef
+    of fnAutoNumberLabel:
+      addLabel getFootnoteNum(s, rstnodeToRefname(n))
+      refn.add rstnodeToRefname(n)
+    of fnAutoSymbol:
+      inc s.currFootnoteSymRef
+      addLabel getAutoSymbol(s, s.currFootnoteSymRef)
+      refn.add $s.currFootnoteSymRef
+    of fnCitation:
+      result.add n.sons[0]
+      refn.add rstnodeToRefname(n)
+    # TODO: correctly report ambiguities
+    let anchorInfo = findMainAnchorRst(s, refn, n.info)
+    if anchorInfo.len != 0:
+      result.add newLeaf(anchorInfo[0].target.anchor)  # add link
+    else:
+      rstMessage(s.filenames, s.msgHandler, n.info, mwBrokenLink, refn)
+      result.add newLeaf(refn)  # add link
+  of rnLeaf:
+    discard
+  else:
+    var regroup = false
+    for i in 0 ..< n.len:
+      n.sons[i] = resolveSubs(s, n.sons[i])
+      if n.sons[i] != nil and n.sons[i].kind == rnFootnote:
+        regroup = true
+    if regroup:  # group footnotes together into rnFootnoteGroup
+      var newSons: seq[PRstNode]
+      var i = 0
+      while i < n.len:
+        if n.sons[i] != nil and n.sons[i].kind == rnFootnote:
+          var grp = newRstNode(rnFootnoteGroup)
+          while i < n.len and n.sons[i].kind == rnFootnote:
+            grp.sons.add n.sons[i]
+            inc i
+          newSons.add grp
+        else:
+          newSons.add n.sons[i]
+          inc i
+      result.sons = newSons
+
+proc completePass2*(s: PRstSharedState) =
+  for (filename, importdocInfo) in s.idxImports.pairs:
+    if not importdocInfo.used:
+      rstMessage(s.filenames, s.msgHandler, importdocInfo.fromInfo,
+                 mwUnusedImportdoc, filename)
+
+proc rstParse*(text, filename: string,
+               line, column: int,
+               options: RstParseOptions,
+               findFile: FindFileHandler = nil,
+               findRefFile: FindRefFileHandler = nil,
+               msgHandler: MsgHandler = nil):
+              tuple[node: PRstNode, filenames: RstFileTable, hasToc: bool] =
+  ## Parses the whole `text`. The result is ready for `rstgen.renderRstToOut`,
+  ## note that 2nd tuple element should be fed to `initRstGenerator`
+  ## argument `filenames` (it is being filled here at least with `filename`
+  ## and possibly with other files from RST ``.. include::`` statement).
+  var sharedState = newRstSharedState(options, filename, findFile, findRefFile,
+                                      msgHandler, hasToc=false)
+  let unresolved = rstParsePass1(text, line, column, sharedState)
+  preparePass2(sharedState, unresolved)
+  result.node = resolveSubs(sharedState, unresolved)
+  completePass2(sharedState)
+  result.filenames = sharedState.filenames
+  result.hasToc = sharedState.hasToc
diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim
new file mode 100644
index 000000000..2bbb0d0b8
--- /dev/null
+++ b/lib/packages/docutils/rstast.nim
@@ -0,0 +1,444 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements an AST for the `reStructuredText`:idx: parser.
+
+import std/[strutils, json]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  RstNodeKind* = enum        ## the possible node kinds of an PRstNode
+    rnInner,                  # an inner node or a root
+    rnHeadline,               # a headline
+    rnOverline,               # an over- and underlined headline
+    rnMarkdownHeadline,       # a Markdown headline
+    rnTransition,             # a transition (the ------------- <hr> thingie)
+    rnParagraph,              # a paragraph
+    rnBulletList,             # a bullet list
+    rnBulletItem,             # a bullet item
+    rnEnumList,               # an enumerated list
+    rnEnumItem,               # an enumerated item
+    rnDefList, rnMdDefList,   # a definition list (RST/Markdown)
+    rnDefItem,                # an item of a definition list consisting of ...
+    rnDefName,                # ... a name part ...
+    rnDefBody,                # ... and a body part ...
+    rnFieldList,              # a field list
+    rnField,                  # a field item
+    rnFieldName,              # consisting of a field name ...
+    rnFieldBody,              # ... and a field body
+    rnOptionList, rnOptionListItem, rnOptionGroup, rnOption, rnOptionString,
+    rnOptionArgument, rnDescription, rnLiteralBlock,
+    rnMarkdownBlockQuote,     # a quote starting from punctuation like >>>
+    rnMarkdownBlockQuoteItem, # a quotation block, quote lines starting with
+                              # the same number of chars
+    rnLineBlock,              # the | thingie
+    rnLineBlockItem,          # a son of rnLineBlock - one line inside it.
+                              # When `RstNode` lineIndent="\n" the line's empty
+    rnBlockQuote,             # text just indented
+    rnTable, rnGridTable, rnMarkdownTable, rnTableRow, rnTableHeaderCell, rnTableDataCell,
+    rnFootnote,               # a footnote
+    rnCitation,               # similar to footnote, so use rnFootnote instead
+    rnFootnoteGroup,          # footnote group - exists for a purely stylistic
+                              # reason: to display a few footnotes as 1 block
+    rnStandaloneHyperlink, rnHyperlink,
+    rnRstRef,                 # RST reference like `section name`_
+    rnPandocRef,              # Pandoc Markdown reference like [section name]
+    rnInternalRef, rnFootnoteRef,
+    rnNimdocRef,              # reference to automatically generated Nim symbol
+    rnDirective,              # a general directive
+    rnDirArg,                 # a directive argument (for some directives).
+                              # here are directives that are not rnDirective:
+    rnRaw, rnTitle, rnContents, rnImage, rnFigure, rnCodeBlock, rnAdmonition,
+    rnRawHtml, rnRawLatex,
+    rnContainer,              # ``container`` directive
+    rnIndex,                  # index directve:
+                              # .. index::
+                              #   key
+                              #     * `file#id <file#id>`_
+                              #     * `file#id <file#id>'_
+    rnSubstitutionDef,        # a definition of a substitution
+    # Inline markup:
+    rnInlineCode,             # interpreted text with code in a known language
+    rnCodeFragment,           # inline code for highlighting with the specified
+                              # class (which cannot be inferred from context)
+    rnUnknownRole,            # interpreted text with an unknown role
+    rnSub, rnSup, rnIdx,
+    rnEmphasis,               # "*"
+    rnStrongEmphasis,         # "**"
+    rnTripleEmphasis,         # "***"
+    rnInterpretedText,        # "`" an auxiliary role for parsing that will
+                              # be converted into other kinds like rnInlineCode
+    rnInlineLiteral,          # "``"
+    rnInlineTarget,           # "_`target`"
+    rnSubstitutionReferences, # "|"
+    rnSmiley,                 # some smiley
+    rnDefaultRole,            # .. default-role:: code
+    rnLeaf                    # a leaf; the node's text field contains the
+                              # leaf val
+
+  FileIndex* = distinct int32
+  TLineInfo* = object
+    line*: uint16
+    col*: int16
+    fileIndex*: FileIndex
+
+  PRstNode* = ref RstNode    ## an RST node
+  RstNodeSeq* = seq[PRstNode]
+  RstNode* {.acyclic, final.} = object ## AST node (result of RST parsing)
+    case kind*: RstNodeKind ## the node's kind
+    of rnLeaf, rnSmiley:
+      text*: string           ## string that is expected to be displayed
+    of rnEnumList:
+      labelFmt*: string       ## label format like "(1)"
+    of rnLineBlockItem:
+      lineIndent*: string     ## a few spaces or newline at the line beginning
+    of rnAdmonition:
+      adType*: string         ## admonition type: "note", "caution", etc. This
+                              ## text will set the style and also be displayed
+    of rnOverline, rnHeadline, rnMarkdownHeadline:
+      level*: int             ## level of headings starting from 1 (main
+                              ## chapter) to larger ones (minor sub-sections)
+                              ## level=0 means it's document title or subtitle
+    of rnFootnote, rnCitation, rnOptionListItem:
+      order*: int             ## footnote order (for auto-symbol footnotes and
+                              ## auto-numbered ones without a label)
+    of rnMarkdownBlockQuoteItem:
+      quotationDepth*: int    ## number of characters in line prefix
+    of rnRstRef, rnPandocRef, rnSubstitutionReferences,
+        rnInterpretedText, rnField, rnInlineCode, rnCodeBlock, rnFootnoteRef:
+      info*: TLineInfo        ## To have line/column info for warnings at
+                              ## nodes that are post-processed after parsing
+    of rnNimdocRef:
+      tooltip*: string
+    of rnTable, rnGridTable, rnMarkdownTable:
+      colCount*: int          ## Number of (not-united) cells in the table
+    of rnTableRow:
+      endsHeader*: bool       ## Is last row in the header of table?
+    of rnTableHeaderCell, rnTableDataCell:
+      span*: int              ## Number of table columns that the cell occupies
+    else:
+      discard
+    anchor*: string           ## anchor, internal link target
+                              ## (aka HTML id tag, aka Latex label/hypertarget)
+    sons*: RstNodeSeq        ## the node's sons
+
+proc `==`*(a, b: FileIndex): bool {.borrow.}
+
+proc len*(n: PRstNode): int =
+  result = len(n.sons)
+
+proc newRstNode*(kind: RstNodeKind, sons: seq[PRstNode] = @[],
+                 anchor = ""): PRstNode =
+  result = PRstNode(kind: kind, sons: sons, anchor: anchor)
+
+proc newRstNode*(kind: RstNodeKind, info: TLineInfo,
+                 sons: seq[PRstNode] = @[]): PRstNode =
+  result = PRstNode(kind: kind, sons: sons)
+  result.info = info
+
+proc newRstNode*(kind: RstNodeKind, s: string): PRstNode {.deprecated.} =
+  assert kind in {rnLeaf, rnSmiley}
+  result = newRstNode(kind)
+  result.text = s
+
+proc newRstLeaf*(s: string): PRstNode =
+  result = newRstNode(rnLeaf)
+  result.text = s
+
+proc lastSon*(n: PRstNode): PRstNode =
+  result = n.sons[len(n.sons)-1]
+
+proc add*(father, son: PRstNode) =
+  add(father.sons, son)
+
+proc add*(father: PRstNode; s: string) =
+  add(father.sons, newRstLeaf(s))
+
+proc addIfNotNil*(father, son: PRstNode) =
+  if son != nil: add(father, son)
+
+
+type
+  RenderContext {.pure.} = object
+    indent: int
+    verbatim: int
+
+proc renderRstToRst(d: var RenderContext, n: PRstNode,
+                    result: var string) {.gcsafe.}
+
+proc renderRstSons(d: var RenderContext, n: PRstNode, result: var string) =
+  for i in countup(0, len(n) - 1):
+    renderRstToRst(d, n.sons[i], result)
+
+proc renderRstToRst(d: var RenderContext, n: PRstNode, result: var string) =
+  # this is needed for the index generation; it may also be useful for
+  # debugging, but most code is already debugged...
+  const
+    lvlToChar: array[0..8, char] = ['!', '=', '-', '~', '`', '<', '*', '|', '+']
+  if n == nil: return
+  var ind = spaces(d.indent)
+  case n.kind
+  of rnInner:
+    renderRstSons(d, n, result)
+  of rnHeadline:
+    result.add("\n")
+    result.add(ind)
+
+    let oldLen = result.len
+    renderRstSons(d, n, result)
+    let headlineLen = result.len - oldLen
+
+    result.add("\n")
+    result.add(ind)
+    result.add repeat(lvlToChar[n.level], headlineLen)
+  of rnOverline:
+    result.add("\n")
+    result.add(ind)
+
+    var headline = ""
+    renderRstSons(d, n, headline)
+
+    let lvl = repeat(lvlToChar[n.level], headline.len - d.indent)
+    result.add(lvl)
+    result.add("\n")
+    result.add(headline)
+
+    result.add("\n")
+    result.add(ind)
+    result.add(lvl)
+  of rnTransition:
+    result.add("\n\n")
+    result.add(ind)
+    result.add repeat('-', 78-d.indent)
+    result.add("\n\n")
+  of rnParagraph:
+    result.add("\n\n")
+    result.add(ind)
+    renderRstSons(d, n, result)
+  of rnBulletItem:
+    inc(d.indent, 2)
+    var tmp = ""
+    renderRstSons(d, n, tmp)
+    if tmp.len > 0:
+      result.add("\n")
+      result.add(ind)
+      result.add("* ")
+      result.add(tmp)
+    dec(d.indent, 2)
+  of rnEnumItem:
+    inc(d.indent, 4)
+    var tmp = ""
+    renderRstSons(d, n, tmp)
+    if tmp.len > 0:
+      result.add("\n")
+      result.add(ind)
+      result.add("(#) ")
+      result.add(tmp)
+    dec(d.indent, 4)
+  of rnOptionList, rnFieldList, rnDefList, rnDefItem, rnLineBlock, rnFieldName,
+     rnFieldBody, rnStandaloneHyperlink, rnBulletList, rnEnumList:
+    renderRstSons(d, n, result)
+  of rnDefName:
+    result.add("\n\n")
+    result.add(ind)
+    renderRstSons(d, n, result)
+  of rnDefBody:
+    inc(d.indent, 2)
+    if n.sons[0].kind != rnBulletList:
+      result.add("\n")
+      result.add(ind)
+      result.add("  ")
+    renderRstSons(d, n, result)
+    dec(d.indent, 2)
+  of rnField:
+    var tmp = ""
+    renderRstToRst(d, n.sons[0], tmp)
+
+    var L = max(tmp.len + 3, 30)
+    inc(d.indent, L)
+
+    result.add "\n"
+    result.add ind
+    result.add ':'
+    result.add tmp
+    result.add ':'
+    result.add spaces(L - tmp.len - 2)
+    renderRstToRst(d, n.sons[1], result)
+
+    dec(d.indent, L)
+  of rnLineBlockItem:
+    result.add("\n")
+    result.add(ind)
+    result.add("| ")
+    renderRstSons(d, n, result)
+  of rnBlockQuote:
+    inc(d.indent, 2)
+    renderRstSons(d, n, result)
+    dec(d.indent, 2)
+  of rnRstRef:
+    result.add("`")
+    renderRstSons(d, n, result)
+    result.add("`_")
+  of rnHyperlink:
+    result.add('`')
+    renderRstToRst(d, n.sons[0], result)
+    result.add(" <")
+    renderRstToRst(d, n.sons[1], result)
+    result.add(">`_")
+  of rnUnknownRole:
+    result.add('`')
+    renderRstToRst(d, n.sons[0],result)
+    result.add("`:")
+    renderRstToRst(d, n.sons[1],result)
+    result.add(':')
+  of rnSub:
+    result.add('`')
+    renderRstSons(d, n, result)
+    result.add("`:sub:")
+  of rnSup:
+    result.add('`')
+    renderRstSons(d, n, result)
+    result.add("`:sup:")
+  of rnIdx:
+    result.add('`')
+    renderRstSons(d, n, result)
+    result.add("`:idx:")
+  of rnEmphasis:
+    result.add("*")
+    renderRstSons(d, n, result)
+    result.add("*")
+  of rnStrongEmphasis:
+    result.add("**")
+    renderRstSons(d, n, result)
+    result.add("**")
+  of rnTripleEmphasis:
+    result.add("***")
+    renderRstSons(d, n, result)
+    result.add("***")
+  of rnInterpretedText:
+    result.add('`')
+    renderRstSons(d, n, result)
+    result.add('`')
+  of rnInlineLiteral:
+    inc(d.verbatim)
+    result.add("``")
+    renderRstSons(d, n, result)
+    result.add("``")
+    dec(d.verbatim)
+  of rnSmiley:
+    result.add(n.text)
+  of rnLeaf:
+    if d.verbatim == 0 and n.text == "\\":
+      result.add("\\\\") # XXX: escape more special characters!
+    else:
+      result.add(n.text)
+  of rnIndex:
+    result.add("\n\n")
+    result.add(ind)
+    result.add(".. index::\n")
+
+    inc(d.indent, 3)
+    if n.sons[2] != nil: renderRstSons(d, n.sons[2], result)
+    dec(d.indent, 3)
+  of rnContents:
+    result.add("\n\n")
+    result.add(ind)
+    result.add(".. contents::")
+  else:
+    result.add("Error: cannot render: " & $n.kind)
+
+proc renderRstToRst*(n: PRstNode, result: var string) =
+  ## renders `n` into its string representation and appends to `result`.
+  var d: RenderContext
+  renderRstToRst(d, n, result)
+
+proc renderRstToJsonNode(node: PRstNode): JsonNode =
+  result =
+    %[
+      (key: "kind", val: %($node.kind)),
+      (key: "level", val: %BiggestInt(node.level))
+     ]
+  if node.kind in {rnLeaf, rnSmiley} and node.text.len > 0:
+    result.add("text", %node.text)
+  if len(node.sons) > 0:
+    var accm = newSeq[JsonNode](len(node.sons))
+    for i, son in node.sons:
+      accm[i] = renderRstToJsonNode(son)
+    result.add("sons", %accm)
+
+proc renderRstToJson*(node: PRstNode): string =
+  ## Writes the given RST node as JSON that is in the form
+  ##
+  ##     {
+  ##       "kind":string node.kind,
+  ##       "text":optional string node.text,
+  ##       "level":optional int node.level,
+  ##       "sons":optional node array
+  ##     }
+  renderRstToJsonNode(node).pretty
+
+proc renderRstToText*(node: PRstNode): string =
+  ## minimal text representation of markup node
+  const code = {rnCodeFragment, rnInterpretedText, rnInlineLiteral, rnInlineCode}
+  if node == nil:
+    return ""
+  case node.kind
+  of rnLeaf, rnSmiley:
+    result.add node.text
+  else:
+    if node.kind in code: result.add "`"
+    for i in 0 ..< node.sons.len:
+      if node.kind in {rnInlineCode, rnCodeBlock} and i == 0:
+        continue  # omit language specifier
+      result.add renderRstToText(node.sons[i])
+    if node.kind in code: result.add "`"
+
+proc treeRepr*(node: PRstNode, indent=0): string =
+  ## Writes the parsed RST `node` into an AST tree with compact string
+  ## representation in the format (one line per every sub-node):
+  ## ``indent - kind - [text|level|order|adType] - anchor (if non-zero)``
+  ## (suitable for debugging of RST parsing).
+  if node == nil:
+    result.add " ".repeat(indent) & "[nil]\n"
+    return
+  result.add " ".repeat(indent) & $node.kind
+  case node.kind
+  of rnLeaf, rnSmiley:
+    result.add (if node.text == "": "" else: "  '" & node.text & "'")
+  of rnEnumList:
+    result.add "  labelFmt=" & node.labelFmt
+  of rnLineBlockItem:
+    var txt: string
+    if node.lineIndent == "\n": txt = "  (blank line)"
+    else: txt = "  lineIndent=" & $node.lineIndent.len
+    result.add txt
+  of rnAdmonition:
+    result.add "  adType=" & node.adType
+  of rnHeadline, rnOverline, rnMarkdownHeadline:
+    result.add "  level=" & $node.level
+  of rnFootnote, rnCitation, rnOptionListItem:
+    result.add (if node.order == 0:   "" else: "  order=" & $node.order)
+  of rnMarkdownBlockQuoteItem:
+    result.add "  quotationDepth=" & $node.quotationDepth
+  of rnTable, rnGridTable, rnMarkdownTable:
+    result.add "  colCount=" & $node.colCount
+  of rnTableHeaderCell, rnTableDataCell:
+    if node.span > 0:
+      result.add "  span=" & $node.span
+  of rnTableRow:
+    if node.endsHeader: result.add "  endsHeader"
+  else:
+    discard
+  result.add (if node.anchor == "": "" else: "  anchor='" & node.anchor & "'")
+  result.add "\n"
+  for son in node.sons:
+    result.add treeRepr(son, indent=indent+2)
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim
new file mode 100644
index 000000000..7fc0ac03a
--- /dev/null
+++ b/lib/packages/docutils/rstgen.nim
@@ -0,0 +1,1566 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a generator of HTML/Latex from
+## `reStructuredText`:idx: (see http://docutils.sourceforge.net/rst.html for
+## information on this markup syntax) and is used by the compiler's `docgen
+## tools <docgen.html>`_.
+##
+## You can generate HTML output through the convenience proc ``rstToHtml``,
+## which provided an input string with rst markup returns a string with the
+## generated HTML. The final output is meant to be embedded inside a full
+## document you provide yourself, so it won't contain the usual ``<header>`` or
+## ``<body>`` parts.
+##
+## You can also create a ``RstGenerator`` structure and populate it with the
+## other lower level methods to finally build complete documents. This requires
+## many options and tweaking, but you are not limited to snippets and can
+## generate `LaTeX documents <https://en.wikipedia.org/wiki/LaTeX>`_ too.
+##
+## `Docutils configuration files`_ are not supported. Instead HTML generation
+## can be tweaked by editing file ``config/nimdoc.cfg``.
+##
+## .. _Docutils configuration files: https://docutils.sourceforge.io/docs/user/config.htm
+##
+## There are stylistic difference between how this module renders some elements
+## and how original Python Docutils does:
+##
+## * Backreferences to TOC in section headings are not generated.
+##   In HTML each section is also a link that points to the section itself:
+##   this is done for user to be able to copy the link into clipboard.
+##
+## * The same goes for footnotes/citations links: they point to themselves.
+##   No backreferences are generated since finding all references of a footnote
+##   can be done by simply searching for ``[footnoteName]``.
+
+import std/[strutils, os, hashes, strtabs, tables, sequtils,
+  algorithm, parseutils, strbasics]
+
+import rstast, rst, rstidx, highlite
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio, formatfloat]
+
+
+import ../../std/private/since
+
+const
+  HtmlExt = "html"
+  IndexExt* = ".idx"
+
+type
+  OutputTarget* = enum ## which document type to generate
+    outHtml,            # output is HTML
+    outLatex            # output is Latex
+
+  MetaEnum* = enum
+    metaNone, metaTitleRaw, metaTitle, metaSubtitle, metaAuthor, metaVersion
+
+  EscapeMode* = enum  # in Latex text inside options [] and URLs is
+                      # escaped slightly differently than in normal text
+    emText, emOption, emUrl  # emText is currently used for code also
+
+  RstGenerator* = object of RootObj
+    target*: OutputTarget
+    config*: StringTableRef
+    splitAfter*: int          # split too long entries in the TOC
+    listingCounter*: int
+    tocPart*: seq[PRstNode]   # headings for Table of Contents
+    hasToc*: bool
+    theIndex: string # Contents of the index file to be dumped at the end.
+    findFile*: FindFileHandler
+    msgHandler*: MsgHandler
+    outDir*: string      ## output directory, initialized by docgen.nim
+    destFile*: string    ## output (HTML) file, initialized by docgen.nim
+    filenames*: RstFileTable
+    filename*: string         ## source Nim or Rst file
+    meta*: array[MetaEnum, string]
+    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: Table[string, int] ## \
+    ## Keeps count of same text index terms to generate different identifiers
+    ## for hyperlinks. See renderIndexTerm proc for details.
+    id*: int               ## A counter useful for generating IDs.
+    onTestSnippet*: proc (d: var RstGenerator; filename, cmd: string; status: int;
+                          content: string) {.gcsafe.}
+    escMode*: EscapeMode
+    curQuotationDepth: int
+
+  PDoc = var RstGenerator ## Alias to type less.
+
+  CodeBlockParams = object ## Stores code block params.
+    numberLines: bool ## True if the renderer has to show line numbers.
+    startLine: int ## The starting line of the code block, by default 1.
+    langStr: string ## Input string used to specify the language.
+    lang: SourceLanguage ## Type of highlighting, by default none.
+    filename: string
+    testCmd: string
+    status: int
+
+proc prettyLink*(file: string): string =
+  changeFileExt(file, "").replace("_._", "..")
+
+proc init(p: var CodeBlockParams) =
+  ## Default initialisation of CodeBlockParams to sane values.
+  p.startLine = 1
+  p.lang = langNone
+  p.langStr = ""
+
+proc initRstGenerator*(g: var RstGenerator, target: OutputTarget,
+                       config: StringTableRef, filename: string,
+                       findFile: FindFileHandler = nil,
+                       msgHandler: MsgHandler = nil,
+                       filenames = default(RstFileTable),
+                       hasToc = false) =
+  ## Initializes a ``RstGenerator``.
+  ##
+  ## You need to call this before using a ``RstGenerator`` with any other
+  ## procs in this module. Pass a non ``nil`` ``StringTableRef`` 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()
+  ## <#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 overridden by the embedded rst, but
+  ## it helps to prettify the generated index if no title is found.
+  ##
+  ## The ``RstParseOptions``, ``FindFileHandler`` and ``MsgHandler`` types
+  ## are defined in the `packages/docutils/rst module <rst.html>`_.
+  ## ``options`` selects the behaviour of the rst parser.
+  ##
+  ## ``findFile`` is a proc used by the rst ``include`` directive among others.
+  ## The purpose of this proc is to mangle or filter paths. It receives paths
+  ## specified in the rst document and has to return a valid path to existing
+  ## files or the empty string otherwise.  If you pass ``nil``, a default proc
+  ## will be used which given a path returns the input path only if the file
+  ## exists. One use for this proc is to transform relative paths found in the
+  ## document to absolute path, useful if the rst file and the resources it
+  ## references are not in the same directory as the current working directory.
+  ##
+  ## The ``msgHandler`` is a proc used for user error reporting. It will be
+  ## called with the filename, line, col, and type of any error found during
+  ## parsing. If you pass ``nil``, a default message handler will be used which
+  ## writes the messages to the standard output.
+  ##
+  ## Example:
+  ##
+  ##   ```nim
+  ##   import packages/docutils/rstgen
+  ##
+  ##   var gen: RstGenerator
+  ##   gen.initRstGenerator(outHtml, defaultConfig(), "filename", {})
+  ##   ```
+  g.config = config
+  g.target = target
+  g.tocPart = @[]
+  g.hasToc = hasToc
+  g.filename = filename
+  g.filenames = filenames
+  g.splitAfter = 20
+  g.theIndex = ""
+  g.findFile = findFile
+  g.currentSection = ""
+  g.id = 0
+  g.escMode = emText
+  g.curQuotationDepth = 0
+  let fileParts = filename.splitFile
+  if fileParts.ext == ".nim":
+    g.currentSection = "Module " & fileParts.name
+  g.seenIndexTerms = initTable[string, int]()
+  g.msgHandler = msgHandler
+
+  let s = config.getOrDefault"split.item.toc"
+  if s != "": g.splitAfter = parseInt(s)
+  for i in low(g.meta)..high(g.meta): g.meta[i] = ""
+
+proc writeIndexFile*(g: var RstGenerator, outfile: string) =
+  ## Writes the current index buffer to the specified output file.
+  ##
+  ## You previously need to add entries to the index with the `setIndexTerm()
+  ## <#setIndexTerm,RstGenerator,string,string,string,string,string>`_ proc.
+  ## If the index is empty the file won't be created.
+  if g.theIndex.len > 0: writeFile(outfile, g.theIndex)
+
+proc addHtmlChar(dest: var string, c: char) =
+  # Escapes HTML characters. Note that single quote ' is not escaped as
+  # &apos; -- unlike XML (for standards pre HTML5 it was even forbidden).
+  case c
+  of '&': add(dest, "&amp;")
+  of '<': add(dest, "&lt;")
+  of '>': add(dest, "&gt;")
+  of '\"': add(dest, "&quot;")
+  else: add(dest, c)
+
+proc addTexChar(dest: var string, c: char, escMode: EscapeMode) =
+  ## Escapes 10 special Latex characters and sometimes ` and [, ].
+  ## TODO: @ is always a normal symbol (besides the header), am I wrong?
+  ## All escapes that need to work in text and code blocks (`emText` mode)
+  ## should start from \ (to be compatible with fancyvrb/fvextra).
+  case c
+  of '_', '&', '#', '%': add(dest, "\\" & c)
+  # commands \label and \pageref don't accept \$ by some reason but OK with $:
+  of '$': (if escMode == emUrl: add(dest, c) else: add(dest, "\\" & c))
+  # \~ and \^ have a special meaning unless they are followed by {}
+  of '~', '^': add(dest, "\\" & c & "{}")
+  # Latex loves to substitute ` to opening quote, even in texttt mode!
+  of '`': add(dest, "\\textasciigrave{}")
+  # add {} to avoid gobbling up space by \textbackslash
+  of '\\': add(dest, "\\textbackslash{}")
+  # Using { and } in URL in Latex: https://tex.stackexchange.com/a/469175
+  of '{':
+    add(dest, if escMode == emUrl: "\\%7B" else: "\\{")
+  of '}':
+    add(dest, if escMode == emUrl: "\\%7D" else: "\\}")
+  of ']':
+    # escape ] inside an optional argument in e.g. \section[static[T]]{..
+    add(dest, if escMode == emOption: "\\text{]}" else: "]")
+  else: add(dest, c)
+
+proc escChar*(target: OutputTarget, dest: var string,
+              c: char, escMode: EscapeMode) {.inline.} =
+  case target
+  of outHtml:  addHtmlChar(dest, c)
+  of outLatex: addTexChar(dest, c, escMode)
+
+proc addSplitter(target: OutputTarget; dest: var string) {.inline.} =
+  case target
+  of outHtml: add(dest, "<wbr />")
+  of outLatex: add(dest, "\\-")
+
+proc nextSplitPoint*(s: string, start: int): int =
+  result = start
+  while result < len(s) + 0:
+    case s[result]
+    of '_': return
+    of 'a'..'z':
+      if result + 1 < len(s) + 0:
+        if s[result + 1] in {'A'..'Z'}: return
+    else: discard
+    inc(result)
+  dec(result)                 # last valid index
+
+proc esc*(target: OutputTarget, s: string, splitAfter = -1, escMode = emText): string =
+  ## Escapes the HTML.
+  result = ""
+  if splitAfter >= 0:
+    var partLen = 0
+    var j = 0
+    while j < len(s):
+      var k = nextSplitPoint(s, j)
+      #if (splitter != " ") or (partLen + k - j + 1 > splitAfter):
+      partLen = 0
+      addSplitter(target, result)
+      for i in countup(j, k): escChar(target, result, s[i], escMode)
+      inc(partLen, k - j + 1)
+      j = k + 1
+  else:
+    for i in countup(0, len(s) - 1): escChar(target, result, s[i], escMode)
+
+
+proc disp(target: OutputTarget, xml, tex: string): string =
+  if target != outLatex: result = xml
+  else: result = tex
+
+proc dispF(target: OutputTarget, xml, tex: string,
+           args: varargs[string]): string =
+  if target != outLatex: result = xml % args
+  else: result = tex % args
+
+proc dispA(target: OutputTarget, dest: var string,
+           xml, tex: string, args: varargs[string]) =
+  if target != outLatex: addf(dest, xml, args)
+  else: addf(dest, tex, args)
+
+proc `or`(x, y: string): string {.inline.} =
+  result = if x.len == 0: y else: x
+
+proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string) {.gcsafe.}
+  ## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration.
+  ##
+  ## Before using this proc you need to initialise a ``RstGenerator`` with
+  ## ``initRstGenerator`` and parse a rst file with ``rstParse`` from the
+  ## `packages/docutils/rst module <rst.html>`_. Example:
+  ##   ```nim
+  ##   # ...configure gen and rst vars...
+  ##   var generatedHtml = ""
+  ##   renderRstToOut(gen, rst, generatedHtml)
+  ##   echo generatedHtml
+  ##   ```
+
+proc renderAux(d: PDoc, n: PRstNode, result: var string) =
+  for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
+
+template idS(txt: string): string =
+  if txt == "": ""
+  else:
+    case d.target
+    of outHtml:
+      " id=\"" & txt & "\""
+    of outLatex:
+      "\\label{" & txt & "}\\hypertarget{" & txt & "}{}"
+        # we add \label for page number references via \pageref, while
+        # \hypertarget is for clickable links via \hyperlink.
+
+proc renderAux(d: PDoc, n: PRstNode, html, tex: string, result: var string) =
+  # formats sons of `n` as substitution variable $1 inside strings `html` and
+  # `tex`, internal target (anchor) is provided as substitute $2.
+  var tmp = ""
+  for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], tmp)
+  case d.target
+  of outHtml:  result.addf(html, [tmp, n.anchor.idS])
+  of outLatex: result.addf(tex,  [tmp, n.anchor.idS])
+
+# ---------------- index handling --------------------------------------------
+
+proc setIndexTerm*(d: var RstGenerator; k: IndexEntryKind, htmlFile, id, term: string,
+                   linkTitle, linkDesc = "", line = 0) =
+  ## Adds a `term` to the index using the specified hyperlink identifier.
+  ##
+  ## A new entry will be added to the index using the format
+  ## ``term<tab>file#id``. The file part will come from the `htmlFile`
+  ## parameter.
+  ##
+  ## 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,string>`_
+  ## 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()
+  ## <#writeIndexFile,RstGenerator,string>`_. The purpose of the index is
+  ## documented in the `docgen tools guide
+  ## <docgen.html#related-options-index-switch>`_.
+  let (entry, isTitle) = formatIndexEntry(k, htmlFile, id, term,
+                                          linkTitle, linkDesc, line)
+  if isTitle: d.theIndex.insert(entry)
+  else: d.theIndex.add(entry)
+
+proc hash(n: PRstNode): int =
+  if n.kind == rnLeaf:
+    result = hash(n.text)
+  elif n.len > 0:
+    result = hash(n.sons[0])
+    for i in 1 ..< len(n):
+      result = result !& hash(n.sons[i])
+    result = !$result
+
+proc htmlFileRelPath(d: PDoc): string =
+  if d.outDir.len == 0:
+    # /foo/bar/zoo.nim -> zoo.html
+    changeFileExt(extractFilename(d.filename), HtmlExt)
+  else: # d is initialized in docgen.nim
+    # outDir   = /foo              -\
+    # destFile = /foo/bar/zoo.html -|-> bar/zoo.html
+    d.destFile.relativePath(d.outDir, '/')
+
+proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
+  ## Renders the string decorated within \`foobar\`\:idx\: markers.
+  ##
+  ## Additionally adds the enclosed 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.getOrDefault(refname) + 1
+  else:
+    d.seenIndexTerms[refname] = 1
+  let id = refname & '_' & $d.seenIndexTerms.getOrDefault(refname)
+
+  var term = ""
+  renderAux(d, n, term)
+  setIndexTerm(d, ieIdxRole,
+  htmlFileRelPath(d), id, term, d.currentSection)
+  dispA(d.target, result, "<span id=\"$1\">$2</span>", "\\nimindexterm{$1}{$2}",
+        [id, term])
+
+type
+  IndexedDocs* = Table[IndexEntry, seq[IndexEntry]] ## \
+    ## Contains the index sequences for doc types.
+    ##
+    ## The key is a *fake* IndexEntry 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 empty.
+    ##
+    ## The value indexed by this IndexEntry is a sequence with the real index
+    ## entries found in the ``.idx`` file.
+
+when defined(gcDestructors):
+  template `<-`(a, b: var IndexEntry) = a = move(b)
+else:
+  proc `<-`(a: var IndexEntry, b: IndexEntry) =
+    shallowCopy a.keyword, b.keyword
+    shallowCopy a.link, b.link
+    shallowCopy a.linkTitle, b.linkTitle
+    shallowCopy a.linkDesc, b.linkDesc
+    shallowCopy a.module, b.module
+
+proc sortIndex(a: var openArray[IndexEntry]) =
+  # we use shellsort here; fast and simple
+  let n = len(a)
+  var h = 1
+  while true:
+    h = 3 * h + 1
+    if h > n: break
+  while true:
+    h = h div 3
+    for i in countup(h, n - 1):
+      var v: IndexEntry
+      v <- a[i]
+      var j = i
+      while cmp(a[j-h], v) >= 0:
+        a[j] <- a[j-h]
+        j = j-h
+        if j < h: break
+      a[j] <- v
+    if h == 1: break
+
+proc escapeLink(s: string): string =
+  ## This proc is mostly copied from uri/encodeUrl except that
+  ## these chars are also left unencoded: '#', '/'.
+  result = newStringOfCap(s.len + s.len shr 2)
+  for c in items(s):
+    case c
+    of 'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~': # same as that in uri/encodeUrl
+      add(result, c)
+    of '#', '/': # example.com/foo/#bar (don't escape the '/' and '#' in such links)
+      add(result, c)
+    else:
+      add(result, "%")
+      add(result, toHex(ord(c), 2))
+
+proc generateSymbolIndex(symbols: seq[IndexEntry]): string =
+  result = "<dl>"
+  var i = 0
+  while i < symbols.len:
+    let keyword = esc(outHtml, symbols[i].keyword)
+    let cleanedKeyword = keyword.escapeLink
+    result.addf("<dt><a name=\"$2\" href=\"#$2\"><span>$1:</span></a></dt><dd><ul class=\"simple\">\n",
+                [keyword, cleanedKeyword])
+    var j = i
+    while j < symbols.len and symbols[i].keyword == symbols[j].keyword:
+      let
+        url = symbols[j].link.escapeLink
+        module = symbols[j].module
+        text =
+          if symbols[j].linkTitle.len > 0:
+            esc(outHtml, module & ": " & symbols[j].linkTitle)
+          else: url
+        desc = symbols[j].linkDesc
+      if desc.len > 0:
+        result.addf("""<li><a class="reference external"
+          title="$3" data-doc-search-tag="$2" href="$1">$2</a></li>
+          """, [url, text, desc])
+      else:
+        result.addf("""<li><a class="reference external"
+          data-doc-search-tag="$2" href="$1">$2</a></li>
+          """, [url, text])
+      inc j
+    result.add("</ul></dd>\n")
+    i = j
+  result.add("</dl>")
+
+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 = repeat("<li><ul>", newLevel - level)
+  else:
+    result = repeat("</ul></li>", level - newLevel)
+  level = newLevel
+
+proc generateDocumentationToc(entries: seq[IndexEntry]): 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
+    titleTag: 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)
+    if rawLevel < 1:
+      # This is a normal symbol, push it *inside* one level from the last one.
+      levels[L].level = level + 1
+    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
+      titleTag = levels[L].text
+    else:
+      result.add(level.indentToLevel(levels[L].level))
+      result.addf("""<li><a class="reference" data-doc-search-tag="$1: $2" href="$3">
+        $3</a></li>
+        """, [titleTag, levels[L].text, link, levels[L].text])
+    inc L
+  result.add(level.indentToLevel(1) & "</ul>\n")
+
+proc generateDocumentationIndex(docs: IndexedDocs): 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[IndexEntry, seq[IndexEntry]](docs))
+  sort(titles, cmp)
+
+  for title in titles:
+    let tocList = generateDocumentationToc(docs.getOrDefault(title))
+    result.add("<ul><li><a href=\"" &
+      title.link & "\">" & title.linkTitle & "</a>\n" & tocList & "</li></ul>\n")
+
+proc generateDocumentationJumps(docs: IndexedDocs): 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[IndexEntry, seq[IndexEntry]](docs))
+  sort(titles, cmp)
+
+  var chunks: seq[string] = @[]
+  for title in titles:
+    chunks.add("<a href=\"" & title.link & "\">" & title.linkTitle & "</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=\"$1.html\">$2</a>" % [name, name.prettyLink])
+
+  result.add(chunks.join(", ") & ".<br/>")
+
+proc readIndexDir*(dir: string):
+    tuple[modules: seq[string], symbols: seq[IndexEntry], docs: IndexedDocs] =
+  ## Walks `dir` reading ``.idx`` files converting them in IndexEntry 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[IndexEntry, seq[IndexEntry]](32)
+  newSeq(result.symbols, 15_000)
+  setLen(result.symbols, 0)
+  var L = 0
+  # Scan index files and build the list of symbols.
+  for path in walkDirRec(dir):
+    if path.endsWith(IndexExt):
+      var (fileEntries, title) = parseIdxFile(path)
+      # Depending on type add this to the list of symbols or table of APIs.
+
+      if title.kind == ieNimTitle:
+        for i in 0 ..< fileEntries.len:
+          if fileEntries[i].kind != ieNim:
+            continue
+          # Ok, non TOC entry, add it.
+          setLen(result.symbols, L + 1)
+          result.symbols[L] = fileEntries[i]
+          inc L
+        if fileEntries.len > 0:
+          var x = fileEntries[0].link
+          let i = find(x, '#')
+          if i > 0:
+            x.setLen(i)
+          if i != 0:
+            # don't add entries starting with '#'
+            result.modules.add(x.changeFileExt(""))
+      else:
+        # Generate the symbolic anchor for index quickjumps.
+        title.aux = "doc_toc_" & $result.docs.len
+        result.docs[title] = fileEntries
+
+      for i in 0 ..< fileEntries.len:
+        if fileEntries[i].kind != ieIdxRole:
+          continue
+
+        setLen(result.symbols, L + 1)
+        result.symbols[L] = fileEntries[i]
+        inc L
+
+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 ``nim doc|rst2html``
+  ## which use the ``--index:on`` switch. These index files are the result of
+  ## calls to `setIndexTerm()
+  ## <#setIndexTerm,RstGenerator,string,string,string,string,string>`_
+  ## and `writeIndexFile() <#writeIndexFile,RstGenerator,string>`_, 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 repeated 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)
+  sort(modules, system.cmp)
+
+  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 />")
+
+  when false:
+    # 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 renderHeadline(d: PDoc, n: PRstNode, result: var string) =
+  var tmp = ""
+  for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
+  d.currentSection = tmp
+  var tocName = esc(d.target, renderRstToText(n), escMode = emOption)
+    # for Latex: simple text without commands that may break TOC/hyperref
+  if d.hasToc:
+    d.tocPart.add n
+    dispA(d.target, result, "\n<h$1><a class=\"toc-backref\"" &
+      "$2 href=\"#$5\">$3</a></h$1>", "\\rsth$4[$6]{$3}$2\n",
+      [$n.level, n.anchor.idS, tmp,
+       $chr(n.level - 1 + ord('A')), n.anchor, tocName])
+  else:
+    dispA(d.target, result, "\n<h$1$2>$3</h$1>",
+                            "\\rsth$4[$5]{$3}$2\n", [
+        $n.level, n.anchor.idS, tmp,
+        $chr(n.level - 1 + ord('A')), tocName])
+
+  # Generate index entry using spaces to indicate TOC level for the output HTML.
+  assert n.level >= 0
+  setIndexTerm(d, ieHeading, htmlFile = d.htmlFileRelPath, id = n.anchor,
+               term = n.addNodes, linkTitle = spaces(max(0, n.level)) & tmp)
+
+proc renderOverline(d: PDoc, n: PRstNode, result: var string) =
+  if n.level == 0 and d.meta[metaTitle].len == 0:
+    d.meta[metaTitleRaw] = n.addNodes
+    for i in countup(0, len(n)-1):
+      renderRstToOut(d, n.sons[i], d.meta[metaTitle])
+    d.currentSection = d.meta[metaTitle]
+  elif n.level == 0 and d.meta[metaSubtitle].len == 0:
+    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)
+    d.currentSection = tmp
+    var tocName = esc(d.target, renderRstToText(n), escMode=emOption)
+    dispA(d.target, result, "<h$1$2><center>$3</center></h$1>",
+                   "\\rstov$4[$5]{$3}$2\n", [$n.level,
+                   n.anchor.idS, tmp, $chr(n.level - 1 + ord('A')), tocName])
+    setIndexTerm(d, ieHeading, htmlFile = d.htmlFileRelPath, id = n.anchor,
+                 term = n.addNodes, linkTitle = spaces(max(0, n.level)) & tmp)
+
+proc renderTocEntry(d: PDoc, n: PRstNode, result: var string) =
+  var header = ""
+  for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], header)
+  dispA(d.target, result,
+    "<li><a class=\"reference\" id=\"$1_toc\" href=\"#$1\">$2</a></li>\n",
+    "\\item\\label{$1_toc} $2\\ref{$1}\n", [n.anchor, header])
+
+proc renderTocEntries*(d: var RstGenerator, j: var int, lvl: int,
+                       result: var string) =
+  var tmp = ""
+  while j <= high(d.tocPart):
+    var a = abs(d.tocPart[j].level)
+    if a == lvl:
+      renderTocEntry(d, d.tocPart[j], tmp)
+      inc(j)
+    elif a > lvl:
+      renderTocEntries(d, j, a, tmp)
+    else:
+      break
+  if lvl > 1:
+    dispA(d.target, result, "<ul class=\"simple\">$1</ul>",
+                            "\\begin{enumerate}$1\\end{enumerate}", [tmp])
+  else:
+    result.add(tmp)
+
+proc renderImage(d: PDoc, n: PRstNode, result: var string) =
+  let
+    arg = getArgument(n)
+  var
+    options = ""
+
+  var s = esc(d.target, getFieldValue(n, "scale").strip())
+  if s.len > 0:
+    dispA(d.target, options, " scale=\"$1\"", " scale=$1", [s])
+
+  s = esc(d.target, getFieldValue(n, "height").strip())
+  if s.len > 0:
+    dispA(d.target, options, " height=\"$1\"", " height=$1", [s])
+
+  s = esc(d.target, getFieldValue(n, "width").strip())
+  if s.len > 0:
+    dispA(d.target, options, " width=\"$1\"", " width=$1", [s])
+
+  s = esc(d.target, getFieldValue(n, "alt").strip())
+  if s.len > 0:
+    dispA(d.target, options, " alt=\"$1\"", "", [s])
+
+  s = esc(d.target, getFieldValue(n, "align").strip())
+  if s.len > 0:
+    dispA(d.target, options, " align=\"$1\"", "", [s])
+
+  if options.len > 0: options = dispF(d.target, "$1", "[$1]", [options])
+
+  var htmlOut = ""
+  if arg.endsWith(".mp4") or arg.endsWith(".ogg") or
+     arg.endsWith(".webm"):
+    htmlOut = """
+      <video$3 src="$1"$2 autoPlay='true' loop='true' muted='true'>
+      Sorry, your browser doesn't support embedded videos
+      </video>
+    """
+  else:
+    htmlOut = "<img$3 src=\"$1\"$2/>"
+
+  # support for `:target:` links for images:
+  var target = esc(d.target, getFieldValue(n, "target").strip(), escMode=emUrl)
+  discard safeProtocol(target)
+
+  if target.len > 0:
+    # `htmlOut` needs to be of the following format for link to work for images:
+    # <a class="reference external" href="target"><img src=\"$1\"$2/></a>
+    var htmlOutWithLink = ""
+    dispA(d.target, htmlOutWithLink,
+      "<a class=\"reference external\" href=\"$2\">$1</a>",
+      "\\href{$2}{$1}", [htmlOut, target])
+    htmlOut = htmlOutWithLink
+
+  dispA(d.target, result, htmlOut, "$3\\includegraphics$2{$1}",
+        [esc(d.target, arg), options, n.anchor.idS])
+  if len(n) >= 3: renderRstToOut(d, n.sons[2], result)
+
+proc renderSmiley(d: PDoc, n: PRstNode, result: var string) =
+  dispA(d.target, result,
+    """<img src="$1" width="15"
+        height="17" hspace="2" vspace="2" class="smiley" />""",
+    "\\includegraphics{$1}",
+    [d.config.getOrDefault"doc.smiley_format" % n.text])
+
+proc getField1Int(d: PDoc, n: PRstNode, fieldName: string): int =
+  template err(msg: string) =
+    rstMessage(d.filenames, d.msgHandler, n.info, meInvalidField, msg)
+  let value = n.getFieldValue
+  var number: int
+  let nChars = parseInt(value, number)
+  if nChars == 0:
+    if value.len == 0:
+      # use a good default value:
+      result = 1
+    else:
+      err("field $1 requires an integer, but '$2' was given" %
+          [fieldName, value])
+  elif nChars < value.len:
+    err("extra arguments were given to $1: '$2'" %
+        [fieldName, value[nChars..^1]])
+  else:
+    result = number
+
+proc parseCodeBlockField(d: PDoc, n: PRstNode, params: var CodeBlockParams) =
+  ## Parses useful fields which can appear before a code block.
+  ##
+  ## This supports the special ``default-language`` internal string generated
+  ## by the ``rst`` module to communicate a specific default language.
+  case n.getArgument.toLowerAscii
+  of "number-lines":
+    params.numberLines = true
+    # See if the field has a parameter specifying a different line than 1.
+    params.startLine = getField1Int(d, n, "number-lines")
+  of "file", "filename":
+    # The ``file`` option is a Nim extension to the official spec, it acts
+    # like it would for other directives like ``raw`` or ``cvs-table``. This
+    # field is dealt with in ``rst.nim`` which replaces the existing block with
+    # the referenced file, so we only need to ignore it here to avoid incorrect
+    # warning messages.
+    params.filename = n.getFieldValue.strip
+  of "test":
+    params.testCmd = n.getFieldValue.strip
+    if params.testCmd.len == 0:
+      # factor with D20210224T221756. Note that `$docCmd` should appear before `$file`
+      # but after all other options, but currently `$options` merges both options and `$file` so it's tricky.
+      params.testCmd = "$nim r --backend:$backend --lib:$libpath $docCmd $options"
+    else:
+      # consider whether `$docCmd` should be appended here too
+      params.testCmd = unescape(params.testCmd)
+  of "status", "exitcode":
+    params.status = getField1Int(d, n, n.getArgument)
+  of "default-language":
+    params.langStr = n.getFieldValue.strip
+    params.lang = params.langStr.getSourceLanguage
+  else:
+    rstMessage(d.filenames, d.msgHandler, n.info, mwUnsupportedField,
+               n.getArgument)
+
+proc parseCodeBlockParams(d: PDoc, n: PRstNode): CodeBlockParams =
+  ## Iterates over all code block fields and returns processed params.
+  ##
+  ## Also processes the argument of the directive as the default language. This
+  ## is done last so as to override any internal communication field variables.
+  result.init
+  if n.isNil:
+    return
+  assert n.kind in {rnCodeBlock, rnInlineCode}
+
+  # Parse the field list for rendering parameters if there are any.
+  if not n.sons[1].isNil:
+    for son in n.sons[1].sons: d.parseCodeBlockField(son, result)
+
+  # Parse the argument and override the language.
+  result.langStr = strip(getArgument(n))
+  if result.langStr != "":
+    result.lang = getSourceLanguage(result.langStr)
+
+proc buildLinesHtmlTable(d: PDoc; params: CodeBlockParams, code: string,
+                         idStr: string):
+    tuple[beginTable, endTable: string] =
+  ## Returns the necessary tags to start/end a code block in HTML.
+  ##
+  ## If the numberLines has not been used, the tags will default to a simple
+  ## <pre> pair. Otherwise it will build a table and insert an initial column
+  ## with all the line numbers, which requires you to pass the `code` to detect
+  ## how many lines have to be generated (and starting at which point!).
+  inc d.listingCounter
+  let id = $d.listingCounter
+  if not params.numberLines:
+    result = (d.config.getOrDefault"doc.listing_start" %
+                [id, sourceLanguageToStr[params.lang], idStr],
+              d.config.getOrDefault"doc.listing_end" % id)
+    return
+
+  var codeLines = code.strip.countLines
+  assert codeLines > 0
+  result.beginTable = """<table$1 class="line-nums-table">""" % [idStr] &
+      """<tbody><tr><td class="blob-line-nums"><pre class="line-nums">"""
+  var line = params.startLine
+  while codeLines > 0:
+    result.beginTable.add($line & "\n")
+    line.inc
+    codeLines.dec
+  result.beginTable.add("</pre></td><td>" & (
+      d.config.getOrDefault"doc.listing_start" %
+        [id, sourceLanguageToStr[params.lang], idStr]))
+  result.endTable = (d.config.getOrDefault"doc.listing_end" % id) &
+      "</td></tr></tbody></table>" & (
+      d.config.getOrDefault"doc.listing_button" % id)
+
+proc renderCodeLang*(result: var string, lang: SourceLanguage, code: string,
+                     target: OutputTarget) =
+  var g: GeneralTokenizer
+  initGeneralTokenizer(g, code)
+  while true:
+    getNextToken(g, lang)
+    case g.kind
+    of gtEof: break
+    of gtNone, gtWhitespace:
+      add(result, substr(code, g.start, g.length + g.start - 1))
+    else:
+      dispA(target, result, "<span class=\"$2\">$1</span>", "\\span$2{$1}", [
+        esc(target, substr(code, g.start, g.length+g.start-1)),
+        tokenClassToStr[g.kind]])
+  deinitGeneralTokenizer(g)
+
+proc renderNimCode*(result: var string, code: string, target: OutputTarget) =
+  renderCodeLang(result, langNim, code, target)
+
+proc renderCode(d: PDoc, n: PRstNode, result: var string) {.gcsafe.} =
+  ## Renders a code (code block or inline code), appending it to `result`.
+  ##
+  ## If the code block uses the ``number-lines`` option, a table will be
+  ## generated with two columns, the first being a list of numbers and the
+  ## second the code block itself. The code block can use syntax highlighting,
+  ## which depends on the directive argument specified by the rst input, and
+  ## may also come from the parser through the internal ``default-language``
+  ## option to differentiate between a plain code block and Nim's code block
+  ## extension.
+  assert n.kind in {rnCodeBlock, rnInlineCode}
+  var params = d.parseCodeBlockParams(n)
+  if n.sons[2] == nil: return
+  var m = n.sons[2].sons[0]
+  assert m.kind == rnLeaf
+
+  if params.testCmd.len > 0 and d.onTestSnippet != nil:
+    d.onTestSnippet(d, params.filename, params.testCmd, params.status, m.text)
+
+  var blockStart, blockEnd: string
+  case d.target
+  of outHtml:
+    if n.kind == rnCodeBlock:
+      (blockStart, blockEnd) = buildLinesHtmlTable(d, params, m.text,
+                                                   n.anchor.idS)
+    else:  # rnInlineCode
+      blockStart = "<tt class=\"docutils literal\"><span class=\"pre\">"
+      blockEnd = "</span></tt>"
+  of outLatex:
+    if n.kind == rnCodeBlock:
+      blockStart = "\n\n" & n.anchor.idS & "\\begin{rstpre}\n"
+      blockEnd = "\n\\end{rstpre}\n\n"
+    else:  # rnInlineCode
+      blockStart = "\\rstcode{"
+      blockEnd = "}"
+  dispA(d.target, result, blockStart, blockStart, [])
+  if params.lang == langNone:
+    if len(params.langStr) > 0 and params.langStr.toLowerAscii != "none":
+      rstMessage(d.filenames, d.msgHandler, n.info, mwUnsupportedLanguage,
+                 params.langStr)
+    for letter in m.text: escChar(d.target, result, letter, emText)
+  else:
+    renderCodeLang(result, params.lang, m.text, d.target)
+  dispA(d.target, result, blockEnd, blockEnd)
+
+proc renderContainer(d: PDoc, n: PRstNode, result: var string) =
+  var tmp = ""
+  renderRstToOut(d, n.sons[2], tmp)
+  var arg = esc(d.target, strip(getArgument(n)))
+  if arg == "":
+    dispA(d.target, result, "<div>$1</div>", "$1", [tmp])
+  else:
+    dispA(d.target, result, "<div class=\"$1\">$2</div>", "$2", [arg, tmp])
+
+proc renderField(d: PDoc, n: PRstNode, result: var string) =
+  var b = false
+  if d.target == outLatex:
+    var fieldname = addNodes(n.sons[0])
+    var fieldval = esc(d.target, strip(addNodes(n.sons[1])))
+    if cmpIgnoreStyle(fieldname, "author") == 0 or
+       cmpIgnoreStyle(fieldname, "authors") == 0:
+      if d.meta[metaAuthor].len == 0:
+        d.meta[metaAuthor] = fieldval
+        b = true
+    elif cmpIgnoreStyle(fieldname, "version") == 0:
+      if d.meta[metaVersion].len == 0:
+        d.meta[metaVersion] = fieldval
+        b = true
+  if not b:
+    renderAux(d, n, "<tr>$1</tr>\n", "$1", result)
+
+proc renderEnumList(d: PDoc, n: PRstNode, result: var string) =
+  var
+    specifier = ""
+    specStart = ""
+    i1 = 0
+    pre = ""
+    i2 = n.labelFmt.len - 1
+    post = ""
+  if n.labelFmt[0] == '(':
+    i1 = 1
+    pre = "("
+  if n.labelFmt[^1] == ')' or n.labelFmt[^1] == '.':
+    i2 = n.labelFmt.len - 2
+    post = $n.labelFmt[^1]
+  let enumR = i1 .. i2  # enumerator range without surrounding (, ), .
+  if d.target == outLatex:
+    result.add ("\n%" & n.labelFmt & "\n")
+    # use enumerate parameters from package enumitem
+    if n.labelFmt[i1].isDigit:
+      var labelDef = ""
+      if pre != "" or post != "":
+        labelDef = "label=" & pre & "\\arabic*" & post & ","
+      if n.labelFmt[enumR] != "1":
+        specStart = "start=$1" % [n.labelFmt[enumR]]
+      if labelDef != "" or specStart != "":
+        specifier = "[$1$2]" % [labelDef, specStart]
+    else:
+      let (first, labelDef) =
+        if n.labelFmt[i1].isUpperAscii: ('A', "label=" & pre & "\\Alph*" & post)
+        else: ('a', "label=" & pre & "\\alph*" & post)
+      if n.labelFmt[i1] != first:
+        specStart = ",start=" & $(ord(n.labelFmt[i1]) - ord(first) + 1)
+      specifier = "[$1$2]" % [labelDef, specStart]
+  else:  # HTML
+    # TODO: implement enumerator formatting using pre and post ( and ) for HTML
+    if n.labelFmt[i1].isDigit:
+      if n.labelFmt[enumR] != "1":
+        specStart = " start=\"$1\"" % [n.labelFmt[enumR]]
+      specifier = "class=\"simple\"" & specStart
+    else:
+      let (first, labelDef) =
+        if n.labelFmt[i1].isUpperAscii: ('A', "class=\"upperalpha simple\"")
+        else: ('a', "class=\"loweralpha simple\"")
+      if n.labelFmt[i1] != first:
+        specStart = " start=\"$1\"" % [ $(ord(n.labelFmt[i1]) - ord(first) + 1) ]
+      specifier = labelDef & specStart
+  renderAux(d, n, "<ol$2 " & specifier & ">$1</ol>\n",
+            "\\begin{enumerate}" & specifier & "$2$1\\end{enumerate}\n",
+            result)
+
+proc renderAdmonition(d: PDoc, n: PRstNode, result: var string) =
+  var
+    htmlCls = "admonition_warning"
+    texSz = "\\large"
+    texColor = "orange"
+  case n.adType
+  of "hint", "note", "tip":
+    htmlCls = "admonition-info"; texSz = "\\normalsize"; texColor = "green"
+  of "attention", "admonition", "important", "warning", "caution":
+    htmlCls = "admonition-warning"; texSz = "\\large"; texColor = "orange"
+  of "danger", "error":
+    htmlCls = "admonition-error"; texSz = "\\Large"; texColor = "red"
+  else: discard
+  let txt = n.adType.capitalizeAscii()
+  let htmlHead = "<div class=\"admonition " & htmlCls & "\">"
+  renderAux(d, n,
+      htmlHead & "<span$2 class=\"" & htmlCls & "-text\"><b>" & txt &
+        ":</b></span>\n" & "$1</div>\n",
+      "\n\n\\begin{rstadmonition}[borderline west={0.2em}{0pt}{" &
+        texColor & "}]$2\n" &
+        "{" & texSz & "\\color{" & texColor & "}{\\textbf{" & txt & ":}}} " &
+        "$1\n\\end{rstadmonition}\n",
+      result)
+
+proc renderHyperlink(d: PDoc, text, link: PRstNode, result: var string,
+                     external: bool, nimdoc = false, tooltip="") =
+  var linkStr = ""
+  block:
+    let mode = d.escMode
+    d.escMode = emUrl
+    renderRstToOut(d, link, linkStr)
+    d.escMode = mode
+  discard safeProtocol(linkStr)
+  var textStr = ""
+  renderRstToOut(d, text, textStr)
+  let nimDocStr = if nimdoc: " nimdoc" else: ""
+  var tooltipStr = ""
+  if tooltip != "":
+    tooltipStr = """ title="$1"""" % [ esc(d.target, tooltip) ]
+  if external:
+    dispA(d.target, result,
+      "<a class=\"reference external$3\"$4 href=\"$2\">$1</a>",
+      "\\href{$2}{$1}", [textStr, linkStr, nimDocStr, tooltipStr])
+  else:
+    dispA(d.target, result,
+      "<a class=\"reference internal$3\"$4 href=\"#$2\">$1</a>",
+      "\\hyperlink{$2}{$1} (p.~\\pageref{$2})",
+      [textStr, linkStr, nimDocStr, tooltipStr])
+
+proc traverseForIndex*(d: PDoc, n: PRstNode) =
+  ## A version of [renderRstToOut] that only fills entries for ``.idx`` files.
+  var discarded: string
+  if n == nil: return
+  case n.kind
+  of rnIdx: renderIndexTerm(d, n, discarded)
+  of rnHeadline, rnMarkdownHeadline: renderHeadline(d, n, discarded)
+  of rnOverline: renderOverline(d, n, discarded)
+  else:
+    for i in 0 ..< len(n):
+      traverseForIndex(d, n.sons[i])
+
+proc renderRstToOut(d: PDoc, n: PRstNode, result: var string) =
+  if n == nil: return
+  case n.kind
+  of rnInner: renderAux(d, n, result)
+  of rnHeadline, rnMarkdownHeadline: renderHeadline(d, n, result)
+  of rnOverline: renderOverline(d, n, result)
+  of rnTransition: renderAux(d, n, "<hr$2 />\n", "\n\n\\vspace{0.6em}\\hrule$2\n", result)
+  of rnParagraph: renderAux(d, n, "<p$2>$1</p>\n", "\n\n$2\n$1\n\n", result)
+  of rnBulletList:
+    renderAux(d, n, "<ul$2 class=\"simple\">$1</ul>\n",
+                    "\\begin{itemize}\n$2\n$1\\end{itemize}\n", result)
+  of rnBulletItem, rnEnumItem:
+    renderAux(d, n, "<li$2>$1</li>\n", "\\item $2$1\n", result)
+  of rnEnumList: renderEnumList(d, n, result)
+  of rnDefList, rnMdDefList:
+    renderAux(d, n, "<dl$2 class=\"docutils\">$1</dl>\n",
+                    "\\begin{description}\n$2\n$1\\end{description}\n", result)
+  of rnDefItem: renderAux(d, n, result)
+  of rnDefName: renderAux(d, n, "<dt$2>$1</dt>\n", "$2\\item[$1]\\  ", result)
+  of rnDefBody: renderAux(d, n, "<dd$2>$1</dd>\n", "$2\n$1\n", result)
+  of rnFieldList:
+    var tmp = ""
+    for i in countup(0, len(n) - 1):
+      renderRstToOut(d, n.sons[i], tmp)
+    if tmp.len != 0:
+      dispA(d.target, result,
+          "<table$2 class=\"docinfo\" frame=\"void\" rules=\"none\">" &
+          "<col class=\"docinfo-name\" />" &
+          "<col class=\"docinfo-content\" />" &
+          "<tbody valign=\"top\">$1" &
+          "</tbody></table>",
+          "\\begin{description}\n$2\n$1\\end{description}\n",
+          [tmp, n.anchor.idS])
+  of rnField: renderField(d, n, result)
+  of rnFieldName:
+    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:
+    renderRstToOut(d, n.sons[2], result)
+  of rnOptionList:
+    renderAux(d, n, "<div$2 class=\"option-list\">$1</div>",
+        "\\begin{rstoptlist}$2\n$1\\end{rstoptlist}", result)
+  of rnOptionListItem:
+    var addclass = if n.order mod 2 == 1: " odd" else: ""
+    renderAux(d, n,
+        "<div class=\"option-list-item" & addclass & "\">$1</div>\n",
+        "$1", result)
+  of rnOptionGroup:
+    renderAux(d, n,
+        "<div class=\"option-list-label\"><tt><span class=\"option\">" &
+        "$1</span></tt></div>",
+        "\\item[\\rstcodeitem{\\spanoption{$1}}]", result)
+  of rnDescription:
+    renderAux(d, n, "<div class=\"option-list-description\">$1</div>",
+        " $1\n", result)
+  of rnOption, rnOptionString, rnOptionArgument:
+    raiseAssert "renderRstToOut"
+  of rnLiteralBlock:
+    renderAux(d, n, "<pre$2>$1</pre>\n",
+                    "\n\n$2\\begin{rstpre}\n$1\n\\end{rstpre}\n\n", result)
+  of rnMarkdownBlockQuote:
+    d.curQuotationDepth = 1
+    var tmp = ""
+    renderAux(d, n, "$1", "$1", tmp)
+    let itemEnding =
+      if d.target == outHtml: "</blockquote>" else: "\\end{rstquote}"
+    tmp.add itemEnding.repeat(d.curQuotationDepth - 1)
+    dispA(d.target, result,
+        "<blockquote$2 class=\"markdown-quote\">$1</blockquote>\n",
+        "\n\\begin{rstquote}\n$2\n$1\\end{rstquote}\n", [tmp, n.anchor.idS])
+  of rnMarkdownBlockQuoteItem:
+    let addQuotationDepth = n.quotationDepth - d.curQuotationDepth
+    var itemPrefix: string  # start or ending (quotation grey bar on the left)
+    if addQuotationDepth >= 0:
+      let s =
+        if d.target == outHtml: "<blockquote class=\"markdown-quote\">"
+        else: "\\begin{rstquote}"
+      itemPrefix = s.repeat(addQuotationDepth)
+    else:
+      let s =
+        if d.target == outHtml: "</blockquote>"
+        else: "\\end{rstquote}"
+      itemPrefix = s.repeat(-addQuotationDepth)
+    renderAux(d, n, itemPrefix & "<p>$1</p>", itemPrefix & "\n$1", result)
+    d.curQuotationDepth = n.quotationDepth
+  of rnLineBlock:
+    if n.sons.len == 1 and n.sons[0].lineIndent == "\n":
+      # whole line block is one empty line, no need to add extra spacing
+      renderAux(d, n, "<p$2>$1</p> ", "\n\n$2\n$1", result)
+    else:  # add extra spacing around the line block for Latex
+      renderAux(d, n, "<p$2>$1</p>",
+        "\n\\vspace{0.5em}$2\n$1\\vspace{0.5em}\n", result)
+  of rnLineBlockItem:
+    if n.lineIndent.len == 0:  # normal case - no additional indentation
+      renderAux(d, n, "$1<br/>", "\\noindent $1\n\n", result)
+    elif n.lineIndent == "\n":  # add one empty line
+      renderAux(d, n, "<br/>", "\\vspace{1em}\n", result)
+    else:  # additional indentation w.r.t. '| '
+      let indent = $(0.5 * (n.lineIndent.len - 1).toFloat) & "em"
+      renderAux(d, n,
+        "<span style=\"margin-left: " & indent & "\">$1</span><br/>",
+        "\\noindent\\hspace{" & indent & "}$1\n\n", result)
+  of rnBlockQuote:
+    renderAux(d, n, "<blockquote$2><p>$1</p></blockquote>\n",
+                    "\\begin{quote}\n$2\n$1\\end{quote}\n", result)
+  of rnAdmonition: renderAdmonition(d, n, result)
+  of rnTable, rnGridTable, rnMarkdownTable:
+    renderAux(d, n,
+      "<table$2 border=\"1\" class=\"docutils\">$1</table>",
+      "\n$2\n\\begin{rsttab}{" &
+        "L".repeat(n.colCount) & "}\n\\toprule\n$1" &
+        "\\addlinespace[0.1em]\\bottomrule\n\\end{rsttab}", result)
+  of rnTableRow:
+    if len(n) >= 1:
+      case d.target
+      of outHtml:
+        result.add("<tr>")
+        renderAux(d, n, result)
+        result.add("</tr>\n")
+      of outLatex:
+        if n.sons[0].kind == rnTableHeaderCell:
+          result.add "\\rowcolor{gray!15} "
+        var spanLines: seq[(int, int)]
+        var nCell = 0
+        for uCell in 0 .. n.len - 1:
+          renderRstToOut(d, n.sons[uCell], result)
+          if n.sons[uCell].span > 0:
+            spanLines.add (nCell + 1, nCell + n.sons[uCell].span)
+            nCell += n.sons[uCell].span
+          else:
+            nCell += 1
+          if uCell != n.len - 1:
+            result.add(" & ")
+        result.add("\\\\")
+        if n.endsHeader: result.add("\\midrule\n")
+        for (start, stop) in spanLines:
+          result.add("\\cmidrule(lr){$1-$2}" % [$start, $stop])
+        result.add("\n")
+  of rnTableHeaderCell, rnTableDataCell:
+    case d.target
+    of outHtml:
+      let tag = if n.kind == rnTableHeaderCell: "th" else: "td"
+      var spanSpec: string
+      if n.span <= 1: spanSpec = ""
+      else:
+        spanSpec = " colspan=\"" & $n.span & "\" style=\"text-align: center\""
+      renderAux(d, n, "<$1$2>$$1</$1>" % [tag, spanSpec], "", result)
+    of outLatex:
+      let text = if n.kind == rnTableHeaderCell: "\\textbf{$1}" else: "$1"
+      var latexStr: string
+      if n.span <= 1: latexStr = text
+      else: latexStr = "\\multicolumn{" & $n.span & "}{c}{" & text & "}"
+      renderAux(d, n, "", latexStr, result)
+  of rnFootnoteGroup:
+    renderAux(d, n,
+      "<hr class=\"footnote\">" &
+          "<div class=\"footnote-group\">\n$1</div>\n",
+      "\n\n\\noindent\\rule{0.25\\linewidth}{.4pt}\n" &
+          "\\begin{rstfootnote}\n$1\\end{rstfootnote}\n\n",
+      result)
+  of rnFootnote, rnCitation:
+    var mark = ""
+    renderAux(d, n.sons[0], mark)
+    var body = ""
+    renderRstToOut(d, n.sons[1], body)
+    dispA(d.target, result,
+      "<div$2><div class=\"footnote-label\">" &
+          "<sup><strong><a href=\"#$4\">[$3]</a></strong></sup>" &
+          "</div> &ensp; $1\n</div>\n",
+      "\\item[\\textsuperscript{[$3]}]$2 $1\n",
+      [body, n.anchor.idS, mark, n.anchor])
+  of rnPandocRef:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[1], result, external=false)
+  of rnRstRef:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[0], result, external=false)
+  of rnStandaloneHyperlink:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[0], result, external=true)
+  of rnInternalRef:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[1], result, external=false)
+  of rnNimdocRef:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[1], result, external=false,
+                    nimdoc=true, tooltip=n.tooltip)
+  of rnHyperlink:
+    renderHyperlink(d, text=n.sons[0], link=n.sons[1], result, external=true)
+  of rnFootnoteRef:
+    var tmp = "["
+    renderAux(d, n.sons[0], tmp)
+    tmp.add "]"
+    dispA(d.target, result,
+      "<sup><strong><a class=\"reference internal\" href=\"#$2\">" &
+          "$1</a></strong></sup>",
+      "\\textsuperscript{\\hyperlink{$2}{\\textbf{$1}}}",
+      [tmp, n.sons[1].text])
+  of rnDirArg, rnRaw: renderAux(d, n, result)
+  of rnRawHtml:
+    if d.target != outLatex and not lastSon(n).isNil:
+      result.add addNodes(lastSon(n))
+  of rnRawLatex:
+    if d.target == outLatex and not lastSon(n).isNil:
+      result.add addNodes(lastSon(n))
+
+  of rnImage, rnFigure: renderImage(d, n, result)
+  of rnCodeBlock, rnInlineCode: renderCode(d, n, result)
+  of rnContainer: renderContainer(d, n, result)
+  of rnSubstitutionReferences, rnSubstitutionDef:
+    renderAux(d, n, "|$1|", "|$1|", result)
+  of rnDirective:
+    renderAux(d, n, "", "", result)
+  of rnUnknownRole, rnCodeFragment:
+    var tmp0 = ""
+    var tmp1 = ""
+    renderRstToOut(d, n.sons[0], tmp0)
+    renderRstToOut(d, n.sons[1], tmp1)
+    var class = tmp1
+    # don't allow missing role break latex compilation:
+    if d.target == outLatex and n.kind == rnUnknownRole: class = "Other"
+    if n.kind == rnCodeFragment:
+      dispA(d.target, result,
+            "<tt class=\"docutils literal\"><span class=\"pre $2\">" &
+              "$1</span></tt>",
+            "\\rstcode{\\span$2{$1}}", [tmp0, class])
+    else:  # rnUnknownRole, not necessarily code/monospace font
+      dispA(d.target, result, "<span class=\"$2\">$1</span>", "\\span$2{$1}",
+            [tmp0, class])
+  of rnSub: renderAux(d, n, "<sub>$1</sub>", "\\rstsub{$1}", result)
+  of rnSup: renderAux(d, n, "<sup>$1</sup>", "\\rstsup{$1}", result)
+  of rnEmphasis: renderAux(d, n, "<em>$1</em>", "\\emph{$1}", result)
+  of rnStrongEmphasis:
+    renderAux(d, n, "<strong>$1</strong>", "\\textbf{$1}", result)
+  of rnTripleEmphasis:
+    renderAux(d, n, "<strong><em>$1</em></strong>",
+                    "\\textbf{emph{$1}}", result)
+  of rnIdx:
+    renderIndexTerm(d, n, result)
+  of rnInlineLiteral, rnInterpretedText:
+    renderAux(d, n,
+      "<tt class=\"docutils literal\"><span class=\"pre\">$1</span></tt>",
+      "\\rstcode{$1}", result)
+  of rnInlineTarget:
+    var tmp = ""
+    renderAux(d, n, tmp)
+    dispA(d.target, result,
+      "<span class=\"target\" id=\"$2\">$1</span>",
+      "\\label{$2}\\hypertarget{$2}{$1}",
+      [tmp, rstnodeToRefname(n)])
+  of rnSmiley: renderSmiley(d, n, result)
+  of rnLeaf: result.add(esc(d.target, n.text, escMode=d.escMode))
+  of rnContents: d.hasToc = true
+  of rnDefaultRole: discard
+  of rnTitle:
+    d.meta[metaTitle] = ""
+    renderRstToOut(d, n.sons[0], d.meta[metaTitle])
+    d.meta[metaTitleRaw] = n.sons[0].addNodes
+
+# -----------------------------------------------------------------------------
+
+proc getVarIdx(varnames: openArray[string], id: string): int =
+  for i in countup(0, high(varnames)):
+    if cmpIgnoreStyle(varnames[i], id) == 0:
+      return i
+  result = -1
+
+proc formatNamedVars*(frmt: string, varnames: openArray[string],
+                      varvalues: openArray[string]): string =
+  var i = 0
+  var L = len(frmt)
+  result = ""
+  var num = 0
+  while i < L:
+    if frmt[i] == '$':
+      inc(i)                  # skip '$'
+      case frmt[i]
+      of '#':
+        add(result, varvalues[num])
+        inc(num)
+        inc(i)
+      of '$':
+        add(result, "$")
+        inc(i)
+      of '0'..'9':
+        var j = 0
+        while true:
+          j = (j * 10) + ord(frmt[i]) - ord('0')
+          inc(i)
+          if i > L-1 or frmt[i] notin {'0'..'9'}: break
+        if j > high(varvalues) + 1:
+          raise newException(ValueError, "invalid index: " & $j)
+        num = j
+        add(result, varvalues[j - 1])
+      of 'A'..'Z', 'a'..'z', '\x80'..'\xFF':
+        var id = ""
+        while true:
+          add(id, frmt[i])
+          inc(i)
+          if frmt[i] notin {'A'..'Z', '_', 'a'..'z', '\x80'..'\xFF'}: break
+        var idx = getVarIdx(varnames, id)
+        if idx >= 0:
+          add(result, varvalues[idx])
+        else:
+          raise newException(ValueError, "unknown substitution var: " & id)
+      of '{':
+        var id = ""
+        inc(i)
+        while frmt[i] != '}':
+          if frmt[i] == '\0':
+            raise newException(ValueError, "'}' expected")
+          add(id, frmt[i])
+          inc(i)
+        inc(i)                # skip }
+                              # search for the variable:
+        var idx = getVarIdx(varnames, id)
+        if idx >= 0: add(result, varvalues[idx])
+        else:
+          raise newException(ValueError, "unknown substitution var: " & id)
+      else:
+        raise newException(ValueError, "unknown substitution: $" & $frmt[i])
+    var start = i
+    while i < L:
+      if frmt[i] != '$': inc(i)
+      else: break
+    if i-1 >= start: add(result, substr(frmt, start, i - 1))
+
+
+proc defaultConfig*(): StringTableRef =
+  ## Returns a default configuration for embedded HTML generation.
+  ##
+  ## The returned ``StringTableRef`` contains the parameters used by the HTML
+  ## engine to build the final output. For information on what these parameters
+  ## are and their purpose, please look up the file ``config/nimdoc.cfg``
+  ## bundled with the compiler.
+  ##
+  ## The only difference between the contents of that file and the values
+  ## provided by this proc is the ``doc.file`` variable. The ``doc.file``
+  ## variable of the configuration file contains HTML to build standalone
+  ## pages, while this proc returns just the content for procs like
+  ## ``rstToHtml`` to generate the bare minimum HTML.
+  result = newStringTable(modeStyleInsensitive)
+
+  template setConfigVar(key, val) =
+    result[key] = val
+
+  # If you need to modify these values, it might be worth updating the template
+  # file in config/nimdoc.cfg.
+  setConfigVar("split.item.toc", "20")
+  setConfigVar("doc.section", """
+<div class="section" id="$sectionID">
+<h1><a class="toc-backref" href="#$sectionTitleID">$sectionTitle</a></h1>
+<dl class="item">
+$content
+</dl></div>
+""")
+  setConfigVar("doc.section.toc", """
+<li>
+  <a class="reference" href="#$sectionID" id="$sectionTitleID">$sectionTitle</a>
+  <ul class="simple">
+    $content
+  </ul>
+</li>
+""")
+  setConfigVar("doc.item", """
+<dt id="$itemID"><a name="$itemSymOrIDEnc"></a><pre>$header</pre></dt>
+<dd>
+$desc
+</dd>
+""")
+  setConfigVar("doc.item.toc", """
+  <li><a class="reference" href="#$itemSymOrIDEnc"
+    title="$header_plain">$name</a></li>
+""")
+  setConfigVar("doc.toc", """
+<div class="navigation" id="navigation">
+<ul class="simple">
+$content
+</ul>
+</div>""")
+  setConfigVar("doc.body_toc", """
+$tableofcontents
+<div class="content" id="content">
+$moduledesc
+$content
+</div>
+""")
+  setConfigVar("doc.listing_start", "<pre$3 class = \"listing\">")
+  setConfigVar("doc.listing_end", "</pre>")
+  setConfigVar("doc.listing_button", "</pre>")
+  setConfigVar("doc.body_no_toc", "$moduledesc $content")
+  setConfigVar("doc.file", "$content")
+  setConfigVar("doc.smiley_format", "/images/smilies/$1.gif")
+
+# ---------- forum ---------------------------------------------------------
+
+proc rstToHtml*(s: string, options: RstParseOptions,
+                config: StringTableRef,
+                msgHandler: MsgHandler = rst.defaultMsgHandler): string {.gcsafe.} =
+  ## Converts an input rst string into embeddable HTML.
+  ##
+  ## This convenience proc parses any input string using rst markup (it doesn't
+  ## have to be a full document!) and returns an embeddable piece of HTML. The
+  ## proc is meant to be used in *online* environments without access to a
+  ## meaningful filesystem, and therefore rst ``include`` like directives won't
+  ## work. For an explanation of the ``config`` parameter see the
+  ## ``initRstGenerator`` proc. Example:
+  ##
+  ##   ```nim
+  ##   import packages/docutils/rstgen, strtabs
+  ##
+  ##   echo rstToHtml("*Hello* **world**!", {},
+  ##     newStringTable(modeStyleInsensitive))
+  ##   # --> <em>Hello</em> <strong>world</strong>!
+  ##   ```
+  ##
+  ## If you need to allow the rst ``include`` directive or tweak the generated
+  ## output you have to create your own ``RstGenerator`` with
+  ## ``initRstGenerator`` and related procs.
+
+  proc myFindFile(filename: string): string =
+    # we don't find any files in online mode:
+    result = ""
+  proc myFindRefFile(filename: string): (string, string) =
+    result = ("", "")
+
+  const filen = "input"
+  let (rst, filenames, t) = rstParse(s, filen,
+                                     line=LineRstInit, column=ColRstInit,
+                                     options, myFindFile, myFindRefFile, msgHandler)
+  var d: RstGenerator
+  initRstGenerator(d, outHtml, config, filen, myFindFile, msgHandler,
+                   filenames, hasToc = t)
+  result = ""
+  renderRstToOut(d, rst, result)
+  strbasics.strip(result)
+
+
+proc rstToLatex*(rstSource: string; options: RstParseOptions): string {.inline, since: (1, 3).} =
+  ## Convenience proc for `renderRstToOut` and `initRstGenerator`.
+  runnableExamples: doAssert rstToLatex("*Hello* **world**", {}) == """\emph{Hello} \textbf{world}"""
+  if rstSource.len == 0: return
+  let (rst, filenames, t) = rstParse(rstSource, "",
+                                     line=LineRstInit, column=ColRstInit,
+                                     options)
+  var rstGenera: RstGenerator
+  rstGenera.initRstGenerator(outLatex, defaultConfig(), "input",
+                             filenames=filenames, hasToc = t)
+  rstGenera.renderRstToOut(rst, result)
+  strbasics.strip(result)
diff --git a/lib/packages/docutils/rstidx.nim b/lib/packages/docutils/rstidx.nim
new file mode 100644
index 000000000..1472d28fd
--- /dev/null
+++ b/lib/packages/docutils/rstidx.nim
@@ -0,0 +1,141 @@
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+
+## Nim `idx`:idx: file format related definitions.
+
+import std/[strutils, syncio, hashes]
+from std/os import splitFile
+
+type
+  IndexEntryKind* = enum ## discriminator tag
+    ieMarkupTitle = "markupTitle"
+                           ## RST/Markdown title, text in `keyword` +
+                           ## HTML text in `linkTitle`
+    ieNimTitle = "nimTitle"
+                           ## Nim title
+    ieHeading = "heading"  ## RST/Markdown markup heading, escaped
+    ieIdxRole = "idx"      ## RST :idx: definition, escaped
+    ieNim = "nim"          ## Nim symbol, unescaped
+    ieNimGroup = "nimgrp"  ## Nim overload group, unescaped
+  IndexEntry* = object
+    kind*: IndexEntryKind  ## 0.
+    keyword*: string       ## 1.
+    link*: string          ## 2.
+    linkTitle*: string     ## 3. contains a prettier text for the href
+    linkDesc*: string      ## 4. the title attribute of the final href
+    line*: int             ## 5.
+    module*: string        ## origin file, NOT a field in ``.idx`` file
+    aux*: string           ## auxuliary field, NOT a field in ``.idx`` file
+
+proc isDocumentationTitle*(hyperlink: string): bool =
+  ## Returns true if the hyperlink is actually a documentation title.
+  ##
+  ## Documentation titles lack the hash. See `mergeIndexes()
+  ## <#mergeIndexes,string>`_ for a more detailed explanation.
+  result = hyperlink.find('#') < 0
+
+proc `$`*(e: IndexEntry): string =
+  """("$1", "$2", "$3", "$4", $5)""" % [
+      e.keyword, e.link, e.linkTitle, e.linkDesc, $e.line]
+
+proc quoteIndexColumn(text: string): string =
+  ## Returns a safe version of `text` for serialization to the ``.idx`` file.
+  ##
+  ## The returned version can be put without worries in a line based tab
+  ## separated column text file. The following character sequence replacements
+  ## will be performed for that goal:
+  ##
+  ## * ``"\\"`` => ``"\\\\"``
+  ## * ``"\n"`` => ``"\\n"``
+  ## * ``"\t"`` => ``"\\t"``
+  result = newStringOfCap(text.len + 3)
+  for c in text:
+    case c
+    of '\\': result.add "\\"
+    of '\L': result.add "\\n"
+    of '\C': discard
+    of '\t': result.add "\\t"
+    else: result.add c
+
+proc unquoteIndexColumn*(text: string): string =
+  ## Returns the unquoted version generated by ``quoteIndexColumn``.
+  result = text.multiReplace(("\\t", "\t"), ("\\n", "\n"), ("\\\\", "\\"))
+
+proc formatIndexEntry*(kind: IndexEntryKind; htmlFile, id, term, linkTitle,
+                       linkDesc: string, line: int):
+                      tuple[entry: string, isTitle: bool] =
+  result.entry = $kind
+  result.entry.add('\t')
+  result.entry.add term
+  result.entry.add('\t')
+  result.entry.add(htmlFile)
+  if id.len > 0:
+    result.entry.add('#')
+    result.entry.add(id)
+    result.isTitle = false
+  else:
+    result.isTitle = true
+  result.entry.add('\t' & linkTitle.quoteIndexColumn)
+  result.entry.add('\t' & linkDesc.quoteIndexColumn)
+  result.entry.add('\t' & $line)
+  result.entry.add("\n")
+
+proc parseIndexEntryKind(s: string): IndexEntryKind =
+  result = case s:
+    of "nim": ieNim
+    of "nimgrp": ieNimGroup
+    of "heading": ieHeading
+    of "idx": ieIdxRole
+    of "nimTitle": ieNimTitle
+    of "markupTitle": ieMarkupTitle
+    else: raise newException(ValueError, "unknown index entry value $1" % [s])
+
+proc parseIdxFile*(path: string):
+    tuple[fileEntries: seq[IndexEntry], title: IndexEntry] =
+  var
+    f = 0
+  newSeq(result.fileEntries, 500)
+  setLen(result.fileEntries, 0)
+  let (_, base, _) = path.splitFile
+  for line in lines(path):
+    let s = line.find('\t')
+    if s < 0: continue
+    setLen(result.fileEntries, f+1)
+    let cols = line.split('\t')
+    result.fileEntries[f].kind = parseIndexEntryKind(cols[0])
+    result.fileEntries[f].keyword = cols[1]
+    result.fileEntries[f].link = cols[2]
+    if result.fileEntries[f].kind == ieIdxRole:
+      result.fileEntries[f].module = base
+    else:
+      if result.title.keyword.len == 0:
+        result.fileEntries[f].module = base
+      else:
+        result.fileEntries[f].module = result.title.keyword
+
+    result.fileEntries[f].linkTitle = cols[3].unquoteIndexColumn
+    result.fileEntries[f].linkDesc = cols[4].unquoteIndexColumn
+    result.fileEntries[f].line = parseInt(cols[5])
+
+    if result.fileEntries[f].kind in {ieNimTitle, ieMarkupTitle}:
+      result.title = result.fileEntries[f]
+    inc f
+
+proc cmp*(a, b: IndexEntry): int =
+  ## Sorts two ``IndexEntry`` 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: IndexEntry): Hash =
+  ## Returns the hash for the combined fields of the type.
+  ##
+  ## The hash is computed as the chained hash of the individual string hashes.
+  result = x.keyword.hash !& x.link.hash
+  result = result !& x.linkTitle.hash
+  result = result !& x.linkDesc.hash
+  result = !$result
diff --git a/lib/posix/epoll.nim b/lib/posix/epoll.nim
new file mode 100644
index 000000000..007488354
--- /dev/null
+++ b/lib/posix/epoll.nim
@@ -0,0 +1,99 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+from std/posix import SocketHandle
+
+const
+  EPOLLIN* = 0x00000001
+  EPOLLPRI* = 0x00000002
+  EPOLLOUT* = 0x00000004
+  EPOLLERR* = 0x00000008
+  EPOLLHUP* = 0x00000010
+  EPOLLRDNORM* = 0x00000040
+  EPOLLRDBAND* = 0x00000080
+  EPOLLWRNORM* = 0x00000100
+  EPOLLWRBAND* = 0x00000200
+  EPOLLMSG* = 0x00000400
+  EPOLLRDHUP* = 0x00002000
+  EPOLLEXCLUSIVE* = 1 shl 28
+  EPOLLWAKEUP* = 1 shl 29
+  EPOLLONESHOT* = 1 shl 30
+  EPOLLET* = 1 shl 31
+
+# Valid opcodes ( "op" parameter ) to issue to epoll_ctl().
+
+const
+  EPOLL_CTL_ADD* = 1          # Add a file descriptor to the interface.
+  EPOLL_CTL_DEL* = 2          # Remove a file descriptor from the interface.
+  EPOLL_CTL_MOD* = 3          # Change file descriptor epoll_event structure.
+
+# https://github.com/torvalds/linux/blob/ff6992735ade75aae3e35d16b17da1008d753d28/include/uapi/linux/eventpoll.h#L77
+when defined(linux) and defined(amd64):
+  {.pragma: epollPacked, packed.}
+else:
+  {.pragma: epollPacked.}
+
+type
+  EpollData* {.importc: "epoll_data_t",
+      header: "<sys/epoll.h>", pure, final, union.} = object
+    `ptr`* {.importc: "ptr".}: pointer
+    fd* {.importc: "fd".}: cint
+    u32* {.importc: "u32".}: uint32
+    u64* {.importc: "u64".}: uint64
+
+  EpollEvent* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final, epollPacked.} = object
+    events*: uint32 # Epoll events
+    data*: EpollData # User data variable
+
+proc epoll_create*(size: cint): cint {.importc: "epoll_create",
+    header: "<sys/epoll.h>".}
+  ## Creates an epoll instance.  Returns an fd for the new instance.
+  ##
+  ## The "size" parameter is a hint specifying the number of file
+  ## descriptors to be associated with the new instance.  The fd
+  ## returned by epoll_create() should be closed with close().
+
+proc epoll_create1*(flags: cint): cint {.importc: "epoll_create1",
+    header: "<sys/epoll.h>".}
+  ## Same as epoll_create but with an FLAGS parameter.  The unused SIZE
+  ## parameter has been dropped.
+
+proc epoll_ctl*(epfd: cint; op: cint; fd: cint | SocketHandle; event: ptr EpollEvent): cint {.
+    importc: "epoll_ctl", header: "<sys/epoll.h>".}
+  ## Manipulate an epoll instance "epfd". Returns `0` in case of success,
+  ## `-1` in case of error (the "errno" variable will contain the specific error code).
+  ##
+  ## The "op" parameter is one of the `EPOLL_CTL_*`
+  ## constants defined above. The "fd" parameter is the target of the
+  ## operation. The "event" parameter describes which events the caller
+  ## is interested in and any associated user data.
+
+proc epoll_wait*(epfd: cint; events: ptr EpollEvent; maxevents: cint;
+                 timeout: cint): cint {.importc: "epoll_wait",
+    header: "<sys/epoll.h>".}
+  ## Wait for events on an epoll instance "epfd". Returns the number of
+  ## triggered events returned in "events" buffer. Or -1 in case of
+  ## error with the "errno" variable set to the specific error code. The
+  ## "events" parameter is a buffer that will contain triggered
+  ## events. The "maxevents" is the maximum number of events to be
+  ## returned ( usually size of "events" ). The "timeout" parameter
+  ## specifies the maximum wait time in milliseconds (-1 == infinite).
+  ##
+  ## This function is a cancellation point and therefore not marked with
+  ## __THROW.
+
+
+#proc epoll_pwait*(epfd: cint; events: ptr EpollEvent; maxevents: cint;
+#                  timeout: cint; ss: ptr sigset_t): cint {.
+#    importc: "epoll_pwait", header: "<sys/epoll.h>".}
+# Same as epoll_wait, but the thread's signal mask is temporarily
+# and atomically replaced with the one provided as parameter.
+#
+# This function is a cancellation point and therefore not marked with
+# __THROW.
diff --git a/lib/posix/inotify.nim b/lib/posix/inotify.nim
new file mode 100644
index 000000000..575accc18
--- /dev/null
+++ b/lib/posix/inotify.nim
@@ -0,0 +1,111 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+# Get the platform-dependent flags.
+# Structure describing an inotify event.
+type
+  InotifyEvent* {.pure, final, importc: "struct inotify_event",
+                  header: "<sys/inotify.h>",
+                  completeStruct.} = object            ## An Inotify event.
+    wd* {.importc: "wd".}: FileHandle                  ## Watch descriptor.
+    mask* {.importc: "mask".}: uint32                  ## Watch mask.
+    cookie* {.importc: "cookie".}: uint32              ## Cookie to synchronize two events.
+    len* {.importc: "len".}: uint32                    ## Length (including NULs) of name.
+    name* {.importc: "name".}: UncheckedArray[char]    ## Name.
+
+# Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH.
+const
+  IN_ACCESS* = 0x00000001                          ## File was accessed.
+  IN_MODIFY* = 0x00000002                          ## File was modified.
+  IN_ATTRIB* = 0x00000004                          ## Metadata changed.
+  IN_CLOSE_WRITE* = 0x00000008                     ## Writtable file was closed.
+  IN_CLOSE_NOWRITE* = 0x00000010                   ## Unwrittable file closed.
+  IN_CLOSE* = (IN_CLOSE_WRITE or IN_CLOSE_NOWRITE) ## Close.
+  IN_OPEN* = 0x00000020                            ## File was opened.
+  IN_MOVED_FROM* = 0x00000040                      ## File was moved from X.
+  IN_MOVED_TO* = 0x00000080                        ## File was moved to Y.
+  IN_MOVE* = (IN_MOVED_FROM or IN_MOVED_TO)        ## Moves.
+  IN_CREATE* = 0x00000100                          ## Subfile was created.
+  IN_DELETE* = 0x00000200                          ## Subfile was deleted.
+  IN_DELETE_SELF* = 0x00000400                     ## Self was deleted.
+  IN_MOVE_SELF* = 0x00000800                       ## Self was moved.
+
+# Events sent by the kernel.
+const
+  IN_UNMOUNT* = 0x00002000    ## Backing fs was unmounted.
+  IN_Q_OVERFLOW* = 0x00004000 ## Event queued overflowed.
+  IN_IGNORED* = 0x00008000    ## File was ignored.
+
+# Special flags.
+const
+  IN_ONLYDIR* = 0x01000000     ## Only watch the path if it is a directory.
+  IN_DONT_FOLLOW* = 0x02000000 ## Do not follow a sym link.
+  IN_EXCL_UNLINK* = 0x04000000 ## Exclude events on unlinked objects.
+  IN_MASK_ADD* = 0x20000000    ## Add to the mask of an already existing watch.
+  IN_ISDIR* = 0x40000000       ## Event occurred against dir.
+  IN_ONESHOT* = 0x80000000     ## Only send event once.
+
+# All events which a program can wait on.
+const
+  IN_ALL_EVENTS* = (IN_ACCESS or IN_MODIFY or IN_ATTRIB or IN_CLOSE_WRITE or
+      IN_CLOSE_NOWRITE or IN_OPEN or IN_MOVED_FROM or IN_MOVED_TO or
+      IN_CREATE or IN_DELETE or IN_DELETE_SELF or IN_MOVE_SELF)
+
+
+proc inotify_init*(): FileHandle {.cdecl, importc: "inotify_init",
+    header: "<sys/inotify.h>".}
+  ## Create and initialize inotify instance.
+
+proc inotify_init1*(flags: cint): FileHandle {.cdecl, importc: "inotify_init1",
+    header: "<sys/inotify.h>".}
+  ## Like `inotify_init<#inotify_init>`_ ,
+  ## but has a flags argument that provides access to some extra functionality.
+
+proc inotify_add_watch*(fd: cint; name: cstring; mask: uint32): cint {.cdecl,
+    importc: "inotify_add_watch", header: "<sys/inotify.h>".}
+  ## Add watch of object NAME to inotify instance FD. Notify about events specified by MASK.
+
+proc inotify_rm_watch*(fd: cint; wd: cint): cint {.cdecl,
+    importc: "inotify_rm_watch", header: "<sys/inotify.h>".}
+  ## Remove the watch specified by WD from the inotify instance FD.
+
+iterator inotify_events*(evs: pointer, n: int): ptr InotifyEvent =
+  ## Abstract the packed buffer interface to yield event object pointers.
+  runnableExamples("-r:off"):
+    when defined(linux):
+       import std/posix  # needed for FileHandle read procedure
+       const MaxWatches = 8192
+
+       let inotifyFd = inotify_init()  # create new inotify instance and get it's FileHandle
+       let wd = inotifyFd.inotify_add_watch("/tmp", IN_CREATE or IN_DELETE)  # Add new watch
+
+       var events: array[MaxWatches, byte]  # event buffer
+       while (let n = read(inotifyFd, addr events, MaxWatches); n) > 0:  # blocks until any events have been read
+         for e in inotify_events(addr events, n):
+           echo (e[].wd, e[].mask, cast[cstring](addr e[].name))    # echo watch id, mask, and name value of each event
+  var ev: ptr InotifyEvent = cast[ptr InotifyEvent](evs)
+  var n = n
+  while n > 0:
+    yield ev
+    let sz = InotifyEvent.sizeof + int(ev[].len)
+    n -= sz
+    ev = cast[ptr InotifyEvent](cast[uint](ev) + uint(sz))
+
+runnableExamples:
+  when defined(linux):
+    let inotifyFd = inotify_init()  # create and get new inotify FileHandle
+    doAssert inotifyFd >= 0         # check for errors
+
+    let wd = inotifyFd.inotify_add_watch("/tmp", IN_CREATE or IN_DELETE)  # Add new watch
+    doAssert wd >= 0                 # check for errors
+
+    discard inotifyFd.inotify_rm_watch(wd) # remove watch
diff --git a/lib/posix/kqueue.nim b/lib/posix/kqueue.nim
new file mode 100644
index 000000000..2450cdb42
--- /dev/null
+++ b/lib/posix/kqueue.nim
@@ -0,0 +1,161 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+from std/posix import Timespec
+
+when defined(macosx) or defined(freebsd) or defined(openbsd) or
+     defined(dragonfly):
+  const
+    EVFILT_READ*     = -1
+    EVFILT_WRITE*    = -2
+    EVFILT_AIO*      = -3 ## attached to aio requests
+    EVFILT_VNODE*    = -4 ## attached to vnodes
+    EVFILT_PROC*     = -5 ## attached to struct proc
+    EVFILT_SIGNAL*   = -6 ## attached to struct proc
+    EVFILT_TIMER*    = -7 ## timers
+elif defined(netbsd):
+  const
+    EVFILT_READ*     = 0
+    EVFILT_WRITE*    = 1
+    EVFILT_AIO*      = 2 ## attached to aio requests
+    EVFILT_VNODE*    = 3 ## attached to vnodes
+    EVFILT_PROC*     = 4 ## attached to struct proc
+    EVFILT_SIGNAL*   = 5 ## attached to struct proc
+    EVFILT_TIMER*    = 6 ## timers (in ms)
+when defined(macosx):
+  const
+    EVFILT_MACHPORT* = -8  ## Mach portsets
+    EVFILT_FS*       = -9  ## filesystem events
+    EVFILT_USER*     = -10 ## user events
+    EVFILT_VM        = -12 ## virtual memory events
+elif defined(freebsd):
+  const
+    EVFILT_FS*       = -9  ## filesystem events
+    EVFILT_LIO*      = -10 ## attached to lio requests
+    EVFILT_USER*     = -11 ## user events
+elif defined(dragonfly):
+  const
+    EVFILT_EXCEPT*   = -8  ## exceptional conditions
+    EVFILT_USER*     = -9  ## user events
+    EVFILT_FS*       = -10 ## filesystem events
+
+# Actions:
+const
+  EV_ADD*      = 0x0001 ## Add event to queue (implies enable).
+                        ## Re-adding an existing element modifies it.
+  EV_DELETE*   = 0x0002 ## Delete event from queue.
+  EV_ENABLE*   = 0x0004 ## Enable event.
+  EV_DISABLE*  = 0x0008 ## Disable event (not reported).
+
+# Flags:
+const
+  EV_ONESHOT*  = 0x0010 ## Only report one occurrence.
+  EV_CLEAR*    = 0x0020 ## Clear event state after reporting.
+  EV_RECEIPT*  = 0x0040 ## Force EV_ERROR on success, data == 0
+  EV_DISPATCH* = 0x0080 ## Disable event after reporting.
+
+  EV_SYSFLAGS* = 0xF000 ## Reserved by system
+  EV_DROP*     = 0x1000 ## Not should be dropped
+  EV_FLAG1*    = 0x2000 ## Filter-specific flag
+
+# Return values:
+const
+  EV_EOF*      = 0x8000 ## EOF detected
+  EV_ERROR*    = 0x4000 ## Error, data contains errno
+  EV_NODATA*   = 0x1000 ## EOF and no more data
+
+when defined(macosx) or defined(freebsd) or defined(dragonfly):
+  # EVFILT_USER is not supported by OpenBSD and NetBSD
+  #
+  # data/hint flags/masks for EVFILT_USER, shared with userspace
+  #
+  # On input, the top two bits of fflags specifies how the lower twenty four
+  # bits should be applied to the stored value of fflags.
+  #
+  # On output, the top two bits will always be set to NOTE_FFNOP and the
+  # remaining twenty four bits will contain the stored fflags value.
+  const
+    NOTE_FFNOP*      = 0x00000000'u32 ## ignore input fflags
+    NOTE_FFAND*      = 0x40000000'u32 ## AND fflags
+    NOTE_FFOR*       = 0x80000000'u32 ## OR fflags
+    NOTE_FFCOPY*     = 0xc0000000'u32 ## copy fflags
+    NOTE_FFCTRLMASK* = 0xc0000000'u32 ## masks for operations
+    NOTE_FFLAGSMASK* = 0x00ffffff'u32
+
+    NOTE_TRIGGER*    = 0x01000000'u32 ## Cause the event to be triggered
+                                      ## for output.
+
+# data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
+const
+  NOTE_LOWAT*      = 0x0001 ## low water mark
+
+# data/hint flags for EVFILT_VNODE, shared with userspace
+const
+  NOTE_DELETE*     = 0x0001 ## vnode was removed
+  NOTE_WRITE*      = 0x0002 ## data contents changed
+  NOTE_EXTEND*     = 0x0004 ## size increased
+  NOTE_ATTRIB*     = 0x0008 ## attributes changed
+  NOTE_LINK*       = 0x0010 ## link count changed
+  NOTE_RENAME*     = 0x0020 ## vnode was renamed
+  NOTE_REVOKE*     = 0x0040 ## vnode access was revoked
+
+# data/hint flags for EVFILT_PROC, shared with userspace
+const
+  NOTE_EXIT*       = 0x80000000'u32 ## process exited
+  NOTE_FORK*       = 0x40000000'u32 ## process forked
+  NOTE_EXEC*       = 0x20000000'u32 ## process exec'd
+  NOTE_PCTRLMASK*  = 0xf0000000'u32 ## mask for hint bits
+  NOTE_PDATAMASK*  = 0x000fffff'u32 ## mask for pid
+
+# additional flags for EVFILT_PROC
+const
+  NOTE_TRACK*      = 0x00000001'u32 ## follow across forks
+  NOTE_TRACKERR*   = 0x00000002'u32 ## could not track child
+  NOTE_CHILD*      = 0x00000004'u32 ## am a child process
+
+when defined(macosx) or defined(freebsd):
+  # additional flags for EVFILE_TIMER
+  const
+    NOTE_SECONDS*    = 0x00000001'u32 ## data is seconds
+    NOTE_MSECONDS*   = 0x00000002'u32 ## data is milliseconds
+    NOTE_USECONDS*   = 0x00000004'u32 ## data is microseconds
+    NOTE_NSECONDS*   = 0x00000008'u32 ## data is nanoseconds
+else:
+  # NetBSD and OpenBSD doesn't support NOTE_{TIME} constants, but
+  # support EVFILT_TIMER with granularity of milliseconds.
+  const
+    NOTE_MSECONDS*   = 0x00000000'u32
+
+type
+  ## This define not fully satisfy NetBSD "struct kevent"
+  ## but it works and tested.
+  KEvent* {.importc: "struct kevent",
+            header: """#include <sys/types.h>
+                       #include <sys/event.h>
+                       #include <sys/time.h>""", pure, final.} = object
+    ident*  : uint     ## identifier for this event  (uintptr_t)
+    filter* : cshort   ## filter for event
+    flags*  : cushort  ## general flags
+    fflags* : cuint    ## filter-specific flags
+    data*   : int      ## filter-specific data  (intptr_t)
+    udata*  : pointer  ## opaque user data identifier
+
+proc kqueue*(): cint {.importc: "kqueue", header: "<sys/event.h>".}
+  ## Creates new queue and returns its descriptor.
+
+proc kevent*(kqFD: cint,
+             changelist: ptr KEvent, nchanges: cint,
+             eventlist: ptr KEvent, nevents: cint, timeout: ptr Timespec): cint
+     {.importc: "kevent", header: "<sys/event.h>".}
+  ## Manipulates queue for given `kqFD` descriptor.
+
+proc EV_SET*(event: ptr KEvent, ident: uint, filter: cshort, flags: cushort,
+             fflags: cuint, data: int, udata: pointer)
+     {.importc: "EV_SET", header: "<sys/event.h>".}
+  ## Fills event with given data.
diff --git a/lib/posix/linux.nim b/lib/posix/linux.nim
new file mode 100644
index 000000000..29fd4288d
--- /dev/null
+++ b/lib/posix/linux.nim
@@ -0,0 +1,39 @@
+import std/posix
+
+## Flags of `clone` syscall.
+## See `clone syscall manual
+## <https://man7.org/linux/man-pages/man2/clone.2.html>`_ for more information.
+const
+  CSIGNAL* = 0x000000FF'i32
+  CLONE_VM* = 0x00000100'i32
+  CLONE_FS* = 0x00000200'i32
+  CLONE_FILES* = 0x00000400'i32
+  CLONE_SIGHAND* = 0x00000800'i32
+  CLONE_PIDFD* = 0x00001000'i32
+  CLONE_PTRACE* = 0x00002000'i32
+  CLONE_VFORK* = 0x00004000'i32
+  CLONE_PARENT* = 0x00008000'i32
+  CLONE_THREAD* = 0x00010000'i32
+  CLONE_NEWNS* = 0x00020000'i32
+  CLONE_SYSVSEM* = 0x00040000'i32
+  CLONE_SETTLS* = 0x00080000'i32
+  CLONE_PARENT_SETTID* = 0x00100000'i32
+  CLONE_CHILD_CLEARTID* = 0x00200000'i32
+  CLONE_DETACHED* = 0x00400000'i32
+  CLONE_UNTRACED* = 0x00800000'i32
+  CLONE_CHILD_SETTID* = 0x01000000'i32
+  CLONE_NEWCGROUP* = 0x02000000'i32
+  CLONE_NEWUTS* = 0x04000000'i32
+  CLONE_NEWIPC* = 0x08000000'i32
+  CLONE_NEWUSER* = 0x10000000'i32
+  CLONE_NEWPID* = 0x20000000'i32
+  CLONE_NEWNET* = 0x40000000'i32
+  CLONE_IO* = 0x80000000'i32
+
+
+# fn should be of type proc (a2: pointer) {.cdecl.}
+proc clone*(fn: pointer; child_stack: pointer; flags: cint;
+            arg: pointer; ptid: ptr Pid; tls: pointer;
+            ctid: ptr Pid): cint {.importc, header: "<sched.h>".}
+
+proc pipe2*(a: array[0..1, cint], flags: cint): cint {.importc, header: "<unistd.h>".}
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index 6bda372bb..fbe945df3 100755..100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -13,48 +13,57 @@
 # net/if, sys/socket, sys/uio, netinet/in, netinet/tcp, netdb
 
 ## This is a raw POSIX interface module. It does not not provide any
-## convenience: cstrings are used instead of proper Nimrod strings and
-## return codes indicate errors. If you want exceptions 
-## and a proper Nimrod-like interface, use the OS module or write a wrapper.
-
+## convenience: cstrings are used instead of proper Nim strings and
+## return codes indicate errors. If you want exceptions
+## and a proper Nim-like interface, use the OS module or write a wrapper.
+##
+## For high-level wrappers specialized for Linux and BSDs see:
+## `posix_utils <posix_utils.html>`_
+##
 ## Coding conventions:
 ## ALL types are named the same as in the POSIX standard except that they start
-## with 'T' or 'P' (if they are pointers) and without the '_t' prefix to be
-## consistent with Nimrod conventions. If an identifier is a Nimrod keyword
+## with 'T' or 'P' (if they are pointers) and without the '_t' suffix to be
+## consistent with Nim conventions. If an identifier is a Nim keyword
 ## the \`identifier\` notation is used.
 ##
-## This library relies on the header files of your C compiler. Thus the
-## resulting C code will just include <XYZ.h> and *not* define the
+## This library relies on the header files of your C compiler. The
+## resulting C code will just `#include <XYZ.h>` and *not* define the
 ## symbols declared here.
 
-from times import TTime
+# Dead code elimination ensures that we don't accidentally generate #includes
+# for files that might not exist on a specific platform! The user will get an
+# error only if they actually try to use the missing declaration
 
-const
-  hasSpawnH = defined(linux)
-  hasAioH = defined(linux)
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
 
+# TODO these constants don't seem to be fetched from a header file for unknown
+#      platforms - where do they come from and why are they here?
 when false:
   const
-    C_IRUSR = 0c000400 ## Read by owner.
-    C_IWUSR = 0c000200 ## Write by owner.
-    C_IXUSR = 0c000100 ## Execute by owner.
-    C_IRGRP = 0c000040 ## Read by group.
-    C_IWGRP = 0c000020 ## Write by group.
-    C_IXGRP = 0c000010 ## Execute by group.
-    C_IROTH = 0c000004 ## Read by others.
-    C_IWOTH = 0c000002 ## Write by others.
-    C_IXOTH = 0c000001 ## Execute by others.
-    C_ISUID = 0c004000 ## Set user ID.
-    C_ISGID = 0c002000 ## Set group ID.
-    C_ISVTX = 0c001000 ## On directories, restricted deletion flag.
-    C_ISDIR = 0c040000 ## Directory.
-    C_ISFIFO = 0c010000 ##FIFO.
-    C_ISREG = 0c100000 ## Regular file.
-    C_ISBLK = 0c060000 ## Block special.
-    C_ISCHR = 0c020000 ## Character special.
-    C_ISCTG = 0c110000 ## Reserved.
-    C_ISLNK = 0c120000 ## Symbolic link.</p>
-    C_ISSOCK = 0c140000 ## Socket.
+    C_IRUSR = 0o000400 ## Read by owner.
+    C_IWUSR = 0o000200 ## Write by owner.
+    C_IXUSR = 0o000100 ## Execute by owner.
+    C_IRGRP = 0o000040 ## Read by group.
+    C_IWGRP = 0o000020 ## Write by group.
+    C_IXGRP = 0o000010 ## Execute by group.
+    C_IROTH = 0o000004 ## Read by others.
+    C_IWOTH = 0o000002 ## Write by others.
+    C_IXOTH = 0o000001 ## Execute by others.
+    C_ISUID = 0o004000 ## Set user ID.
+    C_ISGID = 0o002000 ## Set group ID.
+    C_ISVTX = 0o001000 ## On directories, restricted deletion flag.
+    C_ISDIR = 0o040000 ## Directory.
+    C_ISFIFO = 0o010000 ##FIFO.
+    C_ISREG = 0o100000 ## Regular file.
+    C_ISBLK = 0o060000 ## Block special.
+    C_ISCHR = 0o020000 ## Character special.
+    C_ISCTG = 0o110000 ## Reserved.
+    C_ISLNK = 0o120000 ## Symbolic link.</p>
+    C_ISSOCK = 0o140000 ## Socket.
 
 const
   MM_NULLLBL* = nil
@@ -63,1657 +72,69 @@ const
   MM_NULLTXT* = nil
   MM_NULLACT* = nil
   MM_NULLTAG* = nil
-  
+
   STDERR_FILENO* = 2 ## File number of stderr;
   STDIN_FILENO* = 0  ## File number of stdin;
-  STDOUT_FILENO* = 1 ## File number of stdout; 
-
-type
-  TDIR* {.importc: "DIR", header: "<dirent.h>", final, pure.} = object
-    ## A type representing a directory stream. 
-
-  Tdirent* {.importc: "struct dirent", 
-             header: "<dirent.h>", final, pure.} = object ## dirent_t struct
-    d_ino*: TIno  ## File serial number.
-    d_name*: array [0..255, char] ## Name of entry.
-
-  Tflock* {.importc: "flock", final, pure,
-            header: "<fcntl.h>".} = object ## flock type
-    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. 
-    l_whence*: cshort ## Flag for starting offset. 
-    l_start*: Toff    ## Relative offset in bytes. 
-    l_len*: Toff      ## Size; if 0 then until EOF. 
-    l_pid*: TPid      ## Process ID of the process holding the lock; 
-                      ## returned with F_GETLK. 
-  
-  Tfenv* {.importc: "fenv_t", header: "<fenv.h>", final, pure.} = 
-    object ## Represents the entire floating-point environment. The
-           ## floating-point environment refers collectively to any
-           ## floating-point status flags and control modes supported
-           ## by the implementation.
-  Tfexcept* {.importc: "fexcept_t", header: "<fenv.h>", final, pure.} = 
-    object ## Represents the floating-point status flags collectively, 
-           ## including any status the implementation associates with the 
-           ## flags. A floating-point status flag is a system variable 
-           ## whose value is set (but never cleared) when a floating-point
-           ## exception is raised, which occurs as a side effect of
-           ## exceptional floating-point arithmetic to provide auxiliary
-           ## information. A floating-point control mode is a system variable
-           ## whose value may be set by the user to affect the subsequent 
-           ## behavior of floating-point arithmetic.
-
-  TFTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
-    base*: cint
-    level*: cint
-    
-  TGlob* {.importc: "glob_t", header: "<glob.h>", 
-           final, pure.} = object ## glob_t
-    gl_pathc*: int          ## Count of paths matched by pattern. 
-    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames. 
-    gl_offs*: int           ## Slots to reserve at the beginning of gl_pathv. 
-  
-  TGroup* {.importc: "struct group", header: "<grp.h>", 
-            final, pure.} = object ## struct group
-    gr_name*: cstring     ## The name of the group. 
-    gr_gid*: TGid         ## Numerical group ID. 
-    gr_mem*: cstringArray ## Pointer to a null-terminated array of character 
-                          ## pointers to member names. 
-
-  Ticonv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} = 
-    object ## Identifies the conversion from one codeset to another.
-
-  Tlconv* {.importc: "struct lconv", header: "<locale.h>", final,
-            pure.} = object
-    currency_symbol*: cstring
-    decimal_point*: cstring
-    frac_digits*: char
-    grouping*: cstring
-    int_curr_symbol*: cstring
-    int_frac_digits*: char
-    int_n_cs_precedes*: char
-    int_n_sep_by_space*: char
-    int_n_sign_posn*: char
-    int_p_cs_precedes*: char
-    int_p_sep_by_space*: char
-    int_p_sign_posn*: char
-    mon_decimal_point*: cstring
-    mon_grouping*: cstring
-    mon_thousands_sep*: cstring
-    negative_sign*: cstring
-    n_cs_precedes*: char
-    n_sep_by_space*: char
-    n_sign_posn*: char
-    positive_sign*: cstring
-    p_cs_precedes*: char
-    p_sep_by_space*: char
-    p_sign_posn*: char
-    thousands_sep*: cstring
-
-  TMqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
-  TMqAttr* {.importc: "struct mq_attr", 
-             header: "<mqueue.h>", 
-             final, pure.} = object ## message queue attribute
-    mq_flags*: int   ## Message queue flags. 
-    mq_maxmsg*: int  ## Maximum number of messages. 
-    mq_msgsize*: int ## Maximum message size. 
-    mq_curmsgs*: int ## Number of messages currently queued. 
-
-  TPasswd* {.importc: "struct passwd", header: "<pwd.h>", 
-             final, pure.} = object ## struct passwd
-    pw_name*: cstring   ## User's login name. 
-    pw_uid*: TUid       ## Numerical user ID. 
-    pw_gid*: TGid       ## Numerical group ID. 
-    pw_dir*: cstring    ## Initial working directory. 
-    pw_shell*: cstring  ## Program to use as shell. 
-
-  Tblkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int
-    ## used for file block counts
-  Tblksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int
-    ## used for block sizes
-  TClock* {.importc: "clock_t", header: "<sys/types.h>".} = int
-  TClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
-  TDev* {.importc: "dev_t", header: "<sys/types.h>".} = int
-  Tfsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
-  Tfsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
-  TGid* {.importc: "gid_t", header: "<sys/types.h>".} = int
-  Tid* {.importc: "id_t", header: "<sys/types.h>".} = int
-  Tino* {.importc: "ino_t", header: "<sys/types.h>".} = int
-  TKey* {.importc: "key_t", header: "<sys/types.h>".} = int
-  TMode* {.importc: "mode_t", header: "<sys/types.h>".} = int
-  TNlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int
-  TOff* {.importc: "off_t", header: "<sys/types.h>".} = int64
-  TPid* {.importc: "pid_t", header: "<sys/types.h>".} = int
-  Tpthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int
-  Tpthread_barrier* {.importc: "pthread_barrier_t", 
-                      header: "<sys/types.h>".} = int
-  Tpthread_barrierattr* {.importc: "pthread_barrierattr_t", 
-                          header: "<sys/types.h>".} = int
-  Tpthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = int
-  Tpthread_condattr* {.importc: "pthread_condattr_t", 
-                       header: "<sys/types.h>".} = int
-  Tpthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = int
-  Tpthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
-  Tpthread_mutexattr* {.importc: "pthread_mutexattr_t", 
-                        header: "<sys/types.h>".} = int
-  Tpthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = int
-  Tpthread_rwlock* {.importc: "pthread_rwlock_t", 
-                     header: "<sys/types.h>".} = int
-  Tpthread_rwlockattr* {.importc: "pthread_rwlockattr_t", 
-                         header: "<sys/types.h>".} = int
-  Tpthread_spinlock* {.importc: "pthread_spinlock_t", 
-                       header: "<sys/types.h>".} = int
-  Tpthread* {.importc: "pthread_t", header: "<sys/types.h>".} = int
-  Tsuseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int
-  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
-  Ttimer* {.importc: "timer_t", header: "<sys/types.h>".} = int
-  Ttrace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int
-  Ttrace_event_id* {.importc: "trace_event_id_t", 
-                     header: "<sys/types.h>".} = int
-  Ttrace_event_set* {.importc: "trace_event_set_t", 
-                      header: "<sys/types.h>".} = int
-  Ttrace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
-  Tuid* {.importc: "uid_t", header: "<sys/types.h>".} = int
-  Tuseconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
-  
-  Tutsname* {.importc: "struct utsname", 
-              header: "<sys/utsname.h>", 
-              final, pure.} = object ## struct utsname
-    sysname*,      ## Name of this implementation of the operating system. 
-      nodename*,   ## Name of this node within the communications 
-                   ## network to which this node is attached, if any. 
-      release*,    ## Current release level of this implementation. 
-      version*,    ## Current version level of this release. 
-      machine*: array [0..255, char] ## Name of the hardware type on which the
-                                     ## system is running. 
-
-  TSem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
-  Tipc_perm* {.importc: "struct ipc_perm", 
-               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
-    uid*: tuid    ## Owner's user ID. 
-    gid*: tgid    ## Owner's group ID. 
-    cuid*: Tuid   ## Creator's user ID. 
-    cgid*: Tgid   ## Creator's group ID. 
-    mode*: TMode  ## Read/write permission. 
-  
-  TStat* {.importc: "struct stat", 
-           header: "<sys/stat.h>", final, pure.} = object ## struct stat
-    st_dev*: TDev          ## Device ID of device containing file. 
-    st_ino*: TIno          ## File serial number. 
-    st_mode*: TMode        ## Mode of file (see below). 
-    st_nlink*: tnlink      ## Number of hard links to the file. 
-    st_uid*: tuid          ## User ID of file. 
-    st_gid*: Tgid          ## Group ID of file. 
-    st_rdev*: TDev         ## Device ID (if file is character or block special). 
-    st_size*: TOff         ## For regular files, the file size in bytes. 
-                           ## For symbolic links, the length in bytes of the 
-                           ## pathname contained in the symbolic link. 
-                           ## For a shared memory object, the length in bytes. 
-                           ## For a typed memory object, the length in bytes. 
-                           ## For other file types, the use of this field is 
-                           ## unspecified. 
-    st_atime*: ttime       ## Time of last access. 
-    st_mtime*: ttime       ## Time of last data modification. 
-    st_ctime*: ttime       ## Time of last status change. 
-    st_blksize*: Tblksize  ## A file system-specific preferred I/O block size  
-                           ## for this object. In some file system types, this 
-                           ## may vary from file to file. 
-    st_blocks*: Tblkcnt    ## Number of blocks allocated for this object. 
-
-  
-  TStatvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>", 
-              final, pure.} = object ## struct statvfs
-    f_bsize*: int        ## File system block size. 
-    f_frsize*: int       ## Fundamental file system block size. 
-    f_blocks*: Tfsblkcnt ## Total number of blocks on file system
-                         ## in units of f_frsize. 
-    f_bfree*: Tfsblkcnt  ## Total number of free blocks. 
-    f_bavail*: Tfsblkcnt ## Number of free blocks available to 
-                         ## non-privileged process. 
-    f_files*: Tfsfilcnt  ## Total number of file serial numbers. 
-    f_ffree*: Tfsfilcnt  ## Total number of free file serial numbers. 
-    f_favail*: Tfsfilcnt ## Number of file serial numbers available to 
-                         ## non-privileged process. 
-    f_fsid*: int         ## File system ID. 
-    f_flag*: int         ## Bit mask of f_flag values. 
-    f_namemax*: int      ## Maximum filename length. 
-
-  Tposix_typed_mem_info* {.importc: "struct posix_typed_mem_info", 
-                           header: "<sys/mman.h>", final, pure.} = object
-    posix_tmi_length*: int
-  
-  Ttm* {.importc: "struct tm", header: "<time.h>", 
-         final, pure.} = object ## struct tm
-    tm_sec*: cint   ## Seconds [0,60]. 
-    tm_min*: cint   ## Minutes [0,59]. 
-    tm_hour*: cint  ## Hour [0,23]. 
-    tm_mday*: cint  ## Day of month [1,31]. 
-    tm_mon*: cint   ## Month of year [0,11]. 
-    tm_year*: cint  ## Years since 1900. 
-    tm_wday*: cint  ## Day of week [0,6] (Sunday =0). 
-    tm_yday*: cint  ## Day of year [0,365]. 
-    tm_isdst*: cint ## Daylight Savings flag. 
-  Ttimespec* {.importc: "struct timespec", 
-               header: "<time.h>", final, pure.} = object ## struct timespec
-    tv_sec*: Ttime ## Seconds. 
-    tv_nsec*: int  ## Nanoseconds. 
-  titimerspec* {.importc: "struct itimerspec", header: "<time.h>", 
-                 final, pure.} = object ## struct itimerspec
-    it_interval*: ttimespec ## Timer period. 
-    it_value*: ttimespec    ## Timer expiration. 
-  
-  Tsig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
-    ## Possibly volatile-qualified integer type of an object that can be 
-    ## accessed as an atomic entity, even in the presence of asynchronous
-    ## interrupts.
-  Tsigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
-  
-  TsigEvent* {.importc: "struct sigevent", 
-               header: "<signal.h>", final, pure.} = object ## struct sigevent
-    sigev_notify*: cint           ## Notification type. 
-    sigev_signo*: cint            ## Signal number. 
-    sigev_value*: Tsigval         ## Signal value. 
-    sigev_notify_function*: proc (x: TSigval) {.noconv.} ## Notification func. 
-    sigev_notify_attributes*: ptr Tpthreadattr ## Notification attributes.
-
-  TsigVal* {.importc: "union sigval", 
-             header: "<signal.h>", final, pure.} = object ## struct sigval
-    sival_ptr*: pointer ## pointer signal value; 
-                        ## integer signal value not defined!
-  TSigaction* {.importc: "struct sigaction", 
-                header: "<signal.h>", final, pure.} = object ## struct sigaction
-    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
-                                            ## function or one of the macros 
-                                            ## SIG_IGN or SIG_DFL. 
-    sa_mask*: TsigSet ## Set of signals to be blocked during execution of 
-                      ## the signal handling function. 
-    sa_flags*: cint   ## Special flags. 
-    sa_sigaction*: proc (x: cint, y: var TSigInfo, z: pointer) {.noconv.}
-
-  TStack* {.importc: "stack_t",
-            header: "<signal.h>", final, pure.} = object ## stack_t
-    ss_sp*: pointer  ## Stack base or pointer. 
-    ss_size*: int    ## Stack size. 
-    ss_flags*: cint  ## Flags. 
-
-  TSigStack* {.importc: "struct sigstack", 
-               header: "<signal.h>", final, pure.} = object ## struct sigstack
-    ss_onstack*: cint ## Non-zero when signal stack is in use. 
-    ss_sp*: pointer   ## Signal stack pointer. 
-
-  TsigInfo* {.importc: "siginfo_t", 
-              header: "<signal.h>", final, pure.} = object ## siginfo_t
-    si_signo*: cint    ## Signal number. 
-    si_code*: cint     ## Signal code. 
-    si_errno*: cint    ## If non-zero, an errno value associated with 
-                       ## this signal, as defined in <errno.h>. 
-    si_pid*: tpid      ## Sending process ID. 
-    si_uid*: tuid      ## Real user ID of sending process. 
-    si_addr*: pointer  ## Address of faulting instruction. 
-    si_status*: cint   ## Exit value or signal. 
-    si_band*: int      ## Band event for SIGPOLL. 
-    si_value*: TSigval ## Signal value. 
-  
-  Tnl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
-  Tnl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
-
-  Tsched_param* {.importc: "struct sched_param", 
-                  header: "<sched.h>", 
-                  final, pure.} = object ## struct sched_param
-    sched_priority*: cint
-    sched_ss_low_priority*: cint     ## Low scheduling priority for 
-                                     ## sporadic server. 
-    sched_ss_repl_period*: ttimespec ## Replenishment period for 
-                                     ## sporadic server. 
-    sched_ss_init_budget*: ttimespec ## Initial budget for sporadic server. 
-    sched_ss_max_repl*: cint         ## Maximum pending replenishments for 
-                                     ## sporadic server. 
-
-  Ttimeval* {.importc: "struct timeval", header: "<sys/select.h>", 
-              final, pure.} = object ## struct timeval
-    tv_sec*: int       ## Seconds. 
-    tv_usec*: int ## Microseconds. 
-  Tfd_set* {.importc: "fd_set", header: "<sys/select.h>", 
-             final, pure.} = object
-  Tmcontext* {.importc: "mcontext_t", header: "<ucontext.h>", 
-               final, pure.} = object
-  Tucontext* {.importc: "ucontext_t", header: "<ucontext.h>", 
-               final, pure.} = object ## ucontext_t
-    uc_link*: ptr Tucontext ## Pointer to the context that is resumed 
-                            ## when this context returns. 
-    uc_sigmask*: Tsigset    ## The set of signals that are blocked when this 
-                            ## context is active. 
-    uc_stack*: TStack       ## The stack used by this context. 
-    uc_mcontext*: Tmcontext ## A machine-specific representation of the saved 
-                            ## context. 
-
-when hasAioH:
-  type
-    Taiocb* {.importc: "struct aiocb", header: "<aio.h>", 
-              final, pure.} = object ## struct aiocb
-      aio_fildes*: cint         ## File descriptor. 
-      aio_offset*: TOff         ## File offset. 
-      aio_buf*: pointer         ## Location of buffer. 
-      aio_nbytes*: int          ## Length of transfer. 
-      aio_reqprio*: cint        ## Request priority offset. 
-      aio_sigevent*: TSigEvent  ## Signal number and value. 
-      aio_lio_opcode: cint      ## Operation to be performed. 
- 
-when hasSpawnH:
-  type
-    Tposix_spawnattr* {.importc: "posix_spawnattr_t", 
-                        header: "<spawn.h>".} = cint
-    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t", 
-                                 header: "<spawn.h>".} = cint 
-
-type
-  TSocklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cint
-  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cint
-  
-  TSockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>", 
-               pure, final.} = object ## struct sockaddr
-    sa_family*: Tsa_family         ## Address family. 
-    sa_data*: array [0..255, char] ## Socket address (variable-length data). 
-  
-  Tsockaddr_storage* {.importc: "struct sockaddr_storage",
-                       header: "<sys/socket.h>", 
-                       pure, final.} = object ## struct sockaddr_storage
-    ss_family*: Tsa_family ## Address family. 
-
-  Tif_nameindex* {.importc: "struct if_nameindex", final, 
-                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
-    if_index*: cint   ## Numeric index of the interface. 
-    if_name*: cstring ## Null-terminated name of the interface. 
-
-
-  TIOVec* {.importc: "struct iovec", pure, final,
-            header: "<sys/uio.h>".} = object ## struct iovec
-    iov_base*: pointer ## Base address of a memory region for input or output. 
-    iov_len*: int    ## The size of the memory pointed to by iov_base. 
-    
-  Tmsghdr* {.importc: "struct msghdr", pure, final,
-             header: "<sys/socket.h>".} = object  ## struct msghdr
-    msg_name*: pointer  ## Optional address. 
-    msg_namelen*: TSockLen  ## Size of address. 
-    msg_iov*: ptr TIOVec    ## Scatter/gather array. 
-    msg_iovlen*: cint   ## Members in msg_iov. 
-    msg_control*: pointer  ## Ancillary data; see below. 
-    msg_controllen*: TSockLen ## Ancillary data buffer len. 
-    msg_flags*: cint ## Flags on received message. 
-
-
-  Tcmsghdr* {.importc: "struct cmsghdr", pure, final, 
-              header: "<sys/socket.h>".} = object ## struct cmsghdr
-    cmsg_len*: TSockLen ## Data byte count, including the cmsghdr. 
-    cmsg_level*: cint   ## Originating protocol. 
-    cmsg_type*: cint    ## Protocol-specific type. 
-
-  TLinger* {.importc: "struct linger", pure, final, 
-             header: "<sys/socket.h>".} = object ## struct linger
-    l_onoff*: cint  ## Indicates whether linger option is enabled. 
-    l_linger*: cint ## Linger time, in seconds. 
-  
-  TInPort* = int16 ## unsigned!
-  TInAddrScalar* = int32 ## unsigned!
-  
-  TInAddr* {.importc: "struct in_addr", pure, final, 
-             header: "<netinet/in.h>".} = object ## struct in_addr
-    s_addr*: TInAddrScalar
-
-  Tsockaddr_in* {.importc: "struct sockaddr_in", pure, final, 
-                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
-    sin_family*: TSa_family ## AF_INET. 
-    sin_port*: TInPort      ## Port number. 
-    sin_addr*: TInAddr      ## IP address. 
-
-  TIn6Addr* {.importc: "struct in6_addr", pure, final,
-              header: "<netinet/in.h>".} = object ## struct in6_addr
-    s6_addr*: array [0..15, char]
-
-  Tsockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
-                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
-    sin6_family*: TSa_family ## AF_INET6. 
-    sin6_port*: TInPort      ## Port number. 
-    sin6_flowinfo*: int32    ## IPv6 traffic class and flow information. 
-    sin6_addr*: Tin6Addr     ## IPv6 address. 
-    sin6_scope_id*: int32    ## Set of interfaces for a scope. 
-  
-  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final, 
-                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
-    ipv6mr_multiaddr*: TIn6Addr ## IPv6 multicast address. 
-    ipv6mr_interface*: cint     ## Interface index. 
-
-  Thostent* {.importc: "struct hostent", pure, final, 
-              header: "<netdb.h>".} = object ## struct hostent
-    h_name*: cstring           ## Official name of the host. 
-    h_aliases*: cstringArray   ## A pointer to an array of pointers to 
-                               ## alternative host names, terminated by a 
-                               ## null pointer. 
-    h_addrtype*: cint          ## Address type. 
-    h_length*: cint            ## The length, in bytes, of the address. 
-    h_addr_list*: cstringArray ## A pointer to an array of pointers to network 
-                               ## addresses (in network byte order) for the
-                               ## host, terminated by a null pointer. 
-
-  Tnetent* {.importc: "struct netent", pure, final, 
-              header: "<netdb.h>".} = object ## struct netent
-    n_name*: cstring         ## Official, fully-qualified (including the 
-                             ## domain) name of the host. 
-    n_aliases*: cstringArray ## A pointer to an array of pointers to 
-                             ## alternative network names, terminated by a 
-                             ## null pointer. 
-    n_addrtype*: cint        ## The address type of the network. 
-    n_net*: int32            ## The network number, in host byte order. 
-
-  TProtoent* {.importc: "struct protoent", pure, final, 
-              header: "<netdb.h>".} = object ## struct protoent
-    p_name*: cstring         ## Official name of the protocol. 
-    p_aliases*: cstringArray ## A pointer to an array of pointers to 
-                             ## alternative protocol names, terminated by 
-                             ## a null pointer. 
-    p_proto*: cint           ## The protocol number. 
-
-  TServent* {.importc: "struct servent", pure, final, 
-              header: "<netdb.h>".} = object ## struct servent
-    s_name*: cstring         ## Official name of the service. 
-    s_aliases*: cstringArray ## A pointer to an array of pointers to 
-                             ## alternative service names, terminated by 
-                             ## a null pointer. 
-    s_port*: cint            ## The port number at which the service 
-                             ## resides, in network byte order. 
-    s_proto*: cstring        ## The name of the protocol to use when 
-                             ## contacting the service. 
-
-  Taddrinfo* {.importc: "struct addrinfo", pure, final, 
-              header: "<netdb.h>".} = object ## struct addrinfo
-    ai_flags*: cint         ## Input flags. 
-    ai_family*: cint        ## Address family of socket. 
-    ai_socktype*: cint      ## Socket type. 
-    ai_protocol*: cint      ## Protocol of socket. 
-    ai_addrlen*: TSockLen   ## Length of socket address. 
-    ai_addr*: ptr TSockAddr ## Socket address of socket. 
-    ai_canonname*: cstring  ## Canonical name of service location. 
-    ai_next*: ptr TAddrInfo ## Pointer to next in list. 
-  
-  TPollfd* {.importc: "struct pollfd", pure, final, 
-             header: "<poll.h>".} = object ## struct pollfd
-    fd*: cint        ## The following descriptor being polled. 
-    events*: cshort  ## The input event flags (see below). 
-    revents*: cshort ## The output event flags (see below).  
-  
-  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = cint
-
-var
-  errno* {.importc, header: "<errno.h>".}: cint ## error variable
-  daylight* {.importc, header: "<time.h>".}: cint
-  timezone* {.importc, header: "<time.h>".}: int
-  
-# Constants as variables:
-when hasAioH:
-  var
-    AIO_ALLDONE* {.importc, header: "<aio.h>".}: cint
-      ## A return value indicating that none of the requested operations 
-      ## could be canceled since they are already complete.
-    AIO_CANCELED* {.importc, header: "<aio.h>".}: cint
-      ## A return value indicating that all requested operations have
-      ## been canceled.
-    AIO_NOTCANCELED* {.importc, header: "<aio.h>".}: cint
-      ## A return value indicating that some of the requested operations could 
-      ## not be canceled since they are in progress.
-    LIO_NOP* {.importc, header: "<aio.h>".}: cint
-      ## A lio_listio() element operation option indicating that no transfer is
-      ## requested.
-    LIO_NOWAIT* {.importc, header: "<aio.h>".}: cint
-      ## A lio_listio() synchronization operation indicating that the calling 
-      ## thread is to continue execution while the lio_listio() operation is 
-      ## being performed, and no notification is given when the operation is
-      ## complete.
-    LIO_READ* {.importc, header: "<aio.h>".}: cint
-      ## A lio_listio() element operation option requesting a read.
-    LIO_WAIT* {.importc, header: "<aio.h>".}: cint
-      ## A lio_listio() synchronization operation indicating that the calling 
-      ## thread is to suspend until the lio_listio() operation is complete.
-    LIO_WRITE* {.importc, header: "<aio.h>".}: cint
-      ## A lio_listio() element operation option requesting a write.
-
-var
-  RTLD_LAZY* {.importc, header: "<dlfcn.h>".}: cint
-    ## Relocations are performed at an implementation-defined time.
-  RTLD_NOW* {.importc, header: "<dlfcn.h>".}: cint
-    ## Relocations are performed when the object is loaded.
-  RTLD_GLOBAL* {.importc, header: "<dlfcn.h>".}: cint
-    ## All symbols are available for relocation processing of other modules.
-  RTLD_LOCAL* {.importc, header: "<dlfcn.h>".}: cint
-    ## All symbols are not made available for relocation processing by 
-    ## other modules. 
-    
-  E2BIG* {.importc, header: "<errno.h>".}: cint
-      ## Argument list too long.
-  EACCES* {.importc, header: "<errno.h>".}: cint
-      ## Permission denied.
-  EADDRINUSE* {.importc, header: "<errno.h>".}: cint
-      ## Address in use.
-  EADDRNOTAVAIL* {.importc, header: "<errno.h>".}: cint
-      ## Address not available.
-  EAFNOSUPPORT* {.importc, header: "<errno.h>".}: cint
-      ## Address family not supported.
-  EAGAIN* {.importc, header: "<errno.h>".}: cint
-      ## Resource unavailable, try again (may be the same value as EWOULDBLOCK).
-  EALREADY* {.importc, header: "<errno.h>".}: cint
-      ## Connection already in progress.
-  EBADF* {.importc, header: "<errno.h>".}: cint
-      ## Bad file descriptor.
-  EBADMSG* {.importc, header: "<errno.h>".}: cint
-      ## Bad message.
-  EBUSY* {.importc, header: "<errno.h>".}: cint
-      ## Device or resource busy.
-  ECANCELED* {.importc, header: "<errno.h>".}: cint
-      ## Operation canceled.
-  ECHILD* {.importc, header: "<errno.h>".}: cint
-      ## No child processes.
-  ECONNABORTED* {.importc, header: "<errno.h>".}: cint
-      ## Connection aborted.
-  ECONNREFUSED* {.importc, header: "<errno.h>".}: cint
-      ## Connection refused.
-  ECONNRESET* {.importc, header: "<errno.h>".}: cint
-      ## Connection reset.
-  EDEADLK* {.importc, header: "<errno.h>".}: cint
-      ## Resource deadlock would occur.
-  EDESTADDRREQ* {.importc, header: "<errno.h>".}: cint
-      ## Destination address required.
-  EDOM* {.importc, header: "<errno.h>".}: cint
-      ## Mathematics argument out of domain of function.
-  EDQUOT* {.importc, header: "<errno.h>".}: cint
-      ## Reserved.
-  EEXIST* {.importc, header: "<errno.h>".}: cint
-      ## File exists.
-  EFAULT* {.importc, header: "<errno.h>".}: cint
-      ## Bad address.
-  EFBIG* {.importc, header: "<errno.h>".}: cint
-      ## File too large.
-  EHOSTUNREACH* {.importc, header: "<errno.h>".}: cint
-      ## Host is unreachable.
-  EIDRM* {.importc, header: "<errno.h>".}: cint
-      ## Identifier removed.
-  EILSEQ* {.importc, header: "<errno.h>".}: cint
-      ## Illegal byte sequence.
-  EINPROGRESS* {.importc, header: "<errno.h>".}: cint
-      ## Operation in progress.
-  EINTR* {.importc, header: "<errno.h>".}: cint
-      ## Interrupted function.
-  EINVAL* {.importc, header: "<errno.h>".}: cint
-      ## Invalid argument.
-  EIO* {.importc, header: "<errno.h>".}: cint
-      ## I/O error.
-  EISCONN* {.importc, header: "<errno.h>".}: cint
-      ## Socket is connected.
-  EISDIR* {.importc, header: "<errno.h>".}: cint
-      ## Is a directory.
-  ELOOP* {.importc, header: "<errno.h>".}: cint
-      ## Too many levels of symbolic links.
-  EMFILE* {.importc, header: "<errno.h>".}: cint
-      ## Too many open files.
-  EMLINK* {.importc, header: "<errno.h>".}: cint
-      ## Too many links.
-  EMSGSIZE* {.importc, header: "<errno.h>".}: cint
-      ## Message too large.
-  EMULTIHOP* {.importc, header: "<errno.h>".}: cint
-      ## Reserved.
-  ENAMETOOLONG* {.importc, header: "<errno.h>".}: cint
-      ## Filename too long.
-  ENETDOWN* {.importc, header: "<errno.h>".}: cint
-      ## Network is down.
-  ENETRESET* {.importc, header: "<errno.h>".}: cint
-      ## Connection aborted by network.
-  ENETUNREACH* {.importc, header: "<errno.h>".}: cint
-      ## Network unreachable.
-  ENFILE* {.importc, header: "<errno.h>".}: cint
-      ## Too many files open in system.
-  ENOBUFS* {.importc, header: "<errno.h>".}: cint
-      ## No buffer space available.
-  ENODATA* {.importc, header: "<errno.h>".}: cint
-      ## No message is available on the STREAM head read queue.
-  ENODEV* {.importc, header: "<errno.h>".}: cint
-      ## No such device.
-  ENOENT* {.importc, header: "<errno.h>".}: cint
-      ## No such file or directory.
-  ENOEXEC* {.importc, header: "<errno.h>".}: cint
-      ## Executable file format error.
-  ENOLCK* {.importc, header: "<errno.h>".}: cint
-      ## No locks available.
-  ENOLINK* {.importc, header: "<errno.h>".}: cint
-      ## Reserved.
-  ENOMEM* {.importc, header: "<errno.h>".}: cint
-      ## Not enough space.
-  ENOMSG* {.importc, header: "<errno.h>".}: cint
-      ## No message of the desired type.
-  ENOPROTOOPT* {.importc, header: "<errno.h>".}: cint
-      ## Protocol not available.
-  ENOSPC* {.importc, header: "<errno.h>".}: cint
-      ## No space left on device.
-  ENOSR* {.importc, header: "<errno.h>".}: cint
-      ## No STREAM resources.
-  ENOSTR* {.importc, header: "<errno.h>".}: cint
-      ## Not a STREAM.
-  ENOSYS* {.importc, header: "<errno.h>".}: cint
-      ## Function not supported.
-  ENOTCONN* {.importc, header: "<errno.h>".}: cint
-      ## The socket is not connected.
-  ENOTDIR* {.importc, header: "<errno.h>".}: cint
-      ## Not a directory.
-  ENOTEMPTY* {.importc, header: "<errno.h>".}: cint
-      ## Directory not empty.
-  ENOTSOCK* {.importc, header: "<errno.h>".}: cint
-      ## Not a socket.
-  ENOTSUP* {.importc, header: "<errno.h>".}: cint
-      ## Not supported.
-  ENOTTY* {.importc, header: "<errno.h>".}: cint
-      ## Inappropriate I/O control operation.
-  ENXIO* {.importc, header: "<errno.h>".}: cint
-      ## No such device or address.
-  EOPNOTSUPP* {.importc, header: "<errno.h>".}: cint
-      ## Operation not supported on socket.
-  EOVERFLOW* {.importc, header: "<errno.h>".}: cint
-      ## Value too large to be stored in data type.
-  EPERM* {.importc, header: "<errno.h>".}: cint
-      ## Operation not permitted.
-  EPIPE* {.importc, header: "<errno.h>".}: cint
-      ## Broken pipe.
-  EPROTO* {.importc, header: "<errno.h>".}: cint
-      ## Protocol error.
-  EPROTONOSUPPORT* {.importc, header: "<errno.h>".}: cint
-      ## Protocol not supported.
-  EPROTOTYPE* {.importc, header: "<errno.h>".}: cint
-      ## Protocol wrong type for socket.
-  ERANGE* {.importc, header: "<errno.h>".}: cint
-      ## Result too large.
-  EROFS* {.importc, header: "<errno.h>".}: cint
-      ## Read-only file system.
-  ESPIPE* {.importc, header: "<errno.h>".}: cint
-      ## Invalid seek.
-  ESRCH* {.importc, header: "<errno.h>".}: cint
-      ## No such process.
-  ESTALE* {.importc, header: "<errno.h>".}: cint
-      ## Reserved.
-  ETIME* {.importc, header: "<errno.h>".}: cint
-      ## Stream ioctl() timeout.
-  ETIMEDOUT* {.importc, header: "<errno.h>".}: cint
-      ## Connection timed out.
-  ETXTBSY* {.importc, header: "<errno.h>".}: cint
-      ## Text file busy.
-  EWOULDBLOCK* {.importc, header: "<errno.h>".}: cint
-      ## Operation would block (may be the same value as [EAGAIN]).
-  EXDEV* {.importc, header: "<errno.h>".}: cint
-      ## Cross-device link.   
-
-  F_DUPFD* {.importc, header: "<fcntl.h>".}: cint
-    ## Duplicate file descriptor.
-  F_GETFD* {.importc, header: "<fcntl.h>".}: cint
-    ## Get file descriptor flags.
-  F_SETFD* {.importc, header: "<fcntl.h>".}: cint
-    ## Set file descriptor flags.
-  F_GETFL* {.importc, header: "<fcntl.h>".}: cint
-    ## Get file status flags and file access modes.
-  F_SETFL* {.importc, header: "<fcntl.h>".}: cint
-    ## Set file status flags.
-  F_GETLK* {.importc, header: "<fcntl.h>".}: cint
-    ## Get record locking information.
-  F_SETLK* {.importc, header: "<fcntl.h>".}: cint
-    ## Set record locking information.
-  F_SETLKW* {.importc, header: "<fcntl.h>".}: cint
-    ## Set record locking information; wait if blocked.
-  F_GETOWN* {.importc, header: "<fcntl.h>".}: cint
-    ## Get process or process group ID to receive SIGURG signals.
-  F_SETOWN* {.importc, header: "<fcntl.h>".}: cint
-    ## Set process or process group ID to receive SIGURG signals. 
-  FD_CLOEXEC* {.importc, header: "<fcntl.h>".}: cint
-    ## Close the file descriptor upon execution of an exec family function. 
-  F_RDLCK* {.importc, header: "<fcntl.h>".}: cint
-    ## Shared or read lock.
-  F_UNLCK* {.importc, header: "<fcntl.h>".}: cint
-    ## Unlock.
-  F_WRLCK* {.importc, header: "<fcntl.h>".}: cint
-    ## Exclusive or write lock. 
-  O_CREAT* {.importc, header: "<fcntl.h>".}: cint
-    ## Create file if it does not exist.
-  O_EXCL* {.importc, header: "<fcntl.h>".}: cint
-    ## Exclusive use flag.
-  O_NOCTTY* {.importc, header: "<fcntl.h>".}: cint
-    ## Do not assign controlling terminal.
-  O_TRUNC* {.importc, header: "<fcntl.h>".}: cint
-    ## Truncate flag. 
-  O_APPEND* {.importc, header: "<fcntl.h>".}: cint
-    ## Set append mode.
-  O_DSYNC* {.importc, header: "<fcntl.h>".}: cint
-    ## Write according to synchronized I/O data integrity completion.
-  O_NONBLOCK* {.importc, header: "<fcntl.h>".}: cint
-    ## Non-blocking mode.
-  O_RSYNC* {.importc, header: "<fcntl.h>".}: cint
-    ## Synchronized read I/O operations.
-  O_SYNC* {.importc, header: "<fcntl.h>".}: cint
-    ## Write according to synchronized I/O file integrity completion. 
-  O_ACCMODE* {.importc, header: "<fcntl.h>".}: cint
-    ## Mask for file access modes.      
-  O_RDONLY* {.importc, header: "<fcntl.h>".}: cint
-    ## Open for reading only.
-  O_RDWR* {.importc, header: "<fcntl.h>".}: cint
-    ## Open for reading and writing.
-  O_WRONLY* {.importc, header: "<fcntl.h>".}: cint
-    ## Open for writing only. 
-  POSIX_FADV_NORMAL* {.importc, header: "<fcntl.h>".}: cint
-    ## The application has no advice to give on its behavior with
-    ## respect to the specified data. It is the default characteristic
-    ## if no advice is given for an open file.
-  POSIX_FADV_SEQUENTIAL* {.importc, header: "<fcntl.h>".}: cint
-    ## The application expects to access the specified data 
-    # sequentially from lower offsets to higher offsets.
-  POSIX_FADV_RANDOM* {.importc, header: "<fcntl.h>".}: cint
-    ## The application expects to access the specified data in a random order.
-  POSIX_FADV_WILLNEED* {.importc, header: "<fcntl.h>".}: cint
-    ## The application expects to access the specified data in the near future.
-  POSIX_FADV_DONTNEED* {.importc, header: "<fcntl.h>".}: cint
-    ## The application expects that it will not access the specified data
-    ## in the near future.
-  POSIX_FADV_NOREUSE* {.importc, header: "<fcntl.h>".}: cint
-    ## The application expects to access the specified data once and 
-    ## then not reuse it thereafter. 
-
-  FE_DIVBYZERO* {.importc, header: "<fenv.h>".}: cint
-  FE_INEXACT* {.importc, header: "<fenv.h>".}: cint
-  FE_INVALID* {.importc, header: "<fenv.h>".}: cint
-  FE_OVERFLOW* {.importc, header: "<fenv.h>".}: cint
-  FE_UNDERFLOW* {.importc, header: "<fenv.h>".}: cint
-  FE_ALL_EXCEPT* {.importc, header: "<fenv.h>".}: cint
-  FE_DOWNWARD* {.importc, header: "<fenv.h>".}: cint
-  FE_TONEAREST* {.importc, header: "<fenv.h>".}: cint
-  FE_TOWARDZERO* {.importc, header: "<fenv.h>".}: cint
-  FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
-  FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
-
-  MM_HARD* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Source of the condition is hardware.
-  MM_SOFT* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Source of the condition is software.
-  MM_FIRM* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Source of the condition is firmware.
-  MM_APPL* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Condition detected by application.
-  MM_UTIL* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Condition detected by utility.
-  MM_OPSYS* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Condition detected by operating system.
-  MM_RECOVER* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Recoverable error.
-  MM_NRECOV* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Non-recoverable error.
-  MM_HALT* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Error causing application to halt.
-  MM_ERROR* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Application has encountered a non-fatal fault.
-  MM_WARNING* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Application has detected unusual non-error condition.
-  MM_INFO* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Informative message.
-  MM_NOSEV* {.importc, header: "<fmtmsg.h>".}: cint
-    ## No severity level provided for the message.
-  MM_PRINT* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Display message on standard error.
-  MM_CONSOLE* {.importc, header: "<fmtmsg.h>".}: cint
-    ## Display message on system console. 
-
-  MM_OK* {.importc, header: "<fmtmsg.h>".}: cint
-    ## The function succeeded.
-  MM_NOTOK* {.importc, header: "<fmtmsg.h>".}: cint
-    ## The function failed completely.
-  MM_NOMSG* {.importc, header: "<fmtmsg.h>".}: cint
-    ## The function was unable to generate a message on standard error, 
-    ## but otherwise succeeded.
-  MM_NOCON* {.importc, header: "<fmtmsg.h>".}: cint
-    ## The function was unable to generate a console message, but 
-    ## otherwise succeeded. 
-    
-  FNM_NOMATCH* {.importc, header: "<fnmatch.h>".}: cint
-    ## The string does not match the specified pattern.
-  FNM_PATHNAME* {.importc, header: "<fnmatch.h>".}: cint
-    ## Slash in string only matches slash in pattern.
-  FNM_PERIOD* {.importc, header: "<fnmatch.h>".}: cint
-    ## Leading period in string must be exactly matched by period in pattern.
-  FNM_NOESCAPE* {.importc, header: "<fnmatch.h>".}: cint
-    ## Disable backslash escaping.
-  FNM_NOSYS* {.importc, header: "<fnmatch.h>".}: cint
-    ## Reserved.
-
-  FTW_F* {.importc, header: "<ftw.h>".}: cint
-    ## File.
-  FTW_D* {.importc, header: "<ftw.h>".}: cint
-    ## Directory.
-  FTW_DNR* {.importc, header: "<ftw.h>".}: cint
-    ## Directory without read permission.
-  FTW_DP* {.importc, header: "<ftw.h>".}: cint
-    ## Directory with subdirectories visited.
-  FTW_NS* {.importc, header: "<ftw.h>".}: cint
-    ## Unknown type; stat() failed.
-  FTW_SL* {.importc, header: "<ftw.h>".}: cint
-    ## Symbolic link.
-  FTW_SLN* {.importc, header: "<ftw.h>".}: cint
-    ## Symbolic link that names a nonexistent file.
-
-  FTW_PHYS* {.importc, header: "<ftw.h>".}: cint
-    ## Physical walk, does not follow symbolic links. Otherwise, nftw() 
-    ## follows links but does not walk down any path that crosses itself.
-  FTW_MOUNT* {.importc, header: "<ftw.h>".}: cint
-    ## The walk does not cross a mount point.
-  FTW_DEPTH* {.importc, header: "<ftw.h>".}: cint
-    ## All subdirectories are visited before the directory itself.
-  FTW_CHDIR* {.importc, header: "<ftw.h>".}: cint
-    ## The walk changes to each directory before reading it. 
-
-  GLOB_APPEND* {.importc, header: "<glob.h>".}: cint
-    ## Append generated pathnames to those previously obtained.
-  GLOB_DOOFFS* {.importc, header: "<glob.h>".}: cint
-    ## Specify how many null pointers to add to the beginning of gl_pathv.
-  GLOB_ERR* {.importc, header: "<glob.h>".}: cint
-    ## Cause glob() to return on error.
-  GLOB_MARK* {.importc, header: "<glob.h>".}: cint
-    ## Each pathname that is a directory that matches pattern has a 
-    ## slash appended.
-  GLOB_NOCHECK* {.importc, header: "<glob.h>".}: cint
-    ## If pattern does not match any pathname, then return a list
-    ## consisting of only pattern.
-  GLOB_NOESCAPE* {.importc, header: "<glob.h>".}: cint
-    ## Disable backslash escaping.
-  GLOB_NOSORT* {.importc, header: "<glob.h>".}: cint
-    ## Do not sort the pathnames returned.
-  GLOB_ABORTED* {.importc, header: "<glob.h>".}: cint
-    ## The scan was stopped because GLOB_ERR was set or errfunc() 
-    ## returned non-zero.
-  GLOB_NOMATCH* {.importc, header: "<glob.h>".}: cint
-    ## The pattern does not match any existing pathname, and GLOB_NOCHECK 
-    ## was not set in flags.
-  GLOB_NOSPACE* {.importc, header: "<glob.h>".}: cint
-    ## An attempt to allocate memory failed.
-  GLOB_NOSYS* {.importc, header: "<glob.h>".}: cint
-    ## Reserved
-
-  CODESET* {.importc, header: "<langinfo.h>".}: cint
-    ## Codeset name.
-  D_T_FMT* {.importc, header: "<langinfo.h>".}: cint
-    ## String for formatting date and time.
-  D_FMT * {.importc, header: "<langinfo.h>".}: cint
-    ## Date format string.
-  T_FMT* {.importc, header: "<langinfo.h>".}: cint
-    ## Time format string.
-  T_FMT_AMPM* {.importc, header: "<langinfo.h>".}: cint
-    ## a.m. or p.m. time format string.
-  AM_STR* {.importc, header: "<langinfo.h>".}: cint
-    ## Ante-meridiem affix.
-  PM_STR* {.importc, header: "<langinfo.h>".}: cint
-    ## Post-meridiem affix.
-  DAY_1* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the first day of the week (for example, Sunday).
-  DAY_2* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the second day of the week (for example, Monday).
-  DAY_3* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the third day of the week (for example, Tuesday).
-  DAY_4* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the fourth day of the week (for example, Wednesday).
-  DAY_5* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the fifth day of the week (for example, Thursday).
-  DAY_6* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the sixth day of the week (for example, Friday).
-  DAY_7* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the seventh day of the week (for example, Saturday).
-  ABDAY_1* {.importc, header: "<langinfo.h>".}: cint
-    ## Abbreviated name of the first day of the week.
-  ABDAY_2* {.importc, header: "<langinfo.h>".}: cint
-  ABDAY_3* {.importc, header: "<langinfo.h>".}: cint
-  ABDAY_4* {.importc, header: "<langinfo.h>".}: cint
-  ABDAY_5* {.importc, header: "<langinfo.h>".}: cint
-  ABDAY_6* {.importc, header: "<langinfo.h>".}: cint
-  ABDAY_7* {.importc, header: "<langinfo.h>".}: cint
-  MON_1* {.importc, header: "<langinfo.h>".}: cint
-    ## Name of the first month of the year.
-  MON_2* {.importc, header: "<langinfo.h>".}: cint
-  MON_3* {.importc, header: "<langinfo.h>".}: cint
-  MON_4* {.importc, header: "<langinfo.h>".}: cint
-  MON_5* {.importc, header: "<langinfo.h>".}: cint
-  MON_6* {.importc, header: "<langinfo.h>".}: cint
-  MON_7* {.importc, header: "<langinfo.h>".}: cint
-  MON_8* {.importc, header: "<langinfo.h>".}: cint
-  MON_9* {.importc, header: "<langinfo.h>".}: cint
-  MON_10* {.importc, header: "<langinfo.h>".}: cint
-  MON_11* {.importc, header: "<langinfo.h>".}: cint
-  MON_12* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_1* {.importc, header: "<langinfo.h>".}: cint
-    ## Abbreviated name of the first month.
-  ABMON_2* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_3* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_4* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_5* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_6* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_7* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_8* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_9* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_10* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_11* {.importc, header: "<langinfo.h>".}: cint
-  ABMON_12* {.importc, header: "<langinfo.h>".}: cint
-  ERA* {.importc, header: "<langinfo.h>".}: cint
-    ## Era description segments.
-  ERA_D_FMT* {.importc, header: "<langinfo.h>".}: cint
-    ## Era date format string.
-  ERA_D_T_FMT* {.importc, header: "<langinfo.h>".}: cint
-    ## Era date and time format string.
-  ERA_T_FMT* {.importc, header: "<langinfo.h>".}: cint
-    ## Era time format string.
-  ALT_DIGITS* {.importc, header: "<langinfo.h>".}: cint
-    ## Alternative symbols for digits.
-  RADIXCHAR* {.importc, header: "<langinfo.h>".}: cint
-    ## Radix character.
-  THOUSEP* {.importc, header: "<langinfo.h>".}: cint
-    ## Separator for thousands.
-  YESEXPR* {.importc, header: "<langinfo.h>".}: cint
-    ## Affirmative response expression.
-  NOEXPR* {.importc, header: "<langinfo.h>".}: cint
-    ## Negative response expression.
-  CRNCYSTR* {.importc, header: "<langinfo.h>".}: cint
-    ## Local currency symbol, preceded by '-' if the symbol 
-    ## should appear before the value, '+' if the symbol should appear 
-    ## after the value, or '.' if the symbol should replace the radix
-    ## character. If the local currency symbol is the empty string, 
-    ## implementations may return the empty string ( "" ).
-
-  LC_ALL* {.importc, header: "<locale.h>".}: cint
-  LC_COLLATE* {.importc, header: "<locale.h>".}: cint
-  LC_CTYPE* {.importc, header: "<locale.h>".}: cint
-  LC_MESSAGES* {.importc, header: "<locale.h>".}: cint
-  LC_MONETARY* {.importc, header: "<locale.h>".}: cint
-  LC_NUMERIC* {.importc, header: "<locale.h>".}: cint
-  LC_TIME* {.importc, header: "<locale.h>".}: cint
-  
-  PTHREAD_BARRIER_SERIAL_THREAD* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CANCEL_ASYNCHRONOUS* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CANCEL_ENABLE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CANCEL_DEFERRED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CANCEL_DISABLE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CANCELED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_COND_INITIALIZER* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CREATE_DETACHED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_CREATE_JOINABLE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_EXPLICIT_SCHED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_INHERIT_SCHED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_MUTEX_DEFAULT* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_MUTEX_ERRORCHECK* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_MUTEX_INITIALIZER* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_MUTEX_NORMAL* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_MUTEX_RECURSIVE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_ONCE_INIT* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_PRIO_INHERIT* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_PRIO_NONE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_PRIO_PROTECT* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_PROCESS_SHARED* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_PROCESS_PRIVATE* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_SCOPE_PROCESS* {.importc, header: "<pthread.h>".}: cint
-  PTHREAD_SCOPE_SYSTEM* {.importc, header: "<pthread.h>".}: cint
-
-  POSIX_ASYNC_IO* {.importc: "_POSIX_ASYNC_IO", header: "<unistd.h>".}: cint
-  POSIX_PRIO_IO* {.importc: "_POSIX_PRIO_IO", header: "<unistd.h>".}: cint
-  POSIX_SYNC_IO* {.importc: "_POSIX_SYNC_IO", header: "<unistd.h>".}: cint
-  F_OK* {.importc: "F_OK", header: "<unistd.h>".}: cint
-  R_OK* {.importc: "R_OK", header: "<unistd.h>".}: cint
-  W_OK* {.importc: "W_OK", header: "<unistd.h>".}: cint
-  X_OK* {.importc: "X_OK", header: "<unistd.h>".}: cint
-
-  CS_PATH* {.importc: "_CS_PATH", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFF32_CFLAGS* {.importc: "_CS_POSIX_V6_ILP32_OFF32_CFLAGS",
-    header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFF32_LDFLAGS* {.
-    importc: "_CS_POSIX_V6_ILP32_OFF32_LDFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFF32_LIBS* {.importc: "_CS_POSIX_V6_ILP32_OFF32_LIBS",
-    header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* {.
-    importc: "_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* {.
-    importc: "_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_ILP32_OFFBIG_LIBS* {.
-    importc: "_CS_POSIX_V6_ILP32_OFFBIG_LIBS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LP64_OFF64_CFLAGS* {.
-    importc: "_CS_POSIX_V6_LP64_OFF64_CFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LP64_OFF64_LDFLAGS* {.
-    importc: "_CS_POSIX_V6_LP64_OFF64_LDFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LP64_OFF64_LIBS* {.
-    importc: "_CS_POSIX_V6_LP64_OFF64_LIBS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* {.
-    importc: "_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* {.
-    importc: "_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_LPBIG_OFFBIG_LIBS* {.
-    importc: "_CS_POSIX_V6_LPBIG_OFFBIG_LIBS", header: "<unistd.h>".}: cint
-  CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* {.
-    importc: "_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS", header: "<unistd.h>".}: cint
-  F_LOCK* {.importc: "F_LOCK", header: "<unistd.h>".}: cint
-  F_TEST* {.importc: "F_TEST", header: "<unistd.h>".}: cint
-  F_TLOCK* {.importc: "F_TLOCK", header: "<unistd.h>".}: cint
-  F_ULOCK* {.importc: "F_ULOCK", header: "<unistd.h>".}: cint
-  PC_2_SYMLINKS* {.importc: "_PC_2_SYMLINKS", header: "<unistd.h>".}: cint
-  PC_ALLOC_SIZE_MIN* {.importc: "_PC_ALLOC_SIZE_MIN",
-    header: "<unistd.h>".}: cint
-  PC_ASYNC_IO* {.importc: "_PC_ASYNC_IO", header: "<unistd.h>".}: cint
-  PC_CHOWN_RESTRICTED* {.importc: "_PC_CHOWN_RESTRICTED", 
-    header: "<unistd.h>".}: cint
-  PC_FILESIZEBITS* {.importc: "_PC_FILESIZEBITS", header: "<unistd.h>".}: cint
-  PC_LINK_MAX* {.importc: "_PC_LINK_MAX", header: "<unistd.h>".}: cint
-  PC_MAX_CANON* {.importc: "_PC_MAX_CANON", header: "<unistd.h>".}: cint
-
-  PC_MAX_INPUT*{.importc: "_PC_MAX_INPUT", header: "<unistd.h>".}: cint
-  PC_NAME_MAX*{.importc: "_PC_NAME_MAX", header: "<unistd.h>".}: cint
-  PC_NO_TRUNC*{.importc: "_PC_NO_TRUNC", header: "<unistd.h>".}: cint
-  PC_PATH_MAX*{.importc: "_PC_PATH_MAX", header: "<unistd.h>".}: cint
-  PC_PIPE_BUF*{.importc: "_PC_PIPE_BUF", header: "<unistd.h>".}: cint
-  PC_PRIO_IO*{.importc: "_PC_PRIO_IO", header: "<unistd.h>".}: cint
-  PC_REC_INCR_XFER_SIZE*{.importc: "_PC_REC_INCR_XFER_SIZE", 
-    header: "<unistd.h>".}: cint
-  PC_REC_MIN_XFER_SIZE*{.importc: "_PC_REC_MIN_XFER_SIZE", 
-    header: "<unistd.h>".}: cint
-  PC_REC_XFER_ALIGN*{.importc: "_PC_REC_XFER_ALIGN", header: "<unistd.h>".}: cint
-  PC_SYMLINK_MAX*{.importc: "_PC_SYMLINK_MAX", header: "<unistd.h>".}: cint
-  PC_SYNC_IO*{.importc: "_PC_SYNC_IO", header: "<unistd.h>".}: cint
-  PC_VDISABLE*{.importc: "_PC_VDISABLE", header: "<unistd.h>".}: cint
-  SC_2_C_BIND*{.importc: "_SC_2_C_BIND", header: "<unistd.h>".}: cint
-  SC_2_C_DEV*{.importc: "_SC_2_C_DEV", header: "<unistd.h>".}: cint
-  SC_2_CHAR_TERM*{.importc: "_SC_2_CHAR_TERM", header: "<unistd.h>".}: cint
-  SC_2_FORT_DEV*{.importc: "_SC_2_FORT_DEV", header: "<unistd.h>".}: cint
-  SC_2_FORT_RUN*{.importc: "_SC_2_FORT_RUN", header: "<unistd.h>".}: cint
-  SC_2_LOCALEDEF*{.importc: "_SC_2_LOCALEDEF", header: "<unistd.h>".}: cint
-  SC_2_PBS*{.importc: "_SC_2_PBS", header: "<unistd.h>".}: cint
-  SC_2_PBS_ACCOUNTING*{.importc: "_SC_2_PBS_ACCOUNTING", 
-    header: "<unistd.h>".}: cint
-  SC_2_PBS_CHECKPOINT*{.importc: "_SC_2_PBS_CHECKPOINT", 
-    header: "<unistd.h>".}: cint
-  SC_2_PBS_LOCATE*{.importc: "_SC_2_PBS_LOCATE", header: "<unistd.h>".}: cint
-  SC_2_PBS_MESSAGE*{.importc: "_SC_2_PBS_MESSAGE", header: "<unistd.h>".}: cint
-  SC_2_PBS_TRACK*{.importc: "_SC_2_PBS_TRACK", header: "<unistd.h>".}: cint
-  SC_2_SW_DEV*{.importc: "_SC_2_SW_DEV", header: "<unistd.h>".}: cint
-  SC_2_UPE*{.importc: "_SC_2_UPE", header: "<unistd.h>".}: cint
-  SC_2_VERSION*{.importc: "_SC_2_VERSION", header: "<unistd.h>".}: cint
-  SC_ADVISORY_INFO*{.importc: "_SC_ADVISORY_INFO", header: "<unistd.h>".}: cint
-  SC_AIO_LISTIO_MAX*{.importc: "_SC_AIO_LISTIO_MAX", header: "<unistd.h>".}: cint
-  SC_AIO_MAX*{.importc: "_SC_AIO_MAX", header: "<unistd.h>".}: cint
-  SC_AIO_PRIO_DELTA_MAX*{.importc: "_SC_AIO_PRIO_DELTA_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_ARG_MAX*{.importc: "_SC_ARG_MAX", header: "<unistd.h>".}: cint
-  SC_ASYNCHRONOUS_IO*{.importc: "_SC_ASYNCHRONOUS_IO", 
-    header: "<unistd.h>".}: cint
-  SC_ATEXIT_MAX*{.importc: "_SC_ATEXIT_MAX", header: "<unistd.h>".}: cint
-  SC_BARRIERS*{.importc: "_SC_BARRIERS", header: "<unistd.h>".}: cint
-  SC_BC_BASE_MAX*{.importc: "_SC_BC_BASE_MAX", header: "<unistd.h>".}: cint
-  SC_BC_DIM_MAX*{.importc: "_SC_BC_DIM_MAX", header: "<unistd.h>".}: cint
-  SC_BC_SCALE_MAX*{.importc: "_SC_BC_SCALE_MAX", header: "<unistd.h>".}: cint
-  SC_BC_STRING_MAX*{.importc: "_SC_BC_STRING_MAX", header: "<unistd.h>".}: cint
-  SC_CHILD_MAX*{.importc: "_SC_CHILD_MAX", header: "<unistd.h>".}: cint
-  SC_CLK_TCK*{.importc: "_SC_CLK_TCK", header: "<unistd.h>".}: cint
-  SC_CLOCK_SELECTION*{.importc: "_SC_CLOCK_SELECTION", 
-    header: "<unistd.h>".}: cint
-  SC_COLL_WEIGHTS_MAX*{.importc: "_SC_COLL_WEIGHTS_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_CPUTIME*{.importc: "_SC_CPUTIME", header: "<unistd.h>".}: cint
-  SC_DELAYTIMER_MAX*{.importc: "_SC_DELAYTIMER_MAX", header: "<unistd.h>".}: cint
-  SC_EXPR_NEST_MAX*{.importc: "_SC_EXPR_NEST_MAX", header: "<unistd.h>".}: cint
-  SC_FSYNC*{.importc: "_SC_FSYNC", header: "<unistd.h>".}: cint
-  SC_GETGR_R_SIZE_MAX*{.importc: "_SC_GETGR_R_SIZE_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_GETPW_R_SIZE_MAX*{.importc: "_SC_GETPW_R_SIZE_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_HOST_NAME_MAX*{.importc: "_SC_HOST_NAME_MAX", header: "<unistd.h>".}: cint
-  SC_IOV_MAX*{.importc: "_SC_IOV_MAX", header: "<unistd.h>".}: cint
-  SC_IPV6*{.importc: "_SC_IPV6", header: "<unistd.h>".}: cint
-  SC_JOB_CONTROL*{.importc: "_SC_JOB_CONTROL", header: "<unistd.h>".}: cint
-  SC_LINE_MAX*{.importc: "_SC_LINE_MAX", header: "<unistd.h>".}: cint
-  SC_LOGIN_NAME_MAX*{.importc: "_SC_LOGIN_NAME_MAX", header: "<unistd.h>".}: cint
-  SC_MAPPED_FILES*{.importc: "_SC_MAPPED_FILES", header: "<unistd.h>".}: cint
-  SC_MEMLOCK*{.importc: "_SC_MEMLOCK", header: "<unistd.h>".}: cint
-  SC_MEMLOCK_RANGE*{.importc: "_SC_MEMLOCK_RANGE", header: "<unistd.h>".}: cint
-  SC_MEMORY_PROTECTION*{.importc: "_SC_MEMORY_PROTECTION", 
-    header: "<unistd.h>".}: cint
-  SC_MESSAGE_PASSING*{.importc: "_SC_MESSAGE_PASSING", 
-    header: "<unistd.h>".}: cint
-  SC_MONOTONIC_CLOCK*{.importc: "_SC_MONOTONIC_CLOCK", 
-    header: "<unistd.h>".}: cint
-  SC_MQ_OPEN_MAX*{.importc: "_SC_MQ_OPEN_MAX", header: "<unistd.h>".}: cint
-  SC_MQ_PRIO_MAX*{.importc: "_SC_MQ_PRIO_MAX", header: "<unistd.h>".}: cint
-  SC_NGROUPS_MAX*{.importc: "_SC_NGROUPS_MAX", header: "<unistd.h>".}: cint
-  SC_OPEN_MAX*{.importc: "_SC_OPEN_MAX", header: "<unistd.h>".}: cint
-  SC_PAGE_SIZE*{.importc: "_SC_PAGE_SIZE", header: "<unistd.h>".}: cint
-  SC_PRIORITIZED_IO*{.importc: "_SC_PRIORITIZED_IO", header: "<unistd.h>".}: cint
-  SC_PRIORITY_SCHEDULING*{.importc: "_SC_PRIORITY_SCHEDULING", 
-    header: "<unistd.h>".}: cint
-  SC_RAW_SOCKETS*{.importc: "_SC_RAW_SOCKETS", header: "<unistd.h>".}: cint
-  SC_RE_DUP_MAX*{.importc: "_SC_RE_DUP_MAX", header: "<unistd.h>".}: cint
-  SC_READER_WRITER_LOCKS*{.importc: "_SC_READER_WRITER_LOCKS", 
-    header: "<unistd.h>".}: cint
-  SC_REALTIME_SIGNALS*{.importc: "_SC_REALTIME_SIGNALS", 
-    header: "<unistd.h>".}: cint
-  SC_REGEXP*{.importc: "_SC_REGEXP", header: "<unistd.h>".}: cint
-  SC_RTSIG_MAX*{.importc: "_SC_RTSIG_MAX", header: "<unistd.h>".}: cint
-  SC_SAVED_IDS*{.importc: "_SC_SAVED_IDS", header: "<unistd.h>".}: cint
-  SC_SEM_NSEMS_MAX*{.importc: "_SC_SEM_NSEMS_MAX", header: "<unistd.h>".}: cint
-  SC_SEM_VALUE_MAX*{.importc: "_SC_SEM_VALUE_MAX", header: "<unistd.h>".}: cint
-  SC_SEMAPHORES*{.importc: "_SC_SEMAPHORES", header: "<unistd.h>".}: cint
-  SC_SHARED_MEMORY_OBJECTS*{.importc: "_SC_SHARED_MEMORY_OBJECTS", 
-    header: "<unistd.h>".}: cint
-  SC_SHELL*{.importc: "_SC_SHELL", header: "<unistd.h>".}: cint
-  SC_SIGQUEUE_MAX*{.importc: "_SC_SIGQUEUE_MAX", header: "<unistd.h>".}: cint
-  SC_SPAWN*{.importc: "_SC_SPAWN", header: "<unistd.h>".}: cint
-  SC_SPIN_LOCKS*{.importc: "_SC_SPIN_LOCKS", header: "<unistd.h>".}: cint
-  SC_SPORADIC_SERVER*{.importc: "_SC_SPORADIC_SERVER", 
-    header: "<unistd.h>".}: cint
-  SC_SS_REPL_MAX*{.importc: "_SC_SS_REPL_MAX", header: "<unistd.h>".}: cint
-  SC_STREAM_MAX*{.importc: "_SC_STREAM_MAX", header: "<unistd.h>".}: cint
-  SC_SYMLOOP_MAX*{.importc: "_SC_SYMLOOP_MAX", header: "<unistd.h>".}: cint
-  SC_SYNCHRONIZED_IO*{.importc: "_SC_SYNCHRONIZED_IO", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_ATTR_STACKADDR*{.importc: "_SC_THREAD_ATTR_STACKADDR", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_ATTR_STACKSIZE*{.importc: "_SC_THREAD_ATTR_STACKSIZE", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_CPUTIME*{.importc: "_SC_THREAD_CPUTIME", header: "<unistd.h>".}: cint
-  SC_THREAD_DESTRUCTOR_ITERATIONS*{.importc: "_SC_THREAD_DESTRUCTOR_ITERATIONS",
-    header: "<unistd.h>".}: cint
-  SC_THREAD_KEYS_MAX*{.importc: "_SC_THREAD_KEYS_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_PRIO_INHERIT*{.importc: "_SC_THREAD_PRIO_INHERIT", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_PRIO_PROTECT*{.importc: "_SC_THREAD_PRIO_PROTECT", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_PRIORITY_SCHEDULING*{.importc: "_SC_THREAD_PRIORITY_SCHEDULING",
-    header: "<unistd.h>".}: cint
-  SC_THREAD_PROCESS_SHARED*{.importc: "_SC_THREAD_PROCESS_SHARED", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_SAFE_FUNCTIONS*{.importc: "_SC_THREAD_SAFE_FUNCTIONS", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_SPORADIC_SERVER*{.importc: "_SC_THREAD_SPORADIC_SERVER", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_STACK_MIN*{.importc: "_SC_THREAD_STACK_MIN", 
-    header: "<unistd.h>".}: cint
-  SC_THREAD_THREADS_MAX*{.importc: "_SC_THREAD_THREADS_MAX", 
-    header: "<unistd.h>".}: cint
-  SC_THREADS*{.importc: "_SC_THREADS", header: "<unistd.h>".}: cint
-  SC_TIMEOUTS*{.importc: "_SC_TIMEOUTS", header: "<unistd.h>".}: cint
-  SC_TIMER_MAX*{.importc: "_SC_TIMER_MAX", header: "<unistd.h>".}: cint
-  SC_TIMERS*{.importc: "_SC_TIMERS", header: "<unistd.h>".}: cint
-  SC_TRACE*{.importc: "_SC_TRACE", header: "<unistd.h>".}: cint
-  SC_TRACE_EVENT_FILTER*{.importc: "_SC_TRACE_EVENT_FILTER", header: "<unistd.h>".}: cint
-  SC_TRACE_EVENT_NAME_MAX*{.importc: "_SC_TRACE_EVENT_NAME_MAX", header: "<unistd.h>".}: cint
-  SC_TRACE_INHERIT*{.importc: "_SC_TRACE_INHERIT", header: "<unistd.h>".}: cint
-  SC_TRACE_LOG*{.importc: "_SC_TRACE_LOG", header: "<unistd.h>".}: cint
-  SC_TRACE_NAME_MAX*{.importc: "_SC_TRACE_NAME_MAX", header: "<unistd.h>".}: cint
-  SC_TRACE_SYS_MAX*{.importc: "_SC_TRACE_SYS_MAX", header: "<unistd.h>".}: cint
-  SC_TRACE_USER_EVENT_MAX*{.importc: "_SC_TRACE_USER_EVENT_MAX", header: "<unistd.h>".}: cint
-  SC_TTY_NAME_MAX*{.importc: "_SC_TTY_NAME_MAX", header: "<unistd.h>".}: cint
-  SC_TYPED_MEMORY_OBJECTS*{.importc: "_SC_TYPED_MEMORY_OBJECTS", header: "<unistd.h>".}: cint
-  SC_TZNAME_MAX*{.importc: "_SC_TZNAME_MAX", header: "<unistd.h>".}: cint
-  SC_V6_ILP32_OFF32*{.importc: "_SC_V6_ILP32_OFF32", header: "<unistd.h>".}: cint
-  SC_V6_ILP32_OFFBIG*{.importc: "_SC_V6_ILP32_OFFBIG", header: "<unistd.h>".}: cint
-  SC_V6_LP64_OFF64*{.importc: "_SC_V6_LP64_OFF64", header: "<unistd.h>".}: cint
-  SC_V6_LPBIG_OFFBIG*{.importc: "_SC_V6_LPBIG_OFFBIG", header: "<unistd.h>".}: cint
-  SC_VERSION*{.importc: "_SC_VERSION", header: "<unistd.h>".}: cint
-  SC_XBS5_ILP32_OFF32*{.importc: "_SC_XBS5_ILP32_OFF32", header: "<unistd.h>".}: cint
-  SC_XBS5_ILP32_OFFBIG*{.importc: "_SC_XBS5_ILP32_OFFBIG", header: "<unistd.h>".}: cint
-  SC_XBS5_LP64_OFF64*{.importc: "_SC_XBS5_LP64_OFF64", header: "<unistd.h>".}: cint
-  SC_XBS5_LPBIG_OFFBIG*{.importc: "_SC_XBS5_LPBIG_OFFBIG", 
-                         header: "<unistd.h>".}: cint
-  SC_XOPEN_CRYPT*{.importc: "_SC_XOPEN_CRYPT", header: "<unistd.h>".}: cint
-  SC_XOPEN_ENH_I18N*{.importc: "_SC_XOPEN_ENH_I18N", header: "<unistd.h>".}: cint
-  SC_XOPEN_LEGACY*{.importc: "_SC_XOPEN_LEGACY", header: "<unistd.h>".}: cint
-  SC_XOPEN_REALTIME*{.importc: "_SC_XOPEN_REALTIME", header: "<unistd.h>".}: cint
-  SC_XOPEN_REALTIME_THREADS*{.importc: "_SC_XOPEN_REALTIME_THREADS", 
-                              header: "<unistd.h>".}: cint
-  SC_XOPEN_SHM*{.importc: "_SC_XOPEN_SHM", header: "<unistd.h>".}: cint
-  SC_XOPEN_STREAMS*{.importc: "_SC_XOPEN_STREAMS", header: "<unistd.h>".}: cint
-  SC_XOPEN_UNIX*{.importc: "_SC_XOPEN_UNIX", header: "<unistd.h>".}: cint
-  SC_XOPEN_VERSION*{.importc: "_SC_XOPEN_VERSION", header: "<unistd.h>".}: cint
-  SC_NPROCESSORS_ONLN*{.importc: "_SC_NPROCESSORS_ONLN", 
-                        header: "<unistd.h>".}: cint
-  
-  SEM_FAILED* {.importc, header: "<semaphore.h>".}: pointer
-  IPC_CREAT* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Create entry if key does not exist.
-  IPC_EXCL* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Fail if key exists.
-  IPC_NOWAIT* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Error if request must wait.
-
-  IPC_PRIVATE* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Private key.
-
-  IPC_RMID* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Remove identifier.
-  IPC_SET* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Set options.
-  IPC_STAT* {.importc, header: "<sys/ipc.h>".}: cint
-    ## Get options. 
-
-  S_IFMT* {.importc, header: "<sys/stat.h>".}: cint
-    ## Type of file.
-  S_IFBLK* {.importc, header: "<sys/stat.h>".}: cint
-    ## Block special.
-  S_IFCHR* {.importc, header: "<sys/stat.h>".}: cint
-    ## Character special.
-  S_IFIFO* {.importc, header: "<sys/stat.h>".}: cint
-    ## FIFO special.
-  S_IFREG* {.importc, header: "<sys/stat.h>".}: cint
-    ## Regular.
-  S_IFDIR* {.importc, header: "<sys/stat.h>".}: cint
-    ## Directory.
-  S_IFLNK* {.importc, header: "<sys/stat.h>".}: cint
-    ## Symbolic link.
-  S_IFSOCK* {.importc, header: "<sys/stat.h>".}: cint
-    ## Socket.
-  S_IRWXU* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read, write, execute/search by owner.
-  S_IRUSR* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read permission, owner.
-  S_IWUSR* {.importc, header: "<sys/stat.h>".}: cint
-    ## Write permission, owner.
-  S_IXUSR* {.importc, header: "<sys/stat.h>".}: cint
-    ## Execute/search permission, owner.
-  S_IRWXG* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read, write, execute/search by group.
-  S_IRGRP* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read permission, group.
-  S_IWGRP* {.importc, header: "<sys/stat.h>".}: cint
-    ## Write permission, group.
-  S_IXGRP* {.importc, header: "<sys/stat.h>".}: cint
-    ## Execute/search permission, group.
-  S_IRWXO* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read, write, execute/search by others.
-  S_IROTH* {.importc, header: "<sys/stat.h>".}: cint
-    ## Read permission, others.
-  S_IWOTH* {.importc, header: "<sys/stat.h>".}: cint
-    ## Write permission, others.
-  S_IXOTH* {.importc, header: "<sys/stat.h>".}: cint
-    ## Execute/search permission, others.
-  S_ISUID* {.importc, header: "<sys/stat.h>".}: cint
-    ## Set-user-ID on execution.
-  S_ISGID* {.importc, header: "<sys/stat.h>".}: cint
-    ## Set-group-ID on execution.
-  S_ISVTX* {.importc, header: "<sys/stat.h>".}: cint
-    ## On directories, restricted deletion flag.
-  
-  ST_RDONLY* {.importc, header: "<sys/statvfs.h>".}: cint
-    ## Read-only file system.
-  ST_NOSUID* {.importc, header: "<sys/statvfs.h>".}: cint
-    ## Does not support the semantics of the ST_ISUID and ST_ISGID file mode bits.
-       
-  PROT_READ* {.importc, header: "<sys/mman.h>".}: cint
-    ## Page can be read.
-  PROT_WRITE* {.importc, header: "<sys/mman.h>".}: cint
-    ## Page can be written.
-  PROT_EXEC* {.importc, header: "<sys/mman.h>".}: cint
-    ## Page can be executed.
-  PROT_NONE* {.importc, header: "<sys/mman.h>".}: cint
-    ## Page cannot be accessed.
-  MAP_SHARED* {.importc, header: "<sys/mman.h>".}: cint
-    ## Share changes.
-  MAP_PRIVATE* {.importc, header: "<sys/mman.h>".}: cint
-    ## Changes are private.
-  MAP_FIXED* {.importc, header: "<sys/mman.h>".}: cint
-    ## Interpret addr exactly.
-  MS_ASYNC* {.importc, header: "<sys/mman.h>".}: cint
-    ## Perform asynchronous writes.
-  MS_SYNC* {.importc, header: "<sys/mman.h>".}: cint
-    ## Perform synchronous writes.
-  MS_INVALIDATE* {.importc, header: "<sys/mman.h>".}: cint
-    ## Invalidate mappings.
-  MCL_CURRENT* {.importc, header: "<sys/mman.h>".}: cint
-    ## Lock currently mapped pages.
-  MCL_FUTURE* {.importc, header: "<sys/mman.h>".}: cint
-    ## Lock pages that become mapped.
-  MAP_FAILED* {.importc, header: "<sys/mman.h>".}: cint
-  POSIX_MADV_NORMAL* {.importc, header: "<sys/mman.h>".}: cint
-    ## The application has no advice to give on its behavior with 
-    ## respect to the specified range. It is the default characteristic 
-    ## if no advice is given for a range of memory.
-  POSIX_MADV_SEQUENTIAL* {.importc, header: "<sys/mman.h>".}: cint
-    ## The application expects to access the specified range sequentially
-    ## from lower addresses to higher addresses.
-  POSIX_MADV_RANDOM* {.importc, header: "<sys/mman.h>".}: cint
-    ## The application expects to access the specified range in a random order.
-  POSIX_MADV_WILLNEED* {.importc, header: "<sys/mman.h>".}: cint
-    ## The application expects to access the specified range in the near future.
-  POSIX_MADV_DONTNEED* {.importc, header: "<sys/mman.h>".}: cint
-  POSIX_TYPED_MEM_ALLOCATE* {.importc, header: "<sys/mman.h>".}: cint
-  POSIX_TYPED_MEM_ALLOCATE_CONTIG* {.importc, header: "<sys/mman.h>".}: cint
-  POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc, header: "<sys/mman.h>".}: cint
-
-
-  CLOCKS_PER_SEC* {.importc, header: "<time.h>".}: int
-    ## A number used to convert the value returned by the clock() function
-    ## into seconds.
-  CLOCK_PROCESS_CPUTIME_ID* {.importc, header: "<time.h>".}: cint
-    ## The identifier of the CPU-time clock associated with the process 
-    ## making a clock() or timer*() function call.
-  CLOCK_THREAD_CPUTIME_ID* {.importc, header: "<time.h>".}: cint
-  CLOCK_REALTIME* {.importc, header: "<time.h>".}: cint
-    ## The identifier of the system-wide realtime clock.
-  TIMER_ABSTIME* {.importc, header: "<time.h>".}: cint
-    ## Flag indicating time is absolute. For functions taking timer 
-    ## objects, this refers to the clock associated with the timer.
-  CLOCK_MONOTONIC* {.importc, header: "<time.h>".}: cint
-
-  WNOHANG* {.importc, header: "<sys/wait.h>".}: cint
-    ## Do not hang if no status is available; return immediately.
-  WUNTRACED* {.importc, header: "<sys/wait.h>".}: cint
-    ## Report status of stopped child process.
-  WEXITSTATUS* {.importc, header: "<sys/wait.h>".}: cint
-    ## Return exit status.
-  WIFCONTINUED* {.importc, header: "<sys/wait.h>".}: cint
-    ## True if child has been continued.
-  WIFEXITED* {.importc, header: "<sys/wait.h>".}: cint
-    ## True if child exited normally.
-  WIFSIGNALED* {.importc, header: "<sys/wait.h>".}: cint
-    ## True if child exited due to uncaught signal.
-  WIFSTOPPED* {.importc, header: "<sys/wait.h>".}: cint
-    ## True if child is currently stopped.
-  WSTOPSIG* {.importc, header: "<sys/wait.h>".}: cint
-    ## Return signal number that caused process to stop.
-  WTERMSIG* {.importc, header: "<sys/wait.h>".}: cint
-    ## Return signal number that caused process to terminate.
-  WEXITED* {.importc, header: "<sys/wait.h>".}: cint
-    ## Wait for processes that have exited.
-  WSTOPPED* {.importc, header: "<sys/wait.h>".}: cint
-    ## Status is returned for any child that has stopped upon receipt 
-    ## of a signal.
-  WCONTINUED* {.importc, header: "<sys/wait.h>".}: cint
-    ## Status is returned for any child that was stopped and has been continued.
-  WNOWAIT* {.importc, header: "<sys/wait.h>".}: cint
-    ## Keep the process whose status is returned in infop in a waitable state. 
-  P_ALL* {.importc, header: "<sys/wait.h>".}: cint 
-  P_PID* {.importc, header: "<sys/wait.h>".}: cint 
-  P_PGID* {.importc, header: "<sys/wait.h>".}: cint
-       
-  SIG_DFL* {.importc, header: "<signal.h>".}: proc (x: cint) {.noconv.}
-    ## Request for default signal handling.
-  SIG_ERR* {.importc, header: "<signal.h>".}: proc (x: cint) {.noconv.}
-    ## Return value from signal() in case of error.
-  cSIG_HOLD* {.importc: "SIG_HOLD", 
-    header: "<signal.h>".}: proc (x: cint) {.noconv.}
-    ## Request that signal be held.
-  SIG_IGN* {.importc, header: "<signal.h>".}: proc (x: cint) {.noconv.}
-    ## Request that signal be ignored. 
-
-  SIGEV_NONE* {.importc, header: "<signal.h>".}: cint
-  SIGEV_SIGNAL* {.importc, header: "<signal.h>".}: cint
-  SIGEV_THREAD* {.importc, header: "<signal.h>".}: cint
-  SIGABRT* {.importc, header: "<signal.h>".}: cint
-  SIGALRM* {.importc, header: "<signal.h>".}: cint
-  SIGBUS* {.importc, header: "<signal.h>".}: cint
-  SIGCHLD* {.importc, header: "<signal.h>".}: cint
-  SIGCONT* {.importc, header: "<signal.h>".}: cint
-  SIGFPE* {.importc, header: "<signal.h>".}: cint
-  SIGHUP* {.importc, header: "<signal.h>".}: cint
-  SIGILL* {.importc, header: "<signal.h>".}: cint
-  SIGINT* {.importc, header: "<signal.h>".}: cint
-  SIGKILL* {.importc, header: "<signal.h>".}: cint
-  SIGPIPE* {.importc, header: "<signal.h>".}: cint
-  SIGQUIT* {.importc, header: "<signal.h>".}: cint
-  SIGSEGV* {.importc, header: "<signal.h>".}: cint
-  SIGSTOP* {.importc, header: "<signal.h>".}: cint
-  SIGTERM* {.importc, header: "<signal.h>".}: cint
-  SIGTSTP* {.importc, header: "<signal.h>".}: cint
-  SIGTTIN* {.importc, header: "<signal.h>".}: cint
-  SIGTTOU* {.importc, header: "<signal.h>".}: cint
-  SIGUSR1* {.importc, header: "<signal.h>".}: cint
-  SIGUSR2* {.importc, header: "<signal.h>".}: cint
-  SIGPOLL* {.importc, header: "<signal.h>".}: cint
-  SIGPROF* {.importc, header: "<signal.h>".}: cint
-  SIGSYS* {.importc, header: "<signal.h>".}: cint
-  SIGTRAP* {.importc, header: "<signal.h>".}: cint
-  SIGURG* {.importc, header: "<signal.h>".}: cint
-  SIGVTALRM* {.importc, header: "<signal.h>".}: cint
-  SIGXCPU* {.importc, header: "<signal.h>".}: cint
-  SIGXFSZ* {.importc, header: "<signal.h>".}: cint
-  SA_NOCLDSTOP* {.importc, header: "<signal.h>".}: cint
-  SIG_BLOCK* {.importc, header: "<signal.h>".}: cint
-  SIG_UNBLOCK* {.importc, header: "<signal.h>".}: cint
-  SIG_SETMASK* {.importc, header: "<signal.h>".}: cint
-  SA_ONSTACK* {.importc, header: "<signal.h>".}: cint
-  SA_RESETHAND* {.importc, header: "<signal.h>".}: cint
-  SA_RESTART* {.importc, header: "<signal.h>".}: cint
-  SA_SIGINFO* {.importc, header: "<signal.h>".}: cint
-  SA_NOCLDWAIT* {.importc, header: "<signal.h>".}: cint
-  SA_NODEFER* {.importc, header: "<signal.h>".}: cint
-  SS_ONSTACK* {.importc, header: "<signal.h>".}: cint
-  SS_DISABLE* {.importc, header: "<signal.h>".}: cint
-  MINSIGSTKSZ* {.importc, header: "<signal.h>".}: cint
-  SIGSTKSZ* {.importc, header: "<signal.h>".}: cint
-
-  NL_SETD* {.importc, header: "<nl_types.h>".}: cint
-  NL_CAT_LOCALE* {.importc, header: "<nl_types.h>".}: cint
-
-  SCHED_FIFO* {.importc, header: "<sched.h>".}: cint
-  SCHED_RR* {.importc, header: "<sched.h>".}: cint
-  SCHED_SPORADIC* {.importc, header: "<sched.h>".}: cint
-  SCHED_OTHER* {.importc, header: "<sched.h>".}: cint
-  FD_SETSIZE* {.importc, header: "<sys/select.h>".}: cint
-
-  SEEK_SET* {.importc, header: "<unistd.h>".}: cint
-  SEEK_CUR* {.importc, header: "<unistd.h>".}: cint
-  SEEK_END* {.importc, header: "<unistd.h>".}: cint
-
-  SCM_RIGHTS* {.importc, header: "<sys/socket.h>".}: cint
-    ## Indicates that the data array contains the access rights 
-    ## to be sent or received. 
-
-  SOCK_DGRAM* {.importc, header: "<sys/socket.h>".}: cint ## Datagram socket.
-  SOCK_RAW* {.importc, header: "<sys/socket.h>".}: cint
-    ## Raw Protocol Interface.
-  SOCK_SEQPACKET* {.importc, header: "<sys/socket.h>".}: cint
-    ## Sequenced-packet socket.
-  SOCK_STREAM* {.importc, header: "<sys/socket.h>".}: cint
-    ## Byte-stream socket. 
-    
-  SOL_SOCKET* {.importc, header: "<sys/socket.h>".}: cint
-    ## Options to be accessed at socket level, not protocol level. 
-    
-  SO_ACCEPTCONN* {.importc, header: "<sys/socket.h>".}: cint
-    ## Socket is accepting connections.
-  SO_BROADCAST* {.importc, header: "<sys/socket.h>".}: cint
-    ## Transmission of broadcast messages is supported.
-  SO_DEBUG* {.importc, header: "<sys/socket.h>".}: cint
-    ## Debugging information is being recorded.
-  SO_DONTROUTE* {.importc, header: "<sys/socket.h>".}: cint
-    ## Bypass normal routing.
-  SO_ERROR* {.importc, header: "<sys/socket.h>".}: cint
-    ## Socket error status.
-  SO_KEEPALIVE* {.importc, header: "<sys/socket.h>".}: cint
-    ## Connections are kept alive with periodic messages.
-  SO_LINGER* {.importc, header: "<sys/socket.h>".}: cint
-    ## Socket lingers on close.
-  SO_OOBINLINE* {.importc, header: "<sys/socket.h>".}: cint
-    ## Out-of-band data is transmitted in line.
-  SO_RCVBUF* {.importc, header: "<sys/socket.h>".}: cint
-    ## Receive buffer size.
-  SO_RCVLOWAT* {.importc, header: "<sys/socket.h>".}: cint
-    ## Receive *low water mark*.
-  SO_RCVTIMEO* {.importc, header: "<sys/socket.h>".}: cint
-    ## Receive timeout.
-  SO_REUSEADDR* {.importc, header: "<sys/socket.h>".}: cint
-    ## Reuse of local addresses is supported.
-  SO_SNDBUF* {.importc, header: "<sys/socket.h>".}: cint
-    ## Send buffer size.
-  SO_SNDLOWAT* {.importc, header: "<sys/socket.h>".}: cint
-    ## Send *low water mark*.
-  SO_SNDTIMEO* {.importc, header: "<sys/socket.h>".}: cint
-    ## Send timeout.
-  SO_TYPE* {.importc, header: "<sys/socket.h>".}: cint
-    ## Socket type. 
-      
-  SOMAXCONN* {.importc, header: "<sys/socket.h>".}: cint
-    ## The maximum backlog queue length. 
-    
-  MSG_CTRUNC* {.importc, header: "<sys/socket.h>".}: cint
-    ## Control data truncated.
-  MSG_DONTROUTE* {.importc, header: "<sys/socket.h>".}: cint
-    ## Send without using routing tables.
-  MSG_EOR* {.importc, header: "<sys/socket.h>".}: cint
-    ## Terminates a record (if supported by the protocol).
-  MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
-    ## Out-of-band data.
-  MSG_PEEK* {.importc, header: "<sys/socket.h>".}: cint
-    ## Leave received data in queue.
-  MSG_TRUNC* {.importc, header: "<sys/socket.h>".}: cint
-    ## Normal data truncated.
-  MSG_WAITALL* {.importc, header: "<sys/socket.h>".}: cint
-    ## Attempt to fill the read buffer. 
-
-  AF_INET* {.importc, header: "<sys/socket.h>".}: cint
-    ## Internet domain sockets for use with IPv4 addresses.
-  AF_INET6* {.importc, header: "<sys/socket.h>".}: cint
-    ## Internet domain sockets for use with IPv6 addresses.
-  AF_UNIX* {.importc, header: "<sys/socket.h>".}: cint
-    ## UNIX domain sockets.
-  AF_UNSPEC* {.importc, header: "<sys/socket.h>".}: cint
-    ## Unspecified. 
-
-  SHUT_RD* {.importc, header: "<sys/socket.h>".}: cint
-    ## Disables further receive operations.
-  SHUT_RDWR* {.importc, header: "<sys/socket.h>".}: cint
-    ## Disables further send and receive operations.
-  SHUT_WR* {.importc, header: "<sys/socket.h>".}: cint
-    ## Disables further send operations. 
-
-  IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
-    
-  IPPROTO_IP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Internet protocol.
-  IPPROTO_IPV6* {.importc, header: "<netinet/in.h>".}: cint
-    ## Internet Protocol Version 6.
-  IPPROTO_ICMP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Control message protocol.
-  IPPROTO_RAW* {.importc, header: "<netinet/in.h>".}: cint
-    ## Raw IP Packets Protocol. 
-  IPPROTO_TCP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Transmission control protocol.
-  IPPROTO_UDP* {.importc, header: "<netinet/in.h>".}: cint
-    ## User datagram protocol.
-
-  INADDR_ANY* {.importc, header: "<netinet/in.h>".}: TinAddrScalar
-    ## IPv4 local host address.
-  INADDR_BROADCAST* {.importc, header: "<netinet/in.h>".}: TinAddrScalar
-    ## IPv4 broadcast address.
-
-  INET_ADDRSTRLEN* {.importc, header: "<netinet/in.h>".}: cint
-    ## 16. Length of the string form for IP. 
-
-  IPV6_JOIN_GROUP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Join a multicast group.
-  IPV6_LEAVE_GROUP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Quit a multicast group.
-  IPV6_MULTICAST_HOPS* {.importc, header: "<netinet/in.h>".}: cint
-    ## Multicast hop limit.
-  IPV6_MULTICAST_IF* {.importc, header: "<netinet/in.h>".}: cint
-    ## Interface to use for outgoing multicast packets.
-  IPV6_MULTICAST_LOOP* {.importc, header: "<netinet/in.h>".}: cint
-    ## Multicast packets are delivered back to the local application.
-  IPV6_UNICAST_HOPS* {.importc, header: "<netinet/in.h>".}: cint
-    ## Unicast hop limit.
-  IPV6_V6ONLY* {.importc, header: "<netinet/in.h>".}: cint
-    ## Restrict AF_INET6 socket to IPv6 communications only.
-
-  TCP_NODELAY* {.importc, header: "<netinet/tcp.h>".}: cint
-    ## Avoid coalescing of small segments. 
-
-  IPPORT_RESERVED* {.importc, header: "<netdb.h>".}: cint 
-
-  HOST_NOT_FOUND* {.importc, header: "<netdb.h>".}: cint 
-  NO_DATA* {.importc, header: "<netdb.h>".}: cint 
-  NO_RECOVERY* {.importc, header: "<netdb.h>".}: cint 
-  TRY_AGAIN* {.importc, header: "<netdb.h>".}: cint 
-
-  AI_PASSIVE* {.importc, header: "<netdb.h>".}: cint 
-    ## Socket address is intended for bind().
-  AI_CANONNAME* {.importc, header: "<netdb.h>".}: cint 
-    ## Request for canonical name.
-  AI_NUMERICHOST* {.importc, header: "<netdb.h>".}: cint 
-    ## Return numeric host address as name.
-  AI_NUMERICSERV* {.importc, header: "<netdb.h>".}: cint 
-    ## Inhibit service name resolution.
-  AI_V4MAPPED* {.importc, header: "<netdb.h>".}: cint 
-     ## If no IPv6 addresses are found, query for IPv4 addresses and
-     ## return them to the caller as IPv4-mapped IPv6 addresses.
-  AI_ALL* {.importc, header: "<netdb.h>".}: cint 
-    ## Query for both IPv4 and IPv6 addresses.
-  AI_ADDRCONFIG* {.importc, header: "<netdb.h>".}: cint 
-    ## Query for IPv4 addresses only when an IPv4 address is configured; 
-    ## query for IPv6 addresses only when an IPv6 address is configured.
-
-  NI_NOFQDN* {.importc, header: "<netdb.h>".}: cint 
-    ## Only the nodename portion of the FQDN is returned for local hosts.
-  NI_NUMERICHOST* {.importc, header: "<netdb.h>".}: cint 
-    ## The numeric form of the node's address is returned instead of its name.
-  NI_NAMEREQD* {.importc, header: "<netdb.h>".}: cint 
-    ## Return an error if the node's name cannot be located in the database.
-  NI_NUMERICSERV* {.importc, header: "<netdb.h>".}: cint 
-    ## The numeric form of the service address is returned instead of its name.
-  NI_NUMERICSCOPE* {.importc, header: "<netdb.h>".}: cint 
-    ## For IPv6 addresses, the numeric form of the scope identifier is
-    ## returned instead of its name.
-  NI_DGRAM* {.importc, header: "<netdb.h>".}: cint 
-    ## Indicates that the service is a datagram service (SOCK_DGRAM). 
-
-  EAI_AGAIN* {.importc, header: "<netdb.h>".}: cint 
-    ## The name could not be resolved at this time. Future attempts may succeed.
-  EAI_BADFLAGS* {.importc, header: "<netdb.h>".}: cint 
-    ## The flags had an invalid value.
-  EAI_FAIL* {.importc, header: "<netdb.h>".}: cint 
-    ## A non-recoverable error occurred.
-  EAI_FAMILY* {.importc, header: "<netdb.h>".}: cint 
-    ## The address family was not recognized or the address length 
-    ## was invalid for the specified family.
-  EAI_MEMORY* {.importc, header: "<netdb.h>".}: cint 
-    ## There was a memory allocation failure.
-  EAI_NONAME* {.importc, header: "<netdb.h>".}: cint 
-    ## The name does not resolve for the supplied parameters.
-    ## NI_NAMEREQD is set and the host's name cannot be located, 
-    ## or both nodename and servname were null.
-  EAI_SERVICE* {.importc, header: "<netdb.h>".}: cint 
-    ## The service passed was not recognized for the specified socket type.
-  EAI_SOCKTYPE* {.importc, header: "<netdb.h>".}: cint 
-    ## The intended socket type was not recognized.
-  EAI_SYSTEM* {.importc, header: "<netdb.h>".}: cint 
-    ## A system error occurred. The error code can be found in errno.
-  EAI_OVERFLOW* {.importc, header: "<netdb.h>".}: cint 
-    ## An argument buffer overflowed.
-
-  POLLIN* {.importc, header: "<poll.h>".}: cshort
-    ## Data other than high-priority data may be read without blocking.
-  POLLRDNORM* {.importc, header: "<poll.h>".}: cshort
-    ## Normal data may be read without blocking.
-  POLLRDBAND* {.importc, header: "<poll.h>".}: cshort
-    ## Priority data may be read without blocking.
-  POLLPRI* {.importc, header: "<poll.h>".}: cshort
-    ## High priority data may be read without blocking.
-  POLLOUT* {.importc, header: "<poll.h>".}: cshort
-    ## Normal data may be written without blocking.
-  POLLWRNORM* {.importc, header: "<poll.h>".}: cshort
-    ## Equivalent to POLLOUT.
-  POLLWRBAND* {.importc, header: "<poll.h>".}: cshort
-    ## Priority data may be written.
-  POLLERR* {.importc, header: "<poll.h>".}: cshort
-    ## An error has occurred (revents only).
-  POLLHUP* {.importc, header: "<poll.h>".}: cshort
-    ## Device has been disconnected (revents only).
-  POLLNVAL* {.importc, header: "<poll.h>".}: cshort
-    ## Invalid fd member (revents only). 
-
-
-when hasSpawnh:
-  var
-    POSIX_SPAWN_RESETIDS* {.importc, header: "<spawn.h>".}: cint
-    POSIX_SPAWN_SETPGROUP* {.importc, header: "<spawn.h>".}: cint
-    POSIX_SPAWN_SETSCHEDPARAM* {.importc, header: "<spawn.h>".}: cint
-    POSIX_SPAWN_SETSCHEDULER* {.importc, header: "<spawn.h>".}: cint
-    POSIX_SPAWN_SETSIGDEF* {.importc, header: "<spawn.h>".}: cint
-    POSIX_SPAWN_SETSIGMASK* {.importc, header: "<spawn.h>".}: cint
+  STDOUT_FILENO* = 1 ## File number of stdout;
+
+  DT_UNKNOWN* = 0 ## Unknown file type.
+  DT_FIFO* = 1    ## Named pipe, or FIFO.
+  DT_CHR* = 2     ## Character device.
+  DT_DIR* = 4     ## Directory.
+  DT_BLK* = 6     ## Block device.
+  DT_REG* = 8     ## Regular file.
+  DT_LNK* = 10    ## Symbolic link.
+  DT_SOCK* = 12   ## UNIX domain socket.
+  DT_WHT* = 14
+
+# Special types
+type Sighandler = proc (a: cint) {.noconv.}
+
+const StatHasNanoseconds* = defined(linux) or defined(freebsd) or
+    defined(osx) or defined(openbsd) or defined(dragonfly) or defined(haiku) ## \
+  ## Boolean flag that indicates if the system supports nanosecond time
+  ## resolution in the fields of `Stat`. Note that the nanosecond based fields
+  ## (`Stat.st_atim`, `Stat.st_mtim` and `Stat.st_ctim`) can be accessed
+  ## without checking this flag, because this module defines fallback procs
+  ## when they are not available.
+
+# Platform specific stuff
+
+when (defined(linux) and not defined(android)) and defined(amd64):
+  include posix_linux_amd64
+elif defined(openbsd) and defined(amd64):
+  include posix_openbsd_amd64
+elif (defined(macos) or defined(macosx) or defined(bsd)) and defined(cpu64):
+  include posix_macos_amd64
+elif defined(nintendoswitch):
+  include posix_nintendoswitch
+elif defined(haiku):
+  include posix_haiku
+else:
+  include posix_other
+
+# There used to be this name in posix.nim a long time ago, not sure why!
+
+when StatHasNanoseconds:
+  proc st_atime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last access.
+    result = s.st_atim.tv_sec
+  proc st_mtime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last data modification.
+    result = s.st_mtim.tv_sec
+  proc st_ctime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last status change.
+    result = s.st_ctim.tv_sec
+else:
+  proc st_atim*(s: Stat): Timespec {.inline.} =
+    ## Nanosecond-granularity time of last access.
+    result.tv_sec = s.st_atime
+  proc st_mtim*(s: Stat): Timespec {.inline.} =
+    ## Nanosecond-granularity time of last data modification.
+    result.tv_sec = s.st_mtime
+  proc st_ctim*(s: Stat): Timespec {.inline.} =
+    ## Nanosecond-granularity time of last data modification.
+    result.tv_sec = s.st_ctime
 
 when hasAioH:
   proc aio_cancel*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".}
@@ -1721,326 +142,373 @@ when hasAioH:
   proc aio_fsync*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".}
   proc aio_read*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".}
   proc aio_return*(a1: ptr Taiocb): int {.importc, header: "<aio.h>".}
-  proc aio_suspend*(a1: ptr ptr Taiocb, a2: cint, a3: ptr ttimespec): cint {.
+  proc aio_suspend*(a1: ptr ptr Taiocb, a2: cint, a3: ptr Timespec): cint {.
                    importc, header: "<aio.h>".}
   proc aio_write*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".}
   proc lio_listio*(a1: cint, a2: ptr ptr Taiocb, a3: cint,
-               a4: ptr Tsigevent): cint {.importc, header: "<aio.h>".}
+               a4: ptr SigEvent): cint {.importc, header: "<aio.h>".}
 
 # arpa/inet.h
-proc htonl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".}
-proc htons*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".}
-proc ntohl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".}
-proc ntohs*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".}
-
-proc inet_addr*(a1: cstring): int32 {.importc, header: "<arpa/inet.h>".}
-proc inet_ntoa*(a1: int32): cstring {.importc, header: "<arpa/inet.h>".}
-proc inet_ntop*(a1: cint, a2: pointer, a3: cstring, a4: int32): cstring {.
-  importc, header: "<arpa/inet.h>".}
-proc inet_pton*(a1: cint, a2: cstring, a3: pointer): cint {.
+proc htonl*(a1: uint32): uint32 {.importc, header: "<arpa/inet.h>".}
+proc htons*(a1: uint16): uint16 {.importc, header: "<arpa/inet.h>".}
+proc ntohl*(a1: uint32): uint32 {.importc, header: "<arpa/inet.h>".}
+proc ntohs*(a1: uint16): uint16 {.importc, header: "<arpa/inet.h>".}
+
+when not defined(zephyr):
+  proc inet_addr*(a1: cstring): InAddrT {.importc, header: "<arpa/inet.h>".}
+  proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "<arpa/inet.h>".}
+
+proc inet_ntop*(a1: cint, a2: pointer | ptr InAddr | ptr In6Addr, a3: cstring, a4: int32): cstring {.
+  importc:"(char *)$1", header: "<arpa/inet.h>".}
+proc inet_pton*(a1: cint, a2: cstring, a3: pointer | ptr InAddr | ptr In6Addr): cint {.
   importc, header: "<arpa/inet.h>".}
 
 var
-  in6addr_any* {.importc, header: "<netinet/in.h>".}: TIn6Addr
-  in6addr_loopback* {.importc, header: "<netinet/in.h>".}: TIn6Addr
+  in6addr_any* {.importc, header: "<netinet/in.h>".}: In6Addr
+  in6addr_loopback* {.importc, header: "<netinet/in.h>".}: In6Addr
 
-proc IN6ADDR_ANY_INIT* (): TIn6Addr {.importc, header: "<netinet/in.h>".}
-proc IN6ADDR_LOOPBACK_INIT* (): TIn6Addr {.importc, header: "<netinet/in.h>".}
+proc IN6ADDR_ANY_INIT* (): In6Addr {.importc, header: "<netinet/in.h>".}
+proc IN6ADDR_LOOPBACK_INIT* (): In6Addr {.importc, header: "<netinet/in.h>".}
 
 # dirent.h
-proc closedir*(a1: ptr TDIR): cint  {.importc, header: "<dirent.h>".}
-proc opendir*(a1: cstring): ptr TDir {.importc, header: "<dirent.h>".}
-proc readdir*(a1: ptr TDIR): ptr TDirent  {.importc, header: "<dirent.h>".}
-proc readdir_r*(a1: ptr TDIR, a2: ptr Tdirent, a3: ptr ptr TDirent): cint  {.
-                importc, header: "<dirent.h>".}
-proc rewinddir*(a1: ptr TDIR)  {.importc, header: "<dirent.h>".}
-proc seekdir*(a1: ptr TDIR, a2: int)  {.importc, header: "<dirent.h>".}
-proc telldir*(a1: ptr TDIR): int {.importc, header: "<dirent.h>".}
+proc closedir*(a1: ptr DIR): cint  {.importc, header: "<dirent.h>".}
+proc opendir*(a1: cstring): ptr DIR {.importc, header: "<dirent.h>", sideEffect.}
+proc readdir*(a1: ptr DIR): ptr Dirent  {.importc, header: "<dirent.h>", sideEffect.}
+proc readdir_r*(a1: ptr DIR, a2: ptr Dirent, a3: ptr ptr Dirent): cint  {.
+                importc, header: "<dirent.h>", sideEffect.}
+proc rewinddir*(a1: ptr DIR)  {.importc, header: "<dirent.h>".}
+proc seekdir*(a1: ptr DIR, a2: int)  {.importc, header: "<dirent.h>".}
+proc telldir*(a1: ptr DIR): int {.importc, header: "<dirent.h>".}
 
 # dlfcn.h
-proc dlclose*(a1: pointer): cint {.importc, header: "<dlfcn.h>".}
-proc dlerror*(): cstring {.importc, header: "<dlfcn.h>".}
-proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "<dlfcn.h>".}
-proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "<dlfcn.h>".}
-
-proc creat*(a1: cstring, a2: Tmode): cint {.importc, header: "<fcntl.h>".}
-proc fcntl*(a1: cint, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".}
-proc open*(a1: cstring, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".}
-proc posix_fadvise*(a1: cint, a2, a3: Toff, a4: cint): cint {.
-  importc, header: "<fcntl.h>".}
-proc posix_fallocate*(a1: cint, a2, a3: Toff): cint {.
+proc dlclose*(a1: pointer): cint {.importc, header: "<dlfcn.h>", sideEffect.}
+proc dlerror*(): cstring {.importc, header: "<dlfcn.h>", sideEffect.}
+proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "<dlfcn.h>", sideEffect.}
+proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "<dlfcn.h>", sideEffect.}
+
+proc creat*(a1: cstring, a2: Mode): cint {.importc, header: "<fcntl.h>", sideEffect.}
+proc fcntl*(a1: cint | SocketHandle, a2: cint): cint {.varargs, importc, header: "<fcntl.h>", sideEffect.}
+proc openImpl(a1: cstring, a2: cint): cint {.varargs, importc: "open", header: "<fcntl.h>", sideEffect.}
+proc open*(a1: cstring, a2: cint, mode: Mode | cint = 0.Mode): cint {.inline.} =
+  # prevents bug #17888
+  openImpl(a1, a2, mode)
+
+proc posix_fadvise*(a1: cint, a2, a3: Off, a4: cint): cint {.
   importc, header: "<fcntl.h>".}
 
-proc feclearexcept*(a1: cint): cint {.importc, header: "<fenv.h>".}
-proc fegetexceptflag*(a1: ptr Tfexcept, a2: cint): cint {.
-  importc, header: "<fenv.h>".}
-proc feraiseexcept*(a1: cint): cint {.importc, header: "<fenv.h>".}
-proc fesetexceptflag*(a1: ptr Tfexcept, a2: cint): cint {.
-  importc, header: "<fenv.h>".}
-proc fetestexcept*(a1: cint): cint {.importc, header: "<fenv.h>".}
-proc fegetround*(): cint {.importc, header: "<fenv.h>".}
-proc fesetround*(a1: cint): cint {.importc, header: "<fenv.h>".}
-proc fegetenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
-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>".}
-
-proc fmtmsg*(a1: int, a2: cstring, a3: cint,
-            a4, a5, a6: cstring): cint {.importc, header: "<fmtmsg.h>".}
-            
+proc ftruncate*(a1: cint, a2: Off): cint {.importc, header: "<unistd.h>".}
+when defined(osx):              # 2001 POSIX evidently does not concern Apple
+  type FStore {.importc: "fstore_t", header: "<fcntl.h>", bycopy.} = object
+    fst_flags: uint32           ## IN: flags word
+    fst_posmode: cint           ## IN: indicates offset field
+    fst_offset,                 ## IN: start of the region
+      fst_length,               ## IN: size of the region
+      fst_bytesalloc: Off       ## OUT: number of bytes allocated
+  var F_PEOFPOSMODE {.importc, header: "<fcntl.h>".}: cint
+  var F_ALLOCATEALL {.importc, header: "<fcntl.h>".}: uint32
+  var F_PREALLOCATE {.importc, header: "<fcntl.h>".}: cint
+  proc posix_fallocate*(a1: cint, a2, a3: Off): cint =
+    var fst = FStore(fst_flags: F_ALLOCATEALL, fst_posmode: F_PEOFPOSMODE,
+                     fst_offset: a2, fst_length: a3)
+    # Must also call ftruncate to match what POSIX does. Unlike posix_fallocate,
+    # this can shrink files.  Could guard w/getFileSize, but caller likely knows
+    # present size & has no good reason to call this unless it is growing.
+    if fcntl(a1, F_PREALLOCATE, fst.addr) != cint(-1): ftruncate(a1, a2 + a3)
+    else: cint(-1)
+else:
+  proc posix_fallocate*(a1: cint, a2, a3: Off): cint {.
+    importc, header: "<fcntl.h>".}
+
+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>".}
+
 proc fnmatch*(a1, a2: cstring, a3: cint): cint {.importc, header: "<fnmatch.h>".}
-proc ftw*(a1: cstring, 
-         a2: proc (x1: cstring, x2: ptr TStat, x3: cint): cint {.noconv.},
+proc ftw*(a1: cstring,
+         a2: proc (x1: cstring, x2: ptr Stat, x3: cint): cint {.noconv.},
          a3: cint): cint {.importc, header: "<ftw.h>".}
-proc nftw*(a1: cstring, 
-          a2: proc (x1: cstring, x2: ptr TStat, 
-                    x3: cint, x4: ptr TFTW): cint {.noconv.},
-          a3: cint,
-          a4: cint): cint {.importc, header: "<ftw.h>".}
+when not (defined(linux) and defined(amd64)) and not defined(nintendoswitch):
+  proc nftw*(a1: cstring,
+            a2: proc (x1: cstring, x2: ptr Stat,
+                      x3: cint, x4: ptr FTW): cint {.noconv.},
+            a3: cint,
+            a4: cint): cint {.importc, header: "<ftw.h>".}
 
 proc glob*(a1: cstring, a2: cint,
           a3: proc (x1: cstring, x2: cint): cint {.noconv.},
-          a4: ptr Tglob): cint {.importc, header: "<glob.h>".}
-proc globfree*(a1: ptr TGlob) {.importc, header: "<glob.h>".}
-
-proc getgrgid*(a1: TGid): ptr TGroup {.importc, header: "<grp.h>".}
-proc getgrnam*(a1: cstring): ptr TGroup {.importc, header: "<grp.h>".}
-proc getgrgid_r*(a1: Tgid, a2: ptr TGroup, a3: cstring, a4: int,
-                 a5: ptr ptr TGroup): cint {.importc, header: "<grp.h>".}
-proc getgrnam_r*(a1: cstring, a2: ptr TGroup, a3: cstring, 
-                  a4: int, a5: ptr ptr TGroup): cint {.
+          a4: ptr Glob): cint {.importc, header: "<glob.h>", sideEffect.}
+  ## Filename globbing. Use `os.walkPattern() <os.html#glob_1>`_ and similar.
+
+proc globfree*(a1: ptr Glob) {.importc, header: "<glob.h>".}
+
+proc getgrgid*(a1: Gid): ptr Group {.importc, header: "<grp.h>".}
+proc getgrnam*(a1: cstring): ptr Group {.importc, header: "<grp.h>".}
+proc getgrgid_r*(a1: Gid, a2: ptr Group, a3: cstring, a4: int,
+                 a5: ptr ptr Group): cint {.importc, header: "<grp.h>".}
+proc getgrnam_r*(a1: cstring, a2: ptr Group, a3: cstring,
+                  a4: int, a5: ptr ptr Group): cint {.
                  importc, header: "<grp.h>".}
-proc getgrent*(): ptr TGroup {.importc, header: "<grp.h>".}
+proc getgrent*(): ptr Group {.importc, header: "<grp.h>".}
 proc endgrent*() {.importc, header: "<grp.h>".}
 proc setgrent*() {.importc, header: "<grp.h>".}
 
 
-proc iconv_open*(a1, a2: cstring): TIconv {.importc, header: "<iconv.h>".}
-proc iconv*(a1: Ticonv, a2: var cstring, a3: var int, a4: var cstring,
+proc iconv_open*(a1, a2: cstring): Iconv {.importc, header: "<iconv.h>".}
+proc iconv*(a1: Iconv, a2: var cstring, a3: var int, a4: var cstring,
             a5: var int): int {.importc, header: "<iconv.h>".}
-proc iconv_close*(a1: Ticonv): cint {.importc, header: "<iconv.h>".}
+proc iconv_close*(a1: Iconv): cint {.importc, header: "<iconv.h>".}
 
-proc nl_langinfo*(a1: Tnl_item): cstring {.importc, header: "<langinfo.h>".}
+proc nl_langinfo*(a1: Nl_item): cstring {.importc, header: "<langinfo.h>".}
 
 proc basename*(a1: cstring): cstring {.importc, header: "<libgen.h>".}
 proc dirname*(a1: cstring): cstring {.importc, header: "<libgen.h>".}
 
-proc localeconv*(): ptr Tlconv {.importc, header: "<locale.h>".}
+proc localeconv*(): ptr Lconv {.importc, header: "<locale.h>".}
 proc setlocale*(a1: cint, a2: cstring): cstring {.
-                importc, header: "<locale.h>".}
+                importc, header: "<locale.h>", sideEffect.}
 
 proc strfmon*(a1: cstring, a2: int, a3: cstring): int {.varargs,
    importc, header: "<monetary.h>".}
 
-proc mq_close*(a1: Tmqd): cint {.importc, header: "<mqueue.h>".}
-proc mq_getattr*(a1: Tmqd, a2: ptr Tmq_attr): cint {.
-  importc, header: "<mqueue.h>".}
-proc mq_notify*(a1: Tmqd, a2: ptr Tsigevent): cint {.
-  importc, header: "<mqueue.h>".}
-proc mq_open*(a1: cstring, a2: cint): TMqd {.
-  varargs, importc, header: "<mqueue.h>".}
-proc mq_receive*(a1: Tmqd, a2: cstring, a3: int, a4: var int): int {.
-  importc, header: "<mqueue.h>".}
-proc mq_send*(a1: Tmqd, a2: cstring, a3: int, a4: int): cint {.
-  importc, header: "<mqueue.h>".}
-proc mq_setattr*(a1: Tmqd, a2, a3: ptr Tmq_attr): cint {.
-  importc, header: "<mqueue.h>".}
-
-proc mq_timedreceive*(a1: Tmqd, a2: cstring, a3: int, a4: int, 
-                      a5: ptr TTimespec): int {.importc, header: "<mqueue.h>".}
-proc mq_timedsend*(a1: Tmqd, a2: cstring, a3: int, a4: int, 
-                   a5: ptr TTimeSpec): cint {.importc, header: "<mqueue.h>".}
-proc mq_unlink*(a1: cstring): cint {.importc, header: "<mqueue.h>".}
-
-
-proc getpwnam*(a1: cstring): ptr TPasswd {.importc, header: "<pwd.h>".}
-proc getpwuid*(a1: Tuid): ptr TPasswd {.importc, header: "<pwd.h>".}
-proc getpwnam_r*(a1: cstring, a2: ptr Tpasswd, a3: cstring, a4: int,
-                 a5: ptr ptr Tpasswd): cint {.importc, header: "<pwd.h>".}
-proc getpwuid_r*(a1: Tuid, a2: ptr Tpasswd, a3: cstring,
-      a4: int, a5: ptr ptr Tpasswd): cint {.importc, header: "<pwd.h>".}
+when not (defined(nintendoswitch) or defined(macos) or defined(macosx)):
+  proc mq_notify*(mqdes: Mqd, event: ptr SigEvent): cint {.
+    importc, header: "<mqueue.h>".}
+
+  proc mq_open*(name: cstring, flags: cint): Mqd {.
+    varargs, importc, header: "<mqueue.h>".}
+
+  proc mq_close*(mqdes: Mqd): cint {.importc, header: "<mqueue.h>".}
+
+  proc mq_receive*(
+    mqdes: Mqd,
+    buffer: cstring,
+    length: csize_t,
+    priority: var cuint
+  ): int {.importc, header: "<mqueue.h>".}
+
+  proc mq_timedreceive*(
+    mqdes: Mqd,
+    buffer: cstring,
+    length: csize_t,
+    priority: cuint,
+    timeout: ptr Timespec
+  ): int {.importc, header: "<mqueue.h>".}
+
+  proc mq_send*(
+    mqdes: Mqd,
+    buffer: cstring,
+    length: csize_t,
+    priority: cuint
+  ): cint {.importc, header: "<mqueue.h>".}
+
+  proc mq_timedsend*(
+    mqdes: Mqd,
+    buffer: cstring,
+    length: csize_t,
+    priority: cuint,
+    timeout: ptr Timespec
+  ): cint {.importc, header: "<mqueue.h>".}
+
+  proc mq_getattr*(mqdes: Mqd, attribute: ptr MqAttr): cint {.
+    importc, header: "<mqueue.h>".}
+
+  proc mq_setattr*(mqdes: Mqd, newAttribute, oldAttribute: ptr MqAttr): cint {.
+    importc, header: "<mqueue.h>".}
+
+  proc mq_unlink*(mqdes: cstring): cint {.importc, header: "<mqueue.h>".}
+
+
+proc getpwnam*(a1: cstring): ptr Passwd {.importc, header: "<pwd.h>".}
+proc getpwuid*(a1: Uid): ptr Passwd {.importc, header: "<pwd.h>".}
+proc getpwnam_r*(a1: cstring, a2: ptr Passwd, a3: cstring, a4: int,
+                 a5: ptr ptr Passwd): cint {.importc, header: "<pwd.h>".}
+proc getpwuid_r*(a1: Uid, a2: ptr Passwd, a3: cstring,
+      a4: int, a5: ptr ptr Passwd): cint {.importc, header: "<pwd.h>".}
 proc endpwent*() {.importc, header: "<pwd.h>".}
-proc getpwent*(): ptr TPasswd {.importc, header: "<pwd.h>".}
+proc getpwent*(): ptr Passwd {.importc, header: "<pwd.h>".}
 proc setpwent*() {.importc, header: "<pwd.h>".}
 
-proc uname*(a1: var Tutsname): cint {.importc, header: "<sys/utsname.h>".}
+proc uname*(a1: var Utsname): cint {.importc, header: "<sys/utsname.h>".}
+
+proc strerror*(errnum: cint): cstring {.importc, header: "<string.h>".}
 
-proc pthread_atfork*(a1, a2, a3: proc {.noconv.}): cint {.
+proc pthread_atfork*(a1, a2, a3: proc () {.noconv.}): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_destroy*(a1: ptr Tpthread_attr): cint {.
+proc pthread_attr_destroy*(a1: ptr Pthread_attr): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_getdetachstate*(a1: ptr Tpthread_attr, a2: cint): cint {.
+proc pthread_attr_getdetachstate*(a1: ptr Pthread_attr, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_getguardsize*(a1: ptr Tpthread_attr, a2: var cint): cint {.
+proc pthread_attr_getguardsize*(a1: ptr Pthread_attr, a2: var cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_getinheritsched*(a1: ptr Tpthread_attr,
+proc pthread_attr_getinheritsched*(a1: ptr Pthread_attr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getschedparam*(a1: ptr Tpthread_attr,
-          a2: ptr Tsched_param): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getschedpolicy*(a1: ptr Tpthread_attr,
+proc pthread_attr_getschedparam*(a1: ptr Pthread_attr,
+          a2: ptr Sched_param): cint {.importc, header: "<pthread.h>".}
+proc pthread_attr_getschedpolicy*(a1: ptr Pthread_attr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getscope*(a1: ptr Tpthread_attr,
+proc pthread_attr_getscope*(a1: ptr Pthread_attr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getstack*(a1: ptr Tpthread_attr,
+proc pthread_attr_getstack*(a1: ptr Pthread_attr,
          a2: var pointer, a3: var int): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getstackaddr*(a1: ptr Tpthread_attr,
+proc pthread_attr_getstackaddr*(a1: ptr Pthread_attr,
           a2: var pointer): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_getstacksize*(a1: ptr Tpthread_attr,
+proc pthread_attr_getstacksize*(a1: ptr Pthread_attr,
           a2: var int): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_init*(a1: ptr Tpthread_attr): cint {.
+proc pthread_attr_init*(a1: ptr Pthread_attr): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setdetachstate*(a1: ptr Tpthread_attr, a2: cint): cint {.
+proc pthread_attr_setdetachstate*(a1: ptr Pthread_attr, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setguardsize*(a1: ptr Tpthread_attr, a2: int): cint {.
+proc pthread_attr_setguardsize*(a1: ptr Pthread_attr, a2: int): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setinheritsched*(a1: ptr Tpthread_attr, a2: cint): cint {.
+proc pthread_attr_setinheritsched*(a1: ptr Pthread_attr, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setschedparam*(a1: ptr Tpthread_attr,
-          a2: ptr Tsched_param): cint {.importc, header: "<pthread.h>".}
-proc pthread_attr_setschedpolicy*(a1: ptr Tpthread_attr, a2: cint): cint {.
+proc pthread_attr_setschedparam*(a1: ptr Pthread_attr,
+          a2: ptr Sched_param): cint {.importc, header: "<pthread.h>".}
+proc pthread_attr_setschedpolicy*(a1: ptr Pthread_attr, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setscope*(a1: ptr Tpthread_attr, a2: cint): cint {.importc,
+proc pthread_attr_setscope*(a1: ptr Pthread_attr, a2: cint): cint {.importc,
   header: "<pthread.h>".}
-proc pthread_attr_setstack*(a1: ptr Tpthread_attr, a2: pointer, a3: int): cint {.
+proc pthread_attr_setstack*(a1: ptr Pthread_attr, a2: pointer, a3: int): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setstackaddr*(a1: ptr TPthread_attr, a2: pointer): cint {.
+proc pthread_attr_setstackaddr*(a1: ptr Pthread_attr, a2: pointer): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_attr_setstacksize*(a1: ptr TPthread_attr, a2: int): cint {.
+proc pthread_attr_setstacksize*(a1: ptr Pthread_attr, a2: int): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_barrier_destroy*(a1: ptr Tpthread_barrier): cint {.
+proc pthread_barrier_destroy*(a1: ptr Pthread_barrier): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_barrier_init*(a1: ptr Tpthread_barrier,
-         a2: ptr Tpthread_barrierattr, a3: cint): cint {.
+proc pthread_barrier_init*(a1: ptr Pthread_barrier,
+         a2: ptr Pthread_barrierattr, a3: cint): cint {.
          importc, header: "<pthread.h>".}
-proc pthread_barrier_wait*(a1: ptr Tpthread_barrier): cint {.
+proc pthread_barrier_wait*(a1: ptr Pthread_barrier): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_barrierattr_destroy*(a1: ptr Tpthread_barrierattr): cint {.
+proc pthread_barrierattr_destroy*(a1: ptr Pthread_barrierattr): cint {.
   importc, header: "<pthread.h>".}
 proc pthread_barrierattr_getpshared*(
-          a1: ptr Tpthread_barrierattr, a2: var cint): cint {.
+          a1: ptr Pthread_barrierattr, a2: var cint): cint {.
           importc, header: "<pthread.h>".}
-proc pthread_barrierattr_init*(a1: ptr TPthread_barrierattr): cint {.
+proc pthread_barrierattr_init*(a1: ptr Pthread_barrierattr): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_barrierattr_setpshared*(a1: ptr TPthread_barrierattr, 
+proc pthread_barrierattr_setpshared*(a1: ptr Pthread_barrierattr,
   a2: cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_cancel*(a1: Tpthread): cint {.importc, header: "<pthread.h>".}
+proc pthread_cancel*(a1: Pthread): cint {.importc, header: "<pthread.h>".}
 proc pthread_cleanup_push*(a1: proc (x: pointer) {.noconv.}, a2: pointer) {.
   importc, header: "<pthread.h>".}
 proc pthread_cleanup_pop*(a1: cint) {.importc, header: "<pthread.h>".}
-proc pthread_cond_broadcast*(a1: ptr Tpthread_cond): cint {.
+proc pthread_cond_broadcast*(a1: ptr Pthread_cond): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_cond_destroy*(a1: ptr Tpthread_cond): cint {.importc, header: "<pthread.h>".}
-proc pthread_cond_init*(a1: ptr Tpthread_cond,
-          a2: ptr Tpthread_condattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_cond_signal*(a1: ptr Tpthread_cond): cint {.importc, header: "<pthread.h>".}
-proc pthread_cond_timedwait*(a1: ptr Tpthread_cond,
-          a2: ptr Tpthread_mutex, a3: ptr Ttimespec): cint {.importc, header: "<pthread.h>".}
-
-proc pthread_cond_wait*(a1: ptr Tpthread_cond,
-          a2: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".}
-proc pthread_condattr_destroy*(a1: ptr Tpthread_condattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_condattr_getclock*(a1: ptr Tpthread_condattr,
-          a2: var Tclockid): cint {.importc, header: "<pthread.h>".}
-proc pthread_condattr_getpshared*(a1: ptr Tpthread_condattr,
+proc pthread_cond_destroy*(a1: ptr Pthread_cond): cint {.importc, header: "<pthread.h>".}
+proc pthread_cond_init*(a1: ptr Pthread_cond,
+          a2: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_cond_signal*(a1: ptr Pthread_cond): cint {.importc, header: "<pthread.h>".}
+proc pthread_cond_timedwait*(a1: ptr Pthread_cond,
+          a2: ptr Pthread_mutex, a3: ptr Timespec): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_cond_wait*(a1: ptr Pthread_cond,
+          a2: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".}
+proc pthread_condattr_destroy*(a1: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_condattr_getclock*(a1: ptr Pthread_condattr,
+          a2: var ClockId): cint {.importc, header: "<pthread.h>".}
+proc pthread_condattr_getpshared*(a1: ptr Pthread_condattr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-          
-proc pthread_condattr_init*(a1: ptr TPthread_condattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_condattr_setclock*(a1: ptr TPthread_condattr,a2: Tclockid): cint {.importc, header: "<pthread.h>".}
-proc pthread_condattr_setpshared*(a1: ptr TPthread_condattr, a2: cint): cint {.importc, header: "<pthread.h>".}
 
-proc pthread_create*(a1: ptr Tpthread, a2: ptr Tpthread_attr,
+proc pthread_condattr_init*(a1: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_condattr_setclock*(a1: ptr Pthread_condattr,a2: ClockId): cint {.importc, header: "<pthread.h>".}
+proc pthread_condattr_setpshared*(a1: ptr Pthread_condattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_create*(a1: ptr Pthread, a2: ptr Pthread_attr,
           a3: proc (x: pointer): pointer {.noconv.}, a4: pointer): cint {.importc, header: "<pthread.h>".}
-proc pthread_detach*(a1: Tpthread): cint {.importc, header: "<pthread.h>".}
-proc pthread_equal*(a1, a2: Tpthread): cint {.importc, header: "<pthread.h>".}
+proc pthread_detach*(a1: Pthread): cint {.importc, header: "<pthread.h>".}
+proc pthread_equal*(a1, a2: Pthread): cint {.importc, header: "<pthread.h>".}
 proc pthread_exit*(a1: pointer) {.importc, header: "<pthread.h>".}
 proc pthread_getconcurrency*(): cint {.importc, header: "<pthread.h>".}
-proc pthread_getcpuclockid*(a1: Tpthread, a2: var Tclockid): cint {.importc, header: "<pthread.h>".}
-proc pthread_getschedparam*(a1: Tpthread,  a2: var cint,
-          a3: ptr Tsched_param): cint {.importc, header: "<pthread.h>".}
-proc pthread_getspecific*(a1: Tpthread_key): pointer {.importc, header: "<pthread.h>".}
-proc pthread_join*(a1: Tpthread, a2: ptr pointer): cint {.importc, header: "<pthread.h>".}
-proc pthread_key_create*(a1: ptr Tpthread_key, a2: proc (x: pointer) {.noconv.}): cint {.importc, header: "<pthread.h>".}
-proc pthread_key_delete*(a1: Tpthread_key): cint {.importc, header: "<pthread.h>".}
-
-proc pthread_mutex_destroy*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_getprioceiling*(a1: ptr Tpthread_mutex,
+proc pthread_getcpuclockid*(a1: Pthread, a2: var ClockId): cint {.importc, header: "<pthread.h>".}
+proc pthread_getschedparam*(a1: Pthread,  a2: var cint,
+          a3: ptr Sched_param): cint {.importc, header: "<pthread.h>".}
+proc pthread_getspecific*(a1: Pthread_key): pointer {.importc, header: "<pthread.h>".}
+proc pthread_join*(a1: Pthread, a2: ptr pointer): cint {.importc, header: "<pthread.h>".}
+proc pthread_key_create*(a1: ptr Pthread_key, a2: proc (x: pointer) {.noconv.}): cint {.importc, header: "<pthread.h>".}
+proc pthread_key_delete*(a1: Pthread_key): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_mutex_destroy*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_getprioceiling*(a1: ptr Pthread_mutex,
          a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_init*(a1: ptr Tpthread_mutex,
-          a2: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_lock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_setprioceiling*(a1: ptr Tpthread_mutex,a2: cint,
+proc pthread_mutex_init*(a1: ptr Pthread_mutex,
+          a2: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_lock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_setprioceiling*(a1: ptr Pthread_mutex,a2: cint,
           a3: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_timedlock*(a1: ptr Tpthread_mutex,
-          a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_trylock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutex_unlock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_destroy*(a1: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_timedlock*(a1: ptr Pthread_mutex,
+          a2: ptr Timespec): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_trylock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutex_unlock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_destroy*(a1: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".}
 
 proc pthread_mutexattr_getprioceiling*(
-          a1: ptr Tpthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_getprotocol*(a1: ptr Tpthread_mutexattr,
+          a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_getprotocol*(a1: ptr Pthread_mutexattr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_getpshared*(a1: ptr Tpthread_mutexattr,
+proc pthread_mutexattr_getpshared*(a1: ptr Pthread_mutexattr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_gettype*(a1: ptr Tpthread_mutexattr,
+proc pthread_mutexattr_gettype*(a1: ptr Pthread_mutexattr,
           a2: var cint): cint {.importc, header: "<pthread.h>".}
 
-proc pthread_mutexattr_init*(a1: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_setprioceiling*(a1: ptr tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_setprotocol*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_setpshared*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_mutexattr_settype*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
-
-proc pthread_once*(a1: ptr Tpthread_once, a2: proc {.noconv.}): cint {.importc, header: "<pthread.h>".}
-
-proc pthread_rwlock_destroy*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_init*(a1: ptr Tpthread_rwlock,
-          a2: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_rdlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_timedrdlock*(a1: ptr Tpthread_rwlock,
-          a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_timedwrlock*(a1: ptr Tpthread_rwlock,
-          a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".}
-
-proc pthread_rwlock_tryrdlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_trywrlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_unlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlock_wrlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlockattr_destroy*(a1: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_init*(a1: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_setprioceiling*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_setprotocol*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_setpshared*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+proc pthread_mutexattr_settype*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_once*(a1: ptr Pthread_once, a2: proc () {.noconv.}): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_rwlock_destroy*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_init*(a1: ptr Pthread_rwlock,
+          a2: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_rdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_timedrdlock*(a1: ptr Pthread_rwlock,
+          a2: ptr Timespec): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_timedwrlock*(a1: ptr Pthread_rwlock,
+          a2: ptr Timespec): cint {.importc, header: "<pthread.h>".}
+
+proc pthread_rwlock_tryrdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_trywrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_unlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlock_wrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlockattr_destroy*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
 proc pthread_rwlockattr_getpshared*(
-          a1: ptr Tpthread_rwlockattr, a2: var cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlockattr_init*(a1: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
-proc pthread_rwlockattr_setpshared*(a1: ptr Tpthread_rwlockattr, a2: cint): cint {.importc, header: "<pthread.h>".}
+          a1: ptr Pthread_rwlockattr, a2: var cint): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlockattr_init*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".}
+proc pthread_rwlockattr_setpshared*(a1: ptr Pthread_rwlockattr, a2: cint): cint {.importc, header: "<pthread.h>".}
 
-proc pthread_self*(): Tpthread {.importc, header: "<pthread.h>".}
+proc pthread_self*(): Pthread {.importc, header: "<pthread.h>".}
 proc pthread_setcancelstate*(a1: cint, a2: var cint): cint {.importc, header: "<pthread.h>".}
 proc pthread_setcanceltype*(a1: cint, a2: var cint): cint {.importc, header: "<pthread.h>".}
 proc pthread_setconcurrency*(a1: cint): cint {.importc, header: "<pthread.h>".}
-proc pthread_setschedparam*(a1: Tpthread, a2: cint,
-          a3: ptr Tsched_param): cint {.importc, header: "<pthread.h>".}
+proc pthread_setschedparam*(a1: Pthread, a2: cint,
+          a3: ptr Sched_param): cint {.importc, header: "<pthread.h>".}
 
-proc pthread_setschedprio*(a1: Tpthread, a2: cint): cint {.
+proc pthread_setschedprio*(a1: Pthread, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_setspecific*(a1: Tpthread_key, a2: pointer): cint {.
+proc pthread_setspecific*(a1: Pthread_key, a2: pointer): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_spin_destroy*(a1: ptr Tpthread_spinlock): cint {.
+proc pthread_spin_destroy*(a1: ptr Pthread_spinlock): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_spin_init*(a1: ptr Tpthread_spinlock, a2: cint): cint {.
+proc pthread_spin_init*(a1: ptr Pthread_spinlock, a2: cint): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_spin_lock*(a1: ptr Tpthread_spinlock): cint {.
+proc pthread_spin_lock*(a1: ptr Pthread_spinlock): cint {.
   importc, header: "<pthread.h>".}
-proc pthread_spin_trylock*(a1: ptr Tpthread_spinlock): cint{.
+proc pthread_spin_trylock*(a1: ptr Pthread_spinlock): cint{.
   importc, header: "<pthread.h>".}
-proc pthread_spin_unlock*(a1: ptr Tpthread_spinlock): cint {.
+proc pthread_spin_unlock*(a1: ptr Pthread_spinlock): cint {.
   importc, header: "<pthread.h>".}
 proc pthread_testcancel*() {.importc, header: "<pthread.h>".}
 
 
+proc exitnow*(code: int) {.importc: "_exit", header: "<unistd.h>".}
 proc access*(a1: cstring, a2: cint): cint {.importc, header: "<unistd.h>".}
 proc alarm*(a1: cint): cint {.importc, header: "<unistd.h>".}
 proc chdir*(a1: cstring): cint {.importc, header: "<unistd.h>".}
-proc chown*(a1: cstring, a2: Tuid, a3: Tgid): cint {.importc, header: "<unistd.h>".}
-proc close*(a1: cint): cint {.importc, header: "<unistd.h>".}
+proc chown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".}
+proc close*(a1: cint | SocketHandle): cint {.importc, header: "<unistd.h>".}
 proc confstr*(a1: cint, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".}
 proc crypt*(a1, a2: cstring): cstring {.importc, header: "<unistd.h>".}
 proc ctermid*(a1: cstring): cstring {.importc, header: "<unistd.h>".}
@@ -2048,395 +516,487 @@ proc dup*(a1: cint): cint {.importc, header: "<unistd.h>".}
 proc dup2*(a1, a2: cint): cint {.importc, header: "<unistd.h>".}
 proc encrypt*(a1: array[0..63, char], a2: cint) {.importc, header: "<unistd.h>".}
 
-proc execl*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
-proc execle*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
-proc execlp*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>".}
-proc execv*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>".}
+proc execl*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
+proc execle*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
+proc execlp*(a1, a2: cstring): cint {.varargs, importc, header: "<unistd.h>", sideEffect.}
+proc execv*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
 proc execve*(a1: cstring, a2, a3: cstringArray): cint {.
-  importc, header: "<unistd.h>".}
-proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>".}
-proc fchown*(a1: cint, a2: Tuid, a3: Tgid): cint {.importc, header: "<unistd.h>".}
-proc fchdir*(a1: cint): cint {.importc, header: "<unistd.h>".}
+  importc, header: "<unistd.h>", sideEffect.}
+proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
+proc execvpe*(a1: cstring, a2: cstringArray, a3: cstringArray): cint {.importc, header: "<unistd.h>", sideEffect.}
+proc fchown*(a1: cint, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>", sideEffect.}
+proc fchdir*(a1: cint): cint {.importc, header: "<unistd.h>", sideEffect.}
 proc fdatasync*(a1: cint): cint {.importc, header: "<unistd.h>".}
-proc fork*(): Tpid {.importc, header: "<unistd.h>".}
+proc fork*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
 proc fpathconf*(a1, a2: cint): int {.importc, header: "<unistd.h>".}
 proc fsync*(a1: cint): cint {.importc, header: "<unistd.h>".}
-proc ftruncate*(a1: cint, a2: Toff): cint {.importc, header: "<unistd.h>".}
-proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "<unistd.h>".}
-proc getegid*(): TGid {.importc, header: "<unistd.h>".}
-proc geteuid*(): TUid {.importc, header: "<unistd.h>".}
-proc getgid*(): TGid {.importc, header: "<unistd.h>".}
+ ## synchronize a file's buffer cache to the storage device
+
+proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "<unistd.h>", sideEffect.}
+proc getuid*(): Uid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the real user ID of the calling process
+
+proc geteuid*(): Uid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the effective user ID of the calling process
 
-proc getgroups*(a1: cint, a2: ptr array[0..255, Tgid]): cint {.
+proc getgid*(): Gid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the real group ID of the calling process
+
+proc getegid*(): Gid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the effective group ID of the calling process
+
+proc getgroups*(a1: cint, a2: ptr array[0..255, Gid]): cint {.
   importc, header: "<unistd.h>".}
-proc gethostid*(): int {.importc, header: "<unistd.h>".}
-proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".}
-proc getlogin*(): cstring {.importc, header: "<unistd.h>".}
-proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".}
+proc gethostid*(): int {.importc, header: "<unistd.h>", sideEffect.}
+proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>", sideEffect.}
+proc getlogin*(): cstring {.importc, header: "<unistd.h>", sideEffect.}
+proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>", sideEffect.}
 
 proc getopt*(a1: cint, a2: cstringArray, a3: cstring): cint {.
   importc, header: "<unistd.h>".}
-proc getpgid*(a1: Tpid): Tpid {.importc, header: "<unistd.h>".}
-proc getpgrp*(): Tpid {.importc, header: "<unistd.h>".}
-proc getpid*(): Tpid {.importc, header: "<unistd.h>".}
-proc getppid*(): Tpid {.importc, header: "<unistd.h>".}
-proc getsid*(a1: Tpid): Tpid {.importc, header: "<unistd.h>".}
-proc getuid*(): Tuid {.importc, header: "<unistd.h>".}
+proc getpgid*(a1: Pid): Pid {.importc, header: "<unistd.h>".}
+proc getpgrp*(): Pid {.importc, header: "<unistd.h>".}
+proc getpid*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns  the process ID (PID) of the calling process
+
+proc getppid*(): Pid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the process ID of the parent of the calling process
+
+proc getsid*(a1: Pid): Pid {.importc, header: "<unistd.h>", sideEffect.}
+ ## returns the session ID of the calling process
+
 proc getwd*(a1: cstring): cstring {.importc, header: "<unistd.h>".}
 proc isatty*(a1: cint): cint {.importc, header: "<unistd.h>".}
-proc lchown*(a1: cstring, a2: Tuid, a3: Tgid): cint {.importc, header: "<unistd.h>".}
+proc lchown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".}
 proc link*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".}
 
-proc lockf*(a1, a2: cint, a3: Toff): cint {.importc, header: "<unistd.h>".}
-proc lseek*(a1: cint, a2: Toff, a3: cint): Toff {.importc, header: "<unistd.h>".}
+proc lockf*(a1, a2: cint, a3: Off): cint {.importc, header: "<unistd.h>".}
+proc lseek*(a1: cint, a2: Off, a3: cint): Off {.importc, header: "<unistd.h>".}
 proc nice*(a1: cint): cint {.importc, header: "<unistd.h>".}
 proc pathconf*(a1: cstring, a2: cint): int {.importc, header: "<unistd.h>".}
 
 proc pause*(): cint {.importc, header: "<unistd.h>".}
+proc pclose*(a: File): cint {.importc, header: "<stdio.h>".}
 proc pipe*(a: array[0..1, cint]): cint {.importc, header: "<unistd.h>".}
-proc pread*(a1: cint, a2: pointer, a3: int, a4: Toff): int {.
+proc popen*(a1, a2: cstring): File {.importc, header: "<stdio.h>".}
+proc pread*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
   importc, header: "<unistd.h>".}
-proc pwrite*(a1: cint, a2: pointer, a3: int, a4: Toff): int {.
+proc pwrite*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
   importc, header: "<unistd.h>".}
 proc read*(a1: cint, a2: pointer, a3: int): int {.importc, header: "<unistd.h>".}
-proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".}
+when not defined(nintendoswitch):
+  proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".}
+proc ioctl*(f: FileHandle, device: uint): int {.importc: "ioctl",
+      header: "<sys/ioctl.h>", varargs, tags: [WriteIOEffect].}
+  ## A system call for device-specific input/output operations and other
+  ## operations which cannot be expressed by regular system calls
 
 proc rmdir*(a1: cstring): cint {.importc, header: "<unistd.h>".}
-proc setegid*(a1: Tgid): cint {.importc, header: "<unistd.h>".}
-proc seteuid*(a1: Tuid): cint {.importc, header: "<unistd.h>".}
-proc setgid*(a1: Tgid): cint {.importc, header: "<unistd.h>".}
-
-proc setpgid*(a1, a2: Tpid): cint {.importc, header: "<unistd.h>".}
-proc setpgrp*(): Tpid {.importc, header: "<unistd.h>".}
-proc setregid*(a1, a2: Tgid): cint {.importc, header: "<unistd.h>".}
-proc setreuid*(a1, a2: Tuid): cint {.importc, header: "<unistd.h>".}
-proc setsid*(): Tpid {.importc, header: "<unistd.h>".}
-proc setuid*(a1: Tuid): cint {.importc, header: "<unistd.h>".}
+proc setegid*(a1: Gid): cint {.importc, header: "<unistd.h>".}
+proc seteuid*(a1: Uid): cint {.importc, header: "<unistd.h>".}
+proc setgid*(a1: Gid): cint {.importc, header: "<unistd.h>".}
+
+proc setpgid*(a1, a2: Pid): cint {.importc, header: "<unistd.h>".}
+proc setpgrp*(): Pid {.importc, header: "<unistd.h>".}
+proc setregid*(a1, a2: Gid): cint {.importc, header: "<unistd.h>".}
+proc setreuid*(a1, a2: Uid): cint {.importc, header: "<unistd.h>".}
+proc setsid*(): Pid {.importc, header: "<unistd.h>".}
+proc setuid*(a1: Uid): cint {.importc, header: "<unistd.h>".}
 proc sleep*(a1: cint): cint {.importc, header: "<unistd.h>".}
 proc swab*(a1, a2: pointer, a3: int) {.importc, header: "<unistd.h>".}
-proc symlink*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".}
+when not defined(nintendoswitch):
+  proc symlink*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".}
+else:
+  proc symlink*(a1, a2: cstring): cint = -1
 proc sync*() {.importc, header: "<unistd.h>".}
 proc sysconf*(a1: cint): int {.importc, header: "<unistd.h>".}
-proc tcgetpgrp*(a1: cint): tpid {.importc, header: "<unistd.h>".}
-proc tcsetpgrp*(a1: cint, a2: Tpid): cint {.importc, header: "<unistd.h>".}
-proc truncate*(a1: cstring, a2: Toff): cint {.importc, header: "<unistd.h>".}
+proc tcgetpgrp*(a1: cint): Pid {.importc, header: "<unistd.h>".}
+proc tcsetpgrp*(a1: cint, a2: Pid): cint {.importc, header: "<unistd.h>".}
+proc truncate*(a1: cstring, a2: Off): cint {.importc, header: "<unistd.h>".}
 proc ttyname*(a1: cint): cstring {.importc, header: "<unistd.h>".}
 proc ttyname_r*(a1: cint, a2: cstring, a3: int): cint {.
   importc, header: "<unistd.h>".}
-proc ualarm*(a1, a2: Tuseconds): Tuseconds {.importc, header: "<unistd.h>".}
+proc ualarm*(a1, a2: Useconds): Useconds {.importc, header: "<unistd.h>".}
 proc unlink*(a1: cstring): cint {.importc, header: "<unistd.h>".}
-proc usleep*(a1: Tuseconds): cint {.importc, header: "<unistd.h>".}
-proc vfork*(): tpid {.importc, header: "<unistd.h>".}
+proc usleep*(a1: Useconds): cint {.importc, header: "<unistd.h>".}
+proc vfork*(): Pid {.importc, header: "<unistd.h>".}
 proc write*(a1: cint, a2: pointer, a3: int): int {.importc, header: "<unistd.h>".}
 
-proc sem_close*(a1: ptr Tsem): cint {.importc, header: "<semaphore.h>".}
-proc sem_destroy*(a1: ptr Tsem): cint {.importc, header: "<semaphore.h>".}
-proc sem_getvalue*(a1: ptr Tsem, a2: var cint): cint {.
+proc sem_close*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".}
+proc sem_destroy*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".}
+proc sem_getvalue*(a1: ptr Sem, a2: var cint): cint {.
   importc, header: "<semaphore.h>".}
-proc sem_init*(a1: ptr Tsem, a2: cint, a3: cint): cint {.
+proc sem_init*(a1: ptr Sem, a2: cint, a3: cint): cint {.
   importc, header: "<semaphore.h>".}
-proc sem_open*(a1: cstring, a2: cint): ptr TSem {.
+proc sem_open*(a1: cstring, a2: cint): ptr Sem {.
   varargs, importc, header: "<semaphore.h>".}
-proc sem_post*(a1: ptr Tsem): cint {.importc, header: "<semaphore.h>".}
-proc sem_timedwait*(a1: ptr Tsem, a2: ptr Ttimespec): cint {.
+proc sem_post*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".}
+proc sem_timedwait*(a1: ptr Sem, a2: ptr Timespec): cint {.
   importc, header: "<semaphore.h>".}
-proc sem_trywait*(a1: ptr Tsem): cint {.importc, header: "<semaphore.h>".}
+proc sem_trywait*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".}
 proc sem_unlink*(a1: cstring): cint {.importc, header: "<semaphore.h>".}
-proc sem_wait*(a1: ptr Tsem): cint {.importc, header: "<semaphore.h>".}
+proc sem_wait*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".}
 
-proc ftok*(a1: cstring, a2: cint): Tkey {.importc, header: "<sys/ipc.h>".}
+proc ftok*(a1: cstring, a2: cint): Key {.importc, header: "<sys/ipc.h>".}
 
-proc statvfs*(a1: cstring, a2: var Tstatvfs): cint {.
+proc statvfs*(a1: cstring, a2: var Statvfs): cint {.
   importc, header: "<sys/statvfs.h>".}
-proc fstatvfs*(a1: cint, a2: var Tstatvfs): cint {.
+proc fstatvfs*(a1: cint, a2: var Statvfs): cint {.
   importc, header: "<sys/statvfs.h>".}
 
-proc chmod*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".}
-proc fchmod*(a1: cint, a2: TMode): cint {.importc, header: "<sys/stat.h>".}
-proc fstat*(a1: cint, a2: var Tstat): cint {.importc, header: "<sys/stat.h>".}
-proc lstat*(a1: cstring, a2: var Tstat): cint {.importc, header: "<sys/stat.h>".}
-proc mkdir*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".}
-proc mkfifo*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".}
-proc mknod*(a1: cstring, a2: TMode, a3: Tdev): cint {.
+proc chmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+when defined(osx) or defined(freebsd):
+  proc lchmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+proc fchmod*(a1: cint, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+proc fstat*(a1: cint, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+proc lstat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+proc mkdir*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+  ## Use `os.createDir() <os.html#createDir,string>`_ and similar.
+
+proc mkfifo*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".}
+proc mknod*(a1: cstring, a2: Mode, a3: Dev): cint {.
   importc, header: "<sys/stat.h>".}
-proc stat*(a1: cstring, a2: var Tstat): cint {.importc, header: "<sys/stat.h>".}
-proc umask*(a1: Tmode): TMode {.importc, header: "<sys/stat.h>".}
+proc stat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>".}
+proc umask*(a1: Mode): Mode {.importc, header: "<sys/stat.h>".}
 
-proc S_ISBLK*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISBLK*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a block special file.
-proc S_ISCHR*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISCHR*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a character special file.
-proc S_ISDIR*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISDIR*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a directory.
-proc S_ISFIFO*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISFIFO*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a pipe or FIFO special file.
-proc S_ISREG*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISREG*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a regular file.
-proc S_ISLNK*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISLNK*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a symbolic link.
-proc S_ISSOCK*(m: Tmode): bool {.importc, header: "<sys/stat.h>".}
-  ## Test for a socket. 
-    
-proc S_TYPEISMQ*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".}
+proc S_ISSOCK*(m: Mode): bool {.importc, header: "<sys/stat.h>".}
+  ## Test for a socket.
+
+proc S_TYPEISMQ*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a message queue.
-proc S_TYPEISSEM*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".}
+proc S_TYPEISSEM*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".}
   ## Test for a semaphore.
-proc S_TYPEISSHM*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".}
-  ## Test for a shared memory object. 
-    
-proc S_TYPEISTMO*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".}
-  ## Test macro for a typed memory object. 
-  
+proc S_TYPEISSHM*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".}
+  ## Test for a shared memory object.
+
+proc S_TYPEISTMO*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".}
+  ## Test macro for a typed memory object.
+
 proc mlock*(a1: pointer, a2: int): cint {.importc, header: "<sys/mman.h>".}
 proc mlockall*(a1: cint): cint {.importc, header: "<sys/mman.h>".}
-proc mmap*(a1: pointer, a2: int, a3, a4, a5: cint, a6: Toff): pointer {.
+proc mmap*(a1: pointer, a2: int, a3, a4, a5: cint, a6: Off): pointer {.
   importc, header: "<sys/mman.h>".}
 proc mprotect*(a1: pointer, a2: int, a3: cint): cint {.
   importc, header: "<sys/mman.h>".}
 proc msync*(a1: pointer, a2: int, a3: cint): cint {.importc, header: "<sys/mman.h>".}
+
 proc munlock*(a1: pointer, a2: int): cint {.importc, header: "<sys/mman.h>".}
 proc munlockall*(): cint {.importc, header: "<sys/mman.h>".}
 proc munmap*(a1: pointer, a2: int): cint {.importc, header: "<sys/mman.h>".}
 proc posix_madvise*(a1: pointer, a2: int, a3: cint): cint {.
   importc, header: "<sys/mman.h>".}
-proc posix_mem_offset*(a1: pointer, a2: int, a3: var Toff,
+proc posix_mem_offset*(a1: pointer, a2: int, a3: var Off,
            a4: var int, a5: var cint): cint {.importc, header: "<sys/mman.h>".}
-proc posix_typed_mem_get_info*(a1: cint, 
-  a2: var Tposix_typed_mem_info): cint {.importc, header: "<sys/mman.h>".}
+when not (defined(linux) and defined(amd64)) and not defined(nintendoswitch) and
+     not defined(haiku):
+  proc posix_typed_mem_get_info*(a1: cint,
+    a2: var Posix_typed_mem_info): cint {.importc, header: "<sys/mman.h>".}
 proc posix_typed_mem_open*(a1: cstring, a2, a3: cint): cint {.
   importc, header: "<sys/mman.h>".}
-proc shm_open*(a1: cstring, a2: cint, a3: Tmode): cint {.
+proc shm_open*(a1: cstring, a2: cint, a3: Mode): cint {.
   importc, header: "<sys/mman.h>".}
 proc shm_unlink*(a1: cstring): cint {.importc, header: "<sys/mman.h>".}
 
-proc asctime*(a1: var ttm): cstring{.importc, header: "<time.h>".}
-
-proc asctime_r*(a1: var ttm, a2: cstring): cstring {.importc, header: "<time.h>".}
-proc clock*(): Tclock {.importc, header: "<time.h>".}
-proc clock_getcpuclockid*(a1: tpid, a2: var Tclockid): cint {.
-  importc, header: "<time.h>".}
-proc clock_getres*(a1: Tclockid, a2: var Ttimespec): cint {.
-  importc, header: "<time.h>".}
-proc clock_gettime*(a1: Tclockid, a2: var Ttimespec): cint {.
-  importc, header: "<time.h>".}
-proc clock_nanosleep*(a1: Tclockid, a2: cint, a3: var Ttimespec,
-               a4: var Ttimespec): cint {.importc, header: "<time.h>".}
-proc clock_settime*(a1: Tclockid, a2: var Ttimespec): cint {.
-  importc, header: "<time.h>".}
-
-proc ctime*(a1: var Ttime): cstring {.importc, header: "<time.h>".}
-proc ctime_r*(a1: var Ttime, a2: cstring): cstring {.importc, header: "<time.h>".}
-proc difftime*(a1, a2: Ttime): cdouble {.importc, header: "<time.h>".}
-proc getdate*(a1: cstring): ptr ttm {.importc, header: "<time.h>".}
-
-proc gmtime*(a1: var ttime): ptr ttm {.importc, header: "<time.h>".}
-proc gmtime_r*(a1: var ttime, a2: var ttm): ptr ttm {.importc, header: "<time.h>".}
-proc localtime*(a1: var ttime): ptr ttm {.importc, header: "<time.h>".}
-proc localtime_r*(a1: var ttime, a2: var ttm): ptr ttm {.importc, header: "<time.h>".}
-proc mktime*(a1: var ttm): ttime  {.importc, header: "<time.h>".}
-proc nanosleep*(a1, a2: var Ttimespec): cint {.importc, header: "<time.h>".}
+proc asctime*(a1: var Tm): cstring{.importc, header: "<time.h>".}
+
+proc asctime_r*(a1: var Tm, a2: cstring): cstring {.importc, header: "<time.h>".}
+proc clock*(): Clock {.importc, header: "<time.h>", sideEffect.}
+proc clock_getcpuclockid*(a1: Pid, a2: var ClockId): cint {.
+  importc, header: "<time.h>", sideEffect.}
+proc clock_getres*(a1: ClockId, a2: var Timespec): cint {.
+  importc, header: "<time.h>", sideEffect.}
+proc clock_gettime*(a1: ClockId, a2: var Timespec): cint {.
+  importc, header: "<time.h>", sideEffect.}
+proc clock_nanosleep*(a1: ClockId, a2: cint, a3: var Timespec,
+               a4: var Timespec): cint {.importc, header: "<time.h>", sideEffect.}
+proc clock_settime*(a1: ClockId, a2: var Timespec): cint {.
+  importc, header: "<time.h>", sideEffect.}
+
+proc `==`*(a, b: Time): bool {.borrow.}
+proc `-`*(a, b: Time): Time {.borrow.}
+proc ctime*(a1: var Time): cstring {.importc, header: "<time.h>".}
+proc ctime_r*(a1: var Time, a2: cstring): cstring {.importc, header: "<time.h>".}
+proc difftime*(a1, a2: Time): cdouble {.importc, header: "<time.h>".}
+proc getdate*(a1: cstring): ptr Tm {.importc, header: "<time.h>".}
+proc gmtime*(a1: var Time): ptr Tm {.importc, header: "<time.h>".}
+proc gmtime_r*(a1: var Time, a2: var Tm): ptr Tm {.importc, header: "<time.h>".}
+proc localtime*(a1: var Time): ptr Tm {.importc, header: "<time.h>".}
+proc localtime_r*(a1: var Time, a2: var Tm): ptr Tm {.importc, header: "<time.h>".}
+proc mktime*(a1: var Tm): Time  {.importc, header: "<time.h>".}
+proc timegm*(a1: var Tm): Time  {.importc, header: "<time.h>".}
+proc nanosleep*(a1, a2: var Timespec): cint {.importc, header: "<time.h>", sideEffect.}
 proc strftime*(a1: cstring, a2: int, a3: cstring,
-           a4: var ttm): int {.importc, header: "<time.h>".}
-proc strptime*(a1, a2: cstring, a3: var ttm): cstring {.importc, header: "<time.h>".}
-proc time*(a1: var Ttime): ttime {.importc, header: "<time.h>".}
-proc timer_create*(a1: var Tclockid, a2: var Tsigevent,
-               a3: var Ttimer): cint {.importc, header: "<time.h>".}
-proc timer_delete*(a1: var Ttimer): cint {.importc, header: "<time.h>".}
-proc timer_gettime*(a1: Ttimer, a2: var Titimerspec): cint {.
+           a4: var Tm): int {.importc, header: "<time.h>".}
+proc strptime*(a1, a2: cstring, a3: var Tm): cstring {.importc, header: "<time.h>".}
+proc time*(a1: var Time): Time {.importc, header: "<time.h>", sideEffect.}
+proc timer_create*(a1: ClockId, a2: var SigEvent,
+               a3: var Timer): cint {.importc, header: "<time.h>".}
+proc timer_delete*(a1: Timer): cint {.importc, header: "<time.h>".}
+proc timer_gettime*(a1: Timer, a2: var Itimerspec): cint {.
   importc, header: "<time.h>".}
-proc timer_getoverrun*(a1: Ttimer): cint {.importc, header: "<time.h>".}
-proc timer_settime*(a1: Ttimer, a2: cint, a3: var Titimerspec,
-               a4: var titimerspec): cint {.importc, header: "<time.h>".}
+proc timer_getoverrun*(a1: Timer): cint {.importc, header: "<time.h>".}
+proc timer_settime*(a1: Timer, a2: cint, a3: var Itimerspec,
+               a4: var Itimerspec): cint {.importc, header: "<time.h>".}
 proc tzset*() {.importc, header: "<time.h>".}
 
 
-proc wait*(a1: var cint): tpid {.importc, header: "<sys/wait.h>".}
-proc waitid*(a1: cint, a2: tid, a3: var Tsiginfo, a4: cint): cint {.
-  importc, header: "<sys/wait.h>".}
-proc waitpid*(a1: tpid, a2: var cint, a3: cint): tpid {.
-  importc, header: "<sys/wait.h>".}
+proc wait*(a1: ptr cint): Pid {.importc, discardable, header: "<sys/wait.h>", sideEffect.}
+proc waitid*(a1: cint, a2: Id, a3: var SigInfo, a4: cint): cint {.
+  importc, header: "<sys/wait.h>", sideEffect.}
+proc waitpid*(a1: Pid, a2: var cint, a3: cint): Pid {.
+  importc, header: "<sys/wait.h>", sideEffect.}
+
+type Rusage* {.importc: "struct rusage", header: "<sys/resource.h>",
+               bycopy.} = object
+  ru_utime*, ru_stime*: Timeval                       # User and system time
+  ru_maxrss*, ru_ixrss*, ru_idrss*, ru_isrss*,        # memory sizes
+    ru_minflt*, ru_majflt*, ru_nswap*,                # paging activity
+    ru_inblock*, ru_oublock*, ru_msgsnd*, ru_msgrcv*, # IO activity
+    ru_nsignals*, ru_nvcsw*, ru_nivcsw*: clong        # switching activity
+
+proc wait4*(pid: Pid, status: ptr cint, options: cint, rusage: ptr Rusage): Pid
+  {.importc, header: "<sys/wait.h>", sideEffect.}
+
+const
+  RUSAGE_SELF* = cint(0)
+  RUSAGE_CHILDREN* = cint(-1)
+  RUSAGE_THREAD* = cint(1)    # This one is less std; Linux, BSD agree though.
+
+# This can only fail if `who` is invalid or `rusage` ptr is invalid.
+proc getrusage*(who: cint, rusage: ptr Rusage): cint
+  {.importc, header: "<sys/resource.h>", discardable.}
 
 proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {.
   importc, header: "<signal.h>".}
-proc kill*(a1: Tpid, a2: cint): cint {.importc, header: "<signal.h>".}
-proc killpg*(a1: Tpid, a2: cint): cint {.importc, header: "<signal.h>".}
-proc pthread_kill*(a1: tpthread, a2: cint): cint {.importc, header: "<signal.h>".}
-proc pthread_sigmask*(a1: cint, a2, a3: var Tsigset): cint {.
+proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
+proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
+proc pthread_kill*(a1: Pthread, a2: cint): cint {.importc, header: "<signal.h>".}
+proc pthread_sigmask*(a1: cint, a2, a3: var Sigset): cint {.
   importc, header: "<signal.h>".}
 proc `raise`*(a1: cint): cint {.importc, header: "<signal.h>".}
-proc sigaction*(a1: cint, a2, a3: var Tsigaction): cint {.
+proc sigaction*(a1: cint, a2, a3: var Sigaction): cint {.
+  importc, header: "<signal.h>".}
+
+proc sigaction*(a1: cint, a2: var Sigaction; a3: ptr Sigaction = nil): cint {.
   importc, header: "<signal.h>".}
-proc sigaddset*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".}
-proc sigaltstack*(a1, a2: var Tstack): cint {.importc, header: "<signal.h>".}
-proc sigdelset*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".}
-proc sigemptyset*(a1: var Tsigset): cint {.importc, header: "<signal.h>".}
-proc sigfillset*(a1: var Tsigset): cint {.importc, header: "<signal.h>".}
+
+proc sigaddset*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".}
+proc sigaltstack*(a1, a2: var Stack): cint {.importc, header: "<signal.h>".}
+proc sigdelset*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".}
+proc sigemptyset*(a1: var Sigset): cint {.importc, header: "<signal.h>".}
+proc sigfillset*(a1: var Sigset): cint {.importc, header: "<signal.h>".}
 proc sighold*(a1: cint): cint {.importc, header: "<signal.h>".}
 proc sigignore*(a1: cint): cint {.importc, header: "<signal.h>".}
 proc siginterrupt*(a1, a2: cint): cint {.importc, header: "<signal.h>".}
-proc sigismember*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".}
-proc signal*(a1: cint, a2: proc (x: cint) {.noconv.}) {.
+proc sigismember*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".}
+proc signal*(a1: cint, a2: Sighandler) {.
   importc, header: "<signal.h>".}
 proc sigpause*(a1: cint): cint {.importc, header: "<signal.h>".}
-proc sigpending*(a1: var tsigset): cint {.importc, header: "<signal.h>".}
-proc sigprocmask*(a1: cint, a2, a3: var tsigset): cint {.
+proc sigpending*(a1: var Sigset): cint {.importc, header: "<signal.h>".}
+proc sigprocmask*(a1: cint, a2, a3: var Sigset): cint {.
   importc, header: "<signal.h>".}
-proc sigqueue*(a1: tpid, a2: cint, a3: Tsigval): cint {.
+proc sigqueue*(a1: Pid, a2: cint, a3: SigVal): cint {.
   importc, header: "<signal.h>".}
 proc sigrelse*(a1: cint): cint {.importc, header: "<signal.h>".}
 proc sigset*(a1: int, a2: proc (x: cint) {.noconv.}) {.
   importc, header: "<signal.h>".}
-proc sigsuspend*(a1: var Tsigset): cint {.importc, header: "<signal.h>".}
-proc sigtimedwait*(a1: var Tsigset, a2: var tsiginfo, 
-                   a3: var ttimespec): cint {.importc, header: "<signal.h>".}
-proc sigwait*(a1: var Tsigset, a2: var cint): cint {.
+proc sigsuspend*(a1: var Sigset): cint {.importc, header: "<signal.h>".}
+
+when defined(android):
+  proc syscall(arg: clong): clong {.varargs, importc: "syscall", header: "<unistd.h>".}
+  var NR_rt_sigtimedwait {.importc: "__NR_rt_sigtimedwait", header: "<sys/syscall.h>".}: clong
+  var NSIGMAX {.importc: "NSIG", header: "<signal.h>".}: clong
+
+  proc sigtimedwait*(a1: var Sigset, a2: var SigInfo, a3: var Timespec): cint =
+    result = cint(syscall(NR_rt_sigtimedwait, addr(a1), addr(a2), addr(a3), NSIGMAX div 8))
+else:
+  proc sigtimedwait*(a1: var Sigset, a2: var SigInfo,
+                     a3: var Timespec): cint {.importc, header: "<signal.h>".}
+
+when defined(sunos) or defined(solaris):
+  # The following compile time flag is needed on Illumos/Solaris to use the POSIX
+  # `sigwait` implementation. See the documentation here:
+  # https://docs.oracle.com/cd/E19455-01/806-5257/6je9h033k/index.html
+  # https://www.illumos.org/man/2/sigwait
+  {.passc: "-D_POSIX_PTHREAD_SEMANTICS".}
+
+proc sigwait*(a1: var Sigset, a2: var cint): cint {.
   importc, header: "<signal.h>".}
-proc sigwaitinfo*(a1: var Tsigset, a2: var tsiginfo): cint {.
+proc sigwaitinfo*(a1: var Sigset, a2: var SigInfo): cint {.
   importc, header: "<signal.h>".}
 
-
-proc catclose*(a1: Tnl_catd): cint {.importc, header: "<nl_types.h>".}
-proc catgets*(a1: Tnl_catd, a2, a3: cint, a4: cstring): cstring {.
-  importc, header: "<nl_types.h>".}
-proc catopen*(a1: cstring, a2: cint): Tnl_catd {.
-  importc, header: "<nl_types.h>".}
+when not defined(nintendoswitch):
+  proc catclose*(a1: Nl_catd): cint {.importc, header: "<nl_types.h>".}
+  proc catgets*(a1: Nl_catd, a2, a3: cint, a4: cstring): cstring {.
+    importc, header: "<nl_types.h>".}
+  proc catopen*(a1: cstring, a2: cint): Nl_catd {.
+    importc, header: "<nl_types.h>".}
 
 proc sched_get_priority_max*(a1: cint): cint {.importc, header: "<sched.h>".}
 proc sched_get_priority_min*(a1: cint): cint {.importc, header: "<sched.h>".}
-proc sched_getparam*(a1: tpid, a2: var Tsched_param): cint {.
+proc sched_getparam*(a1: Pid, a2: var Sched_param): cint {.
   importc, header: "<sched.h>".}
-proc sched_getscheduler*(a1: tpid): cint {.importc, header: "<sched.h>".}
-proc sched_rr_get_interval*(a1: tpid, a2: var Ttimespec): cint {.
+proc sched_getscheduler*(a1: Pid): cint {.importc, header: "<sched.h>".}
+proc sched_rr_get_interval*(a1: Pid, a2: var Timespec): cint {.
   importc, header: "<sched.h>".}
-proc sched_setparam*(a1: tpid, a2: var Tsched_param): cint {.
+proc sched_setparam*(a1: Pid, a2: var Sched_param): cint {.
   importc, header: "<sched.h>".}
-proc sched_setscheduler*(a1: tpid, a2: cint, a3: var tsched_param): cint {.
+proc sched_setscheduler*(a1: Pid, a2: cint, a3: var Sched_param): cint {.
   importc, header: "<sched.h>".}
 proc sched_yield*(): cint {.importc, header: "<sched.h>".}
 
-proc strerror*(errnum: cint): cstring {.importc, header: "<string.h>".}
+proc hstrerror*(herrnum: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".}
 
-proc FD_CLR*(a1: cint, a2: var Tfd_set) {.importc, header: "<sys/select.h>".}
-proc FD_ISSET*(a1: cint, a2: var Tfd_set): cint {.
+proc FD_CLR*(a1: cint, a2: var TFdSet) {.importc, header: "<sys/select.h>".}
+proc FD_ISSET*(a1: cint | SocketHandle, a2: var TFdSet): cint {.
   importc, header: "<sys/select.h>".}
-proc FD_SET*(a1: cint, a2: var Tfd_set) {.importc, header: "<sys/select.h>".}
-proc FD_ZERO*(a1: var Tfd_set) {.importc, header: "<sys/select.h>".}
+proc FD_SET*(a1: cint | SocketHandle, a2: var TFdSet) {.
+  importc: "FD_SET", header: "<sys/select.h>".}
+proc FD_ZERO*(a1: var TFdSet) {.importc, header: "<sys/select.h>".}
 
-proc pselect*(a1: cint, a2, a3, a4: ptr Tfd_set, a5: ptr ttimespec,
-         a6: var Tsigset): cint  {.importc, header: "<sys/select.h>".}
-proc select*(a1: cint, a2, a3, a4: ptr Tfd_set, a5: ptr ttimeval): cint {.
+proc pselect*(a1: cint, a2, a3, a4: ptr TFdSet, a5: ptr Timespec,
+         a6: var Sigset): cint  {.importc, header: "<sys/select.h>".}
+proc select*(a1: cint | SocketHandle, a2, a3, a4: ptr TFdSet, a5: ptr Timeval): cint {.
              importc, header: "<sys/select.h>".}
 
 when hasSpawnH:
-  proc posix_spawn*(a1: var tpid, a2: cstring,
+  proc posix_spawn*(a1: var Pid, a2: cstring,
             a3: var Tposix_spawn_file_actions,
-            a4: var Tposix_spawnattr, 
+            a4: var Tposix_spawnattr,
             a5, a6: cstringArray): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawn_file_actions_addclose*(a1: var tposix_spawn_file_actions,
+  proc posix_spawn_file_actions_addclose*(a1: var Tposix_spawn_file_actions,
             a2: cint): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawn_file_actions_adddup2*(a1: var tposix_spawn_file_actions,
+  proc posix_spawn_file_actions_adddup2*(a1: var Tposix_spawn_file_actions,
             a2, a3: cint): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawn_file_actions_addopen*(a1: var tposix_spawn_file_actions,
-            a2: cint, a3: cstring, a4: cint, a5: tmode): cint {.
+  proc posix_spawn_file_actions_addopen*(a1: var Tposix_spawn_file_actions,
+            a2: cint, a3: cstring, a4: cint, a5: Mode): cint {.
             importc, header: "<spawn.h>".}
   proc posix_spawn_file_actions_destroy*(
-    a1: var tposix_spawn_file_actions): cint {.importc, header: "<spawn.h>".}
+    a1: var Tposix_spawn_file_actions): cint {.importc, header: "<spawn.h>".}
   proc posix_spawn_file_actions_init*(
-    a1: var tposix_spawn_file_actions): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_destroy*(a1: var tposix_spawnattr): cint {.
+    a1: var Tposix_spawn_file_actions): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_destroy*(a1: var Tposix_spawnattr): cint {.
     importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getsigdefault*(a1: var tposix_spawnattr,
-            a2: var Tsigset): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getflags*(a1: var tposix_spawnattr,
+  proc posix_spawnattr_getsigdefault*(a1: var Tposix_spawnattr,
+            a2: var Sigset): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_getflags*(a1: var Tposix_spawnattr,
             a2: var cshort): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getpgroup*(a1: var tposix_spawnattr,
-            a2: var tpid): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getschedparam*(a1: var tposix_spawnattr,
-            a2: var tsched_param): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getschedpolicy*(a1: var tposix_spawnattr,
+  proc posix_spawnattr_getpgroup*(a1: var Tposix_spawnattr,
+            a2: var Pid): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_getschedparam*(a1: var Tposix_spawnattr,
+            a2: var Sched_param): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_getschedpolicy*(a1: var Tposix_spawnattr,
             a2: var cint): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_getsigmask*(a1: var tposix_spawnattr,
-            a2: var tsigset): cint {.importc, header: "<spawn.h>".}
-  
-  proc posix_spawnattr_init*(a1: var tposix_spawnattr): cint {.
+  proc posix_spawnattr_getsigmask*(a1: var Tposix_spawnattr,
+            a2: var Sigset): cint {.importc, header: "<spawn.h>".}
+
+  proc posix_spawnattr_init*(a1: var Tposix_spawnattr): cint {.
     importc, header: "<spawn.h>".}
-  proc posix_spawnattr_setsigdefault*(a1: var tposix_spawnattr,
-            a2: var tsigset): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_setflags*(a1: var tposix_spawnattr, a2: cshort): cint {.
+  proc posix_spawnattr_setsigdefault*(a1: var Tposix_spawnattr,
+            a2: var Sigset): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_setflags*(a1: var Tposix_spawnattr, a2: cint): cint {.
     importc, header: "<spawn.h>".}
-  proc posix_spawnattr_setpgroup*(a1: var tposix_spawnattr, a2: tpid): cint {.
+  proc posix_spawnattr_setpgroup*(a1: var Tposix_spawnattr, a2: Pid): cint {.
     importc, header: "<spawn.h>".}
-  
-  proc posix_spawnattr_setschedparam*(a1: var tposix_spawnattr,
-            a2: var tsched_param): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnattr_setschedpolicy*(a1: var tposix_spawnattr, 
+
+  proc posix_spawnattr_setschedparam*(a1: var Tposix_spawnattr,
+            a2: var Sched_param): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnattr_setschedpolicy*(a1: var Tposix_spawnattr,
                                        a2: cint): cint {.
                                        importc, header: "<spawn.h>".}
-  proc posix_spawnattr_setsigmask*(a1: var tposix_spawnattr,
-            a2: var tsigset): cint {.importc, header: "<spawn.h>".}
-  proc posix_spawnp*(a1: var tpid, a2: cstring,
-            a3: var tposix_spawn_file_actions,
-            a4: var tposix_spawnattr,
+  proc posix_spawnattr_setsigmask*(a1: var Tposix_spawnattr,
+            a2: var Sigset): cint {.importc, header: "<spawn.h>".}
+  proc posix_spawnp*(a1: var Pid, a2: cstring,
+            a3: var Tposix_spawn_file_actions,
+            a4: var Tposix_spawnattr,
             a5, a6: cstringArray): cint {.importc, header: "<spawn.h>".}
 
-proc getcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".}
-proc makecontext*(a1: var Tucontext, a4: proc (){.noconv.}, a3: cint) {.
-  varargs, importc, header: "<ucontext.h>".}
-proc setcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".}
-proc swapcontext*(a1, a2: var Tucontext): cint {.importc, header: "<ucontext.h>".}
+when not defined(nintendoswitch):
+  proc getcontext*(a1: var Ucontext): cint {.importc, header: "<ucontext.h>".}
+  proc makecontext*(a1: var Ucontext, a4: proc (){.noconv.}, a3: cint) {.
+    varargs, importc, header: "<ucontext.h>".}
+  proc setcontext*(a1: var Ucontext): cint {.importc, header: "<ucontext.h>".}
+  proc swapcontext*(a1, a2: var Ucontext): cint {.importc, header: "<ucontext.h>".}
 
-proc readv*(a1: cint, a2: ptr TIOVec, a3: cint): int {.
+proc readv*(a1: cint, a2: ptr IOVec, a3: cint): int {.
   importc, header: "<sys/uio.h>".}
-proc writev*(a1: cint, a2: ptr TIOVec, a3: cint): int {.
+proc writev*(a1: cint, a2: ptr IOVec, a3: cint): int {.
   importc, header: "<sys/uio.h>".}
 
 proc CMSG_DATA*(cmsg: ptr Tcmsghdr): cstring {.
   importc, header: "<sys/socket.h>".}
 
-proc CMSG_NXTHDR*(mhdr: ptr TMsgHdr, cmsg: ptr TCMsgHdr): ptr TCmsgHdr {.
+proc CMSG_NXTHDR*(mhdr: ptr Tmsghdr, cmsg: ptr Tcmsghdr): ptr Tcmsghdr {.
   importc, header: "<sys/socket.h>".}
 
-proc CMSG_FIRSTHDR*(mhdr: ptr TMsgHdr): ptr TCMsgHdr {.
+proc CMSG_FIRSTHDR*(mhdr: ptr Tmsghdr): ptr Tcmsghdr {.
   importc, header: "<sys/socket.h>".}
 
-proc accept*(a1: cint, a2: ptr Tsockaddr, a3: ptr Tsocklen): cint {.
+proc CMSG_SPACE*(len: csize_t): csize_t {.
   importc, header: "<sys/socket.h>".}
 
-proc bindSocket*(a1: cint, a2: ptr Tsockaddr, a3: Tsocklen): cint {.
-  importc: "bind", header: "<sys/socket.h>".}
-  ## is Posix's ``bind``, because ``bind`` is a reserved word
-  
-proc connect*(a1: cint, a2: ptr Tsockaddr, a3: Tsocklen): cint {.
-  importc, header: "<sys/socket.h>".}
-proc getpeername*(a1: cint, a2: ptr Tsockaddr, a3: ptr Tsocklen): cint {.
-  importc, header: "<sys/socket.h>".}
-proc getsockname*(a1: cint, a2: ptr Tsockaddr, a3: ptr Tsocklen): cint {.
+proc CMSG_LEN*(len: csize_t): csize_t {.
   importc, header: "<sys/socket.h>".}
 
-proc getsockopt*(a1, a2, a3: cint, a4: pointer, a5: ptr Tsocklen): cint {.
-  importc, header: "<sys/socket.h>".}
+const
+  INVALID_SOCKET* = SocketHandle(-1)
 
-proc listen*(a1, a2: cint): cint {.
-  importc, header: "<sys/socket.h>".}
-proc recv*(a1: cint, a2: pointer, a3: int, a4: cint): int {.
-  importc, header: "<sys/socket.h>".}
-proc recvfrom*(a1: cint, a2: pointer, a3: int, a4: cint,
-        a5: ptr Tsockaddr, a6: ptr Tsocklen): int {.
-  importc, header: "<sys/socket.h>".}
-proc recvmsg*(a1: cint, a2: ptr Tmsghdr, a3: cint): int {.
+proc `==`*(x, y: SocketHandle): bool {.borrow.}
+
+proc accept*(a1: SocketHandle, a2: ptr SockAddr, a3: ptr SockLen): SocketHandle {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+
+when defined(linux) or defined(bsd) or defined(nuttx):
+  proc accept4*(a1: SocketHandle, a2: ptr SockAddr, a3: ptr SockLen,
+                flags: cint): SocketHandle {.importc, header: "<sys/socket.h>".}
+
+proc bindSocket*(a1: SocketHandle, a2: ptr SockAddr, a3: SockLen): cint {.
+  importc: "bind", header: "<sys/socket.h>".}
+  ## is Posix's `bind`, because `bind` is a reserved word
+
+proc connect*(a1: SocketHandle, a2: ptr SockAddr, a3: SockLen): cint {.
   importc, header: "<sys/socket.h>".}
-proc send*(a1: cint, a2: pointer, a3: int, a4: cint): int {.
+proc getpeername*(a1: SocketHandle, a2: ptr SockAddr, a3: ptr SockLen): cint {.
   importc, header: "<sys/socket.h>".}
-proc sendmsg*(a1: cint, a2: ptr Tmsghdr, a3: cint): int {.
+proc getsockname*(a1: SocketHandle, a2: ptr SockAddr, a3: ptr SockLen): cint {.
   importc, header: "<sys/socket.h>".}
-proc sendto*(a1: cint, a2: pointer, a3: int, a4: cint, a5: ptr Tsockaddr,
-             a6: Tsocklen): int {.
+
+proc getsockopt*(a1: SocketHandle, a2, a3: cint, a4: pointer, a5: ptr SockLen): cint {.
   importc, header: "<sys/socket.h>".}
-proc setsockopt*(a1, a2, a3: cint, a4: pointer, a5: Tsocklen): cint {.
+
+proc listen*(a1: SocketHandle, a2: cint): cint {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc recv*(a1: SocketHandle, a2: pointer, a3: int, a4: cint): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc recvfrom*(a1: SocketHandle, a2: pointer, a3: int, a4: cint,
+        a5: ptr SockAddr, a6: ptr SockLen): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc recvmsg*(a1: SocketHandle, a2: ptr Tmsghdr, a3: cint): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc send*(a1: SocketHandle, a2: pointer, a3: int, a4: cint): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc sendmsg*(a1: SocketHandle, a2: ptr Tmsghdr, a3: cint): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc sendto*(a1: SocketHandle, a2: pointer, a3: int, a4: cint, a5: ptr SockAddr,
+             a6: SockLen): int {.
+  importc, header: "<sys/socket.h>", sideEffect.}
+proc setsockopt*(a1: SocketHandle, a2, a3: cint, a4: pointer, a5: SockLen): cint {.
   importc, header: "<sys/socket.h>".}
-proc shutdown*(a1, a2: cint): cint {.
+proc shutdown*(a1: SocketHandle, a2: cint): cint {.
   importc, header: "<sys/socket.h>".}
-proc socket*(a1, a2, a3: cint): cint {.
+proc socket*(a1, a2, a3: cint): SocketHandle {.
   importc, header: "<sys/socket.h>".}
 proc sockatmark*(a1: cint): cint {.
   importc, header: "<sys/socket.h>".}
@@ -2449,40 +1009,46 @@ proc if_indextoname*(a1: cint, a2: cstring): cstring {.
 proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".}
 proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".}
 
-proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Unspecified address.
-proc IN6_IS_ADDR_LOOPBACK* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_LOOPBACK* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Loopback address.
-proc IN6_IS_ADDR_MULTICAST* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MULTICAST* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast address.
-proc IN6_IS_ADDR_LINKLOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_LINKLOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Unicast link-local address.
-proc IN6_IS_ADDR_SITELOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_SITELOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Unicast site-local address.
-proc IN6_IS_ADDR_V4MAPPED* (a1: ptr TIn6Addr): cint {.
-  importc, header: "<netinet/in.h>".}
-  ## IPv4 mapped address.
-proc IN6_IS_ADDR_V4COMPAT* (a1: ptr TIn6Addr): cint {.
+when defined(lwip):
+  proc IN6_IS_ADDR_V4MAPPED*(ipv6_address: ptr In6Addr): cint =
+    var bits32: ptr array[4, uint32] = cast[ptr array[4, uint32]](ipv6_address)
+    return (bits32[1] == 0'u32 and bits32[2] == htonl(0x0000FFFF)).cint
+else:
+  proc IN6_IS_ADDR_V4MAPPED* (a1: ptr In6Addr): cint {.
+    importc, header: "<netinet/in.h>".}
+    ## IPv4 mapped address.
+
+proc IN6_IS_ADDR_V4COMPAT* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## IPv4-compatible address.
-proc IN6_IS_ADDR_MC_NODELOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MC_NODELOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast node-local address.
-proc IN6_IS_ADDR_MC_LINKLOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MC_LINKLOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast link-local address.
-proc IN6_IS_ADDR_MC_SITELOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MC_SITELOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast site-local address.
-proc IN6_IS_ADDR_MC_ORGLOCAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MC_ORGLOCAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast organization-local address.
-proc IN6_IS_ADDR_MC_GLOBAL* (a1: ptr TIn6Addr): cint {.
+proc IN6_IS_ADDR_MC_GLOBAL* (a1: ptr In6Addr): cint {.
   importc, header: "<netinet/in.h>".}
   ## Multicast global address.
 
@@ -2490,44 +1056,121 @@ proc endhostent*() {.importc, header: "<netdb.h>".}
 proc endnetent*() {.importc, header: "<netdb.h>".}
 proc endprotoent*() {.importc, header: "<netdb.h>".}
 proc endservent*() {.importc, header: "<netdb.h>".}
-proc freeaddrinfo*(a1: ptr Taddrinfo) {.importc, header: "<netdb.h>".}
+proc freeAddrInfo*(a1: ptr AddrInfo) {.importc: "freeaddrinfo", header: "<netdb.h>".}
 
-proc gai_strerror*(a1: cint): cstring {.importc, header: "<netdb.h>".}
+proc gai_strerror*(a1: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".}
 
-proc getaddrinfo*(a1, a2: cstring, a3: ptr TAddrInfo, 
-                  a4: var ptr TAddrInfo): cint {.importc, header: "<netdb.h>".}
-                  
-proc gethostbyaddr*(a1: pointer, a2: Tsocklen, a3: cint): ptr THostent {.
-                    importc, header: "<netdb.h>".}
-proc gethostbyname*(a1: cstring): ptr THostent {.importc, header: "<netdb.h>".}
-proc gethostent*(): ptr THostent {.importc, header: "<netdb.h>".}
+proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo,
+                  a4: var ptr AddrInfo): cint {.importc, header: "<netdb.h>".}
 
-proc getnameinfo*(a1: ptr Tsockaddr, a2: Tsocklen,
-                  a3: cstring, a4: Tsocklen, a5: cstring,
-                  a6: Tsocklen, a7: cint): cint {.importc, header: "<netdb.h>".}
+when not defined(android4):
+  proc gethostbyaddr*(a1: pointer, a2: SockLen, a3: cint): ptr Hostent {.
+                      importc, header: "<netdb.h>".}
+else:
+  proc gethostbyaddr*(a1: cstring, a2: cint, a3: cint): ptr Hostent {.
+                      importc, header: "<netdb.h>".}
+proc gethostbyname*(a1: cstring): ptr Hostent {.importc, header: "<netdb.h>".}
+proc gethostent*(): ptr Hostent {.importc, header: "<netdb.h>".}
 
-proc getnetbyaddr*(a1: int32, a2: cint): ptr TNetent {.importc, header: "<netdb.h>".}
-proc getnetbyname*(a1: cstring): ptr TNetent {.importc, header: "<netdb.h>".}
-proc getnetent*(): ptr TNetent {.importc, header: "<netdb.h>".}
+proc getnameinfo*(a1: ptr SockAddr, a2: SockLen,
+                  a3: cstring, a4: SockLen, a5: cstring,
+                  a6: SockLen, a7: cint): cint {.importc, header: "<netdb.h>".}
 
-proc getprotobyname*(a1: cstring): ptr TProtoent {.importc, header: "<netdb.h>".}
-proc getprotobynumber*(a1: cint): ptr TProtoent {.importc, header: "<netdb.h>".}
-proc getprotoent*(): ptr TProtoent {.importc, header: "<netdb.h>".}
+proc getnetbyaddr*(a1: int32, a2: cint): ptr Tnetent {.importc, header: "<netdb.h>".}
+proc getnetbyname*(a1: cstring): ptr Tnetent {.importc, header: "<netdb.h>".}
+proc getnetent*(): ptr Tnetent {.importc, header: "<netdb.h>".}
 
-proc getservbyname*(a1, a2: cstring): ptr TServent {.importc, header: "<netdb.h>".}
-proc getservbyport*(a1: cint, a2: cstring): ptr TServent {.
+proc getprotobyname*(a1: cstring): ptr Protoent {.importc, header: "<netdb.h>".}
+proc getprotobynumber*(a1: cint): ptr Protoent {.importc, header: "<netdb.h>".}
+proc getprotoent*(): ptr Protoent {.importc, header: "<netdb.h>".}
+
+proc getservbyname*(a1, a2: cstring): ptr Servent {.importc, header: "<netdb.h>".}
+proc getservbyport*(a1: cint, a2: cstring): ptr Servent {.
   importc, header: "<netdb.h>".}
-proc getservent*(): ptr TServent {.importc, header: "<netdb.h>".}
+proc getservent*(): ptr Servent {.importc, header: "<netdb.h>".}
 
 proc sethostent*(a1: cint) {.importc, header: "<netdb.h>".}
 proc setnetent*(a1: cint) {.importc, header: "<netdb.h>".}
 proc setprotoent*(a1: cint) {.importc, header: "<netdb.h>".}
 proc setservent*(a1: cint) {.importc, header: "<netdb.h>".}
 
-proc poll*(a1: ptr Tpollfd, a2: Tnfds, a3: int): cint {.
-  importc, header: "<poll.h>".}
+when not defined(lwip):
+  proc poll*(a1: ptr TPollfd, a2: Tnfds, a3: int): cint {.
+    importc, header: "<poll.h>", sideEffect.}
 
-proc realpath*(name, resolved: CString): CString {.
+proc realpath*(name, resolved: cstring): cstring {.
   importc: "realpath", header: "<stdlib.h>".}
 
+proc mkstemp*(tmpl: cstring): cint {.importc, header: "<stdlib.h>", sideEffect.}
+  ## Creates a unique temporary file.
+  ##
+  ## .. warning:: The `tmpl` argument is written to by `mkstemp` and thus
+  ##   can't be a string literal. If in doubt make a copy of the cstring before
+  ##   passing it in.
+
+proc mkstemps*(tmpl: cstring, suffixlen: int): cint {.importc, header: "<stdlib.h>", sideEffect.}
+  ## Creates a unique temporary file.
+  ##
+  ## .. warning:: The `tmpl` argument is written to by `mkstemps` and thus
+  ##   can't be a string literal. If in doubt make a copy of the cstring before
+  ##   passing it in.
+
+proc mkdtemp*(tmpl: cstring): pointer {.importc, header: "<stdlib.h>", sideEffect.}
+
+when defined(linux) or defined(bsd) or defined(osx):
+  proc mkostemp*(tmpl: cstring, oflags: cint): cint {.importc, header: "<stdlib.h>", sideEffect.}
+  proc mkostemps*(tmpl: cstring, suffixlen: cint, oflags: cint): cint {.importc, header: "<stdlib.h>", sideEffect.}
+
+  proc posix_memalign*(memptr: pointer, alignment: csize_t, size: csize_t): cint {.importc, header: "<stdlib.h>".}
+
+proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {.
+  importc: "utimes", header: "<sys/time.h>", sideEffect.}
+  ## Sets file access and modification times.
+  ##
+  ## Pass the filename and an array of times to set the access and modification
+  ## times respectively. If you pass nil as the array both attributes will be
+  ## set to the current time.
+  ##
+  ## Returns zero on success.
+  ##
+  ## For more information read http://www.unix.com/man-page/posix/3/utimes/.
+
+proc handle_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.importc: "signal", header: "<signal.h>".}
+
+template onSignal*(signals: varargs[cint], body: untyped) =
+  ## Setup code to be executed when Unix signals are received. The
+  ## currently handled signal is injected as `sig` into the calling
+  ## scope.
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   from std/posix import SIGINT, SIGTERM, onSignal
+  ##   onSignal(SIGINT, SIGTERM):
+  ##     echo "bye from signal ", sig
+  ##   ```
+
+  for s in signals:
+    handle_signal(s,
+      proc (signal: cint) {.noconv.} =
+        let sig {.inject.} = signal
+        body
+    )
 
+type
+  RLimit* {.importc: "struct rlimit",
+            header: "<sys/resource.h>", pure, final.} = object
+    rlim_cur*: int
+    rlim_max*: int
+  ## The getrlimit() and setrlimit() system calls get and set resource limits respectively.
+  ## Each resource has an associated soft and hard limit, as defined by the RLimit structure
+
+proc setrlimit*(resource: cint, rlp: var RLimit): cint {.
+  importc: "setrlimit", header: "<sys/resource.h>".}
+  ## The setrlimit() system calls sets resource limits.
+
+proc getrlimit*(resource: cint, rlp: var RLimit): cint {.
+  importc: "getrlimit", header: "<sys/resource.h>".}
+  ## The getrlimit() system call gets resource limits.
+
+when defined(nimHasStyleChecks):
+  {.pop.} # {.push styleChecks: off.}
diff --git a/lib/posix/posix_freertos_consts.nim b/lib/posix/posix_freertos_consts.nim
new file mode 100644
index 000000000..0f0fc0aae
--- /dev/null
+++ b/lib/posix/posix_freertos_consts.nim
@@ -0,0 +1,506 @@
+# Generated by detect.nim
+
+
+
+# <errno.h>
+var E2BIG* {.importc: "E2BIG", header: "<errno.h>".}: cint
+var EACCES* {.importc: "EACCES", header: "<errno.h>".}: cint
+var EADDRINUSE* {.importc: "EADDRINUSE", header: "<errno.h>".}: cint
+var EADDRNOTAVAIL* {.importc: "EADDRNOTAVAIL", header: "<errno.h>".}: cint
+var EAFNOSUPPORT* {.importc: "EAFNOSUPPORT", header: "<errno.h>".}: cint
+var EAGAIN* {.importc: "EAGAIN", header: "<errno.h>".}: cint
+var EALREADY* {.importc: "EALREADY", header: "<errno.h>".}: cint
+var EBADF* {.importc: "EBADF", header: "<errno.h>".}: cint
+var EBADMSG* {.importc: "EBADMSG", header: "<errno.h>".}: cint
+var EBUSY* {.importc: "EBUSY", header: "<errno.h>".}: cint
+var ECANCELED* {.importc: "ECANCELED", header: "<errno.h>".}: cint
+var ECHILD* {.importc: "ECHILD", header: "<errno.h>".}: cint
+var ECONNABORTED* {.importc: "ECONNABORTED", header: "<errno.h>".}: cint
+var ECONNREFUSED* {.importc: "ECONNREFUSED", header: "<errno.h>".}: cint
+var ECONNRESET* {.importc: "ECONNRESET", header: "<errno.h>".}: cint
+var EDEADLK* {.importc: "EDEADLK", header: "<errno.h>".}: cint
+var EDESTADDRREQ* {.importc: "EDESTADDRREQ", header: "<errno.h>".}: cint
+var EDOM* {.importc: "EDOM", header: "<errno.h>".}: cint
+var EDQUOT* {.importc: "EDQUOT", header: "<errno.h>".}: cint
+var EEXIST* {.importc: "EEXIST", header: "<errno.h>".}: cint
+var EFAULT* {.importc: "EFAULT", header: "<errno.h>".}: cint
+var EFBIG* {.importc: "EFBIG", header: "<errno.h>".}: cint
+var EHOSTUNREACH* {.importc: "EHOSTUNREACH", header: "<errno.h>".}: cint
+var EIDRM* {.importc: "EIDRM", header: "<errno.h>".}: cint
+var EILSEQ* {.importc: "EILSEQ", header: "<errno.h>".}: cint
+var EINPROGRESS* {.importc: "EINPROGRESS", header: "<errno.h>".}: cint
+var EINTR* {.importc: "EINTR", header: "<errno.h>".}: cint
+var EINVAL* {.importc: "EINVAL", header: "<errno.h>".}: cint
+var EIO* {.importc: "EIO", header: "<errno.h>".}: cint
+var EISCONN* {.importc: "EISCONN", header: "<errno.h>".}: cint
+var EISDIR* {.importc: "EISDIR", header: "<errno.h>".}: cint
+var ELOOP* {.importc: "ELOOP", header: "<errno.h>".}: cint
+var EMFILE* {.importc: "EMFILE", header: "<errno.h>".}: cint
+var EMLINK* {.importc: "EMLINK", header: "<errno.h>".}: cint
+var EMSGSIZE* {.importc: "EMSGSIZE", header: "<errno.h>".}: cint
+var EMULTIHOP* {.importc: "EMULTIHOP", header: "<errno.h>".}: cint
+var ENAMETOOLONG* {.importc: "ENAMETOOLONG", header: "<errno.h>".}: cint
+var ENETDOWN* {.importc: "ENETDOWN", header: "<errno.h>".}: cint
+var ENETRESET* {.importc: "ENETRESET", header: "<errno.h>".}: cint
+var ENETUNREACH* {.importc: "ENETUNREACH", header: "<errno.h>".}: cint
+var ENFILE* {.importc: "ENFILE", header: "<errno.h>".}: cint
+var ENOBUFS* {.importc: "ENOBUFS", header: "<errno.h>".}: cint
+var ENODATA* {.importc: "ENODATA", header: "<errno.h>".}: cint
+var ENODEV* {.importc: "ENODEV", header: "<errno.h>".}: cint
+var ENOENT* {.importc: "ENOENT", header: "<errno.h>".}: cint
+var ENOEXEC* {.importc: "ENOEXEC", header: "<errno.h>".}: cint
+var ENOLCK* {.importc: "ENOLCK", header: "<errno.h>".}: cint
+var ENOLINK* {.importc: "ENOLINK", header: "<errno.h>".}: cint
+var ENOMEM* {.importc: "ENOMEM", header: "<errno.h>".}: cint
+var ENOMSG* {.importc: "ENOMSG", header: "<errno.h>".}: cint
+var ENOPROTOOPT* {.importc: "ENOPROTOOPT", header: "<errno.h>".}: cint
+var ENOSPC* {.importc: "ENOSPC", header: "<errno.h>".}: cint
+var ENOSR* {.importc: "ENOSR", header: "<errno.h>".}: cint
+var ENOSTR* {.importc: "ENOSTR", header: "<errno.h>".}: cint
+var ENOSYS* {.importc: "ENOSYS", header: "<errno.h>".}: cint
+var ENOTCONN* {.importc: "ENOTCONN", header: "<errno.h>".}: cint
+var ENOTDIR* {.importc: "ENOTDIR", header: "<errno.h>".}: cint
+var ENOTEMPTY* {.importc: "ENOTEMPTY", header: "<errno.h>".}: cint
+var ENOTSOCK* {.importc: "ENOTSOCK", header: "<errno.h>".}: cint
+var ENOTSUP* {.importc: "ENOTSUP", header: "<errno.h>".}: cint
+var ENOTTY* {.importc: "ENOTTY", header: "<errno.h>".}: cint
+var ENXIO* {.importc: "ENXIO", header: "<errno.h>".}: cint
+var EOPNOTSUPP* {.importc: "EOPNOTSUPP", header: "<errno.h>".}: cint
+var EOVERFLOW* {.importc: "EOVERFLOW", header: "<errno.h>".}: cint
+var EPERM* {.importc: "EPERM", header: "<errno.h>".}: cint
+var EPIPE* {.importc: "EPIPE", header: "<errno.h>".}: cint
+var EPROTO* {.importc: "EPROTO", header: "<errno.h>".}: cint
+var EPROTONOSUPPORT* {.importc: "EPROTONOSUPPORT", header: "<errno.h>".}: cint
+var EPROTOTYPE* {.importc: "EPROTOTYPE", header: "<errno.h>".}: cint
+var ERANGE* {.importc: "ERANGE", header: "<errno.h>".}: cint
+var EROFS* {.importc: "EROFS", header: "<errno.h>".}: cint
+var ESPIPE* {.importc: "ESPIPE", header: "<errno.h>".}: cint
+var ESRCH* {.importc: "ESRCH", header: "<errno.h>".}: cint
+var ESTALE* {.importc: "ESTALE", header: "<errno.h>".}: cint
+var ETIME* {.importc: "ETIME", header: "<errno.h>".}: cint
+var ETIMEDOUT* {.importc: "ETIMEDOUT", header: "<errno.h>".}: cint
+var ETXTBSY* {.importc: "ETXTBSY", header: "<errno.h>".}: cint
+var EWOULDBLOCK* {.importc: "EWOULDBLOCK", header: "<errno.h>".}: cint
+var EXDEV* {.importc: "EXDEV", header: "<errno.h>".}: cint
+
+# <sys/fcntl.h>
+var F_GETFD* {.importc: "F_GETFD", header: "<sys/fcntl.h>".}: cint
+# var F_SETFD* {.importc: "F_SETFD", header: "<sys/fcntl.h>".}: cint
+var F_GETFL* {.importc: "F_GETFL", header: "<sys/fcntl.h>".}: cint
+var F_SETFL* {.importc: "F_SETFL", header: "<sys/fcntl.h>".}: cint
+# var F_GETLK* {.importc: "F_GETLK", header: "<sys/fcntl.h>".}: cint
+# var F_SETLK* {.importc: "F_SETLK", header: "<sys/fcntl.h>".}: cint
+# var F_SETLKW* {.importc: "F_SETLKW", header: "<sys/fcntl.h>".}: cint
+# var F_GETOWN* {.importc: "F_GETOWN", header: "<sys/fcntl.h>".}: cint
+# var F_SETOWN* {.importc: "F_SETOWN", header: "<sys/fcntl.h>".}: cint
+# var FD_CLOEXEC* {.importc: "FD_CLOEXEC", header: "<sys/fcntl.h>".}: cint
+# var F_RDLCK* {.importc: "F_RDLCK", header: "<sys/fcntl.h>".}: cint
+# var F_UNLCK* {.importc: "F_UNLCK", header: "<sys/fcntl.h>".}: cint
+# var F_WRLCK* {.importc: "F_WRLCK", header: "<sys/fcntl.h>".}: cint
+var O_CREAT* {.importc: "O_CREAT", header: "<sys/fcntl.h>".}: cint
+var O_EXCL* {.importc: "O_EXCL", header: "<sys/fcntl.h>".}: cint
+# var O_NOCTTY* {.importc: "O_NOCTTY", header: "<sys/fcntl.h>".}: cint
+var O_TRUNC* {.importc: "O_TRUNC", header: "<sys/fcntl.h>".}: cint
+var O_APPEND* {.importc: "O_APPEND", header: "<sys/fcntl.h>".}: cint
+# var O_DSYNC* {.importc: "O_DSYNC", header: "<sys/fcntl.h>".}: cint
+var O_NONBLOCK* {.importc: "O_NONBLOCK", header: "<sys/fcntl.h>".}: cint
+# var O_RSYNC* {.importc: "O_RSYNC", header: "<sys/fcntl.h>".}: cint
+# var O_SYNC* {.importc: "O_SYNC", header: "<sys/fcntl.h>".}: cint
+# var O_ACCMODE* {.importc: "O_ACCMODE", header: "<sys/fcntl.h>".}: cint
+var O_RDONLY* {.importc: "O_RDONLY", header: "<sys/fcntl.h>".}: cint
+var O_RDWR* {.importc: "O_RDWR", header: "<sys/fcntl.h>".}: cint
+var O_WRONLY* {.importc: "O_WRONLY", header: "<sys/fcntl.h>".}: cint
+# var O_CLOEXEC* {.importc: "O_CLOEXEC", header: "<sys/fcntl.h>".}: cint
+
+# # <locale.h>
+# var LC_ALL* {.importc: "LC_ALL", header: "<locale.h>".}: cint
+# var LC_COLLATE* {.importc: "LC_COLLATE", header: "<locale.h>".}: cint
+# var LC_CTYPE* {.importc: "LC_CTYPE", header: "<locale.h>".}: cint
+# var LC_MESSAGES* {.importc: "LC_MESSAGES", header: "<locale.h>".}: cint
+# var LC_MONETARY* {.importc: "LC_MONETARY", header: "<locale.h>".}: cint
+# var LC_NUMERIC* {.importc: "LC_NUMERIC", header: "<locale.h>".}: cint
+# var LC_TIME* {.importc: "LC_TIME", header: "<locale.h>".}: cint
+
+# <netdb.h>
+var HOST_NOT_FOUND* {.importc: "HOST_NOT_FOUND", header: "<netdb.h>".}: cint
+var NO_DATA* {.importc: "NO_DATA", header: "<netdb.h>".}: cint
+var NO_RECOVERY* {.importc: "NO_RECOVERY", header: "<netdb.h>".}: cint
+var TRY_AGAIN* {.importc: "TRY_AGAIN", header: "<netdb.h>".}: cint
+var AI_PASSIVE* {.importc: "AI_PASSIVE", header: "<netdb.h>".}: cint
+var AI_CANONNAME* {.importc: "AI_CANONNAME", header: "<netdb.h>".}: cint
+var AI_NUMERICHOST* {.importc: "AI_NUMERICHOST", header: "<netdb.h>".}: cint
+var AI_NUMERICSERV* {.importc: "AI_NUMERICSERV", header: "<netdb.h>".}: cint
+var AI_V4MAPPED* {.importc: "AI_V4MAPPED", header: "<netdb.h>".}: cint
+var AI_ALL* {.importc: "AI_ALL", header: "<netdb.h>".}: cint
+var AI_ADDRCONFIG* {.importc: "AI_ADDRCONFIG", header: "<netdb.h>".}: cint
+var NI_NOFQDN* {.importc: "NI_NOFQDN", header: "<netdb.h>".}: cint
+var NI_NUMERICHOST* {.importc: "NI_NUMERICHOST", header: "<netdb.h>".}: cint
+var NI_NAMEREQD* {.importc: "NI_NAMEREQD", header: "<netdb.h>".}: cint
+var NI_NUMERICSERV* {.importc: "NI_NUMERICSERV", header: "<netdb.h>".}: cint
+var NI_DGRAM* {.importc: "NI_DGRAM", header: "<netdb.h>".}: cint
+var EAI_AGAIN* {.importc: "EAI_AGAIN", header: "<netdb.h>".}: cint
+var EAI_BADFLAGS* {.importc: "EAI_BADFLAGS", header: "<netdb.h>".}: cint
+var EAI_FAIL* {.importc: "EAI_FAIL", header: "<netdb.h>".}: cint
+var EAI_FAMILY* {.importc: "EAI_FAMILY", header: "<netdb.h>".}: cint
+var EAI_MEMORY* {.importc: "EAI_MEMORY", header: "<netdb.h>".}: cint
+var EAI_NONAME* {.importc: "EAI_NONAME", header: "<netdb.h>".}: cint
+var EAI_SERVICE* {.importc: "EAI_SERVICE", header: "<netdb.h>".}: cint
+var EAI_SOCKTYPE* {.importc: "EAI_SOCKTYPE", header: "<netdb.h>".}: cint
+
+var LWIP_DNS_API_DECLARE_H_ERRNO* {.importc: "LWIP_DNS_API_DECLARE_H_ERRNO", header: "<netdb.h>".}: cint
+var LWIP_DNS_API_DEFINE_ERRORS* {.importc: "LWIP_DNS_API_DEFINE_ERRORS", header: "<netdb.h>".}: cint
+var LWIP_DNS_API_DEFINE_FLAGS* {.importc: "LWIP_DNS_API_DEFINE_FLAGS", header: "<netdb.h>".}: cint
+var LWIP_DNS_API_DECLARE_STRUCTS* {.importc: "LWIP_DNS_API_DECLARE_STRUCTS", header: "<netdb.h>".}: cint
+var NETDB_ELEM_SIZE* {.importc: "NETDB_ELEM_SIZE", header: "<netdb.h>".}: cint
+
+
+# <netif.h>
+var ENABLE_LOOPBACK* {.importc: "ENABLE_LOOPBACK", header: "<netif.h>".}: cint
+var NETIF_MAX_HWADDR_LEN* {.importc: "NETIF_MAX_HWADDR_LEN", header: "<netif.h>".}: cint
+var NETIF_NAMESIZE* {.importc: "NETIF_NAMESIZE", header: "<netif.h>".}: cint
+var NETIF_FLAG_UP* {.importc: "NETIF_FLAG_UP", header: "<netif.h>".}: cint
+var NETIF_FLAG_BROADCAST* {.importc: "NETIF_FLAG_BROADCAST", header: "<netif.h>".}: cint
+var NETIF_FLAG_LINK_UP* {.importc: "NETIF_FLAG_LINK_UP", header: "<netif.h>".}: cint
+var NETIF_FLAG_ETHARP* {.importc: "NETIF_FLAG_ETHARP", header: "<netif.h>".}: cint
+var NETIF_FLAG_ETHERNET* {.importc: "NETIF_FLAG_ETHERNET", header: "<netif.h>".}: cint
+var NETIF_FLAG_IGMP* {.importc: "NETIF_FLAG_IGMP", header: "<netif.h>".}: cint
+var NETIF_FLAG_MLD6* {.importc: "NETIF_FLAG_MLD6", header: "<netif.h>".}: cint
+var NETIF_FLAG_GARP* {.importc: "NETIF_FLAG_GARP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_GEN_IP* {.importc: "NETIF_CHECKSUM_GEN_IP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_GEN_UDP* {.importc: "NETIF_CHECKSUM_GEN_UDP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_GEN_TCP* {.importc: "NETIF_CHECKSUM_GEN_TCP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_GEN_ICMP* {.importc: "NETIF_CHECKSUM_GEN_ICMP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_GEN_ICMP6* {.importc: "NETIF_CHECKSUM_GEN_ICMP6", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_CHECK_IP* {.importc: "NETIF_CHECKSUM_CHECK_IP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_CHECK_UDP* {.importc: "NETIF_CHECKSUM_CHECK_UDP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_CHECK_TCP* {.importc: "NETIF_CHECKSUM_CHECK_TCP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_CHECK_ICMP* {.importc: "NETIF_CHECKSUM_CHECK_ICMP", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_CHECK_ICMP6* {.importc: "NETIF_CHECKSUM_CHECK_ICMP6", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_ENABLE_ALL* {.importc: "NETIF_CHECKSUM_ENABLE_ALL", header: "<netif.h>".}: cint
+var NETIF_CHECKSUM_DISABLE_ALL* {.importc: "NETIF_CHECKSUM_DISABLE_ALL", header: "<netif.h>".}: cint
+var NETIF_ADDR_IDX_MAX* {.importc: "NETIF_ADDR_IDX_MAX", header: "<netif.h>".}: cint
+var LWIP_NETIF_USE_HINTS* {.importc: "LWIP_NETIF_USE_HINTS", header: "<netif.h>".}: cint
+var NETIF_NO_INDEX* {.importc: "NETIF_NO_INDEX", header: "<netif.h>".}: cint
+var LWIP_NSC_NONE* {.importc: "LWIP_NSC_NONE", header: "<netif.h>".}: cint
+var LWIP_NSC_NETIF_ADDED* {.importc: "LWIP_NSC_NETIF_ADDED", header: "<netif.h>".}: cint
+var LWIP_NSC_NETIF_REMOVED* {.importc: "LWIP_NSC_NETIF_REMOVED", header: "<netif.h>".}: cint
+var LWIP_NSC_LINK_CHANGED* {.importc: "LWIP_NSC_LINK_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_STATUS_CHANGED* {.importc: "LWIP_NSC_STATUS_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV4_ADDRESS_CHANGED* {.importc: "LWIP_NSC_IPV4_ADDRESS_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV4_GATEWAY_CHANGED* {.importc: "LWIP_NSC_IPV4_GATEWAY_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV4_NETMASK_CHANGED* {.importc: "LWIP_NSC_IPV4_NETMASK_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV4_SETTINGS_CHANGED* {.importc: "LWIP_NSC_IPV4_SETTINGS_CHANGED", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV6_SET* {.importc: "LWIP_NSC_IPV6_SET", header: "<netif.h>".}: cint
+var LWIP_NSC_IPV6_ADDR_STATE_CHANGED* {.importc: "LWIP_NSC_IPV6_ADDR_STATE_CHANGED", header: "<netif.h>".}: cint
+#define NETIF_DECLARE_EXT_CALLBACK(name)
+
+
+# <net/if.h>
+var IF_NAMESIZE* {.importc: "IF_NAMESIZE", header: "<net/if.h>".}: cint
+
+# <sys/socket.h>
+var IPPROTO_IP* {.importc: "IPPROTO_IP", header: "<sys/socket.h>".}: cint
+var IPPROTO_IPV6* {.importc: "IPPROTO_IPV6", header: "<sys/socket.h>".}: cint
+var IPPROTO_ICMP* {.importc: "IPPROTO_ICMP", header: "<sys/socket.h>".}: cint
+var IPPROTO_ICMPV6* {.importc: "IPPROTO_ICMPV6", header: "<sys/socket.h>".}: cint
+var IPPROTO_RAW* {.importc: "IPPROTO_RAW", header: "<sys/socket.h>".}: cint
+var IPPROTO_TCP* {.importc: "IPPROTO_TCP", header: "<sys/socket.h>".}: cint
+var IPPROTO_UDP* {.importc: "IPPROTO_UDP", header: "<sys/socket.h>".}: cint
+var INADDR_ANY* {.importc: "INADDR_ANY", header: "<sys/socket.h>".}: InAddrScalar
+var INADDR_LOOPBACK* {.importc: "INADDR_LOOPBACK", header: "<sys/socket.h>".}: InAddrScalar
+var INADDR_BROADCAST* {.importc: "INADDR_BROADCAST", header: "<sys/socket.h>".}: InAddrScalar
+var INET_ADDRSTRLEN* {.importc: "INET_ADDRSTRLEN", header: "<sys/socket.h>".}: cint
+var INET6_ADDRSTRLEN* {.importc: "INET6_ADDRSTRLEN", header: "<sys/socket.h>".}: cint
+var IPV6_JOIN_GROUP* {.importc: "IPV6_JOIN_GROUP", header: "<sys/socket.h>".}: cint
+var IPV6_LEAVE_GROUP* {.importc: "IPV6_LEAVE_GROUP", header: "<sys/socket.h>".}: cint
+var IPV6_MULTICAST_HOPS* {.importc: "IPV6_MULTICAST_HOPS", header: "<sys/socket.h>".}: cint
+var IPV6_MULTICAST_IF* {.importc: "IPV6_MULTICAST_IF", header: "<sys/socket.h>".}: cint
+var IPV6_MULTICAST_LOOP* {.importc: "IPV6_MULTICAST_LOOP", header: "<sys/socket.h>".}: cint
+var IPV6_UNICAST_HOPS* {.importc: "IPV6_UNICAST_HOPS", header: "<sys/socket.h>".}: cint
+var IPV6_V6ONLY* {.importc: "IPV6_V6ONLY", header: "<sys/socket.h>".}: cint
+
+# <netinet/tcp.h>
+const TCP_NODELAY*    = 0x01    # don't delay send to coalesce packets
+const TCP_KEEPALIVE*  = 0x02    # send KEEPALIVE probes when idle for pcb->keep_idle milliseconds
+const TCP_KEEPIDLE*   = 0x03    # set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt
+const TCP_KEEPINTVL*  = 0x04    # set pcb->keep_intvl - Use seconds for get/setsockopt
+const TCP_KEEPCNT*    = 0x05    # set pcb->keep_cnt   - Use number of probes sent for get/setsockopt
+
+# <nl_types.h>
+# var NL_SETD* {.importc: "NL_SETD", header: "<nl_types.h>".}: cint
+# var NL_CAT_LOCALE* {.importc: "NL_CAT_LOCALE", header: "<nl_types.h>".}: cint
+
+# <sys/poll.h>
+# var POLLIN* {.importc: "POLLIN", header: "<sys/poll.h>".}: cshort
+# var POLLRDNORM* {.importc: "POLLRDNORM", header: "<sys/poll.h>".}: cshort
+# var POLLRDBAND* {.importc: "POLLRDBAND", header: "<sys/poll.h>".}: cshort
+# var POLLPRI* {.importc: "POLLPRI", header: "<sys/poll.h>".}: cshort
+# var POLLOUT* {.importc: "POLLOUT", header: "<sys/poll.h>".}: cshort
+# var POLLWRNORM* {.importc: "POLLWRNORM", header: "<sys/poll.h>".}: cshort
+# var POLLWRBAND* {.importc: "POLLWRBAND", header: "<sys/poll.h>".}: cshort
+# var POLLERR* {.importc: "POLLERR", header: "<sys/poll.h>".}: cshort
+# var POLLHUP* {.importc: "POLLHUP", header: "<sys/poll.h>".}: cshort
+# var POLLNVAL* {.importc: "POLLNVAL", header: "<sys/poll.h>".}: cshort
+
+# <pthread.h>
+var PTHREAD_STACK_MIN* {.importc: "PTHREAD_STACK_MIN", header: "<pthread.h>".}: cint
+# var PTHREAD_BARRIER_SERIAL_THREAD* {.importc: "PTHREAD_BARRIER_SERIAL_THREAD", header: "<pthread.h>".}: cint
+# var PTHREAD_CANCEL_ASYNCHRONOUS* {.importc: "PTHREAD_CANCEL_ASYNCHRONOUS", header: "<pthread.h>".}: cint
+# var PTHREAD_CANCEL_ENABLE* {.importc: "PTHREAD_CANCEL_ENABLE", header: "<pthread.h>".}: cint
+# var PTHREAD_CANCEL_DEFERRED* {.importc: "PTHREAD_CANCEL_DEFERRED", header: "<pthread.h>".}: cint
+# var PTHREAD_CANCEL_DISABLE* {.importc: "PTHREAD_CANCEL_DISABLE", header: "<pthread.h>".}: cint
+# var PTHREAD_CREATE_DETACHED* {.importc: "PTHREAD_CREATE_DETACHED", header: "<pthread.h>".}: cint
+# var PTHREAD_CREATE_JOINABLE* {.importc: "PTHREAD_CREATE_JOINABLE", header: "<pthread.h>".}: cint
+# var PTHREAD_EXPLICIT_SCHED* {.importc: "PTHREAD_EXPLICIT_SCHED", header: "<pthread.h>".}: cint
+# var PTHREAD_INHERIT_SCHED* {.importc: "PTHREAD_INHERIT_SCHED", header: "<pthread.h>".}: cint
+# var PTHREAD_MUTEX_DEFAULT* {.importc: "PTHREAD_MUTEX_DEFAULT", header: "<pthread.h>".}: cint
+# var PTHREAD_MUTEX_ERRORCHECK* {.importc: "PTHREAD_MUTEX_ERRORCHECK", header: "<pthread.h>".}: cint
+# var PTHREAD_MUTEX_NORMAL* {.importc: "PTHREAD_MUTEX_NORMAL", header: "<pthread.h>".}: cint
+# var PTHREAD_MUTEX_RECURSIVE* {.importc: "PTHREAD_MUTEX_RECURSIVE", header: "<pthread.h>".}: cint
+# var PTHREAD_PRIO_INHERIT* {.importc: "PTHREAD_PRIO_INHERIT", header: "<pthread.h>".}: cint
+# var PTHREAD_PRIO_NONE* {.importc: "PTHREAD_PRIO_NONE", header: "<pthread.h>".}: cint
+# var PTHREAD_PRIO_PROTECT* {.importc: "PTHREAD_PRIO_PROTECT", header: "<pthread.h>".}: cint
+# var PTHREAD_PROCESS_SHARED* {.importc: "PTHREAD_PROCESS_SHARED", header: "<pthread.h>".}: cint
+# var PTHREAD_PROCESS_PRIVATE* {.importc: "PTHREAD_PROCESS_PRIVATE", header: "<pthread.h>".}: cint
+# var PTHREAD_SCOPE_PROCESS* {.importc: "PTHREAD_SCOPE_PROCESS", header: "<pthread.h>".}: cint
+# var PTHREAD_SCOPE_SYSTEM* {.importc: "PTHREAD_SCOPE_SYSTEM", header: "<pthread.h>".}: cint
+
+# # <sched.h>
+# var SCHED_FIFO* {.importc: "SCHED_FIFO", header: "<sched.h>".}: cint
+# var SCHED_RR* {.importc: "SCHED_RR", header: "<sched.h>".}: cint
+# var SCHED_SPORADIC* {.importc: "SCHED_SPORADIC", header: "<sched.h>".}: cint
+# var SCHED_OTHER* {.importc: "SCHED_OTHER", header: "<sched.h>".}: cint
+
+# <semaphore.h>
+var SEM_FAILED* {.importc: "SEM_FAILED", header: "<semaphore.h>".}: pointer
+
+# # <signal.h>
+# var SIGEV_NONE* {.importc: "SIGEV_NONE", header: "<signal.h>".}: cint
+# var SIGEV_SIGNAL* {.importc: "SIGEV_SIGNAL", header: "<signal.h>".}: cint
+# var SIGEV_THREAD* {.importc: "SIGEV_THREAD", header: "<signal.h>".}: cint
+# var SIGABRT* {.importc: "SIGABRT", header: "<signal.h>".}: cint
+# var SIGALRM* {.importc: "SIGALRM", header: "<signal.h>".}: cint
+# var SIGBUS* {.importc: "SIGBUS", header: "<signal.h>".}: cint
+# var SIGCHLD* {.importc: "SIGCHLD", header: "<signal.h>".}: cint
+# var SIGCONT* {.importc: "SIGCONT", header: "<signal.h>".}: cint
+# var SIGFPE* {.importc: "SIGFPE", header: "<signal.h>".}: cint
+# var SIGHUP* {.importc: "SIGHUP", header: "<signal.h>".}: cint
+# var SIGILL* {.importc: "SIGILL", header: "<signal.h>".}: cint
+# var SIGINT* {.importc: "SIGINT", header: "<signal.h>".}: cint
+# var SIGKILL* {.importc: "SIGKILL", header: "<signal.h>".}: cint
+# var SIGPIPE* {.importc: "SIGPIPE", header: "<signal.h>".}: cint
+# var SIGQUIT* {.importc: "SIGQUIT", header: "<signal.h>".}: cint
+# var SIGSEGV* {.importc: "SIGSEGV", header: "<signal.h>".}: cint
+# var SIGSTOP* {.importc: "SIGSTOP", header: "<signal.h>".}: cint
+# var SIGTERM* {.importc: "SIGTERM", header: "<signal.h>".}: cint
+# var SIGTSTP* {.importc: "SIGTSTP", header: "<signal.h>".}: cint
+# var SIGTTIN* {.importc: "SIGTTIN", header: "<signal.h>".}: cint
+# var SIGTTOU* {.importc: "SIGTTOU", header: "<signal.h>".}: cint
+# var SIGUSR1* {.importc: "SIGUSR1", header: "<signal.h>".}: cint
+# var SIGUSR2* {.importc: "SIGUSR2", header: "<signal.h>".}: cint
+# var SIGPOLL* {.importc: "SIGPOLL", header: "<signal.h>".}: cint
+# var SIGPROF* {.importc: "SIGPROF", header: "<signal.h>".}: cint
+# var SIGSYS* {.importc: "SIGSYS", header: "<signal.h>".}: cint
+# var SIGTRAP* {.importc: "SIGTRAP", header: "<signal.h>".}: cint
+# var SIGURG* {.importc: "SIGURG", header: "<signal.h>".}: cint
+# var SIGVTALRM* {.importc: "SIGVTALRM", header: "<signal.h>".}: cint
+# var SIGXCPU* {.importc: "SIGXCPU", header: "<signal.h>".}: cint
+# var SIGXFSZ* {.importc: "SIGXFSZ", header: "<signal.h>".}: cint
+# var SA_NOCLDSTOP* {.importc: "SA_NOCLDSTOP", header: "<signal.h>".}: cint
+# var SIG_BLOCK* {.importc: "SIG_BLOCK", header: "<signal.h>".}: cint
+# var SIG_UNBLOCK* {.importc: "SIG_UNBLOCK", header: "<signal.h>".}: cint
+# var SIG_SETMASK* {.importc: "SIG_SETMASK", header: "<signal.h>".}: cint
+# var SA_ONSTACK* {.importc: "SA_ONSTACK", header: "<signal.h>".}: cint
+# var SA_RESETHAND* {.importc: "SA_RESETHAND", header: "<signal.h>".}: cint
+# var SA_RESTART* {.importc: "SA_RESTART", header: "<signal.h>".}: cint
+# var SA_SIGINFO* {.importc: "SA_SIGINFO", header: "<signal.h>".}: cint
+# var SA_NOCLDWAIT* {.importc: "SA_NOCLDWAIT", header: "<signal.h>".}: cint
+# var SA_NODEFER* {.importc: "SA_NODEFER", header: "<signal.h>".}: cint
+# var SS_ONSTACK* {.importc: "SS_ONSTACK", header: "<signal.h>".}: cint
+# var SS_DISABLE* {.importc: "SS_DISABLE", header: "<signal.h>".}: cint
+# var MINSIGSTKSZ* {.importc: "MINSIGSTKSZ", header: "<signal.h>".}: cint
+# var SIGSTKSZ* {.importc: "SIGSTKSZ", header: "<signal.h>".}: cint
+# var SIG_HOLD* {.importc: "SIG_HOLD", header: "<signal.h>".}: Sighandler
+# var SIG_DFL* {.importc: "SIG_DFL", header: "<signal.h>".}: Sighandler
+# var SIG_ERR* {.importc: "SIG_ERR", header: "<signal.h>".}: Sighandler
+# var SIG_IGN* {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler
+
+# # <sys/ipc.h>
+# var IPC_CREAT* {.importc: "IPC_CREAT", header: "<sys/ipc.h>".}: cint
+# var IPC_EXCL* {.importc: "IPC_EXCL", header: "<sys/ipc.h>".}: cint
+# var IPC_NOWAIT* {.importc: "IPC_NOWAIT", header: "<sys/ipc.h>".}: cint
+# var IPC_PRIVATE* {.importc: "IPC_PRIVATE", header: "<sys/ipc.h>".}: cint
+# var IPC_RMID* {.importc: "IPC_RMID", header: "<sys/ipc.h>".}: cint
+# var IPC_SET* {.importc: "IPC_SET", header: "<sys/ipc.h>".}: cint
+# var IPC_STAT* {.importc: "IPC_STAT", header: "<sys/ipc.h>".}: cint
+
+# # <sys/mman.h>
+# var PROT_READ* {.importc: "PROT_READ", header: "<sys/mman.h>".}: cint
+# var PROT_WRITE* {.importc: "PROT_WRITE", header: "<sys/mman.h>".}: cint
+# var PROT_EXEC* {.importc: "PROT_EXEC", header: "<sys/mman.h>".}: cint
+# var PROT_NONE* {.importc: "PROT_NONE", header: "<sys/mman.h>".}: cint
+# var MAP_ANONYMOUS* {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
+# var MAP_FIXED_NOREPLACE* {.importc: "MAP_FIXED_NOREPLACE", header: "<sys/mman.h>".}: cint
+# var MAP_NORESERVE* {.importc: "MAP_NORESERVE", header: "<sys/mman.h>".}: cint
+# var MAP_SHARED* {.importc: "MAP_SHARED", header: "<sys/mman.h>".}: cint
+# var MAP_PRIVATE* {.importc: "MAP_PRIVATE", header: "<sys/mman.h>".}: cint
+# var MAP_FIXED* {.importc: "MAP_FIXED", header: "<sys/mman.h>".}: cint
+# var MS_ASYNC* {.importc: "MS_ASYNC", header: "<sys/mman.h>".}: cint
+# var MS_SYNC* {.importc: "MS_SYNC", header: "<sys/mman.h>".}: cint
+# var MS_INVALIDATE* {.importc: "MS_INVALIDATE", header: "<sys/mman.h>".}: cint
+# var MCL_CURRENT* {.importc: "MCL_CURRENT", header: "<sys/mman.h>".}: cint
+# var MCL_FUTURE* {.importc: "MCL_FUTURE", header: "<sys/mman.h>".}: cint
+# var MAP_FAILED* {.importc: "MAP_FAILED", header: "<sys/mman.h>".}: pointer
+# var POSIX_MADV_NORMAL* {.importc: "POSIX_MADV_NORMAL", header: "<sys/mman.h>".}: cint
+# var POSIX_MADV_SEQUENTIAL* {.importc: "POSIX_MADV_SEQUENTIAL", header: "<sys/mman.h>".}: cint
+# var POSIX_MADV_RANDOM* {.importc: "POSIX_MADV_RANDOM", header: "<sys/mman.h>".}: cint
+# var POSIX_MADV_WILLNEED* {.importc: "POSIX_MADV_WILLNEED", header: "<sys/mman.h>".}: cint
+# var POSIX_MADV_DONTNEED* {.importc: "POSIX_MADV_DONTNEED", header: "<sys/mman.h>".}: cint
+# var POSIX_TYPED_MEM_ALLOCATE* {.importc: "POSIX_TYPED_MEM_ALLOCATE", header: "<sys/mman.h>".}: cint
+# var POSIX_TYPED_MEM_ALLOCATE_CONTIG* {.importc: "POSIX_TYPED_MEM_ALLOCATE_CONTIG", header: "<sys/mman.h>".}: cint
+# var POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc: "POSIX_TYPED_MEM_MAP_ALLOCATABLE", header: "<sys/mman.h>".}: cint
+
+# <sys/resource.h>
+# var RLIMIT_NOFILE* {.importc: "RLIMIT_NOFILE", header: "<sys/resource.h>".}: cint
+
+var FD_MAX* {.importc: "CONFIG_LWIP_MAX_SOCKETS", header: "<lwipopts.h>".}: cint
+
+# <sys/select.h>
+var FD_SETSIZE* {.importc: "FD_SETSIZE", header: "<sys/select.h>".}: cint
+
+# <sys/socket.h>
+# struct msghdr->msg_flags bit field values 
+const MSG_TRUNC*   = 0x04
+const MSG_CTRUNC*  = 0x08
+
+# Flags we can use with send and recv.
+const MSG_PEEK*       = 0x01    # Peeks at an incoming message
+const MSG_WAITALL*    = 0x02    # Unimplemented: Requests that the function block until the full amount of data requested can be returned
+const MSG_OOB*        = 0x04    # Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific
+const MSG_DONTWAIT*   = 0x08    # Nonblocking i/o for this operation only
+const MSG_MORE*       = 0x10    # Sender will send more
+# const MSG_NOSIGNAL*   = 0x20    # Uninmplemented: Requests not to send the SIGPIPE signal if an attempt to send is made on a stream-oriented socket that is no longer connected.
+
+# Alternately, they can defined like this, but the above seems better when they're known/stable values:
+# var MSG_TRUNC* {.importc: "MSG_TRUNC", header: "<sys/socket.h>".}: cint
+# var MSG_CTRUNC* {.importc: "MSG_CTRUNC", header: "<sys/socket.h>".}: cint
+# var MSG_DONTROUTE* {.importc: "MSG_DONTROUTE", header: "<sys/socket.h>".}: cint # not defined in lwip
+# var MSG_EOR* {.importc: "MSG_EOR", header: "<sys/socket.h>".}: cint # not defined in lwip
+# var MSG_OOB* {.importc: "MSG_OOB", header: "<sys/socket.h>".}: cint
+
+
+# var SCM_RIGHTS* {.importc: "SCM_RIGHTS", header: "<sys/socket.h>".}: cint
+var SO_ACCEPTCONN* {.importc: "SO_ACCEPTCONN", header: "<sys/socket.h>".}: cint
+var SO_BROADCAST* {.importc: "SO_BROADCAST", header: "<sys/socket.h>".}: cint
+var SO_DEBUG* {.importc: "SO_DEBUG", header: "<sys/socket.h>".}: cint
+var SO_DONTROUTE* {.importc: "SO_DONTROUTE", header: "<sys/socket.h>".}: cint
+var SO_ERROR* {.importc: "SO_ERROR", header: "<sys/socket.h>".}: cint
+var SO_KEEPALIVE* {.importc: "SO_KEEPALIVE", header: "<sys/socket.h>".}: cint
+var SO_LINGER* {.importc: "SO_LINGER", header: "<sys/socket.h>".}: cint
+var SO_OOBINLINE* {.importc: "SO_OOBINLINE", header: "<sys/socket.h>".}: cint
+var SO_RCVBUF* {.importc: "SO_RCVBUF", header: "<sys/socket.h>".}: cint
+var SO_RCVLOWAT* {.importc: "SO_RCVLOWAT", header: "<sys/socket.h>".}: cint
+var SO_RCVTIMEO* {.importc: "SO_RCVTIMEO", header: "<sys/socket.h>".}: cint
+var SO_REUSEADDR* {.importc: "SO_REUSEADDR", header: "<sys/socket.h>".}: cint
+var SO_SNDBUF* {.importc: "SO_SNDBUF", header: "<sys/socket.h>".}: cint
+var SO_SNDLOWAT* {.importc: "SO_SNDLOWAT", header: "<sys/socket.h>".}: cint
+var SO_SNDTIMEO* {.importc: "SO_SNDTIMEO", header: "<sys/socket.h>".}: cint
+var SO_TYPE* {.importc: "SO_TYPE", header: "<sys/socket.h>".}: cint
+var SOCK_DGRAM* {.importc: "SOCK_DGRAM", header: "<sys/socket.h>".}: cint
+var SOCK_RAW* {.importc: "SOCK_RAW", header: "<sys/socket.h>".}: cint
+
+# var SOCK_SEQPACKET* {.importc: "SOCK_SEQPACKET", header: "<sys/socket.h>".}: cint
+const SOCK_SEQPACKET* = cint(5)
+
+var SOCK_STREAM* {.importc: "SOCK_STREAM", header: "<sys/socket.h>".}: cint
+var SOL_SOCKET* {.importc: "SOL_SOCKET", header: "<sys/socket.h>".}: cint
+
+const SocketMaxConnections {.intdefine.}: int = 32
+var SOMAXCONN*: cint = SocketMaxConnections.cint
+
+var AF_INET* {.importc: "AF_INET", header: "<sys/socket.h>".}: cint
+var AF_INET6* {.importc: "AF_INET6", header: "<sys/socket.h>".}: cint
+# var AF_UNIX* {.importc: "AF_UNIX", header: "<sys/socket.h>".}: cint
+const AF_UNIX*: cint = 1 # for compat with Nim libraries, doesn't exist on freertos
+var AF_UNSPEC* {.importc: "AF_UNSPEC", header: "<sys/socket.h>".}: cint
+var SHUT_RD* {.importc: "SHUT_RD", header: "<sys/socket.h>".}: cint
+var SHUT_RDWR* {.importc: "SHUT_RDWR", header: "<sys/socket.h>".}: cint
+var SHUT_WR* {.importc: "SHUT_WR", header: "<sys/socket.h>".}: cint
+
+# # <sys/stat.h>
+# <sys/stat.h>
+
+# var S_IFBLK* {.importc: "S_IFBLK", header: "<sys/stat.h>".}: cint
+# var S_IFCHR* {.importc: "S_IFCHR", header: "<sys/stat.h>".}: cint
+# var S_IFDIR* {.importc: "S_IFDIR", header: "<sys/stat.h>".}: cint
+# var S_IFIFO* {.importc: "S_IFIFO", header: "<sys/stat.h>".}: cint
+# var S_IFLNK* {.importc: "S_IFLNK", header: "<sys/stat.h>".}: cint
+# var S_IFMT* {.importc: "S_IFMT", header: "<sys/stat.h>".}: cint
+# var S_IFREG* {.importc: "S_IFREG", header: "<sys/stat.h>".}: cint
+# var S_IFSOCK* {.importc: "S_IFSOCK", header: "<sys/stat.h>".}: cint
+var S_IRGRP* {.importc: "S_IRGRP", header: "<sys/stat.h>".}: cint
+var S_IROTH* {.importc: "S_IROTH", header: "<sys/stat.h>".}: cint
+var S_IRUSR* {.importc: "S_IRUSR", header: "<sys/stat.h>".}: cint
+# var S_IRWXG* {.importc: "S_IRWXG", header: "<sys/stat.h>".}: cint
+# var S_IRWXO* {.importc: "S_IRWXO", header: "<sys/stat.h>".}: cint
+# var S_IRWXU* {.importc: "S_IRWXU", header: "<sys/stat.h>".}: cint
+# var S_ISGID* {.importc: "S_ISGID", header: "<sys/stat.h>".}: cint
+# var S_ISUID* {.importc: "S_ISUID", header: "<sys/stat.h>".}: cint
+# var S_ISVTX* {.importc: "S_ISVTX", header: "<sys/stat.h>".}: cint
+var S_IWGRP* {.importc: "S_IWGRP", header: "<sys/stat.h>".}: cint
+var S_IWOTH* {.importc: "S_IWOTH", header: "<sys/stat.h>".}: cint
+var S_IWUSR* {.importc: "S_IWUSR", header: "<sys/stat.h>".}: cint
+var S_IXGRP* {.importc: "S_IXGRP", header: "<sys/stat.h>".}: cint
+var S_IXOTH* {.importc: "S_IXOTH", header: "<sys/stat.h>".}: cint
+var S_IXUSR* {.importc: "S_IXUSR", header: "<sys/stat.h>".}: cint
+
+# # <sys/statvfs.h>
+# var ST_RDONLY* {.importc: "ST_RDONLY", header: "<sys/statvfs.h>".}: cint
+# var ST_NOSUID* {.importc: "ST_NOSUID", header: "<sys/statvfs.h>".}: cint
+
+# # <sys/wait.h>
+# var WNOHANG* {.importc: "WNOHANG", header: "<sys/wait.h>".}: cint
+# var WUNTRACED* {.importc: "WUNTRACED", header: "<sys/wait.h>".}: cint
+# var WEXITED* {.importc: "WEXITED", header: "<sys/wait.h>".}: cint
+# var WSTOPPED* {.importc: "WSTOPPED", header: "<sys/wait.h>".}: cint
+# var WCONTINUED* {.importc: "WCONTINUED", header: "<sys/wait.h>".}: cint
+# var WNOWAIT* {.importc: "WNOWAIT", header: "<sys/wait.h>".}: cint
+# var P_ALL* {.importc: "P_ALL", header: "<sys/wait.h>".}: cint
+# var P_PID* {.importc: "P_PID", header: "<sys/wait.h>".}: cint
+# var P_PGID* {.importc: "P_PGID", header: "<sys/wait.h>".}: cint
+
+# # <spawn.h>
+# var POSIX_SPAWN_RESETIDS* {.importc: "POSIX_SPAWN_RESETIDS", header: "<spawn.h>".}: cint
+# var POSIX_SPAWN_SETPGROUP* {.importc: "POSIX_SPAWN_SETPGROUP", header: "<spawn.h>".}: cint
+# var POSIX_SPAWN_SETSCHEDPARAM* {.importc: "POSIX_SPAWN_SETSCHEDPARAM", header: "<spawn.h>".}: cint
+# var POSIX_SPAWN_SETSCHEDULER* {.importc: "POSIX_SPAWN_SETSCHEDULER", header: "<spawn.h>".}: cint
+# var POSIX_SPAWN_SETSIGDEF* {.importc: "POSIX_SPAWN_SETSIGDEF", header: "<spawn.h>".}: cint
+# var POSIX_SPAWN_SETSIGMASK* {.importc: "POSIX_SPAWN_SETSIGMASK", header: "<spawn.h>".}: cint
+
+## <stdio.h>
+# var IOFBF* {.importc: "_IOFBF", header: "<stdio.h>".}: cint
+# var IONBF* {.importc: "_IONBF", header: "<stdio.h>".}: cint
+
+# <time.h>
+var CLOCKS_PER_SEC* {.importc: "CLOCKS_PER_SEC", header: "<time.h>".}: clong
+var CLOCK_PROCESS_CPUTIME_ID* {.importc: "CLOCK_PROCESS_CPUTIME_ID", header: "<time.h>".}: cint
+var CLOCK_THREAD_CPUTIME_ID* {.importc: "CLOCK_THREAD_CPUTIME_ID", header: "<time.h>".}: cint
+var CLOCK_REALTIME* {.importc: "CLOCK_REALTIME", header: "<time.h>".}: cint
+var TIMER_ABSTIME* {.importc: "TIMER_ABSTIME", header: "<time.h>".}: cint
+var CLOCK_MONOTONIC* {.importc: "CLOCK_MONOTONIC", header: "<time.h>".}: cint
+
+# <unistd.h>
+
+const F_OK* = cint(0)
+const R_OK* = cint(4)
+const W_OK* = cint(2)
+const X_OK* = cint(1)
+const F_LOCK* = cint(1)
+const F_TEST* = cint(3)
+const F_TLOCK* = cint(2)
+const F_ULOCK* = cint(0)
+
+# <stdio.h>
+const SEEK_SET* = cint(0)
+const SEEK_CUR* = cint(1)
+const SEEK_END* = cint(2)
diff --git a/lib/posix/posix_haiku.nim b/lib/posix/posix_haiku.nim
new file mode 100644
index 000000000..32a6d24e2
--- /dev/null
+++ b/lib/posix/posix_haiku.nim
@@ -0,0 +1,603 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+const
+  hasSpawnH = true # should exist for every Posix system nowadays
+  hasAioH = defined(linux)
+
+when defined(linux) and not defined(android):
+  # On Linux:
+  # timer_{create,delete,settime,gettime},
+  # clock_{getcpuclockid, getres, gettime, nanosleep, settime} lives in librt
+  {.passl: "-lrt".}
+when defined(solaris):
+  # On Solaris hstrerror lives in libresolv
+  {.passl: "-lresolv".}
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+    ## A type representing a directory stream.
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct (
+    when defined(i386):
+      int32
+    else:
+      int64
+  )
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: int  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+             header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    when defined(haiku):
+      d_dev*: Dev ## Device (not POSIX)
+      d_pdev*: Dev ## Parent device (only for queries) (not POSIX)
+    d_ino*: Ino  ## File serial number.
+    when defined(dragonfly):
+      # DragonflyBSD doesn't have `d_reclen` field.
+      d_type*: uint8
+    elif defined(linux) or defined(macosx) or defined(freebsd) or
+         defined(netbsd) or defined(openbsd) or defined(genode):
+      d_reclen*: cshort ## Length of this record. (not POSIX)
+      d_type*: int8 ## Type of file; not supported by all filesystem types.
+                    ## (not POSIX)
+      when defined(linux) or defined(openbsd):
+        d_off*: Off  ## Not an offset. Value that `telldir()` would return.
+    elif defined(haiku):
+      d_pino*: Ino ## Parent inode (only for queries) (not POSIX)
+      d_reclen*: cushort ## Length of this record. (not POSIX)
+
+    when not defined(haiku):
+      d_name*: array[0..255, char] ## Name of entry.
+    else:
+      d_name*: UncheckedArray[char] ## Name of entry (NUL terminated).
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
+    base*: cint
+    level*: cint
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: int          ## Count of paths matched by pattern.
+    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
+    gl_offs*: int           ## Slots to reserve at the beginning of gl_pathv.
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} =
+    object ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    currency_symbol*: cstring
+    decimal_point*: cstring
+    frac_digits*: char
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    int_frac_digits*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_p_sign_posn*: char
+    mon_decimal_point*: cstring
+    mon_grouping*: cstring
+    mon_thousands_sep*: cstring
+    negative_sign*: cstring
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    n_sign_posn*: char
+    positive_sign*: cstring
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    p_sign_posn*: char
+    thousands_sep*: cstring
+
+  Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
+  MqAttr* {.importc: "struct mq_attr",
+             header: "<mqueue.h>",
+             final, pure.} = object ## message queue attribute
+    mq_flags*: int   ## Message queue flags.
+    mq_maxmsg*: int  ## Maximum number of messages.
+    mq_msgsize*: int ## Maximum message size.
+    mq_curmsgs*: int ## Number of messages currently queued.
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int64
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int32
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<time.h>".} = int32
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int32
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int32
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int64
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int64
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = int32
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int64
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = int32
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
+    when defined(android) or defined(macos) or defined(macosx) or
+        (defined(bsd) and not defined(openbsd) and not defined(netbsd)):
+      uint16
+    else:
+      uint32
+  )
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int32
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = object
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<sys/types.h>".} = object
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<sys/types.h>".} = object
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = object
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<sys/types.h>".} = object
+  Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = object
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = object
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<sys/types.h>".} = object
+  Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = object
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<sys/types.h>".} = object
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<sys/types.h>".} = object
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<sys/types.h>".} = object
+  Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = object
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int32
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = object
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = uint32
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,        ## Name of this implementation of the operating system.
+      nodename*,     ## Name of this node within the communications
+                     ## network to which this node is attached, if any.
+      release*,      ## Current release level of this implementation.
+      version*,      ## Current version level of this release.
+      machine*: array[32, char] ## Name of the hardware type on which the
+                                ## system is running.
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+  Ipc_perm* {.importc: "struct ipc_perm",
+               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
+    uid*: Uid    ## Owner's user ID.
+    gid*: Gid    ## Owner's group ID.
+    cuid*: Uid   ## Creator's user ID.
+    cgid*: Gid   ## Creator's group ID.
+    mode*: Mode  ## Read/write permission.
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                          ## For symbolic links, the length in bytes of the
+                          ## pathname contained in the symbolic link.
+                          ## For a shared memory object, the length in bytes.
+                          ## For a typed memory object, the length in bytes.
+                          ## For other file types, the use of this field is
+                          ## unspecified.
+    when StatHasNanoseconds:
+      st_atim*: Timespec  ## Time of last access.
+      st_mtim*: Timespec  ## Time of last data modification.
+      st_ctim*: Timespec  ## Time of last status change.
+    else:
+      st_atime*: Time     ## Time of last access.
+      st_mtime*: Time     ## Time of last data modification.
+      st_ctime*: Time     ## Time of last status change.
+    st_blksize*: Blksize  ## A file system-specific preferred I/O block size
+                          ## for this object. In some file system types, this
+                          ## may vary from file to file.
+    st_blocks*: Blkcnt    ## Number of blocks allocated for this object.
+
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: culong        ## File system block size.
+    f_frsize*: culong       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt     ## Total number of blocks on file system
+                            ## in units of f_frsize.
+    f_bfree*: Fsblkcnt      ## Total number of free blocks.
+    f_bavail*: Fsblkcnt     ## Number of free blocks available to
+                            ## non-privileged process.
+    f_files*: Fsfilcnt      ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt      ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt     ## Number of file serial numbers available to
+                            ## non-privileged process.
+    f_fsid*: culong         ## File system ID.
+    f_flag*: culong         ## Bit mask of f_flag values.
+    f_namemax*: culong      ## Maximum filename length.
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>".} = uint64
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_notify*: cint           ## Notification type.
+    sigev_signo*: cint            ## Signal number.
+    sigev_value*: SigVal          ## Signal value.
+    sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
+    sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_ptr*: pointer ## pointer signal value;
+                        ## integer signal value not defined!
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+    sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_size*: csize_t ## Stack size.
+    ss_flags*: cint  ## Flags.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_code*: cint     ## Signal code.
+    si_errno*: cint    ## If non-zero, an errno value associated with
+                       ## this signal, as defined in <errno.h>.
+    si_pid*: Pid       ## Sending process ID.
+    si_uid*: Uid       ## Real user ID of sending process.
+    si_addr*: pointer  ## Address of faulting instruction.
+    si_status*: cint   ## Exit value or signal.
+    si_band*: int      ## Band event for SIGPOLL.
+    si_value*: SigVal  ## Signal value.
+
+  Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
+  Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+  Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
+               final, pure.} = object
+  Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
+               final, pure.} = object ## ucontext_t
+    uc_link*: ptr Ucontext  ## Pointer to the context that is resumed
+                            ## when this context returns.
+    uc_sigmask*: Sigset     ## The set of signals that are blocked when this
+                            ## context is active.
+    uc_stack*: Stack        ## The stack used by this context.
+    uc_mcontext*: Mcontext  ## A machine-specific representation of the saved
+                            ## context.
+
+when hasAioH:
+  type
+    Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+              final, pure.} = object ## struct aiocb
+      aio_fildes*: cint         ## File descriptor.
+      aio_offset*: Off          ## File offset.
+      aio_buf*: pointer         ## Location of buffer.
+      aio_nbytes*: int          ## Length of transfer.
+      aio_reqprio*: cint        ## Request priority offset.
+      aio_sigevent*: SigEvent   ## Signal number and value.
+      aio_lio_opcode: cint      ## Operation to be performed.
+
+when hasSpawnH:
+  type
+    Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                        header: "<spawn.h>", final, pure.} = object
+    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                                 header: "<spawn.h>", final, pure.} = object
+
+when defined(linux):
+  # from sys/un.h
+  const Sockaddr_un_path_length* = 108
+elif defined(haiku):
+  # from sys/un.h
+  const Sockaddr_un_path_length* = 126
+else:
+  # according to http://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/un.h.html
+  # this is >=92
+  const Sockaddr_un_path_length* = 92
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = uint32
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = uint8
+
+  SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+              pure, final.} = object ## struct sockaddr
+    sa_family*: TSa_Family         ## Address family.
+    sa_data*: array[0..255, char] ## Socket address (variable-length data).
+
+  Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
+              pure, final.} = object ## struct sockaddr_un
+    sun_family*: TSa_Family         ## Address family.
+    sun_path*: array[0..Sockaddr_un_path_length-1, char] ## Socket path
+
+  Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                       header: "<sys/socket.h>",
+                       pure, final.} = object ## struct sockaddr_storage
+    ss_family*: TSa_Family ## Address family.
+
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cuint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/uio.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t  ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer     ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: cint      ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: SockLen ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: SockLen ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: int32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: int32    ## Set of interfaces for a scope.
+
+  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
+                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
+    ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
+    ipv6mr_interface*: cuint     ## Interface index.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: InAddrT          ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  TPollfd* {.importc: "struct pollfd", pure, final,
+             header: "<poll.h>".} = object ## struct pollfd
+    fd*: cint        ## The following descriptor being polled.
+    events*: cshort  ## The input event flags (see below).
+    revents*: cshort ## The output event flags (see below).
+
+  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = culong
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc, header: "<time.h>".}: cint
+  timezone* {.importc, header: "<time.h>".}: int
+
+# Regenerate using detect.nim!
+include posix_other_consts
+
+when defined(linux):
+  var
+    MAP_POPULATE* {.importc, header: "<sys/mman.h>".}: cint
+      ## Populate (prefault) page tables for a mapping.
+else:
+  var
+    MAP_POPULATE*: cint = 0
+
+when defined(linux) or defined(nimdoc):
+  when defined(alpha) or defined(mips) or defined(mipsel) or
+      defined(mips64) or defined(mips64el) or defined(parisc) or
+      defined(sparc) or defined(sparc64) or defined(nimdoc):
+    const SO_REUSEPORT* = cint(0x0200)
+      ## Multiple binding: load balancing on incoming TCP connections
+      ## or UDP packets. (Requires Linux kernel > 3.9)
+  else:
+    const SO_REUSEPORT* = cint(15)
+else:
+  var SO_REUSEPORT* {.importc, header: "<sys/socket.h>".}: cint
+
+when defined(macosx):
+  # We can't use the NOSIGNAL flag in the `send` function, it has no effect
+  # Instead we should use SO_NOSIGPIPE in setsockopt
+  const
+    MSG_NOSIGNAL* = 0'i32
+  var
+    SO_NOSIGPIPE* {.importc, header: "<sys/socket.h>".}: cint
+elif defined(solaris):
+  # Solaris doesn't have MSG_NOSIGNAL
+  const
+    MSG_NOSIGNAL* = 0'i32
+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.
+
+when defined(haiku):
+  const
+    SIGKILLTHR* = 21 ## BeOS specific: Kill just the thread, not team
+
+when hasSpawnH:
+  when defined(linux):
+    # better be safe than sorry; Linux has this flag, macosx doesn't, don't
+    # know about the other OSes
+
+    # Non-GNU systems like TCC and musl-libc  don't define __USE_GNU, so we
+    # can't get the magic number from spawn.h
+    const POSIX_SPAWN_USEVFORK* = cint(0x40)
+  else:
+    # macosx lacks this, so we define the constant to be 0 to not affect
+    # OR'ing of flags:
+    const POSIX_SPAWN_USEVFORK* = cint(0)
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Exit code, if WIFEXITED(s)
+proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Termination signal, if WIFSIGNALED(s)
+proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Stop signal, if WIFSTOPPED(s)
+proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited normally.
+proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited due to uncaught signal.
+proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child is currently stopped.
+proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child has been continued.
+
+when defined(nimHasStyleChecks):
+  {.pop.}
diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim
new file mode 100644
index 000000000..8d11c507d
--- /dev/null
+++ b/lib/posix/posix_linux_amd64.nim
@@ -0,0 +1,587 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Types here should conform to the glibc ABI on linux / x86_64
+# When adding a type, the order and size of fields must match
+
+# To be included from posix.nim!
+
+const
+  hasSpawnH = not defined(haiku) # should exist for every Posix system nowadays
+  hasAioH = defined(linux)
+
+# On Linux:
+# timer_{create,delete,settime,gettime},
+# clock_{getcpuclockid, getres, gettime, nanosleep, settime} lives in librt
+{.passl: "-lrt".}
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+# Types
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+    ## A type representing a directory stream.
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
+
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: clong  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+            header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    d_ino*: Ino
+    d_off*: Off
+    d_reclen*: cushort
+    d_type*: int8  # uint8 really!
+    d_name*: array[256, cchar]
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  # no struct FTW on linux
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: csize_t            ## Count of paths matched by pattern.
+    gl_pathv*: cstringArray       ## Pointer to a list of matched pathnames.
+    gl_offs*: csize_t             ## Slots to reserve at the beginning of gl_pathv.
+    gl_flags*: cint
+    gl_closedir*: pointer
+    gl_readdir*: pointer
+    gl_opendir*: pointer
+    gl_lstat*: pointer
+    gl_stat*: pointer
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_passwd*: cstring
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>".} = pointer
+     ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    decimal_point*: cstring
+    thousands_sep*: cstring
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    currency_symbol*: cstring
+    mon_decimal_point*: cstring
+    mon_thousands_sep*: cstring
+    mon_grouping*: cstring
+    positive_sign*: cstring
+    negative_sign*: cstring
+    int_frac_digits*: char
+    frac_digits*: char
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    p_sign_posn*: char
+    n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_p_sign_posn*: char
+    int_n_sign_posn*: char
+
+  Mqd* {.importc: "mqd_t", header: "<mqueue.h>".} = cint
+  MqAttr* {.importc: "struct mq_attr",
+             header: "<mqueue.h>",
+             final, pure.} = object ## message queue attribute
+    mq_flags*: clong   ## Message queue flags.
+    mq_maxmsg*: clong  ## Maximum number of messages.
+    mq_msgsize*: clong ## Maximum message size.
+    mq_curmsgs*: clong ## Number of messages currently queued.
+    pad: array[4, clong]
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_passwd*: cstring
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_gecos*: cstring
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = clong
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = clong
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<sys/types.h>".} = clong
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = cint
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = culong
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = culong
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = culong
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = cuint
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>",
+                  pure, final.} = object
+    abi: array[56 div sizeof(clong), clong]
+
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<sys/types.h>", pure, final.} = object
+    abi: array[32 div sizeof(clong), clong]
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>",
+                  pure, final.} = object
+    abi: array[48 div sizeof(clonglong), clonglong]
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+  Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = cuint
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>",
+                   pure, final.} = object
+    abi: array[40 div sizeof(clong), clong]
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+  Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = cint
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<sys/types.h>", pure, final.} = object
+    abi: array[56 div sizeof(clong), clong]
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<sys/types.h>".} = object
+    abi: array[8 div sizeof(clong), clong]
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<sys/types.h>".} = cint
+  Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = culong
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = clong
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = pointer
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = cuint
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = cuint
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,      ## Name of this implementation of the operating system.
+      nodename*,   ## Name of this node within the communications
+                   ## network to which this node is attached, if any.
+      release*,    ## Current release level of this implementation.
+      version*,    ## Current version level of this release.
+      machine*,    ## Name of the hardware type on which the
+                   ## system is running.
+      domainname*: array[65, char]
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+    abi: array[32 div sizeof(clong), clong]
+
+  Ipc_perm* {.importc: "struct ipc_perm",
+               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
+    key: Key
+    uid*: Uid    ## Owner's user ID.
+    gid*: Gid    ## Owner's group ID.
+    cuid*: Uid   ## Creator's user ID.
+    cgid*: Gid   ## Creator's group ID.
+    mode*: cshort  ## Read/write permission.
+    pad1: cshort
+    seq1: cshort
+    pad2: cshort
+    reserved1: culong
+    reserved2: culong
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    pad0 {.importc: "__pad0".}: cint
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                           ## For symbolic links, the length in bytes of the
+                           ## pathname contained in the symbolic link.
+                           ## For a shared memory object, the length in bytes.
+                           ## For a typed memory object, the length in bytes.
+                           ## For other file types, the use of this field is
+                           ## unspecified.
+    st_blksize*: Blksize   ## A file system-specific preferred I/O block size
+                           ## for this object. In some file system types, this
+                           ## may vary from file to file.
+    st_blocks*: Blkcnt     ## Number of blocks allocated for this object.
+    st_atim*: Timespec   ## Time of last access.
+    st_mtim*: Timespec   ## Time of last data modification.
+    st_ctim*: Timespec   ## Time of last status change.
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: culong        ## File system block size.
+    f_frsize*: culong       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt  ## Total number of blocks on file system
+                         ## in units of f_frsize.
+    f_bfree*: Fsblkcnt   ## Total number of free blocks.
+    f_bavail*: Fsblkcnt  ## Number of free blocks available to
+                         ## non-privileged process.
+    f_files*: Fsfilcnt   ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt   ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt  ## Number of file serial numbers available to
+                         ## non-privileged process.
+    f_fsid*: culong         ## File system ID.
+    f_flag*: culong         ## Bit mask of f_flag values.
+    f_namemax*: culong      ## Maximum filename length.
+    f_spare: array[6, cint]
+
+  # No Posix_typed_mem_info
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+    tm_gmtoff*: clong
+    tm_zone*: cstring
+
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
+    abi: array[1024 div (8 * sizeof(culong)), culong]
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_value*: SigVal          ## Signal value.
+    sigev_signo*: cint            ## Signal number.
+    sigev_notify*: cint           ## Notification type.
+    sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
+    sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
+    abi: array[12, int]
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_ptr*: pointer ## pointer signal value;
+                        ## integer signal value not defined!
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+    sa_restorer: proc() {.noconv.}   ## not intended for application use.
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_size*: int    ## Stack size.
+    ss_flags*: cint  ## Flags.
+
+  SigStack* {.importc: "struct sigstack",
+               header: "<signal.h>", final, pure.} = object ## struct sigstack
+    ss_onstack*: cint ## Non-zero when signal stack is in use.
+    ss_sp*: pointer   ## Signal stack pointer.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_errno*: cint    ## If non-zero, an errno value associated with
+                       ## this signal, as defined in <errno.h>.
+    si_code*: cint     ## Signal code.
+    si_pid*: Pid       ## Sending process ID.
+    si_uid*: Uid       ## Real user ID of sending process.
+    si_addr*: pointer  ## Address of faulting instruction.
+    si_status*: cint   ## Exit value or signal.
+    si_band*: int      ## Band event for SIGPOLL.
+    si_value*: SigVal  ## Signal value.
+    pad {.importc: "_pad".}: array[128 - 56, uint8]
+
+template sa_sigaction*(v: Sigaction): proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.} =
+  cast[proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}](v.sa_handler)
+proc `sa_sigaction=`*(v: var Sigaction, x: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}) =
+  v.sa_handler = cast[proc (x: cint) {.noconv.}](x)
+
+type
+  Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
+  Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = pointer
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time       ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+    abi: array[1024 div (8 * sizeof(clong)), clong]
+
+  Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
+               final, pure.} = object
+    gregs: array[23, clonglong]
+    fpregs: pointer
+    reserved1: array[8, clonglong]
+
+  Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
+               final, pure.} = object ## ucontext_t
+    uc_flags: clong
+    uc_link*: ptr Ucontext  ## Pointer to the context that is resumed
+                            ## when this context returns.
+    uc_stack*: Stack        ## The stack used by this context.
+    uc_mcontext*: Mcontext  ## A machine-specific representation of the saved
+                            ## context.
+    uc_sigmask*: Sigset     ## The set of signals that are blocked when this
+                            ## context is active.
+    # todo fpregds_mem
+
+type
+  Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+            final, pure.} = object ## struct aiocb
+    aio_fildes*: cint         ## File descriptor.
+    aio_lio_opcode*: cint     ## Operation to be performed.
+    aio_reqprio*: cint        ## Request priority offset.
+    aio_buf*: pointer         ## Location of buffer.
+    aio_nbytes*: csize_t        ## Length of transfer.
+    aio_sigevent*: SigEvent   ## Signal number and value.
+    next_prio: pointer
+    abs_prio: cint
+    policy: cint
+    error_Code: cint
+    return_value: clong
+    aio_offset*: Off          ## File offset.
+    reserved: array[32, uint8]
+
+
+when hasSpawnH:
+  type
+    Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                        header: "<spawn.h>", final, pure.} = object
+      flags: cshort
+      pgrp: Pid
+      sd: Sigset
+      ss: Sigset
+      sp: Sched_param
+      policy: cint
+      pad: array[16, cint]
+
+    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                                 header: "<spawn.h>", final, pure.} = object
+      allocated: cint
+      used: cint
+      actions: pointer
+      pad: array[16, cint]
+
+# from sys/un.h
+const Sockaddr_un_path_length* = 108
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cushort
+
+  SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+              pure, final.} = object ## struct sockaddr
+    sa_family*: TSa_Family         ## Address family.
+    sa_data*: array[14, char] ## Socket address (variable-length data).
+
+  Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
+              pure, final.} = object ## struct sockaddr_un
+    sun_family*: TSa_Family         ## Address family.
+    sun_path*: array[108, char] ## Socket path
+
+  Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                       header: "<sys/socket.h>",
+                       pure, final.} = object ## struct sockaddr_storage
+    ss_family*: TSa_Family ## Address family.
+    ss_padding {.importc: "__ss_padding".}: array[128 - sizeof(cshort) - sizeof(culong), char]
+    ss_align {.importc: "__ss_align".}: clong
+
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cuint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/uio.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t    ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer  ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: csize_t   ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: csize_t ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: csize_t ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+    # data follows...
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+    sin_zero: array[16 - 2 - 2 - 4, uint8]
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: uint32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: uint32    ## Set of interfaces for a scope.
+
+  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
+                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
+    ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
+    ipv6mr_interface*: cuint     ## Interface index.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: uint32            ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  TPollfd* {.importc: "struct pollfd", pure, final,
+             header: "<poll.h>".} = object ## struct pollfd
+    fd*: cint        ## The following descriptor being polled.
+    events*: cshort  ## The input event flags (see below).
+    revents*: cshort ## The output event flags (see below).
+
+  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = culong
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc, header: "<time.h>".}: cint
+  timezone* {.importc, header: "<time.h>".}: clong
+
+# Regenerate using detect.nim!
+include posix_linux_amd64_consts
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint =  (s and 0xff00) shr 8
+proc WTERMSIG*(s:cint): cint = s and 0x7f
+proc WSTOPSIG*(s:cint): cint = WEXITSTATUS(s)
+proc WIFEXITED*(s:cint) : bool = WTERMSIG(s) == 0
+proc WIFSIGNALED*(s:cint) : bool = (cast[int8]((s and 0x7f) + 1) shr 1) > 0
+proc WIFSTOPPED*(s:cint) : bool = (s and 0xff) == 0x7f
+proc WIFCONTINUED*(s:cint) : bool = s == WCONTINUED
+
+when defined(nimHasStyleChecks):
+  {.pop.} # {.push styleChecks: off.}
diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim
new file mode 100644
index 000000000..fbe8d0666
--- /dev/null
+++ b/lib/posix/posix_linux_amd64_consts.nim
@@ -0,0 +1,730 @@
+# Generated by detect.nim
+
+
+# <aio.h>
+const AIO_ALLDONE* = cint(2)
+const AIO_CANCELED* = cint(0)
+const AIO_NOTCANCELED* = cint(1)
+const LIO_NOP* = cint(2)
+const LIO_NOWAIT* = cint(1)
+const LIO_READ* = cint(0)
+const LIO_WAIT* = cint(0)
+const LIO_WRITE* = cint(1)
+
+# <dlfcn.h>
+const RTLD_LAZY* = cint(1)
+const RTLD_NOW* = cint(2)
+const RTLD_GLOBAL* = cint(256)
+const RTLD_LOCAL* = cint(0)
+
+# <errno.h>
+const E2BIG* = cint(7)
+const EACCES* = cint(13)
+const EADDRINUSE* = cint(98)
+const EADDRNOTAVAIL* = cint(99)
+const EAFNOSUPPORT* = cint(97)
+const EAGAIN* = cint(11)
+const EALREADY* = cint(114)
+const EBADF* = cint(9)
+const EBADMSG* = cint(74)
+const EBUSY* = cint(16)
+const ECANCELED* = cint(125)
+const ECHILD* = cint(10)
+const ECONNABORTED* = cint(103)
+const ECONNREFUSED* = cint(111)
+const ECONNRESET* = cint(104)
+const EDEADLK* = cint(35)
+const EDESTADDRREQ* = cint(89)
+const EDOM* = cint(33)
+const EDQUOT* = cint(122)
+const EEXIST* = cint(17)
+const EFAULT* = cint(14)
+const EFBIG* = cint(27)
+const EHOSTUNREACH* = cint(113)
+const EIDRM* = cint(43)
+const EILSEQ* = cint(84)
+const EINPROGRESS* = cint(115)
+const EINTR* = cint(4)
+const EINVAL* = cint(22)
+const EIO* = cint(5)
+const EISCONN* = cint(106)
+const EISDIR* = cint(21)
+const ELOOP* = cint(40)
+const EMFILE* = cint(24)
+const EMLINK* = cint(31)
+const EMSGSIZE* = cint(90)
+const EMULTIHOP* = cint(72)
+const ENAMETOOLONG* = cint(36)
+const ENETDOWN* = cint(100)
+const ENETRESET* = cint(102)
+const ENETUNREACH* = cint(101)
+const ENFILE* = cint(23)
+const ENOBUFS* = cint(105)
+const ENODATA* = cint(61)
+const ENODEV* = cint(19)
+const ENOENT* = cint(2)
+const ENOEXEC* = cint(8)
+const ENOLCK* = cint(37)
+const ENOLINK* = cint(67)
+const ENOMEM* = cint(12)
+const ENOMSG* = cint(42)
+const ENOPROTOOPT* = cint(92)
+const ENOSPC* = cint(28)
+const ENOSR* = cint(63)
+const ENOSTR* = cint(60)
+const ENOSYS* = cint(38)
+const ENOTCONN* = cint(107)
+const ENOTDIR* = cint(20)
+const ENOTEMPTY* = cint(39)
+const ENOTSOCK* = cint(88)
+const ENOTSUP* = cint(95)
+const ENOTTY* = cint(25)
+const ENXIO* = cint(6)
+const EOPNOTSUPP* = cint(95)
+const EOVERFLOW* = cint(75)
+const EPERM* = cint(1)
+const EPIPE* = cint(32)
+const EPROTO* = cint(71)
+const EPROTONOSUPPORT* = cint(93)
+const EPROTOTYPE* = cint(91)
+const ERANGE* = cint(34)
+const EROFS* = cint(30)
+const ESPIPE* = cint(29)
+const ESRCH* = cint(3)
+const ESTALE* = cint(116)
+const ETIME* = cint(62)
+const ETIMEDOUT* = cint(110)
+const ETXTBSY* = cint(26)
+const EWOULDBLOCK* = cint(11)
+const EXDEV* = cint(18)
+
+# <fcntl.h>
+const F_DUPFD* = cint(0)
+const F_DUPFD_CLOEXEC* = cint(1030)
+const F_GETFD* = cint(1)
+const F_SETFD* = cint(2)
+const F_GETFL* = cint(3)
+const F_SETFL* = cint(4)
+const F_GETLK* = cint(5)
+const F_SETLK* = cint(6)
+const F_SETLKW* = cint(7)
+const F_GETOWN* = cint(9)
+const F_SETOWN* = cint(8)
+const FD_CLOEXEC* = cint(1)
+const F_RDLCK* = cint(0)
+const F_UNLCK* = cint(2)
+const F_WRLCK* = cint(1)
+const O_CREAT* = cint(64)
+const O_EXCL* = cint(128)
+const O_NOCTTY* = cint(256)
+const O_TRUNC* = cint(512)
+const O_APPEND* = cint(1024)
+const O_DSYNC* = cint(4096)
+const O_NONBLOCK* = cint(2048)
+const O_RSYNC* = cint(1052672)
+const O_SYNC* = cint(1052672)
+const O_ACCMODE* = cint(3)
+const O_RDONLY* = cint(0)
+const O_RDWR* = cint(2)
+const O_WRONLY* = cint(1)
+const O_CLOEXEC* = cint(524288)
+const O_DIRECT* = cint(16384)
+const O_PATH* = cint(2097152)
+const O_NOATIME* = cint(262144)
+const O_TMPFILE* = cint(4259840)
+const POSIX_FADV_NORMAL* = cint(0)
+const POSIX_FADV_SEQUENTIAL* = cint(2)
+const POSIX_FADV_RANDOM* = cint(1)
+const POSIX_FADV_WILLNEED* = cint(3)
+const POSIX_FADV_DONTNEED* = cint(4)
+const POSIX_FADV_NOREUSE* = cint(5)
+
+# <fenv.h>
+const FE_DIVBYZERO* = cint(4)
+const FE_INEXACT* = cint(32)
+const FE_INVALID* = cint(1)
+const FE_OVERFLOW* = cint(8)
+const FE_UNDERFLOW* = cint(16)
+const FE_ALL_EXCEPT* = cint(61)
+const FE_DOWNWARD* = cint(1024)
+const FE_TONEAREST* = cint(0)
+const FE_TOWARDZERO* = cint(3072)
+const FE_UPWARD* = cint(2048)
+const FE_DFL_ENV* = cint(-1)
+
+# <fmtmsg.h>
+const MM_HARD* = cint(1)
+const MM_SOFT* = cint(2)
+const MM_FIRM* = cint(4)
+const MM_APPL* = cint(8)
+const MM_UTIL* = cint(16)
+const MM_OPSYS* = cint(32)
+const MM_RECOVER* = cint(64)
+const MM_NRECOV* = cint(128)
+const MM_HALT* = cint(1)
+const MM_ERROR* = cint(2)
+const MM_WARNING* = cint(3)
+const MM_INFO* = cint(4)
+const MM_NOSEV* = cint(0)
+const MM_PRINT* = cint(256)
+const MM_CONSOLE* = cint(512)
+const MM_OK* = cint(0)
+const MM_NOTOK* = cint(-1)
+const MM_NOMSG* = cint(1)
+const MM_NOCON* = cint(4)
+
+# <fnmatch.h>
+const FNM_NOMATCH* = cint(1)
+const FNM_PATHNAME* = cint(1)
+const FNM_PERIOD* = cint(4)
+const FNM_NOESCAPE* = cint(2)
+const FNM_NOSYS* = cint(-1)
+
+# <ftw.h>
+const FTW_F* = cint(0)
+const FTW_D* = cint(1)
+const FTW_DNR* = cint(2)
+const FTW_DP* = cint(5)
+const FTW_NS* = cint(3)
+const FTW_SL* = cint(4)
+const FTW_SLN* = cint(6)
+const FTW_PHYS* = cint(1)
+const FTW_MOUNT* = cint(2)
+const FTW_DEPTH* = cint(8)
+const FTW_CHDIR* = cint(4)
+
+# <glob.h>
+const GLOB_APPEND* = cint(32)
+const GLOB_DOOFFS* = cint(8)
+const GLOB_ERR* = cint(1)
+const GLOB_MARK* = cint(2)
+const GLOB_NOCHECK* = cint(16)
+const GLOB_NOESCAPE* = cint(64)
+const GLOB_NOSORT* = cint(4)
+const GLOB_ABORTED* = cint(2)
+const GLOB_NOMATCH* = cint(3)
+const GLOB_NOSPACE* = cint(1)
+const GLOB_NOSYS* = cint(4)
+
+# <langinfo.h>
+const CODESET* = cint(14)
+const D_T_FMT* = cint(131112)
+const D_FMT* = cint(131113)
+const T_FMT* = cint(131114)
+const T_FMT_AMPM* = cint(131115)
+const AM_STR* = cint(131110)
+const PM_STR* = cint(131111)
+const DAY_1* = cint(131079)
+const DAY_2* = cint(131080)
+const DAY_3* = cint(131081)
+const DAY_4* = cint(131082)
+const DAY_5* = cint(131083)
+const DAY_6* = cint(131084)
+const DAY_7* = cint(131085)
+const ABDAY_1* = cint(131072)
+const ABDAY_2* = cint(131073)
+const ABDAY_3* = cint(131074)
+const ABDAY_4* = cint(131075)
+const ABDAY_5* = cint(131076)
+const ABDAY_6* = cint(131077)
+const ABDAY_7* = cint(131078)
+const MON_1* = cint(131098)
+const MON_2* = cint(131099)
+const MON_3* = cint(131100)
+const MON_4* = cint(131101)
+const MON_5* = cint(131102)
+const MON_6* = cint(131103)
+const MON_7* = cint(131104)
+const MON_8* = cint(131105)
+const MON_9* = cint(131106)
+const MON_10* = cint(131107)
+const MON_11* = cint(131108)
+const MON_12* = cint(131109)
+const ABMON_1* = cint(131086)
+const ABMON_2* = cint(131087)
+const ABMON_3* = cint(131088)
+const ABMON_4* = cint(131089)
+const ABMON_5* = cint(131090)
+const ABMON_6* = cint(131091)
+const ABMON_7* = cint(131092)
+const ABMON_8* = cint(131093)
+const ABMON_9* = cint(131094)
+const ABMON_10* = cint(131095)
+const ABMON_11* = cint(131096)
+const ABMON_12* = cint(131097)
+const ERA* = cint(131116)
+const ERA_D_FMT* = cint(131118)
+const ERA_D_T_FMT* = cint(131120)
+const ERA_T_FMT* = cint(131121)
+const ALT_DIGITS* = cint(131119)
+const RADIXCHAR* = cint(65536)
+const THOUSEP* = cint(65537)
+const YESEXPR* = cint(327680)
+const NOEXPR* = cint(327681)
+const CRNCYSTR* = cint(262159)
+
+# <locale.h>
+const LC_ALL* = cint(6)
+const LC_COLLATE* = cint(3)
+const LC_CTYPE* = cint(0)
+const LC_MESSAGES* = cint(5)
+const LC_MONETARY* = cint(4)
+const LC_NUMERIC* = cint(1)
+const LC_TIME* = cint(2)
+
+# <netdb.h>
+const IPPORT_RESERVED* = cint(1024)
+const HOST_NOT_FOUND* = cint(1)
+const NO_DATA* = cint(4)
+const NO_RECOVERY* = cint(3)
+const TRY_AGAIN* = cint(2)
+const AI_PASSIVE* = cint(1)
+const AI_CANONNAME* = cint(2)
+const AI_NUMERICHOST* = cint(4)
+const AI_NUMERICSERV* = cint(1024)
+const AI_V4MAPPED* = cint(8)
+const AI_ALL* = cint(16)
+const AI_ADDRCONFIG* = cint(32)
+const NI_NOFQDN* = cint(4)
+const NI_NUMERICHOST* = cint(1)
+const NI_NAMEREQD* = cint(8)
+const NI_NUMERICSERV* = cint(2)
+const NI_DGRAM* = cint(16)
+const EAI_AGAIN* = cint(-3)
+const EAI_BADFLAGS* = cint(-1)
+const EAI_FAIL* = cint(-4)
+const EAI_FAMILY* = cint(-6)
+const EAI_MEMORY* = cint(-10)
+const EAI_NONAME* = cint(-2)
+const EAI_SERVICE* = cint(-8)
+const EAI_SOCKTYPE* = cint(-7)
+const EAI_SYSTEM* = cint(-11)
+const EAI_OVERFLOW* = cint(-12)
+
+# <net/if.h>
+const IF_NAMESIZE* = cint(16)
+
+# <netinet/in.h>
+const IPPROTO_IP* = cint(0)
+const IPPROTO_IPV6* = cint(41)
+const IPPROTO_ICMP* = cint(1)
+const IPPROTO_ICMPV6* = cint(58)
+const IPPROTO_RAW* = cint(255)
+const IPPROTO_TCP* = cint(6)
+const IPPROTO_UDP* = cint(17)
+const INADDR_ANY* = InAddrScalar(0)
+const INADDR_LOOPBACK* = InAddrScalar(2130706433)
+const INADDR_BROADCAST* = InAddrScalar(4294967295)
+const INET_ADDRSTRLEN* = cint(16)
+const INET6_ADDRSTRLEN* = cint(46)
+const IPV6_JOIN_GROUP* = cint(20)
+const IPV6_LEAVE_GROUP* = cint(21)
+const IPV6_MULTICAST_HOPS* = cint(18)
+const IPV6_MULTICAST_IF* = cint(17)
+const IPV6_MULTICAST_LOOP* = cint(19)
+const IPV6_UNICAST_HOPS* = cint(16)
+const IPV6_V6ONLY* = cint(26)
+
+# <netinet/tcp.h>
+const TCP_NODELAY* = cint(1)
+
+# <nl_types.h>
+const NL_SETD* = cint(1)
+const NL_CAT_LOCALE* = cint(1)
+
+# <poll.h>
+const POLLIN* = cshort(1)
+const POLLRDNORM* = cshort(64)
+const POLLRDBAND* = cshort(128)
+const POLLPRI* = cshort(2)
+const POLLOUT* = cshort(4)
+const POLLWRNORM* = cshort(256)
+const POLLWRBAND* = cshort(512)
+const POLLERR* = cshort(8)
+const POLLHUP* = cshort(16)
+const POLLNVAL* = cshort(32)
+
+# <pthread.h>
+const PTHREAD_BARRIER_SERIAL_THREAD* = cint(-1)
+const PTHREAD_CANCEL_ASYNCHRONOUS* = cint(1)
+const PTHREAD_CANCEL_ENABLE* = cint(0)
+const PTHREAD_CANCEL_DEFERRED* = cint(0)
+const PTHREAD_CANCEL_DISABLE* = cint(1)
+const PTHREAD_CREATE_DETACHED* = cint(1)
+const PTHREAD_CREATE_JOINABLE* = cint(0)
+const PTHREAD_EXPLICIT_SCHED* = cint(1)
+const PTHREAD_INHERIT_SCHED* = cint(0)
+const PTHREAD_PROCESS_SHARED* = cint(1)
+const PTHREAD_PROCESS_PRIVATE* = cint(0)
+const PTHREAD_SCOPE_PROCESS* = cint(1)
+const PTHREAD_SCOPE_SYSTEM* = cint(0)
+
+# <sched.h>
+const SCHED_FIFO* = cint(1)
+const SCHED_RR* = cint(2)
+const SCHED_OTHER* = cint(0)
+
+# <semaphore.h>
+const SEM_FAILED* = cast[pointer]((nil))
+
+# <signal.h>
+const SIGEV_NONE* = cint(1)
+const SIGEV_SIGNAL* = cint(0)
+const SIGEV_THREAD* = cint(2)
+const SIGABRT* = cint(6)
+const SIGALRM* = cint(14)
+const SIGBUS* = cint(7)
+const SIGCHLD* = cint(17)
+const SIGCONT* = cint(18)
+const SIGFPE* = cint(8)
+const SIGHUP* = cint(1)
+const SIGILL* = cint(4)
+const SIGINT* = cint(2)
+const SIGKILL* = cint(9)
+const SIGPIPE* = cint(13)
+const SIGQUIT* = cint(3)
+const SIGSEGV* = cint(11)
+const SIGSTOP* = cint(19)
+const SIGTERM* = cint(15)
+const SIGTSTP* = cint(20)
+const SIGTTIN* = cint(21)
+const SIGTTOU* = cint(22)
+const SIGUSR1* = cint(10)
+const SIGUSR2* = cint(12)
+const SIGPOLL* = cint(29)
+const SIGPROF* = cint(27)
+const SIGSYS* = cint(31)
+const SIGTRAP* = cint(5)
+const SIGURG* = cint(23)
+const SIGVTALRM* = cint(26)
+const SIGXCPU* = cint(24)
+const SIGXFSZ* = cint(25)
+const SA_NOCLDSTOP* = cint(1)
+const SIG_BLOCK* = cint(0)
+const SIG_UNBLOCK* = cint(1)
+const SIG_SETMASK* = cint(2)
+const SA_ONSTACK* = cint(134217728)
+const SA_RESETHAND* = cint(-2147483648)
+const SA_RESTART* = cint(268435456)
+const SA_SIGINFO* = cint(4)
+const SA_NOCLDWAIT* = cint(2)
+const SA_NODEFER* = cint(1073741824)
+const SS_ONSTACK* = cint(1)
+const SS_DISABLE* = cint(2)
+const MINSIGSTKSZ* = cint(2048)
+const SIGSTKSZ* = cint(8192)
+const SIG_HOLD* = cast[Sighandler](2)
+const SIG_DFL* = cast[Sighandler](0)
+const SIG_ERR* = cast[Sighandler](-1)
+const SIG_IGN* = cast[Sighandler](1)
+
+# <sys/ipc.h>
+const IPC_CREAT* = cint(512)
+const IPC_EXCL* = cint(1024)
+const IPC_NOWAIT* = cint(2048)
+const IPC_PRIVATE* = cint(0)
+const IPC_RMID* = cint(0)
+const IPC_SET* = cint(1)
+const IPC_STAT* = cint(2)
+
+# <sys/mman.h>
+const PROT_READ* = cint(1)
+const PROT_WRITE* = cint(2)
+const PROT_EXEC* = cint(4)
+const PROT_NONE* = cint(0)
+const MAP_ANONYMOUS* = cint(32)
+const MAP_FIXED_NOREPLACE* = cint(1048576)
+const MAP_NORESERVE* = cint(16384)
+const MAP_SHARED* = cint(1)
+const MAP_PRIVATE* = cint(2)
+const MAP_FIXED* = cint(16)
+const MS_ASYNC* = cint(1)
+const MS_SYNC* = cint(4)
+const MS_INVALIDATE* = cint(2)
+const MCL_CURRENT* = cint(1)
+const MCL_FUTURE* = cint(2)
+const MAP_FAILED* = cast[pointer](0xffffffffffffffff)
+const POSIX_MADV_NORMAL* = cint(0)
+const POSIX_MADV_SEQUENTIAL* = cint(2)
+const POSIX_MADV_RANDOM* = cint(1)
+const POSIX_MADV_WILLNEED* = cint(3)
+const POSIX_MADV_DONTNEED* = cint(4)
+const MAP_POPULATE* = cint(32768)
+
+# <sys/resource.h>
+const RLIMIT_NOFILE* = cint(7)
+const RLIMIT_STACK* = cint(3)
+
+# <sys/select.h>
+const FD_SETSIZE* = cint(1024)
+
+# <sys/socket.h>
+const MSG_CTRUNC* = cint(8)
+const MSG_DONTROUTE* = cint(4)
+const MSG_EOR* = cint(128)
+const MSG_OOB* = cint(1)
+const SCM_RIGHTS* = cint(1)
+const SO_ACCEPTCONN* = cint(30)
+const SO_BINDTODEVICE* = cint(25)
+const SO_BROADCAST* = cint(6)
+const SO_DEBUG* = cint(1)
+const SO_DONTROUTE* = cint(5)
+const SO_ERROR* = cint(4)
+const SO_KEEPALIVE* = cint(9)
+const SO_LINGER* = cint(13)
+const SO_OOBINLINE* = cint(10)
+const SO_RCVBUF* = cint(8)
+const SO_RCVLOWAT* = cint(18)
+const SO_RCVTIMEO* = cint(20)
+const SO_REUSEADDR* = cint(2)
+const SO_SNDBUF* = cint(7)
+const SO_SNDLOWAT* = cint(19)
+const SO_SNDTIMEO* = cint(21)
+const SO_TYPE* = cint(3)
+const SOCK_DGRAM* = cint(2)
+const SOCK_RAW* = cint(3)
+const SOCK_SEQPACKET* = cint(5)
+const SOCK_STREAM* = cint(1)
+const SOCK_CLOEXEC* = cint(524288)
+const SOL_SOCKET* = cint(1)
+const SOMAXCONN* = cint(4096)
+const SO_REUSEPORT* = cint(15)
+const MSG_NOSIGNAL* = cint(16384)
+const MSG_PEEK* = cint(2)
+const MSG_TRUNC* = cint(32)
+const MSG_WAITALL* = cint(256)
+const AF_INET* = cint(2)
+const AF_INET6* = cint(10)
+const AF_UNIX* = cint(1)
+const AF_UNSPEC* = cint(0)
+const SHUT_RD* = cint(0)
+const SHUT_RDWR* = cint(2)
+const SHUT_WR* = cint(1)
+
+# <sys/stat.h>
+const S_IFBLK* = cint(24576)
+const S_IFCHR* = cint(8192)
+const S_IFDIR* = cint(16384)
+const S_IFIFO* = cint(4096)
+const S_IFLNK* = cint(40960)
+const S_IFMT* = cint(61440)
+const S_IFREG* = cint(32768)
+const S_IFSOCK* = cint(49152)
+const S_IRGRP* = cint(32)
+const S_IROTH* = cint(4)
+const S_IRUSR* = cint(256)
+const S_IRWXG* = cint(56)
+const S_IRWXO* = cint(7)
+const S_IRWXU* = cint(448)
+const S_ISGID* = cint(1024)
+const S_ISUID* = cint(2048)
+const S_ISVTX* = cint(512)
+const S_IWGRP* = cint(16)
+const S_IWOTH* = cint(2)
+const S_IWUSR* = cint(128)
+const S_IXGRP* = cint(8)
+const S_IXOTH* = cint(1)
+const S_IXUSR* = cint(64)
+
+# <sys/statvfs.h>
+const ST_RDONLY* = cint(1)
+const ST_NOSUID* = cint(2)
+
+# <sys/wait.h>
+const WNOHANG* = cint(1)
+const WUNTRACED* = cint(2)
+const WEXITED* = cint(4)
+const WSTOPPED* = cint(2)
+const WCONTINUED* = cint(8)
+const WNOWAIT* = cint(16777216)
+
+# <spawn.h>
+const POSIX_SPAWN_RESETIDS* = cint(1)
+const POSIX_SPAWN_SETPGROUP* = cint(2)
+const POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
+const POSIX_SPAWN_SETSCHEDULER* = cint(32)
+const POSIX_SPAWN_SETSIGDEF* = cint(4)
+const POSIX_SPAWN_SETSIGMASK* = cint(8)
+const POSIX_SPAWN_USEVFORK* = cint(64)
+
+# <stdio.h>
+const IOFBF* = cint(0)
+const IONBF* = cint(2)
+
+# <time.h>
+const CLOCKS_PER_SEC* = clong(1000000)
+const CLOCK_PROCESS_CPUTIME_ID* = cint(2)
+const CLOCK_THREAD_CPUTIME_ID* = cint(3)
+const CLOCK_REALTIME* = cint(0)
+const TIMER_ABSTIME* = cint(1)
+const CLOCK_MONOTONIC* = cint(1)
+
+# <unistd.h>
+const POSIX_ASYNC_IO* = cint(1)
+const F_OK* = cint(0)
+const R_OK* = cint(4)
+const W_OK* = cint(2)
+const X_OK* = cint(1)
+const CS_PATH* = cint(0)
+const CS_POSIX_V6_ILP32_OFF32_CFLAGS* = cint(1116)
+const CS_POSIX_V6_ILP32_OFF32_LDFLAGS* = cint(1117)
+const CS_POSIX_V6_ILP32_OFF32_LIBS* = cint(1118)
+const CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* = cint(1120)
+const CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* = cint(1121)
+const CS_POSIX_V6_ILP32_OFFBIG_LIBS* = cint(1122)
+const CS_POSIX_V6_LP64_OFF64_CFLAGS* = cint(1124)
+const CS_POSIX_V6_LP64_OFF64_LDFLAGS* = cint(1125)
+const CS_POSIX_V6_LP64_OFF64_LIBS* = cint(1126)
+const CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* = cint(1128)
+const CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* = cint(1129)
+const CS_POSIX_V6_LPBIG_OFFBIG_LIBS* = cint(1130)
+const CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* = cint(1)
+const F_LOCK* = cint(1)
+const F_TEST* = cint(3)
+const F_TLOCK* = cint(2)
+const F_ULOCK* = cint(0)
+const PC_2_SYMLINKS* = cint(20)
+const PC_ALLOC_SIZE_MIN* = cint(18)
+const PC_ASYNC_IO* = cint(10)
+const PC_CHOWN_RESTRICTED* = cint(6)
+const PC_FILESIZEBITS* = cint(13)
+const PC_LINK_MAX* = cint(0)
+const PC_MAX_CANON* = cint(1)
+const PC_MAX_INPUT* = cint(2)
+const PC_NAME_MAX* = cint(3)
+const PC_NO_TRUNC* = cint(7)
+const PC_PATH_MAX* = cint(4)
+const PC_PIPE_BUF* = cint(5)
+const PC_PRIO_IO* = cint(11)
+const PC_REC_INCR_XFER_SIZE* = cint(14)
+const PC_REC_MIN_XFER_SIZE* = cint(16)
+const PC_REC_XFER_ALIGN* = cint(17)
+const PC_SYMLINK_MAX* = cint(19)
+const PC_SYNC_IO* = cint(9)
+const PC_VDISABLE* = cint(8)
+const SC_2_C_BIND* = cint(47)
+const SC_2_C_DEV* = cint(48)
+const SC_2_CHAR_TERM* = cint(95)
+const SC_2_FORT_DEV* = cint(49)
+const SC_2_FORT_RUN* = cint(50)
+const SC_2_LOCALEDEF* = cint(52)
+const SC_2_PBS* = cint(168)
+const SC_2_PBS_ACCOUNTING* = cint(169)
+const SC_2_PBS_CHECKPOINT* = cint(175)
+const SC_2_PBS_LOCATE* = cint(170)
+const SC_2_PBS_MESSAGE* = cint(171)
+const SC_2_PBS_TRACK* = cint(172)
+const SC_2_SW_DEV* = cint(51)
+const SC_2_UPE* = cint(97)
+const SC_2_VERSION* = cint(46)
+const SC_ADVISORY_INFO* = cint(132)
+const SC_AIO_LISTIO_MAX* = cint(23)
+const SC_AIO_MAX* = cint(24)
+const SC_AIO_PRIO_DELTA_MAX* = cint(25)
+const SC_ARG_MAX* = cint(0)
+const SC_ASYNCHRONOUS_IO* = cint(12)
+const SC_ATEXIT_MAX* = cint(87)
+const SC_BARRIERS* = cint(133)
+const SC_BC_BASE_MAX* = cint(36)
+const SC_BC_DIM_MAX* = cint(37)
+const SC_BC_SCALE_MAX* = cint(38)
+const SC_BC_STRING_MAX* = cint(39)
+const SC_CHILD_MAX* = cint(1)
+const SC_CLK_TCK* = cint(2)
+const SC_CLOCK_SELECTION* = cint(137)
+const SC_COLL_WEIGHTS_MAX* = cint(40)
+const SC_CPUTIME* = cint(138)
+const SC_DELAYTIMER_MAX* = cint(26)
+const SC_EXPR_NEST_MAX* = cint(42)
+const SC_FSYNC* = cint(15)
+const SC_GETGR_R_SIZE_MAX* = cint(69)
+const SC_GETPW_R_SIZE_MAX* = cint(70)
+const SC_HOST_NAME_MAX* = cint(180)
+const SC_IOV_MAX* = cint(60)
+const SC_IPV6* = cint(235)
+const SC_JOB_CONTROL* = cint(7)
+const SC_LINE_MAX* = cint(43)
+const SC_LOGIN_NAME_MAX* = cint(71)
+const SC_MAPPED_FILES* = cint(16)
+const SC_MEMLOCK* = cint(17)
+const SC_MEMLOCK_RANGE* = cint(18)
+const SC_MEMORY_PROTECTION* = cint(19)
+const SC_MESSAGE_PASSING* = cint(20)
+const SC_MONOTONIC_CLOCK* = cint(149)
+const SC_MQ_OPEN_MAX* = cint(27)
+const SC_MQ_PRIO_MAX* = cint(28)
+const SC_NGROUPS_MAX* = cint(3)
+const SC_OPEN_MAX* = cint(4)
+const SC_PAGESIZE* = cint(30)
+const SC_PRIORITIZED_IO* = cint(13)
+const SC_PRIORITY_SCHEDULING* = cint(10)
+const SC_RAW_SOCKETS* = cint(236)
+const SC_RE_DUP_MAX* = cint(44)
+const SC_READER_WRITER_LOCKS* = cint(153)
+const SC_REALTIME_SIGNALS* = cint(9)
+const SC_REGEXP* = cint(155)
+const SC_RTSIG_MAX* = cint(31)
+const SC_SAVED_IDS* = cint(8)
+const SC_SEM_NSEMS_MAX* = cint(32)
+const SC_SEM_VALUE_MAX* = cint(33)
+const SC_SEMAPHORES* = cint(21)
+const SC_SHARED_MEMORY_OBJECTS* = cint(22)
+const SC_SHELL* = cint(157)
+const SC_SIGQUEUE_MAX* = cint(34)
+const SC_SPAWN* = cint(159)
+const SC_SPIN_LOCKS* = cint(154)
+const SC_SPORADIC_SERVER* = cint(160)
+const SC_SS_REPL_MAX* = cint(241)
+const SC_STREAM_MAX* = cint(5)
+const SC_SYMLOOP_MAX* = cint(173)
+const SC_SYNCHRONIZED_IO* = cint(14)
+const SC_THREAD_ATTR_STACKADDR* = cint(77)
+const SC_THREAD_ATTR_STACKSIZE* = cint(78)
+const SC_THREAD_CPUTIME* = cint(139)
+const SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(73)
+const SC_THREAD_KEYS_MAX* = cint(74)
+const SC_THREAD_PRIO_INHERIT* = cint(80)
+const SC_THREAD_PRIO_PROTECT* = cint(81)
+const SC_THREAD_PRIORITY_SCHEDULING* = cint(79)
+const SC_THREAD_PROCESS_SHARED* = cint(82)
+const SC_THREAD_SAFE_FUNCTIONS* = cint(68)
+const SC_THREAD_SPORADIC_SERVER* = cint(161)
+const SC_THREAD_STACK_MIN* = cint(75)
+const SC_THREAD_THREADS_MAX* = cint(76)
+const SC_THREADS* = cint(67)
+const SC_TIMEOUTS* = cint(164)
+const SC_TIMER_MAX* = cint(35)
+const SC_TIMERS* = cint(11)
+const SC_TRACE* = cint(181)
+const SC_TRACE_EVENT_FILTER* = cint(182)
+const SC_TRACE_EVENT_NAME_MAX* = cint(242)
+const SC_TRACE_INHERIT* = cint(183)
+const SC_TRACE_LOG* = cint(184)
+const SC_TRACE_NAME_MAX* = cint(243)
+const SC_TRACE_SYS_MAX* = cint(244)
+const SC_TRACE_USER_EVENT_MAX* = cint(245)
+const SC_TTY_NAME_MAX* = cint(72)
+const SC_TYPED_MEMORY_OBJECTS* = cint(165)
+const SC_TZNAME_MAX* = cint(6)
+const SC_V6_ILP32_OFF32* = cint(176)
+const SC_V6_ILP32_OFFBIG* = cint(177)
+const SC_V6_LP64_OFF64* = cint(178)
+const SC_V6_LPBIG_OFFBIG* = cint(179)
+const SC_VERSION* = cint(29)
+const SC_XBS5_ILP32_OFF32* = cint(125)
+const SC_XBS5_ILP32_OFFBIG* = cint(126)
+const SC_XBS5_LP64_OFF64* = cint(127)
+const SC_XBS5_LPBIG_OFFBIG* = cint(128)
+const SC_XOPEN_CRYPT* = cint(92)
+const SC_XOPEN_ENH_I18N* = cint(93)
+const SC_XOPEN_LEGACY* = cint(129)
+const SC_XOPEN_REALTIME* = cint(130)
+const SC_XOPEN_REALTIME_THREADS* = cint(131)
+const SC_XOPEN_SHM* = cint(94)
+const SC_XOPEN_STREAMS* = cint(246)
+const SC_XOPEN_UNIX* = cint(91)
+const SC_XOPEN_VERSION* = cint(89)
+const SC_NPROCESSORS_ONLN* = cint(84)
+const SEEK_SET* = cint(0)
+const SEEK_CUR* = cint(1)
+const SEEK_END* = cint(2)
diff --git a/lib/posix/posix_macos_amd64.nim b/lib/posix/posix_macos_amd64.nim
new file mode 100644
index 000000000..a4b64ed62
--- /dev/null
+++ b/lib/posix/posix_macos_amd64.nim
@@ -0,0 +1,620 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+const
+  hasSpawnH = true # should exist for every Posix system nowadays
+  hasAioH = false
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+    ## A type representing a directory stream.
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
+
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: int  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+             header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    when defined(haiku):
+      d_dev*: Dev ## Device (not POSIX)
+      d_pdev*: Dev ## Parent device (only for queries) (not POSIX)
+    d_ino*: Ino  ## File serial number.
+    when defined(dragonfly):
+      # DragonflyBSD doesn't have `d_reclen` field.
+      d_type*: uint8
+    elif defined(linux) or defined(macosx) or defined(freebsd) or
+         defined(netbsd) or defined(openbsd) or defined(genode):
+      d_reclen*: cshort ## Length of this record. (not POSIX)
+      d_type*: int8 ## Type of file; not supported by all filesystem types.
+                    ## (not POSIX)
+      when defined(linux) or defined(openbsd):
+        d_off*: Off  ## Not an offset. Value that `telldir()` would return.
+    elif defined(haiku):
+      d_pino*: Ino ## Parent inode (only for queries) (not POSIX)
+      d_reclen*: cushort ## Length of this record. (not POSIX)
+
+    d_name*: array[0..255, char] ## Name of entry.
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
+    base*: cint
+    level*: cint
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: int          ## Count of paths matched by pattern.
+    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
+    gl_offs*: int           ## Slots to reserve at the beginning of gl_pathv.
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} =
+    object ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    currency_symbol*: cstring
+    decimal_point*: cstring
+    frac_digits*: char
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    int_frac_digits*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_p_sign_posn*: char
+    mon_decimal_point*: cstring
+    mon_grouping*: cstring
+    mon_thousands_sep*: cstring
+    negative_sign*: cstring
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    n_sign_posn*: char
+    positive_sign*: cstring
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    p_sign_posn*: char
+    thousands_sep*: cstring
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int32
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = (
+    when defined(freebsd):
+      uint32
+    else:
+      int32)
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = int
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = int
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
+    when defined(openbsd) or defined(netbsd):
+      uint32
+    else:
+      uint16
+  )
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = uint16
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<sys/types.h>".} = int
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<sys/types.h>".} = int
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = int
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<sys/types.h>".} = int
+  Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = int
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<sys/types.h>".} = int
+  Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = int
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<sys/types.h>".} = int
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<sys/types.h>".} = int
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<sys/types.h>".} = int
+  Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = int
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int32
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = int
+  Trace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int
+  Trace_event_id* {.importc: "trace_event_id_t",
+                     header: "<sys/types.h>".} = int
+  Trace_event_set* {.importc: "trace_event_set_t",
+                      header: "<sys/types.h>".} = int
+  Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,      ## Name of this implementation of the operating system.
+      nodename*,   ## Name of this node within the communications
+                   ## network to which this node is attached, if any.
+      release*,    ## Current release level of this implementation.
+      version*,    ## Current version level of this release.
+      machine*: array[0..255, char] ## Name of the hardware type on which the
+                                     ## system is running.
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+  Ipc_perm* {.importc: "struct ipc_perm",
+               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
+    uid*: Uid    ## Owner's user ID.
+    gid*: Gid    ## Owner's group ID.
+    cuid*: Uid   ## Creator's user ID.
+    cgid*: Gid   ## Creator's group ID.
+    mode*: Mode  ## Read/write permission.
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                          ## For symbolic links, the length in bytes of the
+                          ## pathname contained in the symbolic link.
+                          ## For a shared memory object, the length in bytes.
+                          ## For a typed memory object, the length in bytes.
+                          ## For other file types, the use of this field is
+                          ## unspecified.
+    when defined(osx):
+      st_atim* {.importc:"st_atimespec".}: Timespec  ## Time of last access.
+      st_mtim* {.importc:"st_mtimespec".}: Timespec  ## Time of last data modification.
+      st_ctim*  {.importc:"st_ctimespec".}: Timespec  ## Time of last status change.
+    elif StatHasNanoseconds:
+      st_atim*: Timespec  ## Time of last access.
+      st_mtim*: Timespec  ## Time of last data modification.
+      st_ctim*: Timespec  ## Time of last status change.
+    else:
+      st_atime*: Time     ## Time of last access.
+      st_mtime*: Time     ## Time of last data modification.
+      st_ctime*: Time     ## Time of last status change.
+
+    st_blksize*: Blksize  ## A file system-specific preferred I/O block size
+                          ## for this object. In some file system types, this
+                          ## may vary from file to file.
+    st_blocks*: Blkcnt    ## Number of blocks allocated for this object.
+
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: int        ## File system block size.
+    f_frsize*: int       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt  ## Total number of blocks on file system
+                         ## in units of f_frsize.
+    f_bfree*: Fsblkcnt   ## Total number of free blocks.
+    f_bavail*: Fsblkcnt  ## Number of free blocks available to
+                         ## non-privileged process.
+    f_files*: Fsfilcnt   ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt   ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt  ## Number of file serial numbers available to
+                         ## non-privileged process.
+    f_fsid*: int         ## File system ID.
+    f_flag*: int         ## Bit mask of f_flag values.
+    f_namemax*: int      ## Maximum filename length.
+
+  Posix_typed_mem_info* {.importc: "struct posix_typed_mem_info",
+                           header: "<sys/mman.h>", final, pure.} = object
+    posix_tmi_length*: int
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_notify*: cint           ## Notification type.
+    sigev_signo*: cint            ## Signal number.
+    sigev_value*: SigVal          ## Signal value.
+    sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
+    sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_ptr*: pointer ## pointer signal value;
+                        ## integer signal value not defined!
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+    sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_size*: int    ## Stack size.
+    ss_flags*: cint  ## Flags.
+
+  SigStack* {.importc: "struct sigstack",
+               header: "<signal.h>", final, pure.} = object ## struct sigstack
+    ss_onstack*: cint ## Non-zero when signal stack is in use.
+    ss_sp*: pointer   ## Signal stack pointer.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_code*: cint     ## Signal code.
+    si_errno*: cint    ## If non-zero, an errno value associated with
+                       ## this signal, as defined in <errno.h>.
+    si_pid*: Pid       ## Sending process ID.
+    si_uid*: Uid       ## Real user ID of sending process.
+    si_addr*: pointer  ## Address of faulting instruction.
+    si_status*: cint   ## Exit value or signal.
+    si_band*: int      ## Band event for SIGPOLL.
+    si_value*: SigVal  ## Signal value.
+
+  Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
+  Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+    sched_ss_low_priority*: cint     ## Low scheduling priority for
+                                     ## sporadic server.
+    sched_ss_repl_period*: Timespec  ## Replenishment period for
+                                     ## sporadic server.
+    sched_ss_init_budget*: Timespec  ## Initial budget for sporadic server.
+    sched_ss_max_repl*: cint         ## Maximum pending replenishments for
+                                     ## sporadic server.
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+  Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
+               final, pure.} = object
+  Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
+               final, pure.} = object ## ucontext_t
+    uc_link*: ptr Ucontext  ## Pointer to the context that is resumed
+                            ## when this context returns.
+    uc_sigmask*: Sigset     ## The set of signals that are blocked when this
+                            ## context is active.
+    uc_stack*: Stack        ## The stack used by this context.
+    uc_mcontext*: Mcontext  ## A machine-specific representation of the saved
+                            ## context.
+
+when hasAioH:
+  type
+    Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+              final, pure.} = object ## struct aiocb
+      aio_fildes*: cint         ## File descriptor.
+      aio_offset*: Off          ## File offset.
+      aio_buf*: pointer         ## Location of buffer.
+      aio_nbytes*: int          ## Length of transfer.
+      aio_reqprio*: cint        ## Request priority offset.
+      aio_sigevent*: SigEvent   ## Signal number and value.
+      aio_lio_opcode: cint      ## Operation to be performed.
+
+when hasSpawnH:
+  type
+    Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                        header: "<spawn.h>", final, pure.} = object
+    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                                 header: "<spawn.h>", final, pure.} = object
+
+
+when not defined(macos) and not defined(macosx): # freebsd
+  type
+    Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
+    MqAttr* {.importc: "struct mq_attr",
+              header: "<mqueue.h>",
+              final, pure.} = object ## message queue attribute
+      mq_flags*: int   ## Message queue flags.
+      mq_maxmsg*: int  ## Maximum number of messages.
+      mq_msgsize*: int ## Maximum message size.
+      mq_curmsgs*: int ## Number of messages currently queued.
+
+when defined(linux):
+  # from sys/un.h
+  const Sockaddr_un_path_length* = 108
+else:
+  # according to http://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/un.h.html
+  # this is >=92
+  const Sockaddr_un_path_length* = 92
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = uint8
+
+  SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+              pure, final.} = object ## struct sockaddr
+    sa_family*: TSa_Family         ## Address family.
+    sa_data*: array[0..255, char] ## Socket address (variable-length data).
+
+  Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
+              pure, final.} = object ## struct sockaddr_un
+    sun_family*: TSa_Family         ## Address family.
+    sun_path*: array[0..Sockaddr_un_path_length-1, char] ## Socket path
+
+  Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                       header: "<sys/socket.h>",
+                       pure, final.} = object ## struct sockaddr_storage
+    ss_family*: TSa_Family ## Address family.
+
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/uio.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t    ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer  ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: cint   ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: SockLen ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: SockLen ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: uint32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: uint32    ## Set of interfaces for a scope.
+
+  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
+                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
+    ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
+    ipv6mr_interface*: cint     ## Interface index.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: uint32            ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  TPollfd* {.importc: "struct pollfd", pure, final,
+             header: "<poll.h>".} = object ## struct pollfd
+    fd*: cint        ## The following descriptor being polled.
+    events*: cshort  ## The input event flags (see below).
+    revents*: cshort ## The output event flags (see below).
+
+  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = cint
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc, header: "<time.h>".}: cint
+  timezone* {.importc, header: "<time.h>".}: int
+
+# Regenerate using detect.nim!
+include posix_other_consts
+
+when defined(linux):
+  var
+    MAP_POPULATE* {.importc, header: "<sys/mman.h>".}: cint
+      ## Populate (prefault) page tables for a mapping.
+else:
+  var
+    MAP_POPULATE*: cint = 0
+
+when defined(linux) or defined(nimdoc):
+  when defined(alpha) or defined(mips) or defined(mipsel) or
+      defined(mips64) or defined(mips64el) or defined(parisc) or
+      defined(sparc) or defined(sparc64) or defined(nimdoc):
+    const SO_REUSEPORT* = cint(0x0200)
+      ## Multiple binding: load balancing on incoming TCP connections
+      ## or UDP packets. (Requires Linux kernel > 3.9)
+  else:
+    const SO_REUSEPORT* = cint(15)
+else:
+  var SO_REUSEPORT* {.importc, header: "<sys/socket.h>".}: cint
+
+when defined(linux) or defined(bsd):
+  var SOCK_CLOEXEC* {.importc, header: "<sys/socket.h>".}: cint
+
+when defined(macosx):
+  # We can't use the NOSIGNAL flag in the `send` function, it has no effect
+  # Instead we should use SO_NOSIGPIPE in setsockopt
+  const
+    MSG_NOSIGNAL* = 0'i32
+  var
+    SO_NOSIGPIPE* {.importc, header: "<sys/socket.h>".}: cint
+elif defined(solaris):
+  # Solaris doesn't have MSG_NOSIGNAL
+  const
+    MSG_NOSIGNAL* = 0'i32
+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.
+
+when defined(haiku):
+  const
+    SIGKILLTHR* = 21 ## BeOS specific: Kill just the thread, not team
+
+when hasSpawnH:
+  when defined(linux):
+    # better be safe than sorry; Linux has this flag, macosx doesn't, don't
+    # know about the other OSes
+
+    # Non-GNU systems like TCC and musl-libc  don't define __USE_GNU, so we
+    # can't get the magic number from spawn.h
+    const POSIX_SPAWN_USEVFORK* = cint(0x40)
+  else:
+    # macosx lacks this, so we define the constant to be 0 to not affect
+    # OR'ing of flags:
+    const POSIX_SPAWN_USEVFORK* = cint(0)
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Exit code, if WIFEXITED(s)
+proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Termination signal, if WIFSIGNALED(s)
+proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Stop signal, if WIFSTOPPED(s)
+proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited normally.
+proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited due to uncaught signal.
+proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child is currently stopped.
+proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child has been continued.
+
+when defined(nimHasStyleChecks):
+  {.pop.}
diff --git a/lib/posix/posix_nintendoswitch.nim b/lib/posix/posix_nintendoswitch.nim
new file mode 100644
index 000000000..b66563695
--- /dev/null
+++ b/lib/posix/posix_nintendoswitch.nim
@@ -0,0 +1,506 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Joey Yakimowich-Payne
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# To be included from posix.nim!
+
+const
+  hasSpawnH = true
+  hasAioH = false
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+
+const SIG_HOLD* = cast[Sighandler](2)
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
+
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: clong  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+            header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    d_ino*: Ino
+    d_type*: int8  # uint8 really!
+    d_name*: array[256, cchar]
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  # no struct FTW on linux
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: cint          ## Count of paths matched by pattern.
+    gl_matchc*: cint          ## Count of paths matching pattern
+    gl_offs*: cint           ## Slots to reserve at the beginning of gl_pathv.
+    gl_flags*: cint
+    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
+    gl_errfunc*: pointer
+    gl_closedir*: pointer
+    gl_readdir*: pointer
+    gl_opendir*: pointer
+    gl_lstat*: pointer
+    gl_stat*: pointer
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_passwd*: cstring
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>".} = pointer
+     ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    decimal_point*: cstring
+    thousands_sep*: cstring
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    currency_symbol*: cstring
+    mon_decimal_point*: cstring
+    mon_thousands_sep*: cstring
+    mon_grouping*: cstring
+    positive_sign*: cstring
+    negative_sign*: cstring
+    int_frac_digits*: char
+    frac_digits*: char
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    p_sign_posn*: char
+    n_sign_posn*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_p_sign_posn*: char
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_passwd*: cstring
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_comment*: cstring
+    pw_gecos*: cstring
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = clong
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = clong
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<sys/types.h>".} = clong
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = cint
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = culong
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = culong
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = culong
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = cuint
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint16
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>",
+                  pure, final.} = object
+    abi: array[56 div sizeof(clong), clong]
+
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<sys/types.h>", pure, final.} = object
+    abi: array[32 div sizeof(clong), clong]
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>",
+                  pure, final.} = object
+    abi: array[48 div sizeof(clonglong), clonglong]
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+  Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = cuint
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>",
+                   pure, final.} = object
+    abi: array[48 div sizeof(clong), clong]
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<sys/types.h>", pure, final.} = object
+    abi: array[4 div sizeof(cint), cint]
+  Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = cint
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<sys/types.h>", pure, final.} = object
+    abi: array[56 div sizeof(clong), clong]
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<sys/types.h>".} = object
+    abi: array[8 div sizeof(clong), clong]
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<sys/types.h>".} = cint
+  Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = culong
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = clong
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = pointer
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = cuint
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = cuint
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,      ## Name of this implementation of the operating system.
+      nodename*,   ## Name of this node within the communications
+                   ## network to which this node is attached, if any.
+      release*,    ## Current release level of this implementation.
+      version*,    ## Current version level of this release.
+      machine*,    ## Name of the hardware type on which the
+                   ## system is running.
+      domainname*: array[65, char]
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+    abi: array[32 div sizeof(clong), clong]
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                           ## For symbolic links, the length in bytes of the
+                           ## pathname contained in the symbolic link.
+                           ## For a shared memory object, the length in bytes.
+                           ## For a typed memory object, the length in bytes.
+                           ## For other file types, the use of this field is
+                           ## unspecified.
+    when StatHasNanoseconds:
+      st_atim*: Timespec  ## Time of last access.
+      pad1: clong
+      st_mtim*: Timespec  ## Time of last data modification.
+      pad2: clong
+      st_ctim*: Timespec  ## Time of last status change.
+      pad3: clong
+    else:
+      st_atime*: Time     ## Time of last access.
+      pad1: clong
+      st_mtime*: Time     ## Time of last data modification.
+      pad2: clong
+      st_ctime*: Time     ## Time of last status change.
+      pad3: clong
+    st_blksize*: Blksize   ## A file system-specific preferred I/O block size
+                           ## for this object. In some file system types, this
+                           ## may vary from file to file.
+    st_blocks*: Blkcnt     ## Number of blocks allocated for this object.
+    reserved: array[2, clong]
+
+
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: culong        ## File system block size.
+    f_frsize*: culong       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt  ## Total number of blocks on file system
+                         ## in units of f_frsize.
+    f_bfree*: Fsblkcnt   ## Total number of free blocks.
+    f_bavail*: Fsblkcnt  ## Number of free blocks available to
+                         ## non-privileged process.
+    f_files*: Fsfilcnt   ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt   ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt  ## Number of file serial numbers available to
+                         ## non-privileged process.
+    f_fsid*: culong         ## File system ID.
+    f_flag*: culong         ## Bit mask of f_flag values.
+    f_namemax*: culong      ## Maximum filename length.
+
+  # No Posix_typed_mem_info
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>", final.} = culong
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_notify*: cint           ## Notification type.
+    sigev_signo*: cint            ## Signal number.
+    sigev_value*: SigVal          ## Signal value.
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_int*: cint    ## integer signal value
+    sival_ptr*: pointer ## pointer signal value;
+
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_flags*: cint  ## Flags.
+    ss_size*: csize_t ## Stack size.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_code*: cint     ## Signal code.
+    si_value*: SigVal  ## Signal value.
+
+  Nl_item* {.importc: "nl_item", header: "<langinfo.h>".} = cint
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time       ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+    abi: array[((64+(sizeof(clong) * 8)-1) div (sizeof(clong) * 8)), clong]
+
+proc si_pid*(info: SigInfo): Pid =
+  ## This might not be correct behavior. si_pid doesn't exist in Switch's
+  ## devkitpro headers
+  raise newException(OSError, "Nintendo switch cannot get si_pid!")
+
+type
+  Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+            final, pure.} = object ## struct aiocb
+    aio_fildes*: cint         ## File descriptor.
+    aio_lio_opcode*: cint     ## Operation to be performed.
+    aio_reqprio*: cint        ## Request priority offset.
+    aio_buf*: pointer         ## Location of buffer.
+    aio_nbytes*: csize_t      ## Length of transfer.
+    aio_sigevent*: SigEvent   ## Signal number and value.
+    next_prio: pointer
+    abs_prio: cint
+    policy: cint
+    error_Code: cint
+    return_value: clong
+    aio_offset*: Off          ## File offset.
+    reserved: array[32, uint8]
+
+type
+  Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                      header: "<spawn.h>", final, pure.} = object
+  Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                               header: "<spawn.h>", final, pure.} = object
+
+# from sys/un.h
+const Sockaddr_un_path_length* = 108
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
+  # cushort really
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cshort
+
+  SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+              pure, final.} = object ## struct sockaddr
+    sa_len: uint8
+    sa_family*: TSa_Family         ## Address family.
+    sa_data*: array[14, char] ## Socket address (variable-length data).
+
+  Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                       header: "<sys/socket.h>",
+                       pure, final.} = object ## struct sockaddr_storage
+    ss_len: uint8
+    ss_family*: TSa_Family ## Address family.
+    ss_padding1: array[64 - sizeof(uint8) - sizeof(cshort), char]
+    ss_align: clonglong
+    ss_padding2: array[
+      128 - sizeof(uint8) - sizeof(cshort) -
+      (64 - sizeof(uint8) - sizeof(cshort)) - 64, char]
+
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cuint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/socket.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t    ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer  ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: csize_t   ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: csize_t ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: csize_t ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+    # data follows...
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_len*: cushort
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+    sin_zero: array[8, uint8]
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: uint32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: uint32    ## Set of interfaces for a scope.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: uint32            ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  TPollfd* {.importc: "struct pollfd", pure, final,
+             header: "<poll.h>".} = object ## struct pollfd
+    fd*: cint        ## The following descriptor being polled.
+    events*: cshort  ## The input event flags (see below).
+    revents*: cshort ## The output event flags (see below).
+
+  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = culong
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc: "_daylight", header: "<time.h>".}: cint
+  timezone* {.importc: "_timezone", header: "<time.h>".}: clong
+
+# Regenerate using detect.nim!
+include posix_nintendoswitch_consts
+
+const POSIX_SPAWN_USEVFORK* = cint(0x40)  # needs _GNU_SOURCE!
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint =  (s shr 8) and 0xff
+proc WIFEXITED*(s:cint) : bool = (s and 0xff) == 0
+proc WTERMSIG*(s:cint): cint = s and 0x7f
+proc WSTOPSIG*(s:cint): cint = WEXITSTATUS(s)
+proc WIFSIGNALED*(s:cint) : bool = ((s and 0x7f) > 0) and ((s and 0x7f) < 0x7f)
+proc WIFSTOPPED*(s:cint) : bool = (s and 0xff) == 0x7f
diff --git a/lib/posix/posix_nintendoswitch_consts.nim b/lib/posix/posix_nintendoswitch_consts.nim
new file mode 100644
index 000000000..8cd8824b5
--- /dev/null
+++ b/lib/posix/posix_nintendoswitch_consts.nim
@@ -0,0 +1,587 @@
+# Generated by detect.nim
+
+
+# <aio.h>
+
+# <dlfcn.h>
+
+# <errno.h>
+const E2BIG* = cint(7)
+const EACCES* = cint(13)
+const EADDRINUSE* = cint(112)
+const EADDRNOTAVAIL* = cint(125)
+const EAFNOSUPPORT* = cint(106)
+const EAGAIN* = cint(11)
+const EALREADY* = cint(120)
+const EBADF* = cint(9)
+const EBADMSG* = cint(77)
+const EBUSY* = cint(16)
+const ECANCELED* = cint(140)
+const ECHILD* = cint(10)
+const ECONNABORTED* = cint(113)
+const ECONNREFUSED* = cint(111)
+const ECONNRESET* = cint(104)
+const EDEADLK* = cint(45)
+const EDESTADDRREQ* = cint(121)
+const EDOM* = cint(33)
+const EDQUOT* = cint(132)
+const EEXIST* = cint(17)
+const EFAULT* = cint(14)
+const EFBIG* = cint(27)
+const EHOSTUNREACH* = cint(118)
+const EIDRM* = cint(36)
+const EILSEQ* = cint(138)
+const EINPROGRESS* = cint(119)
+const EINTR* = cint(4)
+const EINVAL* = cint(22)
+const EIO* = cint(5)
+const EISCONN* = cint(127)
+const EISDIR* = cint(21)
+const ELOOP* = cint(92)
+const EMFILE* = cint(24)
+const EMLINK* = cint(31)
+const EMSGSIZE* = cint(122)
+const EMULTIHOP* = cint(74)
+const ENAMETOOLONG* = cint(91)
+const ENETDOWN* = cint(115)
+const ENETRESET* = cint(126)
+const ENETUNREACH* = cint(114)
+const ENFILE* = cint(23)
+const ENOBUFS* = cint(105)
+const ENODATA* = cint(61)
+const ENODEV* = cint(19)
+const ENOENT* = cint(2)
+const ENOEXEC* = cint(8)
+const ENOLCK* = cint(46)
+const ENOLINK* = cint(67)
+const ENOMEM* = cint(12)
+const ENOMSG* = cint(35)
+const ENOPROTOOPT* = cint(109)
+const ENOSPC* = cint(28)
+const ENOSR* = cint(63)
+const ENOSTR* = cint(60)
+const ENOSYS* = cint(88)
+const ENOTCONN* = cint(128)
+const ENOTDIR* = cint(20)
+const ENOTEMPTY* = cint(90)
+const ENOTSOCK* = cint(108)
+const ENOTSUP* = cint(134)
+const ENOTTY* = cint(25)
+const ENXIO* = cint(6)
+const EOPNOTSUPP* = cint(95)
+const EOVERFLOW* = cint(139)
+const EPERM* = cint(1)
+const EPIPE* = cint(32)
+const EPROTO* = cint(71)
+const EPROTONOSUPPORT* = cint(123)
+const EPROTOTYPE* = cint(107)
+const ERANGE* = cint(34)
+const EROFS* = cint(30)
+const ESPIPE* = cint(29)
+const ESRCH* = cint(3)
+const ESTALE* = cint(133)
+const ETIME* = cint(62)
+const ETIMEDOUT* = cint(116)
+const ETXTBSY* = cint(26)
+const EWOULDBLOCK* = cint(11)
+const EXDEV* = cint(18)
+
+# <fcntl.h>
+const F_DUPFD* = cint(0)
+const F_GETFD* = cint(1)
+const F_SETFD* = cint(2)
+const F_GETFL* = cint(3)
+const F_SETFL* = cint(4)
+const F_GETLK* = cint(7)
+const F_SETLK* = cint(8)
+const F_SETLKW* = cint(9)
+const F_GETOWN* = cint(5)
+const F_SETOWN* = cint(6)
+const FD_CLOEXEC* = cint(1)
+const F_RDLCK* = cint(1)
+const F_UNLCK* = cint(3)
+const F_WRLCK* = cint(2)
+const O_CREAT* = cint(512)
+const O_EXCL* = cint(2048)
+const O_NOCTTY* = cint(32768)
+const O_TRUNC* = cint(1024)
+const O_APPEND* = cint(8)
+const O_NONBLOCK* = cint(16384)
+const O_SYNC* = cint(8192)
+const O_ACCMODE* = cint(3)
+const O_RDONLY* = cint(0)
+const O_RDWR* = cint(2)
+const O_WRONLY* = cint(1)
+
+# <fenv.h>
+
+# <fmtmsg.h>
+
+# <fnmatch.h>
+const FNM_NOMATCH* = cint(1)
+const FNM_PATHNAME* = cint(2)
+const FNM_PERIOD* = cint(4)
+const FNM_NOESCAPE* = cint(1)
+
+# <ftw.h>
+
+# <glob.h>
+const GLOB_APPEND* = cint(1)
+const GLOB_DOOFFS* = cint(2)
+const GLOB_ERR* = cint(4)
+const GLOB_MARK* = cint(8)
+const GLOB_NOCHECK* = cint(16)
+const GLOB_NOSORT* = cint(32)
+const GLOB_NOSPACE* = cint(-1)
+
+# <langinfo.h>
+const CODESET* = cint(0)
+const D_T_FMT* = cint(1)
+const D_FMT* = cint(2)
+const T_FMT* = cint(3)
+const T_FMT_AMPM* = cint(4)
+const AM_STR* = cint(5)
+const PM_STR* = cint(6)
+const DAY_1* = cint(7)
+const DAY_2* = cint(8)
+const DAY_3* = cint(9)
+const DAY_4* = cint(10)
+const DAY_5* = cint(11)
+const DAY_6* = cint(12)
+const DAY_7* = cint(13)
+const ABDAY_1* = cint(14)
+const ABDAY_2* = cint(15)
+const ABDAY_3* = cint(16)
+const ABDAY_4* = cint(17)
+const ABDAY_5* = cint(18)
+const ABDAY_6* = cint(19)
+const ABDAY_7* = cint(20)
+const MON_1* = cint(21)
+const MON_2* = cint(22)
+const MON_3* = cint(23)
+const MON_4* = cint(24)
+const MON_5* = cint(25)
+const MON_6* = cint(26)
+const MON_7* = cint(27)
+const MON_8* = cint(28)
+const MON_9* = cint(29)
+const MON_10* = cint(30)
+const MON_11* = cint(31)
+const MON_12* = cint(32)
+const ABMON_1* = cint(33)
+const ABMON_2* = cint(34)
+const ABMON_3* = cint(35)
+const ABMON_4* = cint(36)
+const ABMON_5* = cint(37)
+const ABMON_6* = cint(38)
+const ABMON_7* = cint(39)
+const ABMON_8* = cint(40)
+const ABMON_9* = cint(41)
+const ABMON_10* = cint(42)
+const ABMON_11* = cint(43)
+const ABMON_12* = cint(44)
+const ERA* = cint(45)
+const ERA_D_FMT* = cint(46)
+const ERA_D_T_FMT* = cint(47)
+const ERA_T_FMT* = cint(48)
+const ALT_DIGITS* = cint(49)
+const RADIXCHAR* = cint(50)
+const THOUSEP* = cint(51)
+const YESEXPR* = cint(52)
+const NOEXPR* = cint(53)
+const CRNCYSTR* = cint(56)
+
+# <locale.h>
+const LC_ALL* = cint(0)
+const LC_COLLATE* = cint(1)
+const LC_CTYPE* = cint(2)
+const LC_MESSAGES* = cint(6)
+const LC_MONETARY* = cint(3)
+const LC_NUMERIC* = cint(4)
+const LC_TIME* = cint(5)
+
+# <netdb.h>
+const IPPORT_RESERVED* = cint(1024)
+const HOST_NOT_FOUND* = cint(1)
+const NO_DATA* = cint(4)
+const NO_RECOVERY* = cint(3)
+const TRY_AGAIN* = cint(2)
+const AI_PASSIVE* = cint(1)
+const AI_CANONNAME* = cint(2)
+const AI_NUMERICHOST* = cint(4)
+const AI_NUMERICSERV* = cint(8)
+const AI_V4MAPPED* = cint(2048)
+const AI_ALL* = cint(256)
+const AI_ADDRCONFIG* = cint(1024)
+const NI_NOFQDN* = cint(1)
+const NI_NUMERICHOST* = cint(2)
+const NI_NAMEREQD* = cint(4)
+const NI_NUMERICSERV* = cint(8)
+const NI_NUMERICSCOPE* = cint(32)
+const NI_DGRAM* = cint(16)
+const EAI_AGAIN* = cint(2)
+const EAI_BADFLAGS* = cint(3)
+const EAI_FAIL* = cint(4)
+const EAI_FAMILY* = cint(5)
+const EAI_MEMORY* = cint(6)
+const EAI_NONAME* = cint(8)
+const EAI_SERVICE* = cint(9)
+const EAI_SOCKTYPE* = cint(10)
+const EAI_SYSTEM* = cint(11)
+const EAI_OVERFLOW* = cint(14)
+
+# <net/if.h>
+const IF_NAMESIZE* = cint(16)
+
+# <netinet/in.h>
+const IPPROTO_IP* = cint(0)
+const IPPROTO_IPV6* = cint(41)
+const IPPROTO_ICMP* = cint(1)
+const IPPROTO_ICMPV6* = cint(58)
+const IPPROTO_RAW* = cint(255)
+const IPPROTO_TCP* = cint(6)
+const IPPROTO_UDP* = cint(17)
+const INADDR_ANY* = InAddrScalar(0)
+const INADDR_LOOPBACK* = InAddrScalar(2130706433)
+const INADDR_BROADCAST* = InAddrScalar(4294967295)
+const INET_ADDRSTRLEN* = cint(16)
+const INET6_ADDRSTRLEN* = cint(46)
+const IPV6_JOIN_GROUP* = cint(12)
+const IPV6_LEAVE_GROUP* = cint(13)
+const IPV6_MULTICAST_HOPS* = cint(10)
+const IPV6_MULTICAST_IF* = cint(9)
+const IPV6_MULTICAST_LOOP* = cint(11)
+const IPV6_UNICAST_HOPS* = cint(4)
+const IPV6_V6ONLY* = cint(27)
+
+# <netinet/tcp.h>
+const TCP_NODELAY* = cint(1)
+
+# <nl_types.h>
+
+# <poll.h>
+const POLLIN* = cshort(1)
+const POLLRDNORM* = cshort(64)
+const POLLRDBAND* = cshort(128)
+const POLLPRI* = cshort(2)
+const POLLOUT* = cshort(4)
+const POLLWRNORM* = cshort(4)
+const POLLWRBAND* = cshort(256)
+const POLLERR* = cshort(8)
+const POLLHUP* = cshort(16)
+const POLLNVAL* = cshort(32)
+
+# <pthread.h>
+const PTHREAD_CREATE_DETACHED* = cint(0)
+const PTHREAD_CREATE_JOINABLE* = cint(1)
+const PTHREAD_EXPLICIT_SCHED* = cint(2)
+const PTHREAD_INHERIT_SCHED* = cint(1)
+const PTHREAD_SCOPE_PROCESS* = cint(0)
+const PTHREAD_SCOPE_SYSTEM* = cint(1)
+
+# <sched.h>
+const SCHED_FIFO* = cint(1)
+const SCHED_RR* = cint(2)
+const SCHED_OTHER* = cint(0)
+
+# <semaphore.h>
+
+# <signal.h>
+const SIGEV_NONE* = cint(1)
+const SIGEV_SIGNAL* = cint(2)
+const SIGEV_THREAD* = cint(3)
+const SIGABRT* = cint(6)
+const SIGALRM* = cint(14)
+const SIGBUS* = cint(10)
+const SIGCHLD* = cint(20)
+const SIGCONT* = cint(19)
+const SIGFPE* = cint(8)
+const SIGHUP* = cint(1)
+const SIGILL* = cint(4)
+const SIGINT* = cint(2)
+const SIGKILL* = cint(9)
+const SIGPIPE* = cint(13)
+const SIGQUIT* = cint(3)
+const SIGSEGV* = cint(11)
+const SIGSTOP* = cint(17)
+const SIGTERM* = cint(15)
+const SIGTSTP* = cint(18)
+const SIGTTIN* = cint(21)
+const SIGTTOU* = cint(22)
+const SIGUSR1* = cint(30)
+const SIGUSR2* = cint(31)
+const SIGPOLL* = cint(23)
+const SIGPROF* = cint(27)
+const SIGSYS* = cint(12)
+const SIGTRAP* = cint(5)
+const SIGURG* = cint(16)
+const SIGVTALRM* = cint(26)
+const SIGXCPU* = cint(24)
+const SIGXFSZ* = cint(25)
+const SA_NOCLDSTOP* = cint(1)
+const SIG_BLOCK* = cint(1)
+const SIG_UNBLOCK* = cint(2)
+const SIG_SETMASK* = cint(0)
+const SS_ONSTACK* = cint(1)
+const SS_DISABLE* = cint(2)
+const MINSIGSTKSZ* = cint(2048)
+const SIGSTKSZ* = cint(8192)
+const SIG_DFL* = cast[Sighandler](0)
+const SIG_ERR* = cast[Sighandler](-1)
+const SIG_IGN* = cast[Sighandler](1)
+
+# <sys/ipc.h>
+
+# <sys/mman.h>
+
+# <sys/resource.h>
+
+# <sys/select.h>
+const FD_SETSIZE* = cint(64)
+
+# <sys/socket.h>
+const MSG_CTRUNC* = cint(32)
+const MSG_DONTROUTE* = cint(4)
+const MSG_EOR* = cint(8)
+const MSG_OOB* = cint(1)
+const SCM_RIGHTS* = cint(1)
+const SO_ACCEPTCONN* = cint(2)
+const SO_BROADCAST* = cint(32)
+const SO_DEBUG* = cint(1)
+const SO_DONTROUTE* = cint(16)
+const SO_ERROR* = cint(4103)
+const SO_KEEPALIVE* = cint(8)
+const SO_LINGER* = cint(128)
+const SO_OOBINLINE* = cint(256)
+const SO_RCVBUF* = cint(4098)
+const SO_RCVLOWAT* = cint(4100)
+const SO_RCVTIMEO* = cint(4102)
+const SO_REUSEADDR* = cint(4)
+const SO_SNDBUF* = cint(4097)
+const SO_SNDLOWAT* = cint(4099)
+const SO_SNDTIMEO* = cint(4101)
+const SO_TYPE* = cint(4104)
+const SOCK_DGRAM* = cint(2)
+const SOCK_RAW* = cint(3)
+const SOCK_SEQPACKET* = cint(5)
+const SOCK_STREAM* = cint(1)
+const SOL_SOCKET* = cint(65535)
+const SOMAXCONN* = cint(128)
+const SO_REUSEPORT* = cint(512)
+const MSG_NOSIGNAL* = cint(131072)
+const MSG_PEEK* = cint(2)
+const MSG_TRUNC* = cint(16)
+const MSG_WAITALL* = cint(64)
+const AF_INET* = cint(2)
+const AF_INET6* = cint(28)
+const AF_UNIX* = cint(1)
+const AF_UNSPEC* = cint(0)
+const SHUT_RD* = cint(0)
+const SHUT_RDWR* = cint(2)
+const SHUT_WR* = cint(1)
+
+# <sys/stat.h>
+const S_IFBLK* = cint(24576)
+const S_IFCHR* = cint(8192)
+const S_IFDIR* = cint(16384)
+const S_IFIFO* = cint(4096)
+const S_IFLNK* = cint(40960)
+const S_IFMT* = cint(61440)
+const S_IFREG* = cint(32768)
+const S_IFSOCK* = cint(49152)
+const S_IRGRP* = cint(32)
+const S_IROTH* = cint(4)
+const S_IRUSR* = cint(256)
+const S_IRWXG* = cint(56)
+const S_IRWXO* = cint(7)
+const S_IRWXU* = cint(448)
+const S_ISGID* = cint(1024)
+const S_ISUID* = cint(2048)
+const S_ISVTX* = cint(512)
+const S_IWGRP* = cint(16)
+const S_IWOTH* = cint(2)
+const S_IWUSR* = cint(128)
+const S_IXGRP* = cint(8)
+const S_IXOTH* = cint(1)
+const S_IXUSR* = cint(64)
+
+# <sys/statvfs.h>
+const ST_RDONLY* = cint(1)
+const ST_NOSUID* = cint(2)
+
+# <sys/wait.h>
+const WNOHANG* = cint(1)
+const WUNTRACED* = cint(2)
+
+# <spawn.h>
+const POSIX_SPAWN_RESETIDS* = cint(1)
+const POSIX_SPAWN_SETPGROUP* = cint(2)
+const POSIX_SPAWN_SETSCHEDPARAM* = cint(4)
+const POSIX_SPAWN_SETSCHEDULER* = cint(8)
+const POSIX_SPAWN_SETSIGDEF* = cint(16)
+const POSIX_SPAWN_SETSIGMASK* = cint(32)
+
+# <stdio.h>
+const IOFBF* = cint(0)
+const IONBF* = cint(2)
+
+# <time.h>
+const CLOCKS_PER_SEC* = clong(100)
+const CLOCK_REALTIME* = cint(1)
+const TIMER_ABSTIME* = cint(4)
+const CLOCK_MONOTONIC* = cint(4)
+
+# <unistd.h>
+const F_OK* = cint(0)
+const R_OK* = cint(4)
+const W_OK* = cint(2)
+const X_OK* = cint(1)
+const F_LOCK* = cint(1)
+const F_TEST* = cint(3)
+const F_TLOCK* = cint(2)
+const F_ULOCK* = cint(0)
+const PC_2_SYMLINKS* = cint(13)
+const PC_ALLOC_SIZE_MIN* = cint(15)
+const PC_ASYNC_IO* = cint(9)
+const PC_CHOWN_RESTRICTED* = cint(6)
+const PC_FILESIZEBITS* = cint(12)
+const PC_LINK_MAX* = cint(0)
+const PC_MAX_CANON* = cint(1)
+const PC_MAX_INPUT* = cint(2)
+const PC_NAME_MAX* = cint(3)
+const PC_NO_TRUNC* = cint(7)
+const PC_PATH_MAX* = cint(4)
+const PC_PIPE_BUF* = cint(5)
+const PC_PRIO_IO* = cint(10)
+const PC_REC_INCR_XFER_SIZE* = cint(16)
+const PC_REC_MIN_XFER_SIZE* = cint(18)
+const PC_REC_XFER_ALIGN* = cint(19)
+const PC_SYMLINK_MAX* = cint(14)
+const PC_SYNC_IO* = cint(11)
+const PC_VDISABLE* = cint(8)
+const SC_2_C_BIND* = cint(108)
+const SC_2_C_DEV* = cint(109)
+const SC_2_CHAR_TERM* = cint(107)
+const SC_2_FORT_DEV* = cint(110)
+const SC_2_FORT_RUN* = cint(111)
+const SC_2_LOCALEDEF* = cint(112)
+const SC_2_PBS* = cint(113)
+const SC_2_PBS_ACCOUNTING* = cint(114)
+const SC_2_PBS_CHECKPOINT* = cint(115)
+const SC_2_PBS_LOCATE* = cint(116)
+const SC_2_PBS_MESSAGE* = cint(117)
+const SC_2_PBS_TRACK* = cint(118)
+const SC_2_SW_DEV* = cint(119)
+const SC_2_UPE* = cint(120)
+const SC_2_VERSION* = cint(121)
+const SC_ADVISORY_INFO* = cint(54)
+const SC_AIO_LISTIO_MAX* = cint(34)
+const SC_AIO_MAX* = cint(35)
+const SC_AIO_PRIO_DELTA_MAX* = cint(36)
+const SC_ARG_MAX* = cint(0)
+const SC_ASYNCHRONOUS_IO* = cint(21)
+const SC_ATEXIT_MAX* = cint(55)
+const SC_BARRIERS* = cint(56)
+const SC_BC_BASE_MAX* = cint(57)
+const SC_BC_DIM_MAX* = cint(58)
+const SC_BC_SCALE_MAX* = cint(59)
+const SC_BC_STRING_MAX* = cint(60)
+const SC_CHILD_MAX* = cint(1)
+const SC_CLK_TCK* = cint(2)
+const SC_CLOCK_SELECTION* = cint(61)
+const SC_COLL_WEIGHTS_MAX* = cint(62)
+const SC_CPUTIME* = cint(63)
+const SC_DELAYTIMER_MAX* = cint(37)
+const SC_EXPR_NEST_MAX* = cint(64)
+const SC_FSYNC* = cint(22)
+const SC_GETGR_R_SIZE_MAX* = cint(50)
+const SC_GETPW_R_SIZE_MAX* = cint(51)
+const SC_HOST_NAME_MAX* = cint(65)
+const SC_IOV_MAX* = cint(66)
+const SC_IPV6* = cint(67)
+const SC_JOB_CONTROL* = cint(5)
+const SC_LINE_MAX* = cint(68)
+const SC_LOGIN_NAME_MAX* = cint(52)
+const SC_MAPPED_FILES* = cint(23)
+const SC_MEMLOCK* = cint(24)
+const SC_MEMLOCK_RANGE* = cint(25)
+const SC_MEMORY_PROTECTION* = cint(26)
+const SC_MESSAGE_PASSING* = cint(27)
+const SC_MONOTONIC_CLOCK* = cint(69)
+const SC_MQ_OPEN_MAX* = cint(13)
+const SC_MQ_PRIO_MAX* = cint(14)
+const SC_NGROUPS_MAX* = cint(3)
+const SC_OPEN_MAX* = cint(4)
+const SC_PAGE_SIZE* = cint(8)
+const SC_PRIORITIZED_IO* = cint(28)
+const SC_PRIORITY_SCHEDULING* = cint(101)
+const SC_RAW_SOCKETS* = cint(70)
+const SC_RE_DUP_MAX* = cint(73)
+const SC_READER_WRITER_LOCKS* = cint(71)
+const SC_REALTIME_SIGNALS* = cint(29)
+const SC_REGEXP* = cint(72)
+const SC_RTSIG_MAX* = cint(15)
+const SC_SAVED_IDS* = cint(6)
+const SC_SEM_NSEMS_MAX* = cint(16)
+const SC_SEM_VALUE_MAX* = cint(17)
+const SC_SEMAPHORES* = cint(30)
+const SC_SHARED_MEMORY_OBJECTS* = cint(31)
+const SC_SHELL* = cint(74)
+const SC_SIGQUEUE_MAX* = cint(18)
+const SC_SPAWN* = cint(75)
+const SC_SPIN_LOCKS* = cint(76)
+const SC_SPORADIC_SERVER* = cint(77)
+const SC_SS_REPL_MAX* = cint(78)
+const SC_STREAM_MAX* = cint(100)
+const SC_SYMLOOP_MAX* = cint(79)
+const SC_SYNCHRONIZED_IO* = cint(32)
+const SC_THREAD_ATTR_STACKADDR* = cint(43)
+const SC_THREAD_ATTR_STACKSIZE* = cint(44)
+const SC_THREAD_CPUTIME* = cint(80)
+const SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(53)
+const SC_THREAD_KEYS_MAX* = cint(38)
+const SC_THREAD_PRIO_INHERIT* = cint(46)
+const SC_THREAD_PRIO_PROTECT* = cint(47)
+const SC_THREAD_PRIORITY_SCHEDULING* = cint(45)
+const SC_THREAD_PROCESS_SHARED* = cint(48)
+const SC_THREAD_SAFE_FUNCTIONS* = cint(49)
+const SC_THREAD_SPORADIC_SERVER* = cint(81)
+const SC_THREAD_STACK_MIN* = cint(39)
+const SC_THREAD_THREADS_MAX* = cint(40)
+const SC_THREADS* = cint(42)
+const SC_TIMEOUTS* = cint(82)
+const SC_TIMER_MAX* = cint(19)
+const SC_TIMERS* = cint(33)
+const SC_TRACE* = cint(83)
+const SC_TRACE_EVENT_FILTER* = cint(84)
+const SC_TRACE_EVENT_NAME_MAX* = cint(85)
+const SC_TRACE_INHERIT* = cint(86)
+const SC_TRACE_LOG* = cint(87)
+const SC_TRACE_NAME_MAX* = cint(88)
+const SC_TRACE_SYS_MAX* = cint(89)
+const SC_TRACE_USER_EVENT_MAX* = cint(90)
+const SC_TTY_NAME_MAX* = cint(41)
+const SC_TYPED_MEMORY_OBJECTS* = cint(91)
+const SC_TZNAME_MAX* = cint(20)
+const SC_V6_ILP32_OFF32* = cint(92)
+const SC_V6_ILP32_OFFBIG* = cint(93)
+const SC_V6_LP64_OFF64* = cint(94)
+const SC_V6_LPBIG_OFFBIG* = cint(95)
+const SC_VERSION* = cint(7)
+const SC_XBS5_ILP32_OFF32* = cint(92)
+const SC_XBS5_ILP32_OFFBIG* = cint(93)
+const SC_XBS5_LP64_OFF64* = cint(94)
+const SC_XBS5_LPBIG_OFFBIG* = cint(95)
+const SC_XOPEN_CRYPT* = cint(96)
+const SC_XOPEN_ENH_I18N* = cint(97)
+const SC_XOPEN_LEGACY* = cint(98)
+const SC_XOPEN_REALTIME* = cint(99)
+const SC_XOPEN_REALTIME_THREADS* = cint(102)
+const SC_XOPEN_SHM* = cint(103)
+const SC_XOPEN_STREAMS* = cint(104)
+const SC_XOPEN_UNIX* = cint(105)
+const SC_XOPEN_VERSION* = cint(106)
+const SC_NPROCESSORS_ONLN* = cint(10)
+const SEEK_SET* = cint(0)
+const SEEK_CUR* = cint(1)
+const SEEK_END* = cint(2)
diff --git a/lib/posix/posix_openbsd_amd64.nim b/lib/posix/posix_openbsd_amd64.nim
new file mode 100644
index 000000000..184cd89c0
--- /dev/null
+++ b/lib/posix/posix_openbsd_amd64.nim
@@ -0,0 +1,565 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+const
+  hasSpawnH = true # should exist for every Posix system nowadays
+  hasAioH = false
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+    ## A type representing a directory stream.
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct clonglong
+
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: int  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+             header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    when defined(haiku):
+      d_dev*: Dev ## Device (not POSIX)
+      d_pdev*: Dev ## Parent device (only for queries) (not POSIX)
+    d_ino*: Ino  ## File serial number.
+    when defined(dragonfly):
+      # DragonflyBSD doesn't have `d_reclen` field.
+      d_type*: uint8
+    elif defined(linux) or defined(macosx) or defined(freebsd) or
+         defined(netbsd) or defined(openbsd) or defined(genode):
+      d_reclen*: cshort ## Length of this record. (not POSIX)
+      d_type*: int8 ## Type of file; not supported by all filesystem types.
+                    ## (not POSIX)
+      when defined(linux) or defined(openbsd):
+        d_off*: Off  ## Not an offset. Value that `telldir()` would return.
+    elif defined(haiku):
+      d_pino*: Ino ## Parent inode (only for queries) (not POSIX)
+      d_reclen*: cushort ## Length of this record. (not POSIX)
+
+    d_name*: array[0..255, char] ## Name of entry.
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
+    base*: cint
+    level*: cint
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: int          ## Count of paths matched by pattern.
+    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
+    gl_offs*: int           ## Slots to reserve at the beginning of gl_pathv.
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} =
+    object ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    currency_symbol*: cstring
+    decimal_point*: cstring
+    frac_digits*: char
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    int_frac_digits*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_p_sign_posn*: char
+    mon_decimal_point*: cstring
+    mon_grouping*: cstring
+    mon_thousands_sep*: cstring
+    negative_sign*: cstring
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    n_sign_posn*: char
+    positive_sign*: cstring
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    p_sign_posn*: char
+    thousands_sep*: cstring
+
+  Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
+  MqAttr* {.importc: "struct mq_attr",
+             header: "<mqueue.h>",
+             final, pure.} = object ## message queue attribute
+    mq_flags*: int   ## Message queue flags.
+    mq_maxmsg*: int  ## Maximum number of messages.
+    mq_msgsize*: int ## Maximum message size.
+    mq_curmsgs*: int ## Number of messages currently queued.
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int32
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = (
+    when defined(freebsd):
+      uint32
+    else:
+      int32)
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = int
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = int
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = uint32
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<pthread.h>".} = int
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<pthread.h>".} = int
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<pthread.h>".} = int
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<pthread.h>".} = int
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<pthread.h>".} = int
+  Pthread_key* {.importc: "pthread_key_t", header: "<pthread.h>".} = int
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<pthread.h>".} = int
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<pthread.h>".} = int
+  Pthread_once* {.importc: "pthread_once_t", header: "<pthread.h>".} = int
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<pthread.h>".} = int
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<pthread.h>".} = int
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<pthread.h>".} = int
+  Pthread* {.importc: "pthread_t", header: "<pthread.h>".} = int
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int32
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = int
+  Trace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int
+  Trace_event_id* {.importc: "trace_event_id_t",
+                     header: "<sys/types.h>".} = int
+  Trace_event_set* {.importc: "trace_event_set_t",
+                      header: "<sys/types.h>".} = int
+  Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,      ## Name of this implementation of the operating system.
+      nodename*,   ## Name of this node within the communications
+                   ## network to which this node is attached, if any.
+      release*,    ## Current release level of this implementation.
+      version*,    ## Current version level of this release.
+      machine*: array[0..255, char] ## Name of the hardware type on which the
+                                     ## system is running.
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+  Ipc_perm* {.importc: "struct ipc_perm",
+               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
+    uid*: Uid    ## Owner's user ID.
+    gid*: Gid    ## Owner's group ID.
+    cuid*: Uid   ## Creator's user ID.
+    cgid*: Gid   ## Creator's group ID.
+    mode*: Mode  ## Read/write permission.
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                          ## For symbolic links, the length in bytes of the
+                          ## pathname contained in the symbolic link.
+                          ## For a shared memory object, the length in bytes.
+                          ## For a typed memory object, the length in bytes.
+                          ## For other file types, the use of this field is
+                          ## unspecified.
+    when StatHasNanoseconds:
+      st_atim*: Timespec  ## Time of last access.
+      st_mtim*: Timespec  ## Time of last data modification.
+      st_ctim*: Timespec  ## Time of last status change.
+    else:
+      st_atime*: Time     ## Time of last access.
+      st_mtime*: Time     ## Time of last data modification.
+      st_ctime*: Time     ## Time of last status change.
+    st_blksize*: Blksize  ## A file system-specific preferred I/O block size
+                          ## for this object. In some file system types, this
+                          ## may vary from file to file.
+    st_blocks*: Blkcnt    ## Number of blocks allocated for this object.
+
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: int        ## File system block size.
+    f_frsize*: int       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt  ## Total number of blocks on file system
+                         ## in units of f_frsize.
+    f_bfree*: Fsblkcnt   ## Total number of free blocks.
+    f_bavail*: Fsblkcnt  ## Number of free blocks available to
+                         ## non-privileged process.
+    f_files*: Fsfilcnt   ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt   ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt  ## Number of file serial numbers available to
+                         ## non-privileged process.
+    f_fsid*: int         ## File system ID.
+    f_flag*: int         ## Bit mask of f_flag values.
+    f_namemax*: int      ## Maximum filename length.
+
+  Posix_typed_mem_info* {.importc: "struct posix_typed_mem_info",
+                           header: "<sys/mman.h>", final, pure.} = object
+    posix_tmi_length*: int
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_notify*: cint           ## Notification type.
+    sigev_signo*: cint            ## Signal number.
+    sigev_value*: SigVal          ## Signal value.
+    sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
+    sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_ptr*: pointer ## pointer signal value;
+                        ## integer signal value not defined!
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+    sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_size*: int    ## Stack size.
+    ss_flags*: cint  ## Flags.
+
+  SigStack* {.importc: "struct sigstack",
+               header: "<signal.h>", final, pure.} = object ## struct sigstack
+    ss_onstack*: cint ## Non-zero when signal stack is in use.
+    ss_sp*: pointer   ## Signal stack pointer.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_code*: cint     ## Signal code.
+    si_errno*: cint    ## If non-zero, an errno value associated with
+                       ## this signal, as defined in <errno.h>.
+    si_pid*: Pid       ## Sending process ID.
+    si_uid*: Uid       ## Real user ID of sending process.
+    si_addr*: pointer  ## Address of faulting instruction.
+    si_status*: cint   ## Exit value or signal.
+    si_band*: int      ## Band event for SIGPOLL.
+    si_value*: SigVal  ## Signal value.
+
+  Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
+  Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+    sched_ss_low_priority*: cint     ## Low scheduling priority for
+                                     ## sporadic server.
+    sched_ss_repl_period*: Timespec  ## Replenishment period for
+                                     ## sporadic server.
+    sched_ss_init_budget*: Timespec  ## Initial budget for sporadic server.
+    sched_ss_max_repl*: cint         ## Maximum pending replenishments for
+                                     ## sporadic server.
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+  # the following aren't actually defined, but they're here to keep things happy for now
+  Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
+               final, pure.} = object
+  Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
+               final, pure.} = object ## ucontext_t
+    uc_link*: ptr Ucontext  ## Pointer to the context that is resumed
+                            ## when this context returns.
+    uc_sigmask*: Sigset     ## The set of signals that are blocked when this
+                            ## context is active.
+    uc_stack*: Stack        ## The stack used by this context.
+    uc_mcontext*: Mcontext  ## A machine-specific representation of the saved
+                            ## context.
+
+when hasAioH:
+  type
+    Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+              final, pure.} = object ## struct aiocb
+      aio_fildes*: cint         ## File descriptor.
+      aio_offset*: Off          ## File offset.
+      aio_buf*: pointer         ## Location of buffer.
+      aio_nbytes*: int          ## Length of transfer.
+      aio_reqprio*: cint        ## Request priority offset.
+      aio_sigevent*: SigEvent   ## Signal number and value.
+      aio_lio_opcode: cint      ## Operation to be performed.
+
+when hasSpawnH:
+  type
+    Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                        header: "<spawn.h>", final, pure.} = object
+    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                                 header: "<spawn.h>", final, pure.} = object
+
+# according to http://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/un.h.html
+# this is >=92
+const Sockaddr_un_path_length* = 92
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = uint8
+
+  SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+              pure, final.} = object ## struct sockaddr
+    sa_family*: TSa_Family         ## Address family.
+    sa_data*: array[0..255, char] ## Socket address (variable-length data).
+
+  Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
+              pure, final.} = object ## struct sockaddr_un
+    sun_family*: TSa_Family         ## Address family.
+    sun_path*: array[0..Sockaddr_un_path_length-1, char] ## Socket path
+
+  Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                       header: "<sys/socket.h>",
+                       pure, final.} = object ## struct sockaddr_storage
+    ss_family*: TSa_Family ## Address family.
+
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/uio.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t    ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer  ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: cint   ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: SockLen ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: SockLen ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: uint32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: uint32    ## Set of interfaces for a scope.
+
+  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
+                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
+    ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
+    ipv6mr_interface*: cint     ## Interface index.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: uint32            ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  TPollfd* {.importc: "struct pollfd", pure, final,
+             header: "<poll.h>".} = object ## struct pollfd
+    fd*: cint        ## The following descriptor being polled.
+    events*: cshort  ## The input event flags (see below).
+    revents*: cshort ## The output event flags (see below).
+
+  Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = cint
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc, header: "<time.h>".}: cint
+  timezone* {.importc, header: "<time.h>".}: int
+
+# Regenerate using detect.nim!
+include posix_other_consts
+
+var
+  MAP_POPULATE*: cint = 0
+
+when defined(nimdoc):
+  const SO_REUSEPORT* = cint(0x0200)
+else:
+  var SO_REUSEPORT* {.importc, header: "<sys/socket.h>".}: cint
+
+var SOCK_CLOEXEC* {.importc, header: "<sys/socket.h>".}: cint
+
+var MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
+
+when hasSpawnH:
+    # openbsd lacks this, so we define the constant to be 0 to not affect
+    # OR'ing of flags:
+    const POSIX_SPAWN_USEVFORK* = cint(0)
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Exit code, if WIFEXITED(s)
+proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Termination signal, if WIFSIGNALED(s)
+proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Stop signal, if WIFSTOPPED(s)
+proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited normally.
+proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited due to uncaught signal.
+proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child is currently stopped.
+proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child has been continued.
+
+when defined(nimHasStyleChecks):
+  {.pop.}
diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim
new file mode 100644
index 000000000..ea8731405
--- /dev/null
+++ b/lib/posix/posix_other.nim
@@ -0,0 +1,706 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+when defined(freertos) or defined(zephyr):
+  const
+    hasSpawnH = false # should exist for every Posix system nowadays
+    hasAioH = false
+else:
+  const
+    hasSpawnH = true # should exist for every Posix system nowadays
+    hasAioH = defined(linux)
+
+when defined(linux) and not defined(android):
+  # On Linux:
+  # timer_{create,delete,settime,gettime},
+  # clock_{getcpuclockid, getres, gettime, nanosleep, settime} lives in librt
+  {.passl: "-lrt".}
+when defined(solaris):
+  # On Solaris hstrerror lives in libresolv
+  {.passl: "-lresolv".}
+
+type
+  DIR* {.importc: "DIR", header: "<dirent.h>",
+          incompleteStruct.} = object
+    ## A type representing a directory stream.
+
+type
+  SocketHandle* = distinct cint # The type used to represent socket descriptors
+
+type
+  Time* {.importc: "time_t", header: "<time.h>".} = distinct (
+    when defined(nimUse64BitCTime):
+      int64
+    else:
+      clong
+  )
+
+  Timespec* {.importc: "struct timespec",
+               header: "<time.h>", final, pure.} = object ## struct timespec
+    tv_sec*: Time  ## Seconds.
+    tv_nsec*: int  ## Nanoseconds.
+
+  Dirent* {.importc: "struct dirent",
+             header: "<dirent.h>", final, pure.} = object ## dirent_t struct
+    when defined(haiku):
+      d_dev*: Dev ## Device (not POSIX)
+      d_pdev*: Dev ## Parent device (only for queries) (not POSIX)
+    d_ino*: Ino  ## File serial number.
+    when defined(dragonfly):
+      # DragonflyBSD doesn't have `d_reclen` field.
+      d_type*: uint8
+    elif defined(linux) or defined(macosx) or defined(freebsd) or
+         defined(netbsd) or defined(openbsd) or defined(genode):
+      d_reclen*: cshort ## Length of this record. (not POSIX)
+      d_type*: int8 ## Type of file; not supported by all filesystem types.
+                    ## (not POSIX)
+      when defined(linux) or defined(openbsd):
+        d_off*: Off  ## Not an offset. Value that `telldir()` would return.
+    elif defined(haiku):
+      d_pino*: Ino ## Parent inode (only for queries) (not POSIX)
+      d_reclen*: cushort ## Length of this record. (not POSIX)
+
+    d_name*: array[0..255, char] ## Name of entry.
+
+  Tflock* {.importc: "struct flock", final, pure,
+            header: "<fcntl.h>".} = object ## flock type
+    l_type*: cshort   ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
+    l_whence*: cshort ## Flag for starting offset.
+    l_start*: Off     ## Relative offset in bytes.
+    l_len*: Off       ## Size; if 0 then until EOF.
+    l_pid*: Pid      ## Process ID of the process holding the lock;
+                      ## returned with F_GETLK.
+
+  FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
+    base*: cint
+    level*: cint
+
+  Glob* {.importc: "glob_t", header: "<glob.h>",
+           final, pure.} = object ## glob_t
+    gl_pathc*: int          ## Count of paths matched by pattern.
+    gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
+    gl_offs*: int           ## Slots to reserve at the beginning of gl_pathv.
+
+  Group* {.importc: "struct group", header: "<grp.h>",
+            final, pure.} = object ## struct group
+    gr_name*: cstring     ## The name of the group.
+    gr_gid*: Gid         ## Numerical group ID.
+    gr_mem*: cstringArray ## Pointer to a null-terminated array of character
+                          ## pointers to member names.
+
+  Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} =
+    object ## Identifies the conversion from one codeset to another.
+
+  Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
+            pure.} = object
+    currency_symbol*: cstring
+    decimal_point*: cstring
+    frac_digits*: char
+    grouping*: cstring
+    int_curr_symbol*: cstring
+    int_frac_digits*: char
+    int_n_cs_precedes*: char
+    int_n_sep_by_space*: char
+    int_n_sign_posn*: char
+    int_p_cs_precedes*: char
+    int_p_sep_by_space*: char
+    int_p_sign_posn*: char
+    mon_decimal_point*: cstring
+    mon_grouping*: cstring
+    mon_thousands_sep*: cstring
+    negative_sign*: cstring
+    n_cs_precedes*: char
+    n_sep_by_space*: char
+    n_sign_posn*: char
+    positive_sign*: cstring
+    p_cs_precedes*: char
+    p_sep_by_space*: char
+    p_sign_posn*: char
+    thousands_sep*: cstring
+
+  Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
+  MqAttr* {.importc: "struct mq_attr",
+             header: "<mqueue.h>",
+             final, pure.} = object ## message queue attribute
+    mq_flags*: int   ## Message queue flags.
+    mq_maxmsg*: int  ## Maximum number of messages.
+    mq_msgsize*: int ## Maximum message size.
+    mq_curmsgs*: int ## Number of messages currently queued.
+
+  Passwd* {.importc: "struct passwd", header: "<pwd.h>",
+             final, pure.} = object ## struct passwd
+    pw_name*: cstring   ## User's login name.
+    pw_uid*: Uid        ## Numerical user ID.
+    pw_gid*: Gid        ## Numerical group ID.
+    pw_dir*: cstring    ## Initial working directory.
+    pw_shell*: cstring  ## Program to use as shell.
+
+  Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int
+    ## used for file block counts
+  Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int
+    ## used for block sizes
+  Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
+  ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
+  Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int
+  Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
+  Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
+  Gid* {.importc: "gid_t", header: "<sys/types.h>".} = int
+  Id* {.importc: "id_t", header: "<sys/types.h>".} = int
+  Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
+  Key* {.importc: "key_t", header: "<sys/types.h>".} = int
+  Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
+    when defined(android) or defined(macos) or defined(macosx) or
+        (defined(bsd) and not defined(openbsd) and not defined(netbsd)):
+      uint16
+    else:
+      uint32
+  )
+  Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int
+  Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
+  Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
+  Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int
+  Pthread_barrier* {.importc: "pthread_barrier_t",
+                      header: "<sys/types.h>".} = int
+  Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
+                          header: "<sys/types.h>".} = int
+  Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = int
+  Pthread_condattr* {.importc: "pthread_condattr_t",
+                       header: "<sys/types.h>".} = int
+  Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = int
+  Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
+  Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
+                        header: "<sys/types.h>".} = int
+  Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = int
+  Pthread_rwlock* {.importc: "pthread_rwlock_t",
+                     header: "<sys/types.h>".} = int
+  Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
+                         header: "<sys/types.h>".} = int
+  Pthread_spinlock* {.importc: "pthread_spinlock_t",
+                       header: "<sys/types.h>".} = int
+  Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = int
+  Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int
+  #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
+  Timer* {.importc: "timer_t", header: "<sys/types.h>".} = int
+  Trace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int
+  Trace_event_id* {.importc: "trace_event_id_t",
+                     header: "<sys/types.h>".} = int
+  Trace_event_set* {.importc: "trace_event_set_t",
+                      header: "<sys/types.h>".} = int
+  Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
+  Uid* {.importc: "uid_t", header: "<sys/types.h>".} = int
+  Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
+
+  Utsname* {.importc: "struct utsname",
+              header: "<sys/utsname.h>",
+              final, pure.} = object ## struct utsname
+    sysname*,      ## Name of this implementation of the operating system.
+      nodename*,   ## Name of this node within the communications
+                   ## network to which this node is attached, if any.
+      release*,    ## Current release level of this implementation.
+      version*,    ## Current version level of this release.
+      machine*: array[0..255, char] ## Name of the hardware type on which the
+                                     ## system is running.
+
+  Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
+  Ipc_perm* {.importc: "struct ipc_perm",
+               header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
+    uid*: Uid    ## Owner's user ID.
+    gid*: Gid    ## Owner's group ID.
+    cuid*: Uid   ## Creator's user ID.
+    cgid*: Gid   ## Creator's group ID.
+    mode*: Mode  ## Read/write permission.
+
+  Stat* {.importc: "struct stat",
+           header: "<sys/stat.h>", final, pure.} = object ## struct stat
+    st_dev*: Dev          ## Device ID of device containing file.
+    st_ino*: Ino          ## File serial number.
+    st_mode*: Mode        ## Mode of file (see below).
+    st_nlink*: Nlink      ## Number of hard links to the file.
+    st_uid*: Uid          ## User ID of file.
+    st_gid*: Gid          ## Group ID of file.
+    st_rdev*: Dev         ## Device ID (if file is character or block special).
+    st_size*: Off         ## For regular files, the file size in bytes.
+                          ## For symbolic links, the length in bytes of the
+                          ## pathname contained in the symbolic link.
+                          ## For a shared memory object, the length in bytes.
+                          ## For a typed memory object, the length in bytes.
+                          ## For other file types, the use of this field is
+                          ## unspecified.
+    when StatHasNanoseconds:
+      st_atim*: Timespec  ## Time of last access.
+      st_mtim*: Timespec  ## Time of last data modification.
+      st_ctim*: Timespec  ## Time of last status change.
+    else:
+      st_atime*: Time     ## Time of last access.
+      st_mtime*: Time     ## Time of last data modification.
+      st_ctime*: Time     ## Time of last status change.
+    st_blksize*: Blksize  ## A file system-specific preferred I/O block size
+                          ## for this object. In some file system types, this
+                          ## may vary from file to file.
+    st_blocks*: Blkcnt    ## Number of blocks allocated for this object.
+
+
+  Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
+              final, pure.} = object ## struct statvfs
+    f_bsize*: int        ## File system block size.
+    f_frsize*: int       ## Fundamental file system block size.
+    f_blocks*: Fsblkcnt  ## Total number of blocks on file system
+                         ## in units of f_frsize.
+    f_bfree*: Fsblkcnt   ## Total number of free blocks.
+    f_bavail*: Fsblkcnt  ## Number of free blocks available to
+                         ## non-privileged process.
+    f_files*: Fsfilcnt   ## Total number of file serial numbers.
+    f_ffree*: Fsfilcnt   ## Total number of free file serial numbers.
+    f_favail*: Fsfilcnt  ## Number of file serial numbers available to
+                         ## non-privileged process.
+    f_fsid*: int         ## File system ID.
+    f_flag*: int         ## Bit mask of f_flag values.
+    f_namemax*: int      ## Maximum filename length.
+
+  Posix_typed_mem_info* {.importc: "struct posix_typed_mem_info",
+                           header: "<sys/mman.h>", final, pure.} = object
+    posix_tmi_length*: int
+
+  Tm* {.importc: "struct tm", header: "<time.h>",
+         final, pure.} = object ## struct tm
+    tm_sec*: cint   ## Seconds [0,60].
+    tm_min*: cint   ## Minutes [0,59].
+    tm_hour*: cint  ## Hour [0,23].
+    tm_mday*: cint  ## Day of month [1,31].
+    tm_mon*: cint   ## Month of year [0,11].
+    tm_year*: cint  ## Years since 1900.
+    tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+    tm_yday*: cint  ## Day of year [0,365].
+    tm_isdst*: cint ## Daylight Savings flag.
+  Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
+                 final, pure.} = object ## struct itimerspec
+    it_interval*: Timespec  ## Timer period.
+    it_value*: Timespec     ## Timer expiration.
+
+  Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
+    ## Possibly volatile-qualified integer type of an object that can be
+    ## accessed as an atomic entity, even in the presence of asynchronous
+    ## interrupts.
+  Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
+
+  SigEvent* {.importc: "struct sigevent",
+               header: "<signal.h>", final, pure.} = object ## struct sigevent
+    sigev_notify*: cint           ## Notification type.
+    sigev_signo*: cint            ## Signal number.
+    sigev_value*: SigVal          ## Signal value.
+    sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
+    sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
+
+  SigVal* {.importc: "union sigval",
+             header: "<signal.h>", final, pure.} = object ## struct sigval
+    sival_ptr*: pointer ## pointer signal value;
+                        ## integer signal value not defined!
+  Sigaction* {.importc: "struct sigaction",
+                header: "<signal.h>", final, pure.} = object ## struct sigaction
+    sa_handler*: proc (x: cint) {.noconv.}  ## Pointer to a signal-catching
+                                            ## function or one of the macros
+                                            ## SIG_IGN or SIG_DFL.
+    sa_mask*: Sigset ## Set of signals to be blocked during execution of
+                      ## the signal handling function.
+    sa_flags*: cint   ## Special flags.
+    sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
+
+  Stack* {.importc: "stack_t",
+            header: "<signal.h>", final, pure.} = object ## stack_t
+    ss_sp*: pointer  ## Stack base or pointer.
+    ss_size*: int    ## Stack size.
+    ss_flags*: cint  ## Flags.
+
+  SigStack* {.importc: "struct sigstack",
+               header: "<signal.h>", final, pure.} = object ## struct sigstack
+    ss_onstack*: cint ## Non-zero when signal stack is in use.
+    ss_sp*: pointer   ## Signal stack pointer.
+
+  SigInfo* {.importc: "siginfo_t",
+              header: "<signal.h>", final, pure.} = object ## siginfo_t
+    si_signo*: cint    ## Signal number.
+    si_code*: cint     ## Signal code.
+    si_errno*: cint    ## If non-zero, an errno value associated with
+                       ## this signal, as defined in <errno.h>.
+    si_pid*: Pid       ## Sending process ID.
+    si_uid*: Uid       ## Real user ID of sending process.
+    si_addr*: pointer  ## Address of faulting instruction.
+    si_status*: cint   ## Exit value or signal.
+    si_band*: int      ## Band event for SIGPOLL.
+    si_value*: SigVal  ## Signal value.
+
+  Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
+  Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
+
+  Sched_param* {.importc: "struct sched_param",
+                  header: "<sched.h>",
+                  final, pure.} = object ## struct sched_param
+    sched_priority*: cint
+    sched_ss_low_priority*: cint     ## Low scheduling priority for
+                                     ## sporadic server.
+    sched_ss_repl_period*: Timespec  ## Replenishment period for
+                                     ## sporadic server.
+    sched_ss_init_budget*: Timespec  ## Initial budget for sporadic server.
+    sched_ss_max_repl*: cint         ## Maximum pending replenishments for
+                                     ## sporadic server.
+
+  Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
+             final, pure.} = object ## struct timeval
+    tv_sec*: Time ## Seconds.
+    tv_usec*: Suseconds ## Microseconds.
+  TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
+           final, pure.} = object
+  Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
+               final, pure.} = object
+  Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
+               final, pure.} = object ## ucontext_t
+    uc_link*: ptr Ucontext  ## Pointer to the context that is resumed
+                            ## when this context returns.
+    uc_sigmask*: Sigset     ## The set of signals that are blocked when this
+                            ## context is active.
+    uc_stack*: Stack        ## The stack used by this context.
+    uc_mcontext*: Mcontext  ## A machine-specific representation of the saved
+                            ## context.
+
+when hasAioH:
+  type
+    Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
+              final, pure.} = object ## struct aiocb
+      aio_fildes*: cint         ## File descriptor.
+      aio_offset*: Off          ## File offset.
+      aio_buf*: pointer         ## Location of buffer.
+      aio_nbytes*: int          ## Length of transfer.
+      aio_reqprio*: cint        ## Request priority offset.
+      aio_sigevent*: SigEvent   ## Signal number and value.
+      aio_lio_opcode: cint      ## Operation to be performed.
+
+when hasSpawnH:
+  type
+    Tposix_spawnattr* {.importc: "posix_spawnattr_t",
+                        header: "<spawn.h>", final, pure.} = object
+    Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
+                                 header: "<spawn.h>", final, pure.} = object
+
+when defined(linux):
+  const Sockaddr_max_length* = 255
+  # from sys/un.h
+  const Sockaddr_un_path_length* = 108
+elif defined(zephyr):
+  when defined(net_ipv6):
+    const Sockaddr_max_length* = 24
+  elif defined(net_raw):
+    const Sockaddr_max_length* = 20
+  elif defined(net_ipv4):
+    const Sockaddr_max_length* = 8
+  else:
+    const Sockaddr_max_length* = 255 # just for compilation purposes
+
+  const Sockaddr_un_path_length* = Sockaddr_max_length
+  # Zephyr is heavily customizable so it's easy to get to a state  
+  # where Nim & Zephyr IPv6 settings are out of sync, causing painful runtime failures. 
+  when defined(net_ipv4) or defined(net_ipv6) or defined(net_raw):
+    {.emit: ["NIM_STATIC_ASSERT(NET_SOCKADDR_MAX_SIZE == ",
+        Sockaddr_max_length,
+        ",\"NET_SOCKADDR_MAX_SIZE and Sockaddr_max_length size mismatch!",
+        " Check that Nim and Zephyr IPv4/IPv6 settings match.",
+        " Try adding -d:net_ipv6 to enable IPv6 for Nim on Zephyr.\" );"].}
+elif defined(freertos) or defined(lwip):
+  const Sockaddr_max_length* = 14
+  const Sockaddr_un_path_length* = 108
+else:
+  const Sockaddr_max_length* = 255
+  # according to http://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/un.h.html
+  # this is >=92
+  const Sockaddr_un_path_length* = 92
+
+type
+  SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
+  TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cushort
+
+when defined(lwip):
+  type
+    SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+                pure, final.} = object ## struct sockaddr
+      sa_len*: uint8         ## Address family.
+      sa_family*: TSa_Family         ## Address family.
+      sa_data*: array[0..Sockaddr_max_length-sizeof(uint8)-sizeof(TSa_Family), char] ## Socket address (variable-length data).
+
+    Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                        header: "<sys/socket.h>",
+                        pure, final.} = object ## struct sockaddr_storage
+      s2_len*: uint8 ## Address family.
+      ss_family*: TSa_Family ## Address family.
+      s2_data1*: array[2, char] ## Address family.
+      s2_data2*: array[3, uint32] ## Address family.
+      when defined(lwip6) or defined(net_ipv6):
+        s2_data3*: array[3, uint32] ## Address family.
+elif defined(zephyr):
+  type
+    SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+                pure, final.} = object ## struct sockaddr
+      sa_family*: TSa_Family         ## Address family.
+      data*: array[0..Sockaddr_max_length-sizeof(TSa_Family), char] ## Socket address (variable-length data).
+
+    Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                        header: "<sys/socket.h>",
+                        pure, final.} = object ## struct sockaddr_storage
+      ss_family*: TSa_Family ## Address family.
+      data*: array[0..Sockaddr_max_length-sizeof(TSa_Family), char] ## Socket address (variable-length data).
+  {.emit: ["NIM_STATIC_ASSERT(sizeof(struct sockaddr) == ", sizeof(Sockaddr), ",\"struct size mismatch\" );"].}
+  {.emit: ["NIM_STATIC_ASSERT(sizeof(struct sockaddr_storage) == ", sizeof(Sockaddr_storage), ",\"struct size mismatch\" );"].}
+else:
+  type
+    SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
+                pure, final.} = object ## struct sockaddr
+      sa_family*: TSa_Family         ## Address family.
+      sa_data*: array[0..Sockaddr_max_length-sizeof(TSa_Family), char] ## Socket address (variable-length data).
+
+    Sockaddr_storage* {.importc: "struct sockaddr_storage",
+                        header: "<sys/socket.h>",
+                        pure, final.} = object ## struct sockaddr_storage
+      ss_family*: TSa_Family ## Address family.
+
+type
+  Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
+              pure, final.} = object ## struct sockaddr_un
+    sun_family*: TSa_Family         ## Address family.
+    sun_path*: array[0..Sockaddr_un_path_length-sizeof(TSa_Family), char] ## Socket path
+
+
+type
+  Tif_nameindex* {.importc: "struct if_nameindex", final,
+                   pure, header: "<net/if.h>".} = object ## struct if_nameindex
+    if_index*: cint   ## Numeric index of the interface.
+    if_name*: cstring ## Null-terminated name of the interface.
+
+
+  IOVec* {.importc: "struct iovec", pure, final,
+            header: "<sys/uio.h>".} = object ## struct iovec
+    iov_base*: pointer ## Base address of a memory region for input or output.
+    iov_len*: csize_t    ## The size of the memory pointed to by iov_base.
+
+  Tmsghdr* {.importc: "struct msghdr", pure, final,
+             header: "<sys/socket.h>".} = object  ## struct msghdr
+    msg_name*: pointer  ## Optional address.
+    msg_namelen*: SockLen  ## Size of address.
+    msg_iov*: ptr IOVec    ## Scatter/gather array.
+    msg_iovlen*: cint   ## Members in msg_iov.
+    msg_control*: pointer  ## Ancillary data; see below.
+    msg_controllen*: SockLen ## Ancillary data buffer len.
+    msg_flags*: cint ## Flags on received message.
+
+
+  Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
+              header: "<sys/socket.h>".} = object ## struct cmsghdr
+    cmsg_len*: SockLen ## Data byte count, including the cmsghdr.
+    cmsg_level*: cint   ## Originating protocol.
+    cmsg_type*: cint    ## Protocol-specific type.
+
+  TLinger* {.importc: "struct linger", pure, final,
+             header: "<sys/socket.h>".} = object ## struct linger
+    l_onoff*: cint  ## Indicates whether linger option is enabled.
+    l_linger*: cint ## Linger time, in seconds.
+
+  InPort* = uint16
+  InAddrScalar* = uint32
+
+  InAddrT* {.importc: "in_addr_t", pure, final,
+             header: "<netinet/in.h>".} = uint32
+
+  InAddr* {.importc: "struct in_addr", pure, final,
+             header: "<netinet/in.h>".} = object ## struct in_addr
+    s_addr*: InAddrScalar
+
+  # TODO: Fixme for FreeRTOS/LwIP, these are incorrect
+  Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
+                  header: "<netinet/in.h>".} = object ## struct sockaddr_in
+    sin_family*: TSa_Family ## AF_INET.
+    sin_port*: InPort      ## Port number.
+    sin_addr*: InAddr      ## IP address.
+
+  In6Addr* {.importc: "struct in6_addr", pure, final,
+              header: "<netinet/in.h>".} = object ## struct in6_addr
+    s6_addr*: array[0..15, char]
+
+  Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
+                   header: "<netinet/in.h>".} = object ## struct sockaddr_in6
+    sin6_family*: TSa_Family ## AF_INET6.
+    sin6_port*: InPort      ## Port number.
+    sin6_flowinfo*: int32    ## IPv6 traffic class and flow information.
+    sin6_addr*: In6Addr     ## IPv6 address.
+    sin6_scope_id*: int32    ## Set of interfaces for a scope.
+
+  Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
+                header: "<netinet/in.h>".} = object ## struct ipv6_mreq
+    ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
+    ipv6mr_interface*: cint     ## Interface index.
+
+  Hostent* {.importc: "struct hostent", pure, final,
+              header: "<netdb.h>".} = object ## struct hostent
+    h_name*: cstring           ## Official name of the host.
+    h_aliases*: cstringArray   ## A pointer to an array of pointers to
+                               ## alternative host names, terminated by a
+                               ## null pointer.
+    h_addrtype*: cint          ## Address type.
+    h_length*: cint            ## The length, in bytes, of the address.
+    h_addr_list*: cstringArray ## A pointer to an array of pointers to network
+                               ## addresses (in network byte order) for the
+                               ## host, terminated by a null pointer.
+
+  Tnetent* {.importc: "struct netent", pure, final,
+              header: "<netdb.h>".} = object ## struct netent
+    n_name*: cstring         ## Official, fully-qualified (including the
+                             ## domain) name of the host.
+    n_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative network names, terminated by a
+                             ## null pointer.
+    n_addrtype*: cint        ## The address type of the network.
+    n_net*: int32            ## The network number, in host byte order.
+
+  Protoent* {.importc: "struct protoent", pure, final,
+              header: "<netdb.h>".} = object ## struct protoent
+    p_name*: cstring         ## Official name of the protocol.
+    p_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative protocol names, terminated by
+                             ## a null pointer.
+    p_proto*: cint           ## The protocol number.
+
+  Servent* {.importc: "struct servent", pure, final,
+             header: "<netdb.h>".} = object ## struct servent
+    s_name*: cstring         ## Official name of the service.
+    s_aliases*: cstringArray ## A pointer to an array of pointers to
+                             ## alternative service names, terminated by
+                             ## a null pointer.
+    s_port*: cint            ## The port number at which the service
+                             ## resides, in network byte order.
+    s_proto*: cstring        ## The name of the protocol to use when
+                             ## contacting the service.
+
+  AddrInfo* {.importc: "struct addrinfo", pure, final,
+              header: "<netdb.h>".} = object ## struct addrinfo
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: SockLen   ## Length of socket address.
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_canonname*: cstring  ## Canonical name of service location.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+when not defined(lwip):
+  type
+    TPollfd* {.importc: "struct pollfd", pure, final,
+              header: "<poll.h>".} = object ## struct pollfd
+      fd*: cint        ## The following descriptor being polled.
+      events*: cshort  ## The input event flags (see below).
+      revents*: cshort ## The output event flags (see below).
+
+  when defined(zephyr):
+    type
+      Tnfds* = distinct cint
+  else:
+    type
+      Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = cint
+
+var
+  errno* {.importc, header: "<errno.h>".}: cint ## error variable
+  h_errno* {.importc, header: "<netdb.h>".}: cint
+  daylight* {.importc, header: "<time.h>".}: cint
+  timezone* {.importc, header: "<time.h>".}: int
+
+# Regenerate using detect.nim!
+when defined(lwip):
+  include posix_freertos_consts
+else:
+  include posix_other_consts
+
+when defined(linux):
+  var
+    MAP_POPULATE* {.importc, header: "<sys/mman.h>".}: cint
+      ## Populate (prefault) page tables for a mapping.
+else:
+  var
+    MAP_POPULATE*: cint = 0
+
+when defined(linux) or defined(nimdoc):
+  when defined(alpha) or defined(mips) or defined(mipsel) or
+      defined(mips64) or defined(mips64el) or defined(parisc) or
+      defined(sparc) or defined(sparc64) or defined(nimdoc):
+    const SO_REUSEPORT* = cint(0x0200)
+      ## Multiple binding: load balancing on incoming TCP connections
+      ## or UDP packets. (Requires Linux kernel > 3.9)
+  else:
+    const SO_REUSEPORT* = cint(15)
+elif defined(nuttx):
+  # Not supported, use SO_REUSEADDR to avoid compilation errors.
+  var SO_REUSEPORT* {.importc: "SO_REUSEADDR", header: "<sys/socket.h>".}: cint
+else:
+  var SO_REUSEPORT* {.importc, header: "<sys/socket.h>".}: cint
+
+when defined(linux) or defined(bsd) or defined(nuttx):
+  var SOCK_CLOEXEC* {.importc, header: "<sys/socket.h>".}: cint
+
+when defined(macosx):
+  # We can't use the NOSIGNAL flag in the `send` function, it has no effect
+  # Instead we should use SO_NOSIGPIPE in setsockopt
+  const
+    MSG_NOSIGNAL* = 0'i32
+  var
+    SO_NOSIGPIPE* {.importc, header: "<sys/socket.h>".}: cint
+elif defined(solaris):
+  # Solaris doesn't have MSG_NOSIGNAL
+  const
+    MSG_NOSIGNAL* = 0'i32
+elif defined(zephyr) or defined(freertos) or defined(lwip):
+  # LwIP/FreeRTOS doesn't have MSG_NOSIGNAL
+  const
+    MSG_NOSIGNAL* = 0x20'i32
+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.
+
+when defined(haiku):
+  const
+    SIGKILLTHR* = 21 ## BeOS specific: Kill just the thread, not team
+
+when hasSpawnH:
+  when defined(linux):
+    # better be safe than sorry; Linux has this flag, macosx and NuttX don't,
+    # don't know about the other OSes
+
+    # Non-GNU systems like TCC and musl-libc don't define __USE_GNU, so we
+    # can't get the magic number from spawn.h
+    const POSIX_SPAWN_USEVFORK* = cint(0x40)
+  else:
+    # macosx and NuttX lack this, so we define the constant to be 0 to not affect
+    # OR'ing of flags:
+    const POSIX_SPAWN_USEVFORK* = cint(0)
+
+# <sys/wait.h>
+proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Exit code, if WIFEXITED(s)
+proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Termination signal, if WIFSIGNALED(s)
+proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
+  ## Stop signal, if WIFSTOPPED(s)
+proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited normally.
+proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child exited due to uncaught signal.
+proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child is currently stopped.
+proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
+  ## True if child has been continued.
+
+when defined(nimHasStyleChecks):
+  {.pop.}
diff --git a/lib/posix/posix_other_consts.nim b/lib/posix/posix_other_consts.nim
new file mode 100644
index 000000000..d346b4150
--- /dev/null
+++ b/lib/posix/posix_other_consts.nim
@@ -0,0 +1,757 @@
+# Generated by detect.nim
+
+# <aio.h>
+var AIO_ALLDONE* {.importc: "AIO_ALLDONE", header: "<aio.h>".}: cint
+var AIO_CANCELED* {.importc: "AIO_CANCELED", header: "<aio.h>".}: cint
+var AIO_NOTCANCELED* {.importc: "AIO_NOTCANCELED", header: "<aio.h>".}: cint
+var LIO_NOP* {.importc: "LIO_NOP", header: "<aio.h>".}: cint
+var LIO_NOWAIT* {.importc: "LIO_NOWAIT", header: "<aio.h>".}: cint
+var LIO_READ* {.importc: "LIO_READ", header: "<aio.h>".}: cint
+var LIO_WAIT* {.importc: "LIO_WAIT", header: "<aio.h>".}: cint
+var LIO_WRITE* {.importc: "LIO_WRITE", header: "<aio.h>".}: cint
+
+# <dlfcn.h>
+var RTLD_LAZY* {.importc: "RTLD_LAZY", header: "<dlfcn.h>".}: cint
+var RTLD_NOW* {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: cint
+var RTLD_GLOBAL* {.importc: "RTLD_GLOBAL", header: "<dlfcn.h>".}: cint
+var RTLD_LOCAL* {.importc: "RTLD_LOCAL", header: "<dlfcn.h>".}: cint
+
+# <errno.h>
+var E2BIG* {.importc: "E2BIG", header: "<errno.h>".}: cint
+var EACCES* {.importc: "EACCES", header: "<errno.h>".}: cint
+var EADDRINUSE* {.importc: "EADDRINUSE", header: "<errno.h>".}: cint
+var EADDRNOTAVAIL* {.importc: "EADDRNOTAVAIL", header: "<errno.h>".}: cint
+var EAFNOSUPPORT* {.importc: "EAFNOSUPPORT", header: "<errno.h>".}: cint
+var EAGAIN* {.importc: "EAGAIN", header: "<errno.h>".}: cint
+var EALREADY* {.importc: "EALREADY", header: "<errno.h>".}: cint
+var EBADF* {.importc: "EBADF", header: "<errno.h>".}: cint
+var EBADMSG* {.importc: "EBADMSG", header: "<errno.h>".}: cint
+var EBUSY* {.importc: "EBUSY", header: "<errno.h>".}: cint
+var ECANCELED* {.importc: "ECANCELED", header: "<errno.h>".}: cint
+var ECHILD* {.importc: "ECHILD", header: "<errno.h>".}: cint
+var ECONNABORTED* {.importc: "ECONNABORTED", header: "<errno.h>".}: cint
+var ECONNREFUSED* {.importc: "ECONNREFUSED", header: "<errno.h>".}: cint
+var ECONNRESET* {.importc: "ECONNRESET", header: "<errno.h>".}: cint
+var EDEADLK* {.importc: "EDEADLK", header: "<errno.h>".}: cint
+var EDESTADDRREQ* {.importc: "EDESTADDRREQ", header: "<errno.h>".}: cint
+var EDOM* {.importc: "EDOM", header: "<errno.h>".}: cint
+var EDQUOT* {.importc: "EDQUOT", header: "<errno.h>".}: cint
+var EEXIST* {.importc: "EEXIST", header: "<errno.h>".}: cint
+var EFAULT* {.importc: "EFAULT", header: "<errno.h>".}: cint
+var EFBIG* {.importc: "EFBIG", header: "<errno.h>".}: cint
+var EHOSTUNREACH* {.importc: "EHOSTUNREACH", header: "<errno.h>".}: cint
+var EIDRM* {.importc: "EIDRM", header: "<errno.h>".}: cint
+var EILSEQ* {.importc: "EILSEQ", header: "<errno.h>".}: cint
+var EINPROGRESS* {.importc: "EINPROGRESS", header: "<errno.h>".}: cint
+var EINTR* {.importc: "EINTR", header: "<errno.h>".}: cint
+var EINVAL* {.importc: "EINVAL", header: "<errno.h>".}: cint
+var EIO* {.importc: "EIO", header: "<errno.h>".}: cint
+var EISCONN* {.importc: "EISCONN", header: "<errno.h>".}: cint
+var EISDIR* {.importc: "EISDIR", header: "<errno.h>".}: cint
+var ELOOP* {.importc: "ELOOP", header: "<errno.h>".}: cint
+var EMFILE* {.importc: "EMFILE", header: "<errno.h>".}: cint
+var EMLINK* {.importc: "EMLINK", header: "<errno.h>".}: cint
+var EMSGSIZE* {.importc: "EMSGSIZE", header: "<errno.h>".}: cint
+var EMULTIHOP* {.importc: "EMULTIHOP", header: "<errno.h>".}: cint
+var ENAMETOOLONG* {.importc: "ENAMETOOLONG", header: "<errno.h>".}: cint
+var ENETDOWN* {.importc: "ENETDOWN", header: "<errno.h>".}: cint
+var ENETRESET* {.importc: "ENETRESET", header: "<errno.h>".}: cint
+var ENETUNREACH* {.importc: "ENETUNREACH", header: "<errno.h>".}: cint
+var ENFILE* {.importc: "ENFILE", header: "<errno.h>".}: cint
+var ENOBUFS* {.importc: "ENOBUFS", header: "<errno.h>".}: cint
+var ENODATA* {.importc: "ENODATA", header: "<errno.h>".}: cint
+var ENODEV* {.importc: "ENODEV", header: "<errno.h>".}: cint
+var ENOENT* {.importc: "ENOENT", header: "<errno.h>".}: cint
+var ENOEXEC* {.importc: "ENOEXEC", header: "<errno.h>".}: cint
+var ENOLCK* {.importc: "ENOLCK", header: "<errno.h>".}: cint
+var ENOLINK* {.importc: "ENOLINK", header: "<errno.h>".}: cint
+var ENOMEM* {.importc: "ENOMEM", header: "<errno.h>".}: cint
+var ENOMSG* {.importc: "ENOMSG", header: "<errno.h>".}: cint
+var ENOPROTOOPT* {.importc: "ENOPROTOOPT", header: "<errno.h>".}: cint
+var ENOSPC* {.importc: "ENOSPC", header: "<errno.h>".}: cint
+var ENOSR* {.importc: "ENOSR", header: "<errno.h>".}: cint
+var ENOSTR* {.importc: "ENOSTR", header: "<errno.h>".}: cint
+var ENOSYS* {.importc: "ENOSYS", header: "<errno.h>".}: cint
+var ENOTCONN* {.importc: "ENOTCONN", header: "<errno.h>".}: cint
+var ENOTDIR* {.importc: "ENOTDIR", header: "<errno.h>".}: cint
+var ENOTEMPTY* {.importc: "ENOTEMPTY", header: "<errno.h>".}: cint
+var ENOTSOCK* {.importc: "ENOTSOCK", header: "<errno.h>".}: cint
+var ENOTSUP* {.importc: "ENOTSUP", header: "<errno.h>".}: cint
+var ENOTTY* {.importc: "ENOTTY", header: "<errno.h>".}: cint
+var ENXIO* {.importc: "ENXIO", header: "<errno.h>".}: cint
+var EOPNOTSUPP* {.importc: "EOPNOTSUPP", header: "<errno.h>".}: cint
+var EOVERFLOW* {.importc: "EOVERFLOW", header: "<errno.h>".}: cint
+var EPERM* {.importc: "EPERM", header: "<errno.h>".}: cint
+var EPIPE* {.importc: "EPIPE", header: "<errno.h>".}: cint
+var EPROTO* {.importc: "EPROTO", header: "<errno.h>".}: cint
+var EPROTONOSUPPORT* {.importc: "EPROTONOSUPPORT", header: "<errno.h>".}: cint
+var EPROTOTYPE* {.importc: "EPROTOTYPE", header: "<errno.h>".}: cint
+var ERANGE* {.importc: "ERANGE", header: "<errno.h>".}: cint
+var EROFS* {.importc: "EROFS", header: "<errno.h>".}: cint
+var ESPIPE* {.importc: "ESPIPE", header: "<errno.h>".}: cint
+var ESRCH* {.importc: "ESRCH", header: "<errno.h>".}: cint
+var ESTALE* {.importc: "ESTALE", header: "<errno.h>".}: cint
+var ETIME* {.importc: "ETIME", header: "<errno.h>".}: cint
+var ETIMEDOUT* {.importc: "ETIMEDOUT", header: "<errno.h>".}: cint
+var ETXTBSY* {.importc: "ETXTBSY", header: "<errno.h>".}: cint
+var EWOULDBLOCK* {.importc: "EWOULDBLOCK", header: "<errno.h>".}: cint
+var EXDEV* {.importc: "EXDEV", header: "<errno.h>".}: cint
+
+# <fcntl.h>
+var F_DUPFD* {.importc: "F_DUPFD", header: "<fcntl.h>".}: cint
+when defined(nuttx):
+  var F_DUPFD_CLOEXEC* {.importc: "F_DUPFD_CLOEXEC", header: "<fcntl.h>".}: cint
+else:
+  var F_DUPFD_CLOEXEC* {.importc: "F_DUPFD", header: "<fcntl.h>".}: cint
+var F_GETFD* {.importc: "F_GETFD", header: "<fcntl.h>".}: cint
+var F_SETFD* {.importc: "F_SETFD", header: "<fcntl.h>".}: cint
+var F_GETFL* {.importc: "F_GETFL", header: "<fcntl.h>".}: cint
+var F_SETFL* {.importc: "F_SETFL", header: "<fcntl.h>".}: cint
+var F_GETLK* {.importc: "F_GETLK", header: "<fcntl.h>".}: cint
+var F_SETLK* {.importc: "F_SETLK", header: "<fcntl.h>".}: cint
+var F_SETLKW* {.importc: "F_SETLKW", header: "<fcntl.h>".}: cint
+var F_GETOWN* {.importc: "F_GETOWN", header: "<fcntl.h>".}: cint
+var F_SETOWN* {.importc: "F_SETOWN", header: "<fcntl.h>".}: cint
+var FD_CLOEXEC* {.importc: "FD_CLOEXEC", header: "<fcntl.h>".}: cint
+var F_RDLCK* {.importc: "F_RDLCK", header: "<fcntl.h>".}: cint
+var F_UNLCK* {.importc: "F_UNLCK", header: "<fcntl.h>".}: cint
+var F_WRLCK* {.importc: "F_WRLCK", header: "<fcntl.h>".}: cint
+var O_CREAT* {.importc: "O_CREAT", header: "<fcntl.h>".}: cint
+var O_EXCL* {.importc: "O_EXCL", header: "<fcntl.h>".}: cint
+var O_NOCTTY* {.importc: "O_NOCTTY", header: "<fcntl.h>".}: cint
+var O_TRUNC* {.importc: "O_TRUNC", header: "<fcntl.h>".}: cint
+var O_APPEND* {.importc: "O_APPEND", header: "<fcntl.h>".}: cint
+var O_DSYNC* {.importc: "O_DSYNC", header: "<fcntl.h>".}: cint
+var O_NONBLOCK* {.importc: "O_NONBLOCK", header: "<fcntl.h>".}: cint
+var O_RSYNC* {.importc: "O_RSYNC", header: "<fcntl.h>".}: cint
+var O_SYNC* {.importc: "O_SYNC", header: "<fcntl.h>".}: cint
+var O_ACCMODE* {.importc: "O_ACCMODE", header: "<fcntl.h>".}: cint
+var O_RDONLY* {.importc: "O_RDONLY", header: "<fcntl.h>".}: cint
+var O_RDWR* {.importc: "O_RDWR", header: "<fcntl.h>".}: cint
+var O_WRONLY* {.importc: "O_WRONLY", header: "<fcntl.h>".}: cint
+var O_CLOEXEC* {.importc: "O_CLOEXEC", header: "<fcntl.h>".}: cint
+when defined(nuttx):
+  var O_DIRECT* {.importc: "O_DIRECT", header: "<fcntl.h>".}: cint
+  var O_PATH* {.importc: "O_PATH", header: "<fcntl.h>".}: cint
+  var O_NOATIME* {.importc: "O_NOATIME", header: "<fcntl.h>".}: cint
+  var O_TMPFILE* {.importc: "O_TMPFILE", header: "<fcntl.h>".}: cint
+var POSIX_FADV_NORMAL* {.importc: "POSIX_FADV_NORMAL", header: "<fcntl.h>".}: cint
+var POSIX_FADV_SEQUENTIAL* {.importc: "POSIX_FADV_SEQUENTIAL", header: "<fcntl.h>".}: cint
+var POSIX_FADV_RANDOM* {.importc: "POSIX_FADV_RANDOM", header: "<fcntl.h>".}: cint
+var POSIX_FADV_WILLNEED* {.importc: "POSIX_FADV_WILLNEED", header: "<fcntl.h>".}: cint
+var POSIX_FADV_DONTNEED* {.importc: "POSIX_FADV_DONTNEED", header: "<fcntl.h>".}: cint
+var POSIX_FADV_NOREUSE* {.importc: "POSIX_FADV_NOREUSE", header: "<fcntl.h>".}: cint
+
+# <fenv.h>
+var FE_DIVBYZERO* {.importc: "FE_DIVBYZERO", header: "<fenv.h>".}: cint
+var FE_INEXACT* {.importc: "FE_INEXACT", header: "<fenv.h>".}: cint
+var FE_INVALID* {.importc: "FE_INVALID", header: "<fenv.h>".}: cint
+var FE_OVERFLOW* {.importc: "FE_OVERFLOW", header: "<fenv.h>".}: cint
+var FE_UNDERFLOW* {.importc: "FE_UNDERFLOW", header: "<fenv.h>".}: cint
+var FE_ALL_EXCEPT* {.importc: "FE_ALL_EXCEPT", header: "<fenv.h>".}: cint
+var FE_DOWNWARD* {.importc: "FE_DOWNWARD", header: "<fenv.h>".}: cint
+var FE_TONEAREST* {.importc: "FE_TONEAREST", header: "<fenv.h>".}: cint
+var FE_TOWARDZERO* {.importc: "FE_TOWARDZERO", header: "<fenv.h>".}: cint
+var FE_UPWARD* {.importc: "FE_UPWARD", header: "<fenv.h>".}: cint
+var FE_DFL_ENV* {.importc: "FE_DFL_ENV", header: "<fenv.h>".}: cint
+
+# <fmtmsg.h>
+var MM_HARD* {.importc: "MM_HARD", header: "<fmtmsg.h>".}: cint
+var MM_SOFT* {.importc: "MM_SOFT", header: "<fmtmsg.h>".}: cint
+var MM_FIRM* {.importc: "MM_FIRM", header: "<fmtmsg.h>".}: cint
+var MM_APPL* {.importc: "MM_APPL", header: "<fmtmsg.h>".}: cint
+var MM_UTIL* {.importc: "MM_UTIL", header: "<fmtmsg.h>".}: cint
+var MM_OPSYS* {.importc: "MM_OPSYS", header: "<fmtmsg.h>".}: cint
+var MM_RECOVER* {.importc: "MM_RECOVER", header: "<fmtmsg.h>".}: cint
+var MM_NRECOV* {.importc: "MM_NRECOV", header: "<fmtmsg.h>".}: cint
+var MM_HALT* {.importc: "MM_HALT", header: "<fmtmsg.h>".}: cint
+var MM_ERROR* {.importc: "MM_ERROR", header: "<fmtmsg.h>".}: cint
+var MM_WARNING* {.importc: "MM_WARNING", header: "<fmtmsg.h>".}: cint
+var MM_INFO* {.importc: "MM_INFO", header: "<fmtmsg.h>".}: cint
+var MM_NOSEV* {.importc: "MM_NOSEV", header: "<fmtmsg.h>".}: cint
+var MM_PRINT* {.importc: "MM_PRINT", header: "<fmtmsg.h>".}: cint
+var MM_CONSOLE* {.importc: "MM_CONSOLE", header: "<fmtmsg.h>".}: cint
+var MM_OK* {.importc: "MM_OK", header: "<fmtmsg.h>".}: cint
+var MM_NOTOK* {.importc: "MM_NOTOK", header: "<fmtmsg.h>".}: cint
+var MM_NOMSG* {.importc: "MM_NOMSG", header: "<fmtmsg.h>".}: cint
+var MM_NOCON* {.importc: "MM_NOCON", header: "<fmtmsg.h>".}: cint
+
+# <fnmatch.h>
+var FNM_NOMATCH* {.importc: "FNM_NOMATCH", header: "<fnmatch.h>".}: cint
+var FNM_PATHNAME* {.importc: "FNM_PATHNAME", header: "<fnmatch.h>".}: cint
+var FNM_PERIOD* {.importc: "FNM_PERIOD", header: "<fnmatch.h>".}: cint
+var FNM_NOESCAPE* {.importc: "FNM_NOESCAPE", header: "<fnmatch.h>".}: cint
+var FNM_NOSYS* {.importc: "FNM_NOSYS", header: "<fnmatch.h>".}: cint
+
+# <ftw.h>
+var FTW_F* {.importc: "FTW_F", header: "<ftw.h>".}: cint
+var FTW_D* {.importc: "FTW_D", header: "<ftw.h>".}: cint
+var FTW_DNR* {.importc: "FTW_DNR", header: "<ftw.h>".}: cint
+var FTW_DP* {.importc: "FTW_DP", header: "<ftw.h>".}: cint
+var FTW_NS* {.importc: "FTW_NS", header: "<ftw.h>".}: cint
+var FTW_SL* {.importc: "FTW_SL", header: "<ftw.h>".}: cint
+var FTW_SLN* {.importc: "FTW_SLN", header: "<ftw.h>".}: cint
+var FTW_PHYS* {.importc: "FTW_PHYS", header: "<ftw.h>".}: cint
+var FTW_MOUNT* {.importc: "FTW_MOUNT", header: "<ftw.h>".}: cint
+var FTW_DEPTH* {.importc: "FTW_DEPTH", header: "<ftw.h>".}: cint
+var FTW_CHDIR* {.importc: "FTW_CHDIR", header: "<ftw.h>".}: cint
+
+# <glob.h>
+var GLOB_APPEND* {.importc: "GLOB_APPEND", header: "<glob.h>".}: cint
+var GLOB_DOOFFS* {.importc: "GLOB_DOOFFS", header: "<glob.h>".}: cint
+var GLOB_ERR* {.importc: "GLOB_ERR", header: "<glob.h>".}: cint
+var GLOB_MARK* {.importc: "GLOB_MARK", header: "<glob.h>".}: cint
+var GLOB_NOCHECK* {.importc: "GLOB_NOCHECK", header: "<glob.h>".}: cint
+var GLOB_NOESCAPE* {.importc: "GLOB_NOESCAPE", header: "<glob.h>".}: cint
+var GLOB_NOSORT* {.importc: "GLOB_NOSORT", header: "<glob.h>".}: cint
+var GLOB_ABORTED* {.importc: "GLOB_ABORTED", header: "<glob.h>".}: cint
+var GLOB_NOMATCH* {.importc: "GLOB_NOMATCH", header: "<glob.h>".}: cint
+var GLOB_NOSPACE* {.importc: "GLOB_NOSPACE", header: "<glob.h>".}: cint
+var GLOB_NOSYS* {.importc: "GLOB_NOSYS", header: "<glob.h>".}: cint
+
+# <langinfo.h>
+var CODESET* {.importc: "CODESET", header: "<langinfo.h>".}: cint
+var D_T_FMT* {.importc: "D_T_FMT", header: "<langinfo.h>".}: cint
+var D_FMT* {.importc: "D_FMT", header: "<langinfo.h>".}: cint
+var T_FMT* {.importc: "T_FMT", header: "<langinfo.h>".}: cint
+var T_FMT_AMPM* {.importc: "T_FMT_AMPM", header: "<langinfo.h>".}: cint
+var AM_STR* {.importc: "AM_STR", header: "<langinfo.h>".}: cint
+var PM_STR* {.importc: "PM_STR", header: "<langinfo.h>".}: cint
+var DAY_1* {.importc: "DAY_1", header: "<langinfo.h>".}: cint
+var DAY_2* {.importc: "DAY_2", header: "<langinfo.h>".}: cint
+var DAY_3* {.importc: "DAY_3", header: "<langinfo.h>".}: cint
+var DAY_4* {.importc: "DAY_4", header: "<langinfo.h>".}: cint
+var DAY_5* {.importc: "DAY_5", header: "<langinfo.h>".}: cint
+var DAY_6* {.importc: "DAY_6", header: "<langinfo.h>".}: cint
+var DAY_7* {.importc: "DAY_7", header: "<langinfo.h>".}: cint
+var ABDAY_1* {.importc: "ABDAY_1", header: "<langinfo.h>".}: cint
+var ABDAY_2* {.importc: "ABDAY_2", header: "<langinfo.h>".}: cint
+var ABDAY_3* {.importc: "ABDAY_3", header: "<langinfo.h>".}: cint
+var ABDAY_4* {.importc: "ABDAY_4", header: "<langinfo.h>".}: cint
+var ABDAY_5* {.importc: "ABDAY_5", header: "<langinfo.h>".}: cint
+var ABDAY_6* {.importc: "ABDAY_6", header: "<langinfo.h>".}: cint
+var ABDAY_7* {.importc: "ABDAY_7", header: "<langinfo.h>".}: cint
+var MON_1* {.importc: "MON_1", header: "<langinfo.h>".}: cint
+var MON_2* {.importc: "MON_2", header: "<langinfo.h>".}: cint
+var MON_3* {.importc: "MON_3", header: "<langinfo.h>".}: cint
+var MON_4* {.importc: "MON_4", header: "<langinfo.h>".}: cint
+var MON_5* {.importc: "MON_5", header: "<langinfo.h>".}: cint
+var MON_6* {.importc: "MON_6", header: "<langinfo.h>".}: cint
+var MON_7* {.importc: "MON_7", header: "<langinfo.h>".}: cint
+var MON_8* {.importc: "MON_8", header: "<langinfo.h>".}: cint
+var MON_9* {.importc: "MON_9", header: "<langinfo.h>".}: cint
+var MON_10* {.importc: "MON_10", header: "<langinfo.h>".}: cint
+var MON_11* {.importc: "MON_11", header: "<langinfo.h>".}: cint
+var MON_12* {.importc: "MON_12", header: "<langinfo.h>".}: cint
+var ABMON_1* {.importc: "ABMON_1", header: "<langinfo.h>".}: cint
+var ABMON_2* {.importc: "ABMON_2", header: "<langinfo.h>".}: cint
+var ABMON_3* {.importc: "ABMON_3", header: "<langinfo.h>".}: cint
+var ABMON_4* {.importc: "ABMON_4", header: "<langinfo.h>".}: cint
+var ABMON_5* {.importc: "ABMON_5", header: "<langinfo.h>".}: cint
+var ABMON_6* {.importc: "ABMON_6", header: "<langinfo.h>".}: cint
+var ABMON_7* {.importc: "ABMON_7", header: "<langinfo.h>".}: cint
+var ABMON_8* {.importc: "ABMON_8", header: "<langinfo.h>".}: cint
+var ABMON_9* {.importc: "ABMON_9", header: "<langinfo.h>".}: cint
+var ABMON_10* {.importc: "ABMON_10", header: "<langinfo.h>".}: cint
+var ABMON_11* {.importc: "ABMON_11", header: "<langinfo.h>".}: cint
+var ABMON_12* {.importc: "ABMON_12", header: "<langinfo.h>".}: cint
+var ERA* {.importc: "ERA", header: "<langinfo.h>".}: cint
+var ERA_D_FMT* {.importc: "ERA_D_FMT", header: "<langinfo.h>".}: cint
+var ERA_D_T_FMT* {.importc: "ERA_D_T_FMT", header: "<langinfo.h>".}: cint
+var ERA_T_FMT* {.importc: "ERA_T_FMT", header: "<langinfo.h>".}: cint
+var ALT_DIGITS* {.importc: "ALT_DIGITS", header: "<langinfo.h>".}: cint
+var RADIXCHAR* {.importc: "RADIXCHAR", header: "<langinfo.h>".}: cint
+var THOUSEP* {.importc: "THOUSEP", header: "<langinfo.h>".}: cint
+var YESEXPR* {.importc: "YESEXPR", header: "<langinfo.h>".}: cint
+var NOEXPR* {.importc: "NOEXPR", header: "<langinfo.h>".}: cint
+var CRNCYSTR* {.importc: "CRNCYSTR", header: "<langinfo.h>".}: cint
+
+# <locale.h>
+var LC_ALL* {.importc: "LC_ALL", header: "<locale.h>".}: cint
+var LC_COLLATE* {.importc: "LC_COLLATE", header: "<locale.h>".}: cint
+var LC_CTYPE* {.importc: "LC_CTYPE", header: "<locale.h>".}: cint
+var LC_MESSAGES* {.importc: "LC_MESSAGES", header: "<locale.h>".}: cint
+var LC_MONETARY* {.importc: "LC_MONETARY", header: "<locale.h>".}: cint
+var LC_NUMERIC* {.importc: "LC_NUMERIC", header: "<locale.h>".}: cint
+var LC_TIME* {.importc: "LC_TIME", header: "<locale.h>".}: cint
+
+# <netdb.h>
+var IPPORT_RESERVED* {.importc: "IPPORT_RESERVED", header: "<netdb.h>".}: cint
+var HOST_NOT_FOUND* {.importc: "HOST_NOT_FOUND", header: "<netdb.h>".}: cint
+var NO_DATA* {.importc: "NO_DATA", header: "<netdb.h>".}: cint
+var NO_RECOVERY* {.importc: "NO_RECOVERY", header: "<netdb.h>".}: cint
+var TRY_AGAIN* {.importc: "TRY_AGAIN", header: "<netdb.h>".}: cint
+var AI_PASSIVE* {.importc: "AI_PASSIVE", header: "<netdb.h>".}: cint
+var AI_CANONNAME* {.importc: "AI_CANONNAME", header: "<netdb.h>".}: cint
+var AI_NUMERICHOST* {.importc: "AI_NUMERICHOST", header: "<netdb.h>".}: cint
+var AI_NUMERICSERV* {.importc: "AI_NUMERICSERV", header: "<netdb.h>".}: cint
+var AI_V4MAPPED* {.importc: "AI_V4MAPPED", header: "<netdb.h>".}: cint
+var AI_ALL* {.importc: "AI_ALL", header: "<netdb.h>".}: cint
+var AI_ADDRCONFIG* {.importc: "AI_ADDRCONFIG", header: "<netdb.h>".}: cint
+var NI_NOFQDN* {.importc: "NI_NOFQDN", header: "<netdb.h>".}: cint
+var NI_NUMERICHOST* {.importc: "NI_NUMERICHOST", header: "<netdb.h>".}: cint
+var NI_NAMEREQD* {.importc: "NI_NAMEREQD", header: "<netdb.h>".}: cint
+var NI_NUMERICSERV* {.importc: "NI_NUMERICSERV", header: "<netdb.h>".}: cint
+var NI_NUMERICSCOPE* {.importc: "NI_NUMERICSCOPE", header: "<netdb.h>".}: cint
+var NI_DGRAM* {.importc: "NI_DGRAM", header: "<netdb.h>".}: cint
+var EAI_AGAIN* {.importc: "EAI_AGAIN", header: "<netdb.h>".}: cint
+var EAI_BADFLAGS* {.importc: "EAI_BADFLAGS", header: "<netdb.h>".}: cint
+var EAI_FAIL* {.importc: "EAI_FAIL", header: "<netdb.h>".}: cint
+var EAI_FAMILY* {.importc: "EAI_FAMILY", header: "<netdb.h>".}: cint
+var EAI_MEMORY* {.importc: "EAI_MEMORY", header: "<netdb.h>".}: cint
+var EAI_NONAME* {.importc: "EAI_NONAME", header: "<netdb.h>".}: cint
+var EAI_SERVICE* {.importc: "EAI_SERVICE", header: "<netdb.h>".}: cint
+var EAI_SOCKTYPE* {.importc: "EAI_SOCKTYPE", header: "<netdb.h>".}: cint
+var EAI_SYSTEM* {.importc: "EAI_SYSTEM", header: "<netdb.h>".}: cint
+var EAI_OVERFLOW* {.importc: "EAI_OVERFLOW", header: "<netdb.h>".}: cint
+
+# <net/if.h>
+var IF_NAMESIZE* {.importc: "IF_NAMESIZE", header: "<net/if.h>".}: cint
+
+# <netinet/in.h>
+var IPPROTO_IP* {.importc: "IPPROTO_IP", header: "<netinet/in.h>".}: cint
+var IPPROTO_IPV6* {.importc: "IPPROTO_IPV6", header: "<netinet/in.h>".}: cint
+var IPPROTO_ICMP* {.importc: "IPPROTO_ICMP", header: "<netinet/in.h>".}: cint
+var IPPROTO_ICMPV6* {.importc: "IPPROTO_ICMPV6", header: "<netinet/in.h>".}: cint
+var IPPROTO_RAW* {.importc: "IPPROTO_RAW", header: "<netinet/in.h>".}: cint
+var IPPROTO_TCP* {.importc: "IPPROTO_TCP", header: "<netinet/in.h>".}: cint
+var IPPROTO_UDP* {.importc: "IPPROTO_UDP", header: "<netinet/in.h>".}: cint
+var INADDR_ANY* {.importc: "INADDR_ANY", header: "<netinet/in.h>".}: InAddrScalar
+var INADDR_LOOPBACK* {.importc: "INADDR_LOOPBACK", header: "<netinet/in.h>".}: InAddrScalar
+var INADDR_BROADCAST* {.importc: "INADDR_BROADCAST", header: "<netinet/in.h>".}: InAddrScalar
+var INET_ADDRSTRLEN* {.importc: "INET_ADDRSTRLEN", header: "<netinet/in.h>".}: cint
+var INET6_ADDRSTRLEN* {.importc: "INET6_ADDRSTRLEN", header: "<netinet/in.h>".}: cint
+var IPV6_JOIN_GROUP* {.importc: "IPV6_JOIN_GROUP", header: "<netinet/in.h>".}: cint
+var IPV6_LEAVE_GROUP* {.importc: "IPV6_LEAVE_GROUP", header: "<netinet/in.h>".}: cint
+var IPV6_MULTICAST_HOPS* {.importc: "IPV6_MULTICAST_HOPS", header: "<netinet/in.h>".}: cint
+var IPV6_MULTICAST_IF* {.importc: "IPV6_MULTICAST_IF", header: "<netinet/in.h>".}: cint
+var IPV6_MULTICAST_LOOP* {.importc: "IPV6_MULTICAST_LOOP", header: "<netinet/in.h>".}: cint
+var IPV6_UNICAST_HOPS* {.importc: "IPV6_UNICAST_HOPS", header: "<netinet/in.h>".}: cint
+var IPV6_V6ONLY* {.importc: "IPV6_V6ONLY", header: "<netinet/in.h>".}: cint
+
+# <netinet/tcp.h>
+var TCP_NODELAY* {.importc: "TCP_NODELAY", header: "<netinet/tcp.h>".}: cint
+
+# <nl_types.h>
+var NL_SETD* {.importc: "NL_SETD", header: "<nl_types.h>".}: cint
+var NL_CAT_LOCALE* {.importc: "NL_CAT_LOCALE", header: "<nl_types.h>".}: cint
+
+# <poll.h>
+var POLLIN* {.importc: "POLLIN", header: "<poll.h>".}: cshort
+var POLLRDNORM* {.importc: "POLLRDNORM", header: "<poll.h>".}: cshort
+var POLLRDBAND* {.importc: "POLLRDBAND", header: "<poll.h>".}: cshort
+var POLLPRI* {.importc: "POLLPRI", header: "<poll.h>".}: cshort
+var POLLOUT* {.importc: "POLLOUT", header: "<poll.h>".}: cshort
+var POLLWRNORM* {.importc: "POLLWRNORM", header: "<poll.h>".}: cshort
+var POLLWRBAND* {.importc: "POLLWRBAND", header: "<poll.h>".}: cshort
+var POLLERR* {.importc: "POLLERR", header: "<poll.h>".}: cshort
+var POLLHUP* {.importc: "POLLHUP", header: "<poll.h>".}: cshort
+var POLLNVAL* {.importc: "POLLNVAL", header: "<poll.h>".}: cshort
+
+# <pthread.h>
+var PTHREAD_BARRIER_SERIAL_THREAD* {.importc: "PTHREAD_BARRIER_SERIAL_THREAD", header: "<pthread.h>".}: cint
+var PTHREAD_CANCEL_ASYNCHRONOUS* {.importc: "PTHREAD_CANCEL_ASYNCHRONOUS", header: "<pthread.h>".}: cint
+var PTHREAD_CANCEL_ENABLE* {.importc: "PTHREAD_CANCEL_ENABLE", header: "<pthread.h>".}: cint
+var PTHREAD_CANCEL_DEFERRED* {.importc: "PTHREAD_CANCEL_DEFERRED", header: "<pthread.h>".}: cint
+var PTHREAD_CANCEL_DISABLE* {.importc: "PTHREAD_CANCEL_DISABLE", header: "<pthread.h>".}: cint
+var PTHREAD_CREATE_DETACHED* {.importc: "PTHREAD_CREATE_DETACHED", header: "<pthread.h>".}: cint
+var PTHREAD_CREATE_JOINABLE* {.importc: "PTHREAD_CREATE_JOINABLE", header: "<pthread.h>".}: cint
+var PTHREAD_EXPLICIT_SCHED* {.importc: "PTHREAD_EXPLICIT_SCHED", header: "<pthread.h>".}: cint
+var PTHREAD_INHERIT_SCHED* {.importc: "PTHREAD_INHERIT_SCHED", header: "<pthread.h>".}: cint
+var PTHREAD_MUTEX_DEFAULT* {.importc: "PTHREAD_MUTEX_DEFAULT", header: "<pthread.h>".}: cint
+var PTHREAD_MUTEX_ERRORCHECK* {.importc: "PTHREAD_MUTEX_ERRORCHECK", header: "<pthread.h>".}: cint
+var PTHREAD_MUTEX_NORMAL* {.importc: "PTHREAD_MUTEX_NORMAL", header: "<pthread.h>".}: cint
+var PTHREAD_MUTEX_RECURSIVE* {.importc: "PTHREAD_MUTEX_RECURSIVE", header: "<pthread.h>".}: cint
+var PTHREAD_PRIO_INHERIT* {.importc: "PTHREAD_PRIO_INHERIT", header: "<pthread.h>".}: cint
+var PTHREAD_PRIO_NONE* {.importc: "PTHREAD_PRIO_NONE", header: "<pthread.h>".}: cint
+var PTHREAD_PRIO_PROTECT* {.importc: "PTHREAD_PRIO_PROTECT", header: "<pthread.h>".}: cint
+var PTHREAD_PROCESS_SHARED* {.importc: "PTHREAD_PROCESS_SHARED", header: "<pthread.h>".}: cint
+var PTHREAD_PROCESS_PRIVATE* {.importc: "PTHREAD_PROCESS_PRIVATE", header: "<pthread.h>".}: cint
+var PTHREAD_SCOPE_PROCESS* {.importc: "PTHREAD_SCOPE_PROCESS", header: "<pthread.h>".}: cint
+var PTHREAD_SCOPE_SYSTEM* {.importc: "PTHREAD_SCOPE_SYSTEM", header: "<pthread.h>".}: cint
+
+# <sched.h>
+var SCHED_FIFO* {.importc: "SCHED_FIFO", header: "<sched.h>".}: cint
+var SCHED_RR* {.importc: "SCHED_RR", header: "<sched.h>".}: cint
+var SCHED_SPORADIC* {.importc: "SCHED_SPORADIC", header: "<sched.h>".}: cint
+var SCHED_OTHER* {.importc: "SCHED_OTHER", header: "<sched.h>".}: cint
+
+# <semaphore.h>
+var SEM_FAILED* {.importc: "SEM_FAILED", header: "<semaphore.h>".}: pointer
+
+# <signal.h>
+var SIGEV_NONE* {.importc: "SIGEV_NONE", header: "<signal.h>".}: cint
+var SIGEV_SIGNAL* {.importc: "SIGEV_SIGNAL", header: "<signal.h>".}: cint
+var SIGEV_THREAD* {.importc: "SIGEV_THREAD", header: "<signal.h>".}: cint
+var SIGABRT* {.importc: "SIGABRT", header: "<signal.h>".}: cint
+var SIGALRM* {.importc: "SIGALRM", header: "<signal.h>".}: cint
+var SIGBUS* {.importc: "SIGBUS", header: "<signal.h>".}: cint
+var SIGCHLD* {.importc: "SIGCHLD", header: "<signal.h>".}: cint
+var SIGCONT* {.importc: "SIGCONT", header: "<signal.h>".}: cint
+var SIGFPE* {.importc: "SIGFPE", header: "<signal.h>".}: cint
+var SIGHUP* {.importc: "SIGHUP", header: "<signal.h>".}: cint
+var SIGILL* {.importc: "SIGILL", header: "<signal.h>".}: cint
+var SIGINT* {.importc: "SIGINT", header: "<signal.h>".}: cint
+var SIGKILL* {.importc: "SIGKILL", header: "<signal.h>".}: cint
+var SIGPIPE* {.importc: "SIGPIPE", header: "<signal.h>".}: cint
+var SIGQUIT* {.importc: "SIGQUIT", header: "<signal.h>".}: cint
+var SIGSEGV* {.importc: "SIGSEGV", header: "<signal.h>".}: cint
+var SIGSTOP* {.importc: "SIGSTOP", header: "<signal.h>".}: cint
+var SIGTERM* {.importc: "SIGTERM", header: "<signal.h>".}: cint
+var SIGTSTP* {.importc: "SIGTSTP", header: "<signal.h>".}: cint
+var SIGTTIN* {.importc: "SIGTTIN", header: "<signal.h>".}: cint
+var SIGTTOU* {.importc: "SIGTTOU", header: "<signal.h>".}: cint
+var SIGUSR1* {.importc: "SIGUSR1", header: "<signal.h>".}: cint
+var SIGUSR2* {.importc: "SIGUSR2", header: "<signal.h>".}: cint
+var SIGPOLL* {.importc: "SIGPOLL", header: "<signal.h>".}: cint
+var SIGPROF* {.importc: "SIGPROF", header: "<signal.h>".}: cint
+var SIGSYS* {.importc: "SIGSYS", header: "<signal.h>".}: cint
+var SIGTRAP* {.importc: "SIGTRAP", header: "<signal.h>".}: cint
+var SIGURG* {.importc: "SIGURG", header: "<signal.h>".}: cint
+var SIGVTALRM* {.importc: "SIGVTALRM", header: "<signal.h>".}: cint
+var SIGXCPU* {.importc: "SIGXCPU", header: "<signal.h>".}: cint
+var SIGXFSZ* {.importc: "SIGXFSZ", header: "<signal.h>".}: cint
+var SA_NOCLDSTOP* {.importc: "SA_NOCLDSTOP", header: "<signal.h>".}: cint
+var SIG_BLOCK* {.importc: "SIG_BLOCK", header: "<signal.h>".}: cint
+var SIG_UNBLOCK* {.importc: "SIG_UNBLOCK", header: "<signal.h>".}: cint
+var SIG_SETMASK* {.importc: "SIG_SETMASK", header: "<signal.h>".}: cint
+var SA_ONSTACK* {.importc: "SA_ONSTACK", header: "<signal.h>".}: cint
+var SA_RESETHAND* {.importc: "SA_RESETHAND", header: "<signal.h>".}: cint
+var SA_RESTART* {.importc: "SA_RESTART", header: "<signal.h>".}: cint
+var SA_SIGINFO* {.importc: "SA_SIGINFO", header: "<signal.h>".}: cint
+var SA_NOCLDWAIT* {.importc: "SA_NOCLDWAIT", header: "<signal.h>".}: cint
+var SA_NODEFER* {.importc: "SA_NODEFER", header: "<signal.h>".}: cint
+var SS_ONSTACK* {.importc: "SS_ONSTACK", header: "<signal.h>".}: cint
+var SS_DISABLE* {.importc: "SS_DISABLE", header: "<signal.h>".}: cint
+var MINSIGSTKSZ* {.importc: "MINSIGSTKSZ", header: "<signal.h>".}: cint
+var SIGSTKSZ* {.importc: "SIGSTKSZ", header: "<signal.h>".}: cint
+var SIG_HOLD* {.importc: "SIG_HOLD", header: "<signal.h>".}: Sighandler
+var SIG_DFL* {.importc: "SIG_DFL", header: "<signal.h>".}: Sighandler
+var SIG_ERR* {.importc: "SIG_ERR", header: "<signal.h>".}: Sighandler
+var SIG_IGN* {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler
+
+# <sys/ipc.h>
+var IPC_CREAT* {.importc: "IPC_CREAT", header: "<sys/ipc.h>".}: cint
+var IPC_EXCL* {.importc: "IPC_EXCL", header: "<sys/ipc.h>".}: cint
+var IPC_NOWAIT* {.importc: "IPC_NOWAIT", header: "<sys/ipc.h>".}: cint
+var IPC_PRIVATE* {.importc: "IPC_PRIVATE", header: "<sys/ipc.h>".}: cint
+var IPC_RMID* {.importc: "IPC_RMID", header: "<sys/ipc.h>".}: cint
+var IPC_SET* {.importc: "IPC_SET", header: "<sys/ipc.h>".}: cint
+var IPC_STAT* {.importc: "IPC_STAT", header: "<sys/ipc.h>".}: cint
+
+# <sys/mman.h>
+var PROT_READ* {.importc: "PROT_READ", header: "<sys/mman.h>".}: cint
+var PROT_WRITE* {.importc: "PROT_WRITE", header: "<sys/mman.h>".}: cint
+var PROT_EXEC* {.importc: "PROT_EXEC", header: "<sys/mman.h>".}: cint
+var PROT_NONE* {.importc: "PROT_NONE", header: "<sys/mman.h>".}: cint
+var MAP_ANONYMOUS* {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
+var MAP_FIXED_NOREPLACE* {.importc: "MAP_FIXED_NOREPLACE", header: "<sys/mman.h>".}: cint
+var MAP_NORESERVE* {.importc: "MAP_NORESERVE", header: "<sys/mman.h>".}: cint
+var MAP_SHARED* {.importc: "MAP_SHARED", header: "<sys/mman.h>".}: cint
+var MAP_PRIVATE* {.importc: "MAP_PRIVATE", header: "<sys/mman.h>".}: cint
+var MAP_FIXED* {.importc: "MAP_FIXED", header: "<sys/mman.h>".}: cint
+var MS_ASYNC* {.importc: "MS_ASYNC", header: "<sys/mman.h>".}: cint
+var MS_SYNC* {.importc: "MS_SYNC", header: "<sys/mman.h>".}: cint
+var MS_INVALIDATE* {.importc: "MS_INVALIDATE", header: "<sys/mman.h>".}: cint
+var MCL_CURRENT* {.importc: "MCL_CURRENT", header: "<sys/mman.h>".}: cint
+var MCL_FUTURE* {.importc: "MCL_FUTURE", header: "<sys/mman.h>".}: cint
+var MAP_FAILED* {.importc: "MAP_FAILED", header: "<sys/mman.h>".}: pointer
+var POSIX_MADV_NORMAL* {.importc: "POSIX_MADV_NORMAL", header: "<sys/mman.h>".}: cint
+var POSIX_MADV_SEQUENTIAL* {.importc: "POSIX_MADV_SEQUENTIAL", header: "<sys/mman.h>".}: cint
+var POSIX_MADV_RANDOM* {.importc: "POSIX_MADV_RANDOM", header: "<sys/mman.h>".}: cint
+var POSIX_MADV_WILLNEED* {.importc: "POSIX_MADV_WILLNEED", header: "<sys/mman.h>".}: cint
+var POSIX_MADV_DONTNEED* {.importc: "POSIX_MADV_DONTNEED", header: "<sys/mman.h>".}: cint
+var POSIX_TYPED_MEM_ALLOCATE* {.importc: "POSIX_TYPED_MEM_ALLOCATE", header: "<sys/mman.h>".}: cint
+var POSIX_TYPED_MEM_ALLOCATE_CONTIG* {.importc: "POSIX_TYPED_MEM_ALLOCATE_CONTIG", header: "<sys/mman.h>".}: cint
+var POSIX_TYPED_MEM_MAP_ALLOCATABLE* {.importc: "POSIX_TYPED_MEM_MAP_ALLOCATABLE", header: "<sys/mman.h>".}: cint
+
+# <sys/resource.h>
+var RLIMIT_NOFILE* {.importc: "RLIMIT_NOFILE", header: "<sys/resource.h>".}: cint
+var RLIMIT_STACK* {.importc: "RLIMIT_STACK", header: "<sys/resource.h>".}: cint
+
+# <sys/select.h>
+var FD_SETSIZE* {.importc: "FD_SETSIZE", header: "<sys/select.h>".}: cint
+when defined(zephyr):
+  # Zephyr specific hardcoded value
+  var FD_MAX* {.importc: "CONFIG_POSIX_MAX_FDS ", header: "<sys/select.h>".}: cint
+
+# <sys/socket.h>
+var MSG_CTRUNC* {.importc: "MSG_CTRUNC", header: "<sys/socket.h>".}: cint
+var MSG_DONTROUTE* {.importc: "MSG_DONTROUTE", header: "<sys/socket.h>".}: cint
+var MSG_EOR* {.importc: "MSG_EOR", header: "<sys/socket.h>".}: cint
+var MSG_OOB* {.importc: "MSG_OOB", header: "<sys/socket.h>".}: cint
+var SCM_RIGHTS* {.importc: "SCM_RIGHTS", header: "<sys/socket.h>".}: cint
+var SO_ACCEPTCONN* {.importc: "SO_ACCEPTCONN", header: "<sys/socket.h>".}: cint
+var SO_BINDTODEVICE* {.importc: "SO_BINDTODEVICE", header: "<sys/socket.h>".}: cint
+var SO_BROADCAST* {.importc: "SO_BROADCAST", header: "<sys/socket.h>".}: cint
+var SO_DEBUG* {.importc: "SO_DEBUG", header: "<sys/socket.h>".}: cint
+var SO_DONTROUTE* {.importc: "SO_DONTROUTE", header: "<sys/socket.h>".}: cint
+var SO_ERROR* {.importc: "SO_ERROR", header: "<sys/socket.h>".}: cint
+var SO_KEEPALIVE* {.importc: "SO_KEEPALIVE", header: "<sys/socket.h>".}: cint
+var SO_LINGER* {.importc: "SO_LINGER", header: "<sys/socket.h>".}: cint
+var SO_OOBINLINE* {.importc: "SO_OOBINLINE", header: "<sys/socket.h>".}: cint
+var SO_RCVBUF* {.importc: "SO_RCVBUF", header: "<sys/socket.h>".}: cint
+var SO_RCVLOWAT* {.importc: "SO_RCVLOWAT", header: "<sys/socket.h>".}: cint
+var SO_RCVTIMEO* {.importc: "SO_RCVTIMEO", header: "<sys/socket.h>".}: cint
+var SO_REUSEADDR* {.importc: "SO_REUSEADDR", header: "<sys/socket.h>".}: cint
+var SO_SNDBUF* {.importc: "SO_SNDBUF", header: "<sys/socket.h>".}: cint
+var SO_SNDLOWAT* {.importc: "SO_SNDLOWAT", header: "<sys/socket.h>".}: cint
+var SO_SNDTIMEO* {.importc: "SO_SNDTIMEO", header: "<sys/socket.h>".}: cint
+var SO_TYPE* {.importc: "SO_TYPE", header: "<sys/socket.h>".}: cint
+var SOCK_DGRAM* {.importc: "SOCK_DGRAM", header: "<sys/socket.h>".}: cint
+var SOCK_RAW* {.importc: "SOCK_RAW", header: "<sys/socket.h>".}: cint
+when defined(zephyr):
+  const SOCK_SEQPACKET* = cint(5)
+  var SOMAXCONN* {.importc: "CONFIG_NET_SOCKETS_POLL_MAX", header: "<sys/socket.h>".}: cint
+else:
+  var SOCK_SEQPACKET* {.importc: "SOCK_SEQPACKET", header: "<sys/socket.h>".}: cint
+  var SOMAXCONN* {.importc: "SOMAXCONN", header: "<sys/socket.h>".}: cint
+
+var SOCK_STREAM* {.importc: "SOCK_STREAM", header: "<sys/socket.h>".}: cint
+var SOL_SOCKET* {.importc: "SOL_SOCKET", header: "<sys/socket.h>".}: cint
+var MSG_PEEK* {.importc: "MSG_PEEK", header: "<sys/socket.h>".}: cint
+var MSG_TRUNC* {.importc: "MSG_TRUNC", header: "<sys/socket.h>".}: cint
+var MSG_WAITALL* {.importc: "MSG_WAITALL", header: "<sys/socket.h>".}: cint
+var AF_INET* {.importc: "AF_INET", header: "<sys/socket.h>".}: cint
+var AF_INET6* {.importc: "AF_INET6", header: "<sys/socket.h>".}: cint
+var AF_UNIX* {.importc: "AF_UNIX", header: "<sys/socket.h>".}: cint
+var AF_UNSPEC* {.importc: "AF_UNSPEC", header: "<sys/socket.h>".}: cint
+var SHUT_RD* {.importc: "SHUT_RD", header: "<sys/socket.h>".}: cint
+var SHUT_RDWR* {.importc: "SHUT_RDWR", header: "<sys/socket.h>".}: cint
+var SHUT_WR* {.importc: "SHUT_WR", header: "<sys/socket.h>".}: cint
+
+# <sys/stat.h>
+var S_IFBLK* {.importc: "S_IFBLK", header: "<sys/stat.h>".}: cint
+var S_IFCHR* {.importc: "S_IFCHR", header: "<sys/stat.h>".}: cint
+var S_IFDIR* {.importc: "S_IFDIR", header: "<sys/stat.h>".}: cint
+var S_IFIFO* {.importc: "S_IFIFO", header: "<sys/stat.h>".}: cint
+var S_IFLNK* {.importc: "S_IFLNK", header: "<sys/stat.h>".}: cint
+var S_IFMT* {.importc: "S_IFMT", header: "<sys/stat.h>".}: cint
+var S_IFREG* {.importc: "S_IFREG", header: "<sys/stat.h>".}: cint
+var S_IFSOCK* {.importc: "S_IFSOCK", header: "<sys/stat.h>".}: cint
+var S_IRGRP* {.importc: "S_IRGRP", header: "<sys/stat.h>".}: cint
+var S_IROTH* {.importc: "S_IROTH", header: "<sys/stat.h>".}: cint
+var S_IRUSR* {.importc: "S_IRUSR", header: "<sys/stat.h>".}: cint
+var S_IRWXG* {.importc: "S_IRWXG", header: "<sys/stat.h>".}: cint
+var S_IRWXO* {.importc: "S_IRWXO", header: "<sys/stat.h>".}: cint
+var S_IRWXU* {.importc: "S_IRWXU", header: "<sys/stat.h>".}: cint
+var S_ISGID* {.importc: "S_ISGID", header: "<sys/stat.h>".}: cint
+var S_ISUID* {.importc: "S_ISUID", header: "<sys/stat.h>".}: cint
+var S_ISVTX* {.importc: "S_ISVTX", header: "<sys/stat.h>".}: cint
+var S_IWGRP* {.importc: "S_IWGRP", header: "<sys/stat.h>".}: cint
+var S_IWOTH* {.importc: "S_IWOTH", header: "<sys/stat.h>".}: cint
+var S_IWUSR* {.importc: "S_IWUSR", header: "<sys/stat.h>".}: cint
+var S_IXGRP* {.importc: "S_IXGRP", header: "<sys/stat.h>".}: cint
+var S_IXOTH* {.importc: "S_IXOTH", header: "<sys/stat.h>".}: cint
+var S_IXUSR* {.importc: "S_IXUSR", header: "<sys/stat.h>".}: cint
+
+# <sys/statvfs.h>
+var ST_RDONLY* {.importc: "ST_RDONLY", header: "<sys/statvfs.h>".}: cint
+var ST_NOSUID* {.importc: "ST_NOSUID", header: "<sys/statvfs.h>".}: cint
+
+# <sys/wait.h>
+var WNOHANG* {.importc: "WNOHANG", header: "<sys/wait.h>".}: cint
+var WUNTRACED* {.importc: "WUNTRACED", header: "<sys/wait.h>".}: cint
+var WEXITED* {.importc: "WEXITED", header: "<sys/wait.h>".}: cint
+var WSTOPPED* {.importc: "WSTOPPED", header: "<sys/wait.h>".}: cint
+var WCONTINUED* {.importc: "WCONTINUED", header: "<sys/wait.h>".}: cint
+var WNOWAIT* {.importc: "WNOWAIT", header: "<sys/wait.h>".}: cint
+var P_ALL* {.importc: "P_ALL", header: "<sys/wait.h>".}: cint
+var P_PID* {.importc: "P_PID", header: "<sys/wait.h>".}: cint
+var P_PGID* {.importc: "P_PGID", header: "<sys/wait.h>".}: cint
+
+# <spawn.h>
+var POSIX_SPAWN_RESETIDS* {.importc: "POSIX_SPAWN_RESETIDS", header: "<spawn.h>".}: cint
+var POSIX_SPAWN_SETPGROUP* {.importc: "POSIX_SPAWN_SETPGROUP", header: "<spawn.h>".}: cint
+var POSIX_SPAWN_SETSCHEDPARAM* {.importc: "POSIX_SPAWN_SETSCHEDPARAM", header: "<spawn.h>".}: cint
+var POSIX_SPAWN_SETSCHEDULER* {.importc: "POSIX_SPAWN_SETSCHEDULER", header: "<spawn.h>".}: cint
+var POSIX_SPAWN_SETSIGDEF* {.importc: "POSIX_SPAWN_SETSIGDEF", header: "<spawn.h>".}: cint
+var POSIX_SPAWN_SETSIGMASK* {.importc: "POSIX_SPAWN_SETSIGMASK", header: "<spawn.h>".}: cint
+
+# <stdio.h>
+var IOFBF* {.importc: "_IOFBF", header: "<stdio.h>".}: cint
+var IONBF* {.importc: "_IONBF", header: "<stdio.h>".}: cint
+
+# <time.h>
+var CLOCKS_PER_SEC* {.importc: "CLOCKS_PER_SEC", header: "<time.h>".}: clong
+var CLOCK_PROCESS_CPUTIME_ID* {.importc: "CLOCK_PROCESS_CPUTIME_ID", header: "<time.h>".}: cint
+var CLOCK_THREAD_CPUTIME_ID* {.importc: "CLOCK_THREAD_CPUTIME_ID", header: "<time.h>".}: cint
+var CLOCK_REALTIME* {.importc: "CLOCK_REALTIME", header: "<time.h>".}: cint
+var TIMER_ABSTIME* {.importc: "TIMER_ABSTIME", header: "<time.h>".}: cint
+var CLOCK_MONOTONIC* {.importc: "CLOCK_MONOTONIC", header: "<time.h>".}: cint
+
+# <unistd.h>
+var POSIX_ASYNC_IO* {.importc: "_POSIX_ASYNC_IO", header: "<unistd.h>".}: cint
+var POSIX_PRIO_IO* {.importc: "_POSIX_PRIO_IO", header: "<unistd.h>".}: cint
+var POSIX_SYNC_IO* {.importc: "_POSIX_SYNC_IO", header: "<unistd.h>".}: cint
+var F_OK* {.importc: "F_OK", header: "<unistd.h>".}: cint
+var R_OK* {.importc: "R_OK", header: "<unistd.h>".}: cint
+var W_OK* {.importc: "W_OK", header: "<unistd.h>".}: cint
+var X_OK* {.importc: "X_OK", header: "<unistd.h>".}: cint
+var CS_PATH* {.importc: "_CS_PATH", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFF32_CFLAGS* {.importc: "_CS_POSIX_V6_ILP32_OFF32_CFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFF32_LDFLAGS* {.importc: "_CS_POSIX_V6_ILP32_OFF32_LDFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFF32_LIBS* {.importc: "_CS_POSIX_V6_ILP32_OFF32_LIBS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* {.importc: "_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* {.importc: "_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_ILP32_OFFBIG_LIBS* {.importc: "_CS_POSIX_V6_ILP32_OFFBIG_LIBS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LP64_OFF64_CFLAGS* {.importc: "_CS_POSIX_V6_LP64_OFF64_CFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LP64_OFF64_LDFLAGS* {.importc: "_CS_POSIX_V6_LP64_OFF64_LDFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LP64_OFF64_LIBS* {.importc: "_CS_POSIX_V6_LP64_OFF64_LIBS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* {.importc: "_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* {.importc: "_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_LPBIG_OFFBIG_LIBS* {.importc: "_CS_POSIX_V6_LPBIG_OFFBIG_LIBS", header: "<unistd.h>".}: cint
+var CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* {.importc: "_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS", header: "<unistd.h>".}: cint
+var F_LOCK* {.importc: "F_LOCK", header: "<unistd.h>".}: cint
+var F_TEST* {.importc: "F_TEST", header: "<unistd.h>".}: cint
+var F_TLOCK* {.importc: "F_TLOCK", header: "<unistd.h>".}: cint
+var F_ULOCK* {.importc: "F_ULOCK", header: "<unistd.h>".}: cint
+var PC_2_SYMLINKS* {.importc: "_PC_2_SYMLINKS", header: "<unistd.h>".}: cint
+var PC_ALLOC_SIZE_MIN* {.importc: "_PC_ALLOC_SIZE_MIN", header: "<unistd.h>".}: cint
+var PC_ASYNC_IO* {.importc: "_PC_ASYNC_IO", header: "<unistd.h>".}: cint
+var PC_CHOWN_RESTRICTED* {.importc: "_PC_CHOWN_RESTRICTED", header: "<unistd.h>".}: cint
+var PC_FILESIZEBITS* {.importc: "_PC_FILESIZEBITS", header: "<unistd.h>".}: cint
+var PC_LINK_MAX* {.importc: "_PC_LINK_MAX", header: "<unistd.h>".}: cint
+var PC_MAX_CANON* {.importc: "_PC_MAX_CANON", header: "<unistd.h>".}: cint
+var PC_MAX_INPUT* {.importc: "_PC_MAX_INPUT", header: "<unistd.h>".}: cint
+var PC_NAME_MAX* {.importc: "_PC_NAME_MAX", header: "<unistd.h>".}: cint
+var PC_NO_TRUNC* {.importc: "_PC_NO_TRUNC", header: "<unistd.h>".}: cint
+var PC_PATH_MAX* {.importc: "_PC_PATH_MAX", header: "<unistd.h>".}: cint
+var PC_PIPE_BUF* {.importc: "_PC_PIPE_BUF", header: "<unistd.h>".}: cint
+var PC_PRIO_IO* {.importc: "_PC_PRIO_IO", header: "<unistd.h>".}: cint
+var PC_REC_INCR_XFER_SIZE* {.importc: "_PC_REC_INCR_XFER_SIZE", header: "<unistd.h>".}: cint
+var PC_REC_MIN_XFER_SIZE* {.importc: "_PC_REC_MIN_XFER_SIZE", header: "<unistd.h>".}: cint
+var PC_REC_XFER_ALIGN* {.importc: "_PC_REC_XFER_ALIGN", header: "<unistd.h>".}: cint
+var PC_SYMLINK_MAX* {.importc: "_PC_SYMLINK_MAX", header: "<unistd.h>".}: cint
+var PC_SYNC_IO* {.importc: "_PC_SYNC_IO", header: "<unistd.h>".}: cint
+var PC_VDISABLE* {.importc: "_PC_VDISABLE", header: "<unistd.h>".}: cint
+var SC_2_C_BIND* {.importc: "_SC_2_C_BIND", header: "<unistd.h>".}: cint
+var SC_2_C_DEV* {.importc: "_SC_2_C_DEV", header: "<unistd.h>".}: cint
+var SC_2_CHAR_TERM* {.importc: "_SC_2_CHAR_TERM", header: "<unistd.h>".}: cint
+var SC_2_FORT_DEV* {.importc: "_SC_2_FORT_DEV", header: "<unistd.h>".}: cint
+var SC_2_FORT_RUN* {.importc: "_SC_2_FORT_RUN", header: "<unistd.h>".}: cint
+var SC_2_LOCALEDEF* {.importc: "_SC_2_LOCALEDEF", header: "<unistd.h>".}: cint
+var SC_2_PBS* {.importc: "_SC_2_PBS", header: "<unistd.h>".}: cint
+var SC_2_PBS_ACCOUNTING* {.importc: "_SC_2_PBS_ACCOUNTING", header: "<unistd.h>".}: cint
+var SC_2_PBS_CHECKPOINT* {.importc: "_SC_2_PBS_CHECKPOINT", header: "<unistd.h>".}: cint
+var SC_2_PBS_LOCATE* {.importc: "_SC_2_PBS_LOCATE", header: "<unistd.h>".}: cint
+var SC_2_PBS_MESSAGE* {.importc: "_SC_2_PBS_MESSAGE", header: "<unistd.h>".}: cint
+var SC_2_PBS_TRACK* {.importc: "_SC_2_PBS_TRACK", header: "<unistd.h>".}: cint
+var SC_2_SW_DEV* {.importc: "_SC_2_SW_DEV", header: "<unistd.h>".}: cint
+var SC_2_UPE* {.importc: "_SC_2_UPE", header: "<unistd.h>".}: cint
+var SC_2_VERSION* {.importc: "_SC_2_VERSION", header: "<unistd.h>".}: cint
+var SC_ADVISORY_INFO* {.importc: "_SC_ADVISORY_INFO", header: "<unistd.h>".}: cint
+var SC_AIO_LISTIO_MAX* {.importc: "_SC_AIO_LISTIO_MAX", header: "<unistd.h>".}: cint
+var SC_AIO_MAX* {.importc: "_SC_AIO_MAX", header: "<unistd.h>".}: cint
+var SC_AIO_PRIO_DELTA_MAX* {.importc: "_SC_AIO_PRIO_DELTA_MAX", header: "<unistd.h>".}: cint
+var SC_ARG_MAX* {.importc: "_SC_ARG_MAX", header: "<unistd.h>".}: cint
+var SC_ASYNCHRONOUS_IO* {.importc: "_SC_ASYNCHRONOUS_IO", header: "<unistd.h>".}: cint
+var SC_ATEXIT_MAX* {.importc: "_SC_ATEXIT_MAX", header: "<unistd.h>".}: cint
+var SC_BARRIERS* {.importc: "_SC_BARRIERS", header: "<unistd.h>".}: cint
+var SC_BC_BASE_MAX* {.importc: "_SC_BC_BASE_MAX", header: "<unistd.h>".}: cint
+var SC_BC_DIM_MAX* {.importc: "_SC_BC_DIM_MAX", header: "<unistd.h>".}: cint
+var SC_BC_SCALE_MAX* {.importc: "_SC_BC_SCALE_MAX", header: "<unistd.h>".}: cint
+var SC_BC_STRING_MAX* {.importc: "_SC_BC_STRING_MAX", header: "<unistd.h>".}: cint
+var SC_CHILD_MAX* {.importc: "_SC_CHILD_MAX", header: "<unistd.h>".}: cint
+var SC_CLK_TCK* {.importc: "_SC_CLK_TCK", header: "<unistd.h>".}: cint
+var SC_CLOCK_SELECTION* {.importc: "_SC_CLOCK_SELECTION", header: "<unistd.h>".}: cint
+var SC_COLL_WEIGHTS_MAX* {.importc: "_SC_COLL_WEIGHTS_MAX", header: "<unistd.h>".}: cint
+var SC_CPUTIME* {.importc: "_SC_CPUTIME", header: "<unistd.h>".}: cint
+var SC_DELAYTIMER_MAX* {.importc: "_SC_DELAYTIMER_MAX", header: "<unistd.h>".}: cint
+var SC_EXPR_NEST_MAX* {.importc: "_SC_EXPR_NEST_MAX", header: "<unistd.h>".}: cint
+var SC_FSYNC* {.importc: "_SC_FSYNC", header: "<unistd.h>".}: cint
+var SC_GETGR_R_SIZE_MAX* {.importc: "_SC_GETGR_R_SIZE_MAX", header: "<unistd.h>".}: cint
+var SC_GETPW_R_SIZE_MAX* {.importc: "_SC_GETPW_R_SIZE_MAX", header: "<unistd.h>".}: cint
+var SC_HOST_NAME_MAX* {.importc: "_SC_HOST_NAME_MAX", header: "<unistd.h>".}: cint
+var SC_IOV_MAX* {.importc: "_SC_IOV_MAX", header: "<unistd.h>".}: cint
+var SC_IPV6* {.importc: "_SC_IPV6", header: "<unistd.h>".}: cint
+var SC_JOB_CONTROL* {.importc: "_SC_JOB_CONTROL", header: "<unistd.h>".}: cint
+var SC_LINE_MAX* {.importc: "_SC_LINE_MAX", header: "<unistd.h>".}: cint
+var SC_LOGIN_NAME_MAX* {.importc: "_SC_LOGIN_NAME_MAX", header: "<unistd.h>".}: cint
+var SC_MAPPED_FILES* {.importc: "_SC_MAPPED_FILES", header: "<unistd.h>".}: cint
+var SC_MEMLOCK* {.importc: "_SC_MEMLOCK", header: "<unistd.h>".}: cint
+var SC_MEMLOCK_RANGE* {.importc: "_SC_MEMLOCK_RANGE", header: "<unistd.h>".}: cint
+var SC_MEMORY_PROTECTION* {.importc: "_SC_MEMORY_PROTECTION", header: "<unistd.h>".}: cint
+var SC_MESSAGE_PASSING* {.importc: "_SC_MESSAGE_PASSING", header: "<unistd.h>".}: cint
+var SC_MONOTONIC_CLOCK* {.importc: "_SC_MONOTONIC_CLOCK", header: "<unistd.h>".}: cint
+var SC_MQ_OPEN_MAX* {.importc: "_SC_MQ_OPEN_MAX", header: "<unistd.h>".}: cint
+var SC_MQ_PRIO_MAX* {.importc: "_SC_MQ_PRIO_MAX", header: "<unistd.h>".}: cint
+var SC_NGROUPS_MAX* {.importc: "_SC_NGROUPS_MAX", header: "<unistd.h>".}: cint
+var SC_OPEN_MAX* {.importc: "_SC_OPEN_MAX", header: "<unistd.h>".}: cint
+var SC_PAGESIZE* {.importc: "_SC_PAGESIZE", header: "<unistd.h>".}: cint
+var SC_PRIORITIZED_IO* {.importc: "_SC_PRIORITIZED_IO", header: "<unistd.h>".}: cint
+var SC_PRIORITY_SCHEDULING* {.importc: "_SC_PRIORITY_SCHEDULING", header: "<unistd.h>".}: cint
+var SC_RAW_SOCKETS* {.importc: "_SC_RAW_SOCKETS", header: "<unistd.h>".}: cint
+var SC_RE_DUP_MAX* {.importc: "_SC_RE_DUP_MAX", header: "<unistd.h>".}: cint
+var SC_READER_WRITER_LOCKS* {.importc: "_SC_READER_WRITER_LOCKS", header: "<unistd.h>".}: cint
+var SC_REALTIME_SIGNALS* {.importc: "_SC_REALTIME_SIGNALS", header: "<unistd.h>".}: cint
+var SC_REGEXP* {.importc: "_SC_REGEXP", header: "<unistd.h>".}: cint
+var SC_RTSIG_MAX* {.importc: "_SC_RTSIG_MAX", header: "<unistd.h>".}: cint
+var SC_SAVED_IDS* {.importc: "_SC_SAVED_IDS", header: "<unistd.h>".}: cint
+var SC_SEM_NSEMS_MAX* {.importc: "_SC_SEM_NSEMS_MAX", header: "<unistd.h>".}: cint
+var SC_SEM_VALUE_MAX* {.importc: "_SC_SEM_VALUE_MAX", header: "<unistd.h>".}: cint
+var SC_SEMAPHORES* {.importc: "_SC_SEMAPHORES", header: "<unistd.h>".}: cint
+var SC_SHARED_MEMORY_OBJECTS* {.importc: "_SC_SHARED_MEMORY_OBJECTS", header: "<unistd.h>".}: cint
+var SC_SHELL* {.importc: "_SC_SHELL", header: "<unistd.h>".}: cint
+var SC_SIGQUEUE_MAX* {.importc: "_SC_SIGQUEUE_MAX", header: "<unistd.h>".}: cint
+var SC_SPAWN* {.importc: "_SC_SPAWN", header: "<unistd.h>".}: cint
+var SC_SPIN_LOCKS* {.importc: "_SC_SPIN_LOCKS", header: "<unistd.h>".}: cint
+var SC_SPORADIC_SERVER* {.importc: "_SC_SPORADIC_SERVER", header: "<unistd.h>".}: cint
+var SC_SS_REPL_MAX* {.importc: "_SC_SS_REPL_MAX", header: "<unistd.h>".}: cint
+var SC_STREAM_MAX* {.importc: "_SC_STREAM_MAX", header: "<unistd.h>".}: cint
+var SC_SYMLOOP_MAX* {.importc: "_SC_SYMLOOP_MAX", header: "<unistd.h>".}: cint
+var SC_SYNCHRONIZED_IO* {.importc: "_SC_SYNCHRONIZED_IO", header: "<unistd.h>".}: cint
+var SC_THREAD_ATTR_STACKADDR* {.importc: "_SC_THREAD_ATTR_STACKADDR", header: "<unistd.h>".}: cint
+var SC_THREAD_ATTR_STACKSIZE* {.importc: "_SC_THREAD_ATTR_STACKSIZE", header: "<unistd.h>".}: cint
+var SC_THREAD_CPUTIME* {.importc: "_SC_THREAD_CPUTIME", header: "<unistd.h>".}: cint
+var SC_THREAD_DESTRUCTOR_ITERATIONS* {.importc: "_SC_THREAD_DESTRUCTOR_ITERATIONS", header: "<unistd.h>".}: cint
+var SC_THREAD_KEYS_MAX* {.importc: "_SC_THREAD_KEYS_MAX", header: "<unistd.h>".}: cint
+var SC_THREAD_PRIO_INHERIT* {.importc: "_SC_THREAD_PRIO_INHERIT", header: "<unistd.h>".}: cint
+var SC_THREAD_PRIO_PROTECT* {.importc: "_SC_THREAD_PRIO_PROTECT", header: "<unistd.h>".}: cint
+var SC_THREAD_PRIORITY_SCHEDULING* {.importc: "_SC_THREAD_PRIORITY_SCHEDULING", header: "<unistd.h>".}: cint
+var SC_THREAD_PROCESS_SHARED* {.importc: "_SC_THREAD_PROCESS_SHARED", header: "<unistd.h>".}: cint
+var SC_THREAD_SAFE_FUNCTIONS* {.importc: "_SC_THREAD_SAFE_FUNCTIONS", header: "<unistd.h>".}: cint
+var SC_THREAD_SPORADIC_SERVER* {.importc: "_SC_THREAD_SPORADIC_SERVER", header: "<unistd.h>".}: cint
+var SC_THREAD_STACK_MIN* {.importc: "_SC_THREAD_STACK_MIN", header: "<unistd.h>".}: cint
+var SC_THREAD_THREADS_MAX* {.importc: "_SC_THREAD_THREADS_MAX", header: "<unistd.h>".}: cint
+var SC_THREADS* {.importc: "_SC_THREADS", header: "<unistd.h>".}: cint
+var SC_TIMEOUTS* {.importc: "_SC_TIMEOUTS", header: "<unistd.h>".}: cint
+var SC_TIMER_MAX* {.importc: "_SC_TIMER_MAX", header: "<unistd.h>".}: cint
+var SC_TIMERS* {.importc: "_SC_TIMERS", header: "<unistd.h>".}: cint
+var SC_TRACE* {.importc: "_SC_TRACE", header: "<unistd.h>".}: cint
+var SC_TRACE_EVENT_FILTER* {.importc: "_SC_TRACE_EVENT_FILTER", header: "<unistd.h>".}: cint
+var SC_TRACE_EVENT_NAME_MAX* {.importc: "_SC_TRACE_EVENT_NAME_MAX", header: "<unistd.h>".}: cint
+var SC_TRACE_INHERIT* {.importc: "_SC_TRACE_INHERIT", header: "<unistd.h>".}: cint
+var SC_TRACE_LOG* {.importc: "_SC_TRACE_LOG", header: "<unistd.h>".}: cint
+var SC_TRACE_NAME_MAX* {.importc: "_SC_TRACE_NAME_MAX", header: "<unistd.h>".}: cint
+var SC_TRACE_SYS_MAX* {.importc: "_SC_TRACE_SYS_MAX", header: "<unistd.h>".}: cint
+var SC_TRACE_USER_EVENT_MAX* {.importc: "_SC_TRACE_USER_EVENT_MAX", header: "<unistd.h>".}: cint
+var SC_TTY_NAME_MAX* {.importc: "_SC_TTY_NAME_MAX", header: "<unistd.h>".}: cint
+var SC_TYPED_MEMORY_OBJECTS* {.importc: "_SC_TYPED_MEMORY_OBJECTS", header: "<unistd.h>".}: cint
+var SC_TZNAME_MAX* {.importc: "_SC_TZNAME_MAX", header: "<unistd.h>".}: cint
+var SC_V6_ILP32_OFF32* {.importc: "_SC_V6_ILP32_OFF32", header: "<unistd.h>".}: cint
+var SC_V6_ILP32_OFFBIG* {.importc: "_SC_V6_ILP32_OFFBIG", header: "<unistd.h>".}: cint
+var SC_V6_LP64_OFF64* {.importc: "_SC_V6_LP64_OFF64", header: "<unistd.h>".}: cint
+var SC_V6_LPBIG_OFFBIG* {.importc: "_SC_V6_LPBIG_OFFBIG", header: "<unistd.h>".}: cint
+var SC_VERSION* {.importc: "_SC_VERSION", header: "<unistd.h>".}: cint
+var SC_XBS5_ILP32_OFF32* {.importc: "_SC_XBS5_ILP32_OFF32", header: "<unistd.h>".}: cint
+var SC_XBS5_ILP32_OFFBIG* {.importc: "_SC_XBS5_ILP32_OFFBIG", header: "<unistd.h>".}: cint
+var SC_XBS5_LP64_OFF64* {.importc: "_SC_XBS5_LP64_OFF64", header: "<unistd.h>".}: cint
+var SC_XBS5_LPBIG_OFFBIG* {.importc: "_SC_XBS5_LPBIG_OFFBIG", header: "<unistd.h>".}: cint
+var SC_XOPEN_CRYPT* {.importc: "_SC_XOPEN_CRYPT", header: "<unistd.h>".}: cint
+var SC_XOPEN_ENH_I18N* {.importc: "_SC_XOPEN_ENH_I18N", header: "<unistd.h>".}: cint
+var SC_XOPEN_LEGACY* {.importc: "_SC_XOPEN_LEGACY", header: "<unistd.h>".}: cint
+var SC_XOPEN_REALTIME* {.importc: "_SC_XOPEN_REALTIME", header: "<unistd.h>".}: cint
+var SC_XOPEN_REALTIME_THREADS* {.importc: "_SC_XOPEN_REALTIME_THREADS", header: "<unistd.h>".}: cint
+var SC_XOPEN_SHM* {.importc: "_SC_XOPEN_SHM", header: "<unistd.h>".}: cint
+var SC_XOPEN_STREAMS* {.importc: "_SC_XOPEN_STREAMS", header: "<unistd.h>".}: cint
+var SC_XOPEN_UNIX* {.importc: "_SC_XOPEN_UNIX", header: "<unistd.h>".}: cint
+var SC_XOPEN_VERSION* {.importc: "_SC_XOPEN_VERSION", header: "<unistd.h>".}: cint
+var SC_NPROCESSORS_ONLN* {.importc: "_SC_NPROCESSORS_ONLN", header: "<unistd.h>".}: cint
+var SEEK_SET* {.importc: "SEEK_SET", header: "<unistd.h>".}: cint
+var SEEK_CUR* {.importc: "SEEK_CUR", header: "<unistd.h>".}: cint
+var SEEK_END* {.importc: "SEEK_END", header: "<unistd.h>".}: cint
+
+# <nuttx/config.h>
+when defined(nuttx):
+  var NEPOLL_MAX* {.importc: "CONFIG_FS_NEPOLL_DESCRIPTORS", header: "<nuttx/config.h>".}: cint
diff --git a/lib/posix/posix_utils.nim b/lib/posix/posix_utils.nim
new file mode 100644
index 000000000..0c668246f
--- /dev/null
+++ b/lib/posix/posix_utils.nim
@@ -0,0 +1,133 @@
+#
+#            Nim's Runtime Library
+#    (c) Copyright 2019 Federico Ceratto and other Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## A set of helpers for the POSIX module.
+## Raw interfaces are in the other ``posix*.nim`` files.
+
+# Where possible, contribute OS-independent procs in `os <os.html>`_ instead.
+
+import std/[posix, parsecfg, os]
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+type Uname* = object
+  sysname*, nodename*, release*, version*, machine*: string
+
+template charArrayToString(input: typed): string =
+  $cast[cstring](addr input)
+
+proc uname*(): Uname =
+  ## Provides system information in a `Uname` struct with sysname, nodename,
+  ## release, version and machine attributes.
+
+  when defined(posix):
+    runnableExamples:
+      echo uname().nodename, uname().release, uname().version
+      doAssert uname().sysname.len != 0
+
+  var u: Utsname
+  if uname(u) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+  result.sysname = charArrayToString u.sysname
+  result.nodename = charArrayToString u.nodename
+  result.release = charArrayToString u.release
+  result.version = charArrayToString u.version
+  result.machine = charArrayToString u.machine
+
+proc fsync*(fd: int) =
+  ## synchronize a file's buffer cache to the storage device
+  if fsync(fd.cint) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc stat*(path: string): Stat =
+  ## Returns file status in a `Stat` structure
+  if stat(path.cstring, result) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc memoryLock*(a1: pointer, a2: int) =
+  ## Locks pages starting from a1 for a1 bytes and prevent them from being swapped.
+  if mlock(a1, a2) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc memoryLockAll*(flags: int) =
+  ## Locks all memory for the running process to prevent swapping.
+  ##
+  ## example:
+  ##   ```nim
+  ##   memoryLockAll(MCL_CURRENT or MCL_FUTURE)
+  ##   ```
+  if mlockall(flags.cint) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc memoryUnlock*(a1: pointer, a2: int) =
+  ## Unlock pages starting from a1 for a1 bytes and allow them to be swapped.
+  if munlock(a1, a2) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc memoryUnlockAll*() =
+  ## Unlocks all memory for the running process to allow swapping.
+  if munlockall() != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc sendSignal*(pid: Pid, signal: int) =
+  ## Sends a signal to a running process by calling `kill`.
+  ## Raise exception in case of failure e.g. process not running.
+  if kill(pid, signal.cint) != 0:
+    raiseOSError(OSErrorCode(errno))
+
+proc mkstemp*(prefix: string, suffix=""): (string, File) =
+  ## Creates a unique temporary file from a prefix string. A six-character string
+  ## will be added. If suffix is provided it will be added to the string
+  ## The file is created with perms 0600.
+  ## Returns the filename and a file opened in r/w mode.
+  var tmpl = cstring(prefix & "XXXXXX" & suffix)
+  let fd =
+    if len(suffix) == 0:
+      when declared(mkostemp):
+        mkostemp(tmpl, O_CLOEXEC)
+      else:
+        mkstemp(tmpl)
+    else:
+      when declared(mkostemps):
+        mkostemps(tmpl, cint(len(suffix)), O_CLOEXEC)
+      else:
+        mkstemps(tmpl, cint(len(suffix)))
+  var f: File
+  if open(f, fd, fmReadWrite):
+    return ($tmpl, f)
+  raiseOSError(OSErrorCode(errno))
+
+proc mkdtemp*(prefix: string): string =
+  ## Creates a unique temporary directory from a prefix string. Adds a six chars suffix.
+  ## The directory is created with permissions 0700. Returns the directory name.
+  var tmpl = cstring(prefix & "XXXXXX")
+  if mkdtemp(tmpl) == nil:
+    raiseOSError(OSErrorCode(errno))
+  return $tmpl
+
+proc osReleaseFile*(): Config {.since: (1, 5).} =
+  ## Gets system identification from `os-release` file and returns it as a `parsecfg.Config`.
+  ## You also need to import the `parsecfg` module to gain access to this object.
+  ## The `os-release` file is an official Freedesktop.org open standard.
+  ## Available in Linux and BSD distributions, except Android and Android-based Linux.
+  ## `os-release` file is not available on Windows and OS X by design.
+  ## * https://www.freedesktop.org/software/systemd/man/os-release.html
+  runnableExamples:
+    import std/parsecfg
+    when defined(linux):
+      let data = osReleaseFile()
+      echo "OS name: ", data.getSectionValue("", "NAME") ## the data is up to each distro.
+
+  # We do not use a {.strdefine.} because Standard says it *must* be that path.
+  for osReleaseFile in ["/etc/os-release", "/usr/lib/os-release"]:
+    if fileExists(osReleaseFile):
+      return loadConfig(osReleaseFile)
+  raise newException(IOError, "File not found: /etc/os-release, /usr/lib/os-release")
diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim
new file mode 100644
index 000000000..7fb6bb81c
--- /dev/null
+++ b/lib/posix/termios.nim
@@ -0,0 +1,256 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+import std/posix
+
+type
+  Speed* = cuint
+  Cflag* = cuint
+
+const
+  NCCS* = when defined(macosx): 20 else: 32
+
+when defined(linux) and defined(amd64):
+  type
+    Termios* {.importc: "struct termios", header: "<termios.h>".} = object
+      c_iflag*: Cflag        # input mode flags
+      c_oflag*: Cflag        # output mode flags
+      c_cflag*: Cflag        # control mode flags
+      c_lflag*: Cflag        # local mode flags
+      c_line*: cuchar
+      c_cc*: array[NCCS, cuchar]  # control characters
+      c_ispeed*: Speed
+      c_ospeed*: Speed
+else:
+  type
+    Termios* {.importc: "struct termios", header: "<termios.h>".} = object
+      c_iflag*: Cflag        # input mode flags
+      c_oflag*: Cflag        # output mode flags
+      c_cflag*: Cflag        # control mode flags
+      c_lflag*: Cflag        # local mode flags
+      c_cc*: array[NCCS, cuchar]  # control characters
+
+# cc characters
+
+var
+  VINTR* {.importc, header: "<termios.h>".}: cint
+  VQUIT* {.importc, header: "<termios.h>".}: cint
+  VERASE* {.importc, header: "<termios.h>".}: cint
+  VKILL* {.importc, header: "<termios.h>".}: cint
+  VEOF* {.importc, header: "<termios.h>".}: cint
+  VTIME* {.importc, header: "<termios.h>".}: cint
+  VMIN* {.importc, header: "<termios.h>".}: cint
+  VSTART* {.importc, header: "<termios.h>".}: cint
+  VSTOP* {.importc, header: "<termios.h>".}: cint
+  VSUSP* {.importc, header: "<termios.h>".}: cint
+  VEOL* {.importc, header: "<termios.h>".}: cint
+
+# iflag bits
+
+var
+  IGNBRK* {.importc, header: "<termios.h>".}: Cflag
+  BRKINT* {.importc, header: "<termios.h>".}: Cflag
+  IGNPAR* {.importc, header: "<termios.h>".}: Cflag
+  PARMRK* {.importc, header: "<termios.h>".}: Cflag
+  INPCK* {.importc, header: "<termios.h>".}: Cflag
+  ISTRIP* {.importc, header: "<termios.h>".}: Cflag
+  INLCR* {.importc, header: "<termios.h>".}: Cflag
+  IGNCR* {.importc, header: "<termios.h>".}: Cflag
+  ICRNL* {.importc, header: "<termios.h>".}: Cflag
+  IUCLC* {.importc, header: "<termios.h>".}: Cflag
+  IXON* {.importc, header: "<termios.h>".}: Cflag
+  IXANY* {.importc, header: "<termios.h>".}: Cflag
+  IXOFF* {.importc, header: "<termios.h>".}: Cflag
+
+# oflag bits
+
+var
+  OPOST* {.importc, header: "<termios.h>".}: Cflag
+  ONLCR* {.importc, header: "<termios.h>".}: Cflag
+  OCRNL* {.importc, header: "<termios.h>".}: Cflag
+  ONOCR* {.importc, header: "<termios.h>".}: Cflag
+  ONLRET* {.importc, header: "<termios.h>".}: Cflag
+  OFILL* {.importc, header: "<termios.h>".}: Cflag
+  OFDEL* {.importc, header: "<termios.h>".}: Cflag
+  NLDLY* {.importc, header: "<termios.h>".}: Cflag
+  NL0* {.importc, header: "<termios.h>".}: Cflag
+  NL1* {.importc, header: "<termios.h>".}: Cflag
+  CRDLY* {.importc, header: "<termios.h>".}: Cflag
+  CR0* {.importc, header: "<termios.h>".}: Cflag
+  CR1* {.importc, header: "<termios.h>".}: Cflag
+  CR2* {.importc, header: "<termios.h>".}: Cflag
+  CR3* {.importc, header: "<termios.h>".}: Cflag
+  TABDLY* {.importc, header: "<termios.h>".}: Cflag
+  TAB0* {.importc, header: "<termios.h>".}: Cflag
+  TAB1* {.importc, header: "<termios.h>".}: Cflag
+  TAB2* {.importc, header: "<termios.h>".}: Cflag
+  TAB3* {.importc, header: "<termios.h>".}: Cflag
+  BSDLY* {.importc, header: "<termios.h>".}: Cflag
+  BS0* {.importc, header: "<termios.h>".}: Cflag
+  BS1* {.importc, header: "<termios.h>".}: Cflag
+  FFDLY* {.importc, header: "<termios.h>".}: Cflag
+  FF0* {.importc, header: "<termios.h>".}: Cflag
+  FF1* {.importc, header: "<termios.h>".}: Cflag
+  VTDLY* {.importc, header: "<termios.h>".}: Cflag
+  VT0* {.importc, header: "<termios.h>".}: Cflag
+  VT1* {.importc, header: "<termios.h>".}: Cflag
+
+# cflag bit meaning
+
+var
+  B0* {.importc, header: "<termios.h>".}: Speed
+  B50* {.importc, header: "<termios.h>".}: Speed
+  B75* {.importc, header: "<termios.h>".}: Speed
+  B110* {.importc, header: "<termios.h>".}: Speed
+  B134* {.importc, header: "<termios.h>".}: Speed
+  B150* {.importc, header: "<termios.h>".}: Speed
+  B200* {.importc, header: "<termios.h>".}: Speed
+  B300* {.importc, header: "<termios.h>".}: Speed
+  B600* {.importc, header: "<termios.h>".}: Speed
+  B1200* {.importc, header: "<termios.h>".}: Speed
+  B1800* {.importc, header: "<termios.h>".}: Speed
+  B2400* {.importc, header: "<termios.h>".}: Speed
+  B4800* {.importc, header: "<termios.h>".}: Speed
+  B9600* {.importc, header: "<termios.h>".}: Speed
+  B19200* {.importc, header: "<termios.h>".}: Speed
+  B38400* {.importc, header: "<termios.h>".}: Speed
+  B57600* {.importc, header: "<termios.h>".}: Speed
+  B115200* {.importc, header: "<termios.h>".}: Speed
+  B230400* {.importc, header: "<termios.h>".}: Speed
+  B460800* {.importc, header: "<termios.h>".}: Speed
+  B500000* {.importc, header: "<termios.h>".}: Speed
+  B576000* {.importc, header: "<termios.h>".}: Speed
+  B921600* {.importc, header: "<termios.h>".}: Speed
+  B1000000* {.importc, header: "<termios.h>".}: Speed
+  B1152000* {.importc, header: "<termios.h>".}: Speed
+  B1500000* {.importc, header: "<termios.h>".}: Speed
+  B2000000* {.importc, header: "<termios.h>".}: Speed
+  B2500000* {.importc, header: "<termios.h>".}: Speed
+  B3000000* {.importc, header: "<termios.h>".}: Speed
+  B3500000* {.importc, header: "<termios.h>".}: Speed
+  B4000000* {.importc, header: "<termios.h>".}: Speed
+  EXTA* {.importc, header: "<termios.h>".}: Speed
+  EXTB* {.importc, header: "<termios.h>".}: Speed
+  CSIZE* {.importc, header: "<termios.h>".}: Cflag
+  CS5* {.importc, header: "<termios.h>".}: Cflag
+  CS6* {.importc, header: "<termios.h>".}: Cflag
+  CS7* {.importc, header: "<termios.h>".}: Cflag
+  CS8* {.importc, header: "<termios.h>".}: Cflag
+  CSTOPB* {.importc, header: "<termios.h>".}: Cflag
+  CREAD* {.importc, header: "<termios.h>".}: Cflag
+  PARENB* {.importc, header: "<termios.h>".}: Cflag
+  PARODD* {.importc, header: "<termios.h>".}: Cflag
+  HUPCL* {.importc, header: "<termios.h>".}: Cflag
+  CLOCAL* {.importc, header: "<termios.h>".}: Cflag
+
+# lflag bits
+
+var
+  ISIG* {.importc, header: "<termios.h>".}: Cflag
+  ICANON* {.importc, header: "<termios.h>".}: Cflag
+  ECHO* {.importc, header: "<termios.h>".}: Cflag
+  ECHOE* {.importc, header: "<termios.h>".}: Cflag
+  ECHOK* {.importc, header: "<termios.h>".}: Cflag
+  ECHONL* {.importc, header: "<termios.h>".}: Cflag
+  NOFLSH* {.importc, header: "<termios.h>".}: Cflag
+  TOSTOP* {.importc, header: "<termios.h>".}: Cflag
+  IEXTEN* {.importc, header: "<termios.h>".}: Cflag
+
+# tcflow() and TCXONC use these
+
+var
+  TCOOFF* {.importc, header: "<termios.h>".}: cint
+  TCOON* {.importc, header: "<termios.h>".}: cint
+  TCIOFF* {.importc, header: "<termios.h>".}: cint
+  TCION* {.importc, header: "<termios.h>".}: cint
+
+# tcflush() and TCFLSH use these
+
+var
+  TCIFLUSH* {.importc, header: "<termios.h>".}: cint
+  TCOFLUSH* {.importc, header: "<termios.h>".}: cint
+  TCIOFLUSH* {.importc, header: "<termios.h>".}: cint
+
+# tcsetattr uses these
+
+var
+  TCSANOW* {.importc, header: "<termios.h>".}: cint
+  TCSADRAIN* {.importc, header: "<termios.h>".}: cint
+  TCSAFLUSH* {.importc, header: "<termios.h>".}: cint
+
+# Compare a character C to a value VAL from the `cc' array in a
+#   `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.
+
+template cceq*(val, c): untyped =
+  c == val and val != POSIX_VDISABLE
+
+# Return the output baud rate stored in *TERMIOS_P.
+
+proc cfGetOspeed*(termios: ptr Termios): Speed {.importc: "cfgetospeed",
+    header: "<termios.h>".}
+# Return the input baud rate stored in *TERMIOS_P.
+
+proc cfGetIspeed*(termios: ptr Termios): Speed {.importc: "cfgetispeed",
+    header: "<termios.h>".}
+# Set the output baud rate stored in *TERMIOS_P to SPEED.
+
+proc cfSetOspeed*(termios: ptr Termios; speed: Speed): cint {.
+    importc: "cfsetospeed", header: "<termios.h>".}
+# Set the input baud rate stored in *TERMIOS_P to SPEED.
+
+proc cfSetIspeed*(termios: ptr Termios; speed: Speed): cint {.
+    importc: "cfsetispeed", header: "<termios.h>".}
+# Set both the input and output baud rates in *TERMIOS_OP to SPEED.
+
+proc tcGetAttr*(fd: cint; termios: ptr Termios): cint {.
+    importc: "tcgetattr", header: "<termios.h>".}
+# Set the state of FD to *TERMIOS_P.
+#   Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>.
+
+proc tcSetAttr*(fd: cint; optional_actions: cint; termios: ptr Termios): cint {.
+    importc: "tcsetattr", header: "<termios.h>".}
+# Set *TERMIOS_P to indicate raw mode.
+
+proc tcSendBreak*(fd: cint; duration: cint): cint {.importc: "tcsendbreak",
+    header: "<termios.h>".}
+# Wait for pending output to be written on FD.
+#
+#   This function is a cancellation point and therefore not marked with
+#  .
+
+proc tcDrain*(fd: cint): cint {.importc: "tcdrain", header: "<termios.h>".}
+# Flush pending data on FD.
+#   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>.
+
+proc tcFlush*(fd: cint; queue_selector: cint): cint {.importc: "tcflush",
+    header: "<termios.h>".}
+# Suspend or restart transmission on FD.
+#   Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>.
+
+proc tcFlow*(fd: cint; action: cint): cint {.importc: "tcflow",
+    header: "<termios.h>".}
+# Get process group ID for session leader for controlling terminal FD.
+
+# Window size ioctl.  Solaris based systems have an uncommen place for this.
+when defined(solaris) or defined(sunos):
+  var TIOCGWINSZ*{.importc, header: "<sys/termios.h>".}: culong
+else:
+  var TIOCGWINSZ*{.importc, header: "<sys/ioctl.h>".}: culong
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+type IOctl_WinSize* = object
+  ws_row*, ws_col*, ws_xpixel*, ws_ypixel*: cushort
+
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+proc ioctl*(fd: cint, request: culong, reply: ptr IOctl_WinSize): int {.
+  importc: "ioctl", header: "<stdio.h>", varargs.}
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim
new file mode 100644
index 000000000..b12ed7cdd
--- /dev/null
+++ b/lib/pure/algorithm.nim
@@ -0,0 +1,917 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements some common generic algorithms on `openArray`s.
+##
+## Basic usage
+## ===========
+##
+
+runnableExamples:
+  type People = tuple
+    year: int
+    name: string
+
+  var a: seq[People]
+
+  a.add((2000, "John"))
+  a.add((2005, "Marie"))
+  a.add((2010, "Jane"))
+
+  # Sorting with default system.cmp
+  a.sort()
+  assert a == @[(year: 2000, name: "John"), (year: 2005, name: "Marie"),
+                (year: 2010, name: "Jane")]
+
+  proc myCmp(x, y: People): int =
+    cmp(x.name, y.name)
+
+  # Sorting with custom proc
+  a.sort(myCmp)
+  assert a == @[(year: 2010, name: "Jane"), (year: 2000, name: "John"),
+                (year: 2005, name: "Marie")]
+
+## See also
+## ========
+## * `sequtils module<sequtils.html>`_ for working with the built-in seq type
+## * `tables module<tables.html>`_ for sorting tables
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  SortOrder* = enum
+    Descending, Ascending
+
+proc `*`*(x: int, order: SortOrder): int {.inline.} =
+  ## Flips the sign of `x` if `order == Descending`.
+  ## If `order == Ascending` then `x` is returned.
+  ##
+  ## `x` is supposed to be the result of a comparator, i.e.
+  ## | `< 0` for *less than*,
+  ## | `== 0` for *equal*,
+  ## | `> 0` for *greater than*.
+  runnableExamples:
+    assert -123 * Descending == 123
+    assert 123 * Descending == -123
+    assert -123 * Ascending == -123
+    assert 123 * Ascending == 123
+  var y = order.ord - 1
+  result = (x xor y) - y
+
+template fillImpl[T](a: var openArray[T], first, last: int, value: T) =
+  var x = first
+  while x <= last:
+    a[x] = value
+    inc(x)
+
+proc fill*[T](a: var openArray[T], first, last: Natural, value: T) =
+  ## Assigns `value` to all elements of the slice `a[first..last]`.
+  ##
+  ## If an invalid range is passed, it raises `IndexDefect`.
+  runnableExamples:
+    var a: array[6, int]
+    a.fill(1, 3, 9)
+    assert a == [0, 9, 9, 9, 0, 0]
+    a.fill(3, 5, 7)
+    assert a == [0, 9, 9, 7, 7, 7]
+    doAssertRaises(IndexDefect, a.fill(1, 7, 9))
+  fillImpl(a, first, last, value)
+
+proc fill*[T](a: var openArray[T], value: T) =
+  ## Assigns `value` to all elements of the container `a`.
+  runnableExamples:
+    var a: array[6, int]
+    a.fill(9)
+    assert a == [9, 9, 9, 9, 9, 9]
+    a.fill(4)
+    assert a == [4, 4, 4, 4, 4, 4]
+  fillImpl(a, 0, a.high, value)
+
+
+proc reverse*[T](a: var openArray[T], first, last: Natural) =
+  ## Reverses the slice `a[first..last]`.
+  ##
+  ## If an invalid range is passed, it raises `IndexDefect`.
+  ##
+  ## **See also:**
+  ## * `reversed proc<#reversed,openArray[T],Natural,int>`_ reverse a slice and returns a `seq[T]`
+  ## * `reversed proc<#reversed,openArray[T]>`_ reverse and returns a `seq[T]`
+  runnableExamples:
+    var a = [1, 2, 3, 4, 5, 6]
+    a.reverse(1, 3)
+    assert a == [1, 4, 3, 2, 5, 6]
+    a.reverse(1, 3)
+    assert a == [1, 2, 3, 4, 5, 6]
+    doAssertRaises(IndexDefect, a.reverse(1, 7))
+  var x = first
+  var y = last
+  while x < y:
+    swap(a[x], a[y])
+    dec(y)
+    inc(x)
+
+proc reverse*[T](a: var openArray[T]) =
+  ## Reverses the contents of the container `a`.
+  ##
+  ## **See also:**
+  ## * `reversed proc<#reversed,openArray[T],Natural,int>`_ reverse a slice and returns a `seq[T]`
+  ## * `reversed proc<#reversed,openArray[T]>`_ reverse and returns a `seq[T]`
+  runnableExamples:
+    var a = [1, 2, 3, 4, 5, 6]
+    a.reverse()
+    assert a == [6, 5, 4, 3, 2, 1]
+    a.reverse()
+    assert a == [1, 2, 3, 4, 5, 6]
+  # the max is needed, since a.high is -1 if a is empty
+  reverse(a, 0, max(0, a.high))
+
+proc reversed*[T](a: openArray[T]): seq[T] {.inline.} =
+  ## Returns the elements of `a` in reverse order.
+  ##
+  ## **See also:**
+  ## * `reverse proc<#reverse,openArray[T]>`_
+  runnableExamples:
+    assert [10, 11, 12].reversed == @[12, 11, 10]
+    assert seq[string].default.reversed == @[]
+  let n = a.len
+  result.setLen(n)
+  for i in 0..<n: result[i] = a[n - (i + 1)]
+
+proc reversed*[T](a: openArray[T], first: Natural, last: int): seq[T]
+  {.inline, deprecated: "use: `reversed(toOpenArray(a, first, last))`".} =
+  reversed(toOpenArray(a, first, last))
+
+when defined(nimHasEffectsOf):
+  {.experimental: "strictEffects".}
+else:
+  {.pragma: effectsOf.}
+
+proc binarySearch*[T, K](a: openArray[T], key: K,
+                         cmp: proc (x: T, y: K): int {.closure.}): int {.effectsOf: cmp.} =
+  ## Binary search for `key` in `a`. Return the index of `key` or -1 if not found.
+  ## Assumes that `a` is sorted according to `cmp`.
+  ##
+  ## `cmp` is the comparator function to use, the expected return values are
+  ## the same as those of system.cmp.
+  runnableExamples:
+    assert binarySearch(["a", "b", "c", "d"], "d", system.cmp[string]) == 3
+    assert binarySearch(["a", "b", "c", "d"], "c", system.cmp[string]) == 2
+  let len = a.len
+
+  if len == 0:
+    return -1
+
+  if len == 1:
+    if cmp(a[0], key) == 0:
+      return 0
+    else:
+      return -1
+
+  result = 0
+  if (len and (len - 1)) == 0:
+    # when `len` is a power of 2, a faster shr can be used.
+    var step = len shr 1
+    var cmpRes: int
+    while step > 0:
+      let i = result or step
+      cmpRes = cmp(a[i], key)
+      if cmpRes == 0:
+        return i
+
+      if cmpRes < 0:
+        result = i
+      step = step shr 1
+    if cmp(a[result], key) != 0: result = -1
+  else:
+    var b = len
+    var cmpRes: int
+    while result < b:
+      var mid = (result + b) shr 1
+      cmpRes = cmp(a[mid], key)
+      if cmpRes == 0:
+        return mid
+
+      if cmpRes < 0:
+        result = mid + 1
+      else:
+        b = mid
+    if result >= len or cmp(a[result], key) != 0: result = -1
+
+proc binarySearch*[T](a: openArray[T], key: T): int =
+  ## Binary search for `key` in `a`. Return the index of `key` or -1 if not found.
+  ## Assumes that `a` is sorted.
+  runnableExamples:
+    assert binarySearch([0, 1, 2, 3, 4], 4) == 4
+    assert binarySearch([0, 1, 2, 3, 4], 2) == 2
+  binarySearch(a, key, cmp[T])
+
+const
+  onlySafeCode = true
+
+proc lowerBound*[T, K](a: openArray[T], key: K,
+                       cmp: proc(x: T, k: K): int {.closure.}): int {.effectsOf: cmp.} =
+  ## Returns the index of the first element in `a` that is not less than
+  ## (i.e. greater or equal to) `key`, or last if no such element is found.
+  ## In other words if you have a sorted sequence and you call
+  ## `insert(thing, elm, lowerBound(thing, elm))`
+  ## the sequence will still be sorted.
+  ## Assumes that `a` is sorted according to `cmp`.
+  ##
+  ## If an invalid range is passed, it raises `IndexDefect`.
+  ##
+  ## This version uses `cmp` to compare the elements.
+  ## The expected return values are the same as those of `system.cmp`.
+  ##
+  ## **See also:**
+  ## * `upperBound proc<#upperBound,openArray[T],K,proc(T,K)>`_ sorted by `cmp` in the specified order
+  ## * `upperBound proc<#upperBound,openArray[T],T>`_
+  runnableExamples:
+    var arr = @[1, 2, 3, 5, 6, 7, 8, 9]
+    assert arr.lowerBound(3, system.cmp[int]) == 2
+    assert arr.lowerBound(4, system.cmp[int]) == 3
+    assert arr.lowerBound(5, system.cmp[int]) == 3
+    arr.insert(4, arr.lowerBound(4, system.cmp[int]))
+    assert arr == [1, 2, 3, 4, 5, 6, 7, 8, 9]
+  result = a.low
+  var count = a.high - a.low + 1
+  var step, pos: int
+  while count != 0:
+    step = count shr 1
+    pos = result + step
+    if cmp(a[pos], key) < 0:
+      result = pos + 1
+      count -= step + 1
+    else:
+      count = step
+
+proc lowerBound*[T](a: openArray[T], key: T): int = lowerBound(a, key, cmp[T])
+  ## Returns the index of the first element in `a` that is not less than
+  ## (i.e. greater or equal to) `key`, or last if no such element is found.
+  ## In other words if you have a sorted sequence and you call
+  ## `insert(thing, elm, lowerBound(thing, elm))`
+  ## the sequence will still be sorted.
+  ## Assumes that `a` is sorted.
+  ##
+  ## This version uses the default comparison function `cmp`.
+  ##
+  ## **See also:**
+  ## * `upperBound proc<#upperBound,openArray[T],K,proc(T,K)>`_ sorted by `cmp` in the specified order
+  ## * `upperBound proc<#upperBound,openArray[T],T>`_
+
+proc upperBound*[T, K](a: openArray[T], key: K,
+                       cmp: proc(x: T, k: K): int {.closure.}): int {.effectsOf: cmp.} =
+  ## Returns the index of the first element in `a` that is greater than
+  ## `key`, or last if no such element is found.
+  ## In other words if you have a sorted sequence and you call
+  ## `insert(thing, elm, upperBound(thing, elm))`
+  ## the sequence will still be sorted.
+  ## Assumes that `a` is sorted according to `cmp`.
+  ##
+  ## If an invalid range is passed, it raises `IndexDefect`.
+  ##
+  ## This version uses `cmp` to compare the elements. The expected
+  ## return values are the same as those of `system.cmp`.
+  ##
+  ## **See also:**
+  ## * `lowerBound proc<#lowerBound,openArray[T],K,proc(T,K)>`_ sorted by `cmp` in the specified order
+  ## * `lowerBound proc<#lowerBound,openArray[T],T>`_
+  runnableExamples:
+    var arr = @[1, 2, 3, 5, 6, 7, 8, 9]
+    assert arr.upperBound(2, system.cmp[int]) == 2
+    assert arr.upperBound(3, system.cmp[int]) == 3
+    assert arr.upperBound(4, system.cmp[int]) == 3
+    arr.insert(4, arr.upperBound(3, system.cmp[int]))
+    assert arr == [1, 2, 3, 4, 5, 6, 7, 8, 9]
+  result = a.low
+  var count = a.high - a.low + 1
+  var step, pos: int
+  while count != 0:
+    step = count shr 1
+    pos = result + step
+    if cmp(a[pos], key) <= 0:
+      result = pos + 1
+      count -= step + 1
+    else:
+      count = step
+
+proc upperBound*[T](a: openArray[T], key: T): int = upperBound(a, key, cmp[T])
+  ## Returns the index of the first element in `a` that is greater than
+  ## `key`, or last if no such element is found.
+  ## In other words if you have a sorted sequence and you call
+  ## `insert(thing, elm, upperBound(thing, elm))`
+  ## the sequence will still be sorted.
+  ## Assumes that `a` is sorted.
+  ##
+  ## This version uses the default comparison function `cmp`.
+  ##
+  ## **See also:**
+  ## * `lowerBound proc<#lowerBound,openArray[T],K,proc(T,K)>`_ sorted by `cmp` in the specified order
+  ## * `lowerBound proc<#lowerBound,openArray[T],T>`_
+
+template `<-`(a, b) =
+  when defined(gcDestructors):
+    a = move b
+  elif onlySafeCode:
+    shallowCopy(a, b)
+  else:
+    copyMem(addr(a), addr(b), sizeof(T))
+
+proc mergeAlt[T](a, b: var openArray[T], lo, m, hi: int,
+              cmp: proc (x, y: T): int {.closure.}, order: SortOrder) {.effectsOf: cmp.} =
+  # Optimization: If max(left) <= min(right) there is nothing to do!
+  # 1 2 3 4 ## 5 6 7 8
+  # -> O(n) for sorted arrays.
+  # On random data this saves up to 40% of mergeAlt calls.
+  if cmp(a[m], a[m+1]) * order <= 0: return
+  var j = lo
+  # copy a[j..m] into b:
+  assert j <= m
+  when onlySafeCode:
+    var bb = 0
+    while j <= m:
+      b[bb] <- a[j]
+      inc(bb)
+      inc(j)
+  else:
+    copyMem(addr(b[0]), addr(a[j]), sizeof(T)*(m-j+1))
+    j = m+1
+  var i = 0
+  var k = lo
+  # copy proper element back:
+  while k < j and j <= hi:
+    if cmp(b[i], a[j]) * order <= 0:
+      a[k] <- b[i]
+      inc(i)
+    else:
+      a[k] <- a[j]
+      inc(j)
+    inc(k)
+  # copy rest of b:
+  when onlySafeCode:
+    while k < j:
+      a[k] <- b[i]
+      inc(k)
+      inc(i)
+  else:
+    if k < j: copyMem(addr(a[k]), addr(b[i]), sizeof(T)*(j-k))
+
+func sort*[T](a: var openArray[T],
+              cmp: proc (x, y: T): int {.closure.},
+              order = SortOrder.Ascending) {.effectsOf: cmp.} =
+  ## Default Nim sort (an implementation of merge sort). The sorting
+  ## is guaranteed to be stable (that is, equal elements stay in the same order)
+  ## and the worst case is guaranteed to be O(n log n).
+  ## Sorts by `cmp` in the specified `order`.
+  ##
+  ## The current implementation uses an iterative
+  ## mergesort to achieve this. It uses a temporary sequence of
+  ## length `a.len div 2`. If you do not wish to provide your own
+  ## `cmp`, you may use `system.cmp` or instead call the overloaded
+  ## version of `sort`, which uses `system.cmp`.
+  ##
+  ##   ```nim
+  ##   sort(myIntArray, system.cmp[int])
+  ##   # do not use cmp[string] here as we want to use the specialized
+  ##   # overload:
+  ##   sort(myStrArray, system.cmp)
+  ##   ```
+  ##
+  ## You can inline adhoc comparison procs with the `do notation
+  ## <manual.html#procedures-do-notation>`_. Example:
+  ##
+  ##   ```nim
+  ##   people.sort do (x, y: Person) -> int:
+  ##     result = cmp(x.surname, y.surname)
+  ##     if result == 0:
+  ##       result = cmp(x.name, y.name)
+  ##   ```
+  ##
+  ## **See also:**
+  ## * `sort proc<#sort,openArray[T]>`_
+  ## * `sorted proc<#sorted,openArray[T],proc(T,T)>`_ sorted by `cmp` in the specified order
+  ## * `sorted proc<#sorted,openArray[T]>`_
+  ## * `sortedByIt template<#sortedByIt.t,untyped,untyped>`_
+  runnableExamples:
+    var d = ["boo", "fo", "barr", "qux"]
+    proc myCmp(x, y: string): int =
+      if x.len() > y.len() or x.len() == y.len(): 1
+      else: -1
+    sort(d, myCmp)
+    assert d == ["fo", "qux", "boo", "barr"]
+  var n = a.len
+  var b = newSeq[T](n div 2)
+  var s = 1
+  while s < n:
+    var m = n-1-s
+    while m >= 0:
+      mergeAlt(a, b, max(m-s+1, 0), m, m+s, cmp, order)
+      dec(m, s*2)
+    s = s*2
+
+proc sort*[T](a: var openArray[T], order = SortOrder.Ascending) = sort[T](a,
+    system.cmp[T], order)
+  ## Shortcut version of `sort` that uses `system.cmp[T]` as the comparison function.
+  ##
+  ## **See also:**
+  ## * `sort func<#sort,openArray[T],proc(T,T)>`_
+  ## * `sorted proc<#sorted,openArray[T],proc(T,T)>`_ sorted by `cmp` in the specified order
+  ## * `sorted proc<#sorted,openArray[T]>`_
+  ## * `sortedByIt template<#sortedByIt.t,untyped,untyped>`_
+
+proc sorted*[T](a: openArray[T], cmp: proc(x, y: T): int {.closure.},
+                order = SortOrder.Ascending): seq[T] {.effectsOf: cmp.} =
+  ## Returns `a` sorted by `cmp` in the specified `order`.
+  ##
+  ## **See also:**
+  ## * `sort func<#sort,openArray[T],proc(T,T)>`_
+  ## * `sort proc<#sort,openArray[T]>`_
+  ## * `sortedByIt template<#sortedByIt.t,untyped,untyped>`_
+  runnableExamples:
+    let
+      a = [2, 3, 1, 5, 4]
+      b = sorted(a, system.cmp[int])
+      c = sorted(a, system.cmp[int], Descending)
+      d = sorted(["adam", "dande", "brian", "cat"], system.cmp[string])
+    assert b == @[1, 2, 3, 4, 5]
+    assert c == @[5, 4, 3, 2, 1]
+    assert d == @["adam", "brian", "cat", "dande"]
+  result = newSeq[T](a.len)
+  for i in 0 .. a.high:
+    result[i] = a[i]
+  sort(result, cmp, order)
+
+proc sorted*[T](a: openArray[T], order = SortOrder.Ascending): seq[T] =
+  ## Shortcut version of `sorted` that uses `system.cmp[T]` as the comparison function.
+  ##
+  ## **See also:**
+  ## * `sort func<#sort,openArray[T],proc(T,T)>`_
+  ## * `sort proc<#sort,openArray[T]>`_
+  ## * `sortedByIt template<#sortedByIt.t,untyped,untyped>`_
+  runnableExamples:
+    let
+      a = [2, 3, 1, 5, 4]
+      b = sorted(a)
+      c = sorted(a, Descending)
+      d = sorted(["adam", "dande", "brian", "cat"])
+    assert b == @[1, 2, 3, 4, 5]
+    assert c == @[5, 4, 3, 2, 1]
+    assert d == @["adam", "brian", "cat", "dande"]
+  sorted[T](a, system.cmp[T], order)
+
+template sortedByIt*(seq1, op: untyped): untyped =
+  ## Convenience template around the `sorted` proc to reduce typing.
+  ##
+  ## The template injects the `it` variable which you can use directly in an
+  ## expression.
+  ##
+  ## Because the underlying `cmp()` is defined for tuples you can also do
+  ## a nested sort.
+  ##
+  ## **See also:**
+  ## * `sort func<#sort,openArray[T],proc(T,T)>`_
+  ## * `sort proc<#sort,openArray[T]>`_
+  ## * `sorted proc<#sorted,openArray[T],proc(T,T)>`_ sorted by `cmp` in the specified order
+  ## * `sorted proc<#sorted,openArray[T]>`_
+  runnableExamples:
+    type Person = tuple[name: string, age: int]
+    var
+      p1: Person = (name: "p1", age: 60)
+      p2: Person = (name: "p2", age: 20)
+      p3: Person = (name: "p3", age: 30)
+      p4: Person = (name: "p4", age: 30)
+      people = @[p1, p2, p4, p3]
+
+    assert people.sortedByIt(it.name) == @[(name: "p1", age: 60), (name: "p2",
+        age: 20), (name: "p3", age: 30), (name: "p4", age: 30)]
+    # Nested sort
+    assert people.sortedByIt((it.age, it.name)) == @[(name: "p2", age: 20),
+       (name: "p3", age: 30), (name: "p4", age: 30), (name: "p1", age: 60)]
+  var result = sorted(seq1, proc(x, y: typeof(items(seq1), typeOfIter)): int =
+    var it {.inject.} = x
+    let a = op
+    it = y
+    let b = op
+    result = cmp(a, b))
+  result
+
+func isSorted*[T](a: openArray[T],
+                 cmp: proc(x, y: T): int {.closure.},
+                 order = SortOrder.Ascending): bool {.effectsOf: cmp.} =
+  ## Checks to see whether `a` is already sorted in `order`
+  ## using `cmp` for the comparison. The parameters are identical
+  ## to `sort`. Requires O(n) time.
+  ##
+  ## **See also:**
+  ## * `isSorted proc<#isSorted,openArray[T]>`_
+  runnableExamples:
+    let
+      a = [2, 3, 1, 5, 4]
+      b = [1, 2, 3, 4, 5]
+      c = [5, 4, 3, 2, 1]
+      d = ["adam", "brian", "cat", "dande"]
+      e = ["adam", "dande", "brian", "cat"]
+    assert isSorted(a) == false
+    assert isSorted(b) == true
+    assert isSorted(c) == false
+    assert isSorted(c, Descending) == true
+    assert isSorted(d) == true
+    assert isSorted(e) == false
+  result = true
+  for i in 0..<len(a)-1:
+    if cmp(a[i], a[i+1]) * order > 0:
+      return false
+
+proc isSorted*[T](a: openArray[T], order = SortOrder.Ascending): bool =
+  ## Shortcut version of `isSorted` that uses `system.cmp[T]` as the comparison function.
+  ##
+  ## **See also:**
+  ## * `isSorted func<#isSorted,openArray[T],proc(T,T)>`_
+  runnableExamples:
+    let
+      a = [2, 3, 1, 5, 4]
+      b = [1, 2, 3, 4, 5]
+      c = [5, 4, 3, 2, 1]
+      d = ["adam", "brian", "cat", "dande"]
+      e = ["adam", "dande", "brian", "cat"]
+    assert isSorted(a) == false
+    assert isSorted(b) == true
+    assert isSorted(c) == false
+    assert isSorted(c, Descending) == true
+    assert isSorted(d) == true
+    assert isSorted(e) == false
+  isSorted(a, system.cmp[T], order)
+
+proc merge*[T](
+  result: var seq[T],
+  x, y: openArray[T], cmp: proc(x, y: T): int {.closure.}
+) {.since: (1, 5, 1), effectsOf: cmp.} =
+  ## Merges two sorted `openArray`. `x` and `y` are assumed to be sorted.
+  ## If you do not wish to provide your own `cmp`,
+  ## you may use `system.cmp` or instead call the overloaded
+  ## version of `merge`, which uses `system.cmp`.
+  ##
+  ## .. note:: The original data of `result` is not cleared,
+  ##    new data is appended to `result`.
+  ##
+  ## **See also:**
+  ## * `merge proc<#merge,seq[T],openArray[T],openArray[T]>`_
+  runnableExamples:
+    let x = @[1, 3, 6]
+    let y = @[2, 3, 4]
+
+    block:
+      var merged = @[7] # new data is appended to merged sequence
+      merged.merge(x, y, system.cmp[int])
+      assert merged == @[7, 1, 2, 3, 3, 4, 6]
+
+    block:
+      var merged = @[7] # if you only want new data, clear merged sequence first
+      merged.setLen(0)
+      merged.merge(x, y, system.cmp[int])
+      assert merged.isSorted
+      assert merged == @[1, 2, 3, 3, 4, 6]
+
+    import std/sugar
+
+    var res: seq[(int, int)]
+    res.merge([(1, 1)], [(1, 2)], (a, b) => a[0] - b[0])
+    assert res == @[(1, 1), (1, 2)]
+
+    assert seq[int].default.dup(merge([1, 3], [2, 4])) == @[1, 2, 3, 4]
+
+  let
+    sizeX = x.len
+    sizeY = y.len
+    oldLen = result.len
+
+  result.setLen(oldLen + sizeX + sizeY)
+
+  var
+    ix = 0
+    iy = 0
+    i = oldLen
+
+  while true:
+    if ix == sizeX:
+      while iy < sizeY:
+        result[i] = y[iy]
+        inc i
+        inc iy
+      return
+
+    if iy == sizeY:
+      while ix < sizeX:
+        result[i] = x[ix]
+        inc i
+        inc ix
+      return
+
+    let itemX = x[ix]
+    let itemY = y[iy]
+
+    if cmp(itemX, itemY) > 0: # to have a stable sort
+      result[i] = itemY
+      inc iy
+    else:
+      result[i] = itemX
+      inc ix
+
+    inc i
+
+proc merge*[T](result: var seq[T], x, y: openArray[T]) {.inline, since: (1, 5, 1).} =
+  ## Shortcut version of `merge` that uses `system.cmp[T]` as the comparison function.
+  ##
+  ## **See also:**
+  ## * `merge proc<#merge,seq[T],openArray[T],openArray[T],proc(T,T)>`_
+  runnableExamples:
+    let x = [5, 10, 15, 20, 25]
+    let y = [50, 40, 30, 20, 10].sorted
+
+    var merged: seq[int]
+    merged.merge(x, y)
+    assert merged.isSorted
+    assert merged == @[5, 10, 10, 15, 20, 20, 25, 30, 40, 50]
+  merge(result, x, y, system.cmp)
+
+proc product*[T](x: openArray[seq[T]]): seq[seq[T]] =
+  ## Produces the Cartesian product of the array.
+  ## Every element of the result is a combination of one element from each seq in `x`,
+  ## with the ith element coming from `x[i]`.
+  ##
+  ## .. warning:: complexity may explode.
+  runnableExamples:
+    assert product(@[@[1], @[2]]) == @[@[1, 2]]
+    assert product(@[@["A", "K"], @["Q"]]) == @[@["K", "Q"], @["A", "Q"]]
+  let xLen = x.len
+  result = newSeq[seq[T]]()
+  if xLen == 0:
+    return
+  if xLen == 1:
+    result = @x
+    return
+  var
+    indices = newSeq[int](xLen)
+    initial = newSeq[int](xLen)
+    index = 0
+  var next = newSeq[T](xLen)
+  for i in 0 ..< xLen:
+    if len(x[i]) == 0: return
+    initial[i] = len(x[i]) - 1
+  indices = initial
+  while true:
+    while indices[index] == -1:
+      indices[index] = initial[index]
+      index += 1
+      if index == xLen: return
+      indices[index] -= 1
+    for ni, i in indices:
+      next[ni] = x[ni][i]
+    result.add(next)
+    index = 0
+    indices[index] -= 1
+
+proc nextPermutation*[T](x: var openArray[T]): bool {.discardable.} =
+  ## Calculates the next lexicographic permutation, directly modifying `x`.
+  ## The result is whether a permutation happened, otherwise we have reached
+  ## the last-ordered permutation.
+  ##
+  ## If you start with an unsorted array/seq, the repeated permutations
+  ## will **not** give you all permutations but stop with the last.
+  ##
+  ## **See also:**
+  ## * `prevPermutation proc<#prevPermutation,openArray[T]>`_
+  runnableExamples:
+    var v = @[0, 1, 2, 3]
+    assert v.nextPermutation() == true
+    assert v == @[0, 1, 3, 2]
+    assert v.nextPermutation() == true
+    assert v == @[0, 2, 1, 3]
+    assert v.prevPermutation() == true
+    assert v == @[0, 1, 3, 2]
+    v = @[3, 2, 1, 0]
+    assert v.nextPermutation() == false
+    assert v == @[3, 2, 1, 0]
+  if x.len < 2:
+    return false
+
+  var i = x.high
+  while i > 0 and x[i-1] >= x[i]:
+    dec i
+
+  if i == 0:
+    return false
+
+  var j = x.high
+  while j >= i and x[j] <= x[i-1]:
+    dec j
+
+  swap x[j], x[i-1]
+  x.reverse(i, x.high)
+
+  result = true
+
+proc prevPermutation*[T](x: var openArray[T]): bool {.discardable.} =
+  ## Calculates the previous lexicographic permutation, directly modifying
+  ## `x`. The result is whether a permutation happened, otherwise we have
+  ## reached the first-ordered permutation.
+  ##
+  ## **See also:**
+  ## * `nextPermutation proc<#nextPermutation,openArray[T]>`_
+  runnableExamples:
+    var v = @[0, 1, 2, 3]
+    assert v.prevPermutation() == false
+    assert v == @[0, 1, 2, 3]
+    assert v.nextPermutation() == true
+    assert v == @[0, 1, 3, 2]
+    assert v.prevPermutation() == true
+    assert v == @[0, 1, 2, 3]
+  if x.len < 2:
+    return false
+
+  var i = x.high
+  while i > 0 and x[i-1] <= x[i]:
+    dec i
+
+  if i == 0:
+    return false
+
+  x.reverse(i, x.high)
+
+  var j = x.high
+  while j >= i and x[j-1] < x[i-1]:
+    dec j
+
+  swap x[i-1], x[j]
+
+  result = true
+
+proc rotateInternal[T](arg: var openArray[T]; first, middle, last: int): int =
+  ## A port of std::rotate from C++.
+  ## Ported from [this reference](http://www.cplusplus.com/reference/algorithm/rotate/).
+  result = first + last - middle
+
+  if first == middle or middle == last:
+    return
+
+  assert first < middle
+  assert middle < last
+
+  # m prefix for mutable
+  var
+    mFirst = first
+    mMiddle = middle
+    next = middle
+
+  swap(arg[mFirst], arg[next])
+  mFirst += 1
+  next += 1
+  if mFirst == mMiddle:
+    mMiddle = next
+
+  while next != last:
+    swap(arg[mFirst], arg[next])
+    mFirst += 1
+    next += 1
+    if mFirst == mMiddle:
+      mMiddle = next
+
+  next = mMiddle
+  while next != last:
+    swap(arg[mFirst], arg[next])
+    mFirst += 1
+    next += 1
+    if mFirst == mMiddle:
+      mMiddle = next
+    elif next == last:
+      next = mMiddle
+
+proc rotatedInternal[T](arg: openArray[T]; first, middle, last: int): seq[T] =
+  let argLen = arg.len
+  result = newSeq[T](argLen)
+  for i in 0 ..< first:
+    result[i] = arg[i]
+  let n = last - middle
+  let m = middle - first
+  for i in 0 ..< n:
+    result[first+i] = arg[middle+i]
+  for i in 0 ..< m:
+    result[first+n+i] = arg[first+i]
+  for i in last ..< argLen:
+    result[i] = arg[i]
+
+proc rotateLeft*[T](arg: var openArray[T]; slice: HSlice[int, int];
+                    dist: int): int {.discardable.} =
+  ## Performs a left rotation on a range of elements. If you want to rotate
+  ## right, use a negative `dist`. Specifically, `rotateLeft` rotates
+  ## the elements at `slice` by `dist` positions.
+  ##
+  ## | The element at index `slice.a + dist` will be at index `slice.a`.
+  ## | The element at index `slice.b` will be at `slice.a + dist - 1`.
+  ## | The element at index `slice.a` will be at `slice.b + 1 - dist`.
+  ## | The element at index `slice.a + dist - 1` will be at `slice.b`.
+  ##
+  ## Elements outside of `slice` will be left unchanged.
+  ## The time complexity is linear to `slice.b - slice.a + 1`.
+  ## If an invalid range (`HSlice`) is passed, it raises `IndexDefect`.
+  ##
+  ## `slice`
+  ## : The indices of the element range that should be rotated.
+  ##
+  ## `dist`
+  ## : The distance in amount of elements that the data should be rotated.
+  ##   Can be negative, can be any number.
+  ##
+  ## **See also:**
+  ## * `rotateLeft proc<#rotateLeft,openArray[T],int>`_ for a version which rotates the whole container
+  ## * `rotatedLeft proc<#rotatedLeft,openArray[T],HSlice[int,int],int>`_ for a version which returns a `seq[T]`
+  runnableExamples:
+    var a = [0, 1, 2, 3, 4, 5]
+    a.rotateLeft(1 .. 4, 3)
+    assert a == [0, 4, 1, 2, 3, 5]
+    a.rotateLeft(1 .. 4, 3)
+    assert a == [0, 3, 4, 1, 2, 5]
+    a.rotateLeft(1 .. 4, -3)
+    assert a == [0, 4, 1, 2, 3, 5]
+    doAssertRaises(IndexDefect, a.rotateLeft(1 .. 7, 2))
+  let sliceLen = slice.b + 1 - slice.a
+  let distLeft = ((dist mod sliceLen) + sliceLen) mod sliceLen
+  arg.rotateInternal(slice.a, slice.a + distLeft, slice.b + 1)
+
+proc rotateLeft*[T](arg: var openArray[T]; dist: int): int {.discardable.} =
+  ## Same as `rotateLeft`, but with default arguments for slice,
+  ## so that this procedure operates on the entire
+  ## `arg`, and not just on a part of it.
+  ##
+  ## **See also:**
+  ## * `rotateLeft proc<#rotateLeft,openArray[T],HSlice[int,int],int>`_ for a version which rotates a range
+  ## * `rotatedLeft proc<#rotatedLeft,openArray[T],int>`_ for a version which returns a `seq[T]`
+  runnableExamples:
+    var a = [1, 2, 3, 4, 5]
+    a.rotateLeft(2)
+    assert a == [3, 4, 5, 1, 2]
+    a.rotateLeft(4)
+    assert a == [2, 3, 4, 5, 1]
+    a.rotateLeft(-6)
+    assert a == [1, 2, 3, 4, 5]
+  let argLen = arg.len
+  let distLeft = ((dist mod argLen) + argLen) mod argLen
+  arg.rotateInternal(0, distLeft, argLen)
+
+proc rotatedLeft*[T](arg: openArray[T]; slice: HSlice[int, int],
+                     dist: int): seq[T] =
+  ## Same as `rotateLeft`, just with the difference that it does
+  ## not modify the argument. It creates a new `seq` instead.
+  ##
+  ## Elements outside of `slice` will be left unchanged.
+  ## If an invalid range (`HSlice`) is passed, it raises `IndexDefect`.
+  ##
+  ## `slice`
+  ## : The indices of the element range that should be rotated.
+  ##
+  ## `dist`
+  ## : The distance in amount of elements that the data should be rotated.
+  ##   Can be negative, can be any number.
+  ##
+  ## **See also:**
+  ## * `rotateLeft proc<#rotateLeft,openArray[T],HSlice[int,int],int>`_ for the in-place version of this proc
+  ## * `rotatedLeft proc<#rotatedLeft,openArray[T],int>`_ for a version which rotates the whole container
+  runnableExamples:
+    var a = @[1, 2, 3, 4, 5]
+    a = rotatedLeft(a, 1 .. 4, 3)
+    assert a == @[1, 5, 2, 3, 4]
+    a = rotatedLeft(a, 1 .. 3, 2)
+    assert a == @[1, 3, 5, 2, 4]
+    a = rotatedLeft(a, 1 .. 3, -2)
+    assert a == @[1, 5, 2, 3, 4]
+  let sliceLen = slice.b + 1 - slice.a
+  let distLeft = ((dist mod sliceLen) + sliceLen) mod sliceLen
+  arg.rotatedInternal(slice.a, slice.a + distLeft, slice.b + 1)
+
+proc rotatedLeft*[T](arg: openArray[T]; dist: int): seq[T] =
+  ## Same as `rotateLeft`, just with the difference that it does
+  ## not modify the argument. It creates a new `seq` instead.
+  ##
+  ## **See also:**
+  ## * `rotateLeft proc<#rotateLeft,openArray[T],int>`_ for the in-place version of this proc
+  ## * `rotatedLeft proc<#rotatedLeft,openArray[T],HSlice[int,int],int>`_ for a version which rotates a range
+  runnableExamples:
+    var a = @[1, 2, 3, 4, 5]
+    a = rotatedLeft(a, 2)
+    assert a == @[3, 4, 5, 1, 2]
+    a = rotatedLeft(a, 4)
+    assert a == @[2, 3, 4, 5, 1]
+    a = rotatedLeft(a, -6)
+    assert a == @[1, 2, 3, 4, 5]
+  let argLen = arg.len
+  let distLeft = ((dist mod argLen) + argLen) mod argLen
+  arg.rotatedInternal(0, distLeft, argLen)
diff --git a/lib/pure/async.nim b/lib/pure/async.nim
new file mode 100644
index 000000000..e4d8d41c3
--- /dev/null
+++ b/lib/pure/async.nim
@@ -0,0 +1,9 @@
+## Exports [asyncmacro](asyncmacro.html) and [asyncfutures](asyncfutures.html) for native backends,
+## and [asyncjs](asyncjs.html) on the JS backend. 
+
+when defined(js):
+  import std/asyncjs
+  export asyncjs
+else:
+  import std/[asyncmacro, asyncfutures]
+  export asyncmacro, asyncfutures
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
new file mode 100644
index 000000000..126db7a7f
--- /dev/null
+++ b/lib/pure/asyncdispatch.nim
@@ -0,0 +1,2065 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements asynchronous IO. This includes a dispatcher,
+## a `Future` type implementation, and an `async` macro which allows
+## asynchronous code to be written in a synchronous style with the `await`
+## keyword.
+##
+## The dispatcher acts as a kind of event loop. You must call `poll` on it
+## (or a function which does so for you such as `waitFor` or `runForever`)
+## in order to poll for any outstanding events. The underlying implementation
+## is based on epoll on Linux, IO Completion Ports on Windows and select on
+## other operating systems.
+##
+## The `poll` function will not, on its own, return any events. Instead
+## an appropriate `Future` object will be completed. A `Future` is a
+## type which holds a value which is not yet available, but which *may* be
+## available in the future. You can check whether a future is finished
+## by using the `finished` function. When a future is finished it means that
+## either the value that it holds is now available or it holds an error instead.
+## The latter situation occurs when the operation to complete a future fails
+## with an exception. You can distinguish between the two situations with the
+## `failed` function.
+##
+## Future objects can also store a callback procedure which will be called
+## automatically once the future completes.
+##
+## Futures therefore can be thought of as an implementation of the proactor
+## pattern. In this
+## pattern you make a request for an action, and once that action is fulfilled
+## a future is completed with the result of that action. Requests can be
+## made by calling the appropriate functions. For example: calling the `recv`
+## function will create a request for some data to be read from a socket. The
+## future which the `recv` function returns will then complete once the
+## requested amount of data is read **or** an exception occurs.
+##
+## Code to read some data from a socket may look something like this:
+##   ```Nim
+##   var future = socket.recv(100)
+##   future.addCallback(
+##     proc () =
+##       echo(future.read)
+##   )
+##   ```
+##
+## All asynchronous functions returning a `Future` will not block. They
+## will not however return immediately. An asynchronous function will have
+## code which will be executed before an asynchronous request is made, in most
+## cases this code sets up the request.
+##
+## In the above example, the `recv` function will return a brand new
+## `Future` instance once the request for data to be read from the socket
+## is made. This `Future` instance will complete once the requested amount
+## of data is read, in this case it is 100 bytes. The second line sets a
+## callback on this future which will be called once the future completes.
+## All the callback does is write the data stored in the future to `stdout`.
+## The `read` function is used for this and it checks whether the future
+## completes with an error for you (if it did, it will simply raise the
+## error), if there is no error, however, it returns the value of the future.
+##
+## Asynchronous procedures
+## =======================
+##
+## Asynchronous procedures remove the pain of working with callbacks. They do
+## this by allowing you to write asynchronous code the same way as you would
+## write synchronous code.
+##
+## An asynchronous procedure is marked using the `{.async.}` pragma.
+## When marking a procedure with the `{.async.}` pragma it must have a
+## `Future[T]` return type or no return type at all. If you do not specify
+## a return type then `Future[void]` is assumed.
+##
+## Inside asynchronous procedures `await` can be used to call any
+## procedures which return a
+## `Future`; this includes asynchronous procedures. When a procedure is
+## "awaited", the asynchronous procedure it is awaited in will
+## suspend its execution
+## until the awaited procedure's Future completes. At which point the
+## asynchronous procedure will resume its execution. During the period
+## when an asynchronous procedure is suspended other asynchronous procedures
+## will be run by the dispatcher.
+##
+## The `await` call may be used in many contexts. It can be used on the right
+## hand side of a variable declaration: `var data = await socket.recv(100)`,
+## in which case the variable will be set to the value of the future
+## automatically. It can be used to await a `Future` object, and it can
+## be used to await a procedure returning a `Future[void]`:
+## `await socket.send("foobar")`.
+##
+## If an awaited future completes with an error, then `await` will re-raise
+## this error. To avoid this, you can use the `yield` keyword instead of
+## `await`. The following section shows different ways that you can handle
+## exceptions in async procs.
+##
+## .. caution::
+##     Procedures marked {.async.} do not support mutable parameters such
+##     as `var int`. References such as `ref int` should be used instead.
+##
+## Handling Exceptions
+## -------------------
+##
+## You can handle exceptions in the same way as in ordinary Nim code;
+## by using the try statement:
+##
+##   ```Nim
+##   try:
+##     let data = await sock.recv(100)
+##     echo("Received ", data)
+##   except:
+##     # Handle exception
+##   ```
+##
+## An alternative approach to handling exceptions is to use `yield` on a future
+## then check the future's `failed` property. For example:
+##
+##   ```Nim
+##   var future = sock.recv(100)
+##   yield future
+##   if future.failed:
+##     # Handle exception
+##   ```
+##
+##
+## Discarding futures
+## ==================
+##
+## Futures should **never** be discarded directly because they may contain
+## errors. If you do not care for the result of a Future then you should use
+## the `asyncCheck` procedure instead of the `discard` keyword. Note that this
+## does not wait for completion, and you should use `waitFor` or `await` for that purpose.
+##
+## .. note:: `await` also checks if the future fails, so you can safely discard
+##   its result.
+##
+## Handling futures
+## ================
+##
+## There are many different operations that apply to a future.
+## The three primary high-level operations are `asyncCheck`,
+## `waitFor`, and `await`.
+##
+## * `asyncCheck`: Raises an exception if the future fails. It neither waits
+##   for the future to finish nor returns the result of the future.
+## * `waitFor`: Polls the event loop and blocks the current thread until the
+##   future finishes. This is often used to call an async procedure from a
+##   synchronous context and should never be used in an `async` proc.
+## * `await`: Pauses execution in the current async procedure until the future
+##   finishes. While the current procedure is paused, other async procedures will
+##   continue running. Should be used instead of `waitFor` in an async
+##   procedure.
+##
+## Here is a handy quick reference chart showing their high-level differences:
+## ==============  =====================   =======================
+## Procedure       Context                 Blocking
+## ==============  =====================   =======================
+## `asyncCheck`    non-async and async     non-blocking
+## `waitFor`       non-async               blocks current thread
+## `await`         async                   suspends current proc
+## ==============  =====================   =======================
+##
+## Examples
+## ========
+##
+## For examples take a look at the documentation for the modules implementing
+## asynchronous IO. A good place to start is the
+## `asyncnet module <asyncnet.html>`_.
+##
+## Investigating pending futures
+## =============================
+##
+## It's possible to get into a situation where an async proc, or more accurately
+## a `Future[T]` gets stuck and
+## never completes. This can happen for various reasons and can cause serious
+## memory leaks. When this occurs it's hard to identify the procedure that is
+## stuck.
+##
+## Thankfully there is a mechanism which tracks the count of each pending future.
+## All you need to do to enable it is compile with `-d:futureLogging` and
+## use the `getFuturesInProgress` procedure to get the list of pending futures
+## together with the stack traces to the moment of their creation.
+##
+## You may also find it useful to use this
+## `prometheus package <https://github.com/dom96/prometheus>`_ which will log
+## the pending futures into prometheus, allowing you to analyse them via a nice
+## graph.
+##
+##
+##
+## Limitations/Bugs
+## ================
+##
+## * The effect system (`raises: []`) does not work with async procedures.
+## * Mutable parameters are not supported by async procedures.
+##
+##
+## Multiple async backend support
+## ==============================
+##
+## Thanks to its powerful macro support, Nim allows ``async``/``await`` to be
+## implemented in libraries with only minimal support from the language - as
+## such, multiple ``async`` libraries exist, including ``asyncdispatch`` and
+## ``chronos``, and more may come to be developed in the future.
+##
+## Libraries built on top of async/await may wish to support multiple async
+## backends - the best way to do so is to create separate modules for each backend
+## that may be imported side-by-side.
+##
+## An alternative way is to select backend using a global compile flag - this
+## method makes it difficult to compose applications that use both backends as may
+## happen with transitive dependencies, but may be appropriate in some cases -
+## libraries choosing this path should call the flag `asyncBackend`, allowing
+## applications to choose the backend with `-d:asyncBackend=<backend_name>`.
+##
+## Known `async` backends include:
+##
+## * `-d:asyncBackend=none`: disable `async` support completely
+## * `-d:asyncBackend=asyncdispatch`: https://nim-lang.org/docs/asyncdispatch.html
+## * `-d:asyncBackend=chronos`: https://github.com/status-im/nim-chronos/
+##
+## ``none`` can be used when a library supports both a synchronous and
+## asynchronous API, to disable the latter.
+
+import std/[os, tables, strutils, times, heapqueue, options, asyncstreams]
+import std/[math, monotimes]
+import std/asyncfutures except callSoon
+
+import std/[nativesockets, net, deques]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+export Port, SocketFlag
+export asyncfutures except callSoon
+export asyncstreams
+
+# TODO: Check if yielded future is nil and throw a more meaningful exception
+
+type
+  PDispatcherBase = ref object of RootRef
+    timers*: HeapQueue[tuple[finishAt: MonoTime, fut: Future[void]]]
+    callbacks*: Deque[proc () {.gcsafe.}]
+
+proc processTimers(
+  p: PDispatcherBase, didSomeWork: var bool
+): Option[int] {.inline.} =
+  # Pop the timers in the order in which they will expire (smaller `finishAt`).
+  var count = p.timers.len
+  let t = getMonoTime()
+  while count > 0 and t >= p.timers[0].finishAt:
+    p.timers.pop().fut.complete()
+    dec count
+    didSomeWork = true
+
+  # Return the number of milliseconds in which the next timer will expire.
+  if p.timers.len == 0: return
+
+  let millisecs = (p.timers[0].finishAt - getMonoTime()).inMilliseconds
+  return some(millisecs.int + 1)
+
+proc processPendingCallbacks(p: PDispatcherBase; didSomeWork: var bool) =
+  while p.callbacks.len > 0:
+    var cb = p.callbacks.popFirst()
+    cb()
+    didSomeWork = true
+
+proc adjustTimeout(
+  p: PDispatcherBase, pollTimeout: int, nextTimer: Option[int]
+): int {.inline.} =
+  if p.callbacks.len != 0:
+    return 0
+
+  if nextTimer.isNone() or pollTimeout == -1:
+    return pollTimeout
+
+  result = max(nextTimer.get(), 0)
+  result = min(pollTimeout, result)
+
+proc runOnce(timeout: int): bool {.gcsafe.}
+
+proc callSoon*(cbproc: proc () {.gcsafe.}) {.gcsafe.}
+  ## Schedule `cbproc` to be called as soon as possible.
+  ## The callback is called when control returns to the event loop.
+
+proc initCallSoonProc =
+  if asyncfutures.getCallSoonProc().isNil:
+    asyncfutures.setCallSoonProc(callSoon)
+
+template implementSetInheritable() {.dirty.} =
+  when declared(setInheritable):
+    proc setInheritable*(fd: AsyncFD, inheritable: bool): bool =
+      ## Control whether a file handle can be inherited by child processes.
+      ## Returns `true` on success.
+      ##
+      ## This procedure is not guaranteed to be available for all platforms.
+      ## Test for availability with `declared() <system.html#declared,untyped>`_.
+      fd.FileHandle.setInheritable(inheritable)
+
+when defined(windows) or defined(nimdoc):
+  import std/[winlean, sets, hashes]
+  type
+    CompletionKey = ULONG_PTR
+
+    CompletionData* = object
+      fd*: AsyncFD       # TODO: Rename this.
+      cb*: owned(proc (fd: AsyncFD, bytesTransferred: DWORD,
+                errcode: OSErrorCode) {.closure, gcsafe.})
+      cell*: ForeignCell # we need this `cell` to protect our `cb` environment,
+                         # when using RegisterWaitForSingleObject, because
+                         # waiting is done in different thread.
+
+    PDispatcher* = ref object of PDispatcherBase
+      ioPort: Handle
+      handles*: HashSet[AsyncFD] # Export handles so that an external library can register them.
+
+    CustomObj = object of OVERLAPPED
+      data*: CompletionData
+
+    CustomRef* = ref CustomObj
+
+    AsyncFD* = distinct int
+
+    PostCallbackData = object
+      ioPort: Handle
+      handleFd: AsyncFD
+      waitFd: Handle
+      ovl: owned CustomRef
+    PostCallbackDataPtr = ptr PostCallbackData
+
+    AsyncEventImpl = object
+      hEvent: Handle
+      hWaiter: Handle
+      pcd: PostCallbackDataPtr
+    AsyncEvent* = ptr AsyncEventImpl
+
+    Callback* = proc (fd: AsyncFD): bool {.closure, gcsafe.}
+
+  proc hash(x: AsyncFD): Hash {.borrow.}
+  proc `==`*(x: AsyncFD, y: AsyncFD): bool {.borrow.}
+
+  proc newDispatcher*(): owned PDispatcher =
+    ## Creates a new Dispatcher instance.
+    new result
+    result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1)
+    result.handles = initHashSet[AsyncFD]()
+    result.timers.clear()
+    result.callbacks = initDeque[proc () {.closure, gcsafe.}](64)
+
+  var gDisp{.threadvar.}: owned PDispatcher ## Global dispatcher
+
+  proc setGlobalDispatcher*(disp: sink PDispatcher) =
+    if not gDisp.isNil:
+      assert gDisp.callbacks.len == 0
+    gDisp = disp
+    initCallSoonProc()
+
+  proc getGlobalDispatcher*(): PDispatcher =
+    if gDisp.isNil:
+      setGlobalDispatcher(newDispatcher())
+    result = gDisp
+
+  proc getIoHandler*(disp: PDispatcher): Handle =
+    ## Returns the underlying IO Completion Port handle (Windows) or selector
+    ## (Unix) for the specified dispatcher.
+    return disp.ioPort
+
+  proc register*(fd: AsyncFD) =
+    ## Registers `fd` with the dispatcher.
+    let p = getGlobalDispatcher()
+
+    if createIoCompletionPort(fd.Handle, p.ioPort,
+                              cast[CompletionKey](fd), 1) == 0:
+      raiseOSError(osLastError())
+    p.handles.incl(fd)
+
+  proc verifyPresence(fd: AsyncFD) =
+    ## Ensures that file descriptor has been registered with the dispatcher.
+    ## Raises ValueError if `fd` has not been registered.
+    let p = getGlobalDispatcher()
+    if fd notin p.handles:
+      raise newException(ValueError,
+        "Operation performed on a socket which has not been registered with" &
+        " the dispatcher yet.")
+
+  proc hasPendingOperations*(): bool =
+    ## Returns `true` if the global dispatcher has pending operations.
+    let p = getGlobalDispatcher()
+    p.handles.len != 0 or p.timers.len != 0 or p.callbacks.len != 0
+
+  proc runOnce(timeout: int): bool =
+    let p = getGlobalDispatcher()
+    if p.handles.len == 0 and p.timers.len == 0 and p.callbacks.len == 0:
+      raise newException(ValueError,
+        "No handles or timers registered in dispatcher.")
+
+    result = false
+    let nextTimer = processTimers(p, result)
+    let at = adjustTimeout(p, timeout, nextTimer)
+    var llTimeout =
+      if at == -1: winlean.INFINITE
+      else: at.int32
+
+    var lpNumberOfBytesTransferred: DWORD
+    var lpCompletionKey: ULONG_PTR
+    var customOverlapped: CustomRef
+    let res = getQueuedCompletionStatus(p.ioPort,
+        addr lpNumberOfBytesTransferred, addr lpCompletionKey,
+        cast[ptr POVERLAPPED](addr customOverlapped), llTimeout).bool
+    result = true
+    # For 'gcDestructors' the destructor of 'customOverlapped' will
+    # be called at the end and we are the only owner here. This means
+    # We do not have to 'GC_unref(customOverlapped)' because the destructor
+    # does that for us.
+
+    # http://stackoverflow.com/a/12277264/492186
+    # TODO: http://www.serverframework.com/handling-multiple-pending-socket-read-and-write-operations.html
+    if res:
+      # This is useful for ensuring the reliability of the overlapped struct.
+      assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
+
+      customOverlapped.data.cb(customOverlapped.data.fd,
+          lpNumberOfBytesTransferred, OSErrorCode(-1))
+
+      # If cell.data != nil, then system.protect(rawEnv(cb)) was called,
+      # so we need to dispose our `cb` environment, because it is not needed
+      # anymore.
+      if customOverlapped.data.cell.data != nil:
+        system.dispose(customOverlapped.data.cell)
+
+      when not defined(gcDestructors):
+        GC_unref(customOverlapped)
+    else:
+      let errCode = osLastError()
+      if customOverlapped != nil:
+        assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
+        customOverlapped.data.cb(customOverlapped.data.fd,
+            lpNumberOfBytesTransferred, errCode)
+        if customOverlapped.data.cell.data != nil:
+          system.dispose(customOverlapped.data.cell)
+        when not defined(gcDestructors):
+          GC_unref(customOverlapped)
+      else:
+        if errCode.int32 == WAIT_TIMEOUT:
+          # Timed out
+          result = false
+        else: raiseOSError(errCode)
+
+    # Timer processing.
+    discard processTimers(p, result)
+    # Callback queue processing
+    processPendingCallbacks(p, result)
+
+
+  var acceptEx: WSAPROC_ACCEPTEX
+  var connectEx: WSAPROC_CONNECTEX
+  var getAcceptExSockAddrs: WSAPROC_GETACCEPTEXSOCKADDRS
+
+  proc initPointer(s: SocketHandle, fun: var pointer, guid: var GUID): bool =
+    # Ref: https://github.com/powdahound/twisted/blob/master/twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c
+    var bytesRet: DWORD
+    fun = nil
+    result = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, addr guid,
+                      sizeof(GUID).DWORD, addr fun, sizeof(pointer).DWORD,
+                      addr bytesRet, nil, nil) == 0
+
+  proc initAll() =
+    let dummySock = createNativeSocket()
+    if dummySock == INVALID_SOCKET:
+      raiseOSError(osLastError())
+    var fun: pointer = nil
+    if not initPointer(dummySock, fun, WSAID_CONNECTEX):
+      raiseOSError(osLastError())
+    connectEx = cast[WSAPROC_CONNECTEX](fun)
+    if not initPointer(dummySock, fun, WSAID_ACCEPTEX):
+      raiseOSError(osLastError())
+    acceptEx = cast[WSAPROC_ACCEPTEX](fun)
+    if not initPointer(dummySock, fun, WSAID_GETACCEPTEXSOCKADDRS):
+      raiseOSError(osLastError())
+    getAcceptExSockAddrs = cast[WSAPROC_GETACCEPTEXSOCKADDRS](fun)
+    close(dummySock)
+
+  proc newCustom*(): CustomRef =
+    result = CustomRef() # 0
+    GC_ref(result) # 1  prevent destructor from doing a premature free.
+    # destructor of newCustom's caller --> 0. This means
+    # Windows holds a ref for us with RC == 0 (single owner).
+    # This is passed back to us in the IO completion port.
+
+  proc recv*(socket: AsyncFD, size: int,
+             flags = {SocketFlag.SafeDisconn}): owned(Future[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
+    ## complete with a value of `""`.
+    ##
+    ## .. warning:: The `Peek` socket flag is not supported on Windows.
+
+
+    # Things to note:
+    #   * When WSARecv completes immediately then `bytesReceived` is very
+    #     unreliable.
+    #   * Still need to implement message-oriented socket disconnection,
+    #     '\0' in the message currently signifies a socket disconnect. Who
+    #     knows what will happen when someone sends that to our socket.
+    verifyPresence(socket)
+    assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
+
+    var retFuture = newFuture[string]("recv")
+    var dataBuf: TWSABuf
+    dataBuf.buf = cast[cstring](alloc0(size))
+    dataBuf.len = size.ULONG
+
+    var bytesReceived: DWORD
+    var flagsio = flags.toOSFlags().DWORD
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            if bytesCount == 0 and dataBuf.buf[0] == '\0':
+              retFuture.complete("")
+            else:
+              var data = newString(bytesCount)
+              assert bytesCount <= size
+              copyMem(addr data[0], addr dataBuf.buf[0], bytesCount)
+              retFuture.complete($data)
+          else:
+            if flags.isDisconnectionError(errcode):
+              retFuture.complete("")
+            else:
+              retFuture.fail(newOSError(errcode))
+        if dataBuf.buf != nil:
+          dealloc dataBuf.buf
+          dataBuf.buf = nil
+    )
+
+    let ret = WSARecv(socket.SocketHandle, addr dataBuf, 1, addr bytesReceived,
+                      addr flagsio, cast[POVERLAPPED](ol), nil)
+    if ret == -1:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        if dataBuf.buf != nil:
+          dealloc dataBuf.buf
+          dataBuf.buf = nil
+        GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete("")
+        else:
+          retFuture.fail(newOSError(err))
+    elif ret == 0:
+      # Request completed immediately.
+      if bytesReceived != 0:
+        var data = newString(bytesReceived)
+        assert bytesReceived <= size
+        copyMem(addr data[0], addr dataBuf.buf[0], bytesReceived)
+        retFuture.complete($data)
+      else:
+        if hasOverlappedIoCompleted(cast[POVERLAPPED](ol)):
+          retFuture.complete("")
+    return retFuture
+
+  proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
+                 flags = {SocketFlag.SafeDisconn}): owned(Future[int]) =
+    ## Reads **up to** `size` bytes from `socket` into `buf`, which must
+    ## at least be of that size. 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 complete with a value of
+    ## `0`.
+    ##
+    ## .. warning:: The `Peek` socket flag is not supported on Windows.
+
+
+    # Things to note:
+    #   * When WSARecv completes immediately then `bytesReceived` is very
+    #     unreliable.
+    #   * Still need to implement message-oriented socket disconnection,
+    #     '\0' in the message currently signifies a socket disconnect. Who
+    #     knows what will happen when someone sends that to our socket.
+    verifyPresence(socket)
+    assert SocketFlag.Peek notin flags, "Peek not supported on Windows."
+
+    var retFuture = newFuture[int]("recvInto")
+
+    #buf[] = '\0'
+    var dataBuf: TWSABuf
+    dataBuf.buf = cast[cstring](buf)
+    dataBuf.len = size.ULONG
+
+    var bytesReceived: DWORD
+    var flagsio = flags.toOSFlags().DWORD
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            retFuture.complete(bytesCount)
+          else:
+            if flags.isDisconnectionError(errcode):
+              retFuture.complete(0)
+            else:
+              retFuture.fail(newOSError(errcode))
+        if dataBuf.buf != nil:
+          dataBuf.buf = nil
+    )
+
+    let ret = WSARecv(socket.SocketHandle, addr dataBuf, 1, addr bytesReceived,
+                      addr flagsio, cast[POVERLAPPED](ol), nil)
+    if ret == -1:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        if dataBuf.buf != nil:
+          dataBuf.buf = nil
+        GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete(0)
+        else:
+          retFuture.fail(newOSError(err))
+    elif ret == 0:
+      # Request completed immediately.
+      if bytesReceived != 0:
+        assert bytesReceived <= size
+        retFuture.complete(bytesReceived)
+      else:
+        if hasOverlappedIoCompleted(cast[POVERLAPPED](ol)):
+          retFuture.complete(bytesReceived)
+    return retFuture
+
+  proc send*(socket: AsyncFD, buf: pointer, size: int,
+             flags = {SocketFlag.SafeDisconn}): owned(Future[void]) =
+    ## Sends `size` bytes from `buf` to `socket`. The returned future
+    ## will complete once all data has been sent.
+    ##
+    ## .. warning:: Use it with caution. If `buf` refers to GC'ed object,
+    ##   you must use GC_ref/GC_unref calls to avoid early freeing of the buffer.
+    verifyPresence(socket)
+    var retFuture = newFuture[void]("send")
+
+    var dataBuf: TWSABuf
+    dataBuf.buf = cast[cstring](buf)
+    dataBuf.len = size.ULONG
+
+    var bytesReceived, lowFlags: DWORD
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            retFuture.complete()
+          else:
+            if flags.isDisconnectionError(errcode):
+              retFuture.complete()
+            else:
+              retFuture.fail(newOSError(errcode))
+    )
+
+    let ret = WSASend(socket.SocketHandle, addr dataBuf, 1, addr bytesReceived,
+                      lowFlags, cast[POVERLAPPED](ol), nil)
+    if ret == -1:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        GC_unref(ol)
+        if flags.isDisconnectionError(err):
+          retFuture.complete()
+        else:
+          retFuture.fail(newOSError(err))
+    else:
+      retFuture.complete()
+      # We don't deallocate `ol` here because even though this completed
+      # immediately poll will still be notified about its completion and it will
+      # free `ol`.
+    return retFuture
+
+  proc sendTo*(socket: AsyncFD, data: pointer, size: int, saddr: ptr SockAddr,
+               saddrLen: SockLen,
+               flags = {SocketFlag.SafeDisconn}): owned(Future[void]) =
+    ## Sends `data` to specified destination `saddr`, using
+    ## socket `socket`. The returned future will complete once all data
+    ## has been sent.
+    verifyPresence(socket)
+    var retFuture = newFuture[void]("sendTo")
+    var dataBuf: TWSABuf
+    dataBuf.buf = cast[cstring](data)
+    dataBuf.len = size.ULONG
+    var bytesSent = 0.DWORD
+    var lowFlags = 0.DWORD
+
+    # we will preserve address in our stack
+    var staddr: array[128, char] # SOCKADDR_STORAGE size is 128 bytes
+    var stalen: cint = cint(saddrLen)
+    zeroMem(addr(staddr[0]), 128)
+    copyMem(addr(staddr[0]), saddr, saddrLen)
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            retFuture.complete()
+          else:
+            retFuture.fail(newOSError(errcode))
+    )
+
+    let ret = WSASendTo(socket.SocketHandle, addr dataBuf, 1, addr bytesSent,
+                        lowFlags, cast[ptr SockAddr](addr(staddr[0])),
+                        stalen, cast[POVERLAPPED](ol), nil)
+    if ret == -1:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        GC_unref(ol)
+        retFuture.fail(newOSError(err))
+    else:
+      retFuture.complete()
+      # We don't deallocate `ol` here because even though this completed
+      # immediately poll will still be notified about its completion and it will
+      # free `ol`.
+    return retFuture
+
+  proc recvFromInto*(socket: AsyncFD, data: pointer, size: int,
+                     saddr: ptr SockAddr, saddrLen: ptr SockLen,
+                     flags = {SocketFlag.SafeDisconn}): owned(Future[int]) =
+    ## Receives a datagram data from `socket` into `buf`, which must
+    ## be at least of size `size`, address of datagram's sender will be
+    ## stored into `saddr` and `saddrLen`. Returned future will complete
+    ## once one datagram has been received, and will return size of packet
+    ## received.
+    verifyPresence(socket)
+    var retFuture = newFuture[int]("recvFromInto")
+
+    var dataBuf = TWSABuf(buf: cast[cstring](data), len: size.ULONG)
+
+    var bytesReceived = 0.DWORD
+    var lowFlags = 0.DWORD
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            assert bytesCount <= size
+            retFuture.complete(bytesCount)
+          else:
+            # datagram sockets don't have disconnection,
+            # so we can just raise an exception
+            retFuture.fail(newOSError(errcode))
+    )
+
+    let res = WSARecvFrom(socket.SocketHandle, addr dataBuf, 1,
+                          addr bytesReceived, addr lowFlags,
+                          saddr, cast[ptr cint](saddrLen),
+                          cast[POVERLAPPED](ol), nil)
+    if res == -1:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        GC_unref(ol)
+        retFuture.fail(newOSError(err))
+    else:
+      # Request completed immediately.
+      if bytesReceived != 0:
+        assert bytesReceived <= size
+        retFuture.complete(bytesReceived)
+      else:
+        if hasOverlappedIoCompleted(cast[POVERLAPPED](ol)):
+          retFuture.complete(bytesReceived)
+    return retFuture
+
+  proc acceptAddr*(socket: AsyncFD, flags = {SocketFlag.SafeDisconn},
+                   inheritable = defined(nimInheritHandles)):
+      owned(Future[tuple[address: string, client: AsyncFD]]) {.gcsafe.} =
+    ## Accepts a new connection. Returns a future containing the client socket
+    ## corresponding to that connection and the remote address of the client.
+    ## The future will complete when the connection is successfully accepted.
+    ##
+    ## The resulting client socket is automatically registered to the
+    ## dispatcher.
+    ##
+    ## If `inheritable` is false (the default), the resulting client socket will
+    ## not be inheritable by child processes.
+    ##
+    ## The `accept` call may result in an error if the connecting socket
+    ## disconnects during the duration of the `accept`. If the `SafeDisconn`
+    ## flag is specified then this error will not be raised and instead
+    ## accept will be called again.
+    verifyPresence(socket)
+    var retFuture = newFuture[tuple[address: string, client: AsyncFD]]("acceptAddr")
+
+    var clientSock = createNativeSocket(inheritable = inheritable)
+    if clientSock == osInvalidSocket: raiseOSError(osLastError())
+
+    const lpOutputLen = 1024
+    var lpOutputBuf = newString(lpOutputLen)
+    var dwBytesReceived: DWORD
+    let dwReceiveDataLength = 0.DWORD # We don't want any data to be read.
+    let dwLocalAddressLength = DWORD(sizeof(Sockaddr_in6) + 16)
+    let dwRemoteAddressLength = DWORD(sizeof(Sockaddr_in6) + 16)
+
+    template failAccept(errcode) =
+      if flags.isDisconnectionError(errcode):
+        var newAcceptFut = acceptAddr(socket, flags)
+        newAcceptFut.callback =
+          proc () =
+            if newAcceptFut.failed:
+              retFuture.fail(newAcceptFut.readError)
+            else:
+              retFuture.complete(newAcceptFut.read)
+      else:
+        retFuture.fail(newOSError(errcode))
+
+    template completeAccept() {.dirty.} =
+      var listenSock = socket
+      let setoptRet = setsockopt(clientSock, SOL_SOCKET,
+          SO_UPDATE_ACCEPT_CONTEXT, addr listenSock,
+          sizeof(listenSock).SockLen)
+      if setoptRet != 0:
+        let errcode = osLastError()
+        discard clientSock.closesocket()
+        failAccept(errcode)
+      else:
+        var localSockaddr, remoteSockaddr: ptr SockAddr
+        var localLen, remoteLen: int32
+        getAcceptExSockAddrs(addr lpOutputBuf[0], dwReceiveDataLength,
+                             dwLocalAddressLength, dwRemoteAddressLength,
+                             addr localSockaddr, addr localLen,
+                             addr remoteSockaddr, addr remoteLen)
+        try:
+          let address = getAddrString(remoteSockaddr)
+          register(clientSock.AsyncFD)
+          retFuture.complete((address: address, client: clientSock.AsyncFD))
+        except:
+          # getAddrString may raise
+          clientSock.close()
+          retFuture.fail(getCurrentException())
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) {.gcsafe.} =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            completeAccept()
+          else:
+            failAccept(errcode)
+    )
+
+    # http://msdn.microsoft.com/en-us/library/windows/desktop/ms737524%28v=vs.85%29.aspx
+    let ret = acceptEx(socket.SocketHandle, clientSock, addr lpOutputBuf[0],
+                       dwReceiveDataLength,
+                       dwLocalAddressLength,
+                       dwRemoteAddressLength,
+                       addr dwBytesReceived, cast[POVERLAPPED](ol))
+
+    if not ret:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        failAccept(err)
+        GC_unref(ol)
+    else:
+      completeAccept()
+      # We don't deallocate `ol` here because even though this completed
+      # immediately poll will still be notified about its completion and it will
+      # free `ol`.
+
+    return retFuture
+
+  implementSetInheritable()
+
+  proc closeSocket*(socket: AsyncFD) =
+    ## Closes a socket and ensures that it is unregistered.
+    socket.SocketHandle.close()
+    getGlobalDispatcher().handles.excl(socket)
+
+  proc unregister*(fd: AsyncFD) =
+    ## Unregisters `fd`.
+    getGlobalDispatcher().handles.excl(fd)
+
+  proc contains*(disp: PDispatcher, fd: AsyncFD): bool =
+    return fd in disp.handles
+
+  {.push stackTrace: off.}
+  proc waitableCallback(param: pointer,
+                        timerOrWaitFired: WINBOOL) {.stdcall.} =
+    var p = cast[PostCallbackDataPtr](param)
+    discard postQueuedCompletionStatus(p.ioPort, timerOrWaitFired.DWORD,
+                                       ULONG_PTR(p.handleFd),
+                                       cast[pointer](p.ovl))
+  {.pop.}
+
+  proc registerWaitableEvent(fd: AsyncFD, cb: Callback; mask: DWORD) =
+    let p = getGlobalDispatcher()
+    var flags = (WT_EXECUTEINWAITTHREAD or WT_EXECUTEONLYONCE).DWORD
+    var hEvent = wsaCreateEvent()
+    if hEvent == 0:
+      raiseOSError(osLastError())
+    var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))
+    pcd.ioPort = p.ioPort
+    pcd.handleFd = fd
+    var ol = newCustom()
+
+    ol.data = CompletionData(fd: fd, cb:
+      proc(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) {.gcsafe.} =
+        # we excluding our `fd` because cb(fd) can register own handler
+        # for this `fd`
+        p.handles.excl(fd)
+        # unregisterWait() is called before callback, because appropriate
+        # winsockets function can re-enable event.
+        # https://msdn.microsoft.com/en-us/library/windows/desktop/ms741576(v=vs.85).aspx
+        if unregisterWait(pcd.waitFd) == 0:
+          let err = osLastError()
+          if err.int32 != ERROR_IO_PENDING:
+            deallocShared(cast[pointer](pcd))
+            discard wsaCloseEvent(hEvent)
+            raiseOSError(err)
+        if cb(fd):
+          # callback returned `true`, so we free all allocated resources
+          deallocShared(cast[pointer](pcd))
+          if not wsaCloseEvent(hEvent):
+            raiseOSError(osLastError())
+          # pcd.ovl will be unrefed in poll().
+        else:
+          # callback returned `false` we need to continue
+          if p.handles.contains(fd):
+            # new callback was already registered with `fd`, so we free all
+            # allocated resources. This happens because in callback `cb`
+            # addRead/addWrite was called with same `fd`.
+            deallocShared(cast[pointer](pcd))
+            if not wsaCloseEvent(hEvent):
+              raiseOSError(osLastError())
+          else:
+            # we need to include `fd` again
+            p.handles.incl(fd)
+            # and register WaitForSingleObject again
+            if not registerWaitForSingleObject(addr(pcd.waitFd), hEvent,
+                                    cast[WAITORTIMERCALLBACK](waitableCallback),
+                                       cast[pointer](pcd), INFINITE, flags):
+              # pcd.ovl will be unrefed in poll()
+              let err = osLastError()
+              deallocShared(cast[pointer](pcd))
+              discard wsaCloseEvent(hEvent)
+              raiseOSError(err)
+            else:
+              # we incref `pcd.ovl` and `protect` callback one more time,
+              # because it will be unrefed and disposed in `poll()` after
+              # callback finishes.
+              GC_ref(pcd.ovl)
+              pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
+    )
+    # We need to protect our callback environment value, so GC will not free it
+    # accidentally.
+    ol.data.cell = system.protect(rawEnv(ol.data.cb))
+
+    # This is main part of `hacky way` is using WSAEventSelect, so `hEvent`
+    # will be signaled when appropriate `mask` events will be triggered.
+    if wsaEventSelect(fd.SocketHandle, hEvent, mask) != 0:
+      let err = osLastError()
+      GC_unref(ol)
+      deallocShared(cast[pointer](pcd))
+      discard wsaCloseEvent(hEvent)
+      raiseOSError(err)
+
+    pcd.ovl = ol
+    if not registerWaitForSingleObject(addr(pcd.waitFd), hEvent,
+                                    cast[WAITORTIMERCALLBACK](waitableCallback),
+                                       cast[pointer](pcd), INFINITE, flags):
+      let err = osLastError()
+      GC_unref(ol)
+      deallocShared(cast[pointer](pcd))
+      discard wsaCloseEvent(hEvent)
+      raiseOSError(err)
+    p.handles.incl(fd)
+
+  proc addRead*(fd: AsyncFD, cb: Callback) =
+    ## Start watching the file descriptor for read availability and then call
+    ## the callback `cb`.
+    ##
+    ## This is not `pure` mechanism for Windows Completion Ports (IOCP),
+    ## so if you can avoid it, please do it. Use `addRead` only if really
+    ## need it (main usecase is adaptation of unix-like libraries to be
+    ## asynchronous on Windows).
+    ##
+    ## If you use this function, you don't need to use asyncdispatch.recv()
+    ## or asyncdispatch.accept(), because they are using IOCP, please use
+    ## nativesockets.recv() and nativesockets.accept() instead.
+    ##
+    ## Be sure your callback `cb` returns `true`, if you want to remove
+    ## watch of `read` notifications, and `false`, if you want to continue
+    ## receiving notifications.
+    registerWaitableEvent(fd, cb, FD_READ or FD_ACCEPT or FD_OOB or FD_CLOSE)
+
+  proc addWrite*(fd: AsyncFD, cb: Callback) =
+    ## Start watching the file descriptor for write availability and then call
+    ## the callback `cb`.
+    ##
+    ## This is not `pure` mechanism for Windows Completion Ports (IOCP),
+    ## so if you can avoid it, please do it. Use `addWrite` only if really
+    ## need it (main usecase is adaptation of unix-like libraries to be
+    ## asynchronous on Windows).
+    ##
+    ## If you use this function, you don't need to use asyncdispatch.send()
+    ## or asyncdispatch.connect(), because they are using IOCP, please use
+    ## nativesockets.send() and nativesockets.connect() instead.
+    ##
+    ## Be sure your callback `cb` returns `true`, if you want to remove
+    ## watch of `write` notifications, and `false`, if you want to continue
+    ## receiving notifications.
+    registerWaitableEvent(fd, cb, FD_WRITE or FD_CONNECT or FD_CLOSE)
+
+  template registerWaitableHandle(p, hEvent, flags, pcd, timeout,
+                                  handleCallback) =
+    let handleFD = AsyncFD(hEvent)
+    pcd.ioPort = p.ioPort
+    pcd.handleFd = handleFD
+    var ol = newCustom()
+    ol.data.fd = handleFD
+    ol.data.cb = handleCallback
+    # We need to protect our callback environment value, so GC will not free it
+    # accidentally.
+    ol.data.cell = system.protect(rawEnv(ol.data.cb))
+
+    pcd.ovl = ol
+    if not registerWaitForSingleObject(addr(pcd.waitFd), hEvent,
+                                    cast[WAITORTIMERCALLBACK](waitableCallback),
+                                    cast[pointer](pcd), timeout.DWORD, flags):
+      let err = osLastError()
+      GC_unref(ol)
+      deallocShared(cast[pointer](pcd))
+      discard closeHandle(hEvent)
+      raiseOSError(err)
+    p.handles.incl(handleFD)
+
+  template closeWaitable(handle: untyped) =
+    let waitFd = pcd.waitFd
+    deallocShared(cast[pointer](pcd))
+    p.handles.excl(fd)
+    if unregisterWait(waitFd) == 0:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        discard closeHandle(handle)
+        raiseOSError(err)
+    if closeHandle(handle) == 0:
+      raiseOSError(osLastError())
+
+  proc addTimer*(timeout: int, oneshot: bool, cb: Callback) =
+    ## Registers callback `cb` to be called when timer expired.
+    ##
+    ## Parameters:
+    ##
+    ## * `timeout` - timeout value in milliseconds.
+    ## * `oneshot`
+    ##   * `true` - generate only one timeout event
+    ##   * `false` - generate timeout events periodically
+
+    doAssert(timeout > 0)
+    let p = getGlobalDispatcher()
+
+    var hEvent = createEvent(nil, 1, 0, nil)
+    if hEvent == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+
+    var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))
+    var flags = WT_EXECUTEINWAITTHREAD.DWORD
+    if oneshot: flags = flags or WT_EXECUTEONLYONCE
+
+    proc timercb(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+      let res = cb(fd)
+      if res or oneshot:
+        closeWaitable(hEvent)
+      else:
+        # if callback returned `false`, then it wants to be called again, so
+        # we need to ref and protect `pcd.ovl` again, because it will be
+        # unrefed and disposed in `poll()`.
+        GC_ref(pcd.ovl)
+        pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
+
+    registerWaitableHandle(p, hEvent, flags, pcd, timeout, timercb)
+
+  proc addProcess*(pid: int, cb: Callback) =
+    ## Registers callback `cb` to be called when process with process ID
+    ## `pid` exited.
+    const NULL = Handle(0)
+    let p = getGlobalDispatcher()
+    let procFlags = SYNCHRONIZE
+    var hProcess = openProcess(procFlags, 0, pid.DWORD)
+    if hProcess == NULL:
+      raiseOSError(osLastError())
+
+    var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))
+    var flags = WT_EXECUTEINWAITTHREAD.DWORD or WT_EXECUTEONLYONCE.DWORD
+
+    proc proccb(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+      closeWaitable(hProcess)
+      discard cb(fd)
+
+    registerWaitableHandle(p, hProcess, flags, pcd, INFINITE, proccb)
+
+  proc newAsyncEvent*(): AsyncEvent =
+    ## Creates a new thread-safe `AsyncEvent` object.
+    ##
+    ## New `AsyncEvent` object is not automatically registered with
+    ## dispatcher like `AsyncSocket`.
+    var sa = SECURITY_ATTRIBUTES(
+      nLength: sizeof(SECURITY_ATTRIBUTES).cint,
+      bInheritHandle: 1
+    )
+    var event = createEvent(addr(sa), 0'i32, 0'i32, nil)
+    if event == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+    result = cast[AsyncEvent](allocShared0(sizeof(AsyncEventImpl)))
+    result.hEvent = event
+
+  proc trigger*(ev: AsyncEvent) =
+    ## Set event `ev` to signaled state.
+    if setEvent(ev.hEvent) == 0:
+      raiseOSError(osLastError())
+
+  proc unregister*(ev: AsyncEvent) =
+    ## Unregisters event `ev`.
+    doAssert(ev.hWaiter != 0, "Event is not registered in the queue!")
+    let p = getGlobalDispatcher()
+    p.handles.excl(AsyncFD(ev.hEvent))
+    if unregisterWait(ev.hWaiter) == 0:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        raiseOSError(err)
+    ev.hWaiter = 0
+
+  proc close*(ev: AsyncEvent) =
+    ## Closes event `ev`.
+    let res = closeHandle(ev.hEvent)
+    deallocShared(cast[pointer](ev))
+    if res == 0:
+      raiseOSError(osLastError())
+
+  proc addEvent*(ev: AsyncEvent, cb: Callback) =
+    ## Registers callback `cb` to be called when `ev` will be signaled
+    doAssert(ev.hWaiter == 0, "Event is already registered in the queue!")
+
+    let p = getGlobalDispatcher()
+    let hEvent = ev.hEvent
+
+    var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))
+    var flags = WT_EXECUTEINWAITTHREAD.DWORD
+
+    proc eventcb(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+      if ev.hWaiter != 0:
+        if cb(fd):
+          # we need this check to avoid exception, if `unregister(event)` was
+          # called in callback.
+          deallocShared(cast[pointer](pcd))
+          if ev.hWaiter != 0:
+            unregister(ev)
+        else:
+          # if callback returned `false`, then it wants to be called again, so
+          # we need to ref and protect `pcd.ovl` again, because it will be
+          # unrefed and disposed in `poll()`.
+          GC_ref(pcd.ovl)
+          pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
+      else:
+        # if ev.hWaiter == 0, then event was unregistered before `poll()` call.
+        deallocShared(cast[pointer](pcd))
+
+    registerWaitableHandle(p, hEvent, flags, pcd, INFINITE, eventcb)
+    ev.hWaiter = pcd.waitFd
+
+  initAll()
+else:
+  import std/selectors
+  from std/posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
+                    MSG_NOSIGNAL
+  when declared(posix.accept4):
+    from std/posix import accept4, SOCK_CLOEXEC
+  when defined(genode):
+    import genode/env # get the implicit Genode env
+    import genode/signals
+
+  const
+    InitCallbackListSize = 4         # initial size of callbacks sequence,
+                                     # associated with file/socket descriptor.
+    InitDelayedCallbackListSize = 64 # initial size of delayed callbacks
+                                     # queue.
+  type
+    AsyncFD* = distinct cint
+    Callback* = proc (fd: AsyncFD): bool {.closure, gcsafe.}
+
+    AsyncData = object
+      readList: seq[Callback]
+      writeList: seq[Callback]
+
+    AsyncEvent* = distinct SelectEvent
+
+    PDispatcher* = ref object of PDispatcherBase
+      selector: Selector[AsyncData]
+      when defined(genode):
+        signalHandler: SignalHandler
+
+  proc `==`*(x, y: AsyncFD): bool {.borrow.}
+  proc `==`*(x, y: AsyncEvent): bool {.borrow.}
+
+  template newAsyncData(): AsyncData =
+    AsyncData(
+      readList: newSeqOfCap[Callback](InitCallbackListSize),
+      writeList: newSeqOfCap[Callback](InitCallbackListSize)
+    )
+
+  proc newDispatcher*(): owned(PDispatcher) =
+    new result
+    result.selector = newSelector[AsyncData]()
+    result.timers.clear()
+    result.callbacks = initDeque[proc () {.closure, gcsafe.}](InitDelayedCallbackListSize)
+    when defined(genode):
+      let entrypoint = ep(cast[GenodeEnv](runtimeEnv))
+      result.signalHandler = newSignalHandler(entrypoint):
+        discard runOnce(0)
+
+  var gDisp{.threadvar.}: owned PDispatcher ## Global dispatcher
+
+  when defined(nuttx):
+    import std/exitprocs
+
+    proc cleanDispatcher() {.noconv.} =
+      gDisp = nil
+
+    proc addFinalyzer() =
+      addExitProc(cleanDispatcher)
+
+  proc setGlobalDispatcher*(disp: owned PDispatcher) =
+    if not gDisp.isNil:
+      assert gDisp.callbacks.len == 0
+    gDisp = disp
+    initCallSoonProc()
+
+  proc getGlobalDispatcher*(): PDispatcher =
+    if gDisp.isNil:
+      setGlobalDispatcher(newDispatcher())
+      when defined(nuttx):
+        addFinalyzer()
+    result = gDisp
+
+  proc getIoHandler*(disp: PDispatcher): Selector[AsyncData] =
+    return disp.selector
+
+  proc register*(fd: AsyncFD) =
+    let p = getGlobalDispatcher()
+    var data = newAsyncData()
+    p.selector.registerHandle(fd.SocketHandle, {}, data)
+
+  proc unregister*(fd: AsyncFD) =
+    getGlobalDispatcher().selector.unregister(fd.SocketHandle)
+
+  proc unregister*(ev: AsyncEvent) =
+    getGlobalDispatcher().selector.unregister(SelectEvent(ev))
+
+  proc contains*(disp: PDispatcher, fd: AsyncFD): bool =
+    return fd.SocketHandle in disp.selector
+
+  proc addRead*(fd: AsyncFD, cb: Callback) =
+    let p = getGlobalDispatcher()
+    var newEvents = {Event.Read}
+    withData(p.selector, fd.SocketHandle, adata) do:
+      adata.readList.add(cb)
+      newEvents.incl(Event.Read)
+      if len(adata.writeList) != 0: newEvents.incl(Event.Write)
+    do:
+      raise newException(ValueError, "File descriptor not registered.")
+    p.selector.updateHandle(fd.SocketHandle, newEvents)
+
+  proc addWrite*(fd: AsyncFD, cb: Callback) =
+    let p = getGlobalDispatcher()
+    var newEvents = {Event.Write}
+    withData(p.selector, fd.SocketHandle, adata) do:
+      adata.writeList.add(cb)
+      newEvents.incl(Event.Write)
+      if len(adata.readList) != 0: newEvents.incl(Event.Read)
+    do:
+      raise newException(ValueError, "File descriptor not registered.")
+    p.selector.updateHandle(fd.SocketHandle, newEvents)
+
+  proc hasPendingOperations*(): bool =
+    let p = getGlobalDispatcher()
+    not p.selector.isEmpty() or p.timers.len != 0 or p.callbacks.len != 0
+
+  proc prependSeq(dest: var seq[Callback]; src: sink seq[Callback]) =
+    var old = move dest
+    dest = src
+    for i in 0..high(old):
+      dest.add(move old[i])
+
+  proc processBasicCallbacks(
+    fd: AsyncFD, event: Event
+  ): tuple[readCbListCount, writeCbListCount: int] =
+    # Process pending descriptor and AsyncEvent callbacks.
+    #
+    # Invoke every callback stored in `rwlist`, until one
+    # returns `false` (which means callback wants to stay
+    # alive). In such case all remaining callbacks will be added
+    # to `rwlist` again, in the order they have been inserted.
+    #
+    # `rwlist` associated with file descriptor MUST BE emptied before
+    # dispatching callback (See https://github.com/nim-lang/Nim/issues/5128),
+    # or it can be possible to fall into endless cycle.
+    var curList: seq[Callback]
+
+    let selector = getGlobalDispatcher().selector
+    withData(selector, fd.int, fdData):
+      case event
+      of Event.Read:
+        #shallowCopy(curList, fdData.readList)
+        curList = move fdData.readList
+        fdData.readList = newSeqOfCap[Callback](InitCallbackListSize)
+      of Event.Write:
+        #shallowCopy(curList, fdData.writeList)
+        curList = move fdData.writeList
+        fdData.writeList = newSeqOfCap[Callback](InitCallbackListSize)
+      else:
+        assert false, "Cannot process callbacks for " & $event
+
+    let newLength = max(len(curList), InitCallbackListSize)
+    var newList = newSeqOfCap[Callback](newLength)
+
+    var eventsExtinguished = false
+    for cb in curList:
+      if eventsExtinguished:
+        newList.add(cb)
+      elif not cb(fd):
+        # Callback wants to be called again.
+        newList.add(cb)
+        # This callback has returned with EAGAIN, so we don't need to
+        # call any other callbacks as they are all waiting for the same event
+        # on the same fd.
+        # We do need to ensure they are called again though.
+        eventsExtinguished = true
+
+    withData(selector, fd.int, fdData) do:
+      # Descriptor is still present in the queue.
+      case event
+      of Event.Read: prependSeq(fdData.readList, newList)
+      of Event.Write: prependSeq(fdData.writeList, newList)
+      else:
+        assert false, "Cannot process callbacks for " & $event
+
+      result.readCbListCount = len(fdData.readList)
+      result.writeCbListCount = len(fdData.writeList)
+    do:
+      # Descriptor was unregistered in callback via `unregister()`.
+      result.readCbListCount = -1
+      result.writeCbListCount = -1
+
+  proc processCustomCallbacks(p: PDispatcher; fd: AsyncFD) =
+    # Process pending custom event callbacks. Custom events are
+    # {Event.Timer, Event.Signal, Event.Process, Event.Vnode}.
+    # There can be only one callback registered with one descriptor,
+    # so there is no need to iterate over list.
+    var curList: seq[Callback]
+
+    withData(p.selector, fd.int, adata) do:
+      curList = move adata.readList
+      adata.readList = newSeqOfCap[Callback](InitCallbackListSize)
+
+    let newLength = len(curList)
+    var newList = newSeqOfCap[Callback](newLength)
+
+    var cb = curList[0]
+    if not cb(fd):
+      newList.add(cb)
+
+    withData(p.selector, fd.int, adata) do:
+      # descriptor still present in queue.
+      adata.readList = newList & adata.readList
+      if len(adata.readList) == 0:
+        # if no callbacks registered with descriptor, unregister it.
+        p.selector.unregister(fd.int)
+    do:
+      # descriptor was unregistered in callback via `unregister()`.
+      discard
+
+  implementSetInheritable()
+
+  proc closeSocket*(sock: AsyncFD) =
+    let selector = getGlobalDispatcher().selector
+    if sock.SocketHandle notin selector:
+      raise newException(ValueError, "File descriptor not registered.")
+
+    let data = selector.getData(sock.SocketHandle)
+    sock.unregister()
+    sock.SocketHandle.close()
+    # We need to unblock the read and write callbacks which could still be
+    # waiting for the socket to become readable and/or writeable.
+    for cb in data.readList & data.writeList:
+      if not cb(sock):
+        raise newException(
+          ValueError, "Expecting async operations to stop when fd has closed."
+        )
+
+  proc runOnce(timeout: int): bool =
+    let p = getGlobalDispatcher()
+    if p.selector.isEmpty() and p.timers.len == 0 and p.callbacks.len == 0:
+      when defined(genode):
+        if timeout == 0: return
+      raise newException(ValueError,
+        "No handles or timers registered in dispatcher.")
+
+    result = false
+    var keys: array[64, ReadyKey]
+    let nextTimer = processTimers(p, result)
+    var count =
+      p.selector.selectInto(adjustTimeout(p, timeout, nextTimer), keys)
+    for i in 0..<count:
+      let fd = keys[i].fd.AsyncFD
+      let events = keys[i].events
+      var (readCbListCount, writeCbListCount) = (0, 0)
+
+      if Event.Read in events or events == {Event.Error}:
+        (readCbListCount, writeCbListCount) =
+          processBasicCallbacks(fd, Event.Read)
+        result = true
+
+      if Event.Write in events or events == {Event.Error}:
+        (readCbListCount, writeCbListCount) =
+          processBasicCallbacks(fd, Event.Write)
+        result = true
+
+      var isCustomEvent = false
+      if Event.User in events:
+        (readCbListCount, writeCbListCount) =
+          processBasicCallbacks(fd, Event.Read)
+        isCustomEvent = true
+        if readCbListCount == 0:
+          p.selector.unregister(fd.int)
+        result = true
+
+      when ioselSupportedPlatform:
+        const customSet = {Event.Timer, Event.Signal, Event.Process,
+                           Event.Vnode}
+        if (customSet * events) != {}:
+          isCustomEvent = true
+          processCustomCallbacks(p, fd)
+          result = true
+
+      # because state `data` can be modified in callback we need to update
+      # descriptor events with currently registered callbacks.
+      if not isCustomEvent and (readCbListCount != -1 and writeCbListCount != -1):
+        var newEvents: set[Event] = {}
+        if readCbListCount > 0: incl(newEvents, Event.Read)
+        if writeCbListCount > 0: incl(newEvents, Event.Write)
+        p.selector.updateHandle(SocketHandle(fd), newEvents)
+
+    # Timer processing.
+    discard processTimers(p, result)
+    # Callback queue processing
+    processPendingCallbacks(p, result)
+
+  proc recv*(socket: AsyncFD, size: int,
+             flags = {SocketFlag.SafeDisconn}): owned(Future[string]) =
+    var retFuture = newFuture[string]("recv")
+
+    var readBuffer = newString(size)
+
+    proc cb(sock: AsyncFD): bool =
+      result = true
+      let res = recv(sock.SocketHandle, addr readBuffer[0], size.cint,
+                     flags.toOSFlags())
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EINTR and lastError.int32 != EWOULDBLOCK and
+           lastError.int32 != EAGAIN:
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete("")
+          else:
+            retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      elif res == 0:
+        # Disconnected
+        retFuture.complete("")
+      else:
+        readBuffer.setLen(res)
+        retFuture.complete(readBuffer)
+    # TODO: The following causes a massive slowdown.
+    #if not cb(socket):
+    addRead(socket, cb)
+    return retFuture
+
+  proc recvInto*(socket: AsyncFD, buf: pointer, size: int,
+                 flags = {SocketFlag.SafeDisconn}): owned(Future[int]) =
+    var retFuture = newFuture[int]("recvInto")
+
+    proc cb(sock: AsyncFD): bool =
+      result = true
+      let res = recv(sock.SocketHandle, buf, size.cint,
+                     flags.toOSFlags())
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EINTR and lastError.int32 != EWOULDBLOCK and
+           lastError.int32 != EAGAIN:
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete(0)
+          else:
+            retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      else:
+        retFuture.complete(res)
+    # TODO: The following causes a massive slowdown.
+    #if not cb(socket):
+    addRead(socket, cb)
+    return retFuture
+
+  proc send*(socket: AsyncFD, buf: pointer, size: int,
+             flags = {SocketFlag.SafeDisconn}): owned(Future[void]) =
+    var retFuture = newFuture[void]("send")
+
+    var written = 0
+
+    proc cb(sock: AsyncFD): bool =
+      result = true
+      let netSize = size-written
+      var d = cast[cstring](buf)
+      let res = send(sock.SocketHandle, addr d[written], netSize.cint,
+                     MSG_NOSIGNAL)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EINTR and
+           lastError.int32 != EWOULDBLOCK and
+           lastError.int32 != EAGAIN:
+          if flags.isDisconnectionError(lastError):
+            retFuture.complete()
+          else:
+            retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      else:
+        written.inc(res)
+        if res != netSize:
+          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
+
+  proc sendTo*(socket: AsyncFD, data: pointer, size: int, saddr: ptr SockAddr,
+               saddrLen: SockLen,
+               flags = {SocketFlag.SafeDisconn}): owned(Future[void]) =
+    ## Sends `data` of size `size` in bytes to specified destination
+    ## (`saddr` of size `saddrLen` in bytes, using socket `socket`.
+    ## The returned future will complete once all data has been sent.
+    var retFuture = newFuture[void]("sendTo")
+
+    # we will preserve address in our stack
+    var staddr: array[128, char] # SOCKADDR_STORAGE size is 128 bytes
+    var stalen = saddrLen
+    zeroMem(addr(staddr[0]), 128)
+    copyMem(addr(staddr[0]), saddr, saddrLen)
+
+    proc cb(sock: AsyncFD): bool =
+      result = true
+      let res = sendto(sock.SocketHandle, data, size, MSG_NOSIGNAL,
+                       cast[ptr SockAddr](addr(staddr[0])), stalen)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EINTR and lastError.int32 != EWOULDBLOCK and
+           lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      else:
+        retFuture.complete()
+
+    addWrite(socket, cb)
+    return retFuture
+
+  proc recvFromInto*(socket: AsyncFD, data: pointer, size: int,
+                     saddr: ptr SockAddr, saddrLen: ptr SockLen,
+                     flags = {SocketFlag.SafeDisconn}): owned(Future[int]) =
+    ## Receives a datagram data from `socket` into `data`, which must
+    ## be at least of size `size` in bytes, address of datagram's sender
+    ## will be stored into `saddr` and `saddrLen`. Returned future will
+    ## complete once one datagram has been received, and will return size
+    ## of packet received.
+    var retFuture = newFuture[int]("recvFromInto")
+    proc cb(sock: AsyncFD): bool =
+      result = true
+      let res = recvfrom(sock.SocketHandle, data, size.cint, flags.toOSFlags(),
+                         saddr, saddrLen)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EINTR and lastError.int32 != EWOULDBLOCK and
+           lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false
+      else:
+        retFuture.complete(res)
+    addRead(socket, cb)
+    return retFuture
+
+  proc acceptAddr*(socket: AsyncFD, flags = {SocketFlag.SafeDisconn},
+                   inheritable = defined(nimInheritHandles)):
+      owned(Future[tuple[address: string, client: AsyncFD]]) =
+    var retFuture = newFuture[tuple[address: string,
+        client: AsyncFD]]("acceptAddr")
+    proc cb(sock: AsyncFD): bool {.gcsafe.} =
+      result = true
+      var sockAddress: Sockaddr_storage
+      var addrLen = sizeof(sockAddress).SockLen
+      var client =
+        when declared(accept4):
+          accept4(sock.SocketHandle, cast[ptr SockAddr](addr(sockAddress)),
+                  addr(addrLen), if inheritable: 0 else: SOCK_CLOEXEC)
+        else:
+          accept(sock.SocketHandle, cast[ptr SockAddr](addr(sockAddress)),
+                 addr(addrLen))
+      when declared(setInheritable) and not declared(accept4):
+        if client != osInvalidSocket and not setInheritable(client, inheritable):
+          # Set failure first because close() itself can fail,
+          # altering osLastError().
+          retFuture.fail(newOSError(osLastError()))
+          close client
+          return false
+
+      if client == osInvalidSocket:
+        let lastError = osLastError()
+        assert lastError.int32 != EWOULDBLOCK and lastError.int32 != EAGAIN
+        if lastError.int32 == EINTR:
+          return false
+        else:
+          if flags.isDisconnectionError(lastError):
+            return false
+          else:
+            retFuture.fail(newOSError(lastError))
+      else:
+        try:
+          let address = getAddrString(cast[ptr SockAddr](addr sockAddress))
+          register(client.AsyncFD)
+          retFuture.complete((address, client.AsyncFD))
+        except:
+          # getAddrString may raise
+          client.close()
+          retFuture.fail(getCurrentException())
+    addRead(socket, cb)
+    return retFuture
+
+  when ioselSupportedPlatform:
+
+    proc addTimer*(timeout: int, oneshot: bool, cb: Callback) =
+      ## Start watching for timeout expiration, and then call the
+      ## callback `cb`.
+      ## `timeout` - time in milliseconds,
+      ## `oneshot` - if `true` only one event will be dispatched,
+      ## if `false` continuous events every `timeout` milliseconds.
+      let p = getGlobalDispatcher()
+      var data = newAsyncData()
+      data.readList.add(cb)
+      p.selector.registerTimer(timeout, oneshot, data)
+
+    proc addSignal*(signal: int, cb: Callback) =
+      ## Start watching signal `signal`, and when signal appears, call the
+      ## callback `cb`.
+      let p = getGlobalDispatcher()
+      var data = newAsyncData()
+      data.readList.add(cb)
+      p.selector.registerSignal(signal, data)
+
+    proc addProcess*(pid: int, cb: Callback) =
+      ## Start watching for process exit with pid `pid`, and then call
+      ## the callback `cb`.
+      let p = getGlobalDispatcher()
+      var data = newAsyncData()
+      data.readList.add(cb)
+      p.selector.registerProcess(pid, data)
+
+  proc newAsyncEvent*(): AsyncEvent =
+    ## Creates new `AsyncEvent`.
+    result = AsyncEvent(newSelectEvent())
+
+  proc trigger*(ev: AsyncEvent) =
+    ## Sets new `AsyncEvent` to signaled state.
+    trigger(SelectEvent(ev))
+
+  proc close*(ev: AsyncEvent) =
+    ## Closes `AsyncEvent`
+    close(SelectEvent(ev))
+
+  proc addEvent*(ev: AsyncEvent, cb: Callback) =
+    ## Start watching for event `ev`, and call callback `cb`, when
+    ## ev will be set to signaled state.
+    let p = getGlobalDispatcher()
+    var data = newAsyncData()
+    data.readList.add(cb)
+    p.selector.registerEvent(SelectEvent(ev), data)
+
+proc drain*(timeout = 500) =
+  ## Waits for completion of **all** events and processes them. Raises `ValueError`
+  ## if there are no pending operations. In contrast to `poll` this
+  ## processes as many events as are available until the timeout has elapsed.
+  var curTimeout = timeout
+  let start = now()
+  while hasPendingOperations():
+    discard runOnce(curTimeout)
+    curTimeout -= (now() - start).inMilliseconds.int
+    if curTimeout < 0:
+      break
+
+proc poll*(timeout = 500) =
+  ## Waits for completion events and processes them. Raises `ValueError`
+  ## if there are no pending operations. This runs the underlying OS
+  ## `epoll`:idx: or `kqueue`:idx: primitive only once.
+  discard runOnce(timeout)
+
+template createAsyncNativeSocketImpl(domain, sockType, protocol: untyped,
+                                     inheritable = defined(nimInheritHandles)) =
+  let handle = createNativeSocket(domain, sockType, protocol, inheritable)
+  if handle == osInvalidSocket:
+    return osInvalidSocket.AsyncFD
+  handle.setBlocking(false)
+  when defined(macosx) and not defined(nimdoc):
+    handle.setSockOptInt(SOL_SOCKET, SO_NOSIGPIPE, 1)
+  result = handle.AsyncFD
+  register(result)
+
+proc createAsyncNativeSocket*(domain: cint, sockType: cint,
+                              protocol: cint,
+                              inheritable = defined(nimInheritHandles)): AsyncFD =
+  createAsyncNativeSocketImpl(domain, sockType, protocol, inheritable)
+
+proc createAsyncNativeSocket*(domain: Domain = Domain.AF_INET,
+                              sockType: SockType = SOCK_STREAM,
+                              protocol: Protocol = IPPROTO_TCP,
+                              inheritable = defined(nimInheritHandles)): AsyncFD =
+  createAsyncNativeSocketImpl(domain, sockType, protocol, inheritable)
+
+when defined(windows) or defined(nimdoc):
+  proc bindToDomain(handle: SocketHandle, domain: Domain) =
+    # Extracted into a separate proc, because connect() on Windows requires
+    # the socket to be initially bound.
+    template doBind(saddr) =
+      if bindAddr(handle, cast[ptr SockAddr](addr(saddr)),
+                  sizeof(saddr).SockLen) < 0'i32:
+        raiseOSError(osLastError())
+
+    if domain == Domain.AF_INET6:
+      var saddr: Sockaddr_in6
+      saddr.sin6_family = uint16(toInt(domain))
+      doBind(saddr)
+    else:
+      var saddr: Sockaddr_in
+      saddr.sin_family = uint16(toInt(domain))
+      doBind(saddr)
+
+  proc doConnect(socket: AsyncFD, addrInfo: ptr AddrInfo): owned(Future[void]) =
+    let retFuture = newFuture[void]("doConnect")
+    result = retFuture
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: socket, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            const SO_UPDATE_CONNECT_CONTEXT = 0x7010
+            socket.SocketHandle.setSockOptInt(SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, 1) # 15022
+            retFuture.complete()
+          else:
+            retFuture.fail(newOSError(errcode))
+    )
+
+    let ret = connectEx(socket.SocketHandle, addrInfo.ai_addr,
+                        cint(addrInfo.ai_addrlen), nil, 0, nil,
+                        cast[POVERLAPPED](ol))
+    if ret:
+      # Request to connect completed immediately.
+      retFuture.complete()
+      # We don't deallocate `ol` here because even though this completed
+      # immediately poll will still be notified about its completion and it
+      # will free `ol`.
+    else:
+      let lastError = osLastError()
+      if lastError.int32 != ERROR_IO_PENDING:
+        # With ERROR_IO_PENDING `ol` will be deallocated in `poll`,
+        # and the future will be completed/failed there, too.
+        GC_unref(ol)
+        retFuture.fail(newOSError(lastError))
+else:
+  proc doConnect(socket: AsyncFD, addrInfo: ptr AddrInfo): owned(Future[void]) =
+    let retFuture = newFuture[void]("doConnect")
+    result = retFuture
+
+    proc cb(fd: AsyncFD): bool =
+      let ret = SocketHandle(fd).getSockOptInt(
+        cint(SOL_SOCKET), cint(SO_ERROR))
+      if ret == 0:
+        # We have connected.
+        retFuture.complete()
+        return true
+      elif ret == EINTR:
+        # interrupted, keep waiting
+        return false
+      else:
+        retFuture.fail(newOSError(OSErrorCode(ret)))
+        return true
+
+    let ret = connect(socket.SocketHandle,
+                      addrInfo.ai_addr,
+                      addrInfo.ai_addrlen.SockLen)
+    if ret == 0:
+      # Request to connect completed immediately.
+      retFuture.complete()
+    else:
+      let lastError = osLastError()
+      if lastError.int32 == EINTR or lastError.int32 == EINPROGRESS:
+        addWrite(socket, cb)
+      else:
+        retFuture.fail(newOSError(lastError))
+
+template asyncAddrInfoLoop(addrInfo: ptr AddrInfo, fd: untyped,
+                           protocol: Protocol = IPPROTO_RAW) =
+  ## Iterates through the AddrInfo linked list asynchronously
+  ## until the connection can be established.
+  const shouldCreateFd = not declared(fd)
+
+  when shouldCreateFd:
+    let sockType = protocol.toSockType()
+
+    var fdPerDomain: array[low(Domain).ord..high(Domain).ord, AsyncFD]
+    for i in low(fdPerDomain)..high(fdPerDomain):
+      fdPerDomain[i] = osInvalidSocket.AsyncFD
+    template closeUnusedFds(domainToKeep = -1) {.dirty.} =
+      for i, fd in fdPerDomain:
+        if fd != osInvalidSocket.AsyncFD and i != domainToKeep:
+          fd.closeSocket()
+
+  var lastException: ref Exception
+  var curAddrInfo = addrInfo
+  var domain: Domain
+  when shouldCreateFd:
+    var curFd: AsyncFD
+  else:
+    var curFd = fd
+  proc tryNextAddrInfo(fut: Future[void]) {.gcsafe.} =
+    if fut == nil or fut.failed:
+      if fut != nil:
+        lastException = fut.readError()
+
+      while curAddrInfo != nil:
+        let domainOpt = curAddrInfo.ai_family.toKnownDomain()
+        if domainOpt.isSome:
+          domain = domainOpt.unsafeGet()
+          break
+        curAddrInfo = curAddrInfo.ai_next
+
+      if curAddrInfo == nil:
+        freeAddrInfo(addrInfo)
+        when shouldCreateFd:
+          closeUnusedFds()
+        if lastException != nil:
+          retFuture.fail(lastException)
+        else:
+          retFuture.fail(newException(
+            IOError, "Couldn't resolve address: " & address))
+        return
+
+      when shouldCreateFd:
+        curFd = fdPerDomain[ord(domain)]
+        if curFd == osInvalidSocket.AsyncFD:
+          try:
+            curFd = createAsyncNativeSocket(domain, sockType, protocol)
+          except:
+            freeAddrInfo(addrInfo)
+            closeUnusedFds()
+            raise getCurrentException()
+          when defined(windows):
+            curFd.SocketHandle.bindToDomain(domain)
+          fdPerDomain[ord(domain)] = curFd
+
+      doConnect(curFd, curAddrInfo).callback = tryNextAddrInfo
+      curAddrInfo = curAddrInfo.ai_next
+    else:
+      freeAddrInfo(addrInfo)
+      when shouldCreateFd:
+        closeUnusedFds(ord(domain))
+        retFuture.complete(curFd)
+      else:
+        retFuture.complete()
+
+  tryNextAddrInfo(nil)
+
+proc dial*(address: string, port: Port,
+           protocol: Protocol = IPPROTO_TCP): owned(Future[AsyncFD]) =
+  ## Establishes connection to the specified `address`:`port` pair via the
+  ## specified protocol. The procedure iterates through possible
+  ## resolutions of the `address` until it succeeds, meaning that it
+  ## seamlessly works with both IPv4 and IPv6.
+  ## Returns the async file descriptor, registered in the dispatcher of
+  ## the current thread, ready to send or receive data.
+  let retFuture = newFuture[AsyncFD]("dial")
+  result = retFuture
+  let sockType = protocol.toSockType()
+
+  let aiList = getAddrInfo(address, port, Domain.AF_UNSPEC, sockType, protocol)
+  asyncAddrInfoLoop(aiList, noFD, protocol)
+
+proc connect*(socket: AsyncFD, address: string, port: Port,
+              domain = Domain.AF_INET): owned(Future[void]) =
+  let retFuture = newFuture[void]("connect")
+  result = retFuture
+
+  when defined(windows):
+    verifyPresence(socket)
+  else:
+    assert getSockDomain(socket.SocketHandle) == domain
+
+  let aiList = getAddrInfo(address, port, domain)
+  when defined(windows):
+    socket.SocketHandle.bindToDomain(domain)
+  asyncAddrInfoLoop(aiList, socket)
+
+proc sleepAsync*(ms: int | float): owned(Future[void]) =
+  ## Suspends the execution of the current async procedure for the next
+  ## `ms` milliseconds.
+  var retFuture = newFuture[void]("sleepAsync")
+  let p = getGlobalDispatcher()
+  when ms is int:
+    p.timers.push((getMonoTime() + initDuration(milliseconds = ms), retFuture))
+  elif ms is float:
+    let ns = (ms * 1_000_000).int64
+    p.timers.push((getMonoTime() + initDuration(nanoseconds = ns), retFuture))
+  return retFuture
+
+proc withTimeout*[T](fut: Future[T], timeout: int): owned(Future[bool]) =
+  ## Returns a future which will complete once `fut` completes or after
+  ## `timeout` milliseconds has elapsed.
+  ##
+  ## If `fut` completes first the returned future will hold true,
+  ## otherwise, if `timeout` milliseconds has elapsed first, the returned
+  ## future will hold false.
+
+  var retFuture = newFuture[bool]("asyncdispatch.`withTimeout`")
+  var timeoutFuture = sleepAsync(timeout)
+  fut.callback =
+    proc () =
+      if not retFuture.finished:
+        if fut.failed:
+          retFuture.fail(fut.error)
+        else:
+          retFuture.complete(true)
+  timeoutFuture.callback =
+    proc () =
+      if not retFuture.finished: retFuture.complete(false)
+  return retFuture
+
+proc accept*(socket: AsyncFD,
+             flags = {SocketFlag.SafeDisconn},
+             inheritable = defined(nimInheritHandles)): owned(Future[AsyncFD]) =
+  ## Accepts a new connection. Returns a future containing the client socket
+  ## corresponding to that connection.
+  ##
+  ## If `inheritable` is false (the default), the resulting client socket
+  ## will not be inheritable by child processes.
+  ##
+  ## The future will complete when the connection is successfully accepted.
+  var retFut = newFuture[AsyncFD]("accept")
+  var fut = acceptAddr(socket, flags, inheritable)
+  fut.callback =
+    proc (future: Future[tuple[address: string, client: AsyncFD]]) =
+      assert future.finished
+      if future.failed:
+        retFut.fail(future.error)
+      else:
+        retFut.complete(future.read.client)
+  return retFut
+
+proc keepAlive(x: string) =
+  discard "mark 'x' as escaping so that it is put into a closure for us to keep the data alive"
+
+proc send*(socket: AsyncFD, data: string,
+           flags = {SocketFlag.SafeDisconn}): owned(Future[void]) =
+  ## Sends `data` to `socket`. The returned future will complete once all
+  ## data has been sent.
+  var retFuture = newFuture[void]("send")
+  if data.len > 0:
+    let sendFut = socket.send(unsafeAddr data[0], data.len, flags)
+    sendFut.callback =
+      proc () =
+        keepAlive(data)
+        if sendFut.failed:
+          retFuture.fail(sendFut.error)
+        else:
+          retFuture.complete()
+  else:
+    retFuture.complete()
+
+  return retFuture
+
+# -- Await Macro
+import std/asyncmacro
+export asyncmacro
+
+proc readAll*(future: FutureStream[string]): owned(Future[string]) {.async.} =
+  ## Returns a future that will complete when all the string data from the
+  ## specified future stream is retrieved.
+  result = ""
+  while true:
+    let (hasValue, value) = await future.read()
+    if hasValue:
+      result.add(value)
+    else:
+      break
+
+proc callSoon(cbproc: proc () {.gcsafe.}) =
+  getGlobalDispatcher().callbacks.addLast(cbproc)
+
+proc runForever*() =
+  ## Begins a never ending global dispatcher poll loop.
+  while true:
+    poll()
+
+proc waitFor*[T](fut: Future[T]): T =
+  ## **Blocks** the current thread until the specified future completes.
+  while not fut.finished:
+    poll()
+
+  fut.read
+
+proc activeDescriptors*(): int {.inline.} =
+  ## Returns the current number of active file descriptors for the current
+  ## event loop. This is a cheap operation that does not involve a system call.
+  when defined(windows):
+    result = getGlobalDispatcher().handles.len
+  elif not defined(nimdoc):
+    result = getGlobalDispatcher().selector.count
+
+when defined(posix):
+  import std/posix
+
+when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
+       defined(solaris) or defined(zephyr) or defined(freertos) or defined(nuttx) or defined(haiku):
+  proc maxDescriptors*(): int {.raises: OSError.} =
+    ## Returns the maximum number of active file descriptors for the current
+    ## process. This involves a system call. For now `maxDescriptors` is
+    ## supported on the following OSes: Windows, Linux, OSX, BSD, Solaris.
+    when defined(windows):
+      result = 16_700_000
+    elif defined(zephyr) or defined(freertos):
+      result = FD_MAX
+    else:
+      var fdLim: RLimit
+      if getrlimit(RLIMIT_NOFILE, fdLim) < 0:
+        raiseOSError(osLastError())
+      result = int(fdLim.rlim_cur) - 1
+
+when defined(genode):
+  proc scheduleCallbacks*(): bool {.discardable.} =
+    ## *Genode only.*
+    ## Schedule callback processing and return immediately.
+    ## Returns `false` if there is nothing to schedule.
+    ## RPC servers should call this to dispatch `callSoon`
+    ## bodies after retiring an RPC to its client.
+    ## This is effectively a non-blocking `poll(…)` and is
+    ## equivalent to scheduling a momentary no-op timeout
+    ## but faster and with less overhead.
+    let dis = getGlobalDispatcher()
+    result = dis.callbacks.len > 0
+    if result: submit(dis.signalHandler.cap)
diff --git a/lib/pure/asyncdispatch.nim.cfg b/lib/pure/asyncdispatch.nim.cfg
new file mode 100644
index 000000000..e88f8eec3
--- /dev/null
+++ b/lib/pure/asyncdispatch.nim.cfg
@@ -0,0 +1,3 @@
+@if nimdoc:
+  --os:linux
+@end
diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim
new file mode 100644
index 000000000..0f6504342
--- /dev/null
+++ b/lib/pure/asyncfile.nim
@@ -0,0 +1,537 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements asynchronous file reading and writing.
+##
+##   ```Nim
+##   import std/[asyncfile, asyncdispatch, os]
+##
+##   proc main() {.async.} =
+##     var file = openAsync(getTempDir() / "foobar.txt", fmReadWrite)
+##     await file.write("test")
+##     file.setFilePos(0)
+##     let data = await file.readAll()
+##     doAssert data == "test"
+##     file.close()
+##
+##   waitFor main()
+##   ```
+
+import std/[asyncdispatch, os]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+  when defined(windows) or defined(nimdoc):
+    import std/widestrs
+
+# TODO: Fix duplication introduced by PR #4683.
+
+when defined(windows) or defined(nimdoc):
+  import std/winlean
+else:
+  import std/posix
+
+type
+  AsyncFile* = ref object
+    fd: AsyncFD
+    offset: int64
+
+when defined(windows) or defined(nimdoc):
+  proc getDesiredAccess(mode: FileMode): int32 =
+    case mode
+    of fmRead:
+      result = GENERIC_READ
+    of fmWrite, fmAppend:
+      result = GENERIC_WRITE
+    of fmReadWrite, fmReadWriteExisting:
+      result = GENERIC_READ or GENERIC_WRITE
+
+  proc getCreationDisposition(mode: FileMode, filename: string): int32 =
+    case mode
+    of fmRead, fmReadWriteExisting:
+      OPEN_EXISTING
+    of fmReadWrite, fmWrite:
+      CREATE_ALWAYS
+    of fmAppend:
+      OPEN_ALWAYS
+else:
+  proc getPosixFlags(mode: FileMode): cint =
+    case mode
+    of fmRead:
+      result = O_RDONLY
+    of fmWrite:
+      result = O_WRONLY or O_CREAT or O_TRUNC
+    of fmAppend:
+      result = O_WRONLY or O_CREAT or O_APPEND
+    of fmReadWrite:
+      result = O_RDWR or O_CREAT or O_TRUNC
+    of fmReadWriteExisting:
+      result = O_RDWR
+    result = result or O_NONBLOCK
+
+proc getFileSize*(f: AsyncFile): int64 =
+  ## Retrieves the specified file's size.
+  when defined(windows) or defined(nimdoc):
+    var high: DWORD
+    let low = getFileSize(f.fd.Handle, addr high)
+    if low == INVALID_FILE_SIZE:
+      raiseOSError(osLastError())
+    result = (high shl 32) or low
+  else:
+    let curPos = lseek(f.fd.cint, 0, SEEK_CUR)
+    result = lseek(f.fd.cint, 0, SEEK_END)
+    f.offset = lseek(f.fd.cint, curPos, SEEK_SET)
+    assert(f.offset == curPos)
+
+proc newAsyncFile*(fd: AsyncFD): AsyncFile =
+  ## Creates `AsyncFile` with a previously opened file descriptor `fd`.
+  new result
+  result.fd = fd
+  register(fd)
+
+proc openAsync*(filename: string, mode = fmRead): AsyncFile =
+  ## Opens a file specified by the path in `filename` using
+  ## the specified FileMode `mode` asynchronously.
+  when defined(windows) or defined(nimdoc):
+    let flags = FILE_FLAG_OVERLAPPED or FILE_ATTRIBUTE_NORMAL
+    let desiredAccess = getDesiredAccess(mode)
+    let creationDisposition = getCreationDisposition(mode, filename)
+    let fd = createFileW(newWideCString(filename), desiredAccess,
+        FILE_SHARE_READ,
+        nil, creationDisposition, flags, 0)
+
+    if fd == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+
+    result = newAsyncFile(fd.AsyncFD)
+
+    if mode == fmAppend:
+      result.offset = getFileSize(result)
+
+  else:
+    let flags = getPosixFlags(mode)
+    # RW (Owner), RW (Group), R (Other)
+    let perm = S_IRUSR or S_IWUSR or S_IRGRP or S_IWGRP or S_IROTH
+    let fd = open(filename, flags, perm)
+    if fd == -1:
+      raiseOSError(osLastError())
+
+    result = newAsyncFile(fd.AsyncFD)
+
+proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] =
+  ## Read `size` bytes from the specified file asynchronously starting at
+  ## the current position of the file pointer.
+  ##
+  ## If the file pointer is past the end of the file then zero is returned
+  ## and no bytes are read into `buf`
+  var retFuture = newFuture[int]("asyncfile.readBuffer")
+
+  when defined(windows) or defined(nimdoc):
+    var ol = newCustom()
+    ol.data = CompletionData(fd: f.fd, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            assert bytesCount > 0
+            assert bytesCount <= size
+            f.offset.inc bytesCount
+            retFuture.complete(bytesCount)
+          else:
+            if errcode.int32 == ERROR_HANDLE_EOF:
+              retFuture.complete(0)
+            else:
+              retFuture.fail(newOSError(errcode))
+    )
+    ol.offset = DWORD(f.offset and 0xffffffff)
+    ol.offsetHigh = DWORD(f.offset shr 32)
+
+    # According to MSDN we're supposed to pass nil to lpNumberOfBytesRead.
+    let ret = readFile(f.fd.Handle, buf, size.int32, nil,
+                       cast[POVERLAPPED](ol))
+    if not ret.bool:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        GC_unref(ol)
+        if err.int32 == ERROR_HANDLE_EOF:
+          # This happens in Windows Server 2003
+          retFuture.complete(0)
+        else:
+          retFuture.fail(newOSError(err))
+    else:
+      # Request completed immediately.
+      var bytesRead: DWORD
+      let overlappedRes = getOverlappedResult(f.fd.Handle,
+          cast[POVERLAPPED](ol), bytesRead, false.WINBOOL)
+      if not overlappedRes.bool:
+        let err = osLastError()
+        if err.int32 == ERROR_HANDLE_EOF:
+          retFuture.complete(0)
+        else:
+          retFuture.fail(newOSError(osLastError()))
+      else:
+        assert bytesRead > 0
+        assert bytesRead <= size
+        f.offset.inc bytesRead
+        retFuture.complete(bytesRead)
+  else:
+    proc cb(fd: AsyncFD): bool =
+      result = true
+      let res = read(fd.cint, cast[cstring](buf), size.cint)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      elif res == 0:
+        # EOF
+        retFuture.complete(0)
+      else:
+        f.offset.inc(res)
+        retFuture.complete(res)
+
+    if not cb(f.fd):
+      addRead(f.fd, cb)
+
+  return retFuture
+
+proc read*(f: AsyncFile, size: int): Future[string] =
+  ## Read `size` bytes from the specified file asynchronously starting at
+  ## the current position of the file pointer. `size` should be greater than zero.
+  ##
+  ## If the file pointer is past the end of the file then an empty string is
+  ## returned.
+  assert size > 0
+  var retFuture = newFuture[string]("asyncfile.read")
+
+  when defined(windows) or defined(nimdoc):
+    var buffer = alloc0(size)
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: f.fd, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            assert bytesCount > 0
+            assert bytesCount <= size
+            var data = newString(bytesCount)
+            copyMem(addr data[0], buffer, bytesCount)
+            f.offset.inc bytesCount
+            retFuture.complete($data)
+          else:
+            if errcode.int32 == ERROR_HANDLE_EOF:
+              retFuture.complete("")
+            else:
+              retFuture.fail(newOSError(errcode))
+        if buffer != nil:
+          dealloc buffer
+          buffer = nil
+    )
+    ol.offset = DWORD(f.offset and 0xffffffff)
+    ol.offsetHigh = DWORD(f.offset shr 32)
+
+    # According to MSDN we're supposed to pass nil to lpNumberOfBytesRead.
+    let ret = readFile(f.fd.Handle, buffer, size.int32, nil,
+                       cast[POVERLAPPED](ol))
+    if not ret.bool:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        if buffer != nil:
+          dealloc buffer
+          buffer = nil
+        GC_unref(ol)
+
+        if err.int32 == ERROR_HANDLE_EOF:
+          # This happens in Windows Server 2003
+          retFuture.complete("")
+        else:
+          retFuture.fail(newOSError(err))
+    else:
+      # Request completed immediately.
+      var bytesRead: DWORD
+      let overlappedRes = getOverlappedResult(f.fd.Handle,
+          cast[POVERLAPPED](ol), bytesRead, false.WINBOOL)
+      if not overlappedRes.bool:
+        let err = osLastError()
+        if err.int32 == ERROR_HANDLE_EOF:
+          retFuture.complete("")
+        else:
+          retFuture.fail(newOSError(osLastError()))
+      else:
+        assert bytesRead > 0
+        assert bytesRead <= size
+        var data = newString(bytesRead)
+        copyMem(addr data[0], buffer, bytesRead)
+        f.offset.inc bytesRead
+        retFuture.complete($data)
+  else:
+    var readBuffer = newString(size)
+
+    proc cb(fd: AsyncFD): bool =
+      result = true
+      let res = read(fd.cint, addr readBuffer[0], size.cint)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      elif res == 0:
+        # EOF
+        f.offset = lseek(fd.cint, 0, SEEK_CUR)
+        retFuture.complete("")
+      else:
+        readBuffer.setLen(res)
+        f.offset.inc(res)
+        retFuture.complete(readBuffer)
+
+    if not cb(f.fd):
+      addRead(f.fd, cb)
+
+  return retFuture
+
+proc readLine*(f: AsyncFile): Future[string] {.async.} =
+  ## Reads a single line from the specified file asynchronously.
+  result = ""
+  while true:
+    var c = await read(f, 1)
+    if c.len == 0:
+      break
+    if c[0] == '\c':
+      c = await read(f, 1)
+      break
+    if c[0] == '\L' or c == "":
+      break
+    else:
+      result.add(c)
+
+proc getFilePos*(f: AsyncFile): int64 =
+  ## Retrieves the current position of the file pointer that is
+  ## used to read from the specified file. The file's first byte has the
+  ## index zero.
+  f.offset
+
+proc setFilePos*(f: AsyncFile, pos: int64) =
+  ## Sets the position of the file pointer that is used for read/write
+  ## operations. The file's first byte has the index zero.
+  f.offset = pos
+  when not defined(windows) and not defined(nimdoc):
+    let ret = lseek(f.fd.cint, pos.Off, SEEK_SET)
+    if ret == -1:
+      raiseOSError(osLastError())
+
+proc readAll*(f: AsyncFile): Future[string] {.async.} =
+  ## Reads all data from the specified file.
+  result = ""
+  while true:
+    let data = await read(f, 4000)
+    if data.len == 0:
+      return
+    result.add data
+
+proc writeBuffer*(f: AsyncFile, buf: pointer, size: int): Future[void] =
+  ## Writes `size` bytes from `buf` to the file specified asynchronously.
+  ##
+  ## The returned Future will complete once all data has been written to the
+  ## specified file.
+  var retFuture = newFuture[void]("asyncfile.writeBuffer")
+  when defined(windows) or defined(nimdoc):
+    var ol = newCustom()
+    ol.data = CompletionData(fd: f.fd, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            assert bytesCount == size.int32
+            retFuture.complete()
+          else:
+            retFuture.fail(newOSError(errcode))
+    )
+    # passing -1 here should work according to MSDN, but doesn't. For more
+    # information see
+    # http://stackoverflow.com/questions/33650899/does-asynchronous-file-
+    #   appending-in-windows-preserve-order
+    ol.offset = DWORD(f.offset and 0xffffffff)
+    ol.offsetHigh = DWORD(f.offset shr 32)
+    f.offset.inc(size)
+
+    # According to MSDN we're supposed to pass nil to lpNumberOfBytesWritten.
+    let ret = writeFile(f.fd.Handle, buf, size.int32, nil,
+                       cast[POVERLAPPED](ol))
+    if not ret.bool:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        GC_unref(ol)
+        retFuture.fail(newOSError(err))
+    else:
+      # Request completed immediately.
+      var bytesWritten: DWORD
+      let overlappedRes = getOverlappedResult(f.fd.Handle,
+          cast[POVERLAPPED](ol), bytesWritten, false.WINBOOL)
+      if not overlappedRes.bool:
+        retFuture.fail(newOSError(osLastError()))
+      else:
+        assert bytesWritten == size.int32
+        retFuture.complete()
+  else:
+    var written = 0
+
+    proc cb(fd: AsyncFD): bool =
+      result = true
+      let remainderSize = size - written
+      var cbuf = cast[cstring](buf)
+      let res = write(fd.cint, addr cbuf[written], remainderSize.cint)
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      else:
+        written.inc res
+        f.offset.inc res
+        if res != remainderSize:
+          result = false # We still have data to write.
+        else:
+          retFuture.complete()
+
+    if not cb(f.fd):
+      addWrite(f.fd, cb)
+  return retFuture
+
+proc write*(f: AsyncFile, data: string): Future[void] =
+  ## Writes `data` to the file specified asynchronously.
+  ##
+  ## The returned Future will complete once all data has been written to the
+  ## specified file.
+  var retFuture = newFuture[void]("asyncfile.write")
+  var copy = data
+  when defined(windows) or defined(nimdoc):
+    var buffer = alloc0(data.len)
+    copyMem(buffer, copy.cstring, data.len)
+
+    var ol = newCustom()
+    ol.data = CompletionData(fd: f.fd, cb:
+      proc (fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
+        if not retFuture.finished:
+          if errcode == OSErrorCode(-1):
+            assert bytesCount == data.len.int32
+            retFuture.complete()
+          else:
+            retFuture.fail(newOSError(errcode))
+        if buffer != nil:
+          dealloc buffer
+          buffer = nil
+    )
+    ol.offset = DWORD(f.offset and 0xffffffff)
+    ol.offsetHigh = DWORD(f.offset shr 32)
+    f.offset.inc(data.len)
+
+    # According to MSDN we're supposed to pass nil to lpNumberOfBytesWritten.
+    let ret = writeFile(f.fd.Handle, buffer, data.len.int32, nil,
+                       cast[POVERLAPPED](ol))
+    if not ret.bool:
+      let err = osLastError()
+      if err.int32 != ERROR_IO_PENDING:
+        if buffer != nil:
+          dealloc buffer
+          buffer = nil
+        GC_unref(ol)
+        retFuture.fail(newOSError(err))
+    else:
+      # Request completed immediately.
+      var bytesWritten: DWORD
+      let overlappedRes = getOverlappedResult(f.fd.Handle,
+          cast[POVERLAPPED](ol), bytesWritten, false.WINBOOL)
+      if not overlappedRes.bool:
+        retFuture.fail(newOSError(osLastError()))
+      else:
+        assert bytesWritten == data.len.int32
+        retFuture.complete()
+  else:
+    var written = 0
+
+    proc cb(fd: AsyncFD): bool =
+      result = true
+
+      let remainderSize = data.len - written
+
+      let res =
+        if data.len == 0:
+          write(fd.cint, copy.cstring, 0)
+        else:
+          write(fd.cint, addr copy[written], remainderSize.cint)
+
+      if res < 0:
+        let lastError = osLastError()
+        if lastError.int32 != EAGAIN:
+          retFuture.fail(newOSError(lastError))
+        else:
+          result = false # We still want this callback to be called.
+      else:
+        written.inc res
+        f.offset.inc res
+        if res != remainderSize:
+          result = false # We still have data to write.
+        else:
+          retFuture.complete()
+
+    if not cb(f.fd):
+      addWrite(f.fd, cb)
+  return retFuture
+
+proc setFileSize*(f: AsyncFile, length: int64) =
+  ## Set a file length.
+  when defined(windows) or defined(nimdoc):
+    var
+      high = (length shr 32).DWORD
+    let
+      low = (length and 0xffffffff).DWORD
+      status = setFilePointer(f.fd.Handle, low, addr high, 0)
+      lastErr = osLastError()
+    if (status == INVALID_SET_FILE_POINTER and lastErr.int32 != NO_ERROR) or
+        (setEndOfFile(f.fd.Handle) == 0):
+      raiseOSError(osLastError())
+  else:
+    # will truncate if Off is a 32-bit type!
+    if ftruncate(f.fd.cint, length.Off) == -1:
+      raiseOSError(osLastError())
+
+proc close*(f: AsyncFile) =
+  ## Closes the file specified.
+  unregister(f.fd)
+  when defined(windows) or defined(nimdoc):
+    if not closeHandle(f.fd.Handle).bool:
+      raiseOSError(osLastError())
+  else:
+    if close(f.fd.cint) == -1:
+      raiseOSError(osLastError())
+
+proc writeFromStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
+  ## Reads data from the specified future stream until it is completed.
+  ## The data which is read is written to the file immediately and
+  ## freed from memory.
+  ##
+  ## This procedure is perfect for saving streamed data to a file without
+  ## wasting memory.
+  while true:
+    let (hasValue, value) = await fs.read()
+    if hasValue:
+      await f.write(value)
+    else:
+      break
+
+proc readToStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
+  ## Writes data to the specified future stream as the file is read.
+  while true:
+    let data = await read(f, 4000)
+    if data.len == 0:
+      break
+    await fs.write(data)
+
+  fs.complete()
diff --git a/lib/pure/asyncfutures.nim b/lib/pure/asyncfutures.nim
new file mode 100644
index 000000000..29ebf8f89
--- /dev/null
+++ b/lib/pure/asyncfutures.nim
@@ -0,0 +1,527 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+import std/[os, tables, strutils, times, heapqueue, options, deques, cstrutils, typetraits]
+
+import system/stacktraces
+
+when defined(nimPreviewSlimSystem):
+  import std/objectdollar # for StackTraceEntry
+  import std/assertions
+
+# TODO: This shouldn't need to be included, but should ideally be exported.
+type
+  CallbackFunc = proc () {.closure, gcsafe.}
+
+  CallbackList = object
+    function: CallbackFunc
+    next: owned(ref CallbackList)
+
+  FutureBase* = ref object of RootObj  ## Untyped future.
+    callbacks: CallbackList
+
+    finished: bool
+    error*: ref Exception              ## Stored exception
+    errorStackTrace*: string
+    when not defined(release) or defined(futureLogging):
+      stackTrace: seq[StackTraceEntry] ## For debugging purposes only.
+      id: int
+      fromProc: string
+
+  Future*[T] = ref object of FutureBase ## Typed future.
+    value: T                            ## Stored value
+
+  FutureVar*[T] = distinct Future[T]
+
+  FutureError* = object of Defect
+    cause*: FutureBase
+
+when not defined(release):
+  var currentID = 0
+
+const isFutureLoggingEnabled* = defined(futureLogging)
+
+const
+  NimAsyncContinueSuffix* = "NimAsyncContinue" ## For internal usage. Do not use.
+
+when isFutureLoggingEnabled:
+  import std/hashes
+  type
+    FutureInfo* = object
+      stackTrace*: seq[StackTraceEntry]
+      fromProc*: string
+
+  var futuresInProgress {.threadvar.}: Table[FutureInfo, int]
+
+  proc getFuturesInProgress*(): var Table[FutureInfo, int] =
+    return futuresInProgress
+
+  proc hash(s: StackTraceEntry): Hash =
+    result = hash(s.procname) !& hash(s.line) !&
+      hash(s.filename)
+    result = !$result
+
+  proc hash(fi: FutureInfo): Hash =
+    result = hash(fi.stackTrace) !& hash(fi.fromProc)
+    result = !$result
+
+  proc getFutureInfo(fut: FutureBase): FutureInfo =
+    let info = FutureInfo(
+      stackTrace: fut.stackTrace,
+      fromProc: fut.fromProc
+    )
+    return info
+
+  proc logFutureStart(fut: FutureBase) =
+    let info = getFutureInfo(fut)
+    if info notin getFuturesInProgress():
+      getFuturesInProgress()[info] = 0
+    getFuturesInProgress()[info].inc()
+
+  proc logFutureFinish(fut: FutureBase) =
+    getFuturesInProgress()[getFutureInfo(fut)].dec()
+
+var callSoonProc {.threadvar.}: proc (cbproc: proc ()) {.gcsafe.}
+
+proc getCallSoonProc*(): (proc(cbproc: proc ()) {.gcsafe.}) =
+  ## Get current implementation of `callSoon`.
+  return callSoonProc
+
+proc setCallSoonProc*(p: (proc(cbproc: proc ()) {.gcsafe.})) =
+  ## Change current implementation of `callSoon`. This is normally called when dispatcher from `asyncdispatcher` is initialized.
+  callSoonProc = p
+
+proc callSoon*(cbproc: proc () {.gcsafe.}) =
+  ## Call `cbproc` "soon".
+  ##
+  ## If async dispatcher is running, `cbproc` will be executed during next dispatcher tick.
+  ##
+  ## If async dispatcher is not running, `cbproc` will be executed immediately.
+  if callSoonProc.isNil:
+    # Loop not initialized yet. Call the function directly to allow setup code to use futures.
+    cbproc()
+  else:
+    callSoonProc(cbproc)
+
+template setupFutureBase(fromProc: string) =
+  new(result)
+  result.finished = false
+  when not defined(release):
+    result.stackTrace = getStackTraceEntries()
+    result.id = currentID
+    result.fromProc = fromProc
+    currentID.inc()
+
+proc newFuture*[T](fromProc: string = "unspecified"): owned(Future[T]) =
+  ## Creates a new future.
+  ##
+  ## Specifying `fromProc`, which is a string specifying the name of the proc
+  ## that this future belongs to, is a good habit as it helps with debugging.
+  setupFutureBase(fromProc)
+  when isFutureLoggingEnabled: logFutureStart(result)
+
+proc newFutureVar*[T](fromProc = "unspecified"): owned(FutureVar[T]) =
+  ## Create a new `FutureVar`. This Future type is ideally suited for
+  ## situations where you want to avoid unnecessary allocations of Futures.
+  ##
+  ## Specifying `fromProc`, which is a string specifying the name of the proc
+  ## that this future belongs to, is a good habit as it helps with debugging.
+  let fo = newFuture[T](fromProc)
+  result = typeof(result)(fo)
+  when isFutureLoggingEnabled: logFutureStart(Future[T](result))
+
+proc clean*[T](future: FutureVar[T]) =
+  ## Resets the `finished` status of `future`.
+  Future[T](future).finished = false
+  Future[T](future).error = nil
+
+proc checkFinished[T](future: Future[T]) =
+  ## Checks whether `future` is finished. If it is then raises a
+  ## `FutureError`.
+  when not defined(release):
+    if future.finished:
+      var msg = ""
+      msg.add("An attempt was made to complete a Future more than once. ")
+      msg.add("Details:")
+      msg.add("\n  Future ID: " & $future.id)
+      msg.add("\n  Created in proc: " & future.fromProc)
+      msg.add("\n  Stack trace to moment of creation:")
+      msg.add("\n" & indent(($future.stackTrace).strip(), 4))
+      when T is string:
+        msg.add("\n  Contents (string): ")
+        msg.add("\n" & indent($future.value, 4))
+      msg.add("\n  Stack trace to moment of secondary completion:")
+      msg.add("\n" & indent(getStackTrace().strip(), 4))
+      var err = newException(FutureError, msg)
+      err.cause = future
+      raise err
+
+proc call(callbacks: var CallbackList) =
+  var current = callbacks
+  while true:
+    if not current.function.isNil:
+      callSoon(current.function)
+
+    if current.next.isNil:
+      break
+    else:
+      current = current.next[]
+  # callback will be called only once, let GC collect them now
+  callbacks.next = nil
+  callbacks.function = nil
+
+proc add(callbacks: var CallbackList, function: CallbackFunc) =
+  if callbacks.function.isNil:
+    callbacks.function = function
+    assert callbacks.next == nil
+  else:
+    let newCallback = new(ref CallbackList)
+    newCallback.function = function
+    newCallback.next = nil
+
+    if callbacks.next == nil:
+      callbacks.next = newCallback
+    else:
+      var last = callbacks.next
+      while last.next != nil:
+        last = last.next
+      last.next = newCallback
+
+proc completeImpl[T, U](future: Future[T], val: sink U, isVoid: static bool) =
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
+  assert(future.error == nil)
+  when not isVoid:
+    future.value = val
+  future.finished = true
+  future.callbacks.call()
+  when isFutureLoggingEnabled: logFutureFinish(future)
+
+proc complete*[T](future: Future[T], val: sink T) =
+  ## Completes `future` with value `val`.
+  completeImpl(future, val, false)
+
+proc complete*(future: Future[void], val = Future[void].default) =
+  completeImpl(future, (), true)
+
+proc complete*[T](future: FutureVar[T]) =
+  ## Completes a `FutureVar`.
+  template fut: untyped = Future[T](future)
+  checkFinished(fut)
+  assert(fut.error == nil)
+  fut.finished = true
+  fut.callbacks.call()
+  when isFutureLoggingEnabled: logFutureFinish(Future[T](future))
+
+proc complete*[T](future: FutureVar[T], val: sink T) =
+  ## Completes a `FutureVar` with value `val`.
+  ##
+  ## Any previously stored value will be overwritten.
+  template fut: untyped = Future[T](future)
+  checkFinished(fut)
+  assert(fut.error.isNil())
+  fut.finished = true
+  fut.value = val
+  fut.callbacks.call()
+  when isFutureLoggingEnabled: logFutureFinish(fut)
+
+proc fail*[T](future: Future[T], error: ref Exception) =
+  ## Completes `future` with `error`.
+  #assert(not future.finished, "Future already finished, cannot finish twice.")
+  checkFinished(future)
+  future.finished = true
+  future.error = error
+  future.errorStackTrace =
+    if getStackTrace(error) == "": getStackTrace() else: getStackTrace(error)
+  future.callbacks.call()
+  when isFutureLoggingEnabled: logFutureFinish(future)
+
+proc clearCallbacks*(future: FutureBase) =
+  future.callbacks.function = nil
+  future.callbacks.next = nil
+
+proc addCallback*(future: FutureBase, cb: proc() {.closure, gcsafe.}) =
+  ## Adds the callbacks proc to be called when the future completes.
+  ##
+  ## If future has already completed then `cb` will be called immediately.
+  assert cb != nil
+  if future.finished:
+    callSoon(cb)
+  else:
+    future.callbacks.add cb
+
+proc addCallback*[T](future: Future[T],
+                     cb: proc (future: Future[T]) {.closure, gcsafe.}) =
+  ## Adds the callbacks proc to be called when the future completes.
+  ##
+  ## If future has already completed then `cb` will be called immediately.
+  future.addCallback(
+    proc() =
+    cb(future)
+  )
+
+proc `callback=`*(future: FutureBase, cb: proc () {.closure, gcsafe.}) =
+  ## Clears the list of callbacks and sets the callback proc to be called when the future completes.
+  ##
+  ## If future has already completed then `cb` will be called immediately.
+  ##
+  ## It's recommended to use `addCallback` or `then` instead.
+  future.clearCallbacks
+  future.addCallback cb
+
+proc `callback=`*[T](future: Future[T],
+    cb: proc (future: Future[T]) {.closure, gcsafe.}) =
+  ## Sets the callback proc to be called when the future completes.
+  ##
+  ## If future has already completed then `cb` will be called immediately.
+  future.callback = proc () = cb(future)
+
+template getFilenameProcname(entry: StackTraceEntry): (string, string) =
+  when compiles(entry.filenameStr) and compiles(entry.procnameStr):
+    # We can't rely on "entry.filename" and "entry.procname" still being valid
+    # cstring pointers, because the "string.data" buffers they pointed to might
+    # be already garbage collected (this entry being a non-shallow copy,
+    # "entry.filename" no longer points to "entry.filenameStr.data", but to the
+    # buffer of the original object).
+    (entry.filenameStr, entry.procnameStr)
+  else:
+    ($entry.filename, $entry.procname)
+
+proc getHint(entry: StackTraceEntry): string =
+  ## We try to provide some hints about stack trace entries that the user
+  ## may not be familiar with, in particular calls inside the stdlib.
+
+  let (filename, procname) = getFilenameProcname(entry)
+
+  result = ""
+  if procname == "processPendingCallbacks":
+    if cmpIgnoreStyle(filename, "asyncdispatch.nim") == 0:
+      return "Executes pending callbacks"
+  elif procname == "poll":
+    if cmpIgnoreStyle(filename, "asyncdispatch.nim") == 0:
+      return "Processes asynchronous completion events"
+
+  if procname.endsWith(NimAsyncContinueSuffix):
+    if cmpIgnoreStyle(filename, "asyncmacro.nim") == 0:
+      return "Resumes an async procedure"
+
+proc `$`*(stackTraceEntries: seq[StackTraceEntry]): string =
+  when defined(nimStackTraceOverride):
+    let entries = addDebuggingInfo(stackTraceEntries)
+  else:
+    let entries = stackTraceEntries
+
+  result = ""
+  # Find longest filename & line number combo for alignment purposes.
+  var longestLeft = 0
+  for entry in entries:
+    let (filename, procname) = getFilenameProcname(entry)
+
+    if procname == "": continue
+
+    let leftLen = filename.len + len($entry.line)
+    if leftLen > longestLeft:
+      longestLeft = leftLen
+
+  # Format the entries.
+  for entry in entries:
+    let (filename, procname) = getFilenameProcname(entry)
+
+    if procname == "" and entry.line == reraisedFromBegin:
+      break
+
+    let left = "$#($#)" % [filename, $entry.line]
+    result.add((spaces(2) & "$# $#\n") % [
+      left,
+      procname
+    ])
+    let hint = getHint(entry)
+    if hint.len > 0:
+      result.add(spaces(4) & "## " & hint & "\n")
+
+proc injectStacktrace[T](future: Future[T]) =
+  when not defined(release):
+    const header = "\nAsync traceback:\n"
+
+    var exceptionMsg = future.error.msg
+    if header in exceptionMsg:
+      # This is messy: extract the original exception message from the msg
+      # containing the async traceback.
+      let start = exceptionMsg.find(header)
+      exceptionMsg = exceptionMsg[0..<start]
+
+
+    var newMsg = exceptionMsg & header
+
+    let entries = getStackTraceEntries(future.error)
+    newMsg.add($entries)
+
+    newMsg.add("Exception message: " & exceptionMsg & "\n")
+
+    # # For debugging purposes
+    # newMsg.add("Exception type:")
+    # for entry in getStackTraceEntries(future.error):
+    #   newMsg.add "\n" & $entry
+    future.error.msg = newMsg
+
+template readImpl(future, T) =
+  when future is Future[T]:
+    let fut {.cursor.} = future
+  else:
+    let fut {.cursor.} = Future[T](future)
+  if fut.finished:
+    if fut.error != nil:
+      injectStacktrace(fut)
+      raise fut.error
+    when T isnot void:
+      result = distinctBase(future).value
+  else:
+    # TODO: Make a custom exception type for this?
+    raise newException(ValueError, "Future still in progress.")
+
+proc read*[T](future: Future[T] | FutureVar[T]): lent T =
+  ## Retrieves the value of `future`. Future must be finished otherwise
+  ## this function will fail with a `ValueError` exception.
+  ##
+  ## If the result of the future is an error then that error will be raised.
+  readImpl(future, T)
+
+proc read*(future: Future[void] | FutureVar[void]) =
+  readImpl(future, void)
+
+proc readError*[T](future: Future[T]): ref Exception =
+  ## Retrieves the exception stored in `future`.
+  ##
+  ## An `ValueError` exception will be thrown if no exception exists
+  ## in the specified Future.
+  if future.error != nil: return future.error
+  else:
+    raise newException(ValueError, "No error in future.")
+
+proc mget*[T](future: FutureVar[T]): var T =
+  ## Returns a mutable value stored in `future`.
+  ##
+  ## Unlike `read`, this function will not raise an exception if the
+  ## Future has not been finished.
+  result = Future[T](future).value
+
+proc finished*(future: FutureBase | FutureVar): bool =
+  ## Determines whether `future` has completed.
+  ##
+  ## `True` may indicate an error or a value. Use `failed` to distinguish.
+  when future is FutureVar:
+    result = (FutureBase(future)).finished
+  else:
+    result = future.finished
+
+proc failed*(future: FutureBase): bool =
+  ## Determines whether `future` completed with an error.
+  return future.error != nil
+
+proc asyncCheck*[T](future: Future[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,
+  ## or use `waitFor` if you need to wait for the future's completion.
+  assert(not future.isNil, "Future is nil")
+  # TODO: We can likely look at the stack trace here and inject the location
+  # where the `asyncCheck` was called to give a better error stack message.
+  proc asyncCheckCallback() =
+    if future.failed:
+      injectStacktrace(future)
+      raise future.error
+  future.callback = asyncCheckCallback
+
+proc `and`*[T, Y](fut1: Future[T], fut2: Future[Y]): Future[void] =
+  ## Returns a future which will complete once both `fut1` and `fut2`
+  ## complete.
+  var retFuture = newFuture[void]("asyncdispatch.`and`")
+  fut1.callback =
+    proc () =
+      if not retFuture.finished:
+        if fut1.failed: retFuture.fail(fut1.error)
+        elif fut2.finished: retFuture.complete()
+  fut2.callback =
+    proc () =
+      if not retFuture.finished:
+        if fut2.failed: retFuture.fail(fut2.error)
+        elif fut1.finished: retFuture.complete()
+  return retFuture
+
+proc `or`*[T, Y](fut1: Future[T], fut2: Future[Y]): Future[void] =
+  ## Returns a future which will complete once either `fut1` or `fut2`
+  ## complete.
+  var retFuture = newFuture[void]("asyncdispatch.`or`")
+  proc cb[X](fut: Future[X]) =
+    if not retFuture.finished:
+      if fut.failed: retFuture.fail(fut.error)
+      else: retFuture.complete()
+  fut1.callback = cb[T]
+  fut2.callback = cb[Y]
+  return retFuture
+
+proc all*[T](futs: varargs[Future[T]]): auto =
+  ## Returns a future which will complete once
+  ## all futures in `futs` complete.
+  ## If the argument is empty, the returned future completes immediately.
+  ##
+  ## If the awaited futures are not `Future[void]`, the returned future
+  ## will hold the values of all awaited futures in a sequence.
+  ##
+  ## If the awaited futures *are* `Future[void]`,
+  ## this proc returns `Future[void]`.
+
+  when T is void:
+    var
+      retFuture = newFuture[void]("asyncdispatch.all")
+      completedFutures = 0
+
+    let totalFutures = len(futs)
+
+    for fut in futs:
+      fut.addCallback proc (f: Future[T]) =
+        inc(completedFutures)
+        if not retFuture.finished:
+          if f.failed:
+            retFuture.fail(f.error)
+          else:
+            if completedFutures == totalFutures:
+              retFuture.complete()
+
+    if totalFutures == 0:
+      retFuture.complete()
+
+    return retFuture
+
+  else:
+    var
+      retFuture = newFuture[seq[T]]("asyncdispatch.all")
+      retValues = newSeq[T](len(futs))
+      completedFutures = 0
+
+    for i, fut in futs:
+      proc setCallback(i: int) =
+        fut.addCallback proc (f: Future[T]) =
+          inc(completedFutures)
+          if not retFuture.finished:
+            if f.failed:
+              retFuture.fail(f.error)
+            else:
+              retValues[i] = f.read()
+
+              if completedFutures == len(retValues):
+                retFuture.complete(retValues)
+
+      setCallback(i)
+
+    if retValues.len == 0:
+      retFuture.complete(retValues)
+
+    return retFuture
diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim
new file mode 100644
index 000000000..39e945d5e
--- /dev/null
+++ b/lib/pure/asynchttpserver.nim
@@ -0,0 +1,440 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a high performance asynchronous HTTP server.
+##
+## This HTTP server has not been designed to be used in production, but
+## for testing applications locally. Because of this, when deploying your
+## application in production you should use a reverse proxy (for example nginx)
+## instead of allowing users to connect directly to this server.
+
+runnableExamples("-r:off"):
+  # This example will create an HTTP server on an automatically chosen port.
+  # It will respond to all requests with a `200 OK` response code and "Hello World"
+  # as the response body.
+  import std/asyncdispatch
+  proc main {.async.} =
+    var server = newAsyncHttpServer()
+    proc cb(req: Request) {.async.} =
+      echo (req.reqMethod, req.url, req.headers)
+      let headers = {"Content-type": "text/plain; charset=utf-8"}
+      await req.respond(Http200, "Hello World", headers.newHttpHeaders())
+
+    server.listen(Port(0)) # or Port(8080) to hardcode the standard HTTP port.
+    let port = server.getPort
+    echo "test this with: curl localhost:" & $port.uint16 & "/"
+    while true:
+      if server.shouldAcceptRequest():
+        await server.acceptRequest(cb)
+      else:
+        # too many concurrent connections, `maxFDs` exceeded
+        # wait 500ms for FDs to be closed
+        await sleepAsync(500)
+
+  waitFor main()
+
+import std/[asyncnet, asyncdispatch, parseutils, uri, strutils]
+import std/httpcore
+from std/nativesockets import getLocalAddr, Domain, AF_INET, AF_INET6
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+export httpcore except parseHeader
+
+const
+  maxLine = 8*1024
+
+# TODO: If it turns out that the decisions that asynchttpserver makes
+# explicitly, about whether to close the client sockets or upgrade them are
+# wrong, then add a return value which determines what to do for the callback.
+# Also, maybe move `client` out of `Request` object and into the args for
+# the proc.
+type
+  Request* = object
+    client*: AsyncSocket # TODO: Separate this into a Response object?
+    reqMethod*: HttpMethod
+    headers*: HttpHeaders
+    protocol*: tuple[orig: string, major, minor: int]
+    url*: Uri
+    hostname*: string    ## The hostname of the client that made the request.
+    body*: string
+
+  AsyncHttpServer* = ref object
+    socket: AsyncSocket
+    reuseAddr: bool
+    reusePort: bool
+    maxBody: int ## The maximum content-length that will be read for the body.
+    maxFDs: int
+
+proc getPort*(self: AsyncHttpServer): Port {.since: (1, 5, 1).} =
+  ## Returns the port `self` was bound to.
+  ##
+  ## Useful for identifying what port `self` is bound to, if it
+  ## was chosen automatically, for example via `listen(Port(0))`.
+  runnableExamples:
+    from std/nativesockets import Port
+    let server = newAsyncHttpServer()
+    server.listen(Port(0))
+    assert server.getPort.uint16 > 0
+    server.close()
+  result = getLocalAddr(self.socket)[1]
+
+proc newAsyncHttpServer*(reuseAddr = true, reusePort = false,
+                         maxBody = 8388608): AsyncHttpServer =
+  ## Creates a new `AsyncHttpServer` instance.
+  result = AsyncHttpServer(reuseAddr: reuseAddr, reusePort: reusePort, maxBody: maxBody)
+
+proc addHeaders(msg: var string, headers: HttpHeaders) =
+  for k, v in headers:
+    msg.add(k & ": " & v & "\c\L")
+
+proc sendHeaders*(req: Request, headers: HttpHeaders): Future[void] =
+  ## Sends the specified headers to the requesting client.
+  var msg = ""
+  addHeaders(msg, headers)
+  return req.client.send(msg)
+
+proc respond*(req: Request, code: HttpCode, content: string,
+              headers: HttpHeaders = nil): Future[void] =
+  ## Responds to the request with the specified `HttpCode`, headers and
+  ## content.
+  ##
+  ## This procedure will **not** close the client socket.
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   import std/json
+  ##   proc handler(req: Request) {.async.} =
+  ##     if req.url.path == "/hello-world":
+  ##       let msg = %* {"message": "Hello World"}
+  ##       let headers = newHttpHeaders([("Content-Type","application/json")])
+  ##       await req.respond(Http200, $msg, headers)
+  ##     else:
+  ##       await req.respond(Http404, "Not Found")
+  ##   ```
+  var msg = "HTTP/1.1 " & $code & "\c\L"
+
+  if headers != nil:
+    msg.addHeaders(headers)
+
+  # If the headers did not contain a Content-Length use our own
+  if headers.isNil() or not headers.hasKey("Content-Length"):
+    msg.add("Content-Length: ")
+    # this particular way saves allocations:
+    msg.addInt content.len
+    msg.add "\c\L"
+
+  msg.add "\c\L"
+  msg.add(content)
+  result = req.client.send(msg)
+
+proc respondError(req: Request, code: HttpCode): Future[void] =
+  ## Responds to the request with the specified `HttpCode`.
+  let content = $code
+  var msg = "HTTP/1.1 " & content & "\c\L"
+
+  msg.add("Content-Length: " & $content.len & "\c\L\c\L")
+  msg.add(content)
+  result = req.client.send(msg)
+
+proc parseProtocol(protocol: string): tuple[orig: string, major, minor: int] =
+  var i = protocol.skipIgnoreCase("HTTP/")
+  if i != 5:
+    raise newException(ValueError, "Invalid request protocol. Got: " &
+        protocol)
+  result.orig = protocol
+  i.inc protocol.parseSaturatedNatural(result.major, i)
+  i.inc # Skip .
+  i.inc protocol.parseSaturatedNatural(result.minor, i)
+
+proc sendStatus(client: AsyncSocket, status: string): Future[void] =
+  client.send("HTTP/1.1 " & status & "\c\L\c\L")
+
+func hasChunkedEncoding(request: Request): bool =
+  ## Searches for a chunked transfer encoding
+  const transferEncoding = "Transfer-Encoding"
+
+  if request.headers.hasKey(transferEncoding):
+    for encoding in seq[string](request.headers[transferEncoding]):
+      if "chunked" == encoding.strip:
+        # Returns true if it is both an HttpPost and has chunked encoding
+        return request.reqMethod == HttpPost
+  return false
+
+proc processRequest(
+  server: AsyncHttpServer,
+  req: FutureVar[Request],
+  client: AsyncSocket,
+  address: sink string,
+  lineFut: FutureVar[string],
+  callback: proc (request: Request): Future[void] {.closure, gcsafe.},
+): Future[bool] {.async.} =
+
+  # Alias `request` to `req.mget()` so we don't have to write `mget` everywhere.
+  template request(): Request =
+    req.mget()
+
+  # GET /path HTTP/1.1
+  # Header: val
+  # \n
+  request.headers.clear()
+  request.body = ""
+  when defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc):
+    request.hostname = address
+  else:
+    request.hostname.shallowCopy(address)
+  assert client != nil
+  request.client = client
+
+  # We should skip at least one empty line before the request
+  # https://tools.ietf.org/html/rfc7230#section-3.5
+  for i in 0..1:
+    lineFut.mget().setLen(0)
+    lineFut.clean()
+    await client.recvLineInto(lineFut, maxLength = maxLine) # TODO: Timeouts.
+
+    if lineFut.mget == "":
+      client.close()
+      return false
+
+    if lineFut.mget.len > maxLine:
+      await request.respondError(Http413)
+      client.close()
+      return false
+    if lineFut.mget != "\c\L":
+      break
+
+  # First line - GET /path HTTP/1.1
+  var i = 0
+  for linePart in lineFut.mget.split(' '):
+    case i
+    of 0:
+      case linePart
+      of "GET": request.reqMethod = HttpGet
+      of "POST": request.reqMethod = HttpPost
+      of "HEAD": request.reqMethod = HttpHead
+      of "PUT": request.reqMethod = HttpPut
+      of "DELETE": request.reqMethod = HttpDelete
+      of "PATCH": request.reqMethod = HttpPatch
+      of "OPTIONS": request.reqMethod = HttpOptions
+      of "CONNECT": request.reqMethod = HttpConnect
+      of "TRACE": request.reqMethod = HttpTrace
+      else:
+        asyncCheck request.respondError(Http400)
+        return true # Retry processing of request
+    of 1:
+      try:
+        parseUri(linePart, request.url)
+      except ValueError:
+        asyncCheck request.respondError(Http400)
+        return true
+    of 2:
+      try:
+        request.protocol = parseProtocol(linePart)
+      except ValueError:
+        asyncCheck request.respondError(Http400)
+        return true
+    else:
+      await request.respondError(Http400)
+      return true
+    inc i
+
+  # Headers
+  while true:
+    i = 0
+    lineFut.mget.setLen(0)
+    lineFut.clean()
+    await client.recvLineInto(lineFut, maxLength = maxLine)
+
+    if lineFut.mget == "":
+      client.close(); return false
+    if lineFut.mget.len > maxLine:
+      await request.respondError(Http413)
+      client.close(); return false
+    if lineFut.mget == "\c\L": break
+    let (key, value) = parseHeader(lineFut.mget)
+    request.headers[key] = value
+    # Ensure the client isn't trying to DoS us.
+    if request.headers.len > headerLimit:
+      await client.sendStatus("400 Bad Request")
+      request.client.close()
+      return false
+
+  if request.reqMethod == HttpPost:
+    # Check for Expect header
+    if request.headers.hasKey("Expect"):
+      if "100-continue" in request.headers["Expect"]:
+        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 parseSaturatedNatural(request.headers["Content-Length"], contentLength) == 0:
+      await request.respond(Http400, "Bad Request. Invalid Content-Length.")
+      return true
+    else:
+      if contentLength > server.maxBody:
+        await request.respondError(Http413)
+        return false
+      request.body = await client.recv(contentLength)
+      if request.body.len != contentLength:
+        await request.respond(Http400, "Bad Request. Content-Length does not match actual.")
+        return true
+  elif hasChunkedEncoding(request):
+    # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
+    var sizeOrData = 0
+    var bytesToRead = 0
+    request.body = ""
+
+    while true:
+      lineFut.mget.setLen(0)
+      lineFut.clean()
+
+      # The encoding format alternates between specifying a number of bytes to read
+      # and the data to be read, of the previously specified size
+      if sizeOrData mod 2 == 0:
+        # Expect a number of chars to read
+        await client.recvLineInto(lineFut, maxLength = maxLine)
+        try:
+          bytesToRead = lineFut.mget.parseHexInt
+        except ValueError:
+          # Malformed request
+          await request.respond(Http411, ("Invalid chunked transfer encoding - " &
+                                          "chunk data size must be hex encoded"))
+          return true
+      else:
+        if bytesToRead == 0:
+          # Done reading chunked data
+          break
+
+        # Read bytesToRead and add to body
+        let chunk = await client.recv(bytesToRead)
+        request.body.add(chunk)
+        # Skip \r\n (chunk terminating bytes per spec)
+        let separator = await client.recv(2)
+        if separator != "\r\n":
+          await request.respond(Http400, "Bad Request. Encoding separator must be \\r\\n")
+          return true
+
+      inc sizeOrData
+  elif request.reqMethod == HttpPost:
+    await request.respond(Http411, "Content-Length required.")
+    return true
+
+  # Call the user's callback.
+  await callback(request)
+
+  if "upgrade" in request.headers.getOrDefault("connection"):
+    return false
+
+  # The request has been served, from this point on returning `true` means the
+  # connection will not be closed and will be kept in the connection pool.
+
+  # Persistent connections
+  if (request.protocol == HttpVer11 and
+      cmpIgnoreCase(request.headers.getOrDefault("connection"), "close") != 0) or
+     (request.protocol == HttpVer10 and
+      cmpIgnoreCase(request.headers.getOrDefault("connection"), "keep-alive") == 0):
+    # 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.
+    return true
+  else:
+    request.client.close()
+    return false
+
+proc processClient(server: AsyncHttpServer, client: AsyncSocket, address: string,
+                   callback: proc (request: Request):
+                      Future[void] {.closure, gcsafe.}) {.async.} =
+  var request = newFutureVar[Request]("asynchttpserver.processClient")
+  request.mget().url = initUri()
+  request.mget().headers = newHttpHeaders()
+  var lineFut = newFutureVar[string]("asynchttpserver.processClient")
+  lineFut.mget() = newStringOfCap(80)
+
+  while not client.isClosed:
+    let retry = await processRequest(
+      server, request, client, address, lineFut, callback
+    )
+    if not retry:
+      client.close()
+      break
+
+const
+  nimMaxDescriptorsFallback* {.intdefine.} = 16_000 ## fallback value for \
+    ## when `maxDescriptors` is not available.
+    ## This can be set on the command line during compilation
+    ## via `-d:nimMaxDescriptorsFallback=N`
+
+proc listen*(server: AsyncHttpServer; port: Port; address = ""; domain = AF_INET) =
+  ## Listen to the given port and address.
+  when declared(maxDescriptors):
+    server.maxFDs = try: maxDescriptors() except: nimMaxDescriptorsFallback
+  else:
+    server.maxFDs = nimMaxDescriptorsFallback
+  server.socket = newAsyncSocket(domain)
+  if server.reuseAddr:
+    server.socket.setSockOpt(OptReuseAddr, true)
+  when not defined(nuttx):
+    if server.reusePort:
+      server.socket.setSockOpt(OptReusePort, true)
+  server.socket.bindAddr(port, address)
+  server.socket.listen()
+
+proc shouldAcceptRequest*(server: AsyncHttpServer;
+                          assumedDescriptorsPerRequest = 5): bool {.inline.} =
+  ## Returns true if the process's current number of opened file
+  ## descriptors is still within the maximum limit and so it's reasonable to
+  ## accept yet another request.
+  result = assumedDescriptorsPerRequest < 0 or
+    (activeDescriptors() + assumedDescriptorsPerRequest < server.maxFDs)
+
+proc acceptRequest*(server: AsyncHttpServer,
+            callback: proc (request: Request): Future[void] {.closure, gcsafe.}) {.async.} =
+  ## Accepts a single request. Write an explicit loop around this proc so that
+  ## errors can be handled properly.
+  var (address, client) = await server.socket.acceptAddr()
+  asyncCheck processClient(server, client, address, callback)
+
+proc serve*(server: AsyncHttpServer, port: Port,
+            callback: proc (request: Request): Future[void] {.closure, gcsafe.},
+            address = "";
+            assumedDescriptorsPerRequest = -1;
+            domain = AF_INET) {.async.} =
+  ## Starts the process of listening for incoming HTTP connections on the
+  ## specified address and port.
+  ##
+  ## When a request is made by a client the specified callback will be called.
+  ##
+  ## If `assumedDescriptorsPerRequest` is 0 or greater the server cares about
+  ## the process's maximum file descriptor limit. It then ensures that the
+  ## process still has the resources for `assumedDescriptorsPerRequest`
+  ## file descriptors before accepting a connection.
+  ##
+  ## You should prefer to call `acceptRequest` instead with a custom server
+  ## loop so that you're in control over the error handling and logging.
+  listen server, port, address, domain
+  while true:
+    if shouldAcceptRequest(server, assumedDescriptorsPerRequest):
+      var (address, client) = await server.socket.acceptAddr()
+      asyncCheck processClient(server, client, address, callback)
+    else:
+      poll()
+    #echo(f.isNil)
+    #echo(f.repr)
+
+proc close*(server: AsyncHttpServer) =
+  ## Terminates the async http server instance.
+  server.socket.close()
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim
new file mode 100644
index 000000000..d4e72c28a
--- /dev/null
+++ b/lib/pure/asyncmacro.nim
@@ -0,0 +1,383 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Implements the `async` and `multisync` macros for `asyncdispatch`.
+
+import std/[macros, strutils, asyncfutures]
+
+type
+  Context = ref object
+    inTry: int
+    hasRet: bool
+
+# TODO: Ref https://github.com/nim-lang/Nim/issues/5617
+# TODO: Add more line infos
+proc newCallWithLineInfo(fromNode: NimNode; theProc: NimNode, args: varargs[NimNode]): NimNode =
+  result = newCall(theProc, args)
+  result.copyLineInfo(fromNode)
+
+template createCb(retFutureSym, iteratorNameSym,
+                  strName, identName, futureVarCompletions: untyped) =
+  bind finished
+  var nameIterVar = iteratorNameSym
+  proc identName {.closure, stackTrace: off.} =
+    try:
+      if not nameIterVar.finished:
+        var next = nameIterVar()
+        # Continue while the yielded future is already finished.
+        while (not next.isNil) and next.finished:
+          next = nameIterVar()
+          if nameIterVar.finished:
+            break
+
+        if next == nil:
+          if not retFutureSym.finished:
+            let msg = "Async procedure ($1) yielded `nil`, are you await'ing a `nil` Future?"
+            raise newException(AssertionDefect, msg % strName)
+        else:
+          {.gcsafe.}:
+            next.addCallback cast[proc() {.closure, gcsafe.}](identName)
+    except:
+      futureVarCompletions
+      if retFutureSym.finished:
+        # Take a look at tasyncexceptions for the bug which this fixes.
+        # That test explains it better than I can here.
+        raise
+      else:
+        retFutureSym.fail(getCurrentException())
+  identName()
+
+proc createFutureVarCompletions(futureVarIdents: seq[NimNode], fromNode: NimNode): NimNode =
+  result = newNimNode(nnkStmtList, fromNode)
+  # Add calls to complete each FutureVar parameter.
+  for ident in futureVarIdents:
+    # Only complete them if they have not been completed already by the user.
+    # In the meantime, this was really useful for debugging :)
+    #result.add(newCall(newIdentNode("echo"), newStrLitNode(fromNode.lineinfo)))
+    result.add newIfStmt(
+      (
+        newCall(newIdentNode("not"),
+                newDotExpr(ident, newIdentNode("finished"))),
+        newCallWithLineInfo(fromNode, newIdentNode("complete"), ident)
+      )
+    )
+
+proc processBody(ctx: Context; node, needsCompletionSym, retFutureSym: NimNode, futureVarIdents: seq[NimNode]): NimNode =
+  result = node
+  case node.kind
+  of nnkReturnStmt:
+    result = newNimNode(nnkStmtList, node)
+
+    # As I've painfully found out, the order here really DOES matter.
+    result.add createFutureVarCompletions(futureVarIdents, node)
+
+    ctx.hasRet = true
+    if node[0].kind == nnkEmpty:
+      if ctx.inTry == 0:
+        result.add newCallWithLineInfo(node, newIdentNode("complete"), retFutureSym, newIdentNode("result"))
+      else:
+        result.add newAssignment(needsCompletionSym, newLit(true))
+    else:
+      let x = processBody(ctx, node[0], needsCompletionSym, retFutureSym, futureVarIdents)
+      if x.kind == nnkYieldStmt: result.add x
+      elif ctx.inTry == 0:
+        result.add newCallWithLineInfo(node, newIdentNode("complete"), retFutureSym, x)
+      else:
+        result.add newAssignment(newIdentNode("result"), x)
+        result.add newAssignment(needsCompletionSym, newLit(true))
+
+    result.add newNimNode(nnkReturnStmt, node).add(newNilLit())
+    return # Don't process the children of this return stmt
+  of RoutineNodes-{nnkTemplateDef}:
+    # skip all the nested procedure definitions
+    return
+  of nnkTryStmt:
+    if result[^1].kind == nnkFinally:
+      inc ctx.inTry
+      result[0] = processBody(ctx, result[0], needsCompletionSym, retFutureSym, futureVarIdents)
+      dec ctx.inTry
+      for i in 1 ..< result.len:
+        result[i] = processBody(ctx, result[i], needsCompletionSym, retFutureSym, futureVarIdents)
+      if ctx.inTry == 0 and ctx.hasRet:
+        let finallyNode = copyNimNode(result[^1])
+        let stmtNode = newNimNode(nnkStmtList)
+        for child in result[^1]:
+          stmtNode.add child
+        stmtNode.add newIfStmt(
+          ( needsCompletionSym,
+            newCallWithLineInfo(node, newIdentNode("complete"), retFutureSym,
+            newIdentNode("result")
+            )
+          )
+        )
+        finallyNode.add stmtNode
+        result[^1] = finallyNode
+    else:
+      for i in 0 ..< result.len:
+        result[i] = processBody(ctx, result[i], needsCompletionSym, retFutureSym, futureVarIdents)
+  else:
+    for i in 0 ..< result.len:
+      result[i] = processBody(ctx, result[i], needsCompletionSym, retFutureSym, futureVarIdents)
+
+  # echo result.repr
+
+proc getName(node: NimNode): string =
+  case node.kind
+  of nnkPostfix:
+    return node[1].strVal
+  of nnkIdent, nnkSym:
+    return node.strVal
+  of nnkEmpty:
+    return "anonymous"
+  else:
+    error("Unknown name.", node)
+
+proc getFutureVarIdents(params: NimNode): seq[NimNode] =
+  result = @[]
+  for i in 1 ..< len(params):
+    expectKind(params[i], nnkIdentDefs)
+    if params[i][1].kind == nnkBracketExpr and
+       params[i][1][0].eqIdent(FutureVar.astToStr):
+      ## eqIdent: first char is case sensitive!!!
+      result.add(params[i][0])
+
+proc isInvalidReturnType(typeName: string): bool =
+  return typeName notin ["Future"] #, "FutureStream"]
+
+proc verifyReturnType(typeName: string, node: NimNode = nil) =
+  if typeName.isInvalidReturnType:
+    error("Expected return type of 'Future' got '$1'" %
+          typeName, node)
+
+template await*(f: typed): untyped {.used.} =
+  static:
+    error "await expects Future[T], got " & $typeof(f)
+
+template await*[T](f: Future[T]): auto {.used.} =
+  when not defined(nimHasTemplateRedefinitionPragma):
+    {.pragma: redefine.}
+  template yieldFuture {.redefine.} = yield FutureBase()
+
+  when compiles(yieldFuture):
+    var internalTmpFuture: FutureBase = f
+    yield internalTmpFuture
+    (cast[typeof(f)](internalTmpFuture)).read()
+  else:
+    macro errorAsync(futureError: Future[T]) =
+      error(
+        "Can only 'await' inside a proc marked as 'async'. Use " &
+        "'waitFor' when calling an 'async' proc in a non-async scope instead",
+        futureError)
+    errorAsync(f)
+
+proc asyncSingleProc(prc: NimNode): NimNode =
+  ## This macro transforms a single procedure into a closure iterator.
+  ## The `async` macro supports a stmtList holding multiple async procedures.
+  if prc.kind == nnkProcTy:
+    result = prc
+    if prc[0][0].kind == nnkEmpty:
+      result[0][0] = quote do: Future[void]
+    return result
+
+  if prc.kind in RoutineNodes and prc.name.kind != nnkEmpty:
+    # Only non anonymous functions need/can have stack trace disabled
+    prc.addPragma(nnkExprColonExpr.newTree(ident"stackTrace", ident"off"))
+
+  if prc.kind notin {nnkProcDef, nnkLambda, nnkMethodDef, nnkDo}:
+    error("Cannot transform this node kind into an async proc." &
+          " proc/method definition or lambda node expected.", prc)
+
+  if prc[4].kind != nnkEmpty:
+    for prag in prc[4]:
+      if prag.eqIdent("discardable"):
+        error("Cannot make async proc discardable. Futures have to be " &
+          "checked with `asyncCheck` instead of discarded", prag)
+
+  let prcName = prc.name.getName
+
+  var returnType = prc.params[0]
+  var baseType: NimNode
+  if returnType.kind in nnkCallKinds and returnType[0].eqIdent("owned") and
+      returnType.len == 2:
+    returnType = returnType[1]
+  # Verify that the return type is a Future[T]
+  if returnType.kind == nnkBracketExpr:
+    let fut = repr(returnType[0])
+    verifyReturnType(fut, returnType[0])
+    baseType = returnType[1]
+  elif returnType.kind in nnkCallKinds and returnType[0].eqIdent("[]"):
+    let fut = repr(returnType[1])
+    verifyReturnType(fut, returnType[0])
+    baseType = returnType[2]
+  elif returnType.kind == nnkEmpty:
+    baseType = returnType
+  else:
+    verifyReturnType(repr(returnType), returnType)
+
+  let futureVarIdents = getFutureVarIdents(prc.params)
+  var outerProcBody = newNimNode(nnkStmtList, prc.body)
+
+  # Extract the documentation comment from the original procedure declaration.
+  # Note that we're not removing it from the body in order not to make this
+  # transformation even more complex.
+  let body2 = extractDocCommentsAndRunnables(prc.body)
+
+  # -> var retFuture = newFuture[T]()
+  var retFutureSym = genSym(nskVar, "retFuture")
+  var subRetType =
+    if returnType.kind == nnkEmpty: newIdentNode("void")
+    else: baseType
+  outerProcBody.add(
+    newVarStmt(retFutureSym,
+      newCall(
+        newNimNode(nnkBracketExpr, prc.body).add(
+          newIdentNode("newFuture"),
+          subRetType),
+      newLit(prcName)))) # Get type from return type of this proc
+
+  # -> iterator nameIter(): FutureBase {.closure.} =
+  # ->   {.push warning[resultshadowed]: off.}
+  # ->   var result: T
+  # ->   {.pop.}
+  # ->   <proc_body>
+  # ->   complete(retFuture, result)
+  var iteratorNameSym = genSym(nskIterator, $prcName & " (Async)")
+  var needsCompletionSym = genSym(nskVar, "needsCompletion")
+  var ctx = Context()
+  var procBody = processBody(ctx, prc.body, needsCompletionSym, retFutureSym, futureVarIdents)
+  # don't do anything with forward bodies (empty)
+  if procBody.kind != nnkEmpty:
+    # fix #13899, defer should not escape its original scope
+    let blockStmt = newStmtList(newTree(nnkBlockStmt, newEmptyNode(), procBody))
+    procBody = newStmtList()
+    let resultIdent = ident"result"
+    procBody.add quote do:
+      # Check whether there is an implicit return
+      when typeof(`blockStmt`) is void:
+        `blockStmt`
+      else:
+        `resultIdent` = `blockStmt`
+    procBody.add(createFutureVarCompletions(futureVarIdents, nil))
+    procBody.insert(0): quote do:
+      {.push warning[resultshadowed]: off.}
+      when `subRetType` isnot void:
+        var `resultIdent`: `subRetType`
+      else:
+        var `resultIdent`: Future[void]
+      {.pop.}
+
+      var `needsCompletionSym` = false
+    procBody.add quote do:
+      complete(`retFutureSym`, `resultIdent`)
+
+    var closureIterator = newProc(iteratorNameSym, [quote do: owned(FutureBase)],
+                                  procBody, nnkIteratorDef)
+    closureIterator.pragma = newNimNode(nnkPragma, lineInfoFrom = prc.body)
+    closureIterator.addPragma(newIdentNode("closure"))
+
+    # If proc has an explicit gcsafe pragma, we add it to iterator as well.
+    if prc.pragma.findChild(it.kind in {nnkSym, nnkIdent} and $it == "gcsafe") != nil:
+      closureIterator.addPragma(newIdentNode("gcsafe"))
+    outerProcBody.add(closureIterator)
+
+    # -> createCb(retFuture)
+    # NOTE: The NimAsyncContinueSuffix is checked for in asyncfutures.nim to produce
+    # friendlier stack traces:
+    var cbName = genSym(nskProc, prcName & NimAsyncContinueSuffix)
+    var procCb = getAst createCb(retFutureSym, iteratorNameSym,
+                          newStrLitNode(prcName),
+                          cbName,
+                          createFutureVarCompletions(futureVarIdents, nil)
+                        )
+    outerProcBody.add procCb
+
+    # -> return retFuture
+    outerProcBody.add newNimNode(nnkReturnStmt, prc.body[^1]).add(retFutureSym)
+
+  result = prc
+  # Add discardable pragma.
+  if returnType.kind == nnkEmpty:
+    # xxx consider removing `owned`? it's inconsistent with non-void case
+    result.params[0] = quote do: owned(Future[void])
+
+  # based on the yglukhov's patch to chronos: https://github.com/status-im/nim-chronos/pull/47
+  if procBody.kind != nnkEmpty:
+    body2.add quote do:
+      `outerProcBody`
+    result.body = body2
+
+macro async*(prc: untyped): untyped =
+  ## Macro which processes async procedures into the appropriate
+  ## iterators and yield statements.
+  if prc.kind == nnkStmtList:
+    result = newStmtList()
+    for oneProc in prc:
+      result.add asyncSingleProc(oneProc)
+  else:
+    result = asyncSingleProc(prc)
+  when defined(nimDumpAsync):
+    echo repr result
+
+proc splitParamType(paramType: NimNode, async: bool): NimNode =
+  result = paramType
+  if paramType.kind == nnkInfix and paramType[0].strVal in ["|", "or"]:
+    let firstAsync = "async" in paramType[1].toStrLit().strVal.normalize
+    let secondAsync = "async" in paramType[2].toStrLit().strVal.normalize
+
+    if firstAsync:
+      result = paramType[if async: 1 else: 2]
+    elif secondAsync:
+      result = paramType[if async: 2 else: 1]
+
+proc stripReturnType(returnType: NimNode): NimNode =
+  # Strip out the 'Future' from 'Future[T]'.
+  result = returnType
+  if returnType.kind == nnkBracketExpr:
+    let fut = repr(returnType[0])
+    verifyReturnType(fut, returnType)
+    result = returnType[1]
+
+proc splitProc(prc: NimNode): (NimNode, NimNode) =
+  ## Takes a procedure definition which takes a generic union of arguments,
+  ## for example: proc (socket: Socket | AsyncSocket).
+  ## It transforms them so that `proc (socket: Socket)` and
+  ## `proc (socket: AsyncSocket)` are returned.
+
+  result[0] = prc.copyNimTree()
+  # Retrieve the `T` inside `Future[T]`.
+  let returnType = stripReturnType(result[0][3][0])
+  result[0][3][0] = splitParamType(returnType, async = false)
+  for i in 1 ..< result[0][3].len:
+    # Sync proc (0) -> FormalParams (3) -> IdentDefs, the parameter (i) ->
+    # parameter type (1).
+    result[0][3][i][1] = splitParamType(result[0][3][i][1], async=false)
+  var multisyncAwait = quote:
+    template await(value: typed): untyped =
+      value
+
+  result[0][^1] = nnkStmtList.newTree(multisyncAwait, result[0][^1])
+
+  result[1] = prc.copyNimTree()
+  if result[1][3][0].kind == nnkBracketExpr:
+    result[1][3][0][1] = splitParamType(result[1][3][0][1], async = true)
+  for i in 1 ..< result[1][3].len:
+    # Async proc (1) -> FormalParams (3) -> IdentDefs, the parameter (i) ->
+    # parameter type (1).
+    result[1][3][i][1] = splitParamType(result[1][3][i][1], async = true)
+
+macro multisync*(prc: untyped): untyped =
+  ## Macro which processes async procedures into both asynchronous and
+  ## synchronous procedures.
+  ##
+  ## The generated async procedures use the `async` macro, whereas the
+  ## generated synchronous procedures simply strip off the `await` calls.
+  let (sync, asyncPrc) = splitProc(prc)
+  result = newStmtList()
+  result.add(asyncSingleProc(asyncPrc))
+  result.add(sync)
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
new file mode 100644
index 000000000..ee07e599e
--- /dev/null
+++ b/lib/pure/asyncnet.nim
@@ -0,0 +1,1004 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a high-level asynchronous sockets API based on the
+## asynchronous dispatcher defined in the `asyncdispatch` module.
+##
+## Asynchronous IO in Nim
+## ======================
+##
+## Async IO in Nim consists of multiple layers (from highest to lowest):
+##
+## * `asyncnet` module
+##
+## * Async await
+##
+## * `asyncdispatch` module (event loop)
+##
+## * `selectors` module
+##
+## Each builds on top of the layers below it. The selectors module is an
+## abstraction for the various system `select()` mechanisms such as epoll or
+## kqueue. If you wish you can use it directly, and some people have done so
+## `successfully <http://goran.krampe.se/2014/10/25/nim-socketserver/>`_.
+## But you must be aware that on Windows it only supports
+## `select()`.
+##
+## The async dispatcher implements the proactor pattern and also has an
+## implementation of IOCP. It implements the proactor pattern for other
+## OS' via the selectors module. Futures are also implemented here, and
+## indeed all the procedures return a future.
+##
+## The final layer is the async await transformation. This allows you to
+## write asynchronous code in a synchronous style and works similar to
+## C#'s await. The transformation works by converting any async procedures
+## into an iterator.
+##
+## This is all single threaded, fully non-blocking and does give you a
+## lot of control. In theory you should be able to work with any of these
+## layers interchangeably (as long as you only care about non-Windows
+## platforms).
+##
+## For most applications using `asyncnet` is the way to go as it builds
+## over all the layers, providing some extra features such as buffering.
+##
+## SSL
+## ===
+##
+## SSL can be enabled by compiling with the `-d:ssl` flag.
+##
+## You must create a new SSL context with the `newContext` function defined
+## in the `net` module. You may then call `wrapSocket` on your socket using
+## the newly created SSL context to get an SSL socket.
+##
+## Examples
+## ========
+##
+## Chat server
+## -----------
+##
+## The following example demonstrates a simple chat server.
+##
+##   ```Nim
+##   import std/[asyncnet, asyncdispatch]
+##
+##   var clients {.threadvar.}: seq[AsyncSocket]
+##
+##   proc processClient(client: AsyncSocket) {.async.} =
+##     while true:
+##       let line = await client.recvLine()
+##       if line.len == 0: break
+##       for c in clients:
+##         await c.send(line & "\c\L")
+##
+##   proc serve() {.async.} =
+##     clients = @[]
+##     var server = newAsyncSocket()
+##     server.setSockOpt(OptReuseAddr, true)
+##     server.bindAddr(Port(12345))
+##     server.listen()
+##
+##     while true:
+##       let client = await server.accept()
+##       clients.add client
+##
+##       asyncCheck processClient(client)
+##
+##   asyncCheck serve()
+##   runForever()
+##   ```
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+import std/[asyncdispatch, nativesockets, net, os]
+
+export SOBool
+
+# TODO: Remove duplication introduced by PR #4683.
+
+const defineSsl = defined(ssl) or defined(nimdoc)
+const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr) or
+    defined(nuttx)
+
+when defineSsl:
+  import std/openssl
+
+type
+  # TODO: I would prefer to just do:
+  # AsyncSocket* {.borrow: `.`.} = distinct Socket. But that doesn't work.
+  AsyncSocketDesc = object
+    fd: SocketHandle
+    closed: bool     ## determines whether this socket has been closed
+    isBuffered: bool ## determines whether this socket is buffered.
+    buffer: array[0..BufferSize, char]
+    currPos: int     # current index in buffer
+    bufLen: int      # current length of buffer
+    isSsl: bool
+    when defineSsl:
+      sslHandle: SslPtr
+      sslContext: SslContext
+      bioIn: BIO
+      bioOut: BIO
+      sslNoShutdown: bool
+    domain: Domain
+    sockType: SockType
+    protocol: Protocol
+  AsyncSocket* = ref AsyncSocketDesc
+
+proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET,
+                     sockType: SockType = SOCK_STREAM,
+                     protocol: Protocol = IPPROTO_TCP,
+                     buffered = true,
+                     inheritable = defined(nimInheritHandles)): owned(AsyncSocket) =
+  ## Creates a new `AsyncSocket` based on the supplied params.
+  ##
+  ## The supplied `fd`'s non-blocking state will be enabled implicitly.
+  ##
+  ## If `inheritable` is false (the default), the supplied `fd` will not
+  ## be inheritable by child processes.
+  ##
+  ## **Note**: This procedure will **NOT** register `fd` with the global
+  ## async dispatcher. You need to do this manually. If you have used
+  ## `newAsyncNativeSocket` to create `fd` then it's already registered.
+  assert fd != osInvalidSocket.AsyncFD
+  new(result)
+  result.fd = fd.SocketHandle
+  fd.SocketHandle.setBlocking(false)
+  if not fd.SocketHandle.setInheritable(inheritable):
+    raiseOSError(osLastError())
+  result.isBuffered = buffered
+  result.domain = domain
+  result.sockType = sockType
+  result.protocol = protocol
+  if buffered:
+    result.currPos = 0
+
+proc newAsyncSocket*(domain: Domain = AF_INET, sockType: SockType = SOCK_STREAM,
+                     protocol: Protocol = IPPROTO_TCP, buffered = true,
+                     inheritable = defined(nimInheritHandles)): owned(AsyncSocket) =
+  ## Creates a new asynchronous socket.
+  ##
+  ## This procedure will also create a brand new file descriptor for
+  ## this socket.
+  ##
+  ## If `inheritable` is false (the default), the new file descriptor will not
+  ## be inheritable by child processes.
+  let fd = createAsyncNativeSocket(domain, sockType, protocol, inheritable)
+  if fd.SocketHandle == osInvalidSocket:
+    raiseOSError(osLastError())
+  result = newAsyncSocket(fd, domain, sockType, protocol, buffered, inheritable)
+
+proc getLocalAddr*(socket: AsyncSocket): (string, Port) =
+  ## Get the socket's local address and port number.
+  ##
+  ## This is high-level interface for `getsockname`:idx:.
+  getLocalAddr(socket.fd, socket.domain)
+
+when not useNimNetLite:
+  proc getPeerAddr*(socket: AsyncSocket): (string, Port) =
+    ## Get the socket's peer address and port number.
+    ##
+    ## This is high-level interface for `getpeername`:idx:.
+    getPeerAddr(socket.fd, socket.domain)
+
+proc newAsyncSocket*(domain, sockType, protocol: cint,
+                     buffered = true,
+                     inheritable = defined(nimInheritHandles)): owned(AsyncSocket) =
+  ## Creates a new asynchronous socket.
+  ##
+  ## This procedure will also create a brand new file descriptor for
+  ## this socket.
+  ##
+  ## If `inheritable` is false (the default), the new file descriptor will not
+  ## be inheritable by child processes.
+  let fd = createAsyncNativeSocket(domain, sockType, protocol, inheritable)
+  if fd.SocketHandle == osInvalidSocket:
+    raiseOSError(osLastError())
+  result = newAsyncSocket(fd, Domain(domain), SockType(sockType),
+                          Protocol(protocol), buffered, inheritable)
+
+when defineSsl:
+  proc getSslError(socket: AsyncSocket, err: cint): cint =
+    assert socket.isSsl
+    assert err < 0
+    var ret = SSL_get_error(socket.sslHandle, err.cint)
+    case ret
+    of SSL_ERROR_ZERO_RETURN:
+      raiseSSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
+    of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
+      return ret
+    of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ:
+      return ret
+    of SSL_ERROR_WANT_X509_LOOKUP:
+      raiseSSLError("Function for x509 lookup has been called.")
+    of SSL_ERROR_SYSCALL, SSL_ERROR_SSL:
+      socket.sslNoShutdown = true
+      raiseSSLError()
+    else: raiseSSLError("Unknown Error")
+
+  proc sendPendingSslData(socket: AsyncSocket,
+      flags: set[SocketFlag]) {.async.} =
+    let len = bioCtrlPending(socket.bioOut)
+    if len > 0:
+      var data = newString(len)
+      let read = bioRead(socket.bioOut, cast[cstring](addr data[0]), len)
+      assert read != 0
+      if read < 0:
+        raiseSSLError()
+      data.setLen(read)
+      await socket.fd.AsyncFD.send(data, flags)
+
+  proc appeaseSsl(socket: AsyncSocket, flags: set[SocketFlag],
+                  sslError: cint): owned(Future[bool]) {.async.} =
+    ## Returns `true` if `socket` is still connected, otherwise `false`.
+    result = true
+    case sslError
+    of SSL_ERROR_WANT_WRITE:
+      await sendPendingSslData(socket, flags)
+    of SSL_ERROR_WANT_READ:
+      var data = await recv(socket.fd.AsyncFD, BufferSize, flags)
+      let length = len(data)
+      if length > 0:
+        let ret = bioWrite(socket.bioIn, cast[cstring](addr data[0]), length.cint)
+        if ret < 0:
+          raiseSSLError()
+      elif length == 0:
+        # connection not properly closed by remote side or connection dropped
+        SSL_set_shutdown(socket.sslHandle, SSL_RECEIVED_SHUTDOWN)
+        result = false
+    else:
+      raiseSSLError("Cannot appease SSL.")
+
+  template sslLoop(socket: AsyncSocket, flags: set[SocketFlag],
+                   op: untyped) =
+    var opResult {.inject.} = -1.cint
+    while opResult < 0:
+      ErrClearError()
+      # Call the desired operation.
+      opResult = op
+      let err =
+        if opResult < 0:
+          getSslError(socket, opResult.cint)
+        else:
+          SSL_ERROR_NONE
+      # Send any remaining pending SSL data.
+      await sendPendingSslData(socket, flags)
+
+      # If the operation failed, try to see if SSL has some data to read
+      # or write.
+      if opResult < 0:
+        let fut = appeaseSsl(socket, flags, err.cint)
+        yield fut
+        if not fut.read():
+          # Socket disconnected.
+          if SocketFlag.SafeDisconn in flags:
+            opResult = 0.cint
+            break
+          else:
+            raiseSSLError("Socket has been disconnected")
+
+proc dial*(address: string, port: Port, protocol = IPPROTO_TCP,
+           buffered = true): owned(Future[AsyncSocket]) {.async.} =
+  ## Establishes connection to the specified `address`:`port` pair via the
+  ## specified protocol. The procedure iterates through possible
+  ## resolutions of the `address` until it succeeds, meaning that it
+  ## seamlessly works with both IPv4 and IPv6.
+  ## Returns AsyncSocket ready to send or receive data.
+  let asyncFd = await asyncdispatch.dial(address, port, protocol)
+  let sockType = protocol.toSockType()
+  let domain = getSockDomain(asyncFd.SocketHandle)
+  result = newAsyncSocket(asyncFd, domain, sockType, protocol, buffered)
+
+proc connect*(socket: AsyncSocket, address: string, port: Port) {.async.} =
+  ## Connects `socket` to server at `address:port`.
+  ##
+  ## Returns a `Future` which will complete when the connection succeeds
+  ## or an error occurs.
+  await connect(socket.fd.AsyncFD, address, port, socket.domain)
+  if socket.isSsl:
+    when defineSsl:
+      if not isIpAddress(address):
+        # Set the SNI address for this connection. This call can fail if
+        # we're not using TLSv1+.
+        discard SSL_set_tlsext_host_name(socket.sslHandle, address)
+
+      let flags = {SocketFlag.SafeDisconn}
+      sslSetConnectState(socket.sslHandle)
+      sslLoop(socket, flags, sslDoHandshake(socket.sslHandle))
+
+template readInto(buf: pointer, size: int, socket: AsyncSocket,
+                  flags: set[SocketFlag]): int =
+  ## Reads **up to** `size` bytes from `socket` into `buf`. Note that
+  ## this is a template and not a proc.
+  assert(not socket.closed, "Cannot `recv` on a closed socket")
+  var res = 0
+  if socket.isSsl:
+    when defineSsl:
+      # SSL mode.
+      sslLoop(socket, flags,
+        sslRead(socket.sslHandle, cast[cstring](buf), size.cint))
+      res = opResult
+  else:
+    # Not in SSL mode.
+    res = await asyncdispatch.recvInto(socket.fd.AsyncFD, buf, size, flags)
+  res
+
+template readIntoBuf(socket: AsyncSocket,
+    flags: set[SocketFlag]): int =
+  var size = readInto(addr socket.buffer[0], BufferSize, socket, flags)
+  socket.currPos = 0
+  socket.bufLen = size
+  size
+
+proc recvInto*(socket: AsyncSocket, buf: pointer, size: int,
+           flags = {SocketFlag.SafeDisconn}): owned(Future[int]) {.async.} =
+  ## Reads **up to** `size` bytes from `socket` into `buf`.
+  ##
+  ## For buffered sockets this function will attempt to read all the requested
+  ## data. It will read this data in `BufferSize` chunks.
+  ##
+  ## For unbuffered sockets this function makes no effort to read
+  ## all the data requested. It will return as much data as the operating system
+  ## gives it.
+  ##
+  ## If socket is disconnected during the
+  ## recv operation then the future may complete with only a part of the
+  ## requested data.
+  ##
+  ## If socket is disconnected and no data is available
+  ## to be read then the future will complete with a value of `0`.
+  if socket.isBuffered:
+    let originalBufPos = socket.currPos
+
+    if socket.bufLen == 0:
+      let res = socket.readIntoBuf(flags - {SocketFlag.Peek})
+      if res == 0:
+        return 0
+
+    var read = 0
+    var cbuf = cast[cstring](buf)
+    while read < size:
+      if socket.currPos >= socket.bufLen:
+        if SocketFlag.Peek in flags:
+          # We don't want to get another buffer if we're peeking.
+          break
+        let res = socket.readIntoBuf(flags - {SocketFlag.Peek})
+        if res == 0:
+          break
+
+      let chunk = min(socket.bufLen-socket.currPos, size-read)
+      copyMem(addr(cbuf[read]), addr(socket.buffer[socket.currPos]), chunk)
+      read.inc(chunk)
+      socket.currPos.inc(chunk)
+
+    if SocketFlag.Peek in flags:
+      # Restore old buffer cursor position.
+      socket.currPos = originalBufPos
+    result = read
+  else:
+    result = readInto(buf, size, socket, flags)
+
+proc recv*(socket: AsyncSocket, size: int,
+           flags = {SocketFlag.SafeDisconn}): owned(Future[string]) {.async.} =
+  ## Reads **up to** `size` bytes from `socket`.
+  ##
+  ## For buffered sockets this function will attempt to read all the requested
+  ## data. It will read this data in `BufferSize` chunks.
+  ##
+  ## For unbuffered sockets this function makes no effort to read
+  ## all the data requested. It will return as much data as the operating system
+  ## gives it.
+  ##
+  ## If socket is disconnected during the
+  ## recv operation then the future may complete with only a part of the
+  ## requested data.
+  ##
+  ## If socket is disconnected and no data is available
+  ## to be read then the future will complete with a value of `""`.
+  if socket.isBuffered:
+    result = newString(size)
+    when not defined(nimSeqsV2):
+      shallow(result)
+    let originalBufPos = socket.currPos
+
+    if socket.bufLen == 0:
+      let res = socket.readIntoBuf(flags - {SocketFlag.Peek})
+      if res == 0:
+        result.setLen(0)
+        return
+
+    var read = 0
+    while read < size:
+      if socket.currPos >= socket.bufLen:
+        if SocketFlag.Peek in flags:
+          # We don't want to get another buffer if we're peeking.
+          break
+        let res = socket.readIntoBuf(flags - {SocketFlag.Peek})
+        if res == 0:
+          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 SocketFlag.Peek in flags:
+      # Restore old buffer cursor position.
+      socket.currPos = originalBufPos
+    result.setLen(read)
+  else:
+    result = newString(size)
+    let read = readInto(addr result[0], size, socket, flags)
+    result.setLen(read)
+
+proc send*(socket: AsyncSocket, buf: pointer, size: int,
+            flags = {SocketFlag.SafeDisconn}) {.async.} =
+  ## Sends `size` bytes from `buf` to `socket`. The returned future will complete once all
+  ## data has been sent.
+  assert socket != nil
+  assert(not socket.closed, "Cannot `send` on a closed socket")
+  if socket.isSsl:
+    when defineSsl:
+      sslLoop(socket, flags,
+              sslWrite(socket.sslHandle, cast[cstring](buf), size.cint))
+      await sendPendingSslData(socket, flags)
+  else:
+    await send(socket.fd.AsyncFD, buf, size, flags)
+
+proc send*(socket: AsyncSocket, data: string,
+           flags = {SocketFlag.SafeDisconn}) {.async.} =
+  ## Sends `data` to `socket`. The returned future will complete once all
+  ## data has been sent.
+  assert socket != nil
+  if socket.isSsl:
+    when defineSsl:
+      var copy = data
+      sslLoop(socket, flags,
+        sslWrite(socket.sslHandle, cast[cstring](addr copy[0]), copy.len.cint))
+      await sendPendingSslData(socket, flags)
+  else:
+    await send(socket.fd.AsyncFD, data, flags)
+
+proc acceptAddr*(socket: AsyncSocket, flags = {SocketFlag.SafeDisconn},
+                 inheritable = defined(nimInheritHandles)):
+      owned(Future[tuple[address: string, client: AsyncSocket]]) =
+  ## Accepts a new connection. Returns a future containing the client socket
+  ## corresponding to that connection and the remote address of the client.
+  ##
+  ## If `inheritable` is false (the default), the resulting client socket will
+  ## not be inheritable by child processes.
+  ##
+  ## The future will complete when the connection is successfully accepted.
+  var retFuture = newFuture[tuple[address: string, client: AsyncSocket]]("asyncnet.acceptAddr")
+  var fut = acceptAddr(socket.fd.AsyncFD, flags, inheritable)
+  fut.callback =
+    proc (future: Future[tuple[address: string, client: AsyncFD]]) =
+      assert future.finished
+      if future.failed:
+        retFuture.fail(future.readError)
+      else:
+        let resultTup = (future.read.address,
+                         newAsyncSocket(future.read.client, socket.domain,
+                         socket.sockType, socket.protocol, socket.isBuffered, inheritable))
+        retFuture.complete(resultTup)
+  return retFuture
+
+proc accept*(socket: AsyncSocket,
+    flags = {SocketFlag.SafeDisconn}): owned(Future[AsyncSocket]) =
+  ## Accepts a new connection. Returns a future containing the client socket
+  ## corresponding to that connection.
+  ## If `inheritable` is false (the default), the resulting client socket will
+  ## not be inheritable by child processes.
+  ## The future will complete when the connection is successfully accepted.
+  var retFut = newFuture[AsyncSocket]("asyncnet.accept")
+  var fut = acceptAddr(socket, flags)
+  fut.callback =
+    proc (future: Future[tuple[address: string, client: AsyncSocket]]) =
+      assert future.finished
+      if future.failed:
+        retFut.fail(future.readError)
+      else:
+        retFut.complete(future.read.client)
+  return retFut
+
+proc recvLineInto*(socket: AsyncSocket, resString: FutureVar[string],
+    flags = {SocketFlag.SafeDisconn}, maxLength = MaxLineLength) {.async.} =
+  ## Reads a line of data from `socket` into `resString`.
+  ##
+  ## If a full line is read `\r\L` is not
+  ## added to `line`, however if solely `\r\L` is read then `line`
+  ## will be set to it.
+  ##
+  ## If the socket is disconnected, `line` will be set to `""`.
+  ##
+  ## 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**.
+  ##
+  ## The `maxLength` parameter determines the maximum amount of characters
+  ## that can be read. `resString` will be truncated after that.
+  ##
+  ## .. warning:: The `Peek` flag is not yet implemented.
+  ##
+  ## .. warning:: `recvLineInto` on unbuffered sockets assumes that the protocol uses `\r\L` to delimit a new line.
+  assert SocketFlag.Peek notin flags ## TODO:
+  result = newFuture[void]("asyncnet.recvLineInto")
+
+  # TODO: Make the async transformation check for FutureVar params and complete
+  # them when the result future is completed.
+  # Can we replace the result future with the FutureVar?
+
+  template addNLIfEmpty(): untyped =
+    if resString.mget.len == 0:
+      resString.mget.add("\c\L")
+
+  if socket.isBuffered:
+    if socket.bufLen == 0:
+      let res = socket.readIntoBuf(flags)
+      if res == 0:
+        resString.complete()
+        return
+
+    var lastR = false
+    while true:
+      if socket.currPos >= socket.bufLen:
+        let res = socket.readIntoBuf(flags)
+        if res == 0:
+          resString.mget.setLen(0)
+          resString.complete()
+          return
+
+      case socket.buffer[socket.currPos]
+      of '\r':
+        lastR = true
+        addNLIfEmpty()
+      of '\L':
+        addNLIfEmpty()
+        socket.currPos.inc()
+        resString.complete()
+        return
+      else:
+        if lastR:
+          socket.currPos.inc()
+          resString.complete()
+          return
+        else:
+          resString.mget.add socket.buffer[socket.currPos]
+      socket.currPos.inc()
+
+      # Verify that this isn't a DOS attack: #3847.
+      if resString.mget.len > maxLength: break
+  else:
+    var c = ""
+    while true:
+      c = await recv(socket, 1, flags)
+      if c.len == 0:
+        resString.mget.setLen(0)
+        resString.complete()
+        return
+      if c == "\r":
+        c = await recv(socket, 1, flags) # Skip \L
+        assert c == "\L"
+        addNLIfEmpty()
+        resString.complete()
+        return
+      elif c == "\L":
+        addNLIfEmpty()
+        resString.complete()
+        return
+      resString.mget.add c
+
+      # Verify that this isn't a DOS attack: #3847.
+      if resString.mget.len > maxLength: break
+  resString.complete()
+
+proc recvLine*(socket: AsyncSocket,
+    flags = {SocketFlag.SafeDisconn},
+    maxLength = MaxLineLength): owned(Future[string]) {.async.} =
+  ## Reads a line of data from `socket`. Returned future will complete once
+  ## a full line is read or an error occurs.
+  ##
+  ## If a full line is read `\r\L` is not
+  ## added to `line`, however if solely `\r\L` is read then `line`
+  ## will be set to it.
+  ##
+  ## If the socket is disconnected, `line` will be set to `""`.
+  ##
+  ## 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**.
+  ##
+  ## The `maxLength` parameter determines the maximum amount of characters
+  ## that can be read. The result is truncated after that.
+  ##
+  ## .. warning:: The `Peek` flag is not yet implemented.
+  ##
+  ## .. warning:: `recvLine` on unbuffered sockets assumes that the protocol uses `\r\L` to delimit a new line.
+  assert SocketFlag.Peek notin flags ## TODO:
+
+  # TODO: Optimise this
+  var resString = newFutureVar[string]("asyncnet.recvLine")
+  resString.mget() = ""
+  await socket.recvLineInto(resString, flags, maxLength)
+  result = resString.mget()
+
+proc listen*(socket: AsyncSocket, backlog = SOMAXCONN) {.tags: [
+    ReadIOEffect].} =
+  ## Marks `socket` as accepting connections.
+  ## `Backlog` specifies the maximum length of the
+  ## queue of pending connections.
+  ##
+  ## Raises an OSError error upon failure.
+  if listen(socket.fd, backlog) < 0'i32: raiseOSError(osLastError())
+
+proc bindAddr*(socket: AsyncSocket, port = Port(0), address = "") {.
+  tags: [ReadIOEffect].} =
+  ## Binds `address`:`port` to the socket.
+  ##
+  ## If `address` is "" then ADDR_ANY will be bound.
+  var realaddr = address
+  if realaddr == "":
+    case socket.domain
+    of AF_INET6: realaddr = "::"
+    of AF_INET: realaddr = "0.0.0.0"
+    else:
+      raise newException(ValueError,
+        "Unknown socket address family and no address specified to bindAddr")
+
+  var aiList = getAddrInfo(realaddr, port, socket.domain)
+  if bindAddr(socket.fd, aiList.ai_addr, aiList.ai_addrlen.SockLen) < 0'i32:
+    freeAddrInfo(aiList)
+    raiseOSError(osLastError())
+  freeAddrInfo(aiList)
+
+proc hasDataBuffered*(s: AsyncSocket): bool {.since: (1, 5).} =
+  ## Determines whether an AsyncSocket has data buffered.
+  # xxx dedup with std/net
+  s.isBuffered and s.bufLen > 0 and s.currPos != s.bufLen
+
+when defined(posix) and not useNimNetLite:
+
+  proc connectUnix*(socket: AsyncSocket, path: string): owned(Future[void]) =
+    ## Binds Unix socket to `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    when not defined(nimdoc):
+      let retFuture = newFuture[void]("connectUnix")
+      result = retFuture
+
+      proc cb(fd: AsyncFD): bool =
+        let ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
+        if ret == 0:
+          retFuture.complete()
+          return true
+        elif ret == EINTR:
+          return false
+        else:
+          retFuture.fail(newOSError(OSErrorCode(ret)))
+          return true
+
+      var socketAddr = makeUnixAddr(path)
+      let ret = socket.fd.connect(cast[ptr SockAddr](addr socketAddr),
+                        (offsetOf(socketAddr, sun_path) + path.len + 1).SockLen)
+      if ret == 0:
+        # Request to connect completed immediately.
+        retFuture.complete()
+      else:
+        let lastError = osLastError()
+        if lastError.int32 == EINTR or lastError.int32 == EINPROGRESS:
+          addWrite(AsyncFD(socket.fd), cb)
+        else:
+          retFuture.fail(newOSError(lastError))
+
+  proc bindUnix*(socket: AsyncSocket, path: string) {.
+    tags: [ReadIOEffect].} =
+    ## Binds Unix socket to `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    when not defined(nimdoc):
+      var socketAddr = makeUnixAddr(path)
+      if socket.fd.bindAddr(cast[ptr SockAddr](addr socketAddr),
+          (offsetOf(socketAddr, sun_path) + path.len + 1).SockLen) != 0'i32:
+        raiseOSError(osLastError())
+
+elif defined(nimdoc):
+
+  proc connectUnix*(socket: AsyncSocket, path: string): owned(Future[void]) =
+    ## Binds Unix socket to `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    discard
+
+  proc bindUnix*(socket: AsyncSocket, path: string) =
+    ## Binds Unix socket to `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    discard
+
+proc close*(socket: AsyncSocket) =
+  ## Closes the socket.
+  if socket.closed: return
+
+  defer:
+    socket.fd.AsyncFD.closeSocket()
+    socket.closed = true # TODO: Add extra debugging checks for this.
+
+  when defineSsl:
+    if socket.isSsl:
+      let res =
+        # Don't call SSL_shutdown if the connection has not been fully
+        # established, see:
+        # https://github.com/openssl/openssl/issues/710#issuecomment-253897666
+        if not socket.sslNoShutdown and SSL_in_init(socket.sslHandle) == 0:
+          ErrClearError()
+          SSL_shutdown(socket.sslHandle)
+        else:
+          0
+      SSL_free(socket.sslHandle)
+      if res == 0:
+        discard
+      elif res != 1:
+        raiseSSLError()
+
+when defineSsl:
+  proc sslHandle*(self: AsyncSocket): SslPtr =
+    ## Retrieve the ssl pointer of `socket`.
+    ## Useful for interfacing with `openssl`.
+    self.sslHandle
+  
+  proc wrapSocket*(ctx: SslContext, socket: AsyncSocket) =
+    ## Wraps a socket in an SSL context. This function effectively turns
+    ## `socket` into an SSL socket.
+    ##
+    ## **Disclaimer**: This code is not well tested, may be very unsafe and
+    ## prone to security vulnerabilities.
+    socket.isSsl = true
+    socket.sslContext = ctx
+    socket.sslHandle = SSL_new(socket.sslContext.context)
+    if socket.sslHandle == nil:
+      raiseSSLError()
+
+    socket.bioIn = bioNew(bioSMem())
+    socket.bioOut = bioNew(bioSMem())
+    sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut)
+
+    socket.sslNoShutdown = true
+
+  proc wrapConnectedSocket*(ctx: SslContext, socket: AsyncSocket,
+                            handshake: SslHandshakeType,
+                            hostname: string = "") =
+    ## Wraps a connected socket in an SSL context. This function effectively
+    ## turns `socket` into an SSL socket.
+    ## `hostname` should be specified so that the client knows which hostname
+    ## the server certificate should be validated against.
+    ##
+    ## This should be called on a connected socket, and will perform
+    ## an SSL handshake immediately.
+    ##
+    ## **Disclaimer**: This code is not well tested, may be very unsafe and
+    ## prone to security vulnerabilities.
+    wrapSocket(ctx, socket)
+
+    case handshake
+    of handshakeAsClient:
+      if hostname.len > 0 and not isIpAddress(hostname):
+        # Set the SNI address for this connection. This call can fail if
+        # we're not using TLSv1+.
+        discard SSL_set_tlsext_host_name(socket.sslHandle, hostname)
+      sslSetConnectState(socket.sslHandle)
+    of handshakeAsServer:
+      sslSetAcceptState(socket.sslHandle)
+
+  proc getPeerCertificates*(socket: AsyncSocket): seq[Certificate] {.since: (1, 1).} =
+    ## Returns the certificate chain received by the peer we are connected to
+    ## through the given socket.
+    ## The handshake must have been completed and the certificate chain must
+    ## have been verified successfully or else an empty sequence is returned.
+    ## The chain is ordered from leaf certificate to root certificate.
+    if not socket.isSsl:
+      result = newSeq[Certificate]()
+    else:
+      result = getPeerCertificates(socket.sslHandle)
+
+proc getSockOpt*(socket: AsyncSocket, opt: SOBool, level = SOL_SOCKET): bool {.
+  tags: [ReadIOEffect].} =
+  ## Retrieves option `opt` as a boolean value.
+  var res = getSockOptInt(socket.fd, cint(level), toCInt(opt))
+  result = res != 0
+
+proc setSockOpt*(socket: AsyncSocket, opt: SOBool, value: bool,
+    level = SOL_SOCKET) {.tags: [WriteIOEffect].} =
+  ## Sets option `opt` to a boolean value specified by `value`.
+  var valuei = cint(if value: 1 else: 0)
+  setSockOptInt(socket.fd, cint(level), toCInt(opt), valuei)
+
+proc isSsl*(socket: AsyncSocket): bool =
+  ## Determines whether `socket` is a SSL socket.
+  socket.isSsl
+
+proc getFd*(socket: AsyncSocket): SocketHandle =
+  ## Returns the socket's file descriptor.
+  return socket.fd
+
+proc isClosed*(socket: AsyncSocket): bool =
+  ## Determines whether the socket has been closed.
+  return socket.closed
+
+proc sendTo*(socket: AsyncSocket, address: string, port: Port, data: string,
+             flags = {SocketFlag.SafeDisconn}): owned(Future[void])
+            {.async, since: (1, 3).} =
+  ## This proc sends `data` to the specified `address`, which may be an IP
+  ## address or a hostname. If a hostname is specified this function will try
+  ## each IP of that hostname. The returned future will complete once all data
+  ## has been sent.
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## This proc is normally used with connectionless sockets (UDP sockets).
+  assert(socket.protocol != IPPROTO_TCP,
+         "Cannot `sendTo` on a TCP socket. Use `send` instead")
+  assert(not socket.closed, "Cannot `sendTo` on a closed socket")
+
+  let aiList = getAddrInfo(address, port, socket.domain, socket.sockType,
+                           socket.protocol)
+
+  var
+    it = aiList
+    success = false
+    lastException: ref Exception
+
+  while it != nil:
+    let fut = sendTo(socket.fd.AsyncFD, cstring(data), len(data), it.ai_addr,
+                     it.ai_addrlen.SockLen, flags)
+
+    yield fut
+
+    if not fut.failed:
+      success = true
+
+      break
+
+    lastException = fut.readError()
+
+    it = it.ai_next
+
+  freeAddrInfo(aiList)
+
+  if not success:
+    if lastException != nil:
+      raise lastException
+    else:
+      raise newException(IOError, "Couldn't resolve address: " & address)
+
+proc recvFrom*(socket: AsyncSocket, data: FutureVar[string], size: int,
+               address: FutureVar[string], port: FutureVar[Port],
+               flags = {SocketFlag.SafeDisconn}): owned(Future[int])
+              {.async, since: (1, 3).} =
+  ## Receives a datagram data from `socket` into `data`, which must be at
+  ## least of size `size`. The address and port of datagram's sender will be
+  ## stored into `address` and `port`, respectively. Returned future will
+  ## complete once one datagram has been received, and will return size of
+  ## packet received.
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## This proc is normally used with connectionless sockets (UDP sockets).
+  ##
+  ## **Notes**
+  ## * `data` must be initialized to the length of `size`.
+  ## * `address` must be initialized to 46 in length.
+  template adaptRecvFromToDomain(domain: Domain) =
+    var lAddr = sizeof(sAddr).SockLen
+
+    result = await recvFromInto(AsyncFD(getFd(socket)), cstring(data.mget()), size,
+                                cast[ptr SockAddr](addr sAddr), addr lAddr,
+                                flags)
+
+    data.mget().setLen(result)
+    data.complete()
+
+    getAddrString(cast[ptr SockAddr](addr sAddr), address.mget())
+
+    address.complete()
+
+    when domain == AF_INET6:
+      port.complete(ntohs(sAddr.sin6_port).Port)
+    else:
+      port.complete(ntohs(sAddr.sin_port).Port)
+
+  assert(socket.protocol != IPPROTO_TCP,
+         "Cannot `recvFrom` on a TCP socket. Use `recv` or `recvInto` instead")
+  assert(not socket.closed, "Cannot `recvFrom` on a closed socket")
+  assert(size == len(data.mget()),
+         "`date` was not initialized correctly. `size` != `len(data.mget())`")
+  assert(46 == len(address.mget()),
+         "`address` was not initialized correctly. 46 != `len(address.mget())`")
+
+  case socket.domain
+  of AF_INET6:
+    var sAddr: Sockaddr_in6
+    adaptRecvFromToDomain(AF_INET6)
+  of AF_INET:
+    var sAddr: Sockaddr_in
+    adaptRecvFromToDomain(AF_INET)
+  else:
+    raise newException(ValueError, "Unknown socket address family")
+
+proc recvFrom*(socket: AsyncSocket, size: int,
+               flags = {SocketFlag.SafeDisconn}):
+              owned(Future[tuple[data: string, address: string, port: Port]])
+              {.async, since: (1, 3).} =
+  ## Receives a datagram data from `socket`, which must be at least of size
+  ## `size`. Returned future will complete once one datagram has been received
+  ## and will return tuple with: data of packet received; and address and port
+  ## of datagram's sender.
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## This proc is normally used with connectionless sockets (UDP sockets).
+  var
+    data = newFutureVar[string]()
+    address = newFutureVar[string]()
+    port = newFutureVar[Port]()
+
+  data.mget().setLen(size)
+  address.mget().setLen(46)
+
+  let read = await recvFrom(socket, data, size, address, port, flags)
+
+  result = (data.mget(), address.mget(), port.mget())
+
+when not defined(testing) and isMainModule:
+  type
+    TestCases = enum
+      HighClient, LowClient, LowServer
+
+  const test = HighClient
+
+  when test == HighClient:
+    proc main() {.async.} =
+      var sock = newAsyncSocket()
+      await sock.connect("irc.freenode.net", Port(6667))
+      while true:
+        let line = await sock.recvLine()
+        if line == "":
+          echo("Disconnected")
+          break
+        else:
+          echo("Got line: ", line)
+    asyncCheck main()
+  elif test == LowClient:
+    var sock = newAsyncSocket()
+    var f = connect(sock, "irc.freenode.net", Port(6667))
+    f.callback =
+      proc (future: Future[void]) =
+        echo("Connected in future!")
+        for i in 0 .. 50:
+          var recvF = recv(sock, 10)
+          recvF.callback =
+            proc (future: Future[string]) =
+              echo("Read ", future.read.len, ": ", future.read.repr)
+  elif test == LowServer:
+    var sock = newAsyncSocket()
+    sock.bindAddr(Port(6667))
+    sock.listen()
+    proc onAccept(future: Future[AsyncSocket]) =
+      let client = future.read
+      echo "Accepted ", client.fd.cint
+      var t = send(client, "test\c\L")
+      t.callback =
+        proc (future: Future[void]) =
+          echo("Send")
+          client.close()
+
+      var f = accept(sock)
+      f.callback = onAccept
+
+    var f = accept(sock)
+    f.callback = onAccept
+  runForever()
diff --git a/lib/pure/asyncstreams.nim b/lib/pure/asyncstreams.nim
new file mode 100644
index 000000000..c97b98d55
--- /dev/null
+++ b/lib/pure/asyncstreams.nim
@@ -0,0 +1,147 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Unstable API.
+
+import std/asyncfutures
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+import std/deques
+
+type
+  FutureStream*[T] = ref object ## Special future that acts as
+                                ## a queue. Its API is still
+                                ## experimental and so is
+                                ## subject to change.
+    queue: Deque[T]
+    finished: bool
+    cb: proc () {.closure, gcsafe.}
+    error*: ref Exception
+
+proc newFutureStream*[T](fromProc = "unspecified"): FutureStream[T] =
+  ## Create a new `FutureStream`. This future's callback is activated when
+  ## two events occur:
+  ##
+  ## * New data is written into the future stream.
+  ## * The future stream is completed (this means that no more data will be
+  ##   written).
+  ##
+  ## Specifying `fromProc`, which is a string specifying the name of the proc
+  ## that this future belongs to, is a good habit as it helps with debugging.
+  ##
+  ## **Note:** The API of FutureStream is still new and so has a higher
+  ## likelihood of changing in the future.
+  result = FutureStream[T](finished: false, cb: nil)
+  result.queue = initDeque[T]()
+
+proc complete*[T](future: FutureStream[T]) =
+  ## Completes a `FutureStream` signalling the end of data.
+  assert(future.error == nil, "Trying to complete failed stream")
+  future.finished = true
+  if not future.cb.isNil:
+    future.cb()
+
+proc fail*[T](future: FutureStream[T], error: ref Exception) =
+  ## Completes `future` with `error`.
+  assert(not future.finished)
+  future.finished = true
+  future.error = error
+  if not future.cb.isNil:
+    future.cb()
+
+proc `callback=`*[T](future: FutureStream[T],
+    cb: proc (future: FutureStream[T]) {.closure, gcsafe.}) =
+  ## Sets the callback proc to be called when data was placed inside the
+  ## future stream.
+  ##
+  ## The callback is also called when the future is completed. So you should
+  ## use `finished` to check whether data is available.
+  ##
+  ## If the future stream already has data or is finished then `cb` will be
+  ## called immediately.
+  proc named() = cb(future)
+  future.cb = named
+  if future.queue.len > 0 or future.finished:
+    callSoon(future.cb)
+
+proc finished*[T](future: FutureStream[T]): bool =
+  ## Check if a `FutureStream` is finished. `true` value means that
+  ## no more data will be placed inside the stream *and* that there is
+  ## no data waiting to be retrieved.
+  result = future.finished and future.queue.len == 0
+
+proc failed*[T](future: FutureStream[T]): bool =
+  ## Determines whether `future` completed with an error.
+  return future.error != nil
+
+proc write*[T](future: FutureStream[T], value: T): Future[void] =
+  ## Writes the specified value inside the specified future stream.
+  ##
+  ## This will raise `ValueError` if `future` is finished.
+  result = newFuture[void]("FutureStream.put")
+  if future.finished:
+    let msg = "FutureStream is finished and so no longer accepts new data."
+    result.fail(newException(ValueError, msg))
+    return
+  # TODO: Implement limiting of the streams storage to prevent it growing
+  # infinitely when no reads are occurring.
+  future.queue.addLast(value)
+  if not future.cb.isNil: future.cb()
+  result.complete()
+
+proc read*[T](future: FutureStream[T]): owned(Future[(bool, T)]) =
+  ## Returns a future that will complete when the `FutureStream` has data
+  ## placed into it. The future will be completed with the oldest
+  ## value stored inside the stream. The return value will also determine
+  ## whether data was retrieved, `false` means that the future stream was
+  ## completed and no data was retrieved.
+  ##
+  ## This function will remove the data that was returned from the underlying
+  ## `FutureStream`.
+  var resFut = newFuture[(bool, T)]("FutureStream.take")
+  let savedCb = future.cb
+  proc newCb(fs: FutureStream[T]) =
+    # Exit early if `resFut` is already complete. (See #8994).
+    if resFut.finished: return
+
+    # We don't want this callback called again.
+    #future.cb = nil
+
+    # The return value depends on whether the FutureStream has finished.
+    var res: (bool, T)
+    if finished(fs):
+      # Remember, this callback is called when the FutureStream is completed.
+      res[0] = false
+    else:
+      res[0] = true
+      res[1] = fs.queue.popFirst()
+
+    if fs.failed:
+      resFut.fail(fs.error)
+    else:
+      resFut.complete(res)
+
+    # If the saved callback isn't nil then let's call it.
+    if not savedCb.isNil:
+      if fs.queue.len > 0:
+        savedCb()
+      else:
+        future.cb = savedCb
+
+  if future.queue.len > 0 or future.finished:
+    newCb(future)
+  else:
+    future.callback = newCb
+  return resFut
+
+proc len*[T](future: FutureStream[T]): int =
+  ## Returns the amount of data pieces inside the stream.
+  future.queue.len
diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim
new file mode 100644
index 000000000..591d22cc0
--- /dev/null
+++ b/lib/pure/base64.nim
@@ -0,0 +1,273 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2010 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a base64 encoder and decoder.
+##
+## Unstable API.
+##
+## Base64 is an encoding and decoding technique used to convert binary
+## data to an ASCII string format.
+## Each Base64 digit represents exactly 6 bits of data. Three 8-bit
+## bytes (i.e., a total of 24 bits) can therefore be represented by
+## four 6-bit Base64 digits.
+
+##[
+# Basic usage
+## Encoding data
+]##
+
+runnableExamples:
+  let encoded = encode("Hello World")
+  assert encoded == "SGVsbG8gV29ybGQ="
+
+##
+## Apart from strings you can also encode lists of integers or characters:
+##
+
+runnableExamples:
+  let encodedInts = encode([1'u8,2,3])
+  assert encodedInts == "AQID"
+  let encodedChars = encode(['h','e','y'])
+  assert encodedChars == "aGV5"
+
+##[
+## Decoding data
+]##
+
+runnableExamples:
+  let decoded = decode("SGVsbG8gV29ybGQ=")
+  assert decoded == "Hello World"
+
+##[
+## URL Safe Base64
+]##
+
+runnableExamples:
+  assert encode("c\xf7>", safe = true) == "Y_c-"
+  assert encode("c\xf7>", safe = false) == "Y/c+"
+
+## See also
+## ========
+##
+## * `hashes module<hashes.html>`_ for efficient computations of hash values for diverse Nim types
+## * `md5 module<md5.html>`_ for the MD5 checksum algorithm
+## * `sha1 module<sha1.html>`_ for the SHA-1 checksum algorithm
+
+template cbBase(a, b): untyped = [
+  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+  'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+  'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', a, b]
+
+const
+  cb64 = cbBase('+', '/')
+  cb64safe = cbBase('-', '_')
+
+const
+  invalidChar = 255
+
+template encodeSize(size: int): int = (size * 4 div 3) + 6
+
+template encodeInternal(s, alphabet: typed): untyped =
+  ## encodes `s` into base64 representation.
+
+  result.setLen(encodeSize(s.len))
+
+  let
+    padding = s.len mod 3
+    inputEnds = s.len - padding
+
+  var
+    inputIndex = 0
+    outputIndex = 0
+    n: uint32
+    b: uint32
+
+  template inputByte(exp: untyped) =
+    b = uint32(s[inputIndex])
+    n = exp
+    inc inputIndex
+
+  template outputChar(x: typed) =
+    result[outputIndex] = alphabet[x and 63]
+    inc outputIndex
+
+  template outputChar(c: char) =
+    result[outputIndex] = c
+    inc outputIndex
+
+  while inputIndex != inputEnds:
+    inputByte(b shl 16)
+    inputByte(n or b shl 8)
+    inputByte(n or b shl 0)
+    outputChar(n shr 18)
+    outputChar(n shr 12)
+    outputChar(n shr 6)
+    outputChar(n shr 0)
+
+  if padding == 1:
+    inputByte(b shl 16)
+    outputChar(n shr 18)
+    outputChar(n shr 12)
+    outputChar('=')
+    outputChar('=')
+
+  elif padding == 2:
+    inputByte(b shl 16)
+    inputByte(n or b shl 8)
+    outputChar(n shr 18)
+    outputChar(n shr 12)
+    outputChar(n shr 6)
+    outputChar('=')
+
+  result.setLen(outputIndex)
+
+template encodeImpl() {.dirty.} =
+  if safe:
+    encodeInternal(s, cb64safe)
+  else:
+    encodeInternal(s, cb64)
+
+proc encode*[T: byte|char](s: openArray[T], safe = false): string =
+  ## Encodes `s` into base64 representation.
+  ##
+  ## If `safe` is `true` then it will encode using the
+  ## URL-Safe and Filesystem-safe standard alphabet characters,
+  ## which substitutes `-` instead of `+` and `_` instead of `/`.
+  ## * https://en.wikipedia.org/wiki/Base64#URL_applications
+  ## * https://tools.ietf.org/html/rfc4648#page-7
+  ##
+  ## **See also:**
+  ## * `decode proc<#decode,string>`_ for decoding a string
+  runnableExamples:
+    assert encode("Hello World") == "SGVsbG8gV29ybGQ="
+    assert encode(['n', 'i', 'm']) == "bmlt"
+    assert encode(@['n', 'i', 'm']) == "bmlt"
+    assert encode([1'u8, 2, 3, 4, 5]) == "AQIDBAU="
+  encodeImpl()
+
+proc encode*[T: SomeInteger and not byte](s: openArray[T], safe = false): string
+  {.deprecated: "use `byte` or `char` instead".} =
+  encodeImpl()
+
+proc encodeMime*(s: string, lineLen = 75.Positive, newLine = "\r\n",
+                 safe = false): string =
+  ## Encodes `s` into base64 representation as lines.
+  ## Used in email MIME format, use `lineLen` and `newline`.
+  ##
+  ## This procedure encodes a string according to MIME spec.
+  ##
+  ## If `safe` is `true` then it will encode using the
+  ## URL-Safe and Filesystem-safe standard alphabet characters,
+  ## which substitutes `-` instead of `+` and `_` instead of `/`.
+  ## * https://en.wikipedia.org/wiki/Base64#URL_applications
+  ## * https://tools.ietf.org/html/rfc4648#page-7
+  ##
+  ## **See also:**
+  ## * `encode proc<#encode,openArray[T]>`_ for encoding an openArray
+  ## * `decode proc<#decode,string>`_ for decoding a string
+  runnableExamples:
+    assert encodeMime("Hello World", 4, "\n") == "SGVs\nbG8g\nV29y\nbGQ="
+  template cpy(l, src, idx) =
+    b = l
+    while i < b:
+      result[i] = src[idx]
+      inc i
+      inc idx
+
+  if s.len == 0: return
+  let e = encode(s, safe)
+  if e.len <= lineLen or newLine.len == 0:
+    return e
+  result = newString(e.len + newLine.len * ((e.len div lineLen) - int(e.len mod lineLen == 0)))
+  var i, j, k, b: int
+  let nd = e.len - lineLen
+  while j < nd:
+    cpy(i + lineLen, e, j)
+    cpy(i + newLine.len, newLine, k)
+    k = 0
+  cpy(result.len, e, j)
+
+proc initDecodeTable*(): array[256, char] =
+  # computes a decode table at compile time
+  for i in 0 ..< 256:
+    let ch = char(i)
+    var code = invalidChar
+    if ch >= 'A' and ch <= 'Z': code = i - 0x00000041
+    if ch >= 'a' and ch <= 'z': code = i - 0x00000047
+    if ch >= '0' and ch <= '9': code = i + 0x00000004
+    if ch == '+' or ch == '-': code = 0x0000003E
+    if ch == '/' or ch == '_': code = 0x0000003F
+    result[i] = char(code)
+
+const
+  decodeTable = initDecodeTable()
+
+proc decode*(s: string): string =
+  ## Decodes string `s` in base64 representation back into its original form.
+  ## The initial whitespace is skipped.
+  ##
+  ## **See also:**
+  ## * `encode proc<#encode,openArray[T]>`_ for encoding an openarray
+  runnableExamples:
+    assert decode("SGVsbG8gV29ybGQ=") == "Hello World"
+    assert decode("  SGVsbG8gV29ybGQ=") == "Hello World"
+  if s.len == 0: return
+
+  proc decodeSize(size: int): int =
+    return (size * 3 div 4) + 6
+
+  template inputChar(x: untyped) =
+    let x = int decodeTable[ord(s[inputIndex])]
+    if x == invalidChar:
+      raise newException(ValueError,
+        "Invalid base64 format character `" & s[inputIndex] &
+        "` (ord " & $s[inputIndex].ord & ") at location " & $inputIndex & ".")
+    inc inputIndex
+
+  template outputChar(x: untyped) =
+    result[outputIndex] = char(x and 255)
+    inc outputIndex
+
+  # pre allocate output string once
+  result.setLen(decodeSize(s.len))
+  var
+    inputIndex = 0
+    outputIndex = 0
+    inputLen = s.len
+    inputEnds = 0
+  # strip trailing characters
+  while inputLen > 0 and s[inputLen - 1] in {'\n', '\r', ' ', '='}:
+    dec inputLen
+  # hot loop: read 4 characters at at time
+  inputEnds = inputLen - 4
+  while inputIndex <= inputEnds:
+    while s[inputIndex] in {'\n', '\r', ' '}:
+      inc inputIndex
+    inputChar(a)
+    inputChar(b)
+    inputChar(c)
+    inputChar(d)
+    outputChar(a shl 2 or b shr 4)
+    outputChar(b shl 4 or c shr 2)
+    outputChar(c shl 6 or d shr 0)
+  # do the last 2 or 3 characters
+  var leftLen = abs((inputIndex - inputLen) mod 4)
+  if leftLen == 2:
+    inputChar(a)
+    inputChar(b)
+    outputChar(a shl 2 or b shr 4)
+  elif leftLen == 3:
+    inputChar(a)
+    inputChar(b)
+    inputChar(c)
+    outputChar(a shl 2 or b shr 4)
+    outputChar(b shl 4 or c shr 2)
+  result.setLen(outputIndex)
diff --git a/lib/pure/bitops.nim b/lib/pure/bitops.nim
new file mode 100644
index 000000000..0d3351ee5
--- /dev/null
+++ b/lib/pure/bitops.nim
@@ -0,0 +1,883 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim Authors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a series of low level methods for bit manipulation.
+##
+## By default, compiler intrinsics are used where possible to improve performance
+## on supported compilers: `GCC`, `LLVM_GCC`, `CLANG`, `VCC`, `ICC`.
+##
+## The module will fallback to pure nim procs in case the backend is not supported.
+## You can also use the flag `noIntrinsicsBitOpts` to disable compiler intrinsics.
+##
+## This module is also compatible with other backends: `JavaScript`, `NimScript`
+## as well as the `compiletime VM`.
+##
+## As a result of using optimized functions/intrinsics, some functions can return
+## undefined results if the input is invalid. You can use the flag `noUndefinedBitOpts`
+## to force predictable behaviour for all input, causing a small performance hit.
+##
+## At this time only `fastLog2`, `firstSetBit`, `countLeadingZeroBits` and `countTrailingZeroBits`
+## may return undefined and/or platform dependent values if given invalid input.
+
+import std/macros
+import std/private/since
+from std/private/bitops_utils import forwardImpl, castToUnsigned
+
+func bitnot*[T: SomeInteger](x: T): T {.magic: "BitnotI".}
+  ## Computes the `bitwise complement` of the integer `x`.
+
+func internalBitand[T: SomeInteger](x, y: T): T {.magic: "BitandI".}
+
+func internalBitor[T: SomeInteger](x, y: T): T {.magic: "BitorI".}
+
+func internalBitxor[T: SomeInteger](x, y: T): T {.magic: "BitxorI".}
+
+macro bitand*[T: SomeInteger](x, y: T; z: varargs[T]): T =
+  ## Computes the `bitwise and` of all arguments collectively.
+  let fn = bindSym("internalBitand")
+  result = newCall(fn, x, y)
+  for extra in z:
+    result = newCall(fn, result, extra)
+
+macro bitor*[T: SomeInteger](x, y: T; z: varargs[T]): T =
+  ## Computes the `bitwise or` of all arguments collectively.
+  let fn = bindSym("internalBitor")
+  result = newCall(fn, x, y)
+  for extra in z:
+    result = newCall(fn, result, extra)
+
+macro bitxor*[T: SomeInteger](x, y: T; z: varargs[T]): T =
+  ## Computes the `bitwise xor` of all arguments collectively.
+  let fn = bindSym("internalBitxor")
+  result = newCall(fn, x, y)
+  for extra in z:
+    result = newCall(fn, result, extra)
+
+
+type BitsRange*[T] = range[0..sizeof(T)*8-1]
+  ## A range with all bit positions for type `T`.
+
+template typeMasked[T: SomeInteger](x: T): T =
+  when defined(js):
+    T(x and ((0xffffffff_ffffffff'u shr (64 - sizeof(T) * 8))))
+  else:
+    x
+
+func bitsliced*[T: SomeInteger](v: T; slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Returns an extracted (and shifted) slice of bits from `v`.
+  runnableExamples:
+    doAssert 0b10111.bitsliced(2 .. 4) == 0b101
+    doAssert 0b11100.bitsliced(0 .. 2) == 0b100
+    doAssert 0b11100.bitsliced(0 ..< 3) == 0b100
+
+  let
+    upmost = sizeof(T) * 8 - 1
+    uv     = v.castToUnsigned
+  ((uv shl (upmost - slice.b)).typeMasked shr (upmost - slice.b + slice.a)).T
+
+proc bitslice*[T: SomeInteger](v: var T; slice: Slice[int]) {.inline, since: (1, 3).} =
+  ## Mutates `v` into an extracted (and shifted) slice of bits from `v`.
+  runnableExamples:
+    var x = 0b101110
+    x.bitslice(2 .. 4)
+    doAssert x == 0b011
+
+  let
+    upmost = sizeof(T) * 8 - 1
+    uv     = v.castToUnsigned
+  v = ((uv shl (upmost - slice.b)).typeMasked shr (upmost - slice.b + slice.a)).T
+
+func toMask*[T: SomeInteger](slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Creates a bitmask based on a slice of bits.
+  runnableExamples:
+    doAssert toMask[int32](1 .. 3) == 0b1110'i32
+    doAssert toMask[int32](0 .. 3) == 0b1111'i32
+
+  let
+    upmost = sizeof(T) * 8 - 1
+    bitmask = bitnot(0.T).castToUnsigned
+  ((bitmask shl (upmost - slice.b + slice.a)).typeMasked shr (upmost - slice.b)).T
+
+proc masked*[T: SomeInteger](v, mask :T): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with only the `1` bits from `mask` matching those of
+  ## `v` set to 1.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.masked(0b0000_1010'u8) == 0b0000_0010'u8
+
+  bitand(v, mask)
+
+func masked*[T: SomeInteger](v: T; slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with only the `1` bits in the range of `slice`
+  ## matching those of `v` set to 1.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_1011'u8
+    doAssert v.masked(1 .. 3) == 0b0000_1010'u8
+
+  bitand(v, toMask[T](slice))
+
+proc mask*[T: SomeInteger](v: var T; mask: T) {.inline, since: (1, 3).} =
+  ## Mutates `v`, with only the `1` bits from `mask` matching those of
+  ## `v` set to 1.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.mask(0b0000_1010'u8)
+    doAssert v == 0b0000_0010'u8
+
+  v = bitand(v, mask)
+
+proc mask*[T: SomeInteger](v: var T; slice: Slice[int]) {.inline, since: (1, 3).} =
+  ## Mutates `v`, with only the `1` bits in the range of `slice`
+  ## matching those of `v` set to 1.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_1011'u8
+    v.mask(1 .. 3)
+    doAssert v == 0b0000_1010'u8
+
+  v = bitand(v, toMask[T](slice))
+
+func setMasked*[T: SomeInteger](v, mask :T): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits from `mask` set to 1.
+  ##
+  ## Effectively maps to a `bitor <#bitor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.setMasked(0b0000_1010'u8) == 0b0000_1011'u8
+
+  bitor(v, mask)
+
+func setMasked*[T: SomeInteger](v: T; slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits in the range of `slice` set to 1.
+  ##
+  ## Effectively maps to a `bitor <#bitor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.setMasked(2 .. 3) == 0b0000_1111'u8
+
+  bitor(v, toMask[T](slice))
+
+proc setMask*[T: SomeInteger](v: var T; mask: T) {.inline.} =
+  ## Mutates `v`, with all the `1` bits from `mask` set to 1.
+  ##
+  ## Effectively maps to a `bitor <#bitor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.setMask(0b0000_1010'u8)
+    doAssert v == 0b0000_1011'u8
+
+  v = bitor(v, mask)
+
+proc setMask*[T: SomeInteger](v: var T; slice: Slice[int]) {.inline, since: (1, 3).} =
+  ## Mutates `v`, with all the `1` bits in the range of `slice` set to 1.
+  ##
+  ## Effectively maps to a `bitor <#bitor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.setMask(2 .. 3)
+    doAssert v == 0b0000_1111'u8
+
+  v = bitor(v, toMask[T](slice))
+
+func clearMasked*[T: SomeInteger](v, mask :T): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits from `mask` set to 0.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation
+  ## with an *inverted mask*.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.clearMasked(0b0000_1010'u8) == 0b0000_0001'u8
+
+  bitand(v, bitnot(mask))
+
+func clearMasked*[T: SomeInteger](v: T; slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits in the range of `slice` set to 0.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation
+  ## with an *inverted mask*.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.clearMasked(1 .. 3) == 0b0000_0001'u8
+
+  bitand(v, bitnot(toMask[T](slice)))
+
+proc clearMask*[T: SomeInteger](v: var T; mask: T) {.inline.} =
+  ## Mutates `v`, with all the `1` bits from `mask` set to 0.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation
+  ## with an *inverted mask*.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.clearMask(0b0000_1010'u8)
+    doAssert v == 0b0000_0001'u8
+
+  v = bitand(v, bitnot(mask))
+
+proc clearMask*[T: SomeInteger](v: var T; slice: Slice[int]) {.inline, since: (1, 3).} =
+  ## Mutates `v`, with all the `1` bits in the range of `slice` set to 0.
+  ##
+  ## Effectively maps to a `bitand <#bitand.m,T,T,varargs[T]>`_ operation
+  ## with an *inverted mask*.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.clearMask(1 .. 3)
+    doAssert v == 0b0000_0001'u8
+
+  v = bitand(v, bitnot(toMask[T](slice)))
+
+func flipMasked*[T: SomeInteger](v, mask :T): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits from `mask` flipped.
+  ##
+  ## Effectively maps to a `bitxor <#bitxor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.flipMasked(0b0000_1010'u8) == 0b0000_1001'u8
+
+  bitxor(v, mask)
+
+func flipMasked*[T: SomeInteger](v: T; slice: Slice[int]): T {.inline, since: (1, 3).} =
+  ## Returns `v`, with all the `1` bits in the range of `slice` flipped.
+  ##
+  ## Effectively maps to a `bitxor <#bitxor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    let v = 0b0000_0011'u8
+    doAssert v.flipMasked(1 .. 3) == 0b0000_1101'u8
+
+  bitxor(v, toMask[T](slice))
+
+proc flipMask*[T: SomeInteger](v: var T; mask: T) {.inline.} =
+  ## Mutates `v`, with all the `1` bits from `mask` flipped.
+  ##
+  ## Effectively maps to a `bitxor <#bitxor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.flipMask(0b0000_1010'u8)
+    doAssert v == 0b0000_1001'u8
+
+  v = bitxor(v, mask)
+
+proc flipMask*[T: SomeInteger](v: var T; slice: Slice[int]) {.inline, since: (1, 3).} =
+  ## Mutates `v`, with all the `1` bits in the range of `slice` flipped.
+  ##
+  ## Effectively maps to a `bitxor <#bitxor.m,T,T,varargs[T]>`_ operation.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.flipMask(1 .. 3)
+    doAssert v == 0b0000_1101'u8
+
+  v = bitxor(v, toMask[T](slice))
+
+proc setBit*[T: SomeInteger](v: var T; bit: BitsRange[T]) {.inline.} =
+  ## Mutates `v`, with the bit at position `bit` set to 1.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.setBit(5'u8)
+    doAssert v == 0b0010_0011'u8
+
+  v.setMask(1.T shl bit)
+
+proc clearBit*[T: SomeInteger](v: var T; bit: BitsRange[T]) {.inline.} =
+  ## Mutates `v`, with the bit at position `bit` set to 0.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.clearBit(1'u8)
+    doAssert v == 0b0000_0001'u8
+
+  v.clearMask(1.T shl bit)
+
+proc flipBit*[T: SomeInteger](v: var T; bit: BitsRange[T]) {.inline.} =
+  ## Mutates `v`, with the bit at position `bit` flipped.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.flipBit(1'u8)
+    doAssert v == 0b0000_0001'u8
+
+    v = 0b0000_0011'u8
+    v.flipBit(2'u8)
+    doAssert v == 0b0000_0111'u8
+
+  v.flipMask(1.T shl bit)
+
+macro setBits*(v: typed; bits: varargs[typed]): untyped =
+  ## Mutates `v`, with the bits at positions `bits` set to 1.
+  runnableExamples:
+    var v = 0b0000_0011'u8
+    v.setBits(3, 5, 7)
+    doAssert v == 0b1010_1011'u8
+
+  bits.expectKind(nnkBracket)
+  result = newStmtList()
+  for bit in bits:
+    result.add newCall("setBit", v, bit)
+
+macro clearBits*(v: typed; bits: varargs[typed]): untyped =
+  ## Mutates `v`, with the bits at positions `bits` set to 0.
+  runnableExamples:
+    var v = 0b1111_1111'u8
+    v.clearBits(1, 3, 5, 7)
+    doAssert v == 0b0101_0101'u8
+
+  bits.expectKind(nnkBracket)
+  result = newStmtList()
+  for bit in bits:
+    result.add newCall("clearBit", v, bit)
+
+macro flipBits*(v: typed; bits: varargs[typed]): untyped =
+  ## Mutates `v`, with the bits at positions `bits` set to 0.
+  runnableExamples:
+    var v = 0b0000_1111'u8
+    v.flipBits(1, 3, 5, 7)
+    doAssert v == 0b1010_0101'u8
+
+  bits.expectKind(nnkBracket)
+  result = newStmtList()
+  for bit in bits:
+    result.add newCall("flipBit", v, bit)
+
+
+proc testBit*[T: SomeInteger](v: T; bit: BitsRange[T]): bool {.inline.} =
+  ## Returns true if the bit in `v` at positions `bit` is set to 1.
+  runnableExamples:
+    let v = 0b0000_1111'u8
+    doAssert v.testBit(0)
+    doAssert not v.testBit(7)
+
+  let mask = 1.T shl bit
+  return (v and mask) == mask
+
+# #### Pure Nim version ####
+
+func firstSetBitNim(x: uint32): int {.inline.} =
+  ## Returns the 1-based index of the least significant set bit of x, or if x is zero, returns zero.
+  # https://graphics.stanford.edu/%7Eseander/bithacks.html#ZerosOnRightMultLookup
+  const lookup: array[32, uint8] = [0'u8, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15,
+    25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]
+  let v = x.uint32
+  let k = not v + 1 # get two's complement # cast[uint32](-cast[int32](v))
+  result = 1 + lookup[uint32((v and k) * 0x077CB531'u32) shr 27].int
+
+func firstSetBitNim(x: uint64): int {.inline.} =
+  ## Returns the 1-based index of the least significant set bit of x, or if x is zero, returns zero.
+  # https://graphics.stanford.edu/%7Eseander/bithacks.html#ZerosOnRightMultLookup
+  let v = uint64(x)
+  var k = uint32(v and 0xFFFFFFFF'u32)
+  if k == 0:
+    k = uint32(v shr 32'u32) and 0xFFFFFFFF'u32
+    result = 32
+  else:
+    result = 0
+  result += firstSetBitNim(k)
+
+func fastlog2Nim(x: uint32): int {.inline.} =
+  ## Quickly find the log base 2 of a 32-bit or less integer.
+  # https://graphics.stanford.edu/%7Eseander/bithacks.html#IntegerLogDeBruijn
+  # https://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers
+  const lookup: array[32, uint8] = [0'u8, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18,
+    22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31]
+  var v = x.uint32
+  v = v or v shr 1 # first round down to one less than a power of 2
+  v = v or v shr 2
+  v = v or v shr 4
+  v = v or v shr 8
+  v = v or v shr 16
+  result = lookup[uint32(v * 0x07C4ACDD'u32) shr 27].int
+
+func fastlog2Nim(x: uint64): int {.inline.} =
+  ## Quickly find the log base 2 of a 64-bit integer.
+  # https://graphics.stanford.edu/%7Eseander/bithacks.html#IntegerLogDeBruijn
+  # https://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers
+  const lookup: array[64, uint8] = [0'u8, 58, 1, 59, 47, 53, 2, 60, 39, 48, 27, 54,
+    33, 42, 3, 61, 51, 37, 40, 49, 18, 28, 20, 55, 30, 34, 11, 43, 14, 22, 4, 62,
+    57, 46, 52, 38, 26, 32, 41, 50, 36, 17, 19, 29, 10, 13, 21, 56, 45, 25, 31,
+    35, 16, 9, 12, 44, 24, 15, 8, 23, 7, 6, 5, 63]
+  var v = x.uint64
+  v = v or v shr 1 # first round down to one less than a power of 2
+  v = v or v shr 2
+  v = v or v shr 4
+  v = v or v shr 8
+  v = v or v shr 16
+  v = v or v shr 32
+  result = lookup[(v * 0x03F6EAF2CD271461'u64) shr 58].int
+
+import system/countbits_impl
+
+const useBuiltinsRotate = (defined(amd64) or defined(i386)) and
+                          (defined(gcc) or defined(clang) or defined(vcc) or
+                           (defined(icl) and not defined(cpp))) and useBuiltins
+
+template parityImpl[T](value: T): int =
+  # formula id from: https://graphics.stanford.edu/%7Eseander/bithacks.html#ParityParallel
+  var v = value
+  when sizeof(T) == 8:
+    v = v xor (v shr 32)
+  when sizeof(T) >= 4:
+    v = v xor (v shr 16)
+  when sizeof(T) >= 2:
+    v = v xor (v shr 8)
+  v = v xor (v shr 4)
+  v = v and 0xf
+  ((0x6996'u shr v) and 1).int
+
+
+when useGCC_builtins:
+  # Returns the bit parity in value
+  proc builtin_parity(x: cuint): cint {.importc: "__builtin_parity", cdecl.}
+  proc builtin_parityll(x: culonglong): cint {.importc: "__builtin_parityll", cdecl.}
+
+  # Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero.
+  proc builtin_ffs(x: cint): cint {.importc: "__builtin_ffs", cdecl.}
+  proc builtin_ffsll(x: clonglong): cint {.importc: "__builtin_ffsll", cdecl.}
+
+  # Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
+  proc builtin_clz(x: cuint): cint {.importc: "__builtin_clz", cdecl.}
+  proc builtin_clzll(x: culonglong): cint {.importc: "__builtin_clzll", cdecl.}
+
+  # Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
+  proc builtin_ctz(x: cuint): cint {.importc: "__builtin_ctz", cdecl.}
+  proc builtin_ctzll(x: culonglong): cint {.importc: "__builtin_ctzll", cdecl.}
+
+elif useVCC_builtins:
+  # Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).
+  func bitScanReverse(index: ptr culong, mask: culong): uint8 {.
+      importc: "_BitScanReverse", header: "<intrin.h>".}
+  func bitScanReverse64(index: ptr culong, mask: uint64): uint8 {.
+      importc: "_BitScanReverse64", header: "<intrin.h>".}
+
+  # Search the mask data from least significant bit (LSB) to the most significant bit (MSB) for a set bit (1).
+  func bitScanForward(index: ptr culong, mask: culong): uint8 {.
+      importc: "_BitScanForward", header: "<intrin.h>".}
+  func bitScanForward64(index: ptr culong, mask: uint64): uint8 {.
+      importc: "_BitScanForward64", header: "<intrin.h>".}
+
+  template vcc_scan_impl(fnc: untyped; v: untyped): int =
+    var index {.inject.}: culong = 0
+    discard fnc(index.addr, v)
+    index.int
+
+elif useICC_builtins:
+  # Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
+  func bitScanForward(p: ptr uint32, b: uint32): uint8 {.
+      importc: "_BitScanForward", header: "<immintrin.h>".}
+  func bitScanForward64(p: ptr uint32, b: uint64): uint8 {.
+      importc: "_BitScanForward64", header: "<immintrin.h>".}
+
+  # Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
+  func bitScanReverse(p: ptr uint32, b: uint32): uint8 {.
+      importc: "_BitScanReverse", header: "<immintrin.h>".}
+  func bitScanReverse64(p: ptr uint32, b: uint64): uint8 {.
+      importc: "_BitScanReverse64", header: "<immintrin.h>".}
+
+  template icc_scan_impl(fnc: untyped; v: untyped): int =
+    var index: uint32
+    discard fnc(index.addr, v)
+    index.int
+
+func countSetBits*(x: SomeInteger): int {.inline.} =
+  ## Counts the set bits in an integer (also called `Hamming weight`:idx:).
+  runnableExamples:
+    doAssert countSetBits(0b0000_0011'u8) == 2
+    doAssert countSetBits(0b1010_1010'u8) == 4
+
+  result = countSetBitsImpl(x)
+
+func popcount*(x: SomeInteger): int {.inline.} =
+  ## Alias for `countSetBits <#countSetBits,SomeInteger>`_ (Hamming weight).
+  result = countSetBits(x)
+
+func parityBits*(x: SomeInteger): int {.inline.} =
+  ## Calculate the bit parity in an integer. If the number of 1-bits
+  ## is odd, the parity is 1, otherwise 0.
+  runnableExamples:
+    doAssert parityBits(0b0000_0000'u8) == 0
+    doAssert parityBits(0b0101_0001'u8) == 1
+    doAssert parityBits(0b0110_1001'u8) == 0
+    doAssert parityBits(0b0111_1111'u8) == 1
+
+  # Can be used a base if creating ASM version.
+  # https://stackoverflow.com/questions/21617970/how-to-check-if-value-has-even-parity-of-bits-or-odd
+  let x = x.castToUnsigned
+  when nimvm:
+    result = forwardImpl(parityImpl, x)
+  else:
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = builtin_parity(x.uint32).int
+      else: result = builtin_parityll(x.uint64).int
+    else:
+      when sizeof(x) <= 4: result = parityImpl(x.uint32)
+      else: result = parityImpl(x.uint64)
+
+func firstSetBit*(x: SomeInteger): int {.inline.} =
+  ## Returns the 1-based index of the least significant set bit of `x`.
+  ## If `x` is zero, when `noUndefinedBitOpts` is set, the result is 0,
+  ## otherwise the result is undefined.
+  runnableExamples:
+    doAssert firstSetBit(0b0000_0001'u8) == 1
+    doAssert firstSetBit(0b0000_0010'u8) == 2
+    doAssert firstSetBit(0b0000_0100'u8) == 3
+    doAssert firstSetBit(0b0000_1000'u8) == 4
+    doAssert firstSetBit(0b0000_1111'u8) == 1
+
+  # GCC builtin 'builtin_ffs' already handle zero input.
+  let x = x.castToUnsigned
+  when nimvm:
+    when noUndefined:
+      if x == 0:
+        return 0
+    result = forwardImpl(firstSetBitNim, x)
+  else:
+    when noUndefined and not useGCC_builtins:
+      if x == 0:
+        return 0
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = builtin_ffs(cast[cint](x.cuint)).int
+      else: result = builtin_ffsll(cast[clonglong](x.culonglong)).int
+    elif useVCC_builtins:
+      when sizeof(x) <= 4:
+        result = 1 + vcc_scan_impl(bitScanForward, x.culong)
+      elif arch64:
+        result = 1 + vcc_scan_impl(bitScanForward64, x.uint64)
+      else:
+        result = firstSetBitNim(x.uint64)
+    elif useICC_builtins:
+      when sizeof(x) <= 4:
+        result = 1 + icc_scan_impl(bitScanForward, x.uint32)
+      elif arch64:
+        result = 1 + icc_scan_impl(bitScanForward64, x.uint64)
+      else:
+        result = firstSetBitNim(x.uint64)
+    else:
+      when sizeof(x) <= 4: result = firstSetBitNim(x.uint32)
+      else: result = firstSetBitNim(x.uint64)
+
+func fastLog2*(x: SomeInteger): int {.inline.} =
+  ## Quickly find the log base 2 of an integer.
+  ## If `x` is zero, when `noUndefinedBitOpts` is set, the result is -1,
+  ## otherwise the result is undefined.
+  runnableExamples:
+    doAssert fastLog2(0b0000_0001'u8) == 0
+    doAssert fastLog2(0b0000_0010'u8) == 1
+    doAssert fastLog2(0b0000_0100'u8) == 2
+    doAssert fastLog2(0b0000_1000'u8) == 3
+    doAssert fastLog2(0b0000_1111'u8) == 3
+
+  let x = x.castToUnsigned
+  when noUndefined:
+    if x == 0:
+      return -1
+  when nimvm:
+    result = forwardImpl(fastlog2Nim, x)
+  else:
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = 31 - builtin_clz(x.uint32).int
+      else: result = 63 - builtin_clzll(x.uint64).int
+    elif useVCC_builtins:
+      when sizeof(x) <= 4:
+        result = vcc_scan_impl(bitScanReverse, x.culong)
+      elif arch64:
+        result = vcc_scan_impl(bitScanReverse64, x.uint64)
+      else:
+        result = fastlog2Nim(x.uint64)
+    elif useICC_builtins:
+      when sizeof(x) <= 4:
+        result = icc_scan_impl(bitScanReverse, x.uint32)
+      elif arch64:
+        result = icc_scan_impl(bitScanReverse64, x.uint64)
+      else:
+        result = fastlog2Nim(x.uint64)
+    else:
+      when sizeof(x) <= 4: result = fastlog2Nim(x.uint32)
+      else: result = fastlog2Nim(x.uint64)
+
+func countLeadingZeroBits*(x: SomeInteger): int {.inline.} =
+  ## Returns the number of leading zero bits in an integer.
+  ## If `x` is zero, when `noUndefinedBitOpts` is set, the result is 0,
+  ## otherwise the result is undefined.
+  ##
+  ## **See also:**
+  ## * `countTrailingZeroBits proc <#countTrailingZeroBits,SomeInteger>`_
+  runnableExamples:
+    doAssert countLeadingZeroBits(0b0000_0001'u8) == 7
+    doAssert countLeadingZeroBits(0b0000_0010'u8) == 6
+    doAssert countLeadingZeroBits(0b0000_0100'u8) == 5
+    doAssert countLeadingZeroBits(0b0000_1000'u8) == 4
+    doAssert countLeadingZeroBits(0b0000_1111'u8) == 4
+
+  let x = x.castToUnsigned
+  when noUndefined:
+    if x == 0:
+      return 0
+  when nimvm:
+    result = sizeof(x)*8 - 1 - forwardImpl(fastlog2Nim, x)
+  else:
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = builtin_clz(x.uint32).int - (32 - sizeof(x)*8)
+      else: result = builtin_clzll(x.uint64).int
+    else:
+      when sizeof(x) <= 4: result = sizeof(x)*8 - 1 - fastlog2Nim(x.uint32)
+      else: result = sizeof(x)*8 - 1 - fastlog2Nim(x.uint64)
+
+func countTrailingZeroBits*(x: SomeInteger): int {.inline.} =
+  ## Returns the number of trailing zeros in an integer.
+  ## If `x` is zero, when `noUndefinedBitOpts` is set, the result is 0,
+  ## otherwise the result is undefined.
+  ##
+  ## **See also:**
+  ## * `countLeadingZeroBits proc <#countLeadingZeroBits,SomeInteger>`_
+  runnableExamples:
+    doAssert countTrailingZeroBits(0b0000_0001'u8) == 0
+    doAssert countTrailingZeroBits(0b0000_0010'u8) == 1
+    doAssert countTrailingZeroBits(0b0000_0100'u8) == 2
+    doAssert countTrailingZeroBits(0b0000_1000'u8) == 3
+    doAssert countTrailingZeroBits(0b0000_1111'u8) == 0
+
+  let x = x.castToUnsigned
+  when noUndefined:
+    if x == 0:
+      return 0
+  when nimvm:
+    result = firstSetBit(x) - 1
+  else:
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = builtin_ctz(x.uint32).int
+      else: result = builtin_ctzll(x.uint64).int
+    else:
+      result = firstSetBit(x) - 1
+
+when useBuiltinsRotate:
+  when defined(gcc):
+    # GCC was tested until version 4.8.1 and intrinsics were present. Not tested
+    # in previous versions.
+    func builtin_rotl8(value: uint8, shift: cint): uint8
+                      {.importc: "__rolb", header: "<x86intrin.h>".}
+    func builtin_rotl16(value: cushort, shift: cint): cushort
+                       {.importc: "__rolw", header: "<x86intrin.h>".}
+    func builtin_rotl32(value: cuint, shift: cint): cuint
+                       {.importc: "__rold", header: "<x86intrin.h>".}
+    when defined(amd64):
+      func builtin_rotl64(value: culonglong, shift: cint): culonglong
+                         {.importc: "__rolq", header: "<x86intrin.h>".}
+
+    func builtin_rotr8(value: uint8, shift: cint): uint8
+                      {.importc: "__rorb", header: "<x86intrin.h>".}
+    func builtin_rotr16(value: cushort, shift: cint): cushort
+                       {.importc: "__rorw", header: "<x86intrin.h>".}
+    func builtin_rotr32(value: cuint, shift: cint): cuint
+                       {.importc: "__rord", header: "<x86intrin.h>".}
+    when defined(amd64):
+      func builtin_rotr64(value: culonglong, shift: cint): culonglong
+                         {.importc: "__rorq", header: "<x86intrin.h>".}
+  elif defined(clang):
+    # In CLANG, builtins have been present since version 8.0.0 and intrinsics
+    # since version 9.0.0. This implementation chose the builtins, as they have
+    # been around for longer.
+    # https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release
+    # https://releases.llvm.org/8.0.0/tools/clang/docs/LanguageExtensions.html#builtin-rotateleft
+    # source for correct declarations: https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def
+    func builtin_rotl8(value: uint8, shift: uint8): uint8
+                      {.importc: "__builtin_rotateleft8", nodecl.}
+    func builtin_rotl16(value: cushort, shift: cushort): cushort
+                       {.importc: "__builtin_rotateleft16", nodecl.}
+    func builtin_rotl32(value: cuint, shift: cuint): cuint
+                       {.importc: "__builtin_rotateleft32", nodecl.}
+    when defined(amd64):
+      func builtin_rotl64(value: culonglong, shift: culonglong): culonglong
+                         {.importc: "__builtin_rotateleft64", nodecl.}
+
+    func builtin_rotr8(value: uint8, shift: uint8): uint8
+                      {.importc: "__builtin_rotateright8", nodecl.}
+    func builtin_rotr16(value: cushort, shift: cushort): cushort
+                       {.importc: "__builtin_rotateright16", nodecl.}
+    func builtin_rotr32(value: cuint, shift: cuint): cuint
+                       {.importc: "__builtin_rotateright32", nodecl.}
+    when defined(amd64):
+      # shift is unsigned, refs https://github.com/llvm-mirror/clang/commit/892de415b7fde609dafc4e6c1643b7eaa0150a4d
+      func builtin_rotr64(value: culonglong, shift: culonglong): culonglong
+                         {.importc: "__builtin_rotateright64", nodecl.}
+  elif defined(vcc):
+    # Tested on Microsoft (R) C/C++ Optimizing Compiler 19.28.29335 x64 and x86.
+    # Not tested in previous versions.
+    # https://docs.microsoft.com/en-us/cpp/intrinsics/rotl8-rotl16?view=msvc-160
+    # https://docs.microsoft.com/en-us/cpp/intrinsics/rotr8-rotr16?view=msvc-160
+    # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64?view=msvc-160
+    func builtin_rotl8(value: uint8, shift: uint8): uint8
+                      {.importc: "_rotl8", header: "<intrin.h>".}
+    func builtin_rotl16(value: cushort, shift: uint8): cushort
+                       {.importc: "_rotl16", header: "<intrin.h>".}
+    func builtin_rotl32(value: cuint, shift: cint): cuint
+                       {.importc: "_rotl", header: "<stdlib.h>".}
+    when defined(amd64):
+      func builtin_rotl64(value: culonglong, shift: cint): culonglong
+                         {.importc: "_rotl64", header: "<stdlib.h>".}
+
+    func builtin_rotr8(value: uint8, shift: uint8): uint8
+                      {.importc: "_rotr8", header: "<intrin.h>".}
+    func builtin_rotr16(value: cushort, shift: uint8): cushort
+                       {.importc: "_rotr16", header: "<intrin.h>".}
+    func builtin_rotr32(value: cuint, shift: cint): cuint
+                       {.importc: "_rotr", header: "<stdlib.h>".}
+    when defined(amd64):
+      func builtin_rotr64(value: culonglong, shift: cint): culonglong
+                         {.importc: "_rotr64", header: "<stdlib.h>".}
+  elif defined(icl):
+    # Tested on Intel(R) C++ Intel(R) 64 Compiler Classic Version 2021.1.2 Build
+    # 20201208_000000 x64 and x86. Not tested in previous versions.
+    func builtin_rotl8(value: uint8, shift: cint): uint8
+                      {.importc: "__rolb", header: "<immintrin.h>".}
+    func builtin_rotl16(value: cushort, shift: cint): cushort
+                       {.importc: "__rolw", header: "<immintrin.h>".}
+    func builtin_rotl32(value: cuint, shift: cint): cuint
+                       {.importc: "__rold", header: "<immintrin.h>".}
+    when defined(amd64):
+      func builtin_rotl64(value: culonglong, shift: cint): culonglong
+                         {.importc: "__rolq", header: "<immintrin.h>".}
+
+    func builtin_rotr8(value: uint8, shift: cint): uint8
+                      {.importc: "__rorb", header: "<immintrin.h>".}
+    func builtin_rotr16(value: cushort, shift: cint): cushort
+                       {.importc: "__rorw", header: "<immintrin.h>".}
+    func builtin_rotr32(value: cuint, shift: cint): cuint
+                       {.importc: "__rord", header: "<immintrin.h>".}
+    when defined(amd64):
+      func builtin_rotr64(value: culonglong, shift: cint): culonglong
+                         {.importc: "__rorq", header: "<immintrin.h>".}
+
+func rotl[T: SomeUnsignedInt](value: T, rot: int32): T {.inline.} =
+  ## Left-rotate bits in a `value`.
+  # https://stackoverflow.com/a/776523
+  const mask = 8 * sizeof(value) - 1
+  let rot = rot and mask
+  (value shl rot) or (value shr ((-rot) and mask))
+
+func rotr[T: SomeUnsignedInt](value: T, rot: int32): T {.inline.} =
+  ## Right-rotate bits in a `value`.
+  const mask = 8 * sizeof(value) - 1
+  let rot = rot and mask
+  (value shr rot) or (value shl ((-rot) and mask))
+
+func shiftTypeTo(size: static int, shift: int): auto {.inline.} =
+  ## Returns the `shift` for the rotation according to the compiler and the
+  ## `size`.
+  when (defined(vcc) and (size in [4, 8])) or defined(gcc) or defined(icl):
+    cint(shift)
+  elif (defined(vcc) and (size in [1, 2])) or (defined(clang) and size == 1):
+    uint8(shift)
+  elif defined(clang):
+    when size == 2:
+      cushort(shift)
+    elif size == 4:
+      cuint(shift)
+    elif size == 8:
+      culonglong(shift)
+
+func rotateLeftBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) * 8)]): T {.inline.} =
+  ## Left-rotate bits in a `value`.
+  runnableExamples:
+    doAssert rotateLeftBits(0b0110_1001'u8, 4) == 0b1001_0110'u8
+    doAssert rotateLeftBits(0b00111100_11000011'u16, 8) ==
+      0b11000011_00111100'u16
+    doAssert rotateLeftBits(0b0000111111110000_1111000000001111'u32, 16) ==
+      0b1111000000001111_0000111111110000'u32
+    doAssert rotateLeftBits(0b00000000111111111111111100000000_11111111000000000000000011111111'u64, 32) ==
+      0b11111111000000000000000011111111_00000000111111111111111100000000'u64
+  when nimvm:
+    rotl(value, shift.int32)
+  else:
+    when useBuiltinsRotate:
+      const size = sizeof(T)
+      when size == 1:
+        builtin_rotl8(value.uint8, shiftTypeTo(size, shift)).T
+      elif size == 2:
+        builtin_rotl16(value.cushort, shiftTypeTo(size, shift)).T
+      elif size == 4:
+        builtin_rotl32(value.cuint, shiftTypeTo(size, shift)).T
+      elif size == 8 and arch64:
+        builtin_rotl64(value.culonglong, shiftTypeTo(size, shift)).T
+      else:
+        rotl(value, shift.int32)
+    else:
+      rotl(value, shift.int32)
+
+func rotateRightBits*[T: SomeUnsignedInt](value: T, shift: range[0..(sizeof(T) * 8)]): T {.inline.} =
+  ## Right-rotate bits in a `value`.
+  runnableExamples:
+    doAssert rotateRightBits(0b0110_1001'u8, 4) == 0b1001_0110'u8
+    doAssert rotateRightBits(0b00111100_11000011'u16, 8) ==
+      0b11000011_00111100'u16
+    doAssert rotateRightBits(0b0000111111110000_1111000000001111'u32, 16) ==
+      0b1111000000001111_0000111111110000'u32
+    doAssert rotateRightBits(0b00000000111111111111111100000000_11111111000000000000000011111111'u64, 32) ==
+      0b11111111000000000000000011111111_00000000111111111111111100000000'u64
+  when nimvm:
+    rotr(value, shift.int32)
+  else:
+    when useBuiltinsRotate:
+      const size = sizeof(T)
+      when size == 1:
+        builtin_rotr8(value.uint8, shiftTypeTo(size, shift)).T
+      elif size == 2:
+        builtin_rotr16(value.cushort, shiftTypeTo(size, shift)).T
+      elif size == 4:
+        builtin_rotr32(value.cuint, shiftTypeTo(size, shift)).T
+      elif size == 8 and arch64:
+        builtin_rotr64(value.culonglong, shiftTypeTo(size, shift)).T
+      else:
+        rotr(value, shift.int32)
+    else:
+      rotr(value, shift.int32)
+
+func repeatBits[T: SomeUnsignedInt](x: SomeUnsignedInt; retType: type[T]): T  =
+  result = x
+  var i = 1
+  while i != (sizeof(T) div sizeof(x)):
+    result = (result shl (sizeof(x)*8*i)) or result
+    i *= 2
+
+func reverseBits*[T: SomeUnsignedInt](x: T): T =
+  ## Return the bit reversal of x.
+  runnableExamples:
+    doAssert reverseBits(0b10100100'u8) == 0b00100101'u8
+    doAssert reverseBits(0xdd'u8) == 0xbb'u8
+    doAssert reverseBits(0xddbb'u16) == 0xddbb'u16
+    doAssert reverseBits(0xdeadbeef'u32) == 0xf77db57b'u32
+
+  template repeat(x: SomeUnsignedInt): T = repeatBits(x, T)
+
+  result = x
+  result =
+    ((repeat(0x55u8) and result) shl 1) or
+    ((repeat(0xaau8) and result) shr 1)
+  result =
+    ((repeat(0x33u8) and result) shl 2) or
+    ((repeat(0xccu8) and result) shr 2)
+  when sizeof(T) == 1:
+    result = (result shl 4) or (result shr 4)
+  when sizeof(T) >= 2:
+    result =
+      ((repeat(0x0fu8) and result) shl 4) or
+      ((repeat(0xf0u8) and result) shr 4)
+  when sizeof(T) == 2:
+    result = (result shl 8) or (result shr 8)
+  when sizeof(T) >= 4:
+    result =
+      ((repeat(0x00ffu16) and result) shl 8) or
+      ((repeat(0xff00u16) and result) shr 8)
+  when sizeof(T) == 4:
+    result = (result shl 16) or (result shr 16)
+  when sizeof(T) == 8:
+    result =
+      ((repeat(0x0000ffffu32) and result) shl 16) or
+      ((repeat(0xffff0000u32) and result) shr 16)
+    result = (result shl 32) or (result shr 32)
diff --git a/lib/pure/browsers.nim b/lib/pure/browsers.nim
index 243c07dad..59e2078df 100755..100644
--- a/lib/pure/browsers.nim
+++ b/lib/pure/browsers.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,35 +9,104 @@
 
 ## This module implements a simple proc for opening URLs with the user's
 ## default browser.
+##
+## Unstable API.
 
-import strutils
+import std/private/since # used by the deprecated `openDefaultBrowser()`
+
+import std/strutils
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
 when defined(windows):
-  import winlean
+  import std/winlean
+  when defined(nimPreviewSlimSystem):
+    import std/widestrs
+  from std/os import absolutePath
 else:
-  import os, osproc
+  import std/os
+  when not defined(osx):
+    import std/osproc
+
+const osOpenCmd* =
+  when defined(macos) or defined(macosx) or defined(windows): "open" else: "xdg-open" ## \
+  ## Alias for the operating system specific *"open"* command,
+  ## `"open"` on OSX, MacOS and Windows, `"xdg-open"` on Linux, BSD, etc.
+
+proc prepare(s: string): string =
+  if s.contains("://"):
+    result = s
+  else:
+    result = "file://" & absolutePath(s)
+
+proc openDefaultBrowserRaw(url: string) =
+  ## note the url argument should be alreadly prepared, i.e. the url is passed "AS IS"
 
-proc openDefaultBrowser*(url: string) =
-  ## opens `url` with the user's default browser. This does not block.
-  ##
-  ## Under Windows, ``ShellExecute`` is used. Under Mac OS X the ``open``
-  ## command is used. Under Unix, it is checked if ``gnome-open`` exists and
-  ## used if it does. Next attempt is ``kde-open``, then ``xdg-open``.
-  ## Otherwise the environment variable ``BROWSER`` is used to determine the
-  ## default browser to use.
   when defined(windows):
-    discard ShellExecute(0'i32, "open", url, nil, nil, SW_SHOWNORMAL)
+    var o = newWideCString(osOpenCmd)
+    var u = newWideCString(url)
+    discard shellExecuteW(0'i32, o, u, nil, nil, SW_SHOWNORMAL)
   elif defined(macosx):
-    discard execShellCmd("open " & quoteIfContainsWhite(url))
+    discard execShellCmd(osOpenCmd & " " & quoteShell(url))
   else:
-    const attempts = ["gnome-open ", "kde-open ", "xdg-open "]
-    var u = quoteIfContainsWhite(url)
-    for a in items(attempts):
-      if execShellCmd(a & u) == 0: return
+    var u = quoteShell(url)
+    if execShellCmd(osOpenCmd & " " & u) == 0: return
     for b in getEnv("BROWSER").split(PathSep):
       try:
-        # we use ``startProcess`` here because we don't want to block!
-        discard startProcess(command=b, args=[url], options={poUseShell})
+        # we use `startProcess` here because we don't want to block!
+        discard startProcess(command = b, args = [url], options = {poUsePath})
         return
-      except EOS:
-        nil
+      except OSError:
+        discard
+
+proc openDefaultBrowser*(url: string) =
+  ## Opens `url` with the user's default browser. This does not block.
+  ## The URL must not be empty string, to open on a blank page see `openDefaultBrowser()`.
+  ##
+  ## Under Windows, `ShellExecute` is used. Under Mac OS X the `open`
+  ## command is used. Under Unix, it is checked if `xdg-open` exists and
+  ## used if it does. Otherwise the environment variable `BROWSER` is
+  ## used to determine the default browser to use.
+  ##
+  ## This proc doesn't raise an exception on error, beware.
+  ##
+  ##   ```nim
+  ##   block: openDefaultBrowser("https://nim-lang.org")
+  ##   ```
+  doAssert url.len > 0, "URL must not be empty string"
+  openDefaultBrowserRaw(url)
+
+proc openDefaultBrowser*() {.since: (1, 1), deprecated: 
+  "not implemented, please open with a specific url instead".} =
+  ## Intends to open the user's default browser without any `url` (blank page).
+  ## This does not block.
+  ## Intends to implement IETF RFC-6694 Section 3,
+  ## ("about:blank" is reserved for a blank page).
+  ##
+  ## Beware that this intended behavior is **not** implemented and 
+  ## considered not worthy to implement here.
+  ##
+  ## The following describes the behavior of current implementation:
+  ## 
+  ##  - Under Windows, this will only cause a pop-up dialog \
+  ## asking the assocated application with `about` \
+  ## (as Windows simply treats `about:` as a protocol like `http`).
+  ##  - Under Mac OS X the `open "about:blank"` command is used.
+  ##  - Under Unix, it is checked if `xdg-open` exists and used \
+  ## if it does and open the application assocated with `text/html` mime \
+  ## (not `x-scheme-handler/http`, so maybe html-viewer \
+  ## other than your default browser is opened). \
+  ## Otherwise the environment variable `BROWSER` is used \
+  ## to determine the default browser to use.
+  ##
+  ## This proc doesn't raise an exception on error, beware.
+  ##
+  ##   ```nim
+  ##   block: openDefaultBrowser()
+  ##   ```
+  ##
+  ## **See also:**
+  ##
+  ## * https://tools.ietf.org/html/rfc6694#section-3
+  openDefaultBrowserRaw("about:blank")  # See IETF RFC-6694 Section 3.
diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim
index 490ae926d..034f224ac 100755..100644
--- a/lib/pure/cgi.nim
+++ b/lib/pure/cgi.nim
@@ -1,381 +1,315 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module implements helper procs for CGI applictions. Example:
-## 
-## .. code-block:: Nimrod
+## This module implements helper procs for CGI applications. Example:
 ##
-##    import strtabs, cgi
+##   ```Nim
+##   import std/[strtabs, cgi]
 ##
-##    # Fill the values when debugging:
-##    when debug: 
-##      setTestData("name", "Klaus", "password", "123456")
-##    # read the data into `myData`
-##    var myData = readData()
-##    # check that the data's variable names are "name" or "passwort" 
-##    validateData(myData, "name", "password")
-##    # start generating content:
-##    writeContentType()
-##    # generate content:
-##    write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
-##    write(stdout, "<html><head><title>Test</title></head><body>\n")
-##    writeln(stdout, "your name: " & myData["name"])
-##    writeln(stdout, "your password: " & myData["password"])
-##    writeln(stdout, "</body></html>")
-
-import strutils, os, strtabs
-
-proc URLencode*(s: string): string =
-  ## Encodes a value to be HTTP safe: This means that characters in the set
-  ## ``{'A'..'Z', 'a'..'z', '0'..'9', '_'}`` are carried over to the result,
-  ## a space is converted to ``'+'`` and every other character is encoded as
-  ## ``'%xx'`` where ``xx`` denotes its hexadecimal value. 
-  result = ""
-  for i in 0..s.len-1:
-    case s[i]
-    of 'a'..'z', 'A'..'Z', '0'..'9', '_': add(result, s[i])
-    of ' ': add(result, '+')
-    else: 
-      add(result, '%')
-      add(result, toHex(ord(s[i]), 2))
-
-proc handleHexChar(c: char, x: var int) {.inline.} = 
-  case c
-  of '0'..'9': x = (x shl 4) or (ord(c) - ord('0'))
-  of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10)
-  of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
-  else: assert(false)
-
-proc URLdecode*(s: string): string = 
-  ## Decodes a value from its HTTP representation: This means that a ``'+'`` 
-  ## is converted to a space, ``'%xx'`` (where ``xx`` denotes a hexadecimal
-  ## value) is converted to the character with ordinal number ``xx``, and  
-  ## and every other character is carried over. 
-  result = ""
-  var i = 0
-  while i < s.len:
-    case s[i]
-    of '%': 
-      var x = 0
-      handleHexChar(s[i+1], x)
-      handleHexChar(s[i+2], x)
-      inc(i, 2)
-      add(result, chr(x))
-    of '+': add(result, ' ')
-    else: add(result, s[i])
-    inc(i)
-
-proc addXmlChar(dest: var string, c: Char) {.inline.} = 
+##   # Fill the values when debugging:
+##   when debug:
+##     setTestData("name", "Klaus", "password", "123456")
+##   # read the data into `myData`
+##   var myData = readData()
+##   # check that the data's variable names are "name" or "password"
+##   validateData(myData, "name", "password")
+##   # start generating content:
+##   writeContentType()
+##   # generate content:
+##   write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
+##   write(stdout, "<html><head><title>Test</title></head><body>\n")
+##   writeLine(stdout, "your name: " & myData["name"])
+##   writeLine(stdout, "your password: " & myData["password"])
+##   writeLine(stdout, "</body></html>")
+##   ```
+
+import std/[strutils, os, strtabs, cookies, uri]
+export uri.encodeUrl, uri.decodeUrl
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+
+proc addXmlChar(dest: var string, c: char) {.inline.} =
   case c
   of '&': add(dest, "&amp;")
   of '<': add(dest, "&lt;")
   of '>': add(dest, "&gt;")
   of '\"': add(dest, "&quot;")
   else: add(dest, c)
-  
-proc XMLencode*(s: string): string = 
+
+proc xmlEncode*(s: string): string =
   ## Encodes a value to be XML safe:
-  ## * ``"`` is replaced by ``&quot;``
-  ## * ``<`` is replaced by ``&lt;``
-  ## * ``>`` is replaced by ``&gt;``
-  ## * ``&`` is replaced by ``&amp;``
+  ## * `"` is replaced by `&quot;`
+  ## * `<` is replaced by `&lt;`
+  ## * `>` is replaced by `&gt;`
+  ## * `&` is replaced by `&amp;`
   ## * every other character is carried over.
-  result = ""
+  result = newStringOfCap(s.len + s.len shr 2)
   for i in 0..len(s)-1: addXmlChar(result, s[i])
 
 type
-  ECgi* = object of EIO  ## the exception that is raised, if a CGI error occurs
-  TRequestMethod* = enum ## the used request method
-    methodNone,          ## no REQUEST_METHOD environment variable
-    methodPost,          ## query uses the POST method
-    methodGet            ## query uses the GET method
-
-proc cgiError*(msg: string) {.noreturn.} = 
-  ## raises an ECgi exception with message `msg`.
-  var e: ref ECgi
-  new(e)
-  e.msg = msg
-  raise e
-
-proc getEncodedData(allowedMethods: set[TRequestMethod]): string = 
-  case getenv("REQUEST_METHOD") 
-  of "POST": 
-    if methodPost notin allowedMethods: 
+  CgiError* = object of IOError ## Exception that is raised if a CGI error occurs.
+  RequestMethod* = enum ## The used request method.
+    methodNone,         ## no REQUEST_METHOD environment variable
+    methodPost,         ## query uses the POST method
+    methodGet           ## query uses the GET method
+
+proc cgiError*(msg: string) {.noreturn.} =
+  ## Raises a `CgiError` exception with message `msg`.
+  raise newException(CgiError, msg)
+
+proc getEncodedData(allowedMethods: set[RequestMethod]): string =
+  case getEnv("REQUEST_METHOD")
+  of "POST":
+    if methodPost notin allowedMethods:
       cgiError("'REQUEST_METHOD' 'POST' is not supported")
-    var L = parseInt(getenv("CONTENT_LENGTH"))
+    var L = parseInt(getEnv("CONTENT_LENGTH"))
+    if L == 0:
+      return ""
     result = newString(L)
     if readBuffer(stdin, addr(result[0]), L) != L:
       cgiError("cannot read from stdin")
   of "GET":
-    if methodGet notin allowedMethods: 
+    if methodGet notin allowedMethods:
       cgiError("'REQUEST_METHOD' 'GET' is not supported")
-    result = getenv("QUERY_STRING")
-  else: 
+    result = getEnv("QUERY_STRING")
+  else:
     if methodNone notin allowedMethods:
       cgiError("'REQUEST_METHOD' must be 'POST' or 'GET'")
 
-iterator decodeData*(data: string): tuple[key, value: string] = 
+iterator decodeData*(data: string): tuple[key, value: string] =
   ## Reads and decodes CGI data and yields the (name, value) pairs the
   ## data consists of.
-  var i = 0
-  var name = ""
-  var value = ""
-  # decode everything in one pass:
-  while data[i] != '\0':
-    setLen(name, 0) # reuse memory
-    while true:
-      case data[i]
-      of '\0': break
-      of '%': 
-        var x = 0
-        handleHexChar(data[i+1], x)
-        handleHexChar(data[i+2], x)
-        inc(i, 2)
-        add(name, chr(x))
-      of '+': add(name, ' ')
-      of '=', '&': break
-      else: add(name, data[i])
-      inc(i)
-    if data[i] != '=': cgiError("'=' expected")
-    inc(i) # skip '='
-    setLen(value, 0) # reuse memory
-    while true:
-      case data[i]
-      of '%': 
-        var x = 0
-        handleHexChar(data[i+1], x)
-        handleHexChar(data[i+2], x)
-        inc(i, 2)
-        add(value, chr(x))
-      of '+': add(value, ' ')
-      of '&', '\0': break
-      else: add(value, data[i])
-      inc(i)
-    yield (name, value)
-    if data[i] == '&': inc(i)
-    elif data[i] == '\0': break
-    else: cgiError("'&' expected")
- 
-iterator decodeData*(allowedMethods: set[TRequestMethod] = 
-       {methodNone, methodPost, methodGet}): tuple[key, value: string] = 
+  for (key, value) in uri.decodeQuery(data):
+    yield (key, value)
+
+iterator decodeData*(allowedMethods: set[RequestMethod] =
+       {methodNone, methodPost, methodGet}): tuple[key, value: string] =
   ## Reads and decodes CGI data and yields the (name, value) pairs the
   ## data consists of. If the client does not use a method listed in the
-  ## `allowedMethods` set, an `ECgi` exception is raised.
-  var data = getEncodedData(allowedMethods)
-  if not isNil(data): 
-    for key, value in decodeData(data):
-      yield (key, value)
-
-proc readData*(allowedMethods: set[TRequestMethod] = 
-               {methodNone, methodPost, methodGet}): PStringTable = 
-  ## Read CGI data. If the client does not use a method listed in the
-  ## `allowedMethods` set, an `ECgi` exception is raised.
+  ## `allowedMethods` set, a `CgiError` exception is raised.
+  let data = getEncodedData(allowedMethods)
+  for (key, value) in uri.decodeQuery(data):
+    yield (key, value)
+
+proc readData*(allowedMethods: set[RequestMethod] =
+               {methodNone, methodPost, methodGet}): StringTableRef =
+  ## Reads CGI data. If the client does not use a method listed in the
+  ## `allowedMethods` set, a `CgiError` exception is raised.
   result = newStringTable()
-  for name, value in decodeData(allowedMethods): 
+  for name, value in decodeData(allowedMethods):
     result[name] = value
-  
-proc validateData*(data: PStringTable, validKeys: openarray[string]) = 
-  ## validates data; raises `ECgi` if this fails. This checks that each variable
+
+proc readData*(data: string): StringTableRef =
+  ## Reads CGI data from a string.
+  result = newStringTable()
+  for name, value in decodeData(data):
+    result[name] = value
+
+proc validateData*(data: StringTableRef, validKeys: varargs[string]) =
+  ## Validates data; raises `CgiError` if this fails. This checks that each variable
   ## name of the CGI `data` occurs in the `validKeys` array.
   for key, val in pairs(data):
-    if find(validKeys, key) < 0: 
+    if find(validKeys, key) < 0:
       cgiError("unknown variable name: " & key)
 
 proc getContentLength*(): string =
-  ## returns contents of the ``CONTENT_LENGTH`` environment variable
-  return getenv("CONTENT_LENGTH")
+  ## Returns contents of the `CONTENT_LENGTH` environment variable.
+  return getEnv("CONTENT_LENGTH")
 
 proc getContentType*(): string =
-  ## returns contents of the ``CONTENT_TYPE`` environment variable
-  return getenv("CONTENT_Type")
+  ## Returns contents of the `CONTENT_TYPE` environment variable.
+  return getEnv("CONTENT_Type")
 
 proc getDocumentRoot*(): string =
-  ## returns contents of the ``DOCUMENT_ROOT`` environment variable
-  return getenv("DOCUMENT_ROOT")
+  ## Returns contents of the `DOCUMENT_ROOT` environment variable.
+  return getEnv("DOCUMENT_ROOT")
 
 proc getGatewayInterface*(): string =
-  ## returns contents of the ``GATEWAY_INTERFACE`` environment variable
-  return getenv("GATEWAY_INTERFACE")
+  ## Returns contents of the `GATEWAY_INTERFACE` environment variable.
+  return getEnv("GATEWAY_INTERFACE")
 
 proc getHttpAccept*(): string =
-  ## returns contents of the ``HTTP_ACCEPT`` environment variable
-  return getenv("HTTP_ACCEPT")
+  ## Returns contents of the `HTTP_ACCEPT` environment variable.
+  return getEnv("HTTP_ACCEPT")
 
 proc getHttpAcceptCharset*(): string =
-  ## returns contents of the ``HTTP_ACCEPT_CHARSET`` environment variable
-  return getenv("HTTP_ACCEPT_CHARSET")
+  ## Returns contents of the `HTTP_ACCEPT_CHARSET` environment variable.
+  return getEnv("HTTP_ACCEPT_CHARSET")
 
 proc getHttpAcceptEncoding*(): string =
-  ## returns contents of the ``HTTP_ACCEPT_ENCODING`` environment variable
-  return getenv("HTTP_ACCEPT_ENCODING")
+  ## Returns contents of the `HTTP_ACCEPT_ENCODING` environment variable.
+  return getEnv("HTTP_ACCEPT_ENCODING")
 
 proc getHttpAcceptLanguage*(): string =
-  ## returns contents of the ``HTTP_ACCEPT_LANGUAGE`` environment variable
-  return getenv("HTTP_ACCEPT_LANGUAGE")
+  ## Returns contents of the `HTTP_ACCEPT_LANGUAGE` environment variable.
+  return getEnv("HTTP_ACCEPT_LANGUAGE")
 
 proc getHttpConnection*(): string =
-  ## returns contents of the ``HTTP_CONNECTION`` environment variable
-  return getenv("HTTP_CONNECTION")
+  ## Returns contents of the `HTTP_CONNECTION` environment variable.
+  return getEnv("HTTP_CONNECTION")
 
 proc getHttpCookie*(): string =
-  ## returns contents of the ``HTTP_COOKIE`` environment variable
-  return getenv("HTTP_COOKIE")
+  ## Returns contents of the `HTTP_COOKIE` environment variable.
+  return getEnv("HTTP_COOKIE")
 
 proc getHttpHost*(): string =
-  ## returns contents of the ``HTTP_HOST`` environment variable
-  return getenv("HTTP_HOST")
+  ## Returns contents of the `HTTP_HOST` environment variable.
+  return getEnv("HTTP_HOST")
 
 proc getHttpReferer*(): string =
-  ## returns contents of the ``HTTP_REFERER`` environment variable
-  return getenv("HTTP_REFERER")
+  ## Returns contents of the `HTTP_REFERER` environment variable.
+  return getEnv("HTTP_REFERER")
 
 proc getHttpUserAgent*(): string =
-  ## returns contents of the ``HTTP_USER_AGENT`` environment variable
-  return getenv("HTTP_USER_AGENT")
+  ## Returns contents of the `HTTP_USER_AGENT` environment variable.
+  return getEnv("HTTP_USER_AGENT")
 
 proc getPathInfo*(): string =
-  ## returns contents of the ``PATH_INFO`` environment variable
-  return getenv("PATH_INFO")
+  ## Returns contents of the `PATH_INFO` environment variable.
+  return getEnv("PATH_INFO")
 
 proc getPathTranslated*(): string =
-  ## returns contents of the ``PATH_TRANSLATED`` environment variable
-  return getenv("PATH_TRANSLATED")
+  ## Returns contents of the `PATH_TRANSLATED` environment variable.
+  return getEnv("PATH_TRANSLATED")
 
 proc getQueryString*(): string =
-  ## returns contents of the ``QUERY_STRING`` environment variable
-  return getenv("QUERY_STRING")
+  ## Returns contents of the `QUERY_STRING` environment variable.
+  return getEnv("QUERY_STRING")
 
 proc getRemoteAddr*(): string =
-  ## returns contents of the ``REMOTE_ADDR`` environment variable
-  return getenv("REMOTE_ADDR")
+  ## Returns contents of the `REMOTE_ADDR` environment variable.
+  return getEnv("REMOTE_ADDR")
 
 proc getRemoteHost*(): string =
-  ## returns contents of the ``REMOTE_HOST`` environment variable
-  return getenv("REMOTE_HOST")
+  ## Returns contents of the `REMOTE_HOST` environment variable.
+  return getEnv("REMOTE_HOST")
 
 proc getRemoteIdent*(): string =
-  ## returns contents of the ``REMOTE_IDENT`` environment variable
-  return getenv("REMOTE_IDENT")
+  ## Returns contents of the `REMOTE_IDENT` environment variable.
+  return getEnv("REMOTE_IDENT")
 
 proc getRemotePort*(): string =
-  ## returns contents of the ``REMOTE_PORT`` environment variable
-  return getenv("REMOTE_PORT")
+  ## Returns contents of the `REMOTE_PORT` environment variable.
+  return getEnv("REMOTE_PORT")
 
 proc getRemoteUser*(): string =
-  ## returns contents of the ``REMOTE_USER`` environment variable
-  return getenv("REMOTE_USER")
+  ## Returns contents of the `REMOTE_USER` environment variable.
+  return getEnv("REMOTE_USER")
 
 proc getRequestMethod*(): string =
-  ## returns contents of the ``REQUEST_METHOD`` environment variable
-  return getenv("REQUEST_METHOD")
+  ## Returns contents of the `REQUEST_METHOD` environment variable.
+  return getEnv("REQUEST_METHOD")
 
 proc getRequestURI*(): string =
-  ## returns contents of the ``REQUEST_URI`` environment variable
-  return getenv("REQUEST_URI")
+  ## Returns contents of the `REQUEST_URI` environment variable.
+  return getEnv("REQUEST_URI")
 
 proc getScriptFilename*(): string =
-  ## returns contents of the ``SCRIPT_FILENAME`` environment variable
-  return getenv("SCRIPT_FILENAME")
+  ## Returns contents of the `SCRIPT_FILENAME` environment variable.
+  return getEnv("SCRIPT_FILENAME")
 
 proc getScriptName*(): string =
-  ## returns contents of the ``SCRIPT_NAME`` environment variable
-  return getenv("SCRIPT_NAME")
+  ## Returns contents of the `SCRIPT_NAME` environment variable.
+  return getEnv("SCRIPT_NAME")
 
 proc getServerAddr*(): string =
-  ## returns contents of the ``SERVER_ADDR`` environment variable
-  return getenv("SERVER_ADDR")
+  ## Returns contents of the `SERVER_ADDR` environment variable.
+  return getEnv("SERVER_ADDR")
 
 proc getServerAdmin*(): string =
-  ## returns contents of the ``SERVER_ADMIN`` environment variable
-  return getenv("SERVER_ADMIN")
+  ## Returns contents of the `SERVER_ADMIN` environment variable.
+  return getEnv("SERVER_ADMIN")
 
 proc getServerName*(): string =
-  ## returns contents of the ``SERVER_NAME`` environment variable
-  return getenv("SERVER_NAME")
+  ## Returns contents of the `SERVER_NAME` environment variable.
+  return getEnv("SERVER_NAME")
 
 proc getServerPort*(): string =
-  ## returns contents of the ``SERVER_PORT`` environment variable
-  return getenv("SERVER_PORT")
+  ## Returns contents of the `SERVER_PORT` environment variable.
+  return getEnv("SERVER_PORT")
 
 proc getServerProtocol*(): string =
-  ## returns contents of the ``SERVER_PROTOCOL`` environment variable
-  return getenv("SERVER_PROTOCOL")
+  ## Returns contents of the `SERVER_PROTOCOL` environment variable.
+  return getEnv("SERVER_PROTOCOL")
 
 proc getServerSignature*(): string =
-  ## returns contents of the ``SERVER_SIGNATURE`` environment variable
-  return getenv("SERVER_SIGNATURE")
+  ## Returns contents of the `SERVER_SIGNATURE` environment variable.
+  return getEnv("SERVER_SIGNATURE")
 
 proc getServerSoftware*(): string =
-  ## returns contents of the ``SERVER_SOFTWARE`` environment variable
-  return getenv("SERVER_SOFTWARE")
+  ## Returns contents of the `SERVER_SOFTWARE` environment variable.
+  return getEnv("SERVER_SOFTWARE")
 
-proc setTestData*(keysvalues: openarray[string]) = 
-  ## fills the appropriate environment variables to test your CGI application.
+proc setTestData*(keysvalues: varargs[string]) =
+  ## Fills the appropriate environment variables to test your CGI application.
   ## This can only simulate the 'GET' request method. `keysvalues` should
   ## provide embedded (name, value)-pairs. Example:
-  ##
-  ## .. code-block:: Nimrod
-  ##    setTestData("name", "Hanz", "password", "12345")
-  putenv("REQUEST_METHOD", "GET")
+  ##   ```Nim
+  ##   setTestData("name", "Hanz", "password", "12345")
+  ##   ```
+  putEnv("REQUEST_METHOD", "GET")
   var i = 0
   var query = ""
   while i < keysvalues.len:
-    add(query, URLencode(keysvalues[i]))
+    add(query, encodeUrl(keysvalues[i]))
     add(query, '=')
-    add(query, URLencode(keysvalues[i+1]))
+    add(query, encodeUrl(keysvalues[i+1]))
     add(query, '&')
     inc(i, 2)
-  putenv("QUERY_STRING", query)
-
-proc writeContentType*() = 
-  ## call this before starting to send your HTML data to `stdout`. This
-  ## implements this part of the CGI protocol: 
-  ##
-  ## .. code-block:: Nimrod
-  ##     write(stdout, "Content-type: text/html\n\n")
-  ## 
-  ## It also modifies the debug stack traces so that they contain
-  ## ``<br />`` and are easily readable in a browser.  
+  putEnv("QUERY_STRING", query)
+
+proc writeContentType*() =
+  ## Calls this before starting to send your HTML data to `stdout`. This
+  ## implements this part of the CGI protocol:
+  ##   ```Nim
+  ##   write(stdout, "Content-type: text/html\n\n")
+  ##   ```
   write(stdout, "Content-type: text/html\n\n")
-  system.stackTraceNewLine = "<br />\n"
-  
-proc setCookie*(name, value: string) = 
+
+proc resetForStacktrace() =
+  stdout.write """<!--: spam
+Content-Type: text/html
+
+<body bgcolor=#f0f0f8><font color=#f0f0f8 size=-5> -->
+<body bgcolor=#f0f0f8><font color=#f0f0f8 size=-5> --> -->
+</font> </font> </font> </script> </object> </blockquote> </pre>
+</table> </table> </table> </table> </table> </font> </font> </font>
+"""
+
+proc writeErrorMessage*(data: string) =
+  ## Tries to reset browser state and writes `data` to stdout in
+  ## <plaintext> tag.
+  resetForStacktrace()
+  # We use <plaintext> here, instead of escaping, so stacktrace can
+  # be understood by human looking at source.
+  stdout.write("<plaintext>\n")
+  stdout.write(data)
+
+proc setStackTraceStdout*() =
+  ## Makes Nim output stacktraces to stdout, instead of server log.
+  errorMessageWriter = writeErrorMessage
+
+proc setCookie*(name, value: string) =
   ## Sets a cookie.
   write(stdout, "Set-Cookie: ", name, "=", value, "\n")
 
 var
-  cookies: PStringTable = nil
+  gcookies {.threadvar.}: StringTableRef
 
-proc parseCookies(s: string): PStringTable = 
-  result = newStringTable(modeCaseInsensitive)
-  var i = 0
-  while true:
-    while s[i] == ' ' or s[i] == '\t': inc(i)
-    var keystart = i
-    while s[i] != '=' and s[i] != '\0': inc(i)
-    var keyend = i-1
-    if s[i] == '\0': break
-    inc(i) # skip '='
-    var valstart = i
-    while s[i] != ';' and s[i] != '\0': inc(i)
-    result[copy(s, keystart, keyend)] = copy(s, valstart, i-1)
-    if s[i] == '\0': break
-    inc(i) # skip ';'
-    
-proc getCookie*(name: string): string = 
+proc getCookie*(name: string): string =
   ## Gets a cookie. If no cookie of `name` exists, "" is returned.
-  if cookies == nil: cookies = parseCookies(getHttpCookie())
-  result = cookies[name]
+  if gcookies == nil: gcookies = parseCookies(getHttpCookie())
+  result = gcookies.getOrDefault(name)
 
-proc existsCookie*(name: string): bool = 
+proc existsCookie*(name: string): bool =
   ## Checks if a cookie of `name` exists.
-  if cookies == nil: cookies = parseCookies(getHttpCookie())
-  result = hasKey(cookies, name)
-
-
+  if gcookies == nil: gcookies = parseCookies(getHttpCookie())
+  result = hasKey(gcookies, name)
diff --git a/lib/pure/collections/chains.nim b/lib/pure/collections/chains.nim
new file mode 100644
index 000000000..6b2ecd272
--- /dev/null
+++ b/lib/pure/collections/chains.nim
@@ -0,0 +1,44 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Template based implementation of singly and doubly linked lists.
+## The involved types should have 'prev' or 'next' fields and the
+## list header should have 'head' or 'tail' fields.
+
+template prepend*(header, node) =
+  when compiles(header.head):
+    when compiles(node.prev):
+      if header.head != nil:
+        header.head.prev = node
+    node.next = header.head
+    header.head = node
+  when compiles(header.tail):
+    if header.tail == nil:
+      header.tail = node
+
+template append*(header, node) =
+  when compiles(header.head):
+    if header.head == nil:
+      header.head = node
+  when compiles(header.tail):
+    when compiles(node.prev):
+      node.prev = header.tail
+    if header.tail != nil:
+      header.tail.next = node
+    header.tail = node
+
+template unlink*(header, node) =
+  if node.next != nil:
+    node.next.prev = node.prev
+  if node.prev != nil:
+    node.prev.next = node.next
+  if header.head == node:
+    header.head = node.prev
+  if header.tail == node:
+    header.tail = node.next
diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim
new file mode 100644
index 000000000..24257dacb
--- /dev/null
+++ b/lib/pure/collections/critbits.nim
@@ -0,0 +1,537 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a `crit bit tree`:idx: which is an efficient
+## container for a sorted set of strings, or for a sorted mapping of strings. Based on the
+## [excellent paper by Adam Langley](https://www.imperialviolet.org/binary/critbit.pdf).
+## (A crit bit tree is a form of `radix tree`:idx: or `patricia trie`:idx:.)
+
+runnableExamples:
+  from std/sequtils import toSeq
+
+  var critbitAsSet: CritBitTree[void] = ["kitten", "puppy"].toCritBitTree
+  doAssert critbitAsSet.len == 2
+  critbitAsSet.incl("")
+  doAssert "" in critbitAsSet
+  critbitAsSet.excl("")
+  doAssert "" notin critbitAsSet
+  doAssert toSeq(critbitAsSet.items) == @["kitten", "puppy"]
+  let same = ["puppy", "kitten", "puppy"].toCritBitTree
+  doAssert toSeq(same.keys) == toSeq(critbitAsSet.keys)
+
+  var critbitAsDict: CritBitTree[int] = {"key1": 42}.toCritBitTree
+  doAssert critbitAsDict.len == 1
+  critbitAsDict["key2"] = 0
+  doAssert "key2" in critbitAsDict
+  doAssert critbitAsDict["key2"] == 0
+  critbitAsDict.excl("key1")
+  doAssert "key1" notin critbitAsDict
+  doAssert toSeq(critbitAsDict.pairs) == @[("key2", 0)]
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type
+  NodeObj[T] {.acyclic.} = object
+    byte: int ## byte index of the difference
+    otherBits: char
+    case isLeaf: bool
+    of false: child: array[0..1, ref NodeObj[T]]
+    of true:
+      key: string
+      when T isnot void:
+        val: T
+
+  Node[T] = ref NodeObj[T]
+  CritBitTree*[T] = object ## The crit bit tree can either be used
+                           ## as a mapping from strings to
+                           ## some type `T` or as a set of
+                           ## strings if `T` is `void`.
+    root: Node[T]
+    count: int
+
+func len*[T](c: CritBitTree[T]): int {.inline.} =
+  ## Returns the number of elements in `c` in O(1).
+  runnableExamples:
+    let c = ["key1", "key2"].toCritBitTree
+    doAssert c.len == 2
+
+  result = c.count
+
+proc rawGet[T](c: CritBitTree[T], key: string): Node[T] =
+  var it = c.root
+  while it != nil:
+    if not it.isLeaf:
+      let ch = if it.byte < key.len: key[it.byte] else: '\0'
+      let dir = (1 + (ch.ord or it.otherBits.ord)) shr 8
+      it = it.child[dir]
+    else:
+      return if it.key == key: it else: nil
+
+func contains*[T](c: CritBitTree[T], key: string): bool {.inline.} =
+  ## Returns true if `c` contains the given `key`.
+  runnableExamples:
+    var c: CritBitTree[void]
+    incl(c, "key")
+    doAssert c.contains("key")
+
+  result = rawGet(c, key) != nil
+
+func hasKey*[T](c: CritBitTree[T], key: string): bool {.inline.} =
+  ## Alias for `contains <#contains,CritBitTree[T],string>`_.
+  result = rawGet(c, key) != nil
+
+proc rawInsert[T](c: var CritBitTree[T], key: string): Node[T] =
+  if c.root == nil:
+    c.root = Node[T](isleaf: true, key: key)
+    result = c.root
+  else:
+    var it = c.root
+    while not it.isLeaf:
+      let ch = if it.byte < key.len: key[it.byte] else: '\0'
+      let dir = (1 + (ch.ord or it.otherBits.ord)) shr 8
+      it = it.child[dir]
+
+    var newOtherBits = 0
+    var newByte = 0
+    block blockX:
+      while newByte < key.len:
+        let ch = if newByte < it.key.len: it.key[newByte] else: '\0'
+        if ch != key[newByte]:
+          newOtherBits = ch.ord xor key[newByte].ord
+          break blockX
+        inc newByte
+      if newByte < it.key.len:
+        newOtherBits = it.key[newByte].ord
+      else:
+        return it
+    while (newOtherBits and (newOtherBits-1)) != 0:
+      newOtherBits = newOtherBits and (newOtherBits-1)
+    newOtherBits = newOtherBits xor 255
+    let ch = if newByte < it.key.len: it.key[newByte] else: '\0'
+    let dir = (1 + (ord(ch) or newOtherBits)) shr 8
+
+    var inner: Node[T]
+    new inner
+    result = Node[T](isLeaf: true, key: key)
+    inner.otherBits = chr(newOtherBits)
+    inner.byte = newByte
+    inner.child[1 - dir] = result
+
+    var wherep = addr(c.root)
+    while true:
+      var p = wherep[]
+      if p.isLeaf: break
+      if p.byte > newByte: break
+      if p.byte == newByte and p.otherBits.ord > newOtherBits: break
+      let ch = if p.byte < key.len: key[p.byte] else: '\0'
+      let dir = (1 + (ch.ord or p.otherBits.ord)) shr 8
+      wherep = addr(p.child[dir])
+    inner.child[dir] = wherep[]
+    wherep[] = inner
+  inc c.count
+
+func exclImpl[T](c: var CritBitTree[T], key: string): int =
+  var p = c.root
+  var wherep = addr(c.root)
+  var whereq: ptr Node[T] = nil
+  if p == nil: return c.count
+  var dir = 0
+  var q: Node[T]
+  while not p.isLeaf:
+    whereq = wherep
+    q = p
+    let ch = if p.byte < key.len: key[p.byte] else: '\0'
+    dir = (1 + (ch.ord or p.otherBits.ord)) shr 8
+    wherep = addr(p.child[dir])
+    p = wherep[]
+  if p.key == key:
+    # else: not in tree at all
+    if whereq == nil:
+      c.root = nil
+    else:
+      whereq[] = q.child[1 - dir]
+    dec c.count
+
+  return c.count
+
+proc excl*[T](c: var CritBitTree[T], key: string) =
+  ## Removes `key` (and its associated value) from the set `c`.
+  ## If the `key` does not exist, nothing happens.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,CritBitTree[void],string>`_
+  ## * `incl proc <#incl,CritBitTree[T],string,T>`_
+  runnableExamples:
+    var c: CritBitTree[void]
+    incl(c, "key")
+    excl(c, "key")
+    doAssert not c.contains("key")
+
+  discard exclImpl(c, key)
+
+proc missingOrExcl*[T](c: var CritBitTree[T], key: string): bool =
+  ## Returns true if `c` does not contain the given `key`. If the key
+  ## does exist, `c.excl(key)` is performed.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,CritBitTree[T],string>`_
+  ## * `containsOrIncl proc <#containsOrIncl,CritBitTree[T],string,T>`_
+  ## * `containsOrIncl proc <#containsOrIncl,CritBitTree[void],string>`_
+  runnableExamples:
+    block:
+      var c: CritBitTree[void]
+      doAssert c.missingOrExcl("key")
+    block:
+      var c: CritBitTree[void]
+      incl(c, "key")
+      doAssert not c.missingOrExcl("key")
+      doAssert not c.contains("key")
+
+  let oldCount = c.count
+  discard exclImpl(c, key)
+  result = c.count == oldCount
+
+proc containsOrIncl*[T](c: var CritBitTree[T], key: string, val: sink T): bool =
+  ## Returns true if `c` contains the given `key`. If the key does not exist,
+  ## `c[key] = val` is performed.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,CritBitTree[void],string>`_
+  ## * `incl proc <#incl,CritBitTree[T],string,T>`_
+  ## * `containsOrIncl proc <#containsOrIncl,CritBitTree[void],string>`_
+  ## * `missingOrExcl proc <#missingOrExcl,CritBitTree[T],string>`_
+  runnableExamples:
+    block:
+      var c: CritBitTree[int]
+      doAssert not c.containsOrIncl("key", 42)
+      doAssert c.contains("key")
+    block:
+      var c: CritBitTree[int]
+      incl(c, "key", 21)
+      doAssert c.containsOrIncl("key", 42)
+      doAssert c["key"] == 21
+
+  let oldCount = c.count
+  var n = rawInsert(c, key)
+  result = c.count == oldCount
+  when T isnot void:
+    if not result: n.val = val
+
+proc containsOrIncl*(c: var CritBitTree[void], key: string): bool =
+  ## Returns true if `c` contains the given `key`. If the key does not exist,
+  ## it is inserted into `c`.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,CritBitTree[void],string>`_
+  ## * `incl proc <#incl,CritBitTree[T],string,T>`_
+  ## * `containsOrIncl proc <#containsOrIncl,CritBitTree[T],string,T>`_
+  ## * `missingOrExcl proc <#missingOrExcl,CritBitTree[T],string>`_
+  runnableExamples:
+    block:
+      var c: CritBitTree[void]
+      doAssert not c.containsOrIncl("key")
+      doAssert c.contains("key")
+    block:
+      var c: CritBitTree[void]
+      incl(c, "key")
+      doAssert c.containsOrIncl("key")
+
+  let oldCount = c.count
+  discard rawInsert(c, key)
+  result = c.count == oldCount
+
+proc inc*(c: var CritBitTree[int]; key: string, val: int = 1) =
+  ## Increments `c[key]` by `val`.
+  runnableExamples:
+    var c: CritBitTree[int]
+    c["key"] = 1
+    inc(c, "key")
+    doAssert c["key"] == 2
+
+  var n = rawInsert(c, key)
+  inc n.val, val
+
+proc incl*(c: var CritBitTree[void], key: string) =
+  ## Includes `key` in `c`.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,CritBitTree[T],string>`_
+  ## * `incl proc <#incl,CritBitTree[T],string,T>`_
+  runnableExamples:
+    var c: CritBitTree[void]
+    incl(c, "key")
+    doAssert c.hasKey("key")
+
+  discard rawInsert(c, key)
+
+proc incl*[T](c: var CritBitTree[T], key: string, val: sink T) =
+  ## Inserts `key` with value `val` into `c`.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,CritBitTree[T],string>`_
+  ## * `incl proc <#incl,CritBitTree[void],string>`_
+  runnableExamples:
+    var c: CritBitTree[int]
+    incl(c, "key", 42)
+    doAssert c["key"] == 42
+
+  var n = rawInsert(c, key)
+  n.val = val
+
+proc `[]=`*[T](c: var CritBitTree[T], key: string, val: sink T) =
+  ## Alias for `incl <#incl,CritBitTree[T],string,T>`_.
+  ##
+  ## **See also:**
+  ## * `[] proc <#[],CritBitTree[T],string>`_
+  ## * `[] proc <#[],CritBitTree[T],string_2>`_
+  var n = rawInsert(c, key)
+  n.val = val
+
+template get[T](c: CritBitTree[T], key: string): T =
+  let n = rawGet(c, key)
+  if n == nil:
+    raise newException(KeyError, "key not found: " & key)
+
+  n.val
+
+func `[]`*[T](c: CritBitTree[T], key: string): lent T {.inline.} =
+  ## Retrieves the value at `c[key]`. If `key` is not in `t`, the
+  ## `KeyError` exception is raised. One can check with `hasKey` whether
+  ## the key exists.
+  ##
+  ## **See also:**
+  ## * `[] proc <#[],CritBitTree[T],string_2>`_
+  ## * `[]= proc <#[]=,CritBitTree[T],string,T>`_
+  get(c, key)
+
+func `[]`*[T](c: var CritBitTree[T], key: string): var T {.inline.} =
+  ## Retrieves the value at `c[key]`. The value can be modified.
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  ##
+  ## **See also:**
+  ## * `[] proc <#[],CritBitTree[T],string>`_
+  ## * `[]= proc <#[]=,CritBitTree[T],string,T>`_
+  get(c, key)
+
+iterator leaves[T](n: Node[T]): Node[T] =
+  if n != nil:
+    # XXX actually we could compute the necessary stack size in advance:
+    # it's roughly log2(c.count).
+    var stack = @[n]
+    while stack.len > 0:
+      var it = stack.pop
+      while not it.isLeaf:
+        stack.add(it.child[1])
+        it = it.child[0]
+        assert(it != nil)
+      yield it
+
+iterator keys*[T](c: CritBitTree[T]): string =
+  ## Yields all keys in lexicographical order.
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 1, "key2": 2}.toCritBitTree
+    doAssert toSeq(c.keys) == @["key1", "key2"]
+
+  for x in leaves(c.root): yield x.key
+
+iterator values*[T](c: CritBitTree[T]): lent T =
+  ## Yields all values of `c` in the lexicographical order of the
+  ## corresponding keys.
+  ##
+  ## **See also:**
+  ## * `mvalues iterator <#mvalues.i,CritBitTree[T]>`_
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 1, "key2": 2}.toCritBitTree
+    doAssert toSeq(c.values) == @[1, 2]
+
+  for x in leaves(c.root): yield x.val
+
+iterator mvalues*[T](c: var CritBitTree[T]): var T =
+  ## Yields all values of `c` in the lexicographical order of the
+  ## corresponding keys. The values can be modified.
+  ##
+  ## **See also:**
+  ## * `values iterator <#values.i,CritBitTree[T]>`_
+  for x in leaves(c.root): yield x.val
+
+iterator items*[T](c: CritBitTree[T]): string =
+  ## Alias for `keys <#keys.i,CritBitTree[T]>`_.
+  for x in leaves(c.root): yield x.key
+
+iterator pairs*[T](c: CritBitTree[T]): tuple[key: string, val: T] =
+  ## Yields all `(key, value)`-pairs of `c` in the lexicographical order of the
+  ## corresponding keys.
+  ##
+  ## **See also:**
+  ## * `mpairs iterator <#mpairs.i,CritBitTree[T]>`_
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 1, "key2": 2}.toCritBitTree
+    doAssert toSeq(c.pairs) == @[(key: "key1", val: 1), (key: "key2", val: 2)]
+
+  for x in leaves(c.root): yield (x.key, x.val)
+
+iterator mpairs*[T](c: var CritBitTree[T]): tuple[key: string, val: var T] =
+  ## Yields all `(key, value)`-pairs of `c` in the lexicographical order of the
+  ## corresponding keys. The yielded values can be modified.
+  ##
+  ## **See also:**
+  ## * `pairs iterator <#pairs.i,CritBitTree[T]>`_
+  for x in leaves(c.root): yield (x.key, x.val)
+
+proc allprefixedAux[T](c: CritBitTree[T], key: string): Node[T] =
+  var p = c.root
+  var top = p
+  if p != nil:
+    while not p.isLeaf:
+      var q = p
+      let ch = if p.byte < key.len: key[p.byte] else: '\0'
+      let dir = (1 + (ch.ord or p.otherBits.ord)) shr 8
+      p = p.child[dir]
+      if q.byte < key.len: top = p
+    for i in 0 ..< key.len:
+      if i >= p.key.len or p.key[i] != key[i]: return
+    result = top
+
+iterator keysWithPrefix*[T](c: CritBitTree[T], prefix: string): string =
+  ## Yields all keys starting with `prefix`.
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 42, "key2": 43}.toCritBitTree
+    doAssert toSeq(c.keysWithPrefix("key")) == @["key1", "key2"]
+
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield x.key
+
+iterator valuesWithPrefix*[T](c: CritBitTree[T], prefix: string): lent T =
+  ## Yields all values of `c` starting with `prefix` of the
+  ## corresponding keys.
+  ##
+  ## **See also:**
+  ## * `mvaluesWithPrefix iterator <#mvaluesWithPrefix.i,CritBitTree[T],string>`_
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 42, "key2": 43}.toCritBitTree
+    doAssert toSeq(c.valuesWithPrefix("key")) == @[42, 43]
+
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield x.val
+
+iterator mvaluesWithPrefix*[T](c: var CritBitTree[T], prefix: string): var T =
+  ## Yields all values of `c` starting with `prefix` of the
+  ## corresponding keys. The values can be modified.
+  ##
+  ## **See also:**
+  ## * `valuesWithPrefix iterator <#valuesWithPrefix.i,CritBitTree[T],string>`_
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield x.val
+
+iterator itemsWithPrefix*[T](c: CritBitTree[T], prefix: string): string =
+  ## Alias for `keysWithPrefix <#keysWithPrefix.i,CritBitTree[T],string>`_.
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield x.key
+
+iterator pairsWithPrefix*[T](c: CritBitTree[T],
+                             prefix: string): tuple[key: string, val: T] =
+  ## Yields all (key, value)-pairs of `c` starting with `prefix`.
+  ##
+  ## **See also:**
+  ## * `mpairsWithPrefix iterator <#mpairsWithPrefix.i,CritBitTree[T],string>`_
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let c = {"key1": 42, "key2": 43}.toCritBitTree
+    doAssert toSeq(c.pairsWithPrefix("key")) == @[(key: "key1", val: 42), (key: "key2", val: 43)]
+
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield (x.key, x.val)
+
+iterator mpairsWithPrefix*[T](c: var CritBitTree[T],
+                              prefix: string): tuple[key: string, val: var T] =
+  ## Yields all (key, value)-pairs of `c` starting with `prefix`.
+  ## The yielded values can be modified.
+  ##
+  ## **See also:**
+  ## * `pairsWithPrefix iterator <#pairsWithPrefix.i,CritBitTree[T],string>`_
+  let top = allprefixedAux(c, prefix)
+  for x in leaves(top): yield (x.key, x.val)
+
+func `$`*[T](c: CritBitTree[T]): string =
+  ## Turns `c` into a string representation.
+  runnableExamples:
+    doAssert $CritBitTree[int].default == "{:}"
+    doAssert $toCritBitTree({"key1": 1, "key2": 2}) == """{"key1": 1, "key2": 2}"""
+    doAssert $CritBitTree[void].default == "{}"
+    doAssert $toCritBitTree(["key1", "key2"]) == """{"key1", "key2"}"""
+
+  if c.len == 0:
+    when T is void:
+      result = "{}"
+    else:
+      result = "{:}"
+  else:
+    # an educated guess is better than nothing:
+    when T is void:
+      const avgItemLen = 8
+    else:
+      const avgItemLen = 16
+    result = newStringOfCap(c.count * avgItemLen)
+    result.add("{")
+    when T is void:
+      for key in keys(c):
+        if result.len > 1: result.add(", ")
+        result.addQuoted(key)
+    else:
+      for key, val in pairs(c):
+        if result.len > 1: result.add(", ")
+        result.addQuoted(key)
+        result.add(": ")
+        result.addQuoted(val)
+    result.add("}")
+
+func commonPrefixLen*[T](c: CritBitTree[T]): int {.inline, since((1, 3)).} =
+  ## Returns the length of the longest common prefix of all keys in `c`.
+  ## If `c` is empty, returns 0.
+  runnableExamples:
+    var c: CritBitTree[void]
+    doAssert c.commonPrefixLen == 0
+    incl(c, "key1")
+    doAssert c.commonPrefixLen == 4
+    incl(c, "key2")
+    doAssert c.commonPrefixLen == 3
+
+  if c.root != nil:
+    if c.root.isLeaf: len(c.root.key)
+    else: c.root.byte
+  else: 0
+
+proc toCritBitTree*[T](pairs: sink openArray[(string, T)]): CritBitTree[T] {.since: (1, 3).} =
+  ## Creates a new `CritBitTree` that contains the given `pairs`.
+  runnableExamples:
+    doAssert {"a": "0", "b": "1", "c": "2"}.toCritBitTree is CritBitTree[string]
+    doAssert {"a": 0, "b": 1, "c": 2}.toCritBitTree is CritBitTree[int]
+
+  for item in pairs: result.incl item[0], item[1]
+
+proc toCritBitTree*(items: sink openArray[string]): CritBitTree[void] {.since: (1, 3).} =
+  ## Creates a new `CritBitTree` that contains the given `items`.
+  runnableExamples:
+    doAssert ["a", "b", "c"].toCritBitTree is CritBitTree[void]
+
+  for item in items: result.incl item
diff --git a/lib/pure/collections/deques.nim b/lib/pure/collections/deques.nim
new file mode 100644
index 000000000..d2b0099f2
--- /dev/null
+++ b/lib/pure/collections/deques.nim
@@ -0,0 +1,480 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## An implementation of a `deque`:idx: (double-ended queue).
+## The underlying implementation uses a `seq`.
+##
+## .. note:: None of the procs that get an individual value from the deque should be used
+##   on an empty deque.
+##
+## If compiled with the `boundChecks` option, those procs will raise an `IndexDefect`
+## on such access. This should not be relied upon, as `-d:danger` or `--checks:off` will
+## disable those checks and then the procs may return garbage or crash the program.
+##
+## As such, a check to see if the deque is empty is needed before any
+## access, unless your program logic guarantees it indirectly.
+
+runnableExamples:
+  var a = [10, 20, 30, 40].toDeque
+
+  doAssertRaises(IndexDefect, echo a[4])
+
+  a.addLast(50)
+  assert $a == "[10, 20, 30, 40, 50]"
+
+  assert a.peekFirst == 10
+  assert a.peekLast == 50
+  assert len(a) == 5
+
+  assert a.popFirst == 10
+  assert a.popLast == 50
+  assert len(a) == 3
+
+  a.addFirst(11)
+  a.addFirst(22)
+  a.addFirst(33)
+  assert $a == "[33, 22, 11, 20, 30, 40]"
+
+  a.shrink(fromFirst = 1, fromLast = 2)
+  assert $a == "[22, 11, 20]"
+
+## See also
+## ========
+## * `lists module <lists.html>`_ for singly and doubly linked lists and rings
+
+import std/private/since
+
+import std/[assertions, hashes, math]
+
+type
+  Deque*[T] = object
+    ## A double-ended queue backed with a ringed `seq` buffer.
+    ##
+    ## To initialize an empty deque,
+    ## use the `initDeque proc <#initDeque,int>`_.
+    data: seq[T]
+
+    # `head` and `tail` are masked only when accessing an element of `data`
+    # so that `tail - head == data.len` when the deque is full.
+    # They are uint so that incrementing/decrementing them doesn't cause
+    # over/underflow. You can get a number of items with `tail - head`
+    # even if `tail` or `head` is wraps around and `tail < head`, because
+    # `tail - head == (uint.high + 1 + tail) - head` when `tail < head`.
+    head, tail: uint
+
+const
+  defaultInitialSize* = 4
+
+template initImpl(result: typed, initialSize: int) =
+  let correctSize = nextPowerOfTwo(initialSize)
+  newSeq(result.data, correctSize)
+
+template checkIfInitialized(deq: typed) =
+  if deq.data.len == 0:
+    initImpl(deq, defaultInitialSize)
+
+func mask[T](deq: Deque[T]): uint {.inline.} =
+  uint(deq.data.len) - 1
+
+proc initDeque*[T](initialSize: int = defaultInitialSize): Deque[T] =
+  ## Creates a new empty deque.
+  ##
+  ## Optionally, the initial capacity can be reserved via `initialSize`
+  ## as a performance optimization
+  ## (default: `defaultInitialSize <#defaultInitialSize>`_).
+  ## The length of a newly created deque will still be 0.
+  ##
+  ## **See also:**
+  ## * `toDeque proc <#toDeque,openArray[T]>`_
+  result.initImpl(initialSize)
+
+func len*[T](deq: Deque[T]): int {.inline.} =
+  ## Returns the number of elements of `deq`.
+  int(deq.tail - deq.head)
+
+template emptyCheck(deq) =
+  # Bounds check for the regular deque access.
+  when compileOption("boundChecks"):
+    if unlikely(deq.len < 1):
+      raise newException(IndexDefect, "Empty deque.")
+
+template xBoundsCheck(deq, i) =
+  # Bounds check for the array like accesses.
+  when compileOption("boundChecks"): # `-d:danger` or `--checks:off` should disable this.
+    if unlikely(i >= deq.len): # x < deq.low is taken care by the Natural parameter
+      raise newException(IndexDefect,
+                         "Out of bounds: " & $i & " > " & $(deq.len - 1))
+    if unlikely(i < 0): # when used with BackwardsIndex
+      raise newException(IndexDefect,
+                         "Out of bounds: " & $i & " < 0")
+
+proc `[]`*[T](deq: Deque[T], i: Natural): lent T {.inline.} =
+  ## Accesses the `i`-th element of `deq`.
+  runnableExamples:
+    let a = [10, 20, 30, 40, 50].toDeque
+    assert a[0] == 10
+    assert a[3] == 40
+    doAssertRaises(IndexDefect, echo a[8])
+
+  xBoundsCheck(deq, i)
+  return deq.data[(deq.head + i.uint) and deq.mask]
+
+proc `[]`*[T](deq: var Deque[T], i: Natural): var T {.inline.} =
+  ## Accesses the `i`-th element of `deq` and returns a mutable
+  ## reference to it.
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    inc(a[0])
+    assert a[0] == 11
+
+  xBoundsCheck(deq, i)
+  return deq.data[(deq.head + i.uint) and deq.mask]
+
+proc `[]=`*[T](deq: var Deque[T], i: Natural, val: sink T) {.inline.} =
+  ## Sets the `i`-th element of `deq` to `val`.
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    a[0] = 99
+    a[3] = 66
+    assert $a == "[99, 20, 30, 66, 50]"
+
+  checkIfInitialized(deq)
+  xBoundsCheck(deq, i)
+  deq.data[(deq.head + i.uint) and deq.mask] = val
+
+proc `[]`*[T](deq: Deque[T], i: BackwardsIndex): lent T {.inline.} =
+  ## Accesses the backwards indexed `i`-th element.
+  ##
+  ## `deq[^1]` is the last element.
+  runnableExamples:
+    let a = [10, 20, 30, 40, 50].toDeque
+    assert a[^1] == 50
+    assert a[^4] == 20
+    doAssertRaises(IndexDefect, echo a[^9])
+
+  xBoundsCheck(deq, deq.len - int(i))
+  return deq[deq.len - int(i)]
+
+proc `[]`*[T](deq: var Deque[T], i: BackwardsIndex): var T {.inline.} =
+  ## Accesses the backwards indexed `i`-th element and returns a mutable
+  ## reference to it.
+  ##
+  ## `deq[^1]` is the last element.
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    inc(a[^1])
+    assert a[^1] == 51
+
+  xBoundsCheck(deq, deq.len - int(i))
+  return deq[deq.len - int(i)]
+
+proc `[]=`*[T](deq: var Deque[T], i: BackwardsIndex, x: sink T) {.inline.} =
+  ## Sets the backwards indexed `i`-th element of `deq` to `x`.
+  ##
+  ## `deq[^1]` is the last element.
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    a[^1] = 99
+    a[^3] = 77
+    assert $a == "[10, 20, 77, 40, 99]"
+
+  checkIfInitialized(deq)
+  xBoundsCheck(deq, deq.len - int(i))
+  deq[deq.len - int(i)] = x
+
+iterator items*[T](deq: Deque[T]): lent T =
+  ## Yields every element of `deq`.
+  ##
+  ## **See also:**
+  ## * `mitems iterator <#mitems.i,Deque[T]>`_
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let a = [10, 20, 30, 40, 50].toDeque
+    assert toSeq(a.items) == @[10, 20, 30, 40, 50]
+
+  for c in 0 ..< deq.len:
+    yield deq.data[(deq.head + c.uint) and deq.mask]
+
+iterator mitems*[T](deq: var Deque[T]): var T =
+  ## Yields every element of `deq`, which can be modified.
+  ##
+  ## **See also:**
+  ## * `items iterator <#items.i,Deque[T]>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    for x in mitems(a):
+      x = 5 * x - 1
+    assert $a == "[49, 99, 149, 199, 249]"
+
+  for c in 0 ..< deq.len:
+    yield deq.data[(deq.head + c.uint) and deq.mask]
+
+iterator pairs*[T](deq: Deque[T]): tuple[key: int, val: T] =
+  ## Yields every `(position, value)`-pair of `deq`.
+  runnableExamples:
+    from std/sequtils import toSeq
+
+    let a = [10, 20, 30].toDeque
+    assert toSeq(a.pairs) == @[(0, 10), (1, 20), (2, 30)]
+
+  for c in 0 ..< deq.len:
+    yield (c, deq.data[(deq.head + c.uint) and deq.mask])
+
+proc contains*[T](deq: Deque[T], item: T): bool {.inline.} =
+  ## Returns true if `item` is in `deq` or false if not found.
+  ##
+  ## Usually used via the `in` operator.
+  ## It is the equivalent of `deq.find(item) >= 0`.
+  runnableExamples:
+    let q = [7, 9].toDeque
+    assert 7 in q
+    assert q.contains(7)
+    assert 8 notin q
+
+  for e in deq:
+    if e == item: return true
+  return false
+
+proc expandIfNeeded[T](deq: var Deque[T]) =
+  checkIfInitialized(deq)
+  let cap = deq.data.len
+  assert deq.len <= cap
+  if unlikely(deq.len == cap):
+    var n = newSeq[T](cap * 2)
+    var i = 0
+    for x in mitems(deq):
+      when nimvm: n[i] = x # workaround for VM bug
+      else: n[i] = move(x)
+      inc i
+    deq.data = move(n)
+    deq.tail = cap.uint
+    deq.head = 0
+
+proc addFirst*[T](deq: var Deque[T], item: sink T) =
+  ## Adds an `item` to the beginning of `deq`.
+  ##
+  ## **See also:**
+  ## * `addLast proc <#addLast,Deque[T],sinkT>`_
+  runnableExamples:
+    var a = initDeque[int]()
+    for i in 1 .. 5:
+      a.addFirst(10 * i)
+    assert $a == "[50, 40, 30, 20, 10]"
+
+  expandIfNeeded(deq)
+  dec deq.head
+  deq.data[deq.head and deq.mask] = item
+
+proc addLast*[T](deq: var Deque[T], item: sink T) =
+  ## Adds an `item` to the end of `deq`.
+  ##
+  ## **See also:**
+  ## * `addFirst proc <#addFirst,Deque[T],sinkT>`_
+  runnableExamples:
+    var a = initDeque[int]()
+    for i in 1 .. 5:
+      a.addLast(10 * i)
+    assert $a == "[10, 20, 30, 40, 50]"
+
+  expandIfNeeded(deq)
+  deq.data[deq.tail and deq.mask] = item
+  inc deq.tail
+
+proc toDeque*[T](x: openArray[T]): Deque[T] {.since: (1, 3).} =
+  ## Creates a new deque that contains the elements of `x` (in the same order).
+  ##
+  ## **See also:**
+  ## * `initDeque proc <#initDeque,int>`_
+  runnableExamples:
+    let a = toDeque([7, 8, 9])
+    assert len(a) == 3
+    assert $a == "[7, 8, 9]"
+
+  result.initImpl(x.len)
+  for item in items(x):
+    result.addLast(item)
+
+proc peekFirst*[T](deq: Deque[T]): lent T {.inline.} =
+  ## Returns the first element of `deq`, but does not remove it from the deque.
+  ##
+  ## **See also:**
+  ## * `peekFirst proc <#peekFirst,Deque[T]_2>`_ which returns a mutable reference
+  ## * `peekLast proc <#peekLast,Deque[T]>`_
+  runnableExamples:
+    let a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    assert a.peekFirst == 10
+    assert len(a) == 5
+
+  emptyCheck(deq)
+  result = deq.data[deq.head and deq.mask]
+
+proc peekLast*[T](deq: Deque[T]): lent T {.inline.} =
+  ## Returns the last element of `deq`, but does not remove it from the deque.
+  ##
+  ## **See also:**
+  ## * `peekLast proc <#peekLast,Deque[T]_2>`_ which returns a mutable reference
+  ## * `peekFirst proc <#peekFirst,Deque[T]>`_
+  runnableExamples:
+    let a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    assert a.peekLast == 50
+    assert len(a) == 5
+
+  emptyCheck(deq)
+  result = deq.data[(deq.tail - 1) and deq.mask]
+
+proc peekFirst*[T](deq: var Deque[T]): var T {.inline, since: (1, 3).} =
+  ## Returns a mutable reference to the first element of `deq`,
+  ## but does not remove it from the deque.
+  ##
+  ## **See also:**
+  ## * `peekFirst proc <#peekFirst,Deque[T]>`_
+  ## * `peekLast proc <#peekLast,Deque[T]_2>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    a.peekFirst() = 99
+    assert $a == "[99, 20, 30, 40, 50]"
+
+  emptyCheck(deq)
+  result = deq.data[deq.head and deq.mask]
+
+proc peekLast*[T](deq: var Deque[T]): var T {.inline, since: (1, 3).} =
+  ## Returns a mutable reference to the last element of `deq`,
+  ## but does not remove it from the deque.
+  ##
+  ## **See also:**
+  ## * `peekFirst proc <#peekFirst,Deque[T]_2>`_
+  ## * `peekLast proc <#peekLast,Deque[T]>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    a.peekLast() = 99
+    assert $a == "[10, 20, 30, 40, 99]"
+
+  emptyCheck(deq)
+  result = deq.data[(deq.tail - 1) and deq.mask]
+
+template destroy(x: untyped) =
+  reset(x)
+
+proc popFirst*[T](deq: var Deque[T]): T {.inline, discardable.} =
+  ## Removes and returns the first element of the `deq`.
+  ##
+  ## See also:
+  ## * `popLast proc <#popLast,Deque[T]>`_
+  ## * `shrink proc <#shrink,Deque[T],int,int>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    assert a.popFirst == 10
+    assert $a == "[20, 30, 40, 50]"
+
+  emptyCheck(deq)
+  result = move deq.data[deq.head and deq.mask]
+  inc deq.head
+
+proc popLast*[T](deq: var Deque[T]): T {.inline, discardable.} =
+  ## Removes and returns the last element of the `deq`.
+  ##
+  ## **See also:**
+  ## * `popFirst proc <#popFirst,Deque[T]>`_
+  ## * `shrink proc <#shrink,Deque[T],int,int>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    assert a.popLast == 50
+    assert $a == "[10, 20, 30, 40]"
+
+  emptyCheck(deq)
+  dec deq.tail
+  result = move deq.data[deq.tail and deq.mask]
+
+proc clear*[T](deq: var Deque[T]) {.inline.} =
+  ## Resets the deque so that it is empty.
+  ##
+  ## **See also:**
+  ## * `shrink proc <#shrink,Deque[T],int,int>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    clear(a)
+    assert len(a) == 0
+
+  for el in mitems(deq): destroy(el)
+  deq.tail = deq.head
+
+proc shrink*[T](deq: var Deque[T], fromFirst = 0, fromLast = 0) =
+  ## Removes `fromFirst` elements from the front of the deque and
+  ## `fromLast` elements from the back.
+  ##
+  ## If the supplied number of elements exceeds the total number of elements
+  ## in the deque, the deque will remain empty.
+  ##
+  ## **See also:**
+  ## * `clear proc <#clear,Deque[T]>`_
+  ## * `popFirst proc <#popFirst,Deque[T]>`_
+  ## * `popLast proc <#popLast,Deque[T]>`_
+  runnableExamples:
+    var a = [10, 20, 30, 40, 50].toDeque
+    assert $a == "[10, 20, 30, 40, 50]"
+    a.shrink(fromFirst = 2, fromLast = 1)
+    assert $a == "[30, 40]"
+
+  if fromFirst + fromLast > deq.len:
+    clear(deq)
+    return
+
+  for i in 0 ..< fromFirst:
+    destroy(deq.data[deq.head and deq.mask])
+    inc deq.head
+
+  for i in 0 ..< fromLast:
+    destroy(deq.data[(deq.tail - 1) and deq.mask])
+    dec deq.tail
+
+proc `$`*[T](deq: Deque[T]): string =
+  ## Turns a deque into its string representation.
+  runnableExamples:
+    let a = [10, 20, 30].toDeque
+    assert $a == "[10, 20, 30]"
+
+  result = "["
+  for x in deq:
+    if result.len > 1: result.add(", ")
+    result.addQuoted(x)
+  result.add("]")
+
+func `==`*[T](deq1, deq2: Deque[T]): bool =
+  ## The `==` operator for Deque.
+  ## Returns `true` if both deques contains the same values in the same order.
+  runnableExamples:
+    var a, b = initDeque[int]()
+    a.addFirst(2)
+    a.addFirst(1)
+    b.addLast(1)
+    b.addLast(2)
+    doAssert a == b
+
+  if deq1.len != deq2.len:
+    return false
+
+  for i in 0 ..< deq1.len:
+    if deq1.data[(deq1.head + i.uint) and deq1.mask] != deq2.data[(deq2.head + i.uint) and deq2.mask]:
+      return false
+
+  true
+
+func hash*[T](deq: Deque[T]): Hash =
+  ## Hashing of Deque.
+  var h: Hash = 0
+  for x in deq:
+    h = h !& hash(x)
+  !$h
diff --git a/lib/pure/collections/hashcommon.nim b/lib/pure/collections/hashcommon.nim
new file mode 100644
index 000000000..17785c8c7
--- /dev/null
+++ b/lib/pure/collections/hashcommon.nim
@@ -0,0 +1,76 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# An `include` file which contains common code for
+# hash sets and tables.
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+import std / outparams
+
+const
+  growthFactor = 2
+
+# hcode for real keys cannot be zero.  hcode==0 signifies an empty slot.  These
+# two procs retain clarity of that encoding without the space cost of an enum.
+proc isEmpty(hcode: Hash): bool {.inline.} =
+  result = hcode == 0
+
+proc isFilled(hcode: Hash): bool {.inline.} =
+  result = hcode != 0
+
+proc nextTry(h, maxHash: Hash): Hash {.inline.} =
+  result = (h + 1) and maxHash
+
+proc mustRehash[T](t: T): bool {.inline.} =
+  # If this is changed, make sure to synchronize it with `slotsNeeded` below
+  assert(t.dataLen > t.counter)
+  result = (t.dataLen * 2 < t.counter * 3) or (t.dataLen - t.counter < 4)
+
+proc slotsNeeded(count: Natural): int {.inline.} =
+  # Make sure to synchronize with `mustRehash` above
+  result = nextPowerOfTwo(count * 3 div 2 + 4)
+
+template rawGetKnownHCImpl() {.dirty.} =
+  if t.dataLen == 0:
+    return -1
+  var h: Hash = hc and maxHash(t) # start with real hash value
+  while isFilled(t.data[h].hcode):
+    # Compare hc THEN key with boolean short circuit. This makes the common case
+    # zero ==key's for missing (e.g.inserts) and exactly one ==key for present.
+    # It does slow down succeeding lookups by one extra Hash cmp&and..usually
+    # just a few clock cycles, generally worth it for any non-integer-like A.
+    if t.data[h].hcode == hc and t.data[h].key == key:
+      return h
+    h = nextTry(h, maxHash(t))
+  result = -1 - h # < 0 => MISSING; insert idx = -1 - result
+
+proc rawGetKnownHC[X, A](t: X, key: A, hc: Hash): int {.inline.} =
+  rawGetKnownHCImpl()
+
+template genHashImpl(key, hc: typed) =
+  hc = hash(key)
+  if hc == 0: # This almost never taken branch should be very predictable.
+    when sizeof(int) < 4:
+      hc = 31415 # Value doesn't matter; Any non-zero favorite is fine <= 16-bit.
+    else:
+      hc = 314159265 # Value doesn't matter; Any non-zero favorite is fine.
+
+template genHash(key: typed): Hash =
+  var res: Hash
+  genHashImpl(key, res)
+  res
+
+template rawGetImpl() {.dirty.} =
+  genHashImpl(key, hc)
+  rawGetKnownHCImpl()
+
+proc rawGet[X, A](t: X, key: A, hc: var Hash): int {.inline, outParamsAt: [3].} =
+  rawGetImpl()
diff --git a/lib/pure/collections/heapqueue.nim b/lib/pure/collections/heapqueue.nim
new file mode 100644
index 000000000..96f9b4430
--- /dev/null
+++ b/lib/pure/collections/heapqueue.nim
@@ -0,0 +1,266 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Yuriy Glukhov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+
+
+## The `heapqueue` module implements a
+## `binary heap data structure<https://en.wikipedia.org/wiki/Binary_heap>`_
+## that can be used as a `priority queue<https://en.wikipedia.org/wiki/Priority_queue>`_.
+## They are represented as arrays for which `a[k] <= a[2*k+1]` and `a[k] <= a[2*k+2]`
+## for all indices `k` (counting elements from 0). The interesting property of a heap is that
+## `a[0]` is always its smallest element.
+##
+## Basic usage
+## -----------
+##
+runnableExamples:
+  var heap = [8, 2].toHeapQueue
+  heap.push(5)
+  # the first element is the lowest element
+  assert heap[0] == 2
+  # remove and return the lowest element
+  assert heap.pop() == 2
+  # the lowest element remaining is 5
+  assert heap[0] == 5
+
+## Usage with custom objects
+## -------------------------
+## To use a `HeapQueue` with a custom object, the `<` operator must be
+## implemented.
+
+runnableExamples:
+  type Job = object
+    priority: int
+
+  proc `<`(a, b: Job): bool = a.priority < b.priority
+
+  var jobs = initHeapQueue[Job]()
+  jobs.push(Job(priority: 1))
+  jobs.push(Job(priority: 2))
+
+  assert jobs[0].priority == 1
+
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type HeapQueue*[T] = object
+  ## A heap queue, commonly known as a priority queue.
+  data: seq[T]
+
+proc initHeapQueue*[T](): HeapQueue[T] =
+  ## Creates a new empty heap.
+  ##
+  ## Heaps are initialized by default, so it is not necessary to call
+  ## this function explicitly.
+  ##
+  ## **See also:**
+  ## * `toHeapQueue proc <#toHeapQueue,openArray[T]>`_
+  result = default(HeapQueue[T])
+
+proc len*[T](heap: HeapQueue[T]): int {.inline.} =
+  ## Returns the number of elements of `heap`.
+  runnableExamples:
+    let heap = [9, 5, 8].toHeapQueue
+    assert heap.len == 3
+
+  heap.data.len
+
+proc `[]`*[T](heap: HeapQueue[T], i: Natural): lent T {.inline.} =
+  ## Accesses the i-th element of `heap`.
+  heap.data[i]
+
+iterator items*[T](heap: HeapQueue[T]): lent T {.inline, since: (2, 1, 1).} =
+  ## Iterates over each item of `heap`.
+  let L = len(heap)
+  for i in 0 .. high(heap.data):
+    yield heap.data[i]
+    assert(len(heap) == L, "the length of the HeapQueue changed while iterating over it")
+
+proc heapCmp[T](x, y: T): bool {.inline.} = x < y
+
+proc siftup[T](heap: var HeapQueue[T], startpos, p: int) =
+  ## `heap` is a heap at all indices >= `startpos`, except possibly for `p`. `p`
+  ## is the index of a leaf with a possibly out-of-order value. Restores the
+  ## heap invariant.
+  var pos = p
+  let newitem = heap[pos]
+  # Follow the path to the root, moving parents down until finding a place
+  # newitem fits.
+  while pos > startpos:
+    let parentpos = (pos - 1) shr 1
+    let parent = heap[parentpos]
+    if heapCmp(newitem, parent):
+      heap.data[pos] = parent
+      pos = parentpos
+    else:
+      break
+  heap.data[pos] = newitem
+
+proc siftdownToBottom[T](heap: var HeapQueue[T], p: int) =
+  # This is faster when the element should be close to the bottom.
+  let endpos = len(heap)
+  var pos = p
+  let startpos = pos
+  let newitem = heap[pos]
+  # Bubble up the smaller child until hitting a leaf.
+  var childpos = 2 * pos + 1 # leftmost child position
+  while childpos < endpos:
+    # Set childpos to index of smaller child.
+    let rightpos = childpos + 1
+    if rightpos < endpos and not heapCmp(heap[childpos], heap[rightpos]):
+      childpos = rightpos
+    # Move the smaller child up.
+    heap.data[pos] = heap[childpos]
+    pos = childpos
+    childpos = 2 * pos + 1
+  # The leaf at pos is empty now. Put newitem there, and bubble it up
+  # to its final resting place (by sifting its parents down).
+  heap.data[pos] = newitem
+  siftup(heap, startpos, pos)
+
+proc siftdown[T](heap: var HeapQueue[T], p: int) =
+  let endpos = len(heap)
+  var pos = p
+  let newitem = heap[pos]
+  var childpos = 2 * pos + 1
+  while childpos < endpos:
+    let rightpos = childpos + 1
+    if rightpos < endpos and not heapCmp(heap[childpos], heap[rightpos]):
+      childpos = rightpos
+    if not heapCmp(heap[childpos], newitem):
+      break
+    heap.data[pos] = heap[childpos]
+    pos = childpos
+    childpos = 2 * pos + 1
+  heap.data[pos] = newitem
+
+proc push*[T](heap: var HeapQueue[T], item: sink T) =
+  ## Pushes `item` onto `heap`, maintaining the heap invariant.
+  heap.data.add(item)
+  siftup(heap, 0, len(heap) - 1)
+
+proc toHeapQueue*[T](x: openArray[T]): HeapQueue[T] {.since: (1, 3).} =
+  ## Creates a new HeapQueue that contains the elements of `x`.
+  ##
+  ## **See also:**
+  ## * `initHeapQueue proc <#initHeapQueue>`_
+  runnableExamples:
+    var heap = [9, 5, 8].toHeapQueue
+    assert heap.pop() == 5
+    assert heap[0] == 8
+
+  # see https://en.wikipedia.org/wiki/Binary_heap#Building_a_heap
+  result.data = @x
+  for i in countdown(x.len div 2 - 1, 0):
+    siftdown(result, i)
+
+proc pop*[T](heap: var HeapQueue[T]): T =
+  ## Pops and returns the smallest item from `heap`,
+  ## maintaining the heap invariant.
+  runnableExamples:
+    var heap = [9, 5, 8].toHeapQueue
+    assert heap.pop() == 5
+
+  let lastelt = heap.data.pop()
+  if heap.len > 0:
+    result = heap[0]
+    heap.data[0] = lastelt
+    siftdownToBottom(heap, 0)
+  else:
+    result = lastelt
+
+proc find*[T](heap: HeapQueue[T], x: T): int {.since: (1, 3).} =
+  ## Linear scan to find the index of the item `x` or -1 if not found.
+  runnableExamples:
+    let heap = [9, 5, 8].toHeapQueue
+    assert heap.find(5) == 0
+    assert heap.find(9) == 1
+    assert heap.find(777) == -1
+
+  result = -1
+  for i in 0 ..< heap.len:
+    if heap[i] == x: return i
+
+proc contains*[T](heap: HeapQueue[T], x: T): bool {.since: (2, 1, 1).} =
+  ## Returns true if `x` is in `heap` or false if not found. This is a shortcut
+  ## for `find(heap, x) >= 0`.
+  result = find(heap, x) >= 0
+
+proc del*[T](heap: var HeapQueue[T], index: Natural) =
+  ## Removes the element at `index` from `heap`, maintaining the heap invariant.
+  runnableExamples:
+    var heap = [9, 5, 8].toHeapQueue
+    heap.del(1)
+    assert heap[0] == 5
+    assert heap[1] == 8
+
+  swap(heap.data[^1], heap.data[index])
+  let newLen = heap.len - 1
+  heap.data.setLen(newLen)
+  if index < newLen:
+    siftdownToBottom(heap, index)
+
+proc replace*[T](heap: var HeapQueue[T], item: sink T): T =
+  ## Pops and returns the current smallest value, and add the new item.
+  ## This is more efficient than `pop()` followed by `push()`, and can be
+  ## more appropriate when using a fixed-size heap. Note that the value
+  ## returned may be larger than `item`! That constrains reasonable uses of
+  ## this routine unless written as part of a conditional replacement.
+  ##
+  ## **See also:**
+  ## * `pushpop proc <#pushpop,HeapQueue[T],sinkT>`_
+  runnableExamples:
+    var heap = [5, 12].toHeapQueue
+    assert heap.replace(6) == 5
+    assert heap.len == 2
+    assert heap[0] == 6
+    assert heap.replace(4) == 6
+
+  result = heap[0]
+  heap.data[0] = item
+  siftdown(heap, 0)
+
+proc pushpop*[T](heap: var HeapQueue[T], item: sink T): T =
+  ## Fast version of a `push()` followed by a `pop()`.
+  ##
+  ## **See also:**
+  ## * `replace proc <#replace,HeapQueue[T],sinkT>`_
+  runnableExamples:
+    var heap = [5, 12].toHeapQueue
+    assert heap.pushpop(6) == 5
+    assert heap.len == 2
+    assert heap[0] == 6
+    assert heap.pushpop(4) == 4
+
+  result = item
+  if heap.len > 0 and heapCmp(heap.data[0], result):
+    swap(result, heap.data[0])
+    siftdown(heap, 0)
+
+proc clear*[T](heap: var HeapQueue[T]) =
+  ## Removes all elements from `heap`, making it empty.
+  runnableExamples:
+    var heap = [9, 5, 8].toHeapQueue
+    heap.clear()
+    assert heap.len == 0
+
+  heap.data.setLen(0)
+
+proc `$`*[T](heap: HeapQueue[T]): string =
+  ## Turns a heap into its string representation.
+  runnableExamples:
+    let heap = [1, 2].toHeapQueue
+    assert $heap == "[1, 2]"
+
+  result = "["
+  for x in heap.data:
+    if result.len > 1: result.add(", ")
+    result.addQuoted(x)
+  result.add("]")
diff --git a/lib/pure/collections/intsets.nim b/lib/pure/collections/intsets.nim
new file mode 100644
index 000000000..765a23e97
--- /dev/null
+++ b/lib/pure/collections/intsets.nim
@@ -0,0 +1,23 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Specialization of the generic `packedsets module <packedsets.html>`_
+## (see its documentation for more examples) for ordinal sparse sets.
+
+import std/private/since
+import std/packedsets
+export packedsets
+
+type
+  IntSet* = PackedSet[int]
+
+proc toIntSet*(x: openArray[int]): IntSet {.since: (1, 3), inline.} = toPackedSet[int](x)
+
+proc initIntSet*(): IntSet {.inline.} = initPackedSet[int]()
+
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim
new file mode 100644
index 000000000..6b88747ef
--- /dev/null
+++ b/lib/pure/collections/lists.nim
@@ -0,0 +1,1015 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Implementation of:
+## * `singly linked lists <#SinglyLinkedList>`_
+## * `doubly linked lists <#DoublyLinkedList>`_
+## * `singly linked rings <#SinglyLinkedRing>`_ (circular lists)
+## * `doubly linked rings <#DoublyLinkedRing>`_ (circular lists)
+##
+## # Basic Usage
+## Because it makes no sense to do otherwise, the `next` and `prev` pointers
+## are not hidden from you and can be manipulated directly for efficiency.
+##
+## ## Lists
+runnableExamples:
+  var list = initDoublyLinkedList[int]()
+  let
+    a = newDoublyLinkedNode[int](3)
+    b = newDoublyLinkedNode[int](7)
+    c = newDoublyLinkedNode[int](9)
+
+  list.add(a)
+  list.add(b)
+  list.prepend(c)
+
+  assert a.next == b
+  assert a.prev == c
+  assert c.next == a
+  assert c.next.next == b
+  assert c.prev == nil
+  assert b.next == nil
+
+## ## Rings
+runnableExamples:
+  var ring = initSinglyLinkedRing[int]()
+  let
+    a = newSinglyLinkedNode[int](3)
+    b = newSinglyLinkedNode[int](7)
+    c = newSinglyLinkedNode[int](9)
+
+  ring.add(a)
+  ring.add(b)
+  ring.prepend(c)
+
+  assert c.next == a
+  assert a.next == b
+  assert c.next.next == b
+  assert b.next == c
+  assert c.next.next.next == c
+
+## # See also
+## * `deques module <deques.html>`_ for double-ended queues
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type
+  DoublyLinkedNodeObj*[T] = object
+    ## A node of a doubly linked list.
+    ##
+    ## It consists of a `value` field, and pointers to `next` and `prev`.
+    next*: DoublyLinkedNode[T]
+    prev* {.cursor.}: DoublyLinkedNode[T]
+    value*: T
+  DoublyLinkedNode*[T] = ref DoublyLinkedNodeObj[T]
+
+  SinglyLinkedNodeObj*[T] = object
+    ## A node of a singly linked list.
+    ##
+    ## It consists of a `value` field, and a pointer to `next`.
+    next*: SinglyLinkedNode[T]
+    value*: T
+  SinglyLinkedNode*[T] = ref SinglyLinkedNodeObj[T]
+
+  SinglyLinkedList*[T] = object
+    ## A singly linked list.
+    head*: SinglyLinkedNode[T]
+    tail* {.cursor.}: SinglyLinkedNode[T]
+
+  DoublyLinkedList*[T] = object
+    ## A doubly linked list.
+    head*: DoublyLinkedNode[T]
+    tail* {.cursor.}: DoublyLinkedNode[T]
+
+  SinglyLinkedRing*[T] = object
+    ## A singly linked ring.
+    head*: SinglyLinkedNode[T]
+    tail* {.cursor.}: SinglyLinkedNode[T]
+
+  DoublyLinkedRing*[T] = object
+    ## A doubly linked ring.
+    head*: DoublyLinkedNode[T]
+
+  SomeLinkedList*[T] = SinglyLinkedList[T] | DoublyLinkedList[T]
+
+  SomeLinkedRing*[T] = SinglyLinkedRing[T] | DoublyLinkedRing[T]
+
+  SomeLinkedCollection*[T] = SomeLinkedList[T] | SomeLinkedRing[T]
+
+  SomeLinkedNode*[T] = SinglyLinkedNode[T] | DoublyLinkedNode[T]
+
+proc initSinglyLinkedList*[T](): SinglyLinkedList[T] =
+  ## Creates a new singly linked list that is empty.
+  ##
+  ## Singly linked lists are initialized by default, so it is not necessary to
+  ## call this function explicitly.
+  runnableExamples:
+    let a = initSinglyLinkedList[int]()
+
+  discard
+
+proc initDoublyLinkedList*[T](): DoublyLinkedList[T] =
+  ## Creates a new doubly linked list that is empty.
+  ##
+  ## Doubly linked lists are initialized by default, so it is not necessary to
+  ## call this function explicitly.
+  runnableExamples:
+    let a = initDoublyLinkedList[int]()
+
+  discard
+
+proc initSinglyLinkedRing*[T](): SinglyLinkedRing[T] =
+  ## Creates a new singly linked ring that is empty.
+  ##
+  ## Singly linked rings are initialized by default, so it is not necessary to
+  ## call this function explicitly.
+  runnableExamples:
+    let a = initSinglyLinkedRing[int]()
+
+  discard
+
+proc initDoublyLinkedRing*[T](): DoublyLinkedRing[T] =
+  ## Creates a new doubly linked ring that is empty.
+  ##
+  ## Doubly linked rings are initialized by default, so it is not necessary to
+  ## call this function explicitly.
+  runnableExamples:
+    let a = initDoublyLinkedRing[int]()
+
+  discard
+
+proc newDoublyLinkedNode*[T](value: T): DoublyLinkedNode[T] =
+  ## Creates a new doubly linked node with the given `value`.
+  runnableExamples:
+    let n = newDoublyLinkedNode[int](5)
+    assert n.value == 5
+
+  new(result)
+  result.value = value
+
+proc newSinglyLinkedNode*[T](value: T): SinglyLinkedNode[T] =
+  ## Creates a new singly linked node with the given `value`.
+  runnableExamples:
+    let n = newSinglyLinkedNode[int](5)
+    assert n.value == 5
+
+  new(result)
+  result.value = value
+
+template itemsListImpl() {.dirty.} =
+  var it {.cursor.} = L.head
+  while it != nil:
+    yield it.value
+    it = it.next
+
+template itemsRingImpl() {.dirty.} =
+  var it {.cursor.} = L.head
+  if it != nil:
+    while true:
+      yield it.value
+      it = it.next
+      if it == L.head: break
+
+iterator items*[T](L: SomeLinkedList[T]): T =
+  ## Yields every value of `L`.
+  ##
+  ## **See also:**
+  ## * `mitems iterator <#mitems.i,SomeLinkedList[T]>`_
+  ## * `nodes iterator <#nodes.i,SomeLinkedList[T]>`_
+  runnableExamples:
+    from std/sugar import collect
+    from std/sequtils import toSeq
+    let a = collect(initSinglyLinkedList):
+      for i in 1..3: 10 * i
+    assert toSeq(items(a)) == toSeq(a)
+    assert toSeq(a) == @[10, 20, 30]
+
+  itemsListImpl()
+
+iterator items*[T](L: SomeLinkedRing[T]): T =
+  ## Yields every value of `L`.
+  ##
+  ## **See also:**
+  ## * `mitems iterator <#mitems.i,SomeLinkedRing[T]>`_
+  ## * `nodes iterator <#nodes.i,SomeLinkedRing[T]>`_
+  runnableExamples:
+    from std/sugar import collect
+    from std/sequtils import toSeq
+    let a = collect(initSinglyLinkedRing):
+      for i in 1..3: 10 * i
+    assert toSeq(items(a)) == toSeq(a)
+    assert toSeq(a) == @[10, 20, 30]
+
+  itemsRingImpl()
+
+iterator mitems*[T](L: var SomeLinkedList[T]): var T =
+  ## Yields every value of `L` so that you can modify it.
+  ##
+  ## **See also:**
+  ## * `items iterator <#items.i,SomeLinkedList[T]>`_
+  ## * `nodes iterator <#nodes.i,SomeLinkedList[T]>`_
+  runnableExamples:
+    var a = initSinglyLinkedList[int]()
+    for i in 1..5:
+      a.add(10 * i)
+    assert $a == "[10, 20, 30, 40, 50]"
+    for x in mitems(a):
+      x = 5 * x - 1
+    assert $a == "[49, 99, 149, 199, 249]"
+
+  itemsListImpl()
+
+iterator mitems*[T](L: var SomeLinkedRing[T]): var T =
+  ## Yields every value of `L` so that you can modify it.
+  ##
+  ## **See also:**
+  ## * `items iterator <#items.i,SomeLinkedRing[T]>`_
+  ## * `nodes iterator <#nodes.i,SomeLinkedRing[T]>`_
+  runnableExamples:
+    var a = initSinglyLinkedRing[int]()
+    for i in 1..5:
+      a.add(10 * i)
+    assert $a == "[10, 20, 30, 40, 50]"
+    for x in mitems(a):
+      x = 5 * x - 1
+    assert $a == "[49, 99, 149, 199, 249]"
+
+  itemsRingImpl()
+
+iterator nodes*[T](L: SomeLinkedList[T]): SomeLinkedNode[T] =
+  ## Iterates over every node of `x`. Removing the current node from the
+  ## list during traversal is supported.
+  ##
+  ## **See also:**
+  ## * `items iterator <#items.i,SomeLinkedList[T]>`_
+  ## * `mitems iterator <#mitems.i,SomeLinkedList[T]>`_
+  runnableExamples:
+    var a = initDoublyLinkedList[int]()
+    for i in 1..5:
+      a.add(10 * i)
+    assert $a == "[10, 20, 30, 40, 50]"
+    for x in nodes(a):
+      if x.value == 30:
+        a.remove(x)
+      else:
+        x.value = 5 * x.value - 1
+    assert $a == "[49, 99, 199, 249]"
+
+  var it {.cursor.} = L.head
+  while it != nil:
+    let nxt = it.next
+    yield it
+    it = nxt
+
+iterator nodes*[T](L: SomeLinkedRing[T]): SomeLinkedNode[T] =
+  ## Iterates over every node of `x`. Removing the current node from the
+  ## list during traversal is supported.
+  ##
+  ## **See also:**
+  ## * `items iterator <#items.i,SomeLinkedRing[T]>`_
+  ## * `mitems iterator <#mitems.i,SomeLinkedRing[T]>`_
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    for i in 1..5:
+      a.add(10 * i)
+    assert $a == "[10, 20, 30, 40, 50]"
+    for x in nodes(a):
+      if x.value == 30:
+        a.remove(x)
+      else:
+        x.value = 5 * x.value - 1
+    assert $a == "[49, 99, 199, 249]"
+
+  var it {.cursor.} = L.head
+  if it != nil:
+    while true:
+      let nxt = it.next
+      yield it
+      it = nxt
+      if it == L.head: break
+
+proc `$`*[T](L: SomeLinkedCollection[T]): string =
+  ## Turns a list into its string representation for logging and printing.
+  runnableExamples:
+    let a = [1, 2, 3, 4].toSinglyLinkedList
+    assert $a == "[1, 2, 3, 4]"
+
+  result = "["
+  for x in nodes(L):
+    if result.len > 1: result.add(", ")
+    result.addQuoted(x.value)
+  result.add("]")
+
+proc find*[T](L: SomeLinkedCollection[T], value: T): SomeLinkedNode[T] =
+  ## Searches in the list for a value. Returns `nil` if the value does not
+  ## exist.
+  ##
+  ## **See also:**
+  ## * `contains proc <#contains,SomeLinkedCollection[T],T>`_
+  runnableExamples:
+    let a = [9, 8].toSinglyLinkedList
+    assert a.find(9).value == 9
+    assert a.find(1) == nil
+
+  for x in nodes(L):
+    if x.value == value: return x
+
+proc contains*[T](L: SomeLinkedCollection[T], value: T): bool {.inline.} =
+  ## Searches in the list for a value. Returns `false` if the value does not
+  ## exist, `true` otherwise. This allows the usage of the `in` and `notin`
+  ## operators.
+  ##
+  ## **See also:**
+  ## * `find proc <#find,SomeLinkedCollection[T],T>`_
+  runnableExamples:
+    let a = [9, 8].toSinglyLinkedList
+    assert a.contains(9)
+    assert 8 in a
+    assert(not a.contains(1))
+    assert 2 notin a
+
+  result = find(L, value) != nil
+
+proc prepend*[T: SomeLinkedList](a: var T, b: T) {.since: (1, 5, 1).} =
+  ## Prepends a shallow copy of `b` to the beginning of `a`.
+  ##
+  ## **See also:**
+  ## * `prependMoved proc <#prependMoved,T,T>`_
+  ##   for moving the second list instead of copying
+  runnableExamples:
+    from std/sequtils import toSeq
+    var a = [4, 5].toSinglyLinkedList
+    let b = [1, 2, 3].toSinglyLinkedList
+    a.prepend(b)
+    assert a.toSeq == [1, 2, 3, 4, 5]
+    assert b.toSeq == [1, 2, 3]
+    a.prepend(a)
+    assert a.toSeq == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
+
+  var tmp = b.copy
+  tmp.addMoved(a)
+  a = tmp
+
+proc prependMoved*[T: SomeLinkedList](a, b: var T) {.since: (1, 5, 1).} =
+  ## Moves `b` before the head of `a`. Efficiency: O(1).
+  ## Note that `b` becomes empty after the operation unless it has the same address as `a`.
+  ## Self-prepending results in a cycle.
+  ##
+  ## **See also:**
+  ## * `prepend proc <#prepend,T,T>`_
+  ##   for prepending a copy of a list
+  runnableExamples:
+    import std/[sequtils, enumerate, sugar]
+    var
+      a = [4, 5].toSinglyLinkedList
+      b = [1, 2, 3].toSinglyLinkedList
+      c = [0, 1].toSinglyLinkedList
+    a.prependMoved(b)
+    assert a.toSeq == [1, 2, 3, 4, 5]
+    assert b.toSeq == []
+    c.prependMoved(c)
+    let s = collect:
+      for i, ci in enumerate(c):
+        if i == 6: break
+        ci
+    assert s == [0, 1, 0, 1, 0, 1]
+
+  b.addMoved(a)
+  swap a, b
+
+proc add*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]) {.inline.} =
+  ## Appends (adds to the end) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedList[int]()
+    let n = newSinglyLinkedNode[int](9)
+    a.add(n)
+    assert a.contains(9)
+
+  n.next = nil
+  if L.tail != nil:
+    assert(L.tail.next == nil)
+    L.tail.next = n
+  L.tail = n
+  if L.head == nil: L.head = n
+
+proc add*[T](L: var SinglyLinkedList[T], value: T) {.inline.} =
+  ## Appends (adds to the end) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedList[int]()
+    a.add(9)
+    a.add(8)
+    assert a.contains(9)
+
+  add(L, newSinglyLinkedNode(value))
+
+proc prepend*[T](L: var SinglyLinkedList[T],
+                 n: SinglyLinkedNode[T]) {.inline.} =
+  ## Prepends (adds to the beginning) a node to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,SinglyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedList[int]()
+    let n = newSinglyLinkedNode[int](9)
+    a.prepend(n)
+    assert a.contains(9)
+
+  n.next = L.head
+  L.head = n
+  if L.tail == nil: L.tail = n
+
+proc prepend*[T](L: var SinglyLinkedList[T], value: T) {.inline.} =
+  ## Prepends (adds to the beginning) a node to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,SinglyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  runnableExamples:
+    var a = initSinglyLinkedList[int]()
+    a.prepend(9)
+    a.prepend(8)
+    assert a.contains(9)
+
+  prepend(L, newSinglyLinkedNode(value))
+
+func copy*[T](a: SinglyLinkedList[T]): SinglyLinkedList[T] {.since: (1, 5, 1).} =
+  ## Creates a shallow copy of `a`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    type Foo = ref object
+      x: int
+    var
+      f = Foo(x: 1)
+      a = [f].toSinglyLinkedList
+    let b = a.copy
+    a.add([f].toSinglyLinkedList)
+    assert a.toSeq == [f, f]
+    assert b.toSeq == [f] # b isn't modified...
+    f.x = 42
+    assert a.head.value.x == 42
+    assert b.head.value.x == 42 # ... but the elements are not deep copied
+
+    let c = [1, 2, 3].toSinglyLinkedList
+    assert $c == $c.copy
+
+  result = initSinglyLinkedList[T]()
+  for x in a.items:
+    result.add(x)
+
+proc addMoved*[T](a, b: var SinglyLinkedList[T]) {.since: (1, 5, 1).} =
+  ## Moves `b` to the end of `a`. Efficiency: O(1).
+  ## Note that `b` becomes empty after the operation unless it has the same address as `a`.
+  ## Self-adding results in a cycle.
+  ##
+  ## **See also:**
+  ## * `add proc <#add,T,T>`_ for adding a copy of a list
+  runnableExamples:
+    import std/[sequtils, enumerate, sugar]
+    var
+      a = [1, 2, 3].toSinglyLinkedList
+      b = [4, 5].toSinglyLinkedList
+      c = [0, 1].toSinglyLinkedList
+    a.addMoved(b)
+    assert a.toSeq == [1, 2, 3, 4, 5]
+    assert b.toSeq == []
+    c.addMoved(c)
+    let s = collect:
+      for i, ci in enumerate(c):
+        if i == 6: break
+        ci
+    assert s == [0, 1, 0, 1, 0, 1]
+
+  if b.head != nil:
+    if a.head == nil:
+      a.head = b.head
+    else:
+      a.tail.next = b.head
+    a.tail = b.tail
+  if a.addr != b.addr:
+    b.head = nil
+    b.tail = nil
+
+proc add*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) =
+  ## Appends (adds to the end) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedList[int]()
+    let n = newDoublyLinkedNode[int](9)
+    a.add(n)
+    assert a.contains(9)
+
+  n.next = nil
+  n.prev = L.tail
+  if L.tail != nil:
+    assert(L.tail.next == nil)
+    L.tail.next = n
+  L.tail = n
+  if L.head == nil: L.head = n
+
+proc add*[T](L: var DoublyLinkedList[T], value: T) =
+  ## Appends (adds to the end) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedList[int]()
+    a.add(9)
+    a.add(8)
+    assert a.contains(9)
+
+  add(L, newDoublyLinkedNode(value))
+
+proc prepend*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) =
+  ## Prepends (adds to the beginning) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,DoublyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedList[int]()
+    let n = newDoublyLinkedNode[int](9)
+    a.prepend(n)
+    assert a.contains(9)
+
+  n.prev = nil
+  n.next = L.head
+  if L.head != nil:
+    assert(L.head.prev == nil)
+    L.head.prev = n
+  L.head = n
+  if L.tail == nil: L.tail = n
+
+proc prepend*[T](L: var DoublyLinkedList[T], value: T) =
+  ## Prepends (adds to the beginning) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,DoublyLinkedList[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `remove proc <#remove,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedList[int]()
+    a.prepend(9)
+    a.prepend(8)
+    assert a.contains(9)
+
+  prepend(L, newDoublyLinkedNode(value))
+
+func copy*[T](a: DoublyLinkedList[T]): DoublyLinkedList[T] {.since: (1, 5, 1).} =
+  ## Creates a shallow copy of `a`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    type Foo = ref object
+      x: int
+    var
+      f = Foo(x: 1)
+      a = [f].toDoublyLinkedList
+    let b = a.copy
+    a.add([f].toDoublyLinkedList)
+    assert a.toSeq == [f, f]
+    assert b.toSeq == [f] # b isn't modified...
+    f.x = 42
+    assert a.head.value.x == 42
+    assert b.head.value.x == 42 # ... but the elements are not deep copied
+
+    let c = [1, 2, 3].toDoublyLinkedList
+    assert $c == $c.copy
+
+  result = initDoublyLinkedList[T]()
+  for x in a.items:
+    result.add(x)
+
+proc addMoved*[T](a, b: var DoublyLinkedList[T]) {.since: (1, 5, 1).} =
+  ## Moves `b` to the end of `a`. Efficiency: O(1).
+  ## Note that `b` becomes empty after the operation unless it has the same address as `a`.
+  ## Self-adding results in a cycle.
+  ##
+  ## **See also:**
+  ## * `add proc <#add,T,T>`_
+  ##   for adding a copy of a list
+  runnableExamples:
+    import std/[sequtils, enumerate, sugar]
+    var
+      a = [1, 2, 3].toDoublyLinkedList
+      b = [4, 5].toDoublyLinkedList
+      c = [0, 1].toDoublyLinkedList
+    a.addMoved(b)
+    assert a.toSeq == [1, 2, 3, 4, 5]
+    assert b.toSeq == []
+    c.addMoved(c)
+    let s = collect:
+      for i, ci in enumerate(c):
+        if i == 6: break
+        ci
+    assert s == [0, 1, 0, 1, 0, 1]
+
+  if b.head != nil:
+    if a.head == nil:
+      a.head = b.head
+    else:
+      b.head.prev = a.tail
+      a.tail.next = b.head
+    a.tail = b.tail
+  if a.addr != b.addr:
+    b.head = nil
+    b.tail = nil
+
+proc add*[T: SomeLinkedList](a: var T, b: T) {.since: (1, 5, 1).} =
+  ## Appends a shallow copy of `b` to the end of `a`.
+  ##
+  ## **See also:**
+  ## * `addMoved proc <#addMoved,SinglyLinkedList[T],SinglyLinkedList[T]>`_
+  ## * `addMoved proc <#addMoved,DoublyLinkedList[T],DoublyLinkedList[T]>`_
+  ##   for moving the second list instead of copying
+  runnableExamples:
+    from std/sequtils import toSeq
+    var a = [1, 2, 3].toSinglyLinkedList
+    let b = [4, 5].toSinglyLinkedList
+    a.add(b)
+    assert a.toSeq == [1, 2, 3, 4, 5]
+    assert b.toSeq == [4, 5]
+    a.add(a)
+    assert a.toSeq == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
+
+  var tmp = b.copy
+  a.addMoved(tmp)
+
+proc remove*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]): bool {.discardable.} =
+  ## Removes a node `n` from `L`.
+  ## Returns `true` if `n` was found in `L`.
+  ## Efficiency: O(n); the list is traversed until `n` is found.
+  ## Attempting to remove an element not contained in the list is a no-op.
+  ## When the list is cyclic, the cycle is preserved after removal.
+  runnableExamples:
+    import std/[sequtils, enumerate, sugar]
+    var a = [0, 1, 2].toSinglyLinkedList
+    let n = a.head.next
+    assert n.value == 1
+    assert a.remove(n) == true
+    assert a.toSeq == [0, 2]
+    assert a.remove(n) == false
+    assert a.toSeq == [0, 2]
+    a.addMoved(a) # cycle: [0, 2, 0, 2, ...]
+    a.remove(a.head)
+    let s = collect:
+      for i, ai in enumerate(a):
+        if i == 4: break
+        ai
+    assert s == [2, 2, 2, 2]
+
+  if n == L.head:
+    L.head = n.next
+    if L.tail.next == n:
+      L.tail.next = L.head # restore cycle
+  else:
+    var prev {.cursor.} = L.head
+    while prev.next != n and prev.next != nil:
+      prev = prev.next
+    if prev.next == nil:
+      return false
+    prev.next = n.next
+    if L.tail == n:
+      L.tail = prev # update tail if we removed the last node
+  true
+
+proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) =
+  ## Removes a node `n` from `L`. Efficiency: O(1).
+  ## This function assumes, for the sake of efficiency, that `n` is contained in `L`,
+  ## otherwise the effects are undefined.
+  ## When the list is cyclic, the cycle is preserved after removal.
+  runnableExamples:
+    import std/[sequtils, enumerate, sugar]
+    var a = [0, 1, 2].toSinglyLinkedList
+    let n = a.head.next
+    assert n.value == 1
+    a.remove(n)
+    assert a.toSeq == [0, 2]
+    a.remove(n)
+    assert a.toSeq == [0, 2]
+    a.addMoved(a) # cycle: [0, 2, 0, 2, ...]
+    a.remove(a.head)
+    let s = collect:
+      for i, ai in enumerate(a):
+        if i == 4: break
+        ai
+    assert s == [2, 2, 2, 2]
+
+  if n == L.tail: L.tail = n.prev
+  if n == L.head: L.head = n.next
+  if n.next != nil: n.next.prev = n.prev
+  if n.prev != nil: n.prev.next = n.next
+
+
+
+proc add*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) =
+  ## Appends (adds to the end) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedRing[int]()
+    let n = newSinglyLinkedNode[int](9)
+    a.add(n)
+    assert a.contains(9)
+
+  if L.head != nil:
+    n.next = L.head
+    assert(L.tail != nil)
+    L.tail.next = n
+  else:
+    n.next = n
+    L.head = n
+  L.tail = n
+
+proc add*[T](L: var SinglyLinkedRing[T], value: T) =
+  ## Appends (adds to the end) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedRing[int]()
+    a.add(9)
+    a.add(8)
+    assert a.contains(9)
+
+  add(L, newSinglyLinkedNode(value))
+
+proc prepend*[T](L: var SinglyLinkedRing[T], n: SinglyLinkedNode[T]) =
+  ## Prepends (adds to the beginning) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,SinglyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],T>`_ for prepending a value
+  runnableExamples:
+    var a = initSinglyLinkedRing[int]()
+    let n = newSinglyLinkedNode[int](9)
+    a.prepend(n)
+    assert a.contains(9)
+
+  if L.head != nil:
+    n.next = L.head
+    assert(L.tail != nil)
+    L.tail.next = n
+  else:
+    n.next = n
+    L.tail = n
+  L.head = n
+
+proc prepend*[T](L: var SinglyLinkedRing[T], value: T) =
+  ## Prepends (adds to the beginning) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,SinglyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,SinglyLinkedRing[T],SinglyLinkedNode[T]>`_
+  ##   for prepending a node
+  runnableExamples:
+    var a = initSinglyLinkedRing[int]()
+    a.prepend(9)
+    a.prepend(8)
+    assert a.contains(9)
+
+  prepend(L, newSinglyLinkedNode(value))
+
+
+
+proc add*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) =
+  ## Appends (adds to the end) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    let n = newDoublyLinkedNode[int](9)
+    a.add(n)
+    assert a.contains(9)
+
+  if L.head != nil:
+    n.next = L.head
+    n.prev = L.head.prev
+    L.head.prev.next = n
+    L.head.prev = n
+  else:
+    n.prev = n
+    n.next = n
+    L.head = n
+
+proc add*[T](L: var DoublyLinkedRing[T], value: T) =
+  ## Appends (adds to the end) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    a.add(9)
+    a.add(8)
+    assert a.contains(9)
+
+  add(L, newDoublyLinkedNode(value))
+
+proc prepend*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) =
+  ## Prepends (adds to the beginning) a node `n` to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,DoublyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],T>`_ for prepending a value
+  ## * `remove proc <#remove,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    let n = newDoublyLinkedNode[int](9)
+    a.prepend(n)
+    assert a.contains(9)
+
+  if L.head != nil:
+    n.next = L.head
+    n.prev = L.head.prev
+    L.head.prev.next = n
+    L.head.prev = n
+  else:
+    n.prev = n
+    n.next = n
+  L.head = n
+
+proc prepend*[T](L: var DoublyLinkedRing[T], value: T) =
+  ## Prepends (adds to the beginning) a value to `L`. Efficiency: O(1).
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for appending a node
+  ## * `add proc <#add,DoublyLinkedRing[T],T>`_ for appending a value
+  ## * `prepend proc <#prepend,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for prepending a node
+  ## * `remove proc <#remove,DoublyLinkedRing[T],DoublyLinkedNode[T]>`_
+  ##   for removing a node
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    a.prepend(9)
+    a.prepend(8)
+    assert a.contains(9)
+
+  prepend(L, newDoublyLinkedNode(value))
+
+proc remove*[T](L: var DoublyLinkedRing[T], n: DoublyLinkedNode[T]) =
+  ## Removes `n` from `L`. Efficiency: O(1).
+  ## This function assumes, for the sake of efficiency, that `n` is contained in `L`,
+  ## otherwise the effects are undefined.
+  runnableExamples:
+    var a = initDoublyLinkedRing[int]()
+    let n = newDoublyLinkedNode[int](5)
+    a.add(n)
+    assert 5 in a
+    a.remove(n)
+    assert 5 notin a
+
+  n.next.prev = n.prev
+  n.prev.next = n.next
+  if n == L.head:
+    let p = L.head.prev
+    if p == L.head:
+      # only one element left:
+      L.head = nil
+    else:
+      L.head = p
+
+proc append*[T](a: var (SinglyLinkedList[T] | SinglyLinkedRing[T]),
+                b: SinglyLinkedList[T] | SinglyLinkedNode[T] | T) =
+  ## Alias for `a.add(b)`.
+  ##
+  ## **See also:**
+  ## * `add proc <#add,SinglyLinkedList[T],SinglyLinkedNode[T]>`_
+  ## * `add proc <#add,SinglyLinkedList[T],T>`_
+  ## * `add proc <#add,T,T>`_
+  a.add(b)
+
+proc append*[T](a: var (DoublyLinkedList[T] | DoublyLinkedRing[T]),
+                b: DoublyLinkedList[T] | DoublyLinkedNode[T] | T) =
+  ## Alias for `a.add(b)`.
+  ##
+  ## **See also:**
+  ## * `add proc <#add,DoublyLinkedList[T],DoublyLinkedNode[T]>`_
+  ## * `add proc <#add,DoublyLinkedList[T],T>`_
+  ## * `add proc <#add,T,T>`_
+  a.add(b)
+
+proc appendMoved*[T: SomeLinkedList](a, b: var T) {.since: (1, 5, 1).} =
+  ## Alias for `a.addMoved(b)`.
+  ##
+  ## **See also:**
+  ## * `addMoved proc <#addMoved,SinglyLinkedList[T],SinglyLinkedList[T]>`_
+  ## * `addMoved proc <#addMoved,DoublyLinkedList[T],DoublyLinkedList[T]>`_
+  a.addMoved(b)
+
+func toSinglyLinkedList*[T](elems: openArray[T]): SinglyLinkedList[T] {.since: (1, 5, 1).} =
+  ## Creates a new `SinglyLinkedList` from the members of `elems`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    let a = [1, 2, 3, 4, 5].toSinglyLinkedList
+    assert a.toSeq == [1, 2, 3, 4, 5]
+
+  result = initSinglyLinkedList[T]()
+  for elem in elems.items:
+    result.add(elem)
+
+func toSinglyLinkedRing*[T](elems: openArray[T]): SinglyLinkedRing[T] =
+  ## Creates a new `SinglyLinkedRing` from the members of `elems`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    let a = [1, 2, 3, 4, 5].toSinglyLinkedRing
+    assert a.toSeq == [1, 2, 3, 4, 5]
+
+  result = initSinglyLinkedRing[T]()
+  for elem in elems.items:
+    result.add(elem)
+
+func toDoublyLinkedList*[T](elems: openArray[T]): DoublyLinkedList[T] {.since: (1, 5, 1).} =
+  ## Creates a new `DoublyLinkedList` from the members of `elems`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    let a = [1, 2, 3, 4, 5].toDoublyLinkedList
+    assert a.toSeq == [1, 2, 3, 4, 5]
+
+  result = initDoublyLinkedList[T]()
+  for elem in elems.items:
+    result.add(elem)
+
+func toDoublyLinkedRing*[T](elems: openArray[T]): DoublyLinkedRing[T] =
+  ## Creates a new `DoublyLinkedRing` from the members of `elems`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    let a = [1, 2, 3, 4, 5].toDoublyLinkedRing
+    assert a.toSeq == [1, 2, 3, 4, 5]
+
+  result = initDoublyLinkedRing[T]()
+  for elem in elems.items:
+    result.add(elem)
diff --git a/lib/pure/collections/rtarrays.nim b/lib/pure/collections/rtarrays.nim
new file mode 100644
index 000000000..3c3ffda7c
--- /dev/null
+++ b/lib/pure/collections/rtarrays.nim
@@ -0,0 +1,37 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+## Module that implements a fixed length array whose size
+## is determined at runtime. Note: This is not ready for other people to use!
+##
+## Unstable API.
+
+const
+  ArrayPartSize = 10
+
+type
+  RtArray*[T] = object ##
+    L: Natural
+    spart: seq[T]
+    apart: array[ArrayPartSize, T]
+
+template usesSeqPart(x): untyped = x.L > ArrayPartSize
+
+proc initRtArray*[T](len: Natural): RtArray[T] =
+  result.L = len
+  if usesSeqPart(result):
+    newSeq(result.spart, len)
+
+proc getRawData*[T](x: var RtArray[T]): ptr UncheckedArray[T] =
+  if usesSeqPart(x): cast[ptr UncheckedArray[T]](addr(x.spart[0]))
+  else: cast[ptr UncheckedArray[T]](addr(x.apart[0]))
+
+#proc len*[T](x: RtArray[T]): int = x.L
+
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
new file mode 100644
index 000000000..3c0d8dc0e
--- /dev/null
+++ b/lib/pure/collections/sequtils.nim
@@ -0,0 +1,1162 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2011 Alexander Mitchell-Robinson
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Although this module has `seq` in its name, it implements operations
+## not only for the `seq`:idx: type, but for three built-in container types
+## under the `openArray` umbrella:
+## * sequences
+## * strings
+## * array
+##
+## The `system` module defines several common functions, such as:
+## * `newSeq[T]` for creating new sequences of type `T`
+## * `@` for converting arrays and strings to sequences
+## * `add` for adding new elements to strings and sequences
+## * `&` for string and seq concatenation
+## * `in` (alias for `contains`) and `notin` for checking if an item is
+##   in a container
+##
+## This module builds upon that, providing additional functionality in form of
+## procs, iterators and templates inspired by functional programming
+## languages.
+##
+## For functional style programming you have different options at your disposal:
+## * the `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+## * pass an `anonymous proc<manual.html#procedures-anonymous-procs>`_
+## * import the `sugar module<sugar.html>`_  and use
+##   the `=> macro<sugar.html#%3D>.m,untyped,untyped>`_
+## * use `...It templates<#18>`_
+##   (`mapIt<#mapIt.t,typed,untyped>`_,
+##   `filterIt<#filterIt.t,untyped,untyped>`_, etc.)
+##
+## Chaining of functions is possible thanks to the
+## `method call syntax<manual.html#procedures-method-call-syntax>`_.
+
+runnableExamples:
+  import std/sugar
+
+  # Creating a sequence from 1 to 10, multiplying each member by 2,
+  # keeping only the members which are not divisible by 6.
+  let
+    foo = toSeq(1..10).map(x => x * 2).filter(x => x mod 6 != 0)
+    bar = toSeq(1..10).mapIt(it * 2).filterIt(it mod 6 != 0)
+    baz = collect:
+      for i in 1..10:
+        let j = 2 * i
+        if j mod 6 != 0:
+          j
+
+  doAssert foo == bar
+  doAssert foo == baz
+  doAssert foo == @[2, 4, 8, 10, 14, 16, 20]
+
+  doAssert foo.any(x => x > 17)
+  doAssert not bar.allIt(it < 20)
+  doAssert foo.foldl(a + b) == 74 # sum of all members
+
+
+runnableExamples:
+  from std/strutils import join
+
+  let
+    vowels = @"aeiou"
+    foo = "sequtils is an awesome module"
+
+  doAssert (vowels is seq[char]) and (vowels == @['a', 'e', 'i', 'o', 'u'])
+  doAssert foo.filterIt(it notin vowels).join == "sqtls s n wsm mdl"
+
+## See also
+## ========
+## * `strutils module<strutils.html>`_ for common string functions
+## * `sugar module<sugar.html>`_ for syntactic sugar macros
+## * `algorithm module<algorithm.html>`_ for common generic algorithms
+## * `json module<json.html>`_ for a structure which allows
+##   heterogeneous members
+
+
+import std/private/since
+
+import std/macros
+from std/typetraits import supportsCopyMem
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+when defined(nimHasEffectsOf):
+  {.experimental: "strictEffects".}
+else:
+  {.pragma: effectsOf.}
+
+macro evalOnceAs(expAlias, exp: untyped,
+                 letAssigneable: static[bool]): untyped =
+  ## Injects `expAlias` in caller scope, to avoid bugs involving multiple
+  ## substitution in macro arguments such as
+  ## https://github.com/nim-lang/Nim/issues/7187.
+  ## `evalOnceAs(myAlias, myExp)` will behave as `let myAlias = myExp`
+  ## except when `letAssigneable` is false (e.g. to handle openArray) where
+  ## it just forwards `exp` unchanged.
+  expectKind(expAlias, nnkIdent)
+  var val = exp
+
+  result = newStmtList()
+  # If `exp` is not a symbol we evaluate it once here and then use the temporary
+  # symbol as alias
+  if exp.kind != nnkSym and letAssigneable:
+    val = genSym()
+    result.add(newLetStmt(val, exp))
+
+  result.add(
+    newProc(name = genSym(nskTemplate, $expAlias), params = [getType(untyped)],
+      body = val, procType = nnkTemplateDef))
+
+func concat*[T](seqs: varargs[seq[T]]): seq[T] =
+  ## Takes several sequences' items and returns them inside a new sequence.
+  ## All sequences must be of the same type.
+  ##
+  ## **See also:**
+  ## * `distribute func<#distribute,seq[T],Positive>`_ for a reverse
+  ##   operation
+  ##
+  runnableExamples:
+    let
+      s1 = @[1, 2, 3]
+      s2 = @[4, 5]
+      s3 = @[6, 7]
+      total = concat(s1, s2, s3)
+    assert total == @[1, 2, 3, 4, 5, 6, 7]
+
+  var L = 0
+  for seqitm in items(seqs): inc(L, len(seqitm))
+  newSeq(result, L)
+  var i = 0
+  for s in items(seqs):
+    for itm in items(s):
+      result[i] = itm
+      inc(i)
+
+func addUnique*[T](s: var seq[T], x: sink T) =
+  ## Adds `x` to the container `s` if it is not already present. 
+  ## Uses `==` to check if the item is already present.
+  runnableExamples:
+    var a = @[1, 2, 3]
+    a.addUnique(4)
+    a.addUnique(4)
+    assert a == @[1, 2, 3, 4]
+
+  for i in 0..high(s):
+    if s[i] == x: return
+  when declared(ensureMove):
+    s.add ensureMove(x)
+  else:
+    s.add x
+
+func count*[T](s: openArray[T], x: T): int =
+  ## Returns the number of occurrences of the item `x` in the container `s`.
+  ##
+  runnableExamples:
+    let
+      a = @[1, 2, 2, 3, 2, 4, 2]
+      b = "abracadabra"
+    assert count(a, 2) == 4
+    assert count(a, 99) == 0
+    assert count(b, 'r') == 2
+
+  for itm in items(s):
+    if itm == x:
+      inc result
+
+func cycle*[T](s: openArray[T], n: Natural): seq[T] =
+  ## Returns a new sequence with the items of the container `s` repeated
+  ## `n` times.
+  ## `n` must be a non-negative number (zero or more).
+  ##
+  runnableExamples:
+    let
+      s = @[1, 2, 3]
+      total = s.cycle(3)
+    assert total == @[1, 2, 3, 1, 2, 3, 1, 2, 3]
+
+  result = newSeq[T](n * s.len)
+  var o = 0
+  for x in 0 ..< n:
+    for e in s:
+      result[o] = e
+      inc o
+
+proc repeat*[T](x: T, n: Natural): seq[T] =
+  ## Returns a new sequence with the item `x` repeated `n` times.
+  ## `n` must be a non-negative number (zero or more).
+  ##
+  runnableExamples:
+    let
+      total = repeat(5, 3)
+    assert total == @[5, 5, 5]
+
+  result = newSeq[T](n)
+  for i in 0 ..< n:
+    result[i] = x
+
+func deduplicate*[T](s: openArray[T], isSorted: bool = false): seq[T] =
+  ## Returns a new sequence without duplicates.
+  ##
+  ## Setting the optional argument `isSorted` to true (default: false)
+  ## uses a faster algorithm for deduplication.
+  ##
+  runnableExamples:
+    let
+      dup1 = @[1, 1, 3, 4, 2, 2, 8, 1, 4]
+      dup2 = @["a", "a", "c", "d", "d"]
+      unique1 = deduplicate(dup1)
+      unique2 = deduplicate(dup2, isSorted = true)
+    assert unique1 == @[1, 3, 4, 2, 8]
+    assert unique2 == @["a", "c", "d"]
+
+  result = @[]
+  if s.len > 0:
+    if isSorted:
+      var prev = s[0]
+      result.add(prev)
+      for i in 1..s.high:
+        if s[i] != prev:
+          prev = s[i]
+          result.add(prev)
+    else:
+      for itm in items(s):
+        if not result.contains(itm): result.add(itm)
+
+func minIndex*[T](s: openArray[T]): int {.since: (1, 1).} =
+  ## Returns the index of the minimum value of `s`.
+  ## `T` needs to have a `<` operator.
+  runnableExamples:
+    let
+      a = @[1, 2, 3, 4]
+      b = @[6, 5, 4, 3]
+      c = [2, -7, 8, -5]
+      d = "ziggy"
+    assert minIndex(a) == 0
+    assert minIndex(b) == 3
+    assert minIndex(c) == 1
+    assert minIndex(d) == 2
+
+  for i in 1..high(s):
+    if s[i] < s[result]: result = i
+
+func maxIndex*[T](s: openArray[T]): int {.since: (1, 1).} =
+  ## Returns the index of the maximum value of `s`.
+  ## `T` needs to have a `<` operator.
+  runnableExamples:
+    let
+      a = @[1, 2, 3, 4]
+      b = @[6, 5, 4, 3]
+      c = [2, -7, 8, -5]
+      d = "ziggy"
+    assert maxIndex(a) == 3
+    assert maxIndex(b) == 0
+    assert maxIndex(c) == 2
+    assert maxIndex(d) == 0
+
+  for i in 1..high(s):
+    if s[i] > s[result]: result = i
+
+func minmax*[T](x: openArray[T]): (T, T) =
+  ## The minimum and maximum values of `x`. `T` needs to have a `<` operator.
+  var l = x[0]
+  var h = x[0]
+  for i in 1..high(x):
+    if x[i] < l: l = x[i]
+    if h < x[i]: h = x[i]
+  result = (l, h)
+
+
+template zipImpl(s1, s2, retType: untyped): untyped =
+  proc zip*[S, T](s1: openArray[S], s2: openArray[T]): retType =
+    ## Returns a new sequence with a combination of the two input containers.
+    ##
+    ## The input containers can be of different types.
+    ## If one container is shorter, the remaining items in the longer container
+    ## are discarded.
+    ##
+    ## **Note**: For Nim 1.0.x and older version, `zip` returned a seq of
+    ## named tuples with fields `a` and `b`. For Nim versions 1.1.x and newer,
+    ## `zip` returns a seq of unnamed tuples.
+    runnableExamples:
+      let
+        short = @[1, 2, 3]
+        long = @[6, 5, 4, 3, 2, 1]
+        words = @["one", "two", "three"]
+        letters = "abcd"
+        zip1 = zip(short, long)
+        zip2 = zip(short, words)
+      assert zip1 == @[(1, 6), (2, 5), (3, 4)]
+      assert zip2 == @[(1, "one"), (2, "two"), (3, "three")]
+      assert zip1[2][0] == 3
+      assert zip2[1][1] == "two"
+      when (NimMajor, NimMinor) <= (1, 0):
+        let
+          zip3 = zip(long, letters)
+        assert zip3 == @[(a: 6, b: 'a'), (5, 'b'), (4, 'c'), (3, 'd')]
+        assert zip3[0].b == 'a'
+      else:
+        let
+          zip3: seq[tuple[num: int, letter: char]] = zip(long, letters)
+        assert zip3 == @[(6, 'a'), (5, 'b'), (4, 'c'), (3, 'd')]
+        assert zip3[0].letter == 'a'
+
+    var m = min(s1.len, s2.len)
+    newSeq(result, m)
+    for i in 0 ..< m:
+      result[i] = (s1[i], s2[i])
+
+when (NimMajor, NimMinor) <= (1, 0):
+  zipImpl(s1, s2, seq[tuple[a: S, b: T]])
+else:
+  zipImpl(s1, s2, seq[(S, T)])
+
+proc unzip*[S, T](s: openArray[(S, T)]): (seq[S], seq[T]) {.since: (1, 1).} =
+  ## Returns a tuple of two sequences split out from a sequence of 2-field tuples.
+  runnableExamples:
+    let
+      zipped = @[(1, 'a'), (2, 'b'), (3, 'c')]
+      unzipped1 = @[1, 2, 3]
+      unzipped2 = @['a', 'b', 'c']
+    assert zipped.unzip() == (unzipped1, unzipped2)
+    assert zip(unzipped1, unzipped2).unzip() == (unzipped1, unzipped2)
+  result = (newSeq[S](s.len), newSeq[T](s.len))
+  for i in 0..<s.len:
+    result[0][i] = s[i][0]
+    result[1][i] = s[i][1]
+
+func distribute*[T](s: seq[T], num: Positive, spread = true): seq[seq[T]] =
+  ## Splits and distributes a sequence `s` into `num` sub-sequences.
+  ##
+  ## Returns a sequence of `num` sequences. For *some* input values this is the
+  ## inverse of the `concat <#concat,varargs[seq[T]]>`_ func.
+  ## The input sequence `s` can be empty, which will produce
+  ## `num` empty sequences.
+  ##
+  ## If `spread` is false and the length of `s` is not a multiple of `num`, the
+  ## func will max out the first sub-sequence with `1 + len(s) div num`
+  ## entries, leaving the remainder of elements to the last sequence.
+  ##
+  ## On the other hand, if `spread` is true, the func will distribute evenly
+  ## the remainder of the division across all sequences, which makes the result
+  ## more suited to multithreading where you are passing equal sized work units
+  ## to a thread pool and want to maximize core usage.
+  ##
+  runnableExamples:
+    let numbers = @[1, 2, 3, 4, 5, 6, 7]
+    assert numbers.distribute(3) == @[@[1, 2, 3], @[4, 5], @[6, 7]]
+    assert numbers.distribute(3, false) == @[@[1, 2, 3], @[4, 5, 6], @[7]]
+    assert numbers.distribute(6)[0] == @[1, 2]
+    assert numbers.distribute(6)[1] == @[3]
+
+  if num < 2:
+    result = @[s]
+    return
+
+  # Create the result and calculate the stride size and the remainder if any.
+  result = newSeq[seq[T]](num)
+  var
+    stride = s.len div num
+    first = 0
+    last = 0
+    extra = s.len mod num
+
+  if extra == 0 or spread == false:
+    # Use an algorithm which overcounts the stride and minimizes reading limits.
+    if extra > 0: inc(stride)
+    for i in 0 ..< num:
+      result[i] = newSeq[T]()
+      for g in first ..< min(s.len, first + stride):
+        result[i].add(s[g])
+      first += stride
+  else:
+    # Use an undercounting algorithm which *adds* the remainder each iteration.
+    for i in 0 ..< num:
+      last = first + stride
+      if extra > 0:
+        extra -= 1
+        inc(last)
+      result[i] = newSeq[T]()
+      for g in first ..< last:
+        result[i].add(s[g])
+      first = last
+
+proc map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
+                                                            seq[S] {.inline, effectsOf: op.} =
+  ## Returns a new sequence with the results of the `op` proc applied to every
+  ## item in the container `s`.
+  ##
+  ## Since the input is not modified, you can use it to
+  ## transform the type of the elements in the input container.
+  ##
+  ## Instead of using `map` and `filter`, consider using the `collect` macro
+  ## from the `sugar` module.
+  ##
+  ## **See also:**
+  ## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+  ## * `mapIt template<#mapIt.t,typed,untyped>`_
+  ## * `apply proc<#apply,openArray[T],proc(T)_2>`_ for the in-place version
+  ##
+  runnableExamples:
+    let
+      a = @[1, 2, 3, 4]
+      b = map(a, proc(x: int): string = $x)
+    assert b == @["1", "2", "3", "4"]
+
+  newSeq(result, s.len)
+  for i in 0 ..< s.len:
+    result[i] = op(s[i])
+
+proc apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
+                                                              {.inline, effectsOf: op.} =
+  ## Applies `op` to every item in `s`, modifying it directly.
+  ##
+  ## Note that the container `s` must be declared as a `var`,
+  ## since `s` is modified in-place.
+  ## The parameter function takes a `var T` type parameter.
+  ##
+  ## **See also:**
+  ## * `applyIt template<#applyIt.t,untyped,untyped>`_
+  ## * `map proc<#map,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    var a = @["1", "2", "3", "4"]
+    apply(a, proc(x: var string) = x &= "42")
+    assert a == @["142", "242", "342", "442"]
+
+  for i in 0 ..< s.len: op(s[i])
+
+proc apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
+                                                              {.inline, effectsOf: op.} =
+  ## Applies `op` to every item in `s` modifying it directly.
+  ##
+  ## Note that the container `s` must be declared as a `var`
+  ## and it is required for your input and output types to
+  ## be the same, since `s` is modified in-place.
+  ## The parameter function takes and returns a `T` type variable.
+  ##
+  ## **See also:**
+  ## * `applyIt template<#applyIt.t,untyped,untyped>`_
+  ## * `map proc<#map,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    var a = @["1", "2", "3", "4"]
+    apply(a, proc(x: string): string = x & "42")
+    assert a == @["142", "242", "342", "442"]
+
+  for i in 0 ..< s.len: s[i] = op(s[i])
+
+proc apply*[T](s: openArray[T], op: proc (x: T) {.closure.}) {.inline, since: (1, 3), effectsOf: op.} =
+  ## Same as `apply` but for a proc that does not return anything
+  ## and does not mutate `s` directly.
+  runnableExamples:
+    var message: string
+    apply([0, 1, 2, 3, 4], proc(item: int) = message.addInt item)
+    assert message == "01234"
+  for i in 0 ..< s.len: op(s[i])
+
+iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T {.effectsOf: pred.} =
+  ## Iterates through a container `s` and yields every item that fulfills the
+  ## predicate `pred` (a function that returns a `bool`).
+  ##
+  ## Instead of using `map` and `filter`, consider using the `collect` macro
+  ## from the `sugar` module.
+  ##
+  ## **See also:**
+  ## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+  ## * `filter proc<#filter,openArray[T],proc(T)>`_
+  ## * `filterIt template<#filterIt.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    let numbers = @[1, 4, 5, 8, 9, 7, 4]
+    var evens = newSeq[int]()
+    for n in filter(numbers, proc (x: int): bool = x mod 2 == 0):
+      evens.add(n)
+    assert evens == @[4, 8, 4]
+
+  for i in 0 ..< s.len:
+    if pred(s[i]):
+      yield s[i]
+
+proc filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
+                                                                  {.inline, effectsOf: pred.} =
+  ## Returns a new sequence with all the items of `s` that fulfill the
+  ## predicate `pred` (a function that returns a `bool`).
+  ##
+  ## Instead of using `map` and `filter`, consider using the `collect` macro
+  ## from the `sugar` module.
+  ##
+  ## **See also:**
+  ## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+  ## * `filterIt template<#filterIt.t,untyped,untyped>`_
+  ## * `filter iterator<#filter.i,openArray[T],proc(T)>`_
+  ## * `keepIf proc<#keepIf,seq[T],proc(T)>`_ for the in-place version
+  ##
+  runnableExamples:
+    let
+      colors = @["red", "yellow", "black"]
+      f1 = filter(colors, proc(x: string): bool = x.len < 6)
+      f2 = filter(colors, proc(x: string): bool = x.contains('y'))
+    assert f1 == @["red", "black"]
+    assert f2 == @["yellow"]
+
+  result = newSeq[T]()
+  for i in 0 ..< s.len:
+    if pred(s[i]):
+      result.add(s[i])
+
+proc keepIf*[T](s: var seq[T], pred: proc(x: T): bool {.closure.})
+                                                                {.inline, effectsOf: pred.} =
+  ## Keeps the items in the passed sequence `s` if they fulfill the
+  ## predicate `pred` (a function that returns a `bool`).
+  ##
+  ## Note that `s` must be declared as a `var`.
+  ##
+  ## Similar to the `filter proc<#filter,openArray[T],proc(T)>`_,
+  ## but modifies the sequence directly.
+  ##
+  ## **See also:**
+  ## * `keepItIf template<#keepItIf.t,seq,untyped>`_
+  ## * `filter proc<#filter,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    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]
+
+  var pos = 0
+  for i in 0 ..< len(s):
+    if pred(s[i]):
+      if pos != i:
+        when defined(gcDestructors):
+          s[pos] = move(s[i])
+        else:
+          shallowCopy(s[pos], s[i])
+      inc(pos)
+  setLen(s, pos)
+
+func delete*[T](s: var seq[T]; slice: Slice[int]) =
+  ## Deletes the items `s[slice]`, raising `IndexDefect` if the slice contains
+  ## elements out of range.
+  ##
+  ## This operation moves all elements after `s[slice]` in linear time.
+  runnableExamples:
+    var a = @[10, 11, 12, 13, 14]
+    doAssertRaises(IndexDefect): a.delete(4..5)
+    assert a == @[10, 11, 12, 13, 14]
+    a.delete(4..4)
+    assert a == @[10, 11, 12, 13]
+    a.delete(1..2)
+    assert a == @[10, 13]
+    a.delete(1..<1) # empty slice
+    assert a == @[10, 13]
+  when compileOption("boundChecks"):
+    if not (slice.a < s.len and slice.a >= 0 and slice.b < s.len):
+      raise newException(IndexDefect, $(slice: slice, len: s.len))
+  if slice.b >= slice.a:
+    template defaultImpl =
+      var i = slice.a
+      var j = slice.b + 1
+      var newLen = s.len - j + i
+      while i < newLen:
+        when defined(gcDestructors):
+          s[i] = move(s[j])
+        else:
+          s[i].shallowCopy(s[j])
+        inc(i)
+        inc(j)
+      setLen(s, newLen)
+    when nimvm: defaultImpl()
+    else:
+      when defined(js):
+        let n = slice.b - slice.a + 1
+        let first = slice.a
+        {.emit: "`s`.splice(`first`, `n`);".}
+      else:
+        defaultImpl()
+
+func delete*[T](s: var seq[T]; first, last: Natural) {.deprecated: "use `delete(s, first..last)`".} =
+  ## Deletes the items of a sequence `s` at positions `first..last`
+  ## (including both ends of the range).
+  ## This modifies `s` itself, it does not return a copy.
+  runnableExamples("--warning:deprecated:off"):
+    let outcome = @[1, 1, 1, 1, 1, 1, 1, 1]
+    var dest = @[1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
+    dest.delete(3, 8)
+    assert outcome == dest
+  doAssert first <= last
+  if first >= s.len:
+    return
+  var i = first
+  var j = min(len(s), last + 1)
+  var newLen = len(s) - j + i
+  while i < newLen:
+    when defined(gcDestructors):
+      s[i] = move(s[j])
+    else:
+      s[i].shallowCopy(s[j])
+    inc(i)
+    inc(j)
+  setLen(s, newLen)
+
+func insert*[T](dest: var seq[T], src: openArray[T], pos = 0) =
+  ## Inserts items from `src` into `dest` at position `pos`. This modifies
+  ## `dest` itself, it does not return a copy.
+  ##
+  ## Note that the elements of `src` and `dest` must be of the same type.
+  ##
+  runnableExamples:
+    var dest = @[1, 1, 1, 1, 1, 1, 1, 1]
+    let
+      src = @[2, 2, 2, 2, 2, 2]
+      outcome = @[1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
+    dest.insert(src, 3)
+    assert dest == outcome
+
+  var j = len(dest) - 1
+  var i = j + len(src)
+  if i == j: return
+  dest.setLen(i + 1)
+
+  # Move items after `pos` to the end of the sequence.
+  while j >= pos:
+    when defined(gcDestructors):
+      dest[i] = move(dest[j])
+    else:
+      dest[i].shallowCopy(dest[j])
+    dec(i)
+    dec(j)
+  # Insert items from `dest` into `dest` at `pos`
+  inc(j)
+  for item in src:
+    dest[j] = item
+    inc(j)
+
+
+template filterIt*(s, pred: untyped): untyped =
+  ## Returns a new sequence with all the items of `s` that fulfill the
+  ## predicate `pred`.
+  ##
+  ## Unlike the `filter proc<#filter,openArray[T],proc(T)>`_ and
+  ## `filter iterator<#filter.i,openArray[T],proc(T)>`_,
+  ## the predicate needs to be an expression using the `it` variable
+  ## for testing, like: `filterIt("abcxyz", it == 'x')`.
+  ##
+  ## Instead of using `mapIt` and `filterIt`, consider using the `collect` macro
+  ## from the `sugar` module.
+  ##
+  ## **See also:**
+  ## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+  ## * `filter proc<#filter,openArray[T],proc(T)>`_
+  ## * `filter iterator<#filter.i,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    let
+      temperatures = @[-272.15, -2.0, 24.5, 44.31, 99.9, -113.44]
+      acceptable = temperatures.filterIt(it < 50 and it > -10)
+      notAcceptable = temperatures.filterIt(it > 50 or it < -10)
+    assert acceptable == @[-2.0, 24.5, 44.31]
+    assert notAcceptable == @[-272.15, 99.9, -113.44]
+
+  var result = newSeq[typeof(s[0])]()
+  for it {.inject.} in items(s):
+    if pred: result.add(it)
+  result
+
+template keepItIf*(varSeq: seq, pred: untyped) =
+  ## Keeps the items in the passed sequence (must be declared as a `var`)
+  ## if they fulfill the predicate.
+  ##
+  ## Unlike the `keepIf proc<#keepIf,seq[T],proc(T)>`_,
+  ## the predicate needs to be an expression using
+  ## the `it` variable for testing, like: `keepItIf("abcxyz", it == 'x')`.
+  ##
+  ## **See also:**
+  ## * `keepIf proc<#keepIf,seq[T],proc(T)>`_
+  ## * `filterIt template<#filterIt.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    var candidates = @["foo", "bar", "baz", "foobar"]
+    candidates.keepItIf(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:
+        when defined(gcDestructors):
+          varSeq[pos] = move(varSeq[i])
+        else:
+          shallowCopy(varSeq[pos], varSeq[i])
+      inc(pos)
+  setLen(varSeq, pos)
+
+since (1, 1):
+  template countIt*(s, pred: untyped): int =
+    ## Returns a count of all the items that fulfill the predicate.
+    ##
+    ## The predicate needs to be an expression using
+    ## the `it` variable for testing, like: `countIt(@[1, 2, 3], it > 2)`.
+    ##
+    runnableExamples:
+      let numbers = @[-3, -2, -1, 0, 1, 2, 3, 4, 5, 6]
+      iterator iota(n: int): int =
+        for i in 0..<n: yield i
+      assert numbers.countIt(it < 0) == 3
+      assert countIt(iota(10), it < 2) == 2
+
+    var result = 0
+    for it {.inject.} in s:
+      if pred: result += 1
+    result
+
+proc all*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool {.effectsOf: pred.} =
+  ## Iterates through a container and checks if every item fulfills the
+  ## predicate.
+  ##
+  ## **See also:**
+  ## * `allIt template<#allIt.t,untyped,untyped>`_
+  ## * `any proc<#any,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    let numbers = @[1, 4, 5, 8, 9, 7, 4]
+    assert all(numbers, proc (x: int): bool = x < 10) == true
+    assert all(numbers, proc (x: int): bool = x < 9) == false
+
+  for i in s:
+    if not pred(i):
+      return false
+  true
+
+template allIt*(s, pred: untyped): bool =
+  ## Iterates through a container and checks if every item fulfills the
+  ## predicate.
+  ##
+  ## Unlike the `all proc<#all,openArray[T],proc(T)>`_,
+  ## the predicate needs to be an expression using
+  ## the `it` variable for testing, like: `allIt("abba", it == 'a')`.
+  ##
+  ## **See also:**
+  ## * `all proc<#all,openArray[T],proc(T)>`_
+  ## * `anyIt template<#anyIt.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    let numbers = @[1, 4, 5, 8, 9, 7, 4]
+    assert numbers.allIt(it < 10) == true
+    assert numbers.allIt(it < 9) == false
+
+  var result = true
+  for it {.inject.} in items(s):
+    if not pred:
+      result = false
+      break
+  result
+
+proc any*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool {.effectsOf: pred.} =
+  ## Iterates through a container and checks if at least one item
+  ## fulfills the predicate.
+  ##
+  ## **See also:**
+  ## * `anyIt template<#anyIt.t,untyped,untyped>`_
+  ## * `all proc<#all,openArray[T],proc(T)>`_
+  ##
+  runnableExamples:
+    let numbers = @[1, 4, 5, 8, 9, 7, 4]
+    assert any(numbers, proc (x: int): bool = x > 8) == true
+    assert any(numbers, proc (x: int): bool = x > 9) == false
+
+  for i in s:
+    if pred(i):
+      return true
+  false
+
+template anyIt*(s, pred: untyped): bool =
+  ## Iterates through a container and checks if at least one item
+  ## fulfills the predicate.
+  ##
+  ## Unlike the `any proc<#any,openArray[T],proc(T)>`_,
+  ## the predicate needs to be an expression using
+  ## the `it` variable for testing, like: `anyIt("abba", it == 'a')`.
+  ##
+  ## **See also:**
+  ## * `any proc<#any,openArray[T],proc(T)>`_
+  ## * `allIt template<#allIt.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    let numbers = @[1, 4, 5, 8, 9, 7, 4]
+    assert numbers.anyIt(it > 8) == true
+    assert numbers.anyIt(it > 9) == false
+
+  var result = false
+  for it {.inject.} in items(s):
+    if pred:
+      result = true
+      break
+  result
+
+template toSeq1(s: not iterator): untyped =
+  # overload for typed but not iterator
+  type OutType = typeof(items(s))
+  when compiles(s.len):
+    block:
+      evalOnceAs(s2, s, compiles((let _ = s)))
+      var i = 0
+      var result = newSeq[OutType](s2.len)
+      for it in s2:
+        result[i] = it
+        i += 1
+      result
+  else:
+    var result: seq[OutType]# = @[]
+    for it in s:
+      result.add(it)
+    result
+
+template toSeq2(iter: iterator): untyped =
+  # overload for iterator
+  evalOnceAs(iter2, iter(), false)
+  when compiles(iter2.len):
+    var i = 0
+    var result = newSeq[typeof(iter2)](iter2.len)
+    for x in iter2:
+      result[i] = x
+      inc i
+    result
+  else:
+    type OutType = typeof(iter2())
+    var result: seq[OutType]# = @[]
+    when compiles(iter2()):
+      evalOnceAs(iter4, iter, false)
+      let iter3 = iter4()
+      for x in iter3():
+        result.add(x)
+    else:
+      for x in iter2():
+        result.add(x)
+    result
+
+template toSeq*(iter: untyped): untyped =
+  ## Transforms any iterable (anything that can be iterated over, e.g. with
+  ## a for-loop) into a sequence.
+  ##
+  runnableExamples:
+    let
+      myRange = 1..5
+      mySet: set[int8] = {5'i8, 3, 1}
+    assert typeof(myRange) is HSlice[system.int, system.int]
+    assert typeof(mySet) is set[int8]
+
+    let
+      mySeq1 = toSeq(myRange)
+      mySeq2 = toSeq(mySet)
+    assert mySeq1 == @[1, 2, 3, 4, 5]
+    assert mySeq2 == @[1'i8, 3, 5]
+
+  when compiles(toSeq1(iter)):
+    toSeq1(iter)
+  elif compiles(toSeq2(iter)):
+    toSeq2(iter)
+  else:
+    # overload for untyped, e.g.: `toSeq(myInlineIterator(3))`
+    when compiles(iter.len):
+      block:
+        evalOnceAs(iter2, iter, true)
+        var result = newSeq[typeof(iter)](iter2.len)
+        var i = 0
+        for x in iter2:
+          result[i] = x
+          inc i
+        result
+    else:
+      var result: seq[typeof(iter)] = @[]
+      for x in iter:
+        result.add(x)
+      result
+
+template foldl*(sequence, operation: untyped): untyped =
+  ## Template to fold a sequence from left to right, returning the accumulation.
+  ##
+  ## The sequence is required to have at least a single element. Debug versions
+  ## of your program will assert in this situation but release versions will
+  ## happily go ahead. If the sequence has a single element it will be returned
+  ## without applying `operation`.
+  ##
+  ## The `operation` parameter should be an expression which uses the
+  ## variables `a` and `b` for each step of the fold. Since this is a left
+  ## fold, for non associative binary operations like subtraction think that
+  ## the sequence of numbers 1, 2 and 3 will be parenthesized as (((1) - 2) -
+  ## 3).
+  ##
+  ## **See also:**
+  ## * `foldl template<#foldl.t,,,>`_ with a starting parameter
+  ## * `foldr template<#foldr.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    let
+      numbers = @[5, 9, 11]
+      addition = foldl(numbers, a + b)
+      subtraction = foldl(numbers, a - b)
+      multiplication = foldl(numbers, a * b)
+      words = @["nim", "is", "cool"]
+      concatenation = foldl(words, a & b)
+      procs = @["proc", "Is", "Also", "Fine"]
+
+
+    func foo(acc, cur: string): string =
+      result = acc & cur
+
+    assert addition == 25, "Addition is (((5)+9)+11)"
+    assert subtraction == -15, "Subtraction is (((5)-9)-11)"
+    assert multiplication == 495, "Multiplication is (((5)*9)*11)"
+    assert concatenation == "nimiscool"
+    assert foldl(procs, foo(a, b)) == "procIsAlsoFine"
+
+  let s = sequence
+  assert s.len > 0, "Can't fold empty sequences"
+  var result: typeof(s[0])
+  result = s[0]
+  for i in 1..<s.len:
+    let
+      a {.inject.} = result
+      b {.inject.} = s[i]
+    result = operation
+  result
+
+template foldl*(sequence, operation, first): untyped =
+  ## Template to fold a sequence from left to right, returning the accumulation.
+  ##
+  ## This version of `foldl` gets a **starting parameter**. This makes it possible
+  ## to accumulate the sequence into a different type than the sequence elements.
+  ##
+  ## The `operation` parameter should be an expression which uses the variables
+  ## `a` and `b` for each step of the fold. The `first` parameter is the
+  ## start value (the first `a`) and therefore defines the type of the result.
+  ##
+  ## **See also:**
+  ## * `foldr template<#foldr.t,untyped,untyped>`_
+  ##
+  runnableExamples:
+    let
+      numbers = @[0, 8, 1, 5]
+      digits = foldl(numbers, a & (chr(b + ord('0'))), "")
+    assert digits == "0815"
+
+  var result: typeof(first) = first
+  for x in items(sequence):
+    let
+      a {.inject.} = result
+      b {.inject.} = x
+    result = operation
+  result
+
+template foldr*(sequence, operation: untyped): untyped =
+  ## Template to fold a sequence from right to left, returning the accumulation.
+  ##
+  ## The sequence is required to have at least a single element. Debug versions
+  ## of your program will assert in this situation but release versions will
+  ## happily go ahead. If the sequence has a single element it will be returned
+  ## without applying `operation`.
+  ##
+  ## The `operation` parameter should be an expression which uses the
+  ## variables `a` and `b` for each step of the fold. Since this is a right
+  ## fold, for non associative binary operations like subtraction think that
+  ## the sequence of numbers 1, 2 and 3 will be parenthesized as (1 - (2 -
+  ## (3))).
+  ##
+  ## **See also:**
+  ## * `foldl template<#foldl.t,untyped,untyped>`_
+  ## * `foldl template<#foldl.t,,,>`_ with a starting parameter
+  ##
+  runnableExamples:
+    let
+      numbers = @[5, 9, 11]
+      addition = foldr(numbers, a + b)
+      subtraction = foldr(numbers, a - b)
+      multiplication = foldr(numbers, a * b)
+      words = @["nim", "is", "cool"]
+      concatenation = foldr(words, a & b)
+    assert addition == 25, "Addition is (5+(9+(11)))"
+    assert subtraction == 7, "Subtraction is (5-(9-(11)))"
+    assert multiplication == 495, "Multiplication is (5*(9*(11)))"
+    assert concatenation == "nimiscool"
+
+  let s = sequence # xxx inefficient, use {.evalonce.} pending #13750
+  let n = s.len
+  assert n > 0, "Can't fold empty sequences"
+  var result = s[n - 1]
+  for i in countdown(n - 2, 0):
+    let
+      a {.inject.} = s[i]
+      b {.inject.} = result
+    result = operation
+  result
+
+template mapIt*(s: typed, op: untyped): untyped =
+  ## Returns a new sequence with the results of the `op` proc applied to every
+  ## item in the container `s`.
+  ##
+  ## Since the input is not modified you can use it to
+  ## transform the type of the elements in the input container.
+  ##
+  ## The template injects the `it` variable which you can use directly in an
+  ## expression.
+  ##
+  ## Instead of using `mapIt` and `filterIt`, consider using the `collect` macro
+  ## from the `sugar` module.
+  ##
+  ## **See also:**
+  ## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
+  ## * `map proc<#map,openArray[T],proc(T)>`_
+  ## * `applyIt template<#applyIt.t,untyped,untyped>`_ for the in-place version
+  ##
+  runnableExamples:
+    let
+      nums = @[1, 2, 3, 4]
+      strings = nums.mapIt($(4 * it))
+    assert strings == @["4", "8", "12", "16"]
+
+  type OutType = typeof((
+    block:
+      var it{.inject.}: typeof(items(s), typeOfIter);
+      op), typeOfProc)
+  when OutType is not (proc):
+    # Here, we avoid to create closures in loops.
+    # This avoids https://github.com/nim-lang/Nim/issues/12625
+    when compiles(s.len):
+      block: # using a block avoids https://github.com/nim-lang/Nim/issues/8580
+
+        # BUG: `evalOnceAs(s2, s, false)` would lead to C compile errors
+        # (`error: use of undeclared identifier`) instead of Nim compile errors
+        evalOnceAs(s2, s, compiles((let _ = s)))
+
+        var i = 0
+        var result = newSeq[OutType](s2.len)
+        for it {.inject.} in s2:
+          result[i] = op
+          i += 1
+        result
+    else:
+      var result: seq[OutType]# = @[]
+      # use `items` to avoid https://github.com/nim-lang/Nim/issues/12639
+      for it {.inject.} in items(s):
+        result.add(op)
+      result
+  else:
+    # `op` is going to create closures in loops, let's fallback to `map`.
+    # NOTE: Without this fallback, developers have to define a helper function and
+    # call `map`:
+    #   [1, 2].map((it) => ((x: int) => it + x))
+    # With this fallback, above code can be simplified to:
+    #   [1, 2].mapIt((x: int) => it + x)
+    # In this case, `mapIt` is just syntax sugar for `map`.
+    type InType = typeof(items(s), typeOfIter)
+    # Use a help proc `f` to create closures for each element in `s`
+    let f = proc (x: InType): OutType =
+              let it {.inject.} = x
+              op
+    map(s, f)
+
+template applyIt*(varSeq, op: untyped) =
+  ## Convenience template around the mutable `apply` proc to reduce typing.
+  ##
+  ## The template injects the `it` variable which you can use directly in an
+  ## expression. The expression has to return the same type as the elements
+  ## of the sequence you are mutating.
+  ##
+  ## **See also:**
+  ## * `apply proc<#apply,openArray[T],proc(T)_2>`_
+  ## * `mapIt template<#mapIt.t,typed,untyped>`_
+  ##
+  runnableExamples:
+    var nums = @[1, 2, 3, 4]
+    nums.applyIt(it * 3)
+    assert nums[0] + nums[3] == 15
+
+  for i in low(varSeq) .. high(varSeq):
+    let it {.inject.} = varSeq[i]
+    varSeq[i] = op
+
+
+template newSeqWith*(len: int, init: untyped): untyped =
+  ## Creates a new `seq` of length `len`, calling `init` to initialize
+  ## each value of the seq.
+  ##
+  ## Useful for creating "2D" seqs - seqs containing other seqs
+  ## or to populate fields of the created seq.
+  runnableExamples:
+    ## Creates a seq containing 5 bool seqs, each of length of 3.
+    var seq2D = newSeqWith(5, newSeq[bool](3))
+    assert seq2D.len == 5
+    assert seq2D[0].len == 3
+    assert seq2D[4][2] == false
+
+    ## Creates a seq with random numbers
+    import std/random
+    var seqRand = newSeqWith(20, rand(1.0))
+    assert seqRand[0] != seqRand[1]
+  type T = typeof(init)
+  let newLen = len
+  when supportsCopyMem(T) and declared(newSeqUninit):
+    var result = newSeqUninit[T](newLen)
+  else: # TODO: use `newSeqUnsafe` when that's available
+    var result = newSeq[T](newLen)
+  for i in 0 ..< newLen:
+    result[i] = init
+  move(result) # refs bug #7295
+
+func mapLitsImpl(constructor: NimNode; op: NimNode; nested: bool;
+                 filter = nnkLiterals): NimNode =
+  if constructor.kind in filter:
+    result = newNimNode(nnkCall, lineInfoFrom = constructor)
+    result.add op
+    result.add constructor
+  else:
+    result = copyNimNode(constructor)
+    for v in constructor:
+      if nested or v.kind in filter:
+        result.add mapLitsImpl(v, op, nested, filter)
+      else:
+        result.add v
+
+macro mapLiterals*(constructor, op: untyped;
+                   nested = true): untyped =
+  ## Applies `op` to each of the **atomic** literals like `3`
+  ## or `"abc"` in the specified `constructor` AST. This can
+  ## be used to map every array element to some target type:
+  runnableExamples:
+    let x = mapLiterals([0.1, 1.2, 2.3, 3.4], int)
+    doAssert x is array[4, int]
+    doAssert x == [int(0.1), int(1.2), int(2.3), int(3.4)]
+  ## If `nested` is true (which is the default), the literals are replaced
+  ## everywhere in the `constructor` AST, otherwise only the first level
+  ## is considered:
+  runnableExamples:
+    let a = mapLiterals((1.2, (2.3, 3.4), 4.8), int)
+    let b = mapLiterals((1.2, (2.3, 3.4), 4.8), int, nested=false)
+    assert a == (1, (2, 3), 4)
+    assert b == (1, (2.3, 3.4), 4)
+
+    let c = mapLiterals((1, (2, 3), 4, (5, 6)), `$`)
+    let d = mapLiterals((1, (2, 3), 4, (5, 6)), `$`, nested=false)
+    assert c == ("1", ("2", "3"), "4", ("5", "6"))
+    assert d == ("1", (2, 3), "4", (5, 6))
+  ## There are no constraints for the `constructor` AST, it
+  ## works for nested tuples of arrays of sets etc.
+  result = mapLitsImpl(constructor, op, nested.boolVal)
+
+iterator items*[T](xs: iterator: T): T =
+  ## Iterates over each element yielded by a closure iterator. This may
+  ## not seem particularly useful on its own, but this allows closure
+  ## iterators to be used by the mapIt, filterIt, allIt, anyIt, etc.
+  ## templates.
+  for x in xs():
+    yield x
diff --git a/lib/pure/collections/setimpl.nim b/lib/pure/collections/setimpl.nim
new file mode 100644
index 000000000..360a075d6
--- /dev/null
+++ b/lib/pure/collections/setimpl.nim
@@ -0,0 +1,156 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# An `include` file for the different hash set implementations.
+
+
+template maxHash(t): untyped = high(t.data)
+template dataLen(t): untyped = len(t.data)
+
+include hashcommon
+
+template initImpl(s: typed, size: int) =
+  let correctSize = slotsNeeded(size)
+  when s is OrderedSet:
+    s.first = -1
+    s.last = -1
+  s.counter = 0
+  newSeq(s.data, correctSize)
+
+template rawInsertImpl() {.dirty.} =
+  if data.len == 0:
+    initImpl(s, defaultInitialSize)
+  data[h].key = key
+  data[h].hcode = hc
+
+proc rawInsert[A](s: var HashSet[A], data: var KeyValuePairSeq[A], key: A,
+                  hc: Hash, h: Hash) =
+  rawInsertImpl()
+
+proc enlarge[A](s: var HashSet[A]) =
+  var n: KeyValuePairSeq[A]
+  newSeq(n, len(s.data) * growthFactor)
+  swap(s.data, n) # n is now old seq
+  for i in countup(0, high(n)):
+    if isFilled(n[i].hcode):
+      var j = -1 - rawGetKnownHC(s, n[i].key, n[i].hcode)
+      rawInsert(s, s.data, n[i].key, n[i].hcode, j)
+
+template inclImpl() {.dirty.} =
+  if s.data.len == 0:
+    initImpl(s, defaultInitialSize)
+  var hc: Hash
+  var index = rawGet(s, key, hc)
+  if index < 0:
+    if mustRehash(s):
+      enlarge(s)
+      index = rawGetKnownHC(s, key, hc)
+    rawInsert(s, s.data, key, hc, -1 - index)
+    inc(s.counter)
+
+template containsOrInclImpl() {.dirty.} =
+  if s.data.len == 0:
+    initImpl(s, defaultInitialSize)
+  var hc: Hash
+  var index = rawGet(s, key, hc)
+  if index >= 0:
+    result = true
+  else:
+    result = false
+    if mustRehash(s):
+      enlarge(s)
+      index = rawGetKnownHC(s, key, hc)
+    rawInsert(s, s.data, key, hc, -1 - index)
+    inc(s.counter)
+
+template doWhile(a, b) =
+  while true:
+    b
+    if not a: break
+
+proc exclImpl[A](s: var HashSet[A], key: A): bool {.inline.} =
+  var hc: Hash
+  var i = rawGet(s, key, hc)
+  var msk = high(s.data)
+  result = true
+
+  if i >= 0:
+    result = false
+    dec(s.counter)
+    while true: # KnuthV3 Algo6.4R adapted for i=i+1 instead of i=i-1
+      var j = i # The correctness of this depends on (h+1) in nextTry,
+      var r = j # though may be adaptable to other simple sequences.
+      s.data[i].hcode = 0 # mark current EMPTY
+      {.push warning[UnsafeDefault]:off.}
+      reset(s.data[i].key)
+      {.pop.}
+      doWhile((i >= r and r > j) or (r > j and j > i) or (j > i and i >= r)):
+        i = (i + 1) and msk # increment mod table size
+        if isEmpty(s.data[i].hcode): # end of collision cluster; So all done
+          return
+        r = s.data[i].hcode and msk # "home" location of key@i
+      s.data[j] = move(s.data[i]) # data[i] will be marked EMPTY next loop
+
+template dollarImpl() {.dirty.} =
+  result = "{"
+  for key in items(s):
+    if result.len > 1: result.add(", ")
+    result.addQuoted(key)
+  result.add("}")
+
+
+
+# --------------------------- OrderedSet ------------------------------
+
+proc rawGet[A](t: OrderedSet[A], key: A, hc: var Hash): int {.inline.} =
+  rawGetImpl()
+
+proc rawInsert[A](s: var OrderedSet[A], data: var OrderedKeyValuePairSeq[A],
+                  key: A, hc: Hash, h: Hash) =
+  rawInsertImpl()
+  data[h].next = -1
+  if s.first < 0: s.first = h
+  if s.last >= 0: data[s.last].next = h
+  s.last = h
+
+proc enlarge[A](s: var OrderedSet[A]) =
+  var n: OrderedKeyValuePairSeq[A]
+  newSeq(n, len(s.data) * growthFactor)
+  var h = s.first
+  s.first = -1
+  s.last = -1
+  swap(s.data, n)
+  while h >= 0:
+    var nxt = n[h].next
+    if isFilled(n[h].hcode):
+      var j = -1 - rawGetKnownHC(s, n[h].key, n[h].hcode)
+      rawInsert(s, s.data, n[h].key, n[h].hcode, j)
+    h = nxt
+
+proc exclImpl[A](s: var OrderedSet[A], key: A): bool {.inline.} =
+  if len(s.data) == 0:
+    return true
+  var n: OrderedKeyValuePairSeq[A]
+  newSeq(n, len(s.data))
+  var h = s.first
+  s.first = -1
+  s.last = -1
+  swap(s.data, n)
+  let hc = genHash(key)
+  result = true
+  while h >= 0:
+    var nxt = n[h].next
+    if isFilled(n[h].hcode):
+      if n[h].hcode == hc and n[h].key == key:
+        dec s.counter
+        result = false
+      else:
+        var j = -1 - rawGetKnownHC(s, n[h].key, n[h].hcode)
+        rawInsert(s, s.data, n[h].key, n[h].hcode, j)
+    h = nxt
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim
new file mode 100644
index 000000000..af13135aa
--- /dev/null
+++ b/lib/pure/collections/sets.nim
@@ -0,0 +1,930 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## The `sets` module implements an efficient `hash set`:idx: and
+## ordered hash set.
+##
+## Hash sets are different from the `built in set type
+## <manual.html#types-set-type>`_. Sets allow you to store any value that can be
+## `hashed <hashes.html>`_ and they don't contain duplicate entries.
+##
+## Common usages of sets:
+## * removing duplicates from a container by converting it with `toHashSet proc
+##   <#toHashSet,openArray[A]>`_ (see also `sequtils.deduplicate func
+##   <sequtils.html#deduplicate,openArray[T],bool>`_)
+## * membership testing
+## * mathematical operations on two sets, such as
+##   `union <#union,HashSet[A],HashSet[A]>`_,
+##   `intersection <#intersection,HashSet[A],HashSet[A]>`_,
+##   `difference <#difference,HashSet[A],HashSet[A]>`_, and
+##   `symmetric difference <#symmetricDifference,HashSet[A],HashSet[A]>`_
+##
+## **Examples:**
+##
+##   ```Nim
+##   echo toHashSet([9, 5, 1])     # {9, 1, 5}
+##   echo toOrderedSet([9, 5, 1])  # {9, 5, 1}
+##
+##   let
+##     s1 = toHashSet([9, 5, 1])
+##     s2 = toHashSet([3, 5, 7])
+##
+##   echo s1 + s2    # {9, 1, 3, 5, 7}
+##   echo s1 - s2    # {1, 9}
+##   echo s1 * s2    # {5}
+##   echo s1 -+- s2  # {9, 1, 3, 7}
+##   ```
+##
+## Note: The data types declared here have *value semantics*: This means
+## that `=` performs a copy of the set.
+##
+## **See also:**
+## * `intsets module <intsets.html>`_ for efficient int sets
+## * `tables module <tables.html>`_ for hash tables
+
+
+import
+  std/[hashes, math]
+
+when not defined(nimHasEffectsOf):
+  {.pragma: effectsOf.}
+
+{.pragma: myShallow.}
+# For "integer-like A" that are too big for intsets/bit-vectors to be practical,
+# it would be best to shrink hcode to the same size as the integer.  Larger
+# codes should never be needed, and this can pack more entries per cache-line.
+# Losing hcode entirely is also possible - if some element value is forbidden.
+type
+  KeyValuePair[A] = tuple[hcode: Hash, key: A]
+  KeyValuePairSeq[A] = seq[KeyValuePair[A]]
+  HashSet*[A] {.myShallow.} = object ## \
+    ## A generic hash set.
+    ##
+    ## Use `init proc <#init,HashSet[A]>`_ or `initHashSet proc <#initHashSet>`_
+    ## before calling other procs on it.
+    data: KeyValuePairSeq[A]
+    counter: int
+
+type
+  OrderedKeyValuePair[A] = tuple[
+    hcode: Hash, next: int, key: A]
+  OrderedKeyValuePairSeq[A] = seq[OrderedKeyValuePair[A]]
+  OrderedSet*[A] {.myShallow.} = object ## \
+    ## A generic hash set that remembers insertion order.
+    ##
+    ## Use `init proc <#init,OrderedSet[A]>`_ or `initOrderedSet proc
+    ## <#initOrderedSet>`_ before calling other procs on it.
+    data: OrderedKeyValuePairSeq[A]
+    counter, first, last: int
+  SomeSet*[A] = HashSet[A] | OrderedSet[A]
+    ## Type union representing `HashSet` or `OrderedSet`.
+
+const
+  defaultInitialSize* = 64
+
+include setimpl
+
+# ---------------------------------------------------------------------
+# ------------------------------ HashSet ------------------------------
+# ---------------------------------------------------------------------
+
+
+proc init*[A](s: var HashSet[A], initialSize = defaultInitialSize) =
+  ## Initializes a hash set.
+  ##
+  ## Starting from Nim v0.20, sets are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## You can call this proc on a previously initialized hash set, which will
+  ## discard all its values. This might be more convenient than iterating over
+  ## existing values and calling `excl() <#excl,HashSet[A],A>`_ on them.
+  ##
+  ## See also:
+  ## * `initHashSet proc <#initHashSet>`_
+  ## * `toHashSet proc <#toHashSet,openArray[A]>`_
+  runnableExamples:
+    var a: HashSet[int]
+    init(a)
+
+  initImpl(s, initialSize)
+
+proc initHashSet*[A](initialSize = defaultInitialSize): HashSet[A] =
+  ## Wrapper around `init proc <#init,HashSet[A]>`_ for initialization of
+  ## hash sets.
+  ##
+  ## Returns an empty hash set you can assign directly in `var` blocks in a
+  ## single line.
+  ##
+  ## Starting from Nim v0.20, sets are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## See also:
+  ## * `toHashSet proc <#toHashSet,openArray[A]>`_
+  runnableExamples:
+    var a = initHashSet[int]()
+    a.incl(3)
+    assert len(a) == 1
+  result = default(HashSet[A])
+  result.init(initialSize)
+
+proc `[]`*[A](s: var HashSet[A], key: A): var A =
+  ## Returns the element that is actually stored in `s` which has the same
+  ## value as `key` or raises the `KeyError` exception.
+  ##
+  ## This is useful when one overloaded `hash` and `==` but still needs
+  ## reference semantics for sharing.
+  var hc: Hash
+  var index = rawGet(s, key, hc)
+  if index >= 0: result = s.data[index].key
+  else:
+    when compiles($key):
+      raise newException(KeyError, "key not found: " & $key)
+    else:
+      raise newException(KeyError, "key not found")
+
+proc contains*[A](s: HashSet[A], key: A): bool =
+  ## Returns true if `key` is in `s`.
+  ##
+  ## This allows the usage of `in` operator.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,HashSet[A],A>`_
+  ## * `containsOrIncl proc <#containsOrIncl,HashSet[A],A>`_
+  runnableExamples:
+    var values = initHashSet[int]()
+    assert(not values.contains(2))
+    assert 2 notin values
+
+    values.incl(2)
+    assert values.contains(2)
+    assert 2 in values
+
+  var hc: Hash
+  var index = rawGet(s, key, hc)
+  result = index >= 0
+
+proc len*[A](s: HashSet[A]): int =
+  ## Returns the number of elements in `s`.
+  ##
+  ## Due to an implementation detail you can call this proc on variables which
+  ## have not been initialized yet. The proc will return zero as the length
+  ## then.
+  runnableExamples:
+    var a: HashSet[string]
+    assert len(a) == 0
+    let s = toHashSet([3, 5, 7])
+    assert len(s) == 3
+
+  result = s.counter
+
+proc card*[A](s: HashSet[A]): int =
+  ## Alias for `len() <#len,HashSet[A]>`_.
+  ##
+  ## Card stands for the `cardinality
+  ## <http://en.wikipedia.org/wiki/Cardinality>`_ of a set.
+  result = s.counter
+
+proc incl*[A](s: var HashSet[A], key: A) =
+  ## Includes an element `key` in `s`.
+  ##
+  ## This doesn't do anything if `key` is already in `s`.
+  ##
+  ## See also:
+  ## * `excl proc <#excl,HashSet[A],A>`_ for excluding an element
+  ## * `incl proc <#incl,HashSet[A],HashSet[A]>`_ for including other set
+  ## * `containsOrIncl proc <#containsOrIncl,HashSet[A],A>`_
+  runnableExamples:
+    var values = initHashSet[int]()
+    values.incl(2)
+    values.incl(2)
+    assert values.len == 1
+
+  inclImpl()
+
+proc incl*[A](s: var HashSet[A], other: HashSet[A]) =
+  ## Includes all elements from `other` set into `s` (must be declared as `var`).
+  ##
+  ## This is the in-place version of `s + other <#+,HashSet[A],HashSet[A]>`_.
+  ##
+  ## See also:
+  ## * `excl proc <#excl,HashSet[A],HashSet[A]>`_ for excluding other set
+  ## * `incl proc <#incl,HashSet[A],A>`_ for including an element
+  ## * `containsOrIncl proc <#containsOrIncl,HashSet[A],A>`_
+  runnableExamples:
+    var
+      values = toHashSet([1, 2, 3])
+      others = toHashSet([3, 4, 5])
+    values.incl(others)
+    assert values.len == 5
+
+  for item in other: incl(s, item)
+
+proc toHashSet*[A](keys: openArray[A]): HashSet[A] =
+  ## Creates a new hash set that contains the members of the given
+  ## collection (seq, array, or string) `keys`.
+  ##
+  ## Duplicates are removed.
+  ##
+  ## See also:
+  ## * `initHashSet proc <#initHashSet>`_
+  runnableExamples:
+    let
+      a = toHashSet([5, 3, 2])
+      b = toHashSet("abracadabra")
+    assert len(a) == 3
+    ## a == {2, 3, 5}
+    assert len(b) == 5
+    ## b == {'a', 'b', 'c', 'd', 'r'}
+
+  result = initHashSet[A](keys.len)
+  for key in items(keys): result.incl(key)
+
+iterator items*[A](s: HashSet[A]): A =
+  ## Iterates over elements of the set `s`.
+  ##
+  ## If you need a sequence with the elements you can use `sequtils.toSeq
+  ## template <sequtils.html#toSeq.t,untyped>`_.
+  ##
+  ##   ```Nim
+  ##   type
+  ##     pair = tuple[a, b: int]
+  ##   var
+  ##     a, b = initHashSet[pair]()
+  ##   a.incl((2, 3))
+  ##   a.incl((3, 2))
+  ##   a.incl((2, 3))
+  ##   for x, y in a.items:
+  ##     b.incl((x - 2, y + 1))
+  ##   assert a.len == 2
+  ##   echo b
+  ##   # --> {(a: 1, b: 3), (a: 0, b: 4)}
+  ##   ```
+  let length = s.len
+  for h in 0 .. high(s.data):
+    if isFilled(s.data[h].hcode):
+      yield s.data[h].key
+      assert(len(s) == length, "the length of the HashSet changed while iterating over it")
+
+proc containsOrIncl*[A](s: var HashSet[A], key: A): bool =
+  ## Includes `key` in the set `s` and tells if `key` was already in `s`.
+  ##
+  ## The difference with regards to the `incl proc <#incl,HashSet[A],A>`_ is
+  ## that this proc returns `true` if `s` already contained `key`. The
+  ## proc will return `false` if `key` was added as a new value to `s` during
+  ## this call.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,HashSet[A],A>`_ for including an element
+  ## * `incl proc <#incl,HashSet[A],HashSet[A]>`_ for including other set
+  ## * `missingOrExcl proc <#missingOrExcl,HashSet[A],A>`_
+  runnableExamples:
+    var values = initHashSet[int]()
+    assert values.containsOrIncl(2) == false
+    assert values.containsOrIncl(2) == true
+    assert values.containsOrIncl(3) == false
+
+  containsOrInclImpl()
+
+proc excl*[A](s: var HashSet[A], key: A) =
+  ## Excludes `key` from the set `s`.
+  ##
+  ## This doesn't do anything if `key` is not found in `s`.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,HashSet[A],A>`_ for including an element
+  ## * `excl proc <#excl,HashSet[A],HashSet[A]>`_ for excluding other set
+  ## * `missingOrExcl proc <#missingOrExcl,HashSet[A],A>`_
+  runnableExamples:
+    var s = toHashSet([2, 3, 6, 7])
+    s.excl(2)
+    s.excl(2)
+    assert s.len == 3
+
+  discard exclImpl(s, key)
+
+proc excl*[A](s: var HashSet[A], other: HashSet[A]) =
+  ## Excludes all elements of `other` set from `s`.
+  ##
+  ## This is the in-place version of `s - other <#-,HashSet[A],HashSet[A]>`_.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,HashSet[A],HashSet[A]>`_ for including other set
+  ## * `excl proc <#excl,HashSet[A],A>`_ for excluding an element
+  ## * `missingOrExcl proc <#missingOrExcl,HashSet[A],A>`_
+  runnableExamples:
+    var
+      numbers = toHashSet([1, 2, 3, 4, 5])
+      even = toHashSet([2, 4, 6, 8])
+    numbers.excl(even)
+    assert len(numbers) == 3
+    ## numbers == {1, 3, 5}
+
+  for item in other: discard exclImpl(s, item)
+
+proc missingOrExcl*[A](s: var HashSet[A], key: A): bool =
+  ## Excludes `key` in the set `s` and tells if `key` was already missing from `s`.
+  ##
+  ## The difference with regards to the `excl proc <#excl,HashSet[A],A>`_ is
+  ## that this proc returns `true` if `key` was missing from `s`.
+  ## The proc will return `false` if `key` was in `s` and it was removed
+  ## during this call.
+  ##
+  ## See also:
+  ## * `excl proc <#excl,HashSet[A],A>`_ for excluding an element
+  ## * `excl proc <#excl,HashSet[A],HashSet[A]>`_ for excluding other set
+  ## * `containsOrIncl proc <#containsOrIncl,HashSet[A],A>`_
+  runnableExamples:
+    var s = toHashSet([2, 3, 6, 7])
+    assert s.missingOrExcl(4) == true
+    assert s.missingOrExcl(6) == false
+    assert s.missingOrExcl(6) == true
+
+  exclImpl(s, key)
+
+proc pop*[A](s: var HashSet[A]): A =
+  ## Removes and returns an arbitrary element from the set `s`.
+  ##
+  ## Raises `KeyError` if the set `s` is empty.
+  ##
+  ## See also:
+  ## * `clear proc <#clear,HashSet[A]>`_
+  runnableExamples:
+    var s = toHashSet([2, 1])
+    assert [s.pop, s.pop] in [[1, 2], [2,1]] # order unspecified
+    doAssertRaises(KeyError, echo s.pop)
+
+  for h in 0 .. high(s.data):
+    if isFilled(s.data[h].hcode):
+      result = s.data[h].key
+      excl(s, result)
+      return result
+  raise newException(KeyError, "set is empty")
+
+proc clear*[A](s: var HashSet[A]) =
+  ## Clears the HashSet back to an empty state, without shrinking
+  ## any of the existing storage.
+  ##
+  ## `O(n)` operation, where `n` is the size of the hash bucket.
+  ##
+  ## See also:
+  ## * `pop proc <#pop,HashSet[A]>`_
+  runnableExamples:
+    var s = toHashSet([3, 5, 7])
+    clear(s)
+    assert len(s) == 0
+
+  s.counter = 0
+  for i in 0 ..< s.data.len:
+    s.data[i].hcode = 0
+    {.push warning[UnsafeDefault]:off.}
+    reset(s.data[i].key)
+    {.pop.}
+
+
+proc union*[A](s1, s2: HashSet[A]): HashSet[A] =
+  ## Returns the union of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 + s2 <#+,HashSet[A],HashSet[A]>`_.
+  ##
+  ## The union of two sets is represented mathematically as *A ∪ B* and is the
+  ## set of all objects that are members of `s1`, `s2` or both.
+  ##
+  ## See also:
+  ## * `intersection proc <#intersection,HashSet[A],HashSet[A]>`_
+  ## * `difference proc <#difference,HashSet[A],HashSet[A]>`_
+  ## * `symmetricDifference proc <#symmetricDifference,HashSet[A],HashSet[A]>`_
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = union(a, b)
+    assert c == toHashSet(["a", "b", "c"])
+
+  result = s1
+  incl(result, s2)
+
+proc intersection*[A](s1, s2: HashSet[A]): HashSet[A] =
+  ## Returns the intersection of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 * s2 <#*,HashSet[A],HashSet[A]>`_.
+  ##
+  ## The intersection of two sets is represented mathematically as *A ∩ B* and
+  ## is the set of all objects that are members of `s1` and `s2` at the same
+  ## time.
+  ##
+  ## See also:
+  ## * `union proc <#union,HashSet[A],HashSet[A]>`_
+  ## * `difference proc <#difference,HashSet[A],HashSet[A]>`_
+  ## * `symmetricDifference proc <#symmetricDifference,HashSet[A],HashSet[A]>`_
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = intersection(a, b)
+    assert c == toHashSet(["b"])
+
+  result = initHashSet[A](max(min(s1.data.len, s2.data.len), 2))
+
+  # iterate over the elements of the smaller set
+  if s1.data.len < s2.data.len:
+    for item in s1:
+      if item in s2: incl(result, item)
+  else:
+    for item in s2:
+      if item in s1: incl(result, item)
+
+
+proc difference*[A](s1, s2: HashSet[A]): HashSet[A] =
+  ## Returns the difference of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 - s2 <#-,HashSet[A],HashSet[A]>`_.
+  ##
+  ## The difference of two sets is represented mathematically as *A ∖ B* and is
+  ## the set of all objects that are members of `s1` and not members of `s2`.
+  ##
+  ## See also:
+  ## * `union proc <#union,HashSet[A],HashSet[A]>`_
+  ## * `intersection proc <#intersection,HashSet[A],HashSet[A]>`_
+  ## * `symmetricDifference proc <#symmetricDifference,HashSet[A],HashSet[A]>`_
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = difference(a, b)
+    assert c == toHashSet(["a"])
+
+  result = initHashSet[A]()
+  for item in s1:
+    if not contains(s2, item):
+      incl(result, item)
+
+proc symmetricDifference*[A](s1, s2: HashSet[A]): HashSet[A] =
+  ## Returns the symmetric difference of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 -+- s2 <#-+-,HashSet[A],HashSet[A]>`_.
+  ##
+  ## The symmetric difference of two sets is represented mathematically as *A â–³
+  ## B* or *A ⊖ B* and is the set of all objects that are members of `s1` or
+  ## `s2` but not both at the same time.
+  ##
+  ## See also:
+  ## * `union proc <#union,HashSet[A],HashSet[A]>`_
+  ## * `intersection proc <#intersection,HashSet[A],HashSet[A]>`_
+  ## * `difference proc <#difference,HashSet[A],HashSet[A]>`_
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = symmetricDifference(a, b)
+    assert c == toHashSet(["a", "c"])
+
+  result = s1
+  for item in s2:
+    if containsOrIncl(result, item): excl(result, item)
+
+proc `+`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} =
+  ## Alias for `union(s1, s2) <#union,HashSet[A],HashSet[A]>`_.
+  result = union(s1, s2)
+
+proc `*`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} =
+  ## Alias for `intersection(s1, s2) <#intersection,HashSet[A],HashSet[A]>`_.
+  result = intersection(s1, s2)
+
+proc `-`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} =
+  ## Alias for `difference(s1, s2) <#difference,HashSet[A],HashSet[A]>`_.
+  result = difference(s1, s2)
+
+proc `-+-`*[A](s1, s2: HashSet[A]): HashSet[A] {.inline.} =
+  ## Alias for `symmetricDifference(s1, s2)
+  ## <#symmetricDifference,HashSet[A],HashSet[A]>`_.
+  result = symmetricDifference(s1, s2)
+
+proc disjoint*[A](s1, s2: HashSet[A]): bool =
+  ## Returns `true` if the sets `s1` and `s2` have no items in common.
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+    assert disjoint(a, b) == false
+    assert disjoint(a, b - a) == true
+
+  for item in s1:
+    if item in s2: return false
+  return true
+
+proc `<`*[A](s, t: HashSet[A]): bool =
+  ## Returns true if `s` is a strict or proper subset of `t`.
+  ##
+  ## A strict or proper subset `s` has all of its members in `t` but `t` has
+  ## more elements than `s`.
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = intersection(a, b)
+    assert c < a and c < b
+    assert(not (a < a))
+
+  s.counter != t.counter and s <= t
+
+proc `<=`*[A](s, t: HashSet[A]): bool =
+  ## Returns true if `s` is a subset of `t`.
+  ##
+  ## A subset `s` has all of its members in `t` and `t` doesn't necessarily
+  ## have more members than `s`. That is, `s` can be equal to `t`.
+  runnableExamples:
+    let
+      a = toHashSet(["a", "b"])
+      b = toHashSet(["b", "c"])
+      c = intersection(a, b)
+    assert c <= a and c <= b
+    assert a <= a
+
+  result = false
+  if s.counter > t.counter: return
+  result = true
+  for item in items(s):
+    if not(t.contains(item)):
+      result = false
+      return
+
+proc `==`*[A](s, t: HashSet[A]): bool =
+  ## Returns true if both `s` and `t` have the same members and set size.
+  runnableExamples:
+    var
+      a = toHashSet([1, 2])
+      b = toHashSet([2, 1])
+    assert a == b
+
+  s.counter == t.counter and s <= t
+
+proc map*[A, B](data: HashSet[A], op: proc (x: A): B {.closure.}): HashSet[B] {.effectsOf: op.} =
+  ## Returns a new set after applying `op` proc on each of the elements of
+  ##`data` set.
+  ##
+  ## You can use this proc to transform the elements from a set.
+  runnableExamples:
+    let
+      a = toHashSet([1, 2, 3])
+      b = a.map(proc (x: int): string = $x)
+    assert b == toHashSet(["1", "2", "3"])
+
+  result = initHashSet[B]()
+  for item in items(data): result.incl(op(item))
+
+proc hash*[A](s: HashSet[A]): Hash =
+  ## Hashing of HashSet.
+  for h in 0 .. high(s.data):
+    result = result xor s.data[h].hcode
+  result = !$result
+
+proc `$`*[A](s: HashSet[A]): string =
+  ## Converts the set `s` to a string, mostly for logging and printing purposes.
+  ##
+  ## Don't use this proc for serialization, the representation may change at
+  ## any moment and values are not escaped.
+  ##
+  ## **Examples:**
+  ##   ```Nim
+  ##   echo toHashSet([2, 4, 5])
+  ##   # --> {2, 4, 5}
+  ##   echo toHashSet(["no", "esc'aping", "is \" provided"])
+  ##   # --> {no, esc'aping, is " provided}
+  ##   ```
+  dollarImpl()
+
+
+proc initSet*[A](initialSize = defaultInitialSize): HashSet[A] {.deprecated:
+     "Deprecated since v0.20, use 'initHashSet'".} = initHashSet[A](initialSize)
+
+proc toSet*[A](keys: openArray[A]): HashSet[A] {.deprecated:
+     "Deprecated since v0.20, use 'toHashSet'".} = toHashSet[A](keys)
+
+proc isValid*[A](s: HashSet[A]): bool {.deprecated:
+     "Deprecated since v0.20; sets are initialized by default".} =
+  ## Returns `true` if the set has been initialized (with `initHashSet proc
+  ## <#initHashSet>`_ or `init proc <#init,HashSet[A]>`_).
+  ##
+  runnableExamples:
+    proc savePreferences(options: HashSet[string]) =
+      assert options.isValid, "Pass an initialized set!"
+      # Do stuff here, may crash in release builds!
+  result = s.data.len > 0
+
+
+
+# ---------------------------------------------------------------------
+# --------------------------- OrderedSet ------------------------------
+# ---------------------------------------------------------------------
+
+template forAllOrderedPairs(yieldStmt: untyped) {.dirty.} =
+  if s.data.len > 0:
+    var h = s.first
+    var idx = 0
+    while h >= 0:
+      var nxt = s.data[h].next
+      if isFilled(s.data[h].hcode):
+        yieldStmt
+        inc(idx)
+      h = nxt
+
+
+proc init*[A](s: var OrderedSet[A], initialSize = defaultInitialSize) =
+  ## Initializes an ordered hash set.
+  ##
+  ## Starting from Nim v0.20, sets are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## You can call this proc on a previously initialized hash set, which will
+  ## discard all its values. This might be more convenient than iterating over
+  ## existing values and calling `excl() <#excl,HashSet[A],A>`_ on them.
+  ##
+  ## See also:
+  ## * `initOrderedSet proc <#initOrderedSet>`_
+  ## * `toOrderedSet proc <#toOrderedSet,openArray[A]>`_
+  runnableExamples:
+    var a: OrderedSet[int]
+    init(a)
+
+  initImpl(s, initialSize)
+
+proc initOrderedSet*[A](initialSize = defaultInitialSize): OrderedSet[A] =
+  ## Wrapper around `init proc <#init,OrderedSet[A]>`_ for initialization of
+  ## ordered hash sets.
+  ##
+  ## Returns an empty ordered hash set you can assign directly in `var` blocks
+  ## in a single line.
+  ##
+  ## Starting from Nim v0.20, sets are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## See also:
+  ## * `toOrderedSet proc <#toOrderedSet,openArray[A]>`_
+  runnableExamples:
+    var a = initOrderedSet[int]()
+    a.incl(3)
+    assert len(a) == 1
+
+  result.init(initialSize)
+
+proc toOrderedSet*[A](keys: openArray[A]): OrderedSet[A] =
+  ## Creates a new hash set that contains the members of the given
+  ## collection (seq, array, or string) `keys`.
+  ##
+  ## Duplicates are removed.
+  ##
+  ## See also:
+  ## * `initOrderedSet proc <#initOrderedSet>`_
+  runnableExamples:
+    let
+      a = toOrderedSet([5, 3, 2])
+      b = toOrderedSet("abracadabra")
+    assert len(a) == 3
+    ## a == {5, 3, 2} # different than in HashSet
+    assert len(b) == 5
+    ## b == {'a', 'b', 'r', 'c', 'd'} # different than in HashSet
+
+  result = initOrderedSet[A](keys.len)
+  for key in items(keys): result.incl(key)
+
+proc contains*[A](s: OrderedSet[A], key: A): bool =
+  ## Returns true if `key` is in `s`.
+  ##
+  ## This allows the usage of `in` operator.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,OrderedSet[A],A>`_
+  ## * `containsOrIncl proc <#containsOrIncl,OrderedSet[A],A>`_
+  runnableExamples:
+    var values = initOrderedSet[int]()
+    assert(not values.contains(2))
+    assert 2 notin values
+
+    values.incl(2)
+    assert values.contains(2)
+    assert 2 in values
+
+  var hc: Hash
+  var index = rawGet(s, key, hc)
+  result = index >= 0
+
+proc incl*[A](s: var OrderedSet[A], key: A) =
+  ## Includes an element `key` in `s`.
+  ##
+  ## This doesn't do anything if `key` is already in `s`.
+  ##
+  ## See also:
+  ## * `excl proc <#excl,OrderedSet[A],A>`_ for excluding an element
+  ## * `incl proc <#incl,HashSet[A],OrderedSet[A]>`_ for including other set
+  ## * `containsOrIncl proc <#containsOrIncl,OrderedSet[A],A>`_
+  runnableExamples:
+    var values = initOrderedSet[int]()
+    values.incl(2)
+    values.incl(2)
+    assert values.len == 1
+
+  inclImpl()
+
+proc incl*[A](s: var HashSet[A], other: OrderedSet[A]) =
+  ## Includes all elements from the OrderedSet `other` into
+  ## HashSet `s` (must be declared as `var`).
+  ##
+  ## See also:
+  ## * `incl proc <#incl,OrderedSet[A],A>`_ for including an element
+  ## * `containsOrIncl proc <#containsOrIncl,OrderedSet[A],A>`_
+  runnableExamples:
+    var
+      values = toHashSet([1, 2, 3])
+      others = toOrderedSet([3, 4, 5])
+    values.incl(others)
+    assert values.len == 5
+
+  for item in items(other): incl(s, item)
+
+proc containsOrIncl*[A](s: var OrderedSet[A], key: A): bool =
+  ## Includes `key` in the set `s` and tells if `key` was already in `s`.
+  ##
+  ## The difference with regards to the `incl proc <#incl,OrderedSet[A],A>`_ is
+  ## that this proc returns `true` if `s` already contained `key`. The
+  ## proc will return false if `key` was added as a new value to `s` during
+  ## this call.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,OrderedSet[A],A>`_ for including an element
+  ## * `missingOrExcl proc <#missingOrExcl,OrderedSet[A],A>`_
+  runnableExamples:
+    var values = initOrderedSet[int]()
+    assert values.containsOrIncl(2) == false
+    assert values.containsOrIncl(2) == true
+    assert values.containsOrIncl(3) == false
+
+  containsOrInclImpl()
+
+proc excl*[A](s: var OrderedSet[A], key: A) =
+  ## Excludes `key` from the set `s`. Efficiency: `O(n)`.
+  ##
+  ## This doesn't do anything if `key` is not found in `s`.
+  ##
+  ## See also:
+  ## * `incl proc <#incl,OrderedSet[A],A>`_ for including an element
+  ## * `missingOrExcl proc <#missingOrExcl,OrderedSet[A],A>`_
+  runnableExamples:
+    var s = toOrderedSet([2, 3, 6, 7])
+    s.excl(2)
+    s.excl(2)
+    assert s.len == 3
+
+  discard exclImpl(s, key)
+
+proc missingOrExcl*[A](s: var OrderedSet[A], key: A): bool =
+  ## Excludes `key` in the set `s` and tells if `key` was already missing from `s`.
+  ## Efficiency: O(n).
+  ##
+  ## The difference with regards to the `excl proc <#excl,OrderedSet[A],A>`_ is
+  ## that this proc returns `true` if `key` was missing from `s`.
+  ## The proc will return `false` if `key` was in `s` and it was removed
+  ## during this call.
+  ##
+  ## See also:
+  ## * `excl proc <#excl,OrderedSet[A],A>`_
+  ## * `containsOrIncl proc <#containsOrIncl,OrderedSet[A],A>`_
+  runnableExamples:
+    var s = toOrderedSet([2, 3, 6, 7])
+    assert s.missingOrExcl(4) == true
+    assert s.missingOrExcl(6) == false
+    assert s.missingOrExcl(6) == true
+
+  exclImpl(s, key)
+
+proc clear*[A](s: var OrderedSet[A]) =
+  ## Clears the OrderedSet back to an empty state, without shrinking
+  ## any of the existing storage.
+  ##
+  ## `O(n)` operation where `n` is the size of the hash bucket.
+  runnableExamples:
+    var s = toOrderedSet([3, 5, 7])
+    clear(s)
+    assert len(s) == 0
+
+  s.counter = 0
+  s.first = -1
+  s.last = -1
+  for i in 0 ..< s.data.len:
+    s.data[i].hcode = 0
+    s.data[i].next = 0
+    {.push warning[UnsafeDefault]:off.}
+    reset(s.data[i].key)
+    {.pop.}
+
+proc len*[A](s: OrderedSet[A]): int {.inline.} =
+  ## Returns the number of elements in `s`.
+  ##
+  ## Due to an implementation detail you can call this proc on variables which
+  ## have not been initialized yet. The proc will return zero as the length
+  ## then.
+  runnableExamples:
+    var a: OrderedSet[string]
+    assert len(a) == 0
+    let s = toHashSet([3, 5, 7])
+    assert len(s) == 3
+
+  result = s.counter
+
+proc card*[A](s: OrderedSet[A]): int {.inline.} =
+  ## Alias for `len() <#len,OrderedSet[A]>`_.
+  ##
+  ## Card stands for the `cardinality
+  ## <http://en.wikipedia.org/wiki/Cardinality>`_ of a set.
+  result = s.counter
+
+proc `==`*[A](s, t: OrderedSet[A]): bool =
+  ## Equality for ordered sets.
+  runnableExamples:
+    let
+      a = toOrderedSet([1, 2])
+      b = toOrderedSet([2, 1])
+    assert(not (a == b))
+
+  if s.counter != t.counter: return false
+  var h = s.first
+  var g = t.first
+  var compared = 0
+  while h >= 0 and g >= 0:
+    var nxh = s.data[h].next
+    var nxg = t.data[g].next
+    if isFilled(s.data[h].hcode) and isFilled(t.data[g].hcode):
+      if s.data[h].key == t.data[g].key:
+        inc compared
+      else:
+        return false
+    h = nxh
+    g = nxg
+  result = compared == s.counter
+
+proc hash*[A](s: OrderedSet[A]): Hash =
+  ## Hashing of OrderedSet.
+  forAllOrderedPairs:
+    result = result !& s.data[h].hcode
+  result = !$result
+
+proc `$`*[A](s: OrderedSet[A]): string =
+  ## Converts the ordered hash set `s` to a string, mostly for logging and
+  ## printing purposes.
+  ##
+  ## Don't use this proc for serialization, the representation may change at
+  ## any moment and values are not escaped.
+  ##
+  ## **Examples:**
+  ##   ```Nim
+  ##   echo toOrderedSet([2, 4, 5])
+  ##   # --> {2, 4, 5}
+  ##   echo toOrderedSet(["no", "esc'aping", "is \" provided"])
+  ##   # --> {no, esc'aping, is " provided}
+  ##   ```
+  dollarImpl()
+
+
+
+iterator items*[A](s: OrderedSet[A]): A =
+  ## Iterates over keys in the ordered set `s` in insertion order.
+  ##
+  ## If you need a sequence with the elements you can use `sequtils.toSeq
+  ## template <sequtils.html#toSeq.t,untyped>`_.
+  ##
+  ##   ```Nim
+  ##   var a = initOrderedSet[int]()
+  ##   for value in [9, 2, 1, 5, 1, 8, 4, 2]:
+  ##     a.incl(value)
+  ##   for value in a.items:
+  ##     echo "Got ", value
+  ##   # --> Got 9
+  ##   # --> Got 2
+  ##   # --> Got 1
+  ##   # --> Got 5
+  ##   # --> Got 8
+  ##   # --> Got 4
+  ##   ```
+  let length = s.len
+  forAllOrderedPairs:
+    yield s.data[h].key
+    assert(len(s) == length, "the length of the OrderedSet changed while iterating over it")
+
+iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
+  ## Iterates through (position, value) tuples of OrderedSet `s`.
+  runnableExamples:
+    let a = toOrderedSet("abracadabra")
+    var p = newSeq[(int, char)]()
+    for x in pairs(a):
+      p.add(x)
+    assert p == @[(0, 'a'), (1, 'b'), (2, 'r'), (3, 'c'), (4, 'd')]
+
+  let length = s.len
+  forAllOrderedPairs:
+    yield (idx, s.data[h].key)
+    assert(len(s) == length, "the length of the OrderedSet changed while iterating over it")
diff --git a/lib/pure/collections/sharedlist.nim b/lib/pure/collections/sharedlist.nim
new file mode 100644
index 000000000..ec8f1cd86
--- /dev/null
+++ b/lib/pure/collections/sharedlist.nim
@@ -0,0 +1,105 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Shared list support.
+##
+## Unstable API.
+
+{.deprecated.}
+
+{.push stackTrace: off.}
+
+import
+  std/locks
+
+const
+  ElemsPerNode = 100
+
+type
+  SharedListNode[A] = ptr object
+    next: SharedListNode[A]
+    dataLen: int
+    d: array[ElemsPerNode, A]
+
+  SharedList*[A] = object ## generic shared list
+    head, tail: SharedListNode[A]
+    lock*: Lock
+
+template withLock(t, x: untyped) =
+  acquire(t.lock)
+  x
+  release(t.lock)
+
+proc iterAndMutate*[A](x: var SharedList[A]; action: proc(x: A): bool) =
+  ## Iterates over the list. If `action` returns true, the
+  ## current item is removed from the list.
+  ##
+  ## .. warning:: It may not preserve the element order after some modifications.
+  withLock(x):
+    var n = x.head
+    while n != nil:
+      var i = 0
+      while i < n.dataLen:
+        # action can add new items at the end, so release the lock:
+        release(x.lock)
+        if action(n.d[i]):
+          acquire(x.lock)
+          let t = x.tail
+          dec t.dataLen # TODO considering t.dataLen == 0,
+                        # probably the module should be refactored using doubly linked lists
+          n.d[i] = t.d[t.dataLen]
+        else:
+          acquire(x.lock)
+          inc i
+      n = n.next
+
+iterator items*[A](x: var SharedList[A]): A =
+  withLock(x):
+    var it = x.head
+    while it != nil:
+      for i in 0..it.dataLen-1:
+        yield it.d[i]
+      it = it.next
+
+proc add*[A](x: var SharedList[A]; y: A) =
+  withLock(x):
+    var node: SharedListNode[A]
+    if x.tail == nil:
+      node = cast[typeof node](allocShared0(sizeof(node[])))
+      x.tail = node
+      x.head = node
+    elif x.tail.dataLen == ElemsPerNode:
+      node = cast[typeof node](allocShared0(sizeof(node[])))
+      x.tail.next = node
+      x.tail = node
+    else:
+      node = x.tail
+    node.d[node.dataLen] = y
+    inc(node.dataLen)
+
+proc init*[A](t: var SharedList[A]) =
+  initLock t.lock
+  t.head = nil
+  t.tail = nil
+
+proc clear*[A](t: var SharedList[A]) =
+  withLock(t):
+    var it = t.head
+    while it != nil:
+      let nxt = it.next
+      deallocShared(it)
+      it = nxt
+    t.head = nil
+    t.tail = nil
+
+proc deinitSharedList*[A](t: var SharedList[A]) =
+  clear(t)
+  deinitLock t.lock
+
+{.pop.}
diff --git a/lib/pure/collections/sharedtables.nim b/lib/pure/collections/sharedtables.nim
new file mode 100644
index 000000000..b474ecd31
--- /dev/null
+++ b/lib/pure/collections/sharedtables.nim
@@ -0,0 +1,252 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Shared table support for Nim. Use plain old non GC'ed keys and values or
+## you'll be in trouble. Uses a single lock to protect the table, lockfree
+## implementations welcome but if lock contention is so high that you need a
+## lockfree hash table, you're doing it wrong.
+##
+## Unstable API.
+
+{.deprecated.}
+
+import
+  std/[hashes, math, locks]
+
+type
+  KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B]
+  KeyValuePairSeq[A, B] = ptr UncheckedArray[KeyValuePair[A, B]]
+  SharedTable*[A, B] = object ## generic hash SharedTable
+    data: KeyValuePairSeq[A, B]
+    counter, dataLen: int
+    lock: Lock
+
+template maxHash(t): untyped = t.dataLen-1
+
+include tableimpl
+
+template st_maybeRehashPutImpl(enlarge) {.dirty.} =
+  if mustRehash(t):
+    enlarge(t)
+    index = rawGetKnownHC(t, key, hc)
+  index = -1 - index # important to transform for mgetOrPutImpl
+  rawInsert(t, t.data, key, val, hc, index)
+  inc(t.counter)
+
+proc enlarge[A, B](t: var SharedTable[A, B]) =
+  let oldSize = t.dataLen
+  let size = oldSize * growthFactor
+  var n = cast[KeyValuePairSeq[A, B]](allocShared0(
+                                      sizeof(KeyValuePair[A, B]) * size))
+  t.dataLen = size
+  swap(t.data, n)
+  for i in 0..<oldSize:
+    let eh = n[i].hcode
+    if isFilled(eh):
+      var j: Hash = eh and maxHash(t)
+      while isFilled(t.data[j].hcode):
+        j = nextTry(j, maxHash(t))
+      rawInsert(t, t.data, n[i].key, n[i].val, eh, j)
+  deallocShared(n)
+
+template withLock(t, x: untyped) =
+  acquire(t.lock)
+  x
+  release(t.lock)
+
+template withValue*[A, B](t: var SharedTable[A, B], key: A,
+                          value, body: untyped) =
+  ## Retrieves the value at `t[key]`.
+  ## `value` can be modified in the scope of the `withValue` call.
+  runnableExamples:
+    var table: SharedTable[string, string]
+    init(table)
+
+    table["a"] = "x"
+    table["b"] = "y"
+    table["c"] = "z"
+
+    table.withValue("a", value):
+      assert value[] == "x"
+
+    table.withValue("b", value):
+      value[] = "modified"
+
+    table.withValue("b", value):
+      assert value[] == "modified"
+
+    table.withValue("nonexistent", value):
+      assert false # not called
+  acquire(t.lock)
+  try:
+    var hc: Hash
+    var index = rawGet(t, key, hc)
+    let hasKey = index >= 0
+    if hasKey:
+      var value {.inject.} = addr(t.data[index].val)
+      body
+  finally:
+    release(t.lock)
+
+template withValue*[A, B](t: var SharedTable[A, B], key: A,
+                          value, body1, body2: untyped) =
+  ## Retrieves the value at `t[key]`.
+  ## `value` can be modified in the scope of the `withValue` call.
+  runnableExamples:
+    var table: SharedTable[string, string]
+    init(table)
+
+    table["a"] = "x"
+    table["b"] = "y"
+    table["c"] = "z"
+
+
+    table.withValue("a", value):
+      value[] = "m"
+
+    var flag = false
+    table.withValue("d", value):
+      discard value
+      doAssert false
+    do: # if "d" notin table
+      flag = true
+
+    if flag:
+      table["d"] = "n"
+
+    assert table.mget("a") == "m"
+    assert table.mget("d") == "n"
+
+  acquire(t.lock)
+  try:
+    var hc: Hash
+    var index = rawGet(t, key, hc)
+    let hasKey = index >= 0
+    if hasKey:
+      var value {.inject.} = addr(t.data[index].val)
+      body1
+    else:
+      body2
+  finally:
+    release(t.lock)
+
+proc mget*[A, B](t: var SharedTable[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]`. The value can be modified.
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  withLock t:
+    var hc: Hash
+    var index = rawGet(t, key, hc)
+    let hasKey = index >= 0
+    if hasKey: result = t.data[index].val
+  if not hasKey:
+    when compiles($key):
+      raise newException(KeyError, "key not found: " & $key)
+    else:
+      raise newException(KeyError, "key not found")
+
+proc mgetOrPut*[A, B](t: var SharedTable[A, B], key: A, val: B): var B =
+  ## Retrieves value at `t[key]` or puts `val` if not present, either way
+  ## returning a value which can be modified. **Note**: This is inherently
+  ## unsafe in the context of multi-threading since it returns a pointer
+  ## to `B`.
+  withLock t:
+    mgetOrPutImpl(enlarge)
+
+proc hasKeyOrPut*[A, B](t: var SharedTable[A, B], key: A, val: B): bool =
+  ## Returns true if `key` is in the table, otherwise inserts `value`.
+  withLock t:
+    hasKeyOrPutImpl(enlarge)
+
+template tabMakeEmpty(i) = t.data[i].hcode = 0
+template tabCellEmpty(i) = isEmpty(t.data[i].hcode)
+template tabCellHash(i)  = t.data[i].hcode
+
+proc withKey*[A, B](t: var SharedTable[A, B], key: A,
+                    mapper: proc(key: A, val: var B, pairExists: var bool)) =
+  ## Computes a new mapping for the `key` with the specified `mapper`
+  ## procedure.
+  ##
+  ## The `mapper` takes 3 arguments:
+  ##
+  ## 1. `key` - the current key, if it exists, or the key passed to
+  ##    `withKey` otherwise;
+  ## 2. `val` - the current value, if the key exists, or default value
+  ##    of the type otherwise;
+  ## 3. `pairExists` - `true` if the key exists, `false` otherwise.
+  ##
+  ## The `mapper` can can modify `val` and `pairExists` values to change
+  ## the mapping of the key or delete it from the table.
+  ## When adding a value, make sure to set `pairExists` to `true` along
+  ## with modifying the `val`.
+  ##
+  ## The operation is performed atomically and other operations on the table
+  ## will be blocked while the `mapper` is invoked, so it should be short and
+  ## simple.
+  ##
+  ## Example usage:
+  ##
+  ##   ```nim
+  ##   # If value exists, decrement it.
+  ##   # If it becomes zero or less, delete the key
+  ##   t.withKey(1'i64) do (k: int64, v: var int, pairExists: var bool):
+  ##     if pairExists:
+  ##       dec v
+  ##       if v <= 0:
+  ##         pairExists = false
+  ##   ```
+  withLock t:
+    var hc: Hash
+    var index = rawGet(t, key, hc)
+
+    var pairExists = index >= 0
+    if pairExists:
+      mapper(t.data[index].key, t.data[index].val, pairExists)
+      if not pairExists:
+        delImplIdx(t, index, tabMakeEmpty, tabCellEmpty, tabCellHash)
+    else:
+      var val: B
+      mapper(key, val, pairExists)
+      if pairExists:
+        st_maybeRehashPutImpl(enlarge)
+
+proc `[]=`*[A, B](t: var SharedTable[A, B], key: A, val: B) =
+  ## Puts a (key, value)-pair into `t`.
+  withLock t:
+    putImpl(enlarge)
+
+proc add*[A, B](t: var SharedTable[A, B], key: A, val: B) =
+  ## Puts a new (key, value)-pair into `t` even if `t[key]` already exists.
+  ## This can introduce duplicate keys into the table!
+  withLock t:
+    addImpl(enlarge)
+
+proc del*[A, B](t: var SharedTable[A, B], key: A) =
+  ## Deletes `key` from hash table `t`.
+  withLock t:
+    delImpl(tabMakeEmpty, tabCellEmpty, tabCellHash)
+
+proc len*[A, B](t: var SharedTable[A, B]): int =
+  ## Number of elements in `t`.
+  withLock t:
+    result = t.counter
+
+proc init*[A, B](t: var SharedTable[A, B], initialSize = 32) =
+  ## Creates a new hash table that is empty.
+  ##
+  ## This proc must be called before any other usage of `t`.
+  let initialSize = slotsNeeded(initialSize)
+  t.counter = 0
+  t.dataLen = initialSize
+  t.data = cast[KeyValuePairSeq[A, B]](allocShared0(
+                                      sizeof(KeyValuePair[A, B]) * initialSize))
+  initLock t.lock
+
+proc deinitSharedTable*[A, B](t: var SharedTable[A, B]) =
+  deallocShared(t.data)
+  deinitLock t.lock
diff --git a/lib/pure/collections/tableimpl.nim b/lib/pure/collections/tableimpl.nim
new file mode 100644
index 000000000..3542741fa
--- /dev/null
+++ b/lib/pure/collections/tableimpl.nim
@@ -0,0 +1,231 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# An `include` file for the different table implementations.
+
+include hashcommon
+
+const
+  defaultInitialSize* = 32
+
+template rawGetDeepImpl() {.dirty.} =   # Search algo for unconditional add
+  genHashImpl(key, hc)
+  var h: Hash = hc and maxHash(t)
+  while isFilled(t.data[h].hcode):
+    h = nextTry(h, maxHash(t))
+  result = h
+
+template rawInsertImpl() {.dirty.} =
+  data[h].key = key
+  data[h].val = val
+  data[h].hcode = hc
+
+proc rawGetDeep[X, A](t: X, key: A, hc: var Hash): int {.inline, outParamsAt: [3].} =
+  rawGetDeepImpl()
+
+proc rawInsert[X, A, B](t: var X, data: var KeyValuePairSeq[A, B],
+                     key: A, val: sink B, hc: Hash, h: Hash) =
+  rawInsertImpl()
+
+template checkIfInitialized() =
+  if t.dataLen == 0:
+    initImpl(t, defaultInitialSize)
+
+template addImpl(enlarge) {.dirty.} =
+  checkIfInitialized()
+  if mustRehash(t): enlarge(t)
+  var hc: Hash
+  var j = rawGetDeep(t, key, hc)
+  rawInsert(t, t.data, key, val, hc, j)
+  inc(t.counter)
+
+template maybeRehashPutImpl(enlarge, val) {.dirty.} =
+  checkIfInitialized()
+  if mustRehash(t):
+    enlarge(t)
+    index = rawGetKnownHC(t, key, hc)
+  index = -1 - index                  # important to transform for mgetOrPutImpl
+  rawInsert(t, t.data, key, val, hc, index)
+  inc(t.counter)
+
+template putImpl(enlarge) {.dirty.} =
+  checkIfInitialized()
+  var hc: Hash = default(Hash)
+  var index = rawGet(t, key, hc)
+  if index >= 0: t.data[index].val = val
+  else: maybeRehashPutImpl(enlarge, val)
+
+template mgetOrPutImpl(enlarge) {.dirty.} =
+  checkIfInitialized()
+  var hc: Hash = default(Hash)
+  var index = rawGet(t, key, hc)
+  if index < 0:
+    # not present: insert (flipping index)
+    when declared(val):
+      maybeRehashPutImpl(enlarge, val)
+    else:
+      maybeRehashPutImpl(enlarge, default(B))
+  # either way return modifiable val
+  result = t.data[index].val
+
+# template mgetOrPutDefaultImpl(enlarge) {.dirty.} =
+#   checkIfInitialized()
+#   var hc: Hash = default(Hash)
+#   var index = rawGet(t, key, hc)
+#   if index < 0:
+#     # not present: insert (flipping index)
+#     maybeRehashPutImpl(enlarge, default(B))
+#   # either way return modifiable val
+#   result = t.data[index].val
+
+template hasKeyOrPutImpl(enlarge) {.dirty.} =
+  checkIfInitialized()
+  var hc: Hash = default(Hash)
+  var index = rawGet(t, key, hc)
+  if index < 0:
+    result = false
+    maybeRehashPutImpl(enlarge, val)
+  else: result = true
+
+# delImplIdx is KnuthV3 Algo6.4R adapted to i=i+1 (from i=i-1) which has come to
+# be called "back shift delete".  It shifts elements in the collision cluster of
+# a victim backward to make things as-if the victim were never inserted in the
+# first place.  This is desirable to keep things "ageless" after many deletes.
+# It is trickier than you might guess since initial probe (aka "home") locations
+# of keys in a cluster may collide and since table addresses wrap around.
+#
+# A before-after diagram might look like ('.' means empty):
+#   slot:   0   1   2   3   4   5   6   7
+# before(1)
+#   hash1:  6   7   .   3   .   5   5   6  ; Really hash() and msk
+#   data1:  E   F   .   A   .   B   C   D  ; About to delete C @index 6
+# after(2)
+#   hash2:  7   .   .   3   .   5   6   6  ; Really hash() and msk
+#   data2:  F   .   .   A   .   B   D   E  ; After deletion of C
+#
+# This lowers total search depth over the whole table from 1+1+2+2+2+2=10 to 7.
+# Had the victim been B@5, C would need back shifting to slot 5.  Total depth is
+# always lowered by at least 1, e.g. victim A@3.  This is all quite fast when
+# empty slots are frequent (also needed to keep insert/miss searches fast) and
+# hash() is either fast or avoided (via `.hcode`).  It need not compare keys.
+#
+# delImplIdx realizes the above transformation, but only works for dense Linear
+# Probing, nextTry(h)=h+1.  This is not an important limitation since that's the
+# fastest sequence on any CPU made since the 1980s. { Performance analysis often
+# overweights "key cmp" neglecting cache behavior, giving bad ideas how big/slow
+# tables behave (when perf matters most!).  Comparing hcode first means usually
+# only 1 key cmp is needed for *any* seq.  Timing only predictable activity,
+# small tables, and/or integer keys often perpetuates such bad ideas. }
+
+template delImplIdx(t, i, makeEmpty, cellEmpty, cellHash) =
+  let msk = maxHash(t)
+  if i >= 0:
+    dec(t.counter)
+    block outer:
+      while true:         # KnuthV3 Algo6.4R adapted for i=i+1 instead of i=i-1
+        var j = i         # The correctness of this depends on (h+1) in nextTry
+        var r = j         # though may be adaptable to other simple sequences.
+        makeEmpty(i)                     # mark current EMPTY
+        {.push warning[UnsafeDefault]:off.}
+        reset(t.data[i].key)
+        reset(t.data[i].val)
+        {.pop.}
+        while true:
+          i = (i + 1) and msk            # increment mod table size
+          if cellEmpty(i):               # end of collision cluster; So all done
+            break outer
+          r = cellHash(i) and msk        # initial probe index for key@slot i
+          if not ((i >= r and r > j) or (r > j and j > i) or (j > i and i >= r)):
+            break
+        when defined(js):
+          t.data[j] = t.data[i]
+        else:
+          t.data[j] = move(t.data[i]) # data[j] will be marked EMPTY next loop
+
+template delImpl(makeEmpty, cellEmpty, cellHash) {.dirty.} =
+  var hc: Hash
+  var i = rawGet(t, key, hc)
+  delImplIdx(t, i, makeEmpty, cellEmpty, cellHash)
+
+template delImplNoHCode(makeEmpty, cellEmpty, cellHash) {.dirty.} =
+  if t.dataLen > 0:
+    var i: Hash = hash(key) and maxHash(t)
+    while not cellEmpty(i):
+      if t.data[i].key == key:
+        delImplIdx(t, i, makeEmpty, cellEmpty, cellHash)
+        break
+      i = nextTry(i, maxHash(t))
+
+template clearImpl() {.dirty.} =
+  for i in 0 ..< t.dataLen:
+    when compiles(t.data[i].hcode): # CountTable records don't contain a hcode
+      t.data[i].hcode = 0
+    {.push warning[UnsafeDefault]:off.}
+    reset(t.data[i].key)
+    reset(t.data[i].val)
+    {.pop.}
+  t.counter = 0
+
+template ctAnd(a, b): bool =
+  when a:
+    when b: true
+    else: false
+  else: false
+
+template initImpl(result: typed, size: int) =
+  let correctSize = slotsNeeded(size)
+  when ctAnd(declared(SharedTable), typeof(result) is SharedTable):
+    init(result, correctSize)
+  else:
+    result.counter = 0
+    newSeq(result.data, correctSize)
+    when compiles(result.first):
+      result.first = -1
+      result.last = -1
+
+template insertImpl() = # for CountTable
+  if t.dataLen == 0: initImpl(t, defaultInitialSize)
+  if mustRehash(t): enlarge(t)
+  ctRawInsert(t, t.data, key, val)
+  inc(t.counter)
+
+template getOrDefaultImpl(t, key): untyped =
+  mixin rawGet
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  if index >= 0: result = t.data[index].val
+
+template getOrDefaultImpl(t, key, default: untyped): untyped =
+  mixin rawGet
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  result = if index >= 0: t.data[index].val else: default
+
+template dollarImpl(): untyped {.dirty.} =
+  if t.len == 0:
+    result = "{:}"
+  else:
+    result = "{"
+    for key, val in pairs(t):
+      if result.len > 1: result.add(", ")
+      result.addQuoted(key)
+      result.add(": ")
+      result.addQuoted(val)
+    result.add("}")
+
+template equalsImpl(s, t: typed) =
+  if s.counter == t.counter:
+    # different insertion orders mean different 'data' seqs, so we have
+    # to use the slow route here:
+    for key, val in s:
+      if not t.hasKey(key): return false
+      if t.getOrDefault(key) != val: return false
+    return true
+  else:
+    return false
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim
new file mode 100644
index 000000000..d414caeed
--- /dev/null
+++ b/lib/pure/collections/tables.nim
@@ -0,0 +1,2972 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## The `tables` module implements variants of an efficient `hash table`:idx:
+## (also often named `dictionary`:idx: in other programming languages) that is
+## a mapping from keys to values.
+##
+## There are several different types of hash tables available:
+## * `Table<#Table>`_ is the usual hash table,
+## * `OrderedTable<#OrderedTable>`_ is like `Table` but remembers insertion order,
+## * `CountTable<#CountTable>`_ is a mapping from a key to its number of occurrences
+##
+## For consistency with every other data type in Nim these have **value**
+## semantics, this means that `=` performs a copy of the hash table.
+##
+## For `ref semantics<manual.html#types-reference-and-pointer-types>`_
+## use their `Ref` variants: `TableRef<#TableRef>`_,
+## `OrderedTableRef<#OrderedTableRef>`_, and `CountTableRef<#CountTableRef>`_.
+##
+## To give an example, when `a` is a `Table`, then `var b = a` gives `b`
+## as a new independent table. `b` is initialised with the contents of `a`.
+## Changing `b` does not affect `a` and vice versa:
+
+runnableExamples:
+  var
+    a = {1: "one", 2: "two"}.toTable  # creates a Table
+    b = a
+
+  assert a == b
+
+  b[3] = "three"
+  assert 3 notin a
+  assert 3 in b
+  assert a != b
+
+## On the other hand, when `a` is a `TableRef` instead, then changes to `b`
+## also affect `a`. Both `a` and `b` **ref** the same data structure:
+
+runnableExamples:
+  var
+    a = {1: "one", 2: "two"}.newTable  # creates a TableRef
+    b = a
+
+  assert a == b
+
+  b[3] = "three"
+
+  assert 3 in a
+  assert 3 in b
+  assert a == b
+
+##
+## ----
+##
+
+## # Basic usage
+
+
+## ## Table
+runnableExamples:
+  from std/sequtils import zip
+
+  let
+    names = ["John", "Paul", "George", "Ringo"]
+    years = [1940, 1942, 1943, 1940]
+
+  var beatles = initTable[string, int]()
+
+  for pairs in zip(names, years):
+    let (name, birthYear) = pairs
+    beatles[name] = birthYear
+
+  assert beatles == {"George": 1943, "Ringo": 1940, "Paul": 1942, "John": 1940}.toTable
+
+
+  var beatlesByYear = initTable[int, seq[string]]()
+
+  for pairs in zip(years, names):
+    let (birthYear, name) = pairs
+    if not beatlesByYear.hasKey(birthYear):
+      # if a key doesn't exist, we create one with an empty sequence
+      # before we can add elements to it
+      beatlesByYear[birthYear] = @[]
+    beatlesByYear[birthYear].add(name)
+
+  assert beatlesByYear == {1940: @["John", "Ringo"], 1942: @["Paul"], 1943: @["George"]}.toTable
+
+## ## OrderedTable
+## `OrderedTable<#OrderedTable>`_ is used when it is important to preserve
+## the insertion order of keys.
+
+runnableExamples:
+  let
+    a = [('z', 1), ('y', 2), ('x', 3)]
+    ot = a.toOrderedTable  # ordered tables
+
+  assert $ot == """{'z': 1, 'y': 2, 'x': 3}"""
+
+## ## CountTable
+## `CountTable<#CountTable>`_ is useful for counting number of items of some
+## container (e.g. string, sequence or array), as it is a mapping where the
+## items are the keys, and their number of occurrences are the values.
+## For that purpose `toCountTable proc<#toCountTable,openArray[A]>`_
+## comes handy:
+
+runnableExamples:
+  let myString = "abracadabra"
+  let letterFrequencies = toCountTable(myString)
+  assert $letterFrequencies == "{'a': 5, 'd': 1, 'b': 2, 'r': 2, 'c': 1}"
+
+## The same could have been achieved by manually iterating over a container
+## and increasing each key's value with `inc proc
+## <#inc,CountTable[A],A,int>`_:
+
+runnableExamples:
+  let myString = "abracadabra"
+  var letterFrequencies = initCountTable[char]()
+  for c in myString:
+    letterFrequencies.inc(c)
+  assert $letterFrequencies == "{'d': 1, 'r': 2, 'c': 1, 'a': 5, 'b': 2}"
+
+##
+## ----
+##
+
+## ## Hashing
+##
+## If you are using simple standard types like `int` or `string` for the
+## keys of the table you won't have any problems, but as soon as you try to use
+## a more complex object as a key you will be greeted by a strange compiler
+## error:
+##
+##     Error: type mismatch: got (Person)
+##     but expected one of:
+##     hashes.hash(x: openArray[A]): Hash
+##     hashes.hash(x: int): Hash
+##     hashes.hash(x: float): Hash
+##
+## What is happening here is that the types used for table keys require to have
+## a `hash()` proc which will convert them to a `Hash <hashes.html#Hash>`_
+## value, and the compiler is listing all the hash functions it knows.
+## Additionally there has to be a `==` operator that provides the same
+## semantics as its corresponding `hash` proc.
+##
+## After you add `hash` and `==` for your custom type everything will work.
+## Currently, however, `hash` for objects is not defined, whereas
+## `system.==` for objects does exist and performs a "deep" comparison (every
+## field is compared) which is usually what you want. So in the following
+## example implementing only `hash` suffices:
+
+runnableExamples:
+  import std/hashes
+
+  type
+    Person = object
+      firstName, lastName: string
+
+  proc hash(x: Person): Hash =
+    ## Piggyback on the already available string hash proc.
+    ##
+    ## Without this proc nothing works!
+    result = x.firstName.hash !& x.lastName.hash
+    result = !$result
+
+  var
+    salaries = initTable[Person, int]()
+    p1, p2: Person
+
+  p1.firstName = "Jon"
+  p1.lastName = "Ross"
+  salaries[p1] = 30_000
+
+  p2.firstName = "소진"
+  p2.lastName = "ë°•"
+  salaries[p2] = 45_000
+
+##
+## ----
+##
+
+## # See also
+##
+## * `json module<json.html>`_ for table-like structure which allows
+##   heterogeneous members
+## * `strtabs module<strtabs.html>`_ for efficient hash tables
+##   mapping from strings to strings
+## * `hashes module<hashes.html>`_ for helper functions for hashing
+
+
+import std/private/since
+import std/[hashes, math, algorithm]
+
+
+when not defined(nimHasEffectsOf):
+  {.pragma: effectsOf.}
+
+type
+  KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B]
+  KeyValuePairSeq[A, B] = seq[KeyValuePair[A, B]]
+  Table*[A, B] = object
+    ## Generic hash table, consisting of a key-value pair.
+    ##
+    ## `data` and `counter` are internal implementation details which
+    ## can't be accessed.
+    ##
+    ## For creating an empty Table, use `initTable proc<#initTable>`_.
+    data: KeyValuePairSeq[A, B]
+    counter: int
+  TableRef*[A, B] = ref Table[A, B] ## Ref version of `Table<#Table>`_.
+    ##
+    ## For creating a new empty TableRef, use `newTable proc
+    ## <#newTable>`_.
+
+
+# ------------------------------ helpers ---------------------------------
+
+# Do NOT move these to tableimpl.nim, because sharedtables uses that
+# file and has its own implementation.
+template maxHash(t): untyped = high(t.data)
+template dataLen(t): untyped = len(t.data)
+
+include tableimpl
+
+proc raiseKeyError[T](key: T) {.noinline, noreturn.} =
+  when compiles($key):
+    raise newException(KeyError, "key not found: " & $key)
+  else:
+    raise newException(KeyError, "key not found")
+
+template get(t, key): untyped =
+  ## retrieves the value at `t[key]`. The value can be modified.
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  mixin rawGet
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  if index >= 0: result = t.data[index].val
+  else:
+    raiseKeyError(key)
+
+proc enlarge[A, B](t: var Table[A, B]) =
+  var n: KeyValuePairSeq[A, B]
+  newSeq(n, len(t.data) * growthFactor)
+  swap(t.data, n)
+  for i in countup(0, high(n)):
+    let eh = n[i].hcode
+    if isFilled(eh):
+      var j: Hash = eh and maxHash(t)
+      while isFilled(t.data[j].hcode):
+        j = nextTry(j, maxHash(t))
+      when defined(js):
+        rawInsert(t, t.data, n[i].key, n[i].val, eh, j)
+      else:
+        rawInsert(t, t.data, move n[i].key, move n[i].val, eh, j)
+
+
+
+
+# -------------------------------------------------------------------
+# ------------------------------ Table ------------------------------
+# -------------------------------------------------------------------
+
+proc initTable*[A, B](initialSize = defaultInitialSize): Table[A, B] =
+  ## Creates a new hash table that is empty.
+  ##
+  ## Starting from Nim v0.20, tables are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## See also:
+  ## * `toTable proc<#toTable,openArray[]>`_
+  ## * `newTable proc<#newTable>`_ for creating a `TableRef`
+  runnableExamples:
+    let
+      a = initTable[int, string]()
+      b = initTable[char, seq[int]]()
+  result = default(Table[A, B])
+  initImpl(result, initialSize)
+
+proc `[]=`*[A, B](t: var Table[A, B], key: A, val: sink B) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,Table[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,Table[A,B],A,B>`_
+  ## * `del proc<#del,Table[A,B],A>`_ for removing a key from the table
+  runnableExamples:
+    var a = initTable[char, int]()
+    a['x'] = 7
+    a['y'] = 33
+    doAssert a == {'x': 7, 'y': 33}.toTable
+
+  putImpl(enlarge)
+
+proc toTable*[A, B](pairs: openArray[(A, B)]): Table[A, B] =
+  ## Creates a new hash table that contains the given `pairs`.
+  ##
+  ## `pairs` is a container consisting of `(key, value)` tuples.
+  ##
+  ## See also:
+  ## * `initTable proc<#initTable>`_
+  ## * `newTable proc<#newTable,openArray[]>`_ for a `TableRef` version
+  runnableExamples:
+    let a = [('a', 5), ('b', 9)]
+    let b = toTable(a)
+    assert b == {'a': 5, 'b': 9}.toTable
+
+  result = initTable[A, B](pairs.len)
+  for key, val in items(pairs): result[key] = val
+
+proc `[]`*[A, B](t: Table[A, B], key: A): lent B =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  ## One can check with `hasKey proc<#hasKey,Table[A,B],A>`_ whether
+  ## the key exists.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_ for checking if a key is in
+  ##   the table
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert a['a'] == 5
+    doAssertRaises(KeyError):
+      echo a['z']
+  get(t, key)
+
+proc `[]`*[A, B](t: var Table[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]`. The value can be modified.
+  ##
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_ for checking if a key is in
+  ##   the table
+  get(t, key)
+
+proc hasKey*[A, B](t: Table[A, B], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,Table[A,B],A>`_ for use with the `in` operator
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert a.hasKey('a') == true
+    doAssert a.hasKey('z') == false
+
+  var hc: Hash
+  result = rawGet(t, key, hc) >= 0
+
+proc contains*[A, B](t: Table[A, B], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,Table[A,B],A>`_ for use with
+  ## the `in` operator.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert 'b' in a == true
+    doAssert a.contains('z') == false
+
+  return hasKey[A, B](t, key)
+
+proc hasKeyOrPut*[A, B](t: var Table[A, B], key: A, val: B): bool =
+  ## Returns true if `key` is in the table, otherwise inserts `value`.
+  ##
+  ## See also:
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.toTable
+    if a.hasKeyOrPut('a', 50):
+      a['a'] = 99
+    if a.hasKeyOrPut('z', 50):
+      a['z'] = 99
+    doAssert a == {'a': 99, 'b': 9, 'z': 50}.toTable
+
+  hasKeyOrPutImpl(enlarge)
+
+proc getOrDefault*[A, B](t: Table[A, B], key: A): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## default initialization value for type `B` is returned (e.g. 0 for any
+  ## integer type).
+  ##
+  ## See also:
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,Table[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,Table[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert a.getOrDefault('a') == 5
+    doAssert a.getOrDefault('z') == 0
+  result = default(B)
+  getOrDefaultImpl(t, key)
+
+proc getOrDefault*[A, B](t: Table[A, B], key: A, default: B): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise, `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,Table[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,Table[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert a.getOrDefault('a', 99) == 5
+    doAssert a.getOrDefault('z', 99) == 99
+  result = default(B)
+  getOrDefaultImpl(t, key, default)
+
+proc mgetOrPut*[A, B](t: var Table[A, B], key: A, val: B): var B =
+  ## Retrieves value at `t[key]` or puts `val` if not present, either way
+  ## returning a value which can be modified.
+  ##
+  ##
+  ## Note that while the value returned is of type `var B`,
+  ## it is easy to accidentally create a copy of the value at `t[key]`.
+  ## Remember that seqs and strings are value types, and therefore
+  ## cannot be copied into a separate variable for modification.
+  ## See the example below.
+  ##
+  ## See also:
+  ## * `[] proc<#[],Table[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,Table[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,Table[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,Table[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.toTable
+    doAssert a.mgetOrPut('a', 99) == 5
+    doAssert a.mgetOrPut('z', 99) == 99
+    doAssert a == {'a': 5, 'b': 9, 'z': 99}.toTable
+
+    # An example of accidentally creating a copy
+    var t = initTable[int, seq[int]]()
+    # In this example, we expect t[10] to be modified,
+    # but it is not.
+    var copiedSeq = t.mgetOrPut(10, @[10])
+    copiedSeq.add(20)
+    doAssert t[10] == @[10]
+    # Correct
+    t.mgetOrPut(25, @[25]).add(35)
+    doAssert t[25] == @[25, 35]
+
+  mgetOrPutImpl(enlarge)
+
+proc mgetOrPut*[A, B](t: var Table[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]` or puts the
+  ## default initialization value for type `B` (e.g. 0 for any
+  ## integer type).
+  runnableExamples:
+    var a = {'a': 5}.newTable
+    doAssert a.mgetOrPut('a') == 5
+    a.mgetOrPut('z').inc
+    doAssert a == {'a': 5, 'z': 1}.newTable
+
+  mgetOrPutImpl(enlarge)
+
+proc len*[A, B](t: Table[A, B]): int =
+  ## Returns the number of keys in `t`.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toTable
+    doAssert len(a) == 2
+
+  result = t.counter
+
+proc add*[A, B](t: var Table[A, B], key: A, val: sink B) {.deprecated:
+    "Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
+  ## Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
+  ##
+  ## **This can introduce duplicate keys into the table!**
+  ##
+  ## Use `[]= proc<#[]=,Table[A,B],A,sinkB>`_ for inserting a new
+  ## (key, value) pair in the table without introducing duplicates.
+  addImpl(enlarge)
+
+template tabMakeEmpty(i) = t.data[i].hcode = 0
+template tabCellEmpty(i) = isEmpty(t.data[i].hcode)
+template tabCellHash(i)  = t.data[i].hcode
+
+proc del*[A, B](t: var Table[A, B], key: A) =
+  ## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
+  ##
+  ## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
+  ##   this may need to be called multiple times.
+  ##
+  ## See also:
+  ## * `pop proc<#pop,Table[A,B],A,B>`_
+  ## * `clear proc<#clear,Table[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.toTable
+    a.del('a')
+    doAssert a == {'b': 9, 'c': 13}.toTable
+    a.del('z')
+    doAssert a == {'b': 9, 'c': 13}.toTable
+
+  delImpl(tabMakeEmpty, tabCellEmpty, tabCellHash)
+
+proc pop*[A, B](t: var Table[A, B], key: A, val: var B): bool =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
+  ##   this may need to be called multiple times.
+  ##
+  ## See also:
+  ## * `del proc<#del,Table[A,B],A>`_
+  ## * `clear proc<#clear,Table[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var
+      a = {'a': 5, 'b': 9, 'c': 13}.toTable
+      i: int
+    doAssert a.pop('b', i) == true
+    doAssert a == {'a': 5, 'c': 13}.toTable
+    doAssert i == 9
+    i = 0
+    doAssert a.pop('z', i) == false
+    doAssert a == {'a': 5, 'c': 13}.toTable
+    doAssert i == 0
+
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  result = index >= 0
+  if result:
+    val = move(t.data[index].val)
+    delImplIdx(t, index, tabMakeEmpty, tabCellEmpty, tabCellHash)
+
+proc take*[A, B](t: var Table[A, B], key: A, val: var B): bool {.inline.} =
+  ## Alias for:
+  ## * `pop proc<#pop,Table[A,B],A,B>`_
+  pop(t, key, val)
+
+proc clear*[A, B](t: var Table[A, B]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,Table[A,B],A>`_
+  ## * `pop proc<#pop,Table[A,B],A,B>`_
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.toTable
+    doAssert len(a) == 3
+    clear(a)
+    doAssert len(a) == 0
+
+  clearImpl()
+
+proc `$`*[A, B](t: Table[A, B]): string =
+  ## The `$` operator for hash tables. Used internally when calling `echo`
+  ## on a table.
+  dollarImpl()
+
+proc `==`*[A, B](s, t: Table[A, B]): bool =
+  ## The `==` operator for hash tables. Returns `true` if the content of both
+  ## tables contains the same key-value pairs. Insert order does not matter.
+  runnableExamples:
+    let
+      a = {'a': 5, 'b': 9, 'c': 13}.toTable
+      b = {'b': 9, 'c': 13, 'a': 5}.toTable
+    doAssert a == b
+
+  equalsImpl(s, t)
+
+proc indexBy*[A, B, C](collection: A, index: proc(x: B): C): Table[C, B] =
+  ## Index the collection with the proc provided.
+  # TODO: As soon as supported, change collection: A to collection: A[B]
+  result = initTable[C, B]()
+  for item in collection:
+    result[index(item)] = item
+
+
+
+template withValue*[A, B](t: var Table[A, B], key: A, value, body: untyped) =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## `value` can be modified in the scope of the `withValue` call.
+  runnableExamples:
+    type
+      User = object
+        name: string
+        uid: int
+
+    var t = initTable[int, User]()
+    let u = User(name: "Hello", uid: 99)
+    t[1] = u
+
+    t.withValue(1, value):
+      # block is executed only if `key` in `t`
+      value.name = "Nim"
+      value.uid = 1314
+
+    t.withValue(2, value):
+      value.name = "No"
+      value.uid = 521
+
+    assert t[1].name == "Nim"
+    assert t[1].uid == 1314
+
+  mixin rawGet
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  let hasKey = index >= 0
+  if hasKey:
+    var value {.inject.} = addr(t.data[index].val)
+    body
+
+template withValue*[A, B](t: var Table[A, B], key: A,
+                          value, body1, body2: untyped) =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## `value` can be modified in the scope of the `withValue` call.
+  runnableExamples:
+    type
+      User = object
+        name: string
+        uid: int
+
+    var t = initTable[int, User]()
+    let u = User(name: "Hello", uid: 99)
+    t[1] = u
+
+    t.withValue(1, value):
+      # block is executed only if `key` in `t`
+      value.name = "Nim"
+      value.uid = 1314
+
+    t.withValue(521, value):
+      doAssert false
+    do:
+      # block is executed when `key` not in `t`
+      t[1314] = User(name: "exist", uid: 521)
+
+    assert t[1].name == "Nim"
+    assert t[1].uid == 1314
+    assert t[1314].name == "exist"
+    assert t[1314].uid == 521
+
+  mixin rawGet
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  let hasKey = index >= 0
+  if hasKey:
+    var value {.inject.} = addr(t.data[index].val)
+    body1
+  else:
+    body2
+
+
+iterator pairs*[A, B](t: Table[A, B]): (A, B) =
+  ## Iterates over any `(key, value)` pair in the table `t`.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,Table[A,B]>`_
+  ## * `keys iterator<#keys.i,Table[A,B]>`_
+  ## * `values iterator<#values.i,Table[A,B]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = {
+  ##     'o': [1, 5, 7, 9],
+  ##     'e': [2, 4, 6, 8]
+  ##     }.toTable
+  ##
+  ##   for k, v in a.pairs:
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: e
+  ##   # value: [2, 4, 6, 8]
+  ##   # key: o
+  ##   # value: [1, 5, 7, 9]
+  ##   ```
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A, B](t: var Table[A, B]): (A, var B) =
+  ## Iterates over any `(key, value)` pair in the table `t` (must be
+  ## declared as `var`). The values can be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,Table[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,Table[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toTable
+    for k, v in a.mpairs:
+      v.add(v[0] + 10)
+    doAssert a == {'e': @[2, 4, 6, 8, 12], 'o': @[1, 5, 7, 9, 11]}.toTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator keys*[A, B](t: Table[A, B]): lent A =
+  ## Iterates over any key in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,Table[A,B]>`_
+  ## * `values iterator<#values.i,Table[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toTable
+    for k in a.keys:
+      a[k].add(99)
+    doAssert a == {'e': @[2, 4, 6, 8, 99], 'o': @[1, 5, 7, 9, 99]}.toTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].key
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A, B](t: Table[A, B]): lent B =
+  ## Iterates over any value in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,Table[A,B]>`_
+  ## * `keys iterator<#keys.i,Table[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,Table[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toTable
+    for v in a.values:
+      doAssert v.len == 4
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A, B](t: var Table[A, B]): var B =
+  ## Iterates over any value in the table `t` (must be
+  ## declared as `var`). The values can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,Table[A,B]>`_
+  ## * `values iterator<#values.i,Table[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toTable
+    for v in a.mvalues:
+      v.add(99)
+    doAssert a == {'e': @[2, 4, 6, 8, 99], 'o': @[1, 5, 7, 9, 99]}.toTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator allValues*[A, B](t: Table[A, B]; key: A): B {.deprecated:
+    "Deprecated since v1.4; tables with duplicated keys are deprecated".} =
+  ## Iterates over any value in the table `t` that belongs to the given `key`.
+  ##
+  ## Used if you have a table with duplicate keys (as a result of using
+  ## `add proc<#add,Table[A,B],A,sinkB>`_).
+  ##
+  runnableExamples:
+    import std/[sequtils, algorithm]
+
+    var a = {'a': 3, 'b': 5}.toTable
+    for i in 1..3: a.add('z', 10*i)
+    doAssert toSeq(a.pairs).sorted == @[('a', 3), ('b', 5), ('z', 10), ('z', 20), ('z', 30)]
+    doAssert sorted(toSeq(a.allValues('z'))) == @[10, 20, 30]
+  var h: Hash = genHash(key) and high(t.data)
+  let L = len(t)
+  while isFilled(t.data[h].hcode):
+    if t.data[h].key == key:
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+    h = nextTry(h, high(t.data))
+
+
+
+# -------------------------------------------------------------------
+# ---------------------------- TableRef -----------------------------
+# -------------------------------------------------------------------
+
+
+proc newTable*[A, B](initialSize = defaultInitialSize): TableRef[A, B] =
+  ## Creates a new ref hash table that is empty.
+  ##
+  ## See also:
+  ## * `newTable proc<#newTable,openArray[]>`_ for creating a `TableRef`
+  ##   from a collection of `(key, value)` pairs
+  ## * `initTable proc<#initTable>`_ for creating a `Table`
+  runnableExamples:
+    let
+      a = newTable[int, string]()
+      b = newTable[char, seq[int]]()
+
+  new(result)
+  {.noSideEffect.}:
+    result[] = initTable[A, B](initialSize)
+
+proc newTable*[A, B](pairs: openArray[(A, B)]): TableRef[A, B] =
+  ## Creates a new ref hash table that contains the given `pairs`.
+  ##
+  ## `pairs` is a container consisting of `(key, value)` tuples.
+  ##
+  ## See also:
+  ## * `newTable proc<#newTable>`_
+  ## * `toTable proc<#toTable,openArray[]>`_ for a `Table` version
+  runnableExamples:
+    let a = [('a', 5), ('b', 9)]
+    let b = newTable(a)
+    assert b == {'a': 5, 'b': 9}.newTable
+
+  new(result)
+  {.noSideEffect.}:
+    result[] = toTable[A, B](pairs)
+
+proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): TableRef[C, B] =
+  ## Index the collection with the proc provided.
+  # TODO: As soon as supported, change collection: A to collection: A[B]
+  result = newTable[C, B]()
+  {.noSideEffect.}:
+    for item in collection:
+      result[index(item)] = item
+
+proc `[]`*[A, B](t: TableRef[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## If `key` is not in `t`, the  `KeyError` exception is raised.
+  ## One can check with `hasKey proc<#hasKey,TableRef[A,B],A>`_ whether
+  ## the key exists.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,TableRef[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,TableRef[A,B],A>`_ for checking if a key is in
+  ##   the table
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert a['a'] == 5
+    doAssertRaises(KeyError):
+      echo a['z']
+
+  result = t[][key]
+
+proc `[]=`*[A, B](t: TableRef[A, B], key: A, val: sink B) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,TableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,TableRef[A,B],A,B>`_
+  ## * `del proc<#del,TableRef[A,B],A>`_ for removing a key from the table
+  runnableExamples:
+    var a = newTable[char, int]()
+    a['x'] = 7
+    a['y'] = 33
+    doAssert a == {'x': 7, 'y': 33}.newTable
+
+  t[][key] = val
+
+proc hasKey*[A, B](t: TableRef[A, B], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,TableRef[A,B],A>`_ for use with the `in`
+  ##   operator
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert a.hasKey('a') == true
+    doAssert a.hasKey('z') == false
+
+  result = t[].hasKey(key)
+
+proc contains*[A, B](t: TableRef[A, B], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,TableRef[A,B],A>`_ for use with
+  ## the `in` operator.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert 'b' in a == true
+    doAssert a.contains('z') == false
+
+  return hasKey[A, B](t, key)
+
+proc hasKeyOrPut*[A, B](t: TableRef[A, B], key: A, val: B): bool =
+  ## Returns true if `key` is in the table, otherwise inserts `value`.
+  ##
+  ## See also:
+  ## * `hasKey proc<#hasKey,TableRef[A,B],A>`_
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.newTable
+    if a.hasKeyOrPut('a', 50):
+      a['a'] = 99
+    if a.hasKeyOrPut('z', 50):
+      a['z'] = 99
+    doAssert a == {'a': 99, 'b': 9, 'z': 50}.newTable
+
+  t[].hasKeyOrPut(key, val)
+
+proc getOrDefault*[A, B](t: TableRef[A, B], key: A): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## default initialization value for type `B` is returned (e.g. 0 for any
+  ## integer type).
+  ##
+  ## See also:
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,TableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,TableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,TableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert a.getOrDefault('a') == 5
+    doAssert a.getOrDefault('z') == 0
+
+  getOrDefault(t[], key)
+
+proc getOrDefault*[A, B](t: TableRef[A, B], key: A, default: B): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise, `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,TableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,TableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,TableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert a.getOrDefault('a', 99) == 5
+    doAssert a.getOrDefault('z', 99) == 99
+
+  getOrDefault(t[], key, default)
+
+proc mgetOrPut*[A, B](t: TableRef[A, B], key: A, val: B): var B =
+  ## Retrieves value at `t[key]` or puts `val` if not present, either way
+  ## returning a value which can be modified.
+  ##
+  ## Note that while the value returned is of type `var B`,
+  ## it is easy to accidentally create an copy of the value at `t[key]`.
+  ## Remember that seqs and strings are value types, and therefore
+  ## cannot be copied into a separate variable for modification.
+  ## See the example below.
+  ##
+  ## See also:
+  ## * `[] proc<#[],TableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,TableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,TableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,TableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.newTable
+    doAssert a.mgetOrPut('a', 99) == 5
+    doAssert a.mgetOrPut('z', 99) == 99
+    doAssert a == {'a': 5, 'b': 9, 'z': 99}.newTable
+
+    # An example of accidentally creating a copy
+    var t = newTable[int, seq[int]]()
+    # In this example, we expect t[10] to be modified,
+    # but it is not.
+    var copiedSeq = t.mgetOrPut(10, @[10])
+    copiedSeq.add(20)
+    doAssert t[10] == @[10]
+    # Correct
+    t.mgetOrPut(25, @[25]).add(35)
+    doAssert t[25] == @[25, 35]
+  t[].mgetOrPut(key, val)
+
+proc mgetOrPut*[A, B](t: TableRef[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]` or puts the
+  ## default initialization value for type `B` (e.g. 0 for any
+  ## integer type).
+  runnableExamples:
+    var a = {'a': 5}.newTable
+    doAssert a.mgetOrPut('a') == 5
+    a.mgetOrPut('z').inc
+    doAssert a == {'a': 5, 'z': 1}.newTable
+
+  t[].mgetOrPut(key)
+
+proc len*[A, B](t: TableRef[A, B]): int =
+  ## Returns the number of keys in `t`.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newTable
+    doAssert len(a) == 2
+
+  result = t.counter
+
+proc add*[A, B](t: TableRef[A, B], key: A, val: sink B) {.deprecated:
+    "Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
+  ## Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
+  ##
+  ## **This can introduce duplicate keys into the table!**
+  ##
+  ## Use `[]= proc<#[]=,TableRef[A,B],A,sinkB>`_ for inserting a new
+  ## (key, value) pair in the table without introducing duplicates.
+  t[].add(key, val)
+
+proc del*[A, B](t: TableRef[A, B], key: A) =
+  ## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
+  ##
+  ## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
+  ##   this may need to be called multiple times.
+  ##
+  ## See also:
+  ## * `pop proc<#pop,TableRef[A,B],A,B>`_
+  ## * `clear proc<#clear,TableRef[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.newTable
+    a.del('a')
+    doAssert a == {'b': 9, 'c': 13}.newTable
+    a.del('z')
+    doAssert a == {'b': 9, 'c': 13}.newTable
+
+  t[].del(key)
+
+proc pop*[A, B](t: TableRef[A, B], key: A, val: var B): bool =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## .. warning:: If duplicate keys were added (via the now deprecated `add` proc),
+  ##   this may need to be called multiple times.
+  ##
+  ## See also:
+  ## * `del proc<#del,TableRef[A,B],A>`_
+  ## * `clear proc<#clear,TableRef[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var
+      a = {'a': 5, 'b': 9, 'c': 13}.newTable
+      i: int
+    doAssert a.pop('b', i) == true
+    doAssert a == {'a': 5, 'c': 13}.newTable
+    doAssert i == 9
+    i = 0
+    doAssert a.pop('z', i) == false
+    doAssert a == {'a': 5, 'c': 13}.newTable
+    doAssert i == 0
+
+  result = t[].pop(key, val)
+
+proc take*[A, B](t: TableRef[A, B], key: A, val: var B): bool {.inline.} =
+  ## Alias for:
+  ## * `pop proc<#pop,TableRef[A,B],A,B>`_
+  pop(t, key, val)
+
+proc clear*[A, B](t: TableRef[A, B]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,Table[A,B],A>`_
+  ## * `pop proc<#pop,Table[A,B],A,B>`_
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.newTable
+    doAssert len(a) == 3
+    clear(a)
+    doAssert len(a) == 0
+
+  clearImpl()
+
+proc `$`*[A, B](t: TableRef[A, B]): string =
+  ## The `$` operator for hash tables. Used internally when calling `echo`
+  ## on a table.
+  dollarImpl()
+
+proc `==`*[A, B](s, t: TableRef[A, B]): bool =
+  ## The `==` operator for hash tables. Returns `true` if either both tables
+  ## are `nil`, or neither is `nil` and the content of both tables contains the
+  ## same key-value pairs. Insert order does not matter.
+  runnableExamples:
+    let
+      a = {'a': 5, 'b': 9, 'c': 13}.newTable
+      b = {'b': 9, 'c': 13, 'a': 5}.newTable
+    doAssert a == b
+
+  if isNil(s): result = isNil(t)
+  elif isNil(t): result = false
+  else: equalsImpl(s[], t[])
+
+
+
+iterator pairs*[A, B](t: TableRef[A, B]): (A, B) =
+  ## Iterates over any `(key, value)` pair in the table `t`.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,TableRef[A,B]>`_
+  ## * `keys iterator<#keys.i,TableRef[A,B]>`_
+  ## * `values iterator<#values.i,TableRef[A,B]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = {
+  ##     'o': [1, 5, 7, 9],
+  ##     'e': [2, 4, 6, 8]
+  ##     }.newTable
+  ##
+  ##   for k, v in a.pairs:
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: e
+  ##   # value: [2, 4, 6, 8]
+  ##   # key: o
+  ##   # value: [1, 5, 7, 9]
+  ##   ```
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A, B](t: TableRef[A, B]): (A, var B) =
+  ## Iterates over any `(key, value)` pair in the table `t`. The values
+  ## can be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,TableRef[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,TableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newTable
+    for k, v in a.mpairs:
+      v.add(v[0] + 10)
+    doAssert a == {'e': @[2, 4, 6, 8, 12], 'o': @[1, 5, 7, 9, 11]}.newTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator keys*[A, B](t: TableRef[A, B]): lent A =
+  ## Iterates over any key in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,TableRef[A,B]>`_
+  ## * `values iterator<#values.i,TableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newTable
+    for k in a.keys:
+      a[k].add(99)
+    doAssert a == {'e': @[2, 4, 6, 8, 99], 'o': @[1, 5, 7, 9, 99]}.newTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].key
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A, B](t: TableRef[A, B]): lent B =
+  ## Iterates over any value in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,TableRef[A,B]>`_
+  ## * `keys iterator<#keys.i,TableRef[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,TableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newTable
+    for v in a.values:
+      doAssert v.len == 4
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A, B](t: TableRef[A, B]): var B =
+  ## Iterates over any value in the table `t`. The values can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,TableRef[A,B]>`_
+  ## * `values iterator<#values.i,TableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newTable
+    for v in a.mvalues:
+      v.add(99)
+    doAssert a == {'e': @[2, 4, 6, 8, 99], 'o': @[1, 5, 7, 9, 99]}.newTable
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if isFilled(t.data[h].hcode):
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+
+
+
+
+
+
+
+# ---------------------------------------------------------------------------
+# ------------------------------ OrderedTable -------------------------------
+# ---------------------------------------------------------------------------
+
+type
+  OrderedKeyValuePair[A, B] = tuple[
+    hcode: Hash, next: int, key: A, val: B]
+  OrderedKeyValuePairSeq[A, B] = seq[OrderedKeyValuePair[A, B]]
+  OrderedTable*[A, B] = object
+    ## Hash table that remembers insertion order.
+    ##
+    ## For creating an empty OrderedTable, use `initOrderedTable proc
+    ## <#initOrderedTable>`_.
+    data: OrderedKeyValuePairSeq[A, B]
+    counter, first, last: int
+  OrderedTableRef*[A, B] = ref OrderedTable[A, B] ## Ref version of
+    ## `OrderedTable<#OrderedTable>`_.
+    ##
+    ## For creating a new empty OrderedTableRef, use `newOrderedTable proc
+    ## <#newOrderedTable>`_.
+
+
+# ------------------------------ helpers ---------------------------------
+
+proc rawGetKnownHC[A, B](t: OrderedTable[A, B], key: A, hc: Hash): int =
+  rawGetKnownHCImpl()
+
+proc rawGetDeep[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int {.inline.} =
+  rawGetDeepImpl()
+
+proc rawGet[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int =
+  rawGetImpl()
+
+proc rawInsert[A, B](t: var OrderedTable[A, B],
+                     data: var OrderedKeyValuePairSeq[A, B],
+                     key: A, val: sink B, hc: Hash, h: Hash) =
+  rawInsertImpl()
+  data[h].next = -1
+  if t.first < 0: t.first = h
+  if t.last >= 0: data[t.last].next = h
+  t.last = h
+
+proc enlarge[A, B](t: var OrderedTable[A, B]) =
+  var n: OrderedKeyValuePairSeq[A, B]
+  newSeq(n, len(t.data) * growthFactor)
+  var h = t.first
+  t.first = -1
+  t.last = -1
+  swap(t.data, n)
+  while h >= 0:
+    var nxt = n[h].next
+    let eh = n[h].hcode
+    if isFilled(eh):
+      var j: Hash = eh and maxHash(t)
+      while isFilled(t.data[j].hcode):
+        j = nextTry(j, maxHash(t))
+      rawInsert(t, t.data, move n[h].key, move n[h].val, n[h].hcode, j)
+    h = nxt
+
+template forAllOrderedPairs(yieldStmt: untyped) {.dirty.} =
+  if t.counter > 0:
+    var h = t.first
+    while h >= 0:
+      var nxt = t.data[h].next
+      if isFilled(t.data[h].hcode):
+        yieldStmt
+      h = nxt
+
+# ----------------------------------------------------------------------
+
+proc initOrderedTable*[A, B](initialSize = defaultInitialSize): OrderedTable[A, B] =
+  ## Creates a new ordered hash table that is empty.
+  ##
+  ## Starting from Nim v0.20, tables are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## See also:
+  ## * `toOrderedTable proc<#toOrderedTable,openArray[]>`_
+  ## * `newOrderedTable proc<#newOrderedTable>`_ for creating an
+  ##   `OrderedTableRef`
+  runnableExamples:
+    let
+      a = initOrderedTable[int, string]()
+      b = initOrderedTable[char, seq[int]]()
+  result = default(OrderedTable[A, B])
+  initImpl(result, initialSize)
+
+proc `[]=`*[A, B](t: var OrderedTable[A, B], key: A, val: sink B) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTable[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTable[A,B],A,B>`_
+  ## * `del proc<#del,OrderedTable[A,B],A>`_ for removing a key from the table
+  runnableExamples:
+    var a = initOrderedTable[char, int]()
+    a['x'] = 7
+    a['y'] = 33
+    doAssert a == {'x': 7, 'y': 33}.toOrderedTable
+
+  putImpl(enlarge)
+
+proc toOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTable[A, B] =
+  ## Creates a new ordered hash table that contains the given `pairs`.
+  ##
+  ## `pairs` is a container consisting of `(key, value)` tuples.
+  ##
+  ## See also:
+  ## * `initOrderedTable proc<#initOrderedTable>`_
+  ## * `newOrderedTable proc<#newOrderedTable,openArray[]>`_ for an
+  ##   `OrderedTableRef` version
+  runnableExamples:
+    let a = [('a', 5), ('b', 9)]
+    let b = toOrderedTable(a)
+    assert b == {'a': 5, 'b': 9}.toOrderedTable
+
+  result = initOrderedTable[A, B](pairs.len)
+  for key, val in items(pairs): result[key] = val
+
+proc `[]`*[A, B](t: OrderedTable[A, B], key: A): lent B =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## If `key` is not in `t`, the  `KeyError` exception is raised.
+  ## One can check with `hasKey proc<#hasKey,OrderedTable[A,B],A>`_ whether
+  ## the key exists.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,OrderedTable[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_ for checking if a
+  ##   key is in the table
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert a['a'] == 5
+    doAssertRaises(KeyError):
+      echo a['z']
+
+  get(t, key)
+
+proc `[]`*[A, B](t: var OrderedTable[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]`. The value can be modified.
+  ##
+  ## If `key` is not in `t`, the `KeyError` exception is raised.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,OrderedTable[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_ for checking if a
+  ##   key is in the table
+  get(t, key)
+
+proc hasKey*[A, B](t: OrderedTable[A, B], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,OrderedTable[A,B],A>`_ for use with the `in`
+  ##   operator
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert a.hasKey('a') == true
+    doAssert a.hasKey('z') == false
+
+  var hc: Hash = default(Hash)
+  result = rawGet(t, key, hc) >= 0
+
+proc contains*[A, B](t: OrderedTable[A, B], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,OrderedTable[A,B],A>`_ for use with
+  ## the `in` operator.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert 'b' in a == true
+    doAssert a.contains('z') == false
+
+  return hasKey[A, B](t, key)
+
+proc hasKeyOrPut*[A, B](t: var OrderedTable[A, B], key: A, val: B): bool =
+  ## Returns true if `key` is in the table, otherwise inserts `value`.
+  ##
+  ## See also:
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.toOrderedTable
+    if a.hasKeyOrPut('a', 50):
+      a['a'] = 99
+    if a.hasKeyOrPut('z', 50):
+      a['z'] = 99
+    doAssert a == {'a': 99, 'b': 9, 'z': 50}.toOrderedTable
+
+  hasKeyOrPutImpl(enlarge)
+
+proc getOrDefault*[A, B](t: OrderedTable[A, B], key: A): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## default initialization value for type `B` is returned (e.g. 0 for any
+  ## integer type).
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTable[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTable[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert a.getOrDefault('a') == 5
+    doAssert a.getOrDefault('z') == 0
+  result = default(B)
+  getOrDefaultImpl(t, key)
+
+proc getOrDefault*[A, B](t: OrderedTable[A, B], key: A, default: B): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise, `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTable[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTable[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert a.getOrDefault('a', 99) == 5
+    doAssert a.getOrDefault('z', 99) == 99
+  result = default(B)
+  getOrDefaultImpl(t, key, default)
+
+proc mgetOrPut*[A, B](t: var OrderedTable[A, B], key: A, val: B): var B =
+  ## Retrieves value at `t[key]` or puts `val` if not present, either way
+  ## returning a value which can be modified.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTable[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTable[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTable[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTable[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert a.mgetOrPut('a', 99) == 5
+    doAssert a.mgetOrPut('z', 99) == 99
+    doAssert a == {'a': 5, 'b': 9, 'z': 99}.toOrderedTable
+
+  mgetOrPutImpl(enlarge)
+
+proc mgetOrPut*[A, B](t: var OrderedTable[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]` or puts the
+  ## default initialization value for type `B` (e.g. 0 for any
+  ## integer type).
+  runnableExamples:
+    var a = {'a': 5}.toOrderedTable
+    doAssert a.mgetOrPut('a') == 5
+    a.mgetOrPut('z').inc
+    doAssert a == {'a': 5, 'z': 1}.toOrderedTable
+
+  mgetOrPutImpl(enlarge)
+
+proc len*[A, B](t: OrderedTable[A, B]): int {.inline.} =
+  ## Returns the number of keys in `t`.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.toOrderedTable
+    doAssert len(a) == 2
+
+  result = t.counter
+
+proc add*[A, B](t: var OrderedTable[A, B], key: A, val: sink B) {.deprecated:
+    "Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
+  ## Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
+  ##
+  ## **This can introduce duplicate keys into the table!**
+  ##
+  ## Use `[]= proc<#[]=,OrderedTable[A,B],A,sinkB>`_ for inserting a new
+  ## (key, value) pair in the table without introducing duplicates.
+  addImpl(enlarge)
+
+proc del*[A, B](t: var OrderedTable[A, B], key: A) =
+  ## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
+  ##
+  ## O(n) complexity.
+  ##
+  ## See also:
+  ## * `pop proc<#pop,OrderedTable[A,B],A,B>`_
+  ## * `clear proc<#clear,OrderedTable[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.toOrderedTable
+    a.del('a')
+    doAssert a == {'b': 9, 'c': 13}.toOrderedTable
+    a.del('z')
+    doAssert a == {'b': 9, 'c': 13}.toOrderedTable
+
+  if t.counter == 0: return
+  var n: OrderedKeyValuePairSeq[A, B]
+  newSeq(n, len(t.data))
+  var h = t.first
+  t.first = -1
+  t.last = -1
+  swap(t.data, n)
+  let hc = genHash(key)
+  while h >= 0:
+    var nxt = n[h].next
+    if isFilled(n[h].hcode):
+      if n[h].hcode == hc and n[h].key == key:
+        dec t.counter
+      else:
+        var j = -1 - rawGetKnownHC(t, n[h].key, n[h].hcode)
+        rawInsert(t, t.data, move n[h].key, move n[h].val, n[h].hcode, j)
+    h = nxt
+
+proc pop*[A, B](t: var OrderedTable[A, B], key: A, val: var B): bool {.since: (1, 1).} =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## O(n) complexity.
+  ##
+  ## See also:
+  ## * `del proc<#del,OrderedTable[A,B],A>`_
+  ## * `clear proc<#clear,OrderedTable[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var
+      a = {'c': 5, 'b': 9, 'a': 13}.toOrderedTable
+      i: int
+    doAssert a.pop('b', i) == true
+    doAssert a == {'c': 5, 'a': 13}.toOrderedTable
+    doAssert i == 9
+    i = 0
+    doAssert a.pop('z', i) == false
+    doAssert a == {'c': 5, 'a': 13}.toOrderedTable
+    doAssert i == 0
+
+  var hc: Hash
+  var index = rawGet(t, key, hc)
+  result = index >= 0
+  if result:
+    val = move(t.data[index].val)
+    del(t, key)
+
+proc clear*[A, B](t: var OrderedTable[A, B]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,OrderedTable[A,B],A>`_
+  ## * `pop proc<#pop,OrderedTable[A,B],A,B>`_
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.toOrderedTable
+    doAssert len(a) == 3
+    clear(a)
+    doAssert len(a) == 0
+
+  clearImpl()
+  t.first = -1
+  t.last = -1
+
+proc sort*[A, B](t: var OrderedTable[A, B], cmp: proc (x, y: (A, B)): int,
+    order = SortOrder.Ascending) {.effectsOf: cmp.} =
+  ## Sorts `t` according to the function `cmp`.
+  ##
+  ## This modifies the internal list
+  ## that kept the insertion order, so insertion order is lost after this
+  ## call but key lookup and insertions remain possible after `sort` (in
+  ## contrast to the `sort proc<#sort,CountTable[A]>`_ for count tables).
+  runnableExamples:
+    import std/[algorithm]
+    var a = initOrderedTable[char, int]()
+    for i, c in "cab":
+      a[c] = 10*i
+    doAssert a == {'c': 0, 'a': 10, 'b': 20}.toOrderedTable
+    a.sort(system.cmp)
+    doAssert a == {'a': 10, 'b': 20, 'c': 0}.toOrderedTable
+    a.sort(system.cmp, order = SortOrder.Descending)
+    doAssert a == {'c': 0, 'b': 20, 'a': 10}.toOrderedTable
+
+  var list = t.first
+  var
+    p, q, e, tail, oldhead: int
+    nmerges, psize, qsize, i: int
+  if t.counter == 0: return
+  var insize = 1
+  while true:
+    p = list; oldhead = list
+    list = -1; tail = -1; nmerges = 0
+    while p >= 0:
+      inc(nmerges)
+      q = p
+      psize = 0
+      i = 0
+      while i < insize:
+        inc(psize)
+        q = t.data[q].next
+        if q < 0: break
+        inc(i)
+      qsize = insize
+      while psize > 0 or (qsize > 0 and q >= 0):
+        if psize == 0:
+          e = q; q = t.data[q].next; dec(qsize)
+        elif qsize == 0 or q < 0:
+          e = p; p = t.data[p].next; dec(psize)
+        elif cmp((t.data[p].key, t.data[p].val),
+                 (t.data[q].key, t.data[q].val)) * order <= 0:
+          e = p; p = t.data[p].next; dec(psize)
+        else:
+          e = q; q = t.data[q].next; dec(qsize)
+        if tail >= 0: t.data[tail].next = e
+        else: list = e
+        tail = e
+      p = q
+    t.data[tail].next = -1
+    if nmerges <= 1: break
+    insize = insize * 2
+  t.first = list
+  t.last = tail
+
+proc `$`*[A, B](t: OrderedTable[A, B]): string =
+  ## The `$` operator for ordered hash tables. Used internally when calling
+  ## `echo` on a table.
+  dollarImpl()
+
+proc `==`*[A, B](s, t: OrderedTable[A, B]): bool =
+  ## The `==` operator for ordered hash tables. Returns `true` if both the
+  ## content and the order are equal.
+  runnableExamples:
+    let
+      a = {'a': 5, 'b': 9, 'c': 13}.toOrderedTable
+      b = {'b': 9, 'c': 13, 'a': 5}.toOrderedTable
+    doAssert a != b
+
+  if s.counter != t.counter:
+    return false
+  if s.counter == 0 and t.counter == 0:
+    return true
+  var ht = t.first
+  var hs = s.first
+  while ht >= 0 and hs >= 0:
+    var nxtt = t.data[ht].next
+    var nxts = s.data[hs].next
+    if isFilled(t.data[ht].hcode) and isFilled(s.data[hs].hcode):
+      if (s.data[hs].key != t.data[ht].key) or (s.data[hs].val != t.data[ht].val):
+        return false
+    ht = nxtt
+    hs = nxts
+  return true
+
+
+
+iterator pairs*[A, B](t: OrderedTable[A, B]): (A, B) =
+  ## Iterates over any `(key, value)` pair in the table `t` in insertion
+  ## order.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,OrderedTable[A,B]>`_
+  ## * `keys iterator<#keys.i,OrderedTable[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTable[A,B]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = {
+  ##     'o': [1, 5, 7, 9],
+  ##     'e': [2, 4, 6, 8]
+  ##     }.toOrderedTable
+  ##
+  ##   for k, v in a.pairs:
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: o
+  ##   # value: [1, 5, 7, 9]
+  ##   # key: e
+  ##   # value: [2, 4, 6, 8]
+  ##   ```
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A, B](t: var OrderedTable[A, B]): (A, var B) =
+  ## Iterates over any `(key, value)` pair in the table `t` (must be
+  ## declared as `var`) in insertion order. The values can be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTable[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,OrderedTable[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toOrderedTable
+    for k, v in a.mpairs:
+      v.add(v[0] + 10)
+    doAssert a == {'o': @[1, 5, 7, 9, 11],
+                   'e': @[2, 4, 6, 8, 12]}.toOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator keys*[A, B](t: OrderedTable[A, B]): lent A =
+  ## Iterates over any key in the table `t` in insertion order.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTable[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTable[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toOrderedTable
+    for k in a.keys:
+      a[k].add(99)
+    doAssert a == {'o': @[1, 5, 7, 9, 99],
+                   'e': @[2, 4, 6, 8, 99]}.toOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].key
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A, B](t: OrderedTable[A, B]): lent B =
+  ## Iterates over any value in the table `t` in insertion order.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTable[A,B]>`_
+  ## * `keys iterator<#keys.i,OrderedTable[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,OrderedTable[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toOrderedTable
+    for v in a.values:
+      doAssert v.len == 4
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].val
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A, B](t: var OrderedTable[A, B]): var B =
+  ## Iterates over any value in the table `t` (must be
+  ## declared as `var`) in insertion order. The values
+  ## can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,OrderedTable[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTable[A,B]>`_
+  runnableExamples:
+    var a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.toOrderedTable
+    for v in a.mvalues:
+      v.add(99)
+    doAssert a == {'o': @[1, 5, 7, 9, 99],
+                   'e': @[2, 4, 6, 8, 99]}.toOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].val
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+# ---------------------------------------------------------------------------
+# --------------------------- OrderedTableRef -------------------------------
+# ---------------------------------------------------------------------------
+
+proc newOrderedTable*[A, B](initialSize = defaultInitialSize): OrderedTableRef[A, B] =
+  ## Creates a new ordered ref hash table that is empty.
+  ##
+  ## See also:
+  ## * `newOrderedTable proc<#newOrderedTable,openArray[]>`_ for creating
+  ##   an `OrderedTableRef` from a collection of `(key, value)` pairs
+  ## * `initOrderedTable proc<#initOrderedTable>`_ for creating an
+  ##   `OrderedTable`
+  runnableExamples:
+    let
+      a = newOrderedTable[int, string]()
+      b = newOrderedTable[char, seq[int]]()
+  new(result)
+  {.noSideEffect.}:
+    result[] = initOrderedTable[A, B](initialSize)
+
+proc newOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTableRef[A, B] =
+  ## Creates a new ordered ref hash table that contains the given `pairs`.
+  ##
+  ## `pairs` is a container consisting of `(key, value)` tuples.
+  ##
+  ## See also:
+  ## * `newOrderedTable proc<#newOrderedTable>`_
+  ## * `toOrderedTable proc<#toOrderedTable,openArray[]>`_ for an
+  ##   `OrderedTable` version
+  runnableExamples:
+    let a = [('a', 5), ('b', 9)]
+    let b = newOrderedTable(a)
+    assert b == {'a': 5, 'b': 9}.newOrderedTable
+
+  result = newOrderedTable[A, B](pairs.len)
+  {.noSideEffect.}:
+    for key, val in items(pairs): result[key] = val
+
+
+proc `[]`*[A, B](t: OrderedTableRef[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]`.
+  ##
+  ## If `key` is not in `t`, the  `KeyError` exception is raised.
+  ## One can check with `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_ whether
+  ## the key exists.
+  ##
+  ## See also:
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]=,OrderedTableRef[A,B],A,sinkB>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_ for checking if
+  ##   a key is in the table
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert a['a'] == 5
+    doAssertRaises(KeyError):
+      echo a['z']
+  result = t[][key]
+
+proc `[]=`*[A, B](t: OrderedTableRef[A, B], key: A, val: sink B) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `del proc<#del,OrderedTableRef[A,B],A>`_ for removing a key from the table
+  runnableExamples:
+    var a = newOrderedTable[char, int]()
+    a['x'] = 7
+    a['y'] = 33
+    doAssert a == {'x': 7, 'y': 33}.newOrderedTable
+
+  t[][key] = val
+
+proc hasKey*[A, B](t: OrderedTableRef[A, B], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,OrderedTableRef[A,B],A>`_ for use with the `in`
+  ##   operator
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert a.hasKey('a') == true
+    doAssert a.hasKey('z') == false
+
+  result = t[].hasKey(key)
+
+proc contains*[A, B](t: OrderedTableRef[A, B], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_ for use with
+  ## the `in` operator.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert 'b' in a == true
+    doAssert a.contains('z') == false
+
+  return hasKey[A, B](t, key)
+
+proc hasKeyOrPut*[A, B](t: OrderedTableRef[A, B], key: A, val: B): bool =
+  ## Returns true if `key` is in the table, otherwise inserts `value`.
+  ##
+  ## See also:
+  ## * `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.newOrderedTable
+    if a.hasKeyOrPut('a', 50):
+      a['a'] = 99
+    if a.hasKeyOrPut('z', 50):
+      a['z'] = 99
+    doAssert a == {'a': 99, 'b': 9, 'z': 50}.newOrderedTable
+
+  result = t[].hasKeyOrPut(key, val)
+
+proc getOrDefault*[A, B](t: OrderedTableRef[A, B], key: A): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## default initialization value for type `B` is returned (e.g. 0 for any
+  ## integer type).
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert a.getOrDefault('a') == 5
+    doAssert a.getOrDefault('z') == 0
+
+  getOrDefault(t[], key)
+
+proc getOrDefault*[A, B](t: OrderedTableRef[A, B], key: A, default: B): B =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise, `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `mgetOrPut proc<#mgetOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert a.getOrDefault('a', 99) == 5
+    doAssert a.getOrDefault('z', 99) == 99
+
+  getOrDefault(t[], key, default)
+
+proc mgetOrPut*[A, B](t: OrderedTableRef[A, B], key: A, val: B): var B =
+  ## Retrieves value at `t[key]` or puts `val` if not present, either way
+  ## returning a value which can be modified.
+  ##
+  ## See also:
+  ## * `[] proc<#[],OrderedTableRef[A,B],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,OrderedTableRef[A,B],A>`_
+  ## * `hasKeyOrPut proc<#hasKeyOrPut,OrderedTableRef[A,B],A,B>`_
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A>`_ to return
+  ##   a default value (e.g. zero for int) if the key doesn't exist
+  ## * `getOrDefault proc<#getOrDefault,OrderedTableRef[A,B],A,B>`_ to return
+  ##   a custom value if the key doesn't exist
+  runnableExamples:
+    var a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert a.mgetOrPut('a', 99) == 5
+    doAssert a.mgetOrPut('z', 99) == 99
+    doAssert a == {'a': 5, 'b': 9, 'z': 99}.newOrderedTable
+
+  result = t[].mgetOrPut(key, val)
+
+proc mgetOrPut*[A, B](t: OrderedTableRef[A, B], key: A): var B =
+  ## Retrieves the value at `t[key]` or puts the
+  ## default initialization value for type `B` (e.g. 0 for any
+  ## integer type).
+  runnableExamples:
+    var a = {'a': 5}.toOrderedTable
+    doAssert a.mgetOrPut('a') == 5
+    a.mgetOrPut('z').inc
+    doAssert a == {'a': 5, 'z': 1}.toOrderedTable
+
+  t[].mgetOrPut(key)
+
+proc len*[A, B](t: OrderedTableRef[A, B]): int {.inline.} =
+  ## Returns the number of keys in `t`.
+  runnableExamples:
+    let a = {'a': 5, 'b': 9}.newOrderedTable
+    doAssert len(a) == 2
+
+  result = t.counter
+
+proc add*[A, B](t: OrderedTableRef[A, B], key: A, val: sink B) {.deprecated:
+    "Deprecated since v1.4; it was more confusing than useful, use `[]=`".} =
+  ## Puts a new `(key, value)` pair into `t` even if `t[key]` already exists.
+  ##
+  ## **This can introduce duplicate keys into the table!**
+  ##
+  ## Use `[]= proc<#[]=,OrderedTableRef[A,B],A,sinkB>`_ for inserting a new
+  ## (key, value) pair in the table without introducing duplicates.
+  t[].add(key, val)
+
+proc del*[A, B](t: OrderedTableRef[A, B], key: A) =
+  ## Deletes `key` from hash table `t`. Does nothing if the key does not exist.
+  ##
+  ## See also:
+  ## * `clear proc<#clear,OrderedTableRef[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.newOrderedTable
+    a.del('a')
+    doAssert a == {'b': 9, 'c': 13}.newOrderedTable
+    a.del('z')
+    doAssert a == {'b': 9, 'c': 13}.newOrderedTable
+
+  t[].del(key)
+
+proc pop*[A, B](t: OrderedTableRef[A, B], key: A, val: var B): bool {.since: (1, 1).} =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## See also:
+  ## * `del proc<#del,OrderedTableRef[A,B],A>`_
+  ## * `clear proc<#clear,OrderedTableRef[A,B]>`_ to empty the whole table
+  runnableExamples:
+    var
+      a = {'c': 5, 'b': 9, 'a': 13}.newOrderedTable
+      i: int
+    doAssert a.pop('b', i) == true
+    doAssert a == {'c': 5, 'a': 13}.newOrderedTable
+    doAssert i == 9
+    i = 0
+    doAssert a.pop('z', i) == false
+    doAssert a == {'c': 5, 'a': 13}.newOrderedTable
+    doAssert i == 0
+
+  pop(t[], key, val)
+
+proc clear*[A, B](t: OrderedTableRef[A, B]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,OrderedTableRef[A,B],A>`_
+  runnableExamples:
+    var a = {'a': 5, 'b': 9, 'c': 13}.newOrderedTable
+    doAssert len(a) == 3
+    clear(a)
+    doAssert len(a) == 0
+
+  clear(t[])
+
+proc sort*[A, B](t: OrderedTableRef[A, B], cmp: proc (x, y: (A, B)): int,
+    order = SortOrder.Ascending) {.effectsOf: cmp.} =
+  ## Sorts `t` according to the function `cmp`.
+  ##
+  ## This modifies the internal list
+  ## that kept the insertion order, so insertion order is lost after this
+  ## call but key lookup and insertions remain possible after `sort` (in
+  ## contrast to the `sort proc<#sort,CountTableRef[A]>`_ for count tables).
+  runnableExamples:
+    import std/[algorithm]
+    var a = newOrderedTable[char, int]()
+    for i, c in "cab":
+      a[c] = 10*i
+    doAssert a == {'c': 0, 'a': 10, 'b': 20}.newOrderedTable
+    a.sort(system.cmp)
+    doAssert a == {'a': 10, 'b': 20, 'c': 0}.newOrderedTable
+    a.sort(system.cmp, order = SortOrder.Descending)
+    doAssert a == {'c': 0, 'b': 20, 'a': 10}.newOrderedTable
+
+  t[].sort(cmp, order = order)
+
+proc `$`*[A, B](t: OrderedTableRef[A, B]): string =
+  ## The `$` operator for hash tables. Used internally when calling `echo`
+  ## on a table.
+  dollarImpl()
+
+proc `==`*[A, B](s, t: OrderedTableRef[A, B]): bool =
+  ## The `==` operator for ordered hash tables. Returns true if either both
+  ## tables are `nil`, or neither is `nil` and the content and the order of
+  ## both are equal.
+  runnableExamples:
+    let
+      a = {'a': 5, 'b': 9, 'c': 13}.newOrderedTable
+      b = {'b': 9, 'c': 13, 'a': 5}.newOrderedTable
+    doAssert a != b
+
+  if isNil(s): result = isNil(t)
+  elif isNil(t): result = false
+  else: result = s[] == t[]
+
+
+
+iterator pairs*[A, B](t: OrderedTableRef[A, B]): (A, B) =
+  ## Iterates over any `(key, value)` pair in the table `t` in insertion
+  ## order.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,OrderedTableRef[A,B]>`_
+  ## * `keys iterator<#keys.i,OrderedTableRef[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTableRef[A,B]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = {
+  ##     'o': [1, 5, 7, 9],
+  ##     'e': [2, 4, 6, 8]
+  ##     }.newOrderedTable
+  ##
+  ##   for k, v in a.pairs:
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: o
+  ##   # value: [1, 5, 7, 9]
+  ##   # key: e
+  ##   # value: [2, 4, 6, 8]
+  ##   ```
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A, B](t: OrderedTableRef[A, B]): (A, var B) =
+  ## Iterates over any `(key, value)` pair in the table `t` in insertion
+  ## order. The values can be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTableRef[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,OrderedTableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newOrderedTable
+    for k, v in a.mpairs:
+      v.add(v[0] + 10)
+    doAssert a == {'o': @[1, 5, 7, 9, 11],
+                   'e': @[2, 4, 6, 8, 12]}.newOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield (t.data[h].key, t.data[h].val)
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator keys*[A, B](t: OrderedTableRef[A, B]): lent A =
+  ## Iterates over any key in the table `t` in insertion order.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTableRef[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newOrderedTable
+    for k in a.keys:
+      a[k].add(99)
+    doAssert a == {'o': @[1, 5, 7, 9, 99], 'e': @[2, 4, 6, 8,
+        99]}.newOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].key
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A, B](t: OrderedTableRef[A, B]): lent B =
+  ## Iterates over any value in the table `t` in insertion order.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,OrderedTableRef[A,B]>`_
+  ## * `keys iterator<#keys.i,OrderedTableRef[A,B]>`_
+  ## * `mvalues iterator<#mvalues.i,OrderedTableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newOrderedTable
+    for v in a.values:
+      doAssert v.len == 4
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].val
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A, B](t: OrderedTableRef[A, B]): var B =
+  ## Iterates over any value in the table `t` in insertion order. The values
+  ## can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,OrderedTableRef[A,B]>`_
+  ## * `values iterator<#values.i,OrderedTableRef[A,B]>`_
+  runnableExamples:
+    let a = {
+      'o': @[1, 5, 7, 9],
+      'e': @[2, 4, 6, 8]
+      }.newOrderedTable
+    for v in a.mvalues:
+      v.add(99)
+    doAssert a == {'o': @[1, 5, 7, 9, 99],
+                   'e': @[2, 4, 6, 8, 99]}.newOrderedTable
+
+  let L = len(t)
+  forAllOrderedPairs:
+    yield t.data[h].val
+    assert(len(t) == L, "the length of the table changed while iterating over it")
+
+
+
+
+
+
+
+# -------------------------------------------------------------------------
+# ------------------------------ CountTable -------------------------------
+# -------------------------------------------------------------------------
+
+type
+  CountTable*[A] = object
+    ## Hash table that counts the number of each key.
+    ##
+    ## For creating an empty CountTable, use `initCountTable proc
+    ## <#initCountTable>`_.
+    data: seq[tuple[key: A, val: int]]
+    counter: int
+    isSorted: bool
+  CountTableRef*[A] = ref CountTable[A] ## Ref version of
+    ## `CountTable<#CountTable>`_.
+    ##
+    ## For creating a new empty CountTableRef, use `newCountTable proc
+    ## <#newCountTable>`_.
+
+
+# ------------------------------ helpers ---------------------------------
+
+proc ctRawInsert[A](t: CountTable[A], data: var seq[tuple[key: A, val: int]],
+                  key: A, val: int) =
+  var h: Hash = hash(key) and high(data)
+  while data[h].val != 0: h = nextTry(h, high(data))
+  data[h].key = key
+  data[h].val = val
+
+proc enlarge[A](t: var CountTable[A]) =
+  var n: seq[tuple[key: A, val: int]]
+  newSeq(n, len(t.data) * growthFactor)
+  for i in countup(0, high(t.data)):
+    if t.data[i].val != 0: ctRawInsert(t, n, move t.data[i].key, move t.data[i].val)
+  swap(t.data, n)
+
+proc rawGet[A](t: CountTable[A], key: A): int =
+  if t.data.len == 0:
+    return -1
+  var h: Hash = hash(key) and high(t.data) # start with real hash value
+  while t.data[h].val != 0:
+    if t.data[h].key == key: return h
+    h = nextTry(h, high(t.data))
+  result = -1 - h # < 0 => MISSING; insert idx = -1 - result
+
+template ctget(t, key, default: untyped): untyped =
+  var index = rawGet(t, key)
+  result = if index >= 0: t.data[index].val else: default
+
+proc inc*[A](t: var CountTable[A], key: A, val = 1)
+
+# ----------------------------------------------------------------------
+
+proc initCountTable*[A](initialSize = defaultInitialSize): CountTable[A] =
+  ## Creates a new count table that is empty.
+  ##
+  ## Starting from Nim v0.20, tables are initialized by default and it is
+  ## not necessary to call this function explicitly.
+  ##
+  ## See also:
+  ## * `toCountTable proc<#toCountTable,openArray[A]>`_
+  ## * `newCountTable proc<#newCountTable>`_ for creating a
+  ##   `CountTableRef`
+  result = default(CountTable[A])
+  initImpl(result, initialSize)
+
+proc toCountTable*[A](keys: openArray[A]): CountTable[A] =
+  ## Creates a new count table with every member of a container `keys`
+  ## having a count of how many times it occurs in that container.
+  result = initCountTable[A](keys.len)
+  for key in items(keys): result.inc(key)
+
+proc `[]`*[A](t: CountTable[A], key: A): int =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise `0` is returned.
+  ##
+  ## See also:
+  ## * `getOrDefault<#getOrDefault,CountTable[A],A,int>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `[]= proc<#[]%3D,CountTable[A],A,int>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,CountTable[A],A>`_ for checking if a key
+  ##   is in the table
+  assert(not t.isSorted, "CountTable must not be used after sorting")
+  ctget(t, key, 0)
+
+template cntMakeEmpty(i) = t.data[i].val = 0
+template cntCellEmpty(i) = t.data[i].val == 0
+template cntCellHash(i)  = hash(t.data[i].key)
+
+proc `[]=`*[A](t: var CountTable[A], key: A, val: int) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],CountTable[A],A>`_ for retrieving a value of a key
+  ## * `inc proc<#inc,CountTable[A],A,int>`_ for incrementing a
+  ##   value of a key
+  assert(not t.isSorted, "CountTable must not be used after sorting")
+  assert val >= 0
+  if val == 0:
+    delImplNoHCode(cntMakeEmpty, cntCellEmpty, cntCellHash)
+  else:
+    let h = rawGet(t, key)
+    if h >= 0:
+      t.data[h].val = val
+    else:
+      insertImpl()
+
+proc inc*[A](t: var CountTable[A], key: A, val = 1) =
+  ## Increments `t[key]` by `val` (default: 1).
+  runnableExamples:
+    var a = toCountTable("aab")
+    a.inc('a')
+    a.inc('b', 10)
+    doAssert a == toCountTable("aaabbbbbbbbbbb")
+
+  assert(not t.isSorted, "CountTable must not be used after sorting")
+  var index = rawGet(t, key)
+  if index >= 0:
+    inc(t.data[index].val, val)
+    if t.data[index].val == 0:
+      delImplIdx(t, index, cntMakeEmpty, cntCellEmpty, cntCellHash)
+  else:
+    if val != 0:
+      insertImpl()
+
+proc len*[A](t: CountTable[A]): int =
+  ## Returns the number of keys in `t`.
+  result = t.counter
+
+proc smallest*[A](t: CountTable[A]): tuple[key: A, val: int] =
+  ## Returns the `(key, value)` pair with the smallest `val`. Efficiency: O(n)
+  ##
+  ## See also:
+  ## * `largest proc<#largest,CountTable[A]>`_
+  assert t.len > 0, "counttable is empty"
+  var minIdx = -1
+  for h in 0 .. high(t.data):
+    if t.data[h].val > 0 and (minIdx == -1 or t.data[minIdx].val > t.data[h].val):
+      minIdx = h
+  result.key = t.data[minIdx].key
+  result.val = t.data[minIdx].val
+
+proc largest*[A](t: CountTable[A]): tuple[key: A, val: int] =
+  ## Returns the `(key, value)` pair with the largest `val`. Efficiency: O(n)
+  ##
+  ## See also:
+  ## * `smallest proc<#smallest,CountTable[A]>`_
+  assert t.len > 0, "counttable is empty"
+  var maxIdx = 0
+  for h in 1 .. high(t.data):
+    if t.data[maxIdx].val < t.data[h].val: maxIdx = h
+  result.key = t.data[maxIdx].key
+  result.val = t.data[maxIdx].val
+
+proc hasKey*[A](t: CountTable[A], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,CountTable[A],A>`_ for use with the `in`
+  ##   operator
+  ## * `[] proc<#[],CountTable[A],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,CountTable[A],A,int>`_ to return
+  ##   a custom value if the key doesn't exist
+  assert(not t.isSorted, "CountTable must not be used after sorting")
+  result = rawGet(t, key) >= 0
+
+proc contains*[A](t: CountTable[A], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,CountTable[A],A>`_ for use with
+  ## the `in` operator.
+  return hasKey[A](t, key)
+
+proc getOrDefault*[A](t: CountTable[A], key: A; default: int = 0): int =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## integer value of `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],CountTable[A],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,CountTable[A],A>`_ for checking if a key
+  ##   is in the table
+  ctget(t, key, default)
+
+proc del*[A](t: var CountTable[A], key: A) {.since: (1, 1).} =
+  ## Deletes `key` from table `t`. Does nothing if the key does not exist.
+  ##
+  ## See also:
+  ## * `pop proc<#pop,CountTable[A],A,int>`_
+  ## * `clear proc<#clear,CountTable[A]>`_ to empty the whole table
+  runnableExamples:
+    var a = toCountTable("aabbbccccc")
+    a.del('b')
+    assert a == toCountTable("aaccccc")
+    a.del('b')
+    assert a == toCountTable("aaccccc")
+    a.del('c')
+    assert a == toCountTable("aa")
+
+  delImplNoHCode(cntMakeEmpty, cntCellEmpty, cntCellHash)
+
+proc pop*[A](t: var CountTable[A], key: A, val: var int): bool {.since: (1, 1).} =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## See also:
+  ## * `del proc<#del,CountTable[A],A>`_
+  ## * `clear proc<#clear,CountTable[A]>`_ to empty the whole table
+  runnableExamples:
+    var a = toCountTable("aabbbccccc")
+    var i = 0
+    assert a.pop('b', i)
+    assert i == 3
+    i = 99
+    assert not a.pop('b', i)
+    assert i == 99
+
+  var index = rawGet(t, key)
+  result = index >= 0
+  if result:
+    val = move(t.data[index].val)
+    delImplIdx(t, index, cntMakeEmpty, cntCellEmpty, cntCellHash)
+
+proc clear*[A](t: var CountTable[A]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,CountTable[A],A>`_
+  ## * `pop proc<#pop,CountTable[A],A,int>`_
+  clearImpl()
+  t.isSorted = false
+
+func ctCmp[T](a, b: tuple[key: T, val: int]): int =
+  result = system.cmp(a.val, b.val)
+
+proc sort*[A](t: var CountTable[A], order = SortOrder.Descending) =
+  ## Sorts the count table so that, by default, the entry with the
+  ## highest counter comes first.
+  ##
+  ## .. warning:: This is destructive! Once sorted, you must not modify `t` afterwards!
+  ##
+  ## You can use the iterators `pairs<#pairs.i,CountTable[A]>`_,
+  ## `keys<#keys.i,CountTable[A]>`_, and `values<#values.i,CountTable[A]>`_
+  ## to iterate over `t` in the sorted order.
+  runnableExamples:
+    import std/[algorithm, sequtils]
+    var a = toCountTable("abracadabra")
+    doAssert a == "aaaaabbrrcd".toCountTable
+    a.sort()
+    doAssert toSeq(a.values) == @[5, 2, 2, 1, 1]
+    a.sort(SortOrder.Ascending)
+    doAssert toSeq(a.values) == @[1, 1, 2, 2, 5]
+
+  t.data.sort(cmp = ctCmp, order = order)
+  t.isSorted = true
+
+proc merge*[A](s: var CountTable[A], t: CountTable[A]) =
+  ## Merges the second table into the first one (must be declared as `var`).
+  runnableExamples:
+    var a = toCountTable("aaabbc")
+    let b = toCountTable("bcc")
+    a.merge(b)
+    doAssert a == toCountTable("aaabbbccc")
+
+  assert(not s.isSorted, "CountTable must not be used after sorting")
+  for key, value in t:
+    s.inc(key, value)
+
+when (NimMajor, NimMinor) <= (1, 0):
+  proc merge*[A](s, t: CountTable[A]): CountTable[A] =
+    ## Merges the two tables into a new one.
+    runnableExamples:
+      let
+        a = toCountTable("aaabbc")
+        b = toCountTable("bcc")
+      doAssert merge(a, b) == toCountTable("aaabbbccc")
+
+    result = initCountTable[A](nextPowerOfTwo(max(s.len, t.len)))
+    for table in @[s, t]:
+      for key, value in table:
+        result.inc(key, value)
+
+proc `$`*[A](t: CountTable[A]): string =
+  ## The `$` operator for count tables. Used internally when calling `echo`
+  ## on a table.
+  dollarImpl()
+
+proc `==`*[A](s, t: CountTable[A]): bool =
+  ## The `==` operator for count tables. Returns `true` if both tables
+  ## contain the same keys with the same count. Insert order does not matter.
+  equalsImpl(s, t)
+
+
+iterator pairs*[A](t: CountTable[A]): (A, int) =
+  ## Iterates over any `(key, value)` pair in the table `t`.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,CountTable[A]>`_
+  ## * `keys iterator<#keys.i,CountTable[A]>`_
+  ## * `values iterator<#values.i,CountTable[A]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = toCountTable("abracadabra")
+  ##
+  ##   for k, v in pairs(a):
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: a
+  ##   # value: 5
+  ##   # key: b
+  ##   # value: 2
+  ##   # key: c
+  ##   # value: 1
+  ##   # key: d
+  ##   # value: 1
+  ##   # key: r
+  ##   # value: 2
+  ##   ```
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A](t: var CountTable[A]): (A, var int) =
+  ## Iterates over any `(key, value)` pair in the table `t` (must be
+  ## declared as `var`). The values can be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTable[A]>`_
+  ## * `mvalues iterator<#mvalues.i,CountTable[A]>`_
+  runnableExamples:
+    var a = toCountTable("abracadabra")
+    for k, v in mpairs(a):
+      v = 2
+    doAssert a == toCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator keys*[A](t: CountTable[A]): lent A =
+  ## Iterates over any key in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTable[A]>`_
+  ## * `values iterator<#values.i,CountTable[A]>`_
+  runnableExamples:
+    var a = toCountTable("abracadabra")
+    for k in keys(a):
+      a[k] = 2
+    doAssert a == toCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].key
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A](t: CountTable[A]): int =
+  ## Iterates over any value in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTable[A]>`_
+  ## * `keys iterator<#keys.i,CountTable[A]>`_
+  ## * `mvalues iterator<#mvalues.i,CountTable[A]>`_
+  runnableExamples:
+    let a = toCountTable("abracadabra")
+    for v in values(a):
+      assert v < 10
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A](t: var CountTable[A]): var int =
+  ## Iterates over any value in the table `t` (must be
+  ## declared as `var`). The values can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,CountTable[A]>`_
+  ## * `values iterator<#values.i,CountTable[A]>`_
+  runnableExamples:
+    var a = toCountTable("abracadabra")
+    for v in mvalues(a):
+      v = 2
+    doAssert a == toCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+
+
+
+
+
+
+# ---------------------------------------------------------------------------
+# ---------------------------- CountTableRef --------------------------------
+# ---------------------------------------------------------------------------
+
+proc inc*[A](t: CountTableRef[A], key: A, val = 1)
+
+proc newCountTable*[A](initialSize = defaultInitialSize): CountTableRef[A] =
+  ## Creates a new ref count table that is empty.
+  ##
+  ## See also:
+  ## * `newCountTable proc<#newCountTable,openArray[A]>`_ for creating
+  ##   a `CountTableRef` from a collection
+  ## * `initCountTable proc<#initCountTable>`_ for creating a
+  ##   `CountTable`
+  new(result)
+  {.noSideEffect.}:
+    result[] = initCountTable[A](initialSize)
+
+proc newCountTable*[A](keys: openArray[A]): CountTableRef[A] =
+  ## Creates a new ref count table with every member of a container `keys`
+  ## having a count of how many times it occurs in that container.
+  result = newCountTable[A](keys.len)
+  {.noSideEffect.}:
+    for key in items(keys): result.inc(key)
+
+proc `[]`*[A](t: CountTableRef[A], key: A): int =
+  ## Retrieves the value at `t[key]` if `key` is in `t`.
+  ## Otherwise `0` is returned.
+  ##
+  ## See also:
+  ## * `getOrDefault<#getOrDefault,CountTableRef[A],A,int>`_ to return
+  ##   a custom value if the key doesn't exist
+  ## * `inc proc<#inc,CountTableRef[A],A,int>`_ to inc even if missing
+  ## * `[]= proc<#[]%3D,CountTableRef[A],A,int>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc<#hasKey,CountTableRef[A],A>`_ for checking if a key
+  ##   is in the table
+  result = t[][key]
+
+proc `[]=`*[A](t: CountTableRef[A], key: A, val: int) =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc<#[],CountTableRef[A],A>`_ for retrieving a value of a key
+  ## * `inc proc<#inc,CountTableRef[A],A,int>`_ for incrementing a
+  ##   value of a key
+  assert val > 0
+  {.noSideEffect.}:
+    t[][key] = val
+
+proc inc*[A](t: CountTableRef[A], key: A, val = 1) =
+  ## Increments `t[key]` by `val` (default: 1).
+  runnableExamples:
+    var a = newCountTable("aab")
+    a.inc('a')
+    a.inc('b', 10)
+    doAssert a == newCountTable("aaabbbbbbbbbbb")
+  {.noSideEffect.}:
+    t[].inc(key, val)
+
+proc smallest*[A](t: CountTableRef[A]): tuple[key: A, val: int] =
+  ## Returns the `(key, value)` pair with the smallest `val`. Efficiency: O(n)
+  ##
+  ## See also:
+  ## * `largest proc<#largest,CountTableRef[A]>`_
+  t[].smallest
+
+proc largest*[A](t: CountTableRef[A]): tuple[key: A, val: int] =
+  ## Returns the `(key, value)` pair with the largest `val`. Efficiency: O(n)
+  ##
+  ## See also:
+  ## * `smallest proc<#smallest,CountTable[A]>`_
+  t[].largest
+
+proc hasKey*[A](t: CountTableRef[A], key: A): bool =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `contains proc<#contains,CountTableRef[A],A>`_ for use with the `in`
+  ##   operator
+  ## * `[] proc<#[],CountTableRef[A],A>`_ for retrieving a value of a key
+  ## * `getOrDefault proc<#getOrDefault,CountTableRef[A],A,int>`_ to return
+  ##   a custom value if the key doesn't exist
+  result = t[].hasKey(key)
+
+proc contains*[A](t: CountTableRef[A], key: A): bool =
+  ## Alias of `hasKey proc<#hasKey,CountTableRef[A],A>`_ for use with
+  ## the `in` operator.
+  return hasKey[A](t, key)
+
+proc getOrDefault*[A](t: CountTableRef[A], key: A, default: int): int =
+  ## Retrieves the value at `t[key]` if `key` is in `t`. Otherwise, the
+  ## integer value of `default` is returned.
+  ##
+  ## See also:
+  ## * `[] proc<#[],CountTableRef[A],A>`_ for retrieving a value of a key
+  ## * `hasKey proc<#hasKey,CountTableRef[A],A>`_ for checking if a key
+  ##   is in the table
+  result = t[].getOrDefault(key, default)
+
+proc len*[A](t: CountTableRef[A]): int =
+  ## Returns the number of keys in `t`.
+  result = t.counter
+
+proc del*[A](t: CountTableRef[A], key: A) {.since: (1, 1).} =
+  ## Deletes `key` from table `t`. Does nothing if the key does not exist.
+  ##
+  ## See also:
+  ## * `pop proc<#pop,CountTableRef[A],A,int>`_
+  ## * `clear proc<#clear,CountTableRef[A]>`_ to empty the whole table
+  del(t[], key)
+
+proc pop*[A](t: CountTableRef[A], key: A, val: var int): bool {.since: (1, 1).} =
+  ## Deletes the `key` from the table.
+  ## Returns `true`, if the `key` existed, and sets `val` to the
+  ## mapping of the key. Otherwise, returns `false`, and the `val` is
+  ## unchanged.
+  ##
+  ## See also:
+  ## * `del proc<#del,CountTableRef[A],A>`_
+  ## * `clear proc<#clear,CountTableRef[A]>`_ to empty the whole table
+  pop(t[], key, val)
+
+proc clear*[A](t: CountTableRef[A]) =
+  ## Resets the table so that it is empty.
+  ##
+  ## See also:
+  ## * `del proc<#del,CountTableRef[A],A>`_
+  ## * `pop proc<#pop,CountTableRef[A],A,int>`_
+  clear(t[])
+
+proc sort*[A](t: CountTableRef[A], order = SortOrder.Descending) =
+  ## Sorts the count table so that, by default, the entry with the
+  ## highest counter comes first.
+  ##
+  ## **This is destructive! You must not modify `t` afterwards!**
+  ##
+  ## You can use the iterators `pairs<#pairs.i,CountTableRef[A]>`_,
+  ## `keys<#keys.i,CountTableRef[A]>`_, and `values<#values.i,CountTableRef[A]>`_
+  ## to iterate over `t` in the sorted order.
+  t[].sort(order = order)
+
+proc merge*[A](s, t: CountTableRef[A]) =
+  ## Merges the second table into the first one.
+  runnableExamples:
+    let
+      a = newCountTable("aaabbc")
+      b = newCountTable("bcc")
+    a.merge(b)
+    doAssert a == newCountTable("aaabbbccc")
+
+  s[].merge(t[])
+
+proc `$`*[A](t: CountTableRef[A]): string =
+  ## The `$` operator for count tables. Used internally when calling `echo`
+  ## on a table.
+  dollarImpl()
+
+proc `==`*[A](s, t: CountTableRef[A]): bool =
+  ## The `==` operator for count tables. Returns `true` if either both tables
+  ## are `nil`, or neither is `nil` and both contain the same keys with the same
+  ## count. Insert order does not matter.
+  if isNil(s): result = isNil(t)
+  elif isNil(t): result = false
+  else: result = s[] == t[]
+
+
+iterator pairs*[A](t: CountTableRef[A]): (A, int) =
+  ## Iterates over any `(key, value)` pair in the table `t`.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,CountTableRef[A]>`_
+  ## * `keys iterator<#keys.i,CountTableRef[A]>`_
+  ## * `values iterator<#values.i,CountTableRef[A]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   let a = newCountTable("abracadabra")
+  ##
+  ##   for k, v in pairs(a):
+  ##     echo "key: ", k
+  ##     echo "value: ", v
+  ##
+  ##   # key: a
+  ##   # value: 5
+  ##   # key: b
+  ##   # value: 2
+  ##   # key: c
+  ##   # value: 1
+  ##   # key: d
+  ##   # value: 1
+  ##   # key: r
+  ##   # value: 2
+  ##   ```
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mpairs*[A](t: CountTableRef[A]): (A, var int) =
+  ## Iterates over any `(key, value)` pair in the table `t`. The values can
+  ## be modified.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTableRef[A]>`_
+  ## * `mvalues iterator<#mvalues.i,CountTableRef[A]>`_
+  runnableExamples:
+    let a = newCountTable("abracadabra")
+    for k, v in mpairs(a):
+      v = 2
+    doAssert a == newCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield (t.data[h].key, t.data[h].val)
+      assert(len(t) == L, "table modified while iterating over it")
+
+iterator keys*[A](t: CountTableRef[A]): A =
+  ## Iterates over any key in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTable[A]>`_
+  ## * `values iterator<#values.i,CountTable[A]>`_
+  runnableExamples:
+    let a = newCountTable("abracadabra")
+    for k in keys(a):
+      a[k] = 2
+    doAssert a == newCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].key
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator values*[A](t: CountTableRef[A]): int =
+  ## Iterates over any value in the table `t`.
+  ##
+  ## See also:
+  ## * `pairs iterator<#pairs.i,CountTableRef[A]>`_
+  ## * `keys iterator<#keys.i,CountTableRef[A]>`_
+  ## * `mvalues iterator<#mvalues.i,CountTableRef[A]>`_
+  runnableExamples:
+    let a = newCountTable("abracadabra")
+    for v in values(a):
+      assert v < 10
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+iterator mvalues*[A](t: CountTableRef[A]): var int =
+  ## Iterates over any value in the table `t`. The values can be modified.
+  ##
+  ## See also:
+  ## * `mpairs iterator<#mpairs.i,CountTableRef[A]>`_
+  ## * `values iterator<#values.i,CountTableRef[A]>`_
+  runnableExamples:
+    var a = newCountTable("abracadabra")
+    for v in mvalues(a):
+      v = 2
+    doAssert a == newCountTable("aabbccddrr")
+
+  let L = len(t)
+  for h in 0 .. high(t.data):
+    if t.data[h].val != 0:
+      yield t.data[h].val
+      assert(len(t) == L, "the length of the table changed while iterating over it")
+
+proc hash*[K,V](s: Table[K,V]): Hash =
+  for p in pairs(s):
+    result = result xor hash(p)
+  result = !$result
+
+proc hash*[K,V](s: OrderedTable[K,V]): Hash =
+  for p in pairs(s):
+    result = result !& hash(p)
+  result = !$result
+
+proc hash*[V](s: CountTable[V]): Hash =
+  for p in pairs(s):
+    result = result xor hash(p)
+  result = !$result
diff --git a/lib/pure/colors.nim b/lib/pure/colors.nim
index 6a86a43c4..d3e6dc063 100755..100644
--- a/lib/pure/colors.nim
+++ b/lib/pure/colors.nim
@@ -1,67 +1,112 @@
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module implements color handling for Nimrod. It is used by 
-## the ``graphics`` module.
+## This module implements color handling for Nim,
+## namely color mixing and parsing the CSS color names.
 
-import strutils
+import std/strutils
+from std/algorithm import binarySearch
 
 type
-  TColor* = distinct int ## a color stored as RGB
+  Color* = distinct int ## A color stored as RGB, e.g. `0xff00cc`.
 
-proc `==` *(a, b: TColor): bool {.borrow.}
-  ## compares two colors.
-  
-template extract(a: TColor, r, g, b: expr) =
+proc `==`*(a, b: Color): bool {.borrow.}
+  ## Compares two colors.
+  ##
+  ##   ```Nim
+  ##   var
+  ##     a = Color(0xff_00_ff)
+  ##     b = colFuchsia
+  ##     c = Color(0x00_ff_cc)
+  ##   assert a == b
+  ##   assert not (a == c)
+  ##   ```
+
+template extract(a: Color, r, g, b: untyped) =
   var r = a.int shr 16 and 0xff
   var g = a.int shr 8 and 0xff
   var b = a.int and 0xff
-  
-template rawRGB(r, g, b: expr): expr =
-  TColor(r shl 16 or g shl 8 or b)
-  
-template colorOp(op: expr) =
+
+template rawRGB(r, g, b: int): Color =
+  Color(r shl 16 or g shl 8 or b)
+
+template colorOp(op): Color =
   extract(a, ar, ag, ab)
   extract(b, br, bg, bb)
-  result = rawRGB(op(ar, br), op(ag, bg), op(ab, bb))
-  
-template satPlus(a, b: expr): expr =
-  # saturated plus:
-  block:
-    var result = a +% b
-    if result > 255: result = 255
-    result
-
-template satMinus(a, b: expr): expr =
-  block:
-    var result = a -% b
-    if result < 0: result = 0
-    result
-  
-proc `+`*(a, b: TColor): TColor =
-  ## adds two colors: This uses saturated artithmetic, so that each color
+  rawRGB(op(ar, br), op(ag, bg), op(ab, bb))
+
+proc satPlus(a, b: int): int {.inline.} =
+  result = a +% b
+  if result > 255: result = 255
+
+proc satMinus(a, b: int): int {.inline.} =
+  result = a -% b
+  if result < 0: result = 0
+
+proc `+`*(a, b: Color): Color =
+  ## Adds two colors.
+  ##
+  ## This uses saturated arithmetic, so that each color
   ## component cannot overflow (255 is used as a maximum).
+  ##
+  runnableExamples:
+    var
+      a = Color(0xaa_00_ff)
+      b = Color(0x11_cc_cc)
+    assert a + b == Color(0xbb_cc_ff)
+
   colorOp(satPlus)
-  
-proc `-`*(a, b: TColor): TColor =
-  ## substracts two colors: This uses saturated artithmetic, so that each color
-  ## component cannot overflow (255 is used as a maximum).
+
+proc `-`*(a, b: Color): Color =
+  ## Subtracts two colors.
+  ##
+  ## This uses saturated arithmetic, so that each color
+  ## component cannot underflow (0 is used as a minimum).
+  ##
+  runnableExamples:
+    var
+      a = Color(0xff_33_ff)
+      b = Color(0x11_ff_cc)
+    assert a - b == Color(0xee_00_33)
+
   colorOp(satMinus)
-  
-proc extractRGB*(a: TColor): tuple[r, g, b: range[0..255]] =
-  ## extracts the red/green/blue components of the color `a`.
+
+proc extractRGB*(a: Color): tuple[r, g, b: range[0..255]] =
+  ## Extracts the red/green/blue components of the color `a`.
+  ##
+  runnableExamples:
+    var
+      a = Color(0xff_00_ff)
+      b = Color(0x00_ff_cc)
+    type
+      Col = range[0..255]
+    # assert extractRGB(a) == (r: 255.Col, g: 0.Col, b: 255.Col)
+    # assert extractRGB(b) == (r: 0.Col, g: 255.Col, b: 204.Col)
+    echo extractRGB(a)
+    echo typeof(extractRGB(a))
+    echo extractRGB(b)
+    echo typeof(extractRGB(b))
+
   result.r = a.int shr 16 and 0xff
   result.g = a.int shr 8 and 0xff
   result.b = a.int and 0xff
-  
-proc intensity*(a: TColor, f: float): TColor = 
-  ## returns `a` with intensity `f`. `f` should be a float from 0.0 (completely
+
+proc intensity*(a: Color, f: float): Color =
+  ## Returns `a` with intensity `f`. `f` should be a float from 0.0 (completely
   ## dark) to 1.0 (full color intensity).
+  ##
+  runnableExamples:
+    var
+      a = Color(0xff_00_ff)
+      b = Color(0x00_42_cc)
+    assert a.intensity(0.5) == Color(0x80_00_80)
+    assert b.intensity(0.5) == Color(0x00_21_66)
+
   var r = toInt(toFloat(a.int shr 16 and 0xff) * f)
   var g = toInt(toFloat(a.int shr 8 and 0xff) * f)
   var b = toInt(toFloat(a.int and 0xff) * f)
@@ -69,346 +114,394 @@ proc intensity*(a: TColor, f: float): TColor =
   if g >% 255: g = 255
   if b >% 255: b = 255
   result = rawRGB(r, g, b)
-  
-template mix*(a, b: TColor, fn: expr): expr =
-  ## uses `fn` to mix the colors `a` and `b`. `fn` is invoked for each component
-  ## R, G, and B. This is a template because `fn` should be inlined and the
-  ## compiler cannot inline proc pointers yet. If `fn`'s result is not in the
-  ## range[0..255], it will be saturated to be so.
-  template `><` (x: expr): expr =
+
+template mix*(a, b: Color, fn: untyped): untyped =
+  ## Uses `fn` to mix the colors `a` and `b`.
+  ##
+  ## `fn` is invoked for each component R, G, and B.
+  ## If `fn`'s result is not in the `range[0..255]`,
+  ## it will be saturated to be so.
+  ##
+  runnableExamples:
+    var
+      a = Color(0x0a2814)
+      b = Color(0x050a03)
+
+    proc myMix(x, y: int): int =
+      2 * x - 3 * y
+
+    assert mix(a, b, myMix) == Color(0x05_32_1f)
+
+  template `><` (x: untyped): untyped =
     # keep it in the range 0..255
     block:
       var y = x # eval only once
       if y >% 255:
         y = if y < 0: 0 else: 255
       y
-  
-  (bind extract)(a, ar, ag, ab)
-  (bind extract)(b, br, bg, bb)
-  (bind rawRGB)(><fn(ar, br), ><fn(ag, bg), ><fn(ab, bb))
+
+  extract(a, ar, ag, ab)
+  extract(b, br, bg, bb)
+  rawRGB(><fn(ar, br), ><fn(ag, bg), ><fn(ab, bb))
 
 
 const
-  colAliceBlue* = TColor(0xF0F8FF)
-  colAntiqueWhite* = TColor(0xFAEBD7)
-  colAqua* = TColor(0x00FFFF)
-  colAquamarine* = TColor(0x7FFFD4)
-  colAzure* = TColor(0xF0FFFF)
-  colBeige* = TColor(0xF5F5DC)
-  colBisque* = TColor(0xFFE4C4)
-  colBlack* = TColor(0x000000)
-  colBlanchedAlmond* = TColor(0xFFEBCD)
-  colBlue* = TColor(0x0000FF)
-  colBlueViolet* = TColor(0x8A2BE2)
-  colBrown* = TColor(0xA52A2A)
-  colBurlyWood* = TColor(0xDEB887)
-  colCadetBlue* = TColor(0x5F9EA0)
-  colChartreuse* = TColor(0x7FFF00)
-  colChocolate* = TColor(0xD2691E)
-  colCoral* = TColor(0xFF7F50)
-  colCornflowerBlue* = TColor(0x6495ED)
-  colCornsilk* = TColor(0xFFF8DC)
-  colCrimson* = TColor(0xDC143C)
-  colCyan* = TColor(0x00FFFF)
-  colDarkBlue* = TColor(0x00008B)
-  colDarkCyan* = TColor(0x008B8B)
-  colDarkGoldenRod* = TColor(0xB8860B)
-  colDarkGray* = TColor(0xA9A9A9)
-  colDarkGreen* = TColor(0x006400)
-  colDarkKhaki* = TColor(0xBDB76B)
-  colDarkMagenta* = TColor(0x8B008B)
-  colDarkOliveGreen* = TColor(0x556B2F)
-  colDarkorange* = TColor(0xFF8C00)
-  colDarkOrchid* = TColor(0x9932CC)
-  colDarkRed* = TColor(0x8B0000)
-  colDarkSalmon* = TColor(0xE9967A)
-  colDarkSeaGreen* = TColor(0x8FBC8F)
-  colDarkSlateBlue* = TColor(0x483D8B)
-  colDarkSlateGray* = TColor(0x2F4F4F)
-  colDarkTurquoise* = TColor(0x00CED1)
-  colDarkViolet* = TColor(0x9400D3)
-  colDeepPink* = TColor(0xFF1493)
-  colDeepSkyBlue* = TColor(0x00BFFF)
-  colDimGray* = TColor(0x696969)
-  colDodgerBlue* = TColor(0x1E90FF)
-  colFireBrick* = TColor(0xB22222)
-  colFloralWhite* = TColor(0xFFFAF0)
-  colForestGreen* = TColor(0x228B22)
-  colFuchsia* = TColor(0xFF00FF)
-  colGainsboro* = TColor(0xDCDCDC)
-  colGhostWhite* = TColor(0xF8F8FF)
-  colGold* = TColor(0xFFD700)
-  colGoldenRod* = TColor(0xDAA520)
-  colGray* = TColor(0x808080)
-  colGreen* = TColor(0x008000)
-  colGreenYellow* = TColor(0xADFF2F)
-  colHoneyDew* = TColor(0xF0FFF0)
-  colHotPink* = TColor(0xFF69B4)
-  colIndianRed* = TColor(0xCD5C5C)
-  colIndigo* = TColor(0x4B0082)
-  colIvory* = TColor(0xFFFFF0)
-  colKhaki* = TColor(0xF0E68C)
-  colLavender* = TColor(0xE6E6FA)
-  colLavenderBlush* = TColor(0xFFF0F5)
-  colLawnGreen* = TColor(0x7CFC00)
-  colLemonChiffon* = TColor(0xFFFACD)
-  colLightBlue* = TColor(0xADD8E6)
-  colLightCoral* = TColor(0xF08080)
-  colLightCyan* = TColor(0xE0FFFF)
-  colLightGoldenRodYellow* = TColor(0xFAFAD2)
-  colLightGrey* = TColor(0xD3D3D3)
-  colLightGreen* = TColor(0x90EE90)
-  colLightPink* = TColor(0xFFB6C1)
-  colLightSalmon* = TColor(0xFFA07A)
-  colLightSeaGreen* = TColor(0x20B2AA)
-  colLightSkyBlue* = TColor(0x87CEFA)
-  colLightSlateGray* = TColor(0x778899)
-  colLightSteelBlue* = TColor(0xB0C4DE)
-  colLightYellow* = TColor(0xFFFFE0)
-  colLime* = TColor(0x00FF00)
-  colLimeGreen* = TColor(0x32CD32)
-  colLinen* = TColor(0xFAF0E6)
-  colMagenta* = TColor(0xFF00FF)
-  colMaroon* = TColor(0x800000)
-  colMediumAquaMarine* = TColor(0x66CDAA)
-  colMediumBlue* = TColor(0x0000CD)
-  colMediumOrchid* = TColor(0xBA55D3)
-  colMediumPurple* = TColor(0x9370D8)
-  colMediumSeaGreen* = TColor(0x3CB371)
-  colMediumSlateBlue* = TColor(0x7B68EE)
-  colMediumSpringGreen* = TColor(0x00FA9A)
-  colMediumTurquoise* = TColor(0x48D1CC)
-  colMediumVioletRed* = TColor(0xC71585)
-  colMidnightBlue* = TColor(0x191970)
-  colMintCream* = TColor(0xF5FFFA)
-  colMistyRose* = TColor(0xFFE4E1)
-  colMoccasin* = TColor(0xFFE4B5)
-  colNavajoWhite* = TColor(0xFFDEAD)
-  colNavy* = TColor(0x000080)
-  colOldLace* = TColor(0xFDF5E6)
-  colOlive* = TColor(0x808000)
-  colOliveDrab* = TColor(0x6B8E23)
-  colOrange* = TColor(0xFFA500)
-  colOrangeRed* = TColor(0xFF4500)
-  colOrchid* = TColor(0xDA70D6)
-  colPaleGoldenRod* = TColor(0xEEE8AA)
-  colPaleGreen* = TColor(0x98FB98)
-  colPaleTurquoise* = TColor(0xAFEEEE)
-  colPaleVioletRed* = TColor(0xD87093)
-  colPapayaWhip* = TColor(0xFFEFD5)
-  colPeachPuff* = TColor(0xFFDAB9)
-  colPeru* = TColor(0xCD853F)
-  colPink* = TColor(0xFFC0CB)
-  colPlum* = TColor(0xDDA0DD)
-  colPowderBlue* = TColor(0xB0E0E6)
-  colPurple* = TColor(0x800080)
-  colRed* = TColor(0xFF0000)
-  colRosyBrown* = TColor(0xBC8F8F)
-  colRoyalBlue* = TColor(0x4169E1)
-  colSaddleBrown* = TColor(0x8B4513)
-  colSalmon* = TColor(0xFA8072)
-  colSandyBrown* = TColor(0xF4A460)
-  colSeaGreen* = TColor(0x2E8B57)
-  colSeaShell* = TColor(0xFFF5EE)
-  colSienna* = TColor(0xA0522D)
-  colSilver* = TColor(0xC0C0C0)
-  colSkyBlue* = TColor(0x87CEEB)
-  colSlateBlue* = TColor(0x6A5ACD)
-  colSlateGray* = TColor(0x708090)
-  colSnow* = TColor(0xFFFAFA)
-  colSpringGreen* = TColor(0x00FF7F)
-  colSteelBlue* = TColor(0x4682B4)
-  colTan* = TColor(0xD2B48C)
-  colTeal* = TColor(0x008080)
-  colThistle* = TColor(0xD8BFD8)
-  colTomato* = TColor(0xFF6347)
-  colTurquoise* = TColor(0x40E0D0)
-  colViolet* = TColor(0xEE82EE)
-  colWheat* = TColor(0xF5DEB3)
-  colWhite* = TColor(0xFFFFFF)
-  colWhiteSmoke* = TColor(0xF5F5F5)
-  colYellow* = TColor(0xFFFF00)
-  colYellowGreen* = TColor(0x9ACD32)
-  
-  colorNames = [
-    ("aliceblue", colAliceBlue),
-    ("antiquewhite", colAntiqueWhite),
-    ("aqua", colAqua),
-    ("aquamarine", colAquamarine),
-    ("azure", colAzure),
-    ("beige", colBeige),
-    ("bisque", colBisque),
-    ("black", colBlack),
-    ("blanchedalmond", colBlanchedAlmond),
-    ("blue", colBlue),
-    ("blueviolet", colBlueViolet),
-    ("brown", colBrown),
-    ("burlywood", colBurlyWood),
-    ("cadetblue", colCadetBlue),
-    ("chartreuse", colChartreuse),
-    ("chocolate", colChocolate),
-    ("coral", colCoral),
-    ("cornflowerblue", colCornflowerBlue),
-    ("cornsilk", colCornsilk),
-    ("crimson", colCrimson),
-    ("cyan", colCyan),
-    ("darkblue", colDarkBlue),
-    ("darkcyan", colDarkCyan),
-    ("darkgoldenrod", colDarkGoldenRod),
-    ("darkgray", colDarkGray),
-    ("darkgreen", colDarkGreen),
-    ("darkkhaki", colDarkKhaki),
-    ("darkmagenta", colDarkMagenta),
-    ("darkolivegreen", colDarkOliveGreen),
-    ("darkorange", colDarkorange),
-    ("darkorchid", colDarkOrchid),
-    ("darkred", colDarkRed),
-    ("darksalmon", colDarkSalmon),
-    ("darkseagreen", colDarkSeaGreen),
-    ("darkslateblue", colDarkSlateBlue),
-    ("darkslategray", colDarkSlateGray),
-    ("darkturquoise", colDarkTurquoise),
-    ("darkviolet", colDarkViolet),
-    ("deeppink", colDeepPink),
-    ("deepskyblue", colDeepSkyBlue),
-    ("dimgray", colDimGray),
-    ("dodgerblue", colDodgerBlue),
-    ("firebrick", colFireBrick),
-    ("floralwhite", colFloralWhite),
-    ("forestgreen", colForestGreen),
-    ("fuchsia", colFuchsia),
-    ("gainsboro", colGainsboro),
-    ("ghostwhite", colGhostWhite),
-    ("gold", colGold),
-    ("goldenrod", colGoldenRod),
-    ("gray", colGray),
-    ("green", colGreen),
-    ("greenyellow", colGreenYellow),
-    ("honeydew", colHoneyDew),
-    ("hotpink", colHotPink),
-    ("indianred", colIndianRed),
-    ("indigo", colIndigo),
-    ("ivory", colIvory),
-    ("khaki", colKhaki),
-    ("lavender", colLavender),
-    ("lavenderblush", colLavenderBlush),
-    ("lawngreen", colLawnGreen),
-    ("lemonchiffon", colLemonChiffon),
-    ("lightblue", colLightBlue),
-    ("lightcoral", colLightCoral),
-    ("lightcyan", colLightCyan),
-    ("lightgoldenrodyellow", colLightGoldenRodYellow),
-    ("lightgrey", colLightGrey),
-    ("lightgreen", colLightGreen),
-    ("lightpink", colLightPink),
-    ("lightsalmon", colLightSalmon),
-    ("lightseagreen", colLightSeaGreen),
-    ("lightskyblue", colLightSkyBlue),
-    ("lightslategray", colLightSlateGray),
-    ("lightsteelblue", colLightSteelBlue),
-    ("lightyellow", colLightYellow),
-    ("lime", colLime),
-    ("limegreen", colLimeGreen),
-    ("linen", colLinen),
-    ("magenta", colMagenta),
-    ("maroon", colMaroon),
-    ("mediumaquamarine", colMediumAquaMarine),
-    ("mediumblue", colMediumBlue),
-    ("mediumorchid", colMediumOrchid),
-    ("mediumpurple", colMediumPurple),
-    ("mediumseagreen", colMediumSeaGreen),
-    ("mediumslateblue", colMediumSlateBlue),
-    ("mediumspringgreen", colMediumSpringGreen),
-    ("mediumturquoise", colMediumTurquoise),
-    ("mediumvioletred", colMediumVioletRed),
-    ("midnightblue", colMidnightBlue),
-    ("mintcream", colMintCream),
-    ("mistyrose", colMistyRose),
-    ("moccasin", colMoccasin),
-    ("navajowhite", colNavajoWhite),
-    ("navy", colNavy),
-    ("oldlace", colOldLace),
-    ("olive", colOlive),
-    ("olivedrab", colOliveDrab),
-    ("orange", colOrange),
-    ("orangered", colOrangeRed),
-    ("orchid", colOrchid),
-    ("palegoldenrod", colPaleGoldenRod),
-    ("palegreen", colPaleGreen),
-    ("paleturquoise", colPaleTurquoise),
-    ("palevioletred", colPaleVioletRed),
-    ("papayawhip", colPapayaWhip),
-    ("peachpuff", colPeachPuff),
-    ("peru", colPeru),
-    ("pink", colPink),
-    ("plum", colPlum),
-    ("powderblue", colPowderBlue),
-    ("purple", colPurple),
-    ("red", colRed),
-    ("rosybrown", colRosyBrown),
-    ("royalblue", colRoyalBlue),
-    ("saddlebrown", colSaddleBrown),
-    ("salmon", colSalmon),
-    ("sandybrown", colSandyBrown),
-    ("seagreen", colSeaGreen),
-    ("seashell", colSeaShell),
-    ("sienna", colSienna),
-    ("silver", colSilver),
-    ("skyblue", colSkyBlue),
-    ("slateblue", colSlateBlue),
-    ("slategray", colSlateGray),
-    ("snow", colSnow),
-    ("springgreen", colSpringGreen),
-    ("steelblue", colSteelBlue),
-    ("tan", colTan),
-    ("teal", colTeal),
-    ("thistle", colThistle),
-    ("tomato", colTomato),
-    ("turquoise", colTurquoise),
-    ("violet", colViolet),
-    ("wheat", colWheat),
-    ("white", colWhite),
-    ("whitesmoke", colWhiteSmoke),
-    ("yellow", colYellow),
-    ("yellowgreen", colYellowGreen)]
-
-proc `$`*(c: TColor): string = 
-  ## converts a color into its textual representation. Example: ``#00FF00``.
+  colAliceBlue* = Color(0xF0F8FF)
+  colAntiqueWhite* = Color(0xFAEBD7)
+  colAqua* = Color(0x00FFFF)
+  colAquamarine* = Color(0x7FFFD4)
+  colAzure* = Color(0xF0FFFF)
+  colBeige* = Color(0xF5F5DC)
+  colBisque* = Color(0xFFE4C4)
+  colBlack* = Color(0x000000)
+  colBlanchedAlmond* = Color(0xFFEBCD)
+  colBlue* = Color(0x0000FF)
+  colBlueViolet* = Color(0x8A2BE2)
+  colBrown* = Color(0xA52A2A)
+  colBurlyWood* = Color(0xDEB887)
+  colCadetBlue* = Color(0x5F9EA0)
+  colChartreuse* = Color(0x7FFF00)
+  colChocolate* = Color(0xD2691E)
+  colCoral* = Color(0xFF7F50)
+  colCornflowerBlue* = Color(0x6495ED)
+  colCornsilk* = Color(0xFFF8DC)
+  colCrimson* = Color(0xDC143C)
+  colCyan* = Color(0x00FFFF)
+  colDarkBlue* = Color(0x00008B)
+  colDarkCyan* = Color(0x008B8B)
+  colDarkGoldenRod* = Color(0xB8860B)
+  colDarkGray* = Color(0xA9A9A9)
+  colDarkGreen* = Color(0x006400)
+  colDarkGrey* = Color(0xA9A9A9)
+  colDarkKhaki* = Color(0xBDB76B)
+  colDarkMagenta* = Color(0x8B008B)
+  colDarkOliveGreen* = Color(0x556B2F)
+  colDarkorange* = Color(0xFF8C00)
+  colDarkOrchid* = Color(0x9932CC)
+  colDarkRed* = Color(0x8B0000)
+  colDarkSalmon* = Color(0xE9967A)
+  colDarkSeaGreen* = Color(0x8FBC8F)
+  colDarkSlateBlue* = Color(0x483D8B)
+  colDarkSlateGray* = Color(0x2F4F4F)
+  colDarkSlateGrey* = Color(0x2F4F4F)
+  colDarkTurquoise* = Color(0x00CED1)
+  colDarkViolet* = Color(0x9400D3)
+  colDeepPink* = Color(0xFF1493)
+  colDeepSkyBlue* = Color(0x00BFFF)
+  colDimGray* = Color(0x696969)
+  colDimGrey* = Color(0x696969)
+  colDodgerBlue* = Color(0x1E90FF)
+  colFireBrick* = Color(0xB22222)
+  colFloralWhite* = Color(0xFFFAF0)
+  colForestGreen* = Color(0x228B22)
+  colFuchsia* = Color(0xFF00FF)
+  colGainsboro* = Color(0xDCDCDC)
+  colGhostWhite* = Color(0xF8F8FF)
+  colGold* = Color(0xFFD700)
+  colGoldenRod* = Color(0xDAA520)
+  colGray* = Color(0x808080)
+  colGreen* = Color(0x008000)
+  colGreenYellow* = Color(0xADFF2F)
+  colGrey* = Color(0x808080)
+  colHoneyDew* = Color(0xF0FFF0)
+  colHotPink* = Color(0xFF69B4)
+  colIndianRed* = Color(0xCD5C5C)
+  colIndigo* = Color(0x4B0082)
+  colIvory* = Color(0xFFFFF0)
+  colKhaki* = Color(0xF0E68C)
+  colLavender* = Color(0xE6E6FA)
+  colLavenderBlush* = Color(0xFFF0F5)
+  colLawnGreen* = Color(0x7CFC00)
+  colLemonChiffon* = Color(0xFFFACD)
+  colLightBlue* = Color(0xADD8E6)
+  colLightCoral* = Color(0xF08080)
+  colLightCyan* = Color(0xE0FFFF)
+  colLightGoldenRodYellow* = Color(0xFAFAD2)
+  colLightGray* = Color(0xD3D3D3)
+  colLightGreen* = Color(0x90EE90)
+  colLightGrey* = Color(0xD3D3D3)
+  colLightPink* = Color(0xFFB6C1)
+  colLightSalmon* = Color(0xFFA07A)
+  colLightSeaGreen* = Color(0x20B2AA)
+  colLightSkyBlue* = Color(0x87CEFA)
+  colLightSlateGray* = Color(0x778899)
+  colLightSlateGrey* = Color(0x778899)
+  colLightSteelBlue* = Color(0xB0C4DE)
+  colLightYellow* = Color(0xFFFFE0)
+  colLime* = Color(0x00FF00)
+  colLimeGreen* = Color(0x32CD32)
+  colLinen* = Color(0xFAF0E6)
+  colMagenta* = Color(0xFF00FF)
+  colMaroon* = Color(0x800000)
+  colMediumAquaMarine* = Color(0x66CDAA)
+  colMediumBlue* = Color(0x0000CD)
+  colMediumOrchid* = Color(0xBA55D3)
+  colMediumPurple* = Color(0x9370DB)
+  colMediumSeaGreen* = Color(0x3CB371)
+  colMediumSlateBlue* = Color(0x7B68EE)
+  colMediumSpringGreen* = Color(0x00FA9A)
+  colMediumTurquoise* = Color(0x48D1CC)
+  colMediumVioletRed* = Color(0xC71585)
+  colMidnightBlue* = Color(0x191970)
+  colMintCream* = Color(0xF5FFFA)
+  colMistyRose* = Color(0xFFE4E1)
+  colMoccasin* = Color(0xFFE4B5)
+  colNavajoWhite* = Color(0xFFDEAD)
+  colNavy* = Color(0x000080)
+  colOldLace* = Color(0xFDF5E6)
+  colOlive* = Color(0x808000)
+  colOliveDrab* = Color(0x6B8E23)
+  colOrange* = Color(0xFFA500)
+  colOrangeRed* = Color(0xFF4500)
+  colOrchid* = Color(0xDA70D6)
+  colPaleGoldenRod* = Color(0xEEE8AA)
+  colPaleGreen* = Color(0x98FB98)
+  colPaleTurquoise* = Color(0xAFEEEE)
+  colPaleVioletRed* = Color(0xDB7093)
+  colPapayaWhip* = Color(0xFFEFD5)
+  colPeachPuff* = Color(0xFFDAB9)
+  colPeru* = Color(0xCD853F)
+  colPink* = Color(0xFFC0CB)
+  colPlum* = Color(0xDDA0DD)
+  colPowderBlue* = Color(0xB0E0E6)
+  colPurple* = Color(0x800080)
+  colRebeccaPurple* = Color(0x663399)
+  colRed* = Color(0xFF0000)
+  colRosyBrown* = Color(0xBC8F8F)
+  colRoyalBlue* = Color(0x4169E1)
+  colSaddleBrown* = Color(0x8B4513)
+  colSalmon* = Color(0xFA8072)
+  colSandyBrown* = Color(0xF4A460)
+  colSeaGreen* = Color(0x2E8B57)
+  colSeaShell* = Color(0xFFF5EE)
+  colSienna* = Color(0xA0522D)
+  colSilver* = Color(0xC0C0C0)
+  colSkyBlue* = Color(0x87CEEB)
+  colSlateBlue* = Color(0x6A5ACD)
+  colSlateGray* = Color(0x708090)
+  colSlateGrey* = Color(0x708090)
+  colSnow* = Color(0xFFFAFA)
+  colSpringGreen* = Color(0x00FF7F)
+  colSteelBlue* = Color(0x4682B4)
+  colTan* = Color(0xD2B48C)
+  colTeal* = Color(0x008080)
+  colThistle* = Color(0xD8BFD8)
+  colTomato* = Color(0xFF6347)
+  colTurquoise* = Color(0x40E0D0)
+  colViolet* = Color(0xEE82EE)
+  colWheat* = Color(0xF5DEB3)
+  colWhite* = Color(0xFFFFFF)
+  colWhiteSmoke* = Color(0xF5F5F5)
+  colYellow* = Color(0xFFFF00)
+  colYellowGreen* = Color(0x9ACD32)
+
+  colorNames = {
+    "aliceblue": colAliceBlue,
+    "antiquewhite": colAntiqueWhite,
+    "aqua": colAqua,
+    "aquamarine": colAquamarine,
+    "azure": colAzure,
+    "beige": colBeige,
+    "bisque": colBisque,
+    "black": colBlack,
+    "blanchedalmond": colBlanchedAlmond,
+    "blue": colBlue,
+    "blueviolet": colBlueViolet,
+    "brown": colBrown,
+    "burlywood": colBurlyWood,
+    "cadetblue": colCadetBlue,
+    "chartreuse": colChartreuse,
+    "chocolate": colChocolate,
+    "coral": colCoral,
+    "cornflowerblue": colCornflowerBlue,
+    "cornsilk": colCornsilk,
+    "crimson": colCrimson,
+    "cyan": colCyan,
+    "darkblue": colDarkBlue,
+    "darkcyan": colDarkCyan,
+    "darkgoldenrod": colDarkGoldenRod,
+    "darkgray": colDarkGray,
+    "darkgreen": colDarkGreen,
+    "darkgrey": colDarkGrey,
+    "darkkhaki": colDarkKhaki,
+    "darkmagenta": colDarkMagenta,
+    "darkolivegreen": colDarkOliveGreen,
+    "darkorange": colDarkorange,
+    "darkorchid": colDarkOrchid,
+    "darkred": colDarkRed,
+    "darksalmon": colDarkSalmon,
+    "darkseagreen": colDarkSeaGreen,
+    "darkslateblue": colDarkSlateBlue,
+    "darkslategray": colDarkSlateGray,
+    "darkslategrey": colDarkSlateGrey,
+    "darkturquoise": colDarkTurquoise,
+    "darkviolet": colDarkViolet,
+    "deeppink": colDeepPink,
+    "deepskyblue": colDeepSkyBlue,
+    "dimgray": colDimGray,
+    "dimgrey": colDimGrey,
+    "dodgerblue": colDodgerBlue,
+    "firebrick": colFireBrick,
+    "floralwhite": colFloralWhite,
+    "forestgreen": colForestGreen,
+    "fuchsia": colFuchsia,
+    "gainsboro": colGainsboro,
+    "ghostwhite": colGhostWhite,
+    "gold": colGold,
+    "goldenrod": colGoldenRod,
+    "gray": colGray,
+    "green": colGreen,
+    "greenyellow": colGreenYellow,
+    "grey": colGrey,
+    "honeydew": colHoneyDew,
+    "hotpink": colHotPink,
+    "indianred": colIndianRed,
+    "indigo": colIndigo,
+    "ivory": colIvory,
+    "khaki": colKhaki,
+    "lavender": colLavender,
+    "lavenderblush": colLavenderBlush,
+    "lawngreen": colLawnGreen,
+    "lemonchiffon": colLemonChiffon,
+    "lightblue": colLightBlue,
+    "lightcoral": colLightCoral,
+    "lightcyan": colLightCyan,
+    "lightgoldenrodyellow": colLightGoldenRodYellow,
+    "lightgray": colLightGray,
+    "lightgreen": colLightGreen,
+    "lightgrey": colLightGrey,
+    "lightpink": colLightPink,
+    "lightsalmon": colLightSalmon,
+    "lightseagreen": colLightSeaGreen,
+    "lightskyblue": colLightSkyBlue,
+    "lightslategray": colLightSlateGray,
+    "lightslategrey": colLightSlateGrey,
+    "lightsteelblue": colLightSteelBlue,
+    "lightyellow": colLightYellow,
+    "lime": colLime,
+    "limegreen": colLimeGreen,
+    "linen": colLinen,
+    "magenta": colMagenta,
+    "maroon": colMaroon,
+    "mediumaquamarine": colMediumAquaMarine,
+    "mediumblue": colMediumBlue,
+    "mediumorchid": colMediumOrchid,
+    "mediumpurple": colMediumPurple,
+    "mediumseagreen": colMediumSeaGreen,
+    "mediumslateblue": colMediumSlateBlue,
+    "mediumspringgreen": colMediumSpringGreen,
+    "mediumturquoise": colMediumTurquoise,
+    "mediumvioletred": colMediumVioletRed,
+    "midnightblue": colMidnightBlue,
+    "mintcream": colMintCream,
+    "mistyrose": colMistyRose,
+    "moccasin": colMoccasin,
+    "navajowhite": colNavajoWhite,
+    "navy": colNavy,
+    "oldlace": colOldLace,
+    "olive": colOlive,
+    "olivedrab": colOliveDrab,
+    "orange": colOrange,
+    "orangered": colOrangeRed,
+    "orchid": colOrchid,
+    "palegoldenrod": colPaleGoldenRod,
+    "palegreen": colPaleGreen,
+    "paleturquoise": colPaleTurquoise,
+    "palevioletred": colPaleVioletRed,
+    "papayawhip": colPapayaWhip,
+    "peachpuff": colPeachPuff,
+    "peru": colPeru,
+    "pink": colPink,
+    "plum": colPlum,
+    "powderblue": colPowderBlue,
+    "purple": colPurple,
+    "rebeccapurple": colRebeccaPurple,
+    "red": colRed,
+    "rosybrown": colRosyBrown,
+    "royalblue": colRoyalBlue,
+    "saddlebrown": colSaddleBrown,
+    "salmon": colSalmon,
+    "sandybrown": colSandyBrown,
+    "seagreen": colSeaGreen,
+    "seashell": colSeaShell,
+    "sienna": colSienna,
+    "silver": colSilver,
+    "skyblue": colSkyBlue,
+    "slateblue": colSlateBlue,
+    "slategray": colSlateGray,
+    "slategrey": colSlateGrey,
+    "snow": colSnow,
+    "springgreen": colSpringGreen,
+    "steelblue": colSteelBlue,
+    "tan": colTan,
+    "teal": colTeal,
+    "thistle": colThistle,
+    "tomato": colTomato,
+    "turquoise": colTurquoise,
+    "violet": colViolet,
+    "wheat": colWheat,
+    "white": colWhite,
+    "whitesmoke": colWhiteSmoke,
+    "yellow": colYellow,
+    "yellowgreen": colYellowGreen}
+
+proc `$`*(c: Color): string =
+  ## Converts a color into its textual representation.
+  ##
+  runnableExamples:
+    assert $colFuchsia == "#FF00FF"
   result = '#' & toHex(int(c), 6)
 
-proc binaryStrSearch(x: openarray[tuple[name: string, col: TColor]], 
-                     y: string): int = 
-  var a = 0
-  var b = len(x) - 1
-  while a <= b: 
-    var mid = (a + b) div 2
-    var c = cmp(x[mid].name, y)
-    if c < 0: a = mid + 1
-    elif c > 0: b = mid - 1
-    else: return mid
-  result = - 1
-  
-proc parseColor*(name: string): TColor = 
-  ## parses `name` to a color value. If no valid color could be 
-  ## parsed ``EInvalidValue`` is raised.
-  if name[0] == '#':
-    result = TColor(parseHexInt(name))
+proc colorNameCmp(x: tuple[name: string, col: Color], y: string): int =
+  result = cmpIgnoreCase(x.name, y)
+
+proc parseColor*(name: string): Color =
+  ## Parses `name` to a color value.
+  ##
+  ## If no valid color could be parsed `ValueError` is raised.
+  ## Case insensitive.
+  ##
+  runnableExamples:
+    var
+      a = "silver"
+      b = "#0179fc"
+      c = "#zzmmtt"
+    assert parseColor(a) == Color(0xc0_c0_c0)
+    assert parseColor(b) == Color(0x01_79_fc)
+    doAssertRaises(ValueError): discard parseColor(c)
+
+  if name.len > 0 and name[0] == '#':
+    result = Color(parseHexInt(name))
   else:
-    var idx = binaryStrSearch(colorNames, name)
-    if idx < 0: raise newException(EInvalidValue, "unkown color: " & name)
+    var idx = binarySearch(colorNames, name, colorNameCmp)
+    if idx < 0: raise newException(ValueError, "unknown color: " & name)
     result = colorNames[idx][1]
 
 proc isColor*(name: string): bool =
-  ## returns true if `name` is a known color name or a hexadecimal color 
-  ## prefixed with ``#``.
-  if name[0] == '#': 
-    for i in 1 .. name.len-1: 
-      if name[i] notin {'0'..'9', 'a'..'f', 'A'..'F'}: return false
+  ## Returns true if `name` is a known color name or a hexadecimal color
+  ## prefixed with `#`. Case insensitive.
+  ##
+  runnableExamples:
+    var
+      a = "silver"
+      b = "#0179fc"
+      c = "#zzmmtt"
+    assert a.isColor
+    assert b.isColor
+    assert not c.isColor
+
+  if name.len == 0: return false
+  if name[0] == '#':
+    for i in 1 .. name.len-1:
+      if name[i] notin HexDigits: return false
     result = true
   else:
-    result = binaryStrSearch(colorNames, name) >= 0
+    result = binarySearch(colorNames, name, colorNameCmp) >= 0
 
-proc rgb*(r, g, b: range[0..255]): TColor =
-  ## constructs a color from RGB values.
-  result = rawRGB(r, g, b)
+proc rgb*(r, g, b: range[0..255]): Color =
+  ## Constructs a color from RGB values.
+  ##
+  runnableExamples:
+    assert rgb(0, 255, 128) == Color(0x00_ff_80)
 
+  result = rawRGB(r, g, b)
diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim
index c06451ca8..b48811eae 100755..100644
--- a/lib/pure/complex.nim
+++ b/lib/pure/complex.nim
@@ -1,88 +1,193 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
+## This module implements complex numbers
+## and basic mathematical operations on them.
+##
+## Complex numbers are currently generic over 64-bit or 32-bit floats.
 
+runnableExamples:
+  from std/math import almostEqual, sqrt
 
-## This module implements complex numbers.
+  let
+    z1 = complex(1.0, 2.0)
+    z2 = complex(3.0, -4.0)
 
-{.push checks:off, line_dir:off, stack_trace:off, debugger:off.}
-# the user does not want to trace a part
-# of the standard library!
+  assert almostEqual(z1 + z2, complex(4.0, -2.0))
+  assert almostEqual(z1 - z2, complex(-2.0, 6.0))
+  assert almostEqual(z1 * z2, complex(11.0, 2.0))
+  assert almostEqual(z1 / z2, complex(-0.2, 0.4))
 
-import
-  math
+  assert almostEqual(abs(z1), sqrt(5.0))
+  assert almostEqual(conjugate(z1), complex(1.0, -2.0))
+
+  let (r, phi) = z1.polar
+  assert almostEqual(rect(r, phi), z1)
+
+{.push checks: off, line_dir: off, stack_trace: off, debugger: off.}
+# the user does not want to trace a part of the standard library!
+
+import std/[math, strformat]
 
 type
-  TComplex* = tuple[re, im: float] 
-    ## a complex number, consisting of a real and an imaginary part
+  Complex*[T: SomeFloat] = object
+    ## A complex number, consisting of a real and an imaginary part.
+    re*, im*: T
+  Complex64* = Complex[float64]
+    ## Alias for a complex number using 64-bit floats.
+  Complex32* = Complex[float32]
+    ## Alias for a complex number using 32-bit floats.
+
+func complex*[T: SomeFloat](re: T; im: T = 0.0): Complex[T] =
+  ## Returns a `Complex[T]` with real part `re` and imaginary part `im`.
+  result.re = re
+  result.im = im
+
+func complex32*(re: float32; im: float32 = 0.0): Complex32 =
+  ## Returns a `Complex32` with real part `re` and imaginary part `im`.
+  result.re = re
+  result.im = im
+
+func complex64*(re: float64; im: float64 = 0.0): Complex64 =
+  ## Returns a `Complex64` with real part `re` and imaginary part `im`.
+  result.re = re
+  result.im = im
+
+template im*(arg: typedesc[float32]): Complex32 = complex32(0, 1)
+  ## Returns the imaginary unit (`complex32(0, 1)`).
+template im*(arg: typedesc[float64]): Complex64 = complex64(0, 1)
+  ## Returns the imaginary unit (`complex64(0, 1)`).
+template im*(arg: float32): Complex32 = complex32(0, arg)
+  ## Returns `arg` as an imaginary number (`complex32(0, arg)`).
+template im*(arg: float64): Complex64 = complex64(0, arg)
+  ## Returns `arg` as an imaginary number (`complex64(0, arg)`).
+
+func abs*[T](z: Complex[T]): T =
+  ## Returns the absolute value of `z`,
+  ## that is the distance from (0, 0) to `z`.
+  result = hypot(z.re, z.im)
+
+func abs2*[T](z: Complex[T]): T =
+  ## Returns the squared absolute value of `z`,
+  ## that is the squared distance from (0, 0) to `z`.
+  ## This is more efficient than `abs(z) ^ 2`.
+  result = z.re * z.re + z.im * z.im
+
+func sgn*[T](z: Complex[T]): Complex[T] =
+  ## Returns the phase of `z` as a unit complex number,
+  ## or 0 if `z` is 0.
+  let a = abs(z)
+  if a != 0:
+    result = z / a
 
-proc `==` *(x, y: TComplex): bool =
-  ## Compare two complex numbers `x` and `y` for equality.
+func conjugate*[T](z: Complex[T]): Complex[T] =
+  ## Returns the complex conjugate of `z` (`complex(z.re, -z.im)`).
+  result.re = z.re
+  result.im = -z.im
+
+func inv*[T](z: Complex[T]): Complex[T] =
+  ## Returns the multiplicative inverse of `z` (`1/z`).
+  conjugate(z) / abs2(z)
+
+func `==`*[T](x, y: Complex[T]): bool =
+  ## Compares two complex numbers for equality.
   result = x.re == y.re and x.im == y.im
 
-proc `+` *(x, y: TComplex): TComplex =
-  ## Add two complex numbers.
+func `+`*[T](x: T; y: Complex[T]): Complex[T] =
+  ## Adds a real number to a complex number.
+  result.re = x + y.re
+  result.im = y.im
+
+func `+`*[T](x: Complex[T]; y: T): Complex[T] =
+  ## Adds a complex number to a real number.
+  result.re = x.re + y
+  result.im = x.im
+
+func `+`*[T](x, y: Complex[T]): Complex[T] =
+  ## Adds two complex numbers.
   result.re = x.re + y.re
   result.im = x.im + y.im
 
-proc `-` *(x, y: TComplex): TComplex =
-  ## Subtract two complex numbers.
-  result.re = x.re - y.re
-  result.im = x.im - y.im
-
-proc `-` *(z: TComplex): TComplex =
+func `-`*[T](z: Complex[T]): Complex[T] =
   ## Unary minus for complex numbers.
   result.re = -z.re
   result.im = -z.im
 
-proc `/` *(x, y: TComplex): TComplex =
-  ## Divide `x` by `y`.
-  var
-    r, den: float
-  if abs(y.re) < abs(y.im):
-    r = y.re / y.im
-    den = y.im + r * y.re
-    result.re = (x.re * r + x.im) / den
-    result.im = (x.im * r - x.re) / den
-  else:
-    r = y.im / y.re
-    den = y.re + r * y.im
-    result.re = (x.re + r * x.im) / den
-    result.im = (x.im - r * x.re) / den
+func `-`*[T](x: T; y: Complex[T]): Complex[T] =
+  ## Subtracts a complex number from a real number.
+  result.re = x - y.re
+  result.im = -y.im
+
+func `-`*[T](x: Complex[T]; y: T): Complex[T] =
+  ## Subtracts a real number from a complex number.
+  result.re = x.re - y
+  result.im = x.im
 
-proc `*` *(x, y: TComplex): TComplex =
-  ## Multiply `x` with `y`.
+func `-`*[T](x, y: Complex[T]): Complex[T] =
+  ## Subtracts two complex numbers.
+  result.re = x.re - y.re
+  result.im = x.im - y.im
+
+func `*`*[T](x: T; y: Complex[T]): Complex[T] =
+  ## Multiplies a real number with a complex number.
+  result.re = x * y.re
+  result.im = x * y.im
+
+func `*`*[T](x: Complex[T]; y: T): Complex[T] =
+  ## Multiplies a complex number with a real number.
+  result.re = x.re * y
+  result.im = x.im * y
+
+func `*`*[T](x, y: Complex[T]): Complex[T] =
+  ## Multiplies two complex numbers.
   result.re = x.re * y.re - x.im * y.im
   result.im = x.im * y.re + x.re * y.im
 
-proc abs*(z: TComplex): float =
-  ## Return the distance from (0,0) to `z`.
-
-  # optimized by checking special cases (sqrt is expensive)
-  var x, y, temp: float
-
-  x = abs(z.re)
-  y = abs(z.im)
-  if x == 0.0:
-    result = y
-  elif y == 0.0:
-    result = x
-  elif x > y:
-    temp = y / x
-    result = x * sqrt(1.0 + temp * temp)
-  else:
-    temp = x / y
-    result = y * sqrt(1.0 + temp * temp)
+func `/`*[T](x: Complex[T]; y: T): Complex[T] =
+  ## Divides a complex number by a real number.
+  result.re = x.re / y
+  result.im = x.im / y
+
+func `/`*[T](x: T; y: Complex[T]): Complex[T] =
+  ## Divides a real number by a complex number.
+  result = x * inv(y)
+
+func `/`*[T](x, y: Complex[T]): Complex[T] =
+  ## Divides two complex numbers.
+  x * conjugate(y) / abs2(y)
+
+func `+=`*[T](x: var Complex[T]; y: Complex[T]) =
+  ## Adds `y` to `x`.
+  x.re += y.re
+  x.im += y.im
+
+func `-=`*[T](x: var Complex[T]; y: Complex[T]) =
+  ## Subtracts `y` from `x`.
+  x.re -= y.re
+  x.im -= y.im
 
-proc sqrt*(z: TComplex): TComplex =
-  ## Square root for a complex number `z`.
-  var x, y, w, r: float
+func `*=`*[T](x: var Complex[T]; y: Complex[T]) =
+  ## Multiplies `x` by `y`.
+  let im = x.im * y.re + x.re * y.im
+  x.re = x.re * y.re - x.im * y.im
+  x.im = im
+
+func `/=`*[T](x: var Complex[T]; y: Complex[T]) =
+  ## Divides `x` by `y` in place.
+  x = x / y
+
+
+func sqrt*[T](z: Complex[T]): Complex[T] =
+  ## Computes the
+  ## ([principal](https://en.wikipedia.org/wiki/Square_root#Principal_square_root_of_a_complex_number))
+  ## square root of a complex number `z`.
+  var x, y, w, r: T
 
   if z.re == 0.0 and z.im == 0.0:
     result = z
@@ -95,12 +200,274 @@ proc sqrt*(z: TComplex): TComplex =
     else:
       r = x / y
       w = sqrt(y) * sqrt(0.5 * (r + sqrt(1.0 + r * r)))
+
     if z.re >= 0.0:
       result.re = w
       result.im = z.im / (w * 2.0)
     else:
-      if z.im >= 0.0: result.im = w
-      else:           result.im = -w
+      result.im = if z.im >= 0.0: w else: -w
       result.re = z.im / (result.im + result.im)
 
+func exp*[T](z: Complex[T]): Complex[T] =
+  ## Computes the exponential function (`e^z`).
+  let
+    rho = exp(z.re)
+    theta = z.im
+  result.re = rho * cos(theta)
+  result.im = rho * sin(theta)
+
+func ln*[T](z: Complex[T]): Complex[T] =
+  ## Returns the
+  ## ([principal value](https://en.wikipedia.org/wiki/Complex_logarithm#Principal_value)
+  ## of the) natural logarithm of `z`.
+  result.re = ln(abs(z))
+  result.im = arctan2(z.im, z.re)
+
+func log10*[T](z: Complex[T]): Complex[T] =
+  ## Returns the logarithm base 10 of `z`.
+  ##
+  ## **See also:**
+  ## * `ln func<#ln,Complex[T]>`_
+  result = ln(z) / ln(10.0)
+
+func log2*[T](z: Complex[T]): Complex[T] =
+  ## Returns the logarithm base 2 of `z`.
+  ##
+  ## **See also:**
+  ## * `ln func<#ln,Complex[T]>`_
+  result = ln(z) / ln(2.0)
+
+func pow*[T](x, y: Complex[T]): Complex[T] =
+  ## `x` raised to the power of `y`.
+  if x.re == 0.0 and x.im == 0.0:
+    if y.re == 0.0 and y.im == 0.0:
+      result.re = 1.0
+      result.im = 0.0
+    else:
+      result.re = 0.0
+      result.im = 0.0
+  elif y.im == 0.0:
+    if y.re == 1.0:
+      result = x
+    elif y.re == -1.0:
+      result = T(1.0) / x
+    elif y.re == 2.0:
+      result = x * x
+    elif y.re == 0.5:
+      result = sqrt(x)
+    elif x.im == 0.0:
+      # Revert to real pow when both base and exponent are real
+      result.re = pow(x.re, y.re)
+      result.im = 0.0
+    else:
+      # Special case when the exponent is real
+      let
+        rho = abs(x)
+        theta = arctan2(x.im, x.re)
+        s = pow(rho, y.re)
+        r = y.re * theta
+      result.re = s * cos(r)
+      result.im = s * sin(r)
+  elif x.im == 0.0 and x.re == E:
+   # Special case Euler's formula
+   result = exp(y)
+  else:
+    let
+      rho = abs(x)
+      theta = arctan2(x.im, x.re)
+      s = pow(rho, y.re) * exp(-y.im * theta)
+      r = y.re * theta + y.im * ln(rho)
+    result.re = s * cos(r)
+    result.im = s * sin(r)
+
+func pow*[T](x: Complex[T]; y: T): Complex[T] =
+  ## The complex number `x` raised to the power of the real number `y`.
+  pow(x, complex[T](y))
+
+
+func sin*[T](z: Complex[T]): Complex[T] =
+  ## Returns the sine of `z`.
+  result.re = sin(z.re) * cosh(z.im)
+  result.im = cos(z.re) * sinh(z.im)
+
+func arcsin*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse sine of `z`.
+  result = -im(T) * ln(im(T) * z + sqrt(T(1.0) - z*z))
+
+func cos*[T](z: Complex[T]): Complex[T] =
+  ## Returns the cosine of `z`.
+  result.re = cos(z.re) * cosh(z.im)
+  result.im = -sin(z.re) * sinh(z.im)
+
+func arccos*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse cosine of `z`.
+  result = -im(T) * ln(z + sqrt(z*z - T(1.0)))
+
+func tan*[T](z: Complex[T]): Complex[T] =
+  ## Returns the tangent of `z`.
+  result = sin(z) / cos(z)
+
+func arctan*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse tangent of `z`.
+  result = T(0.5)*im(T) * (ln(T(1.0) - im(T)*z) - ln(T(1.0) + im(T)*z))
+
+func cot*[T](z: Complex[T]): Complex[T] =
+  ## Returns the cotangent of `z`.
+  result = cos(z)/sin(z)
+
+func arccot*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse cotangent of `z`.
+  result = T(0.5)*im(T) * (ln(T(1.0) - im(T)/z) - ln(T(1.0) + im(T)/z))
+
+func sec*[T](z: Complex[T]): Complex[T] =
+  ## Returns the secant of `z`.
+  result = T(1.0) / cos(z)
+
+func arcsec*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse secant of `z`.
+  result = -im(T) * ln(im(T) * sqrt(1.0 - 1.0/(z*z)) + T(1.0)/z)
+
+func csc*[T](z: Complex[T]): Complex[T] =
+  ## Returns the cosecant of `z`.
+  result = T(1.0) / sin(z)
+
+func arccsc*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse cosecant of `z`.
+  result = -im(T) * ln(sqrt(T(1.0) - T(1.0)/(z*z)) + im(T)/z)
+
+func sinh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic sine of `z`.
+  result = T(0.5) * (exp(z) - exp(-z))
+
+func arcsinh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic sine of `z`.
+  result = ln(z + sqrt(z*z + 1.0))
+
+func cosh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic cosine of `z`.
+  result = T(0.5) * (exp(z) + exp(-z))
+
+func arccosh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic cosine of `z`.
+  result = ln(z + sqrt(z*z - T(1.0)))
+
+func tanh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic tangent of `z`.
+  result = sinh(z) / cosh(z)
+
+func arctanh*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic tangent of `z`.
+  result = T(0.5) * (ln((T(1.0)+z) / (T(1.0)-z)))
+
+func coth*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic cotangent of `z`.
+  result = cosh(z) / sinh(z)
+
+func arccoth*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic cotangent of `z`.
+  result = T(0.5) * (ln(T(1.0) + T(1.0)/z) - ln(T(1.0) - T(1.0)/z))
+
+func sech*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic secant of `z`.
+  result = T(2.0) / (exp(z) + exp(-z))
+
+func arcsech*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic secant of `z`.
+  result = ln(1.0/z + sqrt(T(1.0)/z+T(1.0)) * sqrt(T(1.0)/z-T(1.0)))
+
+func csch*[T](z: Complex[T]): Complex[T] =
+  ## Returns the hyperbolic cosecant of `z`.
+  result = T(2.0) / (exp(z) - exp(-z))
+
+func arccsch*[T](z: Complex[T]): Complex[T] =
+  ## Returns the inverse hyperbolic cosecant of `z`.
+  result = ln(T(1.0)/z + sqrt(T(1.0)/(z*z) + T(1.0)))
+
+func phase*[T](z: Complex[T]): T =
+  ## Returns the phase (or argument) of `z`, that is the angle in polar representation.
+  ##
+  ## | `result = arctan2(z.im, z.re)`
+  arctan2(z.im, z.re)
+
+func polar*[T](z: Complex[T]): tuple[r, phi: T] =
+  ## Returns `z` in polar coordinates.
+  ##
+  ## | `result.r = abs(z)`
+  ## | `result.phi = phase(z)`
+  ##
+  ## **See also:**
+  ## * `rect func<#rect,T,T>`_ for the inverse operation
+  (r: abs(z), phi: phase(z))
+
+func rect*[T](r, phi: T): Complex[T] =
+  ## Returns the complex number with polar coordinates `r` and `phi`.
+  ##
+  ## | `result.re = r * cos(phi)`
+  ## | `result.im = r * sin(phi)`
+  ##
+  ## **See also:**
+  ## * `polar func<#polar,Complex[T]>`_ for the inverse operation
+  complex(r * cos(phi), r * sin(phi))
+
+func almostEqual*[T: SomeFloat](x, y: Complex[T]; unitsInLastPlace: Natural = 4): bool =
+  ## Checks if two complex values are almost equal, using the
+  ## [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon).
+  ##
+  ## Two complex values are considered almost equal if their real and imaginary
+  ## components are almost equal.
+  ##
+  ## `unitsInLastPlace` is the max number of
+  ## [units in the last place](https://en.wikipedia.org/wiki/Unit_in_the_last_place)
+  ## difference tolerated when comparing two numbers. The larger the value, the
+  ## more error is allowed. A `0` value means that two numbers must be exactly the
+  ## same to be considered equal.
+  ##
+  ## The machine epsilon has to be scaled to the magnitude of the values used
+  ## and multiplied by the desired precision in ULPs unless the difference is
+  ## subnormal.
+  almostEqual(x.re, y.re, unitsInLastPlace = unitsInLastPlace) and
+  almostEqual(x.im, y.im, unitsInLastPlace = unitsInLastPlace)
+
+func `$`*(z: Complex): string =
+  ## Returns `z`'s string representation as `"(re, im)"`.
+  runnableExamples:
+    doAssert $complex(1.0, 2.0) == "(1.0, 2.0)"
+
+  result = "(" & $z.re & ", " & $z.im & ")"
+
+proc formatValueAsTuple(result: var string; value: Complex; specifier: string) =
+  ## Format implementation for `Complex` representing the value as a (real, imaginary) tuple.
+  result.add "("
+  formatValue(result, value.re, specifier)
+  result.add ", "
+  formatValue(result, value.im, specifier)
+  result.add ")"
+
+proc formatValueAsComplexNumber(result: var string; value: Complex; specifier: string) =
+  ## Format implementation for `Complex` representing the value as a (RE+IMj) number
+  ## By default, the real and imaginary parts are formatted using the general ('g') format
+  let specifier = if specifier.contains({'e', 'E', 'f', 'F', 'g', 'G'}):
+      specifier.replace("j")
+    else:
+      specifier.replace('j', 'g')
+  result.add "("
+  formatValue(result, value.re, specifier)
+  if value.im >= 0 and not specifier.contains({'+', '-'}):
+    result.add "+"
+  formatValue(result, value.im, specifier)
+  result.add "j)"
+
+proc formatValue*(result: var string; value: Complex; specifier: string) =
+  ## Standard format implementation for `Complex`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  ## For complex numbers, we add a specific 'j' specifier, which formats
+  ## the value as (A+Bj) like in mathematics.
+  if specifier.len == 0:
+    result.add $value
+  elif 'j' in specifier:
+    formatValueAsComplexNumber(result, value, specifier)
+  else:
+    formatValueAsTuple(result, value, specifier)
+
 {.pop.}
diff --git a/lib/pure/concurrency/atomics.nim b/lib/pure/concurrency/atomics.nim
new file mode 100644
index 000000000..818f1b37a
--- /dev/null
+++ b/lib/pure/concurrency/atomics.nim
@@ -0,0 +1,433 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Jörg Wollenschläger
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Types and operations for atomic operations and lockless algorithms.
+##
+## Unstable API.
+## 
+## By default, C++ uses C11 atomic primitives. To use C++ `std::atomic`,
+## `-d:nimUseCppAtomics` can be defined.
+
+runnableExamples:
+  # Atomic
+  var loc: Atomic[int]
+  loc.store(4)
+  assert loc.load == 4
+  loc.store(2)
+  assert loc.load(moRelaxed) == 2
+  loc.store(9)
+  assert loc.load(moAcquire) == 9
+  loc.store(0, moRelease)
+  assert loc.load == 0
+
+  assert loc.exchange(7) == 0
+  assert loc.load == 7
+
+  var expected = 7
+  assert loc.compareExchange(expected, 5, moRelaxed, moRelaxed)
+  assert expected == 7
+  assert loc.load == 5
+
+  assert not loc.compareExchange(expected, 12, moRelaxed, moRelaxed)
+  assert expected == 5
+  assert loc.load == 5
+
+  assert loc.fetchAdd(1) == 5
+  assert loc.fetchAdd(2) == 6
+  assert loc.fetchSub(3) == 8
+
+  loc.atomicInc(1)
+  assert loc.load == 6
+
+  # AtomicFlag
+  var flag: AtomicFlag
+
+  assert not flag.testAndSet
+  assert flag.testAndSet
+  flag.clear(moRelaxed)
+  assert not flag.testAndSet
+
+when (defined(cpp) and defined(nimUseCppAtomics)) or defined(nimdoc):
+  # For the C++ backend, types and operations map directly to C++11 atomics.
+
+  {.push, header: "<atomic>".}
+
+  type
+    MemoryOrder* {.importcpp: "std::memory_order".} = enum
+      ## Specifies how non-atomic operations can be reordered around atomic
+      ## operations.
+
+      moRelaxed
+        ## No ordering constraints. Only the atomicity and ordering against
+        ## other atomic operations is guaranteed.
+
+      moConsume
+        ## This ordering is currently discouraged as it's semantics are
+        ## being revised. Acquire operations should be preferred.
+
+      moAcquire
+        ## When applied to a load operation, no reads or writes in the
+        ## current thread can be reordered before this operation.
+
+      moRelease
+        ## When applied to a store operation, no reads or writes in the
+        ## current thread can be reorderd after this operation.
+
+      moAcquireRelease
+        ## When applied to a read-modify-write operation, this behaves like
+        ## both an acquire and a release operation.
+
+      moSequentiallyConsistent
+        ## Behaves like Acquire when applied to load, like Release when
+        ## applied to a store and like AcquireRelease when applied to a
+        ## read-modify-write operation.
+        ## Also guarantees that all threads observe the same total ordering
+        ## with other moSequentiallyConsistent operations.
+
+  type
+    Atomic*[T] {.importcpp: "std::atomic", completeStruct.} = object
+      ## An atomic object with underlying type `T`.
+      raw: T
+
+    AtomicFlag* {.importcpp: "std::atomic_flag", size: 1.} = object
+      ## An atomic boolean state.
+
+  # Access operations
+
+  proc load*[T](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.load(@)".}
+    ## Atomically obtains the value of the atomic object.
+
+  proc store*[T](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.importcpp: "#.store(@)".}
+    ## Atomically replaces the value of the atomic object with the `desired`
+    ## value.
+
+  proc exchange*[T](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.exchange(@)".}
+    ## Atomically replaces the value of the atomic object with the `desired`
+    ## value and returns the old value.
+
+  proc compareExchange*[T](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.importcpp: "#.compare_exchange_strong(@)".}
+    ## Atomically compares the value of the atomic object with the `expected`
+    ## value and performs exchange with the `desired` one if equal or load if
+    ## not. Returns true if the exchange was successful.
+
+  proc compareExchange*[T](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.importcpp: "#.compare_exchange_strong(@)".}
+    ## Same as above, but allows for different memory orders for success and
+    ## failure.
+
+  proc compareExchangeWeak*[T](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.importcpp: "#.compare_exchange_weak(@)".}
+    ## Same as above, but is allowed to fail spuriously.
+
+  proc compareExchangeWeak*[T](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.importcpp: "#.compare_exchange_weak(@)".}
+    ## Same as above, but allows for different memory orders for success and
+    ## failure.
+
+  # Numerical operations
+
+  proc fetchAdd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.fetch_add(@)".}
+    ## Atomically adds a `value` to the atomic integer and returns the
+    ## original value.
+
+  proc fetchSub*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.fetch_sub(@)".}
+    ## Atomically subtracts a `value` to the atomic integer and returns the
+    ## original value.
+
+  proc fetchAnd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.fetch_and(@)".}
+    ## Atomically replaces the atomic integer with it's bitwise AND
+    ## with the specified `value` and returns the original value.
+
+  proc fetchOr*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.fetch_or(@)".}
+    ## Atomically replaces the atomic integer with it's bitwise OR
+    ## with the specified `value` and returns the original value.
+
+  proc fetchXor*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importcpp: "#.fetch_xor(@)".}
+    ## Atomically replaces the atomic integer with it's bitwise XOR
+    ## with the specified `value` and returns the original value.
+
+  # Flag operations
+
+  proc testAndSet*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent): bool {.importcpp: "#.test_and_set(@)".}
+    ## Atomically sets the atomic flag to true and returns the original value.
+
+  proc clear*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent) {.importcpp: "#.clear(@)".}
+    ## Atomically sets the value of the atomic flag to false.
+
+  proc fence*(order: MemoryOrder) {.importcpp: "std::atomic_thread_fence(@)".}
+    ## Ensures memory ordering without using atomic operations.
+
+  proc signalFence*(order: MemoryOrder) {.importcpp: "std::atomic_signal_fence(@)".}
+    ## Prevents reordering of accesses by the compiler as would fence, but
+    ## inserts no CPU instructions for memory ordering.
+
+  {.pop.}
+
+else:
+  # For the C backend, atomics map to C11 built-ins on GCC and Clang for
+  # trivial Nim types. Other types are implemented using spin locks.
+  # This could be overcome by supporting advanced importc-patterns.
+
+  # Since MSVC does not implement C11, we fall back to MS intrinsics
+  # where available.
+
+  type
+    Trivial = SomeNumber | bool | enum | ptr | pointer
+      # A type that is known to be atomic and whose size is known at
+      # compile time to be 8 bytes or less
+
+  template nonAtomicType*(T: typedesc[Trivial]): untyped =
+    # Maps types to integers of the same size
+    when sizeof(T) == 1: int8
+    elif sizeof(T) == 2: int16
+    elif sizeof(T) == 4: int32
+    elif sizeof(T) == 8: int64
+
+  when defined(vcc):
+
+    # TODO: Trivial types should be volatile and use VC's special volatile
+    # semantics for store and loads.
+
+    type
+      MemoryOrder* = enum
+        moRelaxed
+        moConsume
+        moAcquire
+        moRelease
+        moAcquireRelease
+        moSequentiallyConsistent
+
+      Atomic*[T] = object
+        when T is Trivial:
+          value: T.nonAtomicType
+        else:
+          nonAtomicValue: T
+          guard: AtomicFlag
+
+      AtomicFlag* = distinct int8
+
+    {.push header: "<intrin.h>".}
+
+    # MSVC intrinsics
+    proc interlockedExchange(location: pointer; desired: int8): int8 {.importc: "_InterlockedExchange8".}
+    proc interlockedExchange(location: pointer; desired: int16): int16 {.importc: "_InterlockedExchange16".}
+    proc interlockedExchange(location: pointer; desired: int32): int32 {.importc: "_InterlockedExchange".}
+    proc interlockedExchange(location: pointer; desired: int64): int64 {.importc: "_InterlockedExchange64".}
+
+    proc interlockedCompareExchange(location: pointer; desired, expected: int8): int8 {.importc: "_InterlockedCompareExchange8".}
+    proc interlockedCompareExchange(location: pointer; desired, expected: int16): int16 {.importc: "_InterlockedCompareExchange16".}
+    proc interlockedCompareExchange(location: pointer; desired, expected: int32): int32 {.importc: "_InterlockedCompareExchange".}
+    proc interlockedCompareExchange(location: pointer; desired, expected: int64): int64 {.importc: "_InterlockedCompareExchange64".}
+
+    proc interlockedAnd(location: pointer; value: int8): int8 {.importc: "_InterlockedAnd8".}
+    proc interlockedAnd(location: pointer; value: int16): int16 {.importc: "_InterlockedAnd16".}
+    proc interlockedAnd(location: pointer; value: int32): int32 {.importc: "_InterlockedAnd".}
+    proc interlockedAnd(location: pointer; value: int64): int64 {.importc: "_InterlockedAnd64".}
+
+    proc interlockedOr(location: pointer; value: int8): int8 {.importc: "_InterlockedOr8".}
+    proc interlockedOr(location: pointer; value: int16): int16 {.importc: "_InterlockedOr16".}
+    proc interlockedOr(location: pointer; value: int32): int32 {.importc: "_InterlockedOr".}
+    proc interlockedOr(location: pointer; value: int64): int64 {.importc: "_InterlockedOr64".}
+
+    proc interlockedXor(location: pointer; value: int8): int8 {.importc: "_InterlockedXor8".}
+    proc interlockedXor(location: pointer; value: int16): int16 {.importc: "_InterlockedXor16".}
+    proc interlockedXor(location: pointer; value: int32): int32 {.importc: "_InterlockedXor".}
+    proc interlockedXor(location: pointer; value: int64): int64 {.importc: "_InterlockedXor64".}
+
+    proc fence(order: MemoryOrder): int64 {.importc: "_ReadWriteBarrier()".}
+    proc signalFence(order: MemoryOrder): int64 {.importc: "_ReadWriteBarrier()".}
+
+    {.pop.}
+
+    proc testAndSet*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent): bool =
+      interlockedOr(addr(location), 1'i8) == 1'i8
+    proc clear*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent) =
+      discard interlockedAnd(addr(location), 0'i8)
+
+    proc load*[T: Trivial](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](interlockedOr(addr(location.value), (nonAtomicType(T))0))
+    proc store*[T: Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.inline.} =
+      discard interlockedExchange(addr(location.value), cast[nonAtomicType(T)](desired))
+
+    proc exchange*[T: Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](interlockedExchange(addr(location.value), cast[int64](desired)))
+    proc compareExchange*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+      cast[T](interlockedCompareExchange(addr(location.value), cast[nonAtomicType(T)](desired), cast[nonAtomicType(T)](expected))) == expected
+    proc compareExchange*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+      compareExchange(location, expected, desired, order, order)
+    proc compareExchangeWeak*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+      compareExchange(location, expected, desired, success, failure)
+    proc compareExchangeWeak*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+      compareExchangeWeak(location, expected, desired, order, order)
+
+    proc fetchAdd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      var currentValue = location.load()
+      while not compareExchangeWeak(location, currentValue, currentValue + value): discard
+    proc fetchSub*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      fetchAdd(location, -value, order)
+    proc fetchAnd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](interlockedAnd(addr(location.value), cast[nonAtomicType(T)](value)))
+    proc fetchOr*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](interlockedOr(addr(location.value), cast[nonAtomicType(T)](value)))
+    proc fetchXor*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](interlockedXor(addr(location.value), cast[nonAtomicType(T)](value)))
+
+  else:
+    when defined(cpp):
+      {.push, header: "<atomic>".}
+      template maybeWrapStd(x: string): string =
+        "std::" & x
+    else:
+      {.push, header: "<stdatomic.h>".}
+      template maybeWrapStd(x: string): string =
+        x
+
+    type
+      MemoryOrder* {.importc: "memory_order".maybeWrapStd.} = enum
+        moRelaxed
+        moConsume
+        moAcquire
+        moRelease
+        moAcquireRelease
+        moSequentiallyConsistent
+
+    when defined(cpp):
+      type
+        # Atomic*[T] {.importcpp: "_Atomic('0)".} = object
+
+        AtomicInt8 {.importc: "std::atomic<NI8>".} = int8
+        AtomicInt16 {.importc: "std::atomic<NI16>".} = int16
+        AtomicInt32 {.importc: "std::atomic<NI32>".} = int32
+        AtomicInt64 {.importc: "std::atomic<NI64>".} = int64
+    else:
+      type
+        # Atomic*[T] {.importcpp: "_Atomic('0)".} = object
+
+        AtomicInt8 {.importc: "_Atomic NI8".} = int8
+        AtomicInt16 {.importc: "_Atomic NI16".} = int16
+        AtomicInt32 {.importc: "_Atomic NI32".} = int32
+        AtomicInt64 {.importc: "_Atomic NI64".} = int64
+
+    type
+      AtomicFlag* {.importc: "atomic_flag".maybeWrapStd, size: 1.} = object
+
+      Atomic*[T] = object
+        when T is Trivial:
+          # Maps the size of a trivial type to it's internal atomic type
+          when sizeof(T) == 1: value: AtomicInt8
+          elif sizeof(T) == 2: value: AtomicInt16
+          elif sizeof(T) == 4: value: AtomicInt32
+          elif sizeof(T) == 8: value: AtomicInt64
+        else:
+          nonAtomicValue: T
+          guard: AtomicFlag
+
+    #proc init*[T](location: var Atomic[T]; value: T): T {.importcpp: "atomic_init(@)".}
+    proc atomic_load_explicit[T, A](location: ptr A; order: MemoryOrder): T {.importc: "atomic_load_explicit".maybeWrapStd.}
+    proc atomic_store_explicit[T, A](location: ptr A; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.importc: "atomic_store_explicit".maybeWrapStd.}
+    proc atomic_exchange_explicit[T, A](location: ptr A; desired: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_exchange_explicit".maybeWrapStd.}
+    proc atomic_compare_exchange_strong_explicit[T, A](location: ptr A; expected: ptr T; desired: T; success, failure: MemoryOrder): bool {.importc: "atomic_compare_exchange_strong_explicit".maybeWrapStd.}
+    proc atomic_compare_exchange_weak_explicit[T, A](location: ptr A; expected: ptr T; desired: T; success, failure: MemoryOrder): bool {.importc: "atomic_compare_exchange_weak_explicit".maybeWrapStd.}
+
+    # Numerical operations
+    proc atomic_fetch_add_explicit[T, A](location: ptr A; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_fetch_add_explicit".maybeWrapStd.}
+    proc atomic_fetch_sub_explicit[T, A](location: ptr A; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_fetch_sub_explicit".maybeWrapStd.}
+    proc atomic_fetch_and_explicit[T, A](location: ptr A; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_fetch_and_explicit".maybeWrapStd.}
+    proc atomic_fetch_or_explicit[T, A](location: ptr A; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_fetch_or_explicit".maybeWrapStd.}
+    proc atomic_fetch_xor_explicit[T, A](location: ptr A; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.importc: "atomic_fetch_xor_explicit".maybeWrapStd.}
+
+    # Flag operations
+    # var ATOMIC_FLAG_INIT {.importc, nodecl.}: AtomicFlag
+    # proc init*(location: var AtomicFlag) {.inline.} = location = ATOMIC_FLAG_INIT
+    proc testAndSet*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent): bool {.importc: "atomic_flag_test_and_set_explicit".maybeWrapStd.}
+    proc clear*(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent) {.importc: "atomic_flag_clear_explicit".maybeWrapStd.}
+
+    proc fence*(order: MemoryOrder) {.importc: "atomic_thread_fence".maybeWrapStd.}
+    proc signalFence*(order: MemoryOrder) {.importc: "atomic_signal_fence".maybeWrapStd.}
+
+    {.pop.}
+
+    proc load*[T: Trivial](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_load_explicit[nonAtomicType(T), typeof(location.value)](addr(location.value), order))
+    proc store*[T: Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.inline.} =
+      atomic_store_explicit(addr(location.value), cast[nonAtomicType(T)](desired), order)
+    proc exchange*[T: Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_exchange_explicit(addr(location.value), cast[nonAtomicType(T)](desired), order))
+    proc compareExchange*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+      atomic_compare_exchange_strong_explicit(addr(location.value), cast[ptr nonAtomicType(T)](addr(expected)), cast[nonAtomicType(T)](desired), success, failure)
+    proc compareExchange*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+      compareExchange(location, expected, desired, order, order)
+
+    proc compareExchangeWeak*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+      atomic_compare_exchange_weak_explicit(addr(location.value), cast[ptr nonAtomicType(T)](addr(expected)), cast[nonAtomicType(T)](desired), success, failure)
+    proc compareExchangeWeak*[T: Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+      compareExchangeWeak(location, expected, desired, order, order)
+
+    # Numerical operations
+    proc fetchAdd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_fetch_add_explicit(addr(location.value), cast[nonAtomicType(T)](value), order))
+    proc fetchSub*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_fetch_sub_explicit(addr(location.value), cast[nonAtomicType(T)](value), order))
+    proc fetchAnd*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_fetch_and_explicit(addr(location.value), cast[nonAtomicType(T)](value), order))
+    proc fetchOr*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_fetch_or_explicit(addr(location.value), cast[nonAtomicType(T)](value), order))
+    proc fetchXor*[T: SomeInteger](location: var Atomic[T]; value: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+      cast[T](atomic_fetch_xor_explicit(addr(location.value), cast[nonAtomicType(T)](value), order))
+
+  template withLock[T: not Trivial](location: var Atomic[T]; order: MemoryOrder; body: untyped): untyped =
+    while testAndSet(location.guard, moAcquire): discard
+    try:
+      body
+    finally:
+      clear(location.guard, moRelease)
+
+  proc load*[T: not Trivial](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+    withLock(location, order):
+      result = location.nonAtomicValue
+
+  proc store*[T: not Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.inline.} =
+    withLock(location, order):
+      location.nonAtomicValue = desired
+
+  proc exchange*[T: not Trivial](location: var Atomic[T]; desired: T; order: MemoryOrder = moSequentiallyConsistent): T {.inline.} =
+    withLock(location, order):
+      result = location.nonAtomicValue
+      location.nonAtomicValue = desired
+
+  proc compareExchange*[T: not Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+    withLock(location, success):
+      if location.nonAtomicValue != expected:
+        expected = location.nonAtomicValue
+        return false
+      expected = desired
+      swap(location.nonAtomicValue, expected)
+      return true
+
+  proc compareExchangeWeak*[T: not Trivial](location: var Atomic[T]; expected: var T; desired: T; success, failure: MemoryOrder): bool {.inline.} =
+    compareExchange(location, expected, desired, success, failure)
+
+  proc compareExchange*[T: not Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+    compareExchange(location, expected, desired, order, order)
+
+  proc compareExchangeWeak*[T: not Trivial](location: var Atomic[T]; expected: var T; desired: T; order: MemoryOrder = moSequentiallyConsistent): bool {.inline.} =
+    compareExchangeWeak(location, expected, desired, order, order)
+
+proc atomicInc*[T: SomeInteger](location: var Atomic[T]; value: T = 1) {.inline.} =
+  ## Atomically increments the atomic integer by some `value`.
+  discard location.fetchAdd(value)
+
+proc atomicDec*[T: SomeInteger](location: var Atomic[T]; value: T = 1) {.inline.} =
+  ## Atomically decrements the atomic integer by some `value`.
+  discard location.fetchSub(value)
+
+proc `+=`*[T: SomeInteger](location: var Atomic[T]; value: T) {.inline.} =
+  ## Atomically increments the atomic integer by some `value`.
+  discard location.fetchAdd(value)
+
+proc `-=`*[T: SomeInteger](location: var Atomic[T]; value: T) {.inline.} =
+  ## Atomically decrements the atomic integer by some `value`.
+  discard location.fetchSub(value)
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim
new file mode 100644
index 000000000..9bc3fd579
--- /dev/null
+++ b/lib/pure/concurrency/cpuinfo.nim
@@ -0,0 +1,110 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a proc to determine the number of CPUs / cores.
+
+runnableExamples:
+  doAssert countProcessors() > 0
+
+
+include "system/inclrtl"
+
+when defined(js):
+  import std/jsffi
+  proc countProcessorsImpl(): int =
+    when defined(nodejs):
+      let jsOs = require("os")
+      let jsObj = jsOs.cpus().length
+    else:
+      # `navigator.hardwareConcurrency`
+      # works on browser as well as deno.
+      let navigator{.importcpp.}: JsObject
+      let jsObj = navigator.hardwareConcurrency
+    result = jsObj.to int
+else:
+  when defined(posix) and not (defined(macosx) or defined(bsd)):
+    import std/posix
+
+  when defined(windows):
+    import std/private/win_getsysteminfo
+
+  when defined(freebsd) or defined(macosx):
+    {.emit: "#include <sys/types.h>".}
+
+  when defined(openbsd) or defined(netbsd):
+    {.emit: "#include <sys/param.h>".}
+
+  when defined(macosx) or defined(bsd):
+    # we HAVE to emit param.h before sysctl.h so we cannot use .header here
+    # either. The amount of archaic bullshit in Poonix based OSes is just insane.
+    {.emit: "#include <sys/sysctl.h>".}
+    {.push nodecl.}
+    when defined(macosx):
+      proc sysctlbyname(name: cstring,
+        oldp: pointer, oldlenp: var csize_t,
+        newp: pointer, newlen: csize_t): cint {.importc.}
+    let
+      CTL_HW{.importc.}: cint
+      HW_NCPU{.importc.}: cint
+    proc sysctl[I: static[int]](name: var array[I, cint], namelen: cuint,
+      oldp: pointer, oldlenp: var csize_t,
+      newp: pointer, newlen: csize_t): cint {.importc.}
+    {.pop.}
+
+  when defined(genode):
+    import genode/env
+
+    proc affinitySpaceTotal(env: GenodeEnvPtr): cuint {.
+      importcpp: "@->cpu().affinity_space().total()".}
+
+  when defined(haiku):
+    type
+      SystemInfo {.importc: "system_info", header: "<OS.h>".} = object
+        cpuCount {.importc: "cpu_count".}: uint32
+
+    proc getSystemInfo(info: ptr SystemInfo): int32 {.importc: "get_system_info",
+                                                      header: "<OS.h>".}
+
+  proc countProcessorsImpl(): int {.inline.} =
+    when defined(windows):
+      var
+        si: SystemInfo
+      getSystemInfo(addr si)
+      result = int(si.dwNumberOfProcessors)
+    elif defined(macosx) or defined(bsd):
+      let dest = addr result
+      var len = sizeof(result).csize_t
+      when defined(macosx):
+        # alias of "hw.activecpu"
+        if sysctlbyname("hw.logicalcpu", dest, len, nil, 0) == 0:
+          return
+      var mib = [CTL_HW, HW_NCPU]
+      if sysctl(mib, 2, dest, len, nil, 0) == 0:
+        return
+    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)
+    elif defined(genode):
+      result = runtimeEnv.affinitySpaceTotal().int
+    elif defined(haiku):
+      var sysinfo: SystemInfo
+      if getSystemInfo(addr sysinfo) == 0:
+        result = sysinfo.cpuCount.int
+    else:
+      result = sysconf(SC_NPROCESSORS_ONLN)
+    if result < 0: result = 0
+
+
+
+proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
+  ## Returns the number of the processors/cores the machine has.
+  ## Returns 0 if it cannot be detected.
+  countProcessorsImpl()
diff --git a/lib/pure/concurrency/cpuload.nim b/lib/pure/concurrency/cpuload.nim
new file mode 100644
index 000000000..bfbf16721
--- /dev/null
+++ b/lib/pure/concurrency/cpuload.nim
@@ -0,0 +1,106 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 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.
+##
+## Unstable API.
+
+when defined(windows):
+  import std/[winlean, os, strutils, math]
+
+  proc `-`(a, b: FILETIME): int64 = a.rdFileTime - b.rdFileTime
+elif defined(linux):
+  from std/cpuinfo import countProcessors
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+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: FILETIME
+    calls*: int
+
+proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
+  when defined(windows):
+    var
+      sysIdle, sysKernel, sysUser,
+        procCreation, procExit, procKernel, procUser: FILETIME
+    if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or
+        getProcessTimes(Handle(-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 = sysKernelDiff + sysUserDiff
+        procTotal = 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.float / sysTotal.float < 0.85:
+        result = doCreateThread
+    s.prevSysKernel = sysKernel
+    s.prevSysUser = sysUser
+    s.prevProcKernel = procKernel
+    s.prevProcUser = procUser
+  elif defined(linux):
+    proc fscanf(c: File, frmt: cstring) {.varargs, importc,
+      header: "<stdio.h>".}
+
+    var f: File
+    if 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:
+      result = doNothing
+  else:
+    # XXX implement this for other OSes
+    result = doNothing
+  inc s.calls
+
+when not defined(testing) and isMainModule and not defined(nimdoc):
+  import std/random
+
+  proc busyLoop() =
+    while true:
+      discard rand(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..06ed2fe54
--- /dev/null
+++ b/lib/pure/concurrency/threadpool.nim
@@ -0,0 +1,606 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+{.deprecated: "use the nimble packages `malebolgia`, `taskpools` or `weave` instead".}
+
+## Implements Nim's `parallel & spawn statements <manual_experimental.html#parallel-amp-spawn>`_.
+##
+## Unstable API.
+##
+## See also
+## ========
+## * `threads module <typedthreads.html>`_ for basic thread support
+## * `locks module <locks.html>`_ for locks and condition variables
+## * `asyncdispatch module <asyncdispatch.html>`_ for asynchronous IO
+
+when not compileOption("threads"):
+  {.error: "Threadpool requires --threads:on option.".}
+
+import std/[cpuinfo, cpuload, locks, os]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, typedthreads, sysatomics]
+
+{.push stackTrace:off.}
+
+type
+  Semaphore = object
+    c: Cond
+    L: Lock
+    counter: int
+
+proc initSemaphore(cv: var Semaphore) =
+  initCond(cv.c)
+  initLock(cv.L)
+
+proc destroySemaphore(cv: var Semaphore) {.inline.} =
+  deinitCond(cv.c)
+  deinitLock(cv.L)
+
+proc blockUntil(cv: var Semaphore) =
+  acquire(cv.L)
+  while cv.counter <= 0:
+    wait(cv.c, cv.L)
+  dec cv.counter
+  release(cv.L)
+
+proc signal(cv: var Semaphore) =
+  acquire(cv.L)
+  inc cv.counter
+  release(cv.L)
+  signal(cv.c)
+
+const CacheLineSize = 64 # true for most archs
+
+type
+  Barrier {.compilerproc.} = object
+    entered: int
+    cv: Semaphore # Semaphore takes 3 words at least
+    left {.align(CacheLineSize).}: int
+    interest {.align(CacheLineSize).} : bool # whether 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()
+  # We may not have seen the final value of b.entered yet,
+  # so we need to check for >= instead of ==.
+  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.initSemaphore()
+    fence()
+    b.interest = true
+    fence()
+    while b.left != b.entered: blockUntil(b.cv)
+    destroySemaphore(b.cv)
+
+{.pop.}
+
+# ----------------------------------------------------------------------------
+
+type
+  AwaitInfo = object
+    cv: Semaphore
+    idx: int
+
+  FlowVarBase* = ref FlowVarBaseObj ## Untyped base class for `FlowVar[T] <#FlowVar>`_.
+  FlowVarBaseObj {.acyclic.} = object of RootObj
+    ready, usesSemaphore, awaited: bool
+    cv: Semaphore  # for 'blockUntilAny' support
+    ai: ptr AwaitInfo
+    idx: int
+    data: pointer  # we incRef and unref it to keep it alive; note this MUST NOT
+                   # be RootRef here otherwise the wrong GC keeps track of it!
+    owner: pointer # ptr Worker
+
+  FlowVarObj[T] {.acyclic.} = object of FlowVarBaseObj
+    blob: T
+
+  FlowVar*[T] {.compilerproc.} = ref FlowVarObj[T] ## A data flow variable.
+
+  ToFreeQueue = object
+    len: int
+    lock: Lock
+    empty: Semaphore
+    data: array[128, pointer]
+
+  WorkerProc = proc (thread, args: pointer) {.nimcall, gcsafe.}
+  Worker = object
+    taskArrived: Semaphore
+    taskStarted: Semaphore #\
+    # 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
+    readyForTask: Semaphore
+
+const threadpoolWaitMs {.intdefine.}: int = 100
+
+proc blockUntil*(fv: var FlowVarBaseObj) =
+  ## Waits until the value for `fv` arrives.
+  ##
+  ## Usually it is not necessary to call this explicitly.
+  if fv.usesSemaphore and not fv.awaited:
+    fv.awaited = true
+    blockUntil(fv.cv)
+    destroySemaphore(fv.cv)
+
+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)
+    blockUntil(w.taskStarted)
+    result = true
+
+proc cleanFlowVars(w: ptr Worker) =
+  let q = addr(w.q)
+  acquire(q.lock)
+  for i in 0 ..< q.len:
+    GC_unref(cast[RootRef](q.data[i]))
+    #echo "GC_unref"
+  q.len = 0
+  release(q.lock)
+
+proc wakeupWorkerToProcessQueue(w: ptr Worker) =
+  # we have to ensure it's us who wakes up the owning thread.
+  # This is quite horrible code, but it runs so rarely that it doesn't matter:
+  while not cas(addr w.ready, true, false):
+    cpuRelax()
+    discard
+  w.data = nil
+  w.f = proc (w, a: pointer) {.nimcall.} =
+    let w = cast[ptr Worker](w)
+    cleanFlowVars(w)
+    signal(w.q.empty)
+  signal(w.taskArrived)
+
+proc attach(fv: FlowVarBase; i: int): bool =
+  acquire(fv.cv.L)
+  if fv.cv.counter <= 0:
+    fv.idx = i
+    result = true
+  else:
+    result = false
+  release(fv.cv.L)
+
+proc finished(fv: var FlowVarBaseObj) =
+  doAssert fv.ai.isNil, "flowVar is still attached to an 'blockUntilAny'"
+  # we have to protect against the rare cases where the owner of the flowVar
+  # simply disregards the flowVar and yet the "flowVar" has not yet written
+  # anything to it:
+  blockUntil(fv)
+  if fv.data.isNil: return
+  let owner = cast[ptr Worker](fv.owner)
+  let q = addr(owner.q)
+  acquire(q.lock)
+  while not (q.len < q.data.len):
+    #echo "EXHAUSTED!"
+    release(q.lock)
+    wakeupWorkerToProcessQueue(owner)
+    blockUntil(q.empty)
+    acquire(q.lock)
+  q.data[q.len] = cast[pointer](fv.data)
+  inc q.len
+  release(q.lock)
+  fv.data = nil
+  # the worker thread waits for "data" to be set to nil before shutting down
+  owner.data = nil
+
+proc `=destroy`[T](fv: var FlowVarObj[T]) =
+  finished(fv)
+  `=destroy`(fv.blob)
+
+proc nimCreateFlowVar[T](): FlowVar[T] {.compilerproc.} =
+  new(result)
+
+proc nimFlowVarCreateSemaphore(fv: FlowVarBase) {.compilerproc.} =
+  fv.cv.initSemaphore()
+  fv.usesSemaphore = 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.usesSemaphore:
+    signal(fv.cv)
+
+proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) =
+  ## Blocks until `fv` is available and then passes its value
+  ## to `action`.
+  ##
+  ## Note that due to Nim's parameter passing semantics, this
+  ## means that `T` doesn't need to be copied, so `awaitAndThen` can
+  ## sometimes be more efficient than the `^ proc <#^,FlowVar[T]>`_.
+  blockUntil(fv[])
+  when defined(nimV2):
+    action(fv.blob)
+  elif 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 unsafeRead*[T](fv: FlowVar[ref T]): ptr T =
+  ## Blocks until the value is available and then returns this value.
+  blockUntil(fv[])
+  when defined(nimV2):
+    result = cast[ptr T](fv.blob)
+  else:
+    result = cast[ptr T](fv.data)
+  finished(fv[])
+
+proc `^`*[T](fv: FlowVar[T]): T =
+  ## Blocks until the value is available and then returns this value.
+  blockUntil(fv[])
+  when not defined(nimV2) and (T is string or T is seq or T is ref):
+    deepCopy result, cast[T](fv.data)
+  else:
+    result = fv.blob
+  finished(fv[])
+
+proc blockUntilAny*(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 `blockUntilAny` at the same time.
+  ## That means if you `blockUntilAny([a,b])` and `blockUntilAny([b,c])`
+  ## the second call will only block until `c`. If there is no `flowVar` left
+  ## to be able to wait on, -1 is returned.
+  ##
+  ## **Note:** This results in non-deterministic behaviour and should be avoided.
+  var ai: AwaitInfo
+  ai.cv.initSemaphore()
+  var conflicts = 0
+  result = -1
+  for i in 0 .. flowVars.high:
+    if cas(addr flowVars[i].ai, nil, addr ai):
+      if not attach(flowVars[i], i):
+        result = i
+        break
+    else:
+      inc conflicts
+  if conflicts < flowVars.len:
+    if result < 0:
+      blockUntil(ai.cv)
+      result = ai.idx
+    for i in 0 .. flowVars.high:
+      discard cas(addr flowVars[i].ai, addr ai, nil)
+  destroySemaphore(ai.cv)
+
+proc isReady*(fv: FlowVarBase): bool =
+  ## Determines whether the specified `FlowVarBase`'s value is available.
+  ##
+  ## If `true`, awaiting `fv` will not block.
+  if fv.usesSemaphore and not fv.awaited:
+    acquire(fv.cv.L)
+    result = fv.cv.counter > 0
+    release(fv.cv.L)
+  else:
+    result = true
+
+proc nimArgsPassingDone(p: pointer) {.compilerproc.} =
+  let w = cast[ptr Worker](p)
+  signal(w.taskStarted)
+
+const
+  MaxThreadPoolSize* {.intdefine.} = 256 ## Maximum size of the thread pool. 256 threads
+                                         ## should be good enough for anybody ;-)
+  MaxDistinguishedThread* {.intdefine.} = 32 ## Maximum number of "distinguished" threads.
+
+type
+  ThreadId* = range[0..MaxDistinguishedThread-1] ## A thread identifier.
+
+var
+  currentPoolSize: int
+  maxPoolSize = MaxThreadPoolSize
+  minPoolSize = 4
+  gSomeReady: Semaphore
+  readyWorker: ptr Worker
+
+# A workaround for recursion deadlock issue
+# https://github.com/nim-lang/Nim/issues/4597
+var
+  numSlavesLock: Lock
+  numSlavesRunning {.guard: numSlavesLock.}: int
+  numSlavesWaiting {.guard: numSlavesLock.}: int
+  isSlave {.threadvar.}: bool
+
+numSlavesLock.initLock
+
+gSomeReady.initSemaphore()
+
+proc slave(w: ptr Worker) {.thread.} =
+  isSlave = true
+  while true:
+    if w.shutdown:
+      w.shutdown = false
+      atomicDec currentPoolSize
+      while true:
+        if w.data != nil:
+          sleep(threadpoolWaitMs)
+        else:
+          # The flowvar finalizer ("finished()") set w.data to nil, so we can
+          # safely terminate the thread.
+          #
+          # TODO: look for scenarios in which the flowvar is never finalized, so
+          # a shut down thread gets stuck in this loop until the main thread exits.
+          break
+      break
+    when declared(atomicStoreN):
+      atomicStoreN(addr(w.ready), true, ATOMIC_SEQ_CST)
+    else:
+      w.ready = true
+    readyWorker = w
+    signal(gSomeReady)
+    blockUntil(w.taskArrived)
+    # XXX Somebody needs to look into this (why does this assertion fail
+    # in Visual Studio?)
+    when not defined(vcc) and not defined(tcc): assert(not w.ready)
+
+    withLock numSlavesLock:
+      inc numSlavesRunning
+
+    w.f(w, w.data)
+
+    withLock numSlavesLock:
+      dec numSlavesRunning
+
+    if w.q.len != 0: w.cleanFlowVars
+
+proc distinguishedSlave(w: ptr Worker) {.thread.} =
+  while true:
+    when declared(atomicStoreN):
+      atomicStoreN(addr(w.ready), true, ATOMIC_SEQ_CST)
+    else:
+      w.ready = true
+    signal(w.readyForTask)
+    blockUntil(w.taskArrived)
+    assert(not w.ready)
+    w.f(w, w.data)
+    if w.q.len != 0: w.cleanFlowVars
+
+var
+  workers: array[MaxThreadPoolSize, Thread[ptr Worker]]
+  workersData: array[MaxThreadPoolSize, Worker]
+
+  distinguished: array[MaxDistinguishedThread, Thread[ptr Worker]]
+  distinguishedData: array[MaxDistinguishedThread, Worker]
+
+when defined(nimPinToCpu):
+  var gCpus: Natural
+
+proc setMinPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## Sets the minimum thread pool size. The default value of this is 4.
+  minPoolSize = size
+
+proc setMaxPoolSize*(size: range[1..MaxThreadPoolSize]) =
+  ## Sets the maximum thread pool size. The default value of this
+  ## is `MaxThreadPoolSize <#MaxThreadPoolSize>`_.
+  maxPoolSize = size
+  if currentPoolSize > maxPoolSize:
+    for i in maxPoolSize..currentPoolSize-1:
+      let w = addr(workersData[i])
+      w.shutdown = true
+
+when defined(nimRecursiveSpawn):
+  var localThreadId {.threadvar.}: int
+
+proc activateWorkerThread(i: int) {.noinline.} =
+  workersData[i].taskArrived.initSemaphore()
+  workersData[i].taskStarted.initSemaphore()
+  workersData[i].initialized = true
+  workersData[i].q.empty.initSemaphore()
+  initLock(workersData[i].q.lock)
+  createThread(workers[i], slave, addr(workersData[i]))
+  when defined(nimRecursiveSpawn):
+    localThreadId = i+1
+  when defined(nimPinToCpu):
+    if gCpus > 0: pinToCpu(workers[i], i mod gCpus)
+
+proc activateDistinguishedThread(i: int) {.noinline.} =
+  distinguishedData[i].taskArrived.initSemaphore()
+  distinguishedData[i].taskStarted.initSemaphore()
+  distinguishedData[i].initialized = true
+  distinguishedData[i].q.empty.initSemaphore()
+  initLock(distinguishedData[i].q.lock)
+  distinguishedData[i].readyForTask.initSemaphore()
+  createThread(distinguished[i], distinguishedSlave, addr(distinguishedData[i]))
+
+proc setup() =
+  let p = countProcessors()
+  when defined(nimPinToCpu):
+    gCpus = p
+  currentPoolSize = min(p, MaxThreadPoolSize)
+  readyWorker = addr(workersData[0])
+  for i in 0..<currentPoolSize: activateWorkerThread(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 the `spawnX template
+  ## <#spawnX.t>`_ instead.
+  result = gSomeReady.counter > 0
+
+proc spawn*(call: sink typed) {.magic: "Spawn".} =
+  ## Always spawns a new task, so that the `call` is never executed on
+  ## the calling thread.
+  ##
+  ## `call` has to be a proc call `p(...)` where `p` is gcsafe and has a
+  ## return type that is either `void` or compatible with `FlowVar[T]`.
+  discard "It uses `nimSpawn3` internally"
+
+proc pinnedSpawn*(id: ThreadId; call: sink typed) {.magic: "Spawn".} =
+  ## Always spawns a new task on the worker thread with `id`, so that
+  ## the `call` is **always** executed on the thread.
+  ##
+  ## `call` has to be a proc call `p(...)` where `p` is gcsafe and has a
+  ## return type that is either `void` or compatible with `FlowVar[T]`.
+  discard "It uses `nimSpawn4` internally"
+
+template spawnX*(call) =
+  ## Spawns a new task if a CPU core is ready, otherwise executes the
+  ## call in the calling thread.
+  ##
+  ## Usually, it is advised to use the `spawn proc <#spawn,sinktyped>`_
+  ## in order to not block the producer for an unknown amount of time.
+  ##
+  ## `call` has to be a 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: untyped) {.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 <manual_experimental.html#parallel-amp-spawn>`_
+  ## for further information.
+
+var
+  state: ThreadPoolState
+  stateLock: Lock
+
+initLock stateLock
+
+proc nimSpawn3(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):
+        if currentPoolSize < minPoolSize:
+          if not workersData[currentPoolSize].initialized:
+            activateWorkerThread(currentPoolSize)
+          let w = addr(workersData[currentPoolSize])
+          atomicInc currentPoolSize
+          if selectWorker(w, fn, data):
+            release(stateLock)
+            return
+
+        case advice(state)
+        of doNothing: discard
+        of doCreateThread:
+          if currentPoolSize < maxPoolSize:
+            if not workersData[currentPoolSize].initialized:
+              activateWorkerThread(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.
+    when defined(nimRecursiveSpawn):
+      if localThreadId > 0:
+        # we are a worker thread, so instead of waiting for something which
+        # might as well never happen (see tparallel_quicksort), we run the task
+        # on the current thread instead.
+        var self = addr(workersData[localThreadId-1])
+        fn(self, data)
+        blockUntil(self.taskStarted)
+        return
+
+    if isSlave:
+      # Run under lock until `numSlavesWaiting` increment to avoid a
+      # race (otherwise two last threads might start waiting together)
+      withLock numSlavesLock:
+        if numSlavesRunning <= numSlavesWaiting + 1:
+          # All the other slaves are waiting
+          # If we wait now, we-re deadlocked until
+          # an external spawn happens !
+          if currentPoolSize < maxPoolSize:
+            if not workersData[currentPoolSize].initialized:
+              activateWorkerThread(currentPoolSize)
+            let w = addr(workersData[currentPoolSize])
+            atomicInc currentPoolSize
+            if selectWorker(w, fn, data):
+              return
+          else:
+            # There is no place in the pool. We're deadlocked.
+            # echo "Deadlock!"
+            discard
+
+        inc numSlavesWaiting
+
+    blockUntil(gSomeReady)
+
+    if isSlave:
+      withLock numSlavesLock:
+        dec numSlavesWaiting
+
+var
+  distinguishedLock: Lock
+
+initLock distinguishedLock
+
+proc nimSpawn4(fn: WorkerProc; data: pointer; id: ThreadId) {.compilerproc.} =
+  acquire(distinguishedLock)
+  if not distinguishedData[id].initialized:
+    activateDistinguishedThread(id)
+  release(distinguishedLock)
+  while true:
+    if selectWorker(addr(distinguishedData[id]), fn, data): break
+    blockUntil(distinguishedData[id].readyForTask)
+
+
+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
+    sleep(threadpoolWaitMs)
+    # We cannot "blockUntil(gSomeReady)" because workers may be shut down between
+    # the time we establish that some are not "ready" and the time we wait for a
+    # "signal(gSomeReady)" from inside "slave()" that can never come.
+
+setup()
diff --git a/lib/pure/concurrency/threadpool.nim.cfg b/lib/pure/concurrency/threadpool.nim.cfg
new file mode 100644
index 000000000..aed303eef
--- /dev/null
+++ b/lib/pure/concurrency/threadpool.nim.cfg
@@ -0,0 +1 @@
+--threads:on
diff --git a/lib/pure/cookies.nim b/lib/pure/cookies.nim
new file mode 100644
index 000000000..f628aaf6b
--- /dev/null
+++ b/lib/pure/cookies.nim
@@ -0,0 +1,81 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements helper procs for parsing Cookies.
+
+import std/[strtabs, times, options]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  SameSite* {.pure.} = enum ## The SameSite cookie attribute.
+                            ## `Default` means that `setCookie`
+                            ## proc will not set `SameSite` attribute.
+    Default, None, Lax, Strict
+
+proc parseCookies*(s: string): StringTableRef =
+  ## Parses cookies into a string table.
+  ##
+  ## The proc is meant to parse the Cookie header set by a client, not the
+  ## "Set-Cookie" header set by servers.
+  runnableExamples:
+    import std/strtabs
+    let cookieJar = parseCookies("a=1; foo=bar")
+    assert cookieJar["a"] == "1"
+    assert cookieJar["foo"] == "bar"
+
+  result = newStringTable(modeCaseInsensitive)
+  var i = 0
+  while true:
+    while i < s.len and (s[i] == ' ' or s[i] == '\t'): inc(i)
+    var keystart = i
+    while i < s.len and s[i] != '=': inc(i)
+    var keyend = i-1
+    if i >= s.len: break
+    inc(i) # skip '='
+    var valstart = i
+    while i < s.len and s[i] != ';': inc(i)
+    result[substr(s, keystart, keyend)] = substr(s, valstart, i-1)
+    if i >= s.len: break
+    inc(i) # skip ';'
+
+proc setCookie*(key, value: string, domain = "", path = "",
+                expires = "", noName = false,
+                secure = false, httpOnly = false,
+                maxAge = none(int), sameSite = SameSite.Default): string =
+  ## Creates a command in the format of
+  ## `Set-Cookie: key=value; Domain=...; ...`
+  ##
+  ## .. tip:: Cookies can be vulnerable. Consider setting `secure=true`, `httpOnly=true` and `sameSite=Strict`.
+  result = ""
+  if not noName: result.add("Set-Cookie: ")
+  result.add key & "=" & value
+  if domain != "": result.add("; Domain=" & domain)
+  if path != "": result.add("; Path=" & path)
+  if expires != "": result.add("; Expires=" & expires)
+  if secure: result.add("; Secure")
+  if httpOnly: result.add("; HttpOnly")
+  if maxAge.isSome: result.add("; Max-Age=" & $maxAge.unsafeGet)
+
+  if sameSite != SameSite.Default:
+    if sameSite == SameSite.None:
+      doAssert secure, "Cookies with SameSite=None must specify the Secure attribute!"
+    result.add("; SameSite=" & $sameSite)
+
+proc setCookie*(key, value: string, expires: DateTime|Time,
+                domain = "", path = "", noName = false,
+                secure = false, httpOnly = false,
+                maxAge = none(int), sameSite = SameSite.Default): string =
+  ## Creates a command in the format of
+  ## `Set-Cookie: key=value; Domain=...; ...`
+  result = setCookie(key, value, domain, path,
+                   format(expires.utc, "ddd',' dd MMM yyyy HH:mm:ss 'GMT'"),
+                   noName, secure, httpOnly, maxAge, sameSite)
diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim
new file mode 100644
index 000000000..24836e316
--- /dev/null
+++ b/lib/pure/coro.nim
@@ -0,0 +1,345 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Rokas Kupstys
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Nim coroutines implementation, supports several context switching methods:
+## ========  ============
+## ucontext  available on unix and alike (default)
+## setjmp    available on unix and alike (x86/64 only)
+## fibers    available and required on windows.
+## ========  ============
+##
+## -d:nimCoroutines               Required to build this module.
+## -d:nimCoroutinesUcontext       Use ucontext backend.
+## -d:nimCoroutinesSetjmp         Use setjmp backend.
+## -d:nimCoroutinesSetjmpBundled  Use bundled setjmp implementation.
+##
+## Unstable API.
+
+import system/coro_detection
+
+when not nimCoroutines and not defined(nimdoc):
+  when defined(noNimCoroutines):
+    {.error: "Coroutines can not be used with -d:noNimCoroutines".}
+  else:
+    {.error: "Coroutines require -d:nimCoroutines".}
+
+import std/[os, lists]
+include system/timers
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+const defaultStackSize = 512 * 1024
+const useOrcArc = defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc)
+
+when useOrcArc:
+  proc nimGC_setStackBottom*(theStackBottom: pointer) = discard
+
+proc GC_addStack(bottom: pointer) {.cdecl, importc.}
+proc GC_removeStack(bottom: pointer) {.cdecl, importc.}
+proc GC_setActiveStack(bottom: pointer) {.cdecl, importc.}
+proc GC_getActiveStack() : pointer {.cdecl, importc.}
+
+const
+  CORO_BACKEND_UCONTEXT = 0
+  CORO_BACKEND_SETJMP = 1
+  CORO_BACKEND_FIBERS = 2
+
+when defined(windows):
+  const coroBackend = CORO_BACKEND_FIBERS
+  when defined(nimCoroutinesUcontext):
+    {.warning: "ucontext coroutine backend is not available on windows, defaulting to fibers.".}
+  when defined(nimCoroutinesSetjmp):
+    {.warning: "setjmp coroutine backend is not available on windows, defaulting to fibers.".}
+elif defined(haiku) or defined(openbsd):
+  const coroBackend = CORO_BACKEND_SETJMP
+  when defined(nimCoroutinesUcontext):
+    {.warning: "ucontext coroutine backend is not available on haiku, defaulting to setjmp".}
+elif defined(nimCoroutinesSetjmp) or defined(nimCoroutinesSetjmpBundled):
+  const coroBackend = CORO_BACKEND_SETJMP
+else:
+  const coroBackend = CORO_BACKEND_UCONTEXT
+
+when coroBackend == CORO_BACKEND_FIBERS:
+  import std/winlean
+  type
+    Context = pointer
+
+elif coroBackend == CORO_BACKEND_UCONTEXT:
+  type
+    stack_t {.importc, header: "<ucontext.h>".} = object
+      ss_sp: pointer
+      ss_flags: int
+      ss_size: int
+
+    ucontext_t {.importc, header: "<ucontext.h>".} = object
+      uc_link: ptr ucontext_t
+      uc_stack: stack_t
+
+    Context = ucontext_t
+
+  proc getcontext(context: var ucontext_t): int32 {.importc,
+      header: "<ucontext.h>".}
+  proc setcontext(context: var ucontext_t): int32 {.importc,
+      header: "<ucontext.h>".}
+  proc swapcontext(fromCtx, toCtx: var ucontext_t): int32 {.importc,
+      header: "<ucontext.h>".}
+  proc makecontext(context: var ucontext_t, fn: pointer, argc: int32) {.importc,
+      header: "<ucontext.h>", varargs.}
+
+elif coroBackend == CORO_BACKEND_SETJMP:
+  proc coroExecWithStack*(fn: pointer, stack: pointer) {.noreturn,
+      importc: "narch_$1", fastcall.}
+  when defined(amd64):
+    {.compile: "../arch/x86/amd64.S".}
+  elif defined(i386):
+    {.compile: "../arch/x86/i386.S".}
+  else:
+    # coroExecWithStack is defined in assembly. To support other platforms
+    # please provide implementation of this procedure.
+    {.error: "Unsupported architecture.".}
+
+  when defined(nimCoroutinesSetjmpBundled):
+    # Use setjmp/longjmp implementation shipped with compiler.
+    when defined(amd64):
+      type
+        JmpBuf = array[0x50 + 0x10, uint8]
+    elif defined(i386):
+      type
+        JmpBuf = array[0x1C, uint8]
+    else:
+      # Bundled setjmp/longjmp are defined in assembly. To support other
+      # platforms please provide implementations of these procedures.
+      {.error: "Unsupported architecture.".}
+
+    proc setjmp(ctx: var JmpBuf): int {.importc: "narch_$1".}
+    proc longjmp(ctx: JmpBuf, ret = 1) {.importc: "narch_$1".}
+  else:
+    # Use setjmp/longjmp implementation provided by the system.
+    type
+      JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = object
+
+    proc setjmp(ctx: var JmpBuf): int {.importc, header: "<setjmp.h>".}
+    proc longjmp(ctx: JmpBuf, ret = 1) {.importc, header: "<setjmp.h>".}
+
+  type
+    Context = JmpBuf
+
+when defined(unix):
+  # GLibc fails with "*** longjmp causes uninitialized stack frame ***" because
+  # our custom stacks are not initialized to a magic value.
+  when defined(osx):
+    # workaround: error: The deprecated ucontext routines require _XOPEN_SOURCE to be defined
+    const extra = " -D_XOPEN_SOURCE"
+  else:
+    const extra = ""
+  {.passc: "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0" & extra.}
+
+const
+  CORO_CREATED = 0
+  CORO_EXECUTING = 1
+  CORO_FINISHED = 2
+
+type
+  Stack {.pure.} = object
+    top: pointer    # Top of the stack. Pointer used for deallocating stack if we own it.
+    bottom: pointer # Very bottom of the stack, acts as unique stack identifier.
+    size: int
+
+  Coroutine {.pure.} = object
+    execContext: Context
+    fn: proc()
+    state: int
+    lastRun: Ticks
+    sleepTime: float
+    stack: Stack
+    reference: CoroutineRef
+
+  CoroutinePtr = ptr Coroutine
+
+  CoroutineRef* = ref object
+    ## CoroutineRef holds a pointer to actual coroutine object. Public API always returns
+    ## CoroutineRef instead of CoroutinePtr in order to allow holding a reference to coroutine
+    ## object while it can be safely deallocated by coroutine scheduler loop. In this case
+    ## Coroutine.reference.coro is set to nil. Public API checks for it being nil and
+    ## gracefully fails if it is nil.
+    coro: CoroutinePtr
+
+  CoroutineLoopContext = ref object
+    coroutines: DoublyLinkedList[CoroutinePtr]
+    current: DoublyLinkedNode[CoroutinePtr]
+    loop: Coroutine
+    ncbottom: pointer # non coroutine stack botttom
+
+var ctx {.threadvar.}: CoroutineLoopContext
+
+proc getCurrent(): CoroutinePtr =
+  ## Returns current executing coroutine object.
+  var node = ctx.current
+  if node != nil:
+    return node.value
+  return nil
+
+proc initialize() =
+  ## Initializes coroutine state of current thread.
+  if ctx == nil:
+    ctx = CoroutineLoopContext()
+    ctx.coroutines = initDoublyLinkedList[CoroutinePtr]()
+    ctx.loop = Coroutine()
+    ctx.loop.state = CORO_EXECUTING
+    when not useOrcArc:
+      ctx.ncbottom = GC_getActiveStack()
+    when coroBackend == CORO_BACKEND_FIBERS:
+      ctx.loop.execContext = ConvertThreadToFiberEx(nil, FIBER_FLAG_FLOAT_SWITCH)
+
+proc runCurrentTask()
+
+proc switchTo(current, to: CoroutinePtr) =
+  ## Switches execution from `current` into `to` context.
+  to.lastRun = getTicks()
+  # Update position of current stack so gc invoked from another stack knows how much to scan.
+  when not useOrcArc:
+    GC_setActiveStack(current.stack.bottom)
+  nimGC_setStackBottom(current.stack.bottom)
+  var frame = getFrameState()
+  block:
+    # Execution will switch to another fiber now. We do not need to update current stack
+    when coroBackend == CORO_BACKEND_FIBERS:
+      SwitchToFiber(to.execContext)
+    elif coroBackend == CORO_BACKEND_UCONTEXT:
+      discard swapcontext(current.execContext, to.execContext)
+    elif coroBackend == CORO_BACKEND_SETJMP:
+      var res = setjmp(current.execContext)
+      if res == 0:
+        if to.state == CORO_EXECUTING:
+          # Coroutine is resumed.
+          longjmp(to.execContext, 1)
+        elif to.state == CORO_CREATED:
+          # Coroutine is started.
+          coroExecWithStack(runCurrentTask, to.stack.bottom)
+          #raiseAssert "unreachable"
+    else:
+      {.error: "Invalid coroutine backend set.".}
+  # Execution was just resumed. Restore frame information and set active stack.
+  setFrameState(frame)
+  when not useOrcArc:
+    GC_setActiveStack(current.stack.bottom)
+  nimGC_setStackBottom(ctx.ncbottom)
+
+proc suspend*(sleepTime: float = 0) =
+  ## Stops coroutine execution and resumes no sooner than after `sleeptime` seconds.
+  ## Until then other coroutines are executed.
+  var current = getCurrent()
+  current.sleepTime = sleepTime
+  nimGC_setStackBottom(ctx.ncbottom)
+  switchTo(current, addr(ctx.loop))
+
+proc runCurrentTask() =
+  ## Starts execution of current coroutine and updates it's state through coroutine's life.
+  var sp {.volatile.}: pointer
+  sp = addr(sp)
+  block:
+    var current = getCurrent()
+    current.stack.bottom = sp
+    nimGC_setStackBottom(current.stack.bottom)
+    # Execution of new fiber just started. Since it was entered not through `switchTo` we
+    # have to set active stack here as well. GC_removeStack() has to be called in main loop
+    # because we still need stack available in final suspend(0) call from which we will not
+    # return.
+    when not useOrcArc:
+      GC_addStack(sp)
+      # Activate current stack because we are executing in a new coroutine.
+      GC_setActiveStack(sp)
+    current.state = CORO_EXECUTING
+    try:
+      current.fn() # Start coroutine execution
+    except:
+      echo "Unhandled exception in coroutine."
+      writeStackTrace()
+    current.state = CORO_FINISHED
+  nimGC_setStackBottom(ctx.ncbottom)
+  suspend(0) # Exit coroutine without returning from coroExecWithStack()
+  raiseAssert "unreachable"
+
+proc start*(c: proc(), stacksize: int = defaultStackSize): CoroutineRef {.discardable.} =
+  ## Schedule coroutine for execution. It does not run immediately.
+  if ctx == nil:
+    initialize()
+
+  var coro: CoroutinePtr
+  when coroBackend == CORO_BACKEND_FIBERS:
+    coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine)))
+    coro.execContext = CreateFiberEx(stacksize, stacksize,
+      FIBER_FLAG_FLOAT_SWITCH,
+      (proc(p: pointer) {.stdcall.} = runCurrentTask()), nil)
+  else:
+    coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine) + stacksize))
+    coro.stack.top = cast[pointer](cast[int](coro) + sizeof(Coroutine))
+    coro.stack.bottom = cast[pointer](cast[int](coro.stack.top) + stacksize)
+    when coroBackend == CORO_BACKEND_UCONTEXT:
+      discard getcontext(coro.execContext)
+      coro.execContext.uc_stack.ss_sp = coro.stack.top
+      coro.execContext.uc_stack.ss_size = stacksize
+      coro.execContext.uc_link = addr(ctx.loop.execContext)
+      makecontext(coro.execContext, runCurrentTask, 0)
+  coro.fn = c
+  coro.stack.size = stacksize
+  coro.state = CORO_CREATED
+  coro.reference = CoroutineRef(coro: coro)
+  ctx.coroutines.append(coro)
+  return coro.reference
+
+proc run*() =
+  ## Starts main coroutine scheduler loop which exits when all coroutines exit.
+  ## Calling this proc starts execution of first coroutine.
+  initialize()
+  ctx.current = ctx.coroutines.head
+  var minDelay: float = 0
+  while ctx.current != nil:
+    var current = getCurrent()
+
+    var remaining = current.sleepTime - (float(getTicks() - current.lastRun) / 1_000_000_000)
+    if remaining <= 0:
+      # Save main loop context. Suspending coroutine will resume after this statement with
+      switchTo(addr(ctx.loop), current)
+    else:
+      if minDelay > 0 and remaining > 0:
+        minDelay = min(remaining, minDelay)
+      else:
+        minDelay = remaining
+
+    if current.state == CORO_FINISHED:
+      var next = ctx.current.prev
+      if next == nil:
+        # If first coroutine ends then `prev` is nil even if more coroutines
+        # are to be scheduled.
+        next = ctx.current.next
+      current.reference.coro = nil
+      ctx.coroutines.remove(ctx.current)
+      when not useOrcArc:
+        GC_removeStack(current.stack.bottom)
+      when coroBackend == CORO_BACKEND_FIBERS:
+        DeleteFiber(current.execContext)
+      else:
+        dealloc(current.stack.top)
+      dealloc(current)
+      ctx.current = next
+    elif ctx.current == nil or ctx.current.next == nil:
+      ctx.current = ctx.coroutines.head
+      os.sleep(int(minDelay * 1000))
+    else:
+      ctx.current = ctx.current.next
+
+proc alive*(c: CoroutineRef): bool = c.coro != nil and c.coro.state != CORO_FINISHED
+  ## Returns `true` if coroutine has not returned, `false` otherwise.
+
+proc wait*(c: CoroutineRef, interval = 0.01) =
+  ## Returns only after coroutine `c` has returned. `interval` is time in seconds how often.
+  while alive(c):
+    suspend(interval)
diff --git a/lib/pure/coro.nimcfg b/lib/pure/coro.nimcfg
new file mode 100644
index 000000000..b011bc585
--- /dev/null
+++ b/lib/pure/coro.nimcfg
@@ -0,0 +1 @@
+-d:nimCoroutines
diff --git a/lib/pure/cstrutils.nim b/lib/pure/cstrutils.nim
new file mode 100644
index 000000000..c907e54d8
--- /dev/null
+++ b/lib/pure/cstrutils.nim
@@ -0,0 +1,122 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module supports helper routines for working with `cstring`
+## without having to convert `cstring` to `string`, in order to
+## save allocations.
+##
+## See also
+## ========
+## * `strutils module <strutils.html>`_ for working with `string`
+
+include system/inclrtl
+import std/private/strimpl
+
+
+when defined(js):
+  func jsStartsWith(s, prefix: cstring): bool {.importjs: "#.startsWith(#)".}
+  func jsEndsWith(s, suffix: cstring): bool {.importjs: "#.endsWith(#)".}
+
+
+func startsWith*(s, prefix: cstring): bool {.rtl, extern: "csuStartsWith".} =
+  ## Returns true if `s` starts with `prefix`.
+  ##
+  ## The JS backend uses the native `String.prototype.startsWith` function.
+  runnableExamples:
+    assert startsWith(cstring"Hello, Nimion", cstring"Hello")
+    assert not startsWith(cstring"Hello, Nimion", cstring"Nimion")
+    assert startsWith(cstring"Hello", cstring"")
+
+  when nimvm:
+    startsWithImpl(s, prefix)
+  else:
+    when defined(js):
+      result = jsStartsWith(s, prefix)
+    else:
+      var i = 0
+      while true:
+        if prefix[i] == '\0': return true
+        if s[i] != prefix[i]: return false
+        inc(i)
+
+func endsWith*(s, suffix: cstring): bool {.rtl, extern: "csuEndsWith".} =
+  ## Returns true if `s` ends with `suffix`.
+  ##
+  ## The JS backend uses the native `String.prototype.endsWith` function.
+  runnableExamples:
+    assert endsWith(cstring"Hello, Nimion", cstring"Nimion")
+    assert not endsWith(cstring"Hello, Nimion", cstring"Hello")
+    assert endsWith(cstring"Hello", cstring"")
+
+  when nimvm:
+    endsWithImpl(s, suffix)
+  else:
+    when defined(js):
+      result = jsEndsWith(s, suffix)
+    else:
+      let slen = s.len
+      var i = 0
+      var j = slen - len(suffix)
+      while i + j <% slen:
+        if s[i + j] != suffix[i]: return false
+        inc(i)
+      if suffix[i] == '\0': return true
+
+func cmpIgnoreStyle*(a, b: cstring): int {.rtl, extern: "csuCmpIgnoreStyle".} =
+  ## Semantically the same as `cmp(normalize($a), normalize($b))`. It
+  ## is just optimized to not allocate temporary strings. This should
+  ## NOT be used to compare Nim identifier names, use `macros.eqIdent`
+  ## for that. Returns:
+  ## * 0 if `a == b`
+  ## * < 0 if `a < b`
+  ## * \> 0 if `a > b`
+  runnableExamples:
+    assert cmpIgnoreStyle(cstring"hello", cstring"H_e_L_Lo") == 0
+
+  when nimvm:
+    cmpIgnoreStyleImpl(a, b)
+  else:
+    when defined(js):
+      cmpIgnoreStyleImpl(a, b)
+    else:
+      var i = 0
+      var j = 0
+      while true:
+        while a[i] == '_': inc(i)
+        while b[j] == '_': inc(j) # BUGFIX: typo
+        var aa = toLowerAscii(a[i])
+        var bb = toLowerAscii(b[j])
+        result = ord(aa) - ord(bb)
+        if result != 0 or aa == '\0': break
+        inc(i)
+        inc(j)
+
+func cmpIgnoreCase*(a, b: cstring): int {.rtl, extern: "csuCmpIgnoreCase".} =
+  ## Compares two strings in a case insensitive manner. Returns:
+  ## * 0 if `a == b`
+  ## * < 0 if `a < b`
+  ## * \> 0 if `a > b`
+  runnableExamples:
+    assert cmpIgnoreCase(cstring"hello", cstring"HeLLo") == 0
+    assert cmpIgnoreCase(cstring"echo", cstring"hello") < 0
+    assert cmpIgnoreCase(cstring"yellow", cstring"hello") > 0
+
+  when nimvm:
+    cmpIgnoreCaseImpl(a, b)
+  else:
+    when defined(js):
+      cmpIgnoreCaseImpl(a, b)
+    else:
+      var i = 0
+      while true:
+        var aa = toLowerAscii(a[i])
+        var bb = toLowerAscii(b[i])
+        result = ord(aa) - ord(bb)
+        if result != 0 or aa == '\0': break
+        inc(i)
diff --git a/lib/pure/distros.nim b/lib/pure/distros.nim
new file mode 100644
index 000000000..9e71d4ce0
--- /dev/null
+++ b/lib/pure/distros.nim
@@ -0,0 +1,279 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements the basics for Linux distribution ("distro")
+## detection and the OS's native package manager. Its primary purpose is to
+## produce output for Nimble packages, like:
+##
+##     To complete the installation, run:
+##
+##     sudo apt-get install libblas-dev
+##     sudo apt-get install libvoodoo
+##
+## The above output could be the result of a code snippet like:
+##
+##   ```nim
+##   if detectOs(Ubuntu):
+##     foreignDep "lbiblas-dev"
+##     foreignDep "libvoodoo"
+##   ```
+##
+## See `packaging <packaging.html>`_ for hints on distributing Nim using OS packages.
+
+from std/strutils import contains, toLowerAscii
+
+when not defined(nimscript):
+  from std/osproc import execProcess
+  from std/envvars import existsEnv
+
+type
+  Distribution* {.pure.} = enum ## the list of known distributions
+    Windows                     ## some version of Windows
+    Posix                       ## some POSIX system
+    MacOSX                      ## some version of OSX
+    Linux                       ## some version of Linux
+    Ubuntu
+    Debian
+    Gentoo
+    Fedora
+    RedHat
+
+    OpenSUSE
+    Manjaro
+    Elementary
+    Zorin
+    CentOS
+    Deepin
+    ArchLinux
+    Artix
+    Antergos
+    PCLinuxOS
+    Mageia
+    LXLE
+    Solus
+    Lite
+    Slackware
+    Androidx86
+    Puppy
+    Peppermint
+    Tails
+    AntiX
+    Kali
+    SparkyLinux
+    Apricity
+    BlackLab
+    Bodhi
+    TrueOS
+    ArchBang
+    KaOS
+    WattOS
+    Korora
+    Simplicity
+    RemixOS
+    OpenMandriva
+    Netrunner
+    Alpine
+    BlackArch
+    Ultimate
+    Gecko
+    Parrot
+    KNOPPIX
+    GhostBSD
+    Sabayon
+    Salix
+    Q4OS
+    ClearOS
+    Container
+    ROSA
+    Zenwalk
+    Parabola
+    ChaletOS
+    BackBox
+    MXLinux
+    Vector
+    Maui
+    Qubes
+    RancherOS
+    Oracle
+    TinyCore
+    Robolinux
+    Trisquel
+    Voyager
+    Clonezilla
+    SteamOS
+    Absolute
+    NixOS                       ## NixOS or a Nix build environment
+    AUSTRUMI
+    Arya
+    Porteus
+    AVLinux
+    Elive
+    Bluestar
+    SliTaz
+    Solaris
+    Chakra
+    Wifislax
+    Scientific
+    ExTiX
+    Rockstor
+    GoboLinux
+    Void
+
+    BSD
+    FreeBSD
+    NetBSD
+    OpenBSD
+    DragonFlyBSD
+
+    Haiku
+
+
+const
+  LacksDevPackages* = {Distribution.Gentoo, Distribution.Slackware,
+      Distribution.ArchLinux, Distribution.Artix, Distribution.Antergos,
+      Distribution.BlackArch, Distribution.ArchBang}
+
+# we cache the result of the 'cmdRelease'
+# execution for faster platform detections.
+var unameRes, osReleaseIDRes, releaseRes, hostnamectlRes: string
+
+template cmdRelease(cmd, cache): untyped =
+  if cache.len == 0:
+    cache = (when defined(nimscript): gorge(cmd) else: execProcess(cmd))
+  cache
+
+template uname(): untyped = cmdRelease("uname -a", unameRes)
+template osReleaseID(): untyped = cmdRelease("cat /etc/os-release | grep ^ID=", osReleaseIDRes)
+template release(): untyped = cmdRelease("lsb_release -d", releaseRes)
+template hostnamectl(): untyped = cmdRelease("hostnamectl", hostnamectlRes)
+
+proc detectOsWithAllCmd(d: Distribution): bool =
+  let dd = toLowerAscii($d)
+  result = dd in toLowerAscii(osReleaseID()) or dd in toLowerAscii(release()) or
+            dd in toLowerAscii(uname()) or ("operating system: " & dd) in
+                toLowerAscii(hostnamectl())
+
+proc detectOsImpl(d: Distribution): bool =
+  case d
+  of Distribution.Windows: result = defined(windows)
+  of Distribution.Posix: result = defined(posix)
+  of Distribution.MacOSX: result = defined(macosx)
+  of Distribution.Linux: result = defined(linux)
+  of Distribution.BSD: result = defined(bsd)
+  else:
+    when defined(bsd):
+      case d
+      of Distribution.FreeBSD, Distribution.NetBSD, Distribution.OpenBSD:
+        result = $d in uname()
+      else:
+        result = false
+    elif defined(linux):
+      case d
+      of Distribution.Gentoo:
+        result = ("-" & $d & " ") in uname()
+      of Distribution.Elementary, Distribution.Ubuntu, Distribution.Debian,
+        Distribution.Fedora, Distribution.OpenMandriva, Distribution.CentOS,
+        Distribution.Alpine, Distribution.Mageia, Distribution.Zorin, Distribution.Void:
+        result = toLowerAscii($d) in osReleaseID()
+      of Distribution.RedHat:
+        result = "rhel" in osReleaseID()
+      of Distribution.ArchLinux:
+        result = "arch" in osReleaseID()
+      of Distribution.Artix:
+        result = "artix" in osReleaseID()
+      of Distribution.NixOS:
+        # Check if this is a Nix build or NixOS environment
+        result = existsEnv("NIX_BUILD_TOP") or existsEnv("__NIXOS_SET_ENVIRONMENT_DONE")
+      of Distribution.OpenSUSE:
+        result = "suse" in toLowerAscii(uname()) or "suse" in toLowerAscii(release())
+      of Distribution.GoboLinux:
+        result = "-Gobo " in uname()
+      of Distribution.Solaris:
+        let uname = toLowerAscii(uname())
+        result = ("sun" in uname) or ("solaris" in uname)
+      of Distribution.Haiku:
+        result = defined(haiku)
+      else:
+        result = detectOsWithAllCmd(d)
+    else:
+      result = false
+
+template detectOs*(d: untyped): bool =
+  ## Distro/OS detection. For convenience, the
+  ## required `Distribution.` qualifier is added to the
+  ## enum value.
+  detectOsImpl(Distribution.d)
+
+when not defined(nimble):
+  var foreignDeps*: seq[string] = @[]  ## Registered foreign deps.
+
+proc foreignCmd*(cmd: string; requiresSudo = false) =
+  ## Registers a foreign command to the internal list of commands
+  ## that can be queried later.
+  let c = (if requiresSudo: "sudo " else: "") & cmd
+  when defined(nimble):
+    nimscriptapi.foreignDeps.add(c)
+  else:
+    foreignDeps.add(c)
+
+proc foreignDepInstallCmd*(foreignPackageName: string): (string, bool) =
+  ## Returns the distro's native command to install `foreignPackageName`
+  ## and whether it requires root/admin rights.
+  let p = foreignPackageName
+  when defined(windows):
+    result = ("choco install " & p, false)
+  elif defined(bsd):
+    result = ("ports install " & p, true)
+  elif defined(linux):
+    if detectOs(Ubuntu) or detectOs(Elementary) or detectOs(Debian) or
+        detectOs(KNOPPIX) or detectOs(SteamOS):
+      result = ("apt-get install " & p, true)
+    elif detectOs(Gentoo):
+      result = ("emerge install " & p, true)
+    elif detectOs(Fedora):
+      result = ("yum install " & p, true)
+    elif detectOs(RedHat):
+      result = ("rpm install " & p, true)
+    elif detectOs(OpenSUSE):
+      result = ("yast -i " & p, true)
+    elif detectOs(Slackware):
+      result = ("installpkg " & p, true)
+    elif detectOs(OpenMandriva):
+      result = ("urpmi " & p, true)
+    elif detectOs(ZenWalk):
+      result = ("netpkg install " & p, true)
+    elif detectOs(NixOS):
+      result = ("nix-env -i " & p, false)
+    elif detectOs(Solaris) or detectOs(FreeBSD):
+      result = ("pkg install " & p, true)
+    elif detectOs(NetBSD) or detectOs(OpenBSD):
+      result = ("pkg_add " & p, true)
+    elif detectOs(PCLinuxOS):
+      result = ("rpm -ivh " & p, true)
+    elif detectOs(ArchLinux) or detectOs(Manjaro) or detectOs(Artix):
+      result = ("pacman -S " & p, true)
+    elif detectOs(Void):
+      result = ("xbps-install " & p, true)
+    else:
+      result = ("<your package manager here> install " & p, true)
+  elif defined(haiku):
+    result = ("pkgman install " & p, true)
+  else:
+    result = ("brew install " & p, false)
+
+proc foreignDep*(foreignPackageName: string) =
+  ## Registers `foreignPackageName` to the internal list of foreign deps.
+  ## It is your job to ensure that the package name is correct.
+  let (installCmd, sudo) = foreignDepInstallCmd(foreignPackageName)
+  foreignCmd(installCmd, sudo)
+
+proc echoForeignDeps*() =
+  ## Writes the list of registered foreign deps to stdout.
+  for d in foreignDeps:
+    echo d
diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim
index 592073e3d..a162fe37f 100755..100644
--- a/lib/pure/dynlib.nim
+++ b/lib/pure/dynlib.nim
@@ -1,41 +1,102 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module implements the ability to access symbols from shared
-## libraries. On POSIX this uses the ``dlsym`` mechanism, on 
-## Windows ``LoadLibrary``. 
+## libraries. On POSIX this uses the `dlsym` mechanism, on
+## Windows `LoadLibrary`.
+##
+## Examples
+## ========
+##
+## Loading a simple C function
+## ---------------------------
+##
+## The following example demonstrates loading a function called `greet`
+## from a library that is determined at runtime based upon a language choice.
+## If the library fails to load or the function `greet` is not found,
+## it quits with a failure error code.
+##
+runnableExamples:
+  type
+    GreetFunction = proc (): cstring {.gcsafe, stdcall.}
+
+  proc loadGreet(lang: string) =
+    let lib =
+      case lang
+      of "french":
+        loadLib("french.dll")
+      else:
+        loadLib("english.dll")
+    assert lib != nil, "Error loading library"
+
+    let greet = cast[GreetFunction](lib.symAddr("greet"))
+    assert greet != nil, "Error loading 'greet' function from library"
+
+    echo greet()
+
+    unloadLib(lib)
+
+
+import std/strutils
 
 type
-  TLibHandle* = pointer ## a handle to a dynamically loaded library
+  LibHandle* = pointer ## A handle to a dynamically loaded library.
 
-proc LoadLib*(path: string): TLibHandle
-  ## loads a library from `path`. Returns nil if the library could not 
+proc loadLib*(path: string, globalSymbols = false): LibHandle {.gcsafe.}
+  ## Loads a library from `path`. Returns nil if the library could not
   ## be loaded.
 
-proc UnloadLib*(lib: TLibHandle)
-  ## unloads the library `lib`
+proc loadLib*(): LibHandle {.gcsafe.}
+  ## Gets the handle from the current executable. Returns nil if the
+  ## library could not be loaded.
 
-proc symAddr*(lib: TLibHandle, name: string): pointer
-  ## retrieves the address of a procedure/variable from `lib`. Returns nil
+proc unloadLib*(lib: LibHandle) {.gcsafe.}
+  ## Unloads the library `lib`.
+
+proc raiseInvalidLibrary*(name: cstring) {.noinline, noreturn.} =
+  ## Raises a `LibraryError` exception.
+  raise newException(LibraryError, "could not find symbol: " & $name)
+
+proc symAddr*(lib: LibHandle, name: cstring): pointer {.gcsafe.}
+  ## Retrieves the address of a procedure/variable from `lib`. Returns nil
   ## if the symbol could not be found.
 
-proc checkedSymAddr*(lib: TLibHandle, name: string): pointer =
-  ## retrieves the address of a procedure/variable from `lib`. Raises
-  ## `EInvalidLibrary` if the symbol could not be found.
+proc checkedSymAddr*(lib: LibHandle, name: cstring): pointer =
+  ## Retrieves the address of a procedure/variable from `lib`. Raises
+  ## `LibraryError` if the symbol could not be found.
   result = symAddr(lib, name)
-  if result == nil: 
-    var e: ref EInvalidLibrary
-    new(e)
-    e.msg = "could not find symbol: " & name
-    raise e
+  if result == nil: raiseInvalidLibrary(name)
+
+proc libCandidates*(s: string, dest: var seq[string]) =
+  ## Given a library name pattern `s`, write possible library names to `dest`.
+  var le = strutils.find(s, '(')
+  var ri = strutils.find(s, ')', le+1)
+  if le >= 0 and ri > le:
+    var prefix = substr(s, 0, le - 1)
+    var suffix = substr(s, ri + 1)
+    for middle in split(substr(s, le + 1, ri - 1), '|'):
+      libCandidates(prefix & middle & suffix, dest)
+  else:
+    add(dest, s)
 
-when defined(posix):
+proc loadLibPattern*(pattern: string, globalSymbols = false): LibHandle =
+  ## Loads a library with name matching `pattern`, similar to what the `dynlib`
+  ## pragma does. Returns nil if the library could not be loaded.
+  ##
+  ## .. warning:: this proc uses the GC and so cannot be used to load the GC.
+  var candidates = newSeq[string]()
+  libCandidates(pattern, candidates)
+  for c in candidates:
+    result = loadLib(c, globalSymbols)
+    if not result.isNil: break
+
+when defined(posix) and not defined(nintendoswitch):
   #
   # =========================================================================
   # This is an implementation based on the dlfcn interface.
@@ -44,19 +105,66 @@ when defined(posix):
   # as an emulation layer on top of native functions.
   # =========================================================================
   #
-  var
-    RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
+  import std/posix
+
+  proc loadLib(path: string, globalSymbols = false): LibHandle =
+    let flags =
+      if globalSymbols: RTLD_NOW or RTLD_GLOBAL
+      else: RTLD_NOW
+
+    dlopen(path, flags)
+
+  proc loadLib(): LibHandle = dlopen(nil, RTLD_NOW)
+  proc unloadLib(lib: LibHandle) = discard dlclose(lib)
+  proc symAddr(lib: LibHandle, name: cstring): pointer = dlsym(lib, name)
+
+elif defined(nintendoswitch):
+  #
+  # =========================================================================
+  # Nintendo switch DevkitPro sdk does not have these. Raise an error if called.
+  # =========================================================================
+  #
+
+  proc dlclose(lib: LibHandle) =
+    raise newException(OSError, "dlclose not implemented on Nintendo Switch!")
+  proc dlopen(path: cstring, mode: int): LibHandle =
+    raise newException(OSError, "dlopen not implemented on Nintendo Switch!")
+  proc dlsym(lib: LibHandle, name: cstring): pointer =
+    raise newException(OSError, "dlsym not implemented on Nintendo Switch!")
+  proc loadLib(path: string, global_symbols = false): LibHandle =
+    raise newException(OSError, "loadLib not implemented on Nintendo Switch!")
+  proc loadLib(): LibHandle =
+    raise newException(OSError, "loadLib not implemented on Nintendo Switch!")
+  proc unloadLib(lib: LibHandle) =
+    raise newException(OSError, "unloadLib not implemented on Nintendo Switch!")
+  proc symAddr(lib: LibHandle, name: cstring): pointer =
+    raise newException(OSError, "symAddr not implemented on Nintendo Switch!")
+
+elif defined(genode):
+  #
+  # =========================================================================
+  # Not implemented for Genode without POSIX. Raise an error if called.
+  # =========================================================================
+  #
+
+  template raiseErr(prc: string) =
+    raise newException(OSError, prc & " not implemented, compile with POSIX support")
 
-  proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".}
-  proc dlopen(path: CString, mode: int): TLibHandle {.
-      importc, header: "<dlfcn.h>".}
-  proc dlsym(lib: TLibHandle, name: cstring): pointer {.
-      importc, header: "<dlfcn.h>".}
+  proc dlclose(lib: LibHandle) =
+    raiseErr(OSError, "dlclose")
+  proc dlopen(path: cstring, mode: int): LibHandle =
+    raiseErr(OSError, "dlopen")
+  proc dlsym(lib: LibHandle, name: cstring): pointer =
+    raiseErr(OSError, "dlsym")
+  proc loadLib(path: string, global_symbols = false): LibHandle =
+    raiseErr(OSError, "loadLib")
+  proc loadLib(): LibHandle =
+    raiseErr(OSError, "loadLib")
+  proc unloadLib(lib: LibHandle) =
+    raiseErr(OSError, "unloadLib")
+  proc symAddr(lib: LibHandle, name: cstring): pointer =
+    raiseErr(OSError, "symAddr")
 
-  proc LoadLib(path: string): TLibHandle = return dlopen(path, RTLD_NOW)
-  proc UnloadLib(lib: TLibHandle) = dlclose(lib)
-  proc symAddr(lib: TLibHandle, name: string): pointer = 
-    return dlsym(lib, name)
 
 elif defined(windows) or defined(dos):
   #
@@ -65,20 +173,23 @@ elif defined(windows) or defined(dos):
   # =======================================================================
   #
   type
-    THINSTANCE {.importc: "HINSTANCE".} = pointer
+    HMODULE {.importc: "HMODULE".} = pointer
+    FARPROC {.importc: "FARPROC".} = pointer
 
-  proc FreeLibrary(lib: THINSTANCE) {.importc, header: "<windows.h>", stdcall.}
-  proc winLoadLibrary(path: cstring): THINSTANCE {.
+  proc FreeLibrary(lib: HMODULE) {.importc, header: "<windows.h>", stdcall.}
+  proc winLoadLibrary(path: cstring): HMODULE {.
       importc: "LoadLibraryA", header: "<windows.h>", stdcall.}
-  proc GetProcAddress(lib: THINSTANCE, name: cstring): pointer {.
+  proc getProcAddress(lib: HMODULE, name: cstring): FARPROC {.
       importc: "GetProcAddress", header: "<windows.h>", stdcall.}
 
-  proc LoadLib(path: string): TLibHandle =
-    result = cast[TLibHandle](winLoadLibrary(path))
-  proc UnloadLib(lib: TLibHandle) = FreeLibrary(cast[THINSTANCE](lib))
+  proc loadLib(path: string, globalSymbols = false): LibHandle =
+    result = cast[LibHandle](winLoadLibrary(path))
+  proc loadLib(): LibHandle =
+    result = cast[LibHandle](winLoadLibrary(nil))
+  proc unloadLib(lib: LibHandle) = FreeLibrary(cast[HMODULE](lib))
 
-  proc symAddr(lib: TLibHandle, name: string): pointer =
-    result = GetProcAddress(cast[THINSTANCE](lib), name)
+  proc symAddr(lib: LibHandle, name: cstring): pointer =
+    result = cast[pointer](getProcAddress(cast[HMODULE](lib), name))
 
 else:
   {.error: "no implementation for dynlib".}
diff --git a/lib/pure/encodings.nim b/lib/pure/encodings.nim
new file mode 100644
index 000000000..bbadca655
--- /dev/null
+++ b/lib/pure/encodings.nim
@@ -0,0 +1,511 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Routines for converting between different character encodings. On UNIX, this uses
+## the `iconv`:idx: library, on Windows the Windows API.
+##
+## The following example shows how to change character encodings.
+runnableExamples:
+  when defined(windows):
+    let
+      orig = "öäüß"
+      # convert `orig` from "UTF-8" to "CP1252"
+      cp1252 = convert(orig, "CP1252", "UTF-8")
+      # convert `cp1252` from "CP1252" to "ibm850"
+      ibm850 = convert(cp1252, "ibm850", "CP1252")
+      current = getCurrentEncoding()
+    assert orig == "\195\182\195\164\195\188\195\159"
+    assert ibm850 == "\148\132\129\225"
+    assert convert(ibm850, current, "ibm850") == orig
+
+## The example below uses a reuseable `EncodingConverter` object which is
+## created by `open` with `destEncoding` and `srcEncoding` specified. You can use
+## `convert` on this object multiple times.
+runnableExamples:
+  when defined(windows):
+    var fromGB2312 = open("utf-8", "gb2312")
+    let first = "\203\173\197\194\163\191\210\187" &
+        "\203\242\209\204\211\234\200\206\198\189\201\250"
+    assert fromGB2312.convert(first) == "è°æ€•?一蓑烟雨任平生"
+
+    let second = "\211\208\176\215\205\183\200\231" &
+        "\208\194\163\172\199\227\184\199\200\231\185\202"
+    assert fromGB2312.convert(second) == "有白头如新,倾盖如故"
+
+
+import std/os
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+when not defined(windows):
+  type
+    ConverterObj = object
+    EncodingConverter* = ptr ConverterObj ## Can convert between two character sets.
+
+else:
+  type
+    CodePage = distinct int32
+    EncodingConverter* = object
+      dest, src: CodePage
+
+type
+  EncodingError* = object of ValueError ## Exception that is raised
+                                        ## for encoding errors.
+
+when defined(windows):
+  import std/[parseutils, strutils]
+  proc eqEncodingNames(a, b: string): bool =
+    var i = 0
+    var j = 0
+    while i < a.len and j < b.len:
+      if a[i] in {'-', '_'}: inc i
+      if b[j] in {'-', '_'}: inc j
+      if i < a.len and j < b.len and
+          a[i].toLowerAscii != b[j].toLowerAscii:
+        return false
+      inc i
+      inc j
+    result = i == a.len and j == b.len
+
+  const
+    winEncodings = [
+      (1, "OEMCP"),            # current OEM codepage
+      (037, "IBM037"),         # IBM EBCDIC US-Canada
+      (437, "IBM437"),         # OEM United States
+      (500, "IBM500"),         # IBM EBCDIC International
+      (708, "ASMO-708"),       # Arabic (ASMO 708)
+      (709, "ASMO_449"),       # Arabic (ASMO-449+, BCON V4)
+      (710, ""),               # Arabic - Transparent Arabic
+      (720, "DOS-720"),        # Arabic (Transparent ASMO); Arabic (DOS)
+      (737, "ibm737"),         # OEM Greek (formerly 437G); Greek (DOS)
+      (775, "ibm775"),         # OEM Baltic; Baltic (DOS)
+      (850, "ibm850"),         # OEM Multilingual Latin 1; Western European (DOS)
+      (852, "ibm852"),         # OEM Latin 2; Central European (DOS)
+      (855, "IBM855"),         # OEM Cyrillic (primarily Russian)
+      (857, "ibm857"),         # OEM Turkish; Turkish (DOS)
+      (858, "IBM00858"),       # OEM Multilingual Latin 1 + Euro symbol
+      (860, "IBM860"),         # OEM Portuguese; Portuguese (DOS)
+      (861, "ibm861"),         # OEM Icelandic; Icelandic (DOS)
+      (862, "DOS-862"),        # OEM Hebrew; Hebrew (DOS)
+      (863, "IBM863"),         # OEM French Canadian; French Canadian (DOS)
+      (864, "IBM864"),         # OEM Arabic; Arabic (864)
+      (865, "IBM865"),         # OEM Nordic; Nordic (DOS)
+      (866, "cp866"),          # OEM Russian; Cyrillic (DOS)
+      (869, "ibm869"),         # OEM Modern Greek; Greek, Modern (DOS)
+      (870, "IBM870"),         # IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2
+      (874, "windows-874"),    # ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows)
+      (875, "cp875"),          # IBM EBCDIC Greek Modern
+      (932, "shift_jis"),      # ANSI/OEM Japanese; Japanese (Shift-JIS)
+      (936, "gb2312"),         # ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312)
+      (936, "gbk"),            # Alias for GB2312 encoding
+      (949, "ks_c_5601-1987"), # ANSI/OEM Korean (Unified Hangul Code)
+      (950, "big5"),           # ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
+      (1026, "IBM1026"),       # IBM EBCDIC Turkish (Latin 5)
+      (1047, "IBM01047"),      # IBM EBCDIC Latin 1/Open System
+      (1140, "IBM01140"),      # IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro)
+      (1141, "IBM01141"),      # IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro)
+      (1142, "IBM01142"),      # IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro)
+      (1143, "IBM01143"),      # IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro)
+      (1144, "IBM01144"),      # IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro)
+      (1145, "IBM01145"),      # IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro)
+      (1146, "IBM01146"),      # IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro)
+      (1147, "IBM01147"),      # IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro)
+      (1148, "IBM01148"),      # IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro)
+      (1149, "IBM01149"),      # IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro)
+      (1200, "utf-16"),        # Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications
+      (1201, "unicodeFFFE"),   # Unicode UTF-16, big endian byte order; available only to managed applications
+      (1250, "windows-1250"),  # ANSI Central European; Central European (Windows)
+      (1251, "windows-1251"),  # ANSI Cyrillic; Cyrillic (Windows)
+      (1252, "windows-1252"),  # ANSI Latin 1; Western European (Windows)
+      (1253, "windows-1253"),  # ANSI Greek; Greek (Windows)
+      (1254, "windows-1254"),  # ANSI Turkish; Turkish (Windows)
+      (1255, "windows-1255"),  # ANSI Hebrew; Hebrew (Windows)
+      (1256, "windows-1256"),  # ANSI Arabic; Arabic (Windows)
+      (1257, "windows-1257"),  # ANSI Baltic; Baltic (Windows)
+      (1258, "windows-1258"),  # ANSI/OEM Vietnamese; Vietnamese (Windows)
+
+      (1250, "cp-1250"), # ANSI Central European; Central European (Windows)
+      (1251, "cp-1251"), # ANSI Cyrillic; Cyrillic (Windows)
+      (1252, "cp-1252"), # ANSI Latin 1; Western European (Windows)
+      (1253, "cp-1253"), # ANSI Greek; Greek (Windows)
+      (1254, "cp-1254"), # ANSI Turkish; Turkish (Windows)
+      (1255, "cp-1255"), # ANSI Hebrew; Hebrew (Windows)
+      (1256, "cp-1256"), # ANSI Arabic; Arabic (Windows)
+      (1257, "cp-1257"), # ANSI Baltic; Baltic (Windows)
+      (1258, "cp-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows)
+
+      (1361, "Johab"),                    # Korean (Johab)
+      (10000, "macintosh"),               # MAC Roman; Western European (Mac)
+      (10001, "x-mac-japanese"),          # Japanese (Mac)
+      (10002, "x-mac-chinesetrad"),       # MAC Traditional Chinese (Big5); Chinese Traditional (Mac)
+      (10003, "x-mac-korean"),            # Korean (Mac)
+      (10004, "x-mac-arabic"),            # Arabic (Mac)
+      (10005, "x-mac-hebrew"),            # Hebrew (Mac)
+      (10006, "x-mac-greek"),             # Greek (Mac)
+      (10007, "x-mac-cyrillic"),          # Cyrillic (Mac)
+      (10008, "x-mac-chinesesimp"),       # MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac)
+      (10010, "x-mac-romanian"),          # Romanian (Mac)
+      (10017, "x-mac-ukrainian"),         # Ukrainian (Mac)
+      (10021, "x-mac-thai"),              # Thai (Mac)
+      (10029, "x-mac-ce"),                # MAC Latin 2; Central European (Mac)
+      (10079, "x-mac-icelandic"),         # Icelandic (Mac)
+      (10081, "x-mac-turkish"),           # Turkish (Mac)
+      (10082, "x-mac-croatian"),          # Croatian (Mac)
+      (12000, "utf-32"),                  # Unicode UTF-32, little endian byte order; available only to managed applications
+      (12001, "utf-32BE"),                # Unicode UTF-32, big endian byte order; available only to managed applications
+      (20000, "x-Chinese_CNS"),           # CNS Taiwan; Chinese Traditional (CNS)
+      (20001, "x-cp20001"),               # TCA Taiwan
+      (20002, "x_Chinese-Eten"),          # Eten Taiwan; Chinese Traditional (Eten)
+      (20003, "x-cp20003"),               # IBM5550 Taiwan
+      (20004, "x-cp20004"),               # TeleText Taiwan
+      (20005, "x-cp20005"),               # Wang Taiwan
+      (20105, "x-IA5"),                   # IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5)
+      (20106, "x-IA5-German"),            # IA5 German (7-bit)
+      (20107, "x-IA5-Swedish"),           # IA5 Swedish (7-bit)
+      (20108, "x-IA5-Norwegian"),         # IA5 Norwegian (7-bit)
+      (20127, "us-ascii"),                # US-ASCII (7-bit)
+      (20261, "x-cp20261"),               # T.61
+      (20269, "x-cp20269"),               # ISO 6937 Non-Spacing Accent
+      (20273, "IBM273"),                  # IBM EBCDIC Germany
+      (20277, "IBM277"),                  # IBM EBCDIC Denmark-Norway
+      (20278, "IBM278"),                  # IBM EBCDIC Finland-Sweden
+      (20280, "IBM280"),                  # IBM EBCDIC Italy
+      (20284, "IBM284"),                  # IBM EBCDIC Latin America-Spain
+      (20285, "IBM285"),                  # IBM EBCDIC United Kingdom
+      (20290, "IBM290"),                  # IBM EBCDIC Japanese Katakana Extended
+      (20297, "IBM297"),                  # IBM EBCDIC France
+      (20420, "IBM420"),                  # IBM EBCDIC Arabic
+      (20423, "IBM423"),                  # IBM EBCDIC Greek
+      (20424, "IBM424"),                  # IBM EBCDIC Hebrew
+      (20833, "x-EBCDIC-KoreanExtended"), # IBM EBCDIC Korean Extended
+      (20838, "IBM-Thai"),                # IBM EBCDIC Thai
+      (20866, "koi8-r"),                  # Russian (KOI8-R); Cyrillic (KOI8-R)
+      (20871, "IBM871"),                  # IBM EBCDIC Icelandic
+      (20880, "IBM880"),                  # IBM EBCDIC Cyrillic Russian
+      (20905, "IBM905"),                  # IBM EBCDIC Turkish
+      (20924, "IBM00924"),                # IBM EBCDIC Latin 1/Open System (1047 + Euro symbol)
+      (20932, "EUC-JP"),                  # Japanese (JIS 0208-1990 and 0121-1990)
+      (20936, "x-cp20936"),               # Simplified Chinese (GB2312); Chinese Simplified (GB2312-80)
+      (20949, "x-cp20949"),               # Korean Wansung
+      (21025, "cp1025"),                  # IBM EBCDIC Cyrillic Serbian-Bulgarian
+      (21027, ""),                        # (deprecated)
+      (21866, "koi8-u"),                  # Ukrainian (KOI8-U); Cyrillic (KOI8-U)
+      (28591, "iso-8859-1"),              # ISO 8859-1 Latin 1; Western European (ISO)
+      (28592, "iso-8859-2"),              # ISO 8859-2 Central European; Central European (ISO)
+      (28593, "iso-8859-3"),              # ISO 8859-3 Latin 3
+      (28594, "iso-8859-4"),              # ISO 8859-4 Baltic
+      (28595, "iso-8859-5"),              # ISO 8859-5 Cyrillic
+      (28596, "iso-8859-6"),              # ISO 8859-6 Arabic
+      (28597, "iso-8859-7"),              # ISO 8859-7 Greek
+      (28598, "iso-8859-8"),              # ISO 8859-8 Hebrew; Hebrew (ISO-Visual)
+      (28599, "iso-8859-9"),              # ISO 8859-9 Turkish
+      (28603, "iso-8859-13"),             # ISO 8859-13 Estonian
+      (28605, "iso-8859-15"),             # ISO 8859-15 Latin 9
+      (29001, "x-Europa"),                # Europa 3
+      (38598, "iso-8859-8-i"),            # ISO 8859-8 Hebrew; Hebrew (ISO-Logical)
+      (50220, "iso-2022-jp"),             # ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)
+      (50221, "csISO2022JP"),             # ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana)
+      (50222, "iso-2022-jp"),             # ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI)
+      (50225, "iso-2022-kr"),             # ISO 2022 Korean
+      (50227, "x-cp50227"),               # ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022)
+      (50229, ""),                        # ISO 2022 Traditional Chinese
+      (50930, ""),                        # EBCDIC Japanese (Katakana) Extended
+      (50931, ""),                        # EBCDIC US-Canada and Japanese
+      (50933, ""),                        # EBCDIC Korean Extended and Korean
+      (50935, ""),                        # EBCDIC Simplified Chinese Extended and Simplified Chinese
+      (50936, ""),                        # EBCDIC Simplified Chinese
+      (50937, ""),                        # EBCDIC US-Canada and Traditional Chinese
+      (50939, ""),                        # EBCDIC Japanese (Latin) Extended and Japanese
+      (51932, "euc-jp"),                  # EUC Japanese
+      (51936, "EUC-CN"),                  # EUC Simplified Chinese; Chinese Simplified (EUC)
+      (51949, "euc-kr"),                  # EUC Korean
+      (51950, ""),                        # EUC Traditional Chinese
+      (52936, "hz-gb-2312"),              # HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ)
+      (54936, "GB18030"),                 # Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)
+      (57002, "x-iscii-de"),              # ISCII Devanagari
+      (57003, "x-iscii-be"),              # ISCII Bengali
+      (57004, "x-iscii-ta"),              # ISCII Tamil
+      (57005, "x-iscii-te"),              # ISCII Telugu
+      (57006, "x-iscii-as"),              # ISCII Assamese
+      (57007, "x-iscii-or"),              # ISCII Oriya
+      (57008, "x-iscii-ka"),              # ISCII Kannada
+      (57009, "x-iscii-ma"),              # ISCII Malayalam
+      (57010, "x-iscii-gu"),              # ISCII Gujarati
+      (57011, "x-iscii-pa"),              # ISCII Punjabi
+      (65000, "utf-7"),                   # Unicode (UTF-7)
+      (65001, "utf-8")]                   # Unicode (UTF-8)
+
+  when false:
+    # not needed yet:
+    type
+      CpInfo = object
+        maxCharSize: int32
+        defaultChar: array[0..1, char]
+        leadByte: array[0..12-1, char]
+
+    proc getCPInfo(codePage: CodePage, lpCPInfo: var CpInfo): int32 {.
+      stdcall, importc: "GetCPInfo", dynlib: "kernel32".}
+
+  proc nameToCodePage*(name: string): CodePage =
+    var nameAsInt: int
+    if parseInt(name, nameAsInt) == 0: nameAsInt = -1
+    for no, na in items(winEncodings):
+      if no == nameAsInt or eqEncodingNames(na, name): return CodePage(no)
+    result = CodePage(-1)
+
+  proc codePageToName*(c: CodePage): string =
+    for no, na in items(winEncodings):
+      if no == int(c):
+        return if na.len != 0: na else: $no
+    result = ""
+
+  proc getACP(): CodePage {.stdcall, importc: "GetACP", dynlib: "kernel32".}
+  proc getGetConsoleCP(): CodePage {.stdcall, importc: "GetConsoleCP",
+      dynlib: "kernel32".}
+
+  proc multiByteToWideChar(
+    codePage: CodePage,
+    dwFlags: int32,
+    lpMultiByteStr: cstring,
+    cbMultiByte: cint,
+    lpWideCharStr: cstring,
+    cchWideChar: cint): cint {.
+      stdcall, importc: "MultiByteToWideChar", dynlib: "kernel32".}
+
+  proc wideCharToMultiByte(
+    codePage: CodePage,
+    dwFlags: int32,
+    lpWideCharStr: cstring,
+    cchWideChar: cint,
+    lpMultiByteStr: cstring,
+    cbMultiByte: cint,
+    lpDefaultChar: cstring = nil,
+    lpUsedDefaultChar: pointer = nil): cint {.
+      stdcall, importc: "WideCharToMultiByte", dynlib: "kernel32".}
+
+else:
+  when defined(haiku):
+    const iconvDll = "libiconv.so"
+  elif defined(macosx):
+    const iconvDll = "libiconv.dylib"
+  else:
+    const iconvDll = "(libc.so.6|libiconv.so)"
+
+  const
+    E2BIG = 7.cint
+    EINVAL = 22.cint
+  when defined(linux):
+    const EILSEQ = 84.cint
+  elif defined(macosx):
+    const EILSEQ = 92.cint
+  elif defined(bsd):
+    const EILSEQ = 86.cint
+  elif defined(solaris):
+    const EILSEQ = 88.cint
+  elif defined(haiku):
+    const EILSEQ = -2147454938.cint
+
+  var errno {.importc, header: "<errno.h>".}: cint
+
+  when defined(bsd):
+    {.pragma: importIconv, cdecl, header: "<iconv.h>".}
+    when defined(openbsd):
+      {.passL: "-liconv".}
+  else:
+    {.pragma: importIconv, cdecl, dynlib: iconvDll.}
+
+  proc iconvOpen(tocode, fromcode: cstring): EncodingConverter {.
+    importc: "iconv_open", importIconv.}
+  proc iconvClose(c: EncodingConverter) {.
+    importc: "iconv_close", importIconv.}
+  proc iconv(c: EncodingConverter, inbuf: ptr cstring, inbytesLeft: ptr csize_t,
+             outbuf: ptr cstring, outbytesLeft: ptr csize_t): csize_t {.
+    importc: "iconv", importIconv.}
+
+proc getCurrentEncoding*(uiApp = false): string =
+  ## Retrieves the current encoding. On Unix, "UTF-8" is always returned.
+  ## The `uiApp` parameter is Windows specific. If true, the UI's code-page
+  ## is returned, if false, the Console's code-page is returned.
+  when defined(windows):
+    result = codePageToName(if uiApp: getACP() else: getGetConsoleCP())
+  else:
+    result = "UTF-8"
+
+proc open*(destEncoding = "UTF-8", srcEncoding = "CP1252"): EncodingConverter =
+  ## Opens a converter that can convert from `srcEncoding` to `destEncoding`.
+  ## Raises `EncodingError` if it cannot fulfill the request.
+  when not defined(windows):
+    result = iconvOpen(destEncoding, srcEncoding)
+    if result == cast[EncodingConverter](-1):
+      raise newException(EncodingError,
+        "cannot create encoding converter from " &
+        srcEncoding & " to " & destEncoding)
+  else:
+    result.dest = nameToCodePage(destEncoding)
+    result.src = nameToCodePage(srcEncoding)
+    if int(result.dest) == -1:
+      raise newException(EncodingError,
+        "cannot find encoding " & destEncoding)
+    if int(result.src) == -1:
+      raise newException(EncodingError,
+        "cannot find encoding " & srcEncoding)
+
+proc close*(c: EncodingConverter) =
+  ## Frees the resources the converter `c` holds.
+  when not defined(windows):
+    iconvClose(c)
+
+when defined(windows):
+  proc convertToWideString(codePage: CodePage, s: string): string =
+    # educated guess of capacity:
+    var cap = s.len + s.len shr 2
+    result = newString(cap*2)
+    # convert to utf-16 LE
+    var m = multiByteToWideChar(codePage,
+                                dwFlags = 0'i32,
+                                lpMultiByteStr = cstring(s),
+                                cbMultiByte = cint(s.len),
+                                lpWideCharStr = cstring(result),
+                                cchWideChar = cint(cap))
+    if m == 0:
+      # try again; ask for capacity:
+      cap = multiByteToWideChar(codePage,
+                                dwFlags = 0'i32,
+                                lpMultiByteStr = cstring(s),
+                                cbMultiByte = cint(s.len),
+                                lpWideCharStr = nil,
+                                cchWideChar = cint(0))
+      # and do the conversion properly:
+      result = newString(cap*2)
+      m = multiByteToWideChar(codePage,
+                              dwFlags = 0'i32,
+                              lpMultiByteStr = cstring(s),
+                              cbMultiByte = cint(s.len),
+                              lpWideCharStr = cstring(result),
+                              cchWideChar = cint(cap))
+      if m == 0: raiseOSError(osLastError())
+      setLen(result, m*2)
+    elif m <= cap:
+      setLen(result, m*2)
+    else:
+      assert(false) # cannot happen
+
+  proc convertFromWideString(codePage: CodePage, s: string): string =
+    let charCount = s.len div 2
+    var cap = s.len + s.len shr 2
+    result = newString(cap)
+    var m = wideCharToMultiByte(codePage,
+                                dwFlags = 0'i32,
+                                lpWideCharStr = cstring(s),
+                                cchWideChar = cint(charCount),
+                                lpMultiByteStr = cstring(result),
+                                cbMultiByte = cap.cint)
+    if m == 0:
+      # try again; ask for capacity:
+      cap = wideCharToMultiByte(codePage,
+                                dwFlags = 0'i32,
+                                lpWideCharStr = cstring(s),
+                                cchWideChar = cint(charCount),
+                                lpMultiByteStr = nil,
+                                cbMultiByte = cint(0))
+      # and do the conversion properly:
+      result = newString(cap)
+      m = wideCharToMultiByte(codePage,
+                              dwFlags = 0'i32,
+                              lpWideCharStr = cstring(s),
+                              cchWideChar = cint(charCount),
+                              lpMultiByteStr = cstring(result),
+                              cbMultiByte = cap.cint)
+      if m == 0: raiseOSError(osLastError())
+      setLen(result, m)
+    elif m <= cap:
+      setLen(result, m)
+    else:
+      assert(false) # cannot happen
+
+  proc convertWin(codePageFrom: CodePage, codePageTo: CodePage,
+      s: string): string =
+    # special case: empty string: needed because MultiByteToWideChar, WideCharToMultiByte
+    # return 0 in case of error
+    if s.len == 0: return ""
+    # multiByteToWideChar does not support encoding from code pages below
+    let unsupported = [1201, 12000, 12001]
+
+    if int(codePageFrom) in unsupported:
+      let message = "encoding from " & codePageToName(codePageFrom) & " is not supported on windows"
+      raise newException(EncodingError, message)
+
+    if int(codePageTo) in unsupported:
+      let message = "encoding to " & codePageToName(codePageTo) & " is not supported on windows"
+      raise newException(EncodingError, message)
+
+    # in case it's already UTF-16 little endian - conversion can be simplified
+    let wideString = if int(codePageFrom) == 1200: s
+                     else: convertToWideString(codePageFrom, s)
+    return if int(codePageTo) == 1200: wideString
+           else: convertFromWideString(codePageTo, wideString)
+
+  proc convert*(c: EncodingConverter, s: string): string =
+    result = convertWin(c.src, c.dest, s)
+else:
+  proc convert*(c: EncodingConverter, s: string): string =
+    ## Converts `s` to `destEncoding` that was given to the converter `c`. It
+    ## assumes that `s` is in `srcEncoding`.
+    ##
+    ## .. warning:: UTF-16BE and UTF-32 conversions are not supported on Windows.
+    result = newString(s.len)
+    var inLen = csize_t len(s)
+    var outLen = csize_t len(result)
+    var src = cstring(s)
+    var dst = cstring(result)
+    var iconvres: csize_t
+    while inLen > 0:
+      iconvres = iconv(c, addr src, addr inLen, addr dst, addr outLen)
+      if iconvres == high(csize_t):
+        var lerr = errno
+        if lerr == EILSEQ or lerr == EINVAL:
+          # unknown char, skip
+          dst[0] = src[0]
+          src = cast[cstring](cast[int](src) + 1)
+          dst = cast[cstring](cast[int](dst) + 1)
+          dec(inLen)
+          dec(outLen)
+        elif lerr == E2BIG:
+          var offset = cast[int](dst) - cast[int](cstring(result))
+          setLen(result, len(result) + inLen.int * 2 + 5)
+          # 5 is minimally one utf-8 char
+          dst = cast[cstring](cast[int](cstring(result)) + offset)
+          outLen = csize_t(len(result) - offset)
+        else:
+          raiseOSError(lerr.OSErrorCode)
+    # iconv has a buffer that needs flushing, specially if the last char is
+    # not '\0'
+    discard iconv(c, nil, nil, addr dst, addr outLen)
+    if iconvres == high(csize_t) and errno == E2BIG:
+      var offset = cast[int](dst) - cast[int](cstring(result))
+      setLen(result, len(result) + inLen.int * 2 + 5)
+      # 5 is minimally one utf-8 char
+      dst = cast[cstring](cast[int](cstring(result)) + offset)
+      outLen = csize_t(len(result) - offset)
+      discard iconv(c, nil, nil, addr dst, addr outLen)
+    # trim output buffer
+    setLen(result, len(result) - outLen.int)
+
+proc convert*(s: string, destEncoding = "UTF-8",
+                         srcEncoding = "CP1252"): string =
+  ## Converts `s` to `destEncoding`. It assumed that `s` is in `srcEncoding`.
+  ## This opens a converter, uses it and closes it again and is thus more
+  ## convenient but also likely less efficient than re-using a converter.
+  ##
+  ## .. warning:: UTF-16BE and UTF-32 conversions are not supported on Windows.
+  var c = open(destEncoding, srcEncoding)
+  try:
+    result = convert(c, s)
+  finally:
+    close(c)
diff --git a/lib/pure/endians.nim b/lib/pure/endians.nim
new file mode 100644
index 000000000..4c1d45ae5
--- /dev/null
+++ b/lib/pure/endians.nim
@@ -0,0 +1,148 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains helpers that deal with different byte orders
+## (`endian`:idx:).
+##
+## Endianness is the order of bytes of a value in memory. Big-endian means that
+## the most significant byte is stored at the smallest memory address,
+## while little endian means that the least-significant byte is stored
+## at the smallest address. See also https://en.wikipedia.org/wiki/Endianness.
+##
+## Unstable API.
+
+when defined(gcc) or defined(llvm_gcc) or defined(clang):
+  const useBuiltinSwap = true
+  proc builtin_bswap16(a: uint16): uint16 {.
+      importc: "__builtin_bswap16", nodecl, noSideEffect.}
+
+  proc builtin_bswap32(a: uint32): uint32 {.
+      importc: "__builtin_bswap32", nodecl, noSideEffect.}
+
+  proc builtin_bswap64(a: uint64): uint64 {.
+      importc: "__builtin_bswap64", nodecl, noSideEffect.}
+elif defined(icc):
+  const useBuiltinSwap = true
+  proc builtin_bswap16(a: uint16): uint16 {.
+      importc: "_bswap16", nodecl, noSideEffect.}
+
+  proc builtin_bswap32(a: uint32): uint32 {.
+      importc: "_bswap", nodecl, noSideEffect.}
+
+  proc builtin_bswap64(a: uint64): uint64 {.
+      importc: "_bswap64", nodecl, noSideEffect.}
+elif defined(vcc):
+  const useBuiltinSwap = true
+  proc builtin_bswap16(a: uint16): uint16 {.
+      importc: "_byteswap_ushort", nodecl, header: "<intrin.h>", noSideEffect.}
+
+  proc builtin_bswap32(a: uint32): uint32 {.
+      importc: "_byteswap_ulong", nodecl, header: "<intrin.h>", noSideEffect.}
+
+  proc builtin_bswap64(a: uint64): uint64 {.
+      importc: "_byteswap_uint64", nodecl, header: "<intrin.h>", noSideEffect.}
+else:
+  const useBuiltinSwap = false
+
+when useBuiltinSwap:
+  template swapOpImpl(T: typedesc, op: untyped) =
+    ## We have to use `copyMem` here instead of a simple dereference because they
+    ## may point to a unaligned address. A sufficiently smart compiler _should_
+    ## be able to elide them when they're not necessary.
+    var tmp: T
+    copyMem(addr tmp, inp, sizeof(T))
+    tmp = op(tmp)
+    copyMem(outp, addr tmp, sizeof(T))
+
+  proc swapEndian64*(outp, inp: pointer) {.inline, noSideEffect.} =
+    ## Copies `inp` to `outp`, reversing the byte order.
+    ## Both buffers are supposed to contain at least 8 bytes.
+    runnableExamples:
+      var a = [1'u8, 2, 3, 4, 5, 6, 7, 8]
+      var b: array[8, uint8]
+      swapEndian64(addr b, addr a)
+      assert b == [8'u8, 7, 6, 5, 4, 3, 2, 1]
+
+    swapOpImpl(uint64, builtin_bswap64)
+
+  proc swapEndian32*(outp, inp: pointer) {.inline, noSideEffect.} =
+    ## Copies `inp` to `outp`, reversing the byte order.
+    ## Both buffers are supposed to contain at least 4 bytes.
+    runnableExamples:
+      var a = [1'u8, 2, 3, 4]
+      var b: array[4, uint8]
+      swapEndian32(addr b, addr a)
+      assert b == [4'u8, 3, 2, 1]
+
+    swapOpImpl(uint32, builtin_bswap32)
+
+  proc swapEndian16*(outp, inp: pointer) {.inline, noSideEffect.} =
+    ## Copies `inp` to `outp`, reversing the byte order.
+    ## Both buffers are supposed to contain at least 2 bytes.
+    runnableExamples:
+      var a = [1'u8, 2]
+      var b: array[2, uint8]
+      swapEndian16(addr b, addr a)
+      assert b == [2'u8, 1]
+
+    swapOpImpl(uint16, builtin_bswap16)
+
+else:
+  proc swapEndian64*(outp, inp: pointer) =
+    var i = cast[cstring](inp)
+    var o = cast[cstring](outp)
+    o[0] = i[7]
+    o[1] = i[6]
+    o[2] = i[5]
+    o[3] = i[4]
+    o[4] = i[3]
+    o[5] = i[2]
+    o[6] = i[1]
+    o[7] = i[0]
+
+  proc swapEndian32*(outp, inp: pointer) =
+    var i = cast[cstring](inp)
+    var o = cast[cstring](outp)
+    o[0] = i[3]
+    o[1] = i[2]
+    o[2] = i[1]
+    o[3] = i[0]
+
+  proc swapEndian16*(outp, inp: pointer) =
+    var i = cast[cstring](inp)
+    var o = cast[cstring](outp)
+    o[0] = i[1]
+    o[1] = i[0]
+
+when system.cpuEndian == bigEndian:
+  proc littleEndian64*(outp, inp: pointer) {.inline.} = swapEndian64(outp, inp)
+  proc littleEndian32*(outp, inp: pointer) {.inline.} = swapEndian32(outp, inp)
+  proc littleEndian16*(outp, inp: pointer) {.inline.} = swapEndian16(outp, inp)
+  proc bigEndian64*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 8)
+  proc bigEndian32*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 4)
+  proc bigEndian16*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 2)
+else:
+  proc littleEndian64*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 8)
+    ## Copies `inp` to `outp`, storing it in 64-bit little-endian order.
+    ## Both buffers are supposed to contain at least 8 bytes.
+  proc littleEndian32*(outp, inp: pointer) {.inline.} = copyMem(outp, inp, 4)
+    ## Copies `inp` to `outp`, storing it in 32-bit little-endian order.
+    ## Both buffers are supposed to contain at least 4 bytes.
+  proc littleEndian16*(outp, inp: pointer){.inline.} = copyMem(outp, inp, 2)
+    ## Copies `inp` to `outp`, storing it in 16-bit little-endian order.
+    ## Both buffers are supposed to contain at least 2 bytes.
+  proc bigEndian64*(outp, inp: pointer) {.inline.} = swapEndian64(outp, inp)
+    ## Copies `inp` to `outp`, storing it in 64-bit big-endian order.
+    ## Both buffers are supposed to contain at least 8 bytes.
+  proc bigEndian32*(outp, inp: pointer) {.inline.} = swapEndian32(outp, inp)
+    ## Copies `inp` to `outp`, storing it in 32-bit big-endian order.
+    ## Both buffers are supposed to contain at least 4 bytes.
+  proc bigEndian16*(outp, inp: pointer) {.inline.} = swapEndian16(outp, inp)
+    ## Copies `inp` to `outp`, storing it in 16-bit big-endian order.
+    ## Both buffers are supposed to contain at least 2 bytes.
diff --git a/lib/pure/fenv.nim b/lib/pure/fenv.nim
new file mode 100644
index 000000000..1d96fd6be
--- /dev/null
+++ b/lib/pure/fenv.nim
@@ -0,0 +1,182 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Floating-point environment. Handling of floating-point rounding and
+## exceptions (overflow, division by zero, etc.).
+## The types, vars and procs are bindings for the C standard library
+## [<fenv.h>](https://en.cppreference.com/w/c/numeric/fenv) header.
+
+when defined(posix) and not defined(genode) and not defined(macosx):
+  {.passl: "-lm".}
+
+var
+  FE_DIVBYZERO* {.importc, header: "<fenv.h>".}: cint
+    ## division by zero
+  FE_INEXACT* {.importc, header: "<fenv.h>".}: cint
+    ## inexact result
+  FE_INVALID* {.importc, header: "<fenv.h>".}: cint
+    ## invalid operation
+  FE_OVERFLOW* {.importc, header: "<fenv.h>".}: cint
+    ## result not representable due to overflow
+  FE_UNDERFLOW* {.importc, header: "<fenv.h>".}: cint
+    ## result not representable due to underflow
+  FE_ALL_EXCEPT* {.importc, header: "<fenv.h>".}: cint
+    ## bitwise OR of all supported exceptions
+  FE_DOWNWARD* {.importc, header: "<fenv.h>".}: cint
+    ## round toward -Inf
+  FE_TONEAREST* {.importc, header: "<fenv.h>".}: cint
+    ## round to nearest
+  FE_TOWARDZERO* {.importc, header: "<fenv.h>".}: cint
+    ## round toward 0
+  FE_UPWARD* {.importc, header: "<fenv.h>".}: cint
+    ## round toward +Inf
+  FE_DFL_ENV* {.importc, header: "<fenv.h>".}: cint
+    ## macro of type pointer to `fenv_t` to be used as the argument
+    ## to functions taking an argument of type `fenv_t`; in this
+    ## case the default environment will be used
+
+type
+  Tfenv* {.importc: "fenv_t", header: "<fenv.h>", final, pure.} =
+    object ## Represents the entire floating-point environment. The
+           ## floating-point environment refers collectively to any
+           ## floating-point status flags and control modes supported
+           ## by the implementation.
+  Tfexcept* {.importc: "fexcept_t", header: "<fenv.h>", final, pure.} =
+    object ## Represents the floating-point status flags collectively,
+           ## including any status the implementation associates with the
+           ## flags. A floating-point status flag is a system variable
+           ## whose value is set (but never cleared) when a floating-point
+           ## exception is raised, which occurs as a side effect of
+           ## exceptional floating-point arithmetic to provide auxiliary
+           ## information. A floating-point control mode is a system variable
+           ## whose value may be set by the user to affect the subsequent
+           ## behavior of floating-point arithmetic.
+
+proc feclearexcept*(excepts: cint): cint {.importc, header: "<fenv.h>".}
+  ## Clear the supported exceptions represented by `excepts`.
+
+proc fegetexceptflag*(flagp: ptr Tfexcept, excepts: cint): cint {.
+  importc, header: "<fenv.h>".}
+  ## Store implementation-defined representation of the exception flags
+  ## indicated by `excepts` in the object pointed to by `flagp`.
+
+proc feraiseexcept*(excepts: cint): cint {.importc, header: "<fenv.h>".}
+  ## Raise the supported exceptions represented by `excepts`.
+
+proc fesetexceptflag*(flagp: ptr Tfexcept, excepts: cint): cint {.
+  importc, header: "<fenv.h>".}
+  ## Set complete status for exceptions indicated by `excepts` according to
+  ## the representation in the object pointed to by `flagp`.
+
+proc fetestexcept*(excepts: cint): cint {.importc, header: "<fenv.h>".}
+  ## Determine which of subset of the exceptions specified by `excepts` are
+  ## currently set.
+
+proc fegetround*(): cint {.importc, header: "<fenv.h>".}
+  ## Get current rounding direction.
+
+proc fesetround*(roundingDirection: cint): cint {.importc, header: "<fenv.h>".}
+  ## Establish the rounding direction represented by `roundingDirection`.
+
+proc fegetenv*(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
+  ## Store the current floating-point environment in the object pointed
+  ## to by `envp`.
+
+proc feholdexcept*(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
+  ## Save the current environment in the object pointed to by `envp`, clear
+  ## exception flags and install a non-stop mode (if available) for all
+  ## exceptions.
+
+proc fesetenv*(a1: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
+  ## Establish the floating-point environment represented by the object
+  ## pointed to by `envp`.
+
+proc feupdateenv*(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>".}
+  ## Save current exceptions in temporary storage, install environment
+  ## represented by object pointed to by `envp` and raise exceptions
+  ## according to saved exceptions.
+
+const
+  FLT_RADIX = 2                     ## the radix of the exponent representation
+
+  FLT_MANT_DIG = 24                ## the number of base FLT_RADIX digits in the mantissa part of a float
+  FLT_DIG = 6                      ## the number of digits of precision of a float
+  FLT_MIN_EXP = -125               ## the minimum value of base FLT_RADIX in the exponent part of a float
+  FLT_MAX_EXP = 128                ## the maximum value of base FLT_RADIX in the exponent part of a float
+  FLT_MIN_10_EXP = -37             ## the minimum value in base 10 of the exponent part of a float
+  FLT_MAX_10_EXP = 38              ## the maximum value in base 10 of the exponent part of a float
+  FLT_MIN = 1.17549435e-38'f32     ## the minimum value of a float
+  FLT_MAX = 3.40282347e+38'f32     ## the maximum value of a float
+  FLT_EPSILON = 1.19209290e-07'f32 ## the difference between 1 and the least value greater than 1 of a float
+
+  DBL_MANT_DIG = 53                    ## the number of base FLT_RADIX digits in the mantissa part of a double
+  DBL_DIG = 15                         ## the number of digits of precision of a double
+  DBL_MIN_EXP = -1021                  ## the minimum value of base FLT_RADIX in the exponent part of a double
+  DBL_MAX_EXP = 1024                   ## the maximum value of base FLT_RADIX in the exponent part of a double
+  DBL_MIN_10_EXP = -307                ## the minimum value in base 10 of the exponent part of a double
+  DBL_MAX_10_EXP = 308                 ## the maximum value in base 10 of the exponent part of a double
+  DBL_MIN = 2.2250738585072014E-308    ## the minimal value of a double
+  DBL_MAX = 1.7976931348623157E+308    ## the minimal value of a double
+  DBL_EPSILON = 2.2204460492503131E-16 ## the difference between 1 and the least value greater than 1 of a double
+
+template fpRadix*: int = FLT_RADIX
+  ## The (integer) value of the radix used to represent any floating
+  ## point type on the architecture used to build the program.
+
+template mantissaDigits*(T: typedesc[float32]): int = FLT_MANT_DIG
+  ## Number of digits (in base `floatingPointRadix`) in the mantissa
+  ## of 32-bit floating-point numbers.
+template digits*(T: typedesc[float32]): int = FLT_DIG
+  ## Number of decimal digits that can be represented in a
+  ## 32-bit floating-point type without losing precision.
+template minExponent*(T: typedesc[float32]): int = FLT_MIN_EXP
+  ## Minimum (negative) exponent for 32-bit floating-point numbers.
+template maxExponent*(T: typedesc[float32]): int = FLT_MAX_EXP
+  ## Maximum (positive) exponent for 32-bit floating-point numbers.
+template min10Exponent*(T: typedesc[float32]): int = FLT_MIN_10_EXP
+  ## Minimum (negative) exponent in base 10 for 32-bit floating-point
+  ## numbers.
+template max10Exponent*(T: typedesc[float32]): int = FLT_MAX_10_EXP
+  ## Maximum (positive) exponent in base 10 for 32-bit floating-point
+  ## numbers.
+template minimumPositiveValue*(T: typedesc[float32]): float32 = FLT_MIN
+  ## The smallest positive (nonzero) number that can be represented in a
+  ## 32-bit floating-point type.
+template maximumPositiveValue*(T: typedesc[float32]): float32 = FLT_MAX
+  ## The largest positive number that can be represented in a 32-bit
+  ## floating-point type.
+template epsilon*(T: typedesc[float32]): float32 = FLT_EPSILON
+  ## The difference between 1.0 and the smallest number greater than
+  ## 1.0 that can be represented in a 32-bit floating-point type.
+
+template mantissaDigits*(T: typedesc[float64]): int = DBL_MANT_DIG
+  ## Number of digits (in base `floatingPointRadix`) in the mantissa
+  ## of 64-bit floating-point numbers.
+template digits*(T: typedesc[float64]): int = DBL_DIG
+  ## Number of decimal digits that can be represented in a
+  ## 64-bit floating-point type without losing precision.
+template minExponent*(T: typedesc[float64]): int = DBL_MIN_EXP
+  ## Minimum (negative) exponent for 64-bit floating-point numbers.
+template maxExponent*(T: typedesc[float64]): int = DBL_MAX_EXP
+  ## Maximum (positive) exponent for 64-bit floating-point numbers.
+template min10Exponent*(T: typedesc[float64]): int = DBL_MIN_10_EXP
+  ## Minimum (negative) exponent in base 10 for 64-bit floating-point
+  ## numbers.
+template max10Exponent*(T: typedesc[float64]): int = DBL_MAX_10_EXP
+  ## Maximum (positive) exponent in base 10 for 64-bit floating-point
+  ## numbers.
+template minimumPositiveValue*(T: typedesc[float64]): float64 = DBL_MIN
+  ## The smallest positive (nonzero) number that can be represented in a
+  ## 64-bit floating-point type.
+template maximumPositiveValue*(T: typedesc[float64]): float64 = DBL_MAX
+  ## The largest positive number that can be represented in a 64-bit
+  ## floating-point type.
+template epsilon*(T: typedesc[float64]): float64 = DBL_EPSILON
+  ## The difference between 1.0 and the smallest number greater than
+  ## 1.0 that can be represented in a 64-bit floating-point type.
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim
index 1593119bd..1038d55a1 100755..100644
--- a/lib/pure/hashes.nim
+++ b/lib/pure/hashes.nim
@@ -1,97 +1,779 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module implements efficient computations of hash values for diverse
-## Nimrod types.
-
-import 
-  strutils
-
-type 
-  THash* = int ## a hash value; hash tables using these values should 
-               ## always have a size of a power of two and can use the ``and``
-               ## operator instead of ``mod`` for truncation of the hash value.
-
-proc concHash(h: THash, val: int): THash {.inline.} = 
-  result = h +% val
-  result = result +% result shl 10
-  result = result xor (result shr 6)
-
-proc finishHash(h: THash): THash {.inline.} = 
-  result = h +% h shl 3
-  result = result xor (result shr 11)
-  result = result +% result shl 15
-
-proc hashData*(Data: Pointer, Size: int): THash = 
-  ## hashes an array of bytes of size `size`
-  var 
-    h: THash
-    p: cstring
-    i, s: int
-  h = 0
-  p = cast[cstring](Data)
-  i = 0
-  s = size
-  while s > 0: 
-    h = concHash(h, ord(p[i]))
-    Inc(i)
-    Dec(s)
-  result = finishHash(h)
-
-proc hash*(x: Pointer): THash {.inline.} = 
-  ## efficient hashing of pointers
-  result = (cast[THash](x)) shr 3 # skip the alignment
-  
-proc hash*(x: int): THash {.inline.} = 
-  ## efficient hashing of integers
-  result = x
-
-proc hash*(x: int64): THash {.inline.} = 
-  ## efficient hashing of integers
-  result = toU32(x)
-
-proc hash*(x: char): THash {.inline.} = 
-  ## efficient hashing of characters
-  result = ord(x)
-
-proc hash*(x: string): THash = 
-  ## efficient hashing of strings
-  var h: THash
-  h = 0
-  for i in 0..x.len-1: 
-    h = concHash(h, ord(x[i]))
-  result = finishHash(h)
-  
-proc hashIgnoreStyle*(x: string): THash = 
-  ## efficient hashing of strings; style is ignored
-  var 
-    h: THash
-    c: Char
-  h = 0
-  for i in 0..x.len-1: 
-    c = x[i]
-    if c == '_': 
-      continue                # skip _
-    if c in {'A'..'Z'}: 
+## Nim types. All the procs are based on these two building blocks:
+## - `!& proc <#!&,Hash,int>`_ used to start or mix a hash value, and
+## - `!$ proc <#!$,Hash>`_ 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:
+
+runnableExamples:
+  type
+    Something = object
+      foo: int
+      bar: string
+
+  iterator items(x: Something): Hash =
+    yield hash(x.foo)
+    yield hash(x.bar)
+
+  proc hash(x: Something): Hash =
+    ## Computes a Hash from `x`.
+    var h: Hash = 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,
+## you can simply hash together the hash values of the individual fields:
+
+runnableExamples:
+  type
+    Something = object
+      foo: int
+      bar: string
+
+  proc hash(x: Something): Hash =
+    ## Computes a Hash from `x`.
+    var h: Hash = 0
+    h = h !& hash(x.foo)
+    h = h !& hash(x.bar)
+    result = !$h
+
+## .. important:: Use `-d:nimPreviewHashRef` to
+##    enable hashing `ref`s. It is expected that this behavior
+##    becomes the new default in upcoming versions.
+##
+## .. note:: If the type has a `==` operator, the following must hold:
+##    If two values compare equal, their hashes must also be equal.
+##
+## See also
+## ========
+## * `md5 module <md5.html>`_ for the MD5 checksum algorithm
+## * `base64 module <base64.html>`_ for a Base64 encoder and decoder
+## * `sha1 module <sha1.html>`_ for the SHA-1 checksum algorithm
+## * `tables module <tables.html>`_ for hash tables
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  Hash* = int ## A hash value. Hash tables using these values should
+              ## always have a size of a power of two so they can use the `and`
+              ## operator instead of `mod` for truncation of the hash value.
+
+proc `!&`*(h: Hash, val: int): Hash {.inline.} =
+  ## Mixes a hash value `h` with `val` to produce a new hash value.
+  ##
+  ## This is only needed if you need to implement a `hash` proc for a new datatype.
+  let h = cast[uint](h)
+  let val = cast[uint](val)
+  var res = h + val
+  res = res + res shl 10
+  res = res xor (res shr 6)
+  result = cast[Hash](res)
+
+proc `!$`*(h: Hash): Hash {.inline.} =
+  ## Finishes the computation of the hash value.
+  ##
+  ## This is only needed if you need to implement a `hash` proc for a new datatype.
+  let h = cast[uint](h) # Hash is practically unsigned.
+  var res = h + h shl 3
+  res = res xor (res shr 11)
+  res = res + res shl 15
+  result = cast[Hash](res)
+
+proc hiXorLoFallback64(a, b: uint64): uint64 {.inline.} =
+  let # Fall back in 64-bit arithmetic
+    aH = a shr 32
+    aL = a and 0xFFFFFFFF'u64
+    bH = b shr 32
+    bL = b and 0xFFFFFFFF'u64
+    rHH = aH * bH
+    rHL = aH * bL
+    rLH = aL * bH
+    rLL = aL * bL
+    t = rLL + (rHL shl 32)
+  var c = if t < rLL: 1'u64 else: 0'u64
+  let lo = t + (rLH shl 32)
+  c += (if lo < t: 1'u64 else: 0'u64)
+  let hi = rHH + (rHL shr 32) + (rLH shr 32) + c
+  return hi xor lo
+
+proc hiXorLo(a, b: uint64): uint64 {.inline.} =
+  # XOR of the high & low 8 bytes of the full 16 byte product.
+  when nimvm:
+    result = hiXorLoFallback64(a, b) # `result =` is necessary here.
+  else:
+    when Hash.sizeof < 8:
+      result = hiXorLoFallback64(a, b)
+    elif defined(gcc) or defined(llvm_gcc) or defined(clang):
+      {.emit: """__uint128_t r = `a`; r *= `b`; `result` = (r >> 64) ^ r;""".}
+    elif defined(windows) and not defined(tcc):
+      proc umul128(a, b: uint64, c: ptr uint64): uint64 {.importc: "_umul128", header: "intrin.h".}
+      var b = b
+      let c = umul128(a, b, addr b)
+      result = c xor b
+    else:
+      result = hiXorLoFallback64(a, b)
+
+when defined(js):
+  import std/jsbigints
+  import std/private/jsutils
+
+  proc hiXorLoJs(a, b: JsBigInt): JsBigInt =
+    let
+      prod = a * b
+      mask = big"0xffffffffffffffff" # (big"1" shl big"64") - big"1"
+    result = (prod shr big"64") xor (prod and mask)
+
+  template hashWangYiJS(x: JsBigInt): Hash =
+    let
+      P0 = big"0xa0761d6478bd642f"
+      P1 = big"0xe7037ed1a0b428db"
+      P58 = big"0xeb44accab455d16d" # big"0xeb44accab455d165" xor big"8"
+      res = hiXorLoJs(hiXorLoJs(P0, x xor P1), P58)
+    cast[Hash](toNumber(wrapToInt(res, 32)))
+
+  template toBits(num: float): JsBigInt =
+    let
+      x = newArrayBuffer(8)
+      y = newFloat64Array(x)
+    if hasBigUint64Array():
+      let z = newBigUint64Array(x)
+      y[0] = num
+      z[0]
+    else:
+      let z = newUint32Array(x)
+      y[0] = num
+      big(z[0]) + big(z[1]) shl big(32)
+
+proc hashWangYi1*(x: int64|uint64|Hash): Hash {.inline.} =
+  ## Wang Yi's hash_v1 for 64-bit ints (see https://github.com/rurban/smhasher for
+  ## more details). This passed all scrambling tests in Spring 2019 and is simple.
+  ##
+  ## **Note:** It's ok to define `proc(x: int16): Hash = hashWangYi1(Hash(x))`.
+  const P0  = 0xa0761d6478bd642f'u64
+  const P1  = 0xe7037ed1a0b428db'u64
+  const P58 = 0xeb44accab455d165'u64 xor 8'u64
+  template h(x): untyped = hiXorLo(hiXorLo(P0, uint64(x) xor P1), P58)
+  when nimvm:
+    when defined(js): # Nim int64<->JS Number & VM match => JS gets 32-bit hash
+      result = cast[Hash](h(x)) and cast[Hash](0xFFFFFFFF)
+    else:
+      result = cast[Hash](h(x))
+  else:
+    when defined(js):
+      if hasJsBigInt():
+        result = hashWangYiJS(big(x))
+      else:
+        result = cast[Hash](x) and cast[Hash](0xFFFFFFFF)
+    else:
+      result = cast[Hash](h(x))
+
+proc hashData*(data: pointer, size: int): Hash =
+  ## Hashes an array of bytes of size `size`.
+  var h: Hash = 0
+  when defined(js):
+    var p: cstring
+    {.emit: """`p` = `Data`;""".}
+  else:
+    var p = cast[cstring](data)
+  var i = 0
+  var s = size
+  while s > 0:
+    h = h !& ord(p[i])
+    inc(i)
+    dec(s)
+  result = !$h
+
+proc hashIdentity*[T: Ordinal|enum](x: T): Hash {.inline, since: (1, 3).} =
+  ## The identity hash, i.e. `hashIdentity(x) = x`.
+  cast[Hash](ord(x))
+
+when defined(nimIntHash1):
+  proc hash*[T: Ordinal|enum](x: T): Hash {.inline.} =
+    ## Efficient hashing of integers.
+    cast[Hash](ord(x))
+else:
+  proc hash*[T: Ordinal|enum](x: T): Hash {.inline.} =
+    ## Efficient hashing of integers.
+    hashWangYi1(uint64(ord(x)))
+
+when defined(js):
+  var objectID = 0
+  proc getObjectId(x: pointer): int =
+    {.emit: """
+      if (typeof `x` == "object") {
+        if ("_NimID" in `x`)
+          `result` = `x`["_NimID"];
+        else {
+          `result` = ++`objectID`;
+          `x`["_NimID"] = `result`;
+        }
+      }
+    """.}
+
+proc hash*(x: pointer): Hash {.inline.} =
+  ## Efficient `hash` overload.
+  when defined(js):
+    let y = getObjectId(x)
+  else:
+    let y = cast[int](x)
+  hash(y) # consistent with code expecting scrambled hashes depending on `nimIntHash1`.
+
+proc hash*[T](x: ptr[T]): Hash {.inline.} =
+  ## Efficient `hash` overload.
+  runnableExamples:
+    var a: array[10, uint8]
+    assert a[0].addr.hash != a[1].addr.hash
+    assert cast[pointer](a[0].addr).hash == a[0].addr.hash
+  hash(cast[pointer](x))
+
+when defined(nimPreviewHashRef) or defined(nimdoc):
+  proc hash*[T](x: ref[T]): Hash {.inline.} =
+    ## Efficient `hash` overload.
+    ##
+    ## .. important:: Use `-d:nimPreviewHashRef` to
+    ##    enable hashing `ref`s. It is expected that this behavior
+    ##    becomes the new default in upcoming versions.
+    runnableExamples("-d:nimPreviewHashRef"):
+      type A = ref object
+        x: int
+      let a = A(x: 3)
+      let ha = a.hash
+      assert ha != A(x: 3).hash # A(x: 3) is a different ref object from `a`.
+      a.x = 4
+      assert ha == a.hash # the hash only depends on the address
+    runnableExamples("-d:nimPreviewHashRef"):
+      # you can overload `hash` if you want to customize semantics
+      type A[T] = ref object
+        x, y: T
+      proc hash(a: A): Hash = hash(a.x)
+      assert A[int](x: 3, y: 4).hash == A[int](x: 3, y: 5).hash
+    # xxx pending bug #17733, merge as `proc hash*(pointer | ref | ptr): Hash`
+    # or `proc hash*[T: ref | ptr](x: T): Hash`
+    hash(cast[pointer](x))
+
+proc hash*(x: float): Hash {.inline.} =
+  ## Efficient hashing of floats.
+  let y = x + 0.0 # for denormalization
+  when nimvm:
+    # workaround a JS VM bug: bug #16547
+    result = hashWangYi1(cast[int64](float64(y)))
+  else:
+    when not defined(js):
+      result = hashWangYi1(cast[Hash](y))
+    else:
+      result = hashWangYiJS(toBits(y))
+
+# Forward declarations before methods that hash containers. This allows
+# containers to contain other containers
+proc hash*[A](x: openArray[A]): Hash
+proc hash*[A](x: set[A]): Hash
+
+
+when defined(js):
+  proc imul(a, b: uint32): uint32 =
+    # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
+    let mask = 0xffff'u32
+    var
+      aHi = (a shr 16) and mask
+      aLo = a and mask
+      bHi = (b shr 16) and mask
+      bLo = b and mask
+    result = (aLo * bLo) + (aHi * bLo + aLo * bHi) shl 16
+else:
+  template imul(a, b: uint32): untyped = a * b
+
+proc rotl32(x: uint32, r: int): uint32 {.inline.} =
+  (x shl r) or (x shr (32 - r))
+
+proc murmurHash(x: openArray[byte]): Hash =
+  # https://github.com/PeterScott/murmur3/blob/master/murmur3.c
+  const
+    c1 = 0xcc9e2d51'u32
+    c2 = 0x1b873593'u32
+    n1 = 0xe6546b64'u32
+    m1 = 0x85ebca6b'u32
+    m2 = 0xc2b2ae35'u32
+  let
+    size = len(x)
+    stepSize = 4 # 32-bit
+    n = size div stepSize
+  var
+    h1: uint32
+    i = 0
+
+
+  template impl =
+    var j = stepSize
+    while j > 0:
+      dec j
+      k1 = (k1 shl 8) or (ord(x[i+j])).uint32
+
+  # body
+  while i < n * stepSize:
+    var k1: uint32
+
+    when nimvm:
+      impl()
+    else:
+      when declared(copyMem):
+        copyMem(addr k1, addr x[i], 4)
+      else:
+        impl()
+    inc i, stepSize
+
+    k1 = imul(k1, c1)
+    k1 = rotl32(k1, 15)
+    k1 = imul(k1, c2)
+
+    h1 = h1 xor k1
+    h1 = rotl32(h1, 13)
+    h1 = h1*5 + n1
+
+  # tail
+  var k1: uint32
+  var rem = size mod stepSize
+  while rem > 0:
+    dec rem
+    k1 = (k1 shl 8) or (ord(x[i+rem])).uint32
+  k1 = imul(k1, c1)
+  k1 = rotl32(k1, 15)
+  k1 = imul(k1, c2)
+  h1 = h1 xor k1
+
+  # finalization
+  h1 = h1 xor size.uint32
+  h1 = h1 xor (h1 shr 16)
+  h1 = imul(h1, m1)
+  h1 = h1 xor (h1 shr 13)
+  h1 = imul(h1, m2)
+  h1 = h1 xor (h1 shr 16)
+  return cast[Hash](h1)
+
+proc hashVmImpl(x: cstring, sPos, ePos: int): Hash =
+  raiseAssert "implementation override in compiler/vmops.nim"
+
+proc hashVmImpl(x: string, sPos, ePos: int): Hash =
+  raiseAssert "implementation override in compiler/vmops.nim"
+
+proc hashVmImplChar(x: openArray[char], sPos, ePos: int): Hash =
+  raiseAssert "implementation override in compiler/vmops.nim"
+
+proc hashVmImplByte(x: openArray[byte], sPos, ePos: int): Hash =
+  raiseAssert "implementation override in compiler/vmops.nim"
+
+const k0 = 0xc3a5c85c97cb3127u64 # Primes on (2^63, 2^64) for various uses
+const k1 = 0xb492b66fbe98f273u64
+const k2 = 0x9ae16a3b2f90404fu64
+
+proc load4e(s: openArray[byte], o=0): uint32 {.inline.} =
+  uint32(s[o + 3]) shl 24 or uint32(s[o + 2]) shl 16 or
+  uint32(s[o + 1]) shl  8 or uint32(s[o + 0])
+
+proc load8e(s: openArray[byte], o=0): uint64 {.inline.} =
+  uint64(s[o + 7]) shl 56 or uint64(s[o + 6]) shl 48 or
+  uint64(s[o + 5]) shl 40 or uint64(s[o + 4]) shl 32 or
+  uint64(s[o + 3]) shl 24 or uint64(s[o + 2]) shl 16 or
+  uint64(s[o + 1]) shl  8 or uint64(s[o + 0])
+
+proc load4(s: openArray[byte], o=0): uint32 {.inline.} =
+  when nimvm: result = load4e(s, o)
+  else:
+    when declared copyMem: copyMem result.addr, s[o].addr, result.sizeof
+    else: result = load4e(s, o)
+
+proc load8(s: openArray[byte], o=0): uint64 {.inline.} =
+  when nimvm: result = load8e(s, o)
+  else:
+    when declared copyMem: copyMem result.addr, s[o].addr, result.sizeof
+    else: result = load8e(s, o)
+
+proc lenU(s: openArray[byte]): uint64 {.inline.} = s.len.uint64
+
+proc shiftMix(v: uint64): uint64 {.inline.} = v xor (v shr 47)
+
+proc rotR(v: uint64; bits: cint): uint64 {.inline.} =
+  (v shr bits) or (v shl (64 - bits))
+
+proc len16(u: uint64; v: uint64; mul: uint64): uint64 {.inline.} =
+  var a = (u xor v)*mul
+  a = a xor (a shr 47)
+  var b = (v xor a)*mul
+  b = b xor (b shr 47)
+  b*mul
+
+proc len0_16(s: openArray[byte]): uint64 {.inline.} =
+  if s.len >= 8:
+    let mul = k2 + 2*s.lenU
+    let a   = load8(s) + k2
+    let b   = load8(s, s.len - 8)
+    let c   = rotR(b, 37)*mul + a
+    let d   = (rotR(a, 25) + b)*mul
+    len16 c, d, mul
+  elif s.len >= 4:
+    let mul = k2 + 2*s.lenU
+    let a   = load4(s).uint64
+    len16 s.lenU + (a shl 3), load4(s, s.len - 4), mul
+  elif s.len > 0:
+    let a = uint32(s[0])
+    let b = uint32(s[s.len shr 1])
+    let c = uint32(s[s.len - 1])
+    let y = a      + (b shl 8)
+    let z = s.lenU + (c shl 2)
+    shiftMix(y*k2 xor z*k0)*k2
+  else: k2      # s.len == 0
+
+proc len17_32(s: openArray[byte]): uint64 {.inline.} =
+  let mul = k2 + 2*s.lenU
+  let a = load8(s)*k1
+  let b = load8(s, 8)
+  let c = load8(s, s.len - 8)*mul
+  let d = load8(s, s.len - 16)*k2
+  len16 rotR(a + b, 43) + rotR(c, 30) + d, a + rotR(b + k2, 18) + c, mul
+
+proc len33_64(s: openArray[byte]): uint64 {.inline.} =
+  let mul = k2 + 2*s.lenU
+  let a = load8(s)*k2
+  let b = load8(s, 8)
+  let c = load8(s, s.len - 8)*mul
+  let d = load8(s, s.len - 16)*k2
+  let y = rotR(a + b, 43) + rotR(c, 30) + d
+  let z = len16(y, a + rotR(b + k2, 18) + c, mul)
+  let e = load8(s, 16)*mul
+  let f = load8(s, 24)
+  let g = (y + load8(s, s.len - 32))*mul
+  let h = (z + load8(s, s.len - 24))*mul
+  len16 rotR(e + f, 43) + rotR(g, 30) + h, e + rotR(f + a, 18) + g, mul
+
+type Pair = tuple[first, second: uint64]
+
+proc weakLen32withSeeds2(w, x, y, z, a, b: uint64): Pair {.inline.} =
+  var a = a + w
+  var b = rotR(b + a + z, 21)
+  let c = a
+  a += x
+  a += y
+  b += rotR(a, 44)
+  result[0] = a + z
+  result[1] = b + c
+
+proc weakLen32withSeeds(s: openArray[byte]; o: int; a,b: uint64): Pair {.inline.} =
+  weakLen32withSeeds2 load8(s, o     ), load8(s, o + 8),
+                      load8(s, o + 16), load8(s, o + 24), a, b
+
+proc hashFarm(s: openArray[byte]): uint64 {.inline.} =
+  if s.len <= 16: return len0_16(s)
+  if s.len <= 32: return len17_32(s)
+  if s.len <= 64: return len33_64(s)
+  const seed = 81u64 # not const to use input `h`
+  var
+    o = 0         # s[] ptr arith -> variable origin variable `o`
+    x = seed
+    y = seed*k1 + 113
+    z = shiftMix(y*k2 + 113)*k2
+    v, w: Pair
+  x = x*k2 + load8(s)
+  let eos    = ((s.len - 1) div 64)*64
+  let last64 = eos + ((s.len - 1) and 63) - 63
+  while true:
+    x = rotR(x + y + v[0] + load8(s, o+8), 37)*k1
+    y = rotR(y + v[1] + load8(s, o+48), 42)*k1
+    x = x xor w[1]
+    y += v[0] + load8(s, o+40)
+    z = rotR(z + w[0], 33)*k1
+    v = weakLen32withSeeds(s, o+0 , v[1]*k1, x + w[0])
+    w = weakLen32withSeeds(s, o+32, z + w[1], y + load8(s, o+16))
+    swap z, x
+    inc o, 64
+    if o == eos: break
+  let mul = k1 + ((z and 0xff) shl 1)
+  o = last64
+  w[0] += (s.lenU - 1) and 63
+  v[0] += w[0]
+  w[0] += v[0]
+  x = rotR(x + y + v[0] + load8(s, o+8), 37)*mul
+  y = rotR(y + v[1] + load8(s, o+48), 42)*mul
+  x = x xor w[1]*9
+  y += v[0]*9 + load8(s, o+40)
+  z = rotR(z + w[0], 33)*mul
+  v = weakLen32withSeeds(s, o+0 , v[1]*mul, x + w[0])
+  w = weakLen32withSeeds(s, o+32, z + w[1], y + load8(s, o+16))
+  swap z, x
+  len16 len16(v[0],w[0],mul) + shiftMix(y)*k0 + z, len16(v[1],w[1],mul) + x, mul
+
+template jsNoInt64: untyped =
+  when defined js:
+    when compiles(compileOption("jsbigint64")):
+      when not compileOption("jsbigint64"): true
+      else: false
+    else: false
+  else: false
+const sHash2 = (when defined(nimStringHash2) or jsNoInt64(): true else: false)
+
+template maybeFailJS_Number =
+  when jsNoInt64() and not defined(nimStringHash2):
+    {.error: "Must use `-d:nimStringHash2` when using `--jsbigint64:off`".}
+
+proc hash*(x: string): Hash =
+  ## Efficient hashing of strings.
+  ##
+  ## **See also:**
+  ## * `hashIgnoreStyle <#hashIgnoreStyle,string>`_
+  ## * `hashIgnoreCase <#hashIgnoreCase,string>`_
+  runnableExamples:
+    doAssert hash("abracadabra") != hash("AbracadabrA")
+  maybeFailJS_Number()
+  when not sHash2:
+    result = cast[Hash](hashFarm(toOpenArrayByte(x, 0, x.high)))
+  else:
+    #when nimvm:
+    #  result = hashVmImpl(x, 0, high(x))
+    when true:
+      result = murmurHash(toOpenArrayByte(x, 0, high(x)))
+
+proc hash*(x: cstring): Hash =
+  ## Efficient hashing of null-terminated strings.
+  runnableExamples:
+    doAssert hash(cstring"abracadabra") == hash("abracadabra")
+    doAssert hash(cstring"AbracadabrA") == hash("AbracadabrA")
+    doAssert hash(cstring"abracadabra") != hash(cstring"AbracadabrA")
+
+  maybeFailJS_Number()
+  when not sHash2:
+    when defined js:
+      let xx = $x
+      result = cast[Hash](hashFarm(toOpenArrayByte(xx, 0, xx.high)))
+    else:
+      result = cast[Hash](hashFarm(toOpenArrayByte(x, 0, x.high)))
+  else:
+    #when nimvm:
+    #  result = hashVmImpl(x, 0, high(x))
+    when true:
+      when not defined(js):
+        result = murmurHash(toOpenArrayByte(x, 0, x.high))
+      else:
+        let xx = $x
+        result = murmurHash(toOpenArrayByte(xx, 0, high(xx)))
+
+proc hash*(sBuf: string, sPos, ePos: int): Hash =
+  ## Efficient hashing of a string buffer, from starting
+  ## position `sPos` to ending position `ePos` (included).
+  ##
+  ## `hash(myStr, 0, myStr.high)` is equivalent to `hash(myStr)`.
+  runnableExamples:
+    var a = "abracadabra"
+    doAssert hash(a, 0, 3) == hash(a, 7, 10)
+
+  maybeFailJS_Number()
+  when not sHash2:
+    result = cast[Hash](hashFarm(toOpenArrayByte(sBuf, sPos, ePos)))
+  else:
+    murmurHash(toOpenArrayByte(sBuf, sPos, ePos))
+
+proc hashIgnoreStyle*(x: string): Hash =
+  ## Efficient hashing of strings; style is ignored.
+  ##
+  ## **Note:** This uses a different hashing algorithm than `hash(string)`.
+  ##
+  ## **See also:**
+  ## * `hashIgnoreCase <#hashIgnoreCase,string>`_
+  runnableExamples:
+    doAssert hashIgnoreStyle("aBr_aCa_dAB_ra") == hashIgnoreStyle("abracadabra")
+    doAssert hashIgnoreStyle("abcdefghi") != hash("abcdefghi")
+
+  var h: Hash = 0
+  var i = 0
+  let xLen = x.len
+  while i < xLen:
+    var c = x[i]
+    if c == '_':
+      inc(i)
+    else:
+      if c in {'A'..'Z'}:
+        c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
+      h = h !& ord(c)
+      inc(i)
+  result = !$h
+
+proc hashIgnoreStyle*(sBuf: string, sPos, ePos: int): Hash =
+  ## Efficient hashing of a string buffer, from starting
+  ## position `sPos` to ending position `ePos` (included); style is ignored.
+  ##
+  ## **Note:** This uses a different hashing algorithm than `hash(string)`.
+  ##
+  ## `hashIgnoreStyle(myBuf, 0, myBuf.high)` is equivalent
+  ## to `hashIgnoreStyle(myBuf)`.
+  runnableExamples:
+    var a = "ABracada_b_r_a"
+    doAssert hashIgnoreStyle(a, 0, 3) == hashIgnoreStyle(a, 7, a.high)
+
+  var h: Hash = 0
+  var i = sPos
+  while i <= ePos:
+    var c = sBuf[i]
+    if c == '_':
+      inc(i)
+    else:
+      if c in {'A'..'Z'}:
+        c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
+      h = h !& ord(c)
+      inc(i)
+  result = !$h
+
+proc hashIgnoreCase*(x: string): Hash =
+  ## Efficient hashing of strings; case is ignored.
+  ##
+  ## **Note:** This uses a different hashing algorithm than `hash(string)`.
+  ##
+  ## **See also:**
+  ## * `hashIgnoreStyle <#hashIgnoreStyle,string>`_
+  runnableExamples:
+    doAssert hashIgnoreCase("ABRAcaDABRA") == hashIgnoreCase("abRACAdabra")
+    doAssert hashIgnoreCase("abcdefghi") != hash("abcdefghi")
+
+  var h: Hash = 0
+  for i in 0..x.len-1:
+    var c = x[i]
+    if c in {'A'..'Z'}:
       c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
-    h = concHash(h, ord(c))
-  result = finishHash(h)
-
-proc hashIgnoreCase*(x: string): THash = 
-  ## efficient hashing of strings; case is ignored
-  var 
-    h: THash
-    c: Char
-  h = 0
-  for i in 0..x.len-1: 
-    c = x[i]
-    if c in {'A'..'Z'}: 
+    h = h !& ord(c)
+  result = !$h
+
+proc hashIgnoreCase*(sBuf: string, sPos, ePos: int): Hash =
+  ## Efficient hashing of a string buffer, from starting
+  ## position `sPos` to ending position `ePos` (included); case is ignored.
+  ##
+  ## **Note:** This uses a different hashing algorithm than `hash(string)`.
+  ##
+  ## `hashIgnoreCase(myBuf, 0, myBuf.high)` is equivalent
+  ## to `hashIgnoreCase(myBuf)`.
+  runnableExamples:
+    var a = "ABracadabRA"
+    doAssert hashIgnoreCase(a, 0, 3) == hashIgnoreCase(a, 7, 10)
+
+  var h: Hash = 0
+  for i in sPos..ePos:
+    var c = sBuf[i]
+    if c in {'A'..'Z'}:
       c = chr(ord(c) + (ord('a') - ord('A'))) # toLower()
-    h = concHash(h, ord(c))
-  result = finishHash(h)
+    h = h !& ord(c)
+  result = !$h
+
+proc hash*[T: tuple | object | proc | iterator {.closure.}](x: T): Hash =
+  ## Efficient `hash` overload.
+  runnableExamples:
+    # for `tuple|object`, `hash` must be defined for each component of `x`.
+    type Obj = object
+      x: int
+      y: string
+    type Obj2[T] = object
+      x: int
+      y: string
+    assert hash(Obj(x: 520, y: "Nim")) != hash(Obj(x: 520, y: "Nim2"))
+    # you can define custom hashes for objects (even if they're generic):
+    proc hash(a: Obj2): Hash = hash((a.x))
+    assert hash(Obj2[float](x: 520, y: "Nim")) == hash(Obj2[float](x: 520, y: "Nim2"))
+  runnableExamples:
+    # proc
+    proc fn1() = discard
+    const fn1b = fn1
+    assert hash(fn1b) == hash(fn1)
+
+    # closure
+    proc outer =
+      var a = 0
+      proc fn2() = a.inc
+      assert fn2 is "closure"
+      let fn2b = fn2
+      assert hash(fn2b) == hash(fn2)
+      assert hash(fn2) != hash(fn1)
+    outer()
+
+  when T is "closure":
+    result = hash((rawProc(x), rawEnv(x)))
+  elif T is (proc):
+    result = hash(cast[pointer](x))
+  else:
+    result = 0
+    for f in fields(x):
+      result = result !& hash(f)
+    result = !$result
+
+proc hash*[A](x: openArray[A]): Hash =
+  ## Efficient hashing of arrays and sequences.
+  ## There must be a `hash` proc defined for the element type `A`.
+  when A is byte:
+    when not sHash2:
+      result = cast[Hash](hashFarm(x))
+    else:
+      result = murmurHash(x)
+  elif A is char:
+    when not sHash2:
+      result = cast[Hash](hashFarm(toOpenArrayByte(x, 0, x.high)))
+    else:
+      #when nimvm:
+      #  result = hashVmImplChar(x, 0, x.high)
+      when true:
+        result = murmurHash(toOpenArrayByte(x, 0, x.high))
+  else:
+    result = 0
+    for a in x:
+      result = result !& hash(a)
+    result = !$result
+
+proc hash*[A](aBuf: openArray[A], sPos, ePos: int): Hash =
+  ## Efficient hashing of portions of arrays and sequences, from starting
+  ## position `sPos` to ending position `ePos` (included).
+  ## There must be a `hash` proc defined for the element type `A`.
+  ##
+  ## `hash(myBuf, 0, myBuf.high)` is equivalent to `hash(myBuf)`.
+  runnableExamples:
+    let a = [1, 2, 5, 1, 2, 6]
+    doAssert hash(a, 0, 1) == hash(a, 3, 4)
+  when A is byte:
+    maybeFailJS_Number()
+    when not sHash2:
+      result = cast[Hash](hashFarm(toOpenArray(aBuf, sPos, ePos)))
+    else:
+      #when nimvm:
+      #  result = hashVmImplByte(aBuf, sPos, ePos)
+      when true:
+        result = murmurHash(toOpenArray(aBuf, sPos, ePos))
+  elif A is char:
+    maybeFailJS_Number()
+    when not sHash2:
+      result = cast[Hash](hashFarm(toOpenArrayByte(aBuf, sPos, ePos)))
+    else:
+      #when nimvm:
+      #  result = hashVmImplChar(aBuf, sPos, ePos)
+      when true:
+        result = murmurHash(toOpenArrayByte(aBuf, sPos, ePos))
+  else:
+    for i in sPos .. ePos:
+      result = result !& hash(aBuf[i])
+    result = !$result
+
+proc hash*[A](x: set[A]): Hash =
+  ## Efficient hashing of sets.
+  ## There must be a `hash` proc defined for the element type `A`.
+  result = 0
+  for it in items(x):
+    result = result !& hash(it)
+  result = !$result
diff --git a/lib/pure/hashtabs.nim b/lib/pure/hashtabs.nim
deleted file mode 100755
index 68d19d63b..000000000
--- a/lib/pure/hashtabs.nim
+++ /dev/null
@@ -1,163 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## The ``hashtabs`` module implements an efficient generic hash
-## table/dictionary data type. 
-
-import
-  hashes
-
-const
-  growthFactor = 2
-  startSize = 8
-  sham = sizeof(THash)*8-2 # shift amount
-  mask = 0b11 shl sham
-  usedSlot = 0b10 shl sham
-  delSlot =  0b01 shl sham
-  emptySlot = 0
-
-type
-  TTable*[TKey, TValue] = object
-    counter: int
-    data: seq[tuple[key: TKey, val: TValue, h: THash]]
-
-proc init*(t: var TTable, size = startSize) =
-  t.counter = 0
-  newSeq(t.data, size)
-
-proc markUsed(h: THash): THash {.inline.} =
-  return h and not mask or usedSlot
-
-proc len*(t: TTable): int {.inline.} =
-  ## returns the number of keys in `t`.
-  result = t.counter
-
-proc mustRehash(length, counter: int): bool =
-  assert(length > counter)
-  result = (length * 2 < counter * 3) or (length - counter < 4)
-
-proc nextTry(h, maxHash: THash): THash {.inline.} =
-  result = ((5 * h) + 1) and maxHash
-
-template eq(a, b: expr): expr = a == b
-
-proc rawGet(t: TTable, key: TKey, fullhash: THash): int =
-  var h = fullhash and high(t.data)
-  while (t.data[h].h and mask) != 0:
-    # If it is a deleted entry, the comparison with ``markUsed(fullhash)``
-    # fails, so there is no need to check for this explicitely.
-    if t.data[h].h == markUsed(fullhash) and eq(t.data[h].key, key): return h
-    h = nextTry(h, high(t.data))
-  result = - 1
-
-proc `[]`*(t: TTable, key: TKey): TValue =
-  ## retrieves the value at ``t[key]``. If `key` is not in `t`,
-  ## `EInvalidValue` is raised.
-  var index = rawGet(t, key, hash(key))
-  if index >= 0: result = t.data[index].val
-  else:
-    var e: ref EInvalidValue
-    new(e)
-    e.msg = "invalid key: " & $key
-    raise e
-
-proc hasKey*(t: TTable, key: TKey): bool =
-  ## returns true iff `key` is in the table `t`.
-  result = rawGet(t, key) >= 0
-
-proc rawInsert[TKey, TValue](
-               data: var seq[tuple[key: TKey, val: TValue, h: THash]],
-               tup: tuple[key: TKey, val: TValue, h: THash]) =
-  var h = tup.h and high(data)
-  while (data[h].h and mask) == usedSlot: h = nextTry(h, high(data))
-  data[h] = tup
-
-proc enlarge(t: var TTable) =
-  var n: seq[tuple[key: TKey, val: TValue, h: THash]]
-  newSeq(n, len(t.data) * growthFactor)
-  for i in 0..high(t.data):
-    if (t.data[i].h and mask) == usedSlot: rawInsert(n, t.data[i])
-  swap(t.data, n)
-
-proc `[]=`*(t: var TTable, key: TKey, val: TValue) =
-  ## puts a (key, value)-pair into `t`.
-  var fullhash = hash(key)
-  var index = rawGet(t, key, fullhash)
-  if index >= 0:
-    t.data[index].val = val
-  else:
-    if mustRehash(len(t.data), t.counter): enlarge(t)
-    rawInsert(t.data, (key, val, markUsed(fullhash)))
-    inc(t.counter)
-
-proc add*(t: var TTable, key: TKey, val: TValue) =
-  ## puts a (key, value)-pair into `t`, but does not check if key already
-  ## exists.
-  if mustRehash(len(t.data), t.counter): enlarge(t)
-  rawInsert(t.data, (key, val, markUsed(hash(key))))
-  inc(t.counter)
-
-proc del*(t: var TTable, key: TKey) =
-  ## deletes a (key, val)-pair in `t`.
-  var index = rawGet(t, key)
-  if index >= 0:
-    t.data[index].h = delSlot
-
-proc delAll*(t: var TTable, key: TKey) =
-  ## deletes all (key, val)-pairs in `t`.
-  while true:
-    var index = rawGet(t, key)
-    if index < 0: break
-    t.data[index].h = delSlot
-
-iterator pairs*(t: TTable): tuple[key: TKey, value: TValue] =
-  ## iterates over any (key, value) pair in the table `t`.
-  for h in 0..high(t.data):
-    if (t.data[h].h and mask) == usedSlot:
-      yield (t.data[h].key, t.data[h].val)
-
-iterator keys*(t: TTable): TKey =
-  ## iterate over any key in the table `t`. If key occurs multiple times, it
-  ## is yielded multiple times.
-  for h in 0..high(t.data):
-    if (t.data[h].h and mask) == usedSlot:
-      yield t.data[h].key
-
-iterator values*(t: TTable): TValue =
-  ## iterate over any value in the table `t`. 
-  for h in 0..high(t.data):
-    if (t.data[h].h and mask) == usedSlot:
-      yield t.data[h].val
-
-iterator values*(t: TTable, key: TKey): TValue =
-  ## iterate over any value associated with `key` in `t`.
-  var fullhash = hash(key)
-  var h = fullhash and high(t.data)
-  while (t.data[h].h and mask) != 0:
-    # If it is a deleted entry, the comparison with ``markUsed(fullhash)``
-    # fails, so there is no need to check for this explicitely.
-    if t.data[h].h == markUsed(fullhash) and eq(t.data[h].key, key): 
-      yield t.data[h].val
-    h = nextTry(h, high(t.data))
-
-proc `$`*[KeyToStr=`$`, ValueToStr=`$`](t: TTable): string =
-  ## turns the table into its string representation. `$` must be available
-  ## for TKey and TValue for this to work.
-  if t.len == 0:
-    result = "{:}"
-  else:
-    result = "{"
-    var i = 0
-    for k, v in pairs(t):
-      if i > 0: add(result, ", ")
-      add(result, KeyToStr(k))
-      add(result, ": ")
-      add(result, ValueToStr(v))
-      inc(i)
-    add(result, "}")
diff --git a/lib/pure/htmlgen.nim b/lib/pure/htmlgen.nim
new file mode 100644
index 000000000..fafa72463
--- /dev/null
+++ b/lib/pure/htmlgen.nim
@@ -0,0 +1,812 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Do yourself a favor and import the module
+## as `from std/htmlgen import nil` and then fully qualify the macros.
+##
+## *Note*: The Karax project (`nimble install karax`) has a better
+## way to achieve the same, see https://github.com/pragmagic/karax/blob/master/tests/nativehtmlgen.nim
+## for an example.
+##
+##
+## This module implements a simple `XML`:idx: and `HTML`:idx: code
+## generator. Each commonly used HTML tag has a corresponding macro
+## that generates a string with its HTML representation.
+##
+## MathML
+## ======
+##
+## `MathML <https://wikipedia.org/wiki/MathML>`_ is supported, MathML is part of HTML5.
+## `MathML <https://wikipedia.org/wiki/MathML>`_ is an Standard ISO/IEC 40314 from year 2015.
+## MathML allows you to `draw advanced math on the web <https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#Examples>`_,
+## `visually similar to Latex math. <https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics#Example>`_
+##
+## Examples
+## ========
+##
+##   ```Nim
+##   var nim = "Nim"
+##   echo h1(a(href="https://nim-lang.org", nim))
+##   ```
+##
+## Writes the string:
+##
+##     <h1><a href="https://nim-lang.org">Nim</a></h1>
+##
+
+import
+  std/[macros, strutils]
+
+const
+  coreAttr* = " accesskey class contenteditable dir hidden id lang " &
+    "spellcheck style tabindex title translate " ## HTML DOM Core Attributes
+  eventAttr* = "onabort onblur oncancel oncanplay oncanplaythrough onchange " &
+    "onclick oncuechange ondblclick ondurationchange onemptied onended " &
+    "onerror onfocus oninput oninvalid onkeydown onkeypress onkeyup onload " &
+    "onloadeddata onloadedmetadata onloadstart onmousedown onmouseenter " &
+    "onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel " &
+    "onpause onplay onplaying onprogress onratechange onreset onresize " &
+    "onscroll onseeked onseeking onselect onshow onstalled onsubmit " &
+    "onsuspend ontimeupdate ontoggle onvolumechange onwaiting " ## HTML DOM Event Attributes
+  ariaAttr* = " role "                           ## HTML DOM Aria Attributes
+  commonAttr* = coreAttr & eventAttr & ariaAttr  ## HTML DOM Common Attributes
+
+proc getIdent(e: NimNode): string =
+  case e.kind
+  of nnkIdent:
+    result = e.strVal.normalize
+  of nnkAccQuoted:
+    result = getIdent(e[0])
+    for i in 1 .. e.len-1:
+      result.add getIdent(e[i])
+  else: error("cannot extract identifier from node: " & toStrLit(e).strVal, e)
+
+proc delete[T](s: var seq[T], attr: T): bool =
+  var idx = find(s, attr)
+  if idx >= 0:
+    var L = s.len
+    s[idx] = s[L-1]
+    setLen(s, L-1)
+    result = true
+
+proc xmlCheckedTag*(argsList: NimNode, tag: string, optAttr = "", reqAttr = "",
+    isLeaf = false): NimNode =
+  ## use this procedure to define a new XML tag
+
+  # copy the attributes; when iterating over them these lists
+  # will be modified, so that each attribute is only given one value
+  var req = splitWhitespace(reqAttr)
+  var opt = splitWhitespace(optAttr)
+  result = newNimNode(nnkBracket)
+  result.add(newStrLitNode("<"))
+  result.add(newStrLitNode(tag))
+  # first pass over attributes:
+  for i in 0 ..< argsList.len:
+    if argsList[i].kind == nnkExprEqExpr:
+      var name = getIdent(argsList[i][0])
+      if name.startsWith("data-") or delete(req, name) or delete(opt, name):
+        result.add(newStrLitNode(" "))
+        result.add(newStrLitNode(name))
+        result.add(newStrLitNode("=\""))
+        result.add(argsList[i][1])
+        result.add(newStrLitNode("\""))
+      else:
+        error("invalid attribute for '" & tag & "' element: " & name, argsList[i])
+  # check each required attribute exists:
+  if req.len > 0:
+    error(req[0] & " attribute for '" & tag & "' element expected", argsList)
+  if isLeaf:
+    for i in 0 ..< argsList.len:
+      if argsList[i].kind != nnkExprEqExpr:
+        error("element " & tag & " cannot be nested", argsList[i])
+    result.add(newStrLitNode(" />"))
+  else:
+    result.add(newStrLitNode(">"))
+    # second pass over elements:
+    for i in 0 ..< argsList.len:
+      if argsList[i].kind != nnkExprEqExpr: result.add(argsList[i])
+    result.add(newStrLitNode("</"))
+    result.add(newStrLitNode(tag))
+    result.add(newStrLitNode(">"))
+  result = nestList(ident"&", result)
+
+macro a*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `a` element.
+  result = xmlCheckedTag(e, "a", "href target download rel hreflang type " &
+    commonAttr)
+
+macro abbr*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `abbr` element.
+  result = xmlCheckedTag(e, "abbr", commonAttr)
+
+macro address*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `address` element.
+  result = xmlCheckedTag(e, "address", commonAttr)
+
+macro area*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `area` element.
+  result = xmlCheckedTag(e, "area", "coords download href hreflang rel " &
+    "shape target type" & commonAttr, "alt", true)
+
+macro article*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `article` element.
+  result = xmlCheckedTag(e, "article", commonAttr)
+
+macro aside*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `aside` element.
+  result = xmlCheckedTag(e, "aside", commonAttr)
+
+macro audio*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `audio` element.
+  result = xmlCheckedTag(e, "audio", "src crossorigin preload " &
+    "autoplay mediagroup loop muted controls" & commonAttr)
+
+macro b*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `b` element.
+  result = xmlCheckedTag(e, "b", commonAttr)
+
+macro base*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `base` element.
+  result = xmlCheckedTag(e, "base", "href target" & commonAttr, "", true)
+
+macro bdi*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `bdi` element.
+  result = xmlCheckedTag(e, "bdi", commonAttr)
+
+macro bdo*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `bdo` element.
+  result = xmlCheckedTag(e, "bdo", commonAttr)
+
+macro big*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `big` element.
+  result = xmlCheckedTag(e, "big", commonAttr)
+
+macro blockquote*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `blockquote` element.
+  result = xmlCheckedTag(e, "blockquote", " cite" & commonAttr)
+
+macro body*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `body` element.
+  result = xmlCheckedTag(e, "body", "onafterprint onbeforeprint " &
+    "onbeforeunload onhashchange onmessage onoffline ononline onpagehide " &
+    "onpageshow onpopstate onstorage onunload" & commonAttr)
+
+macro br*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `br` element.
+  result = xmlCheckedTag(e, "br", commonAttr, "", true)
+
+macro button*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `button` element.
+  result = xmlCheckedTag(e, "button", "autofocus disabled form formaction " &
+    "formenctype formmethod formnovalidate formtarget menu name type value" &
+    commonAttr)
+
+macro canvas*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `canvas` element.
+  result = xmlCheckedTag(e, "canvas", "width height" & commonAttr)
+
+macro caption*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `caption` element.
+  result = xmlCheckedTag(e, "caption", commonAttr)
+
+macro center*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `center` element.
+  result = xmlCheckedTag(e, "center", commonAttr)
+
+macro cite*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `cite` element.
+  result = xmlCheckedTag(e, "cite", commonAttr)
+
+macro code*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `code` element.
+  result = xmlCheckedTag(e, "code", commonAttr)
+
+macro col*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `col` element.
+  result = xmlCheckedTag(e, "col", "span" & commonAttr, "", true)
+
+macro colgroup*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `colgroup` element.
+  result = xmlCheckedTag(e, "colgroup", "span" & commonAttr)
+
+macro data*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `data` element.
+  result = xmlCheckedTag(e, "data", "value" & commonAttr)
+
+macro datalist*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `datalist` element.
+  result = xmlCheckedTag(e, "datalist", commonAttr)
+
+macro dd*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `dd` element.
+  result = xmlCheckedTag(e, "dd", commonAttr)
+
+macro del*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `del` element.
+  result = xmlCheckedTag(e, "del", "cite datetime" & commonAttr)
+
+macro details*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `details` element.
+  result = xmlCheckedTag(e, "details", commonAttr & "open")
+
+macro dfn*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `dfn` element.
+  result = xmlCheckedTag(e, "dfn", commonAttr)
+
+macro dialog*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `dialog` element.
+  result = xmlCheckedTag(e, "dialog", commonAttr & "open")
+
+macro `div`*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `div` element.
+  result = xmlCheckedTag(e, "div", commonAttr)
+
+macro dl*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `dl` element.
+  result = xmlCheckedTag(e, "dl", commonAttr)
+
+macro dt*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `dt` element.
+  result = xmlCheckedTag(e, "dt", commonAttr)
+
+macro em*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `em` element.
+  result = xmlCheckedTag(e, "em", commonAttr)
+
+macro embed*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `embed` element.
+  result = xmlCheckedTag(e, "embed", "src type height width" &
+    commonAttr, "", true)
+
+macro fieldset*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `fieldset` element.
+  result = xmlCheckedTag(e, "fieldset", "disabled form name" & commonAttr)
+
+macro figure*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `figure` element.
+  result = xmlCheckedTag(e, "figure", commonAttr)
+
+macro figcaption*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `figcaption` element.
+  result = xmlCheckedTag(e, "figcaption", commonAttr)
+
+macro footer*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `footer` element.
+  result = xmlCheckedTag(e, "footer", commonAttr)
+
+macro form*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `form` element.
+  result = xmlCheckedTag(e, "form", "accept-charset action autocomplete " &
+    "enctype method name novalidate target" & commonAttr)
+
+macro h1*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h1` element.
+  result = xmlCheckedTag(e, "h1", commonAttr)
+
+macro h2*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h2` element.
+  result = xmlCheckedTag(e, "h2", commonAttr)
+
+macro h3*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h3` element.
+  result = xmlCheckedTag(e, "h3", commonAttr)
+
+macro h4*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h4` element.
+  result = xmlCheckedTag(e, "h4", commonAttr)
+
+macro h5*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h5` element.
+  result = xmlCheckedTag(e, "h5", commonAttr)
+
+macro h6*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `h6` element.
+  result = xmlCheckedTag(e, "h6", commonAttr)
+
+macro head*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `head` element.
+  result = xmlCheckedTag(e, "head", commonAttr)
+
+macro header*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `header` element.
+  result = xmlCheckedTag(e, "header", commonAttr)
+
+macro html*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `html` element.
+  result = xmlCheckedTag(e, "html", "xmlns" & commonAttr, "")
+
+macro hr*(): untyped =
+  ## Generates the HTML `hr` element.
+  result = xmlCheckedTag(newNimNode(nnkArgList), "hr", commonAttr, "", true)
+
+macro i*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `i` element.
+  result = xmlCheckedTag(e, "i", commonAttr)
+
+macro iframe*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `iframe` element.
+  result = xmlCheckedTag(e, "iframe", "src srcdoc name sandbox width height loading" &
+    commonAttr)
+
+macro img*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `img` element.
+  result = xmlCheckedTag(e, "img", "crossorigin usemap ismap height width loading" &
+    commonAttr, "src alt", true)
+
+macro input*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `input` element.
+  result = xmlCheckedTag(e, "input", "accept alt autocomplete autofocus " &
+    "checked dirname disabled form formaction formenctype formmethod " &
+    "formnovalidate formtarget height inputmode list max maxlength min " &
+    "minlength multiple name pattern placeholder readonly required size " &
+    "src step type value width" & commonAttr, "", true)
+
+macro ins*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `ins` element.
+  result = xmlCheckedTag(e, "ins", "cite datetime" & commonAttr)
+
+macro kbd*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `kbd` element.
+  result = xmlCheckedTag(e, "kbd", commonAttr)
+
+macro keygen*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `keygen` element.
+  result = xmlCheckedTag(e, "keygen", "autofocus challenge disabled " &
+    "form keytype name" & commonAttr)
+
+macro label*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `label` element.
+  result = xmlCheckedTag(e, "label", "form for" & commonAttr)
+
+macro legend*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `legend` element.
+  result = xmlCheckedTag(e, "legend", commonAttr)
+
+macro li*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `li` element.
+  result = xmlCheckedTag(e, "li", "value" & commonAttr)
+
+macro link*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `link` element.
+  result = xmlCheckedTag(e, "link", "href crossorigin rel media hreflang " &
+    "type sizes" & commonAttr, "", true)
+
+macro main*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `main` element.
+  result = xmlCheckedTag(e, "main", commonAttr)
+
+macro map*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `map` element.
+  result = xmlCheckedTag(e, "map", "name" & commonAttr)
+
+macro mark*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mark` element.
+  result = xmlCheckedTag(e, "mark", commonAttr)
+
+macro marquee*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `marquee` element.
+  result = xmlCheckedTag(e, "marquee", coreAttr &
+    "behavior bgcolor direction height hspace loop scrollamount " &
+    "scrolldelay truespeed vspace width onbounce onfinish onstart")
+
+macro meta*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `meta` element.
+  result = xmlCheckedTag(e, "meta", "name http-equiv content charset" &
+    commonAttr, "", true)
+
+macro meter*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `meter` element.
+  result = xmlCheckedTag(e, "meter", "value min max low high optimum" &
+    commonAttr)
+
+macro nav*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `nav` element.
+  result = xmlCheckedTag(e, "nav", commonAttr)
+
+macro noscript*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `noscript` element.
+  result = xmlCheckedTag(e, "noscript", commonAttr)
+
+macro `object`*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `object` element.
+  result = xmlCheckedTag(e, "object", "data type typemustmatch name usemap " &
+    "form width height" & commonAttr)
+
+macro ol*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `ol` element.
+  result = xmlCheckedTag(e, "ol", "reversed start type" & commonAttr)
+
+macro optgroup*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `optgroup` element.
+  result = xmlCheckedTag(e, "optgroup", "disabled" & commonAttr, "label", false)
+
+macro option*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `option` element.
+  result = xmlCheckedTag(e, "option", "disabled label selected value" &
+    commonAttr)
+
+macro output*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `output` element.
+  result = xmlCheckedTag(e, "output", "for form name" & commonAttr)
+
+macro p*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `p` element.
+  result = xmlCheckedTag(e, "p", commonAttr)
+
+macro param*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `param` element.
+  result = xmlCheckedTag(e, "param", commonAttr, "name value", true)
+
+macro picture*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `picture` element.
+  result = xmlCheckedTag(e, "picture", commonAttr)
+
+macro pre*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `pre` element.
+  result = xmlCheckedTag(e, "pre", commonAttr)
+
+macro progress*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `progress` element.
+  result = xmlCheckedTag(e, "progress", "value max" & commonAttr)
+
+macro q*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `q` element.
+  result = xmlCheckedTag(e, "q", "cite" & commonAttr)
+
+macro rb*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `rb` element.
+  result = xmlCheckedTag(e, "rb", commonAttr)
+
+macro rp*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `rp` element.
+  result = xmlCheckedTag(e, "rp", commonAttr)
+
+macro rt*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `rt` element.
+  result = xmlCheckedTag(e, "rt", commonAttr)
+
+macro rtc*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `rtc` element.
+  result = xmlCheckedTag(e, "rtc", commonAttr)
+
+macro ruby*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `ruby` element.
+  result = xmlCheckedTag(e, "ruby", commonAttr)
+
+macro s*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `s` element.
+  result = xmlCheckedTag(e, "s", commonAttr)
+
+macro samp*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `samp` element.
+  result = xmlCheckedTag(e, "samp", commonAttr)
+
+macro script*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `script` element.
+  result = xmlCheckedTag(e, "script", "src type charset async defer " &
+    "crossorigin" & commonAttr)
+
+macro section*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `section` element.
+  result = xmlCheckedTag(e, "section", commonAttr)
+
+macro select*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `select` element.
+  result = xmlCheckedTag(e, "select", "autofocus disabled form multiple " &
+    "name required size" & commonAttr)
+
+macro slot*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `slot` element.
+  result = xmlCheckedTag(e, "slot", commonAttr)
+
+macro small*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `small` element.
+  result = xmlCheckedTag(e, "small", commonAttr)
+
+macro source*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `source` element.
+  result = xmlCheckedTag(e, "source", "type" & commonAttr, "src", true)
+
+macro span*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `span` element.
+  result = xmlCheckedTag(e, "span", commonAttr)
+
+macro strong*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `strong` element.
+  result = xmlCheckedTag(e, "strong", commonAttr)
+
+macro style*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `style` element.
+  result = xmlCheckedTag(e, "style", "media type" & commonAttr)
+
+macro sub*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `sub` element.
+  result = xmlCheckedTag(e, "sub", commonAttr)
+
+macro summary*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `summary` element.
+  result = xmlCheckedTag(e, "summary", commonAttr)
+
+macro sup*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `sup` element.
+  result = xmlCheckedTag(e, "sup", commonAttr)
+
+macro table*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `table` element.
+  result = xmlCheckedTag(e, "table", "border sortable" & commonAttr)
+
+macro tbody*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `tbody` element.
+  result = xmlCheckedTag(e, "tbody", commonAttr)
+
+macro td*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `td` element.
+  result = xmlCheckedTag(e, "td", "colspan rowspan headers" & commonAttr)
+
+macro `template`*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `template` element.
+  result = xmlCheckedTag(e, "template", commonAttr)
+
+macro textarea*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `textarea` element.
+  result = xmlCheckedTag(e, "textarea", "autocomplete autofocus cols " &
+    "dirname disabled form inputmode maxlength minlength name placeholder " &
+    "readonly required rows wrap" & commonAttr)
+
+macro tfoot*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `tfoot` element.
+  result = xmlCheckedTag(e, "tfoot", commonAttr)
+
+macro th*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `th` element.
+  result = xmlCheckedTag(e, "th", "colspan rowspan headers abbr scope axis" &
+    " sorted" & commonAttr)
+
+macro thead*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `thead` element.
+  result = xmlCheckedTag(e, "thead", commonAttr)
+
+macro time*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `time` element.
+  result = xmlCheckedTag(e, "time", "datetime" & commonAttr)
+
+macro title*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `title` element.
+  result = xmlCheckedTag(e, "title", commonAttr)
+
+macro tr*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `tr` element.
+  result = xmlCheckedTag(e, "tr", commonAttr)
+
+macro track*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `track` element.
+  result = xmlCheckedTag(e, "track", "kind srclang label default" &
+    commonAttr, "src", true)
+
+macro tt*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `tt` element.
+  result = xmlCheckedTag(e, "tt", commonAttr)
+
+macro u*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `u` element.
+  result = xmlCheckedTag(e, "u", commonAttr)
+
+macro ul*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `ul` element.
+  result = xmlCheckedTag(e, "ul", commonAttr)
+
+macro `var`*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `var` element.
+  result = xmlCheckedTag(e, "var", commonAttr)
+
+macro video*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `video` element.
+  result = xmlCheckedTag(e, "video", "src crossorigin poster preload " &
+    "autoplay mediagroup loop muted controls width height" & commonAttr)
+
+macro wbr*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `wbr` element.
+  result = xmlCheckedTag(e, "wbr", commonAttr, "", true)
+
+macro portal*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `portal` element.
+  result = xmlCheckedTag(e, "portal", "width height type src disabled" & commonAttr, "", false)
+
+
+macro math*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `math` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#Examples
+  result = xmlCheckedTag(e, "math", "mathbackground mathcolor href overflow" & commonAttr)
+
+macro maction*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `maction` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/maction
+  result = xmlCheckedTag(e, "maction", "mathbackground mathcolor href" & commonAttr)
+
+macro menclose*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `menclose` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/menclose
+  result = xmlCheckedTag(e, "menclose", "mathbackground mathcolor href notation" & commonAttr)
+
+macro merror*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `merror` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/merror
+  result = xmlCheckedTag(e, "merror", "mathbackground mathcolor href" & commonAttr)
+
+macro mfenced*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mfenced` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfenced
+  result = xmlCheckedTag(e, "mfenced", "mathbackground mathcolor href open separators" & commonAttr)
+
+macro mfrac*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mfrac` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac
+  result = xmlCheckedTag(e, "mfrac", "mathbackground mathcolor href linethickness numalign" & commonAttr)
+
+macro mglyph*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mglyph` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mglyph
+  result = xmlCheckedTag(e, "mglyph", "mathbackground mathcolor href src valign" & commonAttr)
+
+macro mi*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mi` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi
+  result = xmlCheckedTag(e, "mi", "mathbackground mathcolor href mathsize mathvariant" & commonAttr)
+
+macro mlabeledtr*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mlabeledtr` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mlabeledtr
+  result = xmlCheckedTag(e, "mlabeledtr", "mathbackground mathcolor href columnalign groupalign rowalign" & commonAttr)
+
+macro mmultiscripts*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mmultiscripts` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mmultiscripts
+  result = xmlCheckedTag(e, "mmultiscripts", "mathbackground mathcolor href subscriptshift superscriptshift" & commonAttr)
+
+macro mn*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mn` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn
+  result = xmlCheckedTag(e, "mn", "mathbackground mathcolor href mathsize mathvariant" & commonAttr)
+
+macro mo*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mo` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
+  result = xmlCheckedTag(e, "mo",
+    "mathbackground mathcolor fence form largeop lspace mathsize mathvariant movablelimits rspace separator stretchy symmetric" & commonAttr)
+
+macro mover*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mover` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mover
+  result = xmlCheckedTag(e, "mover", "mathbackground mathcolor accent href" & commonAttr)
+
+macro mpadded*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mpadded` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mpadded
+  result = xmlCheckedTag(e, "mpadded", "mathbackground mathcolor depth href lspace voffset" & commonAttr)
+
+macro mphantom*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mphantom` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mphantom
+  result = xmlCheckedTag(e, "mphantom", "mathbackground" & commonAttr)
+
+macro mroot*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mroot` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot
+  result = xmlCheckedTag(e, "mroot", "mathbackground mathcolor href" & commonAttr)
+
+macro mrow*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mrow` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mrow
+  result = xmlCheckedTag(e, "mrow", "mathbackground mathcolor href" & commonAttr)
+
+macro ms*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `ms` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/ms
+  result = xmlCheckedTag(e, "ms", "mathbackground mathcolor href lquote mathsize mathvariant rquote" & commonAttr)
+
+macro mspace*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mspace` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mspace
+  result = xmlCheckedTag(e, "mspace", "mathbackground mathcolor href linebreak" & commonAttr)
+
+macro msqrt*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `msqrt` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt
+  result = xmlCheckedTag(e, "msqrt", "mathbackground mathcolor href" & commonAttr)
+
+macro mstyle*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mstyle` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mstyle
+  result = xmlCheckedTag(e, "mstyle", ("mathbackground mathcolor href decimalpoint displaystyle " &
+    "infixlinebreakstyle scriptlevel scriptminsize scriptsizemultiplier" & commonAttr))
+
+macro msub*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `msub` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub
+  result = xmlCheckedTag(e, "msub", "mathbackground mathcolor href subscriptshift" & commonAttr)
+
+macro msubsup*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `msubsup` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msubsup
+  result = xmlCheckedTag(e, "msubsup", "mathbackground mathcolor href subscriptshift superscriptshift" & commonAttr)
+
+macro msup*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `msup` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup
+  result = xmlCheckedTag(e, "msup", "mathbackground mathcolor href superscriptshift" & commonAttr)
+
+macro mtable*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mtable` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable
+  result = xmlCheckedTag(e, "mtable", ("mathbackground mathcolor href align " &
+    "alignmentscope columnalign columnlines columnspacing columnwidth " &
+    "displaystyle equalcolumns equalrows frame framespacing groupalign " &
+    "rowalign rowlines rowspacing side width" & commonAttr))
+
+macro mtd*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mtd` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtd
+  result = xmlCheckedTag(e, "mtd",
+    "mathbackground mathcolor href columnalign columnspan groupalign rowalign rowspan" & commonAttr)
+
+macro mtext*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `mtext` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtext
+  result = xmlCheckedTag(e, "mtext", "mathbackground mathcolor href mathsize mathvariant" & commonAttr)
+
+macro munder*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `munder` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/munder
+  result = xmlCheckedTag(e, "munder", "mathbackground mathcolor href accentunder align" & commonAttr)
+
+macro munderover*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `munderover` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/munderover
+  result = xmlCheckedTag(e, "munderover", "mathbackground mathcolor href accentunder accent align" & commonAttr)
+
+macro semantics*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `semantics` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics
+  result = xmlCheckedTag(e, "semantics", "mathbackground mathcolor href definitionURL encoding cd src" & commonAttr)
+
+macro annotation*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `annotation` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics
+  result = xmlCheckedTag(e, "annotation", "mathbackground mathcolor href definitionURL encoding cd src" & commonAttr)
+
+macro `annotation-xml`*(e: varargs[untyped]): untyped =
+  ## Generates the HTML `annotation-xml` element. MathML https://wikipedia.org/wiki/MathML
+  ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/semantics
+  result = xmlCheckedTag(e, "annotation", "mathbackground mathcolor href definitionURL encoding cd src" & commonAttr)
+
+
+runnableExamples:
+  let nim = "Nim"
+  assert h1(a(href = "https://nim-lang.org", nim)) ==
+    """<h1><a href="https://nim-lang.org">Nim</a></h1>"""
+  assert form(action = "test", `accept-charset` = "Content-Type") ==
+    """<form action="test" accept-charset="Content-Type"></form>"""
+
+
+  assert math(
+    semantics(
+      mrow(
+        msup(
+          mi("x"),
+          mn("42")
+        )
+      )
+    )
+  ) == "<math><semantics><mrow><msup><mi>x</mi><mn>42</mn></msup></mrow></semantics></math>"
+
+  assert math(
+    semantics(
+      annotation(encoding = "application/x-tex", title = "Latex on Web", r"x^{2} + y")
+    )
+  ) == """<math><semantics><annotation encoding="application/x-tex" title="Latex on Web">x^{2} + y</annotation></semantics></math>"""
diff --git a/lib/pure/htmlparser.nim b/lib/pure/htmlparser.nim
index 892534ce1..62919546f 100755..100644
--- a/lib/pure/htmlparser.nim
+++ b/lib/pure/htmlparser.nim
@@ -1,421 +1,2078 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module parses an HTML document and creates its XML tree representation.
-## It is supposed to handle the *wild* HTML the real world uses.
-## 
+## **NOTE**: The behaviour might change in future versions as it is not
+## clear what "*wild* HTML the real world uses" really implies.
+##
 ## It can be used to parse a wild HTML document and output it as valid XHTML
 ## document (well, if you are lucky):
-##
-## .. code-block:: nimrod
-##
+##   ```Nim
 ##   echo loadHtml("mydirty.html")
-##
+##   ```
 ##
 ## Every tag in the resulting tree is in lower case.
 ##
-## **Note:** The resulting ``PXmlNode`` already use the ``clientData`` field, 
+## **Note:** The resulting `XmlNode` already uses the `clientData` field,
 ## so it cannot be used by clients of this library.
+##
+## Example: Transforming hyperlinks
+## ================================
+##
+## This code demonstrates how you can iterate over all the tags in an HTML file
+## and write back the modified version. In this case we look for hyperlinks
+## ending with the extension `.rst` and convert them to `.html`.
+##
+##   ```Nim test
+##   import std/htmlparser
+##   import std/xmltree  # To use '$' for XmlNode
+##   import std/strtabs  # To access XmlAttributes
+##   import std/os       # To use splitFile
+##   import std/strutils # To use cmpIgnoreCase
+##
+##   proc transformHyperlinks() =
+##     let html = loadHtml("input.html")
+##
+##     for a in html.findAll("a"):
+##       if a.attrs.hasKey "href":
+##         let (dir, filename, ext) = splitFile(a.attrs["href"])
+##         if cmpIgnoreCase(ext, ".rst") == 0:
+##           a.attrs["href"] = dir / filename & ".html"
+##
+##     writeFile("output.html", $html)
+##   ```
+
+{.deprecated: "use `nimble install htmlparser` and import `pkg/htmlparser` instead".}
 
-import strutils, streams, parsexml, xmltree, unicode, strtabs
+import std/[strutils, streams, parsexml, xmltree, unicode, strtabs]
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
 
 type
-  THtmlTag* = enum ## list of all supported HTML tags; order will always be
+  HtmlTag* = enum  ## list of all supported HTML tags; order will always be
                    ## alphabetically
     tagUnknown,    ## unknown HTML element
-    tagA,          ## the HTML ``a`` element
-    tagAbbr,       ## the deprecated HTML ``abbr`` element
-    tagAcronym,    ## the HTML ``acronym`` element
-    tagAddress,    ## the HTML ``address`` element
-    tagApplet,     ## the deprecated HTML ``applet`` element
-    tagArea,       ## the HTML ``area`` element
-    tagB,          ## the HTML ``b`` element
-    tagBase,       ## the HTML ``base`` element
-    tagBdo,        ## the deprecated HTML ``dbo`` element
-    tagBasefont,   ## the deprecated HTML ``basefont`` element
-    tagBig,        ## the HTML ``big`` element
-    tagBlockquote, ## the HTML ``blockquote`` element
-    tagBody,       ## the HTML ``body`` element
-    tagBr,         ## the HTML ``br`` element
-    tagButton,     ## the HTML ``button`` element
-    tagCaption,    ## the HTML ``caption`` element
-    tagCenter,     ## the deprecated HTML ``center`` element
-    tagCite,       ## the HTML ``cite`` element
-    tagCode,       ## the HTML ``code`` element
-    tagCol,        ## the HTML ``col`` element
-    tagColgroup,   ## the HTML ``colgroup`` element
-    tagDd,         ## the HTML ``dd`` element
-    tagDel,        ## the HTML ``del`` element
-    tagDfn,        ## the HTML ``dfn`` element
-    tagDiv,        ## the HTML ``div`` element
-    tagDir,        ## the deprecated HTLM ``dir`` element
-    tagDl,         ## the HTML ``dl`` element
-    tagDt,         ## the HTML ``dt`` element
-    tagEm,         ## the HTML ``em`` element
-    tagFieldset,   ## the HTML ``fieldset`` element
-    tagFont,       ## the deprecated HTML ``font`` element
-    tagForm,       ## the HTML ``form`` element
-    tagFrame,      ## the HTML ``frame`` element
-    tagFrameset,   ## the deprecated HTML ``frameset`` element
-    tagH1,         ## the HTML ``h1`` element
-    tagH2,         ## the HTML ``h2`` element
-    tagH3,         ## the HTML ``h3`` element
-    tagH4,         ## the HTML ``h4`` element
-    tagH5,         ## the HTML ``h5`` element
-    tagH6,         ## the HTML ``h6`` element
-    tagHead,       ## the HTML ``head`` element
-    tagHtml,       ## the HTML ``html`` element
-    tagHr,         ## the HTML ``hr`` element
-    tagI,          ## the HTML ``i`` element
-    tagIframe,     ## the deprecated HTML ``iframe`` element
-    tagImg,        ## the HTML ``img`` element
-    tagInput,      ## the HTML ``input`` element
-    tagIns,        ## the HTML ``ins`` element
-    tagIsindex,    ## the deprecated HTML ``isindex`` element
-    tagKbd,        ## the HTML ``kbd`` element
-    tagLabel,      ## the HTML ``label`` element
-    tagLegend,     ## the HTML ``legend`` element
-    tagLi,         ## the HTML ``li`` element
-    tagLink,       ## the HTML ``link`` element
-    tagMap,        ## the HTML ``map`` element
-    tagMenu,       ## the deprecated HTML ``menu`` element
-    tagMeta,       ## the HTML ``meta`` element
-    tagNobr,       ## the deprecated HTML ``nobr`` element
-    tagNoframes,   ## the deprecated HTML ``noframes`` element
-    tagNoscript,   ## the HTML ``noscript`` element
-    tagObject,     ## the HTML ``object`` element
-    tagOl,         ## the HTML ``ol`` element
-    tagOptgroup,   ## the HTML ``optgroup`` element
-    tagOption,     ## the HTML ``option`` element
-    tagP,          ## the HTML ``p`` element
-    tagParam,      ## the HTML ``param`` element
-    tagPre,        ## the HTML ``pre`` element
-    tagQ,          ## the HTML ``q`` element
-    tagS,          ## the deprecated HTML ``s`` element
-    tagSamp,       ## the HTML ``samp`` element
-    tagScript,     ## the HTML ``script`` element
-    tagSelect,     ## the HTML ``select`` element
-    tagSmall,      ## the HTML ``small`` element
-    tagSpan,       ## the HTML ``span`` element
-    tagStrike,     ## the deprecated HTML ``strike`` element
-    tagStrong,     ## the HTML ``strong`` element
-    tagStyle,      ## the HTML ``style`` element
-    tagSub,        ## the HTML ``sub`` element
-    tagSup,        ## the HTML ``sup`` element
-    tagTable,      ## the HTML ``table`` element
-    tagTbody,      ## the HTML ``tbody`` element
-    tagTd,         ## the HTML ``td`` element
-    tagTextarea,   ## the HTML ``textarea`` element
-    tagTfoot,      ## the HTML ``tfoot`` element
-    tagTh,         ## the HTML ``th`` element
-    tagThead,      ## the HTML ``thead`` element
-    tagTitle,      ## the HTML ``title`` element
-    tagTr,         ## the HTML ``tr`` element
-    tagTt,         ## the HTML ``tt`` element
-    tagU,          ## the deprecated HTML ``u`` element
-    tagUl,         ## the HTML ``ul`` element
-    tagVar         ## the HTML ``var`` element
+    tagA,          ## the HTML `a` element
+    tagAbbr,       ## the deprecated HTML `abbr` element
+    tagAcronym,    ## the HTML `acronym` element
+    tagAddress,    ## the HTML `address` element
+    tagApplet,     ## the deprecated HTML `applet` element
+    tagArea,       ## the HTML `area` element
+    tagArticle,    ## the HTML `article` element
+    tagAside,      ## the HTML `aside` element
+    tagAudio,      ## the HTML `audio` element
+    tagB,          ## the HTML `b` element
+    tagBase,       ## the HTML `base` element
+    tagBdi,        ## the HTML `bdi` element
+    tagBdo,        ## the deprecated HTML `dbo` element
+    tagBasefont,   ## the deprecated HTML `basefont` element
+    tagBig,        ## the HTML `big` element
+    tagBlockquote, ## the HTML `blockquote` element
+    tagBody,       ## the HTML `body` element
+    tagBr,         ## the HTML `br` element
+    tagButton,     ## the HTML `button` element
+    tagCanvas,     ## the HTML `canvas` element
+    tagCaption,    ## the HTML `caption` element
+    tagCenter,     ## the deprecated HTML `center` element
+    tagCite,       ## the HTML `cite` element
+    tagCode,       ## the HTML `code` element
+    tagCol,        ## the HTML `col` element
+    tagColgroup,   ## the HTML `colgroup` element
+    tagCommand,    ## the HTML `command` element
+    tagDatalist,   ## the HTML `datalist` element
+    tagDd,         ## the HTML `dd` element
+    tagDel,        ## the HTML `del` element
+    tagDetails,    ## the HTML `details` element
+    tagDfn,        ## the HTML `dfn` element
+    tagDialog,     ## the HTML `dialog` element
+    tagDiv,        ## the HTML `div` element
+    tagDir,        ## the deprecated HTLM `dir` element
+    tagDl,         ## the HTML `dl` element
+    tagDt,         ## the HTML `dt` element
+    tagEm,         ## the HTML `em` element
+    tagEmbed,      ## the HTML `embed` element
+    tagFieldset,   ## the HTML `fieldset` element
+    tagFigcaption, ## the HTML `figcaption` element
+    tagFigure,     ## the HTML `figure` element
+    tagFont,       ## the deprecated HTML `font` element
+    tagFooter,     ## the HTML `footer` element
+    tagForm,       ## the HTML `form` element
+    tagFrame,      ## the HTML `frame` element
+    tagFrameset,   ## the deprecated HTML `frameset` element
+    tagH1,         ## the HTML `h1` element
+    tagH2,         ## the HTML `h2` element
+    tagH3,         ## the HTML `h3` element
+    tagH4,         ## the HTML `h4` element
+    tagH5,         ## the HTML `h5` element
+    tagH6,         ## the HTML `h6` element
+    tagHead,       ## the HTML `head` element
+    tagHeader,     ## the HTML `header` element
+    tagHgroup,     ## the HTML `hgroup` element
+    tagHtml,       ## the HTML `html` element
+    tagHr,         ## the HTML `hr` element
+    tagI,          ## the HTML `i` element
+    tagIframe,     ## the deprecated HTML `iframe` element
+    tagImg,        ## the HTML `img` element
+    tagInput,      ## the HTML `input` element
+    tagIns,        ## the HTML `ins` element
+    tagIsindex,    ## the deprecated HTML `isindex` element
+    tagKbd,        ## the HTML `kbd` element
+    tagKeygen,     ## the HTML `keygen` element
+    tagLabel,      ## the HTML `label` element
+    tagLegend,     ## the HTML `legend` element
+    tagLi,         ## the HTML `li` element
+    tagLink,       ## the HTML `link` element
+    tagMap,        ## the HTML `map` element
+    tagMark,       ## the HTML `mark` element
+    tagMenu,       ## the deprecated HTML `menu` element
+    tagMeta,       ## the HTML `meta` element
+    tagMeter,      ## the HTML `meter` element
+    tagNav,        ## the HTML `nav` element
+    tagNobr,       ## the deprecated HTML `nobr` element
+    tagNoframes,   ## the deprecated HTML `noframes` element
+    tagNoscript,   ## the HTML `noscript` element
+    tagObject,     ## the HTML `object` element
+    tagOl,         ## the HTML `ol` element
+    tagOptgroup,   ## the HTML `optgroup` element
+    tagOption,     ## the HTML `option` element
+    tagOutput,     ## the HTML `output` element
+    tagP,          ## the HTML `p` element
+    tagParam,      ## the HTML `param` element
+    tagPre,        ## the HTML `pre` element
+    tagProgress,   ## the HTML `progress` element
+    tagQ,          ## the HTML `q` element
+    tagRp,         ## the HTML `rp` element
+    tagRt,         ## the HTML `rt` element
+    tagRuby,       ## the HTML `ruby` element
+    tagS,          ## the deprecated HTML `s` element
+    tagSamp,       ## the HTML `samp` element
+    tagScript,     ## the HTML `script` element
+    tagSection,    ## the HTML `section` element
+    tagSelect,     ## the HTML `select` element
+    tagSmall,      ## the HTML `small` element
+    tagSource,     ## the HTML `source` element
+    tagSpan,       ## the HTML `span` element
+    tagStrike,     ## the deprecated HTML `strike` element
+    tagStrong,     ## the HTML `strong` element
+    tagStyle,      ## the HTML `style` element
+    tagSub,        ## the HTML `sub` element
+    tagSummary,    ## the HTML `summary` element
+    tagSup,        ## the HTML `sup` element
+    tagTable,      ## the HTML `table` element
+    tagTbody,      ## the HTML `tbody` element
+    tagTd,         ## the HTML `td` element
+    tagTextarea,   ## the HTML `textarea` element
+    tagTfoot,      ## the HTML `tfoot` element
+    tagTh,         ## the HTML `th` element
+    tagThead,      ## the HTML `thead` element
+    tagTime,       ## the HTML `time` element
+    tagTitle,      ## the HTML `title` element
+    tagTr,         ## the HTML `tr` element
+    tagTrack,      ## the HTML `track` element
+    tagTt,         ## the HTML `tt` element
+    tagU,          ## the deprecated HTML `u` element
+    tagUl,         ## the HTML `ul` element
+    tagVar,        ## the HTML `var` element
+    tagVideo,      ## the HTML `video` element
+    tagWbr         ## the HTML `wbr` element
 
 const
-  tagStrs = [
-    "a", "abbr", "acronym", "address", "applet", "area", 
-    "b", "base", "basefont", "bdo", "big", "blockquote", "body", 
-    "br", "button", "caption", "center", "cite", "code", 
-    "col", "colgroup", "dd", "del", "dfn", "div", 
-    "dir", "dl", "dt", "em", "fieldset", "font", 
-    "form", "frame", "frameset", "h1", "h2", "h3", 
-    "h4", "h5", "h6", "head", "html", "hr", 
-    "i", "iframe", "img", "input", "ins", "isindex", 
-    "kbd", "label", "legend", "li", "link", "map", 
-    "menu", "meta", "nobr", "noframes", "noscript", "object", "ol", 
-    "optgroup", "option", "p", "param", "pre", "q", 
-    "s", "samp", "script", "select", "small", "span", 
-    "strike", "strong", "style", "sub", "sup", "table", 
-    "tbody", "td", "textarea", "tfoot", "th", "thead", 
-    "title", "tr", "tt", "u", "ul", "var"]
+  tagToStr* = [
+    "a", "abbr", "acronym", "address", "applet", "area", "article",
+    "aside", "audio",
+    "b", "base", "basefont", "bdi", "bdo", "big", "blockquote", "body",
+    "br", "button", "canvas", "caption", "center", "cite", "code",
+    "col", "colgroup", "command",
+    "datalist", "dd", "del", "details", "dfn", "dialog", "div",
+    "dir", "dl", "dt", "em", "embed", "fieldset",
+    "figcaption", "figure", "font", "footer",
+    "form", "frame", "frameset", "h1", "h2", "h3",
+    "h4", "h5", "h6", "head", "header", "hgroup", "html", "hr",
+    "i", "iframe", "img", "input", "ins", "isindex",
+    "kbd", "keygen", "label", "legend", "li", "link", "map", "mark",
+    "menu", "meta", "meter", "nav", "nobr", "noframes", "noscript",
+    "object", "ol",
+    "optgroup", "option", "output", "p", "param", "pre", "progress", "q",
+    "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small",
+    "source", "span", "strike", "strong", "style",
+    "sub", "summary", "sup", "table",
+    "tbody", "td", "textarea", "tfoot", "th", "thead", "time",
+    "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]
   InlineTags* = {tagA, tagAbbr, tagAcronym, tagApplet, tagB, tagBasefont,
     tagBdo, tagBig, tagBr, tagButton, tagCite, tagCode, tagDel, tagDfn,
     tagEm, tagFont, tagI, tagImg, tagIns, tagInput, tagIframe, tagKbd,
     tagLabel, tagMap, tagObject, tagQ, tagSamp, tagScript, tagSelect,
     tagSmall, tagSpan, tagStrong, tagSub, tagSup, tagTextarea, tagTt,
-    tagVar, tagApplet, tagBasefont, tagFont, tagIframe, tagU, tagS, 
-    tagStrike}
-  BlockTags* = {tagAddress, tagBlockquote, tagCenter, tagDel, tagDir, tagDiv, 
-    tagDl, tagFieldset, tagForm, tagH1, tagH2, tagH3, tagH4, 
-    tagH5, tagH6, tagHr, tagIns, tagIsindex, tagMenu, tagNoframes, tagNoscript, 
-    tagOl, tagP, tagPre, tagTable, tagUl, tagCenter, tagDir, tagIsindex, 
+    tagVar, tagApplet, tagBasefont, tagFont, tagIframe, tagU, tagS,
+    tagStrike, tagWbr}
+  BlockTags* = {tagAddress, tagBlockquote, tagCenter, tagDel, tagDir, tagDiv,
+    tagDl, tagFieldset, tagForm, tagH1, tagH2, tagH3, tagH4,
+    tagH5, tagH6, tagHr, tagIns, tagIsindex, tagMenu, tagNoframes, tagNoscript,
+    tagOl, tagP, tagPre, tagTable, tagUl, tagCenter, tagDir, tagIsindex,
     tagMenu, tagNoframes}
-  SingleTags* = {tagArea, tagBase, tagBasefont, 
+  SingleTags* = {tagArea, tagBase, tagBasefont,
     tagBr, tagCol, tagFrame, tagHr, tagImg, tagIsindex,
-    tagLink, tagMeta, tagParam}
-  
-  Entities = [
-    ("nbsp", 0x00A0), ("iexcl", 0x00A1), ("cent", 0x00A2), ("pound", 0x00A3),
-    ("curren", 0x00A4), ("yen", 0x00A5), ("brvbar", 0x00A6), ("sect", 0x00A7),
-    ("uml", 0x00A8), ("copy", 0x00A9), ("ordf", 0x00AA), ("laquo", 0x00AB),
-    ("not", 0x00AC), ("shy", 0x00AD), ("reg", 0x00AE), ("macr", 0x00AF),
-    ("deg", 0x00B0), ("plusmn", 0x00B1), ("sup2", 0x00B2), ("sup3", 0x00B3),
-    ("acute", 0x00B4), ("micro", 0x00B5), ("para", 0x00B6), ("middot", 0x00B7),
-    ("cedil", 0x00B8), ("sup1", 0x00B9), ("ordm", 0x00BA), ("raquo", 0x00BB),
-    ("frac14", 0x00BC), ("frac12", 0x00BD), ("frac34", 0x00BE), 
-    ("iquest", 0x00BF), ("Agrave", 0x00C0), ("Aacute", 0x00C1),
-    ("Acirc", 0x00C2), ("Atilde", 0x00C3), ("Auml", 0x00C4), ("Aring", 0x00C5),
-    ("AElig", 0x00C6), ("Ccedil", 0x00C7), ("Egrave", 0x00C8),
-    ("Eacute", 0x00C9), ("Ecirc", 0x00CA), ("Euml", 0x00CB), ("Igrave", 0x00CC),
-    ("Iacute", 0x00CD), ("Icirc", 0x00CE), ("Iuml", 0x00CF), ("ETH", 0x00D0),
-    ("Ntilde", 0x00D1), ("Ograve", 0x00D2), ("Oacute", 0x00D3), 
-    ("Ocirc", 0x00D4), ("Otilde", 0x00D5), ("Ouml", 0x00D6), ("times", 0x00D7),
-    ("Oslash", 0x00D8), ("Ugrave", 0x00D9), ("Uacute", 0x00DA),
-    ("Ucirc", 0x00DB), ("Uuml", 0x00DC), ("Yacute", 0x00DD), ("THORN", 0x00DE),
-    ("szlig", 0x00DF), ("agrave", 0x00E0), ("aacute", 0x00E1),
-    ("acirc", 0x00E2), ("atilde", 0x00E3), ("auml", 0x00E4), ("aring", 0x00E5),
-    ("aelig", 0x00E6), ("ccedil", 0x00E7), ("egrave", 0x00E8),
-    ("eacute", 0x00E9), ("ecirc", 0x00EA), ("euml", 0x00EB), ("igrave", 0x00EC),
-    ("iacute", 0x00ED), ("icirc", 0x00EE), ("iuml", 0x00EF), ("eth", 0x00F0),
-    ("ntilde", 0x00F1), ("ograve", 0x00F2), ("oacute", 0x00F3),
-    ("ocirc", 0x00F4), ("otilde", 0x00F5), ("ouml", 0x00F6), ("divide", 0x00F7),
-    ("oslash", 0x00F8), ("ugrave", 0x00F9), ("uacute", 0x00FA),
-    ("ucirc", 0x00FB), ("uuml", 0x00FC), ("yacute", 0x00FD), ("thorn", 0x00FE),
-    ("yuml", 0x00FF), ("OElig", 0x0152), ("oelig", 0x0153), ("Scaron", 0x0160),
-    ("scaron", 0x0161), ("Yuml", 0x0178), ("fnof", 0x0192), ("circ", 0x02C6),
-    ("tilde", 0x02DC), ("Alpha", 0x0391), ("Beta", 0x0392), ("Gamma", 0x0393),
-    ("Delta", 0x0394), ("Epsilon", 0x0395), ("Zeta", 0x0396), ("Eta", 0x0397),
-    ("Theta", 0x0398), ("Iota", 0x0399), ("Kappa", 0x039A), ("Lambda", 0x039B),
-    ("Mu", 0x039C), ("Nu", 0x039D), ("Xi", 0x039E), ("Omicron", 0x039F),
-    ("Pi", 0x03A0), ("Rho", 0x03A1), ("Sigma", 0x03A3), ("Tau", 0x03A4),
-    ("Upsilon", 0x03A5), ("Phi", 0x03A6), ("Chi", 0x03A7), ("Psi", 0x03A8),
-    ("Omega", 0x03A9), ("alpha", 0x03B1), ("beta", 0x03B2), ("gamma", 0x03B3),
-    ("delta", 0x03B4), ("epsilon", 0x03B5), ("zeta", 0x03B6), ("eta", 0x03B7),
-    ("theta", 0x03B8), ("iota", 0x03B9), ("kappa", 0x03BA), ("lambda", 0x03BB),
-    ("mu", 0x03BC), ("nu", 0x03BD), ("xi", 0x03BE), ("omicron", 0x03BF),
-    ("pi", 0x03C0), ("rho", 0x03C1), ("sigmaf", 0x03C2), ("sigma", 0x03C3),
-    ("tau", 0x03C4), ("upsilon", 0x03C5), ("phi", 0x03C6), ("chi", 0x03C7),
-    ("psi", 0x03C8), ("omega", 0x03C9), ("thetasym", 0x03D1), ("upsih", 0x03D2),
-    ("piv", 0x03D6), ("ensp", 0x2002), ("emsp", 0x2003), ("thinsp", 0x2009),
-    ("zwnj", 0x200C), ("zwj", 0x200D), ("lrm", 0x200E), ("rlm", 0x200F),
-    ("ndash", 0x2013), ("mdash", 0x2014), ("lsquo", 0x2018), ("rsquo", 0x2019),
-    ("sbquo", 0x201A), ("ldquo", 0x201C), ("rdquo", 0x201D), ("bdquo", 0x201E),
-    ("dagger", 0x2020), ("Dagger", 0x2021), ("bull", 0x2022), 
-    ("hellip", 0x2026), ("permil", 0x2030), ("prime", 0x2032),
-    ("Prime", 0x2033), ("lsaquo", 0x2039), ("rsaquo", 0x203A),
-    ("oline", 0x203E), ("frasl", 0x2044), ("euro", 0x20AC),
-    ("image", 0x2111), ("weierp", 0x2118), ("real", 0x211C),
-    ("trade", 0x2122), ("alefsym", 0x2135), ("larr", 0x2190),
-    ("uarr", 0x2191), ("rarr", 0x2192), ("darr", 0x2193),
-    ("harr", 0x2194), ("crarr", 0x21B5), ("lArr", 0x21D0),
-    ("uArr", 0x21D1), ("rArr", 0x21D2), ("dArr", 0x21D3),
-    ("hArr", 0x21D4), ("forall", 0x2200), ("part", 0x2202),
-    ("exist", 0x2203), ("empty", 0x2205), ("nabla", 0x2207),
-    ("isin", 0x2208), ("notin", 0x2209), ("ni", 0x220B),
-    ("prod", 0x220F), ("sum", 0x2211), ("minus", 0x2212),
-    ("lowast", 0x2217), ("radic", 0x221A), ("prop", 0x221D),
-    ("infin", 0x221E), ("ang", 0x2220), ("and", 0x2227),
-    ("or", 0x2228), ("cap", 0x2229), ("cup", 0x222A),
-    ("int", 0x222B), ("there4", 0x2234), ("sim", 0x223C),
-    ("cong", 0x2245), ("asymp", 0x2248), ("ne", 0x2260),
-    ("equiv", 0x2261), ("le", 0x2264), ("ge", 0x2265),
-    ("sub", 0x2282), ("sup", 0x2283), ("nsub", 0x2284),
-    ("sube", 0x2286), ("supe", 0x2287), ("oplus", 0x2295),
-    ("otimes", 0x2297), ("perp", 0x22A5), ("sdot", 0x22C5),
-    ("lceil", 0x2308), ("rceil", 0x2309), ("lfloor", 0x230A),
-    ("rfloor", 0x230B), ("lang", 0x2329), ("rang", 0x232A),
-    ("loz", 0x25CA), ("spades", 0x2660), ("clubs", 0x2663),
-    ("hearts", 0x2665), ("diams", 0x2666)]
+    tagLink, tagMeta, tagParam, tagWbr, tagSource}
+
+proc allLower(s: string): bool =
+  for c in s:
+    if c < 'a' or c > 'z': return false
+  return true
+
+proc toHtmlTag(s: string): HtmlTag =
+  case s
+  of "a": tagA
+  of "abbr": tagAbbr
+  of "acronym": tagAcronym
+  of "address": tagAddress
+  of "applet": tagApplet
+  of "area": tagArea
+  of "article": tagArticle
+  of "aside": tagAside
+  of "audio": tagAudio
+  of "b": tagB
+  of "base": tagBase
+  of "basefont": tagBasefont
+  of "bdi": tagBdi
+  of "bdo": tagBdo
+  of "big": tagBig
+  of "blockquote": tagBlockquote
+  of "body": tagBody
+  of "br": tagBr
+  of "button": tagButton
+  of "canvas": tagCanvas
+  of "caption": tagCaption
+  of "center": tagCenter
+  of "cite": tagCite
+  of "code": tagCode
+  of "col": tagCol
+  of "colgroup": tagColgroup
+  of "command": tagCommand
+  of "datalist": tagDatalist
+  of "dd": tagDd
+  of "del": tagDel
+  of "details": tagDetails
+  of "dfn": tagDfn
+  of "dialog": tagDialog
+  of "div": tagDiv
+  of "dir": tagDir
+  of "dl": tagDl
+  of "dt": tagDt
+  of "em": tagEm
+  of "embed": tagEmbed
+  of "fieldset": tagFieldset
+  of "figcaption": tagFigcaption
+  of "figure": tagFigure
+  of "font": tagFont
+  of "footer": tagFooter
+  of "form": tagForm
+  of "frame": tagFrame
+  of "frameset": tagFrameset
+  of "h1": tagH1
+  of "h2": tagH2
+  of "h3": tagH3
+  of "h4": tagH4
+  of "h5": tagH5
+  of "h6": tagH6
+  of "head": tagHead
+  of "header": tagHeader
+  of "hgroup": tagHgroup
+  of "html": tagHtml
+  of "hr": tagHr
+  of "i": tagI
+  of "iframe": tagIframe
+  of "img": tagImg
+  of "input": tagInput
+  of "ins": tagIns
+  of "isindex": tagIsindex
+  of "kbd": tagKbd
+  of "keygen": tagKeygen
+  of "label": tagLabel
+  of "legend": tagLegend
+  of "li": tagLi
+  of "link": tagLink
+  of "map": tagMap
+  of "mark": tagMark
+  of "menu": tagMenu
+  of "meta": tagMeta
+  of "meter": tagMeter
+  of "nav": tagNav
+  of "nobr": tagNobr
+  of "noframes": tagNoframes
+  of "noscript": tagNoscript
+  of "object": tagObject
+  of "ol": tagOl
+  of "optgroup": tagOptgroup
+  of "option": tagOption
+  of "output": tagOutput
+  of "p": tagP
+  of "param": tagParam
+  of "pre": tagPre
+  of "progress": tagProgress
+  of "q": tagQ
+  of "rp": tagRp
+  of "rt": tagRt
+  of "ruby": tagRuby
+  of "s": tagS
+  of "samp": tagSamp
+  of "script": tagScript
+  of "section": tagSection
+  of "select": tagSelect
+  of "small": tagSmall
+  of "source": tagSource
+  of "span": tagSpan
+  of "strike": tagStrike
+  of "strong": tagStrong
+  of "style": tagStyle
+  of "sub": tagSub
+  of "summary": tagSummary
+  of "sup": tagSup
+  of "table": tagTable
+  of "tbody": tagTbody
+  of "td": tagTd
+  of "textarea": tagTextarea
+  of "tfoot": tagTfoot
+  of "th": tagTh
+  of "thead": tagThead
+  of "time": tagTime
+  of "title": tagTitle
+  of "tr": tagTr
+  of "track": tagTrack
+  of "tt": tagTt
+  of "u": tagU
+  of "ul": tagUl
+  of "var": tagVar
+  of "video": tagVideo
+  of "wbr": tagWbr
+  else: tagUnknown
 
-proc binaryStrSearch(x: openarray[string], y: string): int = 
-  ## XXX put this into the library somewhere!
-  var a = 0
-  var b = len(x) - 1
-  while a <= b: 
-    var mid = (a + b) div 2
-    var c = cmp(x[mid], y)
-    if c < 0: a = mid + 1
-    elif c > 0: b = mid - 1
-    else: return mid
-  result = - 1
 
-proc htmlTag*(n: PXmlNode): THtmlTag = 
-  ## gets `n`'s tag as a ``THtmlTag``.
+proc htmlTag*(n: XmlNode): HtmlTag =
+  ## Gets `n`'s tag as a `HtmlTag`.
   if n.clientData == 0:
-    n.clientData = binaryStrSearch(tagStrs, n.tag)+1
-  result = THtmlTag(n.clientData)
+    n.clientData = toHtmlTag(n.tag).ord
+  result = HtmlTag(n.clientData)
 
-proc htmlTag*(s: string): THtmlTag =
-  ## converts `s` to a ``THtmlTag``. If `s` is no HTML tag, ``tagUnknown`` is
+proc htmlTag*(s: string): HtmlTag =
+  ## Converts `s` to a `HtmlTag`. If `s` is no HTML tag, `tagUnknown` is
   ## returned.
-  result = THtmlTag(binaryStrSearch(tagStrs, s.toLower)+1)
+  let s = if allLower(s): s else: toLowerAscii(s)
+  result = toHtmlTag(s)
 
-proc entityToUtf8*(entity: string): string = 
-  ## converts an HTML entity name like ``&Uuml;`` to its UTF-8 equivalent.
+proc runeToEntity*(rune: Rune): string =
+  ## converts a Rune to its numeric HTML entity equivalent.
+  runnableExamples:
+    import std/unicode
+    doAssert runeToEntity(Rune(0)) == ""
+    doAssert runeToEntity(Rune(-1)) == ""
+    doAssert runeToEntity("Ü".runeAt(0)) == "#220"
+    doAssert runeToEntity("∈".runeAt(0)) == "#8712"
+  if rune.ord <= 0: result = ""
+  else: result = '#' & $rune.ord
+
+proc entityToRune*(entity: string): Rune =
+  ## Converts an HTML entity name like `&Uuml;` or values like `&#220;`
+  ## or `&#x000DC;` to its UTF-8 equivalent.
+  ## Rune(0) is returned if the entity name is unknown.
+  runnableExamples:
+    import std/unicode
+    doAssert entityToRune("") == Rune(0)
+    doAssert entityToRune("a") == Rune(0)
+    doAssert entityToRune("gt") == ">".runeAt(0)
+    doAssert entityToRune("Uuml") == "Ü".runeAt(0)
+    doAssert entityToRune("quest") == "?".runeAt(0)
+    doAssert entityToRune("#x0003F") == "?".runeAt(0)
+  if entity.len < 2: return # smallest entity has length 2
+  if entity[0] == '#':
+    var runeValue = 0
+    case entity[1]
+    of '0'..'9':
+      try: runeValue = parseInt(entity[1..^1])
+      except ValueError: discard
+    of 'x', 'X': # not case sensitive here
+      try: runeValue = parseHexInt(entity[2..^1])
+      except ValueError: discard
+    else: discard # other entities are not defined with prefix `#`
+    if runeValue notin 0..0x10FFFF: runeValue = 0 # only return legal values
+    return Rune(runeValue)
+  case entity # entity names are case sensitive
+  of "Tab": Rune(0x00009)
+  of "NewLine": Rune(0x0000A)
+  of "excl": Rune(0x00021)
+  of "quot", "QUOT": Rune(0x00022)
+  of "num": Rune(0x00023)
+  of "dollar": Rune(0x00024)
+  of "percnt": Rune(0x00025)
+  of "amp", "AMP": Rune(0x00026)
+  of "apos": Rune(0x00027)
+  of "lpar": Rune(0x00028)
+  of "rpar": Rune(0x00029)
+  of "ast", "midast": Rune(0x0002A)
+  of "plus": Rune(0x0002B)
+  of "comma": Rune(0x0002C)
+  of "period": Rune(0x0002E)
+  of "sol": Rune(0x0002F)
+  of "colon": Rune(0x0003A)
+  of "semi": Rune(0x0003B)
+  of "lt", "LT": Rune(0x0003C)
+  of "equals": Rune(0x0003D)
+  of "gt", "GT": Rune(0x0003E)
+  of "quest": Rune(0x0003F)
+  of "commat": Rune(0x00040)
+  of "lsqb", "lbrack": Rune(0x0005B)
+  of "bsol": Rune(0x0005C)
+  of "rsqb", "rbrack": Rune(0x0005D)
+  of "Hat": Rune(0x0005E)
+  of "lowbar": Rune(0x0005F)
+  of "grave", "DiacriticalGrave": Rune(0x00060)
+  of "lcub", "lbrace": Rune(0x0007B)
+  of "verbar", "vert", "VerticalLine": Rune(0x0007C)
+  of "rcub", "rbrace": Rune(0x0007D)
+  of "nbsp", "NonBreakingSpace": Rune(0x000A0)
+  of "iexcl": Rune(0x000A1)
+  of "cent": Rune(0x000A2)
+  of "pound": Rune(0x000A3)
+  of "curren": Rune(0x000A4)
+  of "yen": Rune(0x000A5)
+  of "brvbar": Rune(0x000A6)
+  of "sect": Rune(0x000A7)
+  of "Dot", "die", "DoubleDot", "uml": Rune(0x000A8)
+  of "copy", "COPY": Rune(0x000A9)
+  of "ordf": Rune(0x000AA)
+  of "laquo": Rune(0x000AB)
+  of "not": Rune(0x000AC)
+  of "shy": Rune(0x000AD)
+  of "reg", "circledR", "REG": Rune(0x000AE)
+  of "macr", "OverBar", "strns": Rune(0x000AF)
+  of "deg": Rune(0x000B0)
+  of "plusmn", "pm", "PlusMinus": Rune(0x000B1)
+  of "sup2": Rune(0x000B2)
+  of "sup3": Rune(0x000B3)
+  of "acute", "DiacriticalAcute": Rune(0x000B4)
+  of "micro": Rune(0x000B5)
+  of "para": Rune(0x000B6)
+  of "middot", "centerdot", "CenterDot": Rune(0x000B7)
+  of "cedil", "Cedilla": Rune(0x000B8)
+  of "sup1": Rune(0x000B9)
+  of "ordm": Rune(0x000BA)
+  of "raquo": Rune(0x000BB)
+  of "frac14": Rune(0x000BC)
+  of "frac12", "half": Rune(0x000BD)
+  of "frac34": Rune(0x000BE)
+  of "iquest": Rune(0x000BF)
+  of "Agrave": Rune(0x000C0)
+  of "Aacute": Rune(0x000C1)
+  of "Acirc": Rune(0x000C2)
+  of "Atilde": Rune(0x000C3)
+  of "Auml": Rune(0x000C4)
+  of "Aring": Rune(0x000C5)
+  of "AElig": Rune(0x000C6)
+  of "Ccedil": Rune(0x000C7)
+  of "Egrave": Rune(0x000C8)
+  of "Eacute": Rune(0x000C9)
+  of "Ecirc": Rune(0x000CA)
+  of "Euml": Rune(0x000CB)
+  of "Igrave": Rune(0x000CC)
+  of "Iacute": Rune(0x000CD)
+  of "Icirc": Rune(0x000CE)
+  of "Iuml": Rune(0x000CF)
+  of "ETH": Rune(0x000D0)
+  of "Ntilde": Rune(0x000D1)
+  of "Ograve": Rune(0x000D2)
+  of "Oacute": Rune(0x000D3)
+  of "Ocirc": Rune(0x000D4)
+  of "Otilde": Rune(0x000D5)
+  of "Ouml": Rune(0x000D6)
+  of "times": Rune(0x000D7)
+  of "Oslash": Rune(0x000D8)
+  of "Ugrave": Rune(0x000D9)
+  of "Uacute": Rune(0x000DA)
+  of "Ucirc": Rune(0x000DB)
+  of "Uuml": Rune(0x000DC)
+  of "Yacute": Rune(0x000DD)
+  of "THORN": Rune(0x000DE)
+  of "szlig": Rune(0x000DF)
+  of "agrave": Rune(0x000E0)
+  of "aacute": Rune(0x000E1)
+  of "acirc": Rune(0x000E2)
+  of "atilde": Rune(0x000E3)
+  of "auml": Rune(0x000E4)
+  of "aring": Rune(0x000E5)
+  of "aelig": Rune(0x000E6)
+  of "ccedil": Rune(0x000E7)
+  of "egrave": Rune(0x000E8)
+  of "eacute": Rune(0x000E9)
+  of "ecirc": Rune(0x000EA)
+  of "euml": Rune(0x000EB)
+  of "igrave": Rune(0x000EC)
+  of "iacute": Rune(0x000ED)
+  of "icirc": Rune(0x000EE)
+  of "iuml": Rune(0x000EF)
+  of "eth": Rune(0x000F0)
+  of "ntilde": Rune(0x000F1)
+  of "ograve": Rune(0x000F2)
+  of "oacute": Rune(0x000F3)
+  of "ocirc": Rune(0x000F4)
+  of "otilde": Rune(0x000F5)
+  of "ouml": Rune(0x000F6)
+  of "divide", "div": Rune(0x000F7)
+  of "oslash": Rune(0x000F8)
+  of "ugrave": Rune(0x000F9)
+  of "uacute": Rune(0x000FA)
+  of "ucirc": Rune(0x000FB)
+  of "uuml": Rune(0x000FC)
+  of "yacute": Rune(0x000FD)
+  of "thorn": Rune(0x000FE)
+  of "yuml": Rune(0x000FF)
+  of "Amacr": Rune(0x00100)
+  of "amacr": Rune(0x00101)
+  of "Abreve": Rune(0x00102)
+  of "abreve": Rune(0x00103)
+  of "Aogon": Rune(0x00104)
+  of "aogon": Rune(0x00105)
+  of "Cacute": Rune(0x00106)
+  of "cacute": Rune(0x00107)
+  of "Ccirc": Rune(0x00108)
+  of "ccirc": Rune(0x00109)
+  of "Cdot": Rune(0x0010A)
+  of "cdot": Rune(0x0010B)
+  of "Ccaron": Rune(0x0010C)
+  of "ccaron": Rune(0x0010D)
+  of "Dcaron": Rune(0x0010E)
+  of "dcaron": Rune(0x0010F)
+  of "Dstrok": Rune(0x00110)
+  of "dstrok": Rune(0x00111)
+  of "Emacr": Rune(0x00112)
+  of "emacr": Rune(0x00113)
+  of "Edot": Rune(0x00116)
+  of "edot": Rune(0x00117)
+  of "Eogon": Rune(0x00118)
+  of "eogon": Rune(0x00119)
+  of "Ecaron": Rune(0x0011A)
+  of "ecaron": Rune(0x0011B)
+  of "Gcirc": Rune(0x0011C)
+  of "gcirc": Rune(0x0011D)
+  of "Gbreve": Rune(0x0011E)
+  of "gbreve": Rune(0x0011F)
+  of "Gdot": Rune(0x00120)
+  of "gdot": Rune(0x00121)
+  of "Gcedil": Rune(0x00122)
+  of "Hcirc": Rune(0x00124)
+  of "hcirc": Rune(0x00125)
+  of "Hstrok": Rune(0x00126)
+  of "hstrok": Rune(0x00127)
+  of "Itilde": Rune(0x00128)
+  of "itilde": Rune(0x00129)
+  of "Imacr": Rune(0x0012A)
+  of "imacr": Rune(0x0012B)
+  of "Iogon": Rune(0x0012E)
+  of "iogon": Rune(0x0012F)
+  of "Idot": Rune(0x00130)
+  of "imath", "inodot": Rune(0x00131)
+  of "IJlig": Rune(0x00132)
+  of "ijlig": Rune(0x00133)
+  of "Jcirc": Rune(0x00134)
+  of "jcirc": Rune(0x00135)
+  of "Kcedil": Rune(0x00136)
+  of "kcedil": Rune(0x00137)
+  of "kgreen": Rune(0x00138)
+  of "Lacute": Rune(0x00139)
+  of "lacute": Rune(0x0013A)
+  of "Lcedil": Rune(0x0013B)
+  of "lcedil": Rune(0x0013C)
+  of "Lcaron": Rune(0x0013D)
+  of "lcaron": Rune(0x0013E)
+  of "Lmidot": Rune(0x0013F)
+  of "lmidot": Rune(0x00140)
+  of "Lstrok": Rune(0x00141)
+  of "lstrok": Rune(0x00142)
+  of "Nacute": Rune(0x00143)
+  of "nacute": Rune(0x00144)
+  of "Ncedil": Rune(0x00145)
+  of "ncedil": Rune(0x00146)
+  of "Ncaron": Rune(0x00147)
+  of "ncaron": Rune(0x00148)
+  of "napos": Rune(0x00149)
+  of "ENG": Rune(0x0014A)
+  of "eng": Rune(0x0014B)
+  of "Omacr": Rune(0x0014C)
+  of "omacr": Rune(0x0014D)
+  of "Odblac": Rune(0x00150)
+  of "odblac": Rune(0x00151)
+  of "OElig": Rune(0x00152)
+  of "oelig": Rune(0x00153)
+  of "Racute": Rune(0x00154)
+  of "racute": Rune(0x00155)
+  of "Rcedil": Rune(0x00156)
+  of "rcedil": Rune(0x00157)
+  of "Rcaron": Rune(0x00158)
+  of "rcaron": Rune(0x00159)
+  of "Sacute": Rune(0x0015A)
+  of "sacute": Rune(0x0015B)
+  of "Scirc": Rune(0x0015C)
+  of "scirc": Rune(0x0015D)
+  of "Scedil": Rune(0x0015E)
+  of "scedil": Rune(0x0015F)
+  of "Scaron": Rune(0x00160)
+  of "scaron": Rune(0x00161)
+  of "Tcedil": Rune(0x00162)
+  of "tcedil": Rune(0x00163)
+  of "Tcaron": Rune(0x00164)
+  of "tcaron": Rune(0x00165)
+  of "Tstrok": Rune(0x00166)
+  of "tstrok": Rune(0x00167)
+  of "Utilde": Rune(0x00168)
+  of "utilde": Rune(0x00169)
+  of "Umacr": Rune(0x0016A)
+  of "umacr": Rune(0x0016B)
+  of "Ubreve": Rune(0x0016C)
+  of "ubreve": Rune(0x0016D)
+  of "Uring": Rune(0x0016E)
+  of "uring": Rune(0x0016F)
+  of "Udblac": Rune(0x00170)
+  of "udblac": Rune(0x00171)
+  of "Uogon": Rune(0x00172)
+  of "uogon": Rune(0x00173)
+  of "Wcirc": Rune(0x00174)
+  of "wcirc": Rune(0x00175)
+  of "Ycirc": Rune(0x00176)
+  of "ycirc": Rune(0x00177)
+  of "Yuml": Rune(0x00178)
+  of "Zacute": Rune(0x00179)
+  of "zacute": Rune(0x0017A)
+  of "Zdot": Rune(0x0017B)
+  of "zdot": Rune(0x0017C)
+  of "Zcaron": Rune(0x0017D)
+  of "zcaron": Rune(0x0017E)
+  of "fnof": Rune(0x00192)
+  of "imped": Rune(0x001B5)
+  of "gacute": Rune(0x001F5)
+  of "jmath": Rune(0x00237)
+  of "circ": Rune(0x002C6)
+  of "caron", "Hacek": Rune(0x002C7)
+  of "breve", "Breve": Rune(0x002D8)
+  of "dot", "DiacriticalDot": Rune(0x002D9)
+  of "ring": Rune(0x002DA)
+  of "ogon": Rune(0x002DB)
+  of "tilde", "DiacriticalTilde": Rune(0x002DC)
+  of "dblac", "DiacriticalDoubleAcute": Rune(0x002DD)
+  of "DownBreve": Rune(0x00311)
+  of "UnderBar": Rune(0x00332)
+  of "Alpha": Rune(0x00391)
+  of "Beta": Rune(0x00392)
+  of "Gamma": Rune(0x00393)
+  of "Delta": Rune(0x00394)
+  of "Epsilon": Rune(0x00395)
+  of "Zeta": Rune(0x00396)
+  of "Eta": Rune(0x00397)
+  of "Theta": Rune(0x00398)
+  of "Iota": Rune(0x00399)
+  of "Kappa": Rune(0x0039A)
+  of "Lambda": Rune(0x0039B)
+  of "Mu": Rune(0x0039C)
+  of "Nu": Rune(0x0039D)
+  of "Xi": Rune(0x0039E)
+  of "Omicron": Rune(0x0039F)
+  of "Pi": Rune(0x003A0)
+  of "Rho": Rune(0x003A1)
+  of "Sigma": Rune(0x003A3)
+  of "Tau": Rune(0x003A4)
+  of "Upsilon": Rune(0x003A5)
+  of "Phi": Rune(0x003A6)
+  of "Chi": Rune(0x003A7)
+  of "Psi": Rune(0x003A8)
+  of "Omega": Rune(0x003A9)
+  of "alpha": Rune(0x003B1)
+  of "beta": Rune(0x003B2)
+  of "gamma": Rune(0x003B3)
+  of "delta": Rune(0x003B4)
+  of "epsiv", "varepsilon", "epsilon": Rune(0x003B5)
+  of "zeta": Rune(0x003B6)
+  of "eta": Rune(0x003B7)
+  of "theta": Rune(0x003B8)
+  of "iota": Rune(0x003B9)
+  of "kappa": Rune(0x003BA)
+  of "lambda": Rune(0x003BB)
+  of "mu": Rune(0x003BC)
+  of "nu": Rune(0x003BD)
+  of "xi": Rune(0x003BE)
+  of "omicron": Rune(0x003BF)
+  of "pi": Rune(0x003C0)
+  of "rho": Rune(0x003C1)
+  of "sigmav", "varsigma", "sigmaf": Rune(0x003C2)
+  of "sigma": Rune(0x003C3)
+  of "tau": Rune(0x003C4)
+  of "upsi", "upsilon": Rune(0x003C5)
+  of "phi", "phiv", "varphi": Rune(0x003C6)
+  of "chi": Rune(0x003C7)
+  of "psi": Rune(0x003C8)
+  of "omega": Rune(0x003C9)
+  of "thetav", "vartheta", "thetasym": Rune(0x003D1)
+  of "Upsi", "upsih": Rune(0x003D2)
+  of "straightphi": Rune(0x003D5)
+  of "piv", "varpi": Rune(0x003D6)
+  of "Gammad": Rune(0x003DC)
+  of "gammad", "digamma": Rune(0x003DD)
+  of "kappav", "varkappa": Rune(0x003F0)
+  of "rhov", "varrho": Rune(0x003F1)
+  of "epsi", "straightepsilon": Rune(0x003F5)
+  of "bepsi", "backepsilon": Rune(0x003F6)
+  of "IOcy": Rune(0x00401)
+  of "DJcy": Rune(0x00402)
+  of "GJcy": Rune(0x00403)
+  of "Jukcy": Rune(0x00404)
+  of "DScy": Rune(0x00405)
+  of "Iukcy": Rune(0x00406)
+  of "YIcy": Rune(0x00407)
+  of "Jsercy": Rune(0x00408)
+  of "LJcy": Rune(0x00409)
+  of "NJcy": Rune(0x0040A)
+  of "TSHcy": Rune(0x0040B)
+  of "KJcy": Rune(0x0040C)
+  of "Ubrcy": Rune(0x0040E)
+  of "DZcy": Rune(0x0040F)
+  of "Acy": Rune(0x00410)
+  of "Bcy": Rune(0x00411)
+  of "Vcy": Rune(0x00412)
+  of "Gcy": Rune(0x00413)
+  of "Dcy": Rune(0x00414)
+  of "IEcy": Rune(0x00415)
+  of "ZHcy": Rune(0x00416)
+  of "Zcy": Rune(0x00417)
+  of "Icy": Rune(0x00418)
+  of "Jcy": Rune(0x00419)
+  of "Kcy": Rune(0x0041A)
+  of "Lcy": Rune(0x0041B)
+  of "Mcy": Rune(0x0041C)
+  of "Ncy": Rune(0x0041D)
+  of "Ocy": Rune(0x0041E)
+  of "Pcy": Rune(0x0041F)
+  of "Rcy": Rune(0x00420)
+  of "Scy": Rune(0x00421)
+  of "Tcy": Rune(0x00422)
+  of "Ucy": Rune(0x00423)
+  of "Fcy": Rune(0x00424)
+  of "KHcy": Rune(0x00425)
+  of "TScy": Rune(0x00426)
+  of "CHcy": Rune(0x00427)
+  of "SHcy": Rune(0x00428)
+  of "SHCHcy": Rune(0x00429)
+  of "HARDcy": Rune(0x0042A)
+  of "Ycy": Rune(0x0042B)
+  of "SOFTcy": Rune(0x0042C)
+  of "Ecy": Rune(0x0042D)
+  of "YUcy": Rune(0x0042E)
+  of "YAcy": Rune(0x0042F)
+  of "acy": Rune(0x00430)
+  of "bcy": Rune(0x00431)
+  of "vcy": Rune(0x00432)
+  of "gcy": Rune(0x00433)
+  of "dcy": Rune(0x00434)
+  of "iecy": Rune(0x00435)
+  of "zhcy": Rune(0x00436)
+  of "zcy": Rune(0x00437)
+  of "icy": Rune(0x00438)
+  of "jcy": Rune(0x00439)
+  of "kcy": Rune(0x0043A)
+  of "lcy": Rune(0x0043B)
+  of "mcy": Rune(0x0043C)
+  of "ncy": Rune(0x0043D)
+  of "ocy": Rune(0x0043E)
+  of "pcy": Rune(0x0043F)
+  of "rcy": Rune(0x00440)
+  of "scy": Rune(0x00441)
+  of "tcy": Rune(0x00442)
+  of "ucy": Rune(0x00443)
+  of "fcy": Rune(0x00444)
+  of "khcy": Rune(0x00445)
+  of "tscy": Rune(0x00446)
+  of "chcy": Rune(0x00447)
+  of "shcy": Rune(0x00448)
+  of "shchcy": Rune(0x00449)
+  of "hardcy": Rune(0x0044A)
+  of "ycy": Rune(0x0044B)
+  of "softcy": Rune(0x0044C)
+  of "ecy": Rune(0x0044D)
+  of "yucy": Rune(0x0044E)
+  of "yacy": Rune(0x0044F)
+  of "iocy": Rune(0x00451)
+  of "djcy": Rune(0x00452)
+  of "gjcy": Rune(0x00453)
+  of "jukcy": Rune(0x00454)
+  of "dscy": Rune(0x00455)
+  of "iukcy": Rune(0x00456)
+  of "yicy": Rune(0x00457)
+  of "jsercy": Rune(0x00458)
+  of "ljcy": Rune(0x00459)
+  of "njcy": Rune(0x0045A)
+  of "tshcy": Rune(0x0045B)
+  of "kjcy": Rune(0x0045C)
+  of "ubrcy": Rune(0x0045E)
+  of "dzcy": Rune(0x0045F)
+  of "ensp": Rune(0x02002)
+  of "emsp": Rune(0x02003)
+  of "emsp13": Rune(0x02004)
+  of "emsp14": Rune(0x02005)
+  of "numsp": Rune(0x02007)
+  of "puncsp": Rune(0x02008)
+  of "thinsp", "ThinSpace": Rune(0x02009)
+  of "hairsp", "VeryThinSpace": Rune(0x0200A)
+  of "ZeroWidthSpace", "NegativeVeryThinSpace", "NegativeThinSpace",
+    "NegativeMediumSpace", "NegativeThickSpace": Rune(0x0200B)
+  of "zwnj": Rune(0x0200C)
+  of "zwj": Rune(0x0200D)
+  of "lrm": Rune(0x0200E)
+  of "rlm": Rune(0x0200F)
+  of "hyphen", "dash": Rune(0x02010)
+  of "ndash": Rune(0x02013)
+  of "mdash": Rune(0x02014)
+  of "horbar": Rune(0x02015)
+  of "Verbar", "Vert": Rune(0x02016)
+  of "lsquo", "OpenCurlyQuote": Rune(0x02018)
+  of "rsquo", "rsquor", "CloseCurlyQuote": Rune(0x02019)
+  of "lsquor", "sbquo": Rune(0x0201A)
+  of "ldquo", "OpenCurlyDoubleQuote": Rune(0x0201C)
+  of "rdquo", "rdquor", "CloseCurlyDoubleQuote": Rune(0x0201D)
+  of "ldquor", "bdquo": Rune(0x0201E)
+  of "dagger": Rune(0x02020)
+  of "Dagger", "ddagger": Rune(0x02021)
+  of "bull", "bullet": Rune(0x02022)
+  of "nldr": Rune(0x02025)
+  of "hellip", "mldr": Rune(0x02026)
+  of "permil": Rune(0x02030)
+  of "pertenk": Rune(0x02031)
+  of "prime": Rune(0x02032)
+  of "Prime": Rune(0x02033)
+  of "tprime": Rune(0x02034)
+  of "bprime", "backprime": Rune(0x02035)
+  of "lsaquo": Rune(0x02039)
+  of "rsaquo": Rune(0x0203A)
+  of "oline": Rune(0x0203E)
+  of "caret": Rune(0x02041)
+  of "hybull": Rune(0x02043)
+  of "frasl": Rune(0x02044)
+  of "bsemi": Rune(0x0204F)
+  of "qprime": Rune(0x02057)
+  of "MediumSpace": Rune(0x0205F)
+  of "NoBreak": Rune(0x02060)
+  of "ApplyFunction", "af": Rune(0x02061)
+  of "InvisibleTimes", "it": Rune(0x02062)
+  of "InvisibleComma", "ic": Rune(0x02063)
+  of "euro": Rune(0x020AC)
+  of "tdot", "TripleDot": Rune(0x020DB)
+  of "DotDot": Rune(0x020DC)
+  of "Copf", "complexes": Rune(0x02102)
+  of "incare": Rune(0x02105)
+  of "gscr": Rune(0x0210A)
+  of "hamilt", "HilbertSpace", "Hscr": Rune(0x0210B)
+  of "Hfr", "Poincareplane": Rune(0x0210C)
+  of "quaternions", "Hopf": Rune(0x0210D)
+  of "planckh": Rune(0x0210E)
+  of "planck", "hbar", "plankv", "hslash": Rune(0x0210F)
+  of "Iscr", "imagline": Rune(0x02110)
+  of "image", "Im", "imagpart", "Ifr": Rune(0x02111)
+  of "Lscr", "lagran", "Laplacetrf": Rune(0x02112)
+  of "ell": Rune(0x02113)
+  of "Nopf", "naturals": Rune(0x02115)
+  of "numero": Rune(0x02116)
+  of "copysr": Rune(0x02117)
+  of "weierp", "wp": Rune(0x02118)
+  of "Popf", "primes": Rune(0x02119)
+  of "rationals", "Qopf": Rune(0x0211A)
+  of "Rscr", "realine": Rune(0x0211B)
+  of "real", "Re", "realpart", "Rfr": Rune(0x0211C)
+  of "reals", "Ropf": Rune(0x0211D)
+  of "rx": Rune(0x0211E)
+  of "trade", "TRADE": Rune(0x02122)
+  of "integers", "Zopf": Rune(0x02124)
+  of "ohm": Rune(0x02126)
+  of "mho": Rune(0x02127)
+  of "Zfr", "zeetrf": Rune(0x02128)
+  of "iiota": Rune(0x02129)
+  of "angst": Rune(0x0212B)
+  of "bernou", "Bernoullis", "Bscr": Rune(0x0212C)
+  of "Cfr", "Cayleys": Rune(0x0212D)
+  of "escr": Rune(0x0212F)
+  of "Escr", "expectation": Rune(0x02130)
+  of "Fscr", "Fouriertrf": Rune(0x02131)
+  of "phmmat", "Mellintrf", "Mscr": Rune(0x02133)
+  of "order", "orderof", "oscr": Rune(0x02134)
+  of "alefsym", "aleph": Rune(0x02135)
+  of "beth": Rune(0x02136)
+  of "gimel": Rune(0x02137)
+  of "daleth": Rune(0x02138)
+  of "CapitalDifferentialD", "DD": Rune(0x02145)
+  of "DifferentialD", "dd": Rune(0x02146)
+  of "ExponentialE", "exponentiale", "ee": Rune(0x02147)
+  of "ImaginaryI", "ii": Rune(0x02148)
+  of "frac13": Rune(0x02153)
+  of "frac23": Rune(0x02154)
+  of "frac15": Rune(0x02155)
+  of "frac25": Rune(0x02156)
+  of "frac35": Rune(0x02157)
+  of "frac45": Rune(0x02158)
+  of "frac16": Rune(0x02159)
+  of "frac56": Rune(0x0215A)
+  of "frac18": Rune(0x0215B)
+  of "frac38": Rune(0x0215C)
+  of "frac58": Rune(0x0215D)
+  of "frac78": Rune(0x0215E)
+  of "larr", "leftarrow", "LeftArrow", "slarr",
+    "ShortLeftArrow": Rune(0x02190)
+  of "uarr", "uparrow", "UpArrow", "ShortUpArrow": Rune(0x02191)
+  of "rarr", "rightarrow", "RightArrow", "srarr",
+    "ShortRightArrow": Rune(0x02192)
+  of "darr", "downarrow", "DownArrow",
+    "ShortDownArrow": Rune(0x02193)
+  of "harr", "leftrightarrow", "LeftRightArrow": Rune(0x02194)
+  of "varr", "updownarrow", "UpDownArrow": Rune(0x02195)
+  of "nwarr", "UpperLeftArrow", "nwarrow": Rune(0x02196)
+  of "nearr", "UpperRightArrow", "nearrow": Rune(0x02197)
+  of "searr", "searrow", "LowerRightArrow": Rune(0x02198)
+  of "swarr", "swarrow", "LowerLeftArrow": Rune(0x02199)
+  of "nlarr", "nleftarrow": Rune(0x0219A)
+  of "nrarr", "nrightarrow": Rune(0x0219B)
+  of "rarrw", "rightsquigarrow": Rune(0x0219D)
+  of "Larr", "twoheadleftarrow": Rune(0x0219E)
+  of "Uarr": Rune(0x0219F)
+  of "Rarr", "twoheadrightarrow": Rune(0x021A0)
+  of "Darr": Rune(0x021A1)
+  of "larrtl", "leftarrowtail": Rune(0x021A2)
+  of "rarrtl", "rightarrowtail": Rune(0x021A3)
+  of "LeftTeeArrow", "mapstoleft": Rune(0x021A4)
+  of "UpTeeArrow", "mapstoup": Rune(0x021A5)
+  of "map", "RightTeeArrow", "mapsto": Rune(0x021A6)
+  of "DownTeeArrow", "mapstodown": Rune(0x021A7)
+  of "larrhk", "hookleftarrow": Rune(0x021A9)
+  of "rarrhk", "hookrightarrow": Rune(0x021AA)
+  of "larrlp", "looparrowleft": Rune(0x021AB)
+  of "rarrlp", "looparrowright": Rune(0x021AC)
+  of "harrw", "leftrightsquigarrow": Rune(0x021AD)
+  of "nharr", "nleftrightarrow": Rune(0x021AE)
+  of "lsh", "Lsh": Rune(0x021B0)
+  of "rsh", "Rsh": Rune(0x021B1)
+  of "ldsh": Rune(0x021B2)
+  of "rdsh": Rune(0x021B3)
+  of "crarr": Rune(0x021B5)
+  of "cularr", "curvearrowleft": Rune(0x021B6)
+  of "curarr", "curvearrowright": Rune(0x021B7)
+  of "olarr", "circlearrowleft": Rune(0x021BA)
+  of "orarr", "circlearrowright": Rune(0x021BB)
+  of "lharu", "LeftVector", "leftharpoonup": Rune(0x021BC)
+  of "lhard", "leftharpoondown", "DownLeftVector": Rune(0x021BD)
+  of "uharr", "upharpoonright", "RightUpVector": Rune(0x021BE)
+  of "uharl", "upharpoonleft", "LeftUpVector": Rune(0x021BF)
+  of "rharu", "RightVector", "rightharpoonup": Rune(0x021C0)
+  of "rhard", "rightharpoondown", "DownRightVector": Rune(0x021C1)
+  of "dharr", "RightDownVector", "downharpoonright": Rune(0x021C2)
+  of "dharl", "LeftDownVector", "downharpoonleft": Rune(0x021C3)
+  of "rlarr", "rightleftarrows", "RightArrowLeftArrow": Rune(0x021C4)
+  of "udarr", "UpArrowDownArrow": Rune(0x021C5)
+  of "lrarr", "leftrightarrows", "LeftArrowRightArrow": Rune(0x021C6)
+  of "llarr", "leftleftarrows": Rune(0x021C7)
+  of "uuarr", "upuparrows": Rune(0x021C8)
+  of "rrarr", "rightrightarrows": Rune(0x021C9)
+  of "ddarr", "downdownarrows": Rune(0x021CA)
+  of "lrhar", "ReverseEquilibrium",
+    "leftrightharpoons": Rune(0x021CB)
+  of "rlhar", "rightleftharpoons", "Equilibrium": Rune(0x021CC)
+  of "nlArr", "nLeftarrow": Rune(0x021CD)
+  of "nhArr", "nLeftrightarrow": Rune(0x021CE)
+  of "nrArr", "nRightarrow": Rune(0x021CF)
+  of "lArr", "Leftarrow", "DoubleLeftArrow": Rune(0x021D0)
+  of "uArr", "Uparrow", "DoubleUpArrow": Rune(0x021D1)
+  of "rArr", "Rightarrow", "Implies",
+    "DoubleRightArrow": Rune(0x021D2)
+  of "dArr", "Downarrow", "DoubleDownArrow": Rune(0x021D3)
+  of "hArr", "Leftrightarrow", "DoubleLeftRightArrow",
+    "iff": Rune(0x021D4)
+  of "vArr", "Updownarrow", "DoubleUpDownArrow": Rune(0x021D5)
+  of "nwArr": Rune(0x021D6)
+  of "neArr": Rune(0x021D7)
+  of "seArr": Rune(0x021D8)
+  of "swArr": Rune(0x021D9)
+  of "lAarr", "Lleftarrow": Rune(0x021DA)
+  of "rAarr", "Rrightarrow": Rune(0x021DB)
+  of "zigrarr": Rune(0x021DD)
+  of "larrb", "LeftArrowBar": Rune(0x021E4)
+  of "rarrb", "RightArrowBar": Rune(0x021E5)
+  of "duarr", "DownArrowUpArrow": Rune(0x021F5)
+  of "loarr": Rune(0x021FD)
+  of "roarr": Rune(0x021FE)
+  of "hoarr": Rune(0x021FF)
+  of "forall", "ForAll": Rune(0x02200)
+  of "comp", "complement": Rune(0x02201)
+  of "part", "PartialD": Rune(0x02202)
+  of "exist", "Exists": Rune(0x02203)
+  of "nexist", "NotExists", "nexists": Rune(0x02204)
+  of "empty", "emptyset", "emptyv", "varnothing": Rune(0x02205)
+  of "nabla", "Del": Rune(0x02207)
+  of "isin", "isinv", "Element", "in": Rune(0x02208)
+  of "notin", "NotElement", "notinva": Rune(0x02209)
+  of "niv", "ReverseElement", "ni", "SuchThat": Rune(0x0220B)
+  of "notni", "notniva", "NotReverseElement": Rune(0x0220C)
+  of "prod", "Product": Rune(0x0220F)
+  of "coprod", "Coproduct": Rune(0x02210)
+  of "sum", "Sum": Rune(0x02211)
+  of "minus": Rune(0x02212)
+  of "mnplus", "mp", "MinusPlus": Rune(0x02213)
+  of "plusdo", "dotplus": Rune(0x02214)
+  of "setmn", "setminus", "Backslash", "ssetmn",
+    "smallsetminus": Rune(0x02216)
+  of "lowast": Rune(0x02217)
+  of "compfn", "SmallCircle": Rune(0x02218)
+  of "radic", "Sqrt": Rune(0x0221A)
+  of "prop", "propto", "Proportional", "vprop",
+    "varpropto": Rune(0x0221D)
+  of "infin": Rune(0x0221E)
+  of "angrt": Rune(0x0221F)
+  of "ang", "angle": Rune(0x02220)
+  of "angmsd", "measuredangle": Rune(0x02221)
+  of "angsph": Rune(0x02222)
+  of "mid", "VerticalBar", "smid", "shortmid": Rune(0x02223)
+  of "nmid", "NotVerticalBar", "nsmid", "nshortmid": Rune(0x02224)
+  of "par", "parallel", "DoubleVerticalBar", "spar",
+    "shortparallel": Rune(0x02225)
+  of "npar", "nparallel", "NotDoubleVerticalBar", "nspar",
+    "nshortparallel": Rune(0x02226)
+  of "and", "wedge": Rune(0x02227)
+  of "or", "vee": Rune(0x02228)
+  of "cap": Rune(0x02229)
+  of "cup": Rune(0x0222A)
+  of "int", "Integral": Rune(0x0222B)
+  of "Int": Rune(0x0222C)
+  of "tint", "iiint": Rune(0x0222D)
+  of "conint", "oint", "ContourIntegral": Rune(0x0222E)
+  of "Conint", "DoubleContourIntegral": Rune(0x0222F)
+  of "Cconint": Rune(0x02230)
+  of "cwint": Rune(0x02231)
+  of "cwconint", "ClockwiseContourIntegral": Rune(0x02232)
+  of "awconint", "CounterClockwiseContourIntegral": Rune(0x02233)
+  of "there4", "therefore", "Therefore": Rune(0x02234)
+  of "becaus", "because", "Because": Rune(0x02235)
+  of "ratio": Rune(0x02236)
+  of "Colon", "Proportion": Rune(0x02237)
+  of "minusd", "dotminus": Rune(0x02238)
+  of "mDDot": Rune(0x0223A)
+  of "homtht": Rune(0x0223B)
+  of "sim", "Tilde", "thksim", "thicksim": Rune(0x0223C)
+  of "bsim", "backsim": Rune(0x0223D)
+  of "ac", "mstpos": Rune(0x0223E)
+  of "acd": Rune(0x0223F)
+  of "wreath", "VerticalTilde", "wr": Rune(0x02240)
+  of "nsim", "NotTilde": Rune(0x02241)
+  of "esim", "EqualTilde", "eqsim": Rune(0x02242)
+  of "sime", "TildeEqual", "simeq": Rune(0x02243)
+  of "nsime", "nsimeq", "NotTildeEqual": Rune(0x02244)
+  of "cong", "TildeFullEqual": Rune(0x02245)
+  of "simne": Rune(0x02246)
+  of "ncong", "NotTildeFullEqual": Rune(0x02247)
+  of "asymp", "ap", "TildeTilde", "approx", "thkap",
+    "thickapprox": Rune(0x02248)
+  of "nap", "NotTildeTilde", "napprox": Rune(0x02249)
+  of "ape", "approxeq": Rune(0x0224A)
+  of "apid": Rune(0x0224B)
+  of "bcong", "backcong": Rune(0x0224C)
+  of "asympeq", "CupCap": Rune(0x0224D)
+  of "bump", "HumpDownHump", "Bumpeq": Rune(0x0224E)
+  of "bumpe", "HumpEqual", "bumpeq": Rune(0x0224F)
+  of "esdot", "DotEqual", "doteq": Rune(0x02250)
+  of "eDot", "doteqdot": Rune(0x02251)
+  of "efDot", "fallingdotseq": Rune(0x02252)
+  of "erDot", "risingdotseq": Rune(0x02253)
+  of "colone", "coloneq", "Assign": Rune(0x02254)
+  of "ecolon", "eqcolon": Rune(0x02255)
+  of "ecir", "eqcirc": Rune(0x02256)
+  of "cire", "circeq": Rune(0x02257)
+  of "wedgeq": Rune(0x02259)
+  of "veeeq": Rune(0x0225A)
+  of "trie", "triangleq": Rune(0x0225C)
+  of "equest", "questeq": Rune(0x0225F)
+  of "ne", "NotEqual": Rune(0x02260)
+  of "equiv", "Congruent": Rune(0x02261)
+  of "nequiv", "NotCongruent": Rune(0x02262)
+  of "le", "leq": Rune(0x02264)
+  of "ge", "GreaterEqual", "geq": Rune(0x02265)
+  of "lE", "LessFullEqual", "leqq": Rune(0x02266)
+  of "gE", "GreaterFullEqual", "geqq": Rune(0x02267)
+  of "lnE", "lneqq": Rune(0x02268)
+  of "gnE", "gneqq": Rune(0x02269)
+  of "Lt", "NestedLessLess", "ll": Rune(0x0226A)
+  of "Gt", "NestedGreaterGreater", "gg": Rune(0x0226B)
+  of "twixt", "between": Rune(0x0226C)
+  of "NotCupCap": Rune(0x0226D)
+  of "nlt", "NotLess", "nless": Rune(0x0226E)
+  of "ngt", "NotGreater", "ngtr": Rune(0x0226F)
+  of "nle", "NotLessEqual", "nleq": Rune(0x02270)
+  of "nge", "NotGreaterEqual", "ngeq": Rune(0x02271)
+  of "lsim", "LessTilde", "lesssim": Rune(0x02272)
+  of "gsim", "gtrsim", "GreaterTilde": Rune(0x02273)
+  of "nlsim", "NotLessTilde": Rune(0x02274)
+  of "ngsim", "NotGreaterTilde": Rune(0x02275)
+  of "lg", "lessgtr", "LessGreater": Rune(0x02276)
+  of "gl", "gtrless", "GreaterLess": Rune(0x02277)
+  of "ntlg", "NotLessGreater": Rune(0x02278)
+  of "ntgl", "NotGreaterLess": Rune(0x02279)
+  of "pr", "Precedes", "prec": Rune(0x0227A)
+  of "sc", "Succeeds", "succ": Rune(0x0227B)
+  of "prcue", "PrecedesSlantEqual", "preccurlyeq": Rune(0x0227C)
+  of "sccue", "SucceedsSlantEqual", "succcurlyeq": Rune(0x0227D)
+  of "prsim", "precsim", "PrecedesTilde": Rune(0x0227E)
+  of "scsim", "succsim", "SucceedsTilde": Rune(0x0227F)
+  of "npr", "nprec", "NotPrecedes": Rune(0x02280)
+  of "nsc", "nsucc", "NotSucceeds": Rune(0x02281)
+  of "sub", "subset": Rune(0x02282)
+  of "sup", "supset", "Superset": Rune(0x02283)
+  of "nsub": Rune(0x02284)
+  of "nsup": Rune(0x02285)
+  of "sube", "SubsetEqual", "subseteq": Rune(0x02286)
+  of "supe", "supseteq", "SupersetEqual": Rune(0x02287)
+  of "nsube", "nsubseteq", "NotSubsetEqual": Rune(0x02288)
+  of "nsupe", "nsupseteq", "NotSupersetEqual": Rune(0x02289)
+  of "subne", "subsetneq": Rune(0x0228A)
+  of "supne", "supsetneq": Rune(0x0228B)
+  of "cupdot": Rune(0x0228D)
+  of "uplus", "UnionPlus": Rune(0x0228E)
+  of "sqsub", "SquareSubset", "sqsubset": Rune(0x0228F)
+  of "sqsup", "SquareSuperset", "sqsupset": Rune(0x02290)
+  of "sqsube", "SquareSubsetEqual", "sqsubseteq": Rune(0x02291)
+  of "sqsupe", "SquareSupersetEqual", "sqsupseteq": Rune(0x02292)
+  of "sqcap", "SquareIntersection": Rune(0x02293)
+  of "sqcup", "SquareUnion": Rune(0x02294)
+  of "oplus", "CirclePlus": Rune(0x02295)
+  of "ominus", "CircleMinus": Rune(0x02296)
+  of "otimes", "CircleTimes": Rune(0x02297)
+  of "osol": Rune(0x02298)
+  of "odot", "CircleDot": Rune(0x02299)
+  of "ocir", "circledcirc": Rune(0x0229A)
+  of "oast", "circledast": Rune(0x0229B)
+  of "odash", "circleddash": Rune(0x0229D)
+  of "plusb", "boxplus": Rune(0x0229E)
+  of "minusb", "boxminus": Rune(0x0229F)
+  of "timesb", "boxtimes": Rune(0x022A0)
+  of "sdotb", "dotsquare": Rune(0x022A1)
+  of "vdash", "RightTee": Rune(0x022A2)
+  of "dashv", "LeftTee": Rune(0x022A3)
+  of "top", "DownTee": Rune(0x022A4)
+  of "bottom", "bot", "perp", "UpTee": Rune(0x022A5)
+  of "models": Rune(0x022A7)
+  of "vDash", "DoubleRightTee": Rune(0x022A8)
+  of "Vdash": Rune(0x022A9)
+  of "Vvdash": Rune(0x022AA)
+  of "VDash": Rune(0x022AB)
+  of "nvdash": Rune(0x022AC)
+  of "nvDash": Rune(0x022AD)
+  of "nVdash": Rune(0x022AE)
+  of "nVDash": Rune(0x022AF)
+  of "prurel": Rune(0x022B0)
+  of "vltri", "vartriangleleft", "LeftTriangle": Rune(0x022B2)
+  of "vrtri", "vartriangleright", "RightTriangle": Rune(0x022B3)
+  of "ltrie", "trianglelefteq", "LeftTriangleEqual": Rune(0x022B4)
+  of "rtrie", "trianglerighteq", "RightTriangleEqual": Rune(0x022B5)
+  of "origof": Rune(0x022B6)
+  of "imof": Rune(0x022B7)
+  of "mumap", "multimap": Rune(0x022B8)
+  of "hercon": Rune(0x022B9)
+  of "intcal", "intercal": Rune(0x022BA)
+  of "veebar": Rune(0x022BB)
+  of "barvee": Rune(0x022BD)
+  of "angrtvb": Rune(0x022BE)
+  of "lrtri": Rune(0x022BF)
+  of "xwedge", "Wedge", "bigwedge": Rune(0x022C0)
+  of "xvee", "Vee", "bigvee": Rune(0x022C1)
+  of "xcap", "Intersection", "bigcap": Rune(0x022C2)
+  of "xcup", "Union", "bigcup": Rune(0x022C3)
+  of "diam", "diamond", "Diamond": Rune(0x022C4)
+  of "sdot": Rune(0x022C5)
+  of "sstarf", "Star": Rune(0x022C6)
+  of "divonx", "divideontimes": Rune(0x022C7)
+  of "bowtie": Rune(0x022C8)
+  of "ltimes": Rune(0x022C9)
+  of "rtimes": Rune(0x022CA)
+  of "lthree", "leftthreetimes": Rune(0x022CB)
+  of "rthree", "rightthreetimes": Rune(0x022CC)
+  of "bsime", "backsimeq": Rune(0x022CD)
+  of "cuvee", "curlyvee": Rune(0x022CE)
+  of "cuwed", "curlywedge": Rune(0x022CF)
+  of "Sub", "Subset": Rune(0x022D0)
+  of "Sup", "Supset": Rune(0x022D1)
+  of "Cap": Rune(0x022D2)
+  of "Cup": Rune(0x022D3)
+  of "fork", "pitchfork": Rune(0x022D4)
+  of "epar": Rune(0x022D5)
+  of "ltdot", "lessdot": Rune(0x022D6)
+  of "gtdot", "gtrdot": Rune(0x022D7)
+  of "Ll": Rune(0x022D8)
+  of "Gg", "ggg": Rune(0x022D9)
+  of "leg", "LessEqualGreater", "lesseqgtr": Rune(0x022DA)
+  of "gel", "gtreqless", "GreaterEqualLess": Rune(0x022DB)
+  of "cuepr", "curlyeqprec": Rune(0x022DE)
+  of "cuesc", "curlyeqsucc": Rune(0x022DF)
+  of "nprcue", "NotPrecedesSlantEqual": Rune(0x022E0)
+  of "nsccue", "NotSucceedsSlantEqual": Rune(0x022E1)
+  of "nsqsube", "NotSquareSubsetEqual": Rune(0x022E2)
+  of "nsqsupe", "NotSquareSupersetEqual": Rune(0x022E3)
+  of "lnsim": Rune(0x022E6)
+  of "gnsim": Rune(0x022E7)
+  of "prnsim", "precnsim": Rune(0x022E8)
+  of "scnsim", "succnsim": Rune(0x022E9)
+  of "nltri", "ntriangleleft", "NotLeftTriangle": Rune(0x022EA)
+  of "nrtri", "ntriangleright", "NotRightTriangle": Rune(0x022EB)
+  of "nltrie", "ntrianglelefteq",
+    "NotLeftTriangleEqual": Rune(0x022EC)
+  of "nrtrie", "ntrianglerighteq",
+    "NotRightTriangleEqual": Rune(0x022ED)
+  of "vellip": Rune(0x022EE)
+  of "ctdot": Rune(0x022EF)
+  of "utdot": Rune(0x022F0)
+  of "dtdot": Rune(0x022F1)
+  of "disin": Rune(0x022F2)
+  of "isinsv": Rune(0x022F3)
+  of "isins": Rune(0x022F4)
+  of "isindot": Rune(0x022F5)
+  of "notinvc": Rune(0x022F6)
+  of "notinvb": Rune(0x022F7)
+  of "isinE": Rune(0x022F9)
+  of "nisd": Rune(0x022FA)
+  of "xnis": Rune(0x022FB)
+  of "nis": Rune(0x022FC)
+  of "notnivc": Rune(0x022FD)
+  of "notnivb": Rune(0x022FE)
+  of "barwed", "barwedge": Rune(0x02305)
+  of "Barwed", "doublebarwedge": Rune(0x02306)
+  of "lceil", "LeftCeiling": Rune(0x02308)
+  of "rceil", "RightCeiling": Rune(0x02309)
+  of "lfloor", "LeftFloor": Rune(0x0230A)
+  of "rfloor", "RightFloor": Rune(0x0230B)
+  of "drcrop": Rune(0x0230C)
+  of "dlcrop": Rune(0x0230D)
+  of "urcrop": Rune(0x0230E)
+  of "ulcrop": Rune(0x0230F)
+  of "bnot": Rune(0x02310)
+  of "profline": Rune(0x02312)
+  of "profsurf": Rune(0x02313)
+  of "telrec": Rune(0x02315)
+  of "target": Rune(0x02316)
+  of "ulcorn", "ulcorner": Rune(0x0231C)
+  of "urcorn", "urcorner": Rune(0x0231D)
+  of "dlcorn", "llcorner": Rune(0x0231E)
+  of "drcorn", "lrcorner": Rune(0x0231F)
+  of "frown", "sfrown": Rune(0x02322)
+  of "smile", "ssmile": Rune(0x02323)
+  of "cylcty": Rune(0x0232D)
+  of "profalar": Rune(0x0232E)
+  of "topbot": Rune(0x02336)
+  of "ovbar": Rune(0x0233D)
+  of "solbar": Rune(0x0233F)
+  of "angzarr": Rune(0x0237C)
+  of "lmoust", "lmoustache": Rune(0x023B0)
+  of "rmoust", "rmoustache": Rune(0x023B1)
+  of "tbrk", "OverBracket": Rune(0x023B4)
+  of "bbrk", "UnderBracket": Rune(0x023B5)
+  of "bbrktbrk": Rune(0x023B6)
+  of "OverParenthesis": Rune(0x023DC)
+  of "UnderParenthesis": Rune(0x023DD)
+  of "OverBrace": Rune(0x023DE)
+  of "UnderBrace": Rune(0x023DF)
+  of "trpezium": Rune(0x023E2)
+  of "elinters": Rune(0x023E7)
+  of "blank": Rune(0x02423)
+  of "oS", "circledS": Rune(0x024C8)
+  of "boxh", "HorizontalLine": Rune(0x02500)
+  of "boxv": Rune(0x02502)
+  of "boxdr": Rune(0x0250C)
+  of "boxdl": Rune(0x02510)
+  of "boxur": Rune(0x02514)
+  of "boxul": Rune(0x02518)
+  of "boxvr": Rune(0x0251C)
+  of "boxvl": Rune(0x02524)
+  of "boxhd": Rune(0x0252C)
+  of "boxhu": Rune(0x02534)
+  of "boxvh": Rune(0x0253C)
+  of "boxH": Rune(0x02550)
+  of "boxV": Rune(0x02551)
+  of "boxdR": Rune(0x02552)
+  of "boxDr": Rune(0x02553)
+  of "boxDR": Rune(0x02554)
+  of "boxdL": Rune(0x02555)
+  of "boxDl": Rune(0x02556)
+  of "boxDL": Rune(0x02557)
+  of "boxuR": Rune(0x02558)
+  of "boxUr": Rune(0x02559)
+  of "boxUR": Rune(0x0255A)
+  of "boxuL": Rune(0x0255B)
+  of "boxUl": Rune(0x0255C)
+  of "boxUL": Rune(0x0255D)
+  of "boxvR": Rune(0x0255E)
+  of "boxVr": Rune(0x0255F)
+  of "boxVR": Rune(0x02560)
+  of "boxvL": Rune(0x02561)
+  of "boxVl": Rune(0x02562)
+  of "boxVL": Rune(0x02563)
+  of "boxHd": Rune(0x02564)
+  of "boxhD": Rune(0x02565)
+  of "boxHD": Rune(0x02566)
+  of "boxHu": Rune(0x02567)
+  of "boxhU": Rune(0x02568)
+  of "boxHU": Rune(0x02569)
+  of "boxvH": Rune(0x0256A)
+  of "boxVh": Rune(0x0256B)
+  of "boxVH": Rune(0x0256C)
+  of "uhblk": Rune(0x02580)
+  of "lhblk": Rune(0x02584)
+  of "block": Rune(0x02588)
+  of "blk14": Rune(0x02591)
+  of "blk12": Rune(0x02592)
+  of "blk34": Rune(0x02593)
+  of "squ", "square", "Square": Rune(0x025A1)
+  of "squf", "squarf", "blacksquare",
+    "FilledVerySmallSquare": Rune(0x025AA)
+  of "EmptyVerySmallSquare": Rune(0x025AB)
+  of "rect": Rune(0x025AD)
+  of "marker": Rune(0x025AE)
+  of "fltns": Rune(0x025B1)
+  of "xutri", "bigtriangleup": Rune(0x025B3)
+  of "utrif", "blacktriangle": Rune(0x025B4)
+  of "utri", "triangle": Rune(0x025B5)
+  of "rtrif", "blacktriangleright": Rune(0x025B8)
+  of "rtri", "triangleright": Rune(0x025B9)
+  of "xdtri", "bigtriangledown": Rune(0x025BD)
+  of "dtrif", "blacktriangledown": Rune(0x025BE)
+  of "dtri", "triangledown": Rune(0x025BF)
+  of "ltrif", "blacktriangleleft": Rune(0x025C2)
+  of "ltri", "triangleleft": Rune(0x025C3)
+  of "loz", "lozenge": Rune(0x025CA)
+  of "cir": Rune(0x025CB)
+  of "tridot": Rune(0x025EC)
+  of "xcirc", "bigcirc": Rune(0x025EF)
+  of "ultri": Rune(0x025F8)
+  of "urtri": Rune(0x025F9)
+  of "lltri": Rune(0x025FA)
+  of "EmptySmallSquare": Rune(0x025FB)
+  of "FilledSmallSquare": Rune(0x025FC)
+  of "starf", "bigstar": Rune(0x02605)
+  of "star": Rune(0x02606)
+  of "phone": Rune(0x0260E)
+  of "female": Rune(0x02640)
+  of "male": Rune(0x02642)
+  of "spades", "spadesuit": Rune(0x02660)
+  of "clubs", "clubsuit": Rune(0x02663)
+  of "hearts", "heartsuit": Rune(0x02665)
+  of "diams", "diamondsuit": Rune(0x02666)
+  of "sung": Rune(0x0266A)
+  of "flat": Rune(0x0266D)
+  of "natur", "natural": Rune(0x0266E)
+  of "sharp": Rune(0x0266F)
+  of "check", "checkmark": Rune(0x02713)
+  of "cross": Rune(0x02717)
+  of "malt", "maltese": Rune(0x02720)
+  of "sext": Rune(0x02736)
+  of "VerticalSeparator": Rune(0x02758)
+  of "lbbrk": Rune(0x02772)
+  of "rbbrk": Rune(0x02773)
+  of "lobrk", "LeftDoubleBracket": Rune(0x027E6)
+  of "robrk", "RightDoubleBracket": Rune(0x027E7)
+  of "lang", "LeftAngleBracket", "langle": Rune(0x027E8)
+  of "rang", "RightAngleBracket", "rangle": Rune(0x027E9)
+  of "Lang": Rune(0x027EA)
+  of "Rang": Rune(0x027EB)
+  of "loang": Rune(0x027EC)
+  of "roang": Rune(0x027ED)
+  of "xlarr", "longleftarrow", "LongLeftArrow": Rune(0x027F5)
+  of "xrarr", "longrightarrow", "LongRightArrow": Rune(0x027F6)
+  of "xharr", "longleftrightarrow",
+    "LongLeftRightArrow": Rune(0x027F7)
+  of "xlArr", "Longleftarrow", "DoubleLongLeftArrow": Rune(0x027F8)
+  of "xrArr", "Longrightarrow", "DoubleLongRightArrow": Rune(0x027F9)
+  of "xhArr", "Longleftrightarrow",
+    "DoubleLongLeftRightArrow": Rune(0x027FA)
+  of "xmap", "longmapsto": Rune(0x027FC)
+  of "dzigrarr": Rune(0x027FF)
+  of "nvlArr": Rune(0x02902)
+  of "nvrArr": Rune(0x02903)
+  of "nvHarr": Rune(0x02904)
+  of "Map": Rune(0x02905)
+  of "lbarr": Rune(0x0290C)
+  of "rbarr", "bkarow": Rune(0x0290D)
+  of "lBarr": Rune(0x0290E)
+  of "rBarr", "dbkarow": Rune(0x0290F)
+  of "RBarr", "drbkarow": Rune(0x02910)
+  of "DDotrahd": Rune(0x02911)
+  of "UpArrowBar": Rune(0x02912)
+  of "DownArrowBar": Rune(0x02913)
+  of "Rarrtl": Rune(0x02916)
+  of "latail": Rune(0x02919)
+  of "ratail": Rune(0x0291A)
+  of "lAtail": Rune(0x0291B)
+  of "rAtail": Rune(0x0291C)
+  of "larrfs": Rune(0x0291D)
+  of "rarrfs": Rune(0x0291E)
+  of "larrbfs": Rune(0x0291F)
+  of "rarrbfs": Rune(0x02920)
+  of "nwarhk": Rune(0x02923)
+  of "nearhk": Rune(0x02924)
+  of "searhk", "hksearow": Rune(0x02925)
+  of "swarhk", "hkswarow": Rune(0x02926)
+  of "nwnear": Rune(0x02927)
+  of "nesear", "toea": Rune(0x02928)
+  of "seswar", "tosa": Rune(0x02929)
+  of "swnwar": Rune(0x0292A)
+  of "rarrc": Rune(0x02933)
+  of "cudarrr": Rune(0x02935)
+  of "ldca": Rune(0x02936)
+  of "rdca": Rune(0x02937)
+  of "cudarrl": Rune(0x02938)
+  of "larrpl": Rune(0x02939)
+  of "curarrm": Rune(0x0293C)
+  of "cularrp": Rune(0x0293D)
+  of "rarrpl": Rune(0x02945)
+  of "harrcir": Rune(0x02948)
+  of "Uarrocir": Rune(0x02949)
+  of "lurdshar": Rune(0x0294A)
+  of "ldrushar": Rune(0x0294B)
+  of "LeftRightVector": Rune(0x0294E)
+  of "RightUpDownVector": Rune(0x0294F)
+  of "DownLeftRightVector": Rune(0x02950)
+  of "LeftUpDownVector": Rune(0x02951)
+  of "LeftVectorBar": Rune(0x02952)
+  of "RightVectorBar": Rune(0x02953)
+  of "RightUpVectorBar": Rune(0x02954)
+  of "RightDownVectorBar": Rune(0x02955)
+  of "DownLeftVectorBar": Rune(0x02956)
+  of "DownRightVectorBar": Rune(0x02957)
+  of "LeftUpVectorBar": Rune(0x02958)
+  of "LeftDownVectorBar": Rune(0x02959)
+  of "LeftTeeVector": Rune(0x0295A)
+  of "RightTeeVector": Rune(0x0295B)
+  of "RightUpTeeVector": Rune(0x0295C)
+  of "RightDownTeeVector": Rune(0x0295D)
+  of "DownLeftTeeVector": Rune(0x0295E)
+  of "DownRightTeeVector": Rune(0x0295F)
+  of "LeftUpTeeVector": Rune(0x02960)
+  of "LeftDownTeeVector": Rune(0x02961)
+  of "lHar": Rune(0x02962)
+  of "uHar": Rune(0x02963)
+  of "rHar": Rune(0x02964)
+  of "dHar": Rune(0x02965)
+  of "luruhar": Rune(0x02966)
+  of "ldrdhar": Rune(0x02967)
+  of "ruluhar": Rune(0x02968)
+  of "rdldhar": Rune(0x02969)
+  of "lharul": Rune(0x0296A)
+  of "llhard": Rune(0x0296B)
+  of "rharul": Rune(0x0296C)
+  of "lrhard": Rune(0x0296D)
+  of "udhar", "UpEquilibrium": Rune(0x0296E)
+  of "duhar", "ReverseUpEquilibrium": Rune(0x0296F)
+  of "RoundImplies": Rune(0x02970)
+  of "erarr": Rune(0x02971)
+  of "simrarr": Rune(0x02972)
+  of "larrsim": Rune(0x02973)
+  of "rarrsim": Rune(0x02974)
+  of "rarrap": Rune(0x02975)
+  of "ltlarr": Rune(0x02976)
+  of "gtrarr": Rune(0x02978)
+  of "subrarr": Rune(0x02979)
+  of "suplarr": Rune(0x0297B)
+  of "lfisht": Rune(0x0297C)
+  of "rfisht": Rune(0x0297D)
+  of "ufisht": Rune(0x0297E)
+  of "dfisht": Rune(0x0297F)
+  of "lopar": Rune(0x02985)
+  of "ropar": Rune(0x02986)
+  of "lbrke": Rune(0x0298B)
+  of "rbrke": Rune(0x0298C)
+  of "lbrkslu": Rune(0x0298D)
+  of "rbrksld": Rune(0x0298E)
+  of "lbrksld": Rune(0x0298F)
+  of "rbrkslu": Rune(0x02990)
+  of "langd": Rune(0x02991)
+  of "rangd": Rune(0x02992)
+  of "lparlt": Rune(0x02993)
+  of "rpargt": Rune(0x02994)
+  of "gtlPar": Rune(0x02995)
+  of "ltrPar": Rune(0x02996)
+  of "vzigzag": Rune(0x0299A)
+  of "vangrt": Rune(0x0299C)
+  of "angrtvbd": Rune(0x0299D)
+  of "ange": Rune(0x029A4)
+  of "range": Rune(0x029A5)
+  of "dwangle": Rune(0x029A6)
+  of "uwangle": Rune(0x029A7)
+  of "angmsdaa": Rune(0x029A8)
+  of "angmsdab": Rune(0x029A9)
+  of "angmsdac": Rune(0x029AA)
+  of "angmsdad": Rune(0x029AB)
+  of "angmsdae": Rune(0x029AC)
+  of "angmsdaf": Rune(0x029AD)
+  of "angmsdag": Rune(0x029AE)
+  of "angmsdah": Rune(0x029AF)
+  of "bemptyv": Rune(0x029B0)
+  of "demptyv": Rune(0x029B1)
+  of "cemptyv": Rune(0x029B2)
+  of "raemptyv": Rune(0x029B3)
+  of "laemptyv": Rune(0x029B4)
+  of "ohbar": Rune(0x029B5)
+  of "omid": Rune(0x029B6)
+  of "opar": Rune(0x029B7)
+  of "operp": Rune(0x029B9)
+  of "olcross": Rune(0x029BB)
+  of "odsold": Rune(0x029BC)
+  of "olcir": Rune(0x029BE)
+  of "ofcir": Rune(0x029BF)
+  of "olt": Rune(0x029C0)
+  of "ogt": Rune(0x029C1)
+  of "cirscir": Rune(0x029C2)
+  of "cirE": Rune(0x029C3)
+  of "solb": Rune(0x029C4)
+  of "bsolb": Rune(0x029C5)
+  of "boxbox": Rune(0x029C9)
+  of "trisb": Rune(0x029CD)
+  of "rtriltri": Rune(0x029CE)
+  of "LeftTriangleBar": Rune(0x029CF)
+  of "RightTriangleBar": Rune(0x029D0)
+  of "race": Rune(0x029DA)
+  of "iinfin": Rune(0x029DC)
+  of "infintie": Rune(0x029DD)
+  of "nvinfin": Rune(0x029DE)
+  of "eparsl": Rune(0x029E3)
+  of "smeparsl": Rune(0x029E4)
+  of "eqvparsl": Rune(0x029E5)
+  of "lozf", "blacklozenge": Rune(0x029EB)
+  of "RuleDelayed": Rune(0x029F4)
+  of "dsol": Rune(0x029F6)
+  of "xodot", "bigodot": Rune(0x02A00)
+  of "xoplus", "bigoplus": Rune(0x02A01)
+  of "xotime", "bigotimes": Rune(0x02A02)
+  of "xuplus", "biguplus": Rune(0x02A04)
+  of "xsqcup", "bigsqcup": Rune(0x02A06)
+  of "qint", "iiiint": Rune(0x02A0C)
+  of "fpartint": Rune(0x02A0D)
+  of "cirfnint": Rune(0x02A10)
+  of "awint": Rune(0x02A11)
+  of "rppolint": Rune(0x02A12)
+  of "scpolint": Rune(0x02A13)
+  of "npolint": Rune(0x02A14)
+  of "pointint": Rune(0x02A15)
+  of "quatint": Rune(0x02A16)
+  of "intlarhk": Rune(0x02A17)
+  of "pluscir": Rune(0x02A22)
+  of "plusacir": Rune(0x02A23)
+  of "simplus": Rune(0x02A24)
+  of "plusdu": Rune(0x02A25)
+  of "plussim": Rune(0x02A26)
+  of "plustwo": Rune(0x02A27)
+  of "mcomma": Rune(0x02A29)
+  of "minusdu": Rune(0x02A2A)
+  of "loplus": Rune(0x02A2D)
+  of "roplus": Rune(0x02A2E)
+  of "Cross": Rune(0x02A2F)
+  of "timesd": Rune(0x02A30)
+  of "timesbar": Rune(0x02A31)
+  of "smashp": Rune(0x02A33)
+  of "lotimes": Rune(0x02A34)
+  of "rotimes": Rune(0x02A35)
+  of "otimesas": Rune(0x02A36)
+  of "Otimes": Rune(0x02A37)
+  of "odiv": Rune(0x02A38)
+  of "triplus": Rune(0x02A39)
+  of "triminus": Rune(0x02A3A)
+  of "tritime": Rune(0x02A3B)
+  of "iprod", "intprod": Rune(0x02A3C)
+  of "amalg": Rune(0x02A3F)
+  of "capdot": Rune(0x02A40)
+  of "ncup": Rune(0x02A42)
+  of "ncap": Rune(0x02A43)
+  of "capand": Rune(0x02A44)
+  of "cupor": Rune(0x02A45)
+  of "cupcap": Rune(0x02A46)
+  of "capcup": Rune(0x02A47)
+  of "cupbrcap": Rune(0x02A48)
+  of "capbrcup": Rune(0x02A49)
+  of "cupcup": Rune(0x02A4A)
+  of "capcap": Rune(0x02A4B)
+  of "ccups": Rune(0x02A4C)
+  of "ccaps": Rune(0x02A4D)
+  of "ccupssm": Rune(0x02A50)
+  of "And": Rune(0x02A53)
+  of "Or": Rune(0x02A54)
+  of "andand": Rune(0x02A55)
+  of "oror": Rune(0x02A56)
+  of "orslope": Rune(0x02A57)
+  of "andslope": Rune(0x02A58)
+  of "andv": Rune(0x02A5A)
+  of "orv": Rune(0x02A5B)
+  of "andd": Rune(0x02A5C)
+  of "ord": Rune(0x02A5D)
+  of "wedbar": Rune(0x02A5F)
+  of "sdote": Rune(0x02A66)
+  of "simdot": Rune(0x02A6A)
+  of "congdot": Rune(0x02A6D)
+  of "easter": Rune(0x02A6E)
+  of "apacir": Rune(0x02A6F)
+  of "apE": Rune(0x02A70)
+  of "eplus": Rune(0x02A71)
+  of "pluse": Rune(0x02A72)
+  of "Esim": Rune(0x02A73)
+  of "Colone": Rune(0x02A74)
+  of "Equal": Rune(0x02A75)
+  of "eDDot", "ddotseq": Rune(0x02A77)
+  of "equivDD": Rune(0x02A78)
+  of "ltcir": Rune(0x02A79)
+  of "gtcir": Rune(0x02A7A)
+  of "ltquest": Rune(0x02A7B)
+  of "gtquest": Rune(0x02A7C)
+  of "les", "LessSlantEqual", "leqslant": Rune(0x02A7D)
+  of "ges", "GreaterSlantEqual", "geqslant": Rune(0x02A7E)
+  of "lesdot": Rune(0x02A7F)
+  of "gesdot": Rune(0x02A80)
+  of "lesdoto": Rune(0x02A81)
+  of "gesdoto": Rune(0x02A82)
+  of "lesdotor": Rune(0x02A83)
+  of "gesdotol": Rune(0x02A84)
+  of "lap", "lessapprox": Rune(0x02A85)
+  of "gap", "gtrapprox": Rune(0x02A86)
+  of "lne", "lneq": Rune(0x02A87)
+  of "gne", "gneq": Rune(0x02A88)
+  of "lnap", "lnapprox": Rune(0x02A89)
+  of "gnap", "gnapprox": Rune(0x02A8A)
+  of "lEg", "lesseqqgtr": Rune(0x02A8B)
+  of "gEl", "gtreqqless": Rune(0x02A8C)
+  of "lsime": Rune(0x02A8D)
+  of "gsime": Rune(0x02A8E)
+  of "lsimg": Rune(0x02A8F)
+  of "gsiml": Rune(0x02A90)
+  of "lgE": Rune(0x02A91)
+  of "glE": Rune(0x02A92)
+  of "lesges": Rune(0x02A93)
+  of "gesles": Rune(0x02A94)
+  of "els", "eqslantless": Rune(0x02A95)
+  of "egs", "eqslantgtr": Rune(0x02A96)
+  of "elsdot": Rune(0x02A97)
+  of "egsdot": Rune(0x02A98)
+  of "el": Rune(0x02A99)
+  of "eg": Rune(0x02A9A)
+  of "siml": Rune(0x02A9D)
+  of "simg": Rune(0x02A9E)
+  of "simlE": Rune(0x02A9F)
+  of "simgE": Rune(0x02AA0)
+  of "LessLess": Rune(0x02AA1)
+  of "GreaterGreater": Rune(0x02AA2)
+  of "glj": Rune(0x02AA4)
+  of "gla": Rune(0x02AA5)
+  of "ltcc": Rune(0x02AA6)
+  of "gtcc": Rune(0x02AA7)
+  of "lescc": Rune(0x02AA8)
+  of "gescc": Rune(0x02AA9)
+  of "smt": Rune(0x02AAA)
+  of "lat": Rune(0x02AAB)
+  of "smte": Rune(0x02AAC)
+  of "late": Rune(0x02AAD)
+  of "bumpE": Rune(0x02AAE)
+  of "pre", "preceq", "PrecedesEqual": Rune(0x02AAF)
+  of "sce", "succeq", "SucceedsEqual": Rune(0x02AB0)
+  of "prE": Rune(0x02AB3)
+  of "scE": Rune(0x02AB4)
+  of "prnE", "precneqq": Rune(0x02AB5)
+  of "scnE", "succneqq": Rune(0x02AB6)
+  of "prap", "precapprox": Rune(0x02AB7)
+  of "scap", "succapprox": Rune(0x02AB8)
+  of "prnap", "precnapprox": Rune(0x02AB9)
+  of "scnap", "succnapprox": Rune(0x02ABA)
+  of "Pr": Rune(0x02ABB)
+  of "Sc": Rune(0x02ABC)
+  of "subdot": Rune(0x02ABD)
+  of "supdot": Rune(0x02ABE)
+  of "subplus": Rune(0x02ABF)
+  of "supplus": Rune(0x02AC0)
+  of "submult": Rune(0x02AC1)
+  of "supmult": Rune(0x02AC2)
+  of "subedot": Rune(0x02AC3)
+  of "supedot": Rune(0x02AC4)
+  of "subE", "subseteqq": Rune(0x02AC5)
+  of "supE", "supseteqq": Rune(0x02AC6)
+  of "subsim": Rune(0x02AC7)
+  of "supsim": Rune(0x02AC8)
+  of "subnE", "subsetneqq": Rune(0x02ACB)
+  of "supnE", "supsetneqq": Rune(0x02ACC)
+  of "csub": Rune(0x02ACF)
+  of "csup": Rune(0x02AD0)
+  of "csube": Rune(0x02AD1)
+  of "csupe": Rune(0x02AD2)
+  of "subsup": Rune(0x02AD3)
+  of "supsub": Rune(0x02AD4)
+  of "subsub": Rune(0x02AD5)
+  of "supsup": Rune(0x02AD6)
+  of "suphsub": Rune(0x02AD7)
+  of "supdsub": Rune(0x02AD8)
+  of "forkv": Rune(0x02AD9)
+  of "topfork": Rune(0x02ADA)
+  of "mlcp": Rune(0x02ADB)
+  of "Dashv", "DoubleLeftTee": Rune(0x02AE4)
+  of "Vdashl": Rune(0x02AE6)
+  of "Barv": Rune(0x02AE7)
+  of "vBar": Rune(0x02AE8)
+  of "vBarv": Rune(0x02AE9)
+  of "Vbar": Rune(0x02AEB)
+  of "Not": Rune(0x02AEC)
+  of "bNot": Rune(0x02AED)
+  of "rnmid": Rune(0x02AEE)
+  of "cirmid": Rune(0x02AEF)
+  of "midcir": Rune(0x02AF0)
+  of "topcir": Rune(0x02AF1)
+  of "nhpar": Rune(0x02AF2)
+  of "parsim": Rune(0x02AF3)
+  of "parsl": Rune(0x02AFD)
+  of "fflig": Rune(0x0FB00)
+  of "filig": Rune(0x0FB01)
+  of "fllig": Rune(0x0FB02)
+  of "ffilig": Rune(0x0FB03)
+  of "ffllig": Rune(0x0FB04)
+  of "Ascr": Rune(0x1D49C)
+  of "Cscr": Rune(0x1D49E)
+  of "Dscr": Rune(0x1D49F)
+  of "Gscr": Rune(0x1D4A2)
+  of "Jscr": Rune(0x1D4A5)
+  of "Kscr": Rune(0x1D4A6)
+  of "Nscr": Rune(0x1D4A9)
+  of "Oscr": Rune(0x1D4AA)
+  of "Pscr": Rune(0x1D4AB)
+  of "Qscr": Rune(0x1D4AC)
+  of "Sscr": Rune(0x1D4AE)
+  of "Tscr": Rune(0x1D4AF)
+  of "Uscr": Rune(0x1D4B0)
+  of "Vscr": Rune(0x1D4B1)
+  of "Wscr": Rune(0x1D4B2)
+  of "Xscr": Rune(0x1D4B3)
+  of "Yscr": Rune(0x1D4B4)
+  of "Zscr": Rune(0x1D4B5)
+  of "ascr": Rune(0x1D4B6)
+  of "bscr": Rune(0x1D4B7)
+  of "cscr": Rune(0x1D4B8)
+  of "dscr": Rune(0x1D4B9)
+  of "fscr": Rune(0x1D4BB)
+  of "hscr": Rune(0x1D4BD)
+  of "iscr": Rune(0x1D4BE)
+  of "jscr": Rune(0x1D4BF)
+  of "kscr": Rune(0x1D4C0)
+  of "lscr": Rune(0x1D4C1)
+  of "mscr": Rune(0x1D4C2)
+  of "nscr": Rune(0x1D4C3)
+  of "pscr": Rune(0x1D4C5)
+  of "qscr": Rune(0x1D4C6)
+  of "rscr": Rune(0x1D4C7)
+  of "sscr": Rune(0x1D4C8)
+  of "tscr": Rune(0x1D4C9)
+  of "uscr": Rune(0x1D4CA)
+  of "vscr": Rune(0x1D4CB)
+  of "wscr": Rune(0x1D4CC)
+  of "xscr": Rune(0x1D4CD)
+  of "yscr": Rune(0x1D4CE)
+  of "zscr": Rune(0x1D4CF)
+  of "Afr": Rune(0x1D504)
+  of "Bfr": Rune(0x1D505)
+  of "Dfr": Rune(0x1D507)
+  of "Efr": Rune(0x1D508)
+  of "Ffr": Rune(0x1D509)
+  of "Gfr": Rune(0x1D50A)
+  of "Jfr": Rune(0x1D50D)
+  of "Kfr": Rune(0x1D50E)
+  of "Lfr": Rune(0x1D50F)
+  of "Mfr": Rune(0x1D510)
+  of "Nfr": Rune(0x1D511)
+  of "Ofr": Rune(0x1D512)
+  of "Pfr": Rune(0x1D513)
+  of "Qfr": Rune(0x1D514)
+  of "Sfr": Rune(0x1D516)
+  of "Tfr": Rune(0x1D517)
+  of "Ufr": Rune(0x1D518)
+  of "Vfr": Rune(0x1D519)
+  of "Wfr": Rune(0x1D51A)
+  of "Xfr": Rune(0x1D51B)
+  of "Yfr": Rune(0x1D51C)
+  of "afr": Rune(0x1D51E)
+  of "bfr": Rune(0x1D51F)
+  of "cfr": Rune(0x1D520)
+  of "dfr": Rune(0x1D521)
+  of "efr": Rune(0x1D522)
+  of "ffr": Rune(0x1D523)
+  of "gfr": Rune(0x1D524)
+  of "hfr": Rune(0x1D525)
+  of "ifr": Rune(0x1D526)
+  of "jfr": Rune(0x1D527)
+  of "kfr": Rune(0x1D528)
+  of "lfr": Rune(0x1D529)
+  of "mfr": Rune(0x1D52A)
+  of "nfr": Rune(0x1D52B)
+  of "ofr": Rune(0x1D52C)
+  of "pfr": Rune(0x1D52D)
+  of "qfr": Rune(0x1D52E)
+  of "rfr": Rune(0x1D52F)
+  of "sfr": Rune(0x1D530)
+  of "tfr": Rune(0x1D531)
+  of "ufr": Rune(0x1D532)
+  of "vfr": Rune(0x1D533)
+  of "wfr": Rune(0x1D534)
+  of "xfr": Rune(0x1D535)
+  of "yfr": Rune(0x1D536)
+  of "zfr": Rune(0x1D537)
+  of "Aopf": Rune(0x1D538)
+  of "Bopf": Rune(0x1D539)
+  of "Dopf": Rune(0x1D53B)
+  of "Eopf": Rune(0x1D53C)
+  of "Fopf": Rune(0x1D53D)
+  of "Gopf": Rune(0x1D53E)
+  of "Iopf": Rune(0x1D540)
+  of "Jopf": Rune(0x1D541)
+  of "Kopf": Rune(0x1D542)
+  of "Lopf": Rune(0x1D543)
+  of "Mopf": Rune(0x1D544)
+  of "Oopf": Rune(0x1D546)
+  of "Sopf": Rune(0x1D54A)
+  of "Topf": Rune(0x1D54B)
+  of "Uopf": Rune(0x1D54C)
+  of "Vopf": Rune(0x1D54D)
+  of "Wopf": Rune(0x1D54E)
+  of "Xopf": Rune(0x1D54F)
+  of "Yopf": Rune(0x1D550)
+  of "aopf": Rune(0x1D552)
+  of "bopf": Rune(0x1D553)
+  of "copf": Rune(0x1D554)
+  of "dopf": Rune(0x1D555)
+  of "eopf": Rune(0x1D556)
+  of "fopf": Rune(0x1D557)
+  of "gopf": Rune(0x1D558)
+  of "hopf": Rune(0x1D559)
+  of "iopf": Rune(0x1D55A)
+  of "jopf": Rune(0x1D55B)
+  of "kopf": Rune(0x1D55C)
+  of "lopf": Rune(0x1D55D)
+  of "mopf": Rune(0x1D55E)
+  of "nopf": Rune(0x1D55F)
+  of "oopf": Rune(0x1D560)
+  of "popf": Rune(0x1D561)
+  of "qopf": Rune(0x1D562)
+  of "ropf": Rune(0x1D563)
+  of "sopf": Rune(0x1D564)
+  of "topf": Rune(0x1D565)
+  of "uopf": Rune(0x1D566)
+  of "vopf": Rune(0x1D567)
+  of "wopf": Rune(0x1D568)
+  of "xopf": Rune(0x1D569)
+  of "yopf": Rune(0x1D56A)
+  of "zopf": Rune(0x1D56B)
+  else: Rune(0)
+
+proc entityToUtf8*(entity: string): string =
+  ## Converts an HTML entity name like `&Uuml;` or values like `&#220;`
+  ## or `&#x000DC;` to its UTF-8 equivalent.
   ## "" is returned if the entity name is unknown. The HTML parser
   ## already converts entities to UTF-8.
-  for name, val in items(entities):
-    if name == entity: return toUTF8(TRune(val))
-  result = ""
+  runnableExamples:
+    const sigma = "Σ"
+    doAssert entityToUtf8("") == ""
+    doAssert entityToUtf8("a") == ""
+    doAssert entityToUtf8("gt") == ">"
+    doAssert entityToUtf8("Uuml") == "Ü"
+    doAssert entityToUtf8("quest") == "?"
+    doAssert entityToUtf8("#63") == "?"
+    doAssert entityToUtf8("Sigma") == sigma
+    doAssert entityToUtf8("#931") == sigma
+    doAssert entityToUtf8("#0931") == sigma
+    doAssert entityToUtf8("#x3A3") == sigma
+    doAssert entityToUtf8("#x03A3") == sigma
+    doAssert entityToUtf8("#x3a3") == sigma
+    doAssert entityToUtf8("#X3a3") == sigma
+  let rune = entityToRune(entity)
+  if rune.ord <= 0: result = ""
+  else: result = toUTF8(rune)
 
-proc addNode(father, son: PXmlNode) = 
+proc addNode(father, son: XmlNode) =
   if son != nil: add(father, son)
 
-proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode
+proc parse(x: var XmlParser, errors: var seq[string]): XmlNode {.gcsafe.}
 
-proc expected(x: var TXmlParser, n: PXmlNode): string =
+proc expected(x: var XmlParser, n: XmlNode): string =
   result = errorMsg(x, "</" & n.tag & "> expected")
 
-proc untilElementEnd(x: var TXmlParser, result: PXmlNode, 
+template elemName(x: untyped): untyped = rawData(x)
+
+template adderr(x: untyped) =
+  errors.add(x)
+
+proc untilElementEnd(x: var XmlParser, result: XmlNode,
                      errors: var seq[string]) =
-  if result.htmlTag in singleTags:
-    if x.kind != xmlElementEnd or cmpIgnoreCase(x.elementName, result.tag) != 0:
+  # we parsed e.g. `<br>` and don't really expect a `</br>`:
+  if result.htmlTag in SingleTags:
+    if x.kind != xmlElementEnd or cmpIgnoreCase(x.elemName, result.tag) != 0:
       return
   while true:
     case x.kind
     of xmlElementStart, xmlElementOpen:
       case result.htmlTag
-      of tagLi, tagP, tagDt, tagDd, tagInput, tagOption:
-        if htmlTag(x.elementName) notin InlineTags:
-          # some tags are common to have no ``</end>``, like ``<li>``:
-          errors.add(expected(x, result))
+      of tagP, tagInput, tagOption:
+        # some tags are common to have no `</end>`, like `<li>` but
+        # allow `<p>` in `<dd>`, `<dt>` and `<li>` in next case
+        if htmlTag(x.elemName) in {tagLi, tagP, tagDt, tagDd, tagInput,
+                                   tagOption}:
+          adderr(expected(x, result))
           break
-      of tagTr, tagTd, tagTh, tagTfoot, tagThead:
-        if htmlTag(x.elementName) in {tagTr, tagTd, tagTh, tagTfoot, tagThead}:
-          errors.add(expected(x, result))
+      of tagDd, tagDt, tagLi:
+        if htmlTag(x.elemName) in {tagLi, tagDt, tagDd, tagInput,
+                                   tagOption}:
+          adderr(expected(x, result))
+          break
+      of tagTd, tagTh:
+        if htmlTag(x.elemName) in {tagTr, tagTd, tagTh, tagTfoot, tagThead}:
+          adderr(expected(x, result))
+          break
+      of tagTr:
+        if htmlTag(x.elemName) == tagTr:
+          adderr(expected(x, result))
           break
       of tagOptgroup:
-        if htmlTag(x.elementName) in {tagOption, tagOptgroup}:
-          errors.add(expected(x, result))
+        if htmlTag(x.elemName) in {tagOption, tagOptgroup}:
+          adderr(expected(x, result))
           break
-      else: nil
+      else: discard
       result.addNode(parse(x, errors))
-    of xmlElementEnd: 
-      if cmpIgnoreCase(x.elementName, result.tag) == 0: 
-        next(x)
-      else:
-        errors.add(expected(x, result))
-        # do not skip it here!
+    of xmlElementEnd:
+      if cmpIgnoreCase(x.elemName, result.tag) != 0:
+        #echo "5; expected: ", result.htmltag, " ", x.elemName
+        adderr(expected(x, result))
+        # this seems to do better match error corrections in browsers:
+        while x.kind in {xmlElementEnd, xmlWhitespace}:
+          if x.kind == xmlElementEnd and cmpIgnoreCase(x.elemName,
+              result.tag) == 0:
+            break
+          next(x)
+      next(x)
       break
     of xmlEof:
-      errors.add(expected(x, result))
+      adderr(expected(x, result))
       break
     else:
       result.addNode(parse(x, errors))
 
-proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode =
+proc parse(x: var XmlParser, errors: var seq[string]): XmlNode =
   case x.kind
-  of xmlComment: 
-    result = newComment(x.charData)
+  of xmlComment:
+    result = newComment(x.rawData)
     next(x)
   of xmlCharData, xmlWhitespace:
-    result = newText(x.charData)
+    result = newText(x.rawData)
     next(x)
   of xmlPI, xmlSpecial:
     # we just ignore processing instructions for now
     next(x)
   of xmlError:
-    errors.add(errorMsg(x))
+    adderr(errorMsg(x))
     next(x)
   of xmlElementStart:
-    result = newElement(x.elementName.toLower)
+    result = newElement(toLowerAscii(x.elemName))
     next(x)
     untilElementEnd(x, result, errors)
   of xmlElementEnd:
-    errors.add(errorMsg(x, "unexpected ending tag: " & x.elementName))
-  of xmlElementOpen: 
-    result = newElement(x.elementName.toLower)
+    adderr(errorMsg(x, "unexpected ending tag: " & x.elemName))
+  of xmlElementOpen:
+    result = newElement(toLowerAscii(x.elemName))
     next(x)
-    result.attr = newStringTable()
-    while true: 
+    result.attrs = newStringTable()
+    while true:
       case x.kind
       of xmlAttribute:
-        result.attr[x.attrKey] = x.attrValue
+        result.attrs[x.rawData] = x.rawData2
         next(x)
       of xmlElementClose:
         next(x)
         break
       of xmlError:
-        errors.add(errorMsg(x))
+        adderr(errorMsg(x))
         next(x)
         break
       else:
-        errors.add(errorMsg(x, "'>' expected"))
+        adderr(errorMsg(x, "'>' expected"))
         next(x)
         break
     untilElementEnd(x, result, errors)
   of xmlAttribute, xmlElementClose:
-    errors.add(errorMsg(x, "<some_tag> expected"))
+    adderr(errorMsg(x, "<some_tag> expected"))
     next(x)
-  of xmlCData: 
-    result = newCData(x.charData)
+  of xmlCData:
+    result = newCData(x.rawData)
     next(x)
   of xmlEntity:
-    var u = entityToUtf8(x.entityName)
+    var u = entityToUtf8(x.rawData)
     if u.len != 0: result = newText(u)
     next(x)
-  of xmlEof: nil
+  of xmlEof: discard
 
-proc parseHtml*(s: PStream, filename: string, 
-                errors: var seq[string]): PXmlNode = 
-  ## parses the XML from stream `s` and returns a ``PXmlNode``. Every
-  ## occured parsing error is added to the `errors` sequence.
-  var x: TXmlParser
-  open(x, s, filename, {reportComments})
+proc parseHtml*(s: Stream, filename: string,
+                errors: var seq[string]): XmlNode =
+  ## Parses the XML from stream `s` and returns a `XmlNode`. Every
+  ## occurred parsing error is added to the `errors` sequence.
+  var x: XmlParser
+  open(x, s, filename, {reportComments, reportWhitespace, allowUnquotedAttribs,
+    allowEmptyAttribs})
   next(x)
   # skip the DOCTYPE:
   if x.kind == xmlSpecial: next(x)
-  result = parse(x, errors)
+
+  result = newElement("document")
+  result.addNode(parse(x, errors))
+  #if x.kind != xmlEof:
+  #  adderr(errorMsg(x, "EOF expected"))
   while x.kind != xmlEof:
-    errors.add(errorMsg(x, "EOF expected"))
+    var oldPos = x.bufpos # little hack to see if we made any progress
     result.addNode(parse(x, errors))
+    if x.bufpos == oldPos:
+      # force progress!
+      next(x)
   close(x)
+  if result.len == 1:
+    result = result[0]
 
-proc parseHtml*(s: PStream): PXmlNode = 
-  ## parses the XTML from stream `s` and returns a ``PXmlNode``. All parsing
+proc parseHtml*(s: Stream): XmlNode =
+  ## Parses the HTML from stream `s` and returns a `XmlNode`. All parsing
   ## errors are ignored.
   var errors: seq[string] = @[]
   result = parseHtml(s, "unknown_html_doc", errors)
 
-proc loadHtml*(path: string, errors: var seq[string]): PXmlNode = 
-  ## Loads and parses HTML from file specified by ``path``, and returns 
-  ## a ``PXmlNode``.  Every occured parsing error is added to
+proc parseHtml*(html: string): XmlNode =
+  ## Parses the HTML from string `html` and returns a `XmlNode`. All parsing
+  ## errors are ignored.
+  parseHtml(newStringStream(html))
+
+proc loadHtml*(path: string, errors: var seq[string]): XmlNode =
+  ## Loads and parses HTML from file specified by `path`, and returns
+  ## a `XmlNode`. Every occurred parsing error is added to
   ## the `errors` sequence.
   var s = newFileStream(path, fmRead)
-  if s == nil: raise newException(EIO, "Unable to read file: " & path)
+  if s == nil: raise newException(IOError, "Unable to read file: " & path)
   result = parseHtml(s, path, errors)
 
-proc loadHtml*(path: string): PXmlNode = 
-  ## Loads and parses HTML from file specified by ``path``, and returns 
-  ## a ``PXmlNode``. All parsing errors are ignored.
-  var errors: seq[string] = @[]  
+proc loadHtml*(path: string): XmlNode =
+  ## Loads and parses HTML from file specified by `path`, and returns
+  ## a `XmlNode`. All parsing errors are ignored.
+  var errors: seq[string] = @[]
   result = loadHtml(path, errors)
 
-when true:
-  nil
-else:
-  proc checkHtmlAux(n: PXmlNode, errors: var seq[string]) =
-    nil
-  
-  proc checkHtmlStructure*(n: PXmlNode, errors: var seq[string]) =
-    ## checks the HTML structure after parsing for other errors like 
-    ## a ``<h1>`` element within a ``<p>`` element.
-    if n == nil or n.htmlTag != tagHtml: 
-      errors.add("<html> tag expected")
-    checkHtmlAux(n, errors)
-  
-when isMainModule:
-  import os
+when not defined(testing) and isMainModule:
+  import std/os
 
-  var errors: seq[string] = @[]  
+  var errors: seq[string] = @[]
   var x = loadHtml(paramStr(1), errors)
   for e in items(errors): echo e
-  
-  var f: TFile
+
+  var f: File
   if open(f, "test.txt", fmWrite):
     f.write($x)
     f.close()
   else:
     quit("cannot write test.txt")
-  
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index c02a7a6e7..08ea99627 100755..100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -1,338 +1,1360 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Dominik Picheta, Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Nim Contributors
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module implements a simple HTTP client that can be used to retrieve
-## webpages/other data.
+## webpages and other data.
+##
+## .. warning:: Validate untrusted inputs: URI parsers and getters are not detecting malicious URIs.
 ##
 ## Retrieving a website
 ## ====================
-## 
+##
 ## This example uses HTTP GET to retrieve
-## ``http://google.com``
-## 
-## .. code-block:: nimrod
-##   echo(getContent("http://google.com"))
-## 
+## `http://google.com`:
+##
+##   ```Nim
+##   import std/httpclient
+##   var client = newHttpClient()
+##   try:
+##     echo client.getContent("http://google.com")
+##   finally:
+##     client.close()
+##   ```
+##
+## The same action can also be performed asynchronously, simply use the
+## `AsyncHttpClient`:
+##
+##   ```Nim
+##   import std/[asyncdispatch, httpclient]
+##
+##   proc asyncProc(): Future[string] {.async.} =
+##     var client = newAsyncHttpClient()
+##     try:
+##       return await client.getContent("http://google.com")
+##     finally:
+##       client.close()
+##
+##   echo waitFor asyncProc()
+##   ```
+##
+## The functionality implemented by `HttpClient` and `AsyncHttpClient`
+## is the same, so you can use whichever one suits you best in the examples
+## shown here.
+##
+## **Note:** You need to run asynchronous examples in an async proc
+## otherwise you will get an `Undeclared identifier: 'await'` error.
+##
+## **Note:** An asynchronous client instance can only deal with one
+## request at a time. To send multiple requests in parallel, use
+## multiple client instances.
+##
 ## Using HTTP POST
 ## ===============
-## 
-## This example demonstrates the usage of the W3 HTML Validator, it 
-## uses ``multipart/form-data`` as the ``Content-Type`` to send the HTML to
-## the server. 
-## 
-## .. code-block:: nimrod
-##   var headers: string = "Content-Type: multipart/form-data; boundary=xyz\c\L"
-##   var body: string = "--xyz\c\L"
-##   # soap 1.2 output
-##   body.add("Content-Disposition: form-data; name=\"output\"\c\L")
-##   body.add("\c\Lsoap12\c\L")
-##    
-##   # html
-##   body.add("--xyz\c\L")
-##   body.add("Content-Disposition: form-data; name=\"uploaded_file\";" &
-##            " filename=\"test.html\"\c\L")
-##   body.add("Content-Type: text/html\c\L")
-##   body.add("\c\L<html><head></head><body><p>test</p></body></html>\c\L")
-##   body.add("--xyz--")
-##    
-##   echo(postContent("http://validator.w3.org/check", headers, body))
-
-import sockets, strutils, parseurl, parseutils, strtabs
+##
+## This example demonstrates the usage of the W3 HTML Validator, it
+## uses `multipart/form-data` as the `Content-Type` to send the HTML to be
+## validated to the server.
+##
+##   ```Nim
+##   var client = newHttpClient()
+##   var data = newMultipartData()
+##   data["output"] = "soap12"
+##   data["uploaded_file"] = ("test.html", "text/html",
+##     "<html><head></head><body><p>test</p></body></html>")
+##   try:
+##     echo client.postContent("http://validator.w3.org/check", multipart=data)
+##   finally:
+##     client.close()
+##   ```
+##
+## To stream files from disk when performing the request, use `addFiles`.
+##
+## **Note:** This will allocate a new `Mimetypes` database every time you call
+## it, you can pass your own via the `mimeDb` parameter to avoid this.
+##
+##   ```Nim
+##   let mimes = newMimetypes()
+##   var client = newHttpClient()
+##   var data = newMultipartData()
+##   data.addFiles({"uploaded_file": "test.html"}, mimeDb = mimes)
+##   try:
+##     echo client.postContent("http://validator.w3.org/check", multipart=data)
+##   finally:
+##     client.close()
+##   ```
+##
+## You can also make post requests with custom headers.
+## This example sets `Content-Type` to `application/json`
+## and uses a json object for the body
+##
+##   ```Nim
+##   import std/[httpclient, json]
+##
+##   let client = newHttpClient()
+##   client.headers = newHttpHeaders({ "Content-Type": "application/json" })
+##   let body = %*{
+##       "data": "some text"
+##   }
+##   try:
+##     let response = client.request("http://some.api", httpMethod = HttpPost, body = $body)
+##     echo response.status
+##   finally:
+##     client.close()
+##   ```
+##
+## Progress reporting
+## ==================
+##
+## You may specify a callback procedure to be called during an HTTP request.
+## This callback will be executed every second with information about the
+## progress of the HTTP request.
+##
+##   ```Nim
+##   import std/[asyncdispatch, httpclient]
+##
+##   proc onProgressChanged(total, progress, speed: BiggestInt) {.async.} =
+##     echo("Downloaded ", progress, " of ", total)
+##     echo("Current rate: ", speed div 1000, "kb/s")
+##
+##   proc asyncProc() {.async.} =
+##     var client = newAsyncHttpClient()
+##     client.onProgressChanged = onProgressChanged
+##     try:
+##       discard await client.getContent("http://speedtest-ams2.digitalocean.com/100mb.test")
+##     finally:
+##       client.close()
+##
+##   waitFor asyncProc()
+##   ```
+##
+## If you would like to remove the callback simply set it to `nil`.
+##
+##   ```Nim
+##   client.onProgressChanged = nil
+##   ```
+##
+## .. warning:: The `total` reported by httpclient may be 0 in some cases.
+##
+##
+## SSL/TLS support
+## ===============
+## This requires the OpenSSL library. Fortunately it's widely used and installed
+## on many operating systems. httpclient will use SSL automatically if you give
+## any of the functions a url with the `https` schema, for example:
+## `https://github.com/`.
+##
+## You will also have to compile with `ssl` defined like so:
+## `nim c -d:ssl ...`.
+##
+## Certificate validation is performed by default.
+##
+## A set of directories and files from the `ssl_certs <ssl_certs.html>`_
+## module are scanned to locate CA certificates.
+##
+## Example of setting SSL verification parameters in a new client:
+##
+##   ```Nim
+##   import httpclient
+##   var client = newHttpClient(sslContext=newContext(verifyMode=CVerifyPeer))
+##   ```
+##
+## There are three options for verify mode:
+##
+## * ``CVerifyNone``: certificates are not verified;
+## * ``CVerifyPeer``: certificates are verified;
+## * ``CVerifyPeerUseEnvVars``: certificates are verified and the optional
+##   environment variables SSL_CERT_FILE and SSL_CERT_DIR are also used to
+##   locate certificates
+##
+## See `newContext <net.html#newContext.string,string,string,string>`_ to tweak or disable certificate validation.
+##
+## Timeouts
+## ========
+##
+## Currently only the synchronous functions support a timeout.
+## The timeout is
+## measured in milliseconds, once it is set any call on a socket which may
+## block will be susceptible to this timeout.
+##
+## It may be surprising but the
+## function as a whole can take longer than the specified timeout, only
+## individual internal calls on the socket are affected. In practice this means
+## that as long as the server is sending data an exception will not be raised,
+## if however data does not reach the client within the specified timeout a
+## `TimeoutError` exception will be raised.
+##
+## Here is how to set a timeout when creating an `HttpClient` instance:
+##
+##   ```Nim
+##   import std/httpclient
+##
+##   let client = newHttpClient(timeout = 42)
+##   ```
+##
+## Proxy
+## =====
+##
+## A proxy can be specified as a param to any of the procedures defined in
+## this module. To do this, use the `newProxy` constructor. Unfortunately,
+## only basic authentication is supported at the moment.
+##
+## Some examples on how to configure a Proxy for `HttpClient`:
+##
+##   ```Nim
+##   import std/httpclient
+##
+##   let myProxy = newProxy("http://myproxy.network")
+##   let client = newHttpClient(proxy = myProxy)
+##   ```
+##
+## Use proxies with basic authentication:
+##
+##   ```Nim
+##   import std/httpclient
+##
+##   let myProxy = newProxy("http://myproxy.network", auth="user:password")
+##   let client = newHttpClient(proxy = myProxy)
+##   ```
+##
+## Get Proxy URL from environment variables:
+##
+##   ```Nim
+##   import std/httpclient
+##
+##   var url = ""
+##   try:
+##     if existsEnv("http_proxy"):
+##       url = getEnv("http_proxy")
+##     elif existsEnv("https_proxy"):
+##       url = getEnv("https_proxy")
+##   except ValueError:
+##     echo "Unable to parse proxy from environment variables."
+##
+##   let myProxy = newProxy(url = url)
+##   let client = newHttpClient(proxy = myProxy)
+##   ```
+##
+## Redirects
+## =========
+##
+## The maximum redirects can be set with the `maxRedirects` of `int` type,
+## it specifies the maximum amount of redirects to follow,
+## it defaults to `5`, you can set it to `0` to disable redirects.
+##
+## Here you can see an example about how to set the `maxRedirects` of `HttpClient`:
+##
+##   ```Nim
+##   import std/httpclient
+##
+##   let client = newHttpClient(maxRedirects = 0)
+##   ```
+##
+
+import std/private/since
+
+import std/[
+  net, strutils, uri, parseutils, base64, os, mimetypes,
+  math, random, httpcore, times, tables, streams, monotimes,
+  asyncnet, asyncdispatch, asyncfile, nativesockets,
+]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+export httpcore except parseHeader # TODO: The `except` doesn't work
 
 type
-  TResponse* = tuple[
-    version: string, 
-    status: string, 
-    headers: PStringTable,
-    body: string]
+  Response* = ref object
+    version*: string
+    status*: string
+    headers*: HttpHeaders
+    body: string
+    bodyStream*: Stream
+
+  AsyncResponse* = ref object
+    version*: string
+    status*: string
+    headers*: HttpHeaders
+    body: string
+    bodyStream*: FutureStream[string]
+
+proc code*(response: Response | AsyncResponse): HttpCode
+           {.raises: [ValueError, OverflowDefect].} =
+  ## Retrieves the specified response's `HttpCode`.
+  ##
+  ## Raises a `ValueError` if the response's `status` does not have a
+  ## corresponding `HttpCode`.
+  return response.status[0 .. 2].parseInt.HttpCode
+
+proc contentType*(response: Response | AsyncResponse): string {.inline.} =
+  ## Retrieves the specified response's content type.
+  ##
+  ## This is effectively the value of the "Content-Type" header.
+  response.headers.getOrDefault("content-type")
 
-  EInvalidProtocol* = object of EBase ## exception that is raised when server
-                                      ## does not conform to the implemented
-                                      ## protocol
+proc contentLength*(response: Response | AsyncResponse): int =
+  ## Retrieves the specified response's content length.
+  ##
+  ## This is effectively the value of the "Content-Length" header.
+  ##
+  ## A `ValueError` exception will be raised if the value is not an integer.
+  ## If the Content-Length header is not set in the response, ContentLength is set to the value -1.
+  var contentLengthHeader = response.headers.getOrDefault("Content-Length", HttpHeaderValues(@["-1"]))
+  result = contentLengthHeader.parseInt()
 
-  EHttpRequestErr* = object of EBase ## Thrown in the ``getContent`` proc 
-                                     ## and ``postContent`` proc,
-                                     ## when the server returns an error
+proc lastModified*(response: Response | AsyncResponse): DateTime =
+  ## Retrieves the specified response's last modified time.
+  ##
+  ## This is effectively the value of the "Last-Modified" header.
+  ##
+  ## Raises a `ValueError` if the parsing fails or the value is not a correctly
+  ## formatted time.
+  var lastModifiedHeader = response.headers.getOrDefault("last-modified")
+  result = parse(lastModifiedHeader, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", utc())
+
+proc body*(response: Response): string =
+  ## Retrieves the specified response's body.
+  ##
+  ## The response's body stream is read synchronously.
+  if response.body.len == 0:
+    response.body = response.bodyStream.readAll()
+  return response.body
+
+proc body*(response: AsyncResponse): Future[string] {.async.} =
+  ## Reads the response's body and caches it. The read is performed only
+  ## once.
+  if response.body.len == 0:
+    response.body = await readAll(response.bodyStream)
+  return response.body
+
+type
+  Proxy* = ref object
+    url*: Uri
+    auth*: string
+
+  MultipartEntry = object
+    name, content: string
+    case isFile: bool
+    of true:
+      filename, contentType: string
+      fileSize: int64
+      isStream: bool
+    else: discard
+
+  MultipartEntries* = openArray[tuple[name, content: string]]
+  MultipartData* = ref object
+    content: seq[MultipartEntry]
+
+  ProtocolError* = object of IOError ## exception that is raised when server
+                                     ## does not conform to the implemented
+                                     ## protocol
+
+  HttpRequestError* = object of IOError ## Thrown in the `getContent` proc
+                                        ## and `postContent` proc,
+                                        ## when the server returns an error
+
+const defUserAgent* = "Nim-httpclient/" & NimVersion
 
 proc httpError(msg: string) =
-  var e: ref EInvalidProtocol
+  var e: ref ProtocolError
   new(e)
   e.msg = msg
   raise e
-  
+
 proc fileError(msg: string) =
-  var e: ref EIO
+  var e: ref IOError
   new(e)
   e.msg = msg
   raise e
 
-proc charAt(d: var string, i: var int, s: TSocket): char {.inline.} = 
-  result = d[i]
-  while result == '\0':
-    d = s.recv()
-    i = 0
-    result = d[i]
-
-proc parseChunks(d: var string, start: int, s: TSocket): string =
-  # get chunks:
-  var i = start
-  result = ""
+when not defined(ssl):
+  type SslContext = ref object
+var defaultSslContext {.threadvar.}: SslContext
+
+proc getDefaultSSL(): SslContext =
+  result = defaultSslContext
+  when defined(ssl):
+    if result == nil:
+      defaultSslContext = newContext(verifyMode = CVerifyPeer)
+      result = defaultSslContext
+      doAssert result != nil, "failure to initialize the SSL context"
+
+proc newProxy*(url: string; auth = ""): Proxy =
+  ## Constructs a new `TProxy` object.
+  result = Proxy(url: parseUri(url), auth: auth)
+
+proc newProxy*(url: Uri; auth = ""): Proxy =
+  ## Constructs a new `TProxy` object.
+  result = Proxy(url: url, auth: auth)
+
+proc newMultipartData*: MultipartData {.inline.} =
+  ## Constructs a new `MultipartData` object.
+  MultipartData()
+
+proc `$`*(data: MultipartData): string {.since: (1, 1).} =
+  ## convert MultipartData to string so it's human readable when echo
+  ## see https://github.com/nim-lang/Nim/issues/11863
+  const sep = "-".repeat(30)
+  for pos, entry in data.content:
+    result.add(sep & center($pos, 3) & sep)
+    result.add("\nname=\"" & entry.name & "\"")
+    if entry.isFile:
+      result.add("; filename=\"" & entry.filename & "\"\n")
+      result.add("Content-Type: " & entry.contentType)
+    result.add("\n\n" & entry.content & "\n")
+
+proc add*(p: MultipartData, name, content: string, filename: string = "",
+          contentType: string = "", useStream = true) =
+  ## Add a value to the multipart data.
+  ##
+  ## When `useStream` is `false`, the file will be read into memory.
+  ##
+  ## Raises a `ValueError` exception if
+  ## `name`, `filename` or `contentType` contain newline characters.
+  if {'\c', '\L'} in name:
+    raise newException(ValueError, "name contains a newline character")
+  if {'\c', '\L'} in filename:
+    raise newException(ValueError, "filename contains a newline character")
+  if {'\c', '\L'} in contentType:
+    raise newException(ValueError, "contentType contains a newline character")
+
+  var entry = MultipartEntry(
+    name: name,
+    content: content,
+    isFile: filename.len > 0
+  )
+
+  if entry.isFile:
+    entry.isStream = useStream
+    entry.filename = filename
+    entry.contentType = contentType
+
+  p.content.add(entry)
+
+proc add*(p: MultipartData, xs: MultipartEntries): MultipartData
+         {.discardable.} =
+  ## Add a list of multipart entries to the multipart data `p`. All values are
+  ## added without a filename and without a content type.
+  ##
+  ##   ```Nim
+  ##   data.add({"action": "login", "format": "json"})
+  ##   ```
+  for name, content in xs.items:
+    p.add(name, content)
+  result = p
+
+proc newMultipartData*(xs: MultipartEntries): MultipartData =
+  ## Create a new multipart data object and fill it with the entries `xs`
+  ## directly.
+  ##
+  ##   ```Nim
+  ##   var data = newMultipartData({"action": "login", "format": "json"})
+  ##   ```
+  result = MultipartData()
+  for entry in xs:
+    result.add(entry.name, entry.content)
+
+proc addFiles*(p: MultipartData, xs: openArray[tuple[name, file: string]],
+               mimeDb = newMimetypes(), useStream = true):
+               MultipartData {.discardable.} =
+  ## Add files to a multipart data object. The files will be streamed from disk
+  ## when the request is being made. When `stream` is `false`, the files are
+  ## instead read into memory, but beware this is very memory ineffecient even
+  ## for small files. The MIME types will automatically be determined.
+  ## Raises an `IOError` if the file cannot be opened or reading fails. To
+  ## manually specify file content, filename and MIME type, use `[]=` instead.
+  ##
+  ##   ```Nim
+  ##   data.addFiles({"uploaded_file": "public/test.html"})
+  ##   ```
+  for name, file in xs.items:
+    var contentType: string
+    let (_, fName, ext) = splitFile(file)
+    if ext.len > 0:
+      contentType = mimeDb.getMimetype(ext[1..ext.high], "")
+    let content = if useStream: file else: readFile(file)
+    p.add(name, content, fName & ext, contentType, useStream = useStream)
+  result = p
+
+proc `[]=`*(p: MultipartData, name, content: string) {.inline.} =
+  ## Add a multipart entry to the multipart data `p`. The value is added
+  ## without a filename and without a content type.
+  ##
+  ##   ```Nim
+  ##   data["username"] = "NimUser"
+  ##   ```
+  p.add(name, content)
+
+proc `[]=`*(p: MultipartData, name: string,
+            file: tuple[name, contentType, content: string]) {.inline.} =
+  ## Add a file to the multipart data `p`, specifying filename, contentType
+  ## and content manually.
+  ##
+  ##   ```Nim
+  ##   data["uploaded_file"] = ("test.html", "text/html",
+  ##     "<html><head></head><body><p>test</p></body></html>")
+  ##   ```
+  p.add(name, file.content, file.name, file.contentType, useStream = false)
+
+proc getBoundary(p: MultipartData): string =
+  if p == nil or p.content.len == 0: return
+  while true:
+    result = $rand(int.high)
+    for i, entry in p.content:
+      if result in entry.content: break
+      elif i == p.content.high: return
+
+proc sendFile(socket: Socket | AsyncSocket,
+              entry: MultipartEntry) {.multisync.} =
+  const chunkSize = 2^18
+  let file =
+    when socket is AsyncSocket: openAsync(entry.content)
+    else: newFileStream(entry.content, fmRead)
+
+  var buffer: string
+  while true:
+    buffer =
+      when socket is AsyncSocket: (await read(file, chunkSize))
+      else: readStr(file, chunkSize)
+    if buffer.len == 0: break
+    await socket.send(buffer)
+  file.close()
+
+proc getNewLocation(lastURL: Uri, headers: HttpHeaders): Uri =
+  let newLocation = headers.getOrDefault"Location"
+  if newLocation == "": httpError("location header expected")
+  # Relative URLs. (Not part of the spec, but soon will be.)
+  let parsedLocation = parseUri(newLocation)
+  if parsedLocation.hostname == "" and parsedLocation.path != "":
+    result = lastURL
+    result.path = parsedLocation.path
+    result.query = parsedLocation.query
+    result.anchor = parsedLocation.anchor
+  else:
+    result = parsedLocation
+
+proc generateHeaders(requestUrl: Uri, httpMethod: HttpMethod, headers: HttpHeaders,
+                     proxy: Proxy): string =
+  # GET
+  result = $httpMethod
+  result.add ' '
+
+  if proxy.isNil or requestUrl.scheme == "https":
+    # /path?query
+    if not requestUrl.path.startsWith("/"): result.add '/'
+    result.add(requestUrl.path)
+    if requestUrl.query.len > 0:
+      result.add("?" & requestUrl.query)
+  else:
+    # Remove the 'http://' from the URL for CONNECT requests for TLS connections.
+    var modifiedUrl = requestUrl
+    if requestUrl.scheme == "https": modifiedUrl.scheme = ""
+    result.add($modifiedUrl)
+
+  # HTTP/1.1\c\l
+  result.add(" HTTP/1.1" & httpNewLine)
+
+  # Host header.
+  if not headers.hasKey("Host"):
+    if requestUrl.port == "":
+      add(result, "Host: " & requestUrl.hostname & httpNewLine)
+    else:
+      add(result, "Host: " & requestUrl.hostname & ":" & requestUrl.port & httpNewLine)
+
+  # Connection header.
+  if not headers.hasKey("Connection"):
+    add(result, "Connection: Keep-Alive" & httpNewLine)
+
+  # Proxy auth header.
+  if not proxy.isNil and proxy.auth != "":
+    let auth = base64.encode(proxy.auth)
+    add(result, "Proxy-Authorization: Basic " & auth & httpNewLine)
+
+  for key, val in headers:
+    add(result, key & ": " & val & httpNewLine)
+
+  add(result, httpNewLine)
+
+type
+  ProgressChangedProc*[ReturnType] =
+    proc (total, progress, speed: BiggestInt):
+      ReturnType {.closure, gcsafe.}
+
+  HttpClientBase*[SocketType] = ref object
+    socket: SocketType
+    connected: bool
+    currentURL: Uri       ## Where we are currently connected.
+    headers*: HttpHeaders ## Headers to send in requests.
+    maxRedirects: Natural ## Maximum redirects, set to `0` to disable.
+    userAgent: string
+    timeout*: int         ## Only used for blocking HttpClient for now.
+    proxy: Proxy
+    ## `nil` or the callback to call when request progress changes.
+    when SocketType is Socket:
+      onProgressChanged*: ProgressChangedProc[void]
+    else:
+      onProgressChanged*: ProgressChangedProc[Future[void]]
+    when defined(ssl):
+      sslContext: net.SslContext
+    contentTotal: BiggestInt
+    contentProgress: BiggestInt
+    oneSecondProgress: BiggestInt
+    lastProgressReport: MonoTime
+    when SocketType is AsyncSocket:
+      bodyStream: FutureStream[string]
+      parseBodyFut: Future[void]
+    else:
+      bodyStream: Stream
+    getBody: bool         ## When `false`, the body is never read in requestAux.
+
+type
+  HttpClient* = HttpClientBase[Socket]
+
+proc newHttpClient*(userAgent = defUserAgent, maxRedirects = 5,
+                    sslContext = getDefaultSSL(), proxy: Proxy = nil,
+                    timeout = -1, headers = newHttpHeaders()): HttpClient =
+  ## Creates a new HttpClient instance.
+  ##
+  ## `userAgent` specifies the user agent that will be used when making
+  ## requests.
+  ##
+  ## `maxRedirects` specifies the maximum amount of redirects to follow,
+  ## default is 5.
+  ##
+  ## `sslContext` specifies the SSL context to use for HTTPS requests.
+  ## See `SSL/TLS support <#sslslashtls-support>`_
+  ##
+  ## `proxy` specifies an HTTP proxy to use for this HTTP client's
+  ## connections.
+  ##
+  ## `timeout` specifies the number of milliseconds to allow before a
+  ## `TimeoutError` is raised.
+  ##
+  ## `headers` specifies the HTTP Headers.
+  runnableExamples:
+    import std/strutils
+
+    let exampleHtml = newHttpClient().getContent("http://example.com")
+    assert "Example Domain" in exampleHtml
+    assert "Pizza" notin exampleHtml
+
+  new result
+  result.headers = headers
+  result.userAgent = userAgent
+  result.maxRedirects = maxRedirects
+  result.proxy = proxy
+  result.timeout = timeout
+  result.onProgressChanged = nil
+  result.bodyStream = newStringStream()
+  result.getBody = true
+  when defined(ssl):
+    result.sslContext = sslContext
+
+type
+  AsyncHttpClient* = HttpClientBase[AsyncSocket]
+
+proc newAsyncHttpClient*(userAgent = defUserAgent, maxRedirects = 5,
+                         sslContext = getDefaultSSL(), proxy: Proxy = nil,
+                         headers = newHttpHeaders()): AsyncHttpClient =
+  ## Creates a new AsyncHttpClient instance.
+  ##
+  ## `userAgent` specifies the user agent that will be used when making
+  ## requests.
+  ##
+  ## `maxRedirects` specifies the maximum amount of redirects to follow,
+  ## default is 5.
+  ##
+  ## `sslContext` specifies the SSL context to use for HTTPS requests.
+  ##
+  ## `proxy` specifies an HTTP proxy to use for this HTTP client's
+  ## connections.
+  ##
+  ## `headers` specifies the HTTP Headers.
+  runnableExamples:
+    import std/[asyncdispatch, strutils]
+
+    proc asyncProc(): Future[string] {.async.} =
+      let client = newAsyncHttpClient()
+      result = await client.getContent("http://example.com")
+
+    let exampleHtml = waitFor asyncProc()
+    assert "Example Domain" in exampleHtml
+    assert "Pizza" notin exampleHtml
+  
+  new result
+  result.headers = headers
+  result.userAgent = userAgent
+  result.maxRedirects = maxRedirects
+  result.proxy = proxy
+  result.timeout = -1 # TODO
+  result.onProgressChanged = nil
+  result.bodyStream = newFutureStream[string]("newAsyncHttpClient")
+  result.getBody = true
+  when defined(ssl):
+    result.sslContext = sslContext
+
+proc close*(client: HttpClient | AsyncHttpClient) =
+  ## Closes any connections held by the HTTP client.
+  if client.connected:
+    client.socket.close()
+    client.connected = false
+
+proc getSocket*(client: HttpClient): Socket {.inline.} =
+  ## Get network socket, useful if you want to find out more details about the connection.
+  ##
+  ## This example shows info about local and remote endpoints:
+  ##
+  ##   ```Nim
+  ##   if client.connected:
+  ##     echo client.getSocket.getLocalAddr
+  ##     echo client.getSocket.getPeerAddr
+  ##   ```
+  return client.socket
+
+proc getSocket*(client: AsyncHttpClient): AsyncSocket {.inline.} =
+  return client.socket
+
+proc reportProgress(client: HttpClient | AsyncHttpClient,
+                    progress: BiggestInt) {.multisync.} =
+  client.contentProgress += progress
+  client.oneSecondProgress += progress
+  if (getMonoTime() - client.lastProgressReport).inSeconds >= 1:
+    if not client.onProgressChanged.isNil:
+      await client.onProgressChanged(client.contentTotal,
+                                     client.contentProgress,
+                                     client.oneSecondProgress)
+      client.oneSecondProgress = 0
+      client.lastProgressReport = getMonoTime()
+
+proc recvFull(client: HttpClient | AsyncHttpClient, size: int, timeout: int,
+              keep: bool): Future[int] {.multisync.} =
+  ## Ensures that all the data requested is read and returned.
+  var readLen = 0
+  while true:
+    if size == readLen: break
+
+    let remainingSize = size - readLen
+    let sizeToRecv = min(remainingSize, net.BufferSize)
+
+    when client.socket is Socket:
+      let data = client.socket.recv(sizeToRecv, timeout)
+    else:
+      let data = await client.socket.recv(sizeToRecv)
+    if data == "":
+      client.close()
+      break # We've been disconnected.
+
+    readLen.inc(data.len)
+    if keep:
+      await client.bodyStream.write(data)
+
+    await reportProgress(client, data.len)
+
+  return readLen
+
+proc parseChunks(client: HttpClient | AsyncHttpClient): Future[void]
+                 {.multisync.} =
   while true:
     var chunkSize = 0
-    var digitFound = false
-    while true: 
-      case d[i]
-      of '0'..'9': 
-        digitFound = true
-        chunkSize = chunkSize shl 4 or (ord(d[i]) - ord('0'))
-      of 'a'..'f': 
-        digitFound = true
-        chunkSize = chunkSize shl 4 or (ord(d[i]) - ord('a') + 10)
-      of 'A'..'F': 
-        digitFound = true
-        chunkSize = chunkSize shl 4 or (ord(d[i]) - ord('A') + 10)
-      of '\0': 
-        d = s.recv()
-        i = -1
-      else: break
+    var chunkSizeStr = await client.socket.recvLine()
+    var i = 0
+    if chunkSizeStr == "":
+      httpError("Server terminated connection prematurely")
+    while i < chunkSizeStr.len:
+      case chunkSizeStr[i]
+      of '0'..'9':
+        chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('0'))
+      of 'a'..'f':
+        chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('a') + 10)
+      of 'A'..'F':
+        chunkSize = chunkSize shl 4 or (ord(chunkSizeStr[i]) - ord('A') + 10)
+      of ';':
+        # http://tools.ietf.org/html/rfc2616#section-3.6.1
+        # We don't care about chunk-extensions.
+        break
+      else:
+        httpError("Invalid chunk size: " & chunkSizeStr)
       inc(i)
-    if not digitFound: httpError("Chunksize expected")
-    if chunkSize <= 0: break
-    while charAt(d, i, s) notin {'\C', '\L', '\0'}: inc(i)
-    if charAt(d, i, s) == '\C': inc(i)
-    if charAt(d, i, s) == '\L': inc(i)
-    else: httpError("CR-LF after chunksize expected")
-    
-    var x = copy(d, i, i+chunkSize-1)
-    var size = x.len
-    result.add(x)
-    inc(i, size)
-    if size < chunkSize:
-      # read in the rest:
-      var missing = chunkSize - size
-      var L = result.len
-      setLen(result, L + missing)    
-      while missing > 0:
-        var bytesRead = s.recv(addr(result[L]), missing)
-        inc(L, bytesRead)
-        dec(missing, bytesRead)
-      # next chunk:
-      d = s.recv()
-      i = 0
-    # skip trailing CR-LF:
-    while charAt(d, i, s) in {'\C', '\L'}: inc(i)
-  
-proc parseBody(d: var string, start: int, s: TSocket,
-               headers: PStringTable): string =
-  if headers["Transfer-Encoding"] == "chunked":
-    result = parseChunks(d, start, s)
+    if chunkSize <= 0:
+      discard await recvFull(client, 2, client.timeout, false) # Skip \c\L
+      break
+    var bytesRead = await recvFull(client, chunkSize, client.timeout, true)
+    if bytesRead != chunkSize:
+      httpError("Server terminated connection prematurely")
+
+    bytesRead = await recvFull(client, 2, client.timeout, false) # Skip \c\L
+    if bytesRead != 2:
+      httpError("Server terminated connection prematurely")
+
+    # Trailer headers will only be sent if the request specifies that we want
+    # them: http://tools.ietf.org/html/rfc2616#section-3.6.1
+
+proc parseBody(client: HttpClient | AsyncHttpClient, headers: HttpHeaders,
+               httpVersion: string): Future[void] {.multisync.} =
+  # Reset progress from previous requests.
+  client.contentTotal = 0
+  client.contentProgress = 0
+  client.oneSecondProgress = 0
+  client.lastProgressReport = MonoTime()
+
+  when client is AsyncHttpClient:
+    assert(not client.bodyStream.finished)
+
+  if headers.getOrDefault"Transfer-Encoding" == "chunked":
+    await parseChunks(client)
   else:
-    result = copy(d, start)
     # -REGION- Content-Length
     # (http://tools.ietf.org/html/rfc2616#section-4.4) NR.3
-    var contentLengthHeader = headers["Content-Length"]
+    var contentLengthHeader = headers.getOrDefault"Content-Length"
     if contentLengthHeader != "":
-      var length = contentLengthHeader.parseint()
-      while result.len() < length: result.add(s.recv())
+      var length = contentLengthHeader.parseInt()
+      client.contentTotal = length
+      if length > 0:
+        let recvLen = await client.recvFull(length, client.timeout, true)
+        if recvLen == 0:
+          client.close()
+          httpError("Got disconnected while trying to read body.")
+        if recvLen != length:
+          httpError("Received length doesn't match expected length. Wanted " &
+                    $length & " got: " & $recvLen)
     else:
       # (http://tools.ietf.org/html/rfc2616#section-4.4) NR.4 TODO
-      
+
       # -REGION- Connection: Close
       # (http://tools.ietf.org/html/rfc2616#section-4.4) NR.5
-      if headers["Connection"] == "close":
-        while True:
-          var moreData = recv(s)
-          if moreData.len == 0: break
-          result.add(moreData)
-
-proc parseResponse(s: TSocket): TResponse =
-  var d = s.recv()
-  var i = 0
-
-  # Parse the version
-  # Parses the first line of the headers
-  # ``HTTP/1.1`` 200 OK
-  var L = skipIgnoreCase(d, "HTTP/1.1", i)
-  if L > 0:
-    result.version = "1.1"
-    inc(i, L)
+      let implicitConnectionClose =
+        httpVersion == "1.0" or
+        # This doesn't match the HTTP spec, but it fixes issues for non-conforming servers.
+        (httpVersion == "1.1" and headers.getOrDefault"Connection" == "")
+      if headers.getOrDefault"Connection" == "close" or implicitConnectionClose:
+        while true:
+          let recvLen = await client.recvFull(4000, client.timeout, true)
+          if recvLen != 4000:
+            client.close()
+            break
+
+  when client is AsyncHttpClient:
+    client.bodyStream.complete()
   else:
-    L = skipIgnoreCase(d, "HTTP/1.0", i)
-    if L > 0:
-      result.version = "1.0"
-      inc(i, L)
-    else: 
-      httpError("invalid HTTP header")
-  L = skipWhiteSpace(d, i)
-  if L <= 0: httpError("invalid HTTP header")
-  inc(i, L)
-  
-  result.status = ""
-  while d[i] notin {'\C', '\L', '\0'}:
-    result.status.add(d[i])
-    inc(i)
-  if d[i] == '\C': inc(i)
-  if d[i] == '\L': inc(i)
-  else: httpError("invalid HTTP header, CR-LF expected")
-
-  # Parse the headers
-  # Everything after the first line leading up to the body
-  # htype: hvalue
-  result.headers = newStringTable(modeCaseInsensitive)
+    client.bodyStream.setPosition(0)
+
+  # If the server will close our connection, then no matter the method of
+  # reading the body, we need to close our socket.
+  if headers.getOrDefault"Connection" == "close":
+    client.close()
+
+proc parseResponse(client: HttpClient | AsyncHttpClient,
+                   getBody: bool): Future[Response | AsyncResponse]
+                   {.multisync.} =
+  new result
+  var parsedStatus = false
+  var linei = 0
+  var fullyRead = false
+  var lastHeaderName = ""
+  var line = ""
+  result.headers = newHttpHeaders()
   while true:
-    var key = ""
-    while d[i] != ':':
-      if d[i] == '\0': httpError("invalid HTTP header, ':' expected")
-      key.add(d[i])
-      inc(i)
-    inc(i) # skip ':'
-    if d[i] == ' ': inc(i) # skip if the character is a space
-    var val = ""
-    while d[i] notin {'\C', '\L', '\0'}:
-      val.add(d[i])
-      inc(i)
-    
-    result.headers[key] = val
-    
-    if d[i] == '\C': inc(i)
-    if d[i] == '\L': inc(i)
-    else: httpError("invalid HTTP header, CR-LF expected")
-    
-    if d[i] == '\C': inc(i)
-    if d[i] == '\L':
-      inc(i)
+    linei = 0
+    when client is HttpClient:
+      line = await client.socket.recvLine(client.timeout)
+    else:
+      line = await client.socket.recvLine()
+    if line == "":
+      # We've been disconnected.
+      client.close()
       break
-    
-  result.body = parseBody(d, i, s, result.headers) 
+    if line == httpNewLine:
+      fullyRead = true
+      break
+    if not parsedStatus:
+      # Parse HTTP version info and status code.
+      var le = skipIgnoreCase(line, "HTTP/", linei)
+      if le <= 0:
+        httpError("invalid http version, `" & line & "`")
+      inc(linei, le)
+      le = skipIgnoreCase(line, "1.1", linei)
+      if le > 0: result.version = "1.1"
+      else:
+        le = skipIgnoreCase(line, "1.0", linei)
+        if le <= 0: httpError("unsupported http version")
+        result.version = "1.0"
+      inc(linei, le)
+      # Status code
+      linei.inc skipWhitespace(line, linei)
+      result.status = line[linei .. ^1]
+      parsedStatus = true
+    else:
+      # Parse headers
+      # There's at least one char because empty lines are handled above (with client.close)
+      if line[0] in {' ', '\t'}:
+        # Check if it's a multiline header value, if so, append to the header we're currently parsing
+        # This works because a line with a header must start with the header name without any leading space
+        # See https://datatracker.ietf.org/doc/html/rfc7230, section 3.2 and 3.2.4
+        # Multiline headers are deprecated in the spec, but it's better to parse them than crash
+        if lastHeaderName == "":
+          # Some extra unparsable lines in the HTTP output - we ignore them
+          discard
+        else:
+          result.headers.table[result.headers.toCaseInsensitive(lastHeaderName)][^1].add "\n" & line
+      else:
+        var name = ""
+        var le = parseUntil(line, name, ':', linei)
+        if le <= 0: httpError("Invalid headers - received empty header name")
+        if line.len == le: httpError("Invalid headers - no colon after header name")
+        inc(linei, le) # Skip the parsed header name
+        inc(linei) # Skip :
+        # If we want to be HTTP spec compliant later, error on linei == line.len (for empty header value)
+        lastHeaderName = name # Remember the header name for the possible multi-line header
+        result.headers.add(name, line[linei .. ^1].strip())
+        if result.headers.len > headerLimit:
+          httpError("too many headers")
 
-type
-  THttpMethod* = enum ## the requested HttpMethod
-    httpHEAD,         ## Asks for the response identical to the one that would
-                      ## correspond to a GET request, but without the response
-                      ## body.
-    httpGET,          ## Retrieves the specified resource.
-    httpPOST,         ## Submits data to be processed to the identified 
-                      ## resource. The data is included in the body of the 
-                      ## request.
-    httpPUT,          ## Uploads a representation of the specified resource.
-    httpDELETE,       ## Deletes the specified resource.
-    httpTRACE,        ## Echoes back the received request, so that a client 
-                      ## can see what intermediate servers are adding or
-                      ## changing in the request.
-    httpOPTIONS,      ## Returns the HTTP methods that the server supports 
-                      ## for specified address.
-    httpCONNECT       ## Converts the request connection to a transparent 
-                      ## TCP/IP tunnel, usually used for proxies.
-
-proc request*(url: string, httpMethod = httpGET, extraHeaders = "", 
-              body = ""): TResponse =
-  ## | Requests ``url`` with the specified ``httpMethod``.
-  ## | Extra headers can be specified and must be seperated by ``\c\L``
-  var r = parseUrl(url)
-  
-  var headers = copy($httpMethod, len("http"))
-  if r.path != "":
-    headers.add(" " & r.path & r.query)
-  headers.add(" / HTTP/1.1\c\L")
-  
-  add(headers, "Host: " & r.hostname & "\c\L")
-  add(headers, extraHeaders)
-  add(headers, "\c\L")
-
-  var s = socket()
-  s.connect(r.hostname, TPort(80))
-  s.send(headers)
-  if body != "":
-    s.send(body)
-  
-  result = parseResponse(s)
-  s.close()
-  
-proc redirection(status: string): bool =
-  const redirectionNRs = ["301", "302", "303", "307"]
-  for i in items(redirectionNRs):
-    if status.startsWith(i):
-      return True
-  
-proc get*(url: string, maxRedirects = 5): TResponse =
-  ## | GET's the ``url`` and returns a ``TResponse`` object
-  ## | This proc also handles redirection
-  result = request(url)
-  for i in 1..maxRedirects:
-    if result.status.redirection():
-      var locationHeader = result.headers["Location"]
-      if locationHeader == "": httpError("location header expected")
-      result = request(locationHeader)
-      
-proc getContent*(url: string): string =
-  ## | GET's the body and returns it as a string.
-  ## | Raises exceptions for the status codes ``4xx`` and ``5xx``
-  var r = get(url)
-  if r.status[0] in {'4','5'}:
-    raise newException(EHTTPRequestErr, r.status)
+  if not fullyRead:
+    httpError("Connection was closed before full request has been made")
+
+  when client is HttpClient:
+    result.bodyStream = newStringStream()
   else:
-    return r.body
-  
-proc post*(url: string, extraHeaders = "", body = "", 
-           maxRedirects = 5): TResponse =
-  ## | POST's ``body`` to the ``url`` and returns a ``TResponse`` object.
-  ## | This proc adds the necessary Content-Length header.
-  ## | This proc also handles redirection.
-  var xh = extraHeaders & "Content-Length: " & $len(body) & "\c\L"
-  result = request(url, httpPOST, xh, body)
-  for i in 1..maxRedirects:
-    if result.status.redirection():
-      var locationHeader = result.headers["Location"]
-      if locationHeader == "": httpError("location header expected")
-      var meth = if result.status != "307": httpGet else: httpPost
-      result = request(locationHeader, meth, xh, body)
-  
-proc postContent*(url: string, extraHeaders = "", body = ""): string =
-  ## | POST's ``body`` to ``url`` and returns the response's body as a string
-  ## | Raises exceptions for the status codes ``4xx`` and ``5xx``
-  var r = post(url, extraHeaders, body)
-  if r.status[0] in {'4','5'}:
-    raise newException(EHTTPRequestErr, r.status)
+    result.bodyStream = newFutureStream[string]("parseResponse")
+
+  if getBody and result.code != Http204:
+    client.bodyStream = result.bodyStream
+    when client is HttpClient:
+      parseBody(client, result.headers, result.version)
+    else:
+      assert(client.parseBodyFut.isNil or client.parseBodyFut.finished)
+      # do not wait here for the body request to complete
+      client.parseBodyFut = parseBody(client, result.headers, result.version)
+      client.parseBodyFut.addCallback do():
+        if client.parseBodyFut.failed:
+          client.bodyStream.fail(client.parseBodyFut.error)
   else:
-    return r.body
-  
-proc downloadFile*(url: string, outputFilename: string) =
-  ## Downloads ``url`` and saves it to ``outputFilename``
-  var f: TFile
-  if open(f, outputFilename, fmWrite):
-    f.write(getContent(url))
-    f.close()
+    when client is AsyncHttpClient:
+      result.bodyStream.complete()
+
+proc newConnection(client: HttpClient | AsyncHttpClient,
+                   url: Uri) {.multisync.} =
+  if client.currentURL.hostname != url.hostname or
+      client.currentURL.scheme != url.scheme or
+      client.currentURL.port != url.port or
+      (not client.connected):
+    # Connect to proxy if specified
+    let connectionUrl =
+      if client.proxy.isNil: url else: client.proxy.url
+
+    let isSsl = connectionUrl.scheme.toLowerAscii() == "https"
+
+    if isSsl and not defined(ssl):
+      raise newException(HttpRequestError,
+        "SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
+
+    if client.connected:
+      client.close()
+      client.connected = false
+
+    # TODO: I should be able to write 'net.Port' here...
+    let port =
+      if connectionUrl.port == "":
+        if isSsl:
+          nativesockets.Port(443)
+        else:
+          nativesockets.Port(80)
+      else: nativesockets.Port(connectionUrl.port.parseInt)
+
+    when client is HttpClient:
+      client.socket = await net.dial(connectionUrl.hostname, port)
+    elif client is AsyncHttpClient:
+      client.socket = await asyncnet.dial(connectionUrl.hostname, port)
+    else: {.fatal: "Unsupported client type".}
+
+    when defined(ssl):
+      if isSsl:
+        try:
+          client.sslContext.wrapConnectedSocket(
+            client.socket, handshakeAsClient, connectionUrl.hostname)
+        except:
+          client.socket.close()
+          raise getCurrentException()
+
+    # If need to CONNECT through proxy
+    if url.scheme == "https" and not client.proxy.isNil:
+      when defined(ssl):
+        # Pass only host:port for CONNECT
+        var connectUrl = initUri()
+        connectUrl.hostname = url.hostname
+        connectUrl.port = if url.port != "": url.port else: "443"
+
+        let proxyHeaderString = generateHeaders(connectUrl, HttpConnect,
+            newHttpHeaders(), client.proxy)
+        await client.socket.send(proxyHeaderString)
+        let proxyResp = await parseResponse(client, false)
+
+        if not proxyResp.status.startsWith("200"):
+          raise newException(HttpRequestError,
+                            "The proxy server rejected a CONNECT request, " &
+                            "so a secure connection could not be established.")
+        client.sslContext.wrapConnectedSocket(
+          client.socket, handshakeAsClient, url.hostname)
+      else:
+        raise newException(HttpRequestError,
+        "SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
+
+    # May be connected through proxy but remember actual URL being accessed
+    client.currentURL = url
+    client.connected = true
+
+proc readFileSizes(client: HttpClient | AsyncHttpClient,
+                   multipart: MultipartData) {.multisync.} =
+  for entry in multipart.content.mitems():
+    if not entry.isFile: continue
+    if not entry.isStream:
+      entry.fileSize = entry.content.len
+      continue
+
+    # TODO: look into making getFileSize work with async
+    let fileSize = getFileSize(entry.content)
+    entry.fileSize = fileSize
+
+proc format(entry: MultipartEntry, boundary: string): string =
+  result = "--" & boundary & httpNewLine
+  result.add("Content-Disposition: form-data; name=\"" & entry.name & "\"")
+  if entry.isFile:
+    result.add("; filename=\"" & entry.filename & "\"" & httpNewLine)
+    result.add("Content-Type: " & entry.contentType & httpNewLine)
   else:
-    fileError("Unable to open file")
+    result.add(httpNewLine & httpNewLine & entry.content)
+
+proc format(client: HttpClient | AsyncHttpClient,
+            multipart: MultipartData): Future[seq[string]] {.multisync.} =
+  let bound = getBoundary(multipart)
+  client.headers["Content-Type"] = "multipart/form-data; boundary=" & bound
+
+  await client.readFileSizes(multipart)
+
+  var length: int64
+  for entry in multipart.content:
+    result.add(format(entry, bound) & httpNewLine)
+    if entry.isFile:
+      length += entry.fileSize + httpNewLine.len
+
+  result.add "--" & bound & "--" & httpNewLine
+
+  for s in result: length += s.len
+  client.headers["Content-Length"] = $length
+
+proc override(fallback, override: HttpHeaders): HttpHeaders =
+  # Right-biased map union for `HttpHeaders`
+
+  result = newHttpHeaders()
+  # Copy by value
+  result.table[] = fallback.table[]
+
+  if override.isNil:
+    # Return the copy of fallback so it does not get modified
+    return result
+
+  for k, vs in override.table:
+    result[k] = vs
+
+proc requestAux(client: HttpClient | AsyncHttpClient, url: Uri,
+                httpMethod: HttpMethod, body = "", headers: HttpHeaders = nil,
+                multipart: MultipartData = nil): Future[Response | AsyncResponse]
+                {.multisync.} =
+  # Helper that actually makes the request. Does not handle redirects.
+  if url.scheme == "":
+    raise newException(ValueError, "No uri scheme supplied.")
+
+  when client is AsyncHttpClient:
+    if not client.parseBodyFut.isNil:
+      # let the current operation finish before making another request
+      await client.parseBodyFut
+      client.parseBodyFut = nil
+
+  await newConnection(client, url)
+
+  var newHeaders: HttpHeaders
+
+  var data: seq[string]
+  if multipart != nil and multipart.content.len > 0:
+    # `format` modifies `client.headers`, see 
+    # https://github.com/nim-lang/Nim/pull/18208#discussion_r647036979
+    data = await client.format(multipart)
+    newHeaders = client.headers.override(headers)
+  else:
+    newHeaders = client.headers.override(headers)
+    # Only change headers if they have not been specified already
+    if not newHeaders.hasKey("Content-Length"):
+      if body.len != 0:
+        newHeaders["Content-Length"] = $body.len
+      elif httpMethod notin {HttpGet, HttpHead}:
+        newHeaders["Content-Length"] = "0"
+
+  if not newHeaders.hasKey("user-agent") and client.userAgent.len > 0:
+    newHeaders["User-Agent"] = client.userAgent
+
+  let headerString = generateHeaders(url, httpMethod, newHeaders,
+                                     client.proxy)
+  await client.socket.send(headerString)
 
+  if data.len > 0:
+    var buffer: string
+    for i, entry in multipart.content:
+      buffer.add data[i]
+      if not entry.isFile: continue
+      if buffer.len > 0:
+        await client.socket.send(buffer)
+        buffer.setLen(0)
+      if entry.isStream:
+        await client.socket.sendFile(entry)
+      else:
+        await client.socket.send(entry.content)
+      buffer.add httpNewLine
+    # send the rest and the last boundary
+    await client.socket.send(buffer & data[^1])
+  elif body.len > 0:
+    await client.socket.send(body)
 
-when isMainModule:
-  #downloadFile("http://force7.de/nimrod/index.html", "nimrodindex.html")
-  #downloadFile("http://www.httpwatch.com/", "ChunkTest.html")
-  #downloadFile("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com",
-  # "validator.html")
+  let getBody = httpMethod notin {HttpHead, HttpConnect} and
+                client.getBody
+  result = await parseResponse(client, getBody)
 
-  #var r = get("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com&
-  #  charset=%28detect+automatically%29&doctype=Inline&group=0")
+proc request*(client: HttpClient | AsyncHttpClient, url: Uri | string,
+              httpMethod: HttpMethod | string = HttpGet, body = "",
+              headers: HttpHeaders = nil,
+              multipart: MultipartData = nil): Future[Response | AsyncResponse]
+              {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a request
+  ## using the custom method string specified by `httpMethod`.
+  ##
+  ## Connection will be kept alive. Further requests on the same `client` to
+  ## the same hostname will not require a new connection to be made. The
+  ## connection can be closed by using the `close` procedure.
+  ##
+  ## This procedure will follow redirects up to a maximum number of redirects
+  ## specified in `client.maxRedirects`.
+  ##
+  ## You need to make sure that the `url` doesn't contain any newline
+  ## characters. Failing to do so will raise `AssertionDefect`.
+  ##
+  ## `headers` are HTTP headers that override the `client.headers` for
+  ## this specific request only and will not be persisted.
+  ##
+  ## **Deprecated since v1.5**: use HttpMethod enum instead; string parameter httpMethod is deprecated
+  when url is string:
+    doAssert(not url.contains({'\c', '\L'}), "url shouldn't contain any newline characters")
+    let url = parseUri(url)
+
+  when httpMethod is string:
+    {.warning:
+       "Deprecated since v1.5; use HttpMethod enum instead; string parameter httpMethod is deprecated".}
+    let httpMethod = case httpMethod
+      of "HEAD":
+        HttpHead
+      of "GET":
+        HttpGet
+      of "POST":
+        HttpPost
+      of "PUT":
+        HttpPut
+      of "DELETE":
+        HttpDelete
+      of "TRACE":
+        HttpTrace
+      of "OPTIONS":
+        HttpOptions
+      of "CONNECT":
+        HttpConnect
+      of "PATCH":
+        HttpPatch
+      else:
+        raise newException(ValueError, "Invalid HTTP method name: " & httpMethod)
+
+  result = await client.requestAux(url, httpMethod, body, headers, multipart)
+
+  var lastURL = url
+  for i in 1..client.maxRedirects:
+    let statusCode = result.code
+
+    if statusCode notin {Http301, Http302, Http303, Http307, Http308}:
+      break
+
+    let redirectTo = getNewLocation(lastURL, result.headers)
+    var redirectMethod: HttpMethod
+    var redirectBody: string
+    # For more informations about the redirect methods see:
+    # https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
+    case statusCode
+    of Http301, Http302, Http303:
+      # The method is changed to GET unless it is GET or HEAD (RFC2616)
+      if httpMethod notin {HttpGet, HttpHead}:
+        redirectMethod = HttpGet
+      else:
+        redirectMethod = httpMethod
+      # The body is stripped away
+      redirectBody = ""
+      # Delete any header value associated with the body
+      if not headers.isNil():
+        headers.del("Content-Length")
+        headers.del("Content-Type")
+        headers.del("Transfer-Encoding")
+    of Http307, Http308:
+      # The method and the body are unchanged
+      redirectMethod = httpMethod
+      redirectBody = body
+    else:
+      # Unreachable
+      doAssert(false)
+
+    # Check if the redirection is to the same domain or a sub-domain (foo.com
+    # -> sub.foo.com)
+    if redirectTo.hostname != lastURL.hostname and
+      not redirectTo.hostname.endsWith("." & lastURL.hostname):
+      # Perform some cleanup of the header values
+      if headers != nil:
+        # Delete the Host header
+        headers.del("Host")
+        # Do not send any sensitive info to a unknown host
+        headers.del("Authorization")
+
+    result = await client.requestAux(redirectTo, redirectMethod, redirectBody,
+                                     headers, multipart)
+    lastURL = redirectTo
+
+proc responseContent(resp: Response | AsyncResponse): Future[string] {.multisync.} =
+  ## Returns the content of a response as a string.
+  ##
+  ## A `HttpRequestError` will be raised if the server responds with a
+  ## client error (status code 4xx) or a server error (status code 5xx).
+  if resp.code.is4xx or resp.code.is5xx:
+    raise newException(HttpRequestError, resp.status.move)
+  else:
+    return await resp.bodyStream.readAll()
+
+proc head*(client: HttpClient | AsyncHttpClient,
+          url: Uri | string): Future[Response | AsyncResponse] {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a HEAD request.
+  ##
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpHead)
+
+proc get*(client: HttpClient | AsyncHttpClient,
+          url: Uri | string): Future[Response | AsyncResponse] {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a GET request.
+  ##
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpGet)
+
+proc getContent*(client: HttpClient | AsyncHttpClient,
+                 url: Uri | string): Future[string] {.multisync.} =
+  ## Connects to the hostname specified by the URL and returns the content of a GET request.
+  let resp = await get(client, url)
+  return await responseContent(resp)
+
+proc delete*(client: HttpClient | AsyncHttpClient,
+             url: Uri | string): Future[Response | AsyncResponse] {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a DELETE request.
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpDelete)
+
+proc deleteContent*(client: HttpClient | AsyncHttpClient,
+                    url: Uri | string): Future[string] {.multisync.} =
+  ## Connects to the hostname specified by the URL and returns the content of a DELETE request.
+  let resp = await delete(client, url)
+  return await responseContent(resp)
+
+proc post*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+           multipart: MultipartData = nil): Future[Response | AsyncResponse]
+           {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a POST request.
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpPost, body, multipart=multipart)
+
+proc postContent*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+                  multipart: MultipartData = nil): Future[string]
+                  {.multisync.} =
+  ## Connects to the hostname specified by the URL and returns the content of a POST request.
+  let resp = await post(client, url, body, multipart)
+  return await responseContent(resp)
+
+proc put*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+          multipart: MultipartData = nil): Future[Response | AsyncResponse]
+          {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a PUT request.
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpPut, body, multipart=multipart)
+
+proc putContent*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+                 multipart: MultipartData = nil): Future[string] {.multisync.} =
+  ## Connects to the hostname specified by the URL andreturns the content of a PUT request.
+  let resp = await put(client, url, body, multipart)
+  return await responseContent(resp)
+
+proc patch*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+            multipart: MultipartData = nil): Future[Response | AsyncResponse]
+            {.multisync.} =
+  ## Connects to the hostname specified by the URL and performs a PATCH request.
+  ## This procedure uses httpClient values such as `client.maxRedirects`.
+  result = await client.request(url, HttpPatch, body, multipart=multipart)
+
+proc patchContent*(client: HttpClient | AsyncHttpClient, url: Uri | string, body = "",
+                   multipart: MultipartData = nil): Future[string]
+                  {.multisync.} =
+  ## Connects to the hostname specified by the URL and returns the content of a PATCH request.
+  let resp = await patch(client, url, body, multipart)
+  return await responseContent(resp)
+
+proc downloadFile*(client: HttpClient, url: Uri | string, filename: string) =
+  ## Downloads `url` and saves it to `filename`.
+  client.getBody = false
+  defer:
+    client.getBody = true
+  let resp = client.get(url)
   
-  var headers: string = "Content-Type: multipart/form-data; boundary=xyz\c\L"
-  var body: string = "--xyz\c\L"
-  # soap 1.2 output
-  body.add("Content-Disposition: form-data; name=\"output\"\c\L")
-  body.add("\c\Lsoap12\c\L")
+  if resp.code.is4xx or resp.code.is5xx:
+    raise newException(HttpRequestError, resp.status)
+
+  client.bodyStream = newFileStream(filename, fmWrite)
+  if client.bodyStream.isNil:
+    fileError("Unable to open file")
+  parseBody(client, resp.headers, resp.version)
+  client.bodyStream.close()
+
+proc downloadFileEx(client: AsyncHttpClient,
+                    url: Uri | string, filename: string): Future[void] {.async.} =
+  ## Downloads `url` and saves it to `filename`.
+  client.getBody = false
+  let resp = await client.get(url)
   
-  # html
-  body.add("--xyz\c\L")
-  body.add("Content-Disposition: form-data; name=\"uploaded_file\";" &
-           " filename=\"test.html\"\c\L")
-  body.add("Content-Type: text/html\c\L")
-  body.add("\c\L<html><head></head><body><p>test</p></body></html>\c\L")
-  body.add("--xyz--")
-
-  echo(postContent("http://validator.w3.org/check", headers, body))
+  if resp.code.is4xx or resp.code.is5xx:
+    raise newException(HttpRequestError, resp.status)
+
+  client.bodyStream = newFutureStream[string]("downloadFile")
+  var file = openAsync(filename, fmWrite)
+  defer: file.close()
+  # Let `parseBody` write response data into client.bodyStream in the
+  # background.
+  let parseBodyFut = parseBody(client, resp.headers, resp.version)
+  parseBodyFut.addCallback do():
+    if parseBodyFut.failed:
+      client.bodyStream.fail(parseBodyFut.error)
+  # The `writeFromStream` proc will complete once all the data in the
+  # `bodyStream` has been written to the file.
+  await file.writeFromStream(client.bodyStream)
+
+proc downloadFile*(client: AsyncHttpClient, url: Uri | string,
+                   filename: string): Future[void] =
+  result = newFuture[void]("downloadFile")
+  try:
+    result = downloadFileEx(client, url, filename)
+  except Exception as exc:
+    result.fail(exc)
+  finally:
+    result.addCallback(
+      proc () = client.getBody = true
+    )
diff --git a/lib/pure/httpcore.nim b/lib/pure/httpcore.nim
new file mode 100644
index 000000000..5ccab379c
--- /dev/null
+++ b/lib/pure/httpcore.nim
@@ -0,0 +1,368 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Contains functionality shared between the `httpclient` and
+## `asynchttpserver` modules.
+##
+## Unstable API.
+import std/private/since
+import std/[tables, strutils, parseutils]
+
+type
+  HttpHeaders* = ref object
+    table*: TableRef[string, seq[string]]
+    isTitleCase: bool
+
+  HttpHeaderValues* = distinct seq[string]
+
+  # The range starts at '0' so that we don't have to explicitly initialise
+  # it. See: http://irclogs.nim-lang.org/19-09-2016.html#19:48:27 for context.
+  HttpCode* = distinct range[0 .. 599]
+
+  HttpVersion* = enum
+    HttpVer11,
+    HttpVer10
+
+  HttpMethod* = enum         ## the requested HttpMethod
+    HttpHead = "HEAD"        ## Asks for the response identical to the one that
+                             ## would correspond to a GET request, but without
+                             ## the response body.
+    HttpGet = "GET"          ## Retrieves the specified resource.
+    HttpPost = "POST"        ## Submits data to be processed to the identified
+                             ## resource. The data is included in the body of
+                             ## the request.
+    HttpPut = "PUT"          ## Uploads a representation of the specified
+                             ## resource.
+    HttpDelete = "DELETE"    ## Deletes the specified resource.
+    HttpTrace = "TRACE"      ## Echoes back the received request, so that a
+                             ## client
+                             ## can see what intermediate servers are adding or
+                             ## changing in the request.
+    HttpOptions = "OPTIONS"  ## Returns the HTTP methods that the server
+                             ## supports for specified address.
+    HttpConnect = "CONNECT"  ## Converts the request connection to a transparent
+                             ## TCP/IP tunnel, usually used for proxies.
+    HttpPatch = "PATCH"      ## Applies partial modifications to a resource.
+
+
+const
+  Http100* = HttpCode(100)
+  Http101* = HttpCode(101)
+  Http102* = HttpCode(102)  ## https://tools.ietf.org/html/rfc2518.html WebDAV
+  Http103* = HttpCode(103)  ## https://tools.ietf.org/html/rfc8297.html Early hints
+  Http200* = HttpCode(200)
+  Http201* = HttpCode(201)
+  Http202* = HttpCode(202)
+  Http203* = HttpCode(203)
+  Http204* = HttpCode(204)
+  Http205* = HttpCode(205)
+  Http206* = HttpCode(206)
+  Http207* = HttpCode(207)  ## https://tools.ietf.org/html/rfc4918.html WebDAV
+  Http208* = HttpCode(208)  ## https://tools.ietf.org/html/rfc5842.html WebDAV, Section 7.1
+  Http226* = HttpCode(226)  ## https://tools.ietf.org/html/rfc3229.html Delta encoding, Section 10.4.1
+  Http300* = HttpCode(300)
+  Http301* = HttpCode(301)
+  Http302* = HttpCode(302)
+  Http303* = HttpCode(303)
+  Http304* = HttpCode(304)
+  Http305* = HttpCode(305)
+  Http307* = HttpCode(307)
+  Http308* = HttpCode(308)
+  Http400* = HttpCode(400)
+  Http401* = HttpCode(401)
+  Http402* = HttpCode(402)  ## https://tools.ietf.org/html/rfc7231.html Payment required, Section 6.5.2
+  Http403* = HttpCode(403)
+  Http404* = HttpCode(404)
+  Http405* = HttpCode(405)
+  Http406* = HttpCode(406)
+  Http407* = HttpCode(407)
+  Http408* = HttpCode(408)
+  Http409* = HttpCode(409)
+  Http410* = HttpCode(410)
+  Http411* = HttpCode(411)
+  Http412* = HttpCode(412)
+  Http413* = HttpCode(413)
+  Http414* = HttpCode(414)
+  Http415* = HttpCode(415)
+  Http416* = HttpCode(416)
+  Http417* = HttpCode(417)
+  Http418* = HttpCode(418)
+  Http421* = HttpCode(421)
+  Http422* = HttpCode(422)
+  Http423* = HttpCode(423)  ## https://tools.ietf.org/html/rfc4918.html WebDAV, Section 11.3
+  Http424* = HttpCode(424)  ## https://tools.ietf.org/html/rfc4918.html WebDAV, Section 11.3
+  Http425* = HttpCode(425)  ## https://tools.ietf.org/html/rfc8470.html Early data
+  Http426* = HttpCode(426)
+  Http428* = HttpCode(428)
+  Http429* = HttpCode(429)
+  Http431* = HttpCode(431)
+  Http451* = HttpCode(451)
+  Http500* = HttpCode(500)
+  Http501* = HttpCode(501)
+  Http502* = HttpCode(502)
+  Http503* = HttpCode(503)
+  Http504* = HttpCode(504)
+  Http505* = HttpCode(505)
+  Http506* = HttpCode(506)  ## https://tools.ietf.org/html/rfc2295.html Content negotiation, Section 8.1
+  Http507* = HttpCode(507)  ## https://tools.ietf.org/html/rfc4918.html WebDAV, Section 11.5
+  Http508* = HttpCode(508)  ## https://tools.ietf.org/html/rfc5842.html WebDAV, Section 7.2
+  Http510* = HttpCode(510)  ## https://tools.ietf.org/html/rfc2774.html Extension framework, Section 7
+  Http511* = HttpCode(511)  ## https://tools.ietf.org/html/rfc6585.html Additional status code, Section 6
+
+
+const httpNewLine* = "\c\L"
+const headerLimit* = 10_000
+
+func toTitleCase(s: string): string =
+  result = newString(len(s))
+  var upper = true
+  for i in 0..len(s) - 1:
+    result[i] = if upper: toUpperAscii(s[i]) else: toLowerAscii(s[i])
+    upper = s[i] == '-'
+
+func toCaseInsensitive*(headers: HttpHeaders, s: string): string {.inline.} =
+  ## For internal usage only. Do not use.
+  return if headers.isTitleCase: toTitleCase(s) else: toLowerAscii(s)
+
+func newHttpHeaders*(titleCase=false): HttpHeaders =
+  ## Returns a new `HttpHeaders` object. if `titleCase` is set to true,
+  ## headers are passed to the server in title case (e.g. "Content-Length")
+  result = HttpHeaders(table: newTable[string, seq[string]](), isTitleCase: titleCase)
+
+func newHttpHeaders*(keyValuePairs:
+    openArray[tuple[key: string, val: string]], titleCase=false): HttpHeaders =
+  ## Returns a new `HttpHeaders` object from an array. if `titleCase` is set to true,
+  ## headers are passed to the server in title case (e.g. "Content-Length")
+  result = HttpHeaders(table: newTable[string, seq[string]](), isTitleCase: titleCase)
+
+  for pair in keyValuePairs:
+    let key = result.toCaseInsensitive(pair.key)
+    {.cast(noSideEffect).}:
+      if key in result.table:
+        result.table[key].add(pair.val)
+      else:
+        result.table[key] = @[pair.val]
+
+func `$`*(headers: HttpHeaders): string {.inline.} =
+  $headers.table
+
+proc clear*(headers: HttpHeaders) {.inline.} =
+  headers.table.clear()
+
+func `[]`*(headers: HttpHeaders, key: string): HttpHeaderValues =
+  ## Returns the values associated with the given `key`. If the returned
+  ## values are passed to a procedure expecting a `string`, the first
+  ## value is automatically picked. If there are
+  ## no values associated with the key, an exception is raised.
+  ##
+  ## To access multiple values of a key, use the overloaded `[]` below or
+  ## to get all of them access the `table` field directly.
+  {.cast(noSideEffect).}:
+    let tmp = headers.table[headers.toCaseInsensitive(key)]
+    return HttpHeaderValues(tmp)
+
+converter toString*(values: HttpHeaderValues): string =
+  return seq[string](values)[0]
+
+func `[]`*(headers: HttpHeaders, key: string, i: int): string =
+  ## Returns the `i`'th value associated with the given key. If there are
+  ## no values associated with the key or the `i`'th value doesn't exist,
+  ## an exception is raised.
+  {.cast(noSideEffect).}:
+    return headers.table[headers.toCaseInsensitive(key)][i]
+
+proc `[]=`*(headers: HttpHeaders, key, value: string) =
+  ## Sets the header entries associated with `key` to the specified value.
+  ## Replaces any existing values.
+  headers.table[headers.toCaseInsensitive(key)] = @[value]
+
+proc `[]=`*(headers: HttpHeaders, key: string, value: seq[string]) =
+  ## Sets the header entries associated with `key` to the specified list of
+  ## values. Replaces any existing values. If `value` is empty,
+  ## deletes the header entries associated with `key`.
+  if value.len > 0:
+    headers.table[headers.toCaseInsensitive(key)] = value
+  else:
+    headers.table.del(headers.toCaseInsensitive(key))
+
+proc add*(headers: HttpHeaders, key, value: string) =
+  ## Adds the specified value to the specified key. Appends to any existing
+  ## values associated with the key.
+  if not headers.table.hasKey(headers.toCaseInsensitive(key)):
+    headers.table[headers.toCaseInsensitive(key)] = @[value]
+  else:
+    headers.table[headers.toCaseInsensitive(key)].add(value)
+
+proc del*(headers: HttpHeaders, key: string) =
+  ## Deletes the header entries associated with `key`
+  headers.table.del(headers.toCaseInsensitive(key))
+
+iterator pairs*(headers: HttpHeaders): tuple[key, value: string] =
+  ## Yields each key, value pair.
+  for k, v in headers.table:
+    for value in v:
+      yield (k, value)
+
+func contains*(values: HttpHeaderValues, value: string): bool =
+  ## Determines if `value` is one of the values inside `values`. Comparison
+  ## is performed without case sensitivity.
+  for val in seq[string](values):
+    if val.toLowerAscii == value.toLowerAscii: return true
+
+func hasKey*(headers: HttpHeaders, key: string): bool =
+  return headers.table.hasKey(headers.toCaseInsensitive(key))
+
+func getOrDefault*(headers: HttpHeaders, key: string,
+    default = @[""].HttpHeaderValues): HttpHeaderValues =
+  ## Returns the values associated with the given `key`. If there are no
+  ## values associated with the key, then `default` is returned.
+  if headers.hasKey(key):
+    return headers[key]
+  else:
+    return default
+
+func len*(headers: HttpHeaders): int {.inline.} = headers.table.len
+
+func parseList(line: string, list: var seq[string], start: int): int =
+  var i = 0
+  var current = ""
+  while start+i < line.len and line[start + i] notin {'\c', '\l'}:
+    i += line.skipWhitespace(start + i)
+    i += line.parseUntil(current, {'\c', '\l', ','}, start + i)
+    list.add(move current)  # implicit current.setLen(0)
+    if start+i < line.len and line[start + i] == ',':
+      i.inc # Skip ,
+
+func parseHeader*(line: string): tuple[key: string, value: seq[string]] =
+  ## Parses a single raw header HTTP line into key value pairs.
+  ##
+  ## Used by `asynchttpserver` and `httpclient` internally and should not
+  ## be used by you.
+  result.value = @[]
+  var i = 0
+  i = line.parseUntil(result.key, ':')
+  inc(i) # skip :
+  if i < len(line):
+    if cmpIgnoreCase(result.key, "cookie") == 0:
+      i += line.skipWhitespace(i)
+      result.value.add line.substr(i)
+    else:
+      i += parseList(line, result.value, i)
+  elif result.key.len > 0:
+    result.value = @[""]
+  else:
+    result.value = @[]
+
+func `==`*(protocol: tuple[orig: string, major, minor: int],
+           ver: HttpVersion): bool =
+  let major =
+    case ver
+    of HttpVer11, HttpVer10: 1
+  let minor =
+    case ver
+    of HttpVer11: 1
+    of HttpVer10: 0
+  result = protocol.major == major and protocol.minor == minor
+
+func contains*(methods: set[HttpMethod], x: string): bool =
+  return parseEnum[HttpMethod](x) in methods
+
+func `$`*(code: HttpCode): string =
+  ## Converts the specified `HttpCode` into a HTTP status.
+  runnableExamples:
+    doAssert($Http404 == "404 Not Found")
+  case code.int
+  of 100: "100 Continue"
+  of 101: "101 Switching Protocols"
+  of 102: "102 Processing"
+  of 103: "103 Early Hints"
+  of 200: "200 OK"
+  of 201: "201 Created"
+  of 202: "202 Accepted"
+  of 203: "203 Non-Authoritative Information"
+  of 204: "204 No Content"
+  of 205: "205 Reset Content"
+  of 206: "206 Partial Content"
+  of 207: "207 Multi-Status"
+  of 208: "208 Already Reported"
+  of 226: "226 IM Used"
+  of 300: "300 Multiple Choices"
+  of 301: "301 Moved Permanently"
+  of 302: "302 Found"
+  of 303: "303 See Other"
+  of 304: "304 Not Modified"
+  of 305: "305 Use Proxy"
+  of 307: "307 Temporary Redirect"
+  of 308: "308 Permanent Redirect"
+  of 400: "400 Bad Request"
+  of 401: "401 Unauthorized"
+  of 402: "402 Payment Required"
+  of 403: "403 Forbidden"
+  of 404: "404 Not Found"
+  of 405: "405 Method Not Allowed"
+  of 406: "406 Not Acceptable"
+  of 407: "407 Proxy Authentication Required"
+  of 408: "408 Request Timeout"
+  of 409: "409 Conflict"
+  of 410: "410 Gone"
+  of 411: "411 Length Required"
+  of 412: "412 Precondition Failed"
+  of 413: "413 Request Entity Too Large"
+  of 414: "414 Request-URI Too Long"
+  of 415: "415 Unsupported Media Type"
+  of 416: "416 Requested Range Not Satisfiable"
+  of 417: "417 Expectation Failed"
+  of 418: "418 I'm a teapot"
+  of 421: "421 Misdirected Request"
+  of 422: "422 Unprocessable Entity"
+  of 423: "423 Locked"
+  of 424: "424 Failed Dependency"
+  of 425: "425 Too Early"
+  of 426: "426 Upgrade Required"
+  of 428: "428 Precondition Required"
+  of 429: "429 Too Many Requests"
+  of 431: "431 Request Header Fields Too Large"
+  of 451: "451 Unavailable For Legal Reasons"
+  of 500: "500 Internal Server Error"
+  of 501: "501 Not Implemented"
+  of 502: "502 Bad Gateway"
+  of 503: "503 Service Unavailable"
+  of 504: "504 Gateway Timeout"
+  of 505: "505 HTTP Version Not Supported"
+  of 506: "506 Variant Also Negotiates"
+  of 507: "507 Insufficient Storage"
+  of 508: "508 Loop Detected"
+  of 510: "510 Not Extended"
+  of 511: "511 Network Authentication Required"
+  else: $(int(code))
+
+func `==`*(a, b: HttpCode): bool {.borrow.}
+
+func is1xx*(code: HttpCode): bool {.inline, since: (1, 5).} =
+  ## Determines whether `code` is a 1xx HTTP status code.
+  runnableExamples:
+    doAssert is1xx(HttpCode(103))
+
+  code.int in 100 .. 199
+
+func is2xx*(code: HttpCode): bool {.inline.} =
+  ## Determines whether `code` is a 2xx HTTP status code.
+  code.int in 200 .. 299
+
+func is3xx*(code: HttpCode): bool {.inline.} =
+  ## Determines whether `code` is a 3xx HTTP status code.
+  code.int in 300 .. 399
+
+func is4xx*(code: HttpCode): bool {.inline.} =
+  ## Determines whether `code` is a 4xx HTTP status code.
+  code.int in 400 .. 499
+
+func is5xx*(code: HttpCode): bool {.inline.} =
+  ## Determines whether `code` is a 5xx HTTP status code.
+  code.int in 500 .. 599
diff --git a/lib/pure/httpserver.nim b/lib/pure/httpserver.nim
deleted file mode 100755
index 2c85d8137..000000000
--- a/lib/pure/httpserver.nim
+++ /dev/null
@@ -1,259 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements a simple HTTP-Server. 
-##
-## Example: 
-##
-## .. code-block:: nimrod
-##  import strutils, sockets, httpserver
-##  
-##  var counter = 0
-##  proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
-##    inc(counter)
-##    client.send("Hallo for the $#th time." % $counter & wwwNL)
-##    return false # do not stop processing
-##  
-##  run(handleRequest, TPort(80))
-##
-
-import strutils, os, osproc, strtabs, streams, sockets
-
-const
-  wwwNL* = "\r\L"
-  ServerSig = "Server: httpserver.nim/1.0.0" & wwwNL
-
-# --------------- output messages --------------------------------------------
-
-proc sendTextContentType(client: TSocket) =
-  send(client, "Content-type: text/html" & wwwNL)
-  send(client, wwwNL)
-
-proc badRequest(client: TSocket) =
-  # Inform the client that a request it has made has a problem.
-  send(client, "HTTP/1.0 400 BAD REQUEST" & wwwNL)
-  sendTextContentType(client)
-  send(client, "<p>Your browser sent a bad request, " &
-               "such as a POST without a Content-Length." & wwwNL)
-
-proc cannotExec(client: TSocket) =
-  send(client, "HTTP/1.0 500 Internal Server Error" & wwwNL)
-  sendTextContentType(client)
-  send(client, "<P>Error prohibited CGI execution." & wwwNL)
-
-proc headers(client: TSocket, filename: string) = 
-  # XXX could use filename to determine file type
-  send(client, "HTTP/1.0 200 OK" & wwwNL)
-  send(client, ServerSig)
-  sendTextContentType(client)
-
-proc notFound(client: TSocket) =
-  send(client, "HTTP/1.0 404 NOT FOUND" & wwwNL)
-  send(client, ServerSig)
-  sendTextContentType(client)
-  send(client, "<html><title>Not Found</title>" & wwwNL)
-  send(client, "<body><p>The server could not fulfill" & wwwNL)
-  send(client, "your request because the resource specified" & wwwNL)
-  send(client, "is unavailable or nonexistent." & wwwNL)
-  send(client, "</body></html>" & wwwNL)
-
-proc unimplemented(client: TSocket) =
-  send(client, "HTTP/1.0 501 Method Not Implemented" & wwwNL)
-  send(client, ServerSig)
-  sendTextContentType(client)
-  send(client, "<html><head><title>Method Not Implemented" & 
-               "</title></head>" &
-               "<body><p>HTTP request method not supported." &
-               "</body></HTML>" & wwwNL)
-
-# ----------------- file serving ---------------------------------------------
-
-proc discardHeaders(client: TSocket) = skip(client)
-
-proc serveFile(client: TSocket, filename: string) =
-  discardHeaders(client)
-  
-  var f: TFile
-  if open(f, filename):
-    headers(client, filename)
-    const bufSize = 8000 # != 8K might be good for memory manager
-    var buf = alloc(bufsize)
-    while True:
-      var bytesread = readBuffer(f, buf, bufsize)
-      if bytesread > 0:
-        var byteswritten = send(client, buf, bytesread)
-        if bytesread != bytesWritten:
-          dealloc(buf)
-          close(f)
-          OSError()
-      if bytesread != bufSize: break
-    dealloc(buf)
-    close(f)
-  else:
-    notFound(client)
-
-# ------------------ CGI execution -------------------------------------------
-
-type
-  TRequestMethod = enum reqGet, reqPost
-
-proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
-  var env = newStringTable(modeCaseInsensitive)
-  var contentLength = -1
-  case meth
-  of reqGet:
-    discardHeaders(client)
-    
-    env["REQUEST_METHOD"] = "GET"
-    env["QUERY_STRING"] = query
-  of reqPost:
-    var buf = ""
-    var dataAvail = false
-    while dataAvail:
-      dataAvail = recvLine(client, buf)
-      var L = toLower(buf)
-      if L.startsWith("content-length:"):
-        var i = len("content-length:")
-        while L[i] in Whitespace: inc(i)
-        contentLength = parseInt(copy(L, i))
-    
-    if contentLength < 0:
-      badRequest(client)
-      return
-
-    env["REQUEST_METHOD"] = "POST"
-    env["CONTENT_LENGTH"] = $contentLength
-  
-  send(client, "HTTP/1.0 200 OK" & wwwNL)
-  
-  var process = startProcess(command=path, env=env)
-  if meth == reqPost:
-    # get from client and post to CGI program:
-    var buf = alloc(contentLength)
-    if recv(client, buf, contentLength) != contentLength: OSError()
-    var inp = process.inputStream
-    inp.writeData(inp, buf, contentLength)
-  
-  var outp = process.outputStream
-  while running(process) or not outp.atEnd(outp):
-    var line = outp.readLine()
-    send(client, line)
-    send(client, wwwNL)
-
-# --------------- Server Setup -----------------------------------------------
-
-proc acceptRequest(client: TSocket) =
-  var cgi = false
-  var query = ""
-  var buf = ""
-  discard recvLine(client, buf)
-  var data = buf.split()
-  var meth = reqGet
-  if cmpIgnoreCase(data[0], "GET") == 0:
-    var q = find(data[1], '?')
-    if q >= 0:
-      cgi = true
-      query = data[1].copy(q+1)
-  elif cmpIgnoreCase(data[0], "POST") == 0:
-    cgi = true
-    meth = reqPost
-  else:
-    unimplemented(client)
-    
-  var path = data[1]
-  if path[path.len-1] == '/' or existsDir(path):
-    path = path / "index.html"
-  
-  if not ExistsFile(path):
-    discardHeaders(client)
-    notFound(client)
-  else:
-    when defined(Windows):
-      var ext = splitFile(path).ext.toLower
-      if ext == ".exe" or ext == ".cgi":
-        # XXX: extract interpreter information here?
-        cgi = true
-    else:
-      if {fpUserExec, fpGroupExec, fpOthersExec} * path.getFilePermissions != {}:
-        cgi = true
-    if not cgi:
-      serveFile(client, path)
-    else:
-      executeCgi(client, path, query, meth)
-
-type
-  TServer* = object       ## contains the current server state
-    socket: TSocket
-    port: TPort
-    client*: TSocket      ## the socket to write the file data to
-    path*, query*: string ## path and query the client requested
-    
-proc open*(s: var TServer, port = TPort(80)) = 
-  ## creates a new server at port `port`. If ``port == 0`` a free port is
-  ## aquired that can be accessed later by the ``port`` proc.
-  s.socket = socket(AF_INET)
-  if s.socket == InvalidSocket: OSError()
-  bindAddr(s.socket, port)
-  listen(s.socket)
-  
-  if port == TPort(0):
-    s.port = getSockName(s.socket)
-  else:
-    s.port = port
-  s.client = InvalidSocket
-  s.path = ""
-  s.query = ""
-  
-proc port*(s: var TServer): TPort = 
-  ## get the port number the server has aquired.
-  result = s.port
-  
-proc next*(s: var TServer) = 
-  ## proceed to the first/next request.
-  s.client = accept(s.socket)
-  headers(s.client, "")
-  var buf = ""
-  discard recvLine(s.client, buf)
-  var data = buf.split()
-  if cmpIgnoreCase(data[0], "GET") == 0:
-    var q = find(data[1], '?')
-    if q >= 0:
-      s.query = data[1].copy(q+1)
-      s.path = data[1].copy(0, q-1)
-    else:
-      s.query = ""
-      s.path = data[1]
-  else:
-    unimplemented(s.client)
-
-proc close*(s: TServer) =
-  ## closes the server (and the socket the server uses).
-  close(s.socket)
-
-proc run*(handleRequest: proc (client: TSocket, path, query: string): bool, 
-          port = TPort(80)) =
-  ## encapsulates the server object and main loop
-  var s: TServer
-  open(s, port)
-  #echo("httpserver running on port ", s.port)
-  while true: 
-    next(s)
-    if handleRequest(s.client, s.path, s.query): break
-    close(s.client)
-  close(s)
-
-when isMainModule:
-  var counter = 0
-  proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
-    inc(counter)
-    client.send("Hallo, Andreas for the $#th time." % $counter & wwwNL)
-    return false # do not stop processing
-  
-  run(handleRequest, TPort(80))
-
diff --git a/lib/pure/includes/unicode_ranges.nim b/lib/pure/includes/unicode_ranges.nim
new file mode 100644
index 000000000..04ccfb747
--- /dev/null
+++ b/lib/pure/includes/unicode_ranges.nim
@@ -0,0 +1,2007 @@
+# This file was created from a script.
+
+const
+  toLowerRanges = [
+    0x00041'i32, 0x0005A'i32, 532,
+    0x000C0'i32, 0x000D6'i32, 532,
+    0x000D8'i32, 0x000DE'i32, 532,
+    0x00189'i32, 0x0018A'i32, 705,
+    0x001B1'i32, 0x001B2'i32, 717,
+    0x00388'i32, 0x0038A'i32, 537,
+    0x0038E'i32, 0x0038F'i32, 563,
+    0x00391'i32, 0x003A1'i32, 532,
+    0x003A3'i32, 0x003AB'i32, 532,
+    0x003FD'i32, 0x003FF'i32, 370,
+    0x00400'i32, 0x0040F'i32, 580,
+    0x00410'i32, 0x0042F'i32, 532,
+    0x00531'i32, 0x00556'i32, 548,
+    0x010A0'i32, 0x010C5'i32, 7764,
+    0x013A0'i32, 0x013EF'i32, 39364,
+    0x013F0'i32, 0x013F5'i32, 508,
+    0x01C90'i32, 0x01CBA'i32, -2508,
+    0x01CBD'i32, 0x01CBF'i32, -2508,
+    0x01F08'i32, 0x01F0F'i32, 492,
+    0x01F18'i32, 0x01F1D'i32, 492,
+    0x01F28'i32, 0x01F2F'i32, 492,
+    0x01F38'i32, 0x01F3F'i32, 492,
+    0x01F48'i32, 0x01F4D'i32, 492,
+    0x01F68'i32, 0x01F6F'i32, 492,
+    0x01F88'i32, 0x01F8F'i32, 492,
+    0x01F98'i32, 0x01F9F'i32, 492,
+    0x01FA8'i32, 0x01FAF'i32, 492,
+    0x01FB8'i32, 0x01FB9'i32, 492,
+    0x01FBA'i32, 0x01FBB'i32, 426,
+    0x01FC8'i32, 0x01FCB'i32, 414,
+    0x01FD8'i32, 0x01FD9'i32, 492,
+    0x01FDA'i32, 0x01FDB'i32, 400,
+    0x01FE8'i32, 0x01FE9'i32, 492,
+    0x01FEA'i32, 0x01FEB'i32, 388,
+    0x01FF8'i32, 0x01FF9'i32, 372,
+    0x01FFA'i32, 0x01FFB'i32, 374,
+    0x02C00'i32, 0x02C2E'i32, 548,
+    0x02C7E'i32, 0x02C7F'i32, -10315,
+    0x0FF21'i32, 0x0FF3A'i32, 532,
+    0x10400'i32, 0x10427'i32, 540,
+    0x104B0'i32, 0x104D3'i32, 540,
+    0x10C80'i32, 0x10CB2'i32, 564,
+    0x118A0'i32, 0x118BF'i32, 532,
+    0x16E40'i32, 0x16E5F'i32, 532,
+    0x1E900'i32, 0x1E921'i32, 534,
+  ]
+
+  toLowerSinglets = [
+    0x00100'i32, 501,
+    0x00102'i32, 501,
+    0x00104'i32, 501,
+    0x00106'i32, 501,
+    0x00108'i32, 501,
+    0x0010A'i32, 501,
+    0x0010C'i32, 501,
+    0x0010E'i32, 501,
+    0x00110'i32, 501,
+    0x00112'i32, 501,
+    0x00114'i32, 501,
+    0x00116'i32, 501,
+    0x00118'i32, 501,
+    0x0011A'i32, 501,
+    0x0011C'i32, 501,
+    0x0011E'i32, 501,
+    0x00120'i32, 501,
+    0x00122'i32, 501,
+    0x00124'i32, 501,
+    0x00126'i32, 501,
+    0x00128'i32, 501,
+    0x0012A'i32, 501,
+    0x0012C'i32, 501,
+    0x0012E'i32, 501,
+    0x00130'i32, 301,
+    0x00132'i32, 501,
+    0x00134'i32, 501,
+    0x00136'i32, 501,
+    0x00139'i32, 501,
+    0x0013B'i32, 501,
+    0x0013D'i32, 501,
+    0x0013F'i32, 501,
+    0x00141'i32, 501,
+    0x00143'i32, 501,
+    0x00145'i32, 501,
+    0x00147'i32, 501,
+    0x0014A'i32, 501,
+    0x0014C'i32, 501,
+    0x0014E'i32, 501,
+    0x00150'i32, 501,
+    0x00152'i32, 501,
+    0x00154'i32, 501,
+    0x00156'i32, 501,
+    0x00158'i32, 501,
+    0x0015A'i32, 501,
+    0x0015C'i32, 501,
+    0x0015E'i32, 501,
+    0x00160'i32, 501,
+    0x00162'i32, 501,
+    0x00164'i32, 501,
+    0x00166'i32, 501,
+    0x00168'i32, 501,
+    0x0016A'i32, 501,
+    0x0016C'i32, 501,
+    0x0016E'i32, 501,
+    0x00170'i32, 501,
+    0x00172'i32, 501,
+    0x00174'i32, 501,
+    0x00176'i32, 501,
+    0x00178'i32, 379,
+    0x00179'i32, 501,
+    0x0017B'i32, 501,
+    0x0017D'i32, 501,
+    0x00181'i32, 710,
+    0x00182'i32, 501,
+    0x00184'i32, 501,
+    0x00186'i32, 706,
+    0x00187'i32, 501,
+    0x0018B'i32, 501,
+    0x0018E'i32, 579,
+    0x0018F'i32, 702,
+    0x00190'i32, 703,
+    0x00191'i32, 501,
+    0x00193'i32, 705,
+    0x00194'i32, 707,
+    0x00196'i32, 711,
+    0x00197'i32, 709,
+    0x00198'i32, 501,
+    0x0019C'i32, 711,
+    0x0019D'i32, 713,
+    0x0019F'i32, 714,
+    0x001A0'i32, 501,
+    0x001A2'i32, 501,
+    0x001A4'i32, 501,
+    0x001A6'i32, 718,
+    0x001A7'i32, 501,
+    0x001A9'i32, 718,
+    0x001AC'i32, 501,
+    0x001AE'i32, 718,
+    0x001AF'i32, 501,
+    0x001B3'i32, 501,
+    0x001B5'i32, 501,
+    0x001B7'i32, 719,
+    0x001B8'i32, 501,
+    0x001BC'i32, 501,
+    0x001C4'i32, 502,
+    0x001C5'i32, 501,
+    0x001C7'i32, 502,
+    0x001C8'i32, 501,
+    0x001CA'i32, 502,
+    0x001CB'i32, 501,
+    0x001CD'i32, 501,
+    0x001CF'i32, 501,
+    0x001D1'i32, 501,
+    0x001D3'i32, 501,
+    0x001D5'i32, 501,
+    0x001D7'i32, 501,
+    0x001D9'i32, 501,
+    0x001DB'i32, 501,
+    0x001DE'i32, 501,
+    0x001E0'i32, 501,
+    0x001E2'i32, 501,
+    0x001E4'i32, 501,
+    0x001E6'i32, 501,
+    0x001E8'i32, 501,
+    0x001EA'i32, 501,
+    0x001EC'i32, 501,
+    0x001EE'i32, 501,
+    0x001F1'i32, 502,
+    0x001F2'i32, 501,
+    0x001F4'i32, 501,
+    0x001F6'i32, 403,
+    0x001F7'i32, 444,
+    0x001F8'i32, 501,
+    0x001FA'i32, 501,
+    0x001FC'i32, 501,
+    0x001FE'i32, 501,
+    0x00200'i32, 501,
+    0x00202'i32, 501,
+    0x00204'i32, 501,
+    0x00206'i32, 501,
+    0x00208'i32, 501,
+    0x0020A'i32, 501,
+    0x0020C'i32, 501,
+    0x0020E'i32, 501,
+    0x00210'i32, 501,
+    0x00212'i32, 501,
+    0x00214'i32, 501,
+    0x00216'i32, 501,
+    0x00218'i32, 501,
+    0x0021A'i32, 501,
+    0x0021C'i32, 501,
+    0x0021E'i32, 501,
+    0x00220'i32, 370,
+    0x00222'i32, 501,
+    0x00224'i32, 501,
+    0x00226'i32, 501,
+    0x00228'i32, 501,
+    0x0022A'i32, 501,
+    0x0022C'i32, 501,
+    0x0022E'i32, 501,
+    0x00230'i32, 501,
+    0x00232'i32, 501,
+    0x0023A'i32, 11295,
+    0x0023B'i32, 501,
+    0x0023D'i32, 337,
+    0x0023E'i32, 11292,
+    0x00241'i32, 501,
+    0x00243'i32, 305,
+    0x00244'i32, 569,
+    0x00245'i32, 571,
+    0x00246'i32, 501,
+    0x00248'i32, 501,
+    0x0024A'i32, 501,
+    0x0024C'i32, 501,
+    0x0024E'i32, 501,
+    0x00370'i32, 501,
+    0x00372'i32, 501,
+    0x00376'i32, 501,
+    0x0037F'i32, 616,
+    0x00386'i32, 538,
+    0x0038C'i32, 564,
+    0x003CF'i32, 508,
+    0x003D8'i32, 501,
+    0x003DA'i32, 501,
+    0x003DC'i32, 501,
+    0x003DE'i32, 501,
+    0x003E0'i32, 501,
+    0x003E2'i32, 501,
+    0x003E4'i32, 501,
+    0x003E6'i32, 501,
+    0x003E8'i32, 501,
+    0x003EA'i32, 501,
+    0x003EC'i32, 501,
+    0x003EE'i32, 501,
+    0x003F4'i32, 440,
+    0x003F7'i32, 501,
+    0x003F9'i32, 493,
+    0x003FA'i32, 501,
+    0x00460'i32, 501,
+    0x00462'i32, 501,
+    0x00464'i32, 501,
+    0x00466'i32, 501,
+    0x00468'i32, 501,
+    0x0046A'i32, 501,
+    0x0046C'i32, 501,
+    0x0046E'i32, 501,
+    0x00470'i32, 501,
+    0x00472'i32, 501,
+    0x00474'i32, 501,
+    0x00476'i32, 501,
+    0x00478'i32, 501,
+    0x0047A'i32, 501,
+    0x0047C'i32, 501,
+    0x0047E'i32, 501,
+    0x00480'i32, 501,
+    0x0048A'i32, 501,
+    0x0048C'i32, 501,
+    0x0048E'i32, 501,
+    0x00490'i32, 501,
+    0x00492'i32, 501,
+    0x00494'i32, 501,
+    0x00496'i32, 501,
+    0x00498'i32, 501,
+    0x0049A'i32, 501,
+    0x0049C'i32, 501,
+    0x0049E'i32, 501,
+    0x004A0'i32, 501,
+    0x004A2'i32, 501,
+    0x004A4'i32, 501,
+    0x004A6'i32, 501,
+    0x004A8'i32, 501,
+    0x004AA'i32, 501,
+    0x004AC'i32, 501,
+    0x004AE'i32, 501,
+    0x004B0'i32, 501,
+    0x004B2'i32, 501,
+    0x004B4'i32, 501,
+    0x004B6'i32, 501,
+    0x004B8'i32, 501,
+    0x004BA'i32, 501,
+    0x004BC'i32, 501,
+    0x004BE'i32, 501,
+    0x004C0'i32, 515,
+    0x004C1'i32, 501,
+    0x004C3'i32, 501,
+    0x004C5'i32, 501,
+    0x004C7'i32, 501,
+    0x004C9'i32, 501,
+    0x004CB'i32, 501,
+    0x004CD'i32, 501,
+    0x004D0'i32, 501,
+    0x004D2'i32, 501,
+    0x004D4'i32, 501,
+    0x004D6'i32, 501,
+    0x004D8'i32, 501,
+    0x004DA'i32, 501,
+    0x004DC'i32, 501,
+    0x004DE'i32, 501,
+    0x004E0'i32, 501,
+    0x004E2'i32, 501,
+    0x004E4'i32, 501,
+    0x004E6'i32, 501,
+    0x004E8'i32, 501,
+    0x004EA'i32, 501,
+    0x004EC'i32, 501,
+    0x004EE'i32, 501,
+    0x004F0'i32, 501,
+    0x004F2'i32, 501,
+    0x004F4'i32, 501,
+    0x004F6'i32, 501,
+    0x004F8'i32, 501,
+    0x004FA'i32, 501,
+    0x004FC'i32, 501,
+    0x004FE'i32, 501,
+    0x00500'i32, 501,
+    0x00502'i32, 501,
+    0x00504'i32, 501,
+    0x00506'i32, 501,
+    0x00508'i32, 501,
+    0x0050A'i32, 501,
+    0x0050C'i32, 501,
+    0x0050E'i32, 501,
+    0x00510'i32, 501,
+    0x00512'i32, 501,
+    0x00514'i32, 501,
+    0x00516'i32, 501,
+    0x00518'i32, 501,
+    0x0051A'i32, 501,
+    0x0051C'i32, 501,
+    0x0051E'i32, 501,
+    0x00520'i32, 501,
+    0x00522'i32, 501,
+    0x00524'i32, 501,
+    0x00526'i32, 501,
+    0x00528'i32, 501,
+    0x0052A'i32, 501,
+    0x0052C'i32, 501,
+    0x0052E'i32, 501,
+    0x010C7'i32, 7764,
+    0x010CD'i32, 7764,
+    0x01E00'i32, 501,
+    0x01E02'i32, 501,
+    0x01E04'i32, 501,
+    0x01E06'i32, 501,
+    0x01E08'i32, 501,
+    0x01E0A'i32, 501,
+    0x01E0C'i32, 501,
+    0x01E0E'i32, 501,
+    0x01E10'i32, 501,
+    0x01E12'i32, 501,
+    0x01E14'i32, 501,
+    0x01E16'i32, 501,
+    0x01E18'i32, 501,
+    0x01E1A'i32, 501,
+    0x01E1C'i32, 501,
+    0x01E1E'i32, 501,
+    0x01E20'i32, 501,
+    0x01E22'i32, 501,
+    0x01E24'i32, 501,
+    0x01E26'i32, 501,
+    0x01E28'i32, 501,
+    0x01E2A'i32, 501,
+    0x01E2C'i32, 501,
+    0x01E2E'i32, 501,
+    0x01E30'i32, 501,
+    0x01E32'i32, 501,
+    0x01E34'i32, 501,
+    0x01E36'i32, 501,
+    0x01E38'i32, 501,
+    0x01E3A'i32, 501,
+    0x01E3C'i32, 501,
+    0x01E3E'i32, 501,
+    0x01E40'i32, 501,
+    0x01E42'i32, 501,
+    0x01E44'i32, 501,
+    0x01E46'i32, 501,
+    0x01E48'i32, 501,
+    0x01E4A'i32, 501,
+    0x01E4C'i32, 501,
+    0x01E4E'i32, 501,
+    0x01E50'i32, 501,
+    0x01E52'i32, 501,
+    0x01E54'i32, 501,
+    0x01E56'i32, 501,
+    0x01E58'i32, 501,
+    0x01E5A'i32, 501,
+    0x01E5C'i32, 501,
+    0x01E5E'i32, 501,
+    0x01E60'i32, 501,
+    0x01E62'i32, 501,
+    0x01E64'i32, 501,
+    0x01E66'i32, 501,
+    0x01E68'i32, 501,
+    0x01E6A'i32, 501,
+    0x01E6C'i32, 501,
+    0x01E6E'i32, 501,
+    0x01E70'i32, 501,
+    0x01E72'i32, 501,
+    0x01E74'i32, 501,
+    0x01E76'i32, 501,
+    0x01E78'i32, 501,
+    0x01E7A'i32, 501,
+    0x01E7C'i32, 501,
+    0x01E7E'i32, 501,
+    0x01E80'i32, 501,
+    0x01E82'i32, 501,
+    0x01E84'i32, 501,
+    0x01E86'i32, 501,
+    0x01E88'i32, 501,
+    0x01E8A'i32, 501,
+    0x01E8C'i32, 501,
+    0x01E8E'i32, 501,
+    0x01E90'i32, 501,
+    0x01E92'i32, 501,
+    0x01E94'i32, 501,
+    0x01E9E'i32, -7115,
+    0x01EA0'i32, 501,
+    0x01EA2'i32, 501,
+    0x01EA4'i32, 501,
+    0x01EA6'i32, 501,
+    0x01EA8'i32, 501,
+    0x01EAA'i32, 501,
+    0x01EAC'i32, 501,
+    0x01EAE'i32, 501,
+    0x01EB0'i32, 501,
+    0x01EB2'i32, 501,
+    0x01EB4'i32, 501,
+    0x01EB6'i32, 501,
+    0x01EB8'i32, 501,
+    0x01EBA'i32, 501,
+    0x01EBC'i32, 501,
+    0x01EBE'i32, 501,
+    0x01EC0'i32, 501,
+    0x01EC2'i32, 501,
+    0x01EC4'i32, 501,
+    0x01EC6'i32, 501,
+    0x01EC8'i32, 501,
+    0x01ECA'i32, 501,
+    0x01ECC'i32, 501,
+    0x01ECE'i32, 501,
+    0x01ED0'i32, 501,
+    0x01ED2'i32, 501,
+    0x01ED4'i32, 501,
+    0x01ED6'i32, 501,
+    0x01ED8'i32, 501,
+    0x01EDA'i32, 501,
+    0x01EDC'i32, 501,
+    0x01EDE'i32, 501,
+    0x01EE0'i32, 501,
+    0x01EE2'i32, 501,
+    0x01EE4'i32, 501,
+    0x01EE6'i32, 501,
+    0x01EE8'i32, 501,
+    0x01EEA'i32, 501,
+    0x01EEC'i32, 501,
+    0x01EEE'i32, 501,
+    0x01EF0'i32, 501,
+    0x01EF2'i32, 501,
+    0x01EF4'i32, 501,
+    0x01EF6'i32, 501,
+    0x01EF8'i32, 501,
+    0x01EFA'i32, 501,
+    0x01EFC'i32, 501,
+    0x01EFE'i32, 501,
+    0x01F59'i32, 492,
+    0x01F5B'i32, 492,
+    0x01F5D'i32, 492,
+    0x01F5F'i32, 492,
+    0x01FBC'i32, 491,
+    0x01FCC'i32, 491,
+    0x01FEC'i32, 493,
+    0x01FFC'i32, 491,
+    0x02126'i32, -7017,
+    0x0212A'i32, -7883,
+    0x0212B'i32, -7762,
+    0x02132'i32, 528,
+    0x02183'i32, 501,
+    0x02C60'i32, 501,
+    0x02C62'i32, -10243,
+    0x02C63'i32, -3314,
+    0x02C64'i32, -10227,
+    0x02C67'i32, 501,
+    0x02C69'i32, 501,
+    0x02C6B'i32, 501,
+    0x02C6D'i32, -10280,
+    0x02C6E'i32, -10249,
+    0x02C6F'i32, -10283,
+    0x02C70'i32, -10282,
+    0x02C72'i32, 501,
+    0x02C75'i32, 501,
+    0x02C80'i32, 501,
+    0x02C82'i32, 501,
+    0x02C84'i32, 501,
+    0x02C86'i32, 501,
+    0x02C88'i32, 501,
+    0x02C8A'i32, 501,
+    0x02C8C'i32, 501,
+    0x02C8E'i32, 501,
+    0x02C90'i32, 501,
+    0x02C92'i32, 501,
+    0x02C94'i32, 501,
+    0x02C96'i32, 501,
+    0x02C98'i32, 501,
+    0x02C9A'i32, 501,
+    0x02C9C'i32, 501,
+    0x02C9E'i32, 501,
+    0x02CA0'i32, 501,
+    0x02CA2'i32, 501,
+    0x02CA4'i32, 501,
+    0x02CA6'i32, 501,
+    0x02CA8'i32, 501,
+    0x02CAA'i32, 501,
+    0x02CAC'i32, 501,
+    0x02CAE'i32, 501,
+    0x02CB0'i32, 501,
+    0x02CB2'i32, 501,
+    0x02CB4'i32, 501,
+    0x02CB6'i32, 501,
+    0x02CB8'i32, 501,
+    0x02CBA'i32, 501,
+    0x02CBC'i32, 501,
+    0x02CBE'i32, 501,
+    0x02CC0'i32, 501,
+    0x02CC2'i32, 501,
+    0x02CC4'i32, 501,
+    0x02CC6'i32, 501,
+    0x02CC8'i32, 501,
+    0x02CCA'i32, 501,
+    0x02CCC'i32, 501,
+    0x02CCE'i32, 501,
+    0x02CD0'i32, 501,
+    0x02CD2'i32, 501,
+    0x02CD4'i32, 501,
+    0x02CD6'i32, 501,
+    0x02CD8'i32, 501,
+    0x02CDA'i32, 501,
+    0x02CDC'i32, 501,
+    0x02CDE'i32, 501,
+    0x02CE0'i32, 501,
+    0x02CE2'i32, 501,
+    0x02CEB'i32, 501,
+    0x02CED'i32, 501,
+    0x02CF2'i32, 501,
+    0x0A640'i32, 501,
+    0x0A642'i32, 501,
+    0x0A644'i32, 501,
+    0x0A646'i32, 501,
+    0x0A648'i32, 501,
+    0x0A64A'i32, 501,
+    0x0A64C'i32, 501,
+    0x0A64E'i32, 501,
+    0x0A650'i32, 501,
+    0x0A652'i32, 501,
+    0x0A654'i32, 501,
+    0x0A656'i32, 501,
+    0x0A658'i32, 501,
+    0x0A65A'i32, 501,
+    0x0A65C'i32, 501,
+    0x0A65E'i32, 501,
+    0x0A660'i32, 501,
+    0x0A662'i32, 501,
+    0x0A664'i32, 501,
+    0x0A666'i32, 501,
+    0x0A668'i32, 501,
+    0x0A66A'i32, 501,
+    0x0A66C'i32, 501,
+    0x0A680'i32, 501,
+    0x0A682'i32, 501,
+    0x0A684'i32, 501,
+    0x0A686'i32, 501,
+    0x0A688'i32, 501,
+    0x0A68A'i32, 501,
+    0x0A68C'i32, 501,
+    0x0A68E'i32, 501,
+    0x0A690'i32, 501,
+    0x0A692'i32, 501,
+    0x0A694'i32, 501,
+    0x0A696'i32, 501,
+    0x0A698'i32, 501,
+    0x0A69A'i32, 501,
+    0x0A722'i32, 501,
+    0x0A724'i32, 501,
+    0x0A726'i32, 501,
+    0x0A728'i32, 501,
+    0x0A72A'i32, 501,
+    0x0A72C'i32, 501,
+    0x0A72E'i32, 501,
+    0x0A732'i32, 501,
+    0x0A734'i32, 501,
+    0x0A736'i32, 501,
+    0x0A738'i32, 501,
+    0x0A73A'i32, 501,
+    0x0A73C'i32, 501,
+    0x0A73E'i32, 501,
+    0x0A740'i32, 501,
+    0x0A742'i32, 501,
+    0x0A744'i32, 501,
+    0x0A746'i32, 501,
+    0x0A748'i32, 501,
+    0x0A74A'i32, 501,
+    0x0A74C'i32, 501,
+    0x0A74E'i32, 501,
+    0x0A750'i32, 501,
+    0x0A752'i32, 501,
+    0x0A754'i32, 501,
+    0x0A756'i32, 501,
+    0x0A758'i32, 501,
+    0x0A75A'i32, 501,
+    0x0A75C'i32, 501,
+    0x0A75E'i32, 501,
+    0x0A760'i32, 501,
+    0x0A762'i32, 501,
+    0x0A764'i32, 501,
+    0x0A766'i32, 501,
+    0x0A768'i32, 501,
+    0x0A76A'i32, 501,
+    0x0A76C'i32, 501,
+    0x0A76E'i32, 501,
+    0x0A779'i32, 501,
+    0x0A77B'i32, 501,
+    0x0A77D'i32, -34832,
+    0x0A77E'i32, 501,
+    0x0A780'i32, 501,
+    0x0A782'i32, 501,
+    0x0A784'i32, 501,
+    0x0A786'i32, 501,
+    0x0A78B'i32, 501,
+    0x0A78D'i32, -41780,
+    0x0A790'i32, 501,
+    0x0A792'i32, 501,
+    0x0A796'i32, 501,
+    0x0A798'i32, 501,
+    0x0A79A'i32, 501,
+    0x0A79C'i32, 501,
+    0x0A79E'i32, 501,
+    0x0A7A0'i32, 501,
+    0x0A7A2'i32, 501,
+    0x0A7A4'i32, 501,
+    0x0A7A6'i32, 501,
+    0x0A7A8'i32, 501,
+    0x0A7AA'i32, -41808,
+    0x0A7AB'i32, -41819,
+    0x0A7AC'i32, -41815,
+    0x0A7AD'i32, -41805,
+    0x0A7AE'i32, -41808,
+    0x0A7B0'i32, -41758,
+    0x0A7B1'i32, -41782,
+    0x0A7B2'i32, -41761,
+    0x0A7B3'i32, 1428,
+    0x0A7B4'i32, 501,
+    0x0A7B6'i32, 501,
+    0x0A7B8'i32, 501,
+    0x0A7BA'i32, 501,
+    0x0A7BC'i32, 501,
+    0x0A7BE'i32, 501,
+    0x0A7C2'i32, 501,
+    0x0A7C4'i32, 452,
+    0x0A7C5'i32, -41807,
+    0x0A7C6'i32, -34884,
+  ]
+
+  toUpperRanges = [
+    0x00061'i32, 0x0007A'i32, 468,
+    0x000E0'i32, 0x000F6'i32, 468,
+    0x000F8'i32, 0x000FE'i32, 468,
+    0x0023F'i32, 0x00240'i32, 11315,
+    0x00256'i32, 0x00257'i32, 295,
+    0x0028A'i32, 0x0028B'i32, 283,
+    0x0037B'i32, 0x0037D'i32, 630,
+    0x003AD'i32, 0x003AF'i32, 463,
+    0x003B1'i32, 0x003C1'i32, 468,
+    0x003C3'i32, 0x003CB'i32, 468,
+    0x003CD'i32, 0x003CE'i32, 437,
+    0x00430'i32, 0x0044F'i32, 468,
+    0x00450'i32, 0x0045F'i32, 420,
+    0x00561'i32, 0x00586'i32, 452,
+    0x010D0'i32, 0x010FA'i32, 3508,
+    0x010FD'i32, 0x010FF'i32, 3508,
+    0x013F8'i32, 0x013FD'i32, 492,
+    0x01C83'i32, 0x01C84'i32, -5742,
+    0x01F00'i32, 0x01F07'i32, 508,
+    0x01F10'i32, 0x01F15'i32, 508,
+    0x01F20'i32, 0x01F27'i32, 508,
+    0x01F30'i32, 0x01F37'i32, 508,
+    0x01F40'i32, 0x01F45'i32, 508,
+    0x01F60'i32, 0x01F67'i32, 508,
+    0x01F70'i32, 0x01F71'i32, 574,
+    0x01F72'i32, 0x01F75'i32, 586,
+    0x01F76'i32, 0x01F77'i32, 600,
+    0x01F78'i32, 0x01F79'i32, 628,
+    0x01F7A'i32, 0x01F7B'i32, 612,
+    0x01F7C'i32, 0x01F7D'i32, 626,
+    0x01F80'i32, 0x01F87'i32, 508,
+    0x01F90'i32, 0x01F97'i32, 508,
+    0x01FA0'i32, 0x01FA7'i32, 508,
+    0x01FB0'i32, 0x01FB1'i32, 508,
+    0x01FD0'i32, 0x01FD1'i32, 508,
+    0x01FE0'i32, 0x01FE1'i32, 508,
+    0x02C30'i32, 0x02C5E'i32, 452,
+    0x02D00'i32, 0x02D25'i32, -6764,
+    0x0AB70'i32, 0x0ABBF'i32, -38364,
+    0x0FF41'i32, 0x0FF5A'i32, 468,
+    0x10428'i32, 0x1044F'i32, 460,
+    0x104D8'i32, 0x104FB'i32, 460,
+    0x10CC0'i32, 0x10CF2'i32, 436,
+    0x118C0'i32, 0x118DF'i32, 468,
+    0x16E60'i32, 0x16E7F'i32, 468,
+    0x1E922'i32, 0x1E943'i32, 466,
+  ]
+
+  toUpperSinglets = [
+    0x000B5'i32, 1243,
+    0x000FF'i32, 621,
+    0x00101'i32, 499,
+    0x00103'i32, 499,
+    0x00105'i32, 499,
+    0x00107'i32, 499,
+    0x00109'i32, 499,
+    0x0010B'i32, 499,
+    0x0010D'i32, 499,
+    0x0010F'i32, 499,
+    0x00111'i32, 499,
+    0x00113'i32, 499,
+    0x00115'i32, 499,
+    0x00117'i32, 499,
+    0x00119'i32, 499,
+    0x0011B'i32, 499,
+    0x0011D'i32, 499,
+    0x0011F'i32, 499,
+    0x00121'i32, 499,
+    0x00123'i32, 499,
+    0x00125'i32, 499,
+    0x00127'i32, 499,
+    0x00129'i32, 499,
+    0x0012B'i32, 499,
+    0x0012D'i32, 499,
+    0x0012F'i32, 499,
+    0x00131'i32, 268,
+    0x00133'i32, 499,
+    0x00135'i32, 499,
+    0x00137'i32, 499,
+    0x0013A'i32, 499,
+    0x0013C'i32, 499,
+    0x0013E'i32, 499,
+    0x00140'i32, 499,
+    0x00142'i32, 499,
+    0x00144'i32, 499,
+    0x00146'i32, 499,
+    0x00148'i32, 499,
+    0x0014B'i32, 499,
+    0x0014D'i32, 499,
+    0x0014F'i32, 499,
+    0x00151'i32, 499,
+    0x00153'i32, 499,
+    0x00155'i32, 499,
+    0x00157'i32, 499,
+    0x00159'i32, 499,
+    0x0015B'i32, 499,
+    0x0015D'i32, 499,
+    0x0015F'i32, 499,
+    0x00161'i32, 499,
+    0x00163'i32, 499,
+    0x00165'i32, 499,
+    0x00167'i32, 499,
+    0x00169'i32, 499,
+    0x0016B'i32, 499,
+    0x0016D'i32, 499,
+    0x0016F'i32, 499,
+    0x00171'i32, 499,
+    0x00173'i32, 499,
+    0x00175'i32, 499,
+    0x00177'i32, 499,
+    0x0017A'i32, 499,
+    0x0017C'i32, 499,
+    0x0017E'i32, 499,
+    0x0017F'i32, 200,
+    0x00180'i32, 695,
+    0x00183'i32, 499,
+    0x00185'i32, 499,
+    0x00188'i32, 499,
+    0x0018C'i32, 499,
+    0x00192'i32, 499,
+    0x00195'i32, 597,
+    0x00199'i32, 499,
+    0x0019A'i32, 663,
+    0x0019E'i32, 630,
+    0x001A1'i32, 499,
+    0x001A3'i32, 499,
+    0x001A5'i32, 499,
+    0x001A8'i32, 499,
+    0x001AD'i32, 499,
+    0x001B0'i32, 499,
+    0x001B4'i32, 499,
+    0x001B6'i32, 499,
+    0x001B9'i32, 499,
+    0x001BD'i32, 499,
+    0x001BF'i32, 556,
+    0x001C5'i32, 499,
+    0x001C6'i32, 498,
+    0x001C8'i32, 499,
+    0x001C9'i32, 498,
+    0x001CB'i32, 499,
+    0x001CC'i32, 498,
+    0x001CE'i32, 499,
+    0x001D0'i32, 499,
+    0x001D2'i32, 499,
+    0x001D4'i32, 499,
+    0x001D6'i32, 499,
+    0x001D8'i32, 499,
+    0x001DA'i32, 499,
+    0x001DC'i32, 499,
+    0x001DD'i32, 421,
+    0x001DF'i32, 499,
+    0x001E1'i32, 499,
+    0x001E3'i32, 499,
+    0x001E5'i32, 499,
+    0x001E7'i32, 499,
+    0x001E9'i32, 499,
+    0x001EB'i32, 499,
+    0x001ED'i32, 499,
+    0x001EF'i32, 499,
+    0x001F2'i32, 499,
+    0x001F3'i32, 498,
+    0x001F5'i32, 499,
+    0x001F9'i32, 499,
+    0x001FB'i32, 499,
+    0x001FD'i32, 499,
+    0x001FF'i32, 499,
+    0x00201'i32, 499,
+    0x00203'i32, 499,
+    0x00205'i32, 499,
+    0x00207'i32, 499,
+    0x00209'i32, 499,
+    0x0020B'i32, 499,
+    0x0020D'i32, 499,
+    0x0020F'i32, 499,
+    0x00211'i32, 499,
+    0x00213'i32, 499,
+    0x00215'i32, 499,
+    0x00217'i32, 499,
+    0x00219'i32, 499,
+    0x0021B'i32, 499,
+    0x0021D'i32, 499,
+    0x0021F'i32, 499,
+    0x00223'i32, 499,
+    0x00225'i32, 499,
+    0x00227'i32, 499,
+    0x00229'i32, 499,
+    0x0022B'i32, 499,
+    0x0022D'i32, 499,
+    0x0022F'i32, 499,
+    0x00231'i32, 499,
+    0x00233'i32, 499,
+    0x0023C'i32, 499,
+    0x00242'i32, 499,
+    0x00247'i32, 499,
+    0x00249'i32, 499,
+    0x0024B'i32, 499,
+    0x0024D'i32, 499,
+    0x0024F'i32, 499,
+    0x00250'i32, 11283,
+    0x00251'i32, 11280,
+    0x00252'i32, 11282,
+    0x00253'i32, 290,
+    0x00254'i32, 294,
+    0x00259'i32, 298,
+    0x0025B'i32, 297,
+    0x0025C'i32, 42819,
+    0x00260'i32, 295,
+    0x00261'i32, 42815,
+    0x00263'i32, 293,
+    0x00265'i32, 42780,
+    0x00266'i32, 42808,
+    0x00268'i32, 291,
+    0x00269'i32, 289,
+    0x0026A'i32, 42808,
+    0x0026B'i32, 11243,
+    0x0026C'i32, 42805,
+    0x0026F'i32, 289,
+    0x00271'i32, 11249,
+    0x00272'i32, 287,
+    0x00275'i32, 286,
+    0x0027D'i32, 11227,
+    0x00280'i32, 282,
+    0x00282'i32, 42807,
+    0x00283'i32, 282,
+    0x00287'i32, 42782,
+    0x00288'i32, 282,
+    0x00289'i32, 431,
+    0x0028C'i32, 429,
+    0x00292'i32, 281,
+    0x0029D'i32, 42761,
+    0x0029E'i32, 42758,
+    0x00371'i32, 499,
+    0x00373'i32, 499,
+    0x00377'i32, 499,
+    0x003AC'i32, 462,
+    0x003C2'i32, 469,
+    0x003CC'i32, 436,
+    0x003D0'i32, 438,
+    0x003D1'i32, 443,
+    0x003D5'i32, 453,
+    0x003D6'i32, 446,
+    0x003D7'i32, 492,
+    0x003D9'i32, 499,
+    0x003DB'i32, 499,
+    0x003DD'i32, 499,
+    0x003DF'i32, 499,
+    0x003E1'i32, 499,
+    0x003E3'i32, 499,
+    0x003E5'i32, 499,
+    0x003E7'i32, 499,
+    0x003E9'i32, 499,
+    0x003EB'i32, 499,
+    0x003ED'i32, 499,
+    0x003EF'i32, 499,
+    0x003F0'i32, 414,
+    0x003F1'i32, 420,
+    0x003F2'i32, 507,
+    0x003F3'i32, 384,
+    0x003F5'i32, 404,
+    0x003F8'i32, 499,
+    0x003FB'i32, 499,
+    0x00461'i32, 499,
+    0x00463'i32, 499,
+    0x00465'i32, 499,
+    0x00467'i32, 499,
+    0x00469'i32, 499,
+    0x0046B'i32, 499,
+    0x0046D'i32, 499,
+    0x0046F'i32, 499,
+    0x00471'i32, 499,
+    0x00473'i32, 499,
+    0x00475'i32, 499,
+    0x00477'i32, 499,
+    0x00479'i32, 499,
+    0x0047B'i32, 499,
+    0x0047D'i32, 499,
+    0x0047F'i32, 499,
+    0x00481'i32, 499,
+    0x0048B'i32, 499,
+    0x0048D'i32, 499,
+    0x0048F'i32, 499,
+    0x00491'i32, 499,
+    0x00493'i32, 499,
+    0x00495'i32, 499,
+    0x00497'i32, 499,
+    0x00499'i32, 499,
+    0x0049B'i32, 499,
+    0x0049D'i32, 499,
+    0x0049F'i32, 499,
+    0x004A1'i32, 499,
+    0x004A3'i32, 499,
+    0x004A5'i32, 499,
+    0x004A7'i32, 499,
+    0x004A9'i32, 499,
+    0x004AB'i32, 499,
+    0x004AD'i32, 499,
+    0x004AF'i32, 499,
+    0x004B1'i32, 499,
+    0x004B3'i32, 499,
+    0x004B5'i32, 499,
+    0x004B7'i32, 499,
+    0x004B9'i32, 499,
+    0x004BB'i32, 499,
+    0x004BD'i32, 499,
+    0x004BF'i32, 499,
+    0x004C2'i32, 499,
+    0x004C4'i32, 499,
+    0x004C6'i32, 499,
+    0x004C8'i32, 499,
+    0x004CA'i32, 499,
+    0x004CC'i32, 499,
+    0x004CE'i32, 499,
+    0x004CF'i32, 485,
+    0x004D1'i32, 499,
+    0x004D3'i32, 499,
+    0x004D5'i32, 499,
+    0x004D7'i32, 499,
+    0x004D9'i32, 499,
+    0x004DB'i32, 499,
+    0x004DD'i32, 499,
+    0x004DF'i32, 499,
+    0x004E1'i32, 499,
+    0x004E3'i32, 499,
+    0x004E5'i32, 499,
+    0x004E7'i32, 499,
+    0x004E9'i32, 499,
+    0x004EB'i32, 499,
+    0x004ED'i32, 499,
+    0x004EF'i32, 499,
+    0x004F1'i32, 499,
+    0x004F3'i32, 499,
+    0x004F5'i32, 499,
+    0x004F7'i32, 499,
+    0x004F9'i32, 499,
+    0x004FB'i32, 499,
+    0x004FD'i32, 499,
+    0x004FF'i32, 499,
+    0x00501'i32, 499,
+    0x00503'i32, 499,
+    0x00505'i32, 499,
+    0x00507'i32, 499,
+    0x00509'i32, 499,
+    0x0050B'i32, 499,
+    0x0050D'i32, 499,
+    0x0050F'i32, 499,
+    0x00511'i32, 499,
+    0x00513'i32, 499,
+    0x00515'i32, 499,
+    0x00517'i32, 499,
+    0x00519'i32, 499,
+    0x0051B'i32, 499,
+    0x0051D'i32, 499,
+    0x0051F'i32, 499,
+    0x00521'i32, 499,
+    0x00523'i32, 499,
+    0x00525'i32, 499,
+    0x00527'i32, 499,
+    0x00529'i32, 499,
+    0x0052B'i32, 499,
+    0x0052D'i32, 499,
+    0x0052F'i32, 499,
+    0x01C80'i32, -5754,
+    0x01C81'i32, -5753,
+    0x01C82'i32, -5744,
+    0x01C85'i32, -5743,
+    0x01C86'i32, -5736,
+    0x01C87'i32, -5681,
+    0x01C88'i32, 35766,
+    0x01D79'i32, 35832,
+    0x01D7D'i32, 4314,
+    0x01D8E'i32, 35884,
+    0x01E01'i32, 499,
+    0x01E03'i32, 499,
+    0x01E05'i32, 499,
+    0x01E07'i32, 499,
+    0x01E09'i32, 499,
+    0x01E0B'i32, 499,
+    0x01E0D'i32, 499,
+    0x01E0F'i32, 499,
+    0x01E11'i32, 499,
+    0x01E13'i32, 499,
+    0x01E15'i32, 499,
+    0x01E17'i32, 499,
+    0x01E19'i32, 499,
+    0x01E1B'i32, 499,
+    0x01E1D'i32, 499,
+    0x01E1F'i32, 499,
+    0x01E21'i32, 499,
+    0x01E23'i32, 499,
+    0x01E25'i32, 499,
+    0x01E27'i32, 499,
+    0x01E29'i32, 499,
+    0x01E2B'i32, 499,
+    0x01E2D'i32, 499,
+    0x01E2F'i32, 499,
+    0x01E31'i32, 499,
+    0x01E33'i32, 499,
+    0x01E35'i32, 499,
+    0x01E37'i32, 499,
+    0x01E39'i32, 499,
+    0x01E3B'i32, 499,
+    0x01E3D'i32, 499,
+    0x01E3F'i32, 499,
+    0x01E41'i32, 499,
+    0x01E43'i32, 499,
+    0x01E45'i32, 499,
+    0x01E47'i32, 499,
+    0x01E49'i32, 499,
+    0x01E4B'i32, 499,
+    0x01E4D'i32, 499,
+    0x01E4F'i32, 499,
+    0x01E51'i32, 499,
+    0x01E53'i32, 499,
+    0x01E55'i32, 499,
+    0x01E57'i32, 499,
+    0x01E59'i32, 499,
+    0x01E5B'i32, 499,
+    0x01E5D'i32, 499,
+    0x01E5F'i32, 499,
+    0x01E61'i32, 499,
+    0x01E63'i32, 499,
+    0x01E65'i32, 499,
+    0x01E67'i32, 499,
+    0x01E69'i32, 499,
+    0x01E6B'i32, 499,
+    0x01E6D'i32, 499,
+    0x01E6F'i32, 499,
+    0x01E71'i32, 499,
+    0x01E73'i32, 499,
+    0x01E75'i32, 499,
+    0x01E77'i32, 499,
+    0x01E79'i32, 499,
+    0x01E7B'i32, 499,
+    0x01E7D'i32, 499,
+    0x01E7F'i32, 499,
+    0x01E81'i32, 499,
+    0x01E83'i32, 499,
+    0x01E85'i32, 499,
+    0x01E87'i32, 499,
+    0x01E89'i32, 499,
+    0x01E8B'i32, 499,
+    0x01E8D'i32, 499,
+    0x01E8F'i32, 499,
+    0x01E91'i32, 499,
+    0x01E93'i32, 499,
+    0x01E95'i32, 499,
+    0x01E9B'i32, 441,
+    0x01EA1'i32, 499,
+    0x01EA3'i32, 499,
+    0x01EA5'i32, 499,
+    0x01EA7'i32, 499,
+    0x01EA9'i32, 499,
+    0x01EAB'i32, 499,
+    0x01EAD'i32, 499,
+    0x01EAF'i32, 499,
+    0x01EB1'i32, 499,
+    0x01EB3'i32, 499,
+    0x01EB5'i32, 499,
+    0x01EB7'i32, 499,
+    0x01EB9'i32, 499,
+    0x01EBB'i32, 499,
+    0x01EBD'i32, 499,
+    0x01EBF'i32, 499,
+    0x01EC1'i32, 499,
+    0x01EC3'i32, 499,
+    0x01EC5'i32, 499,
+    0x01EC7'i32, 499,
+    0x01EC9'i32, 499,
+    0x01ECB'i32, 499,
+    0x01ECD'i32, 499,
+    0x01ECF'i32, 499,
+    0x01ED1'i32, 499,
+    0x01ED3'i32, 499,
+    0x01ED5'i32, 499,
+    0x01ED7'i32, 499,
+    0x01ED9'i32, 499,
+    0x01EDB'i32, 499,
+    0x01EDD'i32, 499,
+    0x01EDF'i32, 499,
+    0x01EE1'i32, 499,
+    0x01EE3'i32, 499,
+    0x01EE5'i32, 499,
+    0x01EE7'i32, 499,
+    0x01EE9'i32, 499,
+    0x01EEB'i32, 499,
+    0x01EED'i32, 499,
+    0x01EEF'i32, 499,
+    0x01EF1'i32, 499,
+    0x01EF3'i32, 499,
+    0x01EF5'i32, 499,
+    0x01EF7'i32, 499,
+    0x01EF9'i32, 499,
+    0x01EFB'i32, 499,
+    0x01EFD'i32, 499,
+    0x01EFF'i32, 499,
+    0x01F51'i32, 508,
+    0x01F53'i32, 508,
+    0x01F55'i32, 508,
+    0x01F57'i32, 508,
+    0x01FB3'i32, 509,
+    0x01FBE'i32, -6705,
+    0x01FC3'i32, 509,
+    0x01FE5'i32, 507,
+    0x01FF3'i32, 509,
+    0x0214E'i32, 472,
+    0x02184'i32, 499,
+    0x02C61'i32, 499,
+    0x02C65'i32, -10295,
+    0x02C66'i32, -10292,
+    0x02C68'i32, 499,
+    0x02C6A'i32, 499,
+    0x02C6C'i32, 499,
+    0x02C73'i32, 499,
+    0x02C76'i32, 499,
+    0x02C81'i32, 499,
+    0x02C83'i32, 499,
+    0x02C85'i32, 499,
+    0x02C87'i32, 499,
+    0x02C89'i32, 499,
+    0x02C8B'i32, 499,
+    0x02C8D'i32, 499,
+    0x02C8F'i32, 499,
+    0x02C91'i32, 499,
+    0x02C93'i32, 499,
+    0x02C95'i32, 499,
+    0x02C97'i32, 499,
+    0x02C99'i32, 499,
+    0x02C9B'i32, 499,
+    0x02C9D'i32, 499,
+    0x02C9F'i32, 499,
+    0x02CA1'i32, 499,
+    0x02CA3'i32, 499,
+    0x02CA5'i32, 499,
+    0x02CA7'i32, 499,
+    0x02CA9'i32, 499,
+    0x02CAB'i32, 499,
+    0x02CAD'i32, 499,
+    0x02CAF'i32, 499,
+    0x02CB1'i32, 499,
+    0x02CB3'i32, 499,
+    0x02CB5'i32, 499,
+    0x02CB7'i32, 499,
+    0x02CB9'i32, 499,
+    0x02CBB'i32, 499,
+    0x02CBD'i32, 499,
+    0x02CBF'i32, 499,
+    0x02CC1'i32, 499,
+    0x02CC3'i32, 499,
+    0x02CC5'i32, 499,
+    0x02CC7'i32, 499,
+    0x02CC9'i32, 499,
+    0x02CCB'i32, 499,
+    0x02CCD'i32, 499,
+    0x02CCF'i32, 499,
+    0x02CD1'i32, 499,
+    0x02CD3'i32, 499,
+    0x02CD5'i32, 499,
+    0x02CD7'i32, 499,
+    0x02CD9'i32, 499,
+    0x02CDB'i32, 499,
+    0x02CDD'i32, 499,
+    0x02CDF'i32, 499,
+    0x02CE1'i32, 499,
+    0x02CE3'i32, 499,
+    0x02CEC'i32, 499,
+    0x02CEE'i32, 499,
+    0x02CF3'i32, 499,
+    0x02D27'i32, -6764,
+    0x02D2D'i32, -6764,
+    0x0A641'i32, 499,
+    0x0A643'i32, 499,
+    0x0A645'i32, 499,
+    0x0A647'i32, 499,
+    0x0A649'i32, 499,
+    0x0A64B'i32, 499,
+    0x0A64D'i32, 499,
+    0x0A64F'i32, 499,
+    0x0A651'i32, 499,
+    0x0A653'i32, 499,
+    0x0A655'i32, 499,
+    0x0A657'i32, 499,
+    0x0A659'i32, 499,
+    0x0A65B'i32, 499,
+    0x0A65D'i32, 499,
+    0x0A65F'i32, 499,
+    0x0A661'i32, 499,
+    0x0A663'i32, 499,
+    0x0A665'i32, 499,
+    0x0A667'i32, 499,
+    0x0A669'i32, 499,
+    0x0A66B'i32, 499,
+    0x0A66D'i32, 499,
+    0x0A681'i32, 499,
+    0x0A683'i32, 499,
+    0x0A685'i32, 499,
+    0x0A687'i32, 499,
+    0x0A689'i32, 499,
+    0x0A68B'i32, 499,
+    0x0A68D'i32, 499,
+    0x0A68F'i32, 499,
+    0x0A691'i32, 499,
+    0x0A693'i32, 499,
+    0x0A695'i32, 499,
+    0x0A697'i32, 499,
+    0x0A699'i32, 499,
+    0x0A69B'i32, 499,
+    0x0A723'i32, 499,
+    0x0A725'i32, 499,
+    0x0A727'i32, 499,
+    0x0A729'i32, 499,
+    0x0A72B'i32, 499,
+    0x0A72D'i32, 499,
+    0x0A72F'i32, 499,
+    0x0A733'i32, 499,
+    0x0A735'i32, 499,
+    0x0A737'i32, 499,
+    0x0A739'i32, 499,
+    0x0A73B'i32, 499,
+    0x0A73D'i32, 499,
+    0x0A73F'i32, 499,
+    0x0A741'i32, 499,
+    0x0A743'i32, 499,
+    0x0A745'i32, 499,
+    0x0A747'i32, 499,
+    0x0A749'i32, 499,
+    0x0A74B'i32, 499,
+    0x0A74D'i32, 499,
+    0x0A74F'i32, 499,
+    0x0A751'i32, 499,
+    0x0A753'i32, 499,
+    0x0A755'i32, 499,
+    0x0A757'i32, 499,
+    0x0A759'i32, 499,
+    0x0A75B'i32, 499,
+    0x0A75D'i32, 499,
+    0x0A75F'i32, 499,
+    0x0A761'i32, 499,
+    0x0A763'i32, 499,
+    0x0A765'i32, 499,
+    0x0A767'i32, 499,
+    0x0A769'i32, 499,
+    0x0A76B'i32, 499,
+    0x0A76D'i32, 499,
+    0x0A76F'i32, 499,
+    0x0A77A'i32, 499,
+    0x0A77C'i32, 499,
+    0x0A77F'i32, 499,
+    0x0A781'i32, 499,
+    0x0A783'i32, 499,
+    0x0A785'i32, 499,
+    0x0A787'i32, 499,
+    0x0A78C'i32, 499,
+    0x0A791'i32, 499,
+    0x0A793'i32, 499,
+    0x0A794'i32, 548,
+    0x0A797'i32, 499,
+    0x0A799'i32, 499,
+    0x0A79B'i32, 499,
+    0x0A79D'i32, 499,
+    0x0A79F'i32, 499,
+    0x0A7A1'i32, 499,
+    0x0A7A3'i32, 499,
+    0x0A7A5'i32, 499,
+    0x0A7A7'i32, 499,
+    0x0A7A9'i32, 499,
+    0x0A7B5'i32, 499,
+    0x0A7B7'i32, 499,
+    0x0A7B9'i32, 499,
+    0x0A7BB'i32, 499,
+    0x0A7BD'i32, 499,
+    0x0A7BF'i32, 499,
+    0x0A7C3'i32, 499,
+    0x0AB53'i32, -428,
+  ]
+
+  toTitleSinglets = [
+    0x001C4'i32, 501,
+    0x001C6'i32, 499,
+    0x001C7'i32, 501,
+    0x001C9'i32, 499,
+    0x001CA'i32, 501,
+    0x001CC'i32, 499,
+    0x001F1'i32, 501,
+    0x001F3'i32, 499,
+  ]
+
+  alphaRanges = [
+    0x00041'i32, 0x0005A'i32,
+    0x00061'i32, 0x0007A'i32,
+    0x000C0'i32, 0x000D6'i32,
+    0x000D8'i32, 0x000F6'i32,
+    0x000F8'i32, 0x002C1'i32,
+    0x002C6'i32, 0x002D1'i32,
+    0x002E0'i32, 0x002E4'i32,
+    0x00370'i32, 0x00374'i32,
+    0x00376'i32, 0x00377'i32,
+    0x0037A'i32, 0x0037D'i32,
+    0x00388'i32, 0x0038A'i32,
+    0x0038E'i32, 0x003A1'i32,
+    0x003A3'i32, 0x003F5'i32,
+    0x003F7'i32, 0x00481'i32,
+    0x0048A'i32, 0x0052F'i32,
+    0x00531'i32, 0x00556'i32,
+    0x00560'i32, 0x00588'i32,
+    0x005D0'i32, 0x005EA'i32,
+    0x005EF'i32, 0x005F2'i32,
+    0x00620'i32, 0x0064A'i32,
+    0x0066E'i32, 0x0066F'i32,
+    0x00671'i32, 0x006D3'i32,
+    0x006E5'i32, 0x006E6'i32,
+    0x006EE'i32, 0x006EF'i32,
+    0x006FA'i32, 0x006FC'i32,
+    0x00712'i32, 0x0072F'i32,
+    0x0074D'i32, 0x007A5'i32,
+    0x007CA'i32, 0x007EA'i32,
+    0x007F4'i32, 0x007F5'i32,
+    0x00800'i32, 0x00815'i32,
+    0x00840'i32, 0x00858'i32,
+    0x00860'i32, 0x0086A'i32,
+    0x008A0'i32, 0x008B4'i32,
+    0x008B6'i32, 0x008BD'i32,
+    0x00904'i32, 0x00939'i32,
+    0x00958'i32, 0x00961'i32,
+    0x00971'i32, 0x00980'i32,
+    0x00985'i32, 0x0098C'i32,
+    0x0098F'i32, 0x00990'i32,
+    0x00993'i32, 0x009A8'i32,
+    0x009AA'i32, 0x009B0'i32,
+    0x009B6'i32, 0x009B9'i32,
+    0x009DC'i32, 0x009DD'i32,
+    0x009DF'i32, 0x009E1'i32,
+    0x009F0'i32, 0x009F1'i32,
+    0x00A05'i32, 0x00A0A'i32,
+    0x00A0F'i32, 0x00A10'i32,
+    0x00A13'i32, 0x00A28'i32,
+    0x00A2A'i32, 0x00A30'i32,
+    0x00A32'i32, 0x00A33'i32,
+    0x00A35'i32, 0x00A36'i32,
+    0x00A38'i32, 0x00A39'i32,
+    0x00A59'i32, 0x00A5C'i32,
+    0x00A72'i32, 0x00A74'i32,
+    0x00A85'i32, 0x00A8D'i32,
+    0x00A8F'i32, 0x00A91'i32,
+    0x00A93'i32, 0x00AA8'i32,
+    0x00AAA'i32, 0x00AB0'i32,
+    0x00AB2'i32, 0x00AB3'i32,
+    0x00AB5'i32, 0x00AB9'i32,
+    0x00AE0'i32, 0x00AE1'i32,
+    0x00B05'i32, 0x00B0C'i32,
+    0x00B0F'i32, 0x00B10'i32,
+    0x00B13'i32, 0x00B28'i32,
+    0x00B2A'i32, 0x00B30'i32,
+    0x00B32'i32, 0x00B33'i32,
+    0x00B35'i32, 0x00B39'i32,
+    0x00B5C'i32, 0x00B5D'i32,
+    0x00B5F'i32, 0x00B61'i32,
+    0x00B85'i32, 0x00B8A'i32,
+    0x00B8E'i32, 0x00B90'i32,
+    0x00B92'i32, 0x00B95'i32,
+    0x00B99'i32, 0x00B9A'i32,
+    0x00B9E'i32, 0x00B9F'i32,
+    0x00BA3'i32, 0x00BA4'i32,
+    0x00BA8'i32, 0x00BAA'i32,
+    0x00BAE'i32, 0x00BB9'i32,
+    0x00C05'i32, 0x00C0C'i32,
+    0x00C0E'i32, 0x00C10'i32,
+    0x00C12'i32, 0x00C28'i32,
+    0x00C2A'i32, 0x00C39'i32,
+    0x00C58'i32, 0x00C5A'i32,
+    0x00C60'i32, 0x00C61'i32,
+    0x00C85'i32, 0x00C8C'i32,
+    0x00C8E'i32, 0x00C90'i32,
+    0x00C92'i32, 0x00CA8'i32,
+    0x00CAA'i32, 0x00CB3'i32,
+    0x00CB5'i32, 0x00CB9'i32,
+    0x00CE0'i32, 0x00CE1'i32,
+    0x00CF1'i32, 0x00CF2'i32,
+    0x00D05'i32, 0x00D0C'i32,
+    0x00D0E'i32, 0x00D10'i32,
+    0x00D12'i32, 0x00D3A'i32,
+    0x00D54'i32, 0x00D56'i32,
+    0x00D5F'i32, 0x00D61'i32,
+    0x00D7A'i32, 0x00D7F'i32,
+    0x00D85'i32, 0x00D96'i32,
+    0x00D9A'i32, 0x00DB1'i32,
+    0x00DB3'i32, 0x00DBB'i32,
+    0x00DC0'i32, 0x00DC6'i32,
+    0x00E01'i32, 0x00E30'i32,
+    0x00E32'i32, 0x00E33'i32,
+    0x00E40'i32, 0x00E46'i32,
+    0x00E81'i32, 0x00E82'i32,
+    0x00E86'i32, 0x00E8A'i32,
+    0x00E8C'i32, 0x00EA3'i32,
+    0x00EA7'i32, 0x00EB0'i32,
+    0x00EB2'i32, 0x00EB3'i32,
+    0x00EC0'i32, 0x00EC4'i32,
+    0x00EDC'i32, 0x00EDF'i32,
+    0x00F40'i32, 0x00F47'i32,
+    0x00F49'i32, 0x00F6C'i32,
+    0x00F88'i32, 0x00F8C'i32,
+    0x01000'i32, 0x0102A'i32,
+    0x01050'i32, 0x01055'i32,
+    0x0105A'i32, 0x0105D'i32,
+    0x01065'i32, 0x01066'i32,
+    0x0106E'i32, 0x01070'i32,
+    0x01075'i32, 0x01081'i32,
+    0x010A0'i32, 0x010C5'i32,
+    0x010D0'i32, 0x010FA'i32,
+    0x010FC'i32, 0x01248'i32,
+    0x0124A'i32, 0x0124D'i32,
+    0x01250'i32, 0x01256'i32,
+    0x0125A'i32, 0x0125D'i32,
+    0x01260'i32, 0x01288'i32,
+    0x0128A'i32, 0x0128D'i32,
+    0x01290'i32, 0x012B0'i32,
+    0x012B2'i32, 0x012B5'i32,
+    0x012B8'i32, 0x012BE'i32,
+    0x012C2'i32, 0x012C5'i32,
+    0x012C8'i32, 0x012D6'i32,
+    0x012D8'i32, 0x01310'i32,
+    0x01312'i32, 0x01315'i32,
+    0x01318'i32, 0x0135A'i32,
+    0x01380'i32, 0x0138F'i32,
+    0x013A0'i32, 0x013F5'i32,
+    0x013F8'i32, 0x013FD'i32,
+    0x01401'i32, 0x0166C'i32,
+    0x0166F'i32, 0x0167F'i32,
+    0x01681'i32, 0x0169A'i32,
+    0x016A0'i32, 0x016EA'i32,
+    0x016F1'i32, 0x016F8'i32,
+    0x01700'i32, 0x0170C'i32,
+    0x0170E'i32, 0x01711'i32,
+    0x01720'i32, 0x01731'i32,
+    0x01740'i32, 0x01751'i32,
+    0x01760'i32, 0x0176C'i32,
+    0x0176E'i32, 0x01770'i32,
+    0x01780'i32, 0x017B3'i32,
+    0x01820'i32, 0x01878'i32,
+    0x01880'i32, 0x01884'i32,
+    0x01887'i32, 0x018A8'i32,
+    0x018B0'i32, 0x018F5'i32,
+    0x01900'i32, 0x0191E'i32,
+    0x01950'i32, 0x0196D'i32,
+    0x01970'i32, 0x01974'i32,
+    0x01980'i32, 0x019AB'i32,
+    0x019B0'i32, 0x019C9'i32,
+    0x01A00'i32, 0x01A16'i32,
+    0x01A20'i32, 0x01A54'i32,
+    0x01B05'i32, 0x01B33'i32,
+    0x01B45'i32, 0x01B4B'i32,
+    0x01B83'i32, 0x01BA0'i32,
+    0x01BAE'i32, 0x01BAF'i32,
+    0x01BBA'i32, 0x01BE5'i32,
+    0x01C00'i32, 0x01C23'i32,
+    0x01C4D'i32, 0x01C4F'i32,
+    0x01C5A'i32, 0x01C7D'i32,
+    0x01C80'i32, 0x01C88'i32,
+    0x01C90'i32, 0x01CBA'i32,
+    0x01CBD'i32, 0x01CBF'i32,
+    0x01CE9'i32, 0x01CEC'i32,
+    0x01CEE'i32, 0x01CF3'i32,
+    0x01CF5'i32, 0x01CF6'i32,
+    0x01D00'i32, 0x01DBF'i32,
+    0x01E00'i32, 0x01F15'i32,
+    0x01F18'i32, 0x01F1D'i32,
+    0x01F20'i32, 0x01F45'i32,
+    0x01F48'i32, 0x01F4D'i32,
+    0x01F50'i32, 0x01F57'i32,
+    0x01F5F'i32, 0x01F7D'i32,
+    0x01F80'i32, 0x01FB4'i32,
+    0x01FB6'i32, 0x01FBC'i32,
+    0x01FC2'i32, 0x01FC4'i32,
+    0x01FC6'i32, 0x01FCC'i32,
+    0x01FD0'i32, 0x01FD3'i32,
+    0x01FD6'i32, 0x01FDB'i32,
+    0x01FE0'i32, 0x01FEC'i32,
+    0x01FF2'i32, 0x01FF4'i32,
+    0x01FF6'i32, 0x01FFC'i32,
+    0x02090'i32, 0x0209C'i32,
+    0x0210A'i32, 0x02113'i32,
+    0x02119'i32, 0x0211D'i32,
+    0x0212A'i32, 0x0212D'i32,
+    0x0212F'i32, 0x02139'i32,
+    0x0213C'i32, 0x0213F'i32,
+    0x02145'i32, 0x02149'i32,
+    0x02183'i32, 0x02184'i32,
+    0x02C00'i32, 0x02C2E'i32,
+    0x02C30'i32, 0x02C5E'i32,
+    0x02C60'i32, 0x02CE4'i32,
+    0x02CEB'i32, 0x02CEE'i32,
+    0x02CF2'i32, 0x02CF3'i32,
+    0x02D00'i32, 0x02D25'i32,
+    0x02D30'i32, 0x02D67'i32,
+    0x02D80'i32, 0x02D96'i32,
+    0x02DA0'i32, 0x02DA6'i32,
+    0x02DA8'i32, 0x02DAE'i32,
+    0x02DB0'i32, 0x02DB6'i32,
+    0x02DB8'i32, 0x02DBE'i32,
+    0x02DC0'i32, 0x02DC6'i32,
+    0x02DC8'i32, 0x02DCE'i32,
+    0x02DD0'i32, 0x02DD6'i32,
+    0x02DD8'i32, 0x02DDE'i32,
+    0x03005'i32, 0x03006'i32,
+    0x03031'i32, 0x03035'i32,
+    0x0303B'i32, 0x0303C'i32,
+    0x03041'i32, 0x03096'i32,
+    0x0309D'i32, 0x0309F'i32,
+    0x030A1'i32, 0x030FA'i32,
+    0x030FC'i32, 0x030FF'i32,
+    0x03105'i32, 0x0312F'i32,
+    0x03131'i32, 0x0318E'i32,
+    0x031A0'i32, 0x031BA'i32,
+    0x031F0'i32, 0x031FF'i32,
+    0x03400'i32, 0x04DB5'i32,
+    0x04E00'i32, 0x09FEF'i32,
+    0x0A000'i32, 0x0A48C'i32,
+    0x0A4D0'i32, 0x0A4FD'i32,
+    0x0A500'i32, 0x0A60C'i32,
+    0x0A610'i32, 0x0A61F'i32,
+    0x0A62A'i32, 0x0A62B'i32,
+    0x0A640'i32, 0x0A66E'i32,
+    0x0A67F'i32, 0x0A69D'i32,
+    0x0A6A0'i32, 0x0A6E5'i32,
+    0x0A717'i32, 0x0A71F'i32,
+    0x0A722'i32, 0x0A788'i32,
+    0x0A78B'i32, 0x0A7BF'i32,
+    0x0A7C2'i32, 0x0A7C6'i32,
+    0x0A7F7'i32, 0x0A801'i32,
+    0x0A803'i32, 0x0A805'i32,
+    0x0A807'i32, 0x0A80A'i32,
+    0x0A80C'i32, 0x0A822'i32,
+    0x0A840'i32, 0x0A873'i32,
+    0x0A882'i32, 0x0A8B3'i32,
+    0x0A8F2'i32, 0x0A8F7'i32,
+    0x0A8FD'i32, 0x0A8FE'i32,
+    0x0A90A'i32, 0x0A925'i32,
+    0x0A930'i32, 0x0A946'i32,
+    0x0A960'i32, 0x0A97C'i32,
+    0x0A984'i32, 0x0A9B2'i32,
+    0x0A9E0'i32, 0x0A9E4'i32,
+    0x0A9E6'i32, 0x0A9EF'i32,
+    0x0A9FA'i32, 0x0A9FE'i32,
+    0x0AA00'i32, 0x0AA28'i32,
+    0x0AA40'i32, 0x0AA42'i32,
+    0x0AA44'i32, 0x0AA4B'i32,
+    0x0AA60'i32, 0x0AA76'i32,
+    0x0AA7E'i32, 0x0AAAF'i32,
+    0x0AAB5'i32, 0x0AAB6'i32,
+    0x0AAB9'i32, 0x0AABD'i32,
+    0x0AADB'i32, 0x0AADD'i32,
+    0x0AAE0'i32, 0x0AAEA'i32,
+    0x0AAF2'i32, 0x0AAF4'i32,
+    0x0AB01'i32, 0x0AB06'i32,
+    0x0AB09'i32, 0x0AB0E'i32,
+    0x0AB11'i32, 0x0AB16'i32,
+    0x0AB20'i32, 0x0AB26'i32,
+    0x0AB28'i32, 0x0AB2E'i32,
+    0x0AB30'i32, 0x0AB5A'i32,
+    0x0AB5C'i32, 0x0AB67'i32,
+    0x0AB70'i32, 0x0ABE2'i32,
+    0x0AC00'i32, 0x0D7A3'i32,
+    0x0D7B0'i32, 0x0D7C6'i32,
+    0x0D7CB'i32, 0x0D7FB'i32,
+    0x0F900'i32, 0x0FA6D'i32,
+    0x0FA70'i32, 0x0FAD9'i32,
+    0x0FB00'i32, 0x0FB06'i32,
+    0x0FB13'i32, 0x0FB17'i32,
+    0x0FB1F'i32, 0x0FB28'i32,
+    0x0FB2A'i32, 0x0FB36'i32,
+    0x0FB38'i32, 0x0FB3C'i32,
+    0x0FB40'i32, 0x0FB41'i32,
+    0x0FB43'i32, 0x0FB44'i32,
+    0x0FB46'i32, 0x0FBB1'i32,
+    0x0FBD3'i32, 0x0FD3D'i32,
+    0x0FD50'i32, 0x0FD8F'i32,
+    0x0FD92'i32, 0x0FDC7'i32,
+    0x0FDF0'i32, 0x0FDFB'i32,
+    0x0FE70'i32, 0x0FE74'i32,
+    0x0FE76'i32, 0x0FEFC'i32,
+    0x0FF21'i32, 0x0FF3A'i32,
+    0x0FF41'i32, 0x0FF5A'i32,
+    0x0FF66'i32, 0x0FFBE'i32,
+    0x0FFC2'i32, 0x0FFC7'i32,
+    0x0FFCA'i32, 0x0FFCF'i32,
+    0x0FFD2'i32, 0x0FFD7'i32,
+    0x0FFDA'i32, 0x0FFDC'i32,
+    0x10000'i32, 0x1000B'i32,
+    0x1000D'i32, 0x10026'i32,
+    0x10028'i32, 0x1003A'i32,
+    0x1003C'i32, 0x1003D'i32,
+    0x1003F'i32, 0x1004D'i32,
+    0x10050'i32, 0x1005D'i32,
+    0x10080'i32, 0x100FA'i32,
+    0x10280'i32, 0x1029C'i32,
+    0x102A0'i32, 0x102D0'i32,
+    0x10300'i32, 0x1031F'i32,
+    0x1032D'i32, 0x10340'i32,
+    0x10342'i32, 0x10349'i32,
+    0x10350'i32, 0x10375'i32,
+    0x10380'i32, 0x1039D'i32,
+    0x103A0'i32, 0x103C3'i32,
+    0x103C8'i32, 0x103CF'i32,
+    0x10400'i32, 0x1049D'i32,
+    0x104B0'i32, 0x104D3'i32,
+    0x104D8'i32, 0x104FB'i32,
+    0x10500'i32, 0x10527'i32,
+    0x10530'i32, 0x10563'i32,
+    0x10600'i32, 0x10736'i32,
+    0x10740'i32, 0x10755'i32,
+    0x10760'i32, 0x10767'i32,
+    0x10800'i32, 0x10805'i32,
+    0x1080A'i32, 0x10835'i32,
+    0x10837'i32, 0x10838'i32,
+    0x1083F'i32, 0x10855'i32,
+    0x10860'i32, 0x10876'i32,
+    0x10880'i32, 0x1089E'i32,
+    0x108E0'i32, 0x108F2'i32,
+    0x108F4'i32, 0x108F5'i32,
+    0x10900'i32, 0x10915'i32,
+    0x10920'i32, 0x10939'i32,
+    0x10980'i32, 0x109B7'i32,
+    0x109BE'i32, 0x109BF'i32,
+    0x10A10'i32, 0x10A13'i32,
+    0x10A15'i32, 0x10A17'i32,
+    0x10A19'i32, 0x10A35'i32,
+    0x10A60'i32, 0x10A7C'i32,
+    0x10A80'i32, 0x10A9C'i32,
+    0x10AC0'i32, 0x10AC7'i32,
+    0x10AC9'i32, 0x10AE4'i32,
+    0x10B00'i32, 0x10B35'i32,
+    0x10B40'i32, 0x10B55'i32,
+    0x10B60'i32, 0x10B72'i32,
+    0x10B80'i32, 0x10B91'i32,
+    0x10C00'i32, 0x10C48'i32,
+    0x10C80'i32, 0x10CB2'i32,
+    0x10CC0'i32, 0x10CF2'i32,
+    0x10D00'i32, 0x10D23'i32,
+    0x10F00'i32, 0x10F1C'i32,
+    0x10F30'i32, 0x10F45'i32,
+    0x10FE0'i32, 0x10FF6'i32,
+    0x11003'i32, 0x11037'i32,
+    0x11083'i32, 0x110AF'i32,
+    0x110D0'i32, 0x110E8'i32,
+    0x11103'i32, 0x11126'i32,
+    0x11150'i32, 0x11172'i32,
+    0x11183'i32, 0x111B2'i32,
+    0x111C1'i32, 0x111C4'i32,
+    0x11200'i32, 0x11211'i32,
+    0x11213'i32, 0x1122B'i32,
+    0x11280'i32, 0x11286'i32,
+    0x1128A'i32, 0x1128D'i32,
+    0x1128F'i32, 0x1129D'i32,
+    0x1129F'i32, 0x112A8'i32,
+    0x112B0'i32, 0x112DE'i32,
+    0x11305'i32, 0x1130C'i32,
+    0x1130F'i32, 0x11310'i32,
+    0x11313'i32, 0x11328'i32,
+    0x1132A'i32, 0x11330'i32,
+    0x11332'i32, 0x11333'i32,
+    0x11335'i32, 0x11339'i32,
+    0x1135D'i32, 0x11361'i32,
+    0x11400'i32, 0x11434'i32,
+    0x11447'i32, 0x1144A'i32,
+    0x11480'i32, 0x114AF'i32,
+    0x114C4'i32, 0x114C5'i32,
+    0x11580'i32, 0x115AE'i32,
+    0x115D8'i32, 0x115DB'i32,
+    0x11600'i32, 0x1162F'i32,
+    0x11680'i32, 0x116AA'i32,
+    0x11700'i32, 0x1171A'i32,
+    0x11800'i32, 0x1182B'i32,
+    0x118A0'i32, 0x118DF'i32,
+    0x119A0'i32, 0x119A7'i32,
+    0x119AA'i32, 0x119D0'i32,
+    0x11A0B'i32, 0x11A32'i32,
+    0x11A5C'i32, 0x11A89'i32,
+    0x11AC0'i32, 0x11AF8'i32,
+    0x11C00'i32, 0x11C08'i32,
+    0x11C0A'i32, 0x11C2E'i32,
+    0x11C72'i32, 0x11C8F'i32,
+    0x11D00'i32, 0x11D06'i32,
+    0x11D08'i32, 0x11D09'i32,
+    0x11D0B'i32, 0x11D30'i32,
+    0x11D60'i32, 0x11D65'i32,
+    0x11D67'i32, 0x11D68'i32,
+    0x11D6A'i32, 0x11D89'i32,
+    0x11EE0'i32, 0x11EF2'i32,
+    0x12000'i32, 0x12399'i32,
+    0x12480'i32, 0x12543'i32,
+    0x13000'i32, 0x1342E'i32,
+    0x14400'i32, 0x14646'i32,
+    0x16800'i32, 0x16A38'i32,
+    0x16A40'i32, 0x16A5E'i32,
+    0x16AD0'i32, 0x16AED'i32,
+    0x16B00'i32, 0x16B2F'i32,
+    0x16B40'i32, 0x16B43'i32,
+    0x16B63'i32, 0x16B77'i32,
+    0x16B7D'i32, 0x16B8F'i32,
+    0x16E40'i32, 0x16E7F'i32,
+    0x16F00'i32, 0x16F4A'i32,
+    0x16F93'i32, 0x16F9F'i32,
+    0x16FE0'i32, 0x16FE1'i32,
+    0x17000'i32, 0x187F7'i32,
+    0x18800'i32, 0x18AF2'i32,
+    0x1B000'i32, 0x1B11E'i32,
+    0x1B150'i32, 0x1B152'i32,
+    0x1B164'i32, 0x1B167'i32,
+    0x1B170'i32, 0x1B2FB'i32,
+    0x1BC00'i32, 0x1BC6A'i32,
+    0x1BC70'i32, 0x1BC7C'i32,
+    0x1BC80'i32, 0x1BC88'i32,
+    0x1BC90'i32, 0x1BC99'i32,
+    0x1D400'i32, 0x1D454'i32,
+    0x1D456'i32, 0x1D49C'i32,
+    0x1D49E'i32, 0x1D49F'i32,
+    0x1D4A5'i32, 0x1D4A6'i32,
+    0x1D4A9'i32, 0x1D4AC'i32,
+    0x1D4AE'i32, 0x1D4B9'i32,
+    0x1D4BD'i32, 0x1D4C3'i32,
+    0x1D4C5'i32, 0x1D505'i32,
+    0x1D507'i32, 0x1D50A'i32,
+    0x1D50D'i32, 0x1D514'i32,
+    0x1D516'i32, 0x1D51C'i32,
+    0x1D51E'i32, 0x1D539'i32,
+    0x1D53B'i32, 0x1D53E'i32,
+    0x1D540'i32, 0x1D544'i32,
+    0x1D54A'i32, 0x1D550'i32,
+    0x1D552'i32, 0x1D6A5'i32,
+    0x1D6A8'i32, 0x1D6C0'i32,
+    0x1D6C2'i32, 0x1D6DA'i32,
+    0x1D6DC'i32, 0x1D6FA'i32,
+    0x1D6FC'i32, 0x1D714'i32,
+    0x1D716'i32, 0x1D734'i32,
+    0x1D736'i32, 0x1D74E'i32,
+    0x1D750'i32, 0x1D76E'i32,
+    0x1D770'i32, 0x1D788'i32,
+    0x1D78A'i32, 0x1D7A8'i32,
+    0x1D7AA'i32, 0x1D7C2'i32,
+    0x1D7C4'i32, 0x1D7CB'i32,
+    0x1E100'i32, 0x1E12C'i32,
+    0x1E137'i32, 0x1E13D'i32,
+    0x1E2C0'i32, 0x1E2EB'i32,
+    0x1E800'i32, 0x1E8C4'i32,
+    0x1E900'i32, 0x1E943'i32,
+    0x1EE00'i32, 0x1EE03'i32,
+    0x1EE05'i32, 0x1EE1F'i32,
+    0x1EE21'i32, 0x1EE22'i32,
+    0x1EE29'i32, 0x1EE32'i32,
+    0x1EE34'i32, 0x1EE37'i32,
+    0x1EE4D'i32, 0x1EE4F'i32,
+    0x1EE51'i32, 0x1EE52'i32,
+    0x1EE61'i32, 0x1EE62'i32,
+    0x1EE67'i32, 0x1EE6A'i32,
+    0x1EE6C'i32, 0x1EE72'i32,
+    0x1EE74'i32, 0x1EE77'i32,
+    0x1EE79'i32, 0x1EE7C'i32,
+    0x1EE80'i32, 0x1EE89'i32,
+    0x1EE8B'i32, 0x1EE9B'i32,
+    0x1EEA1'i32, 0x1EEA3'i32,
+    0x1EEA5'i32, 0x1EEA9'i32,
+    0x1EEAB'i32, 0x1EEBB'i32,
+    0x20000'i32, 0x2A6D6'i32,
+    0x2A700'i32, 0x2B734'i32,
+    0x2B740'i32, 0x2B81D'i32,
+    0x2B820'i32, 0x2CEA1'i32,
+    0x2CEB0'i32, 0x2EBE0'i32,
+    0x2F800'i32, 0x2FA1D'i32,
+  ]
+
+  alphaSinglets = [
+    0x000AA'i32,
+    0x000B5'i32,
+    0x000BA'i32,
+    0x002EC'i32,
+    0x002EE'i32,
+    0x0037F'i32,
+    0x00386'i32,
+    0x0038C'i32,
+    0x00559'i32,
+    0x006D5'i32,
+    0x006FF'i32,
+    0x00710'i32,
+    0x007B1'i32,
+    0x007FA'i32,
+    0x0081A'i32,
+    0x00824'i32,
+    0x00828'i32,
+    0x0093D'i32,
+    0x00950'i32,
+    0x009B2'i32,
+    0x009BD'i32,
+    0x009CE'i32,
+    0x009FC'i32,
+    0x00A5E'i32,
+    0x00ABD'i32,
+    0x00AD0'i32,
+    0x00AF9'i32,
+    0x00B3D'i32,
+    0x00B71'i32,
+    0x00B83'i32,
+    0x00B9C'i32,
+    0x00BD0'i32,
+    0x00C3D'i32,
+    0x00C80'i32,
+    0x00CBD'i32,
+    0x00CDE'i32,
+    0x00D3D'i32,
+    0x00D4E'i32,
+    0x00DBD'i32,
+    0x00E84'i32,
+    0x00EA5'i32,
+    0x00EBD'i32,
+    0x00EC6'i32,
+    0x00F00'i32,
+    0x0103F'i32,
+    0x01061'i32,
+    0x0108E'i32,
+    0x010C7'i32,
+    0x010CD'i32,
+    0x01258'i32,
+    0x012C0'i32,
+    0x017D7'i32,
+    0x017DC'i32,
+    0x018AA'i32,
+    0x01AA7'i32,
+    0x01CFA'i32,
+    0x01F59'i32,
+    0x01F5B'i32,
+    0x01F5D'i32,
+    0x01FBE'i32,
+    0x02071'i32,
+    0x0207F'i32,
+    0x02102'i32,
+    0x02107'i32,
+    0x02115'i32,
+    0x02124'i32,
+    0x02126'i32,
+    0x02128'i32,
+    0x0214E'i32,
+    0x02D27'i32,
+    0x02D2D'i32,
+    0x02D6F'i32,
+    0x02E2F'i32,
+    0x0A8FB'i32,
+    0x0A9CF'i32,
+    0x0AA7A'i32,
+    0x0AAB1'i32,
+    0x0AAC0'i32,
+    0x0AAC2'i32,
+    0x0FB1D'i32,
+    0x0FB3E'i32,
+    0x10808'i32,
+    0x1083C'i32,
+    0x10A00'i32,
+    0x10F27'i32,
+    0x11144'i32,
+    0x11176'i32,
+    0x111DA'i32,
+    0x111DC'i32,
+    0x11288'i32,
+    0x1133D'i32,
+    0x11350'i32,
+    0x1145F'i32,
+    0x114C7'i32,
+    0x11644'i32,
+    0x116B8'i32,
+    0x118FF'i32,
+    0x119E1'i32,
+    0x119E3'i32,
+    0x11A00'i32,
+    0x11A3A'i32,
+    0x11A50'i32,
+    0x11A9D'i32,
+    0x11C40'i32,
+    0x11D46'i32,
+    0x11D98'i32,
+    0x16F50'i32,
+    0x16FE3'i32,
+    0x1D4A2'i32,
+    0x1D4BB'i32,
+    0x1D546'i32,
+    0x1E14E'i32,
+    0x1E94B'i32,
+    0x1EE24'i32,
+    0x1EE27'i32,
+    0x1EE39'i32,
+    0x1EE3B'i32,
+    0x1EE42'i32,
+    0x1EE47'i32,
+    0x1EE49'i32,
+    0x1EE4B'i32,
+    0x1EE54'i32,
+    0x1EE57'i32,
+    0x1EE59'i32,
+    0x1EE5B'i32,
+    0x1EE5D'i32,
+    0x1EE5F'i32,
+    0x1EE64'i32,
+    0x1EE7E'i32,
+  ]
+
+  spaceRanges = [
+    0x00009'i32, 0x0000D'i32,
+    0x00020'i32, 0x00020'i32,
+    0x00085'i32, 0x00085'i32,
+    0x000A0'i32, 0x000A0'i32,
+    0x01680'i32, 0x01680'i32,
+    0x02000'i32, 0x0200A'i32,
+    0x02028'i32, 0x02029'i32,
+    0x0202F'i32, 0x0202F'i32,
+    0x0205F'i32, 0x0205F'i32,
+    0x03000'i32, 0x03000'i32,
+  ]
+
+  unicodeSpaces = [
+    Rune 0x00009,
+    Rune 0x0000A,
+    Rune 0x0000B,
+    Rune 0x0000C,
+    Rune 0x0000D,
+    Rune 0x00020,
+    Rune 0x00085,
+    Rune 0x000A0,
+    Rune 0x01680,
+    Rune 0x02000,
+    Rune 0x02001,
+    Rune 0x02002,
+    Rune 0x02003,
+    Rune 0x02004,
+    Rune 0x02005,
+    Rune 0x02006,
+    Rune 0x02007,
+    Rune 0x02008,
+    Rune 0x02009,
+    Rune 0x0200A,
+    Rune 0x02028,
+    Rune 0x02029,
+    Rune 0x0202F,
+    Rune 0x0205F,
+    Rune 0x03000,
+  ]
+
diff --git a/lib/pure/ioselects/ioselectors_epoll.nim b/lib/pure/ioselects/ioselectors_epoll.nim
new file mode 100644
index 000000000..10658b78e
--- /dev/null
+++ b/lib/pure/ioselects/ioselectors_epoll.nim
@@ -0,0 +1,534 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# This module implements Linux epoll().
+
+import std/[posix, times, epoll]
+
+# Maximum number of events that can be returned
+const MAX_EPOLL_EVENTS = 64
+
+when not defined(android):
+  type
+    SignalFdInfo* {.importc: "struct signalfd_siginfo",
+                    header: "<sys/signalfd.h>", pure, final.} = object
+      ssi_signo*: uint32
+      ssi_errno*: int32
+      ssi_code*: int32
+      ssi_pid*: uint32
+      ssi_uid*: uint32
+      ssi_fd*: int32
+      ssi_tid*: uint32
+      ssi_band*: uint32
+      ssi_overrun*: uint32
+      ssi_trapno*: uint32
+      ssi_status*: int32
+      ssi_int*: int32
+      ssi_ptr*: uint64
+      ssi_utime*: uint64
+      ssi_stime*: uint64
+      ssi_addr*: uint64
+      pad* {.importc: "__pad".}: array[0..47, uint8]
+
+proc timerfd_create(clock_id: ClockId, flags: cint): cint
+     {.cdecl, importc: "timerfd_create", header: "<sys/timerfd.h>".}
+proc timerfd_settime(ufd: cint, flags: cint,
+                      utmr: var Itimerspec, otmr: var Itimerspec): cint
+     {.cdecl, importc: "timerfd_settime", header: "<sys/timerfd.h>".}
+proc eventfd(count: cuint, flags: cint): cint
+     {.cdecl, importc: "eventfd", header: "<sys/eventfd.h>".}
+
+when not defined(android):
+  proc signalfd(fd: cint, mask: var Sigset, flags: cint): cint
+       {.cdecl, importc: "signalfd", header: "<sys/signalfd.h>".}
+
+when hasThreadSupport:
+  type
+    SelectorImpl[T] = object
+      epollFD: cint
+      maxFD: int
+      numFD: int
+      fds: ptr SharedArray[SelectorKey[T]]
+      count*: int
+    Selector*[T] = ptr SelectorImpl[T]
+else:
+  type
+    SelectorImpl[T] = object
+      epollFD: cint
+      maxFD: int
+      numFD: int
+      fds: seq[SelectorKey[T]]
+      count*: int
+    Selector*[T] = ref SelectorImpl[T]
+type
+  SelectEventImpl = object
+    efd: cint
+  SelectEvent* = ptr SelectEventImpl
+
+proc newSelector*[T](): Selector[T] =
+  proc initialNumFD(): int {.inline.} =
+    when defined(nuttx):
+      result = NEPOLL_MAX
+    else:
+      result = 1024
+  # Retrieve the maximum fd count (for current OS) via getrlimit()
+  var maxFD = maxDescriptors()
+  doAssert(maxFD > 0)
+  # Start with a reasonable size, checkFd() will grow this on demand
+  let numFD = initialNumFD()
+
+  var epollFD = epoll_create1(O_CLOEXEC)
+  if epollFD < 0:
+    raiseOSError(osLastError())
+
+  when hasThreadSupport:
+    result = cast[Selector[T]](allocShared0(sizeof(SelectorImpl[T])))
+    result.epollFD = epollFD
+    result.maxFD = maxFD
+    result.numFD = numFD
+    result.fds = allocSharedArray[SelectorKey[T]](numFD)
+  else:
+    result = Selector[T]()
+    result.epollFD = epollFD
+    result.maxFD = maxFD
+    result.numFD = numFD
+    result.fds = newSeq[SelectorKey[T]](numFD)
+
+  for i in 0 ..< numFD:
+    result.fds[i].ident = InvalidIdent
+
+proc close*[T](s: Selector[T]) =
+  let res = posix.close(s.epollFD)
+  when hasThreadSupport:
+    deallocSharedArray(s.fds)
+    deallocShared(cast[pointer](s))
+  if res != 0:
+    raiseIOSelectorsError(osLastError())
+
+proc newSelectEvent*(): SelectEvent =
+  let fdci = eventfd(0, O_CLOEXEC or O_NONBLOCK)
+  if fdci == -1:
+    raiseIOSelectorsError(osLastError())
+  result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+  result.efd = fdci
+
+proc trigger*(ev: SelectEvent) =
+  var data: uint64 = 1
+  if posix.write(ev.efd, addr data, sizeof(uint64)) == -1:
+    raiseIOSelectorsError(osLastError())
+
+proc close*(ev: SelectEvent) =
+  let res = posix.close(ev.efd)
+  deallocShared(cast[pointer](ev))
+  if res != 0:
+    raiseIOSelectorsError(osLastError())
+
+template checkFd(s, f) =
+  # TODO: I don't see how this can ever happen. You won't be able to create an
+  # FD if there is too many. -- DP
+  if f >= s.maxFD:
+    raiseIOSelectorsError("Maximum number of descriptors is exhausted!")
+  if f >= s.numFD:
+    var numFD = s.numFD
+    while numFD <= f: numFD *= 2
+    when hasThreadSupport:
+      s.fds = reallocSharedArray(s.fds, s.numFD, numFD)
+    else:
+      s.fds.setLen(numFD)
+    for i in s.numFD ..< numFD:
+      s.fds[i].ident = InvalidIdent
+    s.numFD = numFD
+
+proc registerHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                        events: set[Event], data: T) =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent, "Descriptor $# already registered" % $fdi)
+  s.setKey(fdi, events, 0, data)
+  if events != {}:
+    var epv = EpollEvent(events: EPOLLRDHUP)
+    epv.data.u64 = fdi.uint
+    if Event.Read in events: epv.events = epv.events or EPOLLIN
+    if Event.Write in events: epv.events = epv.events or EPOLLOUT
+    if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fdi.cint, addr epv) != 0:
+      raiseIOSelectorsError(osLastError())
+    inc(s.count)
+
+proc updateHandle*[T](s: Selector[T], fd: int | SocketHandle, events: set[Event]) =
+  let maskEvents = {Event.Timer, Event.Signal, Event.Process, Event.Vnode,
+                    Event.User, Event.Oneshot, Event.Error}
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor $# is not registered in the selector!" % $fdi)
+  doAssert(pkey.events * maskEvents == {})
+  if pkey.events != events:
+    var epv = EpollEvent(events: EPOLLRDHUP)
+    epv.data.u64 = fdi.uint
+
+    if Event.Read in events: epv.events = epv.events or EPOLLIN
+    if Event.Write in events: epv.events = epv.events or EPOLLOUT
+
+    if pkey.events == {}:
+      if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fdi.cint, addr epv) != 0:
+        raiseIOSelectorsError(osLastError())
+      inc(s.count)
+    else:
+      if events != {}:
+        if epoll_ctl(s.epollFD, EPOLL_CTL_MOD, fdi.cint, addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+      else:
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+        dec(s.count)
+    pkey.events = events
+
+proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor $# is not registered in the selector!" % $fdi)
+  if pkey.events != {}:
+    when not defined(android):
+      if Event.Read in pkey.events or Event.Write in pkey.events or Event.User in pkey.events:
+        var epv = EpollEvent()
+        # TODO: Refactor all these EPOLL_CTL_DEL + dec(s.count) into a proc.
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+        dec(s.count)
+      elif Event.Timer in pkey.events:
+        if Event.Finished notin pkey.events:
+          var epv = EpollEvent()
+          if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+            raiseIOSelectorsError(osLastError())
+          dec(s.count)
+        if posix.close(cint(fdi)) != 0:
+          raiseIOSelectorsError(osLastError())
+      elif Event.Signal in pkey.events:
+        var epv = EpollEvent()
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+        var nmask, omask: Sigset
+        discard sigemptyset(nmask)
+        discard sigemptyset(omask)
+        discard sigaddset(nmask, cint(s.fds[fdi].param))
+        unblockSignals(nmask, omask)
+        dec(s.count)
+        if posix.close(cint(fdi)) != 0:
+          raiseIOSelectorsError(osLastError())
+      elif Event.Process in pkey.events:
+        if Event.Finished notin pkey.events:
+          var epv = EpollEvent()
+          if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+            raiseIOSelectorsError(osLastError())
+          var nmask, omask: Sigset
+          discard sigemptyset(nmask)
+          discard sigemptyset(omask)
+          discard sigaddset(nmask, SIGCHLD)
+          unblockSignals(nmask, omask)
+          dec(s.count)
+        if posix.close(cint(fdi)) != 0:
+          raiseIOSelectorsError(osLastError())
+    else:
+      if Event.Read in pkey.events or Event.Write in pkey.events or Event.User in pkey.events:
+        var epv = EpollEvent()
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+        dec(s.count)
+      elif Event.Timer in pkey.events:
+        if Event.Finished notin pkey.events:
+          var epv = EpollEvent()
+          if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+            raiseIOSelectorsError(osLastError())
+          dec(s.count)
+        if posix.close(cint(fdi)) != 0:
+          raiseIOSelectorsError(osLastError())
+  clearKey(pkey)
+
+proc unregister*[T](s: Selector[T], ev: SelectEvent) =
+  let fdi = int(ev.efd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent, "Event is not registered in the queue!")
+  doAssert(Event.User in pkey.events)
+  var epv = EpollEvent()
+  if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
+    raiseIOSelectorsError(osLastError())
+  dec(s.count)
+  clearKey(pkey)
+
+proc registerTimer*[T](s: Selector[T], timeout: int, oneshot: bool,
+                       data: T): int {.discardable.} =
+  var
+    newTs: Itimerspec
+    oldTs: Itimerspec
+  let fdi = timerfd_create(CLOCK_MONOTONIC, O_CLOEXEC or O_NONBLOCK).int
+  if fdi == -1:
+    raiseIOSelectorsError(osLastError())
+
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+
+  var events = {Event.Timer}
+  var epv = EpollEvent(events: EPOLLIN or EPOLLRDHUP)
+  epv.data.u64 = fdi.uint
+
+  if oneshot:
+    newTs.it_interval.tv_sec = posix.Time(0)
+    newTs.it_interval.tv_nsec = 0
+    newTs.it_value.tv_sec = posix.Time(timeout div 1_000)
+    newTs.it_value.tv_nsec = (timeout %% 1_000) * 1_000_000
+    incl(events, Event.Oneshot)
+    epv.events = epv.events or EPOLLONESHOT
+  else:
+    newTs.it_interval.tv_sec = posix.Time(timeout div 1000)
+    newTs.it_interval.tv_nsec = (timeout %% 1_000) * 1_000_000
+    newTs.it_value.tv_sec = newTs.it_interval.tv_sec
+    newTs.it_value.tv_nsec = newTs.it_interval.tv_nsec
+
+  if timerfd_settime(fdi.cint, cint(0), newTs, oldTs) != 0:
+    raiseIOSelectorsError(osLastError())
+  if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fdi.cint, addr epv) != 0:
+    raiseIOSelectorsError(osLastError())
+  s.setKey(fdi, events, 0, data)
+  inc(s.count)
+  result = fdi
+
+when not defined(android):
+  proc registerSignal*[T](s: Selector[T], signal: int,
+                          data: T): int {.discardable.} =
+    var
+      nmask: Sigset
+      omask: Sigset
+
+    discard sigemptyset(nmask)
+    discard sigemptyset(omask)
+    discard sigaddset(nmask, cint(signal))
+    blockSignals(nmask, omask)
+
+    let fdi = signalfd(-1, nmask, O_CLOEXEC or O_NONBLOCK).int
+    if fdi == -1:
+      raiseIOSelectorsError(osLastError())
+
+    s.checkFd(fdi)
+    doAssert(s.fds[fdi].ident == InvalidIdent)
+
+    var epv = EpollEvent(events: EPOLLIN or EPOLLRDHUP)
+    epv.data.u64 = fdi.uint
+    if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fdi.cint, addr epv) != 0:
+      raiseIOSelectorsError(osLastError())
+    s.setKey(fdi, {Event.Signal}, signal, data)
+    inc(s.count)
+    result = fdi
+
+  proc registerProcess*[T](s: Selector, pid: int,
+                           data: T): int {.discardable.} =
+    var
+      nmask: Sigset
+      omask: Sigset
+
+    discard sigemptyset(nmask)
+    discard sigemptyset(omask)
+    discard sigaddset(nmask, posix.SIGCHLD)
+    blockSignals(nmask, omask)
+
+    let fdi = signalfd(-1, nmask, O_CLOEXEC or O_NONBLOCK).int
+    if fdi == -1:
+      raiseIOSelectorsError(osLastError())
+
+    s.checkFd(fdi)
+    doAssert(s.fds[fdi].ident == InvalidIdent)
+
+    var epv = EpollEvent(events: EPOLLIN or EPOLLRDHUP)
+    epv.data.u64 = fdi.uint
+    epv.events = EPOLLIN or EPOLLRDHUP
+    if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, fdi.cint, addr epv) != 0:
+      raiseIOSelectorsError(osLastError())
+    s.setKey(fdi, {Event.Process, Event.Oneshot}, pid, data)
+    inc(s.count)
+    result = fdi
+
+proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) =
+  let fdi = int(ev.efd)
+  doAssert(s.fds[fdi].ident == InvalidIdent, "Event is already registered in the queue!")
+  s.setKey(fdi, {Event.User}, 0, data)
+  var epv = EpollEvent(events: EPOLLIN or EPOLLRDHUP)
+  epv.data.u64 = ev.efd.uint
+  if epoll_ctl(s.epollFD, EPOLL_CTL_ADD, ev.efd, addr epv) != 0:
+    raiseIOSelectorsError(osLastError())
+  inc(s.count)
+
+proc selectInto*[T](s: Selector[T], timeout: int,
+                    results: var openArray[ReadyKey]): int =
+  var
+    resTable: array[MAX_EPOLL_EVENTS, EpollEvent]
+    maxres = MAX_EPOLL_EVENTS
+    i, k: int
+
+  if maxres > len(results):
+    maxres = len(results)
+
+  verifySelectParams(timeout)
+
+  let count = epoll_wait(s.epollFD, addr(resTable[0]), maxres.cint,
+                         timeout.cint)
+  if count < 0:
+    result = 0
+    let err = osLastError()
+    if cint(err) != EINTR:
+      raiseIOSelectorsError(err)
+  elif count == 0:
+    result = 0
+  else:
+    i = 0
+    k = 0
+    while i < count:
+      let fdi = int(resTable[i].data.u64)
+      let pevents = resTable[i].events
+      var pkey = addr(s.fds[fdi])
+      doAssert(pkey.ident != InvalidIdent)
+      var rkey = ReadyKey(fd: fdi, events: {})
+
+      if (pevents and EPOLLERR) != 0 or (pevents and EPOLLHUP) != 0:
+        if (pevents and EPOLLHUP) != 0:
+          rkey.errorCode = OSErrorCode ECONNRESET
+        else:
+          # Try reading SO_ERROR from fd.
+          var error: cint
+          var size = SockLen sizeof(error)
+          if getsockopt(SocketHandle fdi, SOL_SOCKET, SO_ERROR, addr(error),
+                        addr(size)) == 0'i32:
+            rkey.errorCode = OSErrorCode error
+
+        rkey.events.incl(Event.Error)
+      if (pevents and EPOLLOUT) != 0:
+        rkey.events.incl(Event.Write)
+      when not defined(android):
+        if (pevents and EPOLLIN) != 0:
+          if Event.Read in pkey.events:
+            rkey.events.incl(Event.Read)
+          elif Event.Timer in pkey.events:
+            var data: uint64 = 0
+            if posix.read(cint(fdi), addr data,
+                          sizeof(uint64)) != sizeof(uint64):
+              raiseIOSelectorsError(osLastError())
+            rkey.events.incl(Event.Timer)
+          elif Event.Signal in pkey.events:
+            var data = SignalFdInfo()
+            if posix.read(cint(fdi), addr data,
+                          sizeof(SignalFdInfo)) != sizeof(SignalFdInfo):
+              raiseIOSelectorsError(osLastError())
+            rkey.events.incl(Event.Signal)
+          elif Event.Process in pkey.events:
+            var data = SignalFdInfo()
+            if posix.read(cint(fdi), addr data,
+                          sizeof(SignalFdInfo)) != sizeof(SignalFdInfo):
+              raiseIOSelectorsError(osLastError())
+            if cast[int](data.ssi_pid) == pkey.param:
+              rkey.events.incl(Event.Process)
+            else:
+              inc(i)
+              continue
+          elif Event.User in pkey.events:
+            var data: uint64 = 0
+            if posix.read(cint(fdi), addr data,
+                          sizeof(uint64)) != sizeof(uint64):
+              let err = osLastError()
+              if err == OSErrorCode(EAGAIN):
+                inc(i)
+                continue
+              else:
+                raiseIOSelectorsError(err)
+            rkey.events.incl(Event.User)
+      else:
+        if (pevents and EPOLLIN) != 0:
+          if Event.Read in pkey.events:
+            rkey.events.incl(Event.Read)
+          elif Event.Timer in pkey.events:
+            var data: uint64 = 0
+            if posix.read(cint(fdi), addr data,
+                          sizeof(uint64)) != sizeof(uint64):
+              raiseIOSelectorsError(osLastError())
+            rkey.events.incl(Event.Timer)
+          elif Event.User in pkey.events:
+            var data: uint64 = 0
+            if posix.read(cint(fdi), addr data,
+                          sizeof(uint64)) != sizeof(uint64):
+              let err = osLastError()
+              if err == OSErrorCode(EAGAIN):
+                inc(i)
+                continue
+              else:
+                raiseIOSelectorsError(err)
+            rkey.events.incl(Event.User)
+
+      if Event.Oneshot in pkey.events:
+        var epv = EpollEvent()
+        if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, cint(fdi), addr epv) != 0:
+          raiseIOSelectorsError(osLastError())
+        # we will not clear key until it will be unregistered, so
+        # application can obtain data, but we will decrease counter,
+        # because epoll is empty.
+        dec(s.count)
+        # we are marking key with `Finished` event, to avoid double decrease.
+        pkey.events.incl(Event.Finished)
+
+      results[k] = rkey
+      inc(k)
+      inc(i)
+    result = k
+
+proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey] =
+  result = newSeq[ReadyKey](MAX_EPOLL_EVENTS)
+  let count = selectInto(s, timeout, result)
+  result.setLen(count)
+
+template isEmpty*[T](s: Selector[T]): bool =
+  (s.count == 0)
+
+proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} =
+  return s.fds[fd.int].ident != InvalidIdent
+
+proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    result = s.fds[fdi].data
+
+proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: T): bool =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    s.fds[fdi].data = data
+    result = true
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                        body: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.fds[fdi].data)
+    body
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
+                        body2: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.fds[fdi].data)
+    body1
+  else:
+    body2
+
+proc getFd*[T](s: Selector[T]): int =
+  return s.epollFD.int
diff --git a/lib/pure/ioselects/ioselectors_kqueue.nim b/lib/pure/ioselects/ioselectors_kqueue.nim
new file mode 100644
index 000000000..513578eda
--- /dev/null
+++ b/lib/pure/ioselects/ioselectors_kqueue.nim
@@ -0,0 +1,639 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+#  This module implements BSD kqueue().
+
+import std/[posix, times, kqueue, nativesockets]
+
+const
+  # Maximum number of events that can be returned.
+  MAX_KQUEUE_EVENTS = 64
+  # SIG_IGN and SIG_DFL declared in posix.nim as variables, but we need them
+  # to be constants and GC-safe.
+  SIG_DFL = cast[proc(x: cint) {.noconv,gcsafe.}](0)
+  SIG_IGN = cast[proc(x: cint) {.noconv,gcsafe.}](1)
+
+when defined(kqcache):
+  const CACHE_EVENTS = true
+
+when defined(macosx) or defined(freebsd) or defined(dragonfly):
+  when defined(macosx):
+    const MAX_DESCRIPTORS_ID = 29 # KERN_MAXFILESPERPROC (MacOS)
+  else:
+    const MAX_DESCRIPTORS_ID = 27 # KERN_MAXFILESPERPROC (FreeBSD)
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
+              newp: pointer, newplen: csize_t): cint
+       {.importc: "sysctl",header: """#include <sys/types.h>
+                                      #include <sys/sysctl.h>""".}
+elif defined(netbsd) or defined(openbsd):
+  # OpenBSD and NetBSD don't have KERN_MAXFILESPERPROC, so we are using
+  # KERN_MAXFILES, because KERN_MAXFILES is always bigger,
+  # than KERN_MAXFILESPERPROC.
+  const MAX_DESCRIPTORS_ID = 7 # KERN_MAXFILES
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
+              newp: pointer, newplen: csize_t): cint
+       {.importc: "sysctl",header: """#include <sys/param.h>
+                                      #include <sys/sysctl.h>""".}
+
+when hasThreadSupport:
+  type
+    SelectorImpl[T] = object
+      kqFD: cint
+      maxFD: int
+      changes: ptr SharedArray[KEvent]
+      fds: ptr SharedArray[SelectorKey[T]]
+      count*: int
+      changesLock: Lock
+      changesSize: int
+      changesLength: int
+      sock: cint
+    Selector*[T] = ptr SelectorImpl[T]
+else:
+  type
+    SelectorImpl[T] = object
+      kqFD: cint
+      maxFD: int
+      changes: seq[KEvent]
+      fds: seq[SelectorKey[T]]
+      count*: int
+      sock: cint
+    Selector*[T] = ref SelectorImpl[T]
+
+type
+  SelectEventImpl = object
+    rfd: cint
+    wfd: cint
+
+  SelectEvent* = ptr SelectEventImpl
+  # SelectEvent is declared as `ptr` to be placed in `shared memory`,
+  # so you can share one SelectEvent handle between threads.
+
+proc getUnique[T](s: Selector[T]): int {.inline.} =
+  # we create duplicated handles to get unique indexes for our `fds` array.
+  result = posix.fcntl(s.sock, F_DUPFD_CLOEXEC, s.sock)
+  if result == -1:
+    raiseIOSelectorsError(osLastError())
+
+proc newSelector*[T](): owned(Selector[T]) =
+  var maxFD = 0.cint
+  var size = csize_t(sizeof(cint))
+  var namearr = [1.cint, MAX_DESCRIPTORS_ID.cint]
+  # Obtain maximum number of opened file descriptors for process
+  if sysctl(addr(namearr[0]), 2, cast[pointer](addr maxFD), addr size,
+            nil, 0) != 0:
+    raiseIOSelectorsError(osLastError())
+
+  var kqFD = kqueue()
+  if kqFD < 0:
+    raiseIOSelectorsError(osLastError())
+
+  # we allocating empty socket to duplicate it handle in future, to get unique
+  # indexes for `fds` array. This is needed to properly identify
+  # {Event.Timer, Event.Signal, Event.Process} events.
+  let usock = createNativeSocket(posix.AF_INET, posix.SOCK_STREAM,
+                                 posix.IPPROTO_TCP).cint
+  if usock == -1:
+    let err = osLastError()
+    discard posix.close(kqFD)
+    raiseIOSelectorsError(err)
+
+  when hasThreadSupport:
+    result = cast[Selector[T]](allocShared0(sizeof(SelectorImpl[T])))
+    result.fds = allocSharedArray[SelectorKey[T]](maxFD)
+    result.changes = allocSharedArray[KEvent](MAX_KQUEUE_EVENTS)
+    result.changesSize = MAX_KQUEUE_EVENTS
+    initLock(result.changesLock)
+  else:
+    result = Selector[T]()
+    result.fds = newSeq[SelectorKey[T]](maxFD)
+    result.changes = newSeqOfCap[KEvent](MAX_KQUEUE_EVENTS)
+
+  for i in 0 ..< maxFD:
+    result.fds[i].ident = InvalidIdent
+
+  result.sock = usock
+  result.kqFD = kqFD
+  result.maxFD = maxFD.int
+
+proc close*[T](s: Selector[T]) =
+  let res1 = posix.close(s.kqFD)
+  let res2 = posix.close(s.sock)
+  when hasThreadSupport:
+    deinitLock(s.changesLock)
+    deallocSharedArray(s.fds)
+    deallocShared(cast[pointer](s))
+  if res1 != 0 or res2 != 0:
+    raiseIOSelectorsError(osLastError())
+
+proc newSelectEvent*(): SelectEvent =
+  var fds: array[2, cint]
+  if posix.pipe(fds) != 0:
+    raiseIOSelectorsError(osLastError())
+  setNonBlocking(fds[0])
+  setNonBlocking(fds[1])
+  result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+  result.rfd = fds[0]
+  result.wfd = fds[1]
+
+proc trigger*(ev: SelectEvent) =
+  var data: uint64 = 1
+  if posix.write(ev.wfd, addr data, sizeof(uint64)) != sizeof(uint64):
+    raiseIOSelectorsError(osLastError())
+
+proc close*(ev: SelectEvent) =
+  let res1 = posix.close(ev.rfd)
+  let res2 = posix.close(ev.wfd)
+  deallocShared(cast[pointer](ev))
+  if res1 != 0 or res2 != 0:
+    raiseIOSelectorsError(osLastError())
+
+template checkFd(s, f) =
+  if f >= s.maxFD:
+    raiseIOSelectorsError("Maximum number of descriptors is exhausted!")
+
+when hasThreadSupport:
+  template withChangeLock[T](s: Selector[T], body: untyped) =
+    acquire(s.changesLock)
+    {.locks: [s.changesLock].}:
+      try:
+        body
+      finally:
+        release(s.changesLock)
+else:
+  template withChangeLock(s, body: untyped) =
+    body
+
+when hasThreadSupport:
+  template modifyKQueue[T](s: Selector[T], nident: uint, nfilter: cshort,
+                           nflags: cushort, nfflags: cuint, ndata: int,
+                           nudata: pointer) =
+    mixin withChangeLock
+    s.withChangeLock():
+      if s.changesLength == s.changesSize:
+        # if cache array is full, we allocating new with size * 2
+        let newSize = s.changesSize shl 1
+        let rdata = allocSharedArray[KEvent](newSize)
+        copyMem(rdata, s.changes, s.changesSize * sizeof(KEvent))
+        s.changesSize = newSize
+      s.changes[s.changesLength] = KEvent(ident: nident,
+                                          filter: nfilter, flags: nflags,
+                                          fflags: nfflags, data: ndata,
+                                          udata: nudata)
+      inc(s.changesLength)
+
+  when not declared(CACHE_EVENTS):
+    template flushKQueue[T](s: Selector[T]) =
+      mixin withChangeLock
+      s.withChangeLock():
+        if s.changesLength > 0:
+          if kevent(s.kqFD, addr(s.changes[0]), cint(s.changesLength),
+                    nil, 0, nil) == -1:
+            let res = osLastError()
+            if cint(res) != ENOENT: # ignore pipes whose read end is closed
+              raiseIOSelectorsError(res)
+          s.changesLength = 0
+else:
+  template modifyKQueue[T](s: Selector[T], nident: uint, nfilter: cshort,
+                           nflags: cushort, nfflags: cuint, ndata: int,
+                           nudata: pointer) =
+    s.changes.add(KEvent(ident: nident,
+                         filter: nfilter, flags: nflags,
+                         fflags: nfflags, data: ndata,
+                         udata: nudata))
+
+  when not declared(CACHE_EVENTS):
+    template flushKQueue[T](s: Selector[T]) =
+      let length = cint(len(s.changes))
+      if length > 0:
+        if kevent(s.kqFD, addr(s.changes[0]), length,
+                  nil, 0, nil) == -1:
+          let res = osLastError()
+          if cint(res) != ENOENT: # ignore pipes whose read end is closed
+            raiseIOSelectorsError(res)
+        s.changes.setLen(0)
+
+proc registerHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                        events: set[Event], data: T) =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+  s.setKey(fdi, events, 0, data)
+
+  if events != {}:
+    if Event.Read in events:
+      modifyKQueue(s, uint(fdi), EVFILT_READ, EV_ADD, 0, 0, nil)
+      inc(s.count)
+    if Event.Write in events:
+      modifyKQueue(s, uint(fdi), EVFILT_WRITE, EV_ADD, 0, 0, nil)
+      inc(s.count)
+
+    when not declared(CACHE_EVENTS):
+      flushKQueue(s)
+
+proc updateHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                      events: set[Event]) =
+  let maskEvents = {Event.Timer, Event.Signal, Event.Process, Event.Vnode,
+                    Event.User, Event.Oneshot, Event.Error}
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor $# is not registered in the queue!" % $fdi)
+  doAssert(pkey.events * maskEvents == {})
+
+  if pkey.events != events:
+    if (Event.Read in pkey.events) and (Event.Read notin events):
+      modifyKQueue(s, fdi.uint, EVFILT_READ, EV_DELETE, 0, 0, nil)
+      dec(s.count)
+    if (Event.Write in pkey.events) and (Event.Write notin events):
+      modifyKQueue(s, fdi.uint, EVFILT_WRITE, EV_DELETE, 0, 0, nil)
+      dec(s.count)
+    if (Event.Read notin pkey.events) and (Event.Read in events):
+      modifyKQueue(s, fdi.uint, EVFILT_READ, EV_ADD, 0, 0, nil)
+      inc(s.count)
+    if (Event.Write notin pkey.events) and (Event.Write in events):
+      modifyKQueue(s, fdi.uint, EVFILT_WRITE, EV_ADD, 0, 0, nil)
+      inc(s.count)
+
+    when not declared(CACHE_EVENTS):
+      flushKQueue(s)
+
+    pkey.events = events
+
+proc registerTimer*[T](s: Selector[T], timeout: int, oneshot: bool,
+                       data: T): int {.discardable.} =
+  let fdi = getUnique(s)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+
+  let events = if oneshot: {Event.Timer, Event.Oneshot} else: {Event.Timer}
+  let flags: cushort = if oneshot: EV_ONESHOT or EV_ADD else: EV_ADD
+
+  s.setKey(fdi, events, 0, data)
+
+  # EVFILT_TIMER on Open/Net(BSD) has granularity of only milliseconds,
+  # but MacOS and FreeBSD allow use `0` as `fflags` to use milliseconds
+  # too
+  modifyKQueue(s, fdi.uint, EVFILT_TIMER, flags, 0, cint(timeout), nil)
+
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+
+  inc(s.count)
+  result = fdi
+
+proc registerSignal*[T](s: Selector[T], signal: int,
+                        data: T): int {.discardable.} =
+  let fdi = getUnique(s)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+
+  s.setKey(fdi, {Event.Signal}, signal, data)
+  var nmask, omask: Sigset
+  discard sigemptyset(nmask)
+  discard sigemptyset(omask)
+  discard sigaddset(nmask, cint(signal))
+  blockSignals(nmask, omask)
+  # to be compatible with linux semantic we need to "eat" signals
+  posix.signal(cint(signal), SIG_IGN)
+
+  modifyKQueue(s, signal.uint, EVFILT_SIGNAL, EV_ADD, 0, 0,
+               cast[pointer](fdi))
+
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+
+  inc(s.count)
+  result = fdi
+
+proc registerProcess*[T](s: Selector[T], pid: int,
+                         data: T): int {.discardable.} =
+  let fdi = getUnique(s)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+
+  var kflags: cushort = EV_ONESHOT or EV_ADD
+  setKey(s, fdi, {Event.Process, Event.Oneshot}, pid, data)
+
+  modifyKQueue(s, pid.uint, EVFILT_PROC, kflags, NOTE_EXIT, 0,
+               cast[pointer](fdi))
+
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+
+  inc(s.count)
+  result = fdi
+
+proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) =
+  let fdi = ev.rfd.int
+  doAssert(s.fds[fdi].ident == InvalidIdent, "Event is already registered in the queue!")
+  setKey(s, fdi, {Event.User}, 0, data)
+
+  modifyKQueue(s, fdi.uint, EVFILT_READ, EV_ADD, 0, 0, nil)
+
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+
+  inc(s.count)
+
+template processVnodeEvents(events: set[Event]): cuint =
+  var rfflags = 0.cuint
+  if events == {Event.VnodeWrite, Event.VnodeDelete, Event.VnodeExtend,
+                Event.VnodeAttrib, Event.VnodeLink, Event.VnodeRename,
+                Event.VnodeRevoke}:
+    rfflags = NOTE_DELETE or NOTE_WRITE or NOTE_EXTEND or NOTE_ATTRIB or
+              NOTE_LINK or NOTE_RENAME or NOTE_REVOKE
+  else:
+    if Event.VnodeDelete in events: rfflags = rfflags or NOTE_DELETE
+    if Event.VnodeWrite in events: rfflags = rfflags or NOTE_WRITE
+    if Event.VnodeExtend in events: rfflags = rfflags or NOTE_EXTEND
+    if Event.VnodeAttrib in events: rfflags = rfflags or NOTE_ATTRIB
+    if Event.VnodeLink in events: rfflags = rfflags or NOTE_LINK
+    if Event.VnodeRename in events: rfflags = rfflags or NOTE_RENAME
+    if Event.VnodeRevoke in events: rfflags = rfflags or NOTE_REVOKE
+  rfflags
+
+proc registerVnode*[T](s: Selector[T], fd: cint, events: set[Event], data: T) =
+  let fdi = fd.int
+  setKey(s, fdi, {Event.Vnode} + events, 0, data)
+  var fflags = processVnodeEvents(events)
+
+  modifyKQueue(s, fdi.uint, EVFILT_VNODE, EV_ADD or EV_CLEAR, fflags, 0, nil)
+
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+
+  inc(s.count)
+
+proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor [" & $fdi & "] is not registered in the queue!")
+
+  if pkey.events != {}:
+    if pkey.events * {Event.Read, Event.Write} != {}:
+      if Event.Read in pkey.events:
+        modifyKQueue(s, uint(fdi), EVFILT_READ, EV_DELETE, 0, 0, nil)
+        dec(s.count)
+      if Event.Write in pkey.events:
+        modifyKQueue(s, uint(fdi), EVFILT_WRITE, EV_DELETE, 0, 0, nil)
+        dec(s.count)
+      when not declared(CACHE_EVENTS):
+        flushKQueue(s)
+    elif Event.Timer in pkey.events:
+      if Event.Finished notin pkey.events:
+        modifyKQueue(s, uint(fdi), EVFILT_TIMER, EV_DELETE, 0, 0, nil)
+        when not declared(CACHE_EVENTS):
+          flushKQueue(s)
+        dec(s.count)
+      if posix.close(cint(pkey.ident)) != 0:
+        raiseIOSelectorsError(osLastError())
+    elif Event.Signal in pkey.events:
+      var nmask, omask: Sigset
+      let signal = cint(pkey.param)
+      discard sigemptyset(nmask)
+      discard sigemptyset(omask)
+      discard sigaddset(nmask, signal)
+      unblockSignals(nmask, omask)
+      posix.signal(signal, SIG_DFL)
+      modifyKQueue(s, uint(pkey.param), EVFILT_SIGNAL, EV_DELETE, 0, 0, nil)
+      when not declared(CACHE_EVENTS):
+        flushKQueue(s)
+      dec(s.count)
+      if posix.close(cint(pkey.ident)) != 0:
+        raiseIOSelectorsError(osLastError())
+    elif Event.Process in pkey.events:
+      if Event.Finished notin pkey.events:
+        modifyKQueue(s, uint(pkey.param), EVFILT_PROC, EV_DELETE, 0, 0, nil)
+        when not declared(CACHE_EVENTS):
+          flushKQueue(s)
+        dec(s.count)
+      if posix.close(cint(pkey.ident)) != 0:
+        raiseIOSelectorsError(osLastError())
+    elif Event.Vnode in pkey.events:
+      modifyKQueue(s, uint(fdi), EVFILT_VNODE, EV_DELETE, 0, 0, nil)
+      when not declared(CACHE_EVENTS):
+        flushKQueue(s)
+      dec(s.count)
+    elif Event.User in pkey.events:
+      modifyKQueue(s, uint(fdi), EVFILT_READ, EV_DELETE, 0, 0, nil)
+      when not declared(CACHE_EVENTS):
+        flushKQueue(s)
+      dec(s.count)
+
+  clearKey(pkey)
+
+proc unregister*[T](s: Selector[T], ev: SelectEvent) =
+  let fdi = int(ev.rfd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent, "Event is not registered in the queue!")
+  doAssert(Event.User in pkey.events)
+  modifyKQueue(s, uint(fdi), EVFILT_READ, EV_DELETE, 0, 0, nil)
+  when not declared(CACHE_EVENTS):
+    flushKQueue(s)
+  clearKey(pkey)
+  dec(s.count)
+
+proc selectInto*[T](s: Selector[T], timeout: int,
+                    results: var openArray[ReadyKey]): int =
+  var
+    tv: Timespec
+    resTable: array[MAX_KQUEUE_EVENTS, KEvent]
+    ptv = addr tv
+    maxres = MAX_KQUEUE_EVENTS
+
+  verifySelectParams(timeout)
+
+  if timeout != -1:
+    if timeout >= 1000:
+      tv.tv_sec = posix.Time(timeout div 1_000)
+      tv.tv_nsec = (timeout %% 1_000) * 1_000_000
+    else:
+      tv.tv_sec = posix.Time(0)
+      tv.tv_nsec = timeout * 1_000_000
+  else:
+    ptv = nil
+
+  if maxres > len(results):
+    maxres = len(results)
+
+  var count = 0
+  when not declared(CACHE_EVENTS):
+    count = kevent(s.kqFD, nil, cint(0), addr(resTable[0]), cint(maxres), ptv)
+  else:
+    when hasThreadSupport:
+      s.withChangeLock():
+        if s.changesLength > 0:
+          count = kevent(s.kqFD, addr(s.changes[0]), cint(s.changesLength),
+                         addr(resTable[0]), cint(maxres), ptv)
+          s.changesLength = 0
+        else:
+          count = kevent(s.kqFD, nil, cint(0), addr(resTable[0]), cint(maxres),
+                         ptv)
+    else:
+      let length = cint(len(s.changes))
+      if length > 0:
+        count = kevent(s.kqFD, addr(s.changes[0]), length,
+                       addr(resTable[0]), cint(maxres), ptv)
+        s.changes.setLen(0)
+      else:
+        count = kevent(s.kqFD, nil, cint(0), addr(resTable[0]), cint(maxres),
+                       ptv)
+
+  if count < 0:
+    result = 0
+    let err = osLastError()
+    if cint(err) != EINTR:
+      raiseIOSelectorsError(err)
+  elif count == 0:
+    result = 0
+  else:
+    var i = 0
+    var k = 0 # do not delete this, because `continue` used in cycle.
+    var pkey: ptr SelectorKey[T]
+    while i < count:
+      let kevent = addr(resTable[i])
+      var rkey = ReadyKey(fd: int(kevent.ident), events: {})
+
+      if (kevent.flags and EV_ERROR) != 0:
+        rkey.events = {Event.Error}
+        rkey.errorCode = OSErrorCode(kevent.data)
+
+      case kevent.filter:
+      of EVFILT_READ:
+        pkey = addr(s.fds[int(kevent.ident)])
+        rkey.events.incl(Event.Read)
+        if Event.User in pkey.events:
+          var data: uint64 = 0
+          if posix.read(cint(kevent.ident), addr data,
+                        sizeof(uint64)) != sizeof(uint64):
+            let err = osLastError()
+            if err == OSErrorCode(EAGAIN):
+              # someone already consumed event data
+              inc(i)
+              continue
+            else:
+              raiseIOSelectorsError(err)
+          rkey.events = {Event.User}
+      of EVFILT_WRITE:
+        pkey = addr(s.fds[int(kevent.ident)])
+        rkey.events.incl(Event.Write)
+        rkey.events = {Event.Write}
+      of EVFILT_TIMER:
+        pkey = addr(s.fds[int(kevent.ident)])
+        if Event.Oneshot in pkey.events:
+          # we will not clear key until it will be unregistered, so
+          # application can obtain data, but we will decrease counter,
+          # because kqueue is empty.
+          dec(s.count)
+          # we are marking key with `Finished` event, to avoid double decrease.
+          pkey.events.incl(Event.Finished)
+        rkey.events.incl(Event.Timer)
+      of EVFILT_VNODE:
+        pkey = addr(s.fds[int(kevent.ident)])
+        rkey.events.incl(Event.Vnode)
+        if (kevent.fflags and NOTE_DELETE) != 0:
+          rkey.events.incl(Event.VnodeDelete)
+        if (kevent.fflags and NOTE_WRITE) != 0:
+          rkey.events.incl(Event.VnodeWrite)
+        if (kevent.fflags and NOTE_EXTEND) != 0:
+          rkey.events.incl(Event.VnodeExtend)
+        if (kevent.fflags and NOTE_ATTRIB) != 0:
+          rkey.events.incl(Event.VnodeAttrib)
+        if (kevent.fflags and NOTE_LINK) != 0:
+          rkey.events.incl(Event.VnodeLink)
+        if (kevent.fflags and NOTE_RENAME) != 0:
+          rkey.events.incl(Event.VnodeRename)
+        if (kevent.fflags and NOTE_REVOKE) != 0:
+          rkey.events.incl(Event.VnodeRevoke)
+      of EVFILT_SIGNAL:
+        pkey = addr(s.fds[cast[int](kevent.udata)])
+        rkey.fd = cast[int](kevent.udata)
+        rkey.events.incl(Event.Signal)
+      of EVFILT_PROC:
+        rkey.fd = cast[int](kevent.udata)
+        pkey = addr(s.fds[cast[int](kevent.udata)])
+        # we will not clear key, until it will be unregistered, so
+        # application can obtain data, but we will decrease counter,
+        # because kqueue is empty.
+        dec(s.count)
+        # we are marking key with `Finished` event, to avoid double decrease.
+        pkey.events.incl(Event.Finished)
+        rkey.events.incl(Event.Process)
+      else:
+        doAssert(true, "Unsupported kqueue filter in the queue!")
+
+      if (kevent.flags and EV_EOF) != 0:
+        # TODO this error handling needs to be rethought.
+        # `fflags` can sometimes be `0x80000000` and thus we use 'cast'
+        # here:
+        if kevent.fflags != 0:
+          rkey.errorCode = cast[OSErrorCode](kevent.fflags)
+        else:
+          # This assumes we are dealing with sockets.
+          # TODO: For future-proofing it might be a good idea to give the
+          #       user access to the raw `kevent`.
+          rkey.errorCode = OSErrorCode(ECONNRESET)
+        rkey.events.incl(Event.Error)
+
+      results[k] = rkey
+      inc(k)
+      inc(i)
+    result = k
+
+proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey] =
+  result = newSeq[ReadyKey](MAX_KQUEUE_EVENTS)
+  let count = selectInto(s, timeout, result)
+  result.setLen(count)
+
+template isEmpty*[T](s: Selector[T]): bool =
+  (s.count == 0)
+
+proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} =
+  return s.fds[fd.int].ident != InvalidIdent
+
+proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    result = s.fds[fdi].data
+
+proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: T): bool =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    s.fds[fdi].data = data
+    result = true
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                      body: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.fds[fdi].data)
+    body
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
+                      body2: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.fds[fdi].data)
+    body1
+  else:
+    body2
+
+
+proc getFd*[T](s: Selector[T]): int =
+  return s.kqFD.int
diff --git a/lib/pure/ioselects/ioselectors_poll.nim b/lib/pure/ioselects/ioselectors_poll.nim
new file mode 100644
index 000000000..7c5347156
--- /dev/null
+++ b/lib/pure/ioselects/ioselectors_poll.nim
@@ -0,0 +1,324 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# This module implements Posix poll().
+
+import std/[posix, times]
+
+# Maximum number of events that can be returned
+const MAX_POLL_EVENTS = 64
+
+const hasEventFds = defined(zephyr) or defined(nimPollHasEventFds)
+
+when hasEventFds:
+  proc eventfd(count: cuint, flags: cint): cint
+     {.cdecl, importc: "eventfd", header: "<sys/eventfd.h>".}
+
+when hasThreadSupport:
+  type
+    SelectorImpl[T] = object
+      maxFD : int
+      pollcnt: int
+      fds: ptr SharedArray[SelectorKey[T]]
+      pollfds: ptr SharedArray[TPollFd]
+      count*: int
+      lock: Lock
+    Selector*[T] = ptr SelectorImpl[T]
+else:
+  type
+    SelectorImpl[T] = object
+      maxFD : int
+      pollcnt: int
+      fds: seq[SelectorKey[T]]
+      pollfds: seq[TPollFd]
+      count*: int
+    Selector*[T] = ref SelectorImpl[T]
+
+type
+  SelectEventImpl = object
+    rfd: cint
+    wfd: cint
+  SelectEvent* = ptr SelectEventImpl
+
+when hasThreadSupport:
+  template withPollLock[T](s: Selector[T], body: untyped) =
+    acquire(s.lock)
+    {.locks: [s.lock].}:
+      try:
+        body
+      finally:
+        release(s.lock)
+else:
+  template withPollLock(s, body: untyped) =
+    body
+
+proc newSelector*[T](): Selector[T] =
+  var maxFD = maxDescriptors()
+
+  when hasThreadSupport:
+    result = cast[Selector[T]](allocShared0(sizeof(SelectorImpl[T])))
+    result.maxFD = maxFD
+    result.fds = allocSharedArray[SelectorKey[T]](maxFD)
+    result.pollfds = allocSharedArray[TPollFd](maxFD)
+    initLock(result.lock)
+  else:
+    result = Selector[T]()
+    result.maxFD = maxFD
+    result.fds = newSeq[SelectorKey[T]](maxFD)
+    result.pollfds = newSeq[TPollFd](maxFD)
+
+  for i in 0 ..< maxFD:
+    result.fds[i].ident = InvalidIdent
+
+proc close*[T](s: Selector[T]) =
+  when hasThreadSupport:
+    deinitLock(s.lock)
+    deallocSharedArray(s.fds)
+    deallocSharedArray(s.pollfds)
+    deallocShared(cast[pointer](s))
+
+template pollAdd[T](s: Selector[T], sock: cint, events: set[Event]) =
+  withPollLock(s):
+    var pollev: cshort = 0
+    if Event.Read in events: pollev = pollev or POLLIN
+    if Event.Write in events: pollev = pollev or POLLOUT
+    s.pollfds[s.pollcnt].fd = cint(sock)
+    s.pollfds[s.pollcnt].events = pollev
+    inc(s.count)
+    inc(s.pollcnt)
+
+template pollUpdate[T](s: Selector[T], sock: cint, events: set[Event]) =
+  withPollLock(s):
+    var i = 0
+    var pollev: cshort = 0
+    if Event.Read in events: pollev = pollev or POLLIN
+    if Event.Write in events: pollev = pollev or POLLOUT
+
+    while i < s.pollcnt:
+      if s.pollfds[i].fd == sock:
+        s.pollfds[i].events = pollev
+        break
+      inc(i)
+    doAssert(i < s.pollcnt,
+             "Descriptor [" & $sock & "] is not registered in the queue!")
+
+template pollRemove[T](s: Selector[T], sock: cint) =
+  withPollLock(s):
+    var i = 0
+    while i < s.pollcnt:
+      if s.pollfds[i].fd == sock:
+        if i == s.pollcnt - 1:
+          s.pollfds[i].fd = 0
+          s.pollfds[i].events = 0
+          s.pollfds[i].revents = 0
+        else:
+          while i < (s.pollcnt - 1):
+            s.pollfds[i].fd = s.pollfds[i + 1].fd
+            s.pollfds[i].events = s.pollfds[i + 1].events
+            inc(i)
+        break
+      inc(i)
+    dec(s.pollcnt)
+    dec(s.count)
+
+template checkFd(s, f) =
+  if f >= s.maxFD:
+    raiseIOSelectorsError("Maximum number of descriptors is exhausted!")
+
+proc registerHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                        events: set[Event], data: T) =
+  var fdi = int(fd)
+  s.checkFd(fdi)
+  doAssert(s.fds[fdi].ident == InvalidIdent)
+  setKey(s, fdi, events, 0, data)
+  if events != {}: s.pollAdd(fdi.cint, events)
+
+proc updateHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                      events: set[Event]) =
+  let maskEvents = {Event.Timer, Event.Signal, Event.Process, Event.Vnode,
+                    Event.User, Event.Oneshot, Event.Error}
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor [" & $fdi & "] is not registered in the queue!")
+  doAssert(pkey.events * maskEvents == {})
+
+  if pkey.events != events:
+    if pkey.events == {}:
+      s.pollAdd(fd.cint, events)
+    else:
+      if events != {}:
+        s.pollUpdate(fd.cint, events)
+      else:
+        s.pollRemove(fd.cint)
+    pkey.events = events
+
+proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) =
+  var fdi = int(ev.rfd)
+  doAssert(s.fds[fdi].ident == InvalidIdent, "Event is already registered in the queue!")
+  var events = {Event.User}
+  setKey(s, fdi, events, 0, data)
+  events.incl(Event.Read)
+  s.pollAdd(fdi.cint, events)
+
+proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent,
+           "Descriptor [" & $fdi & "] is not registered in the queue!")
+  pkey.ident = InvalidIdent
+  if pkey.events != {}:
+    pkey.events = {}
+    s.pollRemove(fdi.cint)
+
+proc unregister*[T](s: Selector[T], ev: SelectEvent) =
+  let fdi = int(ev.rfd)
+  s.checkFd(fdi)
+  var pkey = addr(s.fds[fdi])
+  doAssert(pkey.ident != InvalidIdent, "Event is not registered in the queue!")
+  doAssert(Event.User in pkey.events)
+  pkey.ident = InvalidIdent
+  pkey.events = {}
+  s.pollRemove(fdi.cint)
+
+proc newSelectEvent*(): SelectEvent =
+  when not hasEventFds: 
+    var fds: array[2, cint]
+    if posix.pipe(fds) != 0:
+      raiseIOSelectorsError(osLastError())
+    setNonBlocking(fds[0])
+    setNonBlocking(fds[1])
+    result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+    result.rfd = fds[0]
+    result.wfd = fds[1]
+  else: 
+    let fdci = eventfd(0, posix.O_NONBLOCK)
+    if fdci == -1:
+      raiseIOSelectorsError(osLastError())
+    result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+    result.rfd = fdci
+    result.wfd = fdci
+
+proc trigger*(ev: SelectEvent) =
+  var data: uint64 = 1
+  if posix.write(ev.wfd, addr data, sizeof(uint64)) != sizeof(uint64):
+    raiseIOSelectorsError(osLastError())
+
+proc close*(ev: SelectEvent) =
+  let res1 = posix.close(ev.rfd)
+  let res2 = 
+    when  hasEventFds: 0
+    else: posix.close(ev.wfd)
+
+  deallocShared(cast[pointer](ev))
+  if res1 != 0 or res2 != 0:
+    raiseIOSelectorsError(osLastError())
+
+proc selectInto*[T](s: Selector[T], timeout: int,
+                    results: var openArray[ReadyKey]): int =
+  var maxres = MAX_POLL_EVENTS
+  if maxres > len(results):
+    maxres = len(results)
+
+  verifySelectParams(timeout)
+
+  s.withPollLock():
+    let count = posix.poll(addr(s.pollfds[0]), Tnfds(s.pollcnt), timeout)
+    if count < 0:
+      result = 0
+      let err = osLastError()
+      if cint(err) != EINTR:
+        raiseIOSelectorsError(err)
+    elif count == 0:
+      result = 0
+    else:
+      var i = 0
+      var k = 0
+      var rindex = 0
+      while (i < s.pollcnt) and (k < count) and (rindex < maxres):
+        let revents = s.pollfds[i].revents
+        if revents != 0:
+          let fd = s.pollfds[i].fd
+          var pkey = addr(s.fds[fd])
+          var rkey = ReadyKey(fd: int(fd), events: {})
+
+          if (revents and POLLIN) != 0:
+            rkey.events.incl(Event.Read)
+            if Event.User in pkey.events:
+              var data: uint64 = 0
+              if posix.read(fd, addr data, sizeof(uint64)) != sizeof(uint64):
+                let err = osLastError()
+                if err != OSErrorCode(EAGAIN):
+                  raiseIOSelectorsError(err)
+                else:
+                  # someone already consumed event data
+                  inc(i)
+                  continue
+              rkey.events = {Event.User}
+          if (revents and POLLOUT) != 0:
+            rkey.events.incl(Event.Write)
+          if (revents and POLLERR) != 0 or (revents and POLLHUP) != 0 or
+             (revents and POLLNVAL) != 0:
+            rkey.events.incl(Event.Error)
+          results[rindex] = rkey
+          s.pollfds[i].revents = 0
+          inc(rindex)
+          inc(k)
+        inc(i)
+      result = k
+
+proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey] =
+  result = newSeq[ReadyKey](MAX_POLL_EVENTS)
+  let count = selectInto(s, timeout, result)
+  result.setLen(count)
+
+template isEmpty*[T](s: Selector[T]): bool =
+  (s.count == 0)
+
+proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} =
+  return s.fds[fd.int].ident != InvalidIdent
+
+proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    result = s.fds[fdi].data
+
+proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: T): bool =
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    s.fds[fdi].data = data
+    result = true
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                        body: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.getData(fdi))
+    body
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
+                        body2: untyped) =
+  mixin checkFd
+  let fdi = int(fd)
+  s.checkFd(fdi)
+  if fdi in s:
+    var value = addr(s.getData(fdi))
+    body1
+  else:
+    body2
+
+
+proc getFd*[T](s: Selector[T]): int =
+  return -1
diff --git a/lib/pure/ioselects/ioselectors_select.nim b/lib/pure/ioselects/ioselectors_select.nim
new file mode 100644
index 000000000..6c516395b
--- /dev/null
+++ b/lib/pure/ioselects/ioselectors_select.nim
@@ -0,0 +1,454 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# This module implements Posix and Windows select().
+
+import std/[times, nativesockets]
+
+when defined(windows):
+  import std/winlean
+  when defined(gcc):
+    {.passl: "-lws2_32".}
+  elif defined(vcc):
+    {.passl: "ws2_32.lib".}
+  const platformHeaders = """#include <winsock2.h>
+                             #include <windows.h>"""
+  const EAGAIN = WSAEWOULDBLOCK
+else:
+  const platformHeaders = """#include <sys/select.h>
+                             #include <sys/time.h>
+                             #include <sys/types.h>
+                             #include <unistd.h>"""
+type
+  FdSet {.importc: "fd_set", header: platformHeaders, pure, final.} = object
+var
+  FD_SETSIZE {.importc: "FD_SETSIZE", header: platformHeaders.}: cint
+
+proc IOFD_SET(fd: SocketHandle, fdset: ptr FdSet)
+     {.cdecl, importc: "FD_SET", header: platformHeaders, inline.}
+proc IOFD_CLR(fd: SocketHandle, fdset: ptr FdSet)
+     {.cdecl, importc: "FD_CLR", header: platformHeaders, inline.}
+proc IOFD_ZERO(fdset: ptr FdSet)
+     {.cdecl, importc: "FD_ZERO", header: platformHeaders, inline.}
+
+when defined(windows):
+  proc IOFD_ISSET(fd: SocketHandle, fdset: ptr FdSet): cint
+       {.stdcall, importc: "FD_ISSET", header: platformHeaders, inline.}
+  proc ioselect(nfds: cint, readFds, writeFds, exceptFds: ptr FdSet,
+                timeout: ptr Timeval): cint
+       {.stdcall, importc: "select", header: platformHeaders.}
+else:
+  proc IOFD_ISSET(fd: SocketHandle, fdset: ptr FdSet): cint
+       {.cdecl, importc: "FD_ISSET", header: platformHeaders, inline.}
+  proc ioselect(nfds: cint, readFds, writeFds, exceptFds: ptr FdSet,
+                timeout: ptr Timeval): cint
+       {.cdecl, importc: "select", header: platformHeaders.}
+
+when hasThreadSupport:
+  type
+    SelectorImpl[T] = object
+      rSet: FdSet
+      wSet: FdSet
+      eSet: FdSet
+      maxFD: int
+      fds: ptr SharedArray[SelectorKey[T]]
+      count*: int
+      lock: Lock
+    Selector*[T] = ptr SelectorImpl[T]
+else:
+  type
+    SelectorImpl[T] = object
+      rSet: FdSet
+      wSet: FdSet
+      eSet: FdSet
+      maxFD: int
+      fds: seq[SelectorKey[T]]
+      count*: int
+    Selector*[T] = ref SelectorImpl[T]
+
+type
+  SelectEventImpl = object
+    rsock: SocketHandle
+    wsock: SocketHandle
+  SelectEvent* = ptr SelectEventImpl
+
+when hasThreadSupport:
+  template withSelectLock[T](s: Selector[T], body: untyped) =
+    acquire(s.lock)
+    {.locks: [s.lock].}:
+      try:
+        body
+      finally:
+        release(s.lock)
+else:
+  template withSelectLock[T](s: Selector[T], body: untyped) =
+    body
+
+proc newSelector*[T](): Selector[T] =
+  when hasThreadSupport:
+    result = cast[Selector[T]](allocShared0(sizeof(SelectorImpl[T])))
+    result.fds = allocSharedArray[SelectorKey[T]](FD_SETSIZE)
+    initLock result.lock
+  else:
+    result = Selector[T]()
+    result.fds = newSeq[SelectorKey[T]](FD_SETSIZE)
+
+  for i in 0 ..< FD_SETSIZE:
+    result.fds[i].ident = InvalidIdent
+
+  IOFD_ZERO(addr result.rSet)
+  IOFD_ZERO(addr result.wSet)
+  IOFD_ZERO(addr result.eSet)
+
+proc close*[T](s: Selector[T]) =
+  when hasThreadSupport:
+    deallocSharedArray(s.fds)
+    deallocShared(cast[pointer](s))
+    deinitLock(s.lock)
+
+when defined(windows):
+  proc newSelectEvent*(): SelectEvent =
+    var ssock = createNativeSocket()
+    var wsock = createNativeSocket()
+    var rsock: SocketHandle = INVALID_SOCKET
+    var saddr = Sockaddr_in()
+
+    saddr.sin_family = winlean.AF_INET
+    saddr.sin_port = 0
+    saddr.sin_addr.s_addr = INADDR_ANY
+    if bindAddr(ssock, cast[ptr SockAddr](addr(saddr)),
+                sizeof(saddr).SockLen) < 0'i32:
+      raiseIOSelectorsError(osLastError())
+
+    if winlean.listen(ssock, 1) != 0:
+      raiseIOSelectorsError(osLastError())
+
+    var namelen = sizeof(saddr).SockLen
+    if getsockname(ssock, cast[ptr SockAddr](addr(saddr)),
+                   addr(namelen)) != 0'i32:
+      raiseIOSelectorsError(osLastError())
+
+    saddr.sin_addr.s_addr = 0x0100007F
+    if winlean.connect(wsock, cast[ptr SockAddr](addr(saddr)),
+                       sizeof(saddr).SockLen) != 0:
+      raiseIOSelectorsError(osLastError())
+    namelen = sizeof(saddr).SockLen
+    rsock = winlean.accept(ssock, cast[ptr SockAddr](addr(saddr)),
+                           cast[ptr SockLen](addr(namelen)))
+    if rsock == SocketHandle(-1):
+      raiseIOSelectorsError(osLastError())
+
+    if winlean.closesocket(ssock) != 0:
+      raiseIOSelectorsError(osLastError())
+
+    var mode = clong(1)
+    if ioctlsocket(rsock, FIONBIO, addr(mode)) != 0:
+      raiseIOSelectorsError(osLastError())
+    mode = clong(1)
+    if ioctlsocket(wsock, FIONBIO, addr(mode)) != 0:
+      raiseIOSelectorsError(osLastError())
+
+    result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+    result.rsock = rsock
+    result.wsock = wsock
+
+  proc trigger*(ev: SelectEvent) =
+    var data: uint64 = 1
+    if winlean.send(ev.wsock, cast[pointer](addr data),
+                    cint(sizeof(uint64)), 0) != sizeof(uint64):
+      raiseIOSelectorsError(osLastError())
+
+  proc close*(ev: SelectEvent) =
+    let res1 = winlean.closesocket(ev.rsock)
+    let res2 = winlean.closesocket(ev.wsock)
+    deallocShared(cast[pointer](ev))
+    if res1 != 0 or res2 != 0:
+      raiseIOSelectorsError(osLastError())
+
+else:
+  proc newSelectEvent*(): SelectEvent =
+    var fds: array[2, cint]
+    if posix.pipe(fds) != 0:
+      raiseIOSelectorsError(osLastError())
+    setNonBlocking(fds[0])
+    setNonBlocking(fds[1])
+    result = cast[SelectEvent](allocShared0(sizeof(SelectEventImpl)))
+    result.rsock = SocketHandle(fds[0])
+    result.wsock = SocketHandle(fds[1])
+
+  proc trigger*(ev: SelectEvent) =
+    var data: uint64 = 1
+    if posix.write(cint(ev.wsock), addr data, sizeof(uint64)) != sizeof(uint64):
+      raiseIOSelectorsError(osLastError())
+
+  proc close*(ev: SelectEvent) =
+    let res1 = posix.close(cint(ev.rsock))
+    let res2 = posix.close(cint(ev.wsock))
+    deallocShared(cast[pointer](ev))
+    if res1 != 0 or res2 != 0:
+      raiseIOSelectorsError(osLastError())
+
+proc setSelectKey[T](s: Selector[T], fd: SocketHandle, events: set[Event],
+                     data: T) =
+  var i = 0
+  let fdi = int(fd)
+  while i < FD_SETSIZE:
+    if s.fds[i].ident == InvalidIdent:
+      var pkey = addr(s.fds[i])
+      pkey.ident = fdi
+      pkey.events = events
+      pkey.data = data
+      break
+    inc(i)
+  if i >= FD_SETSIZE:
+    raiseIOSelectorsError("Maximum number of descriptors is exhausted!")
+
+proc getKey[T](s: Selector[T], fd: SocketHandle): ptr SelectorKey[T] =
+  var i = 0
+  let fdi = int(fd)
+  while i < FD_SETSIZE:
+    if s.fds[i].ident == fdi:
+      result = addr(s.fds[i])
+      break
+    inc(i)
+  doAssert(i < FD_SETSIZE,
+           "Descriptor [" & $int(fd) & "] is not registered in the queue!")
+
+proc delKey[T](s: Selector[T], fd: SocketHandle) =
+  var empty: T
+  var i = 0
+  while i < FD_SETSIZE:
+    if s.fds[i].ident == fd.int:
+      s.fds[i].ident = InvalidIdent
+      s.fds[i].events = {}
+      s.fds[i].data = empty
+      break
+    inc(i)
+  doAssert(i < FD_SETSIZE,
+           "Descriptor [" & $int(fd) & "] is not registered in the queue!")
+
+proc registerHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                        events: set[Event], data: T) =
+  when not defined(windows):
+    let fdi = int(fd)
+  s.withSelectLock():
+    s.setSelectKey(fd, events, data)
+    when not defined(windows):
+      if fdi > s.maxFD: s.maxFD = fdi
+    if Event.Read in events:
+      IOFD_SET(fd, addr s.rSet)
+      inc(s.count)
+    if Event.Write in events:
+      IOFD_SET(fd, addr s.wSet)
+      IOFD_SET(fd, addr s.eSet)
+      inc(s.count)
+
+proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) =
+  when not defined(windows):
+    let fdi = int(ev.rsock)
+  s.withSelectLock():
+    s.setSelectKey(ev.rsock, {Event.User}, data)
+    when not defined(windows):
+      if fdi > s.maxFD: s.maxFD = fdi
+    IOFD_SET(ev.rsock, addr s.rSet)
+    inc(s.count)
+
+proc updateHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                      events: set[Event]) =
+  let maskEvents = {Event.Timer, Event.Signal, Event.Process, Event.Vnode,
+                    Event.User, Event.Oneshot, Event.Error}
+  s.withSelectLock():
+    var pkey = s.getKey(fd)
+    doAssert(pkey.events * maskEvents == {})
+    if pkey.events != events:
+      if (Event.Read in pkey.events) and (Event.Read notin events):
+        IOFD_CLR(fd, addr s.rSet)
+        dec(s.count)
+      if (Event.Write in pkey.events) and (Event.Write notin events):
+        IOFD_CLR(fd, addr s.wSet)
+        IOFD_CLR(fd, addr s.eSet)
+        dec(s.count)
+      if (Event.Read notin pkey.events) and (Event.Read in events):
+        IOFD_SET(fd, addr s.rSet)
+        inc(s.count)
+      if (Event.Write notin pkey.events) and (Event.Write in events):
+        IOFD_SET(fd, addr s.wSet)
+        IOFD_SET(fd, addr s.eSet)
+        inc(s.count)
+      pkey.events = events
+
+proc unregister*[T](s: Selector[T], fd: SocketHandle|int) =
+  s.withSelectLock():
+    let fd = fd.SocketHandle
+    var pkey = s.getKey(fd)
+    if Event.Read in pkey.events or Event.User in pkey.events:
+      IOFD_CLR(fd, addr s.rSet)
+      dec(s.count)
+    if Event.Write in pkey.events:
+      IOFD_CLR(fd, addr s.wSet)
+      IOFD_CLR(fd, addr s.eSet)
+      dec(s.count)
+    s.delKey(fd)
+
+proc unregister*[T](s: Selector[T], ev: SelectEvent) =
+  let fd = ev.rsock
+  s.withSelectLock():
+    var pkey = s.getKey(fd)
+    IOFD_CLR(fd, addr s.rSet)
+    dec(s.count)
+    s.delKey(fd)
+
+proc selectInto*[T](s: Selector[T], timeout: int,
+                    results: var openArray[ReadyKey]): int =
+  var tv = Timeval()
+  var ptv = addr tv
+  var rset, wset, eset: FdSet
+
+  verifySelectParams(timeout)
+
+  if timeout != -1:
+    when defined(genode) or defined(freertos) or defined(zephyr) or defined(nuttx):
+      tv.tv_sec = posix.Time(timeout div 1_000)
+    else:
+      tv.tv_sec = timeout.int32 div 1_000
+    tv.tv_usec = (timeout.int32 %% 1_000) * 1_000
+  else:
+    ptv = nil
+
+  s.withSelectLock():
+    rset = s.rSet
+    wset = s.wSet
+    eset = s.eSet
+
+  var count = ioselect(cint(s.maxFD) + 1, addr(rset), addr(wset),
+                       addr(eset), ptv)
+  if count < 0:
+    result = 0
+    when defined(windows):
+      raiseIOSelectorsError(osLastError())
+    else:
+      let err = osLastError()
+      if cint(err) != EINTR:
+        raiseIOSelectorsError(err)
+  elif count == 0:
+    result = 0
+  else:
+    var rindex = 0
+    var i = 0
+    var k = 0
+
+    while (i < FD_SETSIZE) and (k < count):
+      if s.fds[i].ident != InvalidIdent:
+        var flag = false
+        var pkey = addr(s.fds[i])
+        var rkey = ReadyKey(fd: int(pkey.ident), events: {})
+        let fd = SocketHandle(pkey.ident)
+        if IOFD_ISSET(fd, addr rset) != 0:
+          if Event.User in pkey.events:
+            var data: uint64 = 0
+            if recv(fd, cast[pointer](addr(data)),
+                    sizeof(uint64).cint, 0) != sizeof(uint64):
+              let err = osLastError()
+              if cint(err) != EAGAIN:
+                raiseIOSelectorsError(err)
+              else:
+                inc(i)
+                inc(k)
+                continue
+            else:
+              flag = true
+              rkey.events = {Event.User}
+          else:
+            flag = true
+            rkey.events = {Event.Read}
+        if IOFD_ISSET(fd, addr wset) != 0:
+          rkey.events.incl(Event.Write)
+          if IOFD_ISSET(fd, addr eset) != 0:
+            rkey.events.incl(Event.Error)
+          flag = true
+        if flag:
+          results[rindex] = rkey
+          inc(rindex)
+          inc(k)
+      inc(i)
+    result = rindex
+
+proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey] =
+  result = newSeq[ReadyKey](FD_SETSIZE)
+  var count = selectInto(s, timeout, result)
+  result.setLen(count)
+
+proc flush*[T](s: Selector[T]) = discard
+
+template isEmpty*[T](s: Selector[T]): bool =
+  (s.count == 0)
+
+proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} =
+  s.withSelectLock():
+    result = false
+
+    let fdi = int(fd)
+    for i in 0..<FD_SETSIZE:
+      if s.fds[i].ident == fdi:
+        return true
+
+proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T =
+  s.withSelectLock():
+    let fdi = int(fd)
+    for i in 0..<FD_SETSIZE:
+      if s.fds[i].ident == fdi:
+        return s.fds[i].data
+
+proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: T): bool =
+  s.withSelectLock():
+    let fdi = int(fd)
+    var i = 0
+    while i < FD_SETSIZE:
+      if s.fds[i].ident == fdi:
+        var pkey = addr(s.fds[i])
+        pkey.data = data
+        result = true
+        break
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                      body: untyped) =
+  mixin withSelectLock
+  s.withSelectLock():
+    var value: ptr T
+    let fdi = int(fd)
+    var i = 0
+    while i < FD_SETSIZE:
+      if s.fds[i].ident == fdi:
+        value = addr(s.fds[i].data)
+        break
+      inc(i)
+    if i != FD_SETSIZE:
+      body
+
+template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                      body1, body2: untyped) =
+  mixin withSelectLock
+  s.withSelectLock():
+    block:
+      var value: ptr T
+      let fdi = int(fd)
+      var i = 0
+      while i < FD_SETSIZE:
+        if s.fds[i].ident == fdi:
+          value = addr(s.fds[i].data)
+          break
+        inc(i)
+      if i != FD_SETSIZE:
+        body1
+      else:
+        body2
+
+
+proc getFd*[T](s: Selector[T]): int =
+  return -1
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
new file mode 100644
index 000000000..53fa7553a
--- /dev/null
+++ b/lib/pure/json.nim
@@ -0,0 +1,1394 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf, Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a simple high performance `JSON`:idx:
+## parser. JSON (JavaScript Object Notation) is a lightweight
+## data-interchange format that is easy for humans to read and write
+## (unlike XML). It is easy for machines to parse and generate.
+## JSON is based on a subset of the JavaScript Programming Language,
+## Standard ECMA-262 3rd Edition - December 1999.
+##
+## See also
+## ========
+## * `std/parsejson <parsejson.html>`_
+## * `std/jsonutils <jsonutils.html>`_
+## * `std/marshal <marshal.html>`_
+## * `std/jscore <jscore.html>`_
+##
+##
+## Overview
+## ========
+##
+## Parsing JSON
+## ------------
+##
+## JSON often arrives into your program (via an API or a file) as a `string`.
+## The first step is to change it from its serialized form into a nested object
+## structure called a `JsonNode`.
+##
+## The `parseJson` procedure takes a string containing JSON and returns a
+## `JsonNode` object. This is an object variant and it is either a
+## `JObject`, `JArray`, `JString`, `JInt`, `JFloat`, `JBool` or
+## `JNull`. You check the kind of this object variant by using the `kind`
+## accessor.
+##
+## For a `JsonNode` who's kind is `JObject`, you can access its fields using
+## the `[]` operator. The following example shows how to do this:
+##
+##   ```Nim
+##   import std/json
+##
+##   let jsonNode = parseJson("""{"key": 3.14}""")
+##
+##   doAssert jsonNode.kind == JObject
+##   doAssert jsonNode["key"].kind == JFloat
+##   ```
+##
+## Reading values
+## --------------
+##
+## Once you have a `JsonNode`, retrieving the values can then be achieved
+## by using one of the helper procedures, which include:
+##
+## * `getInt`
+## * `getFloat`
+## * `getStr`
+## * `getBool`
+##
+## To retrieve the value of `"key"` you can do the following:
+##
+##   ```Nim
+##   import std/json
+##
+##   let jsonNode = parseJson("""{"key": 3.14}""")
+##
+##   doAssert jsonNode["key"].getFloat() == 3.14
+##   ```
+##
+## **Important:** The `[]` operator will raise an exception when the
+## specified field does not exist.
+##
+## Handling optional keys
+## ----------------------
+##
+## By using the `{}` operator instead of `[]`, it will return `nil`
+## when the field is not found. The `get`-family of procedures will return a
+## type's default value when called on `nil`.
+##
+##   ```Nim
+##   import std/json
+##
+##   let jsonNode = parseJson("{}")
+##
+##   doAssert jsonNode{"nope"}.getInt() == 0
+##   doAssert jsonNode{"nope"}.getFloat() == 0
+##   doAssert jsonNode{"nope"}.getStr() == ""
+##   doAssert jsonNode{"nope"}.getBool() == false
+##   ```
+##
+## Using default values
+## --------------------
+##
+## The `get`-family helpers also accept an additional parameter which allow
+## you to fallback to a default value should the key's values be `null`:
+##
+##   ```Nim
+##   import std/json
+##
+##   let jsonNode = parseJson("""{"key": 3.14, "key2": null}""")
+##
+##   doAssert jsonNode["key"].getFloat(6.28) == 3.14
+##   doAssert jsonNode["key2"].getFloat(3.14) == 3.14
+##   doAssert jsonNode{"nope"}.getFloat(3.14) == 3.14 # note the {}
+##   ```
+##
+## Unmarshalling
+## -------------
+##
+## In addition to reading dynamic data, Nim can also unmarshal JSON directly
+## into a type with the `to` macro.
+##
+## Note: Use `Option <options.html#Option>`_ for keys sometimes missing in json
+## responses, and backticks around keys with a reserved keyword as name.
+##
+##   ```Nim
+##   import std/json
+##   import std/options
+##
+##   type
+##     User = object
+##       name: string
+##       age: int
+##       `type`: Option[string]
+##
+##   let userJson = parseJson("""{ "name": "Nim", "age": 12 }""")
+##   let user = to(userJson, User)
+##   if user.`type`.isSome():
+##     assert user.`type`.get() != "robot"
+##   ```
+##
+## Creating JSON
+## =============
+##
+## This module can also be used to comfortably create JSON using the `%*`
+## operator:
+##
+##   ```nim
+##   import std/json
+##
+##   var hisName = "John"
+##   let herAge = 31
+##   var j = %*
+##     [
+##       { "name": hisName, "age": 30 },
+##       { "name": "Susan", "age": herAge }
+##     ]
+##
+##   var j2 = %* {"name": "Isaac", "books": ["Robot Dreams"]}
+##   j2["details"] = %* {"age":35, "pi":3.1415}
+##   echo j2
+##   ```
+##
+## See also: std/jsonutils for hookable json serialization/deserialization
+## of arbitrary types.
+
+runnableExamples:
+  ## Note: for JObject, key ordering is preserved, unlike in some languages,
+  ## this is convenient for some use cases. Example:
+  type Foo = object
+    a1, a2, a0, a3, a4: int
+  doAssert $(%* Foo()) == """{"a1":0,"a2":0,"a0":0,"a3":0,"a4":0}"""
+
+import std/[hashes, tables, strutils, lexbase, streams, macros, parsejson]
+
+import std/options # xxx remove this dependency using same approach as https://github.com/nim-lang/Nim/pull/14563
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, formatfloat]
+
+export
+  tables.`$`
+
+export
+  parsejson.JsonEventKind, parsejson.JsonError, JsonParser, JsonKindError,
+  open, close, str, getInt, getFloat, kind, getColumn, getLine, getFilename,
+  errorMsg, errorMsgExpected, next, JsonParsingError, raiseParseErr, nimIdentNormalize
+
+type
+  JsonNodeKind* = enum ## possible JSON node types
+    JNull,
+    JBool,
+    JInt,
+    JFloat,
+    JString,
+    JObject,
+    JArray
+
+  JsonNode* = ref JsonNodeObj ## JSON node
+  JsonNodeObj* {.acyclic.} = object
+    isUnquoted: bool # the JString was a number-like token and
+                     # so shouldn't be quoted
+    case kind*: JsonNodeKind
+    of JString:
+      str*: string
+    of JInt:
+      num*: BiggestInt
+    of JFloat:
+      fnum*: float
+    of JBool:
+      bval*: bool
+    of JNull:
+      nil
+    of JObject:
+      fields*: OrderedTable[string, JsonNode]
+    of JArray:
+      elems*: seq[JsonNode]
+
+const DepthLimit = 1000
+
+proc newJString*(s: string): JsonNode =
+  ## Creates a new `JString JsonNode`.
+  result = JsonNode(kind: JString, str: s)
+
+proc newJRawNumber(s: string): JsonNode =
+  ## Creates a "raw JS number", that is a number that does not
+  ## fit into Nim's `BiggestInt` field. This is really a `JString`
+  ## with the additional information that it should be converted back
+  ## to the string representation without the quotes.
+  result = JsonNode(kind: JString, str: s, isUnquoted: true)
+
+proc newJInt*(n: BiggestInt): JsonNode =
+  ## Creates a new `JInt JsonNode`.
+  result = JsonNode(kind: JInt, num: n)
+
+proc newJFloat*(n: float): JsonNode =
+  ## Creates a new `JFloat JsonNode`.
+  result = JsonNode(kind: JFloat, fnum: n)
+
+proc newJBool*(b: bool): JsonNode =
+  ## Creates a new `JBool JsonNode`.
+  result = JsonNode(kind: JBool, bval: b)
+
+proc newJNull*(): JsonNode =
+  ## Creates a new `JNull JsonNode`.
+  result = JsonNode(kind: JNull)
+
+proc newJObject*(): JsonNode =
+  ## Creates a new `JObject JsonNode`
+  result = JsonNode(kind: JObject, fields: initOrderedTable[string, JsonNode](2))
+
+proc newJArray*(): JsonNode =
+  ## Creates a new `JArray JsonNode`
+  result = JsonNode(kind: JArray, elems: @[])
+
+proc getStr*(n: JsonNode, default: string = ""): string =
+  ## Retrieves the string value of a `JString JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JString`, or if `n` is nil.
+  if n.isNil or n.kind != JString: return default
+  else: return n.str
+
+proc getInt*(n: JsonNode, default: int = 0): int =
+  ## Retrieves the int value of a `JInt JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JInt`, or if `n` is nil.
+  if n.isNil or n.kind != JInt: return default
+  else: return int(n.num)
+
+proc getBiggestInt*(n: JsonNode, default: BiggestInt = 0): BiggestInt =
+  ## Retrieves the BiggestInt value of a `JInt JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JInt`, or if `n` is nil.
+  if n.isNil or n.kind != JInt: return default
+  else: return n.num
+
+proc getFloat*(n: JsonNode, default: float = 0.0): float =
+  ## Retrieves the float value of a `JFloat JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JFloat` or `JInt`, or if `n` is nil.
+  if n.isNil: return default
+  case n.kind
+  of JFloat: return n.fnum
+  of JInt: return float(n.num)
+  else: return default
+
+proc getBool*(n: JsonNode, default: bool = false): bool =
+  ## Retrieves the bool value of a `JBool JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JBool`, or if `n` is nil.
+  if n.isNil or n.kind != JBool: return default
+  else: return n.bval
+
+proc getFields*(n: JsonNode,
+    default = initOrderedTable[string, JsonNode](2)):
+        OrderedTable[string, JsonNode] =
+  ## Retrieves the key, value pairs of a `JObject JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JObject`, or if `n` is nil.
+  if n.isNil or n.kind != JObject: return default
+  else: return n.fields
+
+proc getElems*(n: JsonNode, default: seq[JsonNode] = @[]): seq[JsonNode] =
+  ## Retrieves the array of a `JArray JsonNode`.
+  ##
+  ## Returns `default` if `n` is not a `JArray`, or if `n` is nil.
+  if n.isNil or n.kind != JArray: return default
+  else: return n.elems
+
+proc add*(father, child: JsonNode) =
+  ## Adds `child` to a JArray node `father`.
+  assert father.kind == JArray
+  father.elems.add(child)
+
+proc add*(obj: JsonNode, key: string, val: JsonNode) =
+  ## Sets a field from a `JObject`.
+  assert obj.kind == JObject
+  obj.fields[key] = val
+
+proc `%`*(s: string): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JString JsonNode`.
+  result = JsonNode(kind: JString, str: s)
+
+proc `%`*(n: uint): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JInt JsonNode`.
+  if n > cast[uint](int.high):
+    result = newJRawNumber($n)
+  else:
+    result = JsonNode(kind: JInt, num: BiggestInt(n))
+
+proc `%`*(n: int): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JInt JsonNode`.
+  result = JsonNode(kind: JInt, num: n)
+
+proc `%`*(n: BiggestUInt): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JInt JsonNode`.
+  if n > cast[BiggestUInt](BiggestInt.high):
+    result = newJRawNumber($n)
+  else:
+    result = JsonNode(kind: JInt, num: BiggestInt(n))
+
+proc `%`*(n: BiggestInt): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JInt JsonNode`.
+  result = JsonNode(kind: JInt, num: n)
+
+proc `%`*(n: float): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JFloat JsonNode`.
+  runnableExamples:
+    assert $(%[NaN, Inf, -Inf, 0.0, -0.0, 1.0, 1e-2]) == """["nan","inf","-inf",0.0,-0.0,1.0,0.01]"""
+    assert (%NaN).kind == JString
+    assert (%0.0).kind == JFloat
+  # for those special cases, we could also have used `newJRawNumber` but then
+  # it would've been inconsisten with the case of `parseJson` vs `%` for representing them.
+  if n != n: newJString("nan")
+  elif n == Inf: newJString("inf")
+  elif n == -Inf: newJString("-inf")
+  else: JsonNode(kind: JFloat, fnum: n)
+
+proc `%`*(b: bool): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JBool JsonNode`.
+  result = JsonNode(kind: JBool, bval: b)
+
+proc `%`*(keyVals: openArray[tuple[key: string, val: JsonNode]]): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JObject JsonNode`
+  if keyVals.len == 0: return newJArray()
+  result = newJObject()
+  for key, val in items(keyVals): result.fields[key] = val
+
+template `%`*(j: JsonNode): JsonNode = j
+
+proc `%`*[T](elements: openArray[T]): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JArray JsonNode`
+  result = newJArray()
+  for elem in elements: result.add(%elem)
+
+proc `%`*[T](table: Table[string, T]|OrderedTable[string, T]): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JObject JsonNode`.
+  result = newJObject()
+  for k, v in table: result[k] = %v
+
+proc `%`*[T](opt: Option[T]): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JNull JsonNode`
+  ## if `opt` is empty, otherwise it delegates to the underlying value.
+  if opt.isSome: %opt.get else: newJNull()
+
+when false:
+  # For 'consistency' we could do this, but that only pushes people further
+  # into that evil comfort zone where they can use Nim without understanding it
+  # causing problems later on.
+  proc `%`*(elements: set[bool]): JsonNode =
+    ## Generic constructor for JSON data. Creates a new `JObject JsonNode`.
+    ## This can only be used with the empty set `{}` and is supported
+    ## to prevent the gotcha `%*{}` which used to produce an empty
+    ## JSON array.
+    result = newJObject()
+    assert false notin elements, "usage error: only empty sets allowed"
+    assert true notin elements, "usage error: only empty sets allowed"
+
+proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
+  ## Sets a field from a `JObject`.
+  assert(obj.kind == JObject)
+  obj.fields[key] = val
+
+proc `%`*[T: object](o: T): JsonNode =
+  ## Construct JsonNode from tuples and objects.
+  result = newJObject()
+  for k, v in o.fieldPairs: result[k] = %v
+
+proc `%`*(o: ref object): JsonNode =
+  ## Generic constructor for JSON data. Creates a new `JObject JsonNode`
+  if o.isNil:
+    result = newJNull()
+  else:
+    result = %(o[])
+
+proc `%`*(o: enum): JsonNode =
+  ## Construct a JsonNode that represents the specified enum value as a
+  ## string. Creates a new `JString JsonNode`.
+  result = %($o)
+
+proc toJsonImpl(x: NimNode): NimNode =
+  case x.kind
+  of nnkBracket: # array
+    if x.len == 0: return newCall(bindSym"newJArray")
+    result = newNimNode(nnkBracket)
+    for i in 0 ..< x.len:
+      result.add(toJsonImpl(x[i]))
+    result = newCall(bindSym("%", brOpen), result)
+  of nnkTableConstr: # object
+    if x.len == 0: return newCall(bindSym"newJObject")
+    result = newNimNode(nnkTableConstr)
+    for i in 0 ..< x.len:
+      x[i].expectKind nnkExprColonExpr
+      result.add newTree(nnkExprColonExpr, x[i][0], toJsonImpl(x[i][1]))
+    result = newCall(bindSym("%", brOpen), result)
+  of nnkCurly: # empty object
+    x.expectLen(0)
+    result = newCall(bindSym"newJObject")
+  of nnkNilLit:
+    result = newCall(bindSym"newJNull")
+  of nnkPar:
+    if x.len == 1: result = toJsonImpl(x[0])
+    else: result = newCall(bindSym("%", brOpen), x)
+  else:
+    result = newCall(bindSym("%", brOpen), x)
+
+macro `%*`*(x: untyped): untyped =
+  ## Convert an expression to a JsonNode directly, without having to specify
+  ## `%` for every element.
+  result = toJsonImpl(x)
+
+proc `==`*(a, b: JsonNode): bool {.noSideEffect, raises: [].} =
+  ## Check two nodes for equality
+  if a.isNil:
+    if b.isNil: return true
+    return false
+  elif b.isNil or a.kind != b.kind:
+    return false
+  else:
+    case a.kind
+    of JString:
+      result = a.str == b.str
+    of JInt:
+      result = a.num == b.num
+    of JFloat:
+      result = a.fnum == b.fnum
+    of JBool:
+      result = a.bval == b.bval
+    of JNull:
+      result = true
+    of JArray:
+      {.cast(raises: []).}: # bug #19303
+        result = a.elems == b.elems
+    of JObject:
+      # we cannot use OrderedTable's equality here as
+      # the order does not matter for equality here.
+      if a.fields.len != b.fields.len: return false
+      for key, val in a.fields:
+        if not b.fields.hasKey(key): return false
+        {.cast(raises: []).}:
+          when defined(nimHasEffectsOf):
+            {.noSideEffect.}:
+              if b.fields[key] != val: return false
+          else:
+            if b.fields[key] != val: return false
+      result = true
+
+proc hash*(n: OrderedTable[string, JsonNode]): Hash {.noSideEffect.}
+
+proc hash*(n: JsonNode): Hash {.noSideEffect.} =
+  ## 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 hash*(n: OrderedTable[string, JsonNode]): Hash =
+  for key, val in n:
+    result = result xor (hash(key) !& hash(val))
+  result = !$result
+
+proc len*(n: JsonNode): int =
+  ## If `n` is a `JArray`, it returns the number of elements.
+  ## If `n` is a `JObject`, it returns the number of pairs.
+  ## Else it returns 0.
+  case n.kind
+  of JArray: result = n.elems.len
+  of JObject: result = n.fields.len
+  else: discard
+
+proc `[]`*(node: JsonNode, name: string): JsonNode {.inline.} =
+  ## Gets a field from a `JObject`, which must not be nil.
+  ## If the value at `name` does not exist, raises KeyError.
+  assert(not isNil(node))
+  assert(node.kind == JObject)
+  when defined(nimJsonGet):
+    if not node.fields.hasKey(name): return nil
+  result = node.fields[name]
+
+proc `[]`*(node: JsonNode, index: int): JsonNode {.inline.} =
+  ## Gets the node at `index` in an Array. Result is undefined if `index`
+  ## is out of bounds, but as long as array bound checks are enabled it will
+  ## result in an exception.
+  assert(not isNil(node))
+  assert(node.kind == JArray)
+  return node.elems[index]
+
+proc `[]`*(node: JsonNode, index: BackwardsIndex): JsonNode {.inline, since: (1, 5, 1).} =
+  ## Gets the node at `array.len-i` in an array through the `^` operator.
+  ##
+  ## i.e. `j[^i]` is a shortcut for `j[j.len-i]`.
+  runnableExamples:
+    let
+      j = parseJson("[1,2,3,4,5]")
+
+    doAssert j[^1].getInt == 5
+    doAssert j[^2].getInt == 4
+
+  `[]`(node, node.len - int(index))
+
+proc `[]`*[U, V](a: JsonNode, x: HSlice[U, V]): JsonNode =
+  ## Slice operation for JArray.
+  ##
+  ## Returns the inclusive range `[a[x.a], a[x.b]]`:
+  runnableExamples:
+    import std/json
+    let arr = %[0,1,2,3,4,5]
+    doAssert arr[2..4] == %[2,3,4]
+    doAssert arr[2..^2] == %[2,3,4]
+    doAssert arr[^4..^2] == %[2,3,4]
+
+  assert(a.kind == JArray)
+  result = newJArray()
+  let xa = (when x.a is BackwardsIndex: a.len - int(x.a) else: int(x.a))
+  let L = (when x.b is BackwardsIndex: a.len - int(x.b) else: int(x.b)) - xa + 1
+  for i in 0..<L:
+    result.add(a[i + xa])
+
+proc hasKey*(node: JsonNode, key: string): bool =
+  ## Checks if `key` exists in `node`.
+  assert(node.kind == JObject)
+  result = node.fields.hasKey(key)
+
+proc contains*(node: JsonNode, key: string): bool =
+  ## Checks if `key` exists in `node`.
+  assert(node.kind == JObject)
+  node.fields.hasKey(key)
+
+proc contains*(node: JsonNode, val: JsonNode): bool =
+  ## Checks if `val` exists in array `node`.
+  assert(node.kind == JArray)
+  find(node.elems, val) >= 0
+
+proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode =
+  ## Traverses the node and gets the given value. If any of the
+  ## keys do not exist, returns `nil`. Also returns `nil` if one of the
+  ## intermediate data structures is not an object.
+  ##
+  ## This proc can be used to create tree structures on the
+  ## fly (sometimes called `autovivification`:idx:):
+  ##
+  runnableExamples:
+    var myjson = %* {"parent": {"child": {"grandchild": 1}}}
+    doAssert myjson{"parent", "child", "grandchild"} == newJInt(1)
+
+  result = node
+  for key in keys:
+    if isNil(result) or result.kind != JObject:
+      return nil
+    result = result.fields.getOrDefault(key)
+
+proc `{}`*(node: JsonNode, index: varargs[int]): JsonNode =
+  ## Traverses the node and gets the given value. If any of the
+  ## indexes do not exist, returns `nil`. Also returns `nil` if one of the
+  ## intermediate data structures is not an array.
+  result = node
+  for i in index:
+    if isNil(result) or result.kind != JArray or i >= node.len:
+      return nil
+    result = result.elems[i]
+
+proc getOrDefault*(node: JsonNode, key: string): JsonNode =
+  ## Gets a field from a `node`. If `node` is nil or not an object or
+  ## value at `key` does not exist, returns nil
+  if not isNil(node) and node.kind == JObject:
+    result = node.fields.getOrDefault(key)
+
+proc `{}`*(node: JsonNode, key: string): JsonNode =
+  ## Gets a field from a `node`. If `node` is nil or not an object or
+  ## value at `key` does not exist, returns nil
+  node.getOrDefault(key)
+
+proc `{}=`*(node: JsonNode, keys: varargs[string], value: JsonNode) =
+  ## Traverses the node and tries to set the value at the given location
+  ## to `value`. If any of the keys are missing, they are added.
+  var node = node
+  for i in 0..(keys.len-2):
+    if not node.hasKey(keys[i]):
+      node[keys[i]] = newJObject()
+    node = node[keys[i]]
+  node[keys[keys.len-1]] = value
+
+proc delete*(obj: JsonNode, key: string) =
+  ## Deletes `obj[key]`.
+  assert(obj.kind == JObject)
+  if not obj.fields.hasKey(key):
+    raise newException(KeyError, "key not in object")
+  obj.fields.del(key)
+
+proc copy*(p: JsonNode): JsonNode =
+  ## Performs a deep copy of `p`.
+  case p.kind
+  of JString:
+    result = newJString(p.str)
+    result.isUnquoted = p.isUnquoted
+  of JInt:
+    result = newJInt(p.num)
+  of JFloat:
+    result = newJFloat(p.fnum)
+  of JBool:
+    result = newJBool(p.bval)
+  of JNull:
+    result = newJNull()
+  of JObject:
+    result = newJObject()
+    for key, val in pairs(p.fields):
+      result.fields[key] = copy(val)
+  of JArray:
+    result = newJArray()
+    for i in items(p.elems):
+      result.elems.add(copy(i))
+
+# ------------- pretty printing ----------------------------------------------
+
+proc indent(s: var string, i: int) =
+  s.add(spaces(i))
+
+proc newIndent(curr, indent: int, ml: bool): int =
+  if ml: return curr + indent
+  else: return indent
+
+proc nl(s: var string, ml: bool) =
+  s.add(if ml: "\n" else: " ")
+
+proc escapeJsonUnquoted*(s: string; result: var string) =
+  ## Converts a string `s` to its JSON representation without quotes.
+  ## Appends to `result`.
+  for c in s:
+    case c
+    of '\L': result.add("\\n")
+    of '\b': result.add("\\b")
+    of '\f': result.add("\\f")
+    of '\t': result.add("\\t")
+    of '\v': result.add("\\u000b")
+    of '\r': result.add("\\r")
+    of '"': result.add("\\\"")
+    of '\0'..'\7': result.add("\\u000" & $ord(c))
+    of '\14'..'\31': result.add("\\u00" & toHex(ord(c), 2))
+    of '\\': result.add("\\\\")
+    else: result.add(c)
+
+proc escapeJsonUnquoted*(s: string): string =
+  ## Converts a string `s` to its JSON representation without quotes.
+  result = newStringOfCap(s.len + s.len shr 3)
+  escapeJsonUnquoted(s, result)
+
+proc escapeJson*(s: string; result: var string) =
+  ## Converts a string `s` to its JSON representation with quotes.
+  ## Appends to `result`.
+  result.add("\"")
+  escapeJsonUnquoted(s, result)
+  result.add("\"")
+
+proc escapeJson*(s: string): string =
+  ## Converts a string `s` to its JSON representation with quotes.
+  result = newStringOfCap(s.len + s.len shr 3)
+  escapeJson(s, result)
+
+proc toUgly*(result: var string, node: JsonNode) =
+  ## Converts `node` to its JSON Representation, without
+  ## regard for human readability. Meant to improve `$` string
+  ## conversion performance.
+  ##
+  ## JSON representation is stored in the passed `result`
+  ##
+  ## This provides higher efficiency than the `pretty` procedure as it
+  ## does **not** attempt to format the resulting JSON to make it human readable.
+  var comma = false
+  case node.kind:
+  of JArray:
+    result.add "["
+    for child in node.elems:
+      if comma: result.add ","
+      else: comma = true
+      result.toUgly child
+    result.add "]"
+  of JObject:
+    result.add "{"
+    for key, value in pairs(node.fields):
+      if comma: result.add ","
+      else: comma = true
+      key.escapeJson(result)
+      result.add ":"
+      result.toUgly value
+    result.add "}"
+  of JString:
+    if node.isUnquoted:
+      result.add node.str
+    else:
+      escapeJson(node.str, result)
+  of JInt:
+    result.addInt(node.num)
+  of JFloat:
+    result.addFloat(node.fnum)
+  of JBool:
+    result.add(if node.bval: "true" else: "false")
+  of JNull:
+    result.add "null"
+
+proc toPretty(result: var string, node: JsonNode, indent = 2, ml = true,
+              lstArr = false, currIndent = 0) =
+  case node.kind
+  of JObject:
+    if lstArr: result.indent(currIndent) # Indentation
+    if node.fields.len > 0:
+      result.add("{")
+      result.nl(ml) # New line
+      var i = 0
+      for key, val in pairs(node.fields):
+        if i > 0:
+          result.add(",")
+          result.nl(ml) # New Line
+        inc i
+        # Need to indent more than {
+        result.indent(newIndent(currIndent, indent, ml))
+        escapeJson(key, result)
+        result.add(": ")
+        toPretty(result, val, indent, ml, false,
+                 newIndent(currIndent, indent, ml))
+      result.nl(ml)
+      result.indent(currIndent) # indent the same as {
+      result.add("}")
+    else:
+      result.add("{}")
+  of JString:
+    if lstArr: result.indent(currIndent)
+    toUgly(result, node)
+  of JInt:
+    if lstArr: result.indent(currIndent)
+    result.addInt(node.num)
+  of JFloat:
+    if lstArr: result.indent(currIndent)
+    result.addFloat(node.fnum)
+  of JBool:
+    if lstArr: result.indent(currIndent)
+    result.add(if node.bval: "true" else: "false")
+  of JArray:
+    if lstArr: result.indent(currIndent)
+    if len(node.elems) != 0:
+      result.add("[")
+      result.nl(ml)
+      for i in 0..len(node.elems)-1:
+        if i > 0:
+          result.add(",")
+          result.nl(ml) # New Line
+        toPretty(result, node.elems[i], indent, ml,
+            true, newIndent(currIndent, indent, ml))
+      result.nl(ml)
+      result.indent(currIndent)
+      result.add("]")
+    else: result.add("[]")
+  of JNull:
+    if lstArr: result.indent(currIndent)
+    result.add("null")
+
+proc pretty*(node: JsonNode, indent = 2): string =
+  ## Returns a JSON Representation of `node`, with indentation and
+  ## on multiple lines.
+  ##
+  ## Similar to prettyprint in Python.
+  runnableExamples:
+    let j = %* {"name": "Isaac", "books": ["Robot Dreams"],
+                "details": {"age": 35, "pi": 3.1415}}
+    doAssert pretty(j) == """
+{
+  "name": "Isaac",
+  "books": [
+    "Robot Dreams"
+  ],
+  "details": {
+    "age": 35,
+    "pi": 3.1415
+  }
+}"""
+  result = ""
+  toPretty(result, node, indent)
+
+proc `$`*(node: JsonNode): string =
+  ## Converts `node` to its JSON Representation on one line.
+  result = newStringOfCap(node.len shl 1)
+  toUgly(result, node)
+
+iterator items*(node: JsonNode): JsonNode =
+  ## Iterator for the items of `node`. `node` has to be a JArray.
+  assert node.kind == JArray, ": items() can not iterate a JsonNode of kind " & $node.kind
+  for i in items(node.elems):
+    yield i
+
+iterator mitems*(node: var JsonNode): var JsonNode =
+  ## Iterator for the items of `node`. `node` has to be a JArray. Items can be
+  ## modified.
+  assert node.kind == JArray, ": mitems() can not iterate a JsonNode of kind " & $node.kind
+  for i in mitems(node.elems):
+    yield i
+
+iterator pairs*(node: JsonNode): tuple[key: string, val: JsonNode] =
+  ## Iterator for the child elements of `node`. `node` has to be a JObject.
+  assert node.kind == JObject, ": pairs() can not iterate a JsonNode of kind " & $node.kind
+  for key, val in pairs(node.fields):
+    yield (key, val)
+
+iterator keys*(node: JsonNode): string =
+  ## Iterator for the keys in `node`. `node` has to be a JObject.
+  assert node.kind == JObject, ": keys() can not iterate a JsonNode of kind " & $node.kind
+  for key in node.fields.keys:
+    yield key
+
+iterator mpairs*(node: var JsonNode): tuple[key: string, val: var JsonNode] =
+  ## Iterator for the child elements of `node`. `node` has to be a JObject.
+  ## Values can be modified
+  assert node.kind == JObject, ": mpairs() can not iterate a JsonNode of kind " & $node.kind
+  for key, val in mpairs(node.fields):
+    yield (key, val)
+
+proc parseJson(p: var JsonParser; rawIntegers, rawFloats: bool, depth = 0): JsonNode =
+  ## Parses JSON from a JSON Parser `p`.
+  case p.tok
+  of tkString:
+    # we capture 'p.a' here, so we need to give it a fresh buffer afterwards:
+    when defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc):
+      result = JsonNode(kind: JString, str: move p.a)
+    else:
+      result = JsonNode(kind: JString)
+      shallowCopy(result.str, p.a)
+      p.a = ""
+    discard getTok(p)
+  of tkInt:
+    if rawIntegers:
+      result = newJRawNumber(p.a)
+    else:
+      try:
+        result = newJInt(parseBiggestInt(p.a))
+      except ValueError:
+        result = newJRawNumber(p.a)
+    discard getTok(p)
+  of tkFloat:
+    if rawFloats:
+      result = newJRawNumber(p.a)
+    else:
+      try:
+        result = newJFloat(parseFloat(p.a))
+      except ValueError:
+        result = newJRawNumber(p.a)
+    discard getTok(p)
+  of tkTrue:
+    result = newJBool(true)
+    discard getTok(p)
+  of tkFalse:
+    result = newJBool(false)
+    discard getTok(p)
+  of tkNull:
+    result = newJNull()
+    discard getTok(p)
+  of tkCurlyLe:
+    if depth > DepthLimit:
+      raiseParseErr(p, "}")
+    result = newJObject()
+    discard getTok(p)
+    while p.tok != tkCurlyRi:
+      if p.tok != tkString:
+        raiseParseErr(p, "string literal as key")
+      var key = p.a
+      discard getTok(p)
+      eat(p, tkColon)
+      var val = parseJson(p, rawIntegers, rawFloats, depth+1)
+      result[key] = val
+      if p.tok != tkComma: break
+      discard getTok(p)
+    eat(p, tkCurlyRi)
+  of tkBracketLe:
+    if depth > DepthLimit:
+      raiseParseErr(p, "]")
+    result = newJArray()
+    discard getTok(p)
+    while p.tok != tkBracketRi:
+      result.add(parseJson(p, rawIntegers, rawFloats, depth+1))
+      if p.tok != tkComma: break
+      discard getTok(p)
+    eat(p, tkBracketRi)
+  of tkError, tkCurlyRi, tkBracketRi, tkColon, tkComma, tkEof:
+    raiseParseErr(p, "{")
+
+iterator parseJsonFragments*(s: Stream, filename: string = ""; rawIntegers = false, rawFloats = false): JsonNode =
+  ## Parses from a stream `s` into `JsonNodes`. `filename` is only needed
+  ## for nice error messages.
+  ## The JSON fragments are separated by whitespace. This can be substantially
+  ## faster than the comparable loop
+  ## `for x in splitWhitespace(s): yield parseJson(x)`.
+  ## This closes the stream `s` after it's done.
+  ## If `rawIntegers` is true, integer literals will not be converted to a `JInt`
+  ## field but kept as raw numbers via `JString`.
+  ## If `rawFloats` is true, floating point literals will not be converted to a `JFloat`
+  ## field but kept as raw numbers via `JString`.
+  var p: JsonParser
+  p.open(s, filename)
+  try:
+    discard getTok(p) # read first token
+    while p.tok != tkEof:
+      yield p.parseJson(rawIntegers, rawFloats)
+  finally:
+    p.close()
+
+proc parseJson*(s: Stream, filename: string = ""; rawIntegers = false, rawFloats = false): JsonNode =
+  ## Parses from a stream `s` into a `JsonNode`. `filename` is only needed
+  ## for nice error messages.
+  ## If `s` contains extra data, it will raise `JsonParsingError`.
+  ## This closes the stream `s` after it's done.
+  ## If `rawIntegers` is true, integer literals will not be converted to a `JInt`
+  ## field but kept as raw numbers via `JString`.
+  ## If `rawFloats` is true, floating point literals will not be converted to a `JFloat`
+  ## field but kept as raw numbers via `JString`.
+  var p: JsonParser
+  p.open(s, filename)
+  try:
+    discard getTok(p) # read first token
+    result = p.parseJson(rawIntegers, rawFloats)
+    eat(p, tkEof) # check if there is no extra data
+  finally:
+    p.close()
+
+when defined(js):
+  from std/math import `mod`
+  from std/jsffi import JsObject, `[]`, to
+  from std/private/jsutils import getProtoName, isInteger, isSafeInteger
+
+  proc parseNativeJson(x: cstring): JsObject {.importjs: "JSON.parse(#)".}
+
+  proc getVarType(x: JsObject, isRawNumber: var bool): JsonNodeKind =
+    result = JNull
+    case $getProtoName(x) # TODO: Implicit returns fail here.
+    of "[object Array]": return JArray
+    of "[object Object]": return JObject
+    of "[object Number]":
+      if isInteger(x) and 1.0 / cast[float](x) != -Inf: # preserve -0.0 as float
+        if isSafeInteger(x):
+          return JInt
+        else:
+          isRawNumber = true
+          return JString
+      else:
+        return JFloat
+    of "[object Boolean]": return JBool
+    of "[object Null]": return JNull
+    of "[object String]": return JString
+    else: assert false
+
+  proc len(x: JsObject): int =
+    {.emit: """
+      `result` = `x`.length;
+    """.}
+
+  proc convertObject(x: JsObject): JsonNode =
+    var isRawNumber = false
+    case getVarType(x, isRawNumber)
+    of JArray:
+      result = newJArray()
+      for i in 0 ..< x.len:
+        result.add(x[i].convertObject())
+    of JObject:
+      result = newJObject()
+      {.emit: """for (var property in `x`) {
+        if (`x`.hasOwnProperty(property)) {
+      """.}
+
+      var nimProperty: cstring
+      var nimValue: JsObject
+      {.emit: "`nimProperty` = property; `nimValue` = `x`[property];".}
+      result[$nimProperty] = nimValue.convertObject()
+      {.emit: "}}".}
+    of JInt:
+      result = newJInt(x.to(int))
+    of JFloat:
+      result = newJFloat(x.to(float))
+    of JString:
+      # Dunno what to do with isUnquoted here
+      if isRawNumber:
+        var value: cstring
+        {.emit: "`value` = `x`.toString();".}
+        result = newJRawNumber($value)
+      else:
+        result = newJString($x.to(cstring))
+    of JBool:
+      result = newJBool(x.to(bool))
+    of JNull:
+      result = newJNull()
+
+  proc parseJson*(buffer: string): JsonNode =
+    when nimvm:
+      return parseJson(newStringStream(buffer), "input")
+    else:
+      return parseNativeJson(buffer).convertObject()
+
+else:
+  proc parseJson*(buffer: string; rawIntegers = false, rawFloats = false): JsonNode =
+    ## Parses JSON from `buffer`.
+    ## If `buffer` contains extra data, it will raise `JsonParsingError`.
+    ## If `rawIntegers` is true, integer literals will not be converted to a `JInt`
+    ## field but kept as raw numbers via `JString`.
+    ## If `rawFloats` is true, floating point literals will not be converted to a `JFloat`
+    ## field but kept as raw numbers via `JString`.
+    result = parseJson(newStringStream(buffer), "input", rawIntegers, rawFloats)
+
+  proc parseFile*(filename: string): JsonNode =
+    ## Parses `file` into a `JsonNode`.
+    ## If `file` contains extra data, it will raise `JsonParsingError`.
+    var stream = newFileStream(filename, fmRead)
+    if stream == nil:
+      raise newException(IOError, "cannot read from file: " & filename)
+    result = parseJson(stream, filename, rawIntegers=false, rawFloats=false)
+
+# -- Json deserialiser. --
+
+template verifyJsonKind(node: JsonNode, kinds: set[JsonNodeKind],
+                        ast: string) =
+  if node == nil:
+    raise newException(KeyError, "key not found: " & ast)
+  elif  node.kind notin kinds:
+    let msg = "Incorrect JSON kind. Wanted '$1' in '$2' but got '$3'." % [
+      $kinds,
+      ast,
+      $node.kind
+    ]
+    raise newException(JsonKindError, msg)
+
+macro isRefSkipDistinct*(arg: typed): untyped =
+  ## internal only, do not use
+  var impl = getTypeImpl(arg)
+  if impl.kind == nnkBracketExpr and impl[0].eqIdent("typeDesc"):
+    impl = getTypeImpl(impl[1])
+  while impl.kind == nnkDistinctTy:
+    impl = getTypeImpl(impl[0])
+  result = newLit(impl.kind == nnkRefTy)
+
+# The following forward declarations don't work in older versions of Nim
+
+# forward declare all initFromJson
+
+proc initFromJson(dst: var string; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson(dst: var bool; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson(dst: var JsonNode; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T: SomeInteger](dst: var T; jsonNode: JsonNode, jsonPath: var string)
+proc initFromJson[T: SomeFloat](dst: var T; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T: enum](dst: var T; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T](dst: var seq[T]; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[S, T](dst: var array[S, T]; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T](dst: var Table[string, T]; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T](dst: var OrderedTable[string, T]; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T](dst: var ref T; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T](dst: var Option[T]; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T: distinct](dst: var T; jsonNode: JsonNode; jsonPath: var string)
+proc initFromJson[T: object|tuple](dst: var T; jsonNode: JsonNode; jsonPath: var string)
+
+# initFromJson definitions
+
+proc initFromJson(dst: var string; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JString, JNull}, jsonPath)
+  # since strings don't have a nil state anymore, this mapping of
+  # JNull to the default string is questionable. `none(string)` and
+  # `some("")` have the same potentional json value `JNull`.
+  if jsonNode.kind == JNull:
+    dst = ""
+  else:
+    dst = jsonNode.str
+
+proc initFromJson(dst: var bool; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JBool}, jsonPath)
+  dst = jsonNode.bval
+
+proc initFromJson(dst: var JsonNode; jsonNode: JsonNode; jsonPath: var string) =
+  if jsonNode == nil:
+    raise newException(KeyError, "key not found: " & jsonPath)
+  dst = jsonNode.copy
+
+proc initFromJson[T: SomeInteger](dst: var T; jsonNode: JsonNode, jsonPath: var string) =
+  when T is uint|uint64 or int.sizeof == 4:
+    verifyJsonKind(jsonNode, {JInt, JString}, jsonPath)
+    case jsonNode.kind
+    of JString:
+      let x = parseBiggestUInt(jsonNode.str)
+      dst = cast[T](x)
+    else:
+      dst = T(jsonNode.num)
+  else:
+    verifyJsonKind(jsonNode, {JInt}, jsonPath)
+    dst = cast[T](jsonNode.num)
+
+proc initFromJson[T: SomeFloat](dst: var T; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JInt, JFloat, JString}, jsonPath)
+  if jsonNode.kind == JString:
+    case jsonNode.str
+    of "nan":
+      let b = NaN
+      dst = T(b)
+      # dst = NaN # would fail some tests because range conversions would cause CT error
+      # in some cases; but this is not a hot-spot inside this branch and backend can optimize this.
+    of "inf":
+      let b = Inf
+      dst = T(b)
+    of "-inf":
+      let b = -Inf
+      dst = T(b)
+    else: raise newException(JsonKindError, "expected 'nan|inf|-inf', got " & jsonNode.str)
+  else:
+    if jsonNode.kind == JFloat:
+      dst = T(jsonNode.fnum)
+    else:
+      dst = T(jsonNode.num)
+
+proc initFromJson[T: enum](dst: var T; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JString}, jsonPath)
+  dst = parseEnum[T](jsonNode.getStr)
+
+proc initFromJson[T](dst: var seq[T]; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JArray}, jsonPath)
+  dst.setLen jsonNode.len
+  let orignalJsonPathLen = jsonPath.len
+  for i in 0 ..< jsonNode.len:
+    jsonPath.add '['
+    jsonPath.addInt i
+    jsonPath.add ']'
+    initFromJson(dst[i], jsonNode[i], jsonPath)
+    jsonPath.setLen orignalJsonPathLen
+
+proc initFromJson[S,T](dst: var array[S,T]; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JArray}, jsonPath)
+  let originalJsonPathLen = jsonPath.len
+  for i in 0 ..< jsonNode.len:
+    jsonPath.add '['
+    jsonPath.addInt i
+    jsonPath.add ']'
+    initFromJson(dst[i.S], jsonNode[i], jsonPath) # `.S` for enum indexed arrays
+    jsonPath.setLen originalJsonPathLen
+
+proc initFromJson[T](dst: var Table[string,T]; jsonNode: JsonNode; jsonPath: var string) =
+  dst = initTable[string, T]()
+  verifyJsonKind(jsonNode, {JObject}, jsonPath)
+  let originalJsonPathLen = jsonPath.len
+  for key in keys(jsonNode.fields):
+    jsonPath.add '.'
+    jsonPath.add key
+    initFromJson(mgetOrPut(dst, key, default(T)), jsonNode[key], jsonPath)
+    jsonPath.setLen originalJsonPathLen
+
+proc initFromJson[T](dst: var OrderedTable[string,T]; jsonNode: JsonNode; jsonPath: var string) =
+  dst = initOrderedTable[string,T]()
+  verifyJsonKind(jsonNode, {JObject}, jsonPath)
+  let originalJsonPathLen = jsonPath.len
+  for key in keys(jsonNode.fields):
+    jsonPath.add '.'
+    jsonPath.add key
+    initFromJson(mgetOrPut(dst, key, default(T)), jsonNode[key], jsonPath)
+    jsonPath.setLen originalJsonPathLen
+
+proc initFromJson[T](dst: var ref T; jsonNode: JsonNode; jsonPath: var string) =
+  verifyJsonKind(jsonNode, {JObject, JNull}, jsonPath)
+  if jsonNode.kind == JNull:
+    dst = nil
+  else:
+    dst = new(T)
+    initFromJson(dst[], jsonNode, jsonPath)
+
+proc initFromJson[T](dst: var Option[T]; jsonNode: JsonNode; jsonPath: var string) =
+  if jsonNode != nil and jsonNode.kind != JNull:
+    when T is ref:
+      dst = some(new(T))
+    else:
+      dst = some(default(T))
+    initFromJson(dst.get, jsonNode, jsonPath)
+
+macro assignDistinctImpl[T: distinct](dst: var T;jsonNode: JsonNode; jsonPath: var string) =
+  let typInst = getTypeInst(dst)
+  let typImpl = getTypeImpl(dst)
+  let baseTyp = typImpl[0]
+
+  result = quote do:
+    initFromJson(`baseTyp`(`dst`), `jsonNode`, `jsonPath`)
+
+proc initFromJson[T: distinct](dst: var T; jsonNode: JsonNode; jsonPath: var string) =
+  assignDistinctImpl(dst, jsonNode, jsonPath)
+
+proc detectIncompatibleType(typeExpr, lineinfoNode: NimNode) =
+  if typeExpr.kind == nnkTupleConstr:
+    error("Use a named tuple instead of: " & typeExpr.repr, lineinfoNode)
+
+proc foldObjectBody(dst, typeNode, tmpSym, jsonNode, jsonPath, originalJsonPathLen: NimNode) =
+  case typeNode.kind
+  of nnkEmpty:
+    discard
+  of nnkRecList, nnkTupleTy:
+    for it in typeNode:
+      foldObjectBody(dst, it, tmpSym, jsonNode, jsonPath, originalJsonPathLen)
+
+  of nnkIdentDefs:
+    typeNode.expectLen 3
+    let fieldSym = typeNode[0]
+    let fieldNameLit = newLit(fieldSym.strVal)
+    let fieldPathLit = newLit("." & fieldSym.strVal)
+    let fieldType = typeNode[1]
+
+    # Detecting incompatiple tuple types in `assignObjectImpl` only
+    # would be much cleaner, but the ast for tuple types does not
+    # contain usable type information.
+    detectIncompatibleType(fieldType, fieldSym)
+
+    dst.add quote do:
+      jsonPath.add `fieldPathLit`
+      when nimvm:
+        when isRefSkipDistinct(`tmpSym`.`fieldSym`):
+          # workaround #12489
+          var tmp: `fieldType`
+          initFromJson(tmp, getOrDefault(`jsonNode`,`fieldNameLit`), `jsonPath`)
+          `tmpSym`.`fieldSym` = tmp
+        else:
+          initFromJson(`tmpSym`.`fieldSym`, getOrDefault(`jsonNode`,`fieldNameLit`), `jsonPath`)
+      else:
+        initFromJson(`tmpSym`.`fieldSym`, getOrDefault(`jsonNode`,`fieldNameLit`), `jsonPath`)
+      jsonPath.setLen `originalJsonPathLen`
+
+  of nnkRecCase:
+    let kindSym = typeNode[0][0]
+    let kindNameLit = newLit(kindSym.strVal)
+    let kindPathLit = newLit("." & kindSym.strVal)
+    let kindType = typeNode[0][1]
+    let kindOffsetLit = newLit(uint(getOffset(kindSym)))
+    dst.add quote do:
+      var kindTmp: `kindType`
+      jsonPath.add `kindPathLit`
+      initFromJson(kindTmp, `jsonNode`[`kindNameLit`], `jsonPath`)
+      jsonPath.setLen `originalJsonPathLen`
+      when defined js:
+        `tmpSym`.`kindSym` = kindTmp
+      else:
+        when nimvm:
+          `tmpSym`.`kindSym` = kindTmp
+        else:
+          # fuck it, assign kind field anyway
+          ((cast[ptr `kindType`](cast[uint](`tmpSym`.addr) + `kindOffsetLit`))[]) = kindTmp
+    dst.add nnkCaseStmt.newTree(nnkDotExpr.newTree(tmpSym, kindSym))
+    for i in 1 ..< typeNode.len:
+      foldObjectBody(dst, typeNode[i], tmpSym, jsonNode, jsonPath, originalJsonPathLen)
+
+  of nnkOfBranch, nnkElse:
+    let ofBranch = newNimNode(typeNode.kind)
+    for i in 0 ..< typeNode.len-1:
+      ofBranch.add copyNimTree(typeNode[i])
+    let dstInner = newNimNode(nnkStmtListExpr)
+    foldObjectBody(dstInner, typeNode[^1], tmpSym, jsonNode, jsonPath, originalJsonPathLen)
+    # resOuter now contains the inner stmtList
+    ofBranch.add dstInner
+    dst[^1].expectKind nnkCaseStmt
+    dst[^1].add ofBranch
+
+  of nnkObjectTy:
+    typeNode[0].expectKind nnkEmpty
+    typeNode[1].expectKind {nnkEmpty, nnkOfInherit}
+    if typeNode[1].kind == nnkOfInherit:
+      let base = typeNode[1][0]
+      var impl = getTypeImpl(base)
+      while impl.kind in {nnkRefTy, nnkPtrTy}:
+        impl = getTypeImpl(impl[0])
+      foldObjectBody(dst, impl, tmpSym, jsonNode, jsonPath, originalJsonPathLen)
+    let body = typeNode[2]
+    foldObjectBody(dst, body, tmpSym, jsonNode, jsonPath, originalJsonPathLen)
+
+  else:
+    error("unhandled kind: " & $typeNode.kind, typeNode)
+
+macro assignObjectImpl[T](dst: var T; jsonNode: JsonNode; jsonPath: var string) =
+  let typeSym = getTypeInst(dst)
+  let originalJsonPathLen = genSym(nskLet, "originalJsonPathLen")
+  result = newStmtList()
+  result.add quote do:
+    let `originalJsonPathLen` = len(`jsonPath`)
+  if typeSym.kind in {nnkTupleTy, nnkTupleConstr}:
+    # both, `dst` and `typeSym` don't have good lineinfo. But nothing
+    # else is available here.
+    detectIncompatibleType(typeSym, dst)
+    foldObjectBody(result, typeSym, dst, jsonNode, jsonPath, originalJsonPathLen)
+  else:
+    foldObjectBody(result, typeSym.getTypeImpl, dst, jsonNode, jsonPath, originalJsonPathLen)
+
+proc initFromJson[T: object|tuple](dst: var T; jsonNode: JsonNode; jsonPath: var string) =
+  assignObjectImpl(dst, jsonNode, jsonPath)
+
+proc to*[T](node: JsonNode, t: typedesc[T]): T =
+  ## `Unmarshals`:idx: the specified node into the object type specified.
+  ##
+  ## Known limitations:
+  ##
+  ##   * Heterogeneous arrays are not supported.
+  ##   * Sets in object variants are not supported.
+  ##   * Not nil annotations are not supported.
+  ##
+  runnableExamples:
+    let jsonNode = parseJson("""
+      {
+        "person": {
+          "name": "Nimmer",
+          "age": 21
+        },
+        "list": [1, 2, 3, 4]
+      }
+    """)
+
+    type
+      Person = object
+        name: string
+        age: int
+
+      Data = object
+        person: Person
+        list: seq[int]
+
+    var data = to(jsonNode, Data)
+    doAssert data.person.name == "Nimmer"
+    doAssert data.person.age == 21
+    doAssert data.list == @[1, 2, 3, 4]
+
+  var jsonPath = ""
+  result = default(T)
+  initFromJson(result, node, jsonPath)
+
+when false:
+  import std/os
+  var s = newFileStream(paramStr(1), fmRead)
+  if s == nil: quit("cannot open the file" & paramStr(1))
+  var x: JsonParser
+  open(x, s, paramStr(1))
+  while true:
+    next(x)
+    case x.kind
+    of jsonError:
+      Echo(x.errorMsg())
+      break
+    of jsonEof: break
+    of jsonString, jsonInt, jsonFloat: echo(x.str)
+    of jsonTrue: echo("!TRUE")
+    of jsonFalse: echo("!FALSE")
+    of jsonNull: echo("!NULL")
+    of jsonObjectStart: echo("{")
+    of jsonObjectEnd: echo("}")
+    of jsonArrayStart: echo("[")
+    of jsonArrayEnd: echo("]")
+
+  close(x)
+
+# { "json": 5 }
+# To get that we shall use, obj["json"]
diff --git a/lib/pure/lenientops.nim b/lib/pure/lenientops.nim
new file mode 100644
index 000000000..a8fc78e39
--- /dev/null
+++ b/lib/pure/lenientops.nim
@@ -0,0 +1,58 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module offers implementations of common binary operations
+## like `+`, `-`, `*`, `/` and comparison operations,
+## which work for mixed float/int operands.
+## All operations convert the integer operand into the
+## type of the float operand. For numerical expressions, the return
+## type is always the type of the float involved in the expression,
+## i.e., there is no auto conversion from float32 to float64.
+##
+## **Note:** In general, auto-converting from int to float loses
+## information, which is why these operators live in a separate
+## module. Use with care.
+##
+## Regarding binary comparison, this module only provides unequal operators.
+## The equality operator `==` is omitted, because depending on the use case
+## either casting to float or rounding to int might be preferred, and users
+## should make an explicit choice.
+
+func `+`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.inline.} =
+  F(i) + f
+func `+`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.inline.} =
+  f + F(i)
+
+func `-`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.inline.} =
+  F(i) - f
+func `-`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.inline.} =
+  f - F(i)
+
+func `*`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.inline.} =
+  F(i) * f
+func `*`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.inline.} =
+  f * F(i)
+
+func `/`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.inline.} =
+  F(i) / f
+func `/`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.inline.} =
+  f / F(i)
+
+func `<`*[I: SomeInteger, F: SomeFloat](i: I, f: F): bool {.inline.} =
+  F(i) < f
+func `<`*[I: SomeInteger, F: SomeFloat](f: F, i: I): bool {.inline.} =
+  f < F(i)
+func `<=`*[I: SomeInteger, F: SomeFloat](i: I, f: F): bool {.inline.} =
+  F(i) <= f
+func `<=`*[I: SomeInteger, F: SomeFloat](f: F, i: I): bool {.inline.} =
+  f <= F(i)
+
+# Note that we must not defined `>=` and `>`, because system.nim already has a
+# template with signature (x, y: untyped): untyped, which would lead to
+# ambiguous calls.
diff --git a/lib/pure/lexbase.nim b/lib/pure/lexbase.nim
index bb207e92a..1efd97b24 100755..100644
--- a/lib/pure/lexbase.nim
+++ b/lib/pure/lexbase.nim
@@ -1,6 +1,6 @@
 #
 #
-#           The Nimrod Compiler
+#            Nim's Runtime Library
 #        (c) Copyright 2009 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -12,10 +12,13 @@
 ## needs refilling.
 
 import
-  strutils, streams
+  std/[strutils, streams]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
 const
-  EndOfFile* = '\0'           ## end of file marker
+  EndOfFile* = '\0' ## end of file marker
   NewLines* = {'\c', '\L'}
 
 # Buffer handling:
@@ -25,48 +28,22 @@ const
 #
 
 type
-  TBaseLexer* = object of TObject ## the base lexer. Inherit your lexer from
-                                  ## this object.
-    bufpos*: int              ## the current position within the buffer
-    buf*: cstring             ## the buffer itself
-    bufLen*: int              ## length of buffer in characters
-    input: PStream            ## the input stream
-    LineNumber*: int          ## the current line number
+  BaseLexer* = object of RootObj ## the base lexer. Inherit your lexer from
+                                 ## this object.
+    bufpos*: int                 ## the current position within the buffer
+    buf*: string                 ## the buffer itself
+    input: Stream                ## the input stream
+    lineNumber*: int             ## the current line number
     sentinel: int
-    lineStart: int            # index of last line start in buffer
-    fileOpened: bool
-
-proc open*(L: var TBaseLexer, input: PStream, bufLen: int = 8192)
-  ## inits the TBaseLexer with a stream to read from
+    lineStart: int               # index of last line start in buffer
+    offsetBase*: int             # use `offsetBase + bufpos` to get the offset
+    refillChars: set[char]
 
-proc close*(L: var TBaseLexer)
+proc close*(L: var BaseLexer) =
   ## closes the base lexer. This closes `L`'s associated stream too.
+  close(L.input)
 
-proc getCurrentLine*(L: TBaseLexer, marker: bool = true): string
-  ## retrieves the current line.
-
-proc getColNumber*(L: TBaseLexer, pos: int): int
-  ## retrieves the current column.
-
-proc HandleCR*(L: var TBaseLexer, pos: int): int
-  ## Call this if you scanned over '\c' in the buffer; it returns the the
-  ## position to continue the scanning from. `pos` must be the position
-  ## of the '\c'.
-proc HandleLF*(L: var TBaseLexer, pos: int): int
-  ## Call this if you scanned over '\L' in the buffer; it returns the the
-  ## position to continue the scanning from. `pos` must be the position
-  ## of the '\L'.
-
-# implementation
-
-const
-  chrSize = sizeof(char)
-
-proc close(L: var TBaseLexer) =
-  dealloc(L.buf)
-  L.input.close(L.input)
-
-proc FillBuffer(L: var TBaseLexer) =
+proc fillBuffer(L: var BaseLexer) =
   var
     charsRead, toCopy, s: int # all are in characters,
                               # not bytes (in case this
@@ -74,23 +51,32 @@ proc FillBuffer(L: var TBaseLexer) =
     oldBufLen: int
   # we know here that pos == L.sentinel, but not if this proc
   # is called the first time by initBaseLexer()
-  assert(L.sentinel < L.bufLen)
-  toCopy = L.BufLen - L.sentinel - 1
+  assert(L.sentinel + 1 <= L.buf.len)
+  toCopy = L.buf.len - (L.sentinel + 1)
   assert(toCopy >= 0)
   if toCopy > 0:
-    MoveMem(L.buf, addr(L.buf[L.sentinel + 1]), toCopy * chrSize) # "moveMem" handles overlapping regions
-  charsRead = L.input.readData(L.input, addr(L.buf[toCopy]),
-                               (L.sentinel + 1) * chrSize) div chrSize
+    when defined(js) or defined(nimscript):
+      # nimscript has to be here to avoid compiling other branch (moveMem)
+      for i in 0 ..< toCopy:
+        L.buf[i] = L.buf[L.sentinel + 1 + i]
+    else:
+      when nimvm:
+        for i in 0 ..< toCopy:
+          L.buf[i] = L.buf[L.sentinel + 1 + i]
+      else:
+        # "moveMem" handles overlapping regions
+        moveMem(addr L.buf[0], addr L.buf[L.sentinel + 1], toCopy)
+  charsRead = L.input.readDataStr(L.buf, toCopy ..< toCopy + L.sentinel + 1)
   s = toCopy + charsRead
   if charsRead < L.sentinel + 1:
-    L.buf[s] = EndOfFile      # set end marker
+    L.buf[s] = EndOfFile # set end marker
     L.sentinel = s
   else:
     # compute sentinel:
-    dec(s)                    # BUGFIX (valgrind)
+    dec(s) # BUGFIX (valgrind)
     while true:
-      assert(s < L.bufLen)
-      while (s >= 0) and not (L.buf[s] in NewLines): Dec(s)
+      assert(s < L.buf.len)
+      while s >= 0 and L.buf[s] notin L.refillChars: dec(s)
       if s >= 0:
         # we found an appropriate character for a sentinel:
         L.sentinel = s
@@ -98,62 +84,78 @@ proc FillBuffer(L: var TBaseLexer) =
       else:
         # rather than to give up here because the line is too long,
         # double the buffer's size and try again:
-        oldBufLen = L.BufLen
-        L.bufLen = L.BufLen * 2
-        L.buf = cast[cstring](realloc(L.buf, L.bufLen * chrSize))
-        assert(L.bufLen - oldBuflen == oldBufLen)
-        charsRead = L.input.ReadData(L.input, addr(L.buf[oldBufLen]),
-                                     oldBufLen * chrSize) div chrSize
+        oldBufLen = L.buf.len
+        L.buf.setLen(L.buf.len * 2)
+        charsRead = readDataStr(L.input, L.buf, oldBufLen ..< L.buf.len)
         if charsRead < oldBufLen:
           L.buf[oldBufLen + charsRead] = EndOfFile
           L.sentinel = oldBufLen + charsRead
           break
-        s = L.bufLen - 1
+        s = L.buf.len - 1
 
-proc fillBaseLexer(L: var TBaseLexer, pos: int): int =
+proc fillBaseLexer(L: var BaseLexer, pos: int): int =
   assert(pos <= L.sentinel)
   if pos < L.sentinel:
-    result = pos + 1          # nothing to do
+    result = pos + 1 # nothing to do
   else:
     fillBuffer(L)
-    L.bufpos = 0              # XXX: is this really correct?
+    L.offsetBase += pos
+    L.bufpos = 0
     result = 0
-  L.lineStart = result
 
-proc HandleCR(L: var TBaseLexer, pos: int): int =
+proc handleCR*(L: var BaseLexer, pos: int): int =
+  ## Call this if you scanned over `'\c'` in the buffer; it returns the
+  ## position to continue the scanning from. `pos` must be the position
+  ## of the `'\c'`.
   assert(L.buf[pos] == '\c')
-  inc(L.linenumber)
+  inc(L.lineNumber)
   result = fillBaseLexer(L, pos)
   if L.buf[result] == '\L':
     result = fillBaseLexer(L, result)
+  L.lineStart = result
 
-proc HandleLF(L: var TBaseLexer, pos: int): int =
+proc handleLF*(L: var BaseLexer, pos: int): int =
+  ## Call this if you scanned over `'\L'` in the buffer; it returns the
+  ## position to continue the scanning from. `pos` must be the position
+  ## of the `'\L'`.
   assert(L.buf[pos] == '\L')
-  inc(L.linenumber)
+  inc(L.lineNumber)
+  result = fillBaseLexer(L, pos) #L.lastNL := result-1; // BUGFIX: was: result;
+  L.lineStart = result
+
+proc handleRefillChar*(L: var BaseLexer, pos: int): int =
+  ## Call this if a terminator character other than a new line is scanned
+  ## at `pos`; it returns the position to continue the scanning from.
+  assert(L.buf[pos] in L.refillChars)
   result = fillBaseLexer(L, pos) #L.lastNL := result-1; // BUGFIX: was: result;
 
-proc skip_UTF_8_BOM(L: var TBaseLexer) =
+proc skipUtf8Bom(L: var BaseLexer) =
   if (L.buf[0] == '\xEF') and (L.buf[1] == '\xBB') and (L.buf[2] == '\xBF'):
     inc(L.bufpos, 3)
     inc(L.lineStart, 3)
 
-proc open(L: var TBaseLexer, input: PStream, bufLen: int = 8192) =
+proc open*(L: var BaseLexer, input: Stream, bufLen: int = 8192;
+           refillChars: set[char] = NewLines) =
+  ## inits the BaseLexer with a stream to read from.
   assert(bufLen > 0)
   assert(input != nil)
   L.input = input
   L.bufpos = 0
-  L.bufLen = bufLen
-  L.buf = cast[cstring](alloc(bufLen * chrSize))
+  L.offsetBase = 0
+  L.refillChars = refillChars
+  L.buf = newString(bufLen)
   L.sentinel = bufLen - 1
   L.lineStart = 0
-  L.linenumber = 1            # lines start at 1
+  L.lineNumber = 1 # lines start at 1
   fillBuffer(L)
-  skip_UTF_8_BOM(L)
+  skipUtf8Bom(L)
 
-proc getColNumber(L: TBaseLexer, pos: int): int =
+proc getColNumber*(L: BaseLexer, pos: int): int =
+  ## retrieves the current column.
   result = abs(pos - L.lineStart)
 
-proc getCurrentLine(L: TBaseLexer, marker: bool = true): string =
+proc getCurrentLine*(L: BaseLexer, marker: bool = true): string =
+  ## retrieves the current line.
   var i: int
   result = ""
   i = L.lineStart
@@ -162,5 +164,4 @@ proc getCurrentLine(L: TBaseLexer, marker: bool = true): string =
     inc(i)
   add(result, "\n")
   if marker:
-    add(result, RepeatChar(getColNumber(L, L.bufpos)) & "^\n")
-
+    add(result, spaces(getColNumber(L, L.bufpos)) & "^\n")
diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim
index 6df39f50b..c30f68af8 100755..100644
--- a/lib/pure/logging.nim
+++ b/lib/pure/logging.nim
@@ -1,146 +1,907 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf, Dominik Picheta
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module implements a simple logger. It is based on the following design:
-## * Runtime log formating is a bug: Sooner or later ever log file is parsed.
-## * Keep it simple: If this library does not fullfill your needs, write your 
-##   own. Trying to support every logging feature just leads to bloat.
-## 
-## Format is:: 
+## This module implements a simple logger.
 ##
-##   DEBUG|INFO|... (2009-11-02 00:00:00)? (Component: )? Message
+## It has been designed to be as simple as possible to avoid bloat.
+## If this library does not fulfill your needs, write your own.
 ##
-## 
+## Basic usage
+## ===========
+##
+## To get started, first create a logger:
+##
+##   ```Nim
+##   import std/logging
+##
+##   var logger = newConsoleLogger()
+##   ```
+##
+## The logger that was created above logs to the console, but this module
+## also provides loggers that log to files, such as the
+## `FileLogger<#FileLogger>`_. Creating custom loggers is also possible by
+## inheriting from the `Logger<#Logger>`_ type.
+##
+## Once a logger has been created, call its `log proc
+## <#log.e,ConsoleLogger,Level,varargs[string,]>`_ to log a message:
+##
+##   ```Nim
+##   logger.log(lvlInfo, "a log message")
+##   # Output: INFO a log message
+##   ```
+##
+## The ``INFO`` within the output is the result of a format string being
+## prepended to the message, and it will differ depending on the message's
+## level. Format strings are `explained in more detail
+## here<#basic-usage-format-strings>`_.
+##
+## There are six logging levels: debug, info, notice, warn, error, and fatal.
+## They are described in more detail within the `Level enum's documentation
+## <#Level>`_. A message is logged if its level is at or above both the logger's
+## ``levelThreshold`` field and the global log filter. The latter can be changed
+## with the `setLogFilter proc<#setLogFilter,Level>`_.
+##
+## .. warning::
+##   For loggers that log to a console or to files, only error and fatal
+##   messages will cause their output buffers to be flushed immediately by default.
+##   set ``flushThreshold`` when creating the logger to change this.
+##
+## Handlers
+## --------
+##
+## When using multiple loggers, calling the log proc for each logger can
+## become repetitive. Instead of doing that, register each logger that will be
+## used with the `addHandler proc<#addHandler,Logger>`_, which is demonstrated
+## in the following example:
+##
+##   ```Nim
+##   import std/logging
+##
+##   var consoleLog = newConsoleLogger()
+##   var fileLog = newFileLogger("errors.log", levelThreshold=lvlError)
+##   var rollingLog = newRollingFileLogger("rolling.log")
+##
+##   addHandler(consoleLog)
+##   addHandler(fileLog)
+##   addHandler(rollingLog)
+##   ```
+##
+## After doing this, use either the `log template
+## <#log.t,Level,varargs[string,]>`_ or one of the level-specific templates,
+## such as the `error template<#error.t,varargs[string,]>`_, to log messages
+## to all registered handlers at once.
+##
+##   ```Nim
+##   # This example uses the loggers created above
+##   log(lvlError, "an error occurred")
+##   error("an error occurred")  # Equivalent to the above line
+##   info("something normal happened")  # Will not be written to errors.log
+##   ```
+##
+## Note that a message's level is still checked against each handler's
+## ``levelThreshold`` and the global log filter.
+##
+## Format strings
+## --------------
+##
+## Log messages are prefixed with format strings. These strings contain
+## placeholders for variables, such as ``$time``, that are replaced with their
+## corresponding values, such as the current time, before they are prepended to
+## a log message. Characters that are not part of variables are unaffected.
+##
+## The format string used by a logger can be specified by providing the `fmtStr`
+## argument when creating the logger or by setting its `fmtStr` field afterward.
+## If not specified, the `default format string<#defaultFmtStr>`_ is used.
+##
+## The following variables, which must be prefixed with a dollar sign (``$``),
+## are available:
+##
+## ============  =======================
+##   Variable      Output
+## ============  =======================
+## $date         Current date
+## $time         Current time
+## $datetime     $dateT$time
+## $app          `os.getAppFilename()<os.html#getAppFilename>`_
+## $appname      Base name of ``$app``
+## $appdir       Directory name of ``$app``
+## $levelid      First letter of log level
+## $levelname    Log level name
+## ============  =======================
+##
+## Note that ``$app``, ``$appname``, and ``$appdir`` are not supported when
+## using the JavaScript backend.
+##
+## The following example illustrates how to use format strings:
+##
+##   ```Nim
+##   import std/logging
+##
+##   var logger = newConsoleLogger(fmtStr="[$time] - $levelname: ")
+##   logger.log(lvlInfo, "this is a message")
+##   # Output: [19:50:13] - INFO: this is a message
+##   ```
+##
+## Notes when using multiple threads
+## ---------------------------------
+##
+## There are a few details to keep in mind when using this module within
+## multiple threads:
+## * The global log filter is actually a thread-local variable, so it needs to
+##   be set in each thread that uses this module.
+## * The list of registered handlers is also a thread-local variable. If a
+##   handler will be used in multiple threads, it needs to be registered in
+##   each of those threads.
+##
+## See also
+## ========
+## * `strutils module<strutils.html>`_ for common string functions
+## * `strformat module<strformat.html>`_ for string interpolation and formatting
+## * `strscans module<strscans.html>`_ for ``scanf`` and ``scanp`` macros, which
+##   offer easier substring extraction than regular expressions
+
+import std/[strutils, times]
+when not defined(js):
+  import std/os
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
 
 type
-  TLevel* = enum  ## logging level
-    lvlAll,       ## all levels active
-    lvlDebug,     ## debug level (and any above) active
-    lvlInfo,      ## info level (and any above) active
-    lvlWarn,      ## warn level (and any above) active
-    lvlError,     ## error level (and any above) active
-    lvlFatal      ## fatal level (and any above) active
+  Level* = enum ## \
+    ## Enumeration of logging levels.
+    ##
+    ## Debug messages represent the lowest logging level, and fatal error
+    ## messages represent the highest logging level. ``lvlAll`` can be used
+    ## to enable all messages, while ``lvlNone`` can be used to disable all
+    ## messages.
+    ##
+    ## Typical usage for each logging level, from lowest to highest, is
+    ## described below:
+    ##
+    ## * **Debug** - debugging information helpful only to developers
+    ## * **Info** - anything associated with normal operation and without
+    ##   any particular importance
+    ## * **Notice** - more important information that users should be
+    ##   notified about
+    ## * **Warn** - impending problems that require some attention
+    ## * **Error** - error conditions that the application can recover from
+    ## * **Fatal** - fatal errors that prevent the application from continuing
+    ##
+    ## It is completely up to the application how to utilize each level.
+    ##
+    ## Individual loggers have a ``levelThreshold`` field that filters out
+    ## any messages with a level lower than the threshold. There is also
+    ## a global filter that applies to all log messages, and it can be changed
+    ## using the `setLogFilter proc<#setLogFilter,Level>`_.
+    lvlAll,     ## All levels active
+    lvlDebug,   ## Debug level and above are active
+    lvlInfo,    ## Info level and above are active
+    lvlNotice,  ## Notice level and above are active
+    lvlWarn,    ## Warn level and above are active
+    lvlError,   ## Error level and above are active
+    lvlFatal,   ## Fatal level and above are active
+    lvlNone     ## No levels active; nothing is logged
 
 const
-  LevelNames*: array [TLevel, string] = [
-    "DEBUG", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"
-  ]
+  LevelNames*: array[Level, string] = [
+    "DEBUG", "DEBUG", "INFO", "NOTICE", "WARN", "ERROR", "FATAL", "NONE"
+  ] ## Array of strings representing each logging level.
+
+  defaultFmtStr* = "$levelname "                         ## The default format string.
+  verboseFmtStr* = "$levelid, [$datetime] -- $appname: " ## \
+  ## A more verbose format string.
+  ##
+  ## This string can be passed as the ``frmStr`` argument to procs that create
+  ## new loggers, such as the `newConsoleLogger proc<#newConsoleLogger>`_.
+  ##
+  ## If a different format string is preferred, refer to the
+  ## `documentation about format strings<#basic-usage-format-strings>`_
+  ## for more information, including a list of available variables.
+  defaultFlushThreshold = when NimMajor >= 2:
+      when defined(nimV1LogFlushBehavior): lvlError else: lvlAll
+    else:
+      when defined(nimFlushAllLogs): lvlAll else: lvlError
+  ## The threshold above which log messages to file-like loggers
+  ## are automatically flushed.
+  ## 
+  ## By default, only error and fatal messages are logged,
+  ## but defining ``-d:nimFlushAllLogs`` will make all levels be flushed
 
 type
-  TLogger* = object of TObject ## abstract logger; the base type of all loggers
-    levelThreshold*: TLevel    ## only messages of level >= levelThreshold 
-                               ## should be processed
-  TConsoleLogger* = object of TLogger ## logger that writes the messages to the
-                                      ## console
-  
-  TFileLogger* = object of TLogger ## logger that writes the messages to a file
-    f: TFile
-    
-  TRollingFileLogger* = object of 
-      TFileLogger ## logger that writes the message to a file
-    maxlines: int # maximum number of lines
-    lines: seq[string]
-
-method log*(L: ref TLogger, level: TLevel,
-            frmt: string, args: openArray[string]) =
-  ## override this method in custom loggers. Default implementation does
-  ## nothing.
-  nil
-  
-method log*(L: ref TConsoleLogger, level: TLevel,
-            frmt: string, args: openArray[string]) = 
-  Writeln(stdout, LevelNames[level], " ", frmt % args)
-
-method log*(L: ref TFileLogger, level: TLevel, 
-            frmt: string, args: openArray[string]) = 
-  Writeln(L.f, LevelNames[level], " ", frmt % args)
-
-proc defaultFilename*(): string = 
-  ## returns the default filename for a logger
-  var (path, name, ext) = splitFile(getApplicationFilename())
-  result = changeFileExt(path / name & "_" & getDateStr(), "log")
-
-proc substituteLog*(frmt: string): string = 
-  ## converts $date to the current date
-  ## converts $time to the current time
-  ## converts $app to getApplicationFilename()
-  ## converts 
-  result = ""
+  Logger* = ref object of RootObj
+    ## The abstract base type of all loggers.
+    ##
+    ## Custom loggers should inherit from this type. They should also provide
+    ## their own implementation of the
+    ## `log method<#log.e,Logger,Level,varargs[string,]>`_.
+    ##
+    ## See also:
+    ## * `ConsoleLogger<#ConsoleLogger>`_
+    ## * `FileLogger<#FileLogger>`_
+    ## * `RollingFileLogger<#RollingFileLogger>`_
+    levelThreshold*: Level ## Only messages that are at or above this
+                           ## threshold will be logged
+    fmtStr*: string ## Format string to prepend to each log message;
+                    ## defaultFmtStr is the default
+
+  ConsoleLogger* = ref object of Logger
+    ## A logger that writes log messages to the console.
+    ##
+    ## Create a new ``ConsoleLogger`` with the `newConsoleLogger proc
+    ## <#newConsoleLogger>`_.
+    ##
+    ## See also:
+    ## * `FileLogger<#FileLogger>`_
+    ## * `RollingFileLogger<#RollingFileLogger>`_
+    useStderr*: bool ## If true, writes to stderr; otherwise, writes to stdout
+    flushThreshold*: Level ## Only messages that are at or above this
+                           ## threshold will be flushed immediately
+
+when not defined(js):
+  type
+    FileLogger* = ref object of Logger
+      ## A logger that writes log messages to a file.
+      ##
+      ## Create a new ``FileLogger`` with the `newFileLogger proc
+      ## <#newFileLogger,File>`_.
+      ##
+      ## **Note:** This logger is not available for the JavaScript backend.
+      ##
+      ## See also:
+      ## * `ConsoleLogger<#ConsoleLogger>`_
+      ## * `RollingFileLogger<#RollingFileLogger>`_
+      file*: File ## The wrapped file
+      flushThreshold*: Level ## Only messages that are at or above this
+                           ## threshold will be flushed immediately
+
+    RollingFileLogger* = ref object of FileLogger
+      ## A logger that writes log messages to a file while performing log
+      ## rotation.
+      ##
+      ## Create a new ``RollingFileLogger`` with the `newRollingFileLogger proc
+      ## <#newRollingFileLogger,FileMode,Positive,int>`_.
+      ##
+      ## **Note:** This logger is not available for the JavaScript backend.
+      ##
+      ## See also:
+      ## * `ConsoleLogger<#ConsoleLogger>`_
+      ## * `FileLogger<#FileLogger>`_
+      maxLines: int # maximum number of lines
+      curLine: int
+      baseName: string # initial filename
+      baseMode: FileMode # initial file mode
+      logFiles: int # how many log files already created, e.g. basename.1, basename.2...
+      bufSize: int # size of output buffer (-1: use system defaults, 0: unbuffered, >0: fixed buffer size)
+
+var
+  level {.threadvar.}: Level          ## global log filter
+  handlers {.threadvar.}: seq[Logger] ## handlers with their own log levels
+
+proc substituteLog*(frmt: string, level: Level,
+                    args: varargs[string, `$`]): string =
+  ## Formats a log message at the specified level with the given format string.
+  ##
+  ## The `format variables<#basic-usage-format-strings>`_ present within
+  ## ``frmt`` will be replaced with the corresponding values before being
+  ## prepended to ``args`` and returned.
+  ##
+  ## Unless you are implementing a custom logger, there is little need to call
+  ## this directly. Use either a logger's log method or one of the logging
+  ## templates.
+  ##
+  ## See also:
+  ## * `log method<#log.e,ConsoleLogger,Level,varargs[string,]>`_
+  ##   for the ConsoleLogger
+  ## * `log method<#log.e,FileLogger,Level,varargs[string,]>`_
+  ##   for the FileLogger
+  ## * `log method<#log.e,RollingFileLogger,Level,varargs[string,]>`_
+  ##   for the RollingFileLogger
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  runnableExamples:
+    doAssert substituteLog(defaultFmtStr, lvlInfo, "a message") == "INFO a message"
+    doAssert substituteLog("$levelid - ", lvlError, "an error") == "E - an error"
+    doAssert substituteLog("$levelid", lvlDebug, "error") == "Derror"
+  var msgLen = 0
+  for arg in args:
+    msgLen += arg.len
+  result = newStringOfCap(frmt.len + msgLen + 20)
   var i = 0
-  while i < frmt.len: 
-    if frmt[i] != '$': 
+  while i < frmt.len:
+    if frmt[i] != '$':
       result.add(frmt[i])
       inc(i)
     else:
       inc(i)
       var v = ""
-      var app = getApplicationFilename()
-      while frmt[i] in IdentChars: 
-        v.add(toLower(frmt[i]))
+      let app = when defined(js): "" else: getAppFilename()
+      while i < frmt.len and frmt[i] in IdentChars:
+        v.add(toLowerAscii(frmt[i]))
         inc(i)
       case v
       of "date": result.add(getDateStr())
       of "time": result.add(getClockStr())
-      of "app":  result.add(app)
-      of "appdir": result.add(app.splitFile.dir)
-      of "appname": result.add(app.splitFile.name)
-      
-
-proc newFileLogger(filename = defaultFilename(), 
-                   mode: TFileMode = fmAppend,
-                   levelThreshold = lvlNone): ref TFileLogger = 
-  new(result)
-  result.levelThreshold = levelThreshold
-  if not open(result.f, filename, mode): 
-    raiseException(EIO, "cannot open for writing: " & filename)
-
-proc newRollingFileLogger(filename = defaultFilename(), 
-                          mode: TFileMode = fmAppend,
-                          levelThreshold = lvlNone,
-                          maxLines = 1000): ref TFileLogger = 
-  new(result)
+      of "datetime": result.add(getDateStr() & "T" & getClockStr())
+      of "app": result.add(app)
+      of "appdir":
+        when not defined(js): result.add(app.splitFile.dir)
+      of "appname":
+        when not defined(js): result.add(app.splitFile.name)
+      of "levelid": result.add(LevelNames[level][0])
+      of "levelname": result.add(LevelNames[level])
+      else: discard
+  for arg in args:
+    result.add(arg)
+
+method log*(logger: Logger, level: Level, args: varargs[string, `$`]) {.
+            raises: [Exception], gcsafe,
+            tags: [RootEffect], base.} =
+  ## Override this method in custom loggers. The default implementation does
+  ## nothing.
+  ##
+  ## See also:
+  ## * `log method<#log.e,ConsoleLogger,Level,varargs[string,]>`_
+  ##   for the ConsoleLogger
+  ## * `log method<#log.e,FileLogger,Level,varargs[string,]>`_
+  ##   for the FileLogger
+  ## * `log method<#log.e,RollingFileLogger,Level,varargs[string,]>`_
+  ##   for the RollingFileLogger
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  discard
+
+method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
+  ## Logs to the console with the given `ConsoleLogger<#ConsoleLogger>`_ only.
+  ##
+  ## This method ignores the list of registered handlers.
+  ##
+  ## Whether the message is logged depends on both the ConsoleLogger's
+  ## ``levelThreshold`` field and the global log filter set using the
+  ## `setLogFilter proc<#setLogFilter,Level>`_.
+  ##
+  ## **Note:** Only error and fatal messages will cause the output buffer
+  ## to be flushed immediately by default. Set ``flushThreshold`` when creating
+  ## the logger to change this.
+  ##
+  ## See also:
+  ## * `log method<#log.e,FileLogger,Level,varargs[string,]>`_
+  ##   for the FileLogger
+  ## * `log method<#log.e,RollingFileLogger,Level,varargs[string,]>`_
+  ##   for the RollingFileLogger
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var consoleLog = newConsoleLogger()
+  ##   consoleLog.log(lvlInfo, "this is a message")
+  ##   consoleLog.log(lvlError, "error code is: ", 404)
+  ##   ```
+  if level >= logging.level and level >= logger.levelThreshold:
+    let ln = substituteLog(logger.fmtStr, level, args)
+    when defined(js):
+      let cln = ln.cstring
+      case level
+      of lvlDebug: {.emit: "console.debug(`cln`);".}
+      of lvlInfo:  {.emit: "console.info(`cln`);".}
+      of lvlWarn:  {.emit: "console.warn(`cln`);".}
+      of lvlError: {.emit: "console.error(`cln`);".}
+      else:        {.emit: "console.log(`cln`);".}
+    else:
+      try:
+        var handle = stdout
+        if logger.useStderr:
+          handle = stderr
+        writeLine(handle, ln)
+        if level >= logger.flushThreshold: flushFile(handle)
+      except IOError:
+        discard
+
+proc newConsoleLogger*(levelThreshold = lvlAll, fmtStr = defaultFmtStr,
+    useStderr = false, flushThreshold = defaultFlushThreshold): ConsoleLogger =
+  ## Creates a new `ConsoleLogger<#ConsoleLogger>`_.
+  ##
+  ## By default, log messages are written to ``stdout``. If ``useStderr`` is
+  ## true, they are written to ``stderr`` instead.
+  ##
+  ## For the JavaScript backend, log messages are written to the console,
+  ## and ``useStderr`` is ignored.
+  ##
+  ## See also:
+  ## * `newFileLogger proc<#newFileLogger,File>`_ that uses a file handle
+  ## * `newFileLogger proc<#newFileLogger,FileMode,int>`_
+  ##   that accepts a filename
+  ## * `newRollingFileLogger proc<#newRollingFileLogger,FileMode,Positive,int>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var normalLog = newConsoleLogger()
+  ##   var formatLog = newConsoleLogger(fmtStr=verboseFmtStr)
+  ##   var errorLog = newConsoleLogger(levelThreshold=lvlError, useStderr=true)
+  ##   ```
+  new result
+  result.fmtStr = fmtStr
   result.levelThreshold = levelThreshold
-  result.maxLines = maxLines
-  if not open(result.f, filename, mode): 
-    raiseException(EIO, "cannot open for writing: " & filename)
+  result.flushThreshold = flushThreshold
+  result.useStderr = useStderr
 
-var
-  level* = lvlNone
-  handlers*: seq[ref TLogger] = @[]
+when not defined(js):
+  method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) =
+    ## Logs a message at the specified level using the given
+    ## `FileLogger<#FileLogger>`_ only.
+    ##
+    ## This method ignores the list of registered handlers.
+    ##
+    ## Whether the message is logged depends on both the FileLogger's
+    ## ``levelThreshold`` field and the global log filter set using the
+    ## `setLogFilter proc<#setLogFilter,Level>`_.
+    ##
+    ## **Notes:**
+    ## * Only error and fatal messages will cause the output buffer
+    ##   to be flushed immediately by default. Set ``flushThreshold`` when creating
+    ##   the logger to change this.
+    ## * This method is not available for the JavaScript backend.
+    ##
+    ## See also:
+    ## * `log method<#log.e,ConsoleLogger,Level,varargs[string,]>`_
+    ##   for the ConsoleLogger
+    ## * `log method<#log.e,RollingFileLogger,Level,varargs[string,]>`_
+    ##   for the RollingFileLogger
+    ## * `log template<#log.t,Level,varargs[string,]>`_
+    ##
+    ## **Examples:**
+    ##
+    ##   ```Nim
+    ##   var fileLog = newFileLogger("messages.log")
+    ##   fileLog.log(lvlInfo, "this is a message")
+    ##   fileLog.log(lvlError, "error code is: ", 404)
+    ##   ```
+    if level >= logging.level and level >= logger.levelThreshold:
+      writeLine(logger.file, substituteLog(logger.fmtStr, level, args))
+      if level >= logger.flushThreshold: flushFile(logger.file)
+
+  proc defaultFilename*(): string =
+    ## Returns the filename that is used by default when naming log files.
+    ##
+    ## **Note:** This proc is not available for the JavaScript backend.
+    var (path, name, _) = splitFile(getAppFilename())
+    result = changeFileExt(path / name, "log")
+
+  proc newFileLogger*(file: File,
+                      levelThreshold = lvlAll,
+                      fmtStr = defaultFmtStr,
+                      flushThreshold = defaultFlushThreshold): FileLogger =
+    ## Creates a new `FileLogger<#FileLogger>`_ that uses the given file handle.
+    ##
+    ## **Note:** This proc is not available for the JavaScript backend.
+    ##
+    ## See also:
+    ## * `newConsoleLogger proc<#newConsoleLogger>`_
+    ## * `newFileLogger proc<#newFileLogger,FileMode,int>`_
+    ##   that accepts a filename
+    ## * `newRollingFileLogger proc<#newRollingFileLogger,FileMode,Positive,int>`_
+    ##
+    ## **Examples:**
+    ##
+    ##   ```Nim
+    ##   var messages = open("messages.log", fmWrite)
+    ##   var formatted = open("formatted.log", fmWrite)
+    ##   var errors = open("errors.log", fmWrite)
+    ##
+    ##   var normalLog = newFileLogger(messages)
+    ##   var formatLog = newFileLogger(formatted, fmtStr=verboseFmtStr)
+    ##   var errorLog = newFileLogger(errors, levelThreshold=lvlError)
+    ##   ```
+    new(result)
+    result.file = file
+    result.levelThreshold = levelThreshold
+    result.flushThreshold = flushThreshold
+    result.fmtStr = fmtStr
+
+  proc newFileLogger*(filename = defaultFilename(),
+                      mode: FileMode = fmAppend,
+                      levelThreshold = lvlAll,
+                      fmtStr = defaultFmtStr,
+                      bufSize: int = -1,
+                      flushThreshold = defaultFlushThreshold): FileLogger =
+    ## Creates a new `FileLogger<#FileLogger>`_ that logs to a file with the
+    ## given filename.
+    ##
+    ## ``bufSize`` controls the size of the output buffer that is used when
+    ## writing to the log file. The following values can be provided:
+    ## * ``-1`` - use system defaults
+    ## * ``0`` - unbuffered
+    ## * ``> 0`` - fixed buffer size
+    ##
+    ## **Note:** This proc is not available for the JavaScript backend.
+    ##
+    ## See also:
+    ## * `newConsoleLogger proc<#newConsoleLogger>`_
+    ## * `newFileLogger proc<#newFileLogger,File>`_ that uses a file handle
+    ## * `newRollingFileLogger proc<#newRollingFileLogger,FileMode,Positive,int>`_
+    ##
+    ## **Examples:**
+    ##
+    ##   ```Nim
+    ##   var normalLog = newFileLogger("messages.log")
+    ##   var formatLog = newFileLogger("formatted.log", fmtStr=verboseFmtStr)
+    ##   var errorLog = newFileLogger("errors.log", levelThreshold=lvlError)
+    ##   ```
+    let file = open(filename, mode, bufSize = bufSize)
+    newFileLogger(file, levelThreshold, fmtStr, flushThreshold)
+
+  # ------
+
+  proc countLogLines(logger: RollingFileLogger): int =
+    let fp = open(logger.baseName, fmRead)
+    for line in fp.lines():
+      result.inc()
+    fp.close()
+
+  proc countFiles(filename: string): int =
+    # Example: file.log.1
+    result = 0
+    var (dir, name, ext) = splitFile(filename)
+    if dir == "":
+      dir = "."
+    for kind, path in walkDir(dir):
+      if kind == pcFile:
+        let llfn = name & ext & ExtSep
+        if path.extractFilename.startsWith(llfn):
+          let numS = path.extractFilename[llfn.len .. ^1]
+          try:
+            let num = parseInt(numS)
+            if num > result:
+              result = num
+          except ValueError: discard
 
-proc logLoop(level: TLevel, msg: string) =
-  for logger in items(handlers): 
+  proc newRollingFileLogger*(filename = defaultFilename(),
+                            mode: FileMode = fmReadWrite,
+                            levelThreshold = lvlAll,
+                            fmtStr = defaultFmtStr,
+                            maxLines: Positive = 1000,
+                            bufSize: int = -1,
+                            flushThreshold = defaultFlushThreshold): RollingFileLogger =
+    ## Creates a new `RollingFileLogger<#RollingFileLogger>`_.
+    ##
+    ## Once the current log file being written to contains ``maxLines`` lines,
+    ## a new log file will be created, and the old log file will be renamed.
+    ##
+    ## ``bufSize`` controls the size of the output buffer that is used when
+    ## writing to the log file. The following values can be provided:
+    ## * ``-1`` - use system defaults
+    ## * ``0`` - unbuffered
+    ## * ``> 0`` - fixed buffer size
+    ##
+    ## **Note:** This proc is not available in the JavaScript backend.
+    ##
+    ## See also:
+    ## * `newConsoleLogger proc<#newConsoleLogger>`_
+    ## * `newFileLogger proc<#newFileLogger,File>`_ that uses a file handle
+    ## * `newFileLogger proc<#newFileLogger,FileMode,int>`_
+    ##   that accepts a filename
+    ##
+    ## **Examples:**
+    ##
+    ##   ```Nim
+    ##   var normalLog = newRollingFileLogger("messages.log")
+    ##   var formatLog = newRollingFileLogger("formatted.log", fmtStr=verboseFmtStr)
+    ##   var shortLog = newRollingFileLogger("short.log", maxLines=200)
+    ##   var errorLog = newRollingFileLogger("errors.log", levelThreshold=lvlError)
+    ##   ```
+    new(result)
+    result.levelThreshold = levelThreshold
+    result.fmtStr = fmtStr
+    result.maxLines = maxLines
+    result.bufSize = bufSize
+    result.file = open(filename, mode, bufSize = result.bufSize)
+    result.curLine = 0
+    result.baseName = filename
+    result.baseMode = mode
+    result.flushThreshold = flushThreshold
+
+    result.logFiles = countFiles(filename)
+
+    if mode == fmAppend:
+      # We need to get a line count because we will be appending to the file.
+      result.curLine = countLogLines(result)
+
+  proc rotate(logger: RollingFileLogger) =
+    let (dir, name, ext) = splitFile(logger.baseName)
+    for i in countdown(logger.logFiles, 0):
+      let srcSuff = if i != 0: ExtSep & $i else: ""
+      moveFile(dir / (name & ext & srcSuff),
+              dir / (name & ext & ExtSep & $(i+1)))
+
+  method log*(logger: RollingFileLogger, level: Level, args: varargs[string, `$`]) =
+    ## Logs a message at the specified level using the given
+    ## `RollingFileLogger<#RollingFileLogger>`_ only.
+    ##
+    ## This method ignores the list of registered handlers.
+    ##
+    ## Whether the message is logged depends on both the RollingFileLogger's
+    ## ``levelThreshold`` field and the global log filter set using the
+    ## `setLogFilter proc<#setLogFilter,Level>`_.
+    ##
+    ## **Notes:**
+    ## * Only error and fatal messages will cause the output buffer
+    ##   to be flushed immediately by default. Set ``flushThreshold`` when creating
+    ##   the logger to change this.
+    ## * This method is not available for the JavaScript backend.
+    ##
+    ## See also:
+    ## * `log method<#log.e,ConsoleLogger,Level,varargs[string,]>`_
+    ##   for the ConsoleLogger
+    ## * `log method<#log.e,FileLogger,Level,varargs[string,]>`_
+    ##   for the FileLogger
+    ## * `log template<#log.t,Level,varargs[string,]>`_
+    ##
+    ## **Examples:**
+    ##
+    ##   ```Nim
+    ##   var rollingLog = newRollingFileLogger("messages.log")
+    ##   rollingLog.log(lvlInfo, "this is a message")
+    ##   rollingLog.log(lvlError, "error code is: ", 404)
+    ##   ```
+    if level >= logging.level and level >= logger.levelThreshold:
+      if logger.curLine >= logger.maxLines:
+        logger.file.close()
+        rotate(logger)
+        logger.logFiles.inc
+        logger.curLine = 0
+        logger.file = open(logger.baseName, logger.baseMode,
+            bufSize = logger.bufSize)
+
+      writeLine(logger.file, substituteLog(logger.fmtStr, level, args))
+      if level >= logger.flushThreshold: flushFile(logger.file)
+      logger.curLine.inc
+
+# --------
+
+proc logLoop(level: Level, args: varargs[string, `$`]) =
+  for logger in items(handlers):
     if level >= logger.levelThreshold:
-      log(logger, level, msg)
+      log(logger, level, args)
+
+template log*(level: Level, args: varargs[string, `$`]) =
+  ## Logs a message at the specified level to all registered handlers.
+  ##
+  ## Whether the message is logged depends on both the FileLogger's
+  ## `levelThreshold` field and the global log filter set using the
+  ## `setLogFilter proc<#setLogFilter,Level>`_.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   log(lvlInfo, "This is an example.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `debug template<#debug.t,varargs[string,]>`_
+  ## * `info template<#info.t,varargs[string,]>`_
+  ## * `notice template<#notice.t,varargs[string,]>`_
+  ## * `warn template<#warn.t,varargs[string,]>`_
+  ## * `error template<#error.t,varargs[string,]>`_
+  ## * `fatal template<#fatal.t,varargs[string,]>`_
+  bind logLoop
+  bind `%`
+  bind logging.level
+
+  if level >= logging.level:
+    logLoop(level, args)
+
+template debug*(args: varargs[string, `$`]) =
+  ## Logs a debug message to all registered handlers.
+  ##
+  ## Debug messages are typically useful to the application developer only,
+  ## and they are usually disabled in release builds, although this template
+  ## does not make that distinction.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   debug("myProc called with arguments: foo, 5")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `info template<#info.t,varargs[string,]>`_
+  ## * `notice template<#notice.t,varargs[string,]>`_
+  log(lvlDebug, args)
+
+template info*(args: varargs[string, `$`]) =
+  ## Logs an info message to all registered handlers.
+  ##
+  ## Info messages are typically generated during the normal operation
+  ## of an application and are of no particular importance. It can be useful to
+  ## aggregate these messages for later analysis.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   info("Application started successfully.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `debug template<#debug.t,varargs[string,]>`_
+  ## * `notice template<#notice.t,varargs[string,]>`_
+  log(lvlInfo, args)
+
+template notice*(args: varargs[string, `$`]) =
+  ## Logs an notice to all registered handlers.
+  ##
+  ## Notices are semantically very similar to info messages, but they are meant
+  ## to be messages that the user should be actively notified about, depending
+  ## on the application.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   notice("An important operation has completed.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `debug template<#debug.t,varargs[string,]>`_
+  ## * `info template<#info.t,varargs[string,]>`_
+  log(lvlNotice, args)
+
+template warn*(args: varargs[string, `$`]) =
+  ## Logs a warning message to all registered handlers.
+  ##
+  ## A warning is a non-error message that may indicate impending problems or
+  ## degraded performance.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   warn("The previous operation took too long to process.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `error template<#error.t,varargs[string,]>`_
+  ## * `fatal template<#fatal.t,varargs[string,]>`_
+  log(lvlWarn, args)
+
+template error*(args: varargs[string, `$`]) =
+  ## Logs an error message to all registered handlers.
+  ##
+  ## Error messages are for application-level error conditions, such as when
+  ## some user input generated an exception. Typically, the application will
+  ## continue to run, but with degraded functionality or loss of data, and
+  ## these effects might be visible to users.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   error("An exception occurred while processing the form.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `warn template<#warn.t,varargs[string,]>`_
+  ## * `fatal template<#fatal.t,varargs[string,]>`_
+  log(lvlError, args)
+
+template fatal*(args: varargs[string, `$`]) =
+  ## Logs a fatal error message to all registered handlers.
+  ##
+  ## Fatal error messages usually indicate that the application cannot continue
+  ## to run and will exit due to a fatal condition. This template only logs the
+  ## message, and it is the application's responsibility to exit properly.
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   var logger = newConsoleLogger()
+  ##   addHandler(logger)
+  ##
+  ##   fatal("Can't open database -- exiting.")
+  ##   ```
+  ##
+  ## See also:
+  ## * `log template<#log.t,Level,varargs[string,]>`_
+  ## * `warn template<#warn.t,varargs[string,]>`_
+  ## * `error template<#error.t,varargs[string,]>`_
+  log(lvlFatal, args)
+
+proc addHandler*(handler: Logger) =
+  ## Adds a logger to the list of registered handlers.
+  ##
+  ## .. warning:: The list of handlers is a thread-local variable. If the given
+  ##   handler will be used in multiple threads, this proc should be called in
+  ##   each of those threads.
+  ##
+  ## See also:
+  ## * `removeHandler proc`_
+  ## * `getHandlers proc<#getHandlers>`_
+  runnableExamples:
+    var logger = newConsoleLogger()
+    addHandler(logger)
+    doAssert logger in getHandlers()
+  handlers.add(handler)
+
+proc removeHandler*(handler: Logger) =
+  ## Removes a logger from the list of registered handlers.
+  ##
+  ## Note that for n times a logger is registered, n calls to this proc
+  ## are required to remove that logger.
+  for i, hnd in handlers:
+    if hnd == handler:
+      handlers.delete(i)
+      return
 
-template log*(level: TLevel, msg: string) =
-  ## logs a message of the given level
-  if level >= logging.Level:
-    (bind logLoop)(level, frmt, args)
+proc getHandlers*(): seq[Logger] =
+  ## Returns a list of all the registered handlers.
+  ##
+  ## See also:
+  ## * `addHandler proc<#addHandler,Logger>`_
+  return handlers
 
-template debug*(msg: string) =
-  ## logs a debug message
-  log(lvlDebug, msg)
+proc setLogFilter*(lvl: Level) =
+  ## Sets the global log filter.
+  ##
+  ## Messages below the provided level will not be logged regardless of an
+  ## individual logger's ``levelThreshold``. By default, all messages are
+  ## logged.
+  ##
+  ## .. warning:: The global log filter is a thread-local variable. If logging
+  ##   is being performed in multiple threads, this proc should be called in each
+  ##   thread unless it is intended that different threads should log at different
+  ##   logging levels.
+  ##
+  ## See also:
+  ## * `getLogFilter proc<#getLogFilter>`_
+  runnableExamples:
+    setLogFilter(lvlError)
+    doAssert getLogFilter() == lvlError
+  level = lvl
 
-template info*(msg: string) = 
-  ## logs an info message
-  log(lvlInfo, msg)
+proc getLogFilter*(): Level =
+  ## Gets the global log filter.
+  ##
+  ## See also:
+  ## * `setLogFilter proc<#setLogFilter,Level>`_
+  return level
 
-template warn*(msg: string) = 
-  ## logs a warning message
-  log(lvlWarn, msg)
+# --------------
 
-template error*(msg: string) = 
-  ## logs an error message
-  log(lvlError, msg)
-  
-template fatal*(msg: string) =  
-  ## logs a fatal error message and calls ``quit(msg)``
-  log(lvlFatal, msg)
+when not defined(testing) and isMainModule:
+  var L = newConsoleLogger()
+  when not defined(js):
+    var fL = newFileLogger("test.log", fmtStr = verboseFmtStr)
+    var rL = newRollingFileLogger("rolling.log", fmtStr = verboseFmtStr)
+    addHandler(fL)
+    addHandler(rL)
+  addHandler(L)
+  for i in 0 .. 25:
+    info("hello", i)
 
+  var nilString: string
+  info "hello ", nilString
diff --git a/lib/pure/macros.nim b/lib/pure/macros.nim
deleted file mode 100755
index 7f5dda1e5..000000000
--- a/lib/pure/macros.nim
+++ /dev/null
@@ -1,250 +0,0 @@
-#

-#

-#            Nimrod's Runtime Library

-#        (c) Copyright 2009 Andreas Rumpf

-#

-#    See the file "copying.txt", included in this

-#    distribution, for details about the copyright.

-#

-

-

-## This module contains the interface to the compiler's abstract syntax 

-## tree (`AST`:idx:). Macros operate on this tree.

-

-## .. include:: ../doc/astspec.txt

-

-#[[[cog

-#def toEnum(name, elems):

-#  body = ""

-#  counter = 0

-#  for e in elems:

-#    if counter % 4 == 0: p = "\n    "

-#    else: p = ""

-#    body = body + p + 'n' + e + ', '

-#    counter = counter + 1

-#

-#  return ("  TNimrod%s* = enum%s\n  TNim%ss* = set[TNimrod%s]\n" %

-#            (name, body[:-2], name, name))

-#

-#enums = eval(open("data/ast.yml").read())

-#cog.out("type\n")

-#for key, val in enums.items():

-#  if key[-4:] == "Flag": continue

-#  cog.out(toEnum(key, val))

-#]]]

-type
-  TNimrodNodeKind* = enum
-    nnkNone, nnkEmpty, nnkIdent, nnkSym, 
-    nnkType, nnkCharLit, nnkIntLit, nnkInt8Lit, 
-    nnkInt16Lit, nnkInt32Lit, nnkInt64Lit, nnkFloatLit, 
-    nnkFloat32Lit, nnkFloat64Lit, nnkStrLit, nnkRStrLit, 
-    nnkTripleStrLit, nnkMetaNode, nnkNilLit, nnkDotCall, 
-    nnkCommand, nnkCall, nnkCallStrLit, nnkExprEqExpr, 
-    nnkExprColonExpr, nnkIdentDefs, nnkVarTuple, nnkInfix, 
-    nnkPrefix, nnkPostfix, nnkPar, nnkCurly, 
-    nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange, 
-    nnkDotExpr, nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr, 
-    nnkElifExpr, nnkElseExpr, nnkLambda, nnkAccQuoted, 
-    nnkTableConstr, nnkBind, nnkSymChoice, nnkHiddenStdConv, 
-    nnkHiddenSubConv, nnkHiddenCallConv, nnkConv, nnkCast, 
-    nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, 
-    nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, 
-    nnkStringToCString, nnkCStringToString, nnkPassAsOpenArray, nnkAsgn, 
-    nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, 
-    nnkModule, nnkProcDef, nnkMethodDef, nnkConverterDef, 
-    nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, 
-    nnkElifBranch, nnkExceptBranch, nnkElse, nnkMacroStmt, 
-    nnkAsmStmt, nnkPragma, nnkIfStmt, nnkWhenStmt, 
-    nnkForStmt, nnkWhileStmt, nnkCaseStmt, nnkVarSection, 
-    nnkConstSection, nnkConstDef, nnkTypeSection, nnkTypeDef, 
-    nnkYieldStmt, nnkTryStmt, nnkFinally, nnkRaiseStmt, 
-    nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, 
-    nnkDiscardStmt, nnkStmtList, nnkImportStmt, nnkFromStmt, 
-    nnkIncludeStmt, nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr, 
-    nnkStmtListType, nnkBlockType, nnkTypeOfExpr, nnkObjectTy, 
-    nnkTupleTy, nnkRecList, nnkRecCase, nnkRecWhen, 
-    nnkRefTy, nnkPtrTy, nnkVarTy, nnkDistinctTy, 
-    nnkProcTy, nnkEnumTy, nnkEnumFieldDef, nnkReturnToken
-  TNimNodeKinds* = set[TNimrodNodeKind]
-  TNimrodTypeKind* = enum
-    ntyNone, ntyBool, ntyChar, ntyEmpty, 
-    ntyArrayConstr, ntyNil, ntyExpr, ntyStmt, 
-    ntyTypeDesc, ntyGenericInvokation, ntyGenericBody, ntyGenericInst, 
-    ntyGenericParam, ntyDistinct, ntyEnum, ntyOrdinal, 
-    ntyArray, ntyObject, ntyTuple, ntySet, 
-    ntyRange, ntyPtr, ntyRef, ntyVar, 
-    ntySequence, ntyProc, ntyPointer, ntyOpenArray, 
-    ntyString, ntyCString, ntyForward, ntyInt, 
-    ntyInt8, ntyInt16, ntyInt32, ntyInt64, 
-    ntyFloat, ntyFloat32, ntyFloat64, ntyFloat128
-  TNimTypeKinds* = set[TNimrodTypeKind]
-  TNimrodSymKind* = enum
-    nskUnknown, nskConditional, nskDynLib, nskParam, 
-    nskGenericParam, nskTemp, nskType, nskConst, 
-    nskVar, nskProc, nskMethod, nskIterator, 
-    nskConverter, nskMacro, nskTemplate, nskField, 
-    nskEnumField, nskForVar, nskModule, nskLabel, 
-    nskStub
-  TNimSymKinds* = set[TNimrodSymKind]
-#[[[end]]]

-

-type

-  TNimrodIdent* = object of TObject

-    ## represents a Nimrod identifier in the AST

-

-  TNimrodSymbol {.final.} = object # hidden

-  TNimrodType {.final.} = object   # hidden

-  

-  PNimrodType* {.compilerproc.} = ref TNimrodType

-    ## represents a Nimrod type in the compiler; currently this is not very

-    ## useful as there is no API to deal with Nimrod types.

-  

-  PNimrodSymbol* {.compilerproc.} = ref TNimrodSymbol

-    ## represents a Nimrod *symbol* in the compiler; a *symbol* is a looked-up

-    ## *ident*.

-  

-  PNimrodNode* = expr

-    ## represents a Nimrod AST node. Macros operate on this type.

-    

-# Nodes should be reference counted to make the `copy` operation very fast!

-# However, this is difficult to achieve: modify(n[0][1]) should propagate to

-# its father. How to do this without back references? Hm, BS, it works without 
-# them.

-

-proc `[]`* (n: PNimrodNode, i: int): PNimrodNode {.magic: "NChild".}

-  ## get `n`'s `i`'th child.

-

-proc `[]=`* (n: PNimrodNode, i: int, child: PNimrodNode) {.magic: "NSetChild".}

-  ## set `n`'s `i`'th child to `child`.

-

-proc `!` *(s: string): TNimrodIdent {.magic: "StrToIdent".}

-  ## constructs an identifier from the string `s`

-

-proc `$`*(i: TNimrodIdent): string {.magic: "IdentToStr".}

-  ## converts a Nimrod identifier to a string

-

-proc `==`* (a, b: TNimrodIdent): bool {.magic: "EqIdent", noSideEffect.}

-  ## compares two Nimrod identifiers

-
-proc `==`* (a, b: PNimrodNode): bool {.magic: "EqNimrodNode", noSideEffect.}

-  ## compares two Nimrod nodes

-

-proc len*(n: PNimrodNode): int {.magic: "NLen".}

-  ## returns the number of children of `n`.

-

-proc add*(father, child: PNimrodNode) {.magic: "NAdd".}

-  ## adds the `child` to the `father` node

-

-proc add*(father: PNimrodNode, children: openArray[PNimrodNode]) {.

-  magic: "NAddMultiple".}

-  ## adds each child of `children` to the `father` node

-

-proc del*(father: PNimrodNode, idx = 0, n = 1) {.magic: "NDel".}

-  ## deletes `n` children of `father` starting at index `idx`. 

-

-proc kind*(n: PNimrodNode): TNimrodNodeKind {.magic: "NKind".}

-  ## returns the `kind` of the node `n`.

-

-proc intVal*(n: PNimrodNode): biggestInt {.magic: "NIntVal".}

-proc floatVal*(n: PNimrodNode): biggestFloat {.magic: "NFloatVal".}

-proc symbol*(n: PNimrodNode): PNimrodSymbol {.magic: "NSymbol".}

-proc ident*(n: PNimrodNode): TNimrodIdent {.magic: "NIdent".}

-proc typ*(n: PNimrodNode): PNimrodType {.magic: "NGetType".}

-proc strVal*(n: PNimrodNode): string  {.magic: "NStrVal".}

-

-proc `intVal=`*(n: PNimrodNode, val: biggestInt) {.magic: "NSetIntVal".}

-proc `floatVal=`*(n: PNimrodNode, val: biggestFloat) {.magic: "NSetFloatVal".}

-proc `symbol=`*(n: PNimrodNode, val: PNimrodSymbol) {.magic: "NSetSymbol".}

-proc `ident=`*(n: PNimrodNode, val: TNimrodIdent) {.magic: "NSetIdent".}

-proc `typ=`*(n: PNimrodNode, typ: PNimrodType) {.magic: "NSetType".}

-proc `strVal=`*(n: PNimrodNode, val: string) {.magic: "NSetStrVal".}

-

-proc newNimNode*(kind: TNimrodNodeKind,

-                 n: PNimrodNode=nil): PNimrodNode {.magic: "NNewNimNode".}

-

-proc copyNimNode*(n: PNimrodNode): PNimrodNode {.magic: "NCopyNimNode".}

-proc copyNimTree*(n: PNimrodNode): PNimrodNode {.magic: "NCopyNimTree".}

-

-proc error*(msg: string) {.magic: "NError".}

-  ## writes an error message at compile time

-

-proc warning*(msg: string) {.magic: "NWarning".}

-  ## writes a warning message at compile time

-

-proc hint*(msg: string) {.magic: "NHint".}

-  ## writes a hint message at compile time

-

-proc newStrLitNode*(s: string): PNimrodNode {.compileTime.} =

-  ## creates a string literal node from `s`

-  result = newNimNode(nnkStrLit)

-  result.strVal = s

-

-proc newIntLitNode*(i: biggestInt): PNimrodNode {.compileTime.} =

-  ## creates a int literal node from `i`

-  result = newNimNode(nnkIntLit)

-  result.intVal = i

-

-proc newFloatLitNode*(f: biggestFloat): PNimrodNode {.compileTime.} =

-  ## creates a float literal node from `f`

-  result = newNimNode(nnkFloatLit)

-  result.floatVal = f

-

-proc newIdentNode*(i: TNimrodIdent): PNimrodNode {.compileTime.} =

-  ## creates an identifier node from `i`

-  result = newNimNode(nnkIdent)

-  result.ident = i

-

-proc newIdentNode*(i: string): PNimrodNode {.compileTime.} =

-  ## creates an identifier node from `i`

-  result = newNimNode(nnkIdent)

-  result.ident = !i

-

-proc toStrLit*(n: PNimrodNode): PNimrodNode {.compileTime.} =

-  ## converts the AST `n` to the concrete Nimrod code and wraps that 

-  ## in a string literal node

-  return newStrLitNode(repr(n))

-

-proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} =

-  ## checks that `n` is of kind `k`. If this is not the case,

-  ## compilation aborts with an error message. This is useful for writing

-  ## macros that check the AST that is passed to them.

-  if n.kind != k: error("macro expects a node of kind: " & repr(k))

-

-proc expectMinLen*(n: PNimrodNode, min: int) {.compileTime.} =

-  ## checks that `n` has at least `min` children. If this is not the case,

-  ## compilation aborts with an error message. This is useful for writing

-  ## macros that check its number of arguments. 

-  if n.len < min: error("macro expects a node with " & $min & " children")

-

-proc expectLen*(n: PNimrodNode, len: int) {.compileTime.} =

-  ## checks that `n` has exactly `len` children. If this is not the case,

-  ## compilation aborts with an error message. This is useful for writing

-  ## macros that check its number of arguments. 

-  if n.len != len: error("macro expects a node with " & $len & " children")

-

-proc newCall*(theProc: TNimrodIdent,

-              args: openArray[PNimrodNode]): PNimrodNode {.compileTime.} =

-  ## produces a new call node. `theProc` is the proc that is called with

-  ## the arguments ``args[0..]``.

-  result = newNimNode(nnkCall)

-  result.add(newIdentNode(theProc))

-  result.add(args)

-  

-proc newCall*(theProc: string,

-              args: openArray[PNimrodNode]): PNimrodNode {.compileTime.} =

-  ## produces a new call node. `theProc` is the proc that is called with

-  ## the arguments ``args[0..]``.

-  result = newNimNode(nnkCall)

-  result.add(newIdentNode(theProc))

-  result.add(args)

-

-proc nestList*(theProc: TNimrodIdent,  

-               x: PNimrodNode): PNimrodNode {.compileTime.} = 

-  ## nests the list `x` into a tree of call expressions:

-  ## ``[a, b, c]`` is transformed into ``theProc(a, theProc(c, d))``

-  var L = x.len

-  result = newCall(theProc, x[L-2], x[L-1])

-  var a = result

-  for i in countdown(L-3, 0):

-    a = newCall(theProc, x[i], copyNimTree(a))

-

diff --git a/lib/pure/marshal.nim b/lib/pure/marshal.nim
new file mode 100644
index 000000000..f9b3d3e4c
--- /dev/null
+++ b/lib/pure/marshal.nim
@@ -0,0 +1,367 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains procs for `serialization`:idx: and `deserialization`:idx:
+## of arbitrary Nim data structures. The serialization format uses `JSON`:idx:.
+##
+## **Restriction:** For objects, their type is **not** serialized. This means
+## essentially that it does not work if the object has some other runtime
+## type than its compiletime type.
+##
+##
+## Basic usage
+## ===========
+##
+runnableExamples:
+  type
+    A = object of RootObj
+    B = object of A
+      f: int
+
+  let a: ref A = new(B)
+  assert $$a[] == "{}" # not "{f: 0}"
+
+  # unmarshal
+  let c = to[B]("""{"f": 2}""")
+  assert typeof(c) is B
+  assert c.f == 2
+
+  # marshal
+  assert $$c == """{"f": 2}"""
+
+## **Note:** The `to` and `$$` operations are available at compile-time!
+##
+##
+## See also
+## ========
+## * `streams module <streams.html>`_
+## * `json module <json.html>`_
+
+const unsupportedPlatform =
+  when defined(js): "javascript"
+  elif defined(nimscript): "nimscript"
+  else: ""
+
+when unsupportedPlatform != "":
+  {.error: "marshal module is not supported in " & unsupportedPlatform & """.
+Please use alternative packages for serialization.
+It is possible to reimplement this module using generics and type traits.
+Please contribute a new implementation.""".}
+
+import std/[streams, typeinfo, json, intsets, tables, unicode]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, formatfloat]
+
+proc ptrToInt(x: pointer): int {.inline.} =
+  result = cast[int](x) # don't skip alignment
+
+proc storeAny(s: Stream, a: Any, stored: var IntSet) =
+  case a.kind
+  of akNone: assert false
+  of akBool: s.write($getBool(a))
+  of akChar:
+    let ch = getChar(a)
+    if ch < '\128':
+      s.write(escapeJson($ch))
+    else:
+      s.write($int(ch))
+  of akArray, akSequence:
+    s.write("[")
+    for i in 0 .. a.len-1:
+      if i > 0: s.write(", ")
+      storeAny(s, a[i], stored)
+    s.write("]")
+  of akObject, akTuple:
+    s.write("{")
+    var i = 0
+    for key, val in fields(a):
+      if i > 0: s.write(", ")
+      s.write(escapeJson(key))
+      s.write(": ")
+      storeAny(s, val, stored)
+      inc(i)
+    s.write("}")
+  of akSet:
+    s.write("[")
+    var i = 0
+    for e in elements(a):
+      if i > 0: s.write(", ")
+      s.write($e)
+      inc(i)
+    s.write("]")
+  of akRange: storeAny(s, skipRange(a), stored)
+  of akEnum: s.write(getEnumField(a).escapeJson)
+  of akPtr, akRef:
+    var x = a.getPointer
+    if isNil(x): s.write("null")
+    elif stored.containsOrIncl(x.ptrToInt):
+      # already stored, so we simply write out the pointer as an int:
+      s.write($x.ptrToInt)
+    else:
+      # else as a [value, key] pair:
+      # (reversed order for convenient x[0] access!)
+      s.write("[")
+      s.write($x.ptrToInt)
+      s.write(", ")
+      storeAny(s, a[], stored)
+      s.write("]")
+  of akProc, akPointer, akCString: s.write($a.getPointer.ptrToInt)
+  of akString:
+    var x = getString(a)
+    if x.validateUtf8() == -1: s.write(escapeJson(x))
+    else:
+      s.write("[")
+      var i = 0
+      for c in x:
+        if i > 0: s.write(", ")
+        s.write($ord(c))
+        inc(i)
+      s.write("]")
+  of akInt..akInt64, akUInt..akUInt64: s.write($getBiggestInt(a))
+  of akFloat..akFloat128: s.write($getBiggestFloat(a))
+
+proc loadAny(p: var JsonParser, a: Any, t: var Table[BiggestInt, pointer]) =
+  case a.kind
+  of akNone: assert false
+  of akBool:
+    case p.kind
+    of jsonFalse: setBiggestInt(a, 0)
+    of jsonTrue: setBiggestInt(a, 1)
+    else: raiseParseErr(p, "'true' or 'false' expected for a bool")
+    next(p)
+  of akChar:
+    if p.kind == jsonString:
+      var x = p.str
+      if x.len == 1:
+        setBiggestInt(a, ord(x[0]))
+        next(p)
+        return
+    elif p.kind == jsonInt:
+      setBiggestInt(a, getInt(p))
+      next(p)
+      return
+    raiseParseErr(p, "string of length 1 expected for a char")
+  of akEnum:
+    if p.kind == jsonString:
+      setBiggestInt(a, getEnumOrdinal(a, p.str))
+      next(p)
+      return
+    raiseParseErr(p, "string expected for an enum")
+  of akArray:
+    if p.kind != jsonArrayStart: raiseParseErr(p, "'[' expected for an array")
+    next(p)
+    var i = 0
+    while p.kind != jsonArrayEnd and p.kind != jsonEof:
+      loadAny(p, a[i], t)
+      inc(i)
+    if p.kind == jsonArrayEnd: next(p)
+    else: raiseParseErr(p, "']' end of array expected")
+  of akSequence:
+    case p.kind
+    of jsonNull:
+      when defined(nimSeqsV2):
+        invokeNewSeq(a, 0)
+      else:
+        setPointer(a, nil)
+      next(p)
+    of jsonArrayStart:
+      next(p)
+      invokeNewSeq(a, 0)
+      var i = 0
+      while p.kind != jsonArrayEnd and p.kind != jsonEof:
+        extendSeq(a)
+        loadAny(p, a[i], t)
+        inc(i)
+      if p.kind == jsonArrayEnd: next(p)
+      else: raiseParseErr(p, "")
+    else:
+      raiseParseErr(p, "'[' expected for a seq")
+  of akObject, akTuple:
+    if a.kind == akObject: setObjectRuntimeType(a)
+    if p.kind != jsonObjectStart: raiseParseErr(p, "'{' expected for an object")
+    next(p)
+    while p.kind != jsonObjectEnd and p.kind != jsonEof:
+      if p.kind != jsonString:
+        raiseParseErr(p, "string expected for a field name")
+      var fieldName = p.str
+      next(p)
+      loadAny(p, a[fieldName], t)
+    if p.kind == jsonObjectEnd: next(p)
+    else: raiseParseErr(p, "'}' end of object expected")
+  of akSet:
+    if p.kind != jsonArrayStart: raiseParseErr(p, "'[' expected for a set")
+    next(p)
+    while p.kind != jsonArrayEnd and p.kind != jsonEof:
+      if p.kind != jsonInt: raiseParseErr(p, "int expected for a set")
+      inclSetElement(a, p.getInt.int)
+      next(p)
+    if p.kind == jsonArrayEnd: next(p)
+    else: raiseParseErr(p, "']' end of array expected")
+  of akPtr, akRef:
+    case p.kind
+    of jsonNull:
+      setPointer(a, nil)
+      next(p)
+    of jsonInt:
+      var raw = t.getOrDefault(p.getInt)
+      setPointer(a, addr raw)
+      next(p)
+    of jsonArrayStart:
+      next(p)
+      if a.kind == akRef: invokeNew(a)
+      else: setPointer(a, alloc0(a.baseTypeSize))
+      if p.kind == jsonInt:
+        t[p.getInt] = getPointer(a)
+        next(p)
+      else: raiseParseErr(p, "index for ref type expected")
+      loadAny(p, a[], t)
+      if p.kind == jsonArrayEnd: next(p)
+      else: raiseParseErr(p, "']' end of ref-address pair expected")
+    else: raiseParseErr(p, "int for pointer type expected")
+  of akProc, akPointer, akCString:
+    case p.kind
+    of jsonNull:
+      setPointer(a, nil)
+      next(p)
+    of jsonInt:
+      setPointer(a, cast[pointer](p.getInt.int))
+      next(p)
+    else: raiseParseErr(p, "int for pointer type expected")
+  of akString:
+    case p.kind
+    of jsonNull:
+      when defined(nimSeqsV2):
+        setString(a, "")
+      else:
+        setPointer(a, nil)
+      next(p)
+    of jsonString:
+      setString(a, p.str)
+      next(p)
+    of jsonArrayStart:
+      next(p)
+      var str = ""
+      while p.kind == jsonInt:
+        let code = p.getInt()
+        if code < 0 or code > 255:
+          raiseParseErr(p, "invalid charcode: " & $code)
+        str.add(chr(code))
+        next(p)
+      if p.kind == jsonArrayEnd: next(p)
+      else: raiseParseErr(p, "an array of charcodes expected for string")
+      setString(a, str)
+    else: raiseParseErr(p, "string expected")
+  of akInt..akInt64, akUInt..akUInt64:
+    if p.kind == jsonInt:
+      setBiggestInt(a, getInt(p))
+      next(p)
+      return
+    raiseParseErr(p, "int expected")
+  of akFloat..akFloat128:
+    if p.kind == jsonFloat:
+      setBiggestFloat(a, getFloat(p))
+      next(p)
+      return
+    raiseParseErr(p, "float expected")
+  of akRange: loadAny(p, a.skipRange, t)
+
+proc loadAny(s: Stream, a: Any, t: var Table[BiggestInt, pointer]) =
+  var p: JsonParser
+  open(p, s, "unknown file")
+  next(p)
+  loadAny(p, a, t)
+  close(p)
+
+proc load*[T](s: Stream, data: var T) =
+  ## Loads `data` from the stream `s`. Raises `IOError` in case of an error.
+  runnableExamples:
+    import std/streams
+
+    var s = newStringStream("[1, 3, 5]")
+    var a: array[3, int]
+    load(s, a)
+    assert a == [1, 3, 5]
+
+  var tab = initTable[BiggestInt, pointer]()
+  loadAny(s, toAny(data), tab)
+
+proc store*[T](s: Stream, data: sink T) =
+  ## Stores `data` into the stream `s`. Raises `IOError` in case of an error.
+  runnableExamples:
+    import std/streams
+
+    var s = newStringStream("")
+    var a = [1, 3, 5]
+    store(s, a)
+    s.setPosition(0)
+    assert s.readAll() == "[1, 3, 5]"
+
+  var stored = initIntSet()
+  var d: T
+  when defined(gcArc) or defined(gcOrc)or defined(gcAtomicArc):
+    d = data
+  else:
+    shallowCopy(d, data)
+  storeAny(s, toAny(d), stored)
+
+proc loadVM[T](typ: typedesc[T], x: T): string =
+  discard "the implementation is in the compiler/vmops"
+
+proc `$$`*[T](x: sink T): string =
+  ## Returns a string representation of `x` (serialization, marshalling).
+  ##
+  ## **Note:** to serialize `x` to JSON use `%x` from the `json` module
+  ## or `jsonutils.toJson(x)`.
+  runnableExamples:
+    type
+      Foo = object
+        id: int
+        bar: string
+    let x = Foo(id: 1, bar: "baz")
+    ## serialize:
+    let y = $$x
+    assert y == """{"id": 1, "bar": "baz"}"""
+
+  when nimvm:
+    result = loadVM(T, x)
+  else:
+    var stored = initIntSet()
+    var d: T
+    when defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc):
+      d = x
+    else:
+      shallowCopy(d, x)
+    var s = newStringStream()
+    storeAny(s, toAny(d), stored)
+    result = s.data
+
+proc toVM[T](typ: typedesc[T], data: string): T =
+  discard "the implementation is in the compiler/vmops"
+
+proc to*[T](data: string): T =
+  ## Reads data and transforms it to a type `T` (deserialization, unmarshalling).
+  runnableExamples:
+    type
+      Foo = object
+        id: int
+        bar: string
+    let y = """{"id": 1, "bar": "baz"}"""
+    assert typeof(y) is string
+    ## deserialize to type 'Foo':
+    let z = y.to[:Foo]
+    assert typeof(z) is Foo
+    assert z.id == 1
+    assert z.bar == "baz"
+
+  when nimvm:
+    result = toVM(T, data)
+  else:
+    var tab = initTable[BiggestInt, pointer]()
+    loadAny(newStringStream(data), toAny(result), tab)
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 8e3dd4bdb..ed7d2382f 100755..100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -1,253 +1,1314 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-##   Constructive mathematics is naturally typed. -- Simon Thompson
-## 
-## Basic math routines for Nimrod.
-## This module is available for the ECMAScript target.
+## *Constructive mathematics is naturally typed.* -- Simon Thompson
+##
+## Basic math routines for Nim.
+##
+## Note that the trigonometric functions naturally operate on radians.
+## The helper functions `degToRad <#degToRad,T>`_ and `radToDeg <#radToDeg,T>`_
+## provide conversion between radians and degrees.
 
-{.push debugger:off .} # the user does not want to trace a part
+runnableExamples:
+  from std/fenv import epsilon
+  from std/random import rand
+
+  proc generateGaussianNoise(mu: float = 0.0, sigma: float = 1.0): (float, float) =
+    # Generates values from a normal distribution.
+    # Translated from https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform#Implementation.
+    var u1: float
+    var u2: float
+    while true:
+      u1 = rand(1.0)
+      u2 = rand(1.0)
+      if u1 > epsilon(float): break
+    let mag = sigma * sqrt(-2 * ln(u1))
+    let z0 = mag * cos(2 * PI * u2) + mu
+    let z1 = mag * sin(2 * PI * u2) + mu
+    (z0, z1)
+
+  echo generateGaussianNoise()
+
+## This module is available for the `JavaScript target
+## <backends.html#backends-the-javascript-target>`_.
+##
+## See also
+## ========
+## * `complex module <complex.html>`_ for complex numbers and their
+##   mathematical operations
+## * `rationals module <rationals.html>`_ for rational numbers and their
+##   mathematical operations
+## * `fenv module <fenv.html>`_ for handling of floating-point rounding
+##   and exceptions (overflow, zero-divide, etc.)
+## * `random module <random.html>`_ for a fast and tiny random number generator
+## * `stats module <stats.html>`_ for statistical analysis
+## * `strformat module <strformat.html>`_ for formatting floats for printing
+## * `system module <system.html>`_ for some very basic and trivial math operators
+##   (`shr`, `shl`, `xor`, `clamp`, etc.)
+
+
+import std/private/since
+{.push debugger: off.} # the user does not want to trace a part
                        # of the standard library!
 
-{.push checks:off, line_dir:off, stack_trace:off.}
+import std/[bitops, fenv]
+import system/countbits_impl
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+when not defined(js) and not defined(nimscript): # C
+  proc c_isnan(x: float): bool {.importc: "isnan", header: "<math.h>".}
+    # a generic like `x: SomeFloat` might work too if this is implemented via a C macro.
+
+  proc c_copysign(x, y: cfloat): cfloat {.importc: "copysignf", header: "<math.h>".}
+  proc c_copysign(x, y: cdouble): cdouble {.importc: "copysign", header: "<math.h>".}
+
+  proc c_signbit(x: SomeFloat): cint {.importc: "signbit", header: "<math.h>".}
+
+  # don't export `c_frexp` in the future and remove `c_frexp2`.
+  func c_frexp2(x: cfloat, exponent: var cint): cfloat {.
+      importc: "frexpf", header: "<math.h>".}
+  func c_frexp2(x: cdouble, exponent: var cint): cdouble {.
+      importc: "frexp", header: "<math.h>".}
+  
+  type
+    div_t {.importc, header: "<stdlib.h>".} = object
+      quot: cint
+      rem: cint
+    ldiv_t {.importc, header: "<stdlib.h>".} = object
+      quot: clong
+      rem: clong
+    lldiv_t {.importc, header: "<stdlib.h>".} = object
+      quot: clonglong
+      rem: clonglong
+  
+  when cint isnot clong:
+    func divmod_c(x, y: cint): div_t {.importc: "div", header: "<stdlib.h>".}
+  when clong isnot clonglong:
+    func divmod_c(x, y: clonglong): lldiv_t {.importc: "lldiv", header: "<stdlib.h>".}
+  func divmod_c(x, y: clong): ldiv_t {.importc: "ldiv", header: "<stdlib.h>".}
+  func divmod*[T: SomeInteger](x, y: T): (T, T) {.inline.} = 
+    ## Specialized instructions for computing both division and modulus.
+    ## Return structure is: (quotient, remainder)
+    runnableExamples:
+      doAssert divmod(5, 2) == (2, 1)
+      doAssert divmod(5, -3) == (-1, 2)
+    when T is cint | clong | clonglong:
+      when compileOption("overflowChecks"):
+        if y == 0:
+          raise new(DivByZeroDefect)
+        elif (x == T.low and y == -1.T):
+          raise new(OverflowDefect)
+      let res = divmod_c(x, y)
+      result[0] = res.quot
+      result[1] = res.rem
+    else:
+      result[0] = x div y
+      result[1] = x mod y
+
+func binom*(n, k: int): int =
+  ## Computes the [binomial coefficient](https://en.wikipedia.org/wiki/Binomial_coefficient).
+  runnableExamples:
+    doAssert binom(6, 2) == 15
+    doAssert binom(-6, 2) == 1
+    doAssert binom(6, 0) == 1
+
+  if k <= 0: return 1
+  if 2 * k > n: return binom(n, n - k)
+  result = n
+  for i in countup(2, k):
+    result = (result * (n + 1 - i)) div i
+
+func createFactTable[N: static[int]]: array[N, int] =
+  result[0] = 1
+  for i in 1 ..< N:
+    result[i] = result[i - 1] * i
+
+func fac*(n: int): int =
+  ## Computes the [factorial](https://en.wikipedia.org/wiki/Factorial) of
+  ## a non-negative integer `n`.
+  ##
+  ## **See also:**
+  ## * `prod func <#prod,openArray[T]>`_
+  runnableExamples:
+    doAssert fac(0) == 1
+    doAssert fac(4) == 24
+    doAssert fac(10) == 3628800
+
+  const factTable =
+    when sizeof(int) == 2:
+      createFactTable[5]()
+    elif sizeof(int) == 4:
+      createFactTable[13]()
+    else:
+      createFactTable[21]()
+  assert(n >= 0, $n & " must not be negative.")
+  assert(n < factTable.len, $n & " is too large to look up in the table")
+  factTable[n]
+
+{.push checks: off, line_dir: off, stack_trace: off.}
 
-when defined(Posix): 
+when defined(posix) and not defined(genode) and not defined(macosx):
   {.passl: "-lm".}
 
 const
-  PI* = 3.1415926535897932384626433 ## the circle constant PI (Ludolph's number)
-  E* = 2.71828182845904523536028747 ## Euler's number
+  PI* = 3.1415926535897932384626433          ## The circle constant PI (Ludolph's number).
+  TAU* = 2.0 * PI                            ## The circle constant TAU (= 2 * PI).
+  E* = 2.71828182845904523536028747          ## Euler's number.
+
+  MaxFloat64Precision* = 16                  ## Maximum number of meaningful digits
+                                             ## after the decimal point for Nim's
+                                             ## `float64` type.
+  MaxFloat32Precision* = 8                   ## Maximum number of meaningful digits
+                                             ## after the decimal point for Nim's
+                                             ## `float32` type.
+  MaxFloatPrecision* = MaxFloat64Precision   ## Maximum number of
+                                             ## meaningful digits
+                                             ## after the decimal point
+                                             ## for Nim's `float` type.
+  MinFloatNormal* = 2.225073858507201e-308   ## Smallest normal number for Nim's
+                                             ## `float` type (= 2^-1022).
+  RadPerDeg = PI / 180.0                     ## Number of radians per degree.
 
 type
-  TFloatClass* = enum ## describes the class a floating point value belongs to.
-                      ## This is the type that is returned by `classify`.
-    fcNormal,    ## value is an ordinary nonzero floating point value
-    fcSubnormal, ## value is a subnormal (a very small) floating point value
-    fcZero,      ## value is zero
-    fcNegZero,   ## value is the negative zero
-    fcNan,       ## value is Not-A-Number (NAN)
-    fcInf,       ## value is positive infinity
-    fcNegInf     ## value is negative infinity
-
-proc classify*(x: float): TFloatClass = 
-  ## classifies a floating point value. Returns `x`'s class as specified by
-  ## `TFloatClass`.
-    
-  # ECMAScript and most C compilers have no classify:
+  FloatClass* = enum ## Describes the class a floating point value belongs to.
+                     ## This is the type that is returned by the
+                     ## `classify func <#classify,float>`_.
+    fcNormal,        ## value is an ordinary nonzero floating point value
+    fcSubnormal,     ## value is a subnormal (a very small) floating point value
+    fcZero,          ## value is zero
+    fcNegZero,       ## value is the negative zero
+    fcNan,           ## value is Not a Number (NaN)
+    fcInf,           ## value is positive infinity
+    fcNegInf         ## value is negative infinity
+
+func isNaN*(x: SomeFloat): bool {.inline, since: (1,5,1).} =
+  ## Returns whether `x` is a `NaN`, more efficiently than via `classify(x) == fcNan`.
+  ## Works even with `--passc:-ffast-math`.
+  runnableExamples:
+    doAssert NaN.isNaN
+    doAssert not Inf.isNaN
+    doAssert not isNaN(3.1415926)
+
+  template fn: untyped = result = x != x
+  when nimvm: fn()
+  else:
+    when defined(js) or defined(nimscript): fn()
+    else: result = c_isnan(x)
+
+when defined(js):
+  import std/private/jsutils
+
+  proc toBitsImpl(x: float): array[2, uint32] =
+    let buffer = newArrayBuffer(8)
+    let a = newFloat64Array(buffer)
+    let b = newUint32Array(buffer)
+    a[0] = x
+    {.emit: "`result` = `b`;".}
+    # result = cast[array[2, uint32]](b)
+
+  proc jsSetSign(x: float, sgn: bool): float =
+    let buffer = newArrayBuffer(8)
+    let a = newFloat64Array(buffer)
+    let b = newUint32Array(buffer)
+    a[0] = x
+    {.emit: """
+    function updateBit(num, bitPos, bitVal) {
+      return (num & ~(1 << bitPos)) | (bitVal << bitPos);
+    }
+    `b`[1] = updateBit(`b`[1], 31, `sgn`);
+    `result` = `a`[0];
+    """.}
+
+proc signbit*(x: SomeFloat): bool {.inline, since: (1, 5, 1).} =
+  ## Returns true if `x` is negative, false otherwise.
+  runnableExamples:
+    doAssert not signbit(0.0)
+    doAssert signbit(-0.0)
+    doAssert signbit(-0.1)
+    doAssert not signbit(0.1)
+
+  when defined(js):
+    let uintBuffer = toBitsImpl(x)
+    result = (uintBuffer[1] shr 31) != 0
+  else:
+    result = c_signbit(x) != 0
+
+func copySign*[T: SomeFloat](x, y: T): T {.inline, since: (1, 5, 1).} =
+  ## Returns a value with the magnitude of `x` and the sign of `y`;
+  ## this works even if x or y are NaN, infinity or zero, all of which can carry a sign.
+  runnableExamples:
+    doAssert copySign(10.0, 1.0) == 10.0
+    doAssert copySign(10.0, -1.0) == -10.0
+    doAssert copySign(-Inf, -0.0) == -Inf
+    doAssert copySign(NaN, 1.0).isNaN
+    doAssert copySign(1.0, copySign(NaN, -1.0)) == -1.0
+
+  # TODO: use signbit for examples
+  when defined(js):
+    let uintBuffer = toBitsImpl(y)
+    let sgn = (uintBuffer[1] shr 31) != 0
+    result = jsSetSign(x, sgn)
+  else:
+    when nimvm: # not exact but we have a vmops for recent enough nim
+      if y > 0.0 or (y == 0.0 and 1.0 / y > 0.0):
+        result = abs(x)
+      elif y <= 0.0:
+        result = -abs(x)
+      else: # must be NaN
+        result = abs(x)
+    else: result = c_copysign(x, y)
+
+func classify*(x: float): FloatClass =
+  ## Classifies a floating point value.
+  ##
+  ## Returns `x`'s class as specified by the `FloatClass enum<#FloatClass>`_.
+  runnableExamples:
+    doAssert classify(0.3) == fcNormal
+    doAssert classify(0.0) == fcZero
+    doAssert classify(0.3 / 0.0) == fcInf
+    doAssert classify(-0.3 / 0.0) == fcNegInf
+    doAssert classify(5.0e-324) == fcSubnormal
+
+  # JavaScript and most C compilers have no classify:
+  if isNan(x): return fcNan
   if x == 0.0:
-    if 1.0/x == Inf:
+    if 1.0 / x == Inf:
       return fcZero
     else:
       return fcNegZero
-  if x*0.5 == x:
+  if x * 0.5 == x:
     if x > 0.0: return fcInf
     else: return fcNegInf
-  if x != x: return fcNan
+  if abs(x) < MinFloatNormal:
+    return fcSubnormal
   return fcNormal
-  # XXX: fcSubnormal is not detected!
 
+func almostEqual*[T: SomeFloat](x, y: T; unitsInLastPlace: Natural = 4): bool {.
+    since: (1, 5), inline.} =
+  ## Checks if two float values are almost equal, using the
+  ## [machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon).
+  ##
+  ## `unitsInLastPlace` is the max number of
+  ## [units in the last place](https://en.wikipedia.org/wiki/Unit_in_the_last_place)
+  ## difference tolerated when comparing two numbers. The larger the value, the
+  ## more error is allowed. A `0` value means that two numbers must be exactly the
+  ## same to be considered equal.
+  ##
+  ## The machine epsilon has to be scaled to the magnitude of the values used
+  ## and multiplied by the desired precision in ULPs unless the difference is
+  ## subnormal.
+  ##
+  # taken from: https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
+  runnableExamples:
+    doAssert almostEqual(PI, 3.14159265358979)
+    doAssert almostEqual(Inf, Inf)
+    doAssert not almostEqual(NaN, NaN)
+
+  if x == y:
+    # short circuit exact equality -- needed to catch two infinities of
+    # the same sign. And perhaps speeds things up a bit sometimes.
+    return true
+  let diff = abs(x - y)
+  result = diff <= epsilon(T) * abs(x + y) * T(unitsInLastPlace) or
+      diff < minimumPositiveValue(T)
+
+func isPowerOfTwo*(x: int): bool =
+  ## Returns `true`, if `x` is a power of two, `false` otherwise.
+  ##
+  ## Zero and negative numbers are not a power of two.
+  ##
+  ## **See also:**
+  ## * `nextPowerOfTwo func <#nextPowerOfTwo,int>`_
+  runnableExamples:
+    doAssert isPowerOfTwo(16)
+    doAssert not isPowerOfTwo(5)
+    doAssert not isPowerOfTwo(0)
+    doAssert not isPowerOfTwo(-16)
+
+  return (x > 0) and ((x and (x - 1)) == 0)
+
+func nextPowerOfTwo*(x: int): int =
+  ## Returns `x` rounded up to the nearest power of two.
+  ##
+  ## Zero and negative numbers get rounded up to 1.
+  ##
+  ## **See also:**
+  ## * `isPowerOfTwo func <#isPowerOfTwo,int>`_
+  runnableExamples:
+    doAssert nextPowerOfTwo(16) == 16
+    doAssert nextPowerOfTwo(5) == 8
+    doAssert nextPowerOfTwo(0) == 1
+    doAssert nextPowerOfTwo(-16) == 1
 
-proc binom*(n, k: int): int {.noSideEffect.} = 
-  ## computes the binomial coefficient
-  if k <= 0: return 1
-  if 2*k > n: return binom(n, n-k)
-  result = n
-  for i in countup(2, k):
-    result = (result * (n + 1 - i)) div i
-    
-proc fac*(n: int): int {.noSideEffect.} = 
-  ## computes the faculty function
-  result = 1
-  for i in countup(2, n):
-    result = result * i
-
-proc isPowerOfTwo*(x: int): bool {.noSideEffect.} =
-  ## returns true, if x is a power of two, false otherwise.
-  ## Negative numbers are not a power of two.
-  return (x and -x) == x
-
-proc nextPowerOfTwo*(x: int): int =
-  ## returns the nearest power of two, so that
-  ## result**2 >= x > (result-1)**2.
   result = x - 1
   when defined(cpu64):
     result = result or (result shr 32)
-  result = result or (result shr 16)
-  result = result or (result shr 8)
+  when sizeof(int) > 2:
+    result = result or (result shr 16)
+  when sizeof(int) > 1:
+    result = result or (result shr 8)
   result = result or (result shr 4)
   result = result or (result shr 2)
   result = result or (result shr 1)
-  Inc(result)
+  result += 1 + ord(x <= 0)
 
-proc countBits32*(n: int32): int {.noSideEffect.} =
-  ## counts the set bits in `n`.
-  var v = n
-  v = v -% ((v shr 1'i32) and 0x55555555'i32)
-  v = (v and 0x33333333'i32) +% ((v shr 2'i32) and 0x33333333'i32)
-  result = ((v +% (v shr 4'i32) and 0xF0F0F0F'i32) *% 0x1010101'i32) shr 24'i32
 
-proc sum*[T](x: openarray[T]): T {.noSideEffect.} = 
-  ## computes the sum of the elements in `x`. 
-  ## If `x` is empty, 0 is returned.
-  for i in items(x): result = result + i
 
-proc mean*(x: openarray[float]): float {.noSideEffect.} = 
-  ## computes the mean of the elements in `x`. 
-  ## If `x` is empty, NaN is returned.
-  result = sum(x) / toFloat(len(x))
-
-proc variance*(x: openarray[float]): float {.noSideEffect.} = 
-  ## computes the variance of the elements in `x`. 
-  ## If `x` is empty, NaN is returned.
-  result = 0.0
-  var m = mean(x)
-  for i in 0 .. high(x):
-    var diff = x[i] - m
-    result = result + diff*diff
-  result = result / toFloat(len(x))
-
-when not defined(ECMAScript):
-  proc random*(max: int): int
-    ## returns a random number in the range 0..max-1. The sequence of
-    ## random number is always the same, unless `randomize` is called
-    ## which initializes the random number generator with a "random"
-    ## number, i.e. a tickcount.
-  proc randomize*()
-    ## initializes the random number generator with a "random"
-    ## number, i.e. a tickcount. Note: Does nothing for the ECMAScript target,
-    ## as ECMAScript does not support this.
-  
-  proc sqrt*(x: float): float {.importc: "sqrt", header: "<math.h>".}
-    ## computes the square root of `x`.
-  
-  proc ln*(x: float): float {.importc: "log", header: "<math.h>".}
-    ## computes ln(x).
-  proc log10*(x: float): float {.importc: "log10", header: "<math.h>".}
-  proc log2*(x: float): float = return ln(x) / ln(2.0)
-  proc exp*(x: float): float {.importc: "exp", header: "<math.h>".}
-    ## computes e**x.
-  
-  proc frexp*(x: float, exponent: var int): float {.
-    importc: "frexp", header: "<math.h>".}
-    ## Split a number into mantissa and exponent.
-    ## `frexp` calculates the mantissa m (a float greater than or equal to 0.5
-    ## and less than 1) and the integer value n such that `x` (the original
-    ## float value) equals m * 2**n. frexp stores n in `exponent` and returns
-    ## m.
-  
-  proc round*(x: float): int {.importc: "lrint", nodecl.}
-    ## converts a float to an int by rounding.  
-  
-  proc arccos*(x: float): float {.importc: "acos", header: "<math.h>".}
-  proc arcsin*(x: float): float {.importc: "asin", header: "<math.h>".}
-  proc arctan*(x: float): float {.importc: "atan", header: "<math.h>".}
-  proc arctan2*(y, x: float): float {.importc: "atan2", header: "<math.h>".}
-    ## Calculate the arc tangent of `y` / `x`.
-    ## `atan2` returns the arc tangent of `y` / `x`; it produces correct
-    ## results even when the resulting angle is near pi/2 or -pi/2
-    ## (`x` near 0).
-  
-  proc cos*(x: float): float {.importc: "cos", header: "<math.h>".}
-  proc cosh*(x: float): float {.importc: "cosh", header: "<math.h>".}
-  proc hypot*(x, y: float): float {.importc: "hypot", header: "<math.h>".}
-    ## same as ``sqrt(x*x + y*y)``.
-  
-  proc sinh*(x: float): float {.importc: "sinh", header: "<math.h>".}
-  proc tan*(x: float): float {.importc: "tan", header: "<math.h>".}
-  proc tanh*(x: float): float {.importc: "tanh", header: "<math.h>".}
-  proc pow*(x, y: float): float {.importc: "pow", header: "<math.h>".}
-    ## computes x to power raised of y.
-    
-  # C procs:
-  proc gettime(dummy: ptr cint): cint {.importc: "time", header: "<time.h>".}
-  proc srand(seed: cint) {.importc: "srand", nodecl.}
-  proc rand(): cint {.importc: "rand", nodecl.}
-    
-  proc randomize() = srand(gettime(nil))
-  proc random(max: int): int = return int(rand()) mod max
-
-  proc trunc*(x: float): float {.importc: "trunc", nodecl.}
-
-else:  
-  proc mathrandom(): float {.importc: "Math.random", nodecl.}
-  proc mathfloor(x: float): float {.importc: "Math.floor", nodecl.}
-  proc random*(max: int): int = return mathfloor(mathrandom() * max)
-  proc randomize*() = nil
+
+when not defined(js): # C
+  func sqrt*(x: float32): float32 {.importc: "sqrtf", header: "<math.h>".}
+  func sqrt*(x: float64): float64 {.importc: "sqrt", header: "<math.h>".} =
+    ## Computes the square root of `x`.
+    ##
+    ## **See also:**
+    ## * `cbrt func <#cbrt,float64>`_ for the cube root
+    runnableExamples:
+      doAssert almostEqual(sqrt(4.0), 2.0)
+      doAssert almostEqual(sqrt(1.44), 1.2)
+  func cbrt*(x: float32): float32 {.importc: "cbrtf", header: "<math.h>".}
+  func cbrt*(x: float64): float64 {.importc: "cbrt", header: "<math.h>".} =
+    ## Computes the cube root of `x`.
+    ##
+    ## **See also:**
+    ## * `sqrt func <#sqrt,float64>`_ for the square root
+    runnableExamples:
+      doAssert almostEqual(cbrt(8.0), 2.0)
+      doAssert almostEqual(cbrt(2.197), 1.3)
+      doAssert almostEqual(cbrt(-27.0), -3.0)
+  func ln*(x: float32): float32 {.importc: "logf", header: "<math.h>".}
+  func ln*(x: float64): float64 {.importc: "log", header: "<math.h>".} =
+    ## Computes the [natural logarithm](https://en.wikipedia.org/wiki/Natural_logarithm)
+    ## of `x`.
+    ##
+    ## **See also:**
+    ## * `log func <#log,T,T>`_
+    ## * `log10 func <#log10,float64>`_
+    ## * `log2 func <#log2,float64>`_
+    ## * `exp func <#exp,float64>`_
+    runnableExamples:
+      doAssert almostEqual(ln(exp(4.0)), 4.0)
+      doAssert almostEqual(ln(1.0), 0.0)
+      doAssert almostEqual(ln(0.0), -Inf)
+      doAssert ln(-7.0).isNaN
+else: # JS
+  func sqrt*(x: float32): float32 {.importc: "Math.sqrt", nodecl.}
+  func sqrt*(x: float64): float64 {.importc: "Math.sqrt", nodecl.}
+
+  func cbrt*(x: float32): float32 {.importc: "Math.cbrt", nodecl.}
+  func cbrt*(x: float64): float64 {.importc: "Math.cbrt", nodecl.}
+
+  func ln*(x: float32): float32 {.importc: "Math.log", nodecl.}
+  func ln*(x: float64): float64 {.importc: "Math.log", nodecl.}
+
+func log*[T: SomeFloat](x, base: T): T =
+  ## Computes the logarithm of `x` to base `base`.
+  ##
+  ## **See also:**
+  ## * `ln func <#ln,float64>`_
+  ## * `log10 func <#log10,float64>`_
+  ## * `log2 func <#log2,float64>`_
+  runnableExamples:
+    doAssert almostEqual(log(9.0, 3.0), 2.0)
+    doAssert almostEqual(log(0.0, 2.0), -Inf)
+    doAssert log(-7.0, 4.0).isNaN
+    doAssert log(8.0, -2.0).isNaN
+
+  ln(x) / ln(base)
+
+when not defined(js): # C
+  func log10*(x: float32): float32 {.importc: "log10f", header: "<math.h>".}
+  func log10*(x: float64): float64 {.importc: "log10", header: "<math.h>".} =
+    ## Computes the common logarithm (base 10) of `x`.
+    ##
+    ## **See also:**
+    ## * `ln func <#ln,float64>`_
+    ## * `log func <#log,T,T>`_
+    ## * `log2 func <#log2,float64>`_
+    runnableExamples:
+      doAssert almostEqual(log10(100.0) , 2.0)
+      doAssert almostEqual(log10(0.0), -Inf)
+      doAssert log10(-100.0).isNaN
+  func exp*(x: float32): float32 {.importc: "expf", header: "<math.h>".}
+  func exp*(x: float64): float64 {.importc: "exp", header: "<math.h>".} =
+    ## Computes the exponential function of `x` (`e^x`).
+    ##
+    ## **See also:**
+    ## * `ln func <#ln,float64>`_
+    runnableExamples:
+      doAssert almostEqual(exp(1.0), E)
+      doAssert almostEqual(ln(exp(4.0)), 4.0)
+      doAssert almostEqual(exp(0.0), 1.0)
+  func sin*(x: float32): float32 {.importc: "sinf", header: "<math.h>".}
+  func sin*(x: float64): float64 {.importc: "sin", header: "<math.h>".} =
+    ## Computes the sine of `x`.
+    ##
+    ## **See also:**
+    ## * `arcsin func <#arcsin,float64>`_
+    runnableExamples:
+      doAssert almostEqual(sin(PI / 6), 0.5)
+      doAssert almostEqual(sin(degToRad(90.0)), 1.0)
+  func cos*(x: float32): float32 {.importc: "cosf", header: "<math.h>".}
+  func cos*(x: float64): float64 {.importc: "cos", header: "<math.h>".} =
+    ## Computes the cosine of `x`.
+    ##
+    ## **See also:**
+    ## * `arccos func <#arccos,float64>`_
+    runnableExamples:
+      doAssert almostEqual(cos(2 * PI), 1.0)
+      doAssert almostEqual(cos(degToRad(60.0)), 0.5)
+  func tan*(x: float32): float32 {.importc: "tanf", header: "<math.h>".}
+  func tan*(x: float64): float64 {.importc: "tan", header: "<math.h>".} =
+    ## Computes the tangent of `x`.
+    ##
+    ## **See also:**
+    ## * `arctan func <#arctan,float64>`_
+    runnableExamples:
+      doAssert almostEqual(tan(degToRad(45.0)), 1.0)
+      doAssert almostEqual(tan(PI / 4), 1.0)
+  func sinh*(x: float32): float32 {.importc: "sinhf", header: "<math.h>".}
+  func sinh*(x: float64): float64 {.importc: "sinh", header: "<math.h>".} =
+    ## Computes the [hyperbolic sine](https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions) of `x`.
+    ##
+    ## **See also:**
+    ## * `arcsinh func <#arcsinh,float64>`_
+    runnableExamples:
+      doAssert almostEqual(sinh(0.0), 0.0)
+      doAssert almostEqual(sinh(1.0), 1.175201193643801)
+  func cosh*(x: float32): float32 {.importc: "coshf", header: "<math.h>".}
+  func cosh*(x: float64): float64 {.importc: "cosh", header: "<math.h>".} =
+    ## Computes the [hyperbolic cosine](https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions) of `x`.
+    ##
+    ## **See also:**
+    ## * `arccosh func <#arccosh,float64>`_
+    runnableExamples:
+      doAssert almostEqual(cosh(0.0), 1.0)
+      doAssert almostEqual(cosh(1.0), 1.543080634815244)
+  func tanh*(x: float32): float32 {.importc: "tanhf", header: "<math.h>".}
+  func tanh*(x: float64): float64 {.importc: "tanh", header: "<math.h>".} =
+    ## Computes the [hyperbolic tangent](https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions) of `x`.
+    ##
+    ## **See also:**
+    ## * `arctanh func <#arctanh,float64>`_
+    runnableExamples:
+      doAssert almostEqual(tanh(0.0), 0.0)
+      doAssert almostEqual(tanh(1.0), 0.7615941559557649)
+  func arcsin*(x: float32): float32 {.importc: "asinf", header: "<math.h>".}
+  func arcsin*(x: float64): float64 {.importc: "asin", header: "<math.h>".} =
+    ## Computes the arc sine of `x`.
+    ##
+    ## **See also:**
+    ## * `sin func <#sin,float64>`_
+    runnableExamples:
+      doAssert almostEqual(radToDeg(arcsin(0.0)), 0.0)
+      doAssert almostEqual(radToDeg(arcsin(1.0)), 90.0)
+  func arccos*(x: float32): float32 {.importc: "acosf", header: "<math.h>".}
+  func arccos*(x: float64): float64 {.importc: "acos", header: "<math.h>".} =
+    ## Computes the arc cosine of `x`.
+    ##
+    ## **See also:**
+    ## * `cos func <#cos,float64>`_
+    runnableExamples:
+      doAssert almostEqual(radToDeg(arccos(0.0)), 90.0)
+      doAssert almostEqual(radToDeg(arccos(1.0)), 0.0)
+  func arctan*(x: float32): float32 {.importc: "atanf", header: "<math.h>".}
+  func arctan*(x: float64): float64 {.importc: "atan", header: "<math.h>".} =
+    ## Calculate the arc tangent of `x`.
+    ##
+    ## **See also:**
+    ## * `arctan2 func <#arctan2,float64,float64>`_
+    ## * `tan func <#tan,float64>`_
+    runnableExamples:
+      doAssert almostEqual(arctan(1.0), 0.7853981633974483)
+      doAssert almostEqual(radToDeg(arctan(1.0)), 45.0)
+  func arctan2*(y, x: float32): float32 {.importc: "atan2f", header: "<math.h>".}
+  func arctan2*(y, x: float64): float64 {.importc: "atan2", header: "<math.h>".} =
+    ## Calculate the arc tangent of `y/x`.
+    ##
+    ## It produces correct results even when the resulting angle is near
+    ## `PI/2` or `-PI/2` (`x` near 0).
+    ##
+    ## **See also:**
+    ## * `arctan func <#arctan,float64>`_
+    runnableExamples:
+      doAssert almostEqual(arctan2(1.0, 0.0), PI / 2.0)
+      doAssert almostEqual(radToDeg(arctan2(1.0, 0.0)), 90.0)
+  func arcsinh*(x: float32): float32 {.importc: "asinhf", header: "<math.h>".}
+  func arcsinh*(x: float64): float64 {.importc: "asinh", header: "<math.h>".}
+    ## Computes the inverse hyperbolic sine of `x`.
+    ##
+    ## **See also:**
+    ## * `sinh func <#sinh,float64>`_
+  func arccosh*(x: float32): float32 {.importc: "acoshf", header: "<math.h>".}
+  func arccosh*(x: float64): float64 {.importc: "acosh", header: "<math.h>".}
+    ## Computes the inverse hyperbolic cosine of `x`.
+    ##
+    ## **See also:**
+    ## * `cosh func <#cosh,float64>`_
+  func arctanh*(x: float32): float32 {.importc: "atanhf", header: "<math.h>".}
+  func arctanh*(x: float64): float64 {.importc: "atanh", header: "<math.h>".}
+    ## Computes the inverse hyperbolic tangent of `x`.
+    ##
+    ## **See also:**
+    ## * `tanh func <#tanh,float64>`_
+
+else: # JS
+  func log10*(x: float32): float32 {.importc: "Math.log10", nodecl.}
+  func log10*(x: float64): float64 {.importc: "Math.log10", nodecl.}
+  func log2*(x: float32): float32 {.importc: "Math.log2", nodecl.}
+  func log2*(x: float64): float64 {.importc: "Math.log2", nodecl.}
+  func exp*(x: float32): float32 {.importc: "Math.exp", nodecl.}
+  func exp*(x: float64): float64 {.importc: "Math.exp", nodecl.}
+
+  func sin*[T: float32|float64](x: T): T {.importc: "Math.sin", nodecl.}
+  func cos*[T: float32|float64](x: T): T {.importc: "Math.cos", nodecl.}
+  func tan*[T: float32|float64](x: T): T {.importc: "Math.tan", nodecl.}
+
+  func sinh*[T: float32|float64](x: T): T {.importc: "Math.sinh", nodecl.}
+  func cosh*[T: float32|float64](x: T): T {.importc: "Math.cosh", nodecl.}
+  func tanh*[T: float32|float64](x: T): T {.importc: "Math.tanh", nodecl.}
+
+  func arcsin*[T: float32|float64](x: T): T {.importc: "Math.asin", nodecl.}
+    # keep this as generic or update test in `tvmops.nim` to make sure we
+    # keep testing that generic importc procs work
+  func arccos*[T: float32|float64](x: T): T {.importc: "Math.acos", nodecl.}
+  func arctan*[T: float32|float64](x: T): T {.importc: "Math.atan", nodecl.}
+  func arctan2*[T: float32|float64](y, x: T): T {.importc: "Math.atan2", nodecl.}
+
+  func arcsinh*[T: float32|float64](x: T): T {.importc: "Math.asinh", nodecl.}
+  func arccosh*[T: float32|float64](x: T): T {.importc: "Math.acosh", nodecl.}
+  func arctanh*[T: float32|float64](x: T): T {.importc: "Math.atanh", nodecl.}
+
+func cot*[T: float32|float64](x: T): T = 1.0 / tan(x)
+  ## Computes the cotangent of `x` (`1/tan(x)`).
+func sec*[T: float32|float64](x: T): T = 1.0 / cos(x)
+  ## Computes the secant of `x` (`1/cos(x)`).
+func csc*[T: float32|float64](x: T): T = 1.0 / sin(x)
+  ## Computes the cosecant of `x` (`1/sin(x)`).
+
+func coth*[T: float32|float64](x: T): T = 1.0 / tanh(x)
+  ## Computes the hyperbolic cotangent of `x` (`1/tanh(x)`).
+func sech*[T: float32|float64](x: T): T = 1.0 / cosh(x)
+  ## Computes the hyperbolic secant of `x` (`1/cosh(x)`).
+func csch*[T: float32|float64](x: T): T = 1.0 / sinh(x)
+  ## Computes the hyperbolic cosecant of `x` (`1/sinh(x)`).
+
+func arccot*[T: float32|float64](x: T): T = arctan(1.0 / x)
+  ## Computes the inverse cotangent of `x` (`arctan(1/x)`).
+func arcsec*[T: float32|float64](x: T): T = arccos(1.0 / x)
+  ## Computes the inverse secant of `x` (`arccos(1/x)`).
+func arccsc*[T: float32|float64](x: T): T = arcsin(1.0 / x)
+  ## Computes the inverse cosecant of `x` (`arcsin(1/x)`).
+
+func arccoth*[T: float32|float64](x: T): T = arctanh(1.0 / x)
+  ## Computes the inverse hyperbolic cotangent of `x` (`arctanh(1/x)`).
+func arcsech*[T: float32|float64](x: T): T = arccosh(1.0 / x)
+  ## Computes the inverse hyperbolic secant of `x` (`arccosh(1/x)`).
+func arccsch*[T: float32|float64](x: T): T = arcsinh(1.0 / x)
+  ## Computes the inverse hyperbolic cosecant of `x` (`arcsinh(1/x)`).
+
+const windowsCC89 = defined(windows) and defined(bcc)
+
+when not defined(js): # C
+  func hypot*(x, y: float32): float32 {.importc: "hypotf", header: "<math.h>".}
+  func hypot*(x, y: float64): float64 {.importc: "hypot", header: "<math.h>".} =
+    ## Computes the length of the hypotenuse of a right-angle triangle with
+    ## `x` as its base and `y` as its height. Equivalent to `sqrt(x*x + y*y)`.
+    runnableExamples:
+      doAssert almostEqual(hypot(3.0, 4.0), 5.0)
+  func pow*(x, y: float32): float32 {.importc: "powf", header: "<math.h>".}
+  func pow*(x, y: float64): float64 {.importc: "pow", header: "<math.h>".} =
+    ## Computes `x` raised to the power of `y`.
+    ##
+    ## To compute the power between integers (e.g. 2^6),
+    ## use the `^ func <#^,T,Natural>`_.
+    ##
+    ## **See also:**
+    ## * `^ func <#^,T,Natural>`_
+    ## * `sqrt func <#sqrt,float64>`_
+    ## * `cbrt func <#cbrt,float64>`_
+    runnableExamples:
+      doAssert almostEqual(pow(100, 1.5), 1000.0)
+      doAssert almostEqual(pow(16.0, 0.5), 4.0)
+
+  # TODO: add C89 version on windows
+  when not windowsCC89:
+    func erf*(x: float32): float32 {.importc: "erff", header: "<math.h>".}
+    func erf*(x: float64): float64 {.importc: "erf", header: "<math.h>".}
+      ## Computes the [error function](https://en.wikipedia.org/wiki/Error_function) for `x`.
+      ##
+      ## **Note:** Not available for the JS backend.
+    func erfc*(x: float32): float32 {.importc: "erfcf", header: "<math.h>".}
+    func erfc*(x: float64): float64 {.importc: "erfc", header: "<math.h>".}
+      ## Computes the [complementary error function](https://en.wikipedia.org/wiki/Error_function#Complementary_error_function) for `x`.
+      ##
+      ## **Note:** Not available for the JS backend.
+    func gamma*(x: float32): float32 {.importc: "tgammaf", header: "<math.h>".}
+    func gamma*(x: float64): float64 {.importc: "tgamma", header: "<math.h>".} =
+      ## Computes the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) for `x`.
+      ##
+      ## **Note:** Not available for the JS backend.
+      ##
+      ## **See also:**
+      ## * `lgamma func <#lgamma,float64>`_ for the natural logarithm of the gamma function
+      runnableExamples:
+        doAssert almostEqual(gamma(1.0), 1.0)
+        doAssert almostEqual(gamma(4.0), 6.0)
+        doAssert almostEqual(gamma(11.0), 3628800.0)
+    func lgamma*(x: float32): float32 {.importc: "lgammaf", header: "<math.h>".}
+    func lgamma*(x: float64): float64 {.importc: "lgamma", header: "<math.h>".} =
+      ## Computes the natural logarithm of the gamma function for `x`.
+      ##
+      ## **Note:** Not available for the JS backend.
+      ##
+      ## **See also:**
+      ## * `gamma func <#gamma,float64>`_ for gamma function
+
+  func floor*(x: float32): float32 {.importc: "floorf", header: "<math.h>".}
+  func floor*(x: float64): float64 {.importc: "floor", header: "<math.h>".} =
+    ## Computes the floor function (i.e. the largest integer not greater than `x`).
+    ##
+    ## **See also:**
+    ## * `ceil func <#ceil,float64>`_
+    ## * `round func <#round,float64>`_
+    ## * `trunc func <#trunc,float64>`_
+    runnableExamples:
+      doAssert floor(2.1)  == 2.0
+      doAssert floor(2.9)  == 2.0
+      doAssert floor(-3.5) == -4.0
+
+  func ceil*(x: float32): float32 {.importc: "ceilf", header: "<math.h>".}
+  func ceil*(x: float64): float64 {.importc: "ceil", header: "<math.h>".} =
+    ## Computes the ceiling function (i.e. the smallest integer not smaller
+    ## than `x`).
+    ##
+    ## **See also:**
+    ## * `floor func <#floor,float64>`_
+    ## * `round func <#round,float64>`_
+    ## * `trunc func <#trunc,float64>`_
+    runnableExamples:
+      doAssert ceil(2.1)  == 3.0
+      doAssert ceil(2.9)  == 3.0
+      doAssert ceil(-2.1) == -2.0
+
+  when windowsCC89:
+    # MSVC 2010 don't have trunc/truncf
+    # this implementation was inspired by Go-lang Math.Trunc
+    func truncImpl(f: float64): float64 =
+      const
+        mask: uint64 = 0x7FF
+        shift: uint64 = 64 - 12
+        bias: uint64 = 0x3FF
+
+      if f < 1:
+        if f < 0: return -truncImpl(-f)
+        elif f == 0: return f # Return -0 when f == -0
+        else: return 0
+
+      var x = cast[uint64](f)
+      let e = (x shr shift) and mask - bias
+
+      # Keep the top 12+e bits, the integer part; clear the rest.
+      if e < 64 - 12:
+        x = x and (not (1'u64 shl (64'u64 - 12'u64 - e) - 1'u64))
+
+      result = cast[float64](x)
+
+    func truncImpl(f: float32): float32 =
+      const
+        mask: uint32 = 0xFF
+        shift: uint32 = 32 - 9
+        bias: uint32 = 0x7F
+
+      if f < 1:
+        if f < 0: return -truncImpl(-f)
+        elif f == 0: return f # Return -0 when f == -0
+        else: return 0
+
+      var x = cast[uint32](f)
+      let e = (x shr shift) and mask - bias
+
+      # Keep the top 9+e bits, the integer part; clear the rest.
+      if e < 32 - 9:
+        x = x and (not (1'u32 shl (32'u32 - 9'u32 - e) - 1'u32))
+
+      result = cast[float32](x)
+
+    func trunc*(x: float64): float64 =
+      if classify(x) in {fcZero, fcNegZero, fcNan, fcInf, fcNegInf}: return x
+      result = truncImpl(x)
+
+    func trunc*(x: float32): float32 =
+      if classify(x) in {fcZero, fcNegZero, fcNan, fcInf, fcNegInf}: return x
+      result = truncImpl(x)
+
+    func round*[T: float32|float64](x: T): T =
+      ## Windows compilers prior to MSVC 2012 do not implement 'round',
+      ## 'roundl' or 'roundf'.
+      result = if x < 0.0: ceil(x - T(0.5)) else: floor(x + T(0.5))
+  else:
+    func round*(x: float32): float32 {.importc: "roundf", header: "<math.h>".}
+    func round*(x: float64): float64 {.importc: "round", header: "<math.h>".} =
+      ## Rounds a float to zero decimal places.
+      ##
+      ## Used internally by the `round func <#round,T,int>`_
+      ## when the specified number of places is 0.
+      ##
+      ## **See also:**
+      ## * `round func <#round,T,int>`_ for rounding to the specific
+      ##   number of decimal places
+      ## * `floor func <#floor,float64>`_
+      ## * `ceil func <#ceil,float64>`_
+      ## * `trunc func <#trunc,float64>`_
+      runnableExamples:
+        doAssert round(3.4) == 3.0
+        doAssert round(3.5) == 4.0
+        doAssert round(4.5) == 5.0
+
+    func trunc*(x: float32): float32 {.importc: "truncf", header: "<math.h>".}
+    func trunc*(x: float64): float64 {.importc: "trunc", header: "<math.h>".} =
+      ## Truncates `x` to the decimal point.
+      ##
+      ## **See also:**
+      ## * `floor func <#floor,float64>`_
+      ## * `ceil func <#ceil,float64>`_
+      ## * `round func <#round,float64>`_
+      runnableExamples:
+        doAssert trunc(PI) == 3.0
+        doAssert trunc(-1.85) == -1.0
+
+  func `mod`*(x, y: float32): float32 {.importc: "fmodf", header: "<math.h>".}
+  func `mod`*(x, y: float64): float64 {.importc: "fmod", header: "<math.h>".} =
+    ## Computes the modulo operation for float values (the remainder of `x` divided by `y`).
+    ##
+    ## **See also:**
+    ## * `floorMod func <#floorMod,T,T>`_ for Python-like (`%` operator) behavior
+    runnableExamples:
+      doAssert  6.5 mod  2.5 ==  1.5
+      doAssert -6.5 mod  2.5 == -1.5
+      doAssert  6.5 mod -2.5 ==  1.5
+      doAssert -6.5 mod -2.5 == -1.5
+
+else: # JS
+  func hypot*(x, y: float32): float32 {.importc: "Math.hypot", varargs, nodecl.}
+  func hypot*(x, y: float64): float64 {.importc: "Math.hypot", varargs, nodecl.}
+  func pow*(x, y: float32): float32 {.importc: "Math.pow", nodecl.}
+  func pow*(x, y: float64): float64 {.importc: "Math.pow", nodecl.}
+  func floor*(x: float32): float32 {.importc: "Math.floor", nodecl.}
+  func floor*(x: float64): float64 {.importc: "Math.floor", nodecl.}
+  func ceil*(x: float32): float32 {.importc: "Math.ceil", nodecl.}
+  func ceil*(x: float64): float64 {.importc: "Math.ceil", nodecl.}
+
+  when (NimMajor, NimMinor) < (1, 5) or defined(nimLegacyJsRound):
+    func round*(x: float): float {.importc: "Math.round", nodecl.}
+  else:
+    func jsRound(x: float): float {.importc: "Math.round", nodecl.}
+    func round*[T: float64 | float32](x: T): T =
+      if x >= 0: result = jsRound(x)
+      else:
+        result = ceil(x)
+        if result - x >= T(0.5):
+          result -= T(1.0)
+  func trunc*(x: float32): float32 {.importc: "Math.trunc", nodecl.}
+  func trunc*(x: float64): float64 {.importc: "Math.trunc", nodecl.}
+
+  func `mod`*(x, y: float32): float32 {.importjs: "(# % #)".}
+  func `mod`*(x, y: float64): float64 {.importjs: "(# % #)".} =
+    ## Computes the modulo operation for float values (the remainder of `x` divided by `y`).
+    runnableExamples:
+      doAssert  6.5 mod  2.5 ==  1.5
+      doAssert -6.5 mod  2.5 == -1.5
+      doAssert  6.5 mod -2.5 ==  1.5
+      doAssert -6.5 mod -2.5 == -1.5
   
-  proc sqrt*(x: float): float {.importc: "Math.sqrt", nodecl.}
-  proc ln*(x: float): float {.importc: "Math.log", nodecl.}
-  proc log10*(x: float): float = return ln(x) / ln(10.0)
-  proc log2*(x: float): float = return ln(x) / ln(2.0)
-
-  proc exp*(x: float): float {.importc: "Math.exp", nodecl.}
-  proc round*(x: float): int {.importc: "Math.round", nodecl.}
-  proc pow*(x, y: float): float {.importc: "Math.pow", nodecl.}
+  func divmod*[T:SomeInteger](num, denom: T): (T, T) = 
+    runnableExamples:
+      doAssert  divmod(5, 2) ==  (2, 1)
+      doAssert divmod(5, -3) == (-1, 2)
+    result[0] = num div denom
+    result[1] = num mod denom
   
-  proc frexp*(x: float, exponent: var int): float =
+
+func round*[T: float32|float64](x: T, places: int): T =
+  ## Decimal rounding on a binary floating point number.
+  ##
+  ## This function is NOT reliable. Floating point numbers cannot hold
+  ## non integer decimals precisely. If `places` is 0 (or omitted),
+  ## round to the nearest integral value following normal mathematical
+  ## rounding rules (e.g.  `round(54.5) -> 55.0`). If `places` is
+  ## greater than 0, round to the given number of decimal places,
+  ## e.g. `round(54.346, 2) -> 54.350000000000001421…`. If `places` is negative, round
+  ## to the left of the decimal place, e.g. `round(537.345, -1) -> 540.0`.
+  runnableExamples:
+    doAssert round(PI, 2) == 3.14
+    doAssert round(PI, 4) == 3.1416
+
+  if places == 0:
+    result = round(x)
+  else:
+    var mult = pow(10.0, T(places))
+    result = round(x * mult) / mult
+
+func floorDiv*[T: SomeInteger](x, y: T): T =
+  ## Floor division is conceptually defined as `floor(x / y)`.
+  ##
+  ## This is different from the `system.div <system.html#div,int,int>`_
+  ## operator, which is defined as `trunc(x / y)`.
+  ## That is, `div` rounds towards `0` and `floorDiv` rounds down.
+  ##
+  ## **See also:**
+  ## * `system.div proc <system.html#div,int,int>`_ for integer division
+  ## * `floorMod func <#floorMod,T,T>`_ for Python-like (`%` operator) behavior
+  runnableExamples:
+    doAssert floorDiv( 13,  3) ==  4
+    doAssert floorDiv(-13,  3) == -5
+    doAssert floorDiv( 13, -3) == -5
+    doAssert floorDiv(-13, -3) ==  4
+
+  result = x div y
+  let r = x mod y
+  if (r > 0 and y < 0) or (r < 0 and y > 0): result.dec 1
+
+func floorMod*[T: SomeNumber](x, y: T): T =
+  ## Floor modulo is conceptually defined as `x - (floorDiv(x, y) * y)`.
+  ##
+  ## This func behaves the same as the `%` operator in Python.
+  ##
+  ## **See also:**
+  ## * `mod func <#mod,float64,float64>`_
+  ## * `floorDiv func <#floorDiv,T,T>`_
+  runnableExamples:
+    doAssert floorMod( 13,  3) ==  1
+    doAssert floorMod(-13,  3) ==  2
+    doAssert floorMod( 13, -3) == -2
+    doAssert floorMod(-13, -3) == -1
+
+  result = x mod y
+  if (result > 0 and y < 0) or (result < 0 and y > 0): result += y
+
+func euclDiv*[T: SomeInteger](x, y: T): T {.since: (1, 5, 1).} =
+  ## Returns euclidean division of `x` by `y`.
+  runnableExamples:
+    doAssert euclDiv(13, 3) == 4
+    doAssert euclDiv(-13, 3) == -5
+    doAssert euclDiv(13, -3) == -4
+    doAssert euclDiv(-13, -3) == 5
+
+  result = x div y
+  if x mod y < 0:
+    if y > 0:
+      dec result
+    else:
+      inc result
+
+func euclMod*[T: SomeNumber](x, y: T): T {.since: (1, 5, 1).} =
+  ## Returns euclidean modulo of `x` by `y`.
+  ## `euclMod(x, y)` is non-negative.
+  runnableExamples:
+    doAssert euclMod(13, 3) == 1
+    doAssert euclMod(-13, 3) == 2
+    doAssert euclMod(13, -3) == 1
+    doAssert euclMod(-13, -3) == 2
+
+  result = x mod y
+  if result < 0:
+    result += abs(y)
+
+func ceilDiv*[T: SomeInteger](x, y: T): T {.inline, since: (1, 5, 1).} =
+  ## Ceil division is conceptually defined as `ceil(x / y)`.
+  ##
+  ## Assumes `x >= 0` and `y > 0` (and `x + y - 1 <= high(T)` if T is SomeUnsignedInt).
+  ##
+  ## This is different from the `system.div <system.html#div,int,int>`_
+  ## operator, which works like `trunc(x / y)`.
+  ## That is, `div` rounds towards `0` and `ceilDiv` rounds up.
+  ##
+  ## This function has the above input limitation, because that allows the
+  ## compiler to generate faster code and it is rarely used with
+  ## negative values or unsigned integers close to `high(T)/2`.
+  ## If you need a `ceilDiv` that works with any input, see:
+  ## https://github.com/demotomohiro/divmath.
+  ##
+  ## **See also:**
+  ## * `system.div proc <system.html#div,int,int>`_ for integer division
+  ## * `floorDiv func <#floorDiv,T,T>`_ for integer division which rounds down.
+  runnableExamples:
+    assert ceilDiv(12, 3) ==  4
+    assert ceilDiv(13, 3) ==  5
+
+  when sizeof(T) == 8:
+    type UT = uint64
+  elif sizeof(T) == 4:
+    type UT = uint32
+  elif sizeof(T) == 2:
+    type UT = uint16
+  elif sizeof(T) == 1:
+    type UT = uint8
+  else:
+    {.fatal: "Unsupported int type".}
+
+  assert x >= 0 and y > 0
+  when T is SomeUnsignedInt:
+    assert x + y - 1 >= x
+
+  # If the divisor is const, the backend C/C++ compiler generates code without a `div`
+  # instruction, as it is slow on most CPUs.
+  # If the divisor is a power of 2 and a const unsigned integer type, the
+  # compiler generates faster code.
+  # If the divisor is const and a signed integer, generated code becomes slower
+  # than the code with unsigned integers, because division with signed integers
+  # need to works for both positive and negative value without `idiv`/`sdiv`.
+  # That is why this code convert parameters to unsigned.
+  # This post contains a comparison of the performance of signed/unsigned integers:
+  # https://github.com/nim-lang/Nim/pull/18596#issuecomment-894420984.
+  # If signed integer arguments were not converted to unsigned integers,
+  # `ceilDiv` wouldn't work for any positive signed integer value, because
+  # `x + (y - 1)` can overflow.
+  ((x.UT + (y.UT - 1.UT)) div y.UT).T
+
+func frexp*[T: float32|float64](x: T): tuple[frac: T, exp: int] {.inline.} =
+  ## Splits `x` into a normalized fraction `frac` and an integral power of 2 `exp`,
+  ## such that `abs(frac) in 0.5..<1` and `x == frac * 2 ^ exp`, except for special
+  ## cases shown below.
+  runnableExamples:
+    doAssert frexp(8.0) == (0.5, 4)
+    doAssert frexp(-8.0) == (-0.5, 4)
+    doAssert frexp(0.0) == (0.0, 0)
+
+    # special cases:
+    when sizeof(int) == 8:
+      doAssert frexp(-0.0).frac.signbit # signbit preserved for +-0
+      doAssert frexp(Inf).frac == Inf # +- Inf preserved
+      doAssert frexp(NaN).frac.isNaN
+
+  when not defined(js):
+    var exp: cint
+    result.frac = c_frexp2(x, exp)
+    result.exp = exp
+  else:
     if x == 0.0:
-      exponent = 0.0
-      result = 0.0
+      # reuse signbit implementation
+      let uintBuffer = toBitsImpl(x)
+      if (uintBuffer[1] shr 31) != 0:
+        # x is -0.0
+        result = (-0.0, 0)
+      else:
+        result = (0.0, 0)
     elif x < 0.0:
-      result = -frexp(-x, exponent)
+      result = frexp(-x)
+      result.frac = -result.frac
     else:
-      var ex = mathfloor(log2(x))
-      exponent = round(ex)
-      result = x / pow(2.0, ex)
-
-  proc arccos*(x: float): float {.importc: "Math.acos", nodecl.}
-  proc arcsin*(x: float): float {.importc: "Math.asin", nodecl.}
-  proc arctan*(x: float): float {.importc: "Math.atan", nodecl.}
-  proc arctan2*(y, x: float): float {.importc: "Math.atan2", nodecl.}
-  
-  proc cos*(x: float): float {.importc: "Math.cos", nodecl.}
-  proc cosh*(x: float): float = return (exp(x)+exp(-x))*0.5
-  proc hypot*(x, y: float): float = return sqrt(x*x + y*y)
-  proc sinh*(x: float): float = return (exp(x)-exp(-x))*0.5
-  proc tan*(x: float): float {.importc: "Math.tan", nodecl.}
-  proc tanh*(x: float): float =
-    var y = exp(2.0*x)
-    return (y-1.0)/(y+1.0)
+      var ex = trunc(log2(x))
+      result.exp = int(ex)
+      result.frac = x / pow(2.0, ex)
+      if abs(result.frac) >= 1:
+        inc(result.exp)
+        result.frac = result.frac / 2
+      if result.exp == 1024 and result.frac == 0.0:
+        result.frac = 0.99999999999999988898
 
+func frexp*[T: float32|float64](x: T, exponent: var int): T {.inline.} =
+  ## Overload of `frexp` that calls `(result, exponent) = frexp(x)`.
+  runnableExamples:
+    var x: int
+    doAssert frexp(5.0, x) == 0.625
+    doAssert x == 3
+
+  (result, exponent) = frexp(x)
+
+
+when not defined(js):
+  when windowsCC89:
+    # taken from Go-lang Math.Log2
+    const ln2 = 0.693147180559945309417232121458176568075500134360255254120680009
+    template log2Impl[T](x: T): T =
+      var exp: int
+      var frac = frexp(x, exp)
+      # Make sure exact powers of two give an exact answer.
+      # Don't depend on Log(0.5)*(1/Ln2)+exp being exactly exp-1.
+      if frac == 0.5: return T(exp - 1)
+      log10(frac) * (1 / ln2) + T(exp)
+
+    func log2*(x: float32): float32 = log2Impl(x)
+    func log2*(x: float64): float64 = log2Impl(x)
+      ## Log2 returns the binary logarithm of x.
+      ## The special cases are the same as for Log.
 
-type
-  TRunningStat* = object  ## an accumulator for statistical data
-    n*: int               ## number of pushed data
-    sum*, min*, max*, mean*: float ## self-explaining
-    oldM, oldS, newS: float
-
-proc push*(s: var TRunningStat, x: float) = 
-  ## pushes a value `x` for processing
-  inc(s.n)
-  # See Knuth TAOCP vol 2, 3rd edition, page 232
-  if s.n == 1:
-    s.oldM = x
-    s.mean = x
-    s.oldS = 0.0
   else:
-    s.mean = s.oldM + (x - s.oldM)/toFloat(s.n)
-    s.newS = s.oldS + (x - s.oldM)*(x - s.mean)
+    func log2*(x: float32): float32 {.importc: "log2f", header: "<math.h>".}
+    func log2*(x: float64): float64 {.importc: "log2", header: "<math.h>".} =
+      ## Computes the binary logarithm (base 2) of `x`.
+      ##
+      ## **See also:**
+      ## * `log func <#log,T,T>`_
+      ## * `log10 func <#log10,float64>`_
+      ## * `ln func <#ln,float64>`_
+      runnableExamples:
+        doAssert almostEqual(log2(8.0), 3.0)
+        doAssert almostEqual(log2(1.0), 0.0)
+        doAssert almostEqual(log2(0.0), -Inf)
+        doAssert log2(-2.0).isNaN
 
-    # set up for next iteration:
-    s.oldM = s.mean
-    s.oldS = s.newS
-  
-  s.sum = s.sum + x
-  if s.min > x: s.min = x
-  if s.max < x: s.max = x
+func splitDecimal*[T: float32|float64](x: T): tuple[intpart: T, floatpart: T] =
+  ## Breaks `x` into an integer and a fractional part.
+  ##
+  ## Returns a tuple containing `intpart` and `floatpart`, representing
+  ## the integer part and the fractional part, respectively.
+  ##
+  ## Both parts have the same sign as `x`.  Analogous to the `modf`
+  ## function in C.
+  runnableExamples:
+    doAssert splitDecimal(5.25) == (intpart: 5.0, floatpart: 0.25)
+    doAssert splitDecimal(-2.73) == (intpart: -2.0, floatpart: -0.73)
+
+  var
+    absolute: T
+  absolute = abs(x)
+  result.intpart = floor(absolute)
+  result.floatpart = absolute - result.intpart
+  if x < 0:
+    result.intpart = -result.intpart
+    result.floatpart = -result.floatpart
+
+
+func degToRad*[T: float32|float64](d: T): T {.inline.} =
+  ## Converts from degrees to radians.
+  ##
+  ## **See also:**
+  ## * `radToDeg func <#radToDeg,T>`_
+  runnableExamples:
+    doAssert almostEqual(degToRad(180.0), PI)
+
+  result = d * T(RadPerDeg)
+
+func radToDeg*[T: float32|float64](d: T): T {.inline.} =
+  ## Converts from radians to degrees.
+  ##
+  ## **See also:**
+  ## * `degToRad func <#degToRad,T>`_
+  runnableExamples:
+    doAssert almostEqual(radToDeg(2 * PI), 360.0)
 
-proc variance*(s: TRunningStat): float = 
-  ## computes the current variance of `s`
-  if s.n > 1: result = s.newS / (toFloat(s.n - 1))
+  result = d / T(RadPerDeg)
 
-proc standardDeviation*(s: TRunningStat): float = 
-  ## computes the current standard deviation of `s`
-  result = sqrt(variance(s))
+func sgn*[T: SomeNumber](x: T): int {.inline.} =
+  ## Sign function.
+  ##
+  ## Returns:
+  ## * `-1` for negative numbers and `NegInf`,
+  ## * `1` for positive numbers and `Inf`,
+  ## * `0` for positive zero, negative zero and `NaN`
+  runnableExamples:
+    doAssert sgn(5) == 1
+    doAssert sgn(0) == 0
+    doAssert sgn(-4.1) == -1
+
+  ord(T(0) < x) - ord(x < T(0))
 
 {.pop.}
 {.pop.}
+
+func sum*[T](x: openArray[T]): T =
+  ## Computes the sum of the elements in `x`.
+  ##
+  ## If `x` is empty, 0 is returned.
+  ##
+  ## **See also:**
+  ## * `prod func <#prod,openArray[T]>`_
+  ## * `cumsum func <#cumsum,openArray[T]>`_
+  ## * `cumsummed func <#cumsummed,openArray[T]>`_
+  runnableExamples:
+    doAssert sum([1, 2, 3, 4]) == 10
+    doAssert sum([-4, 3, 5]) == 4
+
+  for i in items(x): result = result + i
+
+func prod*[T](x: openArray[T]): T =
+  ## Computes the product of the elements in `x`.
+  ##
+  ## If `x` is empty, 1 is returned.
+  ##
+  ## **See also:**
+  ## * `sum func <#sum,openArray[T]>`_
+  ## * `fac func <#fac,int>`_
+  runnableExamples:
+    doAssert prod([1, 2, 3, 4]) == 24
+    doAssert prod([-4, 3, 5]) == -60
+
+  result = T(1)
+  for i in items(x): result = result * i
+
+func cumsummed*[T](x: openArray[T]): seq[T] =
+  ## Returns the cumulative (aka prefix) summation of `x`.
+  ##
+  ## If `x` is empty, `@[]` is returned.
+  ##
+  ## **See also:**
+  ## * `sum func <#sum,openArray[T]>`_
+  ## * `cumsum func <#cumsum,openArray[T]>`_ for the in-place version
+  runnableExamples:
+    doAssert cumsummed([1, 2, 3, 4]) == @[1, 3, 6, 10]
+
+  let xLen = x.len
+  if xLen == 0:
+    return @[]
+  result.setLen(xLen)
+  result[0] = x[0]
+  for i in 1 ..< xLen: result[i] = result[i - 1] + x[i]
+
+func cumsum*[T](x: var openArray[T]) =
+  ## Transforms `x` in-place (must be declared as `var`) into its
+  ## cumulative (aka prefix) summation.
+  ##
+  ## **See also:**
+  ## * `sum func <#sum,openArray[T]>`_
+  ## * `cumsummed func <#cumsummed,openArray[T]>`_ for a version which
+  ##   returns a cumsummed sequence
+  runnableExamples:
+    var a = [1, 2, 3, 4]
+    cumsum(a)
+    doAssert a == @[1, 3, 6, 10]
+
+  for i in 1 ..< x.len: x[i] = x[i - 1] + x[i]
+
+func `^`*[T: SomeNumber](x: T, y: Natural): T =
+  ## Computes `x` to the power of `y`.
+  ##
+  ## The exponent `y` must be non-negative, use
+  ## `pow <#pow,float64,float64>`_ for negative exponents.
+  ##
+  ## **See also:**
+  ## * `pow func <#pow,float64,float64>`_ for negative exponent or
+  ##   floats
+  ## * `sqrt func <#sqrt,float64>`_
+  ## * `cbrt func <#cbrt,float64>`_
+  runnableExamples:
+    doAssert -3 ^ 0 == 1
+    doAssert -3 ^ 1 == -3
+    doAssert -3 ^ 2 == 9
+
+  case y
+  of 0: result = 1
+  of 1: result = x
+  of 2: result = x * x
+  of 3: result = x * x * x
+  else:
+    var (x, y) = (x, y)
+    result = 1
+    while true:
+      if (y and 1) != 0:
+        result *= x
+      y = y shr 1
+      if y == 0:
+        break
+      x *= x
+
+func gcd*[T](x, y: T): T =
+  ## Computes the greatest common (positive) divisor of `x` and `y`.
+  ##
+  ## Note that for floats, the result cannot always be interpreted as
+  ## "greatest decimal `z` such that `z*N == x and z*M == y`
+  ## where N and M are positive integers".
+  ##
+  ## **See also:**
+  ## * `gcd func <#gcd,SomeInteger,SomeInteger>`_ for an integer version
+  ## * `lcm func <#lcm,T,T>`_
+  runnableExamples:
+    doAssert gcd(13.5, 9.0) == 4.5
+
+  var (x, y) = (x, y)
+  while y != 0:
+    x = x mod y
+    swap x, y
+  abs x
+
+when useBuiltins:
+  ## this func uses bitwise comparisons from C compilers, which are not always available.
+  func gcd*(x, y: SomeInteger): SomeInteger =
+    ## Computes the greatest common (positive) divisor of `x` and `y`,
+    ## using the binary GCD (aka Stein's) algorithm.
+    ##
+    ## **See also:**
+    ## * `gcd func <#gcd,T,T>`_ for a float version
+    ## * `lcm func <#lcm,T,T>`_
+    runnableExamples:
+      doAssert gcd(12, 8) == 4
+      doAssert gcd(17, 63) == 1
+  
+    when x is SomeSignedInt:
+      var x = abs(x)
+    else:
+      var x = x
+    when y is SomeSignedInt:
+      var y = abs(y)
+    else:
+      var y = y
+  
+    if x == 0:
+      return y
+    if y == 0:
+      return x
+  
+    let shift = countTrailingZeroBits(x or y)
+    y = y shr countTrailingZeroBits(y)
+    while x != 0:
+      x = x shr countTrailingZeroBits(x)
+      if y > x:
+        swap y, x
+      x -= y
+    y shl shift
+  
+func gcd*[T](x: openArray[T]): T {.since: (1, 1).} =
+  ## Computes the greatest common (positive) divisor of the elements of `x`.
+  ##
+  ## **See also:**
+  ## * `gcd func <#gcd,T,T>`_ for a version with two arguments
+  runnableExamples:
+    doAssert gcd(@[13.5, 9.0]) == 4.5
+
+  result = x[0]
+  for i in 1 ..< x.len:
+    result = gcd(result, x[i])
+
+func lcm*[T](x, y: T): T =
+  ## Computes the least common multiple of `x` and `y`.
+  ##
+  ## **See also:**
+  ## * `gcd func <#gcd,T,T>`_
+  runnableExamples:
+    doAssert lcm(24, 30) == 120
+    doAssert lcm(13, 39) == 39
+
+  x div gcd(x, y) * y
+
+func clamp*[T](val: T, bounds: Slice[T]): T {.since: (1, 5), inline.} =
+  ## Like `system.clamp`, but takes a slice, so you can easily clamp within a range.
+  runnableExamples:
+    assert clamp(10, 1 .. 5) == 5
+    assert clamp(1, 1 .. 3) == 1
+    type A = enum a0, a1, a2, a3, a4, a5
+    assert a1.clamp(a2..a4) == a2
+    assert clamp((3, 0), (1, 0) .. (2, 9)) == (2, 9)
+    doAssertRaises(AssertionDefect): discard clamp(1, 3..2) # invalid bounds
+  assert bounds.a <= bounds.b, $(bounds.a, bounds.b)
+  clamp(val, bounds.a, bounds.b)
+
+func lcm*[T](x: openArray[T]): T {.since: (1, 1).} =
+  ## Computes the least common multiple of the elements of `x`.
+  ##
+  ## **See also:**
+  ## * `lcm func <#lcm,T,T>`_ for a version with two arguments
+  runnableExamples:
+    doAssert lcm(@[24, 30]) == 120
+
+  result = x[0]
+  for i in 1 ..< x.len:
+    result = lcm(result, x[i])
diff --git a/lib/pure/md5.nim b/lib/pure/md5.nim
index e75f80b4c..9c3f6d51b 100755..100644
--- a/lib/pure/md5.nim
+++ b/lib/pure/md5.nim
@@ -1,245 +1,335 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## Module for computing MD5 checksums.
-
-type 
-  MD5State = array[0..3, int32]
-  MD5Block = array[0..15, int32]
-  MD5CBits = array[0..7, int8]
-  MD5Digest* = array[0..15, int8]
-  MD5Buffer = array[0..63, int8]
-  MD5Context* {.final.} = object 
-    State: MD5State
-    Count: array[0..1, int32]
-    Buffer: MD5Buffer
-
-const 
-  padding: cstring = "\x80\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0\0\0\0\0" &
-                     "\0\0\0\0"
-
-proc F(x, y, z: int32): int32 {.inline.} = 
-  Result = (x and y) or ((not x) and z)
-
-proc G(x, y, z: int32): int32 {.inline.} = 
-  Result = (x and z) or (y and (not z))
-
-proc H(x, y, z: int32): int32 {.inline.} = 
-  Result = x xor y xor z
-
-proc I(x, y, z: int32): int32 {.inline.} = 
-  Result = y xor (x or (not z))
-
-proc rot(x: var int32, n: int8) {.inline.} = 
-  x = toU32(x shl ze(n)) or (x shr toU32(32 -% ze(n)))
-
-proc FF(a: var int32, b, c, d, x: int32, s: int8, ac: int32) = 
-  a = a +% F(b, c, d) +% x +% ac
+## Module for computing [MD5 checksums](https://en.wikipedia.org/wiki/MD5).
+##
+## This module also works at compile time and in JavaScript.
+##
+## See also
+## ========
+## * `base64 module<base64.html>`_ for a Base64 encoder and decoder
+## * `sha1 module <sha1.html>`_ for the SHA-1 checksum algorithm
+## * `hashes module<hashes.html>`_ for efficient computations of hash values
+##   for diverse Nim types
+
+{.deprecated: "use command `nimble install checksums` and import `checksums/md5` instead".}
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+type
+  MD5State = array[0..3, uint32]
+  MD5Block = array[0..15, uint32]
+  MD5CBits = array[0..7, uint8]
+  MD5Digest* = array[0..15, uint8]
+    ## MD5 checksum of a string, obtained with the `toMD5 proc <#toMD5,string>`_.
+  MD5Buffer = array[0..63, uint8]
+  MD5Context* {.final.} = object
+    state: MD5State
+    count: array[0..1, uint32]
+    buffer: MD5Buffer
+
+const
+  padding: array[0..63, uint8] = [
+    0x80'u8, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0
+  ]
+
+proc F(x, y, z: uint32): uint32 {.inline.} =
+  result = (x and y) or ((not x) and z)
+
+proc G(x, y, z: uint32): uint32 {.inline.} =
+  result = (x and z) or (y and (not z))
+
+proc H(x, y, z: uint32): uint32 {.inline.} =
+  result = x xor y xor z
+
+proc I(x, y, z: uint32): uint32 {.inline.} =
+  result = y xor (x or (not z))
+
+proc rot(x: var uint32, n: uint8) {.inline.} =
+  x = (x shl n) or (x shr (32'u32 - n))
+
+proc FF(a: var uint32, b, c, d, x: uint32, s: uint8, ac: uint32) =
+  a = a + F(b, c, d) + x + ac
   rot(a, s)
-  a = a +% b
+  a = a + b
 
-proc GG(a: var int32, b, c, d, x: int32, s: int8, ac: int32) = 
-  a = a +% G(b, c, d) +% x +% ac
+proc GG(a: var uint32, b, c, d, x: uint32, s: uint8, ac: uint32) =
+  a = a + G(b, c, d) + x + ac
   rot(a, s)
-  a = a +% b
+  a = a + b
 
-proc HH(a: var int32, b, c, d, x: int32, s: int8, ac: int32) = 
-  a = a +% H(b, c, d) +% x +% ac
+proc HH(a: var uint32, b, c, d, x: uint32, s: uint8, ac: uint32) =
+  a = a + H(b, c, d) + x + ac
   rot(a, s)
-  a = a +% b
+  a = a + b
 
-proc II(a: var int32, b, c, d, x: int32, s: int8, ac: int32) = 
-  a = a +% I(b, c, d) +% x +% ac
+proc II(a: var uint32, b, c, d, x: uint32, s: uint8, ac: uint32) =
+  a = a + I(b, c, d) + x + ac
   rot(a, s)
-  a = a +% b
+  a = a + b
 
-proc encode(dest: var MD5Block, src: cstring) = 
+proc encode(dest: var MD5Block, src: openArray[uint8]) =
   var j = 0
   for i in 0..high(dest):
-    dest[i] = toU32(ord(src[j]) or 
-                ord(src[j+1]) shl 8 or
-                ord(src[j+2]) shl 16 or
-                ord(src[j+3]) shl 24)
+    dest[i] = uint32(ord(src[j])) or
+              uint32(ord(src[j+1])) shl 8 or
+              uint32(ord(src[j+2])) shl 16 or
+              uint32(ord(src[j+3])) shl 24
     inc(j, 4)
 
-proc decode(dest: var openarray[int8], src: openarray[int32]) = 
+proc decode(dest: var openArray[uint8], src: openArray[uint32]) =
   var i = 0
   for j in 0..high(src):
-    dest[i] = toU8(src[j] and 0xff'i32)
-    dest[i+1] = toU8(src[j] shr 8'i32 and 0xff'i32)
-    dest[i+2] = toU8(src[j] shr 16'i32 and 0xff'i32)
-    dest[i+3] = toU8(src[j] shr 24'i32 and 0xff'i32)
+    dest[i] = uint8(src[j] and 0xff'u32)
+    dest[i+1] = uint8(src[j] shr 8 and 0xff'u32)
+    dest[i+2] = uint8(src[j] shr 16 and 0xff'u32)
+    dest[i+3] = uint8(src[j] shr 24 and 0xff'u32)
     inc(i, 4)
 
-proc transform(Buffer: pointer, State: var MD5State) = 
-  var
-    myBlock: MD5Block
-  encode(myBlock, cast[cstring](buffer))
-  var a = State[0]
-  var b = State[1]
-  var c = State[2]
-  var d = State[3]
-  FF(a, b, c, d, myBlock[0], 7'i8, 0xD76AA478'i32)
-  FF(d, a, b, c, myBlock[1], 12'i8, 0xE8C7B756'i32)
-  FF(c, d, a, b, myBlock[2], 17'i8, 0x242070DB'i32)
-  FF(b, c, d, a, myBlock[3], 22'i8, 0xC1BDCEEE'i32)
-  FF(a, b, c, d, myBlock[4], 7'i8, 0xF57C0FAF'i32)
-  FF(d, a, b, c, myBlock[5], 12'i8, 0x4787C62A'i32)
-  FF(c, d, a, b, myBlock[6], 17'i8, 0xA8304613'i32)
-  FF(b, c, d, a, myBlock[7], 22'i8, 0xFD469501'i32)
-  FF(a, b, c, d, myBlock[8], 7'i8, 0x698098D8'i32)
-  FF(d, a, b, c, myBlock[9], 12'i8, 0x8B44F7AF'i32)
-  FF(c, d, a, b, myBlock[10], 17'i8, 0xFFFF5BB1'i32)
-  FF(b, c, d, a, myBlock[11], 22'i8, 0x895CD7BE'i32)
-  FF(a, b, c, d, myBlock[12], 7'i8, 0x6B901122'i32)
-  FF(d, a, b, c, myBlock[13], 12'i8, 0xFD987193'i32)
-  FF(c, d, a, b, myBlock[14], 17'i8, 0xA679438E'i32)
-  FF(b, c, d, a, myBlock[15], 22'i8, 0x49B40821'i32)
-  GG(a, b, c, d, myBlock[1], 5'i8, 0xF61E2562'i32)
-  GG(d, a, b, c, myBlock[6], 9'i8, 0xC040B340'i32)
-  GG(c, d, a, b, myBlock[11], 14'i8, 0x265E5A51'i32)
-  GG(b, c, d, a, myBlock[0], 20'i8, 0xE9B6C7AA'i32)
-  GG(a, b, c, d, myBlock[5], 5'i8, 0xD62F105D'i32)
-  GG(d, a, b, c, myBlock[10], 9'i8, 0x02441453'i32)
-  GG(c, d, a, b, myBlock[15], 14'i8, 0xD8A1E681'i32)
-  GG(b, c, d, a, myBlock[4], 20'i8, 0xE7D3FBC8'i32)
-  GG(a, b, c, d, myBlock[9], 5'i8, 0x21E1CDE6'i32)
-  GG(d, a, b, c, myBlock[14], 9'i8, 0xC33707D6'i32)
-  GG(c, d, a, b, myBlock[3], 14'i8, 0xF4D50D87'i32)
-  GG(b, c, d, a, myBlock[8], 20'i8, 0x455A14ED'i32)
-  GG(a, b, c, d, myBlock[13], 5'i8, 0xA9E3E905'i32)
-  GG(d, a, b, c, myBlock[2], 9'i8, 0xFCEFA3F8'i32)
-  GG(c, d, a, b, myBlock[7], 14'i8, 0x676F02D9'i32)
-  GG(b, c, d, a, myBlock[12], 20'i8, 0x8D2A4C8A'i32)
-  HH(a, b, c, d, myBlock[5], 4'i8, 0xFFFA3942'i32)
-  HH(d, a, b, c, myBlock[8], 11'i8, 0x8771F681'i32)
-  HH(c, d, a, b, myBlock[11], 16'i8, 0x6D9D6122'i32)
-  HH(b, c, d, a, myBlock[14], 23'i8, 0xFDE5380C'i32)
-  HH(a, b, c, d, myBlock[1], 4'i8, 0xA4BEEA44'i32)
-  HH(d, a, b, c, myBlock[4], 11'i8, 0x4BDECFA9'i32)
-  HH(c, d, a, b, myBlock[7], 16'i8, 0xF6BB4B60'i32)
-  HH(b, c, d, a, myBlock[10], 23'i8, 0xBEBFBC70'i32)
-  HH(a, b, c, d, myBlock[13], 4'i8, 0x289B7EC6'i32)
-  HH(d, a, b, c, myBlock[0], 11'i8, 0xEAA127FA'i32)
-  HH(c, d, a, b, myBlock[3], 16'i8, 0xD4EF3085'i32)
-  HH(b, c, d, a, myBlock[6], 23'i8, 0x04881D05'i32)
-  HH(a, b, c, d, myBlock[9], 4'i8, 0xD9D4D039'i32)
-  HH(d, a, b, c, myBlock[12], 11'i8, 0xE6DB99E5'i32)
-  HH(c, d, a, b, myBlock[15], 16'i8, 0x1FA27CF8'i32)
-  HH(b, c, d, a, myBlock[2], 23'i8, 0xC4AC5665'i32)
-  II(a, b, c, d, myBlock[0], 6'i8, 0xF4292244'i32)
-  II(d, a, b, c, myBlock[7], 10'i8, 0x432AFF97'i32)
-  II(c, d, a, b, myBlock[14], 15'i8, 0xAB9423A7'i32)
-  II(b, c, d, a, myBlock[5], 21'i8, 0xFC93A039'i32)
-  II(a, b, c, d, myBlock[12], 6'i8, 0x655B59C3'i32)
-  II(d, a, b, c, myBlock[3], 10'i8, 0x8F0CCC92'i32)
-  II(c, d, a, b, myBlock[10], 15'i8, 0xFFEFF47D'i32)
-  II(b, c, d, a, myBlock[1], 21'i8, 0x85845DD1'i32)
-  II(a, b, c, d, myBlock[8], 6'i8, 0x6FA87E4F'i32)
-  II(d, a, b, c, myBlock[15], 10'i8, 0xFE2CE6E0'i32)
-  II(c, d, a, b, myBlock[6], 15'i8, 0xA3014314'i32)
-  II(b, c, d, a, myBlock[13], 21'i8, 0x4E0811A1'i32)
-  II(a, b, c, d, myBlock[4], 6'i8, 0xF7537E82'i32)
-  II(d, a, b, c, myBlock[11], 10'i8, 0xBD3AF235'i32)
-  II(c, d, a, b, myBlock[2], 15'i8, 0x2AD7D2BB'i32)
-  II(b, c, d, a, myBlock[9], 21'i8, 0xEB86D391'i32)
-  State[0] = State[0] +% a
-  State[1] = State[1] +% b
-  State[2] = State[2] +% c
-  State[3] = State[3] +% d
-  
-proc MD5Init*(c: var MD5Context) = 
-  ## initializes a MD5Context  
-  c.State[0] = 0x67452301'i32
-  c.State[1] = 0xEFCDAB89'i32
-  c.State[2] = 0x98BADCFE'i32
-  c.State[3] = 0x10325476'i32
-  c.Count[0] = 0'i32
-  c.Count[1] = 0'i32
-  ZeroMem(addr(c.Buffer), SizeOf(MD5Buffer))
-
-proc MD5Update*(c: var MD5Context, input: cstring, len: int) = 
-  ## updates the MD5Context with the `input` data of length `len`
-  var input = input
-  var Index = (c.Count[0] shr 3) and 0x3F
-  c.Count[0] = c.count[0] +% toU32(len shl 3)
-  if c.Count[0] < (len shl 3): c.Count[1] = c.count[1] +% 1'i32
-  c.Count[1] = c.count[1] +% toU32(len shr 29)
-  var PartLen = 64 - Index
-  if len >= PartLen: 
-    CopyMem(addr(c.Buffer[Index]), Input, PartLen)
-    transform(addr(c.Buffer), c.State)
-    var i = PartLen
-    while i + 63 < len: 
-      Transform(addr(Input[I]), c.State)
-      inc(i, 64)
-    CopyMem(addr(c.Buffer[0]), addr(Input[i]), len-i)
+template slice(s: cstring, a, b): openArray[uint8] =
+  when nimvm:
+    # toOpenArray is not implemented in VM
+    toOpenArrayByte($s, a, b)
   else:
-    CopyMem(addr(c.Buffer[Index]), addr(Input[0]), len)
+    when defined(js):
+      # toOpenArrayByte for cstring is not implemented in JS
+      toOpenArrayByte($s, a, b)
+    else:
+      s.toOpenArrayByte(a, b)
 
-proc MD5Final*(c: var MD5Context, digest: var MD5Digest) = 
-  ## finishes the MD5Context and stores the result in `digest`
+template slice(s: openArray[uint8], a, b): openArray[uint8] =
+  s.toOpenArray(a, b)
+
+const useMem = declared(copyMem)
+
+template memOrNot(withMem, withoutMem): untyped =
+  when nimvm:
+    withoutMem
+  else:
+    when useMem:
+      withMem
+    else:
+      withoutMem
+
+proc transform(buffer: openArray[uint8], state: var MD5State) =
   var
-    Bits: MD5CBits
-    PadLen: int
-  decode(bits, c.Count)
-  var Index = (c.Count[0] shr 3) and 0x3F
-  if Index < 56: PadLen = 56 - Index
-  else: PadLen = 120 - Index
-  MD5Update(c, padding, PadLen)
-  MD5Update(c, cast[cstring](addr(Bits)), 8)
-  decode(digest, c.State)
-  ZeroMem(addr(c), SizeOf(MD5Context))
+    myBlock: MD5Block
+  encode(myBlock, buffer)
+  var a = state[0]
+  var b = state[1]
+  var c = state[2]
+  var d = state[3]
+  FF(a, b, c, d, myBlock[0], 7'u8, 0xD76AA478'u32)
+  FF(d, a, b, c, myBlock[1], 12'u8, 0xE8C7B756'u32)
+  FF(c, d, a, b, myBlock[2], 17'u8, 0x242070DB'u32)
+  FF(b, c, d, a, myBlock[3], 22'u8, 0xC1BDCEEE'u32)
+  FF(a, b, c, d, myBlock[4], 7'u8, 0xF57C0FAF'u32)
+  FF(d, a, b, c, myBlock[5], 12'u8, 0x4787C62A'u32)
+  FF(c, d, a, b, myBlock[6], 17'u8, 0xA8304613'u32)
+  FF(b, c, d, a, myBlock[7], 22'u8, 0xFD469501'u32)
+  FF(a, b, c, d, myBlock[8], 7'u8, 0x698098D8'u32)
+  FF(d, a, b, c, myBlock[9], 12'u8, 0x8B44F7AF'u32)
+  FF(c, d, a, b, myBlock[10], 17'u8, 0xFFFF5BB1'u32)
+  FF(b, c, d, a, myBlock[11], 22'u8, 0x895CD7BE'u32)
+  FF(a, b, c, d, myBlock[12], 7'u8, 0x6B901122'u32)
+  FF(d, a, b, c, myBlock[13], 12'u8, 0xFD987193'u32)
+  FF(c, d, a, b, myBlock[14], 17'u8, 0xA679438E'u32)
+  FF(b, c, d, a, myBlock[15], 22'u8, 0x49B40821'u32)
+  GG(a, b, c, d, myBlock[1], 5'u8, 0xF61E2562'u32)
+  GG(d, a, b, c, myBlock[6], 9'u8, 0xC040B340'u32)
+  GG(c, d, a, b, myBlock[11], 14'u8, 0x265E5A51'u32)
+  GG(b, c, d, a, myBlock[0], 20'u8, 0xE9B6C7AA'u32)
+  GG(a, b, c, d, myBlock[5], 5'u8, 0xD62F105D'u32)
+  GG(d, a, b, c, myBlock[10], 9'u8, 0x02441453'u32)
+  GG(c, d, a, b, myBlock[15], 14'u8, 0xD8A1E681'u32)
+  GG(b, c, d, a, myBlock[4], 20'u8, 0xE7D3FBC8'u32)
+  GG(a, b, c, d, myBlock[9], 5'u8, 0x21E1CDE6'u32)
+  GG(d, a, b, c, myBlock[14], 9'u8, 0xC33707D6'u32)
+  GG(c, d, a, b, myBlock[3], 14'u8, 0xF4D50D87'u32)
+  GG(b, c, d, a, myBlock[8], 20'u8, 0x455A14ED'u32)
+  GG(a, b, c, d, myBlock[13], 5'u8, 0xA9E3E905'u32)
+  GG(d, a, b, c, myBlock[2], 9'u8, 0xFCEFA3F8'u32)
+  GG(c, d, a, b, myBlock[7], 14'u8, 0x676F02D9'u32)
+  GG(b, c, d, a, myBlock[12], 20'u8, 0x8D2A4C8A'u32)
+  HH(a, b, c, d, myBlock[5], 4'u8, 0xFFFA3942'u32)
+  HH(d, a, b, c, myBlock[8], 11'u8, 0x8771F681'u32)
+  HH(c, d, a, b, myBlock[11], 16'u8, 0x6D9D6122'u32)
+  HH(b, c, d, a, myBlock[14], 23'u8, 0xFDE5380C'u32)
+  HH(a, b, c, d, myBlock[1], 4'u8, 0xA4BEEA44'u32)
+  HH(d, a, b, c, myBlock[4], 11'u8, 0x4BDECFA9'u32)
+  HH(c, d, a, b, myBlock[7], 16'u8, 0xF6BB4B60'u32)
+  HH(b, c, d, a, myBlock[10], 23'u8, 0xBEBFBC70'u32)
+  HH(a, b, c, d, myBlock[13], 4'u8, 0x289B7EC6'u32)
+  HH(d, a, b, c, myBlock[0], 11'u8, 0xEAA127FA'u32)
+  HH(c, d, a, b, myBlock[3], 16'u8, 0xD4EF3085'u32)
+  HH(b, c, d, a, myBlock[6], 23'u8, 0x04881D05'u32)
+  HH(a, b, c, d, myBlock[9], 4'u8, 0xD9D4D039'u32)
+  HH(d, a, b, c, myBlock[12], 11'u8, 0xE6DB99E5'u32)
+  HH(c, d, a, b, myBlock[15], 16'u8, 0x1FA27CF8'u32)
+  HH(b, c, d, a, myBlock[2], 23'u8, 0xC4AC5665'u32)
+  II(a, b, c, d, myBlock[0], 6'u8, 0xF4292244'u32)
+  II(d, a, b, c, myBlock[7], 10'u8, 0x432AFF97'u32)
+  II(c, d, a, b, myBlock[14], 15'u8, 0xAB9423A7'u32)
+  II(b, c, d, a, myBlock[5], 21'u8, 0xFC93A039'u32)
+  II(a, b, c, d, myBlock[12], 6'u8, 0x655B59C3'u32)
+  II(d, a, b, c, myBlock[3], 10'u8, 0x8F0CCC92'u32)
+  II(c, d, a, b, myBlock[10], 15'u8, 0xFFEFF47D'u32)
+  II(b, c, d, a, myBlock[1], 21'u8, 0x85845DD1'u32)
+  II(a, b, c, d, myBlock[8], 6'u8, 0x6FA87E4F'u32)
+  II(d, a, b, c, myBlock[15], 10'u8, 0xFE2CE6E0'u32)
+  II(c, d, a, b, myBlock[6], 15'u8, 0xA3014314'u32)
+  II(b, c, d, a, myBlock[13], 21'u8, 0x4E0811A1'u32)
+  II(a, b, c, d, myBlock[4], 6'u8, 0xF7537E82'u32)
+  II(d, a, b, c, myBlock[11], 10'u8, 0xBD3AF235'u32)
+  II(c, d, a, b, myBlock[2], 15'u8, 0x2AD7D2BB'u32)
+  II(b, c, d, a, myBlock[9], 21'u8, 0xEB86D391'u32)
+  state[0] = state[0] + a
+  state[1] = state[1] + b
+  state[2] = state[2] + c
+  state[3] = state[3] + d
+
+proc md5Init*(c: var MD5Context) {.raises: [], tags: [], gcsafe.}
+proc md5Update*(c: var MD5Context, input: openArray[uint8]) {.raises: [],
+    tags: [], gcsafe.}
+proc md5Final*(c: var MD5Context, digest: var MD5Digest) {.raises: [], tags: [], gcsafe.}
+
+proc md5Update*(c: var MD5Context, input: cstring, len: int) {.raises: [],
+    tags: [], gcsafe.} =
+  ## Updates the `MD5Context` with the `input` data of length `len`.
+  ##
+  ## If you use the `toMD5 proc <#toMD5,string>`_, there's no need to call this
+  ## function explicitly.
+  md5Update(c, input.slice(0, len - 1))
+
+
+proc toMD5*(s: string): MD5Digest =
+  ## Computes the `MD5Digest` value for a string `s`.
+  ##
+  ## **See also:**
+  ## * `getMD5 proc <#getMD5,string>`_ which returns a string representation
+  ##   of the `MD5Digest`
+  ## * `$ proc <#$,MD5Digest>`_ for converting MD5Digest to string
+  runnableExamples:
+    assert $toMD5("abc") == "900150983cd24fb0d6963f7d28e17f72"
 
-proc toMD5*(s: string): MD5Digest = 
-  ## computes the MD5Digest value for a string `s`
   var c: MD5Context
-  MD5Init(c)
-  MD5Update(c, cstring(s), len(s))
-  MD5Final(c, result)
-  
-proc `$`*(D: MD5Digest): string = 
-  ## converts a MD5Digest value into its string representation
+  md5Init(c)
+  md5Update(c, s.slice(0, s.len - 1))
+  md5Final(c, result)
+
+proc `$`*(d: MD5Digest): string =
+  ## Converts a `MD5Digest` value into its string representation.
   const digits = "0123456789abcdef"
   result = ""
-  for i in 0..15: 
-    add(result, Digits[(D[I] shr 4) and 0xF])
-    add(result, Digits[D[I] and 0xF])
+  for i in 0..15:
+    add(result, digits[(d[i].int shr 4) and 0xF])
+    add(result, digits[d[i].int and 0xF])
 
-proc getMD5*(s: string): string =  
-  ## computes an MD5 value of `s` and returns its string representation
-  var 
+proc getMD5*(s: string): string =
+  ## Computes an MD5 value of `s` and returns its string representation.
+  ##
+  ## **See also:**
+  ## * `toMD5 proc <#toMD5,string>`_ which returns the `MD5Digest` of a string
+  runnableExamples:
+    assert getMD5("abc") == "900150983cd24fb0d6963f7d28e17f72"
+
+  var
     c: MD5Context
     d: MD5Digest
-  MD5Init(c)
-  MD5Update(c, cstring(s), len(s))
-  MD5Final(c, d)
+  md5Init(c)
+  md5Update(c, s.slice(0, s.len - 1))
+  md5Final(c, d)
   result = $d
-  
-proc `==`*(D1, D2: MD5Digest): bool =  
-  ## checks if two MD5Digest values are identical
-  for i in 0..15: 
+
+proc `==`*(D1, D2: MD5Digest): bool =
+  ## Checks if two `MD5Digest` values are identical.
+  for i in 0..15:
     if D1[i] != D2[i]: return false
   return true
 
-when isMainModule:
-  assert(getMD5("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern") ==
-    "a3cca2b2aa1e3b5b3b5aad99a8529074")
-  assert(getMD5("Frank jagt im komplett verwahrlosten Taxi quer durch Bayern") ==
-    "7e716d0e702df0505fc72e2b89467910")
-  assert($toMD5("") == "d41d8cd98f00b204e9800998ecf8427e")
+
+proc clearBuffer(c: var MD5Context) {.inline.} =
+  memOrNot:
+    zeroMem(addr(c.buffer), sizeof(MD5Buffer))
+  do:
+    reset(c.buffer)
+
+proc md5Init*(c: var MD5Context) =
+  ## Initializes an `MD5Context`.
+  ##
+  ## If you use the `toMD5 proc <#toMD5,string>`_, there's no need to call this
+  ## function explicitly.
+  c.state[0] = 0x67452301'u32
+  c.state[1] = 0xEFCDAB89'u32
+  c.state[2] = 0x98BADCFE'u32
+  c.state[3] = 0x10325476'u32
+  c.count[0] = 0'u32
+  c.count[1] = 0'u32
+  clearBuffer(c)
+
+proc writeBuffer(c: var MD5Context, index: int,
+                 input: openArray[uint8], inputIndex, len: int) {.inline.} =
+  memOrNot:
+    copyMem(addr(c.buffer[index]), unsafeAddr(input[inputIndex]), len)
+  do:
+    # cannot use system.`[]=` for arrays and openarrays as
+    # it can raise RangeDefect which gets tracked
+    for i in 0..<len:
+      c.buffer[index + i] = input[inputIndex + i]
+
+proc md5Update*(c: var MD5Context, input: openArray[uint8]) =
+  ## Updates the `MD5Context` with the `input` data.
+  ##
+  ## If you use the `toMD5 proc <#toMD5,string>`_, there's no need to call this
+  ## function explicitly.
+  var Index = int((c.count[0] shr 3) and 0x3F)
+  c.count[0] = c.count[0] + (uint32(input.len) shl 3)
+  if c.count[0] < (uint32(input.len) shl 3): c.count[1] = c.count[1] + 1'u32
+  c.count[1] = c.count[1] + (uint32(input.len) shr 29)
+  var PartLen = 64 - Index
+  if input.len >= PartLen:
+    writeBuffer(c, Index, input, 0, PartLen)
+    transform(c.buffer, c.state)
+    var i = PartLen
+    while i + 63 < input.len:
+      transform(input.slice(i, i + 63), c.state)
+      inc(i, 64)
+    if i < input.len:
+      writeBuffer(c, 0, input, i, input.len - i)
+  elif input.len > 0:
+    writeBuffer(c, Index, input, 0, input.len)
+
+proc md5Final*(c: var MD5Context, digest: var MD5Digest) =
+  ## Finishes the `MD5Context` and stores the result in `digest`.
+  ##
+  ## If you use the `toMD5 proc <#toMD5,string>`_, there's no need to call this
+  ## function explicitly.
+  var
+    Bits: MD5CBits
+    PadLen: int
+  decode(Bits, c.count)
+  var Index = int((c.count[0] shr 3) and 0x3F)
+  if Index < 56: PadLen = 56 - Index
+  else: PadLen = 120 - Index
+  md5Update(c, padding.slice(0, PadLen - 1))
+  md5Update(c, Bits)
+  decode(digest, c.state)
+  clearBuffer(c)
 
 
+when defined(nimHasStyleChecks):
+  {.pop.} #{.push styleChecks: off.}
\ No newline at end of file
diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim
new file mode 100644
index 000000000..8eec551c4
--- /dev/null
+++ b/lib/pure/memfiles.nim
@@ -0,0 +1,568 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## :Authors: Zahary Karadjov, Andreas Rumpf
+##
+## This module provides support for `memory mapped files`:idx:
+## (Posix's `mmap`:idx:) on the different operating systems.
+##
+## It also provides some fast iterators over lines in text files (or
+## other "line-like", variable length, delimited records).
+
+when defined(windows):
+  import std/winlean
+  when defined(nimPreviewSlimSystem):
+    import std/widestrs
+elif defined(posix):
+  import std/posix
+else:
+  {.error: "the memfiles module is not supported on your operating system!".}
+
+import std/streams
+import std/oserrors
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions]
+
+
+proc newEIO(msg: string): ref IOError =
+  new(result)
+  result.msg = msg
+
+proc setFileSize(fh: FileHandle, newFileSize = -1, oldSize = -1): OSErrorCode =
+  ## Set the size of open file pointed to by `fh` to `newFileSize` if != -1,
+  ## allocating | freeing space from the file system.  This routine returns the
+  ## last OSErrorCode found rather than raising to support old rollback/clean-up
+  ## code style. [ Should maybe move to std/osfiles. ]
+  if newFileSize < 0 or newFileSize == oldSize:
+    return
+  when defined(windows):
+    var sizeHigh = int32(newFileSize shr 32)
+    let sizeLow = int32(newFileSize and 0xffffffff)
+    let status = setFilePointer(fh, sizeLow, addr(sizeHigh), FILE_BEGIN)
+    let lastErr = osLastError()
+    if (status == INVALID_SET_FILE_POINTER and lastErr.int32 != NO_ERROR) or
+        setEndOfFile(fh) == 0:
+      result = lastErr
+  else:
+    if newFileSize > oldSize: # grow the file
+      var e: cint # posix_fallocate truncates up when needed.
+      when declared(posix_fallocate):
+        while (e = posix_fallocate(fh, 0, newFileSize); e == EINTR):
+          discard
+      if e in [EINVAL, EOPNOTSUPP] and ftruncate(fh, newFileSize) == -1:
+        result = osLastError() # fallback arguable; Most portable BUT allows SEGV
+      elif e != 0:
+        result = osLastError()
+    else: # shrink the file
+      if ftruncate(fh.cint, newFileSize) == -1:
+        result = osLastError()
+
+type
+  MemFile* = object      ## represents a memory mapped file
+    mem*: pointer        ## a pointer to the memory mapped file. The pointer
+                         ## can be used directly to change the contents of the
+                         ## file, if it was opened with write access.
+    size*: int           ## size of the memory mapped file
+
+    when defined(windows):
+      fHandle*: Handle   ## **Caution**: Windows specific public field to allow
+                         ## even more low level trickery.
+      mapHandle*: Handle ## **Caution**: Windows specific public field.
+      wasOpened*: bool   ## **Caution**: Windows specific public field.
+    else:
+      handle*: cint      ## **Caution**: Posix specific public field.
+      flags: cint        ## **Caution**: Platform specific private field.
+
+proc mapMem*(m: var MemFile, mode: FileMode = fmRead,
+             mappedSize = -1, offset = 0, mapFlags = cint(-1)): pointer =
+  ## returns a pointer to a mapped portion of MemFile `m`
+  ##
+  ## `mappedSize` of `-1` maps to the whole file, and
+  ## `offset` must be multiples of the PAGE SIZE of your OS
+  if mode == fmAppend:
+    raise newEIO("The append mode is not supported.")
+
+  var readonly = mode == fmRead
+  when defined(windows):
+    result = mapViewOfFileEx(
+      m.mapHandle,
+      if readonly: FILE_MAP_READ else: FILE_MAP_READ or FILE_MAP_WRITE,
+      int32(offset shr 32),
+      int32(offset and 0xffffffff),
+      WinSizeT(if mappedSize == -1: 0 else: mappedSize),
+      nil)
+    if result == nil:
+      raiseOSError(osLastError())
+  else:
+    assert mappedSize > 0
+
+    m.flags = if mapFlags == cint(-1): MAP_SHARED else: mapFlags
+    #Ensure exactly one of MAP_PRIVATE cr MAP_SHARED is set
+    if int(m.flags and MAP_PRIVATE) == 0:
+      m.flags = m.flags or MAP_SHARED
+
+    result = mmap(
+      nil,
+      mappedSize,
+      if readonly: PROT_READ else: PROT_READ or PROT_WRITE,
+      m.flags,
+      m.handle, offset)
+    if result == cast[pointer](MAP_FAILED):
+      raiseOSError(osLastError())
+
+
+proc unmapMem*(f: var MemFile, p: pointer, size: int) =
+  ## unmaps the memory region `(p, <p+size)` of the mapped file `f`.
+  ## All changes are written back to the file system, if `f` was opened
+  ## with write access.
+  ##
+  ## `size` must be of exactly the size that was requested
+  ## via `mapMem`.
+  when defined(windows):
+    if unmapViewOfFile(p) == 0: raiseOSError(osLastError())
+  else:
+    if munmap(p, size) != 0: raiseOSError(osLastError())
+
+
+proc open*(filename: string, mode: FileMode = fmRead,
+           mappedSize = -1, offset = 0, newFileSize = -1,
+           allowRemap = false, mapFlags = cint(-1)): MemFile =
+  ## opens a memory mapped file. If this fails, `OSError` is raised.
+  ##
+  ## `newFileSize` can only be set if the file does not exist and is opened
+  ## with write access (e.g., with fmReadWrite).
+  ##
+  ##`mappedSize` and `offset`
+  ## can be used to map only a slice of the file.
+  ##
+  ## `offset` must be multiples of the PAGE SIZE of your OS
+  ## (usually 4K or 8K but is unique to your OS)
+  ##
+  ## `allowRemap` only needs to be true if you want to call `mapMem` on
+  ## the resulting MemFile; else file handles are not kept open.
+  ##
+  ## `mapFlags` allows callers to override default choices for memory mapping
+  ## flags with a bitwise mask of a variety of likely platform-specific flags
+  ## which may be ignored or even cause `open` to fail if misspecified.
+  ##
+  ## Example:
+  ##
+  ##   ```nim
+  ##   var
+  ##     mm, mm_full, mm_half: MemFile
+  ##
+  ##   mm = memfiles.open("/tmp/test.mmap", mode = fmWrite, newFileSize = 1024)    # Create a new file
+  ##   mm.close()
+  ##
+  ##   # Read the whole file, would fail if newFileSize was set
+  ##   mm_full = memfiles.open("/tmp/test.mmap", mode = fmReadWrite, mappedSize = -1)
+  ##
+  ##   # Read the first 512 bytes
+  ##   mm_half = memfiles.open("/tmp/test.mmap", mode = fmReadWrite, mappedSize = 512)
+  ##   ```
+
+  # The file can be resized only when write mode is used:
+  if mode == fmAppend:
+    raise newEIO("The append mode is not supported.")
+
+  assert newFileSize == -1 or mode != fmRead
+  var readonly = mode == fmRead
+
+  template rollback =
+    result.mem = nil
+    result.size = 0
+
+  when defined(windows):
+    let desiredAccess = GENERIC_READ
+    let shareMode = FILE_SHARE_READ
+    let flags = FILE_FLAG_RANDOM_ACCESS
+
+    template fail(errCode: OSErrorCode, msg: untyped) =
+      rollback()
+      if result.fHandle != 0: discard closeHandle(result.fHandle)
+      if result.mapHandle != 0: discard closeHandle(result.mapHandle)
+      raiseOSError(errCode)
+      # return false
+      #raise newException(IOError, msg)
+
+    template callCreateFile(winApiProc, filename): untyped =
+      winApiProc(
+        filename,
+        # GENERIC_ALL != (GENERIC_READ or GENERIC_WRITE)
+        if readonly: desiredAccess else: desiredAccess or GENERIC_WRITE,
+        if readonly: shareMode else: shareMode or FILE_SHARE_WRITE,
+        nil,
+        if newFileSize != -1: CREATE_ALWAYS else: OPEN_EXISTING,
+        if readonly: FILE_ATTRIBUTE_READONLY or flags
+        else: FILE_ATTRIBUTE_NORMAL or flags,
+        0)
+
+    result.fHandle = callCreateFile(createFileW, newWideCString(filename))
+
+    if result.fHandle == INVALID_HANDLE_VALUE:
+      fail(osLastError(), "error opening file")
+
+    if (let e = setFileSize(result.fHandle.FileHandle, newFileSize);
+        e != 0.OSErrorCode): fail(e, "error setting file size")
+
+    # since the strings are always 'nil', we simply always call
+    # CreateFileMappingW which should be slightly faster anyway:
+    result.mapHandle = createFileMappingW(
+      result.fHandle, nil,
+      if readonly: PAGE_READONLY else: PAGE_READWRITE,
+      0, 0, nil)
+
+    if result.mapHandle == 0:
+      fail(osLastError(), "error creating mapping")
+
+    result.mem = mapViewOfFileEx(
+      result.mapHandle,
+      if readonly: FILE_MAP_READ else: FILE_MAP_READ or FILE_MAP_WRITE,
+      int32(offset shr 32),
+      int32(offset and 0xffffffff),
+      if mappedSize == -1: 0 else: mappedSize,
+      nil)
+
+    if result.mem == nil:
+      fail(osLastError(), "error mapping view")
+
+    var hi, low: int32
+    low = getFileSize(result.fHandle, addr(hi))
+    if low == INVALID_FILE_SIZE:
+      fail(osLastError(), "error getting file size")
+    else:
+      var fileSize = (int64(hi) shl 32) or int64(uint32(low))
+      if mappedSize != -1: result.size = min(fileSize, mappedSize).int
+      else: result.size = fileSize.int
+
+    result.wasOpened = true
+    if not allowRemap and result.fHandle != INVALID_HANDLE_VALUE:
+      if closeHandle(result.fHandle) != 0:
+        result.fHandle = INVALID_HANDLE_VALUE
+
+  else:
+    template fail(errCode: OSErrorCode, msg: string) =
+      rollback()
+      if result.handle != -1: discard close(result.handle)
+      raiseOSError(errCode)
+
+    var flags = (if readonly: O_RDONLY else: O_RDWR) or O_CLOEXEC
+
+    if newFileSize != -1:
+      flags = flags or O_CREAT or O_TRUNC
+      var permissionsMode = S_IRUSR or S_IWUSR
+      result.handle = open(filename, flags, permissionsMode)
+      if result.handle != -1:
+        if (let e = setFileSize(result.handle.FileHandle, newFileSize);
+            e != 0.OSErrorCode): fail(e, "error setting file size")
+    else:
+      result.handle = open(filename, flags)
+
+    if result.handle == -1:
+      fail(osLastError(), "error opening file")
+
+    if mappedSize != -1: #XXX Logic here differs from `when windows` branch ..
+      result.size = mappedSize #.. which always fstats&Uses min(mappedSize, st).
+    else: # if newFileSize!=-1: result.size=newFileSize # if trust setFileSize
+      var stat: Stat  #^^.. BUT some FSes (eg. Linux HugeTLBfs) round to 2MiB.
+      if fstat(result.handle, stat) != -1:
+        result.size = stat.st_size.int # int may be 32-bit-unsafe for 2..<4 GiB
+      else:
+        fail(osLastError(), "error getting file size")
+
+    result.flags = if mapFlags == cint(-1): MAP_SHARED else: mapFlags
+    # Ensure exactly one of MAP_PRIVATE cr MAP_SHARED is set
+    if int(result.flags and MAP_PRIVATE) == 0:
+      result.flags = result.flags or MAP_SHARED
+
+    let pr = if readonly: PROT_READ else: PROT_READ or PROT_WRITE
+    result.mem = mmap(nil, result.size, pr, result.flags, result.handle, offset)
+    if result.mem == cast[pointer](MAP_FAILED):
+      fail(osLastError(), "file mapping failed")
+
+    if not allowRemap and result.handle != -1:
+      if close(result.handle) == 0:
+        result.handle = -1
+
+proc flush*(f: var MemFile; attempts: Natural = 3) =
+  ## Flushes `f`'s buffer for the number of attempts equal to `attempts`.
+  ## If were errors an exception `OSError` will be raised.
+  var res = false
+  var lastErr: OSErrorCode
+  when defined(windows):
+    for i in 1..attempts:
+      res = flushViewOfFile(f.mem, 0) != 0
+      if res:
+        break
+      lastErr = osLastError()
+      if lastErr != ERROR_LOCK_VIOLATION.OSErrorCode:
+        raiseOSError(lastErr)
+  else:
+    for i in 1..attempts:
+      res = msync(f.mem, f.size, MS_SYNC or MS_INVALIDATE) == 0
+      if res:
+        break
+      lastErr = osLastError()
+      if lastErr != EBUSY.OSErrorCode:
+        raiseOSError(lastErr, "error flushing mapping")
+
+proc resize*(f: var MemFile, newFileSize: int) {.raises: [IOError, OSError].} =
+  ## Resize & re-map the file underlying an `allowRemap MemFile`.  If the OS/FS
+  ## supports it, file space is reserved to ensure room for new virtual pages.
+  ## Caller should wait often enough for `flush` to finish to limit use of
+  ## system RAM for write buffering, perhaps just prior to this call.
+  ## **Note**: this assumes the entire file is mapped read-write at offset 0.
+  ## Also, the value of `.mem` will probably change.
+  if newFileSize < 1: # Q: include system/bitmasks & use PageSize ?
+    raise newException(IOError, "Cannot resize MemFile to < 1 byte")
+  when defined(windows):
+    if not f.wasOpened:
+      raise newException(IOError, "Cannot resize unopened MemFile")
+    if f.fHandle == INVALID_HANDLE_VALUE:
+      raise newException(IOError,
+                         "Cannot resize MemFile opened with allowRemap=false")
+    if unmapViewOfFile(f.mem) == 0 or closeHandle(f.mapHandle) == 0: # Un-do map
+      raiseOSError(osLastError())
+    if newFileSize != f.size: # Seek to size & `setEndOfFile` => allocated.
+      if (let e = setFileSize(f.fHandle.FileHandle, newFileSize);
+          e != 0.OSErrorCode): raiseOSError(e)
+    f.mapHandle = createFileMappingW(f.fHandle, nil, PAGE_READWRITE, 0,0,nil)
+    if f.mapHandle == 0:                                             # Re-do map
+      raiseOSError(osLastError())
+    if (let m = mapViewOfFileEx(f.mapHandle, FILE_MAP_READ or FILE_MAP_WRITE,
+                                0, 0, WinSizeT(newFileSize), nil); m != nil):
+      f.mem  = m
+      f.size = newFileSize
+    else:
+      raiseOSError(osLastError())
+  elif defined(posix):
+    if f.handle == -1:
+      raise newException(IOError,
+                         "Cannot resize MemFile opened with allowRemap=false")
+    if newFileSize != f.size:
+      if (let e = setFileSize(f.handle.FileHandle, newFileSize, f.size);
+          e != 0.OSErrorCode): raiseOSError(e)
+    when defined(linux): #Maybe NetBSD, too?
+      # On Linux this can be over 100 times faster than a munmap,mmap cycle.
+      proc mremap(old: pointer; oldSize, newSize: csize_t; flags: cint):
+          pointer {.importc: "mremap", header: "<sys/mman.h>".}
+      let newAddr = mremap(f.mem, csize_t(f.size), csize_t(newFileSize), 1.cint)
+      if newAddr == cast[pointer](MAP_FAILED):
+        raiseOSError(osLastError())
+    else:
+      if munmap(f.mem, f.size) != 0:
+        raiseOSError(osLastError())
+      let newAddr = mmap(nil, newFileSize, PROT_READ or PROT_WRITE,
+                         f.flags, f.handle, 0)
+      if newAddr == cast[pointer](MAP_FAILED):
+        raiseOSError(osLastError())
+    f.mem = newAddr
+    f.size = newFileSize
+
+proc close*(f: var MemFile) =
+  ## closes the memory mapped file `f`. All changes are written back to the
+  ## file system, if `f` was opened with write access.
+
+  var error = false
+  var lastErr: OSErrorCode
+
+  when defined(windows):
+    if f.wasOpened:
+      error = unmapViewOfFile(f.mem) == 0
+      if not error:
+        error = closeHandle(f.mapHandle) == 0
+        if not error and f.fHandle != INVALID_HANDLE_VALUE:
+          discard closeHandle(f.fHandle)
+          f.fHandle = INVALID_HANDLE_VALUE
+      if error:
+        lastErr = osLastError()
+  else:
+    error = munmap(f.mem, f.size) != 0
+    lastErr = osLastError()
+    if f.handle != -1:
+      error = (close(f.handle) != 0) or error
+
+  f.size = 0
+  f.mem = nil
+
+  when defined(windows):
+    f.fHandle = 0
+    f.mapHandle = 0
+    f.wasOpened = false
+  else:
+    f.handle = -1
+
+  if error: raiseOSError(lastErr)
+
+type MemSlice* = object ## represent slice of a MemFile for iteration over delimited lines/records
+  data*: pointer
+  size*: int
+
+proc `==`*(x, y: MemSlice): bool =
+  ## Compare a pair of MemSlice for strict equality.
+  result = (x.size == y.size and equalMem(x.data, y.data, x.size))
+
+proc `$`*(ms: MemSlice): string {.inline.} =
+  ## Return a Nim string built from a MemSlice.
+  result.setLen(ms.size)
+  copyMem(result.cstring, ms.data, ms.size)
+
+iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline.} =
+  ## Iterates over \[optional `eat`] `delim`-delimited slices in MemFile `mfile`.
+  ##
+  ## Default parameters parse lines ending in either Unix(\\l) or Windows(\\r\\l)
+  ## style on on a line-by-line basis.  I.e., not every line needs the same ending.
+  ## Unlike readLine(File) & lines(File), archaic MacOS9 \\r-delimited lines
+  ## are not supported as a third option for each line.  Such archaic MacOS9
+  ## files can be handled by passing delim='\\r', eat='\\0', though.
+  ##
+  ## Delimiters are not part of the returned slice.  A final, unterminated line
+  ## or record is returned just like any other.
+  ##
+  ## Non-default delimiters can be passed to allow iteration over other sorts
+  ## of "line-like" variable length records.  Pass eat='\\0' to be strictly
+  ## `delim`-delimited. (Eating an optional prefix equal to '\\0' is not
+  ## supported.)
+  ##
+  ## This zero copy, memchr-limited interface is probably the fastest way to
+  ## iterate over line-like records in a file.  However, returned (data,size)
+  ## objects are not Nim strings, bounds checked Nim arrays, or even terminated
+  ## C strings.  So, care is required to access the data (e.g., think C mem*
+  ## functions, not str* functions).
+  ##
+  ## Example:
+  ##   ```nim
+  ##   var count = 0
+  ##   for slice in memSlices(memfiles.open("foo")):
+  ##     if slice.size > 0 and cast[cstring](slice.data)[0] != '#':
+  ##       inc(count)
+  ##   echo count
+  ##   ```
+
+  proc c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
+       importc: "memchr", header: "<string.h>".}
+  proc `-!`(p, q: pointer): int {.inline.} = return cast[int](p) -% cast[int](q)
+  var ms: MemSlice
+  var ending: pointer
+  ms.data = mfile.mem
+  var remaining = mfile.size
+  while remaining > 0:
+    ending = c_memchr(ms.data, delim, csize_t(remaining))
+    if ending == nil: # unterminated final slice
+      ms.size = remaining # Weird case..check eat?
+      yield ms
+      break
+    ms.size = ending -! ms.data # delim is NOT included
+    if eat != '\0' and ms.size > 0 and cast[cstring](ms.data)[ms.size - 1] == eat:
+      dec(ms.size) # trim pre-delim char
+    yield ms
+    ms.data = cast[pointer](cast[int](ending) +% 1) # skip delim
+    remaining = mfile.size - (ms.data -! mfile.mem)
+
+iterator lines*(mfile: MemFile, buf: var string, delim = '\l',
+    eat = '\r'): string {.inline.} =
+  ## Replace contents of passed buffer with each new line, like
+  ## `readLine(File) <syncio.html#readLine,File,string>`_.
+  ## `delim`, `eat`, and delimiting logic is exactly as for `memSlices
+  ## <#memSlices.i,MemFile,char,char>`_, but Nim strings are returned.
+  ##
+  ## Example:
+  ##   ```nim
+  ##   var buffer: string = ""
+  ##   for line in lines(memfiles.open("foo"), buffer):
+  ##     echo line
+  ##   ```
+
+  for ms in memSlices(mfile, delim, eat):
+    setLen(buf, ms.size)
+    if ms.size > 0:
+      copyMem(addr buf[0], ms.data, ms.size)
+    yield buf
+
+iterator lines*(mfile: MemFile, delim = '\l', eat = '\r'): string {.inline.} =
+  ## Return each line in a file as a Nim string, like
+  ## `lines(File) <syncio.html#lines.i,File>`_.
+  ## `delim`, `eat`, and delimiting logic is exactly as for `memSlices
+  ## <#memSlices.i,MemFile,char,char>`_, but Nim strings are returned.
+  ##
+  ## Example:
+  ##   ```nim
+  ##   for line in lines(memfiles.open("foo")):
+  ##     echo line
+  ##   ```
+
+  var buf = newStringOfCap(80)
+  for line in lines(mfile, buf, delim, eat):
+    yield buf
+
+type
+  MemMapFileStream* = ref MemMapFileStreamObj ## a stream that encapsulates a `MemFile`
+  MemMapFileStreamObj* = object of Stream
+    mf: MemFile
+    mode: FileMode
+    pos: ByteAddress
+
+proc mmsClose(s: Stream) =
+  MemMapFileStream(s).pos = -1
+  close(MemMapFileStream(s).mf)
+
+proc mmsFlush(s: Stream) = flush(MemMapFileStream(s).mf)
+
+proc mmsAtEnd(s: Stream): bool = (MemMapFileStream(s).pos >= MemMapFileStream(s).mf.size) or
+                                  (MemMapFileStream(s).pos < 0)
+
+proc mmsSetPosition(s: Stream, pos: int) =
+  if pos > MemMapFileStream(s).mf.size or pos < 0:
+    raise newEIO("cannot set pos in stream")
+  MemMapFileStream(s).pos = pos
+
+proc mmsGetPosition(s: Stream): int = MemMapFileStream(s).pos
+
+proc mmsPeekData(s: Stream, buffer: pointer, bufLen: int): int =
+  let startAddress = cast[int](MemMapFileStream(s).mf.mem)
+  let p = cast[int](MemMapFileStream(s).pos)
+  let l = min(bufLen, MemMapFileStream(s).mf.size - p)
+  moveMem(buffer, cast[pointer](startAddress + p), l)
+  result = l
+
+proc mmsReadData(s: Stream, buffer: pointer, bufLen: int): int =
+  result = mmsPeekData(s, buffer, bufLen)
+  inc(MemMapFileStream(s).pos, result)
+
+proc mmsWriteData(s: Stream, buffer: pointer, bufLen: int) =
+  if MemMapFileStream(s).mode == fmRead:
+    raise newEIO("cannot write to read-only stream")
+  let size = MemMapFileStream(s).mf.size
+  if MemMapFileStream(s).pos + bufLen > size:
+    raise newEIO("cannot write to stream")
+  let p = cast[int](MemMapFileStream(s).mf.mem) +
+          cast[int](MemMapFileStream(s).pos)
+  moveMem(cast[pointer](p), buffer, bufLen)
+  inc(MemMapFileStream(s).pos, bufLen)
+
+proc newMemMapFileStream*(filename: string, mode: FileMode = fmRead,
+    fileSize: int = -1): MemMapFileStream =
+  ## creates a new stream from the file named `filename` with the mode `mode`.
+  ## Raises ## `OSError` if the file cannot be opened. See the `system
+  ## <system.html>`_ module for a list of available FileMode enums.
+  ## `fileSize` can only be set if the file does not exist and is opened
+  ## with write access (e.g., with fmReadWrite).
+  var mf: MemFile = open(filename, mode, newFileSize = fileSize)
+  new(result)
+  result.mode = mode
+  result.mf = mf
+  result.closeImpl = mmsClose
+  result.atEndImpl = mmsAtEnd
+  result.setPositionImpl = mmsSetPosition
+  result.getPositionImpl = mmsGetPosition
+  result.readDataImpl = mmsReadData
+  result.peekDataImpl = mmsPeekData
+  result.writeDataImpl = mmsWriteData
+  result.flushImpl = mmsFlush
diff --git a/lib/pure/mimetypes.nim b/lib/pure/mimetypes.nim
new file mode 100644
index 000000000..ff639e8e5
--- /dev/null
+++ b/lib/pure/mimetypes.nim
@@ -0,0 +1,1071 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a mimetypes database
+
+runnableExamples:
+  var m = newMimetypes()
+  doAssert m.getMimetype("mp4") == "video/mp4"
+  doAssert m.getExt("text/html") == "html"
+  ## Values can be uppercase too.
+  doAssert m.getMimetype("MP4") == "video/mp4"
+  doAssert m.getExt("TEXT/HTML") == "html"
+  ## If values are invalid then `default` is returned.
+  doAssert m.getMimetype("INVALID") == "text/plain"
+  doAssert m.getExt("INVALID/NONEXISTENT") == "txt"
+  doAssert m.getMimetype("") == "text/plain"
+  doAssert m.getExt("") == "txt"
+  ## Register new Mimetypes.
+  m.register(ext = "fakext", mimetype = "text/fakelang")
+  doAssert m.getMimetype("fakext") == "text/fakelang"
+  doAssert m.getMimetype("FaKeXT") == "text/fakelang"
+
+import std/tables
+from std/strutils import startsWith, toLowerAscii, strip
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  MimeDB* = object
+    mimes: OrderedTable[string, string]
+
+const mimes* = {
+  "ez": "application/andrew-inset",
+  "aw": "application/applixware",
+  "atom": "application/atom+xml",
+  "atomcat": "application/atomcat+xml",
+  "atomsvc": "application/atomsvc+xml",
+  "ccxml": "application/ccxml+xml",
+  "cdmia": "application/cdmi-capability",
+  "cdmic": "application/cdmi-container",
+  "cdmid": "application/cdmi-domain",
+  "cdmio": "application/cdmi-object",
+  "cdmiq": "application/cdmi-queue",
+  "cu": "application/cu-seeme",
+  "davmount": "application/davmount+xml",
+  "dbk": "application/docbook+xml",
+  "dssc": "application/dssc+der",
+  "xdssc": "application/dssc+xml",
+  "ecma": "application/ecmascript",
+  "emma": "application/emma+xml",
+  "epub": "application/epub+zip",
+  "exi": "application/exi",
+  "pfr": "application/font-tdpfr",
+  "gml": "application/gml+xml",
+  "gpx": "application/gpx+xml",
+  "gxf": "application/gxf",
+  "stk": "application/hyperstudio",
+  "ink": "application/inkml+xml",
+  "inkml": "application/inkml+xml",
+  "ipfix": "application/ipfix",
+  "jar": "application/java-archive",
+  "ser": "application/java-serialized-object",
+  "class": "application/java-vm",
+  "json": "application/json",
+  "jsonml": "application/jsonml+json",
+  "lostxml": "application/lost+xml",
+  "hqx": "application/mac-binhex40",
+  "cpt": "application/mac-compactpro",
+  "mads": "application/mads+xml",
+  "mrc": "application/marc",
+  "mrcx": "application/marcxml+xml",
+  "ma": "application/mathematica",
+  "nb": "application/mathematica",
+  "mb": "application/mathematica",
+  "mathml": "application/mathml+xml",
+  "mbox": "application/mbox",
+  "mscml": "application/mediaservercontrol+xml",
+  "metalink": "application/metalink+xml",
+  "meta4": "application/metalink4+xml",
+  "mets": "application/mets+xml",
+  "mods": "application/mods+xml",
+  "m21": "application/mp21",
+  "mp21": "application/mp21",
+  "mp4s": "application/mp4",
+  "doc": "application/msword",
+  "dot": "application/msword",
+  "mxf": "application/mxf",
+  "bin": "application/octet-stream",
+  "dms": "application/octet-stream",
+  "lrf": "application/octet-stream",
+  "mar": "application/octet-stream",
+  "so": "application/octet-stream",
+  "dist": "application/octet-stream",
+  "distz": "application/octet-stream",
+  "pkg": "application/octet-stream",
+  "bpk": "application/octet-stream",
+  "dump": "application/octet-stream",
+  "elc": "application/octet-stream",
+  "deploy": "application/octet-stream",
+  "oda": "application/oda",
+  "opf": "application/oebps-package+xml",
+  "ogx": "application/ogg",
+  "omdoc": "application/omdoc+xml",
+  "onetoc": "application/onenote",
+  "onetoc2": "application/onenote",
+  "onetmp": "application/onenote",
+  "onepkg": "application/onenote",
+  "oxps": "application/oxps",
+  "xer": "application/patch-ops-error+xml",
+  "pdf": "application/pdf",
+  "pgp": "application/pgp-encrypted",
+  "asc": "application/pgp-signature",
+  "sig": "application/pgp-signature",
+  "prf": "application/pics-rules",
+  "p10": "application/pkcs10",
+  "p7m": "application/pkcs7-mime",
+  "p7c": "application/pkcs7-mime",
+  "p7s": "application/pkcs7-signature",
+  "p8": "application/pkcs8",
+  "ac": "application/pkix-attr-cert",
+  "cer": "application/pkix-cert",
+  "crl": "application/pkix-crl",
+  "pkipath": "application/pkix-pkipath",
+  "pki": "application/pkixcmp",
+  "pls": "application/pls+xml",
+  "ai": "application/postscript",
+  "eps": "application/postscript",
+  "ps": "application/postscript",
+  "cww": "application/prs.cww",
+  "pskcxml": "application/pskc+xml",
+  "rdf": "application/rdf+xml",
+  "rif": "application/reginfo+xml",
+  "rnc": "application/relax-ng-compact-syntax",
+  "rl": "application/resource-lists+xml",
+  "rld": "application/resource-lists-diff+xml",
+  "rs": "application/rls-services+xml",
+  "gbr": "application/rpki-ghostbusters",
+  "mft": "application/rpki-manifest",
+  "roa": "application/rpki-roa",
+  "rsd": "application/rsd+xml",
+  "rss": "application/rss+xml",
+  "rtf": "application/rtf",
+  "sbml": "application/sbml+xml",
+  "scq": "application/scvp-cv-request",
+  "scs": "application/scvp-cv-response",
+  "spq": "application/scvp-vp-request",
+  "spp": "application/scvp-vp-response",
+  "sdp": "application/sdp",
+  "setpay": "application/set-payment-initiation",
+  "setreg": "application/set-registration-initiation",
+  "shf": "application/shf+xml",
+  "smi": "application/smil+xml",
+  "smil": "application/smil+xml",
+  "rq": "application/sparql-query",
+  "srx": "application/sparql-results+xml",
+  "gram": "application/srgs",
+  "grxml": "application/srgs+xml",
+  "sru": "application/sru+xml",
+  "ssdl": "application/ssdl+xml",
+  "ssml": "application/ssml+xml",
+  "tei": "application/tei+xml",
+  "teicorpus": "application/tei+xml",
+  "tfi": "application/thraud+xml",
+  "tsd": "application/timestamped-data",
+  "plb": "application/vnd.3gpp.pic-bw-large",
+  "psb": "application/vnd.3gpp.pic-bw-small",
+  "pvb": "application/vnd.3gpp.pic-bw-var",
+  "tcap": "application/vnd.3gpp2.tcap",
+  "pwn": "application/vnd.3m.post-it-notes",
+  "aso": "application/vnd.accpac.simply.aso",
+  "imp": "application/vnd.accpac.simply.imp",
+  "acu": "application/vnd.acucobol",
+  "atc": "application/vnd.acucorp",
+  "acutc": "application/vnd.acucorp",
+  "air": "application/vnd.adobe.air-application-installer-package+zip",
+  "fcdt": "application/vnd.adobe.formscentral.fcdt",
+  "fxp": "application/vnd.adobe.fxp",
+  "fxpl": "application/vnd.adobe.fxp",
+  "xdp": "application/vnd.adobe.xdp+xml",
+  "xfdf": "application/vnd.adobe.xfdf",
+  "ahead": "application/vnd.ahead.space",
+  "azf": "application/vnd.airzip.filesecure.azf",
+  "azs": "application/vnd.airzip.filesecure.azs",
+  "azw": "application/vnd.amazon.ebook",
+  "acc": "application/vnd.americandynamics.acc",
+  "ami": "application/vnd.amiga.ami",
+  "apk": "application/vnd.android.package-archive",
+  "cii": "application/vnd.anser-web-certificate-issue-initiation",
+  "fti": "application/vnd.anser-web-funds-transfer-initiation",
+  "atx": "application/vnd.antix.game-component",
+  "mpkg": "application/vnd.apple.installer+xml",
+  "m3u8": "application/vnd.apple.mpegurl",
+  "swi": "application/vnd.aristanetworks.swi",
+  "iota": "application/vnd.astraea-software.iota",
+  "aep": "application/vnd.audiograph",
+  "mpm": "application/vnd.blueice.multipass",
+  "bmi": "application/vnd.bmi",
+  "rep": "application/vnd.businessobjects",
+  "cdxml": "application/vnd.chemdraw+xml",
+  "mmd": "application/vnd.chipnuts.karaoke-mmd",
+  "cdy": "application/vnd.cinderella",
+  "cla": "application/vnd.claymore",
+  "rp9": "application/vnd.cloanto.rp9",
+  "c4g": "application/vnd.clonk.c4group",
+  "c4d": "application/vnd.clonk.c4group",
+  "c4f": "application/vnd.clonk.c4group",
+  "c4p": "application/vnd.clonk.c4group",
+  "c4u": "application/vnd.clonk.c4group",
+  "c11amc": "application/vnd.cluetrust.cartomobile-config",
+  "c11amz": "application/vnd.cluetrust.cartomobile-config-pkg",
+  "csp": "application/vnd.commonspace",
+  "cdbcmsg": "application/vnd.contact.cmsg",
+  "cmc": "application/vnd.cosmocaller",
+  "clkx": "application/vnd.crick.clicker",
+  "clkk": "application/vnd.crick.clicker.keyboard",
+  "clkp": "application/vnd.crick.clicker.palette",
+  "clkt": "application/vnd.crick.clicker.template",
+  "clkw": "application/vnd.crick.clicker.wordbank",
+  "wbs": "application/vnd.criticaltools.wbs+xml",
+  "pml": "application/vnd.ctc-posml",
+  "ppd": "application/vnd.cups-ppd",
+  "car": "application/vnd.curl.car",
+  "pcurl": "application/vnd.curl.pcurl",
+  "dart": "application/vnd.dart",
+  "rdz": "application/vnd.data-vision.rdz",
+  "uvf": "application/vnd.dece.data",
+  "uvvf": "application/vnd.dece.data",
+  "uvd": "application/vnd.dece.data",
+  "uvvd": "application/vnd.dece.data",
+  "uvt": "application/vnd.dece.ttml+xml",
+  "uvvt": "application/vnd.dece.ttml+xml",
+  "uvx": "application/vnd.dece.unspecified",
+  "uvvx": "application/vnd.dece.unspecified",
+  "uvz": "application/vnd.dece.zip",
+  "uvvz": "application/vnd.dece.zip",
+  "fe_launch": "application/vnd.denovo.fcselayout-link",
+  "dna": "application/vnd.dna",
+  "mlp": "application/vnd.dolby.mlp",
+  "dpg": "application/vnd.dpgraph",
+  "dfac": "application/vnd.dreamfactory",
+  "kpxx": "application/vnd.ds-keypoint",
+  "ait": "application/vnd.dvb.ait",
+  "svc": "application/vnd.dvb.service",
+  "geo": "application/vnd.dynageo",
+  "mag": "application/vnd.ecowin.chart",
+  "nml": "application/vnd.enliven",
+  "esf": "application/vnd.epson.esf",
+  "msf": "application/vnd.epson.msf",
+  "qam": "application/vnd.epson.quickanime",
+  "slt": "application/vnd.epson.salt",
+  "ssf": "application/vnd.epson.ssf",
+  "es3": "application/vnd.eszigno3+xml",
+  "et3": "application/vnd.eszigno3+xml",
+  "ez2": "application/vnd.ezpix-album",
+  "ez3": "application/vnd.ezpix-package",
+  "fdf": "application/vnd.fdf",
+  "mseed": "application/vnd.fdsn.mseed",
+  "seed": "application/vnd.fdsn.seed",
+  "dataless": "application/vnd.fdsn.seed",
+  "gph": "application/vnd.flographit",
+  "ftc": "application/vnd.fluxtime.clip",
+  "fm": "application/vnd.framemaker",
+  "frame": "application/vnd.framemaker",
+  "maker": "application/vnd.framemaker",
+  "book": "application/vnd.framemaker",
+  "fnc": "application/vnd.frogans.fnc",
+  "ltf": "application/vnd.frogans.ltf",
+  "fsc": "application/vnd.fsc.weblaunch",
+  "oas": "application/vnd.fujitsu.oasys",
+  "oa2": "application/vnd.fujitsu.oasys2",
+  "oa3": "application/vnd.fujitsu.oasys3",
+  "fg5": "application/vnd.fujitsu.oasysgp",
+  "bh2": "application/vnd.fujitsu.oasysprs",
+  "ddd": "application/vnd.fujixerox.ddd",
+  "xdw": "application/vnd.fujixerox.docuworks",
+  "xbd": "application/vnd.fujixerox.docuworks.binder",
+  "fzs": "application/vnd.fuzzysheet",
+  "txd": "application/vnd.genomatix.tuxedo",
+  "ggb": "application/vnd.geogebra.file",
+  "ggs": "application/vnd.geogebra.slides",
+  "ggt": "application/vnd.geogebra.tool",
+  "gex": "application/vnd.geometry-explorer",
+  "gre": "application/vnd.geometry-explorer",
+  "gxt": "application/vnd.geonext",
+  "g2w": "application/vnd.geoplan",
+  "g3w": "application/vnd.geospace",
+  "gmx": "application/vnd.gmx",
+  "kml": "application/vnd.google-earth.kml+xml",
+  "kmz": "application/vnd.google-earth.kmz",
+  "gqf": "application/vnd.grafeq",
+  "gqs": "application/vnd.grafeq",
+  "gac": "application/vnd.groove-account",
+  "ghf": "application/vnd.groove-help",
+  "gim": "application/vnd.groove-identity-message",
+  "grv": "application/vnd.groove-injector",
+  "gtm": "application/vnd.groove-tool-message",
+  "tpl": "application/vnd.groove-tool-template",
+  "vcg": "application/vnd.groove-vcard",
+  "hal": "application/vnd.hal+xml",
+  "zmm": "application/vnd.handheld-entertainment+xml",
+  "hbci": "application/vnd.hbci",
+  "les": "application/vnd.hhe.lesson-player",
+  "hpgl": "application/vnd.hp-hpgl",
+  "hpid": "application/vnd.hp-hpid",
+  "hps": "application/vnd.hp-hps",
+  "jlt": "application/vnd.hp-jlyt",
+  "pcl": "application/vnd.hp-pcl",
+  "pclxl": "application/vnd.hp-pclxl",
+  "sfd-hdstx": "application/vnd.hydrostatix.sof-data",
+  "mpy": "application/vnd.ibm.minipay",
+  "afp": "application/vnd.ibm.modcap",
+  "listafp": "application/vnd.ibm.modcap",
+  "list3820": "application/vnd.ibm.modcap",
+  "irm": "application/vnd.ibm.rights-management",
+  "sc": "application/vnd.ibm.secure-container",
+  "icc": "application/vnd.iccprofile",
+  "icm": "application/vnd.iccprofile",
+  "igl": "application/vnd.igloader",
+  "ivp": "application/vnd.immervision-ivp",
+  "ivu": "application/vnd.immervision-ivu",
+  "igm": "application/vnd.insors.igm",
+  "xpw": "application/vnd.intercon.formnet",
+  "xpx": "application/vnd.intercon.formnet",
+  "i2g": "application/vnd.intergeo",
+  "qbo": "application/vnd.intu.qbo",
+  "qfx": "application/vnd.intu.qfx",
+  "rcprofile": "application/vnd.ipunplugged.rcprofile",
+  "irp": "application/vnd.irepository.package+xml",
+  "xpr": "application/vnd.is-xpr",
+  "fcs": "application/vnd.isac.fcs",
+  "jam": "application/vnd.jam",
+  "rms": "application/vnd.jcp.javame.midlet-rms",
+  "jisp": "application/vnd.jisp",
+  "joda": "application/vnd.joost.joda-archive",
+  "ktz": "application/vnd.kahootz",
+  "ktr": "application/vnd.kahootz",
+  "karbon": "application/vnd.kde.karbon",
+  "chrt": "application/vnd.kde.kchart",
+  "kfo": "application/vnd.kde.kformula",
+  "flw": "application/vnd.kde.kivio",
+  "kon": "application/vnd.kde.kontour",
+  "kpr": "application/vnd.kde.kpresenter",
+  "kpt": "application/vnd.kde.kpresenter",
+  "ksp": "application/vnd.kde.kspread",
+  "kwd": "application/vnd.kde.kword",
+  "kwt": "application/vnd.kde.kword",
+  "htke": "application/vnd.kenameaapp",
+  "kia": "application/vnd.kidspiration",
+  "kne": "application/vnd.kinar",
+  "knp": "application/vnd.kinar",
+  "skp": "application/vnd.koan",
+  "skd": "application/vnd.koan",
+  "skt": "application/vnd.koan",
+  "skm": "application/vnd.koan",
+  "sse": "application/vnd.kodak-descriptor",
+  "lasxml": "application/vnd.las.las+xml",
+  "lbd": "application/vnd.llamagraphics.life-balance.desktop",
+  "lbe": "application/vnd.llamagraphics.life-balance.exchange+xml",
+  "123": "application/vnd.lotus-1-2-3",
+  "apr": "application/vnd.lotus-approach",
+  "pre": "application/vnd.lotus-freelance",
+  "nsf": "application/vnd.lotus-notes",
+  "org": "application/vnd.lotus-organizer",
+  "scm": "application/vnd.lotus-screencam",
+  "lwp": "application/vnd.lotus-wordpro",
+  "portpkg": "application/vnd.macports.portpkg",
+  "mcd": "application/vnd.mcd",
+  "mc1": "application/vnd.medcalcdata",
+  "cdkey": "application/vnd.mediastation.cdkey",
+  "mwf": "application/vnd.mfer",
+  "mfm": "application/vnd.mfmp",
+  "flo": "application/vnd.micrografx.flo",
+  "igx": "application/vnd.micrografx.igx",
+  "mif": "application/vnd.mif",
+  "daf": "application/vnd.mobius.daf",
+  "dis": "application/vnd.mobius.dis",
+  "mbk": "application/vnd.mobius.mbk",
+  "mqy": "application/vnd.mobius.mqy",
+  "msl": "application/vnd.mobius.msl",
+  "plc": "application/vnd.mobius.plc",
+  "txf": "application/vnd.mobius.txf",
+  "mpn": "application/vnd.mophun.application",
+  "mpc": "application/vnd.mophun.certificate",
+  "xul": "application/vnd.mozilla.xul+xml",
+  "cil": "application/vnd.ms-artgalry",
+  "cab": "application/vnd.ms-cab-compressed",
+  "xls": "application/vnd.ms-excel",
+  "xlm": "application/vnd.ms-excel",
+  "xla": "application/vnd.ms-excel",
+  "xlc": "application/vnd.ms-excel",
+  "xlt": "application/vnd.ms-excel",
+  "xlw": "application/vnd.ms-excel",
+  "xlam": "application/vnd.ms-excel.addin.macroenabled.12",
+  "xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12",
+  "xlsm": "application/vnd.ms-excel.sheet.macroenabled.12",
+  "xltm": "application/vnd.ms-excel.template.macroenabled.12",
+  "eot": "application/vnd.ms-fontobject",
+  "chm": "application/vnd.ms-htmlhelp",
+  "ims": "application/vnd.ms-ims",
+  "lrm": "application/vnd.ms-lrm",
+  "thmx": "application/vnd.ms-officetheme",
+  "cat": "application/vnd.ms-pki.seccat",
+  "stl": "application/vnd.ms-pki.stl",
+  "ppt": "application/vnd.ms-powerpoint",
+  "pps": "application/vnd.ms-powerpoint",
+  "pot": "application/vnd.ms-powerpoint",
+  "ppam": "application/vnd.ms-powerpoint.addin.macroenabled.12",
+  "pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12",
+  "sldm": "application/vnd.ms-powerpoint.slide.macroenabled.12",
+  "ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
+  "potm": "application/vnd.ms-powerpoint.template.macroenabled.12",
+  "mpp": "application/vnd.ms-project",
+  "mpt": "application/vnd.ms-project",
+  "docm": "application/vnd.ms-word.document.macroenabled.12",
+  "dotm": "application/vnd.ms-word.template.macroenabled.12",
+  "wps": "application/vnd.ms-works",
+  "wks": "application/vnd.ms-works",
+  "wcm": "application/vnd.ms-works",
+  "wdb": "application/vnd.ms-works",
+  "wpl": "application/vnd.ms-wpl",
+  "xps": "application/vnd.ms-xpsdocument",
+  "mseq": "application/vnd.mseq",
+  "mus": "application/vnd.musician",
+  "msty": "application/vnd.muvee.style",
+  "taglet": "application/vnd.mynfc",
+  "nlu": "application/vnd.neurolanguage.nlu",
+  "nim": "text/nim",
+  "nimble": "text/nimble",
+  "nimf": "text/nim",
+  "nims": "text/nim",
+  "ntf": "application/vnd.nitf",
+  "nitf": "application/vnd.nitf",
+  "nnd": "application/vnd.noblenet-directory",
+  "nns": "application/vnd.noblenet-sealer",
+  "nnw": "application/vnd.noblenet-web",
+  "ngdat": "application/vnd.nokia.n-gage.data",
+  "n-gage": "application/vnd.nokia.n-gage.symbian.install",
+  "rpst": "application/vnd.nokia.radio-preset",
+  "rpss": "application/vnd.nokia.radio-presets",
+  "edm": "application/vnd.novadigm.edm",
+  "edx": "application/vnd.novadigm.edx",
+  "ext": "application/vnd.novadigm.ext",
+  "odc": "application/vnd.oasis.opendocument.chart",
+  "otc": "application/vnd.oasis.opendocument.chart-template",
+  "odb": "application/vnd.oasis.opendocument.database",
+  "odf": "application/vnd.oasis.opendocument.formula",
+  "odft": "application/vnd.oasis.opendocument.formula-template",
+  "odg": "application/vnd.oasis.opendocument.graphics",
+  "otg": "application/vnd.oasis.opendocument.graphics-template",
+  "odi": "application/vnd.oasis.opendocument.image",
+  "oti": "application/vnd.oasis.opendocument.image-template",
+  "odp": "application/vnd.oasis.opendocument.presentation",
+  "otp": "application/vnd.oasis.opendocument.presentation-template",
+  "ods": "application/vnd.oasis.opendocument.spreadsheet",
+  "ots": "application/vnd.oasis.opendocument.spreadsheet-template",
+  "odt": "application/vnd.oasis.opendocument.text",
+  "odm": "application/vnd.oasis.opendocument.text-master",
+  "ott": "application/vnd.oasis.opendocument.text-template",
+  "oth": "application/vnd.oasis.opendocument.text-web",
+  "xo": "application/vnd.olpc-sugar",
+  "dd2": "application/vnd.oma.dd2+xml",
+  "oxt": "application/vnd.openofficeorg.extension",
+  "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
+  "sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide",
+  "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
+  "potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
+  "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+  "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
+  "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+  "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
+  "mgp": "application/vnd.osgeo.mapguide.package",
+  "dp": "application/vnd.osgi.dp",
+  "esa": "application/vnd.osgi.subsystem",
+  "pdb": "application/vnd.palm",
+  "pqa": "application/vnd.palm",
+  "oprc": "application/vnd.palm",
+  "paw": "application/vnd.pawaafile",
+  "str": "application/vnd.pg.format",
+  "ei6": "application/vnd.pg.osasli",
+  "efif": "application/vnd.picsel",
+  "wg": "application/vnd.pmi.widget",
+  "plf": "application/vnd.pocketlearn",
+  "pbd": "application/vnd.powerbuilder6",
+  "box": "application/vnd.previewsystems.box",
+  "mgz": "application/vnd.proteus.magazine",
+  "qps": "application/vnd.publishare-delta-tree",
+  "ptid": "application/vnd.pvi.ptid1",
+  "qxd": "application/vnd.quark.quarkxpress",
+  "qxt": "application/vnd.quark.quarkxpress",
+  "qwd": "application/vnd.quark.quarkxpress",
+  "qwt": "application/vnd.quark.quarkxpress",
+  "qxl": "application/vnd.quark.quarkxpress",
+  "qxb": "application/vnd.quark.quarkxpress",
+  "bed": "application/vnd.realvnc.bed",
+  "mxl": "application/vnd.recordare.musicxml",
+  "musicxml": "application/vnd.recordare.musicxml+xml",
+  "cryptonote": "application/vnd.rig.cryptonote",
+  "cod": "application/vnd.rim.cod",
+  "rm": "application/vnd.rn-realmedia",
+  "rmvb": "application/vnd.rn-realmedia-vbr",
+  "link66": "application/vnd.route66.link66+xml",
+  "st": "application/vnd.sailingtracker.track",
+  "see": "application/vnd.seemail",
+  "sema": "application/vnd.sema",
+  "semd": "application/vnd.semd",
+  "semf": "application/vnd.semf",
+  "ifm": "application/vnd.shana.informed.formdata",
+  "itp": "application/vnd.shana.informed.formtemplate",
+  "iif": "application/vnd.shana.informed.interchange",
+  "ipk": "application/vnd.shana.informed.package",
+  "twd": "application/vnd.simtech-mindmapper",
+  "twds": "application/vnd.simtech-mindmapper",
+  "mmf": "application/vnd.smaf",
+  "teacher": "application/vnd.smart.teacher",
+  "sdkm": "application/vnd.solent.sdkm+xml",
+  "sdkd": "application/vnd.solent.sdkm+xml",
+  "dxp": "application/vnd.spotfire.dxp",
+  "sfs": "application/vnd.spotfire.sfs",
+  "sdc": "application/vnd.stardivision.calc",
+  "sda": "application/vnd.stardivision.draw",
+  "sdd": "application/vnd.stardivision.impress",
+  "smf": "application/vnd.stardivision.math",
+  "sdw": "application/vnd.stardivision.writer",
+  "vor": "application/vnd.stardivision.writer",
+  "sgl": "application/vnd.stardivision.writer-global",
+  "smzip": "application/vnd.stepmania.package",
+  "sm": "application/vnd.stepmania.stepchart",
+  "sxc": "application/vnd.sun.xml.calc",
+  "stc": "application/vnd.sun.xml.calc.template",
+  "sxd": "application/vnd.sun.xml.draw",
+  "std": "application/vnd.sun.xml.draw.template",
+  "sxi": "application/vnd.sun.xml.impress",
+  "sti": "application/vnd.sun.xml.impress.template",
+  "sxm": "application/vnd.sun.xml.math",
+  "sxw": "application/vnd.sun.xml.writer",
+  "sxg": "application/vnd.sun.xml.writer.global",
+  "stw": "application/vnd.sun.xml.writer.template",
+  "sus": "application/vnd.sus-calendar",
+  "susp": "application/vnd.sus-calendar",
+  "svd": "application/vnd.svd",
+  "sis": "application/vnd.symbian.install",
+  "sisx": "application/vnd.symbian.install",
+  "xsm": "application/vnd.syncml+xml",
+  "bdm": "application/vnd.syncml.dm+wbxml",
+  "xdm": "application/vnd.syncml.dm+xml",
+  "tao": "application/vnd.tao.intent-module-archive",
+  "pcap": "application/vnd.tcpdump.pcap",
+  "cap": "application/vnd.tcpdump.pcap",
+  "dmp": "application/vnd.tcpdump.pcap",
+  "tmo": "application/vnd.tmobile-livetv",
+  "tpt": "application/vnd.trid.tpt",
+  "mxs": "application/vnd.triscape.mxs",
+  "tra": "application/vnd.trueapp",
+  "ufd": "application/vnd.ufdl",
+  "ufdl": "application/vnd.ufdl",
+  "utz": "application/vnd.uiq.theme",
+  "umj": "application/vnd.umajin",
+  "unityweb": "application/vnd.unity",
+  "uoml": "application/vnd.uoml+xml",
+  "vcx": "application/vnd.vcx",
+  "vsd": "application/vnd.visio",
+  "vst": "application/vnd.visio",
+  "vss": "application/vnd.visio",
+  "vsw": "application/vnd.visio",
+  "vis": "application/vnd.visionary",
+  "vsf": "application/vnd.vsf",
+  "wbxml": "application/vnd.wap.wbxml",
+  "wmlc": "application/vnd.wap.wmlc",
+  "wmlsc": "application/vnd.wap.wmlscriptc",
+  "wtb": "application/vnd.webturbo",
+  "nbp": "application/vnd.wolfram.player",
+  "wpd": "application/vnd.wordperfect",
+  "wqd": "application/vnd.wqd",
+  "stf": "application/vnd.wt.stf",
+  "xar": "application/vnd.xara",
+  "xfdl": "application/vnd.xfdl",
+  "hvd": "application/vnd.yamaha.hv-dic",
+  "hvs": "application/vnd.yamaha.hv-script",
+  "hvp": "application/vnd.yamaha.hv-voice",
+  "osf": "application/vnd.yamaha.openscoreformat",
+  "osfpvg": "application/vnd.yamaha.openscoreformat.osfpvg+xml",
+  "saf": "application/vnd.yamaha.smaf-audio",
+  "spf": "application/vnd.yamaha.smaf-phrase",
+  "cmp": "application/vnd.yellowriver-custom-menu",
+  "zir": "application/vnd.zul",
+  "zirz": "application/vnd.zul",
+  "zaz": "application/vnd.zzazz.deck+xml",
+  "vxml": "application/voicexml+xml",
+  "wasm": "application/wasm",
+  "wgt": "application/widget",
+  "hlp": "application/winhlp",
+  "wsdl": "application/wsdl+xml",
+  "wspolicy": "application/wspolicy+xml",
+  "7z": "application/x-7z-compressed",
+  "abw": "application/x-abiword",
+  "ace": "application/x-ace-compressed",
+  "dmg": "application/x-apple-diskimage",
+  "aab": "application/x-authorware-bin",
+  "x32": "application/x-authorware-bin",
+  "u32": "application/x-authorware-bin",
+  "vox": "application/x-authorware-bin",
+  "aam": "application/x-authorware-map",
+  "aas": "application/x-authorware-seg",
+  "bcpio": "application/x-bcpio",
+  "torrent": "application/x-bittorrent",
+  "blb": "application/x-blorb",
+  "blorb": "application/x-blorb",
+  "bz": "application/x-bzip",
+  "bz2": "application/x-bzip2",
+  "boz": "application/x-bzip2",
+  "cbr": "application/x-cbr",
+  "cba": "application/x-cbr",
+  "cbt": "application/x-cbr",
+  "cbz": "application/x-cbr",
+  "cb7": "application/x-cbr",
+  "vcd": "application/x-cdlink",
+  "cfs": "application/x-cfs-compressed",
+  "chat": "application/x-chat",
+  "pgn": "application/x-chess-pgn",
+  "nsc": "application/x-conference",
+  "cpio": "application/x-cpio",
+  "csh": "application/x-csh",
+  "deb": "application/x-debian-package",
+  "udeb": "application/x-debian-package",
+  "dgc": "application/x-dgc-compressed",
+  "dir": "application/x-director",
+  "dcr": "application/x-director",
+  "dxr": "application/x-director",
+  "cst": "application/x-director",
+  "cct": "application/x-director",
+  "cxt": "application/x-director",
+  "w3d": "application/x-director",
+  "fgd": "application/x-director",
+  "swa": "application/x-director",
+  "wad": "application/x-doom",
+  "ncx": "application/x-dtbncx+xml",
+  "dtb": "application/x-dtbook+xml",
+  "res": "application/x-dtbresource+xml",
+  "dvi": "application/x-dvi",
+  "evy": "application/x-envoy",
+  "eva": "application/x-eva",
+  "bdf": "application/x-font-bdf",
+  "gsf": "application/x-font-ghostscript",
+  "psf": "application/x-font-linux-psf",
+  "pcf": "application/x-font-pcf",
+  "snf": "application/x-font-snf",
+  "pfa": "application/x-font-type1",
+  "pfb": "application/x-font-type1",
+  "pfm": "application/x-font-type1",
+  "afm": "application/x-font-type1",
+  "arc": "application/x-freearc",
+  "spl": "application/x-futuresplash",
+  "gca": "application/x-gca-compressed",
+  "ulx": "application/x-glulx",
+  "gnumeric": "application/x-gnumeric",
+  "gramps": "application/x-gramps-xml",
+  "gtar": "application/x-gtar",
+  "hdf": "application/x-hdf",
+  "install": "application/x-install-instructions",
+  "iso": "application/x-iso9660-image",
+  "jnlp": "application/x-java-jnlp-file",
+  "latex": "application/x-latex",
+  "lzh": "application/x-lzh-compressed",
+  "lha": "application/x-lzh-compressed",
+  "mie": "application/x-mie",
+  "prc": "application/x-mobipocket-ebook",
+  "mobi": "application/x-mobipocket-ebook",
+  "application": "application/x-ms-application",
+  "lnk": "application/x-ms-shortcut",
+  "wmd": "application/x-ms-wmd",
+  "wmz": "application/x-ms-wmz",
+  "xbap": "application/x-ms-xbap",
+  "mdb": "application/x-msaccess",
+  "obd": "application/x-msbinder",
+  "crd": "application/x-mscardfile",
+  "clp": "application/x-msclip",
+  "exe": "application/x-msdownload",
+  "dll": "application/x-msdownload",
+  "com": "application/x-msdownload",
+  "bat": "application/x-msdownload",
+  "msi": "application/x-msdownload",
+  "mvb": "application/x-msmediaview",
+  "m13": "application/x-msmediaview",
+  "m14": "application/x-msmediaview",
+  "wmf": "application/x-msmetafile",
+  "wmz": "application/x-msmetafile",
+  "emf": "application/x-msmetafile",
+  "emz": "application/x-msmetafile",
+  "mny": "application/x-msmoney",
+  "pub": "application/x-mspublisher",
+  "scd": "application/x-msschedule",
+  "trm": "application/x-msterminal",
+  "wri": "application/x-mswrite",
+  "nc": "application/x-netcdf",
+  "cdf": "application/x-netcdf",
+  "nzb": "application/x-nzb",
+  "p12": "application/x-pkcs12",
+  "pfx": "application/x-pkcs12",
+  "p7b": "application/x-pkcs7-certificates",
+  "spc": "application/x-pkcs7-certificates",
+  "p7r": "application/x-pkcs7-certreqresp",
+  "rar": "application/x-rar-compressed",
+  "ris": "application/x-research-info-systems",
+  "sh": "application/x-sh",
+  "shar": "application/x-shar",
+  "swf": "application/x-shockwave-flash",
+  "xap": "application/x-silverlight-app",
+  "sql": "application/x-sql",
+  "sit": "application/x-stuffit",
+  "sitx": "application/x-stuffitx",
+  "srt": "application/x-subrip",
+  "sv4cpio": "application/x-sv4cpio",
+  "sv4crc": "application/x-sv4crc",
+  "t3": "application/x-t3vm-image",
+  "gam": "application/x-tads",
+  "tar": "application/x-tar",
+  "tcl": "application/x-tcl",
+  "tex": "application/x-tex",
+  "tfm": "application/x-tex-tfm",
+  "texinfo": "application/x-texinfo",
+  "texi": "application/x-texinfo",
+  "obj": "application/x-tgif",
+  "ustar": "application/x-ustar",
+  "src": "application/x-wais-source",
+  "der": "application/x-x509-ca-cert",
+  "crt": "application/x-x509-ca-cert",
+  "fig": "application/x-xfig",
+  "xlf": "application/x-xliff+xml",
+  "xpi": "application/x-xpinstall",
+  "xz": "application/x-xz",
+  "z1": "application/x-zmachine",
+  "z2": "application/x-zmachine",
+  "z3": "application/x-zmachine",
+  "z4": "application/x-zmachine",
+  "z5": "application/x-zmachine",
+  "z6": "application/x-zmachine",
+  "z7": "application/x-zmachine",
+  "z8": "application/x-zmachine",
+  "xaml": "application/xaml+xml",
+  "xdf": "application/xcap-diff+xml",
+  "xenc": "application/xenc+xml",
+  "xhtml": "application/xhtml+xml",
+  "xht": "application/xhtml+xml",
+  "xml": "application/xml",
+  "xsl": "application/xml",
+  "dtd": "application/xml-dtd",
+  "xop": "application/xop+xml",
+  "xpl": "application/xproc+xml",
+  "xslt": "application/xslt+xml",
+  "xspf": "application/xspf+xml",
+  "mxml": "application/xv+xml",
+  "xhvml": "application/xv+xml",
+  "xvml": "application/xv+xml",
+  "xvm": "application/xv+xml",
+  "yang": "application/yang",
+  "yin": "application/yin+xml",
+  "zip": "application/zip",
+  "adp": "audio/adpcm",
+  "au": "audio/basic",
+  "snd": "audio/basic",
+  "mid": "audio/midi",
+  "midi": "audio/midi",
+  "kar": "audio/midi",
+  "rmi": "audio/midi",
+  "m4a": "audio/mp4",
+  "mp4a": "audio/mp4",
+  "mpga": "audio/mpeg",
+  "mp2": "audio/mpeg",
+  "mp2a": "audio/mpeg",
+  "mp3": "audio/mpeg",
+  "m2a": "audio/mpeg",
+  "m3a": "audio/mpeg",
+  "oga": "audio/ogg",
+  "ogg": "audio/ogg",
+  "spx": "audio/ogg",
+  "opus": "audio/ogg",
+  "s3m": "audio/s3m",
+  "sil": "audio/silk",
+  "uva": "audio/vnd.dece.audio",
+  "uvva": "audio/vnd.dece.audio",
+  "eol": "audio/vnd.digital-winds",
+  "dra": "audio/vnd.dra",
+  "dts": "audio/vnd.dts",
+  "dtshd": "audio/vnd.dts.hd",
+  "lvp": "audio/vnd.lucent.voice",
+  "pya": "audio/vnd.ms-playready.media.pya",
+  "ecelp4800": "audio/vnd.nuera.ecelp4800",
+  "ecelp7470": "audio/vnd.nuera.ecelp7470",
+  "ecelp9600": "audio/vnd.nuera.ecelp9600",
+  "rip": "audio/vnd.rip",
+  "weba": "audio/webm",
+  "aac": "audio/x-aac",
+  "aif": "audio/x-aiff",
+  "aiff": "audio/x-aiff",
+  "aifc": "audio/x-aiff",
+  "caf": "audio/x-caf",
+  "flac": "audio/x-flac",
+  "mka": "audio/x-matroska",
+  "m3u": "audio/x-mpegurl",
+  "wax": "audio/x-ms-wax",
+  "wma": "audio/x-ms-wma",
+  "ram": "audio/x-pn-realaudio",
+  "ra": "audio/x-pn-realaudio",
+  "rmp": "audio/x-pn-realaudio-plugin",
+  "wav": "audio/x-wav",
+  "xm": "audio/xm",
+  "cdx": "chemical/x-cdx",
+  "cif": "chemical/x-cif",
+  "cmdf": "chemical/x-cmdf",
+  "cml": "chemical/x-cml",
+  "csml": "chemical/x-csml",
+  "xyz": "chemical/x-xyz",
+  "ttc": "font/collection",
+  "otf": "font/otf",
+  "ttf": "font/ttf",
+  "woff": "font/woff",
+  "woff2": "font/woff2",
+  "bmp": "image/bmp",
+  "cgm": "image/cgm",
+  "g3": "image/g3fax",
+  "gif": "image/gif",
+  "ief": "image/ief",
+  "jpeg": "image/jpeg",
+  "jpg": "image/jpeg",
+  "jpe": "image/jpeg",
+  "ktx": "image/ktx",
+  "png": "image/png",
+  "btif": "image/prs.btif",
+  "sgi": "image/sgi",
+  "svg": "image/svg+xml",
+  "svgz": "image/svg+xml",
+  "tiff": "image/tiff",
+  "tif": "image/tiff",
+  "psd": "image/vnd.adobe.photoshop",
+  "uvi": "image/vnd.dece.graphic",
+  "uvvi": "image/vnd.dece.graphic",
+  "uvg": "image/vnd.dece.graphic",
+  "uvvg": "image/vnd.dece.graphic",
+  "djvu": "image/vnd.djvu",
+  "djv": "image/vnd.djvu",
+  "sub": "image/vnd.dvb.subtitle",
+  "dwg": "image/vnd.dwg",
+  "dxf": "image/vnd.dxf",
+  "fbs": "image/vnd.fastbidsheet",
+  "fpx": "image/vnd.fpx",
+  "fst": "image/vnd.fst",
+  "mmr": "image/vnd.fujixerox.edmics-mmr",
+  "rlc": "image/vnd.fujixerox.edmics-rlc",
+  "mdi": "image/vnd.ms-modi",
+  "wdp": "image/vnd.ms-photo",
+  "npx": "image/vnd.net-fpx",
+  "wbmp": "image/vnd.wap.wbmp",
+  "xif": "image/vnd.xiff",
+  "webp": "image/webp",
+  "3ds": "image/x-3ds",
+  "ras": "image/x-cmu-raster",
+  "cmx": "image/x-cmx",
+  "fh": "image/x-freehand",
+  "fhc": "image/x-freehand",
+  "fh4": "image/x-freehand",
+  "fh5": "image/x-freehand",
+  "fh7": "image/x-freehand",
+  "ico": "image/x-icon",
+  "sid": "image/x-mrsid-image",
+  "pcx": "image/x-pcx",
+  "pic": "image/x-pict",
+  "pct": "image/x-pict",
+  "pnm": "image/x-portable-anymap",
+  "pbm": "image/x-portable-bitmap",
+  "pgm": "image/x-portable-graymap",
+  "ppm": "image/x-portable-pixmap",
+  "rgb": "image/x-rgb",
+  "tga": "image/x-tga",
+  "xbm": "image/x-xbitmap",
+  "xpm": "image/x-xpixmap",
+  "xwd": "image/x-xwindowdump",
+  "eml": "message/rfc822",
+  "mime": "message/rfc822",
+  "igs": "model/iges",
+  "iges": "model/iges",
+  "msh": "model/mesh",
+  "mesh": "model/mesh",
+  "silo": "model/mesh",
+  "dae": "model/vnd.collada+xml",
+  "dwf": "model/vnd.dwf",
+  "gdl": "model/vnd.gdl",
+  "gtw": "model/vnd.gtw",
+  "mts": "model/vnd.mts",
+  "vtu": "model/vnd.vtu",
+  "wrl": "model/vrml",
+  "vrml": "model/vrml",
+  "x3db": "model/x3d+binary",
+  "x3dbz": "model/x3d+binary",
+  "x3dv": "model/x3d+vrml",
+  "x3dvz": "model/x3d+vrml",
+  "x3d": "model/x3d+xml",
+  "x3dz": "model/x3d+xml",
+  "appcache": "text/cache-manifest",
+  "ics": "text/calendar",
+  "ifb": "text/calendar",
+  "css": "text/css",
+  "csv": "text/csv",
+  "html": "text/html",
+  "htm": "text/html",
+  "js": "text/javascript",
+  "mjs": "text/javascript",
+  "n3": "text/n3",
+  "txt": "text/plain",
+  "text": "text/plain",
+  "conf": "text/plain",
+  "def": "text/plain",
+  "list": "text/plain",
+  "log": "text/plain",
+  "in": "text/plain",
+  "dsc": "text/prs.lines.tag",
+  "rtx": "text/richtext",
+  "sgml": "text/sgml",
+  "sgm": "text/sgml",
+  "tsv": "text/tab-separated-values",
+  "t": "text/troff",
+  "tr": "text/troff",
+  "roff": "text/troff",
+  "man": "text/troff",
+  "me": "text/troff",
+  "ms": "text/troff",
+  "ttl": "text/turtle",
+  "uri": "text/uri-list",
+  "uris": "text/uri-list",
+  "urls": "text/uri-list",
+  "vcard": "text/vcard",
+  "curl": "text/vnd.curl",
+  "dcurl": "text/vnd.curl.dcurl",
+  "mcurl": "text/vnd.curl.mcurl",
+  "scurl": "text/vnd.curl.scurl",
+  "sub": "text/vnd.dvb.subtitle",
+  "fly": "text/vnd.fly",
+  "flx": "text/vnd.fmi.flexstor",
+  "gv": "text/vnd.graphviz",
+  "3dml": "text/vnd.in3d.3dml",
+  "spot": "text/vnd.in3d.spot",
+  "jad": "text/vnd.sun.j2me.app-descriptor",
+  "wml": "text/vnd.wap.wml",
+  "wmls": "text/vnd.wap.wmlscript",
+  "s": "text/x-asm",
+  "asm": "text/x-asm",
+  "c": "text/x-c",
+  "cc": "text/x-c",
+  "cxx": "text/x-c",
+  "cpp": "text/x-c",
+  "h": "text/x-c",
+  "hh": "text/x-c",
+  "dic": "text/x-c",
+  "f": "text/x-fortran",
+  "for": "text/x-fortran",
+  "f77": "text/x-fortran",
+  "f90": "text/x-fortran",
+  "java": "text/x-java-source",
+  "nfo": "text/x-nfo",
+  "opml": "text/x-opml",
+  "p": "text/x-pascal",
+  "pas": "text/x-pascal",
+  "etx": "text/x-setext",
+  "sfv": "text/x-sfv",
+  "uu": "text/x-uuencode",
+  "vcs": "text/x-vcalendar",
+  "vcf": "text/x-vcard",
+  "3gp": "video/3gpp",
+  "3g2": "video/3gpp2",
+  "h261": "video/h261",
+  "h263": "video/h263",
+  "h264": "video/h264",
+  "jpgv": "video/jpeg",
+  "jpm": "video/jpm",
+  "jpgm": "video/jpm",
+  "mj2": "video/mj2",
+  "mjp2": "video/mj2",
+  "mp4": "video/mp4",
+  "mp4v": "video/mp4",
+  "mpg4": "video/mp4",
+  "mpeg": "video/mpeg",
+  "mpg": "video/mpeg",
+  "mpe": "video/mpeg",
+  "m1v": "video/mpeg",
+  "m2v": "video/mpeg",
+  "ogv": "video/ogg",
+  "qt": "video/quicktime",
+  "mov": "video/quicktime",
+  "uvh": "video/vnd.dece.hd",
+  "uvvh": "video/vnd.dece.hd",
+  "uvm": "video/vnd.dece.mobile",
+  "uvvm": "video/vnd.dece.mobile",
+  "uvp": "video/vnd.dece.pd",
+  "uvvp": "video/vnd.dece.pd",
+  "uvs": "video/vnd.dece.sd",
+  "uvvs": "video/vnd.dece.sd",
+  "uvv": "video/vnd.dece.video",
+  "uvvv": "video/vnd.dece.video",
+  "dvb": "video/vnd.dvb.file",
+  "fvt": "video/vnd.fvt",
+  "mxu": "video/vnd.mpegurl",
+  "m4u": "video/vnd.mpegurl",
+  "pyv": "video/vnd.ms-playready.media.pyv",
+  "uvu": "video/vnd.uvvu.mp4",
+  "uvvu": "video/vnd.uvvu.mp4",
+  "viv": "video/vnd.vivo",
+  "webm": "video/webm",
+  "f4v": "video/x-f4v",
+  "fli": "video/x-fli",
+  "flv": "video/x-flv",
+  "m4v": "video/x-m4v",
+  "mkv": "video/x-matroska",
+  "mk3d": "video/x-matroska",
+  "mks": "video/x-matroska",
+  "mng": "video/x-mng",
+  "asf": "video/x-ms-asf",
+  "asx": "video/x-ms-asf",
+  "vob": "video/x-ms-vob",
+  "wm": "video/x-ms-wm",
+  "wmv": "video/x-ms-wmv",
+  "wmx": "video/x-ms-wmx",
+  "wvx": "video/x-ms-wvx",
+  "avi": "video/x-msvideo",
+  "movie": "video/x-sgi-movie",
+  "smv": "video/x-smv",
+  "ice": "x-conference/x-cooltalk",
+}
+
+
+func newMimetypes*(): MimeDB =
+  ## Creates a new Mimetypes database. The database will contain the most
+  ## common mimetypes.
+  {.cast(noSideEffect).}:
+    result.mimes = mimes.toOrderedTable()
+
+func getMimetype*(mimedb: MimeDB, ext: string, default = "text/plain"): string =
+  ## Gets mimetype which corresponds to `ext`. Returns `default` if `ext`
+  ## could not be found. `ext` can start with an optional dot which is ignored.
+  ## `ext` is lowercased before querying `mimedb`.
+  if ext.startsWith("."):
+    result = mimedb.mimes.getOrDefault(ext.toLowerAscii.substr(1))
+  else:
+    result = mimedb.mimes.getOrDefault(ext.toLowerAscii())
+  if result == "":
+    return default
+
+func getExt*(mimedb: MimeDB, mimetype: string, default = "txt"): string =
+  ## Gets extension which corresponds to `mimetype`. Returns `default` if
+  ## `mimetype` could not be found. Extensions are returned without the
+  ## leading dot. `mimetype` is lowercased before querying `mimedb`.
+  result = default
+  let mimeLowered = mimetype.toLowerAscii()
+  for e, m in mimedb.mimes:
+    if m == mimeLowered:
+      result = e
+      break
+
+func register*(mimedb: var MimeDB, ext: string, mimetype: string) =
+  ## Adds `mimetype` to the `mimedb`.
+  ## `mimetype` and `ext` are lowercased before registering on `mimedb`.
+  assert ext.strip.len > 0, "ext argument can not be empty string"
+  assert mimetype.strip.len > 0, "mimetype argument can not be empty string"
+  {.noSideEffect.}:
+    mimedb.mimes[ext.toLowerAscii()] = mimetype.toLowerAscii()
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim
new file mode 100644
index 000000000..656c98a20
--- /dev/null
+++ b/lib/pure/nativesockets.nim
@@ -0,0 +1,870 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a low-level cross-platform sockets interface. Look
+## at the `net` module for the higher-level version.
+
+# TODO: Clean up the exports a bit and everything else in general.
+
+import std/[os, options]
+import std/private/since
+import std/strbasics
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+when hostOS == "solaris":
+  {.passl: "-lsocket -lnsl".}
+
+const useWinVersion = defined(windows) or defined(nimdoc)
+const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr) or
+    defined(nuttx)
+
+when useWinVersion:
+  import std/winlean
+  export WSAEWOULDBLOCK, WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
+         WSANOTINITIALISED, WSAENOTSOCK, WSAEINPROGRESS, WSAEINTR,
+         WSAEDISCON, ERROR_NETNAME_DELETED
+else:
+  import std/posix
+  export fcntl, F_GETFL, O_NONBLOCK, F_SETFL, EAGAIN, EWOULDBLOCK, MSG_NOSIGNAL,
+    EINTR, EINPROGRESS, ECONNRESET, EPIPE, ENETRESET, EBADF
+  export Sockaddr_storage, Sockaddr_un, Sockaddr_un_path_length
+
+export SocketHandle, Sockaddr_in, Addrinfo, INADDR_ANY, SockAddr, SockLen,
+  Sockaddr_in6, Sockaddr_storage,
+  recv, `==`, connect, send, accept, recvfrom, sendto,
+  freeAddrInfo
+
+when not useNimNetLite:
+  export inet_ntoa
+
+export
+  SO_ERROR,
+  SOL_SOCKET,
+  SOMAXCONN,
+  SO_ACCEPTCONN, SO_BROADCAST, SO_DEBUG, SO_DONTROUTE,
+  SO_KEEPALIVE, SO_OOBINLINE, SO_REUSEADDR, SO_REUSEPORT,
+  MSG_PEEK
+
+when defined(macosx) and not defined(nimdoc):
+  export SO_NOSIGPIPE
+
+type
+  Port* = distinct uint16 ## port type
+
+  Domain* = enum ## \
+    ## domain, which specifies the protocol family of the
+    ## created socket. Other domains than those that are listed
+    ## here are unsupported.
+    AF_UNSPEC = 0, ## unspecified domain (can be detected automatically by
+                   ## some procedures, such as getaddrinfo)
+    AF_UNIX = 1,   ## for local socket (using a file). Unsupported on Windows.
+    AF_INET = 2,   ## for network protocol IPv4 or
+    AF_INET6 = when defined(macosx): 30 elif defined(windows): 23 else: 10 ## for network protocol IPv6.
+
+  SockType* = enum     ## second argument to `socket` proc
+    SOCK_STREAM = 1,   ## reliable stream-oriented service or Stream Sockets
+    SOCK_DGRAM = 2,    ## datagram service or Datagram Sockets
+    SOCK_RAW = 3,      ## raw protocols atop the network layer.
+    SOCK_SEQPACKET = 5 ## reliable sequenced packet service
+
+  Protocol* = enum    ## third argument to `socket` proc
+    IPPROTO_TCP = 6,  ## Transmission control protocol.
+    IPPROTO_UDP = 17, ## User datagram protocol.
+    IPPROTO_IP,       ## Internet protocol.
+    IPPROTO_IPV6,     ## Internet Protocol Version 6.
+    IPPROTO_RAW,      ## Raw IP Packets Protocol. Unsupported on Windows.
+    IPPROTO_ICMP      ## Internet Control message protocol.
+    IPPROTO_ICMPV6    ## Internet Control message protocol for IPv6.
+
+  Servent* = object ## information about a service
+    name*: string
+    aliases*: seq[string]
+    port*: Port
+    proto*: string
+
+  Hostent* = object ## information about a given host
+    name*: string
+    aliases*: seq[string]
+    addrtype*: Domain
+    length*: int
+    addrList*: seq[string]
+
+const IPPROTO_NONE* = IPPROTO_IP ## Use this if your socket type requires a protocol value of zero (e.g. Unix sockets).
+
+when useWinVersion:
+  let
+    osInvalidSocket* = winlean.INVALID_SOCKET
+
+  const
+    IOCPARM_MASK* = 127
+    IOC_IN* = int(-2147483648)
+    FIONBIO* = IOC_IN.int32 or ((sizeof(int32) and IOCPARM_MASK) shl 16) or
+               (102 shl 8) or 126
+    nativeAfInet = winlean.AF_INET
+    nativeAfInet6 = winlean.AF_INET6
+
+  proc ioctlsocket*(s: SocketHandle, cmd: clong,
+                   argptr: ptr clong): cint {.
+                   stdcall, importc: "ioctlsocket", dynlib: "ws2_32.dll".}
+else:
+  let
+    osInvalidSocket* = posix.INVALID_SOCKET
+    nativeAfInet = posix.AF_INET
+    nativeAfInet6 = posix.AF_INET6
+    nativeAfUnix = posix.AF_UNIX
+
+proc `==`*(a, b: Port): bool {.borrow.}
+  ## `==` for ports.
+
+proc `$`*(p: Port): string {.borrow.}
+  ## Returns the port number as a string
+
+proc toInt*(domain: Domain): cint
+  ## Converts the Domain enum to a platform-dependent `cint`.
+
+proc toInt*(typ: SockType): cint
+  ## Converts the SockType enum to a platform-dependent `cint`.
+
+proc toInt*(p: Protocol): cint
+  ## Converts the Protocol enum to a platform-dependent `cint`.
+
+when not useWinVersion:
+  proc toInt(domain: Domain): cint =
+    case domain
+    of AF_UNSPEC: result = posix.AF_UNSPEC.cint
+    of AF_UNIX: result = posix.AF_UNIX.cint
+    of AF_INET: result = posix.AF_INET.cint
+    of AF_INET6: result = posix.AF_INET6.cint
+
+  proc toKnownDomain*(family: cint): Option[Domain] =
+    ## Converts the platform-dependent `cint` to the Domain or none(),
+    ## if the `cint` is not known.
+    result = if family == posix.AF_UNSPEC: some(Domain.AF_UNSPEC)
+             elif family == posix.AF_UNIX: some(Domain.AF_UNIX)
+             elif family == posix.AF_INET: some(Domain.AF_INET)
+             elif family == posix.AF_INET6: some(Domain.AF_INET6)
+             else: none(Domain)
+
+  proc toInt(typ: SockType): cint =
+    case typ
+    of SOCK_STREAM: result = posix.SOCK_STREAM
+    of SOCK_DGRAM: result = posix.SOCK_DGRAM
+    of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
+    of SOCK_RAW: result = posix.SOCK_RAW
+
+  proc toInt(p: Protocol): cint =
+    case p
+    of IPPROTO_TCP: result = posix.IPPROTO_TCP
+    of IPPROTO_UDP: result = posix.IPPROTO_UDP
+    of IPPROTO_IP: result = posix.IPPROTO_IP
+    of IPPROTO_IPV6: result = posix.IPPROTO_IPV6
+    of IPPROTO_RAW: result = posix.IPPROTO_RAW
+    of IPPROTO_ICMP: result = posix.IPPROTO_ICMP
+    of IPPROTO_ICMPV6: result = posix.IPPROTO_ICMPV6
+
+else:
+  proc toInt(domain: Domain): cint =
+    result = cast[cint](uint32(ord(domain)))
+
+  proc toKnownDomain*(family: cint): Option[Domain] =
+    ## Converts the platform-dependent `cint` to the Domain or none(),
+    ## if the `cint` is not known.
+    result = if family == winlean.AF_UNSPEC: some(Domain.AF_UNSPEC)
+             elif family == winlean.AF_INET: some(Domain.AF_INET)
+             elif family == winlean.AF_INET6: some(Domain.AF_INET6)
+             else: none(Domain)
+
+  proc toInt(typ: SockType): cint =
+    result = cint(ord(typ))
+
+  proc toInt(p: Protocol): cint =
+    case p
+    of IPPROTO_IP:
+      result = 0.cint
+    of IPPROTO_ICMP:
+      result = 1.cint
+    of IPPROTO_TCP:
+      result = 6.cint
+    of IPPROTO_UDP:
+      result = 17.cint
+    of IPPROTO_IPV6:
+      result = 41.cint
+    of IPPROTO_ICMPV6:
+      result = 58.cint
+    else:
+      result = cint(ord(p))
+
+proc toSockType*(protocol: Protocol): SockType =
+  result = case protocol
+  of IPPROTO_TCP:
+    SOCK_STREAM
+  of IPPROTO_UDP:
+    SOCK_DGRAM
+  of IPPROTO_IP, IPPROTO_IPV6, IPPROTO_RAW, IPPROTO_ICMP, IPPROTO_ICMPV6:
+    SOCK_RAW
+
+proc getProtoByName*(name: string): int {.since: (1, 3, 5).} =
+  ## Returns a protocol code from the database that matches the protocol `name`.
+  when useWinVersion:
+    let protoent = winlean.getprotobyname(name.cstring)
+  else:
+    let protoent = posix.getprotobyname(name.cstring)
+
+  if protoent == nil:
+    raise newException(OSError, "protocol not found: " & name)
+
+  result = protoent.p_proto.int
+
+proc close*(socket: SocketHandle) =
+  ## Closes a socket.
+  when useWinVersion:
+    discard winlean.closesocket(socket)
+  else:
+    discard posix.close(socket)
+  # TODO: These values should not be discarded. An OSError should be raised.
+  # http://stackoverflow.com/questions/12463473/what-happens-if-you-call-close-on-a-bsd-socket-multiple-times
+
+when declared(setInheritable) or defined(nimdoc):
+  proc setInheritable*(s: SocketHandle, inheritable: bool): bool {.inline.} =
+    ## Set whether a socket is inheritable by child processes. Returns `true`
+    ## on success.
+    ##
+    ## This function is not implemented on all platform, test for availability
+    ## with `declared() <system.html#declared,untyped>`.
+    setInheritable(FileHandle s, inheritable)
+
+proc createNativeSocket*(domain: cint, sockType: cint, protocol: cint,
+                         inheritable: bool = defined(nimInheritHandles)): SocketHandle =
+  ## Creates a new socket; returns `osInvalidSocket` if an error occurs.
+  ##
+  ## `inheritable` decides if the resulting SocketHandle can be inherited
+  ## by child processes.
+  ##
+  ## Use this overload if one of the enums specified above does
+  ## not contain what you need.
+  let sockType =
+    when (defined(linux) or defined(bsd)) and not defined(nimdoc):
+      if inheritable: sockType and not SOCK_CLOEXEC else: sockType or SOCK_CLOEXEC
+    else:
+      sockType
+  result = socket(domain, sockType, protocol)
+  when declared(setInheritable) and not (defined(linux) or defined(bsd)):
+    if not setInheritable(result, inheritable):
+      close result
+      return osInvalidSocket
+
+proc createNativeSocket*(domain: Domain = AF_INET,
+                         sockType: SockType = SOCK_STREAM,
+                         protocol: Protocol = IPPROTO_TCP,
+                         inheritable: bool = defined(nimInheritHandles)): SocketHandle =
+  ## Creates a new socket; returns `osInvalidSocket` if an error occurs.
+  ##
+  ## `inheritable` decides if the resulting SocketHandle can be inherited
+  ## by child processes.
+  createNativeSocket(toInt(domain), toInt(sockType), toInt(protocol), inheritable)
+
+proc bindAddr*(socket: SocketHandle, name: ptr SockAddr,
+    namelen: SockLen): cint =
+  result = bindSocket(socket, name, namelen)
+
+proc listen*(socket: SocketHandle, backlog = SOMAXCONN): cint {.tags: [
+    ReadIOEffect].} =
+  ## Marks `socket` as accepting connections.
+  ## `Backlog` specifies the maximum length of the
+  ## queue of pending connections.
+  when useWinVersion:
+    result = winlean.listen(socket, cint(backlog))
+  else:
+    result = posix.listen(socket, cint(backlog))
+
+proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET,
+                  sockType: SockType = SOCK_STREAM,
+                  protocol: Protocol = IPPROTO_TCP): ptr AddrInfo =
+  ##
+  ##
+  ## .. warning:: The resulting `ptr AddrInfo` must be freed using `freeAddrInfo`!
+  var hints: AddrInfo
+  result = nil
+  hints.ai_family = toInt(domain)
+  hints.ai_socktype = toInt(sockType)
+  hints.ai_protocol = toInt(protocol)
+  # OpenBSD doesn't support AI_V4MAPPED and doesn't define the macro AI_V4MAPPED.
+  # FreeBSD, Haiku don't support AI_V4MAPPED but defines the macro.
+  # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092
+  # https://dev.haiku-os.org/ticket/14323
+  when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and
+      not defined(android) and not defined(haiku):
+    if domain == AF_INET6:
+      hints.ai_flags = AI_V4MAPPED
+  let socketPort = if sockType == SOCK_RAW: "" else: $port
+  var gaiResult = getaddrinfo(address, socketPort.cstring, addr(hints), result)
+  if gaiResult != 0'i32:
+    when useWinVersion or defined(freertos) or defined(nuttx):
+      raiseOSError(osLastError())
+    else:
+      raiseOSError(osLastError(), $gai_strerror(gaiResult))
+
+proc ntohl*(x: uint32): uint32 =
+  ## Converts 32-bit unsigned integers from network to host byte order.
+  ## On machines where the host byte order is the same as network byte order,
+  ## this is a no-op; otherwise, it performs a 4-byte swap operation.
+  when cpuEndian == bigEndian: result = x
+  else: result = (x shr 24'u32) or
+                  (x shr 8'u32 and 0xff00'u32) or
+                  (x shl 8'u32 and 0xff0000'u32) or
+                  (x shl 24'u32)
+
+proc ntohs*(x: uint16): uint16 =
+  ## Converts 16-bit unsigned integers from network to host byte order. On
+  ## machines where the host byte order is the same as network byte order,
+  ## this is a no-op; otherwise, it performs a 2-byte swap operation.
+  when cpuEndian == bigEndian: result = x
+  else: result = (x shr 8'u16) or (x shl 8'u16)
+
+template htonl*(x: uint32): untyped =
+  ## Converts 32-bit unsigned integers from host to network byte order. On
+  ## machines where the host byte order is the same as network byte order,
+  ## this is a no-op; otherwise, it performs a 4-byte swap operation.
+  nativesockets.ntohl(x)
+
+template htons*(x: uint16): untyped =
+  ## Converts 16-bit unsigned integers from host to network byte order.
+  ## On machines where the host byte order is the same as network byte
+  ## order, this is a no-op; otherwise, it performs a 2-byte swap operation.
+  nativesockets.ntohs(x)
+
+proc getSockDomain*(socket: SocketHandle): Domain =
+  ## Returns the socket's domain (AF_INET or AF_INET6).
+  var name: Sockaddr_in6
+  var namelen = sizeof(name).SockLen
+  if getsockname(socket, cast[ptr SockAddr](addr(name)),
+                 addr(namelen)) == -1'i32:
+    raiseOSError(osLastError())
+  let knownDomain = toKnownDomain(name.sin6_family.cint)
+  if knownDomain.isSome:
+    result = knownDomain.get()
+  else:
+    raise newException(IOError, "Unknown socket family in getSockDomain")
+
+when not useNimNetLite:
+  proc getServByName*(name, proto: string): Servent {.tags: [ReadIOEffect].} =
+    ## Searches the database from the beginning and finds the first entry for
+    ## which the service name specified by `name` matches the s_name member
+    ## and the protocol name specified by `proto` matches the s_proto member.
+    ##
+    ## On posix this will search through the `/etc/services` file.
+    when useWinVersion:
+      var s = winlean.getservbyname(name, proto)
+    else:
+      var s = posix.getservbyname(name, proto)
+    if s == nil: raiseOSError(osLastError(), "Service not found.")
+    result.name = $s.s_name
+    result.aliases = cstringArrayToSeq(s.s_aliases)
+    result.port = Port(s.s_port)
+    result.proto = $s.s_proto
+
+  proc getServByPort*(port: Port, proto: string): Servent {.tags: [ReadIOEffect].} =
+    ## Searches the database from the beginning and finds the first entry for
+    ## which the port specified by `port` matches the s_port member and the
+    ## protocol name specified by `proto` matches the s_proto member.
+    ##
+    ## On posix this will search through the `/etc/services` file.
+    when useWinVersion:
+      var s = winlean.getservbyport(uint16(port).cint, proto)
+    else:
+      var s = posix.getservbyport(uint16(port).cint, proto)
+    if s == nil: raiseOSError(osLastError(), "Service not found.")
+    result.name = $s.s_name
+    result.aliases = cstringArrayToSeq(s.s_aliases)
+    result.port = Port(s.s_port)
+    result.proto = $s.s_proto
+
+  proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} =
+    ## This function will lookup the hostname of an IP Address.
+    var
+      addrInfo = getAddrInfo(ip, Port(0), AF_UNSPEC)
+      myAddr: pointer
+      addrLen = 0
+      family = 0
+    
+    defer: freeAddrInfo(addrInfo)
+
+    if addrInfo.ai_addr.sa_family.cint == nativeAfInet:
+      family = nativeAfInet
+      myAddr = addr cast[ptr Sockaddr_in](addrInfo.ai_addr).sin_addr
+      addrLen = 4
+    elif addrInfo.ai_addr.sa_family.cint == nativeAfInet6:
+      family = nativeAfInet6
+      myAddr = addr cast[ptr Sockaddr_in6](addrInfo.ai_addr).sin6_addr
+      addrLen = 16
+    else:
+      raise newException(IOError, "Unknown socket family in `getHostByAddr()`")
+
+    when useWinVersion:
+      var s = winlean.gethostbyaddr(cast[ptr InAddr](myAddr), addrLen.cuint,
+                                    cint(family))
+      if s == nil: raiseOSError(osLastError())
+    else:
+      var s =
+        when defined(android4):
+          posix.gethostbyaddr(cast[cstring](myAddr), addrLen.cint,
+                              cint(family))
+        else:
+          posix.gethostbyaddr(myAddr, addrLen.SockLen,
+                              cint(family))
+      if s == nil:
+        raiseOSError(osLastError(), $hstrerror(h_errno))
+
+    result.name = $s.h_name
+    result.aliases = cstringArrayToSeq(s.h_aliases)
+    when useWinVersion:
+      result.addrtype = Domain(s.h_addrtype)
+    else:
+      if s.h_addrtype == posix.AF_INET:
+        result.addrtype = AF_INET
+      elif s.h_addrtype == posix.AF_INET6:
+        result.addrtype = AF_INET6
+      else:
+        raiseOSError(osLastError(), "unknown h_addrtype")
+    if result.addrtype == AF_INET:
+      result.addrList = @[]
+      var i = 0
+      while not isNil(s.h_addr_list[i]):
+        var inaddrPtr = cast[ptr InAddr](s.h_addr_list[i])
+        result.addrList.add($inet_ntoa(inaddrPtr[]))
+        inc(i)
+    else:
+      let strAddrLen = when not useWinVersion: posix.INET6_ADDRSTRLEN.int
+                       else: 46
+      var i = 0
+      while not isNil(s.h_addr_list[i]):
+        var ipStr = newString(strAddrLen)
+        if inet_ntop(nativeAfInet6, cast[pointer](s.h_addr_list[i]),
+                     cstring(ipStr), len(ipStr).int32) == nil:
+          raiseOSError(osLastError())
+        when not useWinVersion:
+          if posix.IN6_IS_ADDR_V4MAPPED(cast[ptr In6Addr](s.h_addr_list[i])) != 0:
+            ipStr.setSlice("::ffff:".len..<strAddrLen)
+        setLen(ipStr, len(cstring(ipStr)))
+        result.addrList.add(ipStr)
+        inc(i)
+    result.length = int(s.h_length)
+
+  proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} =
+    ## This function will lookup the IP address of a hostname.
+    when useWinVersion:
+      var s = winlean.gethostbyname(name)
+    else:
+      var s = posix.gethostbyname(name)
+    if s == nil: raiseOSError(osLastError())
+    result.name = $s.h_name
+    result.aliases = cstringArrayToSeq(s.h_aliases)
+    when useWinVersion:
+      result.addrtype = Domain(s.h_addrtype)
+    else:
+      if s.h_addrtype == posix.AF_INET:
+        result.addrtype = AF_INET
+      elif s.h_addrtype == posix.AF_INET6:
+        result.addrtype = AF_INET6
+      else:
+        raiseOSError(osLastError(), "unknown h_addrtype")
+    if result.addrtype == AF_INET:
+      result.addrList = @[]
+      var i = 0
+      while not isNil(s.h_addr_list[i]):
+        var inaddrPtr = cast[ptr InAddr](s.h_addr_list[i])
+        result.addrList.add($inet_ntoa(inaddrPtr[]))
+        inc(i)
+    else:
+      result.addrList = cstringArrayToSeq(s.h_addr_list)
+    result.length = int(s.h_length)
+
+  proc getHostname*(): string {.tags: [ReadIOEffect].} =
+    ## Returns the local hostname (not the FQDN)
+    # https://tools.ietf.org/html/rfc1035#section-2.3.1
+    # https://tools.ietf.org/html/rfc2181#section-11
+    const size = 256
+    result = newString(size)
+    when useWinVersion:
+      let success = winlean.gethostname(result.cstring, size)
+    else:
+      # Posix
+      let success = posix.gethostname(result.cstring, size)
+    if success != 0.cint:
+      raiseOSError(osLastError())
+    let x = len(cstring(result))
+    result.setLen(x)
+
+  proc getAddrString*(sockAddr: ptr SockAddr): string =
+    ## Returns the string representation of address within sockAddr
+    if sockAddr.sa_family.cint == nativeAfInet:
+      result = $inet_ntoa(cast[ptr Sockaddr_in](sockAddr).sin_addr)
+    elif sockAddr.sa_family.cint == nativeAfInet6:
+      let addrLen = when not useWinVersion: posix.INET6_ADDRSTRLEN.int
+                    else: 46 # it's actually 46 in both cases
+      result = newString(addrLen)
+      let addr6 = addr cast[ptr Sockaddr_in6](sockAddr).sin6_addr
+      when not useWinVersion:
+        if posix.inet_ntop(posix.AF_INET6, addr6, cast[cstring](addr result[0]),
+                          result.len.int32) == nil:
+          raiseOSError(osLastError())
+        if posix.IN6_IS_ADDR_V4MAPPED(addr6) != 0:
+          result.setSlice("::ffff:".len..<addrLen)
+      else:
+        if winlean.inet_ntop(winlean.AF_INET6, addr6, cast[cstring](addr result[0]),
+                            result.len.int32) == nil:
+          raiseOSError(osLastError())
+      setLen(result, len(cstring(result)))
+    else:
+      when defined(posix) and not defined(nimdoc):
+        if sockAddr.sa_family.cint == nativeAfUnix:
+          return "unix"
+      raise newException(IOError, "Unknown socket family in getAddrString")
+
+  proc getAddrString*(sockAddr: ptr SockAddr, strAddress: var string) =
+    ## Stores in `strAddress` the string representation of the address inside
+    ## `sockAddr`
+    ##
+    ## **Note**
+    ## * `strAddress` must be initialized to 46 in length.
+    const length = 46
+    assert(length == len(strAddress),
+          "`strAddress` was not initialized correctly. 46 != `len(strAddress)`")
+    if sockAddr.sa_family.cint == nativeAfInet:
+      let addr4 = addr cast[ptr Sockaddr_in](sockAddr).sin_addr
+      when not useWinVersion:
+        if posix.inet_ntop(posix.AF_INET, addr4, cast[cstring](addr strAddress[0]),
+                          strAddress.len.int32) == nil:
+          raiseOSError(osLastError())
+      else:
+        if winlean.inet_ntop(winlean.AF_INET, addr4, cast[cstring](addr strAddress[0]),
+                            strAddress.len.int32) == nil:
+          raiseOSError(osLastError())
+    elif sockAddr.sa_family.cint == nativeAfInet6:
+      let addr6 = addr cast[ptr Sockaddr_in6](sockAddr).sin6_addr
+      when not useWinVersion:
+        if posix.inet_ntop(posix.AF_INET6, addr6, cast[cstring](addr strAddress[0]),
+                          strAddress.len.int32) == nil:
+          raiseOSError(osLastError())
+        if posix.IN6_IS_ADDR_V4MAPPED(addr6) != 0:
+          strAddress.setSlice("::ffff:".len..<length)
+      else:
+        if winlean.inet_ntop(winlean.AF_INET6, addr6, cast[cstring](addr strAddress[0]),
+                            strAddress.len.int32) == nil:
+          raiseOSError(osLastError())
+    else:
+      raise newException(IOError, "Unknown socket family in getAddrString")
+    setLen(strAddress, len(cstring(strAddress)))
+
+  when defined(posix) and not defined(nimdoc):
+    proc makeUnixAddr*(path: string): Sockaddr_un =
+      result.sun_family = AF_UNIX.TSa_Family
+      if path.len >= Sockaddr_un_path_length:
+        raise newException(ValueError, "socket path too long")
+      copyMem(addr result.sun_path, path.cstring, path.len + 1)
+
+  proc getSockName*(socket: SocketHandle): Port =
+    ## Returns the socket's associated port number.
+    var name: Sockaddr_in
+    when useWinVersion:
+      name.sin_family = uint16(ord(AF_INET))
+    else:
+      name.sin_family = TSa_Family(posix.AF_INET)
+    #name.sin_port = htons(cint16(port))
+    #name.sin_addr.s_addr = htonl(INADDR_ANY)
+    var namelen = sizeof(name).SockLen
+    if getsockname(socket, cast[ptr SockAddr](addr(name)),
+                  addr(namelen)) == -1'i32:
+      raiseOSError(osLastError())
+    result = Port(nativesockets.ntohs(name.sin_port))
+
+  proc getLocalAddr*(socket: SocketHandle, domain: Domain): (string, Port) =
+    ## Returns the socket's local address and port number.
+    ##
+    ## Similar to POSIX's `getsockname`:idx:.
+    case domain
+    of AF_INET:
+      var name: Sockaddr_in
+      when useWinVersion:
+        name.sin_family = uint16(ord(AF_INET))
+      else:
+        name.sin_family = TSa_Family(posix.AF_INET)
+      var namelen = sizeof(name).SockLen
+      if getsockname(socket, cast[ptr SockAddr](addr(name)),
+                    addr(namelen)) == -1'i32:
+        raiseOSError(osLastError())
+      result = ($inet_ntoa(name.sin_addr),
+                Port(nativesockets.ntohs(name.sin_port)))
+    of AF_INET6:
+      var name: Sockaddr_in6
+      when useWinVersion:
+        name.sin6_family = uint16(ord(AF_INET6))
+      else:
+        name.sin6_family = TSa_Family(posix.AF_INET6)
+      var namelen = sizeof(name).SockLen
+      if getsockname(socket, cast[ptr SockAddr](addr(name)),
+                    addr(namelen)) == -1'i32:
+        raiseOSError(osLastError())
+      # Cannot use INET6_ADDRSTRLEN here, because it's a C define.
+      result[0] = newString(64)
+      if inet_ntop(name.sin6_family.cint,
+          addr name.sin6_addr, cast[cstring](addr result[0][0]), (result[0].len+1).int32).isNil:
+        raiseOSError(osLastError())
+      setLen(result[0], result[0].cstring.len)
+      result[1] = Port(nativesockets.ntohs(name.sin6_port))
+    else:
+      raiseOSError(OSErrorCode(-1), "invalid socket family in getLocalAddr")
+
+  proc getPeerAddr*(socket: SocketHandle, domain: Domain): (string, Port) =
+    ## Returns the socket's peer address and port number.
+    ##
+    ## Similar to POSIX's `getpeername`:idx:
+    case domain
+    of AF_INET:
+      var name: Sockaddr_in
+      when useWinVersion:
+        name.sin_family = uint16(ord(AF_INET))
+      else:
+        name.sin_family = TSa_Family(posix.AF_INET)
+      var namelen = sizeof(name).SockLen
+      if getpeername(socket, cast[ptr SockAddr](addr(name)),
+                    addr(namelen)) == -1'i32:
+        raiseOSError(osLastError())
+      result = ($inet_ntoa(name.sin_addr),
+                Port(nativesockets.ntohs(name.sin_port)))
+    of AF_INET6:
+      var name: Sockaddr_in6
+      when useWinVersion:
+        name.sin6_family = uint16(ord(AF_INET6))
+      else:
+        name.sin6_family = TSa_Family(posix.AF_INET6)
+      var namelen = sizeof(name).SockLen
+      if getpeername(socket, cast[ptr SockAddr](addr(name)),
+                    addr(namelen)) == -1'i32:
+        raiseOSError(osLastError())
+      # Cannot use INET6_ADDRSTRLEN here, because it's a C define.
+      result[0] = newString(64)
+      if inet_ntop(name.sin6_family.cint,
+          addr name.sin6_addr, cast[cstring](addr result[0][0]), (result[0].len+1).int32).isNil:
+        raiseOSError(osLastError())
+      setLen(result[0], result[0].cstring.len)
+      result[1] = Port(nativesockets.ntohs(name.sin6_port))
+    else:
+      raiseOSError(OSErrorCode(-1), "invalid socket family in getLocalAddr")
+
+when useNimNetLite: 
+
+  when useWinVersion:
+    const
+      INET_ADDRSTRLEN = 16
+      INET6_ADDRSTRLEN = 46 # it's actually 46 in both cases
+
+  proc sockAddrToStr(sa: ptr SockAddr): string {.noinit.} =
+    let af_family = sa.sa_family
+    var nl, v4Slice: cint
+    var si_addr: ptr InAddr
+
+    if af_family == AF_INET.TSa_Family:
+      nl = INET_ADDRSTRLEN
+      si_addr = cast[ptr Sockaddr_in](sa).sin_addr.addr()
+    elif af_family == AF_INET6.TSa_Family:
+      nl = INET6_ADDRSTRLEN
+      let si6_addr = cast[ptr Sockaddr_in6](sa).sin6_addr.addr()
+      si_addr = cast[ptr InAddr](si6_addr) # let's us reuse logic below 
+      when defined(posix) and not defined(nimdoc) and not defined(zephyr):
+        if posix.IN6_IS_ADDR_V4MAPPED(si6_addr) != 0:
+          v4Slice = "::ffff:".len()
+    else:
+      when defined(posix) and not defined(nimdoc):
+        if af_family.cint == nativeAfUnix:
+          return "unix"
+      return ""
+
+    result = newString(nl)
+    let namePtr = result.cstring()
+    if namePtr == inet_ntop(af_family.cint, si_addr, namePtr, nl):
+      result.setLen(len(namePtr))
+      if v4Slice > 0: result.setSlice(v4Slice.int ..< nl.int)
+    else:
+      return ""
+
+  proc sockAddrToStr(sa: var Sockaddr_in | var Sockaddr_in6): string =
+    result = sockAddrToStr(cast[ptr SockAddr](unsafeAddr(sa)))
+
+  proc getAddrString*(sockAddr: ptr SockAddr): string =
+    result = sockAddrToStr(sockAddr)
+    if result.len() == 0:
+      raiseOSError(osLastError())
+
+  proc getAddrString*(sockAddr: ptr SockAddr, strAddress: var string) {.noinit.} =
+    strAddress = getAddrString(sockAddr)
+
+  proc getLocalAddr*(socket: SocketHandle, domain: Domain): (string, Port) =
+    ## Returns the socket's local address and port number.
+    ##
+    ## Similar to POSIX's `getsockname`:idx:.
+    template sockGetNameOrRaiseError(socket: untyped, name: untyped) =
+      var namelen = sizeof(socket).SockLen
+      if getsockname(socket, cast[ptr SockAddr](addr(name)),
+                    addr(namelen)) == -1'i32:
+        raiseOSError(osLastError())
+
+    case domain
+    of AF_INET:
+      var name = Sockaddr_in(sin_family: TSa_Family(posix.AF_INET))
+      sockGetNameOrRaiseError(socket, name)
+      result = (sockAddrToStr(name),
+                Port(nativesockets.ntohs(name.sin_port)))
+    of AF_INET6:
+      var name = Sockaddr_in6(sin6_family: TSa_Family(posix.AF_INET6))
+      sockGetNameOrRaiseError(socket, name)
+      result = (sockAddrToStr(name),
+                Port(nativesockets.ntohs(name.sin6_port)))
+    else:
+      raiseOSError(OSErrorCode(-1), "invalid socket family in getLocalAddr")
+
+
+proc getSockOptInt*(socket: SocketHandle, level, optname: int): int {.
+  tags: [ReadIOEffect].} =
+  ## getsockopt for integer options.
+  var res: cint
+  var size = sizeof(res).SockLen
+  if getsockopt(socket, cint(level), cint(optname),
+                addr(res), addr(size)) < 0'i32:
+    raiseOSError(osLastError())
+  result = int(res)
+
+proc setSockOptInt*(socket: SocketHandle, level, optname, optval: int) {.
+  tags: [WriteIOEffect].} =
+  ## setsockopt for integer options.
+  var value = cint(optval)
+  if setsockopt(socket, cint(level), cint(optname), addr(value),
+                sizeof(value).SockLen) < 0'i32:
+    raiseOSError(osLastError())
+
+proc setBlocking*(s: SocketHandle, blocking: bool) =
+  ## Sets blocking mode on socket.
+  ##
+  ## Raises OSError on error.
+  when useWinVersion:
+    var mode = clong(ord(not blocking)) # 1 for non-blocking, 0 for blocking
+    if ioctlsocket(s, FIONBIO, addr(mode)) == -1:
+      raiseOSError(osLastError())
+  else: # BSD sockets
+    var x: int = fcntl(s, F_GETFL, 0)
+    if x == -1:
+      raiseOSError(osLastError())
+    else:
+      var mode = if blocking: x and not O_NONBLOCK else: x or O_NONBLOCK
+      if fcntl(s, F_SETFL, mode) == -1:
+        raiseOSError(osLastError())
+
+proc timeValFromMilliseconds(timeout = 500): Timeval =
+  if timeout != -1:
+    var seconds = timeout div 1000
+    when useWinVersion:
+      result.tv_sec = seconds.int32
+      result.tv_usec = ((timeout - seconds * 1000) * 1000).int32
+    else:
+      result.tv_sec = seconds.Time
+      result.tv_usec = ((timeout - seconds * 1000) * 1000).Suseconds
+
+proc createFdSet(fd: var TFdSet, s: seq[SocketHandle], m: var int) =
+  FD_ZERO(fd)
+  for i in items(s):
+    m = max(m, int(i))
+    FD_SET(i, fd)
+
+proc pruneSocketSet(s: var seq[SocketHandle], fd: var TFdSet) =
+  var i = 0
+  var L = s.len
+  while i < L:
+    if FD_ISSET(s[i], fd) == 0'i32:
+      s[i] = s[L-1]
+      dec(L)
+    else:
+      inc(i)
+  setLen(s, L)
+
+proc selectRead*(readfds: var seq[SocketHandle], timeout = 500): int =
+  ## When a socket in `readfds` is ready to be read from then a non-zero
+  ## value will be returned specifying the count of the sockets which can be
+  ## read from. The sockets which cannot be read from will also be removed
+  ## from `readfds`.
+  ##
+  ## `timeout` is specified in milliseconds and `-1` can be specified for
+  ## an unlimited time.
+  var tv {.noinit.}: Timeval = timeValFromMilliseconds(timeout)
+
+  var rd: TFdSet
+  var m = 0
+  createFdSet((rd), readfds, m)
+
+  if timeout != -1:
+    result = int(select(cint(m+1), addr(rd), nil, nil, addr(tv)))
+  else:
+    result = int(select(cint(m+1), addr(rd), nil, nil, nil))
+
+  pruneSocketSet(readfds, (rd))
+
+proc selectWrite*(writefds: var seq[SocketHandle],
+                  timeout = 500): int {.tags: [ReadIOEffect].} =
+  ## When a socket in `writefds` is ready to be written to then a non-zero
+  ## value will be returned specifying the count of the sockets which can be
+  ## written to. The sockets which cannot be written to will also be removed
+  ## from `writefds`.
+  ##
+  ## `timeout` is specified in milliseconds and `-1` can be specified for
+  ## an unlimited time.
+  var tv {.noinit.}: Timeval = timeValFromMilliseconds(timeout)
+
+  var wr: TFdSet
+  var m = 0
+  createFdSet((wr), writefds, m)
+
+  if timeout != -1:
+    result = int(select(cint(m+1), nil, addr(wr), nil, addr(tv)))
+  else:
+    result = int(select(cint(m+1), nil, addr(wr), nil, nil))
+
+  pruneSocketSet(writefds, (wr))
+
+proc accept*(fd: SocketHandle, inheritable = defined(nimInheritHandles)): (SocketHandle, string) =
+  ## Accepts a new client connection.
+  ##
+  ## `inheritable` decides if the resulting SocketHandle can be inherited by
+  ## child processes.
+  ##
+  ## Returns (osInvalidSocket, "") if an error occurred.
+  var sockAddress: SockAddr
+  var addrLen = sizeof(sockAddress).SockLen
+  var sock =
+    when (defined(linux) or defined(bsd)) and not defined(nimdoc):
+      accept4(fd, addr(sockAddress), addr(addrLen),
+              if inheritable: 0 else: SOCK_CLOEXEC)
+    else:
+      accept(fd, addr(sockAddress), addr(addrLen))
+  when declared(setInheritable) and not (defined(linux) or defined(bsd)):
+    if not setInheritable(sock, inheritable):
+      close sock
+      sock = osInvalidSocket
+  if sock == osInvalidSocket:
+    return (osInvalidSocket, "")
+  else:
+    when useNimNetLite:
+      var name = sockAddrToStr(addr sockAddress)
+      return (sock, name)
+    else:
+      return (sock, $inet_ntoa(cast[Sockaddr_in](sockAddress).sin_addr))
+
+when defined(windows):
+  var wsa: WSAData
+  if wsaStartup(0x0101'i16, addr wsa) != 0: raiseOSError(osLastError())
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
new file mode 100644
index 000000000..24c94b651
--- /dev/null
+++ b/lib/pure/net.nim
@@ -0,0 +1,2175 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a high-level cross-platform sockets interface.
+## The procedures implemented in this module are primarily for blocking sockets.
+## For asynchronous non-blocking sockets use the `asyncnet` module together
+## with the `asyncdispatch` module.
+##
+## The first thing you will always need to do in order to start using sockets,
+## is to create a new instance of the `Socket` type using the `newSocket`
+## procedure.
+##
+## SSL
+## ====
+##
+## In order to use the SSL procedures defined in this module, you will need to
+## compile your application with the `-d:ssl` flag. See the
+## `newContext<net.html#newContext%2Cstring%2Cstring%2Cstring%2Cstring>`_
+## procedure for additional details.
+##
+##
+## SSL on Windows
+## ==============
+##
+## On Windows the SSL library checks for valid certificates.
+## It uses the `cacert.pem` file for this purpose which was extracted
+## from `https://curl.se/ca/cacert.pem`. Besides
+## the OpenSSL DLLs (e.g. libssl-1_1-x64.dll, libcrypto-1_1-x64.dll) you
+## also need to ship `cacert.pem` with your `.exe` file.
+##
+##
+## Examples
+## ========
+##
+## Connecting to a server
+## ----------------------
+##
+## After you create a socket with the `newSocket` procedure, you can easily
+## connect it to a server running at a known hostname (or IP address) and port.
+## To do so over TCP, use the example below.
+
+runnableExamples("-r:off"):
+  let socket = newSocket()
+  socket.connect("google.com", Port(80))
+
+## For SSL, use the following example:
+
+runnableExamples("-r:off -d:ssl"):
+  let socket = newSocket()
+  let ctx = newContext()
+  wrapSocket(ctx, socket)
+  socket.connect("google.com", Port(443))
+
+## UDP is a connectionless protocol, so UDP sockets don't have to explicitly
+## call the `connect <net.html#connect%2CSocket%2Cstring>`_ procedure. They can
+## simply start sending data immediately.
+
+runnableExamples("-r:off"):
+  let socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
+  socket.sendTo("192.168.0.1", Port(27960), "status\n")
+
+runnableExamples("-r:off"):
+  let socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
+  let ip = parseIpAddress("192.168.0.1")
+  doAssert socket.sendTo(ip, Port(27960), "status\c\l") == 8
+
+## Creating a server
+## -----------------
+##
+## After you create a socket with the `newSocket` procedure, you can create a
+## TCP server by calling the `bindAddr` and `listen` procedures.
+
+runnableExamples("-r:off"):
+  let socket = newSocket()
+  socket.bindAddr(Port(1234))
+  socket.listen()
+
+  # You can then begin accepting connections using the `accept` procedure.
+  var client: Socket
+  var address = ""
+  while true:
+    socket.acceptAddr(client, address)
+    echo "Client connected from: ", address
+
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+import std/nativesockets
+import std/[os, strutils, times, sets, options, monotimes]
+import std/ssl_config
+export nativesockets.Port, nativesockets.`$`, nativesockets.`==`
+export Domain, SockType, Protocol, IPPROTO_NONE
+
+const useWinVersion = defined(windows) or defined(nimdoc)
+const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr) or
+    defined(nuttx)
+const defineSsl = defined(ssl) or defined(nimdoc)
+
+when useWinVersion:
+  from std/winlean import WSAESHUTDOWN
+
+when defineSsl:
+  import std/openssl
+  when not defined(nimDisableCertificateValidation):
+    from std/ssl_certs import scanSSLCertificates
+
+# Note: The enumerations are mapped to Window's constants.
+
+when defineSsl:
+  type
+    Certificate* = string ## DER encoded certificate
+
+    SslError* = object of CatchableError
+
+    SslCVerifyMode* = enum
+      CVerifyNone, CVerifyPeer, CVerifyPeerUseEnvVars
+
+    SslProtVersion* = enum
+      protSSLv2, protSSLv3, protTLSv1, protSSLv23
+
+    SslContext* = ref object
+      context*: SslCtx
+      referencedData: HashSet[int]
+      extraInternal: SslContextExtraInternal
+
+    SslAcceptResult* = enum
+      AcceptNoClient = 0, AcceptNoHandshake, AcceptSuccess
+
+    SslHandshakeType* = enum
+      handshakeAsClient, handshakeAsServer
+
+    SslClientGetPskFunc* = proc(hint: string): tuple[identity: string, psk: string]
+
+    SslServerGetPskFunc* = proc(identity: string): string
+
+    SslContextExtraInternal = ref object of RootRef
+      serverGetPskFunc: SslServerGetPskFunc
+      clientGetPskFunc: SslClientGetPskFunc
+
+else:
+  type
+    SslContext* = ref object # TODO: Workaround #4797.
+
+const
+  BufferSize*: int = 4000 ## size of a buffered socket's buffer
+  MaxLineLength* = 1_000_000
+
+type
+  SocketImpl* = object     ## socket type
+    fd: SocketHandle
+    isBuffered: bool       # determines whether this socket is buffered.
+    buffer: array[0..BufferSize, char]
+    currPos: int           # current index in buffer
+    bufLen: int            # current length of buffer
+    when defineSsl:
+      isSsl: bool
+      sslHandle: SslPtr
+      sslContext: SslContext
+      sslNoHandshake: bool # True if needs handshake.
+      sslHasPeekChar: bool
+      sslPeekChar: char
+      sslNoShutdown: bool # True if shutdown shouldn't be done.
+    lastError: OSErrorCode ## stores the last error on this socket
+    domain: Domain
+    sockType: SockType
+    protocol: Protocol
+
+  Socket* = ref SocketImpl
+
+  SOBool* = enum ## Boolean socket options.
+    OptAcceptConn, OptBroadcast, OptDebug, OptDontRoute, OptKeepAlive,
+    OptOOBInline, OptReuseAddr, OptReusePort, OptNoDelay
+
+  ReadLineResult* = enum ## result for readLineAsync
+    ReadFullLine, ReadPartialLine, ReadDisconnected, ReadNone
+
+  TimeoutError* = object of CatchableError
+
+  SocketFlag* {.pure.} = enum
+    Peek,
+    SafeDisconn ## Ensures disconnection exceptions (ECONNRESET, EPIPE etc) are not thrown.
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+type
+  IpAddressFamily* {.pure.} = enum ## Describes the type of an IP address
+    IPv6,                          ## IPv6 address
+    IPv4                           ## IPv4 address
+
+  IpAddress* = object                  ## stores an arbitrary IP address
+    case family*: IpAddressFamily      ## the type of the IP address (IPv4 or IPv6)
+    of IpAddressFamily.IPv6:
+      address_v6*: array[0..15, uint8] ## Contains the IP address in bytes in
+                                       ## case of IPv6
+    of IpAddressFamily.IPv4:
+      address_v4*: array[0..3, uint8]  ## Contains the IP address in bytes in
+                                       ## case of IPv4
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+
+when defined(posix) and not defined(lwip):
+  from std/posix import TPollfd, POLLIN, POLLPRI, POLLOUT, POLLWRBAND, Tnfds
+
+  template monitorPollEvent(x: var SocketHandle, y: cint, timeout: int): int =
+    var tpollfd: TPollfd
+    tpollfd.fd = cast[cint](x)
+    tpollfd.events = y
+    posix.poll(addr(tpollfd), Tnfds(1), timeout)
+
+proc timeoutRead(fd: var SocketHandle, timeout = 500): int =
+  when defined(windows) or defined(lwip):
+    var fds = @[fd]
+    selectRead(fds, timeout)
+  else:
+    monitorPollEvent(fd, POLLIN or POLLPRI, timeout)
+
+proc timeoutWrite(fd: var SocketHandle, timeout = 500): int =
+  when defined(windows) or defined(lwip):
+    var fds = @[fd]
+    selectWrite(fds, timeout)
+  else:
+    monitorPollEvent(fd, POLLOUT or POLLWRBAND, timeout)
+
+proc socketError*(socket: Socket, err: int = -1, async = false,
+                  lastError = (-1).OSErrorCode,
+                  flags: set[SocketFlag] = {}) {.gcsafe.}
+
+proc isDisconnectionError*(flags: set[SocketFlag],
+    lastError: OSErrorCode): bool =
+  ## Determines whether `lastError` is a disconnection error. Only does this
+  ## if flags contains `SafeDisconn`.
+  when useWinVersion:
+    SocketFlag.SafeDisconn in flags and
+      (lastError.int32 == WSAECONNRESET or
+       lastError.int32 == WSAECONNABORTED or
+       lastError.int32 == WSAENETRESET or
+       lastError.int32 == WSAEDISCON or
+       lastError.int32 == WSAESHUTDOWN or
+       lastError.int32 == ERROR_NETNAME_DELETED)
+  else:
+    SocketFlag.SafeDisconn in flags and
+      (lastError.int32 == ECONNRESET or
+       lastError.int32 == EPIPE or
+       lastError.int32 == ENETRESET)
+
+proc toOSFlags*(socketFlags: set[SocketFlag]): cint =
+  ## Converts the flags into the underlying OS representation.
+  for f in socketFlags:
+    case f
+    of SocketFlag.Peek:
+      result = result or MSG_PEEK
+    of SocketFlag.SafeDisconn: continue
+
+proc newSocket*(fd: SocketHandle, domain: Domain = AF_INET,
+    sockType: SockType = SOCK_STREAM,
+    protocol: Protocol = IPPROTO_TCP, buffered = true): owned(Socket) =
+  ## Creates a new socket as specified by the params.
+  assert fd != osInvalidSocket
+  result = Socket(
+    fd: fd,
+    isBuffered: buffered,
+    domain: domain,
+    sockType: sockType,
+    protocol: protocol)
+  if buffered:
+    result.currPos = 0
+
+  # Set SO_NOSIGPIPE on OS X.
+  when defined(macosx) and not defined(nimdoc):
+    setSockOptInt(fd, SOL_SOCKET, SO_NOSIGPIPE, 1)
+
+proc newSocket*(domain, sockType, protocol: cint, buffered = true,
+                inheritable = defined(nimInheritHandles)): owned(Socket) =
+  ## Creates a new socket.
+  ##
+  ## The SocketHandle associated with the resulting Socket will not be
+  ## inheritable by child processes by default. This can be changed via
+  ## the `inheritable` parameter.
+  ##
+  ## If an error occurs OSError will be raised.
+  let fd = createNativeSocket(domain, sockType, protocol, inheritable)
+  if fd == osInvalidSocket:
+    raiseOSError(osLastError())
+  result = newSocket(fd, domain.Domain, sockType.SockType, protocol.Protocol,
+                     buffered)
+
+proc newSocket*(domain: Domain = AF_INET, sockType: SockType = SOCK_STREAM,
+                protocol: Protocol = IPPROTO_TCP, buffered = true,
+                inheritable = defined(nimInheritHandles)): owned(Socket) =
+  ## Creates a new socket.
+  ##
+  ## The SocketHandle associated with the resulting Socket will not be
+  ## inheritable by child processes by default. This can be changed via
+  ## the `inheritable` parameter.
+  ##
+  ## If an error occurs OSError will be raised.
+  let fd = createNativeSocket(domain, sockType, protocol, inheritable)
+  if fd == osInvalidSocket:
+    raiseOSError(osLastError())
+  result = newSocket(fd, domain, sockType, protocol, buffered)
+
+proc parseIPv4Address(addressStr: string): IpAddress =
+  ## Parses IPv4 addresses
+  ## Raises ValueError on errors
+  var
+    byteCount = 0
+    currentByte: uint16 = 0
+    separatorValid = false
+    leadingZero = false
+
+  result = IpAddress(family: IpAddressFamily.IPv4)
+
+  for i in 0 .. high(addressStr):
+    if addressStr[i] in strutils.Digits: # Character is a number
+      if leadingZero:
+        raise newException(ValueError,
+          "Invalid IP address. Octal numbers are not allowed")
+      currentByte = currentByte * 10 +
+        cast[uint16](ord(addressStr[i]) - ord('0'))
+      if currentByte == 0'u16:
+        leadingZero = true
+      elif currentByte > 255'u16:
+        raise newException(ValueError,
+          "Invalid IP Address. Value is out of range")
+      separatorValid = true
+    elif addressStr[i] == '.': # IPv4 address separator
+      if not separatorValid or byteCount >= 3:
+        raise newException(ValueError,
+          "Invalid IP Address. The address consists of too many groups")
+      result.address_v4[byteCount] = cast[uint8](currentByte)
+      currentByte = 0
+      byteCount.inc
+      separatorValid = false
+      leadingZero = false
+    else:
+      raise newException(ValueError,
+        "Invalid IP Address. Address contains an invalid character")
+
+  if byteCount != 3 or not separatorValid:
+    raise newException(ValueError, "Invalid IP Address")
+  result.address_v4[byteCount] = cast[uint8](currentByte)
+
+proc parseIPv6Address(addressStr: string): IpAddress =
+  ## Parses IPv6 addresses
+  ## Raises ValueError on errors
+  result = IpAddress(family: IpAddressFamily.IPv6)
+  if addressStr.len < 2:
+    raise newException(ValueError, "Invalid IP Address")
+
+  var
+    groupCount = 0
+    currentGroupStart = 0
+    currentShort: uint32 = 0
+    separatorValid = true
+    dualColonGroup = -1
+    lastWasColon = false
+    v4StartPos = -1
+    byteCount = 0
+
+  for i, c in addressStr:
+    if c == ':':
+      if not separatorValid:
+        raise newException(ValueError,
+          "Invalid IP Address. Address contains an invalid separator")
+      if lastWasColon:
+        if dualColonGroup != -1:
+          raise newException(ValueError,
+            "Invalid IP Address. Address contains more than one \"::\" separator")
+        dualColonGroup = groupCount
+        separatorValid = false
+      elif i != 0 and i != high(addressStr):
+        if groupCount >= 8:
+          raise newException(ValueError,
+            "Invalid IP Address. The address consists of too many groups")
+        result.address_v6[groupCount*2] = cast[uint8](currentShort shr 8)
+        result.address_v6[groupCount*2+1] = cast[uint8](currentShort and 0xFF)
+        currentShort = 0
+        groupCount.inc()
+        if dualColonGroup != -1: separatorValid = false
+      elif i == 0: # only valid if address starts with ::
+        if addressStr[1] != ':':
+          raise newException(ValueError,
+            "Invalid IP Address. Address may not start with \":\"")
+      else: # i == high(addressStr) - only valid if address ends with ::
+        if addressStr[high(addressStr)-1] != ':':
+          raise newException(ValueError,
+            "Invalid IP Address. Address may not end with \":\"")
+      lastWasColon = true
+      currentGroupStart = i + 1
+    elif c == '.': # Switch to parse IPv4 mode
+      if i < 3 or not separatorValid or groupCount >= 7:
+        raise newException(ValueError, "Invalid IP Address")
+      v4StartPos = currentGroupStart
+      currentShort = 0
+      separatorValid = false
+      break
+    elif c in strutils.HexDigits:
+      if c in strutils.Digits: # Normal digit
+        currentShort = (currentShort shl 4) + cast[uint32](ord(c) - ord('0'))
+      elif c >= 'a' and c <= 'f': # Lower case hex
+        currentShort = (currentShort shl 4) + cast[uint32](ord(c) - ord('a')) + 10
+      else: # Upper case hex
+        currentShort = (currentShort shl 4) + cast[uint32](ord(c) - ord('A')) + 10
+      if currentShort > 65535'u32:
+        raise newException(ValueError,
+          "Invalid IP Address. Value is out of range")
+      lastWasColon = false
+      separatorValid = true
+    else:
+      raise newException(ValueError,
+        "Invalid IP Address. Address contains an invalid character")
+
+
+  if v4StartPos == -1: # Don't parse v4. Copy the remaining v6 stuff
+    if separatorValid: # Copy remaining data
+      if groupCount >= 8:
+        raise newException(ValueError,
+          "Invalid IP Address. The address consists of too many groups")
+      result.address_v6[groupCount*2] = cast[uint8](currentShort shr 8)
+      result.address_v6[groupCount*2+1] = cast[uint8](currentShort and 0xFF)
+      groupCount.inc()
+  else: # Must parse IPv4 address
+    var leadingZero = false
+    for i, c in addressStr[v4StartPos..high(addressStr)]:
+      if c in strutils.Digits: # Character is a number
+        if leadingZero:
+          raise newException(ValueError,
+            "Invalid IP address. Octal numbers not allowed")
+        currentShort = currentShort * 10 + cast[uint32](ord(c) - ord('0'))
+        if currentShort == 0'u32:
+          leadingZero = true
+        elif currentShort > 255'u32:
+          raise newException(ValueError,
+            "Invalid IP Address. Value is out of range")
+        separatorValid = true
+      elif c == '.': # IPv4 address separator
+        if not separatorValid or byteCount >= 3:
+          raise newException(ValueError, "Invalid IP Address")
+        result.address_v6[groupCount*2 + byteCount] = cast[uint8](currentShort)
+        currentShort = 0
+        byteCount.inc()
+        separatorValid = false
+        leadingZero = false
+      else: # Invalid character
+        raise newException(ValueError,
+          "Invalid IP Address. Address contains an invalid character")
+
+    if byteCount != 3 or not separatorValid:
+      raise newException(ValueError, "Invalid IP Address")
+    result.address_v6[groupCount*2 + byteCount] = cast[uint8](currentShort)
+    groupCount += 2
+
+  # Shift and fill zeros in case of ::
+  if groupCount > 8:
+    raise newException(ValueError,
+      "Invalid IP Address. The address consists of too many groups")
+  elif groupCount < 8: # must fill
+    if dualColonGroup == -1:
+      raise newException(ValueError,
+        "Invalid IP Address. The address consists of too few groups")
+    var toFill = 8 - groupCount # The number of groups to fill
+    var toShift = groupCount - dualColonGroup # Nr of known groups after ::
+    for i in 0..2*toShift-1: # shift
+      result.address_v6[15-i] = result.address_v6[groupCount*2-i-1]
+    for i in 0..2*toFill-1: # fill with 0s
+      result.address_v6[dualColonGroup*2+i] = 0
+  elif dualColonGroup != -1:
+    raise newException(ValueError,
+      "Invalid IP Address. The address consists of too many groups")
+
+proc parseIpAddress*(addressStr: string): IpAddress =
+  ## Parses an IP address
+  ##
+  ## Raises ValueError on error.
+  ##
+  ## For IPv4 addresses, only the strict form as
+  ## defined in RFC 6943 is considered valid, see
+  ## https://datatracker.ietf.org/doc/html/rfc6943#section-3.1.1.
+  if addressStr.len == 0:
+    raise newException(ValueError, "IP Address string is empty")
+  if addressStr.contains(':'):
+    return parseIPv6Address(addressStr)
+  else:
+    return parseIPv4Address(addressStr)
+
+proc isIpAddress*(addressStr: string): bool {.tags: [].} =
+  ## Checks if a string is an IP address
+  ## Returns true if it is, false otherwise
+  try:
+    discard parseIpAddress(addressStr)
+  except ValueError:
+    return false
+  return true
+
+proc toSockAddr*(address: IpAddress, port: Port, sa: var Sockaddr_storage,
+                 sl: var SockLen) =
+  ## Converts `IpAddress` and `Port` to `SockAddr` and `SockLen`
+  let port = htons(uint16(port))
+  case address.family
+  of IpAddressFamily.IPv4:
+    sl = sizeof(Sockaddr_in).SockLen
+    let s = cast[ptr Sockaddr_in](addr sa)
+    s.sin_family = typeof(s.sin_family)(toInt(AF_INET))
+    s.sin_port = port
+    copyMem(addr s.sin_addr, unsafeAddr address.address_v4[0],
+            sizeof(s.sin_addr))
+  of IpAddressFamily.IPv6:
+    sl = sizeof(Sockaddr_in6).SockLen
+    let s = cast[ptr Sockaddr_in6](addr sa)
+    s.sin6_family = typeof(s.sin6_family)(toInt(AF_INET6))
+    s.sin6_port = port
+    copyMem(addr s.sin6_addr, unsafeAddr address.address_v6[0],
+            sizeof(s.sin6_addr))
+
+proc fromSockAddrAux(sa: ptr Sockaddr_storage, sl: SockLen,
+                     address: var IpAddress, port: var Port) =
+  if sa.ss_family.cint == toInt(AF_INET) and sl == sizeof(Sockaddr_in).SockLen:
+    address = IpAddress(family: IpAddressFamily.IPv4)
+    let s = cast[ptr Sockaddr_in](sa)
+    copyMem(addr address.address_v4[0], addr s.sin_addr,
+            sizeof(address.address_v4))
+    port = ntohs(s.sin_port).Port
+  elif sa.ss_family.cint == toInt(AF_INET6) and
+       sl == sizeof(Sockaddr_in6).SockLen:
+    address = IpAddress(family: IpAddressFamily.IPv6)
+    let s = cast[ptr Sockaddr_in6](sa)
+    copyMem(addr address.address_v6[0], addr s.sin6_addr,
+            sizeof(address.address_v6))
+    port = ntohs(s.sin6_port).Port
+  else:
+    raise newException(ValueError, "Neither IPv4 nor IPv6")
+
+proc fromSockAddr*(sa: Sockaddr_storage | SockAddr | Sockaddr_in | Sockaddr_in6,
+    sl: SockLen, address: var IpAddress, port: var Port) {.inline.} =
+  ## Converts `SockAddr` and `SockLen` to `IpAddress` and `Port`. Raises
+  ## `ObjectConversionDefect` in case of invalid `sa` and `sl` arguments.
+  fromSockAddrAux(cast[ptr Sockaddr_storage](unsafeAddr sa), sl, address, port)
+
+when defineSsl:
+  # OpenSSL >= 1.1.0 does not need explicit init.
+  when not useOpenssl3:
+    CRYPTO_malloc_init()
+    doAssert SslLibraryInit() == 1
+    SSL_load_error_strings()
+    ERR_load_BIO_strings()
+    OpenSSL_add_all_algorithms()
+
+  proc sslHandle*(self: Socket): SslPtr =
+    ## Retrieve the ssl pointer of `socket`.
+    ## Useful for interfacing with `openssl`.
+    self.sslHandle
+
+  proc raiseSSLError*(s = "") {.raises: [SslError].}=
+    ## Raises a new SSL error.
+    if s != "":
+      raise newException(SslError, s)
+    let err = ERR_peek_last_error()
+    if err == 0:
+      raise newException(SslError, "No error reported.")
+    var errStr = $ERR_error_string(err, nil)
+    case err
+    of 336032814, 336032784:
+      errStr = "Please upgrade your OpenSSL library, it does not support the " &
+               "necessary protocols. OpenSSL error is: " & errStr
+    else:
+      discard
+    raise newException(SslError, errStr)
+
+  proc getExtraData*(ctx: SslContext, index: int): RootRef =
+    ## Retrieves arbitrary data stored inside SslContext.
+    if index notin ctx.referencedData:
+      raise newException(IndexDefect, "No data with that index.")
+    let res = ctx.context.SSL_CTX_get_ex_data(index.cint)
+    if cast[int](res) == 0:
+      raiseSSLError()
+    return cast[RootRef](res)
+
+  proc setExtraData*(ctx: SslContext, index: int, data: RootRef) =
+    ## Stores arbitrary data inside SslContext. The unique `index`
+    ## should be retrieved using getSslContextExtraDataIndex.
+    if index in ctx.referencedData:
+      GC_unref(getExtraData(ctx, index))
+
+    if ctx.context.SSL_CTX_set_ex_data(index.cint, cast[pointer](data)) == -1:
+      raiseSSLError()
+
+    if index notin ctx.referencedData:
+      ctx.referencedData.incl(index)
+    GC_ref(data)
+
+  # http://simplestcodings.blogspot.co.uk/2010/08/secure-server-client-using-openssl-in-c.html
+  proc loadCertificates(ctx: SslCtx, certFile, keyFile: string) =
+    if certFile != "" and not fileExists(certFile):
+      raise newException(system.IOError,
+          "Certificate file could not be found: " & certFile)
+    if keyFile != "" and not fileExists(keyFile):
+      raise newException(system.IOError, "Key file could not be found: " & keyFile)
+
+    if certFile != "":
+      var ret = SSL_CTX_use_certificate_chain_file(ctx, certFile)
+      if ret != 1:
+        raiseSSLError()
+
+    # TODO: Password? www.rtfm.com/openssl-examples/part1.pdf
+    if keyFile != "":
+      if SSL_CTX_use_PrivateKey_file(ctx, keyFile,
+                                     SSL_FILETYPE_PEM) != 1:
+        raiseSSLError()
+
+      if SSL_CTX_check_private_key(ctx) != 1:
+        raiseSSLError("Verification of private key file failed.")
+
+  proc newContext*(protVersion = protSSLv23, verifyMode = CVerifyPeer,
+                   certFile = "", keyFile = "", cipherList = CiphersIntermediate,
+                   caDir = "", caFile = "", ciphersuites = CiphersModern): SslContext =
+    ## Creates an SSL context.
+    ##
+    ## Protocol version is currently ignored by default and TLS is used.
+    ## With `-d:openssl10`, only SSLv23 and TLSv1 may be used.
+    ##
+    ## There are three options for verify mode:
+    ## `CVerifyNone`: certificates are not verified;
+    ## `CVerifyPeer`: certificates are verified;
+    ## `CVerifyPeerUseEnvVars`: certificates are verified and the optional
+    ## environment variables SSL_CERT_FILE and SSL_CERT_DIR are also used to
+    ## locate certificates
+    ##
+    ## The `nimDisableCertificateValidation` define overrides verifyMode and
+    ## disables certificate verification globally!
+    ##
+    ## CA certificates will be loaded, in the following order, from:
+    ##
+    ## - caFile, caDir, parameters, if set
+    ## - if `verifyMode` is set to `CVerifyPeerUseEnvVars`,
+    ##   the SSL_CERT_FILE and SSL_CERT_DIR environment variables are used
+    ## - a set of files and directories from the `ssl_certs <ssl_certs.html>`_ file.
+    ##
+    ## The last two parameters specify the certificate file path and the key file
+    ## path, a server socket will most likely not work without these.
+    ##
+    ## Certificates can be generated using the following command:
+    ## - `openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout mykey.pem -out mycert.pem`
+    ## or using ECDSA:
+    ## - `openssl ecparam -out mykey.pem -name secp256k1 -genkey`
+    ## - `openssl req -new -key mykey.pem -x509 -nodes -days 365 -out mycert.pem`
+    var mtd: PSSL_METHOD
+    when defined(openssl10):
+      case protVersion
+      of protSSLv23:
+        mtd = SSLv23_method()
+      of protSSLv2:
+        raiseSSLError("SSLv2 is no longer secure and has been deprecated, use protSSLv23")
+      of protSSLv3:
+        raiseSSLError("SSLv3 is no longer secure and has been deprecated, use protSSLv23")
+      of protTLSv1:
+        mtd = TLSv1_method()
+    else:
+      mtd = TLS_method()
+    if mtd == nil:
+      raiseSSLError("Failed to create TLS context")
+    var newCTX = SSL_CTX_new(mtd)
+    if newCTX == nil:
+      raiseSSLError("Failed to create TLS context")
+
+    if newCTX.SSL_CTX_set_cipher_list(cipherList) != 1:
+      raiseSSLError()
+    when not defined(openssl10) and not defined(libressl):
+      let sslVersion = getOpenSSLVersion()
+      if sslVersion >= 0x010101000 and sslVersion != 0x020000000:
+        # In OpenSSL >= 1.1.1, TLSv1.3 cipher suites can only be configured via
+        # this API.
+        if newCTX.SSL_CTX_set_ciphersuites(ciphersuites) != 1:
+          raiseSSLError()
+    # Automatically the best ECDH curve for client exchange. Without this, ECDH
+    # ciphers will be ignored by the server.
+    #
+    # From OpenSSL >= 1.1.0, this setting is set by default and can't be
+    # overridden.
+    if newCTX.SSL_CTX_set_ecdh_auto(1) != 1:
+      raiseSSLError()
+
+    when defined(nimDisableCertificateValidation):
+      newCTX.SSL_CTX_set_verify(SSL_VERIFY_NONE, nil)
+    else:
+      case verifyMode
+      of CVerifyPeer, CVerifyPeerUseEnvVars:
+        newCTX.SSL_CTX_set_verify(SSL_VERIFY_PEER, nil)
+      of CVerifyNone:
+        newCTX.SSL_CTX_set_verify(SSL_VERIFY_NONE, nil)
+
+    if newCTX == nil:
+      raiseSSLError()
+
+    discard newCTX.SSLCTXSetMode(SSL_MODE_AUTO_RETRY)
+    newCTX.loadCertificates(certFile, keyFile)
+
+    const VerifySuccess = 1 # SSL_CTX_load_verify_locations returns 1 on success.
+
+    when not defined(nimDisableCertificateValidation):
+      if verifyMode != CVerifyNone:
+        # Use the caDir and caFile parameters if set
+        if caDir != "" or caFile != "":
+          if newCTX.SSL_CTX_load_verify_locations(if caFile == "": nil else: caFile.cstring, if caDir == "": nil else: caDir.cstring) != VerifySuccess:
+            raise newException(IOError, "Failed to load SSL/TLS CA certificate(s).")
+
+        else:
+          # Scan for certs in known locations. For CVerifyPeerUseEnvVars also scan
+          # the SSL_CERT_FILE and SSL_CERT_DIR env vars
+          var found = false
+          let useEnvVars = (if verifyMode == CVerifyPeerUseEnvVars: true else: false)
+          for fn in scanSSLCertificates(useEnvVars = useEnvVars):
+            if fn.extractFilename == "":
+              if newCTX.SSL_CTX_load_verify_locations(nil, cstring(fn.normalizePathEnd(false))) == VerifySuccess:
+                found = true
+                break
+            elif newCTX.SSL_CTX_load_verify_locations(cstring(fn), nil) == VerifySuccess:
+              found = true
+              break
+          if not found:
+            raise newException(IOError, "No SSL/TLS CA certificates found.")
+
+    result = SslContext(context: newCTX, referencedData: initHashSet[int](),
+      extraInternal: new(SslContextExtraInternal))
+
+  proc getExtraInternal(ctx: SslContext): SslContextExtraInternal =
+    return ctx.extraInternal
+
+  proc destroyContext*(ctx: SslContext) =
+    ## Free memory referenced by SslContext.
+
+    # We assume here that OpenSSL's internal indexes increase by 1 each time.
+    # That means we can assume that the next internal index is the length of
+    # extra data indexes.
+    for i in ctx.referencedData:
+      GC_unref(getExtraData(ctx, i))
+    ctx.context.SSL_CTX_free()
+
+  proc `pskIdentityHint=`*(ctx: SslContext, hint: string) =
+    ## Sets the identity hint passed to server.
+    ##
+    ## Only used in PSK ciphersuites.
+    if ctx.context.SSL_CTX_use_psk_identity_hint(hint) <= 0:
+      raiseSSLError()
+
+  proc clientGetPskFunc*(ctx: SslContext): SslClientGetPskFunc =
+    return ctx.getExtraInternal().clientGetPskFunc
+
+  proc pskClientCallback(ssl: SslPtr; hint: cstring; identity: cstring;
+      max_identity_len: cuint; psk: ptr uint8;
+      max_psk_len: cuint): cuint {.cdecl.} =
+    let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
+    let hintString = if hint == nil: "" else: $hint
+    let (identityString, pskString) = (ctx.clientGetPskFunc)(hintString)
+    if pskString.len.cuint > max_psk_len:
+      return 0
+    if identityString.len.cuint >= max_identity_len:
+      return 0
+    copyMem(identity, identityString.cstring, identityString.len + 1) # with the last zero byte
+    copyMem(psk, pskString.cstring, pskString.len)
+
+    return pskString.len.cuint
+
+  proc `clientGetPskFunc=`*(ctx: SslContext, fun: SslClientGetPskFunc) =
+    ## Sets function that returns the client identity and the PSK based on identity
+    ## hint from the server.
+    ##
+    ## Only used in PSK ciphersuites.
+    ctx.getExtraInternal().clientGetPskFunc = fun
+    ctx.context.SSL_CTX_set_psk_client_callback(
+        if fun == nil: nil else: pskClientCallback)
+
+  proc serverGetPskFunc*(ctx: SslContext): SslServerGetPskFunc =
+    return ctx.getExtraInternal().serverGetPskFunc
+
+  proc pskServerCallback(ssl: SslCtx; identity: cstring; psk: ptr uint8;
+      max_psk_len: cint): cuint {.cdecl.} =
+    let ctx = SslContext(context: ssl.SSL_get_SSL_CTX)
+    let pskString = (ctx.serverGetPskFunc)($identity)
+    if pskString.len.cint > max_psk_len:
+      return 0
+    copyMem(psk, pskString.cstring, pskString.len)
+
+    return pskString.len.cuint
+
+  proc `serverGetPskFunc=`*(ctx: SslContext, fun: SslServerGetPskFunc) =
+    ## Sets function that returns PSK based on the client identity.
+    ##
+    ## Only used in PSK ciphersuites.
+    ctx.getExtraInternal().serverGetPskFunc = fun
+    ctx.context.SSL_CTX_set_psk_server_callback(if fun == nil: nil
+                                                else: pskServerCallback)
+
+  proc getPskIdentity*(socket: Socket): string =
+    ## Gets the PSK identity provided by the client.
+    assert socket.isSsl
+    return $(socket.sslHandle.SSL_get_psk_identity)
+
+  proc wrapSocket*(ctx: SslContext, socket: Socket) =
+    ## Wraps a socket in an SSL context. This function effectively turns
+    ## `socket` into an SSL socket.
+    ##
+    ## This must be called on an unconnected socket; an SSL session will
+    ## be started when the socket is connected.
+    ##
+    ## FIXME:
+    ## **Disclaimer**: This code is not well tested, may be very unsafe and
+    ## prone to security vulnerabilities.
+
+    assert(not socket.isSsl)
+    socket.isSsl = true
+    socket.sslContext = ctx
+    socket.sslHandle = SSL_new(socket.sslContext.context)
+    socket.sslNoHandshake = false
+    socket.sslHasPeekChar = false
+    socket.sslNoShutdown = false
+    if socket.sslHandle == nil:
+      raiseSSLError()
+
+    if SSL_set_fd(socket.sslHandle, socket.fd) != 1:
+      raiseSSLError()
+
+  proc checkCertName(socket: Socket, hostname: string) {.raises: [SslError], tags:[RootEffect].} =
+    ## Check if the certificate Subject Alternative Name (SAN) or Subject CommonName (CN) matches hostname.
+    ## Wildcards match only in the left-most label.
+    ## When name starts with a dot it will be matched by a certificate valid for any subdomain
+    when not defined(nimDisableCertificateValidation) and not defined(windows):
+      assert socket.isSsl
+      try:
+        let certificate = socket.sslHandle.SSL_get_peer_certificate()
+        if certificate.isNil:
+          raiseSSLError("No SSL certificate found.")
+
+        const X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT = 0x1.cuint
+        # https://www.openssl.org/docs/man1.1.1/man3/X509_check_host.html
+        let match = certificate.X509_check_host(hostname.cstring, hostname.len.cint,
+          X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT, nil)
+        # https://www.openssl.org/docs/man1.1.1/man3/SSL_get_peer_certificate.html
+        X509_free(certificate)
+        if match != 1:
+          raiseSSLError("SSL Certificate check failed.")
+
+      except LibraryError:
+        raiseSSLError("SSL import failed")
+
+  proc wrapConnectedSocket*(ctx: SslContext, socket: Socket,
+                            handshake: SslHandshakeType,
+                            hostname: string = "") =
+    ## Wraps a connected socket in an SSL context. This function effectively
+    ## turns `socket` into an SSL socket.
+    ## `hostname` should be specified so that the client knows which hostname
+    ## the server certificate should be validated against.
+    ##
+    ## This should be called on a connected socket, and will perform
+    ## an SSL handshake immediately.
+    ##
+    ## FIXME:
+    ## **Disclaimer**: This code is not well tested, may be very unsafe and
+    ## prone to security vulnerabilities.
+    wrapSocket(ctx, socket)
+    case handshake
+    of handshakeAsClient:
+      if hostname.len > 0 and not isIpAddress(hostname):
+        # Discard result in case OpenSSL version doesn't support SNI, or we're
+        # not using TLSv1+
+        discard SSL_set_tlsext_host_name(socket.sslHandle, hostname)
+      ErrClearError()
+      let ret = SSL_connect(socket.sslHandle)
+      socketError(socket, ret)
+      when not defined(nimDisableCertificateValidation) and not defined(windows):
+        # FIXME: this should be skipped on CVerifyNone
+        if hostname.len > 0 and not isIpAddress(hostname):
+          socket.checkCertName(hostname)
+    of handshakeAsServer:
+      ErrClearError()
+      let ret = SSL_accept(socket.sslHandle)
+      socketError(socket, ret)
+
+  proc getPeerCertificates*(sslHandle: SslPtr): seq[Certificate] {.since: (1, 1).} =
+    ## Returns the certificate chain received by the peer we are connected to
+    ## through the OpenSSL connection represented by `sslHandle`.
+    ## The handshake must have been completed and the certificate chain must
+    ## have been verified successfully or else an empty sequence is returned.
+    ## The chain is ordered from leaf certificate to root certificate.
+    result = newSeq[Certificate]()
+    if SSL_get_verify_result(sslHandle) != X509_V_OK:
+      return
+    let stack = SSL_get0_verified_chain(sslHandle)
+    if stack == nil:
+      return
+    let length = OPENSSL_sk_num(stack)
+    if length == 0:
+      return
+    for i in 0 .. length - 1:
+      let x509 = cast[PX509](OPENSSL_sk_value(stack, i))
+      result.add(i2d_X509(x509))
+
+  proc getPeerCertificates*(socket: Socket): seq[Certificate] {.since: (1, 1).} =
+    ## Returns the certificate chain received by the peer we are connected to
+    ## through the given socket.
+    ## The handshake must have been completed and the certificate chain must
+    ## have been verified successfully or else an empty sequence is returned.
+    ## The chain is ordered from leaf certificate to root certificate.
+    if not socket.isSsl:
+      result = newSeq[Certificate]()
+    else:
+      result = getPeerCertificates(socket.sslHandle)
+
+  proc `sessionIdContext=`*(ctx: SslContext, sidCtx: string) =
+    ## Sets the session id context in which a session can be reused.
+    ## Used for permitting clients to reuse a session id instead of
+    ## doing a new handshake.
+    ##
+    ## TLS clients might attempt to resume a session using the session id context,
+    ## thus it must be set if verifyMode is set to CVerifyPeer or CVerifyPeerUseEnvVars,
+    ## otherwise the connection will fail and SslError will be raised if resumption occurs.
+    ##
+    ## - Only useful if set server-side.
+    ## - Should be unique per-application to prevent clients from malfunctioning.
+    ## - sidCtx must be at most 32 characters in length.
+    if sidCtx.len > 32:
+      raiseSSLError("sessionIdContext must be shorter than 32 characters")
+    SSL_CTX_set_session_id_context(ctx.context, sidCtx, sidCtx.len)
+
+proc getSocketError*(socket: Socket): OSErrorCode =
+  ## Checks `osLastError` for a valid error. If it has been reset it uses
+  ## the last error stored in the socket object.
+  result = osLastError()
+  if result == 0.OSErrorCode:
+    result = socket.lastError
+  if result == 0.OSErrorCode:
+    raiseOSError(result, "No valid socket error code available")
+
+proc socketError*(socket: Socket, err: int = -1, async = false,
+                  lastError = (-1).OSErrorCode,
+                  flags: set[SocketFlag] = {}) =
+  ## Raises an OSError based on the error code returned by `SSL_get_error`
+  ## (for SSL sockets) and `osLastError` otherwise.
+  ##
+  ## If `async` is `true` no error will be thrown in the case when the
+  ## error was caused by no data being available to be read.
+  ##
+  ## If `err` is not lower than 0 no exception will be raised.
+  ##
+  ## If `flags` contains `SafeDisconn`, no exception will be raised
+  ## when the error was caused by a peer disconnection.
+  when defineSsl:
+    if socket.isSsl:
+      if err <= 0:
+        var ret = SSL_get_error(socket.sslHandle, err.cint)
+        case ret
+        of SSL_ERROR_ZERO_RETURN:
+          raiseSSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
+        of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
+          if async:
+            return
+          else: raiseSSLError("Not enough data on socket.")
+        of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ:
+          if async:
+            return
+          else: raiseSSLError("Not enough data on socket.")
+        of SSL_ERROR_WANT_X509_LOOKUP:
+          raiseSSLError("Function for x509 lookup has been called.")
+        of SSL_ERROR_SYSCALL:
+          # SSL shutdown must not be done if a fatal error occurred.
+          socket.sslNoShutdown = true
+          let osErr = osLastError()
+          if not flags.isDisconnectionError(osErr):
+            var errStr = "IO error has occurred "
+            let sslErr = ERR_peek_last_error()
+            if sslErr == 0 and err == 0:
+              errStr.add "because an EOF was observed that violates the protocol"
+            elif sslErr == 0 and err == -1:
+              errStr.add "in the BIO layer"
+            else:
+              let errStr = $ERR_error_string(sslErr, nil)
+              raiseSSLError(errStr & ": " & errStr)
+            raiseOSError(osErr, errStr)
+        of SSL_ERROR_SSL:
+          # SSL shutdown must not be done if a fatal error occurred.
+          socket.sslNoShutdown = true
+          raiseSSLError()
+        else: raiseSSLError("Unknown Error")
+
+  if err == -1 and not (when defineSsl: socket.isSsl else: false):
+    var lastE = if lastError.int == -1: getSocketError(socket) else: lastError
+    if not flags.isDisconnectionError(lastE):
+      if async:
+        when useWinVersion:
+          if lastE.int32 == WSAEWOULDBLOCK:
+            return
+          else: raiseOSError(lastE)
+        else:
+          if lastE.int32 == EAGAIN or lastE.int32 == EWOULDBLOCK:
+            return
+          else: raiseOSError(lastE)
+      else: raiseOSError(lastE)
+
+proc listen*(socket: Socket, backlog = SOMAXCONN) {.tags: [ReadIOEffect].} =
+  ## Marks `socket` as accepting connections.
+  ## `Backlog` specifies the maximum length of the
+  ## queue of pending connections.
+  ##
+  ## Raises an OSError error upon failure.
+  if nativesockets.listen(socket.fd, backlog) < 0'i32:
+    raiseOSError(osLastError())
+
+proc bindAddr*(socket: Socket, port = Port(0), address = "") {.
+  tags: [ReadIOEffect].} =
+  ## Binds `address`:`port` to the socket.
+  ##
+  ## If `address` is "" then ADDR_ANY will be bound.
+  var realaddr = address
+  if realaddr == "":
+    case socket.domain
+    of AF_INET6: realaddr = "::"
+    of AF_INET: realaddr = "0.0.0.0"
+    else:
+      raise newException(ValueError,
+        "Unknown socket address family and no address specified to bindAddr")
+
+  var aiList = getAddrInfo(realaddr, port, socket.domain)
+  if bindAddr(socket.fd, aiList.ai_addr, aiList.ai_addrlen.SockLen) < 0'i32:
+    freeAddrInfo(aiList)
+    var address2: string
+    address2.addQuoted address
+    raiseOSError(osLastError(), "address: $# port: $#" % [address2, $port])
+  freeAddrInfo(aiList)
+
+proc acceptAddr*(server: Socket, client: var owned(Socket), address: var string,
+                 flags = {SocketFlag.SafeDisconn},
+                 inheritable = defined(nimInheritHandles)) {.
+                 tags: [ReadIOEffect], gcsafe.} =
+  ## Blocks until a connection is being made from a client. When a connection
+  ## is made sets `client` to the client socket and `address` to the address
+  ## of the connecting client.
+  ## This function will raise OSError if an error occurs.
+  ##
+  ## The resulting client will inherit any properties of the server socket. For
+  ## example: whether the socket is buffered or not.
+  ##
+  ## The SocketHandle associated with the resulting client will not be
+  ## inheritable by child processes by default. This can be changed via
+  ## the `inheritable` parameter.
+  ##
+  ## The `accept` call may result in an error if the connecting socket
+  ## disconnects during the duration of the `accept`. If the `SafeDisconn`
+  ## flag is specified then this error will not be raised and instead
+  ## accept will be called again.
+  if client.isNil:
+    new(client)
+  let ret = accept(server.fd, inheritable)
+  let sock = ret[0]
+
+  if sock == osInvalidSocket:
+    let err = osLastError()
+    if flags.isDisconnectionError(err):
+      acceptAddr(server, client, address, flags, inheritable)
+    raiseOSError(err)
+  else:
+    address = ret[1]
+    client.fd = sock
+    client.domain = getSockDomain(sock)
+    client.isBuffered = server.isBuffered
+
+    # Handle SSL.
+    when defineSsl:
+      if server.isSsl:
+        # We must wrap the client sock in a ssl context.
+
+        server.sslContext.wrapSocket(client)
+        ErrClearError()
+        let ret = SSL_accept(client.sslHandle)
+        socketError(client, ret, false)
+
+when false: #defineSsl:
+  proc acceptAddrSSL*(server: Socket, client: var Socket,
+                      address: var string): SSL_acceptResult {.
+                      tags: [ReadIOEffect].} =
+    ## This procedure should only be used for non-blocking **SSL** sockets.
+    ## It will immediately return with one of the following values:
+    ##
+    ## `AcceptSuccess` will be returned when a client has been successfully
+    ## accepted and the handshake has been successfully performed between
+    ## `server` and the newly connected client.
+    ##
+    ## `AcceptNoHandshake` will be returned when a client has been accepted
+    ## but no handshake could be performed. This can happen when the client
+    ## connects but does not yet initiate a handshake. In this case
+    ## `acceptAddrSSL` should be called again with the same parameters.
+    ##
+    ## `AcceptNoClient` will be returned when no client is currently attempting
+    ## to connect.
+    template doHandshake(): untyped =
+      when defineSsl:
+        if server.isSsl:
+          client.setBlocking(false)
+          # We must wrap the client sock in a ssl context.
+
+          if not client.isSsl or client.sslHandle == nil:
+            server.sslContext.wrapSocket(client)
+          ErrClearError()
+          let ret = SSL_accept(client.sslHandle)
+          while ret <= 0:
+            let err = SSL_get_error(client.sslHandle, ret)
+            if err != SSL_ERROR_WANT_ACCEPT:
+              case err
+              of SSL_ERROR_ZERO_RETURN:
+                raiseSSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
+              of SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE,
+                 SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
+                client.sslNoHandshake = true
+                return AcceptNoHandshake
+              of SSL_ERROR_WANT_X509_LOOKUP:
+                raiseSSLError("Function for x509 lookup has been called.")
+              of SSL_ERROR_SYSCALL, SSL_ERROR_SSL:
+                raiseSSLError()
+              else:
+                raiseSSLError("Unknown error")
+          client.sslNoHandshake = false
+
+    if client.isSsl and client.sslNoHandshake:
+      doHandshake()
+      return AcceptSuccess
+    else:
+      acceptAddrPlain(AcceptNoClient, AcceptSuccess):
+        doHandshake()
+
+proc accept*(server: Socket, client: var owned(Socket),
+             flags = {SocketFlag.SafeDisconn},
+             inheritable = defined(nimInheritHandles))
+            {.tags: [ReadIOEffect].} =
+  ## Equivalent to `acceptAddr` but doesn't return the address, only the
+  ## socket.
+  ##
+  ## The SocketHandle associated with the resulting client will not be
+  ## inheritable by child processes by default. This can be changed via
+  ## the `inheritable` parameter.
+  ##
+  ## The `accept` call may result in an error if the connecting socket
+  ## disconnects during the duration of the `accept`. If the `SafeDisconn`
+  ## flag is specified then this error will not be raised and instead
+  ## accept will be called again.
+  var addrDummy = ""
+  acceptAddr(server, client, addrDummy, flags)
+
+when defined(posix) and not defined(lwip):
+  from std/posix import Sigset, sigwait, sigismember, sigemptyset, sigaddset,
+    sigprocmask, pthread_sigmask, SIGPIPE, SIG_BLOCK, SIG_UNBLOCK
+
+template blockSigpipe(body: untyped): untyped =
+  ## Temporary block SIGPIPE within the provided code block. If SIGPIPE is
+  ## raised for the duration of the code block, it will be queued and will be
+  ## raised once the block ends.
+  ##
+  ## Within the block a `selectSigpipe()` template is provided which can be
+  ## used to remove SIGPIPE from the queue. Note that if SIGPIPE is **not**
+  ## raised at the time of call, it will block until SIGPIPE is raised.
+  ##
+  ## If SIGPIPE has already been blocked at the time of execution, the
+  ## signal mask is left as-is and `selectSigpipe()` will become a no-op.
+  ##
+  ## For convenience, this template is also available for non-POSIX system,
+  ## where `body` will be executed as-is.
+  when not defined(posix) or defined(lwip):
+    body
+  else:
+    template sigmask(how: cint, set, oset: var Sigset): untyped {.gensym.} =
+      ## Alias for pthread_sigmask or sigprocmask depending on the status
+      ## of --threads
+      when compileOption("threads"):
+        pthread_sigmask(how, set, oset)
+      else:
+        sigprocmask(how, set, oset)
+
+    var oldSet, watchSet: Sigset
+    if sigemptyset(oldSet) == -1:
+      raiseOSError(osLastError())
+    if sigemptyset(watchSet) == -1:
+      raiseOSError(osLastError())
+
+    if sigaddset(watchSet, SIGPIPE) == -1:
+      raiseOSError(osLastError(), "Couldn't add SIGPIPE to Sigset")
+
+    if sigmask(SIG_BLOCK, watchSet, oldSet) == -1:
+      raiseOSError(osLastError(), "Couldn't block SIGPIPE")
+
+    let alreadyBlocked = sigismember(oldSet, SIGPIPE) == 1
+
+    template selectSigpipe(): untyped {.used.} =
+      if not alreadyBlocked:
+        var signal: cint
+        let err = sigwait(watchSet, signal)
+        if err != 0:
+          raiseOSError(err.OSErrorCode, "Couldn't select SIGPIPE")
+        assert signal == SIGPIPE
+
+    try:
+      body
+    finally:
+      if not alreadyBlocked:
+        if sigmask(SIG_UNBLOCK, watchSet, oldSet) == -1:
+          raiseOSError(osLastError(), "Couldn't unblock SIGPIPE")
+
+proc close*(socket: Socket, flags = {SocketFlag.SafeDisconn}) =
+  ## Closes a socket.
+  ##
+  ## If `socket` is an SSL/TLS socket, this proc will also send a closure
+  ## notification to the peer. If `SafeDisconn` is in `flags`, failure to do so
+  ## due to disconnections will be ignored. This is generally safe in
+  ## practice. See
+  ## `here <https://security.stackexchange.com/a/82044>`_ for more details.
+  try:
+    when defineSsl:
+      if socket.isSsl and socket.sslHandle != nil:
+        # Don't call SSL_shutdown if the connection has not been fully
+        # established, see:
+        # https://github.com/openssl/openssl/issues/710#issuecomment-253897666
+        if not socket.sslNoShutdown and SSL_in_init(socket.sslHandle) == 0:
+          # As we are closing the underlying socket immediately afterwards,
+          # it is valid, under the TLS standard, to perform a unidirectional
+          # shutdown i.e not wait for the peers "close notify" alert with a second
+          # call to SSL_shutdown
+          blockSigpipe:
+            ErrClearError()
+            let res = SSL_shutdown(socket.sslHandle)
+            if res == 0:
+              discard
+            elif res != 1:
+              let
+                err = osLastError()
+                sslError = SSL_get_error(socket.sslHandle, res)
+
+              # If a close notification is received, failures outside of the
+              # protocol will be returned as SSL_ERROR_ZERO_RETURN instead
+              # of SSL_ERROR_SYSCALL. This fact is deduced by digging into
+              # SSL_get_error() source code.
+              if sslError == SSL_ERROR_ZERO_RETURN or
+                 sslError == SSL_ERROR_SYSCALL:
+                when defined(posix) and not defined(macosx) and
+                     not defined(nimdoc):
+                  if err == EPIPE.OSErrorCode:
+                    # Clear the SIGPIPE that's been raised due to
+                    # the disconnection.
+                    selectSigpipe()
+                else:
+                  discard
+                if not flags.isDisconnectionError(err):
+                  socketError(socket, res, lastError = err, flags = flags)
+              else:
+                socketError(socket, res, lastError = err, flags = flags)
+  finally:
+    when defineSsl:
+      if socket.isSsl and socket.sslHandle != nil:
+        SSL_free(socket.sslHandle)
+        socket.sslHandle = nil
+
+    socket.fd.close()
+    socket.fd = osInvalidSocket
+
+when defined(posix):
+  from std/posix import TCP_NODELAY
+else:
+  from std/winlean import TCP_NODELAY
+
+proc toCInt*(opt: SOBool): cint =
+  ## Converts a `SOBool` into its Socket Option cint representation.
+  case opt
+  of OptAcceptConn: SO_ACCEPTCONN
+  of OptBroadcast: SO_BROADCAST
+  of OptDebug: SO_DEBUG
+  of OptDontRoute: SO_DONTROUTE
+  of OptKeepAlive: SO_KEEPALIVE
+  of OptOOBInline: SO_OOBINLINE
+  of OptReuseAddr: SO_REUSEADDR
+  of OptReusePort: SO_REUSEPORT
+  of OptNoDelay: TCP_NODELAY
+
+proc getSockOpt*(socket: Socket, opt: SOBool, level = SOL_SOCKET): bool {.
+  tags: [ReadIOEffect].} =
+  ## Retrieves option `opt` as a boolean value.
+  var res = getSockOptInt(socket.fd, cint(level), toCInt(opt))
+  result = res != 0
+
+proc getLocalAddr*(socket: Socket): (string, Port) =
+  ## Get the socket's local address and port number.
+  ##
+  ## This is high-level interface for `getsockname`:idx:.
+  getLocalAddr(socket.fd, socket.domain)
+
+when not useNimNetLite:
+  proc getPeerAddr*(socket: Socket): (string, Port) =
+    ## Get the socket's peer address and port number.
+    ##
+    ## This is high-level interface for `getpeername`:idx:.
+    getPeerAddr(socket.fd, socket.domain)
+
+proc setSockOpt*(socket: Socket, opt: SOBool, value: bool,
+    level = SOL_SOCKET) {.tags: [WriteIOEffect].} =
+  ## Sets option `opt` to a boolean value specified by `value`.
+  runnableExamples("-r:off"):
+    let socket = newSocket()
+    socket.setSockOpt(OptReusePort, true)
+    socket.setSockOpt(OptNoDelay, true, level = IPPROTO_TCP.cint)
+  var valuei = cint(if value: 1 else: 0)
+  setSockOptInt(socket.fd, cint(level), toCInt(opt), valuei)
+
+when defined(nimdoc) or (defined(posix) and not useNimNetLite):
+  proc connectUnix*(socket: Socket, path: string) =
+    ## Connects to Unix socket on `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    when not defined(nimdoc):
+      var socketAddr = makeUnixAddr(path)
+      if socket.fd.connect(cast[ptr SockAddr](addr socketAddr),
+          (offsetOf(socketAddr, sun_path) + path.len + 1).SockLen) != 0'i32:
+        raiseOSError(osLastError())
+
+  proc bindUnix*(socket: Socket, path: string) =
+    ## Binds Unix socket to `path`.
+    ## This only works on Unix-style systems: Mac OS X, BSD and Linux
+    when not defined(nimdoc):
+      var socketAddr = makeUnixAddr(path)
+      if socket.fd.bindAddr(cast[ptr SockAddr](addr socketAddr),
+          (offsetOf(socketAddr, sun_path) + path.len + 1).SockLen) != 0'i32:
+        raiseOSError(osLastError())
+
+when defineSsl:
+  proc gotHandshake*(socket: Socket): bool =
+    ## Determines whether a handshake has occurred between a client (`socket`)
+    ## and the server that `socket` is connected to.
+    ##
+    ## Throws SslError if `socket` is not an SSL socket.
+    if socket.isSsl:
+      return not socket.sslNoHandshake
+    else:
+      raiseSSLError("Socket is not an SSL socket.")
+
+proc hasDataBuffered*(s: Socket): bool =
+  ## Determines whether a socket has data buffered.
+  result = false
+  if s.isBuffered:
+    result = s.bufLen > 0 and s.currPos != s.bufLen
+
+  when defineSsl:
+    if s.isSsl and not result:
+      result = s.sslHasPeekChar
+
+proc isClosed(socket: Socket): bool =
+  socket.fd == osInvalidSocket
+
+proc uniRecv(socket: Socket, buffer: pointer, size, flags: cint): int =
+  ## Handles SSL and non-ssl recv in a nice package.
+  ##
+  ## In particular handles the case where socket has been closed properly
+  ## for both SSL and non-ssl.
+  result = 0
+  assert(not socket.isClosed, "Cannot `recv` on a closed socket")
+  when defineSsl:
+    if socket.isSsl:
+      ErrClearError()
+      return SSL_read(socket.sslHandle, buffer, size)
+
+  return recv(socket.fd, buffer, size, flags)
+
+proc readIntoBuf(socket: Socket, flags: int32): int =
+  result = 0
+  result = uniRecv(socket, addr(socket.buffer), socket.buffer.high, flags)
+  if result < 0:
+    # Save it in case it gets reset (the Nim codegen occasionally may call
+    # Win API functions which reset it).
+    socket.lastError = osLastError()
+  if result <= 0:
+    socket.bufLen = 0
+    socket.currPos = 0
+    return result
+  socket.bufLen = result
+  socket.currPos = 0
+
+template retRead(flags, readBytes: int) {.dirty.} =
+  let res = socket.readIntoBuf(flags.int32)
+  if res <= 0:
+    if readBytes > 0:
+      return readBytes
+    else:
+      return res
+
+proc recv*(socket: Socket, data: pointer, size: int): int {.tags: [
+    ReadIOEffect].} =
+  ## Receives data from a socket.
+  ##
+  ## **Note**: This is a low-level function, you may be interested in the higher
+  ## level versions of this function which are also named `recv`.
+  if size == 0: return
+  if socket.isBuffered:
+    if socket.bufLen == 0:
+      retRead(0'i32, 0)
+
+    var read = 0
+    while read < size:
+      if socket.currPos >= socket.bufLen:
+        retRead(0'i32, read)
+
+      let chunk = min(socket.bufLen-socket.currPos, size-read)
+      var d = cast[cstring](data)
+      assert size-read >= chunk
+      copyMem(addr(d[read]), addr(socket.buffer[socket.currPos]), chunk)
+      read.inc(chunk)
+      socket.currPos.inc(chunk)
+
+    result = read
+  else:
+    when defineSsl:
+      if socket.isSsl:
+        if socket.sslHasPeekChar: # TODO: Merge this peek char mess into uniRecv
+          copyMem(data, addr(socket.sslPeekChar), 1)
+          socket.sslHasPeekChar = false
+          if size-1 > 0:
+            var d = cast[cstring](data)
+            result = uniRecv(socket, addr(d[1]), cint(size-1), 0'i32) + 1
+          else:
+            result = 1
+        else:
+          result = uniRecv(socket, data, size.cint, 0'i32)
+      else:
+        result = recv(socket.fd, data, size.cint, 0'i32)
+    else:
+      result = recv(socket.fd, data, size.cint, 0'i32)
+    if result < 0:
+      # Save the error in case it gets reset.
+      socket.lastError = osLastError()
+
+proc waitFor(socket: Socket, waited: var Duration, timeout, size: int,
+             funcName: string): int {.tags: [TimeEffect].} =
+  ## determines the amount of characters that can be read. Result will never
+  ## be larger than `size`. For unbuffered sockets this will be `1`.
+  ## For buffered sockets it can be as big as `BufferSize`.
+  ##
+  ## If this function does not determine that there is data on the socket
+  ## within `timeout` ms, a TimeoutError error will be raised.
+  result = 1
+  if size <= 0: assert false
+  if timeout == -1: return size
+  if socket.isBuffered and socket.bufLen != 0 and
+      socket.bufLen != socket.currPos:
+    result = socket.bufLen - socket.currPos
+    result = min(result, size)
+  else:
+    if timeout - waited.inMilliseconds < 1:
+      raise newException(TimeoutError, "Call to '" & funcName & "' timed out.")
+
+    when defineSsl:
+      if socket.isSsl:
+        if socket.hasDataBuffered:
+          # sslPeekChar is present.
+          return 1
+        let sslPending = SSL_pending(socket.sslHandle)
+        if sslPending != 0:
+          return min(sslPending, size)
+
+    var startTime = getMonoTime()
+    let selRet = if socket.hasDataBuffered: 1
+      else:
+        timeoutRead(socket.fd, (timeout - waited.inMilliseconds).int)
+    if selRet < 0: raiseOSError(osLastError())
+    if selRet != 1:
+      raise newException(TimeoutError, "Call to '" & funcName & "' timed out.")
+    waited += (getMonoTime() - startTime)
+
+proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {.
+  tags: [ReadIOEffect, TimeEffect].} =
+  ## overload with a `timeout` parameter in milliseconds.
+  var waited: Duration # duration already waited
+
+  var read = 0
+  while read < size:
+    let avail = waitFor(socket, waited, timeout, size-read, "recv")
+    var d = cast[cstring](data)
+    assert avail <= size-read
+    result = recv(socket, addr(d[read]), avail)
+    if result == 0: break
+    if result < 0:
+      return result
+    inc(read, result)
+
+  result = read
+
+proc recv*(socket: Socket, data: var string, size: int, timeout = -1,
+           flags = {SocketFlag.SafeDisconn}): int =
+  ## Higher-level version of `recv`.
+  ##
+  ## Reads **up to** `size` bytes from `socket` into `data`.
+  ##
+  ## For buffered sockets this function will attempt to read all the requested
+  ## data. It will read this data in `BufferSize` chunks.
+  ##
+  ## For unbuffered sockets this function makes no effort to read
+  ## all the data requested. It will return as much data as the operating system
+  ## gives it.
+  ##
+  ## When 0 is returned the socket's connection has been closed.
+  ##
+  ## This function will throw an OSError exception when an error occurs. A value
+  ## lower than 0 is never returned.
+  ##
+  ## A timeout may be specified in milliseconds, if enough data is not received
+  ## within the time specified a TimeoutError exception will be raised.
+  ##
+  ## .. warning:: Only the `SafeDisconn` flag is currently supported.
+  data.setLen(size)
+  result =
+    if timeout == -1:
+      recv(socket, cstring(data), size)
+    else:
+      recv(socket, cstring(data), size, timeout)
+  if result < 0:
+    data.setLen(0)
+    let lastError = getSocketError(socket)
+    socket.socketError(result, lastError = lastError, flags = flags)
+  else:
+    data.setLen(result)
+
+proc recv*(socket: Socket, size: int, timeout = -1,
+           flags = {SocketFlag.SafeDisconn}): string {.inline.} =
+  ## Higher-level version of `recv` which returns a string.
+  ##
+  ## Reads **up to** `size` bytes from `socket` into the result.
+  ##
+  ## For buffered sockets this function will attempt to read all the requested
+  ## data. It will read this data in `BufferSize` chunks.
+  ##
+  ## For unbuffered sockets this function makes no effort to read
+  ## all the data requested. It will return as much data as the operating system
+  ## gives it.
+  ##
+  ## When `""` is returned the socket's connection has been closed.
+  ##
+  ## This function will throw an OSError exception when an error occurs.
+  ##
+  ## A timeout may be specified in milliseconds, if enough data is not received
+  ## within the time specified a TimeoutError exception will be raised.
+  ##
+  ##
+  ## .. warning:: Only the `SafeDisconn` flag is currently supported.
+  result = newString(size)
+  discard recv(socket, result, size, timeout, flags)
+
+proc peekChar(socket: Socket, c: var char): int {.tags: [ReadIOEffect].} =
+  if socket.isBuffered:
+    result = 1
+    if socket.bufLen == 0 or socket.currPos > socket.bufLen-1:
+      var res = socket.readIntoBuf(0'i32)
+      if res <= 0:
+        result = res
+
+    c = socket.buffer[socket.currPos]
+  else:
+    when defineSsl:
+      if socket.isSsl:
+        if not socket.sslHasPeekChar:
+          result = uniRecv(socket, addr(socket.sslPeekChar), 1, 0'i32)
+          socket.sslHasPeekChar = true
+
+        c = socket.sslPeekChar
+        return
+    result = recv(socket.fd, addr(c), 1, MSG_PEEK)
+
+proc readLine*(socket: Socket, line: var string, timeout = -1,
+               flags = {SocketFlag.SafeDisconn}, maxLength = MaxLineLength) {.
+  tags: [ReadIOEffect, TimeEffect].} =
+  ## Reads a line of data from `socket`.
+  ##
+  ## If a full line is read `\r\L` is not
+  ## added to `line`, however if solely `\r\L` is read then `line`
+  ## will be set to it.
+  ##
+  ## If the socket is disconnected, `line` will be set to `""`.
+  ##
+  ## An OSError exception will be raised in the case of a socket error.
+  ##
+  ## A timeout can be specified in milliseconds, if data is not received within
+  ## the specified time a TimeoutError exception will be raised.
+  ##
+  ## The `maxLength` parameter determines the maximum amount of characters
+  ## that can be read. The result is truncated after that.
+  ##
+  ## .. warning:: Only the `SafeDisconn` flag is currently supported.
+
+  template addNLIfEmpty() =
+    if line.len == 0:
+      line.add("\c\L")
+
+  template raiseSockError() {.dirty.} =
+    let lastError = getSocketError(socket)
+    if flags.isDisconnectionError(lastError):
+      setLen(line, 0)
+    socket.socketError(n, lastError = lastError, flags = flags)
+    return
+
+  var waited: Duration
+
+  setLen(line, 0)
+  while true:
+    var c: char
+    discard waitFor(socket, waited, timeout, 1, "readLine")
+    var n = recv(socket, addr(c), 1)
+    if n < 0: raiseSockError()
+    elif n == 0: setLen(line, 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: raiseSockError()
+      addNLIfEmpty()
+      return
+    elif c == '\L':
+      addNLIfEmpty()
+      return
+    add(line, c)
+
+    # Verify that this isn't a DOS attack: #3847.
+    if line.len > maxLength: break
+
+proc recvLine*(socket: Socket, timeout = -1,
+               flags = {SocketFlag.SafeDisconn},
+               maxLength = MaxLineLength): string =
+  ## Reads a line of data from `socket`.
+  ##
+  ## If a full line is read `\r\L` is not
+  ## added to the result, however if solely `\r\L` is read then the result
+  ## will be set to it.
+  ##
+  ## If the socket is disconnected, the result will be set to `""`.
+  ##
+  ## An OSError exception will be raised in the case of a socket error.
+  ##
+  ## A timeout can be specified in milliseconds, if data is not received within
+  ## the specified time a TimeoutError exception will be raised.
+  ##
+  ## The `maxLength` parameter determines the maximum amount of characters
+  ## that can be read. The result is truncated after that.
+  ##
+  ## .. warning:: Only the `SafeDisconn` flag is currently supported.
+  result = ""
+  readLine(socket, result, timeout, flags, maxLength)
+
+proc recvFrom*[T: string | IpAddress](socket: Socket, data: var string, length: int,
+               address: var T, port: var Port, flags = 0'i32): int {.
+               tags: [ReadIOEffect].} =
+  ## Receives data from `socket`. This function should normally be used with
+  ## connection-less sockets (UDP sockets). The source address of the data
+  ## packet is stored in the `address` argument as either a string or an IpAddress.
+  ##
+  ## If an error occurs an OSError exception will be raised. Otherwise the return
+  ## value will be the length of data received.
+  ##
+  ## .. warning:: This function does not yet have a buffered implementation,
+  ##   so when `socket` is buffered the non-buffered implementation will be
+  ##   used. Therefore if `socket` contains something in its buffer this
+  ##   function will make no effort to return it.
+  template adaptRecvFromToDomain(sockAddress: untyped, domain: Domain) =
+    var addrLen = SockLen(sizeof(sockAddress))
+    result = recvfrom(socket.fd, cstring(data), length.cint, flags.cint,
+                      cast[ptr SockAddr](addr(sockAddress)), addr(addrLen))
+
+    if result != -1:
+      data.setLen(result)
+
+      when typeof(address) is string:
+        address = getAddrString(cast[ptr SockAddr](addr(sockAddress)))
+        when domain == AF_INET6:
+          port = ntohs(sockAddress.sin6_port).Port
+        else:
+          port = ntohs(sockAddress.sin_port).Port
+      else:
+        data.setLen(result)
+        sockAddress.fromSockAddr(addrLen, address, port)
+    else:
+      raiseOSError(osLastError())
+
+  assert(socket.protocol != IPPROTO_TCP, "Cannot `recvFrom` on a TCP socket")
+  # TODO: Buffered sockets
+  data.setLen(length)
+
+  case socket.domain
+  of AF_INET6:
+    var sockAddress: Sockaddr_in6
+    adaptRecvFromToDomain(sockAddress, AF_INET6)
+  of AF_INET:
+    var sockAddress: Sockaddr_in
+    adaptRecvFromToDomain(sockAddress, AF_INET)
+  else:
+    raise newException(ValueError, "Unknown socket address family")
+
+proc skip*(socket: Socket, size: int, timeout = -1) =
+  ## Skips `size` amount of bytes.
+  ##
+  ## An optional timeout can be specified in milliseconds, if skipping the
+  ## bytes takes longer than specified a TimeoutError exception will be raised.
+  ##
+  ## Returns the number of skipped bytes.
+  var waited: Duration
+  var dummy = alloc(size)
+  var bytesSkipped = 0
+  while bytesSkipped != size:
+    let avail = waitFor(socket, waited, timeout, size-bytesSkipped, "skip")
+    bytesSkipped += recv(socket, dummy, avail)
+  dealloc(dummy)
+
+proc send*(socket: Socket, data: pointer, size: int): int {.
+  tags: [WriteIOEffect].} =
+  ## Sends data to a socket.
+  ##
+  ## **Note**: This is a low-level version of `send`. You likely should use
+  ## the version below.
+  assert(not socket.isClosed, "Cannot `send` on a closed socket")
+  when defineSsl:
+    if socket.isSsl:
+      ErrClearError()
+      return SSL_write(socket.sslHandle, cast[cstring](data), size)
+
+  when useWinVersion or defined(macosx):
+    result = send(socket.fd, data, size.cint, 0'i32)
+  else:
+    when defined(solaris):
+      const MSG_NOSIGNAL = 0
+    result = send(socket.fd, data, size, int32(MSG_NOSIGNAL))
+
+proc send*(socket: Socket, data: string,
+           flags = {SocketFlag.SafeDisconn}, maxRetries = 100) {.tags: [WriteIOEffect].} =
+  ## Sends data to a socket. Will try to send all the data by handling interrupts
+  ## and incomplete writes up to `maxRetries`.
+  var written = 0
+  var attempts = 0
+  while data.len - written > 0:
+    let sent = send(socket, cstring(data), data.len)
+
+    if sent < 0:
+      let lastError = osLastError()
+      let isBlockingErr =
+        when defined(nimdoc):
+          false
+        elif useWinVersion:
+          lastError.int32 == WSAEINTR or
+          lastError.int32 == WSAEWOULDBLOCK
+        else:
+          lastError.int32 == EINTR or
+          lastError.int32 == EWOULDBLOCK or
+          lastError.int32 == EAGAIN
+
+      if not isBlockingErr:
+        let lastError = osLastError()
+        socketError(socket, lastError = lastError, flags = flags)
+      else:
+        attempts.inc()
+        if attempts > maxRetries:
+          raiseOSError(osLastError(), "Could not send all data.")
+    else:
+      written.inc(sent)
+
+template `&=`*(socket: Socket; data: typed) =
+  ## an alias for 'send'.
+  send(socket, data)
+
+proc trySend*(socket: Socket, data: string): bool {.tags: [WriteIOEffect].} =
+  ## Safe alternative to `send`. Does not raise an OSError when an error occurs,
+  ## and instead returns `false` on failure.
+  result = send(socket, cstring(data), data.len) == data.len
+
+proc sendTo*(socket: Socket, address: string, port: Port, data: pointer,
+             size: int, af: Domain = AF_INET, flags = 0'i32) {.
+             tags: [WriteIOEffect].} =
+  ## This proc sends `data` to the specified `address`,
+  ## which may be an IP address or a hostname, if a hostname is specified
+  ## this function will try each IP of that hostname. This function
+  ## should normally be used with connection-less sockets (UDP sockets).
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## **Note:** You may wish to use the high-level version of this function
+  ## which is defined below.
+  ##
+  ## **Note:** This proc is not available for SSL sockets.
+  assert(socket.protocol != IPPROTO_TCP, "Cannot `sendTo` on a TCP socket")
+  assert(not socket.isClosed, "Cannot `sendTo` on a closed socket")
+  var aiList = getAddrInfo(address, port, af, socket.sockType, socket.protocol)
+  # try all possibilities:
+  var success = false
+  var it = aiList
+  var result = 0
+  while it != nil:
+    result = sendto(socket.fd, data, size.cint, flags.cint, it.ai_addr,
+                    it.ai_addrlen.SockLen)
+    if result != -1'i32:
+      success = true
+      break
+    it = it.ai_next
+
+  let osError = osLastError()
+  freeAddrInfo(aiList)
+
+  if not success:
+    raiseOSError(osError)
+
+proc sendTo*(socket: Socket, address: string, port: Port,
+             data: string) {.tags: [WriteIOEffect].} =
+  ## This proc sends `data` to the specified `address`,
+  ## which may be an IP address or a hostname, if a hostname is specified
+  ## this function will try each IP of that hostname.
+  ##
+  ## Generally for use with connection-less (UDP) sockets.
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## This is the high-level version of the above `sendTo` function.
+  socket.sendTo(address, port, cstring(data), data.len, socket.domain)
+
+proc sendTo*(socket: Socket, address: IpAddress, port: Port,
+             data: string, flags = 0'i32): int {.
+              discardable, tags: [WriteIOEffect].} =
+  ## This proc sends `data` to the specified `IpAddress` and returns
+  ## the number of bytes written.
+  ##
+  ## Generally for use with connection-less (UDP) sockets.
+  ##
+  ## If an error occurs an OSError exception will be raised.
+  ##
+  ## This is the high-level version of the above `sendTo` function.
+  assert(socket.protocol != IPPROTO_TCP, "Cannot `sendTo` on a TCP socket")
+  assert(not socket.isClosed, "Cannot `sendTo` on a closed socket")
+
+  var sa: Sockaddr_storage
+  var sl: SockLen
+  toSockAddr(address, port, sa, sl)
+  result = sendto(socket.fd, cstring(data), data.len().cint, flags.cint,
+                  cast[ptr SockAddr](addr sa), sl)
+
+  if result == -1'i32:
+    let osError = osLastError()
+    raiseOSError(osError)
+
+
+proc isSsl*(socket: Socket): bool =
+  ## Determines whether `socket` is a SSL socket.
+  when defineSsl:
+    result = socket.isSsl
+  else:
+    result = false
+
+proc getFd*(socket: Socket): SocketHandle = return socket.fd
+  ## Returns the socket's file descriptor
+
+when defined(zephyr) or defined(nimNetSocketExtras): # Remove in future
+  proc getDomain*(socket: Socket): Domain = return socket.domain
+    ## Returns the socket's domain
+
+  proc getType*(socket: Socket): SockType = return socket.sockType
+    ## Returns the socket's type
+
+  proc getProtocol*(socket: Socket): Protocol = return socket.protocol
+    ## Returns the socket's protocol
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+proc IPv4_any*(): IpAddress =
+  ## Returns the IPv4 any address, which can be used to listen on all available
+  ## network adapters
+  result = IpAddress(
+    family: IpAddressFamily.IPv4,
+    address_v4: [0'u8, 0, 0, 0])
+
+proc IPv4_loopback*(): IpAddress =
+  ## Returns the IPv4 loopback address (127.0.0.1)
+  result = IpAddress(
+    family: IpAddressFamily.IPv4,
+    address_v4: [127'u8, 0, 0, 1])
+
+proc IPv4_broadcast*(): IpAddress =
+  ## Returns the IPv4 broadcast address (255.255.255.255)
+  result = IpAddress(
+    family: IpAddressFamily.IPv4,
+    address_v4: [255'u8, 255, 255, 255])
+
+proc IPv6_any*(): IpAddress =
+  ## Returns the IPv6 any address (::0), which can be used
+  ## to listen on all available network adapters
+  result = IpAddress(
+    family: IpAddressFamily.IPv6,
+    address_v6: [0'u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
+
+proc IPv6_loopback*(): IpAddress =
+  ## Returns the IPv6 loopback address (::1)
+  result = IpAddress(
+    family: IpAddressFamily.IPv6,
+    address_v6: [0'u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
+
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+proc `==`*(lhs, rhs: IpAddress): bool =
+  ## Compares two IpAddresses for Equality. Returns true if the addresses are equal
+  if lhs.family != rhs.family: return false
+  if lhs.family == IpAddressFamily.IPv4:
+    for i in low(lhs.address_v4) .. high(lhs.address_v4):
+      if lhs.address_v4[i] != rhs.address_v4[i]: return false
+  else: # IPv6
+    for i in low(lhs.address_v6) .. high(lhs.address_v6):
+      if lhs.address_v6[i] != rhs.address_v6[i]: return false
+  return true
+
+proc `$`*(address: IpAddress): string =
+  ## Converts an IpAddress into the textual representation
+  case address.family
+  of IpAddressFamily.IPv4:
+    result = newStringOfCap(15)
+    result.addInt address.address_v4[0]
+    result.add '.'
+    result.addInt address.address_v4[1]
+    result.add '.'
+    result.addInt address.address_v4[2]
+    result.add '.'
+    result.addInt address.address_v4[3]
+  of IpAddressFamily.IPv6:
+    result = newStringOfCap(39)
+    var
+      currentZeroStart = -1
+      currentZeroCount = 0
+      biggestZeroStart = -1
+      biggestZeroCount = 0
+    # Look for the largest block of zeros
+    for i in 0..7:
+      var isZero = address.address_v6[i*2] == 0 and address.address_v6[i*2+1] == 0
+      if isZero:
+        if currentZeroStart == -1:
+          currentZeroStart = i
+          currentZeroCount = 1
+        else:
+          currentZeroCount.inc()
+        if currentZeroCount > biggestZeroCount:
+          biggestZeroCount = currentZeroCount
+          biggestZeroStart = currentZeroStart
+      else:
+        currentZeroStart = -1
+
+    if biggestZeroCount == 8: # Special case ::0
+      result.add("::")
+    else: # Print address
+      var printedLastGroup = false
+      for i in 0..7:
+        var word: uint16 = (cast[uint16](address.address_v6[i*2])) shl 8
+        word = word or cast[uint16](address.address_v6[i*2+1])
+
+        if biggestZeroCount != 0 and # Check if group is in skip group
+          (i >= biggestZeroStart and i < (biggestZeroStart + biggestZeroCount)):
+          if i == biggestZeroStart: # skip start
+            result.add("::")
+          printedLastGroup = false
+        else:
+          if printedLastGroup:
+            result.add(':')
+          var
+            afterLeadingZeros = false
+            mask = 0xF000'u16
+          for j in 0'u16..3'u16:
+            var val = (mask and word) shr (4'u16*(3'u16-j))
+            if val != 0 or afterLeadingZeros:
+              if val < 0xA:
+                result.add(chr(uint16(ord('0'))+val))
+              else: # val >= 0xA
+                result.add(chr(uint16(ord('a'))+val-0xA))
+              afterLeadingZeros = true
+            mask = mask shr 4
+
+          if not afterLeadingZeros:
+            result.add '0'
+
+          printedLastGroup = true
+
+proc dial*(address: string, port: Port,
+           protocol = IPPROTO_TCP, buffered = true): owned(Socket)
+           {.tags: [ReadIOEffect, WriteIOEffect].} =
+  ## Establishes connection to the specified `address`:`port` pair via the
+  ## specified protocol. The procedure iterates through possible
+  ## resolutions of the `address` until it succeeds, meaning that it
+  ## seamlessly works with both IPv4 and IPv6.
+  ## Returns Socket ready to send or receive data.
+  let sockType = protocol.toSockType()
+
+  let aiList = getAddrInfo(address, port, AF_UNSPEC, sockType, protocol)
+
+  var fdPerDomain: array[low(Domain).ord..high(Domain).ord, SocketHandle]
+  for i in low(fdPerDomain)..high(fdPerDomain):
+    fdPerDomain[i] = osInvalidSocket
+  template closeUnusedFds(domainToKeep = -1) {.dirty.} =
+    for i, fd in fdPerDomain:
+      if fd != osInvalidSocket and i != domainToKeep:
+        fd.close()
+
+  var success = false
+  var lastError: OSErrorCode
+  var it = aiList
+  var domain: Domain
+  var lastFd: SocketHandle
+  while it != nil:
+    let domainOpt = it.ai_family.toKnownDomain()
+    if domainOpt.isNone:
+      it = it.ai_next
+      continue
+    domain = domainOpt.unsafeGet()
+    lastFd = fdPerDomain[ord(domain)]
+    if lastFd == osInvalidSocket:
+      lastFd = createNativeSocket(domain, sockType, protocol)
+      if lastFd == osInvalidSocket:
+        # we always raise if socket creation failed, because it means a
+        # network system problem (e.g. not enough FDs), and not an unreachable
+        # address.
+        let err = osLastError()
+        freeAddrInfo(aiList)
+        closeUnusedFds()
+        raiseOSError(err)
+      fdPerDomain[ord(domain)] = lastFd
+    if connect(lastFd, it.ai_addr, it.ai_addrlen.SockLen) == 0'i32:
+      success = true
+      break
+    lastError = osLastError()
+    it = it.ai_next
+  freeAddrInfo(aiList)
+  closeUnusedFds(ord(domain))
+
+  if success:
+    result = newSocket(lastFd, domain, sockType, protocol, buffered)
+  elif lastError != 0.OSErrorCode:
+    lastFd.close()
+    raiseOSError(lastError)
+  else:
+    lastFd.close()
+    raise newException(IOError, "Couldn't resolve address: " & address)
+
+proc connect*(socket: Socket, address: string,
+    port = Port(0)) {.tags: [ReadIOEffect, RootEffect].} =
+  ## Connects socket to `address`:`port`. `Address` can be an IP address or a
+  ## host name. If `address` is a host name, this function will try each IP
+  ## of that host name. `htons` is already performed on `port` so you must
+  ## not do it.
+  ##
+  ## If `socket` is an SSL socket a handshake will be automatically performed.
+  var aiList = getAddrInfo(address, port, socket.domain)
+  # try all possibilities:
+  var success = false
+  var lastError: OSErrorCode
+  var it = aiList
+  while it != nil:
+    if connect(socket.fd, it.ai_addr, it.ai_addrlen.SockLen) == 0'i32:
+      success = true
+      break
+    else: lastError = osLastError()
+    it = it.ai_next
+
+  freeAddrInfo(aiList)
+  if not success: raiseOSError(lastError)
+
+  when defineSsl:
+    if socket.isSsl:
+      # RFC3546 for SNI specifies that IP addresses are not allowed.
+      if not isIpAddress(address):
+        # Discard result in case OpenSSL version doesn't support SNI, or we're
+        # not using TLSv1+
+        discard SSL_set_tlsext_host_name(socket.sslHandle, address)
+
+      ErrClearError()
+      let ret = SSL_connect(socket.sslHandle)
+      socketError(socket, ret)
+      when not defined(nimDisableCertificateValidation) and not defined(windows):
+        if not isIpAddress(address):
+          socket.checkCertName(address)
+
+proc connectAsync(socket: Socket, name: string, port = Port(0),
+                  af: Domain = AF_INET) {.tags: [ReadIOEffect].} =
+  ## A variant of `connect` for non-blocking sockets.
+  ##
+  ## This procedure will immediately return, it will not block until a connection
+  ## is made. It is up to the caller to make sure the connection has been established
+  ## by checking (using `select`) whether the socket is writeable.
+  ##
+  ## **Note**: For SSL sockets, the `handshake` procedure must be called
+  ## whenever the socket successfully connects to a server.
+  var aiList = getAddrInfo(name, port, af)
+  # try all possibilities:
+  var success = false
+  var lastError: OSErrorCode
+  var it = aiList
+  while it != nil:
+    var ret = connect(socket.fd, it.ai_addr, it.ai_addrlen.SockLen)
+    if ret == 0'i32:
+      success = true
+      break
+    else:
+      lastError = osLastError()
+      when useWinVersion:
+        # Windows EINTR doesn't behave same as POSIX.
+        if lastError.int32 == WSAEWOULDBLOCK:
+          success = true
+          break
+      else:
+        if lastError.int32 == EINTR or lastError.int32 == EINPROGRESS:
+          success = true
+          break
+
+    it = it.ai_next
+
+  freeAddrInfo(aiList)
+  if not success: raiseOSError(lastError)
+
+proc connect*(socket: Socket, address: string, port = Port(0),
+    timeout: int) {.tags: [ReadIOEffect, WriteIOEffect, RootEffect].} =
+  ## Connects to server as specified by `address` on port specified by `port`.
+  ##
+  ## The `timeout` parameter specifies the time in milliseconds to allow for
+  ## the connection to the server to be made.
+  socket.fd.setBlocking(false)
+
+  socket.connectAsync(address, port, socket.domain)
+  if timeoutWrite(socket.fd, timeout) != 1:
+    raise newException(TimeoutError, "Call to 'connect' timed out.")
+  else:
+    let res = getSockOptInt(socket.fd, SOL_SOCKET, SO_ERROR)
+    if res != 0:
+      raiseOSError(OSErrorCode(res))
+    when defineSsl and not defined(nimdoc):
+      if socket.isSsl:
+        socket.fd.setBlocking(true)
+        # RFC3546 for SNI specifies that IP addresses are not allowed.
+        if not isIpAddress(address):
+          # Discard result in case OpenSSL version doesn't support SNI, or we're
+          # not using TLSv1+
+          discard SSL_set_tlsext_host_name(socket.sslHandle, address)
+
+        ErrClearError()
+        let ret = SSL_connect(socket.sslHandle)
+        socketError(socket, ret)
+        when not defined(nimDisableCertificateValidation):
+          if not isIpAddress(address):
+            socket.checkCertName(address)
+  socket.fd.setBlocking(true)
+
+proc getPrimaryIPAddr*(dest = parseIpAddress("8.8.8.8")): IpAddress =
+  ## Finds the local IP address, usually assigned to eth0 on LAN or wlan0 on WiFi,
+  ## used to reach an external address. Useful to run local services.
+  ##
+  ## No traffic is sent.
+  ##
+  ## Supports IPv4 and v6.
+  ## Raises OSError if external networking is not set up.
+  runnableExamples("-r:off"):
+    echo getPrimaryIPAddr() # "192.168.1.2"
+  let socket =
+    if dest.family == IpAddressFamily.IPv4:
+      newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
+    else:
+      newSocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
+  try:
+    socket.connect($dest, 80.Port)
+    result = socket.getLocalAddr()[0].parseIpAddress()
+  finally:
+    socket.close()
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim
new file mode 100644
index 000000000..bf8367d1d
--- /dev/null
+++ b/lib/pure/nimprof.nim
@@ -0,0 +1,233 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Profiling support for Nim. This is an embedded profiler that requires
+## `--profiler:on`. You only need to import this module to get a profiling
+## report at program exit. See `Embedded Stack Trace Profiler <estp.html>`_
+## for usage.
+
+when not defined(profiler) and not defined(memProfiler):
+  {.error: "Profiling support is turned off! Enable profiling by passing `--profiler:on --stackTrace:on` to the compiler (see the Nim Compiler User Guide for more options).".}
+
+{.used.}
+
+# We don't want to profile the profiling code ...
+{.push profiler: off.}
+
+import std/[hashes, algorithm, strutils, tables, sets]
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, sysatomics]
+
+when not defined(memProfiler):
+  include "system/timers"
+
+const
+  withThreads = compileOption("threads")
+  tickCountCorrection = 50_000
+
+when not declared(system.StackTrace):
+  type StackTrace = object
+    lines: array[0..20, cstring]
+    files: array[0..20, cstring]
+  proc `[]`*(st: StackTrace, i: int): cstring = st.lines[i]
+
+# We use a simple hash table of bounded size to keep track of the stack traces:
+type
+  ProfileEntry = object
+    total: int
+    st: StackTrace
+  ProfileData = array[0..64*1024-1, ptr ProfileEntry]
+
+proc `==`(a, b: StackTrace): bool =
+  for i in 0 .. high(a.lines):
+    if a[i] != b[i]: return false
+  result = true
+
+# XXX extract this data structure; it is generally useful ;-)
+# However a chain length of over 3000 is suspicious...
+var
+  profileData: ProfileData
+  emptySlots = profileData.len * 3 div 2
+  maxChainLen = 0
+  totalCalls = 0
+
+when not defined(memProfiler):
+  var interval: Nanos = 5_000_000 - tickCountCorrection # 5ms
+
+  proc setSamplingFrequency*(intervalInUs: int) =
+    ## set this to change the sampling frequency. Default value is 5ms.
+    ## Set it to 0 to disable time based profiling; it uses an imprecise
+    ## instruction count measure instead then.
+    if intervalInUs <= 0: interval = 0
+    else: interval = intervalInUs * 1000 - tickCountCorrection
+
+when withThreads:
+  import std/locks
+  var
+    profilingLock: Lock
+
+  initLock profilingLock
+
+proc hookAux(st: StackTrace, costs: int) =
+  # this is quite performance sensitive!
+  when withThreads: acquire profilingLock
+  inc totalCalls
+  var last = high(st.lines)
+  while last > 0 and isNil(st[last]): dec last
+  var h = hash(pointer(st[last])) and high(profileData)
+
+  # we use probing for maxChainLen entries and replace the encountered entry
+  # with the minimal 'total' value:
+  if emptySlots == 0:
+    var minIdx = h
+    var probes = maxChainLen
+    while probes >= 0:
+      if profileData[h].st == st:
+        # wow, same entry found:
+        inc profileData[h].total, costs
+        return
+      if profileData[minIdx].total < profileData[h].total:
+        minIdx = h
+      h = ((5 * h) + 1) and high(profileData)
+      dec probes
+    profileData[minIdx].total = costs
+    profileData[minIdx].st = st
+  else:
+    var chain = 0
+    while true:
+      if profileData[h] == nil:
+        profileData[h] = cast[ptr ProfileEntry](
+                             allocShared0(sizeof(ProfileEntry)))
+        profileData[h].total = costs
+        profileData[h].st = st
+        dec emptySlots
+        break
+      if profileData[h].st == st:
+        # wow, same entry found:
+        inc profileData[h].total, costs
+        break
+      h = ((5 * h) + 1) and high(profileData)
+      inc chain
+    maxChainLen = max(maxChainLen, chain)
+  when withThreads: release profilingLock
+
+when defined(memProfiler):
+  const
+    SamplingInterval = 50_000
+  var
+    gTicker {.threadvar.}: int
+
+  proc requestedHook(): bool {.nimcall.} =
+    if gTicker == 0:
+      gTicker = SamplingInterval
+      result = true
+    dec gTicker
+
+  proc hook(st: StackTrace, size: int) {.nimcall.} =
+    when defined(ignoreAllocationSize):
+      hookAux(st, 1)
+    else:
+      hookAux(st, size)
+
+else:
+  var
+    t0 {.threadvar.}: Ticks
+    gTicker: int # we use an additional counter to
+                 # avoid calling 'getTicks' too frequently
+
+  proc requestedHook(): bool {.nimcall.} =
+    if interval == 0: result = true
+    elif gTicker == 0:
+      gTicker = 500
+      if getTicks() - t0 > interval:
+        result = true
+    else:
+      dec gTicker
+
+  proc hook(st: StackTrace) {.nimcall.} =
+    #echo "profiling! ", interval
+    if interval == 0:
+      hookAux(st, 1)
+    else:
+      hookAux(st, 1)
+      t0 = getTicks()
+
+proc getTotal(x: ptr ProfileEntry): int =
+  result = if isNil(x): 0 else: x.total
+
+proc cmpEntries(a, b: ptr ProfileEntry): int =
+  result = b.getTotal - a.getTotal
+
+proc `//`(a, b: int): string =
+  result = format("$1/$2 = $3%", a, b, formatFloat(a / b * 100.0, ffDecimal, 2))
+
+proc writeProfile() {.noconv.} =
+  system.profilingRequestedHook = nil
+  when declared(system.StackTrace):
+    system.profilerHook = nil
+  const filename = "profile_results.txt"
+  echo "writing " & filename & "..."
+  var f: File
+  if open(f, filename, fmWrite):
+    sort(profileData, cmpEntries)
+    writeLine(f, "total executions of each stack trace:")
+    var entries = 0
+    for i in 0..high(profileData):
+      if profileData[i] != nil: inc entries
+
+    var perProc = initCountTable[string]()
+    for i in 0..entries-1:
+      var dups = initHashSet[string]()
+      for ii in 0..high(StackTrace.lines):
+        let procname = profileData[i].st[ii]
+        if isNil(procname): break
+        let p = $procname
+        if not containsOrIncl(dups, p):
+          perProc.inc(p, profileData[i].total)
+
+    var sum = 0
+    # only write the first 100 entries:
+    for i in 0..min(100, entries-1):
+      if profileData[i].total > 1:
+        inc sum, profileData[i].total
+        writeLine(f, "Entry: ", i+1, "/", entries, " Calls: ",
+          profileData[i].total // totalCalls, " [sum: ", sum, "; ",
+          sum // totalCalls, "]")
+        for ii in 0..high(StackTrace.lines):
+          let procname = profileData[i].st[ii]
+          let filename = profileData[i].st.files[ii]
+          if isNil(procname): break
+          writeLine(f, "  ", $filename & ": " & $procname, " ",
+                    perProc[$procname] // totalCalls)
+    close(f)
+    echo "... done"
+  else:
+    echo "... failed"
+
+var
+  disabled: int
+
+proc disableProfiling*() =
+  when declared(system.StackTrace):
+    atomicDec disabled
+    system.profilingRequestedHook = nil
+
+proc enableProfiling*() =
+  when declared(system.StackTrace):
+    if atomicInc(disabled) >= 0:
+      system.profilingRequestedHook = requestedHook
+
+when declared(system.StackTrace):
+  import std/exitprocs
+  system.profilingRequestedHook = requestedHook
+  system.profilerHook = hook
+  addExitProc(writeProfile)
+
+{.pop.}
diff --git a/lib/pure/nimprof.nim.cfg b/lib/pure/nimprof.nim.cfg
new file mode 100644
index 000000000..1589e7394
--- /dev/null
+++ b/lib/pure/nimprof.nim.cfg
@@ -0,0 +1 @@
+--profiler:on
diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim
new file mode 100644
index 000000000..4d6ceefd7
--- /dev/null
+++ b/lib/pure/oids.nim
@@ -0,0 +1,99 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Nim OID support. An OID is a global ID that consists of a timestamp,
+## a unique counter and a random value. This combination should suffice to
+## produce a globally distributed unique ID.
+##
+## This implementation calls `initRand()` for the first call of
+## `genOid`.
+
+import std/[hashes, times, endians, random]
+from std/private/decode_helpers import handleHexChar
+
+when defined(nimPreviewSlimSystem):
+  import std/sysatomics
+
+type
+  Oid* = object ## An OID.
+    time: int64
+    fuzz: int32
+    count: int32
+
+proc `==`*(oid1: Oid, oid2: Oid): bool {.inline.} =
+  ## Compares two OIDs for equality.
+  result = (oid1.time == oid2.time) and (oid1.fuzz == oid2.fuzz) and
+          (oid1.count == oid2.count)
+
+proc hash*(oid: Oid): Hash =
+  ## Generates the hash of an OID for use in hashtables.
+  var h: Hash = 0
+  h = h !& hash(oid.time)
+  h = h !& hash(oid.fuzz)
+  h = h !& hash(oid.count)
+  result = !$h
+
+proc hexbyte*(hex: char): int {.inline.} =
+  result = handleHexChar(hex)
+
+proc parseOid*(str: cstring): Oid =
+  ## Parses an OID.
+  var bytes = cast[cstring](cast[pointer](cast[int](addr(result.time)) + 4))
+  var i = 0
+  while i < 12:
+    bytes[i] = chr((hexbyte(str[2 * i]) shl 4) or hexbyte(str[2 * i + 1]))
+    inc(i)
+
+proc `$`*(oid: Oid): string =
+  ## Converts an OID to a string.
+  const hex = "0123456789abcdef"
+
+  result.setLen 24
+
+  var o = oid
+  var bytes = cast[cstring](cast[pointer](cast[int](addr(o)) + 4))
+  var i = 0
+  while i < 12:
+    let b = bytes[i].ord
+    result[2 * i] = hex[(b and 0xF0) shr 4]
+    result[2 * i + 1] = hex[b and 0xF]
+    inc(i)
+
+let
+  t = getTime().toUnix
+
+var
+  seed = initRand(t)
+  incr: int = seed.rand(int.high)
+
+let fuzz = cast[int32](seed.rand(high(int)))
+
+
+template genOid(result: var Oid, incr: var int, fuzz: int32) =
+  var time = getTime().toUnix
+  var i = cast[int32](atomicInc(incr))
+
+  bigEndian64(addr result.time, addr(time))
+  result.fuzz = fuzz
+  bigEndian32(addr result.count, addr(i))
+
+proc genOid*(): Oid =
+  ## Generates a new OID.
+  runnableExamples:
+    doAssert ($genOid()).len == 24
+  runnableExamples("-r:off"):
+    echo $genOid() # for example, "5fc7f546ddbbc84800006aaf"
+  genOid(result, incr, fuzz)
+
+proc generatedTime*(oid: Oid): Time =
+  ## Returns the generated timestamp of the OID.
+  var tmp: int64
+  var dummy = oid.time
+  bigEndian64(addr(tmp), addr(dummy))
+  result = fromUnix(tmp)
diff --git a/lib/pure/options.nim b/lib/pure/options.nim
new file mode 100644
index 000000000..b34ff72c0
--- /dev/null
+++ b/lib/pure/options.nim
@@ -0,0 +1,381 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+##[
+This module implements types which encapsulate an optional value.
+
+A value of type `Option[T]` either contains a value `x` (represented as
+`some(x)`) or is empty (`none(T)`).
+
+This can be useful when you have a value that can be present or not. The
+absence of a value is often represented by `nil`, but that is not always
+available, nor is it always a good solution.
+
+
+Basic usage
+===========
+
+Let's start with an example: a procedure that finds the index of a character
+in a string.
+]##
+
+runnableExamples:
+  proc find(haystack: string, needle: char): Option[int] =
+    for i, c in haystack:
+      if c == needle:
+        return some(i)
+    return none(int)  # This line is actually optional,
+                      # because the default is empty
+
+  let found = "abc".find('c')
+  assert found.isSome and found.get() == 2
+
+##[
+The `get` operation demonstrated above returns the underlying value, or
+raises `UnpackDefect` if there is no value. Note that `UnpackDefect`
+inherits from `system.Defect` and should therefore never be caught.
+Instead, rely on checking if the option contains a value with the
+`isSome <#isSome,Option[T]>`_ and `isNone <#isNone,Option[T]>`_ procs.
+
+
+Pattern matching
+================
+
+.. note:: This requires the [fusion](https://github.com/nim-lang/fusion) package.
+
+[fusion/matching](https://nim-lang.github.io/fusion/src/fusion/matching.html)
+supports pattern matching on `Option`s, with the `Some(<pattern>)` and
+`None()` patterns.
+
+  ```nim
+  {.experimental: "caseStmtMacros".}
+
+  import fusion/matching
+
+  case some(42)
+  of Some(@a):
+    assert a == 42
+  of None():
+    assert false
+
+  assertMatch(some(some(none(int))), Some(Some(None())))
+  ```
+]##
+# xxx pending https://github.com/timotheecour/Nim/issues/376 use `runnableExamples` and `whichModule`
+
+when defined(nimHasEffectsOf):
+  {.experimental: "strictEffects".}
+else:
+  {.pragma: effectsOf.}
+
+import std/typetraits
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+when (NimMajor, NimMinor) >= (1, 1):
+  type
+    SomePointer = ref | ptr | pointer | proc | iterator {.closure.}
+else:
+  type
+    SomePointer = ref | ptr | pointer
+
+type
+  Option*[T] = object
+    ## An optional type that may or may not contain a value of type `T`.
+    ## When `T` is a a pointer type (`ptr`, `pointer`, `ref`, `proc` or `iterator {.closure.}`),
+    ## `none(T)` is represented as `nil`.
+    when T is SomePointer:
+      val: T
+    else:
+      val: T
+      has: bool
+
+  UnpackDefect* = object of Defect
+  UnpackError* {.deprecated: "See corresponding Defect".} = UnpackDefect
+
+proc option*[T](val: sink T): Option[T] {.inline.} =
+  ## Can be used to convert a pointer type (`ptr`, `pointer`, `ref` or `proc`) to an option type.
+  ## It converts `nil` to `none(T)`. When `T` is no pointer type, this is equivalent to `some(val)`.
+  ##
+  ## **See also:**
+  ## * `some proc <#some,T>`_
+  ## * `none proc <#none,typedesc>`_
+  runnableExamples:
+    type
+      Foo = ref object
+        a: int
+        b: string
+
+    assert option[Foo](nil).isNone
+    assert option(42).isSome
+
+  when T is SomePointer:
+    result = Option[T](val: val)
+  else:
+    result = Option[T](has: true, val: val)
+
+proc some*[T](val: sink T): Option[T] {.inline.} =
+  ## Returns an `Option` that has the value `val`.
+  ##
+  ## **See also:**
+  ## * `option proc <#option,T>`_
+  ## * `none proc <#none,typedesc>`_
+  ## * `isSome proc <#isSome,Option[T]>`_
+  runnableExamples:
+    let a = some("abc")
+
+    assert a.isSome
+    assert a.get == "abc"
+
+  when T is SomePointer:
+    assert not val.isNil
+    result = Option[T](val: val)
+  else:
+    result = Option[T](has: true, val: val)
+
+proc none*(T: typedesc): Option[T] {.inline.} =
+  ## Returns an `Option` for this type that has no value.
+  ##
+  ## **See also:**
+  ## * `option proc <#option,T>`_
+  ## * `some proc <#some,T>`_
+  ## * `isNone proc <#isNone,Option[T]>`_
+  runnableExamples:
+    assert none(int).isNone
+
+  # the default is the none type
+  result = Option[T]()
+
+proc none*[T]: Option[T] {.inline.} =
+  ## Alias for `none(T) <#none,typedesc>`_.
+  none(T)
+
+proc isSome*[T](self: Option[T]): bool {.inline.} =
+  ## Checks if an `Option` contains a value.
+  ##
+  ## **See also:**
+  ## * `isNone proc <#isNone,Option[T]>`_
+  ## * `some proc <#some,T>`_
+  runnableExamples:
+    assert some(42).isSome
+    assert not none(string).isSome
+
+  when T is SomePointer:
+    not self.val.isNil
+  else:
+    self.has
+
+proc isNone*[T](self: Option[T]): bool {.inline.} =
+  ## Checks if an `Option` is empty.
+  ##
+  ## **See also:**
+  ## * `isSome proc <#isSome,Option[T]>`_
+  ## * `none proc <#none,typedesc>`_
+  runnableExamples:
+    assert not some(42).isNone
+    assert none(string).isNone
+
+  when T is SomePointer:
+    self.val.isNil
+  else:
+    not self.has
+
+proc get*[T](self: Option[T]): lent T {.inline.} =
+  ## Returns the content of an `Option`. If it has no value,
+  ## an `UnpackDefect` exception is raised.
+  ##
+  ## **See also:**
+  ## * `get proc <#get,Option[T],T>`_ with a default return value
+  runnableExamples:
+    assert some(42).get == 42
+    doAssertRaises(UnpackDefect):
+      echo none(string).get
+
+  if self.isNone:
+    raise newException(UnpackDefect, "Can't obtain a value from a `none`")
+  result = self.val
+
+proc get*[T](self: Option[T], otherwise: T): T {.inline.} =
+  ## Returns the content of the `Option` or `otherwise` if
+  ## the `Option` has no value.
+  runnableExamples:
+    assert some(42).get(9999) == 42
+    assert none(int).get(9999) == 9999
+
+  if self.isSome:
+    self.val
+  else:
+    otherwise
+
+proc get*[T](self: var Option[T]): var T {.inline.} =
+  ## Returns the content of the `var Option` mutably. If it has no value,
+  ## an `UnpackDefect` exception is raised.
+  runnableExamples:
+    var
+      a = some(42)
+      b = none(string)
+    inc(a.get)
+    assert a.get == 43
+    doAssertRaises(UnpackDefect):
+      echo b.get
+
+  if self.isNone:
+    raise newException(UnpackDefect, "Can't obtain a value from a `none`")
+  return self.val
+
+proc map*[T](self: Option[T], callback: proc (input: T)) {.inline, effectsOf: callback.} =
+  ## Applies a `callback` function to the value of the `Option`, if it has one.
+  ##
+  ## **See also:**
+  ## * `map proc <#map,Option[T],proc(T)_2>`_ for a version with a callback
+  ##   which returns a value
+  runnableExamples:
+    var d = 0
+    proc saveDouble(x: int) =
+      d = 2 * x
+
+    none(int).map(saveDouble)
+    assert d == 0
+    some(42).map(saveDouble)
+    assert d == 84
+
+  if self.isSome:
+    callback(self.val)
+
+proc map*[T, R](self: Option[T], callback: proc (input: T): R): Option[R] {.inline, effectsOf: callback.} =
+  ## Applies a `callback` function to the value of the `Option` and returns an
+  ## `Option` containing the new value.
+  ##
+  ## If the `Option` has no value, `none(R)` will be returned.
+  ##
+  ## **See also:**
+  ## * `map proc <#map,Option[T],proc(T)>`_
+  ## * `flatMap proc <#flatMap,Option[T],proc(T)>`_ for a version with a
+  ##   callback that returns an `Option`
+  runnableExamples:
+    proc isEven(x: int): bool =
+      x mod 2 == 0
+
+    assert some(42).map(isEven) == some(true)
+    assert none(int).map(isEven) == none(bool)
+
+  if self.isSome:
+    some[R](callback(self.val))
+  else:
+    none(R)
+
+proc flatten*[T](self: Option[Option[T]]): Option[T] {.inline.} =
+  ## Remove one level of structure in a nested `Option`.
+  ##
+  ## **See also:**
+  ## * `flatMap proc <#flatMap,Option[T],proc(T)>`_
+  runnableExamples:
+    assert flatten(some(some(42))) == some(42)
+    assert flatten(none(Option[int])) == none(int)
+
+  if self.isSome:
+    self.val
+  else:
+    none(T)
+
+proc flatMap*[T, R](self: Option[T],
+                    callback: proc (input: T): Option[R]): Option[R] {.inline, effectsOf: callback.} =
+  ## Applies a `callback` function to the value of the `Option` and returns the new value.
+  ##
+  ## If the `Option` has no value, `none(R)` will be returned.
+  ##
+  ## This is similar to `map`, with the difference that the `callback` returns an
+  ## `Option`, not a raw value. This allows multiple procs with a
+  ## signature of `A -> Option[B]` to be chained together.
+  ##
+  ## See also:
+  ## * `flatten proc <#flatten,Option[Option[A]]>`_
+  ## * `filter proc <#filter,Option[T],proc(T)>`_
+  runnableExamples:
+    proc doublePositives(x: int): Option[int] =
+      if x > 0:
+        some(2 * x)
+      else:
+        none(int)
+
+    assert some(42).flatMap(doublePositives) == some(84)
+    assert none(int).flatMap(doublePositives) == none(int)
+    assert some(-11).flatMap(doublePositives) == none(int)
+
+  map(self, callback).flatten()
+
+proc filter*[T](self: Option[T], callback: proc (input: T): bool): Option[T] {.inline, effectsOf: callback.} =
+  ## Applies a `callback` to the value of the `Option`.
+  ##
+  ## If the `callback` returns `true`, the option is returned as `some`.
+  ## If it returns `false`, it is returned as `none`.
+  ##
+  ## **See also:**
+  ## * `flatMap proc <#flatMap,Option[A],proc(A)>`_
+  runnableExamples:
+    proc isEven(x: int): bool =
+      x mod 2 == 0
+
+    assert some(42).filter(isEven) == some(42)
+    assert none(int).filter(isEven) == none(int)
+    assert some(-11).filter(isEven) == none(int)
+
+  if self.isSome and not callback(self.val):
+    none(T)
+  else:
+    self
+
+proc `==`*[T](a, b: Option[T]): bool {.inline.} =
+  ## Returns `true` if both `Option`s are `none`,
+  ## or if they are both `some` and have equal values.
+  runnableExamples:
+    let
+      a = some(42)
+      b = none(int)
+      c = some(42)
+      d = none(int)
+
+    assert a == c
+    assert b == d
+    assert not (a == b)
+
+  when T is SomePointer:
+    a.val == b.val
+  else:
+    (a.isSome and b.isSome and a.val == b.val) or (a.isNone and b.isNone)
+
+proc `$`*[T](self: Option[T]): string =
+  ## Get the string representation of the `Option`.
+  runnableExamples:
+    assert $some(42) == "some(42)"
+    assert $none(int) == "none(int)"
+
+  if self.isSome:
+    when defined(nimLagacyOptionsDollar):
+      result = "Some("
+    else:
+      result = "some("
+    result.addQuoted self.val
+    result.add ")"
+  else:
+    when defined(nimLagacyOptionsDollar):
+      result = "None[" & name(T) & "]"
+    else:
+      result = "none(" & name(T) & ")"
+
+proc unsafeGet*[T](self: Option[T]): lent T {.inline.}=
+  ## Returns the value of a `some`. The behavior is undefined for `none`.
+  ##
+  ## **Note:** Use this only when you are **absolutely sure** the value is present
+  ## (e.g. after checking with `isSome <#isSome,Option[T]>`_).
+  ## Generally, using the `get proc <#get,Option[T]>`_ is preferred.
+  assert self.isSome
+  result = self.val
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 129774f6e..78ebb1c88 100755..100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1,611 +1,925 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module contains basic operating system facilities like
-## retrieving environment variables, reading command line arguments,
-## working with directories, running shell commands, etc.
-{.deadCodeElim: on.}
+## retrieving environment variables, working with directories,
+## running shell commands, etc.
 
-{.push debugger: off.}
+## .. importdoc:: symlinks.nim, appdirs.nim, dirs.nim, ospaths2.nim
 
-import
-  strutils, times
+runnableExamples:
+  let myFile = "/path/to/my/file.nim"
+  assert splitPath(myFile) == (head: "/path/to/my", tail: "file.nim")
+  when defined(posix):
+    assert parentDir(myFile) == "/path/to/my"
+  assert splitFile(myFile) == (dir: "/path/to/my", name: "file", ext: ".nim")
+  assert myFile.changeFileExt("c") == "/path/to/my/file.c"
+
+## **See also:**
+## * `paths <paths.html>`_ and `files <files.html>`_ modules for high-level file manipulation
+## * `osproc module <osproc.html>`_ for process communication beyond
+##   `execShellCmd proc`_
+## * `uri module <uri.html>`_
+## * `distros module <distros.html>`_
+## * `dynlib module <dynlib.html>`_
+## * `streams module <streams.html>`_
+import std/private/ospaths2
+export ospaths2
+
+import std/private/osfiles
+export osfiles
+
+import std/private/osdirs
+export osdirs
+
+import std/private/ossymlinks
+export ossymlinks
+
+import std/private/osappdirs
+export osappdirs
+
+import std/private/oscommon
+
+include system/inclrtl
+import std/private/since
+
+import std/cmdline
+export cmdline
 
-when defined(windows):
-  import winlean
-elif defined(posix): 
-  import posix
+import std/[strutils, pathnorm]
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+const weirdTarget = defined(nimscript) or defined(js)
+
+since (1, 1):
+  const
+    invalidFilenameChars* = {'/', '\\', ':', '*', '?', '"', '<', '>', '|', '^', '\0'} ## \
+    ## Characters that may produce invalid filenames across Linux, Windows and Mac.
+    ## You can check if your filename contains any of these chars and strip them for safety.
+    ## Mac bans ``':'``, Linux bans ``'/'``, Windows bans all others.
+    invalidFilenames* = [
+      "CON", "PRN", "AUX", "NUL",
+      "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
+      "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"] ## \
+    ## Filenames that may be invalid across Linux, Windows, Mac, etc.
+    ## You can check if your filename match these and rename it for safety
+    ## (Currently all invalid filenames are from Windows only).
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/[winlean, times]
+elif defined(posix):
+  import std/[posix, times]
+
+  proc toTime(ts: Timespec): times.Time {.inline.} =
+    result = initTime(ts.tv_sec.int64, ts.tv_nsec.int)
 else:
   {.error: "OS module not ported to your operating system!".}
 
-include "system/ansi_c"
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
 
-const
-  doslike = defined(windows) or defined(OS2) or defined(DOS)
-    # DOS-like filesystem
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
 
-when defined(Nimdoc): # only for proper documentation:
-  const
-    CurDir* = '.'
-      ## The constant string used by the operating system to refer to the
-      ## current directory.
-      ##
-      ## For example: '.' for POSIX or ':' for the classic Macintosh.
-
-    ParDir* = ".."
-      ## The constant string used by the operating system to refer to the parent
-      ## directory.
-      ##
-      ## For example: ".." for POSIX or "::" for the classic Macintosh.
-
-    DirSep* = '/'
-      ## The character used by the operating system to separate pathname
-      ## components, for example, '/' for POSIX or ':' for the classic
-      ## Macintosh.
-
-    AltSep* = '/'
-      ## An alternative character used by the operating system to separate
-      ## pathname components, or the same as `DirSep` if only one separator
-      ## character exists. This is set to '/' on Windows systems where `DirSep`
-      ## is a backslash.
-
-    PathSep* = ':'
-      ## The character conventionally used by the operating system to separate
-      ## search patch components (as in PATH), such as ':' for POSIX or ';' for
-      ## Windows.
-
-    FileSystemCaseSensitive* = True
-      ## True if the file system is case sensitive, false otherwise. Used by
-      ## `cmpPaths` to compare filenames properly.
-
-    ExeExt* = ""
-      ## The file extension of native executables. For example:
-      ## "" for POSIX, "exe" on Windows.
-
-    ScriptExt* = ""
-      ## The file extension of a script file. For example: "" for POSIX,
-      ## "bat" on Windows.
-
-elif defined(macos):
-  const
-    curdir* = ':'
-    pardir* = "::"
-    dirsep* = ':'
-    altsep* = dirsep
-    pathsep* = ','
-    FileSystemCaseSensitive* = false
-    ExeExt* = ""
-    ScriptExt* = ""
-
-  #  MacOS paths
-  #  ===========
-  #  MacOS directory separator is a colon ":" which is the only character not
-  #  allowed in filenames.
-  #
-  #  A path containing no colon or which begins with a colon is a partial path.
-  #  E.g. ":kalle:petter" ":kalle" "kalle"
-  #
-  #  All other paths are full (absolute) paths. E.g. "HD:kalle:" "HD:"
-  #  When generating paths, one is safe if one ensures that all partial paths
-  #  begin with a colon, and all full paths end with a colon.
-  #  In full paths the first name (e g HD above) is the name of a mounted
-  #  volume.
-  #  These names are not unique, because, for instance, two diskettes with the
-  #  same names could be inserted. This means that paths on MacOS are not
-  #  waterproof. In case of equal names the first volume found will do.
-  #  Two colons "::" are the relative path to the parent. Three is to the
-  #  grandparent etc.
-elif doslike:
-  const
-    curdir* = '.'
-    pardir* = ".."
-    dirsep* = '\\' # seperator within paths
-    altsep* = '/'
-    pathSep* = ';' # seperator between paths
-    FileSystemCaseSensitive* = false
-    ExeExt* = "exe"
-    ScriptExt* = "bat"
-elif defined(PalmOS) or defined(MorphOS):
-  const
-    dirsep* = '/'
-    altsep* = dirsep
-    PathSep* = ';'
-    pardir* = ".."
-    FileSystemCaseSensitive* = false
-    ExeExt* = ""
-    ScriptExt* = ""
-elif defined(RISCOS):
-  const
-    dirsep* = '.'
-    altsep* = '.'
-    pardir* = ".." # is this correct?
-    pathSep* = ','
-    FileSystemCaseSensitive* = true
-    ExeExt* = ""
-    ScriptExt* = ""
-else: # UNIX-like operating system
-  const
-    curdir* = '.'
-    pardir* = ".."
-    dirsep* = '/'
-    altsep* = dirsep
-    pathSep* = ':'
-    FileSystemCaseSensitive* = true
-    ExeExt* = ""
-    ScriptExt* = ""
 
-const
-  ExtSep* = '.'
-    ## The character which separates the base filename from the extension;
-    ## for example, the '.' in ``os.nim``.
-
-# procs dealing with command line arguments:
-proc paramCount*(): int
-  ## Returns the number of command line arguments given to the
-  ## application.
-
-proc paramStr*(i: int): string
-  ## Returns the `i`-th command line arguments given to the
-  ## application.
+import std/oserrors
+export oserrors
+import std/envvars
+export envvars
+
+import std/private/osseps
+export osseps
+
+
+
+proc expandTilde*(path: string): string {.
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Expands ``~`` or a path starting with ``~/`` to a full path, replacing
+  ## ``~`` with `getHomeDir()`_ (otherwise returns ``path`` unmodified).
   ##
-  ## `i` should be in the range `1..paramCount()`, else
-  ## the `EOutOfIndex` exception is raised.
-
-proc OSError*(msg: string = "") {.noinline.} =
-  ## raises an EOS exception with the given message ``msg``.
-  ## If ``msg == ""``, the operating system's error flag
-  ## (``errno``) is converted to a readable error message. On Windows
-  ## ``GetLastError`` is checked before ``errno``.
-  ## If no error flag is set, the message ``unknown OS error`` is used.
-  if len(msg) == 0:
-    when defined(Windows):
-      var err = GetLastError()
-      if err != 0'i32:
-        # sigh, why is this is so difficult?
-        var msgbuf: cstring
-        if FormatMessageA(0x00000100 or 0x00001000 or 0x00000200,
-                          nil, err, 0, addr(msgbuf), 0, nil) != 0'i32:
-          var m = $msgbuf
-          if msgbuf != nil:
-            LocalFree(msgbuf)
-          raise newException(EOS, m)
-    if errno != 0'i32:
-      raise newException(EOS, $os.strerror(errno))
-    else:
-      raise newException(EOS, "unknown OS error")
+  ## Windows: this is still supported despite the Windows platform not having this
+  ## convention; also, both ``~/`` and ``~\`` are handled.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  runnableExamples:
+    assert expandTilde("~" / "appname.cfg") == getHomeDir() / "appname.cfg"
+    assert expandTilde("~/foo/bar") == getHomeDir() / "foo/bar"
+    assert expandTilde("/foo/bar") == "/foo/bar"
+
+  if len(path) == 0 or path[0] != '~':
+    result = path
+  elif len(path) == 1:
+    result = getHomeDir()
+  elif (path[1] in {DirSep, AltSep}):
+    result = getHomeDir() / path.substr(2)
   else:
-    raise newException(EOS, msg)
+    # TODO: handle `~bob` and `~bob/` which means home of bob
+    result = path
 
-proc UnixToNativePath*(path: string): string {.noSideEffect.} =
-  ## Converts an UNIX-like path to a native one.
+proc quoteShellWindows*(s: string): string {.noSideEffect, rtl, extern: "nosp$1".} =
+  ## Quote `s`, so it can be safely passed to Windows API.
   ##
-  ## On an UNIX system this does nothing. Else it converts
-  ## '/', '.', '..' to the appropriate things.
-  when defined(unix):
-    result = path
+  ## Based on Python's `subprocess.list2cmdline`.
+  ## See `this link <http://msdn.microsoft.com/en-us/library/17w5ykft.aspx>`_
+  ## for more details.
+  let needQuote = {' ', '\t'} in s or s.len == 0
+  result = ""
+  var backslashBuff = ""
+  if needQuote:
+    result.add("\"")
+
+  for c in s:
+    if c == '\\':
+      backslashBuff.add(c)
+    elif c == '\"':
+      for i in 0..<backslashBuff.len*2:
+        result.add('\\')
+      backslashBuff.setLen(0)
+      result.add("\\\"")
+    else:
+      if backslashBuff.len != 0:
+        result.add(backslashBuff)
+        backslashBuff.setLen(0)
+      result.add(c)
+
+  if backslashBuff.len > 0:
+    result.add(backslashBuff)
+  if needQuote:
+    result.add(backslashBuff)
+    result.add("\"")
+
+
+proc quoteShellPosix*(s: string): string {.noSideEffect, rtl, extern: "nosp$1".} =
+  ## Quote ``s``, so it can be safely passed to POSIX shell.
+  const safeUnixChars = {'%', '+', '-', '.', '/', '_', ':', '=', '@',
+                         '0'..'9', 'A'..'Z', 'a'..'z'}
+  if s.len == 0:
+    result = "''"
+  elif s.allCharsInSet(safeUnixChars):
+    result = s
   else:
-    var start: int
-    if path[0] == '/':
-      # an absolute path
-      when doslike:
-        result = r"C:\"
-      elif defined(macos):
-        result = "" # must not start with ':'
-      else:
-        result = $dirSep
-      start = 1
-    elif path[0] == '.' and path[1] == '/':
-      # current directory
-      result = $curdir
-      start = 2
+    result = "'" & s.replace("'", "'\"'\"'") & "'"
+
+when defined(windows) or defined(posix) or defined(nintendoswitch):
+  proc quoteShell*(s: string): string {.noSideEffect, rtl, extern: "nosp$1".} =
+    ## Quote ``s``, so it can be safely passed to shell.
+    ##
+    ## When on Windows, it calls `quoteShellWindows proc`_.
+    ## Otherwise, calls `quoteShellPosix proc`_.
+    when defined(windows):
+      result = quoteShellWindows(s)
     else:
-      result = ""
-      start = 0
-
-    var i = start
-    while i < len(path): # ../../../ --> ::::
-      if path[i] == '.' and path[i+1] == '.' and path[i+2] == '/':
-        # parent directory
-        when defined(macos):
-          if result[high(result)] == ':':
-            add result, ':'
-          else:
-            add result, pardir
-        else:
-          add result, pardir & dirSep
-        inc(i, 3)
-      elif path[i] == '/':
-        add result, dirSep
-        inc(i)
-      else:
-        add result, path[i]
-        inc(i)
+      result = quoteShellPosix(s)
 
-proc existsFile*(filename: string): bool =
-  ## Returns true if the file exists, false otherwise.
-  when defined(windows):
-    var a = GetFileAttributesA(filename)
-    if a != -1'i32:
-      result = (a and FILE_ATTRIBUTE_DIRECTORY) == 0'i32
-  else:
-    var res: TStat
-    return stat(filename, res) >= 0'i32 and S_ISREG(res.st_mode)
+  proc quoteShellCommand*(args: openArray[string]): string =
+    ## Concatenates and quotes shell arguments `args`.
+    runnableExamples:
+      when defined(posix):
+        assert quoteShellCommand(["aaa", "", "c d"]) == "aaa '' 'c d'"
+      when defined(windows):
+        assert quoteShellCommand(["aaa", "", "c d"]) == "aaa \"\" \"c d\""
 
-proc existsDir*(dir: string): bool =
-  ## Returns true iff the directory `dir` exists. If `dir` is a file, false
-  ## is returned.
-  when defined(windows):
-    var a = GetFileAttributesA(dir)
-    if a != -1'i32:
-      result = (a and FILE_ATTRIBUTE_DIRECTORY) != 0'i32
-  else:
-    var res: TStat
-    return stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode)
+    # can't use `map` pending https://github.com/nim-lang/Nim/issues/8303
+    result = ""
+    for i in 0..<args.len:
+      if i > 0: result.add " "
+      result.add quoteShell(args[i])
+
+when not weirdTarget:
+  proc c_system(cmd: cstring): cint {.
+    importc: "system", header: "<stdlib.h>".}
 
-proc getLastModificationTime*(file: string): TTime =
+  when not defined(windows):
+    proc c_free(p: pointer) {.
+      importc: "free", header: "<stdlib.h>".}
+
+
+const
+  ExeExts* = ## Platform specific file extension for executables.
+    ## On Windows ``["exe", "cmd", "bat"]``, on Posix ``[""]``.
+    when defined(windows): ["exe", "cmd", "bat"] else: [""]
+
+proc findExe*(exe: string, followSymlinks: bool = true;
+              extensions: openArray[string]=ExeExts): string {.
+  tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect], noNimJs.} =
+  ## Searches for `exe` in the current working directory and then
+  ## in directories listed in the ``PATH`` environment variable.
+  ##
+  ## Returns `""` if the `exe` cannot be found. `exe`
+  ## is added the `ExeExts`_ file extensions if it has none.
+  ##
+  ## If the system supports symlinks it also resolves them until it
+  ## meets the actual file. This behavior can be disabled if desired
+  ## by setting `followSymlinks = false`.
+
+  if exe.len == 0: return
+  template checkCurrentDir() =
+    for ext in extensions:
+      result = addFileExt(exe, ext)
+      if fileExists(result): return
+  when defined(posix):
+    if '/' in exe: checkCurrentDir()
+  else:
+    checkCurrentDir()
+  let path = getEnv("PATH")
+  for candidate in split(path, PathSep):
+    if candidate.len == 0: continue
+    when defined(windows):
+      var x = (if candidate[0] == '"' and candidate[^1] == '"':
+                substr(candidate, 1, candidate.len-2) else: candidate) /
+              exe
+    else:
+      var x = expandTilde(candidate) / exe
+    for ext in extensions:
+      var x = addFileExt(x, ext)
+      if fileExists(x):
+        when not (defined(windows) or defined(nintendoswitch)):
+          while followSymlinks: # doubles as if here
+            if x.symlinkExists:
+              var r = newString(maxSymlinkLen)
+              var len = readlink(x.cstring, r.cstring, maxSymlinkLen)
+              if len < 0:
+                raiseOSError(osLastError(), exe)
+              if len > maxSymlinkLen:
+                r = newString(len+1)
+                len = readlink(x.cstring, r.cstring, len)
+              setLen(r, len)
+              if isAbsolute(r):
+                x = r
+              else:
+                x = parentDir(x) / r
+            else:
+              break
+        return x
+  result = ""
+
+when weirdTarget:
+  const times = "fake const"
+  template Time(x: untyped): untyped = string
+
+proc getLastModificationTime*(file: string): times.Time {.rtl, extern: "nos$1", noWeirdTarget.} =
   ## Returns the `file`'s last modification time.
+  ##
+  ## See also:
+  ## * `getLastAccessTime proc`_
+  ## * `getCreationTime proc`_
+  ## * `fileNewer proc`_
   when defined(posix):
-    var res: TStat
-    if stat(file, res) < 0'i32: OSError()
-    return res.st_mtime
+    var res: Stat
+    if stat(file, res) < 0'i32: raiseOSError(osLastError(), file)
+    result = res.st_mtim.toTime
   else:
-    var f: TWIN32_Find_Data
-    var h = findfirstFileA(file, f)
-    if h == -1'i32: OSError()
-    result = winTimeToUnixTime(rdFileTime(f.ftLastWriteTime))
-    findclose(h)
+    var f: WIN32_FIND_DATA
+    var h = findFirstFile(file, f)
+    if h == -1'i32: raiseOSError(osLastError(), file)
+    result = fromWinTime(rdFileTime(f.ftLastWriteTime))
+    findClose(h)
 
-proc getLastAccessTime*(file: string): TTime =
+proc getLastAccessTime*(file: string): times.Time {.rtl, extern: "nos$1", noWeirdTarget.} =
   ## Returns the `file`'s last read or write access time.
+  ##
+  ## See also:
+  ## * `getLastModificationTime proc`_
+  ## * `getCreationTime proc`_
+  ## * `fileNewer proc`_
   when defined(posix):
-    var res: TStat
-    if stat(file, res) < 0'i32: OSError()
-    return res.st_atime
+    var res: Stat
+    if stat(file, res) < 0'i32: raiseOSError(osLastError(), file)
+    result = res.st_atim.toTime
   else:
-    var f: TWIN32_Find_Data
-    var h = findfirstFileA(file, f)
-    if h == -1'i32: OSError()
-    result = winTimeToUnixTime(rdFileTime(f.ftLastAccessTime))
-    findclose(h)
+    var f: WIN32_FIND_DATA
+    var h = findFirstFile(file, f)
+    if h == -1'i32: raiseOSError(osLastError(), file)
+    result = fromWinTime(rdFileTime(f.ftLastAccessTime))
+    findClose(h)
 
-proc getCreationTime*(file: string): TTime = 
+proc getCreationTime*(file: string): times.Time {.rtl, extern: "nos$1", noWeirdTarget.} =
   ## Returns the `file`'s creation time.
+  ##
+  ## **Note:** Under POSIX OS's, the returned time may actually be the time at
+  ## which the file's attribute's were last modified. See
+  ## `here <https://github.com/nim-lang/Nim/issues/1058>`_ for details.
+  ##
+  ## See also:
+  ## * `getLastModificationTime proc`_
+  ## * `getLastAccessTime proc`_
+  ## * `fileNewer proc`_
   when defined(posix):
-    var res: TStat
-    if stat(file, res) < 0'i32: OSError()
-    return res.st_ctime
+    var res: Stat
+    if stat(file, res) < 0'i32: raiseOSError(osLastError(), file)
+    result = res.st_ctim.toTime
   else:
-    var f: TWIN32_Find_Data
-    var h = findfirstFileA(file, f)
-    if h == -1'i32: OSError()
-    result = winTimeToUnixTime(rdFileTime(f.ftCreationTime))
-    findclose(h)
+    var f: WIN32_FIND_DATA
+    var h = findFirstFile(file, f)
+    if h == -1'i32: raiseOSError(osLastError(), file)
+    result = fromWinTime(rdFileTime(f.ftCreationTime))
+    findClose(h)
 
-proc fileNewer*(a, b: string): bool =
+proc fileNewer*(a, b: string): bool {.rtl, extern: "nos$1", noWeirdTarget.} =
   ## Returns true if the file `a` is newer than file `b`, i.e. if `a`'s
   ## modification time is later than `b`'s.
-  result = getLastModificationTime(a) - getLastModificationTime(b) > 0
+  ##
+  ## See also:
+  ## * `getLastModificationTime proc`_
+  ## * `getLastAccessTime proc`_
+  ## * `getCreationTime proc`_
+  when defined(posix):
+    # If we don't have access to nanosecond resolution, use '>='
+    when not StatHasNanoseconds:
+      result = getLastModificationTime(a) >= getLastModificationTime(b)
+    else:
+      result = getLastModificationTime(a) > getLastModificationTime(b)
+  else:
+    result = getLastModificationTime(a) > getLastModificationTime(b)
 
-proc getCurrentDir*(): string =
-  ## Returns the current working directory.
-  const bufsize = 512 # should be enough
-  result = newString(bufsize)
+
+proc isAdmin*: bool {.noWeirdTarget.} =
+  ## Returns whether the caller's process is a member of the Administrators local
+  ## group (on Windows) or a root (on POSIX), via `geteuid() == 0`.
   when defined(windows):
-    var L = GetCurrentDirectoryA(bufsize, result)
-    if L == 0'i32: OSError()
-    setLen(result, L)
+    # Rewrite of the example from Microsoft Docs:
+    # https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-checktokenmembership#examples
+    # and corresponding PostgreSQL function:
+    # https://doxygen.postgresql.org/win32security_8c.html#ae6b61e106fa5d6c5d077a9d14ee80569
+    var ntAuthority = SID_IDENTIFIER_AUTHORITY(value: SECURITY_NT_AUTHORITY)
+    var administratorsGroup: PSID
+    if not isSuccess(allocateAndInitializeSid(addr ntAuthority,
+                                              BYTE(2),
+                                              SECURITY_BUILTIN_DOMAIN_RID,
+                                              DOMAIN_ALIAS_RID_ADMINS,
+                                              0, 0, 0, 0, 0, 0,
+                                              addr administratorsGroup)):
+      raiseOSError(osLastError(), "could not get SID for Administrators group")
+
+    try:
+      var b: WINBOOL
+      if not isSuccess(checkTokenMembership(0, administratorsGroup, addr b)):
+        raiseOSError(osLastError(), "could not check access token membership")
+
+      result = isSuccess(b)
+    finally:
+      if freeSid(administratorsGroup) != nil:
+        raiseOSError(osLastError(), "failed to free SID for Administrators group")
+
   else:
-    if getcwd(result, bufsize) != nil:
-      setlen(result, c_strlen(result))
-    else:
-      OSError()
+    result = geteuid() == 0
+
 
-proc setCurrentDir*(newDir: string) {.inline.} =
-  ## Sets the current working directory; `EOS` is raised if
-  ## `newDir` cannot been set.
-  when defined(Windows):
-    if SetCurrentDirectoryA(newDir) == 0'i32: OSError()
+proc exitStatusLikeShell*(status: cint): cint =
+  ## Converts exit code from `c_system` into a shell exit code.
+  when defined(posix) and not weirdTarget:
+    if WIFSIGNALED(status):
+      # like the shell!
+      128 + WTERMSIG(status)
+    else:
+      WEXITSTATUS(status)
   else:
-    if chdir(newDir) != 0'i32: OSError()
+    status
 
-proc JoinPath*(head, tail: string): string {.noSideEffect.} =
-  ## Joins two directory names to one.
-  ##
-  ## For example on Unix:
+proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
+  tags: [ExecIOEffect], noWeirdTarget.} =
+  ## Executes a `shell command`:idx:.
   ##
-  ## .. code-block:: nimrod
-  ##   JoinPath("usr", "lib")
+  ## Command has the form 'program args' where args are the command
+  ## line arguments given to program. The proc returns the error code
+  ## of the shell when it has finished (zero if there is no error).
+  ## The proc does not return until the process has finished.
   ##
-  ## results in:
+  ## To execute a program without having a shell involved, use `osproc.execProcess proc
+  ## <osproc.html#execProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_.
   ##
-  ## .. code-block:: nimrod
-  ##   "usr/lib"
+  ## **Examples:**
+  ##   ```Nim
+  ##   discard execShellCmd("ls -la")
+  ##   ```
+  result = exitStatusLikeShell(c_system(command))
+
+proc expandFilename*(filename: string): string {.rtl, extern: "nos$1",
+  tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Returns the full (`absolute`:idx:) path of an existing file `filename`.
   ##
-  ## If head is the empty string, tail is returned.
-  ## If tail is the empty string, head is returned.
-  if len(head) == 0:
-    result = tail
-  elif head[len(head)-1] in {DirSep, AltSep}:
-    if tail[0] in {DirSep, AltSep}:
-      result = head & copy(tail, 1)
-    else:
-      result = head & tail
+  ## Raises `OSError` in case of an error. Follows symlinks.
+  when defined(windows):
+    var bufsize = MAX_PATH.int32
+    var unused: WideCString = nil
+    var res = newWideCString(bufsize)
+    while true:
+      var L = getFullPathNameW(newWideCString(filename), bufsize, res, unused)
+      if L == 0'i32:
+        raiseOSError(osLastError(), filename)
+      elif L > bufsize:
+        res = newWideCString(L)
+        bufsize = L
+      else:
+        result = res$L
+        break
+    # getFullPathName doesn't do case corrections, so we have to use this convoluted
+    # way of retrieving the true filename
+    for x in walkFiles(result):
+      result = x
+    if not fileExists(result) and not dirExists(result):
+      # consider using: `raiseOSError(osLastError(), result)`
+      raise newException(OSError, "file '" & result & "' does not exist")
   else:
-    if tail[0] in {DirSep, AltSep}:
-      result = head & tail
+    # according to Posix we don't need to allocate space for result pathname.
+    # But we need to free return value with free(3).
+    var r = realpath(filename, nil)
+    if r.isNil:
+      raiseOSError(osLastError(), filename)
     else:
-      result = head & DirSep & tail
-
-proc JoinPath*(parts: openarray[string]): string {.noSideEffect.} =
-  ## The same as `JoinPath(head, tail)`, but works with any number
-  ## of directory parts.
-  result = parts[0]
-  for i in 1..high(parts):
-    result = JoinPath(result, parts[i])
-
-proc `/` * (head, tail: string): string {.noSideEffect.} =
-  ## The same as ``joinPath(head, tail)``
-  return joinPath(head, tail)
-
-proc SplitPath*(path: string, head, tail: var string) {.noSideEffect,
-                                                        deprecated.} =
-  ## **Deprecated since version 0.8.2**: use the version that returns a tuple
-  ## instead
-  var
-    sepPos = -1
-  for i in countdown(len(path)-1, 0):
-    if path[i] in {dirsep, altsep}:
-      sepPos = i
-      break
-  if sepPos >= 0:
-    head = copy(path, 0, sepPos-1)
-    tail = copy(path, sepPos+1)
-  else:
-    head = ""
-    tail = path # make a string copy here
+      result = $r
+      c_free(cast[pointer](r))
 
-proc SplitPath*(path: string): tuple[head, tail: string] {.noSideEffect.} =
-  ## Splits a directory into (head, tail), so that
-  ## ``JoinPath(head, tail) == path``.
+proc getCurrentCompilerExe*(): string {.compileTime.} = discard
+  ## Returns the path of the currently running Nim compiler or nimble executable.
   ##
-  ## Examples: 
+  ## Can be used to retrieve the currently executing
+  ## Nim compiler from a Nim or nimscript program, or the nimble binary
+  ## inside a nimble program (likewise with other binaries built from
+  ## compiler API).
+
+proc createHardlink*(src, dest: string) {.noWeirdTarget.} =
+  ## Create a hard link at `dest` which points to the item specified
+  ## by `src`.
   ##
-  ## .. code-block:: nimrod
-  ##   SplitPath("usr/local/bin") -> ("usr/local", "bin")
-  ##   SplitPath("usr/local/bin/") -> ("usr/local/bin", "")
-  ##   SplitPath("bin") -> ("", "bin")
-  ##   SplitPath("/bin") -> ("", "bin")
-  ##   SplitPath("") -> ("", "")
-  var
-    sepPos = -1
-  for i in countdown(len(path)-1, 0):
-    if path[i] in {dirsep, altsep}:
-      sepPos = i
-      break
-  if sepPos >= 0:
-    result.head = copy(path, 0, sepPos-1)
-    result.tail = copy(path, sepPos+1)
+  ## .. warning:: Some OS's restrict the creation of hard links to
+  ##   root users (administrators).
+  ##
+  ## See also:
+  ## * `createSymlink proc`_
+  when defined(windows):
+    var wSrc = newWideCString(src)
+    var wDst = newWideCString(dest)
+    if createHardLinkW(wDst, wSrc, nil) == 0:
+      raiseOSError(osLastError(), $(src, dest))
   else:
-    result.head = ""
-    result.tail = path
+    if link(src, dest) != 0:
+      raiseOSError(osLastError(), $(src, dest))
+
+proc inclFilePermissions*(filename: string,
+                          permissions: set[FilePermission]) {.
+  rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect], noWeirdTarget.} =
+  ## A convenience proc for:
+  ##   ```nim
+  ##   setFilePermissions(filename, getFilePermissions(filename)+permissions)
+  ##   ```
+  setFilePermissions(filename, getFilePermissions(filename)+permissions)
 
-proc parentDir*(path: string): string {.noSideEffect.} =
-  ## Returns the parent directory of `path`.
-  ##
-  ## This is often the same as the ``head`` result of ``splitPath``.
-  ## If there is no parent, ``path`` is returned.
-  ## | Example: ``parentDir("/usr/local/bin") == "/usr/local"``.
-  ## | Example: ``parentDir("/usr/local/bin/") == "/usr/local"``.
-  var
-    sepPos = -1
-    q = 1
-  if path[len(path)-1] in {dirsep, altsep}:
-    q = 2
-  for i in countdown(len(path)-q, 0):
-    if path[i] in {dirsep, altsep}:
-      sepPos = i
-      break
-  if sepPos >= 0:
-    result = copy(path, 0, sepPos-1)
+proc exclFilePermissions*(filename: string,
+                          permissions: set[FilePermission]) {.
+  rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect], noWeirdTarget.} =
+  ## A convenience proc for:
+  ##   ```nim
+  ##   setFilePermissions(filename, getFilePermissions(filename)-permissions)
+  ##   ```
+  setFilePermissions(filename, getFilePermissions(filename)-permissions)
+
+when not weirdTarget and (defined(freebsd) or defined(dragonfly) or defined(netbsd)):
+  proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
+              newp: pointer, newplen: csize_t): cint
+       {.importc: "sysctl",header: """#include <sys/types.h>
+                                      #include <sys/sysctl.h>""".}
+  const
+    CTL_KERN = 1
+    KERN_PROC = 14
+    MAX_PATH = 1024
+
+  when defined(freebsd):
+    const KERN_PROC_PATHNAME = 12
+  elif defined(netbsd):
+    const KERN_PROC_ARGS = 48
+    const KERN_PROC_PATHNAME = 5
   else:
-    result = path
+    const KERN_PROC_PATHNAME = 9
 
-proc `/../` * (head, tail: string): string {.noSideEffect.} =
-  ## The same as ``parentDir(head) / tail``
-  return parentDir(head) / tail
+  proc getApplFreebsd(): string =
+    var pathLength = csize_t(0)
 
-proc normExt(ext: string): string =
-  if ext == "" or ext[0] == extSep: result = ext # no copy needed here
-  else: result = extSep & ext
+    when defined(netbsd):
+      var req = [CTL_KERN.cint, KERN_PROC_ARGS.cint, -1.cint, KERN_PROC_PATHNAME.cint]
+    else:
+      var req = [CTL_KERN.cint, KERN_PROC.cint, KERN_PROC_PATHNAME.cint, -1.cint]
 
-proc searchExtPos(s: string): int =
-  # BUGFIX: do not search until 0! .DS_Store is no file extension!
-  result = -1
-  for i in countdown(len(s)-1, 1):
-    if s[i] == extsep:
-      result = i
-      break
-    elif s[i] in {dirsep, altsep}:
-      break # do not skip over path
+    # first call to get the required length
+    var res = sysctl(addr req[0], 4, nil, addr pathLength, nil, 0)
+
+    if res < 0:
+      return ""
+
+    result.setLen(pathLength)
+    res = sysctl(addr req[0], 4, addr result[0], addr pathLength, nil, 0)
+
+    if res < 0:
+      return ""
+
+    let realLen = len(cstring(result))
+    setLen(result, realLen)
+
+when not weirdTarget and (defined(linux) or defined(solaris) or defined(bsd) or defined(aix)):
+  proc getApplAux(procPath: string): string =
+    result = newString(maxSymlinkLen)
+    var len = readlink(procPath, result.cstring, maxSymlinkLen)
+    if len > maxSymlinkLen:
+      result = newString(len+1)
+      len = readlink(procPath, result.cstring, len)
+    setLen(result, len)
+
+when not weirdTarget and defined(openbsd):
+  proc getApplOpenBsd(): string =
+    # similar to getApplHeuristic, but checks current working directory
+    when declared(paramStr):
+      result = ""
+
+      # POSIX guaranties that this contains the executable
+      # as it has been executed by the calling process
+      let exePath = paramStr(0)
+
+      if len(exePath) == 0:
+        return ""
 
-proc splitFile*(path: string): tuple[dir, name, ext: string] {.noSideEffect.} =
-  ## Splits a filename into (dir, filename, extension).
-  ## `dir` does not end in `DirSep`.
-  ## `extension` includes the leading dot.
+      if exePath[0] == DirSep:
+        # path is absolute
+        result = exePath
+      else:
+        # not an absolute path, check if it's relative to the current working directory
+        for i in 1..<len(exePath):
+          if exePath[i] == DirSep:
+            result = joinPath(getCurrentDir(), exePath)
+            break
+
+      if len(result) > 0:
+        return expandFilename(result)
+
+      # search in path
+      for p in split(getEnv("PATH"), {PathSep}):
+        var x = joinPath(p, exePath)
+        if fileExists(x):
+          return expandFilename(x)
+    else:
+      result = ""
+
+when not (defined(windows) or defined(macosx) or weirdTarget):
+  proc getApplHeuristic(): string =
+    when declared(paramStr):
+      result = paramStr(0)
+      # POSIX guaranties that this contains the executable
+      # as it has been executed by the calling process
+      if len(result) > 0 and result[0] != DirSep: # not an absolute path?
+        # iterate over any path in the $PATH environment variable
+        for p in split(getEnv("PATH"), {PathSep}):
+          var x = joinPath(p, result)
+          if fileExists(x): return x
+    else:
+      result = ""
+
+when defined(macosx):
+  type
+    cuint32* {.importc: "unsigned int", nodecl.} = int
+    ## This is the same as the type ``uint32_t`` in *C*.
+
+  # a really hacky solution: since we like to include 2 headers we have to
+  # define two procs which in reality are the same
+  proc getExecPath1(c: cstring, size: var cuint32) {.
+    importc: "_NSGetExecutablePath", header: "<sys/param.h>".}
+  proc getExecPath2(c: cstring, size: var cuint32): bool {.
+    importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
+
+when defined(haiku):
+  const
+    PATH_MAX = 1024
+    B_FIND_PATH_IMAGE_PATH = 1000
+
+  proc find_path(codePointer: pointer, baseDirectory: cint, subPath: cstring,
+                 pathBuffer: cstring, bufferSize: csize_t): int32
+                {.importc, header: "<FindDirectory.h>".}
+
+  proc getApplHaiku(): string =
+    result = newString(PATH_MAX)
+
+    if find_path(nil, B_FIND_PATH_IMAGE_PATH, nil, result, PATH_MAX) == 0:
+      let realLen = len(cstring(result))
+      setLen(result, realLen)
+    else:
+      result = ""
+
+proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noWeirdTarget, raises: [].} =
+  ## Returns the filename of the application's executable.
+  ## This proc will resolve symlinks.
   ##
-  ## Example:
+  ## Returns empty string when name is unavailable
   ##
-  ## .. code-block:: nimrod
-  ##   var (dir, name, ext) = splitFile("usr/local/nimrodc.html")
-  ##   assert dir == "usr/local"
-  ##   assert name == "nimrodc"
-  ##   assert ext == ".html"
+  ## See also:
+  ## * `getAppDir proc`_
+  ## * `getCurrentCompilerExe proc`_
+
+  # Linux: /proc/<pid>/exe
+  # Solaris:
+  # /proc/<pid>/object/a.out (filename only)
+  # /proc/<pid>/path/a.out (complete pathname)
+  when defined(windows):
+    var bufsize = int32(MAX_PATH)
+    var buf = newWideCString(bufsize)
+    while true:
+      var L = getModuleFileNameW(0, buf, bufsize)
+      if L == 0'i32:
+        result = "" # error!
+        break
+      elif L > bufsize:
+        buf = newWideCString(L)
+        bufsize = L
+      else:
+        result = buf$L
+        break
+  elif defined(macosx):
+    var size = cuint32(0)
+    getExecPath1(nil, size)
+    result = newString(int(size))
+    if getExecPath2(result.cstring, size):
+      result = "" # error!
+    if result.len > 0:
+      try:
+        result = result.expandFilename
+      except OSError:
+        result = ""
+  else:
+    when defined(linux) or defined(aix):
+      result = getApplAux("/proc/self/exe")
+    elif defined(solaris):
+      result = getApplAux("/proc/" & $getpid() & "/path/a.out")
+    elif defined(genode):
+      result = "" # Not supported
+    elif defined(freebsd) or defined(dragonfly) or defined(netbsd):
+      result = getApplFreebsd()
+    elif defined(haiku):
+      result = getApplHaiku()
+    elif defined(openbsd):
+      result = try: getApplOpenBsd() except OSError: ""
+    elif defined(nintendoswitch):
+      result = ""
+
+    # little heuristic that may work on other POSIX-like systems:
+    if result.len == 0:
+      result = try: getApplHeuristic() except OSError: ""
+
+proc getAppDir*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noWeirdTarget.} =
+  ## Returns the directory of the application's executable.
   ##
-  ## If `path` has no extension, `ext` is the empty string.
-  ## If `path` has no directory component, `dir` is the empty string.
-  ## If `path` has no filename component, `name` and `ext` are empty strings.
-  if path.len == 0 or path[path.len-1] in {dirSep, altSep}:
-    result = (path, "", "")
+  ## See also:
+  ## * `getAppFilename proc`_
+  result = splitFile(getAppFilename()).dir
+
+proc sleep*(milsecs: int) {.rtl, extern: "nos$1", tags: [TimeEffect], noWeirdTarget.} =
+  ## Sleeps `milsecs` milliseconds.
+  ## A negative `milsecs` causes sleep to return immediately.
+  when defined(windows):
+    if milsecs < 0:
+      return  # fixes #23732
+    winlean.sleep(int32(milsecs))
   else:
-    var sepPos = -1
-    var dotPos = path.len
-    for i in countdown(len(path)-1, 0):
-      if path[i] == ExtSep:
-        if dotPos == path.len and i > 0: dotPos = i
-      elif path[i] in {dirsep, altsep}:
-        sepPos = i
-        break
-    result.dir = copy(path, 0, sepPos-1)
-    result.name = copy(path, sepPos+1, dotPos-1)
-    result.ext = copy(path, dotPos)
-
-proc extractDir*(path: string): string {.noSideEffect, deprecated.} =
-  ## Extracts the directory of a given path. This is almost the
-  ## same as the `head` result of `splitPath`, except that
-  ## ``extractDir("/usr/lib/") == "/usr/lib/"``.
-  ## **Deprecated since version 0.8.2**: Use ``splitFile(path).dir`` instead.
-  result = splitFile(path).dir
-
-proc extractFilename*(path: string): string {.noSideEffect.} =
-  ## Extracts the filename of a given `path`. This is the same as 
-  ## ``name & ext`` from ``splitFile(path)``.
-  if path.len == 0 or path[path.len-1] in {dirSep, altSep}:
-    result = ""
+    var a, b: Timespec
+    a.tv_sec = posix.Time(milsecs div 1000)
+    a.tv_nsec = (milsecs mod 1000) * 1000 * 1000
+    discard posix.nanosleep(a, b)
+
+proc getFileSize*(file: string): BiggestInt {.rtl, extern: "nos$1",
+  tags: [ReadIOEffect], noWeirdTarget.} =
+  ## Returns the file size of `file` (in bytes). ``OSError`` is
+  ## raised in case of an error.
+  when defined(windows):
+    var a: WIN32_FIND_DATA
+    var resA = findFirstFile(file, a)
+    if resA == -1: raiseOSError(osLastError(), file)
+    result = rdFileSize(a)
+    findClose(resA)
   else:
-    result = splitPath(path).tail
+    var rawInfo: Stat
+    if stat(file, rawInfo) < 0'i32:
+      raiseOSError(osLastError(), file)
+    rawInfo.st_size
+
+when defined(windows) or weirdTarget:
+  type
+    DeviceId* = int32
+    FileId* = int64
+else:
+  type
+    DeviceId* = Dev
+    FileId* = Ino
 
-proc expandFilename*(filename: string): string =
-  ## Returns the full path of `filename`, raises EOS in case of an error.
+type
+  FileInfo* = object
+    ## Contains information associated with a file object.
+    ##
+    ## See also:
+    ## * `getFileInfo(handle) proc`_
+    ## * `getFileInfo(file) proc`_
+    ## * `getFileInfo(path, followSymlink) proc`_
+    id*: tuple[device: DeviceId, file: FileId] ## Device and file id.
+    kind*: PathComponent              ## Kind of file object - directory, symlink, etc.
+    size*: BiggestInt                 ## Size of file.
+    permissions*: set[FilePermission] ## File permissions
+    linkCount*: BiggestInt            ## Number of hard links the file object has.
+    lastAccessTime*: times.Time       ## Time file was last accessed.
+    lastWriteTime*: times.Time        ## Time file was last modified/written to.
+    creationTime*: times.Time         ## Time file was created. Not supported on all systems!
+    blockSize*: int                   ## Preferred I/O block size for this object.
+                                      ## In some filesystems, this may vary from file to file.
+    isSpecial*: bool                  ## Is file special? (on Unix some "files"
+                                      ## can be special=non-regular like FIFOs,
+                                      ## devices); for directories `isSpecial`
+                                      ## is always `false`, for symlinks it is
+                                      ## the same as for the link's target.
+
+template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
+  ## Transforms the native file info structure into the one nim uses.
+  ## 'rawInfo' is either a 'BY_HANDLE_FILE_INFORMATION' structure on Windows,
+  ## or a 'Stat' structure on posix
   when defined(windows):
-    var unused: cstring
-    result = newString(3072)
-    var L = GetFullPathNameA(filename, 3072'i32, result, unused)
-    if L <= 0'i32 or L >= 3072'i32: OSError()
-    setLen(result, L)
+    template merge[T](a, b): untyped =
+       cast[T](
+        (uint64(cast[uint32](a))) or
+        (uint64(cast[uint32](b)) shl 32)
+       )
+    formalInfo.id.device = rawInfo.dwVolumeSerialNumber
+    formalInfo.id.file = merge[FileId](rawInfo.nFileIndexLow, rawInfo.nFileIndexHigh)
+    formalInfo.size = merge[BiggestInt](rawInfo.nFileSizeLow, rawInfo.nFileSizeHigh)
+    formalInfo.linkCount = rawInfo.nNumberOfLinks
+    formalInfo.lastAccessTime = fromWinTime(rdFileTime(rawInfo.ftLastAccessTime))
+    formalInfo.lastWriteTime = fromWinTime(rdFileTime(rawInfo.ftLastWriteTime))
+    formalInfo.creationTime = fromWinTime(rdFileTime(rawInfo.ftCreationTime))
+    formalInfo.blockSize = 8192 # xxx use Windows API instead of hardcoding
+
+    # Retrieve basic permissions
+    if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_READONLY) != 0'i32:
+      formalInfo.permissions = {fpUserExec, fpUserRead, fpGroupExec,
+                                fpGroupRead, fpOthersExec, fpOthersRead}
+    else:
+      formalInfo.permissions = {fpUserExec..fpOthersRead}
+
+    # Retrieve basic file kind
+    if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32:
+      formalInfo.kind = pcDir
+    else:
+      formalInfo.kind = pcFile
+    if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32:
+      formalInfo.kind = succ(formalInfo.kind)
+
   else:
-    var res = realpath(filename, nil)
-    if res == nil: OSError()
-    result = $res
-    c_free(res)
-
-proc SplitFilename*(filename: string, name, extension: var string) {.
-  noSideEffect, deprecated.} = 
-  ## Splits a filename into (name, extension), so that
-  ## ``name & extension == filename``.
+    template checkAndIncludeMode(rawMode, formalMode: untyped) =
+      if (rawInfo.st_mode and rawMode.Mode) != 0.Mode:
+        formalInfo.permissions.incl(formalMode)
+    formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
+    formalInfo.size = rawInfo.st_size
+    formalInfo.linkCount = rawInfo.st_nlink.BiggestInt
+    formalInfo.lastAccessTime = rawInfo.st_atim.toTime
+    formalInfo.lastWriteTime = rawInfo.st_mtim.toTime
+    formalInfo.creationTime = rawInfo.st_ctim.toTime
+    formalInfo.blockSize = rawInfo.st_blksize
+
+    formalInfo.permissions = {}
+    checkAndIncludeMode(S_IRUSR, fpUserRead)
+    checkAndIncludeMode(S_IWUSR, fpUserWrite)
+    checkAndIncludeMode(S_IXUSR, fpUserExec)
+
+    checkAndIncludeMode(S_IRGRP, fpGroupRead)
+    checkAndIncludeMode(S_IWGRP, fpGroupWrite)
+    checkAndIncludeMode(S_IXGRP, fpGroupExec)
+
+    checkAndIncludeMode(S_IROTH, fpOthersRead)
+    checkAndIncludeMode(S_IWOTH, fpOthersWrite)
+    checkAndIncludeMode(S_IXOTH, fpOthersExec)
+
+    (formalInfo.kind, formalInfo.isSpecial) =
+      if S_ISDIR(rawInfo.st_mode):
+        (pcDir, false)
+      elif S_ISLNK(rawInfo.st_mode):
+        assert(path != "") # symlinks can't occur for file handles
+        getSymlinkFileKind(path)
+      else:
+        (pcFile, not S_ISREG(rawInfo.st_mode))
+
+when defined(js):
+  when not declared(FileHandle):
+    type FileHandle = distinct int32
+  when not declared(File):
+    type File = object
+
+proc getFileInfo*(handle: FileHandle): FileInfo {.noWeirdTarget.} =
+  ## Retrieves file information for the file object represented by the given
+  ## handle.
   ##
-  ## Example: After ``SplitFilename("usr/local/nimrodc.html", name, ext)``,
-  ## `name` is "usr/local/nimrodc" and `ext` is ".html".
-  ## If the file has no extension, extension is the empty string.
-  ## **Deprecated since version 0.8.2**: Use ``splitFile(filename)`` instead.
-  var extPos = searchExtPos(filename)
-  if extPos >= 0:
-    name = copy(filename, 0, extPos-1)
-    extension = copy(filename, extPos)
+  ## If the information cannot be retrieved, such as when the file handle
+  ## is invalid, `OSError` is raised.
+  ##
+  ## See also:
+  ## * `getFileInfo(file) proc`_
+  ## * `getFileInfo(path, followSymlink) proc`_
+
+  # Done: ID, Kind, Size, Permissions, Link Count
+  when defined(windows):
+    var rawInfo: BY_HANDLE_FILE_INFORMATION
+    # We have to use the super special '_get_osfhandle' call (wrapped above)
+    # To transform the C file descriptor to a native file handle.
+    var realHandle = get_osfhandle(handle)
+    if getFileInformationByHandle(realHandle, addr rawInfo) == 0:
+      raiseOSError(osLastError(), $handle)
+    rawToFormalFileInfo(rawInfo, "", result)
   else:
-    name = filename # make a string copy here
-    extension = ""
-
-proc extractFileExt*(filename: string): string {.noSideEffect, deprecated.} =
-  ## Extracts the file extension of a given `filename`. This is the
-  ## same as the `extension` result of `splitFilename`.
-  ## **Deprecated since version 0.8.2**: Use ``splitFile(filename).ext``
-  ## instead.
-  result = splitFile(filename).ext
-
-proc extractFileTrunk*(filename: string): string {.noSideEffect, deprecated.} =
-  ## Extracts the file name of a given `filename`. This removes any
-  ## directory information and the file extension.
-  ## **Deprecated since version 0.8.2**: Use ``splitFile(path).name`` instead.
-  result = splitFile(filename).name
-  
-proc ChangeFileExt*(filename, ext: string): string {.noSideEffect.} =
-  ## Changes the file extension to `ext`.
+    var rawInfo: Stat
+    if fstat(handle, rawInfo) < 0'i32:
+      raiseOSError(osLastError(), $handle)
+    rawToFormalFileInfo(rawInfo, "", result)
+
+proc getFileInfo*(file: File): FileInfo {.noWeirdTarget.} =
+  ## Retrieves file information for the file object.
   ##
-  ## If the `filename` has no extension, `ext` will be added.
-  ## If `ext` == "" then any extension is removed.
-  ## `Ext` should be given without the leading '.', because some
-  ## filesystems may use a different character. (Although I know
-  ## of none such beast.)
-  var extPos = searchExtPos(filename)
-  if extPos < 0: result = filename & normExt(ext)
-  else: result = copy(filename, 0, extPos-1) & normExt(ext)
-
-proc addFileExt*(filename, ext: string): string {.noSideEffect.} =
-  ## Adds the file extension `ext` to `filename`, unless
-  ## `filename` already has an extension.
+  ## See also:
+  ## * `getFileInfo(handle) proc`_
+  ## * `getFileInfo(path, followSymlink) proc`_
+  if file.isNil:
+    raise newException(IOError, "File is nil")
+  result = getFileInfo(file.getFileHandle())
+
+proc getFileInfo*(path: string, followSymlink = true): FileInfo {.noWeirdTarget.} =
+  ## Retrieves file information for the file object pointed to by `path`.
   ##
-  ## `Ext` should be given without the leading '.', because some
-  ## filesystems may use a different character.
-  ## (Although I know of none such beast.)
-  var extPos = searchExtPos(filename)
-  if extPos < 0: result = filename & normExt(ext)
-  else: result = filename
-
-proc AppendFileExt*(filename, ext: string): string {.
-  noSideEffect, deprecated.} =
-  ## **Deprecated since version 0.8.2**: Use `addFileExt` instead.
-  result = addFileExt(filename, ext)
-
-proc cmpPaths*(pathA, pathB: string): int {.noSideEffect.} =
-  ## Compares two paths.
+  ## Due to intrinsic differences between operating systems, the information
+  ## contained by the returned `FileInfo object`_ will be slightly
+  ## different across platforms, and in some cases, incomplete or inaccurate.
   ##
-  ## On a case-sensitive filesystem this is done
-  ## case-sensitively otherwise case-insensitively. Returns:
+  ## When `followSymlink` is true (default), symlinks are followed and the
+  ## information retrieved is information related to the symlink's target.
+  ## Otherwise, information on the symlink itself is retrieved (however,
+  ## field `isSpecial` is still determined from the target on Unix).
   ##
-  ## | 0 iff pathA == pathB
-  ## | < 0 iff pathA < pathB
-  ## | > 0 iff pathA > pathB
-  if FileSystemCaseSensitive:
-    result = cmp(pathA, pathB)
-  else:
-    result = cmpIgnoreCase(pathA, pathB)
-
-proc sameFile*(path1, path2: string): bool =
-  ## Returns True if both pathname arguments refer to the same file or
-  ## directory (as indicated by device number and i-node number).
-  ## Raises an exception if an stat() call on either pathname fails.
-  when defined(Windows):
+  ## If the information cannot be retrieved, such as when the path doesn't
+  ## exist, or when permission restrictions prevent the program from retrieving
+  ## file information, `OSError` is raised.
+  ##
+  ## See also:
+  ## * `getFileInfo(handle) proc`_
+  ## * `getFileInfo(file) proc`_
+  when defined(windows):
     var
-      a, b: TWin32FindData
-    var resA = findfirstFileA(path1, a)
-    var resB = findfirstFileA(path2, b)
-    if resA != -1 and resB != -1:
-      result = $a.cFileName == $b.cFileName
-    else:
-      # work around some ``findfirstFileA`` bugs
-      result = cmpPaths(path1, path2) == 0
-    if resA != -1: findclose(resA)
-    if resB != -1: findclose(resB)
+      handle = openHandle(path, followSymlink)
+      rawInfo: BY_HANDLE_FILE_INFORMATION
+    if handle == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError(), path)
+    if getFileInformationByHandle(handle, addr rawInfo) == 0:
+      raiseOSError(osLastError(), path)
+    rawToFormalFileInfo(rawInfo, path, result)
+    discard closeHandle(handle)
   else:
-    var
-      a, b: TStat
-    if stat(path1, a) < 0'i32 or stat(path2, b) < 0'i32:
-      result = cmpPaths(path1, path2) == 0 # be consistent with Windows
+    var rawInfo: Stat
+    if followSymlink:
+      if stat(path, rawInfo) < 0'i32:
+        raiseOSError(osLastError(), path)
     else:
-      result = a.st_dev == b.st_dev and a.st_ino == b.st_ino
+      if lstat(path, rawInfo) < 0'i32:
+        raiseOSError(osLastError(), path)
+    rawToFormalFileInfo(rawInfo, path, result)
 
-proc sameFileContent*(path1, path2: string): bool =
-  ## Returns True if both pathname arguments refer to files with identical
+proc sameFileContent*(path1, path2: string): bool {.rtl, extern: "nos$1",
+  tags: [ReadIOEffect], noWeirdTarget.} =
+  ## Returns true if both pathname arguments refer to files with identical
   ## binary content.
-  const
-    bufSize = 8192 # 8K buffer
+  ##
+  ## See also:
+  ## * `sameFile proc`_
   var
-    a, b: TFile
+    a, b: File
   if not open(a, path1): return false
   if not open(b, path2):
     close(a)
     return false
-  var bufA = alloc(bufsize)
-  var bufB = alloc(bufsize)
-  while True:
-    var readA = readBuffer(a, bufA, bufsize)
-    var readB = readBuffer(b, bufB, bufsize)
+  let bufSize = getFileInfo(a).blockSize
+  var bufA = alloc(bufSize)
+  var bufB = alloc(bufSize)
+  while true:
+    var readA = readBuffer(a, bufA, bufSize)
+    var readB = readBuffer(b, bufB, bufSize)
     if readA != readB:
       result = false
       break
@@ -620,602 +934,99 @@ proc sameFileContent*(path1, path2: string): bool =
   close(a)
   close(b)
 
-proc copyFile*(dest, source: string) {.deprecated.} =
-  ## Copies a file from `source` to `dest`. If this fails,
-  ## `EOS` is raised.
-  ## **Deprecated since version 0.8.8**: Use this proc with named arguments
-  ## only, because the order will change!
-  when defined(Windows):
-    if CopyFileA(source, dest, 0'i32) == 0'i32: OSError()
-  else:
-    # generic version of copyFile which works for any platform:
-    const bufSize = 8000 # better for memory manager
-    var d, s: TFile
-    if not open(s, source): OSError()
-    if not open(d, dest, fmWrite):
-      close(s)
-      OSError()
-    var buf = alloc(bufsize)
-    while True:
-      var bytesread = readBuffer(s, buf, bufsize)
-      if bytesread > 0:
-        var byteswritten = writeBuffer(d, buf, bytesread)
-        if bytesread != bytesWritten:
-          dealloc(buf)
-          close(s)
-          close(d)
-          OSError()
-      if bytesread != bufSize: break
-    dealloc(buf)
-    close(s)
-    close(d)
-
-proc moveFile*(dest, source: string) {.deprecated.} =
-  ## Moves a file from `source` to `dest`. If this fails, `EOS` is raised.
-  ## **Deprecated since version 0.8.8**: Use this proc with named arguments
-  ## only, because the order will change!
-  if crename(source, dest) != 0'i32: OSError()
-
-proc removeFile*(file: string) =
-  ## Removes the `file`. If this fails, `EOS` is raised.
-  if cremove(file) != 0'i32: OSError()
-
-proc executeShellCommand*(command: string): int {.deprecated.} =
-  ## **Deprecated since version 0.8.2**: Use `execShellCmd` instead.
-  result = csystem(command)
-
-proc execShellCmd*(command: string): int =
-  ## Executes a shell command.
+proc isHidden*(path: string): bool {.noWeirdTarget.} =
+  ## Determines whether ``path`` is hidden or not, using `this
+  ## reference <https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory>`_.
   ##
-  ## Command has the form 'program args' where args are the command
-  ## line arguments given to program. The proc returns the error code
-  ## of the shell when it has finished. The proc does not return until
-  ## the process has finished. To execute a program without having a
-  ## shell involved, use the `execProcess` proc of the `osproc`
-  ## module.
-  result = csystem(command)
-
-var
-  envComputed: bool = false
-  environment: seq[string] = @[]
-
-when defined(windows):
-  # because we support Windows GUI applications, things get really
-  # messy here...
-  proc strEnd(cstr: CString, c = 0'i32): CString {.
-    importc: "strchr", header: "<string.h>".}
-
-  proc getEnvVarsC() =
-    if not envComputed:
-      var
-        env = getEnvironmentStringsA()
-        e = env
-      if e == nil: return # an error occured
-      while True:
-        var eend = strEnd(e)
-        add(environment, $e)
-        e = cast[CString](cast[TAddress](eend)+1)
-        if eend[1] == '\0': break
-      envComputed = true
-      discard FreeEnvironmentStringsA(env)
-
-else:
-  var
-    gEnv {.importc: "gEnv".}: ptr array [0..10_000, CString]
-
-  proc getEnvVarsC() =
-    # retrieves the variables of char** env of C's main proc
-    if not envComputed:
-      var i = 0
-      while True:
-        if gEnv[i] == nil: break
-        add environment, $gEnv[i]
-        inc(i)
-      envComputed = true
-
-proc findEnvVar(key: string): int =
-  getEnvVarsC()
-  var temp = key & '='
-  for i in 0..high(environment):
-    if startsWith(environment[i], temp): return i
-  return -1
-
-proc getEnv*(key: string): string =
-  ## Returns the value of the environment variable named `key`.
+  ## On Windows: returns true if it exists and its "hidden" attribute is set.
   ##
-  ## If the variable does not exist, "" is returned. To distinguish
-  ## whether a variable exists or it's value is just "", call
-  ## `existsEnv(key)`.
-  var i = findEnvVar(key)
-  if i >= 0:
-    return copy(environment[i], find(environment[i], '=')+1)
-  else:
-    var env = cgetenv(key)
-    if env == nil: return ""
-    result = $env
-
-proc existsEnv*(key: string): bool =
-  ## Checks whether the environment variable named `key` exists.
-  ## Returns true if it exists, false otherwise.
-  if cgetenv(key) != nil: return true
-  else: return findEnvVar(key) >= 0
-
-proc putEnv*(key, val: string) =
-  ## Sets the value of the environment variable named `key` to `val`.
-  ## If an error occurs, `EInvalidEnvVar` is raised.
-
-  # Note: by storing the string in the environment sequence,
-  # we gurantee that we don't free the memory before the program
-  # ends (this is needed for POSIX compliance). It is also needed so that
-  # the process itself may access its modified environment variables!
-  var indx = findEnvVar(key)
-  if indx >= 0:
-    environment[indx] = key & '=' & val
-  else:
-    add environment, (key & '=' & val)
-    indx = high(environment)
-  when defined(unix):
-    if cputenv(environment[indx]) != 0'i32:
-      OSError()
-  else:
-    if SetEnvironmentVariableA(key, val) == 0'i32:
-      OSError()
-
-iterator iterOverEnvironment*(): tuple[key, value: string] {.deprecated.} =
-  ## Iterate over all environments variables. In the first component of the
-  ## tuple is the name of the current variable stored, in the second its value.
-  ## **Deprecated since version 0.8.2**: Use `envPairs` instead.
-  getEnvVarsC()
-  for i in 0..high(environment):
-    var p = find(environment[i], '=')
-    yield (copy(environment[i], 0, p-1), copy(environment[i], p+1))
-
-iterator envPairs*(): tuple[key, value: string] =
-  ## Iterate over all environments variables. In the first component of the
-  ## tuple is the name of the current variable stored, in the second its value.
-  getEnvVarsC()
-  for i in 0..high(environment):
-    var p = find(environment[i], '=')
-    yield (copy(environment[i], 0, p-1), copy(environment[i], p+1))
-
-iterator walkFiles*(pattern: string): string =
-  ## Iterate over all the files that match the `pattern`.
+  ## On posix: returns true if ``lastPathPart(path)`` starts with ``.`` and is
+  ## not ``.`` or ``..``.
   ##
-  ## `pattern` is OS dependant, but at least the "\*.ext"
-  ## notation is supported.
-  when defined(windows):
-    var
-      f: TWin32FindData
-      res: int
-    res = findfirstFileA(pattern, f)
-    if res != -1:
-      while true:
-        if f.cFileName[0] != '.':
-          yield splitFile(pattern).dir / extractFilename($f.cFileName)
-        if findnextFileA(res, f) == 0'i32: break
-      findclose(res)
-  else: # here we use glob
-    var
-      f: TGlob
-      res: int
-    f.gl_offs = 0
-    f.gl_pathc = 0
-    f.gl_pathv = nil
-    res = glob(pattern, 0, nil, addr(f))
-    if res == 0:
-      for i in 0.. f.gl_pathc - 1:
-        assert(f.gl_pathv[i] != nil)
-        yield $f.gl_pathv[i]
-    globfree(addr(f))
-
-type
-  TPathComponent* = enum  ## Enumeration specifying a path component.
-    pcFile,               ## path refers to a file
-    pcLinkToFile,         ## path refers to a symbolic link to a file
-    pcDir,                ## path refers to a directory
-    pcLinkToDir           ## path refers to a symbolic link to a directory
+  ## **Note**: paths are not normalized to determine `isHidden`.
+  runnableExamples:
+    when defined(posix):
+      assert ".foo".isHidden
+      assert not ".foo/bar".isHidden
+      assert not ".".isHidden
+      assert not "..".isHidden
+      assert not "".isHidden
+      assert ".foo/".isHidden
 
-const
-  pcDirectory* {.deprecated.} = pcDir ## deprecated alias 
-  pcLinkToDirectory* {.deprecated.} = pcLinkToDir ## deprecated alias
-
-iterator walkDir*(dir: string): tuple[kind: TPathComponent, path: string] =
-  ## walks over the directory `dir` and yields for each directory or file in
-  ## `dir`. The component type and full path for each item is returned.
-  ## Walking is not recursive.
-  ## Example: This directory structure::
-  ##   dirA / dirB / fileB1.txt
-  ##        / dirC
-  ##        / fileA1.txt
-  ##        / fileA2.txt
-  ##
-  ## and this code:
-  ##
-  ## .. code-block:: Nimrod
-  ##     for kind, path in walkDir("dirA"):
-  ##       echo(path)
-  ##
-  ## produces this output (but not necessarily in this order!)::
-  ##   dirA/dirB
-  ##   dirA/dirC
-  ##   dirA/fileA1.txt
-  ##   dirA/fileA2.txt
   when defined(windows):
-    var f: TWIN32_Find_Data
-    var h = findfirstFileA(dir / "*", f)
-    if h != -1:
-      while true:
-        var k = pcFile
-        if f.cFilename[0] != '.':
-          if (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32:
-            k = pcDir
-          yield (k, dir / extractFilename($f.cFilename))
-        if findnextFileA(h, f) == 0'i32: break
-      findclose(h)
+    wrapUnary(attributes, getFileAttributesW, path)
+    if attributes != -1'i32:
+      result = (attributes and FILE_ATTRIBUTE_HIDDEN) != 0'i32
   else:
-    var d = openDir(dir)
-    if d != nil:
-      while true:
-        var x = readDir(d)
-        if x == nil: break
-        var y = $x.d_name
-        if y != "." and y != "..":
-          var s: TStat
-          y = dir / y
-          if stat(y, s) < 0'i32: break
-          var k = pcFile
-          if S_ISDIR(s.st_mode): k = pcDir
-          if S_ISLNK(s.st_mode): k = succ(k)
-          yield (k, y)
-      discard closeDir(d)
-
-iterator walkDirRec*(dir: string, filter={pcFile, pcDir}): string =
-  ## walks over the directory `dir` and yields for each file in `dir`. The 
-  ## full path for each file is returned.
-  ## Walking is recursive. `filter` controls the behaviour of the iterator:
+    let fileName = lastPathPart(path)
+    result = len(fileName) >= 2 and fileName[0] == '.' and fileName != ".."
+
+proc getCurrentProcessId*(): int {.noWeirdTarget.} =
+  ## Return current process ID.
   ##
-  ## ---------------------   ---------------------------------------------
-  ## filter                  meaning
-  ## ---------------------   ---------------------------------------------
-  ## ``pcFile``              yield real files
-  ## ``pcLinkToFile``        yield symbolic links to files
-  ## ``pcDir``               follow real directories
-  ## ``pcLinkToDir``         follow symbolic links to directories
-  ## ---------------------   ---------------------------------------------
-  ## 
-  var stack = @[dir]
-  while stack.len > 0:
-    for k,p in walkDir(stack.pop()):
-      if k in filter:
-        case k
-        of pcFile, pcLinkToFile: yield p
-        of pcDir, pcLinkToDir: stack.add(p)
-
-proc rawRemoveDir(dir: string) = 
+  ## See also:
+  ## * `osproc.processID(p: Process) <osproc.html#processID,Process>`_
   when defined(windows):
-    if RemoveDirectoryA(dir) == 0'i32: OSError()
+    proc GetCurrentProcessId(): DWORD {.stdcall, dynlib: "kernel32",
+                                        importc: "GetCurrentProcessId".}
+    result = GetCurrentProcessId().int
   else:
-    if rmdir(dir) != 0'i32: OSError()
-
-proc removeDir*(dir: string) =
-  ## Removes the directory `dir` including all subdirectories and files
-  ## in `dir` (recursively). If this fails, `EOS` is raised.
-  for kind, path in walkDir(dir): 
-    case kind
-    of pcFile, pcLinkToFile, pcLinkToDir: removeFile(path)
-    of pcDir: removeDir(path)
-  rawRemoveDir(dir)
-
-proc rawCreateDir(dir: string) =
-  when defined(unix):
-    if mkdir(dir, 0o711) != 0'i32 and errno != EEXIST:
-      OSError()
+    result = getpid()
+
+proc setLastModificationTime*(file: string, t: times.Time) {.noWeirdTarget.} =
+  ## Sets the `file`'s last modification time. `OSError` is raised in case of
+  ## an error.
+  when defined(posix):
+    let unixt = posix.Time(t.toUnix)
+    let micro = convert(Nanoseconds, Microseconds, t.nanosecond)
+    var timevals = [Timeval(tv_sec: unixt, tv_usec: micro),
+      Timeval(tv_sec: unixt, tv_usec: micro)] # [last access, last modification]
+    if utimes(file, timevals.addr) != 0: raiseOSError(osLastError(), file)
   else:
-    if CreateDirectoryA(dir, nil) == 0'i32 and GetLastError() != 183'i32:
-      OSError()
+    let h = openHandle(path = file, writeAccess = true)
+    if h == INVALID_HANDLE_VALUE: raiseOSError(osLastError(), file)
+    var ft = t.toWinTime.toFILETIME
+    let res = setFileTime(h, nil, nil, ft.addr)
+    discard h.closeHandle
+    if res == 0'i32: raiseOSError(osLastError(), file)
 
-proc createDir*(dir: string) =
-  ## Creates the directory `dir`.
-  ##
-  ## The directory may contain several subdirectories that do not exist yet.
-  ## The full path is created. If this fails, `EOS` is raised. It does **not**
-  ## fail if the path already exists because for most usages this does not 
-  ## indicate an error.
-  for i in 1.. dir.len-1:
-    if dir[i] in {dirsep, altsep}: rawCreateDir(copy(dir, 0, i-1))
-  rawCreateDir(dir)
-
-proc parseCmdLine*(c: string): seq[string] =
-  ## Splits a command line into several components;  
-  ## This proc is only occassionally useful, better use the `parseopt` module.
-  ##
-  ## On Windows, it uses the following parsing rules
-  ## (see http://msdn.microsoft.com/en-us/library/17w5ykft.aspx):
+
+func isValidFilename*(filename: string, maxLen = 259.Positive): bool {.since: (1, 1).} =
+  ## Returns `true` if `filename` is valid for crossplatform use.
   ##
-  ## * Arguments are delimited by white space, which is either a space or a tab.
-  ## * The caret character (^) is not recognized as an escape character or
-  ##   delimiter. The character is handled completely by the command-line parser
-  ##   in the operating system before being passed to the argv array in the
-  ##   program.
-  ## * A string surrounded by double quotation marks ("string") is interpreted
-  ##   as a single argument, regardless of white space contained within. A
-  ##   quoted string can be embedded in an argument.
-  ## * A double quotation mark preceded by a backslash (\") is interpreted as a
-  ##   literal double quotation mark character (").
-  ## * Backslashes are interpreted literally, unless they immediately precede
-  ##   a double quotation mark.
-  ## * If an even number of backslashes is followed by a double quotation mark,
-  ##   one backslash is placed in the argv array for every pair of backslashes,
-  ##   and the double quotation mark is interpreted as a string delimiter.
-  ## * If an odd number of backslashes is followed by a double quotation mark,
-  ##   one backslash is placed in the argv array for every pair of backslashes,
-  ##   and the double quotation mark is "escaped" by the remaining backslash,
-  ##   causing a literal double quotation mark (") to be placed in argv.
+  ## This is useful if you want to copy or save files across Windows, Linux, Mac, etc.
+  ## It uses `invalidFilenameChars`, `invalidFilenames` and `maxLen` to verify the specified `filename`.
   ##
-  ## On Posix systems, it uses the following parsing rules:
-  ## components are separated by
-  ## whitespace unless the whitespace occurs within ``"`` or ``'`` quotes.
-  result = @[]
-  var i = 0
-  var a = ""
-  while true:
-    setLen(a, 0)
-    while c[i] == ' ' or c[i] == '\t': inc(i)
-    when defined(windows):
-      # parse a single argument according to the above rules:
-      var inQuote = false
-      while true:
-        case c[i]        
-        of '\0': break
-        of '\\':
-          var j = i
-          while c[j] == '\\': inc(j)
-          if c[j] == '"': 
-            for k in 0..(j-i) div 2: a.add('\\')
-            if (j-i) mod 2 == 0: 
-              i = j
-            else: 
-              a.add('"')
-              i = j+1
-          else: 
-            a.add(c[i])
-            inc(i)
-        of '"':
-          inc(i)
-          if not inQuote: inQuote = true
-          elif c[i] == '"': 
-            a.add(c[i])
-            inc(i)
-          else:
-            inQuote = false
-            break
-        of ' ', '\t': 
-          if not inQuote: break
-          a.add(c[i])
-          inc(i)
-        else:
-          a.add(c[i])
-          inc(i)
-    else:
-      case c[i]
-      of '\'', '\"':
-        var delim = c[i]
-        inc(i) # skip ' or "
-        while c[i] != '\0' and c[i] != delim:
-          add a, c[i]
-          inc(i)
-        if c[i] != '\0': inc(i)
-      of '\0': break
-      else:
-        while c[i] > ' ':
-          add(a, c[i])
-          inc(i)
-    add(result, a)
-
-type
-  TFilePermission* = enum  ## file access permission; modelled after UNIX
-    fpUserExec,            ## execute access for the file owner
-    fpUserWrite,           ## write access for the file owner
-    fpUserRead,            ## read access for the file owner
-    fpGroupExec,           ## execute access for the group
-    fpGroupWrite,          ## write access for the group
-    fpGroupRead,           ## read access for the group
-    fpOthersExec,          ## execute access for others
-    fpOthersWrite,         ## write access for others
-    fpOthersRead           ## read access for others
-
-proc getFilePermissions*(filename: string): set[TFilePermission] =
-  ## retrieves file permissions for `filename`. `OSError` is raised in case of
-  ## an error. On Windows, only the ``readonly`` flag is checked, every other
-  ## permission is available in any case.
-  when defined(posix):
-    var a: TStat
-    if stat(filename, a) < 0'i32: OSError()
-    result = {}
-    if (a.st_mode and S_IRUSR) != 0'i32: result.incl(fpUserRead)
-    if (a.st_mode and S_IWUSR) != 0'i32: result.incl(fpUserWrite)
-    if (a.st_mode and S_IXUSR) != 0'i32: result.incl(fpUserExec)
-
-    if (a.st_mode and S_IRGRP) != 0'i32: result.incl(fpGroupRead)
-    if (a.st_mode and S_IWGRP) != 0'i32: result.incl(fpGroupWrite)
-    if (a.st_mode and S_IXGRP) != 0'i32: result.incl(fpGroupExec)
-
-    if (a.st_mode and S_IROTH) != 0'i32: result.incl(fpOthersRead)
-    if (a.st_mode and S_IWOTH) != 0'i32: result.incl(fpOthersWrite)
-    if (a.st_mode and S_IXOTH) != 0'i32: result.incl(fpOthersExec)
-  else:
-    var res = GetFileAttributesA(filename)
-    if res == -1'i32: OSError()
-    if (res and FILE_ATTRIBUTE_READONLY) != 0'i32:
-      result = {fpUserExec, fpUserRead, fpGroupExec, fpGroupRead, 
-                fpOthersExec, fpOthersRead}
-    else:
-      result = {fpUserExec..fpOthersRead}
-  
-proc setFilePermissions*(filename: string, permissions: set[TFilePermission]) =
-  ## sets the file permissions for `filename`. `OSError` is raised in case of
-  ## an error. On Windows, only the ``readonly`` flag is changed, depending on
-  ## ``fpUserWrite``.
-  when defined(posix):
-    var p = 0'i32
-    if fpUserRead in permissions: p = p or S_IRUSR
-    if fpUserWrite in permissions: p = p or S_IWUSR
-    if fpUserExec in permissions: p = p or S_IXUSR
-    
-    if fpGroupRead in permissions: p = p or S_IRGRP
-    if fpGroupWrite in permissions: p = p or S_IWGRP
-    if fpGroupExec in permissions: p = p or S_IXGRP
-    
-    if fpOthersRead in permissions: p = p or S_IROTH
-    if fpOthersWrite in permissions: p = p or S_IWOTH
-    if fpOthersExec in permissions: p = p or S_IXOTH
-    
-    if chmod(filename, p) != 0: OSError()
-  else:
-    var res = GetFileAttributesA(filename)
-    if res == -1'i32: OSError()
-    if fpUserWrite in permissions: 
-      res = res and not FILE_ATTRIBUTE_READONLY
-    else:
-      res = res or FILE_ATTRIBUTE_READONLY
-    if SetFileAttributesA(filename, res) == - 1'i32: 
-      OSError()
-  
-proc inclFilePermissions*(filename: string, 
-                          permissions: set[TFilePermission]) =
-  ## a convenience procedure for: 
+  ## See also:
   ##
-  ## .. code-block:: nimrod
-  ##   setFilePermissions(filename, getFilePermissions(filename)+permissions)
-  setFilePermissions(filename, getFilePermissions(filename)+permissions)
-
-proc exclFilePermissions*(filename: string, 
-                          permissions: set[TFilePermission]) =
-  ## a convenience procedure for: 
+  ## * https://docs.microsoft.com/en-us/dotnet/api/system.io.pathtoolongexception
+  ## * https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
+  ## * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
   ##
-  ## .. code-block:: nimrod
-  ##   setFilePermissions(filename, getFilePermissions(filename)-permissions)
-  setFilePermissions(filename, getFilePermissions(filename)-permissions)
-
-proc getHomeDir*(): string =
-  ## Returns the home directory of the current user.
-  when defined(windows): return getEnv("USERPROFILE") & "\\"
-  else: return getEnv("HOME") & "/"
-
-proc getConfigDir*(): string =
-  ## Returns the config directory of the current user for applications.
-  when defined(windows): return getEnv("APPDATA") & "\\"
-  else: return getEnv("HOME") & "/.config/"
-
-when 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
-  # ourselves. This has the additional benefit that the program's behaviour
-  # is always the same -- independent of the used C compiler.
-  var
-    ownArgv: seq[string]
-
-  proc paramStr(i: int): string =
-    if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLineA())
-    return ownArgv[i]
-
-  proc paramCount(): int =
-    if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLineA())
-    result = ownArgv.len-1
-
-else:
-  var
-    cmdCount {.importc: "cmdCount".}: cint
-    cmdLine {.importc: "cmdLine".}: cstringArray
-
-  proc paramStr(i: int): string =
-    if i < cmdCount and i >= 0: return $cmdLine[i]
-    raise newException(EInvalidIndex, "invalid index")
-
-  proc paramCount(): int = return cmdCount-1
-
-when defined(linux) or defined(solaris) or defined(bsd) or defined(aix):
-  proc getApplAux(procPath: string): string =
-    result = newString(256)
-    var len = readlink(procPath, result, 256)
-    if len > 256:
-      result = newString(len+1)
-      len = readlink(procPath, result, len)
-    setlen(result, len)
-
-when defined(macosx):
-  # a really hacky solution: since we like to include 2 headers we have to
-  # define two procs which in reality are the same
-  proc getExecPath1(c: cstring, size: var int32) {.
-    importc: "_NSGetExecutablePath", header: "<sys/param.h>".}
-  proc getExecPath2(c: cstring, size: var int32): bool {.
-    importc: "_NSGetExecutablePath", header: "<mach-o/dyld.h>".}
-
-proc getApplicationFilename*(): string =
-  ## Returns the filename of the application's executable.
-
-  # Linux: /proc/<pid>/exe
-  # Solaris:
-  # /proc/<pid>/object/a.out (filename only)
-  # /proc/<pid>/path/a.out (complete pathname)
-  # *BSD (and maybe Darwin too):
-  # /proc/<pid>/file
-  when defined(windows):
-    result = newString(256)
-    var len = getModuleFileNameA(0, result, 256)
-    setlen(result, int(len))
-  elif defined(linux) or defined(aix):
-    result = getApplAux("/proc/self/exe")
-  elif defined(solaris):
-    result = getApplAux("/proc/" & $getpid() & "/path/a.out")
-  elif defined(bsd):
-    result = getApplAux("/proc/" & $getpid() & "/file")
-  elif defined(macosx):
-    var size: int32
-    getExecPath1(nil, size)
-    result = newString(int(size))
-    if getExecPath2(result, size):
-      result = "" # error!
-  else:
-    # little heuristic that may work on other POSIX-like systems:
-    result = getEnv("_")
-    if len(result) == 0:
-      result = ParamStr(0) # POSIX guaranties that this contains the executable
-                           # as it has been executed by the calling process
-      if len(result) > 0 and result[0] != DirSep: # not an absolute path?
-        # iterate over any path in the $PATH environment variable
-        for p in split(getEnv("PATH"), {PathSep}):
-          var x = joinPath(p, result)
-          if ExistsFile(x): return x
-
-proc getApplicationDir*(): string =
-  ## Returns the directory of the application's executable.
-  result = splitFile(getApplicationFilename()).dir
-
-proc sleep*(milsecs: int) =
-  ## sleeps `milsecs` milliseconds.
-  when defined(windows):
-    winlean.sleep(int32(milsecs))
-  else:
-    var a, b: Ttimespec
-    a.tv_sec = TTime(milsecs div 1000)
-    a.tv_nsec = (milsecs mod 1000) * 1000
-    discard posix.nanosleep(a, b)
-
-proc getFileSize*(file: string): biggestInt =
-  ## returns the file size of `file`. Can raise ``EOS``. 
-  when defined(windows):
-    var a: TWin32FindData
-    var resA = findfirstFileA(file, a)
-    if resA == -1: OSError()
-    result = rdFileSize(a)
-    findclose(resA)
-  else:
-    var f: TFile
-    if open(f, file): 
-      result = getFileSize(f)
-      close(f)
-    else: OSError()
-
-{.pop.}
+  ## .. warning:: This only checks filenames, not whole paths
+  ##    (because basically you can mount anything as a path on Linux).
+  runnableExamples:
+    assert not isValidFilename(" foo")     # Leading white space
+    assert not isValidFilename("foo ")     # Trailing white space
+    assert not isValidFilename("foo.")     # Ends with dot
+    assert not isValidFilename("con.txt")  # "CON" is invalid (Windows)
+    assert not isValidFilename("OwO:UwU")  # ":" is invalid (Mac)
+    assert not isValidFilename("aux.bat")  # "AUX" is invalid (Windows)
+    assert not isValidFilename("")         # Empty string
+    assert not isValidFilename("foo/")     # Filename is empty
+
+  result = true
+  let f = filename.splitFile()
+  if unlikely(f.name.len + f.ext.len > maxLen or f.name.len == 0 or
+    f.name[0] == ' ' or f.name[^1] == ' ' or f.name[^1] == '.' or
+    find(f.name, invalidFilenameChars) != -1): return false
+  for invalid in invalidFilenames:
+    if cmpIgnoreCase(f.name, invalid) == 0: return false
+
+
+# deprecated declarations
+when not weirdTarget:
+  template existsFile*(args: varargs[untyped]): untyped {.deprecated: "use fileExists".} =
+    fileExists(args)
+  template existsDir*(args: varargs[untyped]): untyped {.deprecated: "use dirExists".} =
+    dirExists(args)
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index bbdea1eee..c304ecca6 100755..100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,423 +9,911 @@
 
 ## This module implements an advanced facility for executing OS processes
 ## and process communication.
+##
+## **See also:**
+## * `os module <os.html>`_
+## * `streams module <streams.html>`_
+## * `memfiles module <memfiles.html>`_
+
+include "system/inclrtl"
 
 import
-  strutils, os, strtabs, streams
+  std/[strutils, os, strtabs, streams, cpuinfo, streamwrapper,
+  private/since]
+
+export quoteShell, quoteShellWindows, quoteShellPosix
 
 when defined(windows):
-  import winlean
+  import std/winlean
 else:
-  import posix
+  import std/posix
+
+when defined(linux) and defined(useClone):
+  import std/linux
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions]
+  when defined(windows):
+    import std/widestrs
+
 
 type
-  TProcess = object of TObject
+  ProcessOption* = enum ## Options that can be passed to `startProcess proc
+                        ## <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_.
+    poEchoCmd,          ## Echo the command before execution.
+    poUsePath,          ## Asks system to search for executable using PATH environment
+                        ## variable.
+                        ## On Windows, this is the default.
+    poEvalCommand,      ## Pass `command` directly to the shell, without quoting.
+                        ## Use it only if `command` comes from trusted source.
+    poStdErrToStdOut,   ## Merge stdout and stderr to the stdout stream.
+    poParentStreams,    ## Use the parent's streams.
+    poInteractive,      ## Optimize the buffer handling for responsiveness for
+                        ## UI applications. Currently this only affects
+                        ## Windows: Named pipes are used so that you can peek
+                        ## at the process' output streams.
+    poDaemon            ## Windows: The program creates no Window.
+                        ## Unix: Start the program as a daemon. This is still
+                        ## work in progress!
+
+  ProcessObj = object of RootObj
     when defined(windows):
-      FProcessHandle: Thandle
-      inputHandle, outputHandle, errorHandle: TFileHandle
+      fProcessHandle: Handle
+      fThreadHandle: Handle
+      inHandle, outHandle, errHandle: FileHandle
+      id: Handle
     else:
-      inputHandle, outputHandle, errorHandle: TFileHandle
-    id: cint
-    exitCode: cint
-
-  PProcess* = ref TProcess ## represents an operating system process
-
-  TProcessOption* = enum ## options that can be passed `startProcess`
-    poEchoCmd,           ## echo the command before execution
-    poUseShell,          ## use the shell to execute the command; NOTE: This
-                         ## often creates a security hole!
-    poStdErrToStdOut,    ## merge stdout and stderr to the stdout stream
-    poParentStreams      ## use the parent's streams
-
-proc execProcess*(command: string,
-                  options: set[TProcessOption] = {poStdErrToStdOut,
-                                                  poUseShell}): string
-  ## A convience procedure that executes ``command`` with ``startProcess``
+      inHandle, outHandle, errHandle: FileHandle
+      id: Pid
+    inStream, outStream, errStream: owned(Stream)
+    exitStatus: cint
+    exitFlag: bool
+    options: set[ProcessOption]
+
+  Process* = ref ProcessObj ## Represents an operating system process.
+
+
+proc execProcess*(command: string, workingDir: string = "",
+    args: openArray[string] = [], env: StringTableRef = nil,
+    options: set[ProcessOption] = {poStdErrToStdOut, poUsePath, poEvalCommand}):
+  string {.rtl, extern: "nosp$1", raises: [OSError, IOError],
+                  tags: [ExecIOEffect, ReadIOEffect, RootEffect].}
+  ## A convenience procedure that executes ``command`` with ``startProcess``
   ## and returns its output as a string.
-
-proc executeProcess*(command: string,
-                     options: set[TProcessOption] = {poStdErrToStdOut,
-                                                     poUseShell}): string {.
-                                                     deprecated.} =
-  ## **Deprecated since version 0.8.2**: Use `execProcess` instead.
-  result = execProcess(command, options)
-
-proc execCmd*(command: string): int
-  ## Executes ``command`` and returns its error code. Standard input, output,
-  ## error streams are inherited from the calling process.
-
-proc executeCommand*(command: string): int {.deprecated.} =
-  ## **Deprecated since version 0.8.2**: Use `execCmd` instead.
-  result = execCmd(command)
-  
-
-proc startProcess*(command: string,
-                   workingDir: string = "",
-                   args: openarray[string] = [],
-                   env: PStringTable = nil,
-                   options: set[TProcessOption] = {poStdErrToStdOut}): PProcess
+  ##
+  ## .. warning:: This function uses `poEvalCommand` by default for backwards
+  ##   compatibility. Make sure to pass options explicitly.
+  ##
+  ## See also:
+  ## * `startProcess proc
+  ##   <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ## * `execProcesses proc <#execProcesses,openArray[string],proc(int),proc(int,Process)>`_
+  ## * `execCmd proc <#execCmd,string>`_
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   let outp = execProcess("nim", args=["c", "-r", "mytestfile.nim"], options={poUsePath})
+  ##   let outp_shell = execProcess("nim c -r mytestfile.nim")
+  ##   # Note: outp may have an interleave of text from the nim compile
+  ##   # and any output from mytestfile when it runs
+  ##   ```
+
+proc execCmd*(command: string): int {.rtl, extern: "nosp$1",
+    tags: [ExecIOEffect, ReadIOEffect, RootEffect].}
+  ## Executes ``command`` and returns its error code.
+  ##
+  ## Standard input, output, error streams are inherited from the calling process.
+  ## This operation is also often called `system`:idx:.
+  ##
+  ## See also:
+  ## * `execCmdEx proc <#execCmdEx,string,set[ProcessOption],StringTableRef,string,string>`_
+  ## * `startProcess proc
+  ##   <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ## * `execProcess proc
+  ##   <#execProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   let errC = execCmd("nim c -r mytestfile.nim")
+  ##   ```
+
+proc startProcess*(command: string, workingDir: string = "",
+    args: openArray[string] = [], env: StringTableRef = nil,
+    options: set[ProcessOption] = {poStdErrToStdOut}):
+  owned(Process) {.rtl, extern: "nosp$1", raises: [OSError, IOError],
+                   tags: [ExecIOEffect, ReadEnvEffect, RootEffect].}
   ## Starts a process. `Command` is the executable file, `workingDir` is the
   ## process's working directory. If ``workingDir == ""`` the current directory
-  ## is used. `args` are the command line arguments that are passed to the
+  ## is used (default). `args` are the command line arguments that are passed to the
   ## process. On many operating systems, the first command line argument is the
-  ## name of the executable. `args` should not contain this argument!
+  ## name of the executable. `args` should *not* contain this argument!
   ## `env` is the environment that will be passed to the process.
-  ## If ``env == nil`` the environment is inherited of
+  ## If ``env == nil`` (default) the environment is inherited of
   ## the parent process. `options` are additional flags that may be passed
-  ## to `startProcess`. See the documentation of ``TProcessOption`` for the
-  ## meaning of these flags.
+  ## to `startProcess`. See the documentation of `ProcessOption<#ProcessOption>`_
+  ## for the meaning of these flags.
+  ##
+  ## You need to `close <#close,Process>`_ the process when done.
+  ##
+  ## Note that you can't pass any `args` if you use the option
+  ## ``poEvalCommand``, which invokes the system shell to run the specified
+  ## `command`. In this situation you have to concatenate manually the contents
+  ## of `args` to `command` carefully escaping/quoting any special characters,
+  ## since it will be passed *as is* to the system shell. Each system/shell may
+  ## feature different escaping rules, so try to avoid this kind of shell
+  ## invocation if possible as it leads to non portable software.
   ##
   ## Return value: The newly created process object. Nil is never returned,
-  ## but ``EOS`` is raised in case of an error.
+  ## but ``OSError`` is raised in case of an error.
+  ##
+  ## See also:
+  ## * `execProcesses proc <#execProcesses,openArray[string],proc(int),proc(int,Process)>`_
+  ## * `execProcess proc
+  ##   <#execProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ## * `execCmd proc <#execCmd,string>`_
+
+proc close*(p: Process) {.rtl, extern: "nosp$1", raises: [IOError, OSError], tags: [WriteIOEffect].}
+  ## When the process has finished executing, cleanup related handles.
+  ##
+  ## .. warning:: If the process has not finished executing, this will forcibly
+  ##   terminate the process. Doing so may result in zombie processes and
+  ##   `pty leaks <http://stackoverflow.com/questions/27021641/how-to-fix-request-failed-on-channel-0>`_.
 
-proc suspend*(p: PProcess)
+proc suspend*(p: Process) {.rtl, extern: "nosp$1", tags: [].}
   ## Suspends the process `p`.
+  ##
+  ## See also:
+  ## * `resume proc <#resume,Process>`_
+  ## * `terminate proc <#terminate,Process>`_
+  ## * `kill proc <#kill,Process>`_
 
-proc resume*(p: PProcess)
+
+proc resume*(p: Process) {.rtl, extern: "nosp$1", tags: [].}
   ## Resumes the process `p`.
+  ##
+  ## See also:
+  ## * `suspend proc <#suspend,Process>`_
+  ## * `terminate proc <#terminate,Process>`_
+  ## * `kill proc <#kill,Process>`_
 
-proc terminate*(p: PProcess)
-  ## Terminates the process `p`.
+proc terminate*(p: Process) {.rtl, extern: "nosp$1", tags: [].}
+  ## Stop the process `p`.
+  ##
+  ## On Posix OSes the procedure sends ``SIGTERM`` to the process.
+  ## On Windows the Win32 API function ``TerminateProcess()``
+  ## is called to stop the process.
+  ##
+  ## See also:
+  ## * `suspend proc <#suspend,Process>`_
+  ## * `resume proc <#resume,Process>`_
+  ## * `kill proc <#kill,Process>`_
+  ## * `posix_utils.sendSignal(pid: Pid, signal: int) <posix_utils.html#sendSignal,Pid,int>`_
+
+proc kill*(p: Process) {.rtl, extern: "nosp$1", tags: [].}
+  ## Kill the process `p`.
+  ##
+  ## On Posix OSes the procedure sends ``SIGKILL`` to the process.
+  ## On Windows ``kill`` is simply an alias for `terminate() <#terminate,Process>`_.
+  ##
+  ## See also:
+  ## * `suspend proc <#suspend,Process>`_
+  ## * `resume proc <#resume,Process>`_
+  ## * `terminate proc <#terminate,Process>`_
+  ## * `posix_utils.sendSignal(pid: Pid, signal: int) <posix_utils.html#sendSignal,Pid,int>`_
 
-proc running*(p: PProcess): bool
-  ## Returns true iff the process `p` is still running. Returns immediately.
+proc running*(p: Process): bool {.rtl, extern: "nosp$1", raises: [OSError], tags: [].}
+  ## Returns true if the process `p` is still running. Returns immediately.
 
-proc processID*(p: PProcess): int =
-  ## returns `p`'s process ID.
+proc processID*(p: Process): int {.rtl, extern: "nosp$1".} =
+  ## Returns `p`'s process ID.
+  ##
+  ## See also:
+  ## * `os.getCurrentProcessId proc <os.html#getCurrentProcessId>`_
   return p.id
 
-proc waitForExit*(p: PProcess): int
-  ## waits for the process to finish and returns `p`'s error code.
+proc waitForExit*(p: Process, timeout: int = -1): int {.rtl,
+    extern: "nosp$1", raises: [OSError, ValueError], tags: [TimeEffect].}
+  ## Waits for the process to finish and returns `p`'s error code.
+  ##
+  ## .. warning:: Be careful when using `waitForExit` for processes created without
+  ##   `poParentStreams` because they may fill output buffers, causing deadlock.
+  ##
+  ## On posix, if the process has exited because of a signal, 128 + signal
+  ## number will be returned.
+  ##
+  ## .. warning:: When working with `timeout` parameters, remember that the value is 
+  ##   typically expressed in milliseconds, and ensure that the correct unit of time
+  ##   is used to avoid unexpected behavior.
 
-proc inputStream*(p: PProcess): PStream
-  ## returns ``p``'s input stream for writing to
+proc peekExitCode*(p: Process): int {.rtl, extern: "nosp$1", raises: [OSError], tags: [].}
+  ## Return `-1` if the process is still running. Otherwise the process' exit code.
+  ##
+  ## On posix, if the process has exited because of a signal, 128 + signal
+  ## number will be returned.
 
-proc outputStream*(p: PProcess): PStream
-  ## returns ``p``'s output stream for reading from
+proc inputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].}
+  ## Returns ``p``'s input stream for writing to.
+  ##
+  ## .. warning:: The returned `Stream` should not be closed manually as it
+  ##   is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `outputStream proc <#outputStream,Process>`_
+  ## * `errorStream proc <#errorStream,Process>`_
+
+proc outputStream*(p: Process): Stream {.rtl, extern: "nosp$1", raises: [IOError, OSError], tags: [].}
+  ## Returns ``p``'s output stream for reading from.
+  ##
+  ## You cannot perform peek/write/setOption operations to this stream.
+  ## Use `peekableOutputStream proc <#peekableOutputStream,Process>`_
+  ## if you need to peek stream.
+  ##
+  ## .. warning:: The returned `Stream` should not be closed manually as it
+  ##   is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `inputStream proc <#inputStream,Process>`_
+  ## * `errorStream proc <#errorStream,Process>`_
 
-proc errorStream*(p: PProcess): PStream
-  ## returns ``p``'s output stream for reading from
+proc errorStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].}
+  ## Returns ``p``'s error stream for reading from.
+  ##
+  ## You cannot perform peek/write/setOption operations to this stream.
+  ## Use `peekableErrorStream proc <#peekableErrorStream,Process>`_
+  ## if you need to peek stream.
+  ##
+  ## .. warning:: The returned `Stream` should not be closed manually as it
+  ##   is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `inputStream proc <#inputStream,Process>`_
+  ## * `outputStream proc <#outputStream,Process>`_
 
-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 int, b: pointer, c: int): cint {.
-             importc: "sysctl", header: "<sys/sysctl.h>".}
-
-proc countProcessors*(): int = 
-  ## returns the numer of the processors/cores the machine has.
-  ## Returns 0 if it cannot be determined.
-  when defined(windows):
-    var x = getenv("NUMBER_OF_PROCESSORS")
-    if x.len > 0: result = parseInt(x)
-  elif defined(macosx) or defined(bsd):
-    var
-      mib: array[0..3, cint]
-      len, numCPU: int
-    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
+proc peekableOutputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [], since: (1, 3).}
+  ## Returns ``p``'s output stream for reading from.
+  ##
+  ## You can peek returned stream.
+  ##
+  ## .. warning:: The returned `Stream` should not be closed manually as it
+  ##   is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `outputStream proc <#outputStream,Process>`_
+  ## * `peekableErrorStream proc <#peekableErrorStream,Process>`_
 
-proc startProcessAux(cmd: string, options: set[TProcessOption]): PProcess =
-  var c = parseCmdLine(cmd)
-  var a: seq[string] = @[] # slicing is not yet implemented :-(
-  for i in 1 .. c.len-1: add(a, c[i])
-  result = startProcess(command=c[0], args=a, options=options)
+proc peekableErrorStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [], since: (1, 3).}
+  ## Returns ``p``'s error stream for reading from.
+  ##
+  ## You can run peek operation to returned stream.
+  ##
+  ## .. warning:: The returned `Stream` should not be closed manually as it
+  ##   is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `errorStream proc <#errorStream,Process>`_
+  ## * `peekableOutputStream proc <#peekableOutputStream,Process>`_
+
+proc inputHandle*(p: Process): FileHandle {.rtl, raises: [], extern: "nosp$1",
+  tags: [].} =
+  ## Returns ``p``'s input file handle for writing to.
+  ##
+  ## .. warning:: The returned `FileHandle` should not be closed manually as
+  ##   it is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `outputHandle proc <#outputHandle,Process>`_
+  ## * `errorHandle proc <#errorHandle,Process>`_
+  result = p.inHandle
+
+proc outputHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1",
+    raises: [], tags: [].} =
+  ## Returns ``p``'s output file handle for reading from.
+  ##
+  ## .. warning:: The returned `FileHandle` should not be closed manually as
+  ##   it is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `inputHandle proc <#inputHandle,Process>`_
+  ## * `errorHandle proc <#errorHandle,Process>`_
+  result = p.outHandle
+
+proc errorHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1",
+    raises: [], tags: [].} =
+  ## Returns ``p``'s error file handle for reading from.
+  ##
+  ## .. warning:: The returned `FileHandle` should not be closed manually as
+  ##   it is closed when closing the Process ``p``.
+  ##
+  ## See also:
+  ## * `inputHandle proc <#inputHandle,Process>`_
+  ## * `outputHandle proc <#outputHandle,Process>`_
+  result = p.errHandle
+
+proc countProcessors*(): int {.rtl, extern: "nosp$1", raises: [].} =
+  ## Returns the number of the processors/cores the machine has.
+  ## Returns 0 if it cannot be detected.
+  ## It is implemented just calling `cpuinfo.countProcessors`.
+  result = cpuinfo.countProcessors()
+
+when not defined(nimHasEffectsOf):
+  {.pragma: effectsOf.}
 
 proc execProcesses*(cmds: openArray[string],
-                    options = {poStdErrToStdOut, poParentStreams},
-                    n = countProcessors()): int =
-  ## executes the commands `cmds` in parallel. Creates `n` processes
-  ## that execute in parallel. The highest return value of all processes
-  ## is returned.
+    options = {poStdErrToStdOut, poParentStreams}, n = countProcessors(),
+    beforeRunEvent: proc(idx: int) = nil,
+    afterRunEvent: proc(idx: int, p: Process) = nil):
+  int {.rtl, extern: "nosp$1",
+        raises: [ValueError, OSError, IOError],
+        tags: [ExecIOEffect, TimeEffect, ReadEnvEffect, RootEffect],
+        effectsOf: [beforeRunEvent, afterRunEvent].} =
+  ## Executes the commands `cmds` in parallel.
+  ## Creates `n` processes that execute in parallel.
+  ##
+  ## The highest (absolute) return value of all processes is returned.
+  ## Runs `beforeRunEvent` before running each command.
+
   assert n > 0
   if n > 1:
-    var q: seq[PProcess]
-    newSeq(q, n)
-    var m = min(n, cmds.len)
-    for i in 0..m-1:
-      q[i] = startProcessAux(cmds[i], options=options)
-    when defined(noBusyWaiting):
-      var r = 0
-      for i in m..high(cmds):
-        when defined(debugExecProcesses):
-          var err = ""
-          var outp = outputStream(q[r])
-          while running(q[r]) or not outp.atEnd(outp):
-            err.add(outp.readLine())
-            err.add("\n")
-          echo(err)
-        result = max(waitForExit(q[r]), result)
-        q[r] = startProcessAux(cmds[i], options=options)
-        r = (r + 1) mod n
-    else:
-      var i = m
-      while i <= high(cmds):
-        sleep(50)
-        for r in 0..n-1:
-          if not running(q[r]):
-            #echo(outputStream(q[r]).readLine())
-            result = max(waitForExit(q[r]), result)
-            q[r] = startProcessAux(cmds[i], options=options)
-            inc(i)
-            if i > high(cmds): break
-    for i in 0..m-1:
-      result = max(waitForExit(q[i]), result)  
-  else:
-    for i in 0..high(cmds):
-      var p = startProcessAux(cmds[i], options=options)
-      result = max(waitForExit(p), result)
-
-when true:
-  nil
-else:
-  proc startGUIProcess*(command: string,
-                     workingDir: string = "",
-                     args: openarray[string] = [],
-                     env: PStringTable = nil,
-                     x = -1,
-                     y = -1,
-                     width = -1,
-                     height = -1): PProcess
-
-proc execProcess(command: string,
-                 options: set[TProcessOption] = {poStdErrToStdOut,
-                                                 poUseShell}): string =
-  var p = startProcessAux(command, options=options)
-  var outp = outputStream(p)
-  result = ""
-  while running(p) or not outp.atEnd(outp):
-    result.add(outp.readLine())
-    result.add("\n")
-
-when false:
-  proc deallocCStringArray(a: cstringArray) =
     var i = 0
-    while a[i] != nil:
-      dealloc(a[i])
+    var q = newSeq[Process](n)
+    var idxs = newSeq[int](n) # map process index to cmds index
+
+    when defined(windows):
+      var w: WOHandleArray
+      var m = min(min(n, MAXIMUM_WAIT_OBJECTS), cmds.len)
+      var wcount = m
+    else:
+      var m = min(n, cmds.len)
+
+    while i < m:
+      if beforeRunEvent != nil:
+        beforeRunEvent(i)
+      q[i] = startProcess(cmds[i], options = options + {poEvalCommand})
+      idxs[i] = i
+      when defined(windows):
+        w[i] = q[i].fProcessHandle
       inc(i)
-    dealloc(a)
 
-when defined(Windows):
+    var ecount = len(cmds)
+    while ecount > 0:
+      var rexit = -1
+      when defined(windows):
+        # waiting for all children, get result if any child exits
+        var ret = waitForMultipleObjects(int32(wcount), addr(w), 0'i32,
+                                         INFINITE)
+        if ret == WAIT_TIMEOUT:
+          # must not be happen
+          discard
+        elif ret == WAIT_FAILED:
+          raiseOSError(osLastError())
+        else:
+          var status: int32
+          for r in 0..m-1:
+            if not isNil(q[r]) and q[r].fProcessHandle == w[ret]:
+              discard getExitCodeProcess(q[r].fProcessHandle, status)
+              q[r].exitFlag = true
+              q[r].exitStatus = status
+              rexit = r
+              break
+      else:
+        var status: cint = 1
+        # waiting for all children, get result if any child exits
+        let res = waitpid(-1, status, 0)
+        if res > 0:
+          for r in 0..m-1:
+            if not isNil(q[r]) and q[r].id == res:
+              if WIFEXITED(status) or WIFSIGNALED(status):
+                q[r].exitFlag = true
+                q[r].exitStatus = status
+                rexit = r
+                break
+        else:
+          let err = osLastError()
+          if err == OSErrorCode(ECHILD):
+            # some child exits, we need to check our childs exit codes
+            for r in 0..m-1:
+              if (not isNil(q[r])) and (not running(q[r])):
+                q[r].exitFlag = true
+                q[r].exitStatus = status
+                rexit = r
+                break
+          elif err == OSErrorCode(EINTR):
+            # signal interrupted our syscall, lets repeat it
+            continue
+          else:
+            # all other errors are exceptions
+            raiseOSError(err)
+
+      if rexit >= 0:
+        when defined(windows):
+          let processHandle = q[rexit].fProcessHandle
+        result = max(result, abs(q[rexit].peekExitCode()))
+        if afterRunEvent != nil: afterRunEvent(idxs[rexit], q[rexit])
+        close(q[rexit])
+        if i < len(cmds):
+          if beforeRunEvent != nil: beforeRunEvent(i)
+          q[rexit] = startProcess(cmds[i],
+                                  options = options + {poEvalCommand})
+          idxs[rexit] = i
+          when defined(windows):
+            w[rexit] = q[rexit].fProcessHandle
+          inc(i)
+        else:
+          when defined(windows):
+            for k in 0..wcount - 1:
+              if w[k] == processHandle:
+                w[k] = w[wcount - 1]
+                w[wcount - 1] = 0
+                dec(wcount)
+                break
+          q[rexit] = nil
+        dec(ecount)
+  else:
+    for i in 0..high(cmds):
+      if beforeRunEvent != nil:
+        beforeRunEvent(i)
+      var p = startProcess(cmds[i], options = options + {poEvalCommand})
+      result = max(abs(waitForExit(p)), result)
+      if afterRunEvent != nil: afterRunEvent(i, p)
+      close(p)
+
+iterator lines*(p: Process, keepNewLines = false): string {.since: (1, 3), raises: [OSError, IOError, ValueError], tags: [ReadIOEffect, TimeEffect].} =
+  ## Convenience iterator for working with `startProcess` to read data from a
+  ## background process.
+  ##
+  ## See also:
+  ## * `readLines proc <#readLines,Process>`_
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   const opts = {poUsePath, poDaemon, poStdErrToStdOut}
+  ##   var ps: seq[Process]
+  ##   for prog in ["a", "b"]: # run 2 progs in parallel
+  ##     ps.add startProcess("nim", "", ["r", prog], nil, opts)
+  ##   for p in ps:
+  ##     var i = 0
+  ##     for line in p.lines:
+  ##       echo line
+  ##       i.inc
+  ##       if i > 100: break
+  ##     p.close
+  ##   ```
+  var outp = p.outputStream
+  var line = newStringOfCap(120)
+  while outp.readLine(line):
+    if keepNewLines:
+      line.add("\n")
+    yield line
+  discard waitForExit(p)
+
+proc readLines*(p: Process): (seq[string], int) {.since: (1, 3),
+    raises: [OSError, IOError, ValueError], tags: [ReadIOEffect, TimeEffect].} =
+  ## Convenience function for working with `startProcess` to read data from a
+  ## background process.
+  ##
+  ## See also:
+  ## * `lines iterator <#lines.i,Process>`_
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   const opts = {poUsePath, poDaemon, poStdErrToStdOut}
+  ##   var ps: seq[Process]
+  ##   for prog in ["a", "b"]: # run 2 progs in parallel
+  ##     ps.add startProcess("nim", "", ["r", prog], nil, opts)
+  ##   for p in ps:
+  ##     let (lines, exCode) = p.readLines
+  ##     if exCode != 0:
+  ##       for line in lines: echo line
+  ##     p.close
+  ##   ```
+  for line in p.lines: result[0].add(line)
+  result[1] = p.peekExitCode
+
+when not defined(useNimRtl):
+  proc execProcess(command: string, workingDir: string = "",
+      args: openArray[string] = [], env: StringTableRef = nil,
+      options: set[ProcessOption] = {poStdErrToStdOut, poUsePath,
+          poEvalCommand}):
+    string =
+
+    var p = startProcess(command, workingDir = workingDir, args = args,
+        env = env, options = options)
+    var outp = outputStream(p)
+    result = ""
+    var line = newStringOfCap(120)
+    # consider `p.lines(keepNewLines=true)` to circumvent `running` busy-wait
+    while true:
+      # FIXME: converts CR-LF to LF.
+      if outp.readLine(line):
+        result.add(line)
+        result.add("\n")
+      elif not running(p): break
+    close(p)
+
+template streamAccess(p) =
+  assert poParentStreams notin p.options, "API usage error: stream access not allowed when you use poParentStreams"
+
+when defined(windows) and not defined(useNimRtl):
   # We need to implement a handle stream for Windows:
   type
-    PFileHandleStream = ref TFileHandleStream
-    TFileHandleStream = object of TStream
-      handle: THandle
+    FileHandleStream = ref object of StreamObj
+      handle: Handle
       atTheEnd: bool
 
-  proc hsClose(s: PFileHandleStream) = nil # nothing to do here
-  proc hsAtEnd(s: PFileHandleStream): bool = return s.atTheEnd
+  proc closeHandleCheck(handle: Handle) {.inline.} =
+    if handle.closeHandle() == 0:
+      raiseOSError(osLastError())
 
-  proc hsReadData(s: PFileHandleStream, buffer: pointer, bufLen: int): int =
+  proc fileClose[T: Handle | FileHandle](h: var T) {.inline.} =
+    if h > 4:
+      closeHandleCheck(h)
+      h = INVALID_HANDLE_VALUE.T
+
+  proc hsClose(s: Stream) =
+    FileHandleStream(s).handle.fileClose()
+
+  proc hsAtEnd(s: Stream): bool = return FileHandleStream(s).atTheEnd
+
+  proc hsReadData(s: Stream, buffer: pointer, bufLen: int): int =
+    var s = FileHandleStream(s)
     if s.atTheEnd: return 0
     var br: int32
-    var a = winlean.ReadFile(s.handle, buffer, bufLen, br, nil)
+    var a = winlean.readFile(s.handle, buffer, bufLen.cint, addr br, nil)
     # TRUE and zero bytes returned (EOF).
     # TRUE and n (>0) bytes returned (good data).
     # FALSE and bytes returned undefined (system error).
-    if a == 0 and br != 0: OSError()
-    s.atTheEnd = br < bufLen
+    if a == 0 and br != 0: raiseOSError(osLastError())
+    s.atTheEnd = br == 0 #< bufLen
     result = br
-  
-  proc hsWriteData(s: PFileHandleStream, buffer: pointer, bufLen: int) =
+
+  proc hsWriteData(s: Stream, buffer: pointer, bufLen: int) =
+    var s = FileHandleStream(s)
     var bytesWritten: int32
-    var a = winlean.writeFile(s.handle, buffer, bufLen, bytesWritten, nil)
-    if a == 0: OSError()
+    var a = winlean.writeFile(s.handle, buffer, bufLen.cint,
+                              addr bytesWritten, nil)
+    if a == 0: raiseOSError(osLastError())
 
-  proc newFileHandleStream(handle: THandle): PFileHandleStream =
-    new(result)
-    result.handle = handle
-    result.close = hsClose
-    result.atEnd = hsAtEnd
-    result.readData = hsReadData
-    result.writeData = hsWriteData
-    
-  proc buildCommandLine(a: string, args: openarray[string]): cstring =
-    var res = quoteIfContainsWhite(a)
-    for i in 0..high(args): 
-      res.add(' ')
-      res.add(quoteIfContainsWhite(args[i]))
-    result = cast[cstring](alloc0(res.len+1))
-    copyMem(result, cstring(res), res.len)
-
-  proc buildEnv(env: PStringTable): cstring =
+  proc newFileHandleStream(handle: Handle): owned FileHandleStream =
+    result = FileHandleStream(handle: handle, closeImpl: hsClose, atEndImpl: hsAtEnd,
+      readDataImpl: hsReadData, writeDataImpl: hsWriteData)
+
+  proc buildCommandLine(a: string, args: openArray[string]): string =
+    result = quoteShell(a)
+    for i in 0..high(args):
+      result.add(' ')
+      result.add(quoteShell(args[i]))
+
+  proc buildEnv(env: StringTableRef): tuple[str: cstring, len: int] =
     var L = 0
     for key, val in pairs(env): inc(L, key.len + val.len + 2)
-    result = cast[cstring](alloc0(L+2))
+    var str = cast[cstring](alloc0(L+2))
     L = 0
     for key, val in pairs(env):
       var x = key & "=" & val
-      copyMem(addr(result[L]), cstring(x), x.len+1) # copy \0
+      copyMem(addr(str[L]), cstring(x), x.len+1) # copy \0
       inc(L, x.len+1)
+    (str, L)
 
-  #proc open_osfhandle(osh: THandle, mode: int): int {.
+  #proc open_osfhandle(osh: Handle, mode: int): int {.
   #  importc: "_open_osfhandle", header: "<fcntl.h>".}
 
   #var
   #  O_WRONLY {.importc: "_O_WRONLY", header: "<fcntl.h>".}: int
   #  O_RDONLY {.importc: "_O_RDONLY", header: "<fcntl.h>".}: int
-
-  proc CreatePipeHandles(Rdhandle, WrHandle: var THandle) =
-    var piInheritablePipe: TSecurityAttributes
-    piInheritablePipe.nlength = SizeOF(TSecurityAttributes)
-    piInheritablePipe.lpSecurityDescriptor = nil
-    piInheritablePipe.Binherithandle = 1
-    if CreatePipe(Rdhandle, Wrhandle, piInheritablePipe, 1024) == 0'i32:
-      OSError()
-
-  proc fileClose(h: THandle) {.inline.} =
-    if h > 4: discard CloseHandle(h)
-
-  proc startProcess(command: string,
-                 workingDir: string = "",
-                 args: openarray[string] = [],
-                 env: PStringTable = nil,
-                 options: set[TProcessOption] = {poStdErrToStdOut}): PProcess =
+  proc myDup(h: Handle; inherit: WINBOOL = 1): Handle =
+    let thisProc = getCurrentProcess()
+    if duplicateHandle(thisProc, h, thisProc, addr result, 0, inherit,
+                       DUPLICATE_SAME_ACCESS) == 0:
+      raiseOSError(osLastError())
+
+  proc createAllPipeHandles(si: var STARTUPINFO;
+                            stdin, stdout, stderr: var Handle; hash: int) =
+    var sa: SECURITY_ATTRIBUTES
+    sa.nLength = sizeof(SECURITY_ATTRIBUTES).cint
+    sa.lpSecurityDescriptor = nil
+    sa.bInheritHandle = 1
+    let pipeOutName = newWideCString(r"\\.\pipe\stdout" & $hash)
+    let pipeInName = newWideCString(r"\\.\pipe\stdin" & $hash)
+    let pipeOut = createNamedPipe(pipeOutName,
+      dwOpenMode = PIPE_ACCESS_INBOUND or FILE_FLAG_WRITE_THROUGH,
+      dwPipeMode = PIPE_NOWAIT,
+      nMaxInstances = 1,
+      nOutBufferSize = 1024, nInBufferSize = 1024,
+      nDefaultTimeOut = 0, addr sa)
+    if pipeOut == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+    let pipeIn = createNamedPipe(pipeInName,
+      dwOpenMode = PIPE_ACCESS_OUTBOUND or FILE_FLAG_WRITE_THROUGH,
+      dwPipeMode = PIPE_NOWAIT,
+      nMaxInstances = 1,
+      nOutBufferSize = 1024, nInBufferSize = 1024,
+      nDefaultTimeOut = 0, addr sa)
+    if pipeIn == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+
+    si.hStdOutput = createFileW(pipeOutName,
+        FILE_WRITE_DATA or SYNCHRONIZE, 0, addr sa,
+        OPEN_EXISTING, # very important flag!
+      FILE_ATTRIBUTE_NORMAL,
+      0 # no template file for OPEN_EXISTING
+    )
+    if si.hStdOutput == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+    si.hStdError = myDup(si.hStdOutput)
+    si.hStdInput = createFileW(pipeInName,
+        FILE_READ_DATA or SYNCHRONIZE, 0, addr sa,
+        OPEN_EXISTING, # very important flag!
+      FILE_ATTRIBUTE_NORMAL,
+      0 # no template file for OPEN_EXISTING
+    )
+    if si.hStdInput == INVALID_HANDLE_VALUE:
+      raiseOSError(osLastError())
+
+    stdin = myDup(pipeIn, 0)
+    stdout = myDup(pipeOut, 0)
+    closeHandleCheck(pipeIn)
+    closeHandleCheck(pipeOut)
+    stderr = stdout
+
+  proc createPipeHandles(rdHandle, wrHandle: var Handle) =
+    var sa: SECURITY_ATTRIBUTES
+    sa.nLength = sizeof(SECURITY_ATTRIBUTES).cint
+    sa.lpSecurityDescriptor = nil
+    sa.bInheritHandle = 1
+    if createPipe(rdHandle, wrHandle, sa, 0) == 0'i32:
+      raiseOSError(osLastError())
+
+  proc startProcess(command: string, workingDir: string = "",
+      args: openArray[string] = [], env: StringTableRef = nil,
+      options: set[ProcessOption] = {poStdErrToStdOut}):
+    owned Process =
     var
-      SI: TStartupInfo
-      ProcInfo: TProcessInformation
+      si: STARTUPINFO
+      procInfo: PROCESS_INFORMATION
       success: int
-      hi, ho, he: THandle
+      hi, ho, he: Handle
     new(result)
-    SI.cb = SizeOf(SI)
+    result.options = options
+    result.exitFlag = true
+    si.cb = sizeof(si).cint
     if poParentStreams notin options:
-      SI.dwFlags = STARTF_USESTDHANDLES # STARTF_USESHOWWINDOW or
-      CreatePipeHandles(SI.hStdInput, HI)
-      CreatePipeHandles(HO, Si.hStdOutput)
-      if poStdErrToStdOut in options:
-        SI.hStdError = SI.hStdOutput
-        HE = HO
+      si.dwFlags = STARTF_USESTDHANDLES # STARTF_USESHOWWINDOW or
+      if poInteractive notin options:
+        createPipeHandles(si.hStdInput, hi)
+        createPipeHandles(ho, si.hStdOutput)
+        if poStdErrToStdOut in options:
+          si.hStdError = si.hStdOutput
+          he = ho
+        else:
+          createPipeHandles(he, si.hStdError)
+          if setHandleInformation(he, DWORD(1), DWORD(0)) == 0'i32:
+            raiseOSError(osLastError())
+        if setHandleInformation(hi, DWORD(1), DWORD(0)) == 0'i32:
+          raiseOSError(osLastError())
+        if setHandleInformation(ho, DWORD(1), DWORD(0)) == 0'i32:
+          raiseOSError(osLastError())
       else:
-        CreatePipeHandles(HE, Si.hStdError)
-      result.inputHandle = hi
-      result.outputHandle = ho
-      result.errorHandle = he
+        createAllPipeHandles(si, hi, ho, he, cast[int](result))
+      result.inHandle = FileHandle(hi)
+      result.outHandle = FileHandle(ho)
+      result.errHandle = FileHandle(he)
     else:
-      SI.hStdError = GetStdHandle(STD_ERROR_HANDLE)
-      SI.hStdInput = GetStdHandle(STD_INPUT_HANDLE)
-      SI.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE)
-      result.inputHandle = si.hStdInput
-      result.outputHandle = si.hStdOutput
-      result.errorHandle = si.hStdError
-    
+      si.hStdError = getStdHandle(STD_ERROR_HANDLE)
+      si.hStdInput = getStdHandle(STD_INPUT_HANDLE)
+      si.hStdOutput = getStdHandle(STD_OUTPUT_HANDLE)
+      result.inHandle = FileHandle(si.hStdInput)
+      result.outHandle = FileHandle(si.hStdOutput)
+      result.errHandle = FileHandle(si.hStdError)
+
     var cmdl: cstring
-    if false: # poUseShell in options:
-      cmdl = buildCommandLine(getEnv("COMSPEC"), @["/c", command] & args)
+    var cmdRoot: string
+    if poEvalCommand in options:
+      cmdl = command
+      assert args.len == 0
     else:
-      cmdl = buildCommandLine(command, args)
+      cmdRoot = buildCommandLine(command, args)
+      cmdl = cstring(cmdRoot)
     var wd: cstring = nil
-    var e: cstring = nil
+    var e = (str: nil.cstring, len: -1)
     if len(workingDir) > 0: wd = workingDir
     if env != nil: e = buildEnv(env)
     if poEchoCmd in options: echo($cmdl)
-    success = winlean.CreateProcess(nil,
-      cmdl, nil, nil, 1, NORMAL_PRIORITY_CLASS, e, wd, SI, ProcInfo)
-    
+    var tmp = newWideCString(cmdl)
+    var ee =
+      if e.str.isNil: newWideCString(cstring(nil))
+      else: newWideCString(e.str, e.len)
+    var wwd = newWideCString(wd)
+    var flags = NORMAL_PRIORITY_CLASS or CREATE_UNICODE_ENVIRONMENT
+    if poDaemon in options: flags = flags or CREATE_NO_WINDOW
+    success = winlean.createProcessW(nil, tmp, nil, nil, 1, flags,
+      ee, wwd, si, procInfo)
+    let lastError = osLastError()
+
     if poParentStreams notin options:
-      FileClose(si.hStdInput)
-      FileClose(si.hStdOutput)
+      fileClose(si.hStdInput)
+      fileClose(si.hStdOutput)
       if poStdErrToStdOut notin options:
-        FileClose(si.hStdError)
-      
-    if e != nil: dealloc(e)
-    dealloc(cmdl)
-    if success == 0: OSError()
-    # Close the handle now so anyone waiting is woken:
-    discard closeHandle(procInfo.hThread)
-    result.FProcessHandle = procInfo.hProcess
-    result.id = procInfo.dwProcessID
-
-  proc suspend(p: PProcess) =
-    discard SuspendThread(p.FProcessHandle)
-
-  proc resume(p: PProcess) =
-    discard ResumeThread(p.FProcessHandle)
-
-  proc running(p: PProcess): bool =
-    var x = waitForSingleObject(p.FProcessHandle, 50)
-    return x == WAIT_TIMEOUT
-
-  proc terminate(p: PProcess) =
-    if running(p):
-      discard TerminateProcess(p.FProcessHandle, 0)
+        fileClose(si.hStdError)
+
+    if e.str != nil: dealloc(e.str)
+    if success == 0:
+      if poInteractive in result.options: close(result)
+      const errInvalidParameter = 87.int
+      const errFileNotFound = 2.int
+      if lastError.int in {errInvalidParameter, errFileNotFound}:
+        raiseOSError(lastError,
+              "Requested command not found: '" & command & "'. OS error:")
+      else:
+        raiseOSError(lastError, command)
+    result.fProcessHandle = procInfo.hProcess
+    result.fThreadHandle = procInfo.hThread
+    result.id = procInfo.dwProcessId
+    result.exitFlag = false
+
+  proc closeThreadAndProcessHandle(p: Process) =
+    if p.fThreadHandle != 0:
+      closeHandleCheck(p.fThreadHandle)
+      p.fThreadHandle = 0
+
+    if p.fProcessHandle != 0:
+      closeHandleCheck(p.fProcessHandle)
+      p.fProcessHandle = 0
+
+  proc close(p: Process) =
+    if poParentStreams notin p.options:
+      if p.inStream == nil:
+        p.inHandle.fileClose()
+      else:
+        # p.inHandle can be already closed via inputStream.
+        p.inStream.close
+
+      # You may NOT close outputStream and errorStream.
+      assert p.outStream == nil or FileHandleStream(p.outStream).handle != INVALID_HANDLE_VALUE
+      assert p.errStream == nil or FileHandleStream(p.errStream).handle != INVALID_HANDLE_VALUE
 
-  proc waitForExit(p: PProcess): int =
-    discard WaitForSingleObject(p.FProcessHandle, Infinite)
-    var res: int32
-    discard GetExitCodeProcess(p.FProcessHandle, res)
-    result = res
-    discard CloseHandle(p.FProcessHandle)
+      if p.outHandle != p.errHandle:
+        p.errHandle.fileClose()
+      p.outHandle.fileClose()
+    p.closeThreadAndProcessHandle()
 
-  proc inputStream(p: PProcess): PStream =
-    result = newFileHandleStream(p.inputHandle)
+  proc suspend(p: Process) =
+    discard suspendThread(p.fThreadHandle)
 
-  proc outputStream(p: PProcess): PStream =
-    result = newFileHandleStream(p.outputHandle)
+  proc resume(p: Process) =
+    discard resumeThread(p.fThreadHandle)
 
-  proc errorStream(p: PProcess): PStream =
-    result = newFileHandleStream(p.errorHandle)
+  proc running(p: Process): bool =
+    if p.exitFlag:
+      return false
+    else:
+      var x = waitForSingleObject(p.fProcessHandle, 0)
+      return x == WAIT_TIMEOUT
 
-  proc execCmd(command: string): int = 
+  proc terminate(p: Process) =
+    if running(p):
+      discard terminateProcess(p.fProcessHandle, 0)
+
+  proc kill(p: Process) =
+    terminate(p)
+
+  proc waitForExit(p: Process, timeout: int = -1): int =
+    if p.exitFlag:
+      return p.exitStatus
+
+    let res = waitForSingleObject(p.fProcessHandle, timeout.int32)
+    if res == WAIT_TIMEOUT:
+      terminate(p)
+    var status: int32
+    discard getExitCodeProcess(p.fProcessHandle, status)
+    if status != STILL_ACTIVE:
+      p.exitFlag = true
+      p.exitStatus = status
+      p.closeThreadAndProcessHandle()
+      result = status
+    else:
+      result = -1
+
+  proc peekExitCode(p: Process): int =
+    if p.exitFlag:
+      return p.exitStatus
+
+    result = -1
+    var b = waitForSingleObject(p.fProcessHandle, 0) == WAIT_TIMEOUT
+    if not b:
+      var status: int32
+      discard getExitCodeProcess(p.fProcessHandle, status)
+      p.exitFlag = true
+      p.exitStatus = status
+      p.closeThreadAndProcessHandle()
+      result = status
+
+  proc inputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.inStream == nil:
+      p.inStream = newFileHandleStream(p.inHandle)
+    result = p.inStream
+
+  proc outputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.outStream == nil:
+      p.outStream = newFileHandleStream(p.outHandle)
+    result = p.outStream
+
+  proc errorStream(p: Process): Stream =
+    streamAccess(p)
+    if p.errStream == nil:
+      p.errStream = newFileHandleStream(p.errHandle)
+    result = p.errStream
+
+  proc peekableOutputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.outStream == nil:
+      p.outStream = newFileHandleStream(p.outHandle).newPipeOutStream
+    result = p.outStream
+
+  proc peekableErrorStream(p: Process): Stream =
+    streamAccess(p)
+    if p.errStream == nil:
+      p.errStream = newFileHandleStream(p.errHandle).newPipeOutStream
+    result = p.errStream
+
+  proc execCmd(command: string): int =
     var
-      SI: TStartupInfo
-      ProcInfo: TProcessInformation
-      process: THandle
+      si: STARTUPINFO
+      procInfo: PROCESS_INFORMATION
+      process: Handle
       L: int32
-    SI.cb = SizeOf(SI)
-    SI.hStdError = GetStdHandle(STD_ERROR_HANDLE)
-    SI.hStdInput = GetStdHandle(STD_INPUT_HANDLE)
-    SI.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE)
-    if winlean.CreateProcess(nil, command, nil, nil, 0,
-        NORMAL_PRIORITY_CLASS, nil, nil, SI, ProcInfo) == 0:
-      OSError()
+    si.cb = sizeof(si).cint
+    si.hStdError = getStdHandle(STD_ERROR_HANDLE)
+    si.hStdInput = getStdHandle(STD_INPUT_HANDLE)
+    si.hStdOutput = getStdHandle(STD_OUTPUT_HANDLE)
+    var c = newWideCString(command)
+    var res = winlean.createProcessW(nil, c, nil, nil, 0,
+      NORMAL_PRIORITY_CLASS, nil, nil, si, procInfo)
+    if res == 0:
+      raiseOSError(osLastError())
     else:
-      Process = ProcInfo.hProcess
-      discard CloseHandle(ProcInfo.hThread)
-      if WaitForSingleObject(Process, INFINITE) != -1:
-        discard GetExitCodeProcess(Process, L)
+      process = procInfo.hProcess
+      discard closeHandle(procInfo.hThread)
+      if waitForSingleObject(process, INFINITE) != -1:
+        discard getExitCodeProcess(process, L)
         result = int(L)
       else:
         result = -1
-      discard CloseHandle(Process)
+      discard closeHandle(process)
+
+  proc select(readfds: var seq[Process], timeout = 500): int =
+    assert readfds.len <= MAXIMUM_WAIT_OBJECTS
+    var rfds: WOHandleArray
+    for i in 0..readfds.len()-1:
+      rfds[i] = readfds[i].outHandle #fProcessHandle
+
+    var ret = waitForMultipleObjects(readfds.len.int32,
+                                     addr(rfds), 0'i32, timeout.int32)
+    case ret
+    of WAIT_TIMEOUT:
+      return 0
+    of WAIT_FAILED:
+      raiseOSError(osLastError())
+    else:
+      var i = ret - WAIT_OBJECT_0
+      readfds.del(i)
+      return 1
 
-else:
+  proc hasData*(p: Process): bool =
+    var x: int32
+    if peekNamedPipe(p.outHandle, lpTotalBytesAvail = addr x):
+      result = x > 0
+
+elif not defined(useNimRtl):
   const
     readIdx = 0
     writeIdx = 1
 
-  proc addCmdArgs(command: string, args: openarray[string]): string =
-    result = quoteIfContainsWhite(command)
-    for i in 0 .. high(args):
-      add(result, " ")
-      add(result, quoteIfContainsWhite(args[i]))
-
-  proc toCStringArray(b, a: openarray[string]): cstringArray =
-    result = cast[cstringArray](alloc0((a.len + b.len + 1) * sizeof(cstring)))
-    for i in 0..high(b):
-      result[i] = cast[cstring](alloc(b[i].len+1))
-      copyMem(result[i], cstring(b[i]), b[i].len+1)
-    for i in 0..high(a):
-      result[i+b.len] = cast[cstring](alloc(a[i].len+1))
-      copyMem(result[i+b.len], cstring(a[i]), a[i].len+1)
-
-  proc ToCStringArray(t: PStringTable): cstringArray =
+  proc isExitStatus(status: cint): bool =
+    WIFEXITED(status) or WIFSIGNALED(status)
+
+  proc envToCStringArray(t: StringTableRef): cstringArray =
     result = cast[cstringArray](alloc0((t.len + 1) * sizeof(cstring)))
     var i = 0
     for key, val in pairs(t):
@@ -434,110 +922,660 @@ else:
       copyMem(result[i], addr(x[0]), x.len+1)
       inc(i)
 
-  proc startProcess(command: string,
-                 workingDir: string = "",
-                 args: openarray[string] = [],
-                 env: PStringTable = nil,
-                 options: set[TProcessOption] = {poStdErrToStdOut}): PProcess =
+  proc envToCStringArray(): cstringArray =
+    var counter = 0
+    for key, val in envPairs(): inc counter
+    result = cast[cstringArray](alloc0((counter + 1) * sizeof(cstring)))
+    var i = 0
+    for key, val in envPairs():
+      var x = key & "=" & val
+      result[i] = cast[cstring](alloc(x.len+1))
+      copyMem(result[i], addr(x[0]), x.len+1)
+      inc(i)
+
+  type
+    StartProcessData = object
+      sysCommand: string
+      sysArgs: cstringArray
+      sysEnv: cstringArray
+      workingDir: cstring
+      pStdin, pStdout, pStderr, pErrorPipe: array[0..1, cint]
+      options: set[ProcessOption]
+
+  const useProcessAuxSpawn = declared(posix_spawn) and not defined(useFork) and
+                             not defined(useClone) and not defined(linux)
+  when useProcessAuxSpawn:
+    proc startProcessAuxSpawn(data: StartProcessData): Pid {.
+      raises: [OSError], tags: [ExecIOEffect, ReadEnvEffect, ReadDirEffect, RootEffect], gcsafe.}
+  else:
+    proc startProcessAuxFork(data: StartProcessData): Pid {.
+      raises: [OSError], tags: [ExecIOEffect, ReadEnvEffect, ReadDirEffect, RootEffect], gcsafe.}
+    {.push stacktrace: off, profiler: off.}
+    proc startProcessAfterFork(data: ptr StartProcessData) {.
+      raises: [OSError], tags: [ExecIOEffect, ReadEnvEffect, ReadDirEffect, RootEffect], cdecl, gcsafe.}
+    {.pop.}
+
+  proc startProcess(command: string, workingDir: string = "",
+      args: openArray[string] = [], env: StringTableRef = nil,
+      options: set[ProcessOption] = {poStdErrToStdOut}):
+    owned Process =
     var
-      p_stdin, p_stdout, p_stderr: array [0..1, cint]
+      pStdin, pStdout, pStderr: array[0..1, cint]
     new(result)
-    result.exitCode = 3 # for ``waitForExit``
-    if pipe(p_stdin) != 0'i32 or pipe(p_stdout) != 0'i32:
-      OSError("failed to create a pipe")
-    var Pid = fork()
-    if Pid < 0:
-      OSError("failed to fork process")
-
-    if pid == 0:
-      ## child process:
-      discard close(p_stdin[writeIdx])
-      if dup2(p_stdin[readIdx], readIdx) < 0: OSError()
-      discard close(p_stdout[readIdx])
-      if dup2(p_stdout[writeIdx], writeIdx) < 0: OSError()
-      if poStdErrToStdOut in options:
-        if dup2(p_stdout[writeIdx], 2) < 0: OSError()
+    result.options = options
+    result.exitFlag = true
+
+    if poParentStreams notin options:
+      if pipe(pStdin) != 0'i32 or pipe(pStdout) != 0'i32 or
+         pipe(pStderr) != 0'i32:
+        raiseOSError(osLastError())
+
+    var data: StartProcessData
+    var sysArgsRaw: seq[string]
+    if poEvalCommand in options:
+      const useShPath {.strdefine.} =
+        when not defined(android): "/bin/sh"
+        else: "/system/bin/sh"
+      data.sysCommand = useShPath
+      sysArgsRaw = @[useShPath, "-c", command]
+      assert args.len == 0, "`args` has to be empty when using poEvalCommand."
+    else:
+      data.sysCommand = command
+      sysArgsRaw = @[command]
+      for arg in args.items:
+        sysArgsRaw.add arg
+
+    var pid: Pid
+
+    var sysArgs = allocCStringArray(sysArgsRaw)
+    defer: deallocCStringArray(sysArgs)
+
+    var sysEnv = if env == nil:
+        envToCStringArray()
       else:
-        if pipe(p_stderr) != 0'i32: OSError("failed to create a pipe")
-        discard close(p_stderr[readIdx])
-        if dup2(p_stderr[writeIdx], 2) < 0: OSError()
+        envToCStringArray(env)
+
+    defer: deallocCStringArray(sysEnv)
+
+    data.sysArgs = sysArgs
+    data.sysEnv = sysEnv
+    data.pStdin = pStdin
+    data.pStdout = pStdout
+    data.pStderr = pStderr
+    data.workingDir = workingDir
+    data.options = options
 
+    when useProcessAuxSpawn:
+      var currentDir = getCurrentDir()
+      pid = startProcessAuxSpawn(data)
       if workingDir.len > 0:
-        os.setCurrentDir(workingDir)
-      if poUseShell notin options:
-        var a = toCStringArray([extractFilename(command)], args)
-        if env == nil:
-          discard execv(command, a)
-        else:
-          discard execve(command, a, ToCStringArray(env))
-      else:
-        var x = addCmdArgs(command, args)
-        var a = toCStringArray(["sh", "-c"], [x])
-        if env == nil:
-          discard execv("/bin/sh", a)
-        else:
-          discard execve("/bin/sh", a, ToCStringArray(env))
-      # too risky to raise an exception here:
-      quit("execve call failed: " & $strerror(errno))
+        setCurrentDir(currentDir)
+    else:
+      pid = startProcessAuxFork(data)
+
     # Parent process. Copy process information.
     if poEchoCmd in options:
-      echo(command & " " & join(args, " "))
+      echo(command, " ", join(args, " "))
     result.id = pid
+    result.exitFlag = false
+
+    if poParentStreams in options:
+      # does not make much sense, but better than nothing:
+      result.inHandle = 0
+      result.outHandle = 1
+      if poStdErrToStdOut in options:
+        result.errHandle = result.outHandle
+      else:
+        result.errHandle = 2
+    else:
+      result.inHandle = pStdin[writeIdx]
+      result.outHandle = pStdout[readIdx]
+      if poStdErrToStdOut in options:
+        result.errHandle = result.outHandle
+        discard close(pStderr[readIdx])
+      else:
+        result.errHandle = pStderr[readIdx]
+      discard close(pStderr[writeIdx])
+      discard close(pStdin[readIdx])
+      discard close(pStdout[writeIdx])
+
+  when useProcessAuxSpawn:
+    proc startProcessAuxSpawn(data: StartProcessData): Pid =
+      var attr: Tposix_spawnattr
+      var fops: Tposix_spawn_file_actions
+
+      template chck(e: untyped) =
+        if e != 0'i32: raiseOSError(osLastError())
+
+      chck posix_spawn_file_actions_init(fops)
+      chck posix_spawnattr_init(attr)
+
+      var mask: Sigset
+      chck sigemptyset(mask)
+      chck posix_spawnattr_setsigmask(attr, mask)
+      when not defined(nuttx):
+        if poDaemon in data.options:
+          chck posix_spawnattr_setpgroup(attr, 0'i32)
+
+      var flags = POSIX_SPAWN_USEVFORK or
+                  POSIX_SPAWN_SETSIGMASK
+      when not defined(nuttx):
+        if poDaemon in data.options:
+          flags = flags or POSIX_SPAWN_SETPGROUP
+      chck posix_spawnattr_setflags(attr, flags)
+
+      if not (poParentStreams in data.options):
+        chck posix_spawn_file_actions_addclose(fops, data.pStdin[writeIdx])
+        chck posix_spawn_file_actions_adddup2(fops, data.pStdin[readIdx], readIdx)
+        chck posix_spawn_file_actions_addclose(fops, data.pStdout[readIdx])
+        chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], writeIdx)
+        chck posix_spawn_file_actions_addclose(fops, data.pStderr[readIdx])
+        if poStdErrToStdOut in data.options:
+          chck posix_spawn_file_actions_adddup2(fops, data.pStdout[writeIdx], 2)
+        else:
+          chck posix_spawn_file_actions_adddup2(fops, data.pStderr[writeIdx], 2)
+
+      var res: cint
+      if data.workingDir.len > 0:
+        setCurrentDir($data.workingDir)
+      var pid: Pid
+
+      if (poUsePath in data.options):
+        res = posix_spawnp(pid, data.sysCommand.cstring, fops, attr, data.sysArgs, data.sysEnv)
+      else:
+        res = posix_spawn(pid, data.sysCommand.cstring, fops, attr, data.sysArgs, data.sysEnv)
+
+      discard posix_spawn_file_actions_destroy(fops)
+      discard posix_spawnattr_destroy(attr)
+      if res != 0'i32: raiseOSError(OSErrorCode(res), data.sysCommand)
+
+      return pid
+  else:
+    proc startProcessAuxFork(data: StartProcessData): Pid =
+      if pipe(data.pErrorPipe) != 0:
+        raiseOSError(osLastError())
+
+      defer:
+        discard close(data.pErrorPipe[readIdx])
+
+      var pid: Pid
+      var dataCopy = data
+
+      when defined(useClone):
+        const stackSize = 65536
+        let stackEnd = cast[clong](alloc(stackSize))
+        let stack = cast[pointer](stackEnd + stackSize)
+        let fn: pointer = startProcessAfterFork
+        pid = clone(fn, stack,
+                    cint(CLONE_VM or CLONE_VFORK or SIGCHLD),
+                    pointer(addr dataCopy), nil, nil, nil)
+        discard close(data.pErrorPipe[writeIdx])
+        dealloc(stack)
+      else:
+        pid = fork()
+        if pid == 0:
+          startProcessAfterFork(addr(dataCopy))
+          exitnow(1)
+
+      discard close(data.pErrorPipe[writeIdx])
+      if pid < 0: raiseOSError(osLastError())
+
+      var error: cint
+      let sizeRead = read(data.pErrorPipe[readIdx], addr error, sizeof(error))
+      if sizeRead == sizeof(error):
+        raiseOSError(OSErrorCode(error),
+                      "Could not find command: '" & $data.sysCommand & "'. OS error: " & $strerror(error))
+
+      return pid
+
+    {.push stacktrace: off, profiler: off.}
+    proc startProcessFail(data: ptr StartProcessData, error: cint = errno) =
+      discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
+      exitnow(1)
+
+    when not defined(uClibc) and (not defined(linux) or defined(android)) and
+         not defined(haiku):
+      var environ {.importc.}: cstringArray
+
+    proc startProcessAfterFork(data: ptr StartProcessData) =
+      # Warning: no GC here!
+      # Or anything that touches global structures - all called nim procs
+      # must be marked with stackTrace:off. Inspect C code after making changes.
+      if not (poParentStreams in data.options):
+        discard close(data.pStdin[writeIdx])
+        if dup2(data.pStdin[readIdx], readIdx) < 0:
+          startProcessFail(data)
+        discard close(data.pStdout[readIdx])
+        if dup2(data.pStdout[writeIdx], writeIdx) < 0:
+          startProcessFail(data)
+        discard close(data.pStderr[readIdx])
+        if (poStdErrToStdOut in data.options):
+          if dup2(data.pStdout[writeIdx], 2) < 0:
+            startProcessFail(data)
+        else:
+          if dup2(data.pStderr[writeIdx], 2) < 0:
+            startProcessFail(data)
+
+      if data.workingDir.len > 0:
+        if chdir(data.workingDir) < 0:
+          startProcessFail(data)
+
+      discard close(data.pErrorPipe[readIdx])
+      discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
+
+      if (poUsePath in data.options):
+        when defined(uClibc) or defined(linux) or defined(haiku):
+          # uClibc environment (OpenWrt included) doesn't have the full execvpe
+          var exe: string
+          try:
+            exe = findExe(data.sysCommand)
+          except OSError as e:
+            startProcessFail(data, e.errorCode)
+          discard execve(exe.cstring, data.sysArgs, data.sysEnv)
+        else:
+          # MacOSX doesn't have execvpe, so we need workaround.
+          # On MacOSX we can arrive here only from fork, so this is safe:
+          environ = data.sysEnv
+          discard execvp(data.sysCommand.cstring, data.sysArgs)
+      else:
+        discard execve(data.sysCommand.cstring, data.sysArgs, data.sysEnv)
+
+      startProcessFail(data)
+    {.pop.}
+
+  proc close(p: Process) =
+    if poParentStreams notin p.options:
+      if p.inStream != nil:
+        close(p.inStream)
+      else:
+        discard close(p.inHandle)
+
+      if p.outStream != nil:
+        close(p.outStream)
+      else:
+        discard close(p.outHandle)
+
+      if p.errStream != nil:
+        close(p.errStream)
+      else:
+        discard close(p.errHandle)
+
+  proc suspend(p: Process) =
+    if kill(p.id, SIGSTOP) != 0'i32: raiseOSError(osLastError())
+
+  proc resume(p: Process) =
+    if kill(p.id, SIGCONT) != 0'i32: raiseOSError(osLastError())
+
+  proc running(p: Process): bool =
+    if p.exitFlag:
+      return false
+    else:
+      var status: cint = 1
+      let ret = waitpid(p.id, status, WNOHANG)
+      if ret == int(p.id):
+        if isExitStatus(status):
+          p.exitFlag = true
+          p.exitStatus = status
+          return false
+        else:
+          return true
+      elif ret == 0:
+        return true # Can't establish status. Assume running.
+      else:
+        raiseOSError(osLastError())
+
+  proc terminate(p: Process) =
+    if kill(p.id, SIGTERM) != 0'i32:
+      raiseOSError(osLastError())
+
+  proc kill(p: Process) =
+    if kill(p.id, SIGKILL) != 0'i32:
+      raiseOSError(osLastError())
+
+  when defined(macosx) or defined(freebsd) or defined(netbsd) or
+       defined(openbsd) or defined(dragonfly):
+    import std/kqueue
+
+    proc waitForExit(p: Process, timeout: int = -1): int =
+      if p.exitFlag:
+        return exitStatusLikeShell(p.exitStatus)
+
+      if timeout == -1:
+        var status: cint = 1
+        if waitpid(p.id, status, 0) < 0:
+          raiseOSError(osLastError())
+        p.exitFlag = true
+        p.exitStatus = status
+      else:
+        var kqFD = kqueue()
+        if kqFD == -1:
+          raiseOSError(osLastError())
+
+        var kevIn = KEvent(ident: p.id.uint, filter: EVFILT_PROC,
+                         flags: EV_ADD, fflags: NOTE_EXIT)
+        var kevOut: KEvent
+        var tmspec: Timespec
+
+        if timeout >= 1000:
+          tmspec.tv_sec = posix.Time(timeout div 1_000)
+          tmspec.tv_nsec = (timeout %% 1_000) * 1_000_000
+        else:
+          tmspec.tv_sec = posix.Time(0)
+          tmspec.tv_nsec = (timeout * 1_000_000)
+
+        try:
+          while true:
+            var status: cint = 1
+            var count = kevent(kqFD, addr(kevIn), 1, addr(kevOut), 1,
+                               addr(tmspec))
+            if count < 0:
+              let err = osLastError()
+              if err.cint != EINTR:
+                raiseOSError(osLastError())
+            elif count == 0:
+              # timeout expired, so we trying to kill process
+              if posix.kill(p.id, SIGKILL) == -1:
+                raiseOSError(osLastError())
+              if waitpid(p.id, status, 0) < 0:
+                raiseOSError(osLastError())
+              p.exitFlag = true
+              p.exitStatus = status
+              break
+            else:
+              if kevOut.ident == p.id.uint and kevOut.filter == EVFILT_PROC:
+                if waitpid(p.id, status, 0) < 0:
+                  raiseOSError(osLastError())
+                p.exitFlag = true
+                p.exitStatus = status
+                break
+              else:
+                raiseOSError(osLastError())
+        finally:
+          discard posix.close(kqFD)
+
+      result = exitStatusLikeShell(p.exitStatus)
+  elif defined(haiku):
+    const
+      B_OBJECT_TYPE_THREAD = 3
+      B_EVENT_INVALID = 0x1000
+      B_RELATIVE_TIMEOUT = 0x8
+
+    type
+      ObjectWaitInfo {.importc: "object_wait_info", header: "OS.h".} = object
+        obj {.importc: "object".}: int32
+        typ {.importc: "type".}: uint16
+        events: uint16
+
+    proc waitForObjects(infos: ptr ObjectWaitInfo, numInfos: cint, flags: uint32,
+                        timeout: int64): clong
+                       {.importc: "wait_for_objects_etc", header: "OS.h".}
+
+    proc waitForExit(p: Process, timeout: int = -1): int =
+      if p.exitFlag:
+        return exitStatusLikeShell(p.exitStatus)
+
+      if timeout == -1:
+        var status: cint = 1
+        if waitpid(p.id, status, 0) < 0:
+          raiseOSError(osLastError())
+        p.exitFlag = true
+        p.exitStatus = status
+      else:
+        var info = ObjectWaitInfo(
+          obj: p.id, # Haiku's PID is actually the main thread ID.
+          typ: B_OBJECT_TYPE_THREAD,
+          events: B_EVENT_INVALID # notify when the thread die.
+        )
+
+        while true:
+          var status: cint = 1
+          let count = waitForObjects(addr info, 1, B_RELATIVE_TIMEOUT, timeout)
+
+          if count < 0:
+            let err = count.cint
+            if err == ETIMEDOUT:
+              # timeout expired, so we try to kill the process
+              if posix.kill(p.id, SIGKILL) == -1:
+                raiseOSError(osLastError())
+              if waitpid(p.id, status, 0) < 0:
+                raiseOSError(osLastError())
+              p.exitFlag = true
+              p.exitStatus = status
+              break
+            elif err != EINTR:
+              raiseOSError(err.OSErrorCode)
+          elif count > 0:
+            if waitpid(p.id, status, 0) < 0:
+              raiseOSError(osLastError())
+            p.exitFlag = true
+            p.exitStatus = status
+            break
+          else:
+            raiseAssert "unreachable!"
+
+      result = exitStatusLikeShell(p.exitStatus)
+
+  else:
+    import std/times except getTime
+    import std/monotimes
+
+    proc waitForExit(p: Process, timeout: int = -1): int =
+      if p.exitFlag:
+        return exitStatusLikeShell(p.exitStatus)
+
+      if timeout < 0:
+        # Backwards compatibility with previous verison to
+        # handle cases where timeout == -1, but extend
+        # to handle cases where timeout < 0
+        var status: cint
+        if waitpid(p.id, status, 0) < 0:
+          raiseOSError(osLastError())
+        p.exitFlag = true
+        p.exitStatus = status
+      else:
+        # Max 50ms delay
+        const maxWait = initDuration(milliseconds = 50)
+        let wait = initDuration(milliseconds = timeout)
+        let deadline = getMonoTime() + wait
+        # starting 50μs delay
+        var delay = initDuration(microseconds = 50)
+        
+        while true:
+          var status: cint
+          let pid = waitpid(p.id, status, WNOHANG)
+          if p.id == pid :
+            p.exitFlag = true
+            p.exitStatus = status
+            break
+          elif pid.int == -1:
+            raiseOsError(osLastError())
+          else:
+            # Continue waiting if needed
+            if getMonoTime() >= deadline:
+              # Previous version of `waitForExit`
+              # foricibly killed the process.
+              # We keep this so we don't break programs
+              # that depend on this behavior
+              if posix.kill(p.id, SIGKILL) < 0:
+                raiseOSError(osLastError())
+            else:
+              const max = 1_000_000_000
+              let 
+                newWait = getMonoTime() + delay
+                ticks = newWait.ticks()
+                ns = ticks mod max
+                secs = ticks div max
+              var 
+                waitSpec: TimeSpec
+                unused: Timespec
+              waitSpec.tv_sec = posix.Time(secs)
+              waitSpec.tv_nsec = clong ns 
+              discard posix.clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, waitSpec, unused)
+              let remaining = deadline - getMonoTime()
+              delay = min([delay * 2, remaining, maxWait])
+
+      result = exitStatusLikeShell(p.exitStatus)
+
+  proc peekExitCode(p: Process): int =
+    var status = cint(0)
+    result = -1
+    if p.exitFlag:
+      return exitStatusLikeShell(p.exitStatus)
+
+    var ret = waitpid(p.id, status, WNOHANG)
+    if ret > 0:
+      if isExitStatus(status):
+        p.exitFlag = true
+        p.exitStatus = status
+        result = exitStatusLikeShell(status)
+
+  proc createStream(handle: var FileHandle,
+                    fileMode: FileMode): owned FileStream =
+    var f: File
+    if not open(f, handle, fileMode): raiseOSError(osLastError())
+    return newFileStream(f)
+
+  proc inputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.inStream == nil:
+      p.inStream = createStream(p.inHandle, fmWrite)
+    return p.inStream
+
+  proc outputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.outStream == nil:
+      p.outStream = createStream(p.outHandle, fmRead)
+    return p.outStream
+
+  proc errorStream(p: Process): Stream =
+    streamAccess(p)
+    if p.errStream == nil:
+      p.errStream = createStream(p.errHandle, fmRead)
+    return p.errStream
+
+  proc peekableOutputStream(p: Process): Stream =
+    streamAccess(p)
+    if p.outStream == nil:
+      p.outStream = createStream(p.outHandle, fmRead).newPipeOutStream
+    return p.outStream
+
+  proc peekableErrorStream(p: Process): Stream =
+    streamAccess(p)
+    if p.errStream == nil:
+      p.errStream = createStream(p.errHandle, fmRead).newPipeOutStream
+    return p.errStream
+
+  proc csystem(cmd: cstring): cint {.nodecl, importc: "system",
+                                     header: "<stdlib.h>".}
+
+  proc execCmd(command: string): int =
+    when defined(posix):
+      let tmp = csystem(command)
+      result = if tmp == -1: tmp else: exitStatusLikeShell(tmp)
+    else:
+      result = csystem(command)
+
+  proc createFdSet(fd: var TFdSet, s: seq[Process], m: var int) =
+    FD_ZERO(fd)
+    for i in items(s):
+      m = max(m, int(i.outHandle))
+      FD_SET(cint(i.outHandle), fd)
+
+  proc pruneProcessSet(s: var seq[Process], fd: var TFdSet) =
+    var i = 0
+    var L = s.len
+    while i < L:
+      if FD_ISSET(cint(s[i].outHandle), fd) == 0'i32:
+        s[i] = s[L-1]
+        dec(L)
+      else:
+        inc(i)
+    setLen(s, L)
+
+  proc select(readfds: var seq[Process], timeout = 500): int =
+    var tv: Timeval
+    tv.tv_sec = posix.Time(0)
+    tv.tv_usec = Suseconds(timeout * 1000)
+
+    var rd: TFdSet
+    var m = 0
+    createFdSet((rd), readfds, m)
+
+    if timeout != -1:
+      result = int(select(cint(m+1), addr(rd), nil, nil, addr(tv)))
+    else:
+      result = int(select(cint(m+1), addr(rd), nil, nil, nil))
+
+    pruneProcessSet(readfds, (rd))
+
+  proc hasData*(p: Process): bool =
+    var rd: TFdSet
+
+    FD_ZERO(rd)
+    let m = max(0, int(p.outHandle))
+    FD_SET(cint(p.outHandle), rd)
+
+    result = int(select(cint(m+1), addr(rd), nil, nil, nil)) == 1
+
+
+proc execCmdEx*(command: string, options: set[ProcessOption] = {
+                poStdErrToStdOut, poUsePath}, env: StringTableRef = nil,
+                workingDir = "", input = ""): tuple[
+                output: string,
+                exitCode: int] {.raises: [OSError, IOError], tags:
+                [ExecIOEffect, ReadIOEffect, RootEffect], gcsafe.} =
+  ## A convenience proc that runs the `command`, and returns its `output` and
+  ## `exitCode`. `env` and `workingDir` params behave as for `startProcess`.
+  ## If `input.len > 0`, it is passed as stdin.
+  ##
+  ## Note: this could block if `input.len` is greater than your OS's maximum
+  ## pipe buffer size.
+  ##
+  ## See also:
+  ## * `execCmd proc <#execCmd,string>`_
+  ## * `startProcess proc
+  ##   <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ## * `execProcess proc
+  ##   <#execProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   var result = execCmdEx("nim r --hints:off -", options = {}, input = "echo 3*4")
+  ##   import std/[strutils, strtabs]
+  ##   stripLineEnd(result[0]) ## portable way to remove trailing newline, if any
+  ##   doAssert result == ("12", 0)
+  ##   doAssert execCmdEx("ls --nonexistent").exitCode != 0
+  ##   when defined(posix):
+  ##     assert execCmdEx("echo $FO", env = newStringTable({"FO": "B"})) == ("B\n", 0)
+  ##     assert execCmdEx("echo $PWD", workingDir = "/") == ("/\n", 0)
+  ##   ```
+
+  when (NimMajor, NimMinor, NimPatch) < (1, 3, 5):
+    doAssert input.len == 0
+    doAssert workingDir.len == 0
+    doAssert env == nil
+
+  var p = startProcess(command, options = options + {poEvalCommand},
+    workingDir = workingDir, env = env)
+  var outp = outputStream(p)
 
-    result.inputHandle = p_stdin[writeIdx]
-    result.outputHandle = p_stdout[readIdx]
-    if poStdErrToStdOut in options:
-      result.errorHandle = result.outputHandle
+  if input.len > 0:
+    # There is no way to provide input for the child process
+    # anymore. Closing it will create EOF on stdin instead of eternal
+    # blocking.
+    # Writing in chunks would require a selectors (eg kqueue/epoll) to avoid
+    # blocking on io.
+    inputStream(p).write(input)
+  close inputStream(p)
+
+  # consider `p.lines(keepNewLines=true)` to avoid exit code test
+  result = ("", -1)
+  var line = newStringOfCap(120)
+  while true:
+    if outp.readLine(line):
+      result[0].add(line)
+      result[0].add("\n")
     else:
-      result.errorHandle = p_stderr[readIdx]
-      discard close(p_stderr[writeIdx])
-    discard close(p_stdin[readIdx])
-    discard close(p_stdout[writeIdx])
-
-  proc suspend(p: PProcess) =
-    discard kill(p.id, SIGSTOP)
-
-  proc resume(p: PProcess) =
-    discard kill(p.id, SIGCONT)
-
-  proc running(p: PProcess): bool =
-    result = waitPid(p.id, p.exitCode, WNOHANG) == int(p.id)
-
-  proc terminate(p: PProcess) =
-    if kill(p.id, SIGTERM) == 0'i32:
-      if running(p): discard kill(p.id, SIGKILL)
-
-  proc waitForExit(p: PProcess): int =
-    #if waitPid(p.id, p.exitCode, 0) == int(p.id):
-    # ``waitPid`` fails if the process is not running anymore. But then
-    # ``running`` probably set ``p.exitCode`` for us. Since ``p.exitCode`` is
-    # initialized with 3, wrong success exit codes are prevented.
-    var oldExitCode = p.exitCode
-    if waitPid(p.id, p.exitCode, 0) < 0:
-      # failed, so restore old exitCode
-      p.exitCode = oldExitCode
-    result = int(p.exitCode)
-
-  proc inputStream(p: PProcess): PStream =
-    var f: TFile
-    if not open(f, p.inputHandle, fmWrite): OSError()
-    result = newFileStream(f)
-
-  proc outputStream(p: PProcess): PStream =
-    var f: TFile
-    if not open(f, p.outputHandle, fmRead): OSError()
-    result = newFileStream(f)
-
-  proc errorStream(p: PProcess): PStream =
-    var f: TFile
-    if not open(f, p.errorHandle, fmRead): OSError()
-    result = newFileStream(f)
-
-  proc csystem(cmd: cstring): cint {.nodecl, importc: "system".}
-
-  proc execCmd(command: string): int = 
-    result = csystem(command)
-
-when isMainModule:
-  var x = execProcess("gcc -v")
-  echo "ECHO ", x
+      result[1] = peekExitCode(p)
+      if result[1] != -1: break
+  close(p)
diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim
index 4f8f5347f..8a43daf54 100755..100644
--- a/lib/pure/parsecfg.nim
+++ b/lib/pure/parsecfg.nim
@@ -1,352 +1,659 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## The ``parsecfg`` module implements a high performance configuration file 
-## parser. The configuration file's syntax is similar to the Windows ``.ini`` 
-## format, but much more powerful, as it is not a line based parser. String 
-## literals, raw string literals and triple quoted string literals are supported 
-## as in the Nimrod programming language.
-
-## This is an example of how a configuration file may look like:
+## The `parsecfg` module implements a high performance configuration file
+## parser. The configuration file's syntax is similar to the Windows `.ini`
+## format, but much more powerful, as it is not a line based parser. String
+## literals, raw string literals and triple quoted string literals are supported
+## as in the Nim programming language.
+##
+## Example of how a configuration file may look like:
 ##
-## .. include:: doc/mytest.cfg
+## .. include:: ../../doc/mytest.cfg
 ##     :literal:
-## The file ``examples/parsecfgex.nim`` demonstrates how to use the 
-## configuration file parser:
 ##
-## .. code-block:: nimrod
-##     :file: examples/parsecfgex.nim
-
-
-import 
-  hashes, strutils, lexbase, streams
-
-type 
-  TCfgEventKind* = enum ## enumation of all events that may occur when parsing
-    cfgEof,             ## end of file reached
-    cfgSectionStart,    ## a ``[section]`` has been parsed
-    cfgKeyValuePair,    ## a ``key=value`` pair has been detected
-    cfgOption,          ## a ``--key=value`` command line option
-    cfgError            ## an error ocurred during parsing
-    
-  TCfgEvent* = object of TObject ## describes a parsing event
-    case kind*: TCfgEventKind    ## the kind of the event
-    of cfgEof: nil
-    of cfgSectionStart: 
-      section*: string           ## `section` contains the name of the 
-                                 ## parsed section start (syntax: ``[section]``)
-    of cfgKeyValuePair, cfgOption: 
-      key*, value*: string       ## contains the (key, value) pair if an option
-                                 ## of the form ``--key: value`` or an ordinary
-                                 ## ``key= value`` pair has been parsed.
-                                 ## ``value==""`` if it was not specified in the
-                                 ## configuration file.
-    of cfgError:                 ## the parser encountered an error: `msg`
-      msg*: string               ## contains the error message. No exceptions
-                                 ## are thrown if a parse error occurs.
-  
-  TTokKind = enum 
-    tkInvalid, tkEof,        
-    tkSymbol, tkEquals, tkColon, tkBracketLe, tkBracketRi, tkDashDash
-  TToken {.final.} = object  # a token
-    kind: TTokKind           # the type of the token
-    literal: string          # the parsed (string) literal
-  
-  TParserState = enum 
-    startState # , commaState # not yet used
-  TCfgParser* = object of TBaseLexer ## the parser object.
-    tok: TToken
-    state: TParserState
-    filename: string
+## Here is an example of how to use the configuration file parser:
+runnableExamples("-r:off"):
+  import std/[strutils, streams]
 
-proc open*(c: var TCfgParser, input: PStream, filename: string)
-  ## initializes the parser with an input stream. `Filename` is only used
-  ## for nice error messages.
+  let configFile = "example.ini"
+  var f = newFileStream(configFile, fmRead)
+  assert f != nil, "cannot open " & configFile
+  var p: CfgParser
+  open(p, f, configFile)
+  while true:
+    var e = next(p)
+    case e.kind
+    of cfgEof: break
+    of cfgSectionStart:   ## a `[section]` has been parsed
+      echo "new section: " & e.section
+    of cfgKeyValuePair:
+      echo "key-value-pair: " & e.key & ": " & e.value
+    of cfgOption:
+      echo "command: " & e.key & ": " & e.value
+    of cfgError:
+      echo e.msg
+  close(p)
 
-proc close*(c: var TCfgParser)
-  ## closes the parser `c` and its associated input stream.
+##[
+## Configuration file example
+]##
 
-proc next*(c: var TCfgParser): TCfgEvent
-  ## retrieves the first/next event. This controls the parser.
+##     ```none
+##     charset = "utf-8"
+##     [Package]
+##     name = "hello"
+##     --threads:on
+##     [Author]
+##     name = "nim-lang"
+##     website = "nim-lang.org"
+##     ```
 
-proc getColumn*(c: TCfgParser): int
-  ## get the current column the parser has arrived at.
+##[
+## Creating a configuration file
+]##
 
-proc getLine*(c: TCfgParser): int
-  ## get the current line the parser has arrived at.
-  
-proc getFilename*(c: TCfgParser): string
-  ## get the filename of the file that the parser processes.
+runnableExamples:
+  var dict = newConfig()
+  dict.setSectionKey("","charset", "utf-8")
+  dict.setSectionKey("Package", "name", "hello")
+  dict.setSectionKey("Package", "--threads", "on")
+  dict.setSectionKey("Author", "name", "nim-lang")
+  dict.setSectionKey("Author", "website", "nim-lang.org")
+  assert $dict == """
+charset=utf-8
+[Package]
+name=hello
+--threads:on
+[Author]
+name=nim-lang
+website=nim-lang.org
+"""
 
-proc errorStr*(c: TCfgParser, msg: string): string
-  ## returns a properly formated error message containing current line and
-  ## column information.
+##[
+## Reading a configuration file
+]##
+
+runnableExamples("-r:off"):
+  let dict = loadConfig("config.ini")
+  let charset = dict.getSectionValue("","charset")
+  let threads = dict.getSectionValue("Package","--threads")
+  let pname = dict.getSectionValue("Package","name")
+  let name = dict.getSectionValue("Author","name")
+  let website = dict.getSectionValue("Author","website")
+  echo pname & "\n" & name & "\n" & website
+
+##[
+## Modifying a configuration file
+]##
+
+runnableExamples("-r:off"):
+  var dict = loadConfig("config.ini")
+  dict.setSectionKey("Author", "name", "nim-lang")
+  dict.writeConfig("config.ini")
+
+##[
+## Deleting a section key in a configuration file
+]##
+
+runnableExamples("-r:off"):
+  var dict = loadConfig("config.ini")
+  dict.delSectionKey("Author", "website")
+  dict.writeConfig("config.ini")
+
+##[
+## Supported INI File structure
+]##
+
+# taken from https://docs.python.org/3/library/configparser.html#supported-ini-file-structure
+runnableExamples:
+  import std/streams
+
+  var dict = loadConfig(newStringStream("""[Simple Values]
+    key=value
+    spaces in keys=allowed
+    spaces in values=allowed as well
+    spaces around the delimiter = obviously
+    you can also use : to delimit keys from values
+    [All Values Are Strings]
+    values like this: 19990429
+    or this: 3.14159265359
+    are they treated as numbers : no
+    integers floats and booleans are held as: strings
+    can use the API to get converted values directly: true
+    [No Values]
+    key_without_value
+    # empty string value is not allowed =
+    [ Seletion A   ]
+    space around section name will be ignored
+    [You can use comments]
+    # like this
+    ; or this
+    # By default only in an empty line.
+    # Inline comments can be harmful because they prevent users
+    # from using the delimiting characters as parts of values.
+    # That being said, this can be customized.
+        [Sections Can Be Indented]
+            can_values_be_as_well = True
+            does_that_mean_anything_special = False
+            purpose = formatting for readability
+            # Did I mention we can indent comments, too?
+    """)
+  )
+
+  let section1 = "Simple Values"
+  assert dict.getSectionValue(section1, "key") == "value"
+  assert dict.getSectionValue(section1, "spaces in keys") == "allowed"
+  assert dict.getSectionValue(section1, "spaces in values") == "allowed as well"
+  assert dict.getSectionValue(section1, "spaces around the delimiter") == "obviously"
+  assert dict.getSectionValue(section1, "you can also use") == "to delimit keys from values"
+
+  let section2 = "All Values Are Strings"
+  assert dict.getSectionValue(section2, "values like this") == "19990429"
+  assert dict.getSectionValue(section2, "or this") == "3.14159265359"
+  assert dict.getSectionValue(section2, "are they treated as numbers") == "no"
+  assert dict.getSectionValue(section2, "integers floats and booleans are held as") == "strings"
+  assert dict.getSectionValue(section2, "can use the API to get converted values directly") == "true"
+
+  let section3 = "Seletion A"
+  assert dict.getSectionValue(section3, 
+    "space around section name will be ignored", "not an empty value") == ""
+
+  let section4 = "Sections Can Be Indented"
+  assert dict.getSectionValue(section4, "can_values_be_as_well") == "True"
+  assert dict.getSectionValue(section4, "does_that_mean_anything_special") == "False"
+  assert dict.getSectionValue(section4, "purpose") == "formatting for readability"
+
+import std/[strutils, lexbase, streams, tables]
+import std/private/decode_helpers
+import std/private/since
 
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+include "system/inclrtl"
+
+
+type
+  CfgEventKind* = enum ## enumeration of all events that may occur when parsing
+    cfgEof,            ## end of file reached
+    cfgSectionStart,   ## a `[section]` has been parsed
+    cfgKeyValuePair,   ## a `key=value` pair has been detected
+    cfgOption,         ## a `--key=value` command line option
+    cfgError           ## an error occurred during parsing
+
+  CfgEvent* = object of RootObj ## describes a parsing event
+    case kind*: CfgEventKind    ## the kind of the event
+    of cfgEof: nil
+    of cfgSectionStart:
+      section*: string          ## `section` contains the name of the
+                                ## parsed section start (syntax: `[section]`)
+    of cfgKeyValuePair, cfgOption:
+      key*, value*: string      ## contains the (key, value) pair if an option
+                                ## of the form `--key: value` or an ordinary
+                                ## `key= value` pair has been parsed.
+                                ## `value==""` if it was not specified in the
+                                ## configuration file.
+    of cfgError:                ## the parser encountered an error: `msg`
+      msg*: string              ## contains the error message. No exceptions
+                                ## are thrown if a parse error occurs.
+
+  TokKind = enum
+    tkInvalid, tkEof,
+    tkSymbol, tkEquals, tkColon, tkBracketLe, tkBracketRi, tkDashDash
+  Token = object    # a token
+    kind: TokKind   # the type of the token
+    literal: string # the parsed (string) literal
+
+  CfgParser* = object of BaseLexer ## the parser object.
+    tok: Token
+    filename: string
 
 # implementation
 
-const 
-  SymChars: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF'} 
-  
-proc rawGetTok(c: var TCfgParser, tok: var TToken)
-proc open(c: var TCfgParser, input: PStream, filename: string) = 
+const
+  SymChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', ' ', '\x80'..'\xFF', '.', '/', '\\', '-'}
+
+proc rawGetTok(c: var CfgParser, tok: var Token) {.gcsafe.}
+
+proc open*(c: var CfgParser, input: Stream, filename: string,
+           lineOffset = 0) {.rtl, extern: "npc$1".} =
+  ## Initializes the parser with an input stream. `Filename` is only used
+  ## for nice error messages. `lineOffset` can be used to influence the line
+  ## number information in the generated error messages.
   lexbase.open(c, input)
   c.filename = filename
-  c.state = startState
   c.tok.kind = tkInvalid
   c.tok.literal = ""
+  inc(c.lineNumber, lineOffset)
   rawGetTok(c, c.tok)
-  
-proc close(c: var TCfgParser) = 
+
+proc close*(c: var CfgParser) {.rtl, extern: "npc$1".} =
+  ## Closes the parser `c` and its associated input stream.
   lexbase.close(c)
 
-proc getColumn(c: TCfgParser): int = 
-  result = getColNumber(c, c.bufPos)
+proc getColumn*(c: CfgParser): int {.rtl, extern: "npc$1".} =
+  ## Gets the current column the parser has arrived at.
+  result = getColNumber(c, c.bufpos)
 
-proc getLine(c: TCfgParser): int = 
-  result = c.linenumber
+proc getLine*(c: CfgParser): int {.rtl, extern: "npc$1".} =
+  ## Gets the current line the parser has arrived at.
+  result = c.lineNumber
 
-proc getFilename(c: TCfgParser): string = 
+proc getFilename*(c: CfgParser): string {.rtl, extern: "npc$1".} =
+  ## Gets the filename of the file that the parser processes.
   result = c.filename
 
-proc handleHexChar(c: var TCfgParser, xi: var int) = 
-  case c.buf[c.bufpos]
-  of '0'..'9': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0'))
-    inc(c.bufpos)
-  of 'a'..'f': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('a') + 10)
-    inc(c.bufpos)
-  of 'A'..'F': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10)
-    inc(c.bufpos)
-  else: 
-    nil
-
-proc handleDecChars(c: var TCfgParser, xi: var int) = 
-  while c.buf[c.bufpos] in {'0'..'9'}: 
+proc handleDecChars(c: var CfgParser, xi: var int) =
+  while c.buf[c.bufpos] in {'0'..'9'}:
     xi = (xi * 10) + (ord(c.buf[c.bufpos]) - ord('0'))
     inc(c.bufpos)
 
-proc getEscapedChar(c: var TCfgParser, tok: var TToken) = 
-  inc(c.bufpos)               # skip '\'
+proc getEscapedChar(c: var CfgParser, tok: var Token) =
+  inc(c.bufpos) # skip '\'
   case c.buf[c.bufpos]
-  of 'n', 'N': 
+  of 'n', 'N':
     add(tok.literal, "\n")
-    Inc(c.bufpos)
-  of 'r', 'R', 'c', 'C': 
+    inc(c.bufpos)
+  of 'r', 'R', 'c', 'C':
     add(tok.literal, '\c')
-    Inc(c.bufpos)
-  of 'l', 'L': 
+    inc(c.bufpos)
+  of 'l', 'L':
     add(tok.literal, '\L')
-    Inc(c.bufpos)
-  of 'f', 'F': 
+    inc(c.bufpos)
+  of 'f', 'F':
     add(tok.literal, '\f')
     inc(c.bufpos)
-  of 'e', 'E': 
+  of 'e', 'E':
     add(tok.literal, '\e')
-    Inc(c.bufpos)
-  of 'a', 'A': 
+    inc(c.bufpos)
+  of 'a', 'A':
     add(tok.literal, '\a')
-    Inc(c.bufpos)
-  of 'b', 'B': 
+    inc(c.bufpos)
+  of 'b', 'B':
     add(tok.literal, '\b')
-    Inc(c.bufpos)
-  of 'v', 'V': 
+    inc(c.bufpos)
+  of 'v', 'V':
     add(tok.literal, '\v')
-    Inc(c.bufpos)
-  of 't', 'T': 
+    inc(c.bufpos)
+  of 't', 'T':
     add(tok.literal, '\t')
-    Inc(c.bufpos)
-  of '\'', '\"': 
+    inc(c.bufpos)
+  of '\'', '"':
     add(tok.literal, c.buf[c.bufpos])
-    Inc(c.bufpos)
-  of '\\': 
+    inc(c.bufpos)
+  of '\\':
     add(tok.literal, '\\')
-    Inc(c.bufpos)
-  of 'x', 'X': 
+    inc(c.bufpos)
+  of 'x', 'X':
     inc(c.bufpos)
     var xi = 0
-    handleHexChar(c, xi)
-    handleHexChar(c, xi)
-    add(tok.literal, Chr(xi))
-  of '0'..'9': 
+    if handleHexChar(c.buf[c.bufpos], xi):
+      inc(c.bufpos)
+      if handleHexChar(c.buf[c.bufpos], xi):
+        inc(c.bufpos)
+    add(tok.literal, chr(xi))
+  of '0'..'9':
     var xi = 0
     handleDecChars(c, xi)
-    if (xi <= 255): add(tok.literal, Chr(xi))
+    if (xi <= 255): add(tok.literal, chr(xi))
     else: tok.kind = tkInvalid
   else: tok.kind = tkInvalid
-  
-proc HandleCRLF(c: var TCfgParser, pos: int): int = 
+
+proc handleCRLF(c: var CfgParser, pos: int): int =
   case c.buf[pos]
-  of '\c': result = lexbase.HandleCR(c, pos)
-  of '\L': result = lexbase.HandleLF(c, pos)
+  of '\c': result = lexbase.handleCR(c, pos)
+  of '\L': result = lexbase.handleLF(c, pos)
   else: result = pos
-  
-proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) = 
-  var pos = c.bufPos + 1          # skip "
-  var buf = c.buf                 # put `buf` in a register
+
+proc getString(c: var CfgParser, tok: var Token, rawMode: bool) =
+  var pos = c.bufpos + 1 # skip "
   tok.kind = tkSymbol
-  if (buf[pos] == '\"') and (buf[pos + 1] == '\"'): 
+  if (c.buf[pos] == '"') and (c.buf[pos + 1] == '"'):
     # long string literal:
-    inc(pos, 2)               # skip ""
+    inc(pos, 2) # skip ""
                               # skip leading newline:
-    pos = HandleCRLF(c, pos)
-    buf = c.buf
-    while true: 
-      case buf[pos]
-      of '\"': 
-        if (buf[pos + 1] == '\"') and (buf[pos + 2] == '\"'): break 
-        add(tok.literal, '\"')
-        Inc(pos)
-      of '\c', '\L': 
-        pos = HandleCRLF(c, pos)
-        buf = c.buf
+    pos = handleCRLF(c, pos)
+    while true:
+      case c.buf[pos]
+      of '"':
+        if (c.buf[pos + 1] == '"') and (c.buf[pos + 2] == '"'): break
+        add(tok.literal, '"')
+        inc(pos)
+      of '\c', '\L':
+        pos = handleCRLF(c, pos)
         add(tok.literal, "\n")
-      of lexbase.EndOfFile: 
+      of lexbase.EndOfFile:
         tok.kind = tkInvalid
-        break 
-      else: 
-        add(tok.literal, buf[pos])
-        Inc(pos)
-    c.bufpos = pos + 3       # skip the three """
-  else: 
+        break
+      else:
+        add(tok.literal, c.buf[pos])
+        inc(pos)
+    c.bufpos = pos + 3 # skip the three """
+  else:
     # ordinary string literal
-    while true: 
-      var ch = buf[pos]
-      if ch == '\"': 
-        inc(pos)              # skip '"'
-        break 
-      if ch in {'\c', '\L', lexbase.EndOfFile}: 
+    while true:
+      var ch = c.buf[pos]
+      if ch == '"':
+        inc(pos) # skip '"'
+        break
+      if ch in {'\c', '\L', lexbase.EndOfFile}:
         tok.kind = tkInvalid
-        break 
-      if (ch == '\\') and not rawMode: 
-        c.bufPos = pos
+        break
+      if (ch == '\\') and not rawMode:
+        c.bufpos = pos
         getEscapedChar(c, tok)
-        pos = c.bufPos
-      else: 
+        pos = c.bufpos
+      else:
         add(tok.literal, ch)
-        Inc(pos)
+        inc(pos)
     c.bufpos = pos
 
-proc getSymbol(c: var TCfgParser, tok: var TToken) = 
+proc getSymbol(c: var CfgParser, tok: var Token) =
   var pos = c.bufpos
-  var buf = c.buf
-  while true: 
-    add(tok.literal, buf[pos])
-    Inc(pos)
-    if not (buf[pos] in SymChars): break 
+  while true:
+    add(tok.literal, c.buf[pos])
+    inc(pos)
+    if not (c.buf[pos] in SymChars): break
+
+  while tok.literal.len > 0 and tok.literal[^1] == ' ':
+    tok.literal.setLen(tok.literal.len - 1)
+
   c.bufpos = pos
   tok.kind = tkSymbol
 
-proc skip(c: var TCfgParser) = 
+proc skip(c: var CfgParser) =
   var pos = c.bufpos
-  var buf = c.buf
-  while true: 
-    case buf[pos]
-    of ' ', '\t': 
-      Inc(pos)
-    of '#', ';': 
-      while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
-    of '\c', '\L': 
-      pos = HandleCRLF(c, pos)
-      buf = c.buf
-    else: 
-      break                   # EndOfFile also leaves the loop
+  while true:
+    case c.buf[pos]
+    of ' ', '\t':
+      inc(pos)
+    of '#', ';':
+      while not (c.buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
+    of '\c', '\L':
+      pos = handleCRLF(c, pos)
+    else:
+      break # EndOfFile also leaves the loop
   c.bufpos = pos
 
-proc rawGetTok(c: var TCfgParser, tok: var TToken) = 
+proc rawGetTok(c: var CfgParser, tok: var Token) =
   tok.kind = tkInvalid
-  setlen(tok.literal, 0)
+  setLen(tok.literal, 0)
   skip(c)
   case c.buf[c.bufpos]
-  of '=': 
+  of '=':
     tok.kind = tkEquals
     inc(c.bufpos)
     tok.literal = "="
-  of '-': 
-    inc(c.bufPos)
-    if c.buf[c.bufPos] == '-': inc(c.bufPos)
-    tok.kind = tkDashDash
-    tok.literal = "--"
-  of ':': 
+  of '-':
+    inc(c.bufpos)
+    if c.buf[c.bufpos] == '-':
+      inc(c.bufpos)
+      tok.kind = tkDashDash
+      tok.literal = "--"
+    else:
+      dec(c.bufpos)
+      getSymbol(c, tok)
+  of ':':
     tok.kind = tkColon
     inc(c.bufpos)
     tok.literal = ":"
-  of 'r', 'R': 
-    if c.buf[c.bufPos + 1] == '\"': 
-      Inc(c.bufPos)
+  of 'r', 'R':
+    if c.buf[c.bufpos + 1] == '\"':
+      inc(c.bufpos)
       getString(c, tok, true)
-    else: 
+    else:
       getSymbol(c, tok)
-  of '[': 
+  of '[':
     tok.kind = tkBracketLe
     inc(c.bufpos)
-    tok.literal = "]"
-  of ']': 
+    tok.literal = "["
+  of ']':
     tok.kind = tkBracketRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     tok.literal = "]"
-  of '\"': 
+  of '"':
     getString(c, tok, false)
-  of lexbase.EndOfFile: 
+  of lexbase.EndOfFile:
     tok.kind = tkEof
     tok.literal = "[EOF]"
   else: getSymbol(c, tok)
-  
-proc errorStr(c: TCfgParser, msg: string): string = 
-  result = `%`("$1($2, $3) Error: $4", 
-               [c.filename, $getLine(c), $getColumn(c), msg])
-
-proc getKeyValPair(c: var TCfgParser, kind: TCfgEventKind): TCfgEvent = 
-  if c.tok.kind == tkSymbol: 
-    result.kind = kind
-    result.key = c.tok.literal
-    result.value = ""
+
+proc errorStr*(c: CfgParser, msg: string): string {.rtl, extern: "npc$1".} =
+  ## Returns a properly formatted error message containing current line and
+  ## column information.
+  result = `%`("$1($2, $3) Error: $4",
+                [c.filename, $getLine(c), $getColumn(c), msg])
+
+proc warningStr*(c: CfgParser, msg: string): string {.rtl, extern: "npc$1".} =
+  ## Returns a properly formatted warning message containing current line and
+  ## column information.
+  result = `%`("$1($2, $3) Warning: $4",
+                [c.filename, $getLine(c), $getColumn(c), msg])
+
+proc ignoreMsg*(c: CfgParser, e: CfgEvent): string {.rtl, extern: "npc$1".} =
+  ## Returns a properly formatted warning message containing that
+  ## an entry is ignored.
+  case e.kind
+  of cfgSectionStart: result = c.warningStr("section ignored: " & e.section)
+  of cfgKeyValuePair: result = c.warningStr("key ignored: " & e.key)
+  of cfgOption:
+    result = c.warningStr("command ignored: " & e.key & ": " & e.value)
+  of cfgError: result = e.msg
+  of cfgEof: result = ""
+
+proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent =
+  if c.tok.kind == tkSymbol:
+    case kind
+    of cfgOption, cfgKeyValuePair:
+      result = CfgEvent(kind: kind, key: c.tok.literal.move, value: "")
+    else: discard
     rawGetTok(c, c.tok)
-    if c.tok.kind in {tkEquals, tkColon}: 
+    if c.tok.kind in {tkEquals, tkColon}:
       rawGetTok(c, c.tok)
-      if c.tok.kind == tkSymbol: 
+      if c.tok.kind == tkSymbol:
         result.value = c.tok.literal
-      else: 
-        result.kind = cfgError
-        result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
+      else:
+        result = CfgEvent(kind: cfgError,
+          msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
       rawGetTok(c, c.tok)
-  else: 
-    result.kind = cfgError
-    result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
+  else:
+    result = CfgEvent(kind: cfgError,
+      msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
     rawGetTok(c, c.tok)
 
-proc next(c: var TCfgParser): TCfgEvent = 
-  case c.tok.kind  
-  of tkEof: 
-    result.kind = cfgEof
-  of tkDashDash: 
+proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} =
+  ## Retrieves the first/next event. This controls the parser.
+  case c.tok.kind
+  of tkEof:
+    result = CfgEvent(kind: cfgEof)
+  of tkDashDash:
     rawGetTok(c, c.tok)
     result = getKeyValPair(c, cfgOption)
-  of tkSymbol: 
+  of tkSymbol:
     result = getKeyValPair(c, cfgKeyValuePair)
-  of tkBracketLe: 
+  of tkBracketLe:
     rawGetTok(c, c.tok)
-    if c.tok.kind == tkSymbol: 
-      result.kind = cfgSectionStart
-      result.section = c.tok.literal
-    else: 
-      result.kind = cfgError
-      result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
+    if c.tok.kind == tkSymbol:
+      result = CfgEvent(kind: cfgSectionStart, section: c.tok.literal.move)
+    else:
+      result = CfgEvent(kind: cfgError,
+        msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
     rawGetTok(c, c.tok)
-    if c.tok.kind == tkBracketRi: 
+    if c.tok.kind == tkBracketRi:
       rawGetTok(c, c.tok)
-    else: 
-      result.kind = cfgError
-      result.msg = errorStr(c, "\']\' expected, but found: " & c.tok.literal)
-  of tkInvalid, tkEquals, tkColon, tkBracketRi: 
-    result.kind = cfgError
-    result.msg = errorStr(c, "invalid token: " & c.tok.literal)
+    else:
+      result = CfgEvent(kind: cfgError,
+        msg: errorStr(c, "']' expected, but found: " & c.tok.literal))
+  of tkInvalid, tkEquals, tkColon, tkBracketRi:
+    result = CfgEvent(kind: cfgError,
+      msg: errorStr(c, "invalid token: " & c.tok.literal))
     rawGetTok(c, c.tok)
+
+# ---------------- Configuration file related operations ----------------
+type
+  Config* = OrderedTableRef[string, OrderedTableRef[string, string]]
+
+proc newConfig*(): Config =
+  ## Creates a new configuration table.
+  ## Useful when wanting to create a configuration file.
+  result = newOrderedTable[string, OrderedTableRef[string, string]]()
+
+proc loadConfig*(stream: Stream, filename: string = "[stream]"): Config =
+  ## Loads the specified configuration from stream into a new Config instance.
+  ## `filename` parameter is only used for nicer error messages.
+  var dict = newOrderedTable[string, OrderedTableRef[string, string]]()
+  var curSection = "" ## Current section,
+                      ## the default value of the current section is "",
+                      ## which means that the current section is a common
+  var p: CfgParser
+  open(p, stream, filename)
+  while true:
+    var e = next(p)
+    case e.kind
+    of cfgEof:
+      break
+    of cfgSectionStart: # Only look for the first time the Section
+      curSection = e.section
+    of cfgKeyValuePair:
+      var t = newOrderedTable[string, string]()
+      if dict.hasKey(curSection):
+        t = dict[curSection]
+      t[e.key] = e.value
+      dict[curSection] = t
+    of cfgOption:
+      var c = newOrderedTable[string, string]()
+      if dict.hasKey(curSection):
+        c = dict[curSection]
+      c["--" & e.key] = e.value
+      dict[curSection] = c
+    of cfgError:
+      break
+  close(p)
+  result = dict
+
+proc loadConfig*(filename: string): Config =
+  ## Loads the specified configuration file into a new Config instance.
+  let file = open(filename, fmRead)
+  let fileStream = newFileStream(file)
+  defer: fileStream.close()
+  result = fileStream.loadConfig(filename)
+
+proc replace(s: string): string =
+  var d = ""
+  var i = 0
+  while i < s.len():
+    if s[i] == '\\':
+      d.add(r"\\")
+    elif s[i] == '\c' and s[i+1] == '\l':
+      d.add(r"\c\l")
+      inc(i)
+    elif s[i] == '\c':
+      d.add(r"\n")
+    elif s[i] == '\l':
+      d.add(r"\n")
+    else:
+      d.add(s[i])
+    inc(i)
+  result = d
+
+proc writeConfig*(dict: Config, stream: Stream) =
+  ## Writes the contents of the table to the specified stream.
+  ##
+  ## .. note:: Comment statement will be ignored.
+  for section, sectionData in dict.pairs():
+    if section != "": ## Not general section
+      if not allCharsInSet(section, SymChars): ## Non system character
+        stream.writeLine("[\"" & section & "\"]")
+      else:
+        stream.writeLine("[" & section & "]")
+    for key, value in sectionData.pairs():
+      var kv, segmentChar: string
+      if key.len > 1 and key[0] == '-' and key[1] == '-': ## If it is a command key
+        segmentChar = ":"
+        if not allCharsInSet(key[2..key.len()-1], SymChars):
+          kv.add("--\"")
+          kv.add(key[2..key.len()-1])
+          kv.add("\"")
+        else:
+          kv = key
+      else:
+        segmentChar = "="
+        kv = key
+      if value != "": ## If the key is not empty
+        if not allCharsInSet(value, SymChars):
+          if find(value, '"') == -1:
+            kv.add(segmentChar)
+            kv.add("\"")
+            kv.add(replace(value))
+            kv.add("\"")
+          else:
+            kv.add(segmentChar)
+            kv.add("\"\"\"")
+            kv.add(replace(value))
+            kv.add("\"\"\"")
+        else:
+          kv.add(segmentChar)
+          kv.add(value)
+      stream.writeLine(kv)
+
+proc `$`*(dict: Config): string =
+  ## Writes the contents of the table to string.
+  ## 
+  ## .. note:: Comment statement will be ignored.
+  let stream = newStringStream()
+  defer: stream.close()
+  dict.writeConfig(stream)
+  result = stream.data
+
+proc writeConfig*(dict: Config, filename: string) =
+  ## Writes the contents of the table to the specified configuration file.
+  ## 
+  ## .. note:: Comment statement will be ignored.
+  let file = open(filename, fmWrite)
+  defer: file.close()
+  let fileStream = newFileStream(file)
+  dict.writeConfig(fileStream)
+
+proc getSectionValue*(dict: Config, section, key: string, defaultVal = ""): string =
+  ## Gets the key value of the specified Section.
+  ## Returns the specified default value if the specified key does not exist.
+  if dict.hasKey(section):
+    if dict[section].hasKey(key):
+      result = dict[section][key]
+    else:
+      result = defaultVal
+  else:
+    result = defaultVal
+
+proc setSectionKey*(dict: var Config, section, key, value: string) =
+  ## Sets the Key value of the specified Section.
+  var t = newOrderedTable[string, string]()
+  if dict.hasKey(section):
+    t = dict[section]
+  t[key] = value
+  dict[section] = t
+
+proc delSection*(dict: var Config, section: string) =
+  ## Deletes the specified section and all of its sub keys.
+  dict.del(section)
+
+proc delSectionKey*(dict: var Config, section, key: string) =
+  ## Deletes the key of the specified section.
+  if dict.hasKey(section):
+    if dict[section].hasKey(key):
+      if dict[section].len == 1:
+        dict.del(section)
+      else:
+        dict[section].del(key)
+
+iterator sections*(dict: Config): lent string {.since: (1, 5).} =
+  ## Iterates through the sections in the `dict`.
+  for section in dict.keys:
+    yield section
diff --git a/lib/pure/parsecsv.nim b/lib/pure/parsecsv.nim
index 5970f2090..c7bf0c9c1 100755..100644
--- a/lib/pure/parsecsv.nim
+++ b/lib/pure/parsecsv.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2009 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -8,171 +8,354 @@
 #
 
 ## This module implements a simple high performance `CSV`:idx:
-## (`comma separated value`:idx:) parser. 
+## (`comma separated value`:idx:) parser.
 ##
-## Example: How to use the parser
-## ==============================
+## Basic usage
+## ===========
 ##
-## .. code-block:: nimrod
-##   import os, parsecsv, streams
-##   var s = newFileStream(ParamStr(1), fmRead)
-##   if s == nil: quit("cannot open the file" & ParamStr(1))
-##   var x: TCsvParser
-##   open(x, s, ParamStr(1))
+##   ```nim
+##   import std/parsecsv
+##   from std/os import paramStr
+##   from std/streams import newFileStream
+##
+##   var s = newFileStream(paramStr(1), fmRead)
+##   if s == nil:
+##     quit("cannot open the file" & paramStr(1))
+##
+##   var x: CsvParser
+##   open(x, s, paramStr(1))
 ##   while readRow(x):
-##     Echo "new row: "
+##     echo "new row: "
 ##     for val in items(x.row):
-##       Echo "##", val, "##"
+##       echo "##", val, "##"
 ##   close(x)
+##   ```
+##
+## For CSV files with a header row, the header can be read and then used as a
+## reference for item access with `rowEntry <#rowEntry,CsvParser,string>`_:
+##
+##   ```nim
+##   import std/parsecsv
+##
+##   # Prepare a file
+##   let content = """One,Two,Three,Four
+##   1,2,3,4
+##   10,20,30,40
+##   100,200,300,400
+##   """
+##   writeFile("temp.csv", content)
 ##
+##   var p: CsvParser
+##   p.open("temp.csv")
+##   p.readHeaderRow()
+##   while p.readRow():
+##     echo "new row: "
+##     for col in items(p.headers):
+##       echo "##", col, ":", p.rowEntry(col), "##"
+##   p.close()
+##   ```
+##
+## See also
+## ========
+##
+## * `streams module <streams.html>`_ for using
+##   `open proc <#open,CsvParser,Stream,string,char,char,char>`_
+##   and other stream processing (like `close proc <streams.html#close,Stream>`_)
+## * `parseopt module <parseopt.html>`_ for a command line parser
+## * `parsecfg module <parsecfg.html>`_ for a configuration file parser
+## * `parsexml module <parsexml.html>`_ for a XML / HTML parser
+## * `parsesql module <parsesql.html>`_ for a SQL parser
+## * `other parsers <lib.html#pure-libraries-parsers>`_ for other parsers
 
-import
-  lexbase, streams
+import std/[lexbase, streams]
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
 
 type
-  TCsvRow* = seq[string] ## a row in a CSV file
-  TCsvParser* = object of TBaseLexer ## the parser object.
-    row*: TCsvRow                    ## the current row
+  CsvRow* = seq[string] ## A row in a CSV file.
+  CsvParser* = object of BaseLexer ## The parser object.
+                                   ##
+                                   ## It consists of two public fields:
+                                   ## * `row` is the current row
+                                   ## * `headers` are the columns that are defined in the csv file
+                                   ##   (read using `readHeaderRow <#readHeaderRow,CsvParser>`_).
+                                   ##   Used with `rowEntry <#rowEntry,CsvParser,string>`_).
+    row*: CsvRow
     filename: string
     sep, quote, esc: char
     skipWhite: bool
     currRow: int
+    headers*: seq[string]
 
-  EInvalidCsv* = object of EIO ## exception that is raised if
-                               ## a parsing error occurs
+  CsvError* = object of IOError ## An exception that is raised if
+                                ## a parsing error occurs.
 
-proc raiseEInvalidCsv(filename: string, line, col: int, 
+proc raiseEInvalidCsv(filename: string, line, col: int,
                       msg: string) {.noreturn.} =
-  var e: ref EInvalidCsv
+  var e: ref CsvError
   new(e)
-  e.msg = filename & "(" & $line & ", " & $col & ") Error: " & msg
+  if filename.len == 0:
+    e.msg = "Error: " & msg
+  else:
+    e.msg = filename & "(" & $line & ", " & $col & ") Error: " & msg
   raise e
 
-proc error(my: TCsvParser, pos: int, msg: string) = 
-  raiseEInvalidCsv(my.filename, my.LineNumber, getColNumber(my, pos), msg)
+proc error(self: CsvParser, pos: int, msg: string) =
+  raiseEInvalidCsv(self.filename, self.lineNumber, getColNumber(self, pos), msg)
 
-proc open*(my: var TCsvParser, input: PStream, filename: string,
+proc open*(self: var CsvParser, input: Stream, filename: string,
            separator = ',', quote = '"', escape = '\0',
            skipInitialSpace = false) =
-  ## initializes the parser with an input stream. `Filename` is only used
+  ## Initializes the parser with an input stream. `Filename` is only used
   ## for nice error messages. The parser's behaviour can be controlled by
   ## the diverse optional parameters:
   ## - `separator`: character used to separate fields
-  ## - `quote`: Used to quote fields containing special characters like 
-  ##   `separator`, `quote` or new-line characters. '\0' disables the parsing
+  ## - `quote`: Used to quote fields containing special characters like
+  ##   `separator`, `quote` or new-line characters. '\\0' disables the parsing
   ##   of quotes.
-  ## - `escape`: removes any special meaning from the following character; 
-  ##   '\0' disables escaping; if escaping is disabled and `quote` is not '\0',
+  ## - `escape`: removes any special meaning from the following character;
+  ##   '\\0' disables escaping; if escaping is disabled and `quote` is not '\\0',
   ##   two `quote` characters are parsed one literal `quote` character.
-  ## - `skipInitialSpace`: If true, whitespace immediately following the 
+  ## - `skipInitialSpace`: If true, whitespace immediately following the
   ##   `separator` is ignored.
-  lexbase.open(my, input)
-  my.filename = filename
-  my.sep = separator
-  my.quote = quote
-  my.esc = escape
-  my.skipWhite = skipInitialSpace
-  my.row = @[]
-  my.currRow = 0
-
-proc parseField(my: var TCsvParser, a: var string) = 
-  var pos = my.bufpos
-  var buf = my.buf
-  if my.skipWhite:
-    while buf[pos] in {' ', '\t'}: inc(pos)
+  ##
+  ## See also:
+  ## * `open proc <#open,CsvParser,string,char,char,char>`_ which creates the
+  ##   file stream for you
+  runnableExamples:
+    import std/streams
+    var strm = newStringStream("One,Two,Three\n1,2,3\n10,20,30")
+    var parser: CsvParser
+    parser.open(strm, "tmp.csv")
+    parser.close()
+    strm.close()
+
+  lexbase.open(self, input)
+  self.filename = filename
+  self.sep = separator
+  self.quote = quote
+  self.esc = escape
+  self.skipWhite = skipInitialSpace
+
+proc open*(self: var CsvParser, filename: string,
+           separator = ',', quote = '"', escape = '\0',
+           skipInitialSpace = false) =
+  ## Similar to the `other open proc<#open,CsvParser,Stream,string,char,char,char>`_,
+  ## but creates the file stream for you.
+  runnableExamples:
+    from std/os import removeFile
+    writeFile("tmp.csv", "One,Two,Three\n1,2,3\n10,20,300")
+    var parser: CsvParser
+    parser.open("tmp.csv")
+    parser.close()
+    removeFile("tmp.csv")
+
+  var s = newFileStream(filename, fmRead)
+  if s == nil: self.error(0, "cannot open: " & filename)
+  open(self, s, filename, separator,
+       quote, escape, skipInitialSpace)
+
+proc parseField(self: var CsvParser, a: var string) =
+  var pos = self.bufpos
+  if self.skipWhite:
+    while self.buf[pos] in {' ', '\t'}: inc(pos)
   setLen(a, 0) # reuse memory
-  if buf[pos] == my.quote and my.quote != '\0': 
+  if self.buf[pos] == self.quote and self.quote != '\0':
     inc(pos)
-    while true: 
-      var c = buf[pos]
+    while true:
+      let c = self.buf[pos]
       if c == '\0':
-        my.bufpos = pos # can continue after exception?
-        error(my, pos, my.quote & " expected")
+        self.bufpos = pos # can continue after exception?
+        error(self, pos, self.quote & " expected")
         break
-      elif c == my.quote: 
-        if my.esc == '\0' and buf[pos+1] == my.quote:
-          add(a, my.quote)
+      elif c == self.quote:
+        if self.esc == '\0' and self.buf[pos + 1] == self.quote:
+          add(a, self.quote)
           inc(pos, 2)
         else:
           inc(pos)
           break
-      elif c == my.esc:
-        add(a, buf[pos+1])
+      elif c == self.esc:
+        add(a, self.buf[pos + 1])
         inc(pos, 2)
       else:
         case c
-        of '\c': 
-          pos = handleCR(my, pos)
-          buf = my.buf
+        of '\c':
+          pos = handleCR(self, pos)
           add(a, "\n")
-        of '\l': 
-          pos = handleLF(my, pos)
-          buf = my.buf
+        of '\l':
+          pos = handleLF(self, pos)
           add(a, "\n")
         else:
           add(a, c)
           inc(pos)
   else:
     while true:
-      var c = buf[pos]
-      if c == my.sep: break
+      let c = self.buf[pos]
+      if c == self.sep: break
       if c in {'\c', '\l', '\0'}: break
       add(a, c)
       inc(pos)
-  my.bufpos = pos
+  self.bufpos = pos
+
+proc processedRows*(self: var CsvParser): int {.inline.} =
+  ## Returns number of the processed rows.
+  ##
+  ## But even if `readRow <#readRow,CsvParser,int>`_ arrived at EOF then
+  ## processed rows counter is incremented.
+  runnableExamples:
+    import std/streams
 
-proc processedRows*(my: var TCsvParser): int = 
-  ## returns number of the processed rows
-  return my.currRow
+    var strm = newStringStream("One,Two,Three\n1,2,3")
+    var parser: CsvParser
+    parser.open(strm, "tmp.csv")
+    doAssert parser.readRow()
+    doAssert parser.processedRows() == 1
+    doAssert parser.readRow()
+    doAssert parser.processedRows() == 2
+    ## Even if `readRow` arrived at EOF then `processedRows` is incremented.
+    doAssert parser.readRow() == false
+    doAssert parser.processedRows() == 3
+    doAssert parser.readRow() == false
+    doAssert parser.processedRows() == 4
+    parser.close()
+    strm.close()
 
-proc readRow*(my: var TCsvParser, columns = 0): bool = 
-  ## reads the next row; if `columns` > 0, it expects the row to have
+  self.currRow
+
+proc readRow*(self: var CsvParser, columns = 0): bool =
+  ## Reads the next row; if `columns` > 0, it expects the row to have
   ## exactly this many columns. Returns false if the end of the file
   ## has been encountered else true.
+  ##
+  ## Blank lines are skipped.
+  runnableExamples:
+    import std/streams
+    var strm = newStringStream("One,Two,Three\n1,2,3\n\n10,20,30")
+    var parser: CsvParser
+    parser.open(strm, "tmp.csv")
+    doAssert parser.readRow()
+    doAssert parser.row == @["One", "Two", "Three"]
+    doAssert parser.readRow()
+    doAssert parser.row == @["1", "2", "3"]
+    ## Blank lines are skipped.
+    doAssert parser.readRow()
+    doAssert parser.row == @["10", "20", "30"]
+
+    var emptySeq: seq[string]
+    doAssert parser.readRow() == false
+    doAssert parser.row == emptySeq
+    doAssert parser.readRow() == false
+    doAssert parser.row == emptySeq
+
+    parser.close()
+    strm.close()
+
   var col = 0 # current column
-  var oldpos = my.bufpos
-  while my.buf[my.bufpos] != '\0':
-    var oldlen = my.row.len
-    if oldlen < col+1:
-      setLen(my.row, col+1)
-      my.row[col] = ""
-    parseField(my, my.row[col])
+  let oldpos = self.bufpos
+  # skip initial empty lines #8365
+  while true:
+    case self.buf[self.bufpos]
+    of '\c': self.bufpos = handleCR(self, self.bufpos)
+    of '\l': self.bufpos = handleLF(self, self.bufpos)
+    else: break
+  while self.buf[self.bufpos] != '\0':
+    let oldlen = self.row.len
+    if oldlen < col + 1:
+      setLen(self.row, col + 1)
+      self.row[col] = ""
+    parseField(self, self.row[col])
     inc(col)
-    if my.buf[my.bufpos] == my.sep: 
-      inc(my.bufpos)
+    if self.buf[self.bufpos] == self.sep:
+      inc(self.bufpos)
     else:
-      case my.buf[my.bufpos]
-      of '\c', '\l': 
+      case self.buf[self.bufpos]
+      of '\c', '\l':
         # skip empty lines:
-        while true: 
-          case my.buf[my.bufpos]
-          of '\c': my.bufpos = handleCR(my, my.bufpos)
-          of '\l': my.bufpos = handleLF(my, my.bufpos)
+        while true:
+          case self.buf[self.bufpos]
+          of '\c': self.bufpos = handleCR(self, self.bufpos)
+          of '\l': self.bufpos = handleLF(self, self.bufpos)
           else: break
-      of '\0': nil
-      else: error(my, my.bufpos, my.sep & " expected")
+      of '\0': discard
+      else: error(self, self.bufpos, self.sep & " expected")
       break
-  
-  setlen(my.row, col)
+
+  setLen(self.row, col)
   result = col > 0
-  if result and col != columns and columns > 0: 
-    error(my, oldpos+1, $columns & " columns expected, but found " & 
+  if result and col != columns and columns > 0:
+    error(self, oldpos + 1, $columns & " columns expected, but found " &
           $col & " columns")
-  inc(my.currRow)
-  
-proc close*(my: var TCsvParser) {.inline.} = 
-  ## closes the parser `my` and its associated input stream.
-  lexbase.close(my)
-
-when isMainModule:
-  import os
-  var s = newFileStream(ParamStr(1), fmRead)
-  if s == nil: quit("cannot open the file" & ParamStr(1))
-  var x: TCsvParser
-  open(x, s, ParamStr(1))
+  inc(self.currRow)
+
+proc close*(self: var CsvParser) {.inline.} =
+  ## Closes the parser `self` and its associated input stream.
+  lexbase.close(self)
+
+proc readHeaderRow*(self: var CsvParser) =
+  ## Reads the first row and creates a look-up table for column numbers
+  ## See also:
+  ## * `rowEntry proc <#rowEntry,CsvParser,string>`_
+  runnableExamples:
+    import std/streams
+
+    var strm = newStringStream("One,Two,Three\n1,2,3")
+    var parser: CsvParser
+    parser.open(strm, "tmp.csv")
+
+    parser.readHeaderRow()
+    doAssert parser.headers == @["One", "Two", "Three"]
+    doAssert parser.row == @["One", "Two", "Three"]
+
+    doAssert parser.readRow()
+    doAssert parser.headers == @["One", "Two", "Three"]
+    doAssert parser.row == @["1", "2", "3"]
+
+    parser.close()
+    strm.close()
+
+  let present = self.readRow()
+  if present:
+    self.headers = self.row
+
+proc rowEntry*(self: var CsvParser, entry: string): var string =
+  ## Accesses a specified `entry` from the current row.
+  ##
+  ## Assumes that `readHeaderRow <#readHeaderRow,CsvParser>`_ has already been
+  ## called.
+  ##
+  ## If specified `entry` does not exist, raises KeyError.
+  runnableExamples:
+    import std/streams
+    var strm = newStringStream("One,Two,Three\n1,2,3\n\n10,20,30")
+    var parser: CsvParser
+    parser.open(strm, "tmp.csv")
+    ## Requires calling `readHeaderRow`.
+    parser.readHeaderRow()
+    doAssert parser.readRow()
+    doAssert parser.rowEntry("One") == "1"
+    doAssert parser.rowEntry("Two") == "2"
+    doAssert parser.rowEntry("Three") == "3"
+    doAssertRaises(KeyError):
+      discard parser.rowEntry("NonexistentEntry")
+    parser.close()
+    strm.close()
+
+  let index = self.headers.find(entry)
+  if index >= 0:
+    result = self.row[index]
+  else:
+    raise newException(KeyError, "Entry `" & entry & "` doesn't exist")
+
+when not defined(testing) and isMainModule:
+  import std/os
+  var s = newFileStream(paramStr(1), fmRead)
+  if s == nil: quit("cannot open the file" & paramStr(1))
+  var x: CsvParser
+  open(x, s, paramStr(1))
   while readRow(x):
-    Echo "new row: "
+    echo "new row: "
     for val in items(x.row):
-      Echo "##", val, "##"
+      echo "##", val, "##"
   close(x)
-
diff --git a/lib/pure/parsejson.nim b/lib/pure/parsejson.nim
new file mode 100644
index 000000000..9292a8596
--- /dev/null
+++ b/lib/pure/parsejson.nim
@@ -0,0 +1,522 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements a json parser. It is used
+## and exported by the `json` standard library
+## module, but can also be used in its own right.
+
+import std/[strutils, lexbase, streams, unicode]
+import std/private/decode_helpers
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type
+  JsonEventKind* = enum ## enumeration of all events that may occur when parsing
+    jsonError,          ## an error occurred during parsing
+    jsonEof,            ## end of file reached
+    jsonString,         ## a string literal
+    jsonInt,            ## an integer literal
+    jsonFloat,          ## a float literal
+    jsonTrue,           ## the value `true`
+    jsonFalse,          ## the value `false`
+    jsonNull,           ## the value `null`
+    jsonObjectStart,    ## start of an object: the `{` token
+    jsonObjectEnd,      ## end of an object: the `}` token
+    jsonArrayStart,     ## start of an array: the `[` token
+    jsonArrayEnd        ## end of an array: the `]` token
+
+  TokKind* = enum # must be synchronized with TJsonEventKind!
+    tkError,
+    tkEof,
+    tkString,
+    tkInt,
+    tkFloat,
+    tkTrue,
+    tkFalse,
+    tkNull,
+    tkCurlyLe,
+    tkCurlyRi,
+    tkBracketLe,
+    tkBracketRi,
+    tkColon,
+    tkComma
+
+  JsonError* = enum       ## enumeration that lists all errors that can occur
+    errNone,              ## no error
+    errInvalidToken,      ## invalid token
+    errStringExpected,    ## string expected
+    errColonExpected,     ## `:` expected
+    errCommaExpected,     ## `,` expected
+    errBracketRiExpected, ## `]` expected
+    errCurlyRiExpected,   ## `}` expected
+    errQuoteExpected,     ## `"` or `'` expected
+    errEOC_Expected,      ## `*/` expected
+    errEofExpected,       ## EOF expected
+    errExprExpected       ## expr expected
+
+  ParserState = enum
+    stateEof, stateStart, stateObject, stateArray, stateExpectArrayComma,
+    stateExpectObjectComma, stateExpectColon, stateExpectValue
+
+  JsonParser* = object of BaseLexer ## the parser object.
+    a*: string
+    tok*: TokKind
+    kind: JsonEventKind
+    err: JsonError
+    state: seq[ParserState]
+    filename: string
+    rawStringLiterals: bool
+
+  JsonKindError* = object of ValueError ## raised by the `to` macro if the
+                                        ## JSON kind is incorrect.
+  JsonParsingError* = object of ValueError ## is raised for a JSON error
+
+const
+  errorMessages*: array[JsonError, string] = [
+    "no error",
+    "invalid token",
+    "string expected",
+    "':' expected",
+    "',' expected",
+    "']' expected",
+    "'}' expected",
+    "'\"' or \"'\" expected",
+    "'*/' expected",
+    "EOF expected",
+    "expression expected"
+  ]
+  tokToStr: array[TokKind, string] = [
+    "invalid token",
+    "EOF",
+    "string literal",
+    "int literal",
+    "float literal",
+    "true",
+    "false",
+    "null",
+    "{", "}", "[", "]", ":", ","
+  ]
+
+proc open*(my: var JsonParser, input: Stream, filename: string;
+           rawStringLiterals = false) =
+  ## initializes the parser with an input stream. `Filename` is only used
+  ## for nice error messages. If `rawStringLiterals` is true, string literals
+  ## are kept with their surrounding quotes and escape sequences in them are
+  ## left untouched too.
+  lexbase.open(my, input)
+  my.filename = filename
+  my.state = @[stateStart]
+  my.kind = jsonError
+  my.a = ""
+  my.rawStringLiterals = rawStringLiterals
+
+proc close*(my: var JsonParser) {.inline.} =
+  ## closes the parser `my` and its associated input stream.
+  lexbase.close(my)
+
+proc str*(my: JsonParser): string {.inline.} =
+  ## returns the character data for the events: `jsonInt`, `jsonFloat`,
+  ## `jsonString`
+  assert(my.kind in {jsonInt, jsonFloat, jsonString})
+  return my.a
+
+proc getInt*(my: JsonParser): BiggestInt {.inline.} =
+  ## returns the number for the event: `jsonInt`
+  assert(my.kind == jsonInt)
+  return parseBiggestInt(my.a)
+
+proc getFloat*(my: JsonParser): float {.inline.} =
+  ## returns the number for the event: `jsonFloat`
+  assert(my.kind == jsonFloat)
+  return parseFloat(my.a)
+
+proc kind*(my: JsonParser): JsonEventKind {.inline.} =
+  ## returns the current event type for the JSON parser
+  return my.kind
+
+proc getColumn*(my: JsonParser): int {.inline.} =
+  ## get the current column the parser has arrived at.
+  result = getColNumber(my, my.bufpos)
+
+proc getLine*(my: JsonParser): int {.inline.} =
+  ## get the current line the parser has arrived at.
+  result = my.lineNumber
+
+proc getFilename*(my: JsonParser): string {.inline.} =
+  ## get the filename of the file that the parser processes.
+  result = my.filename
+
+proc errorMsg*(my: JsonParser): string =
+  ## returns a helpful error message for the event `jsonError`
+  assert(my.kind == jsonError)
+  result = "$1($2, $3) Error: $4" % [
+    my.filename, $getLine(my), $getColumn(my), errorMessages[my.err]]
+
+proc errorMsgExpected*(my: JsonParser, e: string): string =
+  ## returns an error message "`e` expected" in the same format as the
+  ## other error messages
+  result = "$1($2, $3) Error: $4" % [
+    my.filename, $getLine(my), $getColumn(my), e & " expected"]
+
+proc parseEscapedUTF16*(buf: cstring, pos: var int): int =
+  result = 0
+  #UTF-16 escape is always 4 bytes.
+  for _ in 0..3:
+    # if char in '0' .. '9', 'a' .. 'f', 'A' .. 'F'
+    if handleHexChar(buf[pos], result):
+      inc(pos)
+    else:
+      return -1
+
+proc parseString(my: var JsonParser): TokKind =
+  result = tkString
+  var pos = my.bufpos + 1
+  if my.rawStringLiterals:
+    add(my.a, '"')
+  while true:
+    case my.buf[pos]
+    of '\0':
+      my.err = errQuoteExpected
+      result = tkError
+      break
+    of '"':
+      if my.rawStringLiterals:
+        add(my.a, '"')
+      inc(pos)
+      break
+    of '\\':
+      if my.rawStringLiterals:
+        add(my.a, '\\')
+      case my.buf[pos+1]
+      of '\\', '"', '\'', '/':
+        add(my.a, my.buf[pos+1])
+        inc(pos, 2)
+      of 'b':
+        add(my.a, '\b')
+        inc(pos, 2)
+      of 'f':
+        add(my.a, '\f')
+        inc(pos, 2)
+      of 'n':
+        add(my.a, '\L')
+        inc(pos, 2)
+      of 'r':
+        add(my.a, '\C')
+        inc(pos, 2)
+      of 't':
+        add(my.a, '\t')
+        inc(pos, 2)
+      of 'v':
+        add(my.a, '\v')
+        inc(pos, 2)
+      of 'u':
+        if my.rawStringLiterals:
+          add(my.a, 'u')
+        inc(pos, 2)
+        var pos2 = pos
+        var r = parseEscapedUTF16(cstring(my.buf), pos)
+        if r < 0:
+          my.err = errInvalidToken
+          break
+        # Deal with surrogates
+        if (r and 0xfc00) == 0xd800:
+          if my.buf[pos] != '\\' or my.buf[pos+1] != 'u':
+            my.err = errInvalidToken
+            break
+          inc(pos, 2)
+          var s = parseEscapedUTF16(cstring(my.buf), pos)
+          if (s and 0xfc00) == 0xdc00 and s > 0:
+            r = 0x10000 + (((r - 0xd800) shl 10) or (s - 0xdc00))
+          else:
+            my.err = errInvalidToken
+            break
+        if my.rawStringLiterals:
+          let length = pos - pos2
+          for i in 1 .. length:
+            if my.buf[pos2] in {'0'..'9', 'A'..'F', 'a'..'f'}:
+              add(my.a, my.buf[pos2])
+              inc pos2
+            else:
+              break
+        else:
+          add(my.a, toUTF8(Rune(r)))
+      else:
+        # don't bother with the error
+        add(my.a, my.buf[pos])
+        inc(pos)
+    of '\c':
+      pos = lexbase.handleCR(my, pos)
+      add(my.a, '\c')
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
+      add(my.a, '\L')
+    else:
+      add(my.a, my.buf[pos])
+      inc(pos)
+  my.bufpos = pos # store back
+
+proc skip(my: var JsonParser) =
+  var pos = my.bufpos
+  while true:
+    case my.buf[pos]
+    of '/':
+      if my.buf[pos+1] == '/':
+        # skip line comment:
+        inc(pos, 2)
+        while true:
+          case my.buf[pos]
+          of '\0':
+            break
+          of '\c':
+            pos = lexbase.handleCR(my, pos)
+            break
+          of '\L':
+            pos = lexbase.handleLF(my, pos)
+            break
+          else:
+            inc(pos)
+      elif my.buf[pos+1] == '*':
+        # skip long comment:
+        inc(pos, 2)
+        while true:
+          case my.buf[pos]
+          of '\0':
+            my.err = errEOC_Expected
+            break
+          of '\c':
+            pos = lexbase.handleCR(my, pos)
+          of '\L':
+            pos = lexbase.handleLF(my, pos)
+          of '*':
+            inc(pos)
+            if my.buf[pos] == '/':
+              inc(pos)
+              break
+          else:
+            inc(pos)
+      else:
+        break
+    of ' ', '\t':
+      inc(pos)
+    of '\c':
+      pos = lexbase.handleCR(my, pos)
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
+    else:
+      break
+  my.bufpos = pos
+
+proc parseNumber(my: var JsonParser) =
+  var pos = my.bufpos
+  if my.buf[pos] == '-':
+    add(my.a, '-')
+    inc(pos)
+  if my.buf[pos] == '.':
+    add(my.a, "0.")
+    inc(pos)
+  else:
+    while my.buf[pos] in Digits:
+      add(my.a, my.buf[pos])
+      inc(pos)
+    if my.buf[pos] == '.':
+      add(my.a, '.')
+      inc(pos)
+  # digits after the dot:
+  while my.buf[pos] in Digits:
+    add(my.a, my.buf[pos])
+    inc(pos)
+  if my.buf[pos] in {'E', 'e'}:
+    add(my.a, my.buf[pos])
+    inc(pos)
+    if my.buf[pos] in {'+', '-'}:
+      add(my.a, my.buf[pos])
+      inc(pos)
+    while my.buf[pos] in Digits:
+      add(my.a, my.buf[pos])
+      inc(pos)
+  my.bufpos = pos
+
+proc parseName(my: var JsonParser) =
+  var pos = my.bufpos
+  if my.buf[pos] in IdentStartChars:
+    while my.buf[pos] in IdentChars:
+      add(my.a, my.buf[pos])
+      inc(pos)
+  my.bufpos = pos
+
+proc getTok*(my: var JsonParser): TokKind =
+  setLen(my.a, 0)
+  skip(my) # skip whitespace, comments
+  case my.buf[my.bufpos]
+  of '-', '.', '0'..'9':
+    parseNumber(my)
+    if {'.', 'e', 'E'} in my.a:
+      result = tkFloat
+    else:
+      result = tkInt
+  of '"':
+    result = parseString(my)
+  of '[':
+    inc(my.bufpos)
+    result = tkBracketLe
+  of '{':
+    inc(my.bufpos)
+    result = tkCurlyLe
+  of ']':
+    inc(my.bufpos)
+    result = tkBracketRi
+  of '}':
+    inc(my.bufpos)
+    result = tkCurlyRi
+  of ',':
+    inc(my.bufpos)
+    result = tkComma
+  of ':':
+    inc(my.bufpos)
+    result = tkColon
+  of '\0':
+    result = tkEof
+  of 'a'..'z', 'A'..'Z', '_':
+    parseName(my)
+    case my.a
+    of "null": result = tkNull
+    of "true": result = tkTrue
+    of "false": result = tkFalse
+    else: result = tkError
+  else:
+    inc(my.bufpos)
+    result = tkError
+  my.tok = result
+
+
+proc next*(my: var JsonParser) =
+  ## retrieves the first/next event. This controls the parser.
+  var tk = getTok(my)
+  var i = my.state.len-1
+  # the following code is a state machine. If we had proper coroutines,
+  # the code could be much simpler.
+  case my.state[i]
+  of stateEof:
+    if tk == tkEof:
+      my.kind = jsonEof
+    else:
+      my.kind = jsonError
+      my.err = errEofExpected
+  of stateStart:
+    # tokens allowed?
+    case tk
+    of tkString, tkInt, tkFloat, tkTrue, tkFalse, tkNull:
+      my.state[i] = stateEof # expect EOF next!
+      my.kind = JsonEventKind(ord(tk))
+    of tkBracketLe:
+      my.state.add(stateArray) # we expect any
+      my.kind = jsonArrayStart
+    of tkCurlyLe:
+      my.state.add(stateObject)
+      my.kind = jsonObjectStart
+    of tkEof:
+      my.kind = jsonEof
+    else:
+      my.kind = jsonError
+      my.err = errEofExpected
+  of stateObject:
+    case tk
+    of tkString, tkInt, tkFloat, tkTrue, tkFalse, tkNull:
+      my.state.add(stateExpectColon)
+      my.kind = JsonEventKind(ord(tk))
+    of tkBracketLe:
+      my.state.add(stateExpectColon)
+      my.state.add(stateArray)
+      my.kind = jsonArrayStart
+    of tkCurlyLe:
+      my.state.add(stateExpectColon)
+      my.state.add(stateObject)
+      my.kind = jsonObjectStart
+    of tkCurlyRi:
+      my.kind = jsonObjectEnd
+      discard my.state.pop()
+    else:
+      my.kind = jsonError
+      my.err = errCurlyRiExpected
+  of stateArray:
+    case tk
+    of tkString, tkInt, tkFloat, tkTrue, tkFalse, tkNull:
+      my.state.add(stateExpectArrayComma) # expect value next!
+      my.kind = JsonEventKind(ord(tk))
+    of tkBracketLe:
+      my.state.add(stateExpectArrayComma)
+      my.state.add(stateArray)
+      my.kind = jsonArrayStart
+    of tkCurlyLe:
+      my.state.add(stateExpectArrayComma)
+      my.state.add(stateObject)
+      my.kind = jsonObjectStart
+    of tkBracketRi:
+      my.kind = jsonArrayEnd
+      discard my.state.pop()
+    else:
+      my.kind = jsonError
+      my.err = errBracketRiExpected
+  of stateExpectArrayComma:
+    case tk
+    of tkComma:
+      discard my.state.pop()
+      next(my)
+    of tkBracketRi:
+      my.kind = jsonArrayEnd
+      discard my.state.pop() # pop stateExpectArrayComma
+      discard my.state.pop() # pop stateArray
+    else:
+      my.kind = jsonError
+      my.err = errBracketRiExpected
+  of stateExpectObjectComma:
+    case tk
+    of tkComma:
+      discard my.state.pop()
+      next(my)
+    of tkCurlyRi:
+      my.kind = jsonObjectEnd
+      discard my.state.pop() # pop stateExpectObjectComma
+      discard my.state.pop() # pop stateObject
+    else:
+      my.kind = jsonError
+      my.err = errCurlyRiExpected
+  of stateExpectColon:
+    case tk
+    of tkColon:
+      my.state[i] = stateExpectValue
+      next(my)
+    else:
+      my.kind = jsonError
+      my.err = errColonExpected
+  of stateExpectValue:
+    case tk
+    of tkString, tkInt, tkFloat, tkTrue, tkFalse, tkNull:
+      my.state[i] = stateExpectObjectComma
+      my.kind = JsonEventKind(ord(tk))
+    of tkBracketLe:
+      my.state[i] = stateExpectObjectComma
+      my.state.add(stateArray)
+      my.kind = jsonArrayStart
+    of tkCurlyLe:
+      my.state[i] = stateExpectObjectComma
+      my.state.add(stateObject)
+      my.kind = jsonObjectStart
+    else:
+      my.kind = jsonError
+      my.err = errExprExpected
+
+proc raiseParseErr*(p: JsonParser, msg: string) {.noinline, noreturn.} =
+  ## raises an `EJsonParsingError` exception.
+  raise newException(JsonParsingError, errorMsgExpected(p, msg))
+
+proc eat*(p: var JsonParser, tok: TokKind) =
+  if p.tok == tok: discard getTok(p)
+  else: raiseParseErr(p, tokToStr[tok])
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim
index 8f4be98f4..03f151b66 100755..100644
--- a/lib/pure/parseopt.nim
+++ b/lib/pure/parseopt.nim
@@ -1,139 +1,510 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module provides the standard Nimrod command line parser.
+## This module provides the standard Nim command line parser.
 ## It supports one convenience iterator over all command line options and some
 ## lower-level features.
+##
+## Supported Syntax
+## ================
+##
+## The following syntax is supported when arguments for the `shortNoVal` and
+## `longNoVal` parameters, which are
+## `described later<#nimshortnoval-and-nimlongnoval>`_, are not provided:
+##
+## 1. Short options: `-abcd`, `-e:5`, `-e=5`
+## 2. Long options: `--foo:bar`, `--foo=bar`, `--foo`
+## 3. Arguments: everything that does not start with a `-`
+##
+## These three kinds of tokens are enumerated in the
+## `CmdLineKind enum<#CmdLineKind>`_.
+##
+## When option values begin with ':' or '=', they need to be doubled up (as in
+## `--delim::`) or alternated (as in `--delim=:`).
+##
+## The `--` option, commonly used to denote that every token that follows is
+## an argument, is interpreted as a long option, and its name is the empty
+## string.
+##
+## Parsing
+## =======
+##
+## Use an `OptParser<#OptParser>`_ to parse command line options. It can be
+## created with `initOptParser<#initOptParser,string,set[char],seq[string]>`_,
+## and `next<#next,OptParser>`_ advances the parser by one token.
+##
+## For each token, the parser's `kind`, `key`, and `val` fields give
+## information about that token. If the token is a long or short option, `key`
+## is the option's name, and  `val` is either the option's value, if provided,
+## or the empty string. For arguments, the `key` field contains the argument
+## itself, and `val` is unused. To check if the end of the command line has
+## been reached, check if `kind` is equal to `cmdEnd`.
+##
+## Here is an example:
+##
+##   ```Nim
+##   import std/parseopt
+##
+##   var p = initOptParser("-ab -e:5 --foo --bar=20 file.txt")
+##   while true:
+##     p.next()
+##     case p.kind
+##     of cmdEnd: break
+##     of cmdShortOption, cmdLongOption:
+##       if p.val == "":
+##         echo "Option: ", p.key
+##       else:
+##         echo "Option and value: ", p.key, ", ", p.val
+##     of cmdArgument:
+##       echo "Argument: ", p.key
+##
+##   # Output:
+##   # Option: a
+##   # Option: b
+##   # Option and value: e, 5
+##   # Option: foo
+##   # Option and value: bar, 20
+##   # Argument: file.txt
+##   ```
+##
+## The `getopt iterator<#getopt.i,OptParser>`_, which is provided for
+## convenience, can be used to iterate through all command line options as well.
+##
+## To set a default value for a variable assigned through `getopt` and accept arguments from the cmd line.
+## Assign the default value to a variable before parsing.
+## Then set the variable to the new value while parsing.
+##
+## Here is an example:
+##
+##   ```Nim
+##   import std/parseopt
+##
+##   var varName: string = "defaultValue"
+##
+##   for kind, key, val in getopt():
+##     case kind
+##     of cmdArgument:
+##       discard
+##     of cmdLongOption, cmdShortOption:
+##       case key:
+##       of "varName": # --varName:<value> in the console when executing
+##         varName = val # do input sanitization in production systems
+##     of cmdEnd:
+##       discard
+##   ```
+##
+## `shortNoVal` and `longNoVal`
+## ============================
+##
+## The optional `shortNoVal` and `longNoVal` parameters present in
+## `initOptParser<#initOptParser,string,set[char],seq[string]>`_ are for
+## specifying which short and long options do not accept values.
+##
+## When `shortNoVal` is non-empty, users are not required to separate short
+## options and their values with a ':' or '=' since the parser knows which
+## options accept values and which ones do not. This behavior also applies for
+## long options if `longNoVal` is non-empty. For short options, `-j4`
+## becomes supported syntax, and for long options, `--foo bar` becomes
+## supported. This is in addition to the `previously mentioned
+## syntax<#supported-syntax>`_. Users can still separate options and their
+## values with ':' or '=', but that becomes optional.
+##
+## As more options which do not accept values are added to your program,
+## remember to amend `shortNoVal` and `longNoVal` accordingly.
+##
+## The following example illustrates the difference between having an empty
+## `shortNoVal` and `longNoVal`, which is the default, and providing
+## arguments for those two parameters:
+##
+##   ```Nim
+##   import std/parseopt
+##
+##   proc printToken(kind: CmdLineKind, key: string, val: string) =
+##     case kind
+##     of cmdEnd: doAssert(false)  # Doesn't happen with getopt()
+##     of cmdShortOption, cmdLongOption:
+##       if val == "":
+##         echo "Option: ", key
+##       else:
+##         echo "Option and value: ", key, ", ", val
+##     of cmdArgument:
+##       echo "Argument: ", key
+##
+##   let cmdLine = "-j4 --first bar"
+##
+##   var emptyNoVal = initOptParser(cmdLine)
+##   for kind, key, val in emptyNoVal.getopt():
+##     printToken(kind, key, val)
+##
+##   # Output:
+##   # Option: j
+##   # Option: 4
+##   # Option: first
+##   # Argument: bar
+##
+##   var withNoVal = initOptParser(cmdLine, shortNoVal = {'c'},
+##                                 longNoVal = @["second"])
+##   for kind, key, val in withNoVal.getopt():
+##     printToken(kind, key, val)
+##
+##   # Output:
+##   # Option and value: j, 4
+##   # Option and value: first, bar
+##   ```
+##
+## See also
+## ========
+##
+## * `os module<os.html>`_ for lower-level command line parsing procs
+## * `parseutils module<parseutils.html>`_ for helpers that parse tokens,
+##   numbers, identifiers, etc.
+## * `strutils module<strutils.html>`_ for common string handling operations
+## * `json module<json.html>`_ for a JSON parser
+## * `parsecfg module<parsecfg.html>`_ for a configuration file parser
+## * `parsecsv module<parsecsv.html>`_ for a simple CSV (comma separated value)
+##   parser
+## * `parsexml module<parsexml.html>`_ for a XML / HTML parser
+## * `other parsers<lib.html#pure-libraries-parsers>`_ for more parsers
 
 {.push debugger: off.}
 
-import 
-  os, strutils
-
-type 
-  TCmdLineKind* = enum        ## the detected command line token
-    cmdEnd,                   ## end of command line reached
-    cmdArgument,              ## argument detected
-    cmdLongoption,            ## a long option ``--option`` detected
-    cmdShortOption            ## a short option ``-c`` detected
-  TOptParser* = 
-      object of TObject ## this object implements the command line parser  
-    cmd: string
+include "system/inclrtl"
+
+import std/strutils
+import std/os
+
+type
+  CmdLineKind* = enum ## The detected command line token.
+    cmdEnd,           ## End of command line reached
+    cmdArgument,      ## An argument such as a filename
+    cmdLongOption,    ## A long option such as --option
+    cmdShortOption    ## A short option such as -c
+  OptParser* = object of RootObj ## \
+    ## Implementation of the command line parser.
+    ##
+    ## To initialize it, use the
+    ## `initOptParser proc<#initOptParser,string,set[char],seq[string]>`_.
     pos: int
     inShortState: bool
-    kind*: TCmdLineKind       ## the dected command line token
-    key*, val*: string        ## key and value pair; ``key`` is the option
-                              ## or the argument, ``value`` is not "" if
-                              ## the option was given a value
-
-proc initOptParser*(cmdline = ""): TOptParser =
-  ## inits the option parser. If ``cmdline == ""``, the real command line
-  ## (as provided by the ``OS`` module) is taken.
-  result.pos = 0
-  result.inShortState = false
-  if cmdline != "": 
-    result.cmd = cmdline
-  else: 
-    result.cmd = ""
-    for i in countup(1, ParamCount()): 
-      result.cmd = result.cmd & quoteIfContainsWhite(paramStr(i)) & ' '
-  result.kind = cmdEnd
-  result.key = ""
-  result.val = ""
-
-proc init*(cmdline: string = ""): TOptParser {.deprecated.} = 
-  ## **Deprecated since version 0.8.2**: Use `initOptParser` instead.
-  result = initOptParser(cmdline)
+    allowWhitespaceAfterColon: bool
+    shortNoVal: set[char]
+    longNoVal: seq[string]
+    cmds: seq[string]
+    idx: int
+    kind*: CmdLineKind           ## The detected command line token
+    key*, val*: string           ## Key and value pair; the key is the option
+                                 ## or the argument, and the value is not "" if
+                                 ## the option was given a value
 
-proc parseWord(s: string, i: int, w: var string, 
-               delim: TCharSet = {'\x09', ' ', '\0'}): int = 
+proc parseWord(s: string, i: int, w: var string,
+               delim: set[char] = {'\t', ' '}): int =
   result = i
-  if s[result] == '\"': 
+  if result < s.len and s[result] == '\"':
     inc(result)
-    while not (s[result] in {'\0', '\"'}): 
+    while result < s.len:
+      if s[result] == '"':
+        inc result
+        break
       add(w, s[result])
       inc(result)
-    if s[result] == '\"': inc(result)
-  else: 
-    while not (s[result] in delim): 
+  else:
+    while result < s.len and s[result] notin delim:
       add(w, s[result])
       inc(result)
 
-proc handleShortOption(p: var TOptParser) = 
+proc initOptParser*(cmdline: seq[string], shortNoVal: set[char] = {},
+                    longNoVal: seq[string] = @[];
+                    allowWhitespaceAfterColon = true): OptParser =
+  ## Initializes the command line parser.
+  ##
+  ## If `cmdline.len == 0`, the real command line as provided by the
+  ## `os` module is retrieved instead if it is available. If the
+  ## command line is not available, a `ValueError` will be raised.
+  ## Behavior of the other parameters remains the same as in
+  ## `initOptParser(string, ...)
+  ## <#initOptParser,string,set[char],seq[string]>`_.
+  ##
+  ## See also:
+  ## * `getopt iterator<#getopt.i,seq[string],set[char],seq[string]>`_
+  runnableExamples:
+    var p = initOptParser()
+    p = initOptParser(@["--left", "--debug:3", "-l", "-r:2"])
+    p = initOptParser(@["--left", "--debug:3", "-l", "-r:2"],
+                      shortNoVal = {'l'}, longNoVal = @["left"])
+
+  result.pos = 0
+  result.idx = 0
+  result.inShortState = false
+  result.shortNoVal = shortNoVal
+  result.longNoVal = longNoVal
+  result.allowWhitespaceAfterColon = allowWhitespaceAfterColon
+  if cmdline.len != 0:
+    result.cmds = newSeq[string](cmdline.len)
+    for i in 0..<cmdline.len:
+      result.cmds[i] = cmdline[i]
+  else:
+    when declared(paramCount):
+      when defined(nimscript):
+        var ctr = 0
+        var firstNimsFound = false
+        for i in countup(0, paramCount()):
+          if firstNimsFound: 
+            result.cmds[ctr] = paramStr(i)
+            inc ctr, 1
+          if paramStr(i).endsWith(".nims") and not firstNimsFound:
+            firstNimsFound = true 
+            result.cmds = newSeq[string](paramCount()-i)
+      else:
+        result.cmds = newSeq[string](paramCount())
+        for i in countup(1, paramCount()):
+          result.cmds[i-1] = paramStr(i)
+    else:
+      # we cannot provide this for NimRtl creation on Posix, because we can't
+      # access the command line arguments then!
+      raiseAssert "empty command line given but" &
+        " real command line is not accessible"
+  result.kind = cmdEnd
+  result.key = ""
+  result.val = ""
+
+proc initOptParser*(cmdline = "", shortNoVal: set[char] = {},
+                    longNoVal: seq[string] = @[];
+                    allowWhitespaceAfterColon = true): OptParser =
+  ## Initializes the command line parser.
+  ##
+  ## If `cmdline == ""`, the real command line as provided by the
+  ## `os` module is retrieved instead if it is available. If the
+  ## command line is not available, a `ValueError` will be raised.
+  ##
+  ## `shortNoVal` and `longNoVal` are used to specify which options
+  ## do not take values. See the `documentation about these
+  ## parameters<#nimshortnoval-and-nimlongnoval>`_ for more information on
+  ## how this affects parsing.
+  ##
+  ## This does not provide a way of passing default values to arguments.
+  ##
+  ## See also:
+  ## * `getopt iterator<#getopt.i,OptParser>`_
+  runnableExamples:
+    var p = initOptParser()
+    p = initOptParser("--left --debug:3 -l -r:2")
+    p = initOptParser("--left --debug:3 -l -r:2",
+                      shortNoVal = {'l'}, longNoVal = @["left"])
+
+  initOptParser(parseCmdLine(cmdline), shortNoVal, longNoVal, allowWhitespaceAfterColon)
+
+proc handleShortOption(p: var OptParser; cmd: string) =
   var i = p.pos
   p.kind = cmdShortOption
-  add(p.key, p.cmd[i])
-  inc(i)
+  if i < cmd.len:
+    add(p.key, cmd[i])
+    inc(i)
   p.inShortState = true
-  while p.cmd[i] in {'\x09', ' '}: 
+  while i < cmd.len and cmd[i] in {'\t', ' '}:
     inc(i)
     p.inShortState = false
-  if p.cmd[i] in {':', '='}: 
-    inc(i)
+  if i < cmd.len and (cmd[i] in {':', '='} or
+      card(p.shortNoVal) > 0 and p.key[0] notin p.shortNoVal):
+    if i < cmd.len and cmd[i] in {':', '='}:
+      inc(i)
     p.inShortState = false
-    while p.cmd[i] in {'\x09', ' '}: inc(i)
-    i = parseWord(p.cmd, i, p.val)
-  if p.cmd[i] == '\0': p.inShortState = false
-  p.pos = i
+    while i < cmd.len and cmd[i] in {'\t', ' '}: inc(i)
+    p.val = substr(cmd, i)
+    p.pos = 0
+    inc p.idx
+  else:
+    p.pos = i
+  if i >= cmd.len:
+    p.inShortState = false
+    p.pos = 0
+    inc p.idx
+
+proc next*(p: var OptParser) {.rtl, extern: "npo$1".} =
+  ## Parses the next token.
+  ##
+  ## `p.kind` describes what kind of token has been parsed. `p.key` and
+  ## `p.val` are set accordingly.
+  runnableExamples:
+    var p = initOptParser("--left -r:2 file.txt")
+    p.next()
+    doAssert p.kind == cmdLongOption and p.key == "left"
+    p.next()
+    doAssert p.kind == cmdShortOption and p.key == "r" and p.val == "2"
+    p.next()
+    doAssert p.kind == cmdArgument and p.key == "file.txt"
+    p.next()
+    doAssert p.kind == cmdEnd
+
+  if p.idx >= p.cmds.len:
+    p.kind = cmdEnd
+    return
 
-proc next*(p: var TOptParser) = 
-  ## parses the first or next option; ``p.kind`` describes what token has been
-  ## parsed. ``p.key`` and ``p.val`` are set accordingly.
   var i = p.pos
-  while p.cmd[i] in {'\x09', ' '}: inc(i)
+  while i < p.cmds[p.idx].len and p.cmds[p.idx][i] in {'\t', ' '}: inc(i)
   p.pos = i
-  setlen(p.key, 0)
-  setlen(p.val, 0)
-  if p.inShortState: 
-    handleShortOption(p)
-    return 
-  case p.cmd[i]
-  of '\0': 
-    p.kind = cmdEnd
-  of '-': 
+  setLen(p.key, 0)
+  setLen(p.val, 0)
+  if p.inShortState:
+    p.inShortState = false
+    if i >= p.cmds[p.idx].len:
+      inc(p.idx)
+      p.pos = 0
+      if p.idx >= p.cmds.len:
+        p.kind = cmdEnd
+        return
+    else:
+      handleShortOption(p, p.cmds[p.idx])
+      return
+
+  if i < p.cmds[p.idx].len and p.cmds[p.idx][i] == '-':
     inc(i)
-    if p.cmd[i] == '-': 
+    if i < p.cmds[p.idx].len and p.cmds[p.idx][i] == '-':
       p.kind = cmdLongOption
       inc(i)
-      i = parseWord(p.cmd, i, p.key, {'\0', ' ', '\x09', ':', '='})
-      while p.cmd[i] in {'\x09', ' '}: inc(i)
-      if p.cmd[i] in {':', '='}: 
+      i = parseWord(p.cmds[p.idx], i, p.key, {' ', '\t', ':', '='})
+      while i < p.cmds[p.idx].len and p.cmds[p.idx][i] in {'\t', ' '}: inc(i)
+      if i < p.cmds[p.idx].len and p.cmds[p.idx][i] in {':', '='}:
         inc(i)
-        while p.cmd[i] in {'\x09', ' '}: inc(i)
-        p.pos = parseWord(p.cmd, i, p.val)
-      else: 
-        p.pos = i
-    else: 
+        while i < p.cmds[p.idx].len and p.cmds[p.idx][i] in {'\t', ' '}: inc(i)
+        # if we're at the end, use the next command line option:
+        if i >= p.cmds[p.idx].len and p.idx < p.cmds.len and
+            p.allowWhitespaceAfterColon:
+          inc p.idx
+          i = 0
+        if p.idx < p.cmds.len:
+          p.val = p.cmds[p.idx].substr(i)
+      elif len(p.longNoVal) > 0 and p.key notin p.longNoVal and p.idx+1 < p.cmds.len:
+        p.val = p.cmds[p.idx+1]
+        inc p.idx
+      else:
+        p.val = ""
+      inc p.idx
+      p.pos = 0
+    else:
       p.pos = i
-      handleShortOption(p)
-  else: 
+      handleShortOption(p, p.cmds[p.idx])
+  else:
     p.kind = cmdArgument
-    p.pos = parseWord(p.cmd, i, p.key)
+    p.key = p.cmds[p.idx]
+    inc p.idx
+    p.pos = 0
+
+when declared(quoteShellCommand):
+  proc cmdLineRest*(p: OptParser): string {.rtl, extern: "npo$1".} =
+    ## Retrieves the rest of the command line that has not been parsed yet.
+    ##
+    ## See also:
+    ## * `remainingArgs proc<#remainingArgs,OptParser>`_
+    ##
+    ## **Examples:**
+    ##   ```Nim
+    ##   var p = initOptParser("--left -r:2 -- foo.txt bar.txt")
+    ##   while true:
+    ##     p.next()
+    ##     if p.kind == cmdLongOption and p.key == "":  # Look for "--"
+    ##       break
+    ##   doAssert p.cmdLineRest == "foo.txt bar.txt"
+    ##   ```
+    result = p.cmds[p.idx .. ^1].quoteShellCommand
 
-proc cmdLineRest*(p: TOptParser): string = 
-  ## retrieves the rest of the command line that has not been parsed yet.
-  result = strip(copy(p.cmd, p.pos, len(p.cmd) - 1)) 
+proc remainingArgs*(p: OptParser): seq[string] {.rtl, extern: "npo$1".} =
+  ## Retrieves a sequence of the arguments that have not been parsed yet.
+  ##
+  ## See also:
+  ## * `cmdLineRest proc<#cmdLineRest,OptParser>`_
+  ##
+  ## **Examples:**
+  ##   ```Nim
+  ##   var p = initOptParser("--left -r:2 -- foo.txt bar.txt")
+  ##   while true:
+  ##     p.next()
+  ##     if p.kind == cmdLongOption and p.key == "":  # Look for "--"
+  ##       break
+  ##   doAssert p.remainingArgs == @["foo.txt", "bar.txt"]
+  ##   ```
+  result = @[]
+  for i in p.idx..<p.cmds.len: result.add p.cmds[i]
 
-proc getRestOfCommandLine*(p: TOptParser): string {.deprecated.} = 
-  ## **Deprecated since version 0.8.2**: Use `cmdLineRest` instead.
-  result = cmdLineRest(p) 
+iterator getopt*(p: var OptParser): tuple[kind: CmdLineKind, key,
+    val: string] =
+  ## Convenience iterator for iterating over the given
+  ## `OptParser<#OptParser>`_.
+  ##
+  ## There is no need to check for `cmdEnd` while iterating. If using `getopt`
+  ## with case switching, checking for `cmdEnd` is required.
+  ##
+  ## See also:
+  ## * `initOptParser proc<#initOptParser,string,set[char],seq[string]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   # these are placeholders, of course
+  ##   proc writeHelp() = discard
+  ##   proc writeVersion() = discard
+  ##
+  ##   var filename: string
+  ##   var p = initOptParser("--left --debug:3 -l -r:2")
+  ##
+  ##   for kind, key, val in p.getopt():
+  ##     case kind
+  ##     of cmdArgument:
+  ##       filename = key
+  ##     of cmdLongOption, cmdShortOption:
+  ##       case key
+  ##       of "help", "h": writeHelp()
+  ##       of "version", "v": writeVersion()
+  ##     of cmdEnd: assert(false) # cannot happen
+  ##   if filename == "":
+  ##     # no filename has been given, so we show the help
+  ##     writeHelp()
+  ##   ```
+  p.pos = 0
+  p.idx = 0
+  while true:
+    next(p)
+    if p.kind == cmdEnd: break
+    yield (p.kind, p.key, p.val)
 
-iterator getopt*(): tuple[kind: TCmdLineKind, key, val: string] =
-  ## This is an convenience iterator for iterating over the command line.
-  ## This uses the TOptParser object. Example:
+iterator getopt*(cmdline: seq[string] = @[],
+                  shortNoVal: set[char] = {}, longNoVal: seq[string] = @[]):
+            tuple[kind: CmdLineKind, key, val: string] =
+  ## Convenience iterator for iterating over command line arguments.
+  ##
+  ## This creates a new `OptParser<#OptParser>`_. If no command line
+  ## arguments are provided, the real command line as provided by the
+  ## `os` module is retrieved instead.
+  ##
+  ## `shortNoVal` and `longNoVal` are used to specify which options
+  ## do not take values. See the `documentation about these
+  ## parameters<#nimshortnoval-and-nimlongnoval>`_ for more information on
+  ## how this affects parsing.
+  ##
+  ## There is no need to check for `cmdEnd` while iterating. If using `getopt`
+  ## with case switching, checking for `cmdEnd` is required.
+  ##
+  ## See also:
+  ## * `initOptParser proc<#initOptParser,seq[string],set[char],seq[string]>`_
+  ##
+  ## **Examples:**
+  ##
+  ##   ```Nim
+  ##   # these are placeholders, of course
+  ##   proc writeHelp() = discard
+  ##   proc writeVersion() = discard
+  ##
+  ##   var filename: string
+  ##   let params = @["--left", "--debug:3", "-l", "-r:2"]
   ##
-  ## .. code-block:: nimrod
-  ##   var
-  ##     filename = ""
-  ##   for kind, key, val in getopt():
+  ##   for kind, key, val in getopt(params):
   ##     case kind
-  ##     of cmdArgument: 
+  ##     of cmdArgument:
   ##       filename = key
   ##     of cmdLongOption, cmdShortOption:
   ##       case key
@@ -141,9 +512,11 @@ iterator getopt*(): tuple[kind: TCmdLineKind, key, val: string] =
   ##       of "version", "v": writeVersion()
   ##     of cmdEnd: assert(false) # cannot happen
   ##   if filename == "":
-  ##     # no filename has been given, so we show the help:
+  ##     # no filename has been written, so we show the help
   ##     writeHelp()
-  var p = initOptParser()
+  ##   ```
+  var p = initOptParser(cmdline, shortNoVal = shortNoVal,
+      longNoVal = longNoVal)
   while true:
     next(p)
     if p.kind == cmdEnd: break
diff --git a/lib/pure/parsesql.nim b/lib/pure/parsesql.nim
index 2109c273a..a7c938d01 100755..100644
--- a/lib/pure/parsesql.nim
+++ b/lib/pure/parsesql.nim
@@ -1,27 +1,32 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2009 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## The ``parsesql`` module implements a high performance SQL file 
+## The `parsesql` module implements a high performance SQL file
 ## parser. It parses PostgreSQL syntax and the SQL ANSI standard.
+##
+## Unstable API.
 
-import 
-  hashes, strutils, lexbase, streams
+import std/[strutils, lexbase]
+import std/private/decode_helpers
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
 # ------------------- scanner -------------------------------------------------
 
 type
-  TTokKind = enum       ## enumeration of all SQL tokens
-    tkInvalid,          ## invalid token
-    tkEof,              ## end of file reached
-    tkIdentifier,       ## abc
-    tkQuotedIdentifier, ## "abc"
-    tkStringConstant,   ## 'abc'
+  TokKind = enum            ## enumeration of all SQL tokens
+    tkInvalid,              ## invalid token
+    tkEof,                  ## end of file reached
+    tkIdentifier,           ## abc
+    tkQuotedIdentifier,     ## "abc"
+    tkStringConstant,       ## 'abc'
     tkEscapeConstant,       ## e'abc'
     tkDollarQuotedConstant, ## $tag$abc$tag$
     tkBitStringConstant,    ## B'00011'
@@ -37,211 +42,195 @@ type
     tkBracketLe,            ## '['
     tkBracketRi,            ## ']'
     tkDot                   ## '.'
-  
-  TToken {.final.} = object  # a token
-    kind: TTokKind           # the type of the token
-    literal: string          # the parsed (string) literal
-  
-  TSqlLexer* = object of TBaseLexer ## the parser object.
+
+  Token = object    # a token
+    kind: TokKind   # the type of the token
+    literal: string # the parsed (string) literal
+
+  SqlLexer* = object of BaseLexer ## the parser object.
     filename: string
 
 const
-  tokKindToStr: array[TTokKind, string] = [
+  tokKindToStr: array[TokKind, string] = [
     "invalid", "[EOF]", "identifier", "quoted identifier", "string constant",
     "escape string constant", "dollar quoted constant", "bit string constant",
     "hex string constant", "integer constant", "numeric constant", "operator",
     ";", ":", ",", "(", ")", "[", "]", "."
   ]
 
-proc open(L: var TSqlLexer, input: PStream, filename: string) = 
-  lexbase.open(L, input)
-  L.filename = filename
-  
-proc close(L: var TSqlLexer) = 
+  reservedKeywords = @[
+    # statements
+    "select", "from", "where", "group", "limit", "offset", "having",
+    # functions
+    "count",
+  ]
+
+proc close(L: var SqlLexer) =
   lexbase.close(L)
 
-proc getColumn(L: TSqlLexer): int = 
+proc getColumn(L: SqlLexer): int =
   ## get the current column the parser has arrived at.
-  result = getColNumber(L, L.bufPos)
+  result = getColNumber(L, L.bufpos)
 
-proc getLine(L: TSqlLexer): int = 
-  result = L.linenumber
+proc getLine(L: SqlLexer): int =
+  result = L.lineNumber
 
-proc handleHexChar(c: var TSqlLexer, xi: var int) = 
-  case c.buf[c.bufpos]
-  of '0'..'9': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0'))
-    inc(c.bufpos)
-  of 'a'..'f': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('a') + 10)
-    inc(c.bufpos)
-  of 'A'..'F': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10)
-    inc(c.bufpos)
-  else: 
-    nil
-
-proc handleOctChar(c: var TSqlLexer, xi: var int) = 
+proc handleOctChar(c: var SqlLexer, xi: var int) =
   if c.buf[c.bufpos] in {'0'..'7'}:
     xi = (xi shl 3) or (ord(c.buf[c.bufpos]) - ord('0'))
     inc(c.bufpos)
 
-proc getEscapedChar(c: var TSqlLexer, tok: var TToken) = 
+proc getEscapedChar(c: var SqlLexer, tok: var Token) =
   inc(c.bufpos)
   case c.buf[c.bufpos]
-  of 'n', 'N': 
+  of 'n', 'N':
     add(tok.literal, '\L')
-    Inc(c.bufpos)
-  of 'r', 'R', 'c', 'C': 
+    inc(c.bufpos)
+  of 'r', 'R', 'c', 'C':
     add(tok.literal, '\c')
-    Inc(c.bufpos)
-  of 'l', 'L': 
+    inc(c.bufpos)
+  of 'l', 'L':
     add(tok.literal, '\L')
-    Inc(c.bufpos)
-  of 'f', 'F': 
+    inc(c.bufpos)
+  of 'f', 'F':
     add(tok.literal, '\f')
     inc(c.bufpos)
-  of 'e', 'E': 
+  of 'e', 'E':
     add(tok.literal, '\e')
-    Inc(c.bufpos)
-  of 'a', 'A': 
+    inc(c.bufpos)
+  of 'a', 'A':
     add(tok.literal, '\a')
-    Inc(c.bufpos)
-  of 'b', 'B': 
+    inc(c.bufpos)
+  of 'b', 'B':
     add(tok.literal, '\b')
-    Inc(c.bufpos)
-  of 'v', 'V': 
+    inc(c.bufpos)
+  of 'v', 'V':
     add(tok.literal, '\v')
-    Inc(c.bufpos)
-  of 't', 'T': 
+    inc(c.bufpos)
+  of 't', 'T':
     add(tok.literal, '\t')
-    Inc(c.bufpos)
-  of '\'', '\"': 
+    inc(c.bufpos)
+  of '\'', '\"':
     add(tok.literal, c.buf[c.bufpos])
-    Inc(c.bufpos)
-  of '\\': 
+    inc(c.bufpos)
+  of '\\':
     add(tok.literal, '\\')
-    Inc(c.bufpos)
-  of 'x', 'X': 
+    inc(c.bufpos)
+  of 'x', 'X':
     inc(c.bufpos)
     var xi = 0
-    handleHexChar(c, xi)
-    handleHexChar(c, xi)
-    add(tok.literal, Chr(xi))
-  of '0'..'7': 
+    if handleHexChar(c.buf[c.bufpos], xi):
+      inc(c.bufpos)
+      if handleHexChar(c.buf[c.bufpos], xi):
+        inc(c.bufpos)
+    add(tok.literal, chr(xi))
+  of '0'..'7':
     var xi = 0
     handleOctChar(c, xi)
     handleOctChar(c, xi)
     handleOctChar(c, xi)
-    if (xi <= 255): add(tok.literal, Chr(xi))
+    if (xi <= 255): add(tok.literal, chr(xi))
     else: tok.kind = tkInvalid
   else: tok.kind = tkInvalid
-  
-proc HandleCRLF(c: var TSqlLexer, pos: int): int = 
+
+proc handleCRLF(c: var SqlLexer, pos: int): int =
   case c.buf[pos]
-  of '\c': result = lexbase.HandleCR(c, pos)
-  of '\L': result = lexbase.HandleLF(c, pos)
+  of '\c': result = lexbase.handleCR(c, pos)
+  of '\L': result = lexbase.handleLF(c, pos)
   else: result = pos
 
-proc skip(c: var TSqlLexer) = 
+proc skip(c: var SqlLexer) =
   var pos = c.bufpos
-  var buf = c.buf
   var nested = 0
-  while true: 
-    case buf[pos]
-    of ' ', '\t': 
-      Inc(pos)
+  while true:
+    case c.buf[pos]
+    of ' ', '\t':
+      inc(pos)
     of '-':
-      if buf[pos+1] == '-':
-        while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
+      if c.buf[pos+1] == '-':
+        while not (c.buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
       else:
         break
     of '/':
-      if buf[pos+1] == '*':
-        inc(pos,2)
+      if c.buf[pos+1] == '*':
+        inc(pos, 2)
         while true:
-          case buf[pos]
+          case c.buf[pos]
           of '\0': break
-          of '\c', '\L': 
-            pos = HandleCRLF(c, pos)
-            buf = c.buf
+          of '\c', '\L':
+            pos = handleCRLF(c, pos)
           of '*':
-            if buf[pos+1] == '/':
+            if c.buf[pos+1] == '/':
               inc(pos, 2)
               if nested <= 0: break
               dec(nested)
             else:
               inc(pos)
           of '/':
-            if buf[pos+1] == '*':
+            if c.buf[pos+1] == '*':
               inc(pos, 2)
               inc(nested)
             else:
               inc(pos)
           else: inc(pos)
       else: break
-    of '\c', '\L': 
-      pos = HandleCRLF(c, pos)
-      buf = c.buf
-    else: 
-      break                   # EndOfFile also leaves the loop
+    of '\c', '\L':
+      pos = handleCRLF(c, pos)
+    else:
+      break # EndOfFile also leaves the loop
   c.bufpos = pos
-  
-proc getString(c: var TSqlLexer, tok: var TToken, kind: TTokKind) = 
-  var pos = c.bufPos + 1
-  var buf = c.buf
+
+proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) =
+  var pos = c.bufpos + 1
   tok.kind = kind
   block parseLoop:
     while true:
-      while true: 
-        var ch = buf[pos]
+      while true:
+        var ch = c.buf[pos]
         if ch == '\'':
-          if buf[pos+1] == '\'':
+          if c.buf[pos+1] == '\'':
             inc(pos, 2)
             add(tok.literal, '\'')
           else:
             inc(pos)
-            break 
-        elif ch in {'\c', '\L', lexbase.EndOfFile}: 
+            break
+        elif ch in {'\c', '\L', lexbase.EndOfFile}:
           tok.kind = tkInvalid
           break parseLoop
-        elif (ch == '\\') and kind == tkEscapeConstant: 
-          c.bufPos = pos
+        elif (ch == '\\') and kind == tkEscapeConstant:
+          c.bufpos = pos
           getEscapedChar(c, tok)
-          pos = c.bufPos
-        else: 
+          pos = c.bufpos
+        else:
           add(tok.literal, ch)
-          Inc(pos)
+          inc(pos)
       c.bufpos = pos
-      var line = c.linenumber
+      var line = c.lineNumber
       skip(c)
-      if c.linenumber > line:
+      if c.lineNumber > line:
         # a new line whitespace has been parsed, so we check if the string
         # continues after the whitespace:
-        buf = c.buf # may have been reallocated
         pos = c.bufpos
-        if buf[pos] == '\'': inc(pos)
+        if c.buf[pos] == '\'': inc(pos)
         else: break parseLoop
       else: break parseLoop
   c.bufpos = pos
 
-proc getDollarString(c: var TSqlLexer, tok: var TToken) = 
-  var pos = c.bufPos + 1
-  var buf = c.buf
+proc getDollarString(c: var SqlLexer, tok: var Token) =
+  var pos = c.bufpos + 1
   tok.kind = tkDollarQuotedConstant
   var tag = "$"
-  while buf[pos] in IdentChars:
-    add(tag, buf[pos])
+  while c.buf[pos] in IdentChars:
+    add(tag, c.buf[pos])
     inc(pos)
-  if buf[pos] == '$': inc(pos)
+  if c.buf[pos] == '$': inc(pos)
   else:
     tok.kind = tkInvalid
     return
   while true:
-    case buf[pos]
-    of '\c', '\L': 
-      pos = HandleCRLF(c, pos)
-      buf = c.buf
+    case c.buf[pos]
+    of '\c', '\L':
+      pos = handleCRLF(c, pos)
       add(tok.literal, "\L")
     of '\0':
       tok.kind = tkInvalid
@@ -249,190 +238,185 @@ proc getDollarString(c: var TSqlLexer, tok: var TToken) =
     of '$':
       inc(pos)
       var tag2 = "$"
-      while buf[pos] in IdentChars:
-        add(tag2, buf[pos])
+      while c.buf[pos] in IdentChars:
+        add(tag2, c.buf[pos])
         inc(pos)
-      if buf[pos] == '$': inc(pos)
+      if c.buf[pos] == '$': inc(pos)
       if tag2 == tag: break
       add(tok.literal, tag2)
       add(tok.literal, '$')
     else:
-      add(tok.literal, buf[pos])
+      add(tok.literal, c.buf[pos])
       inc(pos)
   c.bufpos = pos
 
-proc getSymbol(c: var TSqlLexer, tok: var TToken) = 
+proc getSymbol(c: var SqlLexer, tok: var Token) =
   var pos = c.bufpos
-  var buf = c.buf
-  while true: 
-    add(tok.literal, buf[pos])
-    Inc(pos)
-    if not (buf[pos] in {'a'..'z','A'..'Z','0'..'9','_','$', '\128'..'\255'}):
+  while true:
+    add(tok.literal, c.buf[pos])
+    inc(pos)
+    if c.buf[pos] notin {'a'..'z', 'A'..'Z', '0'..'9', '_', '$',
+        '\128'..'\255'}:
       break
   c.bufpos = pos
   tok.kind = tkIdentifier
 
-proc getQuotedIdentifier(c: var TSqlLexer, tok: var TToken) = 
-  var pos = c.bufPos + 1
-  var buf = c.buf
+proc getQuotedIdentifier(c: var SqlLexer, tok: var Token, quote = '\"') =
+  var pos = c.bufpos + 1
   tok.kind = tkQuotedIdentifier
   while true:
-    var ch = buf[pos]
-    if ch == '\"':
-      if buf[pos+1] == '\"':
+    var ch = c.buf[pos]
+    if ch == quote:
+      if c.buf[pos+1] == quote:
         inc(pos, 2)
-        add(tok.literal, '\"')
+        add(tok.literal, quote)
       else:
         inc(pos)
         break
-    elif ch in {'\c', '\L', lexbase.EndOfFile}: 
+    elif ch in {'\c', '\L', lexbase.EndOfFile}:
       tok.kind = tkInvalid
       break
     else:
       add(tok.literal, ch)
-      Inc(pos)
+      inc(pos)
   c.bufpos = pos
 
-proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
-  var pos = c.bufPos + 1
-  var buf = c.buf
+proc getBitHexString(c: var SqlLexer, tok: var Token, validChars: set[char]) =
+  var pos = c.bufpos + 1
   block parseLoop:
     while true:
-      while true: 
-        var ch = buf[pos]
+      while true:
+        var ch = c.buf[pos]
         if ch in validChars:
           add(tok.literal, ch)
-          Inc(pos)          
+          inc(pos)
         elif ch == '\'':
           inc(pos)
           break
-        else: 
+        else:
           tok.kind = tkInvalid
           break parseLoop
       c.bufpos = pos
-      var line = c.linenumber
+      var line = c.lineNumber
       skip(c)
-      if c.linenumber > line:
+      if c.lineNumber > line:
         # a new line whitespace has been parsed, so we check if the string
         # continues after the whitespace:
-        buf = c.buf # may have been reallocated
         pos = c.bufpos
-        if buf[pos] == '\'': inc(pos)
+        if c.buf[pos] == '\'': inc(pos)
         else: break parseLoop
       else: break parseLoop
   c.bufpos = pos
 
-proc getNumeric(c: var TSqlLexer, tok: var TToken) =
+proc getNumeric(c: var SqlLexer, tok: var Token) =
   tok.kind = tkInteger
-  var pos = c.bufPos
-  var buf = c.buf
-  while buf[pos] in Digits:
-    add(tok.literal, buf[pos])
+  var pos = c.bufpos
+  while c.buf[pos] in Digits:
+    add(tok.literal, c.buf[pos])
     inc(pos)
-  if buf[pos] == '.':
+  if c.buf[pos] == '.':
     tok.kind = tkNumeric
-    add(tok.literal, buf[pos])
+    add(tok.literal, c.buf[pos])
     inc(pos)
-    while buf[pos] in Digits:
-      add(tok.literal, buf[pos])
+    while c.buf[pos] in Digits:
+      add(tok.literal, c.buf[pos])
       inc(pos)
-  if buf[pos] in {'E', 'e'}:
+  if c.buf[pos] in {'E', 'e'}:
     tok.kind = tkNumeric
-    add(tok.literal, buf[pos])
+    add(tok.literal, c.buf[pos])
     inc(pos)
-    if buf[pos] == '+':
+    if c.buf[pos] == '+':
       inc(pos)
-    elif buf[pos] == '-':
-      add(tok.literal, buf[pos])
+    elif c.buf[pos] == '-':
+      add(tok.literal, c.buf[pos])
       inc(pos)
-    if buf[pos] in Digits:
-      while buf[pos] in Digits:
-        add(tok.literal, buf[pos])
+    if c.buf[pos] in Digits:
+      while c.buf[pos] in Digits:
+        add(tok.literal, c.buf[pos])
         inc(pos)
     else:
       tok.kind = tkInvalid
-  c.bufpos = pos  
+  c.bufpos = pos
 
-proc getOperator(c: var TSqlLexer, tok: var TToken) =
+proc getOperator(c: var SqlLexer, tok: var Token) =
   const operators = {'+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%',
                      '^', '&', '|', '`', '?'}
   tok.kind = tkOperator
-  var pos = c.bufPos
-  var buf = c.buf
+  var pos = c.bufpos
   var trailingPlusMinus = false
   while true:
-    case buf[pos]
+    case c.buf[pos]
     of '-':
-      if buf[pos] == '-': break
-      if not trailingPlusMinus and buf[pos+1] notin operators and
+      if c.buf[pos] == '-': break
+      if not trailingPlusMinus and c.buf[pos+1] notin operators and
            tok.literal.len > 0: break
     of '/':
-      if buf[pos] == '*': break
+      if c.buf[pos] == '*': break
     of '~', '!', '@', '#', '%', '^', '&', '|', '`', '?':
       trailingPlusMinus = true
     of '+':
-      if not trailingPlusMinus and buf[pos+1] notin operators and
+      if not trailingPlusMinus and c.buf[pos+1] notin operators and
            tok.literal.len > 0: break
-    of '*', '<', '>', '=': nil
+    of '*', '<', '>', '=': discard
     else: break
-    add(tok.literal, buf[pos])
+    add(tok.literal, c.buf[pos])
     inc(pos)
   c.bufpos = pos
 
-proc getTok(c: var TSqlLexer, tok: var TToken) = 
+proc getTok(c: var SqlLexer, tok: var Token) =
   tok.kind = tkInvalid
-  setlen(tok.literal, 0)
+  setLen(tok.literal, 0)
   skip(c)
   case c.buf[c.bufpos]
-  of ';': 
-    tok.kind = tkSemiColon
-    inc(c.bufPos)
+  of ';':
+    tok.kind = tkSemicolon
+    inc(c.bufpos)
     add(tok.literal, ';')
   of ',':
     tok.kind = tkComma
     inc(c.bufpos)
     add(tok.literal, ',')
-  of ':': 
+  of ':':
     tok.kind = tkColon
     inc(c.bufpos)
     add(tok.literal, ':')
-  of 'e', 'E': 
-    if c.buf[c.bufPos + 1] == '\'': 
-      Inc(c.bufPos)
+  of 'e', 'E':
+    if c.buf[c.bufpos + 1] == '\'':
+      inc(c.bufpos)
       getString(c, tok, tkEscapeConstant)
-    else: 
+    else:
       getSymbol(c, tok)
   of 'b', 'B':
-    if c.buf[c.bufPos + 1] == '\'':
+    if c.buf[c.bufpos + 1] == '\'':
       tok.kind = tkBitStringConstant
       getBitHexString(c, tok, {'0'..'1'})
     else:
       getSymbol(c, tok)
   of 'x', 'X':
-    if c.buf[c.bufPos + 1] == '\'':
+    if c.buf[c.bufpos + 1] == '\'':
       tok.kind = tkHexStringConstant
-      getBitHexString(c, tok, {'a'..'f','A'..'F','0'..'9'})
+      getBitHexString(c, tok, {'a'..'f', 'A'..'F', '0'..'9'})
     else:
       getSymbol(c, tok)
   of '$': getDollarString(c, tok)
-  of '[': 
+  of '[':
     tok.kind = tkBracketLe
     inc(c.bufpos)
     add(tok.literal, '[')
-  of ']': 
+  of ']':
     tok.kind = tkBracketRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, ']')
   of '(':
     tok.kind = tkParLe
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, '(')
   of ')':
     tok.kind = tkParRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, ')')
-  of '.': 
-    if c.buf[c.bufPos + 1] in Digits:
+  of '.':
+    if c.buf[c.bufpos + 1] in Digits:
       getNumeric(c, tok)
     else:
       tok.kind = tkDot
@@ -440,52 +424,54 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
     add(tok.literal, '.')
   of '0'..'9': getNumeric(c, tok)
   of '\'': getString(c, tok, tkStringConstant)
-  of '"': getQuotedIdentifier(c, tok)
-  of lexbase.EndOfFile: 
+  of '"': getQuotedIdentifier(c, tok, '"')
+  of '`': getQuotedIdentifier(c, tok, '`')
+  of lexbase.EndOfFile:
     tok.kind = tkEof
     tok.literal = "[EOF]"
   of 'a', 'c', 'd', 'f'..'w', 'y', 'z', 'A', 'C', 'D', 'F'..'W', 'Y', 'Z', '_',
      '\128'..'\255':
     getSymbol(c, tok)
   of '+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%',
-     '^', '&', '|', '`', '?':
+     '^', '&', '|', '?':
     getOperator(c, tok)
   else:
     add(tok.literal, c.buf[c.bufpos])
     inc(c.bufpos)
-  
-proc errorStr(L: TSqlLexer, msg: string): string = 
+
+proc errorStr(L: SqlLexer, msg: string): string =
   result = "$1($2, $3) Error: $4" % [L.filename, $getLine(L), $getColumn(L), msg]
 
 
 # ----------------------------- parser ----------------------------------------
 
-# Operator/Element	Associativity	Description
-# .	                left    	table/column name separator
-# ::            	left	        PostgreSQL-style typecast
-# [ ]	                left    	array element selection
-# -	                right	        unary minus
-# ^             	left	        exponentiation
-# * / %	                left	        multiplication, division, modulo
-# + -	                left	        addition, subtraction
-# IS	 	IS TRUE, IS FALSE, IS UNKNOWN, IS NULL
-# ISNULL	 	test for null
-# NOTNULL	 	test for not null
-# (any other)	        left    	all other native and user-defined oprs
-# IN	          	set membership
-# BETWEEN	 	range containment
-# OVERLAPS	 	time interval overlap
-# LIKE ILIKE SIMILAR	 	string pattern matching
-# < >	 	less than, greater than
-# =	                right	        equality, assignment
-# NOT	                right	        logical negation
-# AND	                left	        logical conjunction
-# OR              	left	        logical disjunction
+# Operator/Element   Associativity  Description
+# .                  left           table/column name separator
+# ::                 left           PostgreSQL-style typecast
+# [ ]                left           array element selection
+# -                  right          unary minus
+# ^                  left           exponentiation
+# * / %              left           multiplication, division, modulo
+# + -                left           addition, subtraction
+# IS                                IS TRUE, IS FALSE, IS UNKNOWN, IS NULL
+# ISNULL                            test for null
+# NOTNULL                           test for not null
+# (any other)        left           all other native and user-defined oprs
+# IN                                set membership
+# BETWEEN                           range containment
+# OVERLAPS                          time interval overlap
+# LIKE ILIKE SIMILAR                string pattern matching
+# < >                               less than, greater than
+# =                  right          equality, assignment
+# NOT                right          logical negation
+# AND                left           logical conjunction
+# OR                 left           logical disjunction
 
 type
-  TSqlNodeKind* = enum ## kind of SQL abstract syntax tree
+  SqlNodeKind* = enum ## kind of SQL abstract syntax tree
     nkNone,
     nkIdent,
+    nkQuotedIdent,
     nkStringLit,
     nkBitStringLit,
     nkHexStringLit,
@@ -494,13 +480,15 @@ type
     nkPrimaryKey,
     nkForeignKey,
     nkNotNull,
-    
+    nkNull,
+
     nkStmtList,
     nkDot,
     nkDotDot,
     nkPrefix,
     nkInfix,
     nkCall,
+    nkPrGroup,
     nkColumnReference,
     nkReferences,
     nkDefault,
@@ -508,18 +496,23 @@ type
     nkConstraint,
     nkUnique,
     nkIdentity,
-    nkColumnDef,        ## name, datatype, constraints
+    nkColumnDef,      ## name, datatype, constraints
     nkInsert,
     nkUpdate,
     nkDelete,
     nkSelect,
     nkSelectDistinct,
     nkSelectColumns,
+    nkSelectPair,
     nkAsgn,
     nkFrom,
+    nkFromItemPair,
     nkGroup,
+    nkLimit,
+    nkOffset,
     nkHaving,
     nkOrder,
+    nkJoin,
     nkDesc,
     nkUnion,
     nkIntersect,
@@ -528,87 +521,108 @@ type
     nkValueList,
     nkWhere,
     nkCreateTable,
-    nkCreateTableIfNotExists, 
+    nkCreateTableIfNotExists,
     nkCreateType,
     nkCreateTypeIfNotExists,
     nkCreateIndex,
     nkCreateIndexIfNotExists,
     nkEnumDef
-    
+
+const
+  LiteralNodes = {
+    nkIdent, nkQuotedIdent, nkStringLit, nkBitStringLit, nkHexStringLit,
+    nkIntegerLit, nkNumericLit
+  }
+
 type
-  EInvalidSql* = object of EBase  ## Invalid SQL encountered
-  PSqlNode* = ref TSqlNode        ## an SQL abstract syntax tree node
-  TSqlNode* = object              ## an SQL abstract syntax tree node
-    case kind*: TSqlNodeKind      ## kind of syntax tree
-    of nkIdent, nkStringLit, nkBitStringLit, nkHexStringLit,
-                nkIntegerLit, nkNumericLit:
-      strVal*: string             ## AST leaf: the identifier, numeric literal
-                                  ## string literal, etc.
+  SqlParseError* = object of ValueError ## Invalid SQL encountered
+  SqlNode* = ref SqlNodeObj ## an SQL abstract syntax tree node
+  SqlNodeObj* = object      ## an SQL abstract syntax tree node
+    case kind*: SqlNodeKind ## kind of syntax tree
+    of LiteralNodes:
+      strVal*: string       ## AST leaf: the identifier, numeric literal
+                            ## string literal, etc.
     else:
-      sons*: seq[PSqlNode]        ## the node's children
+      sons*: seq[SqlNode]   ## the node's children
 
-  TSqlParser* = object of TSqlLexer ## SQL parser object
-    tok: TToken
+  SqlParser* = object of SqlLexer ## SQL parser object
+    tok: Token
 
-proc newNode(k: TSqlNodeKind): PSqlNode =
-  new(result)
-  result.kind = k
+proc newNode*(k: SqlNodeKind): SqlNode =
+  when defined(js): # bug #14117
+    case k
+    of LiteralNodes:
+      result = SqlNode(kind: k, strVal: "")
+    else:
+      result = SqlNode(kind: k, sons: @[])
+  else:
+    result = SqlNode(kind: k)
 
-proc newNode(k: TSqlNodeKind, s: string): PSqlNode =
-  new(result)
-  result.kind = k
+proc newNode*(k: SqlNodeKind, s: string): SqlNode =
+  result = SqlNode(kind: k)
   result.strVal = s
-  
-proc len*(n: PSqlNode): int =
-  if isNil(n.sons): result = 0
-  else: result = n.sons.len
-  
-proc add*(father, n: PSqlNode) =
-  if isNil(father.sons): father.sons = @[]
+
+proc newNode*(k: SqlNodeKind, sons: seq[SqlNode]): SqlNode =
+  result = SqlNode(kind: k)
+  result.sons = sons
+
+proc len*(n: SqlNode): int =
+  if n.kind in LiteralNodes:
+    result = 0
+  else:
+    result = n.sons.len
+
+proc `[]`*(n: SqlNode; i: int): SqlNode = n.sons[i]
+proc `[]`*(n: SqlNode; i: BackwardsIndex): SqlNode = n.sons[n.len - int(i)]
+
+proc add*(father, n: SqlNode) =
   add(father.sons, n)
 
-proc getTok(p: var TSqlParser) =
+proc getTok(p: var SqlParser) =
   getTok(p, p.tok)
 
-proc sqlError(p: TSqlParser, msg: string) =
-  var e: ref EInvalidSql
+proc sqlError(p: SqlParser, msg: string) =
+  var e: ref SqlParseError
   new(e)
   e.msg = errorStr(p, msg)
   raise e
 
-proc isKeyw(p: TSqlParser, keyw: string): bool =
+proc isKeyw(p: SqlParser, keyw: string): bool =
   result = p.tok.kind == tkIdentifier and
            cmpIgnoreCase(p.tok.literal, keyw) == 0
 
-proc isOpr(p: TSqlParser, opr: string): bool =
+proc isOpr(p: SqlParser, opr: string): bool =
   result = p.tok.kind == tkOperator and
            cmpIgnoreCase(p.tok.literal, opr) == 0
 
-proc optKeyw(p: var TSqlParser, keyw: string) =
+proc optKeyw(p: var SqlParser, keyw: string) =
   if p.tok.kind == tkIdentifier and cmpIgnoreCase(p.tok.literal, keyw) == 0:
     getTok(p)
 
-proc expectIdent(p: TSqlParser) =
+proc expectIdent(p: SqlParser) =
   if p.tok.kind != tkIdentifier and p.tok.kind != tkQuotedIdentifier:
     sqlError(p, "identifier expected")
 
-proc expect(p: TSqlParser, kind: TTokKind) =
+proc expect(p: SqlParser, kind: TokKind) =
   if p.tok.kind != kind:
     sqlError(p, tokKindToStr[kind] & " expected")
 
-proc eat(p: var TSqlParser, kind: TTokKind) =
+proc eat(p: var SqlParser, kind: TokKind) =
   if p.tok.kind == kind:
     getTok(p)
   else:
     sqlError(p, tokKindToStr[kind] & " expected")
 
-proc eat(p: var TSqlParser, keyw: string) =
+proc eat(p: var SqlParser, keyw: string) =
   if isKeyw(p, keyw):
     getTok(p)
   else:
-    sqlError(p, keyw.toUpper() & " expected")
+    sqlError(p, keyw.toUpperAscii() & " expected")
 
-proc parseDataType(p: var TSqlParser): PSqlNode =
+proc opt(p: var SqlParser, kind: TokKind) =
+  if p.tok.kind == kind: getTok(p)
+
+proc parseDataType(p: var SqlParser): SqlNode =
   if isKeyw(p, "enum"):
     result = newNode(nkEnumDef)
     getTok(p)
@@ -636,18 +650,20 @@ proc parseDataType(p: var TSqlParser): PSqlNode =
         getTok(p)
       eat(p, tkParRi)
 
-proc getPrecedence(p: TSqlParser): int = 
+proc getPrecedence(p: SqlParser): int =
   if isOpr(p, "*") or isOpr(p, "/") or isOpr(p, "%"):
     result = 6
   elif isOpr(p, "+") or isOpr(p, "-"):
-    result = 5  
+    result = 5
   elif isOpr(p, "=") or isOpr(p, "<") or isOpr(p, ">") or isOpr(p, ">=") or
        isOpr(p, "<=") or isOpr(p, "<>") or isOpr(p, "!=") or isKeyw(p, "is") or
-       isKeyw(p, "like"):
-    result = 3
+       isKeyw(p, "like") or isKeyw(p, "in"):
+    result = 4
   elif isKeyw(p, "and"):
-    result = 2
+    result = 3
   elif isKeyw(p, "or"):
+    result = 2
+  elif isKeyw(p, "between"):
     result = 1
   elif p.tok.kind == tkOperator:
     # user-defined operator:
@@ -655,11 +671,15 @@ proc getPrecedence(p: TSqlParser): int =
   else:
     result = - 1
 
-proc parseExpr(p: var TSqlParser): PSqlNode
+proc parseExpr(p: var SqlParser): SqlNode {.gcsafe.}
+proc parseSelect(p: var SqlParser): SqlNode {.gcsafe.}
 
-proc identOrLiteral(p: var TSqlParser): PSqlNode = 
+proc identOrLiteral(p: var SqlParser): SqlNode =
   case p.tok.kind
-  of tkIdentifier, tkQuotedIdentifier: 
+  of tkQuotedIdentifier:
+    result = newNode(nkQuotedIdent, p.tok.literal)
+    getTok(p)
+  of tkIdentifier:
     result = newNode(nkIdent, p.tok.literal)
     getTok(p)
   of tkStringConstant, tkEscapeConstant, tkDollarQuotedConstant:
@@ -679,33 +699,42 @@ proc identOrLiteral(p: var TSqlParser): PSqlNode =
     getTok(p)
   of tkParLe:
     getTok(p)
-    result = parseExpr(p)
+    result = newNode(nkPrGroup)
+    while true:
+      result.add(parseExpr(p))
+      if p.tok.kind != tkComma: break
+      getTok(p)
     eat(p, tkParRi)
-  else: 
-    sqlError(p, "expression expected")
-    getTok(p) # we must consume a token here to prevend endless loops!
+  else:
+    if p.tok.literal == "*":
+      result = newNode(nkIdent, p.tok.literal)
+      getTok(p)
+    else:
+      sqlError(p, "expression expected")
+      getTok(p) # we must consume a token here to prevent endless loops!
 
-proc primary(p: var TSqlParser): PSqlNode = 
-  if p.tok.kind == tkOperator or isKeyw(p, "not"): 
+proc primary(p: var SqlParser): SqlNode =
+  if (p.tok.kind == tkOperator and (p.tok.literal == "+" or p.tok.literal ==
+      "-")) or isKeyw(p, "not"):
     result = newNode(nkPrefix)
     result.add(newNode(nkIdent, p.tok.literal))
     getTok(p)
     result.add(primary(p))
     return
   result = identOrLiteral(p)
-  while true: 
+  while true:
     case p.tok.kind
-    of tkParLe: 
+    of tkParLe:
       var a = result
       result = newNode(nkCall)
       result.add(a)
       getTok(p)
-      while true:
+      while p.tok.kind != tkParRi:
         result.add(parseExpr(p))
         if p.tok.kind == tkComma: getTok(p)
         else: break
       eat(p, tkParRi)
-    of tkDot: 
+    of tkDot:
       getTok(p)
       var a = result
       if p.tok.kind == tkDot:
@@ -722,16 +751,16 @@ proc primary(p: var TSqlParser): PSqlNode =
         sqlError(p, "identifier expected")
       getTok(p)
     else: break
-  
-proc lowestExprAux(p: var TSqlParser, v: var PSqlNode, limit: int): int = 
+
+proc lowestExprAux(p: var SqlParser, v: var SqlNode, limit: int): int =
   var
-    v2, node, opNode: PSqlNode
+    v2, node, opNode: SqlNode
   v = primary(p) # expand while operators have priorities higher than 'limit'
   var opPred = getPrecedence(p)
   result = opPred
-  while opPred > limit: 
+  while opPred > limit:
     node = newNode(nkInfix)
-    opNode = newNode(nkIdent, p.tok.literal)
+    opNode = newNode(nkIdent, p.tok.literal.toLowerAscii())
     getTok(p)
     result = lowestExprAux(p, v2, opPred)
     node.add(opNode)
@@ -739,15 +768,15 @@ proc lowestExprAux(p: var TSqlParser, v: var PSqlNode, limit: int): int =
     node.add(v2)
     v = node
     opPred = getPrecedence(p)
-  
-proc parseExpr(p: var TSqlParser): PSqlNode = 
+
+proc parseExpr(p: var SqlParser): SqlNode =
   discard lowestExprAux(p, result, - 1)
 
-proc parseTableName(p: var TSqlParser): PSqlNode =
+proc parseTableName(p: var SqlParser): SqlNode =
   expectIdent(p)
   result = primary(p)
 
-proc parseColumnReference(p: var TSqlParser): PSqlNode =
+proc parseColumnReference(p: var SqlParser): SqlNode =
   result = parseTableName(p)
   if p.tok.kind == tkParLe:
     getTok(p)
@@ -760,21 +789,31 @@ proc parseColumnReference(p: var TSqlParser): PSqlNode =
       result.add(parseTableName(p))
     eat(p, tkParRi)
 
-proc parseCheck(p: var TSqlParser): PSqlNode = 
+proc parseCheck(p: var SqlParser): SqlNode =
   getTok(p)
   result = newNode(nkCheck)
   result.add(parseExpr(p))
 
-proc parseConstraint(p: var TSqlParser): PSqlNode =
+proc parseConstraint(p: var SqlParser): SqlNode =
   getTok(p)
   result = newNode(nkConstraint)
   expectIdent(p)
   result.add(newNode(nkIdent, p.tok.literal))
   getTok(p)
-  eat(p, "check")
+  optKeyw(p, "check")
   result.add(parseExpr(p))
 
-proc parseColumnConstraints(p: var TSqlParser, result: PSqlNode) =
+proc parseParIdentList(p: var SqlParser, father: SqlNode) =
+  eat(p, tkParLe)
+  while true:
+    expectIdent(p)
+    father.add(newNode(nkIdent, p.tok.literal))
+    getTok(p)
+    if p.tok.kind != tkComma: break
+    getTok(p)
+  eat(p, tkParRi)
+
+proc parseColumnConstraints(p: var SqlParser, result: SqlNode) =
   while true:
     if isKeyw(p, "default"):
       getTok(p)
@@ -790,6 +829,9 @@ proc parseColumnConstraints(p: var TSqlParser, result: PSqlNode) =
       getTok(p)
       eat(p, "null")
       result.add(newNode(nkNotNull))
+    elif isKeyw(p, "null"):
+      getTok(p)
+      result.add(newNode(nkNull))
     elif isKeyw(p, "identity"):
       getTok(p)
       result.add(newNode(nkIdentity))
@@ -802,19 +844,20 @@ proc parseColumnConstraints(p: var TSqlParser, result: PSqlNode) =
     elif isKeyw(p, "constraint"):
       result.add(parseConstraint(p))
     elif isKeyw(p, "unique"):
+      getTok(p)
       result.add(newNode(nkUnique))
     else:
       break
 
-proc parseColumnDef(p: var TSqlParser): PSqlNode =
+proc parseColumnDef(p: var SqlParser): SqlNode =
   expectIdent(p)
   result = newNode(nkColumnDef)
   result.add(newNode(nkIdent, p.tok.literal))
   getTok(p)
   result.add(parseDataType(p))
-  parseColumnConstraints(p, result)  
+  parseColumnConstraints(p, result)
 
-proc parseIfNotExists(p: var TSqlParser, k: TSqlNodeKind): PSqlNode = 
+proc parseIfNotExists(p: var SqlParser, k: SqlNodeKind): SqlNode =
   getTok(p)
   if isKeyw(p, "if"):
     getTok(p)
@@ -824,17 +867,7 @@ proc parseIfNotExists(p: var TSqlParser, k: TSqlNodeKind): PSqlNode =
   else:
     result = newNode(k)
 
-proc parseParIdentList(p: var TSqlParser, father: PSqlNode) =
-  eat(p, tkParLe)
-  while true:
-    expectIdent(p)
-    father.add(newNode(nkIdent, p.tok.literal))
-    getTok(p)
-    if p.tok.kind != tkComma: break
-    getTok(p)
-  eat(p, tkParRi)
-
-proc parseTableConstraint(p: var TSqlParser): PSqlNode =
+proc parseTableConstraint(p: var SqlParser): SqlNode =
   if isKeyw(p, "primary"):
     getTok(p)
     eat(p, "key")
@@ -861,22 +894,36 @@ proc parseTableConstraint(p: var TSqlParser): PSqlNode =
   else:
     sqlError(p, "column definition expected")
 
-proc parseTableDef(p: var TSqlParser): PSqlNode =
+proc parseUnique(p: var SqlParser): SqlNode =
+  result = parseExpr(p)
+  if result.kind == nkCall: result.kind = nkUnique
+
+proc parseTableDef(p: var SqlParser): SqlNode =
   result = parseIfNotExists(p, nkCreateTable)
   expectIdent(p)
   result.add(newNode(nkIdent, p.tok.literal))
   getTok(p)
   if p.tok.kind == tkParLe:
-    while true:
-      getTok(p)
-      if p.tok.kind == tkIdentifier or p.tok.kind == tkQuotedIdentifier:
+    getTok(p)
+    while p.tok.kind != tkParRi:
+      if isKeyw(p, "constraint"):
+        result.add parseConstraint(p)
+      elif isKeyw(p, "primary") or isKeyw(p, "foreign"):
+        result.add parseTableConstraint(p)
+      elif isKeyw(p, "unique"):
+        result.add parseUnique(p)
+      elif p.tok.kind == tkIdentifier or p.tok.kind == tkQuotedIdentifier:
         result.add(parseColumnDef(p))
       else:
         result.add(parseTableConstraint(p))
       if p.tok.kind != tkComma: break
+      getTok(p)
     eat(p, tkParRi)
-  
-proc parseTypeDef(p: var TSqlParser): PSqlNode =
+    # skip additional crap after 'create table (...) crap;'
+    while p.tok.kind notin {tkSemicolon, tkEof}:
+      getTok(p)
+
+proc parseTypeDef(p: var SqlParser): SqlNode =
   result = parseIfNotExists(p, nkCreateType)
   expectIdent(p)
   result.add(newNode(nkIdent, p.tok.literal))
@@ -884,12 +931,25 @@ proc parseTypeDef(p: var TSqlParser): PSqlNode =
   eat(p, "as")
   result.add(parseDataType(p))
 
-proc parseWhere(p: var TSqlParser): PSqlNode =
+proc parseWhere(p: var SqlParser): SqlNode =
   getTok(p)
   result = newNode(nkWhere)
   result.add(parseExpr(p))
 
-proc parseIndexDef(p: var TSqlParser): PSqlNode =
+proc parseFromItem(p: var SqlParser): SqlNode =
+  result = newNode(nkFromItemPair)
+  if p.tok.kind == tkParLe:
+    getTok(p)
+    var select = parseSelect(p)
+    result.add(select)
+    eat(p, tkParRi)
+  else:
+    result.add(parseExpr(p))
+  if isKeyw(p, "as"):
+    getTok(p)
+    result.add(parseExpr(p))
+
+proc parseIndexDef(p: var SqlParser): SqlNode =
   result = parseIfNotExists(p, nkCreateIndex)
   if isKeyw(p, "primary"):
     getTok(p)
@@ -914,7 +974,7 @@ proc parseIndexDef(p: var TSqlParser): PSqlNode =
     getTok(p)
   eat(p, tkParRi)
 
-proc parseInsert(p: var TSqlParser): PSqlNode =
+proc parseInsert(p: var SqlParser): SqlNode =
   getTok(p)
   eat(p, "into")
   expectIdent(p)
@@ -924,8 +984,9 @@ proc parseInsert(p: var TSqlParser): PSqlNode =
   if p.tok.kind == tkParLe:
     var n = newNode(nkColumnList)
     parseParIdentList(p, n)
+    result.add n
   else:
-    result.add(nil)
+    result.add(newNode(nkNone))
   if isKeyw(p, "default"):
     getTok(p)
     eat(p, "values")
@@ -941,7 +1002,7 @@ proc parseInsert(p: var TSqlParser): PSqlNode =
     result.add(n)
     eat(p, tkParRi)
 
-proc parseUpdate(p: var TSqlParser): PSqlNode =
+proc parseUpdate(p: var SqlParser): SqlNode =
   getTok(p)
   result = newNode(nkUpdate)
   result.add(primary(p))
@@ -960,19 +1021,21 @@ proc parseUpdate(p: var TSqlParser): PSqlNode =
   if isKeyw(p, "where"):
     result.add(parseWhere(p))
   else:
-    result.add(nil)
-    
-proc parseDelete(p: var TSqlParser): PSqlNode =
+    result.add(newNode(nkNone))
+
+proc parseDelete(p: var SqlParser): SqlNode =
   getTok(p)
+  if isOpr(p, "*"):
+    getTok(p)
   result = newNode(nkDelete)
   eat(p, "from")
   result.add(primary(p))
   if isKeyw(p, "where"):
     result.add(parseWhere(p))
   else:
-    result.add(nil)
+    result.add(newNode(nkNone))
 
-proc parseSelect(p: var TSqlParser): PSqlNode =
+proc parseSelect(p: var SqlParser): SqlNode =
   getTok(p)
   if isKeyw(p, "distinct"):
     getTok(p)
@@ -986,7 +1049,12 @@ proc parseSelect(p: var TSqlParser): PSqlNode =
       a.add(newNode(nkIdent, "*"))
       getTok(p)
     else:
-      a.add(parseExpr(p))
+      var pair = newNode(nkSelectPair)
+      pair.add(parseExpr(p))
+      a.add(pair)
+      if isKeyw(p, "as"):
+        getTok(p)
+        pair.add(parseExpr(p))
     if p.tok.kind != tkComma: break
     getTok(p)
   result.add(a)
@@ -994,7 +1062,7 @@ proc parseSelect(p: var TSqlParser): PSqlNode =
     var f = newNode(nkFrom)
     while true:
       getTok(p)
-      f.add(parseExpr(p))
+      f.add(parseFromItem(p))
       if p.tok.kind != tkComma: break
     result.add(f)
   if isKeyw(p, "where"):
@@ -1008,29 +1076,14 @@ proc parseSelect(p: var TSqlParser): PSqlNode =
       if p.tok.kind != tkComma: break
       getTok(p)
     result.add(g)
-  if isKeyw(p, "having"):
-    var h = newNode(nkHaving)
-    while true:
-      getTok(p)
-      h.add(parseExpr(p))
-      if p.tok.kind != tkComma: break    
-    result.add(h)
-  if isKeyw(p, "union"):
-    result.add(newNode(nkUnion))
-    getTok(p)
-  elif isKeyw(p, "intersect"):
-    result.add(newNode(nkIntersect))
-    getTok(p)  
-  elif isKeyw(p, "except"):
-    result.add(newNode(nkExcept))
-    getTok(p)
   if isKeyw(p, "order"):
     getTok(p)
     eat(p, "by")
     var n = newNode(nkOrder)
     while true:
       var e = parseExpr(p)
-      if isKeyw(p, "asc"): getTok(p) # is default
+      if isKeyw(p, "asc"):
+        getTok(p) # is default
       elif isKeyw(p, "desc"):
         getTok(p)
         var x = newNode(nkDesc)
@@ -1040,8 +1093,47 @@ proc parseSelect(p: var TSqlParser): PSqlNode =
       if p.tok.kind != tkComma: break
       getTok(p)
     result.add(n)
+  if isKeyw(p, "having"):
+    var h = newNode(nkHaving)
+    while true:
+      getTok(p)
+      h.add(parseExpr(p))
+      if p.tok.kind != tkComma: break
+    result.add(h)
+  if isKeyw(p, "union"):
+    result.add(newNode(nkUnion))
+    getTok(p)
+  elif isKeyw(p, "intersect"):
+    result.add(newNode(nkIntersect))
+    getTok(p)
+  elif isKeyw(p, "except"):
+    result.add(newNode(nkExcept))
+    getTok(p)
+  if isKeyw(p, "join") or isKeyw(p, "inner") or isKeyw(p, "outer") or isKeyw(p, "cross"):
+    var join = newNode(nkJoin)
+    result.add(join)
+    if isKeyw(p, "join"):
+      join.add(newNode(nkIdent, ""))
+      getTok(p)
+    else:
+      join.add(newNode(nkIdent, p.tok.literal.toLowerAscii()))
+      getTok(p)
+      eat(p, "join")
+    join.add(parseFromItem(p))
+    eat(p, "on")
+    join.add(parseExpr(p))
+  if isKeyw(p, "limit"):
+    getTok(p)
+    var l = newNode(nkLimit)
+    l.add(parseExpr(p))
+    result.add(l)
+  if isKeyw(p, "offset"):
+    getTok(p)
+    var o = newNode(nkOffset)
+    o.add(parseExpr(p))
+    result.add(o)
 
-proc parseStmt(p: var TSqlParser): PSqlNode =
+proc parseStmt(p: var SqlParser; parent: SqlNode) =
   if isKeyw(p, "create"):
     getTok(p)
     optKeyw(p, "cached")
@@ -1053,81 +1145,121 @@ proc parseStmt(p: var TSqlParser): PSqlNode =
     optKeyw(p, "unique")
     optKeyw(p, "hash")
     if isKeyw(p, "table"):
-      result = parseTableDef(p)
+      parent.add parseTableDef(p)
     elif isKeyw(p, "type"):
-      result = parseTypeDef(p)
+      parent.add parseTypeDef(p)
     elif isKeyw(p, "index"):
-      result = parseIndexDef(p)
+      parent.add parseIndexDef(p)
     else:
       sqlError(p, "TABLE expected")
   elif isKeyw(p, "insert"):
-    result = parseInsert(p)
+    parent.add parseInsert(p)
   elif isKeyw(p, "update"):
-    result = parseUpdate(p)
+    parent.add parseUpdate(p)
   elif isKeyw(p, "delete"):
-    result = parseDelete(p)
+    parent.add parseDelete(p)
   elif isKeyw(p, "select"):
-    result = parseSelect(p)
+    parent.add parseSelect(p)
+  elif isKeyw(p, "begin"):
+    getTok(p)
   else:
-    sqlError(p, "CREATE expected")
+    sqlError(p, "SELECT, CREATE, UPDATE or DELETE expected")
 
-proc open(p: var TSqlParser, input: PStream, filename: string) =
-  ## opens the parser `p` and assigns the input stream `input` to it.
-  ## `filename` is only used for error messages.
-  open(TSqlLexer(p), input, filename)
-  p.tok.kind = tkInvalid
-  p.tok.literal = ""
-  getTok(p)
-  
-proc parse(p: var TSqlParser): PSqlNode =
+proc parse(p: var SqlParser): SqlNode =
   ## parses the content of `p`'s input stream and returns the SQL AST.
-  ## Syntax errors raise an `EInvalidSql` exception.
+  ## Syntax errors raise an `SqlParseError` exception.
   result = newNode(nkStmtList)
   while p.tok.kind != tkEof:
-    var s = parseStmt(p)
-    eat(p, tkSemiColon)
-    result.add(s)
-  if result.len == 1:
-    result = result.sons[0]
-  
-proc close(p: var TSqlParser) =
+    parseStmt(p, result)
+    if p.tok.kind == tkEof:
+      break
+    eat(p, tkSemicolon)
+
+proc close(p: var SqlParser) =
   ## closes the parser `p`. The associated input stream is closed too.
-  close(TSqlLexer(p))
+  close(SqlLexer(p))
 
-proc parseSQL*(input: PStream, filename: string): PSqlNode =
-  ## parses the SQL from `input` into an AST and returns the AST. 
-  ## `filename` is only used for error messages.
-  ## Syntax errors raise an `EInvalidSql` exception.
-  var p: TSqlParser
-  open(p, input, filename)
-  try:
-    result = parse(p)
-  finally:
-    close(p)
+type
+  SqlWriter = object
+    indent: int
+    upperCase: bool
+    buffer: string
+
+proc add(s: var SqlWriter, thing: char) =
+  s.buffer.add(thing)
+
+proc prepareAdd(s: var SqlWriter) {.inline.} =
+  if s.buffer.len > 0 and s.buffer[^1] notin {' ', '\L', '(', '.'}:
+    s.buffer.add(" ")
+
+proc add(s: var SqlWriter, thing: string) =
+  s.prepareAdd
+  s.buffer.add(thing)
+
+proc addKeyw(s: var SqlWriter, thing: string) =
+  var keyw = thing
+  if s.upperCase:
+    keyw = keyw.toUpperAscii()
+  s.add(keyw)
+
+proc addIden(s: var SqlWriter, thing: string) =
+  var iden = thing
+  if iden.toLowerAscii() in reservedKeywords:
+    iden = '"' & iden & '"'
+  s.add(iden)
+
+proc ra(n: SqlNode, s: var SqlWriter) {.gcsafe.}
+
+proc rs(n: SqlNode, s: var SqlWriter, prefix = "(", suffix = ")", sep = ", ") =
+  if n.len > 0:
+    s.add(prefix)
+    for i in 0 .. n.len-1:
+      if i > 0: s.add(sep)
+      ra(n.sons[i], s)
+    s.add(suffix)
 
-proc ra(n: PSqlNode, s: var string, indent: int)
+proc addMulti(s: var SqlWriter, n: SqlNode, sep = ',') =
+  if n.len > 0:
+    for i in 0 .. n.len-1:
+      if i > 0: s.add(sep)
+      ra(n.sons[i], s)
 
-proc rs(n: PSqlNode, s: var string, indent: int,
-        prefix = "(", suffix = ")",
-        sep = ", ") = 
+proc addMulti(s: var SqlWriter, n: SqlNode, sep = ',', prefix, suffix: char) =
   if n.len > 0:
     s.add(prefix)
     for i in 0 .. n.len-1:
       if i > 0: s.add(sep)
-      ra(n.sons[i], s, indent)
+      ra(n.sons[i], s)
     s.add(suffix)
 
-proc ra(n: PSqlNode, s: var string, indent: int) =
+proc quoted(s: string): string =
+  "\"" & replace(s, "\"", "\"\"") & "\""
+
+func escape(result: var string; s: string) =
+  result.add('\'')
+  for c in items(s):
+    case c
+    of '\0'..'\31':
+      result.add("\\x")
+      result.add(toHex(ord(c), 2))
+    of '\'': result.add("''")
+    else: result.add(c)
+  result.add('\'')
+
+proc ra(n: SqlNode, s: var SqlWriter) =
   if n == nil: return
   case n.kind
-  of nkNone: nil
+  of nkNone: discard
   of nkIdent:
     if allCharsInSet(n.strVal, {'\33'..'\127'}):
       s.add(n.strVal)
     else:
-      s.add("\"" & replace(n.strVal, "\"", "\"\"") & "\"")
+      s.add(quoted(n.strVal))
+  of nkQuotedIdent:
+    s.add(quoted(n.strVal))
   of nkStringLit:
-    s.add(escape(n.strVal, "e'", "'"))
+    s.prepareAdd
+    s.buffer.escape(n.strVal)
   of nkBitStringLit:
     s.add("b'" & n.strVal & "'")
   of nkHexStringLit:
@@ -1135,211 +1267,257 @@ proc ra(n: PSqlNode, s: var string, indent: int) =
   of nkIntegerLit, nkNumericLit:
     s.add(n.strVal)
   of nkPrimaryKey:
-    s.add(" primary key")
-    rs(n, s, indent)
+    s.addKeyw("primary key")
+    rs(n, s)
   of nkForeignKey:
-    s.add(" foreign key")
-    rs(n, s, indent)
+    s.addKeyw("foreign key")
+    rs(n, s)
   of nkNotNull:
-    s.add(" not null")
+    s.addKeyw("not null")
+  of nkNull:
+    s.addKeyw("null")
   of nkDot:
-    ra(n.sons[0], s, indent)
-    s.add(".")
-    ra(n.sons[1], s, indent)
+    ra(n.sons[0], s)
+    s.add('.')
+    ra(n.sons[1], s)
   of nkDotDot:
-    ra(n.sons[0], s, indent)
+    ra(n.sons[0], s)
     s.add(". .")
-    ra(n.sons[1], s, indent)
+    ra(n.sons[1], s)
   of nkPrefix:
-    s.add('(')
-    ra(n.sons[0], s, indent)
+    ra(n.sons[0], s)
     s.add(' ')
-    ra(n.sons[1], s, indent)
-    s.add(')')
+    ra(n.sons[1], s)
   of nkInfix:
-    s.add('(')    
-    ra(n.sons[1], s, indent)
+    ra(n.sons[1], s)
     s.add(' ')
-    ra(n.sons[0], s, indent)
+    ra(n.sons[0], s)
     s.add(' ')
-    ra(n.sons[2], s, indent)
-    s.add(')')
+    ra(n.sons[2], s)
   of nkCall, nkColumnReference:
-    ra(n.sons[0], s, indent)
+    ra(n.sons[0], s)
     s.add('(')
     for i in 1..n.len-1:
-      if i > 1: s.add(", ")
-      ra(n.sons[i], s, indent)
+      if i > 1: s.add(',')
+      ra(n.sons[i], s)
+    s.add(')')
+  of nkPrGroup:
+    s.add('(')
+    s.addMulti(n)
     s.add(')')
   of nkReferences:
-    s.add(" references ")
-    ra(n.sons[0], s, indent)
+    s.addKeyw("references")
+    ra(n.sons[0], s)
   of nkDefault:
-    s.add(" default ")
-    ra(n.sons[0], s, indent)
+    s.addKeyw("default")
+    ra(n.sons[0], s)
   of nkCheck:
-    s.add(" check ")
-    ra(n.sons[0], s, indent)
+    s.addKeyw("check")
+    ra(n.sons[0], s)
   of nkConstraint:
-    s.add(" constraint ")
-    ra(n.sons[0], s, indent)
-    s.add(" check ")
-    ra(n.sons[1], s, indent)
+    s.addKeyw("constraint")
+    ra(n.sons[0], s)
+    s.addKeyw("check")
+    ra(n.sons[1], s)
   of nkUnique:
-    s.add(" unique")
-    rs(n, s, indent)
+    s.addKeyw("unique")
+    rs(n, s)
   of nkIdentity:
-    s.add(" identity")
+    s.addKeyw("identity")
   of nkColumnDef:
-    s.add("\n  ")
-    rs(n, s, indent, "", "", " ")
+    rs(n, s, "", "", " ")
   of nkStmtList:
     for i in 0..n.len-1:
-      ra(n.sons[i], s, indent)
-      s.add("\n")
+      ra(n.sons[i], s)
+      s.add(';')
   of nkInsert:
     assert n.len == 3
-    s.add("insert into ")
-    ra(n.sons[0], s, indent)
-    ra(n.sons[1], s, indent)
-    if n.sons[2].kind == nkDefault: 
-      s.add("default values")
+    s.addKeyw("insert into")
+    ra(n.sons[0], s)
+    s.add(' ')
+    ra(n.sons[1], s)
+    if n.sons[2].kind == nkDefault:
+      s.addKeyw("default values")
     else:
-      s.add("\nvalues ")
-      ra(n.sons[2], s, indent)
-    s.add(';')
-  of nkUpdate: 
-    s.add("update ")
-    ra(n.sons[0], s, indent)
-    s.add(" set ")
+      ra(n.sons[2], s)
+  of nkUpdate:
+    s.addKeyw("update")
+    ra(n.sons[0], s)
+    s.addKeyw("set")
     var L = n.len
     for i in 1 .. L-2:
       if i > 1: s.add(", ")
       var it = n.sons[i]
       assert it.kind == nkAsgn
-      ra(it, s, indent)
-    ra(n.sons[L-1], s, indent)
-    s.add(';')
-  of nkDelete: 
-    s.add("delete from ")
-    ra(n.sons[0], s, indent)
-    ra(n.sons[1], s, indent)
-    s.add(';')
+      ra(it, s)
+    ra(n.sons[L-1], s)
+  of nkDelete:
+    s.addKeyw("delete from")
+    ra(n.sons[0], s)
+    ra(n.sons[1], s)
   of nkSelect, nkSelectDistinct:
-    s.add("select ")
+    s.addKeyw("select")
     if n.kind == nkSelectDistinct:
-      s.add("distinct ")
-    rs(n.sons[0], s, indent, "", "", ", ")
-    for i in 1 .. n.len-1: ra(n.sons[i], s, indent)
-    s.add(';')
-  of nkSelectColumns: 
-    assert(false)
+      s.addKeyw("distinct")
+    for i in 0 ..< n.len:
+      ra(n.sons[i], s)
+  of nkSelectColumns:
+    for i, column in n.sons:
+      if i > 0: s.add(',')
+      ra(column, s)
+  of nkSelectPair:
+    ra(n.sons[0], s)
+    if n.sons.len == 2:
+      s.addKeyw("as")
+      ra(n.sons[1], s)
+  of nkFromItemPair:
+    if n.sons[0].kind in {nkIdent, nkQuotedIdent}:
+      ra(n.sons[0], s)
+    else:
+      assert n.sons[0].kind == nkSelect
+      s.add('(')
+      ra(n.sons[0], s)
+      s.add(')')
+    if n.sons.len == 2:
+      s.addKeyw("as")
+      ra(n.sons[1], s)
   of nkAsgn:
-    ra(n.sons[0], s, indent)
+    ra(n.sons[0], s)
     s.add(" = ")
-    ra(n.sons[1], s, indent)  
+    ra(n.sons[1], s)
   of nkFrom:
-    s.add("\nfrom ")
-    rs(n, s, indent, "", "", ", ")
+    s.addKeyw("from")
+    s.addMulti(n)
   of nkGroup:
-    s.add("\ngroup by")
-    rs(n, s, indent, "", "", ", ")
+    s.addKeyw("group by")
+    s.addMulti(n)
+  of nkLimit:
+    s.addKeyw("limit")
+    s.addMulti(n)
+  of nkOffset:
+    s.addKeyw("offset")
+    s.addMulti(n)
   of nkHaving:
-    s.add("\nhaving")
-    rs(n, s, indent, "", "", ", ")
+    s.addKeyw("having")
+    s.addMulti(n)
   of nkOrder:
-    s.add("\norder by ")
-    rs(n, s, indent, "", "", ", ")
+    s.addKeyw("order by")
+    s.addMulti(n)
+  of nkJoin:
+    var joinType = n.sons[0].strVal
+    if joinType == "":
+      joinType = "join"
+    else:
+      joinType &= " " & "join"
+    s.addKeyw(joinType)
+    ra(n.sons[1], s)
+    s.addKeyw("on")
+    ra(n.sons[2], s)
   of nkDesc:
-    ra(n.sons[0], s, indent)
-    s.add(" desc")
+    ra(n.sons[0], s)
+    s.addKeyw("desc")
   of nkUnion:
-    s.add(" union")
+    s.addKeyw("union")
   of nkIntersect:
-    s.add(" intersect")
+    s.addKeyw("intersect")
   of nkExcept:
-    s.add(" except")
+    s.addKeyw("except")
   of nkColumnList:
-    rs(n, s, indent)
+    rs(n, s)
   of nkValueList:
-    s.add("values ")
-    rs(n, s, indent)
+    s.addKeyw("values")
+    rs(n, s)
   of nkWhere:
-    s.add("\nwhere ")
-    ra(n.sons[0], s, indent)
+    s.addKeyw("where")
+    ra(n.sons[0], s)
   of nkCreateTable, nkCreateTableIfNotExists:
-    s.add("create table ")
+    s.addKeyw("create table")
     if n.kind == nkCreateTableIfNotExists:
-      s.add("if not exists ")
-    ra(n.sons[0], s, indent)
+      s.addKeyw("if not exists")
+    ra(n.sons[0], s)
     s.add('(')
     for i in 1..n.len-1:
-      if i > 1: s.add(", ")
-      ra(n.sons[i], s, indent)
+      if i > 1: s.add(',')
+      ra(n.sons[i], s)
     s.add(");")
   of nkCreateType, nkCreateTypeIfNotExists:
-    s.add("create type ")
+    s.addKeyw("create type")
     if n.kind == nkCreateTypeIfNotExists:
-      s.add("if not exists ")
-    ra(n.sons[0], s, indent)
-    s.add(" as ")
-    ra(n.sons[1], s, indent)
-    s.add(';')
+      s.addKeyw("if not exists")
+    ra(n.sons[0], s)
+    s.addKeyw("as")
+    ra(n.sons[1], s)
   of nkCreateIndex, nkCreateIndexIfNotExists:
-    s.add("create index ")
+    s.addKeyw("create index")
     if n.kind == nkCreateIndexIfNotExists:
-      s.add("if not exists ")
-    ra(n.sons[0], s, indent)
-    s.add(" on ")
-    ra(n.sons[1], s, indent)
+      s.addKeyw("if not exists")
+    ra(n.sons[0], s)
+    s.addKeyw("on")
+    ra(n.sons[1], s)
     s.add('(')
     for i in 2..n.len-1:
       if i > 2: s.add(", ")
-      ra(n.sons[i], s, indent)
+      ra(n.sons[i], s)
     s.add(");")
   of nkEnumDef:
-    s.add("enum ")
-    rs(n, s, indent)
+    s.addKeyw("enum")
+    rs(n, s)
 
-# What I want: 
-#
-#select(columns = [T1.all, T2.name], 
-#       fromm = [T1, T2],
-#       where = T1.name ==. T2.name,
-#       orderby = [name]):
-#  
-#for row in dbQuery(db, """select x, y, z 
-#                          from a, b 
-#                          where a.name = b.name"""):
-#  
-
-#select x, y, z:
-#  fromm: Table1, Table2
-#  where: x.name == y.name
-#db.select(fromm = [t1, t2], where = t1.name == t2.name):
-#for x, y, z in db.select(fromm = a, b where = a.name == b.name): 
-#  writeln x, y, z
-
-proc renderSQL*(n: PSqlNode): string =
+proc renderSql*(n: SqlNode, upperCase = false): string =
   ## Converts an SQL abstract syntax tree to its string representation.
-  result = ""
-  ra(n, result, 0)
-
-when isMainModule:
-  echo(renderSQL(parseSQL(newStringStream("""
-      CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic');
-      CREATE TABLE holidays (
-         num_weeks int,
-         happiness happiness
-      );
-      CREATE INDEX table1_attr1 ON table1(attr1);
-      
-      SELECT * FROM myTab WHERE col1 = 'happy';
-  """), "stdin")))
-
-# CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic');
-# CREATE TABLE holidays (
-#    num_weeks int,
-#    happiness happiness
-# );
-# CREATE INDEX table1_attr1 ON table1(attr1)
+  var s: SqlWriter
+  s.buffer = ""
+  s.upperCase = upperCase
+  ra(n, s)
+  return s.buffer
+
+proc `$`*(n: SqlNode): string =
+  ## an alias for `renderSql`.
+  renderSql(n)
+
+proc treeReprAux(s: SqlNode, level: int, result: var string) =
+  result.add('\n')
+  for i in 0 ..< level: result.add("  ")
+
+  result.add($s.kind)
+  if s.kind in LiteralNodes:
+    result.add(' ')
+    result.add(s.strVal)
+  else:
+    for son in s.sons:
+      treeReprAux(son, level + 1, result)
+
+proc treeRepr*(s: SqlNode): string =
+  result = newStringOfCap(128)
+  treeReprAux(s, 0, result)
+
+import std/streams
+
+proc open(L: var SqlLexer, input: Stream, filename: string) =
+  lexbase.open(L, input)
+  L.filename = filename
+
+proc open(p: var SqlParser, input: Stream, filename: string) =
+  ## opens the parser `p` and assigns the input stream `input` to it.
+  ## `filename` is only used for error messages.
+  open(SqlLexer(p), input, filename)
+  p.tok.kind = tkInvalid
+  p.tok.literal = ""
+  getTok(p)
+
+proc parseSql*(input: Stream, filename: string): SqlNode =
+  ## parses the SQL from `input` into an AST and returns the AST.
+  ## `filename` is only used for error messages.
+  ## Syntax errors raise an `SqlParseError` exception.
+  var p: SqlParser
+  open(p, input, filename)
+  try:
+    result = parse(p)
+  finally:
+    close(p)
+
+proc parseSql*(input: string, filename = ""): SqlNode =
+  ## parses the SQL from `input` into an AST and returns the AST.
+  ## `filename` is only used for error messages.
+  ## Syntax errors raise an `SqlParseError` exception.
+  parseSql(newStringStream(input), "")
diff --git a/lib/pure/parseurl.nim b/lib/pure/parseurl.nim
deleted file mode 100755
index ebeda3fd3..000000000
--- a/lib/pure/parseurl.nim
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Dominik Picheta
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Parses & constructs URLs.
-
-import strutils
-
-type
-  TURL* = tuple[      ## represents a *Uniform Resource Locator* (URL)
-                      ## any optional component is "" if it does not exist
-    scheme, username, password, 
-    hostname, port, path, query, anchor: string]
-    
-proc parseUrl*(url: string): TURL =
-  var i: int = 0
-
-  var scheme, username, password: string = ""
-  var hostname, port, path, query, anchor: string = ""
-
-  var temp: string = ""
-  
-  if url[i] != '/': #url isn't a relative path
-    while True:
-      #Scheme
-      if url[i] == ':':
-        if url[i+1] == '/' and url[i+2] == '/':
-          scheme = temp
-          temp = ""
-          inc(i, 3) #Skip the //
-      #Authority(username, password)
-      if url[i] == '@':
-        username = temp.split(':')[0]
-        if temp.split(':').len() > 1:
-          password = temp.split(':')[1]
-        temp = ""
-        inc(i) #Skip the @ 
-      #hostname(subdomain, domain, port)
-      if url[i] == '/' or url[i] == '\0':
-        hostname = temp
-        if hostname.split(':').len() > 1:
-          port = hostname.split(':')[1]
-          hostname = hostname.split(':')[0]
-        
-        temp = ""
-        break
-      
-      temp.add(url[i])
-      inc(i)
-
-  if url[i] == '/': inc(i) # Skip the '/'
-  #Path
-  while True:
-    if url[i] == '?':
-      path = temp
-      temp = ""
-    if url[i] == '#':
-      if temp[0] == '?':
-        query = temp
-      else:
-        path = temp
-      temp = ""
-      
-    if url[i] == '\0':
-      if temp[0] == '?':
-        query = temp
-      elif temp[0] == '#':
-        anchor = temp
-      else:
-        path = temp
-      break
-      
-    temp.add(url[i])
-    inc(i)
-    
-  return (scheme, username, password, hostname, port, path, query, anchor)
-
-proc `$`*(t: TURL): string =
-  result = ""
-  if t.scheme != "": result.add(t.scheme & "://")
-  if t.username != "":
-    if t.password != "":
-      result.add(t.username & ":" & t.password & "@")
-    else:
-      result.add(t.username & "@")
-  result.add(t.hostname)
-  if t.port != "": result.add(":" & t.port)
-  if t.path != "": result.add("/" & t.path)
-  result.add(t.query)
-  result.add(t.anchor)
diff --git a/lib/pure/parseutils.nim b/lib/pure/parseutils.nim
index 0f107793c..2ca255fa0 100755..100644
--- a/lib/pure/parseutils.nim
+++ b/lib/pure/parseutils.nim
@@ -1,19 +1,56 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module contains helpers for parsing tokens, numbers, identifiers, etc.
+## This module contains helpers for parsing tokens, numbers, integers, floats,
+## identifiers, etc.
+##
+## To unpack raw bytes look at the `streams <streams.html>`_ module.
+##
+##   ```nim test
+##   let logs = @["2019-01-10: OK_", "2019-01-11: FAIL_", "2019-01: aaaa"]
+##   var outp: seq[string]
+##
+##   for log in logs:
+##     var res: string
+##     if parseUntil(log, res, ':') == 10: # YYYY-MM-DD == 10
+##       outp.add(res & " - " & captureBetween(log, ' ', '_'))
+##   doAssert outp == @["2019-01-10 - OK", "2019-01-11 - FAIL"]
+##   ```
+##
+##   ```nim test
+##   from std/strutils import Digits, parseInt
+##
+##   let
+##     input1 = "2019 school start"
+##     input2 = "3 years back"
+##     startYear = input1[0 .. skipWhile(input1, Digits)-1] # 2019
+##     yearsBack = input2[0 .. skipWhile(input2, Digits)-1] # 3
+##     examYear = parseInt(startYear) + parseInt(yearsBack)
+##   doAssert "Examination is in " & $examYear == "Examination is in 2022"
+##   ```
+##
+## **See also:**
+## * `strutils module<strutils.html>`_ for combined and identical parsing proc's
+## * `json module<json.html>`_ for a JSON parser
+## * `parsecfg module<parsecfg.html>`_ for a configuration file parser
+## * `parsecsv module<parsecsv.html>`_ for a simple CSV (comma separated value) parser
+## * `parseopt module<parseopt.html>`_ for a command line parser
+## * `parsexml module<parsexml.html>`_ for a XML / HTML parser
+## * `other parsers<lib.html#pure-libraries-parsers>`_ for other parsers
 
-{.deadCodeElim: on.}
-
-{.push debugger:off .} # the user does not want to trace a part
+{.push debugger: off.} # the user does not want to trace a part
                        # of the standard library!
 
+include "system/inclrtl"
+
+template toOa(s: string): openArray[char] = openArray[char](s)
+
 const
   Whitespace = {' ', '\t', '\v', '\r', '\l', '\f'}
   IdentChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
@@ -23,195 +60,1028 @@ const
 proc toLower(c: char): char {.inline.} =
   result = if c in {'A'..'Z'}: chr(ord(c)-ord('A')+ord('a')) else: c
 
-proc parseHex*(s: string, number: var int, start = 0): int = 
-  ## parses a hexadecimal number and stores its value in ``number``. Returns
-  ## the number of the parsed characters or 0 in case of an error.
-  var i = start
+proc parseBin*[T: SomeInteger](s: openArray[char], number: var T, maxLen = 0): int {.noSideEffect.} =
+  ## Parses a binary number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-bin character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseBin("0100_1110_0110_1001_1110_1101", num) == 29
+    doAssert num == 5138925
+    doAssert parseBin("3", num) == 0
+    var num8: int8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8) == 32
+    doAssert num8 == 0b1110_1101'i8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8, 3, 9) == 9
+    doAssert num8 == 0b0100_1110'i8
+    var num8u: uint8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8u) == 32
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseBin("0100111001101001111011010100111001101001", num64) == 40
+    doAssert num64 == 336784608873
+  var i = 0
+  var output = T(0)
   var foundDigit = false
-  if s[i] == '0' and (s[i+1] == 'x' or s[i+1] == 'X'): inc(i, 2)
-  elif s[i] == '#': inc(i)
-  while true: 
+  let last = min(s.len, if maxLen == 0: s.len else: i + maxLen)
+  if i + 1 < last and s[i] == '0' and (s[i+1] in {'b', 'B'}): inc(i, 2)
+  while i < last:
     case s[i]
-    of '_': nil
-    of '0'..'9':
-      number = number shl 4 or (ord(s[i]) - ord('0'))
-      foundDigit = true
-    of 'a'..'f':
-      number = number shl 4 or (ord(s[i]) - ord('a') + 10)
-      foundDigit = true
-    of 'A'..'F':
-      number = number shl 4 or (ord(s[i]) - ord('A') + 10)
+    of '_': discard
+    of '0'..'1':
+      output = output shl 1 or T(ord(s[i]) - ord('0'))
       foundDigit = true
     else: break
     inc(i)
-  if foundDigit: result = i-start
+  if foundDigit:
+    number = output
+    result = i
 
-proc parseOct*(s: string, number: var int, start = 0): int = 
-  ## parses an octal number and stores its value in ``number``. Returns
-  ## the number of the parsed characters or 0 in case of an error.
-  var i = start
+proc parseOct*[T: SomeInteger](s: openArray[char], number: var T, maxLen = 0): int {.noSideEffect.} =
+  ## Parses an octal number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-oct character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseOct("0o23464755", num) == 10
+    doAssert num == 5138925
+    doAssert parseOct("8", num) == 0
+    var num8: int8
+    doAssert parseOct("0o_1464_755", num8) == 11
+    doAssert num8 == -19
+    doAssert parseOct("0o_1464_755", num8, 3, 3) == 3
+    doAssert num8 == 102
+    var num8u: uint8
+    doAssert parseOct("1464755", num8u) == 7
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseOct("2346475523464755", num64) == 16
+    doAssert num64 == 86216859871725
+  var i = 0
+  var output = T(0)
   var foundDigit = false
-  if s[i] == '0' and (s[i+1] == 'o' or s[i+1] == 'O'): inc(i, 2)
-  while true: 
+  let last = min(s.len, if maxLen == 0: s.len else: i + maxLen)
+  if i + 1 < last and s[i] == '0' and (s[i+1] in {'o', 'O'}): inc(i, 2)
+  while i < last:
     case s[i]
-    of '_': nil
+    of '_': discard
     of '0'..'7':
-      number = number shl 3 or (ord(s[i]) - ord('0'))
+      output = output shl 3 or T(ord(s[i]) - ord('0'))
       foundDigit = true
     else: break
     inc(i)
-  if foundDigit: result = i-start
+  if foundDigit:
+    number = output
+    result = i
 
-proc parseIdent*(s: string, ident: var string, start = 0): int =
-  ## parses an identifier and stores it in ``ident``. Returns
+proc parseHex*[T: SomeInteger](s: openArray[char], number: var T, maxLen = 0): int {.noSideEffect.} =
+  ## Parses a hexadecimal number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-hex character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseHex("4E_69_ED", num) == 8
+    doAssert num == 5138925
+    doAssert parseHex("X", num) == 0
+    doAssert parseHex("#ABC", num) == 4
+    var num8: int8
+    doAssert parseHex("0x_4E_69_ED", num8) == 11
+    doAssert num8 == 0xED'i8
+    doAssert parseHex("0x_4E_69_ED", num8, 3, 2) == 2
+    doAssert num8 == 0x4E'i8
+    var num8u: uint8
+    doAssert parseHex("0x_4E_69_ED", num8u) == 11
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseHex("4E69ED4E69ED", num64) == 12
+    doAssert num64 == 86216859871725
+  var i = 0
+  var output = T(0)
+  var foundDigit = false
+  let last = min(s.len, if maxLen == 0: s.len else: i + maxLen)
+  if i + 1 < last and s[i] == '0' and (s[i+1] in {'x', 'X'}): inc(i, 2)
+  elif i < last and s[i] == '#': inc(i)
+  while i < last:
+    case s[i]
+    of '_': discard
+    of '0'..'9':
+      output = output shl 4 or T(ord(s[i]) - ord('0'))
+      foundDigit = true
+    of 'a'..'f':
+      output = output shl 4 or T(ord(s[i]) - ord('a') + 10)
+      foundDigit = true
+    of 'A'..'F':
+      output = output shl 4 or T(ord(s[i]) - ord('A') + 10)
+      foundDigit = true
+    else: break
+    inc(i)
+  if foundDigit:
+    number = output
+    result = i
+
+proc parseIdent*(s: openArray[char], ident: var string): int =
+  ## Parses an identifier and stores it in ``ident``. Returns
   ## the number of the parsed characters or 0 in case of an error.
-  var i = start
-  if s[i] in IdentStartChars:
+  ## If error, the value of `ident` is not changed.
+  runnableExamples:
+    var res: string
+    doAssert parseIdent("Hello World", res, 0) == 5
+    doAssert res == "Hello"
+    doAssert parseIdent("Hello World", res, 1) == 4
+    doAssert res == "ello"
+    doAssert parseIdent("Hello World", res, 6) == 5
+    doAssert res == "World"
+  var i = 0
+  if i < s.len and s[i] in IdentStartChars:
     inc(i)
-    while s[i] in IdentChars: inc(i)
-    ident = copy(s, start, i-1)
-    result = i-start
+    while i < s.len and s[i] in IdentChars: inc(i)
+    ident = substr(s.toOpenArray(0, i-1))
+    result = i
 
-proc parseToken*(s: string, token: var string, validChars: set[char],
-                 start = 0): int =
-  ## parses a token and stores it in ``token``. Returns
-  ## the number of the parsed characters or 0 in case of an error. A token
-  ## consists of the characters in `validChars`. 
-  var i = start
-  while s[i] in validChars: inc(i)
-  result = i-start
-  token = copy(s, start, i-1)
+proc parseIdent*(s: openArray[char]): string =
+  ## Parses an identifier and returns it or an empty string in
+  ## case of an error.
+  runnableExamples:
+    doAssert parseIdent("Hello World", 0) == "Hello"
+    doAssert parseIdent("Hello World", 1) == "ello"
+    doAssert parseIdent("Hello World", 5) == ""
+    doAssert parseIdent("Hello World", 6) == "World"
+  result = ""
+  var i = 0
+  if i < s.len and s[i] in IdentStartChars:
+    inc(i)
+    while i < s.len and s[i] in IdentChars: inc(i)
+    result = substr(s.toOpenArray(0, i - 1))
 
-proc skipWhitespace*(s: string, start = 0): int {.inline.} =
-  ## skips the whitespace starting at ``s[start]``. Returns the number of
+proc parseChar*(s: openArray[char], c: var char): int =
+  ## Parses a single character, stores it in `c` and returns 1.
+  ## In case of error (if start >= s.len) it returns 0
+  ## and the value of `c` is unchanged.
+  runnableExamples:
+    var c: char
+    doAssert "nim".parseChar(c, 3) == 0
+    doAssert c == '\0'
+    doAssert "nim".parseChar(c, 0) == 1
+    doAssert c == 'n'
+  if s.len > 0:
+    c = s[0]
+    result = 1
+
+proc skipWhitespace*(s: openArray[char]): int {.inline.} =
+  ## Skips the whitespace starting at ``s[start]``. Returns the number of
   ## skipped characters.
-  while s[start+result] in Whitespace: inc(result)
+  runnableExamples:
+    doAssert skipWhitespace("Hello World", 0) == 0
+    doAssert skipWhitespace(" Hello World", 0) == 1
+    doAssert skipWhitespace("Hello World", 5) == 1
+    doAssert skipWhitespace("Hello  World", 5) == 2
+  result = 0
+  while result < s.len and s[result] in Whitespace: inc(result)
 
-proc skip*(s, token: string, start = 0): int =
-  while result < token.len and s[result+start] == token[result]: inc(result)
+proc skip*(s, token: openArray[char]): int {.inline.} =
+  ## Skips the `token` starting at ``s[start]``. Returns the length of `token`
+  ## or 0 if there was no `token` at ``s[start]``.
+  runnableExamples:
+    doAssert skip("2019-01-22", "2019", 0) == 4
+    doAssert skip("2019-01-22", "19", 0) == 0
+    doAssert skip("2019-01-22", "19", 2) == 2
+    doAssert skip("CAPlow", "CAP", 0) == 3
+    doAssert skip("CAPlow", "cap", 0) == 0
+  result = 0
+  while result < s.len and result < token.len and
+      s[result] == token[result]:
+    inc(result)
+  if result != token.len: result = 0
+
+proc skipIgnoreCase*(s, token: openArray[char]): int =
+  ## Same as `skip` but case is ignored for token matching.
+  runnableExamples:
+    doAssert skipIgnoreCase("CAPlow", "CAP", 0) == 3
+    doAssert skipIgnoreCase("CAPlow", "cap", 0) == 3
+  result = 0
+  while result < s.len and result < token.len and
+      toLower(s[result]) == toLower(token[result]): inc(result)
   if result != token.len: result = 0
-  
-proc skipIgnoreCase*(s, token: string, start = 0): int =
-  while result < token.len and
-      toLower(s[result+start]) == toLower(token[result]): inc(result)
-  if result != token.len: result = 0  
 
-{.push overflowChecks: on.}
-# this must be compiled with overflow checking turned on:
-proc rawParseInt(s: string, b: var biggestInt, start = 0): int =
+proc skipUntil*(s: openArray[char], until: set[char]): int {.inline.} =
+  ## Skips all characters until one char from the set `until` is found
+  ## or the end is reached.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipUntil("Hello World", {'W', 'e'}, 0) == 1
+    doAssert skipUntil("Hello World", {'W'}, 0) == 6
+    doAssert skipUntil("Hello World", {'W', 'd'}, 0) == 6
+  result = 0
+  while result < s.len and s[result] notin until: inc(result)
+
+proc skipUntil*(s: openArray[char], until: char): int {.inline.} =
+  ## Skips all characters until the char `until` is found
+  ## or the end is reached.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipUntil("Hello World", 'o', 0) == 4
+    doAssert skipUntil("Hello World", 'o', 4) == 0
+    doAssert skipUntil("Hello World", 'W', 0) == 6
+    doAssert skipUntil("Hello World", 'w', 0) == 11
+  result = 0
+  while result < s.len and s[result] != until: inc(result)
+
+proc skipWhile*(s: openArray[char], toSkip: set[char]): int {.inline.} =
+  ## Skips all characters while one char from the set `toSkip` is found.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipWhile("Hello World", {'H', 'e'}) == 2
+    doAssert skipWhile("Hello World", {'e'}) == 0
+    doAssert skipWhile("Hello World", {'W', 'o', 'r'}, 6) == 3
+  result = 0
+  while result < s.len and s[result] in toSkip: inc(result)
+
+proc fastSubstr(s: openArray[char]; token: var string; length: int) =
+  token.setLen length
+  for i in 0 ..< length: token[i] = s[i]
+
+proc parseUntil*(s: openArray[char], token: var string, until: set[char]): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of the characters notin `until`.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, {'W', 'o', 'r'}) == 4
+    doAssert myToken == "Hell"
+    doAssert parseUntil("Hello World", myToken, {'W', 'r'}) == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, {'W', 'r'}, 3) == 3
+    doAssert myToken == "lo "
+  var i = 0
+  while i < s.len and s[i] notin until: inc(i)
+  result = i
+  fastSubstr(s, token, result)
+  #token = substr(s, start, i-1)
+
+proc parseUntil*(s: openArray[char], token: var string, until: char): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of any character that is not the `until` character.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, 'W') == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, 'o') == 4
+    doAssert myToken == "Hell"
+    doAssert parseUntil("Hello World", myToken, 'o', 2) == 2
+    doAssert myToken == "ll"
+  var i = 0
+  while i < s.len and s[i] != until: inc(i)
+  result = i
+  fastSubstr(s, token, result)
+  #token = substr(s, start, i-1)
+
+proc parseUntil*(s: openArray[char], token: var string, until: string): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of any character that comes before the `until`  token.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, "Wor") == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, "Wor", 2) == 4
+    doAssert myToken == "llo "
+  when (NimMajor, NimMinor) <= (1, 0):
+    if until.len == 0:
+      token.setLen(0)
+      return 0
+  var i = 0
+  while i < s.len:
+    if until.len > 0 and s[i] == until[0]:
+      var u = 1
+      while i+u < s.len and u < until.len and s[i+u] == until[u]:
+        inc u
+      if u >= until.len: break
+    inc(i)
+  result = i
+  fastSubstr(s, token, result)
+  #token = substr(s, start, i-1)
+
+proc parseWhile*(s: openArray[char], token: var string, validChars: set[char]): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of the characters in `validChars`.
+  runnableExamples:
+    var myToken: string
+    doAssert parseWhile("Hello World", myToken, {'W', 'o', 'r'}, 0) == 0
+    doAssert myToken.len() == 0
+    doAssert parseWhile("Hello World", myToken, {'W', 'o', 'r'}, 6) == 3
+    doAssert myToken == "Wor"
+  var i = 0
+  while i < s.len and s[i] in validChars: inc(i)
+  result = i
+  fastSubstr(s, token, result)
+  #token = substr(s, start, i-1)
+
+proc captureBetween*(s: openArray[char], first: char, second = '\0'): string =
+  ## Finds the first occurrence of ``first``, then returns everything from there
+  ## up to ``second`` (if ``second`` is '\0', then ``first`` is used).
+  runnableExamples:
+    doAssert captureBetween("Hello World", 'e') == "llo World"
+    doAssert captureBetween("Hello World", 'e', 'r') == "llo Wo"
+    doAssert captureBetween("Hello World".toOpenArray(6, "Hello World".high), 'l') == "d"
+  var i = skipUntil(s, first) + 1
+  result = ""
+  discard parseUntil(s.toOpenArray(i, s.high), result, if second == '\0': first else: second)
+
+proc integerOutOfRangeError() {.noinline.} =
+  raise newException(ValueError, "Parsed integer outside of valid range")
+
+# See #6752
+when defined(js):
+  {.push overflowChecks: off.}
+
+proc rawParseInt(s: openArray[char], b: var BiggestInt): int =
   var
     sign: BiggestInt = -1
-    i = start
-  if s[i] == '+': inc(i)
-  elif s[i] == '-':
-    inc(i)
-    sign = 1
-  if s[i] in {'0'..'9'}:
+    i = 0
+  if i < s.len:
+    if s[i] == '+': inc(i)
+    elif s[i] == '-':
+      inc(i)
+      sign = 1
+  if i < s.len and s[i] in {'0'..'9'}:
     b = 0
-    while s[i] in {'0'..'9'}:
-      b = b * 10 - (ord(s[i]) - ord('0'))
+    while i < s.len and s[i] in {'0'..'9'}:
+      let c = ord(s[i]) - ord('0')
+      if b >= (low(BiggestInt) + c) div 10:
+        b = b * 10 - c
+      else:
+        integerOutOfRangeError()
       inc(i)
-      while s[i] == '_': inc(i) # underscores are allowed and ignored
-    b = b * sign
-    result = i - start
-{.pop.} # overflowChecks
+      while i < s.len and s[i] == '_': inc(i) # underscores are allowed and ignored
+    if sign == -1 and b == low(BiggestInt):
+      integerOutOfRangeError()
+    else:
+      b = b * sign
+      result = i
+
+when defined(js):
+  {.pop.} # overflowChecks: off
 
-proc parseBiggestInt*(s: string, number: var biggestInt, start = 0): int =
-  ## parses an integer starting at `start` and stores the value into `number`.
+proc parseBiggestInt*(s: openArray[char], number: var BiggestInt): int {.
+  rtl, extern: "npuParseBiggestInt", noSideEffect, raises: [ValueError].} =
+  ## Parses an integer and stores the value into `number`.
   ## Result is the number of processed chars or 0 if there is no integer.
-  ## `EOverflow` is raised if an overflow occurs.
-  result = rawParseInt(s, number, start)
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: BiggestInt
+    doAssert parseBiggestInt("9223372036854775807", res) == 19
+    doAssert res == 9223372036854775807
+    doAssert parseBiggestInt("-2024_05_09", res) == 11
+    doAssert res == -20240509
+  var res = BiggestInt(0)
+  # use 'res' for exception safety (don't write to 'number' in case of an
+  # overflow exception):
+  result = rawParseInt(s, res)
+  if result != 0:
+    number = res
 
-proc parseInt*(s: string, number: var int, start = 0): int =
-  ## parses an integer starting at `start` and stores the value into `number`.
+proc parseInt*(s: openArray[char], number: var int): int {.
+  rtl, extern: "npuParseInt", noSideEffect, raises: [ValueError].} =
+  ## Parses an integer and stores the value into `number`.
   ## Result is the number of processed chars or 0 if there is no integer.
-  ## `EOverflow` is raised if an overflow occurs.
-  var res: biggestInt
-  result = parseBiggestInt(s, res, start)
-  if (sizeof(int) <= 4) and
-      ((res < low(int)) or (res > high(int))):
-    raise newException(EOverflow, "overflow")
-  else:
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: int
+    doAssert parseInt("-2024_05_02", res) == 11
+    doAssert res == -20240502
+  var res = BiggestInt(0)
+  result = parseBiggestInt(s, res)
+  when sizeof(int) <= 4:
+    if res < low(int) or res > high(int):
+      integerOutOfRangeError()
+  if result != 0:
     number = int(res)
 
-proc parseBiggestFloat*(s: string, number: var biggestFloat, start = 0): int =
-  ## parses a float starting at `start` and stores the value into `number`.
-  ## Result is the number of processed chars or 0 if there occured a parsing
-  ## error.
-  var
-    esign = 1.0
-    sign = 1.0
-    i = start
-    exponent: int
-    flags: int
-  number = 0.0
-  if s[i] == '+': inc(i)
-  elif s[i] == '-':
-    sign = -1.0
-    inc(i)
-  if s[i] == 'N' or s[i] == 'n':
-    if s[i+1] == 'A' or s[i+1] == 'a':
-      if s[i+2] == 'N' or s[i+2] == 'n':
-        if s[i+3] notin IdentChars:
-          number = NaN
-          return i+3 - start
-    return 0
-  if s[i] == 'I' or s[i] == 'i':
-    if s[i+1] == 'N' or s[i+1] == 'n':
-      if s[i+2] == 'F' or s[i+2] == 'f':
-        if s[i+3] notin IdentChars: 
-          number = Inf*sign
-          return i+3 - start
-    return 0
-  while s[i] in {'0'..'9'}:
-    # Read integer part
-    flags = flags or 1
-    number = number * 10.0 + toFloat(ord(s[i]) - ord('0'))
-    inc(i)
-    while s[i] == '_': inc(i)
-  # Decimal?
-  if s[i] == '.':
-    var hd = 1.0
-    inc(i)
-    while s[i] in {'0'..'9'}:
-      # Read fractional part
-      flags = flags or 2
-      number = number * 10.0 + toFloat(ord(s[i]) - ord('0'))
-      hd = hd * 10.0
-      inc(i)
-      while s[i] == '_': inc(i)
-    number = number / hd # this complicated way preserves precision
-  # Again, read integer and fractional part
-  if flags == 0: return 0
-  # Exponent?
-  if s[i] in {'e', 'E'}:
-    inc(i)
-    if s[i] == '+':
-      inc(i)
-    elif s[i] == '-':
-      esign = -1.0
+proc parseSaturatedNatural*(s: openArray[char], b: var int): int {.
+    raises: [].} =
+  ## Parses a natural number into ``b``. This cannot raise an overflow
+  ## error. ``high(int)`` is returned for an overflow.
+  ## The number of processed character is returned.
+  ## This is usually what you really want to use instead of `parseInt`:idx:.
+  runnableExamples:
+    var res = 0
+    discard parseSaturatedNatural("848", res)
+    doAssert res == 848
+  var i = 0
+  if i < s.len and s[i] == '+': inc(i)
+  if i < s.len and s[i] in {'0'..'9'}:
+    b = 0
+    while i < s.len and s[i] in {'0'..'9'}:
+      let c = ord(s[i]) - ord('0')
+      if b <= (high(int) - c) div 10:
+        b = b * 10 + c
+      else:
+        b = high(int)
       inc(i)
-    if s[i] notin {'0'..'9'}:
-      return 0
-    while s[i] in {'0'..'9'}:
-      exponent = exponent * 10 + ord(s[i]) - ord('0')
+      while i < s.len and s[i] == '_': inc(i) # underscores are allowed and ignored
+    result = i
+
+proc rawParseUInt(s: openArray[char], b: var BiggestUInt): int =
+  var
+    res = 0.BiggestUInt
+    prev = 0.BiggestUInt
+    i = 0
+  if i < s.len - 1 and s[i] == '-' and s[i + 1] in {'0'..'9'}:
+    integerOutOfRangeError()
+  if i < s.len and s[i] == '+': inc(i) # Allow
+  if i < s.len and s[i] in {'0'..'9'}:
+    b = 0
+    while i < s.len and s[i] in {'0'..'9'}:
+      prev = res
+      res = res * 10 + (ord(s[i]) - ord('0')).BiggestUInt
+      if prev > res:
+        integerOutOfRangeError()
       inc(i)
-      while s[i] == '_': inc(i)
-  # Calculate Exponent
-  var hd = 1.0
-  for j in 1..exponent: hd = hd * 10.0
-  if esign > 0.0: number = number * hd
-  else:           number = number / hd
-  # evaluate sign
-  number = number * sign
-  result = i - start
-
-proc parseFloat*(s: string, number: var float, start = 0): int =
-  ## parses a float starting at `start` and stores the value into `number`.
-  ## Result is the number of processed chars or 0 if there occured a parsing
+      while i < s.len and s[i] == '_': inc(i) # underscores are allowed and ignored
+    b = res
+    result = i
+
+proc parseBiggestUInt*(s: openArray[char], number: var BiggestUInt): int {.
+  rtl, extern: "npuParseBiggestUInt", noSideEffect, raises: [ValueError].} =
+  ## Parses an unsigned integer and stores the value
+  ## into `number`.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: BiggestUInt
+    doAssert parseBiggestUInt("12", res, 0) == 2
+    doAssert res == 12
+    doAssert parseBiggestUInt("1111111111111111111", res, 0) == 19
+    doAssert res == 1111111111111111111'u64
+  var res = BiggestUInt(0)
+  # use 'res' for exception safety (don't write to 'number' in case of an
+  # overflow exception):
+  result = rawParseUInt(s, res)
+  if result != 0:
+    number = res
+
+proc parseUInt*(s: openArray[char], number: var uint): int {.
+  rtl, extern: "npuParseUInt", noSideEffect, raises: [ValueError].} =
+  ## Parses an unsigned integer and stores the value
+  ## into `number`.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: uint
+    doAssert parseUInt("3450", res) == 4
+    doAssert res == 3450
+    doAssert parseUInt("3450", res, 2) == 2
+    doAssert res == 50
+  var res = BiggestUInt(0)
+  result = parseBiggestUInt(s, res)
+  when sizeof(BiggestUInt) > sizeof(uint) and sizeof(uint) <= 4:
+    if res > 0xFFFF_FFFF'u64:
+      integerOutOfRangeError()
+  if result != 0:
+    number = uint(res)
+
+proc parseBiggestFloat*(s: openArray[char], number: var BiggestFloat): int {.
+  magic: "ParseBiggestFloat", importc: "nimParseBiggestFloat", noSideEffect.}
+  ## Parses a float and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if a parsing error
+  ## occurred.
+
+proc parseFloat*(s: openArray[char], number: var float): int {.
+  rtl, extern: "npuParseFloat", noSideEffect.} =
+  ## Parses a float and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if there occurred a parsing
   ## error.
-  var bf: biggestFloat
-  result = parseBiggestFloat(s, bf, start)
-  number = bf
-  
+  runnableExamples:
+    var res: float
+    doAssert parseFloat("32", res, 0) == 2
+    doAssert res == 32.0
+    doAssert parseFloat("32.57", res, 0) == 5
+    doAssert res == 32.57
+    doAssert parseFloat("32.57", res, 3) == 2
+    doAssert res == 57.00
+  var bf = BiggestFloat(0.0)
+  result = parseBiggestFloat(s, bf)
+  if result != 0:
+    number = bf
+
+func toLowerAscii(c: char): char =
+  if c in {'A'..'Z'}: char(uint8(c) xor 0b0010_0000'u8) else: c
+
+func parseSize*(s: openArray[char], size: var int64, alwaysBin=false): int =
+  ## Parse a size qualified by binary or metric units into `size`.  This format
+  ## is often called "human readable".  Result is the number of processed chars
+  ## or 0 on parse errors and size is rounded to the nearest integer.  Trailing
+  ## garbage like "/s" in "1k/s" is allowed and detected by `result < s.len`.
+  ##
+  ## To simplify use, following non-rare wild conventions, and since fractional
+  ## data like milli-bytes is so rare, unit matching is case-insensitive but for
+  ## the 'i' distinguishing binary-metric from metric (which cannot be 'I').
+  ##
+  ## An optional trailing 'B|b' is ignored but processed.  I.e., you must still
+  ## know if units are bytes | bits or infer this fact via the case of s[^1] (if
+  ## users can even be relied upon to use 'B' for byte and 'b' for bit or have
+  ## that be s[^1]).
+  ##
+  ## If `alwaysBin==true` then scales are always binary-metric, but e.g. "KiB"
+  ## is still accepted for clarity.  If the value would exceed the range of
+  ## `int64`, `size` saturates to `int64.high`.  Supported metric prefix chars
+  ## include k, m, g, t, p, e, z, y (but z & y saturate unless the number is a
+  ## small fraction).
+  ##
+  ## **See also:**
+  ## * https://en.wikipedia.org/wiki/Binary_prefix
+  ## * `formatSize module<strutils.html>`_ for formatting
+  runnableExamples:
+    var res: int64  # caller must still know if 'b' refers to bytes|bits
+    doAssert parseSize("10.5 MB", res) == 7
+    doAssert res == 10_500_000  # decimal metric Mega prefix
+    doAssert parseSize("64 mib", res) == 6
+    doAssert res == 67108864    # 64 shl 20
+    doAssert parseSize("1G/h", res, true) == 2 # '/' stops parse
+    doAssert res == 1073741824  # 1 shl 30, forced binary metric
+  const prefix = "b" & "kmgtpezy"       # byte|bit & lowCase metric-ish prefixes
+  const scaleM = [1.0, 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24] # 10^(3*idx)
+  const scaleB = [1.0, 1024, 1048576, 1073741824, 1099511627776.0,  # 2^(10*idx)
+                  1125899906842624.0, 1152921504606846976.0,        # ldexp?
+                  1.180591620717411303424e21, 1.208925819614629174706176e24]
+  var number: float
+  var scale = 1.0
+  result = parseFloat(s, number)
+  if number < 0:                        # While parseFloat accepts negatives ..
+    result = 0                          #.. we do not since sizes cannot be < 0
+  if result > 0:
+    let start = result                  # Save spot to maybe unwind white to EOS
+    while result < s.len and s[result] in Whitespace:
+      inc result
+    if result < s.len:                  # Illegal starting char => unity
+      if (let si = prefix.find(s[result].toLowerAscii); si >= 0):
+        inc result                      # Now parse the scale
+        scale = if alwaysBin: scaleB[si] else: scaleM[si]
+        if result < s.len and s[result] == 'i':
+          scale = scaleB[si]            # Switch from default to binary-metric
+          inc result
+        if result < s.len and s[result].toLowerAscii == 'b':
+          inc result                    # Skip optional '[bB]'
+    else:                               # Unwind result advancement when there..
+      result = start                    #..is no unit to the end of `s`.
+    var sizeF = number * scale + 0.5    # Saturate to int64.high when too big
+    size = if sizeF > 9223372036854774784.0: int64.high else: sizeF.int64
+# Above constant=2^63-1024 avoids C UB; github.com/nim-lang/Nim/issues/20102 or
+# stackoverflow.com/questions/20923556/math-pow2-63-1-math-pow2-63-512-is-true
+
+type
+  InterpolatedKind* = enum ## Describes for `interpolatedFragments`
+                           ## which part of the interpolated string is
+                           ## yielded; for example in "str$$$var${expr}"
+    ikStr,                 ## ``str`` part of the interpolated string
+    ikDollar,              ## escaped ``$`` part of the interpolated string
+    ikVar,                 ## ``var`` part of the interpolated string
+    ikExpr                 ## ``expr`` part of the interpolated string
+
+iterator interpolatedFragments*(s: openArray[char]): tuple[kind: InterpolatedKind,
+  value: string] =
+  ## Tokenizes the string `s` into substrings for interpolation purposes.
+  ##
+  runnableExamples:
+    var outp: seq[tuple[kind: InterpolatedKind, value: string]]
+    for k, v in interpolatedFragments("  $this is ${an  example}  $$"):
+      outp.add (k, v)
+    doAssert outp == @[(ikStr, "  "),
+                       (ikVar, "this"),
+                       (ikStr, " is "),
+                       (ikExpr, "an  example"),
+                       (ikStr, "  "),
+                       (ikDollar, "$")]
+
+  var i = 0
+  var kind: InterpolatedKind
+  while true:
+    var j = i
+    if j < s.len and s[j] == '$':
+      if j+1 < s.len and s[j+1] == '{':
+        inc j, 2
+        var nesting = 0
+        block curlies:
+          while j < s.len:
+            case s[j]
+            of '{': inc nesting
+            of '}':
+              if nesting == 0:
+                inc j
+                break curlies
+              dec nesting
+            else: discard
+            inc j
+          raise newException(ValueError,
+            "Expected closing '}': " & substr(s.toOpenArray(i, s.high)))
+        inc i, 2 # skip ${
+        kind = ikExpr
+      elif j+1 < s.len and s[j+1] in IdentStartChars:
+        inc j, 2
+        while j < s.len and s[j] in IdentChars: inc(j)
+        inc i # skip $
+        kind = ikVar
+      elif j+1 < s.len and s[j+1] == '$':
+        inc j, 2
+        inc i # skip $
+        kind = ikDollar
+      else:
+        raise newException(ValueError,
+          "Unable to parse a variable name at " & substr(s.toOpenArray(i, s.high)))
+    else:
+      while j < s.len and s[j] != '$': inc j
+      kind = ikStr
+    if j > i:
+      # do not copy the trailing } for ikExpr:
+      yield (kind, substr(s.toOpenArray(i, j-1-ord(kind == ikExpr))))
+    else:
+      break
+    i = j
+
 {.pop.}
+
+
+proc parseBin*[T: SomeInteger](s: string, number: var T, start = 0,
+    maxLen = 0): int {.noSideEffect.} =
+  ## Parses a binary number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-bin character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseBin("0100_1110_0110_1001_1110_1101", num) == 29
+    doAssert num == 5138925
+    doAssert parseBin("3", num) == 0
+    var num8: int8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8) == 32
+    doAssert num8 == 0b1110_1101'i8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8, 3, 9) == 9
+    doAssert num8 == 0b0100_1110'i8
+    var num8u: uint8
+    doAssert parseBin("0b_0100_1110_0110_1001_1110_1101", num8u) == 32
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseBin("0100111001101001111011010100111001101001", num64) == 40
+    doAssert num64 == 336784608873
+  parseBin(s.toOpenArray(start, s.high), number, maxLen)
+
+proc parseOct*[T: SomeInteger](s: string, number: var T, start = 0,
+    maxLen = 0): int {.noSideEffect.} =
+  ## Parses an octal number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-oct character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseOct("0o23464755", num) == 10
+    doAssert num == 5138925
+    doAssert parseOct("8", num) == 0
+    var num8: int8
+    doAssert parseOct("0o_1464_755", num8) == 11
+    doAssert num8 == -19
+    doAssert parseOct("0o_1464_755", num8, 3, 3) == 3
+    doAssert num8 == 102
+    var num8u: uint8
+    doAssert parseOct("1464755", num8u) == 7
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseOct("2346475523464755", num64) == 16
+    doAssert num64 == 86216859871725
+  parseOct(s.toOpenArray(start, s.high), number, maxLen)
+
+proc parseHex*[T: SomeInteger](s: string, number: var T, start = 0,
+    maxLen = 0): int {.noSideEffect.} =
+  ## Parses a hexadecimal number and stores its value in ``number``.
+  ##
+  ## Returns the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of ``number`` is not changed.
+  ##
+  ## If ``maxLen == 0``, the parsing continues until the first non-hex character
+  ## or to the end of the string. Otherwise, no more than ``maxLen`` characters
+  ## are parsed starting from the ``start`` position.
+  ##
+  ## It does not check for overflow. If the value represented by the string is
+  ## too big to fit into ``number``, only the value of last fitting characters
+  ## will be stored in ``number`` without producing an error.
+  runnableExamples:
+    var num: int
+    doAssert parseHex("4E_69_ED", num) == 8
+    doAssert num == 5138925
+    doAssert parseHex("X", num) == 0
+    doAssert parseHex("#ABC", num) == 4
+    var num8: int8
+    doAssert parseHex("0x_4E_69_ED", num8) == 11
+    doAssert num8 == 0xED'i8
+    doAssert parseHex("0x_4E_69_ED", num8, 3, 2) == 2
+    doAssert num8 == 0x4E'i8
+    var num8u: uint8
+    doAssert parseHex("0x_4E_69_ED", num8u) == 11
+    doAssert num8u == 237
+    var num64: int64
+    doAssert parseHex("4E69ED4E69ED", num64) == 12
+    doAssert num64 == 86216859871725
+  parseHex(s.toOpenArray(start, s.high), number, maxLen)
+
+proc parseIdent*(s: string, ident: var string, start = 0): int =
+  ## Parses an identifier and stores it in ``ident``. Returns
+  ## the number of the parsed characters or 0 in case of an error.
+  ## If error, the value of `ident` is not changed.
+  runnableExamples:
+    var res: string
+    doAssert parseIdent("Hello World", res, 0) == 5
+    doAssert res == "Hello"
+    doAssert parseIdent("Hello World", res, 1) == 4
+    doAssert res == "ello"
+    doAssert parseIdent("Hello World", res, 6) == 5
+    doAssert res == "World"
+  parseIdent(s.toOpenArray(start, s.high), ident)
+
+proc parseIdent*(s: string, start = 0): string =
+  ## Parses an identifier and returns it or an empty string in
+  ## case of an error.
+  runnableExamples:
+    doAssert parseIdent("Hello World", 0) == "Hello"
+    doAssert parseIdent("Hello World", 1) == "ello"
+    doAssert parseIdent("Hello World", 5) == ""
+    doAssert parseIdent("Hello World", 6) == "World"
+  parseIdent(s.toOpenArray(start, s.high))
+
+proc parseChar*(s: string, c: var char, start = 0): int =
+  ## Parses a single character, stores it in `c` and returns 1.
+  ## In case of error (if start >= s.len) it returns 0
+  ## and the value of `c` is unchanged.
+  runnableExamples:
+    var c: char
+    doAssert "nim".parseChar(c, 3) == 0
+    doAssert c == '\0'
+    doAssert "nim".parseChar(c, 0) == 1
+    doAssert c == 'n'
+  parseChar(s.toOpenArray(start, s.high), c)
+
+proc skipWhitespace*(s: string, start = 0): int {.inline.} =
+  ## Skips the whitespace starting at ``s[start]``. Returns the number of
+  ## skipped characters.
+  runnableExamples:
+    doAssert skipWhitespace("Hello World", 0) == 0
+    doAssert skipWhitespace(" Hello World", 0) == 1
+    doAssert skipWhitespace("Hello World", 5) == 1
+    doAssert skipWhitespace("Hello  World", 5) == 2
+  skipWhitespace(s.toOpenArray(start, s.high))
+
+proc skip*(s, token: string, start = 0): int {.inline.} =
+  ## Skips the `token` starting at ``s[start]``. Returns the length of `token`
+  ## or 0 if there was no `token` at ``s[start]``.
+  runnableExamples:
+    doAssert skip("2019-01-22", "2019", 0) == 4
+    doAssert skip("2019-01-22", "19", 0) == 0
+    doAssert skip("2019-01-22", "19", 2) == 2
+    doAssert skip("CAPlow", "CAP", 0) == 3
+    doAssert skip("CAPlow", "cap", 0) == 0
+  skip(s.toOpenArray(start, s.high), token)
+
+proc skipIgnoreCase*(s, token: string, start = 0): int =
+  ## Same as `skip` but case is ignored for token matching.
+  runnableExamples:
+    doAssert skipIgnoreCase("CAPlow", "CAP", 0) == 3
+    doAssert skipIgnoreCase("CAPlow", "cap", 0) == 3
+  skipIgnoreCase(s.toOpenArray(start, s.high), token)
+
+proc skipUntil*(s: string, until: set[char], start = 0): int {.inline.} =
+  ## Skips all characters until one char from the set `until` is found
+  ## or the end is reached.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipUntil("Hello World", {'W', 'e'}, 0) == 1
+    doAssert skipUntil("Hello World", {'W'}, 0) == 6
+    doAssert skipUntil("Hello World", {'W', 'd'}, 0) == 6
+  skipUntil(s.toOpenArray(start, s.high), until)
+
+proc skipUntil*(s: string, until: char, start = 0): int {.inline.} =
+  ## Skips all characters until the char `until` is found
+  ## or the end is reached.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipUntil("Hello World", 'o', 0) == 4
+    doAssert skipUntil("Hello World", 'o', 4) == 0
+    doAssert skipUntil("Hello World", 'W', 0) == 6
+    doAssert skipUntil("Hello World", 'w', 0) == 11
+  skipUntil(s.toOpenArray(start, s.high), until)
+
+proc skipWhile*(s: string, toSkip: set[char], start = 0): int {.inline.} =
+  ## Skips all characters while one char from the set `toSkip` is found.
+  ## Returns number of characters skipped.
+  runnableExamples:
+    doAssert skipWhile("Hello World", {'H', 'e'}) == 2
+    doAssert skipWhile("Hello World", {'e'}) == 0
+    doAssert skipWhile("Hello World", {'W', 'o', 'r'}, 6) == 3
+  skipWhile(s.toOpenArray(start, s.high), toSkip)
+
+proc parseUntil*(s: string, token: var string, until: set[char],
+                 start = 0): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of the characters notin `until`.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, {'W', 'o', 'r'}) == 4
+    doAssert myToken == "Hell"
+    doAssert parseUntil("Hello World", myToken, {'W', 'r'}) == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, {'W', 'r'}, 3) == 3
+    doAssert myToken == "lo "
+  parseUntil(s.toOpenArray(start, s.high), token, until)
+
+proc parseUntil*(s: string, token: var string, until: char,
+                 start = 0): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of any character that is not the `until` character.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, 'W') == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, 'o') == 4
+    doAssert myToken == "Hell"
+    doAssert parseUntil("Hello World", myToken, 'o', 2) == 2
+    doAssert myToken == "ll"
+  parseUntil(s.toOpenArray(start, s.high), token, until)
+
+proc parseUntil*(s: string, token: var string, until: string,
+                 start = 0): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of any character that comes before the `until`  token.
+  runnableExamples:
+    var myToken: string
+    doAssert parseUntil("Hello World", myToken, "Wor") == 6
+    doAssert myToken == "Hello "
+    doAssert parseUntil("Hello World", myToken, "Wor", 2) == 4
+    doAssert myToken == "llo "
+  parseUntil(s.toOpenArray(start, s.high), token, until)
+
+proc parseWhile*(s: string, token: var string, validChars: set[char],
+                 start = 0): int {.inline.} =
+  ## Parses a token and stores it in ``token``. Returns
+  ## the number of the parsed characters or 0 in case of an error. A token
+  ## consists of the characters in `validChars`.
+  runnableExamples:
+    var myToken: string
+    doAssert parseWhile("Hello World", myToken, {'W', 'o', 'r'}, 0) == 0
+    doAssert myToken.len() == 0
+    doAssert parseWhile("Hello World", myToken, {'W', 'o', 'r'}, 6) == 3
+    doAssert myToken == "Wor"
+  parseWhile(s.toOpenArray(start, s.high), token, validChars)
+
+proc captureBetween*(s: string, first: char, second = '\0', start = 0): string =
+  ## Finds the first occurrence of ``first``, then returns everything from there
+  ## up to ``second`` (if ``second`` is '\0', then ``first`` is used).
+  runnableExamples:
+    doAssert captureBetween("Hello World", 'e') == "llo World"
+    doAssert captureBetween("Hello World", 'e', 'r') == "llo Wo"
+    doAssert captureBetween("Hello World", 'l', start = 6) == "d"
+  captureBetween(s.toOpenArray(start, s.high), first, second)
+
+proc parseBiggestInt*(s: string, number: var BiggestInt, start = 0): int {.noSideEffect, raises: [ValueError].} =
+  ## Parses an integer starting at `start` and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if there is no integer.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: BiggestInt
+    doAssert parseBiggestInt("9223372036854775807", res, 0) == 19
+    doAssert res == 9223372036854775807
+    doAssert parseBiggestInt("-2024_05_09", res) == 11
+    doAssert res == -20240509
+    doAssert parseBiggestInt("-2024_05_02", res, 7) == 4
+    doAssert res == 502
+  parseBiggestInt(s.toOpenArray(start, s.high), number)
+
+proc parseInt*(s: string, number: var int, start = 0): int {.noSideEffect, raises: [ValueError].} =
+  ## Parses an integer starting at `start` and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if there is no integer.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: int
+    doAssert parseInt("-2024_05_02", res) == 11
+    doAssert res == -20240502
+    doAssert parseInt("-2024_05_02", res, 7) == 4
+    doAssert res == 502
+  parseInt(s.toOpenArray(start, s.high), number)
+
+
+proc parseSaturatedNatural*(s: string, b: var int, start = 0): int {.
+    raises: [].} =
+  ## Parses a natural number into ``b``. This cannot raise an overflow
+  ## error. ``high(int)`` is returned for an overflow.
+  ## The number of processed character is returned.
+  ## This is usually what you really want to use instead of `parseInt`:idx:.
+  runnableExamples:
+    var res = 0
+    discard parseSaturatedNatural("848", res)
+    doAssert res == 848
+  parseSaturatedNatural(s.toOpenArray(start, s.high), b)
+
+
+proc parseBiggestUInt*(s: string, number: var BiggestUInt, start = 0): int {.noSideEffect, raises: [ValueError].} =
+  ## Parses an unsigned integer starting at `start` and stores the value
+  ## into `number`.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: BiggestUInt
+    doAssert parseBiggestUInt("12", res, 0) == 2
+    doAssert res == 12
+    doAssert parseBiggestUInt("1111111111111111111", res, 0) == 19
+    doAssert res == 1111111111111111111'u64
+  parseBiggestUInt(s.toOpenArray(start, s.high), number)
+
+proc parseUInt*(s: string, number: var uint, start = 0): int {.noSideEffect, raises: [ValueError].} =
+  ## Parses an unsigned integer starting at `start` and stores the value
+  ## into `number`.
+  ## `ValueError` is raised if the parsed integer is out of the valid range.
+  runnableExamples:
+    var res: uint
+    doAssert parseUInt("3450", res) == 4
+    doAssert res == 3450
+    doAssert parseUInt("3450", res, 2) == 2
+    doAssert res == 50
+  parseUInt(s.toOpenArray(start, s.high), number)
+
+proc parseBiggestFloat*(s: string, number: var BiggestFloat, start = 0): int {.noSideEffect.} =
+  ## Parses a float starting at `start` and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if a parsing error
+  ## occurred.
+  parseFloat(s.toOpenArray(start, s.high), number)
+
+proc parseFloat*(s: string, number: var float, start = 0): int {.noSideEffect.} =
+  ## Parses a float starting at `start` and stores the value into `number`.
+  ## Result is the number of processed chars or 0 if there occurred a parsing
+  ## error.
+  runnableExamples:
+    var res: float
+    doAssert parseFloat("32", res, 0) == 2
+    doAssert res == 32.0
+    doAssert parseFloat("32.57", res, 0) == 5
+    doAssert res == 32.57
+    doAssert parseFloat("32.57", res, 3) == 2
+    doAssert res == 57.00
+  parseFloat(s.toOpenArray(start, s.high), number)
+
+iterator interpolatedFragments*(s: string): tuple[kind: InterpolatedKind,
+  value: string] =
+  ## Tokenizes the string `s` into substrings for interpolation purposes.
+  ##
+  runnableExamples:
+    var outp: seq[tuple[kind: InterpolatedKind, value: string]]
+    for k, v in interpolatedFragments("  $this is ${an  example}  $$"):
+      outp.add (k, v)
+    doAssert outp == @[(ikStr, "  "),
+                       (ikVar, "this"),
+                       (ikStr, " is "),
+                       (ikExpr, "an  example"),
+                       (ikStr, "  "),
+                       (ikDollar, "$")]
+  for x in s.toOa.interpolatedFragments:
+    yield x
+
diff --git a/lib/pure/parsexml.nim b/lib/pure/parsexml.nim
index 598ae6c68..c760799a2 100755..100644
--- a/lib/pure/parsexml.nim
+++ b/lib/pure/parsexml.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -8,98 +8,203 @@
 #
 
 ## This module implements a simple high performance `XML`:idx: / `HTML`:idx:
-## parser. 
+## parser.
 ## The only encoding that is supported is UTF-8. The parser has been designed
-## to be somewhat error correcting, so that even most "wild HTML" found on the 
+## to be somewhat error correcting, so that even most "wild HTML" found on the
 ## web can be parsed with it. **Note:** This parser does not check that each
-## ``<tag>`` has a corresponding ``</tag>``! These checks have do be 
-## implemented by the client code for various reasons: 
+## ``<tag>`` has a corresponding ``</tag>``! These checks have do be
+## implemented by the client code for various reasons:
 ##
 ## * Old HTML contains tags that have no end tag: ``<br>`` for example.
 ## * HTML tags are case insensitive, XML tags are case sensitive. Since this
 ##   library can parse both, only the client knows which comparison is to be
 ##   used.
 ## * Thus the checks would have been very difficult to implement properly with
-##   little benefit, especially since they are simple to implement in the 
+##   little benefit, especially since they are simple to implement in the
 ##   client. The client should use the `errorMsgExpected` proc to generate
 ##   a nice error message that fits the other error messages this library
 ##   creates.
 ##
 ##
-## Example 1: Retrieve HTML title
-## ==============================
-##
-## The file ``examples/htmltitle.nim`` demonstrates how to use the 
-## XML parser to accomplish a simple task: To determine the title of an HTML
-## document.
-##
-## .. code-block:: nimrod
-##     :file: examples/htmltitle.nim
-##
-##
-## Example 2: Retrieve all HTML links
-## ==================================
-##
-## The file ``examples/htmlrefs.nim`` demonstrates how to use the 
-## XML parser to accomplish another simple task: To determine all the links 
-## an HTML document contains.
-##
-## .. code-block:: nimrod
-##     :file: examples/htmlrefs.nim
-##
 
-import 
-  hashes, strutils, lexbase, streams, unicode
+##[
+
+Example 1: Retrieve HTML title
+==============================
+
+The file ``examples/htmltitle.nim`` demonstrates how to use the
+XML parser to accomplish a simple task: To determine the title of an HTML
+document.
+
+  ```nim
+  # Example program to show the parsexml module
+  # This program reads an HTML file and writes its title to stdout.
+  # Errors and whitespace are ignored.
+
+  import std/[os, streams, parsexml, strutils]
+
+  if paramCount() < 1:
+    quit("Usage: htmltitle filename[.html]")
+
+  var filename = addFileExt(paramStr(1), "html")
+  var s = newFileStream(filename, fmRead)
+  if s == nil: quit("cannot open the file " & filename)
+  var x: XmlParser
+  open(x, s, filename)
+  while true:
+    x.next()
+    case x.kind
+    of xmlElementStart:
+      if cmpIgnoreCase(x.elementName, "title") == 0:
+        var title = ""
+        x.next()  # skip "<title>"
+        while x.kind == xmlCharData:
+          title.add(x.charData)
+          x.next()
+        if x.kind == xmlElementEnd and cmpIgnoreCase(x.elementName, "title") == 0:
+          echo("Title: " & title)
+          quit(0) # Success!
+        else:
+          echo(x.errorMsgExpected("/title"))
+
+    of xmlEof: break # end of file reached
+    else: discard # ignore other events
+
+  x.close()
+  quit("Could not determine title!")
+  ```
+
+]##
+
+##[
+
+Example 2: Retrieve all HTML links
+==================================
+
+The file ``examples/htmlrefs.nim`` demonstrates how to use the
+XML parser to accomplish another simple task: To determine all the links
+an HTML document contains.
+
+  ```nim
+  # Example program to show the new parsexml module
+  # This program reads an HTML file and writes all its used links to stdout.
+  # Errors and whitespace are ignored.
+
+  import std/[os, streams, parsexml, strutils]
+
+  proc `=?=` (a, b: string): bool =
+    # little trick: define our own comparator that ignores case
+    return cmpIgnoreCase(a, b) == 0
+
+  if paramCount() < 1:
+    quit("Usage: htmlrefs filename[.html]")
+
+  var links = 0 # count the number of links
+  var filename = addFileExt(paramStr(1), "html")
+  var s = newFileStream(filename, fmRead)
+  if s == nil: quit("cannot open the file " & filename)
+  var x: XmlParser
+  open(x, s, filename)
+  next(x) # get first event
+  block mainLoop:
+    while true:
+      case x.kind
+      of xmlElementOpen:
+        # the <a href = "xyz"> tag we are interested in always has an attribute,
+        # thus we search for ``xmlElementOpen`` and not for ``xmlElementStart``
+        if x.elementName =?= "a":
+          x.next()
+          if x.kind == xmlAttribute:
+            if x.attrKey =?= "href":
+              var link = x.attrValue
+              inc(links)
+              # skip until we have an ``xmlElementClose`` event
+              while true:
+                x.next()
+                case x.kind
+                of xmlEof: break mainLoop
+                of xmlElementClose: break
+                else: discard
+              x.next() # skip ``xmlElementClose``
+              # now we have the description for the ``a`` element
+              var desc = ""
+              while x.kind == xmlCharData:
+                desc.add(x.charData)
+                x.next()
+              echo(desc & ": " & link)
+        else:
+          x.next()
+      of xmlEof: break # end of file reached
+      of xmlError:
+        echo(errorMsg(x))
+        x.next()
+      else: x.next() # skip other events
+
+  echo($links & " link(s) found!")
+  x.close()
+  ```
+
+]##
+
+import
+  std/[strutils, lexbase, streams, unicode]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
 
 # the parser treats ``<br />`` as ``<br></br>``
 
-##  xmlElementCloseEnd, ## ``/>`` 
-
-type 
-  TXmlEventKind* = enum ## enumation of all events that may occur when parsing
-    xmlError,           ## an error ocurred during parsing
-    xmlEof,             ## end of file reached
-    xmlCharData,        ## character data
-    xmlWhitespace,      ## whitespace has been parsed
-    xmlComment,         ## a comment has been parsed
-    xmlPI,              ## processing instruction (``<?name something ?>``)
-    xmlElementStart,    ## ``<elem>``
-    xmlElementEnd,      ## ``</elem>``
-    xmlElementOpen,     ## ``<elem 
-    xmlAttribute,       ## ``key = "value"`` pair
-    xmlElementClose,    ## ``>`` 
-    xmlCData,           ## ``<![CDATA[`` ... data ... ``]]>``
-    xmlEntity,          ## &entity;
-    xmlSpecial          ## ``<! ... data ... >``
-    
-  TXmlError* = enum          ## enumeration that lists all errors that can occur
-    errNone,                 ## no error
-    errEndOfCDataExpected,   ## ``]]>`` expected
-    errNameExpected,         ## name expected
-    errSemicolonExpected,    ## ``;`` expected
-    errQmGtExpected,         ## ``?>`` expected
-    errGtExpected,           ## ``>`` expected
-    errEqExpected,           ## ``=`` expected
-    errQuoteExpected,        ## ``"`` or ``'`` expected
-    errEndOfCommentExpected  ## ``-->`` expected
-    
-  TParserState = enum 
+#  xmlElementCloseEnd, ## ``/>``
+
+type
+  XmlEventKind* = enum ## enumeration of all events that may occur when parsing
+    xmlError,          ## an error occurred during parsing
+    xmlEof,            ## end of file reached
+    xmlCharData,       ## character data
+    xmlWhitespace,     ## whitespace has been parsed
+    xmlComment,        ## a comment has been parsed
+    xmlPI,             ## processing instruction (``<?name something ?>``)
+    xmlElementStart,   ## ``<elem>``
+    xmlElementEnd,     ## ``</elem>``
+    xmlElementOpen,    ## ``<elem
+    xmlAttribute,      ## ``key = "value"`` pair
+    xmlElementClose,   ## ``>``
+    xmlCData,          ## ``<![CDATA[`` ... data ... ``]]>``
+    xmlEntity,         ## &entity;
+    xmlSpecial         ## ``<! ... data ... >``
+
+  XmlErrorKind* = enum        ## enumeration that lists all errors that can occur
+    errNone,                  ## no error
+    errEndOfCDataExpected,    ## ``]]>`` expected
+    errNameExpected,          ## name expected
+    errSemicolonExpected,     ## ``;`` expected
+    errQmGtExpected,          ## ``?>`` expected
+    errGtExpected,            ## ``>`` expected
+    errEqExpected,            ## ``=`` expected
+    errQuoteExpected,         ## ``"`` or ``'`` expected
+    errEndOfCommentExpected   ## ``-->`` expected
+    errAttributeValueExpected ## non-empty attribute value expected
+
+  ParserState = enum
     stateStart, stateNormal, stateAttr, stateEmptyElementTag, stateError
 
-  TXmlParseOption* = enum  ## options for the XML parser
-    reportWhitespace,      ## report whitespace
-    reportComments         ## report comments
+  XmlParseOption* = enum ## options for the XML parser
+    reportWhitespace,    ## report whitespace
+    reportComments       ## report comments
+    allowUnquotedAttribs ## allow unquoted attribute values (for HTML)
+    allowEmptyAttribs    ## allow empty attributes (without explicit value)
 
-  TXmlParser* = object of TBaseLexer ## the parser object.
+  XmlParser* = object of BaseLexer ## the parser object.
     a, b, c: string
-    kind: TXmlEventKind
-    err: TXmlError
-    state: TParserState
+    kind: XmlEventKind
+    err: XmlErrorKind
+    state: ParserState
+    cIsEmpty: bool
     filename: string
-    options: set[TXmlParseOption]
- 
+    options: set[XmlParseOption]
+
 const
-  errorMessages: array [TXmlError, string] = [
+  errorMessages: array[XmlErrorKind, string] = [
     "no error",
     "']]>' expected",
     "name expected",
@@ -108,177 +213,208 @@ const
     "'>' expected",
     "'=' expected",
     "'\"' or \"'\" expected",
-    "'-->' expected"
+    "'-->' expected",
+    "attribute value expected"
   ]
 
-proc open*(my: var TXmlParser, input: PStream, filename: string,
-           options: set[TXmlParseOption] = {}) =
+proc open*(my: var XmlParser, input: Stream, filename: string,
+           options: set[XmlParseOption] = {}) =
   ## initializes the parser with an input stream. `Filename` is only used
   ## for nice error messages. The parser's behaviour can be controlled by
   ## the `options` parameter: If `options` contains ``reportWhitespace``
   ## a whitespace token is reported as an ``xmlWhitespace`` event.
   ## If `options` contains ``reportComments`` a comment token is reported as an
-  ## ``xmlComment`` event. 
-  lexbase.open(my, input)
+  ## ``xmlComment`` event.
+  lexbase.open(my, input, 8192, {'\c', '\L', '/'})
   my.filename = filename
   my.state = stateStart
   my.kind = xmlError
   my.a = ""
   my.b = ""
+  my.c = ""
+  my.cIsEmpty = true
   my.options = options
-  
-proc close*(my: var TXmlParser) {.inline.} = 
+
+proc close*(my: var XmlParser) {.inline.} =
   ## closes the parser `my` and its associated input stream.
   lexbase.close(my)
 
-proc charData*(my: TXmlParser): string {.inline.} = 
-  ## returns the character data for the events: ``xmlCharData``, 
-  ## ``xmlWhitespace``, ``xmlComment``, ``xmlCData``, ``xmlSpecial``
-  assert(my.kind in {xmlCharData, xmlWhitespace, xmlComment, xmlCData, 
-                     xmlSpecial})
-  return my.a
-
-proc kind*(my: TXmlParser): TXmlEventKind {.inline.} = 
+proc kind*(my: XmlParser): XmlEventKind {.inline.} =
   ## returns the current event type for the XML parser
   return my.kind
 
-proc elementName*(my: TXmlParser): string {.inline.} = 
-  ## returns the element name for the events: ``xmlElementStart``, 
+template charData*(my: XmlParser): string =
+  ## returns the character data for the events: ``xmlCharData``,
+  ## ``xmlWhitespace``, ``xmlComment``, ``xmlCData``, ``xmlSpecial``
+  ## Raises an assertion in debug mode if ``my.kind`` is not one
+  ## of those events. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
+  assert(my.kind in {xmlCharData, xmlWhitespace, xmlComment, xmlCData,
+                     xmlSpecial})
+  my.a
+
+template elementName*(my: XmlParser): string =
+  ## returns the element name for the events: ``xmlElementStart``,
   ## ``xmlElementEnd``, ``xmlElementOpen``
+  ## Raises an assertion in debug mode if ``my.kind`` is not one
+  ## of those events. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind in {xmlElementStart, xmlElementEnd, xmlElementOpen})
-  return my.a
+  my.a
 
-proc entityName*(my: TXmlParser): string {.inline.} = 
+template entityName*(my: XmlParser): string =
   ## returns the entity name for the event: ``xmlEntity``
+  ## Raises an assertion in debug mode if ``my.kind`` is not
+  ## ``xmlEntity``. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind == xmlEntity)
-  return my.a
-  
-proc attrKey*(my: TXmlParser): string {.inline.} = 
+  my.a
+
+template attrKey*(my: XmlParser): string =
   ## returns the attribute key for the event ``xmlAttribute``
+  ## Raises an assertion in debug mode if ``my.kind`` is not
+  ## ``xmlAttribute``. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind == xmlAttribute)
-  return my.a
-  
-proc attrValue*(my: TXmlParser): string {.inline.} = 
+  my.a
+
+template attrValue*(my: XmlParser): string =
   ## returns the attribute value for the event ``xmlAttribute``
+  ## Raises an assertion in debug mode if ``my.kind`` is not
+  ## ``xmlAttribute``. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind == xmlAttribute)
-  return my.b
+  my.b
 
-proc PIName*(my: TXmlParser): string {.inline.} = 
+template piName*(my: XmlParser): string =
   ## returns the processing instruction name for the event ``xmlPI``
+  ## Raises an assertion in debug mode if ``my.kind`` is not
+  ## ``xmlPI``. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind == xmlPI)
-  return my.a
+  my.a
 
-proc PIRest*(my: TXmlParser): string {.inline.} = 
+template piRest*(my: XmlParser): string =
   ## returns the rest of the processing instruction for the event ``xmlPI``
+  ## Raises an assertion in debug mode if ``my.kind`` is not
+  ## ``xmlPI``. In release mode, this will not trigger an error
+  ## but the value returned will not be valid.
   assert(my.kind == xmlPI)
-  return my.b
+  my.b
+
+proc rawData*(my: var XmlParser): lent string {.inline.} =
+  ## returns the underlying 'data' string by reference.
+  ## This is only used for speed hacks.
+  result = my.a
+
+proc rawData2*(my: var XmlParser): lent string {.inline.} =
+  ## returns the underlying second 'data' string by reference.
+  ## This is only used for speed hacks.
+  result = my.b
 
-proc getColumn*(my: TXmlParser): int {.inline.} = 
+proc getColumn*(my: XmlParser): int {.inline.} =
   ## get the current column the parser has arrived at.
-  result = getColNumber(my, my.bufPos)
+  result = getColNumber(my, my.bufpos)
 
-proc getLine*(my: TXmlParser): int {.inline.} = 
+proc getLine*(my: XmlParser): int {.inline.} =
   ## get the current line the parser has arrived at.
-  result = my.linenumber
+  result = my.lineNumber
 
-proc getFilename*(my: TXmlParser): string {.inline.} = 
+proc getFilename*(my: XmlParser): string {.inline.} =
   ## get the filename of the file that the parser processes.
   result = my.filename
-  
-proc errorMsg*(my: TXmlParser): string = 
+
+proc errorMsg*(my: XmlParser): string =
   ## returns a helpful error message for the event ``xmlError``
   assert(my.kind == xmlError)
   result = "$1($2, $3) Error: $4" % [
     my.filename, $getLine(my), $getColumn(my), errorMessages[my.err]]
 
-proc errorMsgExpected*(my: TXmlParser, tag: string): string = 
+proc errorMsgExpected*(my: XmlParser, tag: string): string =
   ## returns an error message "<tag> expected" in the same format as the
-  ## other error messages 
+  ## other error messages
   result = "$1($2, $3) Error: $4" % [
     my.filename, $getLine(my), $getColumn(my), "<$1> expected" % tag]
 
-proc errorMsg*(my: TXmlParser, msg: string): string = 
+proc errorMsg*(my: XmlParser, msg: string): string =
   ## returns an error message with text `msg` in the same format as the
-  ## other error messages 
+  ## other error messages
   result = "$1($2, $3) Error: $4" % [
     my.filename, $getLine(my), $getColumn(my), msg]
-    
-proc markError(my: var TXmlParser, kind: TXmlError) {.inline.} = 
+
+proc markError(my: var XmlParser, kind: XmlErrorKind) {.inline.} =
   my.err = kind
   my.state = stateError
 
-proc parseCDATA(my: var TXMLParser) = 
+proc parseCDATA(my: var XmlParser) =
   var pos = my.bufpos + len("<![CDATA[")
-  var buf = my.buf
   while true:
-    case buf[pos] 
+    case my.buf[pos]
     of ']':
-      if buf[pos+1] == ']' and buf[pos+2] == '>':
+      if my.buf[pos+1] == ']' and my.buf[pos+2] == '>':
         inc(pos, 3)
         break
       add(my.a, ']')
       inc(pos)
-    of '\0': 
+    of '\0':
       markError(my, errEndOfCDataExpected)
       break
-    of '\c': 
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
+    of '\c':
+      pos = lexbase.handleCR(my, pos)
       add(my.a, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       add(my.a, '\L')
+    of '/':
+      pos = lexbase.handleRefillChar(my, pos)
+      add(my.a, '/')
     else:
-      add(my.a, buf[pos])
-      inc(pos)    
+      add(my.a, my.buf[pos])
+      inc(pos)
   my.bufpos = pos # store back
-  my.kind = xmlCDATA
+  my.kind = xmlCData
 
-proc parseComment(my: var TXMLParser) = 
+proc parseComment(my: var XmlParser) =
   var pos = my.bufpos + len("<!--")
-  var buf = my.buf
   while true:
-    case buf[pos] 
+    case my.buf[pos]
     of '-':
-      if buf[pos+1] == '-' and buf[pos+2] == '>':
+      if my.buf[pos+1] == '-' and my.buf[pos+2] == '>':
         inc(pos, 3)
         break
       if my.options.contains(reportComments): add(my.a, '-')
       inc(pos)
-    of '\0': 
+    of '\0':
       markError(my, errEndOfCommentExpected)
       break
-    of '\c': 
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
+    of '\c':
+      pos = lexbase.handleCR(my, pos)
       if my.options.contains(reportComments): add(my.a, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       if my.options.contains(reportComments): add(my.a, '\L')
+    of '/':
+      pos = lexbase.handleRefillChar(my, pos)
+      if my.options.contains(reportComments): add(my.a, '/')
     else:
-      if my.options.contains(reportComments): add(my.a, buf[pos])
+      if my.options.contains(reportComments): add(my.a, my.buf[pos])
       inc(pos)
   my.bufpos = pos
   my.kind = xmlComment
 
-proc parseWhitespace(my: var TXmlParser, skip=False) = 
+proc parseWhitespace(my: var XmlParser, skip = false) =
   var pos = my.bufpos
-  var buf = my.buf
-  while true: 
-    case buf[pos]
-    of ' ', '\t': 
-      if not skip: add(my.a, buf[pos])
-      Inc(pos)
-    of '\c':  
+  while true:
+    case my.buf[pos]
+    of ' ', '\t':
+      if not skip: add(my.a, my.buf[pos])
+      inc(pos)
+    of '\c':
       # the specification says that CR-LF, CR are to be transformed to LF
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
+      pos = lexbase.handleCR(my, pos)
       if not skip: add(my.a, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       if not skip: add(my.a, '\L')
     else:
       break
@@ -288,114 +424,114 @@ const
   NameStartChar = {'A'..'Z', 'a'..'z', '_', ':', '\128'..'\255'}
   NameChar = {'A'..'Z', 'a'..'z', '0'..'9', '.', '-', '_', ':', '\128'..'\255'}
 
-proc parseName(my: var TXmlParser, dest: var string) = 
+proc parseName(my: var XmlParser, dest: var string) =
   var pos = my.bufpos
-  var buf = my.buf
-  if buf[pos] in nameStartChar: 
+  if my.buf[pos] in NameStartChar:
     while true:
-      add(dest, buf[pos])
+      add(dest, my.buf[pos])
       inc(pos)
-      if buf[pos] notin NameChar: break
+      if my.buf[pos] notin NameChar: break
     my.bufpos = pos
   else:
     markError(my, errNameExpected)
 
-proc parseEntity(my: var TXmlParser, dest: var string) = 
+proc parseEntity(my: var XmlParser, dest: var string) =
   var pos = my.bufpos+1
-  var buf = my.buf
   my.kind = xmlCharData
-  if buf[pos] == '#':
+  if my.buf[pos] == '#':
     var r: int
     inc(pos)
-    if buf[pos] == 'x': 
+    if my.buf[pos] == 'x':
       inc(pos)
       while true:
-        case buf[pos]
-        of '0'..'9': r = (r shl 4) or (ord(buf[pos]) - ord('0'))
-        of 'a'..'f': r = (r shl 4) or (ord(buf[pos]) - ord('a') + 10)
-        of 'A'..'F': r = (r shl 4) or (ord(buf[pos]) - ord('A') + 10)
+        case my.buf[pos]
+        of '0'..'9': r = (r shl 4) or (ord(my.buf[pos]) - ord('0'))
+        of 'a'..'f': r = (r shl 4) or (ord(my.buf[pos]) - ord('a') + 10)
+        of 'A'..'F': r = (r shl 4) or (ord(my.buf[pos]) - ord('A') + 10)
         else: break
         inc(pos)
     else:
-      while buf[pos] in {'0'..'9'}: 
-        r = r * 10 + (ord(buf[pos]) - ord('0'))
+      while my.buf[pos] in {'0'..'9'}:
+        r = r * 10 + (ord(my.buf[pos]) - ord('0'))
         inc(pos)
-    add(dest, toUTF8(TRune(r)))
-  elif buf[pos] == 'l' and buf[pos+1] == 't' and buf[pos+2] == ';':
+    add(dest, toUTF8(Rune(r)))
+  elif my.buf[pos] == 'l' and my.buf[pos+1] == 't' and my.buf[pos+2] == ';':
     add(dest, '<')
     inc(pos, 2)
-  elif buf[pos] == 'g' and buf[pos+1] == 't' and buf[pos+2] == ';':
+  elif my.buf[pos] == 'g' and my.buf[pos+1] == 't' and my.buf[pos+2] == ';':
     add(dest, '>')
     inc(pos, 2)
-  elif buf[pos] == 'a' and buf[pos+1] == 'm' and buf[pos+2] == 'p' and
-      buf[pos+3] == ';':
+  elif my.buf[pos] == 'a' and my.buf[pos+1] == 'm' and my.buf[pos+2] == 'p' and
+      my.buf[pos+3] == ';':
     add(dest, '&')
     inc(pos, 3)
-  elif buf[pos] == 'a' and buf[pos+1] == 'p' and buf[pos+2] == 'o' and 
-      buf[pos+3] == 's' and buf[pos+4] == ';':
+  elif my.buf[pos] == 'a' and my.buf[pos+1] == 'p' and my.buf[pos+2] == 'o' and
+      my.buf[pos+3] == 's' and my.buf[pos+4] == ';':
     add(dest, '\'')
     inc(pos, 4)
-  elif buf[pos] == 'q' and buf[pos+1] == 'u' and buf[pos+2] == 'o' and 
-      buf[pos+3] == 't' and buf[pos+4] == ';':
+  elif my.buf[pos] == 'q' and my.buf[pos+1] == 'u' and my.buf[pos+2] == 'o' and
+      my.buf[pos+3] == 't' and my.buf[pos+4] == ';':
     add(dest, '"')
     inc(pos, 4)
   else:
     my.bufpos = pos
-    parseName(my, dest)
+    var name = ""
+    parseName(my, name)
     pos = my.bufpos
-    if my.err != errNameExpected: 
+    if my.err != errNameExpected and my.buf[pos] == ';':
       my.kind = xmlEntity
     else:
       add(dest, '&')
-  if buf[pos] == ';': 
+    add(dest, name)
+  if my.buf[pos] == ';':
     inc(pos)
   else:
-    markError(my, errSemiColonExpected)
+    my.err = errSemicolonExpected
+    # do not overwrite 'my.state' here, it's a benign error
   my.bufpos = pos
 
-proc parsePI(my: var TXmlParser) = 
+proc parsePI(my: var XmlParser) =
   inc(my.bufpos, "<?".len)
   parseName(my, my.a)
   var pos = my.bufpos
-  var buf = my.buf
   setLen(my.b, 0)
-  while true: 
-    case buf[pos]
+  while true:
+    case my.buf[pos]
     of '\0':
       markError(my, errQmGtExpected)
       break
     of '?':
-      if buf[pos+1] == '>':
+      if my.buf[pos+1] == '>':
         inc(pos, 2)
         break
       add(my.b, '?')
       inc(pos)
     of '\c':
       # the specification says that CR-LF, CR are to be transformed to LF
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf      
+      pos = lexbase.handleCR(my, pos)
       add(my.b, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       add(my.b, '\L')
+    of '/':
+      pos = lexbase.handleRefillChar(my, pos)
+      add(my.b, '/')
     else:
-      add(my.b, buf[pos])
+      add(my.b, my.buf[pos])
       inc(pos)
   my.bufpos = pos
   my.kind = xmlPI
 
-proc parseSpecial(my: var TXmlParser) = 
+proc parseSpecial(my: var XmlParser) =
   # things that start with <!
   var pos = my.bufpos + 2
-  var buf = my.buf
   var opentags = 0
-  while true: 
-    case buf[pos]
+  while true:
+    case my.buf[pos]
     of '\0':
       markError(my, errGtExpected)
       break
-    of '<': 
+    of '<':
       inc(opentags)
       inc(pos)
       add(my.a, '<')
@@ -406,237 +542,279 @@ proc parseSpecial(my: var TXmlParser) =
       dec(opentags)
       inc(pos)
       add(my.a, '>')
-    of '\c':  
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
+    of '\c':
+      pos = lexbase.handleCR(my, pos)
       add(my.a, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       add(my.a, '\L')
+    of '/':
+      pos = lexbase.handleRefillChar(my, pos)
+      add(my.b, '/')
     else:
-      add(my.a, buf[pos])
+      add(my.a, my.buf[pos])
       inc(pos)
   my.bufpos = pos
   my.kind = xmlSpecial
 
-proc parseTag(my: var TXmlParser) = 
+proc parseTag(my: var XmlParser) =
   inc(my.bufpos)
   parseName(my, my.a)
   # if we have no name, do not interpret the '<':
-  if my.a.len == 0: 
+  if my.a.len == 0:
     my.kind = xmlCharData
     add(my.a, '<')
     return
-  parseWhitespace(my, skip=True)
-  if my.buf[my.bufpos] in NameStartChar: 
+  parseWhitespace(my, skip = true)
+  if my.buf[my.bufpos] in NameStartChar:
     # an attribute follows:
     my.kind = xmlElementOpen
     my.state = stateAttr
     my.c = my.a # save for later
+    my.cIsEmpty = false
   else:
     my.kind = xmlElementStart
-    if my.buf[my.bufpos] == '/' and my.buf[my.bufpos+1] == '>':
-      inc(my.bufpos, 2)
+    let slash = my.buf[my.bufpos] == '/'
+    if slash:
+      my.bufpos = lexbase.handleRefillChar(my, my.bufpos)
+    if slash and my.buf[my.bufpos] == '>':
+      inc(my.bufpos)
       my.state = stateEmptyElementTag
+      my.c = ""
+      my.cIsEmpty = true
     elif my.buf[my.bufpos] == '>':
-      inc(my.bufpos)  
+      inc(my.bufpos)
     else:
       markError(my, errGtExpected)
-  
-proc parseEndTag(my: var TXmlParser) = 
-  inc(my.bufpos, 2)
+
+proc parseEndTag(my: var XmlParser) =
+  my.bufpos = lexbase.handleRefillChar(my, my.bufpos+1)
+  #inc(my.bufpos, 2)
   parseName(my, my.a)
-  parseWhitespace(my, skip=True)
+  parseWhitespace(my, skip = true)
   if my.buf[my.bufpos] == '>':
     inc(my.bufpos)
   else:
     markError(my, errGtExpected)
   my.kind = xmlElementEnd
 
-proc parseAttribute(my: var TXmlParser) = 
+proc parseAttribute(my: var XmlParser) =
   my.kind = xmlAttribute
   setLen(my.a, 0)
   setLen(my.b, 0)
   parseName(my, my.a)
   # if we have no name, we have '<tag attr= key %&$$%':
-  if my.a.len == 0: 
+  if my.a.len == 0:
     markError(my, errGtExpected)
     return
-  parseWhitespace(my, skip=True)
+
+  let startPos = my.bufpos
+  parseWhitespace(my, skip = true)
   if my.buf[my.bufpos] != '=':
-    markError(my, errEqExpected)
+    if allowEmptyAttribs notin my.options or
+        (my.buf[my.bufpos] != '>' and my.bufpos == startPos):
+      markError(my, errEqExpected)
     return
+
   inc(my.bufpos)
-  parseWhitespace(my, skip=True)
+  parseWhitespace(my, skip = true)
 
   var pos = my.bufpos
-  var buf = my.buf
-  if buf[pos] in {'\'', '"'}:
-    var quote = buf[pos]
+  if my.buf[pos] in {'\'', '"'}:
+    var quote = my.buf[pos]
     var pendingSpace = false
     inc(pos)
-    while true: 
-      case buf[pos]
+    while true:
+      case my.buf[pos]
       of '\0':
         markError(my, errQuoteExpected)
         break
-      of '&': 
-        if pendingSpace: 
+      of '&':
+        if pendingSpace:
           add(my.b, ' ')
           pendingSpace = false
         my.bufpos = pos
         parseEntity(my, my.b)
         my.kind = xmlAttribute # parseEntity overwrites my.kind!
         pos = my.bufpos
-      of ' ', '\t': 
+      of ' ', '\t':
         pendingSpace = true
         inc(pos)
-      of '\c':  
-        pos = lexbase.HandleCR(my, pos)
-        buf = my.buf
+      of '\c':
+        pos = lexbase.handleCR(my, pos)
         pendingSpace = true
-      of '\L': 
-        pos = lexbase.HandleLF(my, pos)
-        buf = my.buf
+      of '\L':
+        pos = lexbase.handleLF(my, pos)
         pendingSpace = true
+      of '/':
+        pos = lexbase.handleRefillChar(my, pos)
+        add(my.b, '/')
       else:
-        if buf[pos] == quote:
+        if my.buf[pos] == quote:
           inc(pos)
           break
         else:
-          if pendingSpace: 
+          if pendingSpace:
             add(my.b, ' ')
             pendingSpace = false
-          add(my.b, buf[pos])
+          add(my.b, my.buf[pos])
           inc(pos)
+  elif allowUnquotedAttribs in my.options:
+    const disallowedChars = {'"', '\'', '`', '=', '<', '>', ' ',
+                             '\0', '\t', '\L', '\F', '\f'}
+    let startPos = pos
+    while (let c = my.buf[pos]; c notin disallowedChars):
+      if c == '&':
+        my.bufpos = pos
+        parseEntity(my, my.b)
+        my.kind = xmlAttribute # parseEntity overwrites my.kind!
+        pos = my.bufpos
+      elif c == '/':
+        pos = lexbase.handleRefillChar(my, pos)
+        add(my.b, '/')
+      else:
+        add(my.b, c)
+        inc(pos)
+    if pos == startPos:
+      markError(my, errAttributeValueExpected)
   else:
-    markError(my, errQuoteExpected)  
+    markError(my, errQuoteExpected)
+    # error corrections: guess what was meant
+    while my.buf[pos] != '>' and my.buf[pos] > ' ':
+      add(my.b, my.buf[pos])
+      inc pos
   my.bufpos = pos
-  parseWhitespace(my, skip=True)
-  
-proc parseCharData(my: var TXmlParser) = 
+  parseWhitespace(my, skip = true)
+
+proc parseCharData(my: var XmlParser) =
   var pos = my.bufpos
-  var buf = my.buf
-  while true: 
-    case buf[pos]
+  while true:
+    case my.buf[pos]
     of '\0', '<', '&': break
-    of '\c':  
+    of '\c':
       # the specification says that CR-LF, CR are to be transformed to LF
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
+      pos = lexbase.handleCR(my, pos)
       add(my.a, '\L')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
+    of '\L':
+      pos = lexbase.handleLF(my, pos)
       add(my.a, '\L')
+    of '/':
+      pos = lexbase.handleRefillChar(my, pos)
+      add(my.a, '/')
     else:
-      add(my.a, buf[pos])
+      add(my.a, my.buf[pos])
       inc(pos)
   my.bufpos = pos
   my.kind = xmlCharData
 
-proc rawGetTok(my: var TXmlParser) = 
+proc rawGetTok(my: var XmlParser) =
   my.kind = xmlError
   setLen(my.a, 0)
   var pos = my.bufpos
-  var buf = my.buf
-  case buf[pos]
-  of '<': 
-    case buf[pos+1]
+  case my.buf[pos]
+  of '<':
+    case my.buf[pos+1]
     of '/':
       parseEndTag(my)
     of '!':
-      if buf[pos+2] == '[' and buf[pos+3] == 'C' and buf[pos+4] == 'D' and
-          buf[pos+5] == 'A' and buf[pos+6] == 'T' and buf[pos+7] == 'A' and
-          buf[pos+8] == '[':
+      if my.buf[pos+2] == '[' and my.buf[pos+3] == 'C' and
+          my.buf[pos+4] == 'D' and my.buf[pos+5] == 'A' and
+          my.buf[pos+6] == 'T' and my.buf[pos+7] == 'A' and
+          my.buf[pos+8] == '[':
         parseCDATA(my)
-      elif buf[pos+2] == '-' and buf[pos+3] == '-': 
+      elif my.buf[pos+2] == '-' and my.buf[pos+3] == '-':
         parseComment(my)
-      else: 
+      else:
         parseSpecial(my)
     of '?':
       parsePI(my)
-    else: 
+    else:
       parseTag(my)
-  of ' ', '\t', '\c', '\l': 
-    parseWhiteSpace(my)
+  of ' ', '\t', '\c', '\l':
+    parseWhitespace(my)
     my.kind = xmlWhitespace
-  of '\0': 
+  of '\0':
     my.kind = xmlEof
   of '&':
     parseEntity(my, my.a)
-  else: 
+  else:
     parseCharData(my)
   assert my.kind != xmlError
-    
-proc getTok(my: var TXmlParser) = 
+
+proc getTok(my: var XmlParser) =
   while true:
+    let lastKind = my.kind
     rawGetTok(my)
     case my.kind
-    of xmlComment: 
+    of xmlComment:
       if my.options.contains(reportComments): break
-    of xmlWhitespace: 
-      if my.options.contains(reportWhitespace): break
+    of xmlWhitespace:
+      if my.options.contains(reportWhitespace) or lastKind in {xmlCharData,
+          xmlComment, xmlEntity}:
+        break
     else: break
-    
-proc next*(my: var TXmlParser) = 
+
+proc next*(my: var XmlParser) =
   ## retrieves the first/next event. This controls the parser.
   case my.state
   of stateNormal:
-    getTok(my)  
+    getTok(my)
   of stateStart:
+    my.state = stateNormal
     getTok(my)
-    if my.kind == xmlPI and my.a == "xml": 
+    if my.kind == xmlPI and my.a == "xml":
       # just skip the first ``<?xml >`` processing instruction
       getTok(my)
-    my.state = stateNormal
   of stateAttr:
     # parse an attribute key-value pair:
     if my.buf[my.bufpos] == '>':
       my.kind = xmlElementClose
       inc(my.bufpos)
       my.state = stateNormal
-    elif my.buf[my.bufpos] == '/' and my.buf[my.bufpos+1] == '>': 
-      my.kind = xmlElementClose
-      inc(my.bufpos, 2)
-      my.state = stateEmptyElementTag
+    elif my.buf[my.bufpos] == '/':
+      my.bufpos = lexbase.handleRefillChar(my, my.bufpos)
+      if my.buf[my.bufpos] == '>':
+        my.kind = xmlElementClose
+        inc(my.bufpos)
+        my.state = stateEmptyElementTag
+      else:
+        markError(my, errGtExpected)
     else:
       parseAttribute(my)
       # state remains the same
   of stateEmptyElementTag:
     my.state = stateNormal
     my.kind = xmlElementEnd
-    if not isNil(my.c):
+    if not my.cIsEmpty:
       my.a = my.c
-  of stateError: 
+  of stateError:
     my.kind = xmlError
     my.state = stateNormal
-  
-when isMainModule:
-  import os
-  var s = newFileStream(ParamStr(1), fmRead)
-  if s == nil: quit("cannot open the file" & ParamStr(1))
-  var x: TXmlParser
-  open(x, s, ParamStr(1))
+
+when not defined(testing) and isMainModule:
+  import std/os
+  var s = newFileStream(paramStr(1), fmRead)
+  if s == nil: quit("cannot open the file" & paramStr(1))
+  var x: XmlParser
+  open(x, s, paramStr(1))
   while true:
     next(x)
     case x.kind
-    of xmlError: Echo(x.errorMsg())
+    of xmlError: echo(x.errorMsg())
     of xmlEof: break
     of xmlCharData: echo(x.charData)
     of xmlWhitespace: echo("|$1|" % x.charData)
     of xmlComment: echo("<!-- $1 -->" % x.charData)
-    of xmlPI: echo("<? $1 ## $2 ?>" % [x.PIName, x.PIRest])
+    of xmlPI: echo("<? $1 ## $2 ?>" % [x.piName, x.piRest])
     of xmlElementStart: echo("<$1>" % x.elementName)
     of xmlElementEnd: echo("</$1>" % x.elementName)
-    
-    of xmlElementOpen: echo("<$1" % x.elementName) 
-    of xmlAttribute:   
+
+    of xmlElementOpen: echo("<$1" % x.elementName)
+    of xmlAttribute:
       echo("Key: " & x.attrKey)
       echo("Value: " & x.attrValue)
-    
-    of xmlElementClose: echo(">") 
+
+    of xmlElementClose: echo(">")
     of xmlCData:
       echo("<![CDATA[$1]]>" % x.charData)
     of xmlEntity:
@@ -644,4 +822,3 @@ when isMainModule:
     of xmlSpecial:
       echo("SPECIAL: " & x.charData)
   close(x)
-
diff --git a/lib/pure/pathnorm.nim b/lib/pure/pathnorm.nim
new file mode 100644
index 000000000..4cdc02303
--- /dev/null
+++ b/lib/pure/pathnorm.nim
@@ -0,0 +1,121 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## OS-Path normalization. Used by `os.nim` but also
+## generally useful for dealing with paths.
+##
+## Unstable API.
+
+# Yes, this uses import here, not include so that
+# we don't end up exporting these symbols from pathnorm and os:
+import std/private/osseps
+
+type
+  PathIter* = object
+    i, prev: int
+    notFirst: bool
+
+proc hasNext*(it: PathIter; x: string): bool =
+  it.i < x.len
+
+proc next*(it: var PathIter; x: string): (int, int) =
+  it.prev = it.i
+  if not it.notFirst and x[it.i] in {DirSep, AltSep}:
+    # absolute path:
+    inc it.i
+  else:
+    while it.i < x.len and x[it.i] notin {DirSep, AltSep}: inc it.i
+  if it.i > it.prev:
+    result = (it.prev, it.i-1)
+  elif hasNext(it, x):
+    result = next(it, x)
+  # skip all separators:
+  while it.i < x.len and x[it.i] in {DirSep, AltSep}: inc it.i
+  it.notFirst = true
+
+iterator dirs(x: string): (int, int) =
+  var it = default PathIter
+  while hasNext(it, x): yield next(it, x)
+
+proc isDot(x: string; bounds: (int, int)): bool =
+  bounds[1] == bounds[0] and x[bounds[0]] == '.'
+
+proc isDotDot(x: string; bounds: (int, int)): bool =
+  bounds[1] == bounds[0] + 1 and x[bounds[0]] == '.' and x[bounds[0]+1] == '.'
+
+proc isSlash(x: string; bounds: (int, int)): bool =
+  bounds[1] == bounds[0] and x[bounds[0]] in {DirSep, AltSep}
+
+when doslikeFileSystem:
+  import std/private/ntpath
+
+proc addNormalizePath*(x: string; result: var string; state: var int;
+    dirSep = DirSep) =
+  ## Low level proc. Undocumented.
+
+  when doslikeFileSystem: # Add Windows drive at start without normalization
+    var x = x
+    if result == "":
+      let (drive, file) = splitDrive(x)
+      x = file
+      result.add drive
+      for c in result.mitems:
+        if c in {DirSep, AltSep}:
+          c = dirSep
+
+  # state: 0th bit set if isAbsolute path. Other bits count
+  # the number of path components.
+  var it: PathIter
+  it.notFirst = (state shr 1) > 0
+  if it.notFirst:
+    while it.i < x.len and x[it.i] in {DirSep, AltSep}: inc it.i
+  while hasNext(it, x):
+    let b = next(it, x)
+    if (state shr 1 == 0) and isSlash(x, b):
+      if result.len == 0 or result[result.len - 1] notin {DirSep, AltSep}:
+        result.add dirSep
+      state = state or 1
+    elif isDotDot(x, b):
+      if (state shr 1) >= 1:
+        var d = result.len
+        # f/..
+        # We could handle stripping trailing sep here: foo// => foo like this:
+        # while (d-1) > (state and 1) and result[d-1] in {DirSep, AltSep}: dec d
+        # but right now we instead handle it inside os.joinPath
+
+        # strip path component: foo/bar => foo
+        while (d-1) > (state and 1) and result[d-1] notin {DirSep, AltSep}:
+          dec d
+        if d > 0:
+          setLen(result, d-1)
+          dec state, 2
+      else:
+        if result.len > 0 and result[result.len - 1] notin {DirSep, AltSep}:
+          result.add dirSep
+        result.add substr(x, b[0], b[1])
+    elif isDot(x, b):
+      discard "discard the dot"
+    elif b[1] >= b[0]:
+      if result.len > 0 and result[result.len - 1] notin {DirSep, AltSep}:
+        result.add dirSep
+      result.add substr(x, b[0], b[1])
+      inc state, 2
+  if result == "" and x != "": result = "."
+
+proc normalizePath*(path: string; dirSep = DirSep): string =
+  runnableExamples:
+    when defined(posix):
+      doAssert normalizePath("./foo//bar/../baz") == "foo/baz"
+
+  ## - Turns multiple slashes into single slashes.
+  ## - Resolves `'/foo/../bar'` to `'/bar'`.
+  ## - Removes `'./'` from the path, but `"foo/.."` becomes `"."`.
+  result = newStringOfCap(path.len)
+  var state = 0
+  addNormalizePath(path, result, state, dirSep)
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim
index 969ff8106..2969fd6d7 100755..100644
--- a/lib/pure/pegs.nim
+++ b/lib/pure/pegs.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -12,121 +12,183 @@
 ## Matching performance is hopefully competitive with optimized regular
 ## expression engines.
 ##
-## .. include:: ../doc/pegdocs.txt
+## .. include:: ../../doc/pegdocs.txt
 ##
 
+include "system/inclrtl"
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions]
+
 const
   useUnicode = true ## change this to deactivate proper UTF-8 support
 
-import
-  strutils
+import std/[strutils, macros]
+import std/private/decode_helpers
 
 when useUnicode:
-  import unicode
+  import std/unicode
+  export unicode.`==`
 
 const
-  InlineThreshold = 5   ## number of leaves; -1 to disable inlining
-  MaxSubpatterns* = 10 ## defines the maximum number of subpatterns that
-                       ## can be captured. More subpatterns cannot be captured! 
+  InlineThreshold = 5  ## number of leaves; -1 to disable inlining
+  MaxSubpatterns* = 20 ## defines the maximum number of subpatterns that
+                       ## can be captured. More subpatterns cannot be captured!
 
 type
-  TPegKind = enum
+  PegKind* = enum
     pkEmpty,
-    pkAny,              ## any character (.)
-    pkAnyRune,          ## any Unicode character (_)
-    pkNewLine,          ## CR-LF, LF, CR
+    pkAny,            ## any character (.)
+    pkAnyRune,        ## any Unicode character (_)
+    pkNewLine,        ## CR-LF, LF, CR
+    pkLetter,         ## Unicode letter
+    pkLower,          ## Unicode lower case letter
+    pkUpper,          ## Unicode upper case letter
+    pkTitle,          ## Unicode title character
+    pkWhitespace,     ## Unicode whitespace character
     pkTerminal,
     pkTerminalIgnoreCase,
     pkTerminalIgnoreStyle,
-    pkChar,             ## single character to match
+    pkChar,           ## single character to match
     pkCharChoice,
     pkNonTerminal,
-    pkSequence,         ## a b c ... --> Internal DSL: peg(a, b, c)
-    pkOrderedChoice,    ## a / b / ... --> Internal DSL: a / b or /[a, b, c]
-    pkGreedyRep,        ## a*     --> Internal DSL: *a
-                        ## a+     --> (a a*)
-    pkGreedyRepChar,    ## x* where x is a single character (superop)
-    pkGreedyRepSet,     ## [set]* (superop)
-    pkGreedyAny,        ## .* or _* (superop)
-    pkOption,           ## a?     --> Internal DSL: ?a
-    pkAndPredicate,     ## &a     --> Internal DSL: &a
-    pkNotPredicate,     ## !a     --> Internal DSL: !a
-    pkCapture,          ## {a}    --> Internal DSL: capture(a)
-    pkBackRef,          ## $i     --> Internal DSL: backref(i)
+    pkSequence,       ## a b c ... --> Internal DSL: peg(a, b, c)
+    pkOrderedChoice,  ## a / b / ... --> Internal DSL: a / b or /[a, b, c]
+    pkGreedyRep,      ## a*     --> Internal DSL: *a
+                      ## a+     --> (a a*)
+    pkGreedyRepChar,  ## x* where x is a single character (superop)
+    pkGreedyRepSet,   ## [set]* (superop)
+    pkGreedyAny,      ## .* or _* (superop)
+    pkOption,         ## a?     --> Internal DSL: ?a
+    pkAndPredicate,   ## &a     --> Internal DSL: &a
+    pkNotPredicate,   ## !a     --> Internal DSL: !a
+    pkCapture,        ## {a}    --> Internal DSL: capture(a)
+    pkBackRef,        ## $i     --> Internal DSL: backref(i)
     pkBackRefIgnoreCase,
     pkBackRefIgnoreStyle,
-    pkSearch,           ## @a     --> Internal DSL: @a
-    pkRule,             ## a <- b
-    pkList              ## a, b
-  TNonTerminalFlag = enum
+    pkSearch,         ## @a     --> Internal DSL: !*a
+    pkCapturedSearch, ## {@} a  --> Internal DSL: !*\a
+    pkRule,           ## a <- b
+    pkList,           ## a, b
+    pkStartAnchor     ## ^      --> Internal DSL: startAnchor()
+  NonTerminalFlag* = enum
     ntDeclared, ntUsed
-  TNonTerminal {.final.} = object ## represents a non terminal symbol
-    name: string                  ## the name of the symbol
-    line: int                     ## line the symbol has been declared/used in
-    col: int                      ## column the symbol has been declared/used in
-    flags: set[TNonTerminalFlag]  ## the nonterminal's flags
-    rule: TNode                   ## the rule that the symbol refers to
-  TNode {.final.} = object
-    case kind: TPegKind
-    of pkEmpty, pkAny, pkAnyRune, pkGreedyAny, pkNewLine: nil
+  NonTerminalObj = object       ## represents a non terminal symbol
+    name: string                ## the name of the symbol
+    line: int                   ## line the symbol has been declared/used in
+    col: int                    ## column the symbol has been declared/used in
+    flags: set[NonTerminalFlag] ## the nonterminal's flags
+    rule: Peg                   ## the rule that the symbol refers to
+  Peg* {.shallow.} = object ## type that represents a PEG
+    case kind: PegKind
+    of pkEmpty..pkWhitespace: nil
     of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle: term: string
     of pkChar, pkGreedyRepChar: ch: char
     of pkCharChoice, pkGreedyRepSet: charChoice: ref set[char]
-    of pkNonTerminal: nt: PNonTerminal
-    of pkBackRef..pkBackRefIgnoreStyle: index: range[1..MaxSubpatterns]
-    else: sons: seq[TNode]
-  PNonTerminal* = ref TNonTerminal
-  
-  TPeg* = TNode ## type that represents a PEG
-
-proc term*(t: string): TPeg =
+    of pkNonTerminal: nt: NonTerminal
+    of pkBackRef..pkBackRefIgnoreStyle: index: range[-MaxSubpatterns..MaxSubpatterns-1]
+    else: sons: seq[Peg]
+  NonTerminal* = ref NonTerminalObj
+
+func kind*(p: Peg): PegKind = p.kind
+  ## Returns the *PegKind* of a given *Peg* object.
+
+func term*(p: Peg): string = p.term
+  ## Returns the *string* representation of a given *Peg* variant object
+  ## where present.
+
+func ch*(p: Peg): char = p.ch
+  ## Returns the *char* representation of a given *Peg* variant object
+  ## where present.
+
+func charChoice*(p: Peg): ref set[char] = p.charChoice
+  ## Returns the *charChoice* field of a given *Peg* variant object
+  ## where present.
+
+func nt*(p: Peg): NonTerminal = p.nt
+  ## Returns the *NonTerminal* object of a given *Peg* variant object
+  ## where present.
+
+func index*(p: Peg): range[-MaxSubpatterns..MaxSubpatterns-1] = p.index
+  ## Returns the back-reference index of a captured sub-pattern in the
+  ## *Captures* object for a given *Peg* variant object where present.
+
+iterator items*(p: Peg): Peg {.inline.} =
+  ## Yields the child nodes of a *Peg* variant object where present.
+  for s in p.sons:
+    yield s
+
+iterator pairs*(p: Peg): (int, Peg) {.inline.} =
+  ## Yields the indices and child nodes of a *Peg* variant object where present.
+  for i in 0 ..< p.sons.len:
+    yield (i, p.sons[i])
+
+func name*(nt: NonTerminal): string = nt.name
+  ## Gets the name of the symbol represented by the parent *Peg* object variant
+  ## of a given *NonTerminal*.
+
+func line*(nt: NonTerminal): int = nt.line
+  ## Gets the line number of the definition of the parent *Peg* object variant
+  ## of a given *NonTerminal*.
+
+func col*(nt: NonTerminal): int = nt.col
+  ## Gets the column number of the definition of the parent *Peg* object variant
+  ## of a given *NonTerminal*.
+
+func flags*(nt: NonTerminal): set[NonTerminalFlag] = nt.flags
+  ## Gets the *NonTerminalFlag*-typed flags field of the parent *Peg* variant
+  ## object of a given *NonTerminal*.
+
+func rule*(nt: NonTerminal): Peg = nt.rule
+  ## Gets the *Peg* object representing the rule definition of the parent *Peg*
+  ## object variant of a given *NonTerminal*.
+
+func term*(t: string): Peg {.rtl, extern: "npegs$1Str".} =
   ## constructs a PEG from a terminal string
-  if t.len != 1:  
-    result.kind = pkTerminal
-    result.term = t
+  if t.len != 1:
+    result = Peg(kind: pkTerminal, term: t)
   else:
-    result.kind = pkChar
-    result.ch = t[0]
+    result = Peg(kind: pkChar, ch: t[0])
 
-proc termIgnoreCase*(t: string): TPeg =
+func termIgnoreCase*(t: string): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a PEG from a terminal string; ignore case for matching
-  result.kind = pkTerminalIgnoreCase
-  result.term = t
+  result = Peg(kind: pkTerminalIgnoreCase, term: t)
 
-proc termIgnoreStyle*(t: string): TPeg =
+func termIgnoreStyle*(t: string): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a PEG from a terminal string; ignore style for matching
-  result.kind = pkTerminalIgnoreStyle
-  result.term = t
+  result = Peg(kind: pkTerminalIgnoreStyle, term: t)
 
-proc term*(t: char): TPeg =
+func term*(t: char): Peg {.rtl, extern: "npegs$1Char".} =
   ## constructs a PEG from a terminal char
   assert t != '\0'
-  result.kind = pkChar
-  result.ch = t
-  
-proc charSet*(s: set[char]): TPeg =
+  result = Peg(kind: pkChar, ch: t)
+
+func charSet*(s: set[char]): Peg {.rtl, extern: "npegs$1".} =
   ## constructs a PEG from a character set `s`
   assert '\0' notin s
-  result.kind = pkCharChoice
-  new(result.charChoice)
-  result.charChoice^ = s
+  result = Peg(kind: pkCharChoice)
+  {.cast(noSideEffect).}:
+    new(result.charChoice)
+    result.charChoice[] = s
 
-proc len(a: TPeg): int {.inline.} = return a.sons.len
-proc add(d: var TPeg, s: TPeg) {.inline.} = add(d.sons, s)
+func len(a: Peg): int {.inline.} = return a.sons.len
+func add(d: var Peg, s: Peg) {.inline.} = add(d.sons, s)
 
-proc addChoice(dest: var TPeg, elem: TPeg) =
+func addChoice(dest: var Peg, elem: Peg) =
   var L = dest.len-1
-  if L >= 0 and dest.sons[L].kind == pkCharChoice: 
+  if L >= 0 and dest.sons[L].kind == pkCharChoice:
+    # caution! Do not introduce false aliasing here!
     case elem.kind
     of pkCharChoice:
-      dest.sons[L].charChoice^ = dest.sons[L].charChoice^ + elem.charChoice^
-    of pkChar: incl(dest.sons[L].charChoice^, elem.ch)
+      dest.sons[L] = charSet(dest.sons[L].charChoice[] + elem.charChoice[])
+    of pkChar:
+      dest.sons[L] = charSet(dest.sons[L].charChoice[] + {elem.ch})
     else: add(dest, elem)
   else: add(dest, elem)
 
-template multipleOp(k: TPegKind, localOpt: expr) =
-  result.kind = k
-  result.sons = @[]
+template multipleOp(k: PegKind, localOpt: untyped) =
+  result = Peg(kind: k, sons: @[])
   for x in items(a):
     if x.kind == k:
       for y in items(x.sons):
@@ -136,24 +198,29 @@ template multipleOp(k: TPegKind, localOpt: expr) =
   if result.len == 1:
     result = result.sons[0]
 
-proc `/`*(a: openArray[TPeg]): TPeg =
+func `/`*(a: varargs[Peg]): Peg {.
+  rtl, extern: "npegsOrderedChoice".} =
   ## constructs an ordered choice with the PEGs in `a`
   multipleOp(pkOrderedChoice, addChoice)
 
-proc addSequence(dest: var TPeg, elem: TPeg) =
+func addSequence(dest: var Peg, elem: Peg) =
   var L = dest.len-1
-  if L >= 0 and dest.sons[L].kind == pkTerminal: 
+  if L >= 0 and dest.sons[L].kind == pkTerminal:
+    # caution! Do not introduce false aliasing here!
     case elem.kind
-    of pkTerminal: add(dest.sons[L].term, elem.term)
-    of pkChar: add(dest.sons[L].term, elem.ch)
+    of pkTerminal:
+      dest.sons[L] = term(dest.sons[L].term & elem.term)
+    of pkChar:
+      dest.sons[L] = term(dest.sons[L].term & elem.ch)
     else: add(dest, elem)
   else: add(dest, elem)
 
-proc sequence*(a: openArray[TPeg]): TPeg =
+func sequence*(a: varargs[Peg]): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a sequence with all the PEGs from `a`
   multipleOp(pkSequence, addSequence)
- 
-proc `?`*(a: TPeg): TPeg =
+
+func `?`*(a: Peg): Peg {.rtl, extern: "npegsOptional".} =
   ## constructs an optional for the PEG `a`
   if a.kind in {pkOption, pkGreedyRep, pkGreedyAny, pkGreedyRepChar,
                 pkGreedyRepSet}:
@@ -161,99 +228,116 @@ proc `?`*(a: TPeg): TPeg =
     # a? ?  --> a?
     result = a
   else:
-    result.kind = pkOption
-    result.sons = @[a]
+    result = Peg(kind: pkOption, sons: @[a])
 
-proc `*`*(a: TPeg): TPeg =
+func `*`*(a: Peg): Peg {.rtl, extern: "npegsGreedyRep".} =
   ## constructs a "greedy repetition" for the PEG `a`
   case a.kind
   of pkGreedyRep, pkGreedyRepChar, pkGreedyRepSet, pkGreedyAny, pkOption:
     assert false
     # produces endless loop!
   of pkChar:
-    result.kind = pkGreedyRepChar
-    result.ch = a.ch
+    result = Peg(kind: pkGreedyRepChar, ch: a.ch)
   of pkCharChoice:
-    result.kind = pkGreedyRepSet
-    result.charChoice = a.charChoice # copying a reference suffices!
+    result = Peg(kind: pkGreedyRepSet, charChoice: a.charChoice)
   of pkAny, pkAnyRune:
-    result.kind = pkGreedyAny
+    result = Peg(kind: pkGreedyAny)
   else:
-    result.kind = pkGreedyRep
-    result.sons = @[a]
+    result = Peg(kind: pkGreedyRep, sons: @[a])
 
-proc `@`*(a: TPeg): TPeg =
+func `!*`*(a: Peg): Peg {.rtl, extern: "npegsSearch".} =
   ## constructs a "search" for the PEG `a`
-  result.kind = pkSearch
-  result.sons = @[a]
-  
-when false:
-  proc contains(a: TPeg, k: TPegKind): bool =
-    if a.kind == k: return true
-    case a.kind
-    of pkEmpty, pkAny, pkAnyRune, pkGreedyAny, pkNewLine, pkTerminal,
-       pkTerminalIgnoreCase, pkTerminalIgnoreStyle, pkChar, pkGreedyRepChar,
-       pkCharChoice, pkGreedyRepSet: nil
-    of pkNonTerminal: return true
-    else:
-      for i in 0..a.sons.len-1:
-        if contains(a.sons[i], k): return true
+  result = Peg(kind: pkSearch, sons: @[a])
+
+func `!*\`*(a: Peg): Peg {.rtl,
+                             extern: "npgegsCapturedSearch".} =
+  ## constructs a "captured search" for the PEG `a`
+  result = Peg(kind: pkCapturedSearch, sons: @[a])
 
-proc `+`*(a: TPeg): TPeg =
+func `+`*(a: Peg): Peg {.rtl, extern: "npegsGreedyPosRep".} =
   ## constructs a "greedy positive repetition" with the PEG `a`
   return sequence(a, *a)
-  
-proc `&`*(a: TPeg): TPeg =
+
+func `&`*(a: Peg): Peg {.rtl, extern: "npegsAndPredicate".} =
   ## constructs an "and predicate" with the PEG `a`
-  result.kind = pkAndPredicate
-  result.sons = @[a]
+  result = Peg(kind: pkAndPredicate, sons: @[a])
 
-proc `!`*(a: TPeg): TPeg =
+func `!`*(a: Peg): Peg {.rtl, extern: "npegsNotPredicate".} =
   ## constructs a "not predicate" with the PEG `a`
-  result.kind = pkNotPredicate
-  result.sons = @[a]
+  result = Peg(kind: pkNotPredicate, sons: @[a])
 
-proc any*: TPeg {.inline.} =
+func any*: Peg {.inline.} =
   ## constructs the PEG `any character`:idx: (``.``)
-  result.kind = pkAny
+  result = Peg(kind: pkAny)
 
-proc anyRune*: TPeg {.inline.} =
+func anyRune*: Peg {.inline.} =
   ## constructs the PEG `any rune`:idx: (``_``)
-  result.kind = pkAnyRune
+  result = Peg(kind: pkAnyRune)
 
-proc newLine*: TPeg {.inline.} =
+func newLine*: Peg {.inline.} =
   ## constructs the PEG `newline`:idx: (``\n``)
-  result.kind = pkNewline
+  result = Peg(kind: pkNewLine)
+
+func unicodeLetter*: Peg {.inline.} =
+  ## constructs the PEG ``\letter`` which matches any Unicode letter.
+  result = Peg(kind: pkLetter)
+
+func unicodeLower*: Peg {.inline.} =
+  ## constructs the PEG ``\lower`` which matches any Unicode lowercase letter.
+  result = Peg(kind: pkLower)
+
+func unicodeUpper*: Peg {.inline.} =
+  ## constructs the PEG ``\upper`` which matches any Unicode uppercase letter.
+  result = Peg(kind: pkUpper)
 
-proc capture*(a: TPeg): TPeg =
+func unicodeTitle*: Peg {.inline.} =
+  ## constructs the PEG ``\title`` which matches any Unicode title letter.
+  result = Peg(kind: pkTitle)
+
+func unicodeWhitespace*: Peg {.inline.} =
+  ## constructs the PEG ``\white`` which matches any Unicode
+  ## whitespace character.
+  result = Peg(kind: pkWhitespace)
+
+func startAnchor*: Peg {.inline.} =
+  ## constructs the PEG ``^`` which matches the start of the input.
+  result = Peg(kind: pkStartAnchor)
+
+func endAnchor*: Peg {.inline.} =
+  ## constructs the PEG ``$`` which matches the end of the input.
+  result = !any()
+
+func capture*(a: Peg = Peg(kind: pkEmpty)): Peg {.rtl, extern: "npegsCapture".} =
   ## constructs a capture with the PEG `a`
-  result.kind = pkCapture
-  result.sons = @[a]
+  result = Peg(kind: pkCapture, sons: @[a])
 
-proc backref*(index: range[1..MaxSubPatterns]): TPeg = 
+func backref*(index: range[1..MaxSubpatterns], reverse: bool = false): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a back reference of the given `index`. `index` starts counting
-  ## from 1.
-  result.kind = pkBackRef
-  result.index = index-1
+  ## from 1. `reverse` specifies whether indexing starts from the end of the
+  ## capture list.
+  result = Peg(kind: pkBackRef, index: (if reverse: -index else: index - 1))
 
-proc backrefIgnoreCase*(index: range[1..MaxSubPatterns]): TPeg = 
+func backrefIgnoreCase*(index: range[1..MaxSubpatterns], reverse: bool = false): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a back reference of the given `index`. `index` starts counting
-  ## from 1. Ignores case for matching.
-  result.kind = pkBackRefIgnoreCase
-  result.index = index-1
+  ## from 1. `reverse` specifies whether indexing starts from the end of the
+  ## capture list. Ignores case for matching.
+  result = Peg(kind: pkBackRefIgnoreCase, index: (if reverse: -index else: index - 1))
 
-proc backrefIgnoreStyle*(index: range[1..MaxSubPatterns]): TPeg = 
+func backrefIgnoreStyle*(index: range[1..MaxSubpatterns], reverse: bool = false): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a back reference of the given `index`. `index` starts counting
-  ## from 1. Ignores style for matching.
-  result.kind = pkBackRefIgnoreStyle
-  result.index = index-1
+  ## from 1. `reverse` specifies whether indexing starts from the end of the
+  ## capture list. Ignores style for matching.
+  result = Peg(kind: pkBackRefIgnoreStyle, index: (if reverse: -index else: index - 1))
 
-proc spaceCost(n: TPeg): int =
+func spaceCost(n: Peg): int =
   case n.kind
-  of pkEmpty: nil
+  of pkEmpty: discard
   of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle, pkChar,
-     pkGreedyRepChar, pkCharChoice, pkGreedyRepSet, pkAny, pkAnyRune,
-     pkNewLine, pkGreedyAny:
+     pkGreedyRepChar, pkCharChoice, pkGreedyRepSet,
+     pkAny..pkWhitespace, pkGreedyAny, pkBackRef..pkBackRefIgnoreStyle:
     result = 1
   of pkNonTerminal:
     # we cannot inline a rule with a non-terminal
@@ -263,55 +347,53 @@ proc spaceCost(n: TPeg): int =
       inc(result, spaceCost(n.sons[i]))
       if result >= InlineThreshold: break
 
-proc nonterminal*(n: PNonTerminal): TPeg = 
+func nonterminal*(n: NonTerminal): Peg {.
+  rtl, extern: "npegs$1".} =
   ## constructs a PEG that consists of the nonterminal symbol
   assert n != nil
   if ntDeclared in n.flags and spaceCost(n.rule) < InlineThreshold:
     when false: echo "inlining symbol: ", n.name
     result = n.rule # inlining of rule enables better optimizations
   else:
-    result.kind = pkNonTerminal
-    result.nt = n
+    result = Peg(kind: pkNonTerminal, nt: n)
 
-proc newNonTerminal*(name: string, line, column: int): PNonTerminal =
+func newNonTerminal*(name: string, line, column: int): NonTerminal {.
+  rtl, extern: "npegs$1".} =
   ## constructs a nonterminal symbol
-  new(result)
-  result.name = name
-  result.line = line
-  result.col = column
+  result = NonTerminal(name: name, line: line, col: column)
 
-template letters*: expr =
+template letters*: Peg =
   ## expands to ``charset({'A'..'Z', 'a'..'z'})``
-  charset({'A'..'Z', 'a'..'z'})
-  
-template digits*: expr =
+  charSet({'A'..'Z', 'a'..'z'})
+
+template digits*: Peg =
   ## expands to ``charset({'0'..'9'})``
-  charset({'0'..'9'})
+  charSet({'0'..'9'})
 
-template whitespace*: expr =
+template whitespace*: Peg =
   ## expands to ``charset({' ', '\9'..'\13'})``
-  charset({' ', '\9'..'\13'})
-  
-template identChars*: expr =
+  charSet({' ', '\9'..'\13'})
+
+template identChars*: Peg =
   ## expands to ``charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})``
-  charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})
-  
-template identStartChars*: expr =
+  charSet({'a'..'z', 'A'..'Z', '0'..'9', '_'})
+
+template identStartChars*: Peg =
   ## expands to ``charset({'A'..'Z', 'a'..'z', '_'})``
-  charset({'a'..'z', 'A'..'Z', '_'})
+  charSet({'a'..'z', 'A'..'Z', '_'})
 
-template ident*: expr =
+template ident*: Peg =
   ## same as ``[a-zA-Z_][a-zA-z_0-9]*``; standard identifier
-  sequence(charset({'a'..'z', 'A'..'Z', '_'}),
-           *charset({'a'..'z', 'A'..'Z', '0'..'9', '_'}))
-  
-template natural*: expr =
+  sequence(charSet({'a'..'z', 'A'..'Z', '_'}),
+           *charSet({'a'..'z', 'A'..'Z', '0'..'9', '_'}))
+
+template natural*: Peg =
   ## same as ``\d+``
   +digits
 
 # ------------------------- debugging -----------------------------------------
 
-proc esc(c: char, reserved = {'\0'..'\255'}): string = 
+func esc(c: char, reserved = {'\0'..'\255'}): string =
   case c
   of '\b': result = "\\b"
   of '\t': result = "\\t"
@@ -323,46 +405,52 @@ proc esc(c: char, reserved = {'\0'..'\255'}): string =
   of '\a': result = "\\a"
   of '\\': result = "\\\\"
   of 'a'..'z', 'A'..'Z', '0'..'9', '_': result = $c
-  elif c < ' ' or c >= '\128': result = '\\' & $ord(c)
+  elif c < ' ' or c >= '\127': result = '\\' & $ord(c)
   elif c in reserved: result = '\\' & c
   else: result = $c
-  
-proc singleQuoteEsc(c: Char): string = return "'" & esc(c, {'\''}) & "'"
 
-proc singleQuoteEsc(str: string): string = 
+func singleQuoteEsc(c: char): string = return "'" & esc(c, {'\''}) & "'"
+
+func singleQuoteEsc(str: string): string =
   result = "'"
   for c in items(str): add result, esc(c, {'\''})
   add result, '\''
-  
-proc charSetEscAux(cc: set[char]): string = 
+
+func charSetEscAux(cc: set[char]): string =
   const reserved = {'^', '-', ']'}
   result = ""
   var c1 = 0
-  while c1 <= 0xff: 
-    if chr(c1) in cc: 
+  while c1 <= 0xff:
+    if chr(c1) in cc:
       var c2 = c1
       while c2 < 0xff and chr(succ(c2)) in cc: inc(c2)
-      if c1 == c2: 
+      if c1 == c2:
         add result, esc(chr(c1), reserved)
-      elif c2 == succ(c1): 
+      elif c2 == succ(c1):
         add result, esc(chr(c1), reserved) & esc(chr(c2), reserved)
-      else: 
+      else:
         add result, esc(chr(c1), reserved) & '-' & esc(chr(c2), reserved)
       c1 = c2
     inc(c1)
-  
-proc CharSetEsc(cc: set[char]): string =
-  if card(cc) >= 128+64: 
-    result = "[^" & CharSetEscAux({'\1'..'\xFF'} - cc) & ']'
-  else: 
-    result = '[' & CharSetEscAux(cc) & ']'
-  
-proc toStrAux(r: TPeg, res: var string) = 
+
+func charSetEsc(cc: set[char]): string =
+  if card(cc) >= 128+64:
+    result = "[^" & charSetEscAux({'\1'..'\xFF'} - cc) & ']'
+  else:
+    result = '[' & charSetEscAux(cc) & ']'
+
+func toStrAux(r: Peg, res: var string) =
   case r.kind
   of pkEmpty: add(res, "()")
   of pkAny: add(res, '.')
   of pkAnyRune: add(res, '_')
-  of pkNewline: add(res, "\\n")
+  of pkLetter: add(res, "\\letter")
+  of pkLower: add(res, "\\lower")
+  of pkUpper: add(res, "\\upper")
+  of pkTitle: add(res, "\\title")
+  of pkWhitespace: add(res, "\\white")
+
+  of pkNewLine: add(res, "\\n")
   of pkTerminal: add(res, singleQuoteEsc(r.term))
   of pkTerminalIgnoreCase:
     add(res, 'i')
@@ -371,7 +459,7 @@ proc toStrAux(r: TPeg, res: var string) =
     add(res, 'y')
     add(res, singleQuoteEsc(r.term))
   of pkChar: add(res, singleQuoteEsc(r.ch))
-  of pkCharChoice: add(res, charSetEsc(r.charChoice^))
+  of pkCharChoice: add(res, charSetEsc(r.charChoice[]))
   of pkNonTerminal: add(res, r.nt.name)
   of pkSequence:
     add(res, '(')
@@ -394,7 +482,7 @@ proc toStrAux(r: TPeg, res: var string) =
     add(res, singleQuoteEsc(r.ch))
     add(res, '*')
   of pkGreedyRepSet:
-    add(res, charSetEsc(r.charChoice^))
+    add(res, charSetEsc(r.charChoice[]))
     add(res, '*')
   of pkGreedyAny:
     add(res, ".*")
@@ -410,29 +498,34 @@ proc toStrAux(r: TPeg, res: var string) =
   of pkSearch:
     add(res, '@')
     toStrAux(r.sons[0], res)
+  of pkCapturedSearch:
+    add(res, "{@}")
+    toStrAux(r.sons[0], res)
   of pkCapture:
     add(res, '{')
-    toStrAux(r.sons[0], res)    
+    toStrAux(r.sons[0], res)
     add(res, '}')
-  of pkBackRef: 
+  of pkBackRef:
     add(res, '$')
     add(res, $r.index)
-  of pkBackRefIgnoreCase: 
+  of pkBackRefIgnoreCase:
     add(res, "i$")
     add(res, $r.index)
-  of pkBackRefIgnoreStyle: 
+  of pkBackRefIgnoreStyle:
     add(res, "y$")
     add(res, $r.index)
   of pkRule:
-    toStrAux(r.sons[0], res)    
+    toStrAux(r.sons[0], res)
     add(res, " <- ")
     toStrAux(r.sons[1], res)
   of pkList:
     for i in 0 .. high(r.sons):
       toStrAux(r.sons[i], res)
-      add(res, "\n")  
+      add(res, "\n")
+  of pkStartAnchor:
+    add(res, '^')
 
-proc `$` *(r: TPeg): string =
+func `$` *(r: Peg): string {.rtl, extern: "npegsToString".} =
   ## converts a PEG to its string representation
   result = ""
   toStrAux(r, result)
@@ -440,224 +533,658 @@ proc `$` *(r: TPeg): string =
 # --------------------- core engine -------------------------------------------
 
 type
-  TMatchClosure {.final.} = object
-    matches: array[0..maxSubpatterns-1, tuple[first, last: int]]
+  Captures* = object ## contains the captured substrings.
+    matches: array[0..MaxSubpatterns-1, tuple[first, last: int]]
     ml: int
+    origStart: int
+
+func bounds*(c: Captures,
+             i: range[0..MaxSubpatterns-1]): tuple[first, last: int] =
+  ## returns the bounds ``[first..last]`` of the `i`'th capture.
+  result = c.matches[i]
 
 when not useUnicode:
   type
-    TRune = char
-  template fastRuneAt(s, i, ch: expr) =
+    Rune = char
+  template fastRuneAt(s, i, ch) =
     ch = s[i]
     inc(i)
-  template runeLenAt(s, i: expr): expr = 1
-
-proc m(s: string, p: TPeg, start: int, c: var TMatchClosure): int =
-  ## this implements a simple PEG interpreter. Thanks to superoperators it
-  ## has competitive performance nevertheless.
-  ## Returns -1 if it does not match, else the length of the match
-  case p.kind
-  of pkEmpty: result = 0 # match of length 0
-  of pkAny:
-    if s[start] != '\0': result = 1
-    else: result = -1
-  of pkAnyRune:
-    if s[start] != '\0':
-      result = runeLenAt(s, start)
-    else:
-      result = -1
-  of pkGreedyAny:
-    result = len(s) - start
-  of pkNewLine:
-    if s[start] == '\L': result = 1
-    elif s[start] == '\C':
-      if s[start+1] == '\L': result = 2
-      else: result = 1
-    else: result = -1
-  of pkTerminal:
-    result = len(p.term)
-    for i in 0..result-1:
-      if p.term[i] != s[start+i]:
+  template runeLenAt(s, i): untyped = 1
+
+  func isAlpha(a: char): bool {.inline.} = return a in {'a'..'z', 'A'..'Z'}
+  func isUpper(a: char): bool {.inline.} = return a in {'A'..'Z'}
+  func isLower(a: char): bool {.inline.} = return a in {'a'..'z'}
+  func isTitle(a: char): bool {.inline.} = return false
+  func isWhiteSpace(a: char): bool {.inline.} = return a in {' ', '\9'..'\13'}
+
+template matchOrParse(mopProc: untyped) =
+  # Used to make the main matcher proc *rawMatch* as well as event parser
+  # procs. For the former, *enter* and *leave* event handler code generators
+  # are provided which just return *discard*.
+
+  proc mopProc(s: string, p: Peg, start: int, c: var Captures): int {.gcsafe, raises: [].} =
+    proc matchBackRef(s: string, p: Peg, start: int, c: var Captures): int =
+      # Parse handler code must run in an *of* clause of its own for each
+      # *PegKind*, so we encapsulate the identical clause body for
+      # *pkBackRef..pkBackRefIgnoreStyle* here.
+      var index = p.index
+      if index < 0: index.inc(c.ml)
+      if index < 0 or index >= c.ml: return -1
+      var (a, b) = c.matches[index]
+      var n: Peg
+      case p.kind
+      of pkBackRef:
+        n = Peg(kind: pkTerminal, term: s.substr(a, b))
+      of pkBackRefIgnoreStyle:
+        n = Peg(kind: pkTerminalIgnoreStyle, term: s.substr(a, b))
+      of pkBackRefIgnoreCase:
+        n = Peg(kind: pkTerminalIgnoreCase, term: s.substr(a, b))
+      else: assert(false, "impossible case")
+      mopProc(s, n, start, c)
+
+    case p.kind
+    of pkEmpty:
+      enter(pkEmpty, s, p, start)
+      result = 0 # match of length 0
+      leave(pkEmpty, s, p, start, result)
+    of pkAny:
+      enter(pkAny, s, p, start)
+      if start < s.len: result = 1
+      else: result = -1
+      leave(pkAny, s, p, start, result)
+    of pkAnyRune:
+      enter(pkAnyRune, s, p, start)
+      if start < s.len:
+        result = runeLenAt(s, start)
+      else:
         result = -1
-        break
-  of pkTerminalIgnoreCase:
-    var
-      i = 0
-      a, b: TRune
-    result = start
-    while i < len(p.term):
-      fastRuneAt(p.term, i, a)
-      fastRuneAt(s, result, b)
-      if toLower(a) != toLower(b):
+      leave(pkAnyRune, s, p, start, result)
+    of pkLetter:
+      enter(pkLetter, s, p, start)
+      if start < s.len:
+        var a: Rune
+        result = start
+        fastRuneAt(s, result, a)
+        if isAlpha(a): dec(result, start)
+        else: result = -1
+      else:
         result = -1
-        break
-    dec(result, start)
-  of pkTerminalIgnoreStyle:
-    var
-      i = 0
-      a, b: TRune
-    result = start
-    while i < len(p.term):
-      while true:
+      leave(pkLetter, s, p, start, result)
+    of pkLower:
+      enter(pkLower, s, p, start)
+      if start < s.len:
+        var a: Rune
+        result = start
+        fastRuneAt(s, result, a)
+        if isLower(a): dec(result, start)
+        else: result = -1
+      else:
+        result = -1
+      leave(pkLower, s, p, start, result)
+    of pkUpper:
+      enter(pkUpper, s, p, start)
+      if start < s.len:
+        var a: Rune
+        result = start
+        fastRuneAt(s, result, a)
+        if isUpper(a): dec(result, start)
+        else: result = -1
+      else:
+        result = -1
+      leave(pkUpper, s, p, start, result)
+    of pkTitle:
+      enter(pkTitle, s, p, start)
+      if start < s.len:
+        var a: Rune
+        result = start
+        fastRuneAt(s, result, a)
+        if isTitle(a): dec(result, start)
+        else: result = -1
+      else:
+        result = -1
+      leave(pkTitle, s, p, start, result)
+    of pkWhitespace:
+      enter(pkWhitespace, s, p, start)
+      if start < s.len:
+        var a: Rune
+        result = start
+        fastRuneAt(s, result, a)
+        if isWhiteSpace(a): dec(result, start)
+        else: result = -1
+      else:
+        result = -1
+      leave(pkWhitespace, s, p, start, result)
+    of pkGreedyAny:
+      enter(pkGreedyAny, s, p, start)
+      result = len(s) - start
+      leave(pkGreedyAny, s, p, start, result)
+    of pkNewLine:
+      enter(pkNewLine, s, p, start)
+      if start < s.len and s[start] == '\L': result = 1
+      elif start < s.len and s[start] == '\C':
+        if start+1 < s.len and s[start+1] == '\L': result = 2
+        else: result = 1
+      else: result = -1
+      leave(pkNewLine, s, p, start, result)
+    of pkTerminal:
+      enter(pkTerminal, s, p, start)
+      result = len(p.term)
+      for i in 0..result-1:
+        if start+i >= s.len or p.term[i] != s[start+i]:
+          result = -1
+          break
+      leave(pkTerminal, s, p, start, result)
+    of pkTerminalIgnoreCase:
+      enter(pkTerminalIgnoreCase, s, p, start)
+      var
+        i = 0
+        a, b: Rune
+      result = start
+      while i < len(p.term):
+        if result >= s.len:
+          result = -1
+          break
         fastRuneAt(p.term, i, a)
-        if a != TRune('_'): break
-      while true:
         fastRuneAt(s, result, b)
-        if b != TRune('_'): break
-      if toLower(a) != toLower(b):
-        result = -1
-        break
-    dec(result, start)
-  of pkChar:
-    if p.ch == s[start]: result = 1
-    else: result = -1
-  of pkCharChoice:
-    if contains(p.charChoice^, s[start]): result = 1
-    else: result = -1
-  of pkNonTerminal:
-    var oldMl = c.ml
-    when false: echo "enter: ", p.nt.name
-    result = m(s, p.nt.rule, start, c)
-    when false: echo "leave: ", p.nt.name
-    if result < 0: c.ml = oldMl
-  of pkSequence:
-    var oldMl = c.ml  
-    result = 0
-    for i in 0..high(p.sons):
-      var x = m(s, p.sons[i], start+result, c)
-      if x < 0:
+        if toLower(a) != toLower(b):
+          result = -1
+          break
+      dec(result, start)
+      leave(pkTerminalIgnoreCase, s, p, start, result)
+    of pkTerminalIgnoreStyle:
+      enter(pkTerminalIgnoreStyle, s, p, start)
+      var
+        i = 0
+        a, b: Rune
+      result = start
+      while i < len(p.term):
+        while i < len(p.term):
+          fastRuneAt(p.term, i, a)
+          if a != Rune('_'): break
+        while result < s.len:
+          fastRuneAt(s, result, b)
+          if b != Rune('_'): break
+        if result >= s.len:
+          if i >= p.term.len: break
+          else:
+            result = -1
+            break
+        elif toLower(a) != toLower(b):
+          result = -1
+          break
+      dec(result, start)
+      leave(pkTerminalIgnoreStyle, s, p, start, result)
+    of pkChar:
+      enter(pkChar, s, p, start)
+      if start < s.len and p.ch == s[start]: result = 1
+      else: result = -1
+      leave(pkChar, s, p, start, result)
+    of pkCharChoice:
+      enter(pkCharChoice, s, p, start)
+      if start < s.len and contains(p.charChoice[], s[start]): result = 1
+      else: result = -1
+      leave(pkCharChoice, s, p, start, result)
+    of pkNonTerminal:
+      enter(pkNonTerminal, s, p, start)
+      var oldMl = c.ml
+      when false: echo "enter: ", p.nt.name
+      result = mopProc(s, p.nt.rule, start, c)
+      when false: echo "leave: ", p.nt.name
+      if result < 0: c.ml = oldMl
+      leave(pkNonTerminal, s, p, start, result)
+    of pkSequence:
+      enter(pkSequence, s, p, start)
+      var oldMl = c.ml
+      result = 0
+      for i in 0..high(p.sons):
+        var x = mopProc(s, p.sons[i], start+result, c)
+        if x < 0:
+          c.ml = oldMl
+          result = -1
+          break
+        else: inc(result, x)
+      leave(pkSequence, s, p, start, result)
+    of pkOrderedChoice:
+      enter(pkOrderedChoice, s, p, start)
+      var oldMl = c.ml
+      for i in 0..high(p.sons):
+        result = mopProc(s, p.sons[i], start, c)
+        if result >= 0: break
         c.ml = oldMl
-        result = -1
-        break
-      else: inc(result, x)
-  of pkOrderedChoice:
-    var oldMl = c.ml
-    for i in 0..high(p.sons):
-      result = m(s, p.sons[i], start, c)
-      if result >= 0: break
-      c.ml = oldMl
-  of pkSearch:
-    var oldMl = c.ml
-    result = 0
-    while start+result < s.len:
-      var x = m(s, p.sons[0], start+result, c)
-      if x >= 0:
-        inc(result, x)
-        return
-      inc(result)
-    result = -1
-    c.ml = oldMl
-  of pkGreedyRep:
-    result = 0
-    while true:
-      var x = m(s, p.sons[0], start+result, c)
-      # if x == 0, we have an endless loop; so the correct behaviour would be
-      # not to break. But endless loops can be easily introduced:
-      # ``(comment / \w*)*`` is such an example. Breaking for x == 0 does the
-      # expected thing in this case.
-      if x <= 0: break
-      inc(result, x)
-  of pkGreedyRepChar:
-    result = 0
-    var ch = p.ch
-    while ch == s[start+result]: inc(result)
-  of pkGreedyRepSet:
-    result = 0
-    while contains(p.charChoice^, s[start+result]): inc(result)
-  of pkOption:
-    result = max(0, m(s, p.sons[0], start, c))
-  of pkAndPredicate:
-    var oldMl = c.ml
-    result = m(s, p.sons[0], start, c)
-    if result >= 0: result = 0 # do not consume anything
-    else: c.ml = oldMl
-  of pkNotPredicate:
-    var oldMl = c.ml
-    result = m(s, p.sons[0], start, c)
-    if result < 0: result = 0
-    else:
+      leave(pkOrderedChoice, s, p, start, result)
+    of pkSearch:
+      enter(pkSearch, s, p, start)
+      var oldMl = c.ml
+      result = 0
+      while start+result <= s.len:
+        var x = mopProc(s, p.sons[0], start+result, c)
+        if x >= 0:
+          inc(result, x)
+          leave(pkSearch, s, p, start, result)
+          return
+        inc(result)
+      result = -1
       c.ml = oldMl
+      leave(pkSearch, s, p, start, result)
+    of pkCapturedSearch:
+      enter(pkCapturedSearch, s, p, start)
+      var idx = c.ml # reserve a slot for the subpattern
+      inc(c.ml)
+      result = 0
+      while start+result <= s.len:
+        var x = mopProc(s, p.sons[0], start+result, c)
+        if x >= 0:
+          if idx < MaxSubpatterns:
+            c.matches[idx] = (start, start+result-1)
+          #else: silently ignore the capture
+          inc(result, x)
+          leave(pkCapturedSearch, s, p, start, result)
+          return
+        inc(result)
       result = -1
-  of pkCapture:
-    var idx = c.ml # reserve a slot for the subpattern
-    inc(c.ml)
-    result = m(s, p.sons[0], start, c)
-    if result >= 0:
-      if idx < maxSubpatterns:
-        c.matches[idx] = (start, start+result-1)
-      #else: silently ignore the capture
-    else:
       c.ml = idx
-  of pkBackRef..pkBackRefIgnoreStyle: 
-    if p.index >= c.ml: return -1
-    var (a, b) = c.matches[p.index]
-    var n: TPeg
-    n.kind = succ(pkTerminal, ord(p.kind)-ord(pkBackRef)) 
-    n.term = s.copy(a, b)
-    result = m(s, n, start, c)
-  of pkRule, pkList: assert false
-
-proc match*(s: string, pattern: TPeg, matches: var openarray[string],
-            start = 0): bool =
-  ## returns ``true`` if ``s[start..]`` matches the ``pattern`` and
-  ## the captured substrings in the array ``matches``. If it does not
-  ## match, nothing is written into ``matches`` and ``false`` is
-  ## returned.
-  var c: TMatchClosure
-  result = m(s, pattern, start, c) == len(s) -start
-  if result:
-    for i in 0..c.ml-1:
-      matches[i] = copy(s, c.matches[i][0], c.matches[i][1])
+      leave(pkCapturedSearch, s, p, start, result)
+    of pkGreedyRep:
+      enter(pkGreedyRep, s, p, start)
+      result = 0
+      while true:
+        var x = mopProc(s, p.sons[0], start+result, c)
+        # if x == 0, we have an endless loop; so the correct behaviour would be
+        # not to break. But endless loops can be easily introduced:
+        # ``(comment / \w*)*`` is such an example. Breaking for x == 0 does the
+        # expected thing in this case.
+        if x <= 0: break
+        inc(result, x)
+      leave(pkGreedyRep, s, p, start, result)
+    of pkGreedyRepChar:
+      enter(pkGreedyRepChar, s, p, start)
+      result = 0
+      var ch = p.ch
+      while start+result < s.len and ch == s[start+result]: inc(result)
+      leave(pkGreedyRepChar, s, p, start, result)
+    of pkGreedyRepSet:
+      enter(pkGreedyRepSet, s, p, start)
+      result = 0
+      while start+result < s.len and contains(p.charChoice[], s[start+result]):
+        inc(result)
+      leave(pkGreedyRepSet, s, p, start, result)
+    of pkOption:
+      enter(pkOption, s, p, start)
+      result = max(0, mopProc(s, p.sons[0], start, c))
+      leave(pkOption, s, p, start, result)
+    of pkAndPredicate:
+      enter(pkAndPredicate, s, p, start)
+      var oldMl = c.ml
+      result = mopProc(s, p.sons[0], start, c)
+      if result >= 0: result = 0 # do not consume anything
+      else: c.ml = oldMl
+      leave(pkAndPredicate, s, p, start, result)
+    of pkNotPredicate:
+      enter(pkNotPredicate, s, p, start)
+      var oldMl = c.ml
+      result = mopProc(s, p.sons[0], start, c)
+      if result < 0: result = 0
+      else:
+        c.ml = oldMl
+        result = -1
+      leave(pkNotPredicate, s, p, start, result)
+    of pkCapture:
+      enter(pkCapture, s, p, start)
+      if p.sons.len == 0 or p.sons[0].kind == pkEmpty:
+        # empty capture removes last match
+        dec(c.ml)
+        c.matches[c.ml] = (0, 0)
+        result = 0 # match of length 0
+      else:
+        var idx = c.ml # reserve a slot for the subpattern
+        result = mopProc(s, p.sons[0], start, c)
+        if result >= 0:
+          if idx < MaxSubpatterns:
+            if idx != c.ml:
+              for i in countdown(c.ml, idx):
+                c.matches[i+1] = c.matches[i]
+            c.matches[idx] = (start, start+result-1)
+          #else: silently ignore the capture
+          inc(c.ml)
+      leave(pkCapture, s, p, start, result)
+    of pkBackRef:
+      enter(pkBackRef, s, p, start)
+      result = matchBackRef(s, p, start, c)
+      leave(pkBackRef, s, p, start, result)
+    of pkBackRefIgnoreCase:
+      enter(pkBackRefIgnoreCase, s, p, start)
+      result = matchBackRef(s, p, start, c)
+      leave(pkBackRefIgnoreCase, s, p, start, result)
+    of pkBackRefIgnoreStyle:
+      enter(pkBackRefIgnoreStyle, s, p, start)
+      result = matchBackRef(s, p, start, c)
+      leave(pkBackRefIgnoreStyle, s, p, start, result)
+    of pkStartAnchor:
+      enter(pkStartAnchor, s, p, start)
+      if c.origStart == start: result = 0
+      else: result = -1
+      leave(pkStartAnchor, s, p, start, result)
+    of pkRule, pkList: assert false
+
+func rawMatch*(s: string, p: Peg, start: int, c: var Captures): int
+      {.rtl, extern: "npegs$1".} =
+  ## low-level matching proc that implements the PEG interpreter. Use this
+  ## for maximum efficiency (every other PEG operation ends up calling this
+  ## proc).
+  ## Returns -1 if it does not match, else the length of the match
 
-proc match*(s: string, pattern: TPeg, start = 0): bool =
-  ## returns ``true`` if ``s`` matches the ``pattern`` beginning from ``start``.
-  var c: TMatchClosure
-  result = m(s, pattern, start, c) == len(s)-start
+  # Set the handler generators to produce do-nothing handlers.
+  template enter(pk, s, p, start) =
+    discard
+  template leave(pk, s, p, start, length) =
+    discard
+  matchOrParse(matchIt)
+  {.cast(noSideEffect).}:
+    # This cast is allowed because the `matchOrParse` template is used for
+    # both matching and parsing, but side effects are only possible when it's
+    # used by `eventParser`.
+    result = matchIt(s, p, start, c)
+
+macro mkHandlerTplts(handlers: untyped): untyped =
+  # Transforms the handler spec in *handlers* into handler templates.
+  # The AST structure of *handlers[0]*:
+  #
+  #   ```
+  #   StmtList
+  #     Call
+  #       Ident "pkNonTerminal"
+  #       StmtList
+  #         Call
+  #           Ident "enter"
+  #           StmtList
+  #             <handler code block>
+  #         Call
+  #           Ident "leave"
+  #           StmtList
+  #             <handler code block>
+  #     Call
+  #       Ident "pkChar"
+  #       StmtList
+  #         Call
+  #           Ident "leave"
+  #           StmtList
+  #             <handler code block>
+  #     ...
+  #   ```
+  func mkEnter(hdName, body: NimNode): NimNode =
+    template helper(hdName, body) {.dirty.} =
+      template hdName(s, p, start) =
+        let s {.inject.} = s
+        let p {.inject.} = p
+        let start {.inject.} = start
+        body
+    result = getAst(helper(hdName, body))
+
+  template mkLeave(hdPostf, body) {.dirty.} =
+    # this has to be dirty to be able to capture *result* as *length* in
+    # *leaveXX* calls.
+    template `leave hdPostf`(s, p, start, length) =
+      body
+
+  result = newStmtList()
+  for topCall in handlers[0]:
+    if topCall.kind notin nnkCallKinds:
+      error("Call syntax expected.", topCall)
+    let pegKind = topCall[0]
+    if pegKind.kind notin {nnkIdent, nnkSym}:
+      error("PegKind expected.", pegKind)
+    if 2 == topCall.len:
+      for hdDef in topCall[1]:
+        if hdDef.kind notin nnkCallKinds:
+          error("Call syntax expected.", hdDef)
+        if hdDef[0].kind notin {nnkIdent, nnkSym}:
+          error("Handler identifier expected.", hdDef[0])
+        if 2 == hdDef.len:
+          let hdPostf = substr(pegKind.strVal, 2)
+          case hdDef[0].strVal
+          of "enter":
+            result.add mkEnter(newIdentNode("enter" & hdPostf), hdDef[1])
+          of "leave":
+            result.add getAst(mkLeave(ident(hdPostf), hdDef[1]))
+          else:
+            error(
+              "Unsupported handler identifier, expected 'enter' or 'leave'.",
+              hdDef[0]
+            )
+
+template eventParser*(pegAst, handlers: untyped): (proc(s: string): int) =
+  ## Generates an interpreting event parser *proc* according to the specified
+  ## PEG AST and handler code blocks. The *proc* can be called with a string
+  ## to be parsed and will execute the handler code blocks whenever their
+  ## associated grammar element is matched. It returns -1 if the string does not
+  ## match, else the length of the total match. The following example code
+  ## evaluates an arithmetic expression defined by a simple PEG:
+  ##
+  ##   ```nim
+  ##   import std/[strutils, pegs]
+  ##
+  ##   let
+  ##     pegAst = """
+  ##   Expr    <- Sum
+  ##   Sum     <- Product (('+' / '-')Product)*
+  ##   Product <- Value (('*' / '/')Value)*
+  ##   Value   <- [0-9]+ / '(' Expr ')'
+  ##     """.peg
+  ##     txt = "(5+3)/2-7*22"
+  ##
+  ##   var
+  ##     pStack: seq[string] = @[]
+  ##     valStack: seq[float] = @[]
+  ##     opStack = ""
+  ##   let
+  ##     parseArithExpr = pegAst.eventParser:
+  ##       pkNonTerminal:
+  ##         enter:
+  ##           pStack.add p.nt.name
+  ##         leave:
+  ##           pStack.setLen pStack.high
+  ##           if length > 0:
+  ##             let matchStr = s.substr(start, start+length-1)
+  ##             case p.nt.name
+  ##             of "Value":
+  ##               try:
+  ##                 valStack.add matchStr.parseFloat
+  ##                 echo valStack
+  ##               except ValueError:
+  ##                 discard
+  ##             of "Sum", "Product":
+  ##               try:
+  ##                 let val = matchStr.parseFloat
+  ##               except ValueError:
+  ##                 if valStack.len > 1 and opStack.len > 0:
+  ##                   valStack[^2] = case opStack[^1]
+  ##                   of '+': valStack[^2] + valStack[^1]
+  ##                   of '-': valStack[^2] - valStack[^1]
+  ##                   of '*': valStack[^2] * valStack[^1]
+  ##                   else: valStack[^2] / valStack[^1]
+  ##                   valStack.setLen valStack.high
+  ##                   echo valStack
+  ##                   opStack.setLen opStack.high
+  ##                   echo opStack
+  ##       pkChar:
+  ##         leave:
+  ##           if length == 1 and "Value" != pStack[^1]:
+  ##             let matchChar = s[start]
+  ##             opStack.add matchChar
+  ##             echo opStack
+  ##
+  ##   let pLen = parseArithExpr(txt)
+  ##   ```
+  ##
+  ## The *handlers* parameter consists of code blocks for *PegKinds*,
+  ## which define the grammar elements of interest. Each block can contain
+  ## handler code to be executed when the parser enters and leaves text
+  ## matching the grammar element. An *enter* handler can access the specific
+  ## PEG AST node being matched as *p*, the entire parsed string as *s*
+  ## and the position of the matched text segment in *s* as *start*. A *leave*
+  ## handler can access *p*, *s*, *start* and also the length of the matched
+  ## text segment as *length*. For an unsuccessful match, the *enter* and
+  ## *leave* handlers will be executed, with *length* set to -1.
+  ##
+  ## Symbols  declared in an *enter* handler can be made visible in the
+  ## corresponding *leave* handler by annotating them with an *inject* pragma.
+  proc rawParse(s: string, p: Peg, start: int, c: var Captures): int
+      {.gensym.} =
+
+    # binding from *macros*
+    bind strVal
+
+    mkHandlerTplts:
+      handlers
+
+    macro enter(pegKind, s, pegNode, start: untyped): untyped =
+      # This is called by the matcher code in *matchOrParse* at the
+      # start of the code for a grammar element of kind *pegKind*.
+      # Expands to a call to the handler template if one was generated
+      # by *mkHandlerTplts*.
+      template mkDoEnter(hdPostf, s, pegNode, start) =
+        when declared(`enter hdPostf`):
+          `enter hdPostf`(s, pegNode, start)
+        else:
+          discard
+      let hdPostf = ident(substr($pegKind, 2))
+      getAst(mkDoEnter(hdPostf, s, pegNode, start))
+
+    macro leave(pegKind, s, pegNode, start, length: untyped): untyped =
+      # Like *enter*, but called at the end of the matcher code for
+      # a grammar element of kind *pegKind*.
+      template mkDoLeave(hdPostf, s, pegNode, start, length) =
+        when declared(`leave hdPostf`):
+          `leave hdPostf`(s, pegNode, start, length)
+        else:
+          discard
+      let hdPostf = ident(substr($pegKind, 2))
+      getAst(mkDoLeave(hdPostf, s, pegNode, start, length))
+
+    matchOrParse(parseIt)
+    parseIt(s, p, start, c)
+
+  proc parser(s: string): int {.gensym.} =
+    # the proc to be returned
+    var
+      ms: array[MaxSubpatterns, (int, int)]
+      cs = Captures(matches: ms, ml: 0, origStart: 0)
+    rawParse(s, pegAst, 0, cs)
+  parser
+
+template fillMatches(s, caps, c) =
+  for k in 0..c.ml-1:
+    let startIdx = c.matches[k][0]
+    let endIdx = c.matches[k][1]
+    if startIdx != -1:
+      caps[k] = substr(s, startIdx, endIdx)
+    else:
+      caps[k] = ""
 
-proc matchLen*(s: string, pattern: TPeg, matches: var openarray[string],
-               start = 0): int =
+func matchLen*(s: string, pattern: Peg, matches: var openArray[string],
+               start = 0): int {.rtl, extern: "npegs$1Capture".} =
   ## the same as ``match``, but it returns the length of the match,
   ## if there is no match, -1 is returned. Note that a match length
   ## of zero can happen. It's possible that a suffix of `s` remains
   ## that does not belong to the match.
-  var c: TMatchClosure
-  result = m(s, pattern, start, c)
-  if result >= 0:
-    for i in 0..c.ml-1:
-      matches[i] = copy(s, c.matches[i][0], c.matches[i][1])
+  var c: Captures
+  c.origStart = start
+  result = rawMatch(s, pattern, start, c)
+  if result >= 0: fillMatches(s, matches, c)
 
-proc matchLen*(s: string, pattern: TPeg, start = 0): int =
+func matchLen*(s: string, pattern: Peg,
+               start = 0): int {.rtl, extern: "npegs$1".} =
   ## the same as ``match``, but it returns the length of the match,
   ## if there is no match, -1 is returned. Note that a match length
   ## of zero can happen. It's possible that a suffix of `s` remains
   ## that does not belong to the match.
-  var c: TMatchClosure
-  result = m(s, pattern, start, c)
+  var c: Captures
+  c.origStart = start
+  result = rawMatch(s, pattern, start, c)
+
+func match*(s: string, pattern: Peg, matches: var openArray[string],
+            start = 0): bool {.rtl, extern: "npegs$1Capture".} =
+  ## returns ``true`` if ``s[start..]`` matches the ``pattern`` and
+  ## the captured substrings in the array ``matches``. If it does not
+  ## match, nothing is written into ``matches`` and ``false`` is
+  ## returned.
+  result = matchLen(s, pattern, matches, start) != -1
+
+func match*(s: string, pattern: Peg,
+            start = 0): bool {.rtl, extern: "npegs$1".} =
+  ## returns ``true`` if ``s`` matches the ``pattern`` beginning from ``start``.
+  result = matchLen(s, pattern, start) != -1
+
 
-proc find*(s: string, pattern: TPeg, matches: var openarray[string],
-           start = 0): int =
+func find*(s: string, pattern: Peg, matches: var openArray[string],
+           start = 0): int {.rtl, extern: "npegs$1Capture".} =
   ## returns the starting position of ``pattern`` in ``s`` and the captured
   ## substrings in the array ``matches``. If it does not match, nothing
   ## is written into ``matches`` and -1 is returned.
-  for i in 0 .. s.len-1:
-    if matchLen(s, pattern, matches, i) >= 0: return i
+  var c: Captures
+  c.origStart = start
+  for i in start .. s.len-1:
+    c.ml = 0
+    if rawMatch(s, pattern, i, c) >= 0:
+      fillMatches(s, matches, c)
+      return i
   return -1
   # could also use the pattern here: (!P .)* P
-  
-proc find*(s: string, pattern: TPeg, start = 0): int =
+
+func findBounds*(s: string, pattern: Peg, matches: var openArray[string],
+                 start = 0): tuple[first, last: int] {.
+                 rtl, extern: "npegs$1Capture".} =
+  ## returns the starting position and end position of ``pattern`` in ``s``
+  ## and the captured
+  ## substrings in the array ``matches``. If it does not match, nothing
+  ## is written into ``matches`` and (-1,0) is returned.
+  var c: Captures
+  c.origStart = start
+  for i in start .. s.len-1:
+    c.ml = 0
+    var L = rawMatch(s, pattern, i, c)
+    if L >= 0:
+      fillMatches(s, matches, c)
+      return (i, i+L-1)
+  return (-1, 0)
+
+func find*(s: string, pattern: Peg,
+           start = 0): int {.rtl, extern: "npegs$1".} =
   ## returns the starting position of ``pattern`` in ``s``. If it does not
   ## match, -1 is returned.
-  for i in 0 .. s.len-1:
-    if matchLen(s, pattern, i) >= 0: return i
+  var c: Captures
+  c.origStart = start
+  for i in start .. s.len-1:
+    if rawMatch(s, pattern, i, c) >= 0: return i
   return -1
-  
-template `=~`*(s: string, pattern: TPeg): expr =
-  ## This calls ``match`` with an implicit declared ``matches`` array that 
-  ## can be used in the scope of the ``=~`` call: 
-  ## 
-  ## .. code-block:: nimrod
+
+iterator findAll*(s: string, pattern: Peg, start = 0): string =
+  ## yields all matching *substrings* of `s` that match `pattern`.
+  var c: Captures
+  c.origStart = start
+  var i = start
+  while i < s.len:
+    c.ml = 0
+    var L = rawMatch(s, pattern, i, c)
+    if L < 0:
+      inc(i, 1)
+    else:
+      yield substr(s, i, i+L-1)
+      inc(i, L)
+
+func findAll*(s: string, pattern: Peg, start = 0): seq[string] {.
+  rtl, extern: "npegs$1".} =
+  ## returns all matching *substrings* of `s` that match `pattern`.
+  ## If it does not match, `@[]` is returned.
+  result = @[]
+  for it in findAll(s, pattern, start): result.add it
+
+template `=~`*(s: string, pattern: Peg): bool =
+  ## This calls ``match`` with an implicit declared ``matches`` array that
+  ## can be used in the scope of the ``=~`` call:
   ##
-  ##   if line =~ peg"\s* {\w+} \s* '=' \s* {\w+}": 
+  ##   ```nim
+  ##   if line =~ peg"\s* {\w+} \s* '=' \s* {\w+}":
   ##     # matches a key=value pair:
   ##     echo("Key: ", matches[0])
   ##     echo("Value: ", matches[1])
@@ -668,197 +1195,283 @@ template `=~`*(s: string, pattern: TPeg): expr =
   ##     echo("comment: ", matches[0])
   ##   else:
   ##     echo("syntax error")
-  ##  
-  when not definedInScope(matches):
-    var matches: array[0..maxSubpatterns-1, string]
+  ##   ```
+  bind MaxSubpatterns
+  when not declaredInScope(matches):
+    var matches {.inject.} = default(array[0..MaxSubpatterns-1, string])
   match(s, pattern, matches)
 
 # ------------------------- more string handling ------------------------------
 
-proc contains*(s: string, pattern: TPeg, start = 0): bool =
+func contains*(s: string, pattern: Peg, start = 0): bool {.
+  rtl, extern: "npegs$1".} =
   ## same as ``find(s, pattern, start) >= 0``
   return find(s, pattern, start) >= 0
 
-proc contains*(s: string, pattern: TPeg, matches: var openArray[string],
-              start = 0): bool =
+func contains*(s: string, pattern: Peg, matches: var openArray[string],
+              start = 0): bool {.rtl, extern: "npegs$1Capture".} =
   ## same as ``find(s, pattern, matches, start) >= 0``
   return find(s, pattern, matches, start) >= 0
 
-proc startsWith*(s: string, prefix: TPeg): bool =
+func startsWith*(s: string, prefix: Peg, start = 0): bool {.
+  rtl, extern: "npegs$1".} =
   ## returns true if `s` starts with the pattern `prefix`
-  result = matchLen(s, prefix) >= 0
-
-proc endsWith*(s: string, suffix: TPeg): bool =
-  ## returns true if `s` ends with the pattern `prefix`
-  for i in 0 .. s.len-1:
-    if matchLen(s, suffix, i) == s.len - i: return true
-
-proc replace*(s: string, sub: TPeg, by: string): string =
+  result = matchLen(s, prefix, start) >= 0
+
+func endsWith*(s: string, suffix: Peg, start = 0): bool {.
+  rtl, extern: "npegs$1".} =
+  ## returns true if `s` ends with the pattern `suffix`
+  var c: Captures
+  c.origStart = start
+  for i in start .. s.len-1:
+    if rawMatch(s, suffix, i, c) == s.len - i: return true
+
+func replacef*(s: string, sub: Peg, by: string): string {.
+  rtl, extern: "npegs$1".} =
   ## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by`
   ## with the notation ``$i`` and ``$#`` (see strutils.`%`). Examples:
   ##
-  ## .. code-block:: nimrod
-  ##   "var1=key; var2=key2".replace(peg"{\ident}'='{\ident}", "$1<-$2$2")
+  ##   ```nim
+  ##   "var1=key; var2=key2".replacef(peg"{\ident}'='{\ident}", "$1<-$2$2")
+  ##   ```
   ##
   ## Results in:
   ##
-  ## .. code-block:: nimrod
-  ##
+  ##   ```nim
   ##   "var1<-keykey; val2<-key2key2"
+  ##   ```
   result = ""
   var i = 0
-  var caps: array[0..maxSubpatterns-1, string]
+  var caps: array[0..MaxSubpatterns-1, string]
+  var c: Captures
   while i < s.len:
-    var x = matchLen(s, sub, caps, i)
+    c.ml = 0
+    var x = rawMatch(s, sub, i, c)
     if x <= 0:
       add(result, s[i])
       inc(i)
     else:
+      fillMatches(s, caps, c)
       addf(result, by, caps)
       inc(i, x)
-  # copy the rest:
-  add(result, copy(s, i))
-  
-proc parallelReplace*(s: string, subs: openArray[
-                      tuple[pattern: TPeg, repl: string]]): string = 
+  add(result, substr(s, i))
+
+func replace*(s: string, sub: Peg, by = ""): string {.
+  rtl, extern: "npegs$1".} =
+  ## Replaces `sub` in `s` by the string `by`. Captures cannot be accessed
+  ## in `by`.
+  result = ""
+  var i = 0
+  var c: Captures
+  while i < s.len:
+    var x = rawMatch(s, sub, i, c)
+    if x <= 0:
+      add(result, s[i])
+      inc(i)
+    else:
+      add(result, by)
+      inc(i, x)
+  add(result, substr(s, i))
+
+func parallelReplace*(s: string, subs: varargs[
+                      tuple[pattern: Peg, repl: string]]): string {.
+                      rtl, extern: "npegs$1".} =
   ## Returns a modified copy of `s` with the substitutions in `subs`
   ## applied in parallel.
   result = ""
   var i = 0
-  var caps: array[0..maxSubpatterns-1, string]
+  var c: Captures
+  var caps: array[0..MaxSubpatterns-1, string]
   while i < s.len:
     block searchSubs:
       for j in 0..high(subs):
-        var x = matchLen(s, subs[j][0], caps, i)
+        c.ml = 0
+        var x = rawMatch(s, subs[j][0], i, c)
         if x > 0:
+          fillMatches(s, caps, c)
           addf(result, subs[j][1], caps)
           inc(i, x)
           break searchSubs
       add(result, s[i])
       inc(i)
   # copy the rest:
-  add(result, copy(s, i))  
-  
-proc transformFile*(infile, outfile: string,
-                    subs: openArray[tuple[pattern: TPeg, repl: string]]) =
-  ## reads in the file `infile`, performs a parallel replacement (calls
-  ## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
-  ## error occurs. This is supposed to be used for quick scripting.
-  var x = readFile(infile)
-  if not isNil(x):
-    var f: TFile
-    if open(f, outfile, fmWrite):
-      write(f, x.parallelReplace(subs))
-      close(f)
+  add(result, substr(s, i))
+
+when not defined(nimHasEffectsOf):
+  {.pragma: effectsOf.}
+
+func replace*(s: string, sub: Peg, cb: proc(
+              match: int, cnt: int, caps: openArray[string]): string): string {.
+              rtl, extern: "npegs$1cb", effectsOf: cb.} =
+  ## Replaces `sub` in `s` by the resulting strings from the callback.
+  ## The callback proc receives the index of the current match (starting with 0),
+  ## the count of captures and an open array with the captures of each match. Examples:
+  ##
+  ##   ```nim
+  ##   func handleMatches*(m: int, n: int, c: openArray[string]): string =
+  ##     result = ""
+  ##     if m > 0:
+  ##       result.add ", "
+  ##     result.add case n:
+  ##       of 2: c[0].toLower & ": '" & c[1] & "'"
+  ##       of 1: c[0].toLower & ": ''"
+  ##       else: ""
+  ##
+  ##   let s = "Var1=key1;var2=Key2;   VAR3"
+  ##   echo s.replace(peg"{\ident}('='{\ident})* ';'* \s*", handleMatches)
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```nim
+  ##   "var1: 'key1', var2: 'Key2', var3: ''"
+  ##   ```
+  result = ""
+  var i = 0
+  var caps: array[0..MaxSubpatterns-1, string]
+  var c: Captures
+  var m = 0
+  while i < s.len:
+    c.ml = 0
+    var x = rawMatch(s, sub, i, c)
+    if x <= 0:
+      add(result, s[i])
+      inc(i)
     else:
-      quit("cannot open for writing: " & outfile)
-  else:
-    quit("cannot open for reading: " & infile)
-  
-iterator split*(s: string, sep: TPeg): string =
+      fillMatches(s, caps, c)
+      add(result, cb(m, c.ml, caps))
+      inc(i, x)
+      inc(m)
+  add(result, substr(s, i))
+
+when not defined(js):
+  proc transformFile*(infile, outfile: string,
+                      subs: varargs[tuple[pattern: Peg, repl: string]]) {.
+                      rtl, extern: "npegs$1".} =
+    ## reads in the file `infile`, performs a parallel replacement (calls
+    ## `parallelReplace`) and writes back to `outfile`. Raises ``IOError`` if an
+    ## error occurs. This is supposed to be used for quick scripting.
+    ##
+    ## **Note**: this proc does not exist while using the JS backend.
+    var x = readFile(infile)
+    writeFile(outfile, x.parallelReplace(subs))
+
+
+iterator split*(s: string, sep: Peg): string =
   ## Splits the string `s` into substrings.
   ##
   ## Substrings are separated by the PEG `sep`.
   ## Examples:
   ##
-  ## .. code-block:: nimrod
+  ##   ```nim
   ##   for word in split("00232this02939is39an22example111", peg"\d+"):
-  ##     writeln(stdout, word)
+  ##     writeLine(stdout, word)
+  ##   ```
   ##
   ## Results in:
   ##
-  ## .. code-block:: nimrod
+  ##   ```nim
   ##   "this"
   ##   "is"
   ##   "an"
   ##   "example"
-  ##
+  ##   ```
+  var c: Captures
   var
     first = 0
     last = 0
   while last < len(s):
-    var x = matchLen(s, sep, last)
+    c.ml = 0
+    var x = rawMatch(s, sep, last, c)
     if x > 0: inc(last, x)
     first = last
     while last < len(s):
       inc(last)
-      x = matchLen(s, sep, last)
+      c.ml = 0
+      x = rawMatch(s, sep, last, c)
       if x > 0: break
     if first < last:
-      yield copy(s, first, last-1)
+      yield substr(s, first, last-1)
 
-proc split*(s: string, sep: TPeg): seq[string] {.noSideEffect.} =
+func split*(s: string, sep: Peg): seq[string] {.
+  rtl, extern: "npegs$1".} =
   ## Splits the string `s` into substrings.
-  accumulateResult(split(s, sep))
+  result = @[]
+  for it in split(s, sep): result.add it
 
 # ------------------- scanner -------------------------------------------------
 
 type
-  TModifier = enum
+  Modifier = enum
     modNone,
     modVerbatim,
     modIgnoreCase,
     modIgnoreStyle
-  TTokKind = enum       ## enumeration of all tokens
-    tkInvalid,          ## invalid token
-    tkEof,              ## end of file reached
-    tkAny,              ## .
-    tkAnyRune,          ## _
-    tkIdentifier,       ## abc
-    tkStringLit,        ## "abc" or 'abc'
-    tkCharSet,          ## [^A-Z]
-    tkParLe,            ## '('
-    tkParRi,            ## ')'
-    tkCurlyLe,          ## '{'
-    tkCurlyRi,          ## '}'
-    tkArrow,            ## '<-'
-    tkBar,              ## '/'
-    tkStar,             ## '*'
-    tkPlus,             ## '+'
-    tkAmp,              ## '&'
-    tkNot,              ## '!'
-    tkOption,           ## '?'
-    tkAt,               ## '@'
-    tkBuiltin,          ## \identifier
-    tkEscaped,          ## \\
-    tkDollar            ## '$'
-  
-  TToken {.final.} = object  ## a token
-    kind: TTokKind           ## the type of the token
-    modifier: TModifier
-    literal: string          ## the parsed (string) literal
-    charset: set[char]       ## if kind == tkCharSet
-    index: int               ## if kind == tkDollar
-  
-  TPegLexer = object          ## the lexer object.
-    bufpos: int               ## the current position within the buffer
-    buf: cstring              ## the buffer itself
-    LineNumber: int           ## the current line number
-    lineStart: int            ## index of last line start in buffer
-    colOffset: int            ## column to add
+  TokKind = enum  ## enumeration of all tokens
+    tkInvalid,    ## invalid token
+    tkEof,        ## end of file reached
+    tkAny,        ## .
+    tkAnyRune,    ## _
+    tkIdentifier, ## abc
+    tkStringLit,  ## "abc" or 'abc'
+    tkCharSet,    ## [^A-Z]
+    tkParLe,      ## '('
+    tkParRi,      ## ')'
+    tkCurlyLe,    ## '{'
+    tkCurlyRi,    ## '}'
+    tkCurlyAt,    ## '{@}'
+    tkEmptyCurl,  ## '{}'
+    tkArrow,      ## '<-'
+    tkBar,        ## '/'
+    tkStar,       ## '*'
+    tkPlus,       ## '+'
+    tkAmp,        ## '&'
+    tkNot,        ## '!'
+    tkOption,     ## '?'
+    tkAt,         ## '@'
+    tkBuiltin,    ## \identifier
+    tkEscaped,    ## \\
+    tkBackref,    ## '$'
+    tkDollar,     ## '$'
+    tkHat         ## '^'
+
+  Token {.final.} = object ## a token
+    kind: TokKind          ## the type of the token
+    modifier: Modifier
+    literal: string        ## the parsed (string) literal
+    charset: set[char]     ## if kind == tkCharSet
+    index: int             ## if kind == tkBackref
+
+  PegLexer {.inheritable.} = object ## the lexer object.
+    bufpos: int                     ## the current position within the buffer
+    buf: string                     ## the buffer itself
+    lineNumber: int                 ## the current line number
+    lineStart: int                  ## index of last line start in buffer
+    colOffset: int                  ## column to add
     filename: string
 
 const
-  tokKindToStr: array[TTokKind, string] = [
+  tokKindToStr: array[TokKind, string] = [
     "invalid", "[EOF]", ".", "_", "identifier", "string literal",
-    "character set", "(", ")", "{", "}", "<-", "/", "*", "+", "&", "!", "?",
-    "@", "built-in", "escaped", "$"
+    "character set", "(", ")", "{", "}", "{@}", "{}",
+    "<-", "/", "*", "+", "&", "!", "?",
+    "@", "built-in", "escaped", "$", "$", "^"
   ]
 
-proc HandleCR(L: var TPegLexer, pos: int): int =
+func handleCR(L: var PegLexer, pos: int): int =
   assert(L.buf[pos] == '\c')
-  inc(L.linenumber)
+  inc(L.lineNumber)
   result = pos+1
-  if L.buf[result] == '\L': inc(result)
+  if result < L.buf.len and L.buf[result] == '\L': inc(result)
   L.lineStart = result
 
-proc HandleLF(L: var TPegLexer, pos: int): int =
+func handleLF(L: var PegLexer, pos: int): int =
   assert(L.buf[pos] == '\L')
-  inc(L.linenumber)
+  inc(L.lineNumber)
   result = pos+1
   L.lineStart = result
 
-proc init(L: var TPegLexer, input, filename: string, line = 1, col = 0) = 
+func init(L: var PegLexer, input, filename: string, line = 1, col = 0) =
   L.buf = input
   L.bufpos = 0
   L.lineNumber = line
@@ -866,69 +1479,64 @@ proc init(L: var TPegLexer, input, filename: string, line = 1, col = 0) =
   L.lineStart = 0
   L.filename = filename
 
-proc getColumn(L: TPegLexer): int {.inline.} = 
+func getColumn(L: PegLexer): int {.inline.} =
   result = abs(L.bufpos - L.lineStart) + L.colOffset
 
-proc getLine(L: TPegLexer): int {.inline.} = 
-  result = L.linenumber
-  
-proc errorStr(L: TPegLexer, msg: string, line = -1, col = -1): string =
+func getLine(L: PegLexer): int {.inline.} =
+  result = L.lineNumber
+
+func errorStr(L: PegLexer, msg: string, line = -1, col = -1): string =
   var line = if line < 0: getLine(L) else: line
   var col = if col < 0: getColumn(L) else: col
   result = "$1($2, $3) Error: $4" % [L.filename, $line, $col, msg]
 
-proc handleHexChar(c: var TPegLexer, xi: var int) = 
-  case c.buf[c.bufpos]
-  of '0'..'9': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0'))
-    inc(c.bufpos)
-  of 'a'..'f': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('a') + 10)
-    inc(c.bufpos)
-  of 'A'..'F': 
-    xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10)
-    inc(c.bufpos)
-  else: nil
-
-proc getEscapedChar(c: var TPegLexer, tok: var TToken) = 
+func getEscapedChar(c: var PegLexer, tok: var Token) =
   inc(c.bufpos)
+  if c.bufpos >= len(c.buf):
+    tok.kind = tkInvalid
+    return
   case c.buf[c.bufpos]
-  of 'r', 'R', 'c', 'C': 
+  of 'r', 'R', 'c', 'C':
     add(tok.literal, '\c')
-    Inc(c.bufpos)
-  of 'l', 'L': 
+    inc(c.bufpos)
+  of 'l', 'L':
     add(tok.literal, '\L')
-    Inc(c.bufpos)
-  of 'f', 'F': 
+    inc(c.bufpos)
+  of 'f', 'F':
     add(tok.literal, '\f')
     inc(c.bufpos)
-  of 'e', 'E': 
+  of 'e', 'E':
     add(tok.literal, '\e')
-    Inc(c.bufpos)
-  of 'a', 'A': 
+    inc(c.bufpos)
+  of 'a', 'A':
     add(tok.literal, '\a')
-    Inc(c.bufpos)
-  of 'b', 'B': 
+    inc(c.bufpos)
+  of 'b', 'B':
     add(tok.literal, '\b')
-    Inc(c.bufpos)
-  of 'v', 'V': 
+    inc(c.bufpos)
+  of 'v', 'V':
     add(tok.literal, '\v')
-    Inc(c.bufpos)
-  of 't', 'T': 
+    inc(c.bufpos)
+  of 't', 'T':
     add(tok.literal, '\t')
-    Inc(c.bufpos)
-  of 'x', 'X': 
     inc(c.bufpos)
+  of 'x', 'X':
+    inc(c.bufpos)
+    if c.bufpos >= len(c.buf):
+      tok.kind = tkInvalid
+      return
     var xi = 0
-    handleHexChar(c, xi)
-    handleHexChar(c, xi)
+    if handleHexChar(c.buf[c.bufpos], xi):
+      inc(c.bufpos)
+      if handleHexChar(c.buf[c.bufpos], xi):
+        inc(c.bufpos)
     if xi == 0: tok.kind = tkInvalid
-    else: add(tok.literal, Chr(xi))
-  of '0'..'9': 
+    else: add(tok.literal, chr(xi))
+  of '0'..'9':
     var val = ord(c.buf[c.bufpos]) - ord('0')
-    Inc(c.bufpos)
+    inc(c.bufpos)
     var i = 1
-    while (i <= 3) and (c.buf[c.bufpos] in {'0'..'9'}): 
+    while (c.bufpos < len(c.buf)) and (i <= 3) and (c.buf[c.bufpos] in {'0'..'9'}):
       val = val * 10 + ord(c.buf[c.bufpos]) - ord('0')
       inc(c.bufpos)
       inc(i)
@@ -936,38 +1544,35 @@ proc getEscapedChar(c: var TPegLexer, tok: var TToken) =
     else: tok.kind = tkInvalid
   of '\0'..'\31':
     tok.kind = tkInvalid
-  elif c.buf[c.bufpos] in strutils.letters:
+  elif c.buf[c.bufpos] in strutils.Letters:
     tok.kind = tkInvalid
   else:
     add(tok.literal, c.buf[c.bufpos])
-    Inc(c.bufpos)
-  
-proc skip(c: var TPegLexer) = 
+    inc(c.bufpos)
+
+func skip(c: var PegLexer) =
   var pos = c.bufpos
-  var buf = c.buf
-  while true: 
-    case buf[pos]
-    of ' ', '\t': 
-      Inc(pos)
+  while pos < c.buf.len:
+    case c.buf[pos]
+    of ' ', '\t':
+      inc(pos)
     of '#':
-      while not (buf[pos] in {'\c', '\L', '\0'}): inc(pos)
+      while (pos < c.buf.len) and
+             not (c.buf[pos] in {'\c', '\L', '\0'}): inc(pos)
     of '\c':
-      pos = HandleCR(c, pos)
-      buf = c.buf
-    of '\L': 
-      pos = HandleLF(c, pos)
-      buf = c.buf
-    else: 
-      break                   # EndOfFile also leaves the loop
+      pos = handleCR(c, pos)
+    of '\L':
+      pos = handleLF(c, pos)
+    else:
+      break # EndOfFile also leaves the loop
   c.bufpos = pos
-  
-proc getString(c: var TPegLexer, tok: var TToken) = 
+
+func getString(c: var PegLexer, tok: var Token) =
   tok.kind = tkStringLit
-  var pos = c.bufPos + 1
-  var buf = c.buf
-  var quote = buf[pos-1]
-  while true: 
-    case buf[pos]
+  var pos = c.bufpos + 1
+  var quote = c.buf[pos-1]
+  while pos < c.buf.len:
+    case c.buf[pos]
     of '\\':
       c.bufpos = pos
       getEscapedChar(c, tok)
@@ -975,90 +1580,102 @@ proc getString(c: var TPegLexer, tok: var TToken) =
     of '\c', '\L', '\0':
       tok.kind = tkInvalid
       break
-    elif buf[pos] == quote:
+    elif c.buf[pos] == quote:
       inc(pos)
-      break      
+      break
     else:
-      add(tok.literal, buf[pos])
-      Inc(pos)
+      add(tok.literal, c.buf[pos])
+      inc(pos)
   c.bufpos = pos
-  
-proc getDollar(c: var TPegLexer, tok: var TToken) = 
-  var pos = c.bufPos + 1
-  var buf = c.buf
-  if buf[pos] in {'0'..'9'}:
-    tok.kind = tkDollar
+
+func getDollar(c: var PegLexer, tok: var Token) =
+  var pos = c.bufpos + 1
+  var neg = false
+  if pos < c.buf.len and c.buf[pos] == '^':
+    neg = true
+    inc(pos)
+  if pos < c.buf.len and c.buf[pos] in {'0'..'9'}:
+    tok.kind = tkBackref
     tok.index = 0
-    while buf[pos] in {'0'..'9'}:
-      tok.index = tok.index * 10 + ord(buf[pos]) - ord('0')
+    while pos < c.buf.len and c.buf[pos] in {'0'..'9'}:
+      tok.index = tok.index * 10 + ord(c.buf[pos]) - ord('0')
       inc(pos)
+    if neg:
+      tok.index = -tok.index
   else:
-    tok.kind = tkInvalid
+    if neg:
+      dec(pos)
+    tok.kind = tkDollar
   c.bufpos = pos
-  
-proc getCharSet(c: var TPegLexer, tok: var TToken) = 
+
+func getCharSet(c: var PegLexer, tok: var Token) =
   tok.kind = tkCharSet
   tok.charset = {}
-  var pos = c.bufPos + 1
-  var buf = c.buf
+  var pos = c.bufpos + 1
   var caret = false
-  if buf[pos] == '^':
-    inc(pos)
-    caret = true
-  while true:
-    var ch: char
-    case buf[pos]
-    of ']':
+  if pos < c.buf.len:
+    if c.buf[pos] == '^':
       inc(pos)
-      break
-    of '\\':
-      c.bufpos = pos
-      getEscapedChar(c, tok)
-      pos = c.bufpos
-      ch = tok.literal[tok.literal.len-1]
-    of '\C', '\L', '\0':
-      tok.kind = tkInvalid
-      break
-    else: 
-      ch = buf[pos]
-      Inc(pos)
-    incl(tok.charset, ch)
-    if buf[pos] == '-':
-      if buf[pos+1] == ']':
-        incl(tok.charset, '-')
-        inc(pos)
+      caret = true
+    while pos < c.buf.len:
+      var ch: char
+      case c.buf[pos]
+      of ']':
+        if pos < c.buf.len: inc(pos)
+        break
+      of '\\':
+        c.bufpos = pos
+        getEscapedChar(c, tok)
+        pos = c.bufpos
+        ch = tok.literal[tok.literal.len-1]
+      of '\C', '\L', '\0':
+        tok.kind = tkInvalid
+        break
       else:
+        ch = c.buf[pos]
         inc(pos)
-        var ch2: char
-        case buf[pos]
-        of '\\':
-          c.bufpos = pos
-          getEscapedChar(c, tok)
-          pos = c.bufpos
-          ch2 = tok.literal[tok.literal.len-1]
-        of '\C', '\L', '\0':
-          tok.kind = tkInvalid
-          break
-        else: 
-          ch2 = buf[pos]
-          Inc(pos)
-        for i in ord(ch)+1 .. ord(ch2):
-          incl(tok.charset, chr(i))
+      incl(tok.charset, ch)
+      if c.buf[pos] == '-':
+        if pos+1 < c.buf.len and c.buf[pos+1] == ']':
+          incl(tok.charset, '-')
+          inc(pos)
+        else:
+          if pos+1 < c.buf.len:
+            inc(pos)
+          else:
+            break
+          var ch2: char
+          case c.buf[pos]
+          of '\\':
+            c.bufpos = pos
+            getEscapedChar(c, tok)
+            pos = c.bufpos
+            ch2 = tok.literal[tok.literal.len-1]
+          of '\C', '\L', '\0':
+            tok.kind = tkInvalid
+            break
+          else:
+            if pos+1 < c.buf.len:
+              ch2 = c.buf[pos]
+              inc(pos)
+            else:
+              break
+          for i in ord(ch)+1 .. ord(ch2):
+            incl(tok.charset, chr(i))
   c.bufpos = pos
   if caret: tok.charset = {'\1'..'\xFF'} - tok.charset
-  
-proc getSymbol(c: var TPegLexer, tok: var TToken) = 
+
+func getSymbol(c: var PegLexer, tok: var Token) =
   var pos = c.bufpos
-  var buf = c.buf
-  while true: 
-    add(tok.literal, buf[pos])
-    Inc(pos)
-    if buf[pos] notin strutils.IdentChars: break
+  while pos < c.buf.len:
+    add(tok.literal, c.buf[pos])
+    inc(pos)
+    if pos < c.buf.len and c.buf[pos] notin strutils.IdentChars: break
   c.bufpos = pos
   tok.kind = tkIdentifier
 
-proc getBuiltin(c: var TPegLexer, tok: var TToken) =
-  if c.buf[c.bufpos+1] in strutils.Letters:
+func getBuiltin(c: var PegLexer, tok: var Token) =
+  if c.bufpos+1 < c.buf.len and c.buf[c.bufpos+1] in strutils.Letters:
     inc(c.bufpos)
     getSymbol(c, tok)
     tok.kind = tkBuiltin
@@ -1066,31 +1683,49 @@ proc getBuiltin(c: var TPegLexer, tok: var TToken) =
     tok.kind = tkEscaped
     getEscapedChar(c, tok) # may set tok.kind to tkInvalid
 
-proc getTok(c: var TPegLexer, tok: var TToken) = 
+func getTok(c: var PegLexer, tok: var Token) =
   tok.kind = tkInvalid
   tok.modifier = modNone
-  setlen(tok.literal, 0)
+  setLen(tok.literal, 0)
   skip(c)
+
+  if c.bufpos >= c.buf.len:
+    tok.kind = tkEof
+    tok.literal = "[EOF]"
+    add(tok.literal, '\0')
+    inc(c.bufpos)
+    return
+
   case c.buf[c.bufpos]
   of '{':
-    tok.kind = tkCurlyLe
     inc(c.bufpos)
-    add(tok.literal, '{')
-  of '}': 
+    if c.buf[c.bufpos] == '@' and c.bufpos+2 < c.buf.len and
+      c.buf[c.bufpos+1] == '}':
+      tok.kind = tkCurlyAt
+      inc(c.bufpos, 2)
+      add(tok.literal, "{@}")
+    elif c.buf[c.bufpos] == '}' and c.bufpos < c.buf.len:
+      tok.kind = tkEmptyCurl
+      inc(c.bufpos)
+      add(tok.literal, "{}")
+    else:
+      tok.kind = tkCurlyLe
+      add(tok.literal, '{')
+  of '}':
     tok.kind = tkCurlyRi
     inc(c.bufpos)
     add(tok.literal, '}')
-  of '[': 
-    getCharset(c, tok)
+  of '[':
+    getCharSet(c, tok)
   of '(':
     tok.kind = tkParLe
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, '(')
   of ')':
     tok.kind = tkParRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, ')')
-  of '.': 
+  of '.':
     tok.kind = tkAny
     inc(c.bufpos)
     add(tok.literal, '.')
@@ -1098,21 +1733,22 @@ proc getTok(c: var TPegLexer, tok: var TToken) =
     tok.kind = tkAnyRune
     inc(c.bufpos)
     add(tok.literal, '_')
-  of '\\': 
+  of '\\':
     getBuiltin(c, tok)
   of '\'', '"': getString(c, tok)
   of '$': getDollar(c, tok)
-  of '\0': 
-    tok.kind = tkEof
-    tok.literal = "[EOF]"
   of 'a'..'z', 'A'..'Z', '\128'..'\255':
     getSymbol(c, tok)
-    if c.buf[c.bufpos] in {'\'', '"', '$'}:
+    if c.bufpos >= c.buf.len:
+      return
+    if c.buf[c.bufpos] in {'\'', '"'} or
+        c.buf[c.bufpos] == '$' and c.bufpos+1 < c.buf.len and
+        c.buf[c.bufpos+1] in {'^', '0'..'9'}:
       case tok.literal
       of "i": tok.modifier = modIgnoreCase
       of "y": tok.modifier = modIgnoreStyle
       of "v": tok.modifier = modVerbatim
-      else: nil
+      else: discard
       setLen(tok.literal, 0)
       if c.buf[c.bufpos] == '$':
         getDollar(c, tok)
@@ -1128,7 +1764,7 @@ proc getTok(c: var TPegLexer, tok: var TToken) =
     inc(c.bufpos)
     add(tok.literal, '+')
   of '<':
-    if c.buf[c.bufpos+1] == '-':
+    if c.bufpos+2 < c.buf.len and c.buf[c.bufpos+1] == '-':
       inc(c.bufpos, 2)
       tok.kind = tkArrow
       add(tok.literal, "<-")
@@ -1154,43 +1790,57 @@ proc getTok(c: var TPegLexer, tok: var TToken) =
     tok.kind = tkAt
     inc(c.bufpos)
     add(tok.literal, '@')
+    if c.buf[c.bufpos] == '@':
+      tok.kind = tkCurlyAt
+      inc(c.bufpos)
+      add(tok.literal, '@')
+  of '^':
+    tok.kind = tkHat
+    inc(c.bufpos)
+    add(tok.literal, '^')
   else:
+    if c.bufpos >= c.buf.len:
+      tok.kind = tkEof
+      tok.literal = "[EOF]"
     add(tok.literal, c.buf[c.bufpos])
     inc(c.bufpos)
 
-proc arrowIsNextTok(c: TPegLexer): bool =
+func arrowIsNextTok(c: PegLexer): bool =
   # the only look ahead we need
   var pos = c.bufpos
-  while c.buf[pos] in {'\t', ' '}: inc(pos)
+  while pos < c.buf.len and c.buf[pos] in {'\t', ' '}: inc(pos)
+  if pos+1 >= c.buf.len:
+    return
   result = c.buf[pos] == '<' and c.buf[pos+1] == '-'
 
 # ----------------------------- parser ----------------------------------------
-    
+
 type
-  EInvalidPeg* = object of EBase ## raised if an invalid PEG has been detected
-  TPegParser = object of TPegLexer ## the PEG parser object
-    tok: TToken
-    nonterms: seq[PNonTerminal]
-    modifier: TModifier
+  EInvalidPeg* = object of ValueError ## raised if an invalid
+                                      ## PEG has been detected
+  PegParser = object of PegLexer ## the PEG parser object
+    tok: Token
+    nonterms: seq[NonTerminal]
+    modifier: Modifier
     captures: int
+    identIsVerbatim: bool
+    skip: Peg
 
-proc pegError(p: TPegParser, msg: string, line = -1, col = -1) =
-  var e: ref EInvalidPeg
-  new(e)
-  e.msg = errorStr(p, msg, line, col)
+func pegError(p: PegParser, msg: string, line = -1, col = -1) =
+  var e = (ref EInvalidPeg)(msg: errorStr(p, msg, line, col))
   raise e
 
-proc getTok(p: var TPegParser) = 
+func getTok(p: var PegParser) =
   getTok(p, p.tok)
-  if p.tok.kind == tkInvalid: pegError(p, "invalid token")
+  if p.tok.kind == tkInvalid: pegError(p, "'" & p.tok.literal & "' is invalid token")
 
-proc eat(p: var TPegParser, kind: TTokKind) =
+func eat(p: var PegParser, kind: TokKind) =
   if p.tok.kind == kind: getTok(p)
   else: pegError(p, tokKindToStr[kind] & " expected")
 
-proc parseExpr(p: var TPegParser): TPeg
+func parseExpr(p: var PegParser): Peg {.gcsafe.}
 
-proc getNonTerminal(p: var TPegParser, name: string): PNonTerminal =
+func getNonTerminal(p: var PegParser, name: string): NonTerminal =
   for i in 0..high(p.nonterms):
     result = p.nonterms[i]
     if cmpIgnoreStyle(result.name, name) == 0: return
@@ -1198,19 +1848,46 @@ proc getNonTerminal(p: var TPegParser, name: string): PNonTerminal =
   result = newNonTerminal(name, getLine(p), getColumn(p))
   add(p.nonterms, result)
 
-proc modifiedTerm(s: string, m: TModifier): TPeg =
+func modifiedTerm(s: string, m: Modifier): Peg =
   case m
   of modNone, modVerbatim: result = term(s)
   of modIgnoreCase: result = termIgnoreCase(s)
   of modIgnoreStyle: result = termIgnoreStyle(s)
 
-proc modifiedBackref(s: int, m: TModifier): TPeg =
+func modifiedBackref(s: int, m: Modifier): Peg =
+  var
+    reverse = s < 0
+    index = if reverse: -s else: s
   case m
-  of modNone, modVerbatim: result = backRef(s)
-  of modIgnoreCase: result = backRefIgnoreCase(s)
-  of modIgnoreStyle: result = backRefIgnoreStyle(s)
-
-proc primary(p: var TPegParser): TPeg =
+  of modNone, modVerbatim: result = backref(index, reverse)
+  of modIgnoreCase: result = backrefIgnoreCase(index, reverse)
+  of modIgnoreStyle: result = backrefIgnoreStyle(index, reverse)
+
+func builtin(p: var PegParser): Peg =
+  # do not use "y", "skip" or "i" as these would be ambiguous
+  case p.tok.literal
+  of "n": result = newLine()
+  of "d": result = charSet({'0'..'9'})
+  of "D": result = charSet({'\1'..'\xff'} - {'0'..'9'})
+  of "s": result = charSet({' ', '\9'..'\13'})
+  of "S": result = charSet({'\1'..'\xff'} - {' ', '\9'..'\13'})
+  of "w": result = charSet({'a'..'z', 'A'..'Z', '_', '0'..'9'})
+  of "W": result = charSet({'\1'..'\xff'} - {'a'..'z', 'A'..'Z', '_', '0'..'9'})
+  of "a": result = charSet({'a'..'z', 'A'..'Z'})
+  of "A": result = charSet({'\1'..'\xff'} - {'a'..'z', 'A'..'Z'})
+  of "ident": result = pegs.ident
+  of "letter": result = unicodeLetter()
+  of "upper": result = unicodeUpper()
+  of "lower": result = unicodeLower()
+  of "title": result = unicodeTitle()
+  of "white": result = unicodeWhitespace()
+  else: pegError(p, "unknown built-in: " & p.tok.literal)
+
+func token(terminal: Peg, p: PegParser): Peg =
+  if p.skip.kind == pkEmpty: result = terminal
+  else: result = sequence(p.skip, terminal)
+
+func primary(p: var PegParser): Peg =
   case p.tok.kind
   of tkAmp:
     getTok(p)
@@ -1220,26 +1897,35 @@ proc primary(p: var TPegParser): TPeg =
     return !primary(p)
   of tkAt:
     getTok(p)
-    return @primary(p)
-  else: nil
+    return !*primary(p)
+  of tkCurlyAt:
+    getTok(p)
+    return !*\primary(p).token(p)
+  else: discard
   case p.tok.kind
   of tkIdentifier:
-    if not arrowIsNextTok(p):
+    if p.identIsVerbatim:
+      var m = p.tok.modifier
+      if m == modNone: m = p.modifier
+      result = modifiedTerm(p.tok.literal, m).token(p)
+      getTok(p)
+    elif not arrowIsNextTok(p):
       var nt = getNonTerminal(p, p.tok.literal)
-      incl(nt.flags, ntUsed)
-      result = nonTerminal(nt)
+      {.cast(noSideEffect).}:
+        incl(nt.flags, ntUsed)
+      result = nonterminal(nt).token(p)
       getTok(p)
     else:
       pegError(p, "expression expected, but found: " & p.tok.literal)
   of tkStringLit:
     var m = p.tok.modifier
     if m == modNone: m = p.modifier
-    result = modifiedTerm(p.tok.literal, m)
+    result = modifiedTerm(p.tok.literal, m).token(p)
     getTok(p)
   of tkCharSet:
     if '\0' in p.tok.charset:
       pegError(p, "binary zero ('\\0') not allowed in character class")
-    result = charset(p.tok.charset)
+    result = charSet(p.tok.charset).token(p)
     getTok(p)
   of tkParLe:
     getTok(p)
@@ -1247,36 +1933,36 @@ proc primary(p: var TPegParser): TPeg =
     eat(p, tkParRi)
   of tkCurlyLe:
     getTok(p)
-    result = capture(parseExpr(p))
+    result = capture(parseExpr(p)).token(p)
     eat(p, tkCurlyRi)
     inc(p.captures)
+  of tkEmptyCurl:
+    result = capture()
+    getTok(p)
   of tkAny:
-    result = any()
+    result = any().token(p)
     getTok(p)
   of tkAnyRune:
-    result = anyRune()
+    result = anyRune().token(p)
     getTok(p)
   of tkBuiltin:
-    case p.tok.literal
-    of "n": result = newLine()
-    of "d": result = charset({'0'..'9'})
-    of "D": result = charset({'\1'..'\xff'} - {'0'..'9'})
-    of "s": result = charset({' ', '\9'..'\13'})
-    of "S": result = charset({'\1'..'\xff'} - {' ', '\9'..'\13'})
-    of "w": result = charset({'a'..'z', 'A'..'Z', '_', '0'..'9'})
-    of "W": result = charset({'\1'..'\xff'} - {'a'..'z','A'..'Z','_','0'..'9'})
-    of "ident": result = pegs.ident
-    else: pegError(p, "unknown built-in: " & p.tok.literal)
+    result = builtin(p).token(p)
     getTok(p)
   of tkEscaped:
-    result = term(p.tok.literal[0])
+    result = term(p.tok.literal[0]).token(p)
     getTok(p)
   of tkDollar:
+    result = endAnchor()
+    getTok(p)
+  of tkHat:
+    result = startAnchor()
+    getTok(p)
+  of tkBackref:
+    if abs(p.tok.index) > p.captures or p.tok.index == 0:
+      pegError(p, "invalid back reference index: " & $p.tok.index)
     var m = p.tok.modifier
     if m == modNone: m = p.modifier
-    result = modifiedBackRef(p.tok.index, m)
-    if p.tok.index < 0 or p.tok.index > p.captures: 
-      pegError(p, "invalid back reference index: " & $p.tok.index)
+    result = modifiedBackref(p.tok.index, m).token(p)
     getTok(p)
   else:
     pegError(p, "expression expected, but found: " & p.tok.literal)
@@ -1294,12 +1980,13 @@ proc primary(p: var TPegParser): TPeg =
       getTok(p)
     else: break
 
-proc seqExpr(p: var TPegParser): TPeg =
+func seqExpr(p: var PegParser): Peg =
   result = primary(p)
   while true:
     case p.tok.kind
-    of tkAmp, tkNot, tkAt, tkStringLit, tkCharset, tkParLe, tkCurlyLe,
-       tkAny, tkAnyRune, tkBuiltin, tkEscaped, tkDollar:
+    of tkAmp, tkNot, tkAt, tkStringLit, tkCharSet, tkParLe, tkCurlyLe,
+       tkAny, tkAnyRune, tkBuiltin, tkEscaped, tkDollar, tkBackref,
+       tkHat, tkCurlyAt, tkEmptyCurl:
       result = sequence(result, primary(p))
     of tkIdentifier:
       if not arrowIsNextTok(p):
@@ -1307,29 +1994,31 @@ proc seqExpr(p: var TPegParser): TPeg =
       else: break
     else: break
 
-proc parseExpr(p: var TPegParser): TPeg =
+func parseExpr(p: var PegParser): Peg =
   result = seqExpr(p)
   while p.tok.kind == tkBar:
     getTok(p)
     result = result / seqExpr(p)
-  
-proc parseRule(p: var TPegParser): PNonTerminal =
+
+func parseRule(p: var PegParser): NonTerminal =
   if p.tok.kind == tkIdentifier and arrowIsNextTok(p):
     result = getNonTerminal(p, p.tok.literal)
     if ntDeclared in result.flags:
       pegError(p, "attempt to redefine: " & result.name)
-    result.line = getLine(p)
-    result.col = getColumn(p)
+    {.cast(noSideEffect).}:
+      result.line = getLine(p)
+      result.col = getColumn(p)
     getTok(p)
     eat(p, tkArrow)
-    result.rule = parseExpr(p)
-    incl(result.flags, ntDeclared) # NOW inlining may be attempted
+    {.cast(noSideEffect).}:
+      result.rule = parseExpr(p)
+      incl(result.flags, ntDeclared) # NOW inlining may be attempted
   else:
     pegError(p, "rule expected, but found: " & p.tok.literal)
-  
-proc rawParse(p: var TPegParser): TPeg =
+
+func rawParse(p: var PegParser): Peg =
   ## parses a rule or a PEG expression
-  if p.tok.kind == tkBuiltin:
+  while p.tok.kind == tkBuiltin:
     case p.tok.literal
     of "i":
       p.modifier = modIgnoreCase
@@ -1337,12 +2026,16 @@ proc rawParse(p: var TPegParser): TPeg =
     of "y":
       p.modifier = modIgnoreStyle
       getTok(p)
-    else: nil
+    of "skip":
+      getTok(p)
+      p.skip = ?primary(p)
+    else: break
   if p.tok.kind == tkIdentifier and arrowIsNextTok(p):
     result = parseRule(p).rule
     while p.tok.kind != tkEof:
       discard parseRule(p)
   else:
+    p.identIsVerbatim = true
     result = parseExpr(p)
   if p.tok.kind != tkEof:
     pegError(p, "EOF expected, but found: " & p.tok.literal)
@@ -1353,113 +2046,43 @@ proc rawParse(p: var TPegParser): TPeg =
     elif ntUsed notin nt.flags and i > 0:
       pegError(p, "unused rule: " & nt.name, nt.line, nt.col)
 
-proc parsePeg*(input: string, filename = "pattern", line = 1, col = 0): TPeg =
-  var p: TPegParser
-  init(TPegLexer(p), input, filename, line, col)
+func parsePeg*(pattern: string, filename = "pattern", line = 1, col = 0): Peg =
+  ## constructs a Peg object from `pattern`. `filename`, `line`, `col` are
+  ## used for error messages, but they only provide start offsets. `parsePeg`
+  ## keeps track of line and column numbers within `pattern`.
+  var p: PegParser
+  init(PegLexer(p), pattern, filename, line, col)
   p.tok.kind = tkInvalid
   p.tok.modifier = modNone
   p.tok.literal = ""
   p.tok.charset = {}
   p.nonterms = @[]
+  p.identIsVerbatim = false
   getTok(p)
   result = rawParse(p)
 
-proc peg*(pattern: string): TPeg =
-  ## constructs a TPeg object from the `pattern`. The short name has been
-  ## chosen to encourage its use as a raw string modifier::
+func peg*(pattern: string): Peg =
+  ## constructs a Peg object from the `pattern`. The short name has been
+  ## chosen to encourage its use as a raw string modifier:
   ##
-  ##   peg"{\ident} \s* '=' \s* {.*}"
+  ##     peg"{\ident} \s* '=' \s* {.*}"
   result = parsePeg(pattern, "pattern")
 
-proc escapePeg*(s: string): string = 
+func escapePeg*(s: string): string =
   ## escapes `s` so that it is matched verbatim when used as a peg.
   result = ""
   var inQuote = false
-  for c in items(s):  
+  for c in items(s):
     case c
-    of '\0'..'\31', '\'', '"', '\\': 
-      if inQuote: 
+    of '\0'..'\31', '\'', '"', '\\':
+      if inQuote:
         result.add('\'')
         inQuote = false
       result.add("\\x")
       result.add(toHex(ord(c), 2))
     else:
-      if not inQuote: 
+      if not inQuote:
         result.add('\'')
         inQuote = true
       result.add(c)
   if inQuote: result.add('\'')
-
-when isMainModule:
-  assert escapePeg("abc''def'") == r"'abc'\x27\x27'def'\x27"
-  assert match("(a b c)", peg"'(' @ ')'")
-  assert match("W_HI_Le", peg"\y 'while'")
-  assert(not match("W_HI_L", peg"\y 'while'"))
-  assert(not match("W_HI_Le", peg"\y v'while'"))
-  assert match("W_HI_Le", peg"y'while'")
-  
-  assert($ +digits == $peg"\d+")
-  assert "0158787".match(peg"\d+")
-  assert "ABC 0232".match(peg"\w+\s+\d+")
-  assert "ABC".match(peg"\d+ / \w+")
-
-  for word in split("00232this02939is39an22example111", peg"\d+"):
-    writeln(stdout, word)
-
-  assert matchLen("key", ident) == 3
-
-  var pattern = sequence(ident, *whitespace, term('='), *whitespace, ident)
-  assert matchLen("key1=  cal9", pattern) == 11
-  
-  var ws = newNonTerminal("ws", 1, 1)
-  ws.rule = *whitespace
-  
-  var expr = newNonTerminal("expr", 1, 1)
-  expr.rule = sequence(capture(ident), *sequence(
-                nonterminal(ws), term('+'), nonterminal(ws), nonterminal(expr)))
-  
-  var c: TMatchClosure
-  var s = "a+b +  c +d+e+f"
-  assert m(s, expr.rule, 0, c) == len(s)
-  var a = ""
-  for i in 0..c.ml-1:
-    a.add(copy(s, c.matches[i][0], c.matches[i][1]))
-  assert a == "abcdef"
-  #echo expr.rule
-
-  #const filename = "lib/devel/peg/grammar.txt"
-  #var grammar = parsePeg(newFileStream(filename, fmRead), filename)
-  #echo "a <- [abc]*?".match(grammar)
-  assert find("_____abc_______", term("abc")) == 5
-  assert match("_______ana", peg"A <- 'ana' / . A")
-  assert match("abcs%%%", peg"A <- ..A / .A / '%'")
-
-  if "abc" =~ peg"{'a'}'bc' 'xyz' / {\ident}":
-    assert matches[0] == "abc"
-  else:
-    assert false
-  
-  var g2 = peg"""S <- A B / C D
-                 A <- 'a'+
-                 B <- 'b'+
-                 C <- 'c'+
-                 D <- 'd'+
-              """
-  assert($g2 == "((A B) / (C D))")
-  assert match("cccccdddddd", g2)
-  assert("var1=key; var2=key2".replace(peg"{\ident}'='{\ident}", "$1<-$2$2") ==
-         "var1<-keykey; var2<-key2key2")
-  assert "var1=key; var2=key2".endsWith(peg"{\ident}'='{\ident}")
-
-  if "aaaaaa" =~ peg"'aa' !. / ({'a'})+":
-    assert matches[0] == "a"
-  else:
-    assert false
-    
-  var matches: array[0..5, string]
-  if match("abcdefg", peg"'c' {'d'} 'ef' {'g'}", matches, 2): 
-    assert matches[0] == "d"
-    assert matches[1] == "g"
-  else:
-    assert false
-
diff --git a/lib/pure/prelude.nim b/lib/pure/prelude.nim
new file mode 100644
index 000000000..9428f29eb
--- /dev/null
+++ b/lib/pure/prelude.nim
@@ -0,0 +1,28 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimdoc) and isMainModule:
+  from std/compileSettings import nil
+  when compileSettings.querySetting(compileSettings.SingleValueSetting.projectFull) == currentSourcePath:
+    ## This is an include file that simply imports common modules for your convenience.
+    runnableExamples:
+      include std/prelude
+        # same as:
+        # import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt, strformat]
+      let x = 1
+      assert "foo $# $#" % [$x, "bar"] == "foo 1 bar"
+      assert toSeq(1..3) == @[1, 2, 3]
+      when not defined(js) or defined(nodejs):
+        assert getCurrentDir().len > 0
+        assert ($now()).startsWith "20"
+
+  # xxx `nim doc -b:js -d:nodejs --doccmd:-d:nodejs lib/pure/prelude.nim` fails for some reason
+  # specific to `nim doc`, but the code otherwise works with nodejs.
+
+import std/[os, strutils, times, parseutils, hashes, tables, sets, sequtils, parseopt, strformat]
diff --git a/lib/pure/random.nim b/lib/pure/random.nim
new file mode 100644
index 000000000..3ec77d37e
--- /dev/null
+++ b/lib/pure/random.nim
@@ -0,0 +1,766 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Nim's standard random number generator (RNG).
+##
+## Its implementation is based on the `xoroshiro128+`
+## (xor/rotate/shift/rotate) library.
+## * More information: http://xoroshiro.di.unimi.it
+## * C implementation: http://xoroshiro.di.unimi.it/xoroshiro128plus.c
+##
+## **Do not use this module for cryptographic purposes!**
+##
+## Basic usage
+## ===========
+##
+runnableExamples:
+  # Call randomize() once to initialize the default random number generator.
+  # If this is not called, the same results will occur every time these
+  # examples are run.
+  randomize()
+
+  # Pick a number in 0..100.
+  let num = rand(100)
+  doAssert num in 0..100
+
+  # Roll a six-sided die.
+  let roll = rand(1..6)
+  doAssert roll in 1..6
+
+  # Pick a marble from a bag.
+  let marbles = ["red", "blue", "green", "yellow", "purple"]
+  let pick = sample(marbles)
+  doAssert pick in marbles
+
+  # Shuffle some cards.
+  var cards = ["Ace", "King", "Queen", "Jack", "Ten"]
+  shuffle(cards)
+  doAssert cards.len == 5
+
+## These examples all use the default RNG. The
+## `Rand type <#Rand>`_ represents the state of an RNG.
+## For convenience, this module contains a default Rand state that corresponds
+## to the default RNG. Most procs in this module which do
+## not take in a Rand parameter, including those called in the above examples,
+## use the default generator. Those procs are **not** thread-safe.
+##
+## Note that the default generator always starts in the same state.
+## The `randomize proc <#randomize>`_ can be called to initialize the default
+## generator with a seed based on the current time, and it only needs to be
+## called once before the first usage of procs from this module. If
+## `randomize` is not called, the default generator will always produce
+## the same results.
+##
+## RNGs that are independent of the default one can be created with the
+## `initRand proc <#initRand,int64>`_.
+##
+## Again, it is important to remember that this module must **not** be used for
+## cryptographic applications.
+##
+## See also
+## ========
+## * `std/sysrand module <sysrand.html>`_ for a cryptographically secure pseudorandom number generator
+## * `math module <math.html>`_ for basic math routines
+## * `stats module <stats.html>`_ for statistical analysis
+## * `list of cryptographic and hashing modules <lib.html#pure-libraries-hashing>`_
+##   in the standard library
+
+import std/[algorithm, math]
+import std/private/[since, jsutils]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions]
+
+include system/inclrtl
+{.push debugger: off.}
+template whenHasBigInt64(yes64, no64): untyped =
+  when defined(js):
+    when compiles(compileOption("jsbigint64")):
+      when compileOption("jsbigint64"):
+        yes64
+      else:
+        no64
+    else:
+      no64
+  else:
+    yes64
+
+
+whenHasBigInt64:
+  type Ui = uint64
+
+  const randMax = 18_446_744_073_709_551_615u64
+do:
+  type Ui = uint32
+
+  const randMax = 4_294_967_295u32
+
+
+type
+  Rand* = object ## State of a random number generator.
+                 ##
+                 ## Create a new Rand state using the `initRand proc <#initRand,int64>`_.
+                 ##
+                 ## The module contains a default Rand state for convenience.
+                 ## It corresponds to the default RNG's state.
+                 ## The default Rand state always starts with the same values, but the
+                 ## `randomize proc <#randomize>`_ can be used to seed the default generator
+                 ## with a value based on the current time.
+                 ##
+                 ## Many procs have two variations: one that takes in a Rand parameter and
+                 ## another that uses the default generator. The procs that use the default
+                 ## generator are **not** thread-safe!
+    a0, a1: Ui
+
+whenHasBigInt64:
+  const DefaultRandSeed = Rand(
+    a0: 0x69B4C98CB8530805u64,
+    a1: 0xFED1DD3004688D67CAu64)
+
+  # racy for multi-threading but good enough for now:
+  var state = DefaultRandSeed # global for backwards compatibility
+do:
+  var state = Rand(
+    a0: 0x69B4C98Cu32,
+    a1: 0xFED1DD30u32) # global for backwards compatibility
+
+func isValid(r: Rand): bool {.inline.} =
+  ## Check whether state of `r` is valid.
+  ##
+  ## In `xoroshiro128+`, if all bits of `a0` and `a1` are zero,
+  ## they are always zero after calling `next(r: var Rand)`.
+  not (r.a0 == 0 and r.a1 == 0)
+
+since (1, 5):
+  template randState*(): untyped =
+    ## Makes the default Rand state accessible from other modules.
+    ## Useful for module authors.
+    state
+
+proc rotl(x, k: Ui): Ui =
+  result = (x shl k) or (x shr (Ui(64) - k))
+
+proc next*(r: var Rand): uint64 =
+  ## Computes a random `uint64` number using the given state.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer between zero and
+  ##   a given upper bound
+  ## * `rand proc<#rand,Rand,range[]>`_ that returns a float
+  ## * `rand proc<#rand,Rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  ## * `skipRandomNumbers proc<#skipRandomNumbers,Rand>`_
+  runnableExamples("-r:off"):
+    var r = initRand(2019)
+    assert r.next() == 13223559681708962501'u64 # implementation defined
+    assert r.next() == 7229677234260823147'u64 # ditto
+
+  let s0 = r.a0
+  var s1 = r.a1
+  result = s0 + s1
+  s1 = s1 xor s0
+  r.a0 = rotl(s0, 55) xor s1 xor (s1 shl 14) # a, b
+  r.a1 = rotl(s1, 36) # c
+
+proc skipRandomNumbers*(s: var Rand) =
+  ## The jump function for the generator.
+  ##
+  ## This proc is equivalent to `2^64` calls to `next <#next,Rand>`_, and it can
+  ## be used to generate `2^64` non-overlapping subsequences for parallel
+  ## computations.
+  ##
+  ## When multiple threads are generating random numbers, each thread must
+  ## own the `Rand <#Rand>`_ state it is using so that the thread can safely
+  ## obtain random numbers. However, if each thread creates its own Rand state,
+  ## the subsequences of random numbers that each thread generates may overlap,
+  ## even if the provided seeds are unique. This is more likely to happen as the
+  ## number of threads and amount of random numbers generated increases.
+  ##
+  ## If many threads will generate random numbers concurrently, it is better to
+  ## create a single Rand state and pass it to each thread. After passing the
+  ## Rand state to a thread, call this proc before passing it to the next one.
+  ## By using the Rand state this way, the subsequences of random numbers
+  ## generated in each thread will never overlap as long as no thread generates
+  ## more than `2^64` random numbers.
+  ##
+  ## **See also:**
+  ## * `next proc<#next,Rand>`_
+  runnableExamples("--threads:on"):
+    import std/random
+
+    const numbers = 100000
+
+    var
+      thr: array[0..3, Thread[(Rand, int)]]
+      vals: array[0..3, int]
+
+    proc randomSum(params: tuple[r: Rand, index: int]) {.thread.} =
+      var r = params.r
+      var s = 0 # avoid cache thrashing
+      for i in 1..numbers:
+        s += r.rand(0..10)
+      vals[params.index] = s
+
+    var r = initRand(2019)
+    for i in 0..<thr.len:
+      createThread(thr[i], randomSum, (r, i))
+      r.skipRandomNumbers()
+
+    joinThreads(thr)
+
+    for val in vals:
+      doAssert abs(val - numbers * 5) / numbers < 0.1
+
+    doAssert vals == [501737, 497901, 500683, 500157]
+
+
+  whenHasBigInt64:
+    const helper = [0xbeac0467eba5facbu64, 0xd86b048b86aa9922u64]
+  do:
+    const helper = [0xbeac0467u32, 0xd86b048bu32]
+  var
+    s0 = Ui 0
+    s1 = Ui 0
+  for i in 0..high(helper):
+    for b in 0 ..< 64:
+      if (helper[i] and (Ui(1) shl Ui(b))) != 0:
+        s0 = s0 xor s.a0
+        s1 = s1 xor s.a1
+      discard next(s)
+  s.a0 = s0
+  s.a1 = s1
+
+proc rand[T: uint | uint64](r: var Rand; max: T): T =
+  # xxx export in future work
+  if max == 0: return
+  else:
+    let max = uint64(max)
+    when T.high.uint64 == uint64.high:
+      if max == uint64.high: return T(next(r))
+    var iters = 0
+    while true:
+      let x = next(r)
+      # avoid `mod` bias
+      if x <= randMax - (randMax mod max) or iters > 20:
+        return T(x mod (max + 1))
+      else:
+        inc iters
+
+proc rand*(r: var Rand; max: Natural): int {.benign.} =
+  ## Returns a random integer in the range `0..max` using the given state.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,int>`_ that returns an integer using the default RNG
+  ## * `rand proc<#rand,Rand,range[]>`_ that returns a float
+  ## * `rand proc<#rand,Rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples:
+    var r = initRand(123)
+    if false:
+      assert r.rand(100) == 96 # implementation defined
+  # bootstrap: can't use `runnableExamples("-r:off")`
+  cast[int](rand(r, uint64(max)))
+    # xxx toUnsigned pending https://github.com/nim-lang/Nim/pull/18445
+
+proc rand*(max: int): int {.benign.} =
+  ## Returns a random integer in the range `0..max`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the sequence of random
+  ## numbers returned from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer using a
+  ##   provided state
+  ## * `rand proc<#rand,float>`_ that returns a float
+  ## * `rand proc<#rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples("-r:off"):
+    randomize(123)
+    assert [rand(100), rand(100)] == [96, 63] # implementation defined
+
+  rand(state, max)
+
+proc rand*(r: var Rand; max: range[0.0 .. high(float)]): float {.benign.} =
+  ## Returns a random floating point number in the range `0.0..max`
+  ## using the given state.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,float>`_ that returns a float using the default RNG
+  ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer
+  ## * `rand proc<#rand,Rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples:
+    var r = initRand(234)
+    let f = r.rand(1.0) # 8.717181376738381e-07
+
+  let x = next(r)
+  when defined(js):
+    when compiles(compileOption("jsbigint64")):
+      when compileOption("jsbigint64"):
+        result = (float(x) / float(high(uint64))) * max
+      else:
+        result = (float(x) / float(high(uint32))) * max
+    else:
+      result = (float(x) / float(high(uint32))) * max
+  else:
+    let u = (0x3FFu64 shl 52u64) or (x shr 12u64)
+    result = (cast[float](u) - 1.0) * max
+
+proc rand*(max: float): float {.benign.} =
+  ## Returns a random floating point number in the range `0.0..max`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the sequence of random
+  ## numbers returned from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,Rand,range[]>`_ that returns a float using a
+  ##   provided state
+  ## * `rand proc<#rand,int>`_ that returns an integer
+  ## * `rand proc<#rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples:
+    randomize(234)
+    let f = rand(1.0) # 8.717181376738381e-07
+
+  rand(state, max)
+
+proc rand*[T: Ordinal or SomeFloat](r: var Rand; x: HSlice[T, T]): T =
+  ## For a slice `a..b`, returns a value in the range `a..b` using the given
+  ## state.
+  ##
+  ## Allowed types for `T` are integers, floats, and enums without holes.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice and uses the default RNG
+  ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer
+  ## * `rand proc<#rand,Rand,range[]>`_ that returns a float
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples:
+    var r = initRand(345)
+    assert r.rand(1..5) <= 5
+    assert r.rand(-1.1 .. 1.2) >= -1.1
+  assert x.a <= x.b
+  when T is SomeFloat:
+    result = rand(r, x.b - x.a) + x.a
+  else: # Integers and Enum types
+    whenJsNoBigInt64:
+      result = cast[T](rand(r, cast[uint](x.b) - cast[uint](x.a)) + cast[uint](x.a))
+    do:
+      result = cast[T](rand(r, cast[uint64](x.b) - cast[uint64](x.a)) + cast[uint64](x.a))
+
+proc rand*[T: Ordinal or SomeFloat](x: HSlice[T, T]): T =
+  ## For a slice `a..b`, returns a value in the range `a..b`.
+  ##
+  ## Allowed types for `T` are integers, floats, and enums without holes.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the sequence of random
+  ## numbers returned from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,Rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice and uses a provided state
+  ## * `rand proc<#rand,int>`_ that returns an integer
+  ## * `rand proc<#rand,float>`_ that returns a floating point number
+  ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer or range type
+  runnableExamples:
+    randomize(345)
+    assert rand(1..6) <= 6
+
+  result = rand(state, x)
+
+proc rand*[T: Ordinal](r: var Rand; t: typedesc[T]): T {.since: (1, 7, 1).} =
+  ## Returns a random Ordinal in the range `low(T)..high(T)`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the sequence of random
+  ## numbers returned from this proc will always be the same.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,int>`_ that returns an integer
+  ## * `rand proc<#rand,float>`_ that returns a floating point number
+  ## * `rand proc<#rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  when T is range or T is enum:
+    result = rand(r, low(T)..high(T))
+  elif T is bool:
+    result = r.next < randMax div 2
+  else:
+    whenJsNoBigInt64:
+      result = cast[T](r.next shr (sizeof(uint)*8 - sizeof(T)*8))
+    do:
+      result = cast[T](r.next shr (sizeof(uint64)*8 - sizeof(T)*8))
+
+proc rand*[T: Ordinal](t: typedesc[T]): T =
+  ## Returns a random Ordinal in the range `low(T)..high(T)`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the sequence of random
+  ## numbers returned from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `rand proc<#rand,int>`_ that returns an integer
+  ## * `rand proc<#rand,float>`_ that returns a floating point number
+  ## * `rand proc<#rand,HSlice[T: Ordinal or float or float32 or float64,T: Ordinal or float or float32 or float64]>`_
+  ##   that accepts a slice
+  runnableExamples:
+    randomize(567)
+    type E = enum a, b, c, d
+
+    assert rand(E) in a..d
+    assert rand(char) in low(char)..high(char)
+    assert rand(int8) in low(int8)..high(int8)
+    assert rand(uint32) in low(uint32)..high(uint32)
+    assert rand(range[1..16]) in 1..16
+
+  result = rand(state, t)
+
+proc sample*[T](r: var Rand; s: set[T]): T =
+  ## Returns a random element from the set `s` using the given state.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,set[T]>`_ that uses the default RNG
+  ## * `sample proc<#sample,Rand,openArray[T]>`_ for `openArray`s
+  ## * `sample proc<#sample,Rand,openArray[T],openArray[U]>`_ that uses a
+  ##   cumulative distribution function
+  runnableExamples:
+    var r = initRand(987)
+    let s = {1, 3, 5, 7, 9}
+    assert r.sample(s) in s
+
+  assert card(s) != 0
+  var i = rand(r, card(s) - 1)
+  for e in s:
+    if i == 0: return e
+    dec(i)
+
+proc sample*[T](s: set[T]): T =
+  ## Returns a random element from the set `s`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the order of outcomes
+  ## from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,Rand,set[T]>`_ that uses a provided state
+  ## * `sample proc<#sample,openArray[T]>`_ for `openArray`s
+  ## * `sample proc<#sample,openArray[T],openArray[U]>`_ that uses a
+  ##   cumulative distribution function
+  runnableExamples:
+    randomize(987)
+    let s = {1, 3, 5, 7, 9}
+    assert sample(s) in s
+
+  sample(state, s)
+
+proc sample*[T](r: var Rand; a: openArray[T]): T =
+  ## Returns a random element from `a` using the given state.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,openArray[T]>`_ that uses the default RNG
+  ## * `sample proc<#sample,Rand,openArray[T],openArray[U]>`_ that uses a
+  ##   cumulative distribution function
+  ## * `sample proc<#sample,Rand,set[T]>`_ for sets
+  runnableExamples:
+    let marbles = ["red", "blue", "green", "yellow", "purple"]
+    var r = initRand(456)
+    assert r.sample(marbles) in marbles
+
+  result = a[r.rand(a.low..a.high)]
+
+proc sample*[T](a: openArray[T]): lent T =
+  ## Returns a random element from `a`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the order of outcomes
+  ## from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,Rand,openArray[T]>`_ that uses a provided state
+  ## * `sample proc<#sample,openArray[T],openArray[U]>`_ that uses a
+  ##   cumulative distribution function
+  ## * `sample proc<#sample,set[T]>`_ for sets
+  runnableExamples:
+    let marbles = ["red", "blue", "green", "yellow", "purple"]
+    randomize(456)
+    assert sample(marbles) in marbles
+
+  result = a[rand(a.low..a.high)]
+
+proc sample*[T, U](r: var Rand; a: openArray[T]; cdf: openArray[U]): T =
+  ## Returns an element from `a` using a cumulative distribution function
+  ## (CDF) and the given state.
+  ##
+  ## The `cdf` argument does not have to be normalized, and it could contain
+  ## any type of elements that can be converted to a `float`. It must be
+  ## the same length as `a`. Each element in `cdf` should be greater than
+  ## or equal to the previous element.
+  ##
+  ## The outcome of the `cumsum<math.html#cumsum,openArray[T]>`_ proc and the
+  ## return value of the `cumsummed<math.html#cumsummed,openArray[T]>`_ proc,
+  ## which are both in the math module, can be used as the `cdf` argument.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,openArray[T],openArray[U]>`_ that also utilizes
+  ##   a CDF but uses the default RNG
+  ## * `sample proc<#sample,Rand,openArray[T]>`_ that does not use a CDF
+  ## * `sample proc<#sample,Rand,set[T]>`_ for sets
+  runnableExamples:
+    from std/math import cumsummed
+
+    let marbles = ["red", "blue", "green", "yellow", "purple"]
+    let count = [1, 6, 8, 3, 4]
+    let cdf = count.cumsummed
+    var r = initRand(789)
+    assert r.sample(marbles, cdf) in marbles
+
+  assert(cdf.len == a.len) # Two basic sanity checks.
+  assert(float(cdf[^1]) > 0.0)
+  # While we could check cdf[i-1] <= cdf[i] for i in 1..cdf.len, that could get
+  # awfully expensive even in debugging modes.
+  let u = r.rand(float(cdf[^1]))
+  a[cdf.upperBound(U(u))]
+
+proc sample*[T, U](a: openArray[T]; cdf: openArray[U]): T =
+  ## Returns an element from `a` using a cumulative distribution function
+  ## (CDF).
+  ##
+  ## This proc works similarly to
+  ## `sample <#sample,Rand,openArray[T],openArray[U]>`_.
+  ## See that proc's documentation for more details.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the order of outcomes
+  ## from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `sample proc<#sample,Rand,openArray[T],openArray[U]>`_ that also utilizes
+  ##   a CDF but uses a provided state
+  ## * `sample proc<#sample,openArray[T]>`_ that does not use a CDF
+  ## * `sample proc<#sample,set[T]>`_ for sets
+  runnableExamples:
+    from std/math import cumsummed
+
+    let marbles = ["red", "blue", "green", "yellow", "purple"]
+    let count = [1, 6, 8, 3, 4]
+    let cdf = count.cumsummed
+    randomize(789)
+    assert sample(marbles, cdf) in marbles
+
+  state.sample(a, cdf)
+
+proc gauss*(r: var Rand; mu = 0.0; sigma = 1.0): float {.since: (1, 3).} =
+  ## Returns a Gaussian random variate,
+  ## with mean `mu` and standard deviation `sigma`
+  ## using the given state.
+  # Ratio of uniforms method for normal
+  # https://www2.econ.osaka-u.ac.jp/~tanizaki/class/2013/econome3/13.pdf
+  const K = sqrt(2 / E)
+  var
+    a = 0.0
+    b = 0.0
+  while true:
+    a = rand(r, 1.0)
+    b = (2.0 * rand(r, 1.0) - 1.0) * K
+    if  b * b <= -4.0 * a * a * ln(a): break
+  result = mu + sigma * (b / a)
+
+proc gauss*(mu = 0.0, sigma = 1.0): float {.since: (1, 3).} =
+  ## Returns a Gaussian random variate,
+  ## with mean `mu` and standard deviation `sigma`.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the order of outcomes
+  ## from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  result = gauss(state, mu, sigma)
+
+proc initRand*(seed: int64): Rand =
+  ## Initializes a new `Rand <#Rand>`_ state using the given seed.
+  ##
+  ## Providing a specific seed will produce the same results for that seed each time.
+  ##
+  ## The resulting state is independent of the default RNG's state. When `seed == 0`,
+  ## we internally set the seed to an implementation defined non-zero value.
+  ##
+  ## **See also:**
+  ## * `initRand proc<#initRand>`_ that uses the current time
+  ## * `randomize proc<#randomize,int64>`_ that accepts a seed for the default RNG
+  ## * `randomize proc<#randomize>`_ that initializes the default RNG using the current time
+  runnableExamples:
+    from std/times import getTime, toUnix, nanosecond
+
+    var r1 = initRand(123)
+    let now = getTime()
+    var r2 = initRand(now.toUnix * 1_000_000_000 + now.nanosecond)
+  const seedFallback0 = int32.high # arbitrary
+  let seed = if seed != 0: seed else: seedFallback0 # because 0 is a fixed point
+  result.a0 = Ui(seed shr 16)
+  result.a1 = Ui(seed and 0xffff)
+  when not defined(nimLegacyRandomInitRand):
+    # calling `discard next(result)` (even a few times) would still produce
+    # skewed numbers for the 1st call to `rand()`.
+    skipRandomNumbers(result)
+  discard next(result)
+
+proc randomize*(seed: int64) {.benign.} =
+  ## Initializes the default random number generator with the given seed.
+  ##
+  ## Providing a specific seed will produce the same results for that seed each time.
+  ##
+  ## **See also:**
+  ## * `initRand proc<#initRand,int64>`_ that initializes a Rand state
+  ##   with a given seed
+  ## * `randomize proc<#randomize>`_ that uses the current time instead
+  ## * `initRand proc<#initRand>`_ that initializes a Rand state using
+  ##   the current time
+  runnableExamples:
+    from std/times import getTime, toUnix, nanosecond
+
+    randomize(123)
+
+    let now = getTime()
+    randomize(now.toUnix * 1_000_000_000 + now.nanosecond)
+
+  state = initRand(seed)
+
+proc shuffle*[T](r: var Rand; x: var openArray[T]) =
+  ## Shuffles a sequence of elements in-place using the given state.
+  ##
+  ## **See also:**
+  ## * `shuffle proc<#shuffle,openArray[T]>`_ that uses the default RNG
+  runnableExamples:
+    var cards = ["Ace", "King", "Queen", "Jack", "Ten"]
+    var r = initRand(678)
+    r.shuffle(cards)
+    import std/algorithm
+    assert cards.sorted == @["Ace", "Jack", "King", "Queen", "Ten"]
+
+  for i in countdown(x.high, 1):
+    let j = r.rand(i)
+    swap(x[i], x[j])
+
+proc shuffle*[T](x: var openArray[T]) =
+  ## Shuffles a sequence of elements in-place.
+  ##
+  ## If `randomize <#randomize>`_ has not been called, the order of outcomes
+  ## from this proc will always be the same.
+  ##
+  ## This proc uses the default RNG. Thus, it is **not** thread-safe.
+  ##
+  ## **See also:**
+  ## * `shuffle proc<#shuffle,Rand,openArray[T]>`_ that uses a provided state
+  runnableExamples:
+    var cards = ["Ace", "King", "Queen", "Jack", "Ten"]
+    randomize(678)
+    shuffle(cards)
+    import std/algorithm
+    assert cards.sorted == @["Ace", "Jack", "King", "Queen", "Ten"]
+
+  shuffle(state, x)
+
+when not defined(standalone):
+  when defined(js):
+    import std/times
+  else:
+    when defined(nimscript):
+      import std/hashes
+    else:
+      import std/[hashes, os, sysrand, monotimes]
+
+      when compileOption("threads"):
+        import std/locks
+        var baseSeedLock: Lock
+        baseSeedLock.initLock
+
+    var baseState: Rand
+
+  proc initRand(): Rand =
+    ## Initializes a new Rand state.
+    ##
+    ## The resulting state is independent of the default RNG's state.
+    ##
+    ## **Note:** Does not work for the compile-time VM.
+    ##
+    ## See also:
+    ## * `initRand proc<#initRand,int64>`_ that accepts a seed for a new Rand state
+    ## * `randomize proc<#randomize>`_ that initializes the default RNG using the current time
+    ## * `randomize proc<#randomize,int64>`_ that accepts a seed for the default RNG
+    when defined(js):
+      let time = int64(times.epochTime() * 1000) and 0x7fff_ffff
+      result = initRand(time)
+    else:
+      proc getRandomState(): Rand =
+        when defined(nimscript):
+          result = Rand(
+            a0: CompileTime.hash.Ui,
+            a1: CompileDate.hash.Ui)
+          if not result.isValid:
+            result = DefaultRandSeed
+        else:
+          var urand: array[sizeof(Rand), byte]
+
+          for i in 0 .. 7:
+            if sysrand.urandom(urand):
+              copyMem(result.addr, urand[0].addr, sizeof(Rand))
+              if result.isValid:
+                break
+
+          if not result.isValid:
+            # Don't try to get alternative random values from other source like time or process/thread id,
+            # because such code would be never tested and is a liability for security.
+            quit("Failed to initializes baseState in random module as sysrand.urandom doesn't work.")
+
+      when compileOption("threads"):
+        baseSeedLock.withLock:
+          if not baseState.isValid:
+            baseState = getRandomState()
+          result = baseState
+          baseState.skipRandomNumbers
+      else:
+        if not baseState.isValid:
+          baseState = getRandomState()
+        result = baseState
+        baseState.skipRandomNumbers
+
+  since (1, 5, 1):
+    export initRand
+
+  proc randomize*() {.benign.} =
+    ## Initializes the default random number generator with a seed based on
+    ## random number source.
+    ##
+    ## This proc only needs to be called once, and it should be called before
+    ## the first usage of procs from this module that use the default RNG.
+    ##
+    ## **Note:** Does not work for the compile-time VM.
+    ##
+    ## **See also:**
+    ## * `randomize proc<#randomize,int64>`_ that accepts a seed
+    ## * `initRand proc<#initRand>`_ that initializes a Rand state using
+    ##   the current time
+    ## * `initRand proc<#initRand,int64>`_ that initializes a Rand state
+    ##   with a given seed
+    state = initRand()
+
+{.pop.}
diff --git a/lib/pure/rationals.nim b/lib/pure/rationals.nim
new file mode 100644
index 000000000..5f806bd70
--- /dev/null
+++ b/lib/pure/rationals.nim
@@ -0,0 +1,340 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dennis Felsing
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+## This module implements rational numbers, consisting of a numerator and
+## a denominator. The denominator can not be 0.
+
+runnableExamples:
+  let
+    r1 = 1 // 2
+    r2 = -3 // 4
+
+  doAssert r1 + r2 == -1 // 4
+  doAssert r1 - r2 ==  5 // 4
+  doAssert r1 * r2 == -3 // 8
+  doAssert r1 / r2 == -2 // 3
+
+import std/[math, hashes]
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type Rational*[T] = object
+  ## A rational number, consisting of a numerator `num` and a denominator `den`.
+  num*, den*: T
+
+func reduce*[T: SomeInteger](x: var Rational[T]) =
+  ## Reduces the rational number `x`, so that the numerator and denominator
+  ## have no common divisors other than 1 (and -1).
+  ## If `x` is 0, raises `DivByZeroDefect`.
+  ##
+  ## **Note:** This is called automatically by the various operations on rationals.
+  runnableExamples:
+    var r = Rational[int](num: 2, den: 4) # 1/2
+    reduce(r)
+    doAssert r.num == 1
+    doAssert r.den == 2
+  if x.den == 0:
+    raise newException(DivByZeroDefect, "division by zero")
+  let common = gcd(x.num, x.den)
+  if x.den > 0:
+    x.num = x.num div common
+    x.den = x.den div common
+  when T isnot SomeUnsignedInt:
+    if x.den < 0:
+      x.num = -x.num div common
+      x.den = -x.den div common
+
+func initRational*[T: SomeInteger](num, den: T): Rational[T] =
+  ## Creates a new rational number with numerator `num` and denominator `den`.
+  ## `den` must not be 0.
+  ##
+  ## **Note:** `den != 0` is not checked when assertions are turned off.
+  assert(den != 0, "a denominator of zero is invalid")
+  result.num = num
+  result.den = den
+  reduce(result)
+
+func `//`*[T](num, den: T): Rational[T] =
+  ## A friendlier version of `initRational <#initRational,T,T>`_.
+  runnableExamples:
+    let x = 1 // 3 + 1 // 5
+    doAssert x == 8 // 15
+
+  initRational[T](num, den)
+
+func `$`*[T](x: Rational[T]): string =
+  ## Turns a rational number into a string.
+  runnableExamples:
+    doAssert $(1 // 2) == "1/2"
+
+  result = $x.num & "/" & $x.den
+
+func toRational*[T: SomeInteger](x: T): Rational[T] =
+  ## Converts some integer `x` to a rational number.
+  runnableExamples:
+    doAssert toRational(42) == 42 // 1
+
+  result.num = x
+  result.den = 1
+
+func toRational*(x: float,
+                 n: int = high(int) shr (sizeof(int) div 2 * 8)): Rational[int] =
+  ## Calculates the best rational approximation of `x`,
+  ## where the denominator is smaller than `n`
+  ## (default is the largest possible `int` for maximal resolution).
+  ##
+  ## The algorithm is based on the theory of continued fractions.
+  # David Eppstein / UC Irvine / 8 Aug 1993
+  # With corrections from Arno Formella, May 2008
+  runnableExamples:
+    let x = 1.2
+    doAssert x.toRational.toFloat == x
+
+  var
+    m11, m22 = 1
+    m12, m21 = 0
+    ai = int(x)
+    x = x
+  while m21 * ai + m22 <= n:
+    swap m12, m11
+    swap m22, m21
+    m11 = m12 * ai + m11
+    m21 = m22 * ai + m21
+    if x == float(ai): break # division by zero
+    x = 1 / (x - float(ai))
+    if x > float(high(int32)): break # representation failure
+    ai = int(x)
+  result = m11 // m21
+
+func toFloat*[T](x: Rational[T]): float =
+  ## Converts a rational number `x` to a `float`.
+  x.num / x.den
+
+func toInt*[T](x: Rational[T]): int =
+  ## Converts a rational number `x` to an `int`. Conversion rounds towards 0 if
+  ## `x` does not contain an integer value.
+  x.num div x.den
+
+func `+`*[T](x, y: Rational[T]): Rational[T] =
+  ## Adds two rational numbers.
+  let common = lcm(x.den, y.den)
+  result.num = common div x.den * x.num + common div y.den * y.num
+  result.den = common
+  reduce(result)
+
+func `+`*[T](x: Rational[T], y: T): Rational[T] =
+  ## Adds the rational `x` to the int `y`.
+  result.num = x.num + y * x.den
+  result.den = x.den
+
+func `+`*[T](x: T, y: Rational[T]): Rational[T] =
+  ## Adds the int `x` to the rational `y`.
+  result.num = x * y.den + y.num
+  result.den = y.den
+
+func `+=`*[T](x: var Rational[T], y: Rational[T]) =
+  ## Adds the rational `y` to the rational `x` in-place.
+  let common = lcm(x.den, y.den)
+  x.num = common div x.den * x.num + common div y.den * y.num
+  x.den = common
+  reduce(x)
+
+func `+=`*[T](x: var Rational[T], y: T) =
+  ## Adds the int `y` to the rational `x` in-place.
+  x.num += y * x.den
+
+func `-`*[T](x: Rational[T]): Rational[T] =
+  ## Unary minus for rational numbers.
+  result.num = -x.num
+  result.den = x.den
+
+func `-`*[T](x, y: Rational[T]): Rational[T] =
+  ## Subtracts two rational numbers.
+  let common = lcm(x.den, y.den)
+  result.num = common div x.den * x.num - common div y.den * y.num
+  result.den = common
+  reduce(result)
+
+func `-`*[T](x: Rational[T], y: T): Rational[T] =
+  ## Subtracts the int `y` from the rational `x`.
+  result.num = x.num - y * x.den
+  result.den = x.den
+
+func `-`*[T](x: T, y: Rational[T]): Rational[T] =
+  ## Subtracts the rational `y` from the int `x`.
+  result.num = x * y.den - y.num
+  result.den = y.den
+
+func `-=`*[T](x: var Rational[T], y: Rational[T]) =
+  ## Subtracts the rational `y` from the rational `x` in-place.
+  let common = lcm(x.den, y.den)
+  x.num = common div x.den * x.num - common div y.den * y.num
+  x.den = common
+  reduce(x)
+
+func `-=`*[T](x: var Rational[T], y: T) =
+  ## Subtracts the int `y` from the rational `x` in-place.
+  x.num -= y * x.den
+
+func `*`*[T](x, y: Rational[T]): Rational[T] =
+  ## Multiplies two rational numbers.
+  result.num = x.num * y.num
+  result.den = x.den * y.den
+  reduce(result)
+
+func `*`*[T](x: Rational[T], y: T): Rational[T] =
+  ## Multiplies the rational `x` with the int `y`.
+  result.num = x.num * y
+  result.den = x.den
+  reduce(result)
+
+func `*`*[T](x: T, y: Rational[T]): Rational[T] =
+  ## Multiplies the int `x` with the rational `y`.
+  result.num = x * y.num
+  result.den = y.den
+  reduce(result)
+
+func `*=`*[T](x: var Rational[T], y: Rational[T]) =
+  ## Multiplies the rational `x` by `y` in-place.
+  x.num *= y.num
+  x.den *= y.den
+  reduce(x)
+
+func `*=`*[T](x: var Rational[T], y: T) =
+  ## Multiplies the rational `x` by the int `y` in-place.
+  x.num *= y
+  reduce(x)
+
+func reciprocal*[T](x: Rational[T]): Rational[T] =
+  ## Calculates the reciprocal of `x` (`1/x`).
+  ## If `x` is 0, raises `DivByZeroDefect`.
+  if x.num > 0:
+    result.num = x.den
+    result.den = x.num
+  elif x.num < 0:
+    result.num = -x.den
+    result.den = -x.num
+  else:
+    raise newException(DivByZeroDefect, "division by zero")
+
+func `/`*[T](x, y: Rational[T]): Rational[T] =
+  ## Divides the rational `x` by the rational `y`.
+  result.num = x.num * y.den
+  result.den = x.den * y.num
+  reduce(result)
+
+func `/`*[T](x: Rational[T], y: T): Rational[T] =
+  ## Divides the rational `x` by the int `y`.
+  result.num = x.num
+  result.den = x.den * y
+  reduce(result)
+
+func `/`*[T](x: T, y: Rational[T]): Rational[T] =
+  ## Divides the int `x` by the rational `y`.
+  result.num = x * y.den
+  result.den = y.num
+  reduce(result)
+
+func `/=`*[T](x: var Rational[T], y: Rational[T]) =
+  ## Divides the rational `x` by the rational `y` in-place.
+  x.num *= y.den
+  x.den *= y.num
+  reduce(x)
+
+func `/=`*[T](x: var Rational[T], y: T) =
+  ## Divides the rational `x` by the int `y` in-place.
+  x.den *= y
+  reduce(x)
+
+func cmp*(x, y: Rational): int =
+  ## Compares two rationals. Returns
+  ## * a value less than zero, if `x < y`
+  ## * a value greater than zero, if `x > y`
+  ## * zero, if `x == y`
+  (x - y).num
+
+func `<`*(x, y: Rational): bool =
+  ## Returns true if `x` is less than `y`.
+  (x - y).num < 0
+
+func `<=`*(x, y: Rational): bool =
+  ## Returns tue if `x` is less than or equal to `y`.
+  (x - y).num <= 0
+
+func `==`*(x, y: Rational): bool =
+  ## Compares two rationals for equality.
+  (x - y).num == 0
+
+func abs*[T](x: Rational[T]): Rational[T] =
+  ## Returns the absolute value of `x`.
+  runnableExamples:
+    doAssert abs(1 // 2) == 1 // 2
+    doAssert abs(-1 // 2) == 1 // 2
+
+  result.num = abs x.num
+  result.den = abs x.den
+
+func `div`*[T: SomeInteger](x, y: Rational[T]): T =
+  ## Computes the rational truncated division.
+  (x.num * y.den) div (y.num * x.den)
+
+func `mod`*[T: SomeInteger](x, y: Rational[T]): Rational[T] =
+  ## Computes the rational modulo by truncated division (remainder).
+  ## This is same as `x - (x div y) * y`.
+  result = ((x.num * y.den) mod (y.num * x.den)) // (x.den * y.den)
+  reduce(result)
+
+func floorDiv*[T: SomeInteger](x, y: Rational[T]): T =
+  ## Computes the rational floor division.
+  ##
+  ## Floor division is conceptually defined as `floor(x / y)`.
+  ## This is different from the `div` operator, which is defined
+  ## as `trunc(x / y)`. That is, `div` rounds towards 0 and `floorDiv`
+  ## rounds down.
+  floorDiv(x.num * y.den, y.num * x.den)
+
+func floorMod*[T: SomeInteger](x, y: Rational[T]): Rational[T] =
+  ## Computes the rational modulo by floor division (modulo).
+  ##
+  ## This is same as `x - floorDiv(x, y) * y`.
+  ## This func behaves the same as the `%` operator in Python.
+  result = floorMod(x.num * y.den, y.num * x.den) // (x.den * y.den)
+  reduce(result)
+
+func hash*[T](x: Rational[T]): Hash =
+  ## Computes the hash for the rational `x`.
+  # reduce first so that hash(x) == hash(y) for x == y
+  var copy = x
+  reduce(copy)
+
+  var h: Hash = 0
+  h = h !& hash(copy.num)
+  h = h !& hash(copy.den)
+  result = !$h
+
+func `^`*[T: SomeInteger](x: Rational[T], y: T): Rational[T] =
+  ## Computes `x` to the power of `y`.
+  ##
+  ## The exponent `y` must be an integer. Negative exponents are supported
+  ## but floating point exponents are not.
+  runnableExamples:
+    doAssert (-3 // 5) ^ 0 == (1 // 1)
+    doAssert (-3 // 5) ^ 1 == (-3 // 5)
+    doAssert (-3 // 5) ^ 2 == (9 // 25)
+    doAssert (-3 // 5) ^ -2 == (25 // 9)
+
+  if y >= 0:
+    result.num = x.num ^ y
+    result.den = x.den ^ y
+  else:
+    result.num = x.den ^ -y
+    result.den = x.num ^ -y
+  # Note that all powers of reduced rationals are already reduced,
+  # so we don't need to call reduce() here
diff --git a/lib/pure/re.nim b/lib/pure/re.nim
deleted file mode 100755
index dfa191963..000000000
--- a/lib/pure/re.nim
+++ /dev/null
@@ -1,340 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Regular expression support for Nimrod. Consider using the pegs module
-## instead.
-## Currently this module is implemented by providing a wrapper around the
-## `PRCE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
-## C library. This means that your application will depend on the PRCE
-## library's licence when using this module, which should not be a problem
-## though.
-## PRCE's licence follows:
-##
-## .. include:: ../doc/regexprs.txt
-##
-
-import
-  pcre, strutils
-
-const
-  MaxSubpatterns* = 10
-    ## defines the maximum number of subpatterns that can be captured.
-    ## More subpatterns cannot be captured!
-
-type
-  TRegExFlag* = enum     ## options for regular expressions
-    reIgnoreCase = 0,    ## do caseless matching
-    reMultiLine = 1,     ## ``^`` and ``$`` match newlines within data 
-    reDotAll = 2,        ## ``.`` matches anything including NL
-    reExtended = 3       ## ignore whitespace and ``#`` comments
-    
-  TRegExDesc {.pure, final.}  = object 
-    h: PPcre
-    
-  TRegEx* = ref TRegExDesc ## a compiled regular expression
-    
-  EInvalidRegEx* = object of EInvalidValue
-    ## is raised if the pattern is no valid regular expression.
-
-proc rawCompile(pattern: string, flags: cint): PPcre =
-  var
-    msg: CString
-    offset: int
-    com = pcreCompile(pattern, flags, addr(msg), addr(offset), nil)
-  if com == nil:
-    var e: ref EInvalidRegEx
-    new(e)
-    e.msg = $msg & "\n" & pattern & "\n" & repeatChar(offset) & "^\n"
-    raise e
-  return com
-
-proc finalizeRegEx(x: TRegEx) = dealloc(x.h)
-
-proc re*(s: string, flags = {reExtended}): TRegEx =
-  ## Constructor of regular expressions. Note that Nimrod's
-  ## extended raw string literals supports this syntax ``re"[abc]"`` as
-  ## a short form for ``re(r"[abc]")``.
-  new(result, finalizeRegEx)
-  result.h = rawCompile(s, cast[cint](flags))
-  
-proc matchOrFind(s: string, pattern: TRegEx, matches: var openarray[string],
-                 start, flags: cint): cint =
-  var
-    rawMatches: array[0..maxSubpatterns * 3 - 1, cint]
-    res = pcreExec(pattern.h, nil, s, len(s), start, flags,
-      cast[ptr cint](addr(rawMatches)), maxSubpatterns * 3)
-  if res < 0'i32: return res
-  for i in 1..int(res)-1:
-    var a = rawMatches[i * 2]
-    var b = rawMatches[i * 2 + 1]
-    if a >= 0'i32: matches[i-1] = copy(s, int(a), int(b)-1)
-    else: matches[i-1] = ""
-  return rawMatches[1] - rawMatches[0]
-
-proc matchOrFind(s: string, pattern: TRegEx, start, flags: cint): cint =
-  var rawMatches: array [0..maxSubpatterns * 3 - 1, cint]
-  result = pcreExec(pattern.h, nil, s, len(s), start, flags,
-                    cast[ptr cint](addr(rawMatches)), maxSubpatterns * 3)
-  if result >= 0'i32:
-    result = rawMatches[1] - rawMatches[0]
-
-proc match*(s: string, pattern: TRegEx, matches: var openarray[string],
-           start = 0): bool =
-  ## returns ``true`` if ``s[start..]`` matches the ``pattern`` and
-  ## the captured substrings in the array ``matches``. If it does not
-  ## match, nothing is written into ``matches`` and ``false`` is
-  ## returned.
-  return matchOrFind(s, pattern, matches, start, 
-                     PCRE_ANCHORED) == cint(s.len - start)
-
-proc match*(s: string, pattern: TRegEx, start = 0): bool =
-  ## returns ``true`` if ``s[start..]`` matches the ``pattern``.
-  return matchOrFind(s, pattern, start, PCRE_ANCHORED) == cint(s.len - start)
-
-proc matchLen*(s: string, pattern: TRegEx, matches: var openarray[string],
-              start = 0): int =
-  ## the same as ``match``, but it returns the length of the match,
-  ## if there is no match, -1 is returned. Note that a match length
-  ## of zero can happen.
-  return matchOrFind(s, pattern, matches, start, PCRE_ANCHORED)
-
-proc matchLen*(s: string, pattern: TRegEx, start = 0): int =
-  ## the same as ``match``, but it returns the length of the match,
-  ## if there is no match, -1 is returned. Note that a match length
-  ## of zero can happen. 
-  return matchOrFind(s, pattern, start, PCRE_ANCHORED)
-
-proc find*(s: string, pattern: TRegEx, matches: var openarray[string],
-           start = 0): int =
-  ## returns the starting position of ``pattern`` in ``s`` and the captured
-  ## substrings in the array ``matches``. If it does not match, nothing
-  ## is written into ``matches`` and -1 is returned.
-  var
-    rawMatches: array[0..maxSubpatterns * 3 - 1, cint]
-    res = pcreExec(pattern.h, nil, s, len(s), start, 0'i32,
-      cast[ptr cint](addr(rawMatches)), maxSubpatterns * 3)
-  if res < 0'i32: return res
-  for i in 1..int(res)-1:
-    var a = rawMatches[i * 2]
-    var b = rawMatches[i * 2 + 1]
-    if a >= 0'i32: matches[i-1] = copy(s, int(a), int(b)-1)
-    else: matches[i-1] = ""
-  return rawMatches[0]
-
-proc find*(s: string, pattern: TRegEx, start = 0): int =
-  ## returns the starting position of ``pattern`` in ``s``. If it does not
-  ## match, -1 is returned.
-  var matches: array[0..maxSubpatterns-1, string]
-  result = find(s, pattern, matches, start)
-
-template `=~` *(s: string, pattern: TRegEx): expr = 
-  ## This calls ``match`` with an implicit declared ``matches`` array that 
-  ## can be used in the scope of the ``=~`` call: 
-  ## 
-  ## .. code-block:: nimrod
-  ##
-  ##   if line =~ re"\s*(\w+)\s*\=\s*(\w+)": 
-  ##     # matches a key=value pair:
-  ##     echo("Key: ", matches[0])
-  ##     echo("Value: ", matches[1])
-  ##   elif line =~ re"\s*(\#.*)":
-  ##     # matches a comment
-  ##     # note that the implicit ``matches`` array is different from the
-  ##     # ``matches`` array of the first branch
-  ##     echo("comment: ", matches[0])
-  ##   else:
-  ##     echo("syntax error")
-  ##
-  when not definedInScope(matches):
-    var matches: array[0..maxSubPatterns-1, string]
-  match(s, pattern, matches)
-
-# ------------------------- more string handling ------------------------------
-
-proc contains*(s: string, pattern: TRegEx, start = 0): bool =
-  ## same as ``find(s, pattern, start) >= 0``
-  return find(s, pattern, start) >= 0
-
-proc contains*(s: string, pattern: TRegEx, matches: var openArray[string],
-              start = 0): bool =
-  ## same as ``find(s, pattern, matches, start) >= 0``
-  return find(s, pattern, matches, start) >= 0
-
-proc startsWith*(s: string, prefix: TRegEx): bool =
-  ## returns true if `s` starts with the pattern `prefix`
-  result = matchLen(s, prefix) >= 0
-
-proc endsWith*(s: string, suffix: TRegEx): bool =
-  ## returns true if `s` ends with the pattern `prefix`
-  for i in 0 .. s.len-1:
-    if matchLen(s, suffix, i) == s.len - i: return true
-
-proc replace*(s: string, sub: TRegEx, by: string): string =
-  ## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by`
-  ## with the notation ``$i`` and ``$#`` (see strutils.`%`). Examples:
-  ##
-  ## .. code-block:: nimrod
-  ##   "var1=key; var2=key2".replace(re"(\w+)'='(\w+)", "$1<-$2$2")
-  ##
-  ## Results in:
-  ##
-  ## .. code-block:: nimrod
-  ##
-  ##   "var1<-keykey; val2<-key2key2"
-  result = ""
-  var i = 0
-  var caps: array[0..maxSubpatterns-1, string]
-  while i < s.len:
-    var x = matchLen(s, sub, caps, i)
-    if x <= 0:
-      add(result, s[i])
-      inc(i)
-    else:
-      addf(result, by, caps)
-      inc(i, x)
-  # copy the rest:
-  add(result, copy(s, i))
-  
-proc parallelReplace*(s: string, subs: openArray[
-                      tuple[pattern: TRegEx, repl: string]]): string = 
-  ## Returns a modified copy of `s` with the substitutions in `subs`
-  ## applied in parallel.
-  result = ""
-  var i = 0
-  var caps: array[0..maxSubpatterns-1, string]
-  while i < s.len:
-    block searchSubs:
-      for j in 0..high(subs):
-        var x = matchLen(s, subs[j][0], caps, i)
-        if x > 0:
-          addf(result, subs[j][1], caps)
-          inc(i, x)
-          break searchSubs
-      add(result, s[i])
-      inc(i)
-  # copy the rest:
-  add(result, copy(s, i))  
-  
-proc transformFile*(infile, outfile: string,
-                    subs: openArray[tuple[pattern: TRegEx, repl: string]]) =
-  ## reads in the file `infile`, performs a parallel replacement (calls
-  ## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
-  ## error occurs. This is supposed to be used for quick scripting.
-  var x = readFile(infile)
-  if not isNil(x):
-    var f: TFile
-    if open(f, outfile, fmWrite):
-      write(f, x.parallelReplace(subs))
-      close(f)
-    else:
-      quit("cannot open for writing: " & outfile)
-  else:
-    quit("cannot open for reading: " & infile)
-  
-iterator split*(s: string, sep: TRegEx): string =
-  ## Splits the string `s` into substrings.
-  ##
-  ## Substrings are separated by the regular expression `sep`.
-  ## Examples:
-  ##
-  ## .. code-block:: nimrod
-  ##   for word in split("00232this02939is39an22example111", re"\d+"):
-  ##     writeln(stdout, word)
-  ##
-  ## Results in:
-  ##
-  ## .. code-block:: nimrod
-  ##   "this"
-  ##   "is"
-  ##   "an"
-  ##   "example"
-  ##
-  var
-    first = 0
-    last = 0
-  while last < len(s):
-    var x = matchLen(s, sep, last)
-    if x > 0: inc(last, x)
-    first = last
-    while last < len(s):
-      inc(last)
-      x = matchLen(s, sep, last)
-      if x > 0: break
-    if first < last:
-      yield copy(s, first, last-1)
-
-proc split*(s: string, sep: TRegEx): seq[string] =
-  ## Splits the string `s` into substrings.
-  accumulateResult(split(s, sep))
-  
-proc escapeRe*(s: string): string = 
-  ## escapes `s` so that it is matched verbatim when used as a regular 
-  ## expression.
-  result = ""
-  for c in items(s):
-    case c
-    of 'a'..'z', 'A'..'Z', '0'..'9', '_':
-      result.add(c)
-    else: 
-      result.add("\\x")
-      result.add(toHex(ord(c), 2))
-  
-const ## common regular expressions
-  reIdentifier* = r"\b[a-zA-Z_]+[a-zA-Z_0-9]*\b"  ## describes an identifier
-  reNatural* = r"\b\d+\b" ## describes a natural number
-  reInteger* = r"\b[-+]?\d+\b" ## describes an integer
-  reHex* = r"\b0[xX][0-9a-fA-F]+\b" ## describes a hexadecimal number
-  reBinary* = r"\b0[bB][01]+\b" ## describes a binary number (example: 0b11101)
-  reOctal* = r"\b0[oO][0-7]+\b" ## describes an octal number (example: 0o777)
-  reFloat* = r"\b[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\b"
-    ## describes a floating point number
-  reEmail* = r"\b[a-zA-Z0-9!#$%&'*+/=?^_`{|}~\-]+(?:\. &" &
-             r"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)" &
-             r"*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+" &
-             r"(?:[a-zA-Z]{2}|com|org|" &
-             r"net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\b"
-    ## describes a common email address
-  reURL* = r"\b(http(s)?|ftp|gopher|telnet|file|notes|ms\-help):" &
-           r"((//)|(\\\\))+[\w\d:#@%/;$()~_?\+\-\=\\\.\&]*\b"
-    ## describes an URL
-
-when isMainModule:
-  assert match("(a b c)", re"\( .* \)")
-  assert match("WHiLe", re("while", {reIgnoreCase}))
-  
-  assert "0158787".match(re"\d+")
-  assert "ABC 0232".match(re"\w+\s+\d+")
-  assert "ABC".match(re"\d+ | \w+")
-
-  assert matchLen("key", re(reIdentifier)) == 3
-
-  var pattern = re"[a-z0-9]+\s*=\s*[a-z0-9]+"
-  assert matchLen("key1=  cal9", pattern) == 11
-  
-  assert find("_____abc_______", re"abc") == 5
-  
-  var matches: array[0..5, string]
-  if match("abcdefg", re"c(d)ef(g)", matches, 2): 
-    assert matches[0] == "d"
-    assert matches[1] == "g"
-  else:
-    assert false
-  
-  if "abc" =~ re"(a)bcxyz|(\w+)":
-    assert matches[1] == "abc"
-  else:
-    assert false
-    
-  assert "var1=key; var2=key2".endsWith(re"\w+=\w+")
-  assert("var1=key; var2=key2".replace(re"(\w+)=(\w+)", "$1<-$2$2") ==
-         "var1<-keykey; var2<-key2key2")
-
-  for word in split("00232this02939is39an22example111", re"\d+"):
-    writeln(stdout, word)
-
diff --git a/lib/pure/regexprs.nim b/lib/pure/regexprs.nim
deleted file mode 100755
index 43c7f05be..000000000
--- a/lib/pure/regexprs.nim
+++ /dev/null
@@ -1,179 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Regular expression support for Nimrod.
-## Currently this module is implemented by providing a wrapper around the
-## `PRCE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
-## C library. This means that your application will depend on the PRCE
-## library's licence when using this module, which should not be a problem
-## though.
-## PRCE's licence follows:
-##
-## .. include:: ../doc/regexprs.txt
-##
-
-# This is not just a convenient wrapper for the pcre library; the
-# API will stay the same if the implementation should change.
-
-{.deprecated.}
-
-import
-  pcre, strutils
-
-type
-  EInvalidRegEx* = object of EInvalidValue
-    ## is raised if the pattern is no valid regular expression.
-
-const
-  MaxSubpatterns* = 10
-    ## defines the maximum number of subpatterns that can be captured.
-    ## More subpatterns cannot be captured!
-
-proc match*(s, pattern: string, matches: var openarray[string],
-            start: int = 0): bool
-  ## returns ``true`` if ``s[start..]`` matches the ``pattern`` and
-  ## the captured substrings in the array ``matches``. If it does not
-  ## match, nothing is written into ``matches`` and ``false`` is
-  ## returned.
-
-proc match*(s, pattern: string, start: int = 0): bool
-  ## returns ``true`` if ``s`` matches the ``pattern`` beginning from ``start``.
-
-proc matchLen*(s, pattern: string, matches: var openarray[string],
-               start: int = 0): int
-  ## the same as ``match``, but it returns the length of the match,
-  ## if there is no match, -1 is returned. Note that a match length
-  ## of zero can happen.
-
-proc find*(s, pattern: string, matches: var openarray[string],
-           start: int = 0): bool
-  ## returns ``true`` if ``pattern`` occurs in ``s`` and the captured
-  ## substrings in the array ``matches``. If it does not match, nothing
-  ## is written into ``matches``.
-
-proc find*(s, pattern: string, start: int = 0): bool
-  ## returns ``true`` if ``pattern`` occurs in ``s``.
-
-proc rawCompile(pattern: string, flags: cint): PPcre =
-  var
-    msg: CString
-    offset: int
-    com = pcreCompile(pattern, flags, addr(msg), addr(offset), nil)
-  if com == nil:
-    var e: ref EInvalidRegEx
-    new(e)
-    e.msg = $msg & "\n" & pattern & "\n" & repeatChar(offset) & "^\n"
-    raise e
-  return com
-
-proc matchOrFind(s: string, pattern: PPcre, matches: var openarray[string],
-                 start: cint): cint =
-  var
-    rawMatches: array [0..maxSubpatterns * 3 - 1, cint]
-    res = int(pcreExec(pattern, nil, s, len(s), start, 0,
-      cast[ptr cint](addr(rawMatches)), maxSubpatterns * 3))
-  dealloc(pattern)
-  if res < 0: return res
-  for i in 0..res-1:
-    var
-      a = rawMatches[i * 2]
-      b = rawMatches[i * 2 + 1]
-    if a >= 0'i32: matches[i] = copy(s, a, int(b)-1)
-    else: matches[i] = ""
-  return res
-
-proc matchOrFind(s: string, pattern: PPcre, start: cint): cint =
-  var
-    rawMatches: array [0..maxSubpatterns * 3 - 1, cint]
-    res = pcreExec(pattern, nil, s, len(s), start, 0,
-                   cast[ptr cint](addr(rawMatches)), maxSubpatterns * 3)
-  dealloc(pattern)
-  return res
-
-proc match(s, pattern: string, matches: var openarray[string],
-           start: int = 0): bool =
-  return matchOrFind(s, rawCompile(pattern, PCRE_ANCHORED),
-                     matches, start) >= 0'i32
-
-proc matchLen(s, pattern: string, matches: var openarray[string],
-              start: int = 0): int =
-  return matchOrFind(s, rawCompile(pattern, PCRE_ANCHORED), matches, start)
-
-proc find(s, pattern: string, matches: var openarray[string],
-          start: int = 0): bool =
-  return matchOrFind(s, rawCompile(pattern, PCRE_MULTILINE),
-                     matches, start) >= 0'i32
-
-proc match(s, pattern: string, start: int = 0): bool =
-  return matchOrFind(s, rawCompile(pattern, PCRE_ANCHORED), start) >= 0'i32
-
-proc find(s, pattern: string, start: int = 0): bool =
-  return matchOrFind(s, rawCompile(pattern, PCRE_MULTILINE), start) >= 0'i32
-
-template `=~` *(s, pattern: expr): expr = 
-  ## This calls ``match`` with an implicit declared ``matches`` array that 
-  ## can be used in the scope of the ``=~`` call: 
-  ## 
-  ## .. code-block:: nimrod
-  ##
-  ##   if line =~ r"\s*(\w+)\s*\=\s*(\w+)": 
-  ##     # matches a key=value pair:
-  ##     echo("Key: ", matches[1])
-  ##     echo("Value: ", matches[2])
-  ##   elif line =~ r"\s*(\#.*)":
-  ##     # matches a comment
-  ##     # note that the implicit ``matches`` array is different from the
-  ##     # ``matches`` array of the first branch
-  ##     echo("comment: ", matches[1])
-  ##   else:
-  ##     echo("syntax error")
-  ##
-  when not definedInScope(matches):
-    var matches: array[0..maxSubPatterns-1, string]
-  match(s, pattern, matches)
-  
-
-const ## common regular expressions
-  reIdentifier* = r"\b[a-zA-Z_][a-zA-Z_0-9]*\b"  ## describes an identifier
-  reNatural* = r"\b\d+\b" ## describes a natural number
-  reInteger* = r"\b[-+]?\d+\b" ## describes an integer
-  reHex* = r"\b0[xX][0-9a-fA-F]+\b" ## describes a hexadecimal number
-  reBinary* = r"\b0[bB][01]+\b" ## describes a binary number (example: 0b11101)
-  reOctal* = r"\b0[oO][0-7]+\b" ## describes an octal number (example: 0o777)
-  reFloat* = r"\b[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\b"
-    ## describes a floating point number
-  reEmail* = r"\b[a-zA-Z0-9!#$%&'*+/=?^_`{|}~\-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)" &
-             r"*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+(?:[a-zA-Z]{2}|com|org|" &
-             r"net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\b"
-    ## describes a common email address
-  reURL* = r"\b(http(s)?|ftp|gopher|telnet|file|notes|ms\-help):" &
-           r"((//)|(\\\\))+[\w\d:#@%/;$()~_?\+\-\=\\\.\&]*\b"
-    ## describes an URL
-    
-proc verbose*(pattern: string): string {.noSideEffect.} = 
-  ## deletes whitespace from a pattern that is not escaped or in a character
-  ## class. This is modelled after Perl's ``/x`` modifier. 
-  result = ""
-  var i = 0
-  while i < pattern.len: 
-    case pattern[i]
-    of ' ', '\t': 
-      inc i
-    of '\\': 
-      add result, '\\'
-      add result, pattern[i+1]
-      inc i, 2
-    of '[': 
-      while pattern[i] != ']' and pattern[i] != '\0': 
-        add result, pattern[i]
-        inc i
-    else: 
-      add result, pattern[i]
-      inc i
-
diff --git a/lib/pure/reservedmem.nim b/lib/pure/reservedmem.nim
new file mode 100644
index 000000000..ffa0128dc
--- /dev/null
+++ b/lib/pure/reservedmem.nim
@@ -0,0 +1,229 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## :Authors: Zahary Karadjov
+##
+## This module provides utilities for reserving portions of the
+## address space of a program without consuming physical memory.
+## It can be used to implement a dynamically resizable buffer that
+## is guaranteed to remain in the same memory location. The buffer
+## will be able to grow up to the size of the initially reserved
+## portion of the address space.
+##
+## Unstable API.
+
+from std/oserrors import raiseOSError, osLastError
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+template distance*(lhs, rhs: pointer): int =
+  cast[int](rhs) - cast[int](lhs)
+
+template shift*(p: pointer, distance: int): pointer =
+  cast[pointer](cast[int](p) + distance)
+
+type
+  MemAccessFlags* = int
+
+  ReservedMem* = object
+    memStart: pointer
+    usedMemEnd: pointer
+    committedMemEnd: pointer
+    memEnd: pointer
+    maxCommittedAndUnusedPages: int
+    accessFlags: MemAccessFlags
+
+  ReservedMemSeq*[T] = object
+    mem: ReservedMem
+
+when defined(windows):
+  import std/winlean
+  import std/private/win_getsysteminfo
+
+  proc getAllocationGranularity: uint =
+    var sysInfo: SystemInfo
+    getSystemInfo(addr sysInfo)
+    return uint(sysInfo.dwAllocationGranularity)
+
+  let allocationGranularity = getAllocationGranularity().int
+
+  const
+    memNoAccess = MemAccessFlags(PAGE_NOACCESS)
+    memExec* = MemAccessFlags(PAGE_EXECUTE)
+    memExecRead* = MemAccessFlags(PAGE_EXECUTE_READ)
+    memExecReadWrite* = MemAccessFlags(PAGE_EXECUTE_READWRITE)
+    memRead* = MemAccessFlags(PAGE_READONLY)
+    memReadWrite* = MemAccessFlags(PAGE_READWRITE)
+
+  template check(expr) =
+    let r = expr
+    if r == cast[typeof(r)](0):
+      raiseOSError(osLastError())
+
+else:
+  import std/posix
+
+  let allocationGranularity = sysconf(SC_PAGESIZE)
+
+  let
+    memNoAccess = MemAccessFlags(PROT_NONE)
+    memExec* = MemAccessFlags(PROT_EXEC)
+    memExecRead* = MemAccessFlags(PROT_EXEC or PROT_READ)
+    memExecReadWrite* = MemAccessFlags(PROT_EXEC or PROT_READ or PROT_WRITE)
+    memRead* = MemAccessFlags(PROT_READ)
+    memReadWrite* = MemAccessFlags(PROT_READ or PROT_WRITE)
+
+  template check(expr) =
+    if not expr:
+      raiseOSError(osLastError())
+
+func nextAlignedOffset(n, alignment: int): int =
+  result = n
+  let m = n mod alignment
+  if m != 0: result += alignment - m
+
+
+when defined(windows):
+  const
+    MEM_DECOMMIT = 0x4000
+    MEM_RESERVE = 0x2000
+    MEM_COMMIT = 0x1000
+  proc virtualFree(lpAddress: pointer, dwSize: int,
+                   dwFreeType: int32): cint {.header: "<windows.h>", stdcall,
+                   importc: "VirtualFree".}
+  proc virtualAlloc(lpAddress: pointer, dwSize: int, flAllocationType,
+                    flProtect: int32): pointer {.
+                    header: "<windows.h>", stdcall, importc: "VirtualAlloc".}
+
+proc init*(T: type ReservedMem,
+           maxLen: Natural,
+           initLen: Natural = 0,
+           initCommitLen = initLen,
+           memStart = pointer(nil),
+           accessFlags = memReadWrite,
+           maxCommittedAndUnusedPages = 3): ReservedMem =
+
+  assert initLen <= initCommitLen
+  let commitSize = nextAlignedOffset(initCommitLen, allocationGranularity)
+
+  when defined(windows):
+    result.memStart = virtualAlloc(memStart, maxLen, MEM_RESERVE,
+        accessFlags.cint)
+    check result.memStart
+    if commitSize > 0:
+      check virtualAlloc(result.memStart, commitSize, MEM_COMMIT,
+          accessFlags.cint)
+  else:
+    var allocFlags = MAP_PRIVATE or MAP_ANONYMOUS # or MAP_NORESERVE
+                                                  # if memStart != nil:
+                                                  #  allocFlags = allocFlags or MAP_FIXED_NOREPLACE
+    result.memStart = mmap(memStart, maxLen, PROT_NONE, allocFlags, -1, 0)
+    check result.memStart != MAP_FAILED
+    if commitSize > 0:
+      check mprotect(result.memStart, commitSize, cint(accessFlags)) == 0
+
+  result.usedMemEnd = result.memStart.shift(initLen)
+  result.committedMemEnd = result.memStart.shift(commitSize)
+  result.memEnd = result.memStart.shift(maxLen)
+  result.accessFlags = accessFlags
+  result.maxCommittedAndUnusedPages = maxCommittedAndUnusedPages
+
+func len*(m: ReservedMem): int =
+  distance(m.memStart, m.usedMemEnd)
+
+func commitedLen*(m: ReservedMem): int =
+  distance(m.memStart, m.committedMemEnd)
+
+func maxLen*(m: ReservedMem): int =
+  distance(m.memStart, m.memEnd)
+
+proc setLen*(m: var ReservedMem, newLen: int) =
+  let len = m.len
+  m.usedMemEnd = m.memStart.shift(newLen)
+  if newLen > len:
+    let d = distance(m.committedMemEnd, m.usedMemEnd)
+    if d > 0:
+      let commitExtensionSize = nextAlignedOffset(d, allocationGranularity)
+      when defined(windows):
+        check virtualAlloc(m.committedMemEnd, commitExtensionSize,
+                           MEM_COMMIT, m.accessFlags.cint)
+      else:
+        check mprotect(m.committedMemEnd, commitExtensionSize,
+            m.accessFlags.cint) == 0
+  else:
+    let d = distance(m.usedMemEnd, m.committedMemEnd) -
+            m.maxCommittedAndUnusedPages * allocationGranularity
+    if d > 0:
+      let commitSizeShrinkage = nextAlignedOffset(d, allocationGranularity)
+      let newCommitEnd = m.committedMemEnd.shift(-commitSizeShrinkage)
+
+      when defined(windows):
+        check virtualFree(newCommitEnd, commitSizeShrinkage, MEM_DECOMMIT)
+      else:
+        check posix_madvise(newCommitEnd, commitSizeShrinkage,
+                            POSIX_MADV_DONTNEED) == 0
+
+      m.committedMemEnd = newCommitEnd
+
+proc init*(SeqType: type ReservedMemSeq,
+           maxLen: Natural,
+           initLen: Natural = 0,
+           initCommitLen: Natural = 0,
+           memStart = pointer(nil),
+           accessFlags = memReadWrite,
+           maxCommittedAndUnusedPages = 3): SeqType =
+
+  let elemSize = sizeof(SeqType.T)
+  result.mem = ReservedMem.init(maxLen * elemSize,
+                                initLen * elemSize,
+                                initCommitLen * elemSize,
+                                memStart, accessFlags,
+                                maxCommittedAndUnusedPages)
+
+func `[]`*[T](s: ReservedMemSeq[T], pos: Natural): lent T =
+  let elemAddr = s.mem.memStart.shift(pos * sizeof(T))
+  rangeCheck elemAddr < s.mem.usedMemEnd
+  result = (cast[ptr T](elemAddr))[]
+
+func `[]`*[T](s: var ReservedMemSeq[T], pos: Natural): var T =
+  let elemAddr = s.mem.memStart.shift(pos * sizeof(T))
+  rangeCheck elemAddr < s.mem.usedMemEnd
+  result = (cast[ptr T](elemAddr))[]
+
+func `[]`*[T](s: ReservedMemSeq[T], rpos: BackwardsIndex): lent T =
+  return s[int(s.len) - int(rpos)]
+
+func `[]`*[T](s: var ReservedMemSeq[T], rpos: BackwardsIndex): var T =
+  return s[int(s.len) - int(rpos)]
+
+func len*[T](s: ReservedMemSeq[T]): int =
+  s.mem.len div sizeof(T)
+
+proc setLen*[T](s: var ReservedMemSeq[T], newLen: int) =
+  # TODO call destructors
+  s.mem.setLen(newLen * sizeof(T))
+
+proc add*[T](s: var ReservedMemSeq[T], val: T) =
+  let len = s.len
+  s.setLen(len + 1)
+  s[len] = val
+
+proc pop*[T](s: var ReservedMemSeq[T]): T =
+  assert s.usedMemEnd != s.memStart
+  let lastIdx = s.len - 1
+  result = s[lastIdx]
+  s.setLen(lastIdx)
+
+func commitedLen*[T](s: ReservedMemSeq[T]): int =
+  s.mem.commitedLen div sizeof(T)
+
+func maxLen*[T](s: ReservedMemSeq[T]): int =
+  s.mem.maxLen div sizeof(T)
+
diff --git a/lib/pure/ropes.nim b/lib/pure/ropes.nim
index df85baf92..8750aca87 100755..100644
--- a/lib/pure/ropes.nim
+++ b/lib/pure/ropes.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -8,17 +8,21 @@
 #
 
 ## This module contains support for a `rope`:idx: data type.
-## Ropes can represent very long strings efficiently; especially concatenation
+## Ropes can represent very long strings efficiently; in particular, concatenation
 ## is done in O(1) instead of O(n). They are essentially concatenation
-## trees that are only flattened when converting to a native Nimrod
-## string. The empty string is represented by ``nil``. Ropes are immutable and
+## trees that are only flattened when converting to a native Nim
+## string. The empty string is represented by `nil`. Ropes are immutable and
 ## subtrees can be shared without copying.
 ## Leaves can be cached for better memory efficiency at the cost of
 ## runtime efficiency.
 
-{.deadCodeElim: on.}
+include system/inclrtl
+import std/streams
 
-{.push debugger:off .} # the user does not want to trace a part
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, formatfloat, assertions]
+
+{.push debugger: off.} # the user does not want to trace a part
                        # of the standard library!
 
 const
@@ -27,72 +31,69 @@ const
 var
   cacheEnabled = false
 
-type 
-  PRope* = ref TRope ## empty rope is represented by nil
-  TRope {.acyclic, final, pure.} = object
-    left, right: PRope
+type
+  Rope* {.acyclic.} = ref object
+    ## A rope data type. The empty rope is represented by `nil`.
+    left, right: Rope
     length: int
-    data: string # != nil if a leaf
-
-proc isConc(r: PRope): bool {.inline.} = return isNil(r.data)
+    data: string # not empty if a leaf
 
 # Note that the left and right pointers are not needed for leafs.
 # Leaves have relatively high memory overhead (~30 bytes on a 32
 # bit machine) and we produce many of them. This is why we cache and
-# share leafs accross different rope trees.
+# share leafs across different rope trees.
 # To cache them they are inserted in another tree, a splay tree for best
 # performance. But for the caching tree we use the leaf's left and right
 # pointers.
 
-proc len*(a: PRope): int =
-  ## the rope's length
-  if a == nil: result = 0
-  else: result = a.length
-  
-proc newRope(): PRope = new(result)
-proc newRope(data: string): PRope = 
+proc len*(a: Rope): int {.rtl, extern: "nro$1".} =
+  ## The rope's length.
+  if a == nil: 0 else: a.length
+
+proc newRope(): Rope = new(result)
+proc newRope(data: string): Rope =
   new(result)
   result.length = len(data)
   result.data = data
 
-var 
-  cache: PRope                # the root of the cache tree
-  N: PRope                    # dummy rope needed for splay algorithm
+var
+  cache {.threadvar.}: Rope # the root of the cache tree
+  N {.threadvar.}: Rope     # dummy rope needed for splay algorithm
 
 when countCacheMisses:
   var misses, hits: int
-  
-proc splay(s: string, tree: PRope, cmpres: var int): PRope = 
+
+proc splay(s: string, tree: Rope, cmpres: var int): Rope =
   var c: int
   var t = tree
   N.left = nil
-  N.right = nil               # reset to nil
+  N.right = nil # reset to nil
   var le = N
   var r = N
-  while true: 
+  while true:
     c = cmp(s, t.data)
-    if c < 0: 
-      if (t.left != nil) and (s < t.left.data): 
+    if c < 0:
+      if (t.left != nil) and (s < t.left.data):
         var y = t.left
         t.left = y.right
         y.right = t
         t = y
-      if t.left == nil: break 
+      if t.left == nil: break
       r.left = t
       r = t
       t = t.left
-    elif c > 0: 
-      if (t.right != nil) and (s > t.right.data): 
+    elif c > 0:
+      if (t.right != nil) and (s > t.right.data):
         var y = t.right
         t.right = y.left
         y.left = t
         t = y
-      if t.right == nil: break 
+      if t.right == nil: break
       le.right = t
       le = t
       t = t.right
-    else: 
-      break 
+    else:
+      break
   cmpres = c
   le.right = t.left
   r.left = t.right
@@ -100,220 +101,232 @@ proc splay(s: string, tree: PRope, cmpres: var int): PRope =
   t.right = N.left
   result = t
 
-proc insertInCache(s: string, tree: PRope): PRope = 
+proc insertInCache(s: string, tree: Rope): Rope =
   var t = tree
-  if t == nil: 
+  if t == nil:
     result = newRope(s)
     when countCacheMisses: inc(misses)
-    return 
+    return
   var cmp: int
   t = splay(s, t, cmp)
-  if cmp == 0: 
+  if cmp == 0:
     # We get here if it's already in the Tree
     # Don't add it again
     result = t
     when countCacheMisses: inc(hits)
-  else: 
+  else:
     when countCacheMisses: inc(misses)
     result = newRope(s)
-    if cmp < 0: 
+    if cmp < 0:
       result.left = t.left
       result.right = t
       t.left = nil
-    else: 
+    else:
       # i > t.item:
       result.right = t.right
       result.left = t
       t.right = nil
 
-proc rope*(s: string): PRope =
-  ## Converts a string to a rope. 
-  if s.len == 0: 
+proc rope*(s: string = ""): Rope {.rtl, extern: "nro$1Str".} =
+  ## Converts a string to a rope.
+  runnableExamples:
+    let r = rope("I'm a rope")
+    doAssert $r == "I'm a rope"
+
+  if s.len == 0:
     result = nil
-  elif cacheEnabled: 
-    result = insertInCache(s, cache)
-    cache = result
-  else: 
-    result = newRope(s)
-  
-proc rope*(i: BiggestInt): PRope = 
-  ## Converts an int to a rope. 
+  else:
+    when nimvm:
+      # No caching in VM context
+      result = newRope(s)
+    else:
+      if cacheEnabled:
+        result = insertInCache(s, cache)
+        cache = result
+      else:
+        result = newRope(s)
+
+proc rope*(i: BiggestInt): Rope {.rtl, extern: "nro$1BiggestInt".} =
+  ## Converts an int to a rope.
+  runnableExamples:
+    let r = rope(429)
+    doAssert $r == "429"
+
   result = rope($i)
 
-proc rope*(f: BiggestFloat): PRope =
-  ## Converts a float to a rope. 
+proc rope*(f: BiggestFloat): Rope {.rtl, extern: "nro$1BiggestFloat".} =
+  ## Converts a float to a rope.
+  runnableExamples:
+    let r = rope(4.29)
+    doAssert $r == "4.29"
+
   result = rope($f)
 
-proc disableCache*() =
-  ## the cache is discarded and disabled. The GC will reuse its used memory.
-  cache = nil
-  cacheEnabled = false
-  
-proc enableCache*() =
+proc enableCache*() {.rtl, extern: "nro$1".} =
   ## Enables the caching of leaves. This reduces the memory footprint at
   ## the cost of runtime efficiency.
   cacheEnabled = true
 
-proc `&`*(a, b: PRope): PRope =
-  ## the concatenation operator for ropes.
-  if a == nil: 
+proc disableCache*() {.rtl, extern: "nro$1".} =
+  ## The cache is discarded and disabled. The GC will reuse its used memory.
+  cache = nil
+  cacheEnabled = false
+
+proc `&`*(a, b: Rope): Rope {.rtl, extern: "nroConcRopeRope".} =
+  ## The concatenation operator for ropes.
+  runnableExamples:
+    let r = rope("Hello, ") & rope("Nim!")
+    doAssert $r == "Hello, Nim!"
+
+  if a == nil:
     result = b
-  elif b == nil: 
+  elif b == nil:
     result = a
   else:
     result = newRope()
     result.length = a.length + b.length
-    when false:
-      # XXX rebalancing would be nice, but is too expensive.
-      result.left = a.left
-      var x = newRope()
-      x.left = a.right
-      x.right = b
-      result.right = x
-    else:
-      result.left = a
-      result.right = b
-  
-proc `&`*(a: PRope, b: string): PRope = 
-  ## the concatenation operator for ropes.
+    result.left = a
+    result.right = b
+
+proc `&`*(a: Rope, b: string): Rope {.rtl, extern: "nroConcRopeStr".} =
+  ## The concatenation operator for ropes.
+  runnableExamples:
+    let r = rope("Hello, ") & "Nim!"
+    doAssert $r == "Hello, Nim!"
+
   result = a & rope(b)
-  
-proc `&`*(a: string, b: PRope): PRope = 
-  ## the concatenation operator for ropes.
+
+proc `&`*(a: string, b: Rope): Rope {.rtl, extern: "nroConcStrRope".} =
+  ## The concatenation operator for ropes.
+  runnableExamples:
+    let r = "Hello, " & rope("Nim!")
+    doAssert $r == "Hello, Nim!"
+
   result = rope(a) & b
-  
-proc `&`*(a: openarray[PRope]): PRope = 
-  ## the concatenation operator for an openarray of ropes.
-  for i in countup(0, high(a)): result = result & a[i]
 
-proc add*(a: var PRope, b: PRope) =
-  ## adds `b` to the rope `a`.
+proc `&`*(a: openArray[Rope]): Rope {.rtl, extern: "nroConcOpenArray".} =
+  ## The concatenation operator for an `openArray` of ropes.
+  runnableExamples:
+    let r = &[rope("Hello, "), rope("Nim"), rope("!")]
+    doAssert $r == "Hello, Nim!"
+
+  for item in a: result = result & item
+
+proc add*(a: var Rope, b: Rope) {.rtl, extern: "nro$1Rope".} =
+  ## Adds `b` to the rope `a`.
+  runnableExamples:
+    var r = rope("Hello, ")
+    r.add(rope("Nim!"))
+    doAssert $r == "Hello, Nim!"
+
   a = a & b
 
-proc add*(a: var PRope, b: string) =
-  ## adds `b` to the rope `a`.
+proc add*(a: var Rope, b: string) {.rtl, extern: "nro$1Str".} =
+  ## Adds `b` to the rope `a`.
+  runnableExamples:
+    var r = rope("Hello, ")
+    r.add("Nim!")
+    doAssert $r == "Hello, Nim!"
+
   a = a & b
-  
-proc `[]`*(r: PRope, i: int): char =
-  ## returns the character at position `i` in the rope `r`. This is quite
-  ## expensive! Worst-case: O(n). If ``i >= r.len``, ``\0`` is returned.
+
+proc `[]`*(r: Rope, i: int): char {.rtl, extern: "nroCharAt".} =
+  ## Returns the character at position `i` in the rope `r`. This is quite
+  ## expensive! Worst-case: O(n). If `i >= r.len or i < 0`, `\0` is returned.
+  runnableExamples:
+    let r = rope("Hello, Nim!")
+
+    doAssert r[0] == 'H'
+    doAssert r[7] == 'N'
+    doAssert r[22] == '\0'
+
   var x = r
   var j = i
-  if x == nil: return
+  if x == nil or i < 0 or i >= r.len: return
   while true:
-    if not isConc(x):
-      if x.data.len <% j: return x.data[j]
-      return '\0'
+    if x != nil and x.data.len > 0:
+      # leaf
+      return x.data[j]
     else:
-      if x.left.len >% j:
+      if x.left.length > j:
         x = x.left
       else:
+        dec(j, x.left.length)
         x = x.right
-        dec(j, x.len)
 
-iterator leaves*(r: PRope): string =
-  ## iterates over any leaf string in the rope `r`.
+iterator leaves*(r: Rope): string =
+  ## Iterates over any leaf string in the rope `r`.
+  runnableExamples:
+    let r = rope("Hello") & rope(", Nim!")
+    let s = ["Hello", ", Nim!"]
+    var index = 0
+    for leave in r.leaves:
+      doAssert leave == s[index]
+      inc(index)
+
   if r != nil:
     var stack = @[r]
-    while stack.len > 0: 
+    while stack.len > 0:
       var it = stack.pop
-      while isConc(it):
+      while it.left != nil:
+        assert(it.right != nil)
         stack.add(it.right)
         it = it.left
         assert(it != nil)
-      assert(it.data != nil)
       yield it.data
-  
-iterator items*(r: PRope): char =
-  ## iterates over any character in the rope `r`.
+
+iterator items*(r: Rope): char =
+  ## Iterates over any character in the rope `r`.
   for s in leaves(r):
     for c in items(s): yield c
 
-proc write*(f: TFile, r: PRope) =
-  ## writes a rope to a file.
+proc write*(f: File, r: Rope) {.rtl, extern: "nro$1".} =
+  ## Writes a rope to a file.
   for s in leaves(r): write(f, s)
 
-proc `$`*(r: PRope): string = 
-  ## converts a rope back to a string.
-  result = newString(r.len)
-  setLen(result, 0)
+proc write*(s: Stream, r: Rope) {.rtl, extern: "nroWriteStream".} =
+  ## Writes a rope to a stream.
+  for rs in leaves(r): write(s, rs)
+
+proc `$`*(r: Rope): string {.rtl, extern: "nroToString".} =
+  ## Converts a rope back to a string.
+  result = newStringOfCap(r.len)
   for s in leaves(r): add(result, s)
 
-when false:
-  # Format string caching seems reasonable: All leaves can be shared and format
-  # string parsing has to be done only once. A compiled format string is stored
-  # as a rope. A negative length is used for the index into the args array.
-  proc compiledArg(idx: int): PRope =
-    new(result)
-    result.length = -idx
-  
-  proc compileFrmt(frmt: string): PRope = 
-    var i = 0
-    var length = len(frmt)
-    result = nil
-    var num = 0
-    while i < length: 
-      if frmt[i] == '$': 
-        inc(i)
-        case frmt[i]
-        of '$': 
-          add(result, "$")
-          inc(i)
-        of '#': 
-          inc(i)
-          add(result, compiledArg(num+1))
-          inc(num)
-        of '0'..'9': 
-          var j = 0
-          while true: 
-            j = j * 10 + ord(frmt[i]) - ord('0')
-            inc(i)
-            if frmt[i] notin {'0'..'9'}: break 
-          num = j
-          add(s, compiledArg(j))
-        of '{':
-          inc(i)
-          var j = 0
-          while frmt[i] in {'0'..'9'}:
-            j = j * 10 + ord(frmt[i]) - ord('0')
-            inc(i)
-          if frmt[i] == '}': inc(i)
-          else: raise newException(EInvalidValue, "invalid format string")
-          num = j
-          add(s, compiledArg(j))
-        else: raise newException(EInvalidValue, "invalid format string")
-      var start = i
-      while i < length: 
-        if frmt[i] != '$': inc(i)
-        else: break 
-      if i - 1 >= start: 
-        add(result, copy(frmt, start, i-1))
-  
-proc `%`*(frmt: string, args: openarray[PRope]): PRope =
-  ## `%` substitution operator for ropes. Does not support the ``$identifier``
-  ## nor ``${identifier}`` notations.
+proc `%`*(frmt: string, args: openArray[Rope]): Rope {.rtl, extern: "nroFormat".} =
+  ## `%` substitution operator for ropes. Does not support the `$identifier`
+  ## nor `${identifier}` notations.
+  runnableExamples:
+    let r1 = "$1 $2 $3" % [rope("Nim"), rope("is"), rope("a great language")]
+    doAssert $r1 == "Nim is a great language"
+
+    let r2 = "$# $# $#" % [rope("Nim"), rope("is"), rope("a great language")]
+    doAssert $r2 == "Nim is a great language"
+
+    let r3 = "${1} ${2} ${3}" % [rope("Nim"), rope("is"), rope("a great language")]
+    doAssert $r3 == "Nim is a great language"
+
   var i = 0
   var length = len(frmt)
   result = nil
   var num = 0
-  while i < length: 
-    if frmt[i] == '$': 
+  while i < length:
+    if frmt[i] == '$':
       inc(i)
       case frmt[i]
-      of '$': 
+      of '$':
         add(result, "$")
         inc(i)
-      of '#': 
+      of '#':
         inc(i)
         add(result, args[num])
         inc(num)
-      of '0'..'9': 
+      of '0'..'9':
         var j = 0
-        while true: 
+        while true:
           j = j * 10 + ord(frmt[i]) - ord('0')
           inc(i)
-          if frmt[i] notin {'0'..'9'}: break 
-        num = j
+          if i >= frmt.len or frmt[i] notin {'0'..'9'}: break
         add(result, args[j-1])
       of '{':
         inc(i)
@@ -322,44 +335,65 @@ proc `%`*(frmt: string, args: openarray[PRope]): PRope =
           j = j * 10 + ord(frmt[i]) - ord('0')
           inc(i)
         if frmt[i] == '}': inc(i)
-        else: raise newException(EInvalidValue, "invalid format string")
-        num = j
+        else: raise newException(ValueError, "invalid format string")
+
         add(result, args[j-1])
-      else: raise newException(EInvalidValue, "invalid format string")
+      else: raise newException(ValueError, "invalid format string")
     var start = i
-    while i < length: 
+    while i < length:
       if frmt[i] != '$': inc(i)
-      else: break 
-    if i - 1 >= start: 
-      add(result, copy(frmt, start, i - 1))
+      else: break
+    if i - 1 >= start:
+      add(result, substr(frmt, start, i - 1))
+
+proc addf*(c: var Rope, frmt: string, args: openArray[Rope]) {.rtl, extern: "nro$1".} =
+  ## Shortcut for `add(c, frmt % args)`.
+  runnableExamples:
+    var r = rope("Dash: ")
+    r.addf "$1 $2 $3", [rope("Nim"), rope("is"), rope("a great language")]
+    doAssert $r == "Dash: Nim is a great language"
 
-proc addf*(c: var PRope, frmt: string, args: openarray[PRope]) =
-  ## shortcut for ``add(c, frmt % args)``.
   add(c, frmt % args)
 
-proc equalsFile*(r: PRope, f: TFile): bool =
-  ## returns true if the contents of the file `f` equal `r`.
-  var bufSize = 1024 # reasonable start value
-  var buf = alloc(BufSize)
-  for s in leaves(r):
-    if s.len > bufSize:
-      bufSize = max(bufSize * 2, s.len)
-      buf = realloc(buf, bufSize)
-    var readBytes = readBuffer(f, buf, s.len)
-    result = readBytes == s.len and equalMem(buf, cstring(s), s.len)
-    if not result: break
-  if result:
-    result = readBuffer(f, buf, 1) == 0 # really at the end of file?
-  dealloc(buf)
-
-proc equalsFile*(r: PRope, f: string): bool =
-  ## returns true if the contents of the file `f` equal `r`. If `f` does not
-  ## exist, false is returned.
-  var bin: TFile
-  result = open(bin, f)
-  if result:
-    result = equalsFile(r, bin)
-    close(bin)
+when not defined(js) and not defined(nimscript):
+  const
+    bufSize = 1024 # 1 KB is reasonable
+
+  proc equalsFile*(r: Rope, f: File): bool {.rtl, extern: "nro$1File".} =
+    ## Returns true if the contents of the file `f` equal `r`.
+    var
+      buf: array[bufSize, char]
+      bpos = buf.len
+      blen = buf.len
+
+    for s in leaves(r):
+      var spos = 0
+      let slen = s.len
+      while spos < slen:
+        if bpos == blen:
+          # Read more data
+          bpos = 0
+          blen = readBuffer(f, addr(buf[0]), buf.len)
+          if blen == 0: # no more data in file
+            return false
+        let n = min(blen - bpos, slen - spos)
+        # TODO: There's gotta be a better way of comparing here...
+        if not equalMem(addr(buf[bpos]),
+                        cast[pointer](cast[int](cstring(s)) + spos), n):
+          return false
+        spos += n
+        bpos += n
+
+    result = readBuffer(f, addr(buf[0]), 1) == 0 # check that we've read all
+
+  proc equalsFile*(r: Rope, filename: string): bool {.rtl, extern: "nro$1Str".} =
+    ## Returns true if the contents of the file `f` equal `r`. If `f` does not
+    ## exist, false is returned.
+    var f: File
+    result = open(f, filename)
+    if result:
+      result = equalsFile(r, f)
+      close(f)
 
 new(N) # init dummy node for splay algorithm
 
diff --git a/lib/pure/segfaults.nim b/lib/pure/segfaults.nim
new file mode 100644
index 000000000..65b059e86
--- /dev/null
+++ b/lib/pure/segfaults.nim
@@ -0,0 +1,88 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This modules registers a signal handler that turns access violations /
+## segfaults into a ``NilAccessDefect`` exception. To be able to catch
+## a NilAccessDefect all you have to do is to import this module.
+##
+## Tested on these OSes: Linux, Windows, OSX
+
+# xxx possibly broken on arm64, see bug #17178
+
+{.used.}
+
+# do allocate memory upfront:
+var se: ref NilAccessDefect
+new(se)
+se.name = "NilAccessDefect"
+se.msg = "Could not access value because it is nil."
+
+when defined(windows):
+  include "../system/ansi_c"
+
+  import std/winlean
+
+  const
+    EXCEPTION_ACCESS_VIOLATION = DWORD(0xc0000005'i32)
+    EXCEPTION_CONTINUE_SEARCH = LONG(0)
+
+  type
+    PEXCEPTION_RECORD = ptr object
+      exceptionCode: DWORD # other fields left out
+
+    PEXCEPTION_POINTERS = ptr object
+      exceptionRecord: PEXCEPTION_RECORD
+      contextRecord: pointer
+
+    VectoredHandler = proc (p: PEXCEPTION_POINTERS): LONG {.stdcall.}
+  proc addVectoredExceptionHandler(firstHandler: ULONG,
+                                   handler: VectoredHandler): pointer {.
+    importc: "AddVectoredExceptionHandler", stdcall, dynlib: "kernel32.dll".}
+
+  {.push stackTrace: off.}
+  proc segfaultHandler(p: PEXCEPTION_POINTERS): LONG {.stdcall.} =
+    if p.exceptionRecord.exceptionCode == EXCEPTION_ACCESS_VIOLATION:
+      {.gcsafe.}:
+        raise se
+    else:
+      result = EXCEPTION_CONTINUE_SEARCH
+  {.pop.}
+
+  discard addVectoredExceptionHandler(0, segfaultHandler)
+
+  when false:
+    {.push stackTrace: off.}
+    proc segfaultHandler(sig: cint) {.noconv.} =
+      {.gcsafe.}:
+        rawRaise se
+    {.pop.}
+    c_signal(SIGSEGV, segfaultHandler)
+
+else:
+  import std/posix
+
+  var sa: Sigaction
+
+  var SEGV_MAPERR {.importc, header: "<signal.h>".}: cint
+
+  {.push stackTrace: off.}
+  proc segfaultHandler(sig: cint, y: ptr SigInfo, z: pointer) {.noconv.} =
+    if y.si_code == SEGV_MAPERR:
+      {.gcsafe.}:
+        raise se
+    else:
+      quit(1)
+  {.pop.}
+
+  discard sigemptyset(sa.sa_mask)
+
+  sa.sa_sigaction = segfaultHandler
+  sa.sa_flags = SA_SIGINFO or SA_NODEFER
+
+  discard sigaction(SIGSEGV, sa)
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim
new file mode 100644
index 000000000..ac180e2bd
--- /dev/null
+++ b/lib/pure/selectors.nim
@@ -0,0 +1,375 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Eugene Kabanov
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module allows high-level and efficient I/O multiplexing.
+##
+## Supported OS primitives: `epoll`, `kqueue`, `poll` and
+## Windows `select`.
+##
+## To use threadsafe version of this module, it needs to be compiled
+## with both `-d:threadsafe` and `--threads:on` options.
+##
+## Supported features: files, sockets, pipes, timers, processes, signals
+## and user events.
+##
+## Fully supported OS: MacOSX, FreeBSD, OpenBSD, NetBSD, Linux (except
+## for Android).
+##
+## Partially supported OS: Windows (only sockets and user events),
+## Solaris (files, sockets, handles and user events).
+## Android (files, sockets, handles and user events).
+##
+## TODO: `/dev/poll`, `event ports` and filesystem events.
+
+import std/nativesockets
+import std/oserrors
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+const hasThreadSupport = compileOption("threads") and defined(threadsafe)
+
+const ioselSupportedPlatform* = defined(macosx) or defined(freebsd) or
+                                defined(netbsd) or defined(openbsd) or
+                                defined(dragonfly) or defined(nuttx) or
+                                (defined(linux) and not defined(android) and not defined(emscripten))
+  ## This constant is used to determine whether the destination platform is
+  ## fully supported by `ioselectors` module.
+
+const bsdPlatform = defined(macosx) or defined(freebsd) or
+                    defined(netbsd) or defined(openbsd) or
+                    defined(dragonfly)
+
+when defined(nimdoc):
+  type
+    Selector*[T] = ref object
+      ## An object which holds descriptors to be checked for read/write status
+
+    IOSelectorsException* = object of CatchableError
+      ## Exception that is raised if an IOSelectors error occurs.
+
+    Event* {.pure.} = enum
+      ## An enum which hold event types
+      Read,        ## Descriptor is available for read
+      Write,       ## Descriptor is available for write
+      Timer,       ## Timer descriptor is completed
+      Signal,      ## Signal is raised
+      Process,     ## Process is finished
+      Vnode,       ## BSD specific file change
+      User,        ## User event is raised
+      Error,       ## Error occurred while waiting for descriptor
+      VnodeWrite,  ## NOTE_WRITE (BSD specific, write to file occurred)
+      VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occurred)
+      VnodeExtend, ## NOTE_EXTEND (BSD specific, file extended)
+      VnodeAttrib, ## NOTE_ATTRIB (BSD specific, file attributes changed)
+      VnodeLink,   ## NOTE_LINK (BSD specific, file link count changed)
+      VnodeRename, ## NOTE_RENAME (BSD specific, file renamed)
+      VnodeRevoke  ## NOTE_REVOKE (BSD specific, file revoke occurred)
+
+    ReadyKey* = object
+      ## An object which holds result for descriptor
+      fd* : int ## file/socket descriptor
+      events*: set[Event] ## set of events
+      errorCode*: OSErrorCode ## additional error code information for
+                              ## Error events
+
+    SelectEvent* = object
+      ## An object which holds user defined event
+
+  proc newSelector*[T](): Selector[T] =
+    ## Creates a new selector
+
+  proc close*[T](s: Selector[T]) =
+    ## Closes the selector.
+
+  proc registerHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                          events: set[Event], data: T) =
+    ## Registers file/socket descriptor `fd` to selector `s`
+    ## with events set in `events`. The `data` is application-defined
+    ## data, which will be passed when an event is triggered.
+
+  proc updateHandle*[T](s: Selector[T], fd: int | SocketHandle,
+                        events: set[Event]) =
+    ## Update file/socket descriptor `fd`, registered in selector
+    ## `s` with new events set `event`.
+
+  proc registerTimer*[T](s: Selector[T], timeout: int, oneshot: bool,
+                         data: T): int {.discardable.} =
+    ## Registers timer notification with `timeout` (in milliseconds)
+    ## to selector `s`.
+    ##
+    ## If `oneshot` is `true`, timer will be notified only once.
+    ##
+    ## Set `oneshot` to `false` if you want periodic notifications.
+    ##
+    ## The `data` is application-defined data, which will be passed, when
+    ## the timer is triggered.
+    ##
+    ## Returns the file descriptor for the registered timer.
+
+  proc registerSignal*[T](s: Selector[T], signal: int,
+                          data: T): int {.discardable.} =
+    ## Registers Unix signal notification with `signal` to selector
+    ## `s`.
+    ##
+    ## The `data` is application-defined data, which will be
+    ## passed when signal raises.
+    ##
+    ## Returns the file descriptor for the registered signal.
+    ##
+    ## **Note:** This function is not supported on `Windows`.
+
+  proc registerProcess*[T](s: Selector[T], pid: int,
+                           data: T): int {.discardable.} =
+    ## Registers a process id (pid) notification (when process has
+    ## exited) in selector `s`.
+    ##
+    ## The `data` is application-defined data, which will be passed when
+    ## process with `pid` has exited.
+    ##
+    ## Returns the file descriptor for the registered signal.
+
+  proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) =
+    ## Registers selector event `ev` in selector `s`.
+    ##
+    ## The `data` is application-defined data, which will be passed when
+    ## `ev` happens.
+
+  proc registerVnode*[T](s: Selector[T], fd: cint, events: set[Event],
+                         data: T) =
+    ## Registers selector BSD/MacOSX specific vnode events for file
+    ## descriptor `fd` and events `events`.
+    ## `data` application-defined data, which to be passed, when
+    ## vnode event happens.
+    ##
+    ## **Note:** This function is supported only by BSD and MacOSX.
+
+  proc newSelectEvent*(): SelectEvent =
+    ## Creates a new user-defined event.
+
+  proc trigger*(ev: SelectEvent) =
+    ## Trigger event `ev`.
+
+  proc close*(ev: SelectEvent) =
+    ## Closes user-defined event `ev`.
+
+  proc unregister*[T](s: Selector[T], ev: SelectEvent) =
+    ## Unregisters user-defined event `ev` from selector `s`.
+
+  proc unregister*[T](s: Selector[T], fd: int|SocketHandle|cint) =
+    ## Unregisters file/socket descriptor `fd` from selector `s`.
+
+  proc selectInto*[T](s: Selector[T], timeout: int,
+                      results: var openArray[ReadyKey]): int =
+    ## Waits for events registered in selector `s`.
+    ##
+    ## The `timeout` argument specifies the maximum number of milliseconds
+    ## the function will be blocked for if no events are ready. Specifying a
+    ## timeout of `-1` causes the function to block indefinitely.
+    ## All available events will be stored in `results` array.
+    ##
+    ## Returns number of triggered events.
+
+  proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey] =
+    ## Waits for events registered in selector `s`.
+    ##
+    ## The `timeout` argument specifies the maximum number of milliseconds
+    ## the function will be blocked for if no events are ready. Specifying a
+    ## timeout of `-1` causes the function to block indefinitely.
+    ##
+    ## Returns a list of triggered events.
+
+  proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T =
+    ## Retrieves application-defined `data` associated with descriptor `fd`.
+    ## If specified descriptor `fd` is not registered, empty/default value
+    ## will be returned.
+
+  proc setData*[T](s: Selector[T], fd: SocketHandle|int, data: var T): bool =
+    ## Associate application-defined `data` with descriptor `fd`.
+    ##
+    ## Returns `true`, if data was successfully updated, `false` otherwise.
+
+  template isEmpty*[T](s: Selector[T]): bool = # TODO: Why is this a template?
+    ## Returns `true`, if there are no registered events or descriptors
+    ## in selector.
+
+  template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                        body: untyped) =
+    ## Retrieves the application-data assigned with descriptor `fd`
+    ## to `value`. This `value` can be modified in the scope of
+    ## the `withData` call.
+    ##
+    ##   ```nim
+    ##   s.withData(fd, value) do:
+    ##     # block is executed only if `fd` registered in selector `s`
+    ##     value.uid = 1000
+    ##   ```
+
+  template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
+                        body1, body2: untyped) =
+    ## Retrieves the application-data assigned with descriptor `fd`
+    ## to `value`. This `value` can be modified in the scope of
+    ## the `withData` call.
+    ##
+    ##   ```nim
+    ##   s.withData(fd, value) do:
+    ##     # block is executed only if `fd` registered in selector `s`.
+    ##     value.uid = 1000
+    ##   do:
+    ##     # block is executed if `fd` not registered in selector `s`.
+    ##     raise
+    ##   ```
+
+  proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} =
+    ## Determines whether selector contains a file descriptor.
+
+  proc getFd*[T](s: Selector[T]): int =
+    ## Retrieves the underlying selector's file descriptor.
+    ##
+    ## For *poll* and *select* selectors `-1` is returned.
+
+else:
+  import std/strutils
+  when hasThreadSupport:
+    import std/locks
+
+    type
+      SharedArray[T] = UncheckedArray[T]
+
+    proc allocSharedArray[T](nsize: int): ptr SharedArray[T] =
+      result = cast[ptr SharedArray[T]](allocShared0(sizeof(T) * nsize))
+
+    proc reallocSharedArray[T](sa: ptr SharedArray[T], oldsize, nsize: int): ptr SharedArray[T] =
+      result = cast[ptr SharedArray[T]](reallocShared0(sa, oldsize * sizeof(T), sizeof(T) * nsize))
+
+    proc deallocSharedArray[T](sa: ptr SharedArray[T]) =
+      deallocShared(cast[pointer](sa))
+  type
+    Event* {.pure.} = enum
+      Read, Write, Timer, Signal, Process, Vnode, User, Error, Oneshot,
+      Finished, VnodeWrite, VnodeDelete, VnodeExtend, VnodeAttrib, VnodeLink,
+      VnodeRename, VnodeRevoke
+
+  type
+    IOSelectorsException* = object of CatchableError
+
+    ReadyKey* = object
+      fd*: int
+      events*: set[Event]
+      errorCode*: OSErrorCode
+
+    SelectorKey[T] = object
+      ident: int
+      events: set[Event]
+      param: int
+      data: T
+
+  const
+    InvalidIdent = -1
+
+  proc raiseIOSelectorsError[T](message: T) =
+    var msg = ""
+    when T is string:
+      msg.add(message)
+    elif T is OSErrorCode:
+      msg.add(osErrorMsg(message) & " (code: " & $int(message) & ")")
+    else:
+      msg.add("Internal Error\n")
+    var err = newException(IOSelectorsException, msg)
+    raise err
+
+  proc setNonBlocking(fd: cint) {.inline.} =
+    setBlocking(fd.SocketHandle, false)
+
+  when not defined(windows):
+    import std/posix
+
+    template setKey(s, pident, pevents, pparam, pdata: untyped) =
+      var skey = addr(s.fds[pident])
+      skey.ident = pident
+      skey.events = pevents
+      skey.param = pparam
+      skey.data = pdata
+
+  when ioselSupportedPlatform:
+    template blockSignals(newmask: var Sigset, oldmask: var Sigset) =
+      when hasThreadSupport:
+        if posix.pthread_sigmask(SIG_BLOCK, newmask, oldmask) == -1:
+          raiseIOSelectorsError(osLastError())
+      else:
+        if posix.sigprocmask(SIG_BLOCK, newmask, oldmask) == -1:
+          raiseIOSelectorsError(osLastError())
+
+    template unblockSignals(newmask: var Sigset, oldmask: var Sigset) =
+      when hasThreadSupport:
+        if posix.pthread_sigmask(SIG_UNBLOCK, newmask, oldmask) == -1:
+          raiseIOSelectorsError(osLastError())
+      else:
+        if posix.sigprocmask(SIG_UNBLOCK, newmask, oldmask) == -1:
+          raiseIOSelectorsError(osLastError())
+
+  template clearKey[T](key: ptr SelectorKey[T]) =
+    var empty: T
+    key.ident = InvalidIdent
+    key.events = {}
+    key.data = empty
+
+  proc verifySelectParams(timeout: int) =
+    # Timeout of -1 means: wait forever
+    # Anything higher is the time to wait in milliseconds.
+    doAssert(timeout >= -1, "Cannot select with a negative value, got: " & $timeout)
+
+  when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
+       defined(solaris) or defined(zephyr) or defined(freertos) or defined(nuttx) or defined(haiku):
+    template maxDescriptors*(): int =
+      ## Returns the maximum number of active file descriptors for the current
+      ## process. This involves a system call. For now `maxDescriptors` is
+      ## supported on the following OSes: Windows, Linux, OSX, BSD, Solaris.
+      when defined(windows):
+        16_700_000
+      elif defined(zephyr) or defined(freertos):
+        FD_MAX
+      else:
+        var fdLim: RLimit
+        var res = int(getrlimit(RLIMIT_NOFILE, fdLim))
+        if res >= 0:
+          res = int(fdLim.rlim_cur) - 1
+        res
+
+  when defined(nimIoselector):
+    when nimIoselector == "epoll":
+      include ioselects/ioselectors_epoll
+    elif nimIoselector == "kqueue":
+      include ioselects/ioselectors_kqueue
+    elif nimIoselector == "poll":
+      include ioselects/ioselectors_poll
+    elif nimIoselector == "select":
+      include ioselects/ioselectors_select
+    else:
+      {.fatal: "Unknown nimIoselector specified by define.".}
+  elif defined(linux) and not defined(emscripten):
+    include ioselects/ioselectors_epoll
+  elif bsdPlatform:
+    include ioselects/ioselectors_kqueue
+  elif defined(windows):
+    include ioselects/ioselectors_select
+  elif defined(solaris):
+    include ioselects/ioselectors_poll # need to replace it with event ports
+  elif defined(genode):
+    include ioselects/ioselectors_select # TODO: use the native VFS layer
+  elif defined(nintendoswitch):
+    include ioselects/ioselectors_select
+  elif defined(freertos) or defined(lwip):
+    include ioselects/ioselectors_select
+  elif defined(zephyr):
+    include ioselects/ioselectors_poll
+  elif defined(nuttx):
+    include ioselects/ioselectors_epoll
+  else:
+    include ioselects/ioselectors_poll
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
deleted file mode 100755
index 85628db78..000000000
--- a/lib/pure/sockets.nim
+++ /dev/null
@@ -1,416 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements a simple portable type-safe sockets layer.
-
-import os
-
-when defined(Windows):
-  import winlean
-else:
-  import posix
-
-# Note: The enumerations are mapped to Window's constants.
-
-type
-  TSocket* = distinct cint ## socket type
-  TPort* = distinct int16  ## port type
-  
-  TDomain* = enum   ## domain, which specifies the protocol family of the
-                    ## created socket. Other domains than those that are listed
-                    ## here are unsupported.
-    AF_UNIX,        ## for local socket (using a file). Unsupported on Windows.
-    AF_INET = 2,    ## for network protocol IPv4 or
-    AF_INET6 = 23   ## for network protocol IPv6.
-
-  TType* = enum        ## second argument to `socket` proc
-    SOCK_STREAM = 1,   ## reliable stream-oriented service or Stream Sockets
-    SOCK_DGRAM = 2,    ## datagram service or Datagram Sockets
-    SOCK_RAW = 3,      ## raw protocols atop the network layer.
-    SOCK_SEQPACKET = 5 ## reliable sequenced packet service, or
-
-  TProtocol* = enum     ## third argument to `socket` proc
-    IPPROTO_TCP = 6,    ## Transmission control protocol. 
-    IPPROTO_UDP = 17,   ## User datagram protocol.
-    IPPROTO_IP,         ## Internet protocol. Unsupported on Windows.
-    IPPROTO_IPV6,       ## Internet Protocol Version 6. Unsupported on Windows.
-    IPPROTO_RAW,        ## Raw IP Packets Protocol. Unsupported on Windows.
-    IPPROTO_ICMP        ## Control message protocol. Unsupported on Windows.
-
-  TServent* {.pure, final.} = object ## information about a service
-    name*: string
-    aliases*: seq[string]
-    port*: TPort
-    proto*: string
-
-  Thostent* {.pure, final.} = object ## information about a given host
-    name*: string
-    aliases*: seq[string]
-    addrtype*: TDomain
-    length*: int
-    addrList*: seq[string]
-
-const
-  InvalidSocket* = TSocket(-1'i32) ## invalid socket number
-
-proc `==`*(a, b: TSocket): bool {.borrow.}
-  ## ``==`` for sockets. 
-
-proc `==`*(a, b: TPort): bool {.borrow.}
-  ## ``==`` for ports.
-
-proc `$`*(p: TPort): string = 
-  ## returns the port number as a string
-  result = $ze(int16(p))
-
-proc ntohl*(x: int32): int32 = 
-  ## Converts 32-bit integers from network to host byte order.
-  ## On machines where the host byte order is the same as network byte order,
-  ## this is a no-op; otherwise, it performs a 4-byte swap operation.
-  when cpuEndian == bigEndian: result = x
-  else: result = (x shr 24'i32) or
-                 (x shr 8'i32 and 0xff00'i32) or
-                 (x shl 8'i32 and 0xff0000'i32) or
-                 (x shl 24'i32)
-
-proc ntohs*(x: int16): int16 =
-  ## Converts 16-bit integers from network to host byte order. On machines
-  ## where the host byte order is the same as network byte order, this is
-  ## a no-op; otherwise, it performs a 2-byte swap operation.
-  when cpuEndian == bigEndian: result = x
-  else: result = (x shr 8'i16) or (x shl 8'i16)
-
-proc htonl*(x: int32): int32 =
-  ## Converts 32-bit integers from host to network byte order. On machines
-  ## where the host byte order is the same as network byte order, this is
-  ## a no-op; otherwise, it performs a 4-byte swap operation.
-  result = sockets.ntohl(x)
-
-proc htons*(x: int16): int16 =
-  ## Converts 16-bit positive integers from host to network byte order.
-  ## On machines where the host byte order is the same as network byte
-  ## order, this is a no-op; otherwise, it performs a 2-byte swap operation.
-  result = sockets.ntohs(x)
-  
-when defined(Posix):
-  proc ToInt(domain: TDomain): cint =
-    case domain
-    of AF_UNIX:        result = posix.AF_UNIX
-    of AF_INET:        result = posix.AF_INET
-    of AF_INET6:       result = posix.AF_INET6
-    else: nil
-
-  proc ToInt(typ: TType): cint =
-    case typ
-    of SOCK_STREAM:    result = posix.SOCK_STREAM
-    of SOCK_DGRAM:     result = posix.SOCK_DGRAM
-    of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
-    of SOCK_RAW:       result = posix.SOCK_RAW
-    else: nil
-
-  proc ToInt(p: TProtocol): cint =
-    case p
-    of IPPROTO_TCP:    result = posix.IPPROTO_TCP
-    of IPPROTO_UDP:    result = posix.IPPROTO_UDP
-    of IPPROTO_IP:     result = posix.IPPROTO_IP
-    of IPPROTO_IPV6:   result = posix.IPPROTO_IPV6
-    of IPPROTO_RAW:    result = posix.IPPROTO_RAW
-    of IPPROTO_ICMP:   result = posix.IPPROTO_ICMP
-    else: nil
-
-else:
-  proc toInt(domain: TDomain): cint = 
-    result = toU16(ord(domain))
-
-  proc ToInt(typ: TType): cint =
-    result = cint(ord(typ))
-  
-  proc ToInt(p: TProtocol): cint =
-    result = cint(ord(p))
-
-proc socket*(domain: TDomain = AF_INET, typ: TType = SOCK_STREAM,
-             protocol: TProtocol = IPPROTO_TCP): TSocket =
-  ## creates a new socket; returns `InvalidSocket` if an error occurs.  
-  when defined(Windows):
-    result = TSocket(winlean.socket(ord(domain), ord(typ), ord(protocol)))
-  else:
-    result = TSocket(posix.socket(ToInt(domain), ToInt(typ), ToInt(protocol)))
-
-proc listen*(socket: TSocket, attempts = 5) =
-  ## listens to socket.
-  if listen(cint(socket), cint(attempts)) < 0'i32: OSError()
-
-proc bindAddr*(socket: TSocket, port = TPort(0)) =
-  ## binds a port number to a socket.
-  var name: Tsockaddr_in
-  when defined(Windows):
-    name.sin_family = int16(ord(AF_INET))
-  else:
-    name.sin_family = posix.AF_INET
-  name.sin_port = sockets.htons(int16(port))
-  name.sin_addr.s_addr = sockets.htonl(INADDR_ANY)
-  if bindSocket(cint(socket), cast[ptr TSockAddr](addr(name)),
-                sizeof(name)) < 0'i32:
-    OSError()
-  
-proc getSockName*(socket: TSocket): TPort = 
-  ## returns the socket's associated port number.
-  var name: Tsockaddr_in
-  when defined(Windows):
-    name.sin_family = int16(ord(AF_INET))
-  else:
-    name.sin_family = posix.AF_INET
-  #name.sin_port = htons(cint16(port))
-  #name.sin_addr.s_addr = htonl(INADDR_ANY)
-  var namelen: cint = sizeof(name)
-  if getsockname(cint(socket), cast[ptr TSockAddr](addr(name)),
-                 addr(namelen)) == -1'i32:
-    OSError()
-  result = TPort(sockets.ntohs(name.sin_port))
-
-proc accept*(server: TSocket): TSocket =
-  ## waits for a client and returns its socket
-  var client: Tsockaddr_in
-  var clientLen: cint = sizeof(client)
-  result = TSocket(accept(cint(server), cast[ptr TSockAddr](addr(client)),
-                          addr(clientLen)))
-
-proc close*(socket: TSocket) =
-  ## closes a socket.
-  when defined(windows):
-    discard winlean.closeSocket(cint(socket))
-  else:
-    discard posix.close(cint(socket))
-
-proc getServByName*(name, proto: string): TServent =
-  ## well-known getservbyname proc.
-  when defined(Windows):
-    var s = winlean.getservbyname(name, proto)
-  else:
-    var s = posix.getservbyname(name, proto)
-  if s == nil: OSError()
-  result.name = $s.s_name
-  result.aliases = cstringArrayToSeq(s.s_aliases)
-  result.port = TPort(s.s_port)
-  result.proto = $s.s_proto
-  
-proc getServByPort*(port: TPort, proto: string): TServent = 
-  ## well-known getservbyport proc.
-  when defined(Windows):
-    var s = winlean.getservbyport(ze(int16(port)), proto)
-  else:
-    var s = posix.getservbyport(ze(int16(port)), proto)
-  if s == nil: OSError()
-  result.name = $s.s_name
-  result.aliases = cstringArrayToSeq(s.s_aliases)
-  result.port = TPort(s.s_port)
-  result.proto = $s.s_proto
-
-proc getHostByName*(name: string): THostEnt = 
-  ## well-known gethostbyname proc.
-  when defined(Windows):
-    var s = winlean.gethostbyname(name)
-  else:
-    var s = posix.gethostbyname(name)
-  if s == nil: OSError()
-  result.name = $s.h_name
-  result.aliases = cstringArrayToSeq(s.h_aliases)
-  when defined(windows): 
-    result.addrType = TDomain(s.h_addrtype)
-  else:
-    if s.h_addrtype == posix.AF_INET:
-      result.addrType = AF_INET
-    elif s.h_addrtype == posix.AF_INET6:
-      result.addrType = AF_INET6
-    else:
-      OSError("unknown h_addrtype")
-  result.addrList = cstringArrayToSeq(s.h_addr_list)
-  result.length = int(s.h_length)
-
-proc getSockOptInt*(socket: TSocket, level, optname: int): int = 
-  ## getsockopt for integer options.
-  var res: cint
-  var size: cint = sizeof(res)
-  if getsockopt(cint(socket), cint(level), cint(optname), 
-                addr(res), addr(size)) < 0'i32:
-    OSError()
-  result = int(res)
-
-proc setSockOptInt*(socket: TSocket, level, optname, optval: int) =
-  ## setsockopt for integer options.
-  var value = cint(optval)
-  if setsockopt(cint(socket), cint(level), cint(optname), addr(value),  
-                sizeof(value)) < 0'i32:
-    OSError()
-
-proc connect*(socket: TSocket, name: string, port = TPort(0), 
-              af: TDomain = AF_INET) =
-  ## well-known connect operation. Already does ``htons`` on the port number,
-  ## so you shouldn't do it. `name` can be an IP address or a host name of the
-  ## form "force7.de". 
-  var hints: TAddrInfo
-  var aiList: ptr TAddrInfo = nil
-  hints.ai_family = toInt(af)
-  hints.ai_socktype = toInt(SOCK_STREAM)
-  hints.ai_protocol = toInt(IPPROTO_TCP)
-  if getAddrInfo(name, $port, addr(hints), aiList) != 0'i32: OSError()
-  # try all possibilities:
-  var success = false
-  var it = aiList
-  while it != nil:
-    if connect(cint(socket), it.ai_addr, it.ai_addrlen) == 0'i32:
-      success = true
-      break
-    it = it.ai_next
-  freeaddrinfo(aiList)
-  if not success: OSError()
-  
-  when false:
-    var s: TSockAddrIn
-    s.sin_addr.s_addr = inet_addr(name)
-    s.sin_port = sockets.htons(int16(port))
-    when defined(windows):
-      s.sin_family = toU16(ord(af))
-    else:
-      case af 
-      of AF_UNIX: s.sin_family = posix.AF_UNIX
-      of AF_INET: s.sin_family = posix.AF_INET
-      of AF_INET6: s.sin_family = posix.AF_INET6
-      else: nil
-    if connect(cint(socket), cast[ptr TSockAddr](addr(s)), sizeof(s)) < 0'i32:
-      OSError()
-
-#proc recvfrom*(s: TWinSocket, buf: cstring, len, flags: cint, 
-#               fromm: ptr TSockAddr, fromlen: ptr cint): cint 
-
-#proc sendto*(s: TWinSocket, buf: cstring, len, flags: cint,
-#             to: ptr TSockAddr, tolen: cint): cint
-
-proc createFdSet(fd: var TFdSet, s: seq[TSocket], m: var int) = 
-  FD_ZERO(fd)
-  for i in items(s): 
-    m = max(m, int(i))
-    FD_SET(cint(i), fd)
-   
-proc pruneSocketSet(s: var seq[TSocket], fd: var TFdSet) = 
-  var i = 0
-  var L = s.len
-  while i < L:
-    if FD_ISSET(cint(s[i]), fd) != 0'i32:
-      s[i] = s[L-1]
-      dec(L)
-    else:
-      inc(i)
-  setLen(s, L)
-
-proc select*(readfds, writefds, exceptfds: var seq[TSocket], 
-             timeout = 500): int = 
-  ## select with a sensible Nimrod interface. `timeout` is in miliseconds.
-  var tv: TTimeVal
-  tv.tv_sec = 0
-  tv.tv_usec = timeout * 1000
-  
-  var rd, wr, ex: TFdSet
-  var m = 0
-  createFdSet((rd), readfds, m)
-  createFdSet((wr), writefds, m)
-  createFdSet((ex), exceptfds, m)
-  
-  result = int(select(cint(m), addr(rd), addr(wr), addr(ex), addr(tv)))
-  
-  pruneSocketSet(readfds, (rd))
-  pruneSocketSet(writefds, (wr))
-  pruneSocketSet(exceptfds, (ex))
-
-proc select*(readfds, writefds: var seq[TSocket], 
-             timeout = 500): int = 
-  ## select with a sensible Nimrod interface. `timeout` is in miliseconds.
-  var tv: TTimeVal
-  tv.tv_sec = 0
-  tv.tv_usec = timeout * 1000
-  
-  var rd, wr: TFdSet
-  var m = 0
-  createFdSet((rd), readfds, m)
-  createFdSet((wr), writefds, m)
-  
-  result = int(select(cint(m), addr(rd), addr(wr), nil, addr(tv)))
-  
-  pruneSocketSet(readfds, (rd))
-  pruneSocketSet(writefds, (wr))
-
-
-proc select*(readfds: var seq[TSocket], timeout = 500): int = 
-  ## select with a sensible Nimrod interface. `timeout` is in miliseconds.
-  var tv: TTimeVal
-  tv.tv_sec = 0
-  tv.tv_usec = timeout * 1000
-  
-  var rd: TFdSet
-  var m = 0
-  createFdSet((rd), readfds, m)
-  
-  result = int(select(cint(m), addr(rd), nil, nil, addr(tv)))
-  
-  pruneSocketSet(readfds, (rd))
-
-
-proc recvLine*(socket: TSocket, line: var string): bool =
-  ## returns false if no further data is available. `line` must be initalized
-  ## and not nil!
-  setLen(line, 0)
-  while true:
-    var c: char
-    var n = recv(cint(socket), addr(c), 1, 0'i32)
-    if n <= 0: return
-    if c == '\r':
-      n = recv(cint(socket), addr(c), 1, MSG_PEEK)
-      if n > 0 and c == '\L':
-        discard recv(cint(socket), addr(c), 1, 0'i32)
-      elif n <= 0: return false
-      return true
-    elif c == '\L': return true
-    add(line, c)
-
-proc recv*(socket: TSocket, data: pointer, size: int): int =
-  ## receives data from a socket
-  result = recv(cint(socket), data, size, 0'i32)
-
-proc recv*(socket: TSocket): string =
-  ## receives all the data from the socket
-  const bufSize = 200
-  var buf = newString(bufSize)
-  result = ""
-  while true:
-    var bytesRead = recv(socket, cstring(buf), bufSize-1)
-    buf[bytesRead] = '\0' # might not be necessary
-    setLen(buf, bytesRead)
-    add(result, buf)
-    if bytesRead != bufSize-1: break
-  
-proc skip*(socket: TSocket) =
-  ## skips all the data that is pending for the socket
-  const bufSize = 200
-  var buf = alloc(bufSize)
-  while recv(socket, buf, bufSize) == bufSize: nil
-  dealloc(buf)
-
-proc send*(socket: TSocket, data: pointer, size: int): int =
-  ## sends data to a socket.
-  result = send(cint(socket), data, size, 0'i32)
-
-proc send*(socket: TSocket, data: string) =
-  ## sends data to a socket.
-  if send(socket, cstring(data), data.len) != data.len: OSError()
-
-when defined(Windows):
-  var wsa: TWSADATA
-  if WSAStartup(0x0101'i16, wsa) != 0: OSError()
-
-
diff --git a/lib/pure/ssl_certs.nim b/lib/pure/ssl_certs.nim
new file mode 100644
index 000000000..d60cd22eb
--- /dev/null
+++ b/lib/pure/ssl_certs.nim
@@ -0,0 +1,172 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+## Scan for SSL/TLS CA certificates on disk
+## The default locations can be overridden using the SSL_CERT_FILE and
+## SSL_CERT_DIR environment variables.
+
+import std/[os, strutils]
+
+# FWIW look for files before scanning entire dirs.
+
+when defined(macosx):
+  const certificatePaths = [
+    "/etc/ssl/cert.pem",
+    "/System/Library/OpenSSL/certs/cert.pem"
+  ]
+elif defined(linux):
+  const certificatePaths = [
+    # Debian, Ubuntu, Arch: maintained by update-ca-certificates, SUSE, Gentoo
+    # NetBSD (security/mozilla-rootcerts)
+    # SLES10/SLES11, https://golang.org/issue/12139
+    "/etc/ssl/certs/ca-certificates.crt",
+    # OpenSUSE
+    "/etc/ssl/ca-bundle.pem",
+    # Red Hat 5+, Fedora, Centos
+    "/etc/pki/tls/certs/ca-bundle.crt",
+    # Red Hat 4
+    "/usr/share/ssl/certs/ca-bundle.crt",
+    # Fedora/RHEL
+    "/etc/pki/tls/certs",
+    # Android
+    "/data/data/com.termux/files/usr/etc/tls/cert.pem",
+    "/system/etc/security/cacerts",
+  ]
+elif defined(bsd):
+  const certificatePaths = [
+    # Debian, Ubuntu, Arch: maintained by update-ca-certificates, SUSE, Gentoo
+    # NetBSD (security/mozilla-rootcerts)
+    # SLES10/SLES11, https://golang.org/issue/12139
+    "/etc/ssl/certs/ca-certificates.crt",
+    # FreeBSD (security/ca-root-nss package)
+    "/usr/local/share/certs/ca-root-nss.crt",
+    # OpenBSD, FreeBSD (optional symlink)
+    "/etc/ssl/cert.pem",
+    # FreeBSD
+    "/usr/local/share/certs",
+    # NetBSD
+    "/etc/openssl/certs",
+  ]
+else:
+  const certificatePaths = [
+    # Debian, Ubuntu, Arch: maintained by update-ca-certificates, SUSE, Gentoo
+    # NetBSD (security/mozilla-rootcerts)
+    # SLES10/SLES11, https://golang.org/issue/12139
+    "/etc/ssl/certs/ca-certificates.crt",
+    # OpenSUSE
+    "/etc/ssl/ca-bundle.pem",
+    # Red Hat 5+, Fedora, Centos
+    "/etc/pki/tls/certs/ca-bundle.crt",
+    # Red Hat 4
+    "/usr/share/ssl/certs/ca-bundle.crt",
+    # FreeBSD (security/ca-root-nss package)
+    "/usr/local/share/certs/ca-root-nss.crt",
+    # CentOS/RHEL 7
+    "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem",
+    # OpenBSD, FreeBSD (optional symlink)
+    "/etc/ssl/cert.pem",
+    # Fedora/RHEL
+    "/etc/pki/tls/certs",
+    # Android
+    "/system/etc/security/cacerts",
+    # FreeBSD
+    "/usr/local/share/certs",
+    # NetBSD
+    "/etc/openssl/certs",
+  ]
+
+when defined(haiku):
+  const
+    B_FIND_PATH_EXISTING_ONLY = 0x4
+    B_FIND_PATH_DATA_DIRECTORY = 6
+
+  proc find_paths_etc(architecture: cstring, baseDirectory: cint,
+                      subPath: cstring, flags: uint32,
+                      paths: var ptr UncheckedArray[cstring],
+                      pathCount: var csize_t): int32
+                     {.importc, header: "<FindDirectory.h>".}
+  proc free(p: pointer) {.importc, header: "<stdlib.h>".}
+
+iterator scanSSLCertificates*(useEnvVars = false): string =
+  ## Scan for SSL/TLS CA certificates on disk.
+  ##
+  ## if `useEnvVars` is true, the SSL_CERT_FILE and SSL_CERT_DIR
+  ## environment variables can be used to override the certificate
+  ## directories to scan or specify a CA certificate file.
+  if useEnvVars and existsEnv("SSL_CERT_FILE"):
+    yield getEnv("SSL_CERT_FILE")
+
+  elif useEnvVars and existsEnv("SSL_CERT_DIR"):
+    let p = getEnv("SSL_CERT_DIR")
+    for fn in joinPath(p, "*").walkFiles():
+      yield fn
+
+  else:
+    when defined(windows):
+      const cacert = "cacert.pem"
+      let pem = getAppDir() / cacert
+      if fileExists(pem):
+        yield pem
+      else:
+        let path = getEnv("PATH")
+        for candidate in split(path, PathSep):
+          if candidate.len != 0:
+            let x = (if candidate[0] == '"' and candidate[^1] == '"':
+                      substr(candidate, 1, candidate.len-2) else: candidate) / cacert
+            if fileExists(x):
+              yield x
+    elif not defined(haiku):
+      for p in certificatePaths:
+        if p.endsWith(".pem") or p.endsWith(".crt"):
+          if fileExists(p):
+            yield p
+        elif dirExists(p):
+          # check if it's a dir where each cert is one file
+          # named by it's hasg
+          for fn in joinPath(p, "*.0").walkFiles:
+            yield p.normalizePathEnd(true)
+            break
+          for fn in joinPath(p, "*").walkFiles():
+
+            yield fn
+    else:
+      var
+        paths: ptr UncheckedArray[cstring]
+        size: csize_t
+      let err = find_paths_etc(
+        nil, B_FIND_PATH_DATA_DIRECTORY, "ssl/CARootCertificates.pem",
+        B_FIND_PATH_EXISTING_ONLY, paths, size
+      )
+      if err == 0:
+        defer: free(paths)
+        for i in 0 ..< size:
+          yield $paths[i]
+
+# Certificates management on windows
+# when defined(windows) or defined(nimdoc):
+#
+#   import std/openssl
+#
+#   type
+#     PCCertContext {.final, pure.} = pointer
+#     X509 {.final, pure.} = pointer
+#     CertStore {.final, pure.} = pointer
+#
+#   # OpenSSL cert store
+#
+#   {.push stdcall, dynlib: "kernel32", importc.}
+#
+#   proc CertOpenSystemStore*(hprov: pointer=nil, szSubsystemProtocol: cstring): CertStore
+#
+#   proc CertEnumCertificatesInStore*(hCertStore: CertStore, pPrevCertContext: PCCertContext): pointer
+#
+#   proc CertFreeCertificateContext*(pContext: PCCertContext): bool
+#
+#   proc CertCloseStore*(hCertStore:CertStore, flags:cint): bool
+#
+#   {.pop.}
diff --git a/lib/pure/ssl_config.nim b/lib/pure/ssl_config.nim
new file mode 100644
index 000000000..14f66ede4
--- /dev/null
+++ b/lib/pure/ssl_config.nim
@@ -0,0 +1,51 @@
+# This file was automatically generated by tools/ssl_config_parser on 2020-06-03T22:02:05Z. DO NOT EDIT.
+
+## This module contains SSL configuration parameters obtained from
+## `Mozilla OpSec <https://wiki.mozilla.org/Security/Server_Side_TLS>`_.
+##
+## The configuration file used to generate this module: https://ssl-config.mozilla.org/guidelines/5.4.json
+
+const CiphersModern* = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"
+  ## An OpenSSL-compatible list of secure ciphers for ``modern`` compatibility
+  ## per Mozilla's recommendations.
+  ##
+  ## Oldest clients supported by this list:
+  ## * Firefox 63
+  ## * Android 10.0
+  ## * Chrome 70
+  ## * Edge 75
+  ## * Java 11
+  ## * OpenSSL 1.1.1
+  ## * Opera 57
+  ## * Safari 12.1
+
+const CiphersIntermediate* = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
+  ## An OpenSSL-compatible list of secure ciphers for ``intermediate`` compatibility
+  ## per Mozilla's recommendations.
+  ##
+  ## Oldest clients supported by this list:
+  ## * Firefox 27
+  ## * Android 4.4.2
+  ## * Chrome 31
+  ## * Edge
+  ## * IE 11 on Windows 7
+  ## * Java 8u31
+  ## * OpenSSL 1.0.1
+  ## * Opera 20
+  ## * Safari 9
+
+const CiphersOld* = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
+  ## An OpenSSL-compatible list of secure ciphers for ``old`` compatibility
+  ## per Mozilla's recommendations.
+  ##
+  ## Oldest clients supported by this list:
+  ## * Firefox 1
+  ## * Android 2.3
+  ## * Chrome 1
+  ## * Edge 12
+  ## * IE8 on Windows XP
+  ## * Java 6
+  ## * OpenSSL 0.9.8
+  ## * Opera 5
+  ## * Safari 1
+
diff --git a/lib/pure/stats.nim b/lib/pure/stats.nim
new file mode 100644
index 000000000..6a4fd8f01
--- /dev/null
+++ b/lib/pure/stats.nim
@@ -0,0 +1,335 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Statistical analysis framework for performing
+## basic statistical analysis of data.
+## The data is analysed in a single pass, when it
+## is pushed to a `RunningStat` or `RunningRegress` object.
+##
+## `RunningStat` calculates for a single data set
+## - n (data count)
+## - min (smallest value)
+## - max (largest value)
+## - sum
+## - mean
+## - variance
+## - varianceS (sample variance)
+## - standardDeviation
+## - standardDeviationS (sample standard deviation)
+## - skewness (the third statistical moment)
+## - kurtosis (the fourth statistical moment)
+##
+## `RunningRegress` calculates for two sets of data
+## - n (data count)
+## - slope
+## - intercept
+## - correlation
+##
+## Procs are provided to calculate statistics on `openArray`s.
+##
+## However, if more than a single statistical calculation is required, it is more
+## efficient to push the data once to a `RunningStat` object and then
+## call the numerous statistical procs for the `RunningStat` object:
+
+runnableExamples:
+  from std/math import almostEqual
+
+  template `~=`(a, b: float): bool = almostEqual(a, b)
+
+  var statistics: RunningStat  # must be var
+  statistics.push(@[1.0, 2.0, 1.0, 4.0, 1.0, 4.0, 1.0, 2.0])
+  doAssert statistics.n == 8
+  doAssert statistics.mean() ~= 2.0
+  doAssert statistics.variance() ~= 1.5
+  doAssert statistics.varianceS() ~= 1.714285714285715
+  doAssert statistics.skewness() ~= 0.8164965809277261
+  doAssert statistics.skewnessS() ~= 1.018350154434631
+  doAssert statistics.kurtosis() ~= -1.0
+  doAssert statistics.kurtosisS() ~= -0.7000000000000008
+
+from std/math import FloatClass, sqrt, pow, round
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, formatfloat]
+
+{.push debugger: off.} # the user does not want to trace a part
+                       # of the standard library!
+{.push checks: off, line_dir: off, stack_trace: off.}
+
+type
+  RunningStat* = object           ## An accumulator for statistical data.
+    n*: int                       ## amount of pushed data
+    min*, max*, sum*: float       ## self-explaining
+    mom1, mom2, mom3, mom4: float ## statistical moments, mom1 is mean
+
+  RunningRegress* = object ## An accumulator for regression calculations.
+    n*: int                ## amount of pushed data
+    x_stats*: RunningStat  ## stats for the first set of data
+    y_stats*: RunningStat  ## stats for the second set of data
+    s_xy: float            ## accumulated data for combined xy
+
+# ----------- RunningStat --------------------------
+
+proc clear*(s: var RunningStat) =
+  ## Resets `s`.
+  s.n = 0
+  s.min = 0.0
+  s.max = 0.0
+  s.sum = 0.0
+  s.mom1 = 0.0
+  s.mom2 = 0.0
+  s.mom3 = 0.0
+  s.mom4 = 0.0
+
+proc push*(s: var RunningStat, x: float) =
+  ## Pushes a value `x` for processing.
+  if s.n == 0:
+    s.min = x
+    s.max = x
+  else:
+    if s.min > x: s.min = x
+    if s.max < x: s.max = x
+  inc(s.n)
+  # See Knuth TAOCP vol 2, 3rd edition, page 232
+  s.sum += x
+  let n = toFloat(s.n)
+  let delta = x - s.mom1
+  let delta_n = delta / toFloat(s.n)
+  let delta_n2 = delta_n * delta_n
+  let term1 = delta * delta_n * toFloat(s.n - 1)
+  s.mom4 += term1 * delta_n2 * (n*n - 3*n + 3) +
+              6*delta_n2*s.mom2 - 4*delta_n*s.mom3
+  s.mom3 += term1 * delta_n * (n - 2) - 3*delta_n*s.mom2
+  s.mom2 += term1
+  s.mom1 += delta_n
+
+proc push*(s: var RunningStat, x: int) =
+  ## Pushes a value `x` for processing.
+  ##
+  ## `x` is simply converted to `float`
+  ## and the other push operation is called.
+  s.push(toFloat(x))
+
+proc push*(s: var RunningStat, x: openArray[float|int]) =
+  ## Pushes all values of `x` for processing.
+  ##
+  ## Int values of `x` are simply converted to `float` and
+  ## the other push operation is called.
+  for val in x:
+    s.push(val)
+
+proc mean*(s: RunningStat): float =
+  ## Computes the current mean of `s`.
+  result = s.mom1
+
+proc variance*(s: RunningStat): float =
+  ## Computes the current population variance of `s`.
+  result = s.mom2 / toFloat(s.n)
+
+proc varianceS*(s: RunningStat): float =
+  ## Computes the current sample variance of `s`.
+  if s.n > 1: result = s.mom2 / toFloat(s.n - 1)
+
+proc standardDeviation*(s: RunningStat): float =
+  ## Computes the current population standard deviation of `s`.
+  result = sqrt(variance(s))
+
+proc standardDeviationS*(s: RunningStat): float =
+  ## Computes the current sample standard deviation of `s`.
+  result = sqrt(varianceS(s))
+
+proc skewness*(s: RunningStat): float =
+  ## Computes the current population skewness of `s`.
+  result = sqrt(toFloat(s.n)) * s.mom3 / pow(s.mom2, 1.5)
+
+proc skewnessS*(s: RunningStat): float =
+  ## Computes the current sample skewness of `s`.
+  let s2 = skewness(s)
+  result = sqrt(toFloat(s.n*(s.n-1)))*s2 / toFloat(s.n-2)
+
+proc kurtosis*(s: RunningStat): float =
+  ## Computes the current population kurtosis of `s`.
+  result = toFloat(s.n) * s.mom4 / (s.mom2 * s.mom2) - 3.0
+
+proc kurtosisS*(s: RunningStat): float =
+  ## Computes the current sample kurtosis of `s`.
+  result = toFloat(s.n-1) / toFloat((s.n-2)*(s.n-3)) *
+              (toFloat(s.n+1)*kurtosis(s) + 6)
+
+proc `+`*(a, b: RunningStat): RunningStat =
+  ## Combines two `RunningStat`s.
+  ##
+  ## Useful when performing parallel analysis of data series
+  ## and needing to re-combine parallel result sets.
+  result.clear()
+  result.n = a.n + b.n
+
+  let delta = b.mom1 - a.mom1
+  let delta2 = delta*delta
+  let delta3 = delta*delta2
+  let delta4 = delta2*delta2
+  let n = toFloat(result.n)
+
+  result.mom1 = (a.n.float*a.mom1 + b.n.float*b.mom1) / n
+  result.mom2 = a.mom2 + b.mom2 + delta2 * a.n.float * b.n.float / n
+  result.mom3 = a.mom3 + b.mom3 +
+                delta3 * a.n.float * b.n.float * (a.n.float - b.n.float)/(n*n);
+  result.mom3 += 3.0*delta * (a.n.float*b.mom2 - b.n.float*a.mom2) / n
+  result.mom4 = a.mom4 + b.mom4 +
+            delta4*a.n.float*b.n.float * toFloat(a.n*a.n - a.n*b.n + b.n*b.n) /
+                (n*n*n)
+  result.mom4 += 6.0*delta2 * (a.n.float*a.n.float*b.mom2 + b.n.float*b.n.float*a.mom2) /
+                (n*n) +
+                4.0*delta*(a.n.float*b.mom3 - b.n.float*a.mom3) / n
+  result.max = max(a.max, b.max)
+  result.min = min(a.min, b.min)
+
+proc `+=`*(a: var RunningStat, b: RunningStat) {.inline.} =
+  ## Adds the `RunningStat` `b` to `a`.
+  a = a + b
+
+proc `$`*(a: RunningStat): string =
+  ## Produces a string representation of the `RunningStat`. The exact
+  ## format is currently unspecified and subject to change. Currently
+  ## it contains:
+  ##
+  ## - the number of probes
+  ## - min, max values
+  ## - sum, mean and standard deviation.
+  result = "RunningStat(\n"
+  result.add "  number of probes: " & $a.n & "\n"
+  result.add "  max: " & $a.max & "\n"
+  result.add "  min: " & $a.min & "\n"
+  result.add "  sum: " & $a.sum & "\n"
+  result.add "  mean: " & $a.mean & "\n"
+  result.add "  std deviation: " & $a.standardDeviation & "\n"
+  result.add ")"
+
+# ---------------------- standalone array/seq stats ---------------------
+
+proc mean*[T](x: openArray[T]): float =
+  ## Computes the mean of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.mean()
+
+proc variance*[T](x: openArray[T]): float =
+  ## Computes the population variance of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.variance()
+
+proc varianceS*[T](x: openArray[T]): float =
+  ## Computes the sample variance of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.varianceS()
+
+proc standardDeviation*[T](x: openArray[T]): float =
+  ## Computes the population standard deviation of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.standardDeviation()
+
+proc standardDeviationS*[T](x: openArray[T]): float =
+  ## Computes the sample standard deviation of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.standardDeviationS()
+
+proc skewness*[T](x: openArray[T]): float =
+  ## Computes the population skewness of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.skewness()
+
+proc skewnessS*[T](x: openArray[T]): float =
+  ## Computes the sample skewness of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.skewnessS()
+
+proc kurtosis*[T](x: openArray[T]): float =
+  ## Computes the population kurtosis of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.kurtosis()
+
+proc kurtosisS*[T](x: openArray[T]): float =
+  ## Computes the sample kurtosis of `x`.
+  var rs: RunningStat
+  rs.push(x)
+  result = rs.kurtosisS()
+
+# ---------------------- Running Regression -----------------------------
+
+proc clear*(r: var RunningRegress) =
+  ## Resets `r`.
+  r.x_stats.clear()
+  r.y_stats.clear()
+  r.s_xy = 0.0
+  r.n = 0
+
+proc push*(r: var RunningRegress, x, y: float) =
+  ## Pushes two values `x` and `y` for processing.
+  r.s_xy += (r.x_stats.mean() - x)*(r.y_stats.mean() - y) *
+                toFloat(r.n) / toFloat(r.n + 1)
+  r.x_stats.push(x)
+  r.y_stats.push(y)
+  inc(r.n)
+
+proc push*(r: var RunningRegress, x, y: int) {.inline.} =
+  ## Pushes two values `x` and `y` for processing.
+  ##
+  ## `x` and `y` are converted to `float`
+  ## and the other push operation is called.
+  r.push(toFloat(x), toFloat(y))
+
+proc push*(r: var RunningRegress, x, y: openArray[float|int]) =
+  ## Pushes two sets of values `x` and `y` for processing.
+  assert(x.len == y.len)
+  for i in 0..<x.len:
+    r.push(x[i], y[i])
+
+proc slope*(r: RunningRegress): float =
+  ## Computes the current slope of `r`.
+  let s_xx = r.x_stats.varianceS()*toFloat(r.n - 1)
+  result = r.s_xy / s_xx
+
+proc intercept*(r: RunningRegress): float =
+  ## Computes the current intercept of `r`.
+  result = r.y_stats.mean() - r.slope()*r.x_stats.mean()
+
+proc correlation*(r: RunningRegress): float =
+  ## Computes the current correlation of the two data
+  ## sets pushed into `r`.
+  let t = r.x_stats.standardDeviation() * r.y_stats.standardDeviation()
+  result = r.s_xy / (toFloat(r.n) * t)
+
+proc `+`*(a, b: RunningRegress): RunningRegress =
+  ## Combines two `RunningRegress` objects.
+  ##
+  ## Useful when performing parallel analysis of data series
+  ## and needing to re-combine parallel result sets
+  result.clear()
+  result.x_stats = a.x_stats + b.x_stats
+  result.y_stats = a.y_stats + b.y_stats
+  result.n = a.n + b.n
+
+  let delta_x = b.x_stats.mean() - a.x_stats.mean()
+  let delta_y = b.y_stats.mean() - a.y_stats.mean()
+  result.s_xy = a.s_xy + b.s_xy +
+      toFloat(a.n*b.n)*delta_x*delta_y/toFloat(result.n)
+
+proc `+=`*(a: var RunningRegress, b: RunningRegress) =
+  ## Adds the `RunningRegress` `b` to `a`.
+  a = a + b
+
+{.pop.}
+{.pop.}
diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim
index f4d2911fc..56f49d7b1 100755..100644
--- a/lib/pure/streams.nim
+++ b/lib/pure/streams.nim
@@ -1,223 +1,1521 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module provides a stream interface and two implementations thereof:
-## the `PFileStream` and the `PStringStream` which implement the stream
-## interface for Nimrod file objects (`TFile`) and strings. Other modules
-## may provide other implementations for this standard stream interface.
+## the `FileStream <#FileStream>`_ and the `StringStream <#StringStream>`_
+## which implement the stream interface for Nim file objects (`File`) and
+## strings.
+##
+## Other modules may provide other implementations for this standard
+## stream interface.
+##
+## .. warning:: Due to the use of `pointer`, the `readData`, `peekData` and
+## `writeData` interfaces are not available on the compile-time VM, and must
+## be cast from a `ptr string` on the JS backend. However, `readDataStr` is
+## available generally in place of `readData`.
+##
+## Basic usage
+## ===========
+##
+## The basic flow of using this module is:
+##
+## 1. Open input stream
+## 2. Read or write stream
+## 3. Close stream
+##
+## StringStream example
+## --------------------
+##
+##   ```Nim
+##   import std/streams
+##
+##   var strm = newStringStream("""The first line
+##   the second line
+##   the third line""")
+##
+##   var line = ""
+##
+##   while strm.readLine(line):
+##     echo line
+##
+##   # Output:
+##   # The first line
+##   # the second line
+##   # the third line
+##
+##   strm.close()
+##   ```
+##
+## FileStream example
+## ------------------
+##
+## Write file stream example:
+##
+##   ```Nim
+##   import std/streams
+##
+##   var strm = newFileStream("somefile.txt", fmWrite)
+##   var line = ""
+##
+##   if not isNil(strm):
+##     strm.writeLine("The first line")
+##     strm.writeLine("the second line")
+##     strm.writeLine("the third line")
+##     strm.close()
+##
+##   # Output (somefile.txt):
+##   # The first line
+##   # the second line
+##   # the third line
+##   ```
+##
+## Read file stream example:
+##
+##   ```Nim
+##   import std/streams
+##
+##   var strm = newFileStream("somefile.txt", fmRead)
+##   var line = ""
+##
+##   if not isNil(strm):
+##     while strm.readLine(line):
+##       echo line
+##     strm.close()
+##
+##   # Output:
+##   # The first line
+##   # the second line
+##   # the third line
+##   ```
+##
+## See also
+## ========
+## * `asyncstreams module <asyncstreams.html>`_
+## * `io module <syncio.html>`_ for `FileMode enum <syncio.html#FileMode>`_
 
-proc newEIO(msg: string): ref EIO =
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+  export FileMode
+
+proc newEIO(msg: string): owned(ref IOError) =
   new(result)
   result.msg = msg
 
 type
-  PStream* = ref TStream
-  TStream* = object of TObject ## Stream interface that supports
-                               ## writing or reading.
-    close*: proc (s: PStream)
-    atEnd*: proc (s: PStream): bool
-    setPosition*: proc (s: PStream, pos: int)
-    getPosition*: proc (s: PStream): int
-    readData*: proc (s: PStream, buffer: pointer, bufLen: int): int
-    writeData*: proc (s: PStream, buffer: pointer, bufLen: int)
-
-proc write*[T](s: PStream, x: T) = 
-  ## generic write procedure. Writes `x` to the stream `s`. Implementation:
-  ##
-  ## .. code-block:: Nimrod
-  ##
-  ##     s.writeData(s, addr(x), sizeof(x))
-  var x = x
-  s.writeData(s, addr(x), sizeof(x))
-
-proc write*(s: PStream, x: string) = 
-  ## writes the string `x` to the the stream `s`. No length field or 
+  Stream* = ref StreamObj
+    ## All procedures of this module use this type.
+    ## Procedures don't directly use `StreamObj <#StreamObj>`_.
+  StreamObj* = object of RootObj
+    ## Stream interface that supports writing or reading.
+    ##
+    ## **Note:**
+    ## * That these fields here shouldn't be used directly.
+    ##   They are accessible so that a stream implementation can override them.
+    closeImpl*: proc (s: Stream)
+      {.nimcall, raises: [IOError, OSError], tags: [WriteIOEffect], gcsafe.}
+    atEndImpl*: proc (s: Stream): bool
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
+    setPositionImpl*: proc (s: Stream, pos: int)
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
+    getPositionImpl*: proc (s: Stream): int
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
+
+    readDataStrImpl*: proc (s: Stream, buffer: var string, slice: Slice[int]): int
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
+
+    readLineImpl*: proc(s: Stream, line: var string): bool
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
+
+    readDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int): int
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
+    peekDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int): int
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
+    writeDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int)
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [WriteIOEffect], gcsafe.}
+
+    flushImpl*: proc (s: Stream)
+      {.nimcall, raises: [Defect, IOError, OSError], tags: [WriteIOEffect], gcsafe.}
+
+proc flush*(s: Stream) =
+  ## Flushes the buffers that the stream `s` might use.
+  ##
+  ## This procedure causes any unwritten data for that stream to be delivered
+  ## to the host environment to be written to the file.
+  ##
+  ## See also:
+  ## * `close proc <#close,Stream>`_
+  runnableExamples:
+    from std/os import removeFile
+
+    var strm = newFileStream("somefile.txt", fmWrite)
+
+    doAssert "Before write:" & readFile("somefile.txt") == "Before write:"
+    strm.write("hello")
+    doAssert "After  write:" & readFile("somefile.txt") == "After  write:"
+
+    strm.flush()
+    doAssert "After  flush:" & readFile("somefile.txt") == "After  flush:hello"
+    strm.write("HELLO")
+    strm.flush()
+    doAssert "After  flush:" & readFile("somefile.txt") == "After  flush:helloHELLO"
+
+    strm.close()
+    doAssert "After  close:" & readFile("somefile.txt") == "After  close:helloHELLO"
+    removeFile("somefile.txt")
+
+  if not isNil(s.flushImpl): s.flushImpl(s)
+
+proc close*(s: Stream) =
+  ## Closes the stream `s`.
+  ##
+  ## See also:
+  ## * `flush proc <#flush,Stream>`_
+  runnableExamples:
+    block:
+      let strm = newStringStream("The first line\nthe second line\nthe third line")
+      ## do something...
+      strm.close()
+      
+    block:
+      let strm = newFileStream("amissingfile.txt")
+      # deferring works even if newFileStream fails
+      defer: strm.close()
+      if not isNil(strm):
+        ## do something...
+
+  if not isNil(s) and not isNil(s.closeImpl):
+    s.closeImpl(s)
+
+proc atEnd*(s: Stream): bool =
+  ## Checks if more data can be read from `s`. Returns ``true`` if all data has
+  ## been read.
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    var line = ""
+    doAssert strm.atEnd() == false
+    while strm.readLine(line):
+      discard
+    doAssert strm.atEnd() == true
+    strm.close()
+
+  result = s.atEndImpl(s)
+
+proc setPosition*(s: Stream, pos: int) =
+  ## Sets the position `pos` of the stream `s`.
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    strm.setPosition(4)
+    doAssert strm.readLine() == "first line"
+    strm.setPosition(0)
+    doAssert strm.readLine() == "The first line"
+    strm.close()
+
+  s.setPositionImpl(s, pos)
+
+proc getPosition*(s: Stream): int =
+  ## Retrieves the current position in the stream `s`.
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    doAssert strm.getPosition() == 0
+    discard strm.readLine()
+    doAssert strm.getPosition() == 15
+    strm.close()
+
+  result = s.getPositionImpl(s)
+
+proc readData*(s: Stream, buffer: pointer, bufLen: int): int =
+  ## Low level proc that reads data into an untyped `buffer` of `bufLen` size.
+  ##
+  ## **JS note:** `buffer` is treated as a ``ptr string`` and written to between
+  ## ``0..<bufLen``.
+  runnableExamples:
+    var strm = newStringStream("abcde")
+    var buffer: array[6, char]
+    doAssert strm.readData(addr(buffer), 1024) == 5
+    doAssert buffer == ['a', 'b', 'c', 'd', 'e', '\x00']
+    doAssert strm.atEnd() == true
+    strm.close()
+
+  result = s.readDataImpl(s, buffer, bufLen)
+
+proc readDataStr*(s: Stream, buffer: var string, slice: Slice[int]): int =
+  ## Low level proc that reads data into a string ``buffer`` at ``slice``.
+  runnableExamples:
+    var strm = newStringStream("abcde")
+    var buffer = "12345"
+    doAssert strm.readDataStr(buffer, 0..3) == 4
+    doAssert buffer == "abcd5"
+    strm.close()
+
+  if s.readDataStrImpl != nil:
+    result = s.readDataStrImpl(s, buffer, slice)
+  else:
+    # fallback
+    when declared(prepareMutation):
+      # buffer might potentially be a CoW literal with ARC
+      prepareMutation(buffer)
+    result = s.readData(addr buffer[slice.a], slice.b + 1 - slice.a)
+
+template jsOrVmBlock(caseJsOrVm, caseElse: untyped): untyped =
+  when nimvm:
+    block:
+      caseJsOrVm
+  else:
+    block:
+      when defined(js) or defined(nimscript):
+        # nimscript has to be here to avoid semantic checking of caseElse
+        caseJsOrVm
+      else:
+        caseElse
+
+when (NimMajor, NimMinor) >= (1, 3) or not defined(js):
+  proc readAll*(s: Stream): string =
+    ## Reads all available data.
+    runnableExamples:
+      var strm = newStringStream("The first line\nthe second line\nthe third line")
+      doAssert strm.readAll() == "The first line\nthe second line\nthe third line"
+      doAssert strm.atEnd() == true
+      strm.close()
+
+    const bufferSize = 1024
+    jsOrVmBlock:
+      var buffer2: string
+      buffer2.setLen(bufferSize)
+      while true:
+        let readBytes = readDataStr(s, buffer2, 0..<bufferSize)
+        if readBytes == 0:
+          break
+        let prevLen = result.len
+        result.setLen(prevLen + readBytes)
+        result[prevLen..<prevLen+readBytes] = buffer2[0..<readBytes]
+        if readBytes < bufferSize:
+          break
+    do: # not JS or VM
+      var buffer {.noinit.}: array[bufferSize, char]
+      while true:
+        let readBytes = readData(s, addr(buffer[0]), bufferSize)
+        if readBytes == 0:
+          break
+        let prevLen = result.len
+        result.setLen(prevLen + readBytes)
+        copyMem(addr(result[prevLen]), addr(buffer[0]), readBytes)
+        if readBytes < bufferSize:
+          break
+
+proc peekData*(s: Stream, buffer: pointer, bufLen: int): int =
+  ## Low level proc that reads data into an untyped `buffer` of `bufLen` size
+  ## without moving stream position.
+  ##
+  ## **JS note:** `buffer` is treated as a ``ptr string`` and written to between
+  ## ``0..<bufLen``.
+  runnableExamples:
+    var strm = newStringStream("abcde")
+    var buffer: array[6, char]
+    doAssert strm.peekData(addr(buffer), 1024) == 5
+    doAssert buffer == ['a', 'b', 'c', 'd', 'e', '\x00']
+    doAssert strm.atEnd() == false
+    strm.close()
+
+  result = s.peekDataImpl(s, buffer, bufLen)
+
+proc writeData*(s: Stream, buffer: pointer, bufLen: int) =
+  ## Low level proc that writes an untyped `buffer` of `bufLen` size
+  ## to the stream `s`.
+  ##
+  ## **JS note:** `buffer` is treated as a ``ptr string`` and read between
+  ## ``0..<bufLen``.
+  runnableExamples:
+    ## writeData
+    var strm = newStringStream("")
+    var buffer = ['a', 'b', 'c', 'd', 'e']
+    strm.writeData(addr(buffer), sizeof(buffer))
+    doAssert strm.atEnd() == true
+    ## readData
+    strm.setPosition(0)
+    var buffer2: array[6, char]
+    doAssert strm.readData(addr(buffer2), sizeof(buffer2)) == 5
+    doAssert buffer2 == ['a', 'b', 'c', 'd', 'e', '\x00']
+    strm.close()
+
+  s.writeDataImpl(s, buffer, bufLen)
+
+proc write*[T](s: Stream, x: T) =
+  ## Generic write procedure. Writes `x` to the stream `s`. Implementation:
+  ##
+  ## **Note:** Not available for JS backend. Use `write(Stream, string)
+  ## <#write,Stream,string>`_ for now.
+  ##
+  ##   ```Nim
+  ##   s.writeData(s, unsafeAddr(x), sizeof(x))
+  ##   ```
+  runnableExamples:
+    var strm = newStringStream("")
+    strm.write("abcde")
+    strm.setPosition(0)
+    doAssert strm.readAll() == "abcde"
+    strm.close()
+
+  writeData(s, unsafeAddr(x), sizeof(x))
+
+proc write*(s: Stream, x: string) =
+  ## Writes the string `x` to the stream `s`. No length field or
   ## terminating zero is written.
-  s.writeData(s, cstring(x), x.len)
+  runnableExamples:
+    var strm = newStringStream("")
+    strm.write("THE FIRST LINE")
+    strm.setPosition(0)
+    doAssert strm.readLine() == "THE FIRST LINE"
+    strm.close()
+
+  when nimvm:
+    writeData(s, cstring(x), x.len)
+  else:
+    if x.len > 0:
+      when defined(js):
+        var x = x
+        writeData(s, addr(x), x.len)
+      else:
+        writeData(s, cstring(x), x.len)
+
+proc write*(s: Stream, args: varargs[string, `$`]) =
+  ## Writes one or more strings to the the stream. No length fields or
+  ## terminating zeros are written.
+  runnableExamples:
+    var strm = newStringStream("")
+    strm.write(1, 2, 3, 4)
+    strm.setPosition(0)
+    doAssert strm.readLine() == "1234"
+    strm.close()
+
+  for str in args: write(s, str)
+
+proc writeLine*(s: Stream, args: varargs[string, `$`]) =
+  ## Writes one or more strings to the the stream `s` followed
+  ## by a new line. No length field or terminating zero is written.
+  runnableExamples:
+    var strm = newStringStream("")
+    strm.writeLine(1, 2)
+    strm.writeLine(3, 4)
+    strm.setPosition(0)
+    doAssert strm.readAll() == "12\n34\n"
+    strm.close()
+
+  for str in args: write(s, str)
+  write(s, "\n")
+
+proc read*[T](s: Stream, result: var T) =
+  ## Generic read procedure. Reads `result` from the stream `s`.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream("012")
+    ## readInt
+    var i: int8
+    strm.read(i)
+    doAssert i == 48
+    ## readData
+    var buffer: array[2, char]
+    strm.read(buffer)
+    doAssert buffer == ['1', '2']
+    strm.close()
+
+  if readData(s, addr(result), sizeof(T)) != sizeof(T):
+    raise newEIO("cannot read from stream")
+
+proc peek*[T](s: Stream, result: var T) =
+  ## Generic peek procedure. Peeks `result` from the stream `s`.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream("012")
+    ## peekInt
+    var i: int8
+    strm.peek(i)
+    doAssert i == 48
+    ## peekData
+    var buffer: array[2, char]
+    strm.peek(buffer)
+    doAssert buffer == ['0', '1']
+    strm.close()
 
-proc read[T](s: PStream, result: var T) = 
-  ## generic read procedure. Reads `result` from the stream `s`.
-  if s.readData(s, addr(result), sizeof(T)) != sizeof(T):
+  if peekData(s, addr(result), sizeof(T)) != sizeof(T):
     raise newEIO("cannot read from stream")
 
-proc readChar*(s: PStream): char =
-  ## reads a char from the stream `s`. Raises `EIO` if an error occured.
-  ## Returns '\0' as an EOF marker.
-  discard s.readData(s, addr(result), sizeof(result))
+proc readChar*(s: Stream): char =
+  ## Reads a char from the stream `s`.
+  ##
+  ## Raises `IOError` if an error occurred.
+  ## Returns '\\0' as an EOF marker.
+  runnableExamples:
+    var strm = newStringStream("12\n3")
+    doAssert strm.readChar() == '1'
+    doAssert strm.readChar() == '2'
+    doAssert strm.readChar() == '\n'
+    doAssert strm.readChar() == '3'
+    doAssert strm.readChar() == '\x00'
+    strm.close()
+
+  jsOrVmBlock:
+    var str = " "
+    if readDataStr(s, str, 0..0) != 1: result = '\0'
+    else: result = str[0]
+  do:
+    if readData(s, addr(result), sizeof(result)) != 1: result = '\0'
+
+proc peekChar*(s: Stream): char =
+  ## Peeks a char from the stream `s`. Raises `IOError` if an error occurred.
+  ## Returns '\\0' as an EOF marker.
+  runnableExamples:
+    var strm = newStringStream("12\n3")
+    doAssert strm.peekChar() == '1'
+    doAssert strm.peekChar() == '1'
+    discard strm.readAll()
+    doAssert strm.peekChar() == '\x00'
+    strm.close()
+
+  when defined(js):
+    var str = " "
+    if peekData(s, addr(str), sizeof(result)) != 1: result = '\0'
+    else: result = str[0]
+  else:
+    if peekData(s, addr(result), sizeof(result)) != 1: result = '\0'
+
+proc readBool*(s: Stream): bool =
+  ## Reads a bool from the stream `s`.
+  ##
+  ## A bool is one byte long and it is `true` for every non-zero
+  ## (`0000_0000`) value.
+  ## Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(true)
+    strm.write(false)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readBool() == true
+    doAssert strm.readBool() == false
+    doAssertRaises(IOError): discard strm.readBool()
+    strm.close()
+
+  var t: byte
+  read(s, t)
+  result = t != 0.byte
+
+proc peekBool*(s: Stream): bool =
+  ## Peeks a bool from the stream `s`.
+  ##
+  ## A bool is one byte long and it is `true` for every non-zero
+  ## (`0000_0000`) value.
+  ## Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(true)
+    strm.write(false)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekBool() == true
+    ## not false
+    doAssert strm.peekBool() == true
+    doAssert strm.readBool() == true
+    doAssert strm.peekBool() == false
+    strm.close()
+
+  var t: byte
+  peek(s, t)
+  result = t != 0.byte
+
+proc readInt8*(s: Stream): int8 =
+  ## Reads an int8 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i8)
+    strm.write(2'i8)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readInt8() == 1'i8
+    doAssert strm.readInt8() == 2'i8
+    doAssertRaises(IOError): discard strm.readInt8()
+    strm.close()
 
-proc readBool*(s: PStream): bool = 
-  ## reads a bool from the stream `s`. Raises `EIO` if an error occured.
   read(s, result)
 
-proc readInt8*(s: PStream): int8 = 
-  ## reads an int8 from the stream `s`. Raises `EIO` if an error occured.
+proc peekInt8*(s: Stream): int8 =
+  ## Peeks an int8 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i8)
+    strm.write(2'i8)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekInt8() == 1'i8
+    ## not 2'i8
+    doAssert strm.peekInt8() == 1'i8
+    doAssert strm.readInt8() == 1'i8
+    doAssert strm.peekInt8() == 2'i8
+    strm.close()
+
+  peek(s, result)
+
+proc readInt16*(s: Stream): int16 =
+  ## Reads an int16 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i16)
+    strm.write(2'i16)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readInt16() == 1'i16
+    doAssert strm.readInt16() == 2'i16
+    doAssertRaises(IOError): discard strm.readInt16()
+    strm.close()
+
   read(s, result)
 
-proc readInt16*(s: PStream): int16 = 
-  ## reads an int16 from the stream `s`. Raises `EIO` if an error occured.
+proc peekInt16*(s: Stream): int16 =
+  ## Peeks an int16 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i16)
+    strm.write(2'i16)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekInt16() == 1'i16
+    ## not 2'i16
+    doAssert strm.peekInt16() == 1'i16
+    doAssert strm.readInt16() == 1'i16
+    doAssert strm.peekInt16() == 2'i16
+    strm.close()
+
+  peek(s, result)
+
+proc readInt32*(s: Stream): int32 =
+  ## Reads an int32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i32)
+    strm.write(2'i32)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readInt32() == 1'i32
+    doAssert strm.readInt32() == 2'i32
+    doAssertRaises(IOError): discard strm.readInt32()
+    strm.close()
+
   read(s, result)
 
-proc readInt32*(s: PStream): int32 = 
-  ## reads an int32 from the stream `s`. Raises `EIO` if an error occured.
+proc peekInt32*(s: Stream): int32 =
+  ## Peeks an int32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i32)
+    strm.write(2'i32)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekInt32() == 1'i32
+    ## not 2'i32
+    doAssert strm.peekInt32() == 1'i32
+    doAssert strm.readInt32() == 1'i32
+    doAssert strm.peekInt32() == 2'i32
+    strm.close()
+
+  peek(s, result)
+
+proc readInt64*(s: Stream): int64 =
+  ## Reads an int64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i64)
+    strm.write(2'i64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readInt64() == 1'i64
+    doAssert strm.readInt64() == 2'i64
+    doAssertRaises(IOError): discard strm.readInt64()
+    strm.close()
+
   read(s, result)
 
-proc readInt64*(s: PStream): int64 = 
-  ## reads an int64 from the stream `s`. Raises `EIO` if an error occured.
+proc peekInt64*(s: Stream): int64 =
+  ## Peeks an int64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'i64)
+    strm.write(2'i64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekInt64() == 1'i64
+    ## not 2'i64
+    doAssert strm.peekInt64() == 1'i64
+    doAssert strm.readInt64() == 1'i64
+    doAssert strm.peekInt64() == 2'i64
+    strm.close()
+
+  peek(s, result)
+
+proc readUint8*(s: Stream): uint8 =
+  ## Reads an uint8 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u8)
+    strm.write(2'u8)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readUint8() == 1'u8
+    doAssert strm.readUint8() == 2'u8
+    doAssertRaises(IOError): discard strm.readUint8()
+    strm.close()
+
   read(s, result)
 
-proc readFloat32*(s: PStream): float32 = 
-  ## reads a float32 from the stream `s`. Raises `EIO` if an error occured.
+proc peekUint8*(s: Stream): uint8 =
+  ## Peeks an uint8 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u8)
+    strm.write(2'u8)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekUint8() == 1'u8
+    ## not 2'u8
+    doAssert strm.peekUint8() == 1'u8
+    doAssert strm.readUint8() == 1'u8
+    doAssert strm.peekUint8() == 2'u8
+    strm.close()
+
+  peek(s, result)
+
+proc readUint16*(s: Stream): uint16 =
+  ## Reads an uint16 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u16)
+    strm.write(2'u16)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readUint16() == 1'u16
+    doAssert strm.readUint16() == 2'u16
+    doAssertRaises(IOError): discard strm.readUint16()
+    strm.close()
+
   read(s, result)
 
-proc readFloat64*(s: PStream): float64 = 
-  ## reads a float64 from the stream `s`. Raises `EIO` if an error occured.
+proc peekUint16*(s: Stream): uint16 =
+  ## Peeks an uint16 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u16)
+    strm.write(2'u16)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekUint16() == 1'u16
+    ## not 2'u16
+    doAssert strm.peekUint16() == 1'u16
+    doAssert strm.readUint16() == 1'u16
+    doAssert strm.peekUint16() == 2'u16
+    strm.close()
+
+  peek(s, result)
+
+proc readUint32*(s: Stream): uint32 =
+  ## Reads an uint32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u32)
+    strm.write(2'u32)
+    strm.flush()
+    strm.setPosition(0)
+
+    ## get data
+    doAssert strm.readUint32() == 1'u32
+    doAssert strm.readUint32() == 2'u32
+    doAssertRaises(IOError): discard strm.readUint32()
+    strm.close()
+
   read(s, result)
 
-proc readStr*(s: PStream, length: int): string = 
-  ## reads a string of length `length` from the stream `s`. Raises `EIO` if 
-  ## an error occured.
+proc peekUint32*(s: Stream): uint32 =
+  ## Peeks an uint32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u32)
+    strm.write(2'u32)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekUint32() == 1'u32
+    ## not 2'u32
+    doAssert strm.peekUint32() == 1'u32
+    doAssert strm.readUint32() == 1'u32
+    doAssert strm.peekUint32() == 2'u32
+    strm.close()
+
+  peek(s, result)
+
+proc readUint64*(s: Stream): uint64 =
+  ## Reads an uint64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u64)
+    strm.write(2'u64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readUint64() == 1'u64
+    doAssert strm.readUint64() == 2'u64
+    doAssertRaises(IOError): discard strm.readUint64()
+    strm.close()
+
+  read(s, result)
+
+proc peekUint64*(s: Stream): uint64 =
+  ## Peeks an uint64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'u64)
+    strm.write(2'u64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekUint64() == 1'u64
+    ## not 2'u64
+    doAssert strm.peekUint64() == 1'u64
+    doAssert strm.readUint64() == 1'u64
+    doAssert strm.peekUint64() == 2'u64
+    strm.close()
+
+  peek(s, result)
+
+proc readFloat32*(s: Stream): float32 =
+  ## Reads a float32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'f32)
+    strm.write(2'f32)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readFloat32() == 1'f32
+    doAssert strm.readFloat32() == 2'f32
+    doAssertRaises(IOError): discard strm.readFloat32()
+    strm.close()
+
+  read(s, result)
+
+proc peekFloat32*(s: Stream): float32 =
+  ## Peeks a float32 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'f32)
+    strm.write(2'f32)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekFloat32() == 1'f32
+    ## not 2'f32
+    doAssert strm.peekFloat32() == 1'f32
+    doAssert strm.readFloat32() == 1'f32
+    doAssert strm.peekFloat32() == 2'f32
+    strm.close()
+
+  peek(s, result)
+
+proc readFloat64*(s: Stream): float64 =
+  ## Reads a float64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `readStr <#readStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'f64)
+    strm.write(2'f64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.readFloat64() == 1'f64
+    doAssert strm.readFloat64() == 2'f64
+    doAssertRaises(IOError): discard strm.readFloat64()
+    strm.close()
+
+  read(s, result)
+
+proc peekFloat64*(s: Stream): float64 =
+  ## Peeks a float64 from the stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** Not available for JS backend. Use `peekStr <#peekStr,Stream,int>`_ for now.
+  runnableExamples:
+    var strm = newStringStream()
+    ## setup for reading data
+    strm.write(1'f64)
+    strm.write(2'f64)
+    strm.flush()
+    strm.setPosition(0)
+    ## get data
+    doAssert strm.peekFloat64() == 1'f64
+    ## not 2'f64
+    doAssert strm.peekFloat64() == 1'f64
+    doAssert strm.readFloat64() == 1'f64
+    doAssert strm.peekFloat64() == 2'f64
+    strm.close()
+
+  peek(s, result)
+
+proc readStrPrivate(s: Stream, length: int, str: var string) =
+  if length > len(str): setLen(str, length)
+  var L: int
+  when nimvm:
+    L = readDataStr(s, str, 0..length-1)
+  else:
+    when defined(js):
+      L = readData(s, addr(str), length)
+    else:
+      L = readData(s, cstring(str), length)
+  if L != len(str): setLen(str, L)
+
+proc readStr*(s: Stream, length: int, str: var string) {.since: (1, 3).} =
+  ## Reads a string of length `length` from the stream `s`. Raises `IOError` if
+  ## an error occurred.
+  readStrPrivate(s, length, str)
+
+proc readStr*(s: Stream, length: int): string =
+  ## Reads a string of length `length` from the stream `s`. Raises `IOError` if
+  ## an error occurred.
+  runnableExamples:
+    var strm = newStringStream("abcde")
+    doAssert strm.readStr(2) == "ab"
+    doAssert strm.readStr(2) == "cd"
+    doAssert strm.readStr(2) == "e"
+    doAssert strm.readStr(2) == ""
+    strm.close()
+  result = newString(length)
+  readStrPrivate(s, length, result)
+
+proc peekStrPrivate(s: Stream, length: int, str: var string) =
+  if length > len(str): setLen(str, length)
+  when defined(js):
+    let L = peekData(s, addr(str), length)
+  else:
+    let L = peekData(s, cstring(str), length)
+  if L != len(str): setLen(str, L)
+
+proc peekStr*(s: Stream, length: int, str: var string) {.since: (1, 3).} =
+  ## Peeks a string of length `length` from the stream `s`. Raises `IOError` if
+  ## an error occurred.
+  peekStrPrivate(s, length, str)
+
+proc peekStr*(s: Stream, length: int): string =
+  ## Peeks a string of length `length` from the stream `s`. Raises `IOError` if
+  ## an error occurred.
+  runnableExamples:
+    var strm = newStringStream("abcde")
+    doAssert strm.peekStr(2) == "ab"
+    ## not "cd
+    doAssert strm.peekStr(2) == "ab"
+    doAssert strm.readStr(2) == "ab"
+    doAssert strm.peekStr(2) == "cd"
+    strm.close()
   result = newString(length)
-  var L = s.readData(s, addr(result[0]), length)
-  if L != length: setLen(result, L)
+  peekStrPrivate(s, length, result)
+
+proc readLine*(s: Stream, line: var string): bool =
+  ## Reads a line of text from the stream `s` into `line`. `line` must not be
+  ## ``nil``! May throw an IO exception.
+  ##
+  ## A line of text may be delimited by ``LF`` or ``CRLF``.
+  ## The newline character(s) are not part of the returned string.
+  ## Returns ``false`` if the end of the file has been reached, ``true``
+  ## otherwise. If ``false`` is returned `line` contains no new data.
+  ##
+  ## See also:
+  ## * `readLine(Stream) proc <#readLine,Stream>`_
+  ## * `peekLine(Stream) proc <#peekLine,Stream>`_
+  ## * `peekLine(Stream, string) proc <#peekLine,Stream,string>`_
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    var line = ""
+    doAssert strm.readLine(line) == true
+    doAssert line == "The first line"
+    doAssert strm.readLine(line) == true
+    doAssert line == "the second line"
+    doAssert strm.readLine(line) == true
+    doAssert line == "the third line"
+    doAssert strm.readLine(line) == false
+    doAssert line == ""
+    strm.close()
+
+  if s.readLineImpl != nil:
+    result = s.readLineImpl(s, line)
+  else:
+    # fallback
+    line.setLen(0)
+    while true:
+      var c = readChar(s)
+      if c == '\c':
+        c = readChar(s)
+        break
+      elif c == '\L': break
+      elif c == '\0':
+        if line.len > 0: break
+        else: return false
+      line.add(c)
+    result = true
+
+proc peekLine*(s: Stream, line: var string): bool =
+  ## Peeks a line of text from the stream `s` into `line`. `line` must not be
+  ## ``nil``! May throw an IO exception.
+  ##
+  ## A line of text may be delimited by ``CR``, ``LF`` or
+  ## ``CRLF``. The newline character(s) are not part of the returned string.
+  ## Returns ``false`` if the end of the file has been reached, ``true``
+  ## otherwise. If ``false`` is returned `line` contains no new data.
+  ##
+  ## See also:
+  ## * `readLine(Stream) proc <#readLine,Stream>`_
+  ## * `readLine(Stream, string) proc <#readLine,Stream,string>`_
+  ## * `peekLine(Stream) proc <#peekLine,Stream>`_
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    var line = ""
+    doAssert strm.peekLine(line) == true
+    doAssert line == "The first line"
+    doAssert strm.peekLine(line) == true
+    ## not "the second line"
+    doAssert line == "The first line"
+    doAssert strm.readLine(line) == true
+    doAssert line == "The first line"
+    doAssert strm.peekLine(line) == true
+    doAssert line == "the second line"
+    strm.close()
+
+  let pos = getPosition(s)
+  defer: setPosition(s, pos)
+  result = readLine(s, line)
+
+proc readLine*(s: Stream): string =
+  ## Reads a line from a stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** This is not very efficient.
+  ##
+  ## See also:
+  ## * `readLine(Stream, string) proc <#readLine,Stream,string>`_
+  ## * `peekLine(Stream) proc <#peekLine,Stream>`_
+  ## * `peekLine(Stream, string) proc <#peekLine,Stream,string>`_
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    doAssert strm.readLine() == "The first line"
+    doAssert strm.readLine() == "the second line"
+    doAssert strm.readLine() == "the third line"
+    doAssertRaises(IOError): discard strm.readLine()
+    strm.close()
 
-proc readLine*(s: PStream): string =
-  ## Reads a line from a stream `s`. Note: This is not very efficient. Raises 
-  ## `EIO` if an error occured.
   result = ""
-  while not s.atEnd(s): 
+  if s.atEnd:
+    raise newEIO("cannot read from stream")
+  while true:
     var c = readChar(s)
-    if c == '\c': 
+    if c == '\c':
       c = readChar(s)
       break
-    elif c == '\L' or c == '\0': break
-    result.add(c)
+    if c == '\L' or c == '\0':
+      break
+    else:
+      result.add(c)
+
+proc peekLine*(s: Stream): string =
+  ## Peeks a line from a stream `s`. Raises `IOError` if an error occurred.
+  ##
+  ## **Note:** This is not very efficient.
+  ##
+  ## See also:
+  ## * `readLine(Stream) proc <#readLine,Stream>`_
+  ## * `readLine(Stream, string) proc <#readLine,Stream,string>`_
+  ## * `peekLine(Stream, string) proc <#peekLine,Stream,string>`_
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    doAssert strm.peekLine() == "The first line"
+    ## not "the second line"
+    doAssert strm.peekLine() == "The first line"
+    doAssert strm.readLine() == "The first line"
+    doAssert strm.peekLine() == "the second line"
+    strm.close()
+
+  let pos = getPosition(s)
+  defer: setPosition(s, pos)
+  result = readLine(s)
+
+iterator lines*(s: Stream): string =
+  ## Iterates over every line in the stream.
+  ## The iteration is based on ``readLine``.
+  ##
+  ## See also:
+  ## * `readLine(Stream) proc <#readLine,Stream>`_
+  ## * `readLine(Stream, string) proc <#readLine,Stream,string>`_
+  runnableExamples:
+    var strm = newStringStream("The first line\nthe second line\nthe third line")
+    var lines: seq[string]
+    for line in strm.lines():
+      lines.add line
+    doAssert lines == @["The first line", "the second line", "the third line"]
+    strm.close()
+
+  var line: string
+  while s.readLine(line):
+    yield line
 
 type
-  PStringStream* = ref TStringStream ## a stream that encapsulates a string
-  TStringStream* = object of TStream
-    data*: string
+  StringStream* = ref StringStreamObj
+    ## A stream that encapsulates a string.
+  StringStreamObj* = object of StreamObj
+    ## A string stream object.
+    data*: string ## A string data.
+                  ## This is updated when called `writeLine` etc.
     pos: int
-    
-proc ssAtEnd(s: PStringStream): bool = 
-  return s.pos >= s.data.len
-    
-proc ssSetPosition(s: PStringStream, pos: int) = 
-  s.pos = min(pos, s.data.len-1)
-
-proc ssGetPosition(s: PStringStream): int =
-  return s.pos
-
-proc ssReadData(s: PStringStream, buffer: pointer, bufLen: int): int =
-  result = min(bufLen, s.data.len - s.pos)
-  if result > 0: 
-    copyMem(buffer, addr(s.data[s.pos]), result)
-    inc(s.pos, result)
-
-proc ssWriteData(s: PStringStream, buffer: pointer, bufLen: int) = 
-  if bufLen > 0: 
-    setLen(s.data, s.data.len + bufLen)
-    copyMem(addr(s.data[s.pos]), buffer, bufLen)
+
+when (NimMajor, NimMinor) < (1, 3) and defined(js):
+  proc ssAtEnd(s: Stream): bool {.compileTime.} =
+    var s = StringStream(s)
+    return s.pos >= s.data.len
+
+  proc ssSetPosition(s: Stream, pos: int) {.compileTime.} =
+    var s = StringStream(s)
+    s.pos = clamp(pos, 0, s.data.len)
+
+  proc ssGetPosition(s: Stream): int {.compileTime.} =
+    var s = StringStream(s)
+    return s.pos
+
+  proc ssReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int {.compileTime.} =
+    var s = StringStream(s)
+    result = min(slice.b + 1 - slice.a, s.data.len - s.pos)
+    if result > 0:
+      buffer[slice.a..<slice.a+result] = s.data[s.pos..<s.pos+result]
+      inc(s.pos, result)
+    else:
+      result = 0
+
+  proc ssClose(s: Stream) {.compileTime.} =
+    var s = StringStream(s)
+    s.data = ""
+
+  proc newStringStream*(s: string = ""): owned StringStream {.compileTime.} =
+    new(result)
+    result.data = s
+    result.pos = 0
+    result.closeImpl = ssClose
+    result.atEndImpl = ssAtEnd
+    result.setPositionImpl = ssSetPosition
+    result.getPositionImpl = ssGetPosition
+    result.readDataStrImpl = ssReadDataStr
+
+  proc readAll*(s: Stream): string {.compileTime.} =
+    const bufferSize = 1024
+    var bufferr: string
+    bufferr.setLen(bufferSize)
+    while true:
+      let readBytes = readDataStr(s, bufferr, 0..<bufferSize)
+      if readBytes == 0:
+        break
+      let prevLen = result.len
+      result.setLen(prevLen + readBytes)
+      result[prevLen..<prevLen+readBytes] = bufferr[0..<readBytes]
+      if readBytes < bufferSize:
+        break
+
+else: # after 1.3 or JS not defined
+  proc ssAtEnd(s: Stream): bool =
+    var s = StringStream(s)
+    return s.pos >= s.data.len
+
+  proc ssSetPosition(s: Stream, pos: int) =
+    var s = StringStream(s)
+    s.pos = clamp(pos, 0, s.data.len)
+
+  proc ssGetPosition(s: Stream): int =
+    var s = StringStream(s)
+    return s.pos
+
+  proc ssReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int =
+    var s = StringStream(s)
+    when nimvm:
+      discard
+    else:
+      when declared(prepareMutation):
+        prepareMutation(buffer) # buffer might potentially be a CoW literal with ARC
+    result = min(slice.b + 1 - slice.a, s.data.len - s.pos)
+    if result > 0:
+      jsOrVmBlock:
+        buffer[slice.a..<slice.a+result] = s.data[s.pos..<s.pos+result]
+      do:
+        copyMem(unsafeAddr buffer[slice.a], addr s.data[s.pos], result)
+      inc(s.pos, result)
+    else:
+      result = 0
+
+  proc ssReadData(s: Stream, buffer: pointer, bufLen: int): int =
+    var s = StringStream(s)
+    result = min(bufLen, s.data.len - s.pos)
+    if result > 0:
+      when defined(js):
+        try:
+          cast[ptr string](buffer)[][0..<result] = s.data[s.pos..<s.pos+result]
+        except:
+          raise newException(Defect, "could not read string stream, " &
+            "did you use a non-string buffer pointer?", getCurrentException())
+      elif not defined(nimscript):
+        copyMem(buffer, addr(s.data[s.pos]), result)
+      inc(s.pos, result)
+    else:
+      result = 0
+
+  proc ssPeekData(s: Stream, buffer: pointer, bufLen: int): int =
+    var s = StringStream(s)
+    result = min(bufLen, s.data.len - s.pos)
+    if result > 0:
+      when defined(js):
+        try:
+          cast[ptr string](buffer)[][0..<result] = s.data[s.pos..<s.pos+result]
+        except:
+          raise newException(Defect, "could not peek string stream, " &
+            "did you use a non-string buffer pointer?", getCurrentException())
+      elif not defined(nimscript):
+        copyMem(buffer, addr(s.data[s.pos]), result)
+    else:
+      result = 0
+
+  proc ssWriteData(s: Stream, buffer: pointer, bufLen: int) =
+    var s = StringStream(s)
+    if bufLen <= 0:
+      return
+    if s.pos + bufLen > s.data.len:
+      setLen(s.data, s.pos + bufLen)
+    when defined(js):
+      try:
+        s.data[s.pos..<s.pos+bufLen] = cast[ptr string](buffer)[][0..<bufLen]
+      except:
+        raise newException(Defect, "could not write to string stream, " &
+          "did you use a non-string buffer pointer?", getCurrentException())
+    elif not defined(nimscript):
+      copyMem(addr(s.data[s.pos]), buffer, bufLen)
     inc(s.pos, bufLen)
 
-proc ssClose(s: PStringStream) =
-  s.data = nil
+  proc ssClose(s: Stream) =
+    var s = StringStream(s)
+    s.data = ""
 
-proc newStringStream*(s: string = ""): PStringStream = 
-  ## creates a new stream from the string `s`.
-  new(result)
-  result.data = s
-  result.pos = 0
-  result.close = ssClose
-  result.atEnd = ssAtEnd
-  result.setPosition = ssSetPosition
-  result.getPosition = ssGetPosition
-  result.readData = ssReadData
-  result.writeData = ssWriteData
+  proc newStringStream*(s: sink string = ""): owned StringStream =
+    ## Creates a new stream from the string `s`.
+    ##
+    ## See also:
+    ## * `newFileStream proc <#newFileStream,File>`_ creates a file stream from
+    ##   opened File.
+    ## * `newFileStream proc <#newFileStream,string,FileMode,int>`_  creates a
+    ##   file stream from the file name and the mode.
+    ## * `openFileStream proc <#openFileStream,string,FileMode,int>`_ creates a
+    ##   file stream from the file name and the mode.
+    runnableExamples:
+      var strm = newStringStream("The first line\nthe second line\nthe third line")
+      doAssert strm.readLine() == "The first line"
+      doAssert strm.readLine() == "the second line"
+      doAssert strm.readLine() == "the third line"
+      strm.close()
+
+    new(result)
+    result.data = s
+    when nimvm:
+      discard
+    else:
+      when declared(prepareMutation):
+        prepareMutation(result.data) # Allows us to mutate using `addr` logic like `copyMem`, otherwise it errors.
+    result.pos = 0
+    result.closeImpl = ssClose
+    result.atEndImpl = ssAtEnd
+    result.setPositionImpl = ssSetPosition
+    result.getPositionImpl = ssGetPosition
+    result.readDataStrImpl = ssReadDataStr
+    when nimvm:
+      discard
+    else:
+      result.readDataImpl = ssReadData
+      result.peekDataImpl = ssPeekData
+      result.writeDataImpl = ssWriteData
 
 type
-  PFileStream* = ref TFileStream ## a stream that encapsulates a `TFile`
-  TFileStream* = object of TStream
-    f: TFile
-
-proc fsClose(s: PFileStream) = close(s.f)
-proc fsAtEnd(s: PFileStream): bool = return EndOfFile(s.f)
-proc fsSetPosition(s: PFileStream, pos: int) = setFilePos(s.f, pos)
-proc fsGetPosition(s: PFileStream): int = return int(getFilePos(s.f))
-
-proc fsReadData(s: PFileStream, buffer: pointer, bufLen: int): int = 
-  result = readBuffer(s.f, buffer, bufLen)
-  
-proc fsWriteData(s: PFileStream, buffer: pointer, bufLen: int) = 
-  if writeBuffer(s.f, buffer, bufLen) != bufLen: 
+  FileStream* = ref FileStreamObj
+    ## A stream that encapsulates a `File`.
+    ##
+    ## **Note:** Not available for JS backend.
+  FileStreamObj* = object of Stream
+    ## A file stream object.
+    ##
+    ## **Note:** Not available for JS backend.
+    f: File
+
+proc fsClose(s: Stream) =
+  if FileStream(s).f != nil:
+    close(FileStream(s).f)
+    FileStream(s).f = nil
+proc fsFlush(s: Stream) = flushFile(FileStream(s).f)
+proc fsAtEnd(s: Stream): bool = return endOfFile(FileStream(s).f)
+proc fsSetPosition(s: Stream, pos: int) = setFilePos(FileStream(s).f, pos)
+proc fsGetPosition(s: Stream): int = return int(getFilePos(FileStream(s).f))
+
+proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int =
+  result = readBuffer(FileStream(s).f, buffer, bufLen)
+
+proc fsReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int =
+  result = readBuffer(FileStream(s).f, addr buffer[slice.a], slice.b + 1 - slice.a)
+
+proc fsPeekData(s: Stream, buffer: pointer, bufLen: int): int =
+  let pos = fsGetPosition(s)
+  defer: fsSetPosition(s, pos)
+  result = readBuffer(FileStream(s).f, buffer, bufLen)
+
+proc fsWriteData(s: Stream, buffer: pointer, bufLen: int) =
+  if writeBuffer(FileStream(s).f, buffer, bufLen) != bufLen:
     raise newEIO("cannot write to stream")
 
-proc newFileStream*(f: TFile): PFileStream = 
-  ## creates a new stream from the file `f`.
+proc fsReadLine(s: Stream, line: var string): bool =
+  result = readLine(FileStream(s).f, line)
+
+proc newFileStream*(f: File): owned FileStream =
+  ## Creates a new stream from the file `f`.
+  ##
+  ## **Note:** Not available for JS backend.
+  ##
+  ## See also:
+  ## * `newStringStream proc <#newStringStream,string>`_ creates a new stream
+  ##   from string.
+  ## * `newFileStream proc <#newFileStream,string,FileMode,int>`_ is the same
+  ##   as using `open proc <syncio.html#open,File,string,FileMode,int>`_
+  ##   on Examples.
+  ## * `openFileStream proc <#openFileStream,string,FileMode,int>`_ creates a
+  ##   file stream from the file name and the mode.
+  runnableExamples:
+    ## Input (somefile.txt):
+    ## The first line
+    ## the second line
+    ## the third line
+    var f: File
+    if open(f, "somefile.txt", fmRead, -1):
+      var strm = newFileStream(f)
+      var line = ""
+      while strm.readLine(line):
+        echo line
+      ## Output:
+      ## The first line
+      ## the second line
+      ## the third line
+      strm.close()
+
   new(result)
   result.f = f
-  result.close = fsClose
-  result.atEnd = fsAtEnd
-  result.setPosition = fsSetPosition
-  result.getPosition = fsGetPosition
-  result.readData = fsReadData
-  result.writeData = fsWriteData
-
-proc newFileStream*(filename: string, mode: TFileMode): PFileStream = 
-  ## creates a new stream from the file named `filename` with the mode `mode`.
-  ## If the file cannot be opened, nil is returned.
-  var f: TFile
-  if Open(f, filename, mode): result = newFileStream(f)
-
-
-when true:
-  nil
-else:
+  result.closeImpl = fsClose
+  result.atEndImpl = fsAtEnd
+  result.setPositionImpl = fsSetPosition
+  result.getPositionImpl = fsGetPosition
+  result.readDataStrImpl = fsReadDataStr
+  result.readDataImpl = fsReadData
+  result.readLineImpl = fsReadLine
+  result.peekDataImpl = fsPeekData
+  result.writeDataImpl = fsWriteData
+  result.flushImpl = fsFlush
+
+proc newFileStream*(filename: string, mode: FileMode = fmRead,
+    bufSize: int = -1): owned FileStream =
+  ## Creates a new stream from the file named `filename` with the mode `mode`.
+  ##
+  ## If the file cannot be opened, `nil` is returned. See the `io module
+  ## <syncio.html>`_ for a list of available `FileMode enums <syncio.html#FileMode>`_.
+  ##
+  ## **Note:**
+  ## * **This function returns nil in case of failure.**
+  ##   To prevent unexpected behavior and ensure proper error handling,
+  ##   use `openFileStream proc <#openFileStream,string,FileMode,int>`_
+  ##   instead.
+  ## * Not available for JS backend.
+  ##
+  ## See also:
+  ## * `newStringStream proc <#newStringStream,string>`_ creates a new stream
+  ##   from string.
+  ## * `newFileStream proc <#newFileStream,File>`_ creates a file stream from
+  ##   opened File.
+  ## * `openFileStream proc <#openFileStream,string,FileMode,int>`_ creates a
+  ##   file stream from the file name and the mode.
+  runnableExamples:
+    from std/os import removeFile
+    var strm = newFileStream("somefile.txt", fmWrite)
+    if not isNil(strm):
+      strm.writeLine("The first line")
+      strm.writeLine("the second line")
+      strm.writeLine("the third line")
+      strm.close()
+      ## Output (somefile.txt)
+      ## The first line
+      ## the second line
+      ## the third line
+      removeFile("somefile.txt")
+
+  var f: File
+  if open(f, filename, mode, bufSize): result = newFileStream(f)
+
+proc openFileStream*(filename: string, mode: FileMode = fmRead,
+    bufSize: int = -1): owned FileStream =
+  ## Creates a new stream from the file named `filename` with the mode `mode`.
+  ## If the file cannot be opened, an IO exception is raised.
+  ##
+  ## **Note:** Not available for JS backend.
+  ##
+  ## See also:
+  ## * `newStringStream proc <#newStringStream,string>`_ creates a new stream
+  ##   from string.
+  ## * `newFileStream proc <#newFileStream,File>`_ creates a file stream from
+  ##   opened File.
+  ## * `newFileStream proc <#newFileStream,string,FileMode,int>`_  creates a
+  ##   file stream from the file name and the mode.
+  runnableExamples:
+    try:
+      ## Input (somefile.txt):
+      ## The first line
+      ## the second line
+      ## the third line
+      var strm = openFileStream("somefile.txt")
+      echo strm.readLine()
+      ## Output:
+      ## The first line
+      strm.close()
+    except:
+      stderr.write getCurrentExceptionMsg()
+
+  var f: File
+  if open(f, filename, mode, bufSize):
+    return newFileStream(f)
+  else:
+    raise newEIO("cannot open file stream: " & filename)
+
+when false:
   type
-    TFileHandle* = cint ## Operating system file handle
-    PFileHandleStream* = ref TFileHandleStream
-    TFileHandleStream* = object of TStream
-      handle*: TFileHandle
+    FileHandleStream* = ref FileHandleStreamObj
+    FileHandleStreamObj* = object of Stream
+      handle*: FileHandle
       pos: int
 
-  proc newEOS(msg: string): ref EOS =
+  proc newEOS(msg: string): ref OSError =
     new(result)
     result.msg = msg
 
-  proc hsGetPosition(s: PFileHandleStream): int = 
+  proc hsGetPosition(s: FileHandleStream): int =
     return s.pos
 
   when defined(windows):
     # do not import windows as this increases compile times:
-    nil
+    discard
   else:
-    import posix
-    
-    proc hsSetPosition(s: PFileHandleStream, pos: int) = 
+    import std/posix
+
+    proc hsSetPosition(s: FileHandleStream, pos: int) =
       discard lseek(s.handle, pos, SEEK_SET)
 
-    proc hsClose(s: PFileHandleStream) = discard close(s.handle)
-    proc hsAtEnd(s: PFileHandleStream): bool = 
+    proc hsClose(s: FileHandleStream) = discard close(s.handle)
+    proc hsAtEnd(s: FileHandleStream): bool =
       var pos = hsGetPosition(s)
       var theEnd = lseek(s.handle, 0, SEEK_END)
       result = pos >= theEnd
       hsSetPosition(s, pos) # set position back
 
-    proc hsReadData(s: PFileHandleStream, buffer: pointer, bufLen: int): int = 
+    proc hsReadData(s: FileHandleStream, buffer: pointer, bufLen: int): int =
       result = posix.read(s.handle, buffer, bufLen)
       inc(s.pos, result)
-      
-    proc hsWriteData(s: PFileHandleStream, buffer: pointer, bufLen: int) = 
-      if posix.write(s.handle, buffer, bufLen) != bufLen: 
+
+    proc hsPeekData(s: FileHandleStream, buffer: pointer, bufLen: int): int =
+      result = posix.read(s.handle, buffer, bufLen)
+
+    proc hsWriteData(s: FileHandleStream, buffer: pointer, bufLen: int) =
+      if posix.write(s.handle, buffer, bufLen) != bufLen:
         raise newEIO("cannot write to stream")
       inc(s.pos, bufLen)
 
-  proc newFileHandleStream*(handle: TFileHandle): PFileHandleStream = 
+  proc newFileHandleStream*(handle: FileHandle): owned FileHandleStream =
     new(result)
     result.handle = handle
     result.pos = 0
@@ -226,20 +1524,22 @@ else:
     result.setPosition = hsSetPosition
     result.getPosition = hsGetPosition
     result.readData = hsReadData
+    result.peekData = hsPeekData
     result.writeData = hsWriteData
 
-  proc newFileHandleStream*(filename: string, 
-                            mode: TFileMode): PFileHandleStream = 
-    when defined(windows): 
-      nil
+  proc newFileHandleStream*(filename: string,
+                            mode: FileMode): owned FileHandleStream =
+    when defined(windows):
+      discard
     else:
       var flags: cint
       case mode
-      of fmRead:              flags = posix.O_RDONLY
-      of fmWrite:             flags = O_WRONLY or int(O_CREAT)
-      of fmReadWrite:         flags = O_RDWR or int(O_CREAT)
+      of fmRead: flags = posix.O_RDONLY
+      of fmWrite: flags = O_WRONLY or int(O_CREAT)
+      of fmReadWrite: flags = O_RDWR or int(O_CREAT)
       of fmReadWriteExisting: flags = O_RDWR
-      of fmAppend:            flags = O_WRONLY or int(O_CREAT) or O_APPEND
+      of fmAppend: flags = O_WRONLY or int(O_CREAT) or O_APPEND
+      static: raiseAssert "unreachable" # handle bug #17888
       var handle = open(filename, flags)
       if handle < 0: raise newEOS("posix.open() call failed")
     result = newFileHandleStream(handle)
diff --git a/lib/pure/streamwrapper.nim b/lib/pure/streamwrapper.nim
new file mode 100644
index 000000000..99752a9ab
--- /dev/null
+++ b/lib/pure/streamwrapper.nim
@@ -0,0 +1,121 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements stream wrapper.
+##
+## **Since** version 1.2.
+
+import std/[deques, streams]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  PipeOutStream*[T] = ref object of T
+    # When stream peek operation is called, it reads from base stream
+    # type using `baseReadDataImpl` and stores the content to this buffer.
+    # Next stream read operation returns data in the buffer so that previus peek
+    # operation looks like didn't changed read positon.
+    # When stream read operation that returns N byte data is called and the size is smaller than buffer size,
+    # first N elements are removed from buffer.
+    # Deque type can do such operation more efficiently than seq type.
+    buffer: Deque[char]
+    baseReadLineImpl: typeof(StreamObj.readLineImpl)
+    baseReadDataImpl: typeof(StreamObj.readDataImpl)
+
+proc posReadLine[T](s: Stream, line: var string): bool =
+  var s = PipeOutStream[T](s)
+  assert s.baseReadLineImpl != nil
+
+  let n = s.buffer.len
+  line.setLen(0)
+  for i in 0..<n:
+    var c = s.buffer.popFirst
+    if c == '\c':
+      c = readChar(s)
+      return true
+    elif c == '\L': return true
+    elif c == '\0':
+      return line.len > 0
+    line.add(c)
+
+  var line2: string
+  result = s.baseReadLineImpl(s, line2)
+  line.add line2
+
+proc posReadData[T](s: Stream, buffer: pointer, bufLen: int): int =
+  var s = PipeOutStream[T](s)
+  assert s.baseReadDataImpl != nil
+
+  let
+    dest = cast[ptr UncheckedArray[char]](buffer)
+    n = min(s.buffer.len, bufLen)
+  result = n
+  for i in 0..<n:
+    dest[i] = s.buffer.popFirst
+  if bufLen > n:
+    result += s.baseReadDataImpl(s, addr dest[n], bufLen - n)
+
+proc posReadDataStr[T](s: Stream, buffer: var string, slice: Slice[int]): int =
+  posReadData[T](s, addr buffer[slice.a], slice.len)
+
+proc posPeekData[T](s: Stream, buffer: pointer, bufLen: int): int =
+  var s = PipeOutStream[T](s)
+  assert s.baseReadDataImpl != nil
+
+  let
+    dest = cast[ptr UncheckedArray[char]](buffer)
+    n = min(s.buffer.len, bufLen)
+
+  result = n
+  for i in 0..<n:
+    dest[i] = s.buffer[i]
+
+  if bufLen > n:
+    let
+      newDataNeeded = bufLen - n
+      numRead = s.baseReadDataImpl(s, addr dest[n], newDataNeeded)
+    result += numRead
+    for i in 0..<numRead:
+      s.buffer.addLast dest[n + i]
+
+proc newPipeOutStream*[T](s: sink (ref T)): owned PipeOutStream[T] =
+  ## Wrap pipe for reading with PipeOutStream so that you can use peek* procs and generate runtime error
+  ## when setPosition/getPosition is called or write operation is performed.
+  ##
+  ## Example:
+  ##   ```Nim
+  ##   import std/[osproc, streamwrapper]
+  ##   var
+  ##     p = startProcess(exePath)
+  ##     outStream = p.outputStream().newPipeOutStream()
+  ##   echo outStream.peekChar
+  ##   p.close()
+  ##   ```
+
+  assert s.readDataImpl != nil
+
+  new(result)
+  for dest, src in fields((ref T)(result)[], s[]):
+    dest = src
+  wasMoved(s[])
+  if result.readLineImpl != nil:
+    result.baseReadLineImpl = result.readLineImpl
+    result.readLineImpl = posReadLine[T]
+  result.baseReadDataImpl = result.readDataImpl
+  result.readDataImpl = posReadData[T]
+  result.readDataStrImpl = posReadDataStr[T]
+  result.peekDataImpl = posPeekData[T]
+
+  # Set nil to anything you may not call.
+  result.setPositionImpl = nil
+  result.getPositionImpl = nil
+  result.writeDataImpl = nil
+  result.flushImpl = nil
diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim
new file mode 100644
index 000000000..7d093ebb3
--- /dev/null
+++ b/lib/pure/strformat.nim
@@ -0,0 +1,790 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+##[
+String `interpolation`:idx: / `format`:idx: inspired by
+Python's f-strings.
+
+# `fmt` vs. `&`
+
+You can use either `fmt` or the unary `&` operator for formatting. The
+difference between them is subtle but important.
+
+The `fmt"{expr}"` syntax is more aesthetically pleasing, but it hides a small
+gotcha. The string is a
+`generalized raw string literal <manual.html#lexical-analysis-generalized-raw-string-literals>`_.
+This has some surprising effects:
+]##
+
+runnableExamples:
+  let msg = "hello"
+  assert fmt"{msg}\n" == "hello\\n"
+
+##[
+Because the literal is a raw string literal, the `\n` is not interpreted as
+an escape sequence.
+
+There are multiple ways to get around this, including the use of the `&` operator:
+]##
+
+runnableExamples:
+  let msg = "hello"
+
+  assert &"{msg}\n" == "hello\n"
+
+  assert fmt"{msg}{'\n'}" == "hello\n"
+  assert fmt("{msg}\n") == "hello\n"
+  assert "{msg}\n".fmt == "hello\n"
+
+##[
+The choice of style is up to you.
+
+# Formatting strings
+]##
+
+runnableExamples:
+  assert &"""{"abc":>4}""" == " abc"
+  assert &"""{"abc":<4}""" == "abc "
+
+##[
+# Formatting floats
+]##
+
+runnableExamples:
+  assert fmt"{-12345:08}" == "-0012345"
+  assert fmt"{-1:3}" == " -1"
+  assert fmt"{-1:03}" == "-01"
+  assert fmt"{16:#X}" == "0x10"
+
+  assert fmt"{123.456}" == "123.456"
+  assert fmt"{123.456:>9.3f}" == "  123.456"
+  assert fmt"{123.456:9.3f}" == "  123.456"
+  assert fmt"{123.456:9.4f}" == " 123.4560"
+  assert fmt"{123.456:>9.0f}" == "     123."
+  assert fmt"{123.456:<9.4f}" == "123.4560 "
+
+  assert fmt"{123.456:e}" == "1.234560e+02"
+  assert fmt"{123.456:>13e}" == " 1.234560e+02"
+  assert fmt"{123.456:13e}" == " 1.234560e+02"
+
+##[
+# Expressions
+]##
+runnableExamples:
+  let x = 3.14
+  assert fmt"{(if x!=0: 1.0/x else: 0):.5}" == "0.31847"
+  assert fmt"""{(block:
+    var res: string
+    for i in 1..15:
+      res.add (if i mod 15 == 0: "FizzBuzz"
+        elif i mod 5 == 0: "Buzz"
+        elif i mod 3 == 0: "Fizz"
+        else: $i) & " "
+    res)}""" == "1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz "
+##[
+# Debugging strings
+
+`fmt"{expr=}"` expands to `fmt"expr={expr}"` namely the text of the expression,
+an equal sign and the results of evaluated expression.
+]##
+
+runnableExamples:
+  assert fmt"{123.456=}" == "123.456=123.456"
+  assert fmt"{123.456=:>9.3f}" == "123.456=  123.456"
+
+  let x = "hello"
+  assert fmt"{x=}" == "x=hello"
+  assert fmt"{x =}" == "x =hello"
+
+  let y = 3.1415926
+  assert fmt"{y=:.2f}" == fmt"y={y:.2f}"
+  assert fmt"{y=}" == fmt"y={y}"
+  assert fmt"{y = : <8}" == fmt"y = 3.14159 "
+
+  proc hello(a: string, b: float): int = 12
+  assert fmt"{hello(x, y) = }" == "hello(x, y) = 12"
+  assert fmt"{x.hello(y) = }" == "x.hello(y) = 12"
+  assert fmt"{hello x, y = }" == "hello x, y = 12"
+
+##[
+Note that it is space sensitive:
+]##
+
+runnableExamples:
+  let x = "12"
+  assert fmt"{x=}" == "x=12"
+  assert fmt"{x =:}" == "x =12"
+  assert fmt"{x =}" == "x =12"
+  assert fmt"{x= :}" == "x= 12"
+  assert fmt"{x= }" == "x= 12"
+  assert fmt"{x = :}" == "x = 12"
+  assert fmt"{x = }" == "x = 12"
+  assert fmt"{x   =  :}" == "x   =  12"
+  assert fmt"{x   =  }" == "x   =  12"
+
+##[
+# Implementation details
+
+An expression like `&"{key} is {value:arg} {{z}}"` is transformed into:
+
+  ```nim
+  var temp = newStringOfCap(educatedCapGuess)
+  temp.formatValue(key, "")
+  temp.add(" is ")
+  temp.formatValue(value, arg)
+  temp.add(" {z}")
+  temp
+  ```
+
+Parts of the string that are enclosed in the curly braces are interpreted
+as Nim code. To escape a `{` or `}`, double it.
+
+Within a curly expression, however, `{`, `}`, must be escaped with a backslash.
+
+To enable evaluating Nim expressions within curlies, colons inside parentheses
+do not need to be escaped.
+]##
+
+runnableExamples:
+  let x = "hello"
+  assert fmt"""{ "\{(" & x & ")\}" }""" == "{(hello)}"
+  assert fmt"""{{({ x })}}""" == "{(hello)}"
+  assert fmt"""{ $(\{x:1,"world":2\}) }""" == """[("hello", 1), ("world", 2)]"""
+
+##[
+`&` delegates most of the work to an open overloaded set
+of `formatValue` procs. The required signature for a type `T` that supports
+formatting is usually `proc formatValue(result: var string; x: T; specifier: string)`.
+
+The subexpression after the colon
+(`arg` in `&"{key} is {value:arg} {{z}}"`) is optional. It will be passed as
+the last argument to `formatValue`. When the colon with the subexpression it is
+left out, an empty string will be taken instead.
+
+For strings and numeric types the optional argument is a so-called
+"standard format specifier".
+
+# Standard format specifiers for strings, integers and floats
+
+The general form of a standard format specifier is:
+
+    [[fill]align][sign][#][0][minimumwidth][.precision][type]
+
+The square brackets `[]` indicate an optional element.
+
+The optional `align` flag can be one of the following:
+
+`<`
+:   Forces the field to be left-aligned within the available
+    space. (This is the default for strings.)
+
+`>`
+:   Forces the field to be right-aligned within the available space.
+    (This is the default for numbers.)
+
+`^`
+:   Forces the field to be centered within the available space.
+
+Note that unless a minimum field width is defined, the field width
+will always be the same size as the data to fill it, so that the alignment
+option has no meaning in this case.
+
+The optional `fill` character defines the character to be used to pad
+the field to the minimum width. The fill character, if present, must be
+followed by an alignment flag.
+
+The `sign` option is only valid for numeric types, and can be one of the following:
+
+=================        ====================================================
+  Sign                   Meaning
+=================        ====================================================
+`+`                      Indicates that a sign should be used for both
+                         positive as well as negative numbers.
+`-`                      Indicates that a sign should be used only for
+                         negative numbers (this is the default behavior).
+(space)                  Indicates that a leading space should be used on
+                         positive numbers.
+=================        ====================================================
+
+If the `#` character is present, integers use the 'alternate form' for formatting.
+This means that binary, octal and hexadecimal output will be prefixed
+with `0b`, `0o` and `0x`, respectively.
+
+`width` is a decimal integer defining the minimum field width. If not specified,
+then the field width will be determined by the content.
+
+If the width field is preceded by a zero (`0`) character, this enables
+zero-padding.
+
+The `precision` is a decimal number indicating how many digits should be displayed
+after the decimal point in a floating point conversion. For non-numeric types the
+field indicates the maximum field size - in other words, how many characters will
+be used from the field content. The precision is ignored for integer conversions.
+
+Finally, the `type` determines how the data should be presented.
+
+The available integer presentation types are:
+
+=================        ====================================================
+  Type                   Result
+=================        ====================================================
+`b`                      Binary. Outputs the number in base 2.
+`d`                      Decimal Integer. Outputs the number in base 10.
+`o`                      Octal format. Outputs the number in base 8.
+`x`                      Hex format. Outputs the number in base 16, using
+                         lower-case letters for the digits above 9.
+`X`                      Hex format. Outputs the number in base 16, using
+                         uppercase letters for the digits above 9.
+(None)                   The same as `d`.
+=================        ====================================================
+
+The available floating point presentation types are:
+
+=================        ====================================================
+  Type                   Result
+=================        ====================================================
+`e`                      Exponent notation. Prints the number in scientific
+                         notation using the letter `e` to indicate the
+                         exponent.
+`E`                      Exponent notation. Same as `e` except it converts
+                         the number to uppercase.
+`f`                      Fixed point. Displays the number as a fixed-point
+                         number.
+`F`                      Fixed point. Same as `f` except it converts the
+                         number to uppercase.
+`g`                      General format. This prints the number as a
+                         fixed-point number, unless the number is too
+                         large, in which case it switches to `e`
+                         exponent notation.
+`G`                      General format. Same as `g` except it switches to `E`
+                         if the number gets to large.
+`i`                      Complex General format. This is only supported for
+                         complex numbers, which it prints using the mathematical
+                         (RE+IMj) format. The real and imaginary parts are printed
+                         using the general format `g` by default, but it is
+                         possible to combine this format with one of the other
+                         formats (e.g `jf`).
+(None)                   Similar to `g`, except that it prints at least one
+                         digit after the decimal point.
+=================        ====================================================
+
+# Limitations
+
+Because of the well defined order how templates and macros are
+expanded, strformat cannot expand template arguments:
+
+  ```nim
+  template myTemplate(arg: untyped): untyped =
+    echo "arg is: ", arg
+    echo &"--- {arg} ---"
+
+  let x = "abc"
+  myTemplate(x)
+  ```
+
+First the template `myTemplate` is expanded, where every identifier
+`arg` is substituted with its argument. The `arg` inside the
+format string is not seen by this process, because it is part of a
+quoted string literal. It is not an identifier yet. Then the strformat
+macro creates the `arg` identifier from the string literal, an
+identifier that cannot be resolved anymore.
+
+The workaround for this is to bind the template argument to a new local variable.
+
+  ```nim
+  template myTemplate(arg: untyped): untyped =
+    block:
+      let arg1 {.inject.} = arg
+      echo "arg is: ", arg1
+      echo &"--- {arg1} ---"
+  ```
+
+The use of `{.inject.}` here is necessary again because of template
+expansion order and hygienic templates. But since we generally want to
+keep the hygiene of `myTemplate`, and we do not want `arg1`
+to be injected into the context where `myTemplate` is expanded,
+everything is wrapped in a `block`.
+
+
+# Future directions
+
+A curly expression with commas in it like `{x, argA, argB}` could be
+transformed to `formatValue(result, x, argA, argB)` in order to support
+formatters that do not need to parse a custom language within a custom
+language but instead prefer to use Nim's existing syntax. This would also
+help with readability, since there is only so much you can cram into
+single letter DSLs.
+]##
+
+import std/[macros, parseutils, unicode]
+import std/strutils except format
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+proc mkDigit(v: int, typ: char): string {.inline.} =
+  assert(v < 26)
+  if v < 10:
+    result = $chr(ord('0') + v)
+  else:
+    result = $chr(ord(if typ == 'x': 'a' else: 'A') + v - 10)
+
+proc alignString*(s: string, minimumWidth: int; align = '\0'; fill = ' '): string =
+  ## Aligns `s` using the `fill` char.
+  ## This is only of interest if you want to write a custom `format` proc that
+  ## should support the standard format specifiers.
+  if minimumWidth == 0:
+    result = s
+  else:
+    let sRuneLen = if s.validateUtf8 == -1: s.runeLen else: s.len
+    let toFill = minimumWidth - sRuneLen
+    if toFill <= 0:
+      result = s
+    elif align == '<' or align == '\0':
+      result = s & repeat(fill, toFill)
+    elif align == '^':
+      let half = toFill div 2
+      result = repeat(fill, half) & s & repeat(fill, toFill - half)
+    else:
+      result = repeat(fill, toFill) & s
+
+type
+  StandardFormatSpecifier* = object ## Type that describes "standard format specifiers".
+    fill*, align*: char            ## Desired fill and alignment.
+    sign*: char                    ## Desired sign.
+    alternateForm*: bool           ## Whether to prefix binary, octal and hex numbers
+                                   ## with `0b`, `0o`, `0x`.
+    padWithZero*: bool             ## Whether to pad with zeros rather than spaces.
+    minimumWidth*, precision*: int ## Desired minimum width and precision.
+    typ*: char                     ## Type like 'f', 'g' or 'd'.
+    endPosition*: int              ## End position in the format specifier after
+                                   ## `parseStandardFormatSpecifier` returned.
+
+proc formatInt(n: SomeNumber; radix: int; spec: StandardFormatSpecifier): string =
+  ## Converts `n` to a string. If `n` is `SomeFloat`, it casts to `int64`.
+  ## Conversion is done using `radix`. If result's length is less than
+  ## `minimumWidth`, it aligns result to the right or left (depending on `a`)
+  ## with the `fill` char.
+  when n is SomeUnsignedInt:
+    var v = n.uint64
+    let negative = false
+  else:
+    let n = n.int64
+    let negative = n < 0
+    var v =
+      if negative:
+        # `uint64(-n)`, but accounts for `n == low(int64)`
+        uint64(not n) + 1
+      else:
+        uint64(n)
+
+  var xx = ""
+  if spec.alternateForm:
+    case spec.typ
+    of 'X': xx = "0x"
+    of 'x': xx = "0x"
+    of 'b': xx = "0b"
+    of 'o': xx = "0o"
+    else: discard
+
+  if v == 0:
+    result = "0"
+  else:
+    result = ""
+    while v > typeof(v)(0):
+      let d = v mod typeof(v)(radix)
+      v = v div typeof(v)(radix)
+      result.add(mkDigit(d.int, spec.typ))
+    for idx in 0..<(result.len div 2):
+      swap result[idx], result[result.len - idx - 1]
+  if spec.padWithZero:
+    let sign = negative or spec.sign != '-'
+    let toFill = spec.minimumWidth - result.len - xx.len - ord(sign)
+    if toFill > 0:
+      result = repeat('0', toFill) & result
+
+  if negative:
+    result = "-" & xx & result
+  elif spec.sign != '-':
+    result = spec.sign & xx & result
+  else:
+    result = xx & result
+
+  if spec.align == '<':
+    for i in result.len..<spec.minimumWidth:
+      result.add(spec.fill)
+  else:
+    let toFill = spec.minimumWidth - result.len
+    if spec.align == '^':
+      let half = toFill div 2
+      result = repeat(spec.fill, half) & result & repeat(spec.fill, toFill - half)
+    else:
+      if toFill > 0:
+        result = repeat(spec.fill, toFill) & result
+
+proc parseStandardFormatSpecifier*(s: string; start = 0;
+                                   ignoreUnknownSuffix = false): StandardFormatSpecifier =
+  ## An exported helper proc that parses the "standard format specifiers",
+  ## as specified by the grammar:
+  ##
+  ##     [[fill]align][sign][#][0][minimumwidth][.precision][type]
+  ##
+  ## This is only of interest if you want to write a custom `format` proc that
+  ## should support the standard format specifiers. If `ignoreUnknownSuffix` is true,
+  ## an unknown suffix after the `type` field is not an error.
+  const alignChars = {'<', '>', '^'}
+  result.fill = ' '
+  result.align = '\0'
+  result.sign = '-'
+  var i = start
+  if i + 1 < s.len and s[i+1] in alignChars:
+    result.fill = s[i]
+    result.align = s[i+1]
+    inc i, 2
+  elif i < s.len and s[i] in alignChars:
+    result.align = s[i]
+    inc i
+
+  if i < s.len and s[i] in {'-', '+', ' '}:
+    result.sign = s[i]
+    inc i
+
+  if i < s.len and s[i] == '#':
+    result.alternateForm = true
+    inc i
+
+  if i + 1 < s.len and s[i] == '0' and s[i+1] in {'0'..'9'}:
+    result.padWithZero = true
+    inc i
+
+  let parsedLength = parseSaturatedNatural(s, result.minimumWidth, i)
+  inc i, parsedLength
+  if i < s.len and s[i] == '.':
+    inc i
+    let parsedLengthB = parseSaturatedNatural(s, result.precision, i)
+    inc i, parsedLengthB
+  else:
+    result.precision = -1
+
+  if i < s.len and s[i] in {'A'..'Z', 'a'..'z'}:
+    result.typ = s[i]
+    inc i
+  result.endPosition = i
+  if i != s.len and not ignoreUnknownSuffix:
+    raise newException(ValueError,
+      "invalid format string, cannot parse: " & s[i..^1])
+
+proc toRadix(typ: char): int =
+  case typ
+  of 'x', 'X': 16
+  of 'd', '\0': 10
+  of 'o': 8
+  of 'b': 2
+  else:
+    raise newException(ValueError,
+      "invalid type in format string for number, expected one " &
+      " of 'x', 'X', 'b', 'd', 'o' but got: " & typ)
+
+proc formatValue*[T: SomeInteger](result: var string; value: T;
+                                  specifier: static string) =
+  ## Standard format implementation for `SomeInteger`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  when specifier.len == 0:
+    result.add $value
+  else:
+    const
+      spec = parseStandardFormatSpecifier(specifier)
+      radix = toRadix(spec.typ)
+
+    result.add formatInt(value, radix, spec)
+
+proc formatValue*[T: SomeInteger](result: var string; value: T;
+                                  specifier: string) =
+  ## Standard format implementation for `SomeInteger`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  if specifier.len == 0:
+    result.add $value
+  else:
+    let
+      spec = parseStandardFormatSpecifier(specifier)
+      radix = toRadix(spec.typ)
+
+    result.add formatInt(value, radix, spec)
+
+proc formatFloat(
+    result: var string, value: SomeFloat, fmode: FloatFormatMode,
+    spec: StandardFormatSpecifier) =
+  var f = formatBiggestFloat(value, fmode, spec.precision)
+  var sign = false
+  if value >= 0.0:
+    if spec.sign != '-':
+      sign = true
+      if value == 0.0:
+        if 1.0 / value == Inf:
+          # only insert the sign if value != negZero
+          f.insert($spec.sign, 0)
+      else:
+        f.insert($spec.sign, 0)
+  else:
+    sign = true
+
+  if spec.padWithZero:
+    var signStr = ""
+    if sign:
+      signStr = $f[0]
+      f = f[1..^1]
+
+    let toFill = spec.minimumWidth - f.len - ord(sign)
+    if toFill > 0:
+      f = repeat('0', toFill) & f
+    if sign:
+      f = signStr & f
+
+  # the default for numbers is right-alignment:
+  let align = if spec.align == '\0': '>' else: spec.align
+  let res = alignString(f, spec.minimumWidth, align, spec.fill)
+  if spec.typ in {'A'..'Z'}:
+    result.add toUpperAscii(res)
+  else:
+    result.add res
+
+proc toFloatFormatMode(typ: char): FloatFormatMode =
+  case typ
+  of 'e', 'E': ffScientific
+  of 'f', 'F': ffDecimal
+  of 'g', 'G': ffDefault
+  of '\0': ffDefault
+  else:
+    raise newException(ValueError,
+      "invalid type in format string for number, expected one " &
+      " of 'e', 'E', 'f', 'F', 'g', 'G' but got: " & typ)
+
+proc formatValue*(result: var string; value: SomeFloat; specifier: static string) =
+  ## Standard format implementation for `SomeFloat`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  when specifier.len == 0:
+    result.add $value
+  else:
+    const
+      spec = parseStandardFormatSpecifier(specifier)
+      fmode = toFloatFormatMode(spec.typ)
+
+    formatFloat(result, value, fmode, spec)
+
+proc formatValue*(result: var string; value: SomeFloat; specifier: string) =
+  ## Standard format implementation for `SomeFloat`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  if specifier.len == 0:
+    result.add $value
+  else:
+    let
+      spec = parseStandardFormatSpecifier(specifier)
+      fmode = toFloatFormatMode(spec.typ)
+
+    formatFloat(result, value, fmode, spec)
+
+proc formatValue*(result: var string; value: string; specifier: static string) =
+  ## Standard format implementation for `string`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  const spec = parseStandardFormatSpecifier(specifier)
+  var value =
+    when spec.typ in {'s', '\0'}: value
+    else: static:
+      raise newException(ValueError,
+        "invalid type in format string for string, expected 's', but got " &
+        spec.typ)
+  when spec.precision != -1:
+    if spec.precision < runeLen(value):
+      const precision = cast[Natural](spec.precision)
+      setLen(value, Natural(runeOffset(value, precision)))
+
+  result.add alignString(value, spec.minimumWidth, spec.align, spec.fill)
+
+proc formatValue*(result: var string; value: string; specifier: string) =
+  ## Standard format implementation for `string`. It makes little
+  ## sense to call this directly, but it is required to exist
+  ## by the `&` macro.
+  let spec = parseStandardFormatSpecifier(specifier)
+  var value =
+    if spec.typ in {'s', '\0'}: value
+    else:
+      raise newException(ValueError,
+        "invalid type in format string for string, expected 's', but got " &
+        spec.typ)
+  if spec.precision != -1:
+    if spec.precision < runeLen(value):
+      let precision = cast[Natural](spec.precision)
+      setLen(value, Natural(runeOffset(value, precision)))
+
+  result.add alignString(value, spec.minimumWidth, spec.align, spec.fill)
+
+proc formatValue[T: not SomeInteger](result: var string; value: T; specifier: static string) =
+  mixin `$`
+  formatValue(result, $value, specifier)
+
+proc formatValue[T: not SomeInteger](result: var string; value: T; specifier: string) =
+  mixin `$`
+  formatValue(result, $value, specifier)
+
+template formatValue(result: var string; value: char; specifier: string) =
+  result.add value
+
+template formatValue(result: var string; value: cstring; specifier: string) =
+  result.add value
+
+proc strformatImpl(f: string; openChar, closeChar: char,
+                   lineInfoNode: NimNode = nil): NimNode =
+  template missingCloseChar =
+    error("invalid format string: missing closing character '" & closeChar & "'")
+
+  if openChar == ':' or closeChar == ':':
+    error "openChar and closeChar must not be ':'"
+  var i = 0
+  let res = genSym(nskVar, "fmtRes")
+  result = newNimNode(nnkStmtListExpr, lineInfoNode)
+  # XXX: https://github.com/nim-lang/Nim/issues/8405
+  # When compiling with -d:useNimRtl, certain procs such as `count` from the strutils
+  # module are not accessible at compile-time:
+  let expectedGrowth = when defined(useNimRtl): 0 else: count(f, openChar) * 10
+  result.add newVarStmt(res, newCall(bindSym"newStringOfCap",
+                                     newLit(f.len + expectedGrowth)))
+  var strlit = ""
+  while i < f.len:
+    if f[i] == openChar:
+      inc i
+      if f[i] == openChar:
+        inc i
+        strlit.add openChar
+      else:
+        if strlit.len > 0:
+          result.add newCall(bindSym"add", res, newLit(strlit))
+          strlit = ""
+
+        var subexpr = ""
+        var inParens = 0
+        var inSingleQuotes = false
+        var inDoubleQuotes = false
+        template notEscaped:bool = f[i-1]!='\\'
+        while i < f.len and f[i] != closeChar and (f[i] != ':' or inParens != 0):
+          case f[i]
+          of '\\':
+            if i < f.len-1 and f[i+1] in {openChar,closeChar,':'}: inc i
+          of '\'':
+            if not inDoubleQuotes and notEscaped: inSingleQuotes = not inSingleQuotes
+          of '\"':
+            if notEscaped: inDoubleQuotes = not inDoubleQuotes
+          of '(':
+            if not (inSingleQuotes or inDoubleQuotes): inc inParens
+          of ')':
+            if not (inSingleQuotes or inDoubleQuotes): dec inParens
+          of '=':
+            let start = i
+            inc i
+            i += f.skipWhitespace(i)
+            if i == f.len:
+              missingCloseChar
+            if f[i] == closeChar or f[i] == ':':
+              result.add newCall(bindSym"add", res, newLit(subexpr & f[start ..< i]))
+            else:
+              subexpr.add f[start ..< i]
+            continue
+          else: discard
+          subexpr.add f[i]
+          inc i
+
+        if i == f.len:
+          missingCloseChar
+
+        var x: NimNode
+        try:
+          x = parseExpr(subexpr)
+        except ValueError as e:
+          error("could not parse `$#` in `$#`.\n$#" % [subexpr, f, e.msg])
+        x.copyLineInfo(lineInfoNode)
+        let formatSym = bindSym("formatValue", brOpen)
+        var options = ""
+        if f[i] == ':':
+          inc i
+          while i < f.len and f[i] != closeChar:
+            options.add f[i]
+            inc i
+        if i == f.len:
+          missingCloseChar
+        if f[i] == closeChar:
+          inc i
+        result.add newCall(formatSym, res, x, newLit(options))
+    elif f[i] == closeChar:
+      if i<f.len-1 and f[i+1] == closeChar:
+        strlit.add closeChar
+        inc i, 2
+      else:
+        raiseAssert "invalid format string: '$1' instead of '$1$1'" % $closeChar
+    else:
+      strlit.add f[i]
+      inc i
+  if strlit.len > 0:
+    result.add newCall(bindSym"add", res, newLit(strlit))
+  result.add res
+  # workaround for #20381
+  var blockExpr = newNimNode(nnkBlockExpr, lineInfoNode)
+  blockExpr.add(newEmptyNode())
+  blockExpr.add(result)
+  result = blockExpr
+  when defined(debugFmtDsl):
+    echo repr result
+
+macro fmt(pattern: static string; openChar: static char, closeChar: static char, lineInfoNode: untyped): string =
+  ## version of `fmt` with dummy untyped param for line info
+  strformatImpl(pattern, openChar, closeChar, lineInfoNode)
+
+when not defined(nimHasCallsitePragma):
+  {.pragma: callsite.}
+
+template fmt*(pattern: static string; openChar: static char, closeChar: static char): string {.callsite.} =
+  ## Interpolates `pattern` using symbols in scope.
+  runnableExamples:
+    let x = 7
+    assert "var is {x * 2}".fmt == "var is 14"
+    assert "var is {{x}}".fmt == "var is {x}" # escape via doubling
+    const s = "foo: {x}"
+    assert s.fmt == "foo: 7" # also works with const strings
+
+    assert fmt"\n" == r"\n" # raw string literal
+    assert "\n".fmt == "\n" # regular literal (likewise with `fmt("\n")` or `fmt "\n"`)
+  runnableExamples:
+    # custom `openChar`, `closeChar`
+    let x = 7
+    assert "<x>".fmt('<', '>') == "7"
+    assert "<<<x>>>".fmt('<', '>') == "<7>"
+    assert "`x`".fmt('`', '`') == "7"
+  fmt(pattern, openChar, closeChar, dummyForLineInfo)
+
+template fmt*(pattern: static string): untyped {.callsite.} =
+  ## Alias for `fmt(pattern, '{', '}')`.
+  fmt(pattern, '{', '}', dummyForLineInfo)
+
+template `&`*(pattern: string{lit}): string {.callsite.} =
+  ## `&pattern` is the same as `pattern.fmt`.
+  ## For a specification of the `&` macro, see the module level documentation.
+  # pending bug #18275, bug #18278, use `pattern: static string`
+  # consider deprecating this, it's redundant with `fmt` and `fmt` is strictly
+  # more flexible, readable (no confusion with the binary `&`), self-documenting,
+  # not to mention #18275, bug #18278.
+  runnableExamples:
+    let x = 7
+    assert &"{x}\n" == "7\n" # regular string literal
+    assert &"{x}\n" == "{x}\n".fmt # `fmt` can be used instead
+    assert &"{x}\n" != fmt"{x}\n" # see `fmt` docs, this would use a raw string literal
+  fmt(pattern, '{', '}', dummyForLineInfo)
diff --git a/lib/pure/strmisc.nim b/lib/pure/strmisc.nim
new file mode 100644
index 000000000..a3e539e7e
--- /dev/null
+++ b/lib/pure/strmisc.nim
@@ -0,0 +1,83 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Joey Payne
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains various string utility routines that are uncommonly
+## used in comparison to the ones in `strutils <strutils.html>`_.
+
+import std/strutils
+
+func expandTabs*(s: string, tabSize: int = 8): string =
+  ## Expands tab characters in `s`, replacing them by spaces.
+  ##
+  ## The amount of inserted spaces for each tab character is the difference
+  ## between the current column number and the next tab position. Tab positions
+  ## occur every `tabSize` characters.
+  ## The column number starts at 0 and is increased with every single character
+  ## and inserted space, except for newline, which resets the column number
+  ## back to 0.
+  runnableExamples:
+    doAssert expandTabs("\t", 4) == "    "
+    doAssert expandTabs("\tfoo\t", 4) == "    foo "
+    doAssert expandTabs("a\tb\n\txy\t", 3) == "a  b\n   xy "
+
+  result = newStringOfCap(s.len + s.len shr 2)
+
+  template addSpaces(n) =
+    for _ in 1..n:
+      result.add(' ')
+    pos += n
+
+  var pos = 0
+  let denominator = if tabSize > 0: tabSize else: 1
+  for c in s:
+    if c == '\t':
+      let numSpaces = tabSize - pos mod denominator
+      addSpaces(numSpaces)
+    else:
+      result.add(c)
+      pos += 1
+    if c == '\l':
+      pos = 0
+
+func partition*(s: string, sep: string,
+                right: bool = false): (string, string, string) =
+  ## Splits the string at the first (if `right` is false)
+  ## or last (if `right` is true) occurrence of `sep` into a 3-tuple.
+  ##
+  ## Returns a 3-tuple of strings, `(beforeSep, sep, afterSep)` or
+  ## `(s, "", "")` if `sep` is not found and `right` is false or
+  ## `("", "", s)` if `sep` is not found and `right` is true.
+  ##
+  ## **See also:**
+  ## * `rpartition proc <#rpartition,string,string>`_
+  runnableExamples:
+    doAssert partition("foo:bar:baz", ":") == ("foo", ":", "bar:baz")
+    doAssert partition("foo:bar:baz", ":", right = true) == ("foo:bar", ":", "baz")
+    doAssert partition("foobar", ":") == ("foobar", "", "")
+    doAssert partition("foobar", ":", right = true) == ("", "", "foobar")
+
+  let position = if right: s.rfind(sep) else: s.find(sep)
+  if position != -1:
+    return (s[0 ..< position], sep, s[position + sep.len ..< s.len])
+  return if right: ("", "", s) else: (s, "", "")
+
+func rpartition*(s: string, sep: string): (string, string, string) =
+  ## Splits the string at the last occurrence of `sep` into a 3-tuple.
+  ##
+  ## Returns a 3-tuple of strings, `(beforeSep, sep, afterSep)` or
+  ## `("", "", s)` if `sep` is not found. This is the same as
+  ## `partition(s, sep, right = true)`.
+  ##
+  ## **See also:**
+  ## * `partition proc <#partition,string,string,bool>`_
+  runnableExamples:
+    doAssert rpartition("foo:bar:baz", ":") == ("foo:bar", ":", "baz")
+    doAssert rpartition("foobar", ":") == ("", "", "foobar")
+
+  partition(s, sep, right = true)
diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim
new file mode 100644
index 000000000..16ef9e642
--- /dev/null
+++ b/lib/pure/strscans.nim
@@ -0,0 +1,696 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+##[
+This module contains a `scanf`:idx: macro that can be used for extracting
+substrings from an input string. This is often easier than regular expressions.
+Some examples as an appetizer:
+
+  ```nim
+  # check if input string matches a triple of integers:
+  const input = "(1,2,4)"
+  var x, y, z: int
+  if scanf(input, "($i,$i,$i)", x, y, z):
+    echo "matches and x is ", x, " y is ", y, " z is ", z
+
+  # check if input string matches an ISO date followed by an identifier followed
+  # by whitespace and a floating point number:
+  var year, month, day: int
+  var identifier: string
+  var myfloat: float
+  if scanf(input, "$i-$i-$i $w$s$f", year, month, day, identifier, myfloat):
+    echo "yes, we have a match!"
+  ```
+
+As can be seen from the examples, strings are matched verbatim except for
+substrings starting with ``$``. These constructions are available:
+
+=================   ========================================================
+``$b``              Matches a binary integer. This uses ``parseutils.parseBin``.
+``$o``              Matches an octal integer. This uses ``parseutils.parseOct``.
+``$i``              Matches a decimal integer. This uses ``parseutils.parseInt``.
+``$h``              Matches a hex integer. This uses ``parseutils.parseHex``.
+``$f``              Matches a floating-point number. Uses ``parseFloat``.
+``$w``              Matches an ASCII identifier: ``[A-Za-z_][A-Za-z_0-9]*``.
+``$c``              Matches a single ASCII character.
+``$s``              Skips optional whitespace.
+``$$``              Matches a single dollar sign.
+``$.``              Matches if the end of the input string has been reached.
+``$*``              Matches until the token following the ``$*`` was found.
+                    The match is allowed to be of 0 length.
+``$+``              Matches until the token following the ``$+`` was found.
+                    The match must consist of at least one char.
+``${foo}``          User defined matcher. Uses the proc ``foo`` to perform
+                    the match. See below for more details.
+``$[foo]``          Call user defined proc ``foo`` to **skip** some optional
+                    parts in the input string. See below for more details.
+=================   ========================================================
+
+Even though ``$*`` and ``$+`` look similar to the regular expressions ``.*``
+and ``.+``, they work quite differently. There is no non-deterministic
+state machine involved and the matches are non-greedy. ``[$*]``
+matches ``[xyz]`` via ``parseutils.parseUntil``.
+
+Furthermore no backtracking is performed, if parsing fails after a value
+has already been bound to a matched subexpression this value is not restored
+to its original value. This rarely causes problems in practice and if it does
+for you, it's easy enough to bind to a temporary variable first.
+
+
+Startswith vs full match
+========================
+
+``scanf`` returns true if the input string **starts with** the specified
+pattern. If instead it should only return true if there is also nothing
+left in the input, append ``$.`` to your pattern.
+
+
+User definable matchers
+=======================
+
+One very nice advantage over regular expressions is that ``scanf`` is
+extensible with ordinary Nim procs. The proc is either enclosed in ``${}``
+or in ``$[]``. ``${}`` matches and binds the result
+to a variable (that was passed to the ``scanf`` macro) while ``$[]`` merely
+matches optional tokens without any result binding.
+
+
+In this example, we define a helper proc ``someSep`` that skips some separators
+which we then use in our scanf pattern to help us in the matching process:
+
+  ```nim
+  proc someSep(input: string; start: int; seps: set[char] = {':','-','.'}): int =
+    # Note: The parameters and return value must match to what ``scanf`` requires
+    result = 0
+    while start+result < input.len and input[start+result] in seps: inc result
+
+  if scanf(input, "$w$[someSep]$w", key, value):
+    ...
+  ```
+
+It is also possible to pass arguments to a user definable matcher:
+
+  ```nim
+  proc ndigits(input: string; intVal: var int; start: int; n: int): int =
+    # matches exactly ``n`` digits. Matchers need to return 0 if nothing
+    # matched or otherwise the number of processed chars.
+    var x = 0
+    var i = 0
+    while i < n and i+start < input.len and input[i+start] in {'0'..'9'}:
+      x = x * 10 + input[i+start].ord - '0'.ord
+      inc i
+    # only overwrite if we had a match
+    if i == n:
+      result = n
+      intVal = x
+
+  # match an ISO date extracting year, month, day at the same time.
+  # Also ensure the input ends after the ISO date:
+  var year, month, day: int
+  if scanf("2013-01-03", "${ndigits(4)}-${ndigits(2)}-${ndigits(2)}$.", year, month, day):
+    ...
+  ```
+
+
+The scanp macro
+===============
+
+This module also implements a ``scanp`` macro, which syntax somewhat resembles
+an EBNF or PEG grammar, except that it uses Nim's expression syntax and so has
+to use prefix instead of postfix operators.
+
+==============   ===============================================================
+``(E)``          Grouping
+``*E``           Zero or more
+``+E``           One or more
+``?E``           Zero or One
+``E{n,m}``       From ``n`` up to ``m`` times ``E``
+``~E``           Not predicate
+``a ^* b``       Shortcut for ``?(a *(b a))``. Usually used for separators.
+``a ^+ b``       Shortcut for ``?(a +(b a))``. Usually used for separators.
+``'a'``          Matches a single character
+``{'a'..'b'}``   Matches a character set
+``"s"``          Matches a string
+``E -> a``       Bind matching to some action
+``$_``           Access the currently matched character
+==============   ===============================================================
+
+Note that unordered or ordered choice operators (``/``, ``|``) are
+not implemented.
+
+Simple example that parses the ``/etc/passwd`` file line by line:
+
+  ```nim
+  const
+    etc_passwd = """root:x:0:0:root:/root:/bin/bash
+  daemon:x:1:1:daemon:/usr/sbin:/bin/sh
+  bin:x:2:2:bin:/bin:/bin/sh
+  sys:x:3:3:sys:/dev:/bin/sh
+  nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+  messagebus:x:103:107::/var/run/dbus:/bin/false
+  """
+
+  proc parsePasswd(content: string): seq[string] =
+    result = @[]
+    var idx = 0
+    while true:
+      var entry = ""
+      if scanp(content, idx, +(~{'\L', '\0'} -> entry.add($_)), '\L'):
+        result.add entry
+      else:
+        break
+  ```
+
+The ``scanp`` maps the grammar code into Nim code that performs the parsing.
+The parsing is performed with the help of 3 helper templates that that can be
+implemented for a custom type.
+
+These templates need to be named ``atom`` and ``nxt``. ``atom`` should be
+overloaded to handle both `char` and `set[char]`.
+
+  ```nim
+  import std/streams
+
+  template atom(input: Stream; idx: int; c: char): bool =
+    ## Used in scanp for the matching of atoms (usually chars).
+    peekChar(input) == c
+
+  template atom(input: Stream; idx: int; s: set[char]): bool =
+    peekChar(input) in s
+
+  template nxt(input: Stream; idx, step: int = 1) =
+    inc(idx, step)
+    setPosition(input, idx)
+
+  if scanp(content, idx, +( ~{'\L', '\0'} -> entry.add(peekChar($input))), '\L'):
+    result.add entry
+  ```
+
+Calling ordinary Nim procs inside the macro is possible:
+
+  ```nim
+  proc digits(s: string; intVal: var int; start: int): int =
+    var x = 0
+    while result+start < s.len and s[result+start] in {'0'..'9'} and s[result+start] != ':':
+      x = x * 10 + s[result+start].ord - '0'.ord
+      inc result
+    intVal = x
+
+  proc extractUsers(content: string): seq[string] =
+    # Extracts the username and home directory
+    # of each entry (with UID greater than 1000)
+    const
+      digits = {'0'..'9'}
+    result = @[]
+    var idx = 0
+    while true:
+      var login = ""
+      var uid = 0
+      var homedir = ""
+      if scanp(content, idx, *(~ {':', '\0'}) -> login.add($_), ':', * ~ ':', ':',
+              digits($input, uid, $index), ':', *`digits`, ':', * ~ ':', ':',
+              *('/', * ~{':', '/'}) -> homedir.add($_), ':', *('/', * ~{'\L', '/'}), '\L'):
+        if uid >= 1000:
+          result.add login & " " & homedir
+      else:
+        break
+  ```
+
+When used for matching, keep in mind that likewise scanf, no backtracking
+is performed.
+
+  ```nim
+  proc skipUntil(s: string; until: string; unless = '\0'; start: int): int =
+    # Skips all characters until the string `until` is found. Returns 0
+    # if the char `unless` is found first or the end is reached.
+    var i = start
+    var u = 0
+    while true:
+      if i >= s.len or s[i] == unless:
+        return 0
+      elif s[i] == until[0]:
+        u = 1
+        while i+u < s.len and u < until.len and s[i+u] == until[u]:
+          inc u
+        if u >= until.len: break
+      inc(i)
+    result = i+u-start
+
+  iterator collectLinks(s: string): string =
+    const quote = {'\'', '"'}
+    var idx, old = 0
+    var res = ""
+    while idx < s.len:
+      old = idx
+      if scanp(s, idx, "<a", skipUntil($input, "href=", '>', $index),
+              `quote`, *( ~`quote`) -> res.add($_)):
+        yield res
+        res = ""
+      idx = old + 1
+
+  for r in collectLinks(body):
+    echo r
+  ```
+
+In this example both macros are combined seamlessly in order to maximise
+efficiency and perform different checks.
+
+  ```nim
+  iterator parseIps*(soup: string): string =
+    ## ipv4 only!
+    const digits = {'0'..'9'}
+    var a, b, c, d: int
+    var buf = ""
+    var idx = 0
+    while idx < soup.len:
+      if scanp(soup, idx, (`digits`{1,3}, '.', `digits`{1,3}, '.',
+               `digits`{1,3}, '.', `digits`{1,3}) -> buf.add($_)):
+        discard buf.scanf("$i.$i.$i.$i", a, b, c, d)
+        if (a >= 0 and a <= 254) and
+           (b >= 0 and b <= 254) and
+           (c >= 0 and c <= 254) and
+           (d >= 0 and d <= 254):
+          yield buf
+      buf.setLen(0) # need to clear `buf` each time, cause it might contain garbage
+      idx.inc
+  ```
+]##
+
+
+import std/[macros, parseutils]
+import std/private/since
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+proc conditionsToIfChain(n, idx, res: NimNode; start: int): NimNode =
+  assert n.kind == nnkStmtList
+  if start >= n.len: return newAssignment(res, newLit true)
+  var ifs: NimNode = nil
+  if n[start+1].kind == nnkEmpty:
+    ifs = conditionsToIfChain(n, idx, res, start+3)
+  else:
+    ifs = newIfStmt((n[start+1],
+                    newTree(nnkStmtList, newCall(bindSym"inc", idx, n[start+2]),
+                                     conditionsToIfChain(n, idx, res, start+3))))
+  result = newTree(nnkStmtList, n[start], ifs)
+
+proc notZero(x: NimNode): NimNode = newCall(bindSym"!=", x, newLit 0)
+
+proc buildUserCall(x: string; args: varargs[NimNode]): NimNode =
+  let y = parseExpr(x)
+  result = newTree(nnkCall)
+  if y.kind in nnkCallKinds: result.add y[0]
+  else: result.add y
+  for a in args: result.add a
+  if y.kind in nnkCallKinds:
+    for i in 1..<y.len: result.add y[i]
+
+macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): bool =
+  ## See top level documentation of this module about how ``scanf`` works.
+  template matchBind(parser) {.dirty.} =
+    var resLen = genSym(nskLet, "resLen")
+    conds.add newLetStmt(resLen, newCall(bindSym(parser), inp, results[i], idx))
+    conds.add resLen.notZero
+    conds.add resLen
+
+  template at(s: string; i: int): char = (if i < s.len: s[i] else: '\0')
+  template matchError() =
+    error("type mismatch between pattern '$" & pattern[p] & "' (position: " & $p &
+      ") and " & $getTypeInst(results[i]) & " var '" & repr(results[i]) & "'")
+
+  var i = 0
+  var p = 0
+  var idx = genSym(nskVar, "idx")
+  var res = genSym(nskVar, "res")
+  let inp = genSym(nskLet, "inp")
+  result = newTree(nnkStmtListExpr, newLetStmt(inp, input),
+                   newVarStmt(idx, newLit 0), newVarStmt(res, newLit false))
+  var conds = newTree(nnkStmtList)
+  var fullMatch = false
+  while p < pattern.len:
+    if pattern[p] == '$':
+      inc p
+      case pattern[p]
+      of '$':
+        var resLen = genSym(nskLet, "resLen")
+        conds.add newLetStmt(resLen, newCall(bindSym"skip", inp,
+                                             newLit($pattern[p]), idx))
+        conds.add resLen.notZero
+        conds.add resLen
+      of 'w':
+        if i < results.len and getType(results[i]).typeKind == ntyString:
+          matchBind "parseIdent"
+        else:
+          matchError
+        inc i
+      of 'c':
+        if i < results.len and getType(results[i]).typeKind == ntyChar:
+          matchBind "parseChar"
+        else:
+          matchError
+        inc i
+      of 'b':
+        if i < results.len and getType(results[i]).typeKind == ntyInt:
+          matchBind "parseBin"
+        else:
+          matchError
+        inc i
+      of 'o':
+        if i < results.len and getType(results[i]).typeKind == ntyInt:
+          matchBind "parseOct"
+        else:
+          matchError
+        inc i
+      of 'i':
+        if i < results.len and getType(results[i]).typeKind == ntyInt:
+          matchBind "parseInt"
+        else:
+          matchError
+        inc i
+      of 'h':
+        if i < results.len and getType(results[i]).typeKind == ntyInt:
+          matchBind "parseHex"
+        else:
+          matchError
+        inc i
+      of 'f':
+        if i < results.len and getType(results[i]).typeKind == ntyFloat:
+          matchBind "parseFloat"
+        else:
+          matchError
+        inc i
+      of 's':
+        conds.add newCall(bindSym"inc", idx,
+                          newCall(bindSym"skipWhitespace", inp, idx))
+        conds.add newEmptyNode()
+        conds.add newEmptyNode()
+      of '.':
+        if p == pattern.len-1:
+          fullMatch = true
+        else:
+          error("invalid format string")
+      of '*', '+':
+        if i < results.len and getType(results[i]).typeKind == ntyString:
+          var min = ord(pattern[p] == '+')
+          var q = p+1
+          var token = ""
+          while q < pattern.len and pattern[q] != '$':
+            token.add pattern[q]
+            inc q
+          var resLen = genSym(nskLet, "resLen")
+          conds.add newLetStmt(resLen, newCall(bindSym"parseUntil", inp,
+              results[i], newLit(token), idx))
+          conds.add newCall(bindSym">=", resLen, newLit min)
+          conds.add resLen
+        else:
+          matchError
+        inc i
+      of '{':
+        inc p
+        var nesting = 0
+        let start = p
+        while true:
+          case pattern.at(p)
+          of '{': inc nesting
+          of '}':
+            if nesting == 0: break
+            dec nesting
+          of '\0': error("expected closing '}'")
+          else: discard
+          inc p
+        let expr = pattern.substr(start, p-1)
+        if i < results.len:
+          var resLen = genSym(nskLet, "resLen")
+          conds.add newLetStmt(resLen, buildUserCall(expr, inp, results[i], idx))
+          conds.add newCall(bindSym"!=", resLen, newLit 0)
+          conds.add resLen
+        else:
+          error("no var given for $" & expr & " (position: " & $p & ")")
+        inc i
+      of '[':
+        inc p
+        var nesting = 0
+        let start = p
+        while true:
+          case pattern.at(p)
+          of '[': inc nesting
+          of ']':
+            if nesting == 0: break
+            dec nesting
+          of '\0': error("expected closing ']'")
+          else: discard
+          inc p
+        let expr = pattern.substr(start, p-1)
+        conds.add newCall(bindSym"inc", idx, buildUserCall(expr, inp, idx))
+        conds.add newEmptyNode()
+        conds.add newEmptyNode()
+      else: error("invalid format string")
+      inc p
+    else:
+      var token = ""
+      while p < pattern.len and pattern[p] != '$':
+        token.add pattern[p]
+        inc p
+      var resLen = genSym(nskLet, "resLen")
+      conds.add newLetStmt(resLen, newCall(bindSym"skip", inp, newLit(token), idx))
+      conds.add resLen.notZero
+      conds.add resLen
+  result.add conditionsToIfChain(conds, idx, res, 0)
+  if fullMatch:
+    result.add newCall(bindSym"and", res,
+      newCall(bindSym">=", idx, newCall(bindSym"len", inp)))
+  else:
+    result.add res
+
+macro scanTuple*(input: untyped; pattern: static[string]; matcherTypes: varargs[untyped]): untyped {.since: (1, 5).}=
+  ## Works identically as scanf, but instead of predeclaring variables it returns a tuple.
+  ## Tuple is started with a bool which indicates if the scan was successful
+  ## followed by the requested data.
+  ## If using a user defined matcher, provide the types in order they appear after pattern:
+  ## `line.scanTuple("${yourMatcher()}", int)`
+  runnableExamples:
+    let (success, year, month, day, time) = scanTuple("1000-01-01 00:00:00", "$i-$i-$i$s$+")
+    if success:
+      assert year == 1000
+      assert month == 1
+      assert day == 1
+      assert time == "00:00:00"
+  var
+    p = 0
+    userMatches = 0
+    arguments: seq[NimNode]
+  result = newStmtList()
+  template addVar(typ: string) =
+    let varIdent = ident("temp" & $arguments.len)
+    result.add(newNimNode(nnkVarSection).add(newIdentDefs(varIdent, ident(typ), newEmptyNode())))
+    arguments.add(varIdent)
+  while p < pattern.len:
+    if pattern[p] == '$':
+      inc p
+      case pattern[p]
+      of 'w', '*', '+':
+        addVar("string")
+      of 'c':
+        addVar("char")
+      of 'b', 'o', 'i', 'h':
+        addVar("int")
+      of 'f':
+        addVar("float")
+      of '{':
+        if userMatches < matcherTypes.len:
+          let varIdent = ident("temp" & $arguments.len)
+          result.add(newNimNode(nnkVarSection).add(newIdentDefs(varIdent, matcherTypes[userMatches], newEmptyNode())))
+          arguments.add(varIdent)
+          inc userMatches
+      else: discard
+    inc p
+  result.add nnkTupleConstr.newTree(newCall(ident("scanf"), input, newStrLitNode(pattern)))
+  for arg in arguments:
+    result[^1][0].add arg
+    result[^1].add arg
+  result = newBlockStmt(result)
+
+template atom*(input: string; idx: int; c: char): bool =
+  ## Used in scanp for the matching of atoms (usually chars).
+  ## EOF is matched as ``'\0'``.
+  (idx < input.len and input[idx] == c) or (idx == input.len and c == '\0')
+
+template atom*(input: string; idx: int; s: set[char]): bool =
+  (idx < input.len and input[idx] in s) or (idx == input.len and '\0' in s)
+
+template hasNxt*(input: string; idx: int): bool = idx < input.len
+
+#template prepare*(input: string): int = 0
+template success*(x: int): bool = x != 0
+
+template nxt*(input: string; idx, step: int = 1) = inc(idx, step)
+
+macro scanp*(input, idx: typed; pattern: varargs[untyped]): bool =
+  ## See top level documentation of this module about how ``scanp`` works.
+  type StmtTriple = tuple[init, cond, action: NimNode]
+
+  template interf(x): untyped = bindSym(x, brForceOpen)
+
+  proc toIfChain(n: seq[StmtTriple]; idx, res: NimNode; start: int): NimNode =
+    if start >= n.len: return newAssignment(res, newLit true)
+    var ifs: NimNode = nil
+    if n[start].cond.kind == nnkEmpty:
+      ifs = toIfChain(n, idx, res, start+1)
+    else:
+      ifs = newIfStmt((n[start].cond,
+                      newTree(nnkStmtList, n[start].action,
+                              toIfChain(n, idx, res, start+1))))
+    result = newTree(nnkStmtList, n[start].init, ifs)
+
+  proc attach(x, attached: NimNode): NimNode =
+    if attached == nil: x
+    else: newStmtList(attached, x)
+
+  proc placeholder(n, x, j: NimNode): NimNode =
+    if n.kind == nnkPrefix and n[0].eqIdent("$"):
+      let n1 = n[1]
+      if n1.eqIdent"_" or n1.eqIdent"current":
+        result = newTree(nnkBracketExpr, x, j)
+      elif n1.eqIdent"input":
+        result = x
+      elif n1.eqIdent"i" or n1.eqIdent"index":
+        result = j
+      else:
+        error("unknown pattern " & repr(n))
+    else:
+      result = copyNimNode(n)
+      for i in 0 ..< n.len:
+        result.add placeholder(n[i], x, j)
+
+  proc atm(it, input, idx, attached: NimNode): StmtTriple =
+    template `!!`(x): untyped = attach(x, attached)
+    case it.kind
+    of nnkIdent:
+      var resLen = genSym(nskLet, "resLen")
+      result = (newLetStmt(resLen, newCall(it, input, idx)),
+                newCall(interf"success", resLen),
+                !!newCall(interf"nxt", input, idx, resLen))
+    of nnkCallKinds:
+      # *{'A'..'Z'} !! s.add(!_)
+      template buildWhile(input, idx, init, cond, action): untyped =
+        mixin hasNxt
+        while hasNxt(input, idx):
+          init
+          if not cond: break
+          action
+
+      # (x) a  # bind action a to (x)
+      if it[0].kind in {nnkPar, nnkTupleConstr} and it.len == 2:
+        result = atm(it[0], input, idx, placeholder(it[1], input, idx))
+      elif it.kind == nnkInfix and it[0].eqIdent"->":
+        # bind matching to some action:
+        result = atm(it[1], input, idx, placeholder(it[2], input, idx))
+      elif it.kind == nnkInfix and it[0].eqIdent"as":
+        let cond = if it[1].kind in nnkCallKinds: placeholder(it[1], input, idx)
+                   else: newCall(it[1], input, idx)
+        result = (newLetStmt(it[2], cond),
+                  newCall(interf"success", it[2]),
+                  !!newCall(interf"nxt", input, idx, it[2]))
+      elif it.kind == nnkPrefix and it[0].eqIdent"*":
+        let (init, cond, action) = atm(it[1], input, idx, attached)
+        result = (getAst(buildWhile(input, idx, init, cond, action)),
+                  newEmptyNode(), newEmptyNode())
+      elif it.kind == nnkPrefix and it[0].eqIdent"+":
+        # x+  is the same as  xx*
+        result = atm(newTree(nnkTupleConstr, it[1], newTree(nnkPrefix, ident"*", it[1])),
+                      input, idx, attached)
+      elif it.kind == nnkPrefix and it[0].eqIdent"?":
+        # optional.
+        let (init, cond, action) = atm(it[1], input, idx, attached)
+        if cond.kind == nnkEmpty:
+          error("'?' operator applied to a non-condition")
+        else:
+          result = (newTree(nnkStmtList, init, newIfStmt((cond, action))),
+                    newEmptyNode(), newEmptyNode())
+      elif it.kind == nnkPrefix and it[0].eqIdent"~":
+        # not operator
+        let (init, cond, action) = atm(it[1], input, idx, attached)
+        if cond.kind == nnkEmpty:
+          error("'~' operator applied to a non-condition")
+        else:
+          result = (init, newCall(bindSym"not", cond), action)
+      elif it.kind == nnkInfix and it[0].eqIdent"|":
+        let a = atm(it[1], input, idx, attached)
+        let b = atm(it[2], input, idx, attached)
+        if a.cond.kind == nnkEmpty or b.cond.kind == nnkEmpty:
+          error("'|' operator applied to a non-condition")
+        else:
+          result = (newStmtList(a.init, newIfStmt((a.cond, a.action),
+                (newTree(nnkStmtListExpr, b.init, b.cond), b.action))),
+              newEmptyNode(), newEmptyNode())
+      elif it.kind == nnkInfix and it[0].eqIdent"^*":
+        # a ^* b  is rewritten to:  (a *(b a))?
+        #exprList = expr ^+ comma
+        template tmp(a, b): untyped = ?(a, *(b, a))
+        result = atm(getAst(tmp(it[1], it[2])), input, idx, attached)
+
+      elif it.kind == nnkInfix and it[0].eqIdent"^+":
+        # a ^* b  is rewritten to:  (a +(b a))?
+        template tmp(a, b): untyped = (a, *(b, a))
+        result = atm(getAst(tmp(it[1], it[2])), input, idx, attached)
+      elif it.kind == nnkCommand and it.len == 2 and it[0].eqIdent"pred":
+        # enforce that the wrapped call is interpreted as a predicate, not a non-terminal:
+        result = (newEmptyNode(), placeholder(it[1], input, idx), newEmptyNode())
+      else:
+        var resLen = genSym(nskLet, "resLen")
+        result = (newLetStmt(resLen, placeholder(it, input, idx)),
+                  newCall(interf"success", resLen),
+                  !!newCall(interf"nxt", input, idx, resLen))
+    of nnkStrLit..nnkTripleStrLit:
+      var resLen = genSym(nskLet, "resLen")
+      result = (newLetStmt(resLen, newCall(interf"skip", input, it, idx)),
+                newCall(interf"success", resLen),
+                !!newCall(interf"nxt", input, idx, resLen))
+    of nnkCurly, nnkAccQuoted, nnkCharLit:
+      result = (newEmptyNode(), newCall(interf"atom", input, idx, it),
+                !!newCall(interf"nxt", input, idx))
+    of nnkCurlyExpr:
+      if it.len == 3 and it[1].kind == nnkIntLit and it[2].kind == nnkIntLit:
+        var h = newTree(nnkTupleConstr, it[0])
+        for count in 2i64 .. it[1].intVal: h.add(it[0])
+        for count in it[1].intVal .. it[2].intVal-1:
+          h.add(newTree(nnkPrefix, ident"?", it[0]))
+        result = atm(h, input, idx, attached)
+      elif it.len == 2 and it[1].kind == nnkIntLit:
+        var h = newTree(nnkTupleConstr, it[0])
+        for count in 2i64 .. it[1].intVal: h.add(it[0])
+        result = atm(h, input, idx, attached)
+      else:
+        error("invalid pattern")
+    of nnkPar, nnkTupleConstr:
+      if it.len == 1 and it.kind == nnkPar:
+        result = atm(it[0], input, idx, attached)
+      else:
+        # concatenation:
+        var conds: seq[StmtTriple] = @[]
+        for x in it: conds.add atm(x, input, idx, attached)
+        var res = genSym(nskVar, "res")
+        result = (newStmtList(newVarStmt(res, newLit false),
+            toIfChain(conds, idx, res, 0)), res, newEmptyNode())
+    else:
+      error("invalid pattern")
+
+  #var idx = genSym(nskVar, "idx")
+  var res = genSym(nskVar, "res")
+  result = newTree(nnkStmtListExpr, #newVarStmt(idx, newCall(interf"prepare", input)),
+    newVarStmt(res, newLit false))
+  var conds: seq[StmtTriple] = @[]
+  for it in pattern:
+    conds.add atm(it, input, idx, nil)
+  result.add toIfChain(conds, idx, res, 0)
+  result.add res
+  when defined(debugScanp):
+    echo repr result
diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim
index 38be1e983..4b07aca5a 100755..100644
--- a/lib/pure/strtabs.nim
+++ b/lib/pure/strtabs.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,97 +9,118 @@
 
 ## The ``strtabs`` module implements an efficient hash table that is a mapping
 ## from strings to strings. Supports a case-sensitive, case-insensitive and
-## style-insensitive mode. An efficient string substitution operator  ``%``
-## for the string table is also provided.
+## style-insensitive mode.
 
-import
-  os, hashes, strutils
+runnableExamples:
+  var t = newStringTable()
+  t["name"] = "John"
+  t["city"] = "Monaco"
+  doAssert t.len == 2
+  doAssert t.hasKey "name"
+  doAssert "name" in t
 
-type
-  TStringTableMode* = enum    ## describes the tables operation mode
-    modeCaseSensitive,        ## the table is case sensitive
-    modeCaseInsensitive,      ## the table is case insensitive
-    modeStyleInsensitive      ## the table is style insensitive
-  TKeyValuePair = tuple[key, val: string]
-  TKeyValuePairSeq = seq[TKeyValuePair]
-  TStringTable* = object of TObject
-    counter: int
-    data: TKeyValuePairSeq
-    mode: TStringTableMode
+## String tables can be created from a table constructor:
+runnableExamples:
+  var t = {"name": "John", "city": "Monaco"}.newStringTable
 
-  PStringTable* = ref TStringTable ## use this type to declare string tables
+## When using the style insensitive mode (``modeStyleInsensitive``),
+## all letters are compared case insensitively within the ASCII range
+## and underscores are ignored.
+runnableExamples:
+  var x = newStringTable(modeStyleInsensitive)
+  x["first_name"] = "John"
+  x["LastName"] = "Doe"
 
-proc newStringTable*(keyValuePairs: openarray[string],
-                     mode: TStringTableMode = modeCaseSensitive): PStringTable
-  ## creates a new string table with given key value pairs.
-  ## Example::
-  ##   var mytab = newStringTable("key1", "val1", "key2", "val2",
-  ##                              modeCaseInsensitive)
+  doAssert x["firstName"] == "John"
+  doAssert x["last_name"] == "Doe"
 
-proc newStringTable*(mode: TStringTableMode): PStringTable
-  ## creates a new string table that is empty.
+## An efficient string substitution operator
+## `% <#%25,string,StringTableRef,set[FormatFlag]>`_ for the string table
+## is also provided.
+runnableExamples:
+  var t = {"name": "John", "city": "Monaco"}.newStringTable
+  doAssert "${name} lives in ${city}" % t == "John lives in Monaco"
 
-proc `[]=`*(t: PStringTable, key, val: string)
-  ## puts a (key, value)-pair into `t`.
+## **See also:**
+## * `tables module <tables.html>`_ for general hash tables
+## * `sharedtables module<sharedtables.html>`_ for shared hash table support
+## * `strutils module<strutils.html>`_ for common string functions
+## * `json module<json.html>`_ for table-like structure which allows
+##   heterogeneous members
 
-proc `[]`*(t: PStringTable, key: string): string
-  ## retrieves the value at ``t[key]``. If `key` is not in `t`, "" is returned
-  ## and no exception is raised. One can check with ``hasKey`` whether the key
-  ## exists.
+import std/private/since
 
-proc hasKey*(t: PStringTable, key: string): bool
-  ## returns true iff `key` is in the table `t`.
+import
+  std/[hashes, strutils]
 
-proc len*(t: PStringTable): int =
-  ## returns the number of keys in `t`.
-  result = t.counter
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
-iterator pairs*(t: PStringTable): tuple[key, value: string] =
-  ## iterates over any (key, value) pair in the table `t`.
-  for h in 0..high(t.data):
-    if not isNil(t.data[h].key):
-      yield (t.data[h].key, t.data[h].val)
+
+when defined(js) or defined(nimscript) or defined(Standalone):
+  {.pragma: rtlFunc.}
+else:
+  {.pragma: rtlFunc, rtl.}
+  import std/envvars
+
+include "system/inclrtl"
 
 type
-  TFormatFlag* = enum         ## flags for the `%` operator
-    useEnvironment,           ## use environment variable if the ``$key``
-                              ## is not found in the table
-    useEmpty,                 ## use the empty string as a default, thus it
-                              ## won't throw an exception if ``$key`` is not
-                              ## in the table
-    useKey                    ## do not replace ``$key`` if it is not found
-                              ## in the table (or in the environment)
-
-proc `%`*(f: string, t: PStringTable, flags: set[TFormatFlag] = {}): string
-  ## The `%` operator for string tables.
+  StringTableMode* = enum ## Describes the tables operation mode.
+    modeCaseSensitive,    ## the table is case sensitive
+    modeCaseInsensitive,  ## the table is case insensitive
+    modeStyleInsensitive  ## the table is style insensitive
+  KeyValuePair = tuple[key, val: string, hasValue: bool]
+  KeyValuePairSeq = seq[KeyValuePair]
+  StringTableObj* = object of RootObj
+    counter: int
+    data: KeyValuePairSeq
+    mode: StringTableMode
 
-# implementation
+  StringTableRef* = ref StringTableObj
+
+  FormatFlag* = enum ## Flags for the `%` operator.
+    useEnvironment,  ## Use environment variable if the ``$key``
+                     ## is not found in the table.
+                     ## Does nothing when using `js` target.
+    useEmpty,        ## Use the empty string as a default, thus it
+                     ## won't throw an exception if ``$key`` is not
+                     ## in the table.
+    useKey           ## Do not replace ``$key`` if it is not found
+                     ## in the table (or in the environment).
 
 const
   growthFactor = 2
   startSize = 64
 
-proc newStringTable(mode: TStringTableMode): PStringTable =
-  new(result)
-  result.mode = mode
-  result.counter = 0
-  newSeq(result.data, startSize)
+proc mode*(t: StringTableRef): StringTableMode {.inline.} = t.mode
 
-proc newStringTable(keyValuePairs: openarray[string],
-                    mode: TStringTableMode = modeCaseSensitive): PStringTable =
-  result = newStringTable(mode)
-  var i = 0
-  while i < high(keyValuePairs):
-    result[keyValuePairs[i]] = keyValuePairs[i + 1]
-    inc(i, 2)
+iterator pairs*(t: StringTableRef): tuple[key, value: string] =
+  ## Iterates over every `(key, value)` pair in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].hasValue:
+      yield (t.data[h].key, t.data[h].val)
 
-proc myhash(t: PStringTable, key: string): THash =
+iterator keys*(t: StringTableRef): string =
+  ## Iterates over every key in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].hasValue:
+      yield t.data[h].key
+
+iterator values*(t: StringTableRef): string =
+  ## Iterates over every value in the table `t`.
+  for h in 0..high(t.data):
+    if t.data[h].hasValue:
+      yield t.data[h].val
+
+
+proc myhash(t: StringTableRef, key: string): Hash =
   case t.mode
   of modeCaseSensitive: result = hashes.hash(key)
   of modeCaseInsensitive: result = hashes.hashIgnoreCase(key)
   of modeStyleInsensitive: result = hashes.hashIgnoreStyle(key)
 
-proc myCmp(t: PStringTable, a, b: string): bool =
+proc myCmp(t: StringTableRef, a, b: string): bool =
   case t.mode
   of modeCaseSensitive: result = cmp(a, b) == 0
   of modeCaseInsensitive: result = cmpIgnoreCase(a, b) == 0
@@ -109,66 +130,270 @@ proc mustRehash(length, counter: int): bool =
   assert(length > counter)
   result = (length * 2 < counter * 3) or (length - counter < 4)
 
-proc nextTry(h, maxHash: THash): THash =
-  result = ((5 * h) + 1) and maxHash
+proc nextTry(h, maxHash: Hash): Hash {.inline.} =
+  result = (h + 1) and maxHash
 
-proc RawGet(t: PStringTable, key: string): int =
-  var h: THash
-  h = myhash(t, key) and high(t.data) # start with real hash value
-  while not isNil(t.data[h].key):
-    if mycmp(t, t.data[h].key, key):
+proc rawGet(t: StringTableRef, key: string): int =
+  var h: Hash = myhash(t, key) and high(t.data) # start with real hash value
+  while t.data[h].hasValue:
+    if myCmp(t, t.data[h].key, key):
       return h
     h = nextTry(h, high(t.data))
   result = - 1
 
-proc `[]`(t: PStringTable, key: string): string =
-  var index: int
-  index = RawGet(t, key)
+template get(t: StringTableRef, key: string) =
+  var index = rawGet(t, key)
   if index >= 0: result = t.data[index].val
-  else: result = ""
+  else:
+    raise newException(KeyError, "key not found: " & key)
+
+
+proc len*(t: StringTableRef): int {.rtlFunc, extern: "nst$1".} =
+  ## Returns the number of keys in `t`.
+  result = t.counter
 
-proc hasKey(t: PStringTable, key: string): bool =
+proc `[]`*(t: StringTableRef, key: string): var string {.
+           rtlFunc, extern: "nstTake".} =
+  ## Retrieves the location at ``t[key]``.
+  ##
+  ## If `key` is not in `t`, the ``KeyError`` exception is raised.
+  ## One can check with `hasKey proc <#hasKey,StringTableRef,string>`_
+  ## whether the key exists.
+  ##
+  ## See also:
+  ## * `getOrDefault proc <#getOrDefault,StringTableRef,string,string>`_
+  ## * `[]= proc <#[]=,StringTableRef,string,string>`_ for inserting a new
+  ##   (key, value) pair in the table
+  ## * `hasKey proc <#hasKey,StringTableRef,string>`_ for checking if a key
+  ##   is in the table
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    doAssert t["name"] == "John"
+    doAssertRaises(KeyError):
+      echo t["occupation"]
+  get(t, key)
+
+proc getOrDefault*(t: StringTableRef; key: string,
+    default: string = ""): string =
+  ## Retrieves the location at ``t[key]``.
+  ##
+  ## If `key` is not in `t`, the default value is returned (if not specified,
+  ## it is an empty string (`""`)).
+  ##
+  ## See also:
+  ## * `[] proc <#[],StringTableRef,string>`_ for retrieving a value of a key
+  ## * `hasKey proc <#hasKey,StringTableRef,string>`_ for checking if a key
+  ##   is in the table
+  ## * `[]= proc <#[]=,StringTableRef,string,string>`_ for inserting a new
+  ##   (key, value) pair in the table
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    doAssert t.getOrDefault("name") == "John"
+    doAssert t.getOrDefault("occupation") == ""
+    doAssert t.getOrDefault("occupation", "teacher") == "teacher"
+    doAssert t.getOrDefault("name", "Paul") == "John"
+
+  var index = rawGet(t, key)
+  if index >= 0: result = t.data[index].val
+  else: result = default
+
+proc hasKey*(t: StringTableRef, key: string): bool {.rtlFunc,
+    extern: "nst$1".} =
+  ## Returns true if `key` is in the table `t`.
+  ##
+  ## See also:
+  ## * `getOrDefault proc <#getOrDefault,StringTableRef,string,string>`_
+  ## * `contains proc <#contains,StringTableRef,string>`_
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    doAssert t.hasKey("name")
+    doAssert not t.hasKey("occupation")
   result = rawGet(t, key) >= 0
 
-proc RawInsert(t: PStringTable, data: var TKeyValuePairSeq, key, val: string) =
-  var h: THash
-  h = myhash(t, key) and high(data)
-  while not isNil(data[h].key):
+proc contains*(t: StringTableRef, key: string): bool =
+  ## Alias of `hasKey proc <#hasKey,StringTableRef,string>`_ for use with
+  ## the `in` operator.
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    doAssert "name" in t
+    doAssert "occupation" notin t
+  return hasKey(t, key)
+
+proc rawInsert(t: StringTableRef, data: var KeyValuePairSeq, key, val: string) =
+  var h: Hash = myhash(t, key) and high(data)
+  while data[h].hasValue:
     h = nextTry(h, high(data))
   data[h].key = key
   data[h].val = val
+  data[h].hasValue = true
 
-proc Enlarge(t: PStringTable) =
-  var n: TKeyValuePairSeq
+proc enlarge(t: StringTableRef) =
+  var n: KeyValuePairSeq
   newSeq(n, len(t.data) * growthFactor)
   for i in countup(0, high(t.data)):
-    if not isNil(t.data[i].key): RawInsert(t, n, t.data[i].key, t.data[i].val)
+    if t.data[i].hasValue: rawInsert(t, n, move t.data[i].key, move t.data[i].val)
   swap(t.data, n)
 
-proc `[]=`(t: PStringTable, key, val: string) =
-  var index = RawGet(t, key)
+proc `[]=`*(t: StringTableRef, key, val: string) {.
+  rtlFunc, extern: "nstPut".} =
+  ## Inserts a `(key, value)` pair into `t`.
+  ##
+  ## See also:
+  ## * `[] proc <#[],StringTableRef,string>`_ for retrieving a value of a key
+  ## * `del proc <#del,StringTableRef,string>`_ for removing a key from the table
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    t["occupation"] = "teacher"
+    doAssert t.hasKey("occupation")
+
+  var index = rawGet(t, key)
   if index >= 0:
     t.data[index].val = val
   else:
-    if mustRehash(len(t.data), t.counter): Enlarge(t)
-    RawInsert(t, t.data, key, val)
+    if mustRehash(len(t.data), t.counter): enlarge(t)
+    rawInsert(t, t.data, key, val)
     inc(t.counter)
 
-proc RaiseFormatException(s: string) =
-  var e: ref EInvalidValue
-  new(e)
-  e.msg = "format string: key not found: " & s
-  raise e
+proc newStringTable*(mode: StringTableMode): owned(StringTableRef) {.
+  rtlFunc, extern: "nst$1", noSideEffect.} =
+  ## Creates a new empty string table.
+  ##
+  ## See also:
+  ## * `newStringTable(keyValuePairs) proc
+  ##   <#newStringTable,varargs[tuple[string,string]],StringTableMode>`_
+  result = StringTableRef(mode: mode, counter: 0, data: newSeq[KeyValuePair](startSize))
+
+proc newStringTable*(keyValuePairs: varargs[string],
+                     mode: StringTableMode): owned(StringTableRef) {.
+  rtlFunc, extern: "nst$1WithPairs", noSideEffect.} =
+  ## Creates a new string table with given `key, value` string pairs.
+  ##
+  ## `StringTableMode` must be specified.
+  runnableExamples:
+    var mytab = newStringTable("key1", "val1", "key2", "val2",
+                               modeCaseInsensitive)
+
+  result = newStringTable(mode)
+  var i = 0
+  while i < high(keyValuePairs):
+    {.noSideEffect.}:
+      result[keyValuePairs[i]] = keyValuePairs[i + 1]
+    inc(i, 2)
+
+proc newStringTable*(keyValuePairs: varargs[tuple[key, val: string]],
+    mode: StringTableMode = modeCaseSensitive): owned(StringTableRef) {.
+    rtlFunc, extern: "nst$1WithTableConstr", noSideEffect.} =
+  ## Creates a new string table with given `(key, value)` tuple pairs.
+  ##
+  ## The default mode is case sensitive.
+  runnableExamples:
+    var
+      mytab1 = newStringTable({"key1": "val1", "key2": "val2"}, modeCaseInsensitive)
+      mytab2 = newStringTable([("key3", "val3"), ("key4", "val4")])
 
-proc getValue(t: PStringTable, flags: set[TFormatFlag], key: string): string =
-  if hasKey(t, key): return t[key]
-  if useEnvironment in flags: result = os.getEnv(key)
-  else: result = ""
+  result = newStringTable(mode)
+  for key, val in items(keyValuePairs):
+    {.noSideEffect.}:
+      result[key] = val
+
+proc raiseFormatException(s: string) =
+  raise newException(ValueError, "format string: key not found: " & s)
+
+proc getValue(t: StringTableRef, flags: set[FormatFlag], key: string): string =
+  if hasKey(t, key): return t.getOrDefault(key)
+  when defined(js) or defined(nimscript) or defined(Standalone):
+    result = ""
+  else:
+    if useEnvironment in flags: result = getEnv(key)
+    else: result = ""
   if result.len == 0:
     if useKey in flags: result = '$' & key
-    elif not (useEmpty in flags): raiseFormatException(key)
+    elif useEmpty notin flags: raiseFormatException(key)
+
+proc clear*(s: StringTableRef, mode: StringTableMode) {.
+  rtlFunc, extern: "nst$1".} =
+  ## Resets a string table to be empty again, perhaps altering the mode.
+  ##
+  ## See also:
+  ## * `del proc <#del,StringTableRef,string>`_ for removing a key from the table
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    clear(t, modeCaseSensitive)
+    doAssert len(t) == 0
+    doAssert "name" notin t
+    doAssert "city" notin t
+  s.mode = mode
+  s.counter = 0
+  s.data.setLen(startSize)
+  for i in 0..<s.data.len:
+    s.data[i].hasValue = false
+
+proc clear*(s: StringTableRef) {.since: (1, 1).} =
+  ## Resets a string table to be empty again without changing the mode.
+  s.clear(s.mode)
+
+proc del*(t: StringTableRef, key: string) =
+  ## Removes `key` from `t`.
+  ##
+  ## See also:
+  ## * `clear proc <#clear,StringTableRef,StringTableMode>`_ for resetting a
+  ##   table to be empty
+  ## * `[]= proc <#[]=,StringTableRef,string,string>`_ for inserting a new
+  ##   (key, value) pair in the table
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    t.del("name")
+    doAssert len(t) == 1
+    doAssert "name" notin t
+    doAssert "city" in t
+
+  # Impl adapted from `tableimpl.delImplIdx`
+  var i = rawGet(t, key)
+  let msk = high(t.data)
+  if i >= 0:
+    dec(t.counter)
+    block outer:
+      while true: # KnuthV3 Algo6.4R adapted for i=i+1 instead of i=i-1
+        var j = i # The correctness of this depends on (h+1) in nextTry,
+        var r = j # though may be adaptable to other simple sequences.
+        t.data[i].hasValue = false # mark current EMPTY
+        t.data[i].key = ""
+        t.data[i].val = ""
+        while true:
+          i = (i + 1) and msk # increment mod table size
+          if not t.data[i].hasValue: # end of collision cluster; So all done
+            break outer
+          r = t.myhash(t.data[i].key) and msk # "home" location of key@i
+          if not ((i >= r and r > j) or (r > j and j > i) or (j > i and i >= r)):
+            break
+        when defined(js):
+          t.data[j] = t.data[i]
+        elif defined(gcDestructors):
+          t.data[j] = move t.data[i]
+        else:
+          shallowCopy(t.data[j], t.data[i]) # data[j] will be marked EMPTY next loop
+
+proc `$`*(t: StringTableRef): string {.rtlFunc, extern: "nstDollar".} =
+  ## The `$` operator for string tables. Used internally when calling
+  ## `echo` on a table.
+  if t.len == 0:
+    result = "{:}"
+  else:
+    result = "{"
+    for key, val in pairs(t):
+      if result.len > 1: result.add(", ")
+      result.add(key)
+      result.add(": ")
+      result.add(val)
+    result.add("}")
+
+proc `%`*(f: string, t: StringTableRef, flags: set[FormatFlag] = {}): string {.
+  rtlFunc, extern: "nstFormat".} =
+  ## The `%` operator for string tables.
+  runnableExamples:
+    var t = {"name": "John", "city": "Monaco"}.newStringTable
+    doAssert "${name} lives in ${city}" % t == "John lives in Monaco"
 
-proc `%`(f: string, t: PStringTable, flags: set[TFormatFlag] = {}): string =
   const
     PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF'}
   result = ""
@@ -182,12 +407,12 @@ proc `%`(f: string, t: PStringTable, flags: set[TFormatFlag] = {}): string =
       of '{':
         var j = i + 1
         while j < f.len and f[j] != '}': inc(j)
-        add(result, getValue(t, flags, copy(f, i+2, j-1)))
+        add(result, getValue(t, flags, substr(f, i+2, j-1)))
         i = j + 1
       of 'a'..'z', 'A'..'Z', '\x80'..'\xFF', '_':
         var j = i + 1
         while j < f.len and f[j] in PatternChars: inc(j)
-        add(result, getValue(t, flags, copy(f, i+1, j-1)))
+        add(result, getValue(t, flags, substr(f, i+1, j-1)))
         i = j
       else:
         add(result, f[i])
@@ -195,4 +420,3 @@ proc `%`(f: string, t: PStringTable, flags: set[TFormatFlag] = {}): string =
     else:
       add(result, f[i])
       inc(i)
-
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 6854999e3..81be7db17 100755..100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -1,222 +1,673 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module contains various string utility routines.
-## See the module `regexprs` for regular expression support.
+## The system module defines several common functions for working with strings,
+## such as:
+## * `$` for converting other data-types to strings
+## * `&` for string concatenation
+## * `add` for adding a new character or a string to the existing one
+## * `in` (alias for `contains`) and `notin` for checking if a character
+##   is in a string
+##
+## This module builds upon that, providing additional functionality in form of
+## procedures, iterators and templates for strings.
+
+runnableExamples:
+  let
+    numbers = @[867, 5309]
+    multiLineString = "first line\nsecond line\nthird line"
+
+  let jenny = numbers.join("-")
+  assert jenny == "867-5309"
+
+  assert splitLines(multiLineString) ==
+         @["first line", "second line", "third line"]
+  assert split(multiLineString) == @["first", "line", "second",
+                                     "line", "third", "line"]
+  assert indent(multiLineString, 4) ==
+         "    first line\n    second line\n    third line"
+  assert 'z'.repeat(5) == "zzzzz"
+
+## The chaining of functions is possible thanks to the
+## `method call syntax<manual.html#procedures-method-call-syntax>`_:
+
+runnableExamples:
+  from std/sequtils import map
+
+  let jenny = "867-5309"
+  assert jenny.split('-').map(parseInt) == @[867, 5309]
+
+  assert "Beetlejuice".indent(1).repeat(3).strip ==
+         "Beetlejuice Beetlejuice Beetlejuice"
+
+## This module is available for the `JavaScript target
+## <backends.html#backends-the-javascript-target>`_.
+##
+## ----
+##
+## **See also:**
+## * `strformat module<strformat.html>`_ for string interpolation and formatting
+## * `unicode module<unicode.html>`_ for Unicode UTF-8 handling
+## * `sequtils module<sequtils.html>`_ for operations on container
+##   types (including strings)
+## * `parsecsv module<parsecsv.html>`_ for a high-performance CSV parser
+## * `parseutils module<parseutils.html>`_ for lower-level parsing of tokens,
+##   numbers, identifiers, etc.
+## * `parseopt module<parseopt.html>`_ for command-line parsing
+## * `pegs module<pegs.html>`_ for PEG (Parsing Expression Grammar) support
+## * `strtabs module<strtabs.html>`_ for efficient hash tables
+##   (dictionaries, in some programming languages) mapping from strings to strings
+## * `ropes module<ropes.html>`_ for rope data type, which can represent very
+##   long strings efficiently
+## * `re module<re.html>`_ for regular expression (regex) support
+## * `strscans<strscans.html>`_ for `scanf` and `scanp` macros, which offer
+##   easier substring extraction than regular expressions
+
+
+import std/parseutils
+from std/math import pow, floor, log10
+from std/algorithm import fill, reverse
+import std/enumutils
+
+from std/unicode import toLower, toUpper
+export toLower, toUpper
+
+include "system/inclrtl"
+import std/private/[since, jsutils]
+from std/private/strimpl import cmpIgnoreStyleImpl, cmpIgnoreCaseImpl,
+    startsWithImpl, endsWithImpl
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
-import parseutils
-
-{.deadCodeElim: on.}
-
-{.push debugger:off .} # the user does not want to trace a part
-                       # of the standard library!
-
-type
-  TCharSet* = set[char] # for compatibility with Nim
 
 const
   Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'}
-    ## All the characters that count as whitespace.
-    
+    ## All the characters that count as whitespace (space, tab, vertical tab,
+    ## carriage return, new line, form feed).
+
   Letters* = {'A'..'Z', 'a'..'z'}
-    ## the set of letters
-  
+    ## The set of letters.
+
+  UppercaseLetters* = {'A'..'Z'}
+    ## The set of uppercase ASCII letters.
+
+  LowercaseLetters* = {'a'..'z'}
+    ## The set of lowercase ASCII letters.
+
+  PunctuationChars* = {'!'..'/', ':'..'@', '['..'`', '{'..'~'}
+    ## The set of all ASCII punctuation characters.
+
   Digits* = {'0'..'9'}
-    ## the set of digits
-  
+    ## The set of digits.
+
+  HexDigits* = {'0'..'9', 'A'..'F', 'a'..'f'}
+    ## The set of hexadecimal digits.
+
   IdentChars* = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
-    ## the set of characters an identifier can consist of
-  
-  IdentStartChars* = {'a'..'z', 'A'..'Z', '_'}
-    ## the set of characters an identifier can start with
+    ## The set of characters an identifier can consist of.
 
-proc `%` *(formatstr: string, a: openarray[string]): string {.noSideEffect.}
-  ## The `substitution`:idx: operator performs string substitutions in
-  ## `formatstr` and returns a modified `formatstr`. This is often called
-  ## `string interpolation`:idx:.
-  ##
-  ## This is best explained by an example:
-  ##
-  ## .. code-block:: nimrod
-  ##   "$1 eats $2." % ["The cat", "fish"]
+  IdentStartChars* = {'a'..'z', 'A'..'Z', '_'}
+    ## The set of characters an identifier can start with.
+
+  Newlines* = {'\13', '\10'}
+    ## The set of characters a newline terminator can start with (carriage
+    ## return, line feed).
+
+  PrintableChars* = Letters + Digits + PunctuationChars + Whitespace
+    ## The set of all printable ASCII characters (letters, digits, whitespace, and punctuation characters).
+
+  AllChars* = {'\x00'..'\xFF'}
+    ## A set with all the possible characters.
+    ##
+    ## Not very useful by its own, you can use it to create *inverted* sets to
+    ## make the `find func<#find,string,set[char],Natural,int>`_
+    ## find **invalid** characters in strings. Example:
+    ##   ```nim
+    ##   let invalid = AllChars - Digits
+    ##   doAssert "01234".find(invalid) == -1
+    ##   doAssert "01A34".find(invalid) == 2
+    ##   ```
+
+func isAlphaAscii*(c: char): bool {.rtl, extern: "nsuIsAlphaAsciiChar".} =
+  ## Checks whether or not character `c` is alphabetical.
   ##
-  ## Results in:
+  ## This checks a-z, A-Z ASCII characters only.
+  ## Use `Unicode module<unicode.html>`_ for UTF-8 support.
+  runnableExamples:
+    doAssert isAlphaAscii('e') == true
+    doAssert isAlphaAscii('E') == true
+    doAssert isAlphaAscii('8') == false
+  return c in Letters
+
+func isAlphaNumeric*(c: char): bool {.rtl, extern: "nsuIsAlphaNumericChar".} =
+  ## Checks whether or not `c` is alphanumeric.
   ##
-  ## .. code-block:: nimrod
-  ##   "The cat eats fish."
+  ## This checks a-z, A-Z, 0-9 ASCII characters only.
+  runnableExamples:
+    doAssert isAlphaNumeric('n') == true
+    doAssert isAlphaNumeric('8') == true
+    doAssert isAlphaNumeric(' ') == false
+  return c in Letters+Digits
+
+func isDigit*(c: char): bool {.rtl, extern: "nsuIsDigitChar".} =
+  ## Checks whether or not `c` is a number.
   ##
-  ## The substitution variables (the thing after the ``$``) are enumerated
-  ## from 1 to ``a.len``.
-  ## The notation ``$#`` can be used to refer to the next substitution variable:
+  ## This checks 0-9 ASCII characters only.
+  runnableExamples:
+    doAssert isDigit('n') == false
+    doAssert isDigit('8') == true
+  return c in Digits
+
+func isSpaceAscii*(c: char): bool {.rtl, extern: "nsuIsSpaceAsciiChar".} =
+  ## Checks whether or not `c` is a whitespace character.
+  runnableExamples:
+    doAssert isSpaceAscii('n') == false
+    doAssert isSpaceAscii(' ') == true
+    doAssert isSpaceAscii('\t') == true
+  return c in Whitespace
+
+func isLowerAscii*(c: char): bool {.rtl, extern: "nsuIsLowerAsciiChar".} =
+  ## Checks whether or not `c` is a lower case character.
   ##
-  ## .. code-block:: nimrod
-  ##   "$# eats $#." % ["The cat", "fish"]
+  ## This checks ASCII characters only.
+  ## Use `Unicode module<unicode.html>`_ for UTF-8 support.
   ##
-  ## Substitution variables can also be words (that is
-  ## ``[A-Za-z_]+[A-Za-z0-9_]*``) in which case the arguments in `a` with even
-  ## indices are keys and with odd indices are the corresponding values.
-  ## An example:
+  ## See also:
+  ## * `toLowerAscii func<#toLowerAscii,char>`_
+  runnableExamples:
+    doAssert isLowerAscii('e') == true
+    doAssert isLowerAscii('E') == false
+    doAssert isLowerAscii('7') == false
+  return c in LowercaseLetters
+
+func isUpperAscii*(c: char): bool {.rtl, extern: "nsuIsUpperAsciiChar".} =
+  ## Checks whether or not `c` is an upper case character.
   ##
-  ## .. code-block:: nimrod
-  ##   "$animal eats $food." % ["animal", "The cat", "food", "fish"]
+  ## This checks ASCII characters only.
+  ## Use `Unicode module<unicode.html>`_ for UTF-8 support.
   ##
-  ## Results in:
+  ## See also:
+  ## * `toUpperAscii func<#toUpperAscii,char>`_
+  runnableExamples:
+    doAssert isUpperAscii('e') == false
+    doAssert isUpperAscii('E') == true
+    doAssert isUpperAscii('7') == false
+  return c in UppercaseLetters
+
+func toLowerAscii*(c: char): char {.rtl, extern: "nsuToLowerAsciiChar".} =
+  ## Returns the lower case version of character `c`.
   ##
-  ## .. code-block:: nimrod
-  ##   "The cat eats fish."
+  ## This works only for the letters `A-Z`. See `unicode.toLower
+  ## <unicode.html#toLower,Rune>`_ for a version that works for any Unicode
+  ## character.
   ##
-  ## The variables are compared with `cmpIgnoreStyle`. `EInvalidValue` is
-  ## raised if an ill-formed format string has been passed to the `%` operator.
-
-proc `%` *(formatstr, a: string): string {.noSideEffect.}
-  ## This is the same as ``formatstr % [a]``.
+  ## See also:
+  ## * `isLowerAscii func<#isLowerAscii,char>`_
+  ## * `toLowerAscii func<#toLowerAscii,string>`_ for converting a string
+  runnableExamples:
+    doAssert toLowerAscii('A') == 'a'
+    doAssert toLowerAscii('e') == 'e'
+  if c in UppercaseLetters:
+    result = char(uint8(c) xor 0b0010_0000'u8)
+  else:
+    result = c
 
-proc addf*(s: var string, formatstr: string, a: openarray[string])
-  ## The same as ``add(s, formatstr % a)``, but more efficient.
+template toImpl(call) =
+  result = newString(len(s))
+  for i in 0..len(s) - 1:
+    result[i] = call(s[i])
 
-proc strip*(s: string, leading = true, trailing = true): string {.noSideEffect.}
-  ## Strips whitespace from `s` and returns the resulting string.
-  ## If `leading` is true, leading whitespace is stripped.
-  ## If `trailing` is true, trailing whitespace is stripped.
+func toLowerAscii*(s: string): string {.rtl, extern: "nsuToLowerAsciiStr".} =
+  ## Converts string `s` into lower case.
+  ##
+  ## This works only for the letters `A-Z`. See `unicode.toLower
+  ## <unicode.html#toLower,string>`_ for a version that works for any Unicode
+  ## character.
+  ##
+  ## See also:
+  ## * `normalize func<#normalize,string>`_
+  runnableExamples:
+    doAssert toLowerAscii("FooBar!") == "foobar!"
+  toImpl toLowerAscii
+
+func toUpperAscii*(c: char): char {.rtl, extern: "nsuToUpperAsciiChar".} =
+  ## Converts character `c` into upper case.
+  ##
+  ## This works only for the letters `A-Z`.  See `unicode.toUpper
+  ## <unicode.html#toUpper,Rune>`_ for a version that works for any Unicode
+  ## character.
+  ##
+  ## See also:
+  ## * `isUpperAscii func<#isUpperAscii,char>`_
+  ## * `toUpperAscii func<#toUpperAscii,string>`_ for converting a string
+  ## * `capitalizeAscii func<#capitalizeAscii,string>`_
+  runnableExamples:
+    doAssert toUpperAscii('a') == 'A'
+    doAssert toUpperAscii('E') == 'E'
+  if c in LowercaseLetters:
+    result = char(uint8(c) xor 0b0010_0000'u8)
+  else:
+    result = c
 
-proc toLower*(s: string): string {.noSideEffect, procvar.}
-  ## Converts `s` into lower case. This works only for the letters A-Z.
-  ## See `unicode.toLower` for a version that works for any Unicode character.
+func toUpperAscii*(s: string): string {.rtl, extern: "nsuToUpperAsciiStr".} =
+  ## Converts string `s` into upper case.
+  ##
+  ## This works only for the letters `A-Z`.  See `unicode.toUpper
+  ## <unicode.html#toUpper,string>`_ for a version that works for any Unicode
+  ## character.
+  ##
+  ## See also:
+  ## * `capitalizeAscii func<#capitalizeAscii,string>`_
+  runnableExamples:
+    doAssert toUpperAscii("FooBar!") == "FOOBAR!"
+  toImpl toUpperAscii
+
+func capitalizeAscii*(s: string): string {.rtl, extern: "nsuCapitalizeAscii".} =
+  ## Converts the first character of string `s` into upper case.
+  ##
+  ## This works only for the letters `A-Z`.
+  ## Use `Unicode module<unicode.html>`_ for UTF-8 support.
+  ##
+  ## See also:
+  ## * `toUpperAscii func<#toUpperAscii,char>`_
+  runnableExamples:
+    doAssert capitalizeAscii("foo") == "Foo"
+    doAssert capitalizeAscii("-bar") == "-bar"
+  if s.len == 0: result = ""
+  else: result = toUpperAscii(s[0]) & substr(s, 1)
+
+func nimIdentNormalize*(s: string): string =
+  ## Normalizes the string `s` as a Nim identifier.
+  ##
+  ## That means to convert to lower case and remove any '_' on all characters
+  ## except first one.
+  ##
+  ## .. Warning:: Backticks (`) are not handled: they remain *as is* and
+  ##    spaces are preserved. See `nimIdentBackticksNormalize
+  ##    <dochelpers.html#nimIdentBackticksNormalize,string>`_ for
+  ##    an alternative approach.
+  runnableExamples:
+    doAssert nimIdentNormalize("Foo_bar") == "Foobar"
+  result = newString(s.len)
+  if s.len == 0:
+    return
+  result[0] = s[0]
+  var j = 1
+  for i in 1..len(s) - 1:
+    if s[i] in UppercaseLetters:
+      result[j] = chr(ord(s[i]) + (ord('a') - ord('A')))
+      inc j
+    elif s[i] != '_':
+      result[j] = s[i]
+      inc j
+  if j != s.len: setLen(result, j)
 
-proc toLower*(c: Char): Char {.noSideEffect, procvar.}
-  ## Converts `c` into lower case. This works only for the letters A-Z.
-  ## See `unicode.toLower` for a version that works for any Unicode character.
+func normalize*(s: string): string {.rtl, extern: "nsuNormalize".} =
+  ## Normalizes the string `s`.
+  ##
+  ## That means to convert it to lower case and remove any '_'. This
+  ## should NOT be used to normalize Nim identifier names.
+  ##
+  ## See also:
+  ## * `toLowerAscii func<#toLowerAscii,string>`_
+  runnableExamples:
+    doAssert normalize("Foo_bar") == "foobar"
+    doAssert normalize("Foo Bar") == "foo bar"
+  result = newString(s.len)
+  var j = 0
+  for i in 0..len(s) - 1:
+    if s[i] in UppercaseLetters:
+      result[j] = chr(ord(s[i]) + (ord('a') - ord('A')))
+      inc j
+    elif s[i] != '_':
+      result[j] = s[i]
+      inc j
+  if j != s.len: setLen(result, j)
 
-proc toUpper*(s: string): string {.noSideEffect, procvar.}
-  ## Converts `s` into upper case. This works only for the letters a-z.
-  ## See `unicode.toUpper` for a version that works for any Unicode character.
+func cmpIgnoreCase*(a, b: string): int {.rtl, extern: "nsuCmpIgnoreCase".} =
+  ## Compares two strings in a case insensitive manner. Returns:
+  ##
+  ## | `0` if a == b
+  ## | `< 0` if a < b
+  ## | `> 0` if a > b
+  runnableExamples:
+    doAssert cmpIgnoreCase("FooBar", "foobar") == 0
+    doAssert cmpIgnoreCase("bar", "Foo") < 0
+    doAssert cmpIgnoreCase("Foo5", "foo4") > 0
+  cmpIgnoreCaseImpl(a, b)
+
+{.push checks: off, line_trace: off.} # this is a hot-spot in the compiler!
+                                      # thus we compile without checks here
+
+func cmpIgnoreStyle*(a, b: string): int {.rtl, extern: "nsuCmpIgnoreStyle".} =
+  ## Semantically the same as `cmp(normalize(a), normalize(b))`. It
+  ## is just optimized to not allocate temporary strings. This should
+  ## NOT be used to compare Nim identifier names.
+  ## Use `macros.eqIdent<macros.html#eqIdent,string,string>`_ for that.
+  ##
+  ## Returns:
+  ##
+  ## | `0` if a == b
+  ## | `< 0` if a < b
+  ## | `> 0` if a > b
+  runnableExamples:
+    doAssert cmpIgnoreStyle("foo_bar", "FooBar") == 0
+    doAssert cmpIgnoreStyle("foo_bar_5", "FooBar4") > 0
+  cmpIgnoreStyleImpl(a, b)
+{.pop.}
 
-proc toUpper*(c: Char): Char {.noSideEffect, procvar.}
-  ## Converts `c` into upper case. This works only for the letters a-z.
-  ## See `unicode.toUpper` for a version that works for any Unicode character.
+# --------- Private templates for different split separators -----------
 
-proc capitalize*(s: string): string {.noSideEffect, procvar.}
-  ## Converts the first character of `s` into upper case.
-  ## This works only for the letters a-z.
+func substrEq(s: string, pos: int, substr: string): bool =
+  # Always returns false for empty `substr`
+  var length = substr.len
+  if length > 0:
+    var i = 0
+    while i < length and pos+i < s.len and s[pos+i] == substr[i]:
+      inc i
+    i == length
+  else: false
 
-proc normalize*(s: string): string {.noSideEffect, procvar.}
-  ## Normalizes the string `s`. That means to convert it to lower case and
-  ## remove any '_'. This is needed for Nimrod identifiers for example.
+template stringHasSep(s: string, index: int, seps: set[char]): bool =
+  s[index] in seps
 
-proc find*(s, sub: string, start: int = 0): int {.noSideEffect.}
-  ## Searches for `sub` in `s` starting at position `start`. Searching is
-  ## case-sensitive. If `sub` is not in `s`, -1 is returned.
+template stringHasSep(s: string, index: int, sep: char): bool =
+  s[index] == sep
 
-proc find*(s: string, sub: char, start: int = 0): int {.noSideEffect.}
-  ## Searches for `sub` in `s` starting at position `start`. Searching is
-  ## case-sensitive. If `sub` is not in `s`, -1 is returned.
+template stringHasSep(s: string, index: int, sep: string): bool =
+  s.substrEq(index, sep)
 
-proc find*(s: string, chars: set[char], start: int = 0): int {.noSideEffect.}
-  ## Searches for `chars` in `s` starting at position `start`. If `s` contains
-  ## none of the characters in `chars`, -1 is returned.
+template splitCommon(s, sep, maxsplit, sepLen) =
+  ## Common code for split procs
+  var last = 0
+  var splits = maxsplit
 
-proc replaceStr*(s, sub, by: string): string {.noSideEffect, deprecated.}
-  ## Replaces `sub` in `s` by the string `by`.
-  ## **Deprecated since version 0.8.0**: Use `replace` instead.
+  while last <= len(s):
+    var first = last
+    while last < len(s) and not stringHasSep(s, last, sep):
+      inc(last)
+    if splits == 0: last = len(s)
+    yield substr(s, first, last-1)
+    if splits == 0: break
+    dec(splits)
+    inc(last, sepLen)
 
-proc replaceStr*(s: string, sub, by: char): string {.noSideEffect, deprecated.}
-  ## optimized version for characters.
-  ## **Deprecated since version 0.8.0**: Use `replace` instead.
+template oldSplit(s, seps, maxsplit) =
+  var last = 0
+  var splits = maxsplit
+  assert(not ('\0' in seps))
+  while last < len(s):
+    while last < len(s) and s[last] in seps: inc(last)
+    var first = last
+    while last < len(s) and s[last] notin seps: inc(last)
+    if first <= last-1:
+      if splits == 0: last = len(s)
+      yield substr(s, first, last-1)
+      if splits == 0: break
+      dec(splits)
 
-proc deleteStr*(s: var string, first, last: int) {.deprecated.}
-  ## Deletes in `s` the characters at position `first` .. `last`. This modifies
-  ## `s` itself, it does not return a copy.
-  ## **Deprecated since version 0.8.0**: Use `delete` instead.
+template accResult(iter: untyped) =
+  result = @[]
+  for x in iter: add(result, x)
 
-proc toOctal*(c: char): string
-  ## Converts a character `c` to its octal representation. The resulting
-  ## string may not have a leading zero. Its length is always exactly 3.
 
-iterator split*(s: string, seps: set[char] = Whitespace): string =
-  ## Splits the string `s` into substrings.
+iterator split*(s: string, sep: char, maxsplit: int = -1): string =
+  ## Splits the string `s` into substrings using a single separator.
+  ##
+  ## Substrings are separated by the character `sep`.
+  ## The code:
+  ##   ```nim
+  ##   for word in split(";;this;is;an;;example;;;", ';'):
+  ##     writeLine(stdout, word)
+  ##   ```
+  ## Results in:
+  ##   ```
+  ##   ""
+  ##   ""
+  ##   "this"
+  ##   "is"
+  ##   "an"
+  ##   ""
+  ##   "example"
+  ##   ""
+  ##   ""
+  ##   ""
+  ##   ```
+  ##
+  ## See also:
+  ## * `rsplit iterator<#rsplit.i,string,char,int>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `split func<#split,string,char,int>`_
+  splitCommon(s, sep, maxsplit, 1)
+
+iterator split*(s: string, seps: set[char] = Whitespace,
+                maxsplit: int = -1): string =
+  ## Splits the string `s` into substrings using a group of separators.
   ##
   ## Substrings are separated by a substring containing only `seps`.
-  ## Examples:
   ##
-  ## .. code-block:: nimrod
-  ##   for word in split("  this is an  example  "):
-  ##     writeln(stdout, word)
+  ##   ```nim
+  ##   for word in split("this\lis an\texample"):
+  ##     writeLine(stdout, word)
+  ##   ```
   ##
-  ## Results in:
+  ## ...generates this output:
   ##
-  ## .. code-block:: nimrod
+  ##   ```
   ##   "this"
   ##   "is"
   ##   "an"
   ##   "example"
+  ##   ```
   ##
-  ##   for word in split(";;this;is;an;;example;;;", {';'}):
-  ##     writeln(stdout, word)
+  ## And the following code:
   ##
-  ## produces the same output.
-  var last = 0
-  assert(not ('\0' in seps))
-  while last < len(s):
-    while s[last] in seps: inc(last)
-    var first = last
-    while last < len(s) and s[last] not_in seps: inc(last) # BUGFIX!
-    if first <= last-1:
-      yield copy(s, first, last-1)
-
-iterator split*(s: string, sep: char): string =
-  ## Splits the string `s` into substrings.
+  ##   ```nim
+  ##   for word in split("this:is;an$example", {';', ':', '$'}):
+  ##     writeLine(stdout, word)
+  ##   ```
   ##
-  ## Substrings are separated by the character `sep`.
-  ## Example:
+  ## ...produces the same output as the first example. The code:
   ##
-  ## .. code-block:: nimrod
-  ##   for word in split(";;this;is;an;;example;;;", ';'):
-  ##     writeln(stdout, word)
+  ##   ```nim
+  ##   let date = "2012-11-20T22:08:08.398990"
+  ##   let separators = {' ', '-', ':', 'T'}
+  ##   for number in split(date, separators):
+  ##     writeLine(stdout, number)
+  ##   ```
+  ##
+  ## ...results in:
+  ##
+  ##   ```
+  ##   "2012"
+  ##   "11"
+  ##   "20"
+  ##   "22"
+  ##   "08"
+  ##   "08.398990"
+  ##   ```
+  ##
+  ##  .. note:: Empty separator set results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `rsplit iterator<#rsplit.i,string,set[char],int>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `split func<#split,string,set[char],int>`_
+  splitCommon(s, seps, maxsplit, 1)
+
+iterator split*(s: string, sep: string, maxsplit: int = -1): string =
+  ## Splits the string `s` into substrings using a string separator.
+  ##
+  ## Substrings are separated by the string `sep`.
+  ## The code:
+  ##
+  ##   ```nim
+  ##   for word in split("thisDATAisDATAcorrupted", "DATA"):
+  ##     writeLine(stdout, word)
+  ##   ```
   ##
   ## Results in:
   ##
-  ## .. code-block:: nimrod
-  ##   ""
-  ##   ""
+  ##   ```
   ##   "this"
   ##   "is"
-  ##   "an"
-  ##   ""
-  ##   "example"
-  ##   ""
-  ##   ""
-  ##   ""
+  ##   "corrupted"
+  ##   ```
   ##
-  var last = 0
-  assert('\0' != sep)
-  if len(s) > 0:
-    # `<=` is correct here for the edge cases!
-    while last <= len(s):
-      var first = last
-      while last < len(s) and s[last] != sep: inc(last)
-      yield copy(s, first, last-1)
-      inc(last)
-
-iterator splitLines*(s: string): string =
-  ## Splits the string `s` into its containing lines. Every newline
-  ## combination (CR, LF, CR-LF) is supported. The result strings contain
-  ## no trailing ``\n``.
+  ##  .. note:: Empty separator string results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `rsplit iterator<#rsplit.i,string,string,int,bool>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `split func<#split,string,string,int>`_
+  let sepLen = if sep.len == 0: 1 # prevents infinite loop
+    else: sep.len
+  splitCommon(s, sep, maxsplit, sepLen)
+
+
+template rsplitCommon(s, sep, maxsplit, sepLen) =
+  ## Common code for rsplit functions
+  var
+    last = s.len - 1
+    first = last
+    splits = maxsplit
+    startPos = 0
+  # go to -1 in order to get separators at the beginning
+  while first >= -1:
+    while first >= 0 and not stringHasSep(s, first, sep):
+      dec(first)
+    if splits == 0:
+      # No more splits means set first to the beginning
+      first = -1
+    if first == -1:
+      startPos = 0
+    else:
+      startPos = first + sepLen
+    yield substr(s, startPos, last)
+    if splits == 0: break
+    dec(splits)
+    dec(first)
+    last = first
+
+iterator rsplit*(s: string, sep: char,
+                 maxsplit: int = -1): string =
+  ## Splits the string `s` into substrings from the right using a
+  ## string separator. Works exactly the same as `split iterator
+  ## <#split.i,string,char,int>`_ except in **reverse** order.
+  ##
+  ##   ```nim
+  ##   for piece in "foo:bar".rsplit(':'):
+  ##     echo piece
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```
+  ##   "bar"
+  ##   "foo"
+  ##   ```
+  ##
+  ## Substrings are separated from the right by the char `sep`.
+  ##
+  ## See also:
+  ## * `split iterator<#split.i,string,char,int>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `rsplit func<#rsplit,string,char,int>`_
+  rsplitCommon(s, sep, maxsplit, 1)
+
+iterator rsplit*(s: string, seps: set[char] = Whitespace,
+                 maxsplit: int = -1): string =
+  ## Splits the string `s` into substrings from the right using a
+  ## string separator. Works exactly the same as `split iterator
+  ## <#split.i,string,char,int>`_ except in **reverse** order.
+  ##
+  ##   ```nim
+  ##   for piece in "foo bar".rsplit(WhiteSpace):
+  ##     echo piece
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```
+  ##   "bar"
+  ##   "foo"
+  ##   ```
+  ##
+  ## Substrings are separated from the right by the set of chars `seps`
+  ##
+  ##  .. note:: Empty separator set results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `split iterator<#split.i,string,set[char],int>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `rsplit func<#rsplit,string,set[char],int>`_
+  rsplitCommon(s, seps, maxsplit, 1)
+
+iterator rsplit*(s: string, sep: string, maxsplit: int = -1,
+                 keepSeparators: bool = false): string =
+  ## Splits the string `s` into substrings from the right using a
+  ## string separator. Works exactly the same as `split iterator
+  ## <#split.i,string,string,int>`_ except in **reverse** order.
+  ##
+  ##   ```nim
+  ##   for piece in "foothebar".rsplit("the"):
+  ##     echo piece
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```
+  ##   "bar"
+  ##   "foo"
+  ##   ```
+  ##
+  ## Substrings are separated from the right by the string `sep`
+  ##
+  ##  .. note:: Empty separator string results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `split iterator<#split.i,string,string,int>`_
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `rsplit func<#rsplit,string,string,int>`_
+  let sepLen = if sep.len == 0: 1 # prevents infinite loop
+    else: sep.len
+  rsplitCommon(s, sep, maxsplit, sepLen)
+
+iterator splitLines*(s: string, keepEol = false): string =
+  ## Splits the string `s` into its containing lines.
+  ##
+  ## Every `character literal <manual.html#lexical-analysis-character-literals>`_
+  ## newline combination (CR, LF, CR-LF) is supported. The result strings
+  ## contain no trailing end of line characters unless the parameter `keepEol`
+  ## is set to `true`.
   ##
   ## Example:
   ##
-  ## .. code-block:: nimrod
-  ##   for line in lines("\nthis\nis\nan\n\nexample\n"):
-  ##     writeln(stdout, line)
+  ##   ```nim
+  ##   for line in splitLines("\nthis\nis\nan\n\nexample\n"):
+  ##     writeLine(stdout, line)
+  ##   ```
   ##
   ## Results in:
   ##
-  ## .. code-block:: nimrod
+  ##   ```nim
   ##   ""
   ##   "this"
   ##   "is"
@@ -224,426 +675,1574 @@ iterator splitLines*(s: string): string =
   ##   ""
   ##   "example"
   ##   ""
+  ##   ```
+  ##
+  ## See also:
+  ## * `splitWhitespace iterator<#splitWhitespace.i,string,int>`_
+  ## * `splitLines func<#splitLines,string>`_
   var first = 0
   var last = 0
+  var eolpos = 0
   while true:
-    while s[last] notin {'\0', '\c', '\l'}: inc(last)
-    yield copy(s, first, last-1)
-    # skip newlines:
-    if s[last] == '\l': inc(last)
-    elif s[last] == '\c':
-      inc(last)
+    while last < s.len and s[last] notin {'\c', '\l'}: inc(last)
+
+    eolpos = last
+    if last < s.len:
       if s[last] == '\l': inc(last)
-    else: break # was '\0'
+      elif s[last] == '\c':
+        inc(last)
+        if last < s.len and s[last] == '\l': inc(last)
+
+    yield substr(s, first, if keepEol: last-1 else: eolpos-1)
+
+    # no eol characters consumed means that the string is over
+    if eolpos == last:
+      break
+
     first = last
 
-proc splitLinesSeq*(s: string): seq[string] {.noSideEffect, deprecated.} =
-  ## The same as `splitLines`, but is a proc that returns a sequence 
-  ## of substrings.
-  ## **Deprecated since version 0.8.0**: Use `splitLines` instead.
-  accumulateResult(splitLines(s))
-
-proc splitSeq*(s: string, seps: set[char] = Whitespace): seq[string] {.
-  noSideEffect, deprecated.} =
-  ## The same as `split`, but is a proc that returns a sequence of substrings.
-  ## **Deprecated since version 0.8.0**: Use `split` instead.
-  accumulateResult(split(s, seps))
-
-proc splitSeq*(s: string, sep: char): seq[string] {.noSideEffect, 
-                                                    deprecated.} =
-  ## The same as `split`, but is a proc that returns a sequence of substrings.
-  ## **Deprecated since version 0.8.0**: Use `split` instead.
-  accumulateResult(split(s, sep))
-
-proc splitLines*(s: string): seq[string] {.noSideEffect.} =
-  ## The same as the `splitLines` iterator, but is a proc that returns a 
-  ## sequence of substrings.
-  accumulateResult(splitLines(s))
-
-proc split*(s: string, seps: set[char] = Whitespace): seq[string] {.
-  noSideEffect.} =
-  ## The same as the `split` iterator, but is a proc that returns a
-  ## sequence of substrings.
-  accumulateResult(split(s, seps))
-
-proc split*(s: string, sep: char): seq[string] {.noSideEffect.} =
-  ## The same as the `split` iterator, but is a proc that returns a sequence
-  ## of substrings.
-  accumulateResult(split(s, sep))
-
-proc cmpIgnoreCase*(a, b: string): int {.noSideEffect.}
-  ## Compares two strings in a case insensitive manner. Returns:
+iterator splitWhitespace*(s: string, maxsplit: int = -1): string =
+  ## Splits the string `s` at whitespace stripping leading and trailing
+  ## whitespace if necessary. If `maxsplit` is specified and is positive,
+  ## no more than `maxsplit` splits is made.
   ##
-  ## | 0 iff a == b
-  ## | < 0 iff a < b
-  ## | > 0 iff a > b
-
-proc cmpIgnoreStyle*(a, b: string): int {.noSideEffect.}
-  ## Compares two strings normalized (i.e. case and
-  ## underscores do not matter). Returns:
+  ## The following code:
+  ##
+  ##   ```nim
+  ##   let s = "  foo \t bar  baz  "
+  ##   for ms in [-1, 1, 2, 3]:
+  ##     echo "------ maxsplit = ", ms, ":"
+  ##     for item in s.splitWhitespace(maxsplit=ms):
+  ##       echo '"', item, '"'
+  ##   ```
+  ##
+  ## ...results in:
   ##
-  ## | 0 iff a == b
-  ## | < 0 iff a < b
-  ## | > 0 iff a > b
+  ##   ```
+  ##   ------ maxsplit = -1:
+  ##   "foo"
+  ##   "bar"
+  ##   "baz"
+  ##   ------ maxsplit = 1:
+  ##   "foo"
+  ##   "bar  baz  "
+  ##   ------ maxsplit = 2:
+  ##   "foo"
+  ##   "bar"
+  ##   "baz  "
+  ##   ------ maxsplit = 3:
+  ##   "foo"
+  ##   "bar"
+  ##   "baz"
+  ##   ```
+  ##
+  ## See also:
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  oldSplit(s, Whitespace, maxsplit)
 
-proc contains*(s: string, c: char): bool {.noSideEffect.}
-  ## Same as ``find(s, c) >= 0``.
 
-proc contains*(s, sub: string): bool {.noSideEffect.}
-  ## Same as ``find(s, sub) >= 0``.
 
-proc contains*(s: string, chars: set[char]): bool {.noSideEffect.}
-  ## Same as ``find(s, chars) >= 0``.
+func split*(s: string, sep: char, maxsplit: int = -1): seq[string] {.rtl,
+    extern: "nsuSplitChar".} =
+  ## The same as the `split iterator <#split.i,string,char,int>`_ (see its
+  ## documentation), but is a func that returns a sequence of substrings.
+  ##
+  ## See also:
+  ## * `split iterator <#split.i,string,char,int>`_
+  ## * `rsplit func<#rsplit,string,char,int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  runnableExamples:
+    doAssert "a,b,c".split(',') == @["a", "b", "c"]
+    doAssert "".split(' ') == @[""]
+  accResult(split(s, sep, maxsplit))
+
+func split*(s: string, seps: set[char] = Whitespace, maxsplit: int = -1): seq[
+    string] {.rtl, extern: "nsuSplitCharSet".} =
+  ## The same as the `split iterator <#split.i,string,set[char],int>`_ (see its
+  ## documentation), but is a func that returns a sequence of substrings.
+  ##
+  ##  .. note:: Empty separator set results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `split iterator <#split.i,string,set[char],int>`_
+  ## * `rsplit func<#rsplit,string,set[char],int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  runnableExamples:
+    doAssert "a,b;c".split({',', ';'}) == @["a", "b", "c"]
+    doAssert "".split({' '}) == @[""]
+    doAssert "empty seps return unsplit s".split({}) == @["empty seps return unsplit s"]
+  accResult(split(s, seps, maxsplit))
+
+func split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.rtl,
+    extern: "nsuSplitString".} =
+  ## Splits the string `s` into substrings using a string separator.
+  ##
+  ## Substrings are separated by the string `sep`. This is a wrapper around the
+  ## `split iterator <#split.i,string,string,int>`_.
+  ##
+  ##  .. note:: Empty separator string results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `split iterator <#split.i,string,string,int>`_
+  ## * `rsplit func<#rsplit,string,string,int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  runnableExamples:
+    doAssert "a,b,c".split(",") == @["a", "b", "c"]
+    doAssert "a man a plan a canal panama".split("a ") == @["", "man ", "plan ", "canal panama"]
+    doAssert "".split("Elon Musk") == @[""]
+    doAssert "a  largely    spaced sentence".split(" ") == @["a", "", "largely",
+        "", "", "", "spaced", "sentence"]
+    doAssert "a  largely    spaced sentence".split(" ", maxsplit = 1) == @["a", " largely    spaced sentence"]
+    doAssert "empty sep returns unsplit s".split("") == @["empty sep returns unsplit s"]
+  accResult(split(s, sep, maxsplit))
+
+func rsplit*(s: string, sep: char, maxsplit: int = -1): seq[string] {.rtl,
+    extern: "nsuRSplitChar".} =
+  ## The same as the `rsplit iterator <#rsplit.i,string,char,int>`_, but is a func
+  ## that returns a sequence of substrings in original order.
+  ##
+  ## A possible common use case for `rsplit` is path manipulation,
+  ## particularly on systems that don't use a common delimiter.
+  ##
+  ## For example, if a system had `#` as a delimiter, you could
+  ## do the following to get the tail of the path:
+  ##
+  ##   ```nim
+  ##   var tailSplit = rsplit("Root#Object#Method#Index", '#', maxsplit=1)
+  ##   ```
+  ##
+  ## Results in `tailSplit` containing:
+  ##
+  ##   ```nim
+  ##   @["Root#Object#Method", "Index"]
+  ##   ```
+  ##
+  ## See also:
+  ## * `rsplit iterator <#rsplit.i,string,char,int>`_
+  ## * `split func<#split,string,char,int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  accResult(rsplit(s, sep, maxsplit))
+  result.reverse()
+
+func rsplit*(s: string, seps: set[char] = Whitespace,
+             maxsplit: int = -1): seq[string]
+             {.rtl, extern: "nsuRSplitCharSet".} =
+  ## The same as the `rsplit iterator <#rsplit.i,string,set[char],int>`_, but is a
+  ## func that returns a sequence of substrings in original order.
+  ##
+  ## A possible common use case for `rsplit` is path manipulation,
+  ## particularly on systems that don't use a common delimiter.
+  ##
+  ## For example, if a system had `#` as a delimiter, you could
+  ## do the following to get the tail of the path:
+  ##
+  ##   ```nim
+  ##   var tailSplit = rsplit("Root#Object#Method#Index", {'#'}, maxsplit=1)
+  ##   ```
+  ##
+  ## Results in `tailSplit` containing:
+  ##
+  ##   ```nim
+  ##   @["Root#Object#Method", "Index"]
+  ##   ```
+  ##
+  ##  .. note:: Empty separator set results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `rsplit iterator <#rsplit.i,string,set[char],int>`_
+  ## * `split func<#split,string,set[char],int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  accResult(rsplit(s, seps, maxsplit))
+  result.reverse()
+
+func rsplit*(s: string, sep: string, maxsplit: int = -1): seq[string] {.rtl,
+    extern: "nsuRSplitString".} =
+  ## The same as the `rsplit iterator <#rsplit.i,string,string,int,bool>`_, but is a func
+  ## that returns a sequence of substrings in original order.
+  ##
+  ## A possible common use case for `rsplit` is path manipulation,
+  ## particularly on systems that don't use a common delimiter.
+  ##
+  ## For example, if a system had `#` as a delimiter, you could
+  ## do the following to get the tail of the path:
+  ##
+  ##   ```nim
+  ##   var tailSplit = rsplit("Root#Object#Method#Index", "#", maxsplit=1)
+  ##   ```
+  ##
+  ## Results in `tailSplit` containing:
+  ##
+  ##   ```nim
+  ##   @["Root#Object#Method", "Index"]
+  ##   ```
+  ##
+  ##  .. note:: Empty separator string results in returning an original string,
+  ##   following the interpretation "split by no element".
+  ##
+  ## See also:
+  ## * `rsplit iterator <#rsplit.i,string,string,int,bool>`_
+  ## * `split func<#split,string,string,int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  runnableExamples:
+    doAssert "a  largely    spaced sentence".rsplit(" ", maxsplit = 1) == @[
+        "a  largely    spaced", "sentence"]
+    doAssert "a,b,c".rsplit(",") == @["a", "b", "c"]
+    doAssert "a man a plan a canal panama".rsplit("a ") == @["", "man ",
+        "plan ", "canal panama"]
+    doAssert "".rsplit("Elon Musk") == @[""]
+    doAssert "a  largely    spaced sentence".rsplit(" ") == @["a", "",
+        "largely", "", "", "", "spaced", "sentence"]
+    doAssert "empty sep returns unsplit s".rsplit("") == @["empty sep returns unsplit s"]
+  accResult(rsplit(s, sep, maxsplit))
+  result.reverse()
+
+func splitLines*(s: string, keepEol = false): seq[string] {.rtl,
+    extern: "nsuSplitLines".} =
+  ## The same as the `splitLines iterator<#splitLines.i,string>`_ (see its
+  ## documentation), but is a func that returns a sequence of substrings.
+  ##
+  ## See also:
+  ## * `splitLines iterator<#splitLines.i,string>`_
+  ## * `splitWhitespace func<#splitWhitespace,string,int>`_
+  ## * `countLines func<#countLines,string>`_
+  accResult(splitLines(s, keepEol = keepEol))
+
+func splitWhitespace*(s: string, maxsplit: int = -1): seq[string] {.rtl,
+    extern: "nsuSplitWhitespace".} =
+  ## The same as the `splitWhitespace iterator <#splitWhitespace.i,string,int>`_
+  ## (see its documentation), but is a func that returns a sequence of substrings.
+  ##
+  ## See also:
+  ## * `splitWhitespace iterator <#splitWhitespace.i,string,int>`_
+  ## * `splitLines func<#splitLines,string>`_
+  accResult(splitWhitespace(s, maxsplit))
 
-proc toHex*(x: BiggestInt, len: int): string {.noSideEffect.}
-  ## Converts `x` to its hexadecimal representation. The resulting string
-  ## will be exactly `len` characters long. No prefix like ``0x``
-  ## is generated. `x` is treated as an unsigned value.
+func toBin*(x: BiggestInt, len: Positive): string {.rtl, extern: "nsuToBin".} =
+  ## Converts `x` into its binary representation.
+  ##
+  ## The resulting string is always `len` characters long. No leading `0b`
+  ## prefix is generated.
+  runnableExamples:
+    let
+      a = 29
+      b = 257
+    doAssert a.toBin(8) == "00011101"
+    doAssert b.toBin(8) == "00000001"
+    doAssert b.toBin(9) == "100000001"
+  var
+    mask = BiggestUInt 1
+    shift = BiggestUInt 0
+  assert(len > 0)
+  result = newString(len)
+  for j in countdown(len-1, 0):
+    result[j] = chr(int((BiggestUInt(x) and mask) shr shift) + ord('0'))
+    inc shift
+    mask = mask shl BiggestUInt(1)
 
-proc intToStr*(x: int, minchars: int = 1): string
-  ## Converts `x` to its decimal representation. The resulting string
-  ## will be minimally `minchars` characters long. This is achieved by
-  ## adding leading zeros.
+func toOct*(x: BiggestInt, len: Positive): string {.rtl, extern: "nsuToOct".} =
+  ## Converts `x` into its octal representation.
+  ##
+  ## The resulting string is always `len` characters long. No leading `0o`
+  ## prefix is generated.
+  ##
+  ## Do not confuse it with `toOctal func<#toOctal,char>`_.
+  runnableExamples:
+    let
+      a = 62
+      b = 513
+    doAssert a.toOct(3) == "076"
+    doAssert b.toOct(3) == "001"
+    doAssert b.toOct(5) == "01001"
+  var
+    mask = BiggestUInt 7
+    shift = BiggestUInt 0
+  assert(len > 0)
+  result = newString(len)
+  for j in countdown(len-1, 0):
+    result[j] = chr(int((BiggestUInt(x) and mask) shr shift) + ord('0'))
+    inc shift, 3
+    mask = mask shl BiggestUInt(3)
 
-proc ParseInt*(s: string): int {.noSideEffect, procvar.}
-  ## Parses a decimal integer value contained in `s`. If `s` is not
-  ## a valid integer, `EInvalidValue` is raised.
+func toHexImpl(x: BiggestUInt, len: Positive, handleNegative: bool): string =
+  const
+    HexChars = "0123456789ABCDEF"
+  var n = x
+  result = newString(len)
+  for j in countdown(len-1, 0):
+    result[j] = HexChars[int(n and 0xF)]
+    n = n shr 4
+    # handle negative overflow
+    if n == 0 and handleNegative: n = not(BiggestUInt 0)
 
-proc ParseBiggestInt*(s: string): biggestInt {.noSideEffect, procvar.}
-  ## Parses a decimal integer value contained in `s`. If `s` is not
-  ## a valid integer, `EInvalidValue` is raised.
+func toHex*[T: SomeInteger](x: T, len: Positive): string =
+  ## Converts `x` to its hexadecimal representation.
+  ##
+  ## The resulting string will be exactly `len` characters long. No prefix like
+  ## `0x` is generated. `x` is treated as an unsigned value.
+  runnableExamples:
+    let
+      a = 62'u64
+      b = 4097'u64
+    doAssert a.toHex(3) == "03E"
+    doAssert b.toHex(3) == "001"
+    doAssert b.toHex(4) == "1001"
+    doAssert toHex(62, 3) == "03E"
+    doAssert toHex(-8, 6) == "FFFFF8"
+  whenJsNoBigInt64:
+    toHexImpl(cast[BiggestUInt](x), len, x < 0)
+  do:
+    when T is SomeSignedInt:
+      toHexImpl(cast[BiggestUInt](BiggestInt(x)), len, x < 0)
+    else:
+      toHexImpl(BiggestUInt(x), len, x < 0)
+
+func toHex*[T: SomeInteger](x: T): string =
+  ## Shortcut for `toHex(x, T.sizeof * 2)`
+  runnableExamples:
+    doAssert toHex(1984'i64) == "00000000000007C0"
+    doAssert toHex(1984'i16) == "07C0"
+  whenJsNoBigInt64:
+    toHexImpl(cast[BiggestUInt](x), 2*sizeof(T), x < 0)
+  do:
+    when T is SomeSignedInt:
+      toHexImpl(cast[BiggestUInt](BiggestInt(x)), 2*sizeof(T), x < 0)
+    else:
+      toHexImpl(BiggestUInt(x), 2*sizeof(T), x < 0)
 
-proc ParseFloat*(s: string): float {.noSideEffect, procvar.}
-  ## Parses a decimal floating point value contained in `s`. If `s` is not
-  ## a valid floating point number, `EInvalidValue` is raised. ``NAN``,
-  ## ``INF``, ``-INF`` are also supported (case insensitive comparison).
+func toHex*(s: string): string {.rtl.} =
+  ## Converts a bytes string to its hexadecimal representation.
+  ##
+  ## The output is twice the input long. No prefix like
+  ## `0x` is generated.
+  ##
+  ## See also:
+  ## * `parseHexStr func<#parseHexStr,string>`_ for the reverse operation
+  runnableExamples:
+    let
+      a = "1"
+      b = "A"
+      c = "\0\255"
+    doAssert a.toHex() == "31"
+    doAssert b.toHex() == "41"
+    doAssert c.toHex() == "00FF"
+
+  const HexChars = "0123456789ABCDEF"
+  result = newString(s.len * 2)
+  for pos, c in s:
+    var n = ord(c)
+    result[pos * 2 + 1] = HexChars[n and 0xF]
+    n = n shr 4
+    result[pos * 2] = HexChars[n]
+
+func toOctal*(c: char): string {.rtl, extern: "nsuToOctal".} =
+  ## Converts a character `c` to its octal representation.
+  ##
+  ## The resulting string may not have a leading zero. Its length is always
+  ## exactly 3.
+  ##
+  ## Do not confuse it with `toOct func<#toOct,BiggestInt,Positive>`_.
+  runnableExamples:
+    doAssert toOctal('1') == "061"
+    doAssert toOctal('A') == "101"
+    doAssert toOctal('a') == "141"
+    doAssert toOctal('!') == "041"
 
-proc ParseHexInt*(s: string): int {.noSideEffect, procvar.} 
-  ## Parses a hexadecimal integer value contained in `s`. If `s` is not
-  ## a valid integer, `EInvalidValue` is raised. `s` can have one of the
-  ## following optional prefixes: ``0x``, ``0X``, ``#``. 
-  ## Underscores within `s` are ignored.
+  result = newString(3)
+  var val = ord(c)
+  for i in countdown(2, 0):
+    result[i] = chr(val mod 8 + ord('0'))
+    val = val div 8
 
-# the stringify and format operators:
-proc toString*[Ty](x: Ty): string {.deprecated.}
-  ## This generic proc is the same as the stringify operator `$`.
+func fromBin*[T: SomeInteger](s: string): T =
+  ## Parses a binary integer value from a string `s`.
+  ##
+  ## If `s` is not a valid binary integer, `ValueError` is raised. `s` can have
+  ## one of the following optional prefixes: `0b`, `0B`. Underscores within
+  ## `s` are ignored.
+  ##
+  ## Does not check for overflow. If the value represented by `s`
+  ## is too big to fit into a return type, only the value of the rightmost
+  ## binary digits of `s` is returned without producing an error.
+  runnableExamples:
+    let s = "0b_0100_1000_1000_1000_1110_1110_1001_1001"
+    doAssert fromBin[int](s) == 1216933529
+    doAssert fromBin[int8](s) == 0b1001_1001'i8
+    doAssert fromBin[int8](s) == -103'i8
+    doAssert fromBin[uint8](s) == 153
+    doAssert s.fromBin[:int16] == 0b1110_1110_1001_1001'i16
+    doAssert s.fromBin[:uint64] == 1216933529'u64
+
+  let p = parseutils.parseBin(s, result)
+  if p != s.len or p == 0:
+    raise newException(ValueError, "invalid binary integer: " & s)
+
+func fromOct*[T: SomeInteger](s: string): T =
+  ## Parses an octal integer value from a string `s`.
+  ##
+  ## If `s` is not a valid octal integer, `ValueError` is raised. `s` can have
+  ## one of the following optional prefixes: `0o`, `0O`. Underscores within
+  ## `s` are ignored.
+  ##
+  ## Does not check for overflow. If the value represented by `s`
+  ## is too big to fit into a return type, only the value of the rightmost
+  ## octal digits of `s` is returned without producing an error.
+  runnableExamples:
+    let s = "0o_123_456_777"
+    doAssert fromOct[int](s) == 21913087
+    doAssert fromOct[int8](s) == 0o377'i8
+    doAssert fromOct[int8](s) == -1'i8
+    doAssert fromOct[uint8](s) == 255'u8
+    doAssert s.fromOct[:int16] == 24063'i16
+    doAssert s.fromOct[:uint64] == 21913087'u64
+
+  let p = parseutils.parseOct(s, result)
+  if p != s.len or p == 0:
+    raise newException(ValueError, "invalid oct integer: " & s)
+
+func fromHex*[T: SomeInteger](s: string): T =
+  ## Parses a hex integer value from a string `s`.
   ##
-  ## **Deprecated since version 0.8.2:** Use `$` instead.
+  ## If `s` is not a valid hex integer, `ValueError` is raised. `s` can have
+  ## one of the following optional prefixes: `0x`, `0X`, `#`. Underscores within
+  ## `s` are ignored.
+  ##
+  ## Does not check for overflow. If the value represented by `s`
+  ## is too big to fit into a return type, only the value of the rightmost
+  ## hex digits of `s` is returned without producing an error.
+  runnableExamples:
+    let s = "0x_1235_8df6"
+    doAssert fromHex[int](s) == 305499638
+    doAssert fromHex[int8](s) == 0xf6'i8
+    doAssert fromHex[int8](s) == -10'i8
+    doAssert fromHex[uint8](s) == 246'u8
+    doAssert s.fromHex[:int16] == -29194'i16
+    doAssert s.fromHex[:uint64] == 305499638'u64
+
+  let p = parseutils.parseHex(s, result)
+  if p != s.len or p == 0:
+    raise newException(ValueError, "invalid hex integer: " & s)
+
+func intToStr*(x: int, minchars: Positive = 1): string {.rtl,
+    extern: "nsuIntToStr".} =
+  ## Converts `x` to its decimal representation.
+  ##
+  ## The resulting string will be minimally `minchars` characters long. This is
+  ## achieved by adding leading zeros.
+  runnableExamples:
+    doAssert intToStr(1984) == "1984"
+    doAssert intToStr(1984, 6) == "001984"
+  result = $abs(x)
+  for i in 1 .. minchars - len(result):
+    result = '0' & result
+  if x < 0:
+    result = '-' & result
+
+func parseInt*(s: string): int {.rtl, extern: "nsuParseInt".} =
+  ## Parses a decimal integer value contained in `s`.
+  ##
+  ## If `s` is not a valid integer, `ValueError` is raised.
+  runnableExamples:
+    doAssert parseInt("-0042") == -42
+  result = 0
+  let L = parseutils.parseInt(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid integer: " & s)
+
+func parseBiggestInt*(s: string): BiggestInt {.rtl,
+    extern: "nsuParseBiggestInt".} =
+  ## Parses a decimal integer value contained in `s`.
+  ##
+  ## If `s` is not a valid integer, `ValueError` is raised.
+  result = BiggestInt(0)
+  let L = parseutils.parseBiggestInt(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid integer: " & s)
+
+func parseUInt*(s: string): uint {.rtl, extern: "nsuParseUInt".} =
+  ## Parses a decimal unsigned integer value contained in `s`.
+  ##
+  ## If `s` is not a valid integer, `ValueError` is raised.
+  result = uint(0)
+  let L = parseutils.parseUInt(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid unsigned integer: " & s)
+
+func parseBiggestUInt*(s: string): BiggestUInt {.rtl,
+    extern: "nsuParseBiggestUInt".} =
+  ## Parses a decimal unsigned integer value contained in `s`.
+  ##
+  ## If `s` is not a valid integer, `ValueError` is raised.
+  result = BiggestUInt(0)
+  let L = parseutils.parseBiggestUInt(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid unsigned integer: " & s)
+
+func parseFloat*(s: string): float {.rtl, extern: "nsuParseFloat".} =
+  ## Parses a decimal floating point value contained in `s`.
+  ##
+  ## If `s` is not a valid floating point number, `ValueError` is raised.
+  ##`NAN`, `INF`, `-INF` are also supported (case insensitive comparison).
+  runnableExamples:
+    doAssert parseFloat("3.14") == 3.14
+    doAssert parseFloat("inf") == 1.0/0
+  result = 0.0
+  let L = parseutils.parseFloat(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid float: " & s)
+
+func parseBinInt*(s: string): int {.rtl, extern: "nsuParseBinInt".} =
+  ## Parses a binary integer value contained in `s`.
+  ##
+  ## If `s` is not a valid binary integer, `ValueError` is raised. `s` can have
+  ## one of the following optional prefixes: `0b`, `0B`. Underscores within
+  ## `s` are ignored.
+  runnableExamples:
+    let
+      a = "0b11_0101"
+      b = "111"
+    doAssert a.parseBinInt() == 53
+    doAssert b.parseBinInt() == 7
+
+  result = 0
+  let L = parseutils.parseBin(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid binary integer: " & s)
+
+func parseOctInt*(s: string): int {.rtl, extern: "nsuParseOctInt".} =
+  ## Parses an octal integer value contained in `s`.
+  ##
+  ## If `s` is not a valid oct integer, `ValueError` is raised. `s` can have one
+  ## of the following optional prefixes: `0o`, `0O`.  Underscores within
+  ## `s` are ignored.
+  result = 0
+  let L = parseutils.parseOct(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid oct integer: " & s)
+
+func parseHexInt*(s: string): int {.rtl, extern: "nsuParseHexInt".} =
+  ## Parses a hexadecimal integer value contained in `s`.
+  ##
+  ## If `s` is not a valid hex integer, `ValueError` is raised. `s` can have one
+  ## of the following optional prefixes: `0x`, `0X`, `#`.  Underscores
+  ## within `s` are ignored.
+  result = 0
+  let L = parseutils.parseHex(s, result, 0)
+  if L != s.len or L == 0:
+    raise newException(ValueError, "invalid hex integer: " & s)
+
+func generateHexCharToValueMap(): string =
+  ## Generates a string to map a hex digit to uint value.
+  result = ""
+  for inp in 0..255:
+    let ch = chr(inp)
+    let o =
+      case ch
+      of '0'..'9': inp - ord('0')
+      of 'a'..'f': inp - ord('a') + 10
+      of 'A'..'F': inp - ord('A') + 10
+      else: 17 # indicates an invalid hex char
+    result.add chr(o)
+
+const hexCharToValueMap = generateHexCharToValueMap()
+
+func parseHexStr*(s: string): string {.rtl, extern: "nsuParseHexStr".} =
+  ## Converts hex-encoded string to byte string, e.g.:
+  ##
+  ## Raises `ValueError` for an invalid hex values. The comparison is
+  ## case-insensitive.
+  ##
+  ## See also:
+  ## * `toHex func<#toHex,string>`_ for the reverse operation
+  runnableExamples:
+    let
+      a = "41"
+      b = "3161"
+      c = "00ff"
+    doAssert parseHexStr(a) == "A"
+    doAssert parseHexStr(b) == "1a"
+    doAssert parseHexStr(c) == "\0\255"
+
+  if s.len mod 2 != 0:
+    raise newException(ValueError, "Incorrect hex string len")
+  result = newString(s.len div 2)
+  var buf = 0
+  for pos, c in s:
+    let val = hexCharToValueMap[ord(c)].ord
+    if val == 17:
+      raise newException(ValueError, "Invalid hex char `" &
+                         c & "` (ord " & $c.ord & ")")
+    if pos mod 2 == 0:
+      buf = val
+    else:
+      result[pos div 2] = chr(val + buf shl 4)
 
-proc repeatChar*(count: int, c: Char = ' '): string
+func parseBool*(s: string): bool =
+  ## Parses a value into a `bool`.
+  ##
+  ## If `s` is one of the following values: `y, yes, true, 1, on`, then
+  ## returns `true`. If `s` is one of the following values: `n, no, false,
+  ## 0, off`, then returns `false`.  If `s` is something else a
+  ## `ValueError` exception is raised.
+  runnableExamples:
+    let a = "n"
+    doAssert parseBool(a) == false
+
+  case normalize(s)
+  of "y", "yes", "true", "1", "on": result = true
+  of "n", "no", "false", "0", "off": result = false
+  else: raise newException(ValueError, "cannot interpret as a bool: " & s)
+
+func parseEnum*[T: enum](s: string): T =
+  ## Parses an enum `T`. This errors at compile time, if the given enum
+  ## type contains multiple fields with the same string value.
+  ##
+  ## Raises `ValueError` for an invalid value in `s`. The comparison is
+  ## done in a style insensitive way (first letter is still case-sensitive).
+  runnableExamples:
+    type
+      MyEnum = enum
+        first = "1st",
+        second,
+        third = "3rd"
+
+    doAssert parseEnum[MyEnum]("1_st") == first
+    doAssert parseEnum[MyEnum]("second") == second
+    doAssertRaises(ValueError):
+      echo parseEnum[MyEnum]("third")
+
+  genEnumCaseStmt(T, s, default = nil, ord(low(T)), ord(high(T)), nimIdentNormalize)
+
+func parseEnum*[T: enum](s: string, default: T): T =
+  ## Parses an enum `T`. This errors at compile time, if the given enum
+  ## type contains multiple fields with the same string value.
+  ##
+  ## Uses `default` for an invalid value in `s`. The comparison is done in a
+  ## style insensitive way (first letter is still case-sensitive).
+  runnableExamples:
+    type
+      MyEnum = enum
+        first = "1st",
+        second,
+        third = "3rd"
+
+    doAssert parseEnum[MyEnum]("1_st") == first
+    doAssert parseEnum[MyEnum]("second") == second
+    doAssert parseEnum[MyEnum]("last", third) == third
+
+  genEnumCaseStmt(T, s, default, ord(low(T)), ord(high(T)), nimIdentNormalize)
+
+func repeat*(c: char, count: Natural): string {.rtl, extern: "nsuRepeatChar".} =
   ## Returns a string of length `count` consisting only of
   ## the character `c`.
+  runnableExamples:
+    let a = 'z'
+    doAssert a.repeat(5) == "zzzzz"
+  result = newString(count)
+  for i in 0..count-1: result[i] = c
 
-proc startsWith*(s, prefix: string): bool {.noSideEffect.}
-  ## Returns true iff ``s`` starts with ``prefix``.
-  ## If ``prefix == ""`` true is returned.
-
-proc endsWith*(s, suffix: string): bool {.noSideEffect.}
-  ## Returns true iff ``s`` ends with ``suffix``.
-  ## If ``suffix == ""`` true is returned.
+func repeat*(s: string, n: Natural): string {.rtl, extern: "nsuRepeatStr".} =
+  ## Returns string `s` concatenated `n` times.
+  runnableExamples:
+    doAssert "+ foo +".repeat(3) == "+ foo ++ foo ++ foo +"
 
-proc addSep*(dest: var string, sep = ", ", startLen = 0) {.noSideEffect,
-                                                           inline.} = 
-  ## A shorthand for: 
-  ## 
-  ## .. code-block:: nimrod
-  ##   if dest.len > startLen: add(dest, sep)
-  ## 
-  ## This is often useful for generating some code where the items need to
-  ## be *separated* by `sep`. `sep` is only added if `dest` is longer than
-  ## `startLen`. The following example creates a string describing
-  ## an array of integers:  
-  ## 
-  ## .. code-block:: nimrod
-  ##   var arr = "["
-  ##   for x in items([2, 3, 5, 7, 11]):
-  ##     addSep(arr, startLen=len("["))
-  ##     add(arr, $x)
-  ##   add(arr, "]")
-  if dest.len > startLen: add(dest, sep)
+  result = newStringOfCap(n * s.len)
+  for i in 1..n: result.add(s)
 
-proc allCharsInSet*(s: string, theSet: TCharSet): bool =
-  ## returns true iff each character of `s` is in the set `theSet`.
-  for c in items(s):
-    if c notin theSet: return false
-  return true
-
-proc quoteIfContainsWhite*(s: string): string =
-  ## returns ``'"' & s & '"'`` if `s` contains a space and does not
-  ## start with a quote, else returns `s`
-  if find(s, {' ', '\t'}) >= 0 and s[0] != '"':
-    result = '"' & s & '"'
+func spaces*(n: Natural): string {.inline.} =
+  ## Returns a string with `n` space characters. You can use this func
+  ## to left align strings.
+  ##
+  ## See also:
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  ## * `center func<#center,string,int,char>`_
+  runnableExamples:
+    let
+      width = 15
+      text1 = "Hello user!"
+      text2 = "This is a very long string"
+    doAssert text1 & spaces(max(0, width - text1.len)) & "|" ==
+             "Hello user!    |"
+    doAssert text2 & spaces(max(0, width - text2.len)) & "|" ==
+             "This is a very long string|"
+  repeat(' ', n)
+
+func align*(s: string, count: Natural, padding = ' '): string {.rtl,
+    extern: "nsuAlignString".} =
+  ## Aligns a string `s` with `padding`, so that it is of length `count`.
+  ##
+  ## `padding` characters (by default spaces) are added before `s` resulting in
+  ## right alignment. If `s.len >= count`, no spaces are added and `s` is
+  ## returned unchanged. If you need to left align a string use the `alignLeft
+  ## func<#alignLeft,string,Natural,char>`_.
+  ##
+  ## See also:
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  ## * `center func<#center,string,int,char>`_
+  runnableExamples:
+    assert align("abc", 4) == " abc"
+    assert align("a", 0) == "a"
+    assert align("1232", 6) == "  1232"
+    assert align("1232", 6, '#') == "##1232"
+  if s.len < count:
+    result = newString(count)
+    let spaces = count - s.len
+    for i in 0..spaces-1: result[i] = padding
+    for i in spaces..count-1: result[i] = s[i-spaces]
   else:
     result = s
 
-proc startsWith(s, prefix: string): bool =
-  var i = 0
-  while true:
-    if prefix[i] == '\0': return true
-    if s[i] != prefix[i]: return false
-    inc(i)
+func alignLeft*(s: string, count: Natural, padding = ' '): string =
+  ## Left-Aligns a string `s` with `padding`, so that it is of length `count`.
+  ##
+  ## `padding` characters (by default spaces) are added after `s` resulting in
+  ## left alignment. If `s.len >= count`, no spaces are added and `s` is
+  ## returned unchanged. If you need to right align a string use the `align
+  ## func<#align,string,Natural,char>`_.
+  ##
+  ## See also:
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  ## * `center func<#center,string,int,char>`_
+  runnableExamples:
+    assert alignLeft("abc", 4) == "abc "
+    assert alignLeft("a", 0) == "a"
+    assert alignLeft("1232", 6) == "1232  "
+    assert alignLeft("1232", 6, '#') == "1232##"
+  if s.len < count:
+    result = newString(count)
+    if s.len > 0:
+      result[0 .. (s.len - 1)] = s
+    for i in s.len ..< count:
+      result[i] = padding
+  else:
+    result = s
 
-proc endsWith(s, suffix: string): bool =
-  var
-    i = 0
-    j = len(s) - len(suffix)
-  while true:
-    if suffix[i] == '\0': return true
-    if s[i+j] != suffix[i]: return false
-    inc(i)
+func center*(s: string, width: int, fillChar: char = ' '): string {.rtl,
+    extern: "nsuCenterString".} =
+  ## Return the contents of `s` centered in a string `width` long using
+  ## `fillChar` (default: space) as padding.
+  ##
+  ## The original string is returned if `width` is less than or equal
+  ## to `s.len`.
+  ##
+  ## See also:
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  runnableExamples:
+    let a = "foo"
+    doAssert a.center(2) == "foo"
+    doAssert a.center(5) == " foo "
+    doAssert a.center(6) == " foo  "
+  if width <= s.len: return s
+  result = newString(width)
+  # Left padding will be one fillChar
+  # smaller if there are an odd number
+  # of characters
+  let
+    charsLeft = (width - s.len)
+    leftPadding = charsLeft div 2
+  for i in 0 ..< width:
+    if i >= leftPadding and i < leftPadding + s.len:
+      # we are where the string should be located
+      result[i] = s[i-leftPadding]
+    else:
+      # we are either before or after where
+      # the string s should go
+      result[i] = fillChar
 
-when false:
-  proc abbrev(s: string, possibilities: openarray[string]): int = 
-    ## returns the index of the first item in `possibilities` if not
-    ## ambiguous; -1 if no item has been found; -2 if multiple items
-    ## match.
-    result = -1 # none found
-    for i in 0..possibilities.len-1: 
-      if possibilities[i].startsWith(s): 
-        if result >= 0: return -2 # ambiguous
+func indent*(s: string, count: Natural, padding: string = " "): string {.rtl,
+    extern: "nsuIndent".} =
+  ## Indents each line in `s` by `count` amount of `padding`.
+  ##
+  ## **Note:** This does not preserve the new line characters used in `s`.
+  ##
+  ## See also:
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `unindent func<#unindent,string,Natural,string>`_
+  ## * `dedent func<#dedent,string,Natural>`_
+  runnableExamples:
+    doAssert indent("First line\c\l and second line.", 2) ==
+             "  First line\l   and second line."
+  result = ""
+  var i = 0
+  for line in s.splitLines():
+    if i != 0:
+      result.add("\n")
+    for j in 1..count:
+      result.add(padding)
+    result.add(line)
+    i.inc
+
+func unindent*(s: string, count: Natural = int.high,
+               padding: string = " "): string {.rtl, extern: "nsuUnindent".} =
+  ## Unindents each line in `s` by `count` amount of `padding`.
+  ##
+  ## **Note:** This does not preserve the new line characters used in `s`.
+  ##
+  ## See also:
+  ## * `dedent func<#dedent,string,Natural>`_
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  runnableExamples:
+    let x = """
+      Hello
+        There
+    """.unindent()
+
+    doAssert x == "Hello\nThere\n"
+  result = ""
+  var i = 0
+  for line in s.splitLines():
+    if i != 0:
+      result.add("\n")
+    var indentCount = 0
+    for j in 0..<count.int:
+      indentCount.inc
+      if j + padding.len-1 >= line.len or line[j .. j + padding.len-1] != padding:
+        indentCount = j
+        break
+    result.add(line[indentCount*padding.len .. ^1])
+    i.inc
+
+func indentation*(s: string): Natural {.since: (1, 3).} =
+  ## Returns the amount of indentation all lines of `s` have in common,
+  ## ignoring lines that consist only of whitespace.
+  result = int.high
+  for line in s.splitLines:
+    for i, c in line:
+      if i >= result: break
+      elif c != ' ':
         result = i
+        break
+  if result == int.high:
+    result = 0
+
+func dedent*(s: string, count: Natural = indentation(s)): string {.rtl,
+    extern: "nsuDedent", since: (1, 3).} =
+  ## Unindents each line in `s` by `count` amount of `padding`.
+  ## The only difference between this and the
+  ## `unindent func<#unindent,string,Natural,string>`_ is that this by default
+  ## only cuts off the amount of indentation that all lines of `s` share as
+  ## opposed to all indentation. It only supports spaces as padding.
+  ##
+  ## **Note:** This does not preserve the new line characters used in `s`.
+  ##
+  ## See also:
+  ## * `unindent func<#unindent,string,Natural,string>`_
+  ## * `align func<#align,string,Natural,char>`_
+  ## * `alignLeft func<#alignLeft,string,Natural,char>`_
+  ## * `spaces func<#spaces,Natural>`_
+  ## * `indent func<#indent,string,Natural,string>`_
+  runnableExamples:
+    let x = """
+      Hello
+        There
+    """.dedent()
+
+    doAssert x == "Hello\n  There\n"
+  unindent(s, count, " ")
+
+func delete*(s: var string, slice: Slice[int]) =
+  ## Deletes the items `s[slice]`, raising `IndexDefect` if the slice contains
+  ## elements out of range.
+  ##
+  ## This operation moves all elements after `s[slice]` in linear time, and
+  ## is the string analog to `sequtils.delete`.
+  runnableExamples:
+    var a = "abcde"
+    doAssertRaises(IndexDefect): a.delete(4..5)
+    assert a == "abcde"
+    a.delete(4..4)
+    assert a == "abcd"
+    a.delete(1..2)
+    assert a == "ad"
+    a.delete(1..<1) # empty slice
+    assert a == "ad"
+  when compileOption("boundChecks"):
+    if not (slice.a < s.len and slice.a >= 0 and slice.b < s.len):
+      raise newException(IndexDefect, $(slice: slice, len: s.len))
+  if slice.b >= slice.a:
+    var i = slice.a
+    var j = slice.b + 1
+    var newLen = s.len - j + i
+    # if j < s.len: moveMem(addr s[i], addr s[j], s.len - j) # pending benchmark
+    while i < newLen:
+      s[i] = s[j]
+      inc(i)
+      inc(j)
+    setLen(s, newLen)
 
-proc repeatChar(count: int, c: Char = ' '): string =
-  result = newString(count)
-  for i in 0..count-1:
-    result[i] = c
+func delete*(s: var string, first, last: int) {.rtl, extern: "nsuDelete",
+    deprecated: "use `delete(s, first..last)`".} =
+  ## Deletes in `s` the characters at positions `first .. last` (both ends included).
+  runnableExamples("--warning:deprecated:off"):
+    var a = "abracadabra"
 
-proc intToStr(x: int, minchars: int = 1): string =
-  result = $abs(x)
-  for i in 1 .. minchars - len(result):
-    result = '0' & result
-  if x < 0:
-    result = '-' & result
+    a.delete(4, 5)
+    doAssert a == "abradabra"
 
-proc toString[Ty](x: Ty): string = return $x
+    a.delete(1, 6)
+    doAssert a == "ara"
 
-proc toOctal(c: char): string =
-  result = newString(3)
-  var val = ord(c)
-  for i in countdown(2, 0):
-    result[i] = Chr(val mod 8 + ord('0'))
-    val = val div 8
+    a.delete(2, 999)
+    doAssert a == "ar"
 
-proc `%`(formatstr: string, a: string): string =
-  return formatstr % [a]
+  var i = first
+  var j = min(len(s), last+1)
+  var newLen = len(s)-j+i
+  while i < newLen:
+    s[i] = s[j]
+    inc(i)
+    inc(j)
+  setLen(s, newLen)
 
-proc findNormalized(x: string, inArray: openarray[string]): int =
+func startsWith*(s: string, prefix: char): bool {.inline.} =
+  ## Returns true if `s` starts with character `prefix`.
+  ##
+  ## See also:
+  ## * `endsWith func<#endsWith,string,char>`_
+  ## * `continuesWith func<#continuesWith,string,string,Natural>`_
+  ## * `removePrefix func<#removePrefix,string,char>`_
+  runnableExamples:
+    let a = "abracadabra"
+    doAssert a.startsWith('a') == true
+    doAssert a.startsWith('b') == false
+  result = s.len > 0 and s[0] == prefix
+
+func startsWith*(s, prefix: string): bool {.rtl, extern: "nsuStartsWith".} =
+  ## Returns true if `s` starts with string `prefix`.
+  ##
+  ## If `prefix == ""` true is returned.
+  ##
+  ## See also:
+  ## * `endsWith func<#endsWith,string,string>`_
+  ## * `continuesWith func<#continuesWith,string,string,Natural>`_
+  ## * `removePrefix func<#removePrefix,string,string>`_
+  runnableExamples:
+    let a = "abracadabra"
+    doAssert a.startsWith("abra") == true
+    doAssert a.startsWith("bra") == false
+  startsWithImpl(s, prefix)
+
+func endsWith*(s: string, suffix: char): bool {.inline.} =
+  ## Returns true if `s` ends with `suffix`.
+  ##
+  ## See also:
+  ## * `startsWith func<#startsWith,string,char>`_
+  ## * `continuesWith func<#continuesWith,string,string,Natural>`_
+  ## * `removeSuffix func<#removeSuffix,string,char>`_
+  runnableExamples:
+    let a = "abracadabra"
+    doAssert a.endsWith('a') == true
+    doAssert a.endsWith('b') == false
+  result = s.len > 0 and s[s.high] == suffix
+
+func endsWith*(s, suffix: string): bool {.rtl, extern: "nsuEndsWith".} =
+  ## Returns true if `s` ends with `suffix`.
+  ##
+  ## If `suffix == ""` true is returned.
+  ##
+  ## See also:
+  ## * `startsWith func<#startsWith,string,string>`_
+  ## * `continuesWith func<#continuesWith,string,string,Natural>`_
+  ## * `removeSuffix func<#removeSuffix,string,string>`_
+  runnableExamples:
+    let a = "abracadabra"
+    doAssert a.endsWith("abra") == true
+    doAssert a.endsWith("dab") == false
+  endsWithImpl(s, suffix)
+
+func continuesWith*(s, substr: string, start: Natural): bool {.rtl,
+    extern: "nsuContinuesWith".} =
+  ## Returns true if `s` continues with `substr` at position `start`.
+  ##
+  ## If `substr == ""` true is returned.
+  ##
+  ## See also:
+  ## * `startsWith func<#startsWith,string,string>`_
+  ## * `endsWith func<#endsWith,string,string>`_
+  runnableExamples:
+    let a = "abracadabra"
+    doAssert a.continuesWith("ca", 4) == true
+    doAssert a.continuesWith("ca", 5) == false
+    doAssert a.continuesWith("dab", 6) == true
   var i = 0
-  while i < high(inArray):
-    if cmpIgnoreStyle(x, inArray[i]) == 0: return i
-    inc(i, 2) # incrementing by 1 would probably result in a
-              # security hole ...
-  return -1
+  while true:
+    if i >= substr.len: return true
+    if i+start >= s.len or s[i+start] != substr[i]: return false
+    inc(i)
 
-proc addf(s: var string, formatstr: string, a: openarray[string]) =
-  const PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '\128'..'\255', '_'}
-  var i = 0
-  var num = 0
-  while i < len(formatstr):
-    if formatstr[i] == '$':
-      case formatstr[i+1] # again we use the fact that strings
-                          # are zero-terminated here
-      of '#':
-        add s, a[num]
-        inc i, 2
-        inc num
-      of '$':
-        add s, '$'
-        inc(i, 2)
-      of '1'..'9':
-        var j = 0
-        inc(i) # skip $
-        while formatstr[i] in {'0'..'9'}:
-          j = j * 10 + ord(formatstr[i]) - ord('0')
-          inc(i)
-        num = j
-        add s, a[j - 1]
-      of '{':
-        var j = i+1
-        while formatstr[j] notin {'\0', '}'}: inc(j)
-        var x = findNormalized(copy(formatstr, i+2, j-1), a)
-        if x >= 0 and x < high(a): add s, a[x+1]
-        else: raise newException(EInvalidValue, "invalid format string")
-        i = j+1
-      of 'a'..'z', 'A'..'Z', '\128'..'\255', '_':
-        var j = i+1
-        while formatstr[j] in PatternChars: inc(j)
-        var x = findNormalized(copy(formatstr, i+1, j-1), a)
-        if x >= 0 and x < high(a): add s, a[x+1]
-        else: raise newException(EInvalidValue, "invalid format string")
-        i = j
-      else: raise newException(EInvalidValue, "invalid format string")
-    else:
-      add s, formatstr[i]
-      inc(i)
-  
-proc `%`(formatstr: string, a: openarray[string]): string =
-  result = ""
-  addf(result, formatstr, a)
 
-proc cmpIgnoreCase(a, b: string): int =
-  var i = 0
-  while i < a.len and i < b.len:
-    result = ord(toLower(a[i])) - ord(toLower(b[i]))
-    if result != 0: return
-    inc(i)
-  result = a.len - b.len
+func removePrefix*(s: var string, chars: set[char] = Newlines) {.rtl,
+    extern: "nsuRemovePrefixCharSet".} =
+  ## Removes all characters from `chars` from the start of the string `s`
+  ## (in-place).
+  ##
+  ## See also:
+  ## * `removeSuffix func<#removeSuffix,string,set[char]>`_
+  runnableExamples:
+    var userInput = "\r\n*~Hello World!"
+    userInput.removePrefix
+    doAssert userInput == "*~Hello World!"
+    userInput.removePrefix({'~', '*'})
+    doAssert userInput == "Hello World!"
+
+    var otherInput = "?!?Hello!?!"
+    otherInput.removePrefix({'!', '?'})
+    doAssert otherInput == "Hello!?!"
+
+  var start = 0
+  while start < s.len and s[start] in chars: start += 1
+  if start > 0: s.delete(0..start - 1)
+
+func removePrefix*(s: var string, c: char) {.rtl,
+    extern: "nsuRemovePrefixChar".} =
+  ## Removes all occurrences of a single character (in-place) from the start
+  ## of a string.
+  ##
+  ## See also:
+  ## * `removeSuffix func<#removeSuffix,string,char>`_
+  ## * `startsWith func<#startsWith,string,char>`_
+  runnableExamples:
+    var ident = "pControl"
+    ident.removePrefix('p')
+    doAssert ident == "Control"
+  removePrefix(s, chars = {c})
+
+func removePrefix*(s: var string, prefix: string) {.rtl,
+    extern: "nsuRemovePrefixString".} =
+  ## Remove the first matching prefix (in-place) from a string.
+  ##
+  ## See also:
+  ## * `removeSuffix func<#removeSuffix,string,string>`_
+  ## * `startsWith func<#startsWith,string,string>`_
+  runnableExamples:
+    var answers = "yesyes"
+    answers.removePrefix("yes")
+    doAssert answers == "yes"
+  if s.startsWith(prefix) and prefix.len > 0:
+    s.delete(0..prefix.len - 1)
+
+func removeSuffix*(s: var string, chars: set[char] = Newlines) {.rtl,
+    extern: "nsuRemoveSuffixCharSet".} =
+  ## Removes all characters from `chars` from the end of the string `s`
+  ## (in-place).
+  ##
+  ## See also:
+  ## * `removePrefix func<#removePrefix,string,set[char]>`_
+  runnableExamples:
+    var userInput = "Hello World!*~\r\n"
+    userInput.removeSuffix
+    doAssert userInput == "Hello World!*~"
+    userInput.removeSuffix({'~', '*'})
+    doAssert userInput == "Hello World!"
+
+    var otherInput = "Hello!?!"
+    otherInput.removeSuffix({'!', '?'})
+    doAssert otherInput == "Hello"
+
+  if s.len == 0: return
+  var last = s.high
+  while last > -1 and s[last] in chars: last -= 1
+  s.setLen(last + 1)
+
+func removeSuffix*(s: var string, c: char) {.rtl,
+    extern: "nsuRemoveSuffixChar".} =
+  ## Removes all occurrences of a single character (in-place) from the end
+  ## of a string.
+  ##
+  ## See also:
+  ## * `removePrefix func<#removePrefix,string,char>`_
+  ## * `endsWith func<#endsWith,string,char>`_
+  runnableExamples:
+    var table = "users"
+    table.removeSuffix('s')
+    doAssert table == "user"
+
+    var dots = "Trailing dots......."
+    dots.removeSuffix('.')
+    doAssert dots == "Trailing dots"
+
+  removeSuffix(s, chars = {c})
+
+func removeSuffix*(s: var string, suffix: string) {.rtl,
+    extern: "nsuRemoveSuffixString".} =
+  ## Remove the first matching suffix (in-place) from a string.
+  ##
+  ## See also:
+  ## * `removePrefix func<#removePrefix,string,string>`_
+  ## * `endsWith func<#endsWith,string,string>`_
+  runnableExamples:
+    var answers = "yeses"
+    answers.removeSuffix("es")
+    doAssert answers == "yes"
+  var newLen = s.len
+  if s.endsWith(suffix):
+    newLen -= len(suffix)
+    s.setLen(newLen)
+
+
+func addSep*(dest: var string, sep = ", ", startLen: Natural = 0) {.inline.} =
+  ## Adds a separator to `dest` only if its length is bigger than `startLen`.
+  ##
+  ## A shorthand for:
+  ##
+  ##   ```nim
+  ##   if dest.len > startLen: add(dest, sep)
+  ##   ```
+  ##
+  ## This is often useful for generating some code where the items need to
+  ## be *separated* by `sep`. `sep` is only added if `dest` is longer than
+  ## `startLen`. The following example creates a string describing
+  ## an array of integers.
+  runnableExamples:
+    var arr = "["
+    for x in items([2, 3, 5, 7, 11]):
+      addSep(arr, startLen = len("["))
+      add(arr, $x)
+    add(arr, "]")
+    doAssert arr == "[2, 3, 5, 7, 11]"
 
+  if dest.len > startLen: add(dest, sep)
 
-{.push checks: off, line_trace: off .} # this is a hot-spot in the compiler!
-                                       # thus we compile without checks here
+func allCharsInSet*(s: string, theSet: set[char]): bool =
+  ## Returns true if every character of `s` is in the set `theSet`.
+  runnableExamples:
+    doAssert allCharsInSet("aeea", {'a', 'e'}) == true
+    doAssert allCharsInSet("", {'a', 'e'}) == true
 
-proc cmpIgnoreStyle(a, b: string): int =
-  var i = 0
-  var j = 0
-  while True:
-    while a[i] == '_': inc(i)
-    while b[j] == '_': inc(j) # BUGFIX: typo
-    var aa = toLower(a[i])
-    var bb = toLower(b[j])
-    result = ord(aa) - ord(bb)
-    if result != 0 or aa == '\0': break
-    inc(i)
-    inc(j)
+  for c in items(s):
+    if c notin theSet: return false
+  return true
 
-{.pop.}
+func abbrev*(s: string, possibilities: openArray[string]): int =
+  ## Returns the index of the first item in `possibilities` which starts
+  ## with `s`, if not ambiguous.
+  ##
+  ## Returns -1 if no item has been found and -2 if multiple items match.
+  runnableExamples:
+    doAssert abbrev("fac", ["college", "faculty", "industry"]) == 1
+    doAssert abbrev("foo", ["college", "faculty", "industry"]) == -1 # Not found
+    doAssert abbrev("fac", ["college", "faculty", "faculties"]) == -2 # Ambiguous
+    doAssert abbrev("college", ["college", "colleges", "industry"]) == 0
+
+  result = -1 # none found
+  for i in 0..possibilities.len-1:
+    if possibilities[i].startsWith(s):
+      if possibilities[i] == s:
+        # special case: exact match shouldn't be ambiguous
+        return i
+      if result >= 0: return -2 # ambiguous
+      result = i
 
 # ---------------------------------------------------------------------------
 
-proc join*(a: openArray[string], sep: string): string =
-  ## concatenates all strings in `a` separating them with `sep`.
+func join*(a: openArray[string], sep: string = ""): string {.rtl,
+    extern: "nsuJoinSep".} =
+  ## Concatenates all strings in the container `a`, separating them with `sep`.
+  runnableExamples:
+    doAssert join(["A", "B", "Conclusion"], " -> ") == "A -> B -> Conclusion"
+
   if len(a) > 0:
     var L = sep.len * (a.len-1)
     for i in 0..high(a): inc(L, a[i].len)
-    result = newString(L)
-    setLen(result, 0)
+    result = newStringOfCap(L)
     add(result, a[0])
     for i in 1..high(a):
       add(result, sep)
       add(result, a[i])
   else:
     result = ""
-  
-proc join*(a: openArray[string]): string =
-  ## concatenates all strings in `a`.
-  if len(a) > 0:
-    var L = 0
-    for i in 0..high(a): inc(L, a[i].len)
-    result = newString(L)
-    setLen(result, 0)
-    for i in 0..high(a): add(result, a[i])
-  else:
-    result = ""
 
-proc strip(s: string, leading = true, trailing = true): string =
-  const
-    chars: set[Char] = Whitespace
-  var
-    first = 0
-    last = len(s)-1
-  if leading: 
-    while s[first] in chars: inc(first)
-  if trailing:
-    while last >= 0 and s[last] in chars: dec(last)
-  result = copy(s, first, last)
+proc join*[T: not string](a: openArray[T], sep: string = ""): string =
+  ## Converts all elements in the container `a` to strings using `$`,
+  ## and concatenates them with `sep`.
+  runnableExamples:
+    doAssert join([1, 2, 3], " -> ") == "1 -> 2 -> 3"
 
-proc toLower(c: Char): Char =
-  if c in {'A'..'Z'}:
-    result = chr(ord(c) + (ord('a') - ord('A')))
-  else:
-    result = c
-
-proc toLower(s: string): string =
-  result = newString(len(s))
-  for i in 0..len(s) - 1:
-    result[i] = toLower(s[i])
-
-proc toUpper(c: Char): Char =
-  if c in {'a'..'z'}:
-    result = Chr(Ord(c) - (Ord('a') - Ord('A')))
-  else:
-    result = c
-
-proc toUpper(s: string): string =
-  result = newString(len(s))
-  for i in 0..len(s) - 1:
-    result[i] = toUpper(s[i])
-
-proc capitalize(s: string): string =
-  result = toUpper(s[0]) & copy(s, 1)
-
-proc normalize(s: string): string =
   result = ""
-  for i in 0..len(s) - 1:
-    if s[i] in {'A'..'Z'}:
-      add result, Chr(Ord(s[i]) + (Ord('a') - Ord('A')))
-    elif s[i] != '_':
-      add result, s[i]
+  for i, x in a:
+    if i > 0:
+      add(result, sep)
+    add(result, $x)
 
 type
-  TSkipTable = array[Char, int]
+  SkipTable* = array[char, int] ## Character table for efficient substring search.
 
-proc preprocessSub(sub: string, a: var TSkipTable) =
-  var m = len(sub)
-  for i in 0..0xff: a[chr(i)] = m+1
-  for i in 0..m-1: a[sub[i]] = m-i
+func initSkipTable*(a: var SkipTable, sub: string) {.rtl,
+    extern: "nsuInitSkipTable".} =
+  ## Initializes table `a` for efficient search of substring `sub`.
+  ##
+  ## See also:
+  ## * `initSkipTable func<#initSkipTable,string>`_
+  ## * `find func<#find,SkipTable,string,string,Natural,int>`_
+  # TODO: this should be the `default()` initializer for the type.
+  let m = len(sub)
+  fill(a, m)
+
+  for i in 0 ..< m - 1:
+    a[sub[i]] = m - 1 - i
+
+func initSkipTable*(sub: string): SkipTable {.noinit, rtl,
+    extern: "nsuInitNewSkipTable".} =
+  ## Returns a new table initialized for `sub`.
+  ##
+  ## See also:
+  ## * `initSkipTable func<#initSkipTable,SkipTable,string>`_
+  ## * `find func<#find,SkipTable,string,string,Natural,int>`_
+  initSkipTable(result, sub)
+
+func find*(a: SkipTable, s, sub: string, start: Natural = 0, last = -1): int {.
+    rtl, extern: "nsuFindStrA".} =
+  ## Searches for `sub` in `s` inside range `start..last` using preprocessed
+  ## table `a`. If `last` is unspecified, it defaults to `s.high` (the last
+  ## element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ##
+  ## See also:
+  ## * `initSkipTable func<#initSkipTable,string>`_
+  ## * `initSkipTable func<#initSkipTable,SkipTable,string>`_
+  let
+    last = if last < 0: s.high else: last
+    subLast = sub.len - 1
+
+  if subLast == -1:
+    # this was an empty needle string,
+    # we count this as match in the first possible position:
+    return start
+
+  # This is an implementation of the Boyer-Moore Horspool algorithms
+  # https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm
+  result = -1
+  var skip = start
+
+  while last - skip >= subLast:
+    var i = subLast
+    while s[skip + i] == sub[i]:
+      if i == 0:
+        return skip
+      dec i
+    inc skip, a[s[skip + subLast]]
+
+when not (defined(js) or defined(nimdoc) or defined(nimscript)):
+  func c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
+                importc: "memchr", header: "<string.h>".}
+  const hasCStringBuiltin = true
+else:
+  const hasCStringBuiltin = false
+
+func find*(s: string, sub: char, start: Natural = 0, last = -1): int {.rtl,
+    extern: "nsuFindChar".} =
+  ## Searches for `sub` in `s` inside range `start..last` (both ends included).
+  ## If `last` is unspecified or negative, it defaults to `s.high` (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `rfind func<#rfind,string,char,Natural,int>`_
+  ## * `replace func<#replace,string,char,char>`_
+  result = -1
+  let last = if last < 0: s.high else: last
+
+  template findImpl =
+    for i in int(start)..last:
+      if s[i] == sub:
+        return i
+
+  when nimvm:
+    findImpl()
+  else:
+    when hasCStringBuiltin:
+      let length = last-start+1
+      if length > 0:
+        let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](length))
+        if not found.isNil:
+          return cast[int](found) -% cast[int](s.cstring)
+    else:
+      findImpl()
 
-proc findAux(s, sub: string, start: int, a: TSkipTable): int =
-  # fast "quick search" algorithm:
-  var
-    m = len(sub)
-    n = len(s)
-  # search:
-  var j = start
-  while j <= n - m:
-    block match:
-      for k in 0..m-1:
-        if sub[k] != s[k+j]: break match
-      return j
-    inc(j, a[s[j+m]])
-  return -1
+func find*(s: string, chars: set[char], start: Natural = 0, last = -1): int {.
+    rtl, extern: "nsuFindCharSet".} =
+  ## Searches for `chars` in `s` inside range `start..last` (both ends included).
+  ## If `last` is unspecified or negative, it defaults to `s.high` (the last element).
+  ##
+  ## If `s` contains none of the characters in `chars`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `rfind func<#rfind,string,set[char],Natural,int>`_
+  ## * `multiReplace func<#multiReplace,string,varargs[]>`_
+  result = -1
+  let last = if last < 0: s.high else: last
+  for i in int(start)..last:
+    if s[i] in chars:
+      return i
+
+when defined(linux):
+  proc memmem(haystack: pointer, haystacklen: csize_t,
+              needle: pointer, needlelen: csize_t): pointer {.importc, header: """#define _GNU_SOURCE
+#include <string.h>""".}
+elif defined(bsd) or (defined(macosx) and not defined(ios)):
+  proc memmem(haystack: pointer, haystacklen: csize_t,
+              needle: pointer, needlelen: csize_t): pointer {.importc, header: "#include <string.h>".}
+
+func find*(s, sub: string, start: Natural = 0, last = -1): int {.rtl,
+    extern: "nsuFindStr".} =
+  ## Searches for `sub` in `s` inside range `start..last` (both ends included).
+  ## If `last` is unspecified or negative, it defaults to `s.high` (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `rfind func<#rfind,string,string,Natural,int>`_
+  ## * `replace func<#replace,string,string,string>`_
+  if sub.len > s.len - start: return -1
+  if sub.len == 1: return find(s, sub[0], start, last)
 
-proc find(s, sub: string, start: int = 0): int =
-  var a: TSkipTable
-  preprocessSub(sub, a)
-  result = findAux(s, sub, start, a)
+  template useSkipTable =
+    result = find(initSkipTable(sub), s, sub, start, last)
 
-proc find(s: string, sub: char, start: int = 0): int =
-  for i in start..len(s)-1:
+  when nimvm:
+    useSkipTable()
+  else:
+    when declared(memmem):
+      let subLen = sub.len
+      if last < 0 and start < s.len and subLen != 0:
+        let found = memmem(s[start].unsafeAddr, csize_t(s.len - start), sub.cstring, csize_t(subLen))
+        result = if not found.isNil:
+            cast[int](found) -% cast[int](s.cstring)
+          else:
+            -1
+      else:
+        useSkipTable()
+    else:
+      useSkipTable()
+
+func rfind*(s: string, sub: char, start: Natural = 0, last = -1): int {.rtl,
+    extern: "nsuRFindChar".} =
+  ## Searches for `sub` in `s` inside range `start..last` (both ends included)
+  ## in reverse -- starting at high indexes and moving lower to the first
+  ## character or `start`.  If `last` is unspecified, it defaults to `s.high`
+  ## (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `find func<#find,string,char,Natural,int>`_
+  let last = if last == -1: s.high else: last
+  for i in countdown(last, start):
     if sub == s[i]: return i
   return -1
- 
-proc find(s: string, chars: set[char], start: int = 0): int =
-  for i in start..s.len-1:
+
+func rfind*(s: string, chars: set[char], start: Natural = 0, last = -1): int {.
+    rtl, extern: "nsuRFindCharSet".} =
+  ## Searches for `chars` in `s` inside range `start..last` (both ends
+  ## included) in reverse -- starting at high indexes and moving lower to the
+  ## first character or `start`. If `last` is unspecified, it defaults to
+  ## `s.high` (the last element).
+  ##
+  ## If `s` contains none of the characters in `chars`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `find func<#find,string,set[char],Natural,int>`_
+  let last = if last == -1: s.high else: last
+  for i in countdown(last, start):
     if s[i] in chars: return i
-  return -1 
+  return -1
 
-proc contains(s: string, chars: set[char]): bool =
-  return find(s, chars) >= 0
+func rfind*(s, sub: string, start: Natural = 0, last = -1): int {.rtl,
+    extern: "nsuRFindStr".} =
+  ## Searches for `sub` in `s` inside range `start..last` (both ends included)
+  ## included) in reverse -- starting at high indexes and moving lower to the
+  ## first character or `start`. If `last` is unspecified, it defaults to
+  ## `s.high` (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Subtract `start` from the result for a `start`-origin index.
+  ##
+  ## See also:
+  ## * `find func<#find,string,string,Natural,int>`_
+  if sub.len == 0:
+    let rightIndex: Natural = if last < 0: s.len else: last
+    return max(start, rightIndex)
+  if sub.len > s.len - start:
+    return -1
+  let last = if last == -1: s.high else: last
+  result = 0
+  for i in countdown(last - sub.len + 1, start):
+    for j in 0..sub.len-1:
+      result = i
+      if sub[j] != s[i+j]:
+        result = -1
+        break
+    if result != -1: return
+  return -1
+
+
+func count*(s: string, sub: char): int {.rtl, extern: "nsuCountChar".} =
+  ## Counts the occurrences of the character `sub` in the string `s`.
+  ##
+  ## See also:
+  ## * `countLines func<#countLines,string>`_
+  result = 0
+  for c in s:
+    if c == sub: inc result
+
+func count*(s: string, subs: set[char]): int {.rtl,
+    extern: "nsuCountCharSet".} =
+  ## Counts the occurrences of the group of character `subs` in the string `s`.
+  ##
+  ## See also:
+  ## * `countLines func<#countLines,string>`_
+  doAssert card(subs) > 0
+  result = 0
+  for c in s:
+    if c in subs: inc result
+
+func count*(s: string, sub: string, overlapping: bool = false): int {.rtl,
+    extern: "nsuCountString".} =
+  ## Counts the occurrences of a substring `sub` in the string `s`.
+  ## Overlapping occurrences of `sub` only count when `overlapping`
+  ## is set to true (default: false).
+  ##
+  ## See also:
+  ## * `countLines func<#countLines,string>`_
+  doAssert sub.len > 0
+  result = 0
+  var i = 0
+  while true:
+    i = s.find(sub, i)
+    if i < 0: break
+    if overlapping: inc i
+    else: i += sub.len
+    inc result
+
+func countLines*(s: string): int {.rtl, extern: "nsuCountLines".} =
+  ## Returns the number of lines in the string `s`.
+  ##
+  ## This is the same as `len(splitLines(s))`, but much more efficient
+  ## because it doesn't modify the string creating temporary objects. Every
+  ## `character literal <manual.html#lexical-analysis-character-literals>`_
+  ## newline combination (CR, LF, CR-LF) is supported.
+  ##
+  ## In this context, a line is any string separated by a newline combination.
+  ## A line can be an empty string.
+  ##
+  ## See also:
+  ## * `splitLines func<#splitLines,string>`_
+  runnableExamples:
+    doAssert countLines("First line\l and second line.") == 2
+  result = 1
+  var i = 0
+  while i < s.len:
+    case s[i]
+    of '\c':
+      if i+1 < s.len and s[i+1] == '\l': inc i
+      inc result
+    of '\l': inc result
+    else: discard
+    inc i
 
-proc contains(s: string, c: char): bool =
-  return find(s, c) >= 0
 
-proc contains(s, sub: string): bool =
+func contains*(s, sub: string): bool =
+  ## Same as `find(s, sub) >= 0`.
+  ##
+  ## See also:
+  ## * `find func<#find,string,string,Natural,int>`_
   return find(s, sub) >= 0
 
-proc replace*(s, sub, by: string): string =
-  ## Replaces `sub` in `s` by the string `by`.
-  var a: TSkipTable
+func contains*(s: string, chars: set[char]): bool =
+  ## Same as `find(s, chars) >= 0`.
+  ##
+  ## See also:
+  ## * `find func<#find,string,set[char],Natural,int>`_
+  return find(s, chars) >= 0
+
+func replace*(s, sub: string, by = ""): string {.rtl,
+    extern: "nsuReplaceStr".} =
+  ## Replaces every occurrence of the string `sub` in `s` with the string `by`.
+  ##
+  ## See also:
+  ## * `find func<#find,string,string,Natural,int>`_
+  ## * `replace func<#replace,string,char,char>`_ for replacing
+  ##   single characters
+  ## * `replaceWord func<#replaceWord,string,string,string>`_
+  ## * `multiReplace func<#multiReplace,string,varargs[]>`_
   result = ""
-  preprocessSub(sub, a)
-  var i = 0
-  while true:
-    var j = findAux(s, sub, i, a)
-    if j < 0: break
-    add result, copy(s, i, j - 1)
-    add result, by
-    i = j + len(sub)
-  # copy the rest:
-  add result, copy(s, i)
-
-proc replace*(s: string, sub, by: char): string =
-  ## optimized version for characters.
+  let subLen = sub.len
+  if subLen == 0:
+    result = s
+  elif subLen == 1:
+    # when the pattern is a single char, we use a faster
+    # char-based search that doesn't need a skip table:
+    let c = sub[0]
+    let last = s.high
+    var i = 0
+    while true:
+      let j = find(s, c, i, last)
+      if j < 0: break
+      add result, substr(s, i, j - 1)
+      add result, by
+      i = j + subLen
+    # copy the rest:
+    add result, substr(s, i)
+  else:
+    var a = initSkipTable(sub)
+    let last = s.high
+    var i = 0
+    while true:
+      let j = find(a, s, sub, i, last)
+      if j < 0: break
+      add result, substr(s, i, j - 1)
+      add result, by
+      i = j + subLen
+    # copy the rest:
+    add result, substr(s, i)
+
+func replace*(s: string, sub, by: char): string {.rtl,
+    extern: "nsuReplaceChar".} =
+  ## Replaces every occurrence of the character `sub` in `s` with the character
+  ## `by`.
+  ##
+  ## Optimized version of `replace <#replace,string,string,string>`_ for
+  ## characters.
+  ##
+  ## See also:
+  ## * `find func<#find,string,char,Natural,int>`_
+  ## * `replaceWord func<#replaceWord,string,string,string>`_
+  ## * `multiReplace func<#multiReplace,string,varargs[]>`_
   result = newString(s.len)
   var i = 0
   while i < s.len:
@@ -651,136 +2250,144 @@ proc replace*(s: string, sub, by: char): string =
     else: result[i] = s[i]
     inc(i)
 
-proc delete*(s: var string, first, last: int) =
-  ## Deletes in `s` the characters at position `first`..`last`. This modifies
-  ## `s` itself, it does not return a copy.
-  var i = first
-  var j = last+1
-  var newLen = len(s)-j+i
-  while i < newLen:
-    s[i] = s[j]
-    inc(i)
-    inc(j)
-  setlen(s, newLen)
-
-proc replaceStr(s, sub, by: string): string = return replace(s, sub, by)
-proc replaceStr(s: string, sub, by: char): string = return replace(s, sub, by)
-proc deleteStr(s: var string, first, last: int) = delete(s, first, last)
-
-# parsing numbers:
-
-proc toHex(x: BiggestInt, len: int): string =
-  const
-    HexChars = "0123456789ABCDEF"
-  var
-    shift: BiggestInt
-  result = newString(len)
-  for j in countdown(len-1, 0):
-    result[j] = HexChars[toU32(x shr shift) and 0xF'i32]
-    shift = shift + 4
-
-proc parseInt(s: string): int =
-  var L = parseutils.parseInt(s, result, 0)
-  if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s)
-
-proc ParseBiggestInt(s: string): biggestInt =
-  var L = parseutils.parseBiggestInt(s, result, 0)
-  if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s)
-
-proc ParseOctInt*(s: string): int =
+func replaceWord*(s, sub: string, by = ""): string {.rtl,
+    extern: "nsuReplaceWord".} =
+  ## Replaces every occurrence of the string `sub` in `s` with the string `by`.
+  ##
+  ## Each occurrence of `sub` has to be surrounded by word boundaries
+  ## (comparable to `\b` in regular expressions), otherwise it is not
+  ## replaced.
+  if sub.len == 0: return s
+  const wordChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\128'..'\255'}
+  result = ""
+  var a = initSkipTable(sub)
   var i = 0
-  if s[i] == '0' and (s[i+1] == 'o' or s[i+1] == 'O'): inc(i, 2)
-  while true: 
-    case s[i]
-    of '_': inc(i)
-    of '0'..'7': 
-      result = result shl 3 or (ord(s[i]) - ord('0'))
-      inc(i)
-    of '\0': break
-    else: raise newException(EInvalidValue, "invalid integer: " & s)
-
-proc ParseHexInt(s: string): int = 
+  let last = s.high
+  let sublen = sub.len
+  if sublen > 0:
+    while true:
+      var j = find(a, s, sub, i, last)
+      if j < 0: break
+      # word boundary?
+      if (j == 0 or s[j-1] notin wordChars) and
+          (j+sub.len >= s.len or s[j+sub.len] notin wordChars):
+        add result, substr(s, i, j - 1)
+        add result, by
+        i = j + sublen
+      else:
+        add result, substr(s, i, j)
+        i = j + 1
+    # copy the rest:
+    add result, substr(s, i)
+
+func multiReplace*(s: string, replacements: varargs[(string, string)]): string =
+  ## Same as `replace<#replace,string,string,string>`_, but specialized for
+  ## doing multiple replacements in a single pass through the input string.
+  ##
+  ## `multiReplace` scans the input string from left to right and replaces the
+  ## matching substrings in the same order as passed in the argument list.
+  ##
+  ## The implications of the order of scanning the string and matching the
+  ## replacements:
+  ##   - In case of multiple matches at a given position, the earliest
+  ##     replacement is applied.
+  ##   - Overlaps are not handled. After performing a replacement, the scan
+  ##     continues from the character after the matched substring. If the
+  ##     resulting string then contains a possible match starting in a newly
+  ##     placed substring, the additional replacement is not performed.
+  ##
+  ## If the resulting string is not longer than the original input string,
+  ## only a single memory allocation is required.
+  ##
+  runnableExamples:
+    # Swapping occurrences of 'a' and 'b':
+    doAssert multireplace("abba", [("a", "b"), ("b", "a")]) == "baab"
+
+    # The second replacement ("ab") is matched and performed first, the scan then
+    # continues from 'c', so the "bc" replacement is never matched and thus skipped.
+    doAssert multireplace("abc", [("bc", "x"), ("ab", "_b")]) == "_bc"
+  result = newStringOfCap(s.len)
   var i = 0
-  if s[i] == '0' and (s[i+1] == 'x' or s[i+1] == 'X'): inc(i, 2)
-  elif s[i] == '#': inc(i)
-  while true: 
-    case s[i]
-    of '_': inc(i)
-    of '0'..'9': 
-      result = result shl 4 or (ord(s[i]) - ord('0'))
-      inc(i)
-    of 'a'..'f': 
-      result = result shl 4 or (ord(s[i]) - ord('a') + 10)
-      inc(i)
-    of 'A'..'F': 
-      result = result shl 4 or (ord(s[i]) - ord('A') + 10)
+  var fastChk: set[char] = {}
+  for sub, by in replacements.items:
+    if sub.len > 0:
+      # Include first character of all replacements
+      fastChk.incl sub[0]
+  while i < s.len:
+    block sIteration:
+      # Assume most chars in s are not candidates for any replacement operation
+      if s[i] in fastChk:
+        for sub, by in replacements.items:
+          if sub.len > 0 and s.continuesWith(sub, i):
+            add result, by
+            inc(i, sub.len)
+            break sIteration
+      # No matching replacement found
+      # copy current character from s
+      add result, s[i]
       inc(i)
-    of '\0': break
-    else: raise newException(EInvalidValue, "invalid integer: " & s)
 
-proc ParseFloat(s: string): float =
-  var L = parseutils.parseFloat(s, result, 0)
-  if L != s.len: raise newException(EInvalidValue, "invalid float: " & s)
 
-proc toOct*(x: BiggestInt, len: int): string =
-  ## converts `x` into its octal representation. The resulting string is
-  ## always `len` characters long. No leading ``0o`` prefix is generated.
-  var
-    mask: BiggestInt = 7
-    shift: BiggestInt = 0
-  assert(len > 0)
-  result = newString(len)
-  for j in countdown(len-1, 0):
-    result[j] = chr(int((x and mask) shr shift) + ord('0'))
-    shift = shift + 3
-    mask = mask shl 3
 
-proc toBin*(x: BiggestInt, len: int): string =
-  ## converts `x` into its binary representation. The resulting string is
-  ## always `len` characters long. No leading ``0b`` prefix is generated.
-  var
-    mask: BiggestInt = 1
-    shift: BiggestInt = 0
-  assert(len > 0)
-  result = newString(len)
-  for j in countdown(len-1, 0):
-    result[j] = chr(int((x and mask) shr shift) + ord('0'))
-    shift = shift + 1
-    mask = mask shl 1
-
-proc insertSep*(s: string, sep = '_', digits = 3): string = 
-  ## inserts the separator `sep` after `digits` digits from right to left.
-  ## Even though the algorithm works with any string `s`, it is only useful 
+func insertSep*(s: string, sep = '_', digits = 3): string {.rtl,
+    extern: "nsuInsertSep".} =
+  ## Inserts the separator `sep` after `digits` characters (default: 3)
+  ## from right to left.
+  ##
+  ## Even though the algorithm works with any string `s`, it is only useful
   ## if `s` contains a number.
-  ## Example: ``insertSep("1000000") == "1_000_000"`` 
-  var L = (s.len-1) div digits + s.len
-  result = newString(L)
+  runnableExamples:
+    doAssert insertSep("1000000") == "1_000_000"
+  result = newStringOfCap(s.len)
+  let hasPrefix = isDigit(s[s.low]) == false
+  var idx: int
+  if hasPrefix:
+    result.add s[s.low]
+    for i in (s.low + 1)..s.high:
+      idx = i
+      if not isDigit(s[i]):
+        result.add s[i]
+      else:
+        break
+  let partsLen = s.len - idx
+  var L = (partsLen-1) div digits + partsLen
+  result.setLen(L + idx)
   var j = 0
   dec(L)
-  for i in countdown(len(s)-1, 0): 
-    if j == digits: 
-      result[L] = sep
+  for i in countdown(partsLen-1, 0):
+    if j == digits:
+      result[L + idx] = sep
       dec(L)
       j = 0
-    result[L] = s[i]
+    result[L + idx] = s[i + idx]
     inc(j)
     dec(L)
 
-proc escape*(s: string, prefix = "\"", suffix = "\""): string =
-  ## Escapes a string `s`. This does these operations (at the same time):
-  ## * replaces any ``\`` by ``\\``
-  ## * replaces any ``'`` by ``\'``
-  ## * replaces any ``"`` by ``\"``
-  ## * replaces any other character in the set ``{'\0'..'\31', '\128'..'\255'}``
-  ##   by ``\xHH`` where ``HH`` is its hexadecimal value.
-  ## The procedure has been designed so that its output is usable for many
-  ## different common syntaxes. The resulting string is prefixed with
-  ## ``prefix`` and suffixed with ``suffix``. Both may be empty strings.
-  result = prefix
+func escape*(s: string, prefix = "\"", suffix = "\""): string {.rtl,
+    extern: "nsuEscape".} =
+  ## Escapes a string `s`.
+  ##
+  ## .. note:: The escaping scheme is different from
+  ##    `system.addEscapedChar`.
+  ##
+  ## * replaces `'\0'..'\31'` and `'\127'..'\255'` by `\xHH` where `HH` is its hexadecimal value
+  ## * replaces ``\`` by `\\`
+  ## * replaces `'` by `\'`
+  ## * replaces `"` by `\"`
+  ##
+  ## The resulting string is prefixed with `prefix` and suffixed with `suffix`.
+  ## Both may be empty strings.
+  ##
+  ## See also:
+  ## * `addEscapedChar proc<system.html#addEscapedChar,string,char>`_
+  ## * `unescape func<#unescape,string,string,string>`_ for the opposite
+  ##   operation
+  result = newStringOfCap(s.len + s.len shr 2)
+  result.add(prefix)
   for c in items(s):
     case c
-    of '\0'..'\31', '\128'..'\255':
-      add(result, '\\')
+    of '\0'..'\31', '\127'..'\255':
+      add(result, "\\x")
       add(result, toHex(ord(c), 2))
     of '\\': add(result, "\\\\")
     of '\'': add(result, "\\'")
@@ -788,127 +2395,638 @@ proc escape*(s: string, prefix = "\"", suffix = "\""): string =
     else: add(result, c)
   add(result, suffix)
 
-proc validEmailAddress*(s: string): bool = 
-  ## returns true if `s` seems to be a valid e-mail address. 
-  ## The checking also uses a domain list.
-  ## Note: This will be moved into another module soon.
-  const
-    chars = Letters + Digits + {'!','#','$','%','&',
-      '\'','*','+','/','=','?','^','_','`','{','}','|','~','-','.'}
-  var i = 0
-  if s[i] notin chars or s[i] == '.': return false
-  while s[i] in chars: 
-    if s[i] == '.' and s[i+1] == '.': return false
-    inc(i)
-  if s[i] != '@': return false
-  var j = len(s)-1
-  if s[j] notin letters: return false
-  while j >= i and s[j] in letters: dec(j)
-  inc(i) # skip '@'
-  while s[i] in {'0'..'9', 'a'..'z', '-', '.'}: inc(i) 
-  if s[i] != '\0': return false
-  
-  var x = copy(s, j+1)
-  if len(x) == 2 and x[0] in Letters and x[1] in Letters: return true
-  case toLower(x)
-  of "com", "org", "net", "gov", "mil", "biz", "info", "mobi", "name",
-     "aero", "jobs", "museum": return true
-  return false
-  
-proc validIdentifier*(s: string): bool = 
-  ## returns true if `s` is a valid identifier. A valid identifier starts
-  ## with a character of the set `IdentStartChars` and is followed by any
-  ## number of characters of the set `IdentChars`.
-  if s[0] in IdentStartChars:
+func unescape*(s: string, prefix = "\"", suffix = "\""): string {.rtl,
+    extern: "nsuUnescape".} =
+  ## Unescapes a string `s`.
+  ##
+  ## This complements `escape func<#escape,string,string,string>`_
+  ## as it performs the opposite operations.
+  ##
+  ## If `s` does not begin with `prefix` and end with `suffix` a
+  ## ValueError exception will be raised.
+  result = newStringOfCap(s.len)
+  var i = prefix.len
+  if not s.startsWith(prefix):
+    raise newException(ValueError,
+                       "String does not start with: " & prefix)
+  while true:
+    if i >= s.len-suffix.len: break
+    if s[i] == '\\':
+      if i+1 >= s.len:
+        result.add('\\')
+        break
+      case s[i+1]:
+      of 'x':
+        inc i, 2
+        var c = 0
+        i += parseutils.parseHex(s, c, i, maxLen = 2)
+        result.add(chr(c))
+        dec i, 2
+      of '\\':
+        result.add('\\')
+      of '\'':
+        result.add('\'')
+      of '\"':
+        result.add('\"')
+      else:
+        result.add("\\" & s[i+1])
+      inc(i, 2)
+    else:
+      result.add(s[i])
+      inc(i)
+  if not s.endsWith(suffix):
+    raise newException(ValueError,
+                       "String does not end in: " & suffix)
+
+func validIdentifier*(s: string): bool {.rtl, extern: "nsuValidIdentifier".} =
+  ## Returns true if `s` is a valid identifier.
+  ##
+  ## A valid identifier starts with a character of the set `IdentStartChars`
+  ## and is followed by any number of characters of the set `IdentChars`.
+  runnableExamples:
+    doAssert "abc_def08".validIdentifier
+
+  if s.len > 0 and s[0] in IdentStartChars:
     for i in 1..s.len-1:
       if s[i] notin IdentChars: return false
     return true
-  
-proc editDistance*(a, b: string): int =
-  ## returns the edit distance between `a` and `b`. This uses the Levenshtein
-  ## distance algorithm with only a linear memory overhead. This implementation
-  ## is highly optimized!
-  var len1 = a.len
-  var len2 = b.len
-  if len1 > len2:
-    # make `b` the longer string
-    return editDistance(b, a)
-
-  # strip common prefix:
-  var s = 0
-  while a[s] == b[s] and a[s] != '\0':
-    inc(s)
-    dec(len1)
-    dec(len2)
-  # strip common suffix:
-  while len1 > 0 and len2 > 0 and a[s+len1-1] == b[s+len2-1]:
-    dec(len1)
-    dec(len2)
-  # trivial cases:
-  if len1 == 0: return len2
-  if len2 == 0: return len1
-
-  # another special case:
-  if len1 == 1:
-    for j in s..len2-1:
-      if a[s] == b[j]: return len2 - 1
-    return len2
-
-  inc(len1)
-  inc(len2)
-  var half = len1 shr 1
-  # initalize first row:
-  #var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2 * sizeof(int)))
-  var row: seq[int]
-  newSeq(row, len2)
-  var e = s + len2 - 1 # end marker
-  for i in 1..len2 - half - 1: row[i] = i
-  row[0] = len1 - half - 1
-  for i in 1 .. len1 - 1:
-    var char1 = a[i + s - 1]
-    var char2p: int
-    var D, x: int
-    var p: int
-    if i >= len1 - half:
-      # skip the upper triangle:
-      var offset = i - len1 + half
-      char2p = offset
-      p = offset
-      var c3 = row[p] + ord(char1 != b[s + char2p])
-      inc(p)
-      inc(char2p)
-      x = row[p] + 1
-      D = x
-      if x > c3: x = c3
-      row[p] = x
-      inc(p)
+
+
+# floating point formatting:
+when not defined(js):
+  func c_snprintf(buf: cstring, n: csize_t, frmt: cstring): cint {.header: "<stdio.h>",
+                                     importc: "snprintf", varargs.}
+
+type
+  FloatFormatMode* = enum
+    ## The different modes of floating point formatting.
+    ffDefault,   ## use the shorter floating point notation
+    ffDecimal,   ## use decimal floating point notation
+    ffScientific ## use scientific notation (using `e` character)
+
+func formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault,
+                         precision: range[-1..32] = 16;
+                         decimalSep = '.'): string {.rtl, extern: "nsu$1".} =
+  ## Converts a floating point value `f` to a string.
+  ##
+  ## If `format == ffDecimal` then precision is the number of digits to
+  ## be printed after the decimal point.
+  ## If `format == ffScientific` then precision is the maximum number
+  ## of significant digits to be printed.
+  ## `precision`'s default value is the maximum number of meaningful digits
+  ## after the decimal point for Nim's `biggestFloat` type.
+  ##
+  ## If `precision == -1`, it tries to format it nicely.
+  runnableExamples:
+    let x = 123.456
+    doAssert x.formatBiggestFloat() == "123.4560000000000"
+    doAssert x.formatBiggestFloat(ffDecimal, 4) == "123.4560"
+    doAssert x.formatBiggestFloat(ffScientific, 2) == "1.23e+02"
+  when nimvm:
+    discard "implemented in the vmops"
+  else:
+    when defined(js):
+      var precision = precision
+      if precision == -1:
+        # use the same default precision as c_snprintf
+        precision = 6
+      var res: cstring
+      case format
+      of ffDefault:
+        {.emit: "`res` = `f`.toString();".}
+      of ffDecimal:
+        {.emit: "`res` = `f`.toFixed(`precision`);".}
+      of ffScientific:
+        {.emit: "`res` = `f`.toExponential(`precision`);".}
+      result = $res
+      if 1.0 / f == -Inf:
+        # JavaScript removes the "-" from negative Zero, add it back here
+        result = "-" & $res
+      for i in 0 ..< result.len:
+        # Depending on the locale either dot or comma is produced,
+        # but nothing else is possible:
+        if result[i] in {'.', ','}: result[i] = decimalSep
     else:
-      p = 1
-      char2p = 0
-      D = i
-      x = i
-    if i <= half + 1:
-      # skip the lower triangle:
-      e = len2 + i - half - 2
-    # main:
-    while p <= e:
-      dec(D)
-      var c3 = D + ord(char1 != b[char2p + s])
-      inc(char2p)
-      inc(x)
-      if x > c3: x = c3
-      D = row[p] + 1
-      if x > D: x = D
-      row[p] = x
-      inc(p)
-    # lower triangle sentinel:
-    if i <= half:
-      dec(D)
-      var c3 = D + ord(char1 != b[char2p + s])
-      inc(x)
-      if x > c3: x = c3
-      row[p] = x
-  result = row[e]
-  #dealloc(row)
+      const floatFormatToChar: array[FloatFormatMode, char] = ['g', 'f', 'e']
+      var
+        frmtstr {.noinit.}: array[0..5, char]
+        buf {.noinit.}: array[0..2500, char]
+        L: cint
+      frmtstr[0] = '%'
+      if precision >= 0:
+        frmtstr[1] = '#'
+        frmtstr[2] = '.'
+        frmtstr[3] = '*'
+        frmtstr[4] = floatFormatToChar[format]
+        frmtstr[5] = '\0'
+        L = c_snprintf(cast[cstring](addr buf), csize_t(2501), cast[cstring](addr frmtstr), precision, f)
+      else:
+        frmtstr[1] = floatFormatToChar[format]
+        frmtstr[2] = '\0'
+        L = c_snprintf(cast[cstring](addr buf), csize_t(2501), cast[cstring](addr frmtstr), f)
+      result = newString(L)
+      for i in 0 ..< L:
+        # Depending on the locale either dot or comma is produced,
+        # but nothing else is possible:
+        if buf[i] in {'.', ','}: result[i] = decimalSep
+        else: result[i] = buf[i]
+      when defined(windows):
+        # VS pre 2015 violates the C standard: "The exponent always contains at
+        # least two digits, and only as many more digits as necessary to
+        # represent the exponent." [C11 §7.21.6.1]
+        # The following post-processing fixes this behavior.
+        if result.len > 4 and result[^4] == '+' and result[^3] == '0':
+          result[^3] = result[^2]
+          result[^2] = result[^1]
+          result.setLen(result.len - 1)
+
+func formatFloat*(f: float, format: FloatFormatMode = ffDefault,
+                  precision: range[-1..32] = 16; decimalSep = '.'): string {.
+                  rtl, extern: "nsu$1".} =
+  ## Converts a floating point value `f` to a string.
+  ##
+  ## If `format == ffDecimal` then precision is the number of digits to
+  ## be printed after the decimal point.
+  ## If `format == ffScientific` then precision is the maximum number
+  ## of significant digits to be printed.
+  ## `precision`'s default value is the maximum number of meaningful digits
+  ## after the decimal point for Nim's `float` type.
+  ##
+  ## If `precision == -1`, it tries to format it nicely.
+  runnableExamples:
+    let x = 123.456
+    doAssert x.formatFloat() == "123.4560000000000"
+    doAssert x.formatFloat(ffDecimal, 4) == "123.4560"
+    doAssert x.formatFloat(ffScientific, 2) == "1.23e+02"
+
+  result = formatBiggestFloat(f, format, precision, decimalSep)
+
+func trimZeros*(x: var string; decimalSep = '.') =
+  ## Trim trailing zeros from a formatted floating point
+  ## value `x` (must be declared as `var`).
+  ##
+  ## This modifies `x` itself, it does not return a copy.
+  runnableExamples:
+    var x = "123.456000000"
+    x.trimZeros()
+    doAssert x == "123.456"
+
+  let sPos = find(x, decimalSep)
+  if sPos >= 0:
+    var last = find(x, 'e', start = sPos)
+    last = if last >= 0: last - 1 else: high(x)
+    var pos = last
+    while pos >= 0 and x[pos] == '0': dec(pos)
+    if pos > sPos: inc(pos)
+    if last >= pos:
+      x.delete(pos..last)
 
-{.pop.}
+type
+  BinaryPrefixMode* = enum ## The different names for binary prefixes.
+    bpIEC,                 # use the IEC/ISO standard prefixes such as kibi
+    bpColloquial           # use the colloquial kilo, mega etc
+
+func formatSize*(bytes: int64,
+                 decimalSep = '.',
+                 prefix = bpIEC,
+                 includeSpace = false): string =
+  ## Rounds and formats `bytes`.
+  ##
+  ## By default, uses the IEC/ISO standard binary prefixes, so 1024 will be
+  ## formatted as 1KiB.  Set prefix to `bpColloquial` to use the colloquial
+  ## names from the SI standard (e.g. k for 1000 being reused as 1024).
+  ##
+  ## `includeSpace` can be set to true to include the (SI preferred) space
+  ## between the number and the unit (e.g. 1 KiB).
+  ##
+  ## See also:
+  ## * `strformat module<strformat.html>`_ for string interpolation and formatting
+  runnableExamples:
+    doAssert formatSize((1'i64 shl 31) + (300'i64 shl 20)) == "2.293GiB"
+    doAssert formatSize((2.234*1024*1024).int) == "2.234MiB"
+    doAssert formatSize(4096, includeSpace = true) == "4 KiB"
+    doAssert formatSize(4096, prefix = bpColloquial, includeSpace = true) == "4 kB"
+    doAssert formatSize(4096) == "4KiB"
+    doAssert formatSize(5_378_934, prefix = bpColloquial, decimalSep = ',') == "5,13MB"
+
+  const iecPrefixes = ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi"]
+  const collPrefixes = ["", "k", "M", "G", "T", "P", "E", "Z", "Y"]
+  var
+    xb: int64 = bytes
+    fbytes: float
+    lastXb: int64 = bytes
+    matchedIndex = 0
+    prefixes: array[9, string]
+  if prefix == bpColloquial:
+    prefixes = collPrefixes
+  else:
+    prefixes = iecPrefixes
+
+  # Iterate through prefixes seeing if value will be greater than
+  # 0 in each case
+  for index in 1..<prefixes.len:
+    lastXb = xb
+    xb = bytes div (1'i64 shl (index*10))
+    matchedIndex = index
+    if xb == 0:
+      xb = lastXb
+      matchedIndex = index - 1
+      break
+  # xb has the integer number for the latest value; index should be correct
+  fbytes = bytes.float / (1'i64 shl (matchedIndex*10)).float
+  result = formatFloat(fbytes, format = ffDecimal, precision = 3,
+      decimalSep = decimalSep)
+  result.trimZeros(decimalSep)
+  if includeSpace:
+    result &= " "
+  result &= prefixes[matchedIndex]
+  result &= "B"
+
+func formatEng*(f: BiggestFloat,
+                precision: range[0..32] = 10,
+                trim: bool = true,
+                siPrefix: bool = false,
+                unit: string = "",
+                decimalSep = '.',
+                useUnitSpace = false): string =
+  ## Converts a floating point value `f` to a string using engineering notation.
+  ##
+  ## Numbers in of the range -1000.0<f<1000.0 will be formatted without an
+  ## exponent. Numbers outside of this range will be formatted as a
+  ## significand in the range -1000.0<f<1000.0 and an exponent that will always
+  ## be an integer multiple of 3, corresponding with the SI prefix scale k, M,
+  ## G, T etc for numbers with an absolute value greater than 1 and m, μ, n, p
+  ## etc for numbers with an absolute value less than 1.
+  ##
+  ## The default configuration (`trim=true` and `precision=10`) shows the
+  ## **shortest** form that precisely (up to a maximum of 10 decimal places)
+  ## displays the value. For example, 4.100000 will be displayed as 4.1 (which
+  ## is mathematically identical) whereas 4.1000003 will be displayed as
+  ## 4.1000003.
+  ##
+  ## If `trim` is set to true, trailing zeros will be removed; if false, the
+  ## number of digits specified by `precision` will always be shown.
+  ##
+  ## `precision` can be used to set the number of digits to be shown after the
+  ## decimal point or (if `trim` is true) the maximum number of digits to be
+  ## shown.
+  ##
+  ##   ```nim
+  ##    formatEng(0, 2, trim=false) == "0.00"
+  ##    formatEng(0, 2) == "0"
+  ##    formatEng(0.053, 0) == "53e-3"
+  ##    formatEng(52731234, 2) == "52.73e6"
+  ##    formatEng(-52731234, 2) == "-52.73e6"
+  ##    ```
+  ##
+  ## If `siPrefix` is set to true, the number will be displayed with the SI
+  ## prefix corresponding to the exponent. For example 4100 will be displayed
+  ## as "4.1 k" instead of "4.1e3". Note that `u` is used for micro- in place
+  ## of the greek letter mu (μ) as per ISO 2955. Numbers with an absolute
+  ## value outside of the range 1e-18<f<1000e18 (1a<f<1000E) will be displayed
+  ## with an exponent rather than an SI prefix, regardless of whether
+  ## `siPrefix` is true.
+  ##
+  ## If `useUnitSpace` is true, the provided unit will be appended to the string
+  ## (with a space as required by the SI standard). This behaviour is slightly
+  ## different to appending the unit to the result as the location of the space
+  ## is altered depending on whether there is an exponent.
+  ##
+  ##   ```nim
+  ##    formatEng(4100, siPrefix=true, unit="V") == "4.1 kV"
+  ##    formatEng(4.1, siPrefix=true, unit="V") == "4.1 V"
+  ##    formatEng(4.1, siPrefix=true) == "4.1" # Note lack of space
+  ##    formatEng(4100, siPrefix=true) == "4.1 k"
+  ##    formatEng(4.1, siPrefix=true, unit="") == "4.1 " # Space with unit=""
+  ##    formatEng(4100, siPrefix=true, unit="") == "4.1 k"
+  ##    formatEng(4100) == "4.1e3"
+  ##    formatEng(4100, unit="V") == "4.1e3 V"
+  ##    formatEng(4100, unit="", useUnitSpace=true) == "4.1e3 " # Space with useUnitSpace=true
+  ##    ```
+  ##
+  ## `decimalSep` is used as the decimal separator.
+  ##
+  ## See also:
+  ## * `strformat module<strformat.html>`_ for string interpolation and formatting
+  var
+    absolute: BiggestFloat
+    significand: BiggestFloat
+    fexponent: BiggestFloat
+    exponent: int
+    splitResult: seq[string]
+    suffix: string = ""
+  func getPrefix(exp: int): char =
+    ## Get the SI prefix for a given exponent
+    ##
+    ## Assumes exponent is a multiple of 3; returns ' ' if no prefix found
+    const siPrefixes = ['a', 'f', 'p', 'n', 'u', 'm', ' ', 'k', 'M', 'G', 'T',
+        'P', 'E']
+    var index: int = (exp div 3) + 6
+    result = ' '
+    if index in low(siPrefixes)..high(siPrefixes):
+      result = siPrefixes[index]
+
+  # Most of the work is done with the sign ignored, so get the absolute value
+  absolute = abs(f)
+  significand = f
+
+  if absolute == 0.0:
+    # Simple case: just format it and force the exponent to 0
+    exponent = 0
+    result = significand.formatBiggestFloat(ffDecimal, precision,
+        decimalSep = '.')
+  else:
+    # Find the best exponent that's a multiple of 3
+    fexponent = floor(log10(absolute))
+    fexponent = 3.0 * floor(fexponent / 3.0)
+    # Adjust the significand for the new exponent
+    significand /= pow(10.0, fexponent)
+
+    # Adjust the significand and check whether it has affected
+    # the exponent
+    absolute = abs(significand)
+    if absolute >= 1000.0:
+      significand *= 0.001
+      fexponent += 3
+    # Components of the result:
+    result = significand.formatBiggestFloat(ffDecimal, precision,
+        decimalSep = '.')
+    exponent = fexponent.int()
+
+  splitResult = result.split('.')
+  result = splitResult[0]
+  # result should have at most one decimal character
+  if splitResult.len() > 1:
+    # If trim is set, we get rid of trailing zeros.  Don't use trimZeros here as
+    # we can be a bit more efficient through knowledge that there will never be
+    # an exponent in this part.
+    if trim:
+      while splitResult[1].endsWith("0"):
+        # Trim last character
+        splitResult[1].setLen(splitResult[1].len-1)
+      if splitResult[1].len() > 0:
+        result &= decimalSep & splitResult[1]
+    else:
+      result &= decimalSep & splitResult[1]
+
+  # Combine the results accordingly
+  if siPrefix and exponent != 0:
+    var p = getPrefix(exponent)
+    if p != ' ':
+      suffix = " " & p
+      exponent = 0 # Exponent replaced by SI prefix
+  if suffix == "" and useUnitSpace:
+    suffix = " "
+  suffix &= unit
+  if exponent != 0:
+    result &= "e" & $exponent
+  result &= suffix
+
+func findNormalized(x: string, inArray: openArray[string]): int =
+  var i = 0
+  while i < high(inArray):
+    if cmpIgnoreStyle(x, inArray[i]) == 0: return i
+    inc(i, 2) # incrementing by 1 would probably lead to a
+              # security hole...
+  return -1
+
+func invalidFormatString(formatstr: string) {.noinline.} =
+  raise newException(ValueError, "invalid format string: " & formatstr)
+
+func addf*(s: var string, formatstr: string, a: varargs[string, `$`]) {.rtl,
+    extern: "nsuAddf".} =
+  ## The same as `add(s, formatstr % a)`, but more efficient.
+  const PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '\128'..'\255', '_'}
+  var i = 0
+  var num = 0
+  while i < len(formatstr):
+    if formatstr[i] == '$' and i+1 < len(formatstr):
+      case formatstr[i+1]
+      of '#':
+        if num > a.high: invalidFormatString(formatstr)
+        add s, a[num]
+        inc i, 2
+        inc num
+      of '$':
+        add s, '$'
+        inc(i, 2)
+      of '1'..'9', '-':
+        var j = 0
+        inc(i) # skip $
+        var negative = formatstr[i] == '-'
+        if negative: inc i
+        while i < formatstr.len and formatstr[i] in Digits:
+          j = j * 10 + ord(formatstr[i]) - ord('0')
+          inc(i)
+        let idx = if not negative: j-1 else: a.len-j
+        if idx < 0 or idx > a.high: invalidFormatString(formatstr)
+        add s, a[idx]
+      of '{':
+        var j = i+2
+        var k = 0
+        var negative = formatstr[j] == '-'
+        if negative: inc j
+        var isNumber = 0
+        while j < formatstr.len and formatstr[j] notin {'\0', '}'}:
+          if formatstr[j] in Digits:
+            k = k * 10 + ord(formatstr[j]) - ord('0')
+            if isNumber == 0: isNumber = 1
+          else:
+            isNumber = -1
+          inc(j)
+        if isNumber == 1:
+          let idx = if not negative: k-1 else: a.len-k
+          if idx < 0 or idx > a.high: invalidFormatString(formatstr)
+          add s, a[idx]
+        else:
+          var x = findNormalized(substr(formatstr, i+2, j-1), a)
+          if x >= 0 and x < high(a): add s, a[x+1]
+          else: invalidFormatString(formatstr)
+        i = j+1
+      of 'a'..'z', 'A'..'Z', '\128'..'\255', '_':
+        var j = i+1
+        while j < formatstr.len and formatstr[j] in PatternChars: inc(j)
+        var x = findNormalized(substr(formatstr, i+1, j-1), a)
+        if x >= 0 and x < high(a): add s, a[x+1]
+        else: invalidFormatString(formatstr)
+        i = j
+      else:
+        invalidFormatString(formatstr)
+    else:
+      add s, formatstr[i]
+      inc(i)
+
+func `%`*(formatstr: string, a: openArray[string]): string {.rtl,
+    extern: "nsuFormatOpenArray".} =
+  ## Interpolates a format string with the values from `a`.
+  ##
+  ## The `substitution`:idx: operator performs string substitutions in
+  ## `formatstr` and returns a modified `formatstr`. This is often called
+  ## `string interpolation`:idx:.
+  ##
+  ## This is best explained by an example:
+  ##
+  ##   ```nim
+  ##   "$1 eats $2." % ["The cat", "fish"]
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```nim
+  ##   "The cat eats fish."
+  ##   ```
+  ##
+  ## The substitution variables (the thing after the `$`) are enumerated
+  ## from 1 to `a.len`.
+  ## To produce a verbatim `$`, use `$$`.
+  ## The notation `$#` can be used to refer to the next substitution
+  ## variable:
+  ##
+  ##   ```nim
+  ##   "$# eats $#." % ["The cat", "fish"]
+  ##   ```
+  ##
+  ## Substitution variables can also be words (that is
+  ## `[A-Za-z_]+[A-Za-z0-9_]*`) in which case the arguments in `a` with even
+  ## indices are keys and with odd indices are the corresponding values.
+  ## An example:
+  ##
+  ##   ```nim
+  ##   "$animal eats $food." % ["animal", "The cat", "food", "fish"]
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```nim
+  ##   "The cat eats fish."
+  ##   ```
+  ##
+  ## The variables are compared with `cmpIgnoreStyle`. `ValueError` is
+  ## raised if an ill-formed format string has been passed to the `%` operator.
+  ##
+  ## See also:
+  ## * `strformat module<strformat.html>`_ for string interpolation and formatting
+  result = newStringOfCap(formatstr.len + a.len shl 4)
+  addf(result, formatstr, a)
+
+func `%`*(formatstr, a: string): string {.rtl,
+    extern: "nsuFormatSingleElem".} =
+  ## This is the same as `formatstr % [a]` (see
+  ## `% func<#%25,string,openArray[string]>`_).
+  result = newStringOfCap(formatstr.len + a.len)
+  addf(result, formatstr, [a])
+
+func format*(formatstr: string, a: varargs[string, `$`]): string {.rtl,
+    extern: "nsuFormatVarargs".} =
+  ## This is the same as `formatstr % a` (see
+  ## `% func<#%25,string,openArray[string]>`_) except that it supports
+  ## auto stringification.
+  ##
+  ## See also:
+  ## * `strformat module<strformat.html>`_ for string interpolation and formatting
+  result = newStringOfCap(formatstr.len + a.len)
+  addf(result, formatstr, a)
+
+
+func strip*(s: string, leading = true, trailing = true,
+            chars: set[char] = Whitespace): string {.rtl, extern: "nsuStrip".} =
+  ## Strips leading or trailing `chars` (default: whitespace characters)
+  ## from `s` and returns the resulting string.
+  ##
+  ## If `leading` is true (default), leading `chars` are stripped.
+  ## If `trailing` is true (default), trailing `chars` are stripped.
+  ## If both are false, the string is returned unchanged.
+  ##
+  ## See also:
+  ## * `strip proc<strbasics.html#strip,string,set[char]>`_ Inplace version.
+  ## * `stripLineEnd func<#stripLineEnd,string>`_
+  runnableExamples:
+    let a = "  vhellov   "
+    let b = strip(a)
+    doAssert b == "vhellov"
+
+    doAssert a.strip(leading = false) == "  vhellov"
+    doAssert a.strip(trailing = false) == "vhellov   "
+
+    doAssert b.strip(chars = {'v'}) == "hello"
+    doAssert b.strip(leading = false, chars = {'v'}) == "vhello"
+
+    let c = "blaXbla"
+    doAssert c.strip(chars = {'b', 'a'}) == "laXbl"
+    doAssert c.strip(chars = {'b', 'a', 'l'}) == "X"
+
+  var
+    first = 0
+    last = len(s)-1
+  if leading:
+    while first <= last and s[first] in chars: inc(first)
+  if trailing:
+    while last >= first and s[last] in chars: dec(last)
+  result = substr(s, first, last)
+
+func stripLineEnd*(s: var string) =
+  ## Strips one of these suffixes from `s` in-place:
+  ## `\r, \n, \r\n, \f, \v` (at most once instance).
+  ## For example, can be useful in conjunction with `osproc.execCmdEx`.
+  ## aka: `chomp`:idx:
+  runnableExamples:
+    var s = "foo\n\n"
+    s.stripLineEnd
+    doAssert s == "foo\n"
+    s = "foo\r\n"
+    s.stripLineEnd
+    doAssert s == "foo"
+
+  if s.len > 0:
+    case s[^1]
+    of '\n':
+      if s.len > 1 and s[^2] == '\r':
+        s.setLen s.len-2
+      else:
+        s.setLen s.len-1
+    of '\r', '\v', '\f':
+      s.setLen s.len-1
+    else:
+      discard
+
+
+iterator tokenize*(s: string, seps: set[char] = Whitespace): tuple[
+  token: string, isSep: bool] =
+  ## Tokenizes the string `s` into substrings.
+  ##
+  ## Substrings are separated by a substring containing only `seps`.
+  ## Example:
+  ##
+  ##   ```nim
+  ##   for word in tokenize("  this is an  example  "):
+  ##     writeLine(stdout, word)
+  ##   ```
+  ##
+  ## Results in:
+  ##
+  ##   ```nim
+  ##   ("  ", true)
+  ##   ("this", false)
+  ##   (" ", true)
+  ##   ("is", false)
+  ##   (" ", true)
+  ##   ("an", false)
+  ##   ("  ", true)
+  ##   ("example", false)
+  ##   ("  ", true)
+  ##   ```
+  var i = 0
+  while true:
+    var j = i
+    var isSep = j < s.len and s[j] in seps
+    while j < s.len and (s[j] in seps) == isSep: inc(j)
+    if j > i:
+      yield (substr(s, i, j-1), isSep)
+    else:
+      break
+    i = j
+
+func isEmptyOrWhitespace*(s: string): bool {.rtl,
+    extern: "nsuIsEmptyOrWhitespace".} =
+  ## Checks if `s` is empty or consists entirely of whitespace characters.
+  result = s.allCharsInSet(Whitespace)
diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim
new file mode 100644
index 000000000..90ba20c13
--- /dev/null
+++ b/lib/pure/sugar.nim
@@ -0,0 +1,429 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements nice syntactic sugar based on Nim's
+## macro system.
+
+import std/private/since
+import std/macros
+
+proc checkPragma(ex, prag: var NimNode) =
+  since (1, 3):
+    if ex.kind == nnkPragmaExpr:
+      prag = ex[1]
+      ex = ex[0]
+
+proc createProcType(p, b: NimNode): NimNode =
+  result = newNimNode(nnkProcTy)
+  var
+    formalParams = newNimNode(nnkFormalParams).add(b)
+    p = p
+    prag = newEmptyNode()
+
+  checkPragma(p, prag)
+
+  case p.kind
+  of nnkPar, nnkTupleConstr:
+    for i in 0 ..< p.len:
+      let ident = p[i]
+      var identDefs = newNimNode(nnkIdentDefs)
+      case ident.kind
+      of nnkExprColonExpr:
+        identDefs.add ident[0]
+        identDefs.add ident[1]
+      else:
+        identDefs.add newIdentNode("i" & $i)
+        identDefs.add(ident)
+      identDefs.add newEmptyNode()
+      formalParams.add identDefs
+  else:
+    var identDefs = newNimNode(nnkIdentDefs)
+    identDefs.add newIdentNode("i0")
+    identDefs.add(p)
+    identDefs.add newEmptyNode()
+    formalParams.add identDefs
+
+  result.add formalParams
+  result.add prag
+
+macro `=>`*(p, b: untyped): untyped =
+  ## Syntax sugar for anonymous procedures. It also supports pragmas.
+  ##
+  ## .. warning:: Semicolons can not be used to separate procedure arguments.
+  runnableExamples:
+    proc passTwoAndTwo(f: (int, int) -> int): int = f(2, 2)
+
+    assert passTwoAndTwo((x, y) => x + y) == 4
+
+    type
+      Bot = object
+        call: (string {.noSideEffect.} -> string)
+
+    var myBot = Bot()
+
+    myBot.call = (name: string) {.noSideEffect.} => "Hello " & name & ", I'm a bot."
+    assert myBot.call("John") == "Hello John, I'm a bot."
+
+    let f = () => (discard) # simplest proc that returns void
+    f()
+
+  var
+    params = @[ident"auto"]
+    name = newEmptyNode()
+    kind = nnkLambda
+    pragma = newEmptyNode()
+    p = p
+
+  checkPragma(p, pragma)
+
+  if p.kind == nnkInfix and p[0].kind == nnkIdent and p[0].eqIdent"->":
+    params[0] = p[2]
+    p = p[1]
+
+  checkPragma(p, pragma) # check again after -> transform
+
+  case p.kind
+  of nnkPar, nnkTupleConstr:
+    var untypedBeforeColon = 0
+    for i, c in p:
+      var identDefs = newNimNode(nnkIdentDefs)
+      case c.kind
+      of nnkExprColonExpr:
+        let t = c[1]
+        since (1, 3):
+          # + 1 here because of return type in params
+          for j in (i - untypedBeforeColon + 1) .. i:
+            params[j][1] = t
+        untypedBeforeColon = 0
+        identDefs.add(c[0])
+        identDefs.add(t)
+        identDefs.add(newEmptyNode())
+      of nnkIdent:
+        identDefs.add(c)
+        identDefs.add(newIdentNode("auto"))
+        identDefs.add(newEmptyNode())
+        inc untypedBeforeColon
+      of nnkInfix:
+        if c[0].kind == nnkIdent and c[0].eqIdent"->":
+          var procTy = createProcType(c[1], c[2])
+          params[0] = procTy[0][0]
+          for i in 1 ..< procTy[0].len:
+            params.add(procTy[0][i])
+        else:
+          error("Expected proc type (->) got (" & c[0].strVal & ").", c)
+        break
+      else:
+        error("Incorrect procedure parameter.", c)
+      params.add(identDefs)
+  of nnkIdent, nnkOpenSymChoice, nnkClosedSymChoice, nnkSym:
+    var identDefs = newNimNode(nnkIdentDefs)
+    identDefs.add(ident $p)
+    identDefs.add(ident"auto")
+    identDefs.add(newEmptyNode())
+    params.add(identDefs)
+  else:
+    error("Incorrect procedure parameter list.", p)
+  result = newProc(body = b, params = params,
+                   pragmas = pragma, name = name,
+                   procType = kind)
+
+macro `->`*(p, b: untyped): untyped =
+  ## Syntax sugar for procedure types. It also supports pragmas.
+  ##
+  ## .. warning:: Semicolons can not be used to separate procedure arguments.
+  runnableExamples:
+    proc passTwoAndTwo(f: (int, int) -> int): int = f(2, 2)
+    # is the same as:
+    # proc passTwoAndTwo(f: proc (x, y: int): int): int = f(2, 2)
+
+    assert passTwoAndTwo((x, y) => x + y) == 4
+
+    proc passOne(f: (int {.noSideEffect.} -> int)): int = f(1)
+    # is the same as:
+    # proc passOne(f: proc (x: int): int {.noSideEffect.}): int = f(1)
+
+    assert passOne(x {.noSideEffect.} => x + 1) == 2
+
+  result = createProcType(p, b)
+
+macro dump*(x: untyped): untyped =
+  ## Dumps the content of an expression, useful for debugging.
+  ## It accepts any expression and prints a textual representation
+  ## of the tree representing the expression - as it would appear in
+  ## source code - together with the value of the expression.
+  ##
+  ## See also: `dumpToString` which is more convenient and useful since
+  ## it expands intermediate templates/macros, returns a string instead of
+  ## calling `echo`, and works with statements and expressions.
+  runnableExamples("-r:off"):
+    let
+      x = 10
+      y = 20
+    dump(x + y) # prints: `x + y = 30`
+
+  let s = x.toStrLit
+  result = quote do:
+    debugEcho `s`, " = ", `x`
+
+macro dumpToStringImpl(s: static string, x: typed): string =
+  let s2 = x.toStrLit
+  if x.typeKind == ntyVoid:
+    result = quote do:
+      `s` & ": " & `s2`
+  else:
+    result = quote do:
+      `s` & ": " & `s2` & " = " & $`x`
+
+macro dumpToString*(x: untyped): string =
+  ## Returns the content of a statement or expression `x` after semantic analysis,
+  ## useful for debugging.
+  runnableExamples:
+    const a = 1
+    let x = 10
+    assert dumpToString(a + 2) == "a + 2: 3 = 3"
+    assert dumpToString(a + x) == "a + x: 1 + x = 11"
+    template square(x): untyped = x * x
+    assert dumpToString(square(x)) == "square(x): x * x = 100"
+    assert not compiles dumpToString(1 + nonexistent)
+    import std/strutils
+    assert "failedAssertImpl" in dumpToString(assert true) # example with a statement
+  result = newCall(bindSym"dumpToStringImpl")
+  result.add newLit repr(x)
+  result.add x
+
+# TODO: consider exporting this in macros.nim
+proc freshIdentNodes(ast: NimNode): NimNode =
+  # Replace NimIdent and NimSym by a fresh ident node
+  # see also https://github.com/nim-lang/Nim/pull/8531#issuecomment-410436458
+  proc inspect(node: NimNode): NimNode =
+    case node.kind:
+    of nnkIdent, nnkSym, nnkOpenSymChoice, nnkClosedSymChoice, nnkOpenSym:
+      result = ident($node)
+    of nnkEmpty, nnkLiterals:
+      result = node
+    else:
+      result = node.kind.newTree()
+      for child in node:
+        result.add inspect(child)
+  result = inspect(ast)
+
+macro capture*(locals: varargs[typed], body: untyped): untyped {.since: (1, 1).} =
+  ## Useful when creating a closure in a loop to capture some local loop variables
+  ## by their current iteration values.
+  runnableExamples:
+    import std/strformat
+
+    var myClosure: () -> string
+    for i in 5..7:
+      for j in 7..9:
+        if i * j == 42:
+          capture i, j:
+            myClosure = () => fmt"{i} * {j} = 42"
+    assert myClosure() == "6 * 7 = 42"
+
+  var params = @[newIdentNode("auto")]
+  let locals = if locals.len == 1 and locals[0].kind == nnkBracket: locals[0]
+               else: locals
+  for arg in locals:
+    proc getIdent(n: NimNode): NimNode =
+      case n.kind
+      of nnkIdent, nnkSym:
+        let nStr = n.strVal
+        if nStr == "result":
+          error("The variable name cannot be `result`!", n)
+        result = ident(nStr)
+      of nnkHiddenDeref: result = n[0].getIdent()
+      else:
+        error("The argument to be captured `" & n.repr & "` is not a pure identifier. " &
+          "It is an unsupported `" & $n.kind & "` node.", n)
+    let argName = getIdent(arg)
+    params.add(newIdentDefs(argName, freshIdentNodes getTypeInst arg))
+  result = newNimNode(nnkCall)
+  result.add(newProc(newEmptyNode(), params, body, nnkLambda))
+  for arg in locals: result.add(arg)
+
+since (1, 1):
+  import std/private/underscored_calls
+
+  macro dup*[T](arg: T, calls: varargs[untyped]): T =
+    ## Turns an `in-place`:idx: algorithm into one that works on
+    ## a copy and returns this copy, without modifying its input.
+    ##
+    ## This macro also allows for (otherwise in-place) function chaining.
+    ##
+    ## **Since:** Version 1.2.
+    runnableExamples:
+      import std/algorithm
+
+      let a = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
+      assert a.dup(sort) == sorted(a)
+
+      # Chaining:
+      var aCopy = a
+      aCopy.insert(10)
+      assert a.dup(insert(10), sort) == sorted(aCopy)
+
+      let s1 = "abc"
+      let s2 = "xyz"
+      assert s1 & s2 == s1.dup(&= s2)
+
+      # An underscore (_) can be used to denote the place of the argument you're passing:
+      assert "".dup(addQuoted(_, "foo")) == "\"foo\""
+      # but `_` is optional here since the substitution is in 1st position:
+      assert "".dup(addQuoted("foo")) == "\"foo\""
+
+      proc makePalindrome(s: var string) =
+        for i in countdown(s.len-2, 0):
+          s.add(s[i])
+
+      let c = "xyz"
+
+      # chaining:
+      let d = dup c:
+        makePalindrome # xyzyx
+        sort(_, SortOrder.Descending) # zyyxx
+        makePalindrome # zyyxxxyyz
+      assert d == "zyyxxxyyz"
+
+    result = newNimNode(nnkStmtListExpr, arg)
+    let tmp = genSym(nskVar, "dupResult")
+    result.add newVarStmt(tmp, arg)
+    underscoredCalls(result, calls, tmp)
+    result.add tmp
+
+proc trans(n, res, bracketExpr: NimNode): (NimNode, NimNode, NimNode) {.since: (1, 1).} =
+  # Looks for the last statement of the last statement, etc...
+  case n.kind
+  of nnkIfExpr, nnkIfStmt, nnkTryStmt, nnkCaseStmt, nnkWhenStmt:
+    result[0] = copyNimTree(n)
+    result[1] = copyNimTree(n)
+    result[2] = copyNimTree(n)
+    for i in ord(n.kind == nnkCaseStmt) ..< n.len:
+      (result[0][i], result[1][^1], result[2][^1]) = trans(n[i], res, bracketExpr)
+  of nnkStmtList, nnkStmtListExpr, nnkBlockStmt, nnkBlockExpr, nnkWhileStmt,
+      nnkForStmt, nnkElifBranch, nnkElse, nnkElifExpr, nnkOfBranch, nnkExceptBranch:
+    result[0] = copyNimTree(n)
+    result[1] = copyNimTree(n)
+    result[2] = copyNimTree(n)
+    if n.len >= 1:
+      (result[0][^1], result[1][^1], result[2][^1]) = trans(n[^1],
+          res, bracketExpr)
+  of nnkTableConstr:
+    result[1] = n[0][0]
+    result[2] = n[0][1]
+    if bracketExpr.len == 0:
+      bracketExpr.add(ident"initTable") # don't import tables
+    if bracketExpr.len == 1:
+      bracketExpr.add([newCall(bindSym"typeof",
+          newEmptyNode()), newCall(bindSym"typeof", newEmptyNode())])
+    template adder(res, k, v) = res[k] = v
+    result[0] = getAst(adder(res, n[0][0], n[0][1]))
+  of nnkCurly:
+    result[2] = n[0]
+    if bracketExpr.len == 0:
+      bracketExpr.add(ident"initHashSet")
+    if bracketExpr.len == 1:
+      bracketExpr.add(newCall(bindSym"typeof", newEmptyNode()))
+    template adder(res, v) = res.incl(v)
+    result[0] = getAst(adder(res, n[0]))
+  else:
+    result[2] = n
+    if bracketExpr.len == 0:
+      bracketExpr.add(bindSym"newSeq")
+    if bracketExpr.len == 1:
+      bracketExpr.add(newCall(bindSym"typeof", newEmptyNode()))
+    template adder(res, v) = res.add(v)
+    result[0] = getAst(adder(res, n))
+
+proc collectImpl(init, body: NimNode): NimNode {.since: (1, 1).} =
+  let res = genSym(nskVar, "collectResult")
+  var bracketExpr: NimNode
+  if init != nil:
+    expectKind init, {nnkCall, nnkIdent, nnkSym, nnkClosedSymChoice, nnkOpenSymChoice, nnkOpenSym}
+    bracketExpr = newTree(nnkBracketExpr,
+      if init.kind in {nnkCall, nnkClosedSymChoice, nnkOpenSymChoice, nnkOpenSym}:
+        freshIdentNodes(init[0]) else: freshIdentNodes(init))
+  else:
+    bracketExpr = newTree(nnkBracketExpr)
+  let (resBody, keyType, valueType) = trans(body, res, bracketExpr)
+  if bracketExpr.len == 3:
+    bracketExpr[1][1] = keyType
+    bracketExpr[2][1] = valueType
+  else:
+    bracketExpr[1][1] = valueType
+  let call = newTree(nnkCall, bracketExpr)
+  if init != nil and init.kind == nnkCall:
+    for i in 1 ..< init.len:
+      call.add init[i]
+  result = newTree(nnkStmtListExpr, newVarStmt(res, call), resBody, res)
+
+macro collect*(init, body: untyped): untyped {.since: (1, 1).} =
+  ## Comprehension for seqs/sets/tables.
+  ##
+  ## The last expression of `body` has special syntax that specifies
+  ## the collection's add operation. Use `{e}` for set's `incl`,
+  ## `{k: v}` for table's `[]=` and `e` for seq's `add`.
+  # analyse the body, find the deepest expression 'it' and replace it via
+  # 'result.add it'
+  runnableExamples:
+    import std/[sets, tables]
+
+    let data = @["bird", "word"]
+
+    ## seq:
+    let k = collect(newSeq):
+      for i, d in data.pairs:
+        if i mod 2 == 0: d
+    assert k == @["bird"]
+
+    ## seq with initialSize:
+    let x = collect(newSeqOfCap(4)):
+      for i, d in data.pairs:
+        if i mod 2 == 0: d
+    assert x == @["bird"]
+
+    ## HashSet:
+    let y = collect(initHashSet()):
+      for d in data.items: {d}
+    assert y == data.toHashSet
+
+    ## Table:
+    let z = collect(initTable(2)):
+      for i, d in data.pairs: {i: d}
+    assert z == {0: "bird", 1: "word"}.toTable
+
+  result = collectImpl(init, body)
+
+macro collect*(body: untyped): untyped {.since: (1, 5).} =
+  ## Same as `collect` but without an `init` parameter.
+  ##
+  ## **See also:**
+  ## * `sequtils.toSeq proc<sequtils.html#toSeq.t%2Cuntyped>`_
+  ## * `sequtils.mapIt template<sequtils.html#mapIt.t%2Ctyped%2Cuntyped>`_
+  runnableExamples:
+    import std/[sets, tables]
+    let data = @["bird", "word"]
+
+    # seq:
+    let k = collect:
+      for i, d in data.pairs:
+        if i mod 2 == 0: d
+    assert k == @["bird"]
+
+    ## HashSet:
+    let n = collect:
+      for d in data.items: {d}
+    assert n == data.toHashSet
+
+    ## Table:
+    let m = collect:
+      for i, d in data.pairs: {i: d}
+    assert m == {0: "bird", 1: "word"}.toTable
+
+  result = collectImpl(nil, body)
diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim
index 42bd80cb4..53b3d61da 100755..100644
--- a/lib/pure/terminal.nim
+++ b/lib/pure/terminal.nim
@@ -1,310 +1,1033 @@
-#

-#

-#            Nimrod's Runtime Library

-#        (c) Copyright 2009 Andreas Rumpf

-#

-#    See the file "copying.txt", included in this

-#    distribution, for details about the copyright.

-#

-

-## This module contains a few procedures to control the *terminal* 

-## (also called *console*). On UNIX, the implementation simply uses ANSI escape 

-## sequences and does not depend on any other module, on Windows it uses the

-## Windows API.

-## Changing the style is permanent even after program termination! Use the

-## code ``system.addQuitProc(resetAttributes)`` to restore the defaults.

-

-when defined(windows):

-  import windows, os

-  

-  var 

-    conHandle: THandle

-  # = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0)

-    

-  block:

-    var hTemp = GetStdHandle(STD_OUTPUT_HANDLE())

-    if DuplicateHandle(GetCurrentProcess(), hTemp, GetCurrentProcess(),

-                       addr(conHandle), 0, 1, DUPLICATE_SAME_ACCESS) == 0:

-      OSError()

-    

-  proc getCursorPos(): tuple [x,y: int] = 

-    var c: TCONSOLE_SCREEN_BUFFER_INFO

-    if GetConsoleScreenBufferInfo(conHandle, addr(c)) == 0: OSError()

-    return (int(c.dwCursorPosition.x), int(c.dwCursorPosition.y))

-    

-  proc getAttributes(): int16 = 

-    var c: TCONSOLE_SCREEN_BUFFER_INFO

-    # workaround Windows bugs: try several times

-    if GetConsoleScreenBufferInfo(conHandle, addr(c)) != 0: 

-      return c.wAttributes

-    else:

-      OSError()

-    return 0x70'i16 # ERROR: return white background, black text

-    

-  var

-    oldAttr = getAttributes()

-

-proc setCursorPos*(x, y: int) =

-  ## sets the terminal's cursor to the (x,y) position. (0,0) is the 

-  ## upper left of the screen. 

-  when defined(windows):

-    var c: TCoord

-    c.x = int16(x)

-    c.y = int16(y)

-    if SetConsoleCursorPosition(conHandle, c) == 0: OSError()

-  else:

-    stdout.write("\e[" & $y & ';' & $x & 'f')

-
-proc setCursorXPos*(x: int) =

-  ## sets the terminal's cursor to the x position. The y position is
-  ## not changed.

-  when defined(windows):

-    var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO

-    var hStdout = conHandle

-    if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()

-    var origin = scrbuf.dwCursorPosition

-    origin.x = int16(x)

-    if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
-  else:

-    stdout.write("\e[" & $x & 'G')

+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains a few procedures to control the *terminal*
+## (also called *console*). On UNIX, the implementation simply uses ANSI escape
+## sequences and does not depend on any other module, on Windows it uses the
+## Windows API.
+## Changing the style is permanent even after program termination! Use the
+## code `exitprocs.addExitProc(resetAttributes)` to restore the defaults.
+## Similarly, if you hide the cursor, make sure to unhide it with
+## `showCursor` before quitting.
+##
+## Progress bar
+## ============
+##
+## Basic progress bar example:
+runnableExamples("-r:off"):
+  import std/[os, strutils]
+
+  for i in 0..100:
+    stdout.styledWriteLine(fgRed, "0% ", fgWhite, '#'.repeat i, if i > 50: fgGreen else: fgYellow, "\t", $i , "%")
+    sleep 42
+    cursorUp 1
+    eraseLine()
+
+  stdout.resetAttributes()
+
+##[
+## Playing with colorful and styled text
+]##
+
+## Procs like `styledWriteLine`, `styledEcho` etc. have a temporary effect on
+## text parameters. Style parameters only affect the text parameter right after them.
+## After being called, these procs will reset the default style of the terminal.
+## While `setBackGroundColor`, `setForeGroundColor` etc. have a lasting
+## influence on the terminal, you can use `resetAttributes` to
+## reset the default style of the terminal.
+runnableExamples("-r:off"):
+  stdout.styledWriteLine({styleBright, styleBlink, styleUnderscore}, "styled text ")
+  stdout.styledWriteLine(fgRed, "red text ")
+  stdout.styledWriteLine(fgWhite, bgRed, "white text in red background")
+  stdout.styledWriteLine(" ordinary text without style ")
+
+  stdout.setBackGroundColor(bgCyan, true)
+  stdout.setForeGroundColor(fgBlue)
+  stdout.write("blue text in cyan background")
+  stdout.resetAttributes()
+
+  # You can specify multiple text parameters. Style parameters
+  # only affect the text parameter right after them.
+  styledEcho styleBright, fgGreen, "[PASS]", resetStyle, fgGreen, " Yay!"
+
+  stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text")
+
+import std/macros
+import std/strformat
+from std/strutils import toLowerAscii, `%`, parseInt
+import std/colors
+
+when defined(windows):
+  import std/winlean
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions]
+
+type
+  PTerminal = ref object
+    trueColorIsSupported: bool
+    trueColorIsEnabled: bool
+    fgSetColor: bool
+    when defined(windows):
+      hStdout: Handle
+      hStderr: Handle
+      oldStdoutAttr: int16
+      oldStderrAttr: int16
+
+var gTerm {.threadvar.}: owned(PTerminal)
+
+when defined(windows) and defined(consoleapp):
+  proc newTerminal(): owned(PTerminal) {.gcsafe, raises: [OSError].}
+else:
+  proc newTerminal(): owned(PTerminal) {.gcsafe, raises: [].}
+
+proc getTerminal(): PTerminal {.inline.} =
+  if isNil(gTerm):
+    gTerm = newTerminal()
+  result = gTerm
+
+const
+  fgPrefix = "\e[38;2;"
+  bgPrefix = "\e[48;2;"
+  ansiResetCode* = "\e[0m"
+  getPos = "\e[6n"
+  stylePrefix = "\e["
+
+when defined(windows):
+  import std/[winlean, os]
+
+  const
+    DUPLICATE_SAME_ACCESS = 2
+    FOREGROUND_BLUE = 1
+    FOREGROUND_GREEN = 2
+    FOREGROUND_RED = 4
+    FOREGROUND_INTENSITY = 8
+    BACKGROUND_BLUE = 16
+    BACKGROUND_GREEN = 32
+    BACKGROUND_RED = 64
+    BACKGROUND_INTENSITY = 128
+    FOREGROUND_RGB = FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE
+    BACKGROUND_RGB = BACKGROUND_RED or BACKGROUND_GREEN or BACKGROUND_BLUE
+
+    ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
+
+  type
+    SHORT = int16
+    COORD = object
+      x: SHORT
+      y: SHORT
+
+    SMALL_RECT = object
+      left: SHORT
+      top: SHORT
+      right: SHORT
+      bottom: SHORT
+
+    CONSOLE_SCREEN_BUFFER_INFO = object
+      dwSize: COORD
+      dwCursorPosition: COORD
+      wAttributes: int16
+      srWindow: SMALL_RECT
+      dwMaximumWindowSize: COORD
+
+    CONSOLE_CURSOR_INFO = object
+      dwSize: DWORD
+      bVisible: WINBOOL
+
+  proc duplicateHandle(hSourceProcessHandle: Handle, hSourceHandle: Handle,
+                       hTargetProcessHandle: Handle, lpTargetHandle: ptr Handle,
+                       dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
+                       dwOptions: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
+      importc: "DuplicateHandle".}
+  proc getCurrentProcess(): Handle{.stdcall, dynlib: "kernel32",
+                                     importc: "GetCurrentProcess".}
+  proc getConsoleScreenBufferInfo(hConsoleOutput: Handle,
+    lpConsoleScreenBufferInfo: ptr CONSOLE_SCREEN_BUFFER_INFO): WINBOOL{.stdcall,
+    dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".}
+
+  proc getConsoleCursorInfo(hConsoleOutput: Handle,
+      lpConsoleCursorInfo: ptr CONSOLE_CURSOR_INFO): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "GetConsoleCursorInfo".}
+
+  proc setConsoleCursorInfo(hConsoleOutput: Handle,
+      lpConsoleCursorInfo: ptr CONSOLE_CURSOR_INFO): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "SetConsoleCursorInfo".}
+
+  proc terminalWidthIoctl*(handles: openArray[Handle]): int =
+    var csbi: CONSOLE_SCREEN_BUFFER_INFO
+    for h in handles:
+      if getConsoleScreenBufferInfo(h, addr csbi) != 0:
+        return int(csbi.srWindow.right - csbi.srWindow.left + 1)
+    return 0
+
+  proc terminalHeightIoctl*(handles: openArray[Handle]): int =
+    var csbi: CONSOLE_SCREEN_BUFFER_INFO
+    for h in handles:
+      if getConsoleScreenBufferInfo(h, addr csbi) != 0:
+        return int(csbi.srWindow.bottom - csbi.srWindow.top + 1)
+    return 0
+
+  proc terminalWidth*(): int =
+    ## Returns the terminal width in columns.
+    var w: int = 0
+    w = terminalWidthIoctl([getStdHandle(STD_INPUT_HANDLE),
+                             getStdHandle(STD_OUTPUT_HANDLE),
+                             getStdHandle(STD_ERROR_HANDLE)])
+    if w > 0: return w
+    return 80
+
+  proc terminalHeight*(): int =
+    ## Returns the terminal height in rows.
+    var h: int = 0
+    h = terminalHeightIoctl([getStdHandle(STD_INPUT_HANDLE),
+                              getStdHandle(STD_OUTPUT_HANDLE),
+                              getStdHandle(STD_ERROR_HANDLE)])
+    if h > 0: return h
+    return 0
+
+  proc setConsoleCursorPosition(hConsoleOutput: Handle,
+                                dwCursorPosition: COORD): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "SetConsoleCursorPosition".}
+
+  proc fillConsoleOutputCharacter(hConsoleOutput: Handle, cCharacter: char,
+                                  nLength: DWORD, dwWriteCoord: COORD,
+                                  lpNumberOfCharsWritten: ptr DWORD): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".}
+
+  proc fillConsoleOutputAttribute(hConsoleOutput: Handle, wAttribute: int16,
+                                  nLength: DWORD, dwWriteCoord: COORD,
+                                  lpNumberOfAttrsWritten: ptr DWORD): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "FillConsoleOutputAttribute".}
+
+  proc setConsoleTextAttribute(hConsoleOutput: Handle,
+                               wAttributes: int16): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "SetConsoleTextAttribute".}
+
+  proc getConsoleMode(hConsoleHandle: Handle, dwMode: ptr DWORD): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "GetConsoleMode".}
+
+  proc setConsoleMode(hConsoleHandle: Handle, dwMode: DWORD): WINBOOL{.
+      stdcall, dynlib: "kernel32", importc: "SetConsoleMode".}
+
+  proc getCursorPos(h: Handle): tuple [x, y: int] =
+    var c: CONSOLE_SCREEN_BUFFER_INFO
+    if getConsoleScreenBufferInfo(h, addr(c)) == 0:
+      raiseOSError(osLastError())
+    return (int(c.dwCursorPosition.x), int(c.dwCursorPosition.y))
+
+  proc getCursorPos*(): tuple [x, y: int] {.raises: [ValueError, IOError, OSError].} =
+    return getCursorPos(getStdHandle(STD_OUTPUT_HANDLE))
+
+  proc setCursorPos(h: Handle, x, y: int) =
+    var c: COORD
+    c.x = int16(x)
+    c.y = int16(y)
+    if setConsoleCursorPosition(h, c) == 0:
+      raiseOSError(osLastError())
+
+  proc getAttributes(h: Handle): int16 =
+    var c: CONSOLE_SCREEN_BUFFER_INFO
+    # workaround Windows bugs: try several times
+    if getConsoleScreenBufferInfo(h, addr(c)) != 0:
+      return c.wAttributes
+    return 0x70'i16 # ERROR: return white background, black text
+
+  proc initTerminal(term: PTerminal) =
+    var hStdoutTemp = getStdHandle(STD_OUTPUT_HANDLE)
+    if duplicateHandle(getCurrentProcess(), hStdoutTemp, getCurrentProcess(),
+                       addr(term.hStdout), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
+      when defined(consoleapp):
+        raiseOSError(osLastError())
+    var hStderrTemp = getStdHandle(STD_ERROR_HANDLE)
+    if duplicateHandle(getCurrentProcess(), hStderrTemp, getCurrentProcess(),
+                       addr(term.hStderr), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
+      when defined(consoleapp):
+        raiseOSError(osLastError())
+    term.oldStdoutAttr = getAttributes(term.hStdout)
+    term.oldStderrAttr = getAttributes(term.hStderr)
+
+  template conHandle(f: File): Handle =
+    let term = getTerminal()
+    if f == stderr: term.hStderr else: term.hStdout
+
+else:
+  import std/[termios, posix, os, parseutils]
+
+  proc setRaw(fd: FileHandle, time: cint = TCSAFLUSH) =
+    var mode: Termios
+    discard fd.tcGetAttr(addr mode)
+    mode.c_iflag = mode.c_iflag and not Cflag(BRKINT or ICRNL or INPCK or
+      ISTRIP or IXON)
+    mode.c_oflag = mode.c_oflag and not Cflag(OPOST)
+    mode.c_cflag = (mode.c_cflag and not Cflag(CSIZE or PARENB)) or CS8
+    mode.c_lflag = mode.c_lflag and not Cflag(ECHO or ICANON or IEXTEN or ISIG)
+    mode.c_cc[VMIN] = 1.cuchar
+    mode.c_cc[VTIME] = 0.cuchar
+    discard fd.tcSetAttr(time, addr mode)
+
+  proc getCursorPos*(): tuple [x, y: int] {.raises: [ValueError, IOError].} =
+    ## Returns cursor position (x, y)
+    ## writes to stdout and expects the terminal to respond via stdin
+    var
+      xStr = ""
+      yStr = ""
+      ch: char
+      ct: int
+      readX = false
+
+    # use raw mode to ask terminal for cursor position
+    let fd = getFileHandle(stdin)
+    var oldMode: Termios
+    discard fd.tcGetAttr(addr oldMode)
+    fd.setRaw()
+    stdout.write(getPos)
+    flushFile(stdout)
+
+    try:
+      # parse response format: [yyy;xxxR
+      while true:
+        let n = readBuffer(stdin, addr ch, 1)
+        if n == 0 or ch == 'R':
+          if xStr == "" or yStr == "":
+            raise newException(ValueError, "Got character position message that was missing data")
+          break
+        ct += 1
+        if ct > 16:
+          raise newException(ValueError, "Got unterminated character position message from terminal")
+        if ch == ';':
+          readX = true
+        elif ch in {'0'..'9'}:
+          if readX:
+            xStr.add(ch)
+          else:
+            yStr.add(ch)
+    finally:
+      # restore previous terminal mode
+      discard fd.tcSetAttr(TCSADRAIN, addr oldMode)
+
+    return (parseInt(xStr), parseInt(yStr))
+
+  proc terminalWidthIoctl*(fds: openArray[int]): int =
+    ## Returns terminal width from first fd that supports the ioctl.
+
+    var win: IOctl_WinSize
+    for fd in fds:
+      if ioctl(cint(fd), TIOCGWINSZ, addr win) != -1:
+        return int(win.ws_col)
+    return 0
+
+  proc terminalHeightIoctl*(fds: openArray[int]): int =
+    ## Returns terminal height from first fd that supports the ioctl.
+
+    var win: IOctl_WinSize
+    for fd in fds:
+      if ioctl(cint(fd), TIOCGWINSZ, addr win) != -1:
+        return int(win.ws_row)
+    return 0
+
+  var L_ctermid{.importc, header: "<stdio.h>".}: cint
+
+  proc terminalWidth*(): int =
+    ## Returns some reasonable terminal width from either standard file
+    ## descriptors, controlling terminal, environment variables or tradition.
+
+    # POSIX environment variable takes precendence.
+    # _COLUMNS_: This variable shall represent a decimal integer >0 used
+    # to indicate the user's preferred width in column positions for
+    # the terminal screen or window. If this variable is unset or null,
+    # the implementation determines the number of columns, appropriate
+    # for the terminal or window, in an unspecified manner.
+    # When COLUMNS is set, any terminal-width information implied by TERM
+    # is overridden. Users and conforming applications should not set COLUMNS
+    # unless they wish to override the system selection and produce output
+    # unrelated to the terminal characteristics.
+    # See POSIX Base Definitions Section 8.1 Environment Variable Definition
+
+    var w: int
+    var s = getEnv("COLUMNS") # Try standard env var
+    if len(s) > 0 and parseSaturatedNatural(s, w) > 0 and w > 0:
+      return w
+    w = terminalWidthIoctl([0, 1, 2]) # Try standard file descriptors
+    if w > 0: return w
+    var cterm = newString(L_ctermid) # Try controlling tty
+    var fd = open(ctermid(cstring(cterm)), O_RDONLY)
+    if fd != -1:
+      w = terminalWidthIoctl([int(fd)])
+    discard close(fd)
+    if w > 0: return w
+    return 80 # Finally default to venerable value
+
+  proc terminalHeight*(): int =
+    ## Returns some reasonable terminal height from either standard file
+    ## descriptors, controlling terminal, environment variables or tradition.
+    ## Zero is returned if the height could not be determined.
+
+    # POSIX environment variable takes precendence.
+    # _LINES_: This variable shall represent a decimal integer >0 used
+    # to indicate the user's preferred number of lines on a page or
+    # the vertical screen or window size in lines. A line in this case
+    # is a vertical measure large enough to hold the tallest character
+    # in the character set being displayed. If this variable is unset or null,
+    # the implementation determines the number of lines, appropriate
+    # for the terminal or window (size, terminal baud rate, and so on),
+    # in an unspecified manner.
+    # When LINES is set, any terminal-height information implied by TERM
+    # is overridden. Users and conforming applications should not set LINES
+    # unless they wish to override the system selection and produce output
+    # unrelated to the terminal characteristics.
+    # See POSIX Base Definitions Section 8.1 Environment Variable Definition
+
+    var h: int
+    var s = getEnv("LINES") # Try standard env var
+    if len(s) > 0 and parseSaturatedNatural(s, h) > 0 and h > 0:
+      return h
+    h = terminalHeightIoctl([0, 1, 2]) # Try standard file descriptors
+    if h > 0: return h
+    var cterm = newString(L_ctermid) # Try controlling tty
+    var fd = open(ctermid(cstring(cterm)), O_RDONLY)
+    if fd != -1:
+      h = terminalHeightIoctl([int(fd)])
+    discard close(fd)
+    if h > 0: return h
+    return 0 # Could not determine height
+
+proc terminalSize*(): tuple[w, h: int] =
+  ## Returns the terminal width and height as a tuple. Internally calls
+  ## `terminalWidth` and `terminalHeight`, so the same assumptions apply.
+  result = (terminalWidth(), terminalHeight())
+
+when defined(windows):
+  proc setCursorVisibility(f: File, visible: bool) =
+    var ccsi: CONSOLE_CURSOR_INFO
+    let h = conHandle(f)
+    if getConsoleCursorInfo(h, addr(ccsi)) == 0:
+      raiseOSError(osLastError())
+    ccsi.bVisible = if visible: 1 else: 0
+    if setConsoleCursorInfo(h, addr(ccsi)) == 0:
+      raiseOSError(osLastError())
+
+proc hideCursor*(f: File) =
+  ## Hides the cursor.
+  when defined(windows):
+    setCursorVisibility(f, false)
+  else:
+    f.write("\e[?25l")
+
+proc showCursor*(f: File) =
+  ## Shows the cursor.
+  when defined(windows):
+    setCursorVisibility(f, true)
+  else:
+    f.write("\e[?25h")
+
+proc setCursorPos*(f: File, x, y: int) =
+  ## Sets the terminal's cursor to the (x,y) position.
+  ## (0,0) is the upper left of the screen.
+  when defined(windows):
+    let h = conHandle(f)
+    setCursorPos(h, x, y)
+  else:
+    f.write(fmt"{stylePrefix}{y+1};{x+1}f")
+
+proc setCursorXPos*(f: File, x: int) =
+  ## Sets the terminal's cursor to the x position.
+  ## The y position is not changed.
+  when defined(windows):
+    let h = conHandle(f)
+    var scrbuf: CONSOLE_SCREEN_BUFFER_INFO
+    if getConsoleScreenBufferInfo(h, addr(scrbuf)) == 0:
+      raiseOSError(osLastError())
+    var origin = scrbuf.dwCursorPosition
+    origin.x = int16(x)
+    if setConsoleCursorPosition(h, origin) == 0:
+      raiseOSError(osLastError())
+  else:
+    f.write(fmt"{stylePrefix}{x+1}G")
 
 when defined(windows):
-  proc setCursorYPos*(y: int) =

-    ## sets the terminal's cursor to the y position. The x position is
-    ## not changed. **Warning**: This is not supported on UNIX!

-    when defined(windows):

-      var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO

-      var hStdout = conHandle

-      if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()

-      var origin = scrbuf.dwCursorPosition

-      origin.y = int16(y)

-      if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
-    else:

-      nil

-

-proc CursorUp*(count=1) = 

-  ## Moves the cursor up by `count` rows.

-  when defined(windows):

-    var p = getCursorPos()

-    dec(p.y, count)

-    setCursorPos(p.x, p.y)

-  else:

-    stdout.write("\e[" & $count & 'A')

-

-proc CursorDown*(count=1) = 

-  ## Moves the cursor down by `count` rows.

-  when defined(windows):

-    var p = getCursorPos()

-    inc(p.y, count)

-    setCursorPos(p.x, p.y)

-  else:

-    stdout.write("\e[" & $count & 'B')

-

-proc CursorForward*(count=1) = 

-  ## Moves the cursor forward by `count` columns.

-  when defined(windows):

-    var p = getCursorPos()

-    inc(p.x, count)

-    setCursorPos(p.x, p.y)

-  else:

-    stdout.write("\e[" & $count & 'C')

-

-proc CursorBackward*(count=1) = 

-  ## Moves the cursor backward by `count` columns.

-  when defined(windows):

-    var p = getCursorPos()

-    dec(p.x, count)

-    setCursorPos(p.x, p.y)

-  else:

-    stdout.write("\e[" & $count & 'D')

-  

-when true:

-  nil

-else:

-  proc EraseLineEnd* =

-    ## Erases from the current cursor position to the end of the current line.

-    when defined(windows):

-      nil

-    else:

-      stdout.write("\e[K")

-  

-  proc EraseLineStart* =

-    ## Erases from the current cursor position to the start of the current line.

-    when defined(windows):

-      nil

-    else:

-      stdout.write("\e[1K")

-  

-  proc EraseDown* =

-    ## Erases the screen from the current line down to the bottom of the screen.

-    when defined(windows):

-      nil

-    else:

-      stdout.write("\e[J")

-  

-  proc EraseUp* =

-    ## Erases the screen from the current line up to the top of the screen.

-    when defined(windows):

-      nil

-    else:

-      stdout.write("\e[1J")

-  

-proc EraseLine* =

-  ## Erases the entire current line.

-  when defined(windows):

-    var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO

-    var numwrote: DWORD

-    var hStdout = conHandle

-    if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()

-    var origin = scrbuf.dwCursorPosition

-    origin.x = 0'i16

-    if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()

-    var ht = scrbuf.dwSize.Y - origin.Y

-    var wt = scrbuf.dwSize.X - origin.X

-    if FillConsoleOutputCharacter(hStdout,' ', ht*wt, 

-                                  origin, addr(numwrote)) == 0:

-      OSError()

-    if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes, ht * wt,

-                                  scrbuf.dwCursorPosition, addr(numwrote)) == 0:

-      OSError()

-  else:

-    stdout.write("\e[2K")
-    setCursorXPos(0)

-

-proc EraseScreen* =

-  ## Erases the screen with the background colour and moves the cursor to home.

-  when defined(windows):

-    var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO

-    var numwrote: DWORD

-    var origin: TCoord # is inititalized to 0, 0 

-    var hStdout = conHandle

-    if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()

-    if FillConsoleOutputCharacter(hStdout, ' ', scrbuf.dwSize.X*scrbuf.dwSize.Y,

-                                  origin, addr(numwrote)) == 0:

-      OSError()

-    if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes,

-                                  scrbuf.dwSize.X * scrbuf.dwSize.Y, 

-                                  origin, addr(numwrote)) == 0:

-      OSError()

-    setCursorXPos(0)

-  else:

-    stdout.write("\e[2J")

-

-proc ResetAttributes* {.noconv.} = 

-  ## resets all attributes; it is advisable to register this as a quit proc

-  ## with ``system.addQuitProc(resetAttributes)``. 

-  when defined(windows):

-    discard SetConsoleTextAttribute(conHandle, oldAttr)

-  else:

-    stdout.write("\e[0m")

-

-type

-  TStyle* = enum         ## different styles for text output

-    styleBright = 1,     ## bright text

-    styleDim,            ## dim text

-    styleUnknown,        ## unknown

-    styleUnderscore = 4, ## underscored text

-    styleBlink,          ## blinking/bold text

-    styleReverse,        ## unknown

-    styleHidden          ## hidden text

-

-when not defined(windows):

-  var

-    gFG = 0

-    gBG = 0

-

-proc WriteStyled*(txt: string, style: set[TStyle] = {styleBright}) = 

-  ## writes the text `txt` in a given `style`.

-  when defined(windows):

-    var a = 0'i16

-    if styleBright in style: a = a or int16(FOREGROUND_INTENSITY)

-    if styleBlink in style: a = a or int16(BACKGROUND_INTENSITY)

-    if styleReverse in style: a = a or 0x4000'i16 # COMMON_LVB_REVERSE_VIDEO

-    if styleUnderscore in style: a = a or 0x8000'i16 # COMMON_LVB_UNDERSCORE

-    var old = getAttributes()

-    discard SetConsoleTextAttribute(conHandle, old or a)

-    stdout.write(txt)

-    discard SetConsoleTextAttribute(conHandle, old)

-  else:

-    for s in items(style):

-      stdout.write("\e[" & $ord(s) & 'm')

-    stdout.write(txt)

-    resetAttributes()

-    if gFG != 0: 

-      stdout.write("\e[" & $ord(gFG) & 'm')  

-    if gBG != 0:

-      stdout.write("\e[" & $ord(gBG) & 'm')

-

-type

-  TForegroundColor* = enum ## terminal's foreground colors

-    fgBlack = 30,          ## black

-    fgRed,                 ## red

-    fgGreen,               ## green

-    fgYellow,              ## yellow

-    fgBlue,                ## blue

-    fgMagenta,             ## magenta

-    fgCyan,                ## cyan

-    fgWhite                ## white

-

-  TBackgroundColor* = enum ## terminal's background colors

-    bgBlack = 40,          ## black

-    bgRed,                 ## red

-    bgGreen,               ## green

-    bgYellow,              ## yellow

-    bgBlue,                ## blue

-    bgMagenta,             ## magenta

-    bgCyan,                ## cyan

-    bgWhite                ## white

-  

-proc setForegroundColor*(fg: TForegroundColor, bright=false) = 

-  ## sets the terminal's foreground color

-  when defined(windows):

-    var old = getAttributes() and not 0x0007 

-    if bright: 

-      old = old or FOREGROUND_INTENSITY

-    const lookup: array [TForegroundColor, int] = [

-      0,

-      (FOREGROUND_RED),

-      (FOREGROUND_GREEN),

-      (FOREGROUND_RED or FOREGROUND_GREEN),

-      (FOREGROUND_BLUE),

-      (FOREGROUND_RED or FOREGROUND_BLUE),

-      (FOREGROUND_BLUE or FOREGROUND_GREEN),

-      (FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED)]

-    discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[fg]))

-  else:

-    gFG = ord(fg)

-    if bright: inc(gFG, 60)

-    stdout.write("\e[" & $gFG & 'm')

-

-proc setBackgroundColor*(bg: TBackgroundColor, bright=false) = 

-  ## sets the terminal's background color

-  when defined(windows):

-    var old = getAttributes() and not 0x0070

-    if bright: 

-      old = old or BACKGROUND_INTENSITY

-    const lookup: array [TBackgroundColor, int] = [

-      0,

-      (BACKGROUND_RED),

-      (BACKGROUND_GREEN),

-      (BACKGROUND_RED or BACKGROUND_GREEN),

-      (BACKGROUND_BLUE),

-      (BACKGROUND_RED or BACKGROUND_BLUE),

-      (BACKGROUND_BLUE or BACKGROUND_GREEN),

-      (BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED)]

-    discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[bg]))

-  else:

-    gBG = ord(bg)

-    if bright: inc(gBG, 60)

-    stdout.write("\e[" & $gBG & 'm')

-

-when isMainModule:

-  system.addQuitProc(resetAttributes)

-  write(stdout, "never mind")

-  eraseLine()

-  #setCursorPos(2, 2)

-  writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})

-  setBackGroundColor(bgCyan, true)

-  setForeGroundColor(fgBlue)

-  writeln(stdout, "ordinary text")

-

+  proc setCursorYPos*(f: File, y: int) =
+    ## Sets the terminal's cursor to the y position.
+    ## The x position is not changed.
+    ## .. warning:: This is not supported on UNIX!
+    when defined(windows):
+      let h = conHandle(f)
+      var scrbuf: CONSOLE_SCREEN_BUFFER_INFO
+      if getConsoleScreenBufferInfo(h, addr(scrbuf)) == 0:
+        raiseOSError(osLastError())
+      var origin = scrbuf.dwCursorPosition
+      origin.y = int16(y)
+      if setConsoleCursorPosition(h, origin) == 0:
+        raiseOSError(osLastError())
+    else:
+      discard
+
+proc cursorUp*(f: File, count = 1) =
+  ## Moves the cursor up by `count` rows.
+  runnableExamples("-r:off"):
+    stdout.cursorUp(2)
+    write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
+  when defined(windows):
+    let h = conHandle(f)
+    var p = getCursorPos(h)
+    dec(p.y, count)
+    setCursorPos(h, p.x, p.y)
+  else:
+    f.write("\e[" & $count & 'A')
+
+proc cursorDown*(f: File, count = 1) =
+  ## Moves the cursor down by `count` rows.
+  runnableExamples("-r:off"):
+    stdout.cursorDown(2)
+    write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
+  when defined(windows):
+    let h = conHandle(f)
+    var p = getCursorPos(h)
+    inc(p.y, count)
+    setCursorPos(h, p.x, p.y)
+  else:
+    f.write(fmt"{stylePrefix}{count}B")
+
+proc cursorForward*(f: File, count = 1) =
+  ## Moves the cursor forward by `count` columns.
+  runnableExamples("-r:off"):
+    stdout.cursorForward(2)
+    write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
+  when defined(windows):
+    let h = conHandle(f)
+    var p = getCursorPos(h)
+    inc(p.x, count)
+    setCursorPos(h, p.x, p.y)
+  else:
+    f.write(fmt"{stylePrefix}{count}C")
+
+proc cursorBackward*(f: File, count = 1) =
+  ## Moves the cursor backward by `count` columns.
+  runnableExamples("-r:off"):
+    stdout.cursorBackward(2)
+    write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
+  when defined(windows):
+    let h = conHandle(f)
+    var p = getCursorPos(h)
+    dec(p.x, count)
+    setCursorPos(h, p.x, p.y)
+  else:
+    f.write(fmt"{stylePrefix}{count}D")
+
+when true:
+  discard
+else:
+  proc eraseLineEnd*(f: File) =
+    ## Erases from the current cursor position to the end of the current line.
+    when defined(windows):
+      discard
+    else:
+      f.write("\e[K")
+
+  proc eraseLineStart*(f: File) =
+    ## Erases from the current cursor position to the start of the current line.
+    when defined(windows):
+      discard
+    else:
+      f.write("\e[1K")
+
+  proc eraseDown*(f: File) =
+    ## Erases the screen from the current line down to the bottom of the screen.
+    when defined(windows):
+      discard
+    else:
+      f.write("\e[J")
+
+  proc eraseUp*(f: File) =
+    ## Erases the screen from the current line up to the top of the screen.
+    when defined(windows):
+      discard
+    else:
+      f.write("\e[1J")
+
+proc eraseLine*(f: File) =
+  ## Erases the entire current line.
+  runnableExamples("-r:off"):
+    write(stdout, "never mind")
+    stdout.eraseLine() # nothing will be printed on the screen
+  when defined(windows):
+    let h = conHandle(f)
+    var scrbuf: CONSOLE_SCREEN_BUFFER_INFO
+    var numwrote: DWORD
+    if getConsoleScreenBufferInfo(h, addr(scrbuf)) == 0:
+      raiseOSError(osLastError())
+    var origin = scrbuf.dwCursorPosition
+    origin.x = 0'i16
+    if setConsoleCursorPosition(h, origin) == 0:
+      raiseOSError(osLastError())
+    var wt: DWORD = scrbuf.dwSize.x - origin.x
+    if fillConsoleOutputCharacter(h, ' ', wt,
+                                  origin, addr(numwrote)) == 0:
+      raiseOSError(osLastError())
+    if fillConsoleOutputAttribute(h, scrbuf.wAttributes, wt,
+                                  scrbuf.dwCursorPosition, addr(numwrote)) == 0:
+      raiseOSError(osLastError())
+  else:
+    f.write("\e[2K")
+    setCursorXPos(f, 0)
+
+proc eraseScreen*(f: File) =
+  ## Erases the screen with the background colour and moves the cursor to home.
+  when defined(windows):
+    let h = conHandle(f)
+    var scrbuf: CONSOLE_SCREEN_BUFFER_INFO
+    var numwrote: DWORD
+    var origin: COORD # is inititalized to 0, 0
+
+    if getConsoleScreenBufferInfo(h, addr(scrbuf)) == 0:
+      raiseOSError(osLastError())
+    let numChars = int32(scrbuf.dwSize.x)*int32(scrbuf.dwSize.y)
+
+    if fillConsoleOutputCharacter(h, ' ', numChars,
+                                  origin, addr(numwrote)) == 0:
+      raiseOSError(osLastError())
+    if fillConsoleOutputAttribute(h, scrbuf.wAttributes, numChars,
+                                  origin, addr(numwrote)) == 0:
+      raiseOSError(osLastError())
+    setCursorXPos(f, 0)
+  else:
+    f.write("\e[2J")
+
+when not defined(windows):
+  var
+    gFG {.threadvar.}: int
+    gBG {.threadvar.}: int
+
+proc resetAttributes*(f: File) =
+  ## Resets all attributes.
+  when defined(windows):
+    let term = getTerminal()
+    if f == stderr:
+      discard setConsoleTextAttribute(term.hStderr, term.oldStderrAttr)
+    else:
+      discard setConsoleTextAttribute(term.hStdout, term.oldStdoutAttr)
+  else:
+    f.write(ansiResetCode)
+    gFG = 0
+    gBG = 0
+
+type
+  Style* = enum        ## Different styles for text output.
+    styleBright = 1,   ## bright text
+    styleDim,          ## dim text
+    styleItalic,       ## italic (or reverse on terminals not supporting)
+    styleUnderscore,   ## underscored text
+    styleBlink,        ## blinking/bold text
+    styleBlinkRapid,   ## rapid blinking/bold text (not widely supported)
+    styleReverse,      ## reverse
+    styleHidden,       ## hidden text
+    styleStrikethrough ## strikethrough
+
+proc ansiStyleCode*(style: int): string =
+  result = fmt"{stylePrefix}{style}m"
+
+template ansiStyleCode*(style: Style): string =
+  ansiStyleCode(style.int)
+
+# The styleCache can be skipped when `style` is known at compile-time
+template ansiStyleCode*(style: static[Style]): string =
+  (static(stylePrefix & $style.int & "m"))
+
+proc setStyle*(f: File, style: set[Style]) =
+  ## Sets the terminal style.
+  when defined(windows):
+    let h = conHandle(f)
+    var old = getAttributes(h) and (FOREGROUND_RGB or BACKGROUND_RGB)
+    var a = 0'i16
+    if styleBright in style: a = a or int16(FOREGROUND_INTENSITY)
+    if styleBlink in style: a = a or int16(BACKGROUND_INTENSITY)
+    if styleReverse in style: a = a or 0x4000'i16 # COMMON_LVB_REVERSE_VIDEO
+    if styleUnderscore in style: a = a or 0x8000'i16 # COMMON_LVB_UNDERSCORE
+    discard setConsoleTextAttribute(h, old or a)
+  else:
+    for s in items(style):
+      f.write(ansiStyleCode(s))
+
+proc writeStyled*(txt: string, style: set[Style] = {styleBright}) =
+  ## Writes the text `txt` in a given `style` to stdout.
+  when defined(windows):
+    let term = getTerminal()
+    var old = getAttributes(term.hStdout)
+    stdout.setStyle(style)
+    stdout.write(txt)
+    discard setConsoleTextAttribute(term.hStdout, old)
+  else:
+    stdout.setStyle(style)
+    stdout.write(txt)
+    stdout.resetAttributes()
+    if gFG != 0:
+      stdout.write(ansiStyleCode(gFG))
+    if gBG != 0:
+      stdout.write(ansiStyleCode(gBG))
+
+type
+  ForegroundColor* = enum ## Terminal's foreground colors.
+    fgBlack = 30,         ## black
+    fgRed,                ## red
+    fgGreen,              ## green
+    fgYellow,             ## yellow
+    fgBlue,               ## blue
+    fgMagenta,            ## magenta
+    fgCyan,               ## cyan
+    fgWhite,              ## white
+    fg8Bit,               ## 256-color (not supported, see `enableTrueColors` instead.)
+    fgDefault             ## default terminal foreground color
+
+  BackgroundColor* = enum ## Terminal's background colors.
+    bgBlack = 40,         ## black
+    bgRed,                ## red
+    bgGreen,              ## green
+    bgYellow,             ## yellow
+    bgBlue,               ## blue
+    bgMagenta,            ## magenta
+    bgCyan,               ## cyan
+    bgWhite,              ## white
+    bg8Bit,               ## 256-color (not supported, see `enableTrueColors` instead.)
+    bgDefault             ## default terminal background color
+
+when defined(windows):
+  var defaultForegroundColor, defaultBackgroundColor: int16 = 0xFFFF'i16 # Default to an invalid value 0xFFFF
+
+proc setForegroundColor*(f: File, fg: ForegroundColor, bright = false) =
+  ## Sets the terminal's foreground color.
+  when defined(windows):
+    let h = conHandle(f)
+    var old = getAttributes(h) and not FOREGROUND_RGB
+    if defaultForegroundColor == 0xFFFF'i16:
+      defaultForegroundColor = old
+    old = if bright: old or FOREGROUND_INTENSITY
+          else: old and not(FOREGROUND_INTENSITY)
+    const lookup: array[ForegroundColor, int] = [
+      0, # ForegroundColor enum with ordinal 30
+      (FOREGROUND_RED),
+      (FOREGROUND_GREEN),
+      (FOREGROUND_RED or FOREGROUND_GREEN),
+      (FOREGROUND_BLUE),
+      (FOREGROUND_RED or FOREGROUND_BLUE),
+      (FOREGROUND_BLUE or FOREGROUND_GREEN),
+      (FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED),
+      0, # fg8Bit not supported, see `enableTrueColors` instead.
+      0] # unused
+    if fg == fgDefault:
+      discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](defaultForegroundColor)))
+    else:
+      discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](lookup[fg])))
+  else:
+    gFG = ord(fg)
+    if bright: inc(gFG, 60)
+    f.write(ansiStyleCode(gFG))
+
+proc setBackgroundColor*(f: File, bg: BackgroundColor, bright = false) =
+  ## Sets the terminal's background color.
+  when defined(windows):
+    let h = conHandle(f)
+    var old = getAttributes(h) and not BACKGROUND_RGB
+    if defaultBackgroundColor == 0xFFFF'i16:
+      defaultBackgroundColor = old
+    old = if bright: old or BACKGROUND_INTENSITY
+          else: old and not(BACKGROUND_INTENSITY)
+    const lookup: array[BackgroundColor, int] = [
+      0, # BackgroundColor enum with ordinal 40
+      (BACKGROUND_RED),
+      (BACKGROUND_GREEN),
+      (BACKGROUND_RED or BACKGROUND_GREEN),
+      (BACKGROUND_BLUE),
+      (BACKGROUND_RED or BACKGROUND_BLUE),
+      (BACKGROUND_BLUE or BACKGROUND_GREEN),
+      (BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED),
+      0, # bg8Bit not supported, see `enableTrueColors` instead.
+      0] # unused
+    if bg == bgDefault:
+      discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](defaultBackgroundColor)))
+    else:
+      discard setConsoleTextAttribute(h, cast[int16](cast[uint16](old) or cast[uint16](lookup[bg])))
+  else:
+    gBG = ord(bg)
+    if bright: inc(gBG, 60)
+    f.write(ansiStyleCode(gBG))
+
+proc ansiForegroundColorCode*(fg: ForegroundColor, bright = false): string =
+  var style = ord(fg)
+  if bright: inc(style, 60)
+  return ansiStyleCode(style)
+
+template ansiForegroundColorCode*(fg: static[ForegroundColor],
+                                  bright: static[bool] = false): string =
+  ansiStyleCode(fg.int + bright.int * 60)
+
+proc ansiForegroundColorCode*(color: Color): string =
+  let rgb = extractRGB(color)
+  result = fmt"{fgPrefix}{rgb.r};{rgb.g};{rgb.b}m"
+
+template ansiForegroundColorCode*(color: static[Color]): string =
+  const rgb = extractRGB(color)
+  # no usage of `fmt`, see issue #7632
+  (static("$1$2;$3;$4m" % [$fgPrefix, $(rgb.r), $(rgb.g), $(rgb.b)]))
+
+proc ansiBackgroundColorCode*(color: Color): string =
+  let rgb = extractRGB(color)
+  result = fmt"{bgPrefix}{rgb.r};{rgb.g};{rgb.b}m"
+
+template ansiBackgroundColorCode*(color: static[Color]): string =
+  const rgb = extractRGB(color)
+  # no usage of `fmt`, see issue #7632
+  (static("$1$2;$3;$4m" % [$bgPrefix, $(rgb.r), $(rgb.g), $(rgb.b)]))
+
+proc setForegroundColor*(f: File, color: Color) =
+  ## Sets the terminal's foreground true color.
+  if getTerminal().trueColorIsEnabled:
+    f.write(ansiForegroundColorCode(color))
+
+proc setBackgroundColor*(f: File, color: Color) =
+  ## Sets the terminal's background true color.
+  if getTerminal().trueColorIsEnabled:
+    f.write(ansiBackgroundColorCode(color))
+
+proc setTrueColor(f: File, color: Color) =
+  let term = getTerminal()
+  if term.fgSetColor:
+    setForegroundColor(f, color)
+  else:
+    setBackgroundColor(f, color)
+
+proc isatty*(f: File): bool =
+  ## Returns true if `f` is associated with a terminal device.
+  when defined(posix):
+    proc isatty(fildes: FileHandle): cint {.
+      importc: "isatty", header: "<unistd.h>".}
+  else:
+    proc isatty(fildes: FileHandle): cint {.
+      importc: "_isatty", header: "<io.h>".}
+
+  result = isatty(getFileHandle(f)) != 0'i32
+
+type
+  TerminalCmd* = enum ## commands that can be expressed as arguments
+    resetStyle,       ## reset attributes
+    fgColor,          ## set foreground's true color
+    bgColor           ## set background's true color
+
+template styledEchoProcessArg(f: File, s: string) = write f, s
+template styledEchoProcessArg(f: File, style: Style) = setStyle(f, {style})
+template styledEchoProcessArg(f: File, style: set[Style]) = setStyle f, style
+template styledEchoProcessArg(f: File, color: ForegroundColor) =
+  setForegroundColor f, color
+template styledEchoProcessArg(f: File, color: BackgroundColor) =
+  setBackgroundColor f, color
+template styledEchoProcessArg(f: File, color: Color) =
+  setTrueColor f, color
+template styledEchoProcessArg(f: File, cmd: TerminalCmd) =
+  when cmd == resetStyle:
+    resetAttributes(f)
+  elif cmd in {fgColor, bgColor}:
+    let term = getTerminal()
+    term.fgSetColor = cmd == fgColor
+
+macro styledWrite*(f: File, m: varargs[typed]): untyped =
+  ## Similar to `write`, but treating terminal style arguments specially.
+  ## When some argument is `Style`, `set[Style]`, `ForegroundColor`,
+  ## `BackgroundColor` or `TerminalCmd` then it is not sent directly to
+  ## `f`, but instead corresponding terminal style proc is called.
+  runnableExamples("-r:off"):
+    stdout.styledWrite(fgRed, "red text ")
+    stdout.styledWrite(fgGreen, "green text")
+
+  var reset = false
+  result = newNimNode(nnkStmtList)
+
+  for i in countup(0, m.len - 1):
+    let item = m[i]
+    case item.kind
+    of nnkStrLit..nnkTripleStrLit:
+      if i == m.len - 1:
+        # optimize if string literal is last, just call write
+        result.add(newCall(bindSym"write", f, item))
+        if reset: result.add(newCall(bindSym"resetAttributes", f))
+        return
+      else:
+        # if it is string literal just call write, do not enable reset
+        result.add(newCall(bindSym"write", f, item))
+    else:
+      result.add(newCall(bindSym"styledEchoProcessArg", f, item))
+      reset = true
+  if reset: result.add(newCall(bindSym"resetAttributes", f))
+
+template styledWriteLine*(f: File, args: varargs[untyped]) =
+  ## Calls `styledWrite` and appends a newline at the end.
+  runnableExamples:
+    proc error(msg: string) =
+      styledWriteLine(stderr, fgRed, "Error: ", resetStyle, msg)
+
+  styledWrite(f, args)
+  write(f, "\n")
+
+template styledEcho*(args: varargs[untyped]) =
+  ## Echoes styles arguments to stdout using `styledWriteLine`.
+  stdout.styledWriteLine(args)
+
+proc getch*(): char =
+  ## Reads a single character from the terminal, blocking until it is entered.
+  ## The character is not printed to the terminal.
+  when defined(windows):
+    let fd = getStdHandle(STD_INPUT_HANDLE)
+    var keyEvent = KEY_EVENT_RECORD()
+    var numRead: cint
+    while true:
+      # Block until character is entered
+      doAssert(waitForSingleObject(fd, INFINITE) == WAIT_OBJECT_0)
+      doAssert(readConsoleInput(fd, addr(keyEvent), 1, addr(numRead)) != 0)
+      if numRead == 0 or keyEvent.eventType != 1 or keyEvent.bKeyDown == 0:
+        continue
+      return char(keyEvent.uChar)
+  else:
+    let fd = getFileHandle(stdin)
+    var oldMode: Termios
+    discard fd.tcGetAttr(addr oldMode)
+    fd.setRaw()
+    result = stdin.readChar()
+    discard fd.tcSetAttr(TCSADRAIN, addr oldMode)
+
+when defined(windows):
+  proc readPasswordFromStdin*(prompt: string, password: var string):
+                              bool {.tags: [ReadIOEffect, WriteIOEffect].} =
+    ## Reads a `password` from stdin without printing it. `password` must not
+    ## be `nil`! Returns `false` if the end of the file has been reached,
+    ## `true` otherwise.
+    password.setLen(0)
+    stdout.write(prompt)
+    let hi = createFileA("CONIN$",
+      GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0)
+    var mode = DWORD 0
+    discard getConsoleMode(hi, addr mode)
+    let origMode = mode
+    const
+      ENABLE_PROCESSED_INPUT = 1
+      ENABLE_ECHO_INPUT = 4
+    mode = (mode or ENABLE_PROCESSED_INPUT) and not ENABLE_ECHO_INPUT
+
+    discard setConsoleMode(hi, mode)
+    result = readLine(stdin, password)
+    discard setConsoleMode(hi, origMode)
+    discard closeHandle(hi)
+    stdout.write "\n"
+
+else:
+  import std/termios
+
+  proc readPasswordFromStdin*(prompt: string, password: var string):
+                            bool {.tags: [ReadIOEffect, WriteIOEffect].} =
+    password.setLen(0)
+    let fd = stdin.getFileHandle()
+    var cur, old: Termios
+    discard fd.tcGetAttr(cur.addr)
+    old = cur
+    cur.c_lflag = cur.c_lflag and not Cflag(ECHO)
+    discard fd.tcSetAttr(TCSADRAIN, cur.addr)
+    stdout.write prompt
+    result = stdin.readLine(password)
+    stdout.write "\n"
+    discard fd.tcSetAttr(TCSADRAIN, old.addr)
+
+proc readPasswordFromStdin*(prompt = "password: "): string =
+  ## Reads a password from stdin without printing it.
+  result = ""
+  discard readPasswordFromStdin(prompt, result)
+
+
+# Wrappers assuming output to stdout:
+template hideCursor*() = hideCursor(stdout)
+template showCursor*() = showCursor(stdout)
+template setCursorPos*(x, y: int) = setCursorPos(stdout, x, y)
+template setCursorXPos*(x: int) = setCursorXPos(stdout, x)
+when defined(windows):
+  template setCursorYPos*(x: int) = setCursorYPos(stdout, x)
+template cursorUp*(count = 1) = cursorUp(stdout, count)
+template cursorDown*(count = 1) = cursorDown(stdout, count)
+template cursorForward*(count = 1) = cursorForward(stdout, count)
+template cursorBackward*(count = 1) = cursorBackward(stdout, count)
+template eraseLine*() = eraseLine(stdout)
+template eraseScreen*() = eraseScreen(stdout)
+template setStyle*(style: set[Style]) =
+  setStyle(stdout, style)
+template setForegroundColor*(fg: ForegroundColor, bright = false) =
+  setForegroundColor(stdout, fg, bright)
+template setBackgroundColor*(bg: BackgroundColor, bright = false) =
+  setBackgroundColor(stdout, bg, bright)
+template setForegroundColor*(color: Color) =
+  setForegroundColor(stdout, color)
+template setBackgroundColor*(color: Color) =
+  setBackgroundColor(stdout, color)
+proc resetAttributes*() {.noconv.} =
+  ## Resets all attributes on stdout.
+  ## It is advisable to register this as a quit proc with
+  ## `exitprocs.addExitProc(resetAttributes)`.
+  resetAttributes(stdout)
+
+proc isTrueColorSupported*(): bool =
+  ## Returns true if a terminal supports true color.
+  return getTerminal().trueColorIsSupported
+
+when defined(windows):
+  import std/os
+
+proc enableTrueColors*() =
+  ## Enables true color.
+  var term = getTerminal()
+  when defined(windows):
+    var
+      ver: OSVERSIONINFO
+    ver.dwOSVersionInfoSize = sizeof(ver).DWORD
+    let res = getVersionExW(addr ver)
+    if res == 0:
+      term.trueColorIsSupported = false
+    else:
+      term.trueColorIsSupported = ver.dwMajorVersion > 10 or
+        (ver.dwMajorVersion == 10 and (ver.dwMinorVersion > 0 or
+        (ver.dwMinorVersion == 0 and ver.dwBuildNumber >= 10586)))
+    if not term.trueColorIsSupported:
+      term.trueColorIsSupported = getEnv("ANSICON_DEF").len > 0
+
+    if term.trueColorIsSupported:
+      if getEnv("ANSICON_DEF").len == 0:
+        var mode: DWORD = 0
+        if getConsoleMode(getStdHandle(STD_OUTPUT_HANDLE), addr(mode)) != 0:
+          mode = mode or ENABLE_VIRTUAL_TERMINAL_PROCESSING
+          if setConsoleMode(getStdHandle(STD_OUTPUT_HANDLE), mode) != 0:
+            term.trueColorIsEnabled = true
+          else:
+            term.trueColorIsEnabled = false
+      else:
+        term.trueColorIsEnabled = true
+  else:
+    term.trueColorIsSupported = getEnv("COLORTERM").toLowerAscii() in [
+        "truecolor", "24bit"]
+    term.trueColorIsEnabled = term.trueColorIsSupported
+
+proc disableTrueColors*() =
+  ## Disables true color.
+  var term = getTerminal()
+  when defined(windows):
+    if term.trueColorIsSupported:
+      if getEnv("ANSICON_DEF").len == 0:
+        var mode: DWORD = 0
+        if getConsoleMode(getStdHandle(STD_OUTPUT_HANDLE), addr(mode)) != 0:
+          mode = mode and not ENABLE_VIRTUAL_TERMINAL_PROCESSING
+          discard setConsoleMode(getStdHandle(STD_OUTPUT_HANDLE), mode)
+      term.trueColorIsEnabled = false
+  else:
+    term.trueColorIsEnabled = false
+
+proc newTerminal(): owned(PTerminal) =
+  new result
+  when defined(windows):
+    initTerminal(result)
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 70cb038a7..e59153455 100755..100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -1,311 +1,2889 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
+##[
+  The `times` module contains routines and types for dealing with time using
+  the `proleptic Gregorian calendar<https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar>`_.
+  It's also available for the
+  `JavaScript target <backends.html#backends-the-javascript-target>`_.
 
-## This module contains routines and types for dealing with time.
-## This module is available for the ECMAScript target.
+  Although the `times` module supports nanosecond time resolution, the
+  resolution used by `getTime()` depends on the platform and backend
+  (JS is limited to millisecond precision).
 
-{.push debugger:off .} # the user does not want to trace a part
-                       # of the standard library!
+  Examples
+  ========
 
-import
-  strutils
+    ```nim
+    import std/[times, os]
+    # Simple benchmarking
+    let time = cpuTime()
+    sleep(100) # Replace this with something to be timed
+    echo "Time taken: ", cpuTime() - time
+
+    # Current date & time
+    let now1 = now()     # Current timestamp as a DateTime in local time
+    let now2 = now().utc # Current timestamp as a DateTime in UTC
+    let now3 = getTime() # Current timestamp as a Time
+
+    # Arithmetic using Duration
+    echo "One hour from now      : ", now() + initDuration(hours = 1)
+    # Arithmetic using TimeInterval
+    echo "One year from now      : ", now() + 1.years
+    echo "One month from now     : ", now() + 1.months
+    ```
+
+  Parsing and Formatting Dates
+  ============================
+
+  The `DateTime` type can be parsed and formatted using the different
+  `parse` and `format` procedures.
+
+    ```nim
+    let dt = parse("2000-01-01", "yyyy-MM-dd")
+    echo dt.format("yyyy-MM-dd")
+    ```
+
+  The different format patterns that are supported are documented below.
+
+  ===========  =================================================================================  ==============================================
+  Pattern      Description                                                                        Example
+  ===========  =================================================================================  ==============================================
+  `d`          Numeric value representing the day of the month,                                   | `1/04/2012 -> 1`
+               it will be either one or two digits long.                                          | `21/04/2012 -> 21`
+  `dd`         Same as above, but is always two digits.                                           | `1/04/2012 -> 01`
+                                                                                                  | `21/04/2012 -> 21`
+  `ddd`        Three letter string which indicates the day of the week.                           | `Saturday -> Sat`
+                                                                                                  | `Monday -> Mon`
+  `dddd`       Full string for the day of the week.                                               | `Saturday -> Saturday`
+                                                                                                  | `Monday -> Monday`
+  `GG`         The last two digits of the Iso Week-Year                                           | `30/12/2012 -> 13`
+  `GGGG`       The Iso week-calendar year padded to four digits                                   | `30/12/2012 -> 2013`
+  `h`          The hours in one digit if possible. Ranging from 1-12.                             | `5pm -> 5`
+                                                                                                  | `2am -> 2`
+  `hh`         The hours in two digits always. If the hour is one digit, 0 is prepended.          | `5pm -> 05`
+                                                                                                  | `11am -> 11`
+  `H`          The hours in one digit if possible, ranging from 0-23.                             | `5pm -> 17`
+                                                                                                  | `2am -> 2`
+  `HH`         The hours in two digits always. 0 is prepended if the hour is one digit.           | `5pm -> 17`
+                                                                                                  | `2am -> 02`
+  `m`          The minutes in one digit if possible.                                              | `5:30 -> 30`
+                                                                                                  | `2:01 -> 1`
+  `mm`         Same as above but always two digits, 0 is prepended if the minute is one digit.    | `5:30 -> 30`
+                                                                                                  | `2:01 -> 01`
+  `M`          The month in one digit if possible.                                                | `September -> 9`
+                                                                                                  | `December -> 12`
+  `MM`         The month in two digits always. 0 is prepended if the month value is one digit.    | `September -> 09`
+                                                                                                  | `December -> 12`
+  `MMM`        Abbreviated three-letter form of the month.                                        | `September -> Sep`
+                                                                                                  | `December -> Dec`
+  `MMMM`       Full month string, properly capitalized.                                           | `September -> September`
+  `s`          Seconds as one digit if possible.                                                  | `00:00:06 -> 6`
+  `ss`         Same as above but always two digits. 0 is prepended if the second is one digit.    | `00:00:06 -> 06`
+  `t`          `A` when time is in the AM. `P` when time is in the PM.                            | `5pm -> P`
+                                                                                                  | `2am -> A`
+  `tt`         Same as above, but `AM` and `PM` instead of `A` and `P` respectively.              | `5pm -> PM`
+                                                                                                  | `2am -> AM`
+  `yy`         The last two digits of the year. When parsing, the current century is assumed.     | `2012 AD -> 12`
+  `yyyy`       The year, padded to at least four digits.                                          | `2012 AD -> 2012`
+               Is always positive, even when the year is BC.                                      | `24 AD -> 0024`
+               When the year is more than four digits, '+' is prepended.                          | `24 BC -> 00024`
+                                                                                                  | `12345 AD -> +12345`
+  `YYYY`       The year without any padding.                                                      | `2012 AD -> 2012`
+               Is always positive, even when the year is BC.                                      | `24 AD -> 24`
+                                                                                                  | `24 BC -> 24`
+                                                                                                  | `12345 AD -> 12345`
+  `uuuu`       The year, padded to at least four digits. Will be negative when the year is BC.    | `2012 AD -> 2012`
+               When the year is more than four digits, '+' is prepended unless the year is BC.    | `24 AD -> 0024`
+                                                                                                  | `24 BC -> -0023`
+                                                                                                  | `12345 AD -> +12345`
+  `UUUU`       The year without any padding. Will be negative when the year is BC.                | `2012 AD -> 2012`
+                                                                                                  | `24 AD -> 24`
+                                                                                                  | `24 BC -> -23`
+                                                                                                  | `12345 AD -> 12345`
+  `V`          The Iso Week-Number as one or two digits                                           | `3/2/2012 -> 5`
+                                                                                                  | `1/4/2012 -> 13`
+  `VV`         The Iso Week-Number as two digits always. 0 is prepended if one digit.             | `3/2/2012 -> 05`
+                                                                                                  | `1/4/2012 -> 13`
+  `z`          Displays the timezone offset from UTC.                                             | `UTC+7 -> +7`
+                                                                                                  | `UTC-5 -> -5`
+  `zz`         Same as above but with leading 0.                                                  | `UTC+7 -> +07`
+                                                                                                  | `UTC-5 -> -05`
+  `zzz`        Same as above but with `:mm` where *mm* represents minutes.                        | `UTC+7 -> +07:00`
+                                                                                                  | `UTC-5 -> -05:00`
+  `ZZZ`        Same as above but with `mm` where *mm* represents minutes.                         | `UTC+7 -> +0700`
+                                                                                                  | `UTC-5 -> -0500`
+  `zzzz`       Same as above but with `:ss` where *ss* represents seconds.                        | `UTC+7 -> +07:00:00`
+                                                                                                  | `UTC-5 -> -05:00:00`
+  `ZZZZ`       Same as above but with `ss` where *ss* represents seconds.                         | `UTC+7 -> +070000`
+                                                                                                  | `UTC-5 -> -050000`
+  `g`          Era: AD or BC                                                                      | `300 AD -> AD`
+                                                                                                  | `300 BC -> BC`
+  `fff`        Milliseconds display                                                               | `1000000 nanoseconds -> 1`
+  `ffffff`     Microseconds display                                                               | `1000000 nanoseconds -> 1000`
+  `fffffffff`  Nanoseconds display                                                                | `1000000 nanoseconds -> 1000000`
+  ===========  =================================================================================  ==============================================
+
+  Other strings can be inserted by putting them in `''`. For example
+  `hh'->'mm` will give `01->56`.  In addition to spaces,
+  the following characters can be inserted without quoting them:
+  `:` `-` `,` `.` `(` `)` `/` `[` `]`.
+  A literal `'` can be specified with `''`.
+
+  However you don't need to necessarily separate format patterns, as an
+  unambiguous format string like `yyyyMMddhhmmss` is also valid (although
+  only for years in the range 1..9999).
+
+  Duration vs TimeInterval
+  ============================
+  The `times` module exports two similar types that are both used to
+  represent some amount of time: `Duration <#Duration>`_ and
+  `TimeInterval <#TimeInterval>`_.
+  This section explains how they differ and when one should be preferred over the
+  other (short answer: use `Duration` unless support for months and years is
+  needed).
+
+  Duration
+  ----------------------------
+  A `Duration` represents a duration of time stored as seconds and
+  nanoseconds. A `Duration` is always fully normalized, so
+  `initDuration(hours = 1)` and `initDuration(minutes = 60)` are equivalent.
+
+  Arithmetic with a `Duration` is very fast, especially when used with the
+  `Time` type, since it only involves basic arithmetic. Because `Duration`
+  is more performant and easier to understand it should generally preferred.
+
+  TimeInterval
+  ----------------------------
+  A `TimeInterval` represents an amount of time expressed in calendar
+  units, for example "1 year and 2 days". Since some units cannot be
+  normalized (the length of a year is different for leap years for example),
+  the `TimeInterval` type uses separate fields for every unit. The
+  `TimeInterval`'s returned from this module generally don't normalize
+  **anything**, so even units that could be normalized (like seconds,
+  milliseconds and so on) are left untouched.
+
+  Arithmetic with a `TimeInterval` can be very slow, because it requires
+  timezone information.
+
+  Since it's slower and more complex, the `TimeInterval` type should be
+  avoided unless the program explicitly needs the features it offers that
+  `Duration` doesn't have.
+
+  How long is a day?
+  ----------------------------
+  It should be especially noted that the handling of days differs between
+  `TimeInterval` and `Duration`. The `Duration` type always treats a day
+  as exactly 86400 seconds. For `TimeInterval`, it's more complex.
+
+  As an example, consider the amount of time between these two timestamps, both
+  in the same timezone:
+
+    - 2018-03-25T12:00+02:00
+    - 2018-03-26T12:00+01:00
+
+  If only the date & time is considered, it appears that exactly one day has
+  passed. However, the UTC offsets are different, which means that the
+  UTC offset was changed somewhere in between. This happens twice each year for
+  timezones that use daylight savings time. Because of this change, the amount
+  of time that has passed is actually 25 hours.
+
+  The `TimeInterval` type uses calendar units, and will say that exactly one
+  day has passed. The `Duration` type on the other hand normalizes everything
+  to seconds, and will therefore say that 90000 seconds has passed, which is
+  the same as 25 hours.
+
+  See also
+  ========
+  * `monotimes module <monotimes.html>`_
+]##
+
+import std/[strutils, math, options]
+
+import std/private/since
+include "system/inclrtl"
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+when defined(js):
+  import std/jscore
+
+  # This is really bad, but overflow checks are broken badly for
+  # ints on the JS backend. See #6752.
+  {.push overflowChecks: off.}
+  proc `*`(a, b: int64): int64 =
+    system.`*`(a, b)
+  proc `*`(a, b: int): int =
+    system.`*`(a, b)
+  proc `+`(a, b: int64): int64 =
+    system.`+`(a, b)
+  proc `+`(a, b: int): int =
+    system.`+`(a, b)
+  proc `-`(a, b: int64): int64 =
+    system.`-`(a, b)
+  proc `-`(a, b: int): int =
+    system.`-`(a, b)
+  proc inc(a: var int, b: int) =
+    system.inc(a, b)
+  proc inc(a: var int64, b: int) =
+    system.inc(a, b)
+  {.pop.}
+
+elif defined(posix):
+  import std/posix
+
+  type CTime = posix.Time
+
+  when defined(macosx):
+    proc gettimeofday(tp: var Timeval, unused: pointer = nil)
+      {.importc: "gettimeofday", header: "<sys/time.h>", sideEffect.}
 
-type
-  TMonth* = enum ## represents a month
-    mJan, mFeb, mMar, mApr, mMay, mJun, mJul, mAug, mSep, mOct, mNov, mDec
-  TWeekDay* = enum ## represents a weekday
-    dMon, dTue, dWed, dThu, dFri, dSat, dSun
-    
-when defined(posix): 
-  type
-    TTime* = distinct int ## distinct type that represents a time
 elif defined(windows):
-  when defined(vcc):
-    # newest version of Visual C++ defines time_t to be of 64 bits
-    type TTime* = distinct int64
-  else:
-    type TTime* = distinct int32
-elif defined(ECMAScript):
+  import std/winlean, std/time_t
+
   type
-    TTime* {.final.} = object
-      getDay: proc (): int
-      getFullYear: proc (): int
-      getHours: proc (): int
-      getMilliseconds: proc (): int
-      getMinutes: proc (): int
-      getMonth: proc (): int
-      getSeconds: proc (): int
-      getTime: proc (): int
-      getTimezoneOffset: proc (): int
-      getUTCDate: proc (): int
-      getUTCFullYear: proc (): int
-      getUTCHours: proc (): int
-      getUTCMilliseconds: proc (): int
-      getUTCMinutes: proc (): int
-      getUTCMonth: proc (): int
-      getUTCSeconds: proc (): int
-      getYear: proc (): int
-      parse: proc (s: cstring): TTime
-      setDate: proc (x: int)
-      setFullYear: proc (x: int)
-      setHours: proc (x: int)
-      setMilliseconds: proc (x: int)
-      setMinutes: proc (x: int)
-      setMonth: proc (x: int)
-      setSeconds: proc (x: int)
-      setTime: proc (x: int)
-      setUTCDate: proc (x: int)
-      setUTCFullYear: proc (x: int)
-      setUTCHours: proc (x: int)
-      setUTCMilliseconds: proc (x: int)
-      setUTCMinutes: proc (x: int)
-      setUTCMonth: proc (x: int)
-      setUTCSeconds: proc (x: int)
-      setYear: proc (x: int)
-      toGMTString: proc (): cstring
-      toLocaleString: proc (): cstring
-      UTC: proc (): int
+    CTime = time_t.Time
+    Tm {.importc: "struct tm", header: "<time.h>", final, pure.} = object
+      tm_sec*: cint   ## Seconds [0,60].
+      tm_min*: cint   ## Minutes [0,59].
+      tm_hour*: cint  ## Hour [0,23].
+      tm_mday*: cint  ## Day of month [1,31].
+      tm_mon*: cint   ## Month of year [0,11].
+      tm_year*: cint  ## Years since 1900.
+      tm_wday*: cint  ## Day of week [0,6] (Sunday =0).
+      tm_yday*: cint  ## Day of year [0,365].
+      tm_isdst*: cint ## Daylight Savings flag.
+
+  proc localtime(a1: var CTime): ptr Tm {.importc, header: "<time.h>", sideEffect.}
 
 type
-  TTimeInfo* = object of TObject ## represents a time in different parts
-    second*: range[0..61]     ## The number of seconds after the minute,
-                              ## normally in the range 0 to 59, but can
-                              ## be up to 61 to allow for leap seconds.
-    minute*: range[0..59]     ## The number of minutes after the hour,
-                              ## in the range 0 to 59.
-    hour*: range[0..23]       ## The number of hours past midnight,
-                              ## in the range 0 to 23.
-    monthday*: range[1..31]   ## The day of the month, in the range 1 to 31.
-    month*: TMonth            ## The current month.
-    year*: int                ## The current year.
-    weekday*: TWeekDay        ## The current day of the week.
-    yearday*: range[0..365]   ## The number of days since January 1,
-                              ## in the range 0 to 365.
-                              ## Always 0 if the target is ECMAScript.
-
-proc getTime*(): TTime ## gets the current calendar time
-proc getLocalTime*(t: TTime): TTimeInfo
-  ## converts the calendar time `t` to broken-time representation,
-  ## expressed relative to the user's specified time zone.
-proc getGMTime*(t: TTime): TTimeInfo
-  ## converts the calendar time `t` to broken-down time representation,
-  ## expressed in Coordinated Universal Time (UTC).
-
-proc TimeInfoToTime*(timeInfo: TTimeInfo): TTime
-  ## converts a broken-down time structure, expressed as local time, to
-  ## calendar time representation. The function ignores the specified
-  ## contents of the structure members `weekday` and `yearday` and recomputes
-  ## them from the other information in the broken-down time structure.
-
-proc `$` *(timeInfo: TTimeInfo): string
-  ## converts a `TTimeInfo` object to a string representation.
-proc `$` *(time: TTime): string
-  ## converts a calendar time to a string representation.
-
-proc getDateStr*(): string
-  ## gets the current date as a string of the format
-  ## ``YYYY-MM-DD``.
-proc getClockStr*(): string
-  ## gets the current clock time as a string of the format ``HH:MM:SS``.
-
-proc `-` *(a, b: TTime): int64
-  ## computes the difference of two calendar times. Result is in seconds.
-
-proc `<` * (a, b: TTime): bool = 
-  ## returns true iff ``a < b``, that is iff a happened before b.
-  result = a - b < 0
-  
-proc `<=` * (a, b: TTime): bool = 
-  ## returns true iff ``a <= b``.
-  result = a - b <= 0
-
-proc getStartMilsecs*(): int
-  ## get the miliseconds from the start of the program
-
-
-when not defined(ECMAScript):  
-  # C wrapper:
-  type
-    structTM {.importc: "struct tm", final.} = object
-      second {.importc: "tm_sec".},
-        minute {.importc: "tm_min".},
-        hour {.importc: "tm_hour".},
-        monthday {.importc: "tm_mday".},
-        month {.importc: "tm_mon".},
-        year {.importc: "tm_year".},
-        weekday {.importc: "tm_wday".},
-        yearday {.importc: "tm_yday".},
-        isdst {.importc: "tm_isdst".}: cint
-  
-    PTimeInfo = ptr structTM
-    PTime = ptr TTime
-  
-    TClock {.importc: "clock_t".} = range[low(int)..high(int)]
-  
-  proc localtime(timer: PTime): PTimeInfo {.
-    importc: "localtime", header: "<time.h>".}
-  proc gmtime(timer: PTime): PTimeInfo {.importc: "gmtime", header: "<time.h>".}
-  proc timec(timer: PTime): TTime      {.importc: "time", header: "<time.h>".}
-  proc mktime(t: structTM): TTime      {.importc: "mktime", header: "<time.h>".}
-  proc asctime(tblock: structTM): CString {.
-    importc: "asctime", header: "<time.h>".}
-  proc ctime(time: PTime): CString     {.importc: "ctime", header: "<time.h>".}
-  #  strftime(s: CString, maxsize: int, fmt: CString, t: tm): int {.
-  #    importc: "strftime", header: "<time.h>".}
-  proc clock(): TClock {.importc: "clock", header: "<time.h>".}
-  proc difftime(a, b: TTime): float {.importc: "difftime", header: "<time.h>".}
-  
-  var
-    clocksPerSec {.importc: "CLOCKS_PER_SEC", nodecl.}: int
-  
-  
-  # our own procs on top of that:
-  proc tmToTimeInfo(tm: structTM): TTimeInfo =
-    const
-      weekDays: array [0..6, TWeekDay] = [
-        dSun, dMon, dTue, dWed, dThu, dFri, dSat]
-    result.second = int(tm.second)
-    result.minute = int(tm.minute)
-    result.hour = int(tm.hour)
-    result.monthday = int(tm.monthday)
-    result.month = TMonth(tm.month)
-    result.year = tm.year + 1900'i32
-    result.weekday = weekDays[int(tm.weekDay)]
-    result.yearday = int(tm.yearday)
-  
-  proc timeInfoToTM(t: TTimeInfo): structTM =
-    const
-      weekDays: array [TWeekDay, int] = [1, 2, 3, 4, 5, 6, 0]
-    result.second = t.second
-    result.minute = t.minute
-    result.hour = t.hour
-    result.monthday = t.monthday
-    result.month = ord(t.month)
-    result.year = t.year - 1900
-    result.weekday = weekDays[t.weekDay]
-    result.yearday = t.yearday
-    result.isdst = -1
-  
-  proc `-` (a, b: TTime): int64 =
-    return toBiggestInt(difftime(a, b))
-  
-  proc getStartMilsecs(): int =
-    #echo "clocks per sec: ", clocksPerSec
-    #return clock() div (clocksPerSec div 1000)
-    result = toInt(toFloat(clock()) / (toFloat(clocksPerSec) / 1000.0))
-    
-  proc getTime(): TTime = return timec(nil)
-  proc getLocalTime(t: TTime): TTimeInfo =
-    var a = t
-    result = tmToTimeInfo(localtime(addr(a))^)
-    # copying is needed anyway to provide reentrancity; thus
-    # the convertion is not expensive
-  
-  proc getGMTime(t: TTime): TTimeInfo =
-    var a = t
-    result = tmToTimeInfo(gmtime(addr(a))^)
-    # copying is needed anyway to provide reentrancity; thus
-    # the convertion is not expensive
-  
-  proc TimeInfoToTime(timeInfo: TTimeInfo): TTime =
-    var cTimeInfo = timeInfo # for C++ we have to make a copy,
-    # because the header of mktime is broken in my version of libc
-    return mktime(timeInfoToTM(cTimeInfo))
-    
-  proc toStringTillNL(p: cstring): string = 
-    result = ""
-    var i = 0
-    while p[i] != '\0' and p[i] != '\10' and p[i] != '\13': 
-      add(result, p[i])
-      inc(i)
-    return result
-    
-  proc `$`(timeInfo: TTimeInfo): string =
-    # BUGFIX: asctime returns a newline at the end!
-    var p = asctime(timeInfoToTM(timeInfo))
-    result = toStringTillNL(p)
-  
-  proc `$`(time: TTime): string =
-    # BUGFIX: ctime returns a newline at the end!
-    var a = time
-    return toStringTillNL(ctime(addr(a)))
-
-  const
-    epochDiff = 116444736000000000'i64
-    rateDiff = 10000000'i64 # 100 nsecs
-
-  proc unixTimeToWinTime*(t: TTime): int64 = 
-    ## converts a UNIX `TTime` (``time_t``) to a Windows file time
-    result = int64(t) * rateDiff + epochDiff
-    
-  proc winTimeToUnixTime*(t: int64): TTime = 
-    ## converts a Windows time to a UNIX `TTime` (``time_t``)
-    result = TTime((t - epochDiff) div rateDiff)
+  Month* = enum ## Represents a month. Note that the enum starts at `1`,
+                ## so `ord(month)` will give the month number in the
+                ## range `1..12`.
+    mJan = (1, "January")
+    mFeb = "February"
+    mMar = "March"
+    mApr = "April"
+    mMay = "May"
+    mJun = "June"
+    mJul = "July"
+    mAug = "August"
+    mSep = "September"
+    mOct = "October"
+    mNov = "November"
+    mDec = "December"
+
+  WeekDay* = enum ## Represents a weekday.
+    dMon = "Monday"
+    dTue = "Tuesday"
+    dWed = "Wednesday"
+    dThu = "Thursday"
+    dFri = "Friday"
+    dSat = "Saturday"
+    dSun = "Sunday"
+
+type
+  MonthdayRange* = range[1..31]
+  HourRange* = range[0..23]
+  MinuteRange* = range[0..59]
+  SecondRange* = range[0..60] ## \
+    ## Includes the value 60 to allow for a leap second. Note however
+    ## that the `second` of a `DateTime` will never be a leap second.
+  YeardayRange* = range[0..365]
+  NanosecondRange* = range[0..999_999_999]
+
+  IsoWeekRange* = range[1 .. 53]
+    ## An ISO 8601 calendar week number.
+  IsoYear* = distinct int
+    ## An ISO 8601 calendar year number.
+    ##
+    ## .. warning:: The ISO week-based year can correspond to the following or previous year from 29 December to January 3.
+
+  Time* = object ## Represents a point in time.
+    seconds: int64
+    nanosecond: NanosecondRange
+
+  DateTime* = object of RootObj  ## \
+    ## Represents a time in different parts. Although this type can represent
+    ## leap seconds, they are generally not supported in this module. They are
+    ## not ignored, but the `DateTime`'s returned by procedures in this
+    ## module will never have a leap second.
+    nanosecond: NanosecondRange
+    second: SecondRange
+    minute: MinuteRange
+    hour: HourRange
+    monthdayZero: int
+    monthZero: int
+    year: int
+    weekday: WeekDay
+    yearday: YeardayRange
+    isDst: bool
+    timezone: Timezone
+    utcOffset: int
+
+  Duration* = object ## Represents a fixed duration of time, meaning a duration
+                     ## that has constant length independent of the context.
+                     ##
+                     ## To create a new `Duration`, use `initDuration
+                     ## <#initDuration,int64,int64,int64,int64,int64,int64,int64,int64>`_.
+                     ## Instead of trying to access the private attributes, use
+                     ## `inSeconds <#inSeconds,Duration>`_ for converting to seconds and
+                     ## `inNanoseconds <#inNanoseconds,Duration>`_ for converting to nanoseconds.
+    seconds: int64
+    nanosecond: NanosecondRange
+
+  TimeUnit* = enum ## Different units of time.
+    Nanoseconds, Microseconds, Milliseconds, Seconds, Minutes, Hours, Days,
+    Weeks, Months, Years
+
+  FixedTimeUnit* = range[Nanoseconds..Weeks] ## \
+      ## Subrange of `TimeUnit` that only includes units of fixed duration.
+      ## These are the units that can be represented by a `Duration`.
+
+  TimeInterval* = object ## \
+      ## Represents a non-fixed duration of time. Can be used to add and
+      ## subtract non-fixed time units from a `DateTime <#DateTime>`_ or
+      ## `Time <#Time>`_.
+      ##
+      ## Create a new `TimeInterval` with `initTimeInterval proc
+      ## <#initTimeInterval,int,int,int,int,int,int,int,int,int,int>`_.
+      ##
+      ## Note that `TimeInterval` doesn't represent a fixed duration of time,
+      ## since the duration of some units depend on the context (e.g a year
+      ## can be either 365 or 366 days long). The non-fixed time units are
+      ## years, months, days and week.
+      ##
+      ## Note that `TimeInterval`'s returned from the `times` module are
+      ## never normalized. If you want to normalize a time unit,
+      ## `Duration <#Duration>`_ should be used instead.
+    nanoseconds*: int    ## The number of nanoseconds
+    microseconds*: int   ## The number of microseconds
+    milliseconds*: int   ## The number of milliseconds
+    seconds*: int        ## The number of seconds
+    minutes*: int        ## The number of minutes
+    hours*: int          ## The number of hours
+    days*: int           ## The number of days
+    weeks*: int          ## The number of weeks
+    months*: int         ## The number of months
+    years*: int          ## The number of years
+
+  Timezone* = ref object ## \
+      ## Timezone interface for supporting `DateTime <#DateTime>`_\s of arbitrary
+      ## timezones. The `times` module only supplies implementations for the
+      ## system's local time and UTC.
+    zonedTimeFromTimeImpl: proc (x: Time): ZonedTime
+        {.tags: [], raises: [], benign.}
+    zonedTimeFromAdjTimeImpl: proc (x: Time): ZonedTime
+        {.tags: [], raises: [], benign.}
+    name: string
+
+  ZonedTime* = object ## Represents a point in time with an associated
+                      ## UTC offset and DST flag. This type is only used for
+                      ## implementing timezones.
+    time*: Time       ## The point in time being represented.
+    utcOffset*: int   ## The offset in seconds west of UTC,
+                      ## including any offset due to DST.
+    isDst*: bool      ## Determines whether DST is in effect.
+
+  DurationParts* = array[FixedTimeUnit, int64] # Array of Duration parts starts
+  TimeIntervalParts* = array[TimeUnit, int] # Array of Duration parts starts
+
+const
+  secondsInMin = 60
+  secondsInHour = 60*60
+  secondsInDay = 60*60*24
+  rateDiff = 10000000'i64 # 100 nsecs
+                          # The number of hectonanoseconds between 1601/01/01 (windows epoch)
+                          # and 1970/01/01 (unix epoch).
+  epochDiff = 116444736000000000'i64
+
+const unitWeights: array[FixedTimeUnit, int64] = [
+  1'i64,
+  1000,
+  1_000_000,
+  1e9.int64,
+  secondsInMin * 1e9.int64,
+  secondsInHour * 1e9.int64,
+  secondsInDay * 1e9.int64,
+  7 * secondsInDay * 1e9.int64,
+]
+
+when (NimMajor, NimMinor) >= (1, 4):
+  # Newer versions of Nim don't track defects
+  {.pragma: parseFormatRaises, raises: [TimeParseError, TimeFormatParseError].}
+  {.pragma: parseRaises, raises: [TimeParseError].}
+else:
+  # Still track when using older versions
+  {.pragma: parseFormatRaises, raises: [TimeParseError, TimeFormatParseError, Defect].}
+  {.pragma: parseRaises, raises: [TimeParseError, Defect].}
+
+
+#
+# Helper procs
+#
+
+{.pragma: operator, rtl, noSideEffect, benign.}
+
+proc convert*[T: SomeInteger](unitFrom, unitTo: FixedTimeUnit, quantity: T): T
+    {.inline.} =
+  ## Convert a quantity of some duration unit to another duration unit.
+  ## This proc only deals with integers, so the result might be truncated.
+  runnableExamples:
+    doAssert convert(Days, Hours, 2) == 48
+    doAssert convert(Days, Weeks, 13) == 1 # Truncated
+    doAssert convert(Seconds, Milliseconds, -1) == -1000
+  if unitFrom < unitTo:
+    (quantity div (unitWeights[unitTo] div unitWeights[unitFrom])).T
+  else:
+    ((unitWeights[unitFrom] div unitWeights[unitTo]) * quantity).T
+
+proc normalize[T: Duration|Time](seconds, nanoseconds: int64): T =
+  ## Normalize a (seconds, nanoseconds) pair and return it as either
+  ## a `Duration` or `Time`. A normalized `Duration|Time` has a
+  ## positive nanosecond part in the range `NanosecondRange`.
+  result.seconds = seconds + convert(Nanoseconds, Seconds, nanoseconds)
+  var nanosecond = nanoseconds mod convert(Seconds, Nanoseconds, 1)
+  if nanosecond < 0:
+    nanosecond += convert(Seconds, Nanoseconds, 1)
+    result.seconds -= 1
+  result.nanosecond = nanosecond.int
+
+proc isLeapYear*(year: int): bool =
+  ## Returns true if `year` is a leap year.
+  runnableExamples:
+    doAssert isLeapYear(2000)
+    doAssert not isLeapYear(1900)
+  year mod 4 == 0 and (year mod 100 != 0 or year mod 400 == 0)
+
+proc getDaysInMonth*(month: Month, year: int): int =
+  ## Get the number of days in `month` of `year`.
+  # http://www.dispersiondesign.com/articles/time/number_of_days_in_a_month
+  runnableExamples:
+    doAssert getDaysInMonth(mFeb, 2000) == 29
+    doAssert getDaysInMonth(mFeb, 2001) == 28
+  case month
+  of mFeb: result = if isLeapYear(year): 29 else: 28
+  of mApr, mJun, mSep, mNov: result = 30
+  else: result = 31
+
+proc assertValidDate(monthday: MonthdayRange, month: Month, year: int)
+    {.inline.} =
+  assert monthday <= getDaysInMonth(month, year),
+    $year & "-" & intToStr(ord(month), 2) & "-" & $monthday &
+      " is not a valid date"
+
+proc toEpochDay(monthday: MonthdayRange, month: Month, year: int): int64 =
+  ## Get the epoch day from a year/month/day date.
+  ## The epoch day is the number of days since 1970/01/01
+  ## (it might be negative).
+  # Based on http://howardhinnant.github.io/date_algorithms.html
+  assertValidDate monthday, month, year
+  var (y, m, d) = (year, ord(month), monthday.int)
+  if m <= 2:
+    y.dec
+
+  let era = (if y >= 0: y else: y-399) div 400
+  let yoe = y - era * 400
+  let doy = (153 * (m + (if m > 2: -3 else: 9)) + 2) div 5 + d-1
+  let doe = yoe * 365 + yoe div 4 - yoe div 100 + doy
+  return era * 146097 + doe - 719468
+
+proc fromEpochDay(epochday: int64):
+    tuple[monthday: MonthdayRange, month: Month, year: int] =
+  ## Get the year/month/day date from a epoch day.
+  ## The epoch day is the number of days since 1970/01/01
+  ## (it might be negative).
+  # Based on http://howardhinnant.github.io/date_algorithms.html
+  var z = epochday
+  z.inc 719468
+  let era = (if z >= 0: z else: z - 146096) div 146097
+  let doe = z - era * 146097
+  let yoe = (doe - doe div 1460 + doe div 36524 - doe div 146096) div 365
+  let y = yoe + era * 400;
+  let doy = doe - (365 * yoe + yoe div 4 - yoe div 100)
+  let mp = (5 * doy + 2) div 153
+  let d = doy - (153 * mp + 2) div 5 + 1
+  let m = mp + (if mp < 10: 3 else: -9)
+  return (d.MonthdayRange, m.Month, (y + ord(m <= 2)).int)
+
+proc getDayOfYear*(monthday: MonthdayRange, month: Month, year: int):
+    YeardayRange {.tags: [], raises: [], benign.} =
+  ## Returns the day of the year.
+  ## Equivalent with `dateTime(year, month, monthday, 0, 0, 0, 0).yearday`.
+  runnableExamples:
+    doAssert getDayOfYear(1, mJan, 2000) == 0
+    doAssert getDayOfYear(10, mJan, 2000) == 9
+    doAssert getDayOfYear(10, mFeb, 2000) == 40
+
+  assertValidDate monthday, month, year
+  const daysUntilMonth: array[Month, int] =
+    [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
+  const daysUntilMonthLeap: array[Month, int] =
+    [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]
+
+  if isLeapYear(year):
+    result = daysUntilMonthLeap[month] + monthday - 1
+  else:
+    result = daysUntilMonth[month] + monthday - 1
+
+proc getDayOfWeek*(monthday: MonthdayRange, month: Month, year: int): WeekDay
+    {.tags: [], raises: [], benign.} =
+  ## Returns the day of the week enum from day, month and year.
+  ## Equivalent with `dateTime(year, month, monthday, 0, 0, 0, 0).weekday`.
+  runnableExamples:
+    doAssert getDayOfWeek(13, mJun, 1990) == dWed
+    doAssert $getDayOfWeek(13, mJun, 1990) == "Wednesday"
+
+  assertValidDate monthday, month, year
+  # 1970-01-01 is a Thursday, we adjust to the previous Monday
+  let days = toEpochDay(monthday, month, year) - 3
+  let weeks = floorDiv(days, 7'i64)
+  let wd = days - weeks * 7
+  # The value of d is 0 for a Sunday, 1 for a Monday, 2 for a Tuesday, etc.
+  # so we must correct for the WeekDay type.
+  result = if wd == 0: dSun else: WeekDay(wd - 1)
+
+proc getDaysInYear*(year: int): int =
+  ## Get the number of days in a `year`
+  runnableExamples:
+    doAssert getDaysInYear(2000) == 366
+    doAssert getDaysInYear(2001) == 365
+  result = 365 + (if isLeapYear(year): 1 else: 0)
+
+proc `==`*(a, b: IsoYear): bool {.borrow.}
+proc `$`*(p: IsoYear): string {.borrow.}
+
+proc getWeeksInIsoYear*(y: IsoYear): IsoWeekRange {.since: (1, 5).} =
+  ## Returns the number of weeks in the specified ISO 8601 week-based year, which can be
+  ## either 53 or 52.
+  runnableExamples:
+    assert getWeeksInIsoYear(IsoYear(2019)) == 52
+    assert getWeeksInIsoYear(IsoYear(2020)) == 53
+
+  var y = int(y)
+
+  # support negative years
+  y = if y < 0: 400 + y mod 400 else: y
+
+  # source: https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm
+  let p = (y + (y div 4) - (y div 100) + (y div 400)) mod 7
+  let y1 = y - 1
+  let p1 = (y1 + (y1 div 4) - (y1 div 100) + (y1 div 400)) mod 7
+  if p == 4 or p1 == 3: 53 else: 52
+
+proc getIsoWeekAndYear*(dt: DateTime):
+  tuple[isoweek: IsoWeekRange, isoyear: IsoYear] {.since: (1, 5).} =
+  ## Returns the ISO 8601 week and year.
+  ##
+  ## .. warning:: The ISO week-based year can correspond to the following or previous year from 29 December to January 3.
+  runnableExamples:
+    assert getIsoWeekAndYear(initDateTime(21, mApr, 2018, 00, 00, 00)) == (isoweek: 16.IsoWeekRange, isoyear: 2018.IsoYear)
+    block:
+      let (w, y) = getIsoWeekAndYear(initDateTime(30, mDec, 2019, 00, 00, 00))
+      assert w == 01.IsoWeekRange
+      assert y == 2020.IsoYear
+    assert getIsoWeekAndYear(initDateTime(13, mSep, 2020, 00, 00, 00)) == (isoweek: 37.IsoWeekRange, isoyear: 2020.IsoYear)
+    block:
+      let (w, y) = getIsoWeekAndYear(initDateTime(2, mJan, 2021, 00, 00, 00))
+      assert w.int > 52
+      assert w.int < 54
+      assert y.int mod 100 == 20
+
+  # source: https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm
+  var w = (dt.yearday.int - dt.weekday.int + 10) div 7
+  if w < 1:
+    (isoweek: getWeeksInIsoYear(IsoYear(dt.year - 1)), isoyear: IsoYear(dt.year - 1))
+  elif (w > getWeeksInIsoYear(IsoYear(dt.year))):
+    (isoweek: IsoWeekRange(1), isoyear: IsoYear(dt.year + 1))
+  else:
+    (isoweek: IsoWeekRange(w), isoyear: IsoYear(dt.year))
+
+proc stringifyUnit(value: int | int64, unit: TimeUnit): string =
+  ## Stringify time unit with it's name, lowercased
+  let strUnit = $unit
+  result = ""
+  result.addInt value
+  result.add ' '
+  if abs(value) != 1:
+    result.add(strUnit.toLowerAscii())
+  else:
+    result.add(strUnit[0..^2].toLowerAscii())
+
+proc humanizeParts(parts: seq[string]): string =
+  ## Make date string parts human-readable
+  result = ""
+  if parts.len == 0:
+    result.add "0 nanoseconds"
+  elif parts.len == 1:
+    result = parts[0]
+  elif parts.len == 2:
+    result = parts[0] & " and " & parts[1]
+  else:
+    for i in 0..high(parts)-1:
+      result.add parts[i] & ", "
+    result.add "and " & parts[high(parts)]
+
+template subImpl[T: Duration|Time](a: Duration|Time, b: Duration|Time): T =
+  normalize[T](a.seconds - b.seconds, a.nanosecond - b.nanosecond)
+
+template addImpl[T: Duration|Time](a: Duration|Time, b: Duration|Time): T =
+  normalize[T](a.seconds + b.seconds, a.nanosecond + b.nanosecond)
+
+template ltImpl(a: Duration|Time, b: Duration|Time): bool =
+  a.seconds < b.seconds or (
+    a.seconds == b.seconds and a.nanosecond < b.nanosecond)
+
+template lqImpl(a: Duration|Time, b: Duration|Time): bool =
+  a.seconds < b.seconds or (
+    a.seconds == b.seconds and a.nanosecond <= b.nanosecond)
+
+template eqImpl(a: Duration|Time, b: Duration|Time): bool =
+  a.seconds == b.seconds and a.nanosecond == b.nanosecond
+
+#
+# Duration
+#
+
+const DurationZero* = Duration() ## \
+  ## Zero value for durations. Useful for comparisons.
+  ##   ```nim
+  ##   doAssert initDuration(seconds = 1) > DurationZero
+  ##   doAssert initDuration(seconds = 0) == DurationZero
+  ##   ```
+
+proc initDuration*(nanoseconds, microseconds, milliseconds,
+                   seconds, minutes, hours, days, weeks: int64 = 0): Duration =
+  ## Create a new `Duration <#Duration>`_.
+  runnableExamples:
+    let dur = initDuration(seconds = 1, milliseconds = 1)
+    doAssert dur.inMilliseconds == 1001
+    doAssert dur.inSeconds == 1
+
+  let seconds = convert(Weeks, Seconds, weeks) +
+    convert(Days, Seconds, days) +
+    convert(Minutes, Seconds, minutes) +
+    convert(Hours, Seconds, hours) +
+    convert(Seconds, Seconds, seconds) +
+    convert(Milliseconds, Seconds, milliseconds) +
+    convert(Microseconds, Seconds, microseconds) +
+    convert(Nanoseconds, Seconds, nanoseconds)
+  let nanoseconds = (convert(Milliseconds, Nanoseconds, milliseconds mod 1000) +
+    convert(Microseconds, Nanoseconds, microseconds mod 1_000_000) +
+    nanoseconds mod 1_000_000_000).int
+  # Nanoseconds might be negative so we must normalize.
+  result = normalize[Duration](seconds, nanoseconds)
+
+template convert(dur: Duration, unit: static[FixedTimeUnit]): int64 =
+  # The correction is required due to how durations are normalized.
+  # For example,` initDuration(nanoseconds = -1)` is stored as
+  # { seconds = -1, nanoseconds = 999999999 }.
+  when unit == Nanoseconds:
+    dur.seconds * 1_000_000_000 + dur.nanosecond
+  else:
+    let correction = dur.seconds < 0 and dur.nanosecond > 0
+    when unit >= Seconds:
+      convert(Seconds, unit, dur.seconds + ord(correction))
+    else:
+      if correction:
+        convert(Seconds, unit, dur.seconds + 1) -
+          convert(Nanoseconds, unit,
+            convert(Seconds, Nanoseconds, 1) - dur.nanosecond)
+      else:
+        convert(Seconds, unit, dur.seconds) +
+          convert(Nanoseconds, unit, dur.nanosecond)
+
+proc inWeeks*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole weeks.
+  runnableExamples:
+    let dur = initDuration(days = 8)
+    doAssert dur.inWeeks == 1
+  dur.convert(Weeks)
+
+proc inDays*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole days.
+  runnableExamples:
+    let dur = initDuration(hours = -50)
+    doAssert dur.inDays == -2
+  dur.convert(Days)
+
+proc inHours*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole hours.
+  runnableExamples:
+    let dur = initDuration(minutes = 60, days = 2)
+    doAssert dur.inHours == 49
+  dur.convert(Hours)
+
+proc inMinutes*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole minutes.
+  runnableExamples:
+    let dur = initDuration(hours = 2, seconds = 10)
+    doAssert dur.inMinutes == 120
+  dur.convert(Minutes)
+
+proc inSeconds*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole seconds.
+  runnableExamples:
+    let dur = initDuration(hours = 2, milliseconds = 10)
+    doAssert dur.inSeconds == 2 * 60 * 60
+  dur.convert(Seconds)
+
+proc inMilliseconds*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole milliseconds.
+  runnableExamples:
+    let dur = initDuration(seconds = -2)
+    doAssert dur.inMilliseconds == -2000
+  dur.convert(Milliseconds)
+
+proc inMicroseconds*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole microseconds.
+  runnableExamples:
+    let dur = initDuration(seconds = -2)
+    doAssert dur.inMicroseconds == -2000000
+  dur.convert(Microseconds)
+
+proc inNanoseconds*(dur: Duration): int64 =
+  ## Converts the duration to the number of whole nanoseconds.
+  runnableExamples:
+    let dur = initDuration(seconds = -2)
+    doAssert dur.inNanoseconds == -2000000000
+  dur.convert(Nanoseconds)
+
+proc toParts*(dur: Duration): DurationParts =
+  ## Converts a duration into an array consisting of fixed time units.
+  ##
+  ## Each value in the array gives information about a specific unit of
+  ## time, for example `result[Days]` gives a count of days.
+  ##
+  ## This procedure is useful for converting `Duration` values to strings.
+  runnableExamples:
+    var dp = toParts(initDuration(weeks = 2, days = 1))
+    doAssert dp[Days] == 1
+    doAssert dp[Weeks] == 2
+    doAssert dp[Minutes] == 0
+    dp = toParts(initDuration(days = -1))
+    doAssert dp[Days] == -1
+
+  var remS = dur.seconds
+  var remNs = dur.nanosecond.int
+
+  # Ensure the same sign for seconds and nanoseconds
+  if remS < 0 and remNs != 0:
+    remNs -= convert(Seconds, Nanoseconds, 1)
+    remS.inc 1
+
+  for unit in countdown(Weeks, Seconds):
+    let quantity = convert(Seconds, unit, remS)
+    remS = remS mod convert(unit, Seconds, 1)
+
+    result[unit] = quantity
+
+  for unit in countdown(Milliseconds, Nanoseconds):
+    let quantity = convert(Nanoseconds, unit, remNs)
+    remNs = remNs mod convert(unit, Nanoseconds, 1)
+
+    result[unit] = quantity
+
+proc `$`*(dur: Duration): string =
+  ## Human friendly string representation of a `Duration`.
+  runnableExamples:
+    doAssert $initDuration(seconds = 2) == "2 seconds"
+    doAssert $initDuration(weeks = 1, days = 2) == "1 week and 2 days"
+    doAssert $initDuration(hours = 1, minutes = 2, seconds = 3) ==
+      "1 hour, 2 minutes, and 3 seconds"
+    doAssert $initDuration(milliseconds = -1500) ==
+      "-1 second and -500 milliseconds"
+  var parts = newSeq[string]()
+  var numParts = toParts(dur)
+
+  for unit in countdown(Weeks, Nanoseconds):
+    let quantity = numParts[unit]
+    if quantity != 0.int64:
+      parts.add(stringifyUnit(quantity, unit))
+
+  result = humanizeParts(parts)
+
+proc `+`*(a, b: Duration): Duration {.operator, extern: "ntAddDuration".} =
+  ## Add two durations together.
+  runnableExamples:
+    doAssert initDuration(seconds = 1) + initDuration(days = 1) ==
+      initDuration(seconds = 1, days = 1)
+  addImpl[Duration](a, b)
+
+proc `-`*(a, b: Duration): Duration {.operator, extern: "ntSubDuration".} =
+  ## Subtract a duration from another.
+  runnableExamples:
+    doAssert initDuration(seconds = 1, days = 1) - initDuration(seconds = 1) ==
+      initDuration(days = 1)
+  subImpl[Duration](a, b)
+
+proc `-`*(a: Duration): Duration {.operator, extern: "ntReverseDuration".} =
+  ## Reverse a duration.
+  runnableExamples:
+    doAssert -initDuration(seconds = 1) == initDuration(seconds = -1)
+  normalize[Duration](-a.seconds, -a.nanosecond)
+
+proc `<`*(a, b: Duration): bool {.operator, extern: "ntLtDuration".} =
+  ## Note that a duration can be negative,
+  ## so even if `a < b` is true `a` might
+  ## represent a larger absolute duration.
+  ## Use `abs(a) < abs(b)` to compare the absolute
+  ## duration.
+  runnableExamples:
+    doAssert initDuration(seconds = 1) < initDuration(seconds = 2)
+    doAssert initDuration(seconds = -2) < initDuration(seconds = 1)
+    doAssert initDuration(seconds = -2).abs < initDuration(seconds = 1).abs == false
+  ltImpl(a, b)
+
+proc `<=`*(a, b: Duration): bool {.operator, extern: "ntLeDuration".} =
+  lqImpl(a, b)
+
+proc `==`*(a, b: Duration): bool {.operator, extern: "ntEqDuration".} =
+  runnableExamples:
+    let
+      d1 = initDuration(weeks = 1)
+      d2 = initDuration(days = 7)
+    doAssert d1 == d2
+  eqImpl(a, b)
+
+proc `*`*(a: int64, b: Duration): Duration {.operator,
+    extern: "ntMulInt64Duration".} =
+  ## Multiply a duration by some scalar.
+  runnableExamples:
+    doAssert 5 * initDuration(seconds = 1) == initDuration(seconds = 5)
+    doAssert 3 * initDuration(minutes = 45) == initDuration(hours = 2, minutes = 15)
+  normalize[Duration](a * b.seconds, a * b.nanosecond)
+
+proc `*`*(a: Duration, b: int64): Duration {.operator,
+    extern: "ntMulDuration".} =
+  ## Multiply a duration by some scalar.
+  runnableExamples:
+    doAssert initDuration(seconds = 1) * 5 == initDuration(seconds = 5)
+    doAssert initDuration(minutes = 45) * 3 == initDuration(hours = 2, minutes = 15)
+  b * a
+
+proc `+=`*(d1: var Duration, d2: Duration) =
+  d1 = d1 + d2
+
+proc `-=`*(dt: var Duration, ti: Duration) =
+  dt = dt - ti
+
+proc `*=`*(a: var Duration, b: int) =
+  a = a * b
+
+proc `div`*(a: Duration, b: int64): Duration {.operator,
+    extern: "ntDivDuration".} =
+  ## Integer division for durations.
+  runnableExamples:
+    doAssert initDuration(seconds = 3) div 2 ==
+      initDuration(milliseconds = 1500)
+    doAssert initDuration(minutes = 45) div 30 ==
+      initDuration(minutes = 1, seconds = 30)
+    doAssert initDuration(nanoseconds = 3) div 2 ==
+      initDuration(nanoseconds = 1)
+  let carryOver = convert(Seconds, Nanoseconds, a.seconds mod b)
+  normalize[Duration](a.seconds div b, (a.nanosecond + carryOver) div b)
+
+proc high*(typ: typedesc[Duration]): Duration =
+  ## Get the longest representable duration.
+  initDuration(seconds = high(int64), nanoseconds = high(NanosecondRange))
+
+proc low*(typ: typedesc[Duration]): Duration =
+  ## Get the longest representable duration of negative direction.
+  initDuration(seconds = low(int64))
+
+proc abs*(a: Duration): Duration =
+  runnableExamples:
+    doAssert initDuration(milliseconds = -1500).abs ==
+      initDuration(milliseconds = 1500)
+  initDuration(seconds = abs(a.seconds), nanoseconds = -a.nanosecond)
+
+#
+# Time
+#
+
+proc initTime*(unix: int64, nanosecond: NanosecondRange): Time =
+  ## Create a `Time <#Time>`_ from a unix timestamp and a nanosecond part.
+  result.seconds = unix
+  result.nanosecond = nanosecond
+
+proc nanosecond*(time: Time): NanosecondRange =
+  ## Get the fractional part of a `Time` as the number
+  ## of nanoseconds of the second.
+  time.nanosecond
+
+proc fromUnix*(unix: int64): Time
+    {.benign, tags: [], raises: [], noSideEffect.} =
+  ## Convert a unix timestamp (seconds since `1970-01-01T00:00:00Z`)
+  ## to a `Time`.
+  runnableExamples:
+    doAssert $fromUnix(0).utc == "1970-01-01T00:00:00Z"
+  initTime(unix, 0)
+
+proc toUnix*(t: Time): int64 {.benign, tags: [], raises: [], noSideEffect.} =
+  ## Convert `t` to a unix timestamp (seconds since `1970-01-01T00:00:00Z`).
+  ## See also `toUnixFloat` for subsecond resolution.
+  runnableExamples:
+    doAssert fromUnix(0).toUnix() == 0
+  t.seconds
+
+proc fromUnixFloat(seconds: float): Time {.benign, tags: [], raises: [], noSideEffect.} =
+  ## Convert a unix timestamp in seconds to a `Time`; same as `fromUnix`
+  ## but with subsecond resolution.
+  runnableExamples:
+    doAssert fromUnixFloat(123456.0) == fromUnixFloat(123456)
+    doAssert fromUnixFloat(-123456.0) == fromUnixFloat(-123456)
+  let secs = seconds.floor
+  let nsecs = (seconds - secs) * 1e9
+  initTime(secs.int64, nsecs.NanosecondRange)
+
+proc toUnixFloat(t: Time): float {.benign, tags: [], raises: [].} =
+  ## Same as `toUnix` but using subsecond resolution.
+  runnableExamples:
+    let t = getTime()
+    # `<` because of rounding errors
+    doAssert abs(t.toUnixFloat().fromUnixFloat - t) < initDuration(nanoseconds = 1000)
+  t.seconds.float + t.nanosecond / convert(Seconds, Nanoseconds, 1)
+
+since((1, 1)):
+  export fromUnixFloat
+  export toUnixFloat
+
+
+proc fromWinTime*(win: int64): Time =
+  ## Convert a Windows file time (100-nanosecond intervals since
+  ## `1601-01-01T00:00:00Z`) to a `Time`.
+  const hnsecsPerSec = convert(Seconds, Nanoseconds, 1) div 100
+  let nanos = floorMod(win, hnsecsPerSec) * 100
+  let seconds = floorDiv(win - epochDiff, hnsecsPerSec)
+  result = initTime(seconds, nanos)
+
+proc toWinTime*(t: Time): int64 =
+  ## Convert `t` to a Windows file time (100-nanosecond intervals
+  ## since `1601-01-01T00:00:00Z`).
+  result = t.seconds * rateDiff + epochDiff + t.nanosecond div 100
+
+proc getTimeImpl(typ: typedesc[Time]): Time =
+  discard "implemented in the vm"
+
+proc getTime*(): Time {.tags: [TimeEffect], benign.} =
+  ## Gets the current time as a `Time` with up to nanosecond resolution.
+  when nimvm:
+    result = getTimeImpl(Time)
+  else:
+    when defined(js):
+      let millis = newDate().getTime()
+      let seconds = convert(Milliseconds, Seconds, millis)
+      let nanos = convert(Milliseconds, Nanoseconds,
+        millis mod convert(Seconds, Milliseconds, 1).int)
+      result = initTime(seconds, nanos)
+    elif defined(macosx):
+      var a {.noinit.}: Timeval
+      gettimeofday(a)
+      result = initTime(a.tv_sec.int64,
+                        convert(Microseconds, Nanoseconds, a.tv_usec.int))
+    elif defined(posix):
+      var ts {.noinit.}: Timespec
+      discard clock_gettime(CLOCK_REALTIME, ts)
+      result = initTime(ts.tv_sec.int64, ts.tv_nsec.int)
+    elif defined(windows):
+      var f {.noinit.}: FILETIME
+      getSystemTimeAsFileTime(f)
+      result = fromWinTime(rdFileTime(f))
+
+proc `-`*(a, b: Time): Duration {.operator, extern: "ntDiffTime".} =
+  ## Computes the duration between two points in time.
+  runnableExamples:
+    doAssert initTime(1000, 100) - initTime(500, 20) ==
+      initDuration(minutes = 8, seconds = 20, nanoseconds = 80)
+  subImpl[Duration](a, b)
+
+proc `+`*(a: Time, b: Duration): Time {.operator, extern: "ntAddTime".} =
+  ## Add a duration of time to a `Time`.
+  runnableExamples:
+    doAssert (fromUnix(0) + initDuration(seconds = 1)) == fromUnix(1)
+  addImpl[Time](a, b)
+
+proc `-`*(a: Time, b: Duration): Time {.operator, extern: "ntSubTime".} =
+  ## Subtracts a duration of time from a `Time`.
+  runnableExamples:
+    doAssert (fromUnix(0) - initDuration(seconds = 1)) == fromUnix(-1)
+  subImpl[Time](a, b)
+
+proc `<`*(a, b: Time): bool {.operator, extern: "ntLtTime".} =
+  ## Returns true if `a < b`, that is if `a` happened before `b`.
+  runnableExamples:
+    doAssert initTime(50, 0) < initTime(99, 0)
+  ltImpl(a, b)
+
+proc `<=`*(a, b: Time): bool {.operator, extern: "ntLeTime".} =
+  ## Returns true if `a <= b`.
+  lqImpl(a, b)
+
+proc `==`*(a, b: Time): bool {.operator, extern: "ntEqTime".} =
+  ## Returns true if `a == b`, that is if both times represent the same point in time.
+  eqImpl(a, b)
+
+proc `+=`*(t: var Time, b: Duration) =
+  t = t + b
+
+proc `-=`*(t: var Time, b: Duration) =
+  t = t - b
+
+proc high*(typ: typedesc[Time]): Time =
+  initTime(high(int64), high(NanosecondRange))
+
+proc low*(typ: typedesc[Time]): Time =
+  initTime(0, 0)
+
+#
+# DateTime & Timezone
+#
+
+template assertDateTimeInitialized(dt: DateTime) =
+  assert dt.monthdayZero != 0, "Uninitialized datetime"
+
+proc nanosecond*(dt: DateTime): NanosecondRange {.inline.} =
+  ## The number of nanoseconds after the second,
+  ## in the range 0 to 999_999_999.
+  assertDateTimeInitialized(dt)
+  dt.nanosecond
+
+proc second*(dt: DateTime): SecondRange {.inline.} =
+  ## The number of seconds after the minute,
+  ## in the range 0 to 59.
+  assertDateTimeInitialized(dt)
+  dt.second
+
+proc minute*(dt: DateTime): MinuteRange {.inline.} =
+  ## The number of minutes after the hour,
+  ## in the range 0 to 59.
+  assertDateTimeInitialized(dt)
+  dt.minute
+
+proc hour*(dt: DateTime): HourRange {.inline.} =
+  ## The number of hours past midnight,
+  ## in the range 0 to 23.
+  assertDateTimeInitialized(dt)
+  dt.hour
+
+proc monthday*(dt: DateTime): MonthdayRange {.inline.} =
+  ## The day of the month, in the range 1 to 31.
+  assertDateTimeInitialized(dt)
+  # 'cast' to avoid extra range check
+  cast[MonthdayRange](dt.monthdayZero)
+
+proc month*(dt: DateTime): Month =
+  ## The month as an enum, the ordinal value
+  ## is in the range 1 to 12.
+  assertDateTimeInitialized(dt)
+  # 'cast' to avoid extra range check
+  cast[Month](dt.monthZero)
+
+proc year*(dt: DateTime): int {.inline.} =
+  ## The year, using astronomical year numbering
+  ## (meaning that before year 1 is year 0,
+  ## then year -1 and so on).
+  assertDateTimeInitialized(dt)
+  dt.year
+
+proc weekday*(dt: DateTime): WeekDay {.inline.} =
+  ## The day of the week as an enum, the ordinal
+  ## value is in the range 0 (monday) to 6 (sunday).
+  assertDateTimeInitialized(dt)
+  dt.weekday
+
+proc yearday*(dt: DateTime): YeardayRange {.inline.} =
+  ## The number of days since January 1,
+  ## in the range 0 to 365.
+  assertDateTimeInitialized(dt)
+  dt.yearday
+
+proc isDst*(dt: DateTime): bool {.inline.} =
+  ## Determines whether DST is in effect.
+  ## Always false for the JavaScript backend.
+  assertDateTimeInitialized(dt)
+  dt.isDst
+
+proc timezone*(dt: DateTime): Timezone {.inline.} =
+  ## The timezone represented as an implementation
+  ## of `Timezone`.
+  assertDateTimeInitialized(dt)
+  dt.timezone
+
+proc utcOffset*(dt: DateTime): int {.inline.} =
+  ## The offset in seconds west of UTC, including
+  ## any offset due to DST. Note that the sign of
+  ## this number is the opposite of the one in a
+  ## formatted offset string like `+01:00` (which
+  ## would be equivalent to the UTC offset
+  ## `-3600`).
+  assertDateTimeInitialized(dt)
+  dt.utcOffset
+
+proc isInitialized(dt: DateTime): bool =
+  # Returns true if `dt` is not the (invalid) default value for `DateTime`.
+  runnableExamples:
+    doAssert now().isInitialized
+    doAssert not default(DateTime).isInitialized
+  dt.monthZero != 0
+
+since((1, 3)):
+  export isInitialized
+
+proc isLeapDay*(dt: DateTime): bool {.since: (1, 1).} =
+  ## Returns whether `t` is a leap day, i.e. Feb 29 in a leap year. This matters
+  ## as it affects time offset calculations.
+  runnableExamples:
+    let dt = dateTime(2020, mFeb, 29, 00, 00, 00, 00, utc())
+    doAssert dt.isLeapDay
+    doAssert dt+1.years-1.years != dt
+    let dt2 = dateTime(2020, mFeb, 28, 00, 00, 00, 00, utc())
+    doAssert not dt2.isLeapDay
+    doAssert dt2+1.years-1.years == dt2
+    doAssertRaises(Exception): discard dateTime(2021, mFeb, 29, 00, 00, 00, 00, utc())
+  assertDateTimeInitialized dt
+  dt.year.isLeapYear and dt.month == mFeb and dt.monthday == 29
+
+proc toTime*(dt: DateTime): Time {.tags: [], raises: [], benign.} =
+  ## Converts a `DateTime` to a `Time` representing the same point in time.
+  assertDateTimeInitialized dt
+  let epochDay = toEpochDay(dt.monthday, dt.month, dt.year)
+  var seconds = epochDay * secondsInDay
+  seconds.inc dt.hour * secondsInHour
+  seconds.inc dt.minute * 60
+  seconds.inc dt.second
+  seconds.inc dt.utcOffset
+  result = initTime(seconds, dt.nanosecond)
+
+proc initDateTime(zt: ZonedTime, zone: Timezone): DateTime =
+  ## Create a new `DateTime` using `ZonedTime` in the specified timezone.
+  let adjTime = zt.time - initDuration(seconds = zt.utcOffset)
+  let s = adjTime.seconds
+  let epochday = floorDiv(s, secondsInDay)
+  var rem = s - epochday * secondsInDay
+  let hour = rem div secondsInHour
+  rem = rem - hour * secondsInHour
+  let minute = rem div secondsInMin
+  rem = rem - minute * secondsInMin
+  let second = rem
+
+  let (d, m, y) = fromEpochDay(epochday)
+
+  DateTime(
+    year: y,
+    monthZero: m.int,
+    monthdayZero: d,
+    hour: hour,
+    minute: minute,
+    second: second,
+    nanosecond: zt.time.nanosecond,
+    weekday: getDayOfWeek(d, m, y),
+    yearday: getDayOfYear(d, m, y),
+    isDst: zt.isDst,
+    timezone: zone,
+    utcOffset: zt.utcOffset
+  )
+
+proc newTimezone*(
+      name: string,
+      zonedTimeFromTimeImpl: proc (time: Time): ZonedTime
+          {.tags: [], raises: [], benign.},
+      zonedTimeFromAdjTimeImpl: proc (adjTime: Time): ZonedTime
+          {.tags: [], raises: [], benign.}
+    ): owned Timezone =
+  ## Create a new `Timezone`.
+  ##
+  ## `zonedTimeFromTimeImpl` and `zonedTimeFromAdjTimeImpl` is used
+  ## as the underlying implementations for `zonedTimeFromTime` and
+  ## `zonedTimeFromAdjTime`.
+  ##
+  ## If possible, the name parameter should match the name used in the
+  ## tz database. If the timezone doesn't exist in the tz database, or if the
+  ## timezone name is unknown, then any string that describes the timezone
+  ## unambiguously can be used. Note that the timezones name is used for
+  ## checking equality!
+  runnableExamples:
+    proc utcTzInfo(time: Time): ZonedTime =
+      ZonedTime(utcOffset: 0, isDst: false, time: time)
+    let utc = newTimezone("Etc/UTC", utcTzInfo, utcTzInfo)
+  Timezone(
+    name: name,
+    zonedTimeFromTimeImpl: zonedTimeFromTimeImpl,
+    zonedTimeFromAdjTimeImpl: zonedTimeFromAdjTimeImpl
+  )
+
+proc name*(zone: Timezone): string =
+  ## The name of the timezone.
+  ##
+  ## If possible, the name will be the name used in the tz database.
+  ## If the timezone doesn't exist in the tz database, or if the timezone
+  ## name is unknown, then any string that describes the timezone
+  ## unambiguously might be used. For example, the string "LOCAL" is used
+  ## for the system's local timezone.
+  ##
+  ## See also: https://en.wikipedia.org/wiki/Tz_database
+  zone.name
+
+proc zonedTimeFromTime*(zone: Timezone, time: Time): ZonedTime =
+  ## Returns the `ZonedTime` for some point in time.
+  zone.zonedTimeFromTimeImpl(time)
+
+proc zonedTimeFromAdjTime*(zone: Timezone, adjTime: Time): ZonedTime =
+  ## Returns the `ZonedTime` for some local time.
+  ##
+  ## Note that the `Time` argument does not represent a point in time, it
+  ## represent a local time! E.g if `adjTime` is `fromUnix(0)`, it should be
+  ## interpreted as 1970-01-01T00:00:00 in the `zone` timezone, not in UTC.
+  zone.zonedTimeFromAdjTimeImpl(adjTime)
+
+proc `$`*(zone: Timezone): string =
+  ## Returns the name of the timezone.
+  if zone != nil: result = zone.name
+
+proc `==`*(zone1, zone2: Timezone): bool =
+  ## Two `Timezone`'s are considered equal if their name is equal.
+  runnableExamples:
+    doAssert local() == local()
+    doAssert local() != utc()
+  if system.`==`(zone1, zone2):
+    return true
+  if zone1.isNil or zone2.isNil:
+    return false
+  zone1.name == zone2.name
+
+proc inZone*(time: Time, zone: Timezone): DateTime
+    {.tags: [], raises: [], benign.} =
+  ## Convert `time` into a `DateTime` using `zone` as the timezone.
+  result = initDateTime(zone.zonedTimeFromTime(time), zone)
+
+proc inZone*(dt: DateTime, zone: Timezone): DateTime
+    {.tags: [], raises: [], benign.} =
+  ## Returns a `DateTime` representing the same point in time as `dt` but
+  ## using `zone` as the timezone.
+  assertDateTimeInitialized dt
+  dt.toTime.inZone(zone)
+
+proc toAdjTime(dt: DateTime): Time =
+  let epochDay = toEpochDay(dt.monthday, dt.month, dt.year)
+  var seconds = epochDay * secondsInDay
+  seconds.inc dt.hour * secondsInHour
+  seconds.inc dt.minute * secondsInMin
+  seconds.inc dt.second
+  result = initTime(seconds, dt.nanosecond)
+
+when defined(js):
+  proc localZonedTimeFromTime(time: Time): ZonedTime {.benign.} =
+    let jsDate = newDate(time.seconds * 1000)
+    let offset = jsDate.getTimezoneOffset() * secondsInMin
+    result.time = time
+    result.utcOffset = offset
+    result.isDst = false
+
+  proc localZonedTimeFromAdjTime(adjTime: Time): ZonedTime {.benign.} =
+    let utcDate = newDate(adjTime.seconds * 1000)
+    let localDate = newDate(utcDate.getUTCFullYear(), utcDate.getUTCMonth(),
+        utcDate.getUTCDate(), utcDate.getUTCHours(), utcDate.getUTCMinutes(),
+        utcDate.getUTCSeconds(), 0)
+
+    # This is as dumb as it looks - JS doesn't support years in the range
+    # 0-99 in the constructor because they are assumed to be 19xx...
+    # Because JS doesn't support timezone history,
+    # it doesn't really matter in practice.
+    if utcDate.getUTCFullYear() in 0 .. 99:
+      localDate.setFullYear(utcDate.getUTCFullYear())
+
+    result.utcOffset = localDate.getTimezoneOffset() * secondsInMin
+    result.time = adjTime + initDuration(seconds = result.utcOffset)
+    result.isDst = false
 
 else:
-  proc getTime(): TTime {.importc: "new Date", nodecl.}
-
-  const
-    weekDays: array [0..6, TWeekDay] = [
-      dSun, dMon, dTue, dWed, dThu, dFri, dSat]
-  
-  proc getLocalTime(t: TTime): TTimeInfo =
-    result.second = t.getSeconds()
-    result.minute = t.getMinutes()
-    result.hour = t.getHours()
-    result.monthday = t.getDate()
-    result.month = TMonth(t.getMonth())
-    result.year = t.getFullYear()
-    result.weekday = weekDays[t.getDay()]
-    result.yearday = 0
-
-  proc getGMTime(t: TTime): TTimeInfo =
-    result.second = t.getUTCSeconds()
-    result.minute = t.getUTCMinutes()
-    result.hour = t.getUTCHours()
-    result.monthday = t.getUTCDate()
-    result.month = TMonth(t.getUTCMonth())
-    result.year = t.getUTCFullYear()
-    result.weekday = weekDays[t.getDay()]
-    result.yearday = 0
-  
-  proc TimeInfoToTime*(timeInfo: TTimeInfo): TTime =
-    result = getTime()
-    result.setSeconds(timeInfo.second)
-    result.setMinutes(timeInfo.minute)
-    result.setHours(timeInfo.hour)
-    result.setMonth(ord(timeInfo.month))
-    result.setFullYear(timeInfo.year)
-    result.setDate(timeInfo.monthday)
-  
-  proc `$`(timeInfo: TTimeInfo): string = return $(TimeInfoToTIme(timeInfo))
-  proc `$`(time: TTime): string = $time.toLocaleString()
-    
-  proc `-` (a, b: TTime): int64 = 
-    return a.getTime() - b.getTime()
-  
+  proc toAdjUnix(tm: Tm): int64 =
+    let epochDay = toEpochDay(tm.tm_mday, (tm.tm_mon + 1).Month,
+                              tm.tm_year.int + 1900)
+    result = epochDay * secondsInDay
+    result.inc tm.tm_hour * secondsInHour
+    result.inc tm.tm_min * 60
+    result.inc tm.tm_sec
+
+  proc getLocalOffsetAndDst(unix: int64): tuple[offset: int, dst: bool] =
+    # Windows can't handle unix < 0, so we fall back to unix = 0.
+    # FIXME: This should be improved by falling back to the WinAPI instead.
+    when defined(windows):
+      if unix < 0:
+        var a = 0.CTime
+        let tmPtr = localtime(a)
+        if not tmPtr.isNil:
+          let tm = tmPtr[]
+          return ((0 - tm.toAdjUnix).int, false)
+        return (0, false)
+
+    # In case of a 32-bit time_t, we fallback to the closest available
+    # timezone information.
+    var a = clamp(unix, low(CTime).int64, high(CTime).int64).CTime
+    let tmPtr = localtime(a)
+    if not tmPtr.isNil:
+      let tm = tmPtr[]
+      return ((a.int64 - tm.toAdjUnix).int, tm.tm_isdst > 0)
+    return (0, false)
+
+  proc localZonedTimeFromTime(time: Time): ZonedTime {.benign.} =
+    let (offset, dst) = getLocalOffsetAndDst(time.seconds)
+    result.time = time
+    result.utcOffset = offset
+    result.isDst = dst
+
+  proc localZonedTimeFromAdjTime(adjTime: Time): ZonedTime {.benign.} =
+    var adjUnix = adjTime.seconds
+    let past = adjUnix - secondsInDay
+    let (pastOffset, _) = getLocalOffsetAndDst(past)
+
+    let future = adjUnix + secondsInDay
+    let (futureOffset, _) = getLocalOffsetAndDst(future)
+
+    var utcOffset: int
+    if pastOffset == futureOffset:
+      utcOffset = pastOffset.int
+    else:
+      if pastOffset > futureOffset:
+        adjUnix -= secondsInHour
+
+      adjUnix += pastOffset
+      utcOffset = getLocalOffsetAndDst(adjUnix).offset
+
+    # This extra roundtrip is needed to normalize any impossible datetimes
+    # as a result of offset changes (normally due to dst)
+    let utcUnix = adjTime.seconds + utcOffset
+    let (finalOffset, dst) = getLocalOffsetAndDst(utcUnix)
+    result.time = initTime(utcUnix, adjTime.nanosecond)
+    result.utcOffset = finalOffset
+    result.isDst = dst
+
+proc utcTzInfo(time: Time): ZonedTime =
+  ZonedTime(utcOffset: 0, isDst: false, time: time)
+
+var utcInstance {.threadvar.}: Timezone
+var localInstance {.threadvar.}: Timezone
+
+proc utc*(): Timezone =
+  ## Get the `Timezone` implementation for the UTC timezone.
+  runnableExamples:
+    doAssert now().utc.timezone == utc()
+    doAssert utc().name == "Etc/UTC"
+  if utcInstance.isNil:
+    utcInstance = newTimezone("Etc/UTC", utcTzInfo, utcTzInfo)
+  result = utcInstance
+
+proc local*(): Timezone =
+  ## Get the `Timezone` implementation for the local timezone.
+  runnableExamples:
+    doAssert now().timezone == local()
+    doAssert local().name == "LOCAL"
+  if localInstance.isNil:
+    localInstance = newTimezone("LOCAL", localZonedTimeFromTime,
+      localZonedTimeFromAdjTime)
+  result = localInstance
+
+proc utc*(dt: DateTime): DateTime =
+  ## Shorthand for `dt.inZone(utc())`.
+  dt.inZone(utc())
+
+proc local*(dt: DateTime): DateTime =
+  ## Shorthand for `dt.inZone(local())`.
+  dt.inZone(local())
+
+proc utc*(t: Time): DateTime =
+  ## Shorthand for `t.inZone(utc())`.
+  t.inZone(utc())
+
+proc local*(t: Time): DateTime =
+  ## Shorthand for `t.inZone(local())`.
+  t.inZone(local())
+
+proc now*(): DateTime {.tags: [TimeEffect], benign.} =
+  ## Get the current time as a  `DateTime` in the local timezone.
+  ## Shorthand for `getTime().local`.
+  ##
+  ## .. warning:: Unsuitable for benchmarking, use `monotimes.getMonoTime` or
+  ##    `cpuTime` instead, depending on the use case.
+  getTime().local
+
+proc dateTime*(year: int, month: Month, monthday: MonthdayRange,
+               hour: HourRange = 0, minute: MinuteRange = 0, second: SecondRange = 0,
+               nanosecond: NanosecondRange = 0,
+               zone: Timezone = local()): DateTime =
+  ## Create a new `DateTime <#DateTime>`_ in the specified timezone.
+  runnableExamples:
+    assert $dateTime(2017, mMar, 30, zone = utc()) == "2017-03-30T00:00:00Z"
+
+  assertValidDate monthday, month, year
+  let dt = DateTime(
+    monthdayZero: monthday,
+    year: year,
+    monthZero: month.int,
+    hour: hour,
+    minute: minute,
+    second: second,
+    nanosecond: nanosecond
+  )
+  result = initDateTime(zone.zonedTimeFromAdjTime(dt.toAdjTime), zone)
+
+proc initDateTime*(monthday: MonthdayRange, month: Month, year: int,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   nanosecond: NanosecondRange,
+                   zone: Timezone = local()): DateTime {.deprecated: "use `dateTime`".} =
+  ## Create a new `DateTime <#DateTime>`_ in the specified timezone.
+  runnableExamples("--warning:deprecated:off"):
+    assert $initDateTime(30, mMar, 2017, 00, 00, 00, 00, utc()) == "2017-03-30T00:00:00Z"
+  dateTime(year, month, monthday, hour, minute, second, nanosecond, zone)
+
+proc initDateTime*(monthday: MonthdayRange, month: Month, year: int,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   zone: Timezone = local()): DateTime {.deprecated: "use `dateTime`".} =
+  ## Create a new `DateTime <#DateTime>`_ in the specified timezone.
+  runnableExamples("--warning:deprecated:off"):
+    assert $initDateTime(30, mMar, 2017, 00, 00, 00, utc()) == "2017-03-30T00:00:00Z"
+  dateTime(year, month, monthday, hour, minute, second, 0, zone)
+
+proc `+`*(dt: DateTime, dur: Duration): DateTime =
+  runnableExamples:
+    let dt = dateTime(2017, mMar, 30, 00, 00, 00, 00, utc())
+    let dur = initDuration(hours = 5)
+    doAssert $(dt + dur) == "2017-03-30T05:00:00Z"
+
+  (dt.toTime + dur).inZone(dt.timezone)
+
+proc `-`*(dt: DateTime, dur: Duration): DateTime =
+  runnableExamples:
+    let dt = dateTime(2017, mMar, 30, 00, 00, 00, 00, utc())
+    let dur = initDuration(days = 5)
+    doAssert $(dt - dur) == "2017-03-25T00:00:00Z"
+
+  (dt.toTime - dur).inZone(dt.timezone)
+
+proc `-`*(dt1, dt2: DateTime): Duration =
+  ## Compute the duration between `dt1` and `dt2`.
+  runnableExamples:
+    let dt1 = dateTime(2017, mMar, 30, 00, 00, 00, 00, utc())
+    let dt2 = dateTime(2017, mMar, 25, 00, 00, 00, 00, utc())
+
+    doAssert dt1 - dt2 == initDuration(days = 5)
+
+  dt1.toTime - dt2.toTime
+
+proc `<`*(a, b: DateTime): bool =
+  ## Returns true if `a` happened before `b`.
+  return a.toTime < b.toTime
+
+proc `<=`*(a, b: DateTime): bool =
+  ## Returns true if `a` happened before or at the same time as `b`.
+  return a.toTime <= b.toTime
+
+proc `==`*(a, b: DateTime): bool =
+  ## Returns true if `a` and `b` represent the same point in time.
+  if not a.isInitialized: not b.isInitialized
+  elif not b.isInitialized: false
+  else: a.toTime == b.toTime
+
+proc `+=`*(a: var DateTime, b: Duration) =
+  a = a + b
+
+proc `-=`*(a: var DateTime, b: Duration) =
+  a = a - b
+
+proc getDateStr*(dt = now()): string {.rtl, extern: "nt$1", tags: [TimeEffect].} =
+  ## Gets the current local date as a string of the format `YYYY-MM-dd`.
+  runnableExamples:
+    echo getDateStr(now() - 1.months)
+  assertDateTimeInitialized dt
+  result = newStringOfCap(10)  # len("YYYY-MM-dd") == 10
+  result.addInt dt.year
+  result.add '-'
+  result.add intToStr(dt.monthZero, 2)
+  result.add '-'
+  result.add intToStr(dt.monthday, 2)
+
+proc getClockStr*(dt = now()): string {.rtl, extern: "nt$1", tags: [TimeEffect].} =
+  ## Gets the current local clock time as a string of the format `HH:mm:ss`.
+  runnableExamples:
+    echo getClockStr(now() - 1.hours)
+  assertDateTimeInitialized dt
+  result = newStringOfCap(8)  # len("HH:mm:ss") == 8
+  result.add intToStr(dt.hour, 2)
+  result.add ':'
+  result.add intToStr(dt.minute, 2)
+  result.add ':'
+  result.add intToStr(dt.second, 2)
+
+
+#
+# Iso week forward declarations
+#
+
+proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   nanosecond: NanosecondRange,
+                   zone: Timezone = local()): DateTime {.gcsafe, raises: [], tags: [], since: (1, 5).}
+
+proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   zone: Timezone = local()): DateTime {.gcsafe, raises: [], tags: [], since: (1, 5).}
+
+#
+# TimeFormat
+#
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+type
+  DateTimeLocale* = object
+    MMM*: array[mJan..mDec, string]
+    MMMM*: array[mJan..mDec, string]
+    ddd*: array[dMon..dSun, string]
+    dddd*: array[dMon..dSun, string]
+
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+type
+  AmPm = enum
+    apUnknown, apAm, apPm
+
+  Era = enum
+    eraUnknown, eraAd, eraBc
+
+  ParsedTime = object
+    amPm: AmPm
+    era: Era
+    year: Option[int]
+    month: Option[int]
+    monthday: Option[int]
+    isoyear: Option[int]
+    yearweek: Option[int]
+    weekday: Option[WeekDay]
+    utcOffset: Option[int]
+
+    # '0' as default for these work fine
+    # so no need for `Option`.
+    hour: int
+    minute: int
+    second: int
+    nanosecond: int
+
+  FormatTokenKind = enum
+    tkPattern, tkLiteral
+
+  FormatPattern {.pure.} = enum
+    d, dd, ddd, dddd
+    GG, GGGG
+    h, hh, H, HH
+    m, mm, M, MM, MMM, MMMM
+    s, ss
+    fff, ffffff, fffffffff
+    t, tt
+    yy, yyyy
+    YYYY
+    uuuu
+    UUUU
+    V, VV
+    z, zz, zzz, zzzz
+    ZZZ, ZZZZ
+    g
+
+    # This is a special value used to mark literal format values.
+    # See the doc comment for `TimeFormat.patterns`.
+    Lit
+
+  TimeFormat* = object  ## Represents a format for parsing and printing
+                        ## time types.
+                        ##
+                        ## To create a new `TimeFormat` use `initTimeFormat proc
+                        ## <#initTimeFormat,string>`_.
+    patterns: seq[byte] ## \
+      ## Contains the patterns encoded as bytes.
+      ## Literal values are encoded in a special way.
+      ## They start with `Lit.byte`, then the length of the literal, then the
+      ## raw char values of the literal. For example, the literal `foo` would
+      ## be encoded as `@[Lit.byte, 3.byte, 'f'.byte, 'o'.byte, 'o'.byte]`.
+    formatStr: string
+
+  TimeParseError* = object of ValueError ## \
+    ## Raised when parsing input using a `TimeFormat` fails.
+
+  TimeFormatParseError* = object of ValueError ## \
+    ## Raised when parsing a `TimeFormat` string fails.
+
+const
+  DefaultLocale* = DateTimeLocale(
+    MMM: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
+        "Nov", "Dec"],
+    MMMM: ["January", "February", "March", "April", "May", "June", "July",
+        "August", "September", "October", "November", "December"],
+    ddd: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
+    dddd: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
+        "Sunday"],
+  )
+
+  FormatLiterals = {' ', '-', '/', ':', '(', ')', '[', ']', ',', '.'}
+
+proc `$`*(f: TimeFormat): string =
+  ## Returns the format string that was used to construct `f`.
+  runnableExamples:
+    let f = initTimeFormat("yyyy-MM-dd")
+    doAssert $f == "yyyy-MM-dd"
+  f.formatStr
+
+proc raiseParseException(f: TimeFormat, input: string, msg: string) =
+  raise newException(TimeParseError,
+                     "Failed to parse '" & input & "' with format '" & $f &
+                     "'. " & msg)
+
+proc parseInt(s: string, b: var int, start = 0, maxLen = int.high,
+              allowSign = false): int =
+  var sign = -1
+  var i = start
+  let stop = start + min(s.high - start + 1, maxLen) - 1
+  if allowSign and i <= stop:
+    if s[i] == '+':
+      inc(i)
+    elif s[i] == '-':
+      inc(i)
+      sign = 1
+  if i <= stop and s[i] in {'0'..'9'}:
+    b = 0
+    while i <= stop and s[i] in {'0'..'9'}:
+      let c = ord(s[i]) - ord('0')
+      if b >= (low(int) + c) div 10:
+        b = b * 10 - c
+      else:
+        return 0
+      inc(i)
+    if sign == -1 and b == low(int):
+      return 0
+    b = b * sign
+    result = i - start
+
+iterator tokens(f: string): tuple[kind: FormatTokenKind, token: string] =
+  var i = 0
+  var currToken = ""
+
+  template yieldCurrToken() =
+    if currToken.len != 0:
+      yield (tkPattern, currToken)
+      currToken = ""
+
+  while i < f.len:
+    case f[i]
+    of '\'':
+      yieldCurrToken()
+      if i.succ < f.len and f[i.succ] == '\'':
+        yield (tkLiteral, "'")
+        i.inc 2
+      else:
+        var token = ""
+        inc(i) # Skip '
+        while i < f.len and f[i] != '\'':
+          token.add f[i]
+          i.inc
+
+        if i > f.high:
+          raise newException(TimeFormatParseError,
+                             "Unclosed ' in time format string. " &
+                             "For a literal ', use ''.")
+        i.inc
+        yield (tkLiteral, token)
+    of FormatLiterals:
+      yieldCurrToken()
+      yield (tkLiteral, $f[i])
+      i.inc
+    else:
+      # Check if the letter being added matches previous accumulated buffer.
+      if currToken.len == 0 or currToken[0] == f[i]:
+        currToken.add(f[i])
+        i.inc
+      else:
+        yield (tkPattern, currToken)
+        currToken = $f[i]
+        i.inc
+
+  yieldCurrToken()
+
+proc stringToPattern(str: string): FormatPattern =
+  case str
+  of "d": result = d
+  of "dd": result = dd
+  of "ddd": result = ddd
+  of "dddd": result = dddd
+  of "GG": result = GG
+  of "GGGG": result = GGGG
+  of "h": result = h
+  of "hh": result = hh
+  of "H": result = H
+  of "HH": result = HH
+  of "m": result = m
+  of "mm": result = mm
+  of "M": result = M
+  of "MM": result = MM
+  of "MMM": result = MMM
+  of "MMMM": result = MMMM
+  of "s": result = s
+  of "ss": result = ss
+  of "fff": result = fff
+  of "ffffff": result = ffffff
+  of "fffffffff": result = fffffffff
+  of "t": result = t
+  of "tt": result = tt
+  of "yy": result = yy
+  of "yyyy": result = yyyy
+  of "YYYY": result = YYYY
+  of "uuuu": result = uuuu
+  of "UUUU": result = UUUU
+  of "V": result = V
+  of "VV": result = VV
+  of "z": result = z
+  of "zz": result = zz
+  of "zzz": result = zzz
+  of "zzzz": result = zzzz
+  of "ZZZ": result = ZZZ
+  of "ZZZZ": result = ZZZZ
+  of "g": result = g
+  else: raise newException(TimeFormatParseError,
+                           "'" & str & "' is not a valid pattern")
+
+proc initTimeFormat*(format: string): TimeFormat =
+  ## Construct a new time format for parsing & formatting time types.
+  ##
+  ## See `Parsing and formatting dates`_ for documentation of the
+  ## `format` argument.
+  runnableExamples:
+    let f = initTimeFormat("yyyy-MM-dd")
+    doAssert "2000-01-01" == "2000-01-01".parse(f).format(f)
+  result.formatStr = format
+  result.patterns = @[]
+  for kind, token in format.tokens:
+    case kind
+    of tkLiteral:
+      case token
+      else:
+        result.patterns.add(FormatPattern.Lit.byte)
+        if token.len > 255:
+          raise newException(TimeFormatParseError,
+                             "Format literal is to long:" & token)
+        result.patterns.add(token.len.byte)
+        for c in token:
+          result.patterns.add(c.byte)
+    of tkPattern:
+      result.patterns.add(stringToPattern(token).byte)
+
+proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string,
+    loc: DateTimeLocale) =
+  template yearOfEra(dt: DateTime): int =
+    if dt.year <= 0: abs(dt.year) + 1 else: dt.year
+
+  case pattern
+  of d:
+    result.add $dt.monthday
+  of dd:
+    result.add dt.monthday.intToStr(2)
+  of ddd:
+    result.add loc.ddd[dt.weekday]
+  of dddd:
+    result.add loc.dddd[dt.weekday]
+  of GG:
+    result.add (dt.getIsoWeekAndYear.isoyear.int mod 100).intToStr(2)
+  of GGGG:
+    result.add $dt.getIsoWeekAndYear.isoyear
+  of h:
+    result.add(
+      if dt.hour == 0: "12"
+      elif dt.hour > 12: $(dt.hour - 12)
+      else: $dt.hour
+    )
+  of hh:
+    result.add(
+      if dt.hour == 0: "12"
+      elif dt.hour > 12: (dt.hour - 12).intToStr(2)
+      else: dt.hour.intToStr(2)
+    )
+  of H:
+    result.add $dt.hour
+  of HH:
+    result.add dt.hour.intToStr(2)
+  of m:
+    result.add $dt.minute
+  of mm:
+    result.add dt.minute.intToStr(2)
+  of M:
+    result.add $ord(dt.month)
+  of MM:
+    result.add ord(dt.month).intToStr(2)
+  of MMM:
+    result.add loc.MMM[dt.month]
+  of MMMM:
+    result.add loc.MMMM[dt.month]
+  of s:
+    result.add $dt.second
+  of ss:
+    result.add dt.second.intToStr(2)
+  of fff:
+    result.add(intToStr(convert(Nanoseconds, Milliseconds, dt.nanosecond), 3))
+  of ffffff:
+    result.add(intToStr(convert(Nanoseconds, Microseconds, dt.nanosecond), 6))
+  of fffffffff:
+    result.add(intToStr(dt.nanosecond, 9))
+  of t:
+    result.add if dt.hour >= 12: "P" else: "A"
+  of tt:
+    result.add if dt.hour >= 12: "PM" else: "AM"
+  of yy:
+    result.add (dt.yearOfEra mod 100).intToStr(2)
+  of yyyy:
+    let year = dt.yearOfEra
+    if year < 10000:
+      result.add year.intToStr(4)
+    else:
+      result.add '+' & $year
+  of YYYY:
+    if dt.year < 1:
+      result.add $(abs(dt.year) + 1)
+    else:
+      result.add $dt.year
+  of uuuu:
+    let year = dt.year
+    if year < 10000 or year < 0:
+      result.add year.intToStr(4)
+    else:
+      result.add '+' & $year
+  of UUUU:
+    result.add $dt.year
+  of V:
+    result.add $dt.getIsoWeekAndYear.isoweek
+  of VV:
+    result.add dt.getIsoWeekAndYear.isoweek.intToStr(2)
+  of z, zz, zzz, zzzz, ZZZ, ZZZZ:
+    if dt.timezone != nil and dt.timezone.name == "Etc/UTC":
+      result.add 'Z'
+    else:
+      result.add if -dt.utcOffset >= 0: '+' else: '-'
+      let absOffset = abs(dt.utcOffset)
+      case pattern:
+      of z:
+        result.add $(absOffset div 3600)
+      of zz:
+        result.add (absOffset div 3600).intToStr(2)
+      of zzz, ZZZ:
+        let h = (absOffset div 3600).intToStr(2)
+        let m = ((absOffset div 60) mod 60).intToStr(2)
+        let sep = if pattern == zzz: ":" else: ""
+        result.add h & sep & m
+      of zzzz, ZZZZ:
+        let absOffset = abs(dt.utcOffset)
+        let h = (absOffset div 3600).intToStr(2)
+        let m = ((absOffset div 60) mod 60).intToStr(2)
+        let s = (absOffset mod 60).intToStr(2)
+        let sep = if pattern == zzzz: ":" else: ""
+        result.add h & sep & m & sep & s
+      else: assert false
+  of g:
+    result.add if dt.year < 1: "BC" else: "AD"
+  of Lit: assert false # Can't happen
+
+proc parsePattern(input: string, pattern: FormatPattern, i: var int,
+                  parsed: var ParsedTime, loc: DateTimeLocale): bool =
+  template takeInt(allowedWidth: Slice[int], allowSign = false): int =
+    var sv = 0
+    var pd = parseInt(input, sv, i, allowedWidth.b, allowSign)
+    if pd < allowedWidth.a:
+      return false
+    i.inc pd
+    sv
+
+  template contains[T](t: typedesc[T], i: int): bool =
+    i in low(t)..high(t)
+
+  result = true
+
+  case pattern
+  of d:
+    let monthday = takeInt(1..2)
+    parsed.monthday = some(monthday)
+    result = monthday in MonthdayRange
+  of dd:
+    let monthday = takeInt(2..2)
+    parsed.monthday = some(monthday)
+    result = monthday in MonthdayRange
+  of ddd:
+    result = false
+    for d, v in loc.ddd:
+      if input.substr(i, i+v.len-1).cmpIgnoreCase(v) == 0:
+        parsed.weekday = some(d.WeekDay)
+        result = true
+        i.inc v.len
+        break
+  of dddd:
+    result = false
+    for d, v in loc.dddd:
+      if input.substr(i, i+v.len-1).cmpIgnoreCase(v) == 0:
+        parsed.weekday = some(d.WeekDay)
+        result = true
+        i.inc v.len
+        break
+  of GG:
+    # Assumes current century
+    var isoyear = takeInt(2..2)
+    var thisCen = now().year div 100
+    parsed.isoyear = some(thisCen*100 + isoyear)
+    result = isoyear > 0
+  of GGGG:
+    let isoyear = takeInt(1..high(int))
+    parsed.isoyear = some(isoyear)
+    result = isoyear > 0
+  of h, H:
+    parsed.hour = takeInt(1..2)
+    result = parsed.hour in HourRange
+  of hh, HH:
+    parsed.hour = takeInt(2..2)
+    result = parsed.hour in HourRange
+  of m:
+    parsed.minute = takeInt(1..2)
+    result = parsed.hour in MinuteRange
+  of mm:
+    parsed.minute = takeInt(2..2)
+    result = parsed.hour in MinuteRange
+  of M:
+    let month = takeInt(1..2)
+    result = month in 1..12
+    parsed.month = some(month)
+  of MM:
+    let month = takeInt(2..2)
+    result = month in 1..12
+    parsed.month = some(month)
+  of MMM:
+    result = false
+    for n, v in loc.MMM:
+      if input.substr(i, i+v.len-1).cmpIgnoreCase(v) == 0:
+        result = true
+        i.inc v.len
+        parsed.month = some(n.int)
+        break
+  of MMMM:
+    result = false
+    for n, v in loc.MMMM:
+      if input.substr(i, i+v.len-1).cmpIgnoreCase(v) == 0:
+        result = true
+        i.inc v.len
+        parsed.month = some(n.int)
+        break
+  of s:
+    parsed.second = takeInt(1..2)
+  of ss:
+    parsed.second = takeInt(2..2)
+  of fff, ffffff, fffffffff:
+    let len = ($pattern).len
+    let v = takeInt(len..len)
+    parsed.nanosecond = v * 10^(9 - len)
+    result = parsed.nanosecond in NanosecondRange
+  of t:
+    case input[i]:
+    of 'P':
+      parsed.amPm = apPm
+    of 'A':
+      parsed.amPm = apAm
+    else:
+      result = false
+    i.inc 1
+  of tt:
+    if input.substr(i, i+1).cmpIgnoreCase("AM") == 0:
+      parsed.amPm = apAm
+      i.inc 2
+    elif input.substr(i, i+1).cmpIgnoreCase("PM") == 0:
+      parsed.amPm = apPm
+      i.inc 2
+    else:
+      result = false
+  of yy:
+    # Assumes current century
+    var year = takeInt(2..2)
+    var thisCen = now().year div 100
+    parsed.year = some(thisCen*100 + year)
+    result = year > 0
+  of yyyy:
+    let year =
+      if input[i] in {'+', '-'}:
+        takeInt(4..high(int), allowSign = true)
+      else:
+        takeInt(4..4)
+    result = year > 0
+    parsed.year = some(year)
+  of YYYY:
+    let year = takeInt(1..high(int))
+    parsed.year = some(year)
+    result = year > 0
+  of uuuu:
+    let year =
+      if input[i] in {'+', '-'}:
+        takeInt(4..high(int), allowSign = true)
+      else:
+        takeInt(4..4)
+    parsed.year = some(year)
+  of UUUU:
+    parsed.year = some(takeInt(1..high(int), allowSign = true))
+  of V:
+    let yearweek = takeInt(1..2)
+    parsed.yearweek = some(yearweek)
+    result = yearweek in IsoWeekRange
+  of VV:
+    let yearweek = takeInt(2..2)
+    parsed.yearweek = some(yearweek)
+    result = yearweek in IsoWeekRange
+  of z, zz, zzz, zzzz, ZZZ, ZZZZ:
+    case input[i]
+    of '+', '-':
+      let sign = if input[i] == '-': 1 else: -1
+      i.inc
+      var offset = 0
+      case pattern
+      of z:
+        offset = takeInt(1..2) * 3600
+      of zz:
+        offset = takeInt(2..2) * 3600
+      of zzz, ZZZ:
+        offset.inc takeInt(2..2) * 3600
+        if pattern == zzz:
+          if input[i] != ':':
+            return false
+          i.inc
+        offset.inc takeInt(2..2) * 60
+      of zzzz, ZZZZ:
+        offset.inc takeInt(2..2) * 3600
+        if pattern == zzzz:
+          if input[i] != ':':
+            return false
+          i.inc
+        offset.inc takeInt(2..2) * 60
+        if pattern == zzzz:
+          if input[i] != ':':
+            return false
+          i.inc
+        offset.inc takeInt(2..2)
+      else: assert false
+      parsed.utcOffset = some(offset * sign)
+    of 'Z':
+      parsed.utcOffset = some(0)
+      i.inc
+    else:
+      result = false
+  of g:
+    if input.substr(i, i+1).cmpIgnoreCase("BC") == 0:
+      parsed.era = eraBc
+      i.inc 2
+    elif input.substr(i, i+1).cmpIgnoreCase("AD") == 0:
+      parsed.era = eraAd
+      i.inc 2
+    else:
+      result = false
+  of Lit: raiseAssert "Can't happen"
+
+proc toDateTime(p: ParsedTime, zone: Timezone, f: TimeFormat,
+                input: string): DateTime =
+  var year = p.year.get(0)
+  var month = p.month.get(1).Month
+  var monthday = p.monthday.get(1)
+  year =
+    case p.era
+    of eraUnknown:
+      year
+    of eraBc:
+      if year < 1:
+        raiseParseException(f, input,
+          "Expected year to be positive " &
+          "(use 'UUUU' or 'uuuu' for negative years).")
+      -year + 1
+    of eraAd:
+      if year < 1:
+        raiseParseException(f, input,
+          "Expected year to be positive " &
+          "(use 'UUUU' or 'uuuu' for negative years).")
+      year
+
+  let hour =
+    case p.amPm
+    of apUnknown:
+      p.hour
+    of apAm:
+      if p.hour notin 1..12:
+        raiseParseException(f, input,
+          "AM/PM time must be in the interval 1..12")
+      if p.hour == 12: 0 else: p.hour
+    of apPm:
+      if p.hour notin 1..12:
+        raiseParseException(f, input,
+          "AM/PM time must be in the interval 1..12")
+      if p.hour == 12: p.hour else: p.hour + 12
+  let minute = p.minute
+  let second = p.second
+  let nanosecond = p.nanosecond
+
+  if monthday > getDaysInMonth(month, year):
+    raiseParseException(f, input,
+      $year & "-" & ord(month).intToStr(2) &
+      "-" & $monthday & " is not a valid date")
+
+  if p.utcOffset.isNone:
+    # No timezone parsed - assume timezone is `zone`
+    result = dateTime(year, month, monthday, hour, minute, second, nanosecond, zone)
+  else:
+    # Otherwise convert to `zone`
+    result = (dateTime(year, month, monthday, hour, minute, second, nanosecond, utc()).toTime +
+      initDuration(seconds = p.utcOffset.get())).inZone(zone)
+
+proc toDateTimeByWeek(p: ParsedTime, zone: Timezone, f: TimeFormat,
+                   input: string): DateTime =
+  var isoyear = p.isoyear.get(0)
+  var yearweek = p.yearweek.get(1)
+  var weekday = p.weekday.get(dMon)
+
+  if p.amPm != apUnknown:
+    raiseParseException(f, input, "Parsing iso weekyear dates does not support am/pm")
+
+  if p.year.isSome:
+    raiseParseException(f, input, "Use iso-year GG or GGGG as year with iso week number")
+
+  if p.month.isSome:
+    raiseParseException(f, input, "Use either iso week number V or VV or month")
+
+  if p.monthday.isSome:
+    raiseParseException(f, input, "Use weekday ddd or dddd as day with with iso week number")
+
+  if p.isoyear.isNone:
+    raiseParseException(f, input, "Need iso-year with week number")
+
+  let hour = p.hour
+  let minute = p.minute
+  let second = p.second
+  let nanosecond = p.nanosecond
+
+  if p.utcOffset.isNone:
+    result = initDateTime(weekday, yearweek.IsoWeekRange, isoyear.IsoYear, hour, minute, second, nanosecond, zone)
+  else:
+    result = (initDateTime(weekday, yearweek.IsoWeekRange, isoyear.IsoYear, hour, minute, second, nanosecond, zone).toTime +
+      initDuration(seconds = p.utcOffset.get())).inZone(zone)
+
+proc format*(dt: DateTime, f: TimeFormat,
+    loc: DateTimeLocale = DefaultLocale): string {.raises: [].} =
+  ## Format `dt` using the format specified by `f`.
+  runnableExamples:
+    let f = initTimeFormat("yyyy-MM-dd")
+    let dt = dateTime(2000, mJan, 01, 00, 00, 00, 00, utc())
+    doAssert "2000-01-01" == dt.format(f)
+  assertDateTimeInitialized dt
+  result = ""
+  var idx = 0
+  while idx <= f.patterns.high:
+    case f.patterns[idx].FormatPattern
+    of Lit:
+      idx.inc
+      let len = f.patterns[idx]
+      for i in 1'u8..len:
+        idx.inc
+        result.add f.patterns[idx].char
+      idx.inc
+    else:
+      formatPattern(dt, f.patterns[idx].FormatPattern, result = result, loc = loc)
+      idx.inc
+
+proc format*(dt: DateTime, f: string, loc: DateTimeLocale = DefaultLocale): string
+    {.raises: [TimeFormatParseError].} =
+  ## Shorthand for constructing a `TimeFormat` and using it to format `dt`.
+  ##
+  ## See `Parsing and formatting dates`_ for documentation of the
+  ## `format` argument.
+  runnableExamples:
+    let dt = dateTime(2000, mJan, 01, 00, 00, 00, 00, utc())
+    doAssert "2000-01-01" == format(dt, "yyyy-MM-dd")
+  let dtFormat = initTimeFormat(f)
+  result = dt.format(dtFormat, loc)
+
+proc format*(dt: DateTime, f: static[string]): string {.raises: [].} =
+  ## Overload that validates `format` at compile time.
+  const f2 = initTimeFormat(f)
+  result = dt.format(f2)
+
+proc formatValue*(result: var string; value: DateTime | Time, specifier: string) =
+  ## adapter for strformat. Not intended to be called directly.
+  result.add format(value,
+    if specifier.len == 0: "yyyy-MM-dd'T'HH:mm:sszzz" else: specifier)
+
+proc format*(time: Time, f: string, zone: Timezone = local()): string
+    {.raises: [TimeFormatParseError].} =
+  ## Shorthand for constructing a `TimeFormat` and using it to format
+  ## `time`. Will use the timezone specified by `zone`.
+  ##
+  ## See `Parsing and formatting dates`_ for documentation of the
+  ## `f` argument.
+  runnableExamples:
+    var dt = dateTime(1970, mJan, 01, 00, 00, 00, 00, utc())
+    var tm = dt.toTime()
+    doAssert format(tm, "yyyy-MM-dd'T'HH:mm:ss", utc()) == "1970-01-01T00:00:00"
+  time.inZone(zone).format(f)
+
+proc format*(time: Time, f: static[string], zone: Timezone = local()): string
+    {.raises: [].} =
+  ## Overload that validates `f` at compile time.
+  const f2 = initTimeFormat(f)
+  result = time.inZone(zone).format(f2)
+
+proc parse*(input: string, f: TimeFormat, zone: Timezone = local(),
+    loc: DateTimeLocale = DefaultLocale): DateTime {.parseRaises.} =
+  ## Parses `input` as a `DateTime` using the format specified by `f`.
+  ## If no UTC offset was parsed, then `input` is assumed to be specified in
+  ## the `zone` timezone. If a UTC offset was parsed, the result will be
+  ## converted to the `zone` timezone.
+  ##
+  ## Month and day names from the passed in `loc` are used.
+  runnableExamples:
+    let f = initTimeFormat("yyyy-MM-dd")
+    let dt = dateTime(2000, mJan, 01, 00, 00, 00, 00, utc())
+    doAssert dt == "2000-01-01".parse(f, utc())
+  var inpIdx = 0 # Input index
+  var patIdx = 0 # Pattern index
+  var parsed: ParsedTime
+  while inpIdx <= input.high and patIdx <= f.patterns.high:
+    let pattern = f.patterns[patIdx].FormatPattern
+    case pattern
+    of Lit:
+      patIdx.inc
+      let len = f.patterns[patIdx]
+      patIdx.inc
+      for _ in 1'u8..len:
+        if input[inpIdx] != f.patterns[patIdx].char:
+          raiseParseException(f, input,
+                              "Unexpected character: " & input[inpIdx])
+        inpIdx.inc
+        patIdx.inc
+    else:
+      if not parsePattern(input, pattern, inpIdx, parsed, loc):
+        raiseParseException(f, input, "Failed on pattern '" & $pattern & "'")
+      patIdx.inc
+
+  if inpIdx <= input.high:
+    raiseParseException(f, input,
+                        "Parsing ended but there was still input remaining")
+
+  if patIdx <= f.patterns.high:
+    raiseParseException(f, input,
+                            "Parsing ended but there was still patterns remaining")
+
+  if parsed.yearweek.isSome:
+    result = toDateTimeByWeek(parsed, zone, f, input)
+  elif parsed.isoyear.isSome:
+    raiseParseException(f, input, "Iso year GG or GGGG require iso week V or VV")
+  else:
+    result = toDateTime(parsed, zone, f, input)
+
+proc parse*(input, f: string, tz: Timezone = local(),
+    loc: DateTimeLocale = DefaultLocale): DateTime {.parseFormatRaises.} =
+  ## Shorthand for constructing a `TimeFormat` and using it to parse
+  ## `input` as a `DateTime`.
+  ##
+  ## See `Parsing and formatting dates`_ for documentation of the
+  ## `f` argument.
+  runnableExamples:
+    let dt = dateTime(2000, mJan, 01, 00, 00, 00, 00, utc())
+    doAssert dt == parse("2000-01-01", "yyyy-MM-dd", utc())
+  let dtFormat = initTimeFormat(f)
+  result = input.parse(dtFormat, tz, loc = loc)
+
+proc parse*(input: string, f: static[string], zone: Timezone = local(),
+    loc: DateTimeLocale = DefaultLocale): DateTime {.parseRaises.} =
+  ## Overload that validates `f` at compile time.
+  const f2 = initTimeFormat(f)
+  result = input.parse(f2, zone, loc = loc)
+
+proc parseTime*(input, f: string, zone: Timezone): Time {.parseFormatRaises.} =
+  ## Shorthand for constructing a `TimeFormat` and using it to parse
+  ## `input` as a `DateTime`, then converting it a `Time`.
+  ##
+  ## See `Parsing and formatting dates`_ for documentation of the
+  ## `format` argument.
+  runnableExamples:
+    let tStr = "1970-01-01T00:00:00+00:00"
+    doAssert parseTime(tStr, "yyyy-MM-dd'T'HH:mm:sszzz", utc()) == fromUnix(0)
+  parse(input, f, zone).toTime()
+
+proc parseTime*(input: string, f: static[string], zone: Timezone): Time
+    {.parseRaises.} =
+  ## Overload that validates `format` at compile time.
+  const f2 = initTimeFormat(f)
+  result = input.parse(f2, zone).toTime()
+
+proc `$`*(dt: DateTime): string {.tags: [], raises: [], benign.} =
+  ## Converts a `DateTime` object to a string representation.
+  ## It uses the format `yyyy-MM-dd'T'HH:mm:sszzz`.
+  runnableExamples:
+    let dt = dateTime(2000, mJan, 01, 12, 00, 00, 00, utc())
+    doAssert $dt == "2000-01-01T12:00:00Z"
+    doAssert $default(DateTime) == "Uninitialized DateTime"
+  if not dt.isInitialized:
+    result = "Uninitialized DateTime"
+  else:
+    result = format(dt, "yyyy-MM-dd'T'HH:mm:sszzz")
+
+proc `$`*(time: Time): string {.tags: [], raises: [], benign.} =
+  ## Converts a `Time` value to a string representation. It will use the local
+  ## time zone and use the format `yyyy-MM-dd'T'HH:mm:sszzz`.
+  runnableExamples:
+    let dt = dateTime(1970, mJan, 01, 00, 00, 00, 00, local())
+    let tm = dt.toTime()
+    doAssert $tm == "1970-01-01T00:00:00" & format(dt, "zzz")
+  $time.local
+
+#
+# TimeInterval
+#
+
+proc initTimeInterval*(nanoseconds, microseconds, milliseconds,
+                       seconds, minutes, hours,
+                       days, weeks, months, years: int = 0): TimeInterval =
+  ## Creates a new `TimeInterval <#TimeInterval>`_.
+  ##
+  ## This proc doesn't perform any normalization! For example,
+  ## `initTimeInterval(hours = 24)` and `initTimeInterval(days = 1)` are
+  ## not equal.
+  ##
+  ## You can also use the convenience procedures called `milliseconds`,
+  ## `seconds`, `minutes`, `hours`, `days`, `months`, and `years`.
+  runnableExamples:
+    let day = initTimeInterval(hours = 24)
+    let dt = dateTime(2000, mJan, 01, 12, 00, 00, 00, utc())
+    doAssert $(dt + day) == "2000-01-02T12:00:00Z"
+    doAssert initTimeInterval(hours = 24) != initTimeInterval(days = 1)
+  result.nanoseconds = nanoseconds
+  result.microseconds = microseconds
+  result.milliseconds = milliseconds
+  result.seconds = seconds
+  result.minutes = minutes
+  result.hours = hours
+  result.days = days
+  result.weeks = weeks
+  result.months = months
+  result.years = years
+
+proc `+`*(ti1, ti2: TimeInterval): TimeInterval =
+  ## Adds two `TimeInterval` objects together.
+  result.nanoseconds = ti1.nanoseconds + ti2.nanoseconds
+  result.microseconds = ti1.microseconds + ti2.microseconds
+  result.milliseconds = ti1.milliseconds + ti2.milliseconds
+  result.seconds = ti1.seconds + ti2.seconds
+  result.minutes = ti1.minutes + ti2.minutes
+  result.hours = ti1.hours + ti2.hours
+  result.days = ti1.days + ti2.days
+  result.weeks = ti1.weeks + ti2.weeks
+  result.months = ti1.months + ti2.months
+  result.years = ti1.years + ti2.years
+
+proc `-`*(ti: TimeInterval): TimeInterval =
+  ## Reverses a time interval
+  runnableExamples:
+    let day = -initTimeInterval(hours = 24)
+    doAssert day.hours == -24
+
+  result = TimeInterval(
+    nanoseconds: -ti.nanoseconds,
+    microseconds: -ti.microseconds,
+    milliseconds: -ti.milliseconds,
+    seconds: -ti.seconds,
+    minutes: -ti.minutes,
+    hours: -ti.hours,
+    days: -ti.days,
+    weeks: -ti.weeks,
+    months: -ti.months,
+    years: -ti.years
+  )
+
+proc `-`*(ti1, ti2: TimeInterval): TimeInterval =
+  ## Subtracts TimeInterval `ti1` from `ti2`.
+  ##
+  ## Time components are subtracted one-by-one, see output:
+  runnableExamples:
+    let ti1 = initTimeInterval(hours = 24)
+    let ti2 = initTimeInterval(hours = 4)
+    doAssert (ti1 - ti2) == initTimeInterval(hours = 20)
+
+  result = ti1 + (-ti2)
+
+proc `+=`*(a: var TimeInterval, b: TimeInterval) =
+  a = a + b
+
+proc `-=`*(a: var TimeInterval, b: TimeInterval) =
+  a = a - b
+
+proc isStaticInterval(interval: TimeInterval): bool =
+  interval.years == 0 and interval.months == 0 and
+    interval.days == 0 and interval.weeks == 0
+
+proc evaluateStaticInterval(interval: TimeInterval): Duration =
+  assert interval.isStaticInterval
+  initDuration(nanoseconds = interval.nanoseconds,
+    microseconds = interval.microseconds,
+    milliseconds = interval.milliseconds,
+    seconds = interval.seconds,
+    minutes = interval.minutes,
+    hours = interval.hours)
+
+proc between*(startDt, endDt: DateTime): TimeInterval =
+  ## Gives the difference between `startDt` and `endDt` as a
+  ## `TimeInterval`. The following guarantees about the result is given:
+  ##
+  ## - All fields will have the same sign.
+  ## - If `startDt.timezone == endDt.timezone`, it is guaranteed that
+  ##   `startDt + between(startDt, endDt) == endDt`.
+  ## - If `startDt.timezone != endDt.timezone`, then the result will be
+  ##   equivalent to `between(startDt.utc, endDt.utc)`.
+  runnableExamples:
+    var a = dateTime(2015, mMar, 25, 12, 0, 0, 00, utc())
+    var b = dateTime(2017, mApr, 1, 15, 0, 15, 00, utc())
+    var ti = initTimeInterval(years = 2, weeks = 1, hours = 3, seconds = 15)
+    doAssert between(a, b) == ti
+    doAssert between(a, b) == -between(b, a)
+
+  if startDt.timezone != endDt.timezone:
+    return between(startDt.utc, endDt.utc)
+  elif endDt < startDt:
+    return -between(endDt, startDt)
+
+  type Date = tuple[year, month, monthday: int]
+  var startDate: Date = (startDt.year, startDt.month.ord, startDt.monthday)
+  var endDate: Date = (endDt.year, endDt.month.ord, endDt.monthday)
+
+  # Subtract one day from endDate if time of day is earlier than startDay
+  # The subtracted day will be counted by fixed units (hour and lower)
+  # at the end of this proc
+  if (endDt.hour, endDt.minute, endDt.second, endDt.nanosecond) <
+      (startDt.hour, startDt.minute, startDt.second, startDt.nanosecond):
+    if endDate.month == 1 and endDate.monthday == 1:
+      endDate.year.dec
+      endDate.monthday = 31
+      endDate.month = 12
+    elif endDate.monthday == 1:
+      endDate.month.dec
+      endDate.monthday = getDaysInMonth(endDate.month.Month, endDate.year)
+    else:
+      endDate.monthday.dec
+
+  # Years
+  result.years = endDate.year - startDate.year - 1
+  if (startDate.month, startDate.monthday) <= (endDate.month, endDate.monthday):
+    result.years.inc
+  startDate.year.inc result.years
+
+  # Months
+  if startDate.year < endDate.year:
+    result.months.inc 12 - startDate.month # Move to dec
+    if endDate.month != 1 or (startDate.monthday <= endDate.monthday):
+      result.months.inc
+      startDate.year = endDate.year
+      startDate.month = 1
+    else:
+      startDate.month = 12
+  if startDate.year == endDate.year:
+    if (startDate.monthday <= endDate.monthday):
+      result.months.inc endDate.month - startDate.month
+      startDate.month = endDate.month
+    elif endDate.month != 1:
+      let month = endDate.month - 1
+      let daysInMonth = getDaysInMonth(month.Month, startDate.year)
+      if daysInMonth < startDate.monthday:
+        if startDate.monthday - daysInMonth < endDate.monthday:
+          result.months.inc endDate.month - startDate.month - 1
+          startDate.month = endDate.month
+          startDate.monthday = startDate.monthday - daysInMonth
+        else:
+          result.months.inc endDate.month - startDate.month - 2
+          startDate.month = endDate.month - 2
+      else:
+        result.months.inc endDate.month - startDate.month - 1
+        startDate.month = endDate.month - 1
+
+  # Days
+  # This means that start = dec and end = jan
+  if startDate.year < endDate.year:
+    result.days.inc 31 - startDate.monthday + endDate.monthday
+    startDate = endDate
+  else:
+    while startDate.month < endDate.month:
+      let daysInMonth = getDaysInMonth(startDate.month.Month, startDate.year)
+      result.days.inc daysInMonth - startDate.monthday + 1
+      startDate.month.inc
+      startDate.monthday = 1
+    result.days.inc endDate.monthday - startDate.monthday
+    result.weeks = result.days div 7
+    result.days = result.days mod 7
+    startDate = endDate
+
+  # Handle hours, minutes, seconds, milliseconds, microseconds and nanoseconds
+  let newStartDt = dateTime(startDate.year, startDate.month.Month,
+    startDate.monthday, startDt.hour, startDt.minute, startDt.second,
+    startDt.nanosecond, startDt.timezone)
+  let dur = endDt - newStartDt
+  let parts = toParts(dur)
+  # There can still be a full day in `parts` since `Duration` and `TimeInterval`
+  # models days differently.
+  result.hours = parts[Hours].int + parts[Days].int * 24
+  result.minutes = parts[Minutes].int
+  result.seconds = parts[Seconds].int
+  result.milliseconds = parts[Milliseconds].int
+  result.microseconds = parts[Microseconds].int
+  result.nanoseconds = parts[Nanoseconds].int
+
+proc toParts*(ti: TimeInterval): TimeIntervalParts =
+  ## Converts a `TimeInterval` into an array consisting of its time units,
+  ## starting with nanoseconds and ending with years.
+  ##
+  ## This procedure is useful for converting `TimeInterval` values to strings.
+  ## E.g. then you need to implement custom interval printing
+  runnableExamples:
+    var tp = toParts(initTimeInterval(years = 1, nanoseconds = 123))
+    doAssert tp[Years] == 1
+    doAssert tp[Nanoseconds] == 123
+
+  var index = 0
+  for name, value in fieldPairs(ti):
+    result[index.TimeUnit()] = value
+    index += 1
+
+proc `$`*(ti: TimeInterval): string =
+  ## Get string representation of `TimeInterval`.
+  runnableExamples:
+    doAssert $initTimeInterval(years = 1, nanoseconds = 123) ==
+      "1 year and 123 nanoseconds"
+    doAssert $initTimeInterval() == "0 nanoseconds"
+
+  var parts: seq[string] = @[]
+  var tiParts = toParts(ti)
+  for unit in countdown(Years, Nanoseconds):
+    if tiParts[unit] != 0:
+      parts.add(stringifyUnit(tiParts[unit], unit))
+
+  result = humanizeParts(parts)
+
+proc nanoseconds*(nanos: int): TimeInterval {.inline.} =
+  ## TimeInterval of `nanos` nanoseconds.
+  initTimeInterval(nanoseconds = nanos)
+
+proc microseconds*(micros: int): TimeInterval {.inline.} =
+  ## TimeInterval of `micros` microseconds.
+  initTimeInterval(microseconds = micros)
+
+proc milliseconds*(ms: int): TimeInterval {.inline.} =
+  ## TimeInterval of `ms` milliseconds.
+  initTimeInterval(milliseconds = ms)
+
+proc seconds*(s: int): TimeInterval {.inline.} =
+  ## TimeInterval of `s` seconds.
+  ##
+  ## `echo getTime() + 5.seconds`
+  initTimeInterval(seconds = s)
+
+proc minutes*(m: int): TimeInterval {.inline.} =
+  ## TimeInterval of `m` minutes.
+  ##
+  ## `echo getTime() + 5.minutes`
+  initTimeInterval(minutes = m)
+
+proc hours*(h: int): TimeInterval {.inline.} =
+  ## TimeInterval of `h` hours.
+  ##
+  ## `echo getTime() + 2.hours`
+  initTimeInterval(hours = h)
+
+proc days*(d: int): TimeInterval {.inline.} =
+  ## TimeInterval of `d` days.
+  ##
+  ## `echo getTime() + 2.days`
+  initTimeInterval(days = d)
+
+proc weeks*(w: int): TimeInterval {.inline.} =
+  ## TimeInterval of `w` weeks.
+  ##
+  ## `echo getTime() + 2.weeks`
+  initTimeInterval(weeks = w)
+
+proc months*(m: int): TimeInterval {.inline.} =
+  ## TimeInterval of `m` months.
+  ##
+  ## `echo getTime() + 2.months`
+  initTimeInterval(months = m)
+
+proc years*(y: int): TimeInterval {.inline.} =
+  ## TimeInterval of `y` years.
+  ##
+  ## `echo getTime() + 2.years`
+  initTimeInterval(years = y)
+
+proc evaluateInterval(dt: DateTime, interval: TimeInterval):
+    tuple[adjDur, absDur: Duration] =
+  ## Evaluates how many nanoseconds the interval is worth
+  ## in the context of `dt`.
+  ## The result in split into an adjusted diff and an absolute diff.
+  var months = interval.years * 12 + interval.months
+  var curYear = dt.year
+  var curMonth = dt.month
+  result = default(tuple[adjDur, absDur: Duration])
+  # Subtracting
+  if months < 0:
+    for mth in countdown(-1 * months, 1):
+      if curMonth == mJan:
+        curMonth = mDec
+        curYear.dec
+      else:
+        curMonth.dec()
+      let days = getDaysInMonth(curMonth, curYear)
+      result.adjDur = result.adjDur - initDuration(days = days)
+  # Adding
+  else:
+    for mth in 1 .. months:
+      let days = getDaysInMonth(curMonth, curYear)
+      result.adjDur = result.adjDur + initDuration(days = days)
+      if curMonth == mDec:
+        curMonth = mJan
+        curYear.inc
+      else:
+        curMonth.inc()
+
+  result.adjDur = result.adjDur + initDuration(
+    days = interval.days,
+    weeks = interval.weeks)
+  result.absDur = initDuration(
+    nanoseconds = interval.nanoseconds,
+    microseconds = interval.microseconds,
+    milliseconds = interval.milliseconds,
+    seconds = interval.seconds,
+    minutes = interval.minutes,
+    hours = interval.hours)
+
+proc `+`*(dt: DateTime, interval: TimeInterval): DateTime =
+  ## Adds `interval` to `dt`. Components from `interval` are added
+  ## in the order of their size, i.e. first the `years` component, then the
+  ## `months` component and so on. The returned `DateTime` will have the
+  ## same timezone as the input.
+  ##
+  ## Note that when adding months, monthday overflow is allowed. This means that
+  ## if the resulting month doesn't have enough days it, the month will be
+  ## incremented and the monthday will be set to the number of days overflowed.
+  ## So adding one month to `31 October` will result in `31 November`, which
+  ## will overflow and result in `1 December`.
+  runnableExamples:
+    let dt = dateTime(2017, mMar, 30, 00, 00, 00, 00, utc())
+    doAssert $(dt + 1.months) == "2017-04-30T00:00:00Z"
+    # This is correct and happens due to monthday overflow.
+    doAssert $(dt - 1.months) == "2017-03-02T00:00:00Z"
+  let (adjDur, absDur) = evaluateInterval(dt, interval)
+
+  if adjDur != DurationZero:
+    var zt = dt.timezone.zonedTimeFromAdjTime(dt.toAdjTime + adjDur)
+    if absDur != DurationZero:
+      zt = dt.timezone.zonedTimeFromTime(zt.time + absDur)
+      result = initDateTime(zt, dt.timezone)
+    else:
+      result = initDateTime(zt, dt.timezone)
+  else:
+    var zt = dt.timezone.zonedTimeFromTime(dt.toTime + absDur)
+    result = initDateTime(zt, dt.timezone)
+
+proc `-`*(dt: DateTime, interval: TimeInterval): DateTime =
+  ## Subtract `interval` from `dt`. Components from `interval` are
+  ## subtracted in the order of their size, i.e. first the `years` component,
+  ## then the `months` component and so on. The returned `DateTime` will
+  ## have the same timezone as the input.
+  runnableExamples:
+    let dt = dateTime(2017, mMar, 30, 00, 00, 00, 00, utc())
+    doAssert $(dt - 5.days) == "2017-03-25T00:00:00Z"
+
+  dt + (-interval)
+
+proc `+`*(time: Time, interval: TimeInterval): Time =
+  ## Adds `interval` to `time`.
+  ## If `interval` contains any years, months, weeks or days the operation
+  ## is performed in the local timezone.
+  runnableExamples:
+    let tm = fromUnix(0)
+    doAssert tm + 5.seconds == fromUnix(5)
+
+  if interval.isStaticInterval:
+    time + evaluateStaticInterval(interval)
+  else:
+    toTime(time.local + interval)
+
+proc `-`*(time: Time, interval: TimeInterval): Time =
+  ## Subtracts `interval` from Time `time`.
+  ## If `interval` contains any years, months, weeks or days the operation
+  ## is performed in the local timezone.
+  runnableExamples:
+    let tm = fromUnix(5)
+    doAssert tm - 5.seconds == fromUnix(0)
+
+  if interval.isStaticInterval:
+    time - evaluateStaticInterval(interval)
+  else:
+    toTime(time.local - interval)
+
+proc `+=`*(a: var DateTime, b: TimeInterval) =
+  a = a + b
+
+proc `-=`*(a: var DateTime, b: TimeInterval) =
+  a = a - b
+
+proc `+=`*(t: var Time, b: TimeInterval) =
+  t = t + b
+
+proc `-=`*(t: var Time, b: TimeInterval) =
+  t = t - b
+
+#
+# Iso week
+#
+
+proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   nanosecond: NanosecondRange,
+                   zone: Timezone = local()): DateTime {.raises: [], tags: [], since: (1, 5).} =
+  ## Create a new `DateTime <#DateTime>`_ from a weekday and an ISO 8601 week number and year
+  ## in the specified timezone.
+  ##
+  ## .. warning:: The ISO week-based year can correspond to the following or previous year from 29 December to January 3.
+  runnableExamples:
+    assert initDateTime(21, mApr, 2018, 00, 00, 00) == initDateTime(dSat, 16, 2018.IsoYear, 00, 00, 00)
+    assert initDateTime(30, mDec, 2019, 00, 00, 00) == initDateTime(dMon, 01, 2020.IsoYear, 00, 00, 00)
+    assert initDateTime(13, mSep, 2020, 00, 00, 00) == initDateTime(dSun, 37, 2020.IsoYear, 00, 00, 00)
+    assert initDateTime(2, mJan, 2021, 00, 00, 00) == initDateTime(dSat, 53, 2020.IsoYear, 00, 00, 00)
+
+  # source https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm
+  let d = isoweek * 7 + weekday.int - initDateTime(4, mJan, isoyear.int, 00, 00, 00, zone).weekday.int - 4
+  initDateTime(1, mJan, isoyear.int, hour, minute, second, nanosecond, zone) + initTimeInterval(days=d)
+
+proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
+                   hour: HourRange, minute: MinuteRange, second: SecondRange,
+                   zone: Timezone = local()): DateTime {.raises: [], tags: [], since: (1, 5).} =
+  initDateTime(weekday, isoweek, isoyear, hour, minute, second, 0, zone)
+
+#
+# Other
+#
+
+proc epochTime*(): float {.tags: [TimeEffect].} =
+  ## Gets time after the UNIX epoch (1970) in seconds. It is a float
+  ## because sub-second resolution is likely to be supported (depending
+  ## on the hardware/OS).
+  ##
+  ## `getTime` should generally be preferred over this proc.
+  ##
+  ## .. warning:: Unsuitable for benchmarking (but still better than `now`),
+  ##    use `monotimes.getMonoTime` or `cpuTime` instead, depending on the use case.
+  when defined(js):
+    result = newDate().getTime() / 1000
+  elif defined(macosx):
+    var a {.noinit.}: Timeval
+    gettimeofday(a)
+    result = toBiggestFloat(a.tv_sec.int64) + toBiggestFloat(
+        a.tv_usec)*0.00_0001
+  elif defined(posix):
+    var ts {.noinit.}: Timespec
+    discard clock_gettime(CLOCK_REALTIME, ts)
+    result = toBiggestFloat(ts.tv_sec.int64) +
+      toBiggestFloat(ts.tv_nsec.int64) / 1_000_000_000
+  elif defined(windows):
+    var f {.noinit.}: winlean.FILETIME
+    getSystemTimeAsFileTime(f)
+    var i64 = rdFileTime(f) - epochDiff
+    var secs = i64 div rateDiff
+    var subsecs = i64 mod rateDiff
+    result = toFloat(int(secs)) + toFloat(int(subsecs)) * 0.0000001
+  else:
+    {.error: "unknown OS".}
+
+when not defined(js):
+  type
+    Clock {.importc: "clock_t".} = distinct int
+
+  proc getClock(): Clock
+      {.importc: "clock", header: "<time.h>", tags: [TimeEffect], used, sideEffect.}
+
   var
-    startMilsecs = getTime()
-  
-  proc getStartMilsecs(): int =
-    ## get the miliseconds from the start of the program
-    return int(getTime() - startMilsecs)
-
-proc getDateStr(): string =
-  var ti = getLocalTime(getTime())
-  result = $ti.year & '-' & intToStr(ord(ti.month)+1, 2) &
-    '-' & intToStr(ti.monthDay, 2)
-
-proc getClockStr(): string =
-  var ti = getLocalTime(getTime())
-  result = intToStr(ti.hour, 2) & ':' & intToStr(ti.minute, 2) &
-    ':' & intToStr(ti.second, 2)
-
-{.pop.}
+    clocksPerSec {.importc: "CLOCKS_PER_SEC", nodecl, used.}: int
+
+  proc cpuTime*(): float {.tags: [TimeEffect].} =
+    ## Gets time spent that the CPU spent to run the current process in
+    ## seconds. This may be more useful for benchmarking than `epochTime`.
+    ## However, it may measure the real time instead (depending on the OS).
+    ## The value of the result has no meaning.
+    ## To generate useful timing values, take the difference between
+    ## the results of two `cpuTime` calls:
+    runnableExamples:
+      var t0 = cpuTime()
+      # some useless work here (calculate fibonacci)
+      var fib = @[0, 1, 1]
+      for i in 1..10:
+        fib.add(fib[^1] + fib[^2])
+      echo "CPU time [s] ", cpuTime() - t0
+      echo "Fib is [s] ", fib
+    ## When the flag `--benchmarkVM` is passed to the compiler, this proc is
+    ## also available at compile time
+    when defined(posix) and not defined(osx) and declared(CLOCK_THREAD_CPUTIME_ID):
+      # 'clocksPerSec' is a compile-time constant, possibly a
+      # rather awful one, so use clock_gettime instead
+      var ts: Timespec
+      discard clock_gettime(CLOCK_THREAD_CPUTIME_ID, ts)
+      result = toFloat(ts.tv_sec.int) +
+        toFloat(ts.tv_nsec.int) / 1_000_000_000
+    else:
+      result = toFloat(int(getClock())) / toFloat(clocksPerSec)
+
+
+#
+# Deprecations
+#
+
+proc `nanosecond=`*(dt: var DateTime, value: NanosecondRange) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.nanosecond = value
+
+proc `second=`*(dt: var DateTime, value: SecondRange) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.second = value
+
+proc `minute=`*(dt: var DateTime, value: MinuteRange) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.minute = value
+
+proc `hour=`*(dt: var DateTime, value: HourRange) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.hour = value
+
+proc `monthdayZero=`*(dt: var DateTime, value: int) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.monthdayZero = value
+
+proc `monthZero=`*(dt: var DateTime, value: int) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.monthZero = value
+
+proc `year=`*(dt: var DateTime, value: int) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.year = value
+
+proc `weekday=`*(dt: var DateTime, value: WeekDay) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.weekday = value
+
+proc `yearday=`*(dt: var DateTime, value: YeardayRange) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.yearday = value
+
+proc `isDst=`*(dt: var DateTime, value: bool) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.isDst = value
+
+proc `timezone=`*(dt: var DateTime, value: Timezone) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.timezone = value
+
+proc `utcOffset=`*(dt: var DateTime, value: int) {.deprecated: "Deprecated since v1.3.1".} =
+  dt.utcOffset = value
diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim
new file mode 100644
index 000000000..78af84fdd
--- /dev/null
+++ b/lib/pure/typetraits.nim
@@ -0,0 +1,376 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module defines compile-time reflection procs for
+## working with types.
+##
+## Unstable API.
+
+import std/private/since
+export system.`$` # for backward compatibility
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type HoleyEnum* = (not Ordinal) and enum ## Enum with holes.
+type OrdinalEnum* = Ordinal and enum ## Enum without holes.
+
+runnableExamples:
+  type A = enum a0 = 2, a1 = 4, a2
+  type B = enum b0 = 2, b1, b2
+  assert A is enum
+  assert A is HoleyEnum
+  assert A isnot OrdinalEnum
+  assert B isnot HoleyEnum
+  assert B is OrdinalEnum
+  assert int isnot HoleyEnum
+  type C[T] = enum h0 = 2, h1 = 4
+  assert C[float] is HoleyEnum
+
+proc name*(t: typedesc): string {.magic: "TypeTrait".} =
+  ## Returns the name of `t`.
+  ##
+  ## Alias for `system.\`$\`(t) <dollars.html#$,typedesc>`_ since Nim v0.20.
+  runnableExamples:
+    doAssert name(int) == "int"
+    doAssert name(seq[string]) == "seq[string]"
+
+proc arity*(t: typedesc): int {.magic: "TypeTrait".} =
+  ## Returns the arity of `t`. This is the number of "type"
+  ## components or the number of generic parameters a given type `t` has.
+  runnableExamples:
+    doAssert arity(int) == 0
+    doAssert arity(seq[string]) == 1
+    doAssert arity(array[3, int]) == 2
+    doAssert arity((int, int, float, string)) == 4
+
+proc genericHead*(t: typedesc): typedesc {.magic: "TypeTrait".} =
+  ## Accepts an instantiated generic type and returns its
+  ## uninstantiated form.
+  ## A compile-time error will be produced if the supplied type
+  ## is not generic.
+  ##
+  ## **See also:**
+  ## * `stripGenericParams proc <#stripGenericParams,typedesc>`_
+  runnableExamples:
+    type
+      Foo[T] = object
+      FooInst = Foo[int]
+      Foo2 = genericHead(FooInst)
+
+    doAssert Foo2 is Foo and Foo is Foo2
+    doAssert genericHead(Foo[seq[string]]) is Foo
+    doAssert not compiles(genericHead(int))
+
+    type Generic = concept f
+      type _ = genericHead(typeof(f))
+
+    proc bar(a: Generic): typeof(a) = a
+
+    doAssert bar(Foo[string].default) == Foo[string]()
+    doAssert not compiles bar(string.default)
+
+    when false: # these don't work yet
+      doAssert genericHead(Foo[int])[float] is Foo[float]
+      doAssert seq[int].genericHead is seq
+
+proc stripGenericParams*(t: typedesc): typedesc {.magic: "TypeTrait".} =
+  ## This trait is similar to `genericHead <#genericHead,typedesc>`_, but
+  ## instead of producing an error for non-generic types, it will just return
+  ## them unmodified.
+  runnableExamples:
+    type Foo[T] = object
+
+    doAssert stripGenericParams(Foo[string]) is Foo
+    doAssert stripGenericParams(int) is int
+
+proc supportsCopyMem*(t: typedesc): bool {.magic: "TypeTrait".}
+  ## Returns true if `t` is safe to use for `copyMem`:idx:.
+  ##
+  ## Other languages name a type like these `blob`:idx:.
+
+proc hasDefaultValue*(t: typedesc): bool {.magic: "TypeTrait".} =
+  ## Returns true if `t` has a valid default value.
+  runnableExamples:
+    {.experimental: "strictNotNil".}
+    type
+      NilableObject = ref object
+        a: int
+      Object = NilableObject not nil
+      RequiresInit[T] = object
+        a {.requiresInit.}: T
+
+    assert hasDefaultValue(NilableObject)
+    assert not hasDefaultValue(Object)
+    assert hasDefaultValue(string)
+    assert not hasDefaultValue(var string)
+    assert not hasDefaultValue(RequiresInit[int])
+
+proc isNamedTuple*(T: typedesc): bool {.magic: "TypeTrait".} =
+  ## Returns true for named tuples, false for any other type.
+  runnableExamples:
+    doAssert not isNamedTuple(int)
+    doAssert not isNamedTuple((string, int))
+    doAssert isNamedTuple(tuple[name: string, age: int])
+
+template pointerBase*[T](_: typedesc[ptr T | ref T]): typedesc =
+  ## Returns `T` for `ref T | ptr T`.
+  runnableExamples:
+    assert (ref int).pointerBase is int
+    type A = ptr seq[float]
+    assert A.pointerBase is seq[float]
+    assert (ref A).pointerBase is A # not seq[float]
+    assert (var s = "abc"; s[0].addr).typeof.pointerBase is char
+  T
+
+proc rangeBase*(T: typedesc[range]): typedesc {.magic: "TypeTrait".} =
+  ## Returns the base type for range types, or the type itself otherwise.
+  ##
+  ## **See also:**
+  ## * `rangeBase template <#rangeBase.t,T>`_
+  runnableExamples:
+    type MyRange = range[0..5]
+    type MyEnum = enum a, b, c
+    type MyEnumRange = range[b..c]
+    doAssert rangeBase(MyRange) is int
+    doAssert rangeBase(MyEnumRange) is MyEnum
+    doAssert rangeBase(range['a'..'z']) is char
+
+template rangeBase*[T: range](a: T): untyped =
+  ## Overload of `rangeBase <#rangeBase,typedesc,static[bool]>`_ for values.
+  runnableExamples:
+    type MyRange = range[0..5]
+    type MyEnum = enum a, b, c
+    type MyEnumRange = range[b..c]
+    let x = MyRange(3)
+    doAssert rangeBase(x) is int
+    doAssert $typeof(rangeBase(x)) == "int"
+    doAssert rangeBase(x) == 3
+    let y: set[MyEnumRange] = {c}
+    for e in y:
+      doAssert rangeBase(e) is MyEnum
+      doAssert $typeof(rangeBase(e)) == "MyEnum"
+      doAssert rangeBase(e) == c
+    let z: seq[range['a'..'z']] = @['c']
+    doAssert rangeBase(z[0]) is char
+    doAssert $typeof(rangeBase(z[0])) == "char"
+    doAssert rangeBase(z[0]) == 'c'
+  rangeBase(typeof(T))(a)
+
+proc distinctBase*(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".} =
+  ## Returns the base type for distinct types, or the type itself otherwise.
+  ## If `recursive` is false, only the immediate distinct base will be returned.
+  ##
+  ## **See also:**
+  ## * `distinctBase template <#distinctBase.t,T,static[bool]>`_
+  runnableExamples:
+    type MyInt = distinct int
+    type MyOtherInt = distinct MyInt
+    doAssert distinctBase(MyInt) is int
+    doAssert distinctBase(MyOtherInt) is int
+    doAssert distinctBase(MyOtherInt, false) is MyInt
+    doAssert distinctBase(int) is int
+
+since (1, 1):
+  template distinctBase*[T](a: T, recursive: static bool = true): untyped =
+    ## Overload of `distinctBase <#distinctBase,typedesc,static[bool]>`_ for values.
+    runnableExamples:
+      type MyInt = distinct int
+      type MyOtherInt = distinct MyInt
+      doAssert 12.MyInt.distinctBase == 12
+      doAssert 12.MyOtherInt.distinctBase == 12
+      doAssert 12.MyOtherInt.distinctBase(false) is MyInt
+      doAssert 12.distinctBase == 12
+    when T is distinct:
+      distinctBase(typeof(a), recursive)(a)
+    else: # avoids hint ConvFromXtoItselfNotNeeded
+      a
+
+  proc tupleLen*(T: typedesc[tuple]): int {.magic: "TypeTrait".} =
+    ## Returns the number of elements of the tuple type `T`.
+    ##
+    ## **See also:**
+    ## * `tupleLen template <#tupleLen.t>`_
+    runnableExamples:
+      doAssert tupleLen((int, int, float, string)) == 4
+      doAssert tupleLen(tuple[name: string, age: int]) == 2
+
+  template tupleLen*(t: tuple): int =
+    ## Returns the number of elements of the tuple `t`.
+    ##
+    ## **See also:**
+    ## * `tupleLen proc <#tupleLen,typedesc>`_
+    runnableExamples:
+      doAssert tupleLen((1, 2)) == 2
+
+    tupleLen(typeof(t))
+
+  template get*(T: typedesc[tuple], i: static int): untyped =
+    ## Returns the `i`-th element of `T`.
+    # Note: `[]` currently gives: `Error: no generic parameters allowed for ...`
+    runnableExamples:
+      doAssert get((int, int, float, string), 2) is float
+
+    typeof(default(T)[i])
+
+  type StaticParam*[value: static type] = object
+    ## Used to wrap a static value in `genericParams <#genericParams.t,typedesc>`_.
+
+since (1, 3, 5):
+  template elementType*(a: untyped): typedesc =
+    ## Returns the element type of `a`, which can be any iterable (over which you
+    ## can iterate).
+    runnableExamples:
+      iterator myiter(n: int): auto =
+        for i in 0 ..< n:
+          yield i
+
+      doAssert elementType(@[1,2]) is int
+      doAssert elementType("asdf") is char
+      doAssert elementType(myiter(3)) is int
+
+    typeof(block: (for ai in a: ai))
+
+import std/macros
+
+macro enumLen*(T: typedesc[enum]): int =
+  ## Returns the number of items in the enum `T`.
+  runnableExamples:
+    type Foo = enum
+      fooItem1
+      fooItem2
+
+    doAssert Foo.enumLen == 2
+
+  let bracketExpr = getType(T)
+  expectKind(bracketExpr, nnkBracketExpr)
+  let enumTy = bracketExpr[1]
+  expectKind(enumTy, nnkEnumTy)
+  result = newLit(enumTy.len - 1)
+
+macro genericParamsImpl(T: typedesc): untyped =
+  # auxiliary macro needed, can't do it directly in `genericParams`
+  result = newNimNode(nnkTupleConstr)
+  var impl = getTypeImpl(T)
+  expectKind(impl, nnkBracketExpr)
+  impl = impl[1]
+  while true:
+    case impl.kind
+    of nnkSym:
+      impl = impl.getImpl
+    of nnkTypeDef:
+      impl = impl[2]
+    of nnkTypeOfExpr:
+      impl = getTypeInst(impl[0])
+    of nnkBracketExpr:
+      for i in 1..<impl.len:
+        let ai = impl[i]
+        var ret: NimNode = nil
+        case ai.typeKind
+        of ntyTypeDesc:
+          ret = ai
+        of ntyStatic: raiseAssert "unreachable"
+        else:
+          # getType from a resolved symbol might return a typedesc symbol.
+          # If so, use it directly instead of wrapping it in StaticParam.
+          if (ai.kind == nnkSym and ai.symKind == nskType) or
+              (ai.kind == nnkBracketExpr and ai[0].kind == nnkSym and
+              ai[0].symKind == nskType) or ai.kind in {nnkRefTy, nnkVarTy, nnkPtrTy, nnkProcTy}:
+            ret = ai
+          elif ai.kind == nnkInfix and ai[0].kind == nnkIdent and
+                ai[0].strVal == "..":
+            # For built-in array types, the "2" is translated to "0..1" then
+            # automagically translated to "range[0..1]". However this is not
+            # reflected in the AST, thus requiring manual transformation here.
+            #
+            # We will also be losing some context here:
+            #   var a: array[10, int]
+            # will be translated to:
+            #   var a: array[0..9, int]
+            # after typecheck. This means that we can't get the exact
+            # definition as typed by the user, which will cause confusion for
+            # users expecting:
+            #   genericParams(typeof(a)) is (StaticParam(10), int)
+            # to be true while in fact the result will be:
+            #   genericParams(typeof(a)) is (range[0..9], int)
+            ret = newTree(nnkBracketExpr, @[bindSym"range", ai])
+          else:
+            since (1, 1):
+              ret = newTree(nnkBracketExpr, @[bindSym"StaticParam", ai])
+        result.add ret
+      break
+    else:
+      error "wrong kind: " & $impl.kind, impl
+
+since (1, 1):
+  template genericParams*(T: typedesc): untyped =
+    ## Returns the tuple of generic parameters for the generic type `T`.
+    ##
+    ## **Note:** For the builtin array type, the index generic parameter will
+    ## **always** become a range type after it's bound to a variable.
+    runnableExamples:
+      type Foo[T1, T2] = object
+
+      doAssert genericParams(Foo[float, string]) is (float, string)
+
+      type Bar[N: static float, T] = object
+
+      doAssert genericParams(Bar[1.0, string]) is (StaticParam[1.0], string)
+      doAssert genericParams(Bar[1.0, string]).get(0).value == 1.0
+      doAssert genericParams(seq[Bar[2.0, string]]).get(0) is Bar[2.0, string]
+      var s: seq[Bar[3.0, string]]
+      doAssert genericParams(typeof(s)) is (Bar[3.0, string],)
+
+      doAssert genericParams(array[10, int]) is (StaticParam[10], int)
+      var a: array[10, int]
+      doAssert genericParams(typeof(a)) is (range[0..9], int)
+
+    type T2 = T
+    genericParamsImpl(T2)
+
+
+proc hasClosureImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
+
+proc hasClosure*(fn: NimNode): bool {.since: (1, 5, 1).} =
+  ## Returns true if the func/proc/etc `fn` has `closure`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = hasClosureImpl(fn)
+
+template toUnsigned*(T: typedesc[SomeInteger and not range]): untyped =
+  ## Returns an unsigned type with same bit size as `T`.
+  runnableExamples:
+    assert int8.toUnsigned is uint8
+    assert uint.toUnsigned is uint
+    assert int.toUnsigned is uint
+    # range types are currently unsupported:
+    assert not compiles(toUnsigned(range[0..7]))
+  when T is int8: uint8
+  elif T is int16: uint16
+  elif T is int32: uint32
+  elif T is int64: uint64
+  elif T is int: uint
+  else: T
+
+template toSigned*(T: typedesc[SomeInteger and not range]): untyped =
+  ## Returns a signed type with same bit size as `T`.
+  runnableExamples:
+    assert int8.toSigned is int8
+    assert uint16.toSigned is int16
+    # range types are currently unsupported:
+    assert not compiles(toSigned(range[0..7]))
+  when T is uint8: int8
+  elif T is uint16: int16
+  elif T is uint32: int32
+  elif T is uint64: int64
+  elif T is uint: int
+  else: T
diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim
index 099509afe..8cbe117bb 100755..100644
--- a/lib/pure/unicode.nim
+++ b/lib/pure/unicode.nim
@@ -1,1067 +1,473 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module provides support to handle the Unicode UTF-8 encoding.
+##
+## There are no specialized ``insert``, ``delete``, ``add`` and ``contains``
+## procedures for ``seq[Rune]`` in this module because the generic variants
+## of these procedures in the system module already work with it.
+##
+## The current version is compatible with Unicode v12.0.0.
+##
+## **See also:**
+## * `strutils module <strutils.html>`_
+## * `unidecode module <unidecode.html>`_
+## * `encodings module <encodings.html>`_
 
-{.deadCodeElim: on.}
+include "system/inclrtl"
+import std/strbasics
+template toOa(s: string): auto = s.toOpenArray(0, s.high)
+
+proc substr(s: openArray[char] , first, last: int): string =
+  # Copied substr from system
+  let first = max(first, 0)
+  let L = max(min(last, high(s)) - first + 1, 0)
+  result = newString(L)
+  for i in 0 .. L-1:
+    result[i] = s[i+first]
 
 type
-  irune = int # underlying type of TRune
-  TRune* = distinct irune   ## type that can hold any Unicode character
-  TRune16* = distinct int16 ## 16 bit Unicode character
-  
-proc `<=%`*(a, b: TRune): bool {.borrow.}
-proc `<%`*(a, b: TRune): bool {.borrow.}
-proc `==`*(a, b: TRune): bool {.borrow.}
-
-template ones(n: expr): expr = ((1 shl n)-1)
-
-proc runeLen*(s: string): int =
-  ## returns the number of Unicode characters of the string `s`.
+  RuneImpl = int32 # underlying type of Rune
+  Rune* = distinct RuneImpl ## \
+    ## Type that can hold a single Unicode code point.
+    ##
+    ## A Rune may be composed with other Runes to a character on the screen.
+    ## `RuneImpl` is the underlying type used to store Runes, currently `int32`.
+
+template ones(n: untyped): untyped = ((1 shl n)-1)
+
+proc runeLen*(s: openArray[char]): int {.rtl, extern: "nuc$1".} =
+  ## Returns the number of runes of the string ``s``.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeLen == 6
+    ## note: a.len == 8
+
+  result = 0
   var i = 0
   while i < len(s):
-    if ord(s[i]) <=% 127: inc(i)
-    elif ord(s[i]) shr 5 == 0b110: inc(i, 2)
-    elif ord(s[i]) shr 4 == 0b1110: inc(i, 3)
-    elif ord(s[i]) shr 3 == 0b11110: inc(i, 4)
-    else: assert(false)
+    if uint(s[i]) <= 127: inc(i)
+    elif uint(s[i]) shr 5 == 0b110: inc(i, 2)
+    elif uint(s[i]) shr 4 == 0b1110: inc(i, 3)
+    elif uint(s[i]) shr 3 == 0b11110: inc(i, 4)
+    elif uint(s[i]) shr 2 == 0b111110: inc(i, 5)
+    elif uint(s[i]) shr 1 == 0b1111110: inc(i, 6)
+    else: inc i
     inc(result)
 
-proc runeLenAt*(s: string, i: int): int =
-  ## returns the number of bytes the rune starting at ``s[i]`` takes.
-  if ord(s[i]) <=% 127: result = 1
-  elif ord(s[i]) shr 5 == 0b110: result = 2
-  elif ord(s[i]) shr 4 == 0b1110: result = 3
-  elif ord(s[i]) shr 3 == 0b11110: result = 4
-  else: assert(false)
-
-template fastRuneAt*(s: string, i: int, result: expr, doInc = true) =
-  ## Returns the unicode character ``s[i]`` in `result`. If ``doInc == true``
-  ## `i` is incremented by the number of bytes that have been processed.
-  if ord(s[i]) <=% 127:
-    result = TRune(ord(s[i]))
+proc runeLenAt*(s: openArray[char], i: Natural): int =
+  ## Returns the number of bytes the rune starting at ``s[i]`` takes.
+  ##
+  ## See also:
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeLenAt(0) == 1
+    doAssert a.runeLenAt(1) == 2
+
+  if uint(s[i]) <= 127: result = 1
+  elif uint(s[i]) shr 5 == 0b110: result = 2
+  elif uint(s[i]) shr 4 == 0b1110: result = 3
+  elif uint(s[i]) shr 3 == 0b11110: result = 4
+  elif uint(s[i]) shr 2 == 0b111110: result = 5
+  elif uint(s[i]) shr 1 == 0b1111110: result = 6
+  else: result = 1
+
+const replRune = Rune(0xFFFD)
+
+template fastRuneAt*(s: openArray[char] or string, i: int, result: untyped, doInc = true) =
+  ## Returns the rune ``s[i]`` in ``result``.
+  ##
+  ## If ``doInc == true`` (default), ``i`` is incremented by the number
+  ## of bytes that have been processed.
+  bind ones
+  if uint(s[i]) <= 127:
+    result = Rune(uint(s[i]))
     when doInc: inc(i)
-  elif ord(s[i]) shr 5 == 0b110:
-    assert(ord(s[i+1]) shr 6 == 0b10)
-    result = TRune((ord(s[i]) and (bind ones(5))) shl 6 or 
-                   (ord(s[i+1]) and ones(6)))
-    when doInc: inc(i, 2)
-  elif ord(s[i]) shr 4 == 0b1110:
-    assert(ord(s[i+1]) shr 6 == 0b10)
-    assert(ord(s[i+2]) shr 6 == 0b10)
-    result = TRune((ord(s[i]) and ones(4)) shl 12 or
-             (ord(s[i+1]) and ones(6)) shl 6 or
-             (ord(s[i+2]) and ones(6)))
-    when doInc: inc(i, 3)
-  elif ord(s[i]) shr 3 == 0b11110:
-    assert(ord(s[i+1]) shr 6 == 0b10)
-    assert(ord(s[i+2]) shr 6 == 0b10)
-    assert(ord(s[i+3]) shr 6 == 0b10)
-    result = TRune((ord(s[i]) and ones(3)) shl 18 or
-             (ord(s[i+1]) and ones(6)) shl 12 or
-             (ord(s[i+2]) and ones(6)) shl 6 or
-             (ord(s[i+3]) and ones(6)))
-    when doInc: inc(i, 4)
+  elif uint(s[i]) shr 5 == 0b110:
+    # assert(uint(s[i+1]) shr 6 == 0b10)
+    if i <= s.len - 2:
+      result = Rune((uint(s[i]) and (ones(5))) shl 6 or
+                    (uint(s[i+1]) and ones(6)))
+      when doInc: inc(i, 2)
+    else:
+      result = replRune
+      when doInc: inc(i)
+  elif uint(s[i]) shr 4 == 0b1110:
+    # assert(uint(s[i+1]) shr 6 == 0b10)
+    # assert(uint(s[i+2]) shr 6 == 0b10)
+    if i <= s.len - 3:
+      result = Rune((uint(s[i]) and ones(4)) shl 12 or
+                    (uint(s[i+1]) and ones(6)) shl 6 or
+                    (uint(s[i+2]) and ones(6)))
+      when doInc: inc(i, 3)
+    else:
+      result = replRune
+      when doInc: inc(i)
+  elif uint(s[i]) shr 3 == 0b11110:
+    # assert(uint(s[i+1]) shr 6 == 0b10)
+    # assert(uint(s[i+2]) shr 6 == 0b10)
+    # assert(uint(s[i+3]) shr 6 == 0b10)
+    if i <= s.len - 4:
+      result = Rune((uint(s[i]) and ones(3)) shl 18 or
+                    (uint(s[i+1]) and ones(6)) shl 12 or
+                    (uint(s[i+2]) and ones(6)) shl 6 or
+                    (uint(s[i+3]) and ones(6)))
+      when doInc: inc(i, 4)
+    else:
+      result = replRune
+      when doInc: inc(i)
+  elif uint(s[i]) shr 2 == 0b111110:
+    # assert(uint(s[i+1]) shr 6 == 0b10)
+    # assert(uint(s[i+2]) shr 6 == 0b10)
+    # assert(uint(s[i+3]) shr 6 == 0b10)
+    # assert(uint(s[i+4]) shr 6 == 0b10)
+    if i <= s.len - 5:
+      result = Rune((uint(s[i]) and ones(2)) shl 24 or
+                (uint(s[i+1]) and ones(6)) shl 18 or
+                (uint(s[i+2]) and ones(6)) shl 12 or
+                (uint(s[i+3]) and ones(6)) shl 6 or
+                (uint(s[i+4]) and ones(6)))
+      when doInc: inc(i, 5)
+    else:
+      result = replRune
+      when doInc: inc(i)
+  elif uint(s[i]) shr 1 == 0b1111110:
+    # assert(uint(s[i+1]) shr 6 == 0b10)
+    # assert(uint(s[i+2]) shr 6 == 0b10)
+    # assert(uint(s[i+3]) shr 6 == 0b10)
+    # assert(uint(s[i+4]) shr 6 == 0b10)
+    # assert(uint(s[i+5]) shr 6 == 0b10)
+    if i <= s.len - 6:
+      result = Rune((uint(s[i]) and ones(1)) shl 30 or
+                    (uint(s[i+1]) and ones(6)) shl 24 or
+                    (uint(s[i+2]) and ones(6)) shl 18 or
+                    (uint(s[i+3]) and ones(6)) shl 12 or
+                    (uint(s[i+4]) and ones(6)) shl 6 or
+                    (uint(s[i+5]) and ones(6)))
+      when doInc: inc(i, 6)
+    else:
+      result = replRune
+      when doInc: inc(i)
   else:
-    assert(false)
+    result = Rune(uint(s[i]))
+    when doInc: inc(i)
 
-proc runeAt*(s: string, i: int): TRune =
-  ## returns the unicode character in `s` at byte index `i`
+proc runeAt*(s: openArray[char], i: Natural): Rune =
+  ## Returns the rune in ``s`` at **byte index** ``i``.
+  ##
+  ## See also:
+  ## * `runeAtPos proc <#runeAtPos,string,int>`_
+  ## * `runeStrAtPos proc <#runeStrAtPos,string,Natural>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeAt(1) == "ñ".runeAt(0)
+    doAssert a.runeAt(2) == "ñ".runeAt(1)
+    doAssert a.runeAt(3) == "y".runeAt(0)
   fastRuneAt(s, i, result, false)
 
-proc toUTF8*(c: TRune): string = 
-  ## converts a rune into its UTF8 representation
-  var i = irune(c)
+proc validateUtf8*(s: openArray[char]): int =
+  ## Returns the position of the invalid byte in ``s`` if the string ``s`` does
+  ## not hold valid UTF-8 data. Otherwise ``-1`` is returned.
+  ##
+  ## See also:
+  ## * `toUTF8 proc <#toUTF8,Rune>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  var i = 0
+  let L = s.len
+  while i < L:
+    if uint(s[i]) <= 127:
+      inc(i)
+    elif uint(s[i]) shr 5 == 0b110:
+      if uint(s[i]) < 0xc2: return i # Catch overlong ascii representations.
+      if i+1 < L and uint(s[i+1]) shr 6 == 0b10: inc(i, 2)
+      else: return i
+    elif uint(s[i]) shr 4 == 0b1110:
+      if i+2 < L and uint(s[i+1]) shr 6 == 0b10 and uint(s[i+2]) shr 6 == 0b10:
+        inc i, 3
+      else: return i
+    elif uint(s[i]) shr 3 == 0b11110:
+      if i+3 < L and uint(s[i+1]) shr 6 == 0b10 and
+                     uint(s[i+2]) shr 6 == 0b10 and
+                     uint(s[i+3]) shr 6 == 0b10:
+        inc i, 4
+      else: return i
+    else:
+      return i
+  return -1
+
+template fastToUTF8Copy*(c: Rune, s: var string, pos: int, doInc = true) =
+  ## Copies UTF-8 representation of ``c`` into the preallocated string ``s``
+  ## starting at position ``pos``.
+  ##
+  ## If ``doInc == true`` (default), ``pos`` is incremented
+  ## by the number of bytes that have been processed.
+  ##
+  ## To be the most efficient, make sure ``s`` is preallocated
+  ## with an additional amount equal to the byte length of ``c``.
+  ##
+  ## See also:
+  ## * `validateUtf8 proc <#validateUtf8,string>`_
+  ## * `toUTF8 proc <#toUTF8,Rune>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  var i = RuneImpl(c)
   if i <=% 127:
-    result = newString(1)
-    result[0] = chr(i)
+    s.setLen(pos+1)
+    s[pos+0] = chr(i)
+    when doInc: inc(pos)
   elif i <=% 0x07FF:
-    result = newString(2)
-    result[0] = chr((i shr 6) or 0b110_00000)
-    result[1] = chr((i and ones(6)) or 0b10_000000)
+    s.setLen(pos+2)
+    s[pos+0] = chr((i shr 6) or 0b110_00000)
+    s[pos+1] = chr((i and ones(6)) or 0b10_0000_00)
+    when doInc: inc(pos, 2)
   elif i <=% 0xFFFF:
-    result = newString(3)
-    result[0] = chr(i shr 12 or 0b1110_0000)
-    result[1] = chr(i shr 6 and ones(6) or 0b10_0000_00)
-    result[2] = chr(i and ones(6) or 0b10_0000_00)
-  elif i <=% 0x0010FFFF:
-    result = newString(4)
-    result[0] = chr(i shr 18 or 0b1111_0000)
-    result[1] = chr(i shr 12 and ones(6) or 0b10_0000_00)
-    result[2] = chr(i shr 6 and ones(6) or 0b10_0000_00)
-    result[3] = chr(i and ones(6) or 0b10_0000_00)
+    s.setLen(pos+3)
+    s[pos+0] = chr(i shr 12 or 0b1110_0000)
+    s[pos+1] = chr(i shr 6 and ones(6) or 0b10_0000_00)
+    s[pos+2] = chr(i and ones(6) or 0b10_0000_00)
+    when doInc: inc(pos, 3)
+  elif i <=% 0x001FFFFF:
+    s.setLen(pos+4)
+    s[pos+0] = chr(i shr 18 or 0b1111_0000)
+    s[pos+1] = chr(i shr 12 and ones(6) or 0b10_0000_00)
+    s[pos+2] = chr(i shr 6 and ones(6) or 0b10_0000_00)
+    s[pos+3] = chr(i and ones(6) or 0b10_0000_00)
+    when doInc: inc(pos, 4)
+  elif i <=% 0x03FFFFFF:
+    s.setLen(pos+5)
+    s[pos+0] = chr(i shr 24 or 0b111110_00)
+    s[pos+1] = chr(i shr 18 and ones(6) or 0b10_0000_00)
+    s[pos+2] = chr(i shr 12 and ones(6) or 0b10_0000_00)
+    s[pos+3] = chr(i shr 6 and ones(6) or 0b10_0000_00)
+    s[pos+4] = chr(i and ones(6) or 0b10_0000_00)
+    when doInc: inc(pos, 5)
+  elif i <=% 0x7FFFFFFF:
+    s.setLen(pos+6)
+    s[pos+0] = chr(i shr 30 or 0b1111110_0)
+    s[pos+1] = chr(i shr 24 and ones(6) or 0b10_0000_00)
+    s[pos+2] = chr(i shr 18 and ones(6) or 0b10_0000_00)
+    s[pos+3] = chr(i shr 12 and ones(6) or 0b10_0000_00)
+    s[pos+4] = chr(i shr 6 and ones(6) or 0b10_0000_00)
+    s[pos+5] = chr(i and ones(6) or 0b10_0000_00)
+    when doInc: inc(pos, 6)
+  else:
+    discard # error, exception?
+
+proc toUTF8*(c: Rune): string {.rtl, extern: "nuc$1".} =
+  ## Converts a rune into its UTF-8 representation.
+  ##
+  ## See also:
+  ## * `validateUtf8 proc <#validateUtf8,string>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  ## * `utf8 iterator <#utf8.i,string>`_
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeAt(1).toUTF8 == "ñ"
+
+  result = ""
+  fastToUTF8Copy(c, result, 0, false)
+
+proc add*(s: var string; c: Rune) =
+  ## Adds a rune ``c`` to a string ``s``.
+  runnableExamples:
+    var s = "abc"
+    let c = "ä".runeAt(0)
+    s.add(c)
+    doAssert s == "abcä"
+
+  let pos = s.len
+  fastToUTF8Copy(c, s, pos, false)
+
+proc `$`*(rune: Rune): string =
+  ## An alias for `toUTF8 <#toUTF8,Rune>`_.
+  ##
+  ## See also:
+  ## * `validateUtf8 proc <#validateUtf8,string>`_
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  rune.toUTF8
+
+proc `$`*(runes: seq[Rune]): string =
+  ## Converts a sequence of Runes to a string.
+  ##
+  ## See also:
+  ## * `toRunes <#toRunes,string>`_ for a reverse operation
+  runnableExamples:
+    let
+      someString = "öÑ"
+      someRunes = toRunes(someString)
+    doAssert $someRunes == someString
+
+  result = ""
+  for rune in runes:
+    result.add rune
+
+proc runeOffset*(s: openArray[char], pos: Natural, start: Natural = 0): int =
+  ## Returns the byte position of rune
+  ## at position ``pos`` in ``s`` with an optional start byte position.
+  ## Returns the special value -1 if it runs out of the string.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeReverseOffset proc <#runeReverseOffset,string,Positive>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeOffset(1) == 1
+    doAssert a.runeOffset(3) == 4
+    doAssert a.runeOffset(4) == 6
+
+  var
+    i = 0
+    o = start
+  while i < pos:
+    o += runeLenAt(s, o)
+    if o >= s.len:
+      return -1
+    inc i
+  return o
+
+proc runeReverseOffset*(s: openArray[char], rev: Positive): (int, int) =
+  ## Returns a tuple with the byte offset of the
+  ## rune at position ``rev`` in ``s``, counting
+  ## from the end (starting with 1) and the total
+  ## number of runes in the string.
+  ##
+  ## Returns a negative value for offset if there are too few runes in
+  ## the string to satisfy the request.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeOffset proc <#runeOffset,string,Natural,Natural>`_
+  var
+    a = rev.int
+    o = 0
+    x = 0
+  let times = 2*rev.int-s.runeLen # transformed from rev.int - a < s.runeLen - rev.int
+  while o < s.len:
+    let r = runeLenAt(s, o)
+    o += r
+    if a > times:
+      x += r
+    dec a
+  result = if a > 0: (-a, rev.int-a) else: (x, -a+rev.int)
+
+proc runeAtPos*(s: openArray[char], pos: int): Rune =
+  ## Returns the rune at position ``pos``.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeAt proc <#runeAt,string,Natural>`_
+  ## * `runeStrAtPos proc <#runeStrAtPos,string,Natural>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  fastRuneAt(s, runeOffset(s, pos), result, false)
+
+proc runeStrAtPos*(s: openArray[char], pos: Natural): string =
+  ## Returns the rune at position ``pos`` as UTF8 String.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeAt proc <#runeAt,string,Natural>`_
+  ## * `runeAtPos proc <#runeAtPos,string,int>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  let o = runeOffset(s, pos)
+  substr(s.toOpenArray(o,  (o+runeLenAt(s, o)-1)))
+
+proc runeSubStr*(s: openArray[char], pos: int, len: int = int.high): string =
+  ## Returns the UTF-8 substring starting at code point ``pos``
+  ## with ``len`` code points.
+  ##
+  ## If ``pos`` or ``len`` is negative they count from
+  ## the end of the string. If ``len`` is not given it means the longest
+  ## possible string.
+  runnableExamples:
+    let s = "Hänsel  ««: 10,00€"
+    doAssert(runeSubStr(s, 0, 2) == "Hä")
+    doAssert(runeSubStr(s, 10, 1) == ":")
+    doAssert(runeSubStr(s, -6) == "10,00€")
+    doAssert(runeSubStr(s, 10) == ": 10,00€")
+    doAssert(runeSubStr(s, 12, 5) == "10,00")
+    doAssert(runeSubStr(s, -6, 3) == "10,")
+
+  if pos < 0:
+    let (o, rl) = runeReverseOffset(s, -pos)
+    if len >= rl:
+      result = s.substr(o, s.high)
+    elif len < 0:
+      let e = rl + len
+      if e < 0:
+        result = ""
+      else:
+        result = s.substr(o, runeOffset(s, e-(rl+pos), o)-1)
+    else:
+      result = s.substr(o, runeOffset(s, len, o)-1)
   else:
-    assert false
-
-const
-  alphaRanges = [
-    0x00d8,  0x00f6,  # Ø - ö
-    0x00f8,  0x01f5,  # ø - ǵ   
-    0x0250,  0x02a8,  # É - ʨ   
-    0x038e,  0x03a1,  # Ύ - Ρ   
-    0x03a3,  0x03ce,  # Σ - ώ   
-    0x03d0,  0x03d6,  # Ï - Ï–   
-    0x03e2,  0x03f3,  # Ϣ - ϳ   
-    0x0490,  0x04c4,  # Ò - Ó„   
-    0x0561,  0x0587,  # Õ¡ - Ö‡   
-    0x05d0,  0x05ea,  # × - ת   
-    0x05f0,  0x05f2,  # װ - ײ   
-    0x0621,  0x063a,  # ء - غ   
-    0x0640,  0x064a,  # Ù€ - ÙŠ   
-    0x0671,  0x06b7,  # Ù± - Ú·   
-    0x06ba,  0x06be,  # Úº - Ú¾   
-    0x06c0,  0x06ce,  # Û€ - ÛŽ   
-    0x06d0,  0x06d3,  # Û - Û“   
-    0x0905,  0x0939,  # अ - ह   
-    0x0958,  0x0961,  # क़ - ॡ   
-    0x0985,  0x098c,  # অ - ঌ   
-    0x098f,  0x0990,  # ঠ- ঠ  
-    0x0993,  0x09a8,  # ও - ন   
-    0x09aa,  0x09b0,  # প - র   
-    0x09b6,  0x09b9,  # শ - হ   
-    0x09dc,  0x09dd,  # ড় - ৠ  
-    0x09df,  0x09e1,  # à§Ÿ - à§¡   
-    0x09f0,  0x09f1,  # à§° - à§±   
-    0x0a05,  0x0a0a,  # ਅ - ਊ   
-    0x0a0f,  0x0a10,  # ਠ- ਠ  
-    0x0a13,  0x0a28,  # ਓ - ਨ   
-    0x0a2a,  0x0a30,  # ਪ - ਰ   
-    0x0a32,  0x0a33,  # ਲ - ਲ਼   
-    0x0a35,  0x0a36,  # ਵ - ਸ਼   
-    0x0a38,  0x0a39,  # ਸ - ਹ   
-    0x0a59,  0x0a5c,  # ਖ਼ - ੜ   
-    0x0a85,  0x0a8b,  # અ - ઋ   
-    0x0a8f,  0x0a91,  # ઠ- ઑ   
-    0x0a93,  0x0aa8,  # ઓ - ન   
-    0x0aaa,  0x0ab0,  # પ - ર   
-    0x0ab2,  0x0ab3,  # લ - ળ   
-    0x0ab5,  0x0ab9,  # વ - હ   
-    0x0b05,  0x0b0c,  # ଅ - ଌ   
-    0x0b0f,  0x0b10,  # ଠ- ଠ  
-    0x0b13,  0x0b28,  # ଓ - ନ   
-    0x0b2a,  0x0b30,  # ପ - ର   
-    0x0b32,  0x0b33,  # ଲ - ଳ   
-    0x0b36,  0x0b39,  # ଶ - ହ   
-    0x0b5c,  0x0b5d,  # ଡ଼ - ୠ  
-    0x0b5f,  0x0b61,  # à­Ÿ - à­¡   
-    0x0b85,  0x0b8a,  # அ - ஊ   
-    0x0b8e,  0x0b90,  # எ - ஠  
-    0x0b92,  0x0b95,  # ஒ - க   
-    0x0b99,  0x0b9a,  # ங - ச   
-    0x0b9e,  0x0b9f,  # ஞ - ட   
-    0x0ba3,  0x0ba4,  # ண - த   
-    0x0ba8,  0x0baa,  # ந - ப   
-    0x0bae,  0x0bb5,  # ம - வ   
-    0x0bb7,  0x0bb9,  # ஷ - ஹ   
-    0x0c05,  0x0c0c,  # అ - ఌ   
-    0x0c0e,  0x0c10,  # à°Ž - à°   
-    0x0c12,  0x0c28,  # à°’ - à°¨   
-    0x0c2a,  0x0c33,  # à°ª - à°³   
-    0x0c35,  0x0c39,  # à°µ - à°¹   
-    0x0c60,  0x0c61,  # ౠ - ౡ   
-    0x0c85,  0x0c8c,  # ಅ - ಌ   
-    0x0c8e,  0x0c90,  # ಎ - ಠ  
-    0x0c92,  0x0ca8,  # ಒ - ನ   
-    0x0caa,  0x0cb3,  # ಪ - ಳ   
-    0x0cb5,  0x0cb9,  # ವ - ಹ   
-    0x0ce0,  0x0ce1,  # ೠ - ೡ   
-    0x0d05,  0x0d0c,  # അ - ഌ   
-    0x0d0e,  0x0d10,  # à´Ž - à´   
-    0x0d12,  0x0d28,  # à´’ - à´¨   
-    0x0d2a,  0x0d39,  # à´ª - à´¹   
-    0x0d60,  0x0d61,  # ൠ - ൡ   
-    0x0e01,  0x0e30,  # ภ- ะ   
-    0x0e32,  0x0e33,  # า - ำ   
-    0x0e40,  0x0e46,  # เ - ๆ   
-    0x0e5a,  0x0e5b,  # ๚ - ๛   
-    0x0e81,  0x0e82,  # ຠ- ຂ   
-    0x0e87,  0x0e88,  # ງ - ຈ   
-    0x0e94,  0x0e97,  # ດ - ທ   
-    0x0e99,  0x0e9f,  # ນ - ຟ   
-    0x0ea1,  0x0ea3,  # ມ - ຣ   
-    0x0eaa,  0x0eab,  # ສ - ຫ   
-    0x0ead,  0x0eae,  # ອ - ຮ   
-    0x0eb2,  0x0eb3,  # າ - ຳ   
-    0x0ec0,  0x0ec4,  # ເ - ໄ   
-    0x0edc,  0x0edd,  # ໜ - ໠  
-    0x0f18,  0x0f19,  # ༘ - ༙   
-    0x0f40,  0x0f47,  # ཀ - ཇ   
-    0x0f49,  0x0f69,  # ཉ - ཀྵ   
-    0x10d0,  0x10f6,  # რ- ჶ   
-    0x1100,  0x1159,  # á„€ - á…™   
-    0x115f,  0x11a2,  # ᅟ - ᆢ   
-    0x11a8,  0x11f9,  # ᆨ - ᇹ   
-    0x1e00,  0x1e9b,  # Ḁ - ẛ   
-    0x1f50,  0x1f57,  # á½ - á½—   
-    0x1f80,  0x1fb4,  # á¾€ - á¾´   
-    0x1fb6,  0x1fbc,  # á¾¶ - á¾¼   
-    0x1fc2,  0x1fc4,  # á¿‚ - á¿„   
-    0x1fc6,  0x1fcc,  # ῆ - ῌ   
-    0x1fd0,  0x1fd3,  # á¿ - á¿“   
-    0x1fd6,  0x1fdb,  # á¿– - á¿›   
-    0x1fe0,  0x1fec,  # ῠ - Ῥ   
-    0x1ff2,  0x1ff4,  # ῲ - ῴ   
-    0x1ff6,  0x1ffc,  # ῶ - ῼ   
-    0x210a,  0x2113,  # ℊ - ℓ   
-    0x2115,  0x211d,  # â„• - â„   
-    0x2120,  0x2122,  # â„  - â„¢   
-    0x212a,  0x2131,  # K - ℱ   
-    0x2133,  0x2138,  # ℳ - ℸ   
-    0x3041,  0x3094,  # ã - ã‚”   
-    0x30a1,  0x30fa,  # ァ - ヺ   
-    0x3105,  0x312c,  # ㄅ - ㄬ   
-    0x3131,  0x318e,  # ㄱ - ㆎ   
-    0x3192,  0x319f,  # ㆒ - ㆟   
-    0x3260,  0x327b,  # ㉠ - ㉻   
-    0x328a,  0x32b0,  # ㊊ - ㊰   
-    0x32d0,  0x32fe,  # ㋠- ㋾   
-    0x3300,  0x3357,  # ㌀ - 㗠  
-    0x3371,  0x3376,  # ã± - ã¶   
-    0x337b,  0x3394,  # 㻠- ㎔   
-    0x3399,  0x339e,  # ㎙ - ㎞   
-    0x33a9,  0x33ad,  # ㎩ - ㎭   
-    0x33b0,  0x33c1,  # ㎰ - ã   
-    0x33c3,  0x33c5,  # ム- ã…   
-    0x33c7,  0x33d7,  # ㇠- 㗠  
-    0x33d9,  0x33dd,  # ã™ - ã   
-    0x4e00,  0x9fff,  # 一 - 鿿   
-    0xac00,  0xd7a3,  # 가 - 힣   
-    0xf900,  0xfb06,  # 豈 - st   
-    0xfb13,  0xfb17,  # ﬓ - ﬗ   
-    0xfb1f,  0xfb28,  # ײַ - ﬨ   
-    0xfb2a,  0xfb36,  # שׁ - זּ   
-    0xfb38,  0xfb3c,  # טּ - לּ   
-    0xfb40,  0xfb41,  # ï­€ - ï­   
-    0xfb43,  0xfb44,  # ï­ƒ - ï­„   
-    0xfb46,  0xfbb1,  # ï­† - ï®±   
-    0xfbd3,  0xfd3d,  # ﯓ - ﴽ   
-    0xfd50,  0xfd8f,  # ïµ - ï¶   
-    0xfd92,  0xfdc7,  # ï¶’ - ï·‡   
-    0xfdf0,  0xfdf9,  # ï·° - ï·¹   
-    0xfe70,  0xfe72,  # ï¹° - ï¹²   
-    0xfe76,  0xfefc,  # ﹶ - ﻼ   
-    0xff66,  0xff6f,  # ヲ - ッ   
-    0xff71,  0xff9d,  # ï½± - ï¾   
-    0xffa0,  0xffbe,  # ï¾  - ï¾¾   
-    0xffc2,  0xffc7,  # ᅡ - ᅦ   
-    0xffca,  0xffcf,  # ᅧ - ï¿   
-    0xffd2,  0xffd7,  # ï¿’ - ï¿—   
-    0xffda,  0xffdc]  # ᅳ - ᅵ   
-
-  alphaSinglets = [
-    0x00aa,  # ª   
-    0x00b5,  # µ   
-    0x00ba,  # º   
-    0x03da,  # Ïš   
-    0x03dc,  # Ϝ   
-    0x03de,  # Ïž   
-    0x03e0,  # Ï    
-    0x06d5,  # Û•   
-    0x09b2,  # ল   
-    0x0a5e,  # ਫ਼   
-    0x0a8d,  # ઠ  
-    0x0ae0,  # à«    
-    0x0b9c,  # ஜ   
-    0x0cde,  # ೞ   
-    0x0e4f,  # ๠  
-    0x0e84,  # ຄ   
-    0x0e8a,  # ຊ   
-    0x0e8d,  # ຠ  
-    0x0ea5,  # ລ   
-    0x0ea7,  # ວ   
-    0x0eb0,  # ະ   
-    0x0ebd,  # ຽ   
-    0x1fbe,  # á¾¾   
-    0x207f,  # â¿   
-    0x20a8,  # ₨   
-    0x2102,  # â„‚   
-    0x2107,  # ℇ   
-    0x2124,  # ℤ   
-    0x2126,  # Ω   
-    0x2128,  # ℨ   
-    0xfb3e,  # מּ   
-    0xfe74]  # ï¹´   
-
-  spaceRanges = [
-    0x0009,  0x000a,  # tab and newline   
-    0x0020,  0x0020,  # space   
-    0x00a0,  0x00a0,  #     
-    0x2000,  0x200b,  #   - ​   
-    0x2028,  0x2029,  #  - 
    0x3000,  0x3000,  #     
-    0xfeff,  0xfeff]  #    
-
-  toupperRanges = [
-    0x0061,  0x007a, 468,  # a-z A-Z   
-    0x00e0,  0x00f6, 468,  # à-ö À-Ö   
-    0x00f8,  0x00fe, 468,  # ø-þ Ø-Þ   
-    0x0256,  0x0257, 295,  # ɖ-ɗ Ɖ-Ɗ   
-    0x0258,  0x0259, 298,  # ɘ-É™ ÆŽ-Æ   
-    0x028a,  0x028b, 283,  # ʊ-ʋ Ʊ-Ʋ   
-    0x03ad,  0x03af, 463,  # έ-ί Έ-Ί   
-    0x03b1,  0x03c1, 468,  # α-Ï Î‘-Ρ   
-    0x03c3,  0x03cb, 468,  # σ-ϋ Σ-Ϋ   
-    0x03cd,  0x03ce, 437,  # Ï-ÏŽ ÎŽ-Î   
-    0x0430,  0x044f, 468,  # а-Ñ Ð-Я   
-    0x0451,  0x045c, 420,  # Ñ‘-Ñœ Ð-ÐŒ   
-    0x045e,  0x045f, 420,  # Ñž-ÑŸ ÐŽ-Ð   
-    0x0561,  0x0586, 452,  # Õ¡-Ö† Ô±-Õ–   
-    0x1f00,  0x1f07, 508,  # ἀ-ἇ Ἀ-ἠ  
-    0x1f10,  0x1f15, 508,  # á¼-ἕ Ἐ-á¼   
-    0x1f20,  0x1f27, 508,  # ἠ-ἧ Ἠ-Ἧ   
-    0x1f30,  0x1f37, 508,  # ἰ-ἷ Ἰ-Ἷ   
-    0x1f40,  0x1f45, 508,  # ὀ-ὅ Ὀ-ὠ  
-    0x1f60,  0x1f67, 508,  # ὠ-ὧ Ὠ-Ὧ   
-    0x1f70,  0x1f71, 574,  # ὰ-ά Ὰ-Ά   
-    0x1f72,  0x1f75, 586,  # ὲ-ή Ὲ-Ή   
-    0x1f76,  0x1f77, 600,  # ὶ-ί Ὶ-Ί   
-    0x1f78,  0x1f79, 628,  # ὸ-ό Ὸ-Ό   
-    0x1f7a,  0x1f7b, 612,  # ὺ-ύ Ὺ-Ύ   
-    0x1f7c,  0x1f7d, 626,  # ὼ-ώ Ὼ-Ώ   
-    0x1f80,  0x1f87, 508,  # ᾀ-ᾇ ᾈ-ᾠ  
-    0x1f90,  0x1f97, 508,  # á¾-á¾— ᾘ-ᾟ   
-    0x1fa0,  0x1fa7, 508,  # ᾠ-ᾧ ᾨ-ᾯ   
-    0x1fb0,  0x1fb1, 508,  # ᾰ-ᾱ Ᾰ-Ᾱ   
-    0x1fd0,  0x1fd1, 508,  # á¿-á¿‘ Ῐ-á¿™   
-    0x1fe0,  0x1fe1, 508,  # ῠ-ῡ Ῠ-Ῡ   
-    0x2170,  0x217f, 484,  # â…°-â…¿ â… -â…¯   
-    0x24d0,  0x24e9, 474,  # â“-â“© â’¶-â“   
-    0xff41,  0xff5a, 468]  # ï½-z A-Z   
-
-  toupperSinglets = [
-    0x00ff, 621,  # ÿ Ÿ   
-    0x0101, 499,  # Ä Ä€   
-    0x0103, 499,  # ă Ă   
-    0x0105, 499,  # Ä… Ä„   
-    0x0107, 499,  # ć Ć   
-    0x0109, 499,  # ĉ Ĉ   
-    0x010b, 499,  # Ä‹ ÄŠ   
-    0x010d, 499,  # Ä ÄŒ   
-    0x010f, 499,  # Ä ÄŽ   
-    0x0111, 499,  # Ä‘ Ä   
-    0x0113, 499,  # Ä“ Ä’   
-    0x0115, 499,  # Ä• Ä”   
-    0x0117, 499,  # Ä— Ä–   
-    0x0119, 499,  # ę Ę   
-    0x011b, 499,  # Ä› Äš   
-    0x011d, 499,  # Ä Äœ   
-    0x011f, 499,  # ÄŸ Äž   
-    0x0121, 499,  # Ä¡ Ä    
-    0x0123, 499,  # ģ Ģ   
-    0x0125, 499,  # ĥ Ĥ   
-    0x0127, 499,  # ħ Ħ   
-    0x0129, 499,  # ĩ Ĩ   
-    0x012b, 499,  # ī Ī   
-    0x012d, 499,  # ĭ Ĭ   
-    0x012f, 499,  # į Į   
-    0x0131, 268,  # ı I   
-    0x0133, 499,  # ij IJ   
-    0x0135, 499,  # ĵ Ĵ   
-    0x0137, 499,  # ķ Ķ   
-    0x013a, 499,  # ĺ Ĺ   
-    0x013c, 499,  # ļ Ļ   
-    0x013e, 499,  # ľ Ľ   
-    0x0140, 499,  # ŀ Ŀ   
-    0x0142, 499,  # Å‚ Å   
-    0x0144, 499,  # ń Ń   
-    0x0146, 499,  # ņ Ņ   
-    0x0148, 499,  # ň Ň   
-    0x014b, 499,  # Å‹ ÅŠ   
-    0x014d, 499,  # ŠŌ   
-    0x014f, 499,  # Å ÅŽ   
-    0x0151, 499,  # Å‘ Å   
-    0x0153, 499,  # Å“ Å’   
-    0x0155, 499,  # Å• Å”   
-    0x0157, 499,  # Å— Å–   
-    0x0159, 499,  # ř Ř   
-    0x015b, 499,  # Å› Åš   
-    0x015d, 499,  # ŠŜ   
-    0x015f, 499,  # ÅŸ Åž   
-    0x0161, 499,  # Å¡ Å    
-    0x0163, 499,  # ţ Ţ   
-    0x0165, 499,  # ť Ť   
-    0x0167, 499,  # ŧ Ŧ   
-    0x0169, 499,  # ũ Ũ   
-    0x016b, 499,  # ū Ū   
-    0x016d, 499,  # ŭ Ŭ   
-    0x016f, 499,  # ů Ů   
-    0x0171, 499,  # ű Ű   
-    0x0173, 499,  # ų Ų   
-    0x0175, 499,  # ŵ Ŵ   
-    0x0177, 499,  # ŷ Ŷ   
-    0x017a, 499,  # ź Ź   
-    0x017c, 499,  # ż Ż   
-    0x017e, 499,  # ž Ž   
-    0x017f, 200,  # Å¿ S   
-    0x0183, 499,  # ƃ Ƃ   
-    0x0185, 499,  # Æ… Æ„   
-    0x0188, 499,  # ƈ Ƈ   
-    0x018c, 499,  # ƌ Ƌ   
-    0x0192, 499,  # Æ’ Æ‘   
-    0x0199, 499,  # ƙ Ƙ   
-    0x01a1, 499,  # Æ¡ Æ    
-    0x01a3, 499,  # ƣ Ƣ   
-    0x01a5, 499,  # ƥ Ƥ   
-    0x01a8, 499,  # ƨ Ƨ   
-    0x01ad, 499,  # ƭ Ƭ   
-    0x01b0, 499,  # ư Ư   
-    0x01b4, 499,  # ƴ Ƴ   
-    0x01b6, 499,  # ƶ Ƶ   
-    0x01b9, 499,  # ƹ Ƹ   
-    0x01bd, 499,  # ƽ Ƽ   
-    0x01c5, 499,  # Ç… Ç„   
-    0x01c6, 498,  # dž DŽ   
-    0x01c8, 499,  # Lj LJ   
-    0x01c9, 498,  # lj LJ   
-    0x01cb, 499,  # Ç‹ ÇŠ   
-    0x01cc, 498,  # nj NJ   
-    0x01ce, 499,  # ÇŽ Ç   
-    0x01d0, 499,  # Ç Ç   
-    0x01d2, 499,  # Ç’ Ç‘   
-    0x01d4, 499,  # Ç” Ç“   
-    0x01d6, 499,  # Ç– Ç•   
-    0x01d8, 499,  # ǘ Ǘ   
-    0x01da, 499,  # Çš Ç™   
-    0x01dc, 499,  # ǜ Ǜ   
-    0x01df, 499,  # ÇŸ Çž   
-    0x01e1, 499,  # Ç¡ Ç    
-    0x01e3, 499,  # ǣ Ǣ   
-    0x01e5, 499,  # ǥ Ǥ   
-    0x01e7, 499,  # ǧ Ǧ   
-    0x01e9, 499,  # ǩ Ǩ   
-    0x01eb, 499,  # ǫ Ǫ   
-    0x01ed, 499,  # ǭ Ǭ   
-    0x01ef, 499,  # ǯ Ǯ   
-    0x01f2, 499,  # Dz DZ   
-    0x01f3, 498,  # dz DZ   
-    0x01f5, 499,  # ǵ Ǵ   
-    0x01fb, 499,  # ǻ Ǻ   
-    0x01fd, 499,  # ǽ Ǽ   
-    0x01ff, 499,  # ǿ Ǿ   
-    0x0201, 499,  # È È€   
-    0x0203, 499,  # ȃ Ȃ   
-    0x0205, 499,  # È… È„   
-    0x0207, 499,  # ȇ Ȇ   
-    0x0209, 499,  # ȉ Ȉ   
-    0x020b, 499,  # È‹ ÈŠ   
-    0x020d, 499,  # È ÈŒ   
-    0x020f, 499,  # È ÈŽ   
-    0x0211, 499,  # È‘ È   
-    0x0213, 499,  # È“ È’   
-    0x0215, 499,  # È• È”   
-    0x0217, 499,  # È— È–   
-    0x0253, 290,  # É“ Æ   
-    0x0254, 294,  # ɔ Ɔ   
-    0x025b, 297,  # É› Æ   
-    0x0260, 295,  # É  Æ“   
-    0x0263, 293,  # ɣ Ɣ   
-    0x0268, 291,  # ɨ Ɨ   
-    0x0269, 289,  # É© Æ–   
-    0x026f, 289,  # ɯ Ɯ   
-    0x0272, 287,  # ɲ Æ   
-    0x0283, 282,  # ʃ Ʃ   
-    0x0288, 282,  # ʈ Ʈ   
-    0x0292, 281,  # Ê’ Æ·   
-    0x03ac, 462,  # ά Ά   
-    0x03cc, 436,  # ό Ό   
-    0x03d0, 438,  # Ï Î’   
-    0x03d1, 443,  # ϑ Θ   
-    0x03d5, 453,  # ϕ Φ   
-    0x03d6, 446,  # ϖ Π   
-    0x03e3, 499,  # ϣ Ϣ   
-    0x03e5, 499,  # ϥ Ϥ   
-    0x03e7, 499,  # ϧ Ϧ   
-    0x03e9, 499,  # ϩ Ϩ   
-    0x03eb, 499,  # ϫ Ϫ   
-    0x03ed, 499,  # ϭ Ϭ   
-    0x03ef, 499,  # ϯ Ϯ   
-    0x03f0, 414,  # ϰ Κ   
-    0x03f1, 420,  # ϱ Ρ   
-    0x0461, 499,  # Ñ¡ Ñ    
-    0x0463, 499,  # ѣ Ѣ   
-    0x0465, 499,  # ѥ Ѥ   
-    0x0467, 499,  # ѧ Ѧ   
-    0x0469, 499,  # ѩ Ѩ   
-    0x046b, 499,  # ѫ Ѫ   
-    0x046d, 499,  # ѭ Ѭ   
-    0x046f, 499,  # ѯ Ѯ   
-    0x0471, 499,  # ѱ Ѱ   
-    0x0473, 499,  # ѳ Ѳ   
-    0x0475, 499,  # ѵ Ѵ   
-    0x0477, 499,  # ѷ Ѷ   
-    0x0479, 499,  # ѹ Ѹ   
-    0x047b, 499,  # ѻ Ѻ   
-    0x047d, 499,  # ѽ Ѽ   
-    0x047f, 499,  # ѿ Ѿ   
-    0x0481, 499,  # Ò Ò€   
-    0x0491, 499,  # Ò‘ Ò   
-    0x0493, 499,  # Ò“ Ò’   
-    0x0495, 499,  # Ò• Ò”   
-    0x0497, 499,  # Ò— Ò–   
-    0x0499, 499,  # Ò™ Ò˜   
-    0x049b, 499,  # Ò› Òš   
-    0x049d, 499,  # Ò Òœ   
-    0x049f, 499,  # ÒŸ Òž   
-    0x04a1, 499,  # Ò¡ Ò    
-    0x04a3, 499,  # Ò£ Ò¢   
-    0x04a5, 499,  # Ò¥ Ò¤   
-    0x04a7, 499,  # Ò§ Ò¦   
-    0x04a9, 499,  # Ò© Ò¨   
-    0x04ab, 499,  # Ò« Òª   
-    0x04ad, 499,  # Ò­ Ò¬   
-    0x04af, 499,  # Ò¯ Ò®   
-    0x04b1, 499,  # Ò± Ò°   
-    0x04b3, 499,  # Ò³ Ò²   
-    0x04b5, 499,  # Òµ Ò´   
-    0x04b7, 499,  # Ò· Ò¶   
-    0x04b9, 499,  # Ò¹ Ò¸   
-    0x04bb, 499,  # Ò» Òº   
-    0x04bd, 499,  # Ò½ Ò¼   
-    0x04bf, 499,  # Ò¿ Ò¾   
-    0x04c2, 499,  # Ó‚ Ó   
-    0x04c4, 499,  # Ó„ Óƒ   
-    0x04c8, 499,  # Óˆ Ó‡   
-    0x04cc, 499,  # ӌ Ӌ   
-    0x04d1, 499,  # Ó‘ Ó   
-    0x04d3, 499,  # Ó“ Ó’   
-    0x04d5, 499,  # Ó• Ó”   
-    0x04d7, 499,  # Ó— Ó–   
-    0x04d9, 499,  # Ó™ Ó˜   
-    0x04db, 499,  # Ó› Óš   
-    0x04dd, 499,  # Ó Óœ   
-    0x04df, 499,  # ÓŸ Óž   
-    0x04e1, 499,  # Ó¡ Ó    
-    0x04e3, 499,  # Ó£ Ó¢   
-    0x04e5, 499,  # Ó¥ Ó¤   
-    0x04e7, 499,  # Ó§ Ó¦   
-    0x04e9, 499,  # Ó© Ó¨   
-    0x04eb, 499,  # Ó« Óª   
-    0x04ef, 499,  # Ó¯ Ó®   
-    0x04f1, 499,  # Ó± Ó°   
-    0x04f3, 499,  # Ó³ Ó²   
-    0x04f5, 499,  # Óµ Ó´   
-    0x04f9, 499,  # Ó¹ Ó¸   
-    0x1e01, 499,  # ḠḀ   
-    0x1e03, 499,  # ḃ Ḃ   
-    0x1e05, 499,  # ḅ Ḅ   
-    0x1e07, 499,  # ḇ Ḇ   
-    0x1e09, 499,  # ḉ Ḉ   
-    0x1e0b, 499,  # ḋ Ḋ   
-    0x1e0d, 499,  # ḠḌ   
-    0x1e0f, 499,  # ḠḎ   
-    0x1e11, 499,  # ḑ Ḡ  
-    0x1e13, 499,  # ḓ Ḓ   
-    0x1e15, 499,  # ḕ Ḕ   
-    0x1e17, 499,  # ḗ Ḗ   
-    0x1e19, 499,  # ḙ Ḙ   
-    0x1e1b, 499,  # ḛ Ḛ   
-    0x1e1d, 499,  # ḠḜ   
-    0x1e1f, 499,  # ḟ Ḟ   
-    0x1e21, 499,  # ḡ Ḡ   
-    0x1e23, 499,  # ḣ Ḣ   
-    0x1e25, 499,  # ḥ Ḥ   
-    0x1e27, 499,  # ḧ Ḧ   
-    0x1e29, 499,  # ḩ Ḩ   
-    0x1e2b, 499,  # ḫ Ḫ   
-    0x1e2d, 499,  # ḭ Ḭ   
-    0x1e2f, 499,  # ḯ Ḯ   
-    0x1e31, 499,  # ḱ Ḱ   
-    0x1e33, 499,  # ḳ Ḳ   
-    0x1e35, 499,  # ḵ Ḵ   
-    0x1e37, 499,  # ḷ Ḷ   
-    0x1e39, 499,  # ḹ Ḹ   
-    0x1e3b, 499,  # ḻ Ḻ   
-    0x1e3d, 499,  # ḽ Ḽ   
-    0x1e3f, 499,  # ḿ Ḿ   
-    0x1e41, 499,  # á¹ á¹€   
-    0x1e43, 499,  # ṃ Ṃ   
-    0x1e45, 499,  # ṅ Ṅ   
-    0x1e47, 499,  # ṇ Ṇ   
-    0x1e49, 499,  # ṉ Ṉ   
-    0x1e4b, 499,  # ṋ Ṋ   
-    0x1e4d, 499,  # ṠṌ   
-    0x1e4f, 499,  # ṠṎ   
-    0x1e51, 499,  # ṑ Ṡ  
-    0x1e53, 499,  # ṓ Ṓ   
-    0x1e55, 499,  # ṕ Ṕ   
-    0x1e57, 499,  # á¹— á¹–   
-    0x1e59, 499,  # ṙ Ṙ   
-    0x1e5b, 499,  # ṛ Ṛ   
-    0x1e5d, 499,  # ṠṜ   
-    0x1e5f, 499,  # ṟ Ṟ   
-    0x1e61, 499,  # ṡ Ṡ   
-    0x1e63, 499,  # á¹£ á¹¢   
-    0x1e65, 499,  # ṥ Ṥ   
-    0x1e67, 499,  # ṧ Ṧ   
-    0x1e69, 499,  # ṩ Ṩ   
-    0x1e6b, 499,  # ṫ Ṫ   
-    0x1e6d, 499,  # ṭ Ṭ   
-    0x1e6f, 499,  # ṯ Ṯ   
-    0x1e71, 499,  # á¹± á¹°   
-    0x1e73, 499,  # á¹³ á¹²   
-    0x1e75, 499,  # á¹µ á¹´   
-    0x1e77, 499,  # á¹· á¹¶   
-    0x1e79, 499,  # ṹ Ṹ   
-    0x1e7b, 499,  # ṻ Ṻ   
-    0x1e7d, 499,  # á¹½ á¹¼   
-    0x1e7f, 499,  # ṿ Ṿ   
-    0x1e81, 499,  # ẠẀ   
-    0x1e83, 499,  # ẃ Ẃ   
-    0x1e85, 499,  # ẅ Ẅ   
-    0x1e87, 499,  # ẇ Ẇ   
-    0x1e89, 499,  # ẉ Ẉ   
-    0x1e8b, 499,  # ẋ Ẋ   
-    0x1e8d, 499,  # ẠẌ   
-    0x1e8f, 499,  # ẠẎ   
-    0x1e91, 499,  # ẑ Ạ  
-    0x1e93, 499,  # ẓ Ẓ   
-    0x1e95, 499,  # ẕ Ẕ   
-    0x1ea1, 499,  # ạ Ạ   
-    0x1ea3, 499,  # ả Ả   
-    0x1ea5, 499,  # ấ Ấ   
-    0x1ea7, 499,  # ầ Ầ   
-    0x1ea9, 499,  # ẩ Ẩ   
-    0x1eab, 499,  # ẫ Ẫ   
-    0x1ead, 499,  # ậ Ậ   
-    0x1eaf, 499,  # ắ Ắ   
-    0x1eb1, 499,  # ằ Ằ   
-    0x1eb3, 499,  # ẳ Ẳ   
-    0x1eb5, 499,  # ẵ Ẵ   
-    0x1eb7, 499,  # ặ Ặ   
-    0x1eb9, 499,  # ẹ Ẹ   
-    0x1ebb, 499,  # ẻ Ẻ   
-    0x1ebd, 499,  # ẽ Ẽ   
-    0x1ebf, 499,  # ế Ế   
-    0x1ec1, 499,  # ỠỀ   
-    0x1ec3, 499,  # ể Ể   
-    0x1ec5, 499,  # ễ Ễ   
-    0x1ec7, 499,  # ệ Ệ   
-    0x1ec9, 499,  # ỉ Ỉ   
-    0x1ecb, 499,  # ị Ị   
-    0x1ecd, 499,  # ỠỌ   
-    0x1ecf, 499,  # ỠỎ   
-    0x1ed1, 499,  # ố Ỡ  
-    0x1ed3, 499,  # ồ Ồ   
-    0x1ed5, 499,  # ổ Ổ   
-    0x1ed7, 499,  # á»— á»–   
-    0x1ed9, 499,  # ộ Ộ   
-    0x1edb, 499,  # ớ Ớ   
-    0x1edd, 499,  # ỠỜ   
-    0x1edf, 499,  # ở Ở   
-    0x1ee1, 499,  # ỡ Ỡ   
-    0x1ee3, 499,  # ợ Ợ   
-    0x1ee5, 499,  # ụ Ụ   
-    0x1ee7, 499,  # ủ Ủ   
-    0x1ee9, 499,  # ứ Ứ   
-    0x1eeb, 499,  # ừ Ừ   
-    0x1eed, 499,  # ử Ử   
-    0x1eef, 499,  # ữ Ữ   
-    0x1ef1, 499,  # á»± á»°   
-    0x1ef3, 499,  # ỳ Ỳ   
-    0x1ef5, 499,  # ỵ Ỵ   
-    0x1ef7, 499,  # á»· á»¶   
-    0x1ef9, 499,  # ỹ Ỹ   
-    0x1f51, 508,  # ὑ Ὑ   
-    0x1f53, 508,  # ὓ Ὓ   
-    0x1f55, 508,  # ὕ ὠ  
-    0x1f57, 508,  # ὗ Ὗ   
-    0x1fb3, 509,  # á¾³ á¾¼   
-    0x1fc3, 509,  # ῃ ῌ   
-    0x1fe5, 507,  # ῥ Ῥ   
-    0x1ff3, 509]  # ῳ ῼ   
-
-  tolowerRanges = [
-    0x0041,  0x005a, 532,  # A-Z a-z
-    0x00c0,  0x00d6, 532,  # À-Ö à-ö   
-    0x00d8,  0x00de, 532,  # Ø-Þ ø-þ   
-    0x0189,  0x018a, 705,  # Ɖ-Ɗ ɖ-ɗ   
-    0x018e,  0x018f, 702,  # ÆŽ-Æ É˜-É™   
-    0x01b1,  0x01b2, 717,  # Ʊ-Ʋ ʊ-ʋ   
-    0x0388,  0x038a, 537,  # Έ-Ί έ-ί   
-    0x038e,  0x038f, 563,  # ÎŽ-Î Ï-ÏŽ   
-    0x0391,  0x03a1, 532,  # Α-Ρ α-Ï   
-    0x03a3,  0x03ab, 532,  # Σ-Ϋ σ-ϋ   
-    0x0401,  0x040c, 580,  # Ð-ÐŒ Ñ‘-Ñœ   
-    0x040e,  0x040f, 580,  # ÐŽ-Ð Ñž-ÑŸ   
-    0x0410,  0x042f, 532,  # Ð-Я а-Ñ   
-    0x0531,  0x0556, 548,  # Ô±-Õ– Õ¡-Ö†   
-    0x10a0,  0x10c5, 548,  # á‚ -Ⴥ áƒ-ჵ   
-    0x1f08,  0x1f0f, 492,  # Ἀ-ἠἀ-ἇ   
-    0x1f18,  0x1f1d, 492,  # Ἐ-á¼ á¼-ἕ   
-    0x1f28,  0x1f2f, 492,  # Ἠ-Ἧ ἠ-ἧ   
-    0x1f38,  0x1f3f, 492,  # Ἰ-Ἷ ἰ-ἷ   
-    0x1f48,  0x1f4d, 492,  # Ὀ-ὠὀ-ὅ   
-    0x1f68,  0x1f6f, 492,  # Ὠ-Ὧ ὠ-ὧ   
-    0x1f88,  0x1f8f, 492,  # ᾈ-ᾠᾀ-ᾇ   
-    0x1f98,  0x1f9f, 492,  # ᾘ-ᾟ á¾-á¾—   
-    0x1fa8,  0x1faf, 492,  # ᾨ-ᾯ ᾠ-ᾧ   
-    0x1fb8,  0x1fb9, 492,  # Ᾰ-Ᾱ ᾰ-ᾱ   
-    0x1fba,  0x1fbb, 426,  # Ὰ-Ά ὰ-ά   
-    0x1fc8,  0x1fcb, 414,  # Ὲ-Ή ὲ-ή   
-    0x1fd8,  0x1fd9, 492,  # Ῐ-á¿™ á¿-á¿‘   
-    0x1fda,  0x1fdb, 400,  # Ὶ-Ί ὶ-ί   
-    0x1fe8,  0x1fe9, 492,  # Ῠ-Ῡ ῠ-ῡ   
-    0x1fea,  0x1feb, 388,  # Ὺ-Ύ ὺ-ύ   
-    0x1ff8,  0x1ff9, 372,  # Ὸ-Ό ὸ-ό   
-    0x1ffa,  0x1ffb, 374,  # Ὼ-Ώ ὼ-ώ   
-    0x2160,  0x216f, 516,  # â… -â…¯ â…°-â…¿   
-    0x24b6,  0x24cf, 526,  # â’¶-â“ â“-â“©   
-    0xff21,  0xff3a, 532]  # A-Z ï½-z   
-
-  tolowerSinglets = [
-    0x0100, 501,  # Ä€ Ä   
-    0x0102, 501,  # Ă ă   
-    0x0104, 501,  # Ä„ Ä…   
-    0x0106, 501,  # Ć ć   
-    0x0108, 501,  # Ĉ ĉ   
-    0x010a, 501,  # ÄŠ Ä‹   
-    0x010c, 501,  # ÄŒ Ä   
-    0x010e, 501,  # ÄŽ Ä   
-    0x0110, 501,  # Ä Ä‘   
-    0x0112, 501,  # Ä’ Ä“   
-    0x0114, 501,  # Ä” Ä•   
-    0x0116, 501,  # Ä– Ä—   
-    0x0118, 501,  # Ę ę   
-    0x011a, 501,  # Äš Ä›   
-    0x011c, 501,  # Äœ Ä   
-    0x011e, 501,  # Äž ÄŸ   
-    0x0120, 501,  # Ä  Ä¡   
-    0x0122, 501,  # Ģ ģ   
-    0x0124, 501,  # Ĥ ĥ   
-    0x0126, 501,  # Ħ ħ   
-    0x0128, 501,  # Ĩ ĩ   
-    0x012a, 501,  # Ī ī   
-    0x012c, 501,  # Ĭ ĭ   
-    0x012e, 501,  # Į į   
-    0x0130, 301,  # İ i   
-    0x0132, 501,  # IJ ij   
-    0x0134, 501,  # Ĵ ĵ   
-    0x0136, 501,  # Ķ ķ   
-    0x0139, 501,  # Ĺ ĺ   
-    0x013b, 501,  # Ļ ļ   
-    0x013d, 501,  # Ľ ľ   
-    0x013f, 501,  # Ŀ ŀ   
-    0x0141, 501,  # Å Å‚   
-    0x0143, 501,  # Ń ń   
-    0x0145, 501,  # Ņ ņ   
-    0x0147, 501,  # Ň ň   
-    0x014a, 501,  # ÅŠ Å‹   
-    0x014c, 501,  # Ō Š  
-    0x014e, 501,  # ÅŽ Å   
-    0x0150, 501,  # Å Å‘   
-    0x0152, 501,  # Å’ Å“   
-    0x0154, 501,  # Å” Å•   
-    0x0156, 501,  # Å– Å—   
-    0x0158, 501,  # Ř ř   
-    0x015a, 501,  # Åš Å›   
-    0x015c, 501,  # Ŝ Š  
-    0x015e, 501,  # Åž ÅŸ   
-    0x0160, 501,  # Å  Å¡   
-    0x0162, 501,  # Ţ ţ   
-    0x0164, 501,  # Ť ť   
-    0x0166, 501,  # Ŧ ŧ   
-    0x0168, 501,  # Ũ ũ   
-    0x016a, 501,  # Ū ū   
-    0x016c, 501,  # Ŭ ŭ   
-    0x016e, 501,  # Ů ů   
-    0x0170, 501,  # Ű ű   
-    0x0172, 501,  # Ų ų   
-    0x0174, 501,  # Ŵ ŵ   
-    0x0176, 501,  # Ŷ ŷ   
-    0x0178, 379,  # Ÿ ÿ   
-    0x0179, 501,  # Ź ź   
-    0x017b, 501,  # Ż ż   
-    0x017d, 501,  # Ž ž   
-    0x0181, 710,  # Æ É“   
-    0x0182, 501,  # Ƃ ƃ   
-    0x0184, 501,  # Æ„ Æ…   
-    0x0186, 706,  # Ɔ ɔ   
-    0x0187, 501,  # Ƈ ƈ   
-    0x018b, 501,  # Ƌ ƌ   
-    0x0190, 703,  # Æ É›   
-    0x0191, 501,  # Æ‘ Æ’   
-    0x0193, 705,  # Æ“ É    
-    0x0194, 707,  # Ɣ ɣ   
-    0x0196, 711,  # Æ– É©   
-    0x0197, 709,  # Ɨ ɨ   
-    0x0198, 501,  # Ƙ ƙ   
-    0x019c, 711,  # Ɯ ɯ   
-    0x019d, 713,  # Æ É²   
-    0x01a0, 501,  # Æ  Æ¡   
-    0x01a2, 501,  # Ƣ ƣ   
-    0x01a4, 501,  # Ƥ ƥ   
-    0x01a7, 501,  # Ƨ ƨ   
-    0x01a9, 718,  # Ʃ ʃ   
-    0x01ac, 501,  # Ƭ ƭ   
-    0x01ae, 718,  # Ʈ ʈ   
-    0x01af, 501,  # Ư ư   
-    0x01b3, 501,  # Ƴ ƴ   
-    0x01b5, 501,  # Ƶ ƶ   
-    0x01b7, 719,  # Æ· Ê’   
-    0x01b8, 501,  # Ƹ ƹ   
-    0x01bc, 501,  # Ƽ ƽ   
-    0x01c4, 502,  # DŽ dž   
-    0x01c5, 501,  # Dž dž   
-    0x01c7, 502,  # LJ lj   
-    0x01c8, 501,  # Lj lj   
-    0x01ca, 502,  # NJ nj   
-    0x01cb, 501,  # Nj nj   
-    0x01cd, 501,  # Ç ÇŽ   
-    0x01cf, 501,  # Ç Ç   
-    0x01d1, 501,  # Ç‘ Ç’   
-    0x01d3, 501,  # Ç“ Ç”   
-    0x01d5, 501,  # Ç• Ç–   
-    0x01d7, 501,  # Ǘ ǘ   
-    0x01d9, 501,  # Ç™ Çš   
-    0x01db, 501,  # Ǜ ǜ   
-    0x01de, 501,  # Çž ÇŸ   
-    0x01e0, 501,  # Ç  Ç¡   
-    0x01e2, 501,  # Ǣ ǣ   
-    0x01e4, 501,  # Ǥ ǥ   
-    0x01e6, 501,  # Ǧ ǧ   
-    0x01e8, 501,  # Ǩ ǩ   
-    0x01ea, 501,  # Ǫ ǫ   
-    0x01ec, 501,  # Ǭ ǭ   
-    0x01ee, 501,  # Ǯ ǯ   
-    0x01f1, 502,  # DZ dz   
-    0x01f2, 501,  # Dz dz   
-    0x01f4, 501,  # Ǵ ǵ   
-    0x01fa, 501,  # Ǻ ǻ   
-    0x01fc, 501,  # Ǽ ǽ   
-    0x01fe, 501,  # Ǿ ǿ   
-    0x0200, 501,  # È€ È   
-    0x0202, 501,  # Ȃ ȃ   
-    0x0204, 501,  # È„ È…   
-    0x0206, 501,  # Ȇ ȇ   
-    0x0208, 501,  # Ȉ ȉ   
-    0x020a, 501,  # ÈŠ È‹   
-    0x020c, 501,  # ÈŒ È   
-    0x020e, 501,  # ÈŽ È   
-    0x0210, 501,  # È È‘   
-    0x0212, 501,  # È’ È“   
-    0x0214, 501,  # È” È•   
-    0x0216, 501,  # È– È—   
-    0x0386, 538,  # Ά ά   
-    0x038c, 564,  # Ό ό   
-    0x03e2, 501,  # Ϣ ϣ   
-    0x03e4, 501,  # Ϥ ϥ   
-    0x03e6, 501,  # Ϧ ϧ   
-    0x03e8, 501,  # Ϩ ϩ   
-    0x03ea, 501,  # Ϫ ϫ   
-    0x03ec, 501,  # Ϭ ϭ   
-    0x03ee, 501,  # Ϯ ϯ   
-    0x0460, 501,  # Ñ  Ñ¡   
-    0x0462, 501,  # Ѣ ѣ   
-    0x0464, 501,  # Ѥ ѥ   
-    0x0466, 501,  # Ѧ ѧ   
-    0x0468, 501,  # Ѩ ѩ   
-    0x046a, 501,  # Ѫ ѫ   
-    0x046c, 501,  # Ѭ ѭ   
-    0x046e, 501,  # Ѯ ѯ   
-    0x0470, 501,  # Ѱ ѱ   
-    0x0472, 501,  # Ѳ ѳ   
-    0x0474, 501,  # Ѵ ѵ   
-    0x0476, 501,  # Ѷ ѷ   
-    0x0478, 501,  # Ѹ ѹ   
-    0x047a, 501,  # Ѻ ѻ   
-    0x047c, 501,  # Ѽ ѽ   
-    0x047e, 501,  # Ѿ ѿ   
-    0x0480, 501,  # Ò€ Ò   
-    0x0490, 501,  # Ò Ò‘   
-    0x0492, 501,  # Ò’ Ò“   
-    0x0494, 501,  # Ò” Ò•   
-    0x0496, 501,  # Ò– Ò—   
-    0x0498, 501,  # Ò˜ Ò™   
-    0x049a, 501,  # Òš Ò›   
-    0x049c, 501,  # Òœ Ò   
-    0x049e, 501,  # Òž ÒŸ   
-    0x04a0, 501,  # Ò  Ò¡   
-    0x04a2, 501,  # Ò¢ Ò£   
-    0x04a4, 501,  # Ò¤ Ò¥   
-    0x04a6, 501,  # Ò¦ Ò§   
-    0x04a8, 501,  # Ò¨ Ò©   
-    0x04aa, 501,  # Òª Ò«   
-    0x04ac, 501,  # Ò¬ Ò­   
-    0x04ae, 501,  # Ò® Ò¯   
-    0x04b0, 501,  # Ò° Ò±   
-    0x04b2, 501,  # Ò² Ò³   
-    0x04b4, 501,  # Ò´ Òµ   
-    0x04b6, 501,  # Ò¶ Ò·   
-    0x04b8, 501,  # Ò¸ Ò¹   
-    0x04ba, 501,  # Òº Ò»   
-    0x04bc, 501,  # Ò¼ Ò½   
-    0x04be, 501,  # Ò¾ Ò¿   
-    0x04c1, 501,  # Ó Ó‚   
-    0x04c3, 501,  # Óƒ Ó„   
-    0x04c7, 501,  # Ó‡ Óˆ   
-    0x04cb, 501,  # Ӌ ӌ   
-    0x04d0, 501,  # Ó Ó‘   
-    0x04d2, 501,  # Ó’ Ó“   
-    0x04d4, 501,  # Ó” Ó•   
-    0x04d6, 501,  # Ó– Ó—   
-    0x04d8, 501,  # Ó˜ Ó™   
-    0x04da, 501,  # Óš Ó›   
-    0x04dc, 501,  # Óœ Ó   
-    0x04de, 501,  # Óž ÓŸ   
-    0x04e0, 501,  # Ó  Ó¡   
-    0x04e2, 501,  # Ó¢ Ó£   
-    0x04e4, 501,  # Ó¤ Ó¥   
-    0x04e6, 501,  # Ó¦ Ó§   
-    0x04e8, 501,  # Ó¨ Ó©   
-    0x04ea, 501,  # Óª Ó«   
-    0x04ee, 501,  # Ó® Ó¯   
-    0x04f0, 501,  # Ó° Ó±   
-    0x04f2, 501,  # Ó² Ó³   
-    0x04f4, 501,  # Ó´ Óµ   
-    0x04f8, 501,  # Ó¸ Ó¹   
-    0x1e00, 501,  # Ḁ Ḡ  
-    0x1e02, 501,  # Ḃ ḃ   
-    0x1e04, 501,  # Ḅ ḅ   
-    0x1e06, 501,  # Ḇ ḇ   
-    0x1e08, 501,  # Ḉ ḉ   
-    0x1e0a, 501,  # Ḋ ḋ   
-    0x1e0c, 501,  # Ḍ Ḡ  
-    0x1e0e, 501,  # Ḏ Ḡ  
-    0x1e10, 501,  # Ḡḑ   
-    0x1e12, 501,  # Ḓ ḓ   
-    0x1e14, 501,  # Ḕ ḕ   
-    0x1e16, 501,  # Ḗ ḗ   
-    0x1e18, 501,  # Ḙ ḙ   
-    0x1e1a, 501,  # Ḛ ḛ   
-    0x1e1c, 501,  # Ḝ Ḡ  
-    0x1e1e, 501,  # Ḟ ḟ   
-    0x1e20, 501,  # Ḡ ḡ   
-    0x1e22, 501,  # Ḣ ḣ   
-    0x1e24, 501,  # Ḥ ḥ   
-    0x1e26, 501,  # Ḧ ḧ   
-    0x1e28, 501,  # Ḩ ḩ   
-    0x1e2a, 501,  # Ḫ ḫ   
-    0x1e2c, 501,  # Ḭ ḭ   
-    0x1e2e, 501,  # Ḯ ḯ   
-    0x1e30, 501,  # Ḱ ḱ   
-    0x1e32, 501,  # Ḳ ḳ   
-    0x1e34, 501,  # Ḵ ḵ   
-    0x1e36, 501,  # Ḷ ḷ   
-    0x1e38, 501,  # Ḹ ḹ   
-    0x1e3a, 501,  # Ḻ ḻ   
-    0x1e3c, 501,  # Ḽ ḽ   
-    0x1e3e, 501,  # Ḿ ḿ   
-    0x1e40, 501,  # á¹€ á¹   
-    0x1e42, 501,  # Ṃ ṃ   
-    0x1e44, 501,  # Ṅ ṅ   
-    0x1e46, 501,  # Ṇ ṇ   
-    0x1e48, 501,  # Ṉ ṉ   
-    0x1e4a, 501,  # Ṋ ṋ   
-    0x1e4c, 501,  # Ṍ Ṡ  
-    0x1e4e, 501,  # Ṏ Ṡ  
-    0x1e50, 501,  # Ṡṑ   
-    0x1e52, 501,  # Ṓ ṓ   
-    0x1e54, 501,  # Ṕ ṕ   
-    0x1e56, 501,  # á¹– á¹—   
-    0x1e58, 501,  # Ṙ ṙ   
-    0x1e5a, 501,  # Ṛ ṛ   
-    0x1e5c, 501,  # Ṝ Ṡ  
-    0x1e5e, 501,  # Ṟ ṟ   
-    0x1e60, 501,  # Ṡ ṡ   
-    0x1e62, 501,  # á¹¢ á¹£   
-    0x1e64, 501,  # Ṥ ṥ   
-    0x1e66, 501,  # Ṧ ṧ   
-    0x1e68, 501,  # Ṩ ṩ   
-    0x1e6a, 501,  # Ṫ ṫ   
-    0x1e6c, 501,  # Ṭ ṭ   
-    0x1e6e, 501,  # Ṯ ṯ   
-    0x1e70, 501,  # á¹° á¹±   
-    0x1e72, 501,  # á¹² á¹³   
-    0x1e74, 501,  # á¹´ á¹µ   
-    0x1e76, 501,  # á¹¶ á¹·   
-    0x1e78, 501,  # Ṹ ṹ   
-    0x1e7a, 501,  # Ṻ ṻ   
-    0x1e7c, 501,  # á¹¼ á¹½   
-    0x1e7e, 501,  # Ṿ ṿ   
-    0x1e80, 501,  # Ẁ Ạ  
-    0x1e82, 501,  # Ẃ ẃ   
-    0x1e84, 501,  # Ẅ ẅ   
-    0x1e86, 501,  # Ẇ ẇ   
-    0x1e88, 501,  # Ẉ ẉ   
-    0x1e8a, 501,  # Ẋ ẋ   
-    0x1e8c, 501,  # Ẍ Ạ  
-    0x1e8e, 501,  # Ẏ Ạ  
-    0x1e90, 501,  # Ạẑ   
-    0x1e92, 501,  # Ẓ ẓ   
-    0x1e94, 501,  # Ẕ ẕ   
-    0x1ea0, 501,  # Ạ ạ   
-    0x1ea2, 501,  # Ả ả   
-    0x1ea4, 501,  # Ấ ấ   
-    0x1ea6, 501,  # Ầ ầ   
-    0x1ea8, 501,  # Ẩ ẩ   
-    0x1eaa, 501,  # Ẫ ẫ   
-    0x1eac, 501,  # Ậ ậ   
-    0x1eae, 501,  # Ắ ắ   
-    0x1eb0, 501,  # Ằ ằ   
-    0x1eb2, 501,  # Ẳ ẳ   
-    0x1eb4, 501,  # Ẵ ẵ   
-    0x1eb6, 501,  # Ặ ặ   
-    0x1eb8, 501,  # Ẹ ẹ   
-    0x1eba, 501,  # Ẻ ẻ   
-    0x1ebc, 501,  # Ẽ ẽ   
-    0x1ebe, 501,  # Ế ế   
-    0x1ec0, 501,  # Ề Ỡ  
-    0x1ec2, 501,  # Ể ể   
-    0x1ec4, 501,  # Ễ ễ   
-    0x1ec6, 501,  # Ệ ệ   
-    0x1ec8, 501,  # Ỉ ỉ   
-    0x1eca, 501,  # Ị ị   
-    0x1ecc, 501,  # Ọ Ỡ  
-    0x1ece, 501,  # Ỏ Ỡ  
-    0x1ed0, 501,  # Ỡố   
-    0x1ed2, 501,  # Ồ ồ   
-    0x1ed4, 501,  # Ổ ổ   
-    0x1ed6, 501,  # á»– á»—   
-    0x1ed8, 501,  # Ộ ộ   
-    0x1eda, 501,  # Ớ ớ   
-    0x1edc, 501,  # Ờ Ỡ  
-    0x1ede, 501,  # Ở ở   
-    0x1ee0, 501,  # Ỡ ỡ   
-    0x1ee2, 501,  # Ợ ợ   
-    0x1ee4, 501,  # Ụ ụ   
-    0x1ee6, 501,  # Ủ ủ   
-    0x1ee8, 501,  # Ứ ứ   
-    0x1eea, 501,  # Ừ ừ   
-    0x1eec, 501,  # Ử ử   
-    0x1eee, 501,  # Ữ ữ   
-    0x1ef0, 501,  # á»° á»±   
-    0x1ef2, 501,  # Ỳ ỳ   
-    0x1ef4, 501,  # Ỵ ỵ   
-    0x1ef6, 501,  # á»¶ á»·   
-    0x1ef8, 501,  # Ỹ ỹ   
-    0x1f59, 492,  # Ὑ ὑ   
-    0x1f5b, 492,  # Ὓ ὓ   
-    0x1f5d, 492,  # ὠὕ   
-    0x1f5f, 492,  # Ὗ ὗ   
-    0x1fbc, 491,  # á¾¼ á¾³   
-    0x1fcc, 491,  # ῌ ῃ   
-    0x1fec, 493,  # Ῥ ῥ   
-    0x1ffc, 491]  # ῼ ῳ   
-
-  toTitleSinglets = [
-    0x01c4, 501,  # Ç„ Ç…   
-    0x01c6, 499,  # dž Dž   
-    0x01c7, 501,  # LJ Lj   
-    0x01c9, 499,  # lj Lj   
-    0x01ca, 501,  # ÇŠ Ç‹   
-    0x01cc, 499,  # nj Nj   
-    0x01f1, 501,  # DZ Dz   
-    0x01f3, 499]  # dz Dz   
-
-proc binarySearch(c: irune, tab: openArray[iRune], len, stride: int): int = 
+    let o = runeOffset(s, pos)
+    if o < 0:
+      result = ""
+    elif len == int.high:
+      result = s.substr(o, s.len-1)
+    elif len < 0:
+      let (e, rl) = runeReverseOffset(s, -len)
+      discard rl
+      if e <= 0:
+        result = ""
+      else:
+        result = s.substr(o, e-1)
+    else:
+      var e = runeOffset(s, len, o)
+      if e < 0:
+        e = s.len
+      result = s.substr(o, e-1)
+
+proc `<=%`*(a, b: Rune): bool =
+  ## Checks if code point of `a` is smaller or equal to code point of `b`.
+  runnableExamples:
+    let
+      a = "ú".runeAt(0)
+      b = "ü".runeAt(0)
+    doAssert a <=% b
+  return int(a) <=% int(b)
+
+proc `<%`*(a, b: Rune): bool =
+  ## Checks if code point of `a` is smaller than code point of `b`.
+  runnableExamples:
+    let
+      a = "ú".runeAt(0)
+      b = "ü".runeAt(0)
+    doAssert a <% b
+  return int(a) <% int(b)
+
+proc `==`*(a, b: Rune): bool =
+  ## Checks if two runes are equal.
+  return int(a) == int(b)
+
+
+include "includes/unicode_ranges"
+
+proc binarySearch(c: RuneImpl, tab: openArray[int32], len, stride: int): int =
   var n = len
   var t = 0
-  while n > 1: 
+  while n > 1:
     var m = n div 2
     var p = t + m*stride
     if c >= tab[p]:
@@ -1073,41 +479,65 @@ proc binarySearch(c: irune, tab: openArray[iRune], len, stride: int): int =
     return t
   return -1
 
-proc toLower*(c: TRune): TRune = 
-  ## Converts `c` into lower case. This works for any Unicode character.
-  ## If possible, prefer `toLower` over `toUpper`. 
-  var c = irune(c)
-  var p = binarySearch(c, tolowerRanges, len(toLowerRanges) div 3, 3)
-  if p >= 0 and c >= tolowerRanges[p] and c <= tolowerRanges[p+1]:
-    return TRune(c + tolowerRanges[p+2] - 500)
+proc toLower*(c: Rune): Rune {.rtl, extern: "nuc$1".} =
+  ## Converts ``c`` into lower case. This works for any rune.
+  ##
+  ## If possible, prefer ``toLower`` over ``toUpper``.
+  ##
+  ## See also:
+  ## * `toUpper proc <#toUpper,Rune>`_
+  ## * `toTitle proc <#toTitle,Rune>`_
+  ## * `isLower proc <#isLower,Rune>`_
+  var c = RuneImpl(c)
+  var p = binarySearch(c, toLowerRanges, len(toLowerRanges) div 3, 3)
+  if p >= 0 and c >= toLowerRanges[p] and c <= toLowerRanges[p+1]:
+    return Rune(c + toLowerRanges[p+2] - 500)
   p = binarySearch(c, toLowerSinglets, len(toLowerSinglets) div 2, 2)
   if p >= 0 and c == toLowerSinglets[p]:
-    return TRune(c + toLowerSinglets[p+1] - 500)
-  return TRune(c)
+    return Rune(c + toLowerSinglets[p+1] - 500)
+  return Rune(c)
 
-proc toUpper*(c: TRune): TRune = 
-  ## Converts `c` into upper case. This works for any Unicode character.
-  ## If possible, prefer `toLower` over `toUpper`. 
-  var c = irune(c)
+proc toUpper*(c: Rune): Rune {.rtl, extern: "nuc$1".} =
+  ## Converts ``c`` into upper case. This works for any rune.
+  ##
+  ## If possible, prefer ``toLower`` over ``toUpper``.
+  ##
+  ## See also:
+  ## * `toLower proc <#toLower,Rune>`_
+  ## * `toTitle proc <#toTitle,Rune>`_
+  ## * `isUpper proc <#isUpper,Rune>`_
+  var c = RuneImpl(c)
   var p = binarySearch(c, toUpperRanges, len(toUpperRanges) div 3, 3)
   if p >= 0 and c >= toUpperRanges[p] and c <= toUpperRanges[p+1]:
-    return TRune(c + toUpperRanges[p+2] - 500)
+    return Rune(c + toUpperRanges[p+2] - 500)
   p = binarySearch(c, toUpperSinglets, len(toUpperSinglets) div 2, 2)
   if p >= 0 and c == toUpperSinglets[p]:
-    return TRune(c + toUpperSinglets[p+1] - 500)
-  return TRune(c)
+    return Rune(c + toUpperSinglets[p+1] - 500)
+  return Rune(c)
 
-proc toTitle*(c: TRune): TRune = 
-  var c = irune(c)
+proc toTitle*(c: Rune): Rune {.rtl, extern: "nuc$1".} =
+  ## Converts ``c`` to title case.
+  ##
+  ## See also:
+  ## * `toLower proc <#toLower,Rune>`_
+  ## * `toUpper proc <#toUpper,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  var c = RuneImpl(c)
   var p = binarySearch(c, toTitleSinglets, len(toTitleSinglets) div 2, 2)
   if p >= 0 and c == toTitleSinglets[p]:
-    return TRune(c + toTitleSinglets[p+1] - 500)
-  return TRune(c)
+    return Rune(c + toTitleSinglets[p+1] - 500)
+  return Rune(c)
 
-proc isLower*(c: TRune): bool = 
-  ## returns true iff `c` is a lower case Unicode character
-  ## If possible, prefer `isLower` over `isUpper`. 
-  var c = irune(c)
+proc isLower*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is a lower case rune.
+  ##
+  ## If possible, prefer ``isLower`` over ``isUpper``.
+  ##
+  ## See also:
+  ## * `toLower proc <#toLower,Rune>`_
+  ## * `isUpper proc <#isUpper,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  var c = RuneImpl(c)
   # Note: toUpperRanges is correct here!
   var p = binarySearch(c, toUpperRanges, len(toUpperRanges) div 3, 3)
   if p >= 0 and c >= toUpperRanges[p] and c <= toUpperRanges[p+1]:
@@ -1116,10 +546,18 @@ proc isLower*(c: TRune): bool =
   if p >= 0 and c == toUpperSinglets[p]:
     return true
 
-proc isUpper*(c: TRune): bool = 
-  ## returns true iff `c` is a upper case Unicode character
-  ## If possible, prefer `isLower` over `isUpper`. 
-  var c = irune(c)
+proc isUpper*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is a upper case rune.
+  ##
+  ## If possible, prefer ``isLower`` over ``isUpper``.
+  ##
+  ## See also:
+  ## * `toUpper proc <#toUpper,Rune>`_
+  ## * `isLower proc <#isLower,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  ## * `isAlpha proc <#isAlpha,Rune>`_
+  ## * `isWhiteSpace proc <#isWhiteSpace,Rune>`_
+  var c = RuneImpl(c)
   # Note: toLowerRanges is correct here!
   var p = binarySearch(c, toLowerRanges, len(toLowerRanges) div 3, 3)
   if p >= 0 and c >= toLowerRanges[p] and c <= toLowerRanges[p+1]:
@@ -1128,51 +566,950 @@ proc isUpper*(c: TRune): bool =
   if p >= 0 and c == toLowerSinglets[p]:
     return true
 
-proc isAlpha*(c: TRune): bool = 
-  ## returns true iff `c` is an *alpha* Unicode character (i.e. a letter)
-  if isUpper(c) or isLower(c): 
+proc isAlpha*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is an *alpha* rune (i.e., a letter).
+  ##
+  ## See also:
+  ## * `isLower proc <#isLower,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  ## * `isAlpha proc <#isAlpha,Rune>`_
+  ## * `isWhiteSpace proc <#isWhiteSpace,Rune>`_
+  ## * `isCombining proc <#isCombining,Rune>`_
+  if isUpper(c) or isLower(c):
     return true
-  var c = irune(c)
+  var c = RuneImpl(c)
   var p = binarySearch(c, alphaRanges, len(alphaRanges) div 2, 2)
   if p >= 0 and c >= alphaRanges[p] and c <= alphaRanges[p+1]:
     return true
   p = binarySearch(c, alphaSinglets, len(alphaSinglets), 1)
   if p >= 0 and c == alphaSinglets[p]:
     return true
-  
-proc isTitle*(c: TRune): bool = 
+
+proc isTitle*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is a Unicode titlecase code point.
+  ##
+  ## See also:
+  ## * `toTitle proc <#toTitle,Rune>`_
+  ## * `isLower proc <#isLower,Rune>`_
+  ## * `isUpper proc <#isUpper,Rune>`_
+  ## * `isAlpha proc <#isAlpha,Rune>`_
+  ## * `isWhiteSpace proc <#isWhiteSpace,Rune>`_
   return isUpper(c) and isLower(c)
 
-proc isWhiteSpace*(c: TRune): bool = 
-  ## returns true iff `c` is a Unicode whitespace character
-  var c = irune(c)
+proc isWhiteSpace*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is a Unicode whitespace code point.
+  ##
+  ## See also:
+  ## * `isLower proc <#isLower,Rune>`_
+  ## * `isUpper proc <#isUpper,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  ## * `isAlpha proc <#isAlpha,Rune>`_
+  var c = RuneImpl(c)
   var p = binarySearch(c, spaceRanges, len(spaceRanges) div 2, 2)
   if p >= 0 and c >= spaceRanges[p] and c <= spaceRanges[p+1]:
     return true
 
-iterator runes*(s: string): TRune =
-  ## iterates over any unicode character of the string `s`.
+proc isCombining*(c: Rune): bool {.rtl, extern: "nuc$1".} =
+  ## Returns true if ``c`` is a Unicode combining code unit.
+  ##
+  ## See also:
+  ## * `isLower proc <#isLower,Rune>`_
+  ## * `isUpper proc <#isUpper,Rune>`_
+  ## * `isTitle proc <#isTitle,Rune>`_
+  ## * `isAlpha proc <#isAlpha,Rune>`_
+  var c = RuneImpl(c)
+
+  # Optimized to return false immediately for ASCII
+  return c >= 0x0300 and (c <= 0x036f or
+    (c >= 0x1ab0 and c <= 0x1aff) or
+    (c >= 0x1dc0 and c <= 0x1dff) or
+    (c >= 0x20d0 and c <= 0x20ff) or
+    (c >= 0xfe20 and c <= 0xfe2f))
+
+template runeCheck(s, runeProc) =
+  ## Common code for isAlpha and isSpace.
+  result = if len(s) == 0: false else: true
+  var
+    i = 0
+    rune: Rune
+  while i < len(s) and result:
+    fastRuneAt(s, i, rune, doInc = true)
+    result = runeProc(rune) and result
+
+proc isAlpha*(s: openArray[char]): bool {.noSideEffect,
+  rtl, extern: "nuc$1Str".} =
+  ## Returns true if ``s`` contains all alphabetic runes.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.isAlpha
+  runeCheck(s, isAlpha)
+
+proc isSpace*(s: openArray[char]): bool {.noSideEffect,
+  rtl, extern: "nuc$1Str".} =
+  ## Returns true if ``s`` contains all whitespace runes.
+  runnableExamples:
+    let a = "\t\l \v\r\f"
+    doAssert a.isSpace
+  runeCheck(s, isWhiteSpace)
+
+
+template convertRune(s, runeProc) =
+  ## Convert runes in ``s`` using ``runeProc`` as the converter.
+  result = newString(len(s))
+  var
+    i = 0
+    resultIndex = 0
+    rune: Rune
+  while i < len(s):
+    fastRuneAt(s, i, rune, doInc = true)
+    rune = runeProc(rune)
+    fastToUTF8Copy(rune, result, resultIndex, doInc = true)
+
+proc toUpper*(s: openArray[char]): string {.noSideEffect,
+  rtl, extern: "nuc$1Str".} =
+  ## Converts ``s`` into upper-case runes.
+  runnableExamples:
+    doAssert toUpper("abγ") == "ABΓ"
+  convertRune(s, toUpper)
+
+proc toLower*(s: openArray[char]): string {.noSideEffect,
+  rtl, extern: "nuc$1Str".} =
+  ## Converts ``s`` into lower-case runes.
+  runnableExamples:
+    doAssert toLower("ABΓ") == "abγ"
+  convertRune(s, toLower)
+
+proc swapCase*(s: openArray[char]): string {.noSideEffect,
+  rtl, extern: "nuc$1".} =
+  ## Swaps the case of runes in ``s``.
+  ##
+  ## Returns a new string such that the cases of all runes
+  ## are swapped if possible.
+  runnableExamples:
+    doAssert swapCase("Αlpha Βeta Γamma") == "αLPHA βETA γAMMA"
+
   var
     i = 0
-    result: TRune
+    resultIndex = 0
+    rune: Rune
+  result = newString(len(s))
+  while i < len(s):
+    fastRuneAt(s, i, rune)
+    if rune.isUpper():
+      rune = rune.toLower()
+    elif rune.isLower():
+      rune = rune.toUpper()
+    fastToUTF8Copy(rune, result, resultIndex, doInc = true)
+
+proc capitalize*(s: openArray[char]): string {.noSideEffect,
+  rtl, extern: "nuc$1".} =
+  ## Converts the first character of ``s`` into an upper-case rune.
+  runnableExamples:
+    doAssert capitalize("βeta") == "Βeta"
+
+  if len(s) == 0:
+    return ""
+  var
+    rune: Rune
+    i = 0
+  fastRuneAt(s, i, rune, doInc = true)
+  result = $toUpper(rune) & substr(s.toOpenArray(i, s.high))
+
+when not defined(nimHasEffectsOf):
+  {.pragma: effectsOf.}
+
+proc translate*(s: openArray[char], replacements: proc(key: string): string): string {.
+  rtl, extern: "nuc$1", effectsOf: replacements.} =
+  ## Translates words in a string using the ``replacements`` proc to substitute
+  ## words inside ``s`` with their replacements.
+  ##
+  ## ``replacements`` is any proc that takes a word and returns
+  ## a new word to fill it's place.
+  runnableExamples:
+    proc wordToNumber(s: string): string =
+      case s
+      of "one": "1"
+      of "two": "2"
+      else: s
+    let a = "one two three four"
+    doAssert a.translate(wordToNumber) == "1 2 three four"
+
+  # Allocate memory for the new string based on the old one.
+  # If the new string length is less than the old, no allocations
+  # will be needed. If the new string length is greater than the
+  # old, then maybe only one allocation is needed
+  result = newStringOfCap(s.len)
+  var
+    index = 0
+    lastIndex = 0
+    wordStart = 0
+    inWord = false
+    rune: Rune
+
+  while index < len(s):
+    lastIndex = index
+    fastRuneAt(s, index, rune)
+    let whiteSpace = rune.isWhiteSpace()
+
+    if whiteSpace and inWord:
+      # If we've reached the end of a word
+      let word = substr(s.toOpenArray(wordStart, lastIndex - 1))
+      result.add(replacements(word))
+      result.add($rune)
+      inWord = false
+    elif not whiteSpace and not inWord:
+      # If we've hit a non space character and
+      # are not currently in a word, track
+      # the starting index of the word
+      inWord = true
+      wordStart = lastIndex
+    elif whiteSpace:
+      result.add($rune)
+
+  if wordStart < len(s) and inWord:
+    # Get the trailing word at the end
+    let word = substr(s.toOpenArray(wordStart,  s.high))
+    result.add(replacements(word))
+
+proc title*(s: openArray[char]): string {.noSideEffect,
+  rtl, extern: "nuc$1".} =
+  ## Converts ``s`` to a unicode title.
+  ##
+  ## Returns a new string such that the first character
+  ## in each word inside ``s`` is capitalized.
+  runnableExamples:
+    doAssert title("αlpha βeta γamma") == "Αlpha Βeta Γamma"
+
+  var
+    i = 0
+    resultIndex = 0
+    rune: Rune
+  result = newString(len(s))
+  var firstRune = true
+
+  while i < len(s):
+    fastRuneAt(s, i, rune)
+    if not rune.isWhiteSpace() and firstRune:
+      rune = rune.toUpper()
+      firstRune = false
+    elif rune.isWhiteSpace():
+      firstRune = true
+    fastToUTF8Copy(rune, result, resultIndex, doInc = true)
+
+
+iterator runes*(s: openArray[char]): Rune =
+  ## Iterates over any rune of the string ``s`` returning runes.
+  var
+    i = 0
+    result: Rune
   while i < len(s):
     fastRuneAt(s, i, result, true)
     yield result
 
-proc cmpRunesIgnoreCase*(a, b: string): int = 
-  ## compares two UTF8 strings and ignores the case. Returns:
+iterator utf8*(s: openArray[char]): string =
+  ## Iterates over any rune of the string ``s`` returning utf8 values.
+  ##
+  ## See also:
+  ## * `validateUtf8 proc <#validateUtf8,string>`_
+  ## * `toUTF8 proc <#toUTF8,Rune>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  var o = 0
+  while o < s.len:
+    let n = runeLenAt(s, o)
+    yield substr(s.toOpenArray(o, (o+n-1)))
+    o += n
+
+proc toRunes*(s: openArray[char]): seq[Rune] =
+  ## Obtains a sequence containing the Runes in ``s``.
+  ##
+  ## See also:
+  ## * `$ proc <#$,Rune>`_ for a reverse operation
+  runnableExamples:
+    let a = toRunes("aáä")
+    doAssert a == @["a".runeAt(0), "á".runeAt(0), "ä".runeAt(0)]
+
+  result = newSeq[Rune]()
+  for r in s.runes:
+    result.add(r)
+
+proc cmpRunesIgnoreCase*(a, b: openArray[char]): int {.rtl, extern: "nuc$1".} =
+  ## Compares two UTF-8 strings and ignores the case. Returns:
   ##
-  ## | 0 iff a == b
-  ## | < 0 iff a < b
-  ## | > 0 iff a > b
+  ## | `0` if a == b
+  ## | `< 0` if a < b
+  ## | `> 0` if a > b
   var i = 0
   var j = 0
-  var ar, br: TRune
+  var ar, br: Rune
   while i < a.len and j < b.len:
     # slow path:
     fastRuneAt(a, i, ar)
     fastRuneAt(b, j, br)
-    result = irune(toLower(ar)) - irune(toLower(br))
+    when sizeof(int) < 4:
+      const lo = low(int).int32
+      const hi = high(int).int32
+      result = clamp(RuneImpl(toLower(ar)) - RuneImpl(toLower(br)), lo, hi).int
+    else:
+      result = RuneImpl(toLower(ar)) - RuneImpl(toLower(br))
     if result != 0: return
   result = a.len - b.len
 
+proc reversed*(s: openArray[char]): string =
+  ## Returns the reverse of ``s``, interpreting it as runes.
+  ##
+  ## Unicode combining characters are correctly interpreted as well.
+  runnableExamples:
+    assert reversed("Reverse this!") == "!siht esreveR"
+    assert reversed("先秦兩漢") == "漢兩秦先"
+    assert reversed("asâƒdfÌ…") == "fÌ…dsâƒa"
+    assert reversed("a⃞b⃞c⃞") == "c⃞b⃞a⃞"
+
+  var
+    i = 0
+    lastI = 0
+    newPos = len(s) - 1
+    blockPos = 0
+    r: Rune
+
+  template reverseUntil(pos) =
+    var j = pos - 1
+    while j > blockPos:
+      result[newPos] = s[j]
+      dec j
+      dec newPos
+    blockPos = pos - 1
+
+  result = newString(len(s))
+
+  while i < len(s):
+    lastI = i
+    fastRuneAt(s, i, r, true)
+    if not isCombining(r):
+      reverseUntil(lastI)
+
+  reverseUntil(len(s))
+
+proc graphemeLen*(s: openArray[char]; i: Natural): Natural =
+  ## The number of bytes belonging to byte index ``s[i]``,
+  ## including following combining code units.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.graphemeLen(1) == 2 ## ñ
+    doAssert a.graphemeLen(2) == 1
+    doAssert a.graphemeLen(4) == 2 ## ó
+
+  var j = i.int
+  var r, r2: Rune
+  if j < s.len:
+    fastRuneAt(s, j, r, true)
+    result = j-i
+    while j < s.len:
+      fastRuneAt(s, j, r2, true)
+      if not isCombining(r2): break
+      result = j-i
+
+proc lastRune*(s: openArray[char]; last: int): (Rune, int) =
+  ## Length of the last rune in ``s[0..last]``. Returns the rune and its length
+  ## in bytes.
+  if s[last] <= chr(127):
+    result = (Rune(s[last]), 1)
+  else:
+    var L = 0
+    while last-L >= 0 and uint(s[last-L]) shr 6 == 0b10: inc(L)
+    var r: Rune
+    fastRuneAt(s, last-L, r, false)
+    result = (r, L+1)
+
+proc size*(r: Rune): int {.noSideEffect.} =
+  ## Returns the number of bytes the rune ``r`` takes.
+  runnableExamples:
+    let a = toRunes "aá"
+    doAssert size(a[0]) == 1
+    doAssert size(a[1]) == 2
+
+  let v = r.uint32
+  if v <= 0x007F'u32: result = 1
+  elif v <= 0x07FF'u32: result = 2
+  elif v <= 0xFFFF'u32: result = 3
+  elif v <= 0x1FFFFF'u32: result = 4
+  elif v <= 0x3FFFFFF'u32: result = 5
+  elif v <= 0x7FFFFFFF'u32: result = 6
+  else: result = 1
+
+# --------- Private templates for different split separators -----------
+proc stringHasSep(s: openArray[char], index: int, seps: openArray[Rune]): bool =
+  var rune: Rune
+  fastRuneAt(s, index, rune, false)
+  return seps.contains(rune)
+
+proc stringHasSep(s: openArray[char], index: int, sep: Rune): bool =
+  var rune: Rune
+  fastRuneAt(s, index, rune, false)
+  return sep == rune
+
+template splitCommon(s, sep, maxsplit: untyped) =
+  ## Common code for split procedures.
+  let
+    sLen = len(s)
+  var
+    last = 0
+    splits = maxsplit
+  if sLen > 0:
+    while last <= sLen:
+      var first = last
+      while last < sLen and not stringHasSep(s, last, sep):
+        inc(last, runeLenAt(s, last))
+      if splits == 0: last = sLen
+      yield substr(s.toOpenArray(first, (last - 1)))
+      if splits == 0: break
+      dec(splits)
+      inc(last, if last < sLen: runeLenAt(s, last) else: 1)
+
+iterator split*(s: openArray[char], seps: openArray[Rune] = unicodeSpaces,
+  maxsplit: int = -1): string =
+  ## Splits the unicode string ``s`` into substrings using a group of separators.
+  ##
+  ## Substrings are separated by a substring containing only ``seps``.
+  runnableExamples:
+    import std/sequtils
+
+    assert toSeq("hÃllo\lthis\lis an\texample\l是".split) ==
+      @["hÃllo", "this", "is", "an", "example", "是"]
+
+    # And the following code splits the same string using a sequence of Runes.
+    assert toSeq(split("añyóng:hÃllo;是$example", ";:$".toRunes)) ==
+      @["añyóng", "hÃllo", "是", "example"]
+
+    # example with a `Rune` separator and unused one `;`:
+    assert toSeq(split("ab是de:f:", ";:是".toRunes)) == @["ab", "de", "f", ""]
+
+    # Another example that splits a string containing a date.
+    let date = "2012-11-20T22:08:08.398990"
+
+    assert toSeq(split(date, " -:T".toRunes)) ==
+      @["2012", "11", "20", "22", "08", "08.398990"]
+
+  splitCommon(s, seps, maxsplit)
+
+iterator splitWhitespace*(s: openArray[char]): string =
+  ## Splits a unicode string at whitespace runes.
+  splitCommon(s, unicodeSpaces, -1)
+
+template accResult(iter: untyped) =
+  result = @[]
+  for x in iter: add(result, x)
+
+proc splitWhitespace*(s: openArray[char]): seq[string] {.noSideEffect,
+  rtl, extern: "ncuSplitWhitespace".} =
+  ## The same as the `splitWhitespace <#splitWhitespace.i,string>`_
+  ## iterator, but is a proc that returns a sequence of substrings.
+  accResult(splitWhitespace(s))
+
+iterator split*(s: openArray[char], sep: Rune, maxsplit: int = -1): string =
+  ## Splits the unicode string ``s`` into substrings using a single separator.
+  ## Substrings are separated by the rune ``sep``.
+  runnableExamples:
+    import std/sequtils
+
+    assert toSeq(split(";;hÃllo;this;is;an;;example;;;是", ";".runeAt(0))) ==
+      @["", "", "hÃllo", "this", "is", "an", "", "example", "", "", "是"]
+
+  splitCommon(s, sep, maxsplit)
+
+proc split*(s: openArray[char], seps: openArray[Rune] = unicodeSpaces, maxsplit: int = -1):
+    seq[string] {.noSideEffect, rtl, extern: "nucSplitRunes".} =
+  ## The same as the `split iterator <#split.i,string,openArray[Rune],int>`_,
+  ## but is a proc that returns a sequence of substrings.
+  accResult(split(s, seps, maxsplit))
+
+proc split*(s: openArray[char], sep: Rune, maxsplit: int = -1): seq[string] {.noSideEffect,
+  rtl, extern: "nucSplitRune".} =
+  ## The same as the `split iterator <#split.i,string,Rune,int>`_, but is a proc
+  ## that returns a sequence of substrings.
+  accResult(split(s, sep, maxsplit))
+
+proc strip*(s: openArray[char], leading = true, trailing = true,
+            runes: openArray[Rune] = unicodeSpaces): string {.noSideEffect,
+            rtl, extern: "nucStrip".} =
+  ## Strips leading or trailing ``runes`` from ``s`` and returns
+  ## the resulting string.
+  ##
+  ## If ``leading`` is true (default), leading ``runes`` are stripped.
+  ## If ``trailing`` is true (default), trailing ``runes`` are stripped.
+  ## If both are false, the string is returned unchanged.
+  runnableExamples:
+    let a = "\táñyóng   "
+    doAssert a.strip == "áñyóng"
+    doAssert a.strip(leading = false) == "\táñyóng"
+    doAssert a.strip(trailing = false) == "áñyóng   "
+
+  var
+    sI = 0          ## starting index into string ``s``
+    eI = len(s) - 1 ## ending index into ``s``, where the last ``Rune`` starts
+  if leading:
+    var
+      i = 0
+      xI: int ## value of ``sI`` at the beginning of the iteration
+      rune: Rune
+    while i < len(s):
+      xI = i
+      fastRuneAt(s, i, rune)
+      sI = i # Assume to start from next rune
+      if not runes.contains(rune):
+        sI = xI # Go back to where the current rune starts
+        break
+  if trailing:
+    var
+      i = eI
+      xI: int
+      rune: Rune
+    while i >= 0:
+      xI = i
+      fastRuneAt(s, xI, rune)
+      var yI = i - 1
+      while yI >= 0:
+        var
+          yIend = yI
+          pRune: Rune
+        fastRuneAt(s, yIend, pRune)
+        if yIend < xI: break
+        i = yI
+        rune = pRune
+        dec(yI)
+      if not runes.contains(rune):
+        eI = xI - 1
+        break
+      dec(i)
+  let newLen = eI - sI + 1
+  result = newStringOfCap(newLen)
+  if newLen > 0:
+    result.add substr(s.toOpenArray(sI, eI))
+
+proc repeat*(c: Rune, count: Natural): string {.noSideEffect,
+  rtl, extern: "nucRepeatRune".} =
+  ## Returns a string of ``count`` Runes ``c``.
+  ##
+  ## The returned string will have a rune-length of ``count``.
+  runnableExamples:
+    let a = "ñ".runeAt(0)
+    doAssert a.repeat(5) == "ñññññ"
+
+  let s = $c
+  result = newStringOfCap(count * s.len)
+  for i in 0 ..< count:
+    result.add s
+
+proc align*(s: openArray[char], count: Natural, padding = ' '.Rune): string {.
+  noSideEffect, rtl, extern: "nucAlignString".} =
+  ## Aligns a unicode string ``s`` with ``padding``, so that it has a rune-length
+  ## of ``count``.
+  ##
+  ## ``padding`` characters (by default spaces) are added before ``s`` resulting in
+  ## right alignment. If ``s.runelen >= count``, no spaces are added and ``s`` is
+  ## returned unchanged. If you need to left align a string use the `alignLeft
+  ## proc <#alignLeft,string,Natural>`_.
+  runnableExamples:
+    assert align("abc", 4) == " abc"
+    assert align("a", 0) == "a"
+    assert align("1232", 6) == "  1232"
+    assert align("1232", 6, '#'.Rune) == "##1232"
+    assert align("Ã…ge", 5) == "  Ã…ge"
+    assert align("×", 4, '_'.Rune) == "___×"
+
+  let sLen = s.runeLen
+  if sLen < count:
+    let padStr = $padding
+    result = newStringOfCap(padStr.len * count)
+    let spaces = count - sLen
+    for i in 0 ..< spaces: result.add padStr
+    result.add s
+  else:
+    result = s.substr
+
+proc alignLeft*(s: openArray[char], count: Natural, padding = ' '.Rune): string {.
+    noSideEffect.} =
+  ## Left-aligns a unicode string ``s`` with ``padding``, so that it has a
+  ## rune-length of ``count``.
+  ##
+  ## ``padding`` characters (by default spaces) are added after ``s`` resulting in
+  ## left alignment. If ``s.runelen >= count``, no spaces are added and ``s`` is
+  ## returned unchanged. If you need to right align a string use the `align
+  ## proc <#align,string,Natural>`_.
+  runnableExamples:
+    assert alignLeft("abc", 4) == "abc "
+    assert alignLeft("a", 0) == "a"
+    assert alignLeft("1232", 6) == "1232  "
+    assert alignLeft("1232", 6, '#'.Rune) == "1232##"
+    assert alignLeft("Ã…ge", 5) == "Ã…ge  "
+    assert alignLeft("×", 4, '_'.Rune) == "×___"
+  let sLen = s.runeLen
+  if sLen < count:
+    let padStr = $padding
+    result = newStringOfCap(s.len + (count - sLen) * padStr.len)
+    result.add s
+    for i in sLen ..< count:
+      result.add padStr
+  else:
+    result = s.substr
+
+
+proc runeLen*(s: string): int {.inline.} =
+  ## Returns the number of runes of the string ``s``.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeLen == 6
+    ## note: a.len == 8
+  runeLen(toOa(s))
+
+proc runeLenAt*(s: string, i: Natural): int {.inline.} =
+  ## Returns the number of bytes the rune starting at ``s[i]`` takes.
+  ##
+  ## See also:
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeLenAt(0) == 1
+    doAssert a.runeLenAt(1) == 2
+  runeLenAt(toOa(s), i)
+
+proc runeAt*(s: string, i: Natural): Rune {.inline.} =
+  ## Returns the rune in ``s`` at **byte index** ``i``.
+  ##
+  ## See also:
+  ## * `runeAtPos proc <#runeAtPos,string,int>`_
+  ## * `runeStrAtPos proc <#runeStrAtPos,string,Natural>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeAt(1) == "ñ".runeAt(0)
+    doAssert a.runeAt(2) == "ñ".runeAt(1)
+    doAssert a.runeAt(3) == "y".runeAt(0)
+  fastRuneAt(s, i, result, false)
+
+proc validateUtf8*(s: string): int {.inline.} =
+  ## Returns the position of the invalid byte in ``s`` if the string ``s`` does
+  ## not hold valid UTF-8 data. Otherwise ``-1`` is returned.
+  ##
+  ## See also:
+  ## * `toUTF8 proc <#toUTF8,Rune>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  validateUtf8(toOa(s))
+
+proc runeOffset*(s: string, pos: Natural, start: Natural = 0): int {.inline.} =
+  ## Returns the byte position of rune
+  ## at position ``pos`` in ``s`` with an optional start byte position.
+  ## Returns the special value -1 if it runs out of the string.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeReverseOffset proc <#runeReverseOffset,string,Positive>`_
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.runeOffset(1) == 1
+    doAssert a.runeOffset(3) == 4
+    doAssert a.runeOffset(4) == 6
+  runeOffset(toOa(s), pos, start)
+
+proc runeReverseOffset*(s: string, rev: Positive): (int, int) {.inline.} =
+  ## Returns a tuple with the byte offset of the
+  ## rune at position ``rev`` in ``s``, counting
+  ## from the end (starting with 1) and the total
+  ## number of runes in the string.
+  ##
+  ## Returns a negative value for offset if there are too few runes in
+  ## the string to satisfy the request.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeOffset proc <#runeOffset,string,Natural,Natural>`_
+  runeReverseOffset(toOa(s), rev)
+
+proc runeAtPos*(s: string, pos: int): Rune {.inline.} =
+  ## Returns the rune at position ``pos``.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeAt proc <#runeAt,string,Natural>`_
+  ## * `runeStrAtPos proc <#runeStrAtPos,string,Natural>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  fastRuneAt(toOa(s), runeOffset(s, pos), result, false)
+
+proc runeStrAtPos*(s: string, pos: Natural): string {.inline.} =
+  ## Returns the rune at position ``pos`` as UTF8 String.
+  ##
+  ## **Beware:** This can lead to unoptimized code and slow execution!
+  ## Most problems can be solved more efficiently by using an iterator
+  ## or conversion to a seq of Rune.
+  ##
+  ## See also:
+  ## * `runeAt proc <#runeAt,string,Natural>`_
+  ## * `runeAtPos proc <#runeAtPos,string,int>`_
+  ## * `fastRuneAt template <#fastRuneAt.t,string,int,untyped>`_
+  let o = runeOffset(s, pos)
+  substr(s.toOpenArray(o, (o+runeLenAt(s, o)-1)))
+
+proc runeSubStr*(s: string, pos: int, len: int = int.high): string {.inline.} =
+  ## Returns the UTF-8 substring starting at code point ``pos``
+  ## with ``len`` code points.
+  ##
+  ## If ``pos`` or ``len`` is negative they count from
+  ## the end of the string. If ``len`` is not given it means the longest
+  ## possible string.
+  runnableExamples:
+    let s = "Hänsel  ««: 10,00€"
+    doAssert(runeSubStr(s, 0, 2) == "Hä")
+    doAssert(runeSubStr(s, 10, 1) == ":")
+    doAssert(runeSubStr(s, -6) == "10,00€")
+    doAssert(runeSubStr(s, 10) == ": 10,00€")
+    doAssert(runeSubStr(s, 12, 5) == "10,00")
+    doAssert(runeSubStr(s, -6, 3) == "10,")
+  runeSubStr(toOa(s), pos, len)
+
+
+proc isAlpha*(s: string): bool {.noSideEffect, inline.} =
+  ## Returns true if ``s`` contains all alphabetic runes.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.isAlpha
+  isAlpha(toOa(s))
+
+proc isSpace*(s: string): bool {.noSideEffect, inline.} =
+  ## Returns true if ``s`` contains all whitespace runes.
+  runnableExamples:
+    let a = "\t\l \v\r\f"
+    doAssert a.isSpace
+  isSpace(toOa(s))
+
+
+proc toUpper*(s: string): string {.noSideEffect, inline.} =
+  ## Converts ``s`` into upper-case runes.
+  runnableExamples:
+    doAssert toUpper("abγ") == "ABΓ"
+  toUpper(toOa(s))
+
+proc toLower*(s: string): string {.noSideEffect, inline.} =
+  ## Converts ``s`` into lower-case runes.
+  runnableExamples:
+    doAssert toLower("ABΓ") == "abγ"
+  toLower(toOa(s))
+
+proc swapCase*(s: string): string {.noSideEffect, inline.} =
+  ## Swaps the case of runes in ``s``.
+  ##
+  ## Returns a new string such that the cases of all runes
+  ## are swapped if possible.
+  runnableExamples:
+    doAssert swapCase("Αlpha Βeta Γamma") == "αLPHA βETA γAMMA"
+  swapCase(toOa(s))
+
+proc capitalize*(s: string): string {.noSideEffect.} =
+  ## Converts the first character of ``s`` into an upper-case rune.
+  runnableExamples:
+    doAssert capitalize("βeta") == "Βeta"
+  capitalize(toOa(s))
+
+
+proc translate*(s: string, replacements: proc(key: string): string): string {.effectsOf: replacements, inline.} =
+  ## Translates words in a string using the ``replacements`` proc to substitute
+  ## words inside ``s`` with their replacements.
+  ##
+  ## ``replacements`` is any proc that takes a word and returns
+  ## a new word to fill it's place.
+  runnableExamples:
+    proc wordToNumber(s: string): string =
+      case s
+      of "one": "1"
+      of "two": "2"
+      else: s
+    let a = "one two three four"
+    doAssert a.translate(wordToNumber) == "1 2 three four"
+  translate(toOa(s), replacements)
+
+proc title*(s: string): string {.noSideEffect, inline.} =
+  ## Converts ``s`` to a unicode title.
+  ##
+  ## Returns a new string such that the first character
+  ## in each word inside ``s`` is capitalized.
+  runnableExamples:
+    doAssert title("αlpha βeta γamma") == "Αlpha Βeta Γamma"
+  title(toOa(s))
+
+
+iterator runes*(s: string): Rune =
+  ## Iterates over any rune of the string ``s`` returning runes.
+  for rune in runes(toOa(s)):
+    yield rune
+
+iterator utf8*(s: string): string =
+  ## Iterates over any rune of the string ``s`` returning utf8 values.
+  ##
+  ## See also:
+  ## * `validateUtf8 proc <#validateUtf8,string>`_
+  ## * `toUTF8 proc <#toUTF8,Rune>`_
+  ## * `$ proc <#$,Rune>`_ alias for `toUTF8`
+  ## * `fastToUTF8Copy template <#fastToUTF8Copy.t,Rune,string,int>`_
+  for str in utf8(toOa(s)):
+    yield str
+
+proc toRunes*(s: string): seq[Rune] {.inline.} =
+  ## Obtains a sequence containing the Runes in ``s``.
+  ##
+  ## See also:
+  ## * `$ proc <#$,Rune>`_ for a reverse operation
+  runnableExamples:
+    let a = toRunes("aáä")
+    doAssert a == @["a".runeAt(0), "á".runeAt(0), "ä".runeAt(0)]
+  toRunes(toOa(s))
+
+proc cmpRunesIgnoreCase*(a, b: string): int {.inline.} =
+  ## Compares two UTF-8 strings and ignores the case. Returns:
+  ##
+  ## | `0` if a == b
+  ## | `< 0` if a < b
+  ## | `> 0` if a > b
+  cmpRunesIgnoreCase(a.toOa(), b.toOa())
+
+proc reversed*(s: string): string {.inline.} =
+  ## Returns the reverse of ``s``, interpreting it as runes.
+  ##
+  ## Unicode combining characters are correctly interpreted as well.
+  runnableExamples:
+    assert reversed("Reverse this!") == "!siht esreveR"
+    assert reversed("先秦兩漢") == "漢兩秦先"
+    assert reversed("asâƒdfÌ…") == "fÌ…dsâƒa"
+    assert reversed("a⃞b⃞c⃞") == "c⃞b⃞a⃞"
+  reversed(toOa(s))
+
+proc graphemeLen*(s: string; i: Natural): Natural {.inline.} =
+  ## The number of bytes belonging to byte index ``s[i]``,
+  ## including following combining code unit.
+  runnableExamples:
+    let a = "añyóng"
+    doAssert a.graphemeLen(1) == 2 ## ñ
+    doAssert a.graphemeLen(2) == 1
+    doAssert a.graphemeLen(4) == 2 ## ó
+  graphemeLen(toOa(s), i)
+
+proc lastRune*(s: string; last: int): (Rune, int) {.inline.} =
+  ## Length of the last rune in ``s[0..last]``. Returns the rune and its length
+  ## in bytes.
+  lastRune(toOa(s), last)
+
+iterator split*(s: string, seps: openArray[Rune] = unicodeSpaces,
+  maxsplit: int = -1): string =
+  ## Splits the unicode string ``s`` into substrings using a group of separators.
+  ##
+  ## Substrings are separated by a substring containing only ``seps``.
+  runnableExamples:
+    import std/sequtils
+
+    assert toSeq("hÃllo\lthis\lis an\texample\l是".split) ==
+      @["hÃllo", "this", "is", "an", "example", "是"]
+
+    # And the following code splits the same string using a sequence of Runes.
+    assert toSeq(split("añyóng:hÃllo;是$example", ";:$".toRunes)) ==
+      @["añyóng", "hÃllo", "是", "example"]
+
+    # example with a `Rune` separator and unused one `;`:
+    assert toSeq(split("ab是de:f:", ";:是".toRunes)) == @["ab", "de", "f", ""]
+
+    # Another example that splits a string containing a date.
+    let date = "2012-11-20T22:08:08.398990"
+
+    assert toSeq(split(date, " -:T".toRunes)) ==
+      @["2012", "11", "20", "22", "08", "08.398990"]
+
+  splitCommon(toOa(s), seps, maxsplit)
+
+iterator splitWhitespace*(s: string): string =
+  ## Splits a unicode string at whitespace runes.
+  splitCommon(s.toOa(), unicodeSpaces, -1)
+
+
+proc splitWhitespace*(s: string): seq[string] {.noSideEffect, inline.}=
+  ## The same as the `splitWhitespace <#splitWhitespace.i,string>`_
+  ## iterator, but is a proc that returns a sequence of substrings.
+  accResult(splitWhitespace(toOa(s)))
+
+iterator split*(s: string, sep: Rune, maxsplit: int = -1): string =
+  ## Splits the unicode string ``s`` into substrings using a single separator.
+  ## Substrings are separated by the rune ``sep``.
+  runnableExamples:
+    import std/sequtils
+
+    assert toSeq(split(";;hÃllo;this;is;an;;example;;;是", ";".runeAt(0))) ==
+      @["", "", "hÃllo", "this", "is", "an", "", "example", "", "", "是"]
+
+  splitCommon(toOa(s), sep, maxsplit)
+
+proc split*(s: string, seps: openArray[Rune] = unicodeSpaces, maxsplit: int = -1):
+    seq[string] {.noSideEffect, inline.} =
+  ## The same as the `split iterator <#split.i,string,openArray[Rune],int>`_,
+  ## but is a proc that returns a sequence of substrings.
+  accResult(split(toOa(s), seps, maxsplit))
+
+proc split*(s: string, sep: Rune, maxsplit: int = -1): seq[string] {.noSideEffect, inline.} =
+  ## The same as the `split iterator <#split.i,string,Rune,int>`_, but is a proc
+  ## that returns a sequence of substrings.
+  accResult(split(toOa(s), sep, maxsplit))
+
+proc strip*(s: string, leading = true, trailing = true,
+            runes: openArray[Rune] = unicodeSpaces): string {.noSideEffect, inline.} =
+  ## Strips leading or trailing ``runes`` from ``s`` and returns
+  ## the resulting string.
+  ##
+  ## If ``leading`` is true (default), leading ``runes`` are stripped.
+  ## If ``trailing`` is true (default), trailing ``runes`` are stripped.
+  ## If both are false, the string is returned unchanged.
+  runnableExamples:
+    let a = "\táñyóng   "
+    doAssert a.strip == "áñyóng"
+    doAssert a.strip(leading = false) == "\táñyóng"
+    doAssert a.strip(trailing = false) == "áñyóng   "
+  strip(toOa(s), leading, trailing, runes)
+
+
+proc align*(s: string, count: Natural, padding = ' '.Rune): string {.noSideEffect, inline.} =
+  ## Aligns a unicode string ``s`` with ``padding``, so that it has a rune-length
+  ## of ``count``.
+  ##
+  ## ``padding`` characters (by default spaces) are added before ``s`` resulting in
+  ## right alignment. If ``s.runelen >= count``, no spaces are added and ``s`` is
+  ## returned unchanged. If you need to left align a string use the `alignLeft
+  ## proc <#alignLeft,string,Natural>`_.
+  runnableExamples:
+    assert align("abc", 4) == " abc"
+    assert align("a", 0) == "a"
+    assert align("1232", 6) == "  1232"
+    assert align("1232", 6, '#'.Rune) == "##1232"
+    assert align("Ã…ge", 5) == "  Ã…ge"
+    assert align("×", 4, '_'.Rune) == "___×"
+  align(toOa(s), count, padding)
+
+proc alignLeft*(s: string, count: Natural, padding = ' '.Rune): string {.noSideEffect, inline.} =
+  ## Left-aligns a unicode string ``s`` with ``padding``, so that it has a
+  ## rune-length of ``count``.
+  ##
+  ## ``padding`` characters (by default spaces) are added after ``s`` resulting in
+  ## left alignment. If ``s.runelen >= count``, no spaces are added and ``s`` is
+  ## returned unchanged. If you need to right align a string use the `align
+  ## proc <#align,string,Natural>`_.
+  runnableExamples:
+    assert alignLeft("abc", 4) == "abc "
+    assert alignLeft("a", 0) == "a"
+    assert alignLeft("1232", 6) == "1232  "
+    assert alignLeft("1232", 6, '#'.Rune) == "1232##"
+    assert alignLeft("Ã…ge", 5) == "Ã…ge  "
+    assert alignLeft("×", 4, '_'.Rune) == "×___"
+  alignLeft(toOa(s), count, padding)
diff --git a/lib/pure/unidecode/gen.py b/lib/pure/unidecode/gen.py
index 8da0136ff..2fb69f7b2 100755..100644
--- a/lib/pure/unidecode/gen.py
+++ b/lib/pure/unidecode/gen.py
@@ -1,26 +1,30 @@
-#! usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 # Generates the unidecode.dat module
 # (c) 2010 Andreas Rumpf
 
 from unidecode import unidecode
+try:
+  import warnings
+  warnings.simplefilter("ignore")
+except ImportError:
+  pass
 
-def main2(): 
-  data = []
-  for x in xrange(128, 0xffff + 1):
-    u = eval("u'\u%04x'" % x)
-    
-    val = unidecode(u)
-    data.append(val)
-    
-    
-  f = open("unidecode.dat", "wb+") 
-  for d in data:
-    f.write("%s\n" % d)
-  f.close()
+def main():
+  f = open("unidecode.dat", "wb+")
+  for x in range(128, 0xffff + 1):
+    u = eval("u'\\u%04x'" % x)
 
+    val = unidecode(u)
 
-main2()
+    # f.write("%x | " % x)
+    if x == 0x2028: # U+2028 = LINE SEPARATOR
+      val = ""
+    elif x == 0x2029: # U+2029 = PARAGRAPH SEPARATOR
+      val = ""
+    f.write("%s\n" % val)
 
+  f.close()
 
+main()
diff --git a/lib/pure/unidecode/unidecode.dat b/lib/pure/unidecode/unidecode.dat
index 9dff0a4a9..5f4c075d8 100755..100644
--- a/lib/pure/unidecode/unidecode.dat
+++ b/lib/pure/unidecode/unidecode.dat
@@ -58,9 +58,9 @@ P
 1
 o
 >>
-1/4
-1/2
-3/4
+ 1/4 
+ 1/2 
+ 3/4 
 ?
 A
 A
@@ -91,7 +91,7 @@ U
 U
 U
 U
-U
+Y
 Th
 ss
 a
@@ -177,7 +177,7 @@ i
 I
 i
 IJ
-
+ij
 J
 j
 K
@@ -368,7 +368,7 @@ ZH
 zh
 j
 DZ
-D
+Dz
 dz
 G
 g
@@ -414,8 +414,8 @@ Y
 y
 H
 h
-[?]
-[?]
+N
+d
 OU
 ou
 Z
@@ -434,34 +434,34 @@ O
 o
 Y
 y
+l
+n
+t
+j
+db
+qp
+A
+C
+c
+L
+T
+s
+z
 [?]
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+B
+U
+^
+E
+e
+J
+j
+q
+q
+R
+r
+Y
+y
 a
 a
 a
@@ -503,13 +503,13 @@ o
 OE
 O
 F
-R
-R
-R
-R
 r
 r
-R
+r
+r
+r
+r
+r
 R
 R
 s
@@ -519,12 +519,12 @@ S
 S
 t
 t
-U
+u
 U
 v
 ^
-W
-Y
+w
+y
 Y
 z
 z
@@ -556,9 +556,9 @@ ls
 lz
 WW
 ]]
-[?]
-[?]
-k
+h
+h
+h
 h
 j
 r
@@ -737,19 +737,19 @@ V
 
 
 
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+a
+e
+i
+o
+u
+c
+d
+h
+m
+r
+t
+v
+x
 [?]
 [?]
 [?]
@@ -1287,7 +1287,7 @@ o
 f
 ew
 [?]
-.
+:
 -
 [?]
 [?]
@@ -1340,9 +1340,9 @@ o
 u
 '
 
+-
 
-
-
+|
 
 
 :
@@ -7402,41 +7402,41 @@ bh
 
 
 
+b
+d
+f
+m
+n
+p
+r
+r
+s
+t
+z
+g
 
 
 
 
 
+p
 
 
+b
+d
+f
+g
+k
+l
+m
+n
+p
+r
+s
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+v
+x
+z
 
 
 
@@ -7708,7 +7708,7 @@ a
 S
 [?]
 [?]
-[?]
+Ss
 [?]
 A
 a
@@ -8109,9 +8109,6 @@ _
 
 
 
-
-
-
  
 %0
 %00
@@ -8136,19 +8133,23 @@ _
 /
 -[
 ]-
-[?]
+??
 ?!
 !?
 7
 PP
 (]
 [)
+*
 [?]
 [?]
 [?]
+%
+~
 [?]
 [?]
 [?]
+''''
 [?]
 [?]
 [?]
@@ -8156,12 +8157,8 @@ PP
 [?]
 [?]
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+ 
+
 [?]
 [?]
 [?]
@@ -8178,7 +8175,7 @@ PP
 
 
 0
-
+i
 
 
 4
@@ -8209,19 +8206,19 @@ n
 (
 )
 [?]
+a
+e
+o
+x
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+h
+k
+l
+m
+n
+p
+s
+t
 [?]
 [?]
 [?]
@@ -8237,26 +8234,26 @@ Rs
 W
 NS
 D
-EU
+EUR
 K
 T
 Dr
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+Pf
+P
+G
+A
+UAH
+C|
+L
+Sm
+T
+Rs
+L
+M
+m
+R
+l
+BTC
 [?]
 [?]
 [?]
@@ -8294,6 +8291,7 @@ Dr
 
 
 [?]
+
 [?]
 [?]
 [?]
@@ -8319,63 +8317,67 @@ Dr
 [?]
 [?]
 [?]
-[?]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
+ a/c 
+ a/s 
+C
 
 
+ c/o 
+ c/u 
 
 
 
+g
+H
+H
+H
+h
 
+I
+I
+L
+l
 
+N
+No. 
 
 
+P
+Q
+R
+R
+R
 
 
+(sm)
+TEL
+(tm)
 
+Z
 
 
 
+Z
 
+K
+A
+B
+C
+e
+e
+E
+F
+F
+M
+o
 
 
 
 
+i
 
+FAX
 
 
 
@@ -8385,25 +8387,20 @@ Dr
 [?]
 [?]
 [?]
+D
+d
+e
+i
+j
 [?]
 [?]
 [?]
 [?]
+F
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+ 1/7 
+ 1/9 
+ 1/10 
  1/3 
  2/3 
  1/5 
@@ -8458,7 +8455,7 @@ D)
 [?]
 [?]
 [?]
-[?]
+ 0/3 
 [?]
 [?]
 [?]
@@ -8595,8 +8592,12 @@ V
 [?]
 [?]
 [?]
+-
 [?]
 [?]
+/
+\
+*
 [?]
 [?]
 [?]
@@ -8608,6 +8609,7 @@ V
 [?]
 [?]
 [?]
+|
 [?]
 [?]
 [?]
@@ -8626,11 +8628,13 @@ V
 [?]
 [?]
 [?]
+:
 [?]
 [?]
 [?]
 [?]
 [?]
+~
 [?]
 [?]
 [?]
@@ -8670,17 +8674,10 @@ V
 [?]
 [?]
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+<=
+>=
+<=
+>=
 [?]
 [?]
 [?]
@@ -8836,6 +8833,7 @@ V
 [?]
 [?]
 [?]
+^
 [?]
 [?]
 [?]
@@ -8873,9 +8871,8 @@ V
 [?]
 [?]
 [?]
-[?]
-[?]
-[?]
+<
+> 
 [?]
 [?]
 [?]
@@ -9185,166 +9182,166 @@ V
 [?]
 [?]
 [?]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+(1)
+(2)
+(3)
+(4)
+(5)
+(6)
+(7)
+(8)
+(9)
+(10)
+(11)
+(12)
+(13)
+(14)
+(15)
+(16)
+(17)
+(18)
+(19)
+(20)
+1.
+2.
+3.
+4.
+5.
+6.
+7.
+8.
+9.
+10.
+11.
+12.
+13.
+14.
+15.
+16.
+17.
+18.
+19.
+20.
+(a)
+(b)
+(c)
+(d)
+(e)
+(f)
+(g)
+(h)
+(i)
+(j)
+(k)
+(l)
+(m)
+(n)
+(o)
+(p)
+(q)
+(r)
+(s)
+(t)
+(u)
+(v)
+(w)
+(x)
+(y)
+(z)
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+O
+P
+Q
+R
+S
+T
+U
+V
+W
+X
+Y
+Z
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+0
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+0
 -
 -
 |
@@ -9712,7 +9709,7 @@ O
 
 
 
-
+#
 
 
 [?]
@@ -9906,6 +9903,7 @@ O
 
 
 
+*
 
 
 
@@ -9944,8 +9942,7 @@ O
 
 
 
-
-
+|
 
 
 
@@ -9955,7 +9952,7 @@ O
 [?]
 [?]
 
-
+!
 
 
 
@@ -10087,10 +10084,10 @@ O
 [?]
 [?]
 [?]
+[
 [?]
-[?]
-[?]
-[?]
+<
+> 
 [?]
 [?]
 [?]
@@ -10500,6 +10497,8 @@ y
 
 
 
+{
+} 
 
 
 
@@ -10739,6 +10738,9 @@ y
 
 
 
+::=
+==
+===
 
 
 
@@ -11228,27 +11230,22 @@ y
 
 
 
+L
+l
+L
+P
+R
+a
+t
+H
+h
+K
+k
+Z
+z
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+M
+A
 
 
 
@@ -12754,21 +12751,21 @@ H
 [?]
 [?]
 [?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
 (g)
 (n)
 (d)
@@ -12850,21 +12847,21 @@ KIS
 (Zi) 
 (Xie) 
 (Ye) 
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
-[?]
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
 1M
 2M
 3M
@@ -12877,10 +12874,10 @@ KIS
 10M
 11M
 12M
-[?]
-[?]
-[?]
-[?]
+Hg
+erg
+eV
+LTD
 a
 i
 u
@@ -13042,16 +13039,16 @@ watt
 22h
 23h
 24h
-HPA
+hPa
 da
 AU
 bar
 oV
 pc
-[?]
-[?]
-[?]
-[?]
+dm
+dm^2
+dm^3
+IU
 Heisei
 Syouwa
 Taisyou
@@ -13092,7 +13089,7 @@ mm^2
 cm^2
 m^2
 km^2
-mm^4
+mm^3
 cm^3
 m^3
 km^3
@@ -13184,7 +13181,7 @@ Wb
 29d
 30d
 31d
-
+gal
 
 
 
@@ -19841,7 +19838,7 @@ Wb
 [?]
 [?]
 
-[?] 
+Yi 
 Ding 
 Kao 
 Qi 
diff --git a/lib/pure/unidecode/unidecode.nim b/lib/pure/unidecode/unidecode.nim
index 52f9b6b1a..9affc53f6 100755..100644
--- a/lib/pure/unidecode/unidecode.nim
+++ b/lib/pure/unidecode/unidecode.nim
@@ -1,65 +1,64 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## This module is based on Python's Unidecode module by Tomaz Solc, 
-## which in turn is based on the ``Text::Unidecode`` Perl module by 
-## Sean M. Burke 
-## (http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm ).
+## This module is based on Python's [Unidecode](https://pypi.org/project/Unidecode/)
+## module by Tomaz Solc, which in turn is based on the
+## [Text::Unidecode](https://metacpan.org/pod/Text::Unidecode)
+## Perl module by Sean M. Burke.
 ##
-## It provides a single proc that does Unicode to ASCII transliterations:
-## It finds the sequence of ASCII characters that is the closest approximation
-## to the Unicode string.
+## It provides a `unidecode proc <#unidecode,string>`_ that does
+## Unicode to ASCII transliterations: It finds the sequence of ASCII characters
+## that is the closest approximation to the Unicode string.
 ##
-## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some 
-## information is lost in this transformation, of course, since several Unicode 
-## strings can be transformed in the same ASCII representation. So this is a
-## strictly one-way transformation. However a human reader will probably 
-## still be able to guess what original string was meant from the context.
+## For example, the closest to string "Äußerst" in ASCII is "Ausserst". Some
+## information is lost in this transformation, of course, since several Unicode
+## strings can be transformed to the same ASCII representation. So this is a
+## strictly one-way transformation. However, a human reader will probably
+## still be able to guess from the context, what the original string was.
 ##
-## This module needs the data file "unidecode.dat" to work, so it has to be
-## shipped with the application! 
+## This module needs the data file `unidecode.dat` to work: This file is
+## embedded as a resource into your application by default. You can also
+## define the symbol `--define:noUnidecodeTable` during compile time and
+## use the `loadUnidecodeTable proc <#loadUnidecodeTable>`_ to initialize
+## this module.
 
-import unicode
+import std/unicode
 
-proc loadTranslationTable(filename: string): seq[string] =  
-  newSeq(result, 0xffff)
-  var i = 0
-  for line in lines(filename):
-    result[i] = line
-    inc(i)
+when not defined(noUnidecodeTable):
+  import std/strutils
 
-var 
-  translationTable: seq[string]
-  
-var
-  datafile* = "unidecode.dat"   ## location can be overwritten for deployment
+  const translationTable = splitLines(slurp"unidecode/unidecode.dat")
+else:
+  # shared is fine for threading:
+  var translationTable: seq[string]
 
-proc unidecode*(s: string): string = 
+proc loadUnidecodeTable*(datafile = "unidecode.dat") =
+  ## Loads the datafile that `unidecode <#unidecode,string>`_ needs to work.
+  ## This is only required if the module was compiled with the
+  ## `--define:noUnidecodeTable` switch. This needs to be called by the
+  ## main thread before any thread can make a call to `unidecode`.
+  when defined(noUnidecodeTable):
+    newSeq(translationTable, 0xffff)
+    var i = 0
+    for line in lines(datafile):
+      translationTable[i] = line
+      inc(i)
+
+proc unidecode*(s: string): string =
   ## Finds the sequence of ASCII characters that is the closest approximation
   ## to the UTF-8 string `s`.
-  ##
-  ## Example: 
-  ## 
-  ## ..code-block:: nimrod
-  ##   unidecode("\\x53\\x17\\x4E\\xB0")
-  ##
-  ## Results in: "Bei Jing"
-  ##
+  runnableExamples:
+    doAssert unidecode("北京") == "Bei Jing "
+    doAssert unidecode("Äußerst") == "Ausserst"
+
   result = ""
-  for r in runes(s): 
+  for r in runes(s):
     var c = int(r)
     if c <=% 127: add(result, chr(c))
-    elif c <=% 0xffff: 
-      if isNil(translationTable):
-        translationTable = loadTranslationTable(datafile)
-      add(result, translationTable[c-128])
-
-when isMainModule: 
-  echo unidecode("Äußerst")
-
+    elif c <% translationTable.len: add(result, translationTable[c - 128])
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
new file mode 100644
index 000000000..cfb762258
--- /dev/null
+++ b/lib/pure/unittest.nim
@@ -0,0 +1,789 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## :Author: Zahary Karadjov
+##
+## This module implements boilerplate to make unit testing easy.
+##
+## The test status and name is printed after any output or traceback.
+##
+## Tests can be nested, however failure of a nested test will not mark the
+## parent test as failed. Setup and teardown are inherited. Setup can be
+## overridden locally.
+##
+## Compiled test files as well as `nim c -r <testfile.nim>`
+## exit with 0 for success (no failed tests) or 1 for failure.
+##
+## Testament
+## =========
+##
+## Instead of `unittest`, please consider using
+## `the Testament tool <testament.html>`_ which offers process isolation for your tests.
+##
+## Alternatively using `when isMainModule: doAssert conditionHere` is usually a
+## much simpler solution for testing purposes.
+##
+## Running a single test
+## =====================
+##
+## Specify the test name as a command line argument.
+##
+##   ```cmd
+##   nim c -r test "my test name" "another test"
+##   ```
+##
+## Multiple arguments can be used.
+##
+## Running a single test suite
+## ===========================
+##
+## Specify the suite name delimited by `"::"`.
+##
+##   ```cmd
+##   nim c -r test "my test name::"
+##   ```
+##
+## Selecting tests by pattern
+## ==========================
+##
+## A single ``"*"`` can be used for globbing.
+##
+## Delimit the end of a suite name with `"::"`.
+##
+## Tests matching **any** of the arguments are executed.
+##
+##   ```cmd
+##   nim c -r test fast_suite::mytest1 fast_suite::mytest2
+##   nim c -r test "fast_suite::mytest*"
+##   nim c -r test "auth*::" "crypto::hashing*"
+##   # Run suites starting with 'bug #' and standalone tests starting with '#'
+##   nim c -r test 'bug #*::' '::#*'
+##   ```
+##
+## Examples
+## ========
+##
+##   ```nim
+##   suite "description for this stuff":
+##     echo "suite setup: run once before the tests"
+##
+##     setup:
+##       echo "run before each test"
+##
+##     teardown:
+##       echo "run after each test"
+##
+##     test "essential truths":
+##       # give up and stop if this fails
+##       require(true)
+##
+##     test "slightly less obvious stuff":
+##       # print a nasty message and move on, skipping
+##       # the remainder of this block
+##       check(1 != 1)
+##       check("asd"[2] == 'd')
+##
+##     test "out of bounds error is thrown on bad access":
+##       let v = @[1, 2, 3]  # you can do initialization here
+##       expect(IndexDefect):
+##         discard v[4]
+##
+##     echo "suite teardown: run once after the tests"
+##   ```
+##
+## Limitations/Bugs
+## ================
+## Since `check` will rewrite some expressions for supporting checkpoints
+## (namely assigns expressions to variables), some type conversions are not supported.
+## For example `check 4.0 == 2 + 2` won't work. But `doAssert 4.0 == 2 + 2` works.
+## Make sure both sides of the operator (such as `==`, `>=` and so on) have the same type.
+##
+
+import std/private/since
+import std/exitprocs
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+import std/[macros, strutils, streams, times, sets, sequtils]
+
+when declared(stdout):
+  import std/os
+
+const useTerminal = not defined(js)
+
+when useTerminal:
+  import std/terminal
+
+type
+  TestStatus* = enum ## The status of a test when it is done.
+    OK,
+    FAILED,
+    SKIPPED
+
+  OutputLevel* = enum ## The output verbosity of the tests.
+    PRINT_ALL,        ## Print as much as possible.
+    PRINT_FAILURES,   ## Print only the failed tests.
+    PRINT_NONE        ## Print nothing.
+
+  TestResult* = object
+    suiteName*: string
+      ## Name of the test suite that contains this test case.
+      ## Can be ``nil`` if the test case is not in a suite.
+    testName*: string
+      ## Name of the test case
+    status*: TestStatus
+
+  OutputFormatter* = ref object of RootObj
+
+  ConsoleOutputFormatter* = ref object of OutputFormatter
+    colorOutput: bool
+      ## Have test results printed in color.
+      ## Default is `auto` depending on `isatty(stdout)`, or override it with
+      ## `-d:nimUnittestColor:auto|on|off`.
+      ##
+      ## Deprecated: Setting the environment variable `NIMTEST_COLOR` to `always`
+      ## or `never` changes the default for the non-js target to true or false respectively.
+      ## Deprecated: the environment variable `NIMTEST_NO_COLOR`, when set, changes the
+      ## default to true, if `NIMTEST_COLOR` is undefined.
+    outputLevel: OutputLevel
+      ## Set the verbosity of test results.
+      ## Default is `PRINT_ALL`, or override with:
+      ## `-d:nimUnittestOutputLevel:PRINT_ALL|PRINT_FAILURES|PRINT_NONE`.
+      ##
+      ## Deprecated: the `NIMTEST_OUTPUT_LVL` environment variable is set for the non-js target.
+    isInSuite: bool
+    isInTest: bool
+
+  JUnitOutputFormatter* = ref object of OutputFormatter
+    stream: Stream
+    testErrors: seq[string]
+    testStartTime: float
+    testStackTrace: string
+
+var
+  abortOnError* {.threadvar.}: bool ## Set to true in order to quit
+                                    ## immediately on fail. Default is false,
+                                    ## or override with `-d:nimUnittestAbortOnError:on|off`.
+                                    ##
+                                    ## Deprecated: can also override depending on whether
+                                    ## `NIMTEST_ABORT_ON_ERROR` environment variable is set.
+
+  checkpoints {.threadvar.}: seq[string]
+  formatters {.threadvar.}: seq[OutputFormatter]
+  testsFilters {.threadvar.}: HashSet[string]
+  disabledParamFiltering {.threadvar.}: bool
+
+const
+  outputLevelDefault = PRINT_ALL
+  nimUnittestOutputLevel {.strdefine.} = $outputLevelDefault
+  nimUnittestColor {.strdefine.} = "auto" ## auto|on|off
+  nimUnittestAbortOnError {.booldefine.} = false
+
+template deprecateEnvVarHere() =
+  # xxx issue a runtime warning to deprecate this envvar.
+  discard
+
+abortOnError = nimUnittestAbortOnError
+when declared(stdout):
+  if existsEnv("NIMTEST_ABORT_ON_ERROR"):
+    deprecateEnvVarHere()
+    abortOnError = true
+
+method suiteStarted*(formatter: OutputFormatter, suiteName: string) {.base, gcsafe.} =
+  discard
+method testStarted*(formatter: OutputFormatter, testName: string) {.base, gcsafe.} =
+  discard
+method failureOccurred*(formatter: OutputFormatter, checkpoints: seq[string],
+    stackTrace: string) {.base, gcsafe.} =
+  ## ``stackTrace`` is provided only if the failure occurred due to an exception.
+  ## ``checkpoints`` is never ``nil``.
+  discard
+method testEnded*(formatter: OutputFormatter, testResult: TestResult) {.base, gcsafe.} =
+  discard
+method suiteEnded*(formatter: OutputFormatter) {.base, gcsafe.} =
+  discard
+
+proc addOutputFormatter*(formatter: OutputFormatter) =
+  formatters.add(formatter)
+
+proc delOutputFormatter*(formatter: OutputFormatter) =
+  keepIf(formatters, proc (x: OutputFormatter): bool =
+    x != formatter)
+
+proc resetOutputFormatters* {.since: (1, 1).} =
+  formatters = @[]
+
+proc newConsoleOutputFormatter*(outputLevel: OutputLevel = outputLevelDefault,
+                                colorOutput = true): ConsoleOutputFormatter =
+  ConsoleOutputFormatter(
+    outputLevel: outputLevel,
+    colorOutput: colorOutput
+  )
+
+proc colorOutput(): bool =
+  let color = nimUnittestColor
+  case color
+  of "auto":
+    when declared(stdout): result = isatty(stdout)
+    else: result = false
+  of "on": result = true
+  of "off": result = false
+  else: raiseAssert $color
+
+  when declared(stdout):
+    if existsEnv("NIMTEST_COLOR"):
+      deprecateEnvVarHere()
+      let colorEnv = getEnv("NIMTEST_COLOR")
+      if colorEnv == "never":
+        result = false
+      elif colorEnv == "always":
+        result = true
+    elif existsEnv("NIMTEST_NO_COLOR"):
+      deprecateEnvVarHere()
+      result = false
+
+proc defaultConsoleFormatter*(): ConsoleOutputFormatter =
+  var colorOutput = colorOutput()
+  var outputLevel = nimUnittestOutputLevel.parseEnum[:OutputLevel]
+  when declared(stdout):
+    const a = "NIMTEST_OUTPUT_LVL"
+    if existsEnv(a):
+      # xxx issue a warning to deprecate this envvar.
+      outputLevel = getEnv(a).parseEnum[:OutputLevel]
+  result = newConsoleOutputFormatter(outputLevel, colorOutput)
+
+method suiteStarted*(formatter: ConsoleOutputFormatter, suiteName: string) =
+  template rawPrint() = echo("\n[Suite] ", suiteName)
+  when useTerminal:
+    if formatter.colorOutput:
+      styledEcho styleBright, fgBlue, "\n[Suite] ", resetStyle, suiteName
+    else: rawPrint()
+  else: rawPrint()
+  formatter.isInSuite = true
+
+method testStarted*(formatter: ConsoleOutputFormatter, testName: string) =
+  formatter.isInTest = true
+
+method failureOccurred*(formatter: ConsoleOutputFormatter,
+                        checkpoints: seq[string], stackTrace: string) =
+  if stackTrace.len > 0:
+    echo stackTrace
+  let prefix = if formatter.isInSuite: "    " else: ""
+  for msg in items(checkpoints):
+    echo prefix, msg
+
+method testEnded*(formatter: ConsoleOutputFormatter, testResult: TestResult) =
+  formatter.isInTest = false
+
+  if formatter.outputLevel != OutputLevel.PRINT_NONE and
+      (formatter.outputLevel == OutputLevel.PRINT_ALL or testResult.status == TestStatus.FAILED):
+    let prefix = if testResult.suiteName.len > 0: "  " else: ""
+    template rawPrint() = echo(prefix, "[", $testResult.status, "] ",
+        testResult.testName)
+    when useTerminal:
+      if formatter.colorOutput:
+        var color = case testResult.status
+          of TestStatus.OK: fgGreen
+          of TestStatus.FAILED: fgRed
+          of TestStatus.SKIPPED: fgYellow
+        styledEcho styleBright, color, prefix, "[", $testResult.status, "] ",
+            resetStyle, testResult.testName
+      else:
+        rawPrint()
+    else:
+      rawPrint()
+
+method suiteEnded*(formatter: ConsoleOutputFormatter) =
+  formatter.isInSuite = false
+
+proc xmlEscape(s: string): string =
+  result = newStringOfCap(s.len)
+  for c in items(s):
+    case c:
+    of '<': result.add("&lt;")
+    of '>': result.add("&gt;")
+    of '&': result.add("&amp;")
+    of '"': result.add("&quot;")
+    of '\'': result.add("&apos;")
+    else:
+      if ord(c) < 32:
+        result.add("&#" & $ord(c) & ';')
+      else:
+        result.add(c)
+
+proc newJUnitOutputFormatter*(stream: Stream): JUnitOutputFormatter =
+  ## Creates a formatter that writes report to the specified stream in
+  ## JUnit format.
+  ## The ``stream`` is NOT closed automatically when the test are finished,
+  ## because the formatter has no way to know when all tests are finished.
+  ## You should invoke formatter.close() to finalize the report.
+  result = JUnitOutputFormatter(
+    stream: stream,
+    testErrors: @[],
+    testStackTrace: "",
+    testStartTime: 0.0
+  )
+  stream.writeLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
+  stream.writeLine("<testsuites>")
+
+proc close*(formatter: JUnitOutputFormatter) =
+  ## Completes the report and closes the underlying stream.
+  formatter.stream.writeLine("</testsuites>")
+  formatter.stream.close()
+
+method suiteStarted*(formatter: JUnitOutputFormatter, suiteName: string) =
+  formatter.stream.writeLine("\t<testsuite name=\"$1\">" % xmlEscape(suiteName))
+
+method testStarted*(formatter: JUnitOutputFormatter, testName: string) =
+  formatter.testErrors.setLen(0)
+  formatter.testStackTrace.setLen(0)
+  formatter.testStartTime = epochTime()
+
+method failureOccurred*(formatter: JUnitOutputFormatter,
+                        checkpoints: seq[string], stackTrace: string) =
+  ## ``stackTrace`` is provided only if the failure occurred due to an exception.
+  ## ``checkpoints`` is never ``nil``.
+  formatter.testErrors.add(checkpoints)
+  if stackTrace.len > 0:
+    formatter.testStackTrace = stackTrace
+
+method testEnded*(formatter: JUnitOutputFormatter, testResult: TestResult) =
+  let time = epochTime() - formatter.testStartTime
+  let timeStr = time.formatFloat(ffDecimal, precision = 8)
+  formatter.stream.writeLine("\t\t<testcase name=\"$#\" time=\"$#\">" % [
+      xmlEscape(testResult.testName), timeStr])
+  case testResult.status
+  of TestStatus.OK:
+    discard
+  of TestStatus.SKIPPED:
+    formatter.stream.writeLine("<skipped />")
+  of TestStatus.FAILED:
+    let failureMsg = if formatter.testStackTrace.len > 0 and
+                        formatter.testErrors.len > 0:
+                       xmlEscape(formatter.testErrors[^1])
+                     elif formatter.testErrors.len > 0:
+                       xmlEscape(formatter.testErrors[0])
+                     else: "The test failed without outputting an error"
+
+    var errs = ""
+    if formatter.testErrors.len > 1:
+      var startIdx = if formatter.testStackTrace.len > 0: 0 else: 1
+      var endIdx = if formatter.testStackTrace.len > 0:
+          formatter.testErrors.len - 2
+        else: formatter.testErrors.len - 1
+
+      for errIdx in startIdx..endIdx:
+        if errs.len > 0:
+          errs.add("\n")
+        errs.add(xmlEscape(formatter.testErrors[errIdx]))
+
+    if formatter.testStackTrace.len > 0:
+      formatter.stream.writeLine("\t\t\t<error message=\"$#\">$#</error>" % [
+          failureMsg, xmlEscape(formatter.testStackTrace)])
+      if errs.len > 0:
+        formatter.stream.writeLine("\t\t\t<system-err>$#</system-err>" % errs)
+    else:
+      formatter.stream.writeLine("\t\t\t<failure message=\"$#\">$#</failure>" %
+          [failureMsg, errs])
+
+  formatter.stream.writeLine("\t\t</testcase>")
+
+method suiteEnded*(formatter: JUnitOutputFormatter) =
+  formatter.stream.writeLine("\t</testsuite>")
+
+proc glob(matcher, filter: string): bool =
+  ## Globbing using a single `*`. Empty `filter` matches everything.
+  if filter.len == 0:
+    return true
+
+  if not filter.contains('*'):
+    return matcher == filter
+
+  let beforeAndAfter = filter.split('*', maxsplit = 1)
+  if beforeAndAfter.len == 1:
+    # "foo*"
+    return matcher.startsWith(beforeAndAfter[0])
+
+  if matcher.len < filter.len - 1:
+    return false # "12345" should not match "123*345"
+
+  return matcher.startsWith(beforeAndAfter[0]) and matcher.endsWith(
+      beforeAndAfter[1])
+
+proc matchFilter(suiteName, testName, filter: string): bool =
+  if filter == "":
+    return true
+  if testName == filter:
+    # corner case for tests containing "::" in their name
+    return true
+  let suiteAndTestFilters = filter.split("::", maxsplit = 1)
+
+  if suiteAndTestFilters.len == 1:
+    # no suite specified
+    let testFilter = suiteAndTestFilters[0]
+    return glob(testName, testFilter)
+
+  return glob(suiteName, suiteAndTestFilters[0]) and
+         glob(testName, suiteAndTestFilters[1])
+
+proc shouldRun(currentSuiteName, testName: string): bool =
+  ## Check if a test should be run by matching suiteName and testName against
+  ## test filters.
+  if testsFilters.len == 0:
+    return true
+
+  for f in testsFilters:
+    if matchFilter(currentSuiteName, testName, f):
+      return true
+
+  return false
+
+proc ensureInitialized() =
+  if formatters.len == 0:
+    formatters = @[OutputFormatter(defaultConsoleFormatter())]
+
+  if not disabledParamFiltering:
+    when declared(paramCount):
+      # Read tests to run from the command line.
+      for i in 1 .. paramCount():
+        testsFilters.incl(paramStr(i))
+
+# These two procs are added as workarounds for
+# https://github.com/nim-lang/Nim/issues/5549
+proc suiteEnded() =
+  for formatter in formatters:
+    formatter.suiteEnded()
+
+proc testEnded(testResult: TestResult) =
+  for formatter in formatters:
+    formatter.testEnded(testResult)
+
+template suite*(name, body) {.dirty.} =
+  ## Declare a test suite identified by `name` with optional ``setup``
+  ## and/or ``teardown`` section.
+  ##
+  ## A test suite is a series of one or more related tests sharing a
+  ## common fixture (``setup``, ``teardown``). The fixture is executed
+  ## for EACH test.
+  ##
+  ##   ```nim
+  ##   suite "test suite for addition":
+  ##     setup:
+  ##       let result = 4
+  ##
+  ##     test "2 + 2 = 4":
+  ##       check(2+2 == result)
+  ##
+  ##     test "(2 + -2) != 4":
+  ##       check(2 + -2 != result)
+  ##
+  ##     # No teardown needed
+  ##   ```
+  ##
+  ## The suite will run the individual test cases in the order in which
+  ## they were listed. With default global settings the above code prints:
+  ##
+  ##     [Suite] test suite for addition
+  ##       [OK] 2 + 2 = 4
+  ##       [OK] (2 + -2) != 4
+  bind formatters, ensureInitialized, suiteEnded
+
+  block:
+    template setup(setupBody: untyped) {.dirty, used.} =
+      var testSetupIMPLFlag {.used.} = true
+      template testSetupIMPL: untyped {.dirty.} = setupBody
+
+    template teardown(teardownBody: untyped) {.dirty, used.} =
+      var testTeardownIMPLFlag {.used.} = true
+      template testTeardownIMPL: untyped {.dirty.} = teardownBody
+
+    let testSuiteName {.used.} = name
+
+    ensureInitialized()
+    try:
+      for formatter in formatters:
+        formatter.suiteStarted(name)
+      body
+    finally:
+      suiteEnded()
+
+proc exceptionTypeName(e: ref Exception): string {.inline.} =
+  if e == nil: "<foreign exception>"
+  else: $e.name
+
+when not declared(setProgramResult):
+  {.warning: "setProgramResult not available on platform, unittest will not" &
+    " give failing exit code on test failure".}
+  template setProgramResult(a: int) =
+    discard
+
+template test*(name, body) {.dirty.} =
+  ## Define a single test case identified by `name`.
+  ##
+  ##   ```nim
+  ##   test "roses are red":
+  ##     let roses = "red"
+  ##     check(roses == "red")
+  ##   ```
+  ##
+  ## The above code outputs:
+  ##
+  ##     [OK] roses are red
+  bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded, exceptionTypeName, setProgramResult
+
+  ensureInitialized()
+
+  if shouldRun(when declared(testSuiteName): testSuiteName else: "", name):
+    checkpoints = @[]
+    var testStatusIMPL {.inject.} = TestStatus.OK
+
+    for formatter in formatters:
+      formatter.testStarted(name)
+
+    {.push warning[BareExcept]:off.}
+    try:
+      when declared(testSetupIMPLFlag): testSetupIMPL()
+      when declared(testTeardownIMPLFlag):
+        defer: testTeardownIMPL()
+      {.push warning[BareExcept]:on.}
+      body
+      {.pop.}
+
+    except:
+      let e = getCurrentException()
+      let eTypeDesc = "[" & exceptionTypeName(e) & "]"
+      checkpoint("Unhandled exception: " & getCurrentExceptionMsg() & " " & eTypeDesc)
+      if e == nil: # foreign
+        fail()
+      else:
+        var stackTrace {.inject.} = e.getStackTrace()
+        fail()
+
+    finally:
+      if testStatusIMPL == TestStatus.FAILED:
+        setProgramResult 1
+      let testResult = TestResult(
+        suiteName: when declared(testSuiteName): testSuiteName else: "",
+        testName: name,
+        status: testStatusIMPL
+      )
+      testEnded(testResult)
+      checkpoints = @[]
+    {.pop.}
+
+proc checkpoint*(msg: string) =
+  ## Set a checkpoint identified by `msg`. Upon test failure all
+  ## checkpoints encountered so far are printed out. Example:
+  ##
+  ##   ```nim
+  ##   checkpoint("Checkpoint A")
+  ##   check((42, "the Answer to life and everything") == (1, "a"))
+  ##   checkpoint("Checkpoint B")
+  ##   ```
+  ##
+  ## outputs "Checkpoint A" once it fails.
+  checkpoints.add(msg)
+  # TODO: add support for something like SCOPED_TRACE from Google Test
+
+template fail* =
+  ## Print out the checkpoints encountered so far and quit if ``abortOnError``
+  ## is true. Otherwise, erase the checkpoints and indicate the test has
+  ## failed (change exit code and test status). This template is useful
+  ## for debugging, but is otherwise mostly used internally. Example:
+  ##
+  ##   ```nim
+  ##   checkpoint("Checkpoint A")
+  ##   complicatedProcInThread()
+  ##   fail()
+  ##   ```
+  ##
+  ## outputs "Checkpoint A" before quitting.
+  bind ensureInitialized, setProgramResult
+  when declared(testStatusIMPL):
+    testStatusIMPL = TestStatus.FAILED
+  else:
+    setProgramResult 1
+
+  ensureInitialized()
+
+    # var stackTrace: string = nil
+  for formatter in formatters:
+    when declared(stackTrace):
+      formatter.failureOccurred(checkpoints, stackTrace)
+    else:
+      formatter.failureOccurred(checkpoints, "")
+
+  if abortOnError: quit(1)
+
+  checkpoints = @[]
+
+template skip* =
+  ## Mark the test as skipped. Should be used directly
+  ## in case when it is not possible to perform test
+  ## for reasons depending on outer environment,
+  ## or certain application logic conditions or configurations.
+  ## The test code is still executed.
+  ##   ```nim
+  ##   if not isGLContextCreated():
+  ##     skip()
+  ##   ```
+  bind checkpoints
+
+  testStatusIMPL = TestStatus.SKIPPED
+  checkpoints = @[]
+
+macro check*(conditions: untyped): untyped =
+  ## Verify if a statement or a list of statements is true.
+  ## A helpful error message and set checkpoints are printed out on
+  ## failure (if ``outputLevel`` is not ``PRINT_NONE``).
+  runnableExamples:
+    import std/strutils
+
+    check("AKB48".toLowerAscii() == "akb48")
+
+    let teams = {'A', 'K', 'B', '4', '8'}
+
+    check:
+      "AKB48".toLowerAscii() == "akb48"
+      'C' notin teams
+
+  let checked = callsite()[1]
+
+  template asgn(a: untyped, value: typed) =
+    var a = value # XXX: we need "var: var" here in order to
+                  # preserve the semantics of var params
+
+  template print(name: untyped, value: typed) =
+    when compiles(string($value)):
+      checkpoint(name & " was " & $value)
+
+  proc inspectArgs(exp: NimNode): tuple[assigns, check, printOuts: NimNode] =
+    result.check = copyNimTree(exp)
+    result.assigns = newNimNode(nnkStmtList)
+    result.printOuts = newNimNode(nnkStmtList)
+
+    var counter = 0
+
+    if exp[0].kind in {nnkIdent, nnkOpenSymChoice, nnkClosedSymChoice, nnkSym} and
+        $exp[0] in ["not", "in", "notin", "==", "<=",
+                    ">=", "<", ">", "!=", "is", "isnot"]:
+
+      for i in 1 ..< exp.len:
+        if exp[i].kind notin nnkLiterals:
+          inc counter
+          let argStr = exp[i].toStrLit
+          let paramAst = exp[i]
+          if exp[i].kind == nnkIdent:
+            result.printOuts.add getAst(print(argStr, paramAst))
+          if exp[i].kind in nnkCallKinds + {nnkDotExpr, nnkBracketExpr, nnkPar} and
+                  (exp[i].typeKind notin {ntyTypeDesc} or $exp[0] notin ["is", "isnot"]):
+            let callVar = newIdentNode(":c" & $counter)
+            result.assigns.add getAst(asgn(callVar, paramAst))
+            result.check[i] = callVar
+            result.printOuts.add getAst(print(argStr, callVar))
+          if exp[i].kind == nnkExprEqExpr:
+            # ExprEqExpr
+            #   Ident "v"
+            #   IntLit 2
+            result.check[i] = exp[i][1]
+          if exp[i].typeKind notin {ntyTypeDesc}:
+            let arg = newIdentNode(":p" & $counter)
+            result.assigns.add getAst(asgn(arg, paramAst))
+            result.printOuts.add getAst(print(argStr, arg))
+            if exp[i].kind != nnkExprEqExpr:
+              result.check[i] = arg
+            else:
+              result.check[i][1] = arg
+
+  case checked.kind
+  of nnkCallKinds:
+
+    let (assigns, check, printOuts) = inspectArgs(checked)
+    let lineinfo = newStrLitNode(checked.lineInfo)
+    let callLit = checked.toStrLit
+    result = quote do:
+      block:
+        `assigns`
+        if `check`:
+          discard
+        else:
+          checkpoint(`lineinfo` & ": Check failed: " & `callLit`)
+          `printOuts`
+          fail()
+
+  of nnkStmtList:
+    result = newNimNode(nnkStmtList)
+    for node in checked:
+      if node.kind != nnkCommentStmt:
+        result.add(newCall(newIdentNode("check"), node))
+
+  else:
+    let lineinfo = newStrLitNode(checked.lineInfo)
+    let callLit = checked.toStrLit
+
+    result = quote do:
+      if `checked`:
+        discard
+      else:
+        checkpoint(`lineinfo` & ": Check failed: " & `callLit`)
+        fail()
+
+template require*(conditions: untyped) =
+  ## Same as `check` except any failed test causes the program to quit
+  ## immediately. Any teardown statements are not executed and the failed
+  ## test output is not generated.
+  let savedAbortOnError = abortOnError
+  block:
+    abortOnError = true
+    check conditions
+  abortOnError = savedAbortOnError
+
+macro expect*(exceptions: varargs[typed], body: untyped): untyped =
+  ## Test if `body` raises an exception found in the passed `exceptions`.
+  ## The test passes if the raised exception is part of the acceptable
+  ## exceptions. Otherwise, it fails.
+  runnableExamples:
+    import std/[math, random, strutils]
+    proc defectiveRobot() =
+      randomize()
+      case rand(1..4)
+      of 1: raise newException(OSError, "CANNOT COMPUTE!")
+      of 2: discard parseInt("Hello World!")
+      of 3: raise newException(IOError, "I can't do that Dave.")
+      else: assert 2 + 2 == 5
+
+    expect IOError, OSError, ValueError, AssertionDefect:
+      defectiveRobot()
+
+  template expectBody(errorTypes, lineInfoLit, body): NimNode {.dirty.} =
+    {.push warning[BareExcept]:off.}
+    try:
+      {.push warning[BareExcept]:on.}
+      body
+      {.pop.}
+      checkpoint(lineInfoLit & ": Expect Failed, no exception was thrown.")
+      fail()
+    except errorTypes:
+      discard
+    except:
+      let err = getCurrentException()
+      checkpoint(lineInfoLit & ": Expect Failed, " & $err.name & " was thrown.")
+      fail()
+    {.pop.}
+
+  var errorTypes = newNimNode(nnkBracket)
+  for exp in exceptions:
+    errorTypes.add(exp)
+
+  result = getAst(expectBody(errorTypes, errorTypes.lineInfo, body))
+
+proc disableParamFiltering* =
+  ## disables filtering tests with the command line params
+  disabledParamFiltering = true
diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim
new file mode 100644
index 000000000..725d5bbd9
--- /dev/null
+++ b/lib/pure/uri.nim
@@ -0,0 +1,572 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Dominik Picheta
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements URI parsing as specified by RFC 3986.
+##
+## A Uniform Resource Identifier (URI) provides a simple and extensible
+## means for identifying a resource. A URI can be further classified
+## as a locator, a name, or both. The term "Uniform Resource Locator"
+## (URL) refers to the subset of URIs.
+##
+## .. warning:: URI parsers in this module do not perform security validation.
+##
+## # Basic usage
+
+
+## ## Combine URIs
+runnableExamples:
+  let host = parseUri("https://nim-lang.org")
+  assert $host == "https://nim-lang.org"
+  assert $(host / "/blog.html") == "https://nim-lang.org/blog.html"
+  assert $(host / "blog2.html") == "https://nim-lang.org/blog2.html"
+
+## ## Access URI item
+runnableExamples:
+  let res = parseUri("sftp://127.0.0.1:4343")
+  assert isAbsolute(res)
+  assert res.port == "4343"
+
+## ## Data URI Base64
+runnableExamples:
+  assert getDataUri("Hello World", "text/plain") == "data:text/plain;charset=utf-8;base64,SGVsbG8gV29ybGQ="
+  assert getDataUri("Nim", "text/plain") == "data:text/plain;charset=utf-8;base64,Tmlt"
+
+
+import std/[strutils, parseutils, base64]
+import std/private/[since, decode_helpers]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+type
+  Url* = distinct string
+
+  Uri* = object
+    scheme*, username*, password*: string
+    hostname*, port*, path*, query*, anchor*: string
+    opaque*: bool
+    isIpv6*: bool
+
+  UriParseError* = object of ValueError
+
+
+proc uriParseError*(msg: string) {.noreturn.} =
+  ## Raises a `UriParseError` exception with message `msg`.
+  raise newException(UriParseError, msg)
+
+func encodeUrl*(s: string, usePlus = true): string =
+  ## Encodes a URL according to RFC3986.
+  ##
+  ## This means that characters in the set
+  ## `{'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~'}` are
+  ## carried over to the result.
+  ## All other characters are encoded as `%xx` where `xx`
+  ## denotes its hexadecimal value.
+  ##
+  ## As a special rule, when the value of `usePlus` is true,
+  ## spaces are encoded as `+` instead of `%20`.
+  ##
+  ## **See also:**
+  ## * `decodeUrl func<#decodeUrl,string>`_
+  runnableExamples:
+    assert encodeUrl("https://nim-lang.org") == "https%3A%2F%2Fnim-lang.org"
+    assert encodeUrl("https://nim-lang.org/this is a test") == "https%3A%2F%2Fnim-lang.org%2Fthis+is+a+test"
+    assert encodeUrl("https://nim-lang.org/this is a test", false) == "https%3A%2F%2Fnim-lang.org%2Fthis%20is%20a%20test"
+  result = newStringOfCap(s.len + s.len shr 2) # assume 12% non-alnum-chars
+  let fromSpace = if usePlus: "+" else: "%20"
+  for c in s:
+    case c
+    # https://tools.ietf.org/html/rfc3986#section-2.3
+    of 'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~': add(result, c)
+    of ' ': add(result, fromSpace)
+    else:
+      add(result, '%')
+      add(result, toHex(ord(c), 2))
+
+func decodeUrl*(s: string, decodePlus = true): string =
+  ## Decodes a URL according to RFC3986.
+  ##
+  ## This means that any `%xx` (where `xx` denotes a hexadecimal
+  ## value) are converted to the character with ordinal number `xx`,
+  ## and every other character is carried over.
+  ## If `xx` is not a valid hexadecimal value, it is left intact.
+  ##
+  ## As a special rule, when the value of `decodePlus` is true, `+`
+  ## characters are converted to a space.
+  ##
+  ## **See also:**
+  ## * `encodeUrl func<#encodeUrl,string>`_
+  runnableExamples:
+    assert decodeUrl("https%3A%2F%2Fnim-lang.org") == "https://nim-lang.org"
+    assert decodeUrl("https%3A%2F%2Fnim-lang.org%2Fthis+is+a+test") == "https://nim-lang.org/this is a test"
+    assert decodeUrl("https%3A%2F%2Fnim-lang.org%2Fthis%20is%20a%20test",
+        false) == "https://nim-lang.org/this is a test"
+    assert decodeUrl("abc%xyz") == "abc%xyz"
+
+  result = newString(s.len)
+  var i = 0
+  var j = 0
+  while i < s.len:
+    case s[i]
+    of '%':
+      result[j] = decodePercent(s, i)
+    of '+':
+      if decodePlus:
+        result[j] = ' '
+      else:
+        result[j] = s[i]
+    else: result[j] = s[i]
+    inc(i)
+    inc(j)
+  setLen(result, j)
+
+func encodeQuery*(query: openArray[(string, string)], usePlus = true,
+    omitEq = true, sep = '&'): string =
+  ## Encodes a set of (key, value) parameters into a URL query string.
+  ##
+  ## Every (key, value) pair is URL-encoded and written as `key=value`. If the
+  ## value is an empty string then the `=` is omitted, unless `omitEq` is
+  ## false.
+  ## The pairs are joined together by the `sep` character.
+  ##
+  ## The `usePlus` parameter is passed down to the `encodeUrl` function that
+  ## is used for the URL encoding of the string values.
+  ##
+  ## **See also:**
+  ## * `encodeUrl func<#encodeUrl,string>`_
+  runnableExamples:
+    assert encodeQuery({: }) == ""
+    assert encodeQuery({"a": "1", "b": "2"}) == "a=1&b=2"
+    assert encodeQuery({"a": "1", "b": ""}) == "a=1&b"
+    assert encodeQuery({"a": "1", "b": ""}, omitEq = false, sep = ';') == "a=1;b="
+  for elem in query:
+    # Encode the `key = value` pairs and separate them with 'sep'
+    if result.len > 0: result.add(sep)
+    let (key, val) = elem
+    result.add(encodeUrl(key, usePlus))
+    # Omit the '=' if the value string is empty
+    if not omitEq or val.len > 0:
+      result.add('=')
+      result.add(encodeUrl(val, usePlus))
+
+iterator decodeQuery*(data: string, sep = '&'): tuple[key, value: string] =
+  ## Reads and decodes the query string `data` and yields the `(key, value)` pairs
+  ## the data consists of. If compiled with `-d:nimLegacyParseQueryStrict`,
+  ## a `UriParseError` is raised when there is an unencoded `=` character in a decoded
+  ## value, which was the behavior in Nim < 1.5.1.
+  runnableExamples:
+    import std/sequtils
+    assert toSeq(decodeQuery("foo=1&bar=2=3")) == @[("foo", "1"), ("bar", "2=3")]
+    assert toSeq(decodeQuery("foo=1;bar=2=3", ';')) == @[("foo", "1"), ("bar", "2=3")]
+    assert toSeq(decodeQuery("&a&=b&=&&")) == @[("", ""), ("a", ""), ("", "b"), ("", ""), ("", "")]
+
+  proc parseData(data: string, i: int, field: var string, sep: char): int =
+    result = i
+    while result < data.len:
+      let c = data[result]
+      case c
+      of '%': add(field, decodePercent(data, result))
+      of '+': add(field, ' ')
+      of '&': break
+      else:
+        if c == sep: break
+        else: add(field, data[result])
+      inc(result)
+
+  var i = 0
+  var name = ""
+  var value = ""
+  # decode everything in one pass:
+  while i < data.len:
+    setLen(name, 0) # reuse memory
+    i = parseData(data, i, name, '=')
+    setLen(value, 0) # reuse memory
+    if i < data.len and data[i] == '=':
+      inc(i) # skip '='
+      when defined(nimLegacyParseQueryStrict):
+        i = parseData(data, i, value, '=')
+      else:
+        i = parseData(data, i, value, sep)
+    yield (name, value)
+    if i < data.len:
+      when defined(nimLegacyParseQueryStrict):
+        if data[i] != '&':
+          uriParseError("'&' expected at index '$#' for '$#'" % [$i, data])
+      inc(i)
+
+func parseAuthority(authority: string, result: var Uri) =
+  var i = 0
+  var inPort = false
+  var inIPv6 = false
+  while i < authority.len:
+    case authority[i]
+    of '@':
+      swap result.password, result.port
+      result.port.setLen(0)
+      swap result.username, result.hostname
+      result.hostname.setLen(0)
+      inPort = false
+    of ':':
+      if inIPv6:
+        result.hostname.add(authority[i])
+      else:
+        inPort = true
+    of '[':
+      inIPv6 = true
+      result.isIpv6 = true
+    of ']':
+      inIPv6 = false
+    else:
+      if inPort:
+        result.port.add(authority[i])
+      else:
+        result.hostname.add(authority[i])
+    i.inc
+
+func parsePath(uri: string, i: var int, result: var Uri) =
+  i.inc parseUntil(uri, result.path, {'?', '#'}, i)
+
+  # The 'mailto' scheme's PATH actually contains the hostname/username
+  if cmpIgnoreCase(result.scheme, "mailto") == 0:
+    parseAuthority(result.path, result)
+    result.path.setLen(0)
+
+  if i < uri.len and uri[i] == '?':
+    i.inc # Skip '?'
+    i.inc parseUntil(uri, result.query, {'#'}, i)
+
+  if i < uri.len and uri[i] == '#':
+    i.inc # Skip '#'
+    i.inc parseUntil(uri, result.anchor, {}, i)
+
+func initUri*(isIpv6 = false): Uri =
+  ## Initializes a URI with `scheme`, `username`, `password`,
+  ## `hostname`, `port`, `path`, `query`, `anchor` and `isIpv6`.
+  ##
+  ## **See also:**
+  ## * `Uri type <#Uri>`_ for available fields in the URI type
+  runnableExamples:
+    var uri2 = initUri(isIpv6 = true)
+    uri2.scheme = "tcp"
+    uri2.hostname = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
+    uri2.port = "8080"
+    assert $uri2 == "tcp://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8080"
+  result = Uri(scheme: "", username: "", password: "", hostname: "", port: "",
+                path: "", query: "", anchor: "", isIpv6: isIpv6)
+
+func resetUri(uri: var Uri) =
+  for f in uri.fields:
+    when f is string:
+      f.setLen(0)
+    else:
+      f = false
+
+func parseUri*(uri: string, result: var Uri) =
+  ## Parses a URI. The `result` variable will be cleared before.
+  ##
+  ## **See also:**
+  ## * `Uri type <#Uri>`_ for available fields in the URI type
+  ## * `initUri func <#initUri>`_ for initializing a URI
+  runnableExamples:
+    var res = initUri()
+    parseUri("https://nim-lang.org/docs/manual.html", res)
+    assert res.scheme == "https"
+    assert res.hostname == "nim-lang.org"
+    assert res.path == "/docs/manual.html"
+  resetUri(result)
+
+  var i = 0
+
+  # Check if this is a reference URI (relative URI)
+  let doubleSlash = uri.len > 1 and uri[0] == '/' and uri[1] == '/'
+  if i < uri.len and uri[i] == '/':
+    # Make sure `uri` doesn't begin with '//'.
+    if not doubleSlash:
+      parsePath(uri, i, result)
+      return
+
+  # Scheme
+  i.inc parseWhile(uri, result.scheme, Letters + Digits + {'+', '-', '.'}, i)
+  if (i >= uri.len or uri[i] != ':') and not doubleSlash:
+    # Assume this is a reference URI (relative URI)
+    i = 0
+    result.scheme.setLen(0)
+    parsePath(uri, i, result)
+    return
+  if not doubleSlash:
+    i.inc # Skip ':'
+
+  # Authority
+  if i+1 < uri.len and uri[i] == '/' and uri[i+1] == '/':
+    i.inc(2) # Skip //
+    var authority = ""
+    i.inc parseUntil(uri, authority, {'/', '?', '#'}, i)
+    if authority.len > 0:
+      parseAuthority(authority, result)
+  else:
+    result.opaque = true
+
+  # Path
+  parsePath(uri, i, result)
+
+func parseUri*(uri: string): Uri =
+  ## Parses a URI and returns it.
+  ##
+  ## **See also:**
+  ## * `Uri type <#Uri>`_ for available fields in the URI type
+  runnableExamples:
+    let res = parseUri("ftp://Username:Password@Hostname")
+    assert res.username == "Username"
+    assert res.password == "Password"
+    assert res.scheme == "ftp"
+  result = initUri()
+  parseUri(uri, result)
+
+func removeDotSegments(path: string): string =
+  ## Collapses `..` and `.` in `path` in a similar way as done in `os.normalizedPath`
+  ## Caution: this is buggy.
+  runnableExamples:
+    assert removeDotSegments("a1/a2/../a3/a4/a5/./a6/a7/.//./") == "a1/a3/a4/a5/a6/a7/"
+    assert removeDotSegments("http://www.ai.") == "http://www.ai."
+  # xxx adapt or reuse `pathnorm.normalizePath(path, '/')` to make this more reliable, but
+  # taking into account url specificities such as not collapsing leading `//` in scheme
+  # `https://`. see `turi` for failing tests.
+  if path.len == 0: return ""
+  var collection: seq[string] = @[]
+  let endsWithSlash = path.endsWith '/'
+  var i = 0
+  var currentSegment = ""
+  while i < path.len:
+    case path[i]
+    of '/':
+      collection.add(currentSegment)
+      currentSegment = ""
+    of '.':
+      if i+2 < path.len and path[i+1] == '.' and path[i+2] == '/':
+        if collection.len > 0:
+          discard collection.pop()
+          i.inc 3
+          continue
+      elif i + 1 < path.len and path[i+1] == '/':
+        i.inc 2
+        continue
+      currentSegment.add path[i]
+    else:
+      currentSegment.add path[i]
+    i.inc
+  if currentSegment != "":
+    collection.add currentSegment
+
+  result = collection.join("/")
+  if endsWithSlash: result.add '/'
+
+func merge(base, reference: Uri): string =
+  # http://tools.ietf.org/html/rfc3986#section-5.2.3
+  if base.hostname != "" and base.path == "":
+    '/' & reference.path
+  else:
+    let lastSegment = rfind(base.path, "/")
+    if lastSegment == -1:
+      reference.path
+    else:
+      base.path[0 .. lastSegment] & reference.path
+
+func combine*(base: Uri, reference: Uri): Uri =
+  ## Combines a base URI with a reference URI.
+  ##
+  ## This uses the algorithm specified in
+  ## `section 5.2.2 of RFC 3986 <http://tools.ietf.org/html/rfc3986#section-5.2.2>`_.
+  ##
+  ## This means that the slashes inside the base URIs path as well as reference
+  ## URIs path affect the resulting URI.
+  ##
+  ## **See also:**
+  ## * `/ func <#/,Uri,string>`_ for building URIs
+  runnableExamples:
+    let foo = combine(parseUri("https://nim-lang.org/foo/bar"), parseUri("/baz"))
+    assert foo.path == "/baz"
+    let bar = combine(parseUri("https://nim-lang.org/foo/bar"), parseUri("baz"))
+    assert bar.path == "/foo/baz"
+    let qux = combine(parseUri("https://nim-lang.org/foo/bar/"), parseUri("baz"))
+    assert qux.path == "/foo/bar/baz"
+
+  template setAuthority(dest, src): untyped =
+    dest.hostname = src.hostname
+    dest.username = src.username
+    dest.port = src.port
+    dest.password = src.password
+
+  result = initUri()
+  if reference.scheme != base.scheme and reference.scheme != "":
+    result = reference
+    result.path = removeDotSegments(result.path)
+  else:
+    if reference.hostname != "":
+      setAuthority(result, reference)
+      result.path = removeDotSegments(reference.path)
+      result.query = reference.query
+    else:
+      if reference.path == "":
+        result.path = base.path
+        if reference.query != "":
+          result.query = reference.query
+        else:
+          result.query = base.query
+      else:
+        if reference.path.startsWith("/"):
+          result.path = removeDotSegments(reference.path)
+        else:
+          result.path = removeDotSegments(merge(base, reference))
+        result.query = reference.query
+      setAuthority(result, base)
+    result.scheme = base.scheme
+  result.anchor = reference.anchor
+
+func combine*(uris: varargs[Uri]): Uri =
+  ## Combines multiple URIs together.
+  ##
+  ## **See also:**
+  ## * `/ func <#/,Uri,string>`_ for building URIs
+  runnableExamples:
+    let foo = combine(parseUri("https://nim-lang.org/"), parseUri("docs/"),
+        parseUri("manual.html"))
+    assert foo.hostname == "nim-lang.org"
+    assert foo.path == "/docs/manual.html"
+  result = uris[0]
+  for i in 1 ..< uris.len:
+    result = combine(result, uris[i])
+
+func isAbsolute*(uri: Uri): bool =
+  ## Returns true if URI is absolute, false otherwise.
+  runnableExamples:
+    assert parseUri("https://nim-lang.org").isAbsolute
+    assert not parseUri("nim-lang").isAbsolute
+  return uri.scheme != "" and (uri.hostname != "" or uri.path != "")
+
+func `/`*(x: Uri, path: string): Uri =
+  ## Concatenates the path specified to the specified URIs path.
+  ##
+  ## Contrary to the `combine func <#combine,Uri,Uri>`_ you do not have to worry about
+  ## the slashes at the beginning and end of the path and URIs path
+  ## respectively.
+  ##
+  ## **See also:**
+  ## * `combine func <#combine,Uri,Uri>`_
+  runnableExamples:
+    let foo = parseUri("https://nim-lang.org/foo/bar") / "/baz"
+    assert foo.path == "/foo/bar/baz"
+    let bar = parseUri("https://nim-lang.org/foo/bar") / "baz"
+    assert bar.path == "/foo/bar/baz"
+    let qux = parseUri("https://nim-lang.org/foo/bar/") / "baz"
+    assert qux.path == "/foo/bar/baz"
+  result = x
+
+  if result.path.len == 0:
+    if path.len == 0 or path[0] != '/':
+      result.path = "/"
+    result.path.add(path)
+    return
+
+  if result.path.len > 0 and result.path[result.path.len-1] == '/':
+    if path.len > 0 and path[0] == '/':
+      result.path.add(path[1 .. path.len-1])
+    else:
+      result.path.add(path)
+  else:
+    if path.len == 0 or path[0] != '/':
+      result.path.add '/'
+    result.path.add(path)
+
+func `?`*(u: Uri, query: openArray[(string, string)]): Uri =
+  ## Concatenates the query parameters to the specified URI object.
+  runnableExamples:
+    let foo = parseUri("https://example.com") / "foo" ? {"bar": "qux"}
+    assert $foo == "https://example.com/foo?bar=qux"
+  result = u
+  result.query = encodeQuery(query)
+
+func `$`*(u: Uri): string =
+  ## Returns the string representation of the specified URI object.
+  runnableExamples:
+    assert $parseUri("https://nim-lang.org") == "https://nim-lang.org"
+  # Get the len of all the parts.
+  let schemeLen = u.scheme.len
+  let usernameLen = u.username.len
+  let passwordLen = u.password.len
+  let hostnameLen = u.hostname.len
+  let portLen = u.port.len
+  let pathLen = u.path.len
+  let queryLen = u.query.len
+  let anchorLen = u.anchor.len
+  # Prepare a string that fits all the parts and all punctuation chars.
+  # 12 is the max len required by all possible punctuation chars.
+  result = newStringOfCap(
+    schemeLen + usernameLen + passwordLen + hostnameLen + portLen + pathLen + queryLen + anchorLen + 12
+  )
+  # Insert to result.
+  if schemeLen > 0:
+    result.add u.scheme
+    result.add ':'
+    if not u.opaque:
+      result.add '/'
+      result.add '/'
+  if usernameLen > 0:
+    result.add u.username
+    if passwordLen > 0:
+      result.add ':'
+      result.add u.password
+    result.add '@'
+  if u.hostname.endsWith('/'):
+    if u.isIpv6:
+      result.add '['
+      result.add u.hostname[0 .. ^2]
+      result.add ']'
+    else:
+      result.add u.hostname[0 .. ^2]
+  else:
+    if u.isIpv6:
+      result.add '['
+      result.add u.hostname
+      result.add ']'
+    else:
+      result.add u.hostname
+  if portLen > 0:
+    result.add ':'
+    result.add u.port
+  if pathLen > 0:
+    if hostnameLen > 0 and u.path[0] != '/':
+      result.add '/'
+    result.add u.path
+  if queryLen > 0:
+    result.add '?'
+    result.add u.query
+  if anchorLen > 0:
+    result.add '#'
+    result.add u.anchor
+
+
+proc getDataUri*(data, mime: string, encoding = "utf-8"): string {.since: (1, 3).} =
+  ## Convenience proc for `base64.encode` returns a standard Base64 Data URI (RFC-2397)
+  ##
+  ## **See also:**
+  ## * `mimetypes <mimetypes.html>`_ for `mime` argument
+  ## * https://tools.ietf.org/html/rfc2397
+  ## * https://en.wikipedia.org/wiki/Data_URI_scheme
+  runnableExamples: static: assert getDataUri("Nim", "text/plain") == "data:text/plain;charset=utf-8;base64,Tmlt"
+  assert encoding.len > 0 and mime.len > 0 # Must *not* be URL-Safe, see RFC-2397
+  let base64encoded: string = base64.encode(data)
+  # ("data:".len + ";charset=".len + ";base64,".len) == 22
+  result = newStringOfCap(22 + mime.len + encoding.len + base64encoded.len)
+  result.add "data:"
+  result.add mime
+  result.add ";charset="
+  result.add encoding
+  result.add ";base64,"
+  result.add base64encoded
diff --git a/lib/pure/variants.nim b/lib/pure/variants.nim
deleted file mode 100755
index 0b4f078e7..000000000
--- a/lib/pure/variants.nim
+++ /dev/null
@@ -1,181 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements Nimrod's support for the ``variant`` datatype.
-## `TVariant` shows how the flexibility of dynamic typing is achieved
-## within a static type system. 
-
-type
-  TVarType* = enum
-    vtNone,
-    vtBool, 
-    vtChar,
-    vtEnum,
-    vtInt,
-    vtFloat,
-    vtString,
-    vtSet,
-    vtSeq,
-    vtDict
-  TVariant* {.final.} = object of TObject
-    case vtype: TVarType
-    of vtNone: nil
-    of vtBool, vtChar, vtEnum, vtInt: vint: int64
-    of vtFloat: vfloat: float64
-    of vtString: vstring: string
-    of vtSet, vtSeq: q: seq[TVariant]
-    of vtDict: d: seq[tuple[key, val: TVariant]]
-    
-iterator objectFields*[T](x: T, skipInherited: bool): tuple[
-  key: string, val: TVariant] {.magic: "ObjectFields"}
-
-proc `?`*(x: ordinal): TVariant =
-  result.kind = vtEnum
-  result.vint = x
-
-proc `?`*(x: biggestInt): TVariant =
-  result.kind = vtInt
-  result.vint = x
-
-proc `?`*(x: char): TVariant =
-  result.kind = vtChar
-  result.vint = ord(x)
-
-proc `?`*(x: bool): TVariant =
-  result.kind = vtBool
-  result.vint = ord(x)
-
-proc `?`*(x: biggestFloat): TVariant =
-  result.kind = vtFloat
-  result.vfloat = x
-
-proc `?`*(x: string): TVariant =
-  result.kind = vtString
-  result.vstring = x
-
-proc `?`*[T](x: openArray[T]): TVariant =
-  result.kind = vtSeq
-  newSeq(result.q, x.len)
-  for i in 0..x.len-1: result.q[i] = <>x[i]
-
-proc `?`*[T](x: set[T]): TVariant =
-  result.kind = vtSet
-  result.q = @[]
-  for a in items(x): result.q.add(<>a)
-
-proc `?`* [T: object](x: T): TVariant {.magic: "ToVariant".}
-  ## this converts a value to a variant ("boxing")
-
-proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
-
-?[?5, ?67, ?"hallo"]
-myVar?int
-
-  
-proc `==`* (x, y: TVariant): bool =
-  if x.vtype == y.vtype:
-    case x.vtype
-    of vtNone: result = true
-    of vtBool, vtChar, vtEnum, vtInt: result = x.vint == y.vint
-    of vtFloat: result = x.vfloat == y.vfloat
-    of vtString: result = x.vstring == y.vstring
-    of vtSet:
-      # complicated! We check that each a in x also occurs in y and that the
-      # counts are identical:
-      if x.q.len == y.q.len:
-        for a in items(x.q):
-          block inner:
-            for b in items(y.q):
-              if a == b: break inner
-            return false
-        result = true
-    of vtSeq:
-      if x.q.len == y.q.len:
-        for i in 0..x.q.len-1:
-          if x.q[i] != y.q[i]: return false
-        result = true
-    of vtDict:
-      # it is an ordered dict:
-      if x.d.len == y.d.len:
-        for i in 0..x.d.len-1:
-          if x.d[i].key != y.d[i].key: return false
-          if x.d[i].val != y.d[i].val: return false
-        result = true
-
-proc `[]`* (a, b: TVariant): TVariant =
-  case a.vtype
-  of vtSeq:
-    if b.vtype in {vtBool, vtChar, vtEnum, vtInt}:
-      result = a.q[b.vint]
-    else:
-      variantError()
-  of vtDict:
-    for i in 0..a.d.len-1:
-      if a.d[i].key == b: return a.d[i].val
-    if b.vtype in {vtBool, vtChar, vtEnum, vtInt}:
-      result = a.d[b.vint].val
-    variantError()
-  else: variantError()
-
-proc `[]=`* (a, b, c: TVariant) =
-  case a.vtype
-  of vtSeq:
-    if b.vtype in {vtBool, vtChar, vtEnum, vtInt}:
-      a.q[b.vint] = b
-    else:
-      variantError()
-  of vtDict:
-    for i in 0..a.d.len-1:
-      if a.d[i].key == b:
-        a.d[i].val = c
-        return
-    if b.vtype in {vtBool, vtChar, vtEnum, vtInt}:
-      a.d[b.vint].val = c
-    variantError()
-  else: variantError()
-  
-proc `[]`* (a: TVariant, b: int): TVariant {.inline} = return a[?b]
-proc `[]`* (a: TVariant, b: string): TVariant {.inline} = return a[?b]
-proc `[]=`* (a: TVariant, b: int, c: TVariant) {.inline} = a[?b] = c
-proc `[]=`* (a: TVariant, b: string, c: TVariant) {.inline} = a[?b] = c
-
-proc `+`* (x, y: TVariant): TVariant =
-  case x.vtype
-  of vtBool, vtChar, vtEnum, vtInt:
-    if y.vtype == x.vtype:
-      result.vtype = x.vtype
-      result.vint = x.vint + y.vint
-    else:
-      case y.vtype
-      of vtBool, vtChar, vtEnum, vtInt:
-        
-    
-    
-    vint: int64
-  of vtFloat: vfloat: float64
-  of vtString: vstring: string
-  of vtSet, vtSeq: q: seq[TVariant]
-  of vtDict: d: seq[tuple[key, val: TVariant]]
-
-proc `-`* (x, y: TVariant): TVariant
-proc `*`* (x, y: TVariant): TVariant
-proc `/`* (x, y: TVariant): TVariant
-proc `div`* (x, y: TVariant): TVariant
-proc `mod`* (x, y: TVariant): TVariant
-proc `&`* (x, y: TVariant): TVariant
-proc `$`* (x: TVariant): string =
-  # uses JS notation
-  
-proc parseVariant*(s: string): TVariant
-proc `<`* (x, y: TVariant): bool
-proc `<=`* (x, y: TVariant): bool
-
-proc hash*(x: TVariant): int =
-  
-
diff --git a/lib/pure/volatile.nim b/lib/pure/volatile.nim
new file mode 100644
index 000000000..a38247c7d
--- /dev/null
+++ b/lib/pure/volatile.nim
@@ -0,0 +1,34 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Jeff Ciesielski
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains code for generating volatile loads and stores,
+## which are useful in embedded and systems programming.
+
+proc volatileLoad*[T](src: ptr T): T {.inline, noinit.} =
+  ## Generates a volatile load of the value stored in the container `src`.
+  ## Note that this only effects code generation on `C` like backends.
+  when nimvm:
+    result = src[]
+  else:
+    when defined(js):
+      result = src[]
+    else:
+      {.emit: [result, " = (*(", typeof(src[]), " volatile*)", src, ");"].}
+
+proc volatileStore*[T](dest: ptr T, val: T) {.inline.} =
+  ## Generates a volatile store into the container `dest` of the value
+  ## `val`. Note that this only effects code generation on `C` like
+  ## backends.
+  when nimvm:
+    dest[] = val
+  else:
+    when defined(js):
+      dest[] = val
+    else:
+      {.emit: ["*((", typeof(dest[]), " volatile*)(", dest, ")) = ", val, ";"].}
diff --git a/lib/pure/xmldom.nim b/lib/pure/xmldom.nim
deleted file mode 100755
index b7ee165f5..000000000
--- a/lib/pure/xmldom.nim
+++ /dev/null
@@ -1,1093 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Dominik Picheta
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-
-import strutils
-## This module implements XML DOM Level 2 Core specification(http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html)
-
-
-#http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html
-
-#Exceptions
-type
-  EDOMException* = object of E_Base ## Base exception object for all DOM Exceptions
-  EDOMStringSizeErr* = object of EDOMException ## If the specified range of text does not fit into a DOMString
-                                               ## Currently not used(Since DOMString is just string)
-  EHierarchyRequestErr* = object of EDOMException ## If any node is inserted somewhere it doesn't belong
-  EIndexSizeErr* = object of EDOMException ## If index or size is negative, or greater than the allowed value
-  EInuseAttributeErr* = object of EDOMException ## If an attempt is made to add an attribute that is already in use elsewhere
-  EInvalidAccessErr* = object of EDOMException ## If a parameter or an operation is not supported by the underlying object.
-  EInvalidCharacterErr* = object of EDOMException ## This exception is raised when a string parameter contains an illegal character
-  EInvalidModificationErr* = object of EDOMException ## If an attempt is made to modify the type of the underlying object.
-  EInvalidStateErr* = object of EDOMException ## If an attempt is made to use an object that is not, or is no longer, usable.
-  ENamespaceErr* = object of EDOMException ## If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
-  ENotFoundErr* = object of EDOMException ## If an attempt is made to reference a node in a context where it does not exist
-  ENotSupportedErr* = object of EDOMException ## If the implementation does not support the requested type of object or operation.
-  ENoDataAllowedErr* = object of EDOMException ## If data is specified for a node which does not support data
-  ENoModificationAllowedErr* = object of EDOMException ## If an attempt is made to modify an object where modifications are not allowed
-  ESyntaxErr* = object of EDOMException ## If an invalid or illegal string is specified.
-  EWrongDocumentErr* = object of EDOMException ## If a node is used in a different document than the one that created it (that doesn't support it)
-
-const
-  ElementNode* = 1
-  AttributeNode* = 2
-  TextNode* = 3
-  CDataSectionNode* = 4
-  ProcessingInstructionNode* = 7
-  CommentNode* = 8
-  DocumentNode* = 9
-  DocumentFragmentNode* = 11
-
-  # Nodes which are childless - Not sure about AttributeNode
-  childlessObjects = {DocumentNode, AttributeNode, TextNode, CDataSectionNode, ProcessingInstructionNode, CommentNode}
-  # Illegal characters
-  illegalChars = {'>', '<', '&', '"'}
-
-
-type
-  Feature = tuple[name: string, version: string]
-  PDOMImplementation* = ref DOMImplementation
-  DOMImplementation = object
-    Features: seq[Feature] # Read-Only
-
-  PNode* = ref Node
-  Node = object
-    attributes*: seq[PAttr]
-    childNodes*: seq[PNode]
-    FLocalName: string # Read-only
-    FNamespaceURI: string # Read-only
-    FNodeName: string # Read-only
-    nodeValue*: string
-    FNodeType: int # Read-only
-    FOwnerDocument: PDocument # Read-Only
-    FParentNode: PNode # Read-Only
-    prefix*: string # Setting this should change some values... TODO!
-  
-  PElement* = ref Element
-  Element = object of Node
-    FTagName: string # Read-only
-  
-  PCharacterData = ref CharacterData
-  CharacterData = object of Node
-    data*: string
-    
-  PDocument* = ref Document
-  Document = object of Node
-    FImplementation: PDOMImplementation # Read-only
-    FDocumentElement: PElement # Read-only
-    
-  PAttr* = ref Attr  
-  Attr = object of Node
-    FName: string # Read-only
-    FSpecified: bool # Read-only
-    value*: string
-    FOwnerElement: PElement # Read-only
-
-  PDocumentFragment* = ref DocumentFragment
-  DocumentFragment = object of Node
-
-  PText* = ref Text
-  Text = object of CharacterData
-  
-  PComment* = ref comment
-  Comment = object of CharacterData
-  
-  PCDataSection* = ref CDataSection
-  CDataSection = object of Text
-    
-  PProcessingInstruction* = ref ProcessingInstruction
-  ProcessingInstruction = object of Node
-    data*: string
-    FTarget: string # Read-only
-
-# DOMImplementation
-proc getDOM*(): PDOMImplementation =
-  ## Returns a DOMImplementation
-  var DOMImpl: PDOMImplementation
-  new(DOMImpl)
-  DOMImpl.Features = @[(name: "core", version: "2.0"), (name: "core", version: "1.0"), (name: "XML", version: "2.0")]
-  return DOMImpl
-
-proc createDocument*(dom: PDOMImplementation, namespaceURI: string, qualifiedName: string): PDocument =
-  ## Creates an XML Document object of the specified type with its document element.
-  var doc: PDocument
-  new(doc)
-  doc.FNamespaceURI = namespaceURI
-  doc.FImplementation = dom
-  
-  var elTag: PElement
-  new(elTag)
-  elTag.FTagName = qualifiedName
-  elTag.FNodeName = qualifiedName
-  doc.FDocumentElement = elTag
-  doc.FNodeType = DocumentNode
-  
-  return doc
-  
-proc createDocument*(dom: PDOMImplementation, n: PElement): PDocument =
-  ## Creates an XML Document object of the specified type with its document element.
-  
-  # This procedure is not in the specification, it's provided for the parser.
-  var doc: PDocument
-  new(doc)
-  doc.FDocumentElement = n
-  doc.FImplementation = dom
-  doc.FNodeType = DocumentNode
-  
-  return doc
-  
-proc hasFeature*(dom: PDOMImplementation, feature: string, version: string = ""): bool =
-  ## Returns ``true`` if this ``version`` of the DomImplementation implements ``feature``, otherwise ``false``
-  for iName, iVersion in items(dom.Features):
-    if iName == feature:
-      if version == "":
-        return True
-      else:
-        if iVersion == version:
-          return True
-  return False
-
-
-# Document
-# Attributes
-  
-proc implementation*(doc: PDocument): PDOMImplementation =
-  return doc.FImplementation
-  
-proc documentElement*(doc: PDocument): PElement = 
-  return doc.FDocumentElement
-
-# Internal procedures
-proc findNodes(nl: PNode, name: string): seq[PNode] =
-  # Made for getElementsByTagName
-  var r: seq[PNode] = @[]
-  if nl.childNodes == nil: return @[]
-  if nl.childNodes.len() == 0: return @[]
-
-  for i in items(nl.childNodes):
-    if i.FNodeType == ElementNode:
-      if i.FNodeName == name or name == "*":
-        r.add(i)
-        
-      if i.childNodes != nil:
-        if i.childNodes.len() != 0:
-          r.add(findNodes(i, name))
-    
-  return r
-  
-proc findNodesNS(nl: PNode, namespaceURI: string, localName: string): seq[PNode] =
-  # Made for getElementsByTagNameNS
-  var r: seq[PNode] = @[]
-  if nl.childNodes == nil: return @[]
-  if nl.childNodes.len() == 0: return @[]
-
-  for i in items(nl.childNodes):
-    if i.FNodeType == ElementNode:
-      if (i.FNamespaceURI == namespaceURI or namespaceURI == "*") and (i.FLocalName == localName or localName == "*"):
-        r.add(i)
-        
-      if i.childNodes != nil:
-        if i.childNodes.len() != 0:
-          r.add(findNodesNS(i, namespaceURI, localName))
-    
-  return r
-    
-
-#Procedures
-proc createAttribute*(doc: PDocument, name: string): PAttr =
-  ## Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
-  ## To create an attribute with a qualified name and namespace URI, use the createAttributeNS method. 
-  
-  # Check if name contains illegal characters
-  if illegalChars in name:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-  
-  var AttrNode: PAttr
-  new(AttrNode)
-  AttrNode.FName = name
-  AttrNode.FNodeName = name
-  AttrNode.FLocalName = nil
-  AttrNode.prefix = nil
-  AttrNode.FNamespaceURI = nil
-  AttrNode.value = ""
-  AttrNode.FSpecified = False
-  return AttrNode
-
-proc createAttributeNS*(doc: PDocument, namespaceURI: string, qualifiedName: string): PAttr =
-  ## Creates an attribute of the given qualified name and namespace URI
-  
-  # Check if name contains illegal characters
-  if illegalChars in namespaceURI or illegalChars in qualifiedName:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-  # Exceptions
-  if qualifiedName.contains(':'):
-    if namespaceURI == nil:
-      raise newException(ENamespaceErr, "When qualifiedName contains a prefix namespaceURI cannot be nil")
-    elif qualifiedName.split(':')[0].toLower() == "xml" and namespaceURI != "http://www.w3.org/XML/1998/namespace":
-      raise newException(ENamespaceErr, 
-        "When the namespace prefix is \"xml\" namespaceURI has to be \"http://www.w3.org/XML/1998/namespace\"")
-    elif qualifiedName.split(':')[1].toLower() == "xmlns" and namespaceURI != "http://www.w3.org/2000/xmlns/":
-      raise newException(ENamespaceErr, 
-        "When the namespace prefix is \"xmlns\" namespaceURI has to be \"http://www.w3.org/2000/xmlns/\"")
-  
-  var AttrNode: PAttr
-  new(AttrNode)
-  AttrNode.FName = qualifiedName
-  AttrNode.FNodeName = qualifiedName
-  AttrNode.FSpecified = False
-  AttrNode.FNamespaceURI = namespaceURI
-  if qualifiedName.contains(':'):
-    AttrNode.prefix = qualifiedName.split(':')[0]
-    AttrNode.FLocalName = qualifiedName.split(':')[1]
-  else:
-    AttrNode.prefix = nil
-    AttrNode.FLocalName = qualifiedName
-  AttrNode.value = ""
-  
-  AttrNode.FNodeType = AttributeNode
-  return AttrNode
-
-proc createCDATASection*(doc: PDocument, data: string): PCDATASection =
-  ## Creates a CDATASection node whose value is the specified string.
-  var CData: PCDATASection
-  new(CData)
-  CData.data = data
-  CData.nodeValue = data
-  CData.FNodeName = "#text" # Not sure about this, but this is technically a TextNode
-  CData.FNodeType = CDataSectionNode
-  return CData
-
-proc createComment*(doc: PDocument, data: string): PComment =
-  ## Creates a Comment node given the specified string. 
-  var Comm: PComment
-  new(Comm)
-  Comm.data = data
-  Comm.nodeValue = data
-  
-  Comm.FNodeType = CommentNode
-  return Comm
-
-proc createDocumentFragment*(doc: PDocument): PDocumentFragment =
-  ## Creates an empty DocumentFragment object.
-  var DF: PDocumentFragment
-  new(DF)
-  return DF
-
-proc createElement*(doc: PDocument, tagName: string): PElement =
-  ## Creates an element of the type specified.
-  
-  # Check if name contains illegal characters
-  if illegalChars in tagName:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-    
-  var elNode: PElement
-  new(elNode)
-  elNode.FTagName = tagName
-  elNode.FNodeName = tagName
-  elNode.FLocalName = nil
-  elNode.prefix = nil
-  elNode.FNamespaceURI = nil
-  elNode.childNodes = @[]
-  elNode.attributes = @[]
-  
-  elNode.FNodeType = ElementNode
-  
-  return elNode
-
-proc createElementNS*(doc: PDocument, namespaceURI: string, qualifiedName: string): PElement =
-  ## Creates an element of the given qualified name and namespace URI.
-  if qualifiedName.contains(':'):
-    if namespaceURI == nil:
-      raise newException(ENamespaceErr, "When qualifiedName contains a prefix namespaceURI cannot be nil")
-    elif qualifiedName.split(':')[0].toLower() == "xml" and namespaceURI != "http://www.w3.org/XML/1998/namespace":
-      raise newException(ENamespaceErr, 
-        "When the namespace prefix is \"xml\" namespaceURI has to be \"http://www.w3.org/XML/1998/namespace\"")
-        
-  # Check if name contains illegal characters
-  if illegalChars in namespaceURI or illegalChars in qualifiedName:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-    
-  var elNode: PElement
-  new(elNode)
-  elNode.FTagName = qualifiedName
-  elNode.FNodeName = qualifiedName
-  if qualifiedName.contains(':'):
-    elNode.prefix = qualifiedName.split(':')[0]
-    elNode.FLocalName = qualifiedName.split(':')[1]
-  else:
-    elNode.prefix = nil
-    elNode.FLocalName = qualifiedName
-  elNode.FNamespaceURI = namespaceURI
-  elNode.childNodes = @[]
-  elNode.attributes = @[]
-  
-  elNode.FNodeType = ElementNode
-  
-  return elNode
-
-proc createProcessingInstruction*(doc: PDocument, target: string, data: string): PProcessingInstruction = 
-  ## Creates a ProcessingInstruction node given the specified name and data strings. 
-  
-  #Check if name contains illegal characters
-  if illegalChars in target:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-    
-  var PI: PProcessingInstruction
-  new(PI)
-  PI.FTarget = target
-  PI.data = data
-  PI.FNodeType = ProcessingInstructionNode
-  return PI
-
-proc createTextNode*(doc: PDocument, data: string): PText = #Propably TextNode
-  ## Creates a Text node given the specified string. 
-  var txtNode: PText
-  new(txtNode)
-  txtNode.data = data
-  txtNode.nodeValue = data
-  txtNode.FNodeName = "#text"
-  
-  txtNode.FNodeType = TextNode
-  return txtNode
-
-discard """proc getElementById*(doc: PDocument, elementId: string): PElement =
-  ##Returns the ``Element`` whose ID is given by ``elementId``. If no such element exists, returns ``nil``
-  #TODO"""
-
-proc getElementsByTagName*(doc: PDocument, tagName: string): seq[PNode] =
-  ## Returns a NodeList of all the Elements with a given tag name in
-  ## the order in which they are encountered in a preorder traversal of the Document tree. 
-  var result: seq[PNode] = @[]
-  if doc.FDocumentElement.FNodeName == tagName or tagName == "*":
-    result.add(doc.FDocumentElement)
-  
-  result.add(doc.FDocumentElement.findNodes(tagName))
-  return result
-  
-proc getElementsByTagNameNS*(doc: PDocument, namespaceURI: string, localName: string): seq[PNode] =
-  ## Returns a NodeList of all the Elements with a given localName and namespaceURI
-  ## in the order in which they are encountered in a preorder traversal of the Document tree. 
-  var result: seq[PNode] = @[]
-  if doc.FDocumentElement.FLocalName == localName or localName == "*":
-    if doc.FDocumentElement.FNamespaceURI == namespaceURI or namespaceURI == "*":
-      result.add(doc.FDocumentElement)
-      
-  result.add(doc.FDocumentElement.findNodesNS(namespaceURI, localName))
-  return result
-
-proc importNode*(doc: PDocument, importedNode: PNode, deep: bool): PNode =
-  ## Imports a node from another document to this document
-  case importedNode.FNodeType
-  of AttributeNode:
-    var nAttr: PAttr = PAttr(importedNode)
-    nAttr.FOwnerDocument = doc
-    nAttr.FParentNode = nil
-    nAttr.FOwnerElement = nil
-    nAttr.FSpecified = True
-    return nAttr
-  of DocumentFragmentNode:
-    var n: PNode
-    new(n)
-    n = importedNode
-    n.FOwnerDocument = doc
-    n.FParentNode = nil
-
-    n.FOwnerDocument = doc
-    n.FParentNode = nil
-    var tmp: seq[PNode] = n.childNodes
-    n.childNodes = @[]
-    if deep == True:
-      for i in low(tmp.len())..high(tmp.len()):
-        n.childNodes.add(importNode(doc, tmp[i], deep))
-        
-    return n
-  of ElementNode:
-    var n: PNode
-    new(n)
-    n = importedNode
-    n.FOwnerDocument = doc
-    n.FParentNode = nil
-    
-    var tmpA: seq[PAttr] = n.attributes
-    n.attributes = @[]
-    # Import the Element node's attributes
-    for i in low(tmpA.len())..high(tmpA.len()):
-      n.attributes.add(PAttr(importNode(doc, tmpA[i], deep)))
-    # Import the childNodes
-    var tmp: seq[PNode] = n.childNodes
-    n.childNodes = @[]
-    if deep == True:
-      for i in low(tmp.len())..high(tmp.len()):
-        n.childNodes.add(importNode(doc, tmp[i], deep))
-        
-    return n
-  of ProcessingInstructionNode, TextNode, CDataSectionNode, CommentNode:
-    var n: PNode
-    new(n)
-    n = importedNode
-    n.FOwnerDocument = doc
-    n.FParentNode = nil
-    return n
-  else:
-    raise newException(ENotSupportedErr, "The type of node being imported is not supported")
-  
-
-# Node
-# Attributes
-  
-proc firstChild*(n: PNode): PNode =
-  ## Returns this node's first child
-
-  if n.childNodes.len() > 0:
-    return n.childNodes[0]
-  else:
-    return nil
-  
-proc lastChild*(n: PNode): PNode =
-  ## Returns this node's last child
-
-  if n.childNodes.len() > 0:
-    return n.childNodes[n.childNodes.len() - 1]
-  else:
-    return nil
-  
-proc localName*(n: PNode): string =
-  ## Returns this nodes local name
-
-  return n.FLocalName
-
-proc namespaceURI*(n: PNode): string =
-  ## Returns this nodes namespace URI
-  
-  return n.FNamespaceURI
-  
-proc `namespaceURI=`*(n: PNode, value: string) = 
-  n.FNamespaceURI = value
-
-proc nextSibling*(n: PNode): PNode =
-  ## Returns the next sibling of this node
-
-  var nLow: int = low(n.FParentNode.childNodes)
-  var nHigh: int = high(n.FParentNode.childNodes)
-  for i in nLow..nHigh:
-    if n.FParentNode.childNodes[i] == n:
-      return n.FParentNode.childNodes[i + 1]
-  return nil
-
-proc nodeName*(n: PNode): string =
-  ## Returns the name of this node
-
-  return n.FNodeName
-
-proc nodeType*(n: PNode): int =
-  ## Returns the type of this node
-
-  return n.FNodeType
-
-proc ownerDocument*(n: PNode): PDocument =
-  ## Returns the owner document of this node
-
-  return n.FOwnerDocument
-
-proc parentNode*(n: PNode): PNode =
-  ## Returns the parent node of this node
-
-  return n.FParentNode
-  
-proc previousSibling*(n: PNode): PNode =
-  ## Returns the previous sibling of this node
-
-  var nLow: int = low(n.FParentNode.childNodes)
-  var nHigh: int = high(n.FParentNode.childNodes)
-  for i in nLow..nHigh:
-    if n.FParentNode.childNodes[i] == n:
-      return n.FParentNode.childNodes[i - 1]
-  return nil
-  
-proc `prefix=`*(n: PNode, value: string) =
-  ## Modifies the prefix of this node
-
-  # Setter
-  # Check if name contains illegal characters
-  if illegalChars in value:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-
-  if n.FNamespaceURI == nil:
-    raise newException(ENamespaceErr, "namespaceURI cannot be nil")
-  elif value.toLower() == "xml" and n.FNamespaceURI != "http://www.w3.org/XML/1998/namespace":
-    raise newException(ENamespaceErr, 
-      "When the namespace prefix is \"xml\" namespaceURI has to be \"http://www.w3.org/XML/1998/namespace\"")
-  elif value.toLower() == "xmlns" and n.FNamespaceURI != "http://www.w3.org/2000/xmlns/":
-    raise newException(ENamespaceErr, 
-      "When the namespace prefix is \"xmlns\" namespaceURI has to be \"http://www.w3.org/2000/xmlns/\"")
-  elif value.toLower() == "xmlns" and n.FNodeType == AttributeNode:
-    raise newException(ENamespaceErr, "An AttributeNode cannot have a prefix of \"xmlns\"")
-
-  n.FNodeName = value & ":" & n.FLocalName
-  if n.nodeType == ElementNode:
-    var el: PElement = PElement(n)
-    el.FTagName = value & ":" & n.FLocalName
-
-  elif n.nodeType == AttributeNode:
-    var attr: PAttr = PAttr(n)
-    attr.FName = value & ":" & n.FLocalName
-
-# Procedures
-proc appendChild*(n: PNode, newChild: PNode) =
-  ## Adds the node newChild to the end of the list of children of this node.
-  ## If the newChild is already in the tree, it is first removed.
-  
-  # Check if n contains newChild
-  if n.childNodes != nil:
-    for i in low(n.childNodes)..high(n.childNodes):
-      if n.childNodes[i] == newChild:
-        raise newException(EHierarchyRequestErr, "The node to append is already in this nodes children.")
-  
-  # Check if newChild is from this nodes document
-  if n.FOwnerDocument != newChild.FOwnerDocument:
-    raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-  
-  if n == newChild:
-    raise newException(EHierarchyRequestErr, "You can't add a node into itself")
-  
-  if n.nodeType in childlessObjects:
-    raise newException(ENoModificationAllowedErr, "Cannot append children to a childless node")
-  
-  if n.childNodes == nil: n.childNodes = @[]
-    
-  newChild.FParentNode = n
-  for i in low(n.childNodes)..high(n.childNodes):
-    if n.childNodes[i] == newChild:
-      n.childNodes[i] = newChild
-    
-  n.childNodes.add(newChild)
-
-proc cloneNode*(n: PNode, deep: bool): PNode = 
-  ## Returns a duplicate of this node, if ``deep`` is `true`, Element node's children are copied
-  case n.FNodeType
-  of AttributeNode:
-    var newNode: PAttr
-    new(newNode)
-    newNode = PAttr(n)
-    newNode.FSpecified = True
-    newNode.FOwnerElement = nil
-    return newNode
-  of ElementNode:
-    var newNode: PElement
-    new(newNode)
-    newNode = PElement(n)
-    # Import the childNodes
-    var tmp: seq[PNode] = n.childNodes
-    n.childNodes = @[]
-    if deep == True:
-      for i in low(tmp.len())..high(tmp.len()):
-        n.childNodes.add(cloneNode(tmp[i], deep))
-    return newNode
-  else:
-    var newNode: PNode
-    new(newNode)
-    newNode = n
-    return newNode
-
-proc hasAttributes*(n: PNode): bool =
-  ## Returns whether this node (if it is an element) has any attributes. 
-  return n.attributes.len() > 0
-
-proc hasChildNodes*(n: PNode): bool = 
-  ## Returns whether this node has any children.
-  return n.childNodes.len() > 0
-
-proc insertBefore*(n: PNode, newChild: PNode, refChild: PNode): PNode =
-  ## Inserts the node ``newChild`` before the existing child node ``refChild``.
-  ## If ``refChild`` is nil, insert ``newChild`` at the end of the list of children.
-  
-  # Check if newChild is from this nodes document
-  if n.FOwnerDocument != newChild.FOwnerDocument:
-    raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-    
-  for i in low(n.childNodes)..high(n.childNodes):
-    if n.childNodes[i] == refChild:
-      n.childNodes.insert(newChild, i - 1)
-    return
-
-proc isSupported*(n: PNode, feature: string, version: string): bool =
-  ## Tests whether the DOM implementation implements a specific 
-  ## feature and that feature is supported by this node. 
-  return n.FOwnerDocument.FImplementation.hasFeature(feature, version)
-
-proc isEmpty(s: string): bool =
-
-  if s == "" or s == nil:
-    return True
-  for i in items(s):
-    if i != ' ':
-      return False
-  return True
-
-proc normalize*(n: PNode) =
-  ## Merges all seperated TextNodes together, and removes any empty TextNodes
-  var curTextNode: PNode = nil
-  var i: int = 0
-  
-  var newChildNodes: seq[PNode] = @[]
-  while True:
-    if i >= n.childNodes.len:
-      break
-    if n.childNodes[i].nodeType == TextNode:
-      
-      #If the TextNode is empty, remove it
-      if PText(n.childNodes[i]).data.isEmpty():
-        inc(i)
-      
-      if curTextNode == nil:
-        curTextNode = n.childNodes[i]
-      else:
-        PText(curTextNode).data.add(PText(n.childNodes[i]).data)
-        curTextNode.nodeValue.add(PText(n.childNodes[i]).data)
-        inc(i)
-    else:
-      newChildNodes.add(curTextNode)
-      newChildNodes.add(n.childNodes[i])
-      curTextNode = nil
-    
-    inc(i)
-  n.childNodes = newChildNodes
-
-proc removeChild*(n: PNode, oldChild: PNode): PNode =
-  ## Removes the child node indicated by ``oldChild`` from the list of children, and returns it.
-  for i in low(n.childNodes)..high(n.childNodes):
-    if n.childNodes[i] == oldChild:
-      result = n.childNodes[i]
-      n.childNodes.delete(i)
-      return result
-      
-  raise newException(ENotFoundErr, "Node not found")
-    
-proc replaceChild*(n: PNode, newChild: PNode, oldChild: PNode): PNode =
-  ## Replaces the child node ``oldChild`` with ``newChild`` in the list of children, and returns the ``oldChild`` node.
-  
-  # Check if newChild is from this nodes document
-  if n.FOwnerDocument != newChild.FOwnerDocument:
-    raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-  
-  for i in low(n.childNodes)..high(n.childNodes):
-    if n.childNodes[i] == oldChild:
-      result = n.childNodes[i]
-      n.childNodes[i] = newChild
-      return result
-  
-  raise newException(ENotFoundErr, "Node not found")
-  
-# NamedNodeMap
-
-proc getNamedItem*(NList: seq[PNode], name: string): PNode =
-  ## Retrieves a node specified by ``name``. If this node cannot be found returns ``nil``
-  for i in items(NList):
-    if i.nodeName() == name:
-      return i
-  return nil
-  
-proc getNamedItem*(NList: seq[PAttr], name: string): PAttr =
-  ## Retrieves a node specified by ``name``. If this node cannot be found returns ``nil``
-  for i in items(NList):
-    if i.nodeName() == name:
-      return i
-  return nil
-      
-proc getNamedItemNS*(NList: seq[PNode], namespaceURI: string, localName: string): PNode =
-  ## Retrieves a node specified by ``localName`` and ``namespaceURI``. If this node cannot be found returns ``nil``
-  for i in items(NList):
-    if i.namespaceURI() == namespaceURI and i.localName() == localName:
-      return i
-  return nil
-  
-proc getNamedItemNS*(NList: seq[PAttr], namespaceURI: string, localName: string): PAttr = 
-  ## Retrieves a node specified by ``localName`` and ``namespaceURI``. If this node cannot be found returns ``nil``
-  for i in items(NList):
-    if i.NamespaceURI() == namespaceURI and i.LocalName() == localName:
-      return i
-  return nil
-
-proc item*(NList: seq[PNode], index: int): PNode =
-  ## Returns the ``index`` th item in the map. 
-  ## If ``index`` is greater than or equal to the number of nodes in this map, this returns ``nil``.
-  if index >= NList.len(): return nil
-  else: return NList[index]
-
-proc removeNamedItem*(NList: var seq[PNode], name: string): PNode =
-  ## Removes a node specified by ``name``
-  ## Raises the ``ENotFoundErr`` exception, if the node was not found
-  for i in low(NList)..high(NList):
-    if NList[i].FNodeName == name:
-      result = NList[i]
-      NList.delete(i)
-      return result
-  
-  raise newException(ENotFoundErr, "Node not found")
-  
-proc removeNamedItemNS*(NList: var seq[PNode], namespaceURI: string, localName: string): PNode =
-  ## Removes a node specified by local name and namespace URI
-  for i in low(NList)..high(NList):
-    if NList[i].FLocalName == localName and NList[i].FNamespaceURI == namespaceURI:
-      result = NList[i]
-      NList.delete(i)
-      return result
-  
-  raise newException(ENotFoundErr, "Node not found")
-
-proc setNamedItem*(NList: var seq[PNode], arg: PNode): PNode =
-  ## Adds ``arg`` as a ``Node`` to the ``NList``
-  ## If a node with the same name is already present in this map, it is replaced by the new one.
-  if NList != nil:
-    if NList.len() > 0:
-      #Check if newChild is from this nodes document
-      if NList[0].FOwnerDocument != arg.FOwnerDocument:
-        raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-  #Exceptions End
-  
-  var item: PNode = NList.getNamedItem(arg.NodeName())
-  if item == nil:
-    NList.add(arg)
-    return nil
-  else:
-    # Node with the same name exists
-    var index: int = 0
-    for i in low(NList)..high(NList):
-      if NList[i] == item:
-        index = i
-        break
-    NList[index] = arg
-    return item # Return the replaced node
-    
-proc setNamedItem*(NList: var seq[PAttr], arg: PAttr): PAttr =
-  ## Adds ``arg`` as a ``Node`` to the ``NList``
-  ## If a node with the same name is already present in this map, it is replaced by the new one.
-  if NList != nil:
-    if NList.len() > 0:
-      # Check if newChild is from this nodes document
-      if NList[0].FOwnerDocument != arg.FOwnerDocument:
-        raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-        
-  if arg.FOwnerElement != nil:
-    raise newException(EInuseAttributeErr, "This attribute is in use by another element, use cloneNode")
-        
-  # Exceptions end
-  var item: PAttr = NList.getNamedItem(arg.nodeName())
-  if item == nil:
-    NList.add(arg)
-    return nil
-  else:
-    # Node with the same name exists
-    var index: int = 0
-    for i in low(NList)..high(NList):
-      if NList[i] == item:
-        index = i
-        break
-    NList[index] = arg
-    return item # Return the replaced node
-    
-proc setNamedItemNS*(NList: var seq[PNode], arg: PNode): PNode =
-  ## Adds a node using its ``namespaceURI`` and ``localName``
-  if NList != nil:
-    if NList.len() > 0:
-      # Check if newChild is from this nodes document
-      if NList[0].FOwnerDocument != arg.FOwnerDocument:
-        raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-  #Exceptions end
-        
-  var item: PNode = NList.getNamedItemNS(arg.namespaceURI(), arg.localName())
-  if item == nil:
-    NList.add(arg)
-    return nil
-  else:
-    # Node with the same name exists
-    var index: int = 0
-    for i in low(NList)..high(NList):
-      if NList[i] == item:
-        index = i
-        break
-    NList[index] = arg
-    return item # Return the replaced node
-    
-proc setNamedItemNS*(NList: var seq[PAttr], arg: PAttr): PAttr =
-  ## Adds a node using its ``namespaceURI`` and ``localName``
-  if NList != nil:
-    if NList.len() > 0:
-      # Check if newChild is from this nodes document
-      if NList[0].FOwnerDocument != arg.FOwnerDocument:
-        raise newException(EWrongDocumentErr, "This node belongs to a different document, use importNode.")
-        
-  if arg.FOwnerElement != nil:
-    raise newException(EInuseAttributeErr, "This attribute is in use by another element, use cloneNode")
-        
-  # Exceptions end
-  var item: PAttr = NList.getNamedItemNS(arg.namespaceURI(), arg.localName())
-  if item == nil:
-    NList.add(arg)
-    return nil
-  else:
-    # Node with the same name exists
-    var index: int = 0
-    for i in low(NList)..high(NList):
-      if NList[i] == item:
-        index = i
-        break
-    NList[index] = arg
-    return item # Return the replaced node
-    
-# CharacterData - Decided to implement this, 
-# Didn't add the procedures, because you can just edit .data
-
-# Attr
-# Attributes
-proc name*(a: PAttr): string =
-  ## Returns the name of the Attribute
-
-  return a.FName
-  
-proc specified*(a: PAttr): bool =
-  ## Specifies whether this attribute was specified in the original document
-
-  return a.FSpecified
-  
-proc ownerElement*(a: PAttr): PElement = 
-  ## Returns this Attributes owner element
-
-  return a.FOwnerElement
-
-# Element
-# Attributes
-
-proc tagName*(el: PElement): string =
-  ## Returns the Element Tag Name
-
-  return el.FTagName
-
-# Procedures
-proc getAttribute*(el: PElement, name: string): string =
-  ## Retrieves an attribute value by ``name``
-  var attribute = el.attributes.getNamedItem(name)
-  if attribute != nil:
-    return attribute.value
-  else:
-    return nil
-
-proc getAttributeNS*(el: PElement, namespaceURI: string, localName: string): string =
-  ## Retrieves an attribute value by ``localName`` and ``namespaceURI``
-  var attribute = el.attributes.getNamedItemNS(namespaceURI, localName)
-  if attribute != nil:
-    return attribute.value
-  else:
-    return nil
-    
-proc getAttributeNode*(el: PElement, name: string): PAttr =
-  ## Retrieves an attribute node by ``name``
-  ## To retrieve an attribute node by qualified name and namespace URI, use the `getAttributeNodeNS` method
-  return el.attributes.getNamedItem(name)
-
-proc getAttributeNodeNS*(el: PElement, namespaceURI: string, localName: string): PAttr =
-  ## Retrieves an `Attr` node by ``localName`` and ``namespaceURI``
-  return el.attributes.getNamedItemNS(namespaceURI, localName)
-
-proc getElementsByTagName*(el: PElement, name: string): seq[PNode] =
-  ## Returns a `NodeList` of all descendant `Elements` of ``el`` with a given tag ``name``,
-  ## in the order in which they are encountered in a preorder traversal of this `Element` tree
-  ## If ``name`` is `*`, returns all descendant of ``el``
-  result = el.findNodes(name)
-
-proc getElementsByTagNameNS*(el: PElement, namespaceURI: string, localName: string): seq[PNode] =
-  ## Returns a `NodeList` of all the descendant Elements with a given
-  ## ``localName`` and ``namespaceURI`` in the order in which they are
-  ## encountered in a preorder traversal of this Element tree
-  result = el.findNodesNS(namespaceURI, localName)
-
-proc hasAttribute*(el: PElement, name: string): bool =
-  ## Returns ``true`` when an attribute with a given ``name`` is specified 
-  ## on this element , ``false`` otherwise. 
-  return el.attributes.getNamedItem(name) != nil
-
-proc hasAttributeNS*(el: PElement, namespaceURI: string, localName: string): bool =
-  ## Returns ``true`` when an attribute with a given ``localName`` and
-  ## ``namespaceURI`` is specified on this element , ``false`` otherwise 
-  return el.attributes.getNamedItemNS(namespaceURI, localName) != nil
-
-proc removeAttribute*(el: PElement, name: string) =
-  ## Removes an attribute by ``name``
-  for i in low(el.attributes)..high(el.attributes):
-    if el.attributes[i].FName == name:
-      el.attributes.delete(i)
-      
-proc removeAttributeNS*(el: PElement, namespaceURI: string, localName: string) =
-  ## Removes an attribute by ``localName`` and ``namespaceURI``
-  for i in low(el.attributes)..high(el.attributes):
-    if el.attributes[i].FNamespaceURI == namespaceURI and 
-        el.attributes[i].FLocalName == localName:
-      el.attributes.delete(i)
-  
-proc removeAttributeNode*(el: PElement, oldAttr: PAttr): PAttr =
-  ## Removes the specified attribute node
-  ## If the attribute node cannot be found raises ``ENotFoundErr``
-  for i in low(el.attributes)..high(el.attributes):
-    if el.attributes[i] == oldAttr:
-      result = el.attributes[i]
-      el.attributes.delete(i)
-      return result
-  
-  raise newException(ENotFoundErr, "oldAttr is not a member of el's Attributes")
-
-proc setAttributeNode*(el: PElement, newAttr: PAttr): PAttr =
-  ## Adds a new attribute node, if an attribute with the same `nodeName` is
-  ## present, it is replaced by the new one and the replaced attribute is
-  ## returned, otherwise ``nil`` is returned.
-  
-  # Check if newAttr is from this nodes document
-  if el.FOwnerDocument != newAttr.FOwnerDocument:
-    raise newException(EWrongDocumentErr, 
-      "This node belongs to a different document, use importNode.")
-        
-  if newAttr.FOwnerElement != nil:
-    raise newException(EInuseAttributeErr, 
-      "This attribute is in use by another element, use cloneNode")
-  # Exceptions end
-  
-  if el.attributes == nil: el.attributes = @[]
-  return el.attributes.setNamedItem(newAttr)
-  
-proc setAttributeNodeNS*(el: PElement, newAttr: PAttr): PAttr =
-  ## Adds a new attribute node, if an attribute with the localName and 
-  ## namespaceURI of ``newAttr`` is present, it is replaced by the new one
-  ## and the replaced attribute is returned, otherwise ``nil`` is returned.
-  
-  # Check if newAttr is from this nodes document
-  if el.FOwnerDocument != newAttr.FOwnerDocument:
-    raise newException(EWrongDocumentErr, 
-      "This node belongs to a different document, use importNode.")
-        
-  if newAttr.FOwnerElement != nil:
-    raise newException(EInuseAttributeErr, 
-      "This attribute is in use by another element, use cloneNode")
-  # Exceptions end
-  
-  if el.attributes == nil: el.attributes = @[]
-  return el.attributes.setNamedItemNS(newAttr)
-
-proc setAttribute*(el: PElement, name: string, value: string) =
-  ## Adds a new attribute, as specified by ``name`` and ``value``
-  ## If an attribute with that name is already present in the element, its 
-  ## value is changed to be that of the value parameter
-  ## Raises the EInvalidCharacterErr if the specified ``name`` contains 
-  ## illegal characters
-  var AttrNode = el.FOwnerDocument.createAttribute(name)
-  # Check if name contains illegal characters
-  if illegalChars in name:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-    
-  discard el.setAttributeNode(AttrNode)
-  # Set the info later, the setAttributeNode checks
-  # if FOwnerElement is nil, and if it isn't it raises an exception
-  AttrNode.FOwnerElement = el
-  AttrNode.FSpecified = True
-  AttrNode.value = value
-  
-proc setAttributeNS*(el: PElement, namespaceURI, localName, value: string) =
-  ## Adds a new attribute, as specified by ``namespaceURI``, ``localName`` 
-  ## and ``value``.
-  
-  # Check if name contains illegal characters
-  if illegalChars in namespaceURI or illegalChars in localName:
-    raise newException(EInvalidCharacterErr, "Invalid character")
-    
-  var AttrNode = el.FOwnerDocument.createAttributeNS(namespaceURI, localName)
-    
-  discard el.setAttributeNodeNS(AttrNode)
-  # Set the info later, the setAttributeNode checks
-  # if FOwnerElement is nil, and if it isn't it raises an exception
-  AttrNode.FOwnerElement = el
-  AttrNode.FSpecified = True
-  AttrNode.value = value
-
-# Text  
-proc splitData*(TextNode: PText, offset: int): PText =
-  ## Breaks this node into two nodes at the specified offset, 
-  ## keeping both in the tree as siblings.
-  
-  if offset > TextNode.data.len():
-    raise newException(EIndexSizeErr, "Index out of bounds")
-  
-  var left: string = TextNode.data.copy(0, offset)
-  TextNode.data = left
-  var right: string = TextNode.data.copy(offset, TextNode.data.len())
-  
-  if TextNode.FParentNode != nil:
-    for i in low(TextNode.FParentNode.childNodes)..high(TextNode.FParentNode.childNodes):
-      if TextNode.FParentNode.childNodes[i] == TextNode:
-        var newNode: PText = TextNode.FOwnerDocument.createTextNode(right)
-        TextNode.FParentNode.childNodes.insert(newNode, i)
-        return newNode
-  else:
-    var newNode: PText = TextNode.FOwnerDocument.createTextNode(right)
-    return newNode
-
-
-# ProcessingInstruction
-proc target*(PI: PProcessingInstruction): string =
-  ## Returns the Processing Instructions target
-
-  return PI.FTarget
-
-    
-# --Other stuff--
-# Writer
-proc addEscaped(s: string): string = 
-  result = ""
-  for c in items(s):
-    case c
-    of '<': result.add("&lt;")
-    of '>': result.add("&gt;")
-    of '&': result.add("&amp;")
-    of '"': result.add("&quot;")
-    else: result.add(c)
-
-proc nodeToXml(n: PNode, indent: int = 0): string =
-  result = repeatChar(indent, ' ') & "<" & n.nodeName
-  for i in items(n.Attributes):
-    result.add(" " & i.name & "=\"" & addEscaped(i.value) & "\"")
-  
-  if n.childNodes.len() == 0:
-    result.add("/>") # No idea why this doesn't need a \n :O
-  else:
-    # End the beginning of this tag
-    result.add(">\n")
-    for i in items(n.childNodes):
-      case i.nodeType
-      of ElementNode:
-        result.add(nodeToXml(i, indent + 2))
-      of TextNode:
-        result.add(repeatChar(indent * 2, ' '))
-        result.add(addEscaped(i.nodeValue))
-      of CDataSectionNode:
-        result.add(repeatChar(indent * 2, ' '))
-        result.add("<![CDATA[" & i.nodeValue & "]]>")
-      of ProcessingInstructionNode:
-        result.add(repeatChar(indent * 2, ' '))
-        result.add("<?" & PProcessingInstruction(i).target & " " &
-                          PProcessingInstruction(i).data & " ?>")
-      of CommentNode:
-        result.add(repeatChar(indent * 2, ' '))
-        result.add("<!-- " & i.nodeValue & " -->")
-      else:
-        continue
-      result.add("\n")
-    # Add the ending tag - </tag>
-    result.add(repeatChar(indent, ' ') & "</" & n.nodeName & ">")
-
-proc `$`*(doc: PDocument): string =
-  ## Converts a PDocument object into a string representation of it's XML
-  result = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
-  result.add(nodeToXml(doc.documentElement))
diff --git a/lib/pure/xmldomparser.nim b/lib/pure/xmldomparser.nim
deleted file mode 100755
index d9eb210c3..000000000
--- a/lib/pure/xmldomparser.nim
+++ /dev/null
@@ -1,168 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Dominik Picheta
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-import xmldom, os, streams, parsexml, strutils
-
-## This module parses a XML Document into a XML DOM Document representation.
-
-#XMLDom's Parser - Turns XML into a Document
-
-type
-  # Parsing errors
-  EMismatchedTag* = object of E_Base ## Raised when a tag is not properly closed
-  EParserError* = object of E_Base ## Raised when an unexpected XML Parser event occurs
-
-  # For namespaces
-  xmlnsAttr = tuple[name, value: string, ownerElement: PElement]
-
-var nsList: seq[xmlnsAttr] = @[] # Used for storing namespaces
-
-proc getNS(prefix: string): string =
-  var defaultNS: seq[string] = @[]
-
-  for key, value, tag in items(nsList):
-    if ":" in key:
-      if key.split(':')[1] == prefix:
-        return value
-        
-    if key == "xmlns":
-      defaultNS.add(value)
-      
-  # Don't return the default namespaces
-  # in the loop, because then they would have a precedence
-  # over normal namespaces
-  if defaultNS.len() > 0:
-    return defaultNS[0] # Return the first found default namespace
-                        # if none are specified for this prefix
-    
-  return ""
-    
-proc parseText(x: var TXmlParser, doc: var PDocument): PText =
-  result = doc.createTextNode(x.charData())
-
-proc parseElement(x: var TXmlParser, doc: var PDocument): PElement =
-  var n = doc.createElement("")
-
-  while True:
-    case x.kind()
-    of xmlEof:
-      break
-    of xmlElementStart, xmlElementOpen:
-      if n.tagName() != "":
-        n.appendChild(parseElement(x, doc))
-      else:
-        n = doc.createElementNS("", x.elementName)
-        
-    of xmlElementEnd:
-      if x.elementName == n.nodeName:
-        # n.normalize() # Remove any whitespace etc.
-        
-        var ns: string
-        if x.elementName.contains(':'):
-          ns = getNS(x.elementName.split(':')[0])
-        else:
-          ns = getNS("")
-        
-        n.namespaceURI = ns
-        
-        # Remove any namespaces this element declared
-        var count = 0 # Variable which keeps the index
-                      # We need to edit it..
-        for i in low(nsList)..len(nsList)-1:
-          if nsList[count][2] == n:
-            nsList.delete(count)
-            dec(count)
-          inc(count)
-
-        return n
-      else: #The wrong element is ended
-        raise newException(EMismatchedTag, "Mismatched tag at line " & 
-          $x.getLine() & " column " & $x.getColumn)
-      
-    of xmlCharData:
-      n.appendChild(parseText(x, doc))
-    of xmlAttribute:
-      if x.attrKey == "xmlns" or x.attrKey.startsWith("xmlns:"):
-        nsList.add((x.attrKey, x.attrValue, n))
-        
-      if x.attrKey.contains(':'):
-        var ns = getNS(x.attrKey)
-        n.setAttributeNS(ns, x.attrKey, x.attrValue)
-      else:
-        n.setAttribute(x.attrKey, x.attrValue)
-
-    of xmlCData:
-      n.appendChild(doc.createCDATASection(x.charData()))
-    of xmlComment:
-      n.appendChild(doc.createComment(x.charData()))
-    of xmlPI:
-      n.appendChild(doc.createProcessingInstruction(x.PIName(), x.PIRest()))
-      
-    of xmlWhitespace, xmlElementClose, xmlEntity, xmlSpecial:
-      # Unused 'events'
-
-    else:
-      raise newException(EParserError, "Unexpected XML Parser event")
-    x.next()
-
-  raise newException(EMismatchedTag, 
-    "Mismatched tag at line " & $x.getLine() & " column " & $x.getColumn)
-
-proc loadXMLStream*(stream: PStream): PDocument =
-  ## Loads and parses XML from a stream specified by ``stream``, and returns 
-  ## a ``PDocument``
-
-  var x: TXmlParser
-  open(x, stream, nil, {reportComments})
-  
-  var XmlDoc: PDocument
-  var DOM: PDOMImplementation = getDOM()
-  
-  while True:
-    x.next()
-    case x.kind()
-    of xmlEof:
-      break
-    of xmlElementStart, xmlElementOpen:
-      var el: PElement = parseElement(x, XmlDoc)
-      XmlDoc = dom.createDocument(el)
-    of xmlWhitespace, xmlElementClose, xmlEntity, xmlSpecial:
-      # Unused 'events'
-    else:
-      raise newException(EParserError, "Unexpected XML Parser event")
-
-  return XmlDoc
-
-proc loadXML*(xml: string): PDocument =
-  ## Loads and parses XML from a string specified by ``xml``, and returns 
-  ## a ``PDocument``
-  var s = newStringStream(xml)
-  return loadXMLStream(s)
-  
-    
-proc loadXMLFile*(path: string): PDocument =
-  ## Loads and parses XML from a file specified by ``path``, and returns 
-  ## a ``PDocument``
-  
-  var s = newFileStream(path, fmRead)
-  if s == nil: raise newException(EIO, "Unable to read file " & path)
-  return loadXMLStream(s)
-
-
-when isMainModule:
-  var xml = loadXMLFile(r"C:\Users\Dominik\Desktop\Code\Nimrod\xmldom\test.xml")
-  #echo(xml.getElementsByTagName("m:test2")[0].namespaceURI)
-  #echo(xml.getElementsByTagName("bla:test")[0].namespaceURI)
-  #echo(xml.getElementsByTagName("test")[0].namespaceURI)
-  for i in items(xml.getElementsByTagName("*")):
-    if i.namespaceURI != nil:
-      echo(i.nodeName, "=", i.namespaceURI)
-
-    
-  echo($xml)
diff --git a/lib/pure/xmlgen.nim b/lib/pure/xmlgen.nim
deleted file mode 100755
index d1fdcdd57..000000000
--- a/lib/pure/xmlgen.nim
+++ /dev/null
@@ -1,411 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements a simple `XML`:idx: and `HTML`:idx: code 
-## generator. Each commonly used HTML tag has a corresponding macro
-## that generates a string with its HTML representation.
-##
-## Example:
-##
-## .. code-block:: nimrod
-##   var nim = "Nimrod"
-##   echo h1(a(href="http://force7.de/nimrod", nim))
-##  
-## Writes the string::
-##   
-##   <h1><a href="http://force7.de/nimrod">Nimrod</a></h1>
-##
-## **Deprecated since version 0.8.8.** Use the macro ``<>`` in xmltree 
-## instead.
-
-{.deprecated.}
-
-import
-  macros, strutils
-
-const
-  coreAttr* = " id class title style "
-  eventAttr* = " onclick ondblclick onmousedown onmouseup " &
-    "onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup "
-  commonAttr* = coreAttr & eventAttr
-
-proc getIdent(e: PNimrodNode): string {.compileTime.} = 
-  case e.kind
-  of nnkIdent: result = normalize($e.ident)
-  of nnkAccQuoted: result = getIdent(e[0])
-  else: error("cannot extract identifier from node: " & toStrLit(e).strVal)
-
-proc delete[T](s: var seq[T], attr: T): bool = 
-  var idx = find(s, attr)
-  if idx >= 0:
-    var L = s.len
-    s[idx] = s[L-1]
-    setLen(s, L-1)
-    result = true
-
-proc xmlCheckedTag*(e: PNimrodNode, tag: string,
-    optAttr = "", reqAttr = "",
-    isLeaf = false): PNimrodNode {.compileTime.} =
-  ## use this procedure to define a new XML tag
-  
-  # copy the attributes; when iterating over them these lists
-  # will be modified, so that each attribute is only given one value
-  var req = split(reqAttr)
-  var opt = split(optAttr)
-  echo "##", optAttr, "##", opt.len
-  result = newNimNode(nnkBracket, e)
-  result.add(newStrLitNode("<"))
-  result.add(newStrLitNode(tag))
-  # first pass over attributes:
-  for i in 1..e.len-1:
-    if e[i].kind == nnkExprEqExpr: 
-      var name = getIdent(e[i][0])
-      if delete(req, name) or delete(opt, name):
-        result.add(newStrLitNode(" "))
-        result.add(newStrLitNode(name))
-        result.add(newStrLitNode("=\""))
-        result.add(e[i][1])
-        result.add(newStrLitNode("\""))
-      else:
-        error("invalid attribute for '" & tag & "' element: " & name)
-  # check each required attribute exists:
-  if req.len > 0:
-    error(req[0] & " attribute for '" & tag & "' element expected")
-  if isLeaf:
-    for i in 1..e.len-1:
-      if e[i].kind != nnkExprEqExpr: 
-        error("element " & tag & " cannot be nested")
-    result.add(newStrLitNode(" />"))
-  else:
-    result.add(newStrLitNode(">"))
-    # second pass over elements:
-    for i in 1..e.len-1:
-      if e[i].kind != nnkExprEqExpr: result.add(e[i])
-    result.add(newStrLitNode("</"))
-    result.add(newStrLitNode(tag))
-    result.add(newStrLitNode(">"))
-  result = NestList(!"&", result)
-
-
-macro a*(e: expr): expr = 
-  ## generates the HTML ``a`` element.
-  result = xmlCheckedTag(e, "a", "href charset type hreflang rel rev " &
-    "accesskey tabindex" & commonAttr)
-
-macro acronym*(e: expr): expr = 
-  ## generates the HTML ``acronym`` element.
-  result = xmlCheckedTag(e, "acronym", commonAttr)
-
-macro address*(e: expr): expr = 
-  ## generates the HTML ``address`` element.
-  result = xmlCheckedTag(e, "address", commonAttr)
-
-macro area*(e: expr): expr = 
-  ## generates the HTML ``area`` element.
-  result = xmlCheckedTag(e, "area", "shape coords href nohref" &
-    " accesskey tabindex" & commonAttr, "alt", true)
-
-macro b*(e: expr): expr = 
-  ## generates the HTML ``b`` element.
-  result = xmlCheckedTag(e, "b", commonAttr)
-
-macro base*(e: expr): expr = 
-  ## generates the HTML ``base`` element.
-  result = xmlCheckedTag(e, "base", "", "href", true)
-
-macro big*(e: expr): expr = 
-  ## generates the HTML ``big`` element.
-  result = xmlCheckedTag(e, "big", commonAttr)
-
-macro blockquote*(e: expr): expr = 
-  ## generates the HTML ``blockquote`` element.
-  result = xmlCheckedTag(e, "blockquote", " cite" & commonAttr)
-
-macro body*(e: expr): expr = 
-  ## generates the HTML ``body`` element.
-  result = xmlCheckedTag(e, "body", commonAttr)
-
-macro br*(e: expr): expr = 
-  ## generates the HTML ``br`` element.
-  result = xmlCheckedTag(e, "br", "", "", true)
-
-macro button*(e: expr): expr = 
-  ## generates the HTML ``button`` element.
-  result = xmlCheckedTag(e, "button", "accesskey tabindex " &
-    "disabled name type value" & commonAttr)
-
-macro caption*(e: expr): expr = 
-  ## generates the HTML ``caption`` element.
-  result = xmlCheckedTag(e, "caption", commonAttr)
-
-macro cite*(e: expr): expr = 
-  ## generates the HTML ``cite`` element.
-  result = xmlCheckedTag(e, "cite", commonAttr)
-
-macro code*(e: expr): expr = 
-  ## generates the HTML ``code`` element.
-  result = xmlCheckedTag(e, "code", commonAttr)
-
-macro col*(e: expr): expr = 
-  ## generates the HTML ``col`` element.
-  result = xmlCheckedTag(e, "col", "span align valign" & commonAttr, "", true)
-
-macro colgroup*(e: expr): expr = 
-  ## generates the HTML ``colgroup`` element.
-  result = xmlCheckedTag(e, "colgroup", "span align valign" & commonAttr)
-
-macro dd*(e: expr): expr = 
-  ## generates the HTML ``dd`` element.
-  result = xmlCheckedTag(e, "dd", commonAttr)
-
-macro del*(e: expr): expr = 
-  ## generates the HTML ``del`` element.
-  result = xmlCheckedTag(e, "del", "cite datetime" & commonAttr)
-
-macro dfn*(e: expr): expr = 
-  ## generates the HTML ``dfn`` element.
-  result = xmlCheckedTag(e, "dfn", commonAttr)
-
-macro `div`*(e: expr): expr = 
-  ## generates the HTML ``div`` element.
-  result = xmlCheckedTag(e, "div", commonAttr)
-
-macro dl*(e: expr): expr = 
-  ## generates the HTML ``dl`` element.
-  result = xmlCheckedTag(e, "dl", commonAttr)
-
-macro dt*(e: expr): expr = 
-  ## generates the HTML ``dt`` element.
-  result = xmlCheckedTag(e, "dt", commonAttr)
-
-macro em*(e: expr): expr = 
-  ## generates the HTML ``em`` element.
-  result = xmlCheckedTag(e, "em", commonAttr)
-
-macro fieldset*(e: expr): expr = 
-  ## generates the HTML ``fieldset`` element.
-  result = xmlCheckedTag(e, "fieldset", commonAttr)
-
-macro form*(e: expr): expr = 
-  ## generates the HTML ``form`` element.
-  result = xmlCheckedTag(e, "form", "method encype accept accept-charset" & 
-    commonAttr, "action")
-
-macro h1*(e: expr): expr = 
-  ## generates the HTML ``h1`` element.
-  result = xmlCheckedTag(e, "h1", commonAttr)
-
-macro h2*(e: expr): expr = 
-  ## generates the HTML ``h2`` element.
-  result = xmlCheckedTag(e, "h2", commonAttr)
-
-macro h3*(e: expr): expr = 
-  ## generates the HTML ``h3`` element.
-  result = xmlCheckedTag(e, "h3", commonAttr)
-
-macro h4*(e: expr): expr = 
-  ## generates the HTML ``h4`` element.
-  result = xmlCheckedTag(e, "h4", commonAttr)
-
-macro h5*(e: expr): expr = 
-  ## generates the HTML ``h5`` element.
-  result = xmlCheckedTag(e, "h5", commonAttr)
-
-macro h6*(e: expr): expr = 
-  ## generates the HTML ``h6`` element.
-  result = xmlCheckedTag(e, "h6", commonAttr)
-
-macro head*(e: expr): expr = 
-  ## generates the HTML ``head`` element.
-  result = xmlCheckedTag(e, "head", "profile")
-
-macro html*(e: expr): expr = 
-  ## generates the HTML ``html`` element.
-  result = xmlCheckedTag(e, "html", "", "xmlns")
-
-macro hr*(e: expr): expr = 
-  ## generates the HTML ``hr`` element.
-  result = xmlCheckedTag(e, "hr", commonAttr, "", true)
-
-macro i*(e: expr): expr = 
-  ## generates the HTML ``i`` element.
-  result = xmlCheckedTag(e, "i", commonAttr)
-
-macro img*(e: expr): expr = 
-  ## generates the HTML ``img`` element.
-  result = xmlCheckedTag(e, "img", "longdesc height width", "src alt", true)
-
-macro input*(e: expr): expr = 
-  ## generates the HTML ``input`` element.
-  result = xmlCheckedTag(e, "input", "name type value checked maxlength src" &
-    " alt accept disabled readonly accesskey tabindex" & commonAttr, "", true)
-
-macro ins*(e: expr): expr = 
-  ## generates the HTML ``ins`` element.
-  result = xmlCheckedTag(e, "ins", "cite datetime" & commonAttr)
-
-macro kbd*(e: expr): expr = 
-  ## generates the HTML ``kbd`` element.
-  result = xmlCheckedTag(e, "kbd", commonAttr)
-
-macro label*(e: expr): expr = 
-  ## generates the HTML ``label`` element.
-  result = xmlCheckedTag(e, "label", "for accesskey" & commonAttr)
-
-macro legend*(e: expr): expr = 
-  ## generates the HTML ``legend`` element.
-  result = xmlCheckedTag(e, "legend", "accesskey" & commonAttr)
-
-macro li*(e: expr): expr = 
-  ## generates the HTML ``li`` element.
-  result = xmlCheckedTag(e, "li", commonAttr)
-
-macro link*(e: expr): expr = 
-  ## generates the HTML ``link`` element.
-  result = xmlCheckedTag(e, "link", "href charset hreflang type rel rev media" & 
-    commonAttr, "", true)
-
-macro map*(e: expr): expr = 
-  ## generates the HTML ``map`` element.
-  result = xmlCheckedTag(e, "map", "class title" & eventAttr, "id", false)
-
-macro meta*(e: expr): expr = 
-  ## generates the HTML ``meta`` element.
-  result = xmlCheckedTag(e, "meta", "name http-equiv scheme", "content", true)
-
-macro noscript*(e: expr): expr = 
-  ## generates the HTML ``noscript`` element.
-  result = xmlCheckedTag(e, "noscript", commonAttr)
-
-macro `object`*(e: expr): expr = 
-  ## generates the HTML ``object`` element.
-  result = xmlCheckedTag(e, "object", "classid data codebase declare type " &
-    "codetype archive standby width height name tabindex" & commonAttr)
-
-macro ol*(e: expr): expr = 
-  ## generates the HTML ``ol`` element.
-  result = xmlCheckedTag(e, "ol", commonAttr)
-
-macro optgroup*(e: expr): expr = 
-  ## generates the HTML ``optgroup`` element.
-  result = xmlCheckedTag(e, "optgroup", "disabled" & commonAttr, "label", false)
-
-macro option*(e: expr): expr = 
-  ## generates the HTML ``option`` element.
-  result = xmlCheckedTag(e, "option", "selected value" & commonAttr)
-
-macro p*(e: expr): expr = 
-  ## generates the HTML ``p`` element.
-  result = xmlCheckedTag(e, "p", commonAttr)
-
-macro param*(e: expr): expr = 
-  ## generates the HTML ``param`` element.
-  result = xmlCheckedTag(e, "param", "value id type valuetype", "name", true)
-
-macro pre*(e: expr): expr = 
-  ## generates the HTML ``pre`` element.
-  result = xmlCheckedTag(e, "pre", commonAttr)
-
-macro q*(e: expr): expr = 
-  ## generates the HTML ``q`` element.
-  result = xmlCheckedTag(e, "q", "cite" & commonAttr)
-
-macro samp*(e: expr): expr = 
-  ## generates the HTML ``samp`` element.
-  result = xmlCheckedTag(e, "samp", commonAttr)
-
-macro script*(e: expr): expr = 
-  ## generates the HTML ``script`` element.
-  result = xmlCheckedTag(e, "script", "src charset defer", "type", false)
-
-macro select*(e: expr): expr = 
-  ## generates the HTML ``select`` element.
-  result = xmlCheckedTag(e, "select", "name size multiple disabled tabindex" & 
-    commonAttr)
-
-macro small*(e: expr): expr = 
-  ## generates the HTML ``small`` element.
-  result = xmlCheckedTag(e, "small", commonAttr)
-
-macro span*(e: expr): expr = 
-  ## generates the HTML ``span`` element.
-  result = xmlCheckedTag(e, "span", commonAttr)
-
-macro strong*(e: expr): expr = 
-  ## generates the HTML ``strong`` element.
-  result = xmlCheckedTag(e, "strong", commonAttr)
-
-macro style*(e: expr): expr = 
-  ## generates the HTML ``style`` element.
-  result = xmlCheckedTag(e, "style", "media title", "type")
-
-macro sub*(e: expr): expr = 
-  ## generates the HTML ``sub`` element.
-  result = xmlCheckedTag(e, "sub", commonAttr)
-
-macro sup*(e: expr): expr = 
-  ## generates the HTML ``sup`` element.
-  result = xmlCheckedTag(e, "sup", commonAttr)
-
-macro table*(e: expr): expr = 
-  ## generates the HTML ``table`` element.
-  result = xmlCheckedTag(e, "table", "summary border cellpadding cellspacing" &
-    " frame rules width" & commonAttr)
-
-macro tbody*(e: expr): expr = 
-  ## generates the HTML ``tbody`` element.
-  result = xmlCheckedTag(e, "tbody", "align valign" & commonAttr)
-
-macro td*(e: expr): expr = 
-  ## generates the HTML ``td`` element.
-  result = xmlCheckedTag(e, "td", "colspan rowspan abbr axis headers scope" &
-    " align valign" & commonAttr)
-
-macro textarea*(e: expr): expr = 
-  ## generates the HTML ``textarea`` element.
-  result = xmlCheckedTag(e, "textarea", " name disabled readonly accesskey" &
-    " tabindex" & commonAttr, "rows cols", false)
-
-macro tfoot*(e: expr): expr = 
-  ## generates the HTML ``tfoot`` element.
-  result = xmlCheckedTag(e, "tfoot", "align valign" & commonAttr)
-
-macro th*(e: expr): expr = 
-  ## generates the HTML ``th`` element.
-  result = xmlCheckedTag(e, "th", "colspan rowspan abbr axis headers scope" &
-    " align valign" & commonAttr)
-
-macro thead*(e: expr): expr = 
-  ## generates the HTML ``thead`` element.
-  result = xmlCheckedTag(e, "thead", "align valign" & commonAttr)
-
-macro title*(e: expr): expr = 
-  ## generates the HTML ``title`` element.
-  result = xmlCheckedTag(e, "title")
-
-macro tr*(e: expr): expr = 
-  ## generates the HTML ``tr`` element.
-  result = xmlCheckedTag(e, "tr", "align valign" & commonAttr)
-
-macro tt*(e: expr): expr = 
-  ## generates the HTML ``tt`` element.
-  result = xmlCheckedTag(e, "tt", commonAttr)
-
-macro ul*(e: expr): expr = 
-  ## generates the HTML ``ul`` element.
-  result = xmlCheckedTag(e, "ul", commonAttr)
-
-macro `var`*(e: expr): expr = 
-  ## generates the HTML ``var`` element.
-  result = xmlCheckedTag(e, "var", commonAttr)
-
-when isMainModule:
-  var nim = "Nimrod"
-  echo h1(a(href="http://force7.de/nimrod", nim))
-
diff --git a/lib/pure/xmlparser.nim b/lib/pure/xmlparser.nim
index 635497fa8..2c1e4e37c 100755..100644
--- a/lib/pure/xmlparser.nim
+++ b/lib/pure/xmlparser.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -9,30 +9,34 @@
 
 ## This module parses an XML document and creates its XML tree representation.
 
-import streams, parsexml, strtabs, xmltree
+import std/[streams, parsexml, strtabs, xmltree]
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
 
 type
-  EInvalidXml* = object of E_Base ## exception that is raised for invalid XML
-    errors*: seq[string]          ## all detected parsing errors
+  XmlError* = object of ValueError ## Exception that is raised
+                                   ## for invalid XML.
+    errors*: seq[string]           ## All detected parsing errors.
 
-proc raiseInvalidXml(errors: seq[string]) = 
-  var e: ref EInvalidXml
+proc raiseInvalidXml(errors: seq[string]) =
+  var e: ref XmlError
   new(e)
   e.msg = errors[0]
   e.errors = errors
   raise e
 
-proc addNode(father, son: PXmlNode) = 
+proc addNode(father, son: XmlNode) =
   if son != nil: add(father, son)
 
-proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode
+proc parse(x: var XmlParser, errors: var seq[string]): XmlNode {.gcsafe.}
 
-proc untilElementEnd(x: var TXmlParser, result: PXmlNode, 
+proc untilElementEnd(x: var XmlParser, result: XmlNode,
                      errors: var seq[string]) =
   while true:
     case x.kind
-    of xmlElementEnd: 
-      if x.elementName == result.tag: 
+    of xmlElementEnd:
+      if x.elementName == result.tag:
         next(x)
       else:
         errors.add(errorMsg(x, "</" & result.tag & "> expected"))
@@ -44,9 +48,9 @@ proc untilElementEnd(x: var TXmlParser, result: PXmlNode,
     else:
       result.addNode(parse(x, errors))
 
-proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode =
+proc parse(x: var XmlParser, errors: var seq[string]): XmlNode =
   case x.kind
-  of xmlComment: 
+  of xmlComment:
     result = newComment(x.charData)
     next(x)
   of xmlCharData, xmlWhitespace:
@@ -58,20 +62,20 @@ proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode =
   of xmlError:
     errors.add(errorMsg(x))
     next(x)
-  of xmlElementStart:    ## ``<elem>``
+  of xmlElementStart: ## ``<elem>``
     result = newElement(x.elementName)
     next(x)
     untilElementEnd(x, result, errors)
   of xmlElementEnd:
     errors.add(errorMsg(x, "unexpected ending tag: " & x.elementName))
-  of xmlElementOpen: 
+  of xmlElementOpen:
     result = newElement(x.elementName)
     next(x)
-    result.attr = newStringTable()
-    while true: 
+    result.attrs = newStringTable()
+    while true:
       case x.kind
       of xmlAttribute:
-        result.attr[x.attrKey] = x.attrValue
+        result.attrs[x.attrKey] = x.attrValue
         next(x)
       of xmlElementClose:
         next(x)
@@ -88,71 +92,85 @@ proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode =
   of xmlAttribute, xmlElementClose:
     errors.add(errorMsg(x, "<some_tag> expected"))
     next(x)
-  of xmlCData: 
+  of xmlCData:
     result = newCData(x.charData)
     next(x)
   of xmlEntity:
     ## &entity;
-    errors.add(errorMsg(x, "unknown entity: " & x.entityName))
+    result = newEntity(x.entityName)
     next(x)
-  of xmlEof: nil
-
-proc parseXml*(s: PStream, filename: string, 
-               errors: var seq[string]): PXmlNode = 
-  ## parses the XML from stream `s` and returns a ``PXmlNode``. Every
-  ## occured parsing error is added to the `errors` sequence.
-  var x: TXmlParser
-  open(x, s, filename, {reportComments})
+  of xmlEof: discard
+
+proc parseXml*(s: Stream, filename: string,
+               errors: var seq[string], options: set[XmlParseOption] = {reportComments}): XmlNode =
+  ## Parses the XML from stream ``s`` and returns a ``XmlNode``. Every
+  ## occurred parsing error is added to the ``errors`` sequence.
+  var x: XmlParser
+  open(x, s, filename, options)
   while true:
     x.next()
     case x.kind
-    of xmlElementOpen, xmlElementStart: 
+    of xmlElementOpen, xmlElementStart:
       result = parse(x, errors)
       break
-    of xmlComment, xmlWhitespace: nil # just skip it
+    of xmlComment, xmlWhitespace, xmlSpecial, xmlPI: discard # just skip it
     of xmlError:
       errors.add(errorMsg(x))
-    of xmlSpecial:
-      errors.add(errorMsg(x, "<some_tag> expected"))      
     else:
       errors.add(errorMsg(x, "<some_tag> expected"))
       break
   close(x)
 
-proc parseXml*(s: PStream): PXmlNode = 
-  ## parses the XTML from stream `s` and returns a ``PXmlNode``. All parsing
-  ## errors are turned into an ``EInvalidXML`` exception.
+proc parseXml*(s: Stream, options: set[XmlParseOption] = {reportComments}): XmlNode =
+  ## Parses the XML from stream ``s`` and returns a ``XmlNode``. All parsing
+  ## errors are turned into an ``XmlError`` exception.
   var errors: seq[string] = @[]
-  result = parseXml(s, "unknown_html_doc", errors)
-  if errors.len > 0: raiseInvalidXMl(errors)
+  result = parseXml(s, "unknown_xml_doc", errors, options)
+  if errors.len > 0: raiseInvalidXml(errors)
 
-proc loadXml*(path: string, errors: var seq[string]): PXmlNode = 
-  ## Loads and parses XML from file specified by ``path``, and returns 
-  ## a ``PXmlNode``. Every occured parsing error is added to the `errors`
+proc parseXml*(str: string, options: set[XmlParseOption] = {reportComments}): XmlNode =
+  ## Parses the XML from string ``str`` and returns a ``XmlNode``. All parsing
+  ## errors are turned into an ``XmlError`` exception.
+  parseXml(newStringStream(str), options)
+
+proc loadXml*(path: string, errors: var seq[string], options: set[XmlParseOption] = {reportComments}): XmlNode =
+  ## Loads and parses XML from file specified by ``path``, and returns
+  ## a ``XmlNode``. Every occurred parsing error is added to the ``errors``
   ## sequence.
   var s = newFileStream(path, fmRead)
-  if s == nil: raise newException(EIO, "Unable to read file: " & path)
-  result = parseXml(s, path, errors)
+  if s == nil: raise newException(IOError, "Unable to read file: " & path)
+  result = parseXml(s, path, errors, options)
 
-proc loadXml*(path: string): PXmlNode = 
-  ## Loads and parses XML from file specified by ``path``, and returns 
-  ## a ``PXmlNode``.  All parsing errors are turned into an ``EInvalidXML``
-  ## exception.  
+proc loadXml*(path: string, options: set[XmlParseOption] = {reportComments}): XmlNode =
+  ## Loads and parses XML from file specified by ``path``, and returns
+  ## a ``XmlNode``. All parsing errors are turned into an ``XmlError``
+  ## exception.
   var errors: seq[string] = @[]
-  result = loadXml(path, errors)
-  if errors.len > 0: raiseInvalidXMl(errors)
+  result = loadXml(path, errors, options)
+  if errors.len > 0: raiseInvalidXml(errors)
 
 when isMainModule:
-  import os
-
-  var errors: seq[string] = @[]  
-  var x = loadXml(paramStr(1), errors)
-  for e in items(errors): echo e
-  
-  var f: TFile
-  if open(f, "xmltest.txt", fmWrite):
-    f.write($x)
-    f.close()
+  when not defined(testing):
+    import std/os
+
+    var errors: seq[string] = @[]
+    var x = loadXml(paramStr(1), errors)
+    for e in items(errors): echo e
+
+    var f: File
+    if open(f, "xmltest.txt", fmWrite):
+      f.write($x)
+      f.close()
+    else:
+      quit("cannot write test.txt")
   else:
-    quit("cannot write test.txt")
-    
+    block: # correctly parse ../../tests/testdata/doc1.xml
+      let filePath = "tests/testdata/doc1.xml"
+      var errors: seq[string] = @[]
+      var xml = loadXml(filePath, errors)
+      assert(errors.len == 0, "The file tests/testdata/doc1.xml should be parsed without errors.")
+
+    block bug1518:
+      var err: seq[string] = @[]
+      assert $parsexml(newStringStream"<tag>One &amp; two</tag>", "temp.xml",
+          err) == "<tag>One &amp; two</tag>"
diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim
index 8604078fb..5c0cbc5e4 100755..100644
--- a/lib/pure/xmltree.nim
+++ b/lib/pure/xmltree.nim
@@ -1,205 +1,806 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-## A simple XML tree. More efficient and simpler than the DOM.
+## A simple XML tree generator.
+##
+runnableExamples:
+  var g = newElement("myTag")
+  g.add newText("some text")
+  g.add newComment("this is comment")
+
+  var h = newElement("secondTag")
+  h.add newEntity("some entity")
+
+  let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+  let k = newXmlTree("treeTag", [g, h], att)
+
+  doAssert $k == """<treeTag key1="first value" key2="second value">
+  <myTag>some text<!-- this is comment --></myTag>
+  <secondTag>&some entity;</secondTag>
+</treeTag>"""
+
+## **See also:**
+## * `xmlparser module <xmlparser.html>`_ for high-level XML parsing
+## * `parsexml module <parsexml.html>`_ for low-level XML parsing
+## * `htmlgen module <htmlgen.html>`_ for html code generator
+
+import std/private/since
+import std/[macros, strtabs, strutils, sequtils]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
 
-import macros, strtabs
 
 type
-  PXmlNode* = ref TXmlNode ## an XML tree consists of ``PXmlNode``'s. 
-  
-  TXmlNodeKind* = enum  ## different kinds of ``PXmlNode``'s
-    xnText,             ## a text element
-    xnElement,          ## an element with 0 or more children
-    xnCData,            ## a CDATA node
-    xnEntity,           ## an entity (like ``&thing;``)
-    xnComment           ## an XML comment
-  
-  PXmlAttributes* = PStringTable ## an alias for a string to string mapping
-  
-  TXmlNode {.pure, final, acyclic.} = object 
-    case k: TXmlNodeKind
-    of xnText, xnComment, xnCData, xnEntity: 
+  XmlNode* = ref XmlNodeObj ## An XML tree consisting of XML nodes.
+    ##
+    ## Use `newXmlTree proc <#newXmlTree,string,openArray[XmlNode],XmlAttributes>`_
+    ## for creating a new tree.
+
+  XmlNodeKind* = enum ## Different kinds of XML nodes.
+    xnText,           ## a text element
+    xnVerbatimText,   ##
+    xnElement,        ## an element with 0 or more children
+    xnCData,          ## a CDATA node
+    xnEntity,         ## an entity (like ``&thing;``)
+    xnComment         ## an XML comment
+
+  XmlAttributes* = StringTableRef ## An alias for a string to string mapping.
+    ##
+    ## Use `toXmlAttributes proc <#toXmlAttributes,varargs[tuple[string,string]]>`_
+    ## to create `XmlAttributes`.
+
+  XmlNodeObj {.acyclic.} = object
+    case k: XmlNodeKind # private, use the kind() proc to read this field.
+    of xnText, xnVerbatimText, xnComment, xnCData, xnEntity:
       fText: string
     of xnElement:
       fTag: string
-      s: seq[PXmlNode]
-      fAttr: PXmlAttributes
-    fClientData: int              ## for other clients
-  
-proc newXmlNode(kind: TXmlNodeKind): PXmlNode = 
-  ## creates a new ``PXmlNode``.
-  new(result)
-  result.k = kind
-
-proc newElement*(tag: string): PXmlNode = 
-  ## creates a new ``PXmlNode`` of kind ``xnText`` with the given `tag`.
+      s: seq[XmlNode]
+      fAttr: XmlAttributes
+    fClientData: int    ## for other clients
+
+const
+  xmlHeader* = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+    ## Header to use for complete XML output.
+
+template expect(node: XmlNode, kind: set[XmlNodeKind]) =
+  ## Check the node's kind is within a set of values
+  assert node.k in kind, "Got " & $node.k
+
+template expect(node: XmlNode, kind: XmlNodeKind) =
+  ## Check the node's kind equals a value
+  assert node.k == kind, "Got " & $node.k
+
+proc newXmlNode(kind: XmlNodeKind): XmlNode =
+  ## Creates a new ``XmlNode``.
+  result = XmlNode(k: kind)
+
+proc newElement*(tag: sink string): XmlNode =
+  ## Creates a new ``XmlNode`` of kind ``xnElement`` with the given `tag`.
+  ##
+  ## See also:
+  ## * `newXmlTree proc <#newXmlTree,string,openArray[XmlNode],XmlAttributes>`_
+  ## * [<> macro](#<>.m,untyped)
+  runnableExamples:
+    var a = newElement("firstTag")
+    a.add newElement("childTag")
+    assert a.kind == xnElement
+    assert $a == """<firstTag>
+  <childTag />
+</firstTag>"""
+
   result = newXmlNode(xnElement)
   result.fTag = tag
   result.s = @[]
-  # init attributes lazily to safe memory
+  # init attributes lazily to save memory
+
+proc newText*(text: sink string): XmlNode =
+  ## Creates a new ``XmlNode`` of kind ``xnText`` with the text `text`.
+  runnableExamples:
+    var b = newText("my text")
+    assert b.kind == xnText
+    assert $b == "my text"
 
-proc newText*(text: string): PXmlNode = 
-  ## creates a new ``PXmlNode`` of kind ``xnText`` with the text `text`.
   result = newXmlNode(xnText)
   result.fText = text
 
-proc newComment*(comment: string): PXmlNode = 
-  ## creates a new ``PXmlNode`` of kind ``xnComment`` with the text `comment`.
+proc newVerbatimText*(text: sink string): XmlNode {.since: (1, 3).} =
+  ## Creates a new ``XmlNode`` of kind ``xnVerbatimText`` with the text `text`.
+  ## **Since**: Version 1.3.
+  result = newXmlNode(xnVerbatimText)
+  result.fText = text
+
+proc newComment*(comment: sink string): XmlNode =
+  ## Creates a new ``XmlNode`` of kind ``xnComment`` with the text `comment`.
+  runnableExamples:
+    var c = newComment("my comment")
+    assert c.kind == xnComment
+    assert $c == "<!-- my comment -->"
+
   result = newXmlNode(xnComment)
   result.fText = comment
 
-proc newCData*(cdata: string): PXmlNode = 
-  ## creates a new ``PXmlNode`` of kind ``xnComment`` with the text `cdata`.
+proc newCData*(cdata: sink string): XmlNode =
+  ## Creates a new ``XmlNode`` of kind ``xnCData`` with the text `cdata`.
+  runnableExamples:
+    var d = newCData("my cdata")
+    assert d.kind == xnCData
+    assert $d == "<![CDATA[my cdata]]>"
+
   result = newXmlNode(xnCData)
   result.fText = cdata
 
-proc newEntity*(entity: string): PXmlNode = 
-  ## creates a new ``PXmlNode`` of kind ``xnEntity`` with the text `entity`.
-  result = newXmlNode(xnCData)
+proc newEntity*(entity: string): XmlNode =
+  ## Creates a new ``XmlNode`` of kind ``xnEntity`` with the text `entity`.
+  runnableExamples:
+    var e = newEntity("my entity")
+    assert e.kind == xnEntity
+    assert $e == "&my entity;"
+
+  result = newXmlNode(xnEntity)
   result.fText = entity
 
-proc text*(n: PXmlNode): string {.inline.} = 
-  ## gets the associated text with the node `n`. `n` can be a CDATA, Text,
-  ## comment, or entity node.
-  assert n.k in {xnText, xnComment, xnCData, xnEntity}
+proc newXmlTree*(tag: sink string, children: openArray[XmlNode],
+                 attributes: XmlAttributes = nil): XmlNode =
+  ## Creates a new XML tree with `tag`, `children` and `attributes`.
+  ##
+  ## See also:
+  ## * `newElement proc <#newElement,string>`_
+  ## * [<> macro](#<>.m,untyped)
+
+  runnableExamples:
+    var g = newElement("myTag")
+    g.add newText("some text")
+    g.add newComment("this is comment")
+    var h = newElement("secondTag")
+    h.add newEntity("some entity")
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    let k = newXmlTree("treeTag", [g, h], att)
+
+    doAssert $k == """<treeTag key1="first value" key2="second value">
+  <myTag>some text<!-- this is comment --></myTag>
+  <secondTag>&some entity;</secondTag>
+</treeTag>"""
+
+  result = newXmlNode(xnElement)
+  result.fTag = tag
+  newSeq(result.s, children.len)
+  for i in 0..children.len-1: result.s[i] = children[i]
+  result.fAttr = attributes
+
+proc text*(n: XmlNode): lent string {.inline.} =
+  ## Gets the associated text with the node `n`.
+  ##
+  ## `n` can be a CDATA, Text, comment, or entity node.
+  ##
+  ## See also:
+  ## * `text= proc <#text=,XmlNode,string>`_ for text setter
+  ## * `tag proc <#tag,XmlNode>`_ for tag getter
+  ## * `tag= proc <#tag=,XmlNode,string>`_ for tag setter
+  ## * `innerText proc <#innerText,XmlNode>`_
+  runnableExamples:
+    var c = newComment("my comment")
+    assert $c == "<!-- my comment -->"
+    assert c.text == "my comment"
+
+  n.expect {xnText, xnVerbatimText, xnComment, xnCData, xnEntity}
   result = n.fText
 
-proc tag*(n: PXmlNode): string {.inline.} = 
-  ## gets the tag name of `n`. `n` has to be an ``xnElement`` node.
-  assert n.k == xnElement
+proc `text=`*(n: XmlNode, text: sink string) {.inline.} =
+  ## Sets the associated text with the node `n`.
+  ##
+  ## `n` can be a CDATA, Text, comment, or entity node.
+  ##
+  ## See also:
+  ## * `text proc <#text,XmlNode>`_ for text getter
+  ## * `tag proc <#tag,XmlNode>`_ for tag getter
+  ## * `tag= proc <#tag=,XmlNode,string>`_ for tag setter
+  runnableExamples:
+    var e = newEntity("my entity")
+    assert $e == "&my entity;"
+    e.text = "a new entity text"
+    assert $e == "&a new entity text;"
+
+  n.expect {xnText, xnVerbatimText, xnComment, xnCData, xnEntity}
+  n.fText = text
+
+proc tag*(n: XmlNode): lent string {.inline.} =
+  ## Gets the tag name of `n`.
+  ##
+  ## `n` has to be an ``xnElement`` node.
+  ##
+  ## See also:
+  ## * `text proc <#text,XmlNode>`_ for text getter
+  ## * `text= proc <#text=,XmlNode,string>`_ for text setter
+  ## * `tag= proc <#tag=,XmlNode,string>`_ for tag setter
+  ## * `innerText proc <#innerText,XmlNode>`_
+  runnableExamples:
+    var a = newElement("firstTag")
+    a.add newElement("childTag")
+    assert $a == """<firstTag>
+  <childTag />
+</firstTag>"""
+    assert a.tag == "firstTag"
+
+  n.expect xnElement
   result = n.fTag
-    
-proc add*(father, son: PXmlNode) {.inline.} = 
-  ## adds the child `son` to `father`.
+
+proc `tag=`*(n: XmlNode, tag: sink string) {.inline.} =
+  ## Sets the tag name of `n`.
+  ##
+  ## `n` has to be an ``xnElement`` node.
+  ##
+  ## See also:
+  ## * `text proc <#text,XmlNode>`_ for text getter
+  ## * `text= proc <#text=,XmlNode,string>`_ for text setter
+  ## * `tag proc <#tag,XmlNode>`_ for tag getter
+  runnableExamples:
+    var a = newElement("firstTag")
+    a.add newElement("childTag")
+    assert $a == """<firstTag>
+  <childTag />
+</firstTag>"""
+    a.tag = "newTag"
+    assert $a == """<newTag>
+  <childTag />
+</newTag>"""
+
+  n.expect xnElement
+  n.fTag = tag
+
+proc rawText*(n: XmlNode): string {.inline.} =
+  ## Returns the underlying 'text' string by reference.
+  ##
+  ## This is only used for speed hacks.
+  when defined(gcDestructors):
+    result = move(n.fText)
+  else:
+    shallowCopy(result, n.fText)
+
+proc rawTag*(n: XmlNode): string {.inline.} =
+  ## Returns the underlying 'tag' string by reference.
+  ##
+  ## This is only used for speed hacks.
+  when defined(gcDestructors):
+    result = move(n.fTag)
+  else:
+    shallowCopy(result, n.fTag)
+
+proc innerText*(n: XmlNode): string =
+  ## Gets the inner text of `n`:
+  ##
+  ## - If `n` is `xnText` or `xnEntity`, returns its content.
+  ## - If `n` is `xnElement`, runs recursively on each child node and
+  ##   concatenates the results.
+  ## - Otherwise returns an empty string.
+  ##
+  ## See also:
+  ## * `text proc <#text,XmlNode>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newText("my text")
+    f.add newComment("my comment")
+    f.add newEntity("my entity")
+    assert $f == "<myTag>my text<!-- my comment -->&my entity;</myTag>"
+    assert innerText(f) == "my textmy entity"
+
+  proc worker(res: var string, n: XmlNode) =
+    case n.k
+    of xnText, xnEntity:
+      res.add(n.fText)
+    of xnElement:
+      for sub in n.s:
+        worker(res, sub)
+    else:
+      discard
+
+  result = ""
+  worker(result, n)
+
+proc add*(father, son: XmlNode) {.inline.} =
+  ## Adds the child `son` to `father`.
+  ## `father` must be of `xnElement` type
+  ##
+  ## See also:
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newText("my text")
+    f.add newElement("sonTag")
+    f.add newEntity("my entity")
+    assert $f == "<myTag>my text<sonTag />&my entity;</myTag>"
+
+  father.expect xnElement
   add(father.s, son)
-  
-proc len*(n: PXmlNode): int {.inline.} = 
-  ## returns the number `n`'s children.
+
+proc add*(father: XmlNode, sons: openArray[XmlNode]) {.inline.} =
+  ## Adds the children `sons` to `father`.
+  ## `father` must be of `xnElement` type
+  ##
+  ## See also:
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add(@[newText("my text"), newElement("sonTag"), newEntity("my entity")])
+    assert $f == "<myTag>my text<sonTag />&my entity;</myTag>"
+
+  father.expect xnElement
+  add(father.s, sons)
+
+
+proc insert*(father, son: XmlNode, index: int) {.inline.} =
+  ## Inserts the child `son` to a given position in `father`.
+  ##
+  ## `father` must be of `xnElement` kind.
+  ##
+  ## See also:
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert(newElement("second"), 0)
+    assert $f == """<myTag>
+  <second />
+  <first />
+</myTag>"""
+
+  father.expect xnElement
+  if len(father.s) > index:
+    insert(father.s, son, index)
+  else:
+    insert(father.s, son, len(father.s))
+
+proc insert*(father: XmlNode, sons: openArray[XmlNode], index: int) {.inline.} =
+  ## Inserts the children openArray[`sons`] to a given position in `father`.
+  ##
+  ## `father` must be of `xnElement` kind.
+  ##
+  ## See also:
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert([newElement("second"), newElement("third")], 0)
+    assert $f == """<myTag>
+  <second />
+  <third />
+  <first />
+</myTag>"""
+
+  father.expect xnElement
+  if len(father.s) > index:
+    insert(father.s, sons, index)
+  else:
+    insert(father.s, sons, len(father.s))
+
+proc delete*(n: XmlNode, i: Natural) =
+  ## Deletes the `i`'th child of `n`.
+  ##
+  ## See also:
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert(newElement("second"), 0)
+    f.delete(0)
+    assert $f == """<myTag>
+  <first />
+</myTag>"""
+
+  n.expect xnElement
+  n.s.delete(i)
+
+proc delete*(n: XmlNode, slice: Slice[int]) =
+  ## Deletes the items `n[slice]` of `n`.
+  ##
+  ## See also:
+  ## * `delete proc <#delete.XmlNode,int>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert([newElement("second"), newElement("third")], 0)
+    f.delete(0..1)
+    assert $f == """<myTag>
+  <first />
+</myTag>"""
+
+  n.expect xnElement
+  n.s.delete(slice)
+
+proc replace*(n: XmlNode, i: Natural, replacement: openArray[XmlNode]) =
+  ## Replaces the `i`'th child of `n` with `replacement` openArray.
+  ##
+  ## `n` must be of `xnElement` kind.
+  ##
+  ## See also:
+  ## * `replace proc <#replace.XmlNode,Slice[int],openArray[XmlNode]>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert(newElement("second"), 0)
+    f.replace(0, @[newElement("third"), newElement("fourth")])
+    assert $f == """<myTag>
+  <third />
+  <fourth />
+  <first />
+</myTag>"""
+
+  n.expect xnElement
+  n.s.delete(i)
+  n.s.insert(replacement, i)
+
+proc replace*(n: XmlNode, slice: Slice[int], replacement: openArray[XmlNode]) =
+  ## Deletes the items `n[slice]` of `n`.
+  ##
+  ## `n` must be of `xnElement` kind.
+  ##
+  ## See also:
+  ## * `replace proc <#replace.XmlNode,int,openArray[XmlNode]>`_
+  ## * `add proc <#add,XmlNode,XmlNode>`_
+  ## * `add proc <#add,XmlNode,openArray[XmlNode]>`_
+  ## * `delete proc <#delete,XmlNode,Natural>`_
+  ## * `delete proc <#delete.XmlNode,Slice[int]>`_
+  ## * `insert proc <#insert,XmlNode,XmlNode,int>`_
+  ## * `insert proc <#insert,XmlNode,openArray[XmlNode],int>`_
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert([newElement("second"), newElement("fifth")], 0)
+    f.replace(0..1, @[newElement("third"), newElement("fourth")])
+    assert $f == """<myTag>
+  <third />
+  <fourth />
+  <first />
+</myTag>"""
+
+  n.expect xnElement
+  n.s.delete(slice)
+  n.s.insert(replacement, slice.a)
+
+proc len*(n: XmlNode): int {.inline.} =
+  ## Returns the number of `n`'s children.
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert(newElement("second"), 0)
+    assert len(f) == 2
   if n.k == xnElement: result = len(n.s)
 
-proc kind*(n: PXmlNode): TXmlNodeKind {.inline.} =
-  ## returns `n`'s kind.
+proc kind*(n: XmlNode): XmlNodeKind {.inline.} =
+  ## Returns `n`'s kind.
+  runnableExamples:
+    var a = newElement("firstTag")
+    assert a.kind == xnElement
+    var b = newText("my text")
+    assert b.kind == xnText
   result = n.k
 
-proc `[]`* (n: PXmlNode, i: int): PXmlNode {.inline.} = 
-  ## returns the `i`'th child of `n`.
-  assert n.k == xnElement
+proc `[]`*(n: XmlNode, i: int): XmlNode {.inline.} =
+  ## Returns the `i`'th child of `n`.
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("first")
+    f.insert(newElement("second"), 0)
+    assert $f[1] == "<first />"
+    assert $f[0] == "<second />"
+
+  n.expect xnElement
+  result = n.s[i]
+
+proc `[]`*(n: var XmlNode, i: int): var XmlNode {.inline.} =
+  ## Returns the `i`'th child of `n` so that it can be modified.
+  n.expect xnElement
   result = n.s[i]
 
-iterator items*(n: PXmlNode): PXmlNode {.inline.} = 
-  ## iterates over any child of `n`.
-  assert n.k == xnElement
+proc clear*(n: var XmlNode) =
+  ## Recursively clears all children of an XmlNode.
+  ##
+  runnableExamples:
+    var g = newElement("myTag")
+    g.add newText("some text")
+    g.add newComment("this is comment")
+
+    var h = newElement("secondTag")
+    h.add newEntity("some entity")
+
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    var k = newXmlTree("treeTag", [g, h], att)
+
+    doAssert $k == """<treeTag key1="first value" key2="second value">
+  <myTag>some text<!-- this is comment --></myTag>
+  <secondTag>&some entity;</secondTag>
+</treeTag>"""
+
+    clear(k)
+    doAssert $k == """<treeTag key1="first value" key2="second value" />"""
+
+  for i in 0 ..< n.len:
+    clear(n[i])
+  if n.k == xnElement:
+    n.s.setLen(0)
+
+
+iterator items*(n: XmlNode): XmlNode {.inline.} =
+  ## Iterates over all direct children of `n`.
+
+  runnableExamples:
+    var g = newElement("myTag")
+    g.add newText("some text")
+    g.add newComment("this is comment")
+
+    var h = newElement("secondTag")
+    h.add newEntity("some entity")
+    g.add h
+
+    assert $g == "<myTag>some text<!-- this is comment --><secondTag>&some entity;</secondTag></myTag>"
+
+    # for x in g: # the same as `for x in items(g):`
+    #   echo x
+
+    # some text
+    # <!-- this is comment -->
+    # <secondTag>&some entity;<![CDATA[some cdata]]></secondTag>
+
+  n.expect xnElement
   for i in 0 .. n.len-1: yield n[i]
 
-proc attr*(n: PXmlNode): PXmlAttributes {.inline.} = 
-  ## gets the attributes belonging to `n`.
-  assert n.k == xnElement
+iterator mitems*(n: var XmlNode): var XmlNode {.inline.} =
+  ## Iterates over all direct children of `n` so that they can be modified.
+  n.expect xnElement
+  for i in 0 .. n.len-1: yield n[i]
+
+proc toXmlAttributes*(keyValuePairs: varargs[tuple[key,
+    val: string]]): XmlAttributes =
+  ## Converts `{key: value}` pairs into `XmlAttributes`.
+  ##
+  runnableExamples:
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    var j = newElement("myTag")
+    j.attrs = att
+
+    doAssert $j == """<myTag key1="first value" key2="second value" />"""
+
+  newStringTable(keyValuePairs)
+
+proc attrs*(n: XmlNode): XmlAttributes {.inline.} =
+  ## Gets the attributes belonging to `n`.
+  ##
+  ## Returns `nil` if attributes have not been initialised for this node.
+  ##
+  ## See also:
+  ## * `attrs= proc <#attrs=,XmlNode,XmlAttributes>`_ for XmlAttributes setter
+  ## * `attrsLen proc <#attrsLen,XmlNode>`_ for number of attributes
+  ## * `attr proc <#attr,XmlNode,string>`_ for finding an attribute
+  runnableExamples:
+    var j = newElement("myTag")
+    assert j.attrs == nil
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    j.attrs = att
+    assert j.attrs == att
+
+  n.expect xnElement
   result = n.fAttr
-  
-proc `attr=`*(n: PXmlNode, attr: PXmlAttributes) {.inline.} = 
-  ## sets the attributes belonging to `n`.
-  assert n.k == xnElement
+
+proc `attrs=`*(n: XmlNode, attr: XmlAttributes) {.inline.} =
+  ## Sets the attributes belonging to `n`.
+  ##
+  ## See also:
+  ## * `attrs proc <#attrs,XmlNode>`_ for XmlAttributes getter
+  ## * `attrsLen proc <#attrsLen,XmlNode>`_ for number of attributes
+  ## * `attr proc <#attr,XmlNode,string>`_ for finding an attribute
+  runnableExamples:
+    var j = newElement("myTag")
+    assert j.attrs == nil
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    j.attrs = att
+    assert j.attrs == att
+
+  n.expect xnElement
   n.fAttr = attr
 
-proc attrLen*(n: PXmlNode): int {.inline.} = 
-  ## returns the number of `n`'s attributes.
-  assert n.k == xnElement
+proc attrsLen*(n: XmlNode): int {.inline.} =
+  ## Returns the number of `n`'s attributes.
+  ##
+  ## See also:
+  ## * `attrs proc <#attrs,XmlNode>`_ for XmlAttributes getter
+  ## * `attrs= proc <#attrs=,XmlNode,XmlAttributes>`_ for XmlAttributes setter
+  ## * `attr proc <#attr,XmlNode,string>`_ for finding an attribute
+  runnableExamples:
+    var j = newElement("myTag")
+    assert j.attrsLen == 0
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    j.attrs = att
+    assert j.attrsLen == 2
+
+  n.expect xnElement
   if not isNil(n.fAttr): result = len(n.fAttr)
 
-proc clientData*(n: PXmlNode): int {.inline.} =
-  ## gets the client data of `n`. The client data field is used by the HTML
-  ## parser and generator.
+proc attr*(n: XmlNode, name: string): string =
+  ## Finds the first attribute of `n` with a name of `name`.
+  ## Returns "" on failure.
+  ##
+  ## See also:
+  ## * `attrs proc <#attrs,XmlNode>`_ for XmlAttributes getter
+  ## * `attrs= proc <#attrs=,XmlNode,XmlAttributes>`_ for XmlAttributes setter
+  ## * `attrsLen proc <#attrsLen,XmlNode>`_ for number of attributes
+  runnableExamples:
+    var j = newElement("myTag")
+    let att = {"key1": "first value", "key2": "second value"}.toXmlAttributes
+    j.attrs = att
+    assert j.attr("key1") == "first value"
+    assert j.attr("key2") == "second value"
+
+  n.expect xnElement
+  if n.attrs == nil: return ""
+  return n.attrs.getOrDefault(name)
+
+proc clientData*(n: XmlNode): int {.inline.} =
+  ## Gets the client data of `n`.
+  ##
+  ## The client data field is used by the HTML parser and generator.
   result = n.fClientData
 
-proc `clientData=`*(n: PXmlNode, data: int) {.inline.} = 
-  ## sets the client data of `n`. The client data field is used by the HTML
-  ## parser and generator.
+proc `clientData=`*(n: XmlNode, data: int) {.inline.} =
+  ## Sets the client data of `n`.
+  ##
+  ## The client data field is used by the HTML parser and generator.
   n.fClientData = data
 
-proc addEscaped*(result: var string, s: string) = 
-  ## same as ``result.add(escape(s))``, but more efficient.
+proc addEscaped*(result: var string, s: string) =
+  ## The same as `result.add(escape(s)) <#escape,string>`_, but more efficient.
   for c in items(s):
     case c
     of '<': result.add("&lt;")
     of '>': result.add("&gt;")
     of '&': result.add("&amp;")
     of '"': result.add("&quot;")
+    of '\'': result.add("&apos;")
     else: result.add(c)
 
-proc escape*(s: string): string = 
-  ## escapes `s` for inclusion into an XML document. 
+proc escape*(s: string): string =
+  ## Escapes `s` for inclusion into an XML document.
+  ##
   ## Escapes these characters:
   ##
-  ## ------------    -------------------
+  ## ============    ===================
   ## char            is converted to
-  ## ------------    -------------------
+  ## ============    ===================
   ##  ``<``          ``&lt;``
   ##  ``>``          ``&gt;``
   ##  ``&``          ``&amp;``
   ##  ``"``          ``&quot;``
-  ## ------------    -------------------
-  result = newString(s.len)
-  setLen(result, 0)
+  ##  ``'``          ``&apos;``
+  ## ============    ===================
+  ##
+  ## You can also use `addEscaped proc <#addEscaped,string,string>`_.
+  result = newStringOfCap(s.len)
   addEscaped(result, s)
-  
-proc addIndent(result: var string, indent: int) = 
-  result.add("\n")
-  for i in 1..indent: result.add(' ')
-  
-proc noWhitespace(n: PXmlNode): bool =
-  #for i in 1..n.len-1:
-  #  if n[i].kind != n[0].kind: return true
-  for i in 0..n.len-1:
-    if n[i].kind in {xnText, xnEntity}: return true
-  
-proc add*(result: var string, n: PXmlNode, indent = 0, indWidth = 2) = 
-  ## adds the textual representation of `n` to `result`.
+
+proc addIndent(result: var string, indent: int, addNewLines: bool) =
+  if addNewLines:
+    result.add("\n")
+  for i in 1 .. indent:
+    result.add(' ')
+
+proc addImpl(result: var string, n: XmlNode, indent = 0, indWidth = 2,
+          addNewLines = true, lastNodeIsText = false) =
+  proc noWhitespace(n: XmlNode): bool =
+    for i in 0 ..< n.len:
+      if n[i].kind in {xnText, xnVerbatimText, xnEntity}: return true
+
+  proc addEscapedAttr(result: var string, s: string) =
+    # `addEscaped` alternative with less escaped characters.
+    # Only to be used for escaping attribute values enclosed in double quotes!
+    for c in items(s):
+      case c
+      of '<': result.add("&lt;")
+      of '>': result.add("&gt;")
+      of '&': result.add("&amp;")
+      of '"': result.add("&quot;")
+      else: result.add(c)
+
   if n == nil: return
+
   case n.k
   of xnElement:
+    if indent > 0 and not lastNodeIsText:
+      result.addIndent(indent, addNewLines)
+
+    let
+      addNewLines = if n.noWhitespace():
+                      false
+                    else:
+                      addNewLines
+
     result.add('<')
     result.add(n.fTag)
-    if not isNil(n.fAttr): 
-      for key, val in pairs(n.fAttr): 
+    if not isNil(n.fAttr):
+      for key, val in pairs(n.fAttr):
         result.add(' ')
         result.add(key)
         result.add("=\"")
-        result.addEscaped(val)
+        result.addEscapedAttr(val)
         result.add('"')
-    if n.len > 0:
-      result.add('>')
-      if n.len > 1:
-        if noWhitespace(n):
-          # for mixed leaves, we cannot output whitespace for readability,
-          # because this would be wrong. For example: ``a<b>b</b>`` is
-          # different from ``a <b>b</b>``.
-          for i in 0..n.len-1: result.add(n[i], indent+indWidth, indWidth)
-        else: 
-          for i in 0..n.len-1:
-            result.addIndent(indent+indWidth)
-            result.add(n[i], indent+indWidth, indWidth)
-          result.addIndent(indent)
-      else:
-        result.add(n[0], indent+indWidth, indWidth)
-      result.add("</")
-      result.add(n.fTag)
-      result.add(">")
-    else: 
+
+    if n.len == 0:
       result.add(" />")
+      return
+
+    let
+      indentNext = if n.noWhitespace():
+                     indent
+                   else:
+                     indent+indWidth
+    result.add('>')
+    var lastNodeIsText = false
+    for i in 0 ..< n.len:
+      result.addImpl(n[i], indentNext, indWidth, addNewLines, lastNodeIsText)
+      lastNodeIsText = (n[i].kind == xnText) or (n[i].kind == xnVerbatimText)
+
+    if not n.noWhitespace():
+      result.addIndent(indent, addNewLines)
+
+    result.add("</")
+    result.add(n.fTag)
+    result.add(">")
   of xnText:
     result.addEscaped(n.fText)
+  of xnVerbatimText:
+    result.add(n.fText)
   of xnComment:
     result.add("<!-- ")
     result.addEscaped(n.fText)
     result.add(" -->")
-  of xnCDATA:
+  of xnCData:
     result.add("<![CDATA[")
     result.add(n.fText)
     result.add("]]>")
@@ -208,57 +809,138 @@ proc add*(result: var string, n: PXmlNode, indent = 0, indWidth = 2) =
     result.add(n.fText)
     result.add(';')
 
-const
-  xmlHeader* = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" 
-    ## header to use for complete XML output
+proc add*(result: var string, n: XmlNode, indent = 0, indWidth = 2,
+          addNewLines = true) {.inline.} =
+  ## Adds the textual representation of `n` to string `result`.
+  runnableExamples:
+    var
+      a = newElement("firstTag")
+      b = newText("my text")
+      c = newComment("my comment")
+      s = ""
+    s.add(c)
+    s.add(a)
+    s.add(b)
+    assert s == "<!-- my comment --><firstTag />my text"
+  result.addImpl(n, indent, indWidth, addNewLines)
 
-proc `$`*(n: PXmlNode): string =
-  ## converts `n` into its string representation. No ``<$xml ...$>`` declaration
-  ## is produced, so that the produced XML fragments are composable.
+proc `$`*(n: XmlNode): string =
+  ## Converts `n` into its string representation.
+  ##
+  ## No ``<$xml ...$>`` declaration is produced, so that the produced
+  ## XML fragments are composable.
   result = ""
   result.add(n)
 
-proc newXmlTree*(tag: string, children: openArray[PXmlNode],
-                 attributes: PXmlAttributes = nil): PXmlNode = 
-  ## creates a new XML tree with `tag`, `children` and `attributes`
-  result = newXmlNode(xnElement)
-  result.fTag = tag
-  newSeq(result.s, children.len)
-  for i in 0..children.len-1: result.s[i] = children[i]
-  result.fAttr = attributes
-  
-proc xmlConstructor(e: PNimrodNode): PNimrodNode {.compileTime.} =
-  expectLen(e, 2)
-  var a = e[1]
+proc child*(n: XmlNode, name: string): XmlNode =
+  ## Finds the first child element of `n` with a name of `name`.
+  ## Returns `nil` on failure.
+  runnableExamples:
+    var f = newElement("myTag")
+    f.add newElement("firstSon")
+    f.add newElement("secondSon")
+    f.add newElement("thirdSon")
+    assert $(f.child("secondSon")) == "<secondSon />"
+
+  n.expect xnElement
+  for i in items(n):
+    if i.kind == xnElement:
+      if i.tag == name:
+        return i
+
+proc findAll*(n: XmlNode, tag: string, result: var seq[XmlNode],
+    caseInsensitive = false) =
+  ## Iterates over all the children of `n` returning those matching `tag`.
+  ##
+  ## Found nodes satisfying the condition will be appended to the `result`
+  ## sequence.
+  runnableExamples:
+    var
+      b = newElement("good")
+      c = newElement("bad")
+      d = newElement("BAD")
+      e = newElement("GOOD")
+    b.add newText("b text")
+    c.add newText("c text")
+    d.add newText("d text")
+    e.add newText("e text")
+    let a = newXmlTree("father", [b, c, d, e])
+    var s = newSeq[XmlNode]()
+    a.findAll("good", s)
+    assert $s == "@[<good>b text</good>]"
+    s.setLen(0)
+    a.findAll("good", s, caseInsensitive = true)
+    assert $s == "@[<good>b text</good>, <GOOD>e text</GOOD>]"
+    s.setLen(0)
+    a.findAll("BAD", s)
+    assert $s == "@[<BAD>d text</BAD>]"
+    s.setLen(0)
+    a.findAll("BAD", s, caseInsensitive = true)
+    assert $s == "@[<bad>c text</bad>, <BAD>d text</BAD>]"
+
+  n.expect xnElement
+  for child in n.items():
+    if child.k != xnElement:
+      continue
+    if child.tag == tag or
+        (caseInsensitive and cmpIgnoreCase(child.tag, tag) == 0):
+      result.add(child)
+    child.findAll(tag, result)
+
+proc findAll*(n: XmlNode, tag: string, caseInsensitive = false): seq[XmlNode] =
+  ## A shortcut version to assign in let blocks.
+  runnableExamples:
+    var
+      b = newElement("good")
+      c = newElement("bad")
+      d = newElement("BAD")
+      e = newElement("GOOD")
+    b.add newText("b text")
+    c.add newText("c text")
+    d.add newText("d text")
+    e.add newText("e text")
+    let a = newXmlTree("father", [b, c, d, e])
+    assert $(a.findAll("good")) == "@[<good>b text</good>]"
+    assert $(a.findAll("BAD")) == "@[<BAD>d text</BAD>]"
+    assert $(a.findAll("good", caseInsensitive = true)) == "@[<good>b text</good>, <GOOD>e text</GOOD>]"
+    assert $(a.findAll("BAD", caseInsensitive = true)) == "@[<bad>c text</bad>, <BAD>d text</BAD>]"
+
+  newSeq(result, 0)
+  findAll(n, tag, result, caseInsensitive)
+
+proc xmlConstructor(a: NimNode): NimNode =
   if a.kind == nnkCall:
     result = newCall("newXmlTree", toStrLit(a[0]))
     var attrs = newNimNode(nnkBracket, a)
-    var newStringTabCall = newCall("newStringTable", attrs, 
-                                   newIdentNode("modeCaseSensitive"))
+    var newStringTabCall = newCall(bindSym"newStringTable", attrs,
+                                    bindSym"modeCaseSensitive")
     var elements = newNimNode(nnkBracket, a)
     for i in 1..a.len-1:
       if a[i].kind == nnkExprEqExpr:
-        attrs.add(toStrLit(a[i][0]))
+        # In order to support attributes like `data-lang` we have to
+        # replace whitespace because `toStrLit` gives `data - lang`.
+        let attrName = toStrLit(a[i][0]).strVal.replace(" ", "")
+        attrs.add(newStrLitNode(attrName))
         attrs.add(a[i][1])
-        echo repr(attrs)
+        #echo repr(attrs)
       else:
         elements.add(a[i])
     result.add(elements)
-    if attrs.len > 1: 
-      echo repr(newStringTabCall)
+    if attrs.len > 1:
+      #echo repr(newStringTabCall)
       result.add(newStringTabCall)
   else:
     result = newCall("newXmlTree", toStrLit(a))
 
-macro `<>`*(x: expr): expr = 
+macro `<>`*(x: untyped): untyped =
   ## Constructor macro for XML. Example usage:
   ##
-  ## .. code-block:: nimrod
-  ##   <>a(href="http://force7.de/nimrod", "Nimrod rules.")
+  ##   ```nim
+  ##   <>a(href="http://nim-lang.org", newText("Nim rules."))
+  ##   ```
   ##
-  ## Produces an XML tree for::
+  ## Produces an XML tree for:
   ##
-  ##  <a href="http://force7.de/nimrod">Nimrod rules.</a>
+  ##     <a href="http://nim-lang.org">Nim rules.</a>
   ##
   result = xmlConstructor(x)
-
diff --git a/lib/pure/yamllexer.nim b/lib/pure/yamllexer.nim
deleted file mode 100755
index 4640179c1..000000000
--- a/lib/pure/yamllexer.nim
+++ /dev/null
@@ -1,355 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module implements a simple high performance `YAML`:idx:
-## lexer. This is used by the ``yamlparser`` module, but it can be useful
-## to avoid ``yamlparser`` for its overhead. 
-
-import 
-  hashes, strutils, lexbase, streams, unicode
-
-type 
-  TTokenKind* = enum ## YAML tokens
-    tkError,
-    tkEof,
-    tkString,
-    tkNumber,
-    tkTrue,
-    tkFalse,
-    tkNull,
-    tkCurlyLe,
-    tkCurlyRi,
-    tkBracketLe,
-    tkBracketRi,
-    tkColon,
-    tkComma
-
-  TYamlLexer* = object of TBaseLexer ## the lexer object.
-    a: string
-    kind: TJsonEventKind
-    err: TJsonError
-    state: seq[TParserState]
-    filename: string
- 
-proc open*(my: var TYamlLexer, input: PStream, filename: string) =
-  ## initializes the parser with an input stream. `Filename` is only used
-  ## for nice error messages.
-  lexbase.open(my, input)
-  my.filename = filename
-  my.state = @[stateNormal]
-  my.kind = jsonError
-  my.a = ""
-  
-proc close*(my: var TYamlLexer) {.inline.} = 
-  ## closes the parser `my` and its associated input stream.
-  lexbase.close(my)
-
-proc getColumn*(my: TYamlLexer): int {.inline.} = 
-  ## get the current column the parser has arrived at.
-  result = getColNumber(my, my.bufPos)
-
-proc getLine*(my: TYamlLexer): int {.inline.} = 
-  ## get the current line the parser has arrived at.
-  result = my.linenumber
-
-proc getFilename*(my: TYamlLexer): string {.inline.} = 
-  ## get the filename of the file that the parser processes.
-  result = my.filename
-  
-proc handleHexChar(c: Char, x: var TRune): bool = 
-  result = true # Success
-  case c
-  of '0'..'9': x = (x shl 4) or (ord(c) - ord('0'))
-  of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10)
-  of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
-  else: result = false # error
-
-proc parseString(my: var TYamlLexer): TTokKind =
-  result = tkString
-  var pos = my.bufpos + 1
-  var buf = my.buf
-  while true:
-    case buf[pos] 
-    of '\0': 
-      my.err = errQuoteExpected
-      result = tkError
-      break
-    of '"':
-      inc(pos)
-      break
-    of '\\':
-      case buf[pos+1]
-      of '\\', '"', '\'', '/': 
-        add(my.a, buf[pos+1])
-        inc(pos, 2)
-      of 'b':
-        add(my.a, '\b')
-        inc(pos, 2)      
-      of 'f':
-        add(my.a, '\f')
-        inc(pos, 2)      
-      of 'n':
-        add(my.a, '\L')
-        inc(pos, 2)      
-      of 'r':
-        add(my.a, '\C')
-        inc(pos, 2)    
-      of 't':
-        add(my.a, '\t')
-        inc(pos, 2)
-      of 'u':
-        inc(pos, 2)
-        var r: TRune
-        if handleHexChar(buf[pos], r): inc(pos)
-        if handleHexChar(buf[pos], r): inc(pos)
-        if handleHexChar(buf[pos], r): inc(pos)
-        if handleHexChar(buf[pos], r): inc(pos)
-        add(my.a, toUTF8(r))
-      else: 
-        # don't bother with the error
-        add(my.a, buf[pos])
-        inc(pos)
-    of '\c': 
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
-      add(my.a, '\c')
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
-      add(my.a, '\L')
-    else:
-      add(my.a, buf[pos])
-      inc(pos)
-  my.bufpos = pos # store back
-  
-proc skip(my: var TYamlLexer) = 
-  var pos = my.bufpos
-  var buf = my.buf
-  while true: 
-    case buf[pos]
-    of '#':
-      # skip line comment:
-      inc(pos)
-      while true:
-        case buf[pos] 
-        of '\0': break
-        of '\c': 
-          pos = lexbase.HandleCR(my, pos)
-          buf = my.buf
-          break
-        of '\L': 
-          pos = lexbase.HandleLF(my, pos)
-          buf = my.buf
-          break
-        else:
-          inc(pos)
-    of '/': 
-      if buf[pos+1] == '/': 
-        # skip line comment:
-        inc(pos, 2)
-        while true:
-          case buf[pos] 
-          of '\0': 
-            break
-          of '\c': 
-            pos = lexbase.HandleCR(my, pos)
-            buf = my.buf
-            break
-          of '\L': 
-            pos = lexbase.HandleLF(my, pos)
-            buf = my.buf
-            break
-          else:
-            inc(pos)
-      elif buf[pos+1] == '*':
-        # skip long comment:
-        inc(pos, 2)
-        while true:
-          case buf[pos] 
-          of '\0': 
-            my.err = errEOC_Expected
-            break
-          of '\c': 
-            pos = lexbase.HandleCR(my, pos)
-            buf = my.buf
-          of '\L': 
-            pos = lexbase.HandleLF(my, pos)
-            buf = my.buf
-          of '*':
-            inc(pos)
-            if buf[pos] == '/': 
-              inc(pos)
-              break
-          else:
-            inc(pos)
-      else: 
-        break
-    of ' ', '\t': 
-      Inc(pos)
-    of '\c':  
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
-    else:
-      break
-  my.bufpos = pos
-
-proc parseDirective(my: var TYamlLexer) = 
-  var pos = my.bufpos
-  var buf = my.buf
-  inc(pos)
-  while buf[pos] in {'\t', ' '}: inc(pos)
-  while true:
-    case buf[pos] 
-    of '\0': break
-    of '\c': 
-      pos = lexbase.HandleCR(my, pos)
-      buf = my.buf
-      break
-    of '\L': 
-      pos = lexbase.HandleLF(my, pos)
-      buf = my.buf
-      break
-    else:
-      add(my.a, buf[pos])
-      inc(pos)
-
-proc parseNumber(my: var TYamlLexer) = 
-  var pos = my.bufpos
-  var buf = my.buf
-  if buf[pos] == '-': 
-    add(my.a, '-')
-    inc(pos)
-  if buf[pos] == '.': 
-    add(my.a, "0.")
-    inc(pos)
-  else:
-    while buf[pos] in Digits:
-      add(my.a, buf[pos])
-      inc(pos)
-    if buf[pos] == '.':
-      add(my.a, '.')
-      inc(pos)
-  # digits after the dot:
-  while buf[pos] in Digits:
-    add(my.a, buf[pos])
-    inc(pos)
-  if buf[pos] in {'E', 'e'}:
-    add(my.a, buf[pos])
-    inc(pos)
-    if buf[pos] in {'+', '-'}:
-      add(my.a, buf[pos])
-      inc(pos)
-    while buf[pos] in Digits:
-      add(my.a, buf[pos])
-      inc(pos)
-  my.bufpos = pos
-
-proc parseName(my: var TYamlLexer) = 
-  var pos = my.bufpos
-  var buf = my.buf
-  if buf[pos] in IdentStartChars:
-    while buf[pos] in IdentChars:
-      add(my.a, buf[pos])
-      inc(pos)
-  my.bufpos = pos
-
-proc getTok(my: var TYamlLexer): TTokKind = 
-  setLen(my.a, 0)
-  skip(my) # skip whitespace, comments
-  case my.buf[my.bufpos]
-  of '-': 
-    inc(my.bufpos)
-    result = tkHyphen
-  of '-', '.', '0'..'9': 
-    parseNumber(my)
-    result = tkNumber
-  of '"':
-    result = parseString(my)
-  of '\'':
-    result = parseSingleQuote(my)
-  of '[':
-    inc(my.bufpos)
-    result = tkBracketLe
-  of '{':
-    inc(my.bufpos)
-    result = tkCurlyLe
-  of ']':
-    inc(my.bufpos)
-    result = tkBracketRi
-  of '}':
-    inc(my.bufpos)
-    result = tkCurlyRi
-  of ',':
-    inc(my.bufpos)
-    result = tkComma
-  of ':':
-    inc(my.bufpos)
-    result = tkColon
-  of '?':
-    inc(my.bufpos)
-    result = tkQust
-  of '!':
-    inc(my.bufpos)
-    result = tkExcl
-  of '&':
-    inc(my.bufpos)
-    result = tkAmp
-  of '*':
-    inc(my.bufpos)
-    result = tkStar
-  of '|':
-    parseLiteralBlockScalar(my)
-    result = tkLiteralBlockScalar
-  of '>':
-    parseFoldedBlockScalar(my)
-    result = tkFoldedBlockScalar
-  of '%': 
-    parseDirective(my)
-    result = tkDirective
-  of '@', '`': 
-    inc(my.bufpos)
-    result = tkReserved
-  of 'a'..'z', 'A'..'Z', '_':
-    parseName(my)
-    case my.a 
-    of "null": result = tkNull
-    of "true": result = tkTrue
-    of "false": result = tkFalse
-    else: result = tkError
-  of '\0':
-    result = tkEof
-  else: 
-    inc(my.bufpos)
-    result = tkError
-  
-when isMainModule:
-  import os
-  var s = newFileStream(ParamStr(1), fmRead)
-  if s == nil: quit("cannot open the file" & ParamStr(1))
-  var x: TYamlLexer
-  open(x, s, ParamStr(1))
-  while true:
-    next(x)
-    case x.kind
-    of jsonError: Echo(x.errorMsg())
-    of jsonEof: break
-    of jsonString, jsonNumber: echo(x.str)
-    of jsonTrue: Echo("!TRUE")
-    of jsonFalse: Echo("!FALSE")
-    of jsonNull: Echo("!NULL")
-    of jsonObjectStart: Echo("{")
-    of jsonObjectEnd: Echo("}")
-    of jsonArrayStart: Echo("[")
-    of jsonArrayEnd: Echo("]")
-    
-  close(x)
-
diff --git a/lib/std/appdirs.nim b/lib/std/appdirs.nim
new file mode 100644
index 000000000..963451efe
--- /dev/null
+++ b/lib/std/appdirs.nim
@@ -0,0 +1,94 @@
+## This module implements helpers for determining special directories used by apps.
+
+## .. importdoc:: paths.nim
+
+from std/private/osappdirs import nil
+import std/paths
+import std/envvars
+
+proc getHomeDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the home directory of the current user.
+  ##
+  ## This proc is wrapped by the `expandTilde proc`_
+  ## for the convenience of processing paths coming from user configuration files.
+  ##
+  ## See also:
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  result = Path(osappdirs.getHomeDir())
+
+proc getDataDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the data directory of the current user for applications.
+  ## 
+  ## On non-Windows OSs, this proc conforms to the XDG Base Directory
+  ## spec. Thus, this proc returns the value of the `XDG_DATA_HOME` environment
+  ## variable if it is set, otherwise it returns the default configuration
+  ## directory ("~/.local/share" or "~/Library/Application Support" on macOS).
+  ## 
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  result = Path(osappdirs.getDataDir())
+
+proc getConfigDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the config directory of the current user for applications.
+  ##
+  ## On non-Windows OSs, this proc conforms to the XDG Base Directory
+  ## spec. Thus, this proc returns the value of the `XDG_CONFIG_HOME` environment
+  ## variable if it is set, otherwise it returns the default configuration
+  ## directory ("~/.config/").
+  ##
+  ## An OS-dependent trailing slash is always present at the end of the
+  ## returned string: `\\` on Windows and `/` on all other OSs.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getTempDir proc`_
+  result = Path(osappdirs.getConfigDir())
+
+proc getCacheDir*(): Path {.inline.} =
+  ## Returns the cache directory of the current user for applications.
+  ##
+  ## This makes use of the following environment variables:
+  ##
+  ## * On Windows: `getEnv("LOCALAPPDATA")`
+  ##
+  ## * On macOS: `getEnv("XDG_CACHE_HOME", getEnv("HOME") / "Library/Caches")`
+  ##
+  ## * On other platforms: `getEnv("XDG_CACHE_HOME", getEnv("HOME") / ".cache")`
+  ##
+  ## **See also:**
+  ## * `getHomeDir proc`_
+  ## * `getTempDir proc`_
+  ## * `getConfigDir proc`_
+  # follows https://crates.io/crates/platform-dirs
+  result = Path(osappdirs.getCacheDir())
+
+proc getCacheDir*(app: Path): Path {.inline.} =
+  ## Returns the cache directory for an application `app`.
+  ##
+  ## * On Windows, this uses: `getCacheDir() / app / "cache"`
+  ## * On other platforms, this uses: `getCacheDir() / app`
+  result = Path(osappdirs.getCacheDir(app.string))
+
+proc getTempDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the temporary directory of the current user for applications to
+  ## save temporary files in.
+  ##
+  ## On Windows, it calls [GetTempPath](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw).
+  ## On Posix based platforms, it will check `TMPDIR`, `TEMP`, `TMP` and `TEMPDIR` environment variables in order.
+  ## On all platforms, `/tmp` will be returned if the procs fails.
+  ##
+  ## You can override this implementation
+  ## by adding `-d:tempDir=mytempname` to your compiler invocation.
+  ##
+  ## .. Note:: This proc does not check whether the returned path exists.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  result = Path(osappdirs.getTempDir())
diff --git a/lib/std/assertions.nim b/lib/std/assertions.nim
new file mode 100644
index 000000000..56c37d205
--- /dev/null
+++ b/lib/std/assertions.nim
@@ -0,0 +1,122 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when not defined(nimPreviewSlimSystem) and not declared(sysFatal):
+  include "system/rawquits"
+  include "system/fatal"
+
+## This module implements assertion handling.
+
+import std/private/miscdollars
+# ---------------------------------------------------------------------------
+# helpers
+
+type InstantiationInfo = tuple[filename: string, line: int, column: int]
+
+proc `$`(info: InstantiationInfo): string =
+  # The +1 is needed here
+  # instead of overriding `$` (and changing its meaning), consider explicit name.
+  result = ""
+  result.toLocation(info.filename, info.line, info.column + 1)
+
+# ---------------------------------------------------------------------------
+
+
+proc raiseAssert*(msg: string) {.noinline, noreturn, nosinks.} =
+  ## Raises an `AssertionDefect` with `msg`.
+  when defined(nimPreviewSlimSystem):
+    raise newException(AssertionDefect, msg)
+  else:
+    sysFatal(AssertionDefect, msg)
+
+proc failedAssertImpl*(msg: string) {.raises: [], tags: [].} =
+  ## Raises an `AssertionDefect` with `msg`, but this is hidden
+  ## from the effect system. Called when an assertion failed.
+  raiseAssert(msg)
+
+template assertImpl(cond: bool, msg: string, expr: string, enabled: static[bool]) =
+  when enabled:
+    const
+      loc = instantiationInfo(fullPaths = compileOption("excessiveStackTrace"))
+      ploc = $loc
+    bind instantiationInfo
+    mixin failedAssertImpl
+    {.line: loc.}:
+      if not cond:
+        failedAssertImpl(ploc & " `" & expr & "` " & msg)
+
+template assert*(cond: untyped, msg = "") =
+  ## Raises `AssertionDefect` with `msg` if `cond` is false. Note
+  ## that `AssertionDefect` is hidden from the effect system, so it doesn't
+  ## produce `{.raises: [AssertionDefect].}`. This exception is only supposed
+  ## to be caught by unit testing frameworks.
+  ##
+  ## No code will be generated for `assert` when passing `-d:danger` (implied by `--assertions:off`).
+  ## See `command line switches <nimc.html#compiler-usage-commandminusline-switches>`_.
+  runnableExamples: assert 1 == 1
+  runnableExamples("--assertions:off"):
+    assert 1 == 2 # no code generated, no failure here
+  runnableExamples("-d:danger"): assert 1 == 2 # ditto
+  assertImpl(cond, msg, astToStr(cond), compileOption("assertions"))
+
+template doAssert*(cond: untyped, msg = "") =
+  ## Similar to `assert <#assert.t,untyped,string>`_ but is always turned on regardless of `--assertions`.
+  runnableExamples:
+    doAssert 1 == 1 # generates code even when built with `-d:danger` or `--assertions:off`
+  assertImpl(cond, msg, astToStr(cond), true)
+
+template onFailedAssert*(msg, code: untyped): untyped {.dirty.} =
+  ## Sets an assertion failure handler that will intercept any assert
+  ## statements following `onFailedAssert` in the current scope.
+  runnableExamples:
+    type MyError = object of CatchableError
+      lineinfo: tuple[filename: string, line: int, column: int]
+    # block-wide policy to change the failed assert exception type in order to
+    # include a lineinfo
+    onFailedAssert(msg):
+      raise (ref MyError)(msg: msg, lineinfo: instantiationInfo(-2))
+    doAssertRaises(MyError): doAssert false
+  when not defined(nimHasTemplateRedefinitionPragma):
+    {.pragma: redefine.}
+  template failedAssertImpl(msgIMPL: string): untyped {.dirty, redefine.} =
+    let msg = msgIMPL
+    code
+
+template doAssertRaises*(exception: typedesc, code: untyped) =
+  ## Raises `AssertionDefect` if specified `code` does not raise `exception`.
+  runnableExamples:
+    doAssertRaises(ValueError): raise newException(ValueError, "Hello World")
+    doAssertRaises(CatchableError): raise newException(ValueError, "Hello World")
+    doAssertRaises(AssertionDefect): doAssert false
+  var wrong = false
+  const begin = "expected raising '" & astToStr(exception) & "', instead"
+  const msgEnd = " by: " & astToStr(code)
+  template raisedForeign {.gensym.} = raiseAssert(begin & " raised foreign exception" & msgEnd)
+  {.push warning[BareExcept]:off.}
+  when Exception is exception:
+    try:
+      if true:
+        code
+      wrong = true
+    except Exception as e: discard
+    except: raisedForeign()
+  else:
+    try:
+      if true:
+        code
+      wrong = true
+    except exception:
+      discard
+    except Exception as e:
+      mixin `$` # alternatively, we could define $cstring in this module
+      raiseAssert(begin & " raised '" & $e.name & "'" & msgEnd)
+    except: raisedForeign()
+  {.pop.}
+  if wrong:
+    raiseAssert(begin & " nothing was raised" & msgEnd)
diff --git a/lib/std/cmdline.nim b/lib/std/cmdline.nim
new file mode 100644
index 000000000..0ba4619e5
--- /dev/null
+++ b/lib/std/cmdline.nim
@@ -0,0 +1,313 @@
+#

+#

+#            Nim's Runtime Library

+#        (c) Copyright 2022 Andreas Rumpf

+#

+#    See the file "copying.txt", included in this

+#    distribution, for details about the copyright.

+#

+

+## This module contains system facilities for reading command

+## line parameters.

+

+## **See also:**

+## * `parseopt module <parseopt.html>`_ for command-line parser beyond

+##   `parseCmdLine proc`_

+

+

+include system/inclrtl

+

+when defined(nimPreviewSlimSystem):

+  import std/widestrs

+  

+when defined(nodejs):

+  from std/private/oscommon import ReadDirEffect

+

+

+const weirdTarget = defined(nimscript) or defined(js)

+

+

+when weirdTarget:

+  discard

+elif defined(windows):

+  import std/winlean

+elif defined(posix):

+  import std/posix

+else:

+  {.error: "The cmdline module has not been implemented for the target platform.".}

+

+

+# Needed by windows in order to obtain the command line for targets

+# other than command line targets

+when defined(windows) and not weirdTarget:

+  template getCommandLine*(): untyped = getCommandLineW()

+

+

+proc parseCmdLine*(c: string): seq[string] {.

+  noSideEffect, rtl, extern: "nos$1".} =

+  ## Splits a `command line`:idx: into several components.

+  ##

+  ## **Note**: This proc is only occasionally useful, better use the

+  ## `parseopt module <parseopt.html>`_.

+  ##

+  ## On Windows, it uses the `following parsing rules

+  ## <http://msdn.microsoft.com/en-us/library/17w5ykft.aspx>`_:

+  ##

+  ## * Arguments are delimited by white space, which is either a space or a tab.

+  ## * The caret character (^) is not recognized as an escape character or

+  ##   delimiter. The character is handled completely by the command-line parser

+  ##   in the operating system before being passed to the argv array in the

+  ##   program.

+  ## * A string surrounded by double quotation marks ("string") is interpreted

+  ##   as a single argument, regardless of white space contained within. A

+  ##   quoted string can be embedded in an argument.

+  ## * A double quotation mark preceded by a backslash (\") is interpreted as a

+  ##   literal double quotation mark character (").

+  ## * Backslashes are interpreted literally, unless they immediately precede

+  ##   a double quotation mark.

+  ## * If an even number of backslashes is followed by a double quotation mark,

+  ##   one backslash is placed in the argv array for every pair of backslashes,

+  ##   and the double quotation mark is interpreted as a string delimiter.

+  ## * If an odd number of backslashes is followed by a double quotation mark,

+  ##   one backslash is placed in the argv array for every pair of backslashes,

+  ##   and the double quotation mark is "escaped" by the remaining backslash,

+  ##   causing a literal double quotation mark (") to be placed in argv.

+  ##

+  ## On Posix systems, it uses the following parsing rules:

+  ## Components are separated by whitespace unless the whitespace

+  ## occurs within ``"`` or ``'`` quotes.

+  ##

+  ## See also:

+  ## * `parseopt module <parseopt.html>`_

+  ## * `paramCount proc`_

+  ## * `paramStr proc`_

+  ## * `commandLineParams proc`_

+

+  result = @[]

+  var i = 0

+  var a = ""

+  while true:

+    setLen(a, 0)

+    # eat all delimiting whitespace

+    while i < c.len and c[i] in {' ', '\t', '\l', '\r'}: inc(i)

+    if i >= c.len: break

+    when defined(windows):

+      # parse a single argument according to the above rules:

+      var inQuote = false

+      while i < c.len:

+        case c[i]

+        of '\\':

+          var j = i

+          while j < c.len and c[j] == '\\': inc(j)

+          if j < c.len and c[j] == '"':

+            for k in 1..(j-i) div 2: a.add('\\')

+            if (j-i) mod 2 == 0:

+              i = j

+            else:

+              a.add('"')

+              i = j+1

+          else:

+            a.add(c[i])

+            inc(i)

+        of '"':

+          inc(i)

+          if not inQuote: inQuote = true

+          elif i < c.len and c[i] == '"':

+            a.add(c[i])

+            inc(i)

+          else:

+            inQuote = false

+            break

+        of ' ', '\t':

+          if not inQuote: break

+          a.add(c[i])

+          inc(i)

+        else:

+          a.add(c[i])

+          inc(i)

+    else:

+      case c[i]

+      of '\'', '\"':

+        var delim = c[i]

+        inc(i) # skip ' or "

+        while i < c.len and c[i] != delim:

+          add a, c[i]

+          inc(i)

+        if i < c.len: inc(i)

+      else:

+        while i < c.len and c[i] > ' ':

+          add(a, c[i])

+          inc(i)

+    add(result, move a)

+

+when defined(nimdoc):

+  # Common forward declaration docstring block for parameter retrieval procs.

+  proc paramCount*(): int {.tags: [ReadIOEffect].} =

+    ## Returns the number of `command line arguments`:idx: given to the

+    ## application.

+    ##

+    ## Unlike `argc`:idx: in C, if your binary was called without parameters this

+    ## will return zero.

+    ## You can query each individual parameter with `paramStr proc`_

+    ## or retrieve all of them in one go with `commandLineParams proc`_.

+    ##

+    ## **Availability**: When generating a dynamic library (see `--app:lib`) on

+    ## Posix this proc is not defined.

+    ## Test for availability using `declared() <system.html#declared,untyped>`_.

+    ##

+    ## See also:

+    ## * `parseopt module <parseopt.html>`_

+    ## * `parseCmdLine proc`_

+    ## * `paramStr proc`_

+    ## * `commandLineParams proc`_

+    ##

+    ## **Examples:**

+    ##

+    ##   ```nim

+    ##   when declared(paramCount):

+    ##     # Use paramCount() here

+    ##   else:

+    ##     # Do something else!

+    ##   ```

+

+  proc paramStr*(i: int): string {.tags: [ReadIOEffect].} =

+    ## Returns the `i`-th `command line argument`:idx: given to the application.

+    ##

+    ## `i` should be in the range `1..paramCount()`, the `IndexDefect`

+    ## exception will be raised for invalid values. Instead of iterating

+    ## over `paramCount()`_ with this proc you can

+    ## call the convenience `commandLineParams()`_.

+    ##

+    ## Similarly to `argv`:idx: in C,

+    ## 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() <os.html#getAppFilename>`_ instead.

+    ##

+    ## **Availability**: When generating a dynamic library (see `--app:lib`) on

+    ## Posix this proc is not defined.

+    ## Test for availability using `declared() <system.html#declared,untyped>`_.

+    ##

+    ## See also:

+    ## * `parseopt module <parseopt.html>`_

+    ## * `parseCmdLine proc`_

+    ## * `paramCount proc`_

+    ## * `commandLineParams proc`_

+    ## * `getAppFilename proc <os.html#getAppFilename>`_

+    ##

+    ## **Examples:**

+    ##

+    ##   ```nim

+    ##   when declared(paramStr):

+    ##     # Use paramStr() here

+    ##   else:

+    ##     # Do something else!

+    ##   ```

+

+elif defined(nimscript): discard

+elif defined(nodejs):

+  type Argv = object of JsRoot

+  let argv {.importjs: "process.argv".} : Argv

+  proc len(argv: Argv): int {.importjs: "#.length".}

+  proc `[]`(argv: Argv, i: int): cstring {.importjs: "#[#]".}

+

+  proc paramCount*(): int {.tags: [ReadDirEffect].} =

+    result = argv.len - 2

+

+  proc paramStr*(i: int): string {.tags: [ReadIOEffect].} =

+    let i = i + 1

+    if i < argv.len and i >= 0:

+      result = $argv[i]

+    else:

+      raise newException(IndexDefect, formatErrorIndexBound(i - 1, argv.len - 2))

+elif defined(windows):

+  # Since we support GUI applications with Nim, 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

+  # ourselves. This has the additional benefit that the program's behaviour

+  # is always the same -- independent of the used C compiler.

+  var

+    ownArgv {.threadvar.}: seq[string]

+    ownParsedArgv {.threadvar.}: bool

+

+  proc paramCount*(): int {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =

+    # Docstring in nimdoc block.

+    if not ownParsedArgv:

+      ownArgv = parseCmdLine($getCommandLine())

+      ownParsedArgv = true

+    result = ownArgv.len-1

+

+  proc paramStr*(i: int): string {.rtl, extern: "nos$1",

+    tags: [ReadIOEffect].} =

+    # Docstring in nimdoc block.

+    if not ownParsedArgv:

+      ownArgv = parseCmdLine($getCommandLine())

+      ownParsedArgv = true

+    if i < ownArgv.len and i >= 0:

+      result = ownArgv[i]

+    else:

+      raise newException(IndexDefect, formatErrorIndexBound(i, ownArgv.len-1))

+

+elif defined(genode):

+  proc paramStr*(i: int): string =

+    raise newException(OSError, "paramStr is not implemented on Genode")

+

+  proc paramCount*(): int =

+    raise newException(OSError, "paramCount is not implemented on Genode")

+elif weirdTarget or (defined(posix) and appType == "lib"):

+  proc paramStr*(i: int): string {.tags: [ReadIOEffect].} =

+    raise newException(OSError, "paramStr is not implemented on current platform")

+

+  proc paramCount*(): int {.tags: [ReadIOEffect].} =

+    raise newException(OSError, "paramCount is not implemented on current platform")

+elif not defined(createNimRtl) and

+  not(defined(posix) and appType == "lib"):

+  # On Posix, there is no portable way to get the command line from a DLL.

+  var

+    cmdCount {.importc: "cmdCount".}: cint

+    cmdLine {.importc: "cmdLine".}: cstringArray

+

+  proc paramStr*(i: int): string {.tags: [ReadIOEffect].} =

+    # Docstring in nimdoc block.

+    if i < cmdCount and i >= 0:

+      result = $cmdLine[i]

+    else:

+      raise newException(IndexDefect, formatErrorIndexBound(i, cmdCount-1))

+

+  proc paramCount*(): int {.tags: [ReadIOEffect].} =

+    # Docstring in nimdoc block.

+    result = cmdCount-1

+

+when declared(paramCount) or defined(nimdoc):

+  proc commandLineParams*(): seq[string] =

+    ## Convenience proc which returns the command line parameters.

+    ##

+    ## This returns **only** the parameters. If you want to get the application

+    ## executable filename, call `getAppFilename() <os.html#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 `declared()

+    ## <system.html#declared,untyped>`_.

+    ##

+    ## See also:

+    ## * `parseopt module <parseopt.html>`_

+    ## * `parseCmdLine proc`_

+    ## * `paramCount proc`_

+    ## * `paramStr proc`_

+    ## * `getAppFilename proc <os.html#getAppFilename>`_

+    ##

+    ## **Examples:**

+    ##

+    ##   ```nim

+    ##   when declared(commandLineParams):

+    ##     # Use commandLineParams() here

+    ##   else:

+    ##     # Do something else!

+    ##   ```

+    result = @[]

+    for i in 1..paramCount():

+      result.add(paramStr(i))

+else:

+  proc commandLineParams*(): seq[string] {.error:

+  "commandLineParams() unsupported by dynamic libraries".} =

+    discard

diff --git a/lib/std/compilesettings.nim b/lib/std/compilesettings.nim
new file mode 100644
index 000000000..6d8bd22f4
--- /dev/null
+++ b/lib/std/compilesettings.nim
@@ -0,0 +1,66 @@
+#
+#
+#              Nim's Runtime Library
+#        (c) Copyright 2020 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module allows querying the compiler about
+## diverse configuration settings. See also `compileOption`.
+
+# Note: Only add new enum values at the end to ensure binary compatibility with
+# other Nim compiler versions!
+
+type
+  SingleValueSetting* {.pure.} = enum ## \
+                      ## settings resulting in a single string value
+    arguments,        ## experimental: the arguments passed after '-r'
+    outFile,          ## experimental: the output file
+    outDir,           ## the output directory
+    nimcacheDir,      ## the location of the 'nimcache' directory
+    projectName,      ## the project's name that is being compiled
+    projectPath,      ## experimental: some path to the project that is being compiled
+    projectFull,      ## the full path to the project that is being compiled
+    command,          ## experimental: the command (e.g. 'c', 'cpp', 'doc') passed to
+                      ## the Nim compiler
+    commandLine,      ## experimental: the command line passed to Nim
+    linkOptions,      ## additional options passed to the linker
+    compileOptions,   ## additional options passed to the C/C++ compiler
+    ccompilerPath     ## the path to the C/C++ compiler
+    backend           ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
+                      ## and `nim js` would imply backend=js
+    libPath           ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
+    gc {.deprecated.} ## gc selected
+    mm                ## memory management selected
+
+  MultipleValueSetting* {.pure.} = enum ## \
+                      ## settings resulting in a seq of string values
+    nimblePaths,      ## the nimble path(s)
+    searchPaths,      ## the search path for modules
+    lazyPaths,        ## experimental: even more paths
+    commandArgs,      ## the arguments passed to the Nim compiler
+    cincludes,        ## the #include paths passed to the C/C++ compiler
+    clibs             ## libraries passed to the C/C++ compiler
+
+proc querySetting*(setting: SingleValueSetting): string {.
+  compileTime, noSideEffect.} =
+  ## Can be used to get a string compile-time option.
+  ##
+  ## See also:
+  ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
+  ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
+  ##
+  runnableExamples:
+    const nimcache = querySetting(SingleValueSetting.nimcacheDir)
+
+proc querySettingSeq*(setting: MultipleValueSetting): seq[string] {.
+  compileTime, noSideEffect.} =
+  ## Can be used to get a multi-string compile-time option.
+  ##
+  ## See also:
+  ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
+  ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
+  runnableExamples:
+    const nimblePaths = querySettingSeq(MultipleValueSetting.nimblePaths)
diff --git a/lib/std/decls.nim b/lib/std/decls.nim
new file mode 100644
index 000000000..bb7ec3593
--- /dev/null
+++ b/lib/std/decls.nim
@@ -0,0 +1,31 @@
+## This module implements syntax sugar for some declarations.
+
+import std/macros
+
+macro byaddr*(sect) =
+  ## Allows a syntax for l-value references, being an exact analog to
+  ## `auto& a = ex;` in C++.
+  ## 
+  ## .. warning:: This makes use of 2 experimental features, namely nullary
+  ##   templates instantiated as symbols and variable macro pragmas.
+  ##   For this reason, its behavior is not stable. The current implementation
+  ##   allows redefinition, but this is not an intended consequence.
+  runnableExamples:
+    var s = @[10, 11, 12]
+    var a {.byaddr.} = s[0]
+    a += 100
+    assert s == @[110, 11, 12]
+    assert a is int
+    var b {.byaddr.}: int = s[0]
+    assert a.addr == b.addr
+  expectLen sect, 1
+  let def = sect[0]
+  let
+    lhs = def[0]
+    typ = def[1]
+    ex = def[2]
+    addrTyp = if typ.kind == nnkEmpty: typ else: newTree(nnkPtrTy, typ)
+  result = quote do:
+    let tmp: `addrTyp` = addr(`ex`)
+    template `lhs`: untyped = tmp[]
+  result.copyLineInfo(def)
diff --git a/lib/std/dirs.nim b/lib/std/dirs.nim
new file mode 100644
index 000000000..380d6d08f
--- /dev/null
+++ b/lib/std/dirs.nim
@@ -0,0 +1,135 @@
+## This module implements directory handling.
+
+from std/paths import Path, ReadDirEffect, WriteDirEffect
+
+from std/private/osdirs import dirExists, createDir, existsOrCreateDir, removeDir,
+                               moveDir, walkDir, setCurrentDir,
+                               walkDirRec, PathComponent
+
+export PathComponent
+
+proc dirExists*(dir: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
+  ## Returns true if the directory `dir` exists. If `dir` is a file, false
+  ## is returned. Follows symlinks.
+  result = dirExists(dir.string)
+
+proc createDir*(dir: Path) {.inline, tags: [WriteDirEffect, ReadDirEffect].} =
+  ## Creates the `directory`:idx: `dir`.
+  ##
+  ## The directory may contain several subdirectories that do not exist yet.
+  ## The full path is created. If this fails, `OSError` is raised.
+  ##
+  ## It does **not** fail if the directory already exists because for
+  ## most usages this does not indicate an error.
+  ##
+  ## See also:
+  ## * `removeDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `moveDir proc`_
+  createDir(dir.string)
+
+proc existsOrCreateDir*(dir: Path): bool {.inline, tags: [WriteDirEffect, ReadDirEffect].} =
+  ## Checks if a `directory`:idx: `dir` exists, and creates it otherwise.
+  ##
+  ## Does not create parent directories (raises `OSError` if parent directories do not exist).
+  ## Returns `true` if the directory already exists, and `false` otherwise.
+  ##
+  ## See also:
+  ## * `removeDir proc`_
+  ## * `createDir proc`_
+  ## * `moveDir proc`_
+  result = existsOrCreateDir(dir.string)
+
+proc removeDir*(dir: Path, checkDir = false
+                ) {.inline, tags: [WriteDirEffect, ReadDirEffect].} =
+  ## Removes the directory `dir` including all subdirectories and files
+  ## in `dir` (recursively).
+  ##
+  ## If this fails, `OSError` is raised. This does not fail if the directory never
+  ## existed in the first place, unless `checkDir` = true.
+  ##
+  ## See also:
+  ## * `removeFile proc <files.html#removeFile>`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  ## * `moveDir proc`_
+  removeDir(dir.string, checkDir)
+
+proc moveDir*(source, dest: Path) {.inline, tags: [ReadIOEffect, WriteIOEffect].} =
+  ## Moves a directory from `source` to `dest`.
+  ##
+  ## Symlinks are not followed: if `source` contains symlinks, they themself are
+  ## moved, not their target.
+  ##
+  ## If this fails, `OSError` is raised.
+  ##
+  ## See also:
+  ## * `moveFile proc <files.html#moveFile>`_
+  ## * `removeDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  moveDir(source.string, dest.string)
+
+iterator walkDir*(dir: Path; relative = false, checkDir = false,
+                 skipSpecial = false):
+    tuple[kind: PathComponent, path: Path] {.tags: [ReadDirEffect].} =
+  ## Walks over the directory `dir` and yields for each directory or file in
+  ## `dir`. The component type and full path for each item are returned.
+  ##
+  ## Walking is not recursive.
+  ## * If `relative` is true (default: false)
+  ##   the resulting path is shortened to be relative to ``dir``,
+  ##   otherwise the full path is returned.
+  ## * If `checkDir` is true, `OSError` is raised when `dir`
+  ##   doesn't exist.
+  ## * If `skipSpecial` is true, then (besides all directories) only *regular*
+  ##   files (**without** special "file" objects like FIFOs, device files,
+  ##   etc) will be yielded on Unix.
+  for (k, p) in walkDir(dir.string, relative, checkDir, skipSpecial):
+    yield (k, Path(p))
+
+iterator walkDirRec*(dir: Path,
+                     yieldFilter = {pcFile}, followFilter = {pcDir},
+                     relative = false, checkDir = false, skipSpecial = false):
+                    Path {.tags: [ReadDirEffect].} =
+  ## Recursively walks over the directory `dir` and yields for each file
+  ## or directory in `dir`.
+  ##
+  ## Options `relative`, `checkdir`, `skipSpecial` are explained in
+  ## [walkDir iterator] description.
+  ##
+  ## .. warning:: Modifying the directory structure while the iterator
+  ##   is traversing may result in undefined behavior!
+  ##
+  ## Walking is recursive. `followFilter` controls the behaviour of the iterator:
+  ##
+  ## =====================   =============================================
+  ## yieldFilter             meaning
+  ## =====================   =============================================
+  ## ``pcFile``              yield real files (default)
+  ## ``pcLinkToFile``        yield symbolic links to files
+  ## ``pcDir``               yield real directories
+  ## ``pcLinkToDir``         yield symbolic links to directories
+  ## =====================   =============================================
+  ##
+  ## =====================   =============================================
+  ## followFilter            meaning
+  ## =====================   =============================================
+  ## ``pcDir``               follow real directories (default)
+  ## ``pcLinkToDir``         follow symbolic links to directories
+  ## =====================   =============================================
+  ##
+  ##
+  ## See also:
+  ## * `walkDir iterator`_
+  for p in walkDirRec(dir.string, yieldFilter, followFilter, relative,
+                      checkDir, skipSpecial):
+    yield Path(p)
+
+proc setCurrentDir*(newDir: Path) {.inline, tags: [].} =
+  ## Sets the `current working directory`:idx:; `OSError`
+  ## is raised if `newDir` cannot been set.
+  ##
+  ## See also:
+  ## * `getCurrentDir proc <paths.html#getCurrentDir>`_
+  osdirs.setCurrentDir(newDir.string)
diff --git a/lib/std/editdistance.nim b/lib/std/editdistance.nim
new file mode 100644
index 000000000..40c0017ae
--- /dev/null
+++ b/lib/std/editdistance.nim
@@ -0,0 +1,266 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements an algorithm to compute the
+## `edit distance`:idx: between two Unicode strings.
+
+import std/unicode
+
+proc editDistance*(a, b: string): int {.noSideEffect.} =
+  ## Returns the **unicode-rune** edit distance between `a` and `b`.
+  ##
+  ## This uses the `Levenshtein`:idx: distance algorithm with only a linear
+  ## memory overhead.
+  runnableExamples: static: doAssert editdistance("Kitten", "Bitten") == 1
+  if runeLen(a) > runeLen(b):
+    # make `b` the longer string
+    return editDistance(b, a)
+  # strip common prefix
+  var
+    iStart = 0 ## The character starting index of the first rune in both strings `a` and `b`
+    iNextA = 0
+    iNextB = 0
+    runeA, runeB: Rune
+    lenRunesA = 0 ## The number of relevant runes in string `a`.
+    lenRunesB = 0 ## The number of relevant runes in string `b`.
+  block commonPrefix:
+    # `a` is the shorter string
+    while iStart < len(a):
+      iNextA = iStart
+      a.fastRuneAt(iNextA, runeA, doInc = true)
+      iNextB = iStart
+      b.fastRuneAt(iNextB, runeB, doInc = true)
+      if runeA != runeB:
+        inc(lenRunesA)
+        inc(lenRunesB)
+        break
+      iStart = iNextA
+  var
+    # we know that we are either at the start of the strings
+    # or that the current value of runeA is not equal to runeB
+    # => start search for common suffix after the current rune (`i_next_*`)
+    iEndA = iNextA ## The exclusive upper index bound of string `a`.
+    iEndB = iNextB ## The exclusive upper index bound of string `b`.
+    iCurrentA = iNextA
+    iCurrentB = iNextB
+  block commonSuffix:
+    var
+      addRunesA = 0
+      addRunesB = 0
+    while iCurrentA < len(a) and iCurrentB < len(b):
+      iNextA = iCurrentA
+      a.fastRuneAt(iNextA, runeA)
+      iNextB = iCurrentB
+      b.fastRuneAt(iNextB, runeB)
+      inc(addRunesA)
+      inc(addRunesB)
+      if runeA != runeB:
+        iEndA = iNextA
+        iEndB = iNextB
+        inc(lenRunesA, addRunesA)
+        inc(lenRunesB, addRunesB)
+        addRunesA = 0
+        addRunesB = 0
+      iCurrentA = iNextA
+      iCurrentB = iNextB
+    if iCurrentA >= len(a): # `a` exhausted
+      if iCurrentB < len(b): # `b` not exhausted
+        iEndA = iCurrentA
+        iEndB = iCurrentB
+        inc(lenRunesA, addRunesA)
+        inc(lenRunesB, addRunesB)
+        while true:
+          b.fastRuneAt(iEndB, runeB)
+          inc(lenRunesB)
+          if iEndB >= len(b): break
+    elif iCurrentB >= len(b): # `b` exhausted and `a` not exhausted
+      iEndA = iCurrentA
+      iEndB = iCurrentB
+      inc(lenRunesA, addRunesA)
+      inc(lenRunesB, addRunesB)
+      while true:
+        a.fastRuneAt(iEndA, runeA)
+        inc(lenRunesA)
+        if iEndA >= len(a): break
+  block specialCases:
+    # trivial cases:
+    if lenRunesA == 0: return lenRunesB
+    if lenRunesB == 0: return lenRunesA
+    # another special case:
+    if lenRunesA == 1:
+      a.fastRuneAt(iStart, runeA, doInc = false)
+      var iCurrentB = iStart
+      while iCurrentB < iEndB:
+        b.fastRuneAt(iCurrentB, runeB, doInc = true)
+        if runeA == runeB: return lenRunesB - 1
+      return lenRunesB
+  # common case:
+  var
+    len1 = lenRunesA + 1
+    len2 = lenRunesB + 1
+    row: seq[int]
+  let half = lenRunesA div 2
+  newSeq(row, len2)
+  var e = iStart + len2 - 1 # end marker
+  # initialize first row:
+  for i in 1 .. (len2 - half - 1): row[i] = i
+  row[0] = len1 - half - 1
+  iCurrentA = iStart
+  var
+    char2pI = -1
+    char2pPrev: int
+  for i in 1 .. (len1 - 1):
+    iNextA = iCurrentA
+    a.fastRuneAt(iNextA, runeA)
+    var
+      char2p: int
+      diff, x: int
+      p: int
+    if i >= (len1 - half):
+      # skip the upper triangle:
+      let offset = i + half - len1
+      if char2pI == i:
+        b.fastRuneAt(char2pPrev, runeB)
+        char2p = char2pPrev
+        char2pI = i + 1
+      else:
+        char2p = iStart
+        for j in 0 ..< offset:
+          runeB = b.runeAt(char2p)
+          inc(char2p, runeB.size)
+        char2pI = i + 1
+        char2pPrev = char2p
+      p = offset
+      runeB = b.runeAt(char2p)
+      var c3 = row[p] + (if runeA != runeB: 1 else: 0)
+      inc(char2p, runeB.size)
+      inc(p)
+      x = row[p] + 1
+      diff = x
+      if x > c3: x = c3
+      row[p] = x
+      inc(p)
+    else:
+      p = 1
+      char2p = iStart
+      diff = i
+      x = i
+    if i <= (half + 1):
+      # skip the lower triangle:
+      e = len2 + i - half - 2
+    # main:
+    while p <= e:
+      dec(diff)
+      runeB = b.runeAt(char2p)
+      var c3 = diff + (if runeA != runeB: 1 else: 0)
+      inc(char2p, runeB.size)
+      inc(x)
+      if x > c3: x = c3
+      diff = row[p] + 1
+      if x > diff: x = diff
+      row[p] = x
+      inc(p)
+    # lower triangle sentinel:
+    if i <= half:
+      dec(diff)
+      runeB = b.runeAt(char2p)
+      var c3 = diff + (if runeA != runeB: 1 else: 0)
+      inc(x)
+      if x > c3: x = c3
+      row[p] = x
+    iCurrentA = iNextA
+  result = row[e]
+
+proc editDistanceAscii*(a, b: string): int {.noSideEffect.} =
+  ## Returns the edit distance between `a` and `b`.
+  ##
+  ## This uses the `Levenshtein`:idx: distance algorithm with only a linear
+  ## memory overhead.
+  runnableExamples: static: doAssert editDistanceAscii("Kitten", "Bitten") == 1
+  var len1 = a.len
+  var len2 = b.len
+  if len1 > len2:
+    # make `b` the longer string
+    return editDistanceAscii(b, a)
+
+  # strip common prefix:
+  var s = 0
+  while s < len1 and a[s] == b[s]:
+    inc(s)
+    dec(len1)
+    dec(len2)
+  # strip common suffix:
+  while len1 > 0 and len2 > 0 and a[s+len1-1] == b[s+len2-1]:
+    dec(len1)
+    dec(len2)
+  # trivial cases:
+  if len1 == 0: return len2
+  if len2 == 0: return len1
+
+  # another special case:
+  if len1 == 1:
+    for j in s..s+len2-1:
+      if a[s] == b[j]: return len2 - 1
+    return len2
+
+  inc(len1)
+  inc(len2)
+  var half = len1 shr 1
+  # initialize first row:
+  #var row = cast[ptr array[0..high(int) div 8, int]](alloc(len2*sizeof(int)))
+  var row: seq[int]
+  newSeq(row, len2)
+  var e = s + len2 - 1 # end marker
+  for i in 1..len2 - half - 1: row[i] = i
+  row[0] = len1 - half - 1
+  for i in 1 .. len1 - 1:
+    var char1 = a[i + s - 1]
+    var char2p: int
+    var diff, x: int
+    var p: int
+    if i >= len1 - half:
+      # skip the upper triangle:
+      var offset = i - len1 + half
+      char2p = offset
+      p = offset
+      var c3 = row[p] + ord(char1 != b[s + char2p])
+      inc(p)
+      inc(char2p)
+      x = row[p] + 1
+      diff = x
+      if x > c3: x = c3
+      row[p] = x
+      inc(p)
+    else:
+      p = 1
+      char2p = 0
+      diff = i
+      x = i
+    if i <= half + 1:
+      # skip the lower triangle:
+      e = len2 + i - half - 2
+    # main:
+    while p <= e:
+      dec(diff)
+      var c3 = diff + ord(char1 != b[char2p + s])
+      inc(char2p)
+      inc(x)
+      if x > c3: x = c3
+      diff = row[p] + 1
+      if x > diff: x = diff
+      row[p] = x
+      inc(p)
+    # lower triangle sentinel:
+    if i <= half:
+      dec(diff)
+      var c3 = diff + ord(char1 != b[char2p + s])
+      inc(x)
+      if x > c3: x = c3
+      row[p] = x
+  result = row[e]
diff --git a/lib/std/effecttraits.nim b/lib/std/effecttraits.nim
new file mode 100644
index 000000000..3d1b4ffd3
--- /dev/null
+++ b/lib/std/effecttraits.nim
@@ -0,0 +1,63 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module provides access to the inferred .raises effects
+## for Nim's macro system.
+## **Since**: Version 1.4.
+##
+## One can test for the existence of this standard module
+## via `defined(nimHasEffectTraitsModule)`.
+
+import std/macros
+
+proc getRaisesListImpl(n: NimNode): NimNode = discard "see compiler/vmops.nim"
+proc getTagsListImpl(n: NimNode): NimNode = discard "see compiler/vmops.nim"
+proc getForbidsListImpl(n: NimNode): NimNode = discard "see compiler/vmops.nim"
+proc isGcSafeImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
+proc hasNoSideEffectsImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
+
+proc getRaisesList*(fn: NimNode): NimNode =
+  ## Extracts the `.raises` list of the func/proc/etc `fn`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = getRaisesListImpl(fn)
+
+proc getTagsList*(fn: NimNode): NimNode =
+  ## Extracts the `.tags` list of the func/proc/etc `fn`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = getTagsListImpl(fn)
+
+proc getForbidsList*(fn: NimNode): NimNode =
+  ## Extracts the `.forbids` list of the func/proc/etc `fn`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = getForbidsListImpl(fn)
+
+proc isGcSafe*(fn: NimNode): bool =
+  ## Return true if the func/proc/etc `fn` is `gcsafe`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = isGcSafeImpl(fn)
+
+proc hasNoSideEffects*(fn: NimNode): bool =
+  ## Return true if the func/proc/etc `fn` has `noSideEffect`.
+  ## `fn` has to be a resolved symbol of kind `nnkSym`. This
+  ## implies that the macro that calls this proc should accept `typed`
+  ## arguments and not `untyped` arguments.
+  expectKind fn, nnkSym
+  result = hasNoSideEffectsImpl(fn)
diff --git a/lib/std/enumerate.nim b/lib/std/enumerate.nim
new file mode 100644
index 000000000..beb65ed30
--- /dev/null
+++ b/lib/std/enumerate.nim
@@ -0,0 +1,70 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements `enumerate` syntactic sugar based on Nim's
+## macro system.
+
+import std/private/since
+import std/macros
+
+
+macro enumerate*(x: ForLoopStmt): untyped {.since: (1, 3).} =
+  ## Enumerating iterator for collections.
+  ##
+  ## It yields `(count, value)` tuples (which must be immediately unpacked).
+  ## The default starting count `0` can be manually overridden if needed.
+  runnableExamples:
+    let a = [10, 20, 30]
+    var b: seq[(int, int)] = @[]
+    for i, x in enumerate(a):
+      b.add((i, x))
+    assert b == @[(0, 10), (1, 20), (2, 30)]
+
+    let c = "abcd"
+    var d: seq[(int, char)]
+    for (i, x) in enumerate(97, c):
+      d.add((i, x))
+    assert d == @[(97, 'a'), (98, 'b'), (99, 'c'), (100, 'd')]
+
+  template genCounter(x): untyped =
+    # We strip off the first for loop variable and use it as an integer counter.
+    # We must immediately decrement it by one, because it gets incremented before
+    # the loop body - to be able to use the final expression in other macros.
+    newVarStmt(x, infix(countStart, "-", newLit(1)))
+
+  template genInc(x): untyped =
+    newCall(bindSym"inc", x)
+
+  expectKind x, nnkForStmt
+  # check if the starting count is specified:
+  var countStart = if x[^2].len == 2: newLit(0) else: x[^2][1]
+  result = newStmtList()
+  var body = x[^1]
+  if body.kind != nnkStmtList:
+    body = newTree(nnkStmtList, body)
+  var newFor = newTree(nnkForStmt)
+  if x.len == 3: # single iteration variable
+    if x[0].kind == nnkVarTuple: # for (x, y, ...) in iter
+      result.add genCounter(x[0][0])
+      body.insert(0, genInc(x[0][0]))
+      for i in 1 .. x[0].len-2:
+        newFor.add x[0][i]
+    else:
+      error("Missing second for loop variable") # for x in iter
+  else: # for x, y, ... in iter
+    result.add genCounter(x[0])
+    body.insert(0, genInc(x[0]))
+    for i in 1 .. x.len-3:
+      newFor.add x[i]
+  # transform enumerate(X) to 'X'
+  newFor.add x[^2][^1]
+  newFor.add body
+  result.add newFor
+  # now wrap the whole macro in a block to create a new scope
+  result = newBlockStmt(result)
diff --git a/lib/std/enumutils.nim b/lib/std/enumutils.nim
new file mode 100644
index 000000000..9c338817d
--- /dev/null
+++ b/lib/std/enumutils.nim
@@ -0,0 +1,202 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+import std/macros
+from std/typetraits import OrdinalEnum, HoleyEnum
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+# xxx `genEnumCaseStmt` needs tests and runnableExamples
+
+macro genEnumCaseStmt*(typ: typedesc, argSym: typed, default: typed,
+            userMin, userMax: static[int], normalizer: static[proc(s :string): string]): untyped =
+  # Generates a case stmt, which assigns the correct enum field given
+  # a normalized string comparison to the `argSym` input.
+  # string normalization is done using passed normalizer.
+  let typ = typ.getTypeInst[1]
+  let typSym = typ.getTypeImpl.getTypeInst # skip aliases etc to get type sym
+  let impl = typSym.getImpl[2]
+  expectKind impl, nnkEnumTy
+  let normalizerNode = quote: `normalizer`
+  expectKind normalizerNode, nnkSym
+  result = nnkCaseStmt.newTree(newCall(normalizerNode, argSym))
+  # stores all processed field strings to give error msg for ambiguous enums
+  var foundFields: seq[string] = @[]
+  var fVal = ""
+  var fStr = "" # string of current field
+  var fNum = BiggestInt(0) # int value of current field
+  for f in impl:
+    case f.kind
+    of nnkEmpty: continue # skip first node of `enumTy`
+    of nnkSym, nnkIdent:
+      fVal = f.strVal
+      fStr = fVal
+    of nnkAccQuoted:
+      fVal = ""
+      for ch in f:
+        fVal.add ch.strVal
+      fStr = fVal
+    of nnkEnumFieldDef:
+      fVal = f[0].strVal
+      case f[1].kind
+      of nnkStrLit:
+        fStr = f[1].strVal
+      of nnkTupleConstr:
+        fStr = f[1][1].strVal
+        fNum = f[1][0].intVal
+      of nnkIntLit:
+        fStr = f[0].strVal
+        fNum = f[1].intVal
+      else:
+        let fAst = f[0].getImpl
+        if fAst.kind == nnkStrLit:
+          fStr = fAst.strVal
+        else:
+          error("Invalid tuple syntax!", f[1])
+    else: error("Invalid node for enum type `" & $f.kind & "`!", f)
+    # add field if string not already added
+    if fNum >= userMin and fNum <= userMax:
+      fStr = normalizer(fStr)
+      if fStr notin foundFields:
+        result.add nnkOfBranch.newTree(newLit fStr, newDotExpr(typ, ident fVal))
+        foundFields.add fStr
+      else:
+        error("Ambiguous enums cannot be parsed, field " & $fStr &
+          " appears multiple times!", f)
+    inc fNum
+  # finally add else branch to raise or use default
+  if default == nil:
+    let raiseStmt = quote do:
+      raise newException(ValueError, "Invalid enum value: " & $`argSym`)
+    result.add nnkElse.newTree(raiseStmt)
+  else:
+    expectKind(default, nnkSym)
+    result.add nnkElse.newTree(default)
+
+macro enumFullRange(a: typed): untyped =
+  newNimNode(nnkBracket).add(a.getType[1][1..^1])
+
+macro enumNames(a: typed): untyped =
+  # this could be exported too; in particular this could be useful for enum with holes.
+  result = newNimNode(nnkBracket)
+  for ai in a.getType[1][1..^1]:
+    assert ai.kind == nnkSym
+    result.add newLit ai.strVal
+
+iterator items*[T: HoleyEnum](E: typedesc[T]): T =
+  ## Iterates over an enum with holes.
+  runnableExamples:
+    type
+      A = enum
+        a0 = 2
+        a1 = 4
+        a2
+      B[T] = enum
+        b0 = 2
+        b1 = 4
+    from std/sequtils import toSeq
+    assert A.toSeq == [a0, a1, a2]
+    assert B[float].toSeq == [B[float].b0, B[float].b1]
+  for a in enumFullRange(E): yield a
+
+func span(T: typedesc[HoleyEnum]): int =
+  (T.high.ord - T.low.ord) + 1
+
+const invalidSlot = uint8.high
+
+proc genLookup[T: typedesc[HoleyEnum]](_: T): auto =
+  const n = span(T)
+  var i = 0
+  assert n <= invalidSlot.int
+  var ret {.noinit.}: array[n, uint8]
+  for ai in mitems(ret): ai = invalidSlot
+  for ai in items(T):
+    ret[ai.ord - T.low.ord] = uint8(i)
+    inc(i)
+  return ret
+
+func symbolRankImpl[T](a: T): int {.inline.} =
+  const n = T.span
+  const thres = 255 # must be <= `invalidSlot`, but this should be tuned.
+  when n <= thres:
+    const lookup = genLookup(T)
+    let lookup2 {.global.} = lookup # xxx improve pending https://github.com/timotheecour/Nim/issues/553
+    #[
+    This could be optimized using a hash adapted to `T` (possible since it's known at CT)
+    to get better key distribution before indexing into the lookup table table.
+    ]#
+    {.noSideEffect.}: # because it's immutable
+      let ret = lookup2[ord(a) - T.low.ord]
+    if ret != invalidSlot: return ret.int
+  else:
+    var i = 0
+    # we could also generate a case statement as optimization
+    for ai in items(T):
+      if ai == a: return i
+      inc(i)
+  raise newException(IndexDefect, $ord(a) & " invalid for " & $T)
+
+template symbolRank*[T: enum](a: T): int =
+  ## Returns the index in which `a` is listed in `T`.
+  ##
+  ## The cost for a `HoleyEnum` is implementation defined, currently optimized
+  ## for small enums, otherwise is `O(T.enumLen)`.
+  runnableExamples:
+    type
+      A = enum # HoleyEnum
+        a0 = -3
+        a1 = 10
+        a2
+        a3 = (20, "f3Alt")
+      B = enum # OrdinalEnum
+        b0
+        b1
+        b2
+      C = enum # OrdinalEnum
+        c0 = 10
+        c1
+        c2
+    assert a2.symbolRank == 2
+    assert b2.symbolRank == 2
+    assert c2.symbolRank == 2
+    assert c2.ord == 12
+    assert a2.ord == 11
+    var invalid = 7.A
+    doAssertRaises(IndexDefect): discard invalid.symbolRank
+  when T is Ordinal: ord(a) - T.low.ord.static
+  else: symbolRankImpl(a)
+
+proc rangeBase(T: typedesc): typedesc {.magic: "TypeTrait".}
+  # skip one level of range; return the base type of a range type
+
+func symbolName*[T: enum](a: T): string =
+  ## Returns the symbol name of an enum.
+  ##
+  ## This uses `symbolRank`.
+  runnableExamples:
+    type B = enum
+      b0 = (10, "kb0")
+      b1 = "kb1"
+      b2
+    let b = B.low
+    assert b.symbolName == "b0"
+    assert $b == "kb0"
+    static: assert B.high.symbolName == "b2"
+    type C = enum # HoleyEnum
+      c0 = -3
+      c1 = 4
+      c2 = 20
+    assert c1.symbolName == "c1"
+  when T is range:
+    const names = enumNames(rangeBase T)
+  else:
+    const names = enumNames(T)
+  names[a.symbolRank]
diff --git a/lib/std/envvars.nim b/lib/std/envvars.nim
new file mode 100644
index 000000000..a955077ea
--- /dev/null
+++ b/lib/std/envvars.nim
@@ -0,0 +1,221 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+## The `std/envvars` module implements environment variable handling.
+import std/oserrors
+
+type
+  ReadEnvEffect* = object of ReadIOEffect   ## Effect that denotes a read
+                                            ## from an environment variable.
+  WriteEnvEffect* = object of WriteIOEffect ## Effect that denotes a write
+                                            ## to an environment variable.
+
+
+when not defined(nimscript):
+  when defined(nodejs):
+    proc getEnv*(key: string, default = ""): string {.tags: [ReadEnvEffect].} =
+      var ret = default.cstring
+      let key2 = key.cstring
+      {.emit: "const value = process.env[`key2`];".}
+      {.emit: "if (value !== undefined) { `ret` = value };".}
+      result = $ret
+
+    proc existsEnv*(key: string): bool {.tags: [ReadEnvEffect].} =
+      var key2 = key.cstring
+      var ret: bool
+      {.emit: "`ret` = `key2` in process.env;".}
+      result = ret
+
+    proc putEnv*(key, val: string) {.tags: [WriteEnvEffect].} =
+      var key2 = key.cstring
+      var val2 = val.cstring
+      {.emit: "process.env[`key2`] = `val2`;".}
+
+    proc delEnv*(key: string) {.tags: [WriteEnvEffect].} =
+      var key2 = key.cstring
+      {.emit: "delete process.env[`key2`];".}
+
+    iterator envPairsImpl(): tuple[key, value: string] {.tags: [ReadEnvEffect].} =
+      var num: int
+      var keys: RootObj
+      {.emit: "`keys` = Object.keys(process.env); `num` = `keys`.length;".}
+      for i in 0..<num:
+        var key, value: cstring
+        {.emit: "`key` = `keys`[`i`]; `value` = process.env[`key`];".}
+        yield ($key, $value)
+
+  # commented because it must keep working with js+VM
+  # elif defined(js):
+  #   {.error: "requires -d:nodejs".}
+
+  else:
+
+    when defined(windows):
+      proc c_putenv(envstring: cstring): cint {.importc: "_putenv", header: "<stdlib.h>".}
+      from std/private/win_setenv import setEnvImpl
+      import std/winlean
+      when defined(nimPreviewSlimSystem):
+        import std/widestrs
+
+      type wchar_t {.importc: "wchar_t", header: "<stdlib.h>".} = int16
+      proc c_wgetenv(varname: ptr wchar_t): ptr wchar_t {.importc: "_wgetenv",
+          header: "<stdlib.h>".}
+      proc getEnvImpl(env: cstring): WideCString =
+        let r: WideCString = env.newWideCString
+        cast[WideCString](c_wgetenv(cast[ptr wchar_t](r)))
+    else:
+      proc c_getenv(env: cstring): cstring {.
+        importc: "getenv", header: "<stdlib.h>".}
+      proc c_setenv(envname: cstring, envval: cstring, overwrite: cint): cint {.importc: "setenv", header: "<stdlib.h>".}
+      proc c_unsetenv(env: cstring): cint {.importc: "unsetenv", header: "<stdlib.h>".}
+      proc getEnvImpl(env: cstring): cstring = c_getenv(env)
+
+    proc getEnv*(key: string, default = ""): string {.tags: [ReadEnvEffect].} =
+      ## Returns the value of the `environment variable`:idx: named `key`.
+      ##
+      ## If the variable does not exist, `""` is returned. To distinguish
+      ## whether a variable exists or it's value is just `""`, call
+      ## `existsEnv(key) proc`_.
+      ##
+      ## See also:
+      ## * `existsEnv proc`_
+      ## * `putEnv proc`_
+      ## * `delEnv proc`_
+      ## * `envPairs iterator`_
+      runnableExamples:
+        assert getEnv("unknownEnv") == ""
+        assert getEnv("unknownEnv", "doesn't exist") == "doesn't exist"
+
+      let env = getEnvImpl(key)
+      if env == nil:
+        result = default
+      else:
+        result = $env
+
+    proc existsEnv*(key: string): bool {.tags: [ReadEnvEffect].} =
+      ## Checks whether the environment variable named `key` exists.
+      ## Returns true if it exists, false otherwise.
+      ##
+      ## See also:
+      ## * `getEnv proc`_
+      ## * `putEnv proc`_
+      ## * `delEnv proc`_
+      ## * `envPairs iterator`_
+      runnableExamples:
+        assert not existsEnv("unknownEnv")
+
+      result = getEnvImpl(key) != nil
+
+    proc putEnv*(key, val: string) {.tags: [WriteEnvEffect].} =
+      ## Sets the value of the `environment variable`:idx: named `key` to `val`.
+      ## If an error occurs, `OSError` is raised.
+      ##
+      ## See also:
+      ## * `getEnv proc`_
+      ## * `existsEnv proc`_
+      ## * `delEnv proc`_
+      ## * `envPairs iterator`_
+      when defined(windows):
+        if key.len == 0 or '=' in key:
+          raise newException(OSError, "invalid key, got: " & $(key, val))
+        if setEnvImpl(key, val, 1'i32) != 0'i32:
+          raiseOSError(osLastError(), $(key, val))
+      else:
+        if c_setenv(key, val, 1'i32) != 0'i32:
+          raiseOSError(osLastError(), $(key, val))
+
+    proc delEnv*(key: string) {.tags: [WriteEnvEffect].} =
+      ## Deletes the `environment variable`:idx: named `key`.
+      ## If an error occurs, `OSError` is raised.
+      ##
+      ## See also:ven
+      ## * `getEnv proc`_
+      ## * `existsEnv proc`_
+      ## * `putEnv proc`_
+      ## * `envPairs iterator`_
+      template bail = raiseOSError(osLastError(), key)
+      when defined(windows):
+        #[
+        # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s?view=msvc-160
+        > You can remove a variable from the environment by specifying an empty string (that is, "") for value_string
+        note that nil is not legal
+        ]#
+        if key.len == 0 or '=' in key:
+          raise newException(OSError, "invalid key, got: " & key)
+        let envToDel = key & "="
+        if c_putenv(cstring envToDel) != 0'i32: bail
+      else:
+        if c_unsetenv(key) != 0'i32: bail
+
+    when defined(windows):
+      when defined(cpp):
+        proc strEnd(cstr: WideCString, c = 0'i32): WideCString {.importcpp: "(NI16*)wcschr((const wchar_t *)#, #)",
+            header: "<string.h>".}
+      else:
+        proc strEnd(cstr: WideCString, c = 0'i32): WideCString {.importc: "wcschr",
+            header: "<string.h>".}
+    elif defined(macosx) and not defined(ios) and not defined(emscripten):
+      # From the manual:
+      # Shared libraries and bundles don't have direct access to environ,
+      # which is only available to the loader ld(1) when a complete program
+      # is being linked.
+      # The environment routines can still be used, but if direct access to
+      # environ is needed, the _NSGetEnviron() routine, defined in
+      # <crt_externs.h>, can be used to retrieve the address of environ
+      # at runtime.
+      proc NSGetEnviron(): ptr cstringArray {.importc: "_NSGetEnviron",
+          header: "<crt_externs.h>".}
+    elif defined(haiku):
+      var gEnv {.importc: "environ", header: "<stdlib.h>".}: cstringArray
+    else:
+      var gEnv {.importc: "environ".}: cstringArray
+
+    iterator envPairsImpl(): tuple[key, value: string] {.tags: [ReadEnvEffect].} =
+      when defined(windows):
+        let env = getEnvironmentStringsW()
+        var e = env
+        if e != nil:
+          while true:
+            let eend = strEnd(e)
+            let kv = $e
+            let p = find(kv, '=')
+            yield (substr(kv, 0, p-1), substr(kv, p+1))
+            e = cast[WideCString](cast[ByteAddress](eend)+2)
+            if int(eend[1]) == 0: break
+          discard freeEnvironmentStringsW(env)
+      else:
+        var i = 0
+        when defined(macosx) and not defined(ios) and not defined(emscripten):
+          var gEnv = NSGetEnviron()[]
+        while gEnv[i] != nil:
+          let kv = $gEnv[i]
+          inc(i)
+          let p = find(kv, '=')
+          yield (substr(kv, 0, p-1), substr(kv, p+1))
+
+proc envPairsImplSeq(): seq[tuple[key, value: string]] = discard # vmops
+
+iterator envPairs*(): tuple[key, value: string] {.tags: [ReadEnvEffect].} =
+  ## Iterate over all `environments variables`:idx:.
+  ##
+  ## In the first component of the tuple is the name of the current variable stored,
+  ## in the second its value.
+  ##
+  ## Works in native backends, nodejs and vm, like the following APIs:
+  ## * `getEnv proc`_
+  ## * `existsEnv proc`_
+  ## * `putEnv proc`_
+  ## * `delEnv proc`_
+  when nimvm:
+    for ai in envPairsImplSeq(): yield ai
+  else:
+    when defined(nimscript): discard
+    else:
+      for ai in envPairsImpl(): yield ai
diff --git a/lib/std/exitprocs.nim b/lib/std/exitprocs.nim
new file mode 100644
index 000000000..f26368f42
--- /dev/null
+++ b/lib/std/exitprocs.nim
@@ -0,0 +1,87 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module allows adding hooks to program exit.
+
+import std/locks
+when defined(js) and not defined(nodejs):
+  import std/assertions
+
+type
+  FunKind = enum kClosure, kNoconv # extend as needed
+  Fun = object
+    case kind: FunKind
+    of kClosure: fun1: proc () {.closure.}
+    of kNoconv: fun2: proc () {.noconv.}
+
+var
+  gFunsLock: Lock
+  gFuns {.cursor.}: seq[Fun] #Intentionally use the cursor to break up the lifetime trace and make it compatible with JS.
+
+initLock(gFunsLock)
+
+when defined(js):
+  proc addAtExit(quitProc: proc() {.noconv.}) =
+    when defined(nodejs):
+      {.emit: """
+        process.on('exit', `quitProc`);
+      """.}
+    elif defined(js):
+      {.emit: """
+        window.onbeforeunload = `quitProc`;
+      """.}
+else:
+  proc addAtExit(quitProc: proc() {.noconv.}) {.
+    importc: "atexit", header: "<stdlib.h>".}
+
+proc callClosures() {.noconv.} =
+  withLock gFunsLock:
+    for i in countdown(gFuns.len-1, 0):
+      let fun = gFuns[i]
+      case fun.kind
+      of kClosure: fun.fun1()
+      of kNoconv: fun.fun2()
+    gFuns.setLen(0)
+
+template fun() =
+  if gFuns.len == 0:
+    addAtExit(callClosures)
+
+proc addExitProc*(cl: proc () {.closure.}) =
+  ## Adds/registers a quit procedure. Each call to `addExitProc` registers
+  ## another quit procedure. They are executed on a last-in, first-out basis.
+  # Support for `addExitProc` is done by Ansi C's facilities here.
+  # In case of an unhandled exception the exit handlers should
+  # not be called explicitly! The user may decide to do this manually though.
+  withLock gFunsLock:
+    fun()
+    gFuns.add Fun(kind: kClosure, fun1: cl)
+
+proc addExitProc*(cl: proc() {.noconv.}) =
+  ## overload for `noconv` procs.
+  withLock gFunsLock:
+    fun()
+    gFuns.add Fun(kind: kNoconv, fun2: cl)
+
+when not defined(nimscript) and (not defined(js) or defined(nodejs)):
+  proc getProgramResult*(): int =
+    when defined(js) and defined(nodejs):
+      {.emit: """
+`result` = process.exitCode;
+""".}
+    else:
+      result = programResult
+
+  proc setProgramResult*(a: int) =
+    when defined(js) and defined(nodejs):
+      {.emit: """
+process.exitCode = `a`;
+""".}
+    else:
+      programResult = a
diff --git a/lib/std/files.nim b/lib/std/files.nim
new file mode 100644
index 000000000..c4e0491c9
--- /dev/null
+++ b/lib/std/files.nim
@@ -0,0 +1,46 @@
+## This module implements file handling.
+##
+## **See also:**
+## * `paths module <paths.html>`_ for path manipulation
+
+from std/paths import Path, ReadDirEffect, WriteDirEffect
+
+from std/private/osfiles import fileExists, removeFile,
+                                moveFile
+
+
+proc fileExists*(filename: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
+  ## Returns true if `filename` exists and is a regular file or symlink.
+  ##
+  ## Directories, device files, named pipes and sockets return false.
+  result = fileExists(filename.string)
+
+proc removeFile*(file: Path) {.inline, tags: [WriteDirEffect].} =
+  ## Removes the `file`.
+  ##
+  ## If this fails, `OSError` is raised. This does not fail
+  ## if the file never existed in the first place.
+  ##
+  ## On Windows, ignores the read-only attribute.
+  ##
+  ## See also:
+  ## * `removeDir proc <dirs.html#removeDir>`_
+  ## * `moveFile proc`_
+  removeFile(file.string)
+
+proc moveFile*(source, dest: Path) {.inline,
+    tags: [ReadDirEffect, ReadIOEffect, WriteIOEffect].} =
+  ## Moves a file from `source` to `dest`.
+  ##
+  ## Symlinks are not followed: if `source` is a symlink, it is itself moved,
+  ## not its target.
+  ##
+  ## If this fails, `OSError` is raised.
+  ## If `dest` already exists, it will be overwritten.
+  ##
+  ## Can be used to `rename files`:idx:.
+  ##
+  ## See also:
+  ## * `moveDir proc <dirs.html#moveDir>`_
+  ## * `removeFile proc`_
+  moveFile(source.string, dest.string)
diff --git a/lib/std/formatfloat.nim b/lib/std/formatfloat.nim
new file mode 100644
index 000000000..9258245f6
--- /dev/null
+++ b/lib/std/formatfloat.nim
@@ -0,0 +1,143 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements formatting floats as strings.
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+proc c_memcpy(a, b: pointer, size: csize_t): pointer {.importc: "memcpy", header: "<string.h>", discardable.}
+
+proc addCstringN(result: var string, buf: cstring; buflen: int) =
+  # no nimvm support needed, so it doesn't need to be fast here either
+  let oldLen = result.len
+  let newLen = oldLen + buflen
+  result.setLen newLen
+  c_memcpy(result[oldLen].addr, buf, buflen.csize_t)
+
+import std/private/[dragonbox, schubfach]
+
+proc writeFloatToBufferRoundtrip*(buf: var array[65, char]; value: BiggestFloat): int =
+  ## This is the implementation to format floats.
+  ##
+  ## returns the amount of bytes written to `buf` not counting the
+  ## terminating '\0' character.
+  result = toChars(buf, value, forceTrailingDotZero=true).int
+  buf[result] = '\0'
+
+proc writeFloatToBufferRoundtrip*(buf: var array[65, char]; value: float32): int =
+  result = float32ToChars(buf, value, forceTrailingDotZero=true).int
+  buf[result] = '\0'
+
+proc c_snprintf(buf: cstring, n: csize_t, frmt: cstring): cint {.header: "<stdio.h>",
+                                    importc: "snprintf", varargs, noSideEffect.}
+
+proc writeToBuffer(buf: var array[65, char]; value: cstring) =
+  var i = 0
+  while value[i] != '\0':
+    buf[i] = value[i]
+    inc i
+
+proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat): int =
+  ## This is the implementation to format floats.
+  ##
+  ## returns the amount of bytes written to `buf` not counting the
+  ## terminating '\0' character.
+  var n = c_snprintf(cast[cstring](addr buf), 65, "%.16g", value).int
+  var hasDot = false
+  for i in 0..n-1:
+    if buf[i] == ',':
+      buf[i] = '.'
+      hasDot = true
+    elif buf[i] in {'a'..'z', 'A'..'Z', '.'}:
+      hasDot = true
+  if not hasDot:
+    buf[n] = '.'
+    buf[n+1] = '0'
+    buf[n+2] = '\0'
+    result = n + 2
+  else:
+    result = n
+  # On Windows nice numbers like '1.#INF', '-1.#INF' or '1.#NAN' or 'nan(ind)'
+  # of '-1.#IND' are produced.
+  # We want to get rid of these here:
+  if buf[n-1] in {'n', 'N', 'D', 'd', ')'}:
+    writeToBuffer(buf, "nan")
+    result = 3
+  elif buf[n-1] == 'F':
+    if buf[0] == '-':
+      writeToBuffer(buf, "-inf")
+      result = 4
+    else:
+      writeToBuffer(buf, "inf")
+      result = 3
+
+proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat | float32): int {.inline.} =
+  when defined(nimPreviewFloatRoundtrip) or defined(nimPreviewSlimSystem):
+    writeFloatToBufferRoundtrip(buf, value)
+  else:
+    writeFloatToBufferSprintf(buf, value)
+
+proc addFloatRoundtrip*(result: var string; x: float | float32) =
+  when nimvm:
+    raiseAssert "unreachable"
+  else:
+    var buffer {.noinit.}: array[65, char]
+    let n = writeFloatToBufferRoundtrip(buffer, x)
+    result.addCstringN(cast[cstring](buffer[0].addr), n)
+
+proc addFloatSprintf*(result: var string; x: float) =
+  when nimvm:
+    raiseAssert "unreachable"
+  else:
+    var buffer {.noinit.}: array[65, char]
+    let n = writeFloatToBufferSprintf(buffer, x)
+    result.addCstringN(cast[cstring](buffer[0].addr), n)
+
+when defined(js):
+  proc nimFloatToString(a: float): cstring =
+    ## ensures the result doesn't print like an integer, i.e. return 2.0, not 2
+    # print `-0.0` properly
+    {.emit: """
+      function nimOnlyDigitsOrMinus(n) {
+        return n.toString().match(/^-?\d+$/);
+      }
+      if (Number.isSafeInteger(`a`))
+        `result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0";
+      else {
+        `result` = `a`+"";
+        if(nimOnlyDigitsOrMinus(`result`)){
+          `result` = `a`+".0";
+        }
+      }
+    """.}
+
+proc addFloat*(result: var string; x: float | float32) {.inline.} =
+  ## Converts float to its string representation and appends it to `result`.
+  runnableExamples:
+    var
+      s = "foo:"
+      b = 45.67
+    s.addFloat(45.67)
+    assert s == "foo:45.67"
+  template impl =
+    when defined(nimPreviewFloatRoundtrip) or defined(nimPreviewSlimSystem):
+      addFloatRoundtrip(result, x)
+    else:
+      addFloatSprintf(result, x)
+  when defined(js):
+    when nimvm: impl()
+    else:
+      result.add nimFloatToString(x)
+  else: impl()
+
+when defined(nimPreviewSlimSystem):
+  func `$`*(x: float | float32): string =
+    ## Outplace version of `addFloat`.
+    result.addFloat(x)
diff --git a/lib/std/genasts.nim b/lib/std/genasts.nim
new file mode 100644
index 000000000..d0f07c527
--- /dev/null
+++ b/lib/std/genasts.nim
@@ -0,0 +1,89 @@
+## This module implements AST generation using captured variables for macros.
+
+import std/macros
+
+type GenAstOpt* = enum
+  kDirtyTemplate,
+    # When set, uses a dirty template in implementation of `genAst`. This
+    # is occasionally useful as workaround for issues such as #8220, see
+    # `strformat limitations <strformat.html#limitations>`_ for details.
+    # Default is unset, to avoid hijacking of uncaptured local symbols by
+    # symbols in caller scope.
+  kNoNewLit,
+    # don't call call newLit automatically in `genAst` capture parameters
+
+macro genAstOpt*(options: static set[GenAstOpt], args: varargs[untyped]): untyped =
+  ## Accepts a list of captured variables `a=b` or `a` and a block and returns the
+  ## AST that represents it. Local `{.inject.}` symbols (e.g. procs) are captured
+  ## unless `kDirtyTemplate in options`.
+  runnableExamples:
+    # This example shows how one could write a simplified version of `unittest.check`.
+    import std/[macros, strutils]
+    macro check2(cond: bool): untyped =
+      assert cond.kind == nnkInfix, "$# not implemented" % $cond.kind
+      result = genAst(cond, s = repr(cond), lhs = cond[1], rhs = cond[2]):
+        # each local symbol we access must be explicitly captured
+        if not cond:
+          raiseAssert "'$#'' failed: lhs: '$#', rhs: '$#'" % [s, $lhs, $rhs]
+    let a = 3
+    check2 a*2 == a+3
+    if false: check2 a*2 < a+1 # would error with: 'a * 2 < a + 1'' failed: lhs: '6', rhs: '4'
+
+  runnableExamples:
+    # This example goes in more details about the capture semantics.
+    macro fun(a: string, b: static bool): untyped =
+      let c = 'z'
+      var d = 11 # implicitly {.gensym.} and needs to be captured for use in `genAst`.
+      proc localFun(): auto = 12 # implicitly {.inject.}, doesn't need to be captured.
+      genAst(a, b, c = true):
+        # `a`, `b` are captured explicitly, `c` is a local definition masking `c = 'z'`.
+        const b2 = b # macro static param `b` is forwarded here as a static param.
+        # `echo d` would give: `var not init` because `d` is not captured.
+        (a & a, b, c, localFun()) # localFun can be called without capture.
+    assert fun("ab", false) == ("abab", false, true, 12)
+
+  let params = newTree(nnkFormalParams, newEmptyNode())
+  let pragmas =
+    if kDirtyTemplate in options:
+      nnkPragma.newTree(ident"dirty")
+    else:
+      newEmptyNode()
+
+  template newLitMaybe(a): untyped =
+    when (a is type) or (typeof(a) is (proc | iterator | func | NimNode)):
+      a # `proc` actually also covers template, macro
+    else: newLit(a)
+
+  # using `_` as workaround, see https://github.com/nim-lang/Nim/issues/2465#issuecomment-511076669
+  let name = genSym(nskTemplate, "_fun")
+  let call = newCall(name)
+  for a in args[0..^2]:
+    var varName: NimNode
+    var varVal: NimNode
+    case a.kind
+    of nnkExprEqExpr:
+      varName = a[0]
+      varVal = a[1]
+    of nnkIdent:
+      varName = a
+      varVal = a
+    else: error("invalid argument kind: " & $a.kind, a)
+    if kNoNewLit notin options: varVal = newCall(bindSym"newLitMaybe", varVal)
+
+    params.add newTree(nnkIdentDefs, varName, newEmptyNode(), newEmptyNode())
+    call.add varVal
+
+  result = newStmtList()
+  result.add nnkTemplateDef.newTree(
+      name,
+      newEmptyNode(),
+      newEmptyNode(),
+      params,
+      pragmas,
+      newEmptyNode(),
+      args[^1])
+  result.add newCall(bindSym"getAst", call)
+
+template genAst*(args: varargs[untyped]): untyped =
+  ## Convenience wrapper around `genAstOpt`.
+  genAstOpt({}, args)
diff --git a/lib/std/importutils.nim b/lib/std/importutils.nim
new file mode 100644
index 000000000..d2da76ea8
--- /dev/null
+++ b/lib/std/importutils.nim
@@ -0,0 +1,44 @@
+##[
+Utilities related to import and symbol resolution.
+
+Experimental API, subject to change.
+]##
+
+#[
+Possible future APIs:
+* module symbols (https://github.com/nim-lang/Nim/pull/9560)
+* whichModule (subsumes canImport / moduleExists) (https://github.com/timotheecour/Nim/issues/376)
+* getCurrentPkgDir (https://github.com/nim-lang/Nim/pull/10530)
+* import from a computed string + related APIs (https://github.com/nim-lang/Nim/pull/10527)
+]#
+
+when defined(nimImportutilsExample):
+  type
+    Foo = object
+      f0: int # private
+    Goo*[T] = object
+      g0: int # private
+  proc initFoo*(): auto = Foo()
+
+proc privateAccess*(t: typedesc) {.magic: "PrivateAccess".} =
+  ## Enables access to private fields of `t` in current scope.
+  runnableExamples("-d:nimImportutilsExample"):
+    # here we're importing a module containing:
+    # type
+    #   Foo = object
+    #     f0: int # private
+    #   Goo*[T] = object
+    #     g0: int # private
+    # proc initFoo*(): auto = Foo()
+    var f = initFoo()
+    block:
+      assert not compiles(f.f0)
+      privateAccess(f.type)
+      f.f0 = 1 # accessible in this scope
+      block:
+        assert f.f0 == 1 # still in scope
+    assert not compiles(f.f0)
+
+    # this also works with generics
+    privateAccess(Goo)
+    assert Goo[float](g0: 1).g0 == 1
diff --git a/lib/std/isolation.nim b/lib/std/isolation.nim
new file mode 100644
index 000000000..b03e00651
--- /dev/null
+++ b/lib/std/isolation.nim
@@ -0,0 +1,49 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements the `Isolated[T]` type for
+## safe construction of isolated subgraphs that can be
+## passed efficiently to different channels and threads.
+##
+## .. warning:: This module is experimental and its interface may change.
+##
+
+type
+  Isolated*[T] {.sendable.} = object ## Isolated data can only be moved, not copied.
+    value: T
+
+proc `=copy`*[T](dest: var Isolated[T]; src: Isolated[T]) {.error.}
+
+proc `=sink`*[T](dest: var Isolated[T]; src: Isolated[T]) {.inline.} =
+  # delegate to value's sink operation
+  `=sink`(dest.value, src.value)
+
+proc `=destroy`*[T](dest: var Isolated[T]) {.inline.} =
+  # delegate to value's destroy operation
+  `=destroy`(dest.value)
+
+func isolate*[T](value: sink T): Isolated[T] {.magic: "Isolate".} =
+  ## Creates an isolated subgraph from the expression `value`.
+  ## Isolation is checked at compile time.
+  ##
+  ## Please read https://github.com/nim-lang/RFCs/issues/244
+  ## for more details.
+  Isolated[T](value: value)
+
+func unsafeIsolate*[T](value: sink T): Isolated[T] =
+  ## Creates an isolated subgraph from the expression `value`.
+  ##
+  ## .. warning:: The proc doesn't check whether `value` is isolated.
+  ##
+  Isolated[T](value: value)
+
+func extract*[T](src: var Isolated[T]): T =
+  ## Returns the internal value of `src`.
+  ## The value is moved from `src`.
+  result = move(src.value)
diff --git a/lib/std/jsbigints.nim b/lib/std/jsbigints.nim
new file mode 100644
index 000000000..4e996ea7b
--- /dev/null
+++ b/lib/std/jsbigints.nim
@@ -0,0 +1,228 @@
+## Arbitrary precision integers.
+## * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
+when not defined(js):
+  {.fatal: "Module jsbigints is designed to be used with the JavaScript backend.".}
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type JsBigIntImpl {.importjs: "bigint".} = int # https://github.com/nim-lang/Nim/pull/16606
+type JsBigInt* = distinct JsBigIntImpl         ## Arbitrary precision integer for JavaScript target.
+
+func big*(integer: SomeInteger): JsBigInt {.importjs: "BigInt(#)".} =
+  ## Constructor for `JsBigInt`.
+  runnableExamples:
+    doAssert big(1234567890) == big"1234567890"
+    doAssert 0b1111100111.big == 0o1747.big and 0o1747.big == 999.big
+  when nimvm: raiseAssert "JsBigInt can not be used at compile-time nor static context" else: discard
+
+func `'big`*(num: cstring): JsBigInt {.importjs: "BigInt(#)".} =
+  ## Constructor for `JsBigInt`.
+  runnableExamples:
+    doAssert -1'big == 1'big - 2'big
+    # supports decimal, binary, octal, hex:
+    doAssert -12'big == big"-12"
+    doAssert 12'big == 12.big
+    doAssert 0b101'big == 0b101.big
+    doAssert 0o701'big == 0o701.big
+    doAssert 0xdeadbeaf'big == 0xdeadbeaf.big
+    doAssert 0xffffffffffffffff'big == (1'big shl 64'big) - 1'big
+    doAssert not compiles(static(12'big))
+  when nimvm: raiseAssert "JsBigInt can not be used at compile-time nor static context" else: discard
+
+func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
+  ## Alias for `'big`
+  when nimvm: raiseAssert "JsBigInt can not be used at compile-time nor static context" else: discard
+
+func toCstring*(this: JsBigInt; radix: 2..36): cstring {.importjs: "#.toString(#)".} =
+  ## Converts from `JsBigInt` to `cstring` representation.
+  ## * `radix` Base to use for representing numeric values.
+  ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString
+  runnableExamples:
+    doAssert big"2147483647".toCstring(2) == "1111111111111111111111111111111".cstring
+
+func toCstring*(this: JsBigInt): cstring {.importjs: "#.toString()".}
+  ## Converts from `JsBigInt` to `cstring` representation.
+  ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString
+
+func `$`*(this: JsBigInt): string =
+  ## Returns a `string` representation of `JsBigInt`.
+  runnableExamples: doAssert $big"1024" == "1024n"
+  $toCstring(this) & 'n'
+
+func wrapToInt*(this: JsBigInt; bits: Natural): JsBigInt {.importjs:
+  "(() => { const i = #, b = #; return BigInt.asIntN(b, i) })()".} =
+  ## Wraps `this` to a signed `JsBigInt` of `bits` bits in `-2 ^ (bits - 1)` .. `2 ^ (bits - 1) - 1`.
+  ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asIntN
+  runnableExamples:
+    doAssert (big("3") + big("2") ** big("66")).wrapToInt(13) == big("3")
+
+func wrapToUint*(this: JsBigInt; bits: Natural): JsBigInt {.importjs:
+  "(() => { const i = #, b = #; return BigInt.asUintN(b, i) })()".} =
+  ## Wraps `this` to an unsigned `JsBigInt` of `bits` bits in 0 ..  `2 ^ bits - 1`.
+  ## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
+  runnableExamples:
+    doAssert (big("3") + big("2") ** big("66")).wrapToUint(66) == big("3")
+
+func toNumber*(this: JsBigInt): int {.importjs: "Number(#)".} =
+  ## Does not do any bounds check and may or may not return an inexact representation.
+  runnableExamples:
+    doAssert toNumber(big"2147483647") == 2147483647.int
+
+func `+`*(x, y: JsBigInt): JsBigInt {.importjs: "(# $1 #)".} =
+  runnableExamples:
+    doAssert (big"9" + big"1") == big"10"
+
+func `-`*(x, y: JsBigInt): JsBigInt {.importjs: "(# $1 #)".} =
+  runnableExamples:
+    doAssert (big"9" - big"1") == big"8"
+
+func `*`*(x, y: JsBigInt): JsBigInt {.importjs: "(# $1 #)".} =
+  runnableExamples:
+    doAssert (big"42" * big"9") == big"378"
+
+func `div`*(x, y: JsBigInt): JsBigInt {.importjs: "(# / #)".} =
+  ## Same as `div` but for `JsBigInt`(uses JavaScript `BigInt() / BigInt()`).
+  runnableExamples:
+    doAssert big"13" div big"3" == big"4"
+    doAssert big"-13" div big"3" == big"-4"
+    doAssert big"13" div big"-3" == big"-4"
+    doAssert big"-13" div big"-3" == big"4"
+
+func `mod`*(x, y: JsBigInt): JsBigInt {.importjs: "(# % #)".} =
+  ## Same as `mod` but for `JsBigInt` (uses JavaScript `BigInt() % BigInt()`).
+  runnableExamples:
+    doAssert big"13" mod big"3" == big"1"
+    doAssert big"-13" mod big"3" == big"-1"
+    doAssert big"13" mod big"-3" == big"1"
+    doAssert big"-13" mod big"-3" == big"-1"
+
+func `<`*(x, y: JsBigInt): bool {.importjs: "(# $1 #)".} =
+  runnableExamples:
+    doAssert big"2" < big"9"
+
+func `<=`*(x, y: JsBigInt): bool {.importjs: "(# $1 #)".} =
+  runnableExamples:
+    doAssert big"1" <= big"5"
+
+func `==`*(x, y: JsBigInt): bool {.importjs: "(# == #)".} =
+  runnableExamples:
+    doAssert big"42" == big"42"
+
+func `**`*(x, y: JsBigInt): JsBigInt {.importjs: "((#) $1 #)".} =
+  # (#) needed due to unary minus
+  runnableExamples:
+    doAssert big"2" ** big"64" == big"18446744073709551616"
+    doAssert big"-2" ** big"3" == big"-8"
+    doAssert -big"2" ** big"2" == big"4" # parsed as: (-2n) ** 2n
+    doAssert big"0" ** big"0" == big"1" # edge case
+    var ok = false
+    try: discard big"2" ** big"-1" # raises foreign `RangeError`
+    except: ok = true
+    doAssert ok
+
+func `and`*(x, y: JsBigInt): JsBigInt {.importjs: "(# & #)".} =
+  runnableExamples:
+    doAssert (big"555" and big"2") == big"2"
+
+func `or`*(x, y: JsBigInt): JsBigInt {.importjs: "(# | #)".} =
+  runnableExamples:
+    doAssert (big"555" or big"2") == big"555"
+
+func `xor`*(x, y: JsBigInt): JsBigInt {.importjs: "(# ^ #)".} =
+  runnableExamples:
+    doAssert (big"555" xor big"2") == big"553"
+
+func `shl`*(a, b: JsBigInt): JsBigInt {.importjs: "(# << #)".} =
+  runnableExamples:
+    doAssert (big"999" shl big"2") == big"3996"
+
+func `shr`*(a, b: JsBigInt): JsBigInt {.importjs: "(# >> #)".} =
+  runnableExamples:
+    doAssert (big"999" shr big"2") == big"249"
+
+func `-`*(this: JsBigInt): JsBigInt {.importjs: "($1#)".} =
+  runnableExamples:
+    doAssert -(big"10101010101") == big"-10101010101"
+
+func inc*(this: var JsBigInt) {.importjs: "(++[#][0][0])".} =
+  runnableExamples:
+    var big1: JsBigInt = big"1"
+    inc big1
+    doAssert big1 == big"2"
+
+func dec*(this: var JsBigInt) {.importjs: "(--[#][0][0])".} =
+  runnableExamples:
+    var big1: JsBigInt = big"2"
+    dec big1
+    doAssert big1 == big"1"
+
+func inc*(this: var JsBigInt; amount: JsBigInt) {.importjs: "([#][0][0] += #)".} =
+  runnableExamples:
+    var big1: JsBigInt = big"1"
+    inc big1, big"2"
+    doAssert big1 == big"3"
+
+func dec*(this: var JsBigInt; amount: JsBigInt) {.importjs: "([#][0][0] -= #)".} =
+  runnableExamples:
+    var big1: JsBigInt = big"1"
+    dec big1, big"2"
+    doAssert big1 == big"-1"
+
+func `+=`*(x: var JsBigInt; y: JsBigInt) {.importjs: "([#][0][0] $1 #)".} =
+  runnableExamples:
+    var big1: JsBigInt = big"1"
+    big1 += big"2"
+    doAssert big1 == big"3"
+
+func `-=`*(x: var JsBigInt; y: JsBigInt) {.importjs: "([#][0][0] $1 #)".} =
+  runnableExamples:
+    var big1: JsBigInt = big"1"
+    big1 -= big"2"
+    doAssert big1 == big"-1"
+
+func `*=`*(x: var JsBigInt; y: JsBigInt) {.importjs: "([#][0][0] $1 #)".} =
+  runnableExamples:
+    var big1: JsBigInt = big"2"
+    big1 *= big"4"
+    doAssert big1 == big"8"
+
+func `/=`*(x: var JsBigInt; y: JsBigInt) {.importjs: "([#][0][0] $1 #)".} =
+  ## Same as `x = x div y`.
+  runnableExamples:
+    var big1: JsBigInt = big"11"
+    big1 /= big"2"
+    doAssert big1 == big"5"
+
+proc `+`*(_: JsBigInt): JsBigInt {.error:
+  "See https://github.com/tc39/proposal-bigint/blob/master/ADVANCED.md#dont-break-asmjs".} # Can not be used by design
+  ## **Do NOT use.** https://github.com/tc39/proposal-bigint/blob/master/ADVANCED.md#dont-break-asmjs
+
+proc low*(_: typedesc[JsBigInt]): JsBigInt {.error:
+  "Arbitrary precision integers do not have a known low.".} ## **Do NOT use.**
+
+proc high*(_: typedesc[JsBigInt]): JsBigInt {.error:
+  "Arbitrary precision integers do not have a known high.".} ## **Do NOT use.**
+
+
+runnableExamples:
+  block:
+    let big1: JsBigInt = big"2147483647"
+    let big2: JsBigInt = big"666"
+    doAssert JsBigInt isnot int
+    doAssert big1 != big2
+    doAssert big1 > big2
+    doAssert big1 >= big2
+    doAssert big2 < big1
+    doAssert big2 <= big1
+    doAssert not(big1 == big2)
+    let z = JsBigInt.default
+    doAssert $z == "0n"
+  block:
+    var a: seq[JsBigInt]
+    a.setLen 2
+    doAssert a == @[big"0", big"0"]
+    doAssert a[^1] == big"0"
+    var b: JsBigInt
+    doAssert b == big"0"
+    doAssert b == JsBigInt.default
diff --git a/lib/std/jsfetch.nim b/lib/std/jsfetch.nim
new file mode 100644
index 000000000..219594619
--- /dev/null
+++ b/lib/std/jsfetch.nim
@@ -0,0 +1,202 @@
+## - Fetch for the JavaScript target: https://developer.mozilla.org/docs/Web/API/Fetch_API
+when not defined(js):
+  {.fatal: "Module jsfetch is designed to be used with the JavaScript backend.".}
+
+import std/[asyncjs, jsformdata, jsheaders]
+export jsformdata, jsheaders
+from std/httpcore import HttpMethod
+from std/jsffi import JsObject
+
+type
+  FetchOptions* = ref object of JsRoot  ## Options for Fetch API.
+    keepalive*: bool
+    metod* {.importjs: "method".}: cstring
+    body*, integrity*, referrer*, mode*, credentials*, cache*, redirect*, referrerPolicy*: cstring
+    headers*: Headers
+
+  FetchModes* = enum  ## Mode options.
+    fmCors = "cors"
+    fmNoCors = "no-cors"
+    fmSameOrigin = "same-origin"
+
+  FetchCredentials* = enum  ## Credential options. See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials
+    fcInclude = "include"
+    fcSameOrigin = "same-origin"
+    fcOmit = "omit"
+
+  FetchCaches* = enum  ## https://developer.mozilla.org/docs/Web/API/Request/cache
+    fchDefault = "default"
+    fchNoStore = "no-store"
+    fchReload = "reload"
+    fchNoCache = "no-cache"
+    fchForceCache = "force-cache"
+
+  FetchRedirects* = enum  ## Redirects options.
+    frFollow = "follow"
+    frError = "error"
+    frManual = "manual"
+
+  FetchReferrerPolicies* = enum  ## Referrer Policy options.
+    frpNoReferrer = "no-referrer"
+    frpNoReferrerWhenDowngrade = "no-referrer-when-downgrade"
+    frpOrigin = "origin"
+    frpOriginWhenCrossOrigin = "origin-when-cross-origin"
+    frpUnsafeUrl = "unsafe-url"
+
+  Response* = ref object of JsRoot  ## https://developer.mozilla.org/en-US/docs/Web/API/Response
+    bodyUsed*, ok*, redirected*: bool
+    typ* {.importjs: "type".}: cstring
+    url*, statusText*: cstring
+    status*: cint
+    headers*: Headers
+    body*: cstring
+
+  Request* = ref object of JsRoot  ## https://developer.mozilla.org/en-US/docs/Web/API/Request
+    bodyUsed*, ok*, redirected*: bool
+    typ* {.importjs: "type".}: cstring
+    url*, statusText*: cstring
+    status*: cint
+    headers*: Headers
+    body*: cstring
+
+func newResponse*(body: cstring | FormData): Response {.importjs: "(new Response(#))".}
+  ## Constructor for `Response`. This does *not* call `fetch()`. Same as `new Response()`.
+
+func newRequest*(url: cstring): Request {.importjs: "(new Request(#))".}
+  ## Constructor for `Request`. This does *not* call `fetch()`. Same as `new Request()`.
+
+func newRequest*(url: cstring; fetchOptions: FetchOptions): Request {.importjs: "(new Request(#, #))".}
+  ## Constructor for `Request` with `fetchOptions`. Same as `fetch(url, fetchOptions)`.
+
+func clone*(self: Response | Request): Response {.importjs: "#.$1()".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Response/clone
+
+proc text*(self: Response): Future[cstring] {.importjs: "#.$1()".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Response/text
+
+proc json*(self: Response): Future[JsObject] {.importjs: "#.$1()".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Response/json
+
+proc formData*(self: Response): Future[FormData] {.importjs: "#.$1()".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Response/formData
+
+proc unsafeNewFetchOptions*(metod, body, mode, credentials, cache, referrerPolicy: cstring;
+    keepalive: bool; redirect = "follow".cstring; referrer = "client".cstring; integrity = "".cstring; headers: Headers = newHeaders()): FetchOptions {.importjs:
+    "{method: #, body: #, mode: #, credentials: #, cache: #, referrerPolicy: #, keepalive: #, redirect: #, referrer: #, integrity: #, headers: #}".}
+  ## .. warning:: Unsafe `newfetchOptions`.
+
+func newfetchOptions*(metod = HttpGet; body: cstring = nil;
+    mode = fmCors; credentials = fcSameOrigin; cache = fchDefault; referrerPolicy = frpNoReferrerWhenDowngrade;
+    keepalive = false; redirect = frFollow; referrer = "client".cstring; integrity = "".cstring,
+    headers: Headers = newHeaders()): FetchOptions =
+  ## Constructor for `FetchOptions`.
+  result = FetchOptions(
+    body: if metod notin {HttpHead, HttpGet}: body else: nil, 
+    mode: cstring($mode), credentials: cstring($credentials), cache: cstring($cache), referrerPolicy: cstring($referrerPolicy),
+    keepalive: keepalive, redirect: cstring($redirect), referrer: referrer, integrity: integrity, headers: headers,
+    metod: (case metod
+      of HttpHead:   "HEAD".cstring
+      of HttpGet:    "GET".cstring
+      of HttpPost:   "POST".cstring
+      of HttpPut:    "PUT".cstring
+      of HttpDelete: "DELETE".cstring
+      of HttpPatch:  "PATCH".cstring
+      else:          "GET".cstring
+    )
+  )
+
+proc fetch*(url: cstring | Request): Future[Response] {.importjs: "$1(#)".}
+  ## `fetch()` API, simple `GET` only, returns a `Future[Response]`.
+
+proc fetch*(url: cstring | Request; options: FetchOptions): Future[Response] {.importjs: "$1(#, #)".}
+  ## `fetch()` API that takes a `FetchOptions`, returns a `Future[Response]`.
+
+func toCstring*(self: Request | Response | FetchOptions): cstring {.importjs: "JSON.stringify(#)".}
+
+func `$`*(self: Request | Response | FetchOptions): string = $toCstring(self)
+
+
+runnableExamples("-r:off"):
+  import std/[asyncjs, jsconsole, jsformdata, jsheaders]
+  from std/httpcore import HttpMethod
+  from std/jsffi import JsObject
+  from std/sugar import `=>`
+
+  block:
+    let options0: FetchOptions = unsafeNewFetchOptions(
+      metod = "POST".cstring,
+      body = """{"key": "value"}""".cstring,
+      mode = "no-cors".cstring,
+      credentials = "omit".cstring,
+      cache = "no-cache".cstring,
+      referrerPolicy = "no-referrer".cstring,
+      keepalive = false,
+      redirect = "follow".cstring,
+      referrer = "client".cstring,
+      integrity = "".cstring,
+      headers = newHeaders()
+    )
+    assert options0.keepalive == false
+    assert options0.metod == "POST".cstring
+    assert options0.body == """{"key": "value"}""".cstring
+    assert options0.mode == "no-cors".cstring
+    assert options0.credentials == "omit".cstring
+    assert options0.cache == "no-cache".cstring
+    assert options0.referrerPolicy == "no-referrer".cstring
+    assert options0.redirect == "follow".cstring
+    assert options0.referrer == "client".cstring
+    assert options0.integrity == "".cstring
+    assert options0.headers.len == 0
+
+  block:
+    let options1: FetchOptions = newFetchOptions(
+      metod =  HttpPost,
+      body = """{"key": "value"}""".cstring,
+      mode = fmNoCors,
+      credentials = fcOmit,
+      cache = fchNoCache,
+      referrerPolicy = frpNoReferrer,
+      keepalive = false,
+      redirect = frFollow,
+      referrer = "client".cstring,
+      integrity = "".cstring,
+      headers = newHeaders()
+    )
+    assert options1.keepalive == false
+    assert options1.metod == $HttpPost
+    assert options1.body == """{"key": "value"}""".cstring
+    assert options1.mode == $fmNoCors
+    assert options1.credentials == $fcOmit
+    assert options1.cache == $fchNoCache
+    assert options1.referrerPolicy == $frpNoReferrer
+    assert options1.redirect == $frFollow
+    assert options1.referrer == "client".cstring
+    assert options1.integrity == "".cstring
+    assert options1.headers.len == 0
+
+  block:
+    let response: Response = newResponse(body = "-. .. --".cstring)
+    let request: Request = newRequest(url = "http://nim-lang.org".cstring)
+
+  if not defined(nodejs):
+    block:
+      proc doFetch(): Future[Response] {.async.} =
+        fetch "https://httpbin.org/get".cstring
+
+      proc example() {.async.} =
+        let response: Response = await doFetch()
+        assert response.ok
+        assert response.status == 200.cint
+        assert response.headers is Headers
+        assert response.body is cstring
+
+      discard example()
+
+    block:
+      proc example2 {.async.} =
+        await fetch("https://api.github.com/users/torvalds".cstring)
+          .then((response: Response) => response.json())
+          .then((json: JsObject) => console.log(json))
+          .catch((err: Error) => console.log("Request Failed", err))
+
+      discard example2()
diff --git a/lib/std/jsformdata.nim b/lib/std/jsformdata.nim
new file mode 100644
index 000000000..61dcc39a3
--- /dev/null
+++ b/lib/std/jsformdata.nim
@@ -0,0 +1,69 @@
+## - `FormData` for the JavaScript target: https://developer.mozilla.org/en-US/docs/Web/API/FormData
+when not defined(js):
+  {.fatal: "Module jsformdata is designed to be used with the JavaScript backend.".}
+
+from std/dom import Blob
+
+type FormData* = ref object of JsRoot ## FormData API.
+
+func newFormData*(): FormData {.importjs: "new FormData()".}
+
+func add*(self: FormData; name: cstring; value: SomeNumber | bool | cstring | Blob) {.importjs: "#.append(#, #)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/append
+  ##
+  ## .. hint:: Duplicate keys are allowed and order is preserved.
+
+func add*(self: FormData; name: cstring; value: SomeNumber | bool | cstring | Blob; filename: cstring) {.importjs: "#.append(#, #, #)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/append
+  ##
+  ## .. hint:: Duplicate keys are allowed and order is preserved.
+
+func delete*(self: FormData; name: cstring) {.importjs: "#.$1(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/delete
+  ##
+  ## .. warning:: Deletes *all items* with the same key name.
+
+func getAll*(self: FormData; name: cstring): seq[cstring] {.importjs: "#.$1(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/getAll
+
+func hasKey*(self: FormData; name: cstring): bool {.importjs: "#.has(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/has
+
+func keys*(self: FormData): seq[cstring] {.importjs: "Array.from(#.$1())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/keys
+
+func values*(self: FormData): seq[cstring] {.importjs: "Array.from(#.$1())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/values
+
+func pairs*(self: FormData): seq[tuple[key, val: cstring]] {.importjs: "Array.from(#.entries())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries
+
+func put*(self: FormData; name: cstring; value: SomeNumber | bool | cstring | Blob; filename: cstring) {.importjs: "#.set(#, #, #)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/set
+
+func `[]=`*(self: FormData; name: cstring; value: SomeNumber | bool | cstring | Blob) {.importjs: "#.set(#, #)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/set
+
+func `[]`*(self: FormData; name: cstring): cstring {.importjs: "#.get(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/FormData/get
+
+func clear*(self: FormData) {.importjs:
+  "(() => { const frmdt = #; Array.from(frmdt.keys()).forEach((key) => frmdt.delete(key)) })()".}
+  ## Convenience func to delete all items from `FormData`.
+
+func toCstring*(self: FormData): cstring {.importjs: "JSON.stringify(#)".}
+
+func `$`*(self: FormData): string = $toCstring(self)
+
+func len*(self: FormData): int {.importjs: "Array.from(#.entries()).length".}
+
+
+runnableExamples("-r:off"):
+  let data: FormData = newFormData()
+  data["key0"] = "value0".cstring
+  data.add("key1".cstring, "value1".cstring)
+  data.delete("key1")
+  assert data.hasKey("key0")
+  assert data["key0"] == "value0".cstring
+  data.clear()
+  assert data.len == 0
diff --git a/lib/std/jsheaders.nim b/lib/std/jsheaders.nim
new file mode 100644
index 000000000..6fd3b3468
--- /dev/null
+++ b/lib/std/jsheaders.nim
@@ -0,0 +1,83 @@
+## - HTTP Headers for the JavaScript target: https://developer.mozilla.org/en-US/docs/Web/API/Headers
+when not defined(js):
+  {.fatal: "Module jsheaders is designed to be used with the JavaScript backend.".}
+
+type Headers* = ref object of JsRoot ## HTTP Headers API.
+
+func newHeaders*(): Headers {.importjs: "new Headers()".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers
+
+func add*(self: Headers; key: cstring; value: cstring) {.importjs: "#.append(#, #)".}
+  ## Allows duplicated keys.
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/append
+
+func delete*(self: Headers; key: cstring) {.importjs: "#.$1(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/delete
+  ##
+  ## .. warning:: Delete *all* items with `key` from the headers, including duplicated keys.
+
+func hasKey*(self: Headers; key: cstring): bool {.importjs: "#.has(#)".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/has
+
+func keys*(self: Headers): seq[cstring] {.importjs: "Array.from(#.$1())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/keys
+
+func values*(self: Headers): seq[cstring] {.importjs: "Array.from(#.$1())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/values
+
+func entries*(self: Headers): seq[tuple[key, value: cstring]] {.importjs: "Array.from(#.$1())".}
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries
+
+func `[]`*(self: Headers; key: cstring): cstring {.importjs: "#.get(#)".}
+  ## Get *all* items with `key` from the headers, including duplicated values.
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
+
+func `[]=`*(self: Headers; key: cstring; value: cstring) {.importjs: "#.set(#, #)".}
+  ## Do *not* allow duplicated keys, overwrites duplicated keys.
+  ## https://developer.mozilla.org/en-US/docs/Web/API/Headers/set
+
+func clear*(self: Headers) {.importjs:
+  "(() => { const header = #; Array.from(header.keys()).forEach((key) => header.delete(key)) })()".}
+  ## Convenience func to delete all items from `Headers`.
+
+func toCstring*(self: Headers): cstring {.importjs: "JSON.stringify(Array.from(#.entries()))".}
+  ## Returns a `cstring` representation of `Headers`.
+
+func `$`*(self: Headers): string = $toCstring(self)
+
+func len*(self: Headers): int {.importjs: "Array.from(#.entries()).length".}
+
+
+runnableExamples("-r:off"):
+
+  block:
+    let header: Headers = newHeaders()
+    header.add("key", "value")
+    assert header.hasKey("key")
+    assert header.keys() == @["key".cstring]
+    assert header.values() == @["value".cstring]
+    assert header["key"] == "value".cstring
+    header["other"] = "another".cstring
+    assert header["other"] == "another".cstring
+    assert header.entries() == @[("key".cstring, "value".cstring), ("other".cstring, "another".cstring)]
+    assert header.toCstring() == """[["key","value"],["other","another"]]""".cstring
+    header.delete("other")
+    assert header.entries() == @[("key".cstring, "value".cstring)]
+    header.clear()
+    assert header.entries() == @[]
+    assert header.len == 0
+
+  block:
+    let header: Headers = newHeaders()
+    header.add("key", "a")
+    header.add("key", "b")  ## Duplicated.
+    header.add("key", "c")  ## Duplicated.
+    assert header["key"] == "a, b, c".cstring
+    header["key"] = "value".cstring
+    assert header["key"] == "value".cstring
+
+  block:
+    let header: Headers = newHeaders()
+    header["key"] = "a"
+    header["key"] = "b"  ## Overwrites.
+    assert header["key"] == "b".cstring
diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim
new file mode 100644
index 000000000..2d28748ce
--- /dev/null
+++ b/lib/std/jsonutils.nim
@@ -0,0 +1,493 @@
+##[
+This module implements a hookable (de)serialization for arbitrary types using JSON.
+Design goal: avoid importing modules where a custom serialization is needed;
+see strtabs.fromJsonHook,toJsonHook for an example.
+]##
+
+runnableExamples:
+  import std/[strtabs,json]
+  type Foo = ref object
+    t: bool
+    z1: int8
+  let a = (1.5'f32, (b: "b2", a: "a2"), 'x', @[Foo(t: true, z1: -3), nil], [{"name": "John"}.newStringTable])
+  let j = a.toJson
+  assert j.jsonTo(typeof(a)).toJson == j
+  assert $[NaN, Inf, -Inf, 0.0, -0.0, 1.0, 1e-2].toJson == """["nan","inf","-inf",0.0,-0.0,1.0,0.01]"""
+  assert 0.0.toJson.kind == JFloat
+  assert Inf.toJson.kind == JString
+
+import std/[json, strutils, tables, sets, strtabs, options, strformat]
+
+#[
+Future directions:
+add a way to customize serialization, for e.g.:
+* field renaming
+* allow serializing `enum` and `char` as `string` instead of `int`
+  (enum is more compact/efficient, and robust to enum renamings, but string
+  is more human readable)
+* handle cyclic references, using a cache of already visited addresses
+* implement support for serialization and de-serialization of nested variant
+  objects.
+]#
+
+import std/macros
+from std/enumutils import symbolName
+from std/typetraits import OrdinalEnum, tupleLen
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
+
+type
+  Joptions* = object # xxx rename FromJsonOptions
+    ## Options controlling the behavior of `fromJson`.
+    allowExtraKeys*: bool
+      ## If `true` Nim's object to which the JSON is parsed is not required to
+      ## have a field for every JSON key.
+    allowMissingKeys*: bool
+      ## If `true` Nim's object to which JSON is parsed is allowed to have
+      ## fields without corresponding JSON keys.
+    # in future work: a key rename could be added
+  EnumMode* = enum
+    joptEnumOrd
+    joptEnumSymbol
+    joptEnumString
+  JsonNodeMode* = enum ## controls `toJson` for JsonNode types
+    joptJsonNodeAsRef ## returns the ref as is
+    joptJsonNodeAsCopy ## returns a deep copy of the JsonNode
+    joptJsonNodeAsObject ## treats JsonNode as a regular ref object
+  ToJsonOptions* = object
+    enumMode*: EnumMode
+    jsonNodeMode*: JsonNodeMode
+    # xxx charMode, etc
+
+proc initToJsonOptions*(): ToJsonOptions =
+  ## initializes `ToJsonOptions` with sane options.
+  ToJsonOptions(enumMode: joptEnumOrd, jsonNodeMode: joptJsonNodeAsRef)
+
+proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".}
+template distinctBase[T](a: T, recursive: static bool = true): untyped = distinctBase(typeof(a), recursive)(a)
+
+macro getDiscriminants(a: typedesc): seq[string] =
+  ## return the discriminant keys
+  # candidate for std/typetraits
+  var a = a.getTypeImpl
+  doAssert a.kind == nnkBracketExpr
+  let sym = a[1]
+  let t = sym.getTypeImpl
+  let t2 = t[2]
+  case t2.kind
+  of nnkEmpty: # allow empty objects
+    result = quote do:
+        seq[string].default
+  of nnkRecList:
+    result = newTree(nnkBracket)
+    for ti in t2:
+      if ti.kind == nnkRecCase:
+        let key = ti[0][0]
+        result.add newLit key.strVal
+    if result.len > 0:
+      result = quote do:
+        @`result`
+    else:
+      result = quote do:
+        seq[string].default
+  else:
+    raiseAssert "unexpected kind: " & $t2.kind
+
+macro initCaseObject(T: typedesc, fun: untyped): untyped =
+  ## does the minimum to construct a valid case object, only initializing
+  ## the discriminant fields; see also `getDiscriminants`
+  # maybe candidate for std/typetraits
+  var a = T.getTypeImpl
+  doAssert a.kind == nnkBracketExpr
+  let sym = a[1]
+  let t = sym.getTypeImpl
+  var t2: NimNode
+  case t.kind
+  of nnkObjectTy: t2 = t[2]
+  of nnkRefTy: t2 = t[0].getTypeImpl[2]
+  else: raiseAssert $t.kind # xxx `nnkPtrTy` could be handled too
+  doAssert t2.kind == nnkRecList
+  result = newTree(nnkObjConstr)
+  result.add sym
+  for ti in t2:
+    if ti.kind == nnkRecCase:
+      let key = ti[0][0]
+      let typ = ti[0][1]
+      let key2 = key.strVal
+      let val = quote do:
+        `fun`(`key2`, typedesc[`typ`])
+      result.add newTree(nnkExprColonExpr, key, val)
+
+proc raiseJsonException(condStr: string, msg: string) {.noinline.} =
+  # just pick 1 exception type for simplicity; other choices would be:
+  # JsonError, JsonParser, JsonKindError
+  raise newException(ValueError, condStr & " failed: " & msg)
+
+template checkJson(cond: untyped, msg = "") =
+  if not cond:
+    raiseJsonException(astToStr(cond), msg)
+
+proc hasField[T](obj: T, field: string): bool =
+  for k, _ in fieldPairs(obj):
+    if k == field:
+      return true
+  return false
+
+macro accessField(obj: typed, name: static string): untyped =
+  newDotExpr(obj, ident(name))
+
+template fromJsonFields(newObj, oldObj, json, discKeys, opt) =
+  type T = typeof(newObj)
+  # we could customize whether to allow JNull
+  checkJson json.kind == JObject, $json.kind
+  var num, numMatched = 0
+  for key, val in fieldPairs(newObj):
+    num.inc
+    when key notin discKeys:
+      if json.hasKey key:
+        numMatched.inc
+        fromJson(val, json[key], opt)
+      elif opt.allowMissingKeys:
+        # if there are no discriminant keys the `oldObj` must always have the
+        # same keys as the new one. Otherwise we must check, because they could
+        # be set to different branches.
+        when typeof(oldObj) isnot typeof(nil):
+          if discKeys.len == 0 or hasField(oldObj, key):
+            val = accessField(oldObj, key)
+      else:
+        checkJson false, "key '$1' for $2 not in $3" % [key, $T, json.pretty()]
+    else:
+      if json.hasKey key:
+        numMatched.inc
+
+  let ok =
+    if opt.allowExtraKeys and opt.allowMissingKeys:
+      true
+    elif opt.allowExtraKeys:
+      # This check is redundant because if here missing keys are not allowed,
+      # and if `num != numMatched` it will fail in the loop above but it is left
+      # for clarity.
+      assert num == numMatched
+      num == numMatched
+    elif opt.allowMissingKeys:
+      json.len == numMatched
+    else:
+      json.len == num and num == numMatched
+
+  checkJson ok, "There were $1 keys (expecting $2) for $3 with $4" % [$json.len, $num, $T, json.pretty()]
+
+proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions())
+
+proc discKeyMatch[T](obj: T, json: JsonNode, key: static string): bool =
+  if not json.hasKey key:
+    return true
+  let field = accessField(obj, key)
+  var jsonVal: typeof(field)
+  fromJson(jsonVal, json[key])
+  if jsonVal != field:
+    return false
+  return true
+
+macro discKeysMatchBodyGen(obj: typed, json: JsonNode,
+                           keys: static seq[string]): untyped =
+  result = newStmtList()
+  let r = ident("result")
+  for key in keys:
+    let keyLit = newLit key
+    result.add quote do:
+      `r` = `r` and discKeyMatch(`obj`, `json`, `keyLit`)
+
+proc discKeysMatch[T](obj: T, json: JsonNode, keys: static seq[string]): bool =
+  result = true
+  discKeysMatchBodyGen(obj, json, keys)
+
+proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) =
+  ## inplace version of `jsonTo`
+  #[
+  adding "json path" leading to `b` can be added in future work.
+  ]#
+  checkJson b != nil, $($T, b)
+  when compiles(fromJsonHook(a, b, opt)): fromJsonHook(a, b, opt)
+  elif compiles(fromJsonHook(a, b)): fromJsonHook(a, b)
+  elif T is bool: a = to(b,T)
+  elif T is enum:
+    case b.kind
+    of JInt: a = T(b.getBiggestInt())
+    of JString: a = parseEnum[T](b.getStr())
+    else: checkJson false, fmt"Expecting int/string for {$T} got {b.pretty()}"
+  elif T is uint|uint64: a = T(to(b, uint64))
+  elif T is Ordinal: a = cast[T](to(b, int))
+  elif T is pointer: a = cast[pointer](to(b, int))
+  elif T is distinct: a.distinctBase.fromJson(b)
+  elif T is string|SomeNumber: a = to(b,T)
+  elif T is cstring:
+    case b.kind
+    of JNull: a = nil
+    of JString: a = b.str
+    else: checkJson false, fmt"Expecting null/string for {$T} got {b.pretty()}"
+  elif T is JsonNode: a = b
+  elif T is ref | ptr:
+    if b.kind == JNull: a = nil
+    else:
+      a = T()
+      fromJson(a[], b, opt)
+  elif T is array:
+    checkJson a.len == b.len, fmt"Json array size doesn't match for {$T}"
+    var i = 0
+    for ai in mitems(a):
+      fromJson(ai, b[i], opt)
+      i.inc
+  elif T is set:
+    type E = typeof(for ai in a: ai)
+    for val in b.getElems:
+      incl a, jsonTo(val, E)
+  elif T is seq:
+    a.setLen b.len
+    for i, val in b.getElems:
+      fromJson(a[i], val, opt)
+  elif T is object:
+    template fun(key, typ): untyped {.used.} =
+      if b.hasKey key:
+        jsonTo(b[key], typ)
+      elif hasField(a, key):
+        accessField(a, key)
+      else:
+        default(typ)
+    const keys = getDiscriminants(T)
+    when keys.len == 0:
+      fromJsonFields(a, nil, b, keys, opt)
+    else:
+      if discKeysMatch(a, b, keys):
+        fromJsonFields(a, nil, b, keys, opt)
+      else:
+        var newObj = initCaseObject(T, fun)
+        fromJsonFields(newObj, a, b, keys, opt)
+        a = newObj
+  elif T is tuple:
+    when isNamedTuple(T):
+      fromJsonFields(a, nil, b, seq[string].default, opt)
+    else:
+      checkJson b.kind == JArray, $(b.kind) # we could customize whether to allow JNull
+
+      when compiles(tupleLen(T)):
+        let tupleSize = tupleLen(T)
+      else:
+        # Tuple len isn't in csources_v1 so using tupleLen would fail.
+        # Else branch basically never runs (tupleLen added in 1.1 and jsonutils in 1.4), but here for consistency
+        var tupleSize = 0
+        for val in fields(a):
+          tupleSize.inc
+
+      checkJson b.len == tupleSize, fmt"Json doesn't match expected length of {tupleSize}, got {b.pretty()}"
+      var i = 0
+      for val in fields(a):
+        fromJson(val, b[i], opt)
+        i.inc
+  else:
+    # checkJson not appropriate here
+    static: raiseAssert "not yet implemented: " & $T
+
+proc jsonTo*(b: JsonNode, T: typedesc, opt = Joptions()): T =
+  ## reverse of `toJson`
+  fromJson(result, b, opt)
+
+proc toJson*[T](a: T, opt = initToJsonOptions()): JsonNode =
+  ## serializes `a` to json; uses `toJsonHook(a: T)` if it's in scope to
+  ## customize serialization, see strtabs.toJsonHook for an example.
+  ##
+  ## .. note:: With `-d:nimPreviewJsonutilsHoleyEnum`, `toJson` now can 
+  ##    serialize/deserialize holey enums as regular enums (via `ord`) instead of as strings.
+  ##    It is expected that this behavior becomes the new default in upcoming versions.
+  when compiles(toJsonHook(a, opt)): result = toJsonHook(a, opt)
+  elif compiles(toJsonHook(a)): result = toJsonHook(a)
+  elif T is object | tuple:
+    when T is object or isNamedTuple(T):
+      result = newJObject()
+      for k, v in a.fieldPairs: result[k] = toJson(v, opt)
+    else:
+      result = newJArray()
+      for v in a.fields: result.add toJson(v, opt)
+  elif T is ref | ptr:
+    template impl =
+      if system.`==`(a, nil): result = newJNull()
+      else: result = toJson(a[], opt)
+    when T is JsonNode:
+      case opt.jsonNodeMode
+      of joptJsonNodeAsRef: result = a
+      of joptJsonNodeAsCopy: result = copy(a)
+      of joptJsonNodeAsObject: impl()
+    else: impl()
+  elif T is array | seq | set:
+    result = newJArray()
+    for ai in a: result.add toJson(ai, opt)
+  elif T is pointer: result = toJson(cast[int](a), opt)
+    # edge case: `a == nil` could've also led to `newJNull()`, but this results
+    # in simpler code for `toJson` and `fromJson`.
+  elif T is distinct: result = toJson(a.distinctBase, opt)
+  elif T is bool: result = %(a)
+  elif T is SomeInteger: result = %a
+  elif T is enum:
+    case opt.enumMode
+    of joptEnumOrd:
+      when T is Ordinal or defined(nimPreviewJsonutilsHoleyEnum): %(a.ord)
+      else: toJson($a, opt)
+    of joptEnumSymbol:
+      when T is OrdinalEnum:
+        toJson(symbolName(a), opt)
+      else:
+        toJson($a, opt)
+    of joptEnumString: toJson($a, opt)
+  elif T is Ordinal: result = %(a.ord)
+  elif T is cstring: (if a == nil: result = newJNull() else: result = % $a)
+  else: result = %a
+
+proc fromJsonHook*[K: string|cstring, V](t: var (Table[K, V] | OrderedTable[K, V]),
+                         jsonNode: JsonNode, opt = Joptions()) =
+  ## Enables `fromJson` for `Table` and `OrderedTable` types.
+  ##
+  ## See also:
+  ## * `toJsonHook proc<#toJsonHook>`_
+  runnableExamples:
+    import std/[tables, json]
+    var foo: tuple[t: Table[string, int], ot: OrderedTable[string, int]]
+    fromJson(foo, parseJson("""
+      {"t":{"two":2,"one":1},"ot":{"one":1,"three":3}}"""))
+    assert foo.t == [("one", 1), ("two", 2)].toTable
+    assert foo.ot == [("one", 1), ("three", 3)].toOrderedTable
+
+  assert jsonNode.kind == JObject,
+          "The kind of the `jsonNode` must be `JObject`, but its actual " &
+          "type is `" & $jsonNode.kind & "`."
+  clear(t)
+  for k, v in jsonNode:
+    t[k] = jsonTo(v, V, opt)
+
+proc toJsonHook*[K: string|cstring, V](t: (Table[K, V] | OrderedTable[K, V]), opt = initToJsonOptions()): JsonNode =
+  ## Enables `toJson` for `Table` and `OrderedTable` types.
+  ##
+  ## See also:
+  ## * `fromJsonHook proc<#fromJsonHook,,JsonNode>`_
+  runnableExamples:
+    import std/[tables, json, sugar]
+    let foo = (
+      t: [("two", 2)].toTable,
+      ot: [("one", 1), ("three", 3)].toOrderedTable)
+    assert $toJson(foo) == """{"t":{"two":2},"ot":{"one":1,"three":3}}"""
+    # if keys are not string|cstring, you can use this:
+    let a = {10: "foo", 11: "bar"}.newOrderedTable
+    let a2 = collect: (for k,v in a: (k,v))
+    assert $toJson(a2) == """[[10,"foo"],[11,"bar"]]"""
+
+  result = newJObject()
+  for k, v in pairs(t):
+    # not sure if $k has overhead for string
+    result[(when K is string: k else: $k)] = toJson(v, opt)
+
+proc fromJsonHook*[A](s: var SomeSet[A], jsonNode: JsonNode, opt = Joptions()) =
+  ## Enables `fromJson` for `HashSet` and `OrderedSet` types.
+  ##
+  ## See also:
+  ## * `toJsonHook proc<#toJsonHook,SomeSet[A]>`_
+  runnableExamples:
+    import std/[sets, json]
+    var foo: tuple[hs: HashSet[string], os: OrderedSet[string]]
+    fromJson(foo, parseJson("""
+      {"hs": ["hash", "set"], "os": ["ordered", "set"]}"""))
+    assert foo.hs == ["hash", "set"].toHashSet
+    assert foo.os == ["ordered", "set"].toOrderedSet
+
+  assert jsonNode.kind == JArray,
+          "The kind of the `jsonNode` must be `JArray`, but its actual " &
+          "type is `" & $jsonNode.kind & "`."
+  clear(s)
+  for v in jsonNode:
+    incl(s, jsonTo(v, A, opt))
+
+proc toJsonHook*[A](s: SomeSet[A], opt = initToJsonOptions()): JsonNode =
+  ## Enables `toJson` for `HashSet` and `OrderedSet` types.
+  ##
+  ## See also:
+  ## * `fromJsonHook proc<#fromJsonHook,SomeSet[A],JsonNode>`_
+  runnableExamples:
+    import std/[sets, json]
+    let foo = (hs: ["hash"].toHashSet, os: ["ordered", "set"].toOrderedSet)
+    assert $toJson(foo) == """{"hs":["hash"],"os":["ordered","set"]}"""
+
+  result = newJArray()
+  for k in s:
+    add(result, toJson(k, opt))
+
+proc fromJsonHook*[T](self: var Option[T], jsonNode: JsonNode, opt = Joptions()) =
+  ## Enables `fromJson` for `Option` types.
+  ##
+  ## See also:
+  ## * `toJsonHook proc<#toJsonHook,Option[T]>`_
+  runnableExamples:
+    import std/[options, json]
+    var opt: Option[string]
+    fromJsonHook(opt, parseJson("\"test\""))
+    assert get(opt) == "test"
+    fromJson(opt, parseJson("null"))
+    assert isNone(opt)
+
+  if jsonNode.kind != JNull:
+    self = some(jsonTo(jsonNode, T, opt))
+  else:
+    self = none[T]()
+
+proc toJsonHook*[T](self: Option[T], opt = initToJsonOptions()): JsonNode =
+  ## Enables `toJson` for `Option` types.
+  ##
+  ## See also:
+  ## * `fromJsonHook proc<#fromJsonHook,Option[T],JsonNode>`_
+  runnableExamples:
+    import std/[options, json]
+    let optSome = some("test")
+    assert $toJson(optSome) == "\"test\""
+    let optNone = none[string]()
+    assert $toJson(optNone) == "null"
+
+  if isSome(self):
+    toJson(get(self), opt)
+  else:
+    newJNull()
+
+proc fromJsonHook*(a: var StringTableRef, b: JsonNode) =
+  ## Enables `fromJson` for `StringTableRef` type.
+  ##
+  ## See also:
+  ## * `toJsonHook proc<#toJsonHook,StringTableRef>`_
+  runnableExamples:
+    import std/[strtabs, json]
+    var t = newStringTable(modeCaseSensitive)
+    let jsonStr = """{"mode": 0, "table": {"name": "John", "surname": "Doe"}}"""
+    fromJsonHook(t, parseJson(jsonStr))
+    assert t[] == newStringTable("name", "John", "surname", "Doe",
+                                 modeCaseSensitive)[]
+
+  var mode = jsonTo(b["mode"], StringTableMode)
+  a = newStringTable(mode)
+  let b2 = b["table"]
+  for k,v in b2: a[k] = jsonTo(v, string)
+
+proc toJsonHook*(a: StringTableRef): JsonNode =
+  ## Enables `toJson` for `StringTableRef` type.
+  ##
+  ## See also:
+  ## * `fromJsonHook proc<#fromJsonHook,StringTableRef,JsonNode>`_
+  runnableExamples:
+    import std/[strtabs, json]
+    let t = newStringTable("name", "John", "surname", "Doe", modeCaseSensitive)
+    let jsonStr = """{"mode": "modeCaseSensitive",
+                      "table": {"name": "John", "surname": "Doe"}}"""
+    assert toJson(t) == parseJson(jsonStr)
+
+  result = newJObject()
+  result["mode"] = toJson($a.mode)
+  let t = newJObject()
+  for k,v in a: t[k] = toJson(v)
+  result["table"] = t
diff --git a/lib/std/logic.nim b/lib/std/logic.nim
new file mode 100644
index 000000000..84640d380
--- /dev/null
+++ b/lib/std/logic.nim
@@ -0,0 +1,10 @@
+## This module provides further logic operators like 'forall' and 'exists'
+## They are only supported in `.ensures` etc pragmas.
+
+proc `->`*(a, b: bool): bool {.magic: "Implies".}
+proc `<->`*(a, b: bool): bool {.magic: "Iff".}
+
+proc forall*(args: varargs[untyped]): bool {.magic: "Forall".}
+proc exists*(args: varargs[untyped]): bool {.magic: "Exists".}
+
+proc old*[T](x: T): T {.magic: "Old".}
diff --git a/lib/std/monotimes.nim b/lib/std/monotimes.nim
new file mode 100644
index 000000000..bf6dc776b
--- /dev/null
+++ b/lib/std/monotimes.nim
@@ -0,0 +1,160 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+##[
+The `std/monotimes` module implements monotonic timestamps. A monotonic
+timestamp represents the time that has passed since some system defined
+point in time. The monotonic timestamps are guaranteed not to decrease,
+meaning that that the following is guaranteed to work:
+]##
+
+runnableExamples:
+  let a = getMonoTime()
+  let b = getMonoTime()
+  assert a <= b
+
+##[
+This is not guaranteed for the `times.Time` type! This means that the
+`MonoTime` should be used when measuring durations of time with
+high precision.
+
+However, since `MonoTime` represents the time that has passed since some
+unknown time origin, it cannot be converted to a human readable timestamp.
+If this is required, the `times.Time` type should be used instead.
+
+The `MonoTime` type stores the timestamp in nanosecond resolution, but note
+that the actual supported time resolution differs for different systems.
+
+See also
+========
+* `times module <times.html>`_
+]##
+
+import std/times
+
+type
+  MonoTime* = object ## Represents a monotonic timestamp.
+    ticks: int64
+
+when defined(macosx):
+  type
+    MachTimebaseInfoData {.pure, final, importc: "mach_timebase_info_data_t",
+        header: "<mach/mach_time.h>".} = object
+      numer, denom: int32
+
+  proc mach_absolute_time(): int64 {.importc, header: "<mach/mach.h>".}
+  proc mach_timebase_info(info: var MachTimebaseInfoData) {.importc,
+    header: "<mach/mach_time.h>".}
+
+when defined(js):
+  proc getJsTicks: float =
+    ## Returns ticks in the unit seconds.
+    when defined(nodejs):
+      {.emit: """
+      let process = require('process');
+      let time = process.hrtime();
+      `result` = time[0] + time[1] / 1000000000;
+      """.}
+    else:
+      proc jsNow(): float {.importjs: "window.performance.now()".}
+      result = jsNow() / 1000
+
+  # Workaround for #6752.
+  {.push overflowChecks: off.}
+  proc `-`(a, b: int64): int64 =
+    system.`-`(a, b)
+  proc `+`(a, b: int64): int64 =
+    system.`+`(a, b)
+  {.pop.}
+
+elif defined(posix) and not defined(osx):
+  import std/posix
+
+when defined(zephyr):
+  proc k_uptime_ticks(): int64 {.importc: "k_uptime_ticks", header: "<kernel.h>".}
+  proc k_ticks_to_ns_floor64(ticks: int64): int64 {.importc: "k_ticks_to_ns_floor64", header: "<kernel.h>".}
+
+elif defined(windows):
+  proc QueryPerformanceCounter(res: var uint64) {.
+    importc: "QueryPerformanceCounter", stdcall, dynlib: "kernel32".}
+  proc QueryPerformanceFrequency(res: var uint64) {.
+    importc: "QueryPerformanceFrequency", stdcall, dynlib: "kernel32".}
+
+proc getMonoTime*(): MonoTime {.tags: [TimeEffect].} =
+  ## Returns the current `MonoTime` timestamp.
+  ##
+  ## When compiled with the JS backend and executed in a browser,
+  ## this proc calls `window.performance.now()`.
+  ## See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now)
+  ## for more information.
+  when defined(js):
+    let ticks = getJsTicks()
+    result = MonoTime(ticks: (ticks * 1_000_000_000).int64)
+  elif defined(macosx):
+    let ticks = mach_absolute_time()
+    var machAbsoluteTimeFreq: MachTimebaseInfoData
+    mach_timebase_info(machAbsoluteTimeFreq)
+    result = MonoTime(ticks: ticks * machAbsoluteTimeFreq.numer div
+      machAbsoluteTimeFreq.denom)
+  elif defined(zephyr):
+    let ticks = k_ticks_to_ns_floor64(k_uptime_ticks())
+    result = MonoTime(ticks: ticks)
+  elif defined(posix):
+    var ts: Timespec
+    discard clock_gettime(CLOCK_MONOTONIC, ts)
+    result = MonoTime(ticks: ts.tv_sec.int64 * 1_000_000_000 +
+      ts.tv_nsec.int64)
+  elif defined(windows):
+    var ticks: uint64
+    QueryPerformanceCounter(ticks)
+
+    var freq: uint64
+    QueryPerformanceFrequency(freq)
+    let queryPerformanceCounterFreq = 1_000_000_000'u64 div freq
+    result = MonoTime(ticks: (ticks * queryPerformanceCounterFreq).int64)
+
+proc ticks*(t: MonoTime): int64 =
+  ## Returns the raw ticks value from a `MonoTime`. This value always uses
+  ## nanosecond time resolution.
+  t.ticks
+
+proc `$`*(t: MonoTime): string =
+  $t.ticks
+
+proc `-`*(a, b: MonoTime): Duration =
+  ## Returns the difference between two `MonoTime` timestamps as a `Duration`.
+  initDuration(nanoseconds = (a.ticks - b.ticks))
+
+proc `+`*(a: MonoTime, b: Duration): MonoTime =
+  ## Increases `a` by `b`.
+  MonoTime(ticks: a.ticks + b.inNanoseconds)
+
+proc `-`*(a: MonoTime, b: Duration): MonoTime =
+  ## Reduces `a` by `b`.
+  MonoTime(ticks: a.ticks - b.inNanoseconds)
+
+proc `<`*(a, b: MonoTime): bool =
+  ## Returns true if `a` happened before `b`.
+  a.ticks < b.ticks
+
+proc `<=`*(a, b: MonoTime): bool =
+  ## Returns true if `a` happened before `b` or if they happened simultaneous.
+  a.ticks <= b.ticks
+
+proc `==`*(a, b: MonoTime): bool =
+  ## Returns true if `a` and `b` happened simultaneous.
+  a.ticks == b.ticks
+
+proc high*(typ: typedesc[MonoTime]): MonoTime =
+  ## Returns the highest representable `MonoTime`.
+  MonoTime(ticks: high(int64))
+
+proc low*(typ: typedesc[MonoTime]): MonoTime =
+  ## Returns the lowest representable `MonoTime`.
+  MonoTime(ticks: low(int64))
diff --git a/lib/std/objectdollar.nim b/lib/std/objectdollar.nim
new file mode 100644
index 000000000..86ce9afc8
--- /dev/null
+++ b/lib/std/objectdollar.nim
@@ -0,0 +1,13 @@
+## This module implements a generic `$` operator to convert objects to strings.
+
+import std/private/miscdollars
+
+proc `$`*[T: object](x: T): string =
+  ## Generic `$` operator for objects with similar output to
+  ## `$` for named tuples.
+  runnableExamples:
+    type Foo = object
+      a, b: int
+    let x = Foo(a: 23, b: 45)
+    assert $x == "(a: 23, b: 45)"
+  tupleObjectDollar(result, x)
diff --git a/lib/std/oserrors.nim b/lib/std/oserrors.nim
new file mode 100644
index 000000000..7b11c5e8e
--- /dev/null
+++ b/lib/std/oserrors.nim
@@ -0,0 +1,117 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+## The `std/oserrors` module implements OS error reporting.
+
+type
+  OSErrorCode* = distinct int32 ## Specifies an OS Error Code.
+
+when not defined(nimscript):
+  when defined(windows):
+    import std/winlean
+    when defined(nimPreviewSlimSystem):
+      import std/widestrs
+  else:
+    var errno {.importc, header: "<errno.h>".}: cint
+
+    proc c_strerror(errnum: cint): cstring {.
+      importc: "strerror", header: "<string.h>".}
+
+proc `==`*(err1, err2: OSErrorCode): bool {.borrow.}
+proc `$`*(err: OSErrorCode): string {.borrow.}
+
+proc osErrorMsg*(errorCode: OSErrorCode): string =
+  ## Converts an OS error code into a human readable string.
+  ##
+  ## The error code can be retrieved using the `osLastError proc`_.
+  ##
+  ## If conversion fails, or `errorCode` is `0` then `""` will be
+  ## returned.
+  ##
+  ## See also:
+  ## * `raiseOSError proc`_
+  ## * `osLastError proc`_
+  runnableExamples:
+    when defined(linux):
+      assert osErrorMsg(OSErrorCode(0)) == ""
+      assert osErrorMsg(OSErrorCode(1)) == "Operation not permitted"
+      assert osErrorMsg(OSErrorCode(2)) == "No such file or directory"
+
+  result = ""
+  when defined(nimscript):
+    discard
+  elif defined(windows):
+    if errorCode != OSErrorCode(0'i32):
+      var msgbuf: WideCString
+      if formatMessageW(0x00000100 or 0x00001000 or 0x00000200,
+                      nil, errorCode.int32, 0, addr(msgbuf), 0, nil) != 0'i32:
+        result = $msgbuf
+        if msgbuf != nil: localFree(cast[pointer](msgbuf))
+  else:
+    if errorCode != OSErrorCode(0'i32):
+      result = $c_strerror(errorCode.int32)
+
+proc newOSError*(
+  errorCode: OSErrorCode, additionalInfo = ""
+): owned(ref OSError) {.noinline.} =
+  ## Creates a new `OSError exception <system.html#OSError>`_.
+  ##
+  ## The `errorCode` will determine the
+  ## message, `osErrorMsg proc`_ will be used
+  ## to get this message.
+  ##
+  ## The error code can be retrieved using the `osLastError proc`_.
+  ##
+  ## If the error code is `0` or an error message could not be retrieved,
+  ## the message `unknown OS error` will be used.
+  ##
+  ## See also:
+  ## * `osErrorMsg proc`_
+  ## * `osLastError proc`_
+  result = (ref OSError)(errorCode: errorCode.int32, msg: osErrorMsg(errorCode))
+  if additionalInfo.len > 0:
+    if result.msg.len > 0 and result.msg[^1] != '\n': result.msg.add '\n'
+    result.msg.add "Additional info: "
+    result.msg.add additionalInfo
+      # don't add trailing `.` etc, which negatively impacts "jump to file" in IDEs.
+  if result.msg == "":
+    result.msg = "unknown OS error"
+
+proc raiseOSError*(errorCode: OSErrorCode, additionalInfo = "") {.noinline.} =
+  ## Raises an `OSError exception <system.html#OSError>`_.
+  ##
+  ## Read the description of the `newOSError proc`_ to learn
+  ## how the exception object is created.
+  raise newOSError(errorCode, additionalInfo)
+
+{.push stackTrace:off.}
+proc osLastError*(): OSErrorCode {.sideEffect.} =
+  ## Retrieves the last operating system error code.
+  ##
+  ## This procedure is useful in the event when an OS call fails. In that case
+  ## this procedure will return the error code describing the reason why the
+  ## OS call failed. The `OSErrorMsg` procedure can then be used to convert
+  ## this code into a string.
+  ##
+  ## .. warning:: The behaviour of this procedure varies between Windows and POSIX systems.
+  ##   On Windows some OS calls can reset the error code to `0` causing this
+  ##   procedure to return `0`. It is therefore advised to call this procedure
+  ##   immediately after an OS call fails. On POSIX systems this is not a problem.
+  ##
+  ## See also:
+  ## * `osErrorMsg proc`_
+  ## * `raiseOSError proc`_
+  when defined(nimscript):
+    discard
+  elif defined(windows):
+    result = cast[OSErrorCode](getLastError())
+  else:
+    result = OSErrorCode(errno)
+{.pop.}
diff --git a/lib/std/outparams.nim b/lib/std/outparams.nim
new file mode 100644
index 000000000..a471fbaa7
--- /dev/null
+++ b/lib/std/outparams.nim
@@ -0,0 +1,38 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## `outParamsAt` macro for easy writing code that works with both 2.0 and 1.x.
+
+import std/macros
+
+macro outParamsAt*(positions: static openArray[int]; n: untyped): untyped =
+  ## Use this macro to annotate `out` parameters in a portable way.
+  runnableExamples:
+    proc p(x: var int) {.outParamsAt: [1].} =
+      discard "x is really an 'out int' if the Nim compiler supports 'out' parameters"
+
+  result = n
+  when defined(nimHasOutParams):
+    var p = n.params
+    for po in positions:
+      p[po][^2].expectKind nnkVarTy
+      p[po][^2] = newTree(nnkOutTy, p[po][^2][0])
+
+when isMainModule:
+  {.experimental: "strictDefs".}
+
+  proc main(x: var int) {.outParamsAt: [1].} =
+    x = 3
+
+  proc us =
+    var x: int
+    main x
+    echo x
+
+  us()
diff --git a/lib/std/packedsets.nim b/lib/std/packedsets.nim
new file mode 100644
index 000000000..3320558f2
--- /dev/null
+++ b/lib/std/packedsets.nim
@@ -0,0 +1,601 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## The `packedsets` module implements an efficient `Ordinal` set implemented as a
+## `sparse bit set`:idx:.
+##
+## Supports any Ordinal type.
+##
+## See also
+## ========
+## * `sets module <sets.html>`_ for more general hash sets
+
+import std/private/since
+import std/hashes
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+type
+  BitScalar = uint
+
+const
+  InitIntSetSize = 8              # must be a power of two!
+  TrunkShift = 9
+  BitsPerTrunk = 1 shl TrunkShift # needs to be a power of 2 and
+                                  # divisible by 64
+  TrunkMask = BitsPerTrunk - 1
+  IntsPerTrunk = BitsPerTrunk div (sizeof(BitScalar) * 8)
+  IntShift = 5 + ord(sizeof(BitScalar) == 8) # 5 or 6, depending on int width
+  IntMask = 1 shl IntShift - 1
+
+type
+  Trunk {.acyclic.} = ref object
+    next: Trunk                                 # all nodes are connected with this pointer
+    key: int                                    # start address at bit 0
+    bits: array[0..IntsPerTrunk - 1, BitScalar] # a bit vector
+
+  TrunkSeq = seq[Trunk]
+
+  PackedSet*[A: Ordinal] = object
+    ## An efficient set of `Ordinal` types implemented as a sparse bit set.
+    elems: int           # only valid for small numbers
+    counter, max: int
+    head: Trunk
+    data: TrunkSeq
+    a: array[0..33, int] # profiling shows that 34 elements are enough
+
+proc mustRehash[T](t: T): bool {.inline.} =
+  let length = t.max + 1
+  assert length > t.counter
+  result = (length * 2 < t.counter * 3) or (length - t.counter < 4)
+
+proc nextTry(h, maxHash: Hash, perturb: var Hash): Hash {.inline.} =
+  const PERTURB_SHIFT = 5
+  var perturb2 = cast[uint](perturb) shr PERTURB_SHIFT
+  perturb = cast[Hash](perturb2)
+  result = ((5 * h) + 1 + perturb) and maxHash
+
+proc packedSetGet[A](t: PackedSet[A], key: int): Trunk =
+  var h = key and t.max
+  var perturb = key
+  while t.data[h] != nil:
+    if t.data[h].key == key:
+      return t.data[h]
+    h = nextTry(h, t.max, perturb)
+  result = nil
+
+proc intSetRawInsert[A](t: PackedSet[A], data: var TrunkSeq, desc: Trunk) =
+  var h = desc.key and t.max
+  var perturb = desc.key
+  while data[h] != nil:
+    assert data[h] != desc
+    h = nextTry(h, t.max, perturb)
+  assert data[h] == nil
+  data[h] = desc
+
+proc intSetEnlarge[A](t: var PackedSet[A]) =
+  var n: TrunkSeq
+  var oldMax = t.max
+  t.max = ((t.max + 1) * 2) - 1
+  newSeq(n, t.max + 1)
+  for i in countup(0, oldMax):
+    if t.data[i] != nil: intSetRawInsert(t, n, t.data[i])
+  swap(t.data, n)
+
+proc intSetPut[A](t: var PackedSet[A], key: int): Trunk =
+  var h = key and t.max
+  var perturb = key
+  while t.data[h] != nil:
+    if t.data[h].key == key:
+      return t.data[h]
+    h = nextTry(h, t.max, perturb)
+  if mustRehash(t): intSetEnlarge(t)
+  inc(t.counter)
+  h = key and t.max
+  perturb = key
+  while t.data[h] != nil: h = nextTry(h, t.max, perturb)
+  assert t.data[h] == nil
+  new(result)
+  result.next = t.head
+  result.key = key
+  t.head = result
+  t.data[h] = result
+
+proc bitincl[A](s: var PackedSet[A], key: int) {.inline.} =
+  var t = intSetPut(s, key shr TrunkShift)
+  var u = key and TrunkMask
+  t.bits[u shr IntShift] = t.bits[u shr IntShift] or
+      (BitScalar(1) shl (u and IntMask))
+
+proc exclImpl[A](s: var PackedSet[A], key: int) =
+  if s.elems <= s.a.len:
+    for i in 0..<s.elems:
+      if s.a[i] == key:
+        s.a[i] = s.a[s.elems - 1]
+        dec(s.elems)
+        return
+  else:
+    var t = packedSetGet(s, key shr TrunkShift)
+    if t != nil:
+      var u = key and TrunkMask
+      t.bits[u shr IntShift] = t.bits[u shr IntShift] and
+          not(BitScalar(1) shl (u and IntMask))
+
+template dollarImpl(): untyped =
+  result = "{"
+  for key in items(s):
+    if result.len > 1: result.add(", ")
+    result.add $key
+  result.add("}")
+
+iterator items*[A](s: PackedSet[A]): A {.inline.} =
+  ## Iterates over any included element of `s`.
+  if s.elems <= s.a.len:
+    for i in 0..<s.elems:
+      yield A(s.a[i])
+  else:
+    var r = s.head
+    while r != nil:
+      var i = 0
+      while i <= high(r.bits):
+        var w: uint = r.bits[i]
+        # taking a copy of r.bits[i] here is correct, because
+        # modifying operations are not allowed during traversation
+        var j = 0
+        while w != 0: # test all remaining bits for zero
+          if (w and 1) != 0: # the bit is set!
+            yield A((r.key shl TrunkShift) or (i shl IntShift +% j))
+          inc(j)
+          w = w shr 1
+        inc(i)
+      r = r.next
+
+proc initPackedSet*[A]: PackedSet[A] =
+  ## Returns an empty `PackedSet[A]`.
+  ## `A` must be `Ordinal`.
+  ##
+  ## **See also:**
+  ## * `toPackedSet proc <#toPackedSet,openArray[A]>`_
+  runnableExamples:
+    let a = initPackedSet[int]()
+    assert len(a) == 0
+
+    type Id = distinct int
+    var ids = initPackedSet[Id]()
+    ids.incl(3.Id)
+
+  result = PackedSet[A](
+    elems: 0,
+    counter: 0,
+    max: 0,
+    head: nil,
+    data: @[])
+  #  a: array[0..33, int] # profiling shows that 34 elements are enough
+
+proc contains*[A](s: PackedSet[A], key: A): bool =
+  ## Returns true if `key` is in `s`.
+  ##
+  ## This allows the usage of the `in` operator.
+  runnableExamples:
+    type ABCD = enum A, B, C, D
+
+    let a = [1, 3, 5].toPackedSet
+    assert a.contains(3)
+    assert 3 in a
+    assert not a.contains(8)
+    assert 8 notin a
+
+    let letters = [A, C].toPackedSet
+    assert A in letters
+    assert C in letters
+    assert B notin letters
+
+  if s.elems <= s.a.len:
+    result = false
+    for i in 0..<s.elems:
+      if s.a[i] == ord(key): return true
+  else:
+    var t = packedSetGet(s, ord(key) shr TrunkShift)
+    if t != nil:
+      var u = ord(key) and TrunkMask
+      result = (t.bits[u shr IntShift] and
+                (BitScalar(1) shl (u and IntMask))) != 0
+    else:
+      result = false
+
+proc incl*[A](s: var PackedSet[A], key: A) =
+  ## Includes an element `key` in `s`.
+  ##
+  ## This doesn't do anything if `key` is already in `s`.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,PackedSet[A],A>`_ for excluding an element
+  ## * `incl proc <#incl,PackedSet[A],PackedSet[A]>`_ for including a set
+  ## * `containsOrIncl proc <#containsOrIncl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = initPackedSet[int]()
+    a.incl(3)
+    a.incl(3)
+    assert len(a) == 1
+
+  if s.elems <= s.a.len:
+    for i in 0..<s.elems:
+      if s.a[i] == ord(key): return
+    if s.elems < s.a.len:
+      s.a[s.elems] = ord(key)
+      inc(s.elems)
+      return
+    newSeq(s.data, InitIntSetSize)
+    s.max = InitIntSetSize - 1
+    for i in 0..<s.elems:
+      bitincl(s, s.a[i])
+    s.elems = s.a.len + 1
+    # fall through:
+  bitincl(s, ord(key))
+
+proc incl*[A](s: var PackedSet[A], other: PackedSet[A]) =
+  ## Includes all elements from `other` into `s`.
+  ##
+  ## This is the in-place version of `s + other <#+,PackedSet[A],PackedSet[A]>`_.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,PackedSet[A],PackedSet[A]>`_ for excluding a set
+  ## * `incl proc <#incl,PackedSet[A],A>`_ for including an element
+  ## * `containsOrIncl proc <#containsOrIncl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = [1].toPackedSet
+    a.incl([5].toPackedSet)
+    assert len(a) == 2
+    assert 5 in a
+
+  for item in other.items: incl(s, item)
+
+proc toPackedSet*[A](x: openArray[A]): PackedSet[A] {.since: (1, 3).} =
+  ## Creates a new `PackedSet[A]` that contains the elements of `x`.
+  ##
+  ## Duplicates are removed.
+  ##
+  ## **See also:**
+  ## * `initPackedSet proc <#initPackedSet>`_
+  runnableExamples:
+    let a = [5, 6, 7, 8, 8].toPackedSet
+    assert len(a) == 4
+    assert $a == "{5, 6, 7, 8}"
+
+  result = initPackedSet[A]()
+  for item in x:
+    result.incl(item)
+
+proc containsOrIncl*[A](s: var PackedSet[A], key: A): bool =
+  ## Includes `key` in the set `s` and tells if `key` was already in `s`.
+  ##
+  ## The difference with regards to the `incl proc <#incl,PackedSet[A],A>`_ is
+  ## that this proc returns true if `s` already contained `key`. The
+  ## proc will return false if `key` was added as a new value to `s` during
+  ## this call.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,PackedSet[A],A>`_ for including an element
+  ## * `missingOrExcl proc <#missingOrExcl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = initPackedSet[int]()
+    assert a.containsOrIncl(3) == false
+    assert a.containsOrIncl(3) == true
+    assert a.containsOrIncl(4) == false
+
+  if s.elems <= s.a.len:
+    for i in 0..<s.elems:
+      if s.a[i] == ord(key):
+        return true
+    incl(s, key)
+    result = false
+  else:
+    var t = packedSetGet(s, ord(key) shr TrunkShift)
+    if t != nil:
+      var u = ord(key) and TrunkMask
+      result = (t.bits[u shr IntShift] and BitScalar(1) shl (u and IntMask)) != 0
+      if not result:
+        t.bits[u shr IntShift] = t.bits[u shr IntShift] or
+            (BitScalar(1) shl (u and IntMask))
+    else:
+      incl(s, key)
+      result = false
+
+proc excl*[A](s: var PackedSet[A], key: A) =
+  ## Excludes `key` from the set `s`.
+  ##
+  ## This doesn't do anything if `key` is not found in `s`.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,PackedSet[A],A>`_ for including an element
+  ## * `excl proc <#excl,PackedSet[A],PackedSet[A]>`_ for excluding a set
+  ## * `missingOrExcl proc <#missingOrExcl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = [3].toPackedSet
+    a.excl(3)
+    a.excl(3)
+    a.excl(99)
+    assert len(a) == 0
+
+  exclImpl[A](s, ord(key))
+
+proc excl*[A](s: var PackedSet[A], other: PackedSet[A]) =
+  ## Excludes all elements from `other` from `s`.
+  ##
+  ## This is the in-place version of `s - other <#-,PackedSet[A],PackedSet[A]>`_.
+  ##
+  ## **See also:**
+  ## * `incl proc <#incl,PackedSet[A],PackedSet[A]>`_ for including a set
+  ## * `excl proc <#excl,PackedSet[A],A>`_ for excluding an element
+  ## * `missingOrExcl proc <#missingOrExcl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = [1, 5].toPackedSet
+    a.excl([5].toPackedSet)
+    assert len(a) == 1
+    assert 5 notin a
+
+  for item in other.items:
+    excl(s, item)
+
+proc len*[A](s: PackedSet[A]): int {.inline.} =
+  ## Returns the number of elements in `s`.
+  runnableExamples:
+    let a = [1, 3, 5].toPackedSet
+    assert len(a) == 3
+
+  if s.elems < s.a.len:
+    result = s.elems
+  else:
+    result = 0
+    for _ in s.items:
+      # pending bug #11167; when fixed, check each explicit `items` to see if it can be removed
+      inc(result)
+
+proc missingOrExcl*[A](s: var PackedSet[A], key: A): bool =
+  ## Excludes `key` from the set `s` and tells if `key` was already missing from `s`.
+  ##
+  ## The difference with regards to the `excl proc <#excl,PackedSet[A],A>`_ is
+  ## that this proc returns true if `key` was missing from `s`.
+  ## The proc will return false if `key` was in `s` and it was removed
+  ## during this call.
+  ##
+  ## **See also:**
+  ## * `excl proc <#excl,PackedSet[A],A>`_ for excluding an element
+  ## * `excl proc <#excl,PackedSet[A],PackedSet[A]>`_ for excluding a set
+  ## * `containsOrIncl proc <#containsOrIncl,PackedSet[A],A>`_
+  runnableExamples:
+    var a = [5].toPackedSet
+    assert a.missingOrExcl(5) == false
+    assert a.missingOrExcl(5) == true
+
+  var count = s.len
+  exclImpl(s, ord(key))
+  result = count == s.len
+
+proc clear*[A](result: var PackedSet[A]) =
+  ## Clears the `PackedSet[A]` back to an empty state.
+  runnableExamples:
+    var a = [5, 7].toPackedSet
+    clear(a)
+    assert len(a) == 0
+
+  # setLen(result.data, InitIntSetSize)
+  # for i in 0..InitIntSetSize - 1: result.data[i] = nil
+  # result.max = InitIntSetSize - 1
+  result.data = @[]
+  result.max = 0
+  result.counter = 0
+  result.head = nil
+  result.elems = 0
+
+proc isNil*[A](x: PackedSet[A]): bool {.inline.} =
+  ## Returns true if `x` is empty, false otherwise.
+  runnableExamples:
+    var a = initPackedSet[int]()
+    assert a.isNil
+    a.incl(2)
+    assert not a.isNil
+    a.excl(2)
+    assert a.isNil
+
+  x.head.isNil and x.elems == 0
+
+proc `=copy`*[A](dest: var PackedSet[A], src: PackedSet[A]) =
+  ## Copies `src` to `dest`.
+  ## `dest` does not need to be initialized by the `initPackedSet proc <#initPackedSet>`_.
+  if src.elems <= src.a.len:
+    dest.data = @[]
+    dest.max = 0
+    dest.counter = src.counter
+    dest.head = nil
+    dest.elems = src.elems
+    dest.a = src.a
+  else:
+    dest.counter = src.counter
+    dest.max = src.max
+    dest.elems = src.elems
+    newSeq(dest.data, src.data.len)
+
+    var it = src.head
+    while it != nil:
+      var h = it.key and dest.max
+      var perturb = it.key
+      while dest.data[h] != nil: h = nextTry(h, dest.max, perturb)
+      assert dest.data[h] == nil
+      var n: Trunk
+      new(n)
+      n.next = dest.head
+      n.key = it.key
+      n.bits = it.bits
+      dest.head = n
+      dest.data[h] = n
+      it = it.next
+
+proc assign*[A](dest: var PackedSet[A], src: PackedSet[A]) {.inline, deprecated.} =
+  ## Copies `src` to `dest`.
+  ## `dest` does not need to be initialized by the `initPackedSet proc <#initPackedSet>`_.
+  runnableExamples:
+    var
+      a = initPackedSet[int]()
+      b = initPackedSet[int]()
+    b.incl(5)
+    b.incl(7)
+    a.assign(b)
+    assert len(a) == 2
+  `=copy`(dest, src)
+
+proc union*[A](s1, s2: PackedSet[A]): PackedSet[A] =
+  ## Returns the union of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 + s2 <#+,PackedSet[A],PackedSet[A]>`_.
+  runnableExamples:
+    let
+      a = [1, 2, 3].toPackedSet
+      b = [3, 4, 5].toPackedSet
+      c = union(a, b)
+    assert c.len == 5
+    assert c == [1, 2, 3, 4, 5].toPackedSet
+
+  result.assign(s1)
+  incl(result, s2)
+
+proc intersection*[A](s1, s2: PackedSet[A]): PackedSet[A] =
+  ## Returns the intersection of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 * s2 <#*,PackedSet[A],PackedSet[A]>`_.
+  runnableExamples:
+    let
+      a = [1, 2, 3].toPackedSet
+      b = [3, 4, 5].toPackedSet
+      c = intersection(a, b)
+    assert c.len == 1
+    assert c == [3].toPackedSet
+
+  result = initPackedSet[A]()
+  for item in s1.items:
+    if contains(s2, item):
+      incl(result, item)
+
+proc difference*[A](s1, s2: PackedSet[A]): PackedSet[A] =
+  ## Returns the difference of the sets `s1` and `s2`.
+  ##
+  ## The same as `s1 - s2 <#-,PackedSet[A],PackedSet[A]>`_.
+  runnableExamples:
+    let
+      a = [1, 2, 3].toPackedSet
+      b = [3, 4, 5].toPackedSet
+      c = difference(a, b)
+    assert c.len == 2
+    assert c == [1, 2].toPackedSet
+
+  result = initPackedSet[A]()
+  for item in s1.items:
+    if not contains(s2, item):
+      incl(result, item)
+
+proc symmetricDifference*[A](s1, s2: PackedSet[A]): PackedSet[A] =
+  ## Returns the symmetric difference of the sets `s1` and `s2`.
+  runnableExamples:
+    let
+      a = [1, 2, 3].toPackedSet
+      b = [3, 4, 5].toPackedSet
+      c = symmetricDifference(a, b)
+    assert c.len == 4
+    assert c == [1, 2, 4, 5].toPackedSet
+
+  result.assign(s1)
+  for item in s2.items:
+    if containsOrIncl(result, item):
+      excl(result, item)
+
+proc `+`*[A](s1, s2: PackedSet[A]): PackedSet[A] {.inline.} =
+  ## Alias for `union(s1, s2) <#union,PackedSet[A],PackedSet[A]>`_.
+  result = union(s1, s2)
+
+proc `*`*[A](s1, s2: PackedSet[A]): PackedSet[A] {.inline.} =
+  ## Alias for `intersection(s1, s2) <#intersection,PackedSet[A],PackedSet[A]>`_.
+  result = intersection(s1, s2)
+
+proc `-`*[A](s1, s2: PackedSet[A]): PackedSet[A] {.inline.} =
+  ## Alias for `difference(s1, s2) <#difference,PackedSet[A],PackedSet[A]>`_.
+  result = difference(s1, s2)
+
+proc disjoint*[A](s1, s2: PackedSet[A]): bool =
+  ## Returns true if the sets `s1` and `s2` have no items in common.
+  runnableExamples:
+    let
+      a = [1, 2].toPackedSet
+      b = [2, 3].toPackedSet
+      c = [3, 4].toPackedSet
+    assert disjoint(a, b) == false
+    assert disjoint(a, c) == true
+
+  for item in s1.items:
+    if contains(s2, item):
+      return false
+  return true
+
+proc card*[A](s: PackedSet[A]): int {.inline.} =
+  ## Alias for `len() <#len,PackedSet[A]>`_.
+  ##
+  ## Card stands for the [cardinality](http://en.wikipedia.org/wiki/Cardinality)
+  ## of a set.
+  result = s.len()
+
+proc `<=`*[A](s1, s2: PackedSet[A]): bool =
+  ## Returns true if `s1` is a subset of `s2`.
+  ##
+  ## A subset `s1` has all of its elements in `s2`, but `s2` doesn't necessarily
+  ## have more elements than `s1`. That is, `s1` can be equal to `s2`.
+  runnableExamples:
+    let
+      a = [1].toPackedSet
+      b = [1, 2].toPackedSet
+      c = [1, 3].toPackedSet
+    assert a <= b
+    assert b <= b
+    assert not (c <= b)
+
+  for item in s1.items:
+    if not s2.contains(item):
+      return false
+  return true
+
+proc `<`*[A](s1, s2: PackedSet[A]): bool =
+  ## Returns true if `s1` is a proper subset of `s2`.
+  ##
+  ## A strict or proper subset `s1` has all of its elements in `s2`, but `s2` has
+  ## more elements than `s1`.
+  runnableExamples:
+    let
+      a = [1].toPackedSet
+      b = [1, 2].toPackedSet
+      c = [1, 3].toPackedSet
+    assert a < b
+    assert not (b < b)
+    assert not (c < b)
+
+  return s1 <= s2 and not (s2 <= s1)
+
+proc `==`*[A](s1, s2: PackedSet[A]): bool =
+  ## Returns true if both `s1` and `s2` have the same elements and set size.
+  runnableExamples:
+    assert [1, 2].toPackedSet == [2, 1].toPackedSet
+    assert [1, 2].toPackedSet == [2, 1, 2].toPackedSet
+
+  return s1 <= s2 and s2 <= s1
+
+proc `$`*[A](s: PackedSet[A]): string =
+  ## Converts `s` to a string.
+  runnableExamples:
+    let a = [1, 2, 3].toPackedSet
+    assert $a == "{1, 2, 3}"
+
+  dollarImpl()
diff --git a/lib/std/paths.nim b/lib/std/paths.nim
new file mode 100644
index 000000000..664dedd31
--- /dev/null
+++ b/lib/std/paths.nim
@@ -0,0 +1,302 @@
+## This module implements path handling.
+##
+## **See also:**
+## * `files module <files.html>`_ for file access
+
+import std/private/osseps
+export osseps
+
+import std/envvars
+import std/private/osappdirs
+
+import std/[pathnorm, hashes, sugar, strutils]
+
+from std/private/ospaths2 import  joinPath, splitPath,
+                                  ReadDirEffect, WriteDirEffect,
+                                  isAbsolute, relativePath,
+                                  normalizePathEnd, isRelativeTo, parentDir,
+                                  tailDir, isRootDir, parentDirs, `/../`,
+                                  extractFilename, lastPathPart,
+                                  changeFileExt, addFileExt, cmpPaths, splitFile,
+                                  unixToNativePath, absolutePath, normalizeExe,
+                                  normalizePath
+export ReadDirEffect, WriteDirEffect
+
+type
+  Path* = distinct string
+
+func hash*(x: Path): Hash =
+  let x = x.string.dup(normalizePath)
+  if FileSystemCaseSensitive:
+    result = x.hash
+  else:
+    result = x.toLowerAscii.hash
+
+template `$`*(x: Path): string =
+  string(x)
+
+func `==`*(x, y: Path): bool {.inline.} =
+  ## Compares two paths.
+  ##
+  ## On a case-sensitive filesystem this is done
+  ## case-sensitively otherwise case-insensitively.
+  result = cmpPaths(x.string, y.string) == 0
+
+template endsWith(a: string, b: set[char]): bool =
+  a.len > 0 and a[^1] in b
+
+func add(x: var string, tail: string) =
+  var state = 0
+  let trailingSep = tail.endsWith({DirSep, AltSep}) or tail.len == 0 and x.endsWith({DirSep, AltSep})
+  normalizePathEnd(x, trailingSep=false)
+  addNormalizePath(tail, x, state, DirSep)
+  normalizePathEnd(x, trailingSep=trailingSep)
+
+func add*(x: var Path, y: Path) {.borrow.}
+
+func `/`*(head, tail: Path): Path {.inline.} =
+  ## Joins two directory names to one.
+  ##
+  ## returns normalized path concatenation of `head` and `tail`, preserving
+  ## whether or not `tail` has a trailing slash (or, if tail if empty, whether
+  ## head has one).
+  ##
+  ## See also:
+  ## * `splitPath proc`_
+  ## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
+  ## * `uri./ proc <uri.html#/,Uri,string>`_
+  Path(joinPath(head.string, tail.string))
+
+func splitPath*(path: Path): tuple[head, tail: Path] {.inline.} =
+  ## Splits a directory into `(head, tail)` tuple, so that
+  ## ``head / tail == path`` (except for edge cases like "/usr").
+  ##
+  ## See also:
+  ## * `add proc`_
+  ## * `/ proc`_
+  ## * `/../ proc`_
+  ## * `relativePath proc`_
+  let res = splitPath(path.string)
+  result = (Path(res.head), Path(res.tail))
+
+func splitFile*(path: Path): tuple[dir, name: Path, ext: string] {.inline.} =
+  ## Splits a filename into `(dir, name, extension)` tuple.
+  ##
+  ## `dir` does not end in DirSep unless it's `/`.
+  ## `extension` includes the leading dot.
+  ##
+  ## If `path` has no extension, `ext` is the empty string.
+  ## If `path` has no directory component, `dir` is the empty string.
+  ## If `path` has no filename component, `name` and `ext` are empty strings.
+  ##
+  ## See also:
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  let res = splitFile(path.string)
+  result = (Path(res.dir), Path(res.name), res.ext)
+
+func isAbsolute*(path: Path): bool {.inline, raises: [].} =
+  ## Checks whether a given `path` is absolute.
+  ##
+  ## On Windows, network paths are considered absolute too.
+  result = isAbsolute(path.string)
+
+proc relativePath*(path, base: Path, sep = DirSep): Path {.inline.} =
+  ## Converts `path` to a path relative to `base`.
+  ##
+  ## The `sep` (default: DirSep) is used for the path normalizations,
+  ## this can be useful to ensure the relative path only contains `'/'`
+  ## so that it can be used for URL constructions.
+  ##
+  ## On Windows, if a root of `path` and a root of `base` are different,
+  ## returns `path` as is because it is impossible to make a relative path.
+  ## That means an absolute path can be returned.
+  ##
+  ## See also:
+  ## * `splitPath proc`_
+  ## * `parentDir proc`_
+  ## * `tailDir proc`_
+  result = Path(relativePath(path.string, base.string, sep))
+
+proc isRelativeTo*(path: Path, base: Path): bool {.inline.} =
+  ## Returns true if `path` is relative to `base`.
+  result = isRelativeTo(path.string, base.string)
+
+
+func parentDir*(path: Path): Path {.inline.} =
+  ## Returns the parent directory of `path`.
+  ##
+  ## This is similar to ``splitPath(path).head`` when ``path`` doesn't end
+  ## in a dir separator, but also takes care of path normalizations.
+  ## The remainder can be obtained with `lastPathPart(path) proc`_.
+  ##
+  ## See also:
+  ## * `relativePath proc`_
+  ## * `splitPath proc`_
+  ## * `tailDir proc`_
+  ## * `parentDirs iterator`_
+  result = Path(parentDir(path.string))
+
+func tailDir*(path: Path): Path {.inline.} =
+  ## Returns the tail part of `path`.
+  ##
+  ## See also:
+  ## * `relativePath proc`_
+  ## * `splitPath proc`_
+  ## * `parentDir proc`_
+  result = Path(tailDir(path.string))
+
+func isRootDir*(path: Path): bool {.inline.} =
+  ## Checks whether a given `path` is a root directory.
+  result = isRootDir(path.string)
+
+iterator parentDirs*(path: Path, fromRoot=false, inclusive=true): Path =
+  ## Walks over all parent directories of a given `path`.
+  ##
+  ## If `fromRoot` is true (default: false), the traversal will start from
+  ## the file system root directory.
+  ## If `inclusive` is true (default), the original argument will be included
+  ## in the traversal.
+  ##
+  ## Relative paths won't be expanded by this iterator. Instead, it will traverse
+  ## only the directories appearing in the relative path.
+  ##
+  ## See also:
+  ## * `parentDir proc`_
+  ##
+  for p in parentDirs(path.string, fromRoot, inclusive):
+    yield Path(p)
+
+func `/../`*(head, tail: Path): Path {.inline.} =
+  ## The same as ``parentDir(head) / tail``, unless there is no parent
+  ## directory. Then ``head / tail`` is performed instead.
+  ##
+  ## See also:
+  ## * `/ proc`_
+  ## * `parentDir proc`_
+  Path(`/../`(head.string, tail.string))
+
+func extractFilename*(path: Path): Path {.inline.} =
+  ## Extracts the filename of a given `path`.
+  ##
+  ## This is the same as ``name & ext`` from `splitFile(path) proc`_.
+  ##
+  ## See also:
+  ## * `splitFile proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  result = Path(extractFilename(path.string))
+
+func lastPathPart*(path: Path): Path {.inline.} =
+  ## Like `extractFilename proc`_, but ignores
+  ## trailing dir separator; aka: `baseName`:idx: in some other languages.
+  ##
+  ## See also:
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  result = Path(lastPathPart(path.string))
+
+func changeFileExt*(filename: Path, ext: string): Path {.inline.} =
+  ## Changes the file extension to `ext`.
+  ##
+  ## If the `filename` has no extension, `ext` will be added.
+  ## If `ext` == "" then any extension is removed.
+  ##
+  ## `Ext` should be given without the leading `'.'`, because some
+  ## filesystems may use a different character. (Although I know
+  ## of none such beast.)
+  ##
+  ## See also:
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `addFileExt proc`_
+  result = Path(changeFileExt(filename.string, ext))
+
+func addFileExt*(filename: Path, ext: string): Path {.inline.} =
+  ## Adds the file extension `ext` to `filename`, unless
+  ## `filename` already has an extension.
+  ##
+  ## `Ext` should be given without the leading `'.'`, because some
+  ## filesystems may use a different character.
+  ## (Although I know of none such beast.)
+  ##
+  ## See also:
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  result = Path(addFileExt(filename.string, ext))
+
+func unixToNativePath*(path: Path, drive=Path("")): Path {.inline.} =
+  ## Converts an UNIX-like path to a native one.
+  ##
+  ## On an UNIX system this does nothing. Else it converts
+  ## `'/'`, `'.'`, `'..'` to the appropriate things.
+  ##
+  ## On systems with a concept of "drives", `drive` is used to determine
+  ## which drive label to use during absolute path conversion.
+  ## `drive` defaults to the drive of the current working directory, and is
+  ## ignored on systems that do not have a concept of "drives".
+  result = Path(unixToNativePath(path.string, drive.string))
+
+proc getCurrentDir*(): Path {.inline, tags: [].} =
+  ## Returns the `current working directory`:idx: i.e. where the built
+  ## binary is run.
+  ##
+  ## So the path returned by this proc is determined at run time.
+  ##
+  ## See also:
+  ## * `getHomeDir proc <appdirs.html#getHomeDir>`_
+  ## * `getConfigDir proc <appdirs.html#getConfigDir>`_
+  ## * `getTempDir proc <appdirs.html#getTempDir>`_
+  ## * `setCurrentDir proc <dirs.html#setCurrentDir>`_
+  ## * `currentSourcePath template <system.html#currentSourcePath.t>`_
+  ## * `getProjectPath proc <macros.html#getProjectPath>`_
+  result = Path(ospaths2.getCurrentDir())
+
+proc normalizeExe*(file: var Path) {.borrow.}
+
+proc normalizePath*(path: var Path) {.borrow.}
+
+proc normalizePathEnd*(path: var Path, trailingSep = false) {.borrow.}
+
+proc absolutePath*(path: Path, root = getCurrentDir()): Path =
+  ## Returns the absolute path of `path`, rooted at `root` (which must be absolute;
+  ## default: current directory).
+  ## If `path` is absolute, return it, ignoring `root`.
+  ##
+  ## See also:
+  ## * `normalizePath proc`_
+  result = Path(absolutePath(path.string, root.string))
+
+proc expandTildeImpl(path: string): string {.
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  if len(path) == 0 or path[0] != '~':
+    result = path
+  elif len(path) == 1:
+    result = getHomeDir()
+  elif (path[1] in {DirSep, AltSep}):
+    result = joinPath(getHomeDir(), path.substr(2))
+  else:
+    # TODO: handle `~bob` and `~bob/` which means home of bob
+    result = path
+
+proc expandTilde*(path: Path): Path {.inline,
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Expands ``~`` or a path starting with ``~/`` to a full path, replacing
+  ## ``~`` with `getHomeDir() <appdirs.html#getHomeDir>`_ (otherwise returns ``path`` unmodified).
+  ##
+  ## Windows: this is still supported despite the Windows platform not having this
+  ## convention; also, both ``~/`` and ``~\`` are handled.
+  runnableExamples:
+    import std/appdirs
+    assert expandTilde(Path("~") / Path("appname.cfg")) == getHomeDir() / Path("appname.cfg")
+    assert expandTilde(Path("~/foo/bar")) == getHomeDir() / Path("foo/bar")
+    assert expandTilde(Path("/foo/bar")) == Path("/foo/bar")
+  result = Path(expandTildeImpl(path.string))
diff --git a/lib/std/private/asciitables.nim b/lib/std/private/asciitables.nim
new file mode 100644
index 000000000..cbc595651
--- /dev/null
+++ b/lib/std/private/asciitables.nim
@@ -0,0 +1,83 @@
+#[
+move to std/asciitables.nim once stable, or to a fusion package
+once compiler can depend on fusion
+]#
+
+type Cell* = object
+  text*: string
+  width*, row*, col*, ncols*, nrows*: int
+
+iterator parseTableCells*(s: string, delim = '\t'): Cell =
+  ## Iterates over all cells in a `delim`-delimited `s`, after a 1st
+  ## pass that computes number of rows, columns, and width of each column.
+  var widths: seq[int]
+  var cell: Cell
+  template update() =
+    if widths.len<=cell.col:
+      widths.setLen cell.col+1
+      widths[cell.col] = cell.width
+    else:
+      widths[cell.col] = max(widths[cell.col], cell.width)
+    cell.width = 0
+
+  for a in s:
+    case a
+    of '\n':
+      update()
+      cell.col = 0
+      cell.row.inc
+    elif a == delim:
+      update()
+      cell.col.inc
+    else:
+      # todo: consider multi-width chars when porting to non-ascii implementation
+      cell.width.inc
+  if s.len > 0 and s[^1] != '\n':
+    update()
+
+  cell.ncols = widths.len
+  cell.nrows = cell.row + 1
+  cell.row = 0
+  cell.col = 0
+  cell.width = 0
+
+  template update2() =
+    cell.width = widths[cell.col]
+    yield cell
+    cell.text = ""
+    cell.width = 0
+    cell.col.inc
+
+  template finishRow() =
+    for col in cell.col..<cell.ncols:
+      cell.col = col
+      update2()
+    cell.col = 0
+
+  for a in s:
+    case a
+    of '\n':
+      finishRow()
+      cell.row.inc
+    elif a == delim:
+      update2()
+    else:
+      cell.width.inc
+      cell.text.add a
+
+  if s.len > 0 and s[^1] != '\n':
+    finishRow()
+
+proc alignTable*(s: string, delim = '\t', fill = ' ', sep = " "): string =
+  ## Formats a `delim`-delimited `s` representing a table; each cell is aligned
+  ## to a width that's computed for each column; consecutive columns are
+  ## delimited by `sep`, and alignment space is filled using `fill`.
+  ## More customized formatting can be done by calling `parseTableCells` directly.
+  for cell in parseTableCells(s, delim):
+    result.add cell.text
+    for i in cell.text.len..<cell.width:
+      result.add fill
+    if cell.col < cell.ncols-1:
+      result.add sep
+    if cell.col == cell.ncols-1 and cell.row < cell.nrows - 1:
+      result.add '\n'
diff --git a/lib/std/private/bitops_utils.nim b/lib/std/private/bitops_utils.nim
new file mode 100644
index 000000000..0b9484416
--- /dev/null
+++ b/lib/std/private/bitops_utils.nim
@@ -0,0 +1,22 @@
+template forwardImpl*(impl, arg) {.dirty.} =
+  when sizeof(x) <= 4:
+    when x is SomeSignedInt:
+      impl(cast[uint32](x.int32))
+    else:
+      impl(x.uint32)
+  else:
+    when x is SomeSignedInt:
+      impl(cast[uint64](x.int64))
+    else:
+      impl(x.uint64)
+
+# this could also be implemented via:
+# import std/typetraits
+# template castToUnsigned*(x: SomeInteger): auto = cast[toUnsigned(typeof(x))](x)
+
+template castToUnsigned*(x: int8): uint8 = cast[uint8](x)
+template castToUnsigned*(x: int16): uint16 = cast[uint16](x)
+template castToUnsigned*(x: int32): uint32 = cast[uint32](x)
+template castToUnsigned*(x: int64): uint64 = cast[uint64](x)
+template castToUnsigned*(x: int): uint = cast[uint](x)
+template castToUnsigned*[T: SomeUnsignedInt](x: T): T = x
diff --git a/lib/std/private/decode_helpers.nim b/lib/std/private/decode_helpers.nim
new file mode 100644
index 000000000..f11e3060a
--- /dev/null
+++ b/lib/std/private/decode_helpers.nim
@@ -0,0 +1,42 @@
+proc handleHexChar*(c: char, x: var int): bool {.inline.} =
+  ## Converts `%xx` hexadecimal to the ordinal number and adds the result to `x`.
+  ## Returns `true` if `c` is hexadecimal.
+  ##
+  ## When `c` is hexadecimal, the proc is equal to `x = x shl 4 + hex2Int(c)`.
+  runnableExamples:
+    var x = 0
+    assert handleHexChar('a', x)
+    assert x == 10
+
+    assert handleHexChar('B', x)
+    assert x == 171 # 10 shl 4 + 11
+
+    assert not handleHexChar('?', x)
+    assert x == 171 # unchanged
+  result = true
+  case c
+  of '0'..'9': x = (x shl 4) or (ord(c) - ord('0'))
+  of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10)
+  of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
+  else:
+    result = false
+
+proc handleHexChar*(c: char): int {.inline.} =
+  case c
+  of '0'..'9': result = (ord(c) - ord('0'))
+  of 'a'..'f': result = (ord(c) - ord('a') + 10)
+  of 'A'..'F': result = (ord(c) - ord('A') + 10)
+  else: discard
+
+proc decodePercent*(s: openArray[char], i: var int): char =
+  ## Converts `%xx` hexadecimal to the character with ordinal number `xx`.
+  ##
+  ## If `xx` is not a valid hexadecimal value, it is left intact: only the
+  ## leading `%` is returned as-is, and `xx` characters will be processed in the
+  ## next step (e.g. in `uri.decodeUrl`) as regular characters.
+  result = '%'
+  if i+2 < s.len:
+    var x = 0
+    if handleHexChar(s[i+1], x) and handleHexChar(s[i+2], x):
+      result = chr(x)
+      inc(i, 2)
diff --git a/lib/std/private/digitsutils.nim b/lib/std/private/digitsutils.nim
new file mode 100644
index 000000000..f2d0d25cb
--- /dev/null
+++ b/lib/std/private/digitsutils.nim
@@ -0,0 +1,116 @@
+const
+  trailingZeros100: array[100, int8] = [2'i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
+    0, 0, 0, 0, 0, 0]
+
+  digits100: array[200, char] = ['0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5',
+    '0', '6', '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
+    '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', '2', '2', '3',
+    '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '3', '0', '3', '1', '3', '2',
+    '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '4', '0', '4', '1',
+    '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0',
+    '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
+    '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8',
+    '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7',
+    '7', '8', '7', '9', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6',
+    '8', '7', '8', '8', '8', '9', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5',
+    '9', '6', '9', '7', '9', '8', '9', '9']
+
+# Inspired by https://engineering.fb.com/2013/03/15/developer-tools/three-optimization-tips-for-c
+# Generates:
+#   ```nim
+#   var res = ""
+#   for i in 0 .. 99:
+#     if i < 10:
+#       res.add "0" & $i
+#     else:
+#       res.add $i
+#   doAssert res == digits100
+#   ```
+
+proc utoa2Digits*(buf: var openArray[char]; pos: int; digits: uint32) {.inline.} =
+  buf[pos] = digits100[2 * digits]
+  buf[pos+1] = digits100[2 * digits + 1]
+  #copyMem(buf, unsafeAddr(digits100[2 * digits]), 2 * sizeof((char)))
+
+proc trailingZeros2Digits*(digits: uint32): int {.inline.} =
+  trailingZeros100[digits]
+
+when defined(js):
+  proc numToString(a: SomeInteger): cstring {.importjs: "((#) + \"\")".}
+
+func addChars[T](result: var string, x: T, start: int, n: int) {.inline.} =
+  let old = result.len
+  result.setLen old + n
+  template impl =
+    for i in 0..<n: result[old + i] = x[start + i]
+  when nimvm: impl
+  else:
+    when defined(js) or defined(nimscript): impl
+    else:
+      {.noSideEffect.}:
+        copyMem result[old].addr, x[start].unsafeAddr, n
+
+func addChars[T](result: var string, x: T) {.inline.} =
+  addChars(result, x, 0, x.len)
+
+func addIntImpl(result: var string, x: uint64) {.inline.} =
+  var tmp {.noinit.}: array[24, char]
+  var num = x
+  var next = tmp.len - 1
+  const nbatch = 100
+
+  while num >= nbatch:
+    let originNum = num
+    num = num div nbatch
+    let index = int16((originNum - num * nbatch) shl 1)
+    tmp[next] = digits100[index + 1]
+    tmp[next - 1] = digits100[index]
+    dec(next, 2)
+
+  # process last 1-2 digits
+  if num < 10:
+    tmp[next] = chr(ord('0') + num.uint8)
+  else:
+    let index = num * 2
+    tmp[next] = digits100[index + 1]
+    tmp[next - 1] = digits100[index]
+    dec next
+  addChars(result, tmp, next, tmp.len - next)
+
+when not defined(nimHasEnforceNoRaises):
+  {.pragma: enforceNoRaises.}
+
+func addInt*(result: var string, x: uint64) {.enforceNoRaises.} =
+  when nimvm: addIntImpl(result, x)
+  else:
+    when not defined(js): addIntImpl(result, x)
+    else:
+      addChars(result, numToString(x))
+
+proc addInt*(result: var string; x: int64) {.enforceNoRaises.} =
+  ## Converts integer to its string representation and appends it to `result`.
+  runnableExamples:
+    var s = "foo"
+    s.addInt(45)
+    assert s == "foo45"
+  template impl =
+    var num: uint64
+    if x < 0:
+      if x == low(int64):
+        num = cast[uint64](x)
+      else:
+        num = uint64(-x)
+      result.add '-'
+    else:
+      num = uint64(x)
+    addInt(result, num)
+  when nimvm: impl()
+  else:
+    when defined(js):
+      addChars(result, numToString(x))
+    else: impl()
+
+proc addInt*(result: var string; x: int) {.inline, enforceNoRaises.} =
+  addInt(result, int64(x))
diff --git a/lib/std/private/dragonbox.nim b/lib/std/private/dragonbox.nim
new file mode 100644
index 000000000..85ffea84a
--- /dev/null
+++ b/lib/std/private/dragonbox.nim
@@ -0,0 +1,1325 @@
+##  Copyright 2020 Junekey Jeon
+##  Copyright 2020 Alexander Bolz
+##
+##  Distributed under the Boost Software License, Version 1.0.
+##   (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
+
+##  char* output_end = Dtoa(buffer, value);
+##
+##  Converts the given double-precision number into decimal form and stores the result in the given
+##  buffer.
+##
+##  The buffer must be large enough, i.e. >= DtoaMinBufferLength.
+##  The output format is similar to printf("%g").
+##  The output is _not_ null-terminted.
+##
+##  The output is optimal, i.e. the output string
+##   1. rounds back to the input number when read in (using round-to-nearest-even)
+##   2. is as short as possible,
+##   3. is as close to the input number as possible.
+##
+##  Note:
+##  This function may temporarily write up to DtoaMinBufferLength characters into the buffer.
+
+
+import std/private/digitsutils
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+const
+  dtoaMinBufferLength*: cint = 64
+
+##  This file contains an implementation of Junekey Jeon's Dragonbox algorithm.
+##
+##  It is a simplified version of the reference implementation found here:
+##  https://github.com/jk-jeon/dragonbox
+##
+##  The reference implementation also works with single-precision floating-point numbers and
+##  has options to configure the rounding mode.
+
+template dragonbox_Assert*(x: untyped): untyped =
+  assert(x)
+
+# ==================================================================================================
+#
+# ==================================================================================================
+
+type
+  ValueType* = float
+  BitsType* = uint64
+
+type
+  Double* = object
+    bits*: BitsType
+
+const                         ##  = p   (includes the hidden bit)
+  significandSize*: int32 = 53
+
+const ##   static constexpr int32_t   MaxExponent     = 1024 - 1 - (SignificandSize - 1);
+     ##   static constexpr int32_t   MinExponent     = std::numeric_limits<value_type>::min_exponent - 1 - (SignificandSize - 1);
+  exponentBias*: int32 = 1024 - 1 + (significandSize - 1)
+
+const
+  maxIeeeExponent*: BitsType = BitsType(2 * 1024 - 1)
+
+const                         ##  = 2^(p-1)
+  hiddenBit*: BitsType = BitsType(1) shl (significandSize - 1)
+
+const                         ##  = 2^(p-1) - 1
+  significandMask*: BitsType = hiddenBit - 1
+
+const
+  exponentMask*: BitsType = maxIeeeExponent shl (significandSize - 1)
+
+const
+  signMask*: BitsType = not (not BitsType(0) shr 1)
+
+proc constructDouble*(bits: BitsType): Double  =
+  result.bits = bits
+
+proc constructDouble*(value: ValueType): Double  =
+  result.bits = cast[typeof(result.bits)](value)
+
+proc physicalSignificand*(this: Double): BitsType {.noSideEffect.} =
+  return this.bits and significandMask
+
+proc physicalExponent*(this: Double): BitsType {.noSideEffect.} =
+  return (this.bits and exponentMask) shr (significandSize - 1)
+
+proc isFinite*(this: Double): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) != exponentMask
+
+proc isInf*(this: Double): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) == exponentMask and
+      (this.bits and significandMask) == 0
+
+proc isNaN*(this: Double): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) == exponentMask and
+      (this.bits and significandMask) != 0
+
+proc isZero*(this: Double): bool {.noSideEffect.} =
+  return (this.bits and not signMask) == 0
+
+proc signBit*(this: Double): int {.noSideEffect.} =
+  return ord((this.bits and signMask) != 0)
+
+
+# ==================================================================================================
+#
+# ==================================================================================================
+##  namespace
+##  Returns floor(x / 2^n).
+##
+##  Technically, right-shift of negative integers is implementation defined...
+##  Should easily be optimized into SAR (or equivalent) instruction.
+
+proc floorDivPow2*(x: int32; n: int32): int32 {.inline.} =
+  return x shr n
+
+proc floorLog2Pow10*(e: int32): int32 {.inline.} =
+  dragonbox_Assert(e >= -1233)
+  dragonbox_Assert(e <= 1233)
+  return floorDivPow2(e * 1741647, 19)
+
+proc floorLog10Pow2*(e: int32): int32 {.inline.} =
+  dragonbox_Assert(e >= -1500)
+  dragonbox_Assert(e <= 1500)
+  return floorDivPow2(e * 1262611, 22)
+
+proc floorLog10ThreeQuartersPow2*(e: int32): int32 {.inline.} =
+  dragonbox_Assert(e >= -1500)
+  dragonbox_Assert(e <= 1500)
+  return floorDivPow2(e * 1262611 - 524031, 22)
+
+# ==================================================================================================
+#
+# ==================================================================================================
+
+type
+  uint64x2* {.bycopy.} = object
+    hi*: uint64
+    lo*: uint64
+
+
+proc computePow10*(k: int32): uint64x2 {.inline.} =
+  const
+    kMin: int32 = -292
+  const
+    kMax: int32 = 326
+  const
+    pow10: array[kMax - kMin + 1, uint64x2] = [
+      uint64x2(hi: 0xFF77B1FCBEBCDC4F'u, lo: 0x25E8E89C13BB0F7B'u),
+      uint64x2(hi: 0x9FAACF3DF73609B1'u, lo: 0x77B191618C54E9AD'u),
+      uint64x2(hi: 0xC795830D75038C1D'u, lo: 0xD59DF5B9EF6A2418'u),
+      uint64x2(hi: 0xF97AE3D0D2446F25'u, lo: 0x4B0573286B44AD1E'u),
+      uint64x2(hi: 0x9BECCE62836AC577'u, lo: 0x4EE367F9430AEC33'u),
+      uint64x2(hi: 0xC2E801FB244576D5'u, lo: 0x229C41F793CDA740'u),
+      uint64x2(hi: 0xF3A20279ED56D48A'u, lo: 0x6B43527578C11110'u),
+      uint64x2(hi: 0x9845418C345644D6'u, lo: 0x830A13896B78AAAA'u),
+      uint64x2(hi: 0xBE5691EF416BD60C'u, lo: 0x23CC986BC656D554'u),
+      uint64x2(hi: 0xEDEC366B11C6CB8F'u, lo: 0x2CBFBE86B7EC8AA9'u),
+      uint64x2(hi: 0x94B3A202EB1C3F39'u, lo: 0x7BF7D71432F3D6AA'u),
+      uint64x2(hi: 0xB9E08A83A5E34F07'u, lo: 0xDAF5CCD93FB0CC54'u),
+      uint64x2(hi: 0xE858AD248F5C22C9'u, lo: 0xD1B3400F8F9CFF69'u),
+      uint64x2(hi: 0x91376C36D99995BE'u, lo: 0x23100809B9C21FA2'u),
+      uint64x2(hi: 0xB58547448FFFFB2D'u, lo: 0xABD40A0C2832A78B'u),
+      uint64x2(hi: 0xE2E69915B3FFF9F9'u, lo: 0x16C90C8F323F516D'u),
+      uint64x2(hi: 0x8DD01FAD907FFC3B'u, lo: 0xAE3DA7D97F6792E4'u),
+      uint64x2(hi: 0xB1442798F49FFB4A'u, lo: 0x99CD11CFDF41779D'u),
+      uint64x2(hi: 0xDD95317F31C7FA1D'u, lo: 0x40405643D711D584'u),
+      uint64x2(hi: 0x8A7D3EEF7F1CFC52'u, lo: 0x482835EA666B2573'u),
+      uint64x2(hi: 0xAD1C8EAB5EE43B66'u, lo: 0xDA3243650005EED0'u),
+      uint64x2(hi: 0xD863B256369D4A40'u, lo: 0x90BED43E40076A83'u),
+      uint64x2(hi: 0x873E4F75E2224E68'u, lo: 0x5A7744A6E804A292'u),
+      uint64x2(hi: 0xA90DE3535AAAE202'u, lo: 0x711515D0A205CB37'u),
+      uint64x2(hi: 0xD3515C2831559A83'u, lo: 0x0D5A5B44CA873E04'u),
+      uint64x2(hi: 0x8412D9991ED58091'u, lo: 0xE858790AFE9486C3'u),
+      uint64x2(hi: 0xA5178FFF668AE0B6'u, lo: 0x626E974DBE39A873'u),
+      uint64x2(hi: 0xCE5D73FF402D98E3'u, lo: 0xFB0A3D212DC81290'u),
+      uint64x2(hi: 0x80FA687F881C7F8E'u, lo: 0x7CE66634BC9D0B9A'u),
+      uint64x2(hi: 0xA139029F6A239F72'u, lo: 0x1C1FFFC1EBC44E81'u),
+      uint64x2(hi: 0xC987434744AC874E'u, lo: 0xA327FFB266B56221'u),
+      uint64x2(hi: 0xFBE9141915D7A922'u, lo: 0x4BF1FF9F0062BAA9'u),
+      uint64x2(hi: 0x9D71AC8FADA6C9B5'u, lo: 0x6F773FC3603DB4AA'u),
+      uint64x2(hi: 0xC4CE17B399107C22'u, lo: 0xCB550FB4384D21D4'u),
+      uint64x2(hi: 0xF6019DA07F549B2B'u, lo: 0x7E2A53A146606A49'u),
+      uint64x2(hi: 0x99C102844F94E0FB'u, lo: 0x2EDA7444CBFC426E'u),
+      uint64x2(hi: 0xC0314325637A1939'u, lo: 0xFA911155FEFB5309'u),
+      uint64x2(hi: 0xF03D93EEBC589F88'u, lo: 0x793555AB7EBA27CB'u),
+      uint64x2(hi: 0x96267C7535B763B5'u, lo: 0x4BC1558B2F3458DF'u),
+      uint64x2(hi: 0xBBB01B9283253CA2'u, lo: 0x9EB1AAEDFB016F17'u),
+      uint64x2(hi: 0xEA9C227723EE8BCB'u, lo: 0x465E15A979C1CADD'u),
+      uint64x2(hi: 0x92A1958A7675175F'u, lo: 0x0BFACD89EC191ECA'u),
+      uint64x2(hi: 0xB749FAED14125D36'u, lo: 0xCEF980EC671F667C'u),
+      uint64x2(hi: 0xE51C79A85916F484'u, lo: 0x82B7E12780E7401B'u),
+      uint64x2(hi: 0x8F31CC0937AE58D2'u, lo: 0xD1B2ECB8B0908811'u),
+      uint64x2(hi: 0xB2FE3F0B8599EF07'u, lo: 0x861FA7E6DCB4AA16'u),
+      uint64x2(hi: 0xDFBDCECE67006AC9'u, lo: 0x67A791E093E1D49B'u),
+      uint64x2(hi: 0x8BD6A141006042BD'u, lo: 0xE0C8BB2C5C6D24E1'u),
+      uint64x2(hi: 0xAECC49914078536D'u, lo: 0x58FAE9F773886E19'u),
+      uint64x2(hi: 0xDA7F5BF590966848'u, lo: 0xAF39A475506A899F'u),
+      uint64x2(hi: 0x888F99797A5E012D'u, lo: 0x6D8406C952429604'u),
+      uint64x2(hi: 0xAAB37FD7D8F58178'u, lo: 0xC8E5087BA6D33B84'u),
+      uint64x2(hi: 0xD5605FCDCF32E1D6'u, lo: 0xFB1E4A9A90880A65'u),
+      uint64x2(hi: 0x855C3BE0A17FCD26'u, lo: 0x5CF2EEA09A550680'u),
+      uint64x2(hi: 0xA6B34AD8C9DFC06F'u, lo: 0xF42FAA48C0EA481F'u),
+      uint64x2(hi: 0xD0601D8EFC57B08B'u, lo: 0xF13B94DAF124DA27'u),
+      uint64x2(hi: 0x823C12795DB6CE57'u, lo: 0x76C53D08D6B70859'u),
+      uint64x2(hi: 0xA2CB1717B52481ED'u, lo: 0x54768C4B0C64CA6F'u),
+      uint64x2(hi: 0xCB7DDCDDA26DA268'u, lo: 0xA9942F5DCF7DFD0A'u),
+      uint64x2(hi: 0xFE5D54150B090B02'u, lo: 0xD3F93B35435D7C4D'u),
+      uint64x2(hi: 0x9EFA548D26E5A6E1'u, lo: 0xC47BC5014A1A6DB0'u),
+      uint64x2(hi: 0xC6B8E9B0709F109A'u, lo: 0x359AB6419CA1091C'u),
+      uint64x2(hi: 0xF867241C8CC6D4C0'u, lo: 0xC30163D203C94B63'u),
+      uint64x2(hi: 0x9B407691D7FC44F8'u, lo: 0x79E0DE63425DCF1E'u),
+      uint64x2(hi: 0xC21094364DFB5636'u, lo: 0x985915FC12F542E5'u),
+      uint64x2(hi: 0xF294B943E17A2BC4'u, lo: 0x3E6F5B7B17B2939E'u),
+      uint64x2(hi: 0x979CF3CA6CEC5B5A'u, lo: 0xA705992CEECF9C43'u),
+      uint64x2(hi: 0xBD8430BD08277231'u, lo: 0x50C6FF782A838354'u),
+      uint64x2(hi: 0xECE53CEC4A314EBD'u, lo: 0xA4F8BF5635246429'u),
+      uint64x2(hi: 0x940F4613AE5ED136'u, lo: 0x871B7795E136BE9A'u),
+      uint64x2(hi: 0xB913179899F68584'u, lo: 0x28E2557B59846E40'u),
+      uint64x2(hi: 0xE757DD7EC07426E5'u, lo: 0x331AEADA2FE589D0'u),
+      uint64x2(hi: 0x9096EA6F3848984F'u, lo: 0x3FF0D2C85DEF7622'u),
+      uint64x2(hi: 0xB4BCA50B065ABE63'u, lo: 0x0FED077A756B53AA'u),
+      uint64x2(hi: 0xE1EBCE4DC7F16DFB'u, lo: 0xD3E8495912C62895'u),
+      uint64x2(hi: 0x8D3360F09CF6E4BD'u, lo: 0x64712DD7ABBBD95D'u),
+      uint64x2(hi: 0xB080392CC4349DEC'u, lo: 0xBD8D794D96AACFB4'u),
+      uint64x2(hi: 0xDCA04777F541C567'u, lo: 0xECF0D7A0FC5583A1'u),
+      uint64x2(hi: 0x89E42CAAF9491B60'u, lo: 0xF41686C49DB57245'u),
+      uint64x2(hi: 0xAC5D37D5B79B6239'u, lo: 0x311C2875C522CED6'u),
+      uint64x2(hi: 0xD77485CB25823AC7'u, lo: 0x7D633293366B828C'u),
+      uint64x2(hi: 0x86A8D39EF77164BC'u, lo: 0xAE5DFF9C02033198'u),
+      uint64x2(hi: 0xA8530886B54DBDEB'u, lo: 0xD9F57F830283FDFD'u),
+      uint64x2(hi: 0xD267CAA862A12D66'u, lo: 0xD072DF63C324FD7C'u),
+      uint64x2(hi: 0x8380DEA93DA4BC60'u, lo: 0x4247CB9E59F71E6E'u),
+      uint64x2(hi: 0xA46116538D0DEB78'u, lo: 0x52D9BE85F074E609'u),
+      uint64x2(hi: 0xCD795BE870516656'u, lo: 0x67902E276C921F8C'u),
+      uint64x2(hi: 0x806BD9714632DFF6'u, lo: 0x00BA1CD8A3DB53B7'u),
+      uint64x2(hi: 0xA086CFCD97BF97F3'u, lo: 0x80E8A40ECCD228A5'u),
+      uint64x2(hi: 0xC8A883C0FDAF7DF0'u, lo: 0x6122CD128006B2CE'u),
+      uint64x2(hi: 0xFAD2A4B13D1B5D6C'u, lo: 0x796B805720085F82'u),
+      uint64x2(hi: 0x9CC3A6EEC6311A63'u, lo: 0xCBE3303674053BB1'u),
+      uint64x2(hi: 0xC3F490AA77BD60FC'u, lo: 0xBEDBFC4411068A9D'u),
+      uint64x2(hi: 0xF4F1B4D515ACB93B'u, lo: 0xEE92FB5515482D45'u),
+      uint64x2(hi: 0x991711052D8BF3C5'u, lo: 0x751BDD152D4D1C4B'u),
+      uint64x2(hi: 0xBF5CD54678EEF0B6'u, lo: 0xD262D45A78A0635E'u),
+      uint64x2(hi: 0xEF340A98172AACE4'u, lo: 0x86FB897116C87C35'u),
+      uint64x2(hi: 0x9580869F0E7AAC0E'u, lo: 0xD45D35E6AE3D4DA1'u),
+      uint64x2(hi: 0xBAE0A846D2195712'u, lo: 0x8974836059CCA10A'u),
+      uint64x2(hi: 0xE998D258869FACD7'u, lo: 0x2BD1A438703FC94C'u),
+      uint64x2(hi: 0x91FF83775423CC06'u, lo: 0x7B6306A34627DDD0'u),
+      uint64x2(hi: 0xB67F6455292CBF08'u, lo: 0x1A3BC84C17B1D543'u),
+      uint64x2(hi: 0xE41F3D6A7377EECA'u, lo: 0x20CABA5F1D9E4A94'u),
+      uint64x2(hi: 0x8E938662882AF53E'u, lo: 0x547EB47B7282EE9D'u),
+      uint64x2(hi: 0xB23867FB2A35B28D'u, lo: 0xE99E619A4F23AA44'u),
+      uint64x2(hi: 0xDEC681F9F4C31F31'u, lo: 0x6405FA00E2EC94D5'u),
+      uint64x2(hi: 0x8B3C113C38F9F37E'u, lo: 0xDE83BC408DD3DD05'u),
+      uint64x2(hi: 0xAE0B158B4738705E'u, lo: 0x9624AB50B148D446'u),
+      uint64x2(hi: 0xD98DDAEE19068C76'u, lo: 0x3BADD624DD9B0958'u),
+      uint64x2(hi: 0x87F8A8D4CFA417C9'u, lo: 0xE54CA5D70A80E5D7'u),
+      uint64x2(hi: 0xA9F6D30A038D1DBC'u, lo: 0x5E9FCF4CCD211F4D'u),
+      uint64x2(hi: 0xD47487CC8470652B'u, lo: 0x7647C32000696720'u),
+      uint64x2(hi: 0x84C8D4DFD2C63F3B'u, lo: 0x29ECD9F40041E074'u),
+      uint64x2(hi: 0xA5FB0A17C777CF09'u, lo: 0xF468107100525891'u),
+      uint64x2(hi: 0xCF79CC9DB955C2CC'u, lo: 0x7182148D4066EEB5'u),
+      uint64x2(hi: 0x81AC1FE293D599BF'u, lo: 0xC6F14CD848405531'u),
+      uint64x2(hi: 0xA21727DB38CB002F'u, lo: 0xB8ADA00E5A506A7D'u),
+      uint64x2(hi: 0xCA9CF1D206FDC03B'u, lo: 0xA6D90811F0E4851D'u),
+      uint64x2(hi: 0xFD442E4688BD304A'u, lo: 0x908F4A166D1DA664'u),
+      uint64x2(hi: 0x9E4A9CEC15763E2E'u, lo: 0x9A598E4E043287FF'u),
+      uint64x2(hi: 0xC5DD44271AD3CDBA'u, lo: 0x40EFF1E1853F29FE'u),
+      uint64x2(hi: 0xF7549530E188C128'u, lo: 0xD12BEE59E68EF47D'u),
+      uint64x2(hi: 0x9A94DD3E8CF578B9'u, lo: 0x82BB74F8301958CF'u),
+      uint64x2(hi: 0xC13A148E3032D6E7'u, lo: 0xE36A52363C1FAF02'u),
+      uint64x2(hi: 0xF18899B1BC3F8CA1'u, lo: 0xDC44E6C3CB279AC2'u),
+      uint64x2(hi: 0x96F5600F15A7B7E5'u, lo: 0x29AB103A5EF8C0BA'u),
+      uint64x2(hi: 0xBCB2B812DB11A5DE'u, lo: 0x7415D448F6B6F0E8'u),
+      uint64x2(hi: 0xEBDF661791D60F56'u, lo: 0x111B495B3464AD22'u),
+      uint64x2(hi: 0x936B9FCEBB25C995'u, lo: 0xCAB10DD900BEEC35'u),
+      uint64x2(hi: 0xB84687C269EF3BFB'u, lo: 0x3D5D514F40EEA743'u),
+      uint64x2(hi: 0xE65829B3046B0AFA'u, lo: 0x0CB4A5A3112A5113'u),
+      uint64x2(hi: 0x8FF71A0FE2C2E6DC'u, lo: 0x47F0E785EABA72AC'u),
+      uint64x2(hi: 0xB3F4E093DB73A093'u, lo: 0x59ED216765690F57'u),
+      uint64x2(hi: 0xE0F218B8D25088B8'u, lo: 0x306869C13EC3532D'u),
+      uint64x2(hi: 0x8C974F7383725573'u, lo: 0x1E414218C73A13FC'u),
+      uint64x2(hi: 0xAFBD2350644EEACF'u, lo: 0xE5D1929EF90898FB'u),
+      uint64x2(hi: 0xDBAC6C247D62A583'u, lo: 0xDF45F746B74ABF3A'u),
+      uint64x2(hi: 0x894BC396CE5DA772'u, lo: 0x6B8BBA8C328EB784'u),
+      uint64x2(hi: 0xAB9EB47C81F5114F'u, lo: 0x066EA92F3F326565'u),
+      uint64x2(hi: 0xD686619BA27255A2'u, lo: 0xC80A537B0EFEFEBE'u),
+      uint64x2(hi: 0x8613FD0145877585'u, lo: 0xBD06742CE95F5F37'u),
+      uint64x2(hi: 0xA798FC4196E952E7'u, lo: 0x2C48113823B73705'u),
+      uint64x2(hi: 0xD17F3B51FCA3A7A0'u, lo: 0xF75A15862CA504C6'u),
+      uint64x2(hi: 0x82EF85133DE648C4'u, lo: 0x9A984D73DBE722FC'u),
+      uint64x2(hi: 0xA3AB66580D5FDAF5'u, lo: 0xC13E60D0D2E0EBBB'u),
+      uint64x2(hi: 0xCC963FEE10B7D1B3'u, lo: 0x318DF905079926A9'u),
+      uint64x2(hi: 0xFFBBCFE994E5C61F'u, lo: 0xFDF17746497F7053'u),
+      uint64x2(hi: 0x9FD561F1FD0F9BD3'u, lo: 0xFEB6EA8BEDEFA634'u),
+      uint64x2(hi: 0xC7CABA6E7C5382C8'u, lo: 0xFE64A52EE96B8FC1'u),
+      uint64x2(hi: 0xF9BD690A1B68637B'u, lo: 0x3DFDCE7AA3C673B1'u),
+      uint64x2(hi: 0x9C1661A651213E2D'u, lo: 0x06BEA10CA65C084F'u),
+      uint64x2(hi: 0xC31BFA0FE5698DB8'u, lo: 0x486E494FCFF30A63'u),
+      uint64x2(hi: 0xF3E2F893DEC3F126'u, lo: 0x5A89DBA3C3EFCCFB'u),
+      uint64x2(hi: 0x986DDB5C6B3A76B7'u, lo: 0xF89629465A75E01D'u),
+      uint64x2(hi: 0xBE89523386091465'u, lo: 0xF6BBB397F1135824'u),
+      uint64x2(hi: 0xEE2BA6C0678B597F'u, lo: 0x746AA07DED582E2D'u),
+      uint64x2(hi: 0x94DB483840B717EF'u, lo: 0xA8C2A44EB4571CDD'u),
+      uint64x2(hi: 0xBA121A4650E4DDEB'u, lo: 0x92F34D62616CE414'u),
+      uint64x2(hi: 0xE896A0D7E51E1566'u, lo: 0x77B020BAF9C81D18'u),
+      uint64x2(hi: 0x915E2486EF32CD60'u, lo: 0x0ACE1474DC1D122F'u),
+      uint64x2(hi: 0xB5B5ADA8AAFF80B8'u, lo: 0x0D819992132456BB'u),
+      uint64x2(hi: 0xE3231912D5BF60E6'u, lo: 0x10E1FFF697ED6C6A'u),
+      uint64x2(hi: 0x8DF5EFABC5979C8F'u, lo: 0xCA8D3FFA1EF463C2'u),
+      uint64x2(hi: 0xB1736B96B6FD83B3'u, lo: 0xBD308FF8A6B17CB3'u),
+      uint64x2(hi: 0xDDD0467C64BCE4A0'u, lo: 0xAC7CB3F6D05DDBDF'u),
+      uint64x2(hi: 0x8AA22C0DBEF60EE4'u, lo: 0x6BCDF07A423AA96C'u),
+      uint64x2(hi: 0xAD4AB7112EB3929D'u, lo: 0x86C16C98D2C953C7'u),
+      uint64x2(hi: 0xD89D64D57A607744'u, lo: 0xE871C7BF077BA8B8'u),
+      uint64x2(hi: 0x87625F056C7C4A8B'u, lo: 0x11471CD764AD4973'u),
+      uint64x2(hi: 0xA93AF6C6C79B5D2D'u, lo: 0xD598E40D3DD89BD0'u),
+      uint64x2(hi: 0xD389B47879823479'u, lo: 0x4AFF1D108D4EC2C4'u),
+      uint64x2(hi: 0x843610CB4BF160CB'u, lo: 0xCEDF722A585139BB'u),
+      uint64x2(hi: 0xA54394FE1EEDB8FE'u, lo: 0xC2974EB4EE658829'u),
+      uint64x2(hi: 0xCE947A3DA6A9273E'u, lo: 0x733D226229FEEA33'u),
+      uint64x2(hi: 0x811CCC668829B887'u, lo: 0x0806357D5A3F5260'u),
+      uint64x2(hi: 0xA163FF802A3426A8'u, lo: 0xCA07C2DCB0CF26F8'u),
+      uint64x2(hi: 0xC9BCFF6034C13052'u, lo: 0xFC89B393DD02F0B6'u),
+      uint64x2(hi: 0xFC2C3F3841F17C67'u, lo: 0xBBAC2078D443ACE3'u),
+      uint64x2(hi: 0x9D9BA7832936EDC0'u, lo: 0xD54B944B84AA4C0E'u),
+      uint64x2(hi: 0xC5029163F384A931'u, lo: 0x0A9E795E65D4DF12'u),
+      uint64x2(hi: 0xF64335BCF065D37D'u, lo: 0x4D4617B5FF4A16D6'u),
+      uint64x2(hi: 0x99EA0196163FA42E'u, lo: 0x504BCED1BF8E4E46'u),
+      uint64x2(hi: 0xC06481FB9BCF8D39'u, lo: 0xE45EC2862F71E1D7'u),
+      uint64x2(hi: 0xF07DA27A82C37088'u, lo: 0x5D767327BB4E5A4D'u),
+      uint64x2(hi: 0x964E858C91BA2655'u, lo: 0x3A6A07F8D510F870'u),
+      uint64x2(hi: 0xBBE226EFB628AFEA'u, lo: 0x890489F70A55368C'u),
+      uint64x2(hi: 0xEADAB0ABA3B2DBE5'u, lo: 0x2B45AC74CCEA842F'u),
+      uint64x2(hi: 0x92C8AE6B464FC96F'u, lo: 0x3B0B8BC90012929E'u),
+      uint64x2(hi: 0xB77ADA0617E3BBCB'u, lo: 0x09CE6EBB40173745'u),
+      uint64x2(hi: 0xE55990879DDCAABD'u, lo: 0xCC420A6A101D0516'u),
+      uint64x2(hi: 0x8F57FA54C2A9EAB6'u, lo: 0x9FA946824A12232E'u),
+      uint64x2(hi: 0xB32DF8E9F3546564'u, lo: 0x47939822DC96ABFA'u),
+      uint64x2(hi: 0xDFF9772470297EBD'u, lo: 0x59787E2B93BC56F8'u),
+      uint64x2(hi: 0x8BFBEA76C619EF36'u, lo: 0x57EB4EDB3C55B65B'u),
+      uint64x2(hi: 0xAEFAE51477A06B03'u, lo: 0xEDE622920B6B23F2'u),
+      uint64x2(hi: 0xDAB99E59958885C4'u, lo: 0xE95FAB368E45ECEE'u),
+      uint64x2(hi: 0x88B402F7FD75539B'u, lo: 0x11DBCB0218EBB415'u),
+      uint64x2(hi: 0xAAE103B5FCD2A881'u, lo: 0xD652BDC29F26A11A'u),
+      uint64x2(hi: 0xD59944A37C0752A2'u, lo: 0x4BE76D3346F04960'u),
+      uint64x2(hi: 0x857FCAE62D8493A5'u, lo: 0x6F70A4400C562DDC'u),
+      uint64x2(hi: 0xA6DFBD9FB8E5B88E'u, lo: 0xCB4CCD500F6BB953'u),
+      uint64x2(hi: 0xD097AD07A71F26B2'u, lo: 0x7E2000A41346A7A8'u),
+      uint64x2(hi: 0x825ECC24C873782F'u, lo: 0x8ED400668C0C28C9'u),
+      uint64x2(hi: 0xA2F67F2DFA90563B'u, lo: 0x728900802F0F32FB'u),
+      uint64x2(hi: 0xCBB41EF979346BCA'u, lo: 0x4F2B40A03AD2FFBA'u),
+      uint64x2(hi: 0xFEA126B7D78186BC'u, lo: 0xE2F610C84987BFA9'u),
+      uint64x2(hi: 0x9F24B832E6B0F436'u, lo: 0x0DD9CA7D2DF4D7CA'u),
+      uint64x2(hi: 0xC6EDE63FA05D3143'u, lo: 0x91503D1C79720DBC'u),
+      uint64x2(hi: 0xF8A95FCF88747D94'u, lo: 0x75A44C6397CE912B'u),
+      uint64x2(hi: 0x9B69DBE1B548CE7C'u, lo: 0xC986AFBE3EE11ABB'u),
+      uint64x2(hi: 0xC24452DA229B021B'u, lo: 0xFBE85BADCE996169'u),
+      uint64x2(hi: 0xF2D56790AB41C2A2'u, lo: 0xFAE27299423FB9C4'u),
+      uint64x2(hi: 0x97C560BA6B0919A5'u, lo: 0xDCCD879FC967D41B'u),
+      uint64x2(hi: 0xBDB6B8E905CB600F'u, lo: 0x5400E987BBC1C921'u),
+      uint64x2(hi: 0xED246723473E3813'u, lo: 0x290123E9AAB23B69'u),
+      uint64x2(hi: 0x9436C0760C86E30B'u, lo: 0xF9A0B6720AAF6522'u),
+      uint64x2(hi: 0xB94470938FA89BCE'u, lo: 0xF808E40E8D5B3E6A'u),
+      uint64x2(hi: 0xE7958CB87392C2C2'u, lo: 0xB60B1D1230B20E05'u),
+      uint64x2(hi: 0x90BD77F3483BB9B9'u, lo: 0xB1C6F22B5E6F48C3'u),
+      uint64x2(hi: 0xB4ECD5F01A4AA828'u, lo: 0x1E38AEB6360B1AF4'u),
+      uint64x2(hi: 0xE2280B6C20DD5232'u, lo: 0x25C6DA63C38DE1B1'u),
+      uint64x2(hi: 0x8D590723948A535F'u, lo: 0x579C487E5A38AD0F'u),
+      uint64x2(hi: 0xB0AF48EC79ACE837'u, lo: 0x2D835A9DF0C6D852'u),
+      uint64x2(hi: 0xDCDB1B2798182244'u, lo: 0xF8E431456CF88E66'u),
+      uint64x2(hi: 0x8A08F0F8BF0F156B'u, lo: 0x1B8E9ECB641B5900'u),
+      uint64x2(hi: 0xAC8B2D36EED2DAC5'u, lo: 0xE272467E3D222F40'u),
+      uint64x2(hi: 0xD7ADF884AA879177'u, lo: 0x5B0ED81DCC6ABB10'u),
+      uint64x2(hi: 0x86CCBB52EA94BAEA'u, lo: 0x98E947129FC2B4EA'u),
+      uint64x2(hi: 0xA87FEA27A539E9A5'u, lo: 0x3F2398D747B36225'u),
+      uint64x2(hi: 0xD29FE4B18E88640E'u, lo: 0x8EEC7F0D19A03AAE'u),
+      uint64x2(hi: 0x83A3EEEEF9153E89'u, lo: 0x1953CF68300424AD'u),
+      uint64x2(hi: 0xA48CEAAAB75A8E2B'u, lo: 0x5FA8C3423C052DD8'u),
+      uint64x2(hi: 0xCDB02555653131B6'u, lo: 0x3792F412CB06794E'u),
+      uint64x2(hi: 0x808E17555F3EBF11'u, lo: 0xE2BBD88BBEE40BD1'u),
+      uint64x2(hi: 0xA0B19D2AB70E6ED6'u, lo: 0x5B6ACEAEAE9D0EC5'u),
+      uint64x2(hi: 0xC8DE047564D20A8B'u, lo: 0xF245825A5A445276'u),
+      uint64x2(hi: 0xFB158592BE068D2E'u, lo: 0xEED6E2F0F0D56713'u),
+      uint64x2(hi: 0x9CED737BB6C4183D'u, lo: 0x55464DD69685606C'u),
+      uint64x2(hi: 0xC428D05AA4751E4C'u, lo: 0xAA97E14C3C26B887'u),
+      uint64x2(hi: 0xF53304714D9265DF'u, lo: 0xD53DD99F4B3066A9'u),
+      uint64x2(hi: 0x993FE2C6D07B7FAB'u, lo: 0xE546A8038EFE402A'u),
+      uint64x2(hi: 0xBF8FDB78849A5F96'u, lo: 0xDE98520472BDD034'u),
+      uint64x2(hi: 0xEF73D256A5C0F77C'u, lo: 0x963E66858F6D4441'u),
+      uint64x2(hi: 0x95A8637627989AAD'u, lo: 0xDDE7001379A44AA9'u),
+      uint64x2(hi: 0xBB127C53B17EC159'u, lo: 0x5560C018580D5D53'u),
+      uint64x2(hi: 0xE9D71B689DDE71AF'u, lo: 0xAAB8F01E6E10B4A7'u),
+      uint64x2(hi: 0x9226712162AB070D'u, lo: 0xCAB3961304CA70E9'u),
+      uint64x2(hi: 0xB6B00D69BB55C8D1'u, lo: 0x3D607B97C5FD0D23'u),
+      uint64x2(hi: 0xE45C10C42A2B3B05'u, lo: 0x8CB89A7DB77C506B'u),
+      uint64x2(hi: 0x8EB98A7A9A5B04E3'u, lo: 0x77F3608E92ADB243'u),
+      uint64x2(hi: 0xB267ED1940F1C61C'u, lo: 0x55F038B237591ED4'u),
+      uint64x2(hi: 0xDF01E85F912E37A3'u, lo: 0x6B6C46DEC52F6689'u),
+      uint64x2(hi: 0x8B61313BBABCE2C6'u, lo: 0x2323AC4B3B3DA016'u),
+      uint64x2(hi: 0xAE397D8AA96C1B77'u, lo: 0xABEC975E0A0D081B'u),
+      uint64x2(hi: 0xD9C7DCED53C72255'u, lo: 0x96E7BD358C904A22'u),
+      uint64x2(hi: 0x881CEA14545C7575'u, lo: 0x7E50D64177DA2E55'u),
+      uint64x2(hi: 0xAA242499697392D2'u, lo: 0xDDE50BD1D5D0B9EA'u),
+      uint64x2(hi: 0xD4AD2DBFC3D07787'u, lo: 0x955E4EC64B44E865'u),
+      uint64x2(hi: 0x84EC3C97DA624AB4'u, lo: 0xBD5AF13BEF0B113F'u),
+      uint64x2(hi: 0xA6274BBDD0FADD61'u, lo: 0xECB1AD8AEACDD58F'u),
+      uint64x2(hi: 0xCFB11EAD453994BA'u, lo: 0x67DE18EDA5814AF3'u),
+      uint64x2(hi: 0x81CEB32C4B43FCF4'u, lo: 0x80EACF948770CED8'u),
+      uint64x2(hi: 0xA2425FF75E14FC31'u, lo: 0xA1258379A94D028E'u),
+      uint64x2(hi: 0xCAD2F7F5359A3B3E'u, lo: 0x096EE45813A04331'u),
+      uint64x2(hi: 0xFD87B5F28300CA0D'u, lo: 0x8BCA9D6E188853FD'u),
+      uint64x2(hi: 0x9E74D1B791E07E48'u, lo: 0x775EA264CF55347E'u),
+      uint64x2(hi: 0xC612062576589DDA'u, lo: 0x95364AFE032A819E'u),
+      uint64x2(hi: 0xF79687AED3EEC551'u, lo: 0x3A83DDBD83F52205'u),
+      uint64x2(hi: 0x9ABE14CD44753B52'u, lo: 0xC4926A9672793543'u),
+      uint64x2(hi: 0xC16D9A0095928A27'u, lo: 0x75B7053C0F178294'u),
+      uint64x2(hi: 0xF1C90080BAF72CB1'u, lo: 0x5324C68B12DD6339'u),
+      uint64x2(hi: 0x971DA05074DA7BEE'u, lo: 0xD3F6FC16EBCA5E04'u),
+      uint64x2(hi: 0xBCE5086492111AEA'u, lo: 0x88F4BB1CA6BCF585'u),
+      uint64x2(hi: 0xEC1E4A7DB69561A5'u, lo: 0x2B31E9E3D06C32E6'u),
+      uint64x2(hi: 0x9392EE8E921D5D07'u, lo: 0x3AFF322E62439FD0'u),
+      uint64x2(hi: 0xB877AA3236A4B449'u, lo: 0x09BEFEB9FAD487C3'u),
+      uint64x2(hi: 0xE69594BEC44DE15B'u, lo: 0x4C2EBE687989A9B4'u),
+      uint64x2(hi: 0x901D7CF73AB0ACD9'u, lo: 0x0F9D37014BF60A11'u),
+      uint64x2(hi: 0xB424DC35095CD80F'u, lo: 0x538484C19EF38C95'u),
+      uint64x2(hi: 0xE12E13424BB40E13'u, lo: 0x2865A5F206B06FBA'u),
+      uint64x2(hi: 0x8CBCCC096F5088CB'u, lo: 0xF93F87B7442E45D4'u),
+      uint64x2(hi: 0xAFEBFF0BCB24AAFE'u, lo: 0xF78F69A51539D749'u),
+      uint64x2(hi: 0xDBE6FECEBDEDD5BE'u, lo: 0xB573440E5A884D1C'u),
+      uint64x2(hi: 0x89705F4136B4A597'u, lo: 0x31680A88F8953031'u),
+      uint64x2(hi: 0xABCC77118461CEFC'u, lo: 0xFDC20D2B36BA7C3E'u),
+      uint64x2(hi: 0xD6BF94D5E57A42BC'u, lo: 0x3D32907604691B4D'u),
+      uint64x2(hi: 0x8637BD05AF6C69B5'u, lo: 0xA63F9A49C2C1B110'u),
+      uint64x2(hi: 0xA7C5AC471B478423'u, lo: 0x0FCF80DC33721D54'u),
+      uint64x2(hi: 0xD1B71758E219652B'u, lo: 0xD3C36113404EA4A9'u),
+      uint64x2(hi: 0x83126E978D4FDF3B'u, lo: 0x645A1CAC083126EA'u),
+      uint64x2(hi: 0xA3D70A3D70A3D70A'u, lo: 0x3D70A3D70A3D70A4'u),
+      uint64x2(hi: 0xCCCCCCCCCCCCCCCC'u, lo: 0xCCCCCCCCCCCCCCCD'u),
+      uint64x2(hi: 0x8000000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xA000000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xC800000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xFA00000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x9C40000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xC350000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xF424000000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x9896800000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xBEBC200000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xEE6B280000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x9502F90000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xBA43B74000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xE8D4A51000000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x9184E72A00000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xB5E620F480000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xE35FA931A0000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x8E1BC9BF04000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xB1A2BC2EC5000000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xDE0B6B3A76400000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x8AC7230489E80000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xAD78EBC5AC620000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xD8D726B7177A8000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x878678326EAC9000'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xA968163F0A57B400'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xD3C21BCECCEDA100'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x84595161401484A0'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xA56FA5B99019A5C8'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0xCECB8F27F4200F3A'u, lo: 0x0000000000000000'u),
+      uint64x2(hi: 0x813F3978F8940984'u, lo: 0x4000000000000000'u),
+      uint64x2(hi: 0xA18F07D736B90BE5'u, lo: 0x5000000000000000'u),
+      uint64x2(hi: 0xC9F2C9CD04674EDE'u, lo: 0xA400000000000000'u),
+      uint64x2(hi: 0xFC6F7C4045812296'u, lo: 0x4D00000000000000'u),
+      uint64x2(hi: 0x9DC5ADA82B70B59D'u, lo: 0xF020000000000000'u),
+      uint64x2(hi: 0xC5371912364CE305'u, lo: 0x6C28000000000000'u),
+      uint64x2(hi: 0xF684DF56C3E01BC6'u, lo: 0xC732000000000000'u),
+      uint64x2(hi: 0x9A130B963A6C115C'u, lo: 0x3C7F400000000000'u),
+      uint64x2(hi: 0xC097CE7BC90715B3'u, lo: 0x4B9F100000000000'u),
+      uint64x2(hi: 0xF0BDC21ABB48DB20'u, lo: 0x1E86D40000000000'u),
+      uint64x2(hi: 0x96769950B50D88F4'u, lo: 0x1314448000000000'u),
+      uint64x2(hi: 0xBC143FA4E250EB31'u, lo: 0x17D955A000000000'u),
+      uint64x2(hi: 0xEB194F8E1AE525FD'u, lo: 0x5DCFAB0800000000'u),
+      uint64x2(hi: 0x92EFD1B8D0CF37BE'u, lo: 0x5AA1CAE500000000'u),
+      uint64x2(hi: 0xB7ABC627050305AD'u, lo: 0xF14A3D9E40000000'u),
+      uint64x2(hi: 0xE596B7B0C643C719'u, lo: 0x6D9CCD05D0000000'u),
+      uint64x2(hi: 0x8F7E32CE7BEA5C6F'u, lo: 0xE4820023A2000000'u),
+      uint64x2(hi: 0xB35DBF821AE4F38B'u, lo: 0xDDA2802C8A800000'u),
+      uint64x2(hi: 0xE0352F62A19E306E'u, lo: 0xD50B2037AD200000'u),
+      uint64x2(hi: 0x8C213D9DA502DE45'u, lo: 0x4526F422CC340000'u),
+      uint64x2(hi: 0xAF298D050E4395D6'u, lo: 0x9670B12B7F410000'u),
+      uint64x2(hi: 0xDAF3F04651D47B4C'u, lo: 0x3C0CDD765F114000'u),
+      uint64x2(hi: 0x88D8762BF324CD0F'u, lo: 0xA5880A69FB6AC800'u),
+      uint64x2(hi: 0xAB0E93B6EFEE0053'u, lo: 0x8EEA0D047A457A00'u),
+      uint64x2(hi: 0xD5D238A4ABE98068'u, lo: 0x72A4904598D6D880'u),
+      uint64x2(hi: 0x85A36366EB71F041'u, lo: 0x47A6DA2B7F864750'u),
+      uint64x2(hi: 0xA70C3C40A64E6C51'u, lo: 0x999090B65F67D924'u),
+      uint64x2(hi: 0xD0CF4B50CFE20765'u, lo: 0xFFF4B4E3F741CF6D'u),
+      uint64x2(hi: 0x82818F1281ED449F'u, lo: 0xBFF8F10E7A8921A4'u),
+      uint64x2(hi: 0xA321F2D7226895C7'u, lo: 0xAFF72D52192B6A0D'u),
+      uint64x2(hi: 0xCBEA6F8CEB02BB39'u, lo: 0x9BF4F8A69F764490'u),
+      uint64x2(hi: 0xFEE50B7025C36A08'u, lo: 0x02F236D04753D5B4'u),
+      uint64x2(hi: 0x9F4F2726179A2245'u, lo: 0x01D762422C946590'u),
+      uint64x2(hi: 0xC722F0EF9D80AAD6'u, lo: 0x424D3AD2B7B97EF5'u),
+      uint64x2(hi: 0xF8EBAD2B84E0D58B'u, lo: 0xD2E0898765A7DEB2'u),
+      uint64x2(hi: 0x9B934C3B330C8577'u, lo: 0x63CC55F49F88EB2F'u),
+      uint64x2(hi: 0xC2781F49FFCFA6D5'u, lo: 0x3CBF6B71C76B25FB'u),
+      uint64x2(hi: 0xF316271C7FC3908A'u, lo: 0x8BEF464E3945EF7A'u),
+      uint64x2(hi: 0x97EDD871CFDA3A56'u, lo: 0x97758BF0E3CBB5AC'u),
+      uint64x2(hi: 0xBDE94E8E43D0C8EC'u, lo: 0x3D52EEED1CBEA317'u),
+      uint64x2(hi: 0xED63A231D4C4FB27'u, lo: 0x4CA7AAA863EE4BDD'u),
+      uint64x2(hi: 0x945E455F24FB1CF8'u, lo: 0x8FE8CAA93E74EF6A'u),
+      uint64x2(hi: 0xB975D6B6EE39E436'u, lo: 0xB3E2FD538E122B44'u),
+      uint64x2(hi: 0xE7D34C64A9C85D44'u, lo: 0x60DBBCA87196B616'u),
+      uint64x2(hi: 0x90E40FBEEA1D3A4A'u, lo: 0xBC8955E946FE31CD'u),
+      uint64x2(hi: 0xB51D13AEA4A488DD'u, lo: 0x6BABAB6398BDBE41'u),
+      uint64x2(hi: 0xE264589A4DCDAB14'u, lo: 0xC696963C7EED2DD1'u),
+      uint64x2(hi: 0x8D7EB76070A08AEC'u, lo: 0xFC1E1DE5CF543CA2'u),
+      uint64x2(hi: 0xB0DE65388CC8ADA8'u, lo: 0x3B25A55F43294BCB'u),
+      uint64x2(hi: 0xDD15FE86AFFAD912'u, lo: 0x49EF0EB713F39EBE'u),
+      uint64x2(hi: 0x8A2DBF142DFCC7AB'u, lo: 0x6E3569326C784337'u),
+      uint64x2(hi: 0xACB92ED9397BF996'u, lo: 0x49C2C37F07965404'u),
+      uint64x2(hi: 0xD7E77A8F87DAF7FB'u, lo: 0xDC33745EC97BE906'u),
+      uint64x2(hi: 0x86F0AC99B4E8DAFD'u, lo: 0x69A028BB3DED71A3'u),
+      uint64x2(hi: 0xA8ACD7C0222311BC'u, lo: 0xC40832EA0D68CE0C'u),
+      uint64x2(hi: 0xD2D80DB02AABD62B'u, lo: 0xF50A3FA490C30190'u),
+      uint64x2(hi: 0x83C7088E1AAB65DB'u, lo: 0x792667C6DA79E0FA'u),
+      uint64x2(hi: 0xA4B8CAB1A1563F52'u, lo: 0x577001B891185938'u),
+      uint64x2(hi: 0xCDE6FD5E09ABCF26'u, lo: 0xED4C0226B55E6F86'u),
+      uint64x2(hi: 0x80B05E5AC60B6178'u, lo: 0x544F8158315B05B4'u),
+      uint64x2(hi: 0xA0DC75F1778E39D6'u, lo: 0x696361AE3DB1C721'u),
+      uint64x2(hi: 0xC913936DD571C84C'u, lo: 0x03BC3A19CD1E38E9'u),
+      uint64x2(hi: 0xFB5878494ACE3A5F'u, lo: 0x04AB48A04065C723'u),
+      uint64x2(hi: 0x9D174B2DCEC0E47B'u, lo: 0x62EB0D64283F9C76'u),
+      uint64x2(hi: 0xC45D1DF942711D9A'u, lo: 0x3BA5D0BD324F8394'u),
+      uint64x2(hi: 0xF5746577930D6500'u, lo: 0xCA8F44EC7EE36479'u),
+      uint64x2(hi: 0x9968BF6ABBE85F20'u, lo: 0x7E998B13CF4E1ECB'u),
+      uint64x2(hi: 0xBFC2EF456AE276E8'u, lo: 0x9E3FEDD8C321A67E'u),
+      uint64x2(hi: 0xEFB3AB16C59B14A2'u, lo: 0xC5CFE94EF3EA101E'u),
+      uint64x2(hi: 0x95D04AEE3B80ECE5'u, lo: 0xBBA1F1D158724A12'u),
+      uint64x2(hi: 0xBB445DA9CA61281F'u, lo: 0x2A8A6E45AE8EDC97'u),
+      uint64x2(hi: 0xEA1575143CF97226'u, lo: 0xF52D09D71A3293BD'u),
+      uint64x2(hi: 0x924D692CA61BE758'u, lo: 0x593C2626705F9C56'u),
+      uint64x2(hi: 0xB6E0C377CFA2E12E'u, lo: 0x6F8B2FB00C77836C'u),
+      uint64x2(hi: 0xE498F455C38B997A'u, lo: 0x0B6DFB9C0F956447'u),
+      uint64x2(hi: 0x8EDF98B59A373FEC'u, lo: 0x4724BD4189BD5EAC'u),
+      uint64x2(hi: 0xB2977EE300C50FE7'u, lo: 0x58EDEC91EC2CB657'u),
+      uint64x2(hi: 0xDF3D5E9BC0F653E1'u, lo: 0x2F2967B66737E3ED'u),
+      uint64x2(hi: 0x8B865B215899F46C'u, lo: 0xBD79E0D20082EE74'u),
+      uint64x2(hi: 0xAE67F1E9AEC07187'u, lo: 0xECD8590680A3AA11'u),
+      uint64x2(hi: 0xDA01EE641A708DE9'u, lo: 0xE80E6F4820CC9495'u),
+      uint64x2(hi: 0x884134FE908658B2'u, lo: 0x3109058D147FDCDD'u),
+      uint64x2(hi: 0xAA51823E34A7EEDE'u, lo: 0xBD4B46F0599FD415'u),
+      uint64x2(hi: 0xD4E5E2CDC1D1EA96'u, lo: 0x6C9E18AC7007C91A'u),
+      uint64x2(hi: 0x850FADC09923329E'u, lo: 0x03E2CF6BC604DDB0'u),
+      uint64x2(hi: 0xA6539930BF6BFF45'u, lo: 0x84DB8346B786151C'u),
+      uint64x2(hi: 0xCFE87F7CEF46FF16'u, lo: 0xE612641865679A63'u),
+      uint64x2(hi: 0x81F14FAE158C5F6E'u, lo: 0x4FCB7E8F3F60C07E'u),
+      uint64x2(hi: 0xA26DA3999AEF7749'u, lo: 0xE3BE5E330F38F09D'u),
+      uint64x2(hi: 0xCB090C8001AB551C'u, lo: 0x5CADF5BFD3072CC5'u),
+      uint64x2(hi: 0xFDCB4FA002162A63'u, lo: 0x73D9732FC7C8F7F6'u),
+      uint64x2(hi: 0x9E9F11C4014DDA7E'u, lo: 0x2867E7FDDCDD9AFA'u),
+      uint64x2(hi: 0xC646D63501A1511D'u, lo: 0xB281E1FD541501B8'u),
+      uint64x2(hi: 0xF7D88BC24209A565'u, lo: 0x1F225A7CA91A4226'u),
+      uint64x2(hi: 0x9AE757596946075F'u, lo: 0x3375788DE9B06958'u),
+      uint64x2(hi: 0xC1A12D2FC3978937'u, lo: 0x0052D6B1641C83AE'u),
+      uint64x2(hi: 0xF209787BB47D6B84'u, lo: 0xC0678C5DBD23A49A'u),
+      uint64x2(hi: 0x9745EB4D50CE6332'u, lo: 0xF840B7BA963646E0'u),
+      uint64x2(hi: 0xBD176620A501FBFF'u, lo: 0xB650E5A93BC3D898'u),
+      uint64x2(hi: 0xEC5D3FA8CE427AFF'u, lo: 0xA3E51F138AB4CEBE'u),
+      uint64x2(hi: 0x93BA47C980E98CDF'u, lo: 0xC66F336C36B10137'u),
+      uint64x2(hi: 0xB8A8D9BBE123F017'u, lo: 0xB80B0047445D4184'u),
+      uint64x2(hi: 0xE6D3102AD96CEC1D'u, lo: 0xA60DC059157491E5'u),
+      uint64x2(hi: 0x9043EA1AC7E41392'u, lo: 0x87C89837AD68DB2F'u),
+      uint64x2(hi: 0xB454E4A179DD1877'u, lo: 0x29BABE4598C311FB'u),
+      uint64x2(hi: 0xE16A1DC9D8545E94'u, lo: 0xF4296DD6FEF3D67A'u),
+      uint64x2(hi: 0x8CE2529E2734BB1D'u, lo: 0x1899E4A65F58660C'u),
+      uint64x2(hi: 0xB01AE745B101E9E4'u, lo: 0x5EC05DCFF72E7F8F'u),
+      uint64x2(hi: 0xDC21A1171D42645D'u, lo: 0x76707543F4FA1F73'u),
+      uint64x2(hi: 0x899504AE72497EBA'u, lo: 0x6A06494A791C53A8'u),
+      uint64x2(hi: 0xABFA45DA0EDBDE69'u, lo: 0x0487DB9D17636892'u),
+      uint64x2(hi: 0xD6F8D7509292D603'u, lo: 0x45A9D2845D3C42B6'u),
+      uint64x2(hi: 0x865B86925B9BC5C2'u, lo: 0x0B8A2392BA45A9B2'u),
+      uint64x2(hi: 0xA7F26836F282B732'u, lo: 0x8E6CAC7768D7141E'u),
+      uint64x2(hi: 0xD1EF0244AF2364FF'u, lo: 0x3207D795430CD926'u),
+      uint64x2(hi: 0x8335616AED761F1F'u, lo: 0x7F44E6BD49E807B8'u),
+      uint64x2(hi: 0xA402B9C5A8D3A6E7'u, lo: 0x5F16206C9C6209A6'u),
+      uint64x2(hi: 0xCD036837130890A1'u, lo: 0x36DBA887C37A8C0F'u),
+      uint64x2(hi: 0x802221226BE55A64'u, lo: 0xC2494954DA2C9789'u),
+      uint64x2(hi: 0xA02AA96B06DEB0FD'u, lo: 0xF2DB9BAA10B7BD6C'u),
+      uint64x2(hi: 0xC83553C5C8965D3D'u, lo: 0x6F92829494E5ACC7'u),
+      uint64x2(hi: 0xFA42A8B73ABBF48C'u, lo: 0xCB772339BA1F17F9'u),
+      uint64x2(hi: 0x9C69A97284B578D7'u, lo: 0xFF2A760414536EFB'u),
+      uint64x2(hi: 0xC38413CF25E2D70D'u, lo: 0xFEF5138519684ABA'u),
+      uint64x2(hi: 0xF46518C2EF5B8CD1'u, lo: 0x7EB258665FC25D69'u),
+      uint64x2(hi: 0x98BF2F79D5993802'u, lo: 0xEF2F773FFBD97A61'u),
+      uint64x2(hi: 0xBEEEFB584AFF8603'u, lo: 0xAAFB550FFACFD8FA'u),
+      uint64x2(hi: 0xEEAABA2E5DBF6784'u, lo: 0x95BA2A53F983CF38'u),
+      uint64x2(hi: 0x952AB45CFA97A0B2'u, lo: 0xDD945A747BF26183'u),
+      uint64x2(hi: 0xBA756174393D88DF'u, lo: 0x94F971119AEEF9E4'u),
+      uint64x2(hi: 0xE912B9D1478CEB17'u, lo: 0x7A37CD5601AAB85D'u),
+      uint64x2(hi: 0x91ABB422CCB812EE'u, lo: 0xAC62E055C10AB33A'u),
+      uint64x2(hi: 0xB616A12B7FE617AA'u, lo: 0x577B986B314D6009'u),
+      uint64x2(hi: 0xE39C49765FDF9D94'u, lo: 0xED5A7E85FDA0B80B'u),
+      uint64x2(hi: 0x8E41ADE9FBEBC27D'u, lo: 0x14588F13BE847307'u),
+      uint64x2(hi: 0xB1D219647AE6B31C'u, lo: 0x596EB2D8AE258FC8'u),
+      uint64x2(hi: 0xDE469FBD99A05FE3'u, lo: 0x6FCA5F8ED9AEF3BB'u),
+      uint64x2(hi: 0x8AEC23D680043BEE'u, lo: 0x25DE7BB9480D5854'u),
+      uint64x2(hi: 0xADA72CCC20054AE9'u, lo: 0xAF561AA79A10AE6A'u),
+      uint64x2(hi: 0xD910F7FF28069DA4'u, lo: 0x1B2BA1518094DA04'u),
+      uint64x2(hi: 0x87AA9AFF79042286'u, lo: 0x90FB44D2F05D0842'u),
+      uint64x2(hi: 0xA99541BF57452B28'u, lo: 0x353A1607AC744A53'u),
+      uint64x2(hi: 0xD3FA922F2D1675F2'u, lo: 0x42889B8997915CE8'u),
+      uint64x2(hi: 0x847C9B5D7C2E09B7'u, lo: 0x69956135FEBADA11'u),
+      uint64x2(hi: 0xA59BC234DB398C25'u, lo: 0x43FAB9837E699095'u),
+      uint64x2(hi: 0xCF02B2C21207EF2E'u, lo: 0x94F967E45E03F4BB'u),
+      uint64x2(hi: 0x8161AFB94B44F57D'u, lo: 0x1D1BE0EEBAC278F5'u),
+      uint64x2(hi: 0xA1BA1BA79E1632DC'u, lo: 0x6462D92A69731732'u),
+      uint64x2(hi: 0xCA28A291859BBF93'u, lo: 0x7D7B8F7503CFDCFE'u),
+      uint64x2(hi: 0xFCB2CB35E702AF78'u, lo: 0x5CDA735244C3D43E'u),
+      uint64x2(hi: 0x9DEFBF01B061ADAB'u, lo: 0x3A0888136AFA64A7'u),
+      uint64x2(hi: 0xC56BAEC21C7A1916'u, lo: 0x088AAA1845B8FDD0'u),
+      uint64x2(hi: 0xF6C69A72A3989F5B'u, lo: 0x8AAD549E57273D45'u),
+      uint64x2(hi: 0x9A3C2087A63F6399'u, lo: 0x36AC54E2F678864B'u),
+      uint64x2(hi: 0xC0CB28A98FCF3C7F'u, lo: 0x84576A1BB416A7DD'u),
+      uint64x2(hi: 0xF0FDF2D3F3C30B9F'u, lo: 0x656D44A2A11C51D5'u),
+      uint64x2(hi: 0x969EB7C47859E743'u, lo: 0x9F644AE5A4B1B325'u),
+      uint64x2(hi: 0xBC4665B596706114'u, lo: 0x873D5D9F0DDE1FEE'u),
+      uint64x2(hi: 0xEB57FF22FC0C7959'u, lo: 0xA90CB506D155A7EA'u),
+      uint64x2(hi: 0x9316FF75DD87CBD8'u, lo: 0x09A7F12442D588F2'u),
+      uint64x2(hi: 0xB7DCBF5354E9BECE'u, lo: 0x0C11ED6D538AEB2F'u),
+      uint64x2(hi: 0xE5D3EF282A242E81'u, lo: 0x8F1668C8A86DA5FA'u),
+      uint64x2(hi: 0x8FA475791A569D10'u, lo: 0xF96E017D694487BC'u),
+      uint64x2(hi: 0xB38D92D760EC4455'u, lo: 0x37C981DCC395A9AC'u),
+      uint64x2(hi: 0xE070F78D3927556A'u, lo: 0x85BBE253F47B1417'u),
+      uint64x2(hi: 0x8C469AB843B89562'u, lo: 0x93956D7478CCEC8E'u),
+      uint64x2(hi: 0xAF58416654A6BABB'u, lo: 0x387AC8D1970027B2'u),
+      uint64x2(hi: 0xDB2E51BFE9D0696A'u, lo: 0x06997B05FCC0319E'u),
+      uint64x2(hi: 0x88FCF317F22241E2'u, lo: 0x441FECE3BDF81F03'u),
+      uint64x2(hi: 0xAB3C2FDDEEAAD25A'u, lo: 0xD527E81CAD7626C3'u),
+      uint64x2(hi: 0xD60B3BD56A5586F1'u, lo: 0x8A71E223D8D3B074'u),
+      uint64x2(hi: 0x85C7056562757456'u, lo: 0xF6872D5667844E49'u),
+      uint64x2(hi: 0xA738C6BEBB12D16C'u, lo: 0xB428F8AC016561DB'u),
+      uint64x2(hi: 0xD106F86E69D785C7'u, lo: 0xE13336D701BEBA52'u),
+      uint64x2(hi: 0x82A45B450226B39C'u, lo: 0xECC0024661173473'u),
+      uint64x2(hi: 0xA34D721642B06084'u, lo: 0x27F002D7F95D0190'u),
+      uint64x2(hi: 0xCC20CE9BD35C78A5'u, lo: 0x31EC038DF7B441F4'u),
+      uint64x2(hi: 0xFF290242C83396CE'u, lo: 0x7E67047175A15271'u),
+      uint64x2(hi: 0x9F79A169BD203E41'u, lo: 0x0F0062C6E984D386'u),
+      uint64x2(hi: 0xC75809C42C684DD1'u, lo: 0x52C07B78A3E60868'u),
+      uint64x2(hi: 0xF92E0C3537826145'u, lo: 0xA7709A56CCDF8A82'u),
+      uint64x2(hi: 0x9BBCC7A142B17CCB'u, lo: 0x88A66076400BB691'u),
+      uint64x2(hi: 0xC2ABF989935DDBFE'u, lo: 0x6ACFF893D00EA435'u),
+      uint64x2(hi: 0xF356F7EBF83552FE'u, lo: 0x0583F6B8C4124D43'u),
+      uint64x2(hi: 0x98165AF37B2153DE'u, lo: 0xC3727A337A8B704A'u),
+      uint64x2(hi: 0xBE1BF1B059E9A8D6'u, lo: 0x744F18C0592E4C5C'u),
+      uint64x2(hi: 0xEDA2EE1C7064130C'u, lo: 0x1162DEF06F79DF73'u),
+      uint64x2(hi: 0x9485D4D1C63E8BE7'u, lo: 0x8ADDCB5645AC2BA8'u),
+      uint64x2(hi: 0xB9A74A0637CE2EE1'u, lo: 0x6D953E2BD7173692'u),
+      uint64x2(hi: 0xE8111C87C5C1BA99'u, lo: 0xC8FA8DB6CCDD0437'u),
+      uint64x2(hi: 0x910AB1D4DB9914A0'u, lo: 0x1D9C9892400A22A2'u),
+      uint64x2(hi: 0xB54D5E4A127F59C8'u, lo: 0x2503BEB6D00CAB4B'u),
+      uint64x2(hi: 0xE2A0B5DC971F303A'u, lo: 0x2E44AE64840FD61D'u),
+      uint64x2(hi: 0x8DA471A9DE737E24'u, lo: 0x5CEAECFED289E5D2'u),
+      uint64x2(hi: 0xB10D8E1456105DAD'u, lo: 0x7425A83E872C5F47'u),
+      uint64x2(hi: 0xDD50F1996B947518'u, lo: 0xD12F124E28F77719'u),
+      uint64x2(hi: 0x8A5296FFE33CC92F'u, lo: 0x82BD6B70D99AAA6F'u),
+      uint64x2(hi: 0xACE73CBFDC0BFB7B'u, lo: 0x636CC64D1001550B'u),
+      uint64x2(hi: 0xD8210BEFD30EFA5A'u, lo: 0x3C47F7E05401AA4E'u),
+      uint64x2(hi: 0x8714A775E3E95C78'u, lo: 0x65ACFAEC34810A71'u),
+      uint64x2(hi: 0xA8D9D1535CE3B396'u, lo: 0x7F1839A741A14D0D'u),
+      uint64x2(hi: 0xD31045A8341CA07C'u, lo: 0x1EDE48111209A050'u),
+      uint64x2(hi: 0x83EA2B892091E44D'u, lo: 0x934AED0AAB460432'u),
+      uint64x2(hi: 0xA4E4B66B68B65D60'u, lo: 0xF81DA84D5617853F'u),
+      uint64x2(hi: 0xCE1DE40642E3F4B9'u, lo: 0x36251260AB9D668E'u),
+      uint64x2(hi: 0x80D2AE83E9CE78F3'u, lo: 0xC1D72B7C6B426019'u),
+      uint64x2(hi: 0xA1075A24E4421730'u, lo: 0xB24CF65B8612F81F'u),
+      uint64x2(hi: 0xC94930AE1D529CFC'u, lo: 0xDEE033F26797B627'u),
+      uint64x2(hi: 0xFB9B7CD9A4A7443C'u, lo: 0x169840EF017DA3B1'u),
+      uint64x2(hi: 0x9D412E0806E88AA5'u, lo: 0x8E1F289560EE864E'u),
+      uint64x2(hi: 0xC491798A08A2AD4E'u, lo: 0xF1A6F2BAB92A27E2'u),
+      uint64x2(hi: 0xF5B5D7EC8ACB58A2'u, lo: 0xAE10AF696774B1DB'u),
+      uint64x2(hi: 0x9991A6F3D6BF1765'u, lo: 0xACCA6DA1E0A8EF29'u),
+      uint64x2(hi: 0xBFF610B0CC6EDD3F'u, lo: 0x17FD090A58D32AF3'u),
+      uint64x2(hi: 0xEFF394DCFF8A948E'u, lo: 0xDDFC4B4CEF07F5B0'u),
+      uint64x2(hi: 0x95F83D0A1FB69CD9'u, lo: 0x4ABDAF101564F98E'u),
+      uint64x2(hi: 0xBB764C4CA7A4440F'u, lo: 0x9D6D1AD41ABE37F1'u),
+      uint64x2(hi: 0xEA53DF5FD18D5513'u, lo: 0x84C86189216DC5ED'u),
+      uint64x2(hi: 0x92746B9BE2F8552C'u, lo: 0x32FD3CF5B4E49BB4'u),
+      uint64x2(hi: 0xB7118682DBB66A77'u, lo: 0x3FBC8C33221DC2A1'u),
+      uint64x2(hi: 0xE4D5E82392A40515'u, lo: 0x0FABAF3FEAA5334A'u),
+      uint64x2(hi: 0x8F05B1163BA6832D'u, lo: 0x29CB4D87F2A7400E'u),
+      uint64x2(hi: 0xB2C71D5BCA9023F8'u, lo: 0x743E20E9EF511012'u),
+      uint64x2(hi: 0xDF78E4B2BD342CF6'u, lo: 0x914DA9246B255416'u),
+      uint64x2(hi: 0x8BAB8EEFB6409C1A'u, lo: 0x1AD089B6C2F7548E'u),
+      uint64x2(hi: 0xAE9672ABA3D0C320'u, lo: 0xA184AC2473B529B1'u),
+      uint64x2(hi: 0xDA3C0F568CC4F3E8'u, lo: 0xC9E5D72D90A2741E'u),
+      uint64x2(hi: 0x8865899617FB1871'u, lo: 0x7E2FA67C7A658892'u),
+      uint64x2(hi: 0xAA7EEBFB9DF9DE8D'u, lo: 0xDDBB901B98FEEAB7'u),
+      uint64x2(hi: 0xD51EA6FA85785631'u, lo: 0x552A74227F3EA565'u),
+      uint64x2(hi: 0x8533285C936B35DE'u, lo: 0xD53A88958F87275F'u),
+      uint64x2(hi: 0xA67FF273B8460356'u, lo: 0x8A892ABAF368F137'u),
+      uint64x2(hi: 0xD01FEF10A657842C'u, lo: 0x2D2B7569B0432D85'u),
+      uint64x2(hi: 0x8213F56A67F6B29B'u, lo: 0x9C3B29620E29FC73'u),
+      uint64x2(hi: 0xA298F2C501F45F42'u, lo: 0x8349F3BA91B47B8F'u),
+      uint64x2(hi: 0xCB3F2F7642717713'u, lo: 0x241C70A936219A73'u),
+      uint64x2(hi: 0xFE0EFB53D30DD4D7'u, lo: 0xED238CD383AA0110'u),
+      uint64x2(hi: 0x9EC95D1463E8A506'u, lo: 0xF4363804324A40AA'u),
+      uint64x2(hi: 0xC67BB4597CE2CE48'u, lo: 0xB143C6053EDCD0D5'u),
+      uint64x2(hi: 0xF81AA16FDC1B81DA'u, lo: 0xDD94B7868E94050A'u),
+      uint64x2(hi: 0x9B10A4E5E9913128'u, lo: 0xCA7CF2B4191C8326'u),
+      uint64x2(hi: 0xC1D4CE1F63F57D72'u, lo: 0xFD1C2F611F63A3F0'u),
+      uint64x2(hi: 0xF24A01A73CF2DCCF'u, lo: 0xBC633B39673C8CEC'u),
+      uint64x2(hi: 0x976E41088617CA01'u, lo: 0xD5BE0503E085D813'u),
+      uint64x2(hi: 0xBD49D14AA79DBC82'u, lo: 0x4B2D8644D8A74E18'u),
+      uint64x2(hi: 0xEC9C459D51852BA2'u, lo: 0xDDF8E7D60ED1219E'u),
+      uint64x2(hi: 0x93E1AB8252F33B45'u, lo: 0xCABB90E5C942B503'u),
+      uint64x2(hi: 0xB8DA1662E7B00A17'u, lo: 0x3D6A751F3B936243'u),
+      uint64x2(hi: 0xE7109BFBA19C0C9D'u, lo: 0x0CC512670A783AD4'u),
+      uint64x2(hi: 0x906A617D450187E2'u, lo: 0x27FB2B80668B24C5'u),
+      uint64x2(hi: 0xB484F9DC9641E9DA'u, lo: 0xB1F9F660802DEDF6'u),
+      uint64x2(hi: 0xE1A63853BBD26451'u, lo: 0x5E7873F8A0396973'u),
+      uint64x2(hi: 0x8D07E33455637EB2'u, lo: 0xDB0B487B6423E1E8'u),
+      uint64x2(hi: 0xB049DC016ABC5E5F'u, lo: 0x91CE1A9A3D2CDA62'u),
+      uint64x2(hi: 0xDC5C5301C56B75F7'u, lo: 0x7641A140CC7810FB'u),
+      uint64x2(hi: 0x89B9B3E11B6329BA'u, lo: 0xA9E904C87FCB0A9D'u),
+      uint64x2(hi: 0xAC2820D9623BF429'u, lo: 0x546345FA9FBDCD44'u),
+      uint64x2(hi: 0xD732290FBACAF133'u, lo: 0xA97C177947AD4095'u),
+      uint64x2(hi: 0x867F59A9D4BED6C0'u, lo: 0x49ED8EABCCCC485D'u),
+      uint64x2(hi: 0xA81F301449EE8C70'u, lo: 0x5C68F256BFFF5A74'u),
+      uint64x2(hi: 0xD226FC195C6A2F8C'u, lo: 0x73832EEC6FFF3111'u),
+      uint64x2(hi: 0x83585D8FD9C25DB7'u, lo: 0xC831FD53C5FF7EAB'u),
+      uint64x2(hi: 0xA42E74F3D032F525'u, lo: 0xBA3E7CA8B77F5E55'u),
+      uint64x2(hi: 0xCD3A1230C43FB26F'u, lo: 0x28CE1BD2E55F35EB'u),
+      uint64x2(hi: 0x80444B5E7AA7CF85'u, lo: 0x7980D163CF5B81B3'u),
+      uint64x2(hi: 0xA0555E361951C366'u, lo: 0xD7E105BCC332621F'u),
+      uint64x2(hi: 0xC86AB5C39FA63440'u, lo: 0x8DD9472BF3FEFAA7'u),
+      uint64x2(hi: 0xFA856334878FC150'u, lo: 0xB14F98F6F0FEB951'u),
+      uint64x2(hi: 0x9C935E00D4B9D8D2'u, lo: 0x6ED1BF9A569F33D3'u),
+      uint64x2(hi: 0xC3B8358109E84F07'u, lo: 0x0A862F80EC4700C8'u),
+      uint64x2(hi: 0xF4A642E14C6262C8'u, lo: 0xCD27BB612758C0FA'u),
+      uint64x2(hi: 0x98E7E9CCCFBD7DBD'u, lo: 0x8038D51CB897789C'u),
+      uint64x2(hi: 0xBF21E44003ACDD2C'u, lo: 0xE0470A63E6BD56C3'u),
+      uint64x2(hi: 0xEEEA5D5004981478'u, lo: 0x1858CCFCE06CAC74'u),
+      uint64x2(hi: 0x95527A5202DF0CCB'u, lo: 0x0F37801E0C43EBC8'u),
+      uint64x2(hi: 0xBAA718E68396CFFD'u, lo: 0xD30560258F54E6BA'u),
+      uint64x2(hi: 0xE950DF20247C83FD'u, lo: 0x47C6B82EF32A2069'u),
+      uint64x2(hi: 0x91D28B7416CDD27E'u, lo: 0x4CDC331D57FA5441'u),
+      uint64x2(hi: 0xB6472E511C81471D'u, lo: 0xE0133FE4ADF8E952'u),
+      uint64x2(hi: 0xE3D8F9E563A198E5'u, lo: 0x58180FDDD97723A6'u),
+      uint64x2(hi: 0x8E679C2F5E44FF8F'u, lo: 0x570F09EAA7EA7648'u),
+      uint64x2(hi: 0xB201833B35D63F73'u, lo: 0x2CD2CC6551E513DA'u),
+      uint64x2(hi: 0xDE81E40A034BCF4F'u, lo: 0xF8077F7EA65E58D1'u),
+      uint64x2(hi: 0x8B112E86420F6191'u, lo: 0xFB04AFAF27FAF782'u),
+      uint64x2(hi: 0xADD57A27D29339F6'u, lo: 0x79C5DB9AF1F9B563'u),
+      uint64x2(hi: 0xD94AD8B1C7380874'u, lo: 0x18375281AE7822BC'u),
+      uint64x2(hi: 0x87CEC76F1C830548'u, lo: 0x8F2293910D0B15B5'u),
+      uint64x2(hi: 0xA9C2794AE3A3C69A'u, lo: 0xB2EB3875504DDB22'u),
+      uint64x2(hi: 0xD433179D9C8CB841'u, lo: 0x5FA60692A46151EB'u),
+      uint64x2(hi: 0x849FEEC281D7F328'u, lo: 0xDBC7C41BA6BCD333'u),
+      uint64x2(hi: 0xA5C7EA73224DEFF3'u, lo: 0x12B9B522906C0800'u),
+      uint64x2(hi: 0xCF39E50FEAE16BEF'u, lo: 0xD768226B34870A00'u),
+      uint64x2(hi: 0x81842F29F2CCE375'u, lo: 0xE6A1158300D46640'u),
+      uint64x2(hi: 0xA1E53AF46F801C53'u, lo: 0x60495AE3C1097FD0'u),
+      uint64x2(hi: 0xCA5E89B18B602368'u, lo: 0x385BB19CB14BDFC4'u),
+      uint64x2(hi: 0xFCF62C1DEE382C42'u, lo: 0x46729E03DD9ED7B5'u),
+      uint64x2(hi: 0x9E19DB92B4E31BA9'u, lo: 0x6C07A2C26A8346D1'u),
+      uint64x2(hi: 0xC5A05277621BE293'u, lo: 0xC7098B7305241885'u),
+      uint64x2(hi: 0xF70867153AA2DB38'u, lo: 0xB8CBEE4FC66D1EA7'u)]
+  dragonbox_Assert(k >= kMin)
+  dragonbox_Assert(k <= kMax)
+  return pow10[k - kMin]
+
+##  Returns whether value is divisible by 2^e2
+
+proc multipleOfPow2*(value: uint64; e2: int32): bool {.inline.} =
+  dragonbox_Assert(e2 >= 0)
+  return e2 < 64 and (value and ((uint64(1) shl e2) - 1)) == 0
+
+##  Returns whether value is divisible by 5^e5
+
+proc multipleOfPow5*(value: uint64; e5: int32): bool {.inline.} =
+  type
+    MulCmp {.bycopy.} = object
+      mul: uint64
+      cmp: uint64
+
+  const
+    mod5 = [MulCmp(mul: 0x0000000000000001'u, cmp: 0xFFFFFFFFFFFFFFFF'u),
+      MulCmp(mul: 0xCCCCCCCCCCCCCCCD'u, cmp: 0x3333333333333333'u),
+      MulCmp(mul: 0x8F5C28F5C28F5C29'u, cmp: 0x0A3D70A3D70A3D70'u),
+      MulCmp(mul: 0x1CAC083126E978D5'u, cmp: 0x020C49BA5E353F7C'u),
+      MulCmp(mul: 0xD288CE703AFB7E91'u, cmp: 0x0068DB8BAC710CB2'u),
+      MulCmp(mul: 0x5D4E8FB00BCBE61D'u, cmp: 0x0014F8B588E368F0'u),
+      MulCmp(mul: 0x790FB65668C26139'u, cmp: 0x000431BDE82D7B63'u),
+      MulCmp(mul: 0xE5032477AE8D46A5'u, cmp: 0x0000D6BF94D5E57A'u),
+      MulCmp(mul: 0xC767074B22E90E21'u, cmp: 0x00002AF31DC46118'u),
+      MulCmp(mul: 0x8E47CE423A2E9C6D'u, cmp: 0x0000089705F4136B'u),
+      MulCmp(mul: 0x4FA7F60D3ED61F49'u, cmp: 0x000001B7CDFD9D7B'u),
+      MulCmp(mul: 0x0FEE64690C913975'u, cmp: 0x00000057F5FF85E5'u),
+      MulCmp(mul: 0x3662E0E1CF503EB1'u, cmp: 0x000000119799812D'u),
+      MulCmp(mul: 0xA47A2CF9F6433FBD'u, cmp: 0x0000000384B84D09'u),
+      MulCmp(mul: 0x54186F653140A659'u, cmp: 0x00000000B424DC35'u),
+      MulCmp(mul: 0x7738164770402145'u, cmp: 0x0000000024075F3D'u),
+      MulCmp(mul: 0xE4A4D1417CD9A041'u, cmp: 0x000000000734ACA5'u),
+      MulCmp(mul: 0xC75429D9E5C5200D'u, cmp: 0x000000000170EF54'u),
+      MulCmp(mul: 0xC1773B91FAC10669'u, cmp: 0x000000000049C977'u),
+      MulCmp(mul: 0x26B172506559CE15'u, cmp: 0x00000000000EC1E4'u),
+      MulCmp(mul: 0xD489E3A9ADDEC2D1'u, cmp: 0x000000000002F394'u),
+      MulCmp(mul: 0x90E860BB892C8D5D'u, cmp: 0x000000000000971D'u),
+      MulCmp(mul: 0x502E79BF1B6F4F79'u, cmp: 0x0000000000001E39'u),
+      MulCmp(mul: 0xDCD618596BE30FE5'u, cmp: 0x000000000000060B'u),
+      MulCmp(mul: 0x2C2AD1AB7BFA3661'u, cmp: 0x0000000000000135'u)]
+  dragonbox_Assert(e5 >= 0)
+  dragonbox_Assert(e5 <= 24)
+  let m5: MulCmp = mod5[e5]
+  return value * m5.mul <= m5.cmp
+
+type
+  FloatingDecimal64* {.bycopy.} = object
+    significand*: uint64
+    exponent*: int32
+
+
+proc toDecimal64AsymmetricInterval*(e2: int32): FloatingDecimal64 {.inline.} =
+  ##  NB:
+  ##  accept_lower_endpoint = true
+  ##  accept_upper_endpoint = true
+  const
+    P: int32 = significandSize
+  ##  Compute k and beta
+  let minusK: int32 = floorLog10ThreeQuartersPow2(e2)
+  let betaMinus1: int32 = e2 + floorLog2Pow10(-minusK)
+  ##  Compute xi and zi
+  let pow10: uint64x2 = computePow10(-minusK)
+  let lowerEndpoint: uint64 = (pow10.hi - (pow10.hi shr (P + 1))) shr
+      (64 - P - betaMinus1)
+  let upperEndpoint: uint64 = (pow10.hi + (pow10.hi shr (P + 0))) shr
+      (64 - P - betaMinus1)
+  ##  If we don't accept the left endpoint (but we do!) or
+  ##  if the left endpoint is not an integer, increase it
+  let lowerEndpointIsInteger: bool = (2 <= e2 and e2 <= 3)
+  let xi: uint64 = lowerEndpoint + uint64(not lowerEndpointIsInteger)
+  let zi: uint64 = upperEndpoint
+  ##  Try bigger divisor
+  var q: uint64 = zi div 10
+  if q * 10 >= xi:
+    return FloatingDecimal64(significand: q, exponent: minusK + 1)
+  q = ((pow10.hi shr (64 - (P + 1) - betaMinus1)) + 1) div 2
+  ##  When tie occurs, choose one of them according to the rule
+  if e2 == -77:
+    dec(q, ord(q mod 2 != 0))
+    ##  Round to even.
+  else:
+    inc(q, ord(q < xi))
+  return FloatingDecimal64(significand: q, exponent: minusK)
+
+proc computeDelta*(pow10: uint64x2; betaMinus1: int32): uint32 {.inline.} =
+  dragonbox_Assert(betaMinus1 >= 0)
+  dragonbox_Assert(betaMinus1 <= 63)
+  return cast[uint32](pow10.hi shr (64 - 1 - betaMinus1))
+
+when defined(sizeof_Int128):
+  proc mul128*(x: uint64; y: uint64): uint64x2 {.inline.} =
+    ##  1 mulx
+    type
+      uint128T = uint128
+    let p: uint128T = uint128T(x) * y
+    let hi: uint64 = cast[uint64](p shr 64)
+    let lo: uint64 = cast[uint64](p)
+    return (hi, lo)
+
+elif defined(vcc) and defined(cpu64):
+  proc umul128(x, y: uint64, z: ptr uint64): uint64 {.importc: "_umul128", header: "<intrin.h>".}
+  proc mul128*(x: uint64; y: uint64): uint64x2 {.inline.} =
+    var hi: uint64 = 0
+    var lo: uint64 = umul128(x, y, addr(hi))
+    return uint64x2(hi: hi, lo: lo)
+
+else:
+  proc lo32*(x: uint64): uint32 {.inline.} =
+    return cast[uint32](x)
+
+  proc hi32*(x: uint64): uint32 {.inline.} =
+    return cast[uint32](x shr 32)
+
+  proc mul128*(a: uint64; b: uint64): uint64x2 {.inline.} =
+    let b00: uint64 = uint64(lo32(a)) * lo32(b)
+    let b01: uint64 = uint64(lo32(a)) * hi32(b)
+    let b10: uint64 = uint64(hi32(a)) * lo32(b)
+    let b11: uint64 = uint64(hi32(a)) * hi32(b)
+    let mid1: uint64 = b10 + hi32(b00)
+    let mid2: uint64 = b01 + lo32(mid1)
+    let hi: uint64 = b11 + hi32(mid1) + hi32(mid2)
+    let lo: uint64 = lo32(b00) or uint64(lo32(mid2)) shl 32
+    return uint64x2(hi: hi, lo: lo)
+
+##  Returns (x * y) / 2^128
+
+proc mulShift*(x: uint64; y: uint64x2): uint64 {.inline.} =
+  ##  2 mulx
+  var p1: uint64x2 = mul128(x, y.hi)
+  var p0: uint64x2 = mul128(x, y.lo)
+  p1.lo += p0.hi
+  inc(p1.hi, ord(p1.lo < p0.hi))
+  return p1.hi
+
+proc mulParity*(twoF: uint64; pow10: uint64x2; betaMinus1: int32): bool {.inline.} =
+  ##  1 mulx, 1 mul
+  dragonbox_Assert(betaMinus1 >= 1)
+  dragonbox_Assert(betaMinus1 <= 63)
+  let p01: uint64 = twoF * pow10.hi
+  let p10: uint64 = mul128(twoF, pow10.lo).hi
+  let mid: uint64 = p01 + p10
+  return (mid and (uint64(1) shl (64 - betaMinus1))) != 0
+
+proc isIntegralEndpoint*(twoF: uint64; e2: int32; minusK: int32): bool {.inline.} =
+  if e2 < -2:
+    return false
+  if e2 <= 9:
+    return true
+  if e2 <= 86:
+    return multipleOfPow5(twoF, minusK)
+  return false
+
+proc isIntegralMidpoint*(twoF: uint64; e2: int32; minusK: int32): bool {.inline.} =
+  if e2 < -4:
+    return multipleOfPow2(twoF, minusK - e2 + 1)
+  if e2 <= 9:
+    return true
+  if e2 <= 86:
+    return multipleOfPow5(twoF, minusK)
+  return false
+
+proc toDecimal64*(ieeeSignificand: uint64; ieeeExponent: uint64): FloatingDecimal64 {.
+    inline.} =
+  const
+    kappa: int32 = 2
+  const
+    bigDivisor: uint32 = 1000
+  ##  10^(kappa + 1)
+  const
+    smallDivisor: uint32 = 100
+  ##  10^(kappa)
+  ##
+  ##  Step 1:
+  ##  integer promotion & Schubfach multiplier calculation.
+  ##
+  var m2: uint64
+  var e2: int32
+  if ieeeExponent != 0:
+    m2 = hiddenBit or ieeeSignificand
+    e2 = cast[int32](ieeeExponent) - exponentBias
+    if 0 <= -e2 and -e2 < significandSize and multipleOfPow2(m2, -e2):
+      ##  Small integer.
+      return FloatingDecimal64(significand: m2 shr -e2, exponent: 0)
+    if ieeeSignificand == 0 and ieeeExponent > 1:
+      ##  Shorter interval case; proceed like Schubfach.
+      return toDecimal64AsymmetricInterval(e2)
+  else:
+    ##  Subnormal case; interval is always regular.
+    m2 = ieeeSignificand
+    e2 = 1 - exponentBias
+  let isEven: bool = (m2 mod 2 == 0)
+  let acceptLower: bool = isEven
+  let acceptUpper: bool = isEven
+  ##  Compute k and beta.
+  let minusK: int32 = floorLog10Pow2(e2) - kappa
+  let betaMinus1: int32 = e2 + floorLog2Pow10(-minusK)
+  dragonbox_Assert(betaMinus1 >= 6)
+  dragonbox_Assert(betaMinus1 <= 9)
+  let pow10: uint64x2 = computePow10(-minusK)
+  ##  Compute delta
+  ##  10^kappa <= delta < 10^(kappa + 1)
+  ##       100 <= delta < 1000
+  let delta: uint32 = computeDelta(pow10, betaMinus1)
+  dragonbox_Assert(delta >= smallDivisor)
+  dragonbox_Assert(delta < bigDivisor)
+  let twoFl: uint64 = 2 * m2 - 1
+  let twoFc: uint64 = 2 * m2
+  let twoFr: uint64 = 2 * m2 + 1
+  ##  (54 bits)
+  ##  Compute zi
+  ##   (54 + 9 = 63 bits)
+  let zi: uint64 = mulShift(twoFr shl betaMinus1, pow10)
+  ##  2 mulx
+  ##
+  ##  Step 2:
+  ##  Try larger divisor.
+  ##
+  var q: uint64 = zi div bigDivisor
+  ##   uint64_t q = Mul128(zi, 0x83126E978D4FDF3Cu).hi >> 9; // 1 mulx
+  var r: uint32 = cast[uint32](zi) - bigDivisor * cast[uint32](q)
+  ##  r = zi % BigDivisor
+  ##  0 <= r < 1000
+  if r < delta:                  ## likely ~50% ?!
+            ##  (r > deltai)
+    ##  Exclude the right endpoint if necessary
+    if r != 0 or acceptUpper or not isIntegralEndpoint(twoFr, e2, minusK):
+      return FloatingDecimal64(significand: q, exponent: minusK + kappa + 1)
+    dragonbox_Assert(q != 0)
+    dec(q)
+    r = bigDivisor
+  elif r == delta:               ## unlikely
+    ##  Compare fractional parts.
+    ##  Check conditions in the order different from the paper
+    ##  to take advantage of short-circuiting
+    if (acceptLower and isIntegralEndpoint(twoFl, e2, minusK)) or
+        mulParity(twoFl, pow10, betaMinus1):
+      return FloatingDecimal64(significand: q, exponent: minusK + kappa + 1)
+  else:
+    discard
+  ##
+  ##  Step 3:
+  ##  Find the significand with the smaller divisor
+  ##
+  q = q * 10
+  ##  1 hmul
+  ##  0 <= r <= 1000
+  let dist: uint32 = r - (delta div 2) + (smallDivisor div 2)
+  let distQ: uint32 = dist div 100
+  ##  1 mul
+  ##   const uint32_t dist_r = dist % 100;
+  q += distQ
+  ##   if /*likely*/ (dist_r == 0)
+  if dist == distQ * 100:
+    ##       const bool approx_y_parity = ((dist ^ (SmallDivisor / 2)) & 1) != 0;
+    let approxYParity: bool = (dist and 1) != 0
+    ##  Check z^(f) >= epsilon^(f)
+    ##  We have either yi == zi - epsiloni or yi == (zi - epsiloni) - 1,
+    ##  where yi == zi - epsiloni if and only if z^(f) >= epsilon^(f)
+    ##  Since there are only 2 possibilities, we only need to care about the
+    ##  parity. Also, zi and r should have the same parity since the divisor
+    ##  is an even number
+    if mulParity(twoFc, pow10, betaMinus1) != approxYParity:
+      dec(q)
+    elif q mod 2 != 0 and isIntegralMidpoint(twoFc, e2, minusK):
+      dec(q)
+  return FloatingDecimal64(significand: q, exponent: minusK + kappa)
+
+# ==================================================================================================
+#  ToChars
+# ==================================================================================================
+
+when false:
+  template `+!`(x: cstring; offset: int): cstring = cast[cstring](cast[uint](x) + uint(offset))
+
+  template dec(x: cstring; offset=1) = x = cast[cstring](cast[uint](x) - uint(offset))
+  template inc(x: cstring; offset=1) = x = cast[cstring](cast[uint](x) + uint(offset))
+
+  proc memset(x: cstring; ch: char; L: int) {.importc, nodecl.}
+  proc memmove(a, b: cstring; L: int) {.importc, nodecl.}
+
+proc utoa8DigitsSkipTrailingZeros*(buf: var openArray[char]; pos: int; digits: uint32): int {.inline.} =
+  dragonbox_Assert(digits >= 1)
+  dragonbox_Assert(digits <= 99999999'u32)
+  let q: uint32 = digits div 10000
+  let r: uint32 = digits mod 10000
+  let qH: uint32 = q div 100
+  let qL: uint32 = q mod 100
+  utoa2Digits(buf, pos, qH)
+  utoa2Digits(buf, pos + 2, qL)
+  if r == 0:
+    return trailingZeros2Digits(if qL == 0: qH else: qL) + (if qL == 0: 6 else: 4)
+  else:
+    let rH: uint32 = r div 100
+    let rL: uint32 = r mod 100
+    utoa2Digits(buf, pos + 4, rH)
+    utoa2Digits(buf, pos + 6, rL)
+    return trailingZeros2Digits(if rL == 0: rH else: rL) + (if rL == 0: 2 else: 0)
+
+proc printDecimalDigitsBackwards*(buf: var openArray[char]; pos: int; output64: uint64): int {.inline.} =
+  var pos = pos
+  var output64 = output64
+  var tz = 0
+  ##  number of trailing zeros removed.
+  var nd = 0
+  ##  number of decimal digits processed.
+  ##  At most 17 digits remaining
+  if output64 >= 100000000'u64:
+    let q: uint64 = output64 div 100000000'u64
+    let r: uint32 = cast[uint32](output64 mod 100000000'u64)
+    output64 = q
+    dec(pos, 8)
+    if r != 0:
+      tz = utoa8DigitsSkipTrailingZeros(buf, pos, r)
+      dragonbox_Assert(tz >= 0)
+      dragonbox_Assert(tz <= 7)
+    else:
+      tz = 8
+    nd = 8
+  dragonbox_Assert(output64 <= high(uint32))
+  var output = cast[uint32](output64)
+  if output >= 10000:
+    let q: uint32 = output div 10000
+    let r: uint32 = output mod 10000
+    output = q
+    dec(pos, 4)
+    if r != 0:
+      let rH: uint32 = r div 100
+      let rL: uint32 = r mod 100
+      utoa2Digits(buf, pos, rH)
+      utoa2Digits(buf, pos + 2, rL)
+      if tz == nd:
+        inc(tz, trailingZeros2Digits(if rL == 0: rH else: rL) +
+            (if rL == 0: 2 else: 0))
+    else:
+      if tz == nd:
+        inc(tz, 4)
+      else:
+        for i in 0..3: buf[pos+i] = '0'
+      ##  (actually not required...)
+    inc(nd, 4)
+  if output >= 100:
+    let q: uint32 = output div 100
+    let r: uint32 = output mod 100
+    output = q
+    dec(pos, 2)
+    utoa2Digits(buf, pos, r)
+    if tz == nd:
+      inc(tz, trailingZeros2Digits(r))
+    inc(nd, 2)
+    if output >= 100:
+      let q2: uint32 = output div 100
+      let r2: uint32 = output mod 100
+      output = q2
+      dec(pos, 2)
+      utoa2Digits(buf, pos, r2)
+      if tz == nd:
+        inc(tz, trailingZeros2Digits(r2))
+      inc(nd, 2)
+  dragonbox_Assert(output >= 1)
+  dragonbox_Assert(output <= 99)
+  if output >= 10:
+    let q: uint32 = output
+    dec(pos, 2)
+    utoa2Digits(buf, pos, q)
+    if tz == nd:
+      inc(tz, trailingZeros2Digits(q))
+  else:
+    let q: uint32 = output
+    dragonbox_Assert(q >= 1)
+    dragonbox_Assert(q <= 9)
+    dec(pos)
+    buf[pos] = chr(ord('0') + q)
+  return tz
+
+proc decimalLength*(v: uint64): int {.inline.} =
+  dragonbox_Assert(v >= 1)
+  dragonbox_Assert(v <= 99999999999999999'u64)
+  if cast[uint32](v shr 32) != 0:
+    if v >= 10000000000000000'u64:
+      return 17
+    if v >= 1000000000000000'u64:
+      return 16
+    if v >= 100000000000000'u64:
+      return 15
+    if v >= 10000000000000'u64:
+      return 14
+    if v >= 1000000000000'u64:
+      return 13
+    if v >= 100000000000'u64:
+      return 12
+    if v >= 10000000000'u64:
+      return 11
+    return 10
+  let v32: uint32 = cast[uint32](v)
+  if v32 >= 1000000000'u32:
+    return 10
+  if v32 >= 100000000'u32:
+    return 9
+  if v32 >= 10000000'u32:
+    return 8
+  if v32 >= 1000000'u32:
+    return 7
+  if v32 >= 100000'u32:
+    return 6
+  if v32 >= 10000'u32:
+    return 5
+  if v32 >= 1000'u32:
+    return 4
+  if v32 >= 100'u32:
+    return 3
+  if v32 >= 10'u32:
+    return 2
+  return 1
+
+proc formatDigits*[T: Ordinal](buffer: var openArray[char]; pos: T; digits: uint64; decimalExponent: int;
+                  forceTrailingDotZero = false): int {.inline.} =
+  const
+    minFixedDecimalPoint = -6
+  const
+    maxFixedDecimalPoint = 17
+  var pos:int = pos.int
+  assert(minFixedDecimalPoint <= -1, "internal error")
+  assert(maxFixedDecimalPoint >= 17, "internal error")
+  dragonbox_Assert(digits >= 1)
+  dragonbox_Assert(digits <= 99999999999999999'u64)
+  dragonbox_Assert(decimalExponent >= -999)
+  dragonbox_Assert(decimalExponent <= 999)
+  var numDigits = decimalLength(digits)
+  let decimalPoint = numDigits + decimalExponent
+  let useFixed: bool = minFixedDecimalPoint <= decimalPoint and
+      decimalPoint <= maxFixedDecimalPoint
+  ## Prepare the buffer.
+  for i in 0..<32: buffer[pos+i] = '0'
+  assert(minFixedDecimalPoint >= -30, "internal error")
+  assert(maxFixedDecimalPoint <= 32, "internal error")
+  var decimalDigitsPosition: int
+  if useFixed:
+    if decimalPoint <= 0:
+      ##  0.[000]digits
+      decimalDigitsPosition = 2 - decimalPoint
+    else:
+      ##  dig.its
+      ##  digits[000]
+      decimalDigitsPosition = 0
+  else:
+    ##  dE+123 or d.igitsE+123
+    decimalDigitsPosition = 1
+  var digitsEnd = pos + int(decimalDigitsPosition + numDigits)
+  let tz = printDecimalDigitsBackwards(buffer, digitsEnd, digits)
+  dec(digitsEnd, tz)
+  dec(numDigits, tz)
+  ##   decimal_exponent += tz; // => decimal_point unchanged.
+  if useFixed:
+    if decimalPoint <= 0:
+      ##  0.[000]digits
+      buffer[pos+1] = '.'
+      pos = digitsEnd
+    elif decimalPoint < numDigits:
+      ##  dig.its
+      when true: #defined(vcc) and not defined(clang):
+        ##  VC does not inline the memmove call below. (Even if compiled with /arch:AVX2.)
+        ##  However, memcpy will be inlined.
+        var tmp: array[16, char]
+        for i in 0..<16: tmp[i] = buffer[i+pos+decimalPoint]
+        for i in 0..<16: buffer[i+pos+decimalPoint+1] = tmp[i]
+      else:
+        memmove(buffer +! (decimalPoint + 1), buffer +! decimalPoint, 16)
+      buffer[pos+decimalPoint] = '.'
+      pos = digitsEnd + 1
+    else:
+      ##  digits[000]
+      inc(pos, decimalPoint)
+      if forceTrailingDotZero:
+        buffer[pos] = '.'
+        buffer[pos+1] = '0'
+        inc(pos, 2)
+  else:
+    ##  Copy the first digit one place to the left.
+    buffer[pos] = buffer[pos+1]
+    if numDigits == 1:
+      ##  dE+123
+      inc(pos)
+    else:
+      ##  d.igitsE+123
+      buffer[pos+1] = '.'
+      pos = digitsEnd
+    let scientificExponent: int = decimalPoint - 1
+    ##       SF_ASSERT(scientific_exponent != 0);
+    buffer[pos] = 'e'
+    buffer[pos+1] = if scientificExponent < 0: '-' else: '+'
+    inc(pos, 2)
+    let k: uint32 = cast[uint32](if scientificExponent < 0: -scientificExponent else: scientificExponent)
+    if k < 10:
+      buffer[pos] = chr(ord('0') + k)
+      inc(pos)
+    elif k < 100:
+      utoa2Digits(buffer, pos, k)
+      inc(pos, 2)
+    else:
+      let q: uint32 = k div 100
+      let r: uint32 = k mod 100
+      buffer[pos] = chr(ord('0') + q)
+      inc(pos)
+      utoa2Digits(buffer, pos, r)
+      inc(pos, 2)
+  return pos
+
+proc toChars*(buffer: var openArray[char]; v: float; forceTrailingDotZero = false): int {.
+    inline.} =
+  var pos = 0
+  let significand: uint64 = physicalSignificand(constructDouble(v))
+  let exponent: uint64 = physicalExponent(constructDouble(v))
+  if exponent != maxIeeeExponent:
+    ##  Finite
+    buffer[pos] = '-'
+    inc(pos, signBit(constructDouble(v)))
+    if exponent != 0 or significand != 0:
+      ##  != 0
+      let dec = toDecimal64(significand, exponent)
+      return formatDigits(buffer, pos, dec.significand, dec.exponent.int,
+                         forceTrailingDotZero)
+    else:
+      buffer[pos] = '0'
+      buffer[pos+1] = '.'
+      buffer[pos+2] = '0'
+      buffer[pos+3] = ' '
+      inc(pos, if forceTrailingDotZero: 3 else: 1)
+      return pos
+  if significand == 0:
+    buffer[pos] = '-'
+    inc(pos, signBit(constructDouble(v)))
+    buffer[pos] = 'i'
+    buffer[pos+1] = 'n'
+    buffer[pos+2] = 'f'
+    buffer[pos+3] = ' '
+    return pos + 3
+  else:
+    buffer[pos] = 'n'
+    buffer[pos+1] = 'a'
+    buffer[pos+2] = 'n'
+    buffer[pos+3] = ' '
+    return pos + 3
+
+when false:
+  proc toString*(value: float): string =
+    var buffer: array[dtoaMinBufferLength, char]
+    let last = toChars(addr buffer, value)
+    let L = cast[int](last) - cast[int](addr(buffer))
+    result = newString(L)
+    copyMem(addr result[0], addr buffer[0], L)
+
diff --git a/lib/std/private/gitutils.nim b/lib/std/private/gitutils.nim
new file mode 100644
index 000000000..6dc9c8f3b
--- /dev/null
+++ b/lib/std/private/gitutils.nim
@@ -0,0 +1,74 @@
+##[
+internal API for now, API subject to change
+]##
+
+# xxx move other git utilities here; candidate for stdlib.
+
+import std/[os, paths, osproc, strutils, tempfiles]
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, syncio]
+
+const commitHead* = "HEAD"
+
+template retryCall*(maxRetry = 3, backoffDuration = 1.0, call: untyped): bool =
+  ## Retry `call` up to `maxRetry` times with exponential backoff and initial
+  ## duraton of `backoffDuration` seconds.
+  ## This is in particular useful for network commands that can fail.
+  runnableExamples:
+    doAssert not retryCall(maxRetry = 2, backoffDuration = 0.1, false)
+    var i = 0
+    doAssert: retryCall(maxRetry = 3, backoffDuration = 0.1, (i.inc; i >= 3))
+    doAssert retryCall(call = true)
+  var result = false
+  var t = backoffDuration
+  for i in 0..<maxRetry:
+    if call:
+      result = true
+      break
+    if i == maxRetry - 1: break
+    sleep(int(t * 1000))
+    t = t * 2 # exponential backoff
+  result
+
+proc isGitRepo*(dir: string): bool =
+  ## Avoid calling git since it depends on /bin/sh existing and fails in Nix.
+  return fileExists(dir/".git/HEAD")
+
+proc diffFiles*(path1, path2: string): tuple[output: string, same: bool] =
+  ## Returns a human readable diff of files `path1`, `path2`, the exact form of
+  ## which is implementation defined.
+  # This could be customized, e.g. non-git diff with `diff -uNdr`, or with
+  # git diff options (e.g. --color-moved, --word-diff).
+  # in general, `git diff` has more options than `diff`.
+  var status = 0
+  (result.output, status) = execCmdEx("git diff --no-index $1 $2" % [path1.quoteShell, path2.quoteShell])
+  doAssert (status == 0) or (status == 1)
+  result.same = status == 0
+
+proc diffStrings*(a, b: string): tuple[output: string, same: bool] =
+  ## Returns a human readable diff of `a`, `b`, the exact form of which is
+  ## implementation defined.
+  ## See also `experimental.diff`.
+  runnableExamples:
+    let a = "ok1\nok2\nok3\n"
+    let b = "ok1\nok2 alt\nok3\nok4\n"
+    let (c, same) = diffStrings(a, b)
+    doAssert not same
+    let (c2, same2) = diffStrings(a, a)
+    doAssert same2
+  runnableExamples("-r:off"):
+    let a = "ok1\nok2\nok3\n"
+    let b = "ok1\nok2 alt\nok3\nok4\n"
+    echo diffStrings(a, b).output
+
+  template tmpFileImpl(prefix, str): auto =
+    let path = genTempPath(prefix, "")
+    writeFile(path, str)
+    path
+  let patha = tmpFileImpl("diffStrings_a_", a)
+  let pathb = tmpFileImpl("diffStrings_b_", b)
+  defer:
+    removeFile(patha)
+    removeFile(pathb)
+  result = diffFiles(patha, pathb)
diff --git a/lib/std/private/globs.nim b/lib/std/private/globs.nim
new file mode 100644
index 000000000..a6d088558
--- /dev/null
+++ b/lib/std/private/globs.nim
@@ -0,0 +1,70 @@
+##[
+unstable API, internal use only for now.
+this can eventually be moved to std/os and `walkDirRec` can be implemented in terms of this
+to avoid duplication
+]##
+
+import std/os
+when defined(windows):
+  from std/strutils import replace
+
+when defined(nimPreviewSlimSystem):
+  import std/[assertions, objectdollar]
+
+
+when defined(nimHasEffectsOf):
+  {.experimental: "strictEffects".}
+else:
+  {.pragma: effectsOf.}
+
+type
+  PathEntry* = object
+    kind*: PathComponent
+    path*: string
+
+iterator walkDirRecFilter*(dir: string, follow: proc(entry: PathEntry): bool = nil,
+    relative = false, checkDir = true): PathEntry {.tags: [ReadDirEffect], effectsOf: follow.} =
+  ## Improved `os.walkDirRec`.
+  #[
+  note: a yieldFilter isn't needed because caller can filter at call site, without
+  loss of generality, unlike `follow`.
+
+  Future work:
+  * need to document
+  * add a `sort` option, which can be implemented efficiently only here, not at call site.
+  * provide a way to do error reporting, which is tricky because iteration cannot be resumed
+  ]#
+  var stack = @["."]
+  var checkDir = checkDir
+  var entry: PathEntry
+  while stack.len > 0:
+    let d = stack.pop()
+    for k, p in walkDir(dir / d, relative = true, checkDir = checkDir):
+      let rel = d / p
+      entry.kind = k
+      if relative: entry.path = rel
+      else: entry.path = dir / rel
+      if k in {pcDir, pcLinkToDir}:
+        if follow == nil or follow(entry): stack.add rel
+      yield entry
+    checkDir = false
+      # We only check top-level dir, otherwise if a subdir is invalid (eg. wrong
+      # permissions), it'll abort iteration and there would be no way to
+      # continue iteration.
+
+proc nativeToUnixPath*(path: string): string =
+  # pending https://github.com/nim-lang/Nim/pull/13265
+  result = path
+  when defined(windows):
+    if path.len >= 2 and path[0] in {'a'..'z', 'A'..'Z'} and path[1] == ':':
+      result[0] = '/'
+      result[1] = path[0]
+      if path.len > 2 and path[2] != '\\':
+        raiseAssert "paths like `C:foo` are currently unsupported, path: " & path
+  when DirSep == '\\':
+    result = replace(result, '\\', '/')
+
+when isMainModule:
+  import std/sugar
+  for a in walkDirRecFilter(".", follow = a=>a.path.lastPathPart notin ["nimcache", ".git", "csources_v1", "csources", "bin"]):
+    echo a
diff --git a/lib/std/private/jsutils.nim b/lib/std/private/jsutils.nim
new file mode 100644
index 000000000..5f79eab27
--- /dev/null
+++ b/lib/std/private/jsutils.nim
@@ -0,0 +1,96 @@
+when defined(js):
+  import std/jsbigints
+
+  type
+    ArrayBuffer* = ref object of JsRoot
+    Float64Array* = ref object of JsRoot
+    Uint32Array* = ref object of JsRoot
+    Uint8Array* = ref object of JsRoot
+    BigUint64Array* = ref object of JsRoot
+
+
+  func newArrayBuffer*(n: int): ArrayBuffer {.importjs: "new ArrayBuffer(#)".}
+  func newFloat64Array*(buffer: ArrayBuffer): Float64Array {.importjs: "new Float64Array(#)".}
+  func newUint32Array*(buffer: ArrayBuffer): Uint32Array {.importjs: "new Uint32Array(#)".}
+  func newBigUint64Array*(buffer: ArrayBuffer): BigUint64Array {.importjs: "new BigUint64Array(#)".}
+
+  func newUint8Array*(n: int): Uint8Array {.importjs: "new Uint8Array(#)".}
+
+  func `[]`*(arr: Uint32Array, i: int): uint32 {.importjs: "#[#]".}
+  func `[]`*(arr: Uint8Array, i: int): uint8 {.importjs: "#[#]".}
+  func `[]`*(arr: BigUint64Array, i: int): JsBigInt {.importjs: "#[#]".}
+  func `[]=`*(arr: Float64Array, i: int, v: float) {.importjs: "#[#] = #".}
+
+  proc jsTypeOf*[T](x: T): cstring {.importjs: "typeof(#)".} =
+    ## Returns the name of the JsObject's JavaScript type as a cstring.
+    # xxx replace jsffi.jsTypeOf with this definition and add tests
+    runnableExamples:
+      import std/[jsffi, jsbigints]
+      assert jsTypeOf(1.toJs) == "number"
+      assert jsTypeOf(false.toJs) == "boolean"
+      assert [1].toJs.jsTypeOf == "object" # note the difference with `getProtoName`
+      assert big"1".toJs.jsTypeOf == "bigint"
+
+  proc jsConstructorName*[T](a: T): cstring =
+    runnableExamples:
+      import std/jsffi
+      let a = array[2, float64].default
+      assert jsConstructorName(a) == "Float64Array"
+      assert jsConstructorName(a.toJs) == "Float64Array"
+    {.emit: """`result` = `a`.constructor.name;""".}
+
+  proc hasJsBigInt*(): bool =
+    {.emit: """`result` = typeof BigInt != 'undefined';""".}
+
+  proc hasBigUint64Array*(): bool =
+    {.emit: """`result` = typeof BigUint64Array != 'undefined';""".}
+
+  proc getProtoName*[T](a: T): cstring {.importjs: "Object.prototype.toString.call(#)".} =
+    runnableExamples:
+      import std/[jsffi, jsbigints]
+      type A = ref object
+      assert 1.toJs.getProtoName == "[object Number]"
+      assert "a".toJs.getProtoName == "[object String]"
+      assert big"1".toJs.getProtoName == "[object BigInt]"
+      assert false.toJs.getProtoName == "[object Boolean]"
+      assert (a: 1).toJs.getProtoName == "[object Object]"
+      assert A.default.toJs.getProtoName == "[object Null]"
+      assert [1].toJs.getProtoName == "[object Int32Array]" # implementation defined
+      assert @[1].toJs.getProtoName == "[object Array]" # ditto
+
+  const maxSafeInteger* = 9007199254740991
+    ## The same as `Number.MAX_SAFE_INTEGER` or `2^53 - 1`.
+    ## See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
+  runnableExamples:
+    let a {.importjs: "Number.MAX_SAFE_INTEGER".}: int64
+    assert a == maxSafeInteger
+
+  proc isInteger*[T](x: T): bool {.importjs: "Number.isInteger(#)".} =
+    runnableExamples:
+      import std/jsffi
+      assert 1.isInteger
+      assert not 1.5.isInteger
+      assert 1.toJs.isInteger
+      assert not 1.5.toJs.isInteger
+
+  proc isSafeInteger*[T](x: T): bool {.importjs: "Number.isSafeInteger(#)".} =
+    runnableExamples:
+      import std/jsffi
+      assert not "123".toJs.isSafeInteger
+      assert 123.isSafeInteger
+      assert 123.toJs.isSafeInteger
+      when false:
+        assert 9007199254740991.toJs.isSafeInteger
+        assert not 9007199254740992.toJs.isSafeInteger
+
+template whenJsNoBigInt64*(no64, yes64): untyped =
+  when defined(js):
+    when compiles(compileOption("jsbigint64")):
+      when compileOption("jsbigint64"):
+        yes64
+      else:
+        no64
+    else:
+      no64
+  else:
+    no64
diff --git a/lib/std/private/miscdollars.nim b/lib/std/private/miscdollars.nim
new file mode 100644
index 000000000..06fda6fa1
--- /dev/null
+++ b/lib/std/private/miscdollars.nim
@@ -0,0 +1,39 @@
+from std/private/digitsutils import addInt
+
+template toLocation*(result: var string, file: string | cstring, line: int, col: int) =
+  ## avoids spurious allocations
+  # Hopefully this can be re-used everywhere so that if a user needs to customize,
+  # it can be done in a single place.
+  result.add file
+  if line > 0:
+    result.add "("
+    addInt(result, line)
+    if col > 0:
+      result.add ", "
+      addInt(result, col)
+    result.add ")"
+
+proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
+
+template tupleObjectDollar*[T: tuple | object](result: var string, x: T) =
+  result = "("
+  const isNamed = T is object or isNamedTuple(typeof(T))
+  var count {.used.} = 0
+  for name, value in fieldPairs(x):
+    if count > 0: result.add(", ")
+    when isNamed:
+      result.add(name)
+      result.add(": ")
+    count.inc
+    when compiles($value):
+      when value isnot string and value isnot seq and compiles(value.isNil):
+        if value.isNil: result.add "nil"
+        else: result.addQuoted(value)
+      else:
+        result.addQuoted(value)
+    else:
+      result.add("...")
+  when not isNamed:
+    if count == 1:
+      result.add(",") # $(1,) should print as the semantically legal (1,)
+  result.add(")")
diff --git a/lib/std/private/ntpath.nim b/lib/std/private/ntpath.nim
new file mode 100644
index 000000000..7c8661bb7
--- /dev/null
+++ b/lib/std/private/ntpath.nim
@@ -0,0 +1,61 @@
+# This module is inspired by Python's `ntpath.py` module.
+
+import std/[
+  strutils,
+]
+
+# Adapted `splitdrive` function from the following commits in Python source
+# code:
+# 5a607a3ee5e81bdcef3f886f9d20c1376a533df4 (2009): Initial UNC handling (by Mark Hammond)
+# 2ba0fd5767577954f331ecbd53596cd8035d7186 (2022): Support for "UNC"-device paths (by Barney Gale)
+#
+# FAQ: Why use `strip` below? `\\?\UNC` is the start of a "UNC symbolic link",
+# which is a special UNC form. Running `strip` differentiates `\\?\UNC\` (a UNC
+# symbolic link) from e.g. `\\?\UNCD` (UNCD is the server in the UNC path).
+func splitDrive*(p: string): tuple[drive, path: string] =
+  ## Splits a Windows path into a drive and path part. The drive can be e.g.
+  ## `C:`. It can also be a UNC path (`\\server\drive\path`).
+  ##
+  ## The equivalent `splitDrive` for POSIX systems always returns empty drive.
+  ## Therefore this proc is only necessary on DOS-like file systems (together
+  ## with Nim's `doslikeFileSystem` conditional variable).
+  ##
+  ## This proc's use case is to extract `path` such that it can be manipulated
+  ## like a POSIX path.
+  runnableExamples:
+    doAssert splitDrive("C:") == ("C:", "")
+    doAssert splitDrive(r"C:\") == (r"C:", r"\")
+    doAssert splitDrive(r"\\server\drive\foo\bar") == (r"\\server\drive", r"\foo\bar")
+    doAssert splitDrive(r"\\?\UNC\server\share\dir") == (r"\\?\UNC\server\share", r"\dir")
+
+  result = ("", p)
+  if p.len < 2:
+    return
+  const sep = '\\'
+  let normp = p.replace('/', sep)
+  if p.len > 2 and normp[0] == sep and normp[1] == sep and normp[2] != sep:
+
+    # is a UNC path:
+    # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path
+    # \\machine\mountpoint\directory\etc\...
+    #           directory ^^^^^^^^^^^^^^^
+    let start = block:
+      const unc = "\\\\?\\UNC" # Length is 7
+      let idx = min(8, normp.len)
+      if unc == normp[0..<idx].strip(chars = {sep}, leading = false).toUpperAscii:
+        8
+      else:
+        2
+    let index = normp.find(sep, start)
+    if index == -1:
+      return
+    var index2 = normp.find(sep, index + 1)
+
+    # a UNC path can't have two slashes in a row (after the initial two)
+    if index2 == index + 1:
+      return
+    if index2 == -1:
+      index2 = p.len
+    return (p[0..<index2], p[index2..^1])
+  if p[1] == ':':
+    return (p[0..1], p[2..^1])
diff --git a/lib/std/private/osappdirs.nim b/lib/std/private/osappdirs.nim
new file mode 100644
index 000000000..07a6809bb
--- /dev/null
+++ b/lib/std/private/osappdirs.nim
@@ -0,0 +1,176 @@
+## .. importdoc:: paths.nim, dirs.nim
+
+include system/inclrtl
+import std/envvars
+import std/private/ospaths2
+
+proc getHomeDir*(): string {.rtl, extern: "nos$1",
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the home directory of the current user.
+  ##
+  ## This proc is wrapped by the `expandTilde proc`_
+  ## for the convenience of processing paths coming from user configuration files.
+  ##
+  ## See also:
+  ## * `getDataDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  runnableExamples:
+    import std/os
+    assert getHomeDir() == expandTilde("~")
+
+  when defined(windows): return getEnv("USERPROFILE") & "\\"
+  else: return getEnv("HOME") & "/"
+
+proc getDataDir*(): string {.rtl, extern: "nos$1"
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the data directory of the current user for applications.
+  ## 
+  ## On non-Windows OSs, this proc conforms to the XDG Base Directory
+  ## spec. Thus, this proc returns the value of the `XDG_DATA_HOME` environment
+  ## variable if it is set, otherwise it returns the default configuration
+  ## directory ("~/.local/share" or "~/Library/Application Support" on macOS).
+  ## 
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  when defined(windows):
+    result = getEnv("APPDATA")
+  elif defined(macosx):
+    result = getEnv("XDG_DATA_HOME", getEnv("HOME") / "Library" / "Application Support")
+  else:
+    result = getEnv("XDG_DATA_HOME", getEnv("HOME") / ".local" / "share")
+  result.normalizePathEnd(trailingSep = true)
+
+proc getConfigDir*(): string {.rtl, extern: "nos$1",
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the config directory of the current user for applications.
+  ##
+  ## On non-Windows OSs, this proc conforms to the XDG Base Directory
+  ## spec. Thus, this proc returns the value of the `XDG_CONFIG_HOME` environment
+  ## variable if it is set, otherwise it returns the default configuration
+  ## directory ("~/.config/").
+  ##
+  ## An OS-dependent trailing slash is always present at the end of the
+  ## returned string: `\\` on Windows and `/` on all other OSs.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getDataDir proc`_
+  ## * `getTempDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  when defined(windows):
+    result = getEnv("APPDATA")
+  else:
+    result = getEnv("XDG_CONFIG_HOME", getEnv("HOME") / ".config")
+  result.normalizePathEnd(trailingSep = true)
+
+proc getCacheDir*(): string =
+  ## Returns the cache directory of the current user for applications.
+  ##
+  ## This makes use of the following environment variables:
+  ##
+  ## * On Windows: `getEnv("LOCALAPPDATA")`
+  ##
+  ## * On macOS: `getEnv("XDG_CACHE_HOME", getEnv("HOME") / "Library/Caches")`
+  ##
+  ## * On other platforms: `getEnv("XDG_CACHE_HOME", getEnv("HOME") / ".cache")`
+  ##
+  ## **See also:**
+  ## * `getHomeDir proc`_
+  ## * `getTempDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getDataDir proc`_
+  # follows https://crates.io/crates/platform-dirs
+  when defined(windows):
+    result = getEnv("LOCALAPPDATA")
+  elif defined(osx):
+    result = getEnv("XDG_CACHE_HOME", getEnv("HOME") / "Library/Caches")
+  else:
+    result = getEnv("XDG_CACHE_HOME", getEnv("HOME") / ".cache")
+  result.normalizePathEnd(false)
+
+proc getCacheDir*(app: string): string =
+  ## Returns the cache directory for an application `app`.
+  ##
+  ## * On Windows, this uses: `getCacheDir() / app / "cache"`
+  ## * On other platforms, this uses: `getCacheDir() / app`
+  when defined(windows):
+    getCacheDir() / app / "cache"
+  else:
+    getCacheDir() / app
+
+
+when defined(windows):
+  type DWORD = uint32
+
+  when defined(nimPreviewSlimSystem):
+    import std/widestrs
+
+  proc getTempPath(
+    nBufferLength: DWORD, lpBuffer: WideCString
+  ): DWORD {.stdcall, dynlib: "kernel32.dll", importc: "GetTempPathW".} =
+    ## Retrieves the path of the directory designated for temporary files.
+
+template getEnvImpl(result: var string, tempDirList: openArray[string]) =
+  for dir in tempDirList:
+    if existsEnv(dir):
+      result = getEnv(dir)
+      break
+
+template getTempDirImpl(result: var string) =
+  when defined(windows):
+    getEnvImpl(result, ["TMP", "TEMP", "USERPROFILE"])
+  else:
+    getEnvImpl(result, ["TMPDIR", "TEMP", "TMP", "TEMPDIR"])
+
+proc getTempDir*(): string {.rtl, extern: "nos$1",
+  tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the temporary directory of the current user for applications to
+  ## save temporary files in.
+  ##
+  ## On Windows, it calls [GetTempPath](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw).
+  ## On Posix based platforms, it will check `TMPDIR`, `TEMP`, `TMP` and `TEMPDIR` environment variables in order.
+  ## On all platforms, `/tmp` will be returned if the procs fails.
+  ##
+  ## You can override this implementation
+  ## by adding `-d:tempDir=mytempname` to your compiler invocation.
+  ##
+  ## **Note:** This proc does not check whether the returned path exists.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  const tempDirDefault = "/tmp"
+  when defined(tempDir):
+    const tempDir {.strdefine.}: string = tempDirDefault
+    result = tempDir
+  else:
+    when nimvm:
+      getTempDirImpl(result)
+    else:
+      when defined(windows):
+        let size = getTempPath(0, nil)
+        # If the function fails, the return value is zero.
+        if size > 0:
+          let buffer = newWideCString(size.int)
+          if getTempPath(size, buffer) > 0:
+            result = $buffer
+      elif defined(android): result = "/data/local/tmp"
+      else:
+        getTempDirImpl(result)
+    if result.len == 0:
+      result = tempDirDefault
+  normalizePathEnd(result, trailingSep=true)
diff --git a/lib/std/private/oscommon.nim b/lib/std/private/oscommon.nim
new file mode 100644
index 000000000..c49d52ef2
--- /dev/null
+++ b/lib/std/private/oscommon.nim
@@ -0,0 +1,186 @@
+include system/inclrtl
+
+import std/[oserrors]
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+## .. importdoc:: osdirs.nim, os.nim
+
+const weirdTarget* = defined(nimscript) or defined(js)
+
+
+type
+  ReadDirEffect* = object of ReadIOEffect   ## Effect that denotes a read
+                                            ## operation from the directory
+                                            ## structure.
+  WriteDirEffect* = object of WriteIOEffect ## Effect that denotes a write
+                                            ## operation to
+                                            ## the directory structure.
+
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/[winlean, times]
+elif defined(posix):
+  import std/posix
+  proc c_rename(oldname, newname: cstring): cint {.
+    importc: "rename", header: "<stdio.h>".}
+else:
+  {.error: "OS module not ported to your operating system!".}
+
+
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
+
+
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
+
+
+when defined(windows) and not weirdTarget:
+  template wrapUnary*(varname, winApiProc, arg: untyped) =
+    var varname = winApiProc(newWideCString(arg))
+
+  template wrapBinary*(varname, winApiProc, arg, arg2: untyped) =
+    var varname = winApiProc(newWideCString(arg), arg2)
+  proc findFirstFile*(a: string, b: var WIN32_FIND_DATA): Handle =
+    result = findFirstFileW(newWideCString(a), b)
+  template findNextFile*(a, b: untyped): untyped = findNextFileW(a, b)
+
+  template getFilename*(f: untyped): untyped =
+    $cast[WideCString](addr(f.cFileName[0]))
+
+  proc skipFindData*(f: WIN32_FIND_DATA): bool {.inline.} =
+    # Note - takes advantage of null delimiter in the cstring
+    const dot = ord('.')
+    result = f.cFileName[0].int == dot and (f.cFileName[1].int == 0 or
+             f.cFileName[1].int == dot and f.cFileName[2].int == 0)
+
+
+type
+  PathComponent* = enum   ## Enumeration specifying a path component.
+    ##
+    ## See also:
+    ## * `walkDirRec iterator`_
+    ## * `FileInfo object`_
+    pcFile,               ## path refers to a file
+    pcLinkToFile,         ## path refers to a symbolic link to a file
+    pcDir,                ## path refers to a directory
+    pcLinkToDir           ## path refers to a symbolic link to a directory
+
+
+when defined(posix) and not weirdTarget:
+  proc getSymlinkFileKind*(path: string):
+      tuple[pc: PathComponent, isSpecial: bool] =
+    # Helper function.
+    var s: Stat
+    assert(path != "")
+    result = (pcLinkToFile, false)
+    if stat(path, s) == 0'i32:
+      if S_ISDIR(s.st_mode):
+        result = (pcLinkToDir, false)
+      elif not S_ISREG(s.st_mode):
+        result = (pcLinkToFile, true)
+
+proc tryMoveFSObject*(source, dest: string, isDir: bool): bool {.noWeirdTarget.} =
+  ## Moves a file (or directory if `isDir` is true) from `source` to `dest`.
+  ##
+  ## Returns false in case of `EXDEV` error or `AccessDeniedError` on Windows (if `isDir` is true).
+  ## In case of other errors `OSError` is raised.
+  ## Returns true in case of success.
+  when defined(windows):
+    let s = newWideCString(source)
+    let d = newWideCString(dest)
+    result = moveFileExW(s, d, MOVEFILE_COPY_ALLOWED or MOVEFILE_REPLACE_EXISTING) != 0'i32
+  else:
+    result = c_rename(source, dest) == 0'i32
+
+  if not result:
+    let err = osLastError()
+    let isAccessDeniedError =
+      when defined(windows):
+        const AccessDeniedError = OSErrorCode(5)
+        isDir and err == AccessDeniedError
+      else:
+        err == EXDEV.OSErrorCode
+    if not isAccessDeniedError:
+      raiseOSError(err, $(source, dest))
+
+when not defined(windows):
+  const maxSymlinkLen* = 1024
+
+proc fileExists*(filename: string): bool {.rtl, extern: "nos$1",
+                                          tags: [ReadDirEffect], noNimJs, sideEffect.} =
+  ## Returns true if `filename` exists and is a regular file or symlink.
+  ##
+  ## Directories, device files, named pipes and sockets return false.
+  ##
+  ## See also:
+  ## * `dirExists proc`_
+  ## * `symlinkExists proc`_
+  when defined(windows):
+    wrapUnary(a, getFileAttributesW, filename)
+    if a != -1'i32:
+      result = (a and FILE_ATTRIBUTE_DIRECTORY) == 0'i32
+  else:
+    var res: Stat
+    return stat(filename, res) >= 0'i32 and S_ISREG(res.st_mode)
+
+
+proc dirExists*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect],
+                                     noNimJs, sideEffect.} =
+  ## Returns true if the directory `dir` exists. If `dir` is a file, false
+  ## is returned. Follows symlinks.
+  ##
+  ## See also:
+  ## * `fileExists proc`_
+  ## * `symlinkExists proc`_
+  when defined(windows):
+    wrapUnary(a, getFileAttributesW, dir)
+    if a != -1'i32:
+      result = (a and FILE_ATTRIBUTE_DIRECTORY) != 0'i32
+  else:
+    var res: Stat
+    result = stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode)
+
+
+proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1",
+                                          tags: [ReadDirEffect],
+                                          noWeirdTarget, sideEffect.} =
+  ## Returns true if the symlink `link` exists. Will return true
+  ## regardless of whether the link points to a directory or file.
+  ##
+  ## See also:
+  ## * `fileExists proc`_
+  ## * `dirExists proc`_
+  when defined(windows):
+    wrapUnary(a, getFileAttributesW, link)
+    if a != -1'i32:
+      # xxx see: bug #16784 (bug9); checking `IO_REPARSE_TAG_SYMLINK`
+      # may also be needed.
+      result = (a and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32
+  else:
+    var res: Stat
+    result = lstat(link, res) >= 0'i32 and S_ISLNK(res.st_mode)
+
+when defined(windows) and not weirdTarget:
+  proc openHandle*(path: string, followSymlink=true, writeAccess=false): Handle =
+    var flags = FILE_FLAG_BACKUP_SEMANTICS or FILE_ATTRIBUTE_NORMAL
+    if not followSymlink:
+      flags = flags or FILE_FLAG_OPEN_REPARSE_POINT
+    let access = if writeAccess: GENERIC_WRITE else: 0'i32
+
+    result = createFileW(
+      newWideCString(path), access,
+      FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE,
+      nil, OPEN_EXISTING, flags, 0
+      )
diff --git a/lib/std/private/osdirs.nim b/lib/std/private/osdirs.nim
new file mode 100644
index 000000000..a44cad7d9
--- /dev/null
+++ b/lib/std/private/osdirs.nim
@@ -0,0 +1,570 @@
+## .. importdoc:: osfiles.nim, appdirs.nim, paths.nim
+
+include system/inclrtl
+import std/oserrors
+
+
+import ospaths2, osfiles
+import oscommon
+export dirExists, PathComponent
+
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/[winlean, times]
+elif defined(posix):
+  import std/[posix, times]
+
+else:
+  {.error: "OS module not ported to your operating system!".}
+
+
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
+
+
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
+
+# Templates for filtering directories and files
+when defined(windows) and not weirdTarget:
+  template isDir(f: WIN32_FIND_DATA): bool =
+    (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32
+  template isFile(f: WIN32_FIND_DATA): bool =
+    not isDir(f)
+else:
+  template isDir(f: string): bool {.dirty.} =
+    dirExists(f)
+  template isFile(f: string): bool {.dirty.} =
+    fileExists(f)
+
+template defaultWalkFilter(item): bool =
+  ## Walk filter used to return true on both
+  ## files and directories
+  true
+
+template walkCommon(pattern: string, filter) =
+  ## Common code for getting the files and directories with the
+  ## specified `pattern`
+  when defined(windows):
+    var
+      f: WIN32_FIND_DATA
+      res: int
+    res = findFirstFile(pattern, f)
+    if res != -1:
+      defer: findClose(res)
+      let dotPos = searchExtPos(pattern)
+      while true:
+        if not skipFindData(f) and filter(f):
+          # Windows bug/gotcha: 't*.nim' matches 'tfoo.nims' -.- so we check
+          # that the file extensions have the same length ...
+          let ff = getFilename(f)
+          let idx = ff.len - pattern.len + dotPos
+          if dotPos < 0 or idx >= ff.len or (idx >= 0 and ff[idx] == '.') or
+              (dotPos >= 0 and dotPos+1 < pattern.len and pattern[dotPos+1] == '*'):
+            yield splitFile(pattern).dir / extractFilename(ff)
+        if findNextFile(res, f) == 0'i32:
+          let errCode = getLastError()
+          if errCode == ERROR_NO_MORE_FILES: break
+          else: raiseOSError(errCode.OSErrorCode)
+  else: # here we use glob
+    var
+      f: Glob
+      res: int
+    f.gl_offs = 0
+    f.gl_pathc = 0
+    f.gl_pathv = nil
+    res = glob(pattern, 0, nil, addr(f))
+    defer: globfree(addr(f))
+    if res == 0:
+      for i in 0.. f.gl_pathc - 1:
+        assert(f.gl_pathv[i] != nil)
+        let path = $f.gl_pathv[i]
+        if filter(path):
+          yield path
+
+iterator walkPattern*(pattern: string): string {.tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Iterate over all the files and directories that match the `pattern`.
+  ##
+  ## On POSIX this uses the `glob`:idx: call.
+  ## `pattern` is OS dependent, but at least the `"*.ext"`
+  ## notation is supported.
+  ##
+  ## See also:
+  ## * `walkFiles iterator`_
+  ## * `walkDirs iterator`_
+  ## * `walkDir iterator`_
+  ## * `walkDirRec iterator`_
+  runnableExamples:
+    import std/os
+    import std/sequtils
+    let paths = toSeq(walkPattern("lib/pure/*")) # works on Windows too
+    assert "lib/pure/concurrency".unixToNativePath in paths
+    assert "lib/pure/os.nim".unixToNativePath in paths
+  walkCommon(pattern, defaultWalkFilter)
+
+iterator walkFiles*(pattern: string): string {.tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Iterate over all the files that match the `pattern`.
+  ##
+  ## On POSIX this uses the `glob`:idx: call.
+  ## `pattern` is OS dependent, but at least the `"*.ext"`
+  ## notation is supported.
+  ##
+  ## See also:
+  ## * `walkPattern iterator`_
+  ## * `walkDirs iterator`_
+  ## * `walkDir iterator`_
+  ## * `walkDirRec iterator`_
+  runnableExamples:
+    import std/os
+    import std/sequtils
+    assert "lib/pure/os.nim".unixToNativePath in toSeq(walkFiles("lib/pure/*.nim")) # works on Windows too
+  walkCommon(pattern, isFile)
+
+iterator walkDirs*(pattern: string): string {.tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Iterate over all the directories that match the `pattern`.
+  ##
+  ## On POSIX this uses the `glob`:idx: call.
+  ## `pattern` is OS dependent, but at least the `"*.ext"`
+  ## notation is supported.
+  ##
+  ## See also:
+  ## * `walkPattern iterator`_
+  ## * `walkFiles iterator`_
+  ## * `walkDir iterator`_
+  ## * `walkDirRec iterator`_
+  runnableExamples:
+    import std/os
+    import std/sequtils
+    let paths = toSeq(walkDirs("lib/pure/*")) # works on Windows too
+    assert "lib/pure/concurrency".unixToNativePath in paths
+  walkCommon(pattern, isDir)
+
+proc staticWalkDir(dir: string; relative: bool): seq[
+                  tuple[kind: PathComponent, path: string]] =
+  discard
+
+iterator walkDir*(dir: string; relative = false, checkDir = false,
+                  skipSpecial = false):
+  tuple[kind: PathComponent, path: string] {.tags: [ReadDirEffect].} =
+  ## Walks over the directory `dir` and yields for each directory or file in
+  ## `dir`. The component type and full path for each item are returned.
+  ##
+  ## Walking is not recursive.
+  ## * If `relative` is true (default: false)
+  ##   the resulting path is shortened to be relative to ``dir``,
+  ##   otherwise the full path is returned.
+  ## * If `checkDir` is true, `OSError` is raised when `dir`
+  ##   doesn't exist.
+  ## * If `skipSpecial` is true, then (besides all directories) only *regular*
+  ##   files (**without** special "file" objects like FIFOs, device files,
+  ##   etc) will be yielded on Unix.
+  ##
+  ## **Example:**
+  ##
+  ## This directory structure:
+  ##
+  ##     dirA / dirB / fileB1.txt
+  ##          / dirC
+  ##          / fileA1.txt
+  ##          / fileA2.txt
+  ##
+  ## and this code:
+  runnableExamples("-r:off"):
+    import std/[strutils, sugar]
+    # note: order is not guaranteed
+    # this also works at compile time
+    assert collect(for k in walkDir("dirA"): k.path).join(" ") ==
+                          "dirA/dirB dirA/dirC dirA/fileA2.txt dirA/fileA1.txt"
+  ## See also:
+  ## * `walkPattern iterator`_
+  ## * `walkFiles iterator`_
+  ## * `walkDirs iterator`_
+  ## * `walkDirRec iterator`_
+
+  when nimvm:
+    for k, v in items(staticWalkDir(dir, relative)):
+      yield (k, v)
+  else:
+    when weirdTarget:
+      for k, v in items(staticWalkDir(dir, relative)):
+        yield (k, v)
+    elif defined(windows):
+      var f: WIN32_FIND_DATA
+      var h = findFirstFile(dir / "*", f)
+      if h == -1:
+        if checkDir:
+          raiseOSError(osLastError(), dir)
+      else:
+        defer: findClose(h)
+        while true:
+          var k = pcFile
+          if not skipFindData(f):
+            if (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32:
+              k = pcDir
+            if (f.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32:
+              k = succ(k)
+            let xx = if relative: extractFilename(getFilename(f))
+                     else: dir / extractFilename(getFilename(f))
+            yield (k, xx)
+          if findNextFile(h, f) == 0'i32:
+            let errCode = getLastError()
+            if errCode == ERROR_NO_MORE_FILES: break
+            else: raiseOSError(errCode.OSErrorCode)
+    else:
+      var d = opendir(dir)
+      if d == nil:
+        if checkDir:
+          raiseOSError(osLastError(), dir)
+      else:
+        defer: discard closedir(d)
+        while true:
+          var x = readdir(d)
+          if x == nil: break
+          var y = $cast[cstring](addr x.d_name)
+          if y != "." and y != "..":
+            var s: Stat
+            let path = dir / y
+            if not relative:
+              y = path
+            var k = pcFile
+
+            template resolveSymlink() =
+              var isSpecial: bool
+              (k, isSpecial) = getSymlinkFileKind(path)
+              if skipSpecial and isSpecial: continue
+
+            template kSetGeneric() =  # pure Posix component `k` resolution
+              if lstat(path.cstring, s) < 0'i32: continue  # don't yield
+              elif S_ISDIR(s.st_mode):
+                k = pcDir
+              elif S_ISLNK(s.st_mode):
+                resolveSymlink()
+              elif skipSpecial and not S_ISREG(s.st_mode): continue
+
+            when defined(linux) or defined(macosx) or
+                 defined(bsd) or defined(genode) or defined(nintendoswitch):
+              case x.d_type
+              of DT_DIR: k = pcDir
+              of DT_LNK:
+                resolveSymlink()
+              of DT_UNKNOWN:
+                kSetGeneric()
+              else: # DT_REG or special "files" like FIFOs
+                if skipSpecial and x.d_type != DT_REG: continue
+                else: discard # leave it as pcFile
+            else:  # assuming that field `d_type` is not present
+              kSetGeneric()
+
+            yield (k, y)
+
+iterator walkDirRec*(dir: string,
+                     yieldFilter = {pcFile}, followFilter = {pcDir},
+                     relative = false, checkDir = false, skipSpecial = false):
+                    string {.tags: [ReadDirEffect].} =
+  ## Recursively walks over the directory `dir` and yields for each file
+  ## or directory in `dir`.
+  ##
+  ## Options `relative`, `checkdir`, `skipSpecial` are explained in
+  ## [walkDir iterator] description.
+  ##
+  ## .. warning:: Modifying the directory structure while the iterator
+  ##   is traversing may result in undefined behavior!
+  ##
+  ## Walking is recursive. `followFilter` controls the behaviour of the iterator:
+  ##
+  ## =====================   =============================================
+  ## yieldFilter             meaning
+  ## =====================   =============================================
+  ## ``pcFile``              yield real files (default)
+  ## ``pcLinkToFile``        yield symbolic links to files
+  ## ``pcDir``               yield real directories
+  ## ``pcLinkToDir``         yield symbolic links to directories
+  ## =====================   =============================================
+  ##
+  ## =====================   =============================================
+  ## followFilter            meaning
+  ## =====================   =============================================
+  ## ``pcDir``               follow real directories (default)
+  ## ``pcLinkToDir``         follow symbolic links to directories
+  ## =====================   =============================================
+  ##
+  ##
+  ## See also:
+  ## * `walkPattern iterator`_
+  ## * `walkFiles iterator`_
+  ## * `walkDirs iterator`_
+  ## * `walkDir iterator`_
+
+  var stack = @[""]
+  var checkDir = checkDir
+  while stack.len > 0:
+    let d = stack.pop()
+    for k, p in walkDir(dir / d, relative = true, checkDir = checkDir,
+                        skipSpecial = skipSpecial):
+      let rel = d / p
+      if k in {pcDir, pcLinkToDir} and k in followFilter:
+        stack.add rel
+      if k in yieldFilter:
+        yield if relative: rel else: dir / rel
+    checkDir = false
+      # We only check top-level dir, otherwise if a subdir is invalid (eg. wrong
+      # permissions), it'll abort iteration and there would be no way to
+      # continue iteration.
+      # Future work can provide a way to customize this and do error reporting.
+
+
+proc rawRemoveDir(dir: string) {.noWeirdTarget.} =
+  when defined(windows):
+    wrapUnary(res, removeDirectoryW, dir)
+    let lastError = osLastError()
+    if res == 0'i32 and lastError.int32 != 3'i32 and
+        lastError.int32 != 18'i32 and lastError.int32 != 2'i32:
+      raiseOSError(lastError, dir)
+  else:
+    if rmdir(dir) != 0'i32 and errno != ENOENT: raiseOSError(osLastError(), dir)
+
+proc removeDir*(dir: string, checkDir = false) {.rtl, extern: "nos$1", tags: [
+  WriteDirEffect, ReadDirEffect], benign, noWeirdTarget.} =
+  ## Removes the directory `dir` including all subdirectories and files
+  ## in `dir` (recursively).
+  ##
+  ## If this fails, `OSError` is raised. This does not fail if the directory never
+  ## existed in the first place, unless `checkDir` = true.
+  ##
+  ## See also:
+  ## * `tryRemoveFile proc`_
+  ## * `removeFile proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  ## * `copyDir proc`_
+  ## * `copyDirWithPermissions proc`_
+  ## * `moveDir proc`_
+  for kind, path in walkDir(dir, checkDir = checkDir):
+    case kind
+    of pcFile, pcLinkToFile, pcLinkToDir: removeFile(path)
+    of pcDir: removeDir(path, true)
+      # for subdirectories there is no benefit in `checkDir = false`
+      # (unless perhaps for edge case of concurrent processes also deleting
+      # the same files)
+  rawRemoveDir(dir)
+
+proc rawCreateDir(dir: string): bool {.noWeirdTarget.} =
+  # Try to create one directory (not the whole path).
+  # returns `true` for success, `false` if the path has previously existed
+  #
+  # This is a thin wrapper over mkDir (or alternatives on other systems),
+  # so in case of a pre-existing path we don't check that it is a directory.
+  when defined(solaris):
+    let res = mkdir(dir, 0o777)
+    if res == 0'i32:
+      result = true
+    elif errno in {EEXIST, ENOSYS}:
+      result = false
+    else:
+      raiseOSError(osLastError(), dir)
+  elif defined(haiku):
+    let res = mkdir(dir, 0o777)
+    if res == 0'i32:
+      result = true
+    elif errno == EEXIST or errno == EROFS:
+      result = false
+    else:
+      raiseOSError(osLastError(), dir)
+  elif defined(posix):
+    let res = mkdir(dir, 0o777)
+    if res == 0'i32:
+      result = true
+    elif errno == EEXIST:
+      result = false
+    else:
+      #echo res
+      raiseOSError(osLastError(), dir)
+  else:
+    wrapUnary(res, createDirectoryW, dir)
+
+    if res != 0'i32:
+      result = true
+    elif getLastError() == 183'i32:
+      result = false
+    else:
+      raiseOSError(osLastError(), dir)
+
+proc existsOrCreateDir*(dir: string): bool {.rtl, extern: "nos$1",
+  tags: [WriteDirEffect, ReadDirEffect], noWeirdTarget.} =
+  ## Checks if a `directory`:idx: `dir` exists, and creates it otherwise.
+  ##
+  ## Does not create parent directories (raises `OSError` if parent directories do not exist).
+  ## Returns `true` if the directory already exists, and `false` otherwise.
+  ##
+  ## See also:
+  ## * `removeDir proc`_
+  ## * `createDir proc`_
+  ## * `copyDir proc`_
+  ## * `copyDirWithPermissions proc`_
+  ## * `moveDir proc`_
+  result = not rawCreateDir(dir)
+  if result:
+    # path already exists - need to check that it is indeed a directory
+    if not dirExists(dir):
+      raise newException(IOError, "Failed to create '" & dir & "'")
+
+proc createDir*(dir: string) {.rtl, extern: "nos$1",
+  tags: [WriteDirEffect, ReadDirEffect], noWeirdTarget.} =
+  ## Creates the `directory`:idx: `dir`.
+  ##
+  ## The directory may contain several subdirectories that do not exist yet.
+  ## The full path is created. If this fails, `OSError` is raised.
+  ##
+  ## It does **not** fail if the directory already exists because for
+  ## most usages this does not indicate an error.
+  ##
+  ## See also:
+  ## * `removeDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `copyDir proc`_
+  ## * `copyDirWithPermissions proc`_
+  ## * `moveDir proc`_
+  if dir == "":
+    return
+  var omitNext = isAbsolute(dir)
+  for p in parentDirs(dir, fromRoot=true):
+    if omitNext:
+      omitNext = false
+    else:
+      discard existsOrCreateDir(p)
+
+proc copyDir*(source, dest: string, skipSpecial = false) {.rtl, extern: "nos$1",
+  tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect], benign, noWeirdTarget.} =
+  ## Copies a directory from `source` to `dest`.
+  ##
+  ## On non-Windows OSes, symlinks are copied as symlinks. On Windows, symlinks
+  ## are skipped.
+  ##
+  ## If `skipSpecial` is true, then (besides all directories) only *regular*
+  ## files (**without** special "file" objects like FIFOs, device files,
+  ## etc) will be copied on Unix.
+  ##
+  ## If this fails, `OSError` is raised.
+  ##
+  ## On the Windows platform this proc will copy the attributes from
+  ## `source` into `dest`.
+  ##
+  ## On other platforms created files and directories will inherit the
+  ## default permissions of a newly created file/directory for the user.
+  ## Use `copyDirWithPermissions proc`_
+  ## to preserve attributes recursively on these platforms.
+  ##
+  ## See also:
+  ## * `copyDirWithPermissions proc`_
+  ## * `copyFile proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `removeDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  ## * `moveDir proc`_
+  createDir(dest)
+  for kind, path in walkDir(source, skipSpecial = skipSpecial):
+    var noSource = splitPath(path).tail
+    if kind == pcDir:
+      copyDir(path, dest / noSource, skipSpecial = skipSpecial)
+    else:
+      copyFile(path, dest / noSource, {cfSymlinkAsIs})
+
+
+proc copyDirWithPermissions*(source, dest: string,
+                             ignorePermissionErrors = true,
+                             skipSpecial = false)
+  {.rtl, extern: "nos$1", tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect],
+   benign, noWeirdTarget.} =
+  ## Copies a directory from `source` to `dest` preserving file permissions.
+  ##
+  ## On non-Windows OSes, symlinks are copied as symlinks. On Windows, symlinks
+  ## are skipped.
+  ##
+  ## If `skipSpecial` is true, then (besides all directories) only *regular*
+  ## files (**without** special "file" objects like FIFOs, device files,
+  ## etc) will be copied on Unix.
+  ##
+  ## If this fails, `OSError` is raised. This is a wrapper proc around
+  ## `copyDir`_ and `copyFileWithPermissions`_ procs
+  ## on non-Windows platforms.
+  ##
+  ## On Windows this proc is just a wrapper for `copyDir proc`_ since
+  ## that proc already copies attributes.
+  ##
+  ## On non-Windows systems permissions are copied after the file or directory
+  ## itself has been copied, which won't happen atomically and could lead to a
+  ## race condition. If `ignorePermissionErrors` is true (default), errors while
+  ## reading/setting file attributes will be ignored, otherwise will raise
+  ## `OSError`.
+  ##
+  ## See also:
+  ## * `copyDir proc`_
+  ## * `copyFile proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `removeDir proc`_
+  ## * `moveDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  createDir(dest)
+  when not defined(windows):
+    try:
+      setFilePermissions(dest, getFilePermissions(source), followSymlinks =
+                         false)
+    except:
+      if not ignorePermissionErrors:
+        raise
+  for kind, path in walkDir(source, skipSpecial = skipSpecial):
+    var noSource = splitPath(path).tail
+    if kind == pcDir:
+      copyDirWithPermissions(path, dest / noSource, ignorePermissionErrors, skipSpecial = skipSpecial)
+    else:
+      copyFileWithPermissions(path, dest / noSource, ignorePermissionErrors, {cfSymlinkAsIs})
+
+proc moveDir*(source, dest: string) {.tags: [ReadIOEffect, WriteIOEffect], noWeirdTarget.} =
+  ## Moves a directory from `source` to `dest`.
+  ##
+  ## Symlinks are not followed: if `source` contains symlinks, they themself are
+  ## moved, not their target.
+  ##
+  ## If this fails, `OSError` is raised.
+  ##
+  ## See also:
+  ## * `moveFile proc`_
+  ## * `copyDir proc`_
+  ## * `copyDirWithPermissions proc`_
+  ## * `removeDir proc`_
+  ## * `existsOrCreateDir proc`_
+  ## * `createDir proc`_
+  if not tryMoveFSObject(source, dest, isDir = true):
+    # Fallback to copy & del
+    copyDir(source, dest)
+    removeDir(source)
+
+proc setCurrentDir*(newDir: string) {.inline, tags: [], noWeirdTarget.} =
+  ## Sets the `current working directory`:idx:; `OSError`
+  ## is raised if `newDir` cannot been set.
+  ##
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `getCurrentDir proc`_
+  when defined(windows):
+    if setCurrentDirectoryW(newWideCString(newDir)) == 0'i32:
+      raiseOSError(osLastError(), newDir)
+  else:
+    if chdir(newDir) != 0'i32: raiseOSError(osLastError(), newDir)
diff --git a/lib/std/private/osfiles.nim b/lib/std/private/osfiles.nim
new file mode 100644
index 000000000..37d8eabca
--- /dev/null
+++ b/lib/std/private/osfiles.nim
@@ -0,0 +1,416 @@
+include system/inclrtl
+import std/private/since
+import std/oserrors
+
+import oscommon
+export fileExists
+
+import ospaths2, ossymlinks
+
+## .. importdoc:: osdirs.nim, os.nim
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/winlean
+elif defined(posix):
+  import std/[posix, times]
+
+  proc toTime(ts: Timespec): times.Time {.inline.} =
+    result = initTime(ts.tv_sec.int64, ts.tv_nsec.int)
+else:
+  {.error: "OS module not ported to your operating system!".}
+
+
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
+
+
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
+
+
+type
+  FilePermission* = enum   ## File access permission, modelled after UNIX.
+    ##
+    ## See also:
+    ## * `getFilePermissions`_
+    ## * `setFilePermissions`_
+    ## * `FileInfo object`_
+    fpUserExec,            ## execute access for the file owner
+    fpUserWrite,           ## write access for the file owner
+    fpUserRead,            ## read access for the file owner
+    fpGroupExec,           ## execute access for the group
+    fpGroupWrite,          ## write access for the group
+    fpGroupRead,           ## read access for the group
+    fpOthersExec,          ## execute access for others
+    fpOthersWrite,         ## write access for others
+    fpOthersRead           ## read access for others
+
+proc getFilePermissions*(filename: string): set[FilePermission] {.
+  rtl, extern: "nos$1", tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Retrieves file permissions for `filename`.
+  ##
+  ## `OSError` is raised in case of an error.
+  ## On Windows, only the ``readonly`` flag is checked, every other
+  ## permission is available in any case.
+  ##
+  ## See also:
+  ## * `setFilePermissions proc`_
+  ## * `FilePermission enum`_
+  when defined(posix):
+    var a: Stat
+    if stat(filename, a) < 0'i32: raiseOSError(osLastError(), filename)
+    result = {}
+    if (a.st_mode and S_IRUSR.Mode) != 0.Mode: result.incl(fpUserRead)
+    if (a.st_mode and S_IWUSR.Mode) != 0.Mode: result.incl(fpUserWrite)
+    if (a.st_mode and S_IXUSR.Mode) != 0.Mode: result.incl(fpUserExec)
+
+    if (a.st_mode and S_IRGRP.Mode) != 0.Mode: result.incl(fpGroupRead)
+    if (a.st_mode and S_IWGRP.Mode) != 0.Mode: result.incl(fpGroupWrite)
+    if (a.st_mode and S_IXGRP.Mode) != 0.Mode: result.incl(fpGroupExec)
+
+    if (a.st_mode and S_IROTH.Mode) != 0.Mode: result.incl(fpOthersRead)
+    if (a.st_mode and S_IWOTH.Mode) != 0.Mode: result.incl(fpOthersWrite)
+    if (a.st_mode and S_IXOTH.Mode) != 0.Mode: result.incl(fpOthersExec)
+  else:
+    wrapUnary(res, getFileAttributesW, filename)
+    if res == -1'i32: raiseOSError(osLastError(), filename)
+    if (res and FILE_ATTRIBUTE_READONLY) != 0'i32:
+      result = {fpUserExec, fpUserRead, fpGroupExec, fpGroupRead,
+                fpOthersExec, fpOthersRead}
+    else:
+      result = {fpUserExec..fpOthersRead}
+
+proc setFilePermissions*(filename: string, permissions: set[FilePermission],
+                         followSymlinks = true)
+  {.rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect],
+   noWeirdTarget.} =
+  ## Sets the file permissions for `filename`.
+  ##
+  ## If `followSymlinks` set to true (default) and ``filename`` points to a
+  ## symlink, permissions are set to the file symlink points to.
+  ## `followSymlinks` set to false is a noop on Windows and some POSIX
+  ## systems (including Linux) on which `lchmod` is either unavailable or always
+  ## fails, given that symlinks permissions there are not observed.
+  ##
+  ## `OSError` is raised in case of an error.
+  ## On Windows, only the ``readonly`` flag is changed, depending on
+  ## ``fpUserWrite`` permission.
+  ##
+  ## See also:
+  ## * `getFilePermissions proc`_
+  ## * `FilePermission enum`_
+  when defined(posix):
+    var p = 0.Mode
+    if fpUserRead in permissions: p = p or S_IRUSR.Mode
+    if fpUserWrite in permissions: p = p or S_IWUSR.Mode
+    if fpUserExec in permissions: p = p or S_IXUSR.Mode
+
+    if fpGroupRead in permissions: p = p or S_IRGRP.Mode
+    if fpGroupWrite in permissions: p = p or S_IWGRP.Mode
+    if fpGroupExec in permissions: p = p or S_IXGRP.Mode
+
+    if fpOthersRead in permissions: p = p or S_IROTH.Mode
+    if fpOthersWrite in permissions: p = p or S_IWOTH.Mode
+    if fpOthersExec in permissions: p = p or S_IXOTH.Mode
+
+    if not followSymlinks and filename.symlinkExists:
+      when declared(lchmod):
+        if lchmod(filename, cast[Mode](p)) != 0:
+          raiseOSError(osLastError(), $(filename, permissions))
+    else:
+      if chmod(filename, cast[Mode](p)) != 0:
+        raiseOSError(osLastError(), $(filename, permissions))
+  else:
+    wrapUnary(res, getFileAttributesW, filename)
+    if res == -1'i32: raiseOSError(osLastError(), filename)
+    if fpUserWrite in permissions:
+      res = res and not FILE_ATTRIBUTE_READONLY
+    else:
+      res = res or FILE_ATTRIBUTE_READONLY
+    wrapBinary(res2, setFileAttributesW, filename, res)
+    if res2 == - 1'i32: raiseOSError(osLastError(), $(filename, permissions))
+
+
+const hasCCopyfile = defined(osx) and not defined(nimLegacyCopyFile)
+  # xxx instead of `nimLegacyCopyFile`, support something like: `when osxVersion >= (10, 5)`
+
+when hasCCopyfile:
+  # `copyfile` API available since osx 10.5.
+  {.push nodecl, header: "<copyfile.h>".}
+  type
+    copyfile_state_t {.nodecl.} = pointer
+    copyfile_flags_t = cint
+  proc copyfile_state_alloc(): copyfile_state_t
+  proc copyfile_state_free(state: copyfile_state_t): cint
+  proc c_copyfile(src, dst: cstring,  state: copyfile_state_t, flags: copyfile_flags_t): cint {.importc: "copyfile".}
+  when (NimMajor, NimMinor) >= (1, 4):
+    let
+      COPYFILE_DATA {.nodecl.}: copyfile_flags_t
+      COPYFILE_XATTR {.nodecl.}: copyfile_flags_t
+  else:
+    var
+      COPYFILE_DATA {.nodecl.}: copyfile_flags_t
+      COPYFILE_XATTR {.nodecl.}: copyfile_flags_t
+  {.pop.}
+
+type
+  CopyFlag* = enum    ## Copy options.
+    cfSymlinkAsIs,    ## Copy symlinks as symlinks
+    cfSymlinkFollow,  ## Copy the files symlinks point to
+    cfSymlinkIgnore   ## Ignore symlinks
+
+const copyFlagSymlink = {cfSymlinkAsIs, cfSymlinkFollow, cfSymlinkIgnore}
+
+proc copyFile*(source, dest: string, options = {cfSymlinkFollow}; bufferSize = 16_384) {.rtl,
+  extern: "nos$1", tags: [ReadDirEffect, ReadIOEffect, WriteIOEffect],
+  noWeirdTarget.} =
+  ## Copies a file from `source` to `dest`, where `dest.parentDir` must exist.
+  ##
+  ## On non-Windows OSes, `options` specify the way file is copied; by default,
+  ## if `source` is a symlink, copies the file symlink points to. `options` is
+  ## ignored on Windows: symlinks are skipped.
+  ##
+  ## If this fails, `OSError` is raised.
+  ##
+  ## On the Windows platform this proc will
+  ## copy the source file's attributes into dest.
+  ##
+  ## On other platforms you need
+  ## to use `getFilePermissions`_ and
+  ## `setFilePermissions`_
+  ## procs
+  ## to copy them by hand (or use the convenience `copyFileWithPermissions
+  ## proc`_),
+  ## otherwise `dest` will inherit the default permissions of a newly
+  ## created file for the user.
+  ##
+  ## If `dest` already exists, the file attributes
+  ## will be preserved and the content overwritten.
+  ##
+  ## On OSX, `copyfile` C api will be used (available since OSX 10.5) unless
+  ## `-d:nimLegacyCopyFile` is used.
+  ##
+  ## `copyFile` allows to specify `bufferSize` to improve I/O performance.
+  ##
+  ## See also:
+  ## * `CopyFlag enum`_
+  ## * `copyDir proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `tryRemoveFile proc`_
+  ## * `removeFile proc`_
+  ## * `moveFile proc`_
+
+  doAssert card(copyFlagSymlink * options) == 1, "There should be exactly one cfSymlink* in options"
+  let isSymlink = source.symlinkExists
+  if isSymlink and (cfSymlinkIgnore in options or defined(windows)):
+    return
+  when defined(windows):
+    let s = newWideCString(source)
+    let d = newWideCString(dest)
+    if copyFileW(s, d, 0'i32) == 0'i32:
+      raiseOSError(osLastError(), $(source, dest))
+  else:
+    if isSymlink and cfSymlinkAsIs in options:
+      createSymlink(expandSymlink(source), dest)
+    else:
+      when hasCCopyfile:
+        let state = copyfile_state_alloc()
+        # xxx `COPYFILE_STAT` could be used for one-shot
+        # `copyFileWithPermissions`.
+        let status = c_copyfile(source.cstring, dest.cstring, state,
+                                COPYFILE_DATA)
+        if status != 0:
+          let err = osLastError()
+          discard copyfile_state_free(state)
+          raiseOSError(err, $(source, dest))
+        let status2 = copyfile_state_free(state)
+        if status2 != 0: raiseOSError(osLastError(), $(source, dest))
+      else:
+        # generic version of copyFile which works for any platform:
+        var d, s: File
+        if not open(s, source): raiseOSError(osLastError(), source)
+        if not open(d, dest, fmWrite):
+          close(s)
+          raiseOSError(osLastError(), dest)
+
+        # Hints for kernel-level aggressive sequential low-fragmentation read-aheads:
+        # https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html
+        when defined(linux) or defined(osx):
+          discard posix_fadvise(getFileHandle(d), 0.cint, 0.cint, POSIX_FADV_SEQUENTIAL)
+          discard posix_fadvise(getFileHandle(s), 0.cint, 0.cint, POSIX_FADV_SEQUENTIAL)
+
+        var buf = alloc(bufferSize)
+        while true:
+          var bytesread = readBuffer(s, buf, bufferSize)
+          if bytesread > 0:
+            var byteswritten = writeBuffer(d, buf, bytesread)
+            if bytesread != byteswritten:
+              dealloc(buf)
+              close(s)
+              close(d)
+              raiseOSError(osLastError(), dest)
+          if bytesread != bufferSize: break
+        dealloc(buf)
+        close(s)
+        flushFile(d)
+        close(d)
+
+proc copyFileToDir*(source, dir: string, options = {cfSymlinkFollow}; bufferSize = 16_384)
+  {.noWeirdTarget, since: (1,3,7).} =
+  ## Copies a file `source` into directory `dir`, which must exist.
+  ##
+  ## On non-Windows OSes, `options` specify the way file is copied; by default,
+  ## if `source` is a symlink, copies the file symlink points to. `options` is
+  ## ignored on Windows: symlinks are skipped.
+  ##
+  ## `copyFileToDir` allows to specify `bufferSize` to improve I/O performance.
+  ##
+  ## See also:
+  ## * `CopyFlag enum`_
+  ## * `copyFile proc`_
+  if dir.len == 0: # treating "" as "." is error prone
+    raise newException(ValueError, "dest is empty")
+  copyFile(source, dir / source.lastPathPart, options, bufferSize)
+
+
+proc copyFileWithPermissions*(source, dest: string,
+                              ignorePermissionErrors = true,
+                              options = {cfSymlinkFollow}) {.noWeirdTarget.} =
+  ## Copies a file from `source` to `dest` preserving file permissions.
+  ##
+  ## On non-Windows OSes, `options` specify the way file is copied; by default,
+  ## if `source` is a symlink, copies the file symlink points to. `options` is
+  ## ignored on Windows: symlinks are skipped.
+  ##
+  ## This is a wrapper proc around `copyFile`_,
+  ## `getFilePermissions`_ and `setFilePermissions`_
+  ## procs on non-Windows platforms.
+  ##
+  ## On Windows this proc is just a wrapper for `copyFile proc`_ since
+  ## that proc already copies attributes.
+  ##
+  ## On non-Windows systems permissions are copied after the file itself has
+  ## been copied, which won't happen atomically and could lead to a race
+  ## condition. If `ignorePermissionErrors` is true (default), errors while
+  ## reading/setting file attributes will be ignored, otherwise will raise
+  ## `OSError`.
+  ##
+  ## See also:
+  ## * `CopyFlag enum`_
+  ## * `copyFile proc`_
+  ## * `copyDir proc`_
+  ## * `tryRemoveFile proc`_
+  ## * `removeFile proc`_
+  ## * `moveFile proc`_
+  ## * `copyDirWithPermissions proc`_
+  copyFile(source, dest, options)
+  when not defined(windows):
+    try:
+      setFilePermissions(dest, getFilePermissions(source), followSymlinks =
+                         (cfSymlinkFollow in options))
+    except:
+      if not ignorePermissionErrors:
+        raise
+
+when not declared(ENOENT) and not defined(windows):
+  when defined(nimscript):
+    when not defined(haiku):
+      const ENOENT = cint(2) # 2 on most systems including Solaris
+    else:
+      const ENOENT = cint(-2147459069)
+  else:
+    var ENOENT {.importc, header: "<errno.h>".}: cint
+
+when defined(windows) and not weirdTarget:
+  template deleteFile(file: untyped): untyped  = deleteFileW(file)
+  template setFileAttributes(file, attrs: untyped): untyped =
+    setFileAttributesW(file, attrs)
+
+proc tryRemoveFile*(file: string): bool {.rtl, extern: "nos$1", tags: [WriteDirEffect], noWeirdTarget.} =
+  ## Removes the `file`.
+  ##
+  ## If this fails, returns `false`. This does not fail
+  ## if the file never existed in the first place.
+  ##
+  ## On Windows, ignores the read-only attribute.
+  ##
+  ## See also:
+  ## * `copyFile proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `removeFile proc`_
+  ## * `moveFile proc`_
+  result = true
+  when defined(windows):
+    let f = newWideCString(file)
+    if deleteFile(f) == 0:
+      result = false
+      let err = getLastError()
+      if err == ERROR_FILE_NOT_FOUND or err == ERROR_PATH_NOT_FOUND:
+        result = true
+      elif err == ERROR_ACCESS_DENIED and
+         setFileAttributes(f, FILE_ATTRIBUTE_NORMAL) != 0 and
+         deleteFile(f) != 0:
+        result = true
+  else:
+    if unlink(file) != 0'i32 and errno != ENOENT:
+      result = false
+
+proc removeFile*(file: string) {.rtl, extern: "nos$1", tags: [WriteDirEffect], noWeirdTarget.} =
+  ## Removes the `file`.
+  ##
+  ## If this fails, `OSError` is raised. This does not fail
+  ## if the file never existed in the first place.
+  ##
+  ## On Windows, ignores the read-only attribute.
+  ##
+  ## See also:
+  ## * `removeDir proc`_
+  ## * `copyFile proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `tryRemoveFile proc`_
+  ## * `moveFile proc`_
+  if not tryRemoveFile(file):
+    raiseOSError(osLastError(), file)
+
+proc moveFile*(source, dest: string) {.rtl, extern: "nos$1",
+  tags: [ReadDirEffect, ReadIOEffect, WriteIOEffect], noWeirdTarget.} =
+  ## Moves a file from `source` to `dest`.
+  ##
+  ## Symlinks are not followed: if `source` is a symlink, it is itself moved,
+  ## not its target.
+  ##
+  ## If this fails, `OSError` is raised.
+  ## If `dest` already exists, it will be overwritten.
+  ##
+  ## Can be used to `rename files`:idx:.
+  ##
+  ## See also:
+  ## * `moveDir proc`_
+  ## * `copyFile proc`_
+  ## * `copyFileWithPermissions proc`_
+  ## * `removeFile proc`_
+  ## * `tryRemoveFile proc`_
+
+  if not tryMoveFSObject(source, dest, isDir = false):
+    when defined(windows):
+      raiseAssert "unreachable"
+    else:
+      # Fallback to copy & del
+      copyFileWithPermissions(source, dest, options={cfSymlinkAsIs})
+      try:
+        removeFile(source)
+      except:
+        discard tryRemoveFile(dest)
+        raise
diff --git a/lib/std/private/ospaths2.nim b/lib/std/private/ospaths2.nim
new file mode 100644
index 000000000..bc69ff725
--- /dev/null
+++ b/lib/std/private/ospaths2.nim
@@ -0,0 +1,1030 @@
+include system/inclrtl
+import std/private/since
+
+import std/[strutils, pathnorm]
+import std/oserrors
+
+import oscommon
+export ReadDirEffect, WriteDirEffect
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+## .. importdoc:: osappdirs.nim, osdirs.nim, osseps.nim, os.nim
+
+const weirdTarget = defined(nimscript) or defined(js)
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/winlean
+elif defined(posix):
+  import std/posix, system/ansi_c
+else:
+  {.error: "OS module not ported to your operating system!".}
+
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
+
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
+
+
+proc normalizePathAux(path: var string){.inline, raises: [], noSideEffect.}
+
+
+import std/private/osseps
+export osseps
+
+proc absolutePathInternal(path: string): string {.gcsafe.}
+
+proc normalizePathEnd*(path: var string, trailingSep = false) =
+  ## Ensures ``path`` has exactly 0 or 1 trailing `DirSep`, depending on
+  ## ``trailingSep``, and taking care of edge cases: it preservers whether
+  ## a path is absolute or relative, and makes sure trailing sep is `DirSep`,
+  ## not `AltSep`. Trailing `/.` are compressed, see examples.
+  if path.len == 0: return
+  var i = path.len
+  while i >= 1:
+    if path[i-1] in {DirSep, AltSep}: dec(i)
+    elif path[i-1] == '.' and i >= 2 and path[i-2] in {DirSep, AltSep}: dec(i)
+    else: break
+  if trailingSep:
+    # foo// => foo
+    path.setLen(i)
+    # foo => foo/
+    path.add DirSep
+  elif i > 0:
+    # foo// => foo
+    path.setLen(i)
+  else:
+    # // => / (empty case was already taken care of)
+    path = $DirSep
+
+proc normalizePathEnd*(path: string, trailingSep = false): string =
+  ## outplace overload
+  runnableExamples:
+    when defined(posix):
+      assert normalizePathEnd("/lib//.//", trailingSep = true) == "/lib/"
+      assert normalizePathEnd("lib/./.", trailingSep = false) == "lib"
+      assert normalizePathEnd(".//./.", trailingSep = false) == "."
+      assert normalizePathEnd("", trailingSep = true) == "" # not / !
+      assert normalizePathEnd("/", trailingSep = false) == "/" # not "" !
+  result = path
+  result.normalizePathEnd(trailingSep)
+
+template endsWith(a: string, b: set[char]): bool =
+  a.len > 0 and a[^1] in b
+
+proc joinPathImpl(result: var string, state: var int, tail: string) =
+  let trailingSep = tail.endsWith({DirSep, AltSep}) or tail.len == 0 and result.endsWith({DirSep, AltSep})
+  normalizePathEnd(result, trailingSep=false)
+  addNormalizePath(tail, result, state, DirSep)
+  normalizePathEnd(result, trailingSep=trailingSep)
+
+proc joinPath*(head, tail: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Joins two directory names to one.
+  ##
+  ## returns normalized path concatenation of `head` and `tail`, preserving
+  ## whether or not `tail` has a trailing slash (or, if tail if empty, whether
+  ## head has one).
+  ##
+  ## See also:
+  ## * `joinPath(parts: varargs[string]) proc`_
+  ## * `/ proc`_
+  ## * `splitPath proc`_
+  ## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
+  ## * `uri./ proc <uri.html#/,Uri,string>`_
+  runnableExamples:
+    when defined(posix):
+      assert joinPath("usr", "lib") == "usr/lib"
+      assert joinPath("usr", "lib/") == "usr/lib/"
+      assert joinPath("usr", "") == "usr"
+      assert joinPath("usr/", "") == "usr/"
+      assert joinPath("", "") == ""
+      assert joinPath("", "lib") == "lib"
+      assert joinPath("", "/lib") == "/lib"
+      assert joinPath("usr/", "/lib") == "usr/lib"
+      assert joinPath("usr/lib", "../bin") == "usr/bin"
+
+  result = newStringOfCap(head.len + tail.len)
+  var state = 0
+  joinPathImpl(result, state, head)
+  joinPathImpl(result, state, tail)
+  when false:
+    if len(head) == 0:
+      result = tail
+    elif head[len(head)-1] in {DirSep, AltSep}:
+      if tail.len > 0 and tail[0] in {DirSep, AltSep}:
+        result = head & substr(tail, 1)
+      else:
+        result = head & tail
+    else:
+      if tail.len > 0 and tail[0] in {DirSep, AltSep}:
+        result = head & tail
+      else:
+        result = head & DirSep & tail
+
+proc joinPath*(parts: varargs[string]): string {.noSideEffect,
+  rtl, extern: "nos$1OpenArray".} =
+  ## The same as `joinPath(head, tail) proc`_,
+  ## but works with any number of directory parts.
+  ##
+  ## You need to pass at least one element or the proc
+  ## will assert in debug builds and crash on release builds.
+  ##
+  ## See also:
+  ## * `joinPath(head, tail) proc`_
+  ## * `/ proc`_
+  ## * `/../ proc`_
+  ## * `splitPath proc`_
+  runnableExamples:
+    when defined(posix):
+      assert joinPath("a") == "a"
+      assert joinPath("a", "b", "c") == "a/b/c"
+      assert joinPath("usr/lib", "../../var", "log") == "var/log"
+
+  var estimatedLen = 0
+  for p in parts: estimatedLen += p.len
+  result = newStringOfCap(estimatedLen)
+  var state = 0
+  for i in 0..high(parts):
+    joinPathImpl(result, state, parts[i])
+
+proc `/`*(head, tail: string): string {.noSideEffect, inline.} =
+  ## The same as `joinPath(head, tail) proc`_.
+  ##
+  ## See also:
+  ## * `/../ proc`_
+  ## * `joinPath(head, tail) proc`_
+  ## * `joinPath(parts: varargs[string]) proc`_
+  ## * `splitPath proc`_
+  ## * `uri.combine proc <uri.html#combine,Uri,Uri>`_
+  ## * `uri./ proc <uri.html#/,Uri,string>`_
+  runnableExamples:
+    when defined(posix):
+      assert "usr" / "" == "usr"
+      assert "" / "lib" == "lib"
+      assert "" / "/lib" == "/lib"
+      assert "usr/" / "/lib/" == "usr/lib/"
+      assert "usr" / "lib" / "../bin" == "usr/bin"
+
+  result = joinPath(head, tail)
+
+when doslikeFileSystem:
+  import std/private/ntpath
+
+proc splitPath*(path: string): tuple[head, tail: string] {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Splits a directory into `(head, tail)` tuple, so that
+  ## ``head / tail == path`` (except for edge cases like "/usr").
+  ##
+  ## See also:
+  ## * `joinPath(head, tail) proc`_
+  ## * `joinPath(parts: varargs[string]) proc`_
+  ## * `/ proc`_
+  ## * `/../ proc`_
+  ## * `relativePath proc`_
+  runnableExamples:
+    assert splitPath("usr/local/bin") == ("usr/local", "bin")
+    assert splitPath("usr/local/bin/") == ("usr/local/bin", "")
+    assert splitPath("/bin/") == ("/bin", "")
+    when (NimMajor, NimMinor) <= (1, 0):
+      assert splitPath("/bin") == ("", "bin")
+    else:
+      assert splitPath("/bin") == ("/", "bin")
+    assert splitPath("bin") == ("", "bin")
+    assert splitPath("") == ("", "")
+
+  when doslikeFileSystem:
+    let (drive, splitpath) = splitDrive(path)
+    let stop = drive.len
+  else:
+    const stop = 0
+
+  var sepPos = -1
+  for i in countdown(len(path)-1, stop):
+    if path[i] in {DirSep, AltSep}:
+      sepPos = i
+      break
+  if sepPos >= 0:
+    result.head = substr(path, 0,
+      when (NimMajor, NimMinor) <= (1, 0):
+        sepPos-1
+      else:
+        if likely(sepPos >= 1): sepPos-1 else: 0
+    )
+    result.tail = substr(path, sepPos+1)
+  else:
+    when doslikeFileSystem:
+      result.head = drive
+      result.tail = splitpath
+    else:
+      result.head = ""
+      result.tail = path
+
+proc isAbsolute*(path: string): bool {.rtl, noSideEffect, extern: "nos$1", raises: [].} =
+  ## Checks whether a given `path` is absolute.
+  ##
+  ## On Windows, network paths are considered absolute too.
+  runnableExamples:
+    assert not "".isAbsolute
+    assert not ".".isAbsolute
+    when defined(posix):
+      assert "/".isAbsolute
+      assert not "a/".isAbsolute
+      assert "/a/".isAbsolute
+
+  if len(path) == 0: return false
+
+  when doslikeFileSystem:
+    var len = len(path)
+    result = (path[0] in {'/', '\\'}) or
+              (len > 1 and path[0] in {'a'..'z', 'A'..'Z'} and path[1] == ':')
+  elif defined(macos):
+    # according to https://perldoc.perl.org/File/Spec/Mac.html `:a` is a relative path
+    result = path[0] != ':'
+  elif defined(RISCOS):
+    result = path[0] == '$'
+  elif defined(posix):
+    result = path[0] == '/'
+  elif defined(nodejs):
+    {.emit: [result," = require(\"path\").isAbsolute(",path.cstring,");"].}
+  else:
+    raiseAssert "unreachable" # if ever hits here, adapt as needed
+
+when FileSystemCaseSensitive:
+  template `!=?`(a, b: char): bool = a != b
+else:
+  template `!=?`(a, b: char): bool = toLowerAscii(a) != toLowerAscii(b)
+
+when doslikeFileSystem:
+  proc isAbsFromCurrentDrive(path: string): bool {.noSideEffect, raises: [].} =
+    ## An absolute path from the root of the current drive (e.g. "\foo")
+    path.len > 0 and
+    (path[0] == AltSep or
+     (path[0] == DirSep and
+      (path.len == 1 or path[1] notin {DirSep, AltSep, ':'})))
+
+  proc sameRoot(path1, path2: string): bool {.noSideEffect, raises: [].} =
+    ## Return true if path1 and path2 have a same root.
+    ##
+    ## Detail of Windows path formats:
+    ## https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats
+
+    assert(isAbsolute(path1))
+    assert(isAbsolute(path2))
+
+    if isAbsFromCurrentDrive(path1) and isAbsFromCurrentDrive(path2):
+      result = true
+    elif cmpIgnoreCase(splitDrive(path1).drive, splitDrive(path2).drive) == 0:
+      result = true
+    else:
+      result = false
+
+proc relativePath*(path, base: string, sep = DirSep): string {.
+  rtl, extern: "nos$1".} =
+  ## Converts `path` to a path relative to `base`.
+  ##
+  ## The `sep` (default: DirSep_) is used for the path normalizations,
+  ## this can be useful to ensure the relative path only contains `'/'`
+  ## so that it can be used for URL constructions.
+  ##
+  ## On Windows, if a root of `path` and a root of `base` are different,
+  ## returns `path` as is because it is impossible to make a relative path.
+  ## That means an absolute path can be returned.
+  ##
+  ## See also:
+  ## * `splitPath proc`_
+  ## * `parentDir proc`_
+  ## * `tailDir proc`_
+  runnableExamples:
+    assert relativePath("/Users/me/bar/z.nim", "/Users/other/bad", '/') == "../../me/bar/z.nim"
+    assert relativePath("/Users/me/bar/z.nim", "/Users/other", '/') == "../me/bar/z.nim"
+    when not doslikeFileSystem: # On Windows, UNC-paths start with `//`
+      assert relativePath("/Users///me/bar//z.nim", "//Users/", '/') == "me/bar/z.nim"
+    assert relativePath("/Users/me/bar/z.nim", "/Users/me", '/') == "bar/z.nim"
+    assert relativePath("", "/users/moo", '/') == ""
+    assert relativePath("foo", ".", '/') == "foo"
+    assert relativePath("foo", "foo", '/') == "."
+
+  if path.len == 0: return ""
+  var base = if base == ".": "" else: base
+  var path = path
+  path.normalizePathAux
+  base.normalizePathAux
+  let a1 = isAbsolute(path)
+  let a2 = isAbsolute(base)
+  if a1 and not a2:
+    base = absolutePathInternal(base)
+  elif a2 and not a1:
+    path = absolutePathInternal(path)
+
+  when doslikeFileSystem:
+    if isAbsolute(path) and isAbsolute(base):
+      if not sameRoot(path, base):
+        return path
+
+  var f = default PathIter
+  var b = default PathIter
+  var ff = (0, -1)
+  var bb = (0, -1) # (int, int)
+  result = newStringOfCap(path.len)
+  # skip the common prefix:
+  while f.hasNext(path) and b.hasNext(base):
+    ff = next(f, path)
+    bb = next(b, base)
+    let diff = ff[1] - ff[0]
+    if diff != bb[1] - bb[0]: break
+    var same = true
+    for i in 0..diff:
+      if path[i + ff[0]] !=? base[i + bb[0]]:
+        same = false
+        break
+    if not same: break
+    ff = (0, -1)
+    bb = (0, -1)
+  #  for i in 0..diff:
+  #    result.add base[i + bb[0]]
+
+  # /foo/bar/xxx/ -- base
+  # /foo/bar/baz  -- path path
+  #   ../baz
+  # every directory that is in 'base', needs to add '..'
+  while true:
+    if bb[1] >= bb[0]:
+      if result.len > 0 and result[^1] != sep:
+        result.add sep
+      result.add ".."
+    if not b.hasNext(base): break
+    bb = b.next(base)
+
+  # add the rest of 'path':
+  while true:
+    if ff[1] >= ff[0]:
+      if result.len > 0 and result[^1] != sep:
+        result.add sep
+      for i in 0..ff[1] - ff[0]:
+        result.add path[i + ff[0]]
+    if not f.hasNext(path): break
+    ff = f.next(path)
+
+  when not defined(nimOldRelativePathBehavior):
+    if result.len == 0: result.add "."
+
+proc isRelativeTo*(path: string, base: string): bool {.since: (1, 1).} =
+  ## Returns true if `path` is relative to `base`.
+  runnableExamples:
+    doAssert isRelativeTo("./foo//bar", "foo")
+    doAssert isRelativeTo("foo/bar", ".")
+    doAssert isRelativeTo("/foo/bar.nim", "/foo/bar.nim")
+    doAssert not isRelativeTo("foo/bar.nims", "foo/bar.nim")
+  let path = path.normalizePath
+  let base = base.normalizePath
+  let ret = relativePath(path, base)
+  result = path.len > 0 and not ret.startsWith ".."
+
+proc parentDirPos(path: string): int =
+  var q = 1
+  if len(path) >= 1 and path[len(path)-1] in {DirSep, AltSep}: q = 2
+  for i in countdown(len(path)-q, 0):
+    if path[i] in {DirSep, AltSep}: return i
+  result = -1
+
+proc parentDir*(path: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Returns the parent directory of `path`.
+  ##
+  ## This is similar to ``splitPath(path).head`` when ``path`` doesn't end
+  ## in a dir separator, but also takes care of path normalizations.
+  ## The remainder can be obtained with `lastPathPart(path) proc`_.
+  ##
+  ## See also:
+  ## * `relativePath proc`_
+  ## * `splitPath proc`_
+  ## * `tailDir proc`_
+  ## * `parentDirs iterator`_
+  runnableExamples:
+    assert parentDir("") == ""
+    when defined(posix):
+      assert parentDir("/usr/local/bin") == "/usr/local"
+      assert parentDir("foo/bar//") == "foo"
+      assert parentDir("//foo//bar//.") == "/foo"
+      assert parentDir("./foo") == "."
+      assert parentDir("/./foo//./") == "/"
+      assert parentDir("a//./") == "."
+      assert parentDir("a/b/c/..") == "a"
+  result = pathnorm.normalizePath(path)
+  when doslikeFileSystem:
+    let (drive, splitpath) = splitDrive(result)
+    result = splitpath
+  var sepPos = parentDirPos(result)
+  if sepPos >= 0:
+    result = substr(result, 0, sepPos)
+    normalizePathEnd(result)
+  elif result == ".." or result == "." or result.len == 0 or result[^1] in {DirSep, AltSep}:
+    # `.` => `..` and .. => `../..`(etc) would be a sensible alternative
+    # `/` => `/` (as done with splitFile) would be a sensible alternative
+    result = ""
+  else:
+    result = "."
+  when doslikeFileSystem:
+    if result.len == 0:
+      discard
+    elif drive.len > 0 and result.len == 1 and result[0] in {DirSep, AltSep}:
+      result = drive
+    else:
+      result = drive & result
+
+proc tailDir*(path: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Returns the tail part of `path`.
+  ##
+  ## See also:
+  ## * `relativePath proc`_
+  ## * `splitPath proc`_
+  ## * `parentDir proc`_
+  runnableExamples:
+    assert tailDir("/bin") == "bin"
+    assert tailDir("bin") == ""
+    assert tailDir("bin/") == ""
+    assert tailDir("/usr/local/bin") == "usr/local/bin"
+    assert tailDir("//usr//local//bin//") == "usr//local//bin//"
+    assert tailDir("./usr/local/bin") == "usr/local/bin"
+    assert tailDir("usr/local/bin") == "local/bin"
+
+  var i = 0
+  when doslikeFileSystem:
+    let (drive, splitpath) = path.splitDrive
+    if drive != "":
+      return splitpath.strip(chars = {DirSep, AltSep}, trailing = false)
+  while i < len(path):
+    if path[i] in {DirSep, AltSep}:
+      while i < len(path) and path[i] in {DirSep, AltSep}: inc i
+      return substr(path, i)
+    inc i
+  result = ""
+
+proc isRootDir*(path: string): bool {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Checks whether a given `path` is a root directory.
+  runnableExamples:
+    assert isRootDir("")
+    assert isRootDir(".")
+    assert isRootDir("/")
+    assert isRootDir("a")
+    assert not isRootDir("/a")
+    assert not isRootDir("a/b/c")
+
+  when doslikeFileSystem:
+    if splitDrive(path).path == "":
+      return true
+  result = parentDirPos(path) < 0
+
+iterator parentDirs*(path: string, fromRoot=false, inclusive=true): string =
+  ## Walks over all parent directories of a given `path`.
+  ##
+  ## If `fromRoot` is true (default: false), the traversal will start from
+  ## the file system root directory.
+  ## If `inclusive` is true (default), the original argument will be included
+  ## in the traversal.
+  ##
+  ## Relative paths won't be expanded by this iterator. Instead, it will traverse
+  ## only the directories appearing in the relative path.
+  ##
+  ## See also:
+  ## * `parentDir proc`_
+  ##
+  runnableExamples:
+    let g = "a/b/c"
+
+    for p in g.parentDirs:
+      echo p
+      # a/b/c
+      # a/b
+      # a
+
+    for p in g.parentDirs(fromRoot=true):
+      echo p
+      # a/
+      # a/b/
+      # a/b/c
+
+    for p in g.parentDirs(inclusive=false):
+      echo p
+      # a/b
+      # a
+
+  if not fromRoot:
+    var current = path
+    if inclusive: yield path
+    while true:
+      if current.isRootDir: break
+      current = current.parentDir
+      yield current
+  else:
+    when doslikeFileSystem:
+      let start = path.splitDrive.drive.len
+    else:
+      const start = 0
+    for i in countup(start, path.len - 2): # ignore the last /
+      # deal with non-normalized paths such as /foo//bar//baz
+      if path[i] in {DirSep, AltSep} and
+          (i == 0 or path[i-1] notin {DirSep, AltSep}):
+        yield path.substr(0, i)
+
+    if inclusive: yield path
+
+proc `/../`*(head, tail: string): string {.noSideEffect.} =
+  ## The same as ``parentDir(head) / tail``, unless there is no parent
+  ## directory. Then ``head / tail`` is performed instead.
+  ##
+  ## See also:
+  ## * `/ proc`_
+  ## * `parentDir proc`_
+  runnableExamples:
+    when defined(posix):
+      assert "a/b/c" /../ "d/e" == "a/b/d/e"
+      assert "a" /../ "d/e" == "a/d/e"
+
+  when doslikeFileSystem:
+    let (drive, head) = splitDrive(head)
+  let sepPos = parentDirPos(head)
+  if sepPos >= 0:
+    result = substr(head, 0, sepPos-1) / tail
+  else:
+    result = head / tail
+  when doslikeFileSystem:
+    result = drive / result
+
+proc normExt(ext: string): string =
+  if ext == "" or ext[0] == ExtSep: result = ext # no copy needed here
+  else: result = ExtSep & ext
+
+proc searchExtPos*(path: string): int =
+  ## Returns index of the `'.'` char in `path` if it signifies the beginning
+  ## of the file extension. Returns -1 otherwise.
+  ##
+  ## See also:
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  runnableExamples:
+    assert searchExtPos("a/b/c") == -1
+    assert searchExtPos("c.nim") == 1
+    assert searchExtPos("a/b/c.nim") == 5
+    assert searchExtPos("a.b.c.nim") == 5
+    assert searchExtPos(".nim") == -1
+    assert searchExtPos("..nim") == -1
+    assert searchExtPos("a..nim") == 2
+
+  # Unless there is any char that is not `ExtSep` before last `ExtSep` in the file name,
+  # it is not a file extension.
+  const DirSeps = when doslikeFileSystem: {DirSep, AltSep, ':'} else: {DirSep, AltSep}
+  result = -1
+  var i = path.high
+  while i >= 1:
+    if path[i] == ExtSep:
+      break
+    elif path[i] in DirSeps:
+      return -1 # do not skip over path
+    dec i
+
+  for j in countdown(i - 1, 0):
+    if path[j] in DirSeps:
+      return -1
+    elif path[j] != ExtSep:
+      result = i
+      break
+
+proc splitFile*(path: string): tuple[dir, name, ext: string] {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Splits a filename into `(dir, name, extension)` tuple.
+  ##
+  ## `dir` does not end in DirSep_ unless it's `/`.
+  ## `extension` includes the leading dot.
+  ##
+  ## If `path` has no extension, `ext` is the empty string.
+  ## If `path` has no directory component, `dir` is the empty string.
+  ## If `path` has no filename component, `name` and `ext` are empty strings.
+  ##
+  ## See also:
+  ## * `searchExtPos proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  runnableExamples:
+    var (dir, name, ext) = splitFile("usr/local/nimc.html")
+    assert dir == "usr/local"
+    assert name == "nimc"
+    assert ext == ".html"
+    (dir, name, ext) = splitFile("/usr/local/os")
+    assert dir == "/usr/local"
+    assert name == "os"
+    assert ext == ""
+    (dir, name, ext) = splitFile("/usr/local/")
+    assert dir == "/usr/local"
+    assert name == ""
+    assert ext == ""
+    (dir, name, ext) = splitFile("/tmp.txt")
+    assert dir == "/"
+    assert name == "tmp"
+    assert ext == ".txt"
+
+  var namePos = 0
+  var dotPos = 0
+  when doslikeFileSystem:
+    let (drive, _) = splitDrive(path)
+    let stop = len(drive)
+    result.dir = drive
+  else:
+    const stop = 0
+  for i in countdown(len(path) - 1, stop):
+    if path[i] in {DirSep, AltSep} or i == 0:
+      if path[i] in {DirSep, AltSep}:
+        result.dir = substr(path, 0, if likely(i >= 1): i - 1 else: 0)
+        namePos = i + 1
+      if dotPos > i:
+        result.name = substr(path, namePos, dotPos - 1)
+        result.ext = substr(path, dotPos)
+      else:
+        result.name = substr(path, namePos)
+      break
+    elif path[i] == ExtSep and i > 0 and i < len(path) - 1 and
+         path[i - 1] notin {DirSep, AltSep} and
+         path[i + 1] != ExtSep and dotPos == 0:
+      dotPos = i
+
+proc extractFilename*(path: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Extracts the filename of a given `path`.
+  ##
+  ## This is the same as ``name & ext`` from `splitFile(path) proc`_.
+  ##
+  ## See also:
+  ## * `searchExtPos proc`_
+  ## * `splitFile proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  runnableExamples:
+    assert extractFilename("foo/bar/") == ""
+    assert extractFilename("foo/bar") == "bar"
+    assert extractFilename("foo/bar.baz") == "bar.baz"
+
+  if path.len == 0 or path[path.len-1] in {DirSep, AltSep}:
+    result = ""
+  else:
+    result = splitPath(path).tail
+
+proc lastPathPart*(path: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Like `extractFilename proc`_, but ignores
+  ## trailing dir separator; aka: `baseName`:idx: in some other languages.
+  ##
+  ## See also:
+  ## * `searchExtPos proc`_
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `changeFileExt proc`_
+  ## * `addFileExt proc`_
+  runnableExamples:
+    assert lastPathPart("foo/bar/") == "bar"
+    assert lastPathPart("foo/bar") == "bar"
+
+  let path = path.normalizePathEnd(trailingSep = false)
+  result = extractFilename(path)
+
+proc changeFileExt*(filename, ext: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Changes the file extension to `ext`.
+  ##
+  ## If the `filename` has no extension, `ext` will be added.
+  ## If `ext` == "" then any extension is removed.
+  ##
+  ## `Ext` should be given without the leading `'.'`, because some
+  ## filesystems may use a different character. (Although I know
+  ## of none such beast.)
+  ##
+  ## See also:
+  ## * `searchExtPos proc`_
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `addFileExt proc`_
+  runnableExamples:
+    assert changeFileExt("foo.bar", "baz") == "foo.baz"
+    assert changeFileExt("foo.bar", "") == "foo"
+    assert changeFileExt("foo", "baz") == "foo.baz"
+
+  var extPos = searchExtPos(filename)
+  if extPos < 0: result = filename & normExt(ext)
+  else: result = substr(filename, 0, extPos-1) & normExt(ext)
+
+proc addFileExt*(filename, ext: string): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Adds the file extension `ext` to `filename`, unless
+  ## `filename` already has an extension.
+  ##
+  ## `Ext` should be given without the leading `'.'`, because some
+  ## filesystems may use a different character.
+  ## (Although I know of none such beast.)
+  ##
+  ## See also:
+  ## * `searchExtPos proc`_
+  ## * `splitFile proc`_
+  ## * `extractFilename proc`_
+  ## * `lastPathPart proc`_
+  ## * `changeFileExt proc`_
+  runnableExamples:
+    assert addFileExt("foo.bar", "baz") == "foo.bar"
+    assert addFileExt("foo.bar", "") == "foo.bar"
+    assert addFileExt("foo", "baz") == "foo.baz"
+
+  var extPos = searchExtPos(filename)
+  if extPos < 0: result = filename & normExt(ext)
+  else: result = filename
+
+proc cmpPaths*(pathA, pathB: string): int {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Compares two paths.
+  ##
+  ## On a case-sensitive filesystem this is done
+  ## case-sensitively otherwise case-insensitively. Returns:
+  ##
+  ## | `0` if pathA == pathB
+  ## | `< 0` if pathA < pathB
+  ## | `> 0` if pathA > pathB
+  runnableExamples:
+    when defined(macosx):
+      assert cmpPaths("foo", "Foo") == 0
+    elif defined(posix):
+      assert cmpPaths("foo", "Foo") > 0
+
+  let a = normalizePath(pathA)
+  let b = normalizePath(pathB)
+  if FileSystemCaseSensitive:
+    result = cmp(a, b)
+  else:
+    when defined(nimscript):
+      result = cmpic(a, b)
+    elif defined(nimdoc): discard
+    else:
+      result = cmpIgnoreCase(a, b)
+
+proc unixToNativePath*(path: string, drive=""): string {.
+  noSideEffect, rtl, extern: "nos$1".} =
+  ## Converts an UNIX-like path to a native one.
+  ##
+  ## On an UNIX system this does nothing. Else it converts
+  ## `'/'`, `'.'`, `'..'` to the appropriate things.
+  ##
+  ## On systems with a concept of "drives", `drive` is used to determine
+  ## which drive label to use during absolute path conversion.
+  ## `drive` defaults to the drive of the current working directory, and is
+  ## ignored on systems that do not have a concept of "drives".
+  when defined(unix):
+    result = path
+  else:
+    if path.len == 0: return ""
+
+    var start: int
+    if path[0] == '/':
+      # an absolute path
+      when doslikeFileSystem:
+        if drive != "":
+          result = drive & ":" & DirSep
+        else:
+          result = $DirSep
+      elif defined(macos):
+        result = "" # must not start with ':'
+      else:
+        result = $DirSep
+      start = 1
+    elif path[0] == '.' and (path.len == 1 or path[1] == '/'):
+      # current directory
+      result = $CurDir
+      start = when doslikeFileSystem: 1 else: 2
+    else:
+      result = ""
+      start = 0
+
+    var i = start
+    while i < len(path): # ../../../ --> ::::
+      if i+2 < path.len and path[i] == '.' and path[i+1] == '.' and path[i+2] == '/':
+        # parent directory
+        when defined(macos):
+          if result[high(result)] == ':':
+            add result, ':'
+          else:
+            add result, ParDir
+        else:
+          add result, ParDir & DirSep
+        inc(i, 3)
+      elif path[i] == '/':
+        add result, DirSep
+        inc(i)
+      else:
+        add result, path[i]
+        inc(i)
+
+
+when not defined(nimscript):
+  proc getCurrentDir*(): string {.rtl, extern: "nos$1", tags: [].} =
+    ## Returns the `current working directory`:idx: i.e. where the built
+    ## binary is run.
+    ##
+    ## So the path returned by this proc is determined at run time.
+    ##
+    ## See also:
+    ## * `getHomeDir proc`_
+    ## * `getConfigDir proc`_
+    ## * `getTempDir proc`_
+    ## * `setCurrentDir proc`_
+    ## * `currentSourcePath template <system.html#currentSourcePath.t>`_
+    ## * `getProjectPath proc <macros.html#getProjectPath>`_
+    when defined(nodejs):
+      var ret: cstring
+      {.emit: "`ret` = process.cwd();".}
+      return $ret
+    elif defined(js):
+      raiseAssert "use -d:nodejs to have `getCurrentDir` defined"
+    elif defined(windows):
+      var bufsize = MAX_PATH.int32
+      var res = newWideCString(bufsize)
+      while true:
+        var L = getCurrentDirectoryW(bufsize, res)
+        if L == 0'i32:
+          raiseOSError(osLastError())
+        elif L > bufsize:
+          res = newWideCString(L)
+          bufsize = L
+        else:
+          result = res$L
+          break
+    else:
+      var bufsize = 1024 # should be enough
+      result = newString(bufsize)
+      while true:
+        if getcwd(result.cstring, bufsize) != nil:
+          setLen(result, c_strlen(result.cstring))
+          break
+        else:
+          let err = osLastError()
+          if err.int32 == ERANGE:
+            bufsize = bufsize shl 1
+            doAssert(bufsize >= 0)
+            result = newString(bufsize)
+          else:
+            raiseOSError(osLastError())
+
+proc absolutePath*(path: string, root = getCurrentDir()): string =
+  ## Returns the absolute path of `path`, rooted at `root` (which must be absolute;
+  ## default: current directory).
+  ## If `path` is absolute, return it, ignoring `root`.
+  ##
+  ## See also:
+  ## * `normalizedPath proc`_
+  ## * `normalizePath proc`_
+  runnableExamples:
+    assert absolutePath("a") == getCurrentDir() / "a"
+
+  if isAbsolute(path): path
+  else:
+    if not root.isAbsolute:
+      raise newException(ValueError, "The specified root is not absolute: " & root)
+    joinPath(root, path)
+
+proc absolutePathInternal(path: string): string =
+  absolutePath(path, getCurrentDir())
+
+
+proc normalizePath*(path: var string) {.rtl, extern: "nos$1", tags: [].} =
+  ## Normalize a path.
+  ##
+  ## Consecutive directory separators are collapsed, including an initial double slash.
+  ##
+  ## On relative paths, double dot (`..`) sequences are collapsed if possible.
+  ## On absolute paths they are always collapsed.
+  ##
+  ## .. warning:: URL-encoded and Unicode attempts at directory traversal are not detected.
+  ##   Triple dot is not handled.
+  ##
+  ## See also:
+  ## * `absolutePath proc`_
+  ## * `normalizedPath proc`_ for outplace version
+  ## * `normalizeExe proc`_
+  runnableExamples:
+    when defined(posix):
+      var a = "a///b//..//c///d"
+      a.normalizePath()
+      assert a == "a/c/d"
+
+  path = pathnorm.normalizePath(path)
+  when false:
+    let isAbs = isAbsolute(path)
+    var stack: seq[string] = @[]
+    for p in split(path, {DirSep}):
+      case p
+      of "", ".":
+        continue
+      of "..":
+        if stack.len == 0:
+          if isAbs:
+            discard  # collapse all double dots on absoluta paths
+          else:
+            stack.add(p)
+        elif stack[^1] == "..":
+          stack.add(p)
+        else:
+          discard stack.pop()
+      else:
+        stack.add(p)
+
+    if isAbs:
+      path = DirSep & join(stack, $DirSep)
+    elif stack.len > 0:
+      path = join(stack, $DirSep)
+    else:
+      path = "."
+
+proc normalizePathAux(path: var string) = normalizePath(path)
+
+proc normalizedPath*(path: string): string {.rtl, extern: "nos$1", tags: [].} =
+  ## Returns a normalized path for the current OS.
+  ##
+  ## See also:
+  ## * `absolutePath proc`_
+  ## * `normalizePath proc`_ for the in-place version
+  runnableExamples:
+    when defined(posix):
+      assert normalizedPath("a///b//..//c///d") == "a/c/d"
+  result = pathnorm.normalizePath(path)
+
+proc normalizeExe*(file: var string) {.since: (1, 3, 5).} =
+  ## on posix, prepends `./` if `file` doesn't contain `/` and is not `"", ".", ".."`.
+  runnableExamples:
+    import std/sugar
+    when defined(posix):
+      doAssert "foo".dup(normalizeExe) == "./foo"
+      doAssert "foo/../bar".dup(normalizeExe) == "foo/../bar"
+    doAssert "".dup(normalizeExe) == ""
+  when defined(posix):
+    if file.len > 0 and DirSep notin file and file != "." and file != "..":
+      file = "./" & file
+
+proc sameFile*(path1, path2: string): bool {.rtl, extern: "nos$1",
+  tags: [ReadDirEffect], noWeirdTarget.} =
+  ## Returns true if both pathname arguments refer to the same physical
+  ## file or directory.
+  ##
+  ## Raises `OSError` if any of the files does not
+  ## exist or information about it can not be obtained.
+  ##
+  ## This proc will return true if given two alternative hard-linked or
+  ## sym-linked paths to the same file or directory.
+  ##
+  ## See also:
+  ## * `sameFileContent proc`_
+  when defined(windows):
+    var success = true
+    var f1 = openHandle(path1)
+    var f2 = openHandle(path2)
+
+    var lastErr: OSErrorCode
+    if f1 != INVALID_HANDLE_VALUE and f2 != INVALID_HANDLE_VALUE:
+      var fi1, fi2: BY_HANDLE_FILE_INFORMATION
+
+      if getFileInformationByHandle(f1, addr(fi1)) != 0 and
+         getFileInformationByHandle(f2, addr(fi2)) != 0:
+        result = fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber and
+                 fi1.nFileIndexHigh == fi2.nFileIndexHigh and
+                 fi1.nFileIndexLow == fi2.nFileIndexLow
+      else:
+        lastErr = osLastError()
+        success = false
+    else:
+      lastErr = osLastError()
+      success = false
+
+    discard closeHandle(f1)
+    discard closeHandle(f2)
+
+    if not success: raiseOSError(lastErr, $(path1, path2))
+  else:
+    var a, b: Stat
+    if stat(path1, a) < 0'i32 or stat(path2, b) < 0'i32:
+      raiseOSError(osLastError(), $(path1, path2))
+    else:
+      result = a.st_dev == b.st_dev and a.st_ino == b.st_ino
diff --git a/lib/std/private/osseps.nim b/lib/std/private/osseps.nim
new file mode 100644
index 000000000..f2d49d886
--- /dev/null
+++ b/lib/std/private/osseps.nim
@@ -0,0 +1,113 @@
+# Include file that implements 'DirSep' and friends. Do not import this when
+# you also import `os.nim`!
+
+# Improved based on info in 'compiler/platform.nim'
+
+## .. importdoc:: ospaths2.nim
+
+const
+  doslikeFileSystem* = defined(windows) or defined(OS2) or defined(DOS)
+
+const
+  CurDir* =
+    when defined(macos): ':'
+    elif defined(genode): '/'
+    else: '.'
+    ## The constant character used by the operating system to refer to the
+    ## current directory.
+    ##
+    ## For example: `'.'` for POSIX or `':'` for the classic Macintosh.
+
+  ParDir* =
+    when defined(macos): "::"
+    else: ".."
+    ## The constant string used by the operating system to refer to the
+    ## parent directory.
+    ##
+    ## For example: `".."` for POSIX or `"::"` for the classic Macintosh.
+
+  DirSep* =
+    when defined(macos): ':'
+    elif doslikeFileSystem or defined(vxworks): '\\'
+    elif defined(RISCOS): '.'
+    else: '/'
+    ## The character used by the operating system to separate pathname
+    ## components, for example: `'/'` for POSIX, `':'` for the classic
+    ## Macintosh, and `'\\'` on Windows.
+
+  AltSep* =
+    when doslikeFileSystem: '/'
+    else: DirSep
+    ## An alternative character used by the operating system to separate
+    ## pathname components, or the same as DirSep_ if only one separator
+    ## character exists. This is set to `'/'` on Windows systems
+    ## where DirSep_ is a backslash (`'\\'`).
+
+  PathSep* =
+    when defined(macos) or defined(RISCOS): ','
+    elif doslikeFileSystem or defined(vxworks): ';'
+    elif defined(PalmOS) or defined(MorphOS): ':' # platform has ':' but osseps has ';'
+    else: ':'
+    ## The character conventionally used by the operating system to separate
+    ## search path components (as in PATH), such as `':'` for POSIX
+    ## or `';'` for Windows.
+
+  FileSystemCaseSensitive* =
+    when defined(macos) or defined(macosx) or doslikeFileSystem or defined(vxworks) or
+         defined(PalmOS) or defined(MorphOS): false
+    else: true
+    ## True if the file system is case sensitive, false otherwise. Used by
+    ## `cmpPaths proc`_ to compare filenames properly.
+
+  ExeExt* =
+    when doslikeFileSystem: "exe"
+    elif defined(atari): "tpp"
+    elif defined(netware): "nlm"
+    elif defined(vxworks): "vxe"
+    elif defined(nintendoswitch): "elf"
+    else: ""
+    ## The file extension of native executables. For example:
+    ## `""` for POSIX, `"exe"` on Windows (without a dot).
+
+  ScriptExt* =
+    when doslikeFileSystem: "bat"
+    else: ""
+    ## The file extension of a script file. For example: `""` for POSIX,
+    ## `"bat"` on Windows.
+
+  DynlibFormat* =
+    when defined(macos): "$1.dylib" # platform has $1Lib
+    elif defined(macosx): "lib$1.dylib"
+    elif doslikeFileSystem or defined(atari): "$1.dll"
+    elif defined(MorphOS): "$1.prc"
+    elif defined(PalmOS): "$1.prc" # platform has lib$1.so
+    elif defined(genode): "$1.lib.so"
+    elif defined(netware): "$1.nlm"
+    elif defined(amiga): "$1.Library"
+    else: "lib$1.so"
+    ## The format string to turn a filename into a `DLL`:idx: file (also
+    ## called `shared object`:idx: on some operating systems).
+
+  ExtSep* = '.'
+    ## The character which separates the base filename from the extension;
+    ## for example, the `'.'` in `os.nim`.
+
+  #  MacOS paths
+  #  ===========
+  #  MacOS directory separator is a colon ":" which is the only character not
+  #  allowed in filenames.
+  #
+  #  A path containing no colon or which begins with a colon is a partial
+  #  path.
+  #  E.g. ":kalle:petter" ":kalle" "kalle"
+  #
+  #  All other paths are full (absolute) paths. E.g. "HD:kalle:" "HD:"
+  #  When generating paths, one is safe if one ensures that all partial paths
+  #  begin with a colon, and all full paths end with a colon.
+  #  In full paths the first name (e g HD above) is the name of a mounted
+  #  volume.
+  #  These names are not unique, because, for instance, two diskettes with the
+  #  same names could be inserted. This means that paths on MacOS are not
+  #  waterproof. In case of equal names the first volume found will do.
+  #  Two colons "::" are the relative path to the parent. Three is to the
+  #  grandparent etc.
diff --git a/lib/std/private/ossymlinks.nim b/lib/std/private/ossymlinks.nim
new file mode 100644
index 000000000..c1760c42e
--- /dev/null
+++ b/lib/std/private/ossymlinks.nim
@@ -0,0 +1,78 @@
+include system/inclrtl
+import std/oserrors
+
+import oscommon
+export symlinkExists
+
+when defined(nimPreviewSlimSystem):
+  import std/[syncio, assertions, widestrs]
+
+when weirdTarget:
+  discard
+elif defined(windows):
+  import std/[winlean, times]
+elif defined(posix):
+  import std/posix
+else:
+  {.error: "OS module not ported to your operating system!".}
+
+
+when weirdTarget:
+  {.pragma: noWeirdTarget, error: "this proc is not available on the NimScript/js target".}
+else:
+  {.pragma: noWeirdTarget.}
+
+
+when defined(nimscript):
+  # for procs already defined in scriptconfig.nim
+  template noNimJs(body): untyped = discard
+elif defined(js):
+  {.pragma: noNimJs, error: "this proc is not available on the js target".}
+else:
+  {.pragma: noNimJs.}
+
+## .. importdoc:: os.nim
+
+proc createSymlink*(src, dest: string) {.noWeirdTarget.} =
+  ## Create a symbolic link at `dest` which points to the item specified
+  ## by `src`. On most operating systems, will fail if a link already exists.
+  ##
+  ## .. warning:: Some OS's (such as Microsoft Windows) restrict the creation
+  ##   of symlinks to root users (administrators) or users with developer mode enabled.
+  ##
+  ## See also:
+  ## * `createHardlink proc`_
+  ## * `expandSymlink proc`_
+
+  when defined(windows):
+    const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 2
+    # allows anyone with developer mode on to create a link
+    let flag = dirExists(src).int32 or SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+    var wSrc = newWideCString(src)
+    var wDst = newWideCString(dest)
+    if createSymbolicLinkW(wDst, wSrc, flag) == 0 or getLastError() != 0:
+      raiseOSError(osLastError(), $(src, dest))
+  else:
+    if symlink(src, dest) != 0:
+      raiseOSError(osLastError(), $(src, dest))
+
+proc expandSymlink*(symlinkPath: string): string {.noWeirdTarget.} =
+  ## Returns a string representing the path to which the symbolic link points.
+  ##
+  ## On Windows this is a noop, `symlinkPath` is simply returned.
+  ##
+  ## See also:
+  ## * `createSymlink proc`_
+  when defined(windows) or defined(nintendoswitch):
+    result = symlinkPath
+  else:
+    var bufLen = 1024
+    while true:
+      result = newString(bufLen)
+      let len = readlink(symlinkPath.cstring, result.cstring, bufLen)
+      if len < 0:
+        raiseOSError(osLastError(), symlinkPath)
+      if len < bufLen:
+        result.setLen(len)
+        break
+      bufLen = bufLen shl 1
diff --git a/lib/std/private/schubfach.nim b/lib/std/private/schubfach.nim
new file mode 100644
index 000000000..b8c85d2bc
--- /dev/null
+++ b/lib/std/private/schubfach.nim
@@ -0,0 +1,436 @@
+##  Copyright 2020 Alexander Bolz
+##
+##  Distributed under the Boost Software License, Version 1.0.
+##   (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
+
+# --------------------------------------------------------------------------------------------------
+##  This file contains an implementation of the Schubfach algorithm as described in
+##
+##  \[1] Raffaello Giulietti, "The Schubfach way to render doubles",
+##      https://drive.google.com/open?id=1luHhyQF9zKlM8yJ1nebU0OgVYhfC6CBN
+# --------------------------------------------------------------------------------------------------
+
+import std/private/digitsutils
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+template sf_Assert(x: untyped): untyped =
+  assert(x)
+
+# ==================================================================================================
+#
+# ==================================================================================================
+
+type
+  ValueType = float32
+  BitsType = uint32
+  Single {.bycopy.} = object
+    bits: BitsType
+
+const
+  significandSize: int32 = 24
+  MaxExponent = 128
+  exponentBias: int32 = MaxExponent - 1 + (significandSize - 1)
+  maxIeeeExponent: BitsType = BitsType(2 * MaxExponent - 1)
+  hiddenBit: BitsType = BitsType(1) shl (significandSize - 1)
+  significandMask: BitsType = hiddenBit - 1
+  exponentMask: BitsType = maxIeeeExponent shl (significandSize - 1)
+  signMask: BitsType = not (not BitsType(0) shr 1)
+
+proc constructSingle(bits: BitsType): Single  =
+  result.bits = bits
+
+proc constructSingle(value: ValueType): Single  =
+  result.bits = cast[typeof(result.bits)](value)
+
+proc physicalSignificand(this: Single): BitsType {.noSideEffect.} =
+  return this.bits and significandMask
+
+proc physicalExponent(this: Single): BitsType {.noSideEffect.} =
+  return (this.bits and exponentMask) shr (significandSize - 1)
+
+proc isFinite(this: Single): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) != exponentMask
+
+proc isInf(this: Single): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) == exponentMask and
+      (this.bits and significandMask) == 0
+
+proc isNaN(this: Single): bool {.noSideEffect.} =
+  return (this.bits and exponentMask) == exponentMask and
+      (this.bits and significandMask) != 0
+
+proc isZero(this: Single): bool {.noSideEffect.} =
+  return (this.bits and not signMask) == 0
+
+proc signBit(this: Single): int {.noSideEffect.} =
+  return int((this.bits and signMask) != 0)
+
+# ==================================================================================================
+##  Returns floor(x / 2^n).
+##
+##  Technically, right-shift of negative integers is implementation defined...
+##  Should easily be optimized into SAR (or equivalent) instruction.
+
+proc floorDivPow2(x: int32; n: int32): int32 {.inline.} =
+  return x shr n
+
+##  Returns floor(log_10(2^e))
+##  ```c
+##  static inline int32_t FloorLog10Pow2(int32_t e)
+##  {
+##      SF_ASSERT(e >= -1500);
+##      SF_ASSERT(e <=  1500);
+##      return FloorDivPow2(e * 1262611, 22);
+##  }
+##  ```
+##  Returns floor(log_10(3/4 2^e))
+##  ```c
+##  static inline int32_t FloorLog10ThreeQuartersPow2(int32_t e)
+##  {
+##      SF_ASSERT(e >= -1500);
+##      SF_ASSERT(e <=  1500);
+##      return FloorDivPow2(e * 1262611 - 524031, 22);
+##  }
+##  ```
+##  Returns floor(log_2(10^e))
+
+proc floorLog2Pow10(e: int32): int32 {.inline.} =
+  sf_Assert(e >= -1233)
+  sf_Assert(e <= 1233)
+  return floorDivPow2(e * 1741647, 19)
+
+const
+  kMin: int32 = -31
+  kMax: int32 = 45
+  g: array[kMax - kMin + 1, uint64] = [0x81CEB32C4B43FCF5'u64, 0xA2425FF75E14FC32'u64,
+    0xCAD2F7F5359A3B3F'u64, 0xFD87B5F28300CA0E'u64, 0x9E74D1B791E07E49'u64,
+    0xC612062576589DDB'u64, 0xF79687AED3EEC552'u64, 0x9ABE14CD44753B53'u64,
+    0xC16D9A0095928A28'u64, 0xF1C90080BAF72CB2'u64, 0x971DA05074DA7BEF'u64,
+    0xBCE5086492111AEB'u64, 0xEC1E4A7DB69561A6'u64, 0x9392EE8E921D5D08'u64,
+    0xB877AA3236A4B44A'u64, 0xE69594BEC44DE15C'u64, 0x901D7CF73AB0ACDA'u64,
+    0xB424DC35095CD810'u64, 0xE12E13424BB40E14'u64, 0x8CBCCC096F5088CC'u64,
+    0xAFEBFF0BCB24AAFF'u64, 0xDBE6FECEBDEDD5BF'u64, 0x89705F4136B4A598'u64,
+    0xABCC77118461CEFD'u64, 0xD6BF94D5E57A42BD'u64, 0x8637BD05AF6C69B6'u64,
+    0xA7C5AC471B478424'u64, 0xD1B71758E219652C'u64, 0x83126E978D4FDF3C'u64,
+    0xA3D70A3D70A3D70B'u64, 0xCCCCCCCCCCCCCCCD'u64, 0x8000000000000000'u64,
+    0xA000000000000000'u64, 0xC800000000000000'u64, 0xFA00000000000000'u64,
+    0x9C40000000000000'u64, 0xC350000000000000'u64, 0xF424000000000000'u64,
+    0x9896800000000000'u64, 0xBEBC200000000000'u64, 0xEE6B280000000000'u64,
+    0x9502F90000000000'u64, 0xBA43B74000000000'u64, 0xE8D4A51000000000'u64,
+    0x9184E72A00000000'u64, 0xB5E620F480000000'u64, 0xE35FA931A0000000'u64,
+    0x8E1BC9BF04000000'u64, 0xB1A2BC2EC5000000'u64, 0xDE0B6B3A76400000'u64,
+    0x8AC7230489E80000'u64, 0xAD78EBC5AC620000'u64, 0xD8D726B7177A8000'u64,
+    0x878678326EAC9000'u64, 0xA968163F0A57B400'u64, 0xD3C21BCECCEDA100'u64,
+    0x84595161401484A0'u64, 0xA56FA5B99019A5C8'u64, 0xCECB8F27F4200F3A'u64,
+    0x813F3978F8940985'u64, 0xA18F07D736B90BE6'u64, 0xC9F2C9CD04674EDF'u64,
+    0xFC6F7C4045812297'u64, 0x9DC5ADA82B70B59E'u64, 0xC5371912364CE306'u64,
+    0xF684DF56C3E01BC7'u64, 0x9A130B963A6C115D'u64, 0xC097CE7BC90715B4'u64,
+    0xF0BDC21ABB48DB21'u64, 0x96769950B50D88F5'u64, 0xBC143FA4E250EB32'u64,
+    0xEB194F8E1AE525FE'u64, 0x92EFD1B8D0CF37BF'u64, 0xB7ABC627050305AE'u64,
+    0xE596B7B0C643C71A'u64, 0x8F7E32CE7BEA5C70'u64, 0xB35DBF821AE4F38C'u64]
+
+proc computePow10Single(k: int32): uint64 {.inline.} =
+  ##  There are unique beta and r such that 10^k = beta 2^r and
+  ##  2^63 <= beta < 2^64, namely r = floor(log_2 10^k) - 63 and
+  ##  beta = 2^-r 10^k.
+  ##  Let g = ceil(beta), so (g-1) 2^r < 10^k <= g 2^r, with the latter
+  ##  value being a pretty good overestimate for 10^k.
+  ##  NB: Since for all the required exponents k, we have g < 2^64,
+  ##      all constants can be stored in 128-bit integers.
+  sf_Assert(k >= kMin)
+  sf_Assert(k <= kMax)
+  return g[k - kMin]
+
+proc lo32(x: uint64): uint32 {.inline.} =
+  return cast[uint32](x)
+
+proc hi32(x: uint64): uint32 {.inline.} =
+  return cast[uint32](x shr 32)
+
+when defined(sizeof_Int128):
+  proc roundToOdd(g: uint64; cp: uint32): uint32 {.inline.} =
+    let p: uint128 = uint128(g) * cp
+    let y1: uint32 = lo32(cast[uint64](p shr 64))
+    let y0: uint32 = hi32(cast[uint64](p))
+    return y1 or uint32(y0 > 1)
+
+elif defined(vcc) and defined(cpu64):
+  proc umul128(x, y: uint64, z: ptr uint64): uint64 {.importc: "_umul128", header: "<intrin.h>".}
+  proc roundToOdd(g: uint64; cpHi: uint32): uint32 {.inline.} =
+    var p1: uint64 = 0
+    var p0: uint64 = umul128(g, cpHi, addr(p1))
+    let y1: uint32 = lo32(p1)
+    let y0: uint32 = hi32(p0)
+    return y1 or uint32(y0 > 1)
+
+else:
+  proc roundToOdd(g: uint64; cp: uint32): uint32 {.inline.} =
+    let b01: uint64 = uint64(lo32(g)) * cp
+    let b11: uint64 = uint64(hi32(g)) * cp
+    let hi: uint64 = b11 + hi32(b01)
+    let y1: uint32 = hi32(hi)
+    let y0: uint32 = lo32(hi)
+    return y1 or uint32(y0 > 1)
+
+##  Returns whether value is divisible by 2^e2
+
+proc multipleOfPow2(value: uint32; e2: int32): bool {.inline.} =
+  sf_Assert(e2 >= 0)
+  sf_Assert(e2 <= 31)
+  return (value and ((uint32(1) shl e2) - 1)) == 0
+
+type
+  FloatingDecimal32 {.bycopy.} = object
+    digits: uint32            ##  num_digits <= 9
+    exponent: int32
+
+proc toDecimal32(ieeeSignificand: uint32; ieeeExponent: uint32): FloatingDecimal32 {.
+    inline.} =
+  var c: uint32
+  var q: int32
+  if ieeeExponent != 0:
+    c = hiddenBit or ieeeSignificand
+    q = cast[int32](ieeeExponent) - exponentBias
+    if 0 <= -q and -q < significandSize and multipleOfPow2(c, -q):
+      return FloatingDecimal32(digits: c shr -q, exponent: 0'i32)
+  else:
+    c = ieeeSignificand
+    q = 1 - exponentBias
+  let isEven: bool = (c mod 2 == 0)
+  let lowerBoundaryIsCloser: bool = (ieeeSignificand == 0 and ieeeExponent > 1)
+  ##   const int32_t qb = q - 2;
+  let cbl: uint32 = 4 * c - 2 + uint32(lowerBoundaryIsCloser)
+  let cb: uint32 = 4 * c
+  let cbr: uint32 = 4 * c + 2
+  ##  (q * 1262611         ) >> 22 == floor(log_10(    2^q))
+  ##  (q * 1262611 - 524031) >> 22 == floor(log_10(3/4 2^q))
+  sf_Assert(q >= -1500)
+  sf_Assert(q <= 1500)
+  let k: int32 = floorDivPow2(q * 1262611 - (if lowerBoundaryIsCloser: 524031 else: 0), 22)
+  let h: int32 = q + floorLog2Pow10(-k) + 1
+  sf_Assert(h >= 1)
+  sf_Assert(h <= 4)
+  let pow10: uint64 = computePow10Single(-k)
+  let vbl: uint32 = roundToOdd(pow10, cbl shl h)
+  let vb: uint32 = roundToOdd(pow10, cb shl h)
+  let vbr: uint32 = roundToOdd(pow10, cbr shl h)
+  let lower: uint32 = vbl + uint32(not isEven)
+  let upper: uint32 = vbr - uint32(not isEven)
+  ##  See Figure 4 in [1].
+  ##  And the modifications in Figure 6.
+  let s: uint32 = vb div 4
+  ##  NB: 4 * s == vb & ~3 == vb & -4
+  if s >= 10:
+    let sp: uint32 = s div 10
+    ##  = vb / 40
+    let upInside: bool = lower <= 40 * sp
+    let wpInside: bool = 40 * sp + 40 <= upper
+    ##       if (up_inside || wp_inside) // NB: At most one of u' and w' is in R_v.
+    if upInside != wpInside:
+      return FloatingDecimal32(digits: sp + uint32(wpInside), exponent: k + 1)
+  let uInside: bool = lower <= 4 * s
+  let wInside: bool = 4 * s + 4 <= upper
+  if uInside != wInside:
+    return FloatingDecimal32(digits: s + uint32(wInside), exponent: k)
+  let mid: uint32 = 4 * s + 2
+  ##  = 2(s + t)
+  let roundUp: bool = vb > mid or (vb == mid and (s and 1) != 0)
+  return FloatingDecimal32(digits: s + uint32(roundUp), exponent: k)
+
+## ==================================================================================================
+##  ToChars
+## ==================================================================================================
+
+proc printDecimalDigitsBackwards[T: Ordinal](buf: var openArray[char]; pos: T; output: uint32): int {.inline.} =
+  var output = output
+  var pos = pos
+  var tz = 0
+  ##  number of trailing zeros removed.
+  var nd = 0
+  ##  number of decimal digits processed.
+  ##  At most 9 digits remaining
+  if output >= 10000:
+    let q: uint32 = output div 10000
+    let r: uint32 = output mod 10000
+    output = q
+    dec(pos, 4)
+    if r != 0:
+      let rH: uint32 = r div 100
+      let rL: uint32 = r mod 100
+      utoa2Digits(buf, pos, rH)
+      utoa2Digits(buf, pos + 2, rL)
+      tz = trailingZeros2Digits(if rL == 0: rH else: rL) + (if rL == 0: 2 else: 0)
+    else:
+      tz = 4
+    nd = 4
+  if output >= 100:
+    let q: uint32 = output div 100
+    let r: uint32 = output mod 100
+    output = q
+    dec(pos, 2)
+    utoa2Digits(buf, pos, r)
+    if tz == nd:
+      inc(tz, trailingZeros2Digits(r))
+    inc(nd, 2)
+    if output >= 100:
+      let q2: uint32 = output div 100
+      let r2: uint32 = output mod 100
+      output = q2
+      dec(pos, 2)
+      utoa2Digits(buf, pos, r2)
+      if tz == nd:
+        inc(tz, trailingZeros2Digits(r2))
+      inc(nd, 2)
+  sf_Assert(output >= 1)
+  sf_Assert(output <= 99)
+  if output >= 10:
+    let q: uint32 = output
+    dec(pos, 2)
+    utoa2Digits(buf, pos, q)
+    if tz == nd:
+      inc(tz, trailingZeros2Digits(q))
+  else:
+    let q: uint32 = output
+    sf_Assert(q >= 1)
+    sf_Assert(q <= 9)
+    dec(pos)
+    buf[pos] = chr(uint32('0') + q)
+  return tz
+
+proc decimalLength(v: uint32): int {.inline.} =
+  sf_Assert(v >= 1)
+  sf_Assert(v <= 999999999'u)
+  if v >= 100000000'u:
+    return 9
+  if v >= 10000000'u:
+    return 8
+  if v >= 1000000'u:
+    return 7
+  if v >= 100000'u:
+    return 6
+  if v >= 10000'u:
+    return 5
+  if v >= 1000'u:
+    return 4
+  if v >= 100'u:
+    return 3
+  if v >= 10'u:
+    return 2
+  return 1
+
+proc formatDigits[T: Ordinal](buffer: var openArray[char]; pos: T; digits: uint32; decimalExponent: int;
+                  forceTrailingDotZero: bool = false): int {.inline.} =
+  const
+    minFixedDecimalPoint: int32 = -4
+    maxFixedDecimalPoint: int32 = 9
+  var pos = pos
+  assert(minFixedDecimalPoint <= -1, "internal error")
+  assert(maxFixedDecimalPoint >= 1, "internal error")
+  sf_Assert(digits >= 1)
+  sf_Assert(digits <= 999999999'u)
+  sf_Assert(decimalExponent >= -99)
+  sf_Assert(decimalExponent <= 99)
+  var numDigits = decimalLength(digits)
+  let decimalPoint = numDigits + decimalExponent
+  let useFixed: bool = minFixedDecimalPoint <= decimalPoint and
+      decimalPoint <= maxFixedDecimalPoint
+  ##  Prepare the buffer.
+  ##  Avoid calling memset/memcpy with variable arguments below...
+  for i in 0..<32: buffer[pos+i] = '0'
+  assert(minFixedDecimalPoint >= -30, "internal error")
+  assert(maxFixedDecimalPoint <= 32, "internal error")
+  var decimalDigitsPosition: int
+  if useFixed:
+    if decimalPoint <= 0:
+      ##  0.[000]digits
+      decimalDigitsPosition = 2 - decimalPoint
+    else:
+      ##  dig.its
+      ##  digits[000]
+      decimalDigitsPosition = 0
+  else:
+    ##  dE+123 or d.igitsE+123
+    decimalDigitsPosition = 1
+  var digitsEnd = pos + decimalDigitsPosition + numDigits
+  let tz = printDecimalDigitsBackwards(buffer, digitsEnd, digits)
+  dec(digitsEnd, tz)
+  dec(numDigits, tz)
+  ##   decimal_exponent += tz; // => decimal_point unchanged.
+  if useFixed:
+    if decimalPoint <= 0:
+      ##  0.[000]digits
+      buffer[pos+1] = '.'
+      pos = digitsEnd
+    elif decimalPoint < numDigits:
+      ##  dig.its
+      for i in countdown(7, 0):
+        buffer[i + decimalPoint + 1] = buffer[i + decimalPoint]
+      buffer[pos+decimalPoint] = '.'
+      pos = digitsEnd + 1
+    else:
+      ##  digits[000]
+      inc(pos, decimalPoint)
+      if forceTrailingDotZero:
+        buffer[pos] = '.'
+        buffer[pos+1] = '0'
+        inc(pos, 2)
+  else:
+    buffer[pos] = buffer[pos+1]
+    if numDigits == 1:
+      ##  dE+123
+      inc(pos)
+    else:
+      ##  d.igitsE+123
+      buffer[pos+1] = '.'
+      pos = digitsEnd
+    let scientificExponent = decimalPoint - 1
+    ##       SF_ASSERT(scientific_exponent != 0);
+    buffer[pos] = 'e'
+    buffer[pos+1] = if scientificExponent < 0: '-' else: '+'
+    inc(pos, 2)
+    let k: uint32 = cast[uint32](if scientificExponent < 0: -scientificExponent else: scientificExponent)
+    if k < 10:
+      buffer[pos] = chr(uint32('0') + k)
+      inc pos
+    else:
+      utoa2Digits(buffer, pos, k)
+      inc(pos, 2)
+  return pos
+
+proc float32ToChars*(buffer: var openArray[char]; v: float32; forceTrailingDotZero = false): int {.
+    inline.} =
+  let significand: uint32 = physicalSignificand(constructSingle(v))
+  let exponent: uint32 = physicalExponent(constructSingle(v))
+  var pos = 0
+  if exponent != maxIeeeExponent:
+    ##  Finite
+    buffer[pos] = '-'
+    inc(pos, signBit(constructSingle(v)))
+    if exponent != 0 or significand != 0:
+      ##  != 0
+      let dec: auto = toDecimal32(significand, exponent)
+      return formatDigits(buffer, pos, dec.digits, dec.exponent.int, forceTrailingDotZero)
+    else:
+      buffer[pos] = '0'
+      buffer[pos+1] = '.'
+      buffer[pos+2] = '0'
+      buffer[pos+3] = ' '
+      inc(pos, if forceTrailingDotZero: 3 else: 1)
+      return pos
+  if significand == 0:
+    buffer[pos] = '-'
+    inc(pos, signBit(constructSingle(v)))
+    buffer[pos] = 'i'
+    buffer[pos+1] = 'n'
+    buffer[pos+2] = 'f'
+    buffer[pos+3] = ' '
+    return pos + 3
+  else:
+    buffer[pos] = 'n'
+    buffer[pos+1] = 'a'
+    buffer[pos+2] = 'n'
+    buffer[pos+3] = ' '
+    return pos + 3
diff --git a/lib/std/private/since.nim b/lib/std/private/since.nim
new file mode 100644
index 000000000..720120f11
--- /dev/null
+++ b/lib/std/private/since.nim
@@ -0,0 +1,33 @@
+##[
+`since` is used to emulate older versions of nim stdlib,
+see `tuse_version.nim`.
+
+If a symbol `foo` is added in version `(1,3,5)`, use `{.since: (1.3.5).}`, not
+`{.since: (1.4).}`, so that it works in devel in between releases.
+
+The emulation cannot be 100% faithful and to avoid adding too much complexity,
+`since` is not needed in those cases:
+* if a new module is added
+* if an overload is added
+* if an extra parameter to an existing routine is added
+]##
+
+template since*(version: (int, int), body: untyped) {.dirty.} =
+  ## Evaluates `body` if the ``(NimMajor, NimMinor)`` is greater than
+  ## or equal to `version`. Usage:
+  ##   ```Nim
+  ##   proc fun*() {.since: (1, 3).}
+  ##   since (1, 3): fun()
+  ##   ```
+  when (NimMajor, NimMinor) >= version:
+    body
+
+template since*(version: (int, int, int), body: untyped) {.dirty.} =
+  ## Evaluates `body` if ``(NimMajor, NimMinor, NimPatch)`` is greater than 
+  ## or equal to `version`. Usage:
+  ##   ```Nim
+  ##   proc fun*() {.since: (1, 3, 1).}
+  ##   since (1, 3, 1): fun()
+  ##   ```
+  when (NimMajor, NimMinor, NimPatch) >= version:
+    body
diff --git a/lib/std/private/strimpl.nim b/lib/std/private/strimpl.nim
new file mode 100644
index 000000000..f8c9236a5
--- /dev/null
+++ b/lib/std/private/strimpl.nim
@@ -0,0 +1,113 @@
+func toLowerAscii*(c: char): char {.inline.} =
+  if c in {'A'..'Z'}:
+    result = chr(ord(c) + (ord('a') - ord('A')))
+  else:
+    result = c
+
+template firstCharCaseSensitiveImpl[T: string | cstring](a, b: T, aLen, bLen: int) =
+  if aLen == 0 or bLen == 0:
+    return aLen - bLen
+  if a[0] != b[0]: return ord(a[0]) - ord(b[0])
+
+template cmpIgnoreStyleImpl*[T: string | cstring](a, b: T,
+            firstCharCaseSensitive: static bool = false) =
+  let aLen = a.len
+  let bLen = b.len
+  var i = 0
+  var j = 0
+  when firstCharCaseSensitive:
+    firstCharCaseSensitiveImpl(a, b, aLen, bLen)
+    inc i
+    inc j
+  while true:
+    while i < aLen and a[i] == '_': inc i
+    while j < bLen and b[j] == '_': inc j
+    let aa = if i < aLen: toLowerAscii(a[i]) else: '\0'
+    let bb = if j < bLen: toLowerAscii(b[j]) else: '\0'
+    result = ord(aa) - ord(bb)
+    if result != 0: return result
+    # the characters are identical:
+    if i >= aLen:
+      # both cursors at the end:
+      if j >= bLen: return 0
+      # not yet at the end of 'b':
+      return -1
+    elif j >= bLen:
+      return 1
+    inc i
+    inc j
+
+template cmpIgnoreCaseImpl*[T: string | cstring](a, b: T,
+        firstCharCaseSensitive: static bool = false) =
+  let aLen = a.len
+  let bLen = b.len
+  var i = 0
+  when firstCharCaseSensitive:
+    firstCharCaseSensitiveImpl(a, b, aLen, bLen)
+    inc i
+  var m = min(aLen, bLen)
+  while i < m:
+    result = ord(toLowerAscii(a[i])) - ord(toLowerAscii(b[i]))
+    if result != 0: return
+    inc i
+  result = aLen - bLen
+
+template startsWithImpl*[T: string | cstring](s, prefix: T) =
+  let prefixLen = prefix.len
+  let sLen = s.len
+  var i = 0
+  while true:
+    if i >= prefixLen: return true
+    if i >= sLen or s[i] != prefix[i]: return false
+    inc(i)
+
+template endsWithImpl*[T: string | cstring](s, suffix: T) =
+  let suffixLen = suffix.len
+  let sLen = s.len
+  var i = 0
+  var j = sLen - suffixLen
+  while i+j >= 0 and i+j < sLen:
+    if s[i+j] != suffix[i]: return false
+    inc(i)
+  if i >= suffixLen: return true
+
+
+func cmpNimIdentifier*[T: string | cstring](a, b: T): int =
+  cmpIgnoreStyleImpl(a, b, true)
+
+func c_memchr(cstr: pointer, c: char, n: csize_t): pointer {.
+              importc: "memchr", header: "<string.h>".}
+func c_strstr(haystack, needle: cstring): cstring {.
+  importc: "strstr", header: "<string.h>".}
+
+
+func find*(s: cstring, sub: char, start: Natural = 0, last = 0): int =
+  ## Searches for `sub` in `s` inside the range `start..last` (both ends included).
+  ## If `last` is unspecified, it defaults to `s.high` (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Use `s[start..last].rfind` for a `start`-origin index.
+  let last = if last == 0: s.high else: last
+  let L = last-start+1
+  if L > 0:
+    let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](L))
+    if not found.isNil:
+      return cast[int](found) -% cast[int](s)
+  return -1
+
+func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
+  ## Searches for `sub` in `s` inside the range `start..last` (both ends included).
+  ## If `last` is unspecified, it defaults to `s.high` (the last element).
+  ##
+  ## Searching is case-sensitive. If `sub` is not in `s`, -1 is returned.
+  ## Otherwise the index returned is relative to `s[0]`, not `start`.
+  ## Use `s[start..last].find` for a `start`-origin index.
+  if sub.len > s.len - start: return -1
+  if sub.len == 1: return find(s, sub[0], start, last)
+  if last == 0 and s.len > start:
+    let found = c_strstr(cast[cstring](s[start].unsafeAddr), sub)
+    if not found.isNil:
+      result = cast[int](found) -% cast[int](s)
+    else:
+      result = -1
diff --git a/lib/std/private/syslocks.nim b/lib/std/private/syslocks.nim
new file mode 100644
index 000000000..e19ec2c04
--- /dev/null
+++ b/lib/std/private/syslocks.nim
@@ -0,0 +1,234 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Low level system locks and condition vars.
+
+{.push stackTrace: off.}
+
+when defined(windows):
+  type
+    Handle = int
+
+    SysLock* {.importc: "CRITICAL_SECTION",
+              header: "<windows.h>", final, pure, byref.} = object # CRITICAL_SECTION in WinApi
+      DebugInfo: pointer
+      LockCount: int32
+      RecursionCount: int32
+      OwningThread: int
+      LockSemaphore: int
+      SpinCount: int
+
+    SysCond* {.importc: "RTL_CONDITION_VARIABLE", header: "<windows.h>", byref.} = object
+      thePtr {.importc: "Ptr".} : Handle
+
+  proc initSysLock*(L: var SysLock) {.importc: "InitializeCriticalSection",
+                                     header: "<windows.h>".}
+    ## Initializes the lock `L`.
+
+  proc tryAcquireSysAux(L: var SysLock): int32 {.importc: "TryEnterCriticalSection",
+                                                 header: "<windows.h>".}
+    ## Tries to acquire the lock `L`.
+
+  proc tryAcquireSys*(L: var SysLock): bool {.inline.} =
+    result = tryAcquireSysAux(L) != 0'i32
+
+  proc acquireSys*(L: var SysLock) {.importc: "EnterCriticalSection",
+                                    header: "<windows.h>".}
+    ## Acquires the lock `L`.
+
+  proc releaseSys*(L: var SysLock) {.importc: "LeaveCriticalSection",
+                                    header: "<windows.h>".}
+    ## Releases the lock `L`.
+
+  proc deinitSys*(L: SysLock) {.importc: "DeleteCriticalSection",
+                                   header: "<windows.h>".}
+
+  proc initializeConditionVariable(
+    conditionVariable: var SysCond
+  ) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "InitializeConditionVariable".}
+
+  proc sleepConditionVariableCS(
+    conditionVariable: var SysCond,
+    PCRITICAL_SECTION: var SysLock,
+    dwMilliseconds: int
+  ): int32 {.stdcall, noSideEffect, dynlib: "kernel32", importc: "SleepConditionVariableCS".}
+
+
+  proc signalSysCond*(hEvent: var SysCond) {.stdcall, noSideEffect,
+    dynlib: "kernel32", importc: "WakeConditionVariable".}
+
+  proc broadcastSysCond*(hEvent: var SysCond) {.stdcall, noSideEffect,
+    dynlib: "kernel32", importc: "WakeAllConditionVariable".}
+
+  proc initSysCond*(cond: var SysCond) {.inline.} =
+    initializeConditionVariable(cond)
+  proc deinitSysCond*(cond: SysCond) {.inline.} =
+    discard
+  proc waitSysCond*(cond: var SysCond, lock: var SysLock) =
+    discard sleepConditionVariableCS(cond, lock, -1'i32)
+
+elif defined(genode):
+  const
+    Header = "genode_cpp/syslocks.h"
+  type
+    SysLock* {.importcpp: "Nim::SysLock", pure, final,
+              header: Header.} = object
+    SysCond* {.importcpp: "Nim::SysCond", pure, final,
+              header: Header.} = object
+
+  proc initSysLock*(L: var SysLock) = discard
+  proc deinitSys*(L: SysLock) = discard
+  proc acquireSys*(L: var SysLock) {.noSideEffect, importcpp.}
+  proc tryAcquireSys*(L: var SysLock): bool {.noSideEffect, importcpp.}
+  proc releaseSys*(L: var SysLock) {.noSideEffect, importcpp.}
+
+  proc initSysCond*(L: var SysCond) = discard
+  proc deinitSysCond*(L: SysCond) = discard
+  proc waitSysCond*(cond: var SysCond, lock: var SysLock) {.
+    noSideEffect, importcpp.}
+  proc signalSysCond*(cond: var SysCond) {.
+    noSideEffect, importcpp.}
+  proc broadcastSysCond*(cond: var SysCond) {.
+    noSideEffect, importcpp.}
+
+else:
+  type
+    SysLockObj {.importc: "pthread_mutex_t", pure, final,
+               header: """#include <sys/types.h>
+                          #include <pthread.h>""", byref.} = object
+      when defined(linux) and defined(amd64):
+        abi: array[40 div sizeof(clong), clong]
+
+    SysLockAttr* {.importc: "pthread_mutexattr_t", pure, final
+               header: """#include <sys/types.h>
+                          #include <pthread.h>""".} = object
+      when defined(linux) and defined(amd64):
+        abi: array[4 div sizeof(cint), cint]  # actually a cint
+
+    SysCondObj {.importc: "pthread_cond_t", pure, final,
+               header: """#include <sys/types.h>
+                          #include <pthread.h>""", byref.} = object
+      when defined(linux) and defined(amd64):
+        abi: array[48 div sizeof(clonglong), clonglong]
+
+    SysCondAttr {.importc: "pthread_condattr_t", pure, final
+               header: """#include <sys/types.h>
+                          #include <pthread.h>""".} = object
+      when defined(linux) and defined(amd64):
+        abi: array[4 div sizeof(cint), cint]  # actually a cint
+
+    SysLockType = distinct cint
+
+  proc initSysLockAux(L: var SysLockObj, attr: ptr SysLockAttr) {.
+    importc: "pthread_mutex_init", header: "<pthread.h>", noSideEffect.}
+  proc deinitSysAux(L: SysLockObj) {.noSideEffect,
+    importc: "pthread_mutex_destroy", header: "<pthread.h>".}
+
+  proc acquireSysAux(L: var SysLockObj) {.noSideEffect,
+    importc: "pthread_mutex_lock", header: "<pthread.h>".}
+  proc tryAcquireSysAux(L: var SysLockObj): cint {.noSideEffect,
+    importc: "pthread_mutex_trylock", header: "<pthread.h>".}
+
+  proc releaseSysAux(L: var SysLockObj) {.noSideEffect,
+    importc: "pthread_mutex_unlock", header: "<pthread.h>".}
+
+  when defined(ios):
+    # iOS will behave badly if sync primitives are moved in memory. In order
+    # to prevent this once and for all, we're doing an extra malloc when
+    # initializing the primitive.
+    type
+      SysLock* = ptr SysLockObj
+      SysCond* = ptr SysCondObj
+
+    when not declared(c_malloc):
+      proc c_malloc(size: csize_t): pointer {.
+        importc: "malloc", header: "<stdlib.h>".}
+      proc c_free(p: pointer) {.
+        importc: "free", header: "<stdlib.h>".}
+
+    proc initSysLock*(L: var SysLock, attr: ptr SysLockAttr = nil) =
+      L = cast[SysLock](c_malloc(csize_t(sizeof(SysLockObj))))
+      initSysLockAux(L[], attr)
+
+    proc deinitSys*(L: SysLock) =
+      deinitSysAux(L[])
+      c_free(L)
+
+    template acquireSys*(L: var SysLock) =
+      acquireSysAux(L[])
+    template tryAcquireSys*(L: var SysLock): bool =
+      tryAcquireSysAux(L[]) == 0'i32
+    template releaseSys*(L: var SysLock) =
+      releaseSysAux(L[])
+  else:
+    type
+      SysLock* = SysLockObj
+      SysCond* = SysCondObj
+
+    template initSysLock*(L: var SysLock, attr: ptr SysLockAttr = nil) =
+      initSysLockAux(L, attr)
+    template deinitSys*(L: SysLock) =
+      deinitSysAux(L)
+    template acquireSys*(L: var SysLock) =
+      acquireSysAux(L)
+    template tryAcquireSys*(L: var SysLock): bool =
+      tryAcquireSysAux(L) == 0'i32
+    template releaseSys*(L: var SysLock) =
+      releaseSysAux(L)
+
+  # rlocks
+  var SysLockType_Reentrant* {.importc: "PTHREAD_MUTEX_RECURSIVE",
+    header: "<pthread.h>".}: SysLockType
+  proc initSysLockAttr*(a: var SysLockAttr) {.
+    importc: "pthread_mutexattr_init", header: "<pthread.h>", noSideEffect.}
+  proc setSysLockType*(a: var SysLockAttr, t: SysLockType) {.
+    importc: "pthread_mutexattr_settype", header: "<pthread.h>", noSideEffect.}
+
+  # locks
+  proc initSysCondAux(cond: var SysCondObj, cond_attr: ptr SysCondAttr = nil) {.
+    importc: "pthread_cond_init", header: "<pthread.h>", noSideEffect.}
+  proc deinitSysCondAux(cond: SysCondObj) {.noSideEffect,
+    importc: "pthread_cond_destroy", header: "<pthread.h>".}
+
+  proc waitSysCondAux(cond: var SysCondObj, lock: var SysLockObj): cint {.
+    importc: "pthread_cond_wait", header: "<pthread.h>", noSideEffect.}
+  proc signalSysCondAux(cond: var SysCondObj) {.
+    importc: "pthread_cond_signal", header: "<pthread.h>", noSideEffect.}
+  proc broadcastSysCondAux(cond: var SysCondObj) {.
+    importc: "pthread_cond_broadcast", header: "<pthread.h>", noSideEffect.}
+
+  when defined(ios):
+    proc initSysCond*(cond: var SysCond, cond_attr: ptr SysCondAttr = nil) =
+      cond = cast[SysCond](c_malloc(csize_t(sizeof(SysCondObj))))
+      initSysCondAux(cond[], cond_attr)
+
+    proc deinitSysCond*(cond: SysCond) =
+      deinitSysCondAux(cond[])
+      c_free(cond)
+
+    template waitSysCond*(cond: var SysCond, lock: var SysLock) =
+      discard waitSysCondAux(cond[], lock[])
+    template signalSysCond*(cond: var SysCond) =
+      signalSysCondAux(cond[])
+    template broadcastSysCond*(cond: var SysCond) =
+      broadcastSysCondAux(cond[])
+  else:
+    template initSysCond*(cond: var SysCond, cond_attr: ptr SysCondAttr = nil) =
+      initSysCondAux(cond, cond_attr)
+    template deinitSysCond*(cond: SysCond) =
+      deinitSysCondAux(cond)
+
+    template waitSysCond*(cond: var SysCond, lock: var SysLock) =
+      discard waitSysCondAux(cond, lock)
+    template signalSysCond*(cond: var SysCond) =
+      signalSysCondAux(cond)
+    template broadcastSysCond*(cond: var SysCond) =
+      broadcastSysCondAux(cond)
+
+{.pop.}
diff --git a/lib/std/private/threadtypes.nim b/lib/std/private/threadtypes.nim
new file mode 100644
index 000000000..a1cdf21dc
--- /dev/null
+++ b/lib/std/private/threadtypes.nim
@@ -0,0 +1,176 @@
+include system/inclrtl
+
+const hasSharedHeap* = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own
+
+when defined(windows):
+  type
+    Handle* = int
+    SysThread* = Handle
+    WinThreadProc* = proc (x: pointer): int32 {.stdcall.}
+
+  proc createThread*(lpThreadAttributes: pointer, dwStackSize: int32,
+                     lpStartAddress: WinThreadProc,
+                     lpParameter: pointer,
+                     dwCreationFlags: int32,
+                     lpThreadId: var int32): SysThread {.
+    stdcall, dynlib: "kernel32", importc: "CreateThread".}
+
+  proc winSuspendThread*(hThread: SysThread): int32 {.
+    stdcall, dynlib: "kernel32", importc: "SuspendThread".}
+
+  proc winResumeThread*(hThread: SysThread): int32 {.
+    stdcall, dynlib: "kernel32", importc: "ResumeThread".}
+
+  proc waitForSingleObject*(hHandle: SysThread, dwMilliseconds: int32): int32 {.
+    stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".}
+
+  proc waitForMultipleObjects*(nCount: int32,
+                              lpHandles: ptr SysThread,
+                              bWaitAll: int32,
+                              dwMilliseconds: int32): int32 {.
+    stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".}
+
+  proc terminateThread*(hThread: SysThread, dwExitCode: int32): int32 {.
+    stdcall, dynlib: "kernel32", importc: "TerminateThread".}
+
+  proc setThreadAffinityMask*(hThread: SysThread, dwThreadAffinityMask: uint) {.
+    importc: "SetThreadAffinityMask", stdcall, header: "<windows.h>".}
+
+elif defined(genode):
+  const
+    GenodeHeader* = "genode_cpp/threads.h"
+  type
+    SysThread* {.importcpp: "Nim::SysThread",
+                 header: GenodeHeader, final, pure.} = object
+    GenodeThreadProc* = proc (x: pointer) {.noconv.}
+
+  proc initThread*(s: var SysThread,
+                  env: GenodeEnv,
+                  stackSize: culonglong,
+                  entry: GenodeThreadProc,
+                  arg: pointer,
+                  affinity: cuint) {.
+    importcpp: "#.initThread(@)".}
+
+
+else:
+  when not (defined(macosx) or defined(haiku)):
+    {.passl: "-pthread".}
+
+  when not defined(haiku):
+    {.passc: "-pthread".}
+
+  const
+    schedh = "#define _GNU_SOURCE\n#include <sched.h>"
+    pthreadh* = "#define _GNU_SOURCE\n#include <pthread.h>"
+
+  when not declared(Time):
+    when defined(linux):
+      type Time = clong
+    else:
+      type Time = int
+
+  when (defined(linux) or defined(nintendoswitch)) and defined(amd64):
+    type
+      SysThread* {.importc: "pthread_t",
+                  header: "<sys/types.h>" .} = distinct culong
+      Pthread_attr* {.importc: "pthread_attr_t",
+                    header: "<sys/types.h>".} = object
+        abi: array[56 div sizeof(clong), clong]
+  elif defined(openbsd) and defined(amd64):
+    type
+      SysThread* {.importc: "pthread_t", header: "<pthread.h>".} = object
+      Pthread_attr* {.importc: "pthread_attr_t",
+                       header: "<pthread.h>".} = object
+  else:
+    type
+      SysThread* {.importc: "pthread_t", header: "<sys/types.h>".} = int
+      Pthread_attr* {.importc: "pthread_attr_t",
+                       header: "<sys/types.h>".} = object
+  type
+    Timespec* {.importc: "struct timespec", header: "<time.h>".} = object
+      tv_sec*: Time
+      tv_nsec*: clong
+
+  proc pthread_attr_init*(a1: var Pthread_attr): cint {.
+    importc, header: pthreadh.}
+  proc pthread_attr_setstack*(a1: ptr Pthread_attr, a2: pointer, a3: int): cint {.
+    importc, header: pthreadh.}
+  proc pthread_attr_setstacksize*(a1: var Pthread_attr, a2: int): cint {.
+    importc, header: pthreadh.}
+  proc pthread_attr_destroy*(a1: var Pthread_attr): cint {.
+    importc, header: pthreadh.}
+
+  proc pthread_create*(a1: var SysThread, a2: var Pthread_attr,
+            a3: proc (x: pointer): pointer {.noconv.},
+            a4: pointer): cint {.importc: "pthread_create",
+            header: pthreadh.}
+  proc pthread_join*(a1: SysThread, a2: ptr pointer): cint {.
+    importc, header: pthreadh.}
+
+  proc pthread_cancel*(a1: SysThread): cint {.
+    importc: "pthread_cancel", header: pthreadh.}
+
+  type CpuSet* {.importc: "cpu_set_t", header: schedh.} = object
+     when defined(linux) and defined(amd64):
+       abi: array[1024 div (8 * sizeof(culong)), culong]
+
+  proc cpusetZero*(s: var CpuSet) {.importc: "CPU_ZERO", header: schedh.}
+  proc cpusetIncl*(cpu: cint; s: var CpuSet) {.
+    importc: "CPU_SET", header: schedh.}
+
+  when defined(android):
+    # libc of android doesn't implement pthread_setaffinity_np,
+    # it exposes pthread_gettid_np though, so we can use that in combination
+    # with sched_setaffinity to set the thread affinity.
+    type Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32 # From posix_other.nim
+
+    proc setAffinityTID*(tid: Pid; setsize: csize_t; s: var CpuSet) {.
+      importc: "sched_setaffinity", header: schedh.}
+
+    proc pthread_gettid_np*(thread: SysThread): Pid {.
+      importc: "pthread_gettid_np", header: pthreadh.}
+
+    proc setAffinity*(thread: SysThread; setsize: csize_t; s: var CpuSet) =
+      setAffinityTID(pthread_gettid_np(thread), setsize, s)
+  else:
+    proc setAffinity*(thread: SysThread; setsize: csize_t; s: var CpuSet) {.
+      importc: "pthread_setaffinity_np", header: pthreadh.}
+
+
+const
+  emulatedThreadVars* = compileOption("tlsEmulation")
+# we preallocate a fixed size for thread local storage, so that no heap
+# allocations are needed. Currently less than 16K are used on a 64bit machine.
+# We use `float` for proper alignment:
+const nimTlsSize {.intdefine.} = 16000
+type
+  ThreadLocalStorage* = array[0..(nimTlsSize div sizeof(float)), float]
+  PGcThread* = ptr GcThread
+  GcThread* {.pure, inheritable.} = object
+    when emulatedThreadVars:
+      tls*: ThreadLocalStorage
+    else:
+      nil
+    when hasSharedHeap:
+      next*, prev*: PGcThread
+      stackBottom*, stackTop*: pointer
+      stackSize*: int
+    else:
+      nil
+
+const hasAllocStack* = defined(zephyr) # maybe freertos too?
+
+type
+  Thread*[TArg] = object
+    core*: PGcThread
+    sys*: SysThread
+    when TArg is void:
+      dataFn*: proc () {.nimcall, gcsafe.}
+    else:
+      dataFn*: proc (m: TArg) {.nimcall, gcsafe.}
+      data*: TArg
+    when hasAllocStack:
+      rawStack*: pointer
+
+proc `=copy`*[TArg](x: var Thread[TArg], y: Thread[TArg]) {.error.}
diff --git a/lib/std/private/underscored_calls.nim b/lib/std/private/underscored_calls.nim
new file mode 100644
index 000000000..f853572b5
--- /dev/null
+++ b/lib/std/private/underscored_calls.nim
@@ -0,0 +1,56 @@
+
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This is an internal helper module. Do not use.
+
+import std/macros
+
+proc underscoredCalls*(result, calls, arg0: NimNode)
+
+proc underscoredCall(n, arg0: NimNode): NimNode =
+  proc underscorePos(n: NimNode): int =
+    for i in 1 ..< n.len:
+      if n[i].eqIdent("_"): return i
+    return 0
+
+  if n.kind in nnkCallKinds:
+    if n[0].kind in {nnkIdent, nnkSym} and n[0].eqIdent("with"):
+      expectKind n[1], {nnkIdent, nnkSym}
+
+      result = newStmtList()
+      underscoredCalls(result, n[2 .. ^1].newStmtList, newDotExpr(arg0, n[1]))
+    else:
+      result = copyNimNode(n)
+      result.add n[0]
+
+      let u = underscorePos(n)
+      for i in 1..u-1: result.add n[i]
+      result.add arg0
+      for i in u+1..n.len-1: result.add n[i]
+  elif n.kind in {nnkAsgn, nnkExprEqExpr}:
+    var field = n[0]
+    if n[0].kind == nnkDotExpr and n[0][0].eqIdent("_"):
+      # handle _.field = ...
+      field = n[0][1]
+    result = newDotExpr(arg0, field).newAssignment n[1]
+  else:
+    # handle e.g. 'x.dup(sort)'
+    result = newNimNode(nnkCall, n)
+    result.add n
+    result.add arg0
+
+proc underscoredCalls*(result, calls, arg0: NimNode) =
+  expectKind calls, {nnkArgList, nnkStmtList, nnkStmtListExpr}
+
+  for call in calls:
+    if call.kind in {nnkStmtList, nnkStmtListExpr}:
+      underscoredCalls(result, call, arg0)
+    else:
+      result.add underscoredCall(call, arg0)
diff --git a/lib/std/private/win_getsysteminfo.nim b/lib/std/private/win_getsysteminfo.nim
new file mode 100644
index 000000000..b98478231
--- /dev/null
+++ b/lib/std/private/win_getsysteminfo.nim
@@ -0,0 +1,15 @@
+type
+  SystemInfo* = object
+    u1: uint32
+    dwPageSize: uint32
+    lpMinimumApplicationAddress: pointer
+    lpMaximumApplicationAddress: pointer
+    dwActiveProcessorMask: ptr uint32
+    dwNumberOfProcessors*: uint32
+    dwProcessorType: uint32
+    dwAllocationGranularity*: uint32
+    wProcessorLevel: uint16
+    wProcessorRevision: uint16
+
+proc getSystemInfo*(lpSystemInfo: ptr SystemInfo) {.stdcall,
+    dynlib: "kernel32", importc: "GetSystemInfo".}
diff --git a/lib/std/private/win_setenv.nim b/lib/std/private/win_setenv.nim
new file mode 100644
index 000000000..66e199dfe
--- /dev/null
+++ b/lib/std/private/win_setenv.nim
@@ -0,0 +1,106 @@
+#[
+Copyright (c) Facebook, Inc. and its affiliates.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Adapted `setenv` from https://github.com/facebook/folly/blob/master/folly/portability/Stdlib.cpp
+translated from C to nim.
+]#
+
+#[
+Introduced in https://github.com/facebook/folly/commit/5d8ca09a3f96afefb44e35808f03651a096ab9c7
+
+TODO:
+check errno_t vs cint
+]#
+
+when not defined(windows): discard
+else:
+  when defined(nimPreviewSlimSystem):
+    import std/widestrs
+
+  type wchar_t  {.importc: "wchar_t".} = int16
+
+  proc setEnvironmentVariableW*(lpName, lpValue: WideCString): int32 {.
+    stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW", sideEffect.}
+    # same as winlean.setEnvironmentVariableA
+
+  proc c_getenv(varname: cstring): cstring {.importc: "getenv", header: "<stdlib.h>".}
+  proc c_wputenv(envstring: ptr wchar_t): cint {.importc: "_wputenv", header: "<stdlib.h>".}
+  proc c_wgetenv(varname: ptr wchar_t): ptr wchar_t {.importc: "_wgetenv", header: "<stdlib.h>".}
+
+  var errno {.importc, header: "<errno.h>".}: cint
+  var genviron {.importc: "_environ".}: ptr ptr char
+    # xxx `ptr UncheckedArray[WideCString]` did not work
+
+  proc wcstombs(wcstr: ptr char, mbstr: ptr wchar_t, count: csize_t): csize_t {.importc, header: "<stdlib.h>".}
+    # xxx cint vs errno_t?
+
+  proc setEnvImpl*(name: string, value: string, overwrite: cint): cint =
+    const EINVAL = cint(22)
+    let wideName: WideCString = newWideCString(name)
+    if overwrite == 0 and c_wgetenv(cast[ptr wchar_t](wideName)) != nil:
+      return 0
+
+    if value != "":
+      let envstring: WideCString = newWideCString(name & "=" & value)
+      let e = c_wputenv(cast[ptr wchar_t](envstring))
+      if e != 0:
+        errno = EINVAL
+        return -1
+      return 0
+    #[
+    We are trying to set the value to an empty string, but `_putenv` deletes
+    entries if the value is an empty string, and just calling
+    SetEnvironmentVariableA doesn't update `_environ`,
+    so we have to do these terrible things.
+    ]#
+    let envstring: WideCString = newWideCString(name & "=  ")
+    if c_wputenv(cast[ptr wchar_t](envstring)) != 0:
+      errno = EINVAL
+      return -1
+    # Here lies the documentation we blatently ignore to make this work.
+    var s = cast[WideCString](c_wgetenv(cast[ptr wchar_t](wideName)))
+    s[0] = Utf16Char('\0')
+    #[
+    This would result in a double null termination, which normally signifies the
+    end of the environment variable list, so we stick a completely empty
+    environment variable into the list instead.
+    ]#
+    s = cast[WideCString](c_wgetenv(cast[ptr wchar_t](wideName)))
+    s[1] = Utf16Char('=')
+    #[
+    If genviron is null, the MBCS environment has not been initialized
+    yet, and we don't need to try to update it. We have to do this otherwise
+    we'd be forcing the initialization and maintenance of the MBCS environment
+    even though it's never actually used in most programs.
+    ]#
+    if genviron != nil:
+
+      # wcstombs returns `high(csize_t)` if any characters cannot be represented
+      # in the current codepage. Skip updating MBCS environment in this case.
+      # For some reason, second `wcstombs` can find non-convertible characters
+      # that the first `wcstombs` cannot.
+      let requiredSizeS = wcstombs(nil, cast[ptr wchar_t](wideName), 0)
+      if requiredSizeS != high(csize_t):
+        let requiredSize = requiredSizeS.int
+        var buf = newSeq[char](requiredSize + 1)
+        let buf2 = buf[0].addr
+        if wcstombs(buf2, cast[ptr wchar_t](wideName), csize_t(requiredSize + 1)) != high(csize_t):
+          var ptrToEnv = c_getenv(cast[cstring](buf2))
+          ptrToEnv[0] = '\0'
+          ptrToEnv = c_getenv(cast[cstring](buf2))
+          ptrToEnv[1] = '='
+
+    # And now, we have to update the outer environment to have a proper empty value.
+    if setEnvironmentVariableW(wideName, value.newWideCString) == 0:
+      errno = EINVAL
+      return -1
+    return 0
diff --git a/lib/std/setutils.nim b/lib/std/setutils.nim
new file mode 100644
index 000000000..8e7bc6a92
--- /dev/null
+++ b/lib/std/setutils.nim
@@ -0,0 +1,77 @@
+#
+#
+#              Nim's Runtime Library
+#        (c) Copyright 2020 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module adds functionality for the built-in `set` type.
+##
+## See also
+## ========
+## * `std/packedsets <packedsets.html>`_
+## * `std/sets <sets.html>`_
+
+import std/[typetraits, macros]
+
+#[
+  type SetElement* = char|byte|bool|int16|uint16|enum|uint8|int8
+    ## The allowed types of a built-in set.
+]#
+
+template toSet*(iter: untyped): untyped =
+  ## Returns a built-in set from the elements of the iterable `iter`.
+  runnableExamples:
+    assert "helloWorld".toSet == {'W', 'd', 'e', 'h', 'l', 'o', 'r'}
+    assert toSet([10u16, 20, 30]) == {10u16, 20, 30}
+    assert [30u8, 100, 10].toSet == {10u8, 30, 100}
+    assert toSet(@[1321i16, 321, 90]) == {90i16, 321, 1321}
+    assert toSet([false]) == {false}
+    assert toSet(0u8..10) == {0u8..10}
+
+  var result: set[elementType(iter)]
+  for x in iter:
+    incl(result, x)
+  result
+
+macro enumElementsAsSet(enm: typed): untyped = result = newNimNode(nnkCurly).add(enm.getType[1][1..^1])
+
+# func fullSet*(T: typedesc): set[T] {.inline.} = # xxx would give: Error: ordinal type expected
+func fullSet*[T](U: typedesc[T]): set[T] {.inline.} =
+  ## Returns a set containing all elements in `U`.
+  runnableExamples:
+    assert bool.fullSet == {true, false}
+    type A = range[1..3]
+    assert A.fullSet == {1.A, 2, 3}
+    assert int8.fullSet.len == 256
+  when T is Ordinal:
+    {T.low..T.high}
+  else: # Hole filled enum
+    enumElementsAsSet(T)
+
+func complement*[T](s: set[T]): set[T] {.inline.} =
+  ## Returns the set complement of `a`.
+  runnableExamples:
+    type Colors = enum
+      red, green = 3, blue
+    assert complement({red, blue}) == {green}
+    assert complement({red, green, blue}).card == 0
+    assert complement({range[0..10](0), 1, 2, 3}) == {range[0..10](4), 5, 6, 7, 8, 9, 10}
+    assert complement({'0'..'9'}) == {0.char..255.char} - {'0'..'9'}
+  fullSet(T) - s
+
+func `[]=`*[T](t: var set[T], key: T, val: bool) {.inline.} =
+  ## Syntax sugar for `if val: t.incl key else: t.excl key`
+  runnableExamples:
+    type A = enum
+      a0, a1, a2, a3
+    var s = {a0, a3}
+    s[a0] = false
+    s[a1] = false
+    assert s == {a3}
+    s[a2] = true
+    s[a3] = true
+    assert s == {a2, a3}
+  if val: t.incl key else: t.excl key
diff --git a/lib/std/sha1.nim b/lib/std/sha1.nim
new file mode 100644
index 000000000..213af4229
--- /dev/null
+++ b/lib/std/sha1.nim
@@ -0,0 +1,287 @@
+#
+#
+#              Nim's Runtime Library
+#        (c) Copyright 2015 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+## [SHA-1 (Secure Hash Algorithm 1)](https://en.wikipedia.org/wiki/SHA-1)
+## is a cryptographic hash function which takes an input and produces
+## a 160-bit (20-byte) hash value known as a message digest.
+##
+## See also
+## ========
+## * `base64 module<base64.html>`_ for a Base64 encoder and decoder
+## * `hashes module<hashes.html>`_ for efficient computations of hash values for diverse Nim types
+## * `md5 module<md5.html>`_ for the MD5 checksum algorithm
+
+runnableExamples:
+  let accessName = secureHash("John Doe")
+  assert $accessName == "AE6E4D1209F17B460503904FAD297B31E9CF6362"
+
+runnableExamples("-r:off"):
+  let
+    a = secureHashFile("myFile.nim")
+    b = parseSecureHash("10DFAEBF6BFDBC7939957068E2EFACEC4972933C")
+  assert a == b, "files don't match"
+
+
+{.deprecated: "use command `nimble install checksums` and import `checksums/sha1` instead".}
+
+import std/strutils
+from std/endians import bigEndian32, bigEndian64
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+const Sha1DigestSize = 20
+
+type
+  Sha1Digest* = array[0 .. Sha1DigestSize - 1, uint8]
+  SecureHash* = distinct Sha1Digest
+
+type
+  Sha1State* = object
+    count: int
+    state: array[5, uint32]
+    buf:   array[64, byte]
+
+# This implementation of the SHA-1 algorithm was ported from the Chromium OS one
+# with minor modifications that should not affect its functionality.
+
+proc newSha1State*(): Sha1State =
+  ## Creates a `Sha1State`.
+  ##
+  ## If you use the `secureHash proc <#secureHash,openArray[char]>`_,
+  ## there's no need to call this function explicitly.
+  result.count = 0
+  result.state[0] = 0x67452301'u32
+  result.state[1] = 0xEFCDAB89'u32
+  result.state[2] = 0x98BADCFE'u32
+  result.state[3] = 0x10325476'u32
+  result.state[4] = 0xC3D2E1F0'u32
+
+template ror27(val: uint32): uint32 = (val shr 27) or (val shl  5)
+template ror2 (val: uint32): uint32 = (val shr  2) or (val shl 30)
+template ror31(val: uint32): uint32 = (val shr 31) or (val shl  1)
+
+proc transform(ctx: var Sha1State) =
+  var w: array[80, uint32]
+  var a, b, c, d, e: uint32
+  var t = 0
+
+  a = ctx.state[0]
+  b = ctx.state[1]
+  c = ctx.state[2]
+  d = ctx.state[3]
+  e = ctx.state[4]
+
+  template shaF1(a, b, c, d, e, t: untyped) =
+    bigEndian32(addr w[t], addr ctx.buf[t * 4])
+    e += ror27(a) + w[t] + (d xor (b and (c xor d))) + 0x5A827999'u32
+    b = ror2(b)
+
+  while t < 15:
+    shaF1(a, b, c, d, e, t + 0)
+    shaF1(e, a, b, c, d, t + 1)
+    shaF1(d, e, a, b, c, t + 2)
+    shaF1(c, d, e, a, b, t + 3)
+    shaF1(b, c, d, e, a, t + 4)
+    t += 5
+  shaF1(a, b, c, d, e, t + 0) # 16th one, t == 15
+
+  template shaF11(a, b, c, d, e, t: untyped) =
+    w[t] = ror31(w[t-3] xor w[t-8] xor w[t-14] xor w[t-16])
+    e += ror27(a) + w[t] + (d xor (b and (c xor d))) + 0x5A827999'u32
+    b = ror2(b)
+
+  shaF11(e, a, b, c, d, t + 1)
+  shaF11(d, e, a, b, c, t + 2)
+  shaF11(c, d, e, a, b, t + 3)
+  shaF11(b, c, d, e, a, t + 4)
+
+  template shaF2(a, b, c, d, e, t: untyped) =
+    w[t] = ror31(w[t-3] xor w[t-8] xor w[t-14] xor w[t-16])
+    e += ror27(a) + w[t] + (b xor c xor d) + 0x6ED9EBA1'u32
+    b = ror2(b)
+
+  t = 20
+  while t < 40:
+    shaF2(a, b, c, d, e, t + 0)
+    shaF2(e, a, b, c, d, t + 1)
+    shaF2(d, e, a, b, c, t + 2)
+    shaF2(c, d, e, a, b, t + 3)
+    shaF2(b, c, d, e, a, t + 4)
+    t += 5
+
+  template shaF3(a, b, c, d, e, t: untyped) =
+    w[t] = ror31(w[t-3] xor w[t-8] xor w[t-14] xor w[t-16])
+    e += ror27(a) + w[t] + ((b and c) or (d and (b or c))) + 0x8F1BBCDC'u32
+    b = ror2(b)
+
+  while t < 60:
+    shaF3(a, b, c, d, e, t + 0)
+    shaF3(e, a, b, c, d, t + 1)
+    shaF3(d, e, a, b, c, t + 2)
+    shaF3(c, d, e, a, b, t + 3)
+    shaF3(b, c, d, e, a, t + 4)
+    t += 5
+
+  template shaF4(a, b, c, d, e, t: untyped) =
+    w[t] = ror31(w[t-3] xor w[t-8] xor w[t-14] xor w[t-16])
+    e += ror27(a) + w[t] + (b xor c xor d) + 0xCA62C1D6'u32
+    b = ror2(b)
+
+  while t < 80:
+    shaF4(a, b, c, d, e, t + 0)
+    shaF4(e, a, b, c, d, t + 1)
+    shaF4(d, e, a, b, c, t + 2)
+    shaF4(c, d, e, a, b, t + 3)
+    shaF4(b, c, d, e, a, t + 4)
+    t += 5
+
+  ctx.state[0] += a
+  ctx.state[1] += b
+  ctx.state[2] += c
+  ctx.state[3] += d
+  ctx.state[4] += e
+
+proc update*(ctx: var Sha1State, data: openArray[char]) =
+  ## Updates the `Sha1State` with `data`.
+  ##
+  ## If you use the `secureHash proc <#secureHash,openArray[char]>`_,
+  ## there's no need to call this function explicitly.
+  var i = ctx.count mod 64
+  var j = 0
+  var len = data.len
+  # Gather 64-bytes worth of data in order to perform a round with the leftover
+  # data we had stored (but not processed yet)
+  if len > 64 - i:
+    copyMem(addr ctx.buf[i], unsafeAddr data[j], 64 - i)
+    len -= 64 - i
+    j += 64 - i
+    transform(ctx)
+    # Update the index since it's used in the while loop below _and_ we want to
+    # keep its value if this code path isn't executed
+    i = 0
+  # Process the bulk of the payload
+  while len >= 64:
+    copyMem(addr ctx.buf[0], unsafeAddr data[j], 64)
+    len -= 64
+    j += 64
+    transform(ctx)
+  # Process the tail of the payload (len is < 64)
+  while len > 0:
+    dec len
+    ctx.buf[i] = byte(data[j])
+    inc i
+    inc j
+    if i == 64:
+      transform(ctx)
+      i = 0
+  ctx.count += data.len
+
+proc finalize*(ctx: var Sha1State): Sha1Digest =
+  ## Finalizes the `Sha1State` and returns a `Sha1Digest`.
+  ##
+  ## If you use the `secureHash proc <#secureHash,openArray[char]>`_,
+  ## there's no need to call this function explicitly.
+  var cnt = uint64(ctx.count * 8)
+  # a 1 bit
+  update(ctx, "\x80")
+  # Add padding until we reach a complexive size of 64 - 8 bytes
+  while (ctx.count mod 64) != (64 - 8):
+    update(ctx, "\x00")
+  # The message length as a 64bit BE number completes the block
+  var tmp: array[8, char]
+  bigEndian64(addr tmp[0], addr cnt)
+  update(ctx, tmp)
+  # Turn the result into a single 160-bit number
+  for i in 0 ..< 5:
+    bigEndian32(addr ctx.state[i], addr ctx.state[i])
+  copyMem(addr result[0], addr ctx.state[0], Sha1DigestSize)
+
+# Public API
+
+proc secureHash*(str: openArray[char]): SecureHash =
+  ## Generates a `SecureHash` from `str`.
+  ##
+  ## **See also:**
+  ## * `secureHashFile proc <#secureHashFile,string>`_ for generating a `SecureHash` from a file
+  ## * `parseSecureHash proc <#parseSecureHash,string>`_ for converting a string `hash` to `SecureHash`
+  runnableExamples:
+    let hash = secureHash("Hello World")
+    assert hash == parseSecureHash("0A4D55A8D778E5022FAB701977C5D840BBC486D0")
+
+  var state = newSha1State()
+  state.update(str)
+  SecureHash(state.finalize())
+
+proc secureHashFile*(filename: string): SecureHash =
+  ## Generates a `SecureHash` from a file.
+  ##
+  ## **See also:**
+  ## * `secureHash proc <#secureHash,openArray[char]>`_ for generating a `SecureHash` from a string
+  ## * `parseSecureHash proc <#parseSecureHash,string>`_ for converting a string `hash` to `SecureHash`
+  const BufferLength = 8192
+
+  let f = open(filename)
+  var state = newSha1State()
+  var buffer = newString(BufferLength)
+  while true:
+    let length = readChars(f, buffer)
+    if length == 0:
+      break
+    buffer.setLen(length)
+    state.update(buffer)
+    if length != BufferLength:
+      break
+  close(f)
+
+  SecureHash(state.finalize())
+
+proc `$`*(self: SecureHash): string =
+  ## Returns the string representation of a `SecureHash`.
+  ##
+  ## **See also:**
+  ## * `secureHash proc <#secureHash,openArray[char]>`_ for generating a `SecureHash` from a string
+  runnableExamples:
+    let hash = secureHash("Hello World")
+    assert $hash == "0A4D55A8D778E5022FAB701977C5D840BBC486D0"
+
+  result = ""
+  for v in Sha1Digest(self):
+    result.add(toHex(int(v), 2))
+
+proc parseSecureHash*(hash: string): SecureHash =
+  ## Converts a string `hash` to a `SecureHash`.
+  ##
+  ## **See also:**
+  ## * `secureHash proc <#secureHash,openArray[char]>`_ for generating a `SecureHash` from a string
+  ## * `secureHashFile proc <#secureHashFile,string>`_ for generating a `SecureHash` from a file
+  runnableExamples:
+    let
+      hashStr = "0A4D55A8D778E5022FAB701977C5D840BBC486D0"
+      secureHash = secureHash("Hello World")
+    assert secureHash == parseSecureHash(hashStr)
+
+  for i in 0 ..< Sha1DigestSize:
+    Sha1Digest(result)[i] = uint8(parseHexInt(hash[i*2] & hash[i*2 + 1]))
+
+proc `==`*(a, b: SecureHash): bool =
+  ## Checks if two `SecureHash` values are identical.
+  runnableExamples:
+    let
+      a = secureHash("Hello World")
+      b = secureHash("Goodbye World")
+      c = parseSecureHash("0A4D55A8D778E5022FAB701977C5D840BBC486D0")
+    assert a != b
+    assert a == c
+
+  # Not a constant-time comparison, but that's acceptable in this context
+  Sha1Digest(a) == Sha1Digest(b)
+
+proc isValidSha1Hash*(s: string): bool =
+  ## Checks if a string is a valid sha1 hash sum.
+  s.len == 40 and allCharsInSet(s, HexDigits)
\ No newline at end of file
diff --git a/lib/std/socketstreams.nim b/lib/std/socketstreams.nim
new file mode 100644
index 000000000..45e906795
--- /dev/null
+++ b/lib/std/socketstreams.nim
@@ -0,0 +1,182 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2021 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module provides an implementation of the streams interface for sockets.
+## It contains two separate implementations, a
+## `ReadSocketStream <#ReadSocketStream>`_ and a
+## `WriteSocketStream <#WriteSocketStream>`_.
+##
+## The `ReadSocketStream` only supports reading, peeking, and seeking.
+## It reads into a buffer, so even by
+## seeking backwards it will only read the same position a single time from the
+## underlying socket. To clear the buffer and free the data read into it you
+## can call `resetStream`, this will also reset the position back to 0 but
+## won't do anything to the underlying socket.
+##
+## The `WriteSocketStream` allows both reading and writing, but it performs the
+## reads on the internal buffer. So by writing to the buffer you can then read
+## back what was written but without receiving anything from the socket. You
+## can also set the position and overwrite parts of the buffer, and to send
+## anything over the socket you need to call `flush` at which point you can't
+## write anything to the buffer before the point of the flush (but it can still
+## be read). Again to empty the underlying buffer you need to call
+## `resetStream`.
+##
+## Examples
+## ========
+##
+##   ```Nim
+##   import std/socketstreams
+##
+##   var
+##     socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
+##     stream = newReadSocketStream(socket)
+##   socket.sendTo("127.0.0.1", Port(12345), "SOME REQUEST")
+##   echo stream.readLine() # Will call `recv`
+##   stream.setPosition(0)
+##   echo stream.readLine() # Will return the read line from the buffer
+##   stream.resetStream() # Buffer is now empty, position is 0
+##   echo stream.readLine() # Will call `recv` again
+##   stream.close() # Closes the socket
+##   ```
+##
+##   ```Nim
+##   import std/socketstreams
+##
+##   var socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
+##   socket.connect("127.0.0.1", Port(12345))
+##   var sendStream = newWriteSocketStream(socket)
+##   sendStream.write "NOM"
+##   sendStream.setPosition(1)
+##   echo sendStream.peekStr(2) # OM
+##   sendStream.write "I"
+##   sendStream.setPosition(0)
+##   echo sendStream.readStr(3) # NIM
+##   echo sendStream.getPosition() # 3
+##   sendStream.flush() # This actually performs the writing to the socket
+##   sendStream.setPosition(1)
+##   sendStream.write "I" # Throws an error as we can't write into an already sent buffer
+##   ```
+
+import std/[net, streams]
+
+type
+  ReadSocketStream* = ref ReadSocketStreamObj
+  ReadSocketStreamObj* = object of StreamObj
+    data: Socket
+    pos: int
+    buf: seq[byte]
+  WriteSocketStream* = ref WriteSocketStreamObj
+  WriteSocketStreamObj* = object of ReadSocketStreamObj
+    lastFlush: int
+
+proc rsAtEnd(s: Stream): bool =
+  return false
+
+proc rsSetPosition(s: Stream, pos: int) =
+  var s = ReadSocketStream(s)
+  s.pos = pos
+
+proc rsGetPosition(s: Stream): int =
+  var s = ReadSocketStream(s)
+  return s.pos
+
+proc rsPeekData(s: Stream, buffer: pointer, bufLen: int): int =
+  let s = ReadSocketStream(s)
+  if bufLen > 0:
+    let oldLen = s.buf.len
+    s.buf.setLen(max(s.pos + bufLen, s.buf.len))
+    if s.pos + bufLen > oldLen:
+      result = s.data.recv(s.buf[oldLen].addr, s.buf.len - oldLen)
+      if result > 0:
+        result += oldLen - s.pos
+    else:
+      result = bufLen
+    copyMem(buffer, s.buf[s.pos].addr, result)
+
+proc rsReadData(s: Stream, buffer: pointer, bufLen: int): int =
+  result = s.rsPeekData(buffer, bufLen)
+  var s = ReadSocketStream(s)
+  s.pos += bufLen
+
+proc rsReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int =
+  var s = ReadSocketStream(s)
+  result = slice.b + 1 - slice.a
+  if result > 0:
+    result = s.rsReadData(buffer[slice.a].addr, result)
+    inc(s.pos, result)
+  else:
+    result = 0
+
+proc wsWriteData(s: Stream, buffer: pointer, bufLen: int) =
+  var s = WriteSocketStream(s)
+  if s.pos < s.lastFlush:
+    raise newException(IOError, "Unable to write into buffer that has already been sent")
+  if s.buf.len < s.pos + bufLen:
+    s.buf.setLen(s.pos + bufLen)
+  copyMem(s.buf[s.pos].addr, buffer, bufLen)
+  s.pos += bufLen
+
+proc wsPeekData(s: Stream, buffer: pointer, bufLen: int): int =
+  var s = WriteSocketStream(s)
+  result = bufLen
+  if result > 0:
+    if s.pos > s.buf.len or s.pos == s.buf.len or s.pos + bufLen > s.buf.len:
+      raise newException(IOError, "Unable to read past end of write buffer")
+    else:
+      copyMem(buffer, s.buf[s.pos].addr, bufLen)
+
+proc wsReadData(s: Stream, buffer: pointer, bufLen: int): int =
+  result = s.wsPeekData(buffer, bufLen)
+  var s = ReadSocketStream(s)
+  s.pos += bufLen
+
+proc wsAtEnd(s: Stream): bool =
+  var s = WriteSocketStream(s)
+  return s.pos == s.buf.len
+
+proc wsFlush(s: Stream) =
+  var s = WriteSocketStream(s)
+  discard s.data.send(s.buf[s.lastFlush].addr, s.buf.len - s.lastFlush)
+  s.lastFlush = s.buf.len
+
+proc rsClose(s: Stream) =
+  {.cast(raises: [IOError, OSError]), cast(tags: []).}: # todo fixme maybe do something?
+    var s = ReadSocketStream(s)
+    s.data.close()
+
+proc newReadSocketStream*(s: Socket): owned ReadSocketStream =
+  result = ReadSocketStream(data: s, pos: 0,
+    closeImpl: rsClose,
+    atEndImpl: rsAtEnd,
+    setPositionImpl: rsSetPosition,
+    getPositionImpl: rsGetPosition,
+    readDataImpl: rsReadData,
+    peekDataImpl: rsPeekData,
+    readDataStrImpl: rsReadDataStr)
+
+proc resetStream*(s: ReadSocketStream) =
+  s.buf = @[]
+  s.pos = 0
+
+proc newWriteSocketStream*(s: Socket): owned WriteSocketStream =
+  result = WriteSocketStream(data: s, pos: 0,
+    closeImpl: rsClose,
+    atEndImpl: wsAtEnd,
+    setPositionImpl: rsSetPosition,
+    getPositionImpl: rsGetPosition,
+    writeDataImpl: wsWriteData,
+    readDataImpl: wsReadData,
+    peekDataImpl: wsPeekData,
+    flushImpl: wsFlush)
+
+proc resetStream*(s: WriteSocketStream) =
+  s.buf = @[]
+  s.pos = 0
+  s.lastFlush = 0
diff --git a/lib/std/stackframes.nim b/lib/std/stackframes.nim
new file mode 100644
index 000000000..28be7ce11
--- /dev/null
+++ b/lib/std/stackframes.nim
@@ -0,0 +1,30 @@
+const NimStackTrace = compileOption("stacktrace")
+const NimStackTraceMsgs = compileOption("stacktraceMsgs")
+
+template procName*(): string =
+  ## returns current C/C++ function name
+  when defined(c) or defined(cpp):
+    var name {.inject, noinit.}: cstring
+    {.emit: "`name` = __func__;".}
+    $name
+
+template getPFrame*(): PFrame =
+  ## avoids a function call (unlike `getFrame()`)
+  block:
+    when NimStackTrace:
+      var framePtr {.inject, noinit.}: PFrame
+      {.emit: "`framePtr` = &FR_;".}
+      framePtr
+
+template setFrameMsg*(msg: string, prefix = " ") =
+  ## attach a msg to current `PFrame`. This can be called multiple times
+  ## in a given PFrame. Noop unless passing --stacktraceMsgs and --stacktrace
+  when NimStackTrace and NimStackTraceMsgs:
+    block:
+      var fr {.inject, noinit.}: PFrame
+      {.emit: "`fr` = &FR_;".}
+      # consider setting a custom upper limit on size (analog to stack overflow)
+      frameMsgBuf.setLen fr.frameMsgLen
+      frameMsgBuf.add prefix
+      frameMsgBuf.add msg
+      fr.frameMsgLen += prefix.len + msg.len
diff --git a/lib/std/staticos.nim b/lib/std/staticos.nim
new file mode 100644
index 000000000..2617c6913
--- /dev/null
+++ b/lib/std/staticos.nim
@@ -0,0 +1,13 @@
+## This module implements path handling like os module but works at only compile-time.
+## This module works even when cross compiling to OS that is not supported by os module.
+
+proc staticFileExists*(filename: string): bool {.compileTime.} =
+  ## Returns true if `filename` exists and is a regular file or symlink.
+  ##
+  ## Directories, device files, named pipes and sockets return false.
+  discard
+
+proc staticDirExists*(dir: string): bool {.compileTime.} =
+  ## Returns true if the directory `dir` exists. If `dir` is a file, false
+  ## is returned. Follows symlinks.
+  discard
diff --git a/lib/std/strbasics.nim b/lib/std/strbasics.nim
new file mode 100644
index 000000000..b2c36a4be
--- /dev/null
+++ b/lib/std/strbasics.nim
@@ -0,0 +1,119 @@
+#
+#
+#              Nim's Runtime Library
+#        (c) Copyright 2021 Nim Contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module provides some high performance string operations.
+##
+## Experimental API, subject to change.
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+
+const whitespaces = {' ', '\t', '\v', '\r', '\l', '\f'}
+
+proc add*(x: var string, y: openArray[char]) =
+  ## Concatenates `x` and `y` in place. `y` must not overlap with `x` to
+  ## allow future `memcpy` optimizations.
+  # Use `{.noalias.}` ?
+  let n = x.len
+  x.setLen n + y.len
+    # pending #19727
+    # setLen unnecessarily zeros memory
+  var i = 0
+  while i < y.len:
+    x[n + i] = y[i]
+    i.inc
+  # xxx use `nimCopyMem(x[n].addr, y[0].addr, y.len)` after some refactoring
+
+func stripSlice(s: openArray[char], leading = true, trailing = true, chars: set[char] = whitespaces): Slice[int] =
+  ## Returns the slice range of `s` which is stripped `chars`.
+  runnableExamples:
+    assert stripSlice(" abc  ") == 1 .. 3
+  var
+    first = 0
+    last = high(s)
+  if leading:
+    while first <= last and s[first] in chars: inc(first)
+  if trailing:
+    while last >= first and s[last] in chars: dec(last)
+  result = first .. last
+
+func setSlice*(s: var string, slice: Slice[int]) =
+  ## Inplace version of `substr`.
+  runnableExamples:
+    import std/sugar
+
+    var a = "Hello, Nim!"
+    doAssert a.dup(setSlice(7 .. 9)) == "Nim"
+    doAssert a.dup(setSlice(0 .. 0)) == "H"
+    doAssert a.dup(setSlice(0 .. 1)) == "He"
+    doAssert a.dup(setSlice(0 .. 10)) == a
+    doAssert a.dup(setSlice(1 .. 0)).len == 0
+    doAssert a.dup(setSlice(20 .. -1)).len == 0
+
+
+    doAssertRaises(AssertionDefect):
+      discard a.dup(setSlice(-1 .. 1))
+
+    doAssertRaises(AssertionDefect):
+      discard a.dup(setSlice(1 .. 11))
+
+
+  let first = slice.a
+  let last = slice.b
+
+  assert first >= 0
+  assert last <= s.high
+
+  if first > last:
+    s.setLen(0)
+    return
+  template impl =
+    for index in first .. last:
+      s[index - first] = s[index]
+  if first > 0:
+    when nimvm: impl()
+    else:
+      # not JS and not Nimscript
+      when not declared(moveMem):
+        impl()
+      else:
+        when defined(nimSeqsV2):
+          prepareMutation(s)
+        moveMem(addr s[0], addr s[first], last - first + 1)
+  s.setLen(last - first + 1)
+
+func strip*(a: var string, leading = true, trailing = true, chars: set[char] = whitespaces) {.inline.} =
+  ## Inplace version of `strip`. Strips leading or
+  ## trailing `chars` (default: whitespace characters).
+  ##
+  ## If `leading` is true (default), leading `chars` are stripped.
+  ## If `trailing` is true (default), trailing `chars` are stripped.
+  ## If both are false, the string is unchanged.
+  runnableExamples:
+    var a = "  vhellov   "
+    strip(a)
+    assert a == "vhellov"
+
+    a = "  vhellov   "
+    a.strip(leading = false)
+    assert a == "  vhellov"
+
+    a = "  vhellov   "
+    a.strip(trailing = false)
+    assert a == "vhellov   "
+
+    var c = "blaXbla"
+    c.strip(chars = {'b', 'a'})
+    assert c == "laXbl"
+    c = "blaXbla"
+    c.strip(chars = {'b', 'a', 'l'})
+    assert c == "X"
+
+  setSlice(a, stripSlice(a, leading, trailing, chars))
diff --git a/lib/std/symlinks.nim b/lib/std/symlinks.nim
new file mode 100644
index 000000000..dbe908612
--- /dev/null
+++ b/lib/std/symlinks.nim
@@ -0,0 +1,33 @@
+## This module implements symlink (symbolic link) handling.
+
+## .. importdoc:: os.nim
+
+from std/paths import Path, ReadDirEffect
+
+from std/private/ossymlinks import symlinkExists, createSymlink, expandSymlink
+
+proc symlinkExists*(link: Path): bool {.inline, tags: [ReadDirEffect], sideEffect.} =
+  ## Returns true if the symlink `link` exists. Will return true
+  ## regardless of whether the link points to a directory or file.
+  result = symlinkExists(link.string)
+
+proc createSymlink*(src, dest: Path) {.inline.} =
+  ## Create a symbolic link at `dest` which points to the item specified
+  ## by `src`. On most operating systems, will fail if a link already exists.
+  ##
+  ## .. warning:: Some OS's (such as Microsoft Windows) restrict the creation
+  ##   of symlinks to root users (administrators) or users with developer mode enabled.
+  ##
+  ## See also:
+  ## * `createHardlink proc`_
+  ## * `expandSymlink proc`_
+  createSymlink(src.string, dest.string)
+
+proc expandSymlink*(symlinkPath: Path): Path {.inline.} =
+  ## Returns a string representing the path to which the symbolic link points.
+  ##
+  ## On Windows this is a noop, `symlinkPath` is simply returned.
+  ##
+  ## See also:
+  ## * `createSymlink proc`_
+  result = Path(expandSymlink(symlinkPath.string))
diff --git a/lib/std/syncio.nim b/lib/std/syncio.nim
new file mode 100644
index 000000000..c34a025af
--- /dev/null
+++ b/lib/std/syncio.nim
@@ -0,0 +1,942 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2022 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements various synchronized I/O operations.
+
+include system/inclrtl
+import std/private/since
+import std/formatfloat
+when defined(windows):
+  import std/widestrs
+
+# ----------------- IO Part ------------------------------------------------
+type
+  CFile {.importc: "FILE", header: "<stdio.h>",
+          incompleteStruct.} = object
+  File* = ptr CFile ## The type representing a file handle.
+
+  FileMode* = enum       ## The file mode when opening a file.
+    fmRead,              ## Open the file for read access only.
+                         ## If the file does not exist, it will not
+                         ## be created.
+    fmWrite,             ## Open the file for write access only.
+                         ## If the file does not exist, it will be
+                         ## created. Existing files will be cleared!
+    fmReadWrite,         ## Open the file for read and write access.
+                         ## If the file does not exist, it will be
+                         ## created. Existing files will be cleared!
+    fmReadWriteExisting, ## Open the file for read and write access.
+                         ## If the file does not exist, it will not be
+                         ## created. The existing file will not be cleared.
+    fmAppend             ## Open the file for writing only; append data
+                         ## at the end. If the file does not exist, it
+                         ## will be created.
+
+  FileHandle* = cint ## The type that represents an OS file handle; this is
+                      ## useful for low-level file access.
+
+  FileSeekPos* = enum ## Position relative to which seek should happen.
+                      # The values are ordered so that they match with stdio
+                      # SEEK_SET, SEEK_CUR and SEEK_END respectively.
+    fspSet            ## Seek to absolute value
+    fspCur            ## Seek relative to current position
+    fspEnd            ## Seek relative to end
+
+# text file handling:
+when not defined(nimscript) and not defined(js):
+  # duplicated between io and ansi_c
+  const stdioUsesMacros = (defined(osx) or defined(freebsd) or defined(
+      dragonfly)) and not defined(emscripten)
+  const stderrName = when stdioUsesMacros: "__stderrp" else: "stderr"
+  const stdoutName = when stdioUsesMacros: "__stdoutp" else: "stdout"
+  const stdinName = when stdioUsesMacros: "__stdinp" else: "stdin"
+
+  var
+    stdin* {.importc: stdinName, header: "<stdio.h>".}: File
+      ## The standard input stream.
+    stdout* {.importc: stdoutName, header: "<stdio.h>".}: File
+      ## The standard output stream.
+    stderr* {.importc: stderrName, header: "<stdio.h>".}: File
+      ## The standard error stream.
+
+when defined(useStdoutAsStdmsg):
+  template stdmsg*: File = stdout
+else:
+  template stdmsg*: File = stderr
+    ## Template which expands to either stdout or stderr depending on
+    ## `useStdoutAsStdmsg` compile-time switch.
+
+when defined(windows):
+  proc c_fileno(f: File): cint {.
+    importc: "_fileno", header: "<stdio.h>".}
+else:
+  proc c_fileno(f: File): cint {.
+    importc: "fileno", header: "<fcntl.h>".}
+
+when defined(windows):
+  proc c_fdopen(filehandle: cint, mode: cstring): File {.
+    importc: "_fdopen", header: "<stdio.h>".}
+else:
+  proc c_fdopen(filehandle: cint, mode: cstring): File {.
+    importc: "fdopen", header: "<stdio.h>".}
+proc c_fputs(c: cstring, f: File): cint {.
+  importc: "fputs", header: "<stdio.h>", tags: [WriteIOEffect].}
+proc c_fgets(c: cstring, n: cint, f: File): cstring {.
+  importc: "fgets", header: "<stdio.h>", tags: [ReadIOEffect].}
+proc c_fgetc(stream: File): cint {.
+  importc: "fgetc", header: "<stdio.h>", tags: [].}
+proc c_ungetc(c: cint, f: File): cint {.
+  importc: "ungetc", header: "<stdio.h>", tags: [].}
+proc c_putc(c: cint, stream: File): cint {.
+  importc: "putc", header: "<stdio.h>", tags: [WriteIOEffect].}
+proc c_fflush(f: File): cint {.
+  importc: "fflush", header: "<stdio.h>".}
+proc c_fclose(f: File): cint {.
+  importc: "fclose", header: "<stdio.h>".}
+proc c_clearerr(f: File) {.
+  importc: "clearerr", header: "<stdio.h>".}
+proc c_feof(f: File): cint {.
+  importc: "feof", header: "<stdio.h>".}
+
+when not declared(c_fwrite):
+  proc c_fwrite(buf: pointer, size, n: csize_t, f: File): csize_t {.
+    importc: "fwrite", header: "<stdio.h>".}
+
+# C routine that is used here:
+proc c_fread(buf: pointer, size, n: csize_t, f: File): csize_t {.
+  importc: "fread", header: "<stdio.h>", tags: [ReadIOEffect].}
+when defined(windows):
+  when not defined(amd64):
+    proc c_fseek(f: File, offset: int64, whence: cint): cint {.
+      importc: "fseek", header: "<stdio.h>", tags: [].}
+    proc c_ftell(f: File): int64 {.
+      importc: "ftell", header: "<stdio.h>", tags: [].}
+  else:
+    proc c_fseek(f: File, offset: int64, whence: cint): cint {.
+      importc: "_fseeki64", header: "<stdio.h>", tags: [].}
+    when defined(tcc):
+      proc c_fsetpos(f: File, pos: var int64): int32 {.
+        importc: "fsetpos", header: "<stdio.h>", tags: [].}
+      proc c_fgetpos(f: File, pos: var int64): int32 {.
+        importc: "fgetpos", header: "<stdio.h>", tags: [].}
+      proc c_telli64(f: cint): int64 {.
+        importc: "_telli64", header: "<io.h>", tags: [].}
+      proc c_ftell(f: File): int64 =
+        # Taken from https://pt.osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.4-trunk/mingwrt/mingwex/stdio/ftelli64.c
+        result = -1'i64
+        var pos: int64
+        if c_fgetpos(f, pos) == 0 and c_fsetpos(f, pos) == 0:
+          result = c_telli64(c_fileno(f))
+    else:
+      proc c_ftell(f: File): int64 {.
+        importc: "_ftelli64", header: "<stdio.h>", tags: [].}
+else:
+  proc c_fseek(f: File, offset: int64, whence: cint): cint {.
+    importc: "fseeko", header: "<stdio.h>", tags: [].}
+  proc c_ftell(f: File): int64 {.
+    importc: "ftello", header: "<stdio.h>", tags: [].}
+proc c_ferror(f: File): cint {.
+  importc: "ferror", header: "<stdio.h>", tags: [].}
+proc c_setvbuf(f: File, buf: pointer, mode: cint, size: csize_t): cint {.
+  importc: "setvbuf", header: "<stdio.h>", tags: [].}
+
+proc c_fprintf(f: File, frmt: cstring): cint {.
+  importc: "fprintf", header: "<stdio.h>", varargs, discardable.}
+proc c_fputc(c: char, f: File): cint {.
+  importc: "fputc", header: "<stdio.h>".}
+
+proc raiseEIO(msg: string) {.noinline, noreturn.} =
+  raise newException(IOError, msg)
+
+proc raiseEOF() {.noinline, noreturn.} =
+  raise newException(EOFError, "EOF reached")
+
+proc strerror(errnum: cint): cstring {.importc, header: "<string.h>".}
+
+when not defined(nimscript):
+  var
+    errno {.importc, header: "<errno.h>".}: cint ## error variable
+    EINTR {.importc: "EINTR", header: "<errno.h>".}: cint
+
+proc checkErr(f: File) =
+  when not defined(nimscript):
+    if c_ferror(f) != 0:
+      let msg = "errno: " & $errno & " `" & $strerror(errno) & "`"
+      c_clearerr(f)
+      raiseEIO(msg)
+  else:
+    # shouldn't happen
+    quit(1)
+
+{.push stackTrace: off, profiler: off.}
+proc readBuffer*(f: File, buffer: pointer, len: Natural): int {.
+  tags: [ReadIOEffect], benign.} =
+  ## Reads `len` bytes into the buffer pointed to by `buffer`. Returns
+  ## the actual number of bytes that have been read which may be less than
+  ## `len` (if not as many bytes are remaining), but not greater.
+  result = cast[int](c_fread(buffer, 1, cast[csize_t](len), f))
+  if result != len: checkErr(f)
+
+proc readBytes*(f: File, a: var openArray[int8|uint8], start,
+    len: Natural): int {.
+  tags: [ReadIOEffect], benign.} =
+  ## Reads `len` bytes into the buffer `a` starting at `a[start]`. Returns
+  ## the actual number of bytes that have been read which may be less than
+  ## `len` (if not as many bytes are remaining), but not greater.
+  result = readBuffer(f, addr(a[start]), len)
+
+proc readChars*(f: File, a: var openArray[char]): int {.tags: [ReadIOEffect], benign.} =
+  ## Reads up to `a.len` bytes into the buffer `a`. Returns
+  ## the actual number of bytes that have been read which may be less than
+  ## `a.len` (if not as many bytes are remaining), but not greater.
+  result = readBuffer(f, addr(a[0]), a.len)
+
+proc readChars*(f: File, a: var openArray[char], start, len: Natural): int {.
+  tags: [ReadIOEffect], benign, deprecated:
+    "use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))".} =
+  ## Reads `len` bytes into the buffer `a` starting at `a[start]`. Returns
+  ## the actual number of bytes that have been read which may be less than
+  ## `len` (if not as many bytes are remaining), but not greater.
+  if (start + len) > len(a):
+    raiseEIO("buffer overflow: (start+len) > length of openarray buffer")
+  result = readBuffer(f, addr(a[start]), len)
+
+proc write*(f: File, c: cstring) {.tags: [WriteIOEffect], benign.} =
+  ## Writes a value to the file `f`. May throw an IO exception.
+  discard c_fputs(c, f)
+  checkErr(f)
+
+proc writeBuffer*(f: File, buffer: pointer, len: Natural): int {.
+  tags: [WriteIOEffect], benign.} =
+  ## Writes the bytes of buffer pointed to by the parameter `buffer` to the
+  ## file `f`. Returns the number of actual written bytes, which may be less
+  ## than `len` in case of an error.
+  result = cast[int](c_fwrite(buffer, 1, cast[csize_t](len), f))
+  checkErr(f)
+
+proc writeBytes*(f: File, a: openArray[int8|uint8], start, len: Natural): int {.
+  tags: [WriteIOEffect], benign.} =
+  ## Writes the bytes of `a[start..start+len-1]` to the file `f`. Returns
+  ## the number of actual written bytes, which may be less than `len` in case
+  ## of an error.
+  var x = cast[ptr UncheckedArray[int8]](a)
+  result = writeBuffer(f, addr(x[int(start)]), len)
+
+proc writeChars*(f: File, a: openArray[char], start, len: Natural): int {.
+  tags: [WriteIOEffect], benign.} =
+  ## Writes the bytes of `a[start..start+len-1]` to the file `f`. Returns
+  ## the number of actual written bytes, which may be less than `len` in case
+  ## of an error.
+  var x = cast[ptr UncheckedArray[int8]](a)
+  result = writeBuffer(f, addr(x[int(start)]), len)
+
+when defined(windows):
+  proc writeWindows(f: File; s: string; doRaise = false) =
+    # Don't ask why but the 'printf' family of function is the only thing
+    # that writes utf-8 strings reliably on Windows. At least on my Win 10
+    # machine. We also enable `setConsoleOutputCP(65001)` now by default.
+    # But we cannot call printf directly as the string might contain \0.
+    # So we have to loop over all the sections separated by potential \0s.
+    var i = int c_fprintf(f, "%s", s)
+    while i < s.len:
+      if s[i] == '\0':
+        let w = c_fputc('\0', f)
+        if w != 0:
+          if doRaise: raiseEIO("cannot write string to file")
+          break
+        inc i
+      else:
+        let w = c_fprintf(f, "%s", unsafeAddr s[i])
+        if w <= 0:
+          if doRaise: raiseEIO("cannot write string to file")
+          break
+        inc i, w
+
+proc write*(f: File, s: string) {.tags: [WriteIOEffect], benign.} =
+  when defined(windows):
+    writeWindows(f, s, doRaise = true)
+  else:
+    if writeBuffer(f, cstring(s), s.len) != s.len:
+      raiseEIO("cannot write string to file")
+{.pop.}
+
+when defined(nimscript):
+  when defined(windows):
+    const
+      IOFBF = cint(0)
+      IONBF = cint(4)
+  else:
+    # On all systems I could find, including Linux, Mac OS X, and the BSDs
+    const
+      IOFBF = cint(0)
+      IONBF = cint(2)
+else:
+  var
+    IOFBF {.importc: "_IOFBF", nodecl.}: cint
+    IONBF {.importc: "_IONBF", nodecl.}: cint
+
+const SupportIoctlInheritCtl = (defined(linux) or defined(bsd)) and
+                              not defined(nimscript)
+when SupportIoctlInheritCtl:
+  var
+    FIOCLEX {.importc, header: "<sys/ioctl.h>".}: cint
+    FIONCLEX {.importc, header: "<sys/ioctl.h>".}: cint
+
+  proc c_ioctl(fd: cint, request: cint): cint {.
+    importc: "ioctl", header: "<sys/ioctl.h>", varargs.}
+elif defined(posix) and not defined(lwip) and not defined(nimscript):
+  var
+    F_GETFD {.importc, header: "<fcntl.h>".}: cint
+    F_SETFD {.importc, header: "<fcntl.h>".}: cint
+    FD_CLOEXEC {.importc, header: "<fcntl.h>".}: cint
+
+  proc c_fcntl(fd: cint, cmd: cint): cint {.
+    importc: "fcntl", header: "<fcntl.h>", varargs.}
+elif defined(windows):
+  type
+    WinDWORD = culong
+    WinBOOL = cint
+
+  const HANDLE_FLAG_INHERIT = 1.WinDWORD
+
+  proc getOsfhandle(fd: cint): int {.
+    importc: "_get_osfhandle", header: "<io.h>".}
+
+  type
+    IoHandle = distinct pointer
+      ## Windows' HANDLE type. Defined as an untyped pointer but is **not**
+      ## one. Named like this to avoid collision with other `system` modules.
+
+  proc setHandleInformation(hObject: IoHandle, dwMask, dwFlags: WinDWORD):
+                           WinBOOL {.stdcall, dynlib: "kernel32",
+                                  importc: "SetHandleInformation".}
+
+const
+  BufSize = 4000
+
+proc close*(f: File) {.tags: [], gcsafe, sideEffect.} =
+  ## Closes the file.
+  if not f.isNil:
+    discard c_fclose(f)
+
+proc readChar*(f: File): char {.tags: [ReadIOEffect].} =
+  ## Reads a single character from the stream `f`. Should not be used in
+  ## performance sensitive code.
+  let x = c_fgetc(f)
+  if x < 0:
+    checkErr(f)
+    raiseEOF()
+  result = char(x)
+
+proc flushFile*(f: File) {.tags: [WriteIOEffect].} =
+  ## Flushes `f`'s buffer.
+  discard c_fflush(f)
+
+proc getFileHandle*(f: File): FileHandle =
+  ## Returns the file handle of the file `f`. This is only useful for
+  ## platform specific programming.
+  ## Note that on Windows this doesn't return the Windows-specific handle,
+  ## but the C library's notion of a handle, whatever that means.
+  ## Use `getOsFileHandle` instead.
+  c_fileno(f)
+
+proc getOsFileHandle*(f: File): FileHandle =
+  ## Returns the OS file handle of the file `f`. This is only useful for
+  ## platform specific programming.
+  when defined(windows):
+    result = FileHandle getOsfhandle(cint getFileHandle(f))
+  else:
+    result = c_fileno(f)
+
+when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(windows):
+  proc setInheritable*(f: FileHandle, inheritable: bool): bool =
+    ## Controls whether a file handle can be inherited by child processes. Returns
+    ## `true` on success. This requires the OS file handle, which can be
+    ## retrieved via `getOsFileHandle <#getOsFileHandle,File>`_.
+    ##
+    ## This procedure is not guaranteed to be available for all platforms. Test for
+    ## availability with `declared() <system.html#declared,untyped>`_.
+    when SupportIoctlInheritCtl:
+      result = c_ioctl(f, if inheritable: FIONCLEX else: FIOCLEX) != -1
+    elif defined(freertos) or defined(zephyr):
+      result = true
+    elif defined(posix):
+      var flags = c_fcntl(f, F_GETFD)
+      if flags == -1:
+        return false
+      flags = if inheritable: flags and not FD_CLOEXEC else: flags or FD_CLOEXEC
+      result = c_fcntl(f, F_SETFD, flags) != -1
+    else:
+      result = setHandleInformation(cast[IoHandle](f), HANDLE_FLAG_INHERIT,
+                                    inheritable.WinDWORD) != 0
+
+proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
+              benign.} =
+  ## Reads a line of text from the file `f` into `line`. May throw an IO
+  ## exception.
+  ## A line of text may be delimited by `LF` or `CRLF`. The newline
+  ## character(s) are not part of the returned string. Returns `false`
+  ## if the end of the file has been reached, `true` otherwise. If
+  ## `false` is returned `line` contains no new data.
+  proc c_memchr(s: pointer, c: cint, n: csize_t): pointer {.
+    importc: "memchr", header: "<string.h>".}
+
+  when defined(windows):
+    proc readConsole(hConsoleInput: FileHandle, lpBuffer: pointer,
+                     nNumberOfCharsToRead: int32,
+                     lpNumberOfCharsRead: ptr int32,
+                     pInputControl: pointer): int32 {.
+      importc: "ReadConsoleW", stdcall, dynlib: "kernel32".}
+
+    proc getLastError(): int32 {.
+      importc: "GetLastError", stdcall, dynlib: "kernel32", sideEffect.}
+
+    proc formatMessageW(dwFlags: int32, lpSource: pointer,
+                        dwMessageId, dwLanguageId: int32,
+                        lpBuffer: pointer, nSize: int32,
+                        arguments: pointer): int32 {.
+      importc: "FormatMessageW", stdcall, dynlib: "kernel32".}
+
+    proc localFree(p: pointer) {.
+      importc: "LocalFree", stdcall, dynlib: "kernel32".}
+
+    proc isatty(f: File): bool =
+      when defined(posix):
+        proc isatty(fildes: FileHandle): cint {.
+          importc: "isatty", header: "<unistd.h>".}
+      else:
+        proc isatty(fildes: FileHandle): cint {.
+          importc: "_isatty", header: "<io.h>".}
+      result = isatty(getFileHandle(f)) != 0'i32
+
+    # this implies the file is open
+    if f.isatty:
+      const numberOfCharsToRead = 2048
+      var numberOfCharsRead = 0'i32
+      var buffer = newWideCString(numberOfCharsToRead)
+      if readConsole(getOsFileHandle(f), addr(buffer[0]),
+        numberOfCharsToRead, addr(numberOfCharsRead), nil) == 0:
+        var error = getLastError()
+        var errorMsg: string
+        var msgbuf: WideCString
+        if formatMessageW(0x00000100 or 0x00001000 or 0x00000200,
+                        nil, error, 0, addr(msgbuf), 0, nil) != 0'i32:
+          errorMsg = $msgbuf
+          if msgbuf != nil:
+            localFree(cast[pointer](msgbuf))
+        raiseEIO("error: " & $error & " `" & errorMsg & "`")
+      # input always ends with "\r\n"
+      numberOfCharsRead -= 2
+      # handle Ctrl+Z as EOF
+      for i in 0..<numberOfCharsRead:
+        if buffer[i].uint16 == 26: #Ctrl+Z
+          close(f) #has the same effect as setting EOF
+          if i == 0:
+            line = ""
+            return false
+          numberOfCharsRead = i
+          break
+      buffer[numberOfCharsRead] = 0.Utf16Char
+      when defined(nimv2):
+        line = $toWideCString(buffer)
+      else:
+        line = $buffer
+      return(true)
+
+  var pos = 0
+
+  # Use the currently reserved space for a first try
+  var sp = max(line.len, 80)
+  line.setLen(sp)
+
+  while true:
+    # memset to \L so that we can tell how far fgets wrote, even on EOF, where
+    # fgets doesn't append an \L
+    for i in 0..<sp: line[pos+i] = '\L'
+
+    var fgetsSuccess: bool
+    while true:
+      # fixes #9634; this pattern may need to be abstracted as a template if reused;
+      # likely other io procs need this for correctness.
+      fgetsSuccess = c_fgets(cast[cstring](addr line[pos]), sp.cint, f) != nil
+      if fgetsSuccess: break
+      when not defined(nimscript):
+        if errno == EINTR:
+          errno = 0
+          c_clearerr(f)
+          continue
+      checkErr(f)
+      break
+
+    let m = c_memchr(addr line[pos], '\L'.ord, cast[csize_t](sp))
+    if m != nil:
+      # \l found: Could be our own or the one by fgets, in any case, we're done
+      var last = cast[int](m) - cast[int](addr line[0])
+      if last > 0 and line[last-1] == '\c':
+        line.setLen(last-1)
+        return last > 1 or fgetsSuccess
+      elif last > 0 and line[last-1] == '\0':
+        # We have to distinguish among three possible cases:
+        # \0\l\0 => line ending in a null character.
+        # \0\l\l => last line without newline, null was put there by fgets.
+        #   \0\l => last line without newline, null was put there by fgets.
+        if last >= pos + sp - 1 or line[last+1] != '\0': # bug #21273
+          dec last
+      line.setLen(last)
+      return last > 0 or fgetsSuccess
+    else:
+      # fgets will have inserted a null byte at the end of the string.
+      dec sp
+    # No \l found: Increase buffer and read more
+    inc pos, sp
+    sp = 128 # read in 128 bytes at a time
+    line.setLen(pos+sp)
+
+proc readLine*(f: File): string {.tags: [ReadIOEffect], benign.} =
+  ## Reads a line of text from the file `f`. May throw an IO exception.
+  ## A line of text may be delimited by `LF` or `CRLF`. The newline
+  ## character(s) are not part of the returned string.
+  result = newStringOfCap(80)
+  if not readLine(f, result): raiseEOF()
+
+proc write*(f: File, i: int) {.tags: [WriteIOEffect], benign.} =
+  when sizeof(int) == 8:
+    if c_fprintf(f, "%lld", i) < 0: checkErr(f)
+  else:
+    if c_fprintf(f, "%ld", i) < 0: checkErr(f)
+
+proc write*(f: File, i: BiggestInt) {.tags: [WriteIOEffect], benign.} =
+  when sizeof(BiggestInt) == 8:
+    if c_fprintf(f, "%lld", i) < 0: checkErr(f)
+  else:
+    if c_fprintf(f, "%ld", i) < 0: checkErr(f)
+
+proc write*(f: File, b: bool) {.tags: [WriteIOEffect], benign.} =
+  if b: write(f, "true")
+  else: write(f, "false")
+
+proc write*(f: File, r: float32) {.tags: [WriteIOEffect], benign.} =
+  var buffer {.noinit.}: array[65, char]
+  discard writeFloatToBuffer(buffer, r)
+  if c_fprintf(f, "%s", buffer[0].addr) < 0: checkErr(f)
+
+proc write*(f: File, r: BiggestFloat) {.tags: [WriteIOEffect], benign.} =
+  var buffer {.noinit.}: array[65, char]
+  discard writeFloatToBuffer(buffer, r)
+  if c_fprintf(f, "%s", buffer[0].addr) < 0: checkErr(f)
+
+proc write*(f: File, c: char) {.tags: [WriteIOEffect], benign.} =
+  discard c_putc(cint(c), f)
+
+proc write*(f: File, a: varargs[string, `$`]) {.tags: [WriteIOEffect], benign.} =
+  for x in items(a): write(f, x)
+
+proc readAllBuffer(file: File): string =
+  # This proc is for File we want to read but don't know how many
+  # bytes we need to read before the buffer is empty.
+  result = ""
+  var buffer = newString(BufSize)
+  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: File): int64 =
+  # this does not raise an error opposed to `getFileSize`
+  var oldPos = c_ftell(file)
+  discard c_fseek(file, 0, 2) # seek the end of the file
+  result = c_ftell(file)
+  discard c_fseek(file, oldPos, 0)
+
+proc endOfFile*(f: File): bool {.tags: [], benign.} =
+  ## Returns true if `f` is at the end.
+  var c = c_fgetc(f)
+  discard c_ungetc(c, f)
+  return c < 0'i32
+  #result = c_feof(f) != 0
+
+proc readAllFile(file: File, len: int64): string =
+  # We acquire the filesize beforehand and hope it doesn't change.
+  # Speeds things up.
+  result = newString(len)
+  let bytes = readBuffer(file, addr(result[0]), len)
+  if endOfFile(file):
+    if bytes.int64 < len:
+      result.setLen(bytes)
+  else:
+    # We read all the bytes but did not reach the EOF
+    # Try to read it as a buffer
+    result.add(readAllBuffer(file))
+
+proc readAllFile(file: File): string =
+  var len = rawFileSize(file)
+  result = readAllFile(file, len)
+
+proc readAll*(file: File): string {.tags: [ReadIOEffect], benign.} =
+  ## Reads all data from the stream `file`.
+  ##
+  ## Raises an IO exception in case of an error. It is an error if the
+  ## current file position is not at the beginning of the file.
+
+  # Separate handling needed because we need to buffer when we
+  # don't know the overall length of the File.
+  when declared(stdin):
+    let len = if file != stdin: rawFileSize(file) else: -1
+  else:
+    let len = rawFileSize(file)
+  if len > 0:
+    result = readAllFile(file, len)
+  else:
+    result = readAllBuffer(file)
+
+proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
+                          tags: [WriteIOEffect], benign.} =
+  ## Writes the values `x` to `f` and then writes "\\n".
+  ## May throw an IO exception.
+  for i in items(x):
+    write(f, i)
+  write(f, "\n")
+
+# interface to the C procs:
+
+when defined(windows):
+  when defined(cpp):
+    proc wfopen(filename, mode: WideCString): pointer {.
+      importcpp: "_wfopen((const wchar_t*)#, (const wchar_t*)#)", nodecl.}
+    proc wfreopen(filename, mode: WideCString, stream: File): File {.
+      importcpp: "_wfreopen((const wchar_t*)#, (const wchar_t*)#, #)", nodecl.}
+  else:
+    proc wfopen(filename, mode: WideCString): pointer {.
+      importc: "_wfopen", nodecl.}
+    proc wfreopen(filename, mode: WideCString, stream: File): File {.
+      importc: "_wfreopen", nodecl.}
+
+  proc fopen(filename, mode: cstring): pointer =
+    var f = newWideCString(filename)
+    var m = newWideCString(mode)
+    result = wfopen(f, m)
+
+  proc freopen(filename, mode: cstring, stream: File): File =
+    var f = newWideCString(filename)
+    var m = newWideCString(mode)
+    result = wfreopen(f, m, stream)
+
+else:
+  proc fopen(filename, mode: cstring): pointer {.importc: "fopen", nodecl.}
+  proc freopen(filename, mode: cstring, stream: File): File {.
+    importc: "freopen", nodecl.}
+
+const
+  NoInheritFlag =
+    # Platform specific flag for creating a File without inheritance.
+    when not defined(nimInheritHandles):
+      when defined(windows):
+        "N"
+      elif defined(linux) or defined(bsd):
+        "e"
+      else:
+        ""
+    else:
+      ""
+  RawFormatOpen: array[FileMode, cstring] = [
+    # used for open by FileHandle, which calls `fdopen`
+    cstring("rb"), "wb", "w+b", "r+b", "ab"]
+  FormatOpen: array[FileMode, cstring] = [
+    cstring("rb" & NoInheritFlag), "wb" & NoInheritFlag, "w+b" & NoInheritFlag,
+    "r+b" & NoInheritFlag, "ab" & NoInheritFlag
+  ]
+    #"rt", "wt", "w+t", "r+t", "at"
+    # we always use binary here as for Nim the OS line ending
+    # should not be translated.
+
+when defined(posix) and not defined(nimscript):
+  when defined(linux) and defined(amd64):
+    type
+      Mode {.importc: "mode_t", header: "<sys/types.h>".} = cint
+
+      # fillers ensure correct size & offsets
+      Stat {.importc: "struct stat",
+              header: "<sys/stat.h>", final, pure.} = object ## struct stat
+        filler_1: array[24, char]
+        st_mode: Mode ## Mode of file
+        filler_2: array[144 - 24 - 4, char]
+
+    proc modeIsDir(m: Mode): bool =
+      ## Test for a directory.
+      (m and 0o170000) == 0o40000
+
+  else:
+    type
+      Mode {.importc: "mode_t", header: "<sys/types.h>".} = cint
+
+      Stat {.importc: "struct stat",
+               header: "<sys/stat.h>", final, pure.} = object ## struct stat
+        st_mode: Mode ## Mode of file
+
+    proc modeIsDir(m: Mode): bool {.importc: "S_ISDIR", header: "<sys/stat.h>".}
+      ## Test for a directory.
+
+  proc c_fstat(a1: cint, a2: var Stat): cint {.
+    importc: "fstat", header: "<sys/stat.h>".}
+
+
+proc open*(f: var File, filename: string,
+          mode: FileMode = fmRead,
+          bufSize: int = -1): bool {.tags: [], raises: [], benign.} =
+  ## Opens a file named `filename` with given `mode`.
+  ##
+  ## Default mode is readonly. Returns true if the file could be opened.
+  ## This throws no exception if the file could not be opened.
+  ##
+  ## The file handle associated with the resulting `File` is not inheritable.
+  var p = fopen(filename.cstring, FormatOpen[mode])
+  if p != nil:
+    var f2 = cast[File](p)
+    when defined(posix) and not defined(nimscript):
+      # How `fopen` handles opening a directory is not specified in ISO C and
+      # POSIX. We do not want to handle directories as regular files that can
+      # be opened.
+      var res {.noinit.}: Stat
+      if c_fstat(getFileHandle(f2), res) >= 0'i32 and modeIsDir(res.st_mode):
+        close(f2)
+        return false
+    when not defined(nimInheritHandles) and declared(setInheritable) and
+         NoInheritFlag.len == 0:
+      if not setInheritable(getOsFileHandle(f2), false):
+        close(f2)
+        return false
+
+    result = true
+    f = cast[File](p)
+    if bufSize > 0 and bufSize.uint <= high(uint):
+      discard c_setvbuf(f, nil, IOFBF, cast[csize_t](bufSize))
+    elif bufSize == 0:
+      discard c_setvbuf(f, nil, IONBF, 0)
+
+proc reopen*(f: File, filename: string, mode: FileMode = fmRead): bool {.
+  tags: [], benign.} =
+  ## Reopens the file `f` with given `filename` and `mode`. This
+  ## is often used to redirect the `stdin`, `stdout` or `stderr`
+  ## file variables.
+  ##
+  ## Default mode is readonly. Returns true if the file could be reopened.
+  ##
+  ## The file handle associated with `f` won't be inheritable.
+  if freopen(filename.cstring, FormatOpen[mode], f) != nil:
+    when not defined(nimInheritHandles) and declared(setInheritable) and
+         NoInheritFlag.len == 0:
+      if not setInheritable(getOsFileHandle(f), false):
+        close(f)
+        return false
+    result = true
+
+proc open*(f: var File, filehandle: FileHandle,
+           mode: FileMode = fmRead): bool {.tags: [], raises: [], benign.} =
+  ## Creates a `File` from a `filehandle` with given `mode`.
+  ##
+  ## Default mode is readonly. Returns true if the file could be opened.
+  ##
+  ## The passed file handle will no longer be inheritable.
+  when not defined(nimInheritHandles) and declared(setInheritable):
+    let oshandle = when defined(windows): FileHandle getOsfhandle(
+        filehandle) else: filehandle
+    if not setInheritable(oshandle, false):
+      return false
+  f = c_fdopen(filehandle, RawFormatOpen[mode])
+  result = f != nil
+
+proc open*(filename: string,
+            mode: FileMode = fmRead, bufSize: int = -1): File =
+  ## Opens a file named `filename` with given `mode`.
+  ##
+  ## Default mode is readonly. Raises an `IOError` if the file
+  ## could not be opened.
+  ##
+  ## The file handle associated with the resulting `File` is not inheritable.
+  if not open(result, filename, mode, bufSize):
+    raise newException(IOError, "cannot open: " & filename)
+
+proc setFilePos*(f: File, pos: int64, relativeTo: FileSeekPos = fspSet) {.benign, sideEffect.} =
+  ## Sets the position of the file pointer that is used for read/write
+  ## operations. The file's first byte has the index zero.
+  if c_fseek(f, pos, cint(relativeTo)) != 0:
+    raiseEIO("cannot set file position")
+
+proc getFilePos*(f: File): int64 {.benign.} =
+  ## Retrieves the current position of the file pointer that is used to
+  ## read from the file `f`. The file's first byte has the index zero.
+  result = c_ftell(f)
+  if result < 0: raiseEIO("cannot retrieve file position")
+
+proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.} =
+  ## Retrieves the file size (in bytes) of `f`.
+  let oldPos = getFilePos(f)
+  discard c_fseek(f, 0, 2) # seek the end of the file
+  result = getFilePos(f)
+  setFilePos(f, oldPos)
+
+proc setStdIoUnbuffered*() {.tags: [], benign.} =
+  ## Configures `stdin`, `stdout` and `stderr` to be unbuffered.
+  when declared(stdout):
+    discard c_setvbuf(stdout, nil, IONBF, 0)
+  when declared(stderr):
+    discard c_setvbuf(stderr, nil, IONBF, 0)
+  when declared(stdin):
+    discard c_setvbuf(stdin, nil, IONBF, 0)
+
+
+when defined(windows) and not defined(nimscript) and not defined(js):
+  # work-around C's sucking abstraction:
+  # BUGFIX: stdin and stdout should be binary files!
+  proc c_setmode(handle, mode: cint) {.
+    importc: when defined(bcc): "setmode" else: "_setmode",
+    header: "<io.h>".}
+  var
+    O_BINARY {.importc: "_O_BINARY", header: "<fcntl.h>".}: cint
+
+  # we use binary mode on Windows:
+  c_setmode(c_fileno(stdin), O_BINARY)
+  c_setmode(c_fileno(stdout), O_BINARY)
+  c_setmode(c_fileno(stderr), O_BINARY)
+
+when defined(windows) and appType == "console" and
+    not defined(nimDontSetUtf8CodePage) and not defined(nimscript):
+  import std/exitprocs
+
+  proc setConsoleOutputCP(codepage: cuint): int32 {.stdcall, dynlib: "kernel32",
+    importc: "SetConsoleOutputCP".}
+  proc setConsoleCP(wCodePageID: cuint): int32 {.stdcall, dynlib: "kernel32",
+    importc: "SetConsoleCP".}
+  proc getConsoleOutputCP(): cuint {.stdcall, dynlib: "kernel32",
+    importc: "GetConsoleOutputCP".}
+  proc getConsoleCP(): cuint {.stdcall, dynlib: "kernel32",
+    importc: "GetConsoleCP".}
+
+  const Utf8codepage = 65001'u32
+
+  let
+    consoleOutputCP = getConsoleOutputCP()
+    consoleCP = getConsoleCP()
+
+  proc restoreConsoleOutputCP() = discard setConsoleOutputCP(consoleOutputCP)
+  proc restoreConsoleCP() = discard setConsoleCP(consoleCP)
+
+  if consoleOutputCP != Utf8codepage:
+    discard setConsoleOutputCP(Utf8codepage)
+    addExitProc(restoreConsoleOutputCP)
+
+  if consoleCP != Utf8codepage:
+    discard setConsoleCP(Utf8codepage)
+    addExitProc(restoreConsoleCP)
+
+proc readFile*(filename: string): string {.tags: [ReadIOEffect], benign.} =
+  ## Opens a file named `filename` for reading, calls `readAll
+  ## <#readAll,File>`_ and closes the file afterwards. Returns the string.
+  ## Raises an IO exception in case of an error. If you need to call
+  ## this inside a compile time macro you can use `staticRead
+  ## <system.html#staticRead,string>`_.
+  var f: File = nil
+  if open(f, filename):
+    try:
+      result = readAll(f)
+    finally:
+      close(f)
+  else:
+    raise newException(IOError, "cannot open: " & filename)
+
+proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} =
+  ## Opens a file named `filename` for writing. Then writes the
+  ## `content` completely to the file and closes the file afterwards.
+  ## Raises an IO exception in case of an error.
+  var f: File = nil
+  if open(f, filename, fmWrite):
+    try:
+      f.write(content)
+    finally:
+      close(f)
+  else:
+    raise newException(IOError, "cannot open: " & filename)
+
+proc writeFile*(filename: string, content: openArray[byte]) {.since: (1, 1).} =
+  ## Opens a file named `filename` for writing. Then writes the
+  ## `content` completely to the file and closes the file afterwards.
+  ## Raises an IO exception in case of an error.
+  var f: File = nil
+  if open(f, filename, fmWrite):
+    try:
+      discard f.writeBuffer(unsafeAddr content[0], content.len)
+    finally:
+      close(f)
+  else:
+    raise newException(IOError, "cannot open: " & filename)
+
+proc readLines*(filename: string, n: Natural): seq[string] =
+  ## Reads `n` lines from the file named `filename`. Raises an IO exception
+  ## in case of an error. Raises EOF if file does not contain at least `n` lines.
+  ## Available at compile time. A line of text may be delimited by `LF` or `CRLF`.
+  ## The newline character(s) are not part of the returned strings.
+  var f: File = nil
+  if open(f, filename):
+    try:
+      result = newSeq[string](n)
+      for i in 0 .. n - 1:
+        if not readLine(f, result[i]):
+          raiseEOF()
+    finally:
+      close(f)
+  else:
+    raise newException(IOError, "cannot open: " & filename)
+
+template readLines*(filename: string): seq[
+    string] {.deprecated: "use readLines with two arguments".} =
+  readLines(filename, 1)
+
+iterator lines*(filename: string): string {.tags: [ReadIOEffect].} =
+  ## Iterates over any line in the file named `filename`.
+  ##
+  ## If the file does not exist `IOError` is raised. The trailing newline
+  ## character(s) are removed from the iterated lines. Example:
+  ##
+  runnableExamples:
+    import std/strutils
+
+    proc transformLetters(filename: string) =
+      var buffer = ""
+      for line in filename.lines:
+        buffer.add(line.replace("a", "0") & '\n')
+      writeFile(filename, buffer)
+  var f = open(filename, bufSize = 8000)
+  try:
+    var res = newStringOfCap(80)
+    while f.readLine(res): yield res
+  finally:
+    close(f)
+
+iterator lines*(f: File): string {.tags: [ReadIOEffect].} =
+  ## Iterates over any line in the file `f`.
+  ##
+  ## The trailing newline character(s) are removed from the iterated lines.
+  ##
+  runnableExamples:
+    proc countZeros(filename: File): tuple[lines, zeros: int] =
+      for line in filename.lines:
+        for letter in line:
+          if letter == '0':
+            result.zeros += 1
+        result.lines += 1
+  var res = newStringOfCap(80)
+  while f.readLine(res): yield res
+
+template `&=`*(f: File, x: typed) =
+  ## An alias for `write`.
+  write(f, x)
diff --git a/lib/std/sysatomics.nim b/lib/std/sysatomics.nim
new file mode 100644
index 000000000..2f203b3eb
--- /dev/null
+++ b/lib/std/sysatomics.nim
@@ -0,0 +1,376 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimPreviewSlimSystem):
+  {.deprecated: "use `std/atomics` instead".}
+
+# Atomic operations for Nim.
+{.push stackTrace:off, profiler:off.}
+
+const
+  hasThreadSupport = compileOption("threads") and not defined(nimscript)
+const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang) or defined(nintendoswitch)
+const someVcc = defined(vcc) or defined(clang_cl)
+
+type
+  AtomType* = SomeNumber|pointer|ptr|char|bool
+    ## Type Class representing valid types for use with atomic procs
+
+when someGcc:
+  type AtomMemModel* = distinct cint
+
+  var ATOMIC_RELAXED* {.importc: "__ATOMIC_RELAXED", nodecl.}: AtomMemModel
+    ## No barriers or synchronization.
+  var ATOMIC_CONSUME* {.importc: "__ATOMIC_CONSUME", nodecl.}: AtomMemModel
+    ## Data dependency only for both barrier and
+    ## synchronization with another thread.
+  var ATOMIC_ACQUIRE* {.importc: "__ATOMIC_ACQUIRE", nodecl.}: AtomMemModel
+    ## Barrier to hoisting of code and synchronizes with
+    ## release (or stronger)
+    ## semantic stores from another thread.
+  var ATOMIC_RELEASE* {.importc: "__ATOMIC_RELEASE", nodecl.}: AtomMemModel
+    ## Barrier to sinking of code and synchronizes with
+    ## acquire (or stronger)
+    ## semantic loads from another thread.
+  var ATOMIC_ACQ_REL* {.importc: "__ATOMIC_ACQ_REL", nodecl.}: AtomMemModel
+    ## Full barrier in both directions and synchronizes
+    ## with acquire loads
+    ## and release stores in another thread.
+  var ATOMIC_SEQ_CST* {.importc: "__ATOMIC_SEQ_CST", nodecl.}: AtomMemModel
+    ## Full barrier in both directions and synchronizes
+    ## with acquire loads
+    ## and release stores in all threads.
+
+  proc atomicLoadN*[T: AtomType](p: ptr T, mem: AtomMemModel): T {.
+    importc: "__atomic_load_n", nodecl.}
+    ## This proc implements an atomic load operation. It returns the contents at p.
+    ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, ATOMIC_ACQUIRE, ATOMIC_CONSUME.
+
+  proc atomicLoad*[T: AtomType](p, ret: ptr T, mem: AtomMemModel) {.
+    importc: "__atomic_load", nodecl.}
+    ## This is the generic version of an atomic load. It returns the contents at p in ret.
+
+  proc atomicStoreN*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel) {.
+    importc: "__atomic_store_n", nodecl.}
+    ## This proc implements an atomic store operation. It writes val at p.
+    ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, and ATOMIC_RELEASE.
+
+  proc atomicStore*[T: AtomType](p, val: ptr T, mem: AtomMemModel) {.
+    importc: "__atomic_store", nodecl.}
+    ## This is the generic version of an atomic store. It stores the value of val at p
+
+  proc atomicExchangeN*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_exchange_n", nodecl.}
+    ## This proc implements an atomic exchange operation. It writes val at p,
+    ## and returns the previous contents at p.
+    ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, ATOMIC_ACQUIRE, ATOMIC_RELEASE, ATOMIC_ACQ_REL
+
+  proc atomicExchange*[T: AtomType](p, val, ret: ptr T, mem: AtomMemModel) {.
+    importc: "__atomic_exchange", nodecl.}
+    ## This is the generic version of an atomic exchange. It stores the contents at val at p.
+    ## The original value at p is copied into ret.
+
+  proc atomicCompareExchangeN*[T: AtomType](p, expected: ptr T, desired: T,
+    weak: bool, success_memmodel: AtomMemModel, failure_memmodel: AtomMemModel): bool {.
+    importc: "__atomic_compare_exchange_n", nodecl.}
+    ## This proc implements an atomic compare and exchange operation. This compares the
+    ## contents at p with the contents at expected and if equal, writes desired at p.
+    ## If they are not equal, the current contents at p is written into expected.
+    ## Weak is true for weak compare_exchange, and false for the strong variation.
+    ## Many targets only offer the strong variation and ignore the parameter.
+    ## When in doubt, use the strong variation.
+    ## True is returned if desired is written at p and the execution is considered
+    ## to conform to the memory model specified by success_memmodel. There are no
+    ## restrictions on what memory model can be used here. False is returned otherwise,
+    ## and the execution is considered to conform to failure_memmodel. This memory model
+    ## cannot be __ATOMIC_RELEASE nor __ATOMIC_ACQ_REL. It also cannot be a stronger model
+    ## than that specified by success_memmodel.
+
+  proc atomicCompareExchange*[T: AtomType](p, expected, desired: ptr T,
+    weak: bool, success_memmodel: AtomMemModel, failure_memmodel: AtomMemModel): bool {.
+    importc: "__atomic_compare_exchange", nodecl.}
+    ## This proc implements the generic version of atomic_compare_exchange.
+    ## The proc is virtually identical to atomic_compare_exchange_n, except the desired
+    ## value is also a pointer.
+
+  ## Perform the operation return the new value, all memory models are valid
+  proc atomicAddFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_add_fetch", nodecl.}
+  proc atomicSubFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_sub_fetch", nodecl.}
+  proc atomicOrFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_or_fetch", nodecl.}
+  proc atomicAndFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_and_fetch", nodecl.}
+  proc atomicXorFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_xor_fetch", nodecl.}
+  proc atomicNandFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_nand_fetch", nodecl.}
+
+  ## Perform the operation return the old value, all memory models are valid
+  proc atomicFetchAdd*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_add", nodecl.}
+  proc atomicFetchSub*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_sub", nodecl.}
+  proc atomicFetchOr*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_or", nodecl.}
+  proc atomicFetchAnd*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_and", nodecl.}
+  proc atomicFetchXor*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_xor", nodecl.}
+  proc atomicFetchNand*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {.
+    importc: "__atomic_fetch_nand", nodecl.}
+
+  proc atomicTestAndSet*(p: pointer, mem: AtomMemModel): bool {.
+    importc: "__atomic_test_and_set", nodecl.}
+    ## This built-in function performs an atomic test-and-set operation on the byte at p.
+    ## The byte is set to some implementation defined nonzero "set" value and the return
+    ## value is true if and only if the previous contents were "set".
+    ## All memory models are valid.
+
+  proc atomicClear*(p: pointer, mem: AtomMemModel) {.
+    importc: "__atomic_clear", nodecl.}
+    ## This built-in function performs an atomic clear operation at p.
+    ## After the operation, at p contains 0.
+    ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, ATOMIC_RELEASE
+
+  proc atomicThreadFence*(mem: AtomMemModel) {.
+    importc: "__atomic_thread_fence", nodecl.}
+    ## This built-in function acts as a synchronization fence between threads based
+    ## on the specified memory model. All memory orders are valid.
+
+  proc atomicSignalFence*(mem: AtomMemModel) {.
+    importc: "__atomic_signal_fence", nodecl.}
+    ## This built-in function acts as a synchronization fence between a thread and
+    ## signal handlers based in the same thread. All memory orders are valid.
+
+  proc atomicAlwaysLockFree*(size: int, p: pointer): bool {.
+    importc: "__atomic_always_lock_free", nodecl.}
+    ## This built-in function returns true if objects of size bytes always generate
+    ## lock free atomic instructions for the target architecture. size must resolve
+    ## to a compile-time constant and the result also resolves to a compile-time constant.
+    ## ptr is an optional pointer to the object that may be used to determine alignment.
+    ## A value of 0 indicates typical alignment should be used. The compiler may also
+    ## ignore this parameter.
+
+  proc atomicIsLockFree*(size: int, p: pointer): bool {.
+    importc: "__atomic_is_lock_free", nodecl.}
+    ## This built-in function returns true if objects of size bytes always generate
+    ## lock free atomic instructions for the target architecture. If it is not known
+    ## to be lock free a call is made to a runtime routine named __atomic_is_lock_free.
+    ## ptr is an optional pointer to the object that may be used to determine alignment.
+    ## A value of 0 indicates typical alignment should be used. The compiler may also
+    ## ignore this parameter.
+
+  template fence*() = atomicThreadFence(ATOMIC_SEQ_CST)
+elif someVcc:
+  type AtomMemModel* = distinct cint
+
+  const
+    ATOMIC_RELAXED* = 0.AtomMemModel
+    ATOMIC_CONSUME* = 1.AtomMemModel
+    ATOMIC_ACQUIRE* = 2.AtomMemModel
+    ATOMIC_RELEASE* = 3.AtomMemModel
+    ATOMIC_ACQ_REL* = 4.AtomMemModel
+    ATOMIC_SEQ_CST* = 5.AtomMemModel
+
+  proc `==`(x1, x2: AtomMemModel): bool {.borrow.}
+
+  proc readBarrier() {.importc: "_ReadBarrier", header: "<intrin.h>".}
+  proc writeBarrier() {.importc: "_WriteBarrier", header: "<intrin.h>".}
+  proc fence*() {.importc: "_ReadWriteBarrier", header: "<intrin.h>".}
+
+  when defined(cpp):
+    proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
+      {.importcpp: "_InterlockedCompareExchange64(static_cast<NI64 volatile *>(#), #, #)", header: "<intrin.h>".}
+    proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
+      {.importcpp: "_InterlockedCompareExchange(static_cast<long volatile *>(#), #, #)", header: "<intrin.h>".}
+    proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
+      {.importcpp: "_InterlockedCompareExchange8(static_cast<char volatile *>(#), #, #)", header: "<intrin.h>".}
+    proc interlockedExchange8(location: pointer; desired: int8): int8 {.importcpp: "_InterlockedExchange8(static_cast<NI8 volatile *>(#), #)", header: "<intrin.h>".}
+    proc interlockedExchange16(location: pointer; desired: int16): int16 {.importcpp: "_InterlockedExchange16(static_cast<NI16 volatile *>(#), #)", header: "<intrin.h>".}
+    proc interlockedExchange32(location: pointer; desired: int32): int32 {.importcpp: "_InterlockedExchange(static_cast<long volatile *>(#), #)", header: "<intrin.h>".}
+    proc interlockedExchange64(location: pointer; desired: int64): int64 {.importcpp: "_InterlockedExchange64(static_cast<NI64 volatile *>(#), #)", header: "<intrin.h>".}
+  else:
+    proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
+      {.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
+    proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
+      {.importc: "_InterlockedCompareExchange", header: "<intrin.h>".}
+    proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
+      {.importc: "_InterlockedCompareExchange8", header: "<intrin.h>".}
+
+    proc interlockedExchange8(location: pointer; desired: int8): int8 {.importc: "_InterlockedExchange8", header: "<intrin.h>".}
+    proc interlockedExchange16(location: pointer; desired: int16): int16 {.importc: "_InterlockedExchange16", header: "<intrin.h>".}
+    proc interlockedExchange32(location: pointer; desired: int32): int32 {.importc: "_InterlockedExchange", header: "<intrin.h>".}
+    proc interlockedExchange64(location: pointer; desired: int64): int64 {.importc: "_InterlockedExchange64", header: "<intrin.h>".}
+
+
+  template barrier(mem: AtomMemModel) =
+    when mem == ATOMIC_RELAXED: discard
+    elif mem == ATOMIC_CONSUME: readBarrier()
+    elif mem == ATOMIC_ACQUIRE: writeBarrier()
+    elif mem == ATOMIC_RELEASE: fence()
+    elif mem == ATOMIC_ACQ_REL: fence()
+    elif mem == ATOMIC_SEQ_CST: fence()
+
+  proc atomicStoreN*[T: AtomType](p: ptr T, val: T, mem: static[AtomMemModel]) =
+    barrier(mem)
+    p[] = val
+
+  proc atomicLoadN*[T: AtomType](p: ptr T, mem: static[AtomMemModel]): T =
+    result = p[]
+    barrier(mem)
+
+  proc atomicCompareExchangeN*[T: ptr](p, expected: ptr T, desired: T,
+    weak: bool, success_memmodel: AtomMemModel, failure_memmodel: AtomMemModel): bool =
+    when sizeof(T) == 8:
+      interlockedCompareExchange64(p, cast[int64](desired), cast[int64](expected)) ==
+        cast[int64](expected)
+    elif sizeof(T) == 4:
+      interlockedCompareExchange32(p, cast[int32](desired), cast[int32](expected)) ==
+        cast[int32](expected)
+
+  proc atomicExchangeN*[T: ptr](p: ptr T, val: T, mem: AtomMemModel): T =
+    when sizeof(T) == 8:
+      cast[T](interlockedExchange64(p, cast[int64](val)))
+    elif sizeof(T) == 4:
+      cast[T](interlockedExchange32(p, cast[int32](val)))
+  when defined(cpp):
+    when sizeof(int) == 8:
+      proc addAndFetch*(p: ptr int, val: int): int {.
+        importcpp: "_InterlockedExchangeAdd64(static_cast<NI volatile *>(#), #)",
+        header: "<intrin.h>".}
+    else:
+      proc addAndFetch*(p: ptr int, val: int): int {.
+        importcpp: "_InterlockedExchangeAdd(reinterpret_cast<long volatile *>(#), static_cast<long>(#))",
+        header: "<intrin.h>".}
+  else:
+    when sizeof(int) == 8:
+      proc addAndFetch*(p: ptr int, val: int): int {.
+        importc: "_InterlockedExchangeAdd64", header: "<intrin.h>".}
+    else:
+      proc addAndFetch*(p: ptr int, val: int): int {.
+        importc: "_InterlockedExchangeAdd", header: "<intrin.h>".}
+
+else:
+  proc addAndFetch*(p: ptr int, val: int): int {.inline.} =
+    inc(p[], val)
+    result = p[]
+
+
+proc atomicInc*(memLoc: var int, x: int = 1): int {.inline, discardable, raises: [], tags: [].} =
+  ## Atomically increments the integer by some `x`. It returns the new value.
+  when someGcc and hasThreadSupport:
+    result = atomicAddFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
+  elif someVcc and hasThreadSupport:
+    result = addAndFetch(memLoc.addr, x)
+    inc(result, x)
+  else:
+    inc(memLoc, x)
+    result = memLoc
+
+proc atomicDec*(memLoc: var int, x: int = 1): int {.inline, discardable, raises: [], tags: [].} =
+  ## Atomically decrements the integer by some `x`. It returns the new value.
+  when someGcc and hasThreadSupport:
+    when declared(atomicSubFetch):
+      result = atomicSubFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
+    else:
+      result = atomicAddFetch(memLoc.addr, -x, ATOMIC_SEQ_CST)
+  elif someVcc and hasThreadSupport:
+    result = addAndFetch(memLoc.addr, -x)
+    dec(result, x)
+  else:
+    dec(memLoc, x)
+    result = memLoc
+
+when someVcc:
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
+    when sizeof(T) == 8:
+      interlockedCompareExchange64(p, cast[int64](newValue), cast[int64](oldValue)) ==
+        cast[int64](oldValue)
+    elif sizeof(T) == 4:
+      interlockedCompareExchange32(p, cast[int32](newValue), cast[int32](oldValue)) ==
+        cast[int32](oldValue)
+    elif sizeof(T) == 1:
+      interlockedCompareExchange8(p, cast[byte](newValue), cast[byte](oldValue)) ==
+        cast[byte](oldValue)
+    else:
+      {.error: "invalid CAS instruction".}
+
+elif defined(tcc):
+  when defined(amd64):
+    {.emit:"""
+static int __tcc_cas(int *ptr, int oldVal, int newVal)
+{
+    unsigned char ret;
+    __asm__ __volatile__ (
+            "  lock\n"
+            "  cmpxchgq %2,%1\n"
+            "  sete %0\n"
+            : "=q" (ret), "=m" (*ptr)
+            : "r" (newVal), "m" (*ptr), "a" (oldVal)
+            : "memory");
+
+    return ret;
+}
+""".}
+  else:
+    #assert sizeof(int) == 4
+    {.emit:"""
+static int __tcc_cas(int *ptr, int oldVal, int newVal)
+{
+    unsigned char ret;
+    __asm__ __volatile__ (
+            "  lock\n"
+            "  cmpxchgl %2,%1\n"
+            "  sete %0\n"
+            : "=q" (ret), "=m" (*ptr)
+            : "r" (newVal), "m" (*ptr), "a" (oldVal)
+            : "memory");
+
+    return ret;
+}
+""".}
+
+  proc tcc_cas(p: ptr int; oldValue, newValue: int): bool
+    {.importc: "__tcc_cas", nodecl.}
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
+    tcc_cas(cast[ptr int](p), cast[int](oldValue), cast[int](newValue))
+elif declared(atomicCompareExchangeN):
+  proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
+    atomicCompareExchangeN(p, oldValue.unsafeAddr, newValue, false, ATOMIC_SEQ_CST, ATOMIC_SEQ_CST)
+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 someVcc:
+  proc cpuRelax* {.importc: "YieldProcessor", header: "<windows.h>".}
+elif (defined(x86) or defined(amd64)) and (someGcc or defined(bcc)):
+  proc cpuRelax* {.inline.} =
+    {.emit: """asm volatile("pause" ::: "memory");""".}
+elif someGcc or defined(tcc):
+  proc cpuRelax* {.inline.} =
+    {.emit: """asm volatile("" ::: "memory");""".}
+elif defined(icl):
+  proc cpuRelax* {.importc: "_mm_pause", header: "xmmintrin.h".}
+elif false:
+  from std/os import sleep
+
+  proc cpuRelax* {.inline.} = os.sleep(1)
+
+when not declared(fence) and hasThreadSupport:
+  # XXX fixme
+  proc fence*() {.inline.} =
+    var dummy: bool
+    discard cas(addr dummy, false, true)
+
+{.pop.}
diff --git a/lib/std/sysrand.nim b/lib/std/sysrand.nim
new file mode 100644
index 000000000..6f2c6b0c1
--- /dev/null
+++ b/lib/std/sysrand.nim
@@ -0,0 +1,326 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2021 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## .. warning:: This module was added in Nim 1.6. If you are using it for cryptographic purposes,
+##   keep in mind that so far this has not been audited by any security professionals,
+##   therefore may not be secure.
+##
+## `std/sysrand` generates random numbers from a secure source provided by the operating system.
+## It is a cryptographically secure pseudorandom number generator
+## and should be unpredictable enough for cryptographic applications,
+## though its exact quality depends on the OS implementation.
+##
+## | Targets              | Implementation        |
+## | :---                 | ----:                 |
+## | Windows              | `BCryptGenRandom`_    |
+## | Linux                | `getrandom`_          |
+## | MacOSX               | `SecRandomCopyBytes`_ |
+## | iOS                  | `SecRandomCopyBytes`_ |
+## | OpenBSD              | `getentropy openbsd`_ |
+## | FreeBSD              | `getrandom freebsd`_  |
+## | JS (Web Browser)     | `getRandomValues`_    |
+## | Node.js              | `randomFillSync`_     |
+## | Other Unix platforms | `/dev/urandom`_       |
+##
+## .. _BCryptGenRandom: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
+## .. _getrandom: https://man7.org/linux/man-pages/man2/getrandom.2.html
+## .. _getentropy: https://www.unix.com/man-page/mojave/2/getentropy
+## .. _SecRandomCopyBytes: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc
+## .. _getentropy openbsd: https://man.openbsd.org/getentropy.2
+## .. _getrandom freebsd: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable
+## .. _getRandomValues: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
+## .. _randomFillSync: https://nodejs.org/api/crypto.html#crypto_crypto_randomfillsync_buffer_offset_size
+## .. _/dev/urandom: https://en.wikipedia.org/wiki//dev/random
+##
+## On a Linux target, a call to the `getrandom` syscall can be avoided (e.g.
+## for targets running kernel version < 3.17) by passing a compile flag of
+## `-d:nimNoGetRandom`. If this flag is passed, sysrand will use `/dev/urandom`
+## as with any other POSIX compliant OS.
+##
+
+runnableExamples:
+  doAssert urandom(0).len == 0
+  doAssert urandom(113).len == 113
+  doAssert urandom(1234) != urandom(1234) # unlikely to fail in practice
+
+##
+## See also
+## ========
+## * `random module <random.html>`_
+##
+
+
+when not defined(js):
+  import std/oserrors
+
+when defined(posix):
+  import std/posix
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+const
+  batchImplOS = defined(freebsd) or defined(openbsd) or defined(zephyr)
+  batchSize {.used.} = 256
+
+when batchImplOS:
+  template batchImpl(result: var int, dest: var openArray[byte], getRandomImpl) =
+    let size = dest.len
+    if size == 0:
+      return
+
+    let
+      chunks = (size - 1) div batchSize
+      left = size - chunks * batchSize
+
+    for i in 0 ..< chunks:
+      let readBytes = getRandomImpl(addr dest[result], batchSize)
+      if readBytes < 0:
+        return readBytes
+      inc(result, batchSize)
+
+    result = getRandomImpl(addr dest[result], left)
+
+when defined(js):
+  import std/private/jsutils
+
+  when defined(nodejs):
+    {.emit: "const _nim_nodejs_crypto = require('crypto');".}
+
+    proc randomFillSync(p: Uint8Array) {.importjs: "_nim_nodejs_crypto.randomFillSync(#)".}
+
+    template urandomImpl(result: var int, dest: var openArray[byte]) =
+      let size = dest.len
+      if size == 0:
+        return
+
+      var src = newUint8Array(size)
+      randomFillSync(src)
+      for i in 0 ..< size:
+        dest[i] = src[i]
+
+  else:
+    proc getRandomValues(p: Uint8Array) {.importjs: "window.crypto.getRandomValues(#)".}
+      # The requested length of `p` must not be more than 65536.
+
+    proc assign(dest: var openArray[byte], src: Uint8Array, base: int, size: int) =
+      getRandomValues(src)
+      for j in 0 ..< size:
+        dest[base + j] = src[j]
+
+    template urandomImpl(result: var int, dest: var openArray[byte]) =
+      let size = dest.len
+      if size == 0:
+        return
+
+      if size <= batchSize:
+        var src = newUint8Array(size)
+        assign(dest, src, 0, size)
+        return
+
+      let
+        chunks = (size - 1) div batchSize
+        left = size - chunks * batchSize
+
+      var srcArray = newUint8Array(batchSize)
+      for i in 0 ..< chunks:
+        assign(dest, srcArray, result, batchSize)
+        inc(result, batchSize)
+
+      var leftArray = newUint8Array(left)
+      assign(dest, leftArray, result, left)
+
+elif defined(windows):
+  type
+    PVOID = pointer
+    BCRYPT_ALG_HANDLE = PVOID
+    PUCHAR = ptr uint8
+    NTSTATUS = clong
+    ULONG = culong
+
+  const
+    STATUS_SUCCESS = 0x00000000
+    BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002
+
+  proc bCryptGenRandom(
+    hAlgorithm: BCRYPT_ALG_HANDLE,
+    pbBuffer: PUCHAR,
+    cbBuffer: ULONG,
+    dwFlags: ULONG
+  ): NTSTATUS {.stdcall, importc: "BCryptGenRandom", dynlib: "Bcrypt.dll".}
+
+
+  proc randomBytes(pbBuffer: pointer, cbBuffer: Natural): int {.inline.} =
+    bCryptGenRandom(nil, cast[PUCHAR](pbBuffer), ULONG(cbBuffer),
+                            BCRYPT_USE_SYSTEM_PREFERRED_RNG)
+
+  template urandomImpl(result: var int, dest: var openArray[byte]) =
+    let size = dest.len
+    if size == 0:
+      return
+
+    result = randomBytes(addr dest[0], size)
+
+elif defined(linux) and not defined(nimNoGetRandom) and not defined(emscripten):
+  when (NimMajor, NimMinor) >= (1, 4):
+    let SYS_getrandom {.importc: "SYS_getrandom", header: "<sys/syscall.h>".}: clong
+  else:
+    var SYS_getrandom {.importc: "SYS_getrandom", header: "<sys/syscall.h>".}: clong
+  const syscallHeader = """#include <unistd.h>
+#include <sys/syscall.h>"""
+
+  proc syscall(n: clong): clong {.
+      importc: "syscall", varargs, header: syscallHeader.}
+    #  When reading from the urandom source (GRND_RANDOM is not set),
+    #  getrandom() will block until the entropy pool has been
+    #  initialized (unless the GRND_NONBLOCK flag was specified).  If a
+    #  request is made to read a large number of bytes (more than 256),
+    #  getrandom() will block until those bytes have been generated and
+    #  transferred from kernel memory to buf.
+
+  template urandomImpl(result: var int, dest: var openArray[byte]) =
+    let size = dest.len
+    if size == 0:
+      return
+
+    while result < size:
+      let readBytes = syscall(SYS_getrandom, addr dest[result], cint(size - result), 0).int
+      if readBytes == 0:
+        raiseAssert "unreachable"
+      elif readBytes > 0:
+        inc(result, readBytes)
+      else:
+        if osLastError().cint in [EINTR, EAGAIN]: discard
+        else:
+          result = -1
+          break
+
+elif defined(openbsd):
+  proc getentropy(p: pointer, size: cint): cint {.importc: "getentropy", header: "<unistd.h>".}
+    # Fills a buffer with high-quality entropy,
+    # which can be used as input for process-context pseudorandom generators like `arc4random`.
+    # The maximum buffer size permitted is 256 bytes.
+
+  proc getRandomImpl(p: pointer, size: int): int {.inline.} =
+    result = getentropy(p, cint(size)).int
+
+elif defined(zephyr):
+  proc sys_csrand_get(dst: pointer, length: csize_t): cint {.importc: "sys_csrand_get", header: "<random/rand32.h>".}
+    # Fill the destination buffer with cryptographically secure
+    # random data values
+    #
+
+  proc getRandomImpl(p: pointer, size: int): int {.inline.} =
+    # 0 if success, -EIO if entropy reseed error
+    result = sys_csrand_get(p, csize_t(size)).int
+
+elif defined(freebsd):
+  type cssize_t {.importc: "ssize_t", header: "<sys/types.h>".} = int
+
+  proc getrandom(p: pointer, size: csize_t, flags: cuint): cssize_t {.importc: "getrandom", header: "<sys/random.h>".}
+    # Upon successful completion, the number of bytes which were actually read
+    # is returned. For requests larger than 256 bytes, this can be fewer bytes
+    # than were requested. Otherwise, -1 is returned and the global variable
+    # errno is set to indicate the error.
+
+  proc getRandomImpl(p: pointer, size: int): int {.inline.} =
+    result = getrandom(p, csize_t(size), 0)
+
+elif defined(ios) or defined(macosx):
+  {.passl: "-framework Security".}
+
+  const errSecSuccess = 0 ## No error.
+
+  type
+    SecRandom {.importc: "struct __SecRandom".} = object
+
+    SecRandomRef = ptr SecRandom
+      ## An abstract Core Foundation-type object containing information about a random number generator.
+
+  proc secRandomCopyBytes(
+    rnd: SecRandomRef, count: csize_t, bytes: pointer
+  ): cint {.importc: "SecRandomCopyBytes", header: "<Security/SecRandom.h>".}
+    ## https://developer.apple.com/documentation/security/1399291-secrandomcopybytes
+
+  template urandomImpl(result: var int, dest: var openArray[byte]) =
+    let size = dest.len
+    if size == 0:
+      return
+
+    result = secRandomCopyBytes(nil, csize_t(size), addr dest[0])
+
+else:
+  template urandomImpl(result: var int, dest: var openArray[byte]) =
+    let size = dest.len
+    if size == 0:
+      return
+
+    # see: https://www.2uo.de/myths-about-urandom/ which justifies using urandom instead of random
+    let fd = posix.open("/dev/urandom", O_RDONLY)
+
+    if fd < 0:
+      result = -1
+    else:
+      try:
+        var stat: Stat
+        if fstat(fd, stat) != -1 and S_ISCHR(stat.st_mode):
+          let
+            chunks = (size - 1) div batchSize
+            left = size - chunks * batchSize
+
+          for i in 0 ..< chunks:
+            let readBytes = posix.read(fd, addr dest[result], batchSize)
+            if readBytes < 0:
+              return readBytes
+            inc(result, batchSize)
+
+          result = posix.read(fd, addr dest[result], left)
+        else:
+          result = -1
+      finally:
+        discard posix.close(fd)
+
+proc urandomInternalImpl(dest: var openArray[byte]): int {.inline.} =
+  when batchImplOS:
+    batchImpl(result, dest, getRandomImpl)
+  else:
+    urandomImpl(result, dest)
+
+proc urandom*(dest: var openArray[byte]): bool =
+  ## Fills `dest` with random bytes suitable for cryptographic use.
+  ## If the call succeeds, returns `true`.
+  ##
+  ## If `dest` is empty, `urandom` immediately returns success,
+  ## without calling the underlying operating system API.
+  ##
+  ## .. warning:: The code hasn't been audited by cryptography experts and
+  ##   is provided as-is without guarantees. Use at your own risks. For production
+  ##   systems we advise you to request an external audit.
+  result = true
+  when defined(js): discard urandomInternalImpl(dest)
+  else:
+    let ret = urandomInternalImpl(dest)
+    when defined(windows):
+      if ret != STATUS_SUCCESS:
+        result = false
+    else:
+      if ret < 0:
+        result = false
+
+proc urandom*(size: Natural): seq[byte] {.inline.} =
+  ## Returns random bytes suitable for cryptographic use.
+  ##
+  ## .. warning:: The code hasn't been audited by cryptography experts and
+  ##   is provided as-is without guarantees. Use at your own risks. For production
+  ##   systems we advise you to request an external audit.
+  result = newSeq[byte](size)
+  when defined(js): discard urandomInternalImpl(result)
+  else:
+    if not urandom(result):
+      raiseOSError(osLastError())
diff --git a/lib/std/tasks.nim b/lib/std/tasks.nim
new file mode 100644
index 000000000..7e59747f5
--- /dev/null
+++ b/lib/std/tasks.nim
@@ -0,0 +1,312 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2021 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module provides basic primitives for creating parallel programs.
+## A `Task` should be only owned by a single Thread, it cannot be shared by threads.
+
+import std/[macros, isolation, typetraits]
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+export isolation
+
+
+when compileOption("threads"):
+  from std/effecttraits import isGcSafe
+
+
+#
+# proc hello(a: int, b: string) =
+#   echo $a & b
+#
+# let literal = "Nim"
+# let t = toTask(hello(521, literal))
+#
+#
+# is roughly converted to
+#
+# type
+#   ScratchObj_369098780 = object
+#     a: int
+#     b: string
+#
+# let scratch_369098762 = cast[ptr ScratchObj_369098780](c_calloc(csize_t 1,
+#     csize_t sizeof(ScratchObj_369098780)))
+# if scratch_369098762.isNil:
+#   raise newException(OutOfMemDefect, "Could not allocate memory")
+# block:
+#   var isolate_369098776 = isolate(521)
+#   scratch_369098762.a = extract(isolate_369098776)
+#   var isolate_369098778 = isolate(literal)
+#   scratch_369098762.b = extract(isolate_369098778)
+# proc hello_369098781(args`gensym3: pointer) {.nimcall.} =
+#   let objTemp_369098775 = cast[ptr ScratchObj_369098780](args`gensym3)
+#   let :tmp_369098777 = objTemp_369098775.a
+#   let :tmp_369098779 = objTemp_369098775.b
+#   hello(a = :tmp_369098777, b = :tmp_369098779)
+#
+# proc destroyScratch_369098782(args`gensym3: pointer) {.nimcall.} =
+#   let obj_369098783 = cast[ptr ScratchObj_369098780](args`gensym3)
+#   =destroy(obj_369098783[])
+# let t = Task(callback: hello_369098781, args: scratch_369098762, destroy: destroyScratch_369098782)
+#
+
+
+type
+  Task* = object ## `Task` contains the callback and its arguments.
+    callback: proc (args, res: pointer) {.nimcall, gcsafe.}
+    args: pointer
+    destroy: proc (args: pointer) {.nimcall, gcsafe.}
+
+
+proc `=copy`*(x: var Task, y: Task) {.error.}
+
+const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
+when defined(nimAllowNonVarDestructor) and arcLike:
+  proc `=destroy`*(t: Task) {.inline, gcsafe.} =
+    ## Frees the resources allocated for a `Task`.
+    if t.args != nil:
+      if t.destroy != nil:
+        t.destroy(t.args)
+      deallocShared(t.args)
+else:
+  proc `=destroy`*(t: var Task) {.inline, gcsafe.} =
+    ## Frees the resources allocated for a `Task`.
+    if t.args != nil:
+      if t.destroy != nil:
+        t.destroy(t.args)
+      deallocShared(t.args)
+
+proc invoke*(task: Task; res: pointer = nil) {.inline, gcsafe.} =
+  ## Invokes the `task`.
+  assert task.callback != nil
+  task.callback(task.args, res)
+
+template checkIsolate(scratchAssignList: seq[NimNode], procParam, scratchDotExpr: NimNode) =
+  # block:
+  #   var isoTempA = isolate(521)
+  #   scratch.a = extract(isolateA)
+  #   var isoTempB = isolate(literal)
+  #   scratch.b = extract(isolateB)
+  let isolatedTemp = genSym(nskTemp, "isoTemp")
+  scratchAssignList.add newVarStmt(isolatedTemp, newCall(newIdentNode("isolate"), procParam))
+  scratchAssignList.add newAssignment(scratchDotExpr,
+      newCall(newIdentNode("extract"), isolatedTemp))
+
+template addAllNode(assignParam: NimNode, procParam: NimNode) =
+  let scratchDotExpr = newDotExpr(scratchIdent, formalParams[i][0])
+
+  checkIsolate(scratchAssignList, procParam, scratchDotExpr)
+
+  let tempNode = genSym(kind = nskTemp, ident = formalParams[i][0].strVal)
+  callNode.add nnkExprEqExpr.newTree(formalParams[i][0], tempNode)
+  tempAssignList.add newLetStmt(tempNode, newDotExpr(objTemp, formalParams[i][0]))
+  scratchRecList.add newIdentDefs(newIdentNode(formalParams[i][0].strVal), assignParam)
+
+proc analyseRootSym(s: NimNode): NimNode =
+  result = s
+  while true:
+    case result.kind
+    of nnkBracketExpr, nnkDerefExpr, nnkHiddenDeref,
+        nnkAddr, nnkHiddenAddr,
+        nnkObjDownConv, nnkObjUpConv:
+      result = result[0]
+    of nnkDotExpr, nnkCheckedFieldExpr, nnkHiddenStdConv, nnkHiddenSubConv:
+      result = result[1]
+    else:
+      break
+
+macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkCallStrLit}): Task =
+  ## Converts the call and its arguments to `Task`.
+  runnableExamples:
+    proc hello(a: int) = echo a
+
+    let b = toTask hello(13)
+    assert b is Task
+
+  let retType = getTypeInst(e)
+  let returnsVoid = retType.typeKind == ntyVoid
+
+  let rootSym = analyseRootSym(e[0])
+  expectKind rootSym, nnkSym
+
+  when compileOption("threads"):
+    if not isGcSafe(rootSym):
+      error("'toTask' takes a GC safe call expression", e)
+
+  if hasClosure(rootSym):
+    error("closure call is not allowed", e)
+
+  if e.len > 1:
+    let scratchIdent = genSym(kind = nskTemp, ident = "scratch")
+    let impl = e[0].getTypeInst
+
+    when defined(nimTasksDebug):
+      echo impl.treeRepr
+      echo e.treeRepr
+    let formalParams = impl[0]
+
+    var
+      scratchRecList = newNimNode(nnkRecList)
+      scratchAssignList: seq[NimNode]
+      tempAssignList: seq[NimNode]
+      callNode: seq[NimNode]
+
+    let
+      objTemp = genSym(nskTemp, ident = "objTemp")
+
+    for i in 1 ..< formalParams.len:
+      var param = formalParams[i][1]
+
+      if param.kind == nnkBracketExpr and param[0].eqIdent("sink"):
+        param = param[0]
+
+      if param.typeKind in {ntyExpr, ntyStmt}:
+        error("'toTask'ed function cannot have a 'typed' or 'untyped' parameter", e)
+
+      case param.kind
+      of nnkVarTy:
+        error("'toTask'ed function cannot have a 'var' parameter", e)
+      of nnkBracketExpr:
+        if param[0].typeKind == ntyTypeDesc:
+          callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
+        elif param[0].typeKind in {ntyVarargs, ntyOpenArray}:
+          if param[1].typeKind in {ntyExpr, ntyStmt}:
+            error("'toTask'ed function cannot have a 'typed' or 'untyped' parameter", e)
+          let
+            seqType = nnkBracketExpr.newTree(newIdentNode("seq"), param[1])
+            seqCallNode = newCall("@", e[i])
+          addAllNode(seqType, seqCallNode)
+        else:
+          addAllNode(param, e[i])
+      of nnkBracket, nnkObjConstr:
+        # passing by static parameters
+        # so we pass them directly instead of passing by scratchObj
+        callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
+      of nnkSym, nnkPtrTy, nnkProcTy, nnkTupleConstr:
+        addAllNode(param, e[i])
+      of nnkCharLit..nnkNilLit:
+        callNode.add nnkExprEqExpr.newTree(formalParams[i][0], e[i])
+      else:
+        error("'toTask'ed function cannot have a parameter of " & $param.kind & " kind", e)
+
+    let scratchObjType = genSym(kind = nskType, ident = "ScratchObj")
+    let scratchObj = nnkTypeSection.newTree(
+                      nnkTypeDef.newTree(
+                        scratchObjType,
+                        newEmptyNode(),
+                        nnkObjectTy.newTree(
+                          newEmptyNode(),
+                          newEmptyNode(),
+                          scratchRecList
+                        )
+                      )
+                    )
+
+
+    let scratchObjPtrType = quote do:
+      cast[ptr `scratchObjType`](allocShared0(sizeof(`scratchObjType`)))
+
+    let scratchLetSection = newLetStmt(scratchIdent, scratchObjPtrType)
+
+    var stmtList = newStmtList()
+    stmtList.add(scratchObj)
+    stmtList.add(scratchLetSection)
+    stmtList.add(nnkBlockStmt.newTree(newEmptyNode(), newStmtList(scratchAssignList)))
+
+    var functionStmtList = newStmtList()
+    let funcCall = newCall(e[0], callNode)
+    functionStmtList.add tempAssignList
+
+    let funcName = genSym(nskProc, rootSym.strVal)
+    let destroyName = genSym(nskProc, "destroyScratch")
+    let objTemp2 = genSym(ident = "obj")
+    let tempNode = quote("@") do:
+        `=destroy`(@objTemp2[])
+
+    var funcDecl: NimNode
+    if returnsVoid:
+      funcDecl = quote do:
+        proc `funcName`(args, res: pointer) {.gcsafe, nimcall.} =
+          let `objTemp` = cast[ptr `scratchObjType`](args)
+          `functionStmtList`
+          `funcCall`
+    else:
+      funcDecl = quote do:
+        proc `funcName`(args, res: pointer) {.gcsafe, nimcall.} =
+          let `objTemp` = cast[ptr `scratchObjType`](args)
+          `functionStmtList`
+          cast[ptr `retType`](res)[] = `funcCall`
+
+    result = quote do:
+      `stmtList`
+
+      `funcDecl`
+
+      proc `destroyName`(args: pointer) {.gcsafe, nimcall.} =
+        let `objTemp2` = cast[ptr `scratchObjType`](args)
+        `tempNode`
+
+      Task(callback: `funcName`, args: `scratchIdent`, destroy: `destroyName`)
+  else:
+    let funcCall = newCall(e[0])
+    let funcName = genSym(nskProc, rootSym.strVal)
+
+    if returnsVoid:
+      result = quote do:
+        proc `funcName`(args, res: pointer) {.gcsafe, nimcall.} =
+          `funcCall`
+
+        Task(callback: `funcName`, args: nil)
+    else:
+      result = quote do:
+        proc `funcName`(args, res: pointer) {.gcsafe, nimcall.} =
+          cast[ptr `retType`](res)[] = `funcCall`
+
+        Task(callback: `funcName`, args: nil)
+
+
+  when defined(nimTasksDebug):
+    echo result.repr
+
+runnableExamples:
+  block:
+    var num = 0
+    proc hello(a: int) = inc num, a
+
+    let b = toTask hello(13)
+    b.invoke()
+    assert num == 13
+    # A task can be invoked multiple times
+    b.invoke()
+    assert num == 26
+
+  block:
+    type
+      Runnable = ref object
+        data: int
+
+    var data: int
+    proc hello(a: Runnable) {.nimcall.} =
+      a.data += 2
+      data = a.data
+
+
+    when false:
+      # the parameters of call must be isolated.
+      let x = Runnable(data: 12)
+      let b = toTask hello(x) # error ----> expression cannot be isolated: x
+      b.invoke()
+
+    let b = toTask(hello(Runnable(data: 12)))
+    b.invoke()
+    assert data == 14
+    b.invoke()
+    assert data == 16
diff --git a/lib/std/tempfiles.nim b/lib/std/tempfiles.nim
new file mode 100644
index 000000000..539305bde
--- /dev/null
+++ b/lib/std/tempfiles.nim
@@ -0,0 +1,192 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2021 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module creates temporary files and directories.
+##
+## Experimental API, subject to change.
+
+#[
+See also:
+* `GetTempFileName` (on windows), refs https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea
+* `mkstemp` (posix), refs https://man7.org/linux/man-pages/man3/mkstemp.3.html
+]#
+
+import std / [os, random]
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+const
+  maxRetry = 10000
+  letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+  nimTempPathLength {.intdefine.} = 8
+
+
+when defined(windows):
+  import std/winlean
+  when defined(nimPreviewSlimSystem):
+    import std/widestrs
+
+  var O_RDWR {.importc: "_O_RDWR", header: "<fcntl.h>".}: cint
+
+  proc c_fdopen(
+    filehandle: cint,
+    mode: cstring
+  ): File {.importc: "_fdopen",header: "<stdio.h>".}
+
+  proc open_osfhandle(osh: Handle, mode: cint): cint {.
+    importc: "_open_osfhandle", header: "<io.h>".}
+
+  proc close_osfandle(fd: cint): cint {.
+    importc: "_close", header: "<io.h>".}
+else:
+  import std/posix
+
+  proc c_fdopen(
+    filehandle: cint,
+    mode: cstring
+  ): File {.importc: "fdopen",header: "<stdio.h>".}
+
+
+proc safeOpen(filename: string): File =
+  ## Open files exclusively; returns `nil` if the file already exists.
+  # xxx this should be clarified; it doesn't in particular prevent other processes
+  # from opening the file, at least currently.
+  when defined(windows):
+    let dwShareMode = FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE
+    let dwCreation = CREATE_NEW
+    let dwFlags = FILE_FLAG_BACKUP_SEMANTICS or FILE_ATTRIBUTE_NORMAL
+    let handle = createFileW(newWideCString(filename), GENERIC_READ or GENERIC_WRITE, dwShareMode,
+                              nil, dwCreation, dwFlags, Handle(0))
+
+    if handle == INVALID_HANDLE_VALUE:
+      if getLastError() == ERROR_FILE_EXISTS:
+        return nil
+      else:
+        raiseOSError(osLastError(), filename)
+
+    let fileHandle = open_osfhandle(handle, O_RDWR)
+    if fileHandle == -1:
+      discard closeHandle(handle)
+      raiseOSError(osLastError(), filename)
+
+    result = c_fdopen(fileHandle, "w+")
+    if result == nil:
+      discard close_osfandle(fileHandle)
+      raiseOSError(osLastError(), filename)
+  else:
+    # xxx we need a `proc toMode(a: FilePermission): Mode`, possibly by
+    # exposing fusion/filepermissions.fromFilePermissions to stdlib; then we need
+    # to expose a `perm` param so users can customize this (e.g. the temp file may
+    # need execute permissions), and figure out how to make the API cross platform.
+    let mode = Mode(S_IRUSR or S_IWUSR)
+    let flags = posix.O_RDWR or posix.O_CREAT or posix.O_EXCL
+    let fileHandle = posix.open(filename, flags, mode)
+    if fileHandle == -1:
+      if errno == EEXIST:
+        # xxx `getLastError()` should be defined on posix too and resolve to `errno`?
+        return nil
+      else:
+        raiseOSError(osLastError(), filename)
+
+    result = c_fdopen(fileHandle, "w+")
+    if result == nil:
+      discard posix.close(fileHandle) # TODO handles failure when closing file
+      raiseOSError(osLastError(), filename)
+
+
+type
+  NimTempPathState = object
+    state: Rand
+    isInit: bool
+
+var nimTempPathState {.threadvar.}: NimTempPathState
+
+template randomPathName(length: Natural): string =
+  var res = newString(length)
+  if not nimTempPathState.isInit:
+    nimTempPathState.isInit = true
+    nimTempPathState.state = initRand()
+
+  for i in 0 ..< length:
+    res[i] = nimTempPathState.state.sample(letters)
+  res
+
+proc getTempDirImpl(dir: string): string {.inline.} =
+  result = dir
+  if result.len == 0:
+    result = getTempDir()
+
+proc genTempPath*(prefix, suffix: string, dir = ""): string =
+  ## Generates a path name in `dir`.
+  ##
+  ## The path begins with `prefix` and ends with `suffix`.
+  ##
+  ## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
+  let dir = getTempDirImpl(dir)
+  result = dir / (prefix & randomPathName(nimTempPathLength) & suffix)
+
+proc createTempFile*(prefix, suffix: string, dir = ""): tuple[cfile: File, path: string] =
+  ## Creates a new temporary file in the directory `dir`.
+  ##
+  ## This generates a path name using `genTempPath(prefix, suffix, dir)` and
+  ## returns a file handle to an open file and the path of that file, possibly after
+  ## retrying to ensure it doesn't already exist.
+  ##
+  ## If failing to create a temporary file, `OSError` will be raised.
+  ##
+  ## .. note:: It is the caller's responsibility to close `result.cfile` and
+  ##    remove `result.file` when no longer needed.
+  ## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
+  runnableExamples:
+    import std/os
+    doAssertRaises(OSError): discard createTempFile("", "", "nonexistent")
+    let (cfile, path) = createTempFile("tmpprefix_", "_end.tmp")
+    # path looks like: getTempDir() / "tmpprefix_FDCIRZA0_end.tmp"
+    cfile.write "foo"
+    cfile.setFilePos 0
+    assert readAll(cfile) == "foo"
+    close cfile
+    assert readFile(path) == "foo"
+    removeFile(path)
+  # xxx why does above work without `cfile.flushFile` ?
+  let dir = getTempDirImpl(dir)
+  for i in 0 ..< maxRetry:
+    result.path = genTempPath(prefix, suffix, dir)
+    result.cfile = safeOpen(result.path)
+    if result.cfile != nil:
+      return
+
+  raise newException(OSError, "Failed to create a temporary file under directory " & dir)
+
+proc createTempDir*(prefix, suffix: string, dir = ""): string =
+  ## Creates a new temporary directory in the directory `dir`.
+  ##
+  ## This generates a dir name using `genTempPath(prefix, suffix, dir)`, creates
+  ## the directory and returns it, possibly after retrying to ensure it doesn't
+  ## already exist.
+  ##
+  ## If failing to create a temporary directory, `OSError` will be raised.
+  ##
+  ## .. note:: It is the caller's responsibility to remove the directory when no longer needed.
+  ## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
+  runnableExamples:
+    import std/os
+    doAssertRaises(OSError): discard createTempDir("", "", "nonexistent")
+    let dir = createTempDir("tmpprefix_", "_end")
+    # dir looks like: getTempDir() / "tmpprefix_YEl9VuVj_end"
+    assert dirExists(dir)
+    removeDir(dir)
+  let dir = getTempDirImpl(dir)
+  for i in 0 ..< maxRetry:
+    result = genTempPath(prefix, suffix, dir)
+    if not existsOrCreateDir(result):
+      return
+
+  raise newException(OSError, "Failed to create a temporary directory under directory " & dir)
diff --git a/lib/std/time_t.nim b/lib/std/time_t.nim
new file mode 100644
index 000000000..de051b135
--- /dev/null
+++ b/lib/std/time_t.nim
@@ -0,0 +1,23 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+when defined(nimdoc):
+  type
+    Impl = distinct int64
+    Time* = Impl ## \
+      ## Wrapper for `time_t`. On posix, this is an alias to `posix.Time`.
+elif defined(windows):
+  when defined(i386) and defined(gcc):
+    type Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
+  else:
+    # newest version of Visual C++ defines time_t to be of 64 bits
+    type Time* {.importc: "time_t", header: "<time.h>".} = distinct int64
+elif defined(posix):
+  import std/posix
+  export posix.Time
\ No newline at end of file
diff --git a/lib/std/typedthreads.nim b/lib/std/typedthreads.nim
new file mode 100644
index 000000000..7b0b81968
--- /dev/null
+++ b/lib/std/typedthreads.nim
@@ -0,0 +1,305 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+##[
+Thread support for Nim. Threads allow multiple functions to execute concurrently.
+ 
+In Nim, threads are a low-level construct and using a library like `malebolgia`, `taskpools` or `weave` is recommended.
+ 
+When creating a thread, you can pass arguments to it. As Nim's garbage collector does not use atomic references, sharing
+`ref` and other variables managed by the garbage collector between threads is not supported.
+Use global variables to do so, or pointers.
+ 
+Memory allocated using [`sharedAlloc`](./system.html#allocShared.t%2CNatural) can be used and shared between threads.
+
+To communicate between threads, consider using [channels](./system.html#Channel)
+
+Examples
+========
+
+```Nim
+import std/locks
+
+var
+  thr: array[0..4, Thread[tuple[a,b: int]]]
+  L: Lock
+
+proc threadFunc(interval: tuple[a,b: int]) {.thread.} =
+  for i in interval.a..interval.b:
+    acquire(L) # lock stdout
+    echo i
+    release(L)
+
+initLock(L)
+
+for i in 0..high(thr):
+  createThread(thr[i], threadFunc, (i*10, i*10+5))
+joinThreads(thr)
+
+deinitLock(L)
+```
+ 
+When using a memory management strategy that supports shared heaps like `arc` or `boehm`,
+you can pass pointer to threads and share memory between them, but the memory must outlive the thread.
+The default memory management strategy, `orc`, supports this.
+The example below is **not valid** for memory management strategies that use local heaps like `refc`!
+
+```Nim
+import locks
+ 
+var l: Lock
+ 
+proc threadFunc(obj: ptr seq[int]) {.thread.} =
+  withLock l:
+    for i in 0..<100:
+      obj[].add(obj[].len * obj[].len)
+ 
+proc threadHandler() =
+  var thr: array[0..4, Thread[ptr seq[int]]]
+  var s = newSeq[int]()
+    
+  for i in 0..high(thr):
+    createThread(thr[i], threadFunc, s.addr)
+  joinThreads(thr)
+  echo s
+ 
+initLock(l)
+threadHandler()
+deinitLock(l)
+```
+]##
+
+
+import std/private/[threadtypes]
+export Thread
+
+import system/ansi_c
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+when defined(genode):
+  import genode/env
+
+when hostOS == "any":
+  {.error: "Threads not implemented for os:any. Please compile with --threads:off.".}
+
+when hasAllocStack or defined(zephyr) or defined(freertos) or defined(nuttx) or
+    defined(cpu16) or defined(cpu8):
+  const
+    nimThreadStackSize {.intdefine.} = 8192
+    nimThreadStackGuard {.intdefine.} = 128
+
+    StackGuardSize = nimThreadStackGuard
+    ThreadStackSize = nimThreadStackSize - nimThreadStackGuard
+else:
+  const
+    StackGuardSize = 4096
+    ThreadStackMask =
+      when defined(genode):
+        1024*64*sizeof(int)-1
+      else:
+        1024*256*sizeof(int)-1
+
+    ThreadStackSize = ThreadStackMask+1 - StackGuardSize
+
+
+when defined(gcDestructors):
+  proc allocThreadStorage(size: int): pointer =
+    result = c_malloc(csize_t size)
+    zeroMem(result, size)
+else:
+  template allocThreadStorage(size: untyped): untyped = allocShared0(size)
+
+#const globalsSlot = ThreadVarSlot(0)
+#sysAssert checkSlot.int == globalsSlot.int
+
+# Zephyr doesn't include this properly without some help
+when defined(zephyr):
+  {.emit: """/*INCLUDESECTION*/
+  #include <pthread.h>
+  """.}
+
+
+# We jump through some hops here to ensure that Nim thread procs can have
+# the Nim calling convention. This is needed because thread procs are
+# ``stdcall`` on Windows and ``noconv`` on UNIX. Alternative would be to just
+# use ``stdcall`` since it is mapped to ``noconv`` on UNIX anyway.
+
+
+
+{.push stack_trace:off.}
+when defined(windows):
+  proc threadProcWrapper[TArg](closure: pointer): int32 {.stdcall.} =
+    nimThreadProcWrapperBody(closure)
+    # implicitly return 0
+elif defined(genode):
+  proc threadProcWrapper[TArg](closure: pointer) {.noconv.} =
+    nimThreadProcWrapperBody(closure)
+else:
+  proc threadProcWrapper[TArg](closure: pointer): pointer {.noconv.} =
+    nimThreadProcWrapperBody(closure)
+{.pop.}
+
+proc running*[TArg](t: Thread[TArg]): bool {.inline.} =
+  ## Returns true if `t` is running.
+  result = t.dataFn != nil
+
+proc handle*[TArg](t: Thread[TArg]): SysThread {.inline.} =
+  ## Returns the thread handle of `t`.
+  result = t.sys
+
+when hostOS == "windows":
+  const MAXIMUM_WAIT_OBJECTS = 64
+
+  proc joinThread*[TArg](t: Thread[TArg]) {.inline.} =
+    ## Waits for the thread `t` to finish.
+    discard waitForSingleObject(t.sys, -1'i32)
+
+  proc joinThreads*[TArg](t: varargs[Thread[TArg]]) =
+    ## Waits for every thread in `t` to finish.
+    var a: array[MAXIMUM_WAIT_OBJECTS, SysThread]
+    var k = 0
+    while k < len(t):
+      var count = min(len(t) - k, MAXIMUM_WAIT_OBJECTS)
+      for i in 0..(count - 1): a[i] = t[i + k].sys
+      discard waitForMultipleObjects(int32(count),
+                                     cast[ptr SysThread](addr(a)), 1, -1)
+      inc(k, MAXIMUM_WAIT_OBJECTS)
+
+elif defined(genode):
+  proc joinThread*[TArg](t: Thread[TArg]) {.importcpp.}
+    ## Waits for the thread `t` to finish.
+
+  proc joinThreads*[TArg](t: varargs[Thread[TArg]]) =
+    ## Waits for every thread in `t` to finish.
+    for i in 0..t.high: joinThread(t[i])
+
+else:
+  proc joinThread*[TArg](t: Thread[TArg]) {.inline.} =
+    ## Waits for the thread `t` to finish.
+    discard pthread_join(t.sys, nil)
+
+  proc joinThreads*[TArg](t: varargs[Thread[TArg]]) =
+    ## Waits for every thread in `t` to finish.
+    for i in 0..t.high: joinThread(t[i])
+
+when false:
+  # XXX a thread should really release its heap here somehow:
+  proc destroyThread*[TArg](t: var Thread[TArg]) =
+    ## Forces the thread `t` to terminate. This is potentially dangerous if
+    ## you don't have full control over `t` and its acquired resources.
+    when hostOS == "windows":
+      discard TerminateThread(t.sys, 1'i32)
+    else:
+      discard pthread_cancel(t.sys)
+    when declared(registerThread): unregisterThread(addr(t))
+    t.dataFn = nil
+    ## if thread `t` already exited, `t.core` will be `null`.
+    if not isNil(t.core):
+      deallocThreadStorage(t.core)
+      t.core = nil
+
+when hostOS == "windows":
+  proc createThread*[TArg](t: var Thread[TArg],
+                           tp: proc (arg: TArg) {.thread, nimcall.},
+                           param: TArg) =
+    ## Creates a new thread `t` and starts its execution.
+    ##
+    ## Entry point is the proc `tp`.
+    ## `param` is passed to `tp`. `TArg` can be `void` if you
+    ## don't need to pass any data to the thread.
+    t.core = cast[PGcThread](allocThreadStorage(sizeof(GcThread)))
+
+    when TArg isnot void: t.data = param
+    t.dataFn = tp
+    when hasSharedHeap: t.core.stackSize = ThreadStackSize
+    var dummyThreadId: int32
+    t.sys = createThread(nil, ThreadStackSize, threadProcWrapper[TArg],
+                         addr(t), 0'i32, dummyThreadId)
+    if t.sys <= 0:
+      raise newException(ResourceExhaustedError, "cannot create thread")
+
+  proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) =
+    ## Pins a thread to a `CPU`:idx:.
+    ##
+    ## In other words sets a thread's `affinity`:idx:.
+    ## If you don't know what this means, you shouldn't use this proc.
+    setThreadAffinityMask(t.sys, uint(1 shl cpu))
+
+elif defined(genode):
+  var affinityOffset: cuint = 1
+    ## CPU affinity offset for next thread, safe to roll-over.
+
+  proc createThread*[TArg](t: var Thread[TArg],
+                           tp: proc (arg: TArg) {.thread, nimcall.},
+                           param: TArg) =
+    t.core = cast[PGcThread](allocThreadStorage(sizeof(GcThread)))
+
+    when TArg isnot void: t.data = param
+    t.dataFn = tp
+    when hasSharedHeap: t.stackSize = ThreadStackSize
+    t.sys.initThread(
+      runtimeEnv,
+      ThreadStackSize.culonglong,
+      threadProcWrapper[TArg], addr(t), affinityOffset)
+    inc affinityOffset
+
+  proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) =
+    {.hint: "cannot change Genode thread CPU affinity after initialization".}
+    discard
+
+else:
+  proc createThread*[TArg](t: var Thread[TArg],
+                           tp: proc (arg: TArg) {.thread, nimcall.},
+                           param: TArg) =
+    ## Creates a new thread `t` and starts its execution.
+    ##
+    ## Entry point is the proc `tp`. `param` is passed to `tp`.
+    ## `TArg` can be `void` if you
+    ## don't need to pass any data to the thread.
+    t.core = cast[PGcThread](allocThreadStorage(sizeof(GcThread)))
+
+    when TArg isnot void: t.data = param
+    t.dataFn = tp
+    when hasSharedHeap: t.core.stackSize = ThreadStackSize
+    var a {.noinit.}: Pthread_attr
+    doAssert pthread_attr_init(a) == 0
+    when hasAllocStack:
+      var
+        rawstk = allocThreadStorage(ThreadStackSize + StackGuardSize)
+        stk = cast[pointer](cast[uint](rawstk) + StackGuardSize)
+      let setstacksizeResult = pthread_attr_setstack(addr a, stk, ThreadStackSize)
+      t.rawStack = rawstk
+    else:
+      let setstacksizeResult = pthread_attr_setstacksize(a, ThreadStackSize)
+
+    when not defined(ios):
+      # This fails on iOS
+      doAssert(setstacksizeResult == 0)
+    if pthread_create(t.sys, a, threadProcWrapper[TArg], addr(t)) != 0:
+      raise newException(ResourceExhaustedError, "cannot create thread")
+    doAssert pthread_attr_destroy(a) == 0
+
+  proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) =
+    ## Pins a thread to a `CPU`:idx:.
+    ##
+    ## In other words sets a thread's `affinity`:idx:.
+    ## If you don't know what this means, you shouldn't use this proc.
+    when not defined(macosx):
+      var s {.noinit.}: CpuSet
+      cpusetZero(s)
+      cpusetIncl(cpu.cint, s)
+      setAffinity(t.sys, csize_t(sizeof(s)), s)
+
+proc createThread*(t: var Thread[void], tp: proc () {.thread, nimcall.}) =
+  createThread[void](t, tp)
+
+when not defined(gcOrc):
+  include system/threadids
diff --git a/lib/std/varints.nim b/lib/std/varints.nim
new file mode 100644
index 000000000..32fe2fffb
--- /dev/null
+++ b/lib/std/varints.nim
@@ -0,0 +1,121 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## A variable length integer
+## encoding implementation inspired by SQLite.
+##
+## Unstable API.
+
+const
+  maxVarIntLen* = 9 ## the maximal number of bytes a varint can take
+
+proc readVu64*(z: openArray[byte]; pResult: var uint64): int =
+  if z[0] <= 240:
+    pResult = z[0]
+    return 1
+  if z[0] <= 248:
+    if z.len < 2: return 0
+    pResult = (uint64 z[0] - 241) * 256 + z[1].uint64 + 240
+    return 2
+  if z.len < int(z[0]-246): return 0
+  if z[0] == 249:
+    pResult = 2288u64 + 256u64*z[1].uint64 + z[2].uint64
+    return 3
+  if z[0] == 250:
+    pResult = (z[1].uint64 shl 16u64) + (z[2].uint64 shl 8u64) + z[3].uint64
+    return 4
+  let x = (z[1].uint64 shl 24) + (z[2].uint64 shl 16) + (z[3].uint64 shl 8) + z[4].uint64
+  if z[0] == 251:
+    pResult = x
+    return 5
+  if z[0] == 252:
+    pResult = (((uint64)x) shl 8) + z[5].uint64
+    return 6
+  if z[0] == 253:
+    pResult = (((uint64)x) shl 16) + (z[5].uint64 shl 8) + z[6].uint64
+    return 7
+  if z[0] == 254:
+    pResult = (((uint64)x) shl 24) + (z[5].uint64 shl 16) + (z[6].uint64 shl 8) + z[7].uint64
+    return 8
+  pResult = (((uint64)x) shl 32) +
+              (0xffffffff'u64 and ((z[5].uint64 shl 24) +
+              (z[6].uint64 shl 16) + (z[7].uint64 shl 8) + z[8].uint64))
+  return 9
+
+proc varintWrite32(z: var openArray[byte]; y: uint32) =
+  z[0] = cast[uint8](y shr 24)
+  z[1] = cast[uint8](y shr 16)
+  z[2] = cast[uint8](y shr 8)
+  z[3] = cast[uint8](y)
+
+proc writeVu64*(z: var openArray[byte], x: uint64): int =
+  ## Write a varint into z. The buffer z must be at least 9 characters
+  ## long to accommodate the largest possible varint. Returns the number of
+  ## bytes used.
+  if x <= 240:
+    z[0] = cast[uint8](x)
+    return 1
+  if x <= 2287:
+    let y = cast[uint32](x - 240)
+    z[0] = cast[uint8](y shr 8 + 241)
+    z[1] = cast[uint8](y and 255)
+    return 2
+  if x <= 67823:
+    let y = cast[uint32](x - 2288)
+    z[0] = 249
+    z[1] = cast[uint8](y shr 8)
+    z[2] = cast[uint8](y and 255)
+    return 3
+  let y = cast[uint32](x)
+  let w = cast[uint32](x shr 32)
+  if w == 0:
+    if y <= 16777215:
+      z[0] = 250
+      z[1] = cast[uint8](y shr 16)
+      z[2] = cast[uint8](y shr 8)
+      z[3] = cast[uint8](y)
+      return 4
+    z[0] = 251
+    varintWrite32(toOpenArray(z, 1, 4), y)
+    return 5
+  if w <= 255:
+    z[0] = 252
+    z[1] = cast[uint8](w)
+    varintWrite32(toOpenArray(z, 2, 5), y)
+    return 6
+  if w <= 65535:
+    z[0] = 253
+    z[1] = cast[uint8](w shr 8)
+    z[2] = cast[uint8](w)
+    varintWrite32(toOpenArray(z, 3, 6), y)
+    return 7
+  if w <= 16777215:
+    z[0] = 254
+    z[1] = cast[uint8](w shr 16)
+    z[2] = cast[uint8](w shr 8)
+    z[3] = cast[uint8](w)
+    varintWrite32(toOpenArray(z, 4, 7), y)
+    return 8
+  z[0] = 255
+  varintWrite32(toOpenArray(z, 1, 4), w)
+  varintWrite32(toOpenArray(z, 5, 8), y)
+  return 9
+
+proc sar(a, b: int64): int64 =
+  {.emit: [result, " = ", a, " >> ", b, ";"].}
+
+proc sal(a, b: int64): int64 =
+  {.emit: [result, " = ", a, " << ", b, ";"].}
+
+proc encodeZigzag*(x: int64): uint64 {.inline.} =
+  uint64(sal(x, 1)) xor uint64(sar(x, 63))
+
+proc decodeZigzag*(x: uint64): int64 {.inline.} =
+  let casted = cast[int64](x)
+  result = (`shr`(casted, 1)) xor (-(casted and 1))
diff --git a/lib/std/vmutils.nim b/lib/std/vmutils.nim
new file mode 100644
index 000000000..e16912a3c
--- /dev/null
+++ b/lib/std/vmutils.nim
@@ -0,0 +1,11 @@
+##[
+Experimental API, subject to change.
+]##
+
+proc vmTrace*(on: bool) {.compileTime.} =
+  runnableExamples:
+    static: vmTrace(true)
+    proc fn =
+      var a = 1
+      vmTrace(false)
+    static: fn()
diff --git a/lib/std/widestrs.nim b/lib/std/widestrs.nim
new file mode 100644
index 000000000..2ddf80d14
--- /dev/null
+++ b/lib/std/widestrs.nim
@@ -0,0 +1,239 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Nim support for C/C++'s `wide strings`:idx:.
+
+#when not declared(ThisIsSystem):
+#  {.error: "You must not import this module explicitly".}
+
+type
+  Utf16Char* = distinct int16
+
+when not (defined(cpu16) or defined(cpu8)):
+  when defined(nimv2):
+
+    type
+      WideCString* = ptr UncheckedArray[Utf16Char]
+
+      WideCStringObj* = object
+        bytes: int
+        data: WideCString
+
+    const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
+    when defined(nimAllowNonVarDestructor) and arcLike:
+      proc `=destroy`(a: WideCStringObj) =
+        if a.data != nil:
+          when compileOption("threads"):
+            deallocShared(a.data)
+          else:
+            dealloc(a.data)
+    else:
+      proc `=destroy`(a: var WideCStringObj) =
+        if a.data != nil:
+          when compileOption("threads"):
+            deallocShared(a.data)
+          else:
+            dealloc(a.data)
+
+    proc `=copy`(a: var WideCStringObj; b: WideCStringObj) {.error.}
+
+    proc `=sink`(a: var WideCStringObj; b: WideCStringObj) =
+      a.bytes = b.bytes
+      a.data = b.data
+
+    proc createWide(a: var WideCStringObj; bytes: int) =
+      a.bytes = bytes
+      when compileOption("threads"):
+        a.data = cast[typeof(a.data)](allocShared0(bytes))
+      else:
+        a.data = cast[typeof(a.data)](alloc0(bytes))
+
+    template `[]`*(a: WideCStringObj; idx: int): Utf16Char = a.data[idx]
+    template `[]=`*(a: WideCStringObj; idx: int; val: Utf16Char) = a.data[idx] = val
+
+    template nullWide(): untyped = WideCStringObj(bytes: 0, data: nil)
+
+    converter toWideCString*(x: WideCStringObj): WideCString {.inline.} =
+      result = x.data
+
+  else:
+    template nullWide(): untyped = nil
+
+    type
+      WideCString* = ref UncheckedArray[Utf16Char]
+      WideCStringObj* = WideCString
+
+    template createWide(a; L) =
+      unsafeNew(a, L)
+
+  proc ord(arg: Utf16Char): int = int(cast[uint16](arg))
+
+  proc len*(w: WideCString): int =
+    ## returns the length of a widestring. This traverses the whole string to
+    ## find the binary zero end marker!
+    result = 0
+    while int16(w[result]) != 0'i16: inc result
+
+  const
+    UNI_REPLACEMENT_CHAR = Utf16Char(0xFFFD'i16)
+    UNI_MAX_BMP = 0x0000FFFF
+    UNI_MAX_UTF16 = 0x0010FFFF
+    # UNI_MAX_UTF32 = 0x7FFFFFFF
+    # UNI_MAX_LEGAL_UTF32 = 0x0010FFFF
+
+    halfShift = 10
+    halfBase = 0x0010000
+    halfMask = 0x3FF
+
+    UNI_SUR_HIGH_START = 0xD800
+    UNI_SUR_HIGH_END = 0xDBFF
+    UNI_SUR_LOW_START = 0xDC00
+    UNI_SUR_LOW_END = 0xDFFF
+    UNI_REPL = 0xFFFD
+
+  template ones(n: untyped): untyped = ((1 shl n)-1)
+
+  template fastRuneAt(s: cstring, i, L: int, result: untyped, doInc = true) =
+    ## Returns the unicode character `s[i]` in `result`. If `doInc == true`
+    ## `i` is incremented by the number of bytes that have been processed.
+    bind ones
+
+    if ord(s[i]) <= 127:
+      result = ord(s[i])
+      when doInc: inc(i)
+    elif ord(s[i]) shr 5 == 0b110:
+      #assert(ord(s[i+1]) shr 6 == 0b10)
+      if i <= L - 2:
+        result = (ord(s[i]) and (ones(5))) shl 6 or (ord(s[i+1]) and ones(6))
+        when doInc: inc(i, 2)
+      else:
+        result = UNI_REPL
+        when doInc: inc(i)
+    elif ord(s[i]) shr 4 == 0b1110:
+      if i <= L - 3:
+        #assert(ord(s[i+1]) shr 6 == 0b10)
+        #assert(ord(s[i+2]) shr 6 == 0b10)
+        result = (ord(s[i]) and ones(4)) shl 12 or
+                (ord(s[i+1]) and ones(6)) shl 6 or
+                (ord(s[i+2]) and ones(6))
+        when doInc: inc(i, 3)
+      else:
+        result = UNI_REPL
+        when doInc: inc(i)
+    elif ord(s[i]) shr 3 == 0b11110:
+      if i <= L - 4:
+        #assert(ord(s[i+1]) shr 6 == 0b10)
+        #assert(ord(s[i+2]) shr 6 == 0b10)
+        #assert(ord(s[i+3]) shr 6 == 0b10)
+        result = (ord(s[i]) and ones(3)) shl 18 or
+                (ord(s[i+1]) and ones(6)) shl 12 or
+                (ord(s[i+2]) and ones(6)) shl 6 or
+                (ord(s[i+3]) and ones(6))
+        when doInc: inc(i, 4)
+      else:
+        result = UNI_REPL
+        when doInc: inc(i)
+    else:
+      result = 0xFFFD
+      when doInc: inc(i)
+
+  iterator runes(s: cstring, L: int): int =
+    var
+      i = 0
+      result: int
+    while i < L:
+      fastRuneAt(s, i, L, result, true)
+      yield result
+
+  proc newWideCString*(size: int): WideCStringObj =
+    createWide(result, size * 2 + 2)
+
+  proc newWideCString*(source: cstring, L: int): WideCStringObj =
+    ## Warning:: `source` needs to be preallocated with the length `L`
+    createWide(result, L * 2 + 2)
+    var d = 0
+    for ch in runes(source, L):
+
+      if ch <= UNI_MAX_BMP:
+        if ch >= UNI_SUR_HIGH_START and ch <= UNI_SUR_LOW_END:
+          result[d] = UNI_REPLACEMENT_CHAR
+        else:
+          result[d] = cast[Utf16Char](uint16(ch))
+      elif ch > UNI_MAX_UTF16:
+        result[d] = UNI_REPLACEMENT_CHAR
+      else:
+        let ch = ch - halfBase
+        result[d] = cast[Utf16Char](uint16((ch shr halfShift) + UNI_SUR_HIGH_START))
+        inc d
+        result[d] = cast[Utf16Char](uint16((ch and halfMask) + UNI_SUR_LOW_START))
+      inc d
+    result[d] = Utf16Char(0)
+
+  proc newWideCString*(s: cstring): WideCStringObj =
+    if s.isNil: return nullWide
+
+    result = newWideCString(s, s.len)
+
+  proc newWideCString*(s: string): WideCStringObj =
+    result = newWideCString(cstring s, s.len)
+
+  proc `$`*(w: WideCString, estimate: int, replacement: int = 0xFFFD): string =
+    result = newStringOfCap(estimate + estimate shr 2)
+
+    var i = 0
+    while w[i].int16 != 0'i16:
+      var ch = ord(w[i])
+      inc i
+      if ch >= UNI_SUR_HIGH_START and ch <= UNI_SUR_HIGH_END:
+        # If the 16 bits following the high surrogate are in the source buffer...
+        let ch2 = ord(w[i])
+
+        # If it's a low surrogate, convert to UTF32:
+        if ch2 >= UNI_SUR_LOW_START and ch2 <= UNI_SUR_LOW_END:
+          ch = (((ch and halfMask) shl halfShift) + (ch2 and halfMask)) + halfBase
+          inc i
+        else:
+          #invalid UTF-16
+          ch = replacement
+      elif ch >= UNI_SUR_LOW_START and ch <= UNI_SUR_LOW_END:
+        #invalid UTF-16
+        ch = replacement
+
+      if ch < 0x80:
+        result.add chr(ch)
+      elif ch < 0x800:
+        result.add chr((ch shr 6) or 0xc0)
+        result.add chr((ch and 0x3f) or 0x80)
+      elif ch < 0x10000:
+        result.add chr((ch shr 12) or 0xe0)
+        result.add chr(((ch shr 6) and 0x3f) or 0x80)
+        result.add chr((ch and 0x3f) or 0x80)
+      elif ch <= 0x10FFFF:
+        result.add chr((ch shr 18) or 0xf0)
+        result.add chr(((ch shr 12) and 0x3f) or 0x80)
+        result.add chr(((ch shr 6) and 0x3f) or 0x80)
+        result.add chr((ch and 0x3f) or 0x80)
+      else:
+        # replacement char(in case user give very large number):
+        result.add chr(0xFFFD shr 12 or 0b1110_0000)
+        result.add chr(0xFFFD shr 6 and ones(6) or 0b10_0000_00)
+        result.add chr(0xFFFD and ones(6) or 0b10_0000_00)
+
+  proc `$`*(s: WideCString): string =
+    result = s $ 80
+
+  when defined(nimv2):
+    proc `$`*(s: WideCStringObj, estimate: int, replacement: int = 0xFFFD): string =
+      `$`(s.data, estimate, replacement)
+
+    proc `$`*(s: WideCStringObj): string =
+      $(s.data)
+
+    proc len*(w: WideCStringObj): int {.inline.} =
+      len(w.data)
diff --git a/lib/std/with.nim b/lib/std/with.nim
new file mode 100644
index 000000000..c2eaa4bef
--- /dev/null
+++ b/lib/std/with.nim
@@ -0,0 +1,48 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module implements the `with` macro for easy
+## function chaining. See https://github.com/nim-lang/RFCs/issues/193
+## and https://github.com/nim-lang/RFCs/issues/192 for details leading to this
+## particular design.
+##
+## **Since:** version 1.2.
+
+import std/[macros, private / underscored_calls]
+
+macro with*(arg: typed; calls: varargs[untyped]): untyped =
+  ## This macro provides `chaining`:idx: of function calls.
+  ## It does so by patching every call in `calls` to
+  ## use `arg` as the first argument.
+  ##
+  ## .. caution:: This evaluates `arg` multiple times!
+  runnableExamples:
+    var x = "yay"
+    with x:
+      add "abc"
+      add "efg"
+    doAssert x == "yayabcefg"
+
+    var a = 44
+    with a:
+      += 4
+      -= 5
+    doAssert a == 43
+
+    # Nesting works for object types too!
+    var foo = (bar: 1, qux: (baz: 2))
+    with foo:
+      bar = 2
+      with qux:
+        baz = 3
+    doAssert foo.bar == 2
+    doAssert foo.qux.baz == 3
+
+  result = newNimNode(nnkStmtList, arg)
+  underscoredCalls(result, calls, arg)
diff --git a/lib/std/wordwrap.nim b/lib/std/wordwrap.nim
new file mode 100644
index 000000000..9333f880b
--- /dev/null
+++ b/lib/std/wordwrap.nim
@@ -0,0 +1,74 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module contains an algorithm to wordwrap a Unicode string.
+
+import std/[strutils, unicode]
+
+proc olen(s: string; start, lastExclusive: int): int =
+  var i = start
+  result = 0
+  while i < lastExclusive:
+    inc result
+    let L = graphemeLen(s, i)
+    inc i, L
+
+proc wrapWords*(s: string, maxLineWidth = 80,
+               splitLongWords = true,
+               seps: set[char] = Whitespace,
+               newLine = "\n"): string {.noSideEffect.} =
+  ## Word wraps `s`.
+  runnableExamples:
+    doAssert "12345678901234567890".wrapWords() == "12345678901234567890"
+    doAssert "123456789012345678901234567890".wrapWords(20) == "12345678901234567890\n1234567890"
+    doAssert "Hello Bob. Hello John.".wrapWords(13, false) == "Hello Bob.\nHello John."
+    doAssert "Hello Bob. Hello John.".wrapWords(13, true, {';'}) == "Hello Bob. He\nllo John."
+  result = newStringOfCap(s.len + s.len shr 6)
+  var spaceLeft = maxLineWidth
+  var lastSep = ""
+
+  var i = 0
+  while true:
+    var j = i
+    let isSep = j < s.len and s[j] in seps
+    while j < s.len and (s[j] in seps) == isSep: inc(j)
+    if j <= i: break
+    #yield (substr(s, i, j-1), isSep)
+    if isSep:
+      lastSep.setLen 0
+      for k in i..<j:
+        if s[k] notin {'\L', '\C'}: lastSep.add s[k]
+      if lastSep.len == 0:
+        lastSep.add ' '
+        dec spaceLeft
+      else:
+        spaceLeft = spaceLeft - olen(lastSep, 0, lastSep.len)
+    else:
+      let wlen = olen(s, i, j)
+      if wlen > spaceLeft:
+        if splitLongWords and wlen > maxLineWidth:
+          var k = 0
+          while k < j - i:
+            if spaceLeft <= 0:
+              spaceLeft = maxLineWidth
+              result.add newLine
+            dec spaceLeft
+            let L = graphemeLen(s, k+i)
+            for m in 0 ..< L: result.add s[i+k+m]
+            inc k, L
+        else:
+          spaceLeft = maxLineWidth - wlen
+          result.add(newLine)
+          for k in i..<j: result.add(s[k])
+      else:
+        spaceLeft = spaceLeft - wlen
+        result.add(lastSep)
+        for k in i..<j: result.add(s[k])
+        #lastSep.setLen(0)
+    i = j
diff --git a/lib/std/wrapnils.nim b/lib/std/wrapnils.nim
new file mode 100644
index 000000000..0b75c270e
--- /dev/null
+++ b/lib/std/wrapnils.nim
@@ -0,0 +1,193 @@
+## This module allows evaluating expressions safely against the following conditions:
+## * nil dereferences
+## * field accesses with incorrect discriminant in case objects
+##
+## `default(T)` is returned in those cases when evaluating an expression of type `T`.
+## This simplifies code by reducing need for if-else branches.
+##
+## Note: experimental module, unstable API.
+
+#[
+TODO:
+consider handling indexing operations, eg:
+doAssert ?.default(seq[int])[3] == default(int)
+]#
+
+import std/macros
+
+runnableExamples:
+  type Foo = ref object
+    x1: string
+    x2: Foo
+    x3: ref int
+
+  var f: Foo
+  assert ?.f.x2.x1 == "" # returns default value since `f` is nil
+
+  var f2 = Foo(x1: "a")
+  f2.x2 = f2
+  assert ?.f2.x1 == "a" # same as f2.x1 (no nil LHS in this chain)
+  assert ?.Foo(x1: "a").x1 == "a" # can use constructor inside
+
+  # when you know a sub-expression doesn't involve a `nil` (e.g. `f2.x2.x2`),
+  # you can scope it as follows:
+  assert ?.(f2.x2.x2).x3[] == 0
+
+  assert (?.f2.x2.x2).x3 == nil  # this terminates ?. early
+
+runnableExamples:
+  # ?. also allows case object
+  type B = object
+    b0: int
+    case cond: bool
+    of false: discard
+    of true:
+      b1: float
+
+  var b = B(cond: false, b0: 3)
+  doAssertRaises(FieldDefect): discard b.b1 # wrong discriminant
+  doAssert ?.b.b1 == 0.0 # safe
+  b = B(cond: true, b1: 4.5)
+  doAssert ?.b.b1 == 4.5
+
+  # lvalue semantics are preserved:
+  if (let p = ?.b.b1.addr; p != nil): p[] = 4.7
+  doAssert b.b1 == 4.7
+
+proc finalize(n: NimNode, lhs: NimNode, level: int): NimNode =
+  if level == 0:
+    result = quote: `lhs` = `n`
+  else:
+    result = quote: (let `lhs` = `n`)
+
+proc process(n: NimNode, lhs: NimNode, label: NimNode, level: int): NimNode =
+  var n = n.copyNimTree
+  var it = n
+  let addr2 = bindSym"addr"
+  var old: tuple[n: NimNode, index: int]
+  while true:
+    if it.len == 0:
+      result = finalize(n, lhs, level)
+      break
+    elif it.kind == nnkCheckedFieldExpr:
+      let dot = it[0]
+      let obj = dot[0]
+      let objRef = quote do: `addr2`(`obj`)
+        # avoids a copy and preserves lvalue semantics, see tests
+      let check = it[1]
+      let okSet = check[1]
+      let kind1 = check[2]
+      let tmp = genSym(nskLet, "tmpCase")
+      let body = process(objRef, tmp, label, level + 1)
+      let tmp3 = nnkDerefExpr.newTree(tmp)
+      it[0][0] = tmp3
+      let dot2 = nnkDotExpr.newTree(@[tmp, dot[1]])
+      if old.n != nil: old.n[old.index] = dot2
+      else: n = dot2
+      let assgn = finalize(n, lhs, level)
+      result = quote do:
+        `body`
+        if `tmp3`.`kind1` notin `okSet`: break `label`
+        `assgn`
+      break
+    elif it.kind in {nnkHiddenDeref, nnkDerefExpr}:
+      let tmp = genSym(nskLet, "tmp")
+      let body = process(it[0], tmp, label, level + 1)
+      it[0] = tmp
+      let assgn = finalize(n, lhs, level)
+      result = quote do:
+        `body`
+        if `tmp` == nil: break `label`
+        `assgn`
+      break
+    elif it.kind == nnkCall: # consider extending to `nnkCallKinds`
+      # `copyNimTree` needed to avoid `typ = nil` issues
+      old = (it, 1)
+      it = it[1].copyNimTree
+    else:
+      old = (it, 0)
+      it = it[0]
+
+macro `?.`*(a: typed): auto =
+  ## Transforms `a` into an expression that can be safely evaluated even in
+  ## presence of intermediate nil pointers/references, in which case a default
+  ## value is produced.
+  let lhs = genSym(nskVar, "lhs")
+  let label = genSym(nskLabel, "label")
+  let body = process(a, lhs, label, 0)
+  result = quote do:
+    var `lhs`: type(`a`)
+    block `label`:
+      `body`
+    `lhs`
+
+# the code below is not needed for `?.`
+from std/options import Option, isSome, get, option, unsafeGet, UnpackDefect
+
+macro `??.`*(a: typed): Option =
+  ## Same as `?.` but returns an `Option`.
+  runnableExamples:
+    import std/options
+    type Foo = ref object
+      x1: ref int
+      x2: int
+    # `?.` can't distinguish between a valid vs invalid default value, but `??.` can:
+    var f1 = Foo(x1: int.new, x2: 2)
+    doAssert (??.f1.x1[]).get == 0 # not enough to tell when the chain was valid.
+    doAssert (??.f1.x1[]).isSome # a nil didn't occur in the chain
+    doAssert (??.f1.x2).get == 2
+
+    var f2: Foo
+    doAssert not (??.f2.x1[]).isSome # f2 was nil
+
+    doAssertRaises(UnpackDefect): discard (??.f2.x1[]).get
+    doAssert ?.f2.x1[] == 0 # in contrast, this returns default(int)
+
+  let lhs = genSym(nskVar, "lhs")
+  let lhs2 = genSym(nskVar, "lhs")
+  let label = genSym(nskLabel, "label")
+  let body = process(a, lhs2, label, 0)
+  result = quote do:
+    var `lhs`: Option[type(`a`)]
+    block `label`:
+      var `lhs2`: type(`a`)
+      `body`
+      `lhs` = option(`lhs2`)
+    `lhs`
+
+template fakeDot*(a: Option, b): untyped =
+  ## See top-level example.
+  let a1 = a # to avoid double evaluations
+  type T = Option[typeof(unsafeGet(a1).b)]
+  if isSome(a1):
+    let a2 = unsafeGet(a1)
+    when typeof(a2) is ref|ptr:
+      if a2 == nil:
+        default(T)
+      else:
+        option(a2.b)
+    else:
+      option(a2.b)
+  else:
+    # nil is "sticky"; this is needed, see tests
+    default(T)
+
+# xxx this should but doesn't work: func `[]`*[T, I](a: Option[T], i: I): Option {.inline.} =
+
+func `[]`*[T, I](a: Option[T], i: I): auto {.inline.} =
+  ## See top-level example.
+  if isSome(a):
+    # correctly will raise IndexDefect if a is valid but wraps an empty container
+    result = option(a.unsafeGet[i])
+
+func `[]`*[U](a: Option[U]): auto {.inline.} =
+  ## See top-level example.
+  if isSome(a):
+    let a2 = a.unsafeGet
+    if a2 != nil:
+      result = option(a2[])
+
+when false:
+  # xxx: expose a way to do this directly in std/options, e.g.: `getAsIs`
+  proc safeGet[T](a: Option[T]): T {.inline.} =
+    get(a, default(T))
diff --git a/lib/stdlib.nimble b/lib/stdlib.nimble
new file mode 100644
index 000000000..5965d6436
--- /dev/null
+++ b/lib/stdlib.nimble
@@ -0,0 +1,5 @@
+
+version       = system.NimVersion
+author        = "Dominik Picheta"
+description   = "Nim's standard library."
+license       = "MIT"
diff --git a/lib/system.nim b/lib/system.nim
index a83812ed0..2f9cdc5f9 100755..100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1,1169 +1,1745 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
+
 ## The compiler depends on the System module to work properly and the System
 ## module depends on the compiler. Most of the routines listed here use
 ## special compiler magic.
-## Each module implicitly imports the System module; it may not be listed
+##
+## Each module implicitly imports the System module; it must not be listed
 ## explicitly. Because of this there cannot be a user-defined module named
-## ``system``.
+## `system`.
+##
+## System module
+## =============
+##
+## .. include:: ./system_overview.rst
+
 
-{.push hints: off.}
+include "system/basic_types"
+
+func zeroDefault*[T](_: typedesc[T]): T {.magic: "ZeroDefault".} =
+  ## Returns the binary zeros representation of the type `T`. It ignores
+  ## default fields of an object.
+  ##
+  ## See also:
+  ## * `default <#default,typedesc[T]>`_
+
+include "system/compilation"
+
+{.push warning[GcMem]: off, warning[Uninit]: off.}
+# {.push hints: off.}
 
 type
-  int* {.magic: Int.} ## default integer type; bitwidth depends on
-                      ## architecture, but is always the same as a pointer
-  int8* {.magic: Int8.} ## signed 8 bit integer type
-  int16* {.magic: Int16.} ## signed 16 bit integer type
-  int32* {.magic: Int32.} ## signed 32 bit integer type
-  int64* {.magic: Int64.} ## signed 64 bit integer type
-  float* {.magic: Float.} ## default floating point type
-  float32* {.magic: Float32.} ## 32 bit floating point type
-  float64* {.magic: Float64.} ## 64 bit floating point type
-type # we need to start a new type section here, so that ``0`` can have a type
-  bool* {.magic: Bool.} = enum ## built-in boolean type
-    false = 0, true = 1
+  `static`*[T] {.magic: "Static".}
+    ## Meta type representing all values that can be evaluated at compile-time.
+    ##
+    ## The type coercion `static(x)` can be used to force the compile-time
+    ## evaluation of the given expression `x`.
+
+  `type`*[T] {.magic: "Type".}
+    ## Meta type representing the type of all type values.
+    ##
+    ## The coercion `type(x)` can be used to obtain the type of the given
+    ## expression `x`.
 
 type
-  char* {.magic: Char.} ## built-in 8 bit character type (unsigned)
-  string* {.magic: String.} ## built-in string type
-  cstring* {.magic: Cstring.} ## built-in cstring (*compatible string*) type
-  pointer* {.magic: Pointer.} ## built-in pointer type
-  Ordinal* {.magic: Ordinal.}[T]
+  TypeOfMode* = enum ## Possible modes of `typeof`.
+    typeOfProc,      ## Prefer the interpretation that means `x` is a proc call.
+    typeOfIter       ## Prefer the interpretation that means `x` is an iterator call.
+
+proc typeof*(x: untyped; mode = typeOfIter): typedesc {.
+  magic: "TypeOf", noSideEffect, compileTime.} =
+  ## Builtin `typeof` operation for accessing the type of an expression.
+  ## Since version 0.20.0.
+  runnableExamples:
+    proc myFoo(): float = 0.0
+    iterator myFoo(): string = yield "abc"
+    iterator myFoo2(): string = yield "abc"
+    iterator myFoo3(): string {.closure.} = yield "abc"
+    doAssert type(myFoo()) is string
+    doAssert typeof(myFoo()) is string
+    doAssert typeof(myFoo(), typeOfIter) is string
+    doAssert typeof(myFoo3) is iterator
+
+    doAssert typeof(myFoo(), typeOfProc) is float
+    doAssert typeof(0.0, typeOfProc) is float
+    doAssert typeof(myFoo3, typeOfProc) is iterator
+    doAssert not compiles(typeof(myFoo2(), typeOfProc))
+      # this would give: Error: attempting to call routine: 'myFoo2'
+      # since `typeOfProc` expects a typed expression and `myFoo2()` can
+      # only be used in a `for` context.
+
+proc `or`*(a, b: typedesc): typedesc {.magic: "TypeTrait", noSideEffect.}
+  ## Constructs an `or` meta class.
+
+proc `and`*(a, b: typedesc): typedesc {.magic: "TypeTrait", noSideEffect.}
+  ## Constructs an `and` meta class.
+
+proc `not`*(a: typedesc): typedesc {.magic: "TypeTrait", noSideEffect.}
+  ## Constructs an `not` meta class.
+
+when defined(nimHasIterable):
+  type
+    iterable*[T] {.magic: IterableType.}  ## Represents an expression that yields `T`
 
 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)
-  typeDesc* {.magic: TypeDesc.} ## meta type to denote
-                                ## a type description (for templates)
-
-proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
-  ## Special comile-time procedure that checks whether `x` is
-  ## defined. `x` has to be an identifier or a qualified identifier.
-  ## This can be used to check whether a library provides a certain
-  ## feature or not:
-  ##
-  ## .. code-block:: Nimrod
-  ##   when not defined(strutils.toUpper):
-  ##     # provide our own toUpper proc here, because strutils is
-  ##     # missing it.
-
-proc definedInScope*[T](x: T): bool {.
-  magic: "DefinedInScope", noSideEffect.}
-  ## Special comile-time procedure that checks whether `x` is
-  ## defined in the current scope. `x` has to be an identifier.
-
-proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
-  ## Boolean not; returns true iff ``x == false``.
-
-proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
-  ## Boolean ``and``; returns true iff ``x == y == true``.
-  ## Evaluation is short-circuited: This means that if ``x`` is false,
-  ## ``y`` will not even be evaluated.
-proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
-  ## Boolean ``or``; returns true iff ``not (not x and not y)``.
-  ## Evaluation is short-circuited: This means that if ``x`` is true,
-  ## ``y`` will not even be evaluated.
-proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
-  ## Boolean `exclusive or`; returns true iff ``x != y``.
-
-proc new*[T](a: var ref T) {.magic: "New", noSideEffect.}
-  ## creates a new object of type ``T`` and returns a safe (traced)
-  ## reference to it in ``a``.
-
-proc new*[T](a: var ref T, finalizer: proc (x: ref T)) {.
+  Ordinal*[T] {.magic: Ordinal.} ## Generic ordinal type. Includes integer,
+                                  ## bool, character, and enumeration types
+                                  ## as well as their subtypes. See also
+                                  ## `SomeOrdinal`.
+
+
+proc `addr`*[T](x: T): ptr T {.magic: "Addr", noSideEffect.} =
+  ## Builtin `addr` operator for taking the address of a memory location.
+  ##
+  ## .. note:: This works for `let` variables or parameters
+  ##   for better interop with C. When you use it to write a wrapper
+  ##   for a C library and take the address of `let` variables or parameters,
+  ##   you should always check that the original library
+  ##   does never write to data behind the pointer that is returned from
+  ##   this procedure.
+  ##
+  ## Cannot be overloaded.
+  ##
+  ##   ```nim
+  ##   var
+  ##     buf: seq[char] = @['a','b','c']
+  ##     p = buf[1].addr
+  ##   echo p.repr # ref 0x7faa35c40059 --> 'b'
+  ##   echo p[]    # b
+  ##   ```
+  discard
+
+proc unsafeAddr*[T](x: T): ptr T {.magic: "Addr", noSideEffect.} =
+  ## .. warning:: `unsafeAddr` is a deprecated alias for `addr`,
+  ##    use `addr` instead.
+  discard
+
+
+const ThisIsSystem = true
+
+proc new*[T](a: var ref T, finalizer: proc (x: ref T) {.nimcall.}) {.
   magic: "NewFinalize", noSideEffect.}
-  ## creates a new object of type ``T`` and returns a safe (traced)
-  ## reference to it in ``a``. When the garbage collector frees the object,
-  ## `finalizer` is called. The `finalizer` may not keep a reference to the
+  ## Creates a new object of type `T` and returns a safe (traced)
+  ## reference to it in `a`.
+  ##
+  ## When the garbage collector frees the object, `finalizer` is called.
+  ## The `finalizer` may not keep a reference to the
   ## object pointed to by `x`. The `finalizer` cannot prevent the GC from
-  ## freeing the object. Note: The `finalizer` refers to the type `T`, not to
-  ## the object! This means that for each object of type `T` the finalizer
-  ## will be called!
-
-# for low and high the return type T may not be correct, but
-# we handle that with compiler magic in SemLowHigh()
-proc high*[T](x: T): T {.magic: "High", noSideEffect.}
-  ## returns the highest possible index of an array, a sequence, a string or
-  ## the highest possible value of an ordinal value `x`. As a special
-  ## semantic rule, `x` may also be a type identifier.
+  ## freeing the object.
+  ##
+  ## **Note**: The `finalizer` refers to the type `T`, not to the object!
+  ## This means that for each object of type `T` the finalizer will be called!
+
+proc `=wasMoved`*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
+  ## Generic `wasMoved`:idx: implementation that can be overridden.
+
+proc wasMoved*[T](obj: var T) {.inline, noSideEffect.} =
+  ## Resets an object `obj` to its initial (binary zero) value to signify
+  ## it was "moved" and to signify its destructor should do nothing and
+  ## ideally be optimized away.
+  {.cast(raises: []), cast(tags: []).}:
+    `=wasMoved`(obj)
+
+proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
+  result = x
+  {.cast(raises: []), cast(tags: []).}:
+    `=wasMoved`(x)
+
+when defined(nimHasEnsureMove):
+  proc ensureMove*[T](x: T): T {.magic: "EnsureMove", noSideEffect.} =
+    ## Ensures that `x` is moved to the new location, otherwise it gives
+    ## an error at the compile time.
+    runnableExamples:
+      proc foo =
+        var x = "Hello"
+        let y = ensureMove(x)
+        doAssert y == "Hello"
+      foo()
+    discard "implemented in injectdestructors"
+
+type
+  range*[T]{.magic: "Range".}         ## Generic type to construct range types.
+  array*[I, T]{.magic: "Array".}      ## Generic type to construct
+                                      ## fixed-length arrays.
+  openArray*[T]{.magic: "OpenArray".} ## Generic type to construct open arrays.
+                                      ## Open arrays are implemented as a
+                                      ## pointer to the array data and a
+                                      ## length field.
+  varargs*[T]{.magic: "Varargs".}     ## Generic type to construct a varargs type.
+  seq*[T]{.magic: "Seq".}             ## Generic type to construct sequences.
+  set*[T]{.magic: "Set".}             ## Generic type to construct bit sets.
+
+type
+  UncheckedArray*[T]{.magic: "UncheckedArray".}
+  ## Array with no bounds checking.
+
+type sink*[T]{.magic: "BuiltinType".}
+type lent*[T]{.magic: "BuiltinType".}
 
-proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
-  ## returns the lowest possible index of an array, a sequence, a string or
-  ## the lowest possible value of an ordinal value `x`. As a special
+proc high*[T: Ordinal|enum|range](x: T): T {.magic: "High", noSideEffect,
+  deprecated: "Deprecated since v1.4; there should not be `high(value)`. Use `high(type)`.".}
+  ## Returns the highest possible value of an ordinal value `x`.
+  ##
+  ## As a special semantic rule, `x` may also be a type identifier.
+  ##
+  ## **This proc is deprecated**, use this one instead:
+  ## * `high(typedesc) <#high,typedesc[T]>`_
+  ##
+  ## ```nim
+  ## high(2) # => 9223372036854775807
+  ## ```
+
+proc high*[T: Ordinal|enum|range](x: typedesc[T]): T {.magic: "High", noSideEffect.}
+  ## Returns the highest possible value of an ordinal or enum type.
+  ##
+  ## `high(int)` is Nim's way of writing `INT_MAX`:idx: or `MAX_INT`:idx:.
+  ##   ```nim
+  ##   high(int) # => 9223372036854775807
+  ##   ```
+  ##
+  ## See also:
+  ## * `low(typedesc) <#low,typedesc[T]>`_
+
+proc high*[T](x: openArray[T]): int {.magic: "High", noSideEffect.}
+  ## Returns the highest possible index of a sequence `x`.
+  ##   ```nim
+  ##   var s = @[1, 2, 3, 4, 5, 6, 7]
+  ##   high(s) # => 6
+  ##   for i in low(s)..high(s):
+  ##     echo s[i]
+  ##   ```
+  ##
+  ## See also:
+  ## * `low(openArray) <#low,openArray[T]>`_
+
+proc high*[I, T](x: array[I, T]): I {.magic: "High", noSideEffect.}
+  ## Returns the highest possible index of an array `x`.
+  ##
+  ## For empty arrays, the return type is `int`.
+  ##   ```nim
+  ##   var arr = [1, 2, 3, 4, 5, 6, 7]
+  ##   high(arr) # => 6
+  ##   for i in low(arr)..high(arr):
+  ##     echo arr[i]
+  ##   ```
+  ##
+  ## See also:
+  ## * `low(array) <#low,array[I,T]>`_
+
+proc high*[I, T](x: typedesc[array[I, T]]): I {.magic: "High", noSideEffect.}
+  ## Returns the highest possible index of an array type.
+  ##
+  ## For empty arrays, the return type is `int`.
+  ##   ```nim
+  ##   high(array[7, int]) # => 6
+  ##   ```
+  ##
+  ## See also:
+  ## * `low(typedesc[array]) <#low,typedesc[array[I,T]]>`_
+
+proc high*(x: cstring): int {.magic: "High", noSideEffect.}
+  ## Returns the highest possible index of a compatible string `x`.
+  ## This is sometimes an O(n) operation.
+  ##
+  ## See also:
+  ## * `low(cstring) <#low,cstring>`_
+
+proc high*(x: string): int {.magic: "High", noSideEffect.}
+  ## Returns the highest possible index of a string `x`.
+  ##   ```nim
+  ##   var str = "Hello world!"
+  ##   high(str) # => 11
+  ##   ```
+  ##
+  ## See also:
+  ## * `low(string) <#low,string>`_
+
+proc low*[T: Ordinal|enum|range](x: T): T {.magic: "Low", noSideEffect,
+  deprecated: "Deprecated since v1.4; there should not be `low(value)`. Use `low(type)`.".}
+  ## Returns the lowest possible value of an ordinal value `x`. As a special
   ## semantic rule, `x` may also be a type identifier.
+  ##
+  ## **This proc is deprecated**, use this one instead:
+  ## * `low(typedesc) <#low,typedesc[T]>`_
+  ##
+  ## ```nim
+  ## low(2) # => -9223372036854775808
+  ## ```
+
+proc low*[T: Ordinal|enum|range](x: typedesc[T]): T {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible value of an ordinal or enum type.
+  ##
+  ## `low(int)` is Nim's way of writing `INT_MIN`:idx: or `MIN_INT`:idx:.
+  ##   ```nim
+  ##   low(int) # => -9223372036854775808
+  ##   ```
+  ##
+  ## See also:
+  ## * `high(typedesc) <#high,typedesc[T]>`_
+
+proc low*[T](x: openArray[T]): int {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible index of a sequence `x`.
+  ##   ```nim
+  ##   var s = @[1, 2, 3, 4, 5, 6, 7]
+  ##   low(s) # => 0
+  ##   for i in low(s)..high(s):
+  ##     echo s[i]
+  ##   ```
+  ##
+  ## See also:
+  ## * `high(openArray) <#high,openArray[T]>`_
+
+proc low*[I, T](x: array[I, T]): I {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible index of an array `x`.
+  ##
+  ## For empty arrays, the return type is `int`.
+  ##   ```nim
+  ##   var arr = [1, 2, 3, 4, 5, 6, 7]
+  ##   low(arr) # => 0
+  ##   for i in low(arr)..high(arr):
+  ##     echo arr[i]
+  ##   ```
+  ##
+  ## See also:
+  ## * `high(array) <#high,array[I,T]>`_
+
+proc low*[I, T](x: typedesc[array[I, T]]): I {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible index of an array type.
+  ##
+  ## For empty arrays, the return type is `int`.
+  ##   ```nim
+  ##   low(array[7, int]) # => 0
+  ##   ```
+  ##
+  ## See also:
+  ## * `high(typedesc[array]) <#high,typedesc[array[I,T]]>`_
+
+proc low*(x: cstring): int {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible index of a compatible string `x`.
+  ##
+  ## See also:
+  ## * `high(cstring) <#high,cstring>`_
+
+proc low*(x: string): int {.magic: "Low", noSideEffect.}
+  ## Returns the lowest possible index of a string `x`.
+  ##   ```nim
+  ##   var str = "Hello world!"
+  ##   low(str) # => 0
+  ##   ```
+  ##
+  ## See also:
+  ## * `high(string) <#high,string>`_
+
+when not defined(gcArc) and not defined(gcOrc) and not defined(gcAtomicArc):
+  proc shallowCopy*[T](x: var T, y: T) {.noSideEffect, magic: "ShallowCopy".}
+    ## Use this instead of `=` for a `shallow copy`:idx:.
+    ##
+    ## The shallow copy only changes the semantics for sequences and strings
+    ## (and types which contain those).
+    ##
+    ## Be careful with the changed semantics though!
+    ## There is a reason why the default assignment does a deep copy of sequences
+    ## and strings.
+
+# :array|openArray|string|seq|cstring|tuple
+proc `[]`*[I: Ordinal;T](a: T; i: I): T {.
+  noSideEffect, magic: "ArrGet".}
+proc `[]=`*[I: Ordinal;T,S](a: T; i: I;
+  x: sink S) {.noSideEffect, magic: "ArrPut".}
+proc `=`*[T](dest: var T; src: T) {.noSideEffect, magic: "Asgn".}
+proc `=copy`*[T](dest: var T; src: T) {.noSideEffect, magic: "Asgn".}
+
+proc arrGet[I: Ordinal;T](a: T; i: I): T {.
+  noSideEffect, magic: "ArrGet".}
+proc arrPut[I: Ordinal;T,S](a: T; i: I;
+  x: S) {.noSideEffect, magic: "ArrPut".}
+
+const arcLikeMem = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
+
+
+when defined(nimAllowNonVarDestructor) and arcLikeMem and defined(nimPreviewNonVarDestructor):
+  proc `=destroy`*[T](x: T) {.inline, magic: "Destroy".} =
+    ## Generic `destructor`:idx: implementation that can be overridden.
+    discard
+else:
+  proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
+    ## Generic `destructor`:idx: implementation that can be overridden.
+    discard
+
+  when defined(nimAllowNonVarDestructor) and arcLikeMem:
+    proc `=destroy`*(x: string) {.inline, magic: "Destroy", enforceNoRaises.} =
+      discard
+
+    proc `=destroy`*[T](x: seq[T]) {.inline, magic: "Destroy".} =
+      discard
+
+    proc `=destroy`*[T](x: ref T) {.inline, magic: "Destroy".} =
+      discard
+
+when defined(nimHasDup):
+  proc `=dup`*[T](x: T): T {.inline, magic: "Dup".} =
+    ## Generic `dup`:idx: implementation that can be overridden.
+    discard
+
+proc `=sink`*[T](x: var T; y: T) {.inline, nodestroy, magic: "Asgn".} =
+  ## Generic `sink`:idx: implementation that can be overridden.
+  when defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc):
+    x = y
+  else:
+    shallowCopy(x, y)
+
+when defined(nimHasTrace):
+  proc `=trace`*[T](x: var T; env: pointer) {.inline, magic: "Trace".} =
+    ## Generic `trace`:idx: implementation that can be overridden.
+    discard
 
 type
-  range*{.magic: "Range".} [T] ## Generic type to construct range types.
-  array*{.magic: "Array".}[I, T]  ## Generic type to construct
-                                  ## fixed-length arrays.
-  openarray*{.magic: "OpenArray".}[T]  ## Generic type to construct open arrays.
-                                       ## Open arrays are implemented as a
-                                       ## pointer to the array data and a
-                                       ## length field.
-  seq*{.magic: "Seq".}[T]  ## Generic type to construct sequences.
-  set*{.magic: "Set".}[T]  ## Generic type to construct bit sets.
-
-when not defined(EcmaScript) and not defined(NimrodVM):
+  HSlice*[T, U] = object   ## "Heterogeneous" slice type.
+    a*: T                  ## The lower bound (inclusive).
+    b*: U                  ## The upper bound (inclusive).
+  Slice*[T] = HSlice[T, T] ## An alias for `HSlice[T, T]`.
+
+proc `..`*[T, U](a: sink T, b: sink U): HSlice[T, U] {.noSideEffect, inline, magic: "DotDot".} =
+  ## Binary `slice`:idx: operator that constructs an interval `[a, b]`, both `a`
+  ## and `b` are inclusive.
+  ##
+  ## Slices can also be used in the set constructor and in ordinal case
+  ## statements, but then they are special-cased by the compiler.
+  ##   ```nim
+  ##   let a = [10, 20, 30, 40, 50]
+  ##   echo a[2 .. 3] # @[30, 40]
+  ##   ```
+  result = HSlice[T, U](a: a, b: b)
+
+proc `..`*[T](b: sink T): HSlice[int, T]
+  {.noSideEffect, inline, magic: "DotDot", deprecated: "replace `..b` with `0..b`".} =
+  ## Unary `slice`:idx: operator that constructs an interval `[default(int), b]`.
+  ##   ```nim
+  ##   let a = [10, 20, 30, 40, 50]
+  ##   echo a[.. 2] # @[10, 20, 30]
+  ##   ```
+  result = HSlice[int, T](a: 0, b: b)
+
+when defined(hotCodeReloading):
+  {.pragma: hcrInline, inline.}
+else:
+  {.pragma: hcrInline.}
+
+include "system/arithmetics"
+include "system/comparisons"
+
+const
+  appType* {.magic: "AppType".}: string = ""
+    ## A string that describes the application type. Possible values:
+    ## `"console"`, `"gui"`, `"lib"`.
+
+include "system/inclrtl"
+
+const NoFakeVars = defined(nimscript) ## `true` if the backend doesn't support \
+  ## "fake variables" like `var EBADF {.importc.}: cint`.
+
+const notJSnotNims = not defined(js) and not defined(nimscript)
+
+when not defined(js) and not defined(nimSeqsV2):
   type
-    TGenericSeq {.compilerproc, pure.} = object
-      len, space: int
+    TGenericSeq {.compilerproc, pure, inheritable.} = object
+      len, reserved: int
+      when defined(gogc):
+        elemSize: int
+        elemAlign: int
     PGenericSeq {.exportc.} = ptr TGenericSeq
     # len and space without counting the terminating zero:
     NimStringDesc {.compilerproc, final.} = object of TGenericSeq
-      data: array[0..100_000_000, char]
+      data: UncheckedArray[char]
     NimString = ptr NimStringDesc
 
+when notJSnotNims:
   include "system/hti"
 
 type
-  Byte* = Int8 ## this is an alias for ``int8``, that is a signed
-               ## int 8 bits wide.
+  byte* = uint8 ## This is an alias for `uint8`, that is an unsigned
+                ## integer, 8 bits wide.
 
   Natural* = range[0..high(int)]
-    ## is an int type ranging from zero to the maximum value
-    ## of an int. This type is often useful for documentation and debugging.
+    ## is an `int` type ranging from zero to the maximum value
+    ## of an `int`. This type is often useful for documentation and debugging.
 
   Positive* = range[1..high(int)]
-    ## is an int type ranging from one to the maximum value
-    ## of an int. This type is often useful for documentation and debugging.
-
-  TObject* {.exportc: "TNimObject".} =
-    object ## the root of Nimrod's object hierarchy. Objects should
-           ## inherit from TObject or one of its descendants. However,
-           ## objects that have no ancestor are allowed.
-  PObject* = ref TObject ## reference to TObject
-
-  E_Base* {.compilerproc.} = object of TObject ## base exception class;
-                                               ## each exception has to
-                                               ## inherit from `E_Base`.
-    name: cstring             ## The exception's name is its Nimrod identifier.
-                              ## This field is filled automatically in the
-                              ## ``raise`` statement.
-    msg* {.exportc: "message".}: string ## the exception's message. Not
-                                        ## providing an exception message 
+    ## is an `int` type ranging from one to the maximum value
+    ## of an `int`. This type is often useful for documentation and debugging.
+
+type
+  RootObj* {.compilerproc, inheritable.} =
+    object ## The root of Nim's object hierarchy.
+           ##
+           ## Objects should inherit from `RootObj` or one of its descendants.
+           ## However, objects that have no ancestor are also allowed.
+  RootRef* = ref RootObj ## Reference to `RootObj`.
+
+const NimStackTraceMsgs = compileOption("stacktraceMsgs")
+
+type
+  RootEffect* {.compilerproc.} = object of RootObj ## \
+    ## Base effect class.
+    ##
+    ## Each effect should inherit from `RootEffect` unless you know what
+    ## you're doing.
+
+type
+  StackTraceEntry* = object ## In debug mode exceptions store the stack trace that led
+                            ## to them. A `StackTraceEntry` is a single entry of the
+                            ## stack trace.
+    procname*: cstring      ## Name of the proc that is currently executing.
+    line*: int              ## Line number of the proc that is currently executing.
+    filename*: cstring      ## Filename of the proc that is currently executing.
+    when NimStackTraceMsgs:
+      frameMsg*: string     ## When a stacktrace is generated in a given frame and
+                            ## rendered at a later time, we should ensure the stacktrace
+                            ## data isn't invalidated; any pointer into PFrame is
+                            ## subject to being invalidated so shouldn't be stored.
+    when defined(nimStackTraceOverride):
+      programCounter*: uint ## Program counter - will be used to get the rest of the info,
+                            ## when `$` is called on this type. We can't use
+                            ## "cuintptr_t" in here.
+      procnameStr*, filenameStr*: string ## GC-ed alternatives to "procname" and "filename"
+
+  Exception* {.compilerproc, magic: "Exception".} = object of RootObj ## \
+    ## Base exception class.
+    ##
+    ## Each exception has to inherit from `Exception`. See the full `exception
+    ## hierarchy <manual.html#exception-handling-exception-hierarchy>`_.
+    parent*: ref Exception ## Parent exception (can be used as a stack).
+    name*: cstring         ## The exception's name is its Nim identifier.
+                           ## This field is filled automatically in the
+                           ## `raise` statement.
+    msg* {.exportc: "message".}: string ## The exception's message. Not
+                                        ## providing an exception message
                                         ## is bad style.
+    when defined(js):
+      trace*: string
+    else:
+      trace*: seq[StackTraceEntry]
+    up: ref Exception # used for stacking exceptions. Not exported!
+
+  Defect* = object of Exception ## \
+    ## Abstract base class for all exceptions that Nim's runtime raises
+    ## but that are strictly uncatchable as they can also be mapped to
+    ## a `quit` / `trap` / `exit` operation.
+
+  CatchableError* = object of Exception ## \
+    ## Abstract class for all exceptions that are catchable.
+
+when defined(nimIcIntegrityChecks):
+  include "system/exceptions"
+else:
+  import system/exceptions
+  export exceptions
+
+when defined(js) or defined(nimdoc):
+  type
+    JsRoot* = ref object of RootObj
+      ## Root type of the JavaScript object hierarchy
+
+proc unsafeNew*[T](a: var ref T, size: Natural) {.magic: "New", noSideEffect.}
+  ## Creates a new object of type `T` and returns a safe (traced)
+  ## reference to it in `a`.
+  ##
+  ## This is **unsafe** as it allocates an object of the passed `size`.
+  ## This should only be used for optimization purposes when you know
+  ## what you're doing!
+  ##
+  ## See also:
+  ## * `new <#new,ref.T,proc(ref.T)>`_
+
+proc sizeof*[T](x: T): int {.magic: "SizeOf", noSideEffect.}
+  ## Returns the size of `x` in bytes.
+  ##
+  ## Since this is a low-level proc,
+  ## its usage is discouraged - using `new <#new,ref.T,proc(ref.T)>`_ for
+  ## the most cases suffices that one never needs to know `x`'s size.
+  ##
+  ## As a special semantic rule, `x` may also be a type identifier
+  ## (`sizeof(int)` is valid).
+  ##
+  ## Limitations: If used for types that are imported from C or C++,
+  ## sizeof should fallback to the `sizeof` in the C compiler. The
+  ## result isn't available for the Nim compiler and therefore can't
+  ## be used inside of macros.
+  ##   ```nim
+  ##   sizeof('A') # => 1
+  ##   sizeof(2) # => 8
+  ##   ```
+
+proc alignof*[T](x: T): int {.magic: "AlignOf", noSideEffect.}
+proc alignof*(x: typedesc): int {.magic: "AlignOf", noSideEffect.}
+
+proc offsetOfDotExpr(typeAccess: typed): int {.magic: "OffsetOf", noSideEffect, compileTime.}
+
+template offsetOf*[T](t: typedesc[T]; member: untyped): int =
+  var tmp {.noinit.}: ptr T
+  offsetOfDotExpr(tmp[].member)
+
+template offsetOf*[T](value: T; member: untyped): int =
+  offsetOfDotExpr(value.member)
+
+#proc offsetOf*(memberaccess: typed): int {.magic: "OffsetOf", noSideEffect.}
 
-  EAsynch* = object of E_Base ## Abstract exception class for
-                              ## *asynchronous exceptions* (interrupts).
-                              ## This is rarely needed: Most
-                              ## exception types inherit from `ESynch`
-  ESynch* = object of E_Base  ## Abstract exception class for
-                              ## *synchronous exceptions*. Most exceptions
-                              ## should be inherited (directly or indirectly)
-                              ## from ESynch.
-  ESystem* = object of ESynch ## Abstract class for exceptions that the runtime
-                              ## system raises.
-  EIO* = object of ESystem    ## raised if an IO error occured.
-  EOS* = object of ESystem    ## raised if an operating system service failed.
-  EInvalidLibrary* = object of EOS ## raised if a dynamic library
-                                   ## could not be loaded.
-  ERessourceExhausted* = object of ESystem ## raised if a ressource request
-                                           ## could not be fullfilled.
-  EArithmetic* = object of ESynch       ## raised if any kind of arithmetic
-                                        ## error occured.
-  EDivByZero* {.compilerproc.} =
-    object of EArithmetic ## is the exception class for integer divide-by-zero
-                          ## errors.
-  EOverflow* {.compilerproc.} =
-    object of EArithmetic  ## is the exception class for integer calculations
-                           ## whose results are too large to fit in the
-                           ## provided bits.
-
-  EAccessViolation* {.compilerproc.} =
-    object of ESynch ## the exception class for invalid memory access errors
-
-  EAssertionFailed* {.compilerproc.} =
-    object of ESynch  ## is the exception class for Assert
-                      ## procedures that is raised if the
-                      ## assertion proves wrong
-
-  EControlC* = object of EAsynch        ## is the exception class for Ctrl+C
-                                        ## key presses in console applications.
-
-  EInvalidValue* = object of ESynch     ## is the exception class for string
-                                        ## and object conversion errors.
-
-  EOutOfMemory* = object of ESystem     ## is the exception class for
-                                        ## unsuccessful attempts to allocate
-                                        ## memory.
-
-  EInvalidIndex* = object of ESynch     ## is raised if an array index is out
-                                        ## of bounds.
-  EInvalidField* = object of ESynch     ## is raised if a record field is not
-                                        ## accessible because its dicriminant's
-                                        ## value does not fit.
-
-  EOutOfRange* = object of ESynch       ## is raised if a range check error
-                                        ## occured.
-
-  EStackOverflow* = object of ESystem   ## is raised if the hardware stack
-                                        ## used for subroutine calls overflowed.
-
-  ENoExceptionToReraise* = object of ESynch ## is raised if there is no
-                                            ## exception to reraise.
-
-  EInvalidObjectAssignment* =
-    object of ESynch ## is raised if an object gets assigned to its
-                     ## farther's object.
-
-  EInvalidObjectConversion* =
-    object of ESynch ## is raised if an object is converted to an incompatible
-                     ## object type.
-
-  EFloatingPoint* = object of ESynch ## base class for floating point exceptions
-  EFloatInvalidOp* {.compilerproc.} = 
-    object of EFloatingPoint ## Invalid operation according to IEEE: Raised by 
-                             ## 0.0/0.0, for example.
-  EFloatDivByZero* {.compilerproc.} = 
-    object of EFloatingPoint ## Division by zero. Divisor is zero and dividend 
-                             ## is a finite nonzero number.
-  EFloatOverflow* {.compilerproc.} = 
-    object of EFloatingPoint ## Overflow. Operation produces a result 
-                             ## that exceeds the range of the exponent
-  EFloatUnderflow* {.compilerproc.} = 
-    object of EFloatingPoint ## Underflow. Operation produces a result 
-                             ## that is too small to be represented as 
-                             ## a normal number
-  EFloatInexact* {.compilerproc.} = 
-    object of EFloatingPoint ## Inexact. Operation produces a result
-                             ## that cannot be represented with infinite
-                             ## precision -- for example, 2.0 / 3.0, log(1.1) 
-                             ## NOTE: Nimrod currently does not detect these!
-
-  TResult* = enum Failure, Success
-
-proc sizeof*[T](x: T): natural {.magic: "SizeOf", noSideEffect.}
-  ## returns the size of ``x`` in bytes. Since this is a low-level proc,
-  ## its usage is discouraged - using ``new`` for the most cases suffices
-  ## that one never needs to know ``x``'s size. As a special semantic rule,
-  ## ``x`` may also be a type identifier (``sizeof(int)`` is valid).
-
-proc succ*[T](x: ordinal[T], y = 1): T {.magic: "Succ", noSideEffect.}
-  ## returns the ``y``-th successor of the value ``x``. ``T`` has to be
-  ## an ordinal type. If such a value does not exist, ``EOutOfRange`` is raised
-  ## or a compile time error occurs.
-
-proc pred*[T](x: ordinal[T], y = 1): T {.magic: "Pred", noSideEffect.}
-  ## returns the ``y``-th predecessor of the value ``x``. ``T`` has to be
-  ## 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.}
-  ## 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.}
-  ## 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)``.
-  
-proc newSeq*[T](s: var seq[T], len: int) {.magic: "NewSeq", noSideEffect.}
-  ## creates a new sequence of type ``seq[T]`` with length ``len``.
-  ## This is equivalent to ``s = @[]; setlen(s, len)``, but more
+proc sizeof*(x: typedesc): int {.magic: "SizeOf", noSideEffect.}
+
+
+proc newSeq*[T](s: var seq[T], len: Natural) {.magic: "NewSeq", noSideEffect.}
+  ## Creates a new sequence of type `seq[T]` with length `len`.
+  ##
+  ## This is equivalent to `s = @[]; setlen(s, len)`, but more
   ## efficient since no reallocation is needed.
+  ##
+  ## Note that the sequence will be filled with zeroed entries.
+  ## After the creation of the sequence you should assign entries to
+  ## the sequence instead of adding them. Example:
+  ##   ```nim
+  ##   var inputStrings: seq[string]
+  ##   newSeq(inputStrings, 3)
+  ##   assert len(inputStrings) == 3
+  ##   inputStrings[0] = "The fourth"
+  ##   inputStrings[1] = "assignment"
+  ##   inputStrings[2] = "would crash"
+  ##   #inputStrings[3] = "out of bounds"
+  ##   ```
+
+proc newSeq*[T](len = 0.Natural): seq[T] =
+  ## Creates a new sequence of type `seq[T]` with length `len`.
+  ##
+  ## Note that the sequence will be filled with zeroed entries.
+  ## After the creation of the sequence you should assign entries to
+  ## the sequence instead of adding them.
+  ##   ```nim
+  ##   var inputStrings = newSeq[string](3)
+  ##   assert len(inputStrings) == 3
+  ##   inputStrings[0] = "The fourth"
+  ##   inputStrings[1] = "assignment"
+  ##   inputStrings[2] = "would crash"
+  ##   #inputStrings[3] = "out of bounds"
+  ##   ```
+  ##
+  ## See also:
+  ## * `newSeqOfCap <#newSeqOfCap,Natural>`_
+  ## * `newSeqUninit <#newSeqUninit,Natural>`_
+  newSeq(result, len)
+
+proc newSeqOfCap*[T](cap: Natural): seq[T] {.
+  magic: "NewSeqOfCap", noSideEffect.} =
+  ## Creates a new sequence of type `seq[T]` with length zero and capacity
+  ## `cap`. Example:
+  ##   ```nim
+  ##   var x = newSeqOfCap[int](5)
+  ##   assert len(x) == 0
+  ##   x.add(10)
+  ##   assert len(x) == 1
+  ##   ```
+  discard
+
+func len*[TOpenArray: openArray|varargs](x: TOpenArray): int {.magic: "LengthOpenArray".} =
+  ## Returns the length of an openArray.
+  runnableExamples:
+    proc bar[T](a: openArray[T]): int = len(a)
+    assert bar([1,2]) == 2
+    assert [1,2].len == 2
+
+func len*(x: string): int {.magic: "LengthStr".} =
+  ## Returns the length of a string.
+  runnableExamples:
+    assert "abc".len == 3
+    assert "".len == 0
+    assert string.default.len == 0
+
+proc len*(x: cstring): int {.magic: "LengthStr", noSideEffect.} =
+  ## Returns the length of a compatible string. This is an O(n) operation except
+  ## in js at runtime.
+  ##
+  ## **Note:** On the JS backend this currently counts UTF-16 code points
+  ## instead of bytes at runtime (not at compile time). For now, if you
+  ## need the byte length of the UTF-8 encoding, convert to string with
+  ## `$` first then call `len`.
+  runnableExamples:
+    doAssert len(cstring"abc") == 3
+    doAssert len(cstring r"ab\0c") == 5 # \0 is escaped
+    doAssert len(cstring"ab\0c") == 5 # ditto
+    var a: cstring = "ab\0c"
+    when defined(js): doAssert a.len == 4 # len ignores \0 for js
+    else: doAssert a.len == 2 # \0 is a null terminator
+    static:
+      var a2: cstring = "ab\0c"
+      doAssert a2.len == 2 # \0 is a null terminator, even in js vm
+
+func len*(x: (type array)|array): int {.magic: "LengthArray".} =
+  ## Returns the length of an array or an array type.
+  ## This is roughly the same as `high(T)-low(T)+1`.
+  runnableExamples:
+    var a = [1, 1, 1]
+    assert a.len == 3
+    assert array[0, float].len == 0
+    static: assert array[-2..2, float].len == 5
+
+func len*[T](x: seq[T]): int {.magic: "LengthSeq".} =
+  ## Returns the length of `x`.
+  runnableExamples:
+    assert @[0, 1].len == 2
+    assert seq[int].default.len == 0
+    assert newSeq[int](3).len == 3
+    let s = newSeqOfCap[int](3)
+    assert s.len == 0
+  # xxx this gives cgen error: assert newSeqOfCap[int](3).len == 0
+
+func ord*[T: Ordinal|enum](x: T): int {.magic: "Ord".} =
+  ## Returns the internal `int` value of `x`, including for enum with holes
+  ## and distinct ordinal types.
+  runnableExamples:
+    assert ord('A') == 65
+    type Foo = enum
+      f0 = 0, f1 = 3
+    assert f1.ord == 3
+    type Bar = distinct int
+    assert 3.Bar.ord == 3
+
+func chr*(u: range[0..255]): char {.magic: "Chr".} =
+  ## Converts `u` to a `char`, same as `char(u)`.
+  runnableExamples:
+    doAssert chr(65) == 'A'
+    doAssert chr(255) == '\255'
+    doAssert chr(255) == char(255)
+    doAssert not compiles chr(256)
+    doAssert not compiles char(256)
+    var x = 256
+    doAssertRaises(RangeDefect): discard chr(x)
+    doAssertRaises(RangeDefect): discard char(x)
+
+
+include "system/setops"
+
+
+proc contains*[U, V, W](s: HSlice[U, V], value: W): bool {.noSideEffect, inline.} =
+  ## Checks if `value` is within the range of `s`; returns true if
+  ## `value >= s.a and value <= s.b`.
+  ##   ```nim
+  ##   assert((1..3).contains(1) == true)
+  ##   assert((1..3).contains(2) == true)
+  ##   assert((1..3).contains(4) == false)
+  ##   ```
+  result = s.a <= value and value <= s.b
+
+when not defined(nimHasCallsitePragma):
+  {.pragma: callsite.}
+
+template `in`*(x, y: untyped): untyped {.dirty, callsite.} = contains(y, x)
+  ## Sugar for `contains`.
+  ##   ```nim
+  ##   assert(1 in (1..3) == true)
+  ##   assert(5 in (1..3) == false)
+  ##   ```
+template `notin`*(x, y: untyped): untyped {.dirty, callsite.} = not contains(y, x)
+  ## Sugar for `not contains`.
+  ##   ```nim
+  ##   assert(1 notin (1..3) == false)
+  ##   assert(5 notin (1..3) == true)
+  ##   ```
+
+proc `is`*[T, S](x: T, y: S): bool {.magic: "Is", noSideEffect.}
+  ## Checks if `T` is of the same type as `S`.
+  ##
+  ## For a negated version, use `isnot <#isnot.t,untyped,untyped>`_.
+  ##
+  ##   ```nim
+  ##   assert 42 is int
+  ##   assert @[1, 2] is seq
+  ##
+  ##   proc test[T](a: T): int =
+  ##     when (T is int):
+  ##       return a
+  ##     else:
+  ##       return 0
+  ##
+  ##   assert(test[int](3) == 3)
+  ##   assert(test[string]("xyz") == 0)
+  ##   ```
+template `isnot`*(x, y: untyped): untyped {.callsite.} = not (x is y)
+  ## Negated version of `is <#is,T,S>`_. Equivalent to `not(x is y)`.
+  ##   ```nim
+  ##   assert 42 isnot float
+  ##   assert @[1, 2] isnot enum
+  ##   ```
+
+when (defined(nimOwnedEnabled) and not defined(nimscript)) or defined(nimFixedOwned):
+  type owned*[T]{.magic: "BuiltinType".} ## type constructor to mark a ref/ptr or a closure as `owned`.
+else:
+  template owned*(t: typedesc): typedesc = t
+
+when defined(nimOwnedEnabled) and not defined(nimscript):
+  proc new*[T](a: var owned(ref T)) {.magic: "New", noSideEffect.}
+    ## Creates a new object of type `T` and returns a safe (traced)
+    ## reference to it in `a`.
 
-proc len*[T](x: openarray[T]): int {.magic: "LengthOpenArray", noSideEffect.}
-proc len*(x: string): int {.magic: "LengthStr", noSideEffect.}
-proc len*(x: cstring): int {.magic: "LengthStr", noSideEffect.}
-proc len*[I, T](x: array[I, T]): int {.magic: "LengthArray", noSideEffect.}
-proc len*[T](x: seq[T]): int {.magic: "LengthSeq", noSideEffect.}
-  ## returns the length of an array, a sequence or a string.
-  ## This is rougly the same as ``high(T)-low(T)+1``, but its resulting type is
-  ## always an int.
-
-# set routines:
-proc incl*[T](x: var set[T], y: T) {.magic: "Incl", noSideEffect.}
-  ## includes element ``y`` to the set ``x``. This is the same as
-  ## ``x = x + {y}``, but it might be more efficient.
-
-proc excl*[T](x: var set[T], y: T) {.magic: "Excl", noSideEffect.}
-  ## excludes element ``y`` to the set ``x``. This is the same as
-  ## ``x = x - {y}``, but it might be more efficient.
-
-proc card*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
-  ## returns the cardinality of the set ``x``, i.e. the number of elements
-  ## in the set.
-
-proc ord*[T](x: T): int {.magic: "Ord", noSideEffect.}
-  ## returns the internal int value of an ordinal value ``x``.
-
-proc chr*(u: range[0..255]): char {.magic: "Chr", noSideEffect.}
-  ## converts an int in the range 0..255 to a character.
-
-# --------------------------------------------------------------------------
-# built-in operators
-
-proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.}
-  ## zero extends a smaller integer type to ``int``. This treats `x` as
-  ## unsigned.
-proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.}
-  ## zero extends a smaller integer type to ``int``. This treats `x` as
-  ## unsigned.
-
-proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.}
-  ## zero extends a smaller integer type to ``int64``. This treats `x` as
-  ## unsigned.
-proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.}
-  ## zero extends a smaller integer type to ``int64``. This treats `x` as
-  ## unsigned.
-
-proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.}
-  ## zero extends a smaller integer type to ``int64``. This treats `x` as
-  ## unsigned.
-proc ze64*(x: int): int64 {.magic: "ZeIToI64", noDecl, noSideEffect.}
-  ## zero extends a smaller integer type to ``int64``. This treats `x` as
-  ## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``.
-  ## (This is the case on 64 bit processors.)
-
-proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.}
-  ## treats `x` as unsigned and converts it to a byte by taking the last 8 bits
-  ## from `x`.
-proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.}
-  ## treats `x` as unsigned and converts it to an ``int16`` by taking the last
-  ## 16 bits from `x`.
-proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.}
-  ## treats `x` as unsigned and converts it to an ``int32`` by taking the
-  ## last 32 bits from `x`.
-
-
-# integer calculations:
-proc `+` *(x: int): int {.magic: "UnaryPlusI", noSideEffect.}
-proc `+` *(x: int8): int8 {.magic: "UnaryPlusI", noSideEffect.}
-proc `+` *(x: int16): int16 {.magic: "UnaryPlusI", noSideEffect.}
-proc `+` *(x: int32): int32 {.magic: "UnaryPlusI", noSideEffect.}
-proc `+` *(x: int64): int64 {.magic: "UnaryPlusI64", noSideEffect.}
-  ## Unary `+` operator for an integer. Has no effect.
-
-proc `-` *(x: int): int {.magic: "UnaryMinusI", noSideEffect.}
-proc `-` *(x: int8): int8 {.magic: "UnaryMinusI", noSideEffect.}
-proc `-` *(x: int16): int16 {.magic: "UnaryMinusI", noSideEffect.}
-proc `-` *(x: int32): int32 {.magic: "UnaryMinusI", noSideEffect.}
-proc `-` *(x: int64): int64 {.magic: "UnaryMinusI64", noSideEffect.}
-  ## Unary `-` operator for an integer. Negates `x`.
-
-proc `not` *(x: int): int {.magic: "BitnotI", noSideEffect.}
-proc `not` *(x: int8): int8 {.magic: "BitnotI", noSideEffect.}
-proc `not` *(x: int16): int16 {.magic: "BitnotI", noSideEffect.}
-proc `not` *(x: int32): int32 {.magic: "BitnotI", noSideEffect.}
-proc `not` *(x: int64): int64 {.magic: "BitnotI64", noSideEffect.}
-  ## computes the `bitwise complement` of the integer `x`.
-
-proc `+` *(x, y: int): int {.magic: "AddI", noSideEffect.}
-proc `+` *(x, y: int8): int8 {.magic: "AddI", noSideEffect.}
-proc `+` *(x, y: int16): int16 {.magic: "AddI", noSideEffect.}
-proc `+` *(x, y: int32): int32 {.magic: "AddI", noSideEffect.}
-proc `+` *(x, y: int64): int64 {.magic: "AddI64", noSideEffect.}
-  ## Binary `+` operator for an integer.
-
-proc `-` *(x, y: int): int {.magic: "SubI", noSideEffect.}
-proc `-` *(x, y: int8): int8 {.magic: "SubI", noSideEffect.}
-proc `-` *(x, y: int16): int16 {.magic: "SubI", noSideEffect.}
-proc `-` *(x, y: int32): int32 {.magic: "SubI", noSideEffect.}
-proc `-` *(x, y: int64): int64 {.magic: "SubI64", noSideEffect.}
-  ## Binary `-` operator for an integer.
-
-proc `*` *(x, y: int): int {.magic: "MulI", noSideEffect.}
-proc `*` *(x, y: int8): int8 {.magic: "MulI", noSideEffect.}
-proc `*` *(x, y: int16): int16 {.magic: "MulI", noSideEffect.}
-proc `*` *(x, y: int32): int32 {.magic: "MulI", noSideEffect.}
-proc `*` *(x, y: int64): int64 {.magic: "MulI64", noSideEffect.}
-  ## Binary `*` operator for an integer.
-
-proc `div` *(x, y: int): int {.magic: "DivI", noSideEffect.}
-proc `div` *(x, y: int8): int8 {.magic: "DivI", noSideEffect.}
-proc `div` *(x, y: int16): int16 {.magic: "DivI", noSideEffect.}
-proc `div` *(x, y: int32): int32 {.magic: "DivI", noSideEffect.}
-proc `div` *(x, y: int64): int64 {.magic: "DivI64", noSideEffect.}
-  ## computes the integer division. This is roughly the same as
-  ## ``floor(x/y)``.
-
-proc `mod` *(x, y: int): int {.magic: "ModI", noSideEffect.}
-proc `mod` *(x, y: int8): int8 {.magic: "ModI", noSideEffect.}
-proc `mod` *(x, y: int16): int16 {.magic: "ModI", noSideEffect.}
-proc `mod` *(x, y: int32): int32 {.magic: "ModI", noSideEffect.}
-proc `mod` *(x, y: int64): int64 {.magic: "ModI64", noSideEffect.}
-  ## computes the integer modulo operation. This is the same as
-  ## ``x - (x div y) * y``.
-
-proc `shr` *(x, y: int): int {.magic: "ShrI", noSideEffect.}
-proc `shr` *(x, y: int8): int8 {.magic: "ShrI", noSideEffect.}
-proc `shr` *(x, y: int16): int16 {.magic: "ShrI", noSideEffect.}
-proc `shr` *(x, y: int32): int32 {.magic: "ShrI", noSideEffect.}
-proc `shr` *(x, y: int64): int64 {.magic: "ShrI64", noSideEffect.}
-  ## computes the `shift right` operation of `x` and `y`.
-
-proc `shl` *(x, y: int): int {.magic: "ShlI", noSideEffect.}
-proc `shl` *(x, y: int8): int8 {.magic: "ShlI", noSideEffect.}
-proc `shl` *(x, y: int16): int16 {.magic: "ShlI", noSideEffect.}
-proc `shl` *(x, y: int32): int32 {.magic: "ShlI", noSideEffect.}
-proc `shl` *(x, y: int64): int64 {.magic: "ShlI64", noSideEffect.}
-  ## computes the `shift left` operation of `x` and `y`.
-
-proc `and` *(x, y: int): int {.magic: "BitandI", noSideEffect.}
-proc `and` *(x, y: int8): int8 {.magic: "BitandI", noSideEffect.}
-proc `and` *(x, y: int16): int16 {.magic: "BitandI", noSideEffect.}
-proc `and` *(x, y: int32): int32 {.magic: "BitandI", noSideEffect.}
-proc `and` *(x, y: int64): int64 {.magic: "BitandI64", noSideEffect.}
-  ## computes the `bitwise and` of numbers `x` and `y`.
-
-proc `or` *(x, y: int): int {.magic: "BitorI", noSideEffect.}
-proc `or` *(x, y: int8): int8 {.magic: "BitorI", noSideEffect.}
-proc `or` *(x, y: int16): int16 {.magic: "BitorI", noSideEffect.}
-proc `or` *(x, y: int32): int32 {.magic: "BitorI", noSideEffect.}
-proc `or` *(x, y: int64): int64 {.magic: "BitorI64", noSideEffect.}
-  ## computes the `bitwise or` of numbers `x` and `y`.
-
-proc `xor` *(x, y: int): int {.magic: "BitxorI", noSideEffect.}
-proc `xor` *(x, y: int8): int8 {.magic: "BitxorI", noSideEffect.}
-proc `xor` *(x, y: int16): int16 {.magic: "BitxorI", noSideEffect.}
-proc `xor` *(x, y: int32): int32 {.magic: "BitxorI", noSideEffect.}
-proc `xor` *(x, y: int64): int64 {.magic: "BitxorI64", noSideEffect.}
-  ## computes the `bitwise xor` of numbers `x` and `y`.
-
-proc `==` *(x, y: int): bool {.magic: "EqI", noSideEffect.}
-proc `==` *(x, y: int8): bool {.magic: "EqI", noSideEffect.}
-proc `==` *(x, y: int16): bool {.magic: "EqI", noSideEffect.}
-proc `==` *(x, y: int32): bool {.magic: "EqI", noSideEffect.}
-proc `==` *(x, y: int64): bool {.magic: "EqI64", noSideEffect.}
-  ## Compares two integers for equality.
-
-proc `<=` *(x, y: int): bool {.magic: "LeI", noSideEffect.}
-proc `<=` *(x, y: int8): bool {.magic: "LeI", noSideEffect.}
-proc `<=` *(x, y: int16): bool {.magic: "LeI", noSideEffect.}
-proc `<=` *(x, y: int32): bool {.magic: "LeI", noSideEffect.}
-proc `<=` *(x, y: int64): bool {.magic: "LeI64", noSideEffect.}
-  ## Returns true iff `x` is less than or equal to `y`.
-
-proc `<` *(x, y: int): bool {.magic: "LtI", noSideEffect.}
-proc `<` *(x, y: int8): bool {.magic: "LtI", noSideEffect.}
-proc `<` *(x, y: int16): bool {.magic: "LtI", noSideEffect.}
-proc `<` *(x, y: int32): bool {.magic: "LtI", noSideEffect.}
-proc `<` *(x, y: int64): bool {.magic: "LtI64", noSideEffect.}
-  ## Returns true iff `x` is less than `y`.
-
-proc abs*(x: int): int {.magic: "AbsI", noSideEffect.}
-proc abs*(x: int8): int8 {.magic: "AbsI", noSideEffect.}
-proc abs*(x: int16): int16 {.magic: "AbsI", noSideEffect.}
-proc abs*(x: int32): int32 {.magic: "AbsI", noSideEffect.}
-proc abs*(x: int64): int64 {.magic: "AbsI64", noSideEffect.}
-  ## returns the absolute value of `x`. If `x` is ``low(x)`` (that 
-  ## is -MININT for its type), an overflow exception is thrown (if overflow
-  ## checking is turned on).
-
-proc `+%` *(x, y: int): int {.magic: "AddU", noSideEffect.}
-proc `+%` *(x, y: int8): int8 {.magic: "AddU", noSideEffect.}
-proc `+%` *(x, y: int16): int16 {.magic: "AddU", noSideEffect.}
-proc `+%` *(x, y: int32): int32 {.magic: "AddU", noSideEffect.}
-proc `+%` *(x, y: int64): int64 {.magic: "AddU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and adds them. The result is truncated to
-  ## fit into the result. This implements modulo arithmetic. No overflow
-  ## errors are possible.
-
-proc `-%` *(x, y: int): int {.magic: "SubU", noSideEffect.}
-proc `-%` *(x, y: int8): int8 {.magic: "SubU", noSideEffect.}
-proc `-%` *(x, y: int16): int16 {.magic: "SubU", noSideEffect.}
-proc `-%` *(x, y: int32): int32 {.magic: "SubU", noSideEffect.}
-proc `-%` *(x, y: int64): int64 {.magic: "SubU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and subtracts them. The result is
-  ## truncated to fit into the result. This implements modulo arithmetic.
-  ## No overflow errors are possible.
-
-proc `*%` *(x, y: int): int {.magic: "MulU", noSideEffect.}
-proc `*%` *(x, y: int8): int8 {.magic: "MulU", noSideEffect.}
-proc `*%` *(x, y: int16): int16 {.magic: "MulU", noSideEffect.}
-proc `*%` *(x, y: int32): int32 {.magic: "MulU", noSideEffect.}
-proc `*%` *(x, y: int64): int64 {.magic: "MulU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and multiplies them. The result is
-  ## truncated to fit into the result. This implements modulo arithmetic.
-  ## No overflow errors are possible.
-
-proc `/%` *(x, y: int): int {.magic: "DivU", noSideEffect.}
-proc `/%` *(x, y: int8): int8 {.magic: "DivU", noSideEffect.}
-proc `/%` *(x, y: int16): int16 {.magic: "DivU", noSideEffect.}
-proc `/%` *(x, y: int32): int32 {.magic: "DivU", noSideEffect.}
-proc `/%` *(x, y: int64): int64 {.magic: "DivU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and divides them. The result is
-  ## truncated to fit into the result. This implements modulo arithmetic.
-  ## No overflow errors are possible.
-
-proc `%%` *(x, y: int): int {.magic: "ModU", noSideEffect.}
-proc `%%` *(x, y: int8): int8 {.magic: "ModU", noSideEffect.}
-proc `%%` *(x, y: int16): int16 {.magic: "ModU", noSideEffect.}
-proc `%%` *(x, y: int32): int32 {.magic: "ModU", noSideEffect.}
-proc `%%` *(x, y: int64): int64 {.magic: "ModU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and compute the modulo of `x` and `y`.
-  ## The result is truncated to fit into the result.
-  ## This implements modulo arithmetic.
-  ## No overflow errors are possible.
-
-proc `<=%` *(x, y: int): bool {.magic: "LeU", noSideEffect.}
-proc `<=%` *(x, y: int8): bool {.magic: "LeU", noSideEffect.}
-proc `<=%` *(x, y: int16): bool {.magic: "LeU", noSideEffect.}
-proc `<=%` *(x, y: int32): bool {.magic: "LeU", noSideEffect.}
-proc `<=%` *(x, y: int64): bool {.magic: "LeU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and compares them.
-  ## Returns true iff ``unsigned(x) <= unsigned(y)``.
-
-proc `<%` *(x, y: int): bool {.magic: "LtU", noSideEffect.}
-proc `<%` *(x, y: int8): bool {.magic: "LtU", noSideEffect.}
-proc `<%` *(x, y: int16): bool {.magic: "LtU", noSideEffect.}
-proc `<%` *(x, y: int32): bool {.magic: "LtU", noSideEffect.}
-proc `<%` *(x, y: int64): bool {.magic: "LtU64", noSideEffect.}
-  ## treats `x` and `y` as unsigned and compares them.
-  ## Returns true iff ``unsigned(x) < unsigned(y)``.
-
-
-# floating point operations:
-proc `+` *(x: float): float {.magic: "UnaryPlusF64", noSideEffect.}
-proc `-` *(x: float): float {.magic: "UnaryMinusF64", noSideEffect.}
-proc `+` *(x, y: float): float {.magic: "AddF64", noSideEffect.}
-proc `-` *(x, y: float): float {.magic: "SubF64", noSideEffect.}
-proc `*` *(x, y: float): float {.magic: "MulF64", noSideEffect.}
-proc `/` *(x, y: float): float {.magic: "DivF64", noSideEffect.}
-  ## computes the floating point division
-
-proc `==` *(x, y: float): bool {.magic: "EqF64", noSideEffect.}
-proc `<=` *(x, y: float): bool {.magic: "LeF64", noSideEffect.}
-proc `<`  *(x, y: float): bool {.magic: "LtF64", noSideEffect.}
-proc abs*(x: float): float {.magic: "AbsF64", noSideEffect.}
-proc min*(x, y: float): float {.magic: "MinF64", noSideEffect.}
-proc max*(x, y: float): float {.magic: "MaxF64", noSideEffect.}
-
-# set operators
-proc `*` *[T](x, y: set[T]): set[T] {.magic: "MulSet", noSideEffect.}
-  ## This operator computes the intersection of two sets.
-proc `+` *[T](x, y: set[T]): set[T] {.magic: "PlusSet", noSideEffect.}
-  ## This operator computes the union of two sets.
-proc `-` *[T](x, y: set[T]): set[T] {.magic: "MinusSet", noSideEffect.}
-  ## This operator computes the difference of two sets.
-proc `-+-` *[T](x, y: set[T]): set[T] {.magic: "SymDiffSet", noSideEffect.}
-  ## computes the symmetric set difference. This is the same as
-  ## ``(A - B) + (B - A)``, but more efficient.
-
-# comparison operators:
-proc `==` *[T](x, y: ordinal[T]): bool {.magic: "EqEnum", noSideEffect.}
-proc `==` *(x, y: pointer): bool {.magic: "EqRef", noSideEffect.}
-proc `==` *(x, y: string): bool {.magic: "EqStr", noSideEffect.}
-proc `==` *(x, y: cstring): bool {.magic: "EqCString", noSideEffect.}
-proc `==` *(x, y: char): bool {.magic: "EqCh", noSideEffect.}
-proc `==` *(x, y: bool): bool {.magic: "EqB", noSideEffect.}
-proc `==` *[T](x, y: set[T]): bool {.magic: "EqSet", noSideEffect.}
-proc `==` *[T](x, y: ref T): bool {.magic: "EqRef", noSideEffect.}
-proc `==` *[T](x, y: ptr T): bool {.magic: "EqRef", noSideEffect.}
-
-proc `<=` *[T](x, y: ordinal[T]): bool {.magic: "LeEnum", noSideEffect.}
-proc `<=` *(x, y: string): bool {.magic: "LeStr", noSideEffect.}
-proc `<=` *(x, y: char): bool {.magic: "LeCh", noSideEffect.}
-proc `<=` *[T](x, y: set[T]): bool {.magic: "LeSet", noSideEffect.}
-proc `<=` *(x, y: bool): bool {.magic: "LeB", noSideEffect.}
-proc `<=` *[T](x, y: ref T): bool {.magic: "LePtr", noSideEffect.}
-proc `<=` *(x, y: pointer): bool {.magic: "LePtr", noSideEffect.}
-
-proc `<` *[T](x, y: ordinal[T]): bool {.magic: "LtEnum", noSideEffect.}
-proc `<` *(x, y: string): bool {.magic: "LtStr", noSideEffect.}
-proc `<` *(x, y: char): bool {.magic: "LtCh", noSideEffect.}
-proc `<` *[T](x, y: set[T]): bool {.magic: "LtSet", noSideEffect.}
-proc `<` *(x, y: bool): bool {.magic: "LtB", noSideEffect.}
-proc `<` *[T](x, y: ref T): bool {.magic: "LtPtr", noSideEffect.}
-proc `<` *[T](x, y: ptr T): bool {.magic: "LtPtr", noSideEffect.}
-proc `<` *(x, y: pointer): bool {.magic: "LtPtr", noSideEffect.}
-
-template `!=` * (x, y: expr): expr =
-  ## unequals operator. This is a shorthand for ``not (x == y)``.
-  not (x == y)
-
-template `>=` * (x, y: expr): expr =
-  ## "is greater or equals" operator. This is the same as ``y <= x``.
-  y <= x
-
-template `>` * (x, y: expr): expr =
-  ## "is greater" operator. This is the same as ``y < x``.
-  y < x
-
-proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
-  ## One should overload this proc if one wants to overload the ``in`` operator.
-  ## The parameters are in reverse order! ``a in b`` is a template for
-  ## ``contains(b, a)``.
-  ## This is because the unification algorithm that Nimrod uses for overload
-  ## resolution works from left to right.
-  ## But for the ``in`` operator that would be the wrong direction for this
-  ## piece of code:
-  ##
-  ## .. code-block:: Nimrod
-  ##   var s: set[range['a'..'z']] = {'a'..'c'}
-  ##   writeln(stdout, 'b' in s)
-  ##
-  ## If ``in`` had been declared as ``[T](elem: T, s: set[T])`` then ``T`` would
-  ## have been bound to ``char``. But ``s`` is not compatible to type
-  ## ``set[char]``! The solution is to bind ``T`` to ``range['a'..'z']``. This
-  ## is achieved by reversing the parameters for ``contains``; ``in`` then
-  ## passes its arguments in reverse order.
-
-template `in` * (x, y: expr): expr = contains(y, x)
-template `not_in` * (x, y: expr): expr = not contains(y, x)
-
-proc `is` *[T, S](x: T, y: S): bool {.magic: "Is", noSideEffect.}
-template `is_not` *(x, y: expr): expr = not (x is y)
-
-proc cmp*[T, S: typeDesc](x: T, y: S): int =
-  ## Generic compare proc. Returns a value < 0 iff x < y, a value > 0 iff x > y
-  ## and 0 iff x == y. This is useful for writing generic algorithms without
-  ## performance loss. This generic implementation uses the `==` and `<`
-  ## operators.
+  proc new*(t: typedesc): auto =
+    ## Creates a new object of type `T` and returns a safe (traced)
+    ## reference to it as result value.
+    ##
+    ## When `T` is a ref type then the resulting type will be `T`,
+    ## otherwise it will be `ref T`.
+    when (t is ref):
+      var r: owned t
+    else:
+      var r: owned(ref t)
+    new(r)
+    return r
+
+  proc unown*[T](x: T): T {.magic: "Unown", noSideEffect.}
+    ## Use the expression `x` ignoring its ownership attribute.
+
+
+else:
+  template unown*(x: typed): untyped = x
+
+  proc new*[T](a: var ref T) {.magic: "New", noSideEffect.}
+    ## Creates a new object of type `T` and returns a safe (traced)
+    ## reference to it in `a`.
+
+  proc new*(t: typedesc): auto =
+    ## Creates a new object of type `T` and returns a safe (traced)
+    ## reference to it as result value.
+    ##
+    ## When `T` is a ref type then the resulting type will be `T`,
+    ## otherwise it will be `ref T`.
+    when (t is ref):
+      var r: t
+    else:
+      var r: ref t
+    new(r)
+    return r
+
+
+template disarm*(x: typed) =
+  ## Useful for `disarming` dangling pointers explicitly for `--newruntime`.
+  ## Regardless of whether `--newruntime` is used or not
+  ## this sets the pointer or callback `x` to `nil`. This is an
+  ## experimental API!
+  x = nil
+
+proc `of`*[T, S](x: T, y: typedesc[S]): bool {.magic: "Of", noSideEffect.} =
+  ## Checks if `x` is an instance of `y`.
+  runnableExamples:
+    type
+      Base = ref object of RootObj
+      Sub1 = ref object of Base
+      Sub2 = ref object of Base
+      Unrelated = ref object
+
+    var base: Base = Sub1() # downcast
+    doAssert base of Base # generates `CondTrue` (statically true)
+    doAssert base of Sub1
+    doAssert base isnot Sub1
+    doAssert not (base of Sub2)
+
+    base = Sub2() # re-assign
+    doAssert base of Sub2
+    doAssert Sub2(base) != nil # upcast
+    doAssertRaises(ObjectConversionDefect): discard Sub1(base)
+
+    var sub1 = Sub1()
+    doAssert sub1 of Base
+    doAssert sub1.Base of Sub1
+
+    doAssert not compiles(base of Unrelated)
+
+proc cmp*[T](x, y: T): int =
+  ## Generic compare proc.
+  ##
+  ## Returns:
+  ## * a value less than zero, if `x < y`
+  ## * a value greater than zero, if `x > y`
+  ## * zero, if `x == y`
+  ##
+  ## This is useful for writing generic algorithms without performance loss.
+  ## This generic implementation uses the `==` and `<` operators.
+  ##   ```nim
+  ##   import std/algorithm
+  ##   echo sorted(@[4, 2, 6, 5, 8, 7], cmp[int])
+  ##   ```
   if x == y: return 0
   if x < y: return -1
   return 1
 
 proc cmp*(x, y: string): int {.noSideEffect.}
   ## Compare proc for strings. More efficient than the generic version.
+  ##
+  ## **Note**: The precise result values depend on the used C runtime library and
+  ## can differ between operating systems!
+
+proc `@`* [IDX, T](a: sink array[IDX, T]): seq[T] {.magic: "ArrToSeq", noSideEffect.}
+  ## Turns an array into a sequence.
+  ##
+  ## This most often useful for constructing
+  ## sequences with the array constructor: `@[1, 2, 3]` has the type
+  ## `seq[int]`, while `[1, 2, 3]` has the type `array[0..2, int]`.
+  ##
+  ##   ```nim
+  ##   let
+  ##     a = [1, 3, 5]
+  ##     b = "foo"
+  ##
+  ##   echo @a # => @[1, 3, 5]
+  ##   echo @b # => @['f', 'o', 'o']
+  ##   ```
 
-proc `@` * [IDX, T](a: array[IDX, T]): seq[T] {.
-  magic: "ArrToSeq", nosideeffect.}
-  ## turns an array into a sequence. This most often useful for constructing
-  ## sequences with the array constructor: ``@[1, 2, 3]`` has the type 
-  ## ``seq[int]``, while ``[1, 2, 3]`` has the type ``array[0..2, int]``. 
+proc default*[T](_: typedesc[T]): T {.magic: "Default", noSideEffect.} =
+  ## Returns the default value of the type `T`. Contrary to `zeroDefault`, it takes default fields
+  ## of an object into consideration.
+  ##
+  ## See also:
+  ## * `zeroDefault <#zeroDefault,typedesc[T]>`_
+  ##
+  runnableExamples("-d:nimPreviewRangeDefault"):
+    assert (int, float).default == (0, 0.0)
+    type Foo = object
+      a: range[2..6]
+    var x = Foo.default
+    assert x.a == 2
+
+
+proc reset*[T](obj: var T) {.noSideEffect.} =
+  ## Resets an object `obj` to its default value.
+  when nimvm:
+    obj = default(typeof(obj))
+  else:
+    when defined(gcDestructors):
+      {.cast(noSideEffect), cast(raises: []), cast(tags: []).}:
+        `=destroy`(obj)
+        `=wasMoved`(obj)
+    else:
+      obj = default(typeof(obj))
 
-proc setLen*[T](s: var seq[T], newlen: int) {.
-  magic: "SetLengthSeq", noSideEffect.}
-  ## sets the length of `s` to `newlen`.
-  ## ``T`` may be any sequence type.
+proc setLen*[T](s: var seq[T], newlen: Natural) {.
+  magic: "SetLengthSeq", noSideEffect, nodestroy.}
+  ## Sets the length of seq `s` to `newlen`. `T` may be any sequence type.
+  ##
   ## If the current length is greater than the new length,
-  ## ``s`` will be truncated.
-
-proc setLen*(s: var string, newlen: int) {.
+  ## `s` will be truncated.
+  ##   ```nim
+  ##   var x = @[10, 20]
+  ##   x.setLen(5)
+  ##   x[4] = 50
+  ##   assert x == @[10, 20, 0, 0, 50]
+  ##   x.setLen(1)
+  ##   assert x == @[10]
+  ##   ```
+
+proc setLen*(s: var string, newlen: Natural) {.
   magic: "SetLengthStr", noSideEffect.}
-  ## sets the length of `s` to `newlen`.
+  ## Sets the length of string `s` to `newlen`.
+  ##
   ## If the current length is greater than the new length,
-  ## ``s`` will be truncated.
-
-proc newString*(len: int): string {.
+  ## `s` will be truncated.
+  ##   ```nim
+  ##   var myS = "Nim is great!!"
+  ##   myS.setLen(3) # myS <- "Nim"
+  ##   echo myS, " is fantastic!!"
+  ##   ```
+
+proc newString*(len: Natural): string {.
   magic: "NewString", importc: "mnewString", noSideEffect.}
-  ## returns a new string of length ``len`` but with uninitialized
-  ## content. One needs to fill the string character after character
-  ## with the index operator ``s[i]``. This procedure exists only for
-  ## optimization purposes; the same effect can be achieved with the
-  ## ``&`` operator.
-
-# concat operator:
-proc `&` * (x: string, y: char): string {.
-  magic: "ConStrStr", noSideEffect, merge.}
-proc `&` * (x: char, y: char): string {.
-  magic: "ConStrStr", noSideEffect, merge.}
-proc `&` * (x, y: string): string {.
-  magic: "ConStrStr", noSideEffect, merge.}
-proc `&` * (x: char, y: string): string {.
-  magic: "ConStrStr", noSideEffect, merge.}
-  ## is the `concatenation operator`. It concatenates `x` and `y`.
-
-proc add*(x: var string, y: char) {.magic: "AppendStrCh", noSideEffect.}
-proc add*(x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
+  ## Returns a new string of length `len`.
+  ## One needs to fill the string character after character
+  ## with the index operator `s[i]`.
+  ##
+  ## This procedure exists only for optimization purposes;
+  ## the same effect can be achieved with the `&` operator or with `add`.
 
-when not defined(ECMAScript):
-  {.push overflow_checks:off}
-  proc add* (x: var string, y: cstring) =
-    var i = 0
-    while y[i] != '\0':
-      add(x, y[i])
-      inc(i)
-  {.pop.}
-else:
-  proc add* (x: var string, y: cstring) {.pure.} =
-    asm """
-      var len = `x`[0].length-1;
-      for (var i = 0; i < `y`.length; ++i) {
-        `x`[0][len] = `y`.charCodeAt(i);
-        ++len;
-      }
-      `x`[0][len] = 0
-    """
-
-proc add *[T](x: var seq[T], y: T) {.magic: "AppendSeqElem", noSideEffect.}
-proc add *[T](x: var seq[T], y: openArray[T]) {.noSideEffect.} =
-  ## Generic proc for adding a data item `y` to a container `x`.
-  ## For containers that have an order, `add` means *append*. New generic
-  ## containers should also call their adding proc `add` for consistency.
-  ## Generic code becomes much easier to write if the Nimrod naming scheme is
-  ## respected.
-  var xl = x.len
-  setLen(x, xl + y.len)
-  for i in 0..high(y): x[xl+i] = y[i]
-
-proc del* [T](x: var seq[T], i: int) {.noSideEffect.} = 
-  ## deletes the item at index `i` by putting ``x[high(x)]`` into position `i`.
-  ## This is an O(1) operation.
-  var xl = x.len
-  x[i] = x[xl-1]
-  setLen(x, xl-1)
-  
-proc delete*[T](x: var seq[T], i: int) {.noSideEffect.} = 
-  ## deletes the item at index `i` by moving ``x[i+1..]`` by one position.
-  ## This is an O(n) operation.
-  var xl = x.len
-  for j in i..xl-2: x[j] = x[j+1]
-  setLen(x, xl-1)
-  
-proc insert*[T](x: var seq[T], item: T, i = 0) {.noSideEffect.} = 
-  ## inserts `item` into `x` at position `i`.
-  var xl = x.len
-  setLen(x, xl+1)
-  var j = xl-1
-  while j >= i:
-    x[j+1] = x[j]
-    dec(j)
-  x[i] = item
-
-
-proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.}
-  ## takes any Nimrod variable and returns its string representation. It
-  ## works even for complex data graphs with cycles. This is a great
-  ## debugging tool.
+proc newStringOfCap*(cap: Natural): string {.
+  magic: "NewStringOfCap", importc: "rawNewString", noSideEffect.}
+  ## Returns a new string of length `0` but with capacity `cap`.
+  ##
+  ## This procedure exists only for optimization purposes; the same effect can
+  ## be achieved with the `&` operator or with `add`.
+
+proc `&`*(x: string, y: char): string {.
+  magic: "ConStrStr", noSideEffect.}
+  ## Concatenates `x` with `y`.
+  ##   ```nim
+  ##   assert("ab" & 'c' == "abc")
+  ##   ```
+proc `&`*(x, y: char): string {.
+  magic: "ConStrStr", noSideEffect.}
+  ## Concatenates characters `x` and `y` into a string.
+  ##   ```nim
+  ##   assert('a' & 'b' == "ab")
+  ##   ```
+proc `&`*(x, y: string): string {.
+  magic: "ConStrStr", noSideEffect.}
+  ## Concatenates strings `x` and `y`.
+  ##   ```nim
+  ##   assert("ab" & "cd" == "abcd")
+  ##   ```
+proc `&`*(x: char, y: string): string {.
+  magic: "ConStrStr", noSideEffect.}
+  ## Concatenates `x` with `y`.
+  ##   ```nim
+  ##   assert('a' & "bc" == "abc")
+  ##   ```
+
+# implementation note: These must all have the same magic value "ConStrStr" so
+# that the merge optimization works properly.
 
-type
-  TAddress* = int
-    ## is the signed integer type that should be used for converting
-    ## pointers to integer addresses for readability.
+proc add*(x: var string, y: char) {.magic: "AppendStrCh", noSideEffect.}
+  ## Appends `y` to `x` in place.
+  ##   ```nim
+  ##   var tmp = ""
+  ##   tmp.add('a')
+  ##   tmp.add('b')
+  ##   assert(tmp == "ab")
+  ##   ```
+
+proc add*(x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.} =
+  ## Concatenates `x` and `y` in place.
+  ##
+  ## See also `strbasics.add`.
+  runnableExamples:
+    var tmp = ""
+    tmp.add("ab")
+    tmp.add("cd")
+    assert tmp == "abcd"
 
 type
-  BiggestInt* = int64
-    ## is an alias for the biggest signed integer type the Nimrod compiler
-    ## supports. Currently this is ``int64``, but it is platform-dependant
-    ## in general.
-
-  BiggestFloat* = float64
-    ## is an alias for the biggest floating point type the Nimrod
-    ## compiler supports. Currently this is ``float64``, but it is
-    ## platform-dependant in general.
-
-type # these work for most platforms:
-  cchar* {.importc: "char", nodecl.} = char
-    ## This is the same as the type ``char`` in *C*.
-  cschar* {.importc: "signed char", nodecl.} = byte
-    ## This is the same as the type ``signed char`` in *C*.
-  cshort* {.importc: "short", nodecl.} = int16
-    ## This is the same as the type ``short`` in *C*.
-  cint* {.importc: "int", nodecl.} = int32
-    ## This is the same as the type ``int`` in *C*.
-  clong* {.importc: "long", nodecl.} = int
-    ## This is the same as the type ``long`` in *C*.
-  clonglong* {.importc: "long long", nodecl.} = int64
-    ## This is the same as the type ``long long`` in *C*.
-  cfloat* {.importc: "float", nodecl.} = float32
-    ## This is the same as the type ``float`` in *C*.
-  cdouble* {.importc: "double", nodecl.} = float64
-    ## This is the same as the type ``double`` in *C*.
-  clongdouble* {.importc: "long double", nodecl.} = BiggestFloat
-    ## This is the same as the type ``long double`` in *C*.
-    ## This C type is not supported by Nimrod's code generator
-
-  cstringArray* {.importc: "char**", nodecl.} = ptr array [0..50_000, cstring]
-    ## This is binary compatible to the type ``char**`` in *C*. The array's
-    ## high value is large enough to disable bounds checking in practice.
-    ## Use cstringArrayToSeq to convert it into a ``seq[string]``.
-
-  TEndian* = enum ## is a type describing the endianness of a processor.
+  Endianness* = enum ## Type describing the endianness of a processor.
     littleEndian, bigEndian
 
-  PFloat32* = ptr Float32 ## an alias for ``ptr float32``
-  PFloat64* = ptr Float64 ## an alias for ``ptr float64``
-  PInt64* = ptr Int64 ## an alias for ``ptr int64``
-  PInt32* = ptr Int32 ## an alias for ``ptr int32``
+const
+  cpuEndian* {.magic: "CpuEndian".}: Endianness = littleEndian
+    ## The endianness of the target CPU. This is a valuable piece of
+    ## information for low-level code only. This works thanks to compiler
+    ## magic.
+
+  hostOS* {.magic: "HostOS".}: string = ""
+    ## A string that describes the host operating system.
+    ##
+    ## Possible values:
+    ## `"windows"`, `"macosx"`, `"linux"`, `"netbsd"`, `"freebsd"`,
+    ## `"openbsd"`, `"solaris"`, `"aix"`, `"haiku"`, `"standalone"`.
+
+  hostCPU* {.magic: "HostCPU".}: string = ""
+    ## A string that describes the host CPU.
+    ##
+    ## Possible values:
+    ## `"i386"`, `"alpha"`, `"powerpc"`, `"powerpc64"`, `"powerpc64el"`,
+    ## `"sparc"`, `"amd64"`, `"mips"`, `"mipsel"`, `"arm"`, `"arm64"`,
+    ## `"mips64"`, `"mips64el"`, `"riscv32"`, `"riscv64"`, `"loongarch64"`.
+
+  seqShallowFlag = low(int)
+  strlitFlag = 1 shl (sizeof(int)*8 - 2) # later versions of the codegen \
+  # emit this flag
+  # for string literals, it allows for some optimizations.
 
 const
-  isMainModule* {.magic: "IsMainModule".}: bool = false
-    ## is true only when accessed in the main module. This works thanks to
-    ## compiler magic. It is useful to embed testing code in a module.
-
-  CompileDate* {.magic: "CompileDate"}: string = "0000-00-00"
-    ## is the date of compilation as a string of the form
-    ## ``YYYY-MM-DD``. This works thanks to compiler magic.
-
-  CompileTime* {.magic: "CompileTime"}: string = "00:00:00"
-    ## is the time of compilation as a string of the form
-    ## ``HH:MM:SS``. This works thanks to compiler magic.
-
-  NimrodVersion* {.magic: "NimrodVersion"}: string = "0.0.0"
-    ## is the version of Nimrod as a string.
-    ## This works thanks to compiler magic.
-
-  NimrodMajor* {.magic: "NimrodMajor"}: int = 0
-    ## is the major number of Nimrod's version.
-    ## This works thanks to compiler magic.
-
-  NimrodMinor* {.magic: "NimrodMinor"}: int = 0
-    ## is the minor number of Nimrod's version.
-    ## This works thanks to compiler magic.
-
-  NimrodPatch* {.magic: "NimrodPatch"}: int = 0
-    ## is the patch number of Nimrod's version.
-    ## This works thanks to compiler magic.
-
-  cpuEndian* {.magic: "CpuEndian"}: TEndian = littleEndian
-    ## is the endianness of the target CPU. This is a valuable piece of
-    ## information for low-level code only. This works thanks to compiler magic.
-    
-  hostOS* {.magic: "HostOS"}: string = ""
-    ## a string that describes the host operating system. Possible values:
-    ## "windows", "macosx", "linux", "netbsd", "freebsd", "openbsd", "solaris",
-    ## "aix"
-        
-  hostCPU* {.magic: "HostCPU"}: string = ""
-    ## a string that describes the host CPU. Possible values:
-    ## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm"
-  
-proc toFloat*(i: int): float {.
-  magic: "ToFloat", noSideEffect, importc: "toFloat".}
-  ## converts an integer `i` into a ``float``. If the conversion
-  ## fails, `EInvalidValue` is raised. However, on most platforms the
-  ## conversion cannot fail.
-
-proc toBiggestFloat*(i: biggestint): biggestfloat {.
-  magic: "ToBiggestFloat", noSideEffect, importc: "toBiggestFloat".}
-  ## converts an biggestint `i` into a ``biggestfloat``. If the conversion
-  ## fails, `EInvalidValue` is raised. However, on most platforms the
-  ## conversion cannot fail.
-
-proc toInt*(f: float): int {.
-  magic: "ToInt", noSideEffect, importc: "toInt".}
-  ## converts a floating point number `f` into an ``int``. Conversion
-  ## rounds `f` if it does not contain an integer value. If the conversion
-  ## fails (because `f` is infinite for example), `EInvalidValue` is raised.
-
-proc toBiggestInt*(f: biggestfloat): biggestint {.
-  magic: "ToBiggestInt", noSideEffect, importc: "toBiggestInt".}
-  ## converts a biggestfloat `f` into a ``biggestint``. Conversion
-  ## rounds `f` if it does not contain an integer value. If the conversion
-  ## fails (because `f` is infinite for example), `EInvalidValue` is raised.
+  hasThreadSupport = compileOption("threads") and not defined(nimscript)
+  hasSharedHeap = defined(boehmgc) or defined(gogc) # don't share heaps; every thread has its own
 
-proc `/`*(x, y: int): float {.inline, noSideEffect.} =
-  ## integer division that results in a float.
-  result = toFloat(x) / toFloat(y)
+when notJSnotNims and not defined(nimSeqsV2):
+  template space(s: PGenericSeq): int =
+    s.reserved and not (seqShallowFlag or strlitFlag)
 
-proc addQuitProc*(QuitProc: proc {.noconv.}) {.importc: "atexit", nodecl.}
-  ## adds/registers a quit procedure. Each call to ``addQuitProc``
-  ## registers another quit procedure. Up to 30 procedures can be
-  ## registered. They are executed on a last-in, first-out basis
-  ## (that is, the last function registered is the first to be executed).
-  ## ``addQuitProc`` raises an EOutOfIndex if ``quitProc`` cannot be
-  ## registered.
-
-# Support for addQuitProc() is done by Ansi C's facilities here.
-# In case of an unhandled exeption the exit handlers should
-# not be called explicitly! The user may decide to do this manually though.
-
-proc copy*(s: string, first = 0): string {.
-  magic: "CopyStr", importc: "copyStr", noSideEffect.}
-proc copy*(s: string, first, last: int): string {.
-  magic: "CopyStrLast", importc: "copyStrLast", noSideEffect.}
-  ## copies a slice of `s` into a new string and returns this new
-  ## string. The bounds `first` and `last` denote the indices of
-  ## the first and last characters that shall be copied. If ``last``
-  ## is omitted, it is treated as ``high(s)``.
-
-proc zeroMem*(p: Pointer, size: int) {.importc, noDecl.}
-  ## overwrites the contents of the memory at ``p`` with the value 0.
-  ## Exactly ``size`` bytes will be overwritten. Like any procedure
-  ## dealing with raw memory this is *unsafe*.
-
-proc copyMem*(dest, source: Pointer, size: int) {.importc: "memcpy", noDecl.}
-  ## copies the contents from the memory at ``source`` to the memory
-  ## at ``dest``. Exactly ``size`` bytes will be copied. The memory
-  ## regions may not overlap. Like any procedure dealing with raw
-  ## memory this is *unsafe*.
-
-proc moveMem*(dest, source: Pointer, size: int) {.importc: "memmove", noDecl.}
-  ## copies the contents from the memory at ``source`` to the memory
-  ## at ``dest``. Exactly ``size`` bytes will be copied. The memory
-  ## regions may overlap, ``moveMem`` handles this case appropriately
-  ## and is thus somewhat more safe than ``copyMem``. Like any procedure
-  ## dealing with raw memory this is still *unsafe*, though.
-
-proc equalMem*(a, b: Pointer, size: int): bool {.
-  importc: "equalMem", noDecl, noSideEffect.}
-  ## compares the memory blocks ``a`` and ``b``. ``size`` bytes will
-  ## be compared. If the blocks are equal, true is returned, false
-  ## otherwise. Like any procedure dealing with raw memory this is
-  ## *unsafe*.
-
-proc alloc*(size: int): pointer {.noconv.}
-  ## allocates a new memory block with at least ``size`` bytes. The
-  ## block has to be freed with ``realloc(block, 0)`` or
-  ## ``dealloc(block)``. The block is not initialized, so reading
-  ## from it before writing to it is undefined behaviour!
-proc alloc0*(size: int): pointer {.noconv.}
-  ## allocates a new memory block with at least ``size`` bytes. The
-  ## block has to be freed with ``realloc(block, 0)`` or
-  ## ``dealloc(block)``. The block is initialized with all bytes
-  ## containing zero, so it is somewhat safer than ``alloc``.
-proc realloc*(p: Pointer, newsize: int): pointer {.noconv.}
-  ## grows or shrinks a given memory block. If p is **nil** then a new
-  ## memory block is returned. In either way the block has at least
-  ## ``newsize`` bytes. If ``newsize == 0`` and p is not **nil**
-  ## ``realloc`` calls ``dealloc(p)``. In other cases the block has to
-  ## be freed with ``dealloc``.
-proc dealloc*(p: Pointer) {.noconv.}
-  ## frees the memory allocated with ``alloc``, ``alloc0`` or
-  ## ``realloc``. This procedure is dangerous! If one forgets to
-  ## free the memory a leak occurs; if one tries to access freed
-  ## memory (or just freeing it twice!) a core dump may happen
-  ## or other memory may be corrupted. 
-
-proc assert*(cond: bool) {.magic: "Assert", noSideEffect.}
-  ## 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.
-  ## Use ``assert`` for debugging purposes only.
+when hasThreadSupport and defined(tcc) and not compileOption("tlsEmulation"):
+  # tcc doesn't support TLS
+  {.error: "`--tlsEmulation:on` must be used when using threads with tcc backend".}
 
-proc swap*[T](a, b: var T) {.magic: "Swap", noSideEffect.}
-  ## swaps the values `a` and `b`. This is often more efficient than
-  ## ``tmp = a; a = b; b = tmp``. Particularly useful for sorting algorithms.
+when defined(boehmgc):
+  when defined(windows):
+    when sizeof(int) == 8:
+      const boehmLib = "boehmgc64.dll"
+    else:
+      const boehmLib = "boehmgc.dll"
+  elif defined(macosx):
+    const boehmLib = "libgc.dylib"
+  elif defined(openbsd):
+    const boehmLib = "libgc.so.(4|5).0"
+  elif defined(freebsd):
+    const boehmLib = "libgc-threaded.so.1"
+  else:
+    const boehmLib = "libgc.so.1"
+  {.pragma: boehmGC, noconv, dynlib: boehmLib.}
 
-template `>=%` *(x, y: expr): expr = y <=% x
-  ## treats `x` and `y` as unsigned and compares them.
-  ## Returns true iff ``unsigned(x) >= unsigned(y)``.
+when not defined(nimPreviewSlimSystem):
+  type TaintedString* {.deprecated: "Deprecated since 1.5".} = string
 
-template `>%` *(x, y: expr): expr = y <% x
-  ## treats `x` and `y` as unsigned and compares them.
-  ## Returns true iff ``unsigned(x) > unsigned(y)``.
 
-proc `$` *(x: int): string {.magic: "IntToStr", noSideEffect.}
-  ## The stingify operator for an integer argument. Returns `x`
-  ## converted to a decimal string.
+when defined(profiler) and not defined(nimscript):
+  proc nimProfile() {.compilerproc, noinline.}
+when hasThreadSupport:
+  {.pragma: rtlThreadVar, threadvar.}
+else:
+  {.pragma: rtlThreadVar.}
 
-proc `$` *(x: int64): string {.magic: "Int64ToStr", noSideEffect.}
-  ## The stingify operator for an integer argument. Returns `x`
-  ## converted to a decimal string.
+const
+  QuitSuccess* = 0
+    ## is the value that should be passed to `quit <#quit,int>`_ to indicate
+    ## success.
 
-proc `$` *(x: float): string {.magic: "FloatToStr", noSideEffect.}
-  ## The stingify operator for a float argument. Returns `x`
-  ## converted to a decimal string.
+  QuitFailure* = 1
+    ## is the value that should be passed to `quit <#quit,int>`_ to indicate
+    ## failure.
 
-proc `$` *(x: bool): string {.magic: "BoolToStr", noSideEffect.}
-  ## The stingify operator for a boolean argument. Returns `x`
-  ## converted to the string "false" or "true".
+when not defined(js) and hostOS != "standalone":
+  var programResult* {.compilerproc, exportc: "nim_program_result".}: int
+    ## deprecated, prefer `quit` or `exitprocs.getProgramResult`, `exitprocs.setProgramResult`.
 
-proc `$` *(x: char): string {.magic: "CharToStr", noSideEffect.}
-  ## The stingify operator for a character argument. Returns `x`
-  ## converted to a string.
+import std/private/since
+import system/ctypes
+export ctypes
 
-proc `$` *(x: Cstring): string {.magic: "CStrToStr", noSideEffect.}
-  ## The stingify operator for a CString argument. Returns `x`
-  ## converted to a string.
+proc align(address, alignment: int): int =
+  if alignment == 0: # Actually, this is illegal. This branch exists to actively
+                     # hide problems.
+    result = address
+  else:
+    result = (address + (alignment - 1)) and not (alignment - 1)
 
-proc `$` *(x: string): string {.magic: "StrToStr", noSideEffect.}
-  ## The stingify operator for a string argument. Returns `x`
-  ## as it is. This operator is useful for generic code, so
-  ## that ``$expr`` also works if ``expr`` already is a string.
+include system/rawquits
+when defined(genode):
+  export GenodeEnv
 
-proc `$` *[T](x: ordinal[T]): string {.magic: "EnumToStr", noSideEffect.}
-  ## The stingify operator for an enumeration argument. This works for
-  ## any enumeration type thanks to compiler magic. If a
-  ## a ``$`` operator for a concrete enumeration is provided, this is
-  ## used instead. (In other words: *Overwriting* is possible.)
+template sysAssert(cond: bool, msg: string) =
+  when defined(useSysAssert):
+    if not cond:
+      cstderr.rawWrite "[SYSASSERT] "
+      cstderr.rawWrite msg
+      cstderr.rawWrite "\n"
+      rawQuit 1
 
-# undocumented:
-proc getRefcount*[T](x: ref T): int {.importc: "getRefcount", noSideEffect.}
-  ## retrieves the reference count of an heap-allocated object. The
-  ## value is implementation-dependant.
+const hasAlloc = (hostOS != "standalone" or not defined(nogc)) and not defined(nimscript)
 
-#proc writeStackTrace() {.export: "writeStackTrace".}
+when notJSnotNims and hasAlloc and not defined(nimSeqsV2):
+  proc addChar(s: NimString, c: char): NimString {.compilerproc, benign.}
 
-when not defined(NimrodVM):
-  proc getCurrentExceptionMsg*(): string {.exportc.}
-    ## retrieves the error message that was attached to the current
-    ## exception; if there is none, "" is returned.
+when defined(nimscript) or not defined(nimSeqsV2):
+  proc add*[T](x: var seq[T], y: sink T) {.magic: "AppendSeqElem", noSideEffect.}
+    ## Generic proc for adding a data item `y` to a container `x`.
+    ##
+    ## For containers that have an order, `add` means *append*. New generic
+    ## containers should also call their adding proc `add` for consistency.
+    ## Generic code becomes much easier to write if the Nim naming scheme is
+    ## respected.
+    ##   ```nim
+    ##   var s: seq[string] = @["test2","test2"]
+    ##   s.add("test")
+    ##   assert s == @["test2", "test2", "test"]
+    ##   ```
+
+when false: # defined(gcDestructors):
+  proc add*[T](x: var seq[T], y: sink openArray[T]) {.noSideEffect.} =
+    ## Generic proc for adding a container `y` to a container `x`.
+    ##
+    ## For containers that have an order, `add` means *append*. New generic
+    ## containers should also call their adding proc `add` for consistency.
+    ## Generic code becomes much easier to write if the Nim naming scheme is
+    ## respected.
+    ##   ```nim
+    ##   var s: seq[string] = @["test2","test2"]
+    ##   s.add("test") # s <- @[test2, test2, test]
+    ##   ```
+    ##
+    ## See also:
+    ## * `& proc <#&,seq[T],seq[T]>`_
+    {.noSideEffect.}:
+      let xl = x.len
+      setLen(x, xl + y.len)
+      for i in 0..high(y):
+        when nimvm:
+          # workaround the fact that the VM does not yet
+          # handle sink parameters properly:
+          x[xl+i] = y[i]
+        else:
+          x[xl+i] = move y[i]
+else:
+  proc add*[T](x: var seq[T], y: openArray[T]) {.noSideEffect.} =
+    ## Generic proc for adding a container `y` to a container `x`.
+    ##
+    ## For containers that have an order, `add` means *append*. New generic
+    ## containers should also call their adding proc `add` for consistency.
+    ## Generic code becomes much easier to write if the Nim naming scheme is
+    ## respected.
+    ##
+    ## See also:
+    ## * `& proc <#&,seq[T],seq[T]>`_
+    runnableExamples:
+      var a = @["a1", "a2"]
+      a.add(["b1", "b2"])
+      assert a == @["a1", "a2", "b1", "b2"]
+      var c = @["c0", "c1", "c2", "c3"]
+      a.add(c.toOpenArray(1, 2))
+      assert a == @["a1", "a2", "b1", "b2", "c1", "c2"]
+
+    {.noSideEffect.}:
+      let xl = x.len
+      setLen(x, xl + y.len)
+      for i in 0..high(y): x[xl+i] = y[i]
+
+
+when defined(nimSeqsV2):
+  template movingCopy(a, b: typed) =
+    a = move(b)
+else:
+  template movingCopy(a, b: typed) =
+    shallowCopy(a, b)
+
+proc del*[T](x: var seq[T], i: Natural) {.noSideEffect.} =
+  ## Deletes the item at index `i` by putting `x[high(x)]` into position `i`.
+  ##
+  ## This is an `O(1)` operation.
+  ##
+  ## See also:
+  ## * `delete <#delete,seq[T],Natural>`_ for preserving the order
+  runnableExamples:
+    var a = @[10, 11, 12, 13, 14]
+    a.del(2)
+    assert a == @[10, 11, 14, 13]
+  let xl = x.len - 1
+  movingCopy(x[i], x[xl])
+  setLen(x, xl)
+
+proc insert*[T](x: var seq[T], item: sink T, i = 0.Natural) {.noSideEffect.} =
+  ## Inserts `item` into `x` at position `i`.
+  ##   ```nim
+  ##   var i = @[1, 3, 5]
+  ##   i.insert(99, 0) # i <- @[99, 1, 3, 5]
+  ##   ```
+  {.noSideEffect.}:
+    template defaultImpl =
+      let xl = x.len
+      setLen(x, xl+1)
+      var j = xl-1
+      while j >= i:
+        movingCopy(x[j+1], x[j])
+        dec(j)
+    when nimvm:
+      defaultImpl()
+    else:
+      when defined(js):
+        var it : T
+        {.emit: "`x` = `x` || []; `x`.splice(`i`, 0, `it`);".}
+      else:
+        defaultImpl()
+    x[i] = item
+
+when not defined(nimV2):
+  proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.}
+    ## Takes any Nim variable and returns its string representation.
+    ## No trailing newline is inserted (so `echo` won't add an empty newline).
+    ## Use `-d:nimLegacyReprWithNewline` to revert to old behavior where newlines
+    ## were added in some cases.
+    ##
+    ## It works even for complex data graphs with cycles. This is a great
+    ## debugging tool.
+    ##   ```nim
+    ##   var s: seq[string] = @["test2", "test2"]
+    ##   var i = @[1, 2, 3, 4, 5]
+    ##   echo repr(s) # => 0x1055eb050[0x1055ec050"test2", 0x1055ec078"test2"]
+    ##   echo repr(i) # => 0x1055ed050[1, 2, 3, 4, 5]
+    ##   ```
+
+when not defined(nimPreviewSlimSystem):
+  type
+    csize* {.importc: "size_t", nodecl, deprecated: "use `csize_t` instead".} = int
+      ## This isn't the same as `size_t` in *C*. Don't use it.
 
-# new constants:
 const
-  inf* {.magic: "Inf".} = 1.0 / 0.0
-    ## contains the IEEE floating point value of positive infinity.
-  neginf* {.magic: "NegInf".} = -inf
-    ## contains the IEEE floating point value of negative infinity.
-  nan* {.magic: "NaN".} = 0.0 / 0.0
-    ## contains an IEEE floating point value of *Not A Number*. Note
-    ## that you cannot compare a floating point value to this value
-    ## and expect a reasonable result - use the `classify` procedure
-    ## in the module ``math`` for checking for NaN.
-
-var
-  dbgLineHook*: proc = nil
-    ## set this variable to provide a procedure that should be called before
-    ## each executed instruction. This should only be used by debuggers!
-    ## Only code compiled with the ``debugger:on`` switch calls this hook.
-
-# GC interface:
-
-proc getOccupiedMem*(): int
-  ## returns the number of bytes that are owned by the process and hold data.
-
-proc getFreeMem*(): int
-  ## returns the number of bytes that are owned by the process, but do not
-  ## hold any meaningful data.
-
-proc getTotalMem*(): int
-  ## returns the number of bytes that are owned by the process.
-
-
-iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
-  ## Counts from ordinal value `a` down to `b` with the given
-  ## step count. `T` may be any ordinal type, `step` may only
-  ## be positive.
-  var res = a
-  while res >= b:
-    yield res
-    dec(res, step)
-
-iterator countup*[T](a, b: T, step = 1): T {.inline.} =
-  ## Counts from ordinal value `a` up to `b` with the given
-  ## step count. `T` may be any ordinal type, `step` may only
-  ## be positive.
-  var res = a
-  while res <= b:
-    yield res
-    inc(res, step)
-  # we cannot use ``for x in a..b: `` here, because that is not
-  # known in the System module
-
-
-proc min*(x, y: int): int {.magic: "MinI", noSideEffect.}
-proc min*(x, y: int8): int8 {.magic: "MinI", noSideEffect.}
-proc min*(x, y: int16): int16 {.magic: "MinI", noSideEffect.}
-proc min*(x, y: int32): int32 {.magic: "MinI", noSideEffect.}
-proc min*(x, y: int64): int64 {.magic: "MinI64", noSideEffect.}
-  ## The minimum value of two integers.
-
-proc min*[T](x: openarray[T]): T = 
-  ## The minimum value of an openarray.
-  result = x[0]
-  for i in 1..high(x): result = min(result, x[i])
-
-proc max*(x, y: int): int {.magic: "MaxI", noSideEffect.}
-proc max*(x, y: int8): int8 {.magic: "MaxI", noSideEffect.}
-proc max*(x, y: int16): int16 {.magic: "MaxI", noSideEffect.}
-proc max*(x, y: int32): int32 {.magic: "MaxI", noSideEffect.}
-proc max*(x, y: int64): int64 {.magic: "MaxI64", noSideEffect.}
-  ## The maximum value of two integers.
-
-proc max*[T](x: openarray[T]): T = 
-  ## The maximum value of an openarray.
-  result = x[0]
-  for i in 1..high(x): result = max(result, x[i])
-
-
-iterator items*[T](a: openarray[T]): T {.inline.} =
-  ## iterates over each item of `a`.
-  var i = 0
-  while i < len(a):
-    yield a[i]
-    inc(i)
-
-iterator items*[IX, T](a: array[IX, T]): T {.inline.} =
-  ## iterates over each item of `a`.
-  var i = low(IX)
-  if i <= high(IX):
-    while true:
-      yield a[i]
-      if i >= high(IX): break
-      inc(i)
+  Inf* = 0x7FF0000000000000'f64
+    ## Contains the IEEE floating point value of positive infinity.
+  NegInf* = 0xFFF0000000000000'f64
+    ## Contains the IEEE floating point value of negative infinity.
+  NaN* = 0x7FF7FFFFFFFFFFFF'f64
+    ## Contains an IEEE floating point value of *Not A Number*.
+    ##
+    ## Note that you cannot compare a floating point value to this value
+    ## and expect a reasonable result - use the `isNaN` or `classify` procedure
+    ## in the `math module <math.html>`_ for checking for NaN.
 
-iterator items*[T](a: seq[T]): T {.inline.} =
-  ## iterates over each item of `a`.
-  var i = 0
-  while i < len(a):
-    yield a[i]
-    inc(i)
-
-iterator items*(a: string): char {.inline.} =
-  ## iterates over each item of `a`.
-  var i = 0
-  while i < len(a):
-    yield a[i]
-    inc(i)
-
-iterator items*[T](a: set[T]): T {.inline.} =
-  ## iterates over each element of `a`. `items` iterates only over the
-  ## elements that are really in the set (and not over the ones the set is
-  ## able to hold).
-  var i = low(T)
-  if i <= high(T):
-    while true:
-      if i in a: yield i
-      if i >= high(T): break
-      inc(i)
+proc high*(T: typedesc[SomeFloat]): T = Inf
+proc low*(T: typedesc[SomeFloat]): T = NegInf
+
+proc toFloat*(i: int): float {.noSideEffect, inline.} =
+  ## Converts an integer `i` into a `float`. Same as `float(i)`.
+  ##
+  ## If the conversion fails, `ValueError` is raised.
+  ## However, on most platforms the conversion cannot fail.
+  ##
+  ##   ```nim
+  ##   let
+  ##     a = 2
+  ##     b = 3.7
+  ##
+  ##   echo a.toFloat + b # => 5.7
+  ##   ```
+  float(i)
+
+proc toBiggestFloat*(i: BiggestInt): BiggestFloat {.noSideEffect, inline.} =
+  ## Same as `toFloat <#toFloat,int>`_ but for `BiggestInt` to `BiggestFloat`.
+  BiggestFloat(i)
+
+proc toInt*(f: float): int {.noSideEffect.} =
+  ## Converts a floating point number `f` into an `int`.
+  ##
+  ## Conversion rounds `f` half away from 0, see
+  ## `Round half away from zero
+  ## <https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero>`_,
+  ## as opposed to a type conversion which rounds towards zero.
+  ##
+  ## Note that some floating point numbers (e.g. infinity or even 1e19)
+  ## cannot be accurately converted.
+  ##   ```nim
+  ##   doAssert toInt(0.49) == 0
+  ##   doAssert toInt(0.5) == 1
+  ##   doAssert toInt(-0.5) == -1 # rounding is symmetrical
+  ##   ```
+  if f >= 0: int(f+0.5) else: int(f-0.5)
+
+proc toBiggestInt*(f: BiggestFloat): BiggestInt {.noSideEffect.} =
+  ## Same as `toInt <#toInt,float>`_ but for `BiggestFloat` to `BiggestInt`.
+  if f >= 0: BiggestInt(f+0.5) else: BiggestInt(f-0.5)
+
+proc `/`*(x, y: int): float {.inline, noSideEffect.} =
+  ## Division of integers that results in a float.
+  ##   ```nim
+  ##   echo 7 / 5 # => 1.4
+  ##   ```
+  ##
+  ## See also:
+  ## * `div <system.html#div,int,int>`_
+  ## * `mod <system.html#mod,int,int>`_
+  result = toFloat(x) / toFloat(y)
+
+{.push stackTrace: off.}
+
+when defined(js):
+  proc js_abs[T: SomeNumber](x: T): T {.importc: "Math.abs".}
+else:
+  proc c_fabs(x: cdouble): cdouble {.importc: "fabs", header: "<math.h>".}
+  proc c_fabsf(x: cfloat): cfloat {.importc: "fabsf", header: "<math.h>".}
+
+proc abs*[T: float64 | float32](x: T): T {.noSideEffect, inline.} =
+  when nimvm:
+    if x < 0.0: result = -x
+    elif x == 0.0: result = 0.0 # handle 0.0, -0.0
+    else: result = x # handle NaN, > 0
+  else:
+    when defined(js): result = js_abs(x)
+    else:
+      when T is float64:
+        result = c_fabs(x)
+      else:
+        result = c_fabsf(x)
+
+func abs*(x: int): int {.magic: "AbsI", inline.} =
+  if x < 0: -x else: x
+func abs*(x: int8): int8 {.magic: "AbsI", inline.} =
+  if x < 0: -x else: x
+func abs*(x: int16): int16 {.magic: "AbsI", inline.} =
+  if x < 0: -x else: x
+func abs*(x: int32): int32 {.magic: "AbsI", inline.} =
+  if x < 0: -x else: x
+func abs*(x: int64): int64 {.magic: "AbsI", inline.} =
+  ## Returns the absolute value of `x`.
+  ##
+  ## If `x` is `low(x)` (that is -MININT for its type),
+  ## an overflow exception is thrown (if overflow checking is turned on).
+  result = if x < 0: -x else: x
+
+{.pop.} # stackTrace: off
+
+when not defined(nimPreviewSlimSystem):
+  proc addQuitProc*(quitProc: proc() {.noconv.}) {.
+    importc: "atexit", header: "<stdlib.h>", deprecated: "use exitprocs.addExitProc".}
+    ## Adds/registers a quit procedure.
+    ##
+    ## Each call to `addQuitProc` registers another quit procedure. Up to 30
+    ## procedures can be registered. They are executed on a last-in, first-out
+    ## basis (that is, the last function registered is the first to be executed).
+    ## `addQuitProc` raises an EOutOfIndex exception if `quitProc` cannot be
+    ## registered.
+    # Support for addQuitProc() is done by Ansi C's facilities here.
+    # In case of an unhandled exception the exit handlers should
+    # not be called explicitly! The user may decide to do this manually though.
 
-iterator items*(a: cstring): char {.inline.} =
-  ## iterates over each item of `a`.
-  var i = 0
-  while a[i] != '\0':
-    yield a[i]
-    inc(i)
+proc swap*[T](a, b: var T) {.magic: "Swap", noSideEffect.}
+  ## Swaps the values `a` and `b`.
+  ##
+  ## This is often more efficient than `tmp = a; a = b; b = tmp`.
+  ## Particularly useful for sorting algorithms.
+  ##
+  ##   ```nim
+  ##   var
+  ##     a = 5
+  ##     b = 9
+  ##
+  ##   swap(a, b)
+  ##
+  ##   assert a == 9
+  ##   assert b == 5
+  ##   ```
+
+when not defined(js) and not defined(booting) and defined(nimTrMacros):
+  template swapRefsInArray*{swap(arr[a], arr[b])}(arr: openArray[ref], a, b: int) =
+    # Optimize swapping of array elements if they are refs. Default swap
+    # implementation will cause unsureAsgnRef to be emitted which causes
+    # unnecessary slow down in this case.
+    swap(cast[ptr pointer](addr arr[a])[], cast[ptr pointer](addr arr[b])[])
+
+when not defined(nimscript):
+  {.push stackTrace: off, profiler: off.}
+
+  when not defined(nimPreviewSlimSystem):
+    import std/sysatomics
+    export sysatomics
+  else:
+    import std/sysatomics
+
+  {.pop.}
+
+include "system/memalloc"
+
+
+proc `|`*(a, b: typedesc): typedesc = discard
+
+include "system/iterators_1"
+
+
+proc len*[U: Ordinal; V: Ordinal](x: HSlice[U, V]): int {.noSideEffect, inline.} =
+  ## Length of ordinal slice. When x.b < x.a returns zero length.
+  ##   ```nim
+  ##   assert((0..5).len == 6)
+  ##   assert((5..2).len == 0)
+  ##   ```
+  result = max(0, ord(x.b) - ord(x.a) + 1)
 
-proc isNil*[T](x: seq[T]): bool {.noSideEffect, magic: "IsNil".}
 proc isNil*[T](x: ref T): bool {.noSideEffect, magic: "IsNil".}
-proc isNil*(x: string): bool {.noSideEffect, magic: "IsNil".}
+
 proc isNil*[T](x: ptr T): bool {.noSideEffect, magic: "IsNil".}
 proc isNil*(x: pointer): bool {.noSideEffect, magic: "IsNil".}
 proc isNil*(x: cstring): bool {.noSideEffect, magic: "IsNil".}
+proc isNil*[T: proc | iterator {.closure.}](x: T): bool {.noSideEffect, magic: "IsNil".}
   ## Fast check whether `x` is nil. This is sometimes more efficient than
-  ## ``== nil``.
-
-
-# Fixup some magic symbols here:
-#{.fixup_system.} 
-# This is an undocumented pragma that can only be used
-# once in the system module.
-
-proc `&` *[T](x, y: openArray[T]): seq[T] {.noSideEffect.} =
-  newSeq(result, x.len + y.len)
-  for i in 0..x.len-1:
-    result[i] = x[i]
-  for i in 0..y.len-1:
-    result[i+x.len] = y[i]
-
-proc `&` *[T](x: openArray[T], y: T): seq[T] {.noSideEffect.} =
-  newSeq(result, x.len + 1)
-  for i in 0..x.len-1:
-    result[i] = x[i]
-  result[x.len] = y
-
-proc `&` *[T](x: T, y: openArray[T]): seq[T] {.noSideEffect.} =
-  newSeq(result, y.len + 1)
-  for i in 0..y.len-1:
-    result[i] = y[i]
-  result[y.len] = x
-
-when not defined(NimrodVM):
-  when not defined(ECMAScript):
-    proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
-      result = cast[pointer](x)
-  else:
-    proc seqToPtr[T](x: seq[T]): pointer {.pure, nosideeffect.} =
-      asm """return `x`"""
-  
-  proc `==` *[T: typeDesc](x, y: seq[T]): bool {.noSideEffect.} =
-    ## Generic equals operator for sequences: relies on a equals operator for
-    ## the element type `T`.
-    if seqToPtr(x) == seqToPtr(y):
-      result = true
-    elif seqToPtr(x) == nil or seqToPtr(y) == nil:
-      result = false
-    elif x.len == y.len:
-      for i in 0..x.len-1:
-        if x[i] != y[i]: return false
-      result = true
-
-proc find*[T, S: typeDesc](a: T, item: S): int {.inline.}=
+  ## `== nil`.
+
+when defined(nimHasTopDownInference):
+  # magic used for seq type inference
+  proc `@`*[T](a: openArray[T]): seq[T] {.magic: "OpenArrayToSeq".} =
+    ## Turns an *openArray* into a sequence.
+    ##
+    ## This is not as efficient as turning a fixed length array into a sequence
+    ## as it always copies every element of `a`.
+    newSeq(result, a.len)
+    for i in 0..a.len-1: result[i] = a[i]
+else:
+  proc `@`*[T](a: openArray[T]): seq[T] =
+    ## Turns an *openArray* into a sequence.
+    ##
+    ## This is not as efficient as turning a fixed length array into a sequence
+    ## as it always copies every element of `a`.
+    newSeq(result, a.len)
+    for i in 0..a.len-1: result[i] = a[i]
+
+
+when defined(nimSeqsV2):
+
+  proc `&`*[T](x, y: sink seq[T]): seq[T] {.noSideEffect.} =
+    ## Concatenates two sequences.
+    ##
+    ## Requires copying of the sequences.
+    ##   ```nim
+    ##   assert(@[1, 2, 3, 4] & @[5, 6] == @[1, 2, 3, 4, 5, 6])
+    ##   ```
+    ##
+    ## See also:
+    ## * `add(var seq[T], openArray[T]) <#add,seq[T],openArray[T]>`_
+    newSeq(result, x.len + y.len)
+    for i in 0..x.len-1:
+      result[i] = move(x[i])
+    for i in 0..y.len-1:
+      result[i+x.len] = move(y[i])
+
+  proc `&`*[T](x: sink seq[T], y: sink T): seq[T] {.noSideEffect.} =
+    ## Appends element y to the end of the sequence.
+    ##
+    ## Requires copying of the sequence.
+    ##   ```nim
+    ##   assert(@[1, 2, 3] & 4 == @[1, 2, 3, 4])
+    ##   ```
+    ##
+    ## See also:
+    ## * `add(var seq[T], T) <#add,seq[T],sinkT>`_
+    newSeq(result, x.len + 1)
+    for i in 0..x.len-1:
+      result[i] = move(x[i])
+    result[x.len] = move(y)
+
+  proc `&`*[T](x: sink T, y: sink seq[T]): seq[T] {.noSideEffect.} =
+    ## Prepends the element x to the beginning of the sequence.
+    ##
+    ## Requires copying of the sequence.
+    ##   ```nim
+    ##   assert(1 & @[2, 3, 4] == @[1, 2, 3, 4])
+    ##   ```
+    newSeq(result, y.len + 1)
+    result[0] = move(x)
+    for i in 0..y.len-1:
+      result[i+1] = move(y[i])
+
+else:
+
+  proc `&`*[T](x, y: seq[T]): seq[T] {.noSideEffect.} =
+    ## Concatenates two sequences.
+    ##
+    ## Requires copying of the sequences.
+    ##   ```nim
+    ##   assert(@[1, 2, 3, 4] & @[5, 6] == @[1, 2, 3, 4, 5, 6])
+    ##   ```
+    ##
+    ## See also:
+    ## * `add(var seq[T], openArray[T]) <#add,seq[T],openArray[T]>`_
+    newSeq(result, x.len + y.len)
+    for i in 0..x.len-1:
+      result[i] = x[i]
+    for i in 0..y.len-1:
+      result[i+x.len] = y[i]
+
+  proc `&`*[T](x: seq[T], y: T): seq[T] {.noSideEffect.} =
+    ## Appends element y to the end of the sequence.
+    ##
+    ## Requires copying of the sequence.
+    ##   ```nim
+    ##   assert(@[1, 2, 3] & 4 == @[1, 2, 3, 4])
+    ##   ```
+    ##
+    ## See also:
+    ## * `add(var seq[T], T) <#add,seq[T],sinkT>`_
+    newSeq(result, x.len + 1)
+    for i in 0..x.len-1:
+      result[i] = x[i]
+    result[x.len] = y
+
+  proc `&`*[T](x: T, y: seq[T]): seq[T] {.noSideEffect.} =
+    ## Prepends the element x to the beginning of the sequence.
+    ##
+    ## Requires copying of the sequence.
+    ##   ```nim
+    ##   assert(1 & @[2, 3, 4] == @[1, 2, 3, 4])
+    ##   ```
+    newSeq(result, y.len + 1)
+    result[0] = x
+    for i in 0..y.len-1:
+      result[i+1] = y[i]
+
+
+proc instantiationInfo*(index = -1, fullPaths = false): tuple[
+  filename: string, line: int, column: int] {.magic: "InstantiationInfo", noSideEffect.}
+  ## Provides access to the compiler's instantiation stack line information
+  ## of a template.
+  ##
+  ## While similar to the `caller info`:idx: of other languages, it is determined
+  ## at compile time.
+  ##
+  ## This proc is mostly useful for meta programming (eg. `assert` template)
+  ## to retrieve information about the current filename and line number.
+  ## Example:
+  ##
+  ##   ```nim
+  ##   import std/strutils
+  ##
+  ##   template testException(exception, code: untyped): typed =
+  ##     try:
+  ##       let pos = instantiationInfo()
+  ##       discard(code)
+  ##       echo "Test failure at $1:$2 with '$3'" % [pos.filename,
+  ##         $pos.line, astToStr(code)]
+  ##       assert false, "A test expecting failure succeeded?"
+  ##     except exception:
+  ##       discard
+  ##
+  ##   proc tester(pos: int): int =
+  ##     let
+  ##       a = @[1, 2, 3]
+  ##     result = a[pos]
+  ##
+  ##   when isMainModule:
+  ##     testException(IndexDefect, tester(30))
+  ##     testException(IndexDefect, tester(1))
+  ##     # --> Test failure at example.nim:20 with 'tester(1)'
+  ##   ```
+
+
+when notJSnotNims:
+  import system/ansi_c
+  import system/memory
+
+
+{.push stackTrace: off.}
+
+when not defined(js) and hasThreadSupport and hostOS != "standalone":
+  import std/private/syslocks
+  include "system/threadlocalstorage"
+
+when not defined(js) and defined(nimV2):
+  type
+    DestructorProc = proc (p: pointer) {.nimcall, benign, raises: [].}
+    TNimTypeV2 {.compilerproc.} = object
+      destructor: pointer
+      size: int
+      align: int16
+      depth: int16
+      display: ptr UncheckedArray[uint32] # classToken
+      when defined(nimTypeNames) or defined(nimArcIds):
+        name: cstring
+      traceImpl: pointer
+      typeInfoV1: pointer # for backwards compat, usually nil
+      flags: int
+      when defined(gcDestructors):
+        when defined(cpp):
+          vTable: ptr UncheckedArray[pointer] # vtable for types
+        else:
+          vTable: UncheckedArray[pointer] # vtable for types
+    PNimTypeV2 = ptr TNimTypeV2
+
+proc supportsCopyMem(t: typedesc): bool {.magic: "TypeTrait".}
+
+when notJSnotNims and defined(nimSeqsV2):
+  include "system/strs_v2"
+  include "system/seqs_v2"
+
+when not defined(js):
+  template newSeqImpl(T, len) =
+    result = newSeqOfCap[T](len)
+    {.cast(noSideEffect).}:
+      when defined(nimSeqsV2):
+        cast[ptr int](addr result)[] = len
+      else:
+        var s = cast[PGenericSeq](result)
+        s.len = len
+
+  proc newSeqUninitialized*[T: SomeNumber](len: Natural): seq[T] {.deprecated: "Use `newSeqUninit` instead".} =
+    ## Creates a new sequence of type `seq[T]` with length `len`.
+    ##
+    ## Only available for numbers types. Note that the sequence will be
+    ## uninitialized. After the creation of the sequence you should assign
+    ## entries to the sequence instead of adding them.
+    ## Example:
+    ##   ```nim
+    ##   var x = newSeqUninitialized[int](3)
+    ##   assert len(x) == 3
+    ##   x[0] = 10
+    ##   ```
+    result = newSeqOfCap[T](len)
+    when defined(nimSeqsV2):
+      cast[ptr int](addr result)[] = len
+    else:
+      var s = cast[PGenericSeq](result)
+      s.len = len
+
+  func newSeqUninit*[T](len: Natural): seq[T] =
+    ## Creates a new sequence of type `seq[T]` with length `len`.
+    ##
+    ## Only available for types, which don't contain
+    ## managed memory or have destructors.
+    ## Note that the sequence will be uninitialized.
+    ## After the creation of the sequence you should assign
+    ## entries to the sequence instead of adding them.
+    runnableExamples:
+      var x = newSeqUninit[int](3)
+      assert len(x) == 3
+      x[0] = 10
+    when supportsCopyMem(T):
+      when nimvm:
+        result = newSeq[T](len)
+      else:
+        newSeqImpl(T, len)
+    else:
+      {.error: "The type T cannot contain managed memory or have destructors".}
+
+  proc newStringUninit*(len: Natural): string =
+    ## Returns a new string of length `len` but with uninitialized
+    ## content. One needs to fill the string character after character
+    ## with the index operator `s[i]`.
+    ##
+    ## This procedure exists only for optimization purposes;
+    ## the same effect can be achieved with the `&` operator or with `add`.
+    when nimvm:
+      result = newString(len)
+    else:
+      result = newStringOfCap(len)
+      when defined(nimSeqsV2):
+        let s = cast[ptr NimStringV2](addr result)
+        if len > 0:
+          s.len = len
+          s.p.data[len] = '\0'
+      else:
+        let s = cast[NimString](result)
+        s.len = len
+        s.data[len] = '\0'
+else:
+  proc newStringUninit*(len: Natural): string {.
+    magic: "NewString", importc: "mnewString", noSideEffect.}
+
+{.pop.}
+
+when not defined(nimscript):
+  proc writeStackTrace*() {.tags: [], gcsafe, raises: [].}
+    ## Writes the current stack trace to `stderr`. This is only works
+    ## for debug builds. Since it's usually used for debugging, this
+    ## is proclaimed to have no IO effect!
+
+when not declared(sysFatal):
+  include "system/fatal"
+
+type
+  PFrame* = ptr TFrame  ## Represents a runtime frame of the call stack;
+                        ## part of the debugger API.
+  # keep in sync with nimbase.h `struct TFrame_`
+  TFrame* {.importc, nodecl, final.} = object ## The frame itself.
+    prev*: PFrame       ## Previous frame; used for chaining the call stack.
+    procname*: cstring  ## Name of the proc that is currently executing.
+    line*: int          ## Line number of the proc that is currently executing.
+    filename*: cstring  ## Filename of the proc that is currently executing.
+    len*: int16         ## Length of the inspectable slots.
+    calldepth*: int16   ## Used for max call depth checking.
+    when NimStackTraceMsgs:
+      frameMsgLen*: int   ## end position in frameMsgBuf for this frame.
+
+when defined(nimV2):
+  var
+    framePtr {.threadvar.}: PFrame
+
+  include system/arc
+
+template newException*(exceptn: typedesc, message: string;
+                       parentException: ref Exception = nil): untyped =
+  ## Creates an exception object of type `exceptn` and sets its `msg` field
+  ## to `message`. Returns the new exception object.
+  (ref exceptn)(msg: message, parent: parentException)
+
+when not defined(nimPreviewSlimSystem):
+  import std/assertions
+  export assertions
+
+import system/iterators
+export iterators
+
+
+proc find*[T, S](a: T, item: S): int {.inline.}=
   ## Returns the first index of `item` in `a` or -1 if not found. This requires
-  ## appropriate `items` and `==` procs to work.
+  ## appropriate `items` and `==` operations to work.
+  result = 0
   for i in items(a):
     if i == item: return
     inc(result)
@@ -1171,432 +1747,1209 @@ proc find*[T, S: typeDesc](a: T, item: S): int {.inline.}=
 
 proc contains*[T](a: openArray[T], item: T): bool {.inline.}=
   ## Returns true if `item` is in `a` or false if not found. This is a shortcut
-  ## for ``find(a, item) >= 0``.
+  ## for `find(a, item) >= 0`.
+  ##
+  ## This allows the `in` operator: `a.contains(item)` is the same as
+  ## `item in a`.
+  ##   ```nim
+  ##   var a = @[1, 3, 5]
+  ##   assert a.contains(5)
+  ##   assert 3 in a
+  ##   assert 99 notin a
+  ##   ```
   return find(a, item) >= 0
 
-proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} = 
-  ## returns the last item of `s` and decreases ``s.len`` by one. This treats
+proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} =
+  ## Returns the last item of `s` and decreases `s.len` by one. This treats
   ## `s` as a stack and implements the common *pop* operation.
+  ##
+  ## Raises `IndexDefect` if `s` is empty.
+  runnableExamples:
+    var a = @[1, 3, 5, 7]
+    let b = pop(a)
+    assert b == 7
+    assert a == @[1, 3, 5]
+
   var L = s.len-1
-  result = s[L]
-  setLen(s, L)
+  when defined(nimV2):
+    result = move s[L]
+    shrink(s, L)
+  else:
+    result = s[L]
+    setLen(s, L)
+
+proc `==`*[T: tuple|object](x, y: T): bool =
+  ## Generic `==` operator for tuples that is lifted from the components.
+  ## of `x` and `y`.
+  for a, b in fields(x, y):
+    if a != b: return false
+  return true
+
+proc `<=`*[T: tuple](x, y: T): bool =
+  ## Generic lexicographic `<=` operator for tuples that is lifted from the
+  ## components of `x` and `y`. This implementation uses `cmp`.
+  for a, b in fields(x, y):
+    var c = cmp(a, b)
+    if c < 0: return true
+    if c > 0: return false
+  return true
+
+proc `<`*[T: tuple](x, y: T): bool =
+  ## Generic lexicographic `<` operator for tuples that is lifted from the
+  ## components of `x` and `y`. This implementation uses `cmp`.
+  for a, b in fields(x, y):
+    var c = cmp(a, b)
+    if c < 0: return true
+    if c > 0: return false
+  return false
+
+
+include "system/gc_interface"
+
+# we have to compute this here before turning it off in except.nim anyway ...
+const NimStackTrace = compileOption("stacktrace")
+
+import system/coro_detection
+
+{.push checks: off.}
+# obviously we cannot generate checking operations here :-)
+# because it would yield into an endless recursion
+# however, stack-traces are available for most parts
+# of the code
 
-proc each*[T, S](data: openArray[T], op: proc (x: T): S): seq[S] {.
-    noSideEffect.} = 
-  ## The well-known ``map`` operation from functional programming. Applies
-  ## `op` to every item in `data` and returns the result as a sequence.
-  newSeq(result, data.len)
-  for i in 0..data.len-1: result[i] = op(data[i])
+when notJSnotNims:
+  var
+    globalRaiseHook*: proc (e: ref Exception): bool {.nimcall, benign.}
+      ## With this hook you can influence exception handling on a global level.
+      ## If not nil, every 'raise' statement ends up calling this hook.
+      ##
+      ## .. warning:: Ordinary application code should never set this hook! You better know what you do when setting this.
+      ##
+      ## If `globalRaiseHook` returns false, the exception is caught and does
+      ## not propagate further through the call stack.
 
+    localRaiseHook* {.threadvar.}: proc (e: ref Exception): bool {.nimcall, benign.}
+      ## With this hook you can influence exception handling on a
+      ## thread local level.
+      ## If not nil, every 'raise' statement ends up calling this hook.
+      ##
+      ## .. warning:: Ordinary application code should never set this hook! You better know what you do when setting this.
+      ##
+      ## If `localRaiseHook` returns false, the exception
+      ## is caught and does not propagate further through the call stack.
 
-# ----------------- FPU ------------------------------------------------------
+    outOfMemHook*: proc () {.nimcall, tags: [], benign, raises: [].}
+      ## Set this variable to provide a procedure that should be called
+      ## in case of an `out of memory`:idx: event. The standard handler
+      ## writes an error message and terminates the program.
+      ##
+      ## `outOfMemHook` can be used to raise an exception in case of OOM like so:
+      ##
+      ##   ```nim
+      ##   var gOutOfMem: ref EOutOfMemory
+      ##   new(gOutOfMem) # need to be allocated *before* OOM really happened!
+      ##   gOutOfMem.msg = "out of memory"
+      ##
+      ##   proc handleOOM() =
+      ##     raise gOutOfMem
+      ##
+      ##   system.outOfMemHook = handleOOM
+      ##   ```
+      ##
+      ## If the handler does not raise an exception, ordinary control flow
+      ## continues and the program is terminated.
+    unhandledExceptionHook*: proc (e: ref Exception) {.nimcall, tags: [], benign, raises: [].}
+      ## Set this variable to provide a procedure that should be called
+      ## in case of an `unhandle exception` event. The standard handler
+      ## writes an error message and terminates the program, except when
+      ## using `--os:any`
+
+when defined(js) or defined(nimdoc):
+  proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
+    ## Appends `y` to `x` in place.
+    runnableExamples:
+      var tmp = ""
+      tmp.add(cstring("ab"))
+      tmp.add(cstring("cd"))
+      doAssert tmp == "abcd"
+    {.emit: """
+      if (`x` === null) { `x` = []; }
+      var off = `x`.length;
+      `x`.length += `y`.length;
+      for (var i = 0; i < `y`.length; ++i) {
+        `x`[off+i] = `y`.charCodeAt(i);
+      }
+    """.}
+  proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".} =
+    ## Appends `y` to `x` in place.
+    ## Only implemented for JS backend.
+    runnableExamples:
+      when defined(js):
+        var tmp: cstring = ""
+        tmp.add(cstring("ab"))
+        tmp.add(cstring("cd"))
+        doAssert tmp == cstring("abcd")
+
+elif hasAlloc:
+  {.push stackTrace: off, profiler: off.}
+  proc add*(x: var string, y: cstring) =
+    var i = 0
+    if y != nil:
+      while y[i] != '\0':
+        add(x, y[i])
+        inc(i)
+  {.pop.}
 
-#proc disableFPUExceptions*()
-# disables all floating point unit exceptions
+proc echo*(x: varargs[typed, `$`]) {.magic: "Echo", benign, sideEffect.}
+  ## Writes and flushes the parameters to the standard output.
+  ##
+  ## Special built-in that takes a variable number of arguments. Each argument
+  ## is converted to a string via `$`, so it works for user-defined
+  ## types that have an overloaded `$` operator.
+  ## It is roughly equivalent to `writeLine(stdout, x); flushFile(stdout)`, but
+  ## available for the JavaScript target too.
+  ##
+  ## Unlike other IO operations this is guaranteed to be thread-safe as
+  ## `echo` is very often used for debugging convenience. If you want to use
+  ## `echo` inside a `proc without side effects
+  ## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho
+  ## <#debugEcho,varargs[typed,]>`_ instead.
+
+proc debugEcho*(x: varargs[typed, `$`]) {.magic: "Echo", noSideEffect,
+                                          tags: [], raises: [].}
+  ## Same as `echo <#echo,varargs[typed,]>`_, but as a special semantic rule,
+  ## `debugEcho` pretends to be free of side effects, so that it can be used
+  ## for debugging routines marked as `noSideEffect
+  ## <manual.html#pragmas-nosideeffect-pragma>`_.
+
+when hostOS == "standalone" and defined(nogc):
+  proc nimToCStringConv(s: NimString): cstring {.compilerproc, inline.} =
+    if s == nil or s.len == 0: result = cstring""
+    else: result = cast[cstring](addr s.data)
+
+proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo", benign.}
+  ## Get type information for `x`.
+  ##
+  ## Ordinary code should not use this, but the `typeinfo module
+  ## <typeinfo.html>`_ instead.
 
-#proc enableFPUExceptions*()
-# enables all floating point unit exceptions
 
-# ----------------- GC interface ---------------------------------------------
+when not defined(js):
 
-proc GC_disable*()
-  ## disables the GC. If called n-times, n calls to `GC_enable` are needed to
-  ## reactivate the GC. Note that in most circumstances one should only disable
-  ## the mark and sweep phase with `GC_disableMarkAndSweep`.
+  proc likelyProc(val: bool): bool {.importc: "NIM_LIKELY", nodecl, noSideEffect.}
+  proc unlikelyProc(val: bool): bool {.importc: "NIM_UNLIKELY", nodecl, noSideEffect.}
 
-proc GC_enable*()
-  ## enables the GC again.
+template likely*(val: bool): bool =
+  ## Hints the optimizer that `val` is likely going to be true.
+  ##
+  ## You can use this template to decorate a branch condition. On certain
+  ## platforms this can help the processor predict better which branch is
+  ## going to be run. Example:
+  ##   ```nim
+  ##   for value in inputValues:
+  ##     if likely(value <= 100):
+  ##       process(value)
+  ##     else:
+  ##       echo "Value too big!"
+  ##   ```
+  ##
+  ## On backends without branch prediction (JS and the nimscript VM), this
+  ## template will not affect code execution.
+  when nimvm:
+    val
+  else:
+    when defined(js):
+      val
+    else:
+      likelyProc(val)
 
-proc GC_fullCollect*()
-  ## forces a full garbage collection pass.
-  ## Ordinary code does not need to call this (and should not).
+template unlikely*(val: bool): bool =
+  ## Hints the optimizer that `val` is likely going to be false.
+  ##
+  ## You can use this proc to decorate a branch condition. On certain
+  ## platforms this can help the processor predict better which branch is
+  ## going to be run. Example:
+  ##   ```nim
+  ##   for value in inputValues:
+  ##     if unlikely(value > 100):
+  ##       echo "Value too big!"
+  ##     else:
+  ##       process(value)
+  ##   ```
+  ##
+  ## On backends without branch prediction (JS and the nimscript VM), this
+  ## template will not affect code execution.
+  when nimvm:
+    val
+  else:
+    when defined(js):
+      val
+    else:
+      unlikelyProc(val)
 
-type
-  TGC_Strategy* = enum ## the strategy the GC should use for the application
-    gcThroughput,      ## optimize for throughput
-    gcResponsiveness,  ## optimize for responsiveness (default)
-    gcOptimizeTime,    ## optimize for speed
-    gcOptimizeSpace    ## optimize for memory footprint
-
-proc GC_setStrategy*(strategy: TGC_Strategy)
-  ## tells the GC the desired strategy for the application.
-
-proc GC_enableMarkAndSweep*()
-proc GC_disableMarkAndSweep*()
-  ## the current implementation uses a reference counting garbage collector
-  ## with a seldomly run mark and sweep phase to free cycles. The mark and
-  ## sweep phase may take a long time and is not needed if the application
-  ## does not create cycles. Thus the mark and sweep phase can be deactivated
-  ## and activated separately from the rest of the GC.
-
-proc GC_getStatistics*(): string
-  ## returns an informative string about the GC's activity. This may be useful
-  ## for tweaking.
-  
-proc GC_ref*[T](x: ref T) {.magic: "GCref".}
-proc GC_ref*[T](x: seq[T]) {.magic: "GCref".}
-proc GC_ref*(x: string) {.magic: "GCref".}
-  ## marks the object `x` as referenced, so that it will not be freed until
-  ## it is unmarked via `GC_unref`. If called n-times for the same object `x`,
-  ## n calls to `GC_unref` are needed to unmark `x`. 
-  
-proc GC_unref*[T](x: ref T) {.magic: "GCunref".}
-proc GC_unref*[T](x: seq[T]) {.magic: "GCunref".}
-proc GC_unref*(x: string) {.magic: "GCunref".}
-  ## see the documentation of `GC_ref`.
-
-template accumulateResult*(iter: expr) =
-  ## helps to convert an iterator to a proc.
-  result = @[]
-  for x in iter: add(result, x)
-
-{.push checks: off, line_dir: off, debugger: off.}  
-# obviously we cannot generate checking operations here :-)
-# because it would yield into an endless recursion
-# however, stack-traces are available for most parts
-# of the code
+import system/dollars
+export dollars
+
+when defined(nimAuditDelete):
+  {.pragma: auditDelete, deprecated: "review this call for out of bounds behavior".}
+else:
+  {.pragma: auditDelete.}
 
-proc echo*[Ty](x: openarray[Ty]) {.magic: "Echo".}
-  ## equivalent to ``writeln(stdout, x); flush(stdout)``. BUT: This is
-  ## available for the ECMAScript target too!
+proc delete*[T](x: var seq[T], i: Natural) {.noSideEffect, systemRaisesDefect, auditDelete.} =
+  ## Deletes the item at index `i` by moving all `x[i+1..^1]` items by one position.
+  ##
+  ## This is an `O(n)` operation.
+  ##
+  ## See also:
+  ## * `del <#del,seq[T],Natural>`_ for O(1) operation
+  ##
+  runnableExamples:
+    var s = @[1, 2, 3, 4, 5]
+    s.delete(2)
+    doAssert s == @[1, 2, 4, 5]
+
+  when not defined(nimAuditDelete):
+    if i > high(x):
+      # xxx this should call `raiseIndexError2(i, high(x))` after some refactoring
+      raise (ref IndexDefect)(msg: "index out of bounds: '" & $i & "' < '" & $x.len & "' failed")
+
+  template defaultImpl =
+    let xl = x.len
+    for j in i.int..xl-2: movingCopy(x[j], x[j+1])
+    setLen(x, xl-1)
+
+  when nimvm:
+    defaultImpl()
+  else:
+    when defined(js):
+      {.emit: "`x`.splice(`i`, 1);".}
+    else:
+      defaultImpl()
 
-template newException*(exceptn, message: expr): expr = 
-  ## creates an exception object of type "exceptn" and sets its ``msg`` field
-  ## to `message`. Returns the new exception object. 
-  block: # open a new scope
-    var
-      e: ref exceptn
-    new(e)
-    e.msg = message
-    e
 
 const
-  QuitSuccess* = 0
-    ## is the value that should be passed to ``quit`` to indicate
-    ## success.
+  NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch
+    ## is the version of Nim as a string.
+
+when not defined(js):
+  {.push stackTrace: off, profiler: off.}
+
+  when hasAlloc:
+    when not defined(gcRegions) and not usesDestructors:
+      proc initGC() {.gcsafe, raises: [].}
+
+    proc initStackBottom() {.inline, compilerproc.} =
+      # WARNING: This is very fragile! An array size of 8 does not work on my
+      # Linux 64bit system. -- That's because the stack direction is the other
+      # way around.
+      when declared(nimGC_setStackBottom):
+        var locals {.volatile, noinit.}: pointer
+        locals = addr(locals)
+        nimGC_setStackBottom(locals)
+
+    proc initStackBottomWith(locals: pointer) {.inline, compilerproc.} =
+      # We need to keep initStackBottom around for now to avoid
+      # bootstrapping problems.
+      when declared(nimGC_setStackBottom):
+        nimGC_setStackBottom(locals)
+
+    when not usesDestructors:
+      {.push profiler: off.}
+      var
+        strDesc = TNimType(size: sizeof(string), kind: tyString, flags: {ntfAcyclic})
+      {.pop.}
 
-  QuitFailure* = 1
-    ## is the value that should be passed to ``quit`` to indicate
-    ## failure.
+  {.pop.}
 
-proc quit*(errorcode: int = QuitSuccess) {.
-  magic: "Exit", importc: "exit", noDecl, noReturn.}
-  ## stops the program immediately; before stopping the program the
-  ## "quit procedures" are called in the opposite order they were added
-  ## with ``addQuitProc``. ``quit`` never returns and ignores any
-  ## exception that may have been raised by the quit procedures.
-  ## It does *not* call the garbage collector to free all the memory,
-  ## unless a quit procedure calls ``GC_collect``.
 
-when not defined(EcmaScript) and not defined(NimrodVM): 
-  proc quit*(errormsg: string) {.noReturn.}
-    ## a shorthand for ``echo(errormsg); quit(quitFailure)``.
+when not defined(js):
+  # ugly hack, see the accompanying .pop for
+  # the mysterious error message
+  {.push stackTrace: off, profiler: off.}
+
+when notJSnotNims:
+  proc zeroMem(p: pointer, size: Natural) =
+    nimZeroMem(p, size)
+    when declared(memTrackerOp):
+      memTrackerOp("zeroMem", p, size)
+  proc copyMem(dest, source: pointer, size: Natural) =
+    nimCopyMem(dest, source, size)
+    when declared(memTrackerOp):
+      memTrackerOp("copyMem", dest, size)
+  proc moveMem(dest, source: pointer, size: Natural) =
+    c_memmove(dest, source, csize_t(size))
+    when declared(memTrackerOp):
+      memTrackerOp("moveMem", dest, size)
+  proc equalMem(a, b: pointer, size: Natural): bool =
+    nimCmpMem(a, b, size) == 0
+  proc cmpMem(a, b: pointer, size: Natural): int =
+    nimCmpMem(a, b, size).int
+
+when not defined(js) or defined(nimscript):
+  # nimscript can be defined if config file for js compilation
+  proc cmp(x, y: string): int =
+    when nimvm:
+      if x < y: result = -1
+      elif x > y: result = 1
+      else: result = 0
+    else:
+      when not defined(nimscript): # avoid semantic checking
+        let minlen = min(x.len, y.len)
+        result = int(nimCmpMem(x.cstring, y.cstring, cast[csize_t](minlen)))
+        if result == 0:
+          result = x.len - y.len
+
+  when declared(newSeq):
+    proc cstringArrayToSeq*(a: cstringArray, len: Natural): seq[string] =
+      ## Converts a `cstringArray` to a `seq[string]`. `a` is supposed to be
+      ## of length `len`.
+      if a == nil: return @[]
+      newSeq(result, len)
+      for i in 0..len-1: result[i] = $a[i]
+
+    proc cstringArrayToSeq*(a: cstringArray): seq[string] =
+      ## Converts a `cstringArray` to a `seq[string]`. `a` is supposed to be
+      ## terminated by `nil`.
+      if a == nil: return @[]
+      var L = 0
+      while a[L] != nil: inc(L)
+      result = cstringArrayToSeq(a, L)
+
+
+when not defined(js) and declared(alloc0) and declared(dealloc):
+  proc allocCStringArray*(a: openArray[string]): cstringArray =
+    ## Creates a NULL terminated cstringArray from `a`. The result has to
+    ## be freed with `deallocCStringArray` after it's not needed anymore.
+    result = cast[cstringArray](alloc0((a.len+1) * sizeof(cstring)))
+
+    let x = cast[ptr UncheckedArray[string]](a)
+    for i in 0 .. a.high:
+      result[i] = cast[cstring](alloc0(x[i].len+1))
+      copyMem(result[i], addr(x[i][0]), x[i].len)
+
+  proc deallocCStringArray*(a: cstringArray) =
+    ## Frees a NULL terminated cstringArray.
+    var i = 0
+    while a[i] != nil:
+      dealloc(a[i])
+      inc(i)
+    dealloc(a)
 
-when not defined(EcmaScript) and not defined(NimrodVM):
+when notJSnotNims and not gotoBasedExceptions:
+  type
+    PSafePoint = ptr TSafePoint
+    TSafePoint {.compilerproc, final.} = object
+      prev: PSafePoint # points to next safe point ON THE STACK
+      status: int
+      context: C_JmpBuf
+    SafePoint = TSafePoint
+
+when not defined(js):
+  when declared(initAllocator):
+    initAllocator()
+  when hasThreadSupport:
+    when hostOS != "standalone":
+      include system/threadimpl
+      when not defined(nimPreviewSlimSystem):
+        import std/typedthreads
+        export typedthreads
+
+  elif not defined(nogc) and not defined(nimscript):
+    when not defined(useNimRtl) and not defined(createNimRtl): initStackBottom()
+    when declared(initGC): initGC()
+
+when notJSnotNims:
+  proc setControlCHook*(hook: proc () {.noconv.})
+    ## Allows you to override the behaviour of your application when CTRL+C
+    ## is pressed. Only one such hook is supported.
+    ## Example:
+    ##
+    ##   ```nim
+    ##   proc ctrlc() {.noconv.} =
+    ##     echo "Ctrl+C fired!"
+    ##     # do clean up stuff
+    ##     quit()
+    ##
+    ##   setControlCHook(ctrlc)
+    ##   ```
 
-  proc initGC()
+  when not defined(noSignalHandler) and not defined(useNimRtl):
+    proc unsetControlCHook*()
+      ## Reverts a call to setControlCHook.
 
-  var
-    strDesc: TNimType
+  when hostOS != "standalone":
+    proc getStackTrace*(): string {.gcsafe.}
+      ## Gets the current stack trace. This only works for debug builds.
 
-  strDesc.size = sizeof(string)
-  strDesc.kind = tyString
-  strDesc.flags = {ntfAcyclic}
-  initGC() # BUGFIX: need to be called here!
+    proc getStackTrace*(e: ref Exception): string {.gcsafe.}
+      ## Gets the stack trace associated with `e`, which is the stack that
+      ## lead to the `raise` statement. This only works for debug builds.
 
-  {.push stack_trace: off.}
+  {.push stackTrace: off, profiler: off.}
+  when defined(memtracker):
+    include "system/memtracker"
 
-  include "system/ansi_c"
+  when hostOS == "standalone":
+    include "system/embedded"
+  else:
+    include "system/excpt"
+  include "system/chcks"
 
-  proc cmp(x, y: string): int =
-    return int(c_strcmp(x, y))
+  # we cannot compile this with stack tracing on
+  # as it would recurse endlessly!
+  include "system/integerops"
+  {.pop.}
 
-  const pccHack = if defined(pcc): "_" else: "" # Hack for PCC
-  when defined(windows):
-    # work-around C's sucking abstraction:
-    # BUGFIX: stdin and stdout should be binary files!
-    proc setmode(handle, mode: int) {.importc: pccHack & "setmode",
-                                      header: "<io.h>".}
-    proc fileno(f: C_TextFileStar): int {.importc: pccHack & "fileno",
-                                          header: "<fcntl.h>".}
-    var
-      O_BINARY {.importc: pccHack & "O_BINARY", nodecl.}: int
 
-    # we use binary mode in Windows:
-    setmode(fileno(c_stdin), O_BINARY)
-    setmode(fileno(c_stdout), O_BINARY)
+when not defined(js):
+  # this is a hack: without this when statement, you would get:
+  # Error: system module needs: nimGCvisit
+  {.pop.} # stackTrace: off, profiler: off
 
-  when defined(endb):
-    proc endbStep()
 
-  # ----------------- IO Part --------------------------------------------------
 
-  type
-    CFile {.importc: "FILE", nodecl, final.} = object  # empty record for
-                                                       # data hiding
-    TFile* = ptr CFile ## The type representing a file handle.
-
-    TFileMode* = enum           ## The file mode when opening a file.
-      fmRead,                   ## Open the file for read access only.
-      fmWrite,                  ## Open the file for write access only.
-      fmReadWrite,              ## Open the file for read and write access.
-                                ## If the file does not exist, it will be
-                                ## created.
-      fmReadWriteExisting,      ## Open the file for read and write access.
-                                ## If the file does not exist, it will not be
-                                ## created.
-      fmAppend                  ## Open the file for writing only; append data
-                                ## at the end.
-
-    TFileHandle* = cint ## type that represents an OS file handle; this is
-                        ## useful for low-level file access
-
-  # text file handling:
-  var
-    stdin* {.importc: "stdin", noDecl.}: TFile   ## The standard input stream.
-    stdout* {.importc: "stdout", noDecl.}: TFile ## The standard output stream.
-    stderr* {.importc: "stderr", noDecl.}: TFile
-      ## The standard error stream.
-      ##
-      ## Note: In my opinion, this should not be used -- the concept of a
-      ## separate error stream is a design flaw of UNIX. A seperate *message
-      ## stream* is a good idea, but since it is named ``stderr`` there are few
-      ## programs out there that distinguish properly between ``stdout`` and
-      ## ``stderr``. So, that's what you get if you don't name your variables
-      ## appropriately. It also annoys people if redirection via ``>output.txt``
-      ## does not work because the program writes to ``stderr``.
-
-  proc OpenFile*(f: var TFile, filename: string,
-                 mode: TFileMode = fmRead, 
-                 bufSize: int = -1): Bool {.deprecated.}
-    ## **Deprecated since version 0.8.0**: Use `open` instead.
-
-  proc OpenFile*(f: var TFile, filehandle: TFileHandle,
-                 mode: TFileMode = fmRead): Bool {.deprecated.}
-    ## **Deprecated since version 0.8.0**: Use `open` instead.
-
-  proc Open*(f: var TFile, filename: string,
-             mode: TFileMode = fmRead, bufSize: int = -1): Bool
-    ## Opens a file named `filename` with given `mode`.
-    ##
-    ## Default mode is readonly. Returns true iff the file could be opened.
-    ## This throws no exception if the file could not be opened. The reason is
-    ## that the programmer needs to provide an appropriate error message anyway
-    ## (yes, even in scripts).
-
-  proc Open*(f: var TFile, filehandle: TFileHandle,
-             mode: TFileMode = fmRead): Bool
-    ## Creates a ``TFile`` from a `filehandle` with given `mode`.
-    ##
-    ## Default mode is readonly. Returns true iff the file could be opened.
-
-  proc CloseFile*(f: TFile) {.importc: "fclose", nodecl, deprecated.}
-    ## Closes the file.
-    ## **Deprecated since version 0.8.0**: Use `close` instead.
-
-  proc Close*(f: TFile) {.importc: "fclose", nodecl.}
-    ## Closes the file.
-
-  proc EndOfFile*(f: TFile): Bool
-    ## Returns true iff `f` is at the end.
-  proc readChar*(f: TFile): char {.importc: "fgetc", nodecl.}
-    ## Reads a single character from the stream `f`. If the stream
-    ## has no more characters, `EEndOfFile` is raised.
-  proc FlushFile*(f: TFile) {.importc: "fflush", noDecl.}
-    ## Flushes `f`'s buffer.
-
-  proc readFile*(filename: string): string
-    ## Opens a file name `filename` for reading. Then reads the
-    ## file's content completely into a string and
-    ## closes the file afterwards. Returns the string. Returns nil if there was
-    ## an error. Does not throw an IO exception.
-
-  proc write*(f: TFile, r: float)
-  proc write*(f: TFile, i: int)
-  proc write*(f: TFile, s: string)
-  proc write*(f: TFile, b: Bool)
-  proc write*(f: TFile, c: char)
-  proc write*(f: TFile, c: cstring)
-  proc write*(f: TFile, a: openArray[string])
-    ## Writes a value to the file `f`. May throw an IO exception.
-
-  proc readLine*(f: TFile): string
-    ## reads a line of text from the file `f`. May throw an IO exception.
-    ## Reading from an empty file buffer, does not throw an exception, but
-    ## returns nil. A line of text may be delimited by ``CR``, ``LF`` or
-    ## ``CRLF``. The newline character(s) are not part of the returned string.
-
-  proc writeln*[Ty](f: TFile, x: Ty) {.inline.}
-    ## writes a value `x` to `f` and then writes "\n".
-    ## May throw an IO exception.
-
-  proc writeln*[Ty](f: TFile, x: openArray[Ty]) {.inline.}
-    ## writes a value `x` to `f` and then writes "\n".
-    ## May throw an IO exception.
-
-  proc getFileSize*(f: TFile): int64
-    ## retrieves the file size (in bytes) of `f`.
-
-  proc ReadBytes*(f: TFile, a: var openarray[byte], start, len: int): int
-    ## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns
-    ## the actual number of bytes that have been read which may be less than
-    ## `len` (if not as many bytes are remaining), but not greater.
-
-  proc ReadChars*(f: TFile, a: var openarray[char], start, len: int): int
-    ## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns
-    ## the actual number of bytes that have been read which may be less than
-    ## `len` (if not as many bytes are remaining), but not greater.
-
-  proc readBuffer*(f: TFile, buffer: pointer, len: int): int
-    ## reads `len` bytes into the buffer pointed to by `buffer`. Returns
-    ## the actual number of bytes that have been read which may be less than
-    ## `len` (if not as many bytes are remaining), but not greater.
-
-  proc writeBytes*(f: TFile, a: openarray[byte], start, len: int): int
-    ## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns
-    ## the number of actual written bytes, which may be less than `len` in case
-    ## of an error.
-
-  proc writeChars*(f: tFile, a: openarray[char], start, len: int): int
-    ## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns
-    ## the number of actual written bytes, which may be less than `len` in case
-    ## of an error.
-
-  proc writeBuffer*(f: TFile, buffer: pointer, len: int): int
-    ## writes the bytes of buffer pointed to by the parameter `buffer` to the
-    ## file `f`. Returns the number of actual written bytes, which may be less
-    ## than `len` in case of an error.
-
-  proc setFilePos*(f: TFile, pos: int64)
-    ## sets the position of the file pointer that is used for read/write
-    ## operations. The file's first byte has the index zero.
-
-  proc getFilePos*(f: TFile): int64
-    ## retrieves the current position of the file pointer that is used to
-    ## read from the file `f`. The file's first byte has the index zero.
-
-  include "system/sysio"
-
-  iterator lines*(filename: string): string =
-    ## Iterate over any line in the file named `filename`.
-    ## If the file does not exist `EIO` is raised.
-    var
-      f: TFile
-    if not open(f, filename):
-      raise newException(EIO, "cannot open: " & filename)
-    var res = ""
-    while not endOfFile(f):
-      rawReadLine(f, res)
-      yield res
-    Close(f)
-
-  iterator lines*(f: TFile): string =
-    ## Iterate over any line in the file `f`.
-    var res = ""
-    while not endOfFile(f):
-      rawReadLine(f, res)
-      yield res
-
-  proc fileHandle*(f: TFile): TFileHandle {.importc: "fileno",
-                                            header: "<stdio.h>"}
-    ## returns the OS file handle of the file ``f``. This is only useful for
-    ## platform specific programming.
-
-  proc quit(errormsg: string) =
-    echo(errormsg)
-    quit(quitFailure)
-
-  proc cstringArrayToSeq*(a: cstringArray, len: int): seq[string] =
-    ## converts a ``cstringArray`` to a ``seq[string]``. `a` is supposed to be
-    ## of length ``len``.
-    newSeq(result, len)
-    for i in 0..len-1: result[i] = $a[i]
-
-  proc cstringArrayToSeq*(a: cstringArray): seq[string] =
-    ## converts a ``cstringArray`` to a ``seq[string]``. `a` is supposed to be
-    ## terminated by ``nil``.
-    var L = 0
-    while a[L] != nil: inc(L)
-    result = cstringArrayToSeq(a, L)
-
-  # ----------------------------------------------------------------------------
-
-  include "system/excpt"
-  # we cannot compile this with stack tracing on
-  # as it would recurse endlessly!
-  include "system/arithm"
-  {.pop.} # stack trace
-  include "system/dyncalls"
+when notJSnotNims:
+  when hostOS != "standalone" and hostOS != "any":
+    type
+      LibHandle = pointer       # private type
+      ProcAddr = pointer        # library loading and loading of procs:
+
+    proc nimLoadLibrary(path: string): LibHandle {.compilerproc, hcrInline, nonReloadable.}
+    proc nimUnloadLibrary(lib: LibHandle) {.compilerproc, hcrInline, nonReloadable.}
+    proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {.compilerproc, hcrInline, nonReloadable.}
+
+    proc nimLoadLibraryError(path: string) {.compilerproc, hcrInline, nonReloadable.}
+
+    include "system/dyncalls"
+
+  import system/countbits_impl
   include "system/sets"
 
-  const
-    GenericSeqSize = (2 * sizeof(int))
-    
-  proc reprAny(p: pointer, typ: PNimType): string {.compilerproc.}
+  when defined(gogc):
+    const GenericSeqSize = (3 * sizeof(int))
+  else:
+    const GenericSeqSize = (2 * sizeof(int))
 
-  proc getDiscriminant(aa: Pointer, n: ptr TNimNode): int =
-    assert(n.kind == nkCase)
-    var d: int
-    var a = cast[TAddress](aa)
+  proc getDiscriminant(aa: pointer, n: ptr TNimNode): uint =
+    sysAssert(n.kind == nkCase, "getDiscriminant: node != nkCase")
+    var d: uint
+    var a = cast[uint](aa)
     case n.typ.size
-    of 1: d = ze(cast[ptr int8](a +% n.offset)^)
-    of 2: d = ze(cast[ptr int16](a +% n.offset)^)
-    of 4: d = int(cast[ptr int32](a +% n.offset)^)
-    else: assert(false)
+    of 1: d = uint(cast[ptr uint8](a + uint(n.offset))[])
+    of 2: d = uint(cast[ptr uint16](a + uint(n.offset))[])
+    of 4: d = uint(cast[ptr uint32](a + uint(n.offset))[])
+    of 8: d = uint(cast[ptr uint64](a + uint(n.offset))[])
+    else:
+      d = 0'u
+      sysAssert(false, "getDiscriminant: invalid n.typ.size")
     return d
 
-  proc selectBranch(aa: Pointer, n: ptr TNimNode): ptr TNimNode =
+  proc selectBranch(aa: pointer, n: ptr TNimNode): ptr TNimNode =
     var discr = getDiscriminant(aa, n)
-    if discr <% n.len:
+    if discr < cast[uint](n.len):
       result = n.sons[discr]
       if result == nil: result = n.sons[n.len]
-      # n.sons[n.len] contains the ``else`` part (but may be nil)
+      # n.sons[n.len] contains the `else` part (but may be nil)
     else:
       result = n.sons[n.len]
 
-  include "system/mm"
-  include "system/sysstr"
+when notJSnotNims and hasAlloc:
+  {.push profiler: off.}
+  include "system/mmdisp"
+  {.pop.}
+  {.push stackTrace: off, profiler: off.}
+  when not defined(nimSeqsV2):
+    include "system/sysstr"
+  {.pop.}
+
+  include "system/strmantle"
   include "system/assign"
-  include "system/repr"
 
-  # we have to implement it here after gentostr for the cstrToNimStrDummy proc
-  proc getCurrentExceptionMsg(): string =
-    if excHandler == nil: return ""
-    return $excHandler.exc.msg
+  when not defined(nimV2):
+    include "system/repr"
+
+when notJSnotNims and hasThreadSupport and hostOS != "standalone":
+  when not defined(nimPreviewSlimSystem):
+    include "system/channels_builtin"
+
 
-  {.push stack_trace: off.}
-  when defined(endb):
-    include "system/debugger"
+when notJSnotNims and hostOS != "standalone":
+  proc getCurrentException*(): ref Exception {.compilerRtl, inl, benign.} =
+    ## Retrieves the current exception; if there is none, `nil` is returned.
+    result = currException
 
-  when defined(profiler):
+  proc nimBorrowCurrentException(): ref Exception {.compilerRtl, inl, benign, nodestroy.} =
+    # .nodestroy here so that we do not produce a write barrier as the
+    # C codegen only uses it in a borrowed way:
+    result = currException
+
+  proc getCurrentExceptionMsg*(): string {.inline, benign.} =
+    ## Retrieves the error message that was attached to the current
+    ## exception; if there is none, `""` is returned.
+    return if currException == nil: "" else: currException.msg
+
+  proc setCurrentException*(exc: ref Exception) {.inline, benign.} =
+    ## Sets the current exception.
+    ##
+    ## .. warning:: Only use this if you know what you are doing.
+    currException = exc
+elif defined(nimscript):
+  proc getCurrentException*(): ref Exception {.compilerRtl.} = discard
+
+when notJSnotNims:
+  {.push stackTrace: off, profiler: off.}
+  when (defined(profiler) or defined(memProfiler)):
     include "system/profiler"
-  {.pop.} # stacktrace
-
-elif defined(ecmaScript):
-  include "system/ecmasys"
-elif defined(NimrodVM):
-  # Stubs for the GC interface:
-  proc GC_disable() = nil
-  proc GC_enable() = nil
-  proc GC_fullCollect() = nil
-  proc GC_setStrategy(strategy: TGC_Strategy) = nil
-  proc GC_enableMarkAndSweep() = nil
-  proc GC_disableMarkAndSweep() = nil
-  proc GC_getStatistics(): string = return ""
-  
-  proc getOccupiedMem(): int = return -1
-  proc getFreeMem(): int = return -1
-  proc getTotalMem(): int = return -1
-  
-  proc cmp(x, y: string): int =
-    if x == y: return 0
-    if x < y: return -1
-    return 1
-    
-  proc dealloc(p: pointer) = nil
-  proc alloc(size: int): pointer = nil
-  proc alloc0(size: int): pointer = nil
-  proc realloc(p: Pointer, newsize: int): pointer = nil
-
-{.pop.} # checks
-{.pop.} # hints
+  {.pop.}
+
+  proc rawProc*[T: proc {.closure.} | iterator {.closure.}](x: T): pointer {.noSideEffect, inline.} =
+    ## Retrieves the raw proc pointer of the closure `x`. This is
+    ## useful for interfacing closures with C/C++, hash computations, etc.
+    ## If `rawEnv(x)` returns `nil`, the proc which the result points to
+    ## takes as many parameters as `x`, but with `{.nimcall.}` as its calling
+    ## convention instead of `{.closure.}`, otherwise it takes one more parameter
+    ## which is a `pointer`, and it still has `{.nimcall.}` as its calling convention.
+    ## To invoke the resulted proc, what this returns has to be casted into a `proc`,
+    ## not a `ptr proc`, and, in a case where `rawEnv(x)` returns non-`nil`,
+    ## the last and additional argument has to be the result of `rawEnv(x)`.
+    ## This is not available for the JS target.
+    #[
+    The conversion from function pointer to `void*` is a tricky topic, but this
+    should work at least for c++ >= c++11, e.g. for `dlsym` support.
+    refs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57869,
+    https://stackoverflow.com/questions/14125474/casts-between-pointer-to-function-and-pointer-to-object-in-c-and-c
+    ]#
+    runnableExamples:
+      proc makeClosure(x: int): (proc(y: int): int) =
+        var n = x
+        result = (
+          proc(y: int): int =
+            n += y
+            return n
+        )
+
+      var
+        c1 = makeClosure(10)
+        e = c1.rawEnv()
+        p = c1.rawProc()
+
+      if e.isNil():
+        let c2 = cast[proc(y: int): int {.nimcall.}](p)
+        echo c2(2)
+      else:
+        let c3 = cast[proc(y: int; env: pointer): int {.nimcall.}](p)
+        echo c3(3, e)
+
+    {.emit: """
+    `result` = (void*)`x`.ClP_0;
+    """.}
+
+  proc rawEnv*[T: proc {.closure.} | iterator {.closure.}](x: T): pointer {.noSideEffect, inline.} =
+    ## Retrieves the raw environment pointer of the closure `x`. See also `rawProc`.
+    ## This is not available for the JS target.
+    {.emit: """
+    `result` = `x`.ClE_0;
+    """.}
+
+proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magic: "Finished".} =
+  ## It can be used to determine if a first class iterator has finished.
+  when defined(js):
+    # TODO: mangle `:state`
+    {.emit: """
+    `result` = (`x`.ClE_0).HEX3Astate < 0;
+    """.}
+  else:
+    {.emit: """
+    `result` = ((NI*) `x`.ClE_0)[1] < 0;
+    """.}
+
+from std/private/digitsutils import addInt
+export addInt
+
+when defined(js) and not defined(nimscript):
+  # nimscript can be defined if config file for js compilation
+  include "system/jssys"
+  include "system/reprjs"
+
+
+when defined(nimNoQuit):
+  proc quit*(errorcode: int = QuitSuccess) = discard "ignoring quit"
+
+elif defined(nimdoc):
+  proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit", noreturn.}
+    ## Stops the program immediately with an exit code.
+    ##
+    ## Before stopping the program the "exit procedures" are called in the
+    ## opposite order they were added with `addExitProc <exitprocs.html#addExitProc,proc)>`_.
+    ##
+    ## The proc `quit(QuitSuccess)` is called implicitly when your nim
+    ## program finishes without incident for platforms where this is the
+    ## expected behavior. A raised unhandled exception is
+    ## equivalent to calling `quit(QuitFailure)`.
+    ##
+    ## Note that this is a *runtime* call and using `quit` inside a macro won't
+    ## have any compile time effect. If you need to stop the compiler inside a
+    ## macro, use the `error <manual.html#pragmas-error-pragma>`_ or `fatal
+    ## <manual.html#pragmas-fatal-pragma>`_ pragmas.
+    ##
+    ## .. warning:: `errorcode` gets saturated when it exceeds the valid range
+    ##    on the specific platform. On Posix, the valid range is `low(int8)..high(int8)`.
+    ##    On Windows, the valid range is `low(int32)..high(int32)`. For instance,
+    ##    `quit(int(0x100000000))` is equal to `quit(127)` on Linux.
+    ##
+    ## .. danger:: In almost all cases, in particular in library code, prefer
+    ##   alternatives, e.g. `raiseAssert` or raise a `Defect`.
+    ##   `quit` bypasses regular control flow in particular `defer`,
+    ##   `try`, `catch`, `finally` and `destructors`, and exceptions that may have been
+    ##   raised by an `addExitProc` proc, as well as cleanup code in other threads.
+    ##   It does *not* call the garbage collector to free all the memory,
+    ##   unless an `addExitProc` proc calls `GC_fullCollect <#GC_fullCollect>`_.
+
+elif defined(genode):
+  proc quit*(errorcode: int = QuitSuccess) {.inline, noreturn.} =
+    rawQuit(errorcode)
+
+elif defined(js) and defined(nodejs) and not defined(nimscript):
+  proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit",
+    importc: "process.exit", noreturn.}
+
+else:
+  proc quit*(errorcode: int = QuitSuccess) {.inline, noreturn.} =
+    when defined(posix): # posix uses low 8 bits
+      type ExitCodeRange = int8
+    else: # win32 uses low 32 bits
+      type ExitCodeRange = cint
+    when sizeof(errorcode) > sizeof(ExitCodeRange):
+      if errorcode < low(ExitCodeRange):
+        rawQuit(low(ExitCodeRange).cint)
+      elif errorcode > high(ExitCodeRange):
+        rawQuit(high(ExitCodeRange).cint)
+      else:
+        rawQuit(errorcode.cint)
+    else:
+      rawQuit(errorcode.cint)
+
+proc quit*(errormsg: string, errorcode = QuitFailure) {.noreturn.} =
+  ## A shorthand for `echo(errormsg); quit(errorcode)`.
+  when defined(nimscript) or defined(js) or (hostOS == "standalone"):
+    echo errormsg
+  else:
+    when nimvm:
+      echo errormsg
+    else:
+      cstderr.rawWrite(errormsg)
+      cstderr.rawWrite("\n")
+  quit(errorcode)
+
+{.pop.} # checks: off
+# {.pop.} # hints: off
+
+include "system/indices"
+
+proc `&=`*(x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
+  ## Appends in place to a string.
+  ##   ```nim
+  ##   var a = "abc"
+  ##   a &= "de" # a <- "abcde"
+  ##   ```
+
+template `&=`*(x, y: typed) =
+  ## Generic 'sink' operator for Nim.
+  ##
+  ## If not specialized further, an alias for `add`.
+  add(x, y)
+
+when compileOption("rangechecks"):
+  template rangeCheck*(cond) =
+    ## Helper for performing user-defined range checks.
+    ## Such checks will be performed only when the `rangechecks`
+    ## compile-time option is enabled.
+    if not cond: sysFatal(RangeDefect, "range check failed")
+else:
+  template rangeCheck*(cond) = discard
+
+when not defined(gcArc) and not defined(gcOrc) and not defined(gcAtomicArc):
+  proc shallow*[T](s: var seq[T]) {.noSideEffect, inline.} =
+    ## Marks a sequence `s` as `shallow`:idx:. Subsequent assignments will not
+    ## perform deep copies of `s`.
+    ##
+    ## This is only useful for optimization purposes.
+    if s.len == 0: return
+    when not defined(js) and not defined(nimscript) and not defined(nimSeqsV2):
+      var s = cast[PGenericSeq](s)
+      {.noSideEffect.}:
+        s.reserved = s.reserved or seqShallowFlag
+
+  proc shallow*(s: var string) {.noSideEffect, inline.} =
+    ## Marks a string `s` as `shallow`:idx:. Subsequent assignments will not
+    ## perform deep copies of `s`.
+    ##
+    ## This is only useful for optimization purposes.
+    when not defined(js) and not defined(nimscript) and not defined(nimSeqsV2):
+      var s = cast[PGenericSeq](s)
+      if s == nil:
+        s = cast[PGenericSeq](newString(0))
+      # string literals cannot become 'shallow':
+      if (s.reserved and strlitFlag) == 0:
+        {.noSideEffect.}:
+          s.reserved = s.reserved or seqShallowFlag
+
+type
+  NimNodeObj = object
+
+  NimNode* {.magic: "PNimrodNode".} = ref NimNodeObj
+    ## Represents a Nim AST node. Macros operate on this type.
+
+type
+  ForLoopStmt* {.compilerproc.} = object ## \
+    ## A special type that marks a macro as a `for-loop macro`:idx:.
+    ## See `"For Loop Macro" <manual.html#macros-for-loop-macro>`_.
+
+macro varargsLen*(x: varargs[untyped]): int {.since: (1, 1).} =
+  ## returns number of variadic arguments in `x`
+  proc varargsLenImpl(x: NimNode): NimNode {.magic: "LengthOpenArray", noSideEffect.}
+  varargsLenImpl(x)
+
+when defined(nimV2):
+  import system/repr_v2
+  export repr_v2
+
+proc repr*[T, U](x: HSlice[T, U]): string =
+  ## Generic `repr` operator for slices that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(1 .. 5) == "1 .. 5"
+  ##   ```
+  result = repr(x.a)
+  result.add(" .. ")
+  result.add(repr(x.b))
+
+when hasAlloc or defined(nimscript):
+  proc insert*(x: var string, item: string, i = 0.Natural) {.noSideEffect.} =
+    ## Inserts `item` into `x` at position `i`.
+    ##   ```nim
+    ##   var a = "abc"
+    ##   a.insert("zz", 0) # a <- "zzabc"
+    ##   ```
+    if item.len == 0: # prevents self-assignment
+      return
+    var xl = x.len
+    setLen(x, xl+item.len)
+    var j = xl-1
+    while j >= i:
+      when defined(gcArc) or defined(gcOrc) or defined(gcAtomicArc):
+        x[j+item.len] = move x[j]
+      else:
+        shallowCopy(x[j+item.len], x[j])
+      dec(j)
+    j = 0
+    while j < item.len:
+      x[j+i] = item[j]
+      inc(j)
+
+when declared(initDebugger):
+  initDebugger()
+
+proc addEscapedChar*(s: var string, c: char) {.noSideEffect, inline.} =
+  ## Adds a char to string `s` and applies the following escaping:
+  ##
+  ## * replaces any ``\`` by `\\`
+  ## * replaces any `'` by `\'`
+  ## * replaces any `"` by `\"`
+  ## * replaces any `\a` by `\\a`
+  ## * replaces any `\b` by `\\b`
+  ## * replaces any `\t` by `\\t`
+  ## * replaces any `\n` by `\\n`
+  ## * replaces any `\v` by `\\v`
+  ## * replaces any `\f` by `\\f`
+  ## * replaces any `\r` by `\\r`
+  ## * replaces any `\e` by `\\e`
+  ## * replaces any other character not in the set `{\21..\126}`
+  ##   by `\xHH` where `HH` is its hexadecimal value
+  ##
+  ## The procedure has been designed so that its output is usable for many
+  ## different common syntaxes.
+  ##
+  ## .. warning:: This is **not correct** for producing ANSI C code!
+  ##
+  case c
+  of '\a': s.add "\\a" # \x07
+  of '\b': s.add "\\b" # \x08
+  of '\t': s.add "\\t" # \x09
+  of '\n': s.add "\\n" # \x0A
+  of '\v': s.add "\\v" # \x0B
+  of '\f': s.add "\\f" # \x0C
+  of '\r': (when defined(nimLegacyAddEscapedCharx0D): s.add "\\c" else: s.add "\\r") # \x0D
+  of '\e': s.add "\\e" # \x1B
+  of '\\': s.add("\\\\")
+  of '\'': s.add("\\'")
+  of '\"': s.add("\\\"")
+  of {'\32'..'\126'} - {'\\', '\'', '\"'}: s.add(c)
+  else:
+    s.add("\\x")
+    const HexChars = "0123456789ABCDEF"
+    let n = ord(c)
+    s.add(HexChars[int((n and 0xF0) shr 4)])
+    s.add(HexChars[int(n and 0xF)])
+
+proc addQuoted*[T](s: var string, x: T) =
+  ## Appends `x` to string `s` in place, applying quoting and escaping
+  ## if `x` is a string or char.
+  ##
+  ## See `addEscapedChar <#addEscapedChar,string,char>`_
+  ## for the escaping scheme. When `x` is a string, characters in the
+  ## range `{\128..\255}` are never escaped so that multibyte UTF-8
+  ## characters are untouched (note that this behavior is different from
+  ## `addEscapedChar`).
+  ##
+  ## The Nim standard library uses this function on the elements of
+  ## collections when producing a string representation of a collection.
+  ## It is recommended to use this function as well for user-side collections.
+  ## Users may overload `addQuoted` for custom (string-like) types if
+  ## they want to implement a customized element representation.
+  ##
+  ##   ```nim
+  ##   var tmp = ""
+  ##   tmp.addQuoted(1)
+  ##   tmp.add(", ")
+  ##   tmp.addQuoted("string")
+  ##   tmp.add(", ")
+  ##   tmp.addQuoted('c')
+  ##   assert(tmp == """1, "string", 'c'""")
+  ##   ```
+  when T is string or T is cstring:
+    s.add("\"")
+    for c in x:
+      # Only ASCII chars are escaped to avoid butchering
+      # multibyte UTF-8 characters.
+      if c <= 127.char:
+        s.addEscapedChar(c)
+      else:
+        s.add c
+    s.add("\"")
+  elif T is char:
+    s.add("'")
+    s.addEscapedChar(x)
+    s.add("'")
+  # prevent temporary string allocation
+  elif T is SomeInteger:
+    s.addInt(x)
+  elif T is SomeFloat:
+    s.addFloat(x)
+  elif compiles(s.add(x)):
+    s.add(x)
+  else:
+    s.add($x)
+
+proc locals*(): RootObj {.magic: "Plugin", noSideEffect.} =
+  ## Generates a tuple constructor expression listing all the local variables
+  ## in the current scope.
+  ##
+  ## This is quite fast as it does not rely
+  ## on any debug or runtime information. Note that in contrast to what
+  ## the official signature says, the return type is *not* `RootObj` but a
+  ## tuple of a structure that depends on the current scope. Example:
+  ##
+  ##   ```nim
+  ##   proc testLocals() =
+  ##     var
+  ##       a = "something"
+  ##       b = 4
+  ##       c = locals()
+  ##       d = "super!"
+  ##
+  ##     b = 1
+  ##     for name, value in fieldPairs(c):
+  ##       echo "name ", name, " with value ", value
+  ##     echo "B is ", b
+  ##   # -> name a with value something
+  ##   # -> name b with value 4
+  ##   # -> B is 1
+  ##   ```
+  discard
+
+when hasAlloc and notJSnotNims:
+  # XXX how to implement 'deepCopy' is an open problem.
+  proc deepCopy*[T](x: var T, y: T) {.noSideEffect, magic: "DeepCopy".} =
+    ## Performs a deep copy of `y` and copies it into `x`.
+    ##
+    ## This is also used by the code generator
+    ## for the implementation of `spawn`.
+    ##
+    ## For `--mm:arc` or `--mm:orc` deepcopy support has to be enabled
+    ## via `--deepcopy:on`.
+    discard
+
+  proc deepCopy*[T](y: T): T =
+    ## Convenience wrapper around `deepCopy` overload.
+    deepCopy(result, y)
+
+  include "system/deepcopy"
+
+proc procCall*(x: untyped) {.magic: "ProcCall", compileTime.} =
+  ## Special magic to prohibit dynamic binding for `method`:idx: calls.
+  ## This is similar to `super`:idx: in ordinary OO languages.
+  ##   ```nim
+  ##   # 'someMethod' will be resolved fully statically:
+  ##   procCall someMethod(a, b)
+  ##   ```
+  discard
+
+
+proc `==`*(x, y: cstring): bool {.magic: "EqCString", noSideEffect,
+                                   inline.} =
+  ## Checks for equality between two `cstring` variables.
+  proc strcmp(a, b: cstring): cint {.noSideEffect,
+    importc, header: "<string.h>".}
+  if pointer(x) == pointer(y): result = true
+  elif pointer(x) == nil or pointer(y) == nil: result = false
+  else: result = strcmp(x, y) == 0
+
+template closureScope*(body: untyped): untyped =
+  ## Useful when creating a closure in a loop to capture local loop variables by
+  ## their current iteration values.
+  ##
+  ## Note: This template may not work in some cases, use
+  ## `capture <sugar.html#capture.m,varargs[typed],untyped>`_ instead.
+  ##
+  ## Example:
+  ##
+  ##   ```nim
+  ##   var myClosure : proc()
+  ##   # without closureScope:
+  ##   for i in 0 .. 5:
+  ##     let j = i
+  ##     if j == 3:
+  ##       myClosure = proc() = echo j
+  ##   myClosure() # outputs 5. `j` is changed after closure creation
+  ##   # with closureScope:
+  ##   for i in 0 .. 5:
+  ##     closureScope: # Everything in this scope is locked after closure creation
+  ##       let j = i
+  ##       if j == 3:
+  ##         myClosure = proc() = echo j
+  ##   myClosure() # outputs 3
+  ##   ```
+  (proc() = body)()
+
+template once*(body: untyped): untyped =
+  ## Executes a block of code only once (the first time the block is reached).
+  ##   ```nim
+  ##   proc draw(t: Triangle) =
+  ##     once:
+  ##       graphicsInit()
+  ##     line(t.p1, t.p2)
+  ##     line(t.p2, t.p3)
+  ##     line(t.p3, t.p1)
+  ##   ```
+  var alreadyExecuted {.global.} = false
+  if not alreadyExecuted:
+    alreadyExecuted = true
+    body
+
+{.pop.} # warning[GcMem]: off, warning[Uninit]: off
+
+proc substr*(s: openArray[char]): string =
+  ## Copies a slice of `s` into a new string and returns this new
+  ## string.
+  runnableExamples:
+    let a = "abcdefgh"
+    assert a.substr(2, 5) == "cdef"
+    assert a.substr(2) == "cdefgh"
+    assert a.substr(5, 99) == "fgh"
+  result = newString(s.len)
+  for i, ch in s:
+    result[i] = ch
+
+proc substr*(s: string, first, last: int): string = # A bug with `magic: Slice` requires this to exist this way
+  ## Copies a slice of `s` into a new string and returns this new
+  ## string.
+  ##
+  ## The bounds `first` and `last` denote the indices of
+  ## the first and last characters that shall be copied. If `last`
+  ## is omitted, it is treated as `high(s)`. If `last >= s.len`, `s.len`
+  ## is used instead: This means `substr` can also be used to `cut`:idx:
+  ## or `limit`:idx: a string's length.
+  runnableExamples:
+    let a = "abcdefgh"
+    assert a.substr(2, 5) == "cdef"
+    assert a.substr(2) == "cdefgh"
+    assert a.substr(5, 99) == "fgh"
+
+  let first = max(first, 0)
+  let L = max(min(last, high(s)) - first + 1, 0)
+  result = newString(L)
+  for i in 0 .. L-1:
+    result[i] = s[i+first]
+
+proc substr*(s: string, first = 0): string =
+  result = substr(s, first, high(s))
+
+when defined(nimconfig):
+  include "system/nimscript"
+
+when not defined(js):
+  proc toOpenArray*[T](x: ptr UncheckedArray[T]; first, last: int): openArray[T] {.
+    magic: "Slice".}
+  proc toOpenArray*(x: cstring; first, last: int): openArray[char] {.
+    magic: "Slice".}
+  proc toOpenArrayByte*(x: cstring; first, last: int): openArray[byte] {.
+    magic: "Slice".}
+
+proc toOpenArray*[T](x: seq[T]; first, last: int): openArray[T] {.
+  magic: "Slice".}
+  ## Allows passing the slice of `x` from the element at `first` to the element
+  ## at `last` to `openArray[T]` parameters without copying it.
+  ##
+  ## Example:
+  ##   ```nim
+  ##   proc test(x: openArray[int]) =
+  ##     doAssert x == [1, 2, 3]
+  ##
+  ##   let s = @[0, 1, 2, 3, 4]
+  ##   s.toOpenArray(1, 3).test
+  ##   ```
+
+proc toOpenArray*[T](x: openArray[T]; first, last: int): openArray[T] {.
+  magic: "Slice".}
+proc toOpenArray*[I, T](x: array[I, T]; first, last: I): openArray[T] {.
+  magic: "Slice".}
+proc toOpenArray*(x: string; first, last: int): openArray[char] {.
+  magic: "Slice".}
+
+proc toOpenArrayByte*(x: string; first, last: int): openArray[byte] {.
+  magic: "Slice".}
+proc toOpenArrayByte*(x: openArray[char]; first, last: int): openArray[byte] {.
+  magic: "Slice".}
+proc toOpenArrayByte*(x: seq[char]; first, last: int): openArray[byte] {.
+  magic: "Slice".}
+
+proc toOpenArrayChar*(x: openArray[byte]; first, last: int): openArray[char] {.
+  magic: "Slice".}
+
+when defined(genode):
+  var componentConstructHook*: proc (env: GenodeEnv) {.nimcall.}
+    ## Hook into the Genode component bootstrap process.
+    ##
+    ## This hook is called after all globals are initialized.
+    ## When this hook is set the component will not automatically exit,
+    ## call `quit` explicitly to do so. This is the only available method
+    ## of accessing the initial Genode environment.
+
+  proc nim_component_construct(env: GenodeEnv) {.exportc.} =
+    ## Procedure called during `Component::construct` by the loader.
+    if componentConstructHook.isNil:
+      env.rawQuit(programResult)
+        # No native Genode application initialization,
+        # exit as would POSIX.
+    else:
+      componentConstructHook(env)
+        # Perform application initialization
+        # and return to thread entrypoint.
+
+
+when not defined(nimPreviewSlimSystem):
+  import std/widestrs
+  export widestrs
+
+when notJSnotNims:
+  when defined(windows) and compileOption("threads"):
+    when not declared(addSysExitProc):
+      proc addSysExitProc(quitProc: proc() {.noconv.}) {.importc: "atexit", header: "<stdlib.h>".}
+    var echoLock: SysLock
+    initSysLock echoLock
+    addSysExitProc(proc() {.noconv.} = deinitSys(echoLock))
+
+  const stdOutLock = compileOption("threads") and
+                    not defined(windows) and
+                    not defined(android) and
+                    not defined(nintendoswitch) and
+                    not defined(freertos) and
+                    not defined(zephyr) and
+                    not defined(nuttx) and
+                    hostOS != "any"
+
+  proc raiseEIO(msg: string) {.noinline, noreturn.} =
+    raise newException(IOError, msg)
+
+  proc echoBinSafe(args: openArray[string]) {.compilerproc.} =
+    when defined(androidNDK):
+      # When running nim in android app, stdout goes nowhere, so echo gets ignored
+      # To redirect echo to the android logcat, use -d:androidNDK
+      const ANDROID_LOG_VERBOSE = 2.cint
+      proc android_log_print(prio: cint, tag: cstring, fmt: cstring): cint
+        {.importc: "__android_log_print", header: "<android/log.h>", varargs, discardable.}
+      var s = ""
+      for arg in args:
+        s.add arg
+      android_log_print(ANDROID_LOG_VERBOSE, "nim", s)
+    else:
+      # flockfile deadlocks some versions of Android 5.x.x
+      when stdOutLock:
+        proc flockfile(f: CFilePtr) {.importc, nodecl.}
+        proc funlockfile(f: CFilePtr) {.importc, nodecl.}
+        flockfile(cstdout)
+      when defined(windows) and compileOption("threads"):
+        acquireSys echoLock
+      for s in args:
+        when defined(windows):
+          # equivalent to syncio.writeWindows
+          proc writeWindows(f: CFilePtr; s: string; doRaise = false) =
+            # Don't ask why but the 'printf' family of function is the only thing
+            # that writes utf-8 strings reliably on Windows. At least on my Win 10
+            # machine. We also enable `setConsoleOutputCP(65001)` now by default.
+            # But we cannot call printf directly as the string might contain \0.
+            # So we have to loop over all the sections separated by potential \0s.
+            var i = int c_fprintf(f, "%s", s)
+            while i < s.len:
+              if s[i] == '\0':
+                let w = c_fputc('\0', f)
+                if w != 0:
+                  if doRaise: raiseEIO("cannot write string to file")
+                  break
+                inc i
+              else:
+                let w = c_fprintf(f, "%s", unsafeAddr s[i])
+                if w <= 0:
+                  if doRaise: raiseEIO("cannot write string to file")
+                  break
+                inc i, w
+          writeWindows(cstdout, s)
+        else:
+          discard c_fwrite(s.cstring, cast[csize_t](s.len), 1, cstdout)
+      const linefeed = "\n"
+      discard c_fwrite(linefeed.cstring, linefeed.len, 1, cstdout)
+      discard c_fflush(cstdout)
+      when stdOutLock:
+        funlockfile(cstdout)
+      when defined(windows) and compileOption("threads"):
+        releaseSys echoLock
+
+when not defined(nimPreviewSlimSystem):
+  import std/syncio
+  export syncio
+
+when not defined(createNimHcr) and not defined(nimscript):
+  include nimhcr
+
+when notJSnotNims and not defined(nimSeqsV2):
+  proc prepareMutation*(s: var string) {.inline.} =
+    ## String literals (e.g. "abc", etc) in the ARC/ORC mode are "copy on write",
+    ## therefore you should call `prepareMutation` before modifying the strings
+    ## via `addr`.
+    runnableExamples:
+      var x = "abc"
+      var y = "defgh"
+      prepareMutation(y) # without this, you may get a `SIGBUS` or `SIGSEGV`
+      moveMem(addr y[0], addr x[0], x.len)
+      assert y == "abcgh"
+    discard
+
+proc arrayWith*[T](y: T, size: static int): array[size, T] {.raises: [].} =
+  ## Creates a new array filled with `y`.
+  for i in 0..size-1:
+    when nimvm:
+      result[i] = y
+    else:
+      # TODO: fixme it should be `=dup`
+      result[i] = y
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim
index 95feff854..3de6d8713 100755..100644
--- a/lib/system/alloc.nim
+++ b/lib/system/alloc.nim
@@ -1,596 +1,1337 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-# Low level allocator for Nimrod. Has been designed to support the GC.
-# TODO: 
-# - eliminate "used" field
-# - make searching for block O(1)
-
-# ------------ platform specific chunk allocation code -----------------------
-
-when defined(posix): 
-  const
-    PROT_READ  = 1             # page can be read 
-    PROT_WRITE = 2             # page can be written 
-    MAP_PRIVATE = 2            # Changes are private 
-  
-  when defined(linux) or defined(aix):
-    const MAP_ANONYMOUS = 0x20       # don't use a file
-  elif defined(macosx) or defined(bsd):
-    const MAP_ANONYMOUS = 0x1000
-  elif defined(solaris): 
-    const MAP_ANONYMOUS = 0x100
-  else:
-    {.error: "Port memory manager to your platform".}
+# Low level allocator for Nim. Has been designed to support the GC.
+{.push profiler:off.}
 
-  proc mmap(adr: pointer, len: int, prot, flags, fildes: cint,
-            off: int): pointer {.header: "<sys/mman.h>".}
+include osalloc
+import std/private/syslocks
+import std/sysatomics
 
-  proc munmap(adr: pointer, len: int) {.header: "<sys/mman.h>".}
-  
-  proc osAllocPages(size: int): pointer {.inline.} = 
-    result = mmap(nil, size, PROT_READ or PROT_WRITE, 
-                           MAP_PRIVATE or MAP_ANONYMOUS, -1, 0)
-    if result == nil or result == cast[pointer](-1):
-      raiseOutOfMem()
-      
-  proc osDeallocPages(p: pointer, size: int) {.inline} =
-    when reallyOsDealloc: munmap(p, size)
-  
-elif defined(windows): 
-  const
-    MEM_RESERVE = 0x2000 
-    MEM_COMMIT = 0x1000
-    MEM_TOP_DOWN = 0x100000
-    PAGE_READWRITE = 0x04
-
-    MEM_DECOMMIT = 0x4000
-    MEM_RELEASE = 0x8000
-
-  proc VirtualAlloc(lpAddress: pointer, dwSize: int, flAllocationType,
-                    flProtect: int32): pointer {.
-                    header: "<windows.h>", stdcall.}
-  
-  proc VirtualFree(lpAddress: pointer, dwSize: int, 
-                   dwFreeType: int32) {.header: "<windows.h>", stdcall.}
-  
-  proc osAllocPages(size: int): pointer {.inline.} = 
-    result = VirtualAlloc(nil, size, MEM_RESERVE or MEM_COMMIT,
-                          PAGE_READWRITE)
-    if result == nil: raiseOutOfMem()
-
-  proc osDeallocPages(p: pointer, size: int) {.inline.} = 
-    # according to Microsoft, 0 is the only correct value here:
-    when reallyOsDealloc: VirtualFree(p, 0, MEM_RELEASE)
-
-else: 
-  {.error: "Port memory manager to your platform".}
-
-# --------------------- end of non-portable code -----------------------------
+template track(op, address, size) =
+  when defined(memTracker):
+    memTrackerOp(op, address, size)
 
 # We manage *chunks* of memory. Each chunk is a multiple of the page size.
-# Each chunk starts at an address that is divisible by the page size. Chunks
-# that are bigger than ``ChunkOsReturn`` are returned back to the operating
-# system immediately.
+# Each chunk starts at an address that is divisible by the page size.
+# Small chunks may be divided into smaller cells of reusable pointers to reduce the number of page allocations.
+
+# An allocation of a small pointer looks approximately like this
+#[
+
+  alloc -> rawAlloc -> No free chunk available > Request a new page from tslf -> result = chunk.data -------------+
+              |                                                                                                   |
+              v                                                                                                   |
+    Free chunk available                                                                                          |
+              |                                                                                                   |
+              v                                                                                                   v
+      Fetch shared cells -> No free cells available -> Advance acc -> result = chunk.data + chunk.acc -------> return
+    (may not add new cells)                                                                                       ^
+              |                                                                                                   |
+              v                                                                                                   |
+     Free cells available -> result = chunk.freeList -> Advance chunk.freeList -----------------------------------+
+]#
+# so it is split into 3 paths, where the last path is preferred to prevent unnecessary allocations.
+#
+#
+# A deallocation of a small pointer then looks like this
+#[
+  dealloc -> rawDealloc -> chunk.owner == addr(a) --------------> This thread owns the chunk ------> The current chunk is active    -> Chunk is completely unused -----> Chunk references no foreign cells
+                                      |                                       |                   (Add cell into the current chunk)                 |                  Return the current chunk back to tlsf
+                                      |                                       |                                   |                                 |
+                                      v                                       v                                   v                                 v
+                      A different thread owns this chunk.     The current chunk is not active.          chunk.free was < size      Chunk references foreign cells, noop
+                      Add the cell to a.sharedFreeLists      Add the cell into the active chunk          Activate the chunk                       (end)
+                                    (end)                                    (end)                              (end)
+]#
+# So "true" deallocation is delayed for as long as possible in favor of reusing cells.
 
 const
-  ChunkOsReturn = 256 * PageSize
-  InitialMemoryRequest = ChunkOsReturn div 2 # < ChunkOsReturn!
+  nimMinHeapPages {.intdefine.} = 128 # 0.5 MB
   SmallChunkSize = PageSize
+  MaxFli = when sizeof(int) > 2: 30 else: 14
+  MaxLog2Sli = 5 # 32, this cannot be increased without changing 'uint32'
+                 # everywhere!
+  MaxSli = 1 shl MaxLog2Sli
+  FliOffset = 6
+  RealFli = MaxFli - FliOffset
+
+  # size of chunks in last matrix bin
+  MaxBigChunkSize = int(1'i32 shl MaxFli - 1'i32 shl (MaxFli-MaxLog2Sli-1))
+  HugeChunkSize = MaxBigChunkSize + 1
 
-type 
-  PTrunk = ptr TTrunk
-  TTrunk {.final.} = object 
+type
+  PTrunk = ptr Trunk
+  Trunk = object
     next: PTrunk         # all nodes are connected with this pointer
     key: int             # start address at bit 0
-    bits: array[0..IntsPerTrunk-1, int] # a bit vector
-  
-  TTrunkBuckets = array[0..1023, PTrunk]
-  TIntSet {.final.} = object 
-    data: TTrunkBuckets
-  
-type
-  TAlignType = biggestFloat
-  TFreeCell {.final, pure.} = object
-    next: ptr TFreeCell  # next free cell in chunk (overlaid with refcount)
-    zeroField: int       # 0 means cell is not used (overlaid with typ field)
-                         # 1 means cell is manually managed pointer
-
-  PChunk = ptr TBaseChunk
-  PBigChunk = ptr TBigChunk
-  PSmallChunk = ptr TSmallChunk
-  TBaseChunk {.pure.} = object
-    prevSize: int        # size of previous chunk; for coalescing
-    size: int            # if < PageSize it is a small chunk
-    used: bool           # later will be optimized into prevSize...
-  
-  TSmallChunk = object of TBaseChunk
-    next, prev: PSmallChunk  # chunks of the same size
-    freeList: ptr TFreeCell
-    free: int            # how many bytes remain    
-    acc: int             # accumulator for small object allocation
-    data: TAlignType     # start of usable memory
-  
-  TBigChunk = object of TBaseChunk # not necessarily > PageSize!
-    next: PBigChunk      # chunks of the same (or bigger) size
-    prev: PBigChunk
-    align: int
-    data: TAlignType     # start of usable memory
-
-template smallChunkOverhead(): expr = sizeof(TSmallChunk)-sizeof(TAlignType)
-template bigChunkOverhead(): expr = sizeof(TBigChunk)-sizeof(TAlignType)
-
-proc roundup(x, v: int): int {.inline.} = 
-  result = (x + (v-1)) and not (v-1)
-  assert(result >= x)
-  #return ((-x) and (v-1)) +% x
-
-assert(roundup(14, PageSize) == PageSize)
-assert(roundup(15, 8) == 16)
-assert(roundup(65, 8) == 72)
+    bits: array[0..IntsPerTrunk-1, uint] # a bit vector
+
+  TrunkBuckets = array[0..255, PTrunk]
+  IntSet = object
+    data: TrunkBuckets
 
 # ------------- chunk table ---------------------------------------------------
 # We use a PtrSet of chunk starts and a table[Page, chunksize] for chunk
 # endings of big chunks. This is needed by the merging operation. The only
 # remaining operation is best-fit for big chunks. Since there is a size-limit
 # for big chunks (because greater than the limit means they are returned back
-# to the OS), a fixed size array can be used. 
+# to the OS), a fixed size array can be used.
 
 type
-  PLLChunk = ptr TLLChunk
-  TLLChunk {.pure.} = object ## *low-level* chunk
+  PLLChunk = ptr LLChunk
+  LLChunk = object ## *low-level* chunk
     size: int                # remaining size
     acc: int                 # accumulator
-    
-  TAllocator {.final, pure.} = object
+    next: PLLChunk           # next low-level chunk; only needed for dealloc
+
+  PAvlNode = ptr AvlNode
+  AvlNode = object
+    link: array[0..1, PAvlNode] # Left (0) and right (1) links
+    key, upperBound: int
+    level: int
+
+const
+  RegionHasLock = false # hasThreadSupport and defined(gcDestructors)
+
+type
+  FreeCell {.final, pure.} = object
+    # A free cell is a pointer that has been freed, meaning it became available for reuse.
+    # It may become foreign if it is lent to a chunk that did not create it, doing so reduces the amount of needed pages.
+    next: ptr FreeCell  # next free cell in chunk (overlaid with refcount)
+    when not defined(gcDestructors):
+      zeroField: int       # 0 means cell is not used (overlaid with typ field)
+                          # 1 means cell is manually managed pointer
+                          # otherwise a PNimType is stored in there
+    else:
+      alignment: int
+
+  PChunk = ptr BaseChunk
+  PBigChunk = ptr BigChunk
+  PSmallChunk = ptr SmallChunk
+  BaseChunk {.pure, inheritable.} = object
+    prevSize: int        # size of previous chunk; for coalescing
+                         # 0th bit == 1 if 'used
+    size: int            # if < PageSize it is a small chunk
+    owner: ptr MemRegion
+
+  SmallChunk = object of BaseChunk
+    next, prev: PSmallChunk  # chunks of the same size
+    freeList: ptr FreeCell   # Singly linked list of cells. They may be from foreign chunks or from the current chunk.
+                             #  Should be `nil` when the chunk isn't active in `a.freeSmallChunks`.
+    free: int32              # Bytes this chunk is able to provide using both the accumulator and free cells.
+                             # When a cell is considered foreign, its source chunk's free field is NOT adjusted until it
+                             #  reaches dealloc while the source chunk is active.
+                             # Instead, the receiving chunk gains the capacity and thus reserves space in the foreign chunk.
+    acc: uint32              # Offset from data, used when there are no free cells available but the chunk is considered free.
+    foreignCells: int        # When a free cell is given to a chunk that is not its origin,
+                             #  both the cell and the source chunk are considered foreign.
+                             # Receiving a foreign cell can happen both when deallocating from another thread or when
+                             #  the active chunk in `a.freeSmallChunks` is not the current chunk.
+                             # Freeing a chunk while `foreignCells > 0` leaks memory as all references to it become lost.
+    data {.align: MemAlign.}: UncheckedArray[byte]      # start of usable memory
+
+  BigChunk = object of BaseChunk # not necessarily > PageSize!
+    next, prev: PBigChunk    # chunks of the same (or bigger) size
+    data {.align: MemAlign.}: UncheckedArray[byte]      # start of usable memory
+
+  HeapLinks = object
+    len: int
+    chunks: array[30, (PBigChunk, int)]
+    next: ptr HeapLinks
+
+  MemRegion = object
+    when not defined(gcDestructors):
+      minLargeObj, maxLargeObj: int
+    freeSmallChunks: array[0..max(1, SmallChunkSize div MemAlign-1), PSmallChunk]
+      # List of available chunks per size class. Only one is expected to be active per class.
+    when defined(gcDestructors):
+      sharedFreeLists: array[0..max(1, SmallChunkSize div MemAlign-1), ptr FreeCell]
+        # When a thread frees a pointer it did not create, it must not adjust the counters.
+        # Instead, the cell is placed here and deferred until the next allocation.
+    flBitmap: uint32
+    slBitmap: array[RealFli, uint32]
+    matrix: array[RealFli, array[MaxSli, PBigChunk]]
     llmem: PLLChunk
-    currMem, maxMem, freeMem: int # memory sizes (allocated from OS)
-    freeSmallChunks: array[0..SmallChunkSize div MemAlign-1, PSmallChunk]
-    freeChunksList: PBigChunk # XXX make this a datastructure with O(1) access
-    chunkStarts: TIntSet
-   
-proc incCurrMem(a: var TAllocator, bytes: int) {.inline.} = 
-  inc(a.currMem, bytes)
-
-proc decCurrMem(a: var TAllocator, bytes: int) {.inline.} =
+    currMem, maxMem, freeMem, occ: int # memory sizes (allocated from OS)
+    lastSize: int # needed for the case that OS gives us pages linearly
+    when RegionHasLock:
+      lock: SysLock
+    when defined(gcDestructors):
+      sharedFreeListBigChunks: PBigChunk # make no attempt at avoiding false sharing for now for this object field
+
+    chunkStarts: IntSet
+    when not defined(gcDestructors):
+      root, deleted, last, freeAvlNodes: PAvlNode
+    lockActive, locked, blockChunkSizeIncrease: bool # if locked, we cannot free pages.
+    nextChunkSize: int
+    when not defined(gcDestructors):
+      bottomData: AvlNode
+    heapLinks: HeapLinks
+    when defined(nimTypeNames):
+      allocCounter, deallocCounter: int
+
+template smallChunkOverhead(): untyped = sizeof(SmallChunk)
+template bigChunkOverhead(): untyped = sizeof(BigChunk)
+
+when hasThreadSupport:
+  template loada(x: untyped): untyped = atomicLoadN(unsafeAddr x, ATOMIC_RELAXED)
+  template storea(x, y: untyped) = atomicStoreN(unsafeAddr x, y, ATOMIC_RELAXED)
+
+  when false:
+    # not yet required
+    template atomicStatDec(x, diff: untyped) = discard atomicSubFetch(unsafeAddr x, diff, ATOMIC_RELAXED)
+    template atomicStatInc(x, diff: untyped) = discard atomicAddFetch(unsafeAddr x, diff, ATOMIC_RELAXED)
+else:
+  template loada(x: untyped): untyped = x
+  template storea(x, y: untyped) = x = y
+
+template atomicStatDec(x, diff: untyped) = dec x, diff
+template atomicStatInc(x, diff: untyped) = inc x, diff
+
+const
+  fsLookupTable: array[byte, int8] = [
+    -1'i8, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+    5, 5, 5, 5, 5, 5, 5, 5,
+    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+    7, 7, 7, 7, 7, 7, 7, 7
+  ]
+
+proc msbit(x: uint32): int {.inline.} =
+  let a = if x <= 0xff_ff'u32:
+            (if x <= 0xff: 0 else: 8)
+          else:
+            (if x <= 0xff_ff_ff'u32: 16 else: 24)
+  result = int(fsLookupTable[byte(x shr a)]) + a
+
+proc lsbit(x: uint32): int {.inline.} =
+  msbit(x and ((not x) + 1))
+
+proc setBit(nr: int; dest: var uint32) {.inline.} =
+  dest = dest or (1u32 shl (nr and 0x1f))
+
+proc clearBit(nr: int; dest: var uint32) {.inline.} =
+  dest = dest and not (1u32 shl (nr and 0x1f))
+
+proc mappingSearch(r, fl, sl: var int) {.inline.} =
+  #let t = (1 shl (msbit(uint32 r) - MaxLog2Sli)) - 1
+  # This diverges from the standard TLSF algorithm because we need to ensure
+  # PageSize alignment:
+  let t = roundup((1 shl (msbit(uint32 r) - MaxLog2Sli)), PageSize) - 1
+  r = r + t
+  r = r and not t
+  r = min(r, MaxBigChunkSize).int
+  fl = msbit(uint32 r)
+  sl = (r shr (fl - MaxLog2Sli)) - MaxSli
+  dec fl, FliOffset
+  sysAssert((r and PageMask) == 0, "mappingSearch: still not aligned")
+
+# See http://www.gii.upv.es/tlsf/files/papers/tlsf_desc.pdf for details of
+# this algorithm.
+
+proc mappingInsert(r: int): tuple[fl, sl: int] {.inline.} =
+  sysAssert((r and PageMask) == 0, "mappingInsert: still not aligned")
+  result.fl = msbit(uint32 r)
+  result.sl = (r shr (result.fl - MaxLog2Sli)) - MaxSli
+  dec result.fl, FliOffset
+
+template mat(): untyped = a.matrix[fl][sl]
+
+proc findSuitableBlock(a: MemRegion; fl, sl: var int): PBigChunk {.inline.} =
+  let tmp = a.slBitmap[fl] and (not 0u32 shl sl)
+  result = nil
+  if tmp != 0:
+    sl = lsbit(tmp)
+    result = mat()
+  else:
+    fl = lsbit(a.flBitmap and (not 0u32 shl (fl + 1)))
+    if fl > 0:
+      sl = lsbit(a.slBitmap[fl])
+      result = mat()
+
+template clearBits(sl, fl) =
+  clearBit(sl, a.slBitmap[fl])
+  if a.slBitmap[fl] == 0u32:
+    # do not forget to cascade:
+    clearBit(fl, a.flBitmap)
+
+proc removeChunkFromMatrix(a: var MemRegion; b: PBigChunk) =
+  let (fl, sl) = mappingInsert(b.size)
+  if b.next != nil: b.next.prev = b.prev
+  if b.prev != nil: b.prev.next = b.next
+  if mat() == b:
+    mat() = b.next
+    if mat() == nil:
+      clearBits(sl, fl)
+  b.prev = nil
+  b.next = nil
+
+proc removeChunkFromMatrix2(a: var MemRegion; b: PBigChunk; fl, sl: int) =
+  mat() = b.next
+  if mat() != nil:
+    mat().prev = nil
+  else:
+    clearBits(sl, fl)
+  b.prev = nil
+  b.next = nil
+
+proc addChunkToMatrix(a: var MemRegion; b: PBigChunk) =
+  let (fl, sl) = mappingInsert(b.size)
+  b.prev = nil
+  b.next = mat()
+  if mat() != nil:
+    mat().prev = b
+  mat() = b
+  setBit(sl, a.slBitmap[fl])
+  setBit(fl, a.flBitmap)
+
+proc incCurrMem(a: var MemRegion, bytes: int) {.inline.} =
+  atomicStatInc(a.currMem, bytes)
+
+proc decCurrMem(a: var MemRegion, bytes: int) {.inline.} =
   a.maxMem = max(a.maxMem, a.currMem)
-  dec(a.currMem, bytes)
+  atomicStatDec(a.currMem, bytes)
 
-proc getMaxMem(a: var TAllocator): int =
-  # Since we update maxPagesCount only when freeing pages, 
+proc getMaxMem(a: var MemRegion): int =
+  # Since we update maxPagesCount only when freeing pages,
   # maxPagesCount may not be up to date. Thus we use the
   # maximum of these both values here:
-  return max(a.currMem, a.maxMem)
-   
-var
-  allocator: TAllocator
-    
-proc llAlloc(a: var TAllocator, size: int): pointer =
+  result = max(a.currMem, a.maxMem)
+
+const nimMaxHeap {.intdefine.} = 0
+
+proc allocPages(a: var MemRegion, size: int): pointer =
+  when nimMaxHeap != 0:
+    if a.occ + size > nimMaxHeap * 1024 * 1024:
+      raiseOutOfMem()
+  osAllocPages(size)
+
+proc tryAllocPages(a: var MemRegion, size: int): pointer =
+  when nimMaxHeap != 0:
+    if a.occ + size > nimMaxHeap * 1024 * 1024:
+      raiseOutOfMem()
+  osTryAllocPages(size)
+
+proc llAlloc(a: var MemRegion, size: int): pointer =
   # *low-level* alloc for the memory managers data structures. Deallocation
-  # is never done.
+  # is done at the end of the allocator's life time.
   if a.llmem == nil or size > a.llmem.size:
-    var request = roundup(size+sizeof(TLLChunk), PageSize)
-    a.llmem = cast[PLLChunk](osAllocPages(request))
-    incCurrMem(a, request)
-    a.llmem.size = request - sizeof(TLLChunk)
-    a.llmem.acc = sizeof(TLLChunk)
-  result = cast[pointer](cast[TAddress](a.llmem) + a.llmem.acc)
+    # the requested size is ``roundup(size+sizeof(LLChunk), PageSize)``, but
+    # since we know ``size`` is a (small) constant, we know the requested size
+    # is one page:
+    sysAssert roundup(size+sizeof(LLChunk), PageSize) == PageSize, "roundup 6"
+    var old = a.llmem # can be nil and is correct with nil
+    a.llmem = cast[PLLChunk](allocPages(a, PageSize))
+    when defined(nimAvlcorruption):
+      trackLocation(a.llmem, PageSize)
+    incCurrMem(a, PageSize)
+    a.llmem.size = PageSize - sizeof(LLChunk)
+    a.llmem.acc = sizeof(LLChunk)
+    a.llmem.next = old
+  result = cast[pointer](cast[int](a.llmem) + a.llmem.acc)
   dec(a.llmem.size, size)
   inc(a.llmem.acc, size)
   zeroMem(result, size)
-  
-proc IntSetGet(t: TIntSet, key: int): PTrunk = 
+
+when not defined(gcDestructors):
+  proc getBottom(a: var MemRegion): PAvlNode =
+    result = addr(a.bottomData)
+    if result.link[0] == nil:
+      result.link[0] = result
+      result.link[1] = result
+
+  proc allocAvlNode(a: var MemRegion, key, upperBound: int): PAvlNode =
+    if a.freeAvlNodes != nil:
+      result = a.freeAvlNodes
+      a.freeAvlNodes = a.freeAvlNodes.link[0]
+    else:
+      result = cast[PAvlNode](llAlloc(a, sizeof(AvlNode)))
+      when defined(nimAvlcorruption):
+        cprintf("tracking location: %p\n", result)
+    result.key = key
+    result.upperBound = upperBound
+    let bottom = getBottom(a)
+    result.link[0] = bottom
+    result.link[1] = bottom
+    result.level = 1
+    #when defined(nimAvlcorruption):
+    #  track("allocAvlNode", result, sizeof(AvlNode))
+    sysAssert(bottom == addr(a.bottomData), "bottom data")
+    sysAssert(bottom.link[0] == bottom, "bottom link[0]")
+    sysAssert(bottom.link[1] == bottom, "bottom link[1]")
+
+  proc deallocAvlNode(a: var MemRegion, n: PAvlNode) {.inline.} =
+    n.link[0] = a.freeAvlNodes
+    a.freeAvlNodes = n
+
+proc addHeapLink(a: var MemRegion; p: PBigChunk, size: int): ptr HeapLinks =
+  var it = addr(a.heapLinks)
+  while it != nil and it.len >= it.chunks.len: it = it.next
+  if it == nil:
+    var n = cast[ptr HeapLinks](llAlloc(a, sizeof(HeapLinks)))
+    n.next = a.heapLinks.next
+    a.heapLinks.next = n
+    n.chunks[0] = (p, size)
+    n.len = 1
+    result = n
+  else:
+    let L = it.len
+    it.chunks[L] = (p, size)
+    inc it.len
+    result = it
+
+when not defined(gcDestructors):
+  include "system/avltree"
+
+proc llDeallocAll(a: var MemRegion) =
+  var it = a.llmem
+  while it != nil:
+    # we know each block in the list has the size of 1 page:
+    var next = it.next
+    osDeallocPages(it, PageSize)
+    it = next
+  a.llmem = nil
+
+proc intSetGet(t: IntSet, key: int): PTrunk =
   var it = t.data[key and high(t.data)]
-  while it != nil: 
+  while it != nil:
     if it.key == key: return it
     it = it.next
   result = nil
 
-proc IntSetPut(t: var TIntSet, key: int): PTrunk = 
-  result = IntSetGet(t, key)
+proc intSetPut(a: var MemRegion, t: var IntSet, key: int): PTrunk =
+  result = intSetGet(t, key)
   if result == nil:
-    result = cast[PTrunk](llAlloc(allocator, sizeof(result^)))
+    result = cast[PTrunk](llAlloc(a, sizeof(result[])))
     result.next = t.data[key and high(t.data)]
     t.data[key and high(t.data)] = result
     result.key = key
 
-proc Contains(s: TIntSet, key: int): bool = 
-  var t = IntSetGet(s, key shr TrunkShift)
-  if t != nil: 
+proc contains(s: IntSet, key: int): bool =
+  var t = intSetGet(s, key shr TrunkShift)
+  if t != nil:
     var u = key and TrunkMask
-    result = (t.bits[u shr IntShift] and (1 shl (u and IntMask))) != 0
-  else: 
+    result = (t.bits[u shr IntShift] and (uint(1) shl (u and IntMask))) != 0
+  else:
     result = false
-  
-proc Incl(s: var TIntSet, key: int) = 
-  var t = IntSetPut(s, key shr TrunkShift)
+
+proc incl(a: var MemRegion, s: var IntSet, key: int) =
+  var t = intSetPut(a, s, key shr TrunkShift)
   var u = key and TrunkMask
-  t.bits[u shr IntShift] = t.bits[u shr IntShift] or (1 shl (u and IntMask))
+  t.bits[u shr IntShift] = t.bits[u shr IntShift] or (uint(1) shl (u and IntMask))
 
-proc Excl(s: var TIntSet, key: int) = 
-  var t = IntSetGet(s, key shr TrunkShift)
+proc excl(s: var IntSet, key: int) =
+  var t = intSetGet(s, key shr TrunkShift)
   if t != nil:
     var u = key and TrunkMask
     t.bits[u shr IntShift] = t.bits[u shr IntShift] and not
-        (1 shl (u and IntMask))
+        (uint(1) shl (u and IntMask))
+
+iterator elements(t: IntSet): int {.inline.} =
+  # while traversing it is forbidden to change the set!
+  for h in 0..high(t.data):
+    var r = t.data[h]
+    while r != nil:
+      var i = 0
+      while i <= high(r.bits):
+        var w = r.bits[i] # taking a copy of r.bits[i] here is correct, because
+        # modifying operations are not allowed during traversation
+        var j = 0
+        while w != 0:         # test all remaining bits for zero
+          if (w and 1) != 0:  # the bit is set!
+            yield (r.key shl TrunkShift) or (i shl IntShift +% j)
+          inc(j)
+          w = w shr 1
+        inc(i)
+      r = r.next
+
+proc isSmallChunk(c: PChunk): bool {.inline.} =
+  result = c.size <= SmallChunkSize-smallChunkOverhead()
+
+proc chunkUnused(c: PChunk): bool {.inline.} =
+  result = (c.prevSize and 1) == 0
+
+iterator allObjects(m: var MemRegion): pointer {.inline.} =
+  m.locked = true
+  for s in elements(m.chunkStarts):
+    # we need to check here again as it could have been modified:
+    if s in m.chunkStarts:
+      let c = cast[PChunk](s shl PageShift)
+      if not chunkUnused(c):
+        if isSmallChunk(c):
+          var c = cast[PSmallChunk](c)
+
+          let size = c.size
+          var a = cast[int](addr(c.data))
+          let limit = a + c.acc.int
+          while a <% limit:
+            yield cast[pointer](a)
+            a = a +% size
+        else:
+          let c = cast[PBigChunk](c)
+          yield addr(c.data)
+  m.locked = false
+
+proc iterToProc*(iter: typed, envType: typedesc; procName: untyped) {.
+                      magic: "Plugin", compileTime.}
+
+when not defined(gcDestructors):
+  proc isCell(p: pointer): bool {.inline.} =
+    result = cast[ptr FreeCell](p).zeroField >% 1
 
-proc ContainsOrIncl(s: var TIntSet, key: int): bool = 
-  var t = IntSetGet(s, key shr TrunkShift)
-  if t != nil: 
-    var u = key and TrunkMask
-    result = (t.bits[u shr IntShift] and (1 shl (u and IntMask))) != 0
-    if not result: 
-      t.bits[u shr IntShift] = t.bits[u shr IntShift] or
-          (1 shl (u and IntMask))
-  else: 
-    Incl(s, key)
-    result = false
-   
 # ------------- chunk management ----------------------------------------------
-proc pageIndex(c: PChunk): int {.inline.} = 
-  result = cast[TAddress](c) shr PageShift
+proc pageIndex(c: PChunk): int {.inline.} =
+  result = cast[int](c) shr PageShift
 
-proc pageIndex(p: pointer): int {.inline.} = 
-  result = cast[TAddress](p) shr PageShift
+proc pageIndex(p: pointer): int {.inline.} =
+  result = cast[int](p) shr PageShift
 
-proc pageAddr(p: pointer): PChunk {.inline.} = 
-  result = cast[PChunk](cast[TAddress](p) and not PageMask)
-  assert(Contains(allocator.chunkStarts, pageIndex(result)))
+proc pageAddr(p: pointer): PChunk {.inline.} =
+  result = cast[PChunk](cast[int](p) and not PageMask)
+  #sysAssert(Contains(allocator.chunkStarts, pageIndex(result)))
 
-var lastSize = PageSize
+when false:
+  proc writeFreeList(a: MemRegion) =
+    var it = a.freeChunksList
+    c_fprintf(stdout, "freeChunksList: %p\n", it)
+    while it != nil:
+      c_fprintf(stdout, "it: %p, next: %p, prev: %p, size: %ld\n",
+                it, it.next, it.prev, it.size)
+      it = it.next
+
+proc requestOsChunks(a: var MemRegion, size: int): PBigChunk =
+  when not defined(emscripten):
+    if not a.blockChunkSizeIncrease:
+      let usedMem = a.occ #a.currMem # - a.freeMem
+      if usedMem < 64 * 1024:
+        a.nextChunkSize = PageSize*4
+      else:
+        a.nextChunkSize = min(roundup(usedMem shr 2, PageSize), a.nextChunkSize * 2)
+        a.nextChunkSize = min(a.nextChunkSize, MaxBigChunkSize).int
+
+  var size = size
+  if size > a.nextChunkSize:
+    result = cast[PBigChunk](allocPages(a, size))
+  else:
+    result = cast[PBigChunk](tryAllocPages(a, a.nextChunkSize))
+    if result == nil:
+      result = cast[PBigChunk](allocPages(a, size))
+      a.blockChunkSizeIncrease = true
+    else:
+      size = a.nextChunkSize
 
-proc requestOsChunks(a: var TAllocator, size: int): PBigChunk = 
   incCurrMem(a, size)
   inc(a.freeMem, size)
-  result = cast[PBigChunk](osAllocPages(size))
-  assert((cast[TAddress](result) and PageMask) == 0)
+  let heapLink = a.addHeapLink(result, size)
+  when defined(debugHeapLinks):
+    cprintf("owner: %p; result: %p; next pointer %p; size: %ld\n", addr(a),
+      result, heapLink, size)
+
+  when defined(memtracker):
+    trackLocation(addr result.size, sizeof(int))
+
+  sysAssert((cast[int](result) and PageMask) == 0, "requestOsChunks 1")
   #zeroMem(result, size)
   result.next = nil
   result.prev = nil
-  result.used = false
   result.size = size
   # update next.prevSize:
-  var nxt = cast[TAddress](result) +% size
-  assert((nxt and PageMask) == 0)
+  var nxt = cast[int](result) +% size
+  sysAssert((nxt and PageMask) == 0, "requestOsChunks 2")
   var next = cast[PChunk](nxt)
   if pageIndex(next) in a.chunkStarts:
     #echo("Next already allocated!")
-    next.prevSize = size
+    next.prevSize = size or (next.prevSize and 1)
   # set result.prevSize:
-  var prv = cast[TAddress](result) -% lastSize
-  assert((nxt and PageMask) == 0)
+  var lastSize = if a.lastSize != 0: a.lastSize else: PageSize
+  var prv = cast[int](result) -% lastSize
+  sysAssert((nxt and PageMask) == 0, "requestOsChunks 3")
   var prev = cast[PChunk](prv)
   if pageIndex(prev) in a.chunkStarts and prev.size == lastSize:
     #echo("Prev already allocated!")
-    result.prevSize = lastSize
+    result.prevSize = lastSize or (result.prevSize and 1)
   else:
-    result.prevSize = 0 # unknown
-  lastSize = size # for next request
-
-proc freeOsChunks(a: var TAllocator, p: pointer, size: int) = 
-  # update next.prevSize:
-  var c = cast[PChunk](p)
-  var nxt = cast[TAddress](p) +% c.size
-  assert((nxt and PageMask) == 0)
-  var next = cast[PChunk](nxt)
-  if pageIndex(next) in a.chunkStarts:
-    next.prevSize = 0 # XXX used
-  excl(a.chunkStarts, pageIndex(p))
-  osDeallocPages(p, size)
-  decCurrMem(a, size)
-  dec(a.freeMem, size)
-  #c_fprintf(c_stdout, "[Alloc] back to OS: %ld\n", size)
+    result.prevSize = 0 or (result.prevSize and 1) # unknown
+    # but do not overwrite 'used' field
+  a.lastSize = size # for next request
+  sysAssert((cast[int](result) and PageMask) == 0, "requestOschunks: unaligned chunk")
 
-proc isAccessible(p: pointer): bool {.inline.} = 
-  result = Contains(allocator.chunkStarts, pageIndex(p))
+proc isAccessible(a: MemRegion, p: pointer): bool {.inline.} =
+  result = contains(a.chunkStarts, pageIndex(p))
 
-proc contains[T](list, x: T): bool = 
+proc contains[T](list, x: T): bool =
   var it = list
   while it != nil:
     if it == x: return true
     it = it.next
-    
-proc writeFreeList(a: TAllocator) =
-  var it = a.freeChunksList
-  c_fprintf(c_stdout, "freeChunksList: %p\n", it)
-  while it != nil: 
-    c_fprintf(c_stdout, "it: %p, next: %p, prev: %p\n", 
-              it, it.next, it.prev)
-    it = it.next
 
-proc ListAdd[T](head: var T, c: T) {.inline.} = 
-  assert(c notin head)
-  assert c.prev == nil
-  assert c.next == nil
+proc listAdd[T](head: var T, c: T) {.inline.} =
+  sysAssert(c notin head, "listAdd 1")
+  sysAssert c.prev == nil, "listAdd 2"
+  sysAssert c.next == nil, "listAdd 3"
   c.next = head
-  if head != nil: 
-    assert head.prev == nil
+  if head != nil:
+    sysAssert head.prev == nil, "listAdd 4"
     head.prev = c
   head = c
 
-proc ListRemove[T](head: var T, c: T) {.inline.} =
-  assert(c in head)
-  if c == head: 
+proc listRemove[T](head: var T, c: T) {.inline.} =
+  sysAssert(c in head, "listRemove")
+  if c == head:
     head = c.next
-    assert c.prev == nil
+    sysAssert c.prev == nil, "listRemove 2"
     if head != nil: head.prev = nil
   else:
-    assert c.prev != nil
+    sysAssert c.prev != nil, "listRemove 3"
     c.prev.next = c.next
     if c.next != nil: c.next.prev = c.prev
   c.next = nil
   c.prev = nil
-  
-proc isSmallChunk(c: PChunk): bool {.inline.} = 
-  return c.size <= SmallChunkSize-smallChunkOverhead()
-  #return c.size < SmallChunkSize
-  
-proc chunkUnused(c: PChunk): bool {.inline.} = 
-  result = not c.used
-  
-proc updatePrevSize(a: var TAllocator, c: PBigChunk, 
-                    prevSize: int) {.inline.} = 
-  var ri = cast[PChunk](cast[TAddress](c) +% c.size)
-  assert((cast[TAddress](ri) and PageMask) == 0)
-  if isAccessible(ri):
-    ri.prevSize = prevSize
-  
-proc freeBigChunk(a: var TAllocator, c: PBigChunk) = 
+
+proc updatePrevSize(a: var MemRegion, c: PBigChunk,
+                    prevSize: int) {.inline.} =
+  var ri = cast[PChunk](cast[int](c) +% c.size)
+  sysAssert((cast[int](ri) and PageMask) == 0, "updatePrevSize")
+  if isAccessible(a, ri):
+    ri.prevSize = prevSize or (ri.prevSize and 1)
+
+proc splitChunk2(a: var MemRegion, c: PBigChunk, size: int): PBigChunk =
+  result = cast[PBigChunk](cast[int](c) +% size)
+  result.size = c.size - size
+  track("result.size", addr result.size, sizeof(int))
+  when not defined(nimOptimizedSplitChunk):
+    # still active because of weird codegen issue on some of our CIs:
+    result.next = nil
+    result.prev = nil
+  # size and not used:
+  result.prevSize = size
+  result.owner = addr a
+  sysAssert((size and 1) == 0, "splitChunk 2")
+  sysAssert((size and PageMask) == 0,
+      "splitChunk: size is not a multiple of the PageSize")
+  updatePrevSize(a, c, result.size)
+  c.size = size
+  incl(a, a.chunkStarts, pageIndex(result))
+
+proc splitChunk(a: var MemRegion, c: PBigChunk, size: int) =
+  let rest = splitChunk2(a, c, size)
+  addChunkToMatrix(a, rest)
+
+proc freeBigChunk(a: var MemRegion, c: PBigChunk) =
   var c = c
-  assert(c.size >= PageSize)
+  sysAssert(c.size >= PageSize, "freeBigChunk")
   inc(a.freeMem, c.size)
-  when coalescRight:
-    var ri = cast[PChunk](cast[TAddress](c) +% c.size)
-    assert((cast[TAddress](ri) and PageMask) == 0)
-    if isAccessible(ri) and chunkUnused(ri):
-      assert(not isSmallChunk(ri))
-      if not isSmallChunk(ri):
-        ListRemove(a.freeChunksList, cast[PBigChunk](ri))
-        inc(c.size, ri.size)
-        excl(a.chunkStarts, pageIndex(ri))
+  c.prevSize = c.prevSize and not 1  # set 'used' to false
   when coalescLeft:
-    if c.prevSize != 0: 
-      var le = cast[PChunk](cast[TAddress](c) -% c.prevSize)
-      assert((cast[TAddress](le) and PageMask) == 0)
-      if isAccessible(le) and chunkUnused(le):
-        assert(not isSmallChunk(le))
-        if not isSmallChunk(le):
-          ListRemove(a.freeChunksList, cast[PBigChunk](le))
+    let prevSize = c.prevSize
+    if prevSize != 0:
+      var le = cast[PChunk](cast[int](c) -% prevSize)
+      sysAssert((cast[int](le) and PageMask) == 0, "freeBigChunk 4")
+      if isAccessible(a, le) and chunkUnused(le):
+        sysAssert(not isSmallChunk(le), "freeBigChunk 5")
+        if not isSmallChunk(le) and le.size < MaxBigChunkSize:
+          removeChunkFromMatrix(a, cast[PBigChunk](le))
           inc(le.size, c.size)
           excl(a.chunkStarts, pageIndex(c))
           c = cast[PBigChunk](le)
+          if c.size > MaxBigChunkSize:
+            let rest = splitChunk2(a, c, MaxBigChunkSize)
+            when defined(nimOptimizedSplitChunk):
+              rest.next = nil
+              rest.prev = nil
+            addChunkToMatrix(a, c)
+            c = rest
+  when coalescRight:
+    var ri = cast[PChunk](cast[int](c) +% c.size)
+    sysAssert((cast[int](ri) and PageMask) == 0, "freeBigChunk 2")
+    if isAccessible(a, ri) and chunkUnused(ri):
+      sysAssert(not isSmallChunk(ri), "freeBigChunk 3")
+      if not isSmallChunk(ri) and c.size < MaxBigChunkSize:
+        removeChunkFromMatrix(a, cast[PBigChunk](ri))
+        inc(c.size, ri.size)
+        excl(a.chunkStarts, pageIndex(ri))
+        if c.size > MaxBigChunkSize:
+          let rest = splitChunk2(a, c, MaxBigChunkSize)
+          addChunkToMatrix(a, rest)
+  addChunkToMatrix(a, c)
 
-  if c.size < ChunkOsReturn: 
-    incl(a.chunkStarts, pageIndex(c))
-    updatePrevSize(a, c, c.size)
-    ListAdd(a.freeChunksList, c)
-    c.used = false
-  else:
-    freeOsChunks(a, c, c.size)
-
-proc splitChunk(a: var TAllocator, c: PBigChunk, size: int) = 
-  var rest = cast[PBigChunk](cast[TAddress](c) +% size)
-  if rest in a.freeChunksList: 
-    c_fprintf(c_stdout, "to add: %p\n", rest)
-    writeFreeList(allocator)
-    assert false
-  rest.size = c.size - size
-  rest.used = false
-  rest.next = nil
-  rest.prev = nil
-  rest.prevSize = size
-  updatePrevSize(a, c, rest.size)
-  c.size = size
-  incl(a.chunkStarts, pageIndex(rest))
-  ListAdd(a.freeChunksList, rest)
-
-proc getBigChunk(a: var TAllocator, size: int): PBigChunk = 
-  # use first fit for now:
-  assert((size and PageMask) == 0)
-  assert(size > 0)
-  result = a.freeChunksList
-  block search:
-    while result != nil:
-      #if not chunkUnused(result): 
-      #  c_fprintf(c_stdout, "%lld\n", int(result.used))
-      assert chunkUnused(result)
-      if result.size == size: 
-        ListRemove(a.freeChunksList, result)
-        break search
-      elif result.size > size:
-        #c_fprintf(c_stdout, "res size: %lld; size: %lld\n", result.size, size)
-        ListRemove(a.freeChunksList, result)
-        splitChunk(a, result, size)
-        break search
-      result = result.next
-      assert result != a.freeChunksList
-    if size < InitialMemoryRequest: 
-      result = requestOsChunks(a, InitialMemoryRequest)
+proc getBigChunk(a: var MemRegion, size: int): PBigChunk =
+  sysAssert(size > 0, "getBigChunk 2")
+  var size = size # roundup(size, PageSize)
+  var fl = 0
+  var sl = 0
+  mappingSearch(size, fl, sl)
+  sysAssert((size and PageMask) == 0, "getBigChunk: unaligned chunk")
+  result = findSuitableBlock(a, fl, sl)
+
+  when RegionHasLock:
+    if not a.lockActive:
+      a.lockActive = true
+      initSysLock(a.lock)
+    acquireSys a.lock
+
+  if result == nil:
+    if size < nimMinHeapPages * PageSize:
+      result = requestOsChunks(a, nimMinHeapPages * PageSize)
       splitChunk(a, result, size)
     else:
       result = requestOsChunks(a, size)
-  result.prevSize = 0 # XXX why is this needed?
-  result.used = true
-  incl(a.chunkStarts, pageIndex(result))
+      # if we over allocated split the chunk:
+      if result.size > size:
+        splitChunk(a, result, size)
+    result.owner = addr a
+  else:
+    removeChunkFromMatrix2(a, result, fl, sl)
+    if result.size >= size + PageSize:
+      splitChunk(a, result, size)
+  # set 'used' to to true:
+  result.prevSize = 1
+  track("setUsedToFalse", addr result.size, sizeof(int))
+  sysAssert result.owner == addr a, "getBigChunk: No owner set!"
+
+  incl(a, a.chunkStarts, pageIndex(result))
   dec(a.freeMem, size)
+  when RegionHasLock:
+    releaseSys a.lock
+
+proc getHugeChunk(a: var MemRegion; size: int): PBigChunk =
+  result = cast[PBigChunk](allocPages(a, size))
+  when RegionHasLock:
+    if not a.lockActive:
+      a.lockActive = true
+      initSysLock(a.lock)
+    acquireSys a.lock
+  incCurrMem(a, size)
+  # XXX add this to the heap links. But also remove it from it later.
+  when false: a.addHeapLink(result, size)
+  sysAssert((cast[int](result) and PageMask) == 0, "getHugeChunk")
+  result.next = nil
+  result.prev = nil
+  result.size = size
+  # set 'used' to to true:
+  result.prevSize = 1
+  result.owner = addr a
+  incl(a, a.chunkStarts, pageIndex(result))
+  when RegionHasLock:
+    releaseSys a.lock
 
-proc getSmallChunk(a: var TAllocator): PSmallChunk = 
+proc freeHugeChunk(a: var MemRegion; c: PBigChunk) =
+  let size = c.size
+  sysAssert(size >= HugeChunkSize, "freeHugeChunk: invalid size")
+  excl(a.chunkStarts, pageIndex(c))
+  decCurrMem(a, size)
+  osDeallocPages(c, size)
+
+proc getSmallChunk(a: var MemRegion): PSmallChunk =
   var res = getBigChunk(a, PageSize)
-  assert res.prev == nil
-  assert res.next == nil
+  sysAssert res.prev == nil, "getSmallChunk 1"
+  sysAssert res.next == nil, "getSmallChunk 2"
   result = cast[PSmallChunk](res)
 
 # -----------------------------------------------------------------------------
+when not defined(gcDestructors):
+  proc isAllocatedPtr(a: MemRegion, p: pointer): bool {.benign.}
 
-proc getCellSize(p: pointer): int {.inline.} = 
-  var c = pageAddr(p)
-  result = c.size
-  
-proc rawAlloc(a: var TAllocator, requestedSize: int): pointer =
-  assert(roundup(65, 8) == 72)
-  assert requestedSize >= sizeof(TFreeCell)
+when true:
+  template allocInv(a: MemRegion): bool = true
+else:
+  proc allocInv(a: MemRegion): bool =
+    ## checks some (not all yet) invariants of the allocator's data structures.
+    for s in low(a.freeSmallChunks)..high(a.freeSmallChunks):
+      var c = a.freeSmallChunks[s]
+      while not (c == nil):
+        if c.next == c:
+          echo "[SYSASSERT] c.next == c"
+          return false
+        if not (c.size == s * MemAlign):
+          echo "[SYSASSERT] c.size != s * MemAlign"
+          return false
+        var it = c.freeList
+        while not (it == nil):
+          if not (it.zeroField == 0):
+            echo "[SYSASSERT] it.zeroField != 0"
+            c_printf("%ld %p\n", it.zeroField, it)
+            return false
+          it = it.next
+        c = c.next
+    result = true
+
+when false:
+  var
+    rsizes: array[50_000, int]
+    rsizesLen: int
+
+  proc trackSize(size: int) =
+    rsizes[rsizesLen] = size
+    inc rsizesLen
+
+  proc untrackSize(size: int) =
+    for i in 0 .. rsizesLen-1:
+      if rsizes[i] == size:
+        rsizes[i] = rsizes[rsizesLen-1]
+        dec rsizesLen
+        return
+    c_fprintf(stdout, "%ld\n", size)
+    sysAssert(false, "untracked size!")
+else:
+  template trackSize(x) = discard
+  template untrackSize(x) = discard
+
+proc deallocBigChunk(a: var MemRegion, c: PBigChunk) =
+  when RegionHasLock:
+    acquireSys a.lock
+  dec a.occ, c.size
+  untrackSize(c.size)
+  sysAssert a.occ >= 0, "rawDealloc: negative occupied memory (case B)"
+  when not defined(gcDestructors):
+    a.deleted = getBottom(a)
+    del(a, a.root, cast[int](addr(c.data)))
+  if c.size >= HugeChunkSize: freeHugeChunk(a, c)
+  else: freeBigChunk(a, c)
+  when RegionHasLock:
+    releaseSys a.lock
+
+when defined(gcDestructors):
+  template atomicPrepend(head, elem: untyped) =
+    # see also https://en.cppreference.com/w/cpp/atomic/atomic_compare_exchange
+    when hasThreadSupport:
+      while true:
+        elem.next.storea head.loada
+        if atomicCompareExchangeN(addr head, addr elem.next, elem, weak = true, ATOMIC_RELEASE, ATOMIC_RELAXED):
+          break
+    else:
+      elem.next.storea head.loada
+      head.storea elem
+
+  proc addToSharedFreeListBigChunks(a: var MemRegion; c: PBigChunk) {.inline.} =
+    sysAssert c.next == nil, "c.next pointer must be nil"
+    atomicPrepend a.sharedFreeListBigChunks, c
+
+  proc addToSharedFreeList(c: PSmallChunk; f: ptr FreeCell; size: int) {.inline.} =
+    atomicPrepend c.owner.sharedFreeLists[size], f
+
+  const MaxSteps = 20
+
+  proc compensateCounters(a: var MemRegion; c: PSmallChunk; size: int) =
+    # rawDealloc did NOT do the usual:
+    # `inc(c.free, size); dec(a.occ, size)` because it wasn't the owner of these
+    # memory locations. We have to compensate here for these for the entire list.
+    var it = c.freeList
+    var total = 0
+    while it != nil:
+      inc total, size
+      let chunk = cast[PSmallChunk](pageAddr(it))
+      if c != chunk:
+        # The cell is foreign, potentially even from a foreign thread.
+        # It must block the current chunk from being freed, as doing so would leak memory.
+        inc c.foreignCells
+      it = it.next
+    # By not adjusting the foreign chunk we reserve space in it to prevent deallocation
+    inc(c.free, total)
+    dec(a.occ, total)
+
+  proc freeDeferredObjects(a: var MemRegion; root: PBigChunk) =
+    var it = root
+    var maxIters = MaxSteps # make it time-bounded
+    while true:
+      let rest = it.next.loada
+      it.next.storea nil
+      deallocBigChunk(a, cast[PBigChunk](it))
+      if maxIters == 0:
+        if rest != nil:
+          addToSharedFreeListBigChunks(a, rest)
+          sysAssert a.sharedFreeListBigChunks != nil, "re-enqueing failed"
+        break
+      it = rest
+      dec maxIters
+      if it == nil: break
+
+proc rawAlloc(a: var MemRegion, requestedSize: int): pointer =
+  when defined(nimTypeNames):
+    inc(a.allocCounter)
+  sysAssert(allocInv(a), "rawAlloc: begin")
+  sysAssert(roundup(65, 8) == 72, "rawAlloc: roundup broken")
   var size = roundup(requestedSize, MemAlign)
-  #c_fprintf(c_stdout, "alloc; size: %ld; %ld\n", requestedSize, size)
-  if size <= SmallChunkSize-smallChunkOverhead(): 
+  sysAssert(size >= sizeof(FreeCell), "rawAlloc: requested size too small")
+  sysAssert(size >= requestedSize, "insufficient allocated size!")
+  #c_fprintf(stdout, "alloc; size: %ld; %ld\n", requestedSize, size)
+
+  if size <= SmallChunkSize-smallChunkOverhead():
+    template fetchSharedCells(tc: PSmallChunk) =
+      # Consumes cells from (potentially) foreign threads from `a.sharedFreeLists[s]`
+      when defined(gcDestructors):
+        if tc.freeList == nil:
+          when hasThreadSupport:
+            # Steal the entire list from `sharedFreeList`:
+            tc.freeList = atomicExchangeN(addr a.sharedFreeLists[s], nil, ATOMIC_RELAXED)
+          else:
+            tc.freeList = a.sharedFreeLists[s]
+            a.sharedFreeLists[s] = nil
+          # if `tc.freeList` isn't nil, `tc` will gain capacity.
+          # We must calculate how much it gained and how many foreign cells are included.
+          compensateCounters(a, tc, size)
+
     # allocate a small block: for small chunks, we use only its next pointer
-    var s = size div MemAlign
+    let s = size div MemAlign
     var c = a.freeSmallChunks[s]
-    if c == nil: 
+    if c == nil:
+      # There is no free chunk of the requested size available, we need a new one.
       c = getSmallChunk(a)
+      # init all fields in case memory didn't get zeroed
       c.freeList = nil
-      assert c.size == PageSize
+      c.foreignCells = 0
+      sysAssert c.size == PageSize, "rawAlloc 3"
       c.size = size
-      c.acc = size
-      c.free = SmallChunkSize - smallChunkOverhead() - size
+      c.acc = size.uint32
+      c.free = SmallChunkSize - smallChunkOverhead() - size.int32
+      sysAssert c.owner == addr(a), "rawAlloc: No owner set!"
       c.next = nil
       c.prev = nil
-      ListAdd(a.freeSmallChunks[s], c)
+      # Shared cells are fetched here in case `c.size * 2 >= SmallChunkSize - smallChunkOverhead()`.
+      # For those single cell chunks, we would otherwise have to allocate a new one almost every time.
+      fetchSharedCells(c)
+      if c.free >= size:
+        # Because removals from `a.freeSmallChunks[s]` only happen in the other alloc branch and during dealloc,
+        #  we must not add it to the list if it cannot be used the next time a pointer of `size` bytes is needed.
+        listAdd(a.freeSmallChunks[s], c)
       result = addr(c.data)
-      assert((cast[TAddress](result) and (MemAlign-1)) == 0)
+      sysAssert((cast[int](result) and (MemAlign-1)) == 0, "rawAlloc 4")
     else:
-      assert c.next != c
+      # There is a free chunk of the requested size available, use it.
+      sysAssert(allocInv(a), "rawAlloc: begin c != nil")
+      sysAssert c.next != c, "rawAlloc 5"
       #if c.size != size:
-      #  c_fprintf(c_stdout, "csize: %lld; size %lld\n", c.size, size)
-      assert c.size == size
+      #  c_fprintf(stdout, "csize: %lld; size %lld\n", c.size, size)
+      sysAssert c.size == size, "rawAlloc 6"
       if c.freeList == nil:
-        assert(c.acc + smallChunkOverhead() + size <= SmallChunkSize) 
-        result = cast[pointer](cast[TAddress](addr(c.data)) +% c.acc)
-        inc(c.acc, size)      
+        sysAssert(c.acc.int + smallChunkOverhead() + size <= SmallChunkSize,
+                  "rawAlloc 7")
+        result = cast[pointer](cast[int](addr(c.data)) +% c.acc.int)
+        inc(c.acc, size)
       else:
+        # There are free cells available, prefer them over the accumulator
         result = c.freeList
-        assert(c.freeList.zeroField == 0)
+        when not defined(gcDestructors):
+          sysAssert(c.freeList.zeroField == 0, "rawAlloc 8")
         c.freeList = c.freeList.next
+        if cast[PSmallChunk](pageAddr(result)) != c:
+          # This cell isn't a blocker for the current chunk's deallocation anymore
+          dec(c.foreignCells)
+        else:
+          sysAssert(c == cast[PSmallChunk](pageAddr(result)), "rawAlloc: Bad cell")
+      # Even if the cell we return is foreign, the local chunk's capacity decreases.
+      # The capacity was previously reserved in the source chunk (when it first got allocated),
+      #  then added into the current chunk during dealloc,
+      #  so the source chunk will not be freed or leak memory because of this.
       dec(c.free, size)
-      assert((cast[TAddress](result) and (MemAlign-1)) == 0)
-    if c.free < size: 
-      ListRemove(a.freeSmallChunks[s], c)
+      sysAssert((cast[int](result) and (MemAlign-1)) == 0, "rawAlloc 9")
+      sysAssert(allocInv(a), "rawAlloc: end c != nil")
+      # We fetch deferred cells *after* advancing `c.freeList`/`acc` to adjust `c.free`.
+      # If after the adjustment it turns out there's free cells available,
+      #  the chunk stays in `a.freeSmallChunks[s]` and the need for a new chunk is delayed.
+      fetchSharedCells(c)
+      sysAssert(allocInv(a), "rawAlloc: before c.free < size")
+      if c.free < size:
+        # Even after fetching shared cells the chunk has no usable memory left. It is no longer the active chunk
+        sysAssert(allocInv(a), "rawAlloc: before listRemove test")
+        listRemove(a.freeSmallChunks[s], c)
+        sysAssert(allocInv(a), "rawAlloc: end listRemove test")
+    sysAssert(((cast[int](result) and PageMask) - smallChunkOverhead()) %%
+               size == 0, "rawAlloc 21")
+    sysAssert(allocInv(a), "rawAlloc: end small size")
+    inc a.occ, size
+    trackSize(c.size)
   else:
-    size = roundup(requestedSize+bigChunkOverhead(), PageSize)
+    when defined(gcDestructors):
+      when hasThreadSupport:
+        let deferredFrees = atomicExchangeN(addr a.sharedFreeListBigChunks, nil, ATOMIC_RELAXED)
+      else:
+        let deferredFrees = a.sharedFreeListBigChunks
+        a.sharedFreeListBigChunks = nil
+      if deferredFrees != nil:
+        freeDeferredObjects(a, deferredFrees)
+
+    size = requestedSize + bigChunkOverhead() #  roundup(requestedSize+bigChunkOverhead(), PageSize)
     # allocate a large block
-    var c = getBigChunk(a, size)
-    assert c.prev == nil
-    assert c.next == nil
-    assert c.size == size
+    var c = if size >= HugeChunkSize: getHugeChunk(a, size)
+            else: getBigChunk(a, size)
+    sysAssert c.prev == nil, "rawAlloc 10"
+    sysAssert c.next == nil, "rawAlloc 11"
     result = addr(c.data)
-    assert((cast[TAddress](result) and (MemAlign-1)) == 0)
-  assert(isAccessible(result))
+    sysAssert((cast[int](c) and (MemAlign-1)) == 0, "rawAlloc 13")
+    sysAssert((cast[int](c) and PageMask) == 0, "rawAlloc: Not aligned on a page boundary")
+    when not defined(gcDestructors):
+      if a.root == nil: a.root = getBottom(a)
+      add(a, a.root, cast[int](result), cast[int](result)+%size)
+    inc a.occ, c.size
+    trackSize(c.size)
+  sysAssert(isAccessible(a, result), "rawAlloc 14")
+  sysAssert(allocInv(a), "rawAlloc: end")
+  when logAlloc: cprintf("var pointer_%p = alloc(%ld) # %p\n", result, requestedSize, addr a)
 
-proc rawDealloc(a: var TAllocator, p: pointer) = 
+proc rawAlloc0(a: var MemRegion, requestedSize: int): pointer =
+  result = rawAlloc(a, requestedSize)
+  zeroMem(result, requestedSize)
+
+proc rawDealloc(a: var MemRegion, p: pointer) =
+  when defined(nimTypeNames):
+    inc(a.deallocCounter)
+  #sysAssert(isAllocatedPtr(a, p), "rawDealloc: no allocated pointer")
+  sysAssert(allocInv(a), "rawDealloc: begin")
   var c = pageAddr(p)
+  sysAssert(c != nil, "rawDealloc: begin")
   if isSmallChunk(c):
     # `p` is within a small chunk:
     var c = cast[PSmallChunk](c)
-    var s = c.size
-    var f = cast[ptr TFreeCell](p)
-    #echo("setting to nil: ", $cast[TAddress](addr(f.zeroField)))
-    assert(f.zeroField != 0)
-    f.zeroField = 0
-    f.next = c.freeList
-    c.freeList = f
-    when overwriteFree: 
-      # set to 0xff to check for usage after free bugs:
-      c_memset(cast[pointer](cast[int](p) +% sizeof(TFreeCell)), -1'i32, 
-               s -% sizeof(TFreeCell))
-    # check if it is not in the freeSmallChunks[s] list:
-    if c.free < s:
-      assert c notin a.freeSmallChunks[s div memAlign]
-      # add it to the freeSmallChunks[s] array:
-      ListAdd(a.freeSmallChunks[s div memAlign], c)
-      inc(c.free, s)
+    let s = c.size
+    #       ^ We might access thread foreign storage here.
+    # The other thread cannot possibly free this block as it's still alive.
+    var f = cast[ptr FreeCell](p)
+    if c.owner == addr(a):
+      # We own the block, there is no foreign thread involved.
+      dec a.occ, s
+      untrackSize(s)
+      sysAssert a.occ >= 0, "rawDealloc: negative occupied memory (case A)"
+      sysAssert(((cast[int](p) and PageMask) - smallChunkOverhead()) %%
+                s == 0, "rawDealloc 3")
+      when not defined(gcDestructors):
+        #echo("setting to nil: ", $cast[int](addr(f.zeroField)))
+        sysAssert(f.zeroField != 0, "rawDealloc 1")
+        f.zeroField = 0
+      when overwriteFree:
+        # set to 0xff to check for usage after free bugs:
+        nimSetMem(cast[pointer](cast[int](p) +% sizeof(FreeCell)), -1'i32,
+                s -% sizeof(FreeCell))
+      let activeChunk = a.freeSmallChunks[s div MemAlign]
+      if activeChunk != nil and c != activeChunk:
+        # This pointer is not part of the active chunk, lend it out
+        #  and do not adjust the current chunk (same logic as compensateCounters.)
+        # Put the cell into the active chunk,
+        #  may prevent a queue of available chunks from forming in a.freeSmallChunks[s div MemAlign].
+        #  This queue would otherwise waste memory in the form of free cells until we return to those chunks.
+        f.next = activeChunk.freeList
+        activeChunk.freeList = f # lend the cell
+        inc(activeChunk.free, s) # By not adjusting the current chunk's capacity it is prevented from being freed
+        inc(activeChunk.foreignCells) # The cell is now considered foreign from the perspective of the active chunk
+      else:
+        f.next = c.freeList
+        c.freeList = f
+        if c.free < s:
+          # The chunk could not have been active as it didn't have enough space to give
+          listAdd(a.freeSmallChunks[s div MemAlign], c)
+          inc(c.free, s)
+        else:
+          inc(c.free, s)
+          # Free only if the entire chunk is unused and there are no borrowed cells.
+          # If the chunk were to be freed while it references foreign cells,
+          #  the foreign chunks will leak memory and can never be freed.
+          if c.free == SmallChunkSize-smallChunkOverhead() and c.foreignCells == 0:
+            listRemove(a.freeSmallChunks[s div MemAlign], c)
+            c.size = SmallChunkSize
+            freeBigChunk(a, cast[PBigChunk](c))
     else:
-      inc(c.free, s)
-      if c.free == SmallChunkSize-smallChunkOverhead():
-        ListRemove(a.freeSmallChunks[s div memAlign], c)
-        c.size = SmallChunkSize
-        freeBigChunk(a, cast[PBigChunk](c))
+      when logAlloc: cprintf("dealloc(pointer_%p) # SMALL FROM %p CALLER %p\n", p, c.owner, addr(a))
+
+      when defined(gcDestructors):
+        addToSharedFreeList(c, f, s div MemAlign)
+    sysAssert(((cast[int](p) and PageMask) - smallChunkOverhead()) %%
+               s == 0, "rawDealloc 2")
   else:
     # set to 0xff to check for usage after free bugs:
-    when overwriteFree: c_memset(p, -1'i32, c.size -% bigChunkOverhead())
-    # free big chunk
-    freeBigChunk(a, cast[PBigChunk](c))
-
-proc isAllocatedPtr(a: TAllocator, p: pointer): bool = 
-  if isAccessible(p):
-    var c = pageAddr(p)
-    if not chunkUnused(c):
-      if isSmallChunk(c):
-        var c = cast[PSmallChunk](c)
-        var offset = (cast[TAddress](p) and (PageSize-1)) -% 
-                     smallChunkOverhead()
-        result = (c.acc >% offset) and (offset %% c.size == 0) and
-          (cast[ptr TFreeCell](p).zeroField >% 1)
+    when overwriteFree: nimSetMem(p, -1'i32, c.size -% bigChunkOverhead())
+    when logAlloc: cprintf("dealloc(pointer_%p) # BIG %p\n", p, c.owner)
+    when defined(gcDestructors):
+      if c.owner == addr(a):
+        deallocBigChunk(a, cast[PBigChunk](c))
       else:
-        var c = cast[PBigChunk](c)
-        result = p == addr(c.data) and cast[ptr TFreeCell](p).zeroField >% 1
+        addToSharedFreeListBigChunks(c.owner[], cast[PBigChunk](c))
+    else:
+      deallocBigChunk(a, cast[PBigChunk](c))
 
-# ---------------------- interface to programs -------------------------------
+  sysAssert(allocInv(a), "rawDealloc: end")
+  #when logAlloc: cprintf("dealloc(pointer_%p)\n", p)
 
-proc alloc(size: int): pointer =
-  result = rawAlloc(allocator, size+sizeof(TFreeCell))
-  cast[ptr TFreeCell](result).zeroField = 1 # mark it as used
-  assert(not isAllocatedPtr(allocator, result))
-  result = cast[pointer](cast[TAddress](result) +% sizeof(TFreeCell))
+when not defined(gcDestructors):
+  proc isAllocatedPtr(a: MemRegion, p: pointer): bool =
+    if isAccessible(a, p):
+      var c = pageAddr(p)
+      if not chunkUnused(c):
+        if isSmallChunk(c):
+          var c = cast[PSmallChunk](c)
+          var offset = (cast[int](p) and (PageSize-1)) -%
+                      smallChunkOverhead()
+          result = (c.acc.int >% offset) and (offset %% c.size == 0) and
+            (cast[ptr FreeCell](p).zeroField >% 1)
+        else:
+          var c = cast[PBigChunk](c)
+          result = p == addr(c.data) and cast[ptr FreeCell](p).zeroField >% 1
 
-proc alloc0(size: int): pointer =
-  result = alloc(size)
-  zeroMem(result, size)
+  proc prepareForInteriorPointerChecking(a: var MemRegion) {.inline.} =
+    a.minLargeObj = lowGauge(a.root)
+    a.maxLargeObj = highGauge(a.root)
 
-proc dealloc(p: pointer) =
-  var x = cast[pointer](cast[TAddress](p) -% sizeof(TFreeCell))
-  assert(cast[ptr TFreeCell](x).zeroField == 1)
-  rawDealloc(allocator, x)
-  assert(not isAllocatedPtr(allocator, x))
+  proc interiorAllocatedPtr(a: MemRegion, p: pointer): pointer =
+    if isAccessible(a, p):
+      var c = pageAddr(p)
+      if not chunkUnused(c):
+        if isSmallChunk(c):
+          var c = cast[PSmallChunk](c)
+          var offset = (cast[int](p) and (PageSize-1)) -%
+                      smallChunkOverhead()
+          if c.acc.int >% offset:
+            sysAssert(cast[int](addr(c.data)) +% offset ==
+                      cast[int](p), "offset is not what you think it is")
+            var d = cast[ptr FreeCell](cast[int](addr(c.data)) +%
+                      offset -% (offset %% c.size))
+            if d.zeroField >% 1:
+              result = d
+              sysAssert isAllocatedPtr(a, result), " result wrong pointer!"
+        else:
+          var c = cast[PBigChunk](c)
+          var d = addr(c.data)
+          if p >= d and cast[ptr FreeCell](d).zeroField >% 1:
+            result = d
+            sysAssert isAllocatedPtr(a, result), " result wrong pointer!"
+    else:
+      var q = cast[int](p)
+      if q >=% a.minLargeObj and q <=% a.maxLargeObj:
+        # this check is highly effective! Test fails for 99,96% of all checks on
+        # an x86-64.
+        var avlNode = inRange(a.root, q)
+        if avlNode != nil:
+          var k = cast[pointer](avlNode.key)
+          var c = cast[PBigChunk](pageAddr(k))
+          sysAssert(addr(c.data) == k, " k is not the same as addr(c.data)!")
+          if cast[ptr FreeCell](k).zeroField >% 1:
+            result = k
+            sysAssert isAllocatedPtr(a, result), " result wrong pointer!"
 
 proc ptrSize(p: pointer): int =
-  var x = cast[pointer](cast[TAddress](p) -% sizeof(TFreeCell))
-  result = pageAddr(x).size - sizeof(TFreeCell)
+  when not defined(gcDestructors):
+    var x = cast[pointer](cast[int](p) -% sizeof(FreeCell))
+    var c = pageAddr(p)
+    sysAssert(not chunkUnused(c), "ptrSize")
+    result = c.size -% sizeof(FreeCell)
+    if not isSmallChunk(c):
+      dec result, bigChunkOverhead()
+  else:
+    var c = pageAddr(p)
+    sysAssert(not chunkUnused(c), "ptrSize")
+    result = c.size
+    if not isSmallChunk(c):
+      dec result, bigChunkOverhead()
+
+proc alloc(allocator: var MemRegion, size: Natural): pointer {.gcsafe.} =
+  when not defined(gcDestructors):
+    result = rawAlloc(allocator, size+sizeof(FreeCell))
+    cast[ptr FreeCell](result).zeroField = 1 # mark it as used
+    sysAssert(not isAllocatedPtr(allocator, result), "alloc")
+    result = cast[pointer](cast[int](result) +% sizeof(FreeCell))
+    track("alloc", result, size)
+  else:
+    result = rawAlloc(allocator, size)
 
-proc realloc(p: pointer, newsize: int): pointer =
+proc alloc0(allocator: var MemRegion, size: Natural): pointer =
+  result = alloc(allocator, size)
+  zeroMem(result, size)
+
+proc dealloc(allocator: var MemRegion, p: pointer) =
+  when not defined(gcDestructors):
+    sysAssert(p != nil, "dealloc: p is nil")
+    var x = cast[pointer](cast[int](p) -% sizeof(FreeCell))
+    sysAssert(x != nil, "dealloc: x is nil")
+    sysAssert(isAccessible(allocator, x), "is not accessible")
+    sysAssert(cast[ptr FreeCell](x).zeroField == 1, "dealloc: object header corrupted")
+    rawDealloc(allocator, x)
+    sysAssert(not isAllocatedPtr(allocator, x), "dealloc: object still accessible")
+    track("dealloc", p, 0)
+  else:
+    rawDealloc(allocator, p)
+
+proc realloc(allocator: var MemRegion, p: pointer, newsize: Natural): pointer =
   if newsize > 0:
-    result = alloc(newsize)
+    result = alloc(allocator, newsize)
     if p != nil:
-      copyMem(result, p, ptrSize(p))
-      dealloc(p)
+      copyMem(result, p, min(ptrSize(p), newsize))
+      dealloc(allocator, p)
   elif p != nil:
-    dealloc(p)
+    dealloc(allocator, p)
 
-proc countFreeMem(): int =
-  # only used for assertions
-  var it = allocator.freeChunksList
-  while it != nil:
-    inc(result, it.size)
-    it = it.next
+proc realloc0(allocator: var MemRegion, p: pointer, oldsize, newsize: Natural): pointer =
+  result = realloc(allocator, p, newsize)
+  if newsize > oldsize:
+    zeroMem(cast[pointer](cast[uint](result) + uint(oldsize)), newsize - oldsize)
+
+proc deallocOsPages(a: var MemRegion) =
+  # we free every 'ordinarily' allocated page by iterating over the page bits:
+  var it = addr(a.heapLinks)
+  while true:
+    let next = it.next
+    for i in 0..it.len-1:
+      let (p, size) = it.chunks[i]
+      when defined(debugHeapLinks):
+        cprintf("owner %p; dealloc A: %p size: %ld; next: %p\n", addr(a),
+          it, size, next)
+      sysAssert size >= PageSize, "origSize too small"
+      osDeallocPages(p, size)
+    it = next
+    if it == nil: break
+  # And then we free the pages that are in use for the page bits:
+  llDeallocAll(a)
+
+proc getFreeMem(a: MemRegion): int {.inline.} = result = a.freeMem
+proc getTotalMem(a: MemRegion): int {.inline.} = result = a.currMem
+proc getOccupiedMem(a: MemRegion): int {.inline.} =
+  result = a.occ
+  # a.currMem - a.freeMem
+
+when defined(nimTypeNames):
+  proc getMemCounters(a: MemRegion): (int, int) {.inline.} =
+    (a.allocCounter, a.deallocCounter)
+
+# ---------------------- thread memory region -------------------------------
+
+template instantiateForRegion(allocator: untyped) {.dirty.} =
+  {.push stackTrace: off.}
+
+  when defined(nimFulldebug):
+    proc interiorAllocatedPtr*(p: pointer): pointer =
+      result = interiorAllocatedPtr(allocator, p)
+
+    proc isAllocatedPtr*(p: pointer): bool =
+      let p = cast[pointer](cast[int](p)-%ByteAddress(sizeof(Cell)))
+      result = isAllocatedPtr(allocator, p)
+
+  proc deallocOsPages = deallocOsPages(allocator)
+
+  proc allocImpl(size: Natural): pointer =
+    result = alloc(allocator, size)
+
+  proc alloc0Impl(size: Natural): pointer =
+    result = alloc0(allocator, size)
+
+  proc deallocImpl(p: pointer) =
+    dealloc(allocator, p)
+
+  proc reallocImpl(p: pointer, newSize: Natural): pointer =
+    result = realloc(allocator, p, newSize)
+
+  proc realloc0Impl(p: pointer, oldSize, newSize: Natural): pointer =
+    result = realloc(allocator, p, newSize)
+    if newSize > oldSize:
+      zeroMem(cast[pointer](cast[uint](result) + uint(oldSize)), newSize - oldSize)
+
+  when false:
+    proc countFreeMem(): int =
+      # only used for assertions
+      var it = allocator.freeChunksList
+      while it != nil:
+        inc(result, it.size)
+        it = it.next
+
+  when hasThreadSupport and not defined(gcDestructors):
+    proc addSysExitProc(quitProc: proc() {.noconv.}) {.importc: "atexit", header: "<stdlib.h>".}
+
+    var sharedHeap: MemRegion
+    var heapLock: SysLock
+    initSysLock(heapLock)
+    addSysExitProc(proc() {.noconv.} = deinitSys(heapLock))
+
+  proc getFreeMem(): int =
+    #sysAssert(result == countFreeMem())
+    result = allocator.freeMem
+
+  proc getTotalMem(): int =
+    result = allocator.currMem
+
+  proc getOccupiedMem(): int =
+    result = allocator.occ #getTotalMem() - getFreeMem()
+
+  proc getMaxMem*(): int =
+    result = getMaxMem(allocator)
+
+  when defined(nimTypeNames):
+    proc getMemCounters*(): (int, int) = getMemCounters(allocator)
+
+  # -------------------- shared heap region ----------------------------------
+
+  proc allocSharedImpl(size: Natural): pointer =
+    when hasThreadSupport and not defined(gcDestructors):
+      acquireSys(heapLock)
+      result = alloc(sharedHeap, size)
+      releaseSys(heapLock)
+    else:
+      result = allocImpl(size)
+
+  proc allocShared0Impl(size: Natural): pointer =
+    result = allocSharedImpl(size)
+    zeroMem(result, size)
+
+  proc deallocSharedImpl(p: pointer) =
+    when hasThreadSupport and not defined(gcDestructors):
+      acquireSys(heapLock)
+      dealloc(sharedHeap, p)
+      releaseSys(heapLock)
+    else:
+      deallocImpl(p)
+
+  proc reallocSharedImpl(p: pointer, newSize: Natural): pointer =
+    when hasThreadSupport and not defined(gcDestructors):
+      acquireSys(heapLock)
+      result = realloc(sharedHeap, p, newSize)
+      releaseSys(heapLock)
+    else:
+      result = reallocImpl(p, newSize)
+
+  proc reallocShared0Impl(p: pointer, oldSize, newSize: Natural): pointer =
+    when hasThreadSupport and not defined(gcDestructors):
+      acquireSys(heapLock)
+      result = realloc0(sharedHeap, p, oldSize, newSize)
+      releaseSys(heapLock)
+    else:
+      result = realloc0Impl(p, oldSize, newSize)
+
+  when hasThreadSupport:
+    when defined(gcDestructors):
+      proc getFreeSharedMem(): int =
+        allocator.freeMem
+
+      proc getTotalSharedMem(): int =
+        allocator.currMem
+
+      proc getOccupiedSharedMem(): int =
+        allocator.occ
+
+    else:
+      template sharedMemStatsShared(v: int) =
+        acquireSys(heapLock)
+        result = v
+        releaseSys(heapLock)
+
+      proc getFreeSharedMem(): int =
+        sharedMemStatsShared(sharedHeap.freeMem)
+
+      proc getTotalSharedMem(): int =
+        sharedMemStatsShared(sharedHeap.currMem)
+
+      proc getOccupiedSharedMem(): int =
+        sharedMemStatsShared(sharedHeap.occ)
+        #sharedMemStatsShared(sharedHeap.currMem - sharedHeap.freeMem)
+  {.pop.}
 
-proc getFreeMem(): int = 
-  result = allocator.freeMem
-  #assert(result == countFreeMem())
-
-proc getTotalMem(): int = return allocator.currMem
-proc getOccupiedMem(): int = return getTotalMem() - getFreeMem()
-
-when isMainModule:
-  const iterations = 4000_000
-  incl(allocator.chunkStarts, 11)
-  assert 11 in allocator.chunkStarts
-  excl(allocator.chunkStarts, 11)
-  assert 11 notin allocator.chunkStarts
-  var p: array [1..iterations, pointer]
-  for i in 7..7:
-    var x = i * 8
-    for j in 1.. iterations:
-      p[j] = alloc(allocator, x)
-    for j in 1..iterations:
-      assert isAllocatedPtr(allocator, p[j])
-    echo($i, " used memory: ", $(allocator.currMem))
-    for j in countdown(iterations, 1):
-      #echo("j: ", $j)
-      dealloc(allocator, p[j])
-      assert(not isAllocatedPtr(allocator, p[j]))
-    echo($i, " after freeing: ", $(allocator.currMem))
-    
+{.pop.}
diff --git a/lib/system/ansi_c.nim b/lib/system/ansi_c.nim
index e9300949b..3098e17d6 100755..100644
--- a/lib/system/ansi_c.nim
+++ b/lib/system/ansi_c.nim
@@ -1,105 +1,233 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-# This include file contains headers of Ansi C procs
-# and definitions of Ansi C types in Nimrod syntax
+# This module contains headers of Ansi C procs
+# and definitions of Ansi C types in Nim syntax
 # All symbols are prefixed with 'c_' to avoid ambiguities
 
-{.push hints:off}
-
-proc c_strcmp(a, b: CString): cint {.nodecl, noSideEffect, importc: "strcmp".}
-proc c_memcmp(a, b: CString, size: cint): cint {.
-  nodecl, noSideEffect, importc: "memcmp".}
-proc c_memcpy(a, b: CString, size: cint) {.nodecl, importc: "memcpy".}
-proc c_strlen(a: CString): int {.nodecl, noSideEffect, importc: "strlen".}
-proc c_memset(p: pointer, value: cint, size: int) {.nodecl, importc: "memset".}
-
-type
-  C_TextFile {.importc: "FILE", nodecl, final.} = object   # empty record for
-                                                           # data hiding
-  C_BinaryFile {.importc: "FILE", nodecl, final.} = object
-  C_TextFileStar = ptr CTextFile
-  C_BinaryFileStar = ptr CBinaryFile
-
-  C_JmpBuf {.importc: "jmp_buf".} = array[0..31, int]
-
-var
-  c_stdin {.importc: "stdin", noDecl.}: C_TextFileStar
-  c_stdout {.importc: "stdout", noDecl.}: C_TextFileStar
-  c_stderr {.importc: "stderr", noDecl.}: C_TextFileStar
-
-var # constants faked as variables:
-  SIGINT {.importc: "SIGINT", nodecl.}: cint
-  SIGSEGV {.importc: "SIGSEGV", nodecl.}: cint
-  SIGABRT {.importc: "SIGABRT", nodecl.}: cint
-  SIGFPE {.importc: "SIGFPE", nodecl.}: cint
-  SIGILL {.importc: "SIGILL", nodecl.}: cint
+{.push hints:off, stack_trace: off, profiler: off.}
+
+proc c_memchr*(s: pointer, c: cint, n: csize_t): pointer {.
+  importc: "memchr", header: "<string.h>".}
+proc c_memcmp*(a, b: pointer, size: csize_t): cint {.
+  importc: "memcmp", header: "<string.h>", noSideEffect.}
+proc c_memcpy*(a, b: pointer, size: csize_t): pointer {.
+  importc: "memcpy", header: "<string.h>", discardable.}
+proc c_memmove*(a, b: pointer, size: csize_t): pointer {.
+  importc: "memmove", header: "<string.h>",discardable.}
+proc c_memset*(p: pointer, value: cint, size: csize_t): pointer {.
+  importc: "memset", header: "<string.h>", discardable.}
+proc c_strcmp*(a, b: cstring): cint {.
+  importc: "strcmp", header: "<string.h>", noSideEffect.}
+proc c_strlen*(a: cstring): csize_t {.
+  importc: "strlen", header: "<string.h>", noSideEffect.}
+proc c_abort*() {.
+  importc: "abort", header: "<stdlib.h>", noSideEffect, noreturn.}
+
+
+when defined(nimBuiltinSetjmp):
+  type
+    C_JmpBuf* = array[5, pointer]
+elif defined(linux) and defined(amd64):
+  type
+    C_JmpBuf* {.importc: "jmp_buf", header: "<setjmp.h>", bycopy.} = object
+        abi: array[200 div sizeof(clong), clong]
+else:
+  type
+    C_JmpBuf* {.importc: "jmp_buf", header: "<setjmp.h>".} = object
+
+
+type CSighandlerT = proc (a: cint) {.noconv.}
+when defined(windows):
+  const
+    SIGABRT* = cint(22)
+    SIGFPE* = cint(8)
+    SIGILL* = cint(4)
+    SIGINT* = cint(2)
+    SIGSEGV* = cint(11)
+    SIGTERM = cint(15)
+    SIG_DFL* = cast[CSighandlerT](0)
+elif defined(macosx) or defined(linux) or defined(freebsd) or
+     defined(openbsd) or defined(netbsd) or defined(solaris) or
+     defined(dragonfly) or defined(nintendoswitch) or defined(genode) or
+     defined(aix) or hostOS == "standalone":
+  const
+    SIGABRT* = cint(6)
+    SIGFPE* = cint(8)
+    SIGILL* = cint(4)
+    SIGINT* = cint(2)
+    SIGSEGV* = cint(11)
+    SIGTERM* = cint(15)
+    SIGPIPE* = cint(13)
+    SIG_DFL* = CSighandlerT(nil)
+elif defined(haiku):
+  const
+    SIGABRT* = cint(6)
+    SIGFPE* = cint(8)
+    SIGILL* = cint(4)
+    SIGINT* = cint(2)
+    SIGSEGV* = cint(11)
+    SIGTERM* = cint(15)
+    SIGPIPE* = cint(7)
+    SIG_DFL* = CSighandlerT(nil)
+else:
+  when defined(nimscript):
+    {.error: "SIGABRT not ported to your platform".}
+  else:
+    var
+      SIGINT* {.importc: "SIGINT", nodecl.}: cint
+      SIGSEGV* {.importc: "SIGSEGV", nodecl.}: cint
+      SIGABRT* {.importc: "SIGABRT", nodecl.}: cint
+      SIGFPE* {.importc: "SIGFPE", nodecl.}: cint
+      SIGILL* {.importc: "SIGILL", nodecl.}: cint
+      SIG_DFL* {.importc: "SIG_DFL", nodecl.}: CSighandlerT
+    when defined(macosx) or defined(linux):
+      var SIGPIPE* {.importc: "SIGPIPE", nodecl.}: cint
 
 when defined(macosx):
-  var
-    SIGBUS {.importc: "SIGBUS", nodecl.}: cint
-      # hopefully this does not lead to new bugs
+  const SIGBUS* = cint(10)
+elif defined(haiku):
+  const SIGBUS* = cint(30)
+
+# "nimRawSetjmp" is defined by default for certain platforms, so we need the
+# "nimStdSetjmp" escape hatch with it.
+when defined(nimSigSetjmp):
+  proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
+    header: "<setjmp.h>", importc: "siglongjmp".}
+  proc c_setjmp*(jmpb: C_JmpBuf): cint =
+    proc c_sigsetjmp(jmpb: C_JmpBuf, savemask: cint): cint {.
+      header: "<setjmp.h>", importc: "sigsetjmp".}
+    c_sigsetjmp(jmpb, 0)
+elif defined(nimBuiltinSetjmp):
+  proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) =
+    # Apple's Clang++ has trouble converting array names to pointers, so we need
+    # to be very explicit here.
+    proc c_builtin_longjmp(jmpb: ptr pointer, retval: cint) {.
+      importc: "__builtin_longjmp", nodecl.}
+    # The second parameter needs to be 1 and sometimes the C/C++ compiler checks it.
+    c_builtin_longjmp(unsafeAddr jmpb[0], 1)
+  proc c_setjmp*(jmpb: C_JmpBuf): cint =
+    proc c_builtin_setjmp(jmpb: ptr pointer): cint {.
+      importc: "__builtin_setjmp", nodecl.}
+    c_builtin_setjmp(unsafeAddr jmpb[0])
+
+elif defined(nimRawSetjmp) and not defined(nimStdSetjmp):
+  when defined(windows):
+    # No `_longjmp()` on Windows.
+    proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
+      header: "<setjmp.h>", importc: "longjmp".}
+    when defined(vcc) or defined(clangcl):
+      proc c_setjmp*(jmpb: C_JmpBuf): cint {.
+        header: "<setjmp.h>", importc: "setjmp".}
+    else:
+      # The Windows `_setjmp()` takes two arguments, with the second being an
+      # undocumented buffer used by the SEH mechanism for stack unwinding.
+      # Mingw-w64 has been trying to get it right for years, but it's still
+      # prone to stack corruption during unwinding, so we disable that by setting
+      # it to NULL.
+      # More details: https://github.com/status-im/nimbus-eth2/issues/3121
+      when defined(nimHasStyleChecks):
+        {.push styleChecks: off.}
+
+      proc c_setjmp*(jmpb: C_JmpBuf): cint =
+        proc c_setjmp_win(jmpb: C_JmpBuf, ctx: pointer): cint {.
+          header: "<setjmp.h>", importc: "_setjmp".}
+        c_setjmp_win(jmpb, nil)
+
+      when defined(nimHasStyleChecks):
+        {.pop.}
+  else:
+    proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
+      header: "<setjmp.h>", importc: "_longjmp".}
+    proc c_setjmp*(jmpb: C_JmpBuf): cint {.
+      header: "<setjmp.h>", importc: "_setjmp".}
 else:
-  var
-    SIGBUS {.importc: "SIGSEGV", nodecl.}: cint
-      # only Mac OS X has this shit
-
-proc c_longjmp(jmpb: C_JmpBuf, retval: cint) {.nodecl, importc: "longjmp".}
-proc c_setjmp(jmpb: var C_JmpBuf): cint {.nodecl, importc: "setjmp".}
-
-proc c_signal(sig: cint, handler: proc (a: cint) {.noconv.}) {.
-  importc: "signal", header: "<signal.h>".}
-proc c_raise(sig: cint) {.importc: "raise", header: "<signal.h>".}
-
-proc c_fputs(c: cstring, f: C_TextFileStar) {.importc: "fputs", noDecl.}
-proc c_fgets(c: cstring, n: int, f: C_TextFileStar): cstring  {.
-  importc: "fgets", noDecl.}
-proc c_fgetc(stream: C_TextFileStar): int {.importc: "fgetc", nodecl.}
-proc c_ungetc(c: int, f: C_TextFileStar) {.importc: "ungetc", nodecl.}
-proc c_putc(c: Char, stream: C_TextFileStar) {.importc: "putc", nodecl.}
-proc c_fprintf(f: C_TextFileStar, frmt: CString) {.
-  importc: "fprintf", nodecl, varargs.}
-
-proc c_fopen(filename, mode: cstring): C_TextFileStar {.
-  importc: "fopen", nodecl.}
-proc c_fclose(f: C_TextFileStar) {.importc: "fclose", nodecl.}
-
-proc c_sprintf(buf, frmt: CString) {.nodecl, importc: "sprintf", varargs.}
-  # we use it only in a way that cannot lead to security issues
-
-proc c_fread(buf: Pointer, size, n: int, f: C_BinaryFileStar): int {.
-  importc: "fread", noDecl.}
-proc c_fseek(f: C_BinaryFileStar, offset: clong, whence: int): int {.
-  importc: "fseek", noDecl.}
-
-proc c_fwrite(buf: Pointer, size, n: int, f: C_BinaryFileStar): int {.
-  importc: "fwrite", noDecl.}
-
-proc c_exit(errorcode: cint) {.importc: "exit", nodecl.}
-proc c_ferror(stream: C_TextFileStar): bool {.importc: "ferror", nodecl.}
-proc c_fflush(stream: C_TextFileStar) {.importc: "fflush", nodecl.}
-proc c_abort() {.importc: "abort", nodecl.}
-proc c_feof(stream: C_TextFileStar): bool {.importc: "feof", nodecl.}
-
-proc c_malloc(size: int): pointer {.importc: "malloc", nodecl.}
-proc c_free(p: pointer) {.importc: "free", nodecl.}
-proc c_realloc(p: pointer, newsize: int): pointer {.importc: "realloc", nodecl.}
+  proc c_longjmp*(jmpb: C_JmpBuf, retval: cint) {.
+    header: "<setjmp.h>", importc: "longjmp".}
+  proc c_setjmp*(jmpb: C_JmpBuf): cint {.
+    header: "<setjmp.h>", importc: "setjmp".}
 
-var errno {.importc, header: "<errno.h>".}: cint ## error variable
-proc strerror(errnum: cint): cstring {.importc, header: "<string.h>".}
+proc c_signal*(sign: cint, handler: CSighandlerT): CSighandlerT {.
+  importc: "signal", header: "<signal.h>", discardable.}
+proc c_raise*(sign: cint): cint {.importc: "raise", header: "<signal.h>".}
 
-proc c_remove(filename: CString): cint {.importc: "remove", noDecl.}
-proc c_rename(oldname, newname: CString): cint {.importc: "rename", noDecl.}
+type
+  CFile {.importc: "FILE", header: "<stdio.h>",
+          incompleteStruct.} = object
+  CFilePtr* = ptr CFile ## The type representing a file handle.
 
-proc c_system(cmd: CString): cint {.importc: "system", header: "<stdlib.h>".}
-proc c_getenv(env: CString): CString {.importc: "getenv", noDecl.}
-proc c_putenv(env: CString): cint {.importc: "putenv", noDecl.}
+# duplicated between io and ansi_c
+const stdioUsesMacros = (defined(osx) or defined(freebsd) or defined(dragonfly)) and not defined(emscripten)
+const stderrName = when stdioUsesMacros: "__stderrp" else: "stderr"
+const stdoutName = when stdioUsesMacros: "__stdoutp" else: "stdout"
+const stdinName = when stdioUsesMacros: "__stdinp" else: "stdin"
 
-{.pop}
+var
+  cstderr* {.importc: stderrName, header: "<stdio.h>".}: CFilePtr
+  cstdout* {.importc: stdoutName, header: "<stdio.h>".}: CFilePtr
+  cstdin* {.importc: stdinName, header: "<stdio.h>".}: CFilePtr
+
+proc c_fprintf*(f: CFilePtr, frmt: cstring): cint {.
+  importc: "fprintf", header: "<stdio.h>", varargs, discardable.}
+proc c_printf*(frmt: cstring): cint {.
+  importc: "printf", header: "<stdio.h>", varargs, discardable.}
+
+proc c_fputs*(c: cstring, f: CFilePtr): cint {.
+  importc: "fputs", header: "<stdio.h>", discardable.}
+proc c_fputc*(c: char, f: CFilePtr): cint {.
+  importc: "fputc", header: "<stdio.h>", discardable.}
+
+proc c_sprintf*(buf, frmt: cstring): cint {.
+  importc: "sprintf", header: "<stdio.h>", varargs, noSideEffect.}
+  # we use it only in a way that cannot lead to security issues
 
+proc c_snprintf*(buf: cstring, n: csize_t, frmt: cstring): cint {.
+  importc: "snprintf", header: "<stdio.h>", varargs, noSideEffect.}
+
+when defined(zephyr) and not defined(zephyrUseLibcMalloc):
+  proc c_malloc*(size: csize_t): pointer {.
+    importc: "k_malloc", header: "<kernel.h>".}
+  proc c_calloc*(nmemb, size: csize_t): pointer {.
+    importc: "k_calloc", header: "<kernel.h>".}
+  proc c_free*(p: pointer) {.
+    importc: "k_free", header: "<kernel.h>".}
+  proc c_realloc*(p: pointer, newsize: csize_t): pointer =
+    # Zephyr's kernel malloc doesn't support realloc
+    result = c_malloc(newSize)
+    # match the ansi c behavior
+    if not result.isNil():
+      copyMem(result, p, newSize)
+      c_free(p)
+else:
+  proc c_malloc*(size: csize_t): pointer {.
+    importc: "malloc", header: "<stdlib.h>".}
+  proc c_calloc*(nmemb, size: csize_t): pointer {.
+    importc: "calloc", header: "<stdlib.h>".}
+  proc c_free*(p: pointer) {.
+    importc: "free", header: "<stdlib.h>".}
+  proc c_realloc*(p: pointer, newsize: csize_t): pointer {.
+    importc: "realloc", header: "<stdlib.h>".}
+
+proc c_fwrite*(buf: pointer, size, n: csize_t, f: CFilePtr): csize_t {.
+  importc: "fwrite", header: "<stdio.h>".}
+
+proc c_fflush*(f: CFilePtr): cint {.
+  importc: "fflush", header: "<stdio.h>".}
+
+proc rawWriteString*(f: CFilePtr, s: cstring, length: int) {.compilerproc, nonReloadable, inline.} =
+  # we cannot throw an exception here!
+  discard c_fwrite(s, 1, cast[csize_t](length), f)
+  discard c_fflush(f)
+
+proc rawWrite*(f: CFilePtr, s: cstring) {.compilerproc, nonReloadable, inline.} =
+  # we cannot throw an exception here!
+  discard c_fwrite(s, 1, c_strlen(s), f)
+  discard c_fflush(f)
+
+{.pop.}
diff --git a/lib/system/arc.nim b/lib/system/arc.nim
new file mode 100644
index 000000000..d001fcaa5
--- /dev/null
+++ b/lib/system/arc.nim
@@ -0,0 +1,267 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+#[
+In this new runtime we simplify the object layouts a bit: The runtime type
+information is only accessed for the objects that have it and it's always
+at offset 0 then. The ``ref`` object header is independent from the
+runtime type and only contains a reference count.
+]#
+
+when defined(gcOrc):
+  const
+    rcIncrement = 0b10000 # so that lowest 4 bits are not touched
+    rcMask = 0b1111
+    rcShift = 4      # shift by rcShift to get the reference counter
+
+else:
+  const
+    rcIncrement = 0b1000 # so that lowest 3 bits are not touched
+    rcMask = 0b111
+    rcShift = 3      # shift by rcShift to get the reference counter
+
+const
+  orcLeakDetector = defined(nimOrcLeakDetector)
+
+type
+  RefHeader = object
+    rc: int # the object header is now a single RC field.
+            # we could remove it in non-debug builds for the 'owned ref'
+            # design but this seems unwise.
+    when defined(gcOrc):
+      rootIdx: int # thanks to this we can delete potential cycle roots
+                   # in O(1) without doubly linked lists
+    when defined(nimArcDebug) or defined(nimArcIds):
+      refId: int
+    when defined(gcOrc) and orcLeakDetector:
+      filename: cstring
+      line: int
+
+  Cell = ptr RefHeader
+
+template setFrameInfo(c: Cell) =
+  when orcLeakDetector:
+    if framePtr != nil and framePtr.prev != nil:
+      c.filename = framePtr.prev.filename
+      c.line = framePtr.prev.line
+    else:
+      c.filename = nil
+      c.line = 0
+
+template head(p: pointer): Cell =
+  cast[Cell](cast[int](p) -% sizeof(RefHeader))
+
+const
+  traceCollector = defined(traceArc)
+
+when defined(nimArcDebug):
+  include cellsets
+
+  const traceId = 20 # 1037
+
+  var gRefId: int
+  var freedCells: CellSet
+elif defined(nimArcIds):
+  var gRefId: int
+
+  const traceId = -1
+
+when defined(gcAtomicArc) and hasThreadSupport:
+  template decrement(cell: Cell): untyped =
+    discard atomicDec(cell.rc, rcIncrement)
+  template increment(cell: Cell): untyped =
+    discard atomicInc(cell.rc, rcIncrement)
+  template count(x: Cell): untyped =
+    atomicLoadN(x.rc.addr, ATOMIC_ACQUIRE) shr rcShift
+else:
+  template decrement(cell: Cell): untyped =
+    dec(cell.rc, rcIncrement)
+  template increment(cell: Cell): untyped =
+    inc(cell.rc, rcIncrement)
+  template count(x: Cell): untyped =
+    x.rc shr rcShift
+
+proc nimNewObj(size, alignment: int): pointer {.compilerRtl.} =
+  let hdrSize = align(sizeof(RefHeader), alignment)
+  let s = size + hdrSize
+  when defined(nimscript):
+    discard
+  else:
+    result = alignedAlloc0(s, alignment) +! hdrSize
+  when defined(nimArcDebug) or defined(nimArcIds):
+    head(result).refId = gRefId
+    atomicInc gRefId
+    if head(result).refId == traceId:
+      writeStackTrace()
+      cfprintf(cstderr, "[nimNewObj] %p %ld\n", result, head(result).count)
+  when traceCollector:
+    cprintf("[Allocated] %p result: %p\n", result -! sizeof(RefHeader), result)
+  setFrameInfo head(result)
+
+proc nimNewObjUninit(size, alignment: int): pointer {.compilerRtl.} =
+  # Same as 'newNewObj' but do not initialize the memory to zero.
+  # The codegen proved for us that this is not necessary.
+  let hdrSize = align(sizeof(RefHeader), alignment)
+  let s = size + hdrSize
+  when defined(nimscript):
+    discard
+  else:
+    result = cast[ptr RefHeader](alignedAlloc(s, alignment) +! hdrSize)
+  head(result).rc = 0
+  when defined(gcOrc):
+    head(result).rootIdx = 0
+  when defined(nimArcDebug):
+    head(result).refId = gRefId
+    atomicInc gRefId
+    if head(result).refId == traceId:
+      writeStackTrace()
+      cfprintf(cstderr, "[nimNewObjUninit] %p %ld\n", result, head(result).count)
+
+  when traceCollector:
+    cprintf("[Allocated] %p result: %p\n", result -! sizeof(RefHeader), result)
+  setFrameInfo head(result)
+
+proc nimDecWeakRef(p: pointer) {.compilerRtl, inl.} =
+  decrement head(p)
+
+proc isUniqueRef*[T](x: ref T): bool {.inline.} =
+  ## Returns true if the object `x` points to is uniquely referenced. Such
+  ## an object can potentially be passed over to a different thread safely,
+  ## if great care is taken. This queries the internal reference count of
+  ## the object which is subject to lots of optimizations! In other words
+  ## the value of `isUniqueRef` can depend on the used compiler version and
+  ## optimizer setting.
+  ## Nevertheless it can be used as a very valuable debugging tool and can
+  ## be used to specify the constraints of a threading related API
+  ## via `assert isUniqueRef(x)`.
+  head(cast[pointer](x)).rc == 0
+
+proc nimIncRef(p: pointer) {.compilerRtl, inl.} =
+  when defined(nimArcDebug):
+    if head(p).refId == traceId:
+      writeStackTrace()
+      cfprintf(cstderr, "[IncRef] %p %ld\n", p, head(p).count)
+
+  increment head(p)
+  when traceCollector:
+    cprintf("[INCREF] %p\n", head(p))
+
+when not defined(gcOrc) or defined(nimThinout):
+  proc unsureAsgnRef(dest: ptr pointer, src: pointer) {.inline.} =
+    # This is only used by the old RTTI mechanism and we know
+    # that 'dest[]' is nil and needs no destruction. Which is really handy
+    # as we cannot destroy the object reliably if it's an object of unknown
+    # compile-time type.
+    dest[] = src
+    if src != nil: nimIncRef src
+
+when not defined(nimscript) and defined(nimArcDebug):
+  proc deallocatedRefId*(p: pointer): int =
+    ## Returns the ref's ID if the ref was already deallocated. This
+    ## is a memory corruption check. Returns 0 if there is no error.
+    let c = head(p)
+    if freedCells.data != nil and freedCells.contains(c):
+      result = c.refId
+    else:
+      result = 0
+
+proc nimRawDispose(p: pointer, alignment: int) {.compilerRtl.} =
+  when not defined(nimscript):
+    when traceCollector:
+      cprintf("[Freed] %p\n", p -! sizeof(RefHeader))
+    when defined(nimOwnedEnabled):
+      if head(p).rc >= rcIncrement:
+        cstderr.rawWrite "[FATAL] dangling references exist\n"
+        rawQuit 1
+    when defined(nimArcDebug):
+      # we do NOT really free the memory here in order to reliably detect use-after-frees
+      if freedCells.data == nil: init(freedCells)
+      freedCells.incl head(p)
+    else:
+      let hdrSize = align(sizeof(RefHeader), alignment)
+      alignedDealloc(p -! hdrSize, alignment)
+
+template `=dispose`*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x), T.alignOf)
+#proc dispose*(x: pointer) = nimRawDispose(x)
+
+proc nimDestroyAndDispose(p: pointer) {.compilerRtl, raises: [].} =
+  let rti = cast[ptr PNimTypeV2](p)
+  if rti.destructor != nil:
+    cast[DestructorProc](rti.destructor)(p)
+  when false:
+    cstderr.rawWrite cast[ptr PNimTypeV2](p)[].name
+    cstderr.rawWrite "\n"
+    if d == nil:
+      cstderr.rawWrite "bah, nil\n"
+    else:
+      cstderr.rawWrite "has destructor!\n"
+  nimRawDispose(p, rti.align)
+
+when defined(gcOrc):
+  when defined(nimThinout):
+    include cyclebreaker
+  else:
+    include orc
+    #include cyclecollector
+
+proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+
+    when defined(nimArcDebug):
+      if cell.refId == traceId:
+        writeStackTrace()
+        cfprintf(cstderr, "[DecRef] %p %ld\n", p, cell.count)
+
+    when defined(gcAtomicArc) and hasThreadSupport:
+      # `atomicDec` returns the new value
+      if atomicDec(cell.rc, rcIncrement) == -rcIncrement:
+        result = true
+        when traceCollector:
+          cprintf("[ABOUT TO DESTROY] %p\n", cell)
+    else:
+      if cell.count == 0:
+        result = true
+        when traceCollector:
+          cprintf("[ABOUT TO DESTROY] %p\n", cell)
+      else:
+        decrement cell
+        # According to Lins it's correct to do nothing else here.
+        when traceCollector:
+          cprintf("[DECREF] %p\n", cell)
+
+proc GC_unref*[T](x: ref T) =
+  ## New runtime only supports this operation for 'ref T'.
+  var y {.cursor.} = x
+  `=destroy`(y)
+
+proc GC_ref*[T](x: ref T) =
+  ## New runtime only supports this operation for 'ref T'.
+  if x != nil: nimIncRef(cast[pointer](x))
+
+when not defined(gcOrc):
+  template GC_fullCollect* =
+    ## Forces a full garbage collection pass. With `--mm:arc` a nop.
+    discard
+
+template setupForeignThreadGc* =
+  ## With `--mm:arc` a nop.
+  discard
+
+template tearDownForeignThreadGc* =
+  ## With `--mm:arc` a nop.
+  discard
+
+proc isObjDisplayCheck(source: PNimTypeV2, targetDepth: int16, token: uint32): bool {.compilerRtl, inl.} =
+  result = targetDepth <= source.depth and source.display[targetDepth] == token
+
+when defined(gcDestructors):
+  proc nimGetVTable(p: pointer, index: int): pointer
+        {.compilerRtl, inline, raises: [].} =
+    result = cast[ptr PNimTypeV2](p).vTable[index]
diff --git a/lib/system/arithm.nim b/lib/system/arithm.nim
deleted file mode 100755
index b93bb9844..000000000
--- a/lib/system/arithm.nim
+++ /dev/null
@@ -1,334 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-
-# simple integer arithmetic with overflow checking
-
-proc raiseOverflow {.compilerproc, noinline, noreturn.} =
-  # a single proc to reduce code size to a minimum
-  raise newException(EOverflow, "over- or underflow")
-
-proc raiseDivByZero {.compilerproc, noinline, noreturn.} =
-  raise newException(EDivByZero, "divison by zero")
-
-proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
-  result = a +% b
-  if (result xor a) >= int64(0) or (result xor b) >= int64(0):
-    return result
-  raiseOverflow()
-
-proc subInt64(a, b: int64): int64 {.compilerProc, inline.} =
-  result = a -% b
-  if (result xor a) >= int64(0) or (result xor not b) >= int64(0):
-    return result
-  raiseOverflow()
-
-proc negInt64(a: int64): int64 {.compilerProc, inline.} =
-  if a != low(int64): return -a
-  raiseOverflow()
-
-proc absInt64(a: int64): int64 {.compilerProc, inline.} =
-  if a != low(int64):
-    if a >= 0: return a
-    else: return -a
-  raiseOverflow()
-
-proc divInt64(a, b: int64): int64 {.compilerProc, inline.} =
-  if b == int64(0):
-    raiseDivByZero()
-  if a == low(int64) and b == int64(-1):
-    raiseOverflow()
-  return a div b
-
-proc modInt64(a, b: int64): int64 {.compilerProc, inline.} =
-  if b == int64(0):
-    raiseDivByZero()
-  return a mod b
-
-#
-# This code has been inspired by Python's source code.
-# The native int product x*y is either exactly right or *way* off, being
-# just the last n bits of the true product, where n is the number of bits
-# in an int (the delivered product is the true product plus i*2**n for
-# some integer i).
-#
-# The native float64 product x*y is subject to three
-# rounding errors: on a sizeof(int)==8 box, each cast to double can lose
-# info, and even on a sizeof(int)==4 box, the multiplication can lose info.
-# But, unlike the native int product, it's not in *range* trouble:  even
-# if sizeof(int)==32 (256-bit ints), the product easily fits in the
-# dynamic range of a float64. So the leading 50 (or so) bits of the float64
-# product are correct.
-#
-# We check these two ways against each other, and declare victory if they're
-# approximately the same. Else, because the native int product is the only
-# one that can lose catastrophic amounts of information, it's the native int
-# product that must have overflowed.
-#
-proc mulInt64(a, b: int64): int64 {.compilerproc.} =
-  var
-    resAsFloat, floatProd: float64
-  result = a *% b
-  floatProd = toBiggestFloat(a) # conversion
-  floatProd = floatProd * toBiggestFloat(b)
-  resAsFloat = toBiggestFloat(result)
-
-  # Fast path for normal case: small multiplicands, and no info
-  # is lost in either method.
-  if resAsFloat == floatProd: return result
-
-  # Somebody somewhere lost info. Close enough, or way off? Note
-  # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
-  # The difference either is or isn't significant compared to the
-  # true value (of which floatProd is a good approximation).
-
-  # abs(diff)/abs(prod) <= 1/32 iff
-  #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
-  if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
-    return result
-  raiseOverflow()
-
-
-proc absInt(a: int): int {.compilerProc, inline.} =
-  if a != low(int):
-    if a >= 0: return a
-    else: return -a
-  raiseOverflow()
-
-const
-  asmVersion = defined(I386) and (defined(vcc) or defined(wcc) or
-               defined(dmc) or defined(gcc) or defined(llvm_gcc))
-    # my Version of Borland C++Builder does not have
-    # tasm32, which is needed for assembler blocks
-    # this is why Borland is not included in the 'when'
-
-when asmVersion and not defined(gcc) and not defined(llvm_gcc):
-  # assembler optimized versions for compilers that
-  # have an intel syntax assembler:
-  proc addInt(a, b: int): int {.compilerProc, pure.} =
-    # a in eax, and b in edx
-    asm """
-        mov eax, `a`
-        add eax, `b`
-        jno theEnd
-        call `raiseOverflow`
-      theEnd:
-    """
-
-  proc subInt(a, b: int): int {.compilerProc, pure.} =
-    asm """
-        mov eax, `a`
-        sub eax, `b`
-        jno theEnd
-        call `raiseOverflow`
-      theEnd:
-    """
-
-  proc negInt(a: int): int {.compilerProc, pure.} =
-    asm """
-        mov eax, `a`
-        neg eax
-        jno theEnd
-        call `raiseOverflow`
-      theEnd:
-    """
-
-  proc divInt(a, b: int): int {.compilerProc, pure.} =
-    asm """
-        mov eax, `a`
-        mov ecx, `b`
-        xor edx, edx
-        idiv ecx
-        jno  theEnd
-        call `raiseOverflow`
-      theEnd:
-    """
-
-  proc modInt(a, b: int): int {.compilerProc, pure.} =
-    asm """
-        mov eax, `a`
-        mov ecx, `b`
-        xor edx, edx
-        idiv ecx
-        jno theEnd
-        call `raiseOverflow`
-      theEnd:
-        mov eax, edx
-    """
-
-  proc mulInt(a, b: int): int {.compilerProc, pure.} =
-    asm """
-        mov eax, `a`
-        mov ecx, `b`
-        xor edx, edx
-        imul ecx
-        jno theEnd
-        call `raiseOverflow`
-      theEnd:
-    """
-
-elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
-  proc addInt(a, b: int): int {.compilerProc, inline.} =
-    # don't use a pure proc here!
-    asm """
-      "addl %%ecx, %%eax\n"
-      "jno 1\n"
-      "call _raiseOverflow\n"
-      "1: \n"
-      :"=a"(`result`)
-      :"a"(`a`), "c"(`b`)
-    """
-
-  proc subInt(a, b: int): int {.compilerProc, inline.} =
-    asm """ "subl %%ecx,%%eax\n"
-            "jno 1\n"
-            "call _raiseOverflow\n"
-            "1: \n"
-           :"=a"(`result`)
-           :"a"(`a`), "c"(`b`)
-    """
-
-  proc mulInt(a, b: int): int {.compilerProc, inline.} =
-    asm """  "xorl %%edx, %%edx\n"
-             "imull %%ecx\n"
-             "jno 1\n"
-             "call _raiseOverflow\n"
-             "1: \n"
-            :"=a"(`result`)
-            :"a"(`a`), "c"(`b`)
-            :"%edx"
-    """
-
-  proc negInt(a: int): int {.compilerProc, inline.} =
-    asm """ "negl %%eax\n"
-            "jno 1\n"
-            "call _raiseOverflow\n"
-            "1: \n"
-           :"=a"(`result`)
-           :"a"(`a`)
-    """
-
-  proc divInt(a, b: int): int {.compilerProc, inline.} =
-    asm """  "xorl %%edx, %%edx\n"
-             "idivl %%ecx\n"
-             "jno 1\n"
-             "call _raiseOverflow\n"
-             "1: \n"
-            :"=a"(`result`)
-            :"a"(`a`), "c"(`b`)
-            :"%edx"
-    """
-
-  proc modInt(a, b: int): int {.compilerProc, inline.} =
-    asm """  "xorl %%edx, %%edx\n"
-             "idivl %%ecx\n"
-             "jno 1\n"
-             "call _raiseOverflow\n"
-             "1: \n"
-             "movl %%edx, %%eax"
-            :"=a"(`result`)
-            :"a"(`a`), "c"(`b`)
-            :"%edx"
-    """
-
-# Platform independant versions of the above (slower!)
-when not defined(addInt):
-  proc addInt(a, b: int): int {.compilerProc, inline.} =
-    result = a +% b
-    if (result xor a) >= 0 or (result xor b) >= 0:
-      return result
-    raiseOverflow()
-
-when not defined(subInt):
-  proc subInt(a, b: int): int {.compilerProc, inline.} =
-    result = a -% b
-    if (result xor a) >= 0 or (result xor not b) >= 0:
-      return result
-    raiseOverflow()
-
-when not defined(negInt):
-  proc negInt(a: int): int {.compilerProc, inline.} =
-    if a != low(int): return -a
-    raiseOverflow()
-
-when not defined(divInt):
-  proc divInt(a, b: int): int {.compilerProc, inline.} =
-    if b == 0:
-      raiseDivByZero()
-    if a == low(int) and b == -1:
-      raiseOverflow()
-    return a div b
-
-when not defined(modInt):
-  proc modInt(a, b: int): int {.compilerProc, inline.} =
-    if b == 0:
-      raiseDivByZero()
-    return a mod b
-
-when not defined(mulInt):
-  #
-  # This code has been inspired by Python's source code.
-  # The native int product x*y is either exactly right or *way* off, being
-  # just the last n bits of the true product, where n is the number of bits
-  # in an int (the delivered product is the true product plus i*2**n for
-  # some integer i).
-  #
-  # The native float64 product x*y is subject to three
-  # rounding errors: on a sizeof(int)==8 box, each cast to double can lose
-  # info, and even on a sizeof(int)==4 box, the multiplication can lose info.
-  # But, unlike the native int product, it's not in *range* trouble:  even
-  # if sizeof(int)==32 (256-bit ints), the product easily fits in the
-  # dynamic range of a float64. So the leading 50 (or so) bits of the float64
-  # product are correct.
-  #
-  # We check these two ways against each other, and declare victory if
-  # they're approximately the same. Else, because the native int product is
-  # the only one that can lose catastrophic amounts of information, it's the
-  # native int product that must have overflowed.
-  #
-  proc mulInt(a, b: int): int {.compilerProc.} =
-    var
-      resAsFloat, floatProd: float
-
-    result = a *% b
-    floatProd = toFloat(a) * toFloat(b)
-    resAsFloat = toFloat(result)
-
-    # Fast path for normal case: small multiplicands, and no info
-    # is lost in either method.
-    if resAsFloat == floatProd: return result
-
-    # Somebody somewhere lost info. Close enough, or way off? Note
-    # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
-    # The difference either is or isn't significant compared to the
-    # true value (of which floatProd is a good approximation).
-
-    # abs(diff)/abs(prod) <= 1/32 iff
-    #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
-    if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
-      return result
-    raiseOverflow()
-
-# We avoid setting the FPU control word here for compatibility with libraries
-# written in other languages.
-
-proc raiseFloatInvalidOp {.noinline, noreturn.} =
-  raise newException(EFloatInvalidOp, "FPU operation caused a NaN result")
-
-proc nanCheck(x: float64) {.compilerProc, inline.} =
-  if x != x: raiseFloatInvalidOp()
-
-proc raiseFloatOverflow(x: float64) {.noinline, noreturn.} =
-  if x > 0.0:
-    raise newException(EFloatOverflow, "FPU operation caused an overflow")
-  else:
-    raise newException(EFloatUnderflow, "FPU operations caused an underflow")
-
-proc infCheck(x: float64) {.compilerProc, inline.} =
-  if x != 0.0 and x*0.5 == x: raiseFloatOverflow(x)
diff --git a/lib/system/arithmetics.nim b/lib/system/arithmetics.nim
new file mode 100644
index 000000000..e229a0f4b
--- /dev/null
+++ b/lib/system/arithmetics.nim
@@ -0,0 +1,405 @@
+proc succ*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Succ", noSideEffect.} =
+  ## Returns the `y`-th successor (default: 1) of the value `x`.
+  ##
+  ## If such a value does not exist, `OverflowDefect` is raised
+  ## or a compile time error occurs.
+  runnableExamples:
+    assert succ(5) == 6
+    assert succ(5, 3) == 8
+
+proc pred*[T, V: Ordinal](x: T, y: V = 1): T {.magic: "Pred", noSideEffect.} =
+  ## Returns the `y`-th predecessor (default: 1) of the value `x`.
+  ##
+  ## If such a value does not exist, `OverflowDefect` is raised
+  ## or a compile time error occurs.
+  runnableExamples:
+    assert pred(5) == 4
+    assert pred(5, 3) == 2
+
+proc inc*[T, V: Ordinal](x: var T, y: V = 1) {.magic: "Inc", noSideEffect.} =
+  ## Increments the ordinal `x` by `y`.
+  ##
+  ## If such a value does not exist, `OverflowDefect` is raised or a compile
+  ## time error occurs. This is a short notation for: `x = succ(x, y)`.
+  runnableExamples:
+    var i = 2
+    inc(i)
+    assert i == 3
+    inc(i, 3)
+    assert i == 6
+
+proc dec*[T, V: Ordinal](x: var T, y: V = 1) {.magic: "Dec", noSideEffect.} =
+  ## Decrements the ordinal `x` by `y`.
+  ##
+  ## If such a value does not exist, `OverflowDefect` is raised or a compile
+  ## time error occurs. This is a short notation for: `x = pred(x, y)`.
+  runnableExamples:
+    var i = 2
+    dec(i)
+    assert i == 1
+    dec(i, 3)
+    assert i == -2
+
+
+
+# --------------------------------------------------------------------------
+# built-in operators
+
+# integer calculations:
+proc `+`*(x: int): int {.magic: "UnaryPlusI", noSideEffect.}
+  ## Unary `+` operator for an integer. Has no effect.
+proc `+`*(x: int8): int8 {.magic: "UnaryPlusI", noSideEffect.}
+proc `+`*(x: int16): int16 {.magic: "UnaryPlusI", noSideEffect.}
+proc `+`*(x: int32): int32 {.magic: "UnaryPlusI", noSideEffect.}
+proc `+`*(x: int64): int64 {.magic: "UnaryPlusI", noSideEffect.}
+
+proc `-`*(x: int): int {.magic: "UnaryMinusI", noSideEffect.}
+  ## Unary `-` operator for an integer. Negates `x`.
+proc `-`*(x: int8): int8 {.magic: "UnaryMinusI", noSideEffect.}
+proc `-`*(x: int16): int16 {.magic: "UnaryMinusI", noSideEffect.}
+proc `-`*(x: int32): int32 {.magic: "UnaryMinusI", noSideEffect.}
+proc `-`*(x: int64): int64 {.magic: "UnaryMinusI64", noSideEffect.}
+
+proc `not`*(x: int): int {.magic: "BitnotI", noSideEffect.} =
+  ## Computes the `bitwise complement` of the integer `x`.
+  runnableExamples:
+    assert not 0'u8 == 255
+    assert not 0'i8 == -1
+    assert not 1000'u16 == 64535
+    assert not 1000'i16 == -1001
+proc `not`*(x: int8): int8 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: int16): int16 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: int32): int32 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: int64): int64 {.magic: "BitnotI", noSideEffect.}
+
+proc `+`*(x, y: int): int {.magic: "AddI", noSideEffect.}
+  ## Binary `+` operator for an integer.
+proc `+`*(x, y: int8): int8 {.magic: "AddI", noSideEffect.}
+proc `+`*(x, y: int16): int16 {.magic: "AddI", noSideEffect.}
+proc `+`*(x, y: int32): int32 {.magic: "AddI", noSideEffect.}
+proc `+`*(x, y: int64): int64 {.magic: "AddI", noSideEffect.}
+
+proc `-`*(x, y: int): int {.magic: "SubI", noSideEffect.}
+  ## Binary `-` operator for an integer.
+proc `-`*(x, y: int8): int8 {.magic: "SubI", noSideEffect.}
+proc `-`*(x, y: int16): int16 {.magic: "SubI", noSideEffect.}
+proc `-`*(x, y: int32): int32 {.magic: "SubI", noSideEffect.}
+proc `-`*(x, y: int64): int64 {.magic: "SubI", noSideEffect.}
+
+proc `*`*(x, y: int): int {.magic: "MulI", noSideEffect.}
+  ## Binary `*` operator for an integer.
+proc `*`*(x, y: int8): int8 {.magic: "MulI", noSideEffect.}
+proc `*`*(x, y: int16): int16 {.magic: "MulI", noSideEffect.}
+proc `*`*(x, y: int32): int32 {.magic: "MulI", noSideEffect.}
+proc `*`*(x, y: int64): int64 {.magic: "MulI", noSideEffect.}
+
+proc `div`*(x, y: int): int {.magic: "DivI", noSideEffect.} =
+  ## Computes the integer division.
+  ##
+  ## This is roughly the same as `math.trunc(x/y).int`.
+  runnableExamples:
+    assert (1 div 2) == 0
+    assert (2 div 2) == 1
+    assert (3 div 2) == 1
+    assert (7 div 3) == 2
+    assert (-7 div 3) == -2
+    assert (7 div -3) == -2
+    assert (-7 div -3) == 2
+proc `div`*(x, y: int8): int8 {.magic: "DivI", noSideEffect.}
+proc `div`*(x, y: int16): int16 {.magic: "DivI", noSideEffect.}
+proc `div`*(x, y: int32): int32 {.magic: "DivI", noSideEffect.}
+proc `div`*(x, y: int64): int64 {.magic: "DivI", noSideEffect.}
+
+proc `mod`*(x, y: int): int {.magic: "ModI", noSideEffect.} =
+  ## Computes the integer modulo operation (remainder).
+  ##
+  ## This is the same as `x - (x div y) * y`.
+  runnableExamples:
+    assert (7 mod 5) == 2
+    assert (-7 mod 5) == -2
+    assert (7 mod -5) == 2
+    assert (-7 mod -5) == -2
+proc `mod`*(x, y: int8): int8 {.magic: "ModI", noSideEffect.}
+proc `mod`*(x, y: int16): int16 {.magic: "ModI", noSideEffect.}
+proc `mod`*(x, y: int32): int32 {.magic: "ModI", noSideEffect.}
+proc `mod`*(x, y: int64): int64 {.magic: "ModI", noSideEffect.}
+
+when defined(nimOldShiftRight):
+  const shrDepMessage = "`shr` will become sign preserving."
+  proc `shr`*(x: int, y: SomeInteger): int {.magic: "ShrI", noSideEffect, deprecated: shrDepMessage.}
+  proc `shr`*(x: int8, y: SomeInteger): int8 {.magic: "ShrI", noSideEffect, deprecated: shrDepMessage.}
+  proc `shr`*(x: int16, y: SomeInteger): int16 {.magic: "ShrI", noSideEffect, deprecated: shrDepMessage.}
+  proc `shr`*(x: int32, y: SomeInteger): int32 {.magic: "ShrI", noSideEffect, deprecated: shrDepMessage.}
+  proc `shr`*(x: int64, y: SomeInteger): int64 {.magic: "ShrI", noSideEffect, deprecated: shrDepMessage.}
+else:
+  proc `shr`*(x: int, y: SomeInteger): int {.magic: "AshrI", noSideEffect.} =
+    ## Computes the `shift right` operation of `x` and `y`, filling
+    ## vacant bit positions with the sign bit.
+    ##
+    ## **Note**: `Operator precedence <manual.html#syntax-precedence>`_
+    ## is different than in *C*.
+    ##
+    ## See also:
+    ## * `ashr func<#ashr,int,SomeInteger>`_ for arithmetic shift right
+    runnableExamples:
+      assert 0b0001_0000'i8 shr 2 == 0b0000_0100'i8
+      assert 0b0000_0001'i8 shr 1 == 0b0000_0000'i8
+      assert 0b1000_0000'i8 shr 4 == 0b1111_1000'i8
+      assert -1 shr 5 == -1
+      assert 1 shr 5 == 0
+      assert 16 shr 2 == 4
+      assert -16 shr 2 == -4
+  proc `shr`*(x: int8, y: SomeInteger): int8 {.magic: "AshrI", noSideEffect.}
+  proc `shr`*(x: int16, y: SomeInteger): int16 {.magic: "AshrI", noSideEffect.}
+  proc `shr`*(x: int32, y: SomeInteger): int32 {.magic: "AshrI", noSideEffect.}
+  proc `shr`*(x: int64, y: SomeInteger): int64 {.magic: "AshrI", noSideEffect.}
+
+
+proc `shl`*(x: int, y: SomeInteger): int {.magic: "ShlI", noSideEffect.} =
+  ## Computes the `shift left` operation of `x` and `y`.
+  ##
+  ## **Note**: `Operator precedence <manual.html#syntax-precedence>`_
+  ## is different than in *C*.
+  runnableExamples:
+    assert 1'i32 shl 4 == 0x0000_0010
+    assert 1'i64 shl 4 == 0x0000_0000_0000_0010
+proc `shl`*(x: int8, y: SomeInteger): int8 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: int16, y: SomeInteger): int16 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: int32, y: SomeInteger): int32 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: int64, y: SomeInteger): int64 {.magic: "ShlI", noSideEffect.}
+
+proc ashr*(x: int, y: SomeInteger): int {.magic: "AshrI", noSideEffect.} =
+  ## Shifts right by pushing copies of the leftmost bit in from the left,
+  ## and let the rightmost bits fall off.
+  ##
+  ## Note that `ashr` is not an operator so use the normal function
+  ## call syntax for it.
+  ##
+  ## See also:
+  ## * `shr func<#shr,int,SomeInteger>`_
+  runnableExamples:
+    assert ashr(0b0001_0000'i8, 2) == 0b0000_0100'i8
+    assert ashr(0b1000_0000'i8, 8) == 0b1111_1111'i8
+    assert ashr(0b1000_0000'i8, 1) == 0b1100_0000'i8
+proc ashr*(x: int8, y: SomeInteger): int8 {.magic: "AshrI", noSideEffect.}
+proc ashr*(x: int16, y: SomeInteger): int16 {.magic: "AshrI", noSideEffect.}
+proc ashr*(x: int32, y: SomeInteger): int32 {.magic: "AshrI", noSideEffect.}
+proc ashr*(x: int64, y: SomeInteger): int64 {.magic: "AshrI", noSideEffect.}
+
+proc `and`*(x, y: int): int {.magic: "BitandI", noSideEffect.} =
+  ## Computes the `bitwise and` of numbers `x` and `y`.
+  runnableExamples:
+    assert (0b0011 and 0b0101) == 0b0001
+    assert (0b0111 and 0b1100) == 0b0100
+proc `and`*(x, y: int8): int8 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: int16): int16 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: int32): int32 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: int64): int64 {.magic: "BitandI", noSideEffect.}
+
+proc `or`*(x, y: int): int {.magic: "BitorI", noSideEffect.} =
+  ## Computes the `bitwise or` of numbers `x` and `y`.
+  runnableExamples:
+    assert (0b0011 or 0b0101) == 0b0111
+    assert (0b0111 or 0b1100) == 0b1111
+proc `or`*(x, y: int8): int8 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: int16): int16 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: int32): int32 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: int64): int64 {.magic: "BitorI", noSideEffect.}
+
+proc `xor`*(x, y: int): int {.magic: "BitxorI", noSideEffect.} =
+  ## Computes the `bitwise xor` of numbers `x` and `y`.
+  runnableExamples:
+    assert (0b0011 xor 0b0101) == 0b0110
+    assert (0b0111 xor 0b1100) == 0b1011
+proc `xor`*(x, y: int8): int8 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: int16): int16 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: int32): int32 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: int64): int64 {.magic: "BitxorI", noSideEffect.}
+
+# unsigned integer operations:
+proc `not`*(x: uint): uint {.magic: "BitnotI", noSideEffect.}
+  ## Computes the `bitwise complement` of the integer `x`.
+proc `not`*(x: uint8): uint8 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: uint16): uint16 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: uint32): uint32 {.magic: "BitnotI", noSideEffect.}
+proc `not`*(x: uint64): uint64 {.magic: "BitnotI", noSideEffect.}
+
+proc `shr`*(x: uint, y: SomeInteger): uint {.magic: "ShrI", noSideEffect.}
+  ## Computes the `shift right` operation of `x` and `y`.
+proc `shr`*(x: uint8, y: SomeInteger): uint8 {.magic: "ShrI", noSideEffect.}
+proc `shr`*(x: uint16, y: SomeInteger): uint16 {.magic: "ShrI", noSideEffect.}
+proc `shr`*(x: uint32, y: SomeInteger): uint32 {.magic: "ShrI", noSideEffect.}
+proc `shr`*(x: uint64, y: SomeInteger): uint64 {.magic: "ShrI", noSideEffect.}
+
+proc `shl`*(x: uint, y: SomeInteger): uint {.magic: "ShlI", noSideEffect.}
+  ## Computes the `shift left` operation of `x` and `y`.
+proc `shl`*(x: uint8, y: SomeInteger): uint8 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: uint16, y: SomeInteger): uint16 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: uint32, y: SomeInteger): uint32 {.magic: "ShlI", noSideEffect.}
+proc `shl`*(x: uint64, y: SomeInteger): uint64 {.magic: "ShlI", noSideEffect.}
+
+proc `and`*(x, y: uint): uint {.magic: "BitandI", noSideEffect.}
+  ## Computes the `bitwise and` of numbers `x` and `y`.
+proc `and`*(x, y: uint8): uint8 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: uint16): uint16 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: uint32): uint32 {.magic: "BitandI", noSideEffect.}
+proc `and`*(x, y: uint64): uint64 {.magic: "BitandI", noSideEffect.}
+
+proc `or`*(x, y: uint): uint {.magic: "BitorI", noSideEffect.}
+  ## Computes the `bitwise or` of numbers `x` and `y`.
+proc `or`*(x, y: uint8): uint8 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: uint16): uint16 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: uint32): uint32 {.magic: "BitorI", noSideEffect.}
+proc `or`*(x, y: uint64): uint64 {.magic: "BitorI", noSideEffect.}
+
+proc `xor`*(x, y: uint): uint {.magic: "BitxorI", noSideEffect.}
+  ## Computes the `bitwise xor` of numbers `x` and `y`.
+proc `xor`*(x, y: uint8): uint8 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: uint16): uint16 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: uint32): uint32 {.magic: "BitxorI", noSideEffect.}
+proc `xor`*(x, y: uint64): uint64 {.magic: "BitxorI", noSideEffect.}
+
+proc `+`*(x, y: uint): uint {.magic: "AddU", noSideEffect.}
+  ## Binary `+` operator for unsigned integers.
+proc `+`*(x, y: uint8): uint8 {.magic: "AddU", noSideEffect.}
+proc `+`*(x, y: uint16): uint16 {.magic: "AddU", noSideEffect.}
+proc `+`*(x, y: uint32): uint32 {.magic: "AddU", noSideEffect.}
+proc `+`*(x, y: uint64): uint64 {.magic: "AddU", noSideEffect.}
+
+proc `-`*(x, y: uint): uint {.magic: "SubU", noSideEffect.}
+  ## Binary `-` operator for unsigned integers.
+proc `-`*(x, y: uint8): uint8 {.magic: "SubU", noSideEffect.}
+proc `-`*(x, y: uint16): uint16 {.magic: "SubU", noSideEffect.}
+proc `-`*(x, y: uint32): uint32 {.magic: "SubU", noSideEffect.}
+proc `-`*(x, y: uint64): uint64 {.magic: "SubU", noSideEffect.}
+
+proc `*`*(x, y: uint): uint {.magic: "MulU", noSideEffect.}
+  ## Binary `*` operator for unsigned integers.
+proc `*`*(x, y: uint8): uint8 {.magic: "MulU", noSideEffect.}
+proc `*`*(x, y: uint16): uint16 {.magic: "MulU", noSideEffect.}
+proc `*`*(x, y: uint32): uint32 {.magic: "MulU", noSideEffect.}
+proc `*`*(x, y: uint64): uint64 {.magic: "MulU", noSideEffect.}
+
+proc `div`*(x, y: uint): uint {.magic: "DivU", noSideEffect.}
+  ## Computes the integer division for unsigned integers.
+  ## This is roughly the same as `trunc(x/y)`.
+proc `div`*(x, y: uint8): uint8 {.magic: "DivU", noSideEffect.}
+proc `div`*(x, y: uint16): uint16 {.magic: "DivU", noSideEffect.}
+proc `div`*(x, y: uint32): uint32 {.magic: "DivU", noSideEffect.}
+proc `div`*(x, y: uint64): uint64 {.magic: "DivU", noSideEffect.}
+
+proc `mod`*(x, y: uint): uint {.magic: "ModU", noSideEffect.}
+  ## Computes the integer modulo operation (remainder) for unsigned integers.
+  ## This is the same as `x - (x div y) * y`.
+proc `mod`*(x, y: uint8): uint8 {.magic: "ModU", noSideEffect.}
+proc `mod`*(x, y: uint16): uint16 {.magic: "ModU", noSideEffect.}
+proc `mod`*(x, y: uint32): uint32 {.magic: "ModU", noSideEffect.}
+proc `mod`*(x, y: uint64): uint64 {.magic: "ModU", noSideEffect.}
+
+proc `+=`*[T: SomeInteger](x: var T, y: T) {.
+  magic: "Inc", noSideEffect.}
+  ## Increments an integer.
+
+proc `-=`*[T: SomeInteger](x: var T, y: T) {.
+  magic: "Dec", noSideEffect.}
+  ## Decrements an integer.
+
+proc `*=`*[T: SomeInteger](x: var T, y: T) {.
+  inline, noSideEffect.} =
+  ## Binary `*=` operator for integers.
+  x = x * y
+
+# floating point operations:
+proc `+`*(x: float32): float32 {.magic: "UnaryPlusF64", noSideEffect.}
+proc `-`*(x: float32): float32 {.magic: "UnaryMinusF64", noSideEffect.}
+proc `+`*(x, y: float32): float32 {.magic: "AddF64", noSideEffect.}
+proc `-`*(x, y: float32): float32 {.magic: "SubF64", noSideEffect.}
+proc `*`*(x, y: float32): float32 {.magic: "MulF64", noSideEffect.}
+proc `/`*(x, y: float32): float32 {.magic: "DivF64", noSideEffect.}
+
+proc `+`*(x: float): float {.magic: "UnaryPlusF64", noSideEffect.}
+proc `-`*(x: float): float {.magic: "UnaryMinusF64", noSideEffect.}
+proc `+`*(x, y: float): float {.magic: "AddF64", noSideEffect.}
+proc `-`*(x, y: float): float {.magic: "SubF64", noSideEffect.}
+proc `*`*(x, y: float): float {.magic: "MulF64", noSideEffect.}
+proc `/`*(x, y: float): float {.magic: "DivF64", noSideEffect.}
+
+proc `+=`*[T: float|float32|float64] (x: var T, y: T) {.
+  inline, noSideEffect.} =
+  ## Increments in place a floating point number.
+  x = x + y
+
+proc `-=`*[T: float|float32|float64] (x: var T, y: T) {.
+  inline, noSideEffect.} =
+  ## Decrements in place a floating point number.
+  x = x - y
+
+proc `*=`*[T: float|float32|float64] (x: var T, y: T) {.
+  inline, noSideEffect.} =
+  ## Multiplies in place a floating point number.
+  x = x * y
+
+proc `/=`*(x: var float64, y: float64) {.inline, noSideEffect.} =
+  ## Divides in place a floating point number.
+  x = x / y
+
+proc `/=`*[T: float|float32](x: var T, y: T) {.inline, noSideEffect.} =
+  ## Divides in place a floating point number.
+  x = x / y
+
+# the following have to be included in system, not imported for some reason:
+
+proc `+%`*(x, y: int): int {.inline.} =
+  ## Treats `x` and `y` as unsigned and adds them.
+  ##
+  ## The result is truncated to fit into the result.
+  ## This implements modulo arithmetic. No overflow errors are possible.
+  cast[int](cast[uint](x) + cast[uint](y))
+proc `+%`*(x, y: int8): int8 {.inline.}   = cast[int8](cast[uint8](x) + cast[uint8](y))
+proc `+%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) + cast[uint16](y))
+proc `+%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) + cast[uint32](y))
+proc `+%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) + cast[uint64](y))
+
+proc `-%`*(x, y: int): int {.inline.} =
+  ## Treats `x` and `y` as unsigned and subtracts them.
+  ##
+  ## The result is truncated to fit into the result.
+  ## This implements modulo arithmetic. No overflow errors are possible.
+  cast[int](cast[uint](x) - cast[uint](y))
+proc `-%`*(x, y: int8): int8 {.inline.}   = cast[int8](cast[uint8](x) - cast[uint8](y))
+proc `-%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) - cast[uint16](y))
+proc `-%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) - cast[uint32](y))
+proc `-%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) - cast[uint64](y))
+
+proc `*%`*(x, y: int): int {.inline.} =
+  ## Treats `x` and `y` as unsigned and multiplies them.
+  ##
+  ## The result is truncated to fit into the result.
+  ## This implements modulo arithmetic. No overflow errors are possible.
+  cast[int](cast[uint](x) * cast[uint](y))
+proc `*%`*(x, y: int8): int8 {.inline.}   = cast[int8](cast[uint8](x) * cast[uint8](y))
+proc `*%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) * cast[uint16](y))
+proc `*%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) * cast[uint32](y))
+proc `*%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) * cast[uint64](y))
+
+proc `/%`*(x, y: int): int {.inline.} =
+  ## Treats `x` and `y` as unsigned and divides them.
+  ##
+  ## The result is truncated to fit into the result.
+  ## This implements modulo arithmetic. No overflow errors are possible.
+  cast[int](cast[uint](x) div cast[uint](y))
+proc `/%`*(x, y: int8): int8 {.inline.}   = cast[int8](cast[uint8](x) div cast[uint8](y))
+proc `/%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) div cast[uint16](y))
+proc `/%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) div cast[uint32](y))
+proc `/%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) div cast[uint64](y))
+
+proc `%%`*(x, y: int): int {.inline.} =
+  ## Treats `x` and `y` as unsigned and compute the modulo of `x` and `y`.
+  ##
+  ## The result is truncated to fit into the result.
+  ## This implements modulo arithmetic. No overflow errors are possible.
+  cast[int](cast[uint](x) mod cast[uint](y))
+proc `%%`*(x, y: int8): int8 {.inline.}   = cast[int8](cast[uint8](x) mod cast[uint8](y))
+proc `%%`*(x, y: int16): int16 {.inline.} = cast[int16](cast[uint16](x) mod cast[uint16](y))
+proc `%%`*(x, y: int32): int32 {.inline.} = cast[int32](cast[uint32](x) mod cast[uint32](y))
+proc `%%`*(x, y: int64): int64 {.inline.} = cast[int64](cast[uint64](x) mod cast[uint64](y))
diff --git a/lib/system/assign.nim b/lib/system/assign.nim
index 44d2e5c64..9f4cbc0fe 100755..100644
--- a/lib/system/assign.nim
+++ b/lib/system/assign.nim
@@ -1,99 +1,198 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-#when defined(debugGC):
-#  {.define: logAssign.}
-proc genericAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.}
-proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode) =
+include seqs_v2_reimpl
+
+proc genericResetAux(dest: pointer, n: ptr TNimNode) {.benign.}
+
+proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) {.benign.}
+proc genericAssignAux(dest, src: pointer, n: ptr TNimNode,
+                      shallow: bool) {.benign.} =
   var
-    d = cast[TAddress](dest)
-    s = cast[TAddress](src)
+    d = cast[int](dest)
+    s = cast[int](src)
   case n.kind
-  of nkNone: assert(false)
   of nkSlot:
-    genericAssign(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
-                  n.typ)
+    genericAssignAux(cast[pointer](d +% n.offset),
+                     cast[pointer](s +% n.offset), n.typ, shallow)
   of nkList:
     for i in 0..n.len-1:
-      genericAssignAux(dest, src, n.sons[i])
+      genericAssignAux(dest, src, n.sons[i], shallow)
   of nkCase:
+    var dd = selectBranch(dest, n)
+    var m = selectBranch(src, n)
+    # reset if different branches are in use; note different branches also
+    # imply that's not self-assignment (``x = x``)!
+    if m != dd and dd != nil:
+      genericResetAux(dest, dd)
     copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
             n.typ.size)
-    var m = selectBranch(src, n)
-    if m != nil: genericAssignAux(dest, src, m)
+    if m != nil:
+      genericAssignAux(dest, src, m, shallow)
+  of nkNone: sysAssert(false, "genericAssignAux")
+  #else:
+  #  echo "ugh memory corruption! ", n.kind
+  #  quit 1
 
-proc genericAssign(dest, src: Pointer, mt: PNimType) =
-  var
-    d = cast[TAddress](dest)
-    s = cast[TAddress](src)
+template deepSeqAssignImpl(operation, additionalArg) {.dirty.} =
+  var d = cast[ptr NimSeqV2Reimpl](dest)
+  var s = cast[ptr NimSeqV2Reimpl](src)
+  d.len = s.len
+  let elem = mt.base
+  d.p = cast[ptr NimSeqPayloadReimpl](newSeqPayload(s.len, elem.size, elem.align))
 
-  assert(mt != nil)
-  case mt.Kind
+  let bs = elem.size
+  let ba = elem.align
+  let headerSize = align(sizeof(NimSeqPayloadBase), ba)
+
+  for i in 0..d.len-1:
+    operation(d.p +! (headerSize+i*bs), s.p +! (headerSize+i*bs), mt.base, additionalArg)
+
+proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) =
+  var
+    d = cast[int](dest)
+    s = cast[int](src)
+  sysAssert(mt != nil, "genericAssignAux 2")
+  case mt.kind
+  of tyString:
+    when defined(nimSeqsV2):
+      var x = cast[ptr NimStringV2](dest)
+      var s2 = cast[ptr NimStringV2](s)[]
+      nimAsgnStrV2(x[], s2)
+    else:
+      var x = cast[PPointer](dest)
+      var s2 = cast[PPointer](s)[]
+      if s2 == nil or shallow or (
+          cast[PGenericSeq](s2).reserved and seqShallowFlag) != 0:
+        unsureAsgnRef(x, s2)
+      else:
+        unsureAsgnRef(x, copyString(cast[NimString](s2)))
   of tySequence:
-    var s2 = cast[ppointer](src)^
-    var seq = cast[PGenericSeq](s2)
-    if s2 == nil:  # this can happen! nil sequences are allowed
-      var x = cast[ppointer](dest)
-      x^ = nil
-      return
-    assert(dest != nil)
-    unsureAsgnRef(cast[ppointer](dest),
-                  newObj(mt, seq.len * mt.base.size + GenericSeqSize))
-    var dst = cast[taddress](cast[ppointer](dest)^)
-    for i in 0..seq.len-1:
-      genericAssign(
-        cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize),
-        cast[pointer](cast[taddress](s2) +% i *% mt.base.size +%
-                     GenericSeqSize),
-        mt.Base)
-    var dstseq = cast[PGenericSeq](dst)
-    dstseq.len = seq.len
-    dstseq.space = seq.len
-  of tyObject, tyTuple, tyPureObject:
-    # we don't need to copy m_type field for tyObject, as they are equal anyway
-    genericAssignAux(dest, src, mt.node)
+    when defined(nimSeqsV2):
+      deepSeqAssignImpl(genericAssignAux, shallow)
+    else:
+      var s2 = cast[PPointer](src)[]
+      var seq = cast[PGenericSeq](s2)
+      var x = cast[PPointer](dest)
+      if s2 == nil or shallow or (seq.reserved and seqShallowFlag) != 0:
+        # this can happen! nil sequences are allowed
+        unsureAsgnRef(x, s2)
+        return
+      sysAssert(dest != nil, "genericAssignAux 3")
+      if ntfNoRefs in mt.base.flags:
+        var ss = nimNewSeqOfCap(mt, seq.len)
+        cast[PGenericSeq](ss).len = seq.len
+        unsureAsgnRef(x, ss)
+        var dst = cast[int](cast[PPointer](dest)[])
+        copyMem(cast[pointer](dst +% align(GenericSeqSize, mt.base.align)),
+                cast[pointer](cast[int](s2) +% align(GenericSeqSize, mt.base.align)),
+                seq.len *% mt.base.size)
+      else:
+        unsureAsgnRef(x, newSeq(mt, seq.len))
+        var dst = cast[int](cast[PPointer](dest)[])
+        for i in 0..seq.len-1:
+          genericAssignAux(
+            cast[pointer](dst +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size ),
+            cast[pointer](cast[int](s2) +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size ),
+            mt.base, shallow)
+  of tyObject:
+    var it = mt.base
+    # don't use recursion here on the PNimType because the subtype
+    # check should only be done at the very end:
+    while it != nil:
+      genericAssignAux(dest, src, it.node, shallow)
+      it = it.base
+    genericAssignAux(dest, src, mt.node, shallow)
+    # we need to copy m_type field for tyObject, as it could be empty for
+    # sequence reallocations:
+    when defined(nimSeqsV2):
+      var pint = cast[ptr PNimTypeV2](dest)
+      #chckObjAsgn(cast[ptr PNimTypeV2](src)[].typeInfoV2, mt)
+      pint[] = cast[PNimTypeV2](mt.typeInfoV2)
+    else:
+      var pint = cast[ptr PNimType](dest)
+      # We need to copy the *static* type not the dynamic type:
+      #   if p of TB:
+      #     var tbObj = TB(p)
+      #     tbObj of TC # needs to be false!
+      #c_fprintf(stdout, "%s %s\n", pint[].name, mt.name)
+      let srcType = cast[ptr PNimType](src)[]
+      if srcType != nil:
+        # `!= nil` needed because of cases where object is not initialized properly (see bug #16706)
+        # note that you can have `srcType == nil` yet `src != nil`
+        chckObjAsgn(srcType, mt)
+      pint[] = mt # cast[ptr PNimType](src)[]
+  of tyTuple:
+    genericAssignAux(dest, src, mt.node, shallow)
   of tyArray, tyArrayConstr:
     for i in 0..(mt.size div mt.base.size)-1:
-      genericAssign(cast[pointer](d +% i*% mt.base.size),
-                    cast[pointer](s +% i*% mt.base.size), mt.base)
-  of tyString: # a leaf
-    var s2 = cast[ppointer](s)^
-    if s2 != nil: # nil strings are possible!
-      unsureAsgnRef(cast[ppointer](dest), copyString(cast[NimString](s2)))
-    else:
-      var x = cast[ppointer](dest)
-      x^ = nil
-      return
-  of tyRef:  # BUGFIX: a long time this has been forgotten!
-    unsureAsgnRef(cast[ppointer](dest), cast[ppointer](s)^)
+      genericAssignAux(cast[pointer](d +% i *% mt.base.size),
+                       cast[pointer](s +% i *% mt.base.size), mt.base, shallow)
+  of tyRef:
+    unsureAsgnRef(cast[PPointer](dest), cast[PPointer](s)[])
   else:
     copyMem(dest, src, mt.size) # copy raw bits
 
-proc genericSeqAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} =
+proc genericAssign(dest, src: pointer, mt: PNimType) {.compilerproc.} =
+  genericAssignAux(dest, src, mt, false)
+
+proc genericShallowAssign(dest, src: pointer, mt: PNimType) {.compilerproc.} =
+  genericAssignAux(dest, src, mt, true)
+
+when false:
+  proc debugNimType(t: PNimType) =
+    if t.isNil:
+      cprintf("nil!")
+      return
+    var k: cstring
+    case t.kind
+    of tyBool: k = "bool"
+    of tyChar: k = "char"
+    of tyEnum: k = "enum"
+    of tyArray: k = "array"
+    of tyObject: k = "object"
+    of tyTuple: k = "tuple"
+    of tyRange: k = "range"
+    of tyPtr: k = "ptr"
+    of tyRef: k = "ref"
+    of tyVar: k = "var"
+    of tySequence: k = "seq"
+    of tyProc: k = "proc"
+    of tyPointer: k = "range"
+    of tyOpenArray: k = "openarray"
+    of tyString: k = "string"
+    of tyCstring: k = "cstring"
+    of tyInt: k = "int"
+    of tyInt32: k = "int32"
+    else: k = "other"
+    cprintf("%s %ld\n", k, t.size)
+    debugNimType(t.base)
+
+proc genericSeqAssign(dest, src: pointer, mt: PNimType) {.compilerproc.} =
   var src = src # ugly, but I like to stress the parser sometimes :-)
   genericAssign(dest, addr(src), mt)
 
 proc genericAssignOpenArray(dest, src: pointer, len: int,
                             mt: PNimType) {.compilerproc.} =
   var
-    d = cast[TAddress](dest)
-    s = cast[TAddress](src)
+    d = cast[int](dest)
+    s = cast[int](src)
   for i in 0..len-1:
-    genericAssign(cast[pointer](d +% i*% mt.base.size),
-                  cast[pointer](s +% i*% mt.base.size), mt.base)
+    genericAssign(cast[pointer](d +% i *% mt.base.size),
+                  cast[pointer](s +% i *% mt.base.size), mt.base)
 
-proc objectInit(dest: Pointer, typ: PNimType) {.compilerProc.}
-proc objectInitAux(dest: Pointer, n: ptr TNimNode) =
-  var d = cast[TAddress](dest)
+proc objectInit(dest: pointer, typ: PNimType) {.compilerproc, benign.}
+proc objectInitAux(dest: pointer, n: ptr TNimNode) {.benign.} =
+  var d = cast[int](dest)
   case n.kind
-  of nkNone: assert(false)
-  of nkSLot: objectInit(cast[pointer](d +% n.offset), n.typ)
+  of nkNone: sysAssert(false, "objectInitAux")
+  of nkSlot: objectInit(cast[pointer](d +% n.offset), n.typ)
   of nkList:
     for i in 0..n.len-1:
       objectInitAux(dest, n.sons[i])
@@ -101,20 +200,99 @@ proc objectInitAux(dest: Pointer, n: ptr TNimNode) =
     var m = selectBranch(dest, n)
     if m != nil: objectInitAux(dest, m)
 
-proc objectInit(dest: Pointer, typ: PNimType) =
+proc objectInit(dest: pointer, typ: PNimType) =
   # the generic init proc that takes care of initialization of complex
   # objects on the stack or heap
-  var d = cast[TAddress](dest)
+  var d = cast[int](dest)
   case typ.kind
   of tyObject:
     # iterate over any structural type
     # here we have to init the type field:
-    var pint = cast[ptr PNimType](dest)
-    pint^ = typ
+    when defined(nimSeqsV2):
+      var pint = cast[ptr PNimTypeV2](dest)
+      pint[] = cast[PNimTypeV2](typ.typeInfoV2)
+    else:
+      var pint = cast[ptr PNimType](dest)
+      pint[] = typ
     objectInitAux(dest, typ.node)
-  of tyTuple, tyPureObject:
+  of tyTuple:
     objectInitAux(dest, typ.node)
   of tyArray, tyArrayConstr:
     for i in 0..(typ.size div typ.base.size)-1:
       objectInit(cast[pointer](d +% i * typ.base.size), typ.base)
-  else: nil # nothing to do
+  else: discard # nothing to do
+
+# ---------------------- assign zero -----------------------------------------
+
+proc genericReset(dest: pointer, mt: PNimType) {.compilerproc, benign.}
+proc genericResetAux(dest: pointer, n: ptr TNimNode) =
+  var d = cast[int](dest)
+  case n.kind
+  of nkNone: sysAssert(false, "genericResetAux")
+  of nkSlot: genericReset(cast[pointer](d +% n.offset), n.typ)
+  of nkList:
+    for i in 0..n.len-1: genericResetAux(dest, n.sons[i])
+  of nkCase:
+    var m = selectBranch(dest, n)
+    if m != nil: genericResetAux(dest, m)
+    zeroMem(cast[pointer](d +% n.offset), n.typ.size)
+
+proc genericReset(dest: pointer, mt: PNimType) =
+  var d = cast[int](dest)
+  sysAssert(mt != nil, "genericReset 2")
+  case mt.kind
+  of tyRef:
+    unsureAsgnRef(cast[PPointer](dest), nil)
+  of tyString:
+    when defined(nimSeqsV2):
+      var s = cast[ptr NimStringV2](dest)
+      frees(s[])
+      zeroMem(dest, mt.size)
+    else:
+      unsureAsgnRef(cast[PPointer](dest), nil)
+  of tySequence:
+    when defined(nimSeqsV2):
+      frees(cast[ptr NimSeqV2Reimpl](dest)[])
+      zeroMem(dest, mt.size)
+    else:
+      unsureAsgnRef(cast[PPointer](dest), nil)
+  of tyTuple:
+    genericResetAux(dest, mt.node)
+  of tyObject:
+    genericResetAux(dest, mt.node)
+    # also reset the type field for tyObject, for correct branch switching!
+    when defined(nimSeqsV2):
+      var pint = cast[ptr PNimTypeV2](dest)
+      pint[] = nil
+    else:
+      var pint = cast[ptr PNimType](dest)
+      pint[] = nil
+  of tyArray, tyArrayConstr:
+    for i in 0..(mt.size div mt.base.size)-1:
+      genericReset(cast[pointer](d +% i *% mt.base.size), mt.base)
+  else:
+    zeroMem(dest, mt.size) # set raw bits to zero
+
+proc selectBranch(discVal, L: int,
+                  a: ptr array[0x7fff, ptr TNimNode]): ptr TNimNode =
+  if discVal <% L:
+    result = a[discVal]
+    if result == nil:
+      result = a[L]
+  else:
+    result = a[L] # a[L] contains the ``else`` part (but may be nil)
+
+proc FieldDiscriminantCheck(oldDiscVal, newDiscVal: int,
+                            a: ptr array[0x7fff, ptr TNimNode],
+                            L: int) {.compilerproc.} =
+  let oldBranch = selectBranch(oldDiscVal, L, a)
+  let newBranch = selectBranch(newDiscVal, L, a)
+  when defined(nimOldCaseObjects):
+    if newBranch != oldBranch and oldDiscVal != 0:
+      sysFatal(FieldDefect, "assignment to discriminant changes object branch")
+  else:
+    if newBranch != oldBranch:
+      if oldDiscVal != 0:
+        sysFatal(FieldDefect, "assignment to discriminant changes object branch")
+      else:
+        sysFatal(FieldDefect, "assignment to discriminant changes object branch; compile with -d:nimOldCaseObjects for a transition period")
diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim
new file mode 100644
index 000000000..8d4b7e897
--- /dev/null
+++ b/lib/system/avltree.nim
@@ -0,0 +1,97 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# not really an AVL tree anymore, but still balanced ...
+
+template isBottom(n: PAvlNode): bool = n.link[0] == n
+
+proc lowGauge(n: PAvlNode): int =
+  var it = n
+  while not isBottom(it):
+    result = it.key
+    it = it.link[0]
+
+proc highGauge(n: PAvlNode): int =
+  result = -1
+  var it = n
+  while not isBottom(it):
+    result = it.upperBound
+    it = it.link[1]
+
+proc find(root: PAvlNode, key: int): PAvlNode =
+  var it = root
+  while not isBottom(it):
+    if it.key == key: return it
+    it = it.link[ord(it.key <% key)]
+
+proc inRange(root: PAvlNode, key: int): PAvlNode =
+  var it = root
+  while not isBottom(it):
+    if it.key <=% key and key <% it.upperBound: return it
+    it = it.link[ord(it.key <% key)]
+
+proc skew(t: var PAvlNode) =
+  if t.link[0].level == t.level:
+    var temp = t
+    t = t.link[0]
+    temp.link[0] = t.link[1]
+    t.link[1] = temp
+
+proc split(t: var PAvlNode) =
+  if t.link[1].link[1].level == t.level:
+    var temp = t
+    t = t.link[1]
+    temp.link[1] = t.link[0]
+    t.link[0] = temp
+    inc t.level
+
+proc add(a: var MemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} =
+  if t.isBottom:
+    t = allocAvlNode(a, key, upperBound)
+  else:
+    if key <% t.key:
+      when defined(avlcorruption):
+        if t.link[0] == nil:
+          cprintf("bug here %p\n", t)
+      add(a, t.link[0], key, upperBound)
+    elif key >% t.key:
+      when defined(avlcorruption):
+        if t.link[1] == nil:
+          cprintf("bug here B %p\n", t)
+      add(a, t.link[1], key, upperBound)
+    else:
+      sysAssert false, "key already exists"
+    skew(t)
+    split(t)
+
+proc del(a: var MemRegion, t: var PAvlNode, x: int) {.benign.} =
+  if isBottom(t): return
+  a.last = t
+  if x <% t.key:
+    del(a, t.link[0], x)
+  else:
+    a.deleted = t
+    del(a, t.link[1], x)
+  if t == a.last and not isBottom(a.deleted) and x == a.deleted.key:
+    a.deleted.key = t.key
+    a.deleted.upperBound = t.upperBound
+    a.deleted = getBottom(a)
+    t = t.link[1]
+    deallocAvlNode(a, a.last)
+  elif t.link[0].level < t.level-1 or
+       t.link[1].level < t.level-1:
+    dec t.level
+    if t.link[1].level > t.level:
+      t.link[1].level = t.level
+    skew(t)
+    skew(t.link[1])
+    skew(t.link[1].link[1])
+    split(t)
+    split(t.link[1])
+
diff --git a/lib/system/basic_types.nim b/lib/system/basic_types.nim
new file mode 100644
index 000000000..bf81b9b6a
--- /dev/null
+++ b/lib/system/basic_types.nim
@@ -0,0 +1,94 @@
+type
+  int* {.magic: Int.}         ## Default integer type; bitwidth depends on
+                              ## architecture, but is always the same as a pointer.
+  int8* {.magic: Int8.}       ## Signed 8 bit integer type.
+  int16* {.magic: Int16.}     ## Signed 16 bit integer type.
+  int32* {.magic: Int32.}     ## Signed 32 bit integer type.
+  int64* {.magic: Int64.}     ## Signed 64 bit integer type.
+  uint* {.magic: UInt.}       ## Unsigned default integer type.
+  uint8* {.magic: UInt8.}     ## Unsigned 8 bit integer type.
+  uint16* {.magic: UInt16.}   ## Unsigned 16 bit integer type.
+  uint32* {.magic: UInt32.}   ## Unsigned 32 bit integer type.
+  uint64* {.magic: UInt64.}   ## Unsigned 64 bit integer type.
+
+type
+  float* {.magic: Float.}     ## Default floating point type.
+  float32* {.magic: Float32.} ## 32 bit floating point type.
+  float64* {.magic: Float.}   ## 64 bit floating point type.
+
+# 'float64' is now an alias to 'float'; this solves many problems
+
+type
+  char* {.magic: Char.}         ## Built-in 8 bit character type (unsigned).
+  string* {.magic: String.}     ## Built-in string 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.
+
+  typedesc* {.magic: TypeDesc.} ## Meta type to denote a type description.
+
+type
+  `ptr`*[T] {.magic: Pointer.}   ## Built-in generic untraced pointer type.
+  `ref`*[T] {.magic: Pointer.}   ## Built-in generic traced pointer type.
+
+  `nil` {.magic: "Nil".}
+
+  void* {.magic: "VoidType".}    ## Meta type to denote the absence of any type.
+  auto* {.magic: Expr.}          ## Meta type for automatic type determination.
+  any* {.deprecated: "Deprecated since v1.5; Use auto instead.".} = distinct auto  ## Deprecated; Use `auto` instead. See https://github.com/nim-lang/RFCs/issues/281
+  untyped* {.magic: Expr.}       ## Meta type to denote an expression that
+                                 ## is not resolved (for templates).
+  typed* {.magic: Stmt.}         ## Meta type to denote an expression that
+                                 ## is resolved (for templates).
+
+type # we need to start a new type section here, so that ``0`` can have a type
+  bool* {.magic: "Bool".} = enum ## Built-in boolean type.
+    false = 0, true = 1
+
+const
+  on* = true    ## Alias for `true`.
+  off* = false  ## Alias for `false`.
+
+type
+  SomeSignedInt* = int|int8|int16|int32|int64
+    ## Type class matching all signed integer types.
+
+  SomeUnsignedInt* = uint|uint8|uint16|uint32|uint64
+    ## Type class matching all unsigned integer types.
+
+  SomeInteger* = SomeSignedInt|SomeUnsignedInt
+    ## Type class matching all integer types.
+
+  SomeFloat* = float|float32|float64
+    ## Type class matching all floating point number types.
+
+  SomeNumber* = SomeInteger|SomeFloat
+    ## Type class matching all number types.
+
+  SomeOrdinal* = int|int8|int16|int32|int64|bool|enum|uint|uint8|uint16|uint32|uint64
+    ## Type class matching all ordinal types; however this includes enums with
+    ## holes. See also `Ordinal`
+
+
+{.push warning[GcMem]: off, warning[Uninit]: off.}
+{.push hints: off.}
+
+proc `not`*(x: bool): bool {.magic: "Not", noSideEffect.}
+  ## Boolean not; returns true if `x == false`.
+
+proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
+  ## Boolean `and`; returns true if `x == y == true` (if both arguments
+  ## are true).
+  ##
+  ## Evaluation is lazy: if `x` is false, `y` will not even be evaluated.
+proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
+  ## Boolean `or`; returns true if `not (not x and not y)` (if any of
+  ## the arguments is true).
+  ##
+  ## Evaluation is lazy: if `x` is true, `y` will not even be evaluated.
+proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
+  ## Boolean `exclusive or`; returns true if `x != y` (if either argument
+  ## is true while the other is false).
+
+{.pop.}
+{.pop.}
diff --git a/lib/system/bitmasks.nim b/lib/system/bitmasks.nim
new file mode 100644
index 000000000..0663247c2
--- /dev/null
+++ b/lib/system/bitmasks.nim
@@ -0,0 +1,39 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Page size of the system; in most cases 4096 bytes. For exotic OS or
+# CPU this needs to be changed:
+const
+  PageShift = when defined(nimPage256) or defined(cpu16): 3
+              elif defined(nimPage512): 9
+              elif defined(nimPage1k): 10
+              else: 12 # \ # my tests showed no improvements for using larger page sizes.
+
+  PageSize = 1 shl PageShift
+  PageMask = PageSize-1
+
+
+  MemAlign = # also minimal allocatable memory block
+    when defined(nimMemAlignTiny): 4
+    elif defined(useMalloc):
+      when defined(amd64): 16 
+      else: 8
+    else: 16
+
+  BitsPerPage = PageSize div MemAlign
+  UnitsPerPage = BitsPerPage div (sizeof(int)*8)
+    # how many ints do we need to describe a page:
+    # on 32 bit systems this is only 16 (!)
+
+  TrunkShift = 9
+  BitsPerTrunk = 1 shl TrunkShift # needs to be power of 2 and divisible by 64
+  TrunkMask = BitsPerTrunk - 1
+  IntsPerTrunk = BitsPerTrunk div (sizeof(int)*8)
+  IntShift = 5 + ord(sizeof(int) == 8) # 5 or 6, depending on int width
+  IntMask = 1 shl IntShift - 1
diff --git a/lib/system/cellseqs_v1.nim b/lib/system/cellseqs_v1.nim
new file mode 100644
index 000000000..1a305aa42
--- /dev/null
+++ b/lib/system/cellseqs_v1.nim
@@ -0,0 +1,46 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# ------------------- cell seq handling ---------------------------------------
+
+type
+  PCellArray = ptr UncheckedArray[PCell]
+  CellSeq {.final, pure.} = object
+    len, cap: int
+    d: PCellArray
+
+proc contains(s: CellSeq, c: PCell): bool {.inline.} =
+  for i in 0 ..< s.len:
+    if s.d[i] == c:
+      return true
+  return false
+
+proc resize(s: var CellSeq) =
+  s.cap = s.cap * 3 div 2
+  let d = cast[PCellArray](alloc(s.cap * sizeof(PCell)))
+  copyMem(d, s.d, s.len * sizeof(PCell))
+  dealloc(s.d)
+  s.d = d
+
+proc add(s: var CellSeq, c: PCell) {.inline.} =
+  if s.len >= s.cap:
+    resize(s)
+  s.d[s.len] = c
+  inc(s.len)
+
+proc init(s: var CellSeq, cap: int = 1024) =
+  s.len = 0
+  s.cap = cap
+  s.d = cast[PCellArray](alloc0(cap * sizeof(PCell)))
+
+proc deinit(s: var CellSeq) =
+  dealloc(s.d)
+  s.d = nil
+  s.len = 0
+  s.cap = 0
diff --git a/lib/system/cellseqs_v2.nim b/lib/system/cellseqs_v2.nim
new file mode 100644
index 000000000..c6c7b1a8e
--- /dev/null
+++ b/lib/system/cellseqs_v2.nim
@@ -0,0 +1,53 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Cell seqs for cyclebreaker and cyclicrefs_v2.
+
+type
+  CellTuple[T] = (T, PNimTypeV2)
+  CellArray[T] = ptr UncheckedArray[CellTuple[T]]
+  CellSeq[T] = object
+    len, cap: int
+    d: CellArray[T]
+
+proc resize[T](s: var CellSeq[T]) =
+  s.cap = s.cap * 3 div 2
+  var newSize = s.cap * sizeof(CellTuple[T])
+  when compileOption("threads"):
+    s.d = cast[CellArray[T]](reallocShared(s.d, newSize))
+  else:
+    s.d = cast[CellArray[T]](realloc(s.d, newSize))
+
+proc add[T](s: var CellSeq[T], c: T, t: PNimTypeV2) {.inline.} =
+  if s.len >= s.cap:
+    s.resize()
+  s.d[s.len] = (c, t)
+  inc(s.len)
+
+proc init[T](s: var CellSeq[T], cap: int = 1024) =
+  s.len = 0
+  s.cap = cap
+  when compileOption("threads"):
+    s.d = cast[CellArray[T]](allocShared(uint(s.cap * sizeof(CellTuple[T]))))
+  else:
+    s.d = cast[CellArray[T]](alloc(s.cap * sizeof(CellTuple[T])))
+
+proc deinit[T](s: var CellSeq[T]) =
+  if s.d != nil:
+    when compileOption("threads"):
+      deallocShared(s.d)
+    else:
+      dealloc(s.d)
+    s.d = nil
+  s.len = 0
+  s.cap = 0
+
+proc pop[T](s: var CellSeq[T]): (T, PNimTypeV2) =
+  result = s.d[s.len-1]
+  dec s.len
diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim
index 0ce83864c..92036c226 100755..100644
--- a/lib/system/cellsets.nim
+++ b/lib/system/cellsets.nim
@@ -1,81 +1,100 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-# Efficient set of pointers for the GC (and repr)
+
+#[
+
+Efficient set of pointers for the GC (and repr)
+-----------------------------------------------
+
+The GC depends on an extremely efficient datastructure for storing a
+set of pointers - this is called a `CellSet` in the source code.
+Inserting, deleting and searching are done in constant time. However,
+modifying a `CellSet` during traversal leads to undefined behaviour.
+
+All operations on a CellSet have to perform efficiently. Because a Cellset can
+become huge a hash table alone is not suitable for this.
+
+We use a mixture of bitset and hash table for this. The hash table maps *pages*
+to a page descriptor. The page descriptor contains a bit for any possible cell
+address within this page. So including a cell is done as follows:
+
+- Find the page descriptor for the page the cell belongs to.
+- Set the appropriate bit in the page descriptor indicating that the
+  cell points to the start of a memory block.
+
+Removing a cell is analogous - the bit has to be set to zero.
+Single page descriptors are never deleted from the hash table. This is not
+needed as the data structures needs to be rebuilt periodically anyway.
+
+Complete traversal is done in this way::
+
+  for each page descriptor d:
+    for each bit in d:
+      if bit == 1:
+        traverse the pointer belonging to this bit
+
+]#
+
+when defined(gcOrc) or defined(gcArc) or defined(gcAtomicArc):
+  type
+    PCell = Cell
+
+  when not declaredInScope(PageShift):
+    include bitmasks
+
+else:
+  type
+    RefCount = int
+
+    Cell {.pure.} = object
+      refcount: RefCount  # the refcount and some flags
+      typ: PNimType
+      when trackAllocationSource:
+        filename: cstring
+        line: int
+      when useCellIds:
+        id: int
+
+    PCell = ptr Cell
 
 type
-  TCell {.pure.} = object
-    refcount: int  # the refcount and some flags
-    typ: PNimType
-    when debugGC:
-      filename: cstring
-      line: int
-
-  PCell = ptr TCell
-
-  PPageDesc = ptr TPageDesc
-  TBitIndex = range[0..UnitsPerPage-1]
-  TPageDesc {.final, pure.} = object
+  PPageDesc = ptr PageDesc
+  BitIndex = range[0..UnitsPerPage-1]
+  PageDesc {.final, pure.} = object
     next: PPageDesc # all nodes are connected with this pointer
-    key: TAddress   # start address at bit 0
-    bits: array[TBitIndex, int] # a bit vector
+    key: uint   # start address at bit 0
+    bits: array[BitIndex, int] # a bit vector
 
-  PPageDescArray = ptr array[0..1000_000, PPageDesc]
-  TCellSet {.final, pure.} = object
+  PPageDescArray = ptr UncheckedArray[PPageDesc]
+  CellSet {.final, pure.} = object
     counter, max: int
     head: PPageDesc
     data: PPageDescArray
 
-  PCellArray = ptr array[0..100_000_000, PCell]
-  TCellSeq {.final, pure.} = object
-    len, cap: int
-    d: PCellArray
+when defined(gcOrc) or defined(gcArc) or defined(gcAtomicArc):
+  discard
+else:
+  include cellseqs_v1
 
 # ------------------- cell set handling ---------------------------------------
 
-proc contains(s: TCellSeq, c: PCell): bool {.inline.} =
-  for i in 0 .. s.len-1:
-    if s.d[i] == c: return True
-  return False
-
-proc add(s: var TCellSeq, c: PCell) {.inline.} =
-  if s.len >= s.cap:
-    s.cap = s.cap * 3 div 2
-    var d = cast[PCellArray](alloc(s.cap * sizeof(PCell)))
-    copyMem(d, s.d, s.len * sizeof(PCell))
-    dealloc(s.d)
-    s.d = d
-    # XXX: realloc?
-  s.d[s.len] = c
-  inc(s.len)
-
-proc init(s: var TCellSeq, cap: int = 1024) =
-  s.len = 0
-  s.cap = cap
-  s.d = cast[PCellArray](alloc0(cap * sizeof(PCell)))
-
-proc deinit(s: var TCellSeq) = 
-  dealloc(s.d)
-  s.d = nil
-  s.len = 0
-  s.cap = 0
-
 const
   InitCellSetSize = 1024 # must be a power of two!
 
-proc Init(s: var TCellSet) =
+proc init(s: var CellSet) =
   s.data = cast[PPageDescArray](alloc0(InitCellSetSize * sizeof(PPageDesc)))
   s.max = InitCellSetSize-1
   s.counter = 0
   s.head = nil
 
-proc Deinit(s: var TCellSet) =
+proc deinit(s: var CellSet) =
   var it = s.head
   while it != nil:
     var n = it.next
@@ -91,33 +110,33 @@ proc nextTry(h, maxHash: int): int {.inline.} =
   # For any initial h in range(maxHash), repeating that maxHash times
   # generates each int in range(maxHash) exactly once (see any text on
   # random-number generation for proof).
-  
-proc CellSetGet(t: TCellSet, key: TAddress): PPageDesc =
+
+proc cellSetGet(t: CellSet, key: uint): PPageDesc =
   var h = cast[int](key) and t.max
   while t.data[h] != nil:
     if t.data[h].key == key: return t.data[h]
     h = nextTry(h, t.max)
   return nil
 
-proc CellSetRawInsert(t: TCellSet, data: PPageDescArray, desc: PPageDesc) =
+proc cellSetRawInsert(t: CellSet, data: PPageDescArray, desc: PPageDesc) =
   var h = cast[int](desc.key) and t.max
   while data[h] != nil:
-    assert(data[h] != desc)
+    sysAssert(data[h] != desc, "CellSetRawInsert 1")
     h = nextTry(h, t.max)
-  assert(data[h] == nil)
+  sysAssert(data[h] == nil, "CellSetRawInsert 2")
   data[h] = desc
 
-proc CellSetEnlarge(t: var TCellSet) =
+proc cellSetEnlarge(t: var CellSet) =
   var oldMax = t.max
   t.max = ((t.max+1)*2)-1
   var n = cast[PPageDescArray](alloc0((t.max + 1) * sizeof(PPageDesc)))
-  for i in 0 .. oldmax:
+  for i in 0 .. oldMax:
     if t.data[i] != nil:
-      CellSetRawInsert(t, n, t.data[i])
+      cellSetRawInsert(t, n, t.data[i])
   dealloc(t.data)
   t.data = n
 
-proc CellSetPut(t: var TCellSet, key: TAddress): PPageDesc =
+proc cellSetPut(t: var CellSet, key: uint): PPageDesc =
   var h = cast[int](key) and t.max
   while true:
     var x = t.data[h]
@@ -126,13 +145,13 @@ proc CellSetPut(t: var TCellSet, key: TAddress): PPageDesc =
     h = nextTry(h, t.max)
 
   if ((t.max+1)*2 < t.counter*3) or ((t.max+1)-t.counter < 4):
-    CellSetEnlarge(t)
+    cellSetEnlarge(t)
   inc(t.counter)
   h = cast[int](key) and t.max
   while t.data[h] != nil: h = nextTry(h, t.max)
-  assert(t.data[h] == nil)
+  sysAssert(t.data[h] == nil, "CellSetPut")
   # the new page descriptor goes into result
-  result = cast[PPageDesc](alloc0(sizeof(TPageDesc)))
+  result = cast[PPageDesc](alloc0(sizeof(PageDesc)))
   result.next = t.head
   result.key = key
   t.head = result
@@ -140,57 +159,110 @@ proc CellSetPut(t: var TCellSet, key: TAddress): PPageDesc =
 
 # ---------- slightly higher level procs --------------------------------------
 
-proc contains(s: TCellSet, cell: PCell): bool =
-  var u = cast[TAddress](cell)
-  var t = CellSetGet(s, u shr PageShift)
+proc contains(s: CellSet, cell: PCell): bool =
+  var u = cast[uint](cell)
+  var t = cellSetGet(s, u shr PageShift)
   if t != nil:
-    u = (u %% PageSize) /% MemAlign
+    u = (u mod PageSize) div MemAlign
     result = (t.bits[u shr IntShift] and (1 shl (u and IntMask))) != 0
   else:
     result = false
 
-proc incl(s: var TCellSet, cell: PCell) {.noinline.} =
-  var u = cast[TAddress](cell)
-  var t = CellSetPut(s, u shr PageShift)
-  u = (u %% PageSize) /% MemAlign
+proc incl(s: var CellSet, cell: PCell) =
+  var u = cast[uint](cell)
+  var t = cellSetPut(s, u shr PageShift)
+  u = (u mod PageSize) div MemAlign
   t.bits[u shr IntShift] = t.bits[u shr IntShift] or (1 shl (u and IntMask))
 
-proc excl(s: var TCellSet, cell: PCell) =
-  var u = cast[TAddress](cell)
-  var t = CellSetGet(s, u shr PageShift)
+proc excl(s: var CellSet, cell: PCell) =
+  var u = cast[uint](cell)
+  var t = cellSetGet(s, u shr PageShift)
   if t != nil:
-    u = (u %% PageSize) /% MemAlign
+    u = (u mod PageSize) div MemAlign
     t.bits[u shr IntShift] = (t.bits[u shr IntShift] and
                               not (1 shl (u and IntMask)))
 
-proc containsOrIncl(s: var TCellSet, cell: PCell): bool = 
-  var u = cast[TAddress](cell)
-  var t = CellSetGet(s, u shr PageShift)
+proc containsOrIncl(s: var CellSet, cell: PCell): bool =
+  var u = cast[uint](cell)
+  var t = cellSetGet(s, u shr PageShift)
   if t != nil:
-    u = (u %% PageSize) /% MemAlign
+    u = (u mod PageSize) div MemAlign
     result = (t.bits[u shr IntShift] and (1 shl (u and IntMask))) != 0
-    if not result: 
+    if not result:
       t.bits[u shr IntShift] = t.bits[u shr IntShift] or
           (1 shl (u and IntMask))
-  else: 
-    Incl(s, cell)
+  else:
+    incl(s, cell)
     result = false
 
-iterator elements(t: TCellSet): PCell {.inline.} =
+iterator elements(t: CellSet): PCell {.inline.} =
   # while traversing it is forbidden to add pointers to the tree!
   var r = t.head
   while r != nil:
-    var i = 0
-    while i <= high(r.bits):
+    var i: uint = 0
+    while int(i) <= high(r.bits):
       var w = r.bits[i] # taking a copy of r.bits[i] here is correct, because
       # modifying operations are not allowed during traversation
-      var j = 0
+      var j: uint = 0
       while w != 0:         # test all remaining bits for zero
         if (w and 1) != 0:  # the bit is set!
           yield cast[PCell]((r.key shl PageShift) or
-                              (i shl IntShift +% j) *% MemAlign)
+                              (i shl IntShift + j) * MemAlign)
         inc(j)
         w = w shr 1
       inc(i)
     r = r.next
 
+when false:
+  type
+    CellSetIter = object
+      p: PPageDesc
+      i, w, j: int
+
+  proc next(it: var CellSetIter): PCell =
+    while true:
+      while it.w != 0:         # test all remaining bits for zero
+        if (it.w and 1) != 0:  # the bit is set!
+          result = cast[PCell]((it.p.key shl PageShift) or
+                               (it.i shl IntShift +% it.j) *% MemAlign)
+
+          inc(it.j)
+          it.w = it.w shr 1
+          return
+        else:
+          inc(it.j)
+          it.w = it.w shr 1
+      # load next w:
+      if it.i >= high(it.p.bits):
+        it.i = 0
+        it.j = 0
+        it.p = it.p.next
+        if it.p == nil: return nil
+      else:
+        inc it.i
+      it.w = it.p.bits[i]
+
+  proc init(it: var CellSetIter; t: CellSet): PCell =
+    it.p = t.head
+    it.i = -1
+    it.w = 0
+    result = it.next
+
+iterator elementsExcept(t, s: CellSet): PCell {.inline.} =
+  var r = t.head
+  while r != nil:
+    let ss = cellSetGet(s, r.key)
+    var i:uint = 0
+    while int(i) <= high(r.bits):
+      var w = r.bits[i]
+      if ss != nil:
+        w = w and not ss.bits[i]
+      var j:uint = 0
+      while w != 0:
+        if (w and 1) != 0:
+          yield cast[PCell]((r.key shl PageShift) or
+                              (i shl IntShift + j) * MemAlign)
+        inc(j)
+        w = w shr 1
+      inc(i)
+    r = r.next
diff --git a/lib/system/cgprocs.nim b/lib/system/cgprocs.nim
new file mode 100644
index 000000000..9a7645f9b
--- /dev/null
+++ b/lib/system/cgprocs.nim
@@ -0,0 +1,10 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Headers for procs that the code generator depends on ("compilerprocs")
diff --git a/lib/system/channels_builtin.nim b/lib/system/channels_builtin.nim
new file mode 100644
index 000000000..02b4d8cbf
--- /dev/null
+++ b/lib/system/channels_builtin.nim
@@ -0,0 +1,459 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Channel support for threads.
+##
+## **Note**: This is part of the system module. Do not import it directly.
+## To activate thread support compile with the `--threads:on` command line switch.
+##
+## **Note:** Channels are designed for the `Thread` type. They are unstable when
+## used with `spawn`
+##
+## **Note:** The current implementation of message passing does
+## not work with cyclic data structures.
+##
+## **Note:** Channels cannot be passed between threads. Use globals or pass
+## them by `ptr`.
+##
+## Example
+## =======
+## The following is a simple example of two different ways to use channels:
+## blocking and non-blocking.
+##
+##   ```Nim
+##   # Be sure to compile with --threads:on.
+##   # The channels and threads modules are part of system and should not be
+##   # imported.
+##   import std/os
+##
+##   # Channels can either be:
+##   #  - declared at the module level, or
+##   #  - passed to procedures by ptr (raw pointer) -- see note on safety.
+##   #
+##   # For simplicity, in this example a channel is declared at module scope.
+##   # Channels are generic, and they include support for passing objects between
+##   # threads.
+##   # Note that objects passed through channels will be deeply copied.
+##   var chan: Channel[string]
+##
+##   # This proc will be run in another thread using the threads module.
+##   proc firstWorker() =
+##     chan.send("Hello World!")
+##
+##   # This is another proc to run in a background thread. This proc takes a while
+##   # to send the message since it sleeps for 2 seconds (or 2000 milliseconds).
+##   proc secondWorker() =
+##     sleep(2000)
+##     chan.send("Another message")
+##
+##   # Initialize the channel.
+##   chan.open()
+##
+##   # Launch the worker.
+##   var worker1: Thread[void]
+##   createThread(worker1, firstWorker)
+##
+##   # Block until the message arrives, then print it out.
+##   echo chan.recv() # "Hello World!"
+##
+##   # Wait for the thread to exit before moving on to the next example.
+##   worker1.joinThread()
+##
+##   # Launch the other worker.
+##   var worker2: Thread[void]
+##   createThread(worker2, secondWorker)
+##   # This time, use a non-blocking approach with tryRecv.
+##   # Since the main thread is not blocked, it could be used to perform other
+##   # useful work while it waits for data to arrive on the channel.
+##   while true:
+##     let tried = chan.tryRecv()
+##     if tried.dataAvailable:
+##       echo tried.msg # "Another message"
+##       break
+##
+##     echo "Pretend I'm doing useful work..."
+##     # For this example, sleep in order not to flood stdout with the above
+##     # message.
+##     sleep(400)
+##
+##   # Wait for the second thread to exit before cleaning up the channel.
+##   worker2.joinThread()
+##
+##   # Clean up the channel.
+##   chan.close()
+##   ```
+##
+## Sample output
+## -------------
+## The program should output something similar to this, but keep in mind that
+## exact results may vary in the real world:
+##
+##     Hello World!
+##     Pretend I'm doing useful work...
+##     Pretend I'm doing useful work...
+##     Pretend I'm doing useful work...
+##     Pretend I'm doing useful work...
+##     Pretend I'm doing useful work...
+##     Another message
+##
+## Passing Channels Safely
+## -----------------------
+## Note that when passing objects to procedures on another thread by pointer
+## (for example through a thread's argument), objects created using the default
+## allocator will use thread-local, GC-managed memory. Thus it is generally
+## safer to store channel objects in global variables (as in the above example),
+## in which case they will use a process-wide (thread-safe) shared heap.
+##
+## However, it is possible to manually allocate shared memory for channels
+## using e.g. `system.allocShared0` and pass these pointers through thread
+## arguments:
+##
+##   ```Nim
+##   proc worker(channel: ptr Channel[string]) =
+##     let greeting = channel[].recv()
+##     echo greeting
+##
+##   proc localChannelExample() =
+##     # Use allocShared0 to allocate some shared-heap memory and zero it.
+##     # The usual warnings about dealing with raw pointers apply. Exercise caution.
+##     var channel = cast[ptr Channel[string]](
+##       allocShared0(sizeof(Channel[string]))
+##     )
+##     channel[].open()
+##     # Create a thread which will receive the channel as an argument.
+##     var thread: Thread[ptr Channel[string]]
+##     createThread(thread, worker, channel)
+##     channel[].send("Hello from the main thread!")
+##     # Clean up resources.
+##     thread.joinThread()
+##     channel[].close()
+##     deallocShared(channel)
+##
+##   localChannelExample() # "Hello from the main thread!"
+##   ```
+
+when not declared(ThisIsSystem):
+  {.error: "You must not import this module explicitly".}
+
+import std/private/syslocks
+
+type
+  pbytes = ptr UncheckedArray[byte]
+  RawChannel {.pure, final.} = object ## msg queue for a thread
+    rd, wr, count, mask, maxItems: int
+    data: pbytes
+    lock: SysLock
+    cond: SysCond
+    elemType: PNimType
+    ready: bool
+    when not usesDestructors:
+      region: MemRegion
+  PRawChannel = ptr RawChannel
+  LoadStoreMode = enum mStore, mLoad
+  Channel*[TMsg] {.gcsafe.} = RawChannel ## a channel for thread communication
+
+const ChannelDeadMask = -2
+
+proc initRawChannel(p: pointer, maxItems: int) =
+  var c = cast[PRawChannel](p)
+  initSysLock(c.lock)
+  initSysCond(c.cond)
+  c.mask = -1
+  c.maxItems = maxItems
+
+proc deinitRawChannel(p: pointer) =
+  var c = cast[PRawChannel](p)
+  # we need to grab the lock to be safe against sending threads!
+  acquireSys(c.lock)
+  c.mask = ChannelDeadMask
+  when not usesDestructors:
+    deallocOsPages(c.region)
+  else:
+    if c.data != nil: deallocShared(c.data)
+  deinitSys(c.lock)
+  deinitSysCond(c.cond)
+
+when not usesDestructors:
+
+  proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel,
+                mode: LoadStoreMode) {.benign.}
+
+  proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel,
+                mode: LoadStoreMode) {.benign.} =
+    var
+      d = cast[int](dest)
+      s = cast[int](src)
+    case n.kind
+    of nkSlot: storeAux(cast[pointer](d +% n.offset),
+                        cast[pointer](s +% n.offset), n.typ, t, mode)
+    of nkList:
+      for i in 0..n.len-1: storeAux(dest, src, n.sons[i], t, mode)
+    of nkCase:
+      copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
+              n.typ.size)
+      var m = selectBranch(src, n)
+      if m != nil: storeAux(dest, src, m, t, mode)
+    of nkNone: sysAssert(false, "storeAux")
+
+  proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel,
+                mode: LoadStoreMode) =
+    template `+!`(p: pointer; x: int): pointer =
+      cast[pointer](cast[int](p) +% x)
+
+    var
+      d = cast[int](dest)
+      s = cast[int](src)
+    sysAssert(mt != nil, "mt == nil")
+    case mt.kind
+    of tyString:
+      if mode == mStore:
+        var x = cast[PPointer](dest)
+        var s2 = cast[PPointer](s)[]
+        if s2 == nil:
+          x[] = nil
+        else:
+          var ss = cast[NimString](s2)
+          var ns = cast[NimString](alloc(t.region, GenericSeqSize + ss.len+1))
+          copyMem(ns, ss, ss.len+1 + GenericSeqSize)
+          x[] = ns
+      else:
+        var x = cast[PPointer](dest)
+        var s2 = cast[PPointer](s)[]
+        if s2 == nil:
+          unsureAsgnRef(x, s2)
+        else:
+          let y = copyDeepString(cast[NimString](s2))
+          #echo "loaded ", cast[int](y), " ", cast[string](y)
+          unsureAsgnRef(x, y)
+          dealloc(t.region, s2)
+    of tySequence:
+      var s2 = cast[PPointer](src)[]
+      var seq = cast[PGenericSeq](s2)
+      var x = cast[PPointer](dest)
+      if s2 == nil:
+        if mode == mStore:
+          x[] = nil
+        else:
+          unsureAsgnRef(x, nil)
+      else:
+        sysAssert(dest != nil, "dest == nil")
+        if mode == mStore:
+          x[] = alloc0(t.region, align(GenericSeqSize, mt.base.align) +% seq.len *% mt.base.size)
+        else:
+          unsureAsgnRef(x, newSeq(mt, seq.len))
+        var dst = cast[int](cast[PPointer](dest)[])
+        var dstseq = cast[PGenericSeq](dst)
+        dstseq.len = seq.len
+        dstseq.reserved = seq.len
+        for i in 0..seq.len-1:
+          storeAux(
+            cast[pointer](dst +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size),
+            cast[pointer](cast[int](s2) +% align(GenericSeqSize, mt.base.align) +%
+                          i *% mt.base.size),
+            mt.base, t, mode)
+        if mode != mStore: dealloc(t.region, s2)
+    of tyObject:
+      if mt.base != nil:
+        storeAux(dest, src, mt.base, t, mode)
+      else:
+        # copy type field:
+        var pint = cast[ptr PNimType](dest)
+        pint[] = cast[ptr PNimType](src)[]
+      storeAux(dest, src, mt.node, t, mode)
+    of tyTuple:
+      storeAux(dest, src, mt.node, t, mode)
+    of tyArray, tyArrayConstr:
+      for i in 0..(mt.size div mt.base.size)-1:
+        storeAux(cast[pointer](d +% i *% mt.base.size),
+                cast[pointer](s +% i *% mt.base.size), mt.base, t, mode)
+    of tyRef:
+      var s = cast[PPointer](src)[]
+      var x = cast[PPointer](dest)
+      if s == nil:
+        if mode == mStore:
+          x[] = nil
+        else:
+          unsureAsgnRef(x, nil)
+      else:
+        #let size = if mt.base.kind == tyObject: cast[ptr PNimType](s)[].size
+        #           else: mt.base.size
+        if mode == mStore:
+          let dyntype = when declared(usrToCell): usrToCell(s).typ
+                        else: mt
+          let size = dyntype.base.size
+          # we store the real dynamic 'ref type' at offset 0, so that
+          # no information is lost
+          let a = alloc0(t.region, size+sizeof(pointer))
+          x[] = a
+          cast[PPointer](a)[] = dyntype
+          storeAux(a +! sizeof(pointer), s, dyntype.base, t, mode)
+        else:
+          let dyntype = cast[ptr PNimType](s)[]
+          var obj = newObj(dyntype, dyntype.base.size)
+          unsureAsgnRef(x, obj)
+          storeAux(x[], s +! sizeof(pointer), dyntype.base, t, mode)
+          dealloc(t.region, s)
+    else:
+      copyMem(dest, src, mt.size) # copy raw bits
+
+proc rawSend(q: PRawChannel, data: pointer, typ: PNimType) =
+  ## Adds an `item` to the end of the queue `q`.
+  var cap = q.mask+1
+  if q.count >= cap:
+    # start with capacity for 2 entries in the queue:
+    if cap == 0: cap = 1
+    when not usesDestructors:
+      var n = cast[pbytes](alloc0(q.region, cap*2*typ.size))
+    else:
+      var n = cast[pbytes](allocShared0(cap*2*typ.size))
+    var z = 0
+    var i = q.rd
+    var c = q.count
+    while c > 0:
+      dec c
+      copyMem(addr(n[z*typ.size]), addr(q.data[i*typ.size]), typ.size)
+      i = (i + 1) and q.mask
+      inc z
+    if q.data != nil:
+      when not usesDestructors:
+        dealloc(q.region, q.data)
+      else:
+        deallocShared(q.data)
+    q.data = n
+    q.mask = cap*2 - 1
+    q.wr = q.count
+    q.rd = 0
+  when not usesDestructors:
+    storeAux(addr(q.data[q.wr * typ.size]), data, typ, q, mStore)
+  else:
+    copyMem(addr(q.data[q.wr * typ.size]), data, typ.size)
+  inc q.count
+  q.wr = (q.wr + 1) and q.mask
+
+proc rawRecv(q: PRawChannel, data: pointer, typ: PNimType) =
+  sysAssert q.count > 0, "rawRecv"
+  dec q.count
+  when not usesDestructors:
+    storeAux(data, addr(q.data[q.rd * typ.size]), typ, q, mLoad)
+  else:
+    copyMem(data, addr(q.data[q.rd * typ.size]), typ.size)
+  q.rd = (q.rd + 1) and q.mask
+
+template lockChannel(q, action): untyped =
+  acquireSys(q.lock)
+  action
+  releaseSys(q.lock)
+
+proc sendImpl(q: PRawChannel, typ: PNimType, msg: pointer, noBlock: bool): bool =
+  if q.mask == ChannelDeadMask:
+    sysFatal(DeadThreadDefect, "cannot send message; thread died")
+  acquireSys(q.lock)
+  if q.maxItems > 0:
+    # Wait until count is less than maxItems
+    if noBlock and q.count >= q.maxItems:
+      releaseSys(q.lock)
+      return
+
+    while q.count >= q.maxItems:
+      waitSysCond(q.cond, q.lock)
+
+  rawSend(q, msg, typ)
+  q.elemType = typ
+  signalSysCond(q.cond)
+  releaseSys(q.lock)
+  result = true
+
+proc send*[TMsg](c: var Channel[TMsg], msg: sink TMsg) {.inline.} =
+  ## Sends a message to a thread. `msg` is deeply copied.
+  discard sendImpl(cast[PRawChannel](addr c), cast[PNimType](getTypeInfo(msg)), unsafeAddr(msg), false)
+  when defined(gcDestructors):
+    wasMoved(msg)
+
+proc trySend*[TMsg](c: var Channel[TMsg], msg: sink TMsg): bool {.inline.} =
+  ## Tries to send a message to a thread.
+  ##
+  ## `msg` is deeply copied. Doesn't block.
+  ##
+  ## Returns `false` if the message was not sent because number of pending items
+  ## in the channel exceeded `maxItems`.
+  result = sendImpl(cast[PRawChannel](addr c), cast[PNimType](getTypeInfo(msg)), unsafeAddr(msg), true)
+  when defined(gcDestructors):
+    if result:
+      wasMoved(msg)
+
+proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) =
+  q.ready = true
+  while q.count <= 0:
+    waitSysCond(q.cond, q.lock)
+  q.ready = false
+  if typ != q.elemType:
+    releaseSys(q.lock)
+    raise newException(ValueError, "cannot receive message of wrong type")
+  rawRecv(q, res, typ)
+  if q.maxItems > 0 and q.count == q.maxItems - 1:
+    # Parent thread is awaiting in send. Wake it up.
+    signalSysCond(q.cond)
+
+proc recv*[TMsg](c: var Channel[TMsg]): TMsg =
+  ## Receives a message from the channel `c`.
+  ##
+  ## This blocks until a message has arrived!
+  ## You may use `peek proc <#peek,Channel[TMsg]>`_ to avoid the blocking.
+  var q = cast[PRawChannel](addr(c))
+  acquireSys(q.lock)
+  llRecv(q, addr(result), cast[PNimType](getTypeInfo(result)))
+  releaseSys(q.lock)
+
+proc tryRecv*[TMsg](c: var Channel[TMsg]): tuple[dataAvailable: bool,
+                                                  msg: TMsg] =
+  ## Tries to receive a message from the channel `c`, but this can fail
+  ## for all sort of reasons, including contention.
+  ##
+  ## If it fails, it returns `(false, default(msg))` otherwise it
+  ## returns `(true, msg)`.
+  var q = cast[PRawChannel](addr(c))
+  if q.mask != ChannelDeadMask:
+    if tryAcquireSys(q.lock):
+      if q.count > 0:
+        llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg)))
+        result.dataAvailable = true
+      releaseSys(q.lock)
+
+proc peek*[TMsg](c: var Channel[TMsg]): int =
+  ## Returns the current number of messages in the channel `c`.
+  ##
+  ## Returns -1 if the channel has been closed.
+  ##
+  ## **Note**: This is dangerous to use as it encourages races.
+  ## It's much better to use `tryRecv proc <#tryRecv,Channel[TMsg]>`_ instead.
+  var q = cast[PRawChannel](addr(c))
+  if q.mask != ChannelDeadMask:
+    lockChannel(q):
+      result = q.count
+  else:
+    result = -1
+
+proc open*[TMsg](c: var Channel[TMsg], maxItems: int = 0) =
+  ## Opens a channel `c` for inter thread communication.
+  ##
+  ## The `send` operation will block until number of unprocessed items is
+  ## less than `maxItems`.
+  ##
+  ## For unlimited queue set `maxItems` to 0.
+  initRawChannel(addr(c), maxItems)
+
+proc close*[TMsg](c: var Channel[TMsg]) =
+  ## Closes a channel `c` and frees its associated resources.
+  deinitRawChannel(addr(c))
+
+proc ready*[TMsg](c: var Channel[TMsg]): bool =
+  ## Returns true if some thread is waiting on the channel `c` for
+  ## new messages.
+  var q = cast[PRawChannel](addr(c))
+  result = q.ready
diff --git a/lib/system/chcks.nim b/lib/system/chcks.nim
new file mode 100644
index 000000000..b48855964
--- /dev/null
+++ b/lib/system/chcks.nim
@@ -0,0 +1,161 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2013 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Implementation of some runtime checks.
+include system/indexerrors
+when defined(nimPreviewSlimSystem):
+  import std/formatfloat
+
+proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
+  when hostOS == "standalone":
+    sysFatal(RangeDefect, "value out of range")
+  else:
+    sysFatal(RangeDefect, "value out of range: ", $val)
+
+proc raiseIndexError4(l1, h1, h2: int) {.compilerproc, noinline.} =
+  sysFatal(IndexDefect, "index out of bounds: " & $l1 & ".." & $h1 & " notin 0.." & $(h2 - 1))
+
+proc raiseIndexError3(i, a, b: int) {.compilerproc, noinline.} =
+  sysFatal(IndexDefect, formatErrorIndexBound(i, a, b))
+
+proc raiseIndexError2(i, n: int) {.compilerproc, noinline.} =
+  sysFatal(IndexDefect, formatErrorIndexBound(i, n))
+
+proc raiseIndexError() {.compilerproc, noinline.} =
+  sysFatal(IndexDefect, "index out of bounds")
+
+proc raiseFieldError(f: string) {.compilerproc, noinline.} =
+  ## remove after bootstrap > 1.5.1
+  sysFatal(FieldDefect, f)
+
+when defined(nimV2):
+  proc raiseFieldError2(f: string, discVal: int) {.compilerproc, noinline.} =
+    ## raised when field is inaccessible given runtime value of discriminant
+    sysFatal(FieldDefect, f & $discVal & "'")
+
+  proc raiseFieldErrorStr(f: string, discVal: string) {.compilerproc, noinline.} =
+    ## raised when field is inaccessible given runtime value of discriminant
+    sysFatal(FieldDefect, formatFieldDefect(f, discVal))
+else:
+  proc raiseFieldError2(f: string, discVal: string) {.compilerproc, noinline.} =
+    ## raised when field is inaccessible given runtime value of discriminant
+    sysFatal(FieldDefect, formatFieldDefect(f, discVal))
+
+proc raiseRangeErrorI(i, a, b: BiggestInt) {.compilerproc, noinline.} =
+  when defined(standalone):
+    sysFatal(RangeDefect, "value out of range")
+  else:
+    sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)
+
+proc raiseRangeErrorF(i, a, b: float) {.compilerproc, noinline.} =
+  when defined(standalone):
+    sysFatal(RangeDefect, "value out of range")
+  else:
+    sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b)
+
+proc raiseRangeErrorU(i, a, b: uint64) {.compilerproc, noinline.} =
+  # todo: better error reporting
+  sysFatal(RangeDefect, "value out of range")
+
+proc raiseRangeErrorNoArgs() {.compilerproc, noinline.} =
+  sysFatal(RangeDefect, "value out of range")
+
+proc raiseObjectConversionError() {.compilerproc, noinline.} =
+  sysFatal(ObjectConversionDefect, "invalid object conversion")
+
+proc chckIndx(i, a, b: int): int =
+  if i >= a and i <= b:
+    return i
+  else:
+    raiseIndexError3(i, a, b)
+
+proc chckRange(i, a, b: int): int =
+  if i >= a and i <= b:
+    return i
+  else:
+    raiseRangeError(i)
+
+proc chckRange64(i, a, b: int64): int64 {.compilerproc.} =
+  if i >= a and i <= b:
+    return i
+  else:
+    raiseRangeError(i)
+
+proc chckRangeU(i, a, b: uint64): uint64 {.compilerproc.} =
+  if i >= a and i <= b:
+    return i
+  else:
+    sysFatal(RangeDefect, "value out of range")
+
+proc chckRangeF(x, a, b: float): float =
+  if x >= a and x <= b:
+    return x
+  else:
+    when hostOS == "standalone":
+      sysFatal(RangeDefect, "value out of range")
+    else:
+      sysFatal(RangeDefect, "value out of range: ", $x)
+
+proc chckNil(p: pointer) =
+  if p == nil:
+    sysFatal(NilAccessDefect, "attempt to write to a nil address")
+
+proc chckNilDisp(p: pointer) {.compilerproc.} =
+  if p == nil:
+    sysFatal(NilAccessDefect, "cannot dispatch; dispatcher is nil")
+
+when not defined(nimV2):
+
+  proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
+    # checks if obj is of type subclass:
+    var x = obj
+    if x == subclass: return # optimized fast path
+    while x != subclass:
+      if x == nil:
+        sysFatal(ObjectConversionDefect, "invalid object conversion")
+      x = x.base
+
+  proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
+    if a != b:
+      sysFatal(ObjectAssignmentDefect, "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
+    if x == subclass: return true # optimized fast path
+    while x != subclass:
+      if x == nil: return false
+      x = x.base
+    return true
+
+when defined(nimV2):
+  proc raiseObjectCaseTransition() {.compilerproc.} =
+    sysFatal(FieldDefect, "assignment to discriminant changes object branch")
diff --git a/lib/system/cntbits.nim b/lib/system/cntbits.nim
deleted file mode 100755
index 281b96dd0..000000000
--- a/lib/system/cntbits.nim
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-
-
-
diff --git a/lib/system/comparisons.nim b/lib/system/comparisons.nim
new file mode 100644
index 000000000..a8d78bb93
--- /dev/null
+++ b/lib/system/comparisons.nim
@@ -0,0 +1,337 @@
+# comparison operators:
+proc `==`*[Enum: enum](x, y: Enum): bool {.magic: "EqEnum", noSideEffect.} =
+  ## Checks whether values within the *same enum* have the same underlying value.
+  runnableExamples:
+    type
+      Enum1 = enum
+        field1 = 3, field2
+      Enum2 = enum
+        place1, place2 = 3
+    var
+      e1 = field1
+      e2 = place2.ord.Enum1
+    assert e1 == e2
+    assert not compiles(e1 == place2) # raises error
+proc `==`*(x, y: pointer): bool {.magic: "EqRef", noSideEffect.} =
+  ## Checks for equality between two `pointer` variables.
+  runnableExamples:
+    var # this is a wildly dangerous example
+      a = cast[pointer](0)
+      b = cast[pointer](nil)
+    assert a == b # true due to the special meaning of `nil`/0 as a pointer
+proc `==`*(x, y: string): bool {.magic: "EqStr", noSideEffect.}
+  ## Checks for equality between two `string` variables.
+
+proc `==`*(x, y: char): bool {.magic: "EqCh", noSideEffect.}
+  ## Checks for equality between two `char` variables.
+proc `==`*(x, y: bool): bool {.magic: "EqB", noSideEffect.}
+  ## Checks for equality between two `bool` variables.
+proc `==`*[T](x, y: set[T]): bool {.magic: "EqSet", noSideEffect.} =
+  ## Checks for equality between two variables of type `set`.
+  runnableExamples:
+    assert {1, 2, 2, 3} == {1, 2, 3} # duplication in sets is ignored
+
+proc `==`*[T](x, y: ref T): bool {.magic: "EqRef", noSideEffect.}
+  ## Checks that two `ref` variables refer to the same item.
+proc `==`*[T](x, y: ptr T): bool {.magic: "EqRef", noSideEffect.}
+  ## Checks that two `ptr` variables refer to the same item.
+proc `==`*[T: proc | iterator](x, y: T): bool {.magic: "EqProc", noSideEffect.}
+  ## Checks that two `proc` variables refer to the same procedure.
+
+proc `<=`*[Enum: enum](x, y: Enum): bool {.magic: "LeEnum", noSideEffect.}
+proc `<=`*(x, y: string): bool {.magic: "LeStr", noSideEffect.} =
+  ## Compares two strings and returns true if `x` is lexicographically
+  ## before `y` (uppercase letters come before lowercase letters).
+  runnableExamples:
+    let
+      a = "abc"
+      b = "abd"
+      c = "ZZZ"
+    assert a <= b
+    assert a <= a
+    assert not (a <= c)
+
+proc `<=`*(x, y: char): bool {.magic: "LeCh", noSideEffect.} =
+  ## Compares two chars and returns true if `x` is lexicographically
+  ## before `y` (uppercase letters come before lowercase letters).
+  runnableExamples:
+    let
+      a = 'a'
+      b = 'b'
+      c = 'Z'
+    assert a <= b
+    assert a <= a
+    assert not (a <= c)
+
+proc `<=`*[T](x, y: set[T]): bool {.magic: "LeSet", noSideEffect.} =
+  ## Returns true if `x` is a subset of `y`.
+  ##
+  ## A subset `x` has all of its members in `y` and `y` doesn't necessarily
+  ## have more members than `x`. That is, `x` can be equal to `y`.
+  runnableExamples:
+    let
+      a = {3, 5}
+      b = {1, 3, 5, 7}
+      c = {2}
+    assert a <= b
+    assert a <= a
+    assert not (a <= c)
+
+proc `<=`*(x, y: bool): bool {.magic: "LeB", noSideEffect.}
+proc `<=`*[T](x, y: ref T): bool {.magic: "LePtr", noSideEffect.}
+proc `<=`*(x, y: pointer): bool {.magic: "LePtr", noSideEffect.}
+
+proc `<`*[Enum: enum](x, y: Enum): bool {.magic: "LtEnum", noSideEffect.}
+proc `<`*(x, y: string): bool {.magic: "LtStr", noSideEffect.} =
+  ## Compares two strings and returns true if `x` is lexicographically
+  ## before `y` (uppercase letters come before lowercase letters).
+  runnableExamples:
+    let
+      a = "abc"
+      b = "abd"
+      c = "ZZZ"
+    assert a < b
+    assert not (a < a)
+    assert not (a < c)
+
+proc `<`*(x, y: char): bool {.magic: "LtCh", noSideEffect.} =
+  ## Compares two chars and returns true if `x` is lexicographically
+  ## before `y` (uppercase letters come before lowercase letters).
+  runnableExamples:
+    let
+      a = 'a'
+      b = 'b'
+      c = 'Z'
+    assert a < b
+    assert not (a < a)
+    assert not (a < c)
+
+proc `<`*[T](x, y: set[T]): bool {.magic: "LtSet", noSideEffect.} =
+  ## Returns true if `x` is a strict or proper subset of `y`.
+  ##
+  ## A strict or proper subset `x` has all of its members in `y` but `y` has
+  ## more elements than `y`.
+  runnableExamples:
+    let
+      a = {3, 5}
+      b = {1, 3, 5, 7}
+      c = {2}
+    assert a < b
+    assert not (a < a)
+    assert not (a < c)
+
+proc `<`*(x, y: bool): bool {.magic: "LtB", noSideEffect.}
+proc `<`*[T](x, y: ref T): bool {.magic: "LtPtr", noSideEffect.}
+proc `<`*[T](x, y: ptr T): bool {.magic: "LtPtr", noSideEffect.}
+proc `<`*(x, y: pointer): bool {.magic: "LtPtr", noSideEffect.}
+
+when not defined(nimHasCallsitePragma):
+  {.pragma: callsite.}
+
+template `!=`*(x, y: untyped): untyped {.callsite.} =
+  ## Unequals operator. This is a shorthand for `not (x == y)`.
+  not (x == y)
+
+template `>=`*(x, y: untyped): untyped {.callsite.} =
+  ## "is greater or equals" operator. This is the same as `y <= x`.
+  y <= x
+
+template `>`*(x, y: untyped): untyped {.callsite.} =
+  ## "is greater" operator. This is the same as `y < x`.
+  y < x
+
+
+proc `==`*(x, y: int): bool {.magic: "EqI", noSideEffect.}
+  ## Compares two integers for equality.
+proc `==`*(x, y: int8): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: int16): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: int32): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: int64): bool {.magic: "EqI", noSideEffect.}
+
+proc `<=`*(x, y: int): bool {.magic: "LeI", noSideEffect.}
+  ## Returns true if `x` is less than or equal to `y`.
+proc `<=`*(x, y: int8): bool {.magic: "LeI", noSideEffect.}
+proc `<=`*(x, y: int16): bool {.magic: "LeI", noSideEffect.}
+proc `<=`*(x, y: int32): bool {.magic: "LeI", noSideEffect.}
+proc `<=`*(x, y: int64): bool {.magic: "LeI", noSideEffect.}
+
+proc `<`*(x, y: int): bool {.magic: "LtI", noSideEffect.}
+  ## Returns true if `x` is less than `y`.
+proc `<`*(x, y: int8): bool {.magic: "LtI", noSideEffect.}
+proc `<`*(x, y: int16): bool {.magic: "LtI", noSideEffect.}
+proc `<`*(x, y: int32): bool {.magic: "LtI", noSideEffect.}
+proc `<`*(x, y: int64): bool {.magic: "LtI", noSideEffect.}
+
+proc `<=`*(x, y: uint): bool {.magic: "LeU", noSideEffect.}
+  ## Returns true if `x <= y`.
+proc `<=`*(x, y: uint8): bool {.magic: "LeU", noSideEffect.}
+proc `<=`*(x, y: uint16): bool {.magic: "LeU", noSideEffect.}
+proc `<=`*(x, y: uint32): bool {.magic: "LeU", noSideEffect.}
+proc `<=`*(x, y: uint64): bool {.magic: "LeU", noSideEffect.}
+
+proc `<`*(x, y: uint): bool {.magic: "LtU", noSideEffect.}
+  ## Returns true if `x < y`.
+proc `<`*(x, y: uint8): bool {.magic: "LtU", noSideEffect.}
+proc `<`*(x, y: uint16): bool {.magic: "LtU", noSideEffect.}
+proc `<`*(x, y: uint32): bool {.magic: "LtU", noSideEffect.}
+proc `<`*(x, y: uint64): bool {.magic: "LtU", noSideEffect.}
+
+proc `<=%`*(x, y: int): bool {.inline.} =
+  ## Treats `x` and `y` as unsigned and compares them.
+  ## Returns true if `unsigned(x) <= unsigned(y)`.
+  cast[uint](x) <= cast[uint](y)
+proc `<=%`*(x, y: int8): bool {.inline.} = cast[uint8](x) <= cast[uint8](y)
+proc `<=%`*(x, y: int16): bool {.inline.} = cast[uint16](x) <= cast[uint16](y)
+proc `<=%`*(x, y: int32): bool {.inline.} = cast[uint32](x) <= cast[uint32](y)
+proc `<=%`*(x, y: int64): bool {.inline.} = cast[uint64](x) <= cast[uint64](y)
+
+proc `<%`*(x, y: int): bool {.inline.} =
+  ## Treats `x` and `y` as unsigned and compares them.
+  ## Returns true if `unsigned(x) < unsigned(y)`.
+  cast[uint](x) < cast[uint](y)
+proc `<%`*(x, y: int8): bool {.inline.} = cast[uint8](x) < cast[uint8](y)
+proc `<%`*(x, y: int16): bool {.inline.} = cast[uint16](x) < cast[uint16](y)
+proc `<%`*(x, y: int32): bool {.inline.} = cast[uint32](x) < cast[uint32](y)
+proc `<%`*(x, y: int64): bool {.inline.} = cast[uint64](x) < cast[uint64](y)
+
+template `>=%`*(x, y: untyped): untyped = y <=% x
+  ## Treats `x` and `y` as unsigned and compares them.
+  ## Returns true if `unsigned(x) >= unsigned(y)`.
+
+template `>%`*(x, y: untyped): untyped = y <% x
+  ## Treats `x` and `y` as unsigned and compares them.
+  ## Returns true if `unsigned(x) > unsigned(y)`.
+
+proc `==`*(x, y: uint): bool {.magic: "EqI", noSideEffect.}
+  ## Compares two unsigned integers for equality.
+proc `==`*(x, y: uint8): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: uint16): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: uint32): bool {.magic: "EqI", noSideEffect.}
+proc `==`*(x, y: uint64): bool {.magic: "EqI", noSideEffect.}
+
+proc `<=`*(x, y: float32): bool {.magic: "LeF64", noSideEffect.}
+proc `<=`*(x, y: float): bool {.magic: "LeF64", noSideEffect.}
+
+proc `<`*(x, y: float32): bool {.magic: "LtF64", noSideEffect.}
+proc `<`*(x, y: float): bool {.magic: "LtF64", noSideEffect.}
+
+proc `==`*(x, y: float32): bool {.magic: "EqF64", noSideEffect.}
+proc `==`*(x, y: float): bool {.magic: "EqF64", noSideEffect.}
+
+{.push stackTrace: off.}
+
+proc min*(x, y: int): int {.magic: "MinI", noSideEffect.} =
+  if x <= y: x else: y
+proc min*(x, y: int8): int8 {.magic: "MinI", noSideEffect.} =
+  if x <= y: x else: y
+proc min*(x, y: int16): int16 {.magic: "MinI", noSideEffect.} =
+  if x <= y: x else: y
+proc min*(x, y: int32): int32 {.magic: "MinI", noSideEffect.} =
+  if x <= y: x else: y
+proc min*(x, y: int64): int64 {.magic: "MinI", noSideEffect.} =
+  ## The minimum value of two integers.
+  if x <= y: x else: y
+proc min*(x, y: float32): float32 {.noSideEffect, inline.} =
+  if x <= y or y != y: x else: y
+proc min*(x, y: float64): float64 {.noSideEffect, inline.} =
+  if x <= y or y != y: x else: y
+proc min*[T: not SomeFloat](x, y: T): T {.inline.} =
+  ## Generic minimum operator of 2 values based on `<=`.
+  if x <= y: x else: y
+
+proc max*(x, y: int): int {.magic: "MaxI", noSideEffect.} =
+  if y <= x: x else: y
+proc max*(x, y: int8): int8 {.magic: "MaxI", noSideEffect.} =
+  if y <= x: x else: y
+proc max*(x, y: int16): int16 {.magic: "MaxI", noSideEffect.} =
+  if y <= x: x else: y
+proc max*(x, y: int32): int32 {.magic: "MaxI", noSideEffect.} =
+  if y <= x: x else: y
+proc max*(x, y: int64): int64 {.magic: "MaxI", noSideEffect.} =
+  ## The maximum value of two integers.
+  if y <= x: x else: y
+proc max*(x, y: float32): float32 {.noSideEffect, inline.} =
+  if y <= x or y != y: x else: y
+proc max*(x, y: float64): float64 {.noSideEffect, inline.} =
+  if y <= x or y != y: x else: y
+proc max*[T: not SomeFloat](x, y: T): T {.inline.} =
+  ## Generic maximum operator of 2 values based on `<=`.
+  if y <= x: x else: y
+
+
+proc min*[T](x: openArray[T]): T =
+  ## The minimum value of `x`. `T` needs to have a `<` operator.
+  result = x[0]
+  for i in 1..high(x):
+    if x[i] < result: result = x[i]
+
+proc max*[T](x: openArray[T]): T =
+  ## The maximum value of `x`. `T` needs to have a `<` operator.
+  result = x[0]
+  for i in 1..high(x):
+    if result < x[i]: result = x[i]
+
+{.pop.} # stackTrace: off
+
+
+proc clamp*[T](x, a, b: T): T =
+  ## Limits the value `x` within the interval \[a, b].
+  ## This proc is equivalent to but faster than `max(a, min(b, x))`.
+  ## 
+  ## .. warning:: `a <= b` is assumed and will not be checked (currently).
+  ##
+  ## **See also:**
+  ## `math.clamp` for a version that takes a `Slice[T]` instead.
+  runnableExamples:
+    assert (1.4).clamp(0.0, 1.0) == 1.0
+    assert (0.5).clamp(0.0, 1.0) == 0.5
+    assert 4.clamp(1, 3) == max(1, min(3, 4))
+  if x < a: return a
+  if x > b: return b
+  return x
+
+
+proc `==`*[I, T](x, y: array[I, T]): bool =
+  for f in low(x)..high(x):
+    if x[f] != y[f]:
+      return
+  result = true
+
+proc `==`*[T](x, y: openArray[T]): bool =
+  if x.len != y.len:
+    return false
+  for f in low(x)..high(x):
+    if x[f] != y[f]:
+      return false
+  result = true
+
+
+proc `==`*[T](x, y: seq[T]): bool {.noSideEffect.} =
+  ## Generic equals operator for sequences: relies on a equals operator for
+  ## the element type `T`.
+  when nimvm:
+    if x.len == 0 and y.len == 0:
+      return true
+  else:
+    when not defined(js):
+      proc seqToPtr[T](x: seq[T]): pointer {.inline, noSideEffect.} =
+        when defined(nimSeqsV2):
+          result = cast[NimSeqV2[T]](x).p
+        else:
+          result = cast[pointer](x)
+
+      if seqToPtr(x) == seqToPtr(y):
+        return true
+    else:
+      var sameObject = false
+      {.emit: """`sameObject` = `x` === `y`;""".}
+      if sameObject: return true
+
+  if x.len != y.len:
+    return false
+
+  for i in 0..x.len-1:
+    if x[i] != y[i]:
+      return false
+
+  return true
diff --git a/lib/system/compilation.nim b/lib/system/compilation.nim
new file mode 100644
index 000000000..cdb976ed5
--- /dev/null
+++ b/lib/system/compilation.nim
@@ -0,0 +1,209 @@
+const
+  NimMajor* {.intdefine.}: int = 2
+    ## is the major number of Nim's version. Example:
+    ##   ```nim
+    ##   when (NimMajor, NimMinor, NimPatch) >= (1, 3, 1): discard
+    ##   ```
+    # see also std/private/since
+
+  NimMinor* {.intdefine.}: int = 2
+    ## is the minor number of Nim's version.
+    ## Odd for devel, even for releases.
+
+  NimPatch* {.intdefine.}: int = 1
+    ## is the patch number of Nim's version.
+    ## Odd for devel, even for releases.
+
+{.push profiler: off.}
+let nimvm* {.magic: "Nimvm", compileTime.}: bool = false
+  ## May be used only in `when` expression.
+  ## It is true in Nim VM context and false otherwise.
+{.pop.}
+
+const
+  isMainModule* {.magic: "IsMainModule".}: bool = false
+    ## True only when accessed in the main module. This works thanks to
+    ## compiler magic. It is useful to embed testing code in a module.
+
+  CompileDate* {.magic: "CompileDate".}: string = "0000-00-00"
+    ## The date (in UTC) of compilation as a string of the form
+    ## `YYYY-MM-DD`. This works thanks to compiler magic.
+
+  CompileTime* {.magic: "CompileTime".}: string = "00:00:00"
+    ## The time (in UTC) of compilation as a string of the form
+    ## `HH:MM:SS`. This works thanks to compiler magic.
+
+proc defined*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}
+  ## Special compile-time procedure that checks whether `x` is
+  ## defined.
+  ##
+  ## `x` is an external symbol introduced through the compiler's
+  ## `-d:x switch <nimc.html#compiler-usage-compileminustime-symbols>`_ to enable
+  ## build time conditionals:
+  ##   ```nim
+  ##   when not defined(release):
+  ##     # Do here programmer friendly expensive sanity checks.
+  ##   # Put here the normal code
+  ##   ```
+  ##
+  ## See also:
+  ## * `compileOption <#compileOption,string>`_ for `on|off` options
+  ## * `compileOption <#compileOption,string,string>`_ for enum options
+  ## * `define pragmas <manual.html#implementation-specific-pragmas-compileminustime-define-pragmas>`_
+
+proc declared*(x: untyped): bool {.magic: "Declared", noSideEffect, compileTime.}
+  ## Special compile-time procedure that checks whether `x` is
+  ## declared. `x` has to be an identifier or a qualified identifier.
+  ##
+  ## This can be used to check whether a library provides a certain
+  ## feature or not:
+  ##   ```nim
+  ##   when not declared(strutils.toUpper):
+  ##     # provide our own toUpper proc here, because strutils is
+  ##     # missing it.
+  ##   ```
+  ##
+  ## See also:
+  ## * `declaredInScope <#declaredInScope,untyped>`_
+
+proc declaredInScope*(x: untyped): bool {.magic: "DeclaredInScope", noSideEffect, compileTime.}
+  ## Special compile-time procedure that checks whether `x` is
+  ## declared in the current scope. `x` has to be an identifier.
+
+proc compiles*(x: untyped): bool {.magic: "Compiles", noSideEffect, compileTime.} =
+  ## Special compile-time procedure that checks whether `x` can be compiled
+  ## without any semantic error.
+  ## This can be used to check whether a type supports some operation:
+  ##   ```nim
+  ##   when compiles(3 + 4):
+  ##     echo "'+' for integers is available"
+  ##   ```
+  discard
+
+proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
+  ## Converts the AST of `x` into a string representation. This is very useful
+  ## for debugging.
+
+proc runnableExamples*(rdoccmd = "", body: untyped) {.magic: "RunnableExamples".} =
+  ## A section you should use to mark `runnable example`:idx: code with.
+  ##
+  ## - In normal debug and release builds code within
+  ##   a `runnableExamples` section is ignored.
+  ## - The documentation generator is aware of these examples and considers them
+  ##   part of the `##` doc comment. As the last step of documentation
+  ##   generation each runnableExample is put in its own file `$file_examples$i.nim`,
+  ##   compiled and tested. The collected examples are
+  ##   put into their own module to ensure the examples do not refer to
+  ##   non-exported symbols.
+  runnableExamples:
+    proc timesTwo*(x: int): int =
+      ## This proc doubles a number.
+      runnableExamples:
+        # at module scope
+        const exported* = 123
+        assert timesTwo(5) == 10
+        block: # at block scope
+          defer: echo "done"
+      runnableExamples "-d:foo -b:cpp":
+        import std/compilesettings
+        assert querySetting(backend) == "cpp"
+        assert defined(foo)
+      runnableExamples "-r:off": ## this one is only compiled
+         import std/browsers
+         openDefaultBrowser "https://forum.nim-lang.org/"
+      2 * x
+
+proc compileOption*(option: string): bool {.
+  magic: "CompileOption", noSideEffect.} =
+  ## Can be used to determine an `on|off` compile-time option.
+  ##
+  ## See also:
+  ## * `compileOption <#compileOption,string,string>`_ for enum options
+  ## * `defined <#defined,untyped>`_
+  ## * `std/compilesettings module <compilesettings.html>`_
+  runnableExamples("--floatChecks:off"):
+    static: doAssert not compileOption("floatchecks")
+    {.push floatChecks: on.}
+    static: doAssert compileOption("floatchecks")
+    # floating point NaN and Inf checks enabled in this scope
+    {.pop.}
+
+proc compileOption*(option, arg: string): bool {.
+  magic: "CompileOptionArg", noSideEffect.} =
+  ## Can be used to determine an enum compile-time option.
+  ##
+  ## See also:
+  ## * `compileOption <#compileOption,string>`_ for `on|off` options
+  ## * `defined <#defined,untyped>`_
+  ## * `std/compilesettings module <compilesettings.html>`_
+  runnableExamples:
+    when compileOption("opt", "size") and compileOption("gc", "boehm"):
+      discard "compiled with optimization for size and uses Boehm's GC"
+
+template currentSourcePath*: string = instantiationInfo(-1, true).filename
+  ## Returns the full file-system path of the current source.
+  ##
+  ## To get the directory containing the current source, use it with
+  ## `ospaths2.parentDir() <ospaths2.html#parentDir%2Cstring>`_ as
+  ## `currentSourcePath.parentDir()`.
+  ##
+  ## The path returned by this template is set at compile time.
+  ##
+  ## See the docstring of `macros.getProjectPath() <macros.html#getProjectPath>`_
+  ## for an example to see the distinction between the `currentSourcePath()`
+  ## and `getProjectPath()`.
+  ##
+  ## See also:
+  ## * `ospaths2.getCurrentDir() proc <ospaths2.html#getCurrentDir>`_
+
+proc slurp*(filename: string): string {.magic: "Slurp".}
+  ## This is an alias for `staticRead <#staticRead,string>`_.
+
+proc staticRead*(filename: string): string {.magic: "Slurp".}
+  ## Compile-time `readFile <syncio.html#readFile,string>`_ proc for easy
+  ## `resource`:idx: embedding:
+  ##
+  ## The maximum file size limit that `staticRead` and `slurp` can read is
+  ## near or equal to the *free* memory of the device you are using to compile.
+  ##   ```nim
+  ##   const myResource = staticRead"mydatafile.bin"
+  ##   ```
+  ##
+  ## `slurp <#slurp,string>`_ is an alias for `staticRead`.
+
+proc gorge*(command: string, input = "", cache = ""): string {.
+  magic: "StaticExec".} = discard
+  ## This is an alias for `staticExec <#staticExec,string,string,string>`_.
+
+proc staticExec*(command: string, input = "", cache = ""): string {.
+  magic: "StaticExec".} = discard
+  ## Executes an external process at compile-time and returns its text output
+  ## (stdout + stderr).
+  ##
+  ## If `input` is not an empty string, it will be passed as a standard input
+  ## to the executed program.
+  ##   ```nim
+  ##   const buildInfo = "Revision " & staticExec("git rev-parse HEAD") &
+  ##                     "\nCompiled on " & staticExec("uname -v")
+  ##   ```
+  ##
+  ## `gorge <#gorge,string,string,string>`_ is an alias for `staticExec`.
+  ##
+  ## Note that you can use this proc inside a pragma like
+  ## `passc <manual.html#implementation-specific-pragmas-passc-pragma>`_ or
+  ## `passl <manual.html#implementation-specific-pragmas-passl-pragma>`_.
+  ##
+  ## If `cache` is not empty, the results of `staticExec` are cached within
+  ## the `nimcache` directory. Use `--forceBuild` to get rid of this caching
+  ## behaviour then. `command & input & cache` (the concatenated string) is
+  ## used to determine whether the entry in the cache is still valid. You can
+  ## use versioning information for `cache`:
+  ##   ```nim
+  ##   const stateMachine = staticExec("dfaoptimizer", "input", "0.8.0")
+  ##   ```
+
+proc gorgeEx*(command: string, input = "", cache = ""): tuple[output: string,
+                                                              exitCode: int] =
+  ## Similar to `gorge <#gorge,string,string,string>`_ but also returns the
+  ## precious exit code.
+  discard
diff --git a/lib/system/coro_detection.nim b/lib/system/coro_detection.nim
new file mode 100644
index 000000000..f6c1b5c15
--- /dev/null
+++ b/lib/system/coro_detection.nim
@@ -0,0 +1,20 @@
+## Coroutine detection logic
+
+template coroutinesSupportedPlatform(): bool =
+  when defined(sparc) or defined(ELATE) or defined(boehmgc) or defined(gogc) or
+    defined(nogc) or defined(gcRegions) or defined(gcMarkAndSweep):
+    false
+  else:
+    true
+
+when defined(nimCoroutines):
+  # Explicit opt-in.
+  when not coroutinesSupportedPlatform():
+    {.error: "Coroutines are not supported on this architecture and/or garbage collector.".}
+  const nimCoroutines* = true
+elif defined(noNimCoroutines):
+  # Explicit opt-out.
+  const nimCoroutines* = false
+else:
+  # Autodetect coroutine support.
+  const nimCoroutines* = false
diff --git a/lib/system/countbits_impl.nim b/lib/system/countbits_impl.nim
new file mode 100644
index 000000000..34969cb32
--- /dev/null
+++ b/lib/system/countbits_impl.nim
@@ -0,0 +1,93 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Contains the used algorithms for counting bits.
+
+from std/private/bitops_utils import forwardImpl, castToUnsigned
+
+const useBuiltins* = not defined(noIntrinsicsBitOpts)
+const noUndefined* = defined(noUndefinedBitOpts)
+const useGCC_builtins* = (defined(gcc) or defined(llvm_gcc) or
+                         defined(clang)) and useBuiltins
+const useICC_builtins* = defined(icc) and useBuiltins
+const useVCC_builtins* = defined(vcc) and useBuiltins
+const arch64* = sizeof(int) == 8
+
+template countBitsImpl(n: uint32): int =
+  # generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+  var v = uint32(n)
+  v = v - ((v shr 1'u32) and 0x55555555'u32)
+  v = (v and 0x33333333'u32) + ((v shr 2'u32) and 0x33333333'u32)
+  (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101'u32) shr 24'u32).int
+
+template countBitsImpl(n: uint64): int =
+  # generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+  var v = uint64(n)
+  v = v - ((v shr 1'u64) and 0x5555555555555555'u64)
+  v = (v and 0x3333333333333333'u64) + ((v shr 2'u64) and 0x3333333333333333'u64)
+  v = (v + (v shr 4'u64) and 0x0F0F0F0F0F0F0F0F'u64)
+  ((v * 0x0101010101010101'u64) shr 56'u64).int
+
+
+when useGCC_builtins:
+  # Returns the number of set 1-bits in value.
+  proc builtin_popcount(x: cuint): cint {.importc: "__builtin_popcount", cdecl.}
+  proc builtin_popcountll(x: culonglong): cint {.
+      importc: "__builtin_popcountll", cdecl.}
+
+elif useVCC_builtins:
+  # Counts the number of one bits (population count) in a 16-, 32-, or 64-byte unsigned integer.
+  func builtin_popcnt16(a2: uint16): uint16 {.
+      importc: "__popcnt16", header: "<intrin.h>".}
+  func builtin_popcnt32(a2: uint32): uint32 {.
+      importc: "__popcnt", header: "<intrin.h>".}
+  func builtin_popcnt64(a2: uint64): uint64 {.
+      importc: "__popcnt64", header: "<intrin.h>".}
+
+elif useICC_builtins:
+  # Intel compiler intrinsics: http://fulla.fnal.gov/intel/compiler_c/main_cls/intref_cls/common/intref_allia_misc.htm
+  # see also: https://software.intel.com/en-us/node/523362
+  # Count the number of bits set to 1 in an integer a, and return that count in dst.
+  func builtin_popcnt32(a: cint): cint {.
+      importc: "_popcnt", header: "<immintrin.h>".}
+  func builtin_popcnt64(a: uint64): cint {.
+      importc: "_popcnt64", header: "<immintrin.h>".}
+
+
+func countSetBitsImpl*(x: SomeInteger): int {.inline.} =
+  ## Counts the set bits in an integer (also called `Hamming weight`:idx:).
+  # TODO: figure out if ICC support _popcnt32/_popcnt64 on platform without POPCNT.
+  # like GCC and MSVC
+  let x = x.castToUnsigned
+  when nimvm:
+    result = forwardImpl(countBitsImpl, x)
+  else:
+    when useGCC_builtins:
+      when sizeof(x) <= 4: result = builtin_popcount(x.cuint).int
+      else: result = builtin_popcountll(x.culonglong).int
+    elif useVCC_builtins:
+      when sizeof(x) <= 2: result = builtin_popcnt16(x.uint16).int
+      elif sizeof(x) <= 4: result = builtin_popcnt32(x.uint32).int
+      elif arch64: result = builtin_popcnt64(x.uint64).int
+      else: result = builtin_popcnt32((x.uint64 and 0xFFFFFFFF'u64).uint32).int +
+                     builtin_popcnt32((x.uint64 shr 32'u64).uint32).int
+    elif useICC_builtins:
+      when sizeof(x) <= 4: result = builtin_popcnt32(x.cint).int
+      elif arch64: result = builtin_popcnt64(x.uint64).int
+      else: result = builtin_popcnt32((x.uint64 and 0xFFFFFFFF'u64).cint).int +
+                     builtin_popcnt32((x.uint64 shr 32'u64).cint).int
+    else:
+      when sizeof(x) <= 4: result = countBitsImpl(x.uint32)
+      else: result = countBitsImpl(x.uint64)
+
+proc countBits32*(n: uint32): int {.compilerproc, inline.} =
+  result = countSetBitsImpl(n)
+
+proc countBits64*(n: uint64): int {.compilerproc, inline.} =
+  result = countSetBitsImpl(n)
diff --git a/lib/system/ctypes.nim b/lib/system/ctypes.nim
new file mode 100644
index 000000000..b788274bd
--- /dev/null
+++ b/lib/system/ctypes.nim
@@ -0,0 +1,84 @@
+## Some type definitions for compatibility between different
+## backends and platforms.
+
+type
+  BiggestInt* = int64
+    ## is an alias for the biggest signed integer type the Nim compiler
+    ## supports. Currently this is `int64`, but it is platform-dependent
+    ## in general.
+
+  BiggestFloat* = float64
+    ## is an alias for the biggest floating point type the Nim
+    ## compiler supports. Currently this is `float64`, but it is
+    ## platform-dependent in general.
+
+  BiggestUInt* = uint64
+    ## is an alias for the biggest unsigned integer type the Nim compiler
+    ## supports. Currently this is `uint64`, but it is platform-dependent
+    ## in general.
+
+when defined(windows):
+  type
+    clong* {.importc: "long", nodecl.} = int32
+      ## This is the same as the type `long` in *C*.
+    culong* {.importc: "unsigned long", nodecl.} = uint32
+      ## This is the same as the type `unsigned long` in *C*.
+else:
+  type
+    clong* {.importc: "long", nodecl.} = int
+      ## This is the same as the type `long` in *C*.
+    culong* {.importc: "unsigned long", nodecl.} = uint
+      ## This is the same as the type `unsigned long` in *C*.
+
+type # these work for most platforms:
+  cchar* {.importc: "char", nodecl.} = char
+    ## This is the same as the type `char` in *C*.
+  cschar* {.importc: "signed char", nodecl.} = int8
+    ## This is the same as the type `signed char` in *C*.
+  cshort* {.importc: "short", nodecl.} = int16
+    ## This is the same as the type `short` in *C*.
+  cint* {.importc: "int", nodecl.} = int32
+    ## This is the same as the type `int` in *C*.
+  csize_t* {.importc: "size_t", nodecl.} = uint
+    ## This is the same as the type `size_t` in *C*.
+  clonglong* {.importc: "long long", nodecl.} = int64
+    ## This is the same as the type `long long` in *C*.
+  cfloat* {.importc: "float", nodecl.} = float32
+    ## This is the same as the type `float` in *C*.
+  cdouble* {.importc: "double", nodecl.} = float64
+    ## This is the same as the type `double` in *C*.
+  clongdouble* {.importc: "long double", nodecl.} = BiggestFloat
+    ## This is the same as the type `long double` in *C*.
+    ## This C type is not supported by Nim's code generator.
+
+  cuchar* {.importc: "unsigned char", nodecl, deprecated: "use `char` or `uint8` instead".} = char
+    ## Deprecated: Use `uint8` instead.
+  cushort* {.importc: "unsigned short", nodecl.} = uint16
+    ## This is the same as the type `unsigned short` in *C*.
+  cuint* {.importc: "unsigned int", nodecl.} = uint32
+    ## This is the same as the type `unsigned int` in *C*.
+  culonglong* {.importc: "unsigned long long", nodecl.} = uint64
+    ## This is the same as the type `unsigned long long` in *C*.
+
+type
+  ByteAddress* {.deprecated: "use `uint`".} = int
+    ## is the signed integer type that should be used for converting
+    ## pointers to integer addresses for readability.
+
+  cstringArray* {.importc: "char**", nodecl.} = ptr UncheckedArray[cstring]
+    ## This is binary compatible to the type `char**` in *C*. The array's
+    ## high value is large enough to disable bounds checking in practice.
+    ## Use `cstringArrayToSeq proc <#cstringArrayToSeq,cstringArray,Natural>`_
+    ## to convert it into a `seq[string]`.
+
+when not defined(nimPreviewSlimSystem):
+  # pollutes namespace
+  type
+    PFloat32* {.deprecated: "use `ptr float32`".} = ptr float32
+      ## An alias for `ptr float32`.
+    PFloat64* {.deprecated: "use `ptr float64`".} = ptr float64
+      ## An alias for `ptr float64`.
+    PInt64* {.deprecated: "use `ptr int64`".} = ptr int64
+      ## An alias for `ptr int64`.
+    PInt32* {.deprecated: "use `ptr int32`".} = ptr int32
+      ## An alias for `ptr int32`.
diff --git a/lib/system/cyclebreaker.nim b/lib/system/cyclebreaker.nim
new file mode 100644
index 000000000..45b0a5a65
--- /dev/null
+++ b/lib/system/cyclebreaker.nim
@@ -0,0 +1,184 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+#[
+A Cycle breaker for Nim
+-----------------------
+
+Instead of "collecting" cycles with all of its pitfalls we will break cycles.
+We exploit that every 'ref' can be 'nil' for this and so get away without
+a distinction between weak and strong pointers. The required runtime
+mechanisms are the same though: We need to be able to traverse the graph.
+This design has the tremendous benefit that it doesn't require a dedicated
+'rawDispose' operation and that it plays well with Nim's cost model.
+The cost of freeing a subgraph with cycles is 2 * N rather than N, that's all.
+
+Cycles do not have to be prepared via .acyclic, there are not multiple
+pointless traversals, only a single proc, `breakCycles` is exposed as a
+separate module.
+
+Algorithm
+---------
+
+We traverse the graph and notice the nodes we've already traversed. If we
+marked the node already, we set the pointer that leads to this node to 'nil'
+and decrement the reference count of the cell we pointed at.
+
+We notice that multiple paths to the same object do not mean
+we found a cycle, it only means the node is shared.
+
+
+   a -------> b <----- c
+   |          ^        ^
+   +----------+        |
+   |                   |
+   +-------------------+
+
+If we simply remove all links to already processed nodes we end up with:
+
+   a -------> b        c
+   |                   ^
+   +                   |
+   |                   |
+   +-------------------+
+
+That seems acceptable, no leak is produced. This implies that the standard
+depth-first traversal suffices.
+
+]#
+
+include cellseqs_v2
+
+const
+  colGreen = 0b000
+  colYellow = 0b001
+  colRed = 0b010
+  colorMask = 0b011
+
+type
+  TraceProc = proc (p, env: pointer) {.nimcall, benign.}
+  DisposeProc = proc (p: pointer) {.nimcall, benign.}
+
+template color(c): untyped = c.rc and colorMask
+template setColor(c, col) =
+  c.rc = c.rc and not colorMask or col
+
+proc nimIncRefCyclic(p: pointer; cyclic: bool) {.compilerRtl, inl.} =
+  let h = head(p)
+  inc h.rc, rcIncrement
+
+proc nimMarkCyclic(p: pointer) {.compilerRtl, inl.} = discard
+
+type
+  GcEnv = object
+    traceStack: CellSeq[ptr pointer]
+
+proc trace(p: pointer; desc: PNimTypeV2; j: var GcEnv) {.inline.} =
+  when false:
+    cprintf("[Trace] desc: %p %p\n", desc, p)
+    cprintf("[Trace] trace: %p\n", desc.traceImpl)
+  if desc.traceImpl != nil:
+    cast[TraceProc](desc.traceImpl)(p, addr(j))
+
+proc nimTraceRef(q: pointer; desc: PNimTypeV2; env: pointer) {.compilerRtl.} =
+  let p = cast[ptr pointer](q)
+  when traceCollector:
+    cprintf("[Trace] raw: %p\n", p)
+    cprintf("[Trace] deref: %p\n", p[])
+  if p[] != nil:
+    var j = cast[ptr GcEnv](env)
+    j.traceStack.add(p, desc)
+
+proc nimTraceRefDyn(q: pointer; env: pointer) {.compilerRtl.} =
+  let p = cast[ptr pointer](q)
+  when traceCollector:
+    cprintf("[TraceDyn] raw: %p\n", p)
+    cprintf("[TraceDyn] deref: %p\n", p[])
+  if p[] != nil:
+    var j = cast[ptr GcEnv](env)
+    j.traceStack.add(p, cast[ptr PNimTypeV2](p[])[])
+
+var markerGeneration: int
+
+proc breakCycles(s: Cell; desc: PNimTypeV2) =
+  let markerColor = if (markerGeneration and 1) == 0: colRed
+                    else: colYellow
+  atomicInc markerGeneration
+  when traceCollector:
+    cprintf("[BreakCycles] starting: %p %s RC %ld trace proc %p\n",
+      s, desc.name, s.rc shr rcShift, desc.traceImpl)
+
+  var j: GcEnv
+  init j.traceStack
+  s.setColor markerColor
+  trace(s +! sizeof(RefHeader), desc, j)
+
+  while j.traceStack.len > 0:
+    let (u, desc) = j.traceStack.pop()
+    let p = u[]
+    let t = head(p)
+    if t.color != markerColor:
+      t.setColor markerColor
+      trace(p, desc, j)
+      when traceCollector:
+        cprintf("[BreakCycles] followed: %p RC %ld\n", t, t.rc shr rcShift)
+    else:
+      if (t.rc shr rcShift) > 0:
+        dec t.rc, rcIncrement
+        # mark as a link that the produced destructor does not have to follow:
+        u[] = nil
+        when traceCollector:
+          cprintf("[BreakCycles] niled out: %p RC %ld\n", t, t.rc shr rcShift)
+      else:
+        # anyhow as a link that the produced destructor does not have to follow:
+        u[] = nil
+        when traceCollector:
+          cprintf("[Bug] %p %s RC %ld\n", t, desc.name, t.rc shr rcShift)
+  deinit j.traceStack
+
+proc thinout*[T](x: ref T) {.inline.} =
+  ## turn the subgraph starting with `x` into its spanning tree by
+  ## `nil`'ing out any pointers that would harm the spanning tree
+  ## structure. Any back pointers that introduced cycles
+  ## and thus would keep the graph from being freed are `nil`'ed.
+  ## This is a form of cycle collection that works well with Nim's ARC
+  ## and its associated cost model.
+  proc getDynamicTypeInfo[T](x: T): PNimTypeV2 {.magic: "GetTypeInfoV2", noSideEffect.}
+
+  breakCycles(head(cast[pointer](x)), getDynamicTypeInfo(x[]))
+
+proc thinout*[T: proc](x: T) {.inline.} =
+  proc rawEnv[T: proc](x: T): pointer {.noSideEffect, inline.} =
+    {.emit: """
+    `result` = `x`.ClE_0;
+    """.}
+
+  let p = rawEnv(x)
+  breakCycles(head(p), cast[ptr PNimTypeV2](p)[])
+
+proc nimDecRefIsLastCyclicDyn(p: pointer): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+    if (cell.rc and not rcMask) == 0:
+      result = true
+      #cprintf("[DESTROY] %p\n", p)
+    else:
+      dec cell.rc, rcIncrement
+      # According to Lins it's correct to do nothing else here.
+      #cprintf("[DeCREF] %p\n", p)
+
+proc nimDecRefIsLastCyclicStatic(p: pointer; desc: PNimTypeV2): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+    if (cell.rc and not rcMask) == 0:
+      result = true
+      #cprintf("[DESTROY] %p %s\n", p, desc.name)
+    else:
+      dec cell.rc, rcIncrement
+      #cprintf("[DeCREF] %p %s %ld\n", p, desc.name, cell.rc)
diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim
deleted file mode 100755
index 01d8bd8a2..000000000
--- a/lib/system/debugger.nim
+++ /dev/null
@@ -1,500 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# This file implements the embedded debugger that can be linked
-# with the application. We should not use dynamic memory here as that
-# would interfere with the GC and trigger ON/OFF errors if the
-# user program corrupts memory. Unfortunately, for dispaying
-# variables we use the ``system.repr()`` proc which uses Nimrod
-# strings and thus allocates memory from the heap. Pity, but
-# I do not want to implement ``repr()`` twice. We also cannot deactivate
-# the GC here as that might run out of memory too quickly...
-
-type
-  TDbgState = enum
-    dbOff,        # debugger is turned off
-    dbStepInto,   # debugger is in tracing mode
-    dbStepOver,
-    dbSkipCurrent,
-    dbQuiting,    # debugger wants to quit
-    dbBreakpoints # debugger is only interested in breakpoints
-
-  TDbgBreakpoint {.final.} = object
-    low, high: int   # range from low to high; if disabled
-                     # both low and high are set to their negative values
-                     # this makes the check faster and safes memory
-    filename: string
-    name: string     # name of breakpoint
-
-  TVarSlot {.compilerproc, final.} = object # variable slots used for debugger:
-    address: pointer
-    typ: PNimType
-    name: cstring   # for globals this is "module.name"
-
-  PExtendedFrame = ptr TExtendedFrame
-  TExtendedFrame {.final.} = object  # If the debugger is enabled the compiler
-                                     # provides an extended frame. Of course
-                                     # only slots that are
-                                     # needed are allocated and not 10_000,
-                                     # except for the global data description.
-    f: TFrame
-    slots: array[0..10_000, TVarSlot]
-
-var
-  dbgInSignal: bool # wether the debugger is in the signal handler
-  dbgIn: TFile # debugger input stream
-  dbgUser: string = "s" # buffer for user input; first command is ``step_into``
-                        # needs to be global cause we store the last command
-                        # in it
-  dbgState: TDbgState = dbStepInto # state of debugger
-  dbgBP: array[0..127, TDbgBreakpoint] # breakpoints
-  dbgBPlen: int = 0
-
-  dbgSkipToFrame: PFrame # frame to be skipped to
-
-  dbgGlobalData: TExtendedFrame # this reserves much space, but
-                                # for now it is the most practical way
-
-  maxDisplayRecDepth: int = 5 # do not display too much data!
-
-proc findBreakpoint(name: string): int =
-  # returns -1 if not found
-  for i in countdown(dbgBPlen-1, 0):
-    if name == dbgBP[i].name: return i
-  return -1
-
-proc ListBreakPoints() =
-  write(stdout, "*** endb| Breakpoints:\n")
-  for i in 0 .. dbgBPlen-1:
-    write(stdout, dbgBP[i].name & ": " & $abs(dbgBP[i].low) & ".." &
-                  $abs(dbgBP[i].high) & dbgBP[i].filename)
-    if dbgBP[i].low < 0:
-      write(stdout, " [disabled]\n")
-    else:
-      write(stdout, "\n")
-  write(stdout, "***\n")
-
-proc openAppend(filename: string): TFile =
-  if open(result, filename, fmAppend):
-    write(result, "----------------------------------------\n")
-
-proc dbgRepr(p: pointer, typ: PNimType): string =
-  var
-    cl: TReprClosure
-  initReprClosure(cl)
-  cl.recDepth = maxDisplayRecDepth
-  # locks for the GC turned out to be a bad idea...
-  # inc(recGcLock)
-  result = ""
-  reprAux(result, p, typ, cl)
-  # dec(recGcLock)
-  deinitReprClosure(cl)
-
-proc writeVariable(stream: TFile, slot: TVarSlot) =
-  write(stream, slot.name)
-  write(stream, " = ")
-  writeln(stream, dbgRepr(slot.address, slot.typ))
-
-proc ListFrame(stream: TFile, f: PExtendedFrame) =
-  write(stream, "*** endb| Frame (" & $f.f.len &  " slots):\n")
-  for i in 0 .. f.f.len-1:
-    writeVariable(stream, f.slots[i])
-  write(stream, "***\n")
-
-proc ListVariables(stream: TFile, f: PExtendedFrame) =
-  write(stream, "*** endb| Frame (" & $f.f.len & " slots):\n")
-  for i in 0 .. f.f.len-1:
-    writeln(stream, f.slots[i].name)
-  write(stream, "***\n")
-
-proc debugOut(msg: cstring) =
-  # the *** *** markers are for easy recognition of debugger
-  # output for external frontends.
-  write(stdout, "*** endb| ")
-  write(stdout, msg)
-  write(stdout, "***\n")
-
-proc dbgFatal(msg: cstring) =
-  debugOut(msg)
-  dbgAborting = True # the debugger wants to abort
-  quit(1)
-
-proc findVariable(frame: PExtendedFrame, varname: cstring): int =
-  for i in 0 .. frame.f.len - 1:
-    if c_strcmp(frame.slots[i].name, varname) == 0: return i
-  return -1
-
-proc dbgShowCurrentProc(dbgFramePointer: PFrame) =
-  if dbgFramePointer != nil:
-    write(stdout, "*** endb| now in proc: ")
-    write(stdout, dbgFramePointer.procname)
-    write(stdout, " ***\n")
-  else:
-    write(stdout, "*** endb| (procedure name not available) ***\n")
-
-proc dbgShowExecutionPoint() =
-  write(stdout, "*** endb| " & $framePtr.filename & "(" & $framePtr.line &
-                ") " & $framePtr.procname & " ***\n")
-
-when defined(windows) or defined(dos) or defined(os2):
-  {.define: FileSystemCaseInsensitive.}
-
-proc fileMatches(c, bp: cstring): bool =
-  # bp = breakpoint filename
-  # c = current filename
-  # we consider it a match if bp is a suffix of c
-  # and the character for the suffix does not exist or
-  # is one of: \  /  :
-  # depending on the OS case does not matter!
-  var blen: int = c_strlen(bp)
-  var clen: int = c_strlen(c)
-  if blen > clen: return false
-  # check for \ /  :
-  if clen-blen-1 >= 0 and c[clen-blen-1] notin {'\\', '/', ':'}:
-    return false
-  var i = 0
-  while i < blen:
-    var x, y: char
-    x = bp[i]
-    y = c[i+clen-blen]
-    when defined(FileSystemCaseInsensitive):
-      if x >= 'A' and x <= 'Z': x = chr(ord(x) - ord('A') + ord('a'))
-      if y >= 'A' and y <= 'Z': y = chr(ord(y) - ord('A') + ord('a'))
-    if x != y: return false
-    inc(i)
-  return true
-
-proc dbgBreakpointReached(line: int): int =
-  for i in 0..dbgBPlen-1:
-    if line >= dbgBP[i].low and line <= dbgBP[i].high and
-        fileMatches(framePtr.filename, dbgBP[i].filename): return i
-  return -1
-
-proc scanAndAppendWord(src: string, a: var string, start: int): int =
-  result = start
-  # skip whitespace:
-  while src[result] in {'\t', ' '}: inc(result)
-  while True:
-    case src[result]
-    of 'a'..'z', '0'..'9': add(a, src[result])
-    of '_': nil # just skip it
-    of 'A'..'Z': add(a, chr(ord(src[result]) - ord('A') + ord('a')))
-    else: break
-    inc(result)
-
-proc scanWord(src: string, a: var string, start: int): int =
-  a = ""
-  result = scanAndAppendWord(src, a, start)
-
-proc scanFilename(src: string, a: var string, start: int): int =
-  result = start
-  a = ""
-  # skip whitespace:
-  while src[result] in {'\t', ' '}: inc(result)
-  while src[result] notin {'\t', ' ', '\0'}:
-    add(a, src[result])
-    inc(result)
-
-proc scanNumber(src: string, a: var int, start: int): int =
-  result = start
-  a = 0
-  while src[result] in {'\t', ' '}: inc(result)
-  while true:
-    case src[result]
-    of '0'..'9': a = a * 10 + ord(src[result]) - ord('0')
-    of '_': nil # skip underscores (nice for long line numbers)
-    else: break
-    inc(result)
-
-proc dbgHelp() =
-  debugOut("""
-list of commands (see the manual for further help):
-              GENERAL
-h, help                 display this help message
-q, quit                 quit the debugger and the program
-<ENTER>                 repeat the previous debugger command
-              EXECUTING
-s, step                 single step, stepping into routine calls
-n, next                 single step, without stepping into routine calls
-f, skipcurrent          continue execution until the current routine finishes
-c, continue             continue execution until the next breakpoint
-i, ignore               continue execution, ignore all breakpoints
-              BREAKPOINTS
-b, break <name> [fromline [toline]] [file]
-                        set a new breakpoint named 'name' for line and file
-                        if line or file are omitted the current one is used
-breakpoints             display the entire breakpoint list
-disable <name>          disable a breakpoint
-enable  <name>          enable a breakpoint
-              DATA DISPLAY
-e, eval <expr>          evaluate the expression <expr>
-o, out <file> <expr>    evaluate <expr> and write it to <file>
-w, where                display the current execution point
-stackframe [file]       display current stack frame [and write it to file]
-u, up                   go up in the call stack
-d, down                 go down in the call stack
-bt, backtrace           display the entire call stack
-l, locals               display available local variables
-g, globals              display available global variables
-maxdisplay <integer>    set the display's recursion maximum
-""")
-
-proc InvalidCommand() =
-  debugOut("[Warning] invalid command ignored (type 'h' for help) ")
-
-proc hasExt(s: string): bool =
-  # returns true if s has a filename extension
-  for i in countdown(len(s)-1, 0):
-    if s[i] == '.': return true
-  return false
-
-proc setBreakPoint(s: string, start: int) =
-  var dbgTemp: string
-  var i = scanWord(s, dbgTemp, start)
-  if i <= start:
-    InvalidCommand()
-    return
-  if dbgBPlen >= high(dbgBP):
-    debugOut("[Warning] no breakpoint could be set; out of breakpoint space ")
-    return
-  var x = dbgBPlen
-  inc(dbgBPlen)
-  dbgBP[x].name = dbgTemp
-  i = scanNumber(s, dbgBP[x].low, i)
-  if dbgBP[x].low == 0:
-    # set to current line:
-    dbgBP[x].low = framePtr.line
-  i = scanNumber(s, dbgBP[x].high, i)
-  if dbgBP[x].high == 0: # set to low:
-    dbgBP[x].high = dbgBP[x].low
-  i = scanFilename(s, dbgTemp, i)
-  if not (dbgTemp.len == 0):
-    if not hasExt(dbgTemp): add(dbgTemp, ".nim")
-    dbgBP[x].filename = dbgTemp
-  else: # use current filename
-    dbgBP[x].filename = $framePtr.filename
-  # skip whitespace:
-  while s[i] in {' ', '\t'}: inc(i)
-  if s[i] != '\0':
-    dec(dbgBPLen) # remove buggy breakpoint
-    InvalidCommand()
-
-proc BreakpointSetEnabled(s: string, start, enabled: int) =
-  var dbgTemp: string
-  var i = scanWord(s, dbgTemp, start)
-  if i <= start:
-    InvalidCommand()
-    return
-  var x = findBreakpoint(dbgTemp)
-  if x < 0: debugOut("[Warning] breakpoint does not exist ")
-  elif enabled * dbgBP[x].low < 0: # signs are different?
-    dbgBP[x].low = -dbgBP[x].low
-    dbgBP[x].high = -dbgBP[x].high
-
-proc dbgEvaluate(stream: TFile, s: string, start: int,
-                 currFrame: PExtendedFrame) =
-  var dbgTemp: string
-  var i = scanWord(s, dbgTemp, start)
-  while s[i] in {' ', '\t'}: inc(i)
-  var f = currFrame
-  if s[i] == '.':
-    inc(i) # skip '.'
-    add(dbgTemp, '.')
-    i = scanAndAppendWord(s, dbgTemp, i)
-    # search for global var:
-    f = addr(dbgGlobalData)
-  if s[i] != '\0':
-    debugOut("[Warning] could not parse expr ")
-    return
-  var j = findVariable(f, dbgTemp)
-  if j < 0:
-    debugOut("[Warning] could not find variable ")
-    return
-  writeVariable(stream, f.slots[j])
-
-proc dbgOut(s: string, start: int, currFrame: PExtendedFrame) =
-  var dbgTemp: string
-  var i = scanFilename(s, dbgTemp, start)
-  if dbgTemp.len == 0:
-    InvalidCommand()
-    return
-  var stream = openAppend(dbgTemp)
-  if stream == nil:
-    debugOut("[Warning] could not open or create file ")
-    return
-  dbgEvaluate(stream, s, i, currFrame)
-  close(stream)
-
-proc dbgStackFrame(s: string, start: int, currFrame: PExtendedFrame) =
-  var dbgTemp: string
-  var i = scanFilename(s, dbgTemp, start)
-  if dbgTemp.len == 0:
-    # just write it to stdout:
-    ListFrame(stdout, currFrame)
-  else:
-    var stream = openAppend(dbgTemp)
-    if stream == nil:
-      debugOut("[Warning] could not open or create file ")
-      return
-    ListFrame(stream, currFrame)
-    close(stream)
-
-proc CommandPrompt() =
-  # if we return from this routine, user code executes again
-  var
-    again = True
-    dbgFramePtr = framePtr # for going down and up the stack
-    dbgDown = 0 # how often we did go down
-
-  while again:
-    write(stdout, "*** endb| >>")
-    var tmp = readLine(stdin)
-    if tmp.len > 0: dbgUser = tmp
-    # now look what we have to do:
-    var dbgTemp: string
-    var i = scanWord(dbgUser, dbgTemp, 0)
-    case dbgTemp
-    of "": InvalidCommand()
-    of "s", "step":
-      dbgState = dbStepInto
-      again = false
-    of "n", "next":
-      dbgState = dbStepOver
-      dbgSkipToFrame = framePtr
-      again = false
-    of "f", "skipcurrent":
-      dbgState = dbSkipCurrent
-      dbgSkipToFrame = framePtr.prev
-      again = false
-    of "c", "continue":
-      dbgState = dbBreakpoints
-      again = false
-    of "i", "ignore":
-      dbgState = dbOff
-      again = false
-    of "h", "help":
-      dbgHelp()
-    of "q", "quit":
-      dbgState = dbQuiting
-      dbgAborting = True
-      again = false
-      quit(1) # BUGFIX: quit with error code > 0
-    of "e", "eval":
-      dbgEvaluate(stdout, dbgUser, i, cast[PExtendedFrame](dbgFramePtr))
-    of "o", "out":
-      dbgOut(dbgUser, i, cast[PExtendedFrame](dbgFramePtr))
-    of "stackframe":
-      dbgStackFrame(dbgUser, i, cast[PExtendedFrame](dbgFramePtr))
-    of "w", "where":
-      dbgShowExecutionPoint()
-    of "l", "locals":
-      ListVariables(stdout, cast[PExtendedFrame](dbgFramePtr))
-    of "g", "globals":
-      ListVariables(stdout, addr(dbgGlobalData))
-    of "u", "up":
-      if dbgDown <= 0:
-        debugOut("[Warning] cannot go up any further ")
-      else:
-        dbgFramePtr = framePtr
-        for j in 0 .. dbgDown-2: # BUGFIX
-          dbgFramePtr = dbgFramePtr.prev
-        dec(dbgDown)
-      dbgShowCurrentProc(dbgFramePtr)
-    of "d", "down":
-      if dbgFramePtr != nil:
-        inc(dbgDown)
-        dbgFramePtr = dbgFramePtr.prev
-        dbgShowCurrentProc(dbgFramePtr)
-      else:
-        debugOut("[Warning] cannot go down any further ")
-    of "bt", "backtrace":
-      WriteStackTrace()
-    of "b", "break":
-      setBreakPoint(dbgUser, i)
-    of "breakpoints":
-      ListBreakPoints()
-    of "disable":
-      BreakpointSetEnabled(dbgUser, i, -1)
-    of "enable":
-      BreakpointSetEnabled(dbgUser, i, +1)
-    of "maxdisplay":
-      var parsed: int
-      i = scanNumber(dbgUser, parsed, i)
-      if dbgUser[i-1] in {'0'..'9'}:
-        if parsed == 0: maxDisplayRecDepth = -1
-        else: maxDisplayRecDepth = parsed
-      else:
-        InvalidCommand()
-    else:
-      InvalidCommand()
-
-proc endbStep() =
-  # we get into here if an unhandled exception has been raised
-  # XXX: do not allow the user to run the program any further?
-  # XXX: BUG: the frame is lost here!
-  dbgShowExecutionPoint()
-  CommandPrompt()
-
-proc checkForBreakpoint() =
-  var i = dbgBreakpointReached(framePtr.line)
-  if i >= 0:
-    write(stdout, "*** endb| reached ")
-    write(stdout, dbgBP[i].name)
-    write(stdout, " in ")
-    write(stdout, framePtr.filename)
-    write(stdout, "(")
-    write(stdout, framePtr.line)
-    write(stdout, ") ")
-    write(stdout, framePtr.procname)
-    write(stdout, " ***\n")
-    CommandPrompt()
-
-# interface to the user program:
-
-proc dbgRegisterBreakpoint(line: int,
-                           filename, name: cstring) {.compilerproc.} =
-  var x = dbgBPlen
-  inc(dbgBPlen)
-  dbgBP[x].name = $name
-  dbgBP[x].filename = $filename
-  dbgBP[x].low = line
-  dbgBP[x].high = line
-
-proc dbgRegisterGlobal(name: cstring, address: pointer,
-                       typ: PNimType) {.compilerproc.} =
-  var i = dbgGlobalData.f.len
-  if i >= high(dbgGlobalData.slots):
-    debugOut("[Warning] cannot register global ")
-    return
-  dbgGlobalData.slots[i].name = name
-  dbgGlobalData.slots[i].typ = typ
-  dbgGlobalData.slots[i].address = address
-  inc(dbgGlobalData.f.len)
-
-proc endb(line: int) {.compilerproc.} =
-  # This proc is called before every Nimrod code line!
-  # Thus, it must have as few parameters as possible to keep the
-  # code size small!
-  # Check if we are at an enabled breakpoint or "in the mood"
-  framePtr.line = line # this is done here for smaller code size!
-  if dbgLineHook != nil: dbgLineHook()
-  case dbgState
-  of dbStepInto:
-    # we really want the command prompt here:
-    dbgShowExecutionPoint()
-    CommandPrompt()
-  of dbSkipCurrent, dbStepOver: # skip current routine
-    if framePtr == dbgSkipToFrame:
-      dbgShowExecutionPoint()
-      CommandPrompt()
-    else: # breakpoints are wanted though (I guess)
-      checkForBreakpoint()
-  of dbBreakpoints: # debugger is only interested in breakpoints
-    checkForBreakpoint()
-  else: nil
diff --git a/lib/system/deepcopy.nim b/lib/system/deepcopy.nim
new file mode 100644
index 000000000..72d35f518
--- /dev/null
+++ b/lib/system/deepcopy.nim
@@ -0,0 +1,206 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+const
+  TableSize = when sizeof(int) <= 2: 0xff else: 0xff_ffff
+
+type
+  PtrTable = ptr object
+    counter, max: int
+    data: array[TableSize, (pointer, pointer)]
+
+template hashPtr(key: pointer): int = cast[int](key) shr 8
+template allocPtrTable: untyped =
+  cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*2*cap))
+
+proc rehash(t: PtrTable): PtrTable =
+  let cap = (t.max+1) * 2
+  result = allocPtrTable()
+  result.counter = t.counter
+  result.max = cap-1
+  for i in 0..t.max:
+    let k = t.data[i][0]
+    if k != nil:
+      var h = hashPtr(k)
+      while result.data[h and result.max][0] != nil: inc h
+      result.data[h and result.max] = t.data[i]
+  dealloc t
+
+proc initPtrTable(): PtrTable =
+  const cap = 32
+  result = allocPtrTable()
+  result.counter = 0
+  result.max = cap-1
+
+template deinit(t: PtrTable) = dealloc(t)
+
+proc get(t: PtrTable; key: pointer): pointer =
+  var h = hashPtr(key)
+  while true:
+    let k = t.data[h and t.max][0]
+    if k == nil: break
+    if k == key:
+      return t.data[h and t.max][1]
+    inc h
+
+proc put(t: var PtrTable; key, val: pointer) =
+  if (t.max+1) * 2 < t.counter * 3: t = rehash(t)
+  var h = hashPtr(key)
+  while t.data[h and t.max][0] != nil: inc h
+  t.data[h and t.max] = (key, val)
+  inc t.counter
+
+proc genericDeepCopyAux(dest, src: pointer, mt: PNimType;
+                        tab: var PtrTable) {.benign.}
+proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode;
+                        tab: var PtrTable) {.benign.} =
+  var
+    d = cast[int](dest)
+    s = cast[int](src)
+  case n.kind
+  of nkSlot:
+    genericDeepCopyAux(cast[pointer](d +% n.offset),
+                       cast[pointer](s +% n.offset), n.typ, tab)
+  of nkList:
+    for i in 0..n.len-1:
+      genericDeepCopyAux(dest, src, n.sons[i], tab)
+  of nkCase:
+    var dd = selectBranch(dest, n)
+    var m = selectBranch(src, n)
+    # reset if different branches are in use; note different branches also
+    # imply that's not self-assignment (``x = x``)!
+    if m != dd and dd != nil:
+      genericResetAux(dest, dd)
+    copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
+            n.typ.size)
+    if m != nil:
+      genericDeepCopyAux(dest, src, m, tab)
+  of nkNone: sysAssert(false, "genericDeepCopyAux")
+
+proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
+  var
+    d = cast[int](dest)
+    s = cast[int](src)
+  sysAssert(mt != nil, "genericDeepCopyAux 2")
+  case mt.kind
+  of tyString:
+    when defined(nimSeqsV2):
+      var x = cast[ptr NimStringV2](dest)
+      var s2 = cast[ptr NimStringV2](s)[]
+      nimAsgnStrV2(x[], s2)
+    else:
+      var x = cast[PPointer](dest)
+      var s2 = cast[PPointer](s)[]
+      if s2 == nil:
+        unsureAsgnRef(x, s2)
+      else:
+        unsureAsgnRef(x, copyDeepString(cast[NimString](s2)))
+  of tySequence:
+    when defined(nimSeqsV2):
+      deepSeqAssignImpl(genericDeepCopyAux, tab)
+    else:
+      var s2 = cast[PPointer](src)[]
+      var seq = cast[PGenericSeq](s2)
+      var x = cast[PPointer](dest)
+      if s2 == nil:
+        unsureAsgnRef(x, s2)
+        return
+      sysAssert(dest != nil, "genericDeepCopyAux 3")
+      unsureAsgnRef(x, newSeq(mt, seq.len))
+      var dst = cast[int](cast[PPointer](dest)[])
+      for i in 0..seq.len-1:
+        genericDeepCopyAux(
+          cast[pointer](dst +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size),
+          cast[pointer](cast[int](s2) +% align(GenericSeqSize, mt.base.align) +% i *% mt.base.size),
+          mt.base, tab)
+  of tyObject:
+    # we need to copy m_type field for tyObject, as it could be empty for
+    # sequence reallocations:
+    if mt.base != nil:
+      genericDeepCopyAux(dest, src, mt.base, tab)
+    else:
+      var pint = cast[ptr PNimType](dest)
+      pint[] = cast[ptr PNimType](src)[]
+    genericDeepCopyAux(dest, src, mt.node, tab)
+  of tyTuple:
+    genericDeepCopyAux(dest, src, mt.node, tab)
+  of tyArray, tyArrayConstr:
+    for i in 0..(mt.size div mt.base.size)-1:
+      genericDeepCopyAux(cast[pointer](d +% i *% mt.base.size),
+                         cast[pointer](s +% i *% mt.base.size), mt.base, tab)
+  of tyRef:
+    let s2 = cast[PPointer](src)[]
+    if s2 == nil:
+      unsureAsgnRef(cast[PPointer](dest), s2)
+    elif mt.base.deepcopy != nil:
+      let z = mt.base.deepcopy(s2)
+      when defined(nimSeqsV2):
+        cast[PPointer](dest)[] = z
+      else:
+        unsureAsgnRef(cast[PPointer](dest), z)
+    else:
+      let z = tab.get(s2)
+      if z == nil:
+        when declared(usrToCell):
+          let x = usrToCell(s2)
+          let realType = x.typ
+          let z = newObj(realType, realType.base.size)
+          unsureAsgnRef(cast[PPointer](dest), z)
+          tab.put(s2, z)
+          genericDeepCopyAux(z, s2, realType.base, tab)
+        else:
+          when false:
+            # addition check disabled
+            let x = usrToCell(s2)
+            let realType = x.typ
+            sysAssert realType == mt, " types do differ"
+          when defined(nimSeqsV2):
+            let typ = if mt.base.kind == tyObject: cast[PNimType](cast[ptr PNimTypeV2](s2)[].typeInfoV1)
+                      else: mt.base
+            let z = nimNewObj(typ.size, typ.align)
+            cast[PPointer](dest)[] = z
+          else:
+            # this version should work for any other GC:
+            let typ = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[] else: mt.base
+            let z = newObj(mt, typ.size)
+            unsureAsgnRef(cast[PPointer](dest), z)
+          tab.put(s2, z)
+          genericDeepCopyAux(z, s2, typ, tab)
+      else:
+        unsureAsgnRef(cast[PPointer](dest), z)
+  of tyPtr:
+    # no cycle check here, but also not really required
+    let s2 = cast[PPointer](src)[]
+    if s2 != nil and mt.base.deepcopy != nil:
+      cast[PPointer](dest)[] = mt.base.deepcopy(s2)
+    else:
+      cast[PPointer](dest)[] = s2
+  else:
+    copyMem(dest, src, mt.size)
+
+proc genericDeepCopy(dest, src: pointer, mt: PNimType) {.compilerproc.} =
+  when not defined(nimSeqsV2): GC_disable()
+  var tab = initPtrTable()
+  genericDeepCopyAux(dest, src, mt, tab)
+  deinit tab
+  when not defined(nimSeqsV2): GC_enable()
+
+proc genericSeqDeepCopy(dest, src: pointer, mt: PNimType) {.compilerproc.} =
+  # also invoked for 'string'
+  var src = src
+  genericDeepCopy(dest, addr(src), mt)
+
+proc genericDeepCopyOpenArray(dest, src: pointer, len: int,
+                            mt: PNimType) {.compilerproc.} =
+  var
+    d = cast[int](dest)
+    s = cast[int](src)
+  for i in 0..len-1:
+    genericDeepCopy(cast[pointer](d +% i *% mt.base.size),
+                    cast[pointer](s +% i *% mt.base.size), mt.base)
diff --git a/lib/system/dollars.nim b/lib/system/dollars.nim
new file mode 100644
index 000000000..89a739d5a
--- /dev/null
+++ b/lib/system/dollars.nim
@@ -0,0 +1,147 @@
+## `$` is Nim's general way of spelling `toString`:idx:.
+runnableExamples:
+  assert $0.1 == "0.1"
+  assert $(-2*3) == "-6"
+
+import std/private/[digitsutils, miscdollars]
+
+when not defined(nimPreviewSlimSystem):
+  import std/formatfloat
+  export addFloat
+
+  func `$`*(x: float | float32): string =
+    ## Outplace version of `addFloat`.
+    result.addFloat(x)
+
+proc `$`*(x: int): string {.raises: [].} =
+  ## Outplace version of `addInt`.
+  result.addInt(x)
+
+proc `$`*(x: int64): string {.raises: [].} =
+  ## Outplace version of `addInt`.
+  result.addInt(x)
+
+proc `$`*(x: uint64): string {.raises: [].} =
+  ## Outplace version of `addInt`.
+  addInt(result, x)
+
+# same as old `ctfeWhitelist` behavior, whether or not this is a good idea.
+template gen(T) =
+  # xxx simplify this by supporting this in compiler: int{lit} | uint64{lit} | int64{lit}
+  func `$`*(x: T{lit}): string {.compileTime.} = result.addInt(x)
+gen(int)
+gen(uint64)
+gen(int64)
+
+
+proc `$`*(x: bool): string {.magic: "BoolToStr", noSideEffect.}
+  ## The stringify operator for a boolean argument. Returns `x`
+  ## converted to the string "false" or "true".
+
+proc `$`*(x: char): string {.magic: "CharToStr", noSideEffect.}
+  ## The stringify operator for a character argument. Returns `x`
+  ## converted to a string.
+  ##   ```Nim
+  ##   assert $'c' == "c"
+  ##   ```
+
+proc `$`*(x: cstring): string {.magic: "CStrToStr", noSideEffect.}
+  ## The stringify operator for a CString argument. Returns `x`
+  ## converted to a string.
+
+proc `$`*(x: string): string {.magic: "StrToStr", noSideEffect.}
+  ## The stringify operator for a string argument. Returns `x`
+  ## as it is. This operator is useful for generic code, so
+  ## that `$expr` also works if `expr` is already a string.
+
+proc `$`*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.}
+  ## The stringify operator for an enumeration argument. This works for
+  ## any enumeration type thanks to compiler magic.
+  ##
+  ## If a `$` operator for a concrete enumeration is provided, this is
+  ## used instead. (In other words: *Overwriting* is possible.)
+
+proc `$`*(t: typedesc): string {.magic: "TypeTrait".}
+  ## Returns the name of the given type.
+  ##
+  ## For more procedures dealing with `typedesc`, see
+  ## `typetraits module <typetraits.html>`_.
+  ##
+  ##   ```Nim
+  ##   doAssert $(typeof(42)) == "int"
+  ##   doAssert $(typeof("Foo")) == "string"
+  ##   static: doAssert $(typeof(@['A', 'B'])) == "seq[char]"
+  ##   ```
+
+proc `$`*[T: tuple](x: T): string =
+  ## Generic `$` operator for tuples that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(23, 45) == "(23, 45)"
+  ##   $(a: 23, b: 45) == "(a: 23, b: 45)"
+  ##   $() == "()"
+  ##   ```
+  tupleObjectDollar(result, x)
+
+when not defined(nimPreviewSlimSystem):
+  import std/objectdollar
+  export objectdollar
+
+proc collectionToString[T](x: T, prefix, separator, suffix: string): string =
+  result = prefix
+  var firstElement = true
+  for value in items(x):
+    if firstElement:
+      firstElement = false
+    else:
+      result.add(separator)
+
+    when value isnot string and value isnot seq and compiles(value.isNil):
+      # this branch should not be necessary
+      if value.isNil:
+        result.add "nil"
+      else:
+        result.addQuoted(value)
+    else:
+      result.addQuoted(value)
+  result.add(suffix)
+
+proc `$`*[T](x: set[T]): string =
+  ## Generic `$` operator for sets that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   ${23, 45} == "{23, 45}"
+  ##   ```
+  collectionToString(x, "{", ", ", "}")
+
+proc `$`*[T](x: seq[T]): string =
+  ## Generic `$` operator for seqs that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(@[23, 45]) == "@[23, 45]"
+  ##   ```
+  collectionToString(x, "@[", ", ", "]")
+
+proc `$`*[T, U](x: HSlice[T, U]): string =
+  ## Generic `$` operator for slices that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##  $(1 .. 5) == "1 .. 5"
+  ##  ```
+  result = $x.a
+  result.add(" .. ")
+  result.add($x.b)
+
+
+when not defined(nimNoArrayToString):
+  proc `$`*[T, IDX](x: array[IDX, T]): string =
+    ## Generic `$` operator for arrays that is lifted from the components.
+    collectionToString(x, "[", ", ", "]")
+
+proc `$`*[T](x: openArray[T]): string =
+  ## Generic `$` operator for openarrays that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]"
+  ##   ```
+  collectionToString(x, "[", ", ", "]")
diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim
index 0946ee355..2162b234f 100755..100644
--- a/lib/system/dyncalls.nim
+++ b/lib/system/dyncalls.nim
@@ -1,30 +1,60 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 # This file implements the ability to call native procs from libraries.
-# It is not possible to do this in a platform independant way, unfortunately.
+# It is not possible to do this in a platform independent way, unfortunately.
 # However, the interface has been designed to take platform differences into
 # account and been ported to all major platforms.
 
-type
-  TLibHandle = pointer       # private type
-  TProcAddr = pointer        # libary loading and loading of procs:
+{.push stack_trace: off.}
 
 const
-  NilLibHandle: TLibHandle = nil
-
-proc nimLoadLibrary(path: string): TLibHandle {.compilerproc.}
-proc nimUnloadLibrary(lib: TLibHandle) {.compilerproc.}
-proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr {.compilerproc.}
-
-proc nimLoadLibraryError(path: string) {.compilerproc, noinline.} =
-  raise newException(EInvalidLibrary, "could not load: " & path)
+  NilLibHandle: LibHandle = nil
+
+proc nimLoadLibraryError(path: string) =
+  # carefully written to avoid memory allocation:
+  const prefix = "could not load: "
+  cstderr.rawWrite(prefix)
+  cstderr.rawWrite(path)
+  when not defined(nimDebugDlOpen) and not defined(windows):
+    cstderr.rawWrite("\n(compile with -d:nimDebugDlOpen for more information)")
+  when defined(windows):
+    const badExe = "\n(bad format; library may be wrong architecture)"
+    let loadError = GetLastError()
+    if loadError == ERROR_BAD_EXE_FORMAT:
+      cstderr.rawWrite(badExe)
+    when defined(guiapp):
+      # Because console output is not shown in GUI apps, display the error as a
+      # message box instead:
+      var
+        msg: array[1000, char]
+        msgLeft = msg.len - 1 # leave (at least) one for nullchar
+        msgIdx = 0
+      copyMem(msg[msgIdx].addr, prefix.cstring, prefix.len)
+      msgLeft -= prefix.len
+      msgIdx += prefix.len
+      let pathLen = min(path.len, msgLeft)
+      copyMem(msg[msgIdx].addr, path.cstring, pathLen)
+      msgLeft -= pathLen
+      msgIdx += pathLen
+      if loadError == ERROR_BAD_EXE_FORMAT and msgLeft >= badExe.len:
+        copyMem(msg[msgIdx].addr, badExe.cstring, badExe.len)
+      discard MessageBoxA(nil, msg[0].addr, nil, 0)
+  cstderr.rawWrite("\n")
+  rawQuit(1)
+
+proc procAddrError(name: cstring) {.compilerproc, nonReloadable, hcrInline.} =
+  # carefully written to avoid memory allocation:
+  cstderr.rawWrite("could not import: ")
+  cstderr.rawWrite(name)
+  cstderr.rawWrite("\n")
+  rawQuit(1)
 
 # this code was inspired from Lua's source code:
 # Lua - An Extensible Extension Language
@@ -43,24 +73,37 @@ when defined(posix):
   #
 
   # c stuff:
-  var
-    RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
+  when defined(linux) or defined(macosx):
+    const RTLD_NOW = cint(2)
+  else:
+    var
+      RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: cint
 
-  proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".}
-  proc dlopen(path: CString, mode: int): TLibHandle {.
+  proc dlclose(lib: LibHandle) {.importc, header: "<dlfcn.h>".}
+  proc dlopen(path: cstring, mode: cint): LibHandle {.
       importc, header: "<dlfcn.h>".}
-  proc dlsym(lib: TLibHandle, name: cstring): TProcAddr {.
+  proc dlsym(lib: LibHandle, name: cstring): ProcAddr {.
       importc, header: "<dlfcn.h>".}
 
-  proc nimUnloadLibrary(lib: TLibHandle) =
-    dlclose(lib)
+  proc dlerror(): cstring {.importc, header: "<dlfcn.h>".}
 
-  proc nimLoadLibrary(path: string): TLibHandle =
-    result = dlopen(path, RTLD_NOW)
+  proc nimUnloadLibrary(lib: LibHandle) =
+    dlclose(lib)
 
-  proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
+  proc nimLoadLibrary(path: string): LibHandle =
+    let flags =
+      when defined(globalSymbols): RTLD_NOW or RTLD_GLOBAL
+      else: RTLD_NOW
+    result = dlopen(path, flags)
+    when defined(nimDebugDlOpen):
+      let error = dlerror()
+      if error != nil:
+        cstderr.rawWrite(error)
+        cstderr.rawWrite("\n")
+
+  proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
     result = dlsym(lib, name)
-    if result == nil: nimLoadLibraryError($name)
+    if result == nil: procAddrError(name)
 
 elif defined(windows) or defined(dos):
   #
@@ -68,60 +111,90 @@ elif defined(windows) or defined(dos):
   # Native Windows Implementation
   # =======================================================================
   #
-  type
-    THINSTANCE {.importc: "HINSTANCE".} = pointer
-
-  proc FreeLibrary(lib: THINSTANCE) {.importc, header: "<windows.h>", stdcall.}
+  when defined(cpp):
+    type
+      THINSTANCE {.importc: "HINSTANCE".} = object
+        x: pointer
+    proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {.
+        importcpp: "(void*)GetProcAddress(@)", header: "<windows.h>", stdcall.}
+  else:
+    type
+      THINSTANCE {.importc: "HINSTANCE".} = pointer
+    proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {.
+        importc: "GetProcAddress", header: "<windows.h>", stdcall.}
+
+  proc freeLibrary(lib: THINSTANCE) {.
+      importc: "FreeLibrary", header: "<windows.h>", stdcall.}
   proc winLoadLibrary(path: cstring): THINSTANCE {.
       importc: "LoadLibraryA", header: "<windows.h>", stdcall.}
-  proc GetProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {.
-      importc: "GetProcAddress", header: "<windows.h>", stdcall.}
-
-  proc nimUnloadLibrary(lib: TLibHandle) =
-    FreeLibrary(cast[THINSTANCE](lib))
-
-  proc nimLoadLibrary(path: string): TLibHandle =
-    result = cast[TLibHandle](winLoadLibrary(path))
 
-  proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
-    result = GetProcAddress(cast[THINSTANCE](lib), name)
-    if result == nil: nimLoadLibraryError($name)
-
-elif defined(mac):
-  #
-  # =======================================================================
-  # Native Mac OS X / Darwin Implementation
-  # =======================================================================
-  #
-  {.error: "no implementation for dyncalls yet".}
-
-  proc nimUnloadLibrary(lib: TLibHandle) =
-    NSUnLinkModule(NSModule(lib), NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES)
-
-  var
-    dyld_present {.importc: "_dyld_present", header: "<dyld.h>".}: int
-
-  proc nimLoadLibrary(path: string): TLibHandle =
-    var
-      img: NSObjectFileImage
-      ret: NSObjectFileImageReturnCode
-      modul: NSModule
-    # this would be a rare case, but prevents crashing if it happens
-    result = nil
-    if dyld_present != 0:
-      ret = NSCreateObjectFileImageFromFile(path, addr(img))
-      if ret == NSObjectFileImageSuccess:
-        modul = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE or
-                                        NSLINKMODULE_OPTION_RETURN_ON_ERROR)
-        NSDestroyObjectFileImage(img)
-        result = TLibHandle(modul)
-
-  proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
-    var
-      nss: NSSymbol
-    nss = NSLookupSymbolInModule(NSModule(lib), name)
-    result = TProcAddr(NSAddressOfSymbol(nss))
-    if result == nil: nimLoadLibraryError($name)
+  proc nimUnloadLibrary(lib: LibHandle) =
+    freeLibrary(cast[THINSTANCE](lib))
+
+  proc nimLoadLibrary(path: string): LibHandle =
+    result = cast[LibHandle](winLoadLibrary(path))
+
+  proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
+    result = getProcAddress(cast[THINSTANCE](lib), name)
+    if result != nil: return
+    const decoratedLength = 250
+    var decorated: array[decoratedLength, char]
+    decorated[0] = '_'
+    var m = 1
+    while m < (decoratedLength - 5):
+      if name[m - 1] == '\x00': break
+      decorated[m] = name[m - 1]
+      inc(m)
+    decorated[m] = '@'
+    for i in countup(0, 50):
+      var k = i * 4
+      if k div 100 == 0:
+        if k div 10 == 0:
+          m = m + 1
+        else:
+          m = m + 2
+      else:
+        m = m + 3
+      decorated[m + 1] = '\x00'
+      while true:
+        decorated[m] = chr(ord('0') + (k %% 10))
+        dec(m)
+        k = k div 10
+        if k == 0: break
+      result = getProcAddress(cast[THINSTANCE](lib), cast[cstring](addr decorated))
+      if result != nil: return
+    procAddrError(name)
+
+elif defined(genode):
+
+  proc nimUnloadLibrary(lib: LibHandle) =
+    raiseAssert("nimUnloadLibrary not implemented")
+
+  proc nimLoadLibrary(path: string): LibHandle =
+    raiseAssert("nimLoadLibrary not implemented")
+
+  proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
+    raiseAssert("nimGetProcAddr not implemented")
+
+elif defined(nintendoswitch) or defined(freertos) or defined(zephyr) or defined(nuttx):
+  proc nimUnloadLibrary(lib: LibHandle) =
+    cstderr.rawWrite("nimUnLoadLibrary not implemented")
+    cstderr.rawWrite("\n")
+    rawQuit(1)
+
+  proc nimLoadLibrary(path: string): LibHandle =
+    cstderr.rawWrite("nimLoadLibrary not implemented")
+    cstderr.rawWrite("\n")
+    rawQuit(1)
+
+
+  proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
+    cstderr.rawWrite("nimGetProAddr not implemented")
+    cstderr.rawWrite(name)
+    cstderr.rawWrite("\n")
+    rawQuit(1)
 
 else:
   {.error: "no implementation for dyncalls".}
+
+{.pop.}
diff --git a/lib/system/ecmasys.nim b/lib/system/ecmasys.nim
deleted file mode 100755
index c0d0a5fd6..000000000
--- a/lib/system/ecmasys.nim
+++ /dev/null
@@ -1,531 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Stubs for the GC interface:
-
-proc GC_disable() = nil
-proc GC_enable() = nil
-proc GC_fullCollect() = nil
-proc GC_setStrategy(strategy: TGC_Strategy) = nil
-proc GC_enableMarkAndSweep() = nil
-proc GC_disableMarkAndSweep() = nil
-proc GC_getStatistics(): string = return ""
-
-proc getOccupiedMem(): int = return -1
-proc getFreeMem(): int = return -1
-proc getTotalMem(): int = return -1
-
-proc alert(s: cstring) {.importc, nodecl.}
-
-type
-  PSafePoint = ptr TSafePoint
-  TSafePoint {.compilerproc, final.} = object
-    prev: PSafePoint # points to next safe point
-    exc: ref E_Base
-
-  PCallFrame = ptr TCallFrame
-  TCallFrame {.importc, nodecl, final.} = object
-    prev: PCallFrame
-    procname: CString
-    line: int # current line number
-    filename: CString
-
-var
-  framePtr {.importc, nodecl, volatile.}: PCallFrame
-  excHandler {.importc, nodecl, volatile.}: PSafePoint = nil
-    # list of exception handlers
-    # a global variable for the root of all try blocks
-
-{.push stacktrace: off.}
-proc nimBoolToStr(x: bool): string {.compilerproc.} =
-  if x: result = "true"
-  else: result = "false"
-
-proc nimCharToStr(x: char): string {.compilerproc.} =
-  result = newString(1)
-  result[0] = x
-
-proc getCurrentExceptionMsg(): string =
-  if excHandler != nil: return $excHandler.exc.msg
-  return ""
-
-proc auxWriteStackTrace(f: PCallFrame): string =
-  type
-    TTempFrame = tuple[procname: CString, line: int]
-  var
-    it = f
-    i = 0
-    total = 0
-    tempFrames: array [0..63, TTempFrame]
-  while it != nil and i <= high(tempFrames):
-    tempFrames[i].procname = it.procname
-    tempFrames[i].line = it.line
-    inc(i)
-    inc(total)
-    it = it.prev
-  while it != nil:
-    inc(total)
-    it = it.prev
-  result = ""
-  # if the buffer overflowed print '...':
-  if total != i:
-    add(result, "(")
-    add(result, $(total-i))
-    add(result, " calls omitted) ...\n")
-  for j in countdown(i-1, 0):
-    add(result, tempFrames[j].procname)
-    if tempFrames[j].line > 0:
-      add(result, ", line: ")
-      add(result, $tempFrames[j].line)
-    add(result, "\n")
-
-proc rawWriteStackTrace(): string =
-  if framePtr == nil:
-    result = "No stack traceback available\n"
-  else:
-    result = "Traceback (most recent call last)\n"& auxWriteStackTrace(framePtr)
-    framePtr = nil
-
-proc raiseException(e: ref E_Base, ename: cstring) {.compilerproc, pure.} =
-  e.name = ename
-  if excHandler != nil:
-    excHandler.exc = e
-  else:
-    var buf = rawWriteStackTrace()
-    if e.msg != nil and e.msg[0] != '\0':
-      add(buf, "Error: unhandled exception: ")
-      add(buf, e.msg)
-    else:
-      add(buf, "Error: unhandled exception")
-    add(buf, " [")
-    add(buf, ename)
-    add(buf, "]\n")
-    alert(buf)
-  asm """throw `e`;"""
-
-proc reraiseException() =
-  if excHandler == nil:
-    raise newException(ENoExceptionToReraise, "no exception to reraise")
-  else:
-    asm """throw excHandler.exc;"""
-
-proc raiseOverflow {.exportc: "raiseOverflow", noreturn.} =
-  raise newException(EOverflow, "over- or underflow")
-
-proc raiseDivByZero {.exportc: "raiseDivByZero", noreturn.} =
-  raise newException(EDivByZero, "divison by zero")
-
-proc raiseRangeError() {.compilerproc, noreturn.} =
-  raise newException(EOutOfRange, "value out of range")
-
-proc raiseIndexError() {.compilerproc, noreturn.} =
-  raise newException(EInvalidIndex, "index out of bounds")
-
-proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
-  raise newException(EInvalidField, f & " is not accessible")
-
-
-
-proc SetConstr() {.varargs, pure, compilerproc.} =
-  asm """
-    var result = {};
-    for (var i = 0; i < arguments.length; ++i) {
-      var x = arguments[i];
-      if (typeof(x) == "object") {
-        for (var j = x[0]; j <= x[1]; ++j) {
-          result[j] = true;
-        }
-      } else {
-        result[x] = true;
-      }
-    }
-    return result;
-  """
-
-proc cstrToNimstr(c: cstring): string {.pure, compilerproc.} =
-  asm """
-    var result = [];
-    for (var i = 0; i < `c`.length; ++i) {
-      result[i] = `c`.charCodeAt(i);
-    }
-    result[result.length] = 0; // terminating zero
-    return result;
-  """
-
-proc toEcmaStr(s: string): cstring {.pure, compilerproc.} =
-  asm """
-    var len = `s`.length-1;
-    var result = new Array(len);
-    var fcc = String.fromCharCode;
-    for (var i = 0; i < len; ++i) {
-      result[i] = fcc(`s`[i]);
-    }
-    return result.join("");
-  """
-
-proc mnewString(len: int): string {.pure, compilerproc.} =
-  asm """
-    var result = new Array(`len`+1);
-    result[0] = 0;
-    result[`len`] = 0;
-    return result;
-  """
-
-proc SetCard(a: int): int {.compilerproc, pure.} =
-  # argument type is a fake
-  asm """
-    var result = 0;
-    for (var elem in `a`) { ++result; }
-    return result;
-  """
-
-proc SetEq(a, b: int): bool {.compilerproc, pure.} =
-  asm """
-    for (var elem in `a`) { if (!`b`[elem]) return false; }
-    for (var elem in `b`) { if (!`a`[elem]) return false; }
-    return true;
-  """
-
-proc SetLe(a, b: int): bool {.compilerproc, pure.} =
-  asm """
-    for (var elem in `a`) { if (!`b`[elem]) return false; }
-    return true;
-  """
-
-proc SetLt(a, b: int): bool {.compilerproc.} =
-  result = SetLe(a, b) and not SetEq(a, b)
-
-proc SetMul(a, b: int): int {.compilerproc, pure.} =
-  asm """
-    var result = {};
-    for (var elem in `a`) {
-      if (`b`[elem]) { result[elem] = true; }
-    }
-    return result;
-  """
-
-proc SetPlus(a, b: int): int {.compilerproc, pure.} =
-  asm """
-    var result = {};
-    for (var elem in `a`) { result[elem] = true; }
-    for (var elem in `b`) { result[elem] = true; }
-    return result;
-  """
-
-proc SetMinus(a, b: int): int {.compilerproc, pure.} =
-  asm """
-    var result = {};
-    for (var elem in `a`) {
-      if (!`b`[elem]) { result[elem] = true; }
-    }
-    return result;
-  """
-
-proc cmpStrings(a, b: string): int {.pure, compilerProc.} =
-  asm """
-    if (`a` == `b`) return 0;
-    if (!`a`) return -1;
-    if (!`b`) return 1;
-    for (var i = 0; i < `a`.length-1; ++i) {
-      var result = `a`[i] - `b`[i];
-      if (result != 0) return result;
-    }
-    return 0;
-  """
-
-proc cmp(x, y: string): int = return cmpStrings(x, y)
-
-proc eqStrings(a, b: string): bool {.pure, compilerProc.} =
-  asm """
-    if (`a == `b`) return true;
-    if ((!`a`) || (!`b`)) return false;
-    var alen = `a`.length;
-    if (alen != `b`.length) return false;
-    for (var i = 0; i < alen; ++i)
-      if (`a`[i] != `b`[i]) return false;
-    return true;
-  """
-
-type
-  TDocument {.importc.} = object of TObject
-    write: proc (text: cstring)
-    writeln: proc (text: cstring)
-    createAttribute: proc (identifier: cstring): ref TNode
-    createElement: proc (identifier: cstring): ref TNode
-    createTextNode: proc (identifier: cstring): ref TNode
-    getElementById: proc (id: cstring): ref TNode
-    getElementsByName: proc (name: cstring): seq[ref TNode]
-    getElementsByTagName: proc (name: cstring): seq[ref TNode]
-
-  TNodeType* = enum
-    ElementNode = 1,
-    AttributeNode,
-    TextNode,
-    CDATANode,
-    EntityRefNode,
-    EntityNode,
-    ProcessingInstructionNode,
-    CommentNode,
-    DocumentNode,
-    DocumentTypeNode,
-    DocumentFragmentNode,
-    NotationNode
-  TNode* {.importc.} = object of TObject
-    attributes*: seq[ref TNode]
-    childNodes*: seq[ref TNode]
-    data*: cstring
-    firstChild*: ref TNode
-    lastChild*: ref TNode
-    nextSibling*: ref TNode
-    nodeName*: cstring
-    nodeType*: TNodeType
-    nodeValue*: cstring
-    parentNode*: ref TNode
-    previousSibling*: ref TNode
-    appendChild*: proc (child: ref TNode)
-    appendData*: proc (data: cstring)
-    cloneNode*: proc (copyContent: bool)
-    deleteData*: proc (start, len: int)
-    getAttribute*: proc (attr: cstring): cstring
-    getAttributeNode*: proc (attr: cstring): ref TNode
-    getElementsByTagName*: proc (): seq[ref TNode]
-    hasChildNodes*: proc (): bool
-    insertBefore*: proc (newNode, before: ref TNode)
-    insertData*: proc (position: int, data: cstring)
-    removeAttribute*: proc (attr: cstring)
-    removeAttributeNode*: proc (attr: ref TNode)
-    removeChild*: proc (child: ref TNode)
-    replaceChild*: proc (newNode, oldNode: ref TNode)
-    replaceData*: proc (start, len: int, text: cstring)
-    setAttribute*: proc (name, value: cstring)
-    setAttributeNode*: proc (attr: ref TNode)
-    
-var
-  document {.importc, nodecl.}: ref TDocument
-
-proc ewriteln(x: cstring) = 
-  var node = document.getElementsByTagName("body")[0]
-  if node != nil: 
-    node.appendChild(document.createTextNode(x))
-    node.appendChild(document.createElement("br"))
-  else: 
-    raise newException(EInvalidValue, "<body> element does not exist yet!")
-
-proc echo*(x: int) = ewriteln($x)
-proc echo*(x: float) = ewriteln($x)
-proc echo*(x: bool) = ewriteln(if x: cstring("true") else: cstring("false"))
-proc echo*(x: string) = ewriteln(x)
-proc echo*(x: cstring) = ewriteln(x)
-
-proc echo[Ty](x: Ty) =
-  echo(x)
-
-proc echo[Ty](x: openArray[Ty]) =
-  for a in items(x): echo(a)
-
-# Arithmetic:
-proc addInt(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` + `b`;
-    if (result > 2147483647 || result < -2147483648) raiseOverflow();
-    return result;
-  """
-
-proc subInt(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` - `b`;
-    if (result > 2147483647 || result < -2147483648) raiseOverflow();
-    return result;
-  """
-
-proc mulInt(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` * `b`;
-    if (result > 2147483647 || result < -2147483648) raiseOverflow();
-    return result;
-  """
-
-proc divInt(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    if (`b` == 0) raiseDivByZero();
-    if (`b` == -1 && `a` == 2147483647) raiseOverflow();
-    return Math.floor(`a` / `b`);
-  """
-
-proc modInt(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    if (`b` == 0) raiseDivByZero();
-    if (`b` == -1 && `a` == 2147483647) raiseOverflow();
-    return Math.floor(`a` % `b`);
-  """
-
-
-
-proc addInt64(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` + `b`;
-    if (result > 9223372036854775807
-    || result < -9223372036854775808) raiseOverflow();
-    return result;
-  """
-
-proc subInt64(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` - `b`;
-    if (result > 9223372036854775807
-    || result < -9223372036854775808) raiseOverflow();
-    return result;
-  """
-
-proc mulInt64(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    var result = `a` * `b`;
-    if (result > 9223372036854775807
-    || result < -9223372036854775808) raiseOverflow();
-    return result;
-  """
-
-proc divInt64(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    if (`b` == 0) raiseDivByZero();
-    if (`b` == -1 && `a` == 9223372036854775807) raiseOverflow();
-    return Math.floor(`a` / `b`);
-  """
-
-proc modInt64(a, b: int): int {.pure, compilerproc.} =
-  asm """
-    if (`b` == 0) raiseDivByZero();
-    if (`b` == -1 && `a` == 9223372036854775807) raiseOverflow();
-    return Math.floor(`a` % `b`);
-  """
-
-proc nimMin(a, b: int): int {.compilerproc.} = return if a <= b: a else: b
-proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b
-
-proc internalAssert(file: cstring, line: int) {.pure, compilerproc.} =
-  var
-    e: ref EAssertionFailed
-  new(e)
-  asm """`e`.message = "[Assertion failure] file: "+`file`+", line: "+`line`"""
-  raise e
-
-include hti
-
-proc isFatPointer(ti: PNimType): bool =
-  # This has to be consistent with the code generator!
-  return ti.base.kind notin {tyRecord, tyRecordConstr, tyObject,
-    tyArray, tyArrayConstr, tyPureObject, tyTuple,
-    tyEmptySet, tyOpenArray, tySet, tyVar, tyRef, tyPtr}
-
-proc NimCopy(x: pointer, ti: PNimType): pointer {.compilerproc.}
-
-proc NimCopyAux(dest, src: Pointer, n: ptr TNimNode) {.exportc.} =
-  case n.kind
-  of nkNone: assert(false)
-  of nkSlot:
-    asm "`dest`[`n`.offset] = NimCopy(`src`[`n`.offset], `n`.typ);"
-  of nkList:
-    for i in 0..n.len-1:
-      NimCopyAux(dest, src, n.sons[i])
-  of nkCase:
-    asm """
-      `dest`[`n`.offset] = NimCopy(`src`[`n`.offset], `n`.typ);
-      for (var i = 0; i < `n`.sons.length; ++i) {
-        NimCopyAux(`dest`, `src`, `n`.sons[i][1]);
-      }
-    """
-
-proc NimCopy(x: pointer, ti: PNimType): pointer =
-  case ti.kind
-  of tyPtr, tyRef, tyVar, tyNil:
-    if not isFatPointer(ti):
-      result = x
-    else:
-      asm """
-        `result` = [null, 0];
-        `result`[0] = `x`[0];
-        `result`[1] = `x`[1];
-      """
-  of tyEmptySet, tySet:
-    asm """
-      `result` = {};
-      for (var key in `x`) { `result`[key] = `x`[key]; }
-    """
-  of tyPureObject, tyTuple, tyObject:
-    if ti.base != nil: result = NimCopy(x, ti.base)
-    elif ti.kind == tyObject:
-      asm "`result` = {m_type: `ti`};"
-    else:
-      asm "`result` = {};"
-    NimCopyAux(result, x, ti.node)
-  of tySequence, tyArrayConstr, tyOpenArray, tyArray:
-    asm """
-      `result` = new Array(`x`.length);
-      for (var i = 0; i < `x`.length; ++i) {
-        `result`[i] = NimCopy(`x`[i], `ti`.base);
-      }
-    """
-  of tyString:
-    asm "`result` = `x`.slice(0);"
-  else:
-    result = x
-
-
-proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
-                 pure, compilerproc.} =
-  # types are fake
-  asm """
-    var result = new Array(`len`);
-    for (var i = 0; i < `len`; ++i) result[i] = NimCopy(`value`, `typ`);
-    return result;
-  """
-
-proc chckIndx(i, a, b: int): int {.compilerproc.} =
-  if i >= a and i <= b: return i
-  else: raiseIndexError()
-
-proc chckRange(i, a, b: int): int {.compilerproc.} =
-  if i >= a and i <= b: return i
-  else: raiseRangeError()
-
-proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
-  # checks if obj is of type subclass:
-  var x = obj
-  if x == subclass: return # optimized fast path
-  while x != subclass:
-    if x == nil:
-      raise newException(EInvalidObjectConversion, "invalid object conversion")
-    x = x.base
-
-{.pop.}
-
-#proc AddU($1, $2)
-#SubU($1, $2)
-#MulU($1, $2)
-#DivU($1, $2)
-#ModU($1, $2)
-#AddU64($1, $2)
-#SubU64($1, $2)
-#MulU64($1, $2)
-#DivU64($1, $2)
-#ModU64($1, $2)
-#LeU($1, $2)
-#LtU($1, $2)
-#LeU64($1, $2)
-#LtU64($1, $2)
-#Ze($1)
-#Ze64($1)
-#ToU8($1)
-#ToU16($1)
-#ToU32($1)
-
-#NegInt($1)
-#NegInt64($1)
-#AbsInt($1)
-#AbsInt64($1)
diff --git a/lib/system/embedded.nim b/lib/system/embedded.nim
new file mode 100644
index 000000000..ea6776f58
--- /dev/null
+++ b/lib/system/embedded.nim
@@ -0,0 +1,61 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+# Bare-bones implementation of some things for embedded targets.
+
+proc chckIndx(i, a, b: int): int {.inline, compilerproc.}
+proc chckRange(i, a, b: int): int {.inline, compilerproc.}
+proc chckRangeF(x, a, b: float): float {.inline, compilerproc.}
+proc chckNil(p: pointer) {.inline, compilerproc.}
+
+proc nimFrame(s: PFrame) {.compilerRtl, inl, exportc: "nimFrame".} = discard
+proc popFrame {.compilerRtl, inl.} = discard
+
+proc setFrame(s: PFrame) {.compilerRtl, inl.} = discard
+when not gotoBasedExceptions:
+  proc pushSafePoint(s: PSafePoint) {.compilerRtl, inl.} = discard
+  proc popSafePoint {.compilerRtl, inl.} = discard
+proc pushCurrentException(e: ref Exception) {.compilerRtl, inl.} = discard
+proc popCurrentException {.compilerRtl, inl.} = discard
+
+# some platforms have native support for stack traces:
+const
+  nativeStackTraceSupported = false
+  hasSomeStackTrace = false
+
+proc quitOrDebug() {.noreturn, importc: "abort", header: "<stdlib.h>", nodecl.}
+
+proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
+  sysFatal(ReraiseDefect, "exception handling is not available")
+
+proc raiseExceptionEx(e: sink(ref Exception), ename, procname, filename: cstring,
+                      line: int) {.compilerRtl.} =
+  sysFatal(ReraiseDefect, "exception handling is not available")
+
+proc reraiseException() {.compilerRtl.} =
+  sysFatal(ReraiseDefect, "no exception to reraise")
+
+proc writeStackTrace() = discard
+
+proc unsetControlCHook() = discard
+proc setControlCHook(hook: proc () {.noconv.}) = discard
+
+proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
+  sysFatal(ReraiseDefect, "exception handling is not available")
+
+when gotoBasedExceptions:
+  var nimInErrorMode {.threadvar.}: bool
+
+  proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} =
+    result = addr(nimInErrorMode)
+
+  proc nimTestErrorFlag() {.compilerRtl.} =
+    if nimInErrorMode:
+      sysFatal(ReraiseDefect, "exception handling is not available")
diff --git a/lib/system/exceptions.nim b/lib/system/exceptions.nim
new file mode 100644
index 000000000..63588f858
--- /dev/null
+++ b/lib/system/exceptions.nim
@@ -0,0 +1,122 @@
+## Exception and effect types used in Nim code.
+
+type
+  TimeEffect* = object of RootEffect   ## Time effect.
+  IOEffect* = object of RootEffect     ## IO effect.
+  ReadIOEffect* = object of IOEffect   ## Effect describing a read IO operation.
+  WriteIOEffect* = object of IOEffect  ## Effect describing a write IO operation.
+  ExecIOEffect* = object of IOEffect   ## Effect describing an executing IO operation.
+
+type
+  IOError* = object of CatchableError ## \
+    ## Raised if an IO error occurred.
+  EOFError* = object of IOError ## \
+    ## Raised if an IO "end of file" error occurred.
+  OSError* = object of CatchableError ## \
+    ## Raised if an operating system service failed.
+    errorCode*: int32 ## OS-defined error code describing this error.
+  LibraryError* = object of OSError ## \
+    ## Raised if a dynamic library could not be loaded.
+  ResourceExhaustedError* = object of CatchableError ## \
+    ## Raised if a resource request could not be fulfilled.
+  ArithmeticDefect* = object of Defect ## \
+    ## Raised if any kind of arithmetic error occurred.
+  DivByZeroDefect* = object of ArithmeticDefect ## \
+    ## Raised for runtime integer divide-by-zero errors.
+
+  OverflowDefect* = object of ArithmeticDefect ## \
+    ## Raised for runtime integer overflows.
+    ##
+    ## This happens for calculations whose results are too large to fit in the
+    ## provided bits.
+  AccessViolationDefect* = object of Defect ## \
+    ## Raised for invalid memory access errors
+  AssertionDefect* = object of Defect ## \
+    ## Raised when assertion is proved wrong.
+    ##
+    ## Usually the result of using the `assert() template
+    ## <assertions.html#assert.t,untyped,string>`_.
+  ValueError* = object of CatchableError ## \
+    ## Raised for string and object conversion errors.
+  KeyError* = object of ValueError ## \
+    ## Raised if a key cannot be found in a table.
+    ##
+    ## Mostly used by the `tables <tables.html>`_ module, it can also be raised
+    ## by other collection modules like `sets <sets.html>`_ or `strtabs
+    ## <strtabs.html>`_.
+  OutOfMemDefect* = object of Defect ## \
+    ## Raised for unsuccessful attempts to allocate memory.
+  IndexDefect* = object of Defect ## \
+    ## Raised if an array index is out of bounds.
+
+  FieldDefect* = object of Defect ## \
+    ## Raised if a record field is not accessible because its discriminant's
+    ## value does not fit.
+  RangeDefect* = object of Defect ## \
+    ## Raised if a range check error occurred.
+  StackOverflowDefect* = object of Defect ## \
+    ## Raised if the hardware stack used for subroutine calls overflowed.
+  ReraiseDefect* = object of Defect ## \
+    ## Raised if there is no exception to reraise.
+  ObjectAssignmentDefect* = object of Defect ## \
+    ## Raised if an object gets assigned to its parent's object.
+  ObjectConversionDefect* = object of Defect ## \
+    ## Raised if an object is converted to an incompatible object type.
+    ## You can use `of` operator to check if conversion will succeed.
+  FloatingPointDefect* = object of Defect ## \
+    ## Base class for floating point exceptions.
+  FloatInvalidOpDefect* = object of FloatingPointDefect ## \
+    ## Raised by invalid operations according to IEEE.
+    ##
+    ## Raised by `0.0/0.0`, for example.
+  FloatDivByZeroDefect* = object of FloatingPointDefect ## \
+    ## Raised by division by zero.
+    ##
+    ## Divisor is zero and dividend is a finite nonzero number.
+  FloatOverflowDefect* = object of FloatingPointDefect ## \
+    ## Raised for overflows.
+    ##
+    ## The operation produced a result that exceeds the range of the exponent.
+  FloatUnderflowDefect* = object of FloatingPointDefect ## \
+    ## Raised for underflows.
+    ##
+    ## The operation produced a result that is too small to be represented as a
+    ## normal number.
+  FloatInexactDefect* = object of FloatingPointDefect ## \
+    ## Raised for inexact results.
+    ##
+    ## The operation produced a result that cannot be represented with infinite
+    ## precision -- for example: `2.0 / 3.0, log(1.1)`
+    ##
+    ## **Note**: Nim currently does not detect these!
+  DeadThreadDefect* = object of Defect ## \
+    ## Raised if it is attempted to send a message to a dead thread.
+  NilAccessDefect* = object of Defect ## \
+    ## Raised on dereferences of `nil` pointers.
+    ##
+    ## This is only raised if the `segfaults module <segfaults.html>`_ was imported!
+
+when not defined(nimPreviewSlimSystem):
+  type
+    ArithmeticError* {.deprecated: "See corresponding Defect".} = ArithmeticDefect
+    DivByZeroError* {.deprecated: "See corresponding Defect".} = DivByZeroDefect
+    OverflowError* {.deprecated: "See corresponding Defect".} = OverflowDefect
+    AccessViolationError* {.deprecated: "See corresponding Defect".} = AccessViolationDefect
+    AssertionError* {.deprecated: "See corresponding Defect".} = AssertionDefect
+    OutOfMemError* {.deprecated: "See corresponding Defect".} = OutOfMemDefect
+    IndexError* {.deprecated: "See corresponding Defect".} = IndexDefect
+
+    FieldError* {.deprecated: "See corresponding Defect".} = FieldDefect
+    RangeError* {.deprecated: "See corresponding Defect".} = RangeDefect
+    StackOverflowError* {.deprecated: "See corresponding Defect".} = StackOverflowDefect
+    ReraiseError* {.deprecated: "See corresponding Defect".} = ReraiseDefect
+    ObjectAssignmentError* {.deprecated: "See corresponding Defect".} = ObjectAssignmentDefect
+    ObjectConversionError* {.deprecated: "See corresponding Defect".} = ObjectConversionDefect
+    FloatingPointError* {.deprecated: "See corresponding Defect".} = FloatingPointDefect
+    FloatInvalidOpError* {.deprecated: "See corresponding Defect".} = FloatInvalidOpDefect
+    FloatDivByZeroError* {.deprecated: "See corresponding Defect".} = FloatDivByZeroDefect
+    FloatOverflowError* {.deprecated: "See corresponding Defect".} = FloatOverflowDefect
+    FloatUnderflowError* {.deprecated: "See corresponding Defect".} = FloatUnderflowDefect
+    FloatInexactError* {.deprecated: "See corresponding Defect".} = FloatInexactDefect
+    DeadThreadError* {.deprecated: "See corresponding Defect".} = DeadThreadDefect
+    NilAccessError* {.deprecated: "See corresponding Defect".} = NilAccessDefect
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 4d7b41da2..dae5c4a4a 100755..100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -1,286 +1,705 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
+# Exception handling code. Carefully coded so that tiny programs which do not
+# use the heap (and nor exceptions) do not include the GC or memory allocator.
 
-# Exception handling code. This is difficult because it has
-# to work if there is no more memory. Do not use ``sprintf``, etc. as they are
-# unsafe!
+import std/private/miscdollars
+import stacktraces
 
-when not defined(windows) or not defined(guiapp):
-  proc writeToStdErr(msg: CString) = write(stdout, msg)
+const noStacktraceAvailable = "No stack traceback available\n"
+
+var
+  errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], benign,
+                                            nimcall.})
+    ## Function that will be called
+    ## instead of `stdmsg.write` when printing stacktrace.
+    ## Unstable API.
+
+when defined(windows):
+  proc GetLastError(): int32 {.header: "<windows.h>", nodecl.}
+  const ERROR_BAD_EXE_FORMAT = 193
 
+when not defined(windows) or not defined(guiapp):
+  proc writeToStdErr(msg: cstring) = rawWrite(cstderr, msg)
+  proc writeToStdErr(msg: cstring, length: int) =
+    rawWriteString(cstderr, msg, length)
 else:
-  proc MessageBoxA(hWnd: cint, lpText, lpCaption: cstring, uType: int): int32 {.
+  proc MessageBoxA(hWnd: pointer, lpText, lpCaption: cstring, uType: int): int32 {.
     header: "<windows.h>", nodecl.}
+  proc writeToStdErr(msg: cstring) =
+    discard MessageBoxA(nil, msg, nil, 0)
+  proc writeToStdErr(msg: cstring, length: int) =
+    discard MessageBoxA(nil, msg, nil, 0)
+
+proc writeToStdErr(msg: string) {.inline.} =
+  # fix bug #13115: handles correctly '\0' unlike default implicit conversion to cstring
+  writeToStdErr(msg.cstring, msg.len)
+
+proc showErrorMessage(data: cstring, length: int) {.gcsafe, raises: [].} =
+  var toWrite = true
+  if errorMessageWriter != nil:
+    try:
+      errorMessageWriter($data)
+      toWrite = false
+    except:
+      discard
+  if toWrite:
+    when defined(genode):
+      # stderr not available by default, use the LOG session
+      echo data
+    else:
+      writeToStdErr(data, length)
 
-  proc writeToStdErr(msg: CString) =
-    discard MessageBoxA(0, msg, nil, 0)
+proc showErrorMessage2(data: string) {.inline.} =
+  showErrorMessage(data.cstring, data.len)
 
-proc raiseException(e: ref E_Base, ename: CString) {.compilerproc.}
-proc reraiseException() {.compilerproc.}
+proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.}
+proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.}
+proc chckRangeF(x, a, b: float): float {.inline, compilerproc, benign.}
+proc chckNil(p: pointer) {.noinline, compilerproc, benign.}
 
-proc registerSignalHandler() {.compilerproc.}
+type
+  GcFrame = ptr GcFrameHeader
+  GcFrameHeader {.compilerproc.} = object
+    len: int
+    prev: ptr GcFrameHeader
 
-proc chckIndx(i, a, b: int): int {.inline, compilerproc.}
-proc chckRange(i, a, b: int): int {.inline, compilerproc.}
-proc chckRangeF(x, a, b: float): float {.inline, compilerproc.}
-proc chckNil(p: pointer) {.inline, compilerproc.}
+when NimStackTraceMsgs:
+  var frameMsgBuf* {.threadvar.}: string
 
-type
-  PSafePoint = ptr TSafePoint
-  TSafePoint {.compilerproc, final.} = object
-    prev: PSafePoint # points to next safe point ON THE STACK
-    exc: ref E_Base
-    status: int
-    context: C_JmpBuf
+when not defined(nimV2):
+  var
+    framePtr {.threadvar.}: PFrame
 
 var
-  excHandler {.compilerproc.}: PSafePoint = nil
-    # list of exception handlers
-    # a global variable for the root of all try blocks
+  currException {.threadvar.}: ref Exception
+
+when not gotoBasedExceptions:
+  var
+    excHandler {.threadvar.}: PSafePoint
+      # list of exception handlers
+      # a global variable for the root of all try blocks
+    gcFramePtr {.threadvar.}: GcFrame
+
+when gotoBasedExceptions:
+  type
+    FrameState = tuple[framePtr: PFrame,
+                      currException: ref Exception]
+else:
+  type
+    FrameState = tuple[gcFramePtr: GcFrame, framePtr: PFrame,
+                      excHandler: PSafePoint, currException: ref Exception]
 
-proc reraiseException() =
-  if excHandler == nil:
-    raise newException(ENoExceptionToReraise, "no exception to reraise")
+proc getFrameState*(): FrameState {.compilerRtl, inl.} =
+  when gotoBasedExceptions:
+    return (framePtr, currException)
   else:
-    c_longjmp(excHandler.context, 1)
+    return (gcFramePtr, framePtr, excHandler, currException)
 
-type
-  PFrame = ptr TFrame
-  TFrame {.importc, nodecl, final.} = object
-    prev: PFrame
-    procname: CString
-    line: int # current line number
-    filename: CString
-    len: int  # length of slots (when not debugging always zero)
+proc setFrameState*(state: FrameState) {.compilerRtl, inl.} =
+  when gotoBasedExceptions:
+    framePtr = state.framePtr
+    currException = state.currException
+  else:
+    gcFramePtr = state.gcFramePtr
+    framePtr = state.framePtr
+    excHandler = state.excHandler
+    currException = state.currException
 
-var
-  buf: string       # cannot be allocated on the stack!
-  assertBuf: string # we need a different buffer for
-                    # assert, as it raises an exception and
-                    # exception handler needs the buffer too
+proc getFrame*(): PFrame {.compilerRtl, inl.} = framePtr
+
+proc popFrame {.compilerRtl, inl.} =
+  framePtr = framePtr.prev
 
-  framePtr {.exportc.}: PFrame
+when false:
+  proc popFrameOfAddr(s: PFrame) {.compilerRtl.} =
+    var it = framePtr
+    if it == s:
+      framePtr = framePtr.prev
+    else:
+      while it != nil:
+        if it == s:
+          framePtr = it.prev
+          break
+        it = it.prev
+
+proc setFrame*(s: PFrame) {.compilerRtl, inl.} =
+  framePtr = s
+
+when not gotoBasedExceptions:
+  proc getGcFrame*(): GcFrame {.compilerRtl, inl.} = gcFramePtr
+  proc popGcFrame*() {.compilerRtl, inl.} = gcFramePtr = gcFramePtr.prev
+  proc setGcFrame*(s: GcFrame) {.compilerRtl, inl.} = gcFramePtr = s
+  proc pushGcFrame*(s: GcFrame) {.compilerRtl, inl.} =
+    s.prev = gcFramePtr
+    zeroMem(cast[pointer](cast[int](s)+%sizeof(GcFrameHeader)), s.len*sizeof(pointer))
+    gcFramePtr = s
+
+  proc pushSafePoint(s: PSafePoint) {.compilerRtl, inl.} =
+    s.prev = excHandler
+    excHandler = s
+
+  proc popSafePoint {.compilerRtl, inl.} =
+    excHandler = excHandler.prev
+
+proc pushCurrentException(e: sink(ref Exception)) {.compilerRtl, inl.} =
+  e.up = currException
+  currException = e
+  #showErrorMessage2 "A"
+
+proc popCurrentException {.compilerRtl, inl.} =
+  currException = currException.up
+  #showErrorMessage2 "B"
+
+proc popCurrentExceptionEx(id: uint) {.compilerRtl.} =
+  discard "only for bootstrapping compatbility"
+
+proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
+  currException = e
+
+# some platforms have native support for stack traces:
+const
+  nativeStackTraceSupported = (defined(macosx) or defined(linux)) and
+                              not NimStackTrace
+  hasSomeStackTrace = NimStackTrace or defined(nimStackTraceOverride) or
+    (defined(nativeStackTrace) and nativeStackTraceSupported)
+
+
+when defined(nativeStacktrace) and nativeStackTraceSupported:
+  type
+    TDl_info {.importc: "Dl_info", header: "<dlfcn.h>",
+               final, pure.} = object
+      dli_fname: cstring
+      dli_fbase: pointer
+      dli_sname: cstring
+      dli_saddr: pointer
+
+  proc backtrace(symbols: ptr pointer, size: int): int {.
+    importc: "backtrace", header: "<execinfo.h>".}
+  proc dladdr(addr1: pointer, info: ptr TDl_info): int {.
+    importc: "dladdr", header: "<dlfcn.h>".}
+
+  when not hasThreadSupport:
+    var
+      tempAddresses: array[maxStackTraceLines, pointer] # should not be alloc'd on stack
+      tempDlInfo: TDl_info
+
+  proc auxWriteStackTraceWithBacktrace(s: var string) =
+    when hasThreadSupport:
+      var
+        tempAddresses: array[maxStackTraceLines, pointer] # but better than a threadvar
+        tempDlInfo: TDl_info
+    # This is allowed to be expensive since it only happens during crashes
+    # (but this way you don't need manual stack tracing)
+    var size = backtrace(cast[ptr pointer](addr(tempAddresses)),
+                         len(tempAddresses))
+    var enabled = false
+    for i in 0..size-1:
+      var dlresult = dladdr(tempAddresses[i], addr(tempDlInfo))
+      if enabled:
+        if dlresult != 0:
+          var oldLen = s.len
+          add(s, tempDlInfo.dli_fname)
+          if tempDlInfo.dli_sname != nil:
+            for k in 1..max(1, 25-(s.len-oldLen)): add(s, ' ')
+            add(s, tempDlInfo.dli_sname)
+        else:
+          add(s, '?')
+        add(s, "\n")
+      else:
+        if dlresult != 0 and tempDlInfo.dli_sname != nil and
+            c_strcmp(tempDlInfo.dli_sname, "signalHandler") == 0'i32:
+          # Once we're past signalHandler, we're at what the user is
+          # interested in
+          enabled = true
+
+when hasSomeStackTrace and not hasThreadSupport:
+  var
+    tempFrames: array[maxStackTraceLines, PFrame] # should not be alloc'd on stack
 
-  tempFrames: array [0..127, PFrame] # cannot be allocated on the stack!
-  
-  stackTraceNewLine* = "\n" ## undocumented feature
+template reraisedFrom(z): untyped =
+  StackTraceEntry(procname: nil, line: z, filename: nil)
 
-proc auxWriteStackTrace(f: PFrame, s: var string) =
-  const 
-    firstCalls = 32
+proc auxWriteStackTrace(f: PFrame; s: var seq[StackTraceEntry]) =
   var
     it = f
     i = 0
-    total = 0
-  while it != nil and i <= high(tempFrames)-(firstCalls-1):
-    # the (-1) is for a nil entry that marks where the '...' should occur
-    tempFrames[i] = it
+  while it != nil:
     inc(i)
-    inc(total)
     it = it.prev
-  var b = it
+  var last = i-1
+  when true: # not defined(gcDestructors):
+    if s.len == 0:
+      s = newSeq[StackTraceEntry](i)
+    else:
+      last = s.len + i - 1
+      s.setLen(last+1)
+  it = f
   while it != nil:
-    inc(total)
+    s[last] = StackTraceEntry(procname: it.procname,
+                              line: it.line,
+                              filename: it.filename)
+    when NimStackTraceMsgs:
+      let first = if it.prev == nil: 0 else: it.prev.frameMsgLen
+      if it.frameMsgLen > first:
+        s[last].frameMsg.setLen(it.frameMsgLen - first)
+        # somehow string slicing not available here
+        for i in first .. it.frameMsgLen-1:
+          s[last].frameMsg[i-first] = frameMsgBuf[i]
     it = it.prev
-  for j in 1..total-i-(firstCalls-1): 
-    if b != nil: b = b.prev
-  if total != i:
-    tempFrames[i] = nil
-    inc(i)
-  while b != nil and i <= high(tempFrames):
-    tempFrames[i] = b
-    inc(i)
-    b = b.prev
-  for j in countdown(i-1, 0):
-    if tempFrames[j] == nil: 
-      add(s, "(")
-      add(s, $(total-i-1))
-      add(s, " calls omitted) ...")
+    dec last
+
+template addFrameEntry(s: var string, f: StackTraceEntry|PFrame) =
+  var oldLen = s.len
+  s.toLocation(f.filename, f.line, 0)
+  for k in 1..max(1, 25-(s.len-oldLen)): add(s, ' ')
+  add(s, f.procname)
+  when NimStackTraceMsgs:
+    when typeof(f) is StackTraceEntry:
+      add(s, f.frameMsg)
     else:
-      add(s, $tempFrames[j].procname)
-      if tempFrames[j].line > 0:
-        add(s, ", line: ")
-        add(s, $tempFrames[j].line)
-    add(s, stackTraceNewLine)
+      var first = if f.prev == nil: 0 else: f.prev.frameMsgLen
+      for i in first..<f.frameMsgLen: add(s, frameMsgBuf[i])
+  add(s, "\n")
 
-proc rawWriteStackTrace(s: var string) =
-  if framePtr == nil:
-    add(s, "No stack traceback available")
-    add(s, stackTraceNewLine)
+proc `$`(stackTraceEntries: seq[StackTraceEntry]): string =
+  when defined(nimStackTraceOverride):
+    let s = addDebuggingInfo(stackTraceEntries)
   else:
-    add(s, "Traceback (most recent call last)")
-    add(s, stackTraceNewLine)
-    auxWriteStackTrace(framePtr, s)
+    let s = stackTraceEntries
+
+  result = newStringOfCap(2000)
+  for i in 0 .. s.len-1:
+    if s[i].line == reraisedFromBegin: result.add "[[reraised from:\n"
+    elif s[i].line == reraisedFromEnd: result.add "]]\n"
+    else: addFrameEntry(result, s[i])
+
+when hasSomeStackTrace:
+
+  proc auxWriteStackTrace(f: PFrame, s: var string) =
+    when hasThreadSupport:
+      var
+        tempFrames: array[maxStackTraceLines, PFrame] # but better than a threadvar
+    const
+      firstCalls = 32
+    var
+      it = f
+      i = 0
+      total = 0
+    # setup long head:
+    while it != nil and i <= high(tempFrames)-firstCalls:
+      tempFrames[i] = it
+      inc(i)
+      inc(total)
+      it = it.prev
+    # go up the stack to count 'total':
+    var b = it
+    while it != nil:
+      inc(total)
+      it = it.prev
+    var skipped = 0
+    if total > len(tempFrames):
+      # skip N
+      skipped = total-i-firstCalls+1
+      for j in 1..skipped:
+        if b != nil: b = b.prev
+      # create '...' entry:
+      tempFrames[i] = nil
+      inc(i)
+    # setup short tail:
+    while b != nil and i <= high(tempFrames):
+      tempFrames[i] = b
+      inc(i)
+      b = b.prev
+    for j in countdown(i-1, 0):
+      if tempFrames[j] == nil:
+        add(s, "(")
+        add(s, $skipped)
+        add(s, " calls omitted) ...\n")
+      else:
+        addFrameEntry(s, tempFrames[j])
 
-proc quitOrDebug() {.inline.} =
-  when not defined(endb):
-    quit(1)
-  else:
-    endbStep() # call the debugger
-
-proc raiseException(e: ref E_Base, ename: CString) =
-  GC_disable() # a bad thing is an error in the GC while raising an exception
-  e.name = ename
-  if excHandler != nil:
-    excHandler.exc = e
-    c_longjmp(excHandler.context, 1)
-  else:
-    if not isNil(buf):
-      setLen(buf, 0)
-      rawWriteStackTrace(buf)
-      if e.msg != nil and e.msg[0] != '\0':
-        add(buf, "Error: unhandled exception: ")
-        add(buf, $e.msg)
+  proc stackTraceAvailable*(): bool
+
+  proc rawWriteStackTrace(s: var string) =
+    when defined(nimStackTraceOverride):
+      add(s, "Traceback (most recent call last, using override)\n")
+      auxWriteStackTraceWithOverride(s)
+    elif NimStackTrace:
+      if framePtr == nil:
+        add(s, noStacktraceAvailable)
       else:
-        add(buf, "Error: unhandled exception")
-      add(buf, " [")
-      add(buf, $ename)
-      add(buf, "]\n")
-      writeToStdErr(buf)
+        add(s, "Traceback (most recent call last)\n")
+        auxWriteStackTrace(framePtr, s)
+    elif defined(nativeStackTrace) and nativeStackTraceSupported:
+      add(s, "Traceback from system (most recent call last)\n")
+      auxWriteStackTraceWithBacktrace(s)
     else:
-      writeToStdErr(ename)
-    quitOrDebug()
-  GC_enable()
+      add(s, noStacktraceAvailable)
 
-var
-  gAssertionFailed: ref EAssertionFailed
-
-proc internalAssert(file: cstring, line: int, cond: bool) {.compilerproc.} =
-  if not cond:
-    #c_fprintf(c_stdout, "Assertion failure: file %s line %ld\n", file, line)
-    #quit(1)
-    GC_disable() # BUGFIX: `$` allocates a new string object!
-    if not isNil(assertBuf):
-      # BUGFIX: when debugging the GC, assertBuf may be nil
-      setLen(assertBuf, 0)
-      add(assertBuf, "[Assertion failure] file: ")
-      add(assertBuf, file)
-      add(assertBuf, " line: ")
-      add(assertBuf, $line)
-      add(assertBuf, "\n")
-      gAssertionFailed.msg = assertBuf
-    GC_enable()
-    if gAssertionFailed != nil:
-      raise gAssertionFailed
+  proc rawWriteStackTrace(s: var seq[StackTraceEntry]) =
+    when defined(nimStackTraceOverride):
+      auxWriteStackTraceWithOverride(s)
+    elif NimStackTrace:
+      auxWriteStackTrace(framePtr, s)
     else:
-      c_fprintf(c_stdout, "Assertion failure: file %s line %ld\n", file, line)
-      quit(1)
-
-proc WriteStackTrace() =
-  var s = ""
-  rawWriteStackTrace(s)
-  writeToStdErr(s)
-
-#proc stackTraceWrapper {.noconv.} =
-#  writeStackTrace()
+      s = @[]
+
+  proc stackTraceAvailable(): bool =
+    when defined(nimStackTraceOverride):
+      result = true
+    elif NimStackTrace:
+      if framePtr == nil:
+        result = false
+      else:
+        result = true
+    elif defined(nativeStackTrace) and nativeStackTraceSupported:
+      result = true
+    else:
+      result = false
+else:
+  proc stackTraceAvailable*(): bool = result = false
+
+var onUnhandledException*: (proc (errorMsg: string) {.
+  nimcall, gcsafe.}) ## Set this error \
+  ## handler to override the existing behaviour on an unhandled exception.
+  ##
+  ## The default is to write a stacktrace to `stderr` and then call `quit(1)`.
+  ## Unstable API.
+
+proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy, gcsafe.} =
+  when hasSomeStackTrace:
+    var buf = newStringOfCap(2000)
+    if e.trace.len == 0:
+      rawWriteStackTrace(buf)
+    else:
+      var trace = $e.trace
+      add(buf, trace)
+      {.gcsafe.}:
+        `=destroy`(trace)
+    add(buf, "Error: unhandled exception: ")
+    add(buf, e.msg)
+    add(buf, " [")
+    add(buf, $e.name)
+    add(buf, "]\n")
+
+    if onUnhandledException != nil:
+      onUnhandledException(buf)
+    else:
+      showErrorMessage2(buf)
+    {.gcsafe.}:
+      `=destroy`(buf)
+  else:
+    # ugly, but avoids heap allocations :-)
+    template xadd(buf, s, slen) =
+      if L + slen < high(buf):
+        copyMem(addr(buf[L]), (when s is cstring: s else: cstring(s)), slen)
+        inc L, slen
+    template add(buf, s) =
+      xadd(buf, s, s.len)
+    var buf: array[0..2000, char]
+    var L = 0
+    if e.trace.len != 0:
+      var trace = $e.trace
+      add(buf, trace)
+      {.gcsafe.}:
+        `=destroy`(trace)
+    add(buf, "Error: unhandled exception: ")
+    add(buf, e.msg)
+    add(buf, " [")
+    xadd(buf, e.name, e.name.len)
+    add(buf, "]\n")
+    if onUnhandledException != nil:
+      onUnhandledException($cast[cstring](buf.addr))
+    else:
+      showErrorMessage(cast[cstring](buf.addr), L)
+
+proc reportUnhandledError(e: ref Exception) {.nodestroy, gcsafe.} =
+  if unhandledExceptionHook != nil:
+    unhandledExceptionHook(e)
+  when hostOS != "any":
+    reportUnhandledErrorAux(e)
+
+when not gotoBasedExceptions:
+  proc nimLeaveFinally() {.compilerRtl.} =
+    when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
+      {.emit: "throw;".}
+    else:
+      if excHandler != nil:
+        c_longjmp(excHandler.context, 1)
+      else:
+        reportUnhandledError(currException)
+        rawQuit(1)
+
+when gotoBasedExceptions:
+  var nimInErrorMode {.threadvar.}: bool
+
+  proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} =
+    result = addr(nimInErrorMode)
+
+  proc nimTestErrorFlag() {.compilerRtl.} =
+    ## This proc must be called before `currException` is destroyed.
+    ## It also must be called at the end of every thread to ensure no
+    ## error is swallowed.
+    if nimInErrorMode and currException != nil:
+      reportUnhandledError(currException)
+      currException = nil
+      rawQuit(1)
+
+proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
+  when defined(nimPanics):
+    if e of Defect:
+      reportUnhandledError(e)
+      rawQuit(1)
+
+  if localRaiseHook != nil:
+    if not localRaiseHook(e): return
+  if globalRaiseHook != nil:
+    if not globalRaiseHook(e): return
+  when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
+    if e == currException:
+      {.emit: "throw;".}
+    else:
+      pushCurrentException(e)
+      {.emit: "throw `e`;".}
+  elif quirkyExceptions or gotoBasedExceptions:
+    pushCurrentException(e)
+    when gotoBasedExceptions:
+      inc nimInErrorMode
+  else:
+    if excHandler != nil:
+      pushCurrentException(e)
+      c_longjmp(excHandler.context, 1)
+    else:
+      reportUnhandledError(e)
+      rawQuit(1)
+
+proc raiseExceptionEx(e: sink(ref Exception), ename, procname, filename: cstring,
+                      line: int) {.compilerRtl, nodestroy.} =
+  if e.name.isNil: e.name = ename
+  when hasSomeStackTrace:
+    when defined(nimStackTraceOverride):
+      if e.trace.len == 0:
+        rawWriteStackTrace(e.trace)
+      else:
+        e.trace.add reraisedFrom(reraisedFromBegin)
+        auxWriteStackTraceWithOverride(e.trace)
+        e.trace.add reraisedFrom(reraisedFromEnd)
+    elif NimStackTrace:
+      if e.trace.len == 0:
+        rawWriteStackTrace(e.trace)
+      elif framePtr != nil:
+        e.trace.add reraisedFrom(reraisedFromBegin)
+        auxWriteStackTrace(framePtr, e.trace)
+        e.trace.add reraisedFrom(reraisedFromEnd)
+  else:
+    if procname != nil and filename != nil:
+      e.trace.add StackTraceEntry(procname: procname, filename: filename, line: line)
+  raiseExceptionAux(e)
 
-#addQuitProc(stackTraceWrapper)
+proc raiseException(e: sink(ref Exception), ename: cstring) {.compilerRtl.} =
+  raiseExceptionEx(e, ename, nil, nil, 0)
 
-var
-  dbgAborting: bool # whether the debugger wants to abort
-
-proc signalHandler(sig: cint) {.exportc: "signalHandler", noconv.} =
-  # print stack trace and quit
-  var s = sig
-  GC_disable()
-  setLen(buf, 0)
-  rawWriteStackTrace(buf)
-
-  if s == SIGINT: add(buf, "SIGINT: Interrupted by Ctrl-C.\n")
-  elif s == SIGSEGV: 
-    add(buf, "SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")
-  elif s == SIGABRT:
-    if dbgAborting: return # the debugger wants to abort
-    add(buf, "SIGABRT: Abnormal termination.\n")
-  elif s == SIGFPE: add(buf, "SIGFPE: Arithmetic error.\n")
-  elif s == SIGILL: add(buf, "SIGILL: Illegal operation.\n")
-  elif s == SIGBUS: 
-    add(buf, "SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
-  else: add(buf, "unknown signal\n")
-  writeToStdErr(buf)
-  dbgAborting = True # play safe here...
-  GC_enable()
-  quit(1) # always quit when SIGABRT
-
-proc registerSignalHandler() =
-  c_signal(SIGINT, signalHandler)
-  c_signal(SIGSEGV, signalHandler)
-  c_signal(SIGABRT, signalHandler)
-  c_signal(SIGFPE, signalHandler)
-  c_signal(SIGILL, signalHandler)
-  c_signal(SIGBUS, signalHandler)
-
-when not defined(noSignalHandler):
-  registerSignalHandler() # call it in initialization section
-# for easier debugging of the GC, this memory is only allocated after the
-# signal handlers have been registered
-new(gAssertionFailed)
-buf = newString(2048)
-assertBuf = newString(2048)
-setLen(buf, 0)
-setLen(assertBuf, 0)
-
-proc raiseRangeError(val: biggestInt) {.compilerproc, noreturn, noinline.} =
-  raise newException(EOutOfRange, "value " & $val & " out of range")
-
-proc raiseIndexError() {.compilerproc, noreturn, noinline.} =
-  raise newException(EInvalidIndex, "index out of bounds")
-
-proc raiseFieldError(f: string) {.compilerproc, noreturn, noinline.} =
-  raise newException(EInvalidField, f & " is not accessible")
-
-proc chckIndx(i, a, b: int): int =
-  if i >= a and i <= b:
-    return i
+proc reraiseException() {.compilerRtl.} =
+  if currException == nil:
+    sysFatal(ReraiseDefect, "no exception to reraise")
   else:
-    raiseIndexError()
-
-proc chckRange(i, a, b: int): int =
-  if i >= a and i <= b:
-    return i
+    when gotoBasedExceptions:
+      inc nimInErrorMode
+    else:
+      raiseExceptionAux(currException)
+
+proc threadTrouble() =
+  # also forward declared, it is 'raises: []' hence the try-except.
+  try:
+    if currException != nil: reportUnhandledError(currException)
+  except:
+    discard
+  rawQuit 1
+
+proc writeStackTrace() =
+  when hasSomeStackTrace:
+    var s = ""
+    rawWriteStackTrace(s)
   else:
-    raiseRangeError(i)
+    let s = noStacktraceAvailable
+  cast[proc (s: string) {.noSideEffect, tags: [], nimcall, raises: [].}](showErrorMessage2)(s)
 
-proc chckRange64(i, a, b: int64): int64 {.compilerproc.} =
-  if i >= a and i <= b:
-    return i
+proc getStackTrace(): string =
+  when hasSomeStackTrace:
+    result = ""
+    rawWriteStackTrace(result)
   else:
-    raiseRangeError(i)
+    result = noStacktraceAvailable
 
-proc chckRangeF(x, a, b: float): float =
-  if x >= a and x <= b:
-    return x
+proc getStackTrace(e: ref Exception): string =
+  if not isNil(e):
+    result = $e.trace
   else:
-    raise newException(EOutOfRange, "value " & $x & " out of range")
-
-proc chckNil(p: pointer) =
-  if p == nil: c_raise(SIGSEGV)
-
-proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
-  # checks if obj is of type subclass:
-  var x = obj
-  if x == subclass: return # optimized fast path
-  while x != subclass:
-    if x == nil:
-      raise newException(EInvalidObjectConversion, "invalid object conversion")
-    x = x.base
-
-proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
-  if a != b:
-    raise newException(EInvalidObjectAssignment, "invalid object assignment")
-
-proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
-  # checks if obj is of type subclass:
-  var x = obj
-  if x == subclass: return true # optimized fast path
-  while x != subclass:
-    if x == nil: return false
-    x = x.base
-  return true
+    result = ""
+
+proc getStackTraceEntries*(e: ref Exception): lent seq[StackTraceEntry] =
+  ## Returns the attached stack trace to the exception `e` as
+  ## a `seq`. This is not yet available for the JS backend.
+  e.trace
+
+proc getStackTraceEntries*(): seq[StackTraceEntry] =
+  ## Returns the stack trace entries for the current stack trace.
+  ## This is not yet available for the JS backend.
+  when hasSomeStackTrace:
+    rawWriteStackTrace(result)
+
+const nimCallDepthLimit {.intdefine.} = 2000
+
+proc callDepthLimitReached() {.noinline.} =
+  writeStackTrace()
+  let msg = "Error: call depth limit reached in a debug build (" &
+      $nimCallDepthLimit & " function calls). You can change it with " &
+      "-d:nimCallDepthLimit=<int> but really try to avoid deep " &
+      "recursions instead.\n"
+  showErrorMessage2(msg)
+  rawQuit(1)
+
+proc nimFrame(s: PFrame) {.compilerRtl, inl, raises: [].} =
+  if framePtr == nil:
+    s.calldepth = 0
+    when NimStackTraceMsgs: s.frameMsgLen = 0
+  else:
+    s.calldepth = framePtr.calldepth+1
+    when NimStackTraceMsgs: s.frameMsgLen = framePtr.frameMsgLen
+  s.prev = framePtr
+  framePtr = s
+  if s.calldepth == nimCallDepthLimit: callDepthLimitReached()
+
+when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
+    not defined(js) and not defined(nimscript) and
+    hostOS != "standalone" and hostOS != "any" and not defined(noCppExceptions) and
+    not quirkyExceptions:
+
+  type
+    StdException {.importcpp: "std::exception", header: "<exception>".} = object
+
+  proc what(ex: StdException): cstring {.importcpp: "((char *)#.what())", nodecl.}
+
+  proc setTerminate(handler: proc() {.noconv.})
+    {.importc: "std::set_terminate", header: "<exception>".}
+
+  setTerminate proc() {.noconv.} =
+    # Remove ourself as a handler, reinstalling the default handler.
+    setTerminate(nil)
+
+    var msg = "Unknown error in unexpected exception handler"
+    try:
+      {.emit: "#if !defined(_MSC_VER) || (_MSC_VER >= 1923)".}
+      raise
+      {.emit: "#endif".}
+    except Exception:
+      msg = currException.getStackTrace() & "Error: unhandled exception: " &
+        currException.msg & " [" & $currException.name & "]"
+    except StdException as e:
+      msg = "Error: unhandled cpp exception: " & $e.what()
+    except:
+      msg = "Error: unhandled unknown cpp exception"
+
+    {.emit: "#if defined(_MSC_VER) && (_MSC_VER < 1923)".}
+    msg = "Error: unhandled unknown cpp exception"
+    {.emit: "#endif".}
+
+    when defined(genode):
+      # stderr not available by default, use the LOG session
+      echo msg
+    else:
+      writeToStdErr msg & "\n"
+
+    rawQuit 1
+
+when not defined(noSignalHandler) and not defined(useNimRtl):
+  type Sighandler = proc (a: cint) {.noconv, benign.}
+    # xxx factor with ansi_c.CSighandlerT, posix.Sighandler
+
+  proc signalHandler(sign: cint) {.exportc: "signalHandler", noconv.} =
+    template processSignal(s, action: untyped) {.dirty.} =
+      if s == SIGINT: action("SIGINT: Interrupted by Ctrl-C.\n")
+      elif s == SIGSEGV:
+        action("SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")
+      elif s == SIGABRT:
+        action("SIGABRT: Abnormal termination.\n")
+      elif s == SIGFPE: action("SIGFPE: Arithmetic error.\n")
+      elif s == SIGILL: action("SIGILL: Illegal operation.\n")
+      elif (when declared(SIGBUS): s == SIGBUS else: false):
+        action("SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
+      else:
+        block platformSpecificSignal:
+          when declared(SIGPIPE):
+            if s == SIGPIPE:
+              action("SIGPIPE: Pipe closed.\n")
+              break platformSpecificSignal
+          action("unknown signal\n")
+
+    # print stack trace and quit
+    when defined(memtracker):
+      logPendingOps()
+    when hasSomeStackTrace:
+      when not usesDestructors: GC_disable()
+      var buf = newStringOfCap(2000)
+      rawWriteStackTrace(buf)
+      processSignal(sign, buf.add) # nice hu? currying a la Nim :-)
+      showErrorMessage2(buf)
+      when not usesDestructors: GC_enable()
+    else:
+      var msg: cstring
+      template asgn(y) =
+        msg = y
+      processSignal(sign, asgn)
+      # xxx use string for msg instead of cstring, and here use showErrorMessage2(msg)
+      # unless there's a good reason to use cstring in signal handler to avoid
+      # using gc?
+      showErrorMessage(msg, msg.len)
+
+    when defined(posix):
+      # reset the signal handler to OS default
+      c_signal(sign, SIG_DFL)
+
+      # re-raise the signal, which will arrive once this handler exit.
+      # this lets the OS perform actions like core dumping and will
+      # also return the correct exit code to the shell.
+      discard c_raise(sign)
+    else:
+      rawQuit(1)
+
+  var SIG_IGN {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler
+
+  proc registerSignalHandler() =
+    # xxx `signal` is deprecated and has many caveats, we should use `sigaction` instead, e.g.
+    # https://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal
+    c_signal(SIGINT, signalHandler)
+    c_signal(SIGSEGV, signalHandler)
+    c_signal(SIGABRT, signalHandler)
+    c_signal(SIGFPE, signalHandler)
+    c_signal(SIGILL, signalHandler)
+    when declared(SIGBUS):
+      c_signal(SIGBUS, signalHandler)
+    when declared(SIGPIPE):
+      when defined(nimLegacySigpipeHandler):
+        c_signal(SIGPIPE, signalHandler)
+      else:
+        c_signal(SIGPIPE, SIG_IGN)
+
+  registerSignalHandler() # call it in initialization section
+
+proc setControlCHook(hook: proc () {.noconv.}) =
+  # ugly cast, but should work on all architectures:
+  when declared(Sighandler):
+    c_signal(SIGINT, cast[Sighandler](hook))
+
+when not defined(noSignalHandler) and not defined(useNimRtl):
+  proc unsetControlCHook() =
+    # proc to unset a hook set by setControlCHook
+    c_signal(SIGINT, signalHandler)
diff --git a/lib/system/fatal.nim b/lib/system/fatal.nim
new file mode 100644
index 000000000..25c05e52d
--- /dev/null
+++ b/lib/system/fatal.nim
@@ -0,0 +1,58 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+{.push profiler: off.}
+
+const
+  gotoBasedExceptions = compileOption("exceptions", "goto")
+  quirkyExceptions = compileOption("exceptions", "quirky")
+
+when hostOS == "standalone":
+  include "$projectpath/panicoverride"
+
+  func sysFatal(exceptn: typedesc[Defect], message: string) {.inline.} =
+    panic(message)
+
+  func sysFatal(exceptn: typedesc[Defect], message, arg: string) {.inline.} =
+    rawoutput(message)
+    panic(arg)
+
+elif quirkyExceptions and not defined(nimscript):
+  import ansi_c
+
+  func name(t: typedesc): string {.magic: "TypeTrait".}
+
+  func sysFatal(exceptn: typedesc[Defect], message, arg: string) {.inline, noreturn.} =
+    when nimvm:
+      # TODO when doAssertRaises works in CT, add a test for it
+      raise (ref exceptn)(msg: message & arg)
+    else:
+      {.noSideEffect.}:
+        writeStackTrace()
+        var buf = newStringOfCap(200)
+        add(buf, "Error: unhandled exception: ")
+        add(buf, message)
+        add(buf, arg)
+        add(buf, " [")
+        add(buf, name exceptn)
+        add(buf, "]\n")
+        cstderr.rawWrite buf
+      rawQuit 1
+
+  func sysFatal(exceptn: typedesc[Defect], message: string) {.inline, noreturn.} =
+    sysFatal(exceptn, message, "")
+
+else:
+  func sysFatal(exceptn: typedesc[Defect], message: string) {.inline, noreturn.} =
+    raise (ref exceptn)(msg: message)
+
+  func sysFatal(exceptn: typedesc[Defect], message, arg: string) {.inline, noreturn.} =
+    raise (ref exceptn)(msg: message & arg)
+
+{.pop.}
diff --git a/lib/system/formatfloat.nim b/lib/system/formatfloat.nim
new file mode 100644
index 000000000..70dd857d5
--- /dev/null
+++ b/lib/system/formatfloat.nim
@@ -0,0 +1,6 @@
+when not defined(nimPreviewSlimSystem):
+  import std/formatfloat
+  export formatfloat
+  {.deprecated: "use `std/formatfloat`".}
+else:
+  {.error: "use `std/formatfloat`".}
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index da8f75768..9289c7f55 100755..100644
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -1,647 +1,911 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-
 #            Garbage Collector
 #
-# The basic algorithm is *Deferrent Reference Counting* with cycle detection.
-# Special care has been taken to avoid recursion as far as possible to avoid
-# stack overflows when traversing deep datastructures. This is comparable to
-# an incremental and generational GC. It should be well-suited for soft real
-# time applications (like games).
-#
-# Future Improvements:
-# * Support for multi-threading. However, locks for the reference counting
-#   might turn out to be too slow.
+# Refcounting + Mark&Sweep. Complex algorithms avoided.
+# Been there, done that, didn't work.
+
+#[
+
+A *cell* is anything that is traced by the GC
+(sequences, refs, strings, closures).
+
+The basic algorithm is *Deferrent Reference Counting* with cycle detection.
+References on the stack are not counted for better performance and easier C
+code generation.
+
+Each cell has a header consisting of a RC and a pointer to its type
+descriptor. However the program does not know about these, so they are placed at
+negative offsets. In the GC code the type `PCell` denotes a pointer
+decremented by the right offset, so that the header can be accessed easily. It
+is extremely important that `pointer` is not confused with a `PCell`.
+
+In Nim the compiler cannot always know if a reference
+is stored on the stack or not. This is caused by var parameters.
+Consider this example:
+
+  ```Nim
+  proc setRef(r: var ref TNode) =
+    new(r)
+
+  proc usage =
+    var
+      r: ref TNode
+    setRef(r) # here we should not update the reference counts, because
+              # r is on the stack
+    setRef(r.left) # here we should update the refcounts!
+  ```
+
+We have to decide at runtime whether the reference is on the stack or not.
+The generated code looks roughly like this:
+
+  ```C
+  void setref(TNode** ref) {
+    unsureAsgnRef(ref, newObj(TNode_TI, sizeof(TNode)))
+  }
+  void usage(void) {
+    setRef(&r)
+    setRef(&r->left)
+  }
+  ```
+
+Note that for systems with a continuous stack (which most systems have)
+the check whether the ref is on the stack is very cheap (only two
+comparisons).
+]#
+
+{.push profiler:off.}
 
 const
   CycleIncrease = 2 # is a multiplicative increase
-  InitialCycleThreshold = 4*1024*1024 # X MB because cycle checking is slow
-  ZctThreshold = 256  # we collect garbage if the ZCT's size
-                      # reaches this threshold
-                      # this seems to be a good value
+  InitialCycleThreshold = when defined(nimCycleBreaker): high(int)
+                          else: 4*1024*1024 # X MB because cycle checking is slow
+  InitialZctThreshold = 500  # we collect garbage if the ZCT's size
+                             # reaches this threshold
+                             # this seems to be a good value
+  withRealTime = defined(useRealtimeGC)
+
+when withRealTime and not declared(getTicks):
+  include "system/timers"
+when defined(memProfiler):
+  proc nimProfile(requestedSize: int) {.benign.}
+
+when hasThreadSupport:
+  import std/sharedlist
 
 const
   rcIncrement = 0b1000 # so that lowest 3 bits are not touched
-  # NOTE: Most colors are currently unused
   rcBlack = 0b000  # cell is colored black; in use or free
   rcGray = 0b001   # possible member of a cycle
   rcWhite = 0b010  # member of a garbage cycle
   rcPurple = 0b011 # possible root of a cycle
-  rcZct = 0b100    # in ZCT
-  rcRed = 0b101    # Candidate cycle undergoing sigma-computation
-  rcOrange = 0b110 # Candidate cycle awaiting epoch boundary
+  ZctFlag = 0b100  # in ZCT
   rcShift = 3      # shift by rcShift to get the reference counter
-  colorMask = 0b111
+  colorMask = 0b011
 type
-  TWalkOp = enum
-    waZctDecRef, waPush, waCycleDecRef
+  WalkOp = enum
+    waMarkGlobal,    # part of the backup/debug mark&sweep
+    waMarkPrecise,   # part of the backup/debug mark&sweep
+    waZctDecRef, waPush
+    #, waDebug
 
-  TFinalizer {.compilerproc.} = proc (self: pointer)
+  Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign, raises: [].}
     # A ref type can have a finalizer that is called before the object's
     # storage is freed.
 
-  TGcStat {.final, pure.} = object
+  GcStat {.final, pure.} = object
     stackScans: int          # number of performed stack scans (for statistics)
     cycleCollections: int    # number of performed full collections
     maxThreshold: int        # max threshold that has been set
     maxStackSize: int        # max stack size
     maxStackCells: int       # max stack cells in ``decStack``
-    cycleTableSize: int      # max entries in cycle table  
-  
-  TGcHeap {.final, pure.} = object # this contains the zero count and
-                                   # non-zero count table
-    zct: TCellSeq            # the zero count table
-    decStack: TCellSeq       # cells in the stack that are to decref again
-    cycleRoots: TCellSet
-    tempStack: TCellSeq      # temporary stack for recursion elimination
-    stat: TGcStat
+    cycleTableSize: int      # max entries in cycle table
+    maxPause: int64          # max measured GC pause in nanoseconds
+
+  GcStack {.final, pure.} = object
+    when nimCoroutines:
+      prev: ptr GcStack
+      next: ptr GcStack
+      maxStackSize: int      # Used to track statistics because we can not use
+                             # GcStat.maxStackSize when multiple stacks exist.
+    bottom: pointer
+
+    when withRealTime or nimCoroutines:
+      pos: pointer           # Used with `withRealTime` only for code clarity, see GC_Step().
+    when withRealTime:
+      bottomSaved: pointer
+
+  GcHeap {.final, pure.} = object # this contains the zero count and
+                                  # non-zero count table
+    stack: GcStack
+    when nimCoroutines:
+      activeStack: ptr GcStack    # current executing coroutine stack.
+    cycleThreshold: int
+    zctThreshold: int
+    when useCellIds:
+      idGenerator: int
+    zct: CellSeq             # the zero count table
+    decStack: CellSeq        # cells in the stack that are to decref again
+    tempStack: CellSeq       # temporary stack for recursion elimination
+    recGcLock: int           # prevent recursion via finalizers; no thread lock
+    when withRealTime:
+      maxPause: Nanos        # max allowed pause in nanoseconds; active if > 0
+    region: MemRegion        # garbage collected region
+    stat: GcStat
+    marked: CellSet
+    additionalRoots: CellSeq # dummy roots for GC_ref/unref
+    when hasThreadSupport:
+      toDispose: SharedList[pointer]
+    gcThreadId: int
 
 var
-  stackBottom: pointer
-  gch: TGcHeap
-  cycleThreshold: int = InitialCycleThreshold
-  recGcLock: int = 0
-    # we use a lock to prevend the garbage collector to be triggered in a
-    # finalizer; the collector should not call itself this way! Thus every
-    # object allocated by a finalizer will not trigger a garbage collection.
-    # This is wasteful but safe. This is a lock against recursive garbage
-    # collection, not a lock for threads!
-
-proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc.}
-  # unsureAsgnRef updates the reference counters only if dest is not on the
-  # stack. It is used by the code generator if it cannot decide wether a
-  # reference is in the stack or not (this can happen for var parameters).
-#proc growObj(old: pointer, newsize: int): pointer {.compilerproc.}
-proc newObj(typ: PNimType, size: int): pointer {.compilerproc.}
-proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.}
-
-proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} =
-  if (c.refcount and rcZct) == 0:
-    c.refcount = c.refcount and not colorMask or rcZct
+  gch {.rtlThreadVar.}: GcHeap
+
+when not defined(useNimRtl):
+  instantiateForRegion(gch.region)
+
+template gcAssert(cond: bool, msg: string) =
+  when defined(useGcAssert):
+    if not cond:
+      cstderr.rawWrite "[GCASSERT] "
+      cstderr.rawWrite msg
+      when defined(logGC):
+        cstderr.rawWrite "[GCASSERT] statistics:\L"
+        cstderr.rawWrite GC_getStatistics()
+      GC_disable()
+      writeStackTrace()
+      #var x: ptr int
+      #echo x[]
+      rawQuit 1
+
+proc addZCT(s: var CellSeq, c: PCell) {.noinline.} =
+  if (c.refcount and ZctFlag) == 0:
+    c.refcount = c.refcount or ZctFlag
     add(s, c)
 
 proc cellToUsr(cell: PCell): pointer {.inline.} =
   # convert object (=pointer to refcount) to pointer to userdata
-  result = cast[pointer](cast[TAddress](cell)+%TAddress(sizeof(TCell)))
+  result = cast[pointer](cast[int](cell)+%ByteAddress(sizeof(Cell)))
 
 proc usrToCell(usr: pointer): PCell {.inline.} =
   # convert pointer to userdata to object (=pointer to refcount)
-  result = cast[PCell](cast[TAddress](usr)-%TAddress(sizeof(TCell)))
-
-proc canbeCycleRoot(c: PCell): bool {.inline.} =
-  result = ntfAcyclic notin c.typ.flags
+  result = cast[PCell](cast[int](usr)-%ByteAddress(sizeof(Cell)))
 
 proc extGetCellType(c: pointer): PNimType {.compilerproc.} =
   # used for code generation concerning debugging
   result = usrToCell(c).typ
 
 proc internRefcount(p: pointer): int {.exportc: "getRefcount".} =
-  result = int(usrToCell(p).refcount) shr rcShift
-
-proc GC_disable() = inc(recGcLock)
-proc GC_enable() =
-  if recGcLock > 0: dec(recGcLock)
-
-proc GC_setStrategy(strategy: TGC_Strategy) =
-  case strategy
-  of gcThroughput: nil
-  of gcResponsiveness: nil
-  of gcOptimizeSpace: nil
-  of gcOptimizeTime: nil
-
-proc GC_enableMarkAndSweep() =
-  cycleThreshold = InitialCycleThreshold
-
-proc GC_disableMarkAndSweep() =
-  cycleThreshold = high(cycleThreshold)-1
-  # set to the max value to suppress the cycle detector
+  result = usrToCell(p).refcount shr rcShift
 
 # this that has to equals zero, otherwise we have to round up UnitsPerPage:
 when BitsPerPage mod (sizeof(int)*8) != 0:
   {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
 
-when debugGC:
-  proc writeCell(msg: CString, c: PCell) =
+template color(c): untyped = c.refCount and colorMask
+template setColor(c, col) =
+  when col == rcBlack:
+    c.refcount = c.refcount and not colorMask
+  else:
+    c.refcount = c.refcount and not colorMask or col
+
+when defined(logGC):
+  proc writeCell(msg: cstring, c: PCell) =
     var kind = -1
-    if c.typ != nil: kind = ord(c.typ.kind)
-    when debugGC:
-      c_fprintf(c_stdout, "[GC] %s: %p %d rc=%ld from %s(%ld)\n",
-                msg, c, kind, c.refcount shr rcShift, c.filename, c.line)
+    var typName: cstring = "nil"
+    if c.typ != nil:
+      kind = ord(c.typ.kind)
+      when defined(nimTypeNames):
+        if not c.typ.name.isNil:
+          typName = c.typ.name
+
+    when leakDetector:
+      c_printf("[GC] %s: %p %d %s rc=%ld from %s(%ld)\n",
+                msg, c, kind, typName, c.refcount shr rcShift, c.filename, c.line)
     else:
-      c_fprintf(c_stdout, "[GC] %s: %p %d rc=%ld\n",
-                msg, c, kind, c.refcount shr rcShift)
-
-when traceGC:
-  # traceGC is a special switch to enable extensive debugging
-  type
-    TCellState = enum
-      csAllocated, csZctFreed, csCycFreed
-  var
-    states: array[TCellState, TCellSet]
-
-  proc traceCell(c: PCell, state: TCellState) =
-    case state
-    of csAllocated:
-      if c in states[csAllocated]:
-        writeCell("attempt to alloc an already allocated cell", c)
-        assert(false)
-      excl(states[csCycFreed], c)
-      excl(states[csZctFreed], c)
-    of csZctFreed:
-      if c in states[csZctFreed]:
-        writeCell("attempt to free zct cell twice", c)
-        assert(false)
-      if c in states[csCycFreed]:
-        writeCell("attempt to free with zct, but already freed with cyc", c)
-        assert(false)
-      if c notin states[csAllocated]:
-        writeCell("attempt to free not an allocated cell", c)
-        assert(false)
-      excl(states[csAllocated], c)
-    of csCycFreed:
-      if c notin states[csAllocated]:
-        writeCell("attempt to free a not allocated cell", c)
-        assert(false)
-      if c in states[csCycFreed]:
-        writeCell("attempt to free cyc cell twice", c)
-        assert(false)
-      if c in states[csZctFreed]:
-        writeCell("attempt to free with cyc, but already freed with zct", c)
-        assert(false)
-      excl(states[csAllocated], c)
-    incl(states[state], c)
-
-  proc writeLeakage() =
-    var z = 0
-    var y = 0
-    var e = 0
-    for c in elements(states[csAllocated]):
-      inc(e)
-      if c in states[csZctFreed]: inc(z)
-      elif c in states[csCycFreed]: inc(z)
-      else: writeCell("leak", c)
-    cfprintf(cstdout, "Allocations: %ld; ZCT freed: %ld; CYC freed: %ld\n",
-             e, z, y)
-
-template gcTrace(cell, state: expr): stmt =
-  when traceGC: traceCell(cell, state)
+      c_printf("[GC] %s: %p %d %s rc=%ld; thread=%ld\n",
+                msg, c, kind, typName, c.refcount shr rcShift, gch.gcThreadId)
 
-# -----------------------------------------------------------------------------
+template logCell(msg: cstring, c: PCell) =
+  when defined(logGC):
+    writeCell(msg, c)
+
+template gcTrace(cell, state: untyped) =
+  when traceGC: traceCell(cell, state)
 
 # forward declarations:
-proc collectCT(gch: var TGcHeap)
-proc IsOnStack(p: pointer): bool {.noinline.}
-proc forAllChildren(cell: PCell, op: TWalkOp)
-proc doOperation(p: pointer, op: TWalkOp)
-proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp)
+proc collectCT(gch: var GcHeap) {.benign, raises: [].}
+proc isOnStack(p: pointer): bool {.noinline, benign, raises: [].}
+proc forAllChildren(cell: PCell, op: WalkOp) {.benign, raises: [].}
+proc doOperation(p: pointer, op: WalkOp) {.benign, raises: [].}
+proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign, raises: [].}
 # we need the prototype here for debugging purposes
 
-proc prepareDealloc(cell: PCell) =
-  if cell.typ.finalizer != nil:
-    # the finalizer could invoke something that
-    # allocates memory; this could trigger a garbage
-    # collection. Since we are already collecting we
-    # prevend recursive entering here by a lock.
-    # XXX: we should set the cell's children to nil!
-    inc(recGcLock)
-    (cast[TFinalizer](cell.typ.finalizer))(cellToUsr(cell))
-    dec(recGcLock)
+proc incRef(c: PCell) {.inline.} =
+  gcAssert(isAllocatedPtr(gch.region, c), "incRef: interiorPtr")
+  c.refcount = c.refcount +% rcIncrement
+  # and not colorMask
+  logCell("incRef", c)
 
-proc setStackBottom(theStackBottom: pointer) {.compilerproc.} =
-  stackBottom = theStackBottom
+proc nimGCref(p: pointer) {.compilerproc.} =
+  # we keep it from being collected by pretending it's not even allocated:
+  let c = usrToCell(p)
+  add(gch.additionalRoots, c)
+  incRef(c)
 
-proc PossibleRoot(gch: var TGcHeap, c: PCell) {.inline.} =
-  if canbeCycleRoot(c): incl(gch.cycleRoots, c)
+proc rtlAddZCT(c: PCell) {.rtl, inl.} =
+  # we MUST access gch as a global here, because this crosses DLL boundaries!
+  addZCT(gch.zct, c)
 
 proc decRef(c: PCell) {.inline.} =
-  when stressGC:
-    if c.refcount <% rcIncrement:
-      writeCell("broken cell", c)
-  assert(c.refcount >=% rcIncrement)
+  gcAssert(isAllocatedPtr(gch.region, c), "decRef: interiorPtr")
+  gcAssert(c.refcount >=% rcIncrement, "decRef")
   c.refcount = c.refcount -% rcIncrement
   if c.refcount <% rcIncrement:
-    addZCT(gch.zct, c)
-  elif canBeCycleRoot(c):
-    incl(gch.cycleRoots, c) 
-
-proc incRef(c: PCell) {.inline.} = 
-  c.refcount = c.refcount +% rcIncrement
-  if canBeCycleRoot(c):
-    incl(gch.cycleRoots, c)
-
-proc nimGCref(p: pointer) {.compilerproc, inline.} = incRef(usrToCell(p))
-proc nimGCunref(p: pointer) {.compilerproc, inline.} = decRef(usrToCell(p))
-
-proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
+    rtlAddZCT(c)
+  logCell("decRef", c)
+
+proc nimGCunref(p: pointer) {.compilerproc.} =
+  let cell = usrToCell(p)
+  var L = gch.additionalRoots.len-1
+  var i = L
+  let d = gch.additionalRoots.d
+  while i >= 0:
+    if d[i] == cell:
+      d[i] = d[L]
+      dec gch.additionalRoots.len
+      break
+    dec(i)
+  decRef(usrToCell(p))
+
+include gc_common
+
+template beforeDealloc(gch: var GcHeap; c: PCell; msg: typed) =
+  when false:
+    for i in 0..gch.decStack.len-1:
+      if gch.decStack.d[i] == c:
+        sysAssert(false, msg)
+
+proc nimGCunrefNoCycle(p: pointer) {.compilerproc, inline.} =
+  sysAssert(allocInv(gch.region), "begin nimGCunrefNoCycle")
+  decRef(usrToCell(p))
+  sysAssert(allocInv(gch.region), "end nimGCunrefNoCycle 5")
+
+proc nimGCunrefRC1(p: pointer) {.compilerproc, inline.} =
+  decRef(usrToCell(p))
+
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
   # the code generator calls this proc!
-  assert(not isOnStack(dest))
+  gcAssert(not isOnStack(dest), "asgnRef")
   # BUGFIX: first incRef then decRef!
   if src != nil: incRef(usrToCell(src))
-  if dest^ != nil: decRef(usrToCell(dest^))
-  dest^ = src
-
-proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-  # the code generator calls this proc if it is known at compile time that no 
-  # cycle is possible.
-  if src != nil: 
-    var c = usrToCell(src)
-    c.refcount = c.refcount +% rcIncrement
-  if dest^ != nil: 
-    var c = usrToCell(dest^)
-    c.refcount = c.refcount -% rcIncrement
-    if c.refcount <% rcIncrement:
-      addZCT(gch.zct, c)
-  dest^ = src
+  if dest[] != nil: decRef(usrToCell(dest[]))
+  dest[] = src
+
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
 
-proc unsureAsgnRef(dest: ppointer, src: pointer) =
-  if not IsOnStack(dest):
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc.} =
+  # unsureAsgnRef updates the reference counters only if dest is not on the
+  # stack. It is used by the code generator if it cannot decide whether a
+  # reference is in the stack or not (this can happen for var parameters).
+  if not isOnStack(dest):
     if src != nil: incRef(usrToCell(src))
-    if dest^ != nil: decRef(usrToCell(dest^))
-  dest^ = src
+    # XXX finally use assembler for the stack checking instead!
+    # the test for '!= nil' is correct, but I got tired of the segfaults
+    # resulting from the crappy stack checking:
+    if cast[int](dest[]) >=% PageSize: decRef(usrToCell(dest[]))
+  else:
+    # can't be an interior pointer if it's a stack location!
+    gcAssert(interiorAllocatedPtr(gch.region, dest) == nil,
+             "stack loc AND interior pointer")
+  dest[] = src
 
 proc initGC() =
-  when traceGC:
-    for i in low(TCellState)..high(TCellState): Init(states[i])
-  gch.stat.stackScans = 0
-  gch.stat.cycleCollections = 0
-  gch.stat.maxThreshold = 0
-  gch.stat.maxStackSize = 0
-  gch.stat.maxStackCells = 0
-  gch.stat.cycleTableSize = 0
-  # init the rt
-  init(gch.zct)
-  init(gch.tempStack)
-  Init(gch.cycleRoots)
-  Init(gch.decStack)
-  new(gOutOfMem) # reserve space for the EOutOfMemory exception here!
-
-proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) =
-  var d = cast[TAddress](dest)
+  when not defined(useNimRtl):
+    when traceGC:
+      for i in low(CellState)..high(CellState): init(states[i])
+    gch.cycleThreshold = InitialCycleThreshold
+    gch.zctThreshold = InitialZctThreshold
+    gch.stat.stackScans = 0
+    gch.stat.cycleCollections = 0
+    gch.stat.maxThreshold = 0
+    gch.stat.maxStackSize = 0
+    gch.stat.maxStackCells = 0
+    gch.stat.cycleTableSize = 0
+    # init the rt
+    init(gch.zct)
+    init(gch.tempStack)
+    init(gch.decStack)
+    init(gch.marked)
+    init(gch.additionalRoots)
+    when hasThreadSupport:
+      init(gch.toDispose)
+    gch.gcThreadId = atomicInc(gHeapidGenerator) - 1
+    gcAssert(gch.gcThreadId >= 0, "invalid computed thread ID")
+
+proc cellsetReset(s: var CellSet) =
+  deinit(s)
+  init(s)
+
+{.push stacktrace:off.}
+
+proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) {.benign.} =
+  var d = cast[int](dest)
   case n.kind
-  of nkNone: assert(false)
   of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op)
   of nkList:
-    for i in 0..n.len-1: forAllSlotsAux(dest, n.sons[i], op)
+    for i in 0..n.len-1:
+      # inlined for speed
+      if n.sons[i].kind == nkSlot:
+        if n.sons[i].typ.kind in {tyRef, tyString, tySequence}:
+          doOperation(cast[PPointer](d +% n.sons[i].offset)[], op)
+        else:
+          forAllChildrenAux(cast[pointer](d +% n.sons[i].offset),
+                            n.sons[i].typ, op)
+      else:
+        forAllSlotsAux(dest, n.sons[i], op)
   of nkCase:
     var m = selectBranch(dest, n)
     if m != nil: forAllSlotsAux(dest, m, op)
+  of nkNone: sysAssert(false, "forAllSlotsAux")
 
-proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp) =
-  var d = cast[TAddress](dest)
+proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) =
+  var d = cast[int](dest)
   if dest == nil: return # nothing to do
   if ntfNoRefs notin mt.flags:
-    case mt.Kind
+    case mt.kind
+    of tyRef, tyString, tySequence: # leaf:
+      doOperation(cast[PPointer](d)[], op)
+    of tyObject, tyTuple:
+      forAllSlotsAux(dest, mt.node, op)
     of tyArray, tyArrayConstr, tyOpenArray:
       for i in 0..(mt.size div mt.base.size)-1:
         forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op)
-    of tyRef, tyString, tySequence: # leaf:
-      doOperation(cast[ppointer](d)^, op)
-    of tyObject, tyTuple, tyPureObject:
-      forAllSlotsAux(dest, mt.node, op)
-    else: nil
-
-proc forAllChildren(cell: PCell, op: TWalkOp) =
-  assert(cell != nil)
-  assert(cell.typ != nil)
-  case cell.typ.Kind
-  of tyRef: # common case
-    forAllChildrenAux(cellToUsr(cell), cell.typ.base, op)
-  of tySequence:
-    var d = cast[TAddress](cellToUsr(cell))
-    var s = cast[PGenericSeq](d)
-    if s != nil:
-      for i in 0..s.len-1:
-        forAllChildrenAux(cast[pointer](d +% i *% cell.typ.base.size +%
-          GenericSeqSize), cell.typ.base, op)
-  of tyString: nil
-  else: assert(false)
-
-proc checkCollection {.inline.} =
-  # checks if a collection should be done
-  if recGcLock == 0:
-    collectCT(gch)
-
-proc newObj(typ: PNimType, size: int): pointer =
-  # generates a new object and sets its reference counter to 0
-  assert(typ.kind in {tyRef, tyString, tySequence})
-  checkCollection()
-  var res = cast[PCell](rawAlloc(allocator, size + sizeof(TCell)))
-  zeroMem(res, size+sizeof(TCell))
-  assert((cast[TAddress](res) and (MemAlign-1)) == 0)
-  # now it is buffered in the ZCT
-  res.typ = typ
-  when debugGC:
-    if framePtr != nil and framePtr.prev != nil:
-      res.filename = framePtr.prev.filename
-      res.line = framePtr.prev.line
-  res.refcount = rcZct # refcount is zero, but mark it to be in the ZCT  
-  assert(isAllocatedPtr(allocator, res))
-  # its refcount is zero, so add it to the ZCT:
-  block addToZCT: 
-    # we check the last 8 entries (cache line) for a slot
-    # that could be reused
-    var L = gch.zct.len
-    var d = gch.zct.d
+    else: discard
+
+proc forAllChildren(cell: PCell, op: WalkOp) =
+  gcAssert(cell != nil, "forAllChildren: cell is nil")
+  gcAssert(isAllocatedPtr(gch.region, cell), "forAllChildren: pointer not part of the heap")
+  gcAssert(cell.typ != nil, "forAllChildren: cell.typ is nil")
+  gcAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: unknown GC'ed type"
+  let marker = cell.typ.marker
+  if marker != nil:
+    marker(cellToUsr(cell), op.int)
+  else:
+    case cell.typ.kind
+    of tyRef: # common case
+      forAllChildrenAux(cellToUsr(cell), cell.typ.base, op)
+    of tySequence:
+      var d = cast[int](cellToUsr(cell))
+      var s = cast[PGenericSeq](d)
+      if s != nil:
+        for i in 0..s.len-1:
+          forAllChildrenAux(cast[pointer](d +% align(GenericSeqSize, cell.typ.base.align) +% i *% cell.typ.base.size), cell.typ.base, op)
+    else: discard
+
+proc addNewObjToZCT(res: PCell, gch: var GcHeap) {.inline.} =
+  # we check the last 8 entries (cache line) for a slot that could be reused.
+  # In 63% of all cases we succeed here! But we have to optimize the heck
+  # out of this small linear search so that ``newObj`` is not slowed down.
+  #
+  # Slots to try          cache hit
+  # 1                     32%
+  # 4                     59%
+  # 8                     63%
+  # 16                    66%
+  # all slots             68%
+  var L = gch.zct.len
+  var d = gch.zct.d
+  when true:
+    # loop unrolled for performance:
+    template replaceZctEntry(i: untyped) =
+      c = d[i]
+      if c.refcount >=% rcIncrement:
+        c.refcount = c.refcount and not ZctFlag
+        d[i] = res
+        return
+    if L > 8:
+      var c: PCell
+      replaceZctEntry(L-1)
+      replaceZctEntry(L-2)
+      replaceZctEntry(L-3)
+      replaceZctEntry(L-4)
+      replaceZctEntry(L-5)
+      replaceZctEntry(L-6)
+      replaceZctEntry(L-7)
+      replaceZctEntry(L-8)
+      add(gch.zct, res)
+    else:
+      d[L] = res
+      inc(gch.zct.len)
+  else:
     for i in countdown(L-1, max(0, L-8)):
       var c = d[i]
       if c.refcount >=% rcIncrement:
-        c.refcount = c.refcount and not colorMask
+        c.refcount = c.refcount and not ZctFlag
         d[i] = res
-        break addToZCT
+        return
     add(gch.zct, res)
-  when logGC: writeCell("new cell", res)
+
+{.push stackTrace: off, profiler:off.}
+proc gcInvariant*() =
+  sysAssert(allocInv(gch.region), "injected")
+  when declared(markForDebug):
+    markForDebug(gch)
+{.pop.}
+
+template setFrameInfo(c: PCell) =
+  when leakDetector:
+    if framePtr != nil and framePtr.prev != nil:
+      c.filename = framePtr.prev.filename
+      c.line = framePtr.prev.line
+    else:
+      c.filename = nil
+      c.line = 0
+
+proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer =
+  # generates a new object and sets its reference counter to 0
+  incTypeSize typ, size
+  sysAssert(allocInv(gch.region), "rawNewObj begin")
+  gcAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1")
+  collectCT(gch)
+  var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell)))
+  #gcAssert typ.kind in {tyString, tySequence} or size >= typ.base.size, "size too small"
+  gcAssert((cast[int](res) and (MemAlign-1)) == 0, "newObj: 2")
+  # now it is buffered in the ZCT
+  res.typ = typ
+  setFrameInfo(res)
+  # refcount is zero, color is black, but mark it to be in the ZCT
+  res.refcount = ZctFlag
+  sysAssert(isAllocatedPtr(gch.region, res), "newObj: 3")
+  # its refcount is zero, so add it to the ZCT:
+  addNewObjToZCT(res, gch)
+  logCell("new cell", res)
+  track("rawNewObj", res, size)
   gcTrace(res, csAllocated)
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator * 1000_000 + gch.gcThreadId
   result = cellToUsr(res)
+  sysAssert(allocInv(gch.region), "rawNewObj end")
+
+{.pop.} # .stackTrace off
+{.pop.} # .profiler off
+
+proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  result = rawNewObj(typ, size, gch)
+  when defined(memProfiler): nimProfile(size)
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerRtl, noinline.} =
+  result = rawNewObj(typ, size, gch)
+  zeroMem(result, size)
+  when defined(memProfiler): nimProfile(size)
+
+{.push overflowChecks: on.}
+proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} =
+  # `newObj` already uses locks, so no need for them here.
+  let size = align(GenericSeqSize, typ.base.align) + len * typ.base.size
+  result = newObj(typ, size)
+  cast[PGenericSeq](result).len = len
+  cast[PGenericSeq](result).reserved = len
+  when defined(memProfiler): nimProfile(size)
+{.pop.}
+
+proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl, noinline.} =
+  # generates a new object and sets its reference counter to 1
+  incTypeSize typ, size
+  sysAssert(allocInv(gch.region), "newObjRC1 begin")
+  gcAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1")
+  collectCT(gch)
+  sysAssert(allocInv(gch.region), "newObjRC1 after collectCT")
 
-proc newSeq(typ: PNimType, len: int): pointer =
-  result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
+  var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell)))
+  sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc")
+  sysAssert((cast[int](res) and (MemAlign-1)) == 0, "newObj: 2")
+  # now it is buffered in the ZCT
+  res.typ = typ
+  setFrameInfo(res)
+  res.refcount = rcIncrement # refcount is 1
+  sysAssert(isAllocatedPtr(gch.region, res), "newObj: 3")
+  logCell("new cell", res)
+  track("newObjRC1", res, size)
+  gcTrace(res, csAllocated)
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator * 1000_000 + gch.gcThreadId
+  result = cellToUsr(res)
+  zeroMem(result, size)
+  sysAssert(allocInv(gch.region), "newObjRC1 end")
+  when defined(memProfiler): nimProfile(size)
+
+{.push overflowChecks: on.}
+proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
+  let size = align(GenericSeqSize, typ.base.align) + len * typ.base.size
+  result = newObjRC1(typ, size)
   cast[PGenericSeq](result).len = len
-  cast[PGenericSeq](result).space = len
+  cast[PGenericSeq](result).reserved = len
+  when defined(memProfiler): nimProfile(size)
+{.pop.}
 
-proc growObj(old: pointer, newsize: int): pointer =
-  checkCollection()
+proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer =
+  collectCT(gch)
   var ol = usrToCell(old)
-  assert(ol.typ != nil)
-  assert(ol.typ.kind in {tyString, tySequence})
-  var res = cast[PCell](rawAlloc(allocator, newsize + sizeof(TCell)))
-  var elemSize = 1
+  sysAssert(ol.typ != nil, "growObj: 1")
+  gcAssert(ol.typ.kind in {tyString, tySequence}, "growObj: 2")
+  sysAssert(allocInv(gch.region), "growObj begin")
+
+  var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell)))
+  var elemSize,elemAlign = 1
   if ol.typ.kind != tyString:
     elemSize = ol.typ.base.size
-  
-  var oldsize = cast[PGenericSeq](old).len*elemSize + GenericSeqSize
-  copyMem(res, ol, oldsize + sizeof(TCell))
-  zeroMem(cast[pointer](cast[TAddress](res)+% oldsize +% sizeof(TCell)),
+    elemAlign = ol.typ.base.align
+  incTypeSize ol.typ, newsize
+
+  var oldsize = align(GenericSeqSize, elemAlign) + cast[PGenericSeq](old).len * elemSize
+  copyMem(res, ol, oldsize + sizeof(Cell))
+  zeroMem(cast[pointer](cast[int](res) +% oldsize +% sizeof(Cell)),
           newsize-oldsize)
-  assert((cast[TAddress](res) and (MemAlign-1)) == 0)
-  assert(res.refcount shr rcShift <=% 1)
-  #if res.refcount <% rcIncrement:
-  #  add(gch.zct, res)
-  #else: # XXX: what to do here?
-  #  decRef(ol)
-  if (ol.refcount and colorMask) == rcZct:
-    var j = gch.zct.len-1
-    var d = gch.zct.d
-    while j >= 0: 
-      if d[j] == ol:
-        d[j] = res
-        break
-      dec(j)
-  if canBeCycleRoot(ol): excl(gch.cycleRoots, ol)
-  when logGC:
-    writeCell("growObj old cell", ol)
-    writeCell("growObj new cell", res)
+  sysAssert((cast[int](res) and (MemAlign-1)) == 0, "growObj: 3")
+  # This can be wrong for intermediate temps that are nevertheless on the
+  # heap because of lambda lifting:
+  #gcAssert(res.refcount shr rcShift <=% 1, "growObj: 4")
+  logCell("growObj old cell", ol)
+  logCell("growObj new cell", res)
   gcTrace(ol, csZctFreed)
   gcTrace(res, csAllocated)
-  when reallyDealloc: rawDealloc(allocator, ol)
-  else:
-    assert(ol.typ != nil)
-    zeroMem(ol, sizeof(TCell))
+  track("growObj old", ol, 0)
+  track("growObj new", res, newsize)
+  # since we steal the old seq's contents, we set the old length to 0.
+  cast[PGenericSeq](old).len = 0
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator * 1000_000 + gch.gcThreadId
   result = cellToUsr(res)
+  sysAssert(allocInv(gch.region), "growObj end")
+  when defined(memProfiler): nimProfile(newsize-oldsize)
+
+proc growObj(old: pointer, newsize: int): pointer {.rtl.} =
+  result = growObj(old, newsize, gch)
+
+{.push profiler:off, stackTrace:off.}
 
 # ---------------- cycle collector -------------------------------------------
 
-proc doOperation(p: pointer, op: TWalkOp) =
+proc freeCyclicCell(gch: var GcHeap, c: PCell) =
+  prepareDealloc(c)
+  gcTrace(c, csCycFreed)
+  track("cycle collector dealloc cell", c, 0)
+  logCell("cycle collector dealloc cell", c)
+  when reallyDealloc:
+    sysAssert(allocInv(gch.region), "free cyclic cell")
+    beforeDealloc(gch, c, "freeCyclicCell: stack trash")
+    rawDealloc(gch.region, c)
+  else:
+    gcAssert(c.typ != nil, "freeCyclicCell")
+    zeroMem(c, sizeof(Cell))
+
+proc sweep(gch: var GcHeap) =
+  for x in allObjects(gch.region):
+    if isCell(x):
+      # cast to PCell is correct here:
+      var c = cast[PCell](x)
+      if c notin gch.marked: freeCyclicCell(gch, c)
+
+proc markS(gch: var GcHeap, c: PCell) =
+  gcAssert isAllocatedPtr(gch.region, c), "markS: foreign heap root detected A!"
+  incl(gch.marked, c)
+  gcAssert gch.tempStack.len == 0, "stack not empty!"
+  forAllChildren(c, waMarkPrecise)
+  while gch.tempStack.len > 0:
+    dec gch.tempStack.len
+    var d = gch.tempStack.d[gch.tempStack.len]
+    gcAssert isAllocatedPtr(gch.region, d), "markS: foreign heap root detected B!"
+    if not containsOrIncl(gch.marked, d):
+      forAllChildren(d, waMarkPrecise)
+
+proc markGlobals(gch: var GcHeap) {.raises: [].} =
+  if gch.gcThreadId == 0:
+    for i in 0 .. globalMarkersLen-1: globalMarkers[i]()
+  for i in 0 .. threadLocalMarkersLen-1: threadLocalMarkers[i]()
+  let d = gch.additionalRoots.d
+  for i in 0 .. gch.additionalRoots.len-1: markS(gch, d[i])
+
+when logGC:
+  var
+    cycleCheckA: array[100, PCell]
+    cycleCheckALen = 0
+
+  proc alreadySeen(c: PCell): bool =
+    for i in 0 .. cycleCheckALen-1:
+      if cycleCheckA[i] == c: return true
+    if cycleCheckALen == len(cycleCheckA):
+      gcAssert(false, "cycle detection overflow")
+      rawQuit 1
+    cycleCheckA[cycleCheckALen] = c
+    inc cycleCheckALen
+
+  proc debugGraph(s: PCell) =
+    if alreadySeen(s):
+      writeCell("child cell (already seen) ", s)
+    else:
+      writeCell("cell {", s)
+      forAllChildren(s, waDebug)
+      c_printf("}\n")
+
+proc doOperation(p: pointer, op: WalkOp) =
   if p == nil: return
   var c: PCell = usrToCell(p)
-  assert(c != nil)
-  case op # faster than function pointers because of easy prediction
+  gcAssert(c != nil, "doOperation: 1")
+  # the 'case' should be faster than function pointers because of easy
+  # prediction:
+  case op
   of waZctDecRef:
-    assert(c.refcount >=% rcIncrement)
-    c.refcount = c.refcount -% rcIncrement
-    when logGC: writeCell("decref (from doOperation)", c)
-    if c.refcount <% rcIncrement: addZCT(gch.zct, c)
+    #if not isAllocatedPtr(gch.region, c):
+    #  c_printf("[GC] decref bug: %p", c)
+    gcAssert(isAllocatedPtr(gch.region, c), "decRef: waZctDecRef")
+    gcAssert(c.refcount >=% rcIncrement, "doOperation 2")
+    logCell("decref (from doOperation)", c)
+    track("waZctDecref", p, 0)
+    decRef(c)
   of waPush:
     add(gch.tempStack, c)
-  of waCycleDecRef:
-    assert(c.refcount >=% rcIncrement)
-    c.refcount = c.refcount -% rcIncrement
-
-# we now use a much simpler and non-recursive algorithm for cycle removal
-proc collectCycles(gch: var TGcHeap) =
-  var tabSize = 0
-  for c in elements(gch.cycleRoots):
-    inc(tabSize)
-    forallChildren(c, waCycleDecRef)
-  gch.stat.cycleTableSize = max(gch.stat.cycleTableSize, tabSize)
-
-  # restore reference counts (a depth-first traversal is needed):
-  var marker: TCellSet
-  Init(marker)
-  for c in elements(gch.cycleRoots):
-    if c.refcount >=% rcIncrement:
-      if not containsOrIncl(marker, c):
-        gch.tempStack.len = 0
-        forAllChildren(c, waPush)
-        while gch.tempStack.len > 0:
-          dec(gch.tempStack.len)
-          var d = gch.tempStack.d[gch.tempStack.len]
-          d.refcount = d.refcount +% rcIncrement
-          if d in gch.cycleRoots and not containsOrIncl(marker, d):
-            forAllChildren(d, waPush)
-  # remove cycles:
-  for c in elements(gch.cycleRoots):
-    if c.refcount <% rcIncrement:
-      gch.tempStack.len = 0
-      forAllChildren(c, waPush)
-      while gch.tempStack.len > 0:
-        dec(gch.tempStack.len)
-        var d = gch.tempStack.d[gch.tempStack.len]
-        if d.refcount <% rcIncrement:
-          if d notin gch.cycleRoots: # d is leaf of c and not part of cycle
-            addZCT(gch.zct, d)
-            when logGC: writeCell("add to ZCT (from cycle collector)", d)
-      prepareDealloc(c)
-      gcTrace(c, csCycFreed)
-      when logGC: writeCell("cycle collector dealloc cell", c)
-      when reallyDealloc: rawDealloc(allocator, c)
-      else:
-        assert(c.typ != nil)
-        zeroMem(c, sizeof(TCell))
-  Deinit(gch.cycleRoots)
-  Init(gch.cycleRoots)
+  of waMarkGlobal:
+    markS(gch, c)
+  of waMarkPrecise:
+    add(gch.tempStack, c)
+  #of waDebug: debugGraph(c)
+
+proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} =
+  doOperation(d, WalkOp(op))
 
-proc gcMark(p: pointer) {.inline.} =
+proc collectZCT(gch: var GcHeap): bool {.benign, raises: [].}
+
+proc collectCycles(gch: var GcHeap) {.raises: [].} =
+  when hasThreadSupport:
+    for c in gch.toDispose:
+      nimGCunref(c)
+  # ensure the ZCT 'color' is not used:
+  while gch.zct.len > 0: discard collectZCT(gch)
+  cellsetReset(gch.marked)
+  var d = gch.decStack.d
+  for i in 0..gch.decStack.len-1:
+    sysAssert isAllocatedPtr(gch.region, d[i]), "collectCycles"
+    markS(gch, d[i])
+  markGlobals(gch)
+  sweep(gch)
+
+proc gcMark(gch: var GcHeap, p: pointer) {.inline.} =
   # the addresses are not as cells on the stack, so turn them to cells:
-  var cell = usrToCell(p)
-  var c = cast[TAddress](cell)
-  if c >% PageSize and (c and (MemAlign-1)) == 0:
+  sysAssert(allocInv(gch.region), "gcMark begin")
+  var c = cast[int](p)
+  if c >% PageSize:
     # fast check: does it look like a cell?
-    if isAllocatedPtr(allocator, cell): 
+    var objStart = cast[PCell](interiorAllocatedPtr(gch.region, p))
+    if objStart != nil:
       # mark the cell:
-      cell.refcount = cell.refcount +% rcIncrement
-      add(gch.decStack, cell)
-
-# ----------------- stack management --------------------------------------
-#  inspired from Smart Eiffel
-
-proc stackSize(): int {.noinline.} =
-  var stackTop: array[0..1, pointer]
-  result = abs(cast[int](addr(stackTop[0])) - cast[int](stackBottom))
-
-when defined(sparc): # For SPARC architecture.
-  proc isOnStack(p: pointer): bool =
-    var stackTop: array [0..1, pointer]
-    var b = cast[TAddress](stackBottom)
-    var a = cast[TAddress](addr(stackTop[0]))
-    var x = cast[TAddress](p)
-    result = x >=% a and x <=% b
-
-  proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
-    when defined(sparcv9):
-      asm  """"flushw \n" """
-    else:
-      asm  """"ta      0x3   ! ST_FLUSH_WINDOWS\n" """
-
-    var
-      max = stackBottom
-      sp: PPointer
-      stackTop: array[0..1, pointer]
-    sp = addr(stackTop[0])
-    # Addresses decrease as the stack grows.
-    while sp <= max:
-      gcMark(sp^)
-      sp = cast[ppointer](cast[TAddress](sp) +% sizeof(pointer))
-
-elif defined(ELATE):
-  {.error: "stack marking code is to be written for this architecture".}
-
-elif defined(hppa) or defined(hp9000) or defined(hp9000s300) or
-     defined(hp9000s700) or defined(hp9000s800) or defined(hp9000s820):
-  # ---------------------------------------------------------------------------
-  # Generic code for architectures where addresses increase as the stack grows.
-  # ---------------------------------------------------------------------------
-  proc isOnStack(p: pointer): bool =
-    var stackTop: array [0..1, pointer]
-    var a = cast[TAddress](stackBottom)
-    var b = cast[TAddress](addr(stackTop[0]))
-    var x = cast[TAddress](p)
-    result = x >=% a and x <=% b
-
-  var
-    jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int
-      # a little hack to get the size of a TJmpBuf in the generated C code
-      # in a platform independant way
-
-  proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
-    var registers: C_JmpBuf
-    if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
-      var max = cast[TAddress](stackBottom)
-      var sp = cast[TAddress](addr(registers)) +% jmpbufSize -% sizeof(pointer)
-      # sp will traverse the JMP_BUF as well (jmp_buf size is added,
-      # otherwise sp would be below the registers structure).
-      while sp >=% max:
-        gcMark(cast[ppointer](sp)^)
-        sp = sp -% sizeof(pointer)
-
-else:
-  # ---------------------------------------------------------------------------
-  # Generic code for architectures where addresses decrease as the stack grows.
-  # ---------------------------------------------------------------------------
-  proc isOnStack(p: pointer): bool =
-    var stackTop: array [0..1, pointer]
-    var b = cast[TAddress](stackBottom)
-    var a = cast[TAddress](addr(stackTop[0]))
-    var x = cast[TAddress](p)
-    result = x >=% a and x <=% b
-
-  proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
-    # We use a jmp_buf buffer that is in the C stack.
-    # Used to traverse the stack and registers assuming
-    # that 'setjmp' will save registers in the C stack.
-    var registers: C_JmpBuf
-    if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
-      var max = cast[TAddress](stackBottom)
-      var sp = cast[TAddress](addr(registers))
-      while sp <=% max:
-        gcMark(cast[ppointer](sp)^)
-        sp = sp +% sizeof(pointer)
-
-# ----------------------------------------------------------------------------
-# end of non-portable code
-# ----------------------------------------------------------------------------
-
-proc CollectZCT(gch: var TGcHeap) =
-  # Note: Freeing may add child objects to the ZCT! So essentially we do 
-  # deep freeing, which is bad for incremental operation. In order to 
+      incRef(objStart)
+      add(gch.decStack, objStart)
+    when false:
+      let cell = usrToCell(p)
+      if isAllocatedPtr(gch.region, cell):
+        sysAssert false, "allocated pointer but not interior?"
+        # mark the cell:
+        incRef(cell)
+        add(gch.decStack, cell)
+  sysAssert(allocInv(gch.region), "gcMark end")
+
+#[
+  This method is conditionally marked with an attribute so that it gets ignored by the LLVM ASAN
+  (Address SANitizer) intrumentation as it will raise false errors due to the implementation of
+  garbage collection that is used by Nim. For more information, please see the documentation of
+  `CLANG_NO_SANITIZE_ADDRESS` in `lib/nimbase.h`.
+ ]#
+proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl,
+    codegenDecl: "CLANG_NO_SANITIZE_ADDRESS N_LIB_PRIVATE $# $#$#".} =
+  forEachStackSlot(gch, gcMark)
+
+proc collectZCT(gch: var GcHeap): bool =
+  # Note: Freeing may add child objects to the ZCT! So essentially we do
+  # deep freeing, which is bad for incremental operation. In order to
   # avoid a deep stack, we move objects to keep the ZCT small.
   # This is performance critical!
+  const workPackage = 100
   var L = addr(gch.zct.len)
-  while L^ > 0:
+
+  when withRealTime:
+    var steps = workPackage
+    var t0: Ticks
+    if gch.maxPause > 0: t0 = getticks()
+  while L[] > 0:
     var c = gch.zct.d[0]
+    sysAssert(isAllocatedPtr(gch.region, c), "CollectZCT: isAllocatedPtr")
     # remove from ZCT:
-    assert((c.refcount and colorMask) == rcZct)
-    c.refcount = c.refcount and not colorMask
-    gch.zct.d[0] = gch.zct.d[L^ - 1]
-    dec(L^)
-    if c.refcount <% rcIncrement: 
+    gcAssert((c.refcount and ZctFlag) == ZctFlag, "collectZCT")
+
+    c.refcount = c.refcount and not ZctFlag
+    gch.zct.d[0] = gch.zct.d[L[] - 1]
+    dec(L[])
+    when withRealTime: dec steps
+    if c.refcount <% rcIncrement:
       # It may have a RC > 0, if it is in the hardware stack or
       # it has not been removed yet from the ZCT. This is because
-      # ``incref`` does not bother to remove the cell from the ZCT 
+      # ``incref`` does not bother to remove the cell from the ZCT
       # as this might be too slow.
       # In any case, it should be removed from the ZCT. But not
       # freed. **KEEP THIS IN MIND WHEN MAKING THIS INCREMENTAL!**
-      if canBeCycleRoot(c): excl(gch.cycleRoots, c)
-      when logGC: writeCell("zct dealloc cell", c)
+      logCell("zct dealloc cell", c)
+      track("zct dealloc cell", c, 0)
       gcTrace(c, csZctFreed)
       # We are about to free the object, call the finalizer BEFORE its
       # children are deleted as well, because otherwise the finalizer may
       # access invalid memory. This is done by prepareDealloc():
       prepareDealloc(c)
       forAllChildren(c, waZctDecRef)
-      when reallyDealloc: rawDealloc(allocator, c)
+      when reallyDealloc:
+        sysAssert(allocInv(gch.region), "collectZCT: rawDealloc")
+        beforeDealloc(gch, c, "collectZCT: stack trash")
+        rawDealloc(gch.region, c)
       else:
-        assert(c.typ != nil)
-        zeroMem(c, sizeof(TCell))
-
-proc unmarkStackAndRegisters(gch: var TGcHeap) = 
+        sysAssert(c.typ != nil, "collectZCT 2")
+        zeroMem(c, sizeof(Cell))
+    when withRealTime:
+      if steps == 0:
+        steps = workPackage
+        if gch.maxPause > 0:
+          let duration = getticks() - t0
+          # the GC's measuring is not accurate and needs some cleanup actions
+          # (stack unmarking), so subtract some short amount of time in
+          # order to miss deadlines less often:
+          if duration >= gch.maxPause - 50_000:
+            return false
+  result = true
+
+proc unmarkStackAndRegisters(gch: var GcHeap) =
   var d = gch.decStack.d
   for i in 0..gch.decStack.len-1:
-    assert isAllocatedPtr(allocator, d[i])
-    decRef(d[i]) # OPT: cannot create a cycle!
+    sysAssert isAllocatedPtr(gch.region, d[i]), "unmarkStackAndRegisters"
+    decRef(d[i])
   gch.decStack.len = 0
 
-proc collectCT(gch: var TGcHeap) =
-  if gch.zct.len >= ZctThreshold or (cycleGC and
-      getOccupiedMem() >= cycleThreshold) or stressGC:
+proc collectCTBody(gch: var GcHeap) {.raises: [].} =
+  when withRealTime:
+    let t0 = getticks()
+  sysAssert(allocInv(gch.region), "collectCT: begin")
+
+  when nimCoroutines:
+    for stack in gch.stack.items():
+      gch.stat.maxStackSize = max(gch.stat.maxStackSize, stack.stackSize())
+  else:
     gch.stat.maxStackSize = max(gch.stat.maxStackSize, stackSize())
-    assert(gch.decStack.len == 0)
-    markStackAndRegisters(gch)
-    gch.stat.maxStackCells = max(gch.stat.maxStackCells, gch.decStack.len)
-    inc(gch.stat.stackScans)
-    collectZCT(gch)
+  sysAssert(gch.decStack.len == 0, "collectCT")
+  prepareForInteriorPointerChecking(gch.region)
+  markStackAndRegisters(gch)
+  gch.stat.maxStackCells = max(gch.stat.maxStackCells, gch.decStack.len)
+  inc(gch.stat.stackScans)
+  if collectZCT(gch):
     when cycleGC:
-      if getOccupiedMem() >= cycleThreshold or stressGC:
+      if getOccupiedMem(gch.region) >= gch.cycleThreshold or alwaysCycleGC:
         collectCycles(gch)
-        collectZCT(gch)
+        #discard collectZCT(gch)
         inc(gch.stat.cycleCollections)
-        cycleThreshold = max(InitialCycleThreshold, getOccupiedMem() *
-                             cycleIncrease)
-        gch.stat.maxThreshold = max(gch.stat.maxThreshold, cycleThreshold)
-    unmarkStackAndRegisters(gch)
-
-proc GC_fullCollect() =
-  var oldThreshold = cycleThreshold
-  cycleThreshold = 0 # forces cycle collection
-  collectCT(gch)
-  cycleThreshold = oldThreshold
-
-proc GC_getStatistics(): string =
-  GC_disable()
-  result = "[GC] total memory: " & $(getTotalMem()) & "\n" &
-           "[GC] occupied memory: " & $(getOccupiedMem()) & "\n" &
-           "[GC] stack scans: " & $gch.stat.stackScans & "\n" &
-           "[GC] stack cells: " & $gch.stat.maxStackCells & "\n" &
-           "[GC] cycle collections: " & $gch.stat.cycleCollections & "\n" &
-           "[GC] max threshold: " & $gch.stat.maxThreshold & "\n" &
-           "[GC] zct capacity: " & $gch.zct.cap & "\n" &
-           "[GC] max cycle table size: " & $gch.stat.cycleTableSize & "\n" &
-           "[GC] max stack size: " & $gch.stat.maxStackSize
-  when traceGC: writeLeakage()
-  GC_enable()
+        gch.cycleThreshold = max(InitialCycleThreshold, getOccupiedMem() *
+                                 CycleIncrease)
+        gch.stat.maxThreshold = max(gch.stat.maxThreshold, gch.cycleThreshold)
+  unmarkStackAndRegisters(gch)
+  sysAssert(allocInv(gch.region), "collectCT: end")
+
+  when withRealTime:
+    let duration = getticks() - t0
+    gch.stat.maxPause = max(gch.stat.maxPause, duration)
+    when defined(reportMissedDeadlines):
+      if gch.maxPause > 0 and duration > gch.maxPause:
+        c_printf("[GC] missed deadline: %ld\n", duration)
+
+proc collectCT(gch: var GcHeap) =
+  if (gch.zct.len >= gch.zctThreshold or (cycleGC and
+      getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) and
+      gch.recGcLock == 0:
+    when false:
+      prepareForInteriorPointerChecking(gch.region)
+      cellsetReset(gch.marked)
+      markForDebug(gch)
+    collectCTBody(gch)
+    gch.zctThreshold = max(InitialZctThreshold, gch.zct.len * CycleIncrease)
+
+proc GC_collectZct*() =
+  ## Collect the ZCT (zero count table). Unstable, experimental API for
+  ## testing purposes.
+  ## DO NOT USE!
+  collectCTBody(gch)
+
+when withRealTime:
+  proc toNano(x: int): Nanos {.inline.} =
+    result = x * 1000
+
+  proc GC_setMaxPause*(MaxPauseInUs: int) =
+    gch.maxPause = MaxPauseInUs.toNano
+
+  proc GC_step(gch: var GcHeap, us: int, strongAdvice: bool) =
+    gch.maxPause = us.toNano
+    if (gch.zct.len >= gch.zctThreshold or (cycleGC and
+        getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) or
+        strongAdvice:
+      collectCTBody(gch)
+      gch.zctThreshold = max(InitialZctThreshold, gch.zct.len * CycleIncrease)
+
+  proc GC_step*(us: int, strongAdvice = false, stackSize = -1) {.noinline.} =
+    if stackSize >= 0:
+      var stackTop {.volatile.}: pointer
+      gch.getActiveStack().pos = addr(stackTop)
+
+      for stack in gch.stack.items():
+        stack.bottomSaved = stack.bottom
+        when stackIncreases:
+          stack.bottom = cast[pointer](
+            cast[int](stack.pos) - sizeof(pointer) * 6 - stackSize)
+        else:
+          stack.bottom = cast[pointer](
+            cast[int](stack.pos) + sizeof(pointer) * 6 + stackSize)
+
+    GC_step(gch, us, strongAdvice)
+
+    if stackSize >= 0:
+      for stack in gch.stack.items():
+        stack.bottom = stack.bottomSaved
+
+when not defined(useNimRtl):
+  proc GC_disable() =
+    inc(gch.recGcLock)
+  proc GC_enable() =
+    when defined(nimDoesntTrackDefects):
+      if gch.recGcLock <= 0:
+        raise newException(AssertionDefect,
+            "API usage error: GC_enable called but GC is already enabled")
+    dec(gch.recGcLock)
+
+  proc GC_setStrategy(strategy: GC_Strategy) =
+    discard
+
+  proc GC_enableMarkAndSweep() =
+    gch.cycleThreshold = InitialCycleThreshold
+
+  proc GC_disableMarkAndSweep() =
+    gch.cycleThreshold = high(typeof(gch.cycleThreshold))-1
+    # set to the max value to suppress the cycle detector
+
+  proc GC_fullCollect() =
+    var oldThreshold = gch.cycleThreshold
+    gch.cycleThreshold = 0 # forces cycle collection
+    collectCT(gch)
+    gch.cycleThreshold = oldThreshold
+
+  proc GC_getStatistics(): string =
+    result = "[GC] total memory: " & $(getTotalMem()) & "\n" &
+             "[GC] occupied memory: " & $(getOccupiedMem()) & "\n" &
+             "[GC] stack scans: " & $gch.stat.stackScans & "\n" &
+             "[GC] stack cells: " & $gch.stat.maxStackCells & "\n" &
+             "[GC] cycle collections: " & $gch.stat.cycleCollections & "\n" &
+             "[GC] max threshold: " & $gch.stat.maxThreshold & "\n" &
+             "[GC] zct capacity: " & $gch.zct.cap & "\n" &
+             "[GC] max cycle table size: " & $gch.stat.cycleTableSize & "\n" &
+             "[GC] max pause time [ms]: " & $(gch.stat.maxPause div 1000_000) & "\n"
+    when nimCoroutines:
+      result.add "[GC] number of stacks: " & $gch.stack.len & "\n"
+      for stack in items(gch.stack):
+        result.add "[GC]   stack " & stack.bottom.repr & "[GC]     max stack size " & cast[pointer](stack.maxStackSize).repr & "\n"
+    else:
+      # this caused memory leaks, see #10488 ; find a way without `repr`
+      # maybe using a local copy of strutils.toHex or snprintf
+      when defined(logGC):
+        result.add "[GC] stack bottom: " & gch.stack.bottom.repr
+      result.add "[GC] max stack size: " & $gch.stat.maxStackSize & "\n"
+
+{.pop.} # profiler: off, stackTrace: off
diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim
new file mode 100644
index 000000000..eb0884560
--- /dev/null
+++ b/lib/system/gc_common.nim
@@ -0,0 +1,482 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Rokas Kupstys
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+type
+  ForeignCell* = object
+    data*: pointer
+    owner: ptr GcHeap
+
+proc protect*(x: pointer): ForeignCell =
+  nimGCref(x)
+  result.data = x
+  result.owner = addr(gch)
+
+when defined(nimTypeNames):
+  type InstancesInfo = array[400, (cstring, int, int)]
+  proc sortInstances(a: var InstancesInfo; n: int) =
+    # we use shellsort here; fast and simple
+    var h = 1
+    while true:
+      h = 3 * h + 1
+      if h > n: break
+    while true:
+      h = h div 3
+      for i in countup(h, n - 1):
+        var v = a[i]
+        var j = i
+        while a[j - h][2] < v[2]:
+          a[j] = a[j - h]
+          j = j - h
+          if j < h: break
+        a[j] = v
+      if h == 1: break
+
+  iterator dumpHeapInstances*(): tuple[name: cstring; count: int; sizes: int] =
+    ## Iterate over summaries of types on heaps.
+    ## This data may be inaccurate if allocations
+    ## are made by the iterator body.
+    if strDesc.nextType == nil:
+      strDesc.nextType = nimTypeRoot
+      strDesc.name = "string"
+      nimTypeRoot = addr strDesc
+    var it = nimTypeRoot
+    while it != nil:
+      if (it.instances > 0 or it.sizes != 0):
+        yield (it.name, it.instances, it.sizes)
+      it = it.nextType
+
+  proc dumpNumberOfInstances* =
+    var a: InstancesInfo
+    var n = 0
+    var totalAllocated = 0
+    for it in dumpHeapInstances():
+      a[n] = it
+      inc n
+      inc totalAllocated, it.sizes
+    sortInstances(a, n)
+    for i in 0 .. n-1:
+      c_fprintf(cstdout, "[Heap] %s: #%ld; bytes: %ld\n", a[i][0], a[i][1], a[i][2])
+    c_fprintf(cstdout, "[Heap] total number of bytes: %ld\n", totalAllocated)
+    when defined(nimTypeNames):
+      let (allocs, deallocs) = getMemCounters()
+      c_fprintf(cstdout, "[Heap] allocs/deallocs: %ld/%ld\n", allocs, deallocs)
+
+  when defined(nimGcRefLeak):
+    proc oomhandler() =
+      c_fprintf(cstdout, "[Heap] ROOTS: #%ld\n", gch.additionalRoots.len)
+      writeLeaks()
+
+    outOfMemHook = oomhandler
+
+template decTypeSize(cell, t) =
+  when defined(nimTypeNames):
+    if t.kind in {tyString, tySequence}:
+      let cap = cast[PGenericSeq](cellToUsr(cell)).space
+      let size =
+        if t.kind == tyString:
+          cap + 1 + GenericSeqSize
+        else:
+          align(GenericSeqSize, t.base.align) + cap * t.base.size
+      atomicDec t.sizes, size+sizeof(Cell)
+    else:
+      atomicDec t.sizes, t.base.size+sizeof(Cell)
+    atomicDec t.instances
+
+template incTypeSize(typ, size) =
+  when defined(nimTypeNames):
+    atomicInc typ.instances
+    atomicInc typ.sizes, size+sizeof(Cell)
+
+proc dispose*(x: ForeignCell) =
+  when hasThreadSupport:
+    # if we own it we can free it directly:
+    if x.owner == addr(gch):
+      nimGCunref(x.data)
+    else:
+      x.owner.toDispose.add(x.data)
+  else:
+    nimGCunref(x.data)
+
+proc isNotForeign*(x: ForeignCell): bool =
+  ## returns true if 'x' belongs to the calling thread.
+  ## No deep copy has to be performed then.
+  x.owner == addr(gch)
+
+when nimCoroutines:
+  iterator items(first: var GcStack): ptr GcStack =
+    var item = addr(first)
+    while true:
+      yield item
+      item = item.next
+      if item == addr(first):
+        break
+
+  proc append(first: var GcStack, stack: ptr GcStack) =
+    ## Append stack to the ring of stacks.
+    first.prev.next = stack
+    stack.prev = first.prev
+    first.prev = stack
+    stack.next = addr(first)
+
+  proc append(first: var GcStack): ptr GcStack =
+    ## Allocate new GcStack object, append it to the ring of stacks and return it.
+    result = cast[ptr GcStack](alloc0(sizeof(GcStack)))
+    first.append(result)
+
+  proc remove(first: var GcStack, stack: ptr GcStack) =
+    ## Remove stack from ring of stacks.
+    gcAssert(addr(first) != stack, "Main application stack can not be removed")
+    if addr(first) == stack or stack == nil:
+      return
+    stack.prev.next = stack.next
+    stack.next.prev = stack.prev
+    dealloc(stack)
+
+  proc remove(stack: ptr GcStack) =
+    gch.stack.remove(stack)
+
+  proc find(first: var GcStack, bottom: pointer): ptr GcStack =
+    ## Find stack struct based on bottom pointer. If `bottom` is nil then main
+    ## thread stack is is returned.
+    if bottom == nil:
+      return addr(gch.stack)
+
+    for stack in first.items():
+      if stack.bottom == bottom:
+        return stack
+
+  proc len(stack: var GcStack): int =
+    for _ in stack.items():
+      result = result + 1
+else:
+  # This iterator gets optimized out in forEachStackSlot().
+  iterator items(first: var GcStack): ptr GcStack = yield addr(first)
+  proc len(stack: var GcStack): int = 1
+
+when defined(nimdoc):
+  proc setupForeignThreadGc*() {.gcsafe.} =
+    ## Call this if you registered a callback that will be run from a thread not
+    ## under your control. This has a cheap thread-local guard, so the GC for
+    ## this thread will only be initialized once per thread, no matter how often
+    ## it is called.
+    ##
+    ## This function is available only when `--threads:on` and `--tlsEmulation:off`
+    ## switches are used
+    discard
+
+  proc tearDownForeignThreadGc*() {.gcsafe.} =
+    ## Call this to tear down the GC, previously initialized by `setupForeignThreadGc`.
+    ## If GC has not been previously initialized, or has already been torn down, the
+    ## call does nothing.
+    ##
+    ## This function is available only when `--threads:on` and `--tlsEmulation:off`
+    ## switches are used
+    discard
+elif declared(threadType):
+  proc setupForeignThreadGc*() {.gcsafe.} =
+    if threadType == ThreadType.None:
+      var stackTop {.volatile.}: pointer
+      nimGC_setStackBottom(addr(stackTop))
+      initGC()
+      threadType = ThreadType.ForeignThread
+
+  proc tearDownForeignThreadGc*() {.gcsafe.} =
+    if threadType != ThreadType.ForeignThread:
+      return
+    when declared(deallocOsPages): deallocOsPages()
+    threadType = ThreadType.None
+    when declared(gch): zeroMem(addr gch, sizeof(gch))
+
+else:
+  template setupForeignThreadGc*() =
+    {.error: "setupForeignThreadGc is available only when ``--threads:on`` and ``--tlsEmulation:off`` are used".}
+
+  template tearDownForeignThreadGc*() =
+    {.error: "tearDownForeignThreadGc is available only when ``--threads:on`` and ``--tlsEmulation:off`` are used".}
+
+# ----------------- stack management --------------------------------------
+#  inspired from Smart Eiffel
+
+when defined(emscripten) or defined(wasm):
+  const stackIncreases = true
+elif defined(sparc):
+  const stackIncreases = false
+elif defined(hppa) or defined(hp9000) or defined(hp9000s300) or
+     defined(hp9000s700) or defined(hp9000s800) or defined(hp9000s820):
+  const stackIncreases = true
+else:
+  const stackIncreases = false
+
+proc stackSize(stack: ptr GcStack): int {.noinline.} =
+  when nimCoroutines:
+    var pos = stack.pos
+  else:
+    var pos {.volatile, noinit.}: pointer
+    pos = addr(pos)
+
+  if pos != nil:
+    when stackIncreases:
+      result = cast[int](pos) -% cast[int](stack.bottom)
+    else:
+      result = cast[int](stack.bottom) -% cast[int](pos)
+  else:
+    result = 0
+
+proc stackSize(): int {.noinline.} =
+  result = 0
+  for stack in gch.stack.items():
+    result = result + stack.stackSize()
+
+when nimCoroutines:
+  proc setPosition(stack: ptr GcStack, position: pointer) =
+    stack.pos = position
+    stack.maxStackSize = max(stack.maxStackSize, stack.stackSize())
+
+  proc setPosition(stack: var GcStack, position: pointer) =
+    setPosition(addr(stack), position)
+
+  proc getActiveStack(gch: var GcHeap): ptr GcStack =
+    return gch.activeStack
+
+  proc isActiveStack(stack: ptr GcStack): bool =
+    return gch.activeStack == stack
+else:
+  # Stack positions do not need to be tracked if coroutines are not used.
+  proc setPosition(stack: ptr GcStack, position: pointer) = discard
+  proc setPosition(stack: var GcStack, position: pointer) = discard
+  # There is just one stack - main stack of the thread. It is active always.
+  proc getActiveStack(gch: var GcHeap): ptr GcStack = addr(gch.stack)
+  proc isActiveStack(stack: ptr GcStack): bool = true
+
+{.push stack_trace: off.}
+when nimCoroutines:
+  proc GC_addStack(bottom: pointer) {.cdecl, dynlib, exportc.} =
+    # c_fprintf(stdout, "GC_addStack: %p;\n", bottom)
+    var stack = gch.stack.append()
+    stack.bottom = bottom
+    stack.setPosition(bottom)
+
+  proc GC_removeStack(bottom: pointer) {.cdecl, dynlib, exportc.} =
+    # c_fprintf(stdout, "GC_removeStack: %p;\n", bottom)
+    gch.stack.find(bottom).remove()
+
+  proc GC_setActiveStack(bottom: pointer) {.cdecl, dynlib, exportc.} =
+    ## Sets active stack and updates current stack position.
+    # c_fprintf(stdout, "GC_setActiveStack: %p;\n", bottom)
+    var sp {.volatile.}: pointer
+    gch.activeStack = gch.stack.find(bottom)
+    gch.activeStack.setPosition(addr(sp))
+
+  proc GC_getActiveStack() : pointer {.cdecl, exportc.} =
+    return gch.activeStack.bottom
+
+when not defined(useNimRtl):
+  proc nimGC_setStackBottom(theStackBottom: pointer) =
+    # Initializes main stack of the thread.
+    when nimCoroutines:
+      if gch.stack.next == nil:
+        # Main stack was not initialized yet
+        gch.stack.next = addr(gch.stack)
+        gch.stack.prev = addr(gch.stack)
+        gch.stack.bottom = theStackBottom
+        gch.stack.maxStackSize = 0
+        gch.activeStack = addr(gch.stack)
+
+    if gch.stack.bottom == nil:
+      # This branch will not be called when -d:nimCoroutines - it is fine,
+      # because same thing is done just above.
+      #c_fprintf(stdout, "stack bottom: %p;\n", theStackBottom)
+      # the first init must be the one that defines the stack bottom:
+      gch.stack.bottom = theStackBottom
+    elif theStackBottom != gch.stack.bottom:
+      var a = cast[int](theStackBottom) # and not PageMask - PageSize*2
+      var b = cast[int](gch.stack.bottom)
+      #c_fprintf(stdout, "old: %p new: %p;\n",gch.stack.bottom,theStackBottom)
+      when stackIncreases:
+        gch.stack.bottom = cast[pointer](min(a, b))
+      else:
+        gch.stack.bottom = cast[pointer](max(a, b))
+
+    when nimCoroutines:
+      if theStackBottom != nil: gch.stack.bottom = theStackBottom
+
+    gch.stack.setPosition(theStackBottom)
+{.pop.}
+
+proc isOnStack(p: pointer): bool =
+  var stackTop {.volatile, noinit.}: pointer
+  stackTop = addr(stackTop)
+  var a = cast[int](gch.getActiveStack().bottom)
+  var b = cast[int](stackTop)
+  when not stackIncreases:
+    swap(a, b)
+  var x = cast[int](p)
+  result = a <=% x and x <=% b
+
+when defined(sparc): # For SPARC architecture.
+  when nimCoroutines:
+    {.error: "Nim coroutines are not supported on this platform."}
+
+  template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
+    when defined(sparcv9):
+      asm  """"flushw \n" """
+    else:
+      asm  """"ta      0x3   ! ST_FLUSH_WINDOWS\n" """
+
+    var
+      max = gch.stack.bottom
+      sp: PPointer
+      stackTop: array[0..1, pointer]
+    sp = addr(stackTop[0])
+    # Addresses decrease as the stack grows.
+    while sp <= max:
+      gcMark(gch, sp[])
+      sp = cast[PPointer](cast[int](sp) +% sizeof(pointer))
+
+elif defined(ELATE):
+  {.error: "stack marking code is to be written for this architecture".}
+
+elif stackIncreases:
+  # ---------------------------------------------------------------------------
+  # Generic code for architectures where addresses increase as the stack grows.
+  # ---------------------------------------------------------------------------
+  when defined(emscripten) or defined(wasm):
+    var
+      jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int
+        # a little hack to get the size of a JmpBuf in the generated C code
+        # in a platform independent way
+
+  template forEachStackSlotAux(gch, gcMark: untyped) {.dirty.} =
+    for stack in gch.stack.items():
+      var max = cast[int](gch.stack.bottom)
+      var sp = cast[int](addr(registers)) -% sizeof(pointer)
+      while sp >=% max:
+        gcMark(gch, cast[PPointer](sp)[])
+        sp = sp -% sizeof(pointer)
+
+  template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
+    when defined(emscripten) or defined(wasm):
+      var registers: cint
+      forEachStackSlotAux(gch, gcMark)
+    else:
+      var registers {.noinit.}: C_JmpBuf
+      if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
+        forEachStackSlotAux(gch, gcMark)
+
+else:
+  # ---------------------------------------------------------------------------
+  # Generic code for architectures where addresses decrease as the stack grows.
+  # ---------------------------------------------------------------------------
+  template forEachStackSlot(gch, gcMark: untyped) {.dirty.} =
+    # We use a jmp_buf buffer that is in the C stack.
+    # Used to traverse the stack and registers assuming
+    # that 'setjmp' will save registers in the C stack.
+    type PStackSlice = ptr array[0..7, pointer]
+    var registers {.noinit.}: C_JmpBuf
+    # Update position of stack gc is executing in.
+    gch.getActiveStack().setPosition(addr(registers))
+    if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
+      for stack in gch.stack.items():
+        var max = cast[int](stack.bottom)
+        var sp = cast[int](addr(registers))
+        when defined(amd64):
+          if stack.isActiveStack():
+            # words within the jmp_buf structure may not be properly aligned.
+            let regEnd = sp +% sizeof(registers)
+            while sp <% regEnd:
+              gcMark(gch, cast[PPointer](sp)[])
+              sp = sp +% sizeof(pointer)
+        # Make sure sp is word-aligned
+        sp = sp and not (sizeof(pointer) - 1)
+        # loop unrolled:
+        while sp <% max - 8*sizeof(pointer):
+          gcMark(gch, cast[PStackSlice](sp)[0])
+          gcMark(gch, cast[PStackSlice](sp)[1])
+          gcMark(gch, cast[PStackSlice](sp)[2])
+          gcMark(gch, cast[PStackSlice](sp)[3])
+          gcMark(gch, cast[PStackSlice](sp)[4])
+          gcMark(gch, cast[PStackSlice](sp)[5])
+          gcMark(gch, cast[PStackSlice](sp)[6])
+          gcMark(gch, cast[PStackSlice](sp)[7])
+          sp = sp +% sizeof(pointer)*8
+        # last few entries:
+        while sp <=% max:
+          gcMark(gch, cast[PPointer](sp)[])
+          sp = sp +% sizeof(pointer)
+
+# ----------------------------------------------------------------------------
+# end of non-portable code
+# ----------------------------------------------------------------------------
+
+proc prepareDealloc(cell: PCell) {.raises: [].} =
+  when declared(useMarkForDebug):
+    when useMarkForDebug:
+      gcAssert(cell notin gch.marked, "Cell still alive!")
+  let t = cell.typ
+  if t.finalizer != nil:
+    # the finalizer could invoke something that
+    # allocates memory; this could trigger a garbage
+    # collection. Since we are already collecting we
+    # prevent recursive entering here by a lock.
+    # XXX: we should set the cell's children to nil!
+    inc(gch.recGcLock)
+    (cast[Finalizer](t.finalizer))(cellToUsr(cell))
+    dec(gch.recGcLock)
+  decTypeSize(cell, t)
+
+proc deallocHeap*(runFinalizers = true; allowGcAfterwards = true) =
+  ## Frees the thread local heap. Runs every finalizer if `runFinalizers`
+  ## is true. If `allowGcAfterwards` is true, a minimal amount of allocation
+  ## happens to ensure the GC can continue to work after the call
+  ## to `deallocHeap`.
+  template deallocCell(x) =
+    if isCell(x):
+      # cast to PCell is correct here:
+      prepareDealloc(cast[PCell](x))
+
+  if runFinalizers:
+    when not declared(allObjectsAsProc):
+      for x in allObjects(gch.region):
+        deallocCell(x)
+    else:
+      var spaceIter: ObjectSpaceIter
+      while true:
+        let x = allObjectsAsProc(gch.region, addr spaceIter)
+        if spaceIter.state < 0: break
+        deallocCell(x)
+
+  deallocOsPages(gch.region)
+  zeroMem(addr gch.region, sizeof(gch.region))
+  if allowGcAfterwards:
+    initGC()
+
+type
+  GlobalMarkerProc = proc () {.nimcall, benign, raises: [].}
+var
+  globalMarkersLen {.exportc.}: int
+  globalMarkers {.exportc.}: array[0..3499, GlobalMarkerProc]
+  threadLocalMarkersLen {.exportc.}: int
+  threadLocalMarkers {.exportc.}: array[0..3499, GlobalMarkerProc]
+  gHeapidGenerator: int
+
+proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
+  if globalMarkersLen <= high(globalMarkers):
+    globalMarkers[globalMarkersLen] = markerProc
+    inc globalMarkersLen
+  else:
+    cstderr.rawWrite("[GC] cannot register global variable; too many global variables")
+    rawQuit 1
+
+proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
+  if threadLocalMarkersLen <= high(threadLocalMarkers):
+    threadLocalMarkers[threadLocalMarkersLen] = markerProc
+    inc threadLocalMarkersLen
+  else:
+    cstderr.rawWrite("[GC] cannot register thread local variable; too many thread local variables")
+    rawQuit 1
diff --git a/lib/system/gc_hooks.nim b/lib/system/gc_hooks.nim
new file mode 100644
index 000000000..ace62eea0
--- /dev/null
+++ b/lib/system/gc_hooks.nim
@@ -0,0 +1,53 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2019 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Hooks for memory management. Can be used to implement custom garbage
+## collectors etc.
+
+type
+  GlobalMarkerProc = proc () {.nimcall, benign, raises: [], tags: [].}
+var
+  globalMarkersLen: int
+  globalMarkers: array[0..3499, GlobalMarkerProc]
+  threadLocalMarkersLen: int
+  threadLocalMarkers: array[0..3499, GlobalMarkerProc]
+
+proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
+  if globalMarkersLen <= high(globalMarkers):
+    globalMarkers[globalMarkersLen] = markerProc
+    inc globalMarkersLen
+  else:
+    cstderr.rawWrite("[GC] cannot register global variable; too many global variables")
+    rawQuit 1
+
+proc nimRegisterThreadLocalMarker(markerProc: GlobalMarkerProc) {.compilerproc.} =
+  if threadLocalMarkersLen <= high(threadLocalMarkers):
+    threadLocalMarkers[threadLocalMarkersLen] = markerProc
+    inc threadLocalMarkersLen
+  else:
+    cstderr.rawWrite("[GC] cannot register thread local variable; too many thread local variables")
+    rawQuit 1
+
+proc traverseGlobals*() =
+  for i in 0..globalMarkersLen-1:
+    globalMarkers[i]()
+
+proc traverseThreadLocals*() =
+  for i in 0..threadLocalMarkersLen-1:
+    threadLocalMarkers[i]()
+
+var
+  newObjHook*: proc (typ: PNimType, size: int): pointer {.nimcall, tags: [], raises: [], gcsafe.}
+  traverseObjHook*: proc (p: pointer, op: int) {.nimcall, tags: [], raises: [], gcsafe.}
+
+proc nimGCvisit(p: pointer, op: int) {.inl, compilerRtl.} =
+  traverseObjHook(p, op)
+
+proc newObj(typ: PNimType, size: int): pointer {.inl, compilerRtl.} =
+  result = newObjHook(typ, size)
diff --git a/lib/system/gc_interface.nim b/lib/system/gc_interface.nim
new file mode 100644
index 000000000..84145f33a
--- /dev/null
+++ b/lib/system/gc_interface.nim
@@ -0,0 +1,100 @@
+# ----------------- GC interface ---------------------------------------------
+const
+  usesDestructors = defined(gcDestructors) or defined(gcHooks)
+
+when not usesDestructors:
+  {.pragma: nodestroy.}
+
+when hasAlloc:
+  type
+    GC_Strategy* = enum  ## The strategy the GC should use for the application.
+      gcThroughput,      ## optimize for throughput
+      gcResponsiveness,  ## optimize for responsiveness (default)
+      gcOptimizeTime,    ## optimize for speed
+      gcOptimizeSpace    ## optimize for memory footprint
+
+when hasAlloc and not defined(js) and not usesDestructors:
+  proc GC_disable*() {.rtl, inl, benign, raises: [].}
+    ## Disables the GC. If called `n` times, `n` calls to `GC_enable`
+    ## are needed to reactivate the GC.
+    ##
+    ## Note that in most circumstances one should only disable
+    ## the mark and sweep phase with
+    ## `GC_disableMarkAndSweep <#GC_disableMarkAndSweep>`_.
+
+  proc GC_enable*() {.rtl, inl, benign, raises: [].}
+    ## Enables the GC again.
+
+  proc GC_fullCollect*() {.rtl, benign.}
+    ## Forces a full garbage collection pass.
+    ## Ordinary code does not need to call this (and should not).
+
+  proc GC_enableMarkAndSweep*() {.rtl, benign.}
+  proc GC_disableMarkAndSweep*() {.rtl, benign.}
+    ## The current implementation uses a reference counting garbage collector
+    ## with a seldomly run mark and sweep phase to free cycles. The mark and
+    ## sweep phase may take a long time and is not needed if the application
+    ## does not create cycles. Thus the mark and sweep phase can be deactivated
+    ## and activated separately from the rest of the GC.
+
+  proc GC_getStatistics*(): string {.rtl, benign.}
+    ## Returns an informative string about the GC's activity. This may be useful
+    ## for tweaking.
+
+  proc GC_ref*[T](x: ref T) {.magic: "GCref", benign.}
+  proc GC_ref*[T](x: seq[T]) {.magic: "GCref", benign.}
+  proc GC_ref*(x: string) {.magic: "GCref", benign.}
+    ## Marks the object `x` as referenced, so that it will not be freed until
+    ## it is unmarked via `GC_unref`.
+    ## If called n-times for the same object `x`,
+    ## n calls to `GC_unref` are needed to unmark `x`.
+
+  proc GC_unref*[T](x: ref T) {.magic: "GCunref", benign.}
+  proc GC_unref*[T](x: seq[T]) {.magic: "GCunref", benign.}
+  proc GC_unref*(x: string) {.magic: "GCunref", benign.}
+    ## See the documentation of `GC_ref <#GC_ref,string>`_.
+
+  proc nimGC_setStackBottom*(theStackBottom: pointer) {.compilerRtl, noinline, benign, raises: [].}
+    ## Expands operating GC stack range to `theStackBottom`. Does nothing
+      ## if current stack bottom is already lower than `theStackBottom`.
+
+when hasAlloc and defined(js):
+  template GC_disable* =
+    {.warning: "GC_disable is a no-op in JavaScript".}
+
+  template GC_enable* =
+    {.warning: "GC_enable is a no-op in JavaScript".}
+
+  template GC_fullCollect* =
+    {.warning: "GC_fullCollect is a no-op in JavaScript".}
+
+  template GC_setStrategy* =
+    {.warning: "GC_setStrategy is a no-op in JavaScript".}
+
+  template GC_enableMarkAndSweep* =
+    {.warning: "GC_enableMarkAndSweep is a no-op in JavaScript".}
+
+  template GC_disableMarkAndSweep* =
+    {.warning: "GC_disableMarkAndSweep is a no-op in JavaScript".}
+
+  template GC_ref*[T](x: ref T) =
+    {.warning: "GC_ref is a no-op in JavaScript".}
+
+  template GC_ref*[T](x: seq[T]) =
+    {.warning: "GC_ref is a no-op in JavaScript".}
+
+  template GC_ref*(x: string) =
+    {.warning: "GC_ref is a no-op in JavaScript".}
+
+  template GC_unref*[T](x: ref T) =
+    {.warning: "GC_unref is a no-op in JavaScript".}
+
+  template GC_unref*[T](x: seq[T]) =
+    {.warning: "GC_unref is a no-op in JavaScript".}
+
+  template GC_unref*(x: string) =
+    {.warning: "GC_unref is a no-op in JavaScript".}
+
+  template GC_getStatistics*(): string =
+    {.warning: "GC_getStatistics is a no-op in JavaScript".}
+    ""
diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim
new file mode 100644
index 000000000..c885a6893
--- /dev/null
+++ b/lib/system/gc_ms.nim
@@ -0,0 +1,526 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# A simple mark&sweep garbage collector for Nim. Define the
+# symbol ``gcUseBitvectors`` to generate a variant of this GC.
+
+{.push profiler:off.}
+
+const
+  InitialThreshold = 4*1024*1024 # X MB because marking&sweeping is slow
+  withBitvectors = defined(gcUseBitvectors)
+  # bitvectors are significantly faster for GC-bench, but slower for
+  # bootstrapping and use more memory
+  rcWhite = 0
+  rcGrey = 1   # unused
+  rcBlack = 2
+
+template mulThreshold(x): untyped = x * 2
+
+when defined(memProfiler):
+  proc nimProfile(requestedSize: int)
+
+when hasThreadSupport:
+  import std/sharedlist
+
+type
+  WalkOp = enum
+    waMarkGlobal,  # we need to mark conservatively for global marker procs
+                   # as these may refer to a global var and not to a thread
+                   # local
+    waMarkPrecise  # fast precise marking
+
+  Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign, raises: [].}
+    # A ref type can have a finalizer that is called before the object's
+    # storage is freed.
+
+  GcStat = object
+    collections: int         # number of performed full collections
+    maxThreshold: int        # max threshold that has been set
+    maxStackSize: int        # max stack size
+    freedObjects: int        # max entries in cycle table
+
+  GcStack {.final, pure.} = object
+    when nimCoroutines:
+      prev: ptr GcStack
+      next: ptr GcStack
+      maxStackSize: int      # Used to track statistics because we can not use
+                             # GcStat.maxStackSize when multiple stacks exist.
+    bottom: pointer
+
+    when nimCoroutines:
+      pos: pointer
+
+  GcHeap = object            # this contains the zero count and
+                             # non-zero count table
+    stack: GcStack
+    when nimCoroutines:
+      activeStack: ptr GcStack    # current executing coroutine stack.
+    cycleThreshold: int
+    when useCellIds:
+      idGenerator: int
+    when withBitvectors:
+      allocated, marked: CellSet
+    tempStack: CellSeq       # temporary stack for recursion elimination
+    recGcLock: int           # prevent recursion via finalizers; no thread lock
+    region: MemRegion        # garbage collected region
+    stat: GcStat
+    when hasThreadSupport:
+      toDispose: SharedList[pointer]
+    gcThreadId: int
+    additionalRoots: CellSeq # dummy roots for GC_ref/unref
+    when defined(nimTracing):
+      tracing: bool
+      indentation: int
+
+var
+  gch {.rtlThreadVar.}: GcHeap
+
+when not defined(useNimRtl):
+  instantiateForRegion(gch.region)
+
+template gcAssert(cond: bool, msg: string) =
+  when defined(useGcAssert):
+    if not cond:
+      cstderr.rawWrite "[GCASSERT] "
+      cstderr.rawWrite msg
+      rawQuit 1
+
+proc cellToUsr(cell: PCell): pointer {.inline.} =
+  # convert object (=pointer to refcount) to pointer to userdata
+  result = cast[pointer](cast[int](cell)+%ByteAddress(sizeof(Cell)))
+
+proc usrToCell(usr: pointer): PCell {.inline.} =
+  # convert pointer to userdata to object (=pointer to refcount)
+  result = cast[PCell](cast[int](usr)-%ByteAddress(sizeof(Cell)))
+
+proc extGetCellType(c: pointer): PNimType {.compilerproc.} =
+  # used for code generation concerning debugging
+  result = usrToCell(c).typ
+
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.inline, compilerproc.} =
+  dest[] = src
+
+proc internRefcount(p: pointer): int {.exportc: "getRefcount".} =
+  result = 0
+
+# this that has to equals zero, otherwise we have to round up UnitsPerPage:
+when BitsPerPage mod (sizeof(int)*8) != 0:
+  {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".}
+
+# forward declarations:
+proc collectCT(gch: var GcHeap; size: int) {.benign, raises: [].}
+proc forAllChildren(cell: PCell, op: WalkOp) {.benign, raises: [].}
+proc doOperation(p: pointer, op: WalkOp) {.benign, raises: [].}
+proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign, raises: [].}
+# we need the prototype here for debugging purposes
+
+when defined(nimGcRefLeak):
+  const
+    MaxTraceLen = 20 # tracking the last 20 calls is enough
+
+  type
+    GcStackTrace = object
+      lines: array[0..MaxTraceLen-1, cstring]
+      files: array[0..MaxTraceLen-1, cstring]
+
+  proc captureStackTrace(f: PFrame, st: var GcStackTrace) =
+    const
+      firstCalls = 5
+    var
+      it = f
+      i = 0
+      total = 0
+    while it != nil and i <= high(st.lines)-(firstCalls-1):
+      # the (-1) is for the "..." entry
+      st.lines[i] = it.procname
+      st.files[i] = it.filename
+      inc(i)
+      inc(total)
+      it = it.prev
+    var b = it
+    while it != nil:
+      inc(total)
+      it = it.prev
+    for j in 1..total-i-(firstCalls-1):
+      if b != nil: b = b.prev
+    if total != i:
+      st.lines[i] = "..."
+      st.files[i] = "..."
+      inc(i)
+    while b != nil and i <= high(st.lines):
+      st.lines[i] = b.procname
+      st.files[i] = b.filename
+      inc(i)
+      b = b.prev
+
+  var ax: array[10_000, GcStackTrace]
+
+proc nimGCref(p: pointer) {.compilerproc.} =
+  # we keep it from being collected by pretending it's not even allocated:
+  when false:
+    when withBitvectors: excl(gch.allocated, usrToCell(p))
+    else: usrToCell(p).refcount = rcBlack
+  when defined(nimGcRefLeak):
+    captureStackTrace(framePtr, ax[gch.additionalRoots.len])
+  add(gch.additionalRoots, usrToCell(p))
+
+proc nimGCunref(p: pointer) {.compilerproc.} =
+  let cell = usrToCell(p)
+  var L = gch.additionalRoots.len-1
+  var i = L
+  let d = gch.additionalRoots.d
+  while i >= 0:
+    if d[i] == cell:
+      d[i] = d[L]
+      when defined(nimGcRefLeak):
+        ax[i] = ax[L]
+      dec gch.additionalRoots.len
+      break
+    dec(i)
+  when false:
+    when withBitvectors: incl(gch.allocated, usrToCell(p))
+    else: usrToCell(p).refcount = rcWhite
+
+when defined(nimGcRefLeak):
+  proc writeLeaks() =
+    for i in 0..gch.additionalRoots.len-1:
+      c_fprintf(stdout, "[Heap] NEW STACK TRACE\n")
+      for ii in 0..MaxTraceLen-1:
+        let line = ax[i].lines[ii]
+        let file = ax[i].files[ii]
+        if isNil(line): break
+        c_fprintf(stdout, "[Heap] %s(%s)\n", file, line)
+
+include gc_common
+
+proc initGC() =
+  when not defined(useNimRtl):
+    gch.cycleThreshold = InitialThreshold
+    gch.stat.collections = 0
+    gch.stat.maxThreshold = 0
+    gch.stat.maxStackSize = 0
+    init(gch.tempStack)
+    init(gch.additionalRoots)
+    when withBitvectors:
+      init(gch.allocated)
+      init(gch.marked)
+    when hasThreadSupport:
+      init(gch.toDispose)
+    gch.gcThreadId = atomicInc(gHeapidGenerator) - 1
+    gcAssert(gch.gcThreadId >= 0, "invalid computed thread ID")
+
+proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) {.benign.} =
+  var d = cast[int](dest)
+  case n.kind
+  of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op)
+  of nkList:
+    for i in 0..n.len-1:
+      forAllSlotsAux(dest, n.sons[i], op)
+  of nkCase:
+    var m = selectBranch(dest, n)
+    if m != nil: forAllSlotsAux(dest, m, op)
+  of nkNone: sysAssert(false, "forAllSlotsAux")
+
+proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) =
+  var d = cast[int](dest)
+  if dest == nil: return # nothing to do
+  if ntfNoRefs notin mt.flags:
+    case mt.kind
+    of tyRef, tyString, tySequence: # leaf:
+      doOperation(cast[PPointer](d)[], op)
+    of tyObject, tyTuple:
+      forAllSlotsAux(dest, mt.node, op)
+    of tyArray, tyArrayConstr, tyOpenArray:
+      for i in 0..(mt.size div mt.base.size)-1:
+        forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op)
+    else: discard
+
+proc forAllChildren(cell: PCell, op: WalkOp) =
+  gcAssert(cell != nil, "forAllChildren: 1")
+  gcAssert(cell.typ != nil, "forAllChildren: 2")
+  gcAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: 3"
+  let marker = cell.typ.marker
+  if marker != nil:
+    marker(cellToUsr(cell), op.int)
+  else:
+    case cell.typ.kind
+    of tyRef: # common case
+      forAllChildrenAux(cellToUsr(cell), cell.typ.base, op)
+    of tySequence:
+      when not defined(nimSeqsV2):
+        var d = cast[int](cellToUsr(cell))
+        var s = cast[PGenericSeq](d)
+        if s != nil:
+          for i in 0..s.len-1:
+            forAllChildrenAux(cast[pointer](d +% align(GenericSeqSize, cell.typ.base.align) +% i *% cell.typ.base.size), cell.typ.base, op)
+    else: discard
+
+proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer =
+  # generates a new object and sets its reference counter to 0
+  incTypeSize typ, size
+  gcAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1")
+  collectCT(gch, size + sizeof(Cell))
+  var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell)))
+  gcAssert((cast[int](res) and (MemAlign-1)) == 0, "newObj: 2")
+  # now it is buffered in the ZCT
+  res.typ = typ
+  when leakDetector and not hasThreadSupport:
+    if framePtr != nil and framePtr.prev != nil:
+      res.filename = framePtr.prev.filename
+      res.line = framePtr.prev.line
+  res.refcount = 0
+  when withBitvectors: incl(gch.allocated, res)
+  when useCellIds:
+    inc gch.idGenerator
+    res.id = gch.idGenerator
+  result = cellToUsr(res)
+
+when useCellIds:
+  proc getCellId*[T](x: ref T): int =
+    let p = usrToCell(cast[pointer](x))
+    result = p.id
+
+{.pop.}
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  result = rawNewObj(typ, size, gch)
+  zeroMem(result, size)
+  when defined(memProfiler): nimProfile(size)
+
+proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  result = rawNewObj(typ, size, gch)
+  when defined(memProfiler): nimProfile(size)
+
+proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  result = rawNewObj(typ, size, gch)
+  zeroMem(result, size)
+  when defined(memProfiler): nimProfile(size)
+
+when not defined(nimSeqsV2):
+  {.push overflowChecks: on.}
+  proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} =
+    # `newObj` already uses locks, so no need for them here.
+    let size = align(GenericSeqSize, typ.base.align) + len * typ.base.size
+    result = newObj(typ, size)
+    cast[PGenericSeq](result).len = len
+    cast[PGenericSeq](result).reserved = len
+    when defined(memProfiler): nimProfile(size)
+
+  proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
+    let size = align(GenericSeqSize, typ.base.align) + len * typ.base.size
+    result = newObj(typ, size)
+    cast[PGenericSeq](result).len = len
+    cast[PGenericSeq](result).reserved = len
+    when defined(memProfiler): nimProfile(size)
+  {.pop.}
+
+  proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer =
+    collectCT(gch, newsize + sizeof(Cell))
+    var ol = usrToCell(old)
+    sysAssert(ol.typ != nil, "growObj: 1")
+    gcAssert(ol.typ.kind in {tyString, tySequence}, "growObj: 2")
+
+    var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell)))
+    var elemSize, elemAlign = 1
+    if ol.typ.kind != tyString:
+      elemSize = ol.typ.base.size
+      elemAlign = ol.typ.base.align
+    incTypeSize ol.typ, newsize
+
+    var oldsize = align(GenericSeqSize, elemAlign) + cast[PGenericSeq](old).len*elemSize
+    copyMem(res, ol, oldsize + sizeof(Cell))
+    zeroMem(cast[pointer](cast[int](res)+% oldsize +% sizeof(Cell)),
+            newsize-oldsize)
+    sysAssert((cast[int](res) and (MemAlign-1)) == 0, "growObj: 3")
+    when withBitvectors: incl(gch.allocated, res)
+    when useCellIds:
+      inc gch.idGenerator
+      res.id = gch.idGenerator
+    result = cellToUsr(res)
+    when defined(memProfiler): nimProfile(newsize-oldsize)
+
+  proc growObj(old: pointer, newsize: int): pointer {.rtl.} =
+    result = growObj(old, newsize, gch)
+
+{.push profiler:off.}
+
+# ----------------- collector -----------------------------------------------
+
+proc mark(gch: var GcHeap, c: PCell) =
+  when hasThreadSupport:
+    for c in gch.toDispose:
+      nimGCunref(c)
+  when withBitvectors:
+    incl(gch.marked, c)
+    gcAssert gch.tempStack.len == 0, "stack not empty!"
+    forAllChildren(c, waMarkPrecise)
+    while gch.tempStack.len > 0:
+      dec gch.tempStack.len
+      var d = gch.tempStack.d[gch.tempStack.len]
+      if not containsOrIncl(gch.marked, d):
+        forAllChildren(d, waMarkPrecise)
+  else:
+    # XXX no 'if c.refCount != rcBlack' here?
+    when defined(nimTracing):
+      if gch.tracing:
+        for i in 1..gch.indentation: c_fprintf(stdout, " ")
+        c_fprintf(stdout, "start marking %p of type %s ((\n",
+                  c, c.typ.name)
+        inc gch.indentation, 2
+
+    c.refcount = rcBlack
+    gcAssert gch.tempStack.len == 0, "stack not empty!"
+    forAllChildren(c, waMarkPrecise)
+    while gch.tempStack.len > 0:
+      dec gch.tempStack.len
+      var d = gch.tempStack.d[gch.tempStack.len]
+      if d.refcount == rcWhite:
+        d.refcount = rcBlack
+        forAllChildren(d, waMarkPrecise)
+
+    when defined(nimTracing):
+      if gch.tracing:
+        dec gch.indentation, 2
+        for i in 1..gch.indentation: c_fprintf(stdout, " ")
+        c_fprintf(stdout, "finished marking %p of type %s))\n",
+                  c, c.typ.name)
+
+proc doOperation(p: pointer, op: WalkOp) =
+  if p == nil: return
+  var c: PCell = usrToCell(p)
+  gcAssert(c != nil, "doOperation: 1")
+  case op
+  of waMarkGlobal: mark(gch, c)
+  of waMarkPrecise:
+    when defined(nimTracing):
+      if c.refcount == rcWhite: mark(gch, c)
+    else:
+      add(gch.tempStack, c)
+
+proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} =
+  doOperation(d, WalkOp(op))
+
+proc freeCyclicCell(gch: var GcHeap, c: PCell) =
+  inc gch.stat.freedObjects
+  prepareDealloc(c)
+  when reallyDealloc: rawDealloc(gch.region, c)
+  else:
+    gcAssert(c.typ != nil, "freeCyclicCell")
+    zeroMem(c, sizeof(Cell))
+
+proc sweep(gch: var GcHeap) =
+  when withBitvectors:
+    for c in gch.allocated.elementsExcept(gch.marked):
+      gch.allocated.excl(c)
+      freeCyclicCell(gch, c)
+  else:
+    for x in allObjects(gch.region):
+      if isCell(x):
+        # cast to PCell is correct here:
+        var c = cast[PCell](x)
+        if c.refcount == rcBlack: c.refcount = rcWhite
+        else: freeCyclicCell(gch, c)
+
+proc markGlobals(gch: var GcHeap) =
+  if gch.gcThreadId == 0:
+    when defined(nimTracing):
+      if gch.tracing:
+        c_fprintf(stdout, "------- globals marking phase:\n")
+    for i in 0 .. globalMarkersLen-1: globalMarkers[i]()
+  when defined(nimTracing):
+    if gch.tracing:
+      c_fprintf(stdout, "------- thread locals marking phase:\n")
+  for i in 0 .. threadLocalMarkersLen-1: threadLocalMarkers[i]()
+  when defined(nimTracing):
+    if gch.tracing:
+      c_fprintf(stdout, "------- additional roots marking phase:\n")
+  let d = gch.additionalRoots.d
+  for i in 0 .. gch.additionalRoots.len-1: mark(gch, d[i])
+
+proc gcMark(gch: var GcHeap, p: pointer) {.inline.} =
+  # the addresses are not as cells on the stack, so turn them to cells:
+  var c = cast[int](p)
+  if c >% PageSize:
+    # fast check: does it look like a cell?
+    var objStart = cast[PCell](interiorAllocatedPtr(gch.region, p))
+    if objStart != nil:
+      mark(gch, objStart)
+
+proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} =
+  forEachStackSlot(gch, gcMark)
+
+proc collectCTBody(gch: var GcHeap) =
+  when not nimCoroutines:
+    gch.stat.maxStackSize = max(gch.stat.maxStackSize, stackSize())
+  when defined(nimTracing):
+    if gch.tracing:
+      c_fprintf(stdout, "------- stack marking phase:\n")
+  prepareForInteriorPointerChecking(gch.region)
+  markStackAndRegisters(gch)
+  markGlobals(gch)
+  sweep(gch)
+
+  inc(gch.stat.collections)
+  when withBitvectors:
+    deinit(gch.marked)
+    init(gch.marked)
+  gch.cycleThreshold = max(InitialThreshold, getOccupiedMem().mulThreshold)
+  gch.stat.maxThreshold = max(gch.stat.maxThreshold, gch.cycleThreshold)
+  sysAssert(allocInv(gch.region), "collectCT: end")
+
+proc collectCT(gch: var GcHeap; size: int) =
+  let fmem = getFreeMem(gch.region)
+  if (getOccupiedMem(gch.region) >= gch.cycleThreshold or
+      size > fmem and fmem > InitialThreshold) and gch.recGcLock == 0:
+    collectCTBody(gch)
+
+when not defined(useNimRtl):
+  proc GC_disable() =
+    inc(gch.recGcLock)
+  proc GC_enable() =
+    when defined(nimDoesntTrackDefects):
+      if gch.recGcLock <= 0:
+        raise newException(AssertionDefect,
+            "API usage error: GC_enable called but GC is already enabled")
+    dec(gch.recGcLock)
+
+  proc GC_setStrategy(strategy: GC_Strategy) = discard
+
+  proc GC_enableMarkAndSweep() =
+    gch.cycleThreshold = InitialThreshold
+
+  proc GC_disableMarkAndSweep() =
+    gch.cycleThreshold = high(typeof(gch.cycleThreshold))-1
+    # set to the max value to suppress the cycle detector
+
+  when defined(nimTracing):
+    proc GC_logTrace*() =
+      gch.tracing = true
+
+  proc GC_fullCollect() =
+    let oldThreshold = gch.cycleThreshold
+    gch.cycleThreshold = 0 # forces cycle collection
+    collectCT(gch, 0)
+    gch.cycleThreshold = oldThreshold
+
+  proc GC_getStatistics(): string =
+    result = "[GC] total memory: " & $getTotalMem() & "\n" &
+             "[GC] occupied memory: " & $getOccupiedMem() & "\n" &
+             "[GC] collections: " & $gch.stat.collections & "\n" &
+             "[GC] max threshold: " & $gch.stat.maxThreshold & "\n" &
+             "[GC] freed objects: " & $gch.stat.freedObjects & "\n"
+    when nimCoroutines:
+      result.add "[GC] number of stacks: " & $gch.stack.len & "\n"
+      for stack in items(gch.stack):
+        result.add "[GC]   stack " & stack.bottom.repr & "[GC]     max stack size " & $stack.maxStackSize & "\n"
+    else:
+      result.add "[GC] max stack size: " & $gch.stat.maxStackSize & "\n"
+
+{.pop.}
diff --git a/lib/system/gc_regions.nim b/lib/system/gc_regions.nim
new file mode 100644
index 000000000..d96de7eac
--- /dev/null
+++ b/lib/system/gc_regions.nim
@@ -0,0 +1,442 @@
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# "Stack GC" for embedded devices or ultra performance requirements.
+import std/private/syslocks
+
+when defined(memProfiler):
+  proc nimProfile(requestedSize: int) {.benign.}
+
+when defined(useMalloc):
+  proc roundup(x, v: int): int {.inline.} =
+    result = (x + (v-1)) and not (v-1)
+  proc emalloc(size: int): pointer {.importc: "malloc", header: "<stdlib.h>".}
+  proc efree(mem: pointer) {.importc: "free", header: "<stdlib.h>".}
+
+  proc osAllocPages(size: int): pointer {.inline.} =
+    emalloc(size)
+
+  proc osTryAllocPages(size: int): pointer {.inline.} =
+    emalloc(size)
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    efree(p)
+
+else:
+  include osalloc
+
+# We manage memory as a thread local stack. Since the allocation pointer
+# is detached from the control flow pointer, this model is vastly more
+# useful than the traditional programming model while almost as safe.
+# Individual objects can also be deleted but no coalescing is performed.
+# Stacks can also be moved from one thread to another.
+
+# We also support 'finalizers'.
+
+type
+  Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.}
+    # A ref type can have a finalizer that is called before the object's
+    # storage is freed.
+
+  AlignType = BiggestFloat
+  ObjHeader = object
+    typ: PNimType
+    nextFinal: ptr ObjHeader # next object with finalizer
+
+  Chunk = ptr BaseChunk
+  BaseChunk = object
+    next: Chunk
+    size: int
+    head, tail: ptr ObjHeader # first and last object in chunk that
+                              # has a finalizer attached to it
+
+const
+  MaxSmallObject = 128
+
+type
+  FreeEntry = ptr object
+    next: FreeEntry
+  SizedFreeEntry = ptr object
+    next: SizedFreeEntry
+    size: int
+  StackPtr = object
+    bump: pointer
+    remaining: int
+    current: Chunk
+
+  MemRegion* = object
+    remaining: int
+    bump: pointer
+    head, tail: Chunk
+    nextChunkSize, totalSize: int
+    when false:
+      freeLists: array[MaxSmallObject div MemAlign, FreeEntry]
+      holes: SizedFreeEntry
+    when hasThreadSupport:
+      lock: SysLock
+
+  SeqHeader = object # minor hack ahead: Since we know that seqs
+                     # and strings cannot have finalizers, we use the field
+                     # instead for a 'region' field so that they can grow
+                     # and shrink safely.
+    typ: PNimType
+    region: ptr MemRegion
+
+var
+  tlRegion {.threadvar.}: MemRegion
+#  tempStrRegion {.threadvar.}: MemRegion  # not yet used
+
+template withRegion*(r: var MemRegion; body: untyped) =
+  let oldRegion = tlRegion
+  tlRegion = r
+  try:
+    body
+  finally:
+    r = tlRegion
+    tlRegion = oldRegion
+
+template inc(p: pointer, s: int) =
+  p = cast[pointer](cast[int](p) +% s)
+
+template dec(p: pointer, s: int) =
+  p = cast[pointer](cast[int](p) -% s)
+
+template `+!`(p: pointer, s: int): pointer =
+  cast[pointer](cast[int](p) +% s)
+
+template `-!`(p: pointer, s: int): pointer =
+  cast[pointer](cast[int](p) -% s)
+
+const nimMinHeapPages {.intdefine.} = 4
+
+proc allocSlowPath(r: var MemRegion; size: int) =
+  # we need to ensure that the underlying linked list
+  # stays small. Say we want to grab 16GB of RAM with some
+  # exponential growth function. So we allocate 16KB, then
+  # 32 KB, 64 KB, 128KB, 256KB, 512KB, 1MB, 2MB, 4MB,
+  # 8MB, 16MB, 32MB, 64MB, 128MB, 512MB, 1GB, 2GB, 4GB, 8GB,
+  # 16GB --> list contains only 20 elements! That's reasonable.
+  if (r.totalSize and 1) == 0:
+    r.nextChunkSize = if r.totalSize < 64 * 1024: PageSize*nimMinHeapPages
+                      else: r.nextChunkSize*2
+  var s = roundup(size+sizeof(BaseChunk), PageSize)
+  var fresh: Chunk
+  if s > r.nextChunkSize:
+    fresh = cast[Chunk](osAllocPages(s))
+  else:
+    fresh = cast[Chunk](osTryAllocPages(r.nextChunkSize))
+    if fresh == nil:
+      fresh = cast[Chunk](osAllocPages(s))
+      # lowest bit in totalSize is the "don't increase nextChunkSize"
+      inc r.totalSize
+    else:
+      s = r.nextChunkSize
+  fresh.size = s
+  fresh.head = nil
+  fresh.tail = nil
+  fresh.next = nil
+  inc r.totalSize, s
+  let old = r.tail
+  if old == nil:
+    r.head = fresh
+  else:
+    r.tail.next = fresh
+  r.bump = fresh +! sizeof(BaseChunk)
+  r.tail = fresh
+  r.remaining = s - sizeof(BaseChunk)
+
+proc allocFast(r: var MemRegion; size: int): pointer =
+  when false:
+    if size <= MaxSmallObject:
+      var it = r.freeLists[size div MemAlign]
+      if it != nil:
+        r.freeLists[size div MemAlign] = it.next
+        return pointer(it)
+    else:
+      var it = r.holes
+      var prev: SizedFreeEntry = nil
+      while it != nil:
+        if it.size >= size:
+          if prev != nil: prev.next = it.next
+          else: r.holes = it.next
+          return pointer(it)
+        prev = it
+        it = it.next
+  let size = roundup(size, MemAlign)
+  if size > r.remaining:
+    allocSlowPath(r, size)
+  sysAssert(size <= r.remaining, "size <= r.remaining")
+  dec(r.remaining, size)
+  result = r.bump
+  inc r.bump, size
+
+proc runFinalizers(c: Chunk) =
+  var it = c.head
+  while it != nil:
+    # indivually freed objects with finalizer stay in the list, but
+    # their typ is nil then:
+    if it.typ != nil and it.typ.finalizer != nil:
+      (cast[Finalizer](it.typ.finalizer))(it+!sizeof(ObjHeader))
+    it = it.nextFinal
+
+proc runFinalizers(c: Chunk; newbump: pointer) =
+  var it = c.head
+  var prev: ptr ObjHeader = nil
+  while it != nil:
+    let nxt = it.nextFinal
+    if it >= newbump:
+      if it.typ != nil and it.typ.finalizer != nil:
+        (cast[Finalizer](it.typ.finalizer))(it+!sizeof(ObjHeader))
+    elif prev != nil:
+      prev.nextFinal = nil
+    prev = it
+    it = nxt
+
+proc dealloc(r: var MemRegion; p: pointer; size: int) =
+  let it = cast[ptr ObjHeader](p-!sizeof(ObjHeader))
+  if it.typ != nil and it.typ.finalizer != nil:
+    (cast[Finalizer](it.typ.finalizer))(p)
+  it.typ = nil
+  # it is beneficial to not use the free lists here:
+  if r.bump -! size == p:
+    dec r.bump, size
+  when false:
+    if size <= MaxSmallObject:
+      let it = cast[FreeEntry](p)
+      it.next = r.freeLists[size div MemAlign]
+      r.freeLists[size div MemAlign] = it
+    else:
+      let it = cast[SizedFreeEntry](p)
+      it.size = size
+      it.next = r.holes
+      r.holes = it
+
+proc deallocAll(r: var MemRegion; head: Chunk) =
+  var it = head
+  while it != nil:
+    let nxt = it.next
+    runFinalizers(it)
+    dec r.totalSize, it.size
+    osDeallocPages(it, it.size)
+    it = nxt
+
+proc deallocAll*(r: var MemRegion) =
+  deallocAll(r, r.head)
+  zeroMem(addr r, sizeof r)
+
+proc obstackPtr*(r: MemRegion): StackPtr =
+  result.bump = r.bump
+  result.remaining = r.remaining
+  result.current = r.tail
+
+template computeRemaining(r): untyped =
+  r.tail.size -% (cast[int](r.bump) -% cast[int](r.tail))
+
+proc setObstackPtr*(r: var MemRegion; sp: StackPtr) =
+  # free everything after 'sp':
+  if sp.current != nil and sp.current.next != nil:
+    deallocAll(r, sp.current.next)
+    sp.current.next = nil
+    when false:
+      # better leak this memory than be sorry:
+      for i in 0..high(r.freeLists): r.freeLists[i] = nil
+      r.holes = nil
+  if r.tail != nil: runFinalizers(r.tail, sp.bump)
+
+  r.bump = sp.bump
+  r.tail = sp.current
+  r.remaining = sp.remaining
+
+proc obstackPtr*(): StackPtr = tlRegion.obstackPtr()
+proc setObstackPtr*(sp: StackPtr) = tlRegion.setObstackPtr(sp)
+proc deallocAll*() = tlRegion.deallocAll()
+
+proc deallocOsPages(r: var MemRegion) = r.deallocAll()
+
+when false:
+  let obs = obstackPtr()
+  try:
+    body
+  finally:
+    setObstackPtr(obs)
+
+template withScratchRegion*(body: untyped) =
+  let oldRegion = tlRegion
+  tlRegion = MemRegion()
+  try:
+    body
+  finally:
+    deallocAll()
+    tlRegion = oldRegion
+
+when false:
+  proc joinRegion*(dest: var MemRegion; src: MemRegion) =
+    # merging is not hard.
+    if dest.head.isNil:
+      dest.head = src.head
+    else:
+      dest.tail.next = src.head
+    dest.tail = src.tail
+    dest.bump = src.bump
+    dest.remaining = src.remaining
+    dest.nextChunkSize = max(dest.nextChunkSize, src.nextChunkSize)
+    inc dest.totalSize, src.totalSize
+
+proc isOnHeap*(r: MemRegion; p: pointer): bool =
+  # the tail chunk is the largest, so check it first. It's also special
+  # in that contains the current bump pointer:
+  if r.tail >= p and p < r.bump:
+    return true
+  var it = r.head
+  while it != r.tail:
+    if it >= p and p <= it+!it.size: return true
+    it = it.next
+
+proc rawNewObj(r: var MemRegion, typ: PNimType, size: int): pointer =
+  var res = cast[ptr ObjHeader](allocFast(r, size + sizeof(ObjHeader)))
+  res.typ = typ
+  if typ.finalizer != nil:
+    res.nextFinal = r.head.head
+    r.head.head = res
+  result = res +! sizeof(ObjHeader)
+
+proc rawNewSeq(r: var MemRegion, typ: PNimType, size: int): pointer =
+  var res = cast[ptr SeqHeader](allocFast(r, size + sizeof(SeqHeader)))
+  res.typ = typ
+  res.region = addr(r)
+  result = res +! sizeof(SeqHeader)
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  sysAssert typ.kind notin {tySequence, tyString}, "newObj cannot be used to construct seqs"
+  result = rawNewObj(tlRegion, typ, size)
+  zeroMem(result, size)
+  when defined(memProfiler): nimProfile(size)
+
+proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  sysAssert typ.kind notin {tySequence, tyString}, "newObj cannot be used to construct seqs"
+  result = rawNewObj(tlRegion, typ, size)
+  when defined(memProfiler): nimProfile(size)
+
+{.push overflowChecks: on.}
+proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} =
+  let size = roundup(align(GenericSeqSize, typ.base.align) + len * typ.base.size, MemAlign)
+  result = rawNewSeq(tlRegion, typ, size)
+  zeroMem(result, size)
+  cast[PGenericSeq](result).len = len
+  cast[PGenericSeq](result).reserved = len
+
+proc newStr(typ: PNimType, len: int; init: bool): pointer {.compilerRtl.} =
+  let size = roundup(len + GenericSeqSize, MemAlign)
+  result = rawNewSeq(tlRegion, typ, size)
+  if init: zeroMem(result, size)
+  cast[PGenericSeq](result).len = 0
+  cast[PGenericSeq](result).reserved = len
+{.pop.}
+
+proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  result = rawNewObj(tlRegion, typ, size)
+  zeroMem(result, size)
+
+proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
+  result = newSeq(typ, len)
+
+proc growObj(regionUnused: var MemRegion; old: pointer, newsize: int): pointer =
+  let sh = cast[ptr SeqHeader](old -! sizeof(SeqHeader))
+  let typ = sh.typ
+  result = rawNewSeq(sh.region[], typ,
+                     roundup(newsize, MemAlign))
+  let elemSize = if typ.kind == tyString: 1 else: typ.base.size
+  let elemAlign = if typ.kind == tyString: 1 else: typ.base.align
+  let oldsize = align(GenericSeqSize, elemAlign) + cast[PGenericSeq](old).len*elemSize
+  zeroMem(result +! oldsize, newsize-oldsize)
+  copyMem(result, old, oldsize)
+  dealloc(sh.region[], old, roundup(oldsize, MemAlign))
+
+proc growObj(old: pointer, newsize: int): pointer {.rtl.} =
+  result = growObj(tlRegion, old, newsize)
+
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
+
+proc allocImpl(size: Natural): pointer =
+  result = c_malloc(cast[csize_t](size))
+  if result == nil: raiseOutOfMem()
+proc alloc0Impl(size: Natural): pointer =
+  result = alloc(size)
+  zeroMem(result, size)
+proc reallocImpl(p: pointer, newsize: Natural): pointer =
+  result = c_realloc(p, cast[csize_t](newsize))
+  if result == nil: raiseOutOfMem()
+proc realloc0Impl(p: pointer, oldsize, newsize: Natural): pointer =
+  result = c_realloc(p, cast[csize_t](newsize))
+  if result == nil: raiseOutOfMem()
+  if newsize > oldsize:
+    zeroMem(cast[pointer](cast[int](result) + oldsize), newsize - oldsize)
+proc deallocImpl(p: pointer) = c_free(p)
+
+proc alloc0(r: var MemRegion; size: Natural): pointer =
+  # ignore the region. That is correct for the channels module
+  # but incorrect in general. XXX
+  result = alloc0(size)
+
+proc alloc(r: var MemRegion; size: Natural): pointer =
+  # ignore the region. That is correct for the channels module
+  # but incorrect in general. XXX
+  result = alloc(size)
+
+proc dealloc(r: var MemRegion; p: pointer) = dealloc(p)
+
+proc allocSharedImpl(size: Natural): pointer =
+  result = c_malloc(cast[csize_t](size))
+  if result == nil: raiseOutOfMem()
+proc allocShared0Impl(size: Natural): pointer =
+  result = alloc(size)
+  zeroMem(result, size)
+proc reallocSharedImpl(p: pointer, newsize: Natural): pointer =
+  result = c_realloc(p, cast[csize_t](newsize))
+  if result == nil: raiseOutOfMem()
+proc reallocShared0Impl(p: pointer, oldsize, newsize: Natural): pointer =
+  result = c_realloc(p, cast[csize_t](newsize))
+  if result == nil: raiseOutOfMem()
+  if newsize > oldsize:
+    zeroMem(cast[pointer](cast[int](result) + oldsize), newsize - oldsize)
+proc deallocSharedImpl(p: pointer) = c_free(p)
+
+when hasThreadSupport:
+  proc getFreeSharedMem(): int = 0
+  proc getTotalSharedMem(): int = 0
+  proc getOccupiedSharedMem(): int = 0
+
+proc GC_disable() = discard
+proc GC_enable() = discard
+proc GC_fullCollect() = discard
+proc GC_setStrategy(strategy: GC_Strategy) = discard
+proc GC_enableMarkAndSweep() = discard
+proc GC_disableMarkAndSweep() = discard
+proc GC_getStatistics(): string = return ""
+
+proc getOccupiedMem(): int =
+  result = tlRegion.totalSize - tlRegion.remaining
+proc getFreeMem(): int = tlRegion.remaining
+proc getTotalMem(): int =
+  result = tlRegion.totalSize
+
+proc getOccupiedMem*(r: MemRegion): int =
+  result = r.totalSize - r.remaining
+proc getFreeMem*(r: MemRegion): int = r.remaining
+proc getTotalMem*(r: MemRegion): int =
+  result = r.totalSize
+
+proc nimGC_setStackBottom(theStackBottom: pointer) = discard
+
+proc nimGCref(x: pointer) {.compilerproc.} = discard
+proc nimGCunref(x: pointer) {.compilerproc.} = discard
diff --git a/lib/system/hti.nim b/lib/system/hti.nim
index 3343000ae..a26aff982 100755..100644
--- a/lib/system/hti.nim
+++ b/lib/system/hti.nim
@@ -1,18 +1,26 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-type # This should be he same as ast.TTypeKind
-     # many enum fields are not used at runtime
+type
+  # This should be the same as ast.TTypeKind
+  # many enum fields are not used at runtime
   TNimKind = enum
-    tyNone, tyBool, tyChar,
-    tyEmpty, tyArrayConstr, tyNil, tyExpr, tyStmt, tyTypeDesc,
-    tyGenericInvokation, # ``T[a, b]`` for types to invoke
+    tyNone,
+    tyBool,
+    tyChar,
+    tyEmpty,
+    tyArrayConstr,
+    tyNil,
+    tyUntyped,
+    tyTyped,
+    tyTypeDesc,
+    tyGenericInvocation, # ``T[a, b]`` for types to invoke
     tyGenericBody,       # ``T[a, b, body]`` last parameter is the body
     tyGenericInst,       # ``T[a, b, realInstance]`` instantiated generic type
     tyGenericParam,      # ``a`` in the example
@@ -21,38 +29,95 @@ type # This should be he same as ast.TTypeKind
     tyOrdinal,
     tyArray,
     tyObject,
-    tyTuple,
+    tyTuple,             # WARNING: The compiler uses tyTuple for pure objects!
     tySet,
     tyRange,
-    tyPtr, tyRef,
+    tyPtr,
+    tyRef,
     tyVar,
     tySequence,
     tyProc,
-    tyPointer, tyOpenArray,
-    tyString, tyCString, tyForward,
-    tyInt, tyInt8, tyInt16, tyInt32, tyInt64,
-    tyFloat, tyFloat32, tyFloat64, tyFloat128,
-    tyPureObject # signals that object has no `n_type` field
+    tyPointer,
+    tyOpenArray,
+    tyString,
+    tyCstring,
+    tyForward,
+    tyInt,
+    tyInt8,
+    tyInt16,
+    tyInt32,
+    tyInt64,
+    tyFloat,
+    tyFloat32,
+    tyFloat64,
+    tyFloat128,
+    tyUInt,
+    tyUInt8,
+    tyUInt16,
+    tyUInt32,
+    tyUInt64,
+    tyOwned, tyUnused1, tyUnused2,
+    tyVarargsHidden,
+    tyUncheckedArray,
+    tyErrorHidden,
+    tyBuiltInTypeClassHidden,
+    tyUserTypeClassHidden,
+    tyUserTypeClassInstHidden,
+    tyCompositeTypeClassHidden,
+    tyInferredHidden,
+    tyAndHidden, tyOrHidden, tyNotHidden,
+    tyAnythingHidden,
+    tyStaticHidden,
+    tyFromExprHidden,
+    tyOptDeprecated,
+    tyVoidHidden
 
   TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
-  TNimNode {.compilerproc, final.} = object
+  TNimNode {.compilerproc.} = object
     kind: TNimNodeKind
     offset: int
     typ: ptr TNimType
-    name: Cstring
+    name: cstring
     len: int
-    sons: ptr array [0..0x7fff, ptr TNimNode]
+    sons: ptr array[0x7fff, ptr TNimNode]
 
-  TNimTypeFlag = enum 
+  TNimTypeFlag = enum
     ntfNoRefs = 0,     # type contains no tyRef, tySequence, tyString
-    ntfAcyclic = 1     # type cannot form a cycle
-  TNimType {.compilerproc, final.} = object
-    size: int
+    ntfAcyclic = 1,    # type cannot form a cycle
+    ntfEnumHole = 2    # enum has holes and thus `$` for them needs the slow
+                       # version
+  TNimType {.compilerproc.} = object
+    when defined(gcHooks):
+      head*: pointer
+    size*: int
+    align*: int
     kind: TNimKind
     flags: set[TNimTypeFlag]
-    base: ptr TNimType
+    base*: ptr TNimType
     node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum
-    finalizer: pointer # the finalizer for the type
-  PNimType = ptr TNimType
-  
+    finalizer*: pointer # the finalizer for the type
+    marker*: proc (p: pointer, op: int) {.nimcall, benign, tags: [], raises: [].} # marker proc for GC
+    deepcopy: proc (p: pointer): pointer {.nimcall, benign, tags: [], raises: [].}
+    when defined(nimSeqsV2):
+      typeInfoV2*: pointer
+    when defined(nimTypeNames):
+      name: cstring
+      nextType: ptr TNimType
+      instances: int # count the number of instances
+      sizes: int # sizes of all instances in bytes
+
+when defined(gcHooks):
+  type
+    PNimType* = ptr TNimType
+else:
+  type
+    PNimType = ptr TNimType
+
+when defined(nimTypeNames):
+  # Declare this variable only once in system.nim
+  when declared(ThisIsSystem):
+    var nimTypeRoot {.compilerproc.}: PNimType
+  else:
+    var nimTypeRoot {.importc.}: PNimType
+
 # node.len may be the ``first`` element of a set
diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim
new file mode 100644
index 000000000..3bf0b9893
--- /dev/null
+++ b/lib/system/inclrtl.nim
@@ -0,0 +1,50 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Pragmas for RTL generation. Has to be an include, because user-defined
+# pragmas cannot be exported.
+
+# There are 3 different usages:
+# 1) Ordinary imported code.
+# 2) Imported from nimrtl.
+#    -> defined(useNimRtl) or appType == "lib" and not defined(createNimRtl)
+# 3) Exported into nimrtl.
+#    -> appType == "lib" and defined(createNimRtl)
+when not defined(nimNewShared):
+  {.pragma: gcsafe.}
+
+when defined(createNimRtl):
+  when defined(useNimRtl):
+    {.error: "Cannot create and use nimrtl at the same time!".}
+  elif appType != "lib":
+    {.error: "nimrtl must be built as a library!".}
+
+when defined(createNimRtl):
+  {.pragma: rtl, exportc: "nimrtl_$1", dynlib, gcsafe.}
+  {.pragma: inl.}
+  {.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.}
+elif defined(useNimRtl):
+  #[
+  `{.rtl.}` should only be used for non-generic procs.
+  ]#
+  const nimrtl* =
+    when defined(windows): "nimrtl.dll"
+    elif defined(macosx): "libnimrtl.dylib"
+    else: "libnimrtl.so"
+  {.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.}
+  {.pragma: inl.}
+  {.pragma: compilerRtl, compilerproc, importc: "nimrtl_$1", dynlib: nimrtl.}
+else:
+  {.pragma: rtl, gcsafe.}
+  {.pragma: inl, inline.}
+  {.pragma: compilerRtl, compilerproc.}
+
+{.pragma: benign, gcsafe.}
+
+{.push sinkInference: on.}
diff --git a/lib/system/indexerrors.nim b/lib/system/indexerrors.nim
new file mode 100644
index 000000000..6a8cb8a0a
--- /dev/null
+++ b/lib/system/indexerrors.nim
@@ -0,0 +1,15 @@
+# imported by other modules, unlike helpers.nim which is included
+# xxx this is now included instead of imported, we should import instead
+
+template formatErrorIndexBound*[T](i, a, b: T): string =
+  when defined(standalone):
+    "indexOutOfBounds"
+  else:
+    if b < a: "index out of bounds, the container is empty"
+    else: "index " & $i & " not in " & $a & " .. " & $b
+
+template formatErrorIndexBound*[T](i, n: T): string =
+  formatErrorIndexBound(i, 0, n)
+
+template formatFieldDefect*(f, discVal): string =
+  f & discVal & "'"
diff --git a/lib/system/indices.nim b/lib/system/indices.nim
new file mode 100644
index 000000000..f2bad2528
--- /dev/null
+++ b/lib/system/indices.nim
@@ -0,0 +1,164 @@
+when not defined(nimHasSystemRaisesDefect):
+  {.pragma: systemRaisesDefect.}
+
+type
+  BackwardsIndex* = distinct int ## Type that is constructed by `^` for
+                                 ## reversed array accesses.
+                                 ## (See `^ template <#^.t,int>`_)
+
+template `^`*(x: int): BackwardsIndex = BackwardsIndex(x)
+  ## Builtin `roof`:idx: operator that can be used for convenient array access.
+  ## `a[^x]` is a shortcut for `a[a.len-x]`.
+  ##
+  ##   ```nim
+  ##   let
+  ##     a = [1, 3, 5, 7, 9]
+  ##     b = "abcdefgh"
+  ##
+  ##   echo a[^1] # => 9
+  ##   echo b[^2] # => g
+  ##   ```
+
+proc `[]`*[T](s: openArray[T]; i: BackwardsIndex): T {.inline, systemRaisesDefect.} =
+  system.`[]`(s, s.len - int(i))
+
+proc `[]`*[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T {.inline, systemRaisesDefect.} =
+  a[Idx(a.len - int(i) + int low(a))]
+proc `[]`*(s: string; i: BackwardsIndex): char {.inline, systemRaisesDefect.} = s[s.len - int(i)]
+
+proc `[]`*[T](s: var openArray[T]; i: BackwardsIndex): var T {.inline, systemRaisesDefect.} =
+  system.`[]`(s, s.len - int(i))
+proc `[]`*[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T {.inline, systemRaisesDefect.} =
+  a[Idx(a.len - int(i) + int low(a))]
+proc `[]`*(s: var string; i: BackwardsIndex): var char {.inline, systemRaisesDefect.} = s[s.len - int(i)]
+
+proc `[]=`*[T](s: var openArray[T]; i: BackwardsIndex; x: T) {.inline, systemRaisesDefect.} =
+  system.`[]=`(s, s.len - int(i), x)
+proc `[]=`*[Idx, T](a: var array[Idx, T]; i: BackwardsIndex; x: T) {.inline, systemRaisesDefect.} =
+  a[Idx(a.len - int(i) + int low(a))] = x
+proc `[]=`*(s: var string; i: BackwardsIndex; x: char) {.inline, systemRaisesDefect.} =
+  s[s.len - int(i)] = x
+
+template `..^`*(a, b: untyped): untyped =
+  ## A shortcut for `.. ^` to avoid the common gotcha that a space between
+  ## '..' and '^' is required.
+  a .. ^b
+
+template `..<`*(a, b: untyped): untyped =
+  ## A shortcut for `a .. pred(b)`.
+  ##   ```nim
+  ##   for i in 5 ..< 9:
+  ##     echo i # => 5; 6; 7; 8
+  ##   ```
+  a .. (when b is BackwardsIndex: succ(b) else: pred(b))
+
+template `[]`*(s: string; i: int): char = arrGet(s, i)
+template `[]=`*(s: string; i: int; val: char) = arrPut(s, i, val)
+
+template `^^`(s, i: untyped): untyped =
+  (when i is BackwardsIndex: s.len - int(i) else: int(i))
+
+template spliceImpl(s, a, L, b: typed): untyped =
+  # make room for additional elements or cut:
+  var shift = b.len - max(0,L)  # ignore negative slice size
+  var newLen = s.len + shift
+  if shift > 0:
+    # enlarge:
+    setLen(s, newLen)
+    for i in countdown(newLen-1, a+b.len): movingCopy(s[i], s[i-shift])
+  else:
+    for i in countup(a+b.len, newLen-1): movingCopy(s[i], s[i-shift])
+    # cut down:
+    setLen(s, newLen)
+  # fill the hole:
+  for i in 0 ..< b.len: s[a+i] = b[i]
+
+proc `[]`*[T, U: Ordinal](s: string, x: HSlice[T, U]): string {.inline, systemRaisesDefect.} =
+  ## Slice operation for strings.
+  ## Returns the inclusive range `[s[x.a], s[x.b]]`:
+  ##   ```nim
+  ##   var s = "abcdef"
+  ##   assert s[1..3] == "bcd"
+  ##   ```
+  let a = s ^^ x.a
+  let L = (s ^^ x.b) - a + 1
+  result = newString(L)
+  for i in 0 ..< L: result[i] = s[i + a]
+
+proc `[]=`*[T, U: Ordinal](s: var string, x: HSlice[T, U], b: string) {.systemRaisesDefect.} =
+  ## Slice assignment for strings.
+  ##
+  ## If `b.len` is not exactly the number of elements that are referred to
+  ## by `x`, a `splice`:idx: is performed:
+  ##
+  runnableExamples:
+    var s = "abcdefgh"
+    s[1 .. ^2] = "xyz"
+    assert s == "axyzh"
+
+  var a = s ^^ x.a
+  var L = (s ^^ x.b) - a + 1
+  if L == b.len:
+    for i in 0..<L: s[i+a] = b[i]
+  else:
+    spliceImpl(s, a, L, b)
+
+proc `[]`*[Idx, T; U, V: Ordinal](a: array[Idx, T], x: HSlice[U, V]): seq[T] {.systemRaisesDefect.} =
+  ## Slice operation for arrays.
+  ## Returns the inclusive range `[a[x.a], a[x.b]]`:
+  ##   ```nim
+  ##   var a = [1, 2, 3, 4]
+  ##   assert a[0..2] == @[1, 2, 3]
+  ##   ```
+  ##
+  ## See also:
+  ## * `toOpenArray(array[I, T];I,I) <#toOpenArray,array[I,T],I,I>`_
+  let xa = a ^^ x.a
+  let L = (a ^^ x.b) - xa + 1
+  result = newSeq[T](L)
+  for i in 0..<L: result[i] = a[Idx(i + xa)]
+
+proc `[]=`*[Idx, T; U, V: Ordinal](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T]) {.systemRaisesDefect.} =
+  ## Slice assignment for arrays.
+  ##   ```nim
+  ##   var a = [10, 20, 30, 40, 50]
+  ##   a[1..2] = @[99, 88]
+  ##   assert a == [10, 99, 88, 40, 50]
+  ##   ```
+  let xa = a ^^ x.a
+  let L = (a ^^ x.b) - xa + 1
+  if L == b.len:
+    for i in 0..<L: a[Idx(i + xa)] = b[i]
+  else:
+    sysFatal(RangeDefect, "different lengths for slice assignment")
+
+proc `[]`*[T; U, V: Ordinal](s: openArray[T], x: HSlice[U, V]): seq[T] {.systemRaisesDefect.} =
+  ## Slice operation for sequences.
+  ## Returns the inclusive range `[s[x.a], s[x.b]]`:
+  ##   ```nim
+  ##   var s = @[1, 2, 3, 4]
+  ##   assert s[0..2] == @[1, 2, 3]
+  ##   ```
+  ##
+  ## See also:
+  ## * `toOpenArray(openArray[T];int,int) <#toOpenArray,openArray[T],int,int>`_
+  let a = s ^^ x.a
+  let L = (s ^^ x.b) - a + 1
+  newSeq(result, L)
+  for i in 0 ..< L: result[i] = s[i + a]
+
+proc `[]=`*[T; U, V: Ordinal](s: var seq[T], x: HSlice[U, V], b: openArray[T]) {.systemRaisesDefect.} =
+  ## Slice assignment for sequences.
+  ##
+  ## If `b.len` is not exactly the number of elements that are referred to
+  ## by `x`, a `splice`:idx: is performed.
+  runnableExamples:
+    var s = @"abcdefgh"
+    s[1 .. ^2] = @"xyz"
+    assert s == @"axyzh"
+  let a = s ^^ x.a
+  let L = (s ^^ x.b) - a + 1
+  if L == b.len:
+    for i in 0 ..< L: s[i+a] = b[i]
+  else:
+    spliceImpl(s, a, L, b)
diff --git a/lib/system/integerops.nim b/lib/system/integerops.nim
new file mode 100644
index 000000000..4ef3594f1
--- /dev/null
+++ b/lib/system/integerops.nim
@@ -0,0 +1,132 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Integer arithmetic with overflow checking. Uses
+# intrinsics or inline assembler.
+
+proc raiseOverflow {.compilerproc, noinline.} =
+  # a single proc to reduce code size to a minimum
+  sysFatal(OverflowDefect, "over- or underflow")
+
+proc raiseDivByZero {.compilerproc, noinline.} =
+  sysFatal(DivByZeroDefect, "division by zero")
+
+{.pragma: nimbaseH, importc, nodecl, noSideEffect, compilerproc.}
+
+when not defined(nimEmulateOverflowChecks):
+  # take the #define from nimbase.h
+
+  proc nimAddInt(a, b: int, res: ptr int): bool {.nimbaseH.}
+  proc nimSubInt(a, b: int, res: ptr int): bool {.nimbaseH.}
+  proc nimMulInt(a, b: int, res: ptr int): bool {.nimbaseH.}
+
+  proc nimAddInt64(a, b: int64; res: ptr int64): bool {.nimbaseH.}
+  proc nimSubInt64(a, b: int64; res: ptr int64): bool {.nimbaseH.}
+  proc nimMulInt64(a, b: int64; res: ptr int64): bool {.nimbaseH.}
+
+# unary minus and 'abs' not required here anymore and are directly handled
+# in the code generator.
+# 'nimModInt' does exist in nimbase.h without check as we moved the
+# check for 0 to the codgen.
+proc nimModInt(a, b: int; res: ptr int): bool {.nimbaseH.}
+
+proc nimModInt64(a, b: int64; res: ptr int64): bool {.nimbaseH.}
+
+# Platform independent versions.
+
+template addImplFallback(name, T, U) {.dirty.} =
+  when not declared(name):
+    proc name(a, b: T; res: ptr T): bool {.compilerproc, inline.} =
+      let r = cast[T](cast[U](a) + cast[U](b))
+      if (r xor a) >= T(0) or (r xor b) >= T(0):
+        res[] = r
+      else:
+        result = true
+
+addImplFallback(nimAddInt, int, uint)
+addImplFallback(nimAddInt64, int64, uint64)
+
+template subImplFallback(name, T, U) {.dirty.} =
+  when not declared(name):
+    proc name(a, b: T; res: ptr T): bool {.compilerproc, inline.} =
+      let r = cast[T](cast[U](a) - cast[U](b))
+      if (r xor a) >= 0 or (r xor not b) >= 0:
+        res[] = r
+      else:
+        result = true
+
+subImplFallback(nimSubInt, int, uint)
+subImplFallback(nimSubInt64, int64, uint64)
+
+template mulImplFallback(name, T, U, conv) {.dirty.} =
+  #
+  # This code has been inspired by Python's source code.
+  # The native int product x*y is either exactly right or *way* off, being
+  # just the last n bits of the true product, where n is the number of bits
+  # in an int (the delivered product is the true product plus i*2**n for
+  # some integer i).
+  #
+  # The native float64 product x*y is subject to three
+  # rounding errors: on a sizeof(int)==8 box, each cast to double can lose
+  # info, and even on a sizeof(int)==4 box, the multiplication can lose info.
+  # But, unlike the native int product, it's not in *range* trouble:  even
+  # if sizeof(int)==32 (256-bit ints), the product easily fits in the
+  # dynamic range of a float64. So the leading 50 (or so) bits of the float64
+  # product are correct.
+  #
+  # We check these two ways against each other, and declare victory if
+  # they're approximately the same. Else, because the native int product is
+  # the only one that can lose catastrophic amounts of information, it's the
+  # native int product that must have overflowed.
+  #
+  when not declared(name):
+    proc name(a, b: T; res: ptr T): bool {.compilerproc, inline.} =
+      let r = cast[T](cast[U](a) * cast[U](b))
+      let floatProd = conv(a) * conv(b)
+      let resAsFloat = conv(r)
+      # Fast path for normal case: small multiplicands, and no info
+      # is lost in either method.
+      if resAsFloat == floatProd:
+        res[] = r
+      else:
+        # Somebody somewhere lost info. Close enough, or way off? Note
+        # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
+        # The difference either is or isn't significant compared to the
+        # true value (of which floatProd is a good approximation).
+
+        # abs(diff)/abs(prod) <= 1/32 iff
+        #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
+        if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
+          res[] = r
+        else:
+          result = true
+
+mulImplFallback(nimMulInt, int, uint, toFloat)
+mulImplFallback(nimMulInt64, int64, uint64, toBiggestFloat)
+
+
+template divImplFallback(name, T) {.dirty.} =
+  proc name(a, b: T; res: ptr T): bool {.compilerproc, inline.} =
+    # we moved the b == 0 case out into the codegen.
+    if a == low(T) and b == T(-1):
+      result = true
+    else:
+      res[] = a div b
+
+divImplFallback(nimDivInt, int)
+divImplFallback(nimDivInt64, int64)
+
+proc raiseFloatInvalidOp {.compilerproc, noinline.} =
+  sysFatal(FloatInvalidOpDefect, "FPU operation caused a NaN result")
+
+proc raiseFloatOverflow(x: float64) {.compilerproc, noinline.} =
+  if x > 0.0:
+    sysFatal(FloatOverflowDefect, "FPU operation caused an overflow")
+  else:
+    sysFatal(FloatUnderflowDefect, "FPU operations caused an underflow")
diff --git a/lib/system/iterators.nim b/lib/system/iterators.nim
new file mode 100644
index 000000000..125bee98f
--- /dev/null
+++ b/lib/system/iterators.nim
@@ -0,0 +1,353 @@
+## Default iterators for some Nim types.
+
+when defined(nimPreviewSlimSystem):
+  import std/assertions
+
+when not defined(nimNoLentIterators):
+  template lent2(T): untyped = lent T
+else:
+  template lent2(T): untyped = T
+
+template unCheckedInc(x) =
+  {.push overflowChecks: off.}
+  inc(x)
+  {.pop.}
+
+iterator items*[T: not char](a: openArray[T]): lent2 T {.inline.} =
+  ## Iterates over each item of `a`.
+  var i = 0
+  while i < len(a):
+    yield a[i]
+    unCheckedInc(i)
+
+iterator items*[T: char](a: openArray[T]): T {.inline.} =
+  ## Iterates over each item of `a`.
+  # a VM bug currently prevents taking address of openArray[char]
+  # elements converted from a string (would fail in `tests/misc/thallo.nim`)
+  # in any case there's no performance advantage of returning char by address.
+  var i = 0
+  while i < len(a):
+    yield a[i]
+    unCheckedInc(i)
+
+iterator mitems*[T](a: var openArray[T]): var T {.inline.} =
+  ## Iterates over each item of `a` so that you can modify the yielded value.
+  var i = 0
+  while i < len(a):
+    yield a[i]
+    unCheckedInc(i)
+
+iterator items*[IX, T](a: array[IX, T]): T {.inline.} =
+  ## Iterates over each item of `a`.
+  when a.len > 0:
+    var i = low(IX)
+    while true:
+      yield a[i]
+      if i >= high(IX): break
+      unCheckedInc(i)
+
+iterator mitems*[IX, T](a: var array[IX, T]): var T {.inline.} =
+  ## Iterates over each item of `a` so that you can modify the yielded value.
+  when a.len > 0:
+    var i = low(IX)
+    while true:
+      yield a[i]
+      if i >= high(IX): break
+      unCheckedInc(i)
+
+iterator items*[T](a: set[T]): T {.inline.} =
+  ## Iterates over each element of `a`. `items` iterates only over the
+  ## elements that are really in the set (and not over the ones the set is
+  ## able to hold).
+  var i = low(T).int
+  while i <= high(T).int:
+    when T is enum and not defined(js):
+      if cast[T](i) in a: yield cast[T](i)
+    else:
+      if T(i) in a: yield T(i)
+    unCheckedInc(i)
+
+iterator items*(a: cstring): char {.inline.} =
+  ## Iterates over each item of `a`.
+  runnableExamples:
+    from std/sequtils import toSeq
+    assert toSeq("abc\0def".cstring) == @['a', 'b', 'c']
+    assert toSeq("abc".cstring) == @['a', 'b', 'c']
+  #[
+  assert toSeq(nil.cstring) == @[] # xxx fails with SIGSEGV
+  this fails with SIGSEGV; unclear whether we want to instead yield nothing
+  or pay a small price to check for `nil`, a benchmark is needed. Note that
+  other procs support `nil`.
+  ]#
+  template impl() =
+    var i = 0
+    let n = len(a)
+    while i < n:
+      yield a[i]
+      unCheckedInc(i)
+  when defined(js): impl()
+  else:
+    when nimvm:
+      # xxx `cstring` should behave like c backend instead.
+      impl()
+    else:
+      var i = 0
+      while a[i] != '\0':
+        yield a[i]
+        unCheckedInc(i)
+
+iterator mitems*(a: var cstring): var char {.inline.} =
+  ## Iterates over each item of `a` so that you can modify the yielded value.
+  # xxx this should give CT error in js RT.
+  runnableExamples:
+    from std/sugar import collect
+    var a = "abc\0def"
+    prepareMutation(a)
+    var b = a.cstring
+    let s = collect:
+      for bi in mitems(b):
+        if bi == 'b': bi = 'B'
+        bi
+    assert s == @['a', 'B', 'c']
+    assert b == "aBc"
+    assert a == "aBc\0def"
+
+  template impl() =
+    var i = 0
+    let n = len(a)
+    while i < n:
+      yield a[i]
+      unCheckedInc(i)
+  when defined(js): impl()
+  else:
+    when nimvm: impl()
+    else:
+      var i = 0
+      while a[i] != '\0':
+        yield a[i]
+        unCheckedInc(i)
+
+iterator items*[T: enum and Ordinal](E: typedesc[T]): T =
+  ## Iterates over the values of `E`.
+  ## See also `enumutils.items` for enums with holes.
+  runnableExamples:
+    type Goo = enum g0 = 2, g1, g2
+    from std/sequtils import toSeq
+    assert Goo.toSeq == [g0, g1, g2]
+  for v in low(E) .. high(E):
+    yield v
+
+iterator items*[T: Ordinal](s: Slice[T]): T =
+  ## Iterates over the slice `s`, yielding each value between `s.a` and `s.b`
+  ## (inclusively).
+  for x in s.a .. s.b:
+    yield x
+
+iterator pairs*[T](a: openArray[T]): tuple[key: int, val: T] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  var i = 0
+  while i < len(a):
+    yield (i, a[i])
+    unCheckedInc(i)
+
+iterator mpairs*[T](a: var openArray[T]): tuple[key: int, val: var T]{.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  ## `a[index]` can be modified.
+  var i = 0
+  while i < len(a):
+    yield (i, a[i])
+    unCheckedInc(i)
+
+iterator pairs*[IX, T](a: array[IX, T]): tuple[key: IX, val: T] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  when a.len > 0:
+    var i = low(IX)
+    while true:
+      yield (i, a[i])
+      if i >= high(IX): break
+      unCheckedInc(i)
+
+iterator mpairs*[IX, T](a: var array[IX, T]): tuple[key: IX, val: var T] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  ## `a[index]` can be modified.
+  when a.len > 0:
+    var i = low(IX)
+    while true:
+      yield (i, a[i])
+      if i >= high(IX): break
+      unCheckedInc(i)
+
+iterator pairs*[T](a: seq[T]): tuple[key: int, val: T] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield (i, a[i])
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the seq changed while iterating over it")
+
+iterator mpairs*[T](a: var seq[T]): tuple[key: int, val: var T] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  ## `a[index]` can be modified.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield (i, a[i])
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the seq changed while iterating over it")
+
+iterator pairs*(a: string): tuple[key: int, val: char] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield (i, a[i])
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the string changed while iterating over it")
+
+iterator mpairs*(a: var string): tuple[key: int, val: var char] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  ## `a[index]` can be modified.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield (i, a[i])
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the string changed while iterating over it")
+
+iterator pairs*(a: cstring): tuple[key: int, val: char] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  when defined(js):
+    var i = 0
+    var L = len(a)
+    while i < L:
+      yield (i, a[i])
+      unCheckedInc(i)
+  else:
+    var i = 0
+    while a[i] != '\0':
+      yield (i, a[i])
+      unCheckedInc(i)
+
+iterator mpairs*(a: var cstring): tuple[key: int, val: var char] {.inline.} =
+  ## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
+  ## `a[index]` can be modified.
+  when defined(js):
+    var i = 0
+    var L = len(a)
+    while i < L:
+      yield (i, a[i])
+      unCheckedInc(i)
+  else:
+    var i = 0
+    while a[i] != '\0':
+      yield (i, a[i])
+      unCheckedInc(i)
+
+iterator items*[T](a: seq[T]): lent2 T {.inline.} =
+  ## Iterates over each item of `a`.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield a[i]
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the seq changed while iterating over it")
+
+iterator mitems*[T](a: var seq[T]): var T {.inline.} =
+  ## Iterates over each item of `a` so that you can modify the yielded value.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield a[i]
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the seq changed while iterating over it")
+
+iterator items*(a: string): char {.inline.} =
+  ## Iterates over each item of `a`.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield a[i]
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the string changed while iterating over it")
+
+iterator mitems*(a: var string): var char {.inline.} =
+  ## Iterates over each item of `a` so that you can modify the yielded value.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield a[i]
+    unCheckedInc(i)
+    assert(len(a) == L, "the length of the string changed while iterating over it")
+
+
+iterator fields*[T: tuple|object](x: T): RootObj {.
+  magic: "Fields", 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.
+  runnableExamples:
+    var t = (1, "foo")
+    for v in fields(t): v = default(typeof(v))
+    doAssert t == (0, "")
+
+iterator fields*[S:tuple|object, T:tuple|object](x: S, y: T): tuple[key: string, val: RootObj] {.
+  magic: "Fields", noSideEffect.} =
+  ## Iterates over every field of `x` and `y`.
+  ##
+  ## .. 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.
+  runnableExamples:
+    var t1 = (1, "foo")
+    var t2 = default(typeof(t1))
+    for v1, v2 in fields(t1, t2): v2 = v1
+    doAssert t1 == t2
+
+iterator fieldPairs*[T: tuple|object](x: T): tuple[key: string, val: RootObj] {.
+  magic: "FieldPairs", noSideEffect.} =
+  ## 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#generics-is-operator>`_.
+  ## 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.
+  runnableExamples:
+    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:
+          result.add("\n\t" & name & " '" & value & "'")
+
+iterator fieldPairs*[S: tuple|object, T: tuple|object](x: S, y: T): tuple[
+  key: string, a, b: RootObj] {.
+  magic: "FieldPairs", noSideEffect.} =
+  ## Iterates over every field of `x` and `y`.
+  ##
+  ## .. 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.
+  runnableExamples:
+    type Foo = object
+      x1: int
+      x2: string
+    var a1 = Foo(x1: 12, x2: "abc")
+    var a2: Foo
+    for name, v1, v2 in fieldPairs(a1, a2):
+      when name == "x2": v2 = v1
+    doAssert a2 == Foo(x1: 0, x2: "abc")
diff --git a/lib/system/iterators_1.nim b/lib/system/iterators_1.nim
new file mode 100644
index 000000000..d00e3f823
--- /dev/null
+++ b/lib/system/iterators_1.nim
@@ -0,0 +1,180 @@
+when sizeof(int) <= 2:
+  type IntLikeForCount = int|int8|int16|char|bool|uint8|enum
+else:
+  type IntLikeForCount = int|int8|int16|int32|char|bool|uint8|uint16|enum
+
+iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} =
+  ## Counts from ordinal value `a` down to `b` (inclusive) with the given
+  ## step count.
+  ##
+  ## `T` may be any ordinal type, `step` may only be positive.
+  ##
+  ## **Note**: This fails to count to `low(int)` if T = int for
+  ## efficiency reasons.
+  runnableExamples:
+    import std/sugar
+    let x = collect(newSeq):
+      for i in countdown(7, 3):
+        i
+
+    assert x == @[7, 6, 5, 4, 3]
+
+    let y = collect(newseq):
+      for i in countdown(9, 2, 3):
+        i
+    assert y == @[9, 6, 3]
+  when T is (uint|uint64):
+    var res = a
+    while res >= b:
+      yield res
+      if res == b: break
+      dec(res, step)
+  elif T is IntLikeForCount and T is Ordinal:
+    var res = int(a)
+    while res >= int(b):
+      when defined(nimHasCastExtendedVm):
+        yield cast[T](res)
+      else:
+        yield T(res)
+      dec(res, step)
+  else:
+    var res = a
+    while res >= b:
+      yield res
+      dec(res, step)
+
+iterator countup*[T](a, b: T, step: Positive = 1): T {.inline.} =
+  ## Counts from ordinal value `a` to `b` (inclusive) with the given
+  ## step count.
+  ##
+  ## `T` may be any ordinal type, `step` may only be positive.
+  ##
+  ## **Note**: This fails to count to `high(int)` if T = int for
+  ## efficiency reasons.
+  runnableExamples:
+    import std/sugar
+    let x = collect(newSeq):
+      for i in countup(3, 7):
+        i
+    
+    assert x == @[3, 4, 5, 6, 7]
+
+    let y = collect(newseq):
+      for i in countup(2, 9, 3):
+        i
+    assert y == @[2, 5, 8]
+  mixin inc
+  when T is IntLikeForCount and T is Ordinal:
+    var res = int(a)
+    while res <= int(b):
+      when defined(nimHasCastExtendedVm):
+        yield cast[T](res)
+      else:
+        yield T(res)
+      inc(res, step)
+  else:
+    var res = a
+    while res <= b:
+      yield res
+      inc(res, step)
+
+iterator `..`*[T](a, b: T): T {.inline.} =
+  ## An alias for `countup(a, b, 1)`.
+  ##
+  ## See also:
+  ## * [..<](#..<.i,T,T)
+  runnableExamples:
+    import std/sugar
+
+    let x = collect(newSeq):
+      for i in 3 .. 7:
+        i
+
+    assert x == @[3, 4, 5, 6, 7]
+  mixin inc
+  when T is IntLikeForCount and T is Ordinal:
+    var res = int(a)
+    while res <= int(b):
+      when defined(nimHasCastExtendedVm):
+        yield cast[T](res)
+      else:
+        yield T(res)
+      inc(res)
+  else:
+    var res = a
+    while res <= b:
+      yield res
+      inc(res)
+
+template dotdotImpl(t) {.dirty.} =
+  iterator `..`*(a, b: t): t {.inline.} =
+    ## A type specialized version of `..` for convenience so that
+    ## mixing integer types works better.
+    ##
+    ## See also:
+    ## * [..<](#..<.i,T,T)
+    var res = a
+    while res <= b:
+      yield res
+      inc(res)
+
+dotdotImpl(int64)
+dotdotImpl(int32)
+dotdotImpl(uint64)
+dotdotImpl(uint32)
+
+iterator `..<`*[T](a, b: T): T {.inline.} =
+  mixin inc
+  var i = a
+  while i < b:
+    yield i
+    inc i
+
+template dotdotLessImpl(t) {.dirty.} =
+  iterator `..<`*(a, b: t): t {.inline.} =
+    ## A type specialized version of `..<` for convenience so that
+    ## mixing integer types works better.
+    var res = a
+    while res < b:
+      yield res
+      inc(res)
+
+dotdotLessImpl(int64)
+dotdotLessImpl(int32)
+dotdotLessImpl(uint64)
+dotdotLessImpl(uint32)
+
+iterator `||`*[S, T](a: S, b: T, annotation: static string = "parallel for"): T {.
+  inline, magic: "OmpParFor", sideEffect.} =
+  ## OpenMP parallel loop iterator. Same as `..` but the loop may run in parallel.
+  ##
+  ## `annotation` is an additional annotation for the code generator to use.
+  ## The default annotation is `parallel for`.
+  ## Please refer to the `OpenMP Syntax Reference
+  ## <https://www.openmp.org/wp-content/uploads/OpenMP-4.5-1115-CPP-web.pdf>`_
+  ## for further information.
+  ##
+  ## Note that the compiler maps that to
+  ## the `#pragma omp parallel for` construct of `OpenMP`:idx: and as
+  ## such isn't aware of the parallelism in your code! Be careful! Later
+  ## versions of `||` will get proper support by Nim's code generator
+  ## and GC.
+  discard
+
+iterator `||`*[S, T](a: S, b: T, step: Positive, annotation: static string = "parallel for"): T {.
+  inline, magic: "OmpParFor", sideEffect.} =
+  ## OpenMP parallel loop iterator with stepping.
+  ## Same as `countup` but the loop may run in parallel.
+  ##
+  ## `annotation` is an additional annotation for the code generator to use.
+  ## The default annotation is `parallel for`.
+  ## Please refer to the `OpenMP Syntax Reference
+  ## <https://www.openmp.org/wp-content/uploads/OpenMP-4.5-1115-CPP-web.pdf>`_
+  ## for further information.
+  ##
+  ## Note that the compiler maps that to
+  ## the `#pragma omp parallel for` construct of `OpenMP`:idx: and as
+  ## such isn't aware of the parallelism in your code! Be careful! Later
+  ## versions of `||` will get proper support by Nim's code generator
+  ## and GC.
+  discard
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
new file mode 100644
index 000000000..5599240fd
--- /dev/null
+++ b/lib/system/jssys.nim
@@ -0,0 +1,768 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+include system/indexerrors
+import std/private/miscdollars
+
+proc log*(s: cstring) {.importc: "console.log", varargs, nodecl.}
+
+type
+  PSafePoint = ptr SafePoint
+  SafePoint {.compilerproc, final.} = object
+    prev: PSafePoint # points to next safe point
+    exc: ref Exception
+
+  PCallFrame = ptr CallFrame
+  CallFrame {.importc, nodecl, final.} = object
+    prev: PCallFrame
+    procname: cstring
+    line: int # current line number
+    filename: cstring
+
+  PJSError = ref object
+    columnNumber {.importc.}: int
+    fileName {.importc.}: cstring
+    lineNumber {.importc.}: int
+    message {.importc.}: cstring
+    stack {.importc.}: cstring
+
+  JSRef = ref RootObj # Fake type.
+
+var
+  framePtr {.importc, nodecl, volatile.}: PCallFrame
+  excHandler {.importc, nodecl, volatile.}: int = 0
+  lastJSError {.importc, nodecl, volatile.}: PJSError = nil
+
+{.push stacktrace: off, profiler:off.}
+proc nimBoolToStr(x: bool): string {.compilerproc.} =
+  if x: result = "true"
+  else: result = "false"
+
+proc nimCharToStr(x: char): string {.compilerproc.} =
+  result = newString(1)
+  result[0] = x
+
+proc isNimException(): bool {.asmNoStackFrame.} =
+  {.emit: "return `lastJSError` && `lastJSError`.m_type;".}
+
+proc getCurrentException*(): ref Exception {.compilerRtl, benign.} =
+  if isNimException(): result = cast[ref Exception](lastJSError)
+
+proc getCurrentExceptionMsg*(): string =
+  if lastJSError != nil:
+    if isNimException():
+      return cast[Exception](lastJSError).msg
+    else:
+      var msg: cstring
+      {.emit: """
+      if (`lastJSError`.message !== undefined) {
+        `msg` = `lastJSError`.message;
+      }
+      """.}
+      if not msg.isNil:
+        return $msg
+  return ""
+
+proc setCurrentException*(exc: ref Exception) =
+  lastJSError = cast[PJSError](exc)
+
+proc closureIterSetupExc(e: ref Exception) {.compilerproc, inline.} =
+  ## Used to set up exception handling for closure iterators
+  setCurrentException(e)
+
+proc auxWriteStackTrace(f: PCallFrame): string =
+  type
+    TempFrame = tuple[procname: cstring, line: int, filename: cstring]
+  var
+    it = f
+    i = 0
+    total = 0
+    tempFrames: array[0..63, TempFrame]
+  while it != nil and i <= high(tempFrames):
+    tempFrames[i].procname = it.procname
+    tempFrames[i].line = it.line
+    tempFrames[i].filename = it.filename
+    inc(i)
+    inc(total)
+    it = it.prev
+  while it != nil:
+    inc(total)
+    it = it.prev
+  result = ""
+  # if the buffer overflowed print '...':
+  if total != i:
+    add(result, "(")
+    add(result, $(total-i))
+    add(result, " calls omitted) ...\n")
+  for j in countdown(i-1, 0):
+    result.toLocation($tempFrames[j].filename, tempFrames[j].line, 0)
+    add(result, " at ")
+    add(result, tempFrames[j].procname)
+    add(result, "\n")
+
+proc rawWriteStackTrace(): string =
+  if framePtr != nil:
+    result = "Traceback (most recent call last)\n" & auxWriteStackTrace(framePtr)
+  else:
+    result = "No stack traceback available\n"
+
+proc writeStackTrace() =
+  var trace = rawWriteStackTrace()
+  trace.setLen(trace.len - 1)
+  echo trace
+
+proc getStackTrace*(): string = rawWriteStackTrace()
+proc getStackTrace*(e: ref Exception): string = e.trace
+
+proc unhandledException(e: ref Exception) {.
+    compilerproc, asmNoStackFrame.} =
+  var buf = ""
+  if e.msg.len != 0:
+    add(buf, "Error: unhandled exception: ")
+    add(buf, e.msg)
+  else:
+    add(buf, "Error: unhandled exception")
+  add(buf, " [")
+  add(buf, e.name)
+  add(buf, "]\n")
+  when NimStackTrace:
+    add(buf, rawWriteStackTrace())
+  let cbuf = cstring(buf)
+  when NimStackTrace:
+    framePtr = nil
+  {.emit: """
+  if (typeof(Error) !== "undefined") {
+    throw new Error(`cbuf`);
+  }
+  else {
+    throw `cbuf`;
+  }
+  """.}
+
+proc raiseException(e: ref Exception, ename: cstring) {.
+    compilerproc, asmNoStackFrame.} =
+  e.name = ename
+  if excHandler == 0:
+    unhandledException(e)
+  when NimStackTrace:
+    e.trace = rawWriteStackTrace()
+  {.emit: "throw `e`;".}
+
+proc reraiseException() {.compilerproc, asmNoStackFrame.} =
+  if lastJSError == nil:
+    raise newException(ReraiseDefect, "no exception to reraise")
+  else:
+    if excHandler == 0:
+      if isNimException():
+        unhandledException(cast[ref Exception](lastJSError))
+
+    {.emit: "throw lastJSError;".}
+
+proc raiseOverflow {.exportc: "raiseOverflow", noreturn, compilerproc.} =
+  raise newException(OverflowDefect, "over- or underflow")
+
+proc raiseDivByZero {.exportc: "raiseDivByZero", noreturn, compilerproc.} =
+  raise newException(DivByZeroDefect, "division by zero")
+
+proc raiseRangeError() {.compilerproc, noreturn.} =
+  raise newException(RangeDefect, "value out of range")
+
+proc raiseIndexError(i, a, b: int) {.compilerproc, noreturn.} =
+  raise newException(IndexDefect, formatErrorIndexBound(int(i), int(a), int(b)))
+
+proc raiseFieldError2(f: string, discVal: string) {.compilerproc, noreturn.} =
+  raise newException(FieldDefect, formatFieldDefect(f, discVal))
+
+proc setConstr() {.varargs, asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = {};
+    for (var i = 0; i < arguments.length; ++i) {
+      var x = arguments[i];
+      if (typeof(x) == "object") {
+        for (var j = x[0]; j <= x[1]; ++j) {
+          result[j] = true;
+        }
+      } else {
+        result[x] = true;
+      }
+    }
+    return result;
+  """.}
+
+proc makeNimstrLit(c: cstring): string {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+  var result = [];
+  for (var i = 0; i < `c`.length; ++i) {
+    result[i] = `c`.charCodeAt(i);
+  }
+  return result;
+  """.}
+
+proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+  var ln = `c`.length;
+  var result = new Array(ln);
+  var r = 0;
+  for (var i = 0; i < ln; ++i) {
+    var ch = `c`.charCodeAt(i);
+
+    if (ch < 128) {
+      result[r] = ch;
+    }
+    else {
+      if (ch < 2048) {
+        result[r] = (ch >> 6) | 192;
+      }
+      else {
+        if (ch < 55296 || ch >= 57344) {
+          result[r] = (ch >> 12) | 224;
+        }
+        else {
+            ++i;
+            ch = 65536 + (((ch & 1023) << 10) | (`c`.charCodeAt(i) & 1023));
+            result[r] = (ch >> 18) | 240;
+            ++r;
+            result[r] = ((ch >> 12) & 63) | 128;
+        }
+        ++r;
+        result[r] = ((ch >> 6) & 63) | 128;
+      }
+      ++r;
+      result[r] = (ch & 63) | 128;
+    }
+    ++r;
+  }
+  return result;
+  """.}
+
+proc toJSStr(s: string): cstring {.compilerproc.} =
+  proc fromCharCode(c: char): cstring {.importc: "String.fromCharCode".}
+  proc join(x: openArray[cstring]; d = cstring""): cstring {.
+    importcpp: "#.join(@)".}
+  proc decodeURIComponent(x: cstring): cstring {.
+    importc: "decodeURIComponent".}
+
+  proc toHexString(c: char; d = 16): cstring {.importcpp: "#.toString(@)".}
+
+  proc log(x: cstring) {.importc: "console.log".}
+
+  var res = newSeq[cstring](s.len)
+  var i = 0
+  var j = 0
+  while i < s.len:
+    var c = s[i]
+    if c < '\128':
+      res[j] = fromCharCode(c)
+      inc i
+    else:
+      var helper = newSeq[cstring]()
+      while true:
+        let code = toHexString(c)
+        if code.len == 1:
+          helper.add cstring"%0"
+        else:
+          helper.add cstring"%"
+        helper.add code
+        inc i
+        if i >= s.len or s[i] < '\128': break
+        c = s[i]
+      try:
+        res[j] = decodeURIComponent join(helper)
+      except:
+        res[j] = join(helper)
+    inc j
+  setLen(res, j)
+  result = join(res)
+
+proc mnewString(len: int): string {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = new Array(`len`);
+    for (var i = 0; i < `len`; i++) {result[i] = 0;}
+    return result;
+  """.}
+
+proc SetCard(a: int): int {.compilerproc, asmNoStackFrame.} =
+  # argument type is a fake
+  {.emit: """
+    var result = 0;
+    for (var elem in `a`) { ++result; }
+    return result;
+  """.}
+
+proc SetEq(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
+  {.emit: """
+    for (var elem in `a`) { if (!`b`[elem]) return false; }
+    for (var elem in `b`) { if (!`a`[elem]) return false; }
+    return true;
+  """.}
+
+proc SetLe(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
+  {.emit: """
+    for (var elem in `a`) { if (!`b`[elem]) return false; }
+    return true;
+  """.}
+
+proc SetLt(a, b: int): bool {.compilerproc.} =
+  result = SetLe(a, b) and not SetEq(a, b)
+
+proc SetMul(a, b: int): int {.compilerproc, asmNoStackFrame.} =
+  {.emit: """
+    var result = {};
+    for (var elem in `a`) {
+      if (`b`[elem]) { result[elem] = true; }
+    }
+    return result;
+  """.}
+
+proc SetPlus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
+  {.emit: """
+    var result = {};
+    for (var elem in `a`) { result[elem] = true; }
+    for (var elem in `b`) { result[elem] = true; }
+    return result;
+  """.}
+
+proc SetMinus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
+  {.emit: """
+    var result = {};
+    for (var elem in `a`) {
+      if (!`b`[elem]) { result[elem] = true; }
+    }
+    return result;
+  """.}
+
+proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`a` == `b`) return 0;
+    if (!`a`) return -1;
+    if (!`b`) return 1;
+    for (var i = 0; i < `a`.length && i < `b`.length; i++) {
+      var result = `a`[i] - `b`[i];
+      if (result != 0) return result;
+    }
+    return `a`.length - `b`.length;
+  """.}
+
+proc cmp(x, y: string): int =
+  when nimvm:
+    if x == y: result = 0
+    elif x < y: result = -1
+    else: result = 1
+  else:
+    result = cmpStrings(x, y)
+
+proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`a` == `b`) return true;
+    if (`a` === null && `b`.length == 0) return true;
+    if (`b` === null && `a`.length == 0) return true;
+    if ((!`a`) || (!`b`)) return false;
+    var alen = `a`.length;
+    if (alen != `b`.length) return false;
+    for (var i = 0; i < alen; ++i)
+      if (`a`[i] != `b`[i]) return false;
+    return true;
+  """.}
+
+when defined(kwin):
+  proc rawEcho {.compilerproc, asmNoStackFrame.} =
+    {.emit: """
+      var buf = "";
+      for (var i = 0; i < arguments.length; ++i) {
+        buf += `toJSStr`(arguments[i]);
+      }
+      print(buf);
+    """.}
+
+elif not defined(nimOldEcho):
+  proc ewriteln(x: cstring) = log(x)
+
+  proc rawEcho {.compilerproc, asmNoStackFrame.} =
+    {.emit: """
+      var buf = "";
+      for (var i = 0; i < arguments.length; ++i) {
+        buf += `toJSStr`(arguments[i]);
+      }
+      console.log(buf);
+    """.}
+
+else:
+  proc ewriteln(x: cstring) =
+    var node : JSRef
+    {.emit: "`node` = document.getElementsByTagName('body')[0];".}
+    if node.isNil:
+      raise newException(ValueError, "<body> element does not exist yet!")
+    {.emit: """
+    `node`.appendChild(document.createTextNode(`x`));
+    `node`.appendChild(document.createElement("br"));
+    """.}
+
+  proc rawEcho {.compilerproc.} =
+    var node : JSRef
+    {.emit: "`node` = document.getElementsByTagName('body')[0];".}
+    if node.isNil:
+      raise newException(IOError, "<body> element does not exist yet!")
+    {.emit: """
+    for (var i = 0; i < arguments.length; ++i) {
+      var x = `toJSStr`(arguments[i]);
+      `node`.appendChild(document.createTextNode(x));
+    }
+    `node`.appendChild(document.createElement("br"));
+    """.}
+
+# Arithmetic:
+proc checkOverflowInt(a: int) {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`a` > 2147483647 || `a` < -2147483648) `raiseOverflow`();
+  """.}
+
+proc addInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` + `b`;
+    `checkOverflowInt`(result);
+    return result;
+  """.}
+
+proc subInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` - `b`;
+    `checkOverflowInt`(result);
+    return result;
+  """.}
+
+proc mulInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` * `b`;
+    `checkOverflowInt`(result);
+    return result;
+  """.}
+
+proc divInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`b` == 0) `raiseDivByZero`();
+    if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
+    return Math.trunc(`a` / `b`);
+  """.}
+
+proc modInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`b` == 0) `raiseDivByZero`();
+    if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
+    return Math.trunc(`a` % `b`);
+  """.}
+
+proc checkOverflowInt64(a: int64) {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`a` > 9223372036854775807n || `a` < -9223372036854775808n) `raiseOverflow`();
+  """.}
+
+proc addInt64(a, b: int64): int64 {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` + `b`;
+    `checkOverflowInt64`(result);
+    return result;
+  """.}
+
+proc subInt64(a, b: int64): int64 {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` - `b`;
+    `checkOverflowInt64`(result);
+    return result;
+  """.}
+
+proc mulInt64(a, b: int64): int64 {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    var result = `a` * `b`;
+    `checkOverflowInt64`(result);
+    return result;
+  """.}
+
+proc divInt64(a, b: int64): int64 {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`b` == 0n) `raiseDivByZero`();
+    if (`b` == -1n && `a` == 9223372036854775807n) `raiseOverflow`();
+    return `a` / `b`;
+  """.}
+
+proc modInt64(a, b: int64): int64 {.asmNoStackFrame, compilerproc.} =
+  {.emit: """
+    if (`b` == 0n) `raiseDivByZero`();
+    if (`b` == -1n && `a` == 9223372036854775807n) `raiseOverflow`();
+    return `a` % `b`;
+  """.}
+
+proc negInt(a: int): int {.compilerproc.} =
+  result = a*(-1)
+
+proc negInt64(a: int64): int64 {.compilerproc.} =
+  result = a*(-1)
+
+proc absInt(a: int): int {.compilerproc.} =
+  result = if a < 0: a*(-1) else: a
+
+proc absInt64(a: int64): int64 {.compilerproc.} =
+  result = if a < 0: a*(-1) else: a
+
+proc nimMin(a, b: int): int {.compilerproc.} = return if a <= b: a else: b
+proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b
+
+proc chckNilDisp(p: JSRef) {.compilerproc.} =
+  if p == nil:
+    sysFatal(NilAccessDefect, "cannot dispatch; dispatcher is nil")
+
+include "system/hti"
+
+proc isFatPointer(ti: PNimType): bool =
+  # This has to be consistent with the code generator!
+  return ti.base.kind notin {tyObject,
+    tyArray, tyArrayConstr, tyTuple,
+    tyOpenArray, tySet, tyVar, tyRef, tyPtr}
+
+proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef {.compilerproc.}
+
+proc nimCopyAux(dest, src: JSRef, n: ptr TNimNode) {.compilerproc.} =
+  case n.kind
+  of nkNone: sysAssert(false, "nimCopyAux")
+  of nkSlot:
+    {.emit: """
+      `dest`[`n`.offset] = nimCopy(`dest`[`n`.offset], `src`[`n`.offset], `n`.typ);
+    """.}
+  of nkList:
+    {.emit: """
+    for (var i = 0; i < `n`.sons.length; i++) {
+      nimCopyAux(`dest`, `src`, `n`.sons[i]);
+    }
+    """.}
+  of nkCase:
+    {.emit: """
+      `dest`[`n`.offset] = nimCopy(`dest`[`n`.offset], `src`[`n`.offset], `n`.typ);
+      for (var i = 0; i < `n`.sons.length; ++i) {
+        nimCopyAux(`dest`, `src`, `n`.sons[i][1]);
+      }
+    """.}
+
+proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef =
+  case ti.kind
+  of tyPtr, tyRef, tyVar, tyNil:
+    if not isFatPointer(ti):
+      result = src
+    else:
+      {.emit: "`result` = [`src`[0], `src`[1]];".}
+  of tySet:
+    {.emit: """
+      if (`dest` === null || `dest` === undefined) {
+        `dest` = {};
+      }
+      else {
+        for (var key in `dest`) { delete `dest`[key]; }
+      }
+      for (var key in `src`) { `dest`[key] = `src`[key]; }
+      `result` = `dest`;
+    """.}
+  of tyTuple, tyObject:
+    if ti.base != nil: result = nimCopy(dest, src, ti.base)
+    elif ti.kind == tyObject:
+      {.emit: "`result` = (`dest` === null || `dest` === undefined) ? {m_type: `ti`} : `dest`;".}
+    else:
+      {.emit: "`result` = (`dest` === null || `dest` === undefined) ? {} : `dest`;".}
+    nimCopyAux(result, src, ti.node)
+  of tyArrayConstr, tyArray:
+    # In order to prevent a type change (TypedArray -> Array) and to have better copying performance,
+    # arrays constructors are considered separately
+    {.emit: """
+      if(ArrayBuffer.isView(`src`)) { 
+        if(`dest` === null || `dest` === undefined || `dest`.length != `src`.length) {
+          `dest` = new `src`.constructor(`src`);
+        } else {
+          `dest`.set(`src`, 0);
+        }
+        `result` = `dest`;
+      } else {
+        if (`src` === null) {
+          `result` = null;
+        }
+        else {
+          if (`dest` === null || `dest` === undefined || `dest`.length != `src`.length) {
+            `dest` = new Array(`src`.length);
+          }
+          `result` = `dest`;
+          for (var i = 0; i < `src`.length; ++i) {
+            `result`[i] = nimCopy(`result`[i], `src`[i], `ti`.base);
+          }
+        }
+      }
+    """.}
+  of tySequence, tyOpenArray:
+    {.emit: """
+      if (`src` === null) {
+        `result` = null;
+      }
+      else {
+        if (`dest` === null || `dest` === undefined || `dest`.length != `src`.length) {
+          `dest` = new Array(`src`.length);
+        }
+        `result` = `dest`;
+        for (var i = 0; i < `src`.length; ++i) {
+          `result`[i] = nimCopy(`result`[i], `src`[i], `ti`.base);
+        }
+      }
+    """.}
+  of tyString:
+    {.emit: """
+      if (`src` !== null) {
+        `result` = `src`.slice(0);
+      }
+    """.}
+  else:
+    result = src
+
+proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.
+                asmNoStackFrame, compilerproc.} =
+  # types are fake
+  {.emit: """
+    var result = new Array(`len`);
+    for (var i = 0; i < `len`; ++i) result[i] = nimCopy(null, `value`, `typ`);
+    return result;
+  """.}
+
+proc chckIndx(i, a, b: int): int {.compilerproc.} =
+  if i >= a and i <= b: return i
+  else: raiseIndexError(i, a, b)
+
+proc chckRange(i, a, b: int): int {.compilerproc.} =
+  if i >= a and i <= b: return i
+  else: raiseRangeError()
+
+proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
+  # checks if obj is of type subclass:
+  var x = obj
+  if x == subclass: return # optimized fast path
+  while x != subclass:
+    if x == nil:
+      raise newException(ObjectConversionDefect, "invalid object conversion")
+    x = x.base
+
+proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
+  # checks if obj is of type subclass:
+  var x = obj
+  if x == subclass: return true # optimized fast path
+  while x != subclass:
+    if x == nil: return false
+    x = x.base
+  return true
+
+proc addChar(x: string, c: char) {.compilerproc, asmNoStackFrame.} =
+  {.emit: "`x`.push(`c`);".}
+
+{.pop.}
+
+proc tenToThePowerOf(b: int): BiggestFloat =
+  # xxx deadcode
+  var b = b
+  var a = 10.0
+  result = 1.0
+  while true:
+    if (b and 1) == 1:
+      result = result * a
+    b = b shr 1
+    if b == 0: break
+    a = a * a
+
+const
+  IdentChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
+
+
+proc parseFloatNative(a: openarray[char]): float =
+  var str = ""
+  for x in a:
+    str.add x
+
+  let cstr = cstring str
+
+  {.emit: """
+  `result` = Number(`cstr`);
+  """.}
+
+proc nimParseBiggestFloat(s: openarray[char], number: var BiggestFloat): int {.compilerproc.} =
+  var sign: bool
+  var i = 0
+  if s[i] == '+': inc(i)
+  elif s[i] == '-':
+    sign = true
+    inc(i)
+  if s[i] == 'N' or s[i] == 'n':
+    if s[i+1] == 'A' or s[i+1] == 'a':
+      if s[i+2] == 'N' or s[i+2] == 'n':
+        if s[i+3] notin IdentChars:
+          number = NaN
+          return i+3
+    return 0
+  if s[i] == 'I' or s[i] == 'i':
+    if s[i+1] == 'N' or s[i+1] == 'n':
+      if s[i+2] == 'F' or s[i+2] == 'f':
+        if s[i+3] notin IdentChars:
+          number = if sign: -Inf else: Inf
+          return i+3
+    return 0
+
+  var buf: string
+    # we could also use an `array[char, N]` buffer to avoid reallocs, or
+    # use a 2-pass algorithm that first computes the length.
+  if sign: buf.add '-'
+  template addInc =
+    buf.add s[i]
+    inc(i)
+  template eatUnderscores =
+    while s[i] == '_': inc(i)
+  while s[i] in {'0'..'9'}: # Read integer part
+    buf.add s[i]
+    inc(i)
+    eatUnderscores()
+  if s[i] == '.': # Decimal?
+    addInc()
+    while s[i] in {'0'..'9'}: # Read fractional part
+      addInc()
+      eatUnderscores()
+  # Again, read integer and fractional part
+  if buf.len == ord(sign): return 0
+  if s[i] in {'e', 'E'}: # Exponent?
+    addInc()
+    if s[i] == '+': inc(i)
+    elif s[i] == '-': addInc()
+    if s[i] notin {'0'..'9'}: return 0
+    while s[i] in {'0'..'9'}:
+      addInc()
+      eatUnderscores()
+  number = parseFloatNative(buf)
+  result = i
+
+# Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce
+# 'Math.trunc' for Nim's ``div`` and ``mod`` operators:
+when defined(nimJsMathTruncPolyfill):
+  {.emit: """
+if (!Math.trunc) {
+  Math.trunc = function(v) {
+    v = +v;
+    if (!isFinite(v)) return v;
+    return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
+  };
+}
+""".}
+
+proc cmpClosures(a, b: JSRef): bool {.compilerproc, asmNoStackFrame.} =
+  # Both `a` and `b` need to be a closure
+  {.emit: """
+    if (`a` !== null && `a`.ClP_0 !== undefined &&
+        `b` !== null && `b`.ClP_0 !== undefined) {
+      return `a`.ClP_0 == `b`.ClP_0 && `a`.ClE_0 == `b`.ClE_0;
+    } else {
+      return `a` == `b`;
+    }
+  """
+  .}
diff --git a/lib/system/memalloc.nim b/lib/system/memalloc.nim
new file mode 100644
index 000000000..a94d0995c
--- /dev/null
+++ b/lib/system/memalloc.nim
@@ -0,0 +1,449 @@
+when notJSnotNims:
+  proc zeroMem*(p: pointer, size: Natural) {.inline, noSideEffect,
+    tags: [], raises: [].}
+    ## Overwrites the contents of the memory at `p` with the value 0.
+    ##
+    ## Exactly `size` bytes will be overwritten. Like any procedure
+    ## dealing with raw memory this is **unsafe**.
+
+  proc copyMem*(dest, source: pointer, size: Natural) {.inline, benign,
+    tags: [], raises: [].}
+    ## Copies the contents from the memory at `source` to the memory
+    ## at `dest`.
+    ## Exactly `size` bytes will be copied. The memory
+    ## regions may not overlap. Like any procedure dealing with raw
+    ## memory this is **unsafe**.
+
+  proc moveMem*(dest, source: pointer, size: Natural) {.inline, benign,
+    tags: [], raises: [].}
+    ## Copies the contents from the memory at `source` to the memory
+    ## at `dest`.
+    ##
+    ## Exactly `size` bytes will be copied. The memory
+    ## regions may overlap, `moveMem` handles this case appropriately
+    ## and is thus somewhat more safe than `copyMem`. Like any procedure
+    ## dealing with raw memory this is still **unsafe**, though.
+
+  proc equalMem*(a, b: pointer, size: Natural): bool {.inline, noSideEffect,
+    tags: [], raises: [].}
+    ## Compares the memory blocks `a` and `b`. `size` bytes will
+    ## be compared.
+    ##
+    ## If the blocks are equal, `true` is returned, `false`
+    ## otherwise. Like any procedure dealing with raw memory this is
+    ## **unsafe**.
+
+  proc cmpMem*(a, b: pointer, size: Natural): int {.inline, noSideEffect,
+    tags: [], raises: [].}
+    ## Compares the memory blocks `a` and `b`. `size` bytes will
+    ## be compared.
+    ##
+    ## Returns:
+    ## * a value less than zero, if `a < b`
+    ## * a value greater than zero, if `a > b`
+    ## * zero, if `a == b`
+    ##
+    ## Like any procedure dealing with raw memory this is
+    ## **unsafe**.
+
+when hasAlloc and not defined(js):
+
+  proc allocImpl*(size: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+  proc alloc0Impl*(size: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+  proc deallocImpl*(p: pointer) {.noconv, rtl, tags: [], benign, raises: [].}
+  proc reallocImpl*(p: pointer, newSize: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+  proc realloc0Impl*(p: pointer, oldSize, newSize: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+
+  proc allocSharedImpl*(size: Natural): pointer {.noconv, compilerproc, rtl, benign, raises: [], tags: [].}
+  proc allocShared0Impl*(size: Natural): pointer {.noconv, rtl, benign, raises: [], tags: [].}
+  proc deallocSharedImpl*(p: pointer) {.noconv, rtl, benign, raises: [], tags: [].}
+  proc reallocSharedImpl*(p: pointer, newSize: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+  proc reallocShared0Impl*(p: pointer, oldSize, newSize: Natural): pointer {.noconv, rtl, tags: [], benign, raises: [].}
+
+  # Allocator statistics for memory leak tests
+
+  {.push stackTrace: off.}
+
+  type AllocStats* = object
+    allocCount: int
+    deallocCount: int
+
+  proc `-`*(a, b: AllocStats): AllocStats =
+    result.allocCount = a.allocCount - b.allocCount
+    result.deallocCount = a.deallocCount - b.deallocCount
+
+  template dumpAllocstats*(code: untyped) =
+    let stats1 = getAllocStats()
+    code
+    let stats2 = getAllocStats()
+    echo $(stats2 - stats1)
+
+  when defined(nimAllocStats):
+    var stats: AllocStats
+    template incStat(what: untyped) = atomicInc stats.what
+    proc getAllocStats*(): AllocStats = stats
+
+  else:
+    template incStat(what: untyped) = discard
+    proc getAllocStats*(): AllocStats = discard
+
+  template alloc*(size: Natural): pointer =
+    ## Allocates a new memory block with at least `size` bytes.
+    ##
+    ## The block has to be freed with `realloc(block, 0) <#realloc.t,pointer,Natural>`_
+    ## or `dealloc(block) <#dealloc,pointer>`_.
+    ## The block is not initialized, so reading
+    ## from it before writing to it is undefined behaviour!
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `allocShared <#allocShared.t,Natural>`_ to allocate from a shared heap.
+    ##
+    ## See also:
+    ## * `alloc0 <#alloc0.t,Natural>`_
+    incStat(allocCount)
+    allocImpl(size)
+
+  proc createU*(T: typedesc, size = 1.Positive): ptr T {.inline, benign, raises: [].} =
+    ## Allocates a new memory block with at least `T.sizeof * size` bytes.
+    ##
+    ## The block has to be freed with `resize(block, 0) <#resize,ptr.T,Natural>`_
+    ## or `dealloc(block) <#dealloc,pointer>`_.
+    ## The block is not initialized, so reading
+    ## from it before writing to it is undefined behaviour!
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `createSharedU <#createSharedU,typedesc>`_ to allocate from a shared heap.
+    ##
+    ## See also:
+    ## * `create <#create,typedesc>`_
+    cast[ptr T](alloc(T.sizeof * size))
+
+  template alloc0*(size: Natural): pointer =
+    ## Allocates a new memory block with at least `size` bytes.
+    ##
+    ## The block has to be freed with `realloc(block, 0) <#realloc.t,pointer,Natural>`_
+    ## or `dealloc(block) <#dealloc,pointer>`_.
+    ## The block is initialized with all bytes containing zero, so it is
+    ## somewhat safer than  `alloc <#alloc.t,Natural>`_.
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `allocShared0 <#allocShared0.t,Natural>`_ to allocate from a shared heap.
+    incStat(allocCount)
+    alloc0Impl(size)
+
+  proc create*(T: typedesc, size = 1.Positive): ptr T {.inline, benign, raises: [].} =
+    ## Allocates a new memory block with at least `T.sizeof * size` bytes.
+    ##
+    ## The block has to be freed with `resize(block, 0) <#resize,ptr.T,Natural>`_
+    ## or `dealloc(block) <#dealloc,pointer>`_.
+    ## The block is initialized with all bytes containing zero, so it is
+    ## somewhat safer than `createU <#createU,typedesc>`_.
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `createShared <#createShared,typedesc>`_ to allocate from a shared heap.
+    cast[ptr T](alloc0(sizeof(T) * size))
+
+  template realloc*(p: pointer, newSize: Natural): pointer =
+    ## Grows or shrinks a given memory block.
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `realloc` calls `dealloc(p)`.
+    ## In other cases the block has to be freed with
+    ## `dealloc(block) <#dealloc,pointer>`_.
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `reallocShared <#reallocShared.t,pointer,Natural>`_ to reallocate
+    ## from a shared heap.
+    reallocImpl(p, newSize)
+
+  template realloc0*(p: pointer, oldSize, newSize: Natural): pointer =
+    ## Grows or shrinks a given memory block.
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `realloc` calls `dealloc(p)`.
+    ## In other cases the block has to be freed with
+    ## `dealloc(block) <#dealloc,pointer>`_.
+    ##
+    ## The block is initialized with all bytes containing zero, so it is
+    ## somewhat safer then realloc
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `reallocShared <#reallocShared.t,pointer,Natural>`_ to reallocate
+    ## from a shared heap.
+    realloc0Impl(p, oldSize, newSize)
+
+  proc resize*[T](p: ptr T, newSize: Natural): ptr T {.inline, benign, raises: [].} =
+    ## Grows or shrinks a given memory block.
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `T.sizeof * newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `resize` calls `dealloc(p)`.
+    ## In other cases the block has to be freed with `free`.
+    ##
+    ## The allocated memory belongs to its allocating thread!
+    ## Use `resizeShared <#resizeShared,ptr.T,Natural>`_ to reallocate
+    ## from a shared heap.
+    cast[ptr T](realloc(p, T.sizeof * newSize))
+
+  proc dealloc*(p: pointer) {.noconv, compilerproc, rtl, benign, raises: [], tags: [].} =
+    ## Frees the memory allocated with `alloc`, `alloc0`,
+    ## `realloc`, `create` or `createU`.
+    ##
+    ## **This procedure is dangerous!**
+    ## If one forgets to free the memory a leak occurs; if one tries to
+    ## access freed memory (or just freeing it twice!) a core dump may happen
+    ## or other memory may be corrupted.
+    ##
+    ## The freed memory must belong to its allocating thread!
+    ## Use `deallocShared <#deallocShared,pointer>`_ to deallocate from a shared heap.
+    incStat(deallocCount)
+    deallocImpl(p)
+
+  template allocShared*(size: Natural): pointer =
+    ## Allocates a new memory block on the shared heap with at
+    ## least `size` bytes.
+    ##
+    ## The block has to be freed with
+    ## `reallocShared(block, 0) <#reallocShared.t,pointer,Natural>`_
+    ## or `deallocShared(block) <#deallocShared,pointer>`_.
+    ##
+    ## The block is not initialized, so reading from it before writing
+    ## to it is undefined behaviour!
+    ##
+    ## See also:
+    ## * `allocShared0 <#allocShared0.t,Natural>`_.
+    incStat(allocCount)
+    allocSharedImpl(size)
+
+  proc createSharedU*(T: typedesc, size = 1.Positive): ptr T {.inline, tags: [],
+                                                               benign, raises: [].} =
+    ## Allocates a new memory block on the shared heap with at
+    ## least `T.sizeof * size` bytes.
+    ##
+    ## The block has to be freed with
+    ## `resizeShared(block, 0) <#resizeShared,ptr.T,Natural>`_ or
+    ## `freeShared(block) <#freeShared,ptr.T>`_.
+    ##
+    ## The block is not initialized, so reading from it before writing
+    ## to it is undefined behaviour!
+    ##
+    ## See also:
+    ## * `createShared <#createShared,typedesc>`_
+    cast[ptr T](allocShared(T.sizeof * size))
+
+  template allocShared0*(size: Natural): pointer =
+    ## Allocates a new memory block on the shared heap with at
+    ## least `size` bytes.
+    ##
+    ## The block has to be freed with
+    ## `reallocShared(block, 0) <#reallocShared.t,pointer,Natural>`_
+    ## or `deallocShared(block) <#deallocShared,pointer>`_.
+    ##
+    ## The block is initialized with all bytes
+    ## containing zero, so it is somewhat safer than
+    ## `allocShared <#allocShared.t,Natural>`_.
+    incStat(allocCount)
+    allocShared0Impl(size)
+
+  proc createShared*(T: typedesc, size = 1.Positive): ptr T {.inline.} =
+    ## Allocates a new memory block on the shared heap with at
+    ## least `T.sizeof * size` bytes.
+    ##
+    ## The block has to be freed with
+    ## `resizeShared(block, 0) <#resizeShared,ptr.T,Natural>`_ or
+    ## `freeShared(block) <#freeShared,ptr.T>`_.
+    ##
+    ## The block is initialized with all bytes
+    ## containing zero, so it is somewhat safer than
+    ## `createSharedU <#createSharedU,typedesc>`_.
+    cast[ptr T](allocShared0(T.sizeof * size))
+
+  template reallocShared*(p: pointer, newSize: Natural): pointer =
+    ## Grows or shrinks a given memory block on the heap.
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `reallocShared` calls
+    ## `deallocShared(p)`.
+    ## In other cases the block has to be freed with
+    ## `deallocShared <#deallocShared,pointer>`_.
+    reallocSharedImpl(p, newSize)
+
+  template reallocShared0*(p: pointer, oldSize, newSize: Natural): pointer =
+    ## Grows or shrinks a given memory block on the heap.
+    ##
+    ## When growing, the new bytes of the block is initialized with all bytes
+    ## containing zero, so it is somewhat safer then reallocShared
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `reallocShared` calls
+    ## `deallocShared(p)`.
+    ## In other cases the block has to be freed with
+    ## `deallocShared <#deallocShared,pointer>`_.
+    reallocShared0Impl(p, oldSize, newSize)
+
+  proc resizeShared*[T](p: ptr T, newSize: Natural): ptr T {.inline, raises: [].} =
+    ## Grows or shrinks a given memory block on the heap.
+    ##
+    ## If `p` is **nil** then a new memory block is returned.
+    ## In either way the block has at least `T.sizeof * newSize` bytes.
+    ## If `newSize == 0` and `p` is not **nil** `resizeShared` calls
+    ## `freeShared(p)`.
+    ## In other cases the block has to be freed with
+    ## `freeShared <#freeShared,ptr.T>`_.
+    cast[ptr T](reallocShared(p, T.sizeof * newSize))
+
+  proc deallocShared*(p: pointer) {.noconv, compilerproc, rtl, benign, raises: [], tags: [].} =
+    ## Frees the memory allocated with `allocShared`, `allocShared0` or
+    ## `reallocShared`.
+    ##
+    ## **This procedure is dangerous!**
+    ## If one forgets to free the memory a leak occurs; if one tries to
+    ## access freed memory (or just freeing it twice!) a core dump may happen
+    ## or other memory may be corrupted.
+    incStat(deallocCount)
+    deallocSharedImpl(p)
+
+  proc freeShared*[T](p: ptr T) {.inline, benign, raises: [].} =
+    ## Frees the memory allocated with `createShared`, `createSharedU` or
+    ## `resizeShared`.
+    ##
+    ## **This procedure is dangerous!**
+    ## If one forgets to free the memory a leak occurs; if one tries to
+    ## access freed memory (or just freeing it twice!) a core dump may happen
+    ## or other memory may be corrupted.
+    deallocShared(p)
+
+  include bitmasks
+
+  template `+!`(p: pointer, s: SomeInteger): pointer =
+    cast[pointer](cast[int](p) +% int(s))
+
+  template `-!`(p: pointer, s: SomeInteger): pointer =
+    cast[pointer](cast[int](p) -% int(s))
+
+  proc alignedAlloc(size, align: Natural): pointer =
+    if align <= MemAlign:
+      when compileOption("threads"):
+        result = allocShared(size)
+      else:
+        result = alloc(size)
+    else:
+      # allocate (size + align - 1) necessary for alignment,
+      # plus 2 bytes to store offset
+      when compileOption("threads"):
+        let base = allocShared(size + align - 1 + sizeof(uint16))
+      else:
+        let base = alloc(size + align - 1 + sizeof(uint16))
+      # memory layout: padding + offset (2 bytes) + user_data
+      # in order to deallocate: read offset at user_data - 2 bytes,
+      # then deallocate user_data - offset
+      let offset = align - (cast[int](base) and (align - 1))
+      cast[ptr uint16](base +! (offset - sizeof(uint16)))[] = uint16(offset)
+      result = base +! offset
+
+  proc alignedAlloc0(size, align: Natural): pointer =
+    if align <= MemAlign:
+      when compileOption("threads"):
+        result = allocShared0(size)
+      else:
+        result = alloc0(size)
+    else:
+      # see comments for alignedAlloc
+      when compileOption("threads"):
+        let base = allocShared0(size + align - 1 + sizeof(uint16))
+      else:
+        let base = alloc0(size + align - 1 + sizeof(uint16))
+      let offset = align - (cast[int](base) and (align - 1))
+      cast[ptr uint16](base +! (offset - sizeof(uint16)))[] = uint16(offset)
+      result = base +! offset
+
+  proc alignedDealloc(p: pointer, align: int) {.compilerproc.} =
+    if align <= MemAlign:
+      when compileOption("threads"):
+        deallocShared(p)
+      else:
+        dealloc(p)
+    else:
+      # read offset at p - 2 bytes, then deallocate (p - offset) pointer
+      let offset = cast[ptr uint16](p -! sizeof(uint16))[]
+      when compileOption("threads"):
+        deallocShared(p -! offset)
+      else:
+        dealloc(p -! offset)
+
+  proc alignedRealloc(p: pointer, oldSize, newSize, align: Natural): pointer =
+    if align <= MemAlign:
+      when compileOption("threads"):
+        result = reallocShared(p, newSize)
+      else:
+        result = realloc(p, newSize)
+    else:
+      result = alignedAlloc(newSize, align)
+      copyMem(result, p, oldSize)
+      alignedDealloc(p, align)
+
+  proc alignedRealloc0(p: pointer, oldSize, newSize, align: Natural): pointer =
+    if align <= MemAlign:
+      when compileOption("threads"):
+        result = reallocShared0(p, oldSize, newSize)
+      else:
+        result = realloc0(p, oldSize, newSize)
+    else:
+      result = alignedAlloc(newSize, align)
+      copyMem(result, p, oldSize)
+      zeroMem(result +! oldSize, newSize - oldSize)
+      alignedDealloc(p, align)
+
+  {.pop.}
+
+# GC interface:
+
+when hasAlloc:
+  proc getOccupiedMem*(): int {.rtl.}
+    ## Returns the number of bytes that are owned by the process and hold data.
+
+  proc getFreeMem*(): int {.rtl.}
+    ## Returns the number of bytes that are owned by the process, but do not
+    ## hold any meaningful data.
+
+  proc getTotalMem*(): int {.rtl.}
+    ## Returns the number of bytes that are owned by the process.
+
+
+when defined(js):
+  # Stubs:
+  proc getOccupiedMem(): int = return -1
+  proc getFreeMem(): int = return -1
+  proc getTotalMem(): int = return -1
+
+  proc dealloc(p: pointer) = discard
+  proc alloc(size: Natural): pointer = discard
+  proc alloc0(size: Natural): pointer = discard
+  proc realloc(p: pointer, newsize: Natural): pointer = discard
+  proc realloc0(p: pointer, oldsize, newsize: Natural): pointer = discard
+
+  proc allocShared(size: Natural): pointer = discard
+  proc allocShared0(size: Natural): pointer = discard
+  proc deallocShared(p: pointer) = discard
+  proc reallocShared(p: pointer, newsize: Natural): pointer = discard
+  proc reallocShared0(p: pointer, oldsize, newsize: Natural): pointer = discard
+
+
+when hasAlloc and hasThreadSupport and not defined(useMalloc):
+  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.
diff --git a/lib/system/memory.nim b/lib/system/memory.nim
new file mode 100644
index 000000000..156773c48
--- /dev/null
+++ b/lib/system/memory.nim
@@ -0,0 +1,55 @@
+{.push stack_trace: off.}
+
+const useLibC = not defined(nimNoLibc)
+
+when useLibC:
+  import ansi_c
+
+proc nimCopyMem*(dest, source: pointer, size: Natural) {.nonReloadable, compilerproc, inline.} =
+  when useLibC:
+    c_memcpy(dest, source, cast[csize_t](size))
+  else:
+    let d = cast[ptr UncheckedArray[byte]](dest)
+    let s = cast[ptr UncheckedArray[byte]](source)
+    var i = 0
+    while i < size:
+      d[i] = s[i]
+      inc i
+
+proc nimSetMem*(a: pointer, v: cint, size: Natural) {.nonReloadable, inline.} =
+  when useLibC:
+    c_memset(a, v, cast[csize_t](size))
+  else:
+    let a = cast[ptr UncheckedArray[byte]](a)
+    var i = 0
+    let v = cast[byte](v)
+    while i < size:
+      a[i] = v
+      inc i
+
+proc nimZeroMem*(p: pointer, size: Natural) {.compilerproc, nonReloadable, inline.} =
+  nimSetMem(p, 0, size)
+
+proc nimCmpMem*(a, b: pointer, size: Natural): cint {.compilerproc, nonReloadable, inline.} =
+  when useLibC:
+    c_memcmp(a, b, cast[csize_t](size))
+  else:
+    let a = cast[ptr UncheckedArray[byte]](a)
+    let b = cast[ptr UncheckedArray[byte]](b)
+    var i = 0
+    while i < size:
+      let d = a[i].cint - b[i].cint
+      if d != 0: return d
+      inc i
+
+proc nimCStrLen*(a: cstring): int {.compilerproc, nonReloadable, inline.} =
+  if a.isNil: return 0
+  when useLibC:
+    cast[int](c_strlen(a))
+  else:
+    var a = cast[ptr byte](a)
+    while a[] != 0:
+      a = cast[ptr byte](cast[uint](a) + 1)
+      inc result
+
+{.pop.}
diff --git a/lib/system/memtracker.nim b/lib/system/memtracker.nim
new file mode 100644
index 000000000..289f4e024
--- /dev/null
+++ b/lib/system/memtracker.nim
@@ -0,0 +1,106 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Memory tracking support for Nim.
+
+when not defined(memTracker):
+  {.error: "Memory tracking support is turned off! Enable memory tracking by passing `--memtracker:on` to the compiler (see the Nim Compiler User Guide for more options).".}
+
+when defined(noSignalHandler):
+  {.error: "Memory tracking works better with the default signal handler.".}
+
+# We don't want to memtrack the tracking code ...
+{.push memtracker: off.}
+
+when declared(getThreadId):
+  template myThreadId(): untyped = getThreadId()
+else:
+  template myThreadId(): untyped = 0
+
+type
+  LogEntry* = object
+    op*: cstring
+    address*: pointer
+    size*: int
+    file*: cstring
+    line*: int
+    thread*: int
+  TrackLog* = object
+    count*: int
+    disabled: bool
+    data*: array[400, LogEntry]
+  TrackLogger* = proc (log: TrackLog) {.nimcall, tags: [], gcsafe.}
+
+var
+  gLog*: TrackLog
+  gLogger*: TrackLogger = proc (log: TrackLog) = discard
+  ilocs: array[4000, (int, int)]
+  ilocn: int
+
+proc trackLocation*(p: pointer; size: int) =
+  let x = (cast[int](p), size)
+  for i in 0..ilocn-1:
+    # already known?
+    if ilocs[i] == x: return
+  ilocs[ilocn] = x
+  inc ilocn
+
+proc setTrackLogger*(logger: TrackLogger) =
+  gLogger = logger
+
+proc addEntry(entry: LogEntry) =
+  if not gLog.disabled:
+    var interesting = false
+    for i in 0..ilocn-1:
+      let p = ilocs[i]
+      #  X..Y and C..D overlap iff (X <= D and C <= Y)
+      let x = p[0]
+      let y = p[0]+p[1]-1
+      let c = cast[int](entry.address)
+      let d = c + entry.size-1
+      if x <= d and c <= y:
+        interesting = myThreadId() != entry.thread # true
+        break
+    if interesting:
+      gLog.disabled = true
+      cprintf("interesting %s:%ld %s\n", entry.file, entry.line, entry.op)
+      let x = cast[proc() {.nimcall, tags: [], gcsafe, raises: [].}](writeStackTrace)
+      x()
+      rawQuit 1
+      #if gLog.count > high(gLog.data):
+      #  gLogger(gLog)
+      #  gLog.count = 0
+      #gLog.data[gLog.count] = entry
+      #inc gLog.count
+      #gLog.disabled = false
+
+proc memTrackerWrite(address: pointer; size: int; file: cstring; line: int) {.compilerproc.} =
+  addEntry LogEntry(op: "write", address: address,
+      size: size, file: file, line: line, thread: myThreadId())
+
+proc memTrackerOp*(op: cstring; address: pointer; size: int) {.tags: [],
+         gcsafe.} =
+  addEntry LogEntry(op: op, address: address, size: size,
+      file: "", line: 0, thread: myThreadId())
+
+proc memTrackerDisable*() =
+  gLog.disabled = true
+
+proc memTrackerEnable*() =
+  gLog.disabled = false
+
+proc logPendingOps() {.noconv.} =
+  # forward declared and called from Nim's signal handler.
+  gLogger(gLog)
+  gLog.count = 0
+
+import std/exitprocs
+addExitProc logPendingOps
+
+{.pop.}
diff --git a/lib/system/mm.nim b/lib/system/mm.nim
deleted file mode 100755
index 76b5d83bd..000000000
--- a/lib/system/mm.nim
+++ /dev/null
@@ -1,189 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# Nimrod high-level memory manager: It supports Boehm's GC, no GC and the
-# native Nimrod GC. The native Nimrod GC is the default.
-
-#{.push checks:on, assertions:on.}
-{.push checks:off.}
-
-const
-  debugGC = false # we wish to debug the GC...
-  logGC = false
-  traceGC = false # extensive debugging
-  reallyDealloc = true # for debugging purposes this can be set to false
-  cycleGC = true # (de)activate the cycle GC
-  stressGC = false
-  reallyOsDealloc = true
-  coalescRight = true
-  coalescLeft = true
-  overwriteFree = false
-
-type
-  PPointer = ptr pointer
-  TByteArray = array[0..1000_0000, byte]
-  PByte = ptr TByteArray
-  PString = ptr string
-
-# Page size of the system; in most cases 4096 bytes. For exotic OS or
-# CPU this needs to be changed:
-const
-  PageShift = 12
-  PageSize = 1 shl PageShift
-  PageMask = PageSize-1
-
-  MemAlign = 8 # also minimal allocatable memory block
-
-  BitsPerPage = PageSize div MemAlign
-  UnitsPerPage = BitsPerPage div (sizeof(int)*8)
-    # how many ints do we need to describe a page:
-    # on 32 bit systems this is only 16 (!)
-
-  TrunkShift = 9
-  BitsPerTrunk = 1 shl TrunkShift # needs to be power of 2 and divisible by 64
-  TrunkMask = BitsPerTrunk - 1
-  IntsPerTrunk = BitsPerTrunk div (sizeof(int)*8)
-  IntShift = 5 + ord(sizeof(int) == 8) # 5 or 6, depending on int width
-  IntMask = 1 shl IntShift - 1
-
-var
-  gOutOfMem: ref EOutOfMemory
-
-proc raiseOutOfMem() {.noreturn.} =
-  if gOutOfMem == nil: quit("out of memory; cannot even throw an exception")
-  gOutOfMem.msg = "out of memory"
-  raise gOutOfMem
-
-when defined(boehmgc):
-  when defined(windows):
-    const boehmLib = "boehmgc.dll"
-  else:
-    const boehmLib = "/usr/lib/libgc.so.1"
-
-  proc boehmGC_disable {.importc: "GC_disable", dynlib: boehmLib.} 
-  proc boehmGC_enable {.importc: "GC_enable", dynlib: boehmLib.} 
-  proc boehmGCincremental {.
-    importc: "GC_enable_incremental", dynlib: boehmLib.} 
-  proc boehmGCfullCollect {.importc: "GC_gcollect", dynlib: boehmLib.}  
-  proc boehmAlloc(size: int): pointer {.
-    importc: "GC_malloc", dynlib: boehmLib.}
-  proc boehmAllocAtomic(size: int): pointer {.
-    importc: "GC_malloc_atomic", dynlib: boehmLib.}
-  proc boehmRealloc(p: pointer, size: int): pointer {.
-    importc: "GC_realloc", dynlib: boehmLib.}
-  proc boehmDealloc(p: pointer) {.importc: "GC_free", dynlib: boehmLib.}
-    
-  proc alloc(size: int): pointer =
-    result = boehmAlloc(size)
-    if result == nil: raiseOutOfMem()
-  proc alloc0(size: int): pointer =
-    result = alloc(size)
-    zeroMem(result, size)
-  proc realloc(p: Pointer, newsize: int): pointer =
-    result = boehmRealloc(p, newsize)
-    if result == nil: raiseOutOfMem()
-  proc dealloc(p: Pointer) =
-    boehmDealloc(p)
-
-  proc initGC() = nil
-  
-  #boehmGCincremental()
-
-  proc GC_disable() = boehmGC_disable()
-  proc GC_enable() = boehmGC_enable()
-  proc GC_fullCollect() = boehmGCfullCollect()
-  proc GC_setStrategy(strategy: TGC_Strategy) = nil
-  proc GC_enableMarkAndSweep() = nil
-  proc GC_disableMarkAndSweep() = nil
-  proc GC_getStatistics(): string = return ""
-  
-  proc getOccupiedMem(): int = return -1
-  proc getFreeMem(): int = return -1
-  proc getTotalMem(): int = return -1
-
-  proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
-    result = alloc(size)
-  proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
-    result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
-    cast[PGenericSeq](result).len = len
-    cast[PGenericSeq](result).space = len
-
-  proc growObj(old: pointer, newsize: int): pointer =
-    result = realloc(old, newsize)
-
-  proc setStackBottom(theStackBottom: pointer) {.compilerproc.} = nil
-  proc nimGCref(p: pointer) {.compilerproc, inline.} = nil
-  proc nimGCunref(p: pointer) {.compilerproc, inline.} = nil
-  
-  proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-  proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-  proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-
-  include "system/cellsets"
-elif defined(nogc):
-  include "system/alloc"
-
-  when false:
-    proc alloc(size: int): pointer =
-      result = c_malloc(size)
-      if result == nil: raiseOutOfMem()
-    proc alloc0(size: int): pointer =
-      result = alloc(size)
-      zeroMem(result, size)
-    proc realloc(p: Pointer, newsize: int): pointer =
-      result = c_realloc(p, newsize)
-      if result == nil: raiseOutOfMem()
-    proc dealloc(p: Pointer) = c_free(p)
-    proc getOccupiedMem(): int = return -1
-    proc getFreeMem(): int = return -1
-    proc getTotalMem(): int = return -1
-
-  proc initGC() = nil
-  proc GC_disable() = nil
-  proc GC_enable() = nil
-  proc GC_fullCollect() = nil
-  proc GC_setStrategy(strategy: TGC_Strategy) = nil
-  proc GC_enableMarkAndSweep() = nil
-  proc GC_disableMarkAndSweep() = nil
-  proc GC_getStatistics(): string = return ""
-  
-  
-  proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
-    result = alloc0(size)
-  proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
-    result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
-    cast[PGenericSeq](result).len = len
-    cast[PGenericSeq](result).space = len
-  proc growObj(old: pointer, newsize: int): pointer =
-    result = realloc(old, newsize)
-
-  proc setStackBottom(theStackBottom: pointer) {.compilerproc.} = nil
-  proc nimGCref(p: pointer) {.compilerproc, inline.} = nil
-  proc nimGCunref(p: pointer) {.compilerproc, inline.} = nil
-  
-  proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-  proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-  proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
-    dest^ = src
-
-  include "system/cellsets"
-else:
-  include "system/alloc"
-  include "system/cellsets"
-  assert(sizeof(TCell) == sizeof(TFreeCell))
-  include "system/gc"
-  
-{.pop.}
-
-  
diff --git a/lib/system/mm/boehm.nim b/lib/system/mm/boehm.nim
new file mode 100644
index 000000000..362d2d470
--- /dev/null
+++ b/lib/system/mm/boehm.nim
@@ -0,0 +1,140 @@
+
+
+
+proc boehmGCinit {.importc: "GC_init", boehmGC.}
+proc boehmGC_disable {.importc: "GC_disable", boehmGC.}
+proc boehmGC_enable {.importc: "GC_enable", boehmGC.}
+proc boehmGCincremental {.
+  importc: "GC_enable_incremental", boehmGC.}
+proc boehmGCfullCollect {.importc: "GC_gcollect", boehmGC.}
+proc boehmGC_set_all_interior_pointers(flag: cint) {.
+  importc: "GC_set_all_interior_pointers", boehmGC.}
+proc boehmAlloc(size: int): pointer {.importc: "GC_malloc", boehmGC.}
+proc boehmAllocAtomic(size: int): pointer {.
+  importc: "GC_malloc_atomic", boehmGC.}
+proc boehmRealloc(p: pointer, size: int): pointer {.
+  importc: "GC_realloc", boehmGC.}
+proc boehmDealloc(p: pointer) {.importc: "GC_free", boehmGC.}
+when hasThreadSupport:
+  proc boehmGC_allow_register_threads {.
+    importc: "GC_allow_register_threads", boehmGC.}
+
+proc boehmGetHeapSize: int {.importc: "GC_get_heap_size", boehmGC.}
+  ## Return the number of bytes in the heap.  Excludes collector private
+  ## data structures. Includes empty blocks and fragmentation loss.
+  ## Includes some pages that were allocated but never written.
+
+proc boehmGetFreeBytes: int {.importc: "GC_get_free_bytes", boehmGC.}
+  ## Return a lower bound on the number of free bytes in the heap.
+
+proc boehmGetBytesSinceGC: int {.importc: "GC_get_bytes_since_gc", boehmGC.}
+  ## Return the number of bytes allocated since the last collection.
+
+proc boehmGetTotalBytes: int {.importc: "GC_get_total_bytes", boehmGC.}
+  ## Return the total number of bytes allocated in this process.
+  ## Never decreases.
+
+proc boehmRegisterFinalizer(obj, ff, cd, off, ocd: pointer) {.importc: "GC_register_finalizer", boehmGC.}
+
+proc allocAtomic(size: int): pointer =
+  result = boehmAllocAtomic(size)
+  zeroMem(result, size)
+
+when not defined(useNimRtl):
+
+  proc allocImpl(size: Natural): pointer =
+    result = boehmAlloc(size)
+    if result == nil: raiseOutOfMem()
+  proc alloc0Impl(size: Natural): pointer =
+    result = alloc(size)
+  proc reallocImpl(p: pointer, newSize: Natural): pointer =
+    result = boehmRealloc(p, newSize)
+    if result == nil: raiseOutOfMem()
+  proc realloc0Impl(p: pointer, oldSize, newSize: Natural): pointer =
+    result = boehmRealloc(p, newSize)
+    if result == nil: raiseOutOfMem()
+    if newSize > oldSize:
+      zeroMem(cast[pointer](cast[int](result) + oldSize), newSize - oldSize)
+  proc deallocImpl(p: pointer) = boehmDealloc(p)
+
+  proc allocSharedImpl(size: Natural): pointer = allocImpl(size)
+  proc allocShared0Impl(size: Natural): pointer = alloc0Impl(size)
+  proc reallocSharedImpl(p: pointer, newSize: Natural): pointer = reallocImpl(p, newSize)
+  proc reallocShared0Impl(p: pointer, oldSize, newSize: Natural): pointer = realloc0Impl(p, oldSize, newSize)
+  proc deallocSharedImpl(p: pointer) = deallocImpl(p)
+
+  when hasThreadSupport:
+    proc getFreeSharedMem(): int =
+      boehmGetFreeBytes()
+    proc getTotalSharedMem(): int =
+      boehmGetHeapSize()
+    proc getOccupiedSharedMem(): int =
+      getTotalSharedMem() - getFreeSharedMem()
+
+  #boehmGCincremental()
+
+  proc GC_disable() = boehmGC_disable()
+  proc GC_enable() = boehmGC_enable()
+  proc GC_fullCollect() = boehmGCfullCollect()
+  proc GC_setStrategy(strategy: GC_Strategy) = discard
+  proc GC_enableMarkAndSweep() = discard
+  proc GC_disableMarkAndSweep() = discard
+  proc GC_getStatistics(): string = return ""
+
+  proc getOccupiedMem(): int = return boehmGetHeapSize()-boehmGetFreeBytes()
+  proc getFreeMem(): int = return boehmGetFreeBytes()
+  proc getTotalMem(): int = return boehmGetHeapSize()
+
+  proc nimGC_setStackBottom(theStackBottom: pointer) = discard
+
+proc initGC() =
+  when defined(boehmNoIntPtr):
+    # See #12286
+    boehmGC_set_all_interior_pointers(0)
+  boehmGCinit()
+  when hasThreadSupport:
+    boehmGC_allow_register_threads()
+
+proc boehmgc_finalizer(obj: pointer, typedFinalizer: (proc(x: pointer) {.cdecl.})) =
+  typedFinalizer(obj)
+
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
+  if ntfNoRefs in typ.flags: result = allocAtomic(size)
+  else: result = alloc(size)
+  if typ.finalizer != nil:
+    boehmRegisterFinalizer(result, boehmgc_finalizer, typ.finalizer, nil, nil)
+{.push overflowChecks: on.}
+proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
+  result = newObj(typ, align(GenericSeqSize, typ.base.align) + len * typ.base.size)
+  cast[PGenericSeq](result).len = len
+  cast[PGenericSeq](result).reserved = len
+{.pop.}
+
+proc growObj(old: pointer, newsize: int): pointer =
+  result = realloc(old, newsize)
+
+proc nimGCref(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunref(p: pointer) {.compilerproc, inline.} = discard
+
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
+
+type
+  MemRegion = object
+
+proc alloc(r: var MemRegion, size: int): pointer =
+  result = boehmAlloc(size)
+  if result == nil: raiseOutOfMem()
+proc alloc0(r: var MemRegion, size: int): pointer =
+  result = alloc(size)
+  zeroMem(result, size)
+proc dealloc(r: var MemRegion, p: pointer) = boehmDealloc(p)
+proc deallocOsPages(r: var MemRegion) {.inline.} = discard
+proc deallocOsPages() {.inline.} = discard
+
+include "system/cellsets"
diff --git a/lib/system/mm/go.nim b/lib/system/mm/go.nim
new file mode 100644
index 000000000..8f3aeb964
--- /dev/null
+++ b/lib/system/mm/go.nim
@@ -0,0 +1,153 @@
+
+when defined(windows):
+  const goLib = "libgo.dll"
+elif defined(macosx):
+  const goLib = "libgo.dylib"
+else:
+  const goLib = "libgo.so"
+
+proc initGC() = discard
+proc GC_disable() = discard
+proc GC_enable() = discard
+proc go_gc() {.importc: "go_gc", dynlib: goLib.}
+proc GC_fullCollect() = go_gc()
+proc GC_setStrategy(strategy: GC_Strategy) = discard
+proc GC_enableMarkAndSweep() = discard
+proc GC_disableMarkAndSweep() = discard
+
+const
+  goNumSizeClasses = 67
+
+type
+  goMStats = object
+    alloc: uint64          # bytes allocated and still in use
+    total_alloc: uint64    # bytes allocated (even if freed)
+    sys: uint64            # bytes obtained from system
+    nlookup: uint64        # number of pointer lookups
+    nmalloc: uint64        # number of mallocs
+    nfree: uint64          # number of frees
+    heap_objects: uint64   # total number of allocated objects
+    pause_total_ns: uint64 # cumulative nanoseconds in GC stop-the-world pauses since the program started
+    numgc: uint32          # number of completed GC cycles
+
+proc goMemStats(): goMStats {.importc: "go_mem_stats", dynlib: goLib.}
+proc goMalloc(size: uint): pointer {.importc: "go_malloc", dynlib: goLib.}
+proc goSetFinalizer(obj: pointer, f: pointer) {.importc: "set_finalizer", codegenDecl:"$1 $2$3 __asm__ (\"main.Set_finalizer\");\n$1 $2$3", dynlib: goLib.}
+proc writebarrierptr(dest: PPointer, src: pointer) {.importc: "writebarrierptr", codegenDecl:"$1 $2$3 __asm__ (\"main.Atomic_store_pointer\");\n$1 $2$3", dynlib: goLib.}
+
+proc GC_getStatistics(): string =
+  var mstats = goMemStats()
+  result = "[GC] total allocated memory: " & $(mstats.total_alloc) & "\n" &
+           "[GC] total memory obtained from system: " & $(mstats.sys) & "\n" &
+           "[GC] occupied memory: " & $(mstats.alloc) & "\n" &
+           "[GC] number of pointer lookups: " & $(mstats.nlookup) & "\n" &
+           "[GC] number of mallocs: " & $(mstats.nmalloc) & "\n" &
+           "[GC] number of frees: " & $(mstats.nfree) & "\n" &
+           "[GC] heap objects: " & $(mstats.heap_objects) & "\n" &
+           "[GC] number of completed GC cycles: " & $(mstats.numgc) & "\n" &
+           "[GC] total GC pause time [ms]: " & $(mstats.pause_total_ns div 1000_000)
+
+proc getOccupiedMem(): int =
+  var mstats = goMemStats()
+  result = int(mstats.alloc)
+
+proc getFreeMem(): int =
+  var mstats = goMemStats()
+  result = int(mstats.sys - mstats.alloc)
+
+proc getTotalMem(): int =
+  var mstats = goMemStats()
+  result = int(mstats.sys)
+
+proc nimGC_setStackBottom(theStackBottom: pointer) = discard
+
+proc allocImpl(size: Natural): pointer =
+  result = goMalloc(size.uint)
+
+proc alloc0Impl(size: Natural): pointer =
+  result = goMalloc(size.uint)
+
+proc reallocImpl(p: pointer, newsize: Natural): pointer =
+  doAssert false, "not implemented"
+
+proc realloc0Impl(p: pointer, oldsize, newsize: Natural): pointer =
+  doAssert false, "not implemented"
+
+proc deallocImpl(p: pointer) =
+  discard
+
+proc allocSharedImpl(size: Natural): pointer = allocImpl(size)
+proc allocShared0Impl(size: Natural): pointer = alloc0Impl(size)
+proc reallocSharedImpl(p: pointer, newsize: Natural): pointer = reallocImpl(p, newsize)
+proc reallocShared0Impl(p: pointer, oldsize, newsize: Natural): pointer = realloc0Impl(p, oldsize, newsize)
+proc deallocSharedImpl(p: pointer) = deallocImpl(p)
+
+when hasThreadSupport:
+  proc getFreeSharedMem(): int = discard
+  proc getTotalSharedMem(): int = discard
+  proc getOccupiedSharedMem(): int = discard
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
+  writebarrierptr(addr(result), goMalloc(size.uint))
+  if typ.finalizer != nil:
+    goSetFinalizer(result, typ.finalizer)
+
+proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
+  writebarrierptr(addr(result), newObj(typ, size))
+
+proc newObjNoInit(typ: PNimType, size: int): pointer =
+  writebarrierptr(addr(result), newObj(typ, size))
+
+proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
+  writebarrierptr(addr(result), newObj(typ, align(GenericSeqSize, typ.base.align) + len * typ.base.size))
+  cast[PGenericSeq](result).len = len
+  cast[PGenericSeq](result).reserved = len
+  cast[PGenericSeq](result).elemSize = typ.base.size
+  cast[PGenericSeq](result).elemAlign = typ.base.align
+
+proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
+  writebarrierptr(addr(result), newSeq(typ, len))
+
+proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
+  result = newObjNoInit(typ, align(GenericSeqSize, typ.base.align) + cap * typ.base.size)
+  cast[PGenericSeq](result).len = 0
+  cast[PGenericSeq](result).reserved = cap
+  cast[PGenericSeq](result).elemSize = typ.base.size
+  cast[PGenericSeq](result).elemAlign = typ.base.align
+
+proc typedMemMove(dest: pointer, src: pointer, size: uint) {.importc: "typedmemmove", dynlib: goLib.}
+
+proc growObj(old: pointer, newsize: int): pointer =
+  # the Go GC doesn't have a realloc
+  let old = cast[PGenericSeq](old)
+  var metadataOld = cast[PGenericSeq](old)
+  if metadataOld.elemSize == 0:
+    metadataOld.elemSize = 1
+
+  let oldsize = align(GenericSeqSize, old.elemAlign) + old.len * old.elemSize
+  writebarrierptr(addr(result), goMalloc(newsize.uint))
+  typedMemMove(result, old, oldsize.uint)
+
+proc nimGCref(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunref(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunrefNoCycle(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunrefRC1(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = discard
+
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  writebarrierptr(dest, src)
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  writebarrierptr(dest, src)
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
+
+type
+  MemRegion = object
+
+proc alloc(r: var MemRegion, size: int): pointer =
+  result = alloc(size)
+proc alloc0(r: var MemRegion, size: int): pointer =
+  result = alloc0Impl(size)
+proc dealloc(r: var MemRegion, p: pointer) = dealloc(p)
+proc deallocOsPages(r: var MemRegion) {.inline.} = discard
+proc deallocOsPages() {.inline.} = discard
diff --git a/lib/system/mm/malloc.nim b/lib/system/mm/malloc.nim
new file mode 100644
index 000000000..47f1a95ae
--- /dev/null
+++ b/lib/system/mm/malloc.nim
@@ -0,0 +1,97 @@
+
+{.push stackTrace: off.}
+
+proc allocImpl(size: Natural): pointer =
+  result = c_malloc(size.csize_t)
+  when defined(zephyr):
+    if result == nil:
+      raiseOutOfMem()
+
+proc alloc0Impl(size: Natural): pointer =
+  result = c_calloc(size.csize_t, 1)
+  when defined(zephyr):
+    if result == nil:
+      raiseOutOfMem()
+
+proc reallocImpl(p: pointer, newSize: Natural): pointer =
+  result = c_realloc(p, newSize.csize_t)
+  when defined(zephyr):
+    if result == nil:
+      raiseOutOfMem()
+
+proc realloc0Impl(p: pointer, oldsize, newSize: Natural): pointer =
+  result = realloc(p, newSize.csize_t)
+  if newSize > oldSize:
+    zeroMem(cast[pointer](cast[uint](result) + uint(oldSize)), newSize - oldSize)
+
+proc deallocImpl(p: pointer) =
+  c_free(p)
+
+
+# The shared allocators map on the regular ones
+
+proc allocSharedImpl(size: Natural): pointer =
+  allocImpl(size)
+
+proc allocShared0Impl(size: Natural): pointer =
+  alloc0Impl(size)
+
+proc reallocSharedImpl(p: pointer, newSize: Natural): pointer =
+  reallocImpl(p, newSize)
+
+proc reallocShared0Impl(p: pointer, oldsize, newSize: Natural): pointer =
+  realloc0Impl(p, oldSize, newSize)
+
+proc deallocSharedImpl(p: pointer) = deallocImpl(p)
+
+
+# Empty stubs for the GC
+
+proc GC_disable() = discard
+proc GC_enable() = discard
+
+when not defined(gcOrc):
+  proc GC_fullCollect() = discard
+  proc GC_enableMarkAndSweep() = discard
+  proc GC_disableMarkAndSweep() = discard
+
+proc GC_setStrategy(strategy: GC_Strategy) = discard
+
+proc getOccupiedMem(): int = discard
+proc getFreeMem(): int = discard
+proc getTotalMem(): int = discard
+
+proc nimGC_setStackBottom(theStackBottom: pointer) = discard
+
+proc initGC() = discard
+
+proc newObjNoInit(typ: PNimType, size: int): pointer =
+  result = alloc(size)
+
+proc growObj(old: pointer, newsize: int): pointer =
+  result = realloc(old, newsize)
+
+proc nimGCref(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunref(p: pointer) {.compilerproc, inline.} = discard
+
+when not defined(gcDestructors):
+  proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+    dest[] = src
+
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
+
+type
+  MemRegion = object
+
+proc alloc(r: var MemRegion, size: int): pointer =
+  result = alloc(size)
+proc alloc0(r: var MemRegion, size: int): pointer =
+  result = alloc0Impl(size)
+proc dealloc(r: var MemRegion, p: pointer) = dealloc(p)
+proc deallocOsPages(r: var MemRegion) = discard
+proc deallocOsPages() = discard
+
+{.pop.}
diff --git a/lib/system/mm/none.nim b/lib/system/mm/none.nim
new file mode 100644
index 000000000..7818a0805
--- /dev/null
+++ b/lib/system/mm/none.nim
@@ -0,0 +1,46 @@
+
+when appType == "lib":
+  {.warning: "nogc in a library context may not work".}
+
+include "system/alloc"
+
+proc initGC() = discard
+proc GC_disable() = discard
+proc GC_enable() = discard
+proc GC_fullCollect() = discard
+proc GC_setStrategy(strategy: GC_Strategy) = discard
+proc GC_enableMarkAndSweep() = discard
+proc GC_disableMarkAndSweep() = discard
+proc GC_getStatistics(): string = return ""
+
+proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
+  result = alloc0Impl(size)
+
+proc newObjNoInit(typ: PNimType, size: int): pointer =
+  result = alloc(size)
+
+{.push overflowChecks: on.}
+proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
+  result = newObj(typ, align(GenericSeqSize, typ.align) + len * typ.base.size)
+  cast[PGenericSeq](result).len = len
+  cast[PGenericSeq](result).reserved = len
+{.pop.}
+
+proc growObj(old: pointer, newsize: int): pointer =
+  result = realloc(old, newsize)
+
+proc nimGC_setStackBottom(theStackBottom: pointer) = discard
+proc nimGCref(p: pointer) {.compilerproc, inline.} = discard
+proc nimGCunref(p: pointer) {.compilerproc, inline.} = discard
+
+proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRef(dest: PPointer, src: pointer) {.compilerproc, inline.} =
+  dest[] = src
+proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline,
+  deprecated: "old compiler compat".} = asgnRef(dest, src)
+
+var allocator {.rtlThreadVar.}: MemRegion
+instantiateForRegion(allocator)
+
+include "system/cellsets"
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim
new file mode 100644
index 000000000..26f2f0bbf
--- /dev/null
+++ b/lib/system/mmdisp.nim
@@ -0,0 +1,120 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Nim high-level memory manager: It supports Boehm's GC, Go's GC, no GC and the
+# native Nim GC. The native Nim GC is the default.
+
+#{.push checks:on, assertions:on.}
+{.push checks:off.}
+
+const
+  debugGC = false # we wish to debug the GC...
+  logGC = false
+  traceGC = false # extensive debugging
+  alwaysCycleGC = defined(nimSmokeCycles)
+  alwaysGC = defined(nimFulldebug) # collect after every memory
+                                # allocation (for debugging)
+  leakDetector = defined(nimLeakDetector)
+  overwriteFree = defined(nimBurnFree) # overwrite memory with 0xFF before free
+  trackAllocationSource = leakDetector
+
+  cycleGC = true # (de)activate the cycle GC
+  reallyDealloc = true # for debugging purposes this can be set to false
+  reallyOsDealloc = true
+  coalescRight = true
+  coalescLeft = true
+  logAlloc = false
+  useCellIds = defined(nimCorruption)
+
+type
+  PPointer = ptr pointer
+  ByteArray = UncheckedArray[byte]
+  PByte = ptr ByteArray
+  PString = ptr string
+
+when declared(IntsPerTrunk):
+  discard
+else:
+  include bitmasks
+
+proc raiseOutOfMem() {.noinline.} =
+  if outOfMemHook != nil: outOfMemHook()
+  cstderr.rawWrite("out of memory\n")
+  rawQuit(1)
+
+when defined(boehmgc):
+  include system / mm / boehm
+
+elif defined(gogc):
+  include system / mm / go
+
+elif (defined(nogc) or defined(gcDestructors)) and defined(useMalloc):
+  include system / mm / malloc
+
+  when defined(nogc):
+    proc GC_getStatistics(): string = ""
+    proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
+      result = alloc0(size)
+
+    proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
+      result = newObj(typ, align(GenericSeqSize, typ.align) + len * typ.base.size)
+      cast[PGenericSeq](result).len = len
+      cast[PGenericSeq](result).reserved = len
+
+elif defined(nogc):
+  include system / mm / none
+
+else:
+  when not defined(gcRegions):
+    include "system/alloc"
+
+    when not usesDestructors:
+      include "system/cellsets"
+    when not leakDetector and not useCellIds and not defined(nimV2):
+      sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell")
+  when defined(gcRegions):
+    # XXX due to bootstrapping reasons, we cannot use  compileOption("gc", "stack") here
+    include "system/gc_regions"
+  elif defined(nimV2) or usesDestructors:
+    when not defined(useNimRtl):
+      var allocator {.rtlThreadVar.}: MemRegion
+      instantiateForRegion(allocator)
+    when defined(gcHooks):
+      include "system/gc_hooks"
+  elif defined(gcMarkAndSweep):
+    # XXX use 'compileOption' here
+    include "system/gc_ms"
+  else:
+    include "system/gc"
+
+when not declared(nimNewSeqOfCap) and not defined(nimSeqsV2):
+  {.push overflowChecks: on.}
+  proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
+    when defined(gcRegions):
+      let s = cap * typ.base.size  # newStr already adds GenericSeqSize
+      result = newStr(typ, s, ntfNoRefs notin typ.base.flags)
+    else:
+      let s = align(GenericSeqSize, typ.base.align) + cap * typ.base.size
+      when declared(newObjNoInit):
+        result = if ntfNoRefs in typ.base.flags: newObjNoInit(typ, s) else: newObj(typ, s)
+      else:
+        result = newObj(typ, s)
+      cast[PGenericSeq](result).len = 0
+      cast[PGenericSeq](result).reserved = cap
+  {.pop.}
+
+{.pop.}
+
+when not declared(ForeignCell):
+  type ForeignCell* = object
+    data*: pointer
+
+  proc protect*(x: pointer): ForeignCell = ForeignCell(data: x)
+  proc dispose*(x: ForeignCell) = discard
+  proc isNotForeign*(x: ForeignCell): bool = false
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim
new file mode 100644
index 000000000..cf81f6d86
--- /dev/null
+++ b/lib/system/nimscript.nim
@@ -0,0 +1,452 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## To learn about scripting in Nim see `NimScript<nims.html>`_
+
+# Nim's configuration system now uses Nim for scripting. This module provides
+# a few things that are required for this to work.
+
+const
+  buildOS* {.magic: "BuildOS".}: string = ""
+    ## The OS this build is running on. Can be different from `system.hostOS`
+    ## for cross compilations.
+
+  buildCPU* {.magic: "BuildCPU".}: string = ""
+    ## The CPU this build is running on. Can be different from `system.hostCPU`
+    ## for cross compilations.
+
+template builtin = discard
+
+# We know the effects better than the compiler:
+{.push hint[XDeclaredButNotUsed]: off.}
+
+proc listDirsImpl(dir: string): seq[string] {.
+  tags: [ReadIOEffect], raises: [OSError].} = builtin
+proc listFilesImpl(dir: string): seq[string] {.
+  tags: [ReadIOEffect], raises: [OSError].} = builtin
+proc removeDir(dir: string, checkDir = true) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc removeFile(dir: string) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc moveFile(src, dest: string) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc moveDir(src, dest: string) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc copyFile(src, dest: string) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc copyDir(src, dest: string) {.
+  tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
+proc createDir(dir: string) {.tags: [WriteIOEffect], raises: [OSError].} =
+  builtin
+
+proc getError: string = builtin
+proc setCurrentDir(dir: string) = builtin
+proc getCurrentDir*(): string =
+  ## Retrieves the current working directory.
+  builtin
+proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} =
+  builtin
+
+proc warningImpl(arg, orig: string) = discard
+proc hintImpl(arg, orig: string) = discard
+
+proc paramStr*(i: int): string =
+  ## Retrieves the `i`'th command line parameter.
+  builtin
+
+proc paramCount*(): int =
+  ## Retrieves the number of command line parameters.
+  builtin
+
+proc switch*(key: string, val="") =
+  ## Sets a Nim compiler command line switch, for
+  ## example `switch("checks", "on")`.
+  builtin
+
+proc warning*(name: string; val: bool) =
+  ## Disables or enables a specific warning.
+  let v = if val: "on" else: "off"
+  warningImpl(name & ":" & v, "warning:" & name & ":" & v)
+
+proc hint*(name: string; val: bool) =
+  ## Disables or enables a specific hint.
+  let v = if val: "on" else: "off"
+  hintImpl(name & ":" & v, "hint:" & name & ":" & v)
+
+proc patchFile*(package, filename, replacement: string) =
+  ## Overrides the location of a given file belonging to the
+  ## passed package.
+  ## If the `replacement` is not an absolute path, the path
+  ## is interpreted to be local to the Nimscript file that contains
+  ## the call to `patchFile`, Nim's `--path` is not used at all
+  ## to resolve the filename!
+  ## The compiler also performs `path substitution <nimc.html#compiler-usage-commandminusline-switches>`_ on `replacement`.
+  ##
+  ## Example:
+  ##   ```nim
+  ##   patchFile("stdlib", "asyncdispatch", "patches/replacement")
+  ##   ```
+  discard
+
+proc getCommand*(): string =
+  ## Gets the Nim command that the compiler has been invoked with, for example
+  ## "c", "js", "build", "help".
+  builtin
+
+proc setCommand*(cmd: string; project="") =
+  ## Sets the Nim command that should be continued with after this Nimscript
+  ## has finished.
+  builtin
+
+proc cmpIgnoreStyle(a, b: string): int = builtin
+proc cmpIgnoreCase(a, b: string): int = builtin
+
+proc cmpic*(a, b: string): int =
+  ## Compares `a` and `b` ignoring case.
+  cmpIgnoreCase(a, b)
+
+proc getEnv*(key: string; default = ""): string {.tags: [ReadIOEffect].} =
+  ## Retrieves the environment variable of name `key`.
+  builtin
+
+proc existsEnv*(key: string): bool {.tags: [ReadIOEffect].} =
+  ## Checks for the existence of an environment variable named `key`.
+  builtin
+
+proc putEnv*(key, val: string) {.tags: [WriteIOEffect].} =
+  ## Sets the value of the environment variable named `key` to `val`.
+  builtin
+
+proc delEnv*(key: string) {.tags: [WriteIOEffect].} =
+  ## Deletes the environment variable named `key`.
+  builtin
+
+proc fileExists*(filename: string): bool {.tags: [ReadIOEffect].} =
+  ## Checks if the file exists.
+  builtin
+
+proc dirExists*(dir: string): bool {.
+  tags: [ReadIOEffect].} =
+  ## Checks if the directory `dir` exists.
+  builtin
+
+proc selfExe*(): string {.deprecated: "Deprecated since v1.7; Use getCurrentCompilerExe".} =
+  ## Returns the currently running nim or nimble executable.
+  builtin
+
+proc toExe*(filename: string): string =
+  ## On Windows adds ".exe" to `filename`, else returns `filename` unmodified.
+  (when defined(windows): filename & ".exe" else: filename)
+
+proc toDll*(filename: string): string =
+  ## On Windows adds ".dll" to `filename`, on Posix produces "lib$filename.so".
+  (when defined(windows): filename & ".dll" else: "lib" & filename & ".so")
+
+proc strip(s: string): string =
+  var i = 0
+  while s[i] in {' ', '\c', '\n'}: inc i
+  result = s.substr(i)
+  if result[0] == '"' and result[^1] == '"':
+    result = result[1..^2]
+
+template `--`*(key, val: untyped) =
+  ## A shortcut for `switch <#switch,string,string>`_
+  ## Example:
+  ##   ```nim
+  ##   --path:somePath # same as switch("path", "somePath")
+  ##   --path:"someOtherPath" # same as switch("path", "someOtherPath")
+  ##   --hint:"[Conf]:off" # same as switch("hint", "[Conf]:off")
+  ##   ```
+  switch(strip(astToStr(key)), strip(astToStr(val)))
+
+template `--`*(key: untyped) =
+  ## A shortcut for `switch <#switch,string,string>`_
+  ## Example:
+  ##   ```nim
+  ##   --listCmd # same as switch("listCmd")
+  ##   ```
+  switch(strip(astToStr(key)))
+
+type
+  ScriptMode* {.pure.} = enum ## Controls the behaviour of the script.
+    Silent,                   ## Be silent.
+    Verbose,                  ## Be verbose.
+    Whatif                    ## Do not run commands, instead just echo what
+                              ## would have been done.
+
+var
+  mode*: ScriptMode ## Set this to influence how mkDir, rmDir, rmFile etc.
+                    ## behave
+
+template checkError(exc: untyped): untyped =
+  let err = getError()
+  if err.len > 0: raise newException(exc, err)
+
+template checkOsError =
+  checkError(OSError)
+
+template log(msg: string, body: untyped) =
+  if mode in {ScriptMode.Verbose, ScriptMode.Whatif}:
+    echo "[NimScript] ", msg
+  if mode != ScriptMode.Whatif:
+    body
+
+proc listDirs*(dir: string): seq[string] =
+  ## Lists all the subdirectories (non-recursively) in the directory `dir`.
+  result = listDirsImpl(dir)
+  checkOsError()
+
+proc listFiles*(dir: string): seq[string] =
+  ## Lists all the files (non-recursively) in the directory `dir`.
+  result = listFilesImpl(dir)
+  checkOsError()
+
+proc rmDir*(dir: string, checkDir = false) {.raises: [OSError].} =
+  ## Removes the directory `dir`.
+  log "rmDir: " & dir:
+    removeDir(dir, checkDir = checkDir)
+    checkOsError()
+
+proc rmFile*(file: string) {.raises: [OSError].} =
+  ## Removes the `file`.
+  log "rmFile: " & file:
+    removeFile file
+    checkOsError()
+
+proc mkDir*(dir: string) {.raises: [OSError].} =
+  ## Creates the directory `dir` including all necessary subdirectories. If
+  ## the directory already exists, no error is raised.
+  log "mkDir: " & dir:
+    createDir dir
+    checkOsError()
+
+proc mvFile*(`from`, to: string) {.raises: [OSError].} =
+  ## Moves the file `from` to `to`.
+  log "mvFile: " & `from` & ", " & to:
+    moveFile `from`, to
+    checkOsError()
+
+proc mvDir*(`from`, to: string) {.raises: [OSError].} =
+  ## Moves the dir `from` to `to`.
+  log "mvDir: " & `from` & ", " & to:
+    moveDir `from`, to
+    checkOsError()
+
+proc cpFile*(`from`, to: string) {.raises: [OSError].} =
+  ## Copies the file `from` to `to`.
+  log "cpFile: " & `from` & ", " & to:
+    copyFile `from`, to
+    checkOsError()
+
+proc cpDir*(`from`, to: string) {.raises: [OSError].} =
+  ## Copies the dir `from` to `to`.
+  log "cpDir: " & `from` & ", " & to:
+    copyDir `from`, to
+    checkOsError()
+
+proc exec*(command: string) {.
+  raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].} =
+  ## Executes an external process. If the external process terminates with
+  ## a non-zero exit code, an OSError exception is raised. The command is
+  ## executed relative to the current source path.
+  ##
+  ## .. note:: If you need a version of `exec` that returns the exit code
+  ##   and text output of the command, you can use `system.gorgeEx
+  ##   <system.html#gorgeEx,string,string,string>`_.
+  log "exec: " & command:
+    if rawExec(command) != 0:
+      raise newException(OSError, "FAILED: " & command)
+    checkOsError()
+
+proc exec*(command: string, input: string, cache = "") {.
+  raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].} =
+  ## Executes an external process. If the external process terminates with
+  ## a non-zero exit code, an OSError exception is raised.
+  ##
+  ## .. warning:: This version of `exec` is executed relative to the nimscript
+  ##   module path, which affects how the command resolves relative paths. Thus
+  ##   it is generally better to use `gorgeEx` directly when you need more
+  ##   control over the execution environment or when working with commands
+  ##   that deal with relative paths.
+  log "exec: " & command:
+    let (output, exitCode) = gorgeEx(command, input, cache)
+    echo output
+    if exitCode != 0:
+      raise newException(OSError, "FAILED: " & command)
+
+proc selfExec*(command: string) {.
+  raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].} =
+  ## Executes an external command with the current nim/nimble executable.
+  ## `Command` must not contain the "nim " part.
+  let c = selfExe() & " " & command
+  log "exec: " & c:
+    if rawExec(c) != 0:
+      raise newException(OSError, "FAILED: " & c)
+    checkOsError()
+
+proc put*(key, value: string) =
+  ## Sets a configuration 'key' like 'gcc.options.always' to its value.
+  builtin
+
+proc get*(key: string): string =
+  ## Retrieves a configuration 'key' like 'gcc.options.always'.
+  builtin
+
+proc exists*(key: string): bool =
+  ## Checks for the existence of a configuration 'key'
+  ## like 'gcc.options.always'.
+  builtin
+
+proc nimcacheDir*(): string =
+  ## Retrieves the location of 'nimcache'.
+  builtin
+
+proc projectName*(): string =
+  ## Retrieves the name of the current project
+  builtin
+
+proc projectDir*(): string =
+  ## Retrieves the absolute directory of the current project
+  builtin
+
+proc projectPath*(): string =
+  ## Retrieves the absolute path of the current project
+  builtin
+
+proc thisDir*(): string =
+  ## Retrieves the directory of the current `nims` script file. Its path is
+  ## obtained via `currentSourcePath` (although, currently,
+  ## `currentSourcePath` resolves symlinks, unlike `thisDir`).
+  builtin
+
+proc cd*(dir: string) {.raises: [OSError].} =
+  ## Changes the current directory.
+  ##
+  ## The change is permanent for the rest of the execution, since this is just
+  ## a shortcut for `os.setCurrentDir() <os.html#setCurrentDir,string>`_ . Use
+  ## the `withDir() <#withDir.t,string,untyped>`_ template if you want to
+  ## perform a temporary change only.
+  setCurrentDir(dir)
+  checkOsError()
+
+proc findExe*(bin: string): string =
+  ## Searches for bin in the current working directory and then in directories
+  ## listed in the PATH environment variable. Returns "" if the exe cannot be
+  ## found.
+  builtin
+
+template withDir*(dir: string; body: untyped): untyped =
+  ## Changes the current directory temporarily.
+  ##
+  ## If you need a permanent change, use the `cd() <#cd,string>`_ proc.
+  ## Usage example:
+  ##   ```nim
+  ##   # inside /some/path/
+  ##   withDir "foo":
+  ##     # move to /some/path/foo/
+  ##   # back in /some/path/
+  ##   ```
+  let curDir = getCurrentDir()
+  try:
+    cd(dir)
+    body
+  finally:
+    cd(curDir)
+
+proc writeTask(name, desc: string) =
+  if desc.len > 0:
+    var spaces = " "
+    for i in 0 ..< 20 - name.len: spaces.add ' '
+    echo name, spaces, desc
+
+proc cppDefine*(define: string) =
+  ## tell Nim that `define` is a C preprocessor `#define` and so always
+  ## needs to be mangled.
+  builtin
+
+proc stdinReadLine(): string {.
+  tags: [ReadIOEffect], raises: [IOError].} =
+  builtin
+
+proc stdinReadAll(): string {.
+  tags: [ReadIOEffect], raises: [IOError].} =
+  builtin
+
+proc readLineFromStdin*(): string {.raises: [IOError].} =
+  ## Reads a line of data from stdin - blocks until \n or EOF which happens when stdin is closed
+  log "readLineFromStdin":
+    result = stdinReadLine()
+    checkError(EOFError)
+
+proc readAllFromStdin*(): string {.raises: [IOError].} =
+  ## Reads all data from stdin - blocks until EOF which happens when stdin is closed
+  log "readAllFromStdin":
+    result = stdinReadAll()
+    checkError(EOFError)
+
+when not defined(nimble):
+  template `==?`(a, b: string): bool = cmpIgnoreStyle(a, b) == 0
+  template task*(name: untyped; description: string; body: untyped): untyped =
+    ## Defines a task. Hidden tasks are supported via an empty description.
+    ##
+    ## Example:
+    ##   ```nim
+    ##   task build, "default build is via the C backend":
+    ##     setCommand "c"
+    ##   ```
+    ##
+    ## For a task named `foo`, this template generates a `proc` named
+    ## `fooTask`.  This is useful if you need to call one task in
+    ## another in your Nimscript.
+    ##
+    ## Example:
+    ##
+    ##   ```nim
+    ##   task foo, "foo":        # > nim foo
+    ##     echo "Running foo"    # Running foo
+    ##
+    ##   task bar, "bar":        # > nim bar
+    ##     echo "Running bar"    # Running bar
+    ##     fooTask()             # Running foo
+    ##   ```
+    proc `name Task`*() =
+      setCommand "nop"
+      body
+
+    let cmd = getCommand()
+    if cmd.len == 0 or cmd ==? "help":
+      setCommand "help"
+      writeTask(astToStr(name), description)
+    elif cmd ==? astToStr(name):
+      `name Task`()
+
+  # nimble has its own implementation for these things.
+  var
+    packageName* = ""    ## Nimble support: Set this to the package name. It
+                         ## is usually not required to do that, nims' filename is
+                         ## the default.
+    version*: string     ## Nimble support: The package's version.
+    author*: string      ## Nimble support: The package's author.
+    description*: string ## Nimble support: The package's description.
+    license*: string     ## Nimble support: The package's license.
+    srcDir*: string      ## Nimble support: The package's source directory.
+    binDir*: string      ## Nimble support: The package's binary directory.
+    backend*: string     ## Nimble support: The package's backend.
+
+    skipDirs*, skipFiles*, skipExt*, installDirs*, installFiles*,
+      installExt*, bin*: seq[string] = @[] ## Nimble metadata.
+    requiresData*: seq[string] = @[] ## Exposes the list of requirements for read
+                                     ## and write accesses.
+
+  proc requires*(deps: varargs[string]) =
+    ## Nimble support: Call this to set the list of requirements of your Nimble
+    ## package.
+    for d in deps: requiresData.add(d)
+
+{.pop.}
diff --git a/lib/system/orc.nim b/lib/system/orc.nim
new file mode 100644
index 000000000..c02a24989
--- /dev/null
+++ b/lib/system/orc.nim
@@ -0,0 +1,543 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Cycle collector based on
+# https://www.cs.purdue.edu/homes/hosking/690M/Bacon01Concurrent.pdf
+# And ideas from Lins' in 2008 by the notion of "critical links", see
+# "Cyclic reference counting" by Rafael Dueire Lins
+# R.D. Lins / Information Processing Letters 109 (2008) 71–78
+#
+
+include cellseqs_v2
+
+const
+  colBlack = 0b000
+  colGray = 0b001
+  colWhite = 0b010
+  maybeCycle = 0b100 # possibly part of a cycle; this has to be a "sticky" bit
+  jumpStackFlag = 0b1000
+  colorMask = 0b011
+
+  logOrc = defined(nimArcIds)
+
+type
+  TraceProc = proc (p, env: pointer) {.nimcall, benign.}
+  DisposeProc = proc (p: pointer) {.nimcall, benign.}
+
+template color(c): untyped = c.rc and colorMask
+template setColor(c, col) =
+  when col == colBlack:
+    c.rc = c.rc and not colorMask
+  else:
+    c.rc = c.rc and not colorMask or col
+
+const
+  optimizedOrc = false # not defined(nimOldOrc)
+# XXX Still incorrect, see tests/arc/tdestroy_in_loopcond
+
+proc nimIncRefCyclic(p: pointer; cyclic: bool) {.compilerRtl, inl.} =
+  let h = head(p)
+  inc h.rc, rcIncrement
+  when optimizedOrc:
+    if cyclic:
+      h.rc = h.rc or maybeCycle
+
+proc nimMarkCyclic(p: pointer) {.compilerRtl, inl.} =
+  when optimizedOrc:
+    if p != nil:
+      let h = head(p)
+      h.rc = h.rc or maybeCycle
+
+proc unsureAsgnRef(dest: ptr pointer, src: pointer) {.inline.} =
+  # This is only used by the old RTTI mechanism and we know
+  # that 'dest[]' is nil and needs no destruction. Which is really handy
+  # as we cannot destroy the object reliably if it's an object of unknown
+  # compile-time type.
+  dest[] = src
+  if src != nil: nimIncRefCyclic(src, true)
+
+const
+  useJumpStack = false # for thavlak the jump stack doesn't improve the performance at all
+
+type
+  GcEnv = object
+    traceStack: CellSeq[ptr pointer]
+    when useJumpStack:
+      jumpStack: CellSeq[ptr pointer]   # Lins' jump stack in order to speed up traversals
+    toFree: CellSeq[Cell]
+    freed, touched, edges, rcSum: int
+    keepThreshold: bool
+
+proc trace(s: Cell; desc: PNimTypeV2; j: var GcEnv) {.inline.} =
+  if desc.traceImpl != nil:
+    var p = s +! sizeof(RefHeader)
+    cast[TraceProc](desc.traceImpl)(p, addr(j))
+
+include threadids
+
+when logOrc or orcLeakDetector:
+  proc writeCell(msg: cstring; s: Cell; desc: PNimTypeV2) =
+    when orcLeakDetector:
+      cfprintf(cstderr, "%s %s file: %s:%ld; color: %ld; thread: %ld\n",
+        msg, desc.name, s.filename, s.line, s.color, getThreadId())
+    else:
+      cfprintf(cstderr, "%s %s %ld root index: %ld; RC: %ld; color: %ld; thread: %ld\n",
+        msg, desc.name, s.refId, s.rootIdx, s.rc shr rcShift, s.color, getThreadId())
+
+proc free(s: Cell; desc: PNimTypeV2) {.inline.} =
+  when traceCollector:
+    cprintf("[From ] %p rc %ld color %ld\n", s, s.rc shr rcShift, s.color)
+  let p = s +! sizeof(RefHeader)
+
+  when logOrc: writeCell("free", s, desc)
+
+  if desc.destructor != nil:
+    cast[DestructorProc](desc.destructor)(p)
+
+  when false:
+    cstderr.rawWrite desc.name
+    cstderr.rawWrite " "
+    if desc.destructor == nil:
+      cstderr.rawWrite "lacks dispose"
+      if desc.traceImpl != nil:
+        cstderr.rawWrite ", but has trace\n"
+      else:
+        cstderr.rawWrite ", and lacks trace\n"
+    else:
+      cstderr.rawWrite "has dispose!\n"
+
+  nimRawDispose(p, desc.align)
+
+template orcAssert(cond, msg) =
+  when logOrc:
+    if not cond:
+      cfprintf(cstderr, "[Bug!] %s\n", msg)
+      rawQuit 1
+
+when logOrc:
+  proc strstr(s, sub: cstring): cstring {.header: "<string.h>", importc.}
+
+proc nimTraceRef(q: pointer; desc: PNimTypeV2; env: pointer) {.compilerRtl, inl.} =
+  let p = cast[ptr pointer](q)
+  if p[] != nil:
+
+    orcAssert strstr(desc.name, "TType") == nil, "following a TType but it's acyclic!"
+
+    var j = cast[ptr GcEnv](env)
+    j.traceStack.add(p, desc)
+
+proc nimTraceRefDyn(q: pointer; env: pointer) {.compilerRtl, inl.} =
+  let p = cast[ptr pointer](q)
+  if p[] != nil:
+    var j = cast[ptr GcEnv](env)
+    j.traceStack.add(p, cast[ptr PNimTypeV2](p[])[])
+
+var
+  roots {.threadvar.}: CellSeq[Cell]
+
+proc unregisterCycle(s: Cell) =
+  # swap with the last element. O(1)
+  let idx = s.rootIdx-1
+  when false:
+    if idx >= roots.len or idx < 0:
+      cprintf("[Bug!] %ld %ld\n", idx, roots.len)
+      rawQuit 1
+  roots.d[idx] = roots.d[roots.len-1]
+  roots.d[idx][0].rootIdx = idx+1
+  dec roots.len
+  s.rootIdx = 0
+
+proc scanBlack(s: Cell; desc: PNimTypeV2; j: var GcEnv) =
+  #[
+  proc scanBlack(s: Cell) =
+    setColor(s, colBlack)
+    for t in sons(s):
+      t.rc = t.rc + rcIncrement
+      if t.color != colBlack:
+        scanBlack(t)
+  ]#
+  s.setColor colBlack
+  let until = j.traceStack.len
+  trace(s, desc, j)
+  when logOrc: writeCell("root still alive", s, desc)
+  while j.traceStack.len > until:
+    let (entry, desc) = j.traceStack.pop()
+    let t = head entry[]
+    inc t.rc, rcIncrement
+    if t.color != colBlack:
+      t.setColor colBlack
+      trace(t, desc, j)
+      when logOrc: writeCell("child still alive", t, desc)
+
+proc markGray(s: Cell; desc: PNimTypeV2; j: var GcEnv) =
+  #[
+  proc markGray(s: Cell) =
+    if s.color != colGray:
+      setColor(s, colGray)
+      for t in sons(s):
+        t.rc = t.rc - rcIncrement
+        if t.color != colGray:
+          markGray(t)
+  ]#
+  if s.color != colGray:
+    s.setColor colGray
+    inc j.touched
+    # keep in mind that refcounts are zero based so add 1 here:
+    inc j.rcSum, (s.rc shr rcShift) + 1
+    orcAssert(j.traceStack.len == 0, "markGray: trace stack not empty")
+    trace(s, desc, j)
+    while j.traceStack.len > 0:
+      let (entry, desc) = j.traceStack.pop()
+      let t = head entry[]
+      dec t.rc, rcIncrement
+      inc j.edges
+      when useJumpStack:
+        if (t.rc shr rcShift) >= 0 and (t.rc and jumpStackFlag) == 0:
+          t.rc = t.rc or jumpStackFlag
+          when traceCollector:
+            cprintf("[Now in jumpstack] %p %ld color %ld in jumpstack %ld\n", t, t.rc shr rcShift, t.color, t.rc and jumpStackFlag)
+          j.jumpStack.add(entry, desc)
+      if t.color != colGray:
+        t.setColor colGray
+        inc j.touched
+        # we already decremented its refcount so account for that:
+        inc j.rcSum, (t.rc shr rcShift) + 2
+        trace(t, desc, j)
+
+proc scan(s: Cell; desc: PNimTypeV2; j: var GcEnv) =
+  #[
+  proc scan(s: Cell) =
+    if s.color == colGray:
+      if s.rc > 0:
+        scanBlack(s)
+      else:
+        s.setColor(colWhite)
+        for t in sons(s): scan(t)
+  ]#
+  if s.color == colGray:
+    if (s.rc shr rcShift) >= 0:
+      scanBlack(s, desc, j)
+      # XXX this should be done according to Lins' paper but currently breaks
+      #when useJumpStack:
+      #  s.setColor colPurple
+    else:
+      when useJumpStack:
+        # first we have to repair all the nodes we have seen
+        # that are still alive; we also need to mark what they
+        # refer to as alive:
+        while j.jumpStack.len > 0:
+          let (entry, desc) = j.jumpStack.pop
+          let t = head entry[]
+          # not in jump stack anymore!
+          t.rc = t.rc and not jumpStackFlag
+          if t.color == colGray and (t.rc shr rcShift) >= 0:
+            scanBlack(t, desc, j)
+            # XXX this should be done according to Lins' paper but currently breaks
+            #t.setColor colPurple
+            when traceCollector:
+              cprintf("[jump stack] %p %ld\n", t, t.rc shr rcShift)
+
+      orcAssert(j.traceStack.len == 0, "scan: trace stack not empty")
+      s.setColor(colWhite)
+      trace(s, desc, j)
+      while j.traceStack.len > 0:
+        let (entry, desc) = j.traceStack.pop()
+        let t = head entry[]
+        if t.color == colGray:
+          if (t.rc shr rcShift) >= 0:
+            scanBlack(t, desc, j)
+          else:
+            when useJumpStack:
+              # first we have to repair all the nodes we have seen
+              # that are still alive; we also need to mark what they
+              # refer to as alive:
+              while j.jumpStack.len > 0:
+                let (entry, desc) = j.jumpStack.pop
+                let t = head entry[]
+                # not in jump stack anymore!
+                t.rc = t.rc and not jumpStackFlag
+                if t.color == colGray and (t.rc shr rcShift) >= 0:
+                  scanBlack(t, desc, j)
+                  # XXX this should be done according to Lins' paper but currently breaks
+                  #t.setColor colPurple
+                  when traceCollector:
+                    cprintf("[jump stack] %p %ld\n", t, t.rc shr rcShift)
+
+            t.setColor(colWhite)
+            trace(t, desc, j)
+
+when false:
+  proc writeCell(msg: cstring; s: Cell) =
+    cfprintf(cstderr, "%s %p root index: %ld; RC: %ld; color: %ld\n",
+      msg, s, s.rootIdx, s.rc shr rcShift, s.color)
+
+proc collectColor(s: Cell; desc: PNimTypeV2; col: int; j: var GcEnv) =
+  #[
+    was: 'collectWhite'.
+
+  proc collectWhite(s: Cell) =
+    if s.color == colWhite and not buffered(s):
+      s.setColor(colBlack)
+      for t in sons(s):
+        collectWhite(t)
+      free(s) # watch out, a bug here!
+  ]#
+  if s.color == col and s.rootIdx == 0:
+    orcAssert(j.traceStack.len == 0, "collectWhite: trace stack not empty")
+
+    s.setColor(colBlack)
+    j.toFree.add(s, desc)
+    trace(s, desc, j)
+    while j.traceStack.len > 0:
+      let (entry, desc) = j.traceStack.pop()
+      let t = head entry[]
+      entry[] = nil # ensure that the destructor does touch moribund objects!
+      if t.color == col and t.rootIdx == 0:
+        j.toFree.add(t, desc)
+        t.setColor(colBlack)
+        trace(t, desc, j)
+
+const
+  defaultThreshold = when defined(nimFixedOrc): 10_000 else: 128
+
+when defined(nimStressOrc):
+  const rootsThreshold = 10 # broken with -d:nimStressOrc: 10 and for havlak iterations 1..8
+else:
+  var rootsThreshold {.threadvar.}: int
+
+proc collectCyclesBacon(j: var GcEnv; lowMark: int) =
+  # pretty direct translation from
+  # https://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon01Concurrent.pdf
+  # Fig. 2. Synchronous Cycle Collection
+  #[
+    for s in roots:
+      markGray(s)
+    for s in roots:
+      scan(s)
+    for s in roots:
+      remove s from roots
+      s.buffered = false
+      collectWhite(s)
+  ]#
+  let last = roots.len - 1
+  when logOrc:
+    for i in countdown(last, lowMark):
+      writeCell("root", roots.d[i][0], roots.d[i][1])
+
+  for i in countdown(last, lowMark):
+    markGray(roots.d[i][0], roots.d[i][1], j)
+
+  var colToCollect = colWhite
+  if j.rcSum == j.edges:
+    # short-cut: we know everything is garbage:
+    colToCollect = colGray
+    # remember the fact that we got so lucky:
+    j.keepThreshold = true
+  else:
+    for i in countdown(last, lowMark):
+      scan(roots.d[i][0], roots.d[i][1], j)
+
+  init j.toFree
+  for i in 0 ..< roots.len:
+    let s = roots.d[i][0]
+    s.rootIdx = 0
+    collectColor(s, roots.d[i][1], colToCollect, j)
+
+  # Bug #22927: `free` calls destructors which can append to `roots`.
+  # We protect against this here by setting `roots.len` to 0 and also
+  # setting the threshold so high that no cycle collection can be triggered
+  # until we are out of this critical section:
+  when not defined(nimStressOrc):
+    let oldThreshold = rootsThreshold
+    rootsThreshold = high(int)
+  roots.len = 0
+
+  for i in 0 ..< j.toFree.len:
+    when orcLeakDetector:
+      writeCell("CYCLIC OBJECT FREED", j.toFree.d[i][0], j.toFree.d[i][1])
+    free(j.toFree.d[i][0], j.toFree.d[i][1])
+
+  when not defined(nimStressOrc):
+    rootsThreshold = oldThreshold
+
+  inc j.freed, j.toFree.len
+  deinit j.toFree
+
+when defined(nimOrcStats):
+  var freedCyclicObjects {.threadvar.}: int
+
+proc partialCollect(lowMark: int) =
+  when false:
+    if roots.len < 10 + lowMark: return
+  when logOrc:
+    cfprintf(cstderr, "[partialCollect] begin\n")
+  var j: GcEnv
+  init j.traceStack
+  collectCyclesBacon(j, lowMark)
+  when logOrc:
+    cfprintf(cstderr, "[partialCollect] end; freed %ld touched: %ld work: %ld\n", j.freed, j.touched,
+      roots.len - lowMark)
+  roots.len = lowMark
+  deinit j.traceStack
+  when defined(nimOrcStats):
+    inc freedCyclicObjects, j.freed
+
+proc collectCycles() =
+  ## Collect cycles.
+  when logOrc:
+    cfprintf(cstderr, "[collectCycles] begin\n")
+
+  var j: GcEnv
+  init j.traceStack
+  when useJumpStack:
+    init j.jumpStack
+    collectCyclesBacon(j, 0)
+    while j.jumpStack.len > 0:
+      let (t, desc) = j.jumpStack.pop
+      # not in jump stack anymore!
+      t.rc = t.rc and not jumpStackFlag
+    deinit j.jumpStack
+  else:
+    collectCyclesBacon(j, 0)
+
+  deinit j.traceStack
+  if roots.len == 0:
+    deinit roots
+
+  when not defined(nimStressOrc):
+    # compute the threshold based on the previous history
+    # of the cycle collector's effectiveness:
+    # we're effective when we collected 50% or more of the nodes
+    # we touched. If we're effective, we can reset the threshold:
+    if j.keepThreshold:
+      discard
+    elif j.freed * 2 >= j.touched:
+      when not defined(nimFixedOrc):
+        rootsThreshold = max(rootsThreshold div 3 * 2, 16)
+      else:
+        rootsThreshold = 0
+      #cfprintf(cstderr, "[collectCycles] freed %ld, touched %ld new threshold %ld\n", j.freed, j.touched, rootsThreshold)
+    elif rootsThreshold < high(int) div 4:
+      rootsThreshold = (if rootsThreshold <= 0: defaultThreshold else: rootsThreshold) * 3 div 2
+  when logOrc:
+    cfprintf(cstderr, "[collectCycles] end; freed %ld new threshold %ld touched: %ld mem: %ld rcSum: %ld edges: %ld\n", j.freed, rootsThreshold, j.touched,
+      getOccupiedMem(), j.rcSum, j.edges)
+  when defined(nimOrcStats):
+    inc freedCyclicObjects, j.freed
+
+when defined(nimOrcStats):
+  type
+    OrcStats* = object ## Statistics of the cycle collector subsystem.
+      freedCyclicObjects*: int ## Number of freed cyclic objects.
+  proc GC_orcStats*(): OrcStats =
+    ## Returns the statistics of the cycle collector subsystem.
+    result = OrcStats(freedCyclicObjects: freedCyclicObjects)
+
+proc registerCycle(s: Cell; desc: PNimTypeV2) =
+  s.rootIdx = roots.len+1
+  if roots.d == nil: init(roots)
+  add(roots, s, desc)
+
+  if roots.len - defaultThreshold >= rootsThreshold:
+    collectCycles()
+  when logOrc:
+    writeCell("[added root]", s, desc)
+
+  orcAssert strstr(desc.name, "TType") == nil, "added a TType as a root!"
+
+proc GC_runOrc* =
+  ## Forces a cycle collection pass.
+  collectCycles()
+  orcAssert roots.len == 0, "roots not empty!"
+
+proc GC_enableOrc*() =
+  ## Enables the cycle collector subsystem of `--mm:orc`. This is a `--mm:orc`
+  ## specific API. Check with `when defined(gcOrc)` for its existence.
+  when not defined(nimStressOrc):
+    rootsThreshold = 0
+
+proc GC_disableOrc*() =
+  ## Disables the cycle collector subsystem of `--mm:orc`. This is a `--mm:orc`
+  ## specific API. Check with `when defined(gcOrc)` for its existence.
+  when not defined(nimStressOrc):
+    rootsThreshold = high(int)
+
+proc GC_prepareOrc*(): int {.inline.} = roots.len
+
+proc GC_partialCollect*(limit: int) =
+  partialCollect(limit)
+
+proc GC_fullCollect* =
+  ## Forces a full garbage collection pass. With `--mm:orc` triggers the cycle
+  ## collector. This is an alias for `GC_runOrc`.
+  collectCycles()
+
+proc GC_enableMarkAndSweep*() =
+  ## For `--mm:orc` an alias for `GC_enableOrc`.
+  GC_enableOrc()
+
+proc GC_disableMarkAndSweep*() =
+  ## For `--mm:orc` an alias for `GC_disableOrc`.
+  GC_disableOrc()
+
+const
+  acyclicFlag = 1 # see also cggtypes.nim, proc genTypeInfoV2Impl
+
+when optimizedOrc:
+  template markedAsCyclic(s: Cell; desc: PNimTypeV2): bool =
+    (desc.flags and acyclicFlag) == 0 and (s.rc and maybeCycle) != 0
+else:
+  template markedAsCyclic(s: Cell; desc: PNimTypeV2): bool =
+    (desc.flags and acyclicFlag) == 0
+
+proc rememberCycle(isDestroyAction: bool; s: Cell; desc: PNimTypeV2) {.noinline.} =
+  if isDestroyAction:
+    if s.rootIdx > 0:
+      unregisterCycle(s)
+  else:
+    # do not call 'rememberCycle' again unless this cell
+    # got an 'incRef' event:
+    if s.rootIdx == 0 and markedAsCyclic(s, desc):
+      s.setColor colBlack
+      registerCycle(s, desc)
+
+proc nimDecRefIsLastCyclicDyn(p: pointer): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+    if (cell.rc and not rcMask) == 0:
+      result = true
+      #cprintf("[DESTROY] %p\n", p)
+    else:
+      dec cell.rc, rcIncrement
+    #if cell.color == colPurple:
+    rememberCycle(result, cell, cast[ptr PNimTypeV2](p)[])
+
+proc nimDecRefIsLastDyn(p: pointer): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+    if (cell.rc and not rcMask) == 0:
+      result = true
+      #cprintf("[DESTROY] %p\n", p)
+    else:
+      dec cell.rc, rcIncrement
+    #if cell.color == colPurple:
+    if result:
+      if cell.rootIdx > 0:
+        unregisterCycle(cell)
+
+proc nimDecRefIsLastCyclicStatic(p: pointer; desc: PNimTypeV2): bool {.compilerRtl, inl.} =
+  if p != nil:
+    var cell = head(p)
+    if (cell.rc and not rcMask) == 0:
+      result = true
+      #cprintf("[DESTROY] %p %s\n", p, desc.name)
+    else:
+      dec cell.rc, rcIncrement
+    #if cell.color == colPurple:
+    rememberCycle(result, cell, desc)
diff --git a/lib/system/osalloc.nim b/lib/system/osalloc.nim
new file mode 100644
index 000000000..5509d0070
--- /dev/null
+++ b/lib/system/osalloc.nim
@@ -0,0 +1,218 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+proc roundup(x, v: int): int {.inline.} =
+  result = (x + (v-1)) and not (v-1)
+  sysAssert(result >= x, "roundup: result < x")
+  #return ((-x) and (v-1)) +% x
+
+sysAssert(roundup(14, PageSize) == PageSize, "invalid PageSize")
+sysAssert(roundup(15, 8) == 16, "roundup broken")
+sysAssert(roundup(65, 8) == 72, "roundup broken 2")
+
+# ------------ platform specific chunk allocation code -----------
+
+# some platforms have really weird unmap behaviour:
+# unmap(blockStart, PageSize)
+# really frees the whole block. Happens for Linux/PowerPC for example. Amd64
+# and x86 are safe though; Windows is special because MEM_RELEASE can only be
+# used with a size of 0. We also allow unmapping to be turned off with
+# -d:nimAllocNoUnmap:
+const doNotUnmap = not (defined(amd64) or defined(i386)) or
+                   defined(windows) or defined(nimAllocNoUnmap)
+
+
+when defined(nimAllocPagesViaMalloc):
+  when not defined(gcArc) and not defined(gcOrc) and not defined(gcAtomicArc):
+    {.error: "-d:nimAllocPagesViaMalloc is only supported with --mm:arc or --mm:atomicArc or --mm:orc".}
+
+  proc osTryAllocPages(size: int): pointer {.inline.} =
+    let base = c_malloc(csize_t size + PageSize - 1 + sizeof(uint32))
+    if base == nil: raiseOutOfMem()
+    # memory layout: padding + offset (4 bytes) + user_data
+    # in order to deallocate: read offset at user_data - 4 bytes,
+    # then deallocate user_data - offset
+    let offset = PageSize - (cast[int](base) and (PageSize - 1))
+    cast[ptr uint32](base +! (offset - sizeof(uint32)))[] = uint32(offset)
+    result = base +! offset
+
+  proc osAllocPages(size: int): pointer {.inline.} =
+    result = osTryAllocPages(size)
+    if result == nil: raiseOutOfMem()
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    # read offset at p - 4 bytes, then deallocate (p - offset) pointer
+    let offset = cast[ptr uint32](p -! sizeof(uint32))[]
+    c_free(p -! offset)
+
+elif defined(emscripten) and not defined(StandaloneHeapSize):
+  const
+    PROT_READ  = 1             # page can be read
+    PROT_WRITE = 2             # page can be written
+    MAP_PRIVATE = 2'i32        # Changes are private
+
+  var MAP_ANONYMOUS {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
+  type
+    PEmscriptenMMapBlock = ptr EmscriptenMMapBlock
+    EmscriptenMMapBlock {.pure, inheritable.} = object
+      realSize: int        # size of previous chunk; for coalescing
+      realPointer: pointer     # if < PageSize it is a small chunk
+
+  proc mmap(adr: pointer, len: int, prot, flags, fildes: cint,
+            off: int): pointer {.header: "<sys/mman.h>".}
+
+  proc munmap(adr: pointer, len: int) {.header: "<sys/mman.h>".}
+
+  proc osAllocPages(block_size: int): pointer {.inline.} =
+    let realSize = block_size + sizeof(EmscriptenMMapBlock) + PageSize + 1
+    result = mmap(nil, realSize, PROT_READ or PROT_WRITE,
+                             MAP_PRIVATE or MAP_ANONYMOUS, -1, 0)
+    if result == nil or result == cast[pointer](-1):
+      raiseOutOfMem()
+
+    let realPointer = result
+    let pos = cast[int](result)
+
+    # Convert pointer to PageSize correct one.
+    var new_pos = cast[int](pos) +% (PageSize - (pos %% PageSize))
+    if (new_pos-pos) < sizeof(EmscriptenMMapBlock):
+      new_pos = new_pos +% PageSize
+    result = cast[pointer](new_pos)
+
+    var mmapDescrPos = cast[int](result) -% sizeof(EmscriptenMMapBlock)
+
+    var mmapDescr = cast[EmscriptenMMapBlock](mmapDescrPos)
+    mmapDescr.realSize = realSize
+    mmapDescr.realPointer = realPointer
+
+    #c_fprintf(stdout, "[Alloc] size %d %d realSize:%d realPos:%d\n", block_size, cast[int](result), realSize, cast[int](realPointer))
+
+  proc osTryAllocPages(size: int): pointer = osAllocPages(size)
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    var mmapDescrPos = cast[int](p) -% sizeof(EmscriptenMMapBlock)
+    var mmapDescr = cast[EmscriptenMMapBlock](mmapDescrPos)
+    munmap(mmapDescr.realPointer, mmapDescr.realSize)
+
+elif defined(genode) and not defined(StandaloneHeapSize):
+  include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages
+
+elif defined(posix) and not defined(StandaloneHeapSize):
+  const
+    PROT_READ  = 1             # page can be read
+    PROT_WRITE = 2             # page can be written
+
+  when defined(netbsd) or defined(openbsd):
+    # OpenBSD security for setjmp/longjmp coroutines
+    var MAP_STACK {.importc: "MAP_STACK", header: "<sys/mman.h>".}: cint
+  else:
+    const MAP_STACK = 0             # avoid sideeffects
+
+  when defined(macosx) or defined(freebsd):
+    const MAP_ANONYMOUS = 0x1000
+    const MAP_PRIVATE = 0x02        # Changes are private
+  elif defined(solaris):
+    const MAP_ANONYMOUS = 0x100
+    const MAP_PRIVATE = 0x02        # Changes are private
+  elif defined(linux) and defined(amd64):
+    # actually, any architecture using asm-generic, but being conservative here,
+    # some arches like mips and alpha use different values
+    const MAP_ANONYMOUS = 0x20
+    const MAP_PRIVATE = 0x02        # Changes are private
+  elif defined(haiku):
+    const MAP_ANONYMOUS = 0x08
+    const MAP_PRIVATE = 0x02
+  else:  # posix including netbsd or openbsd
+    var
+      MAP_ANONYMOUS {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint
+      MAP_PRIVATE {.importc: "MAP_PRIVATE", header: "<sys/mman.h>".}: cint
+
+  proc mmap(adr: pointer, len: csize_t, prot, flags, fildes: cint,
+            off: int): pointer {.header: "<sys/mman.h>".}
+
+  proc munmap(adr: pointer, len: csize_t): cint {.header: "<sys/mman.h>".}
+
+  proc osAllocPages(size: int): pointer {.inline.} =
+    result = mmap(nil, cast[csize_t](size), PROT_READ or PROT_WRITE,
+                             MAP_ANONYMOUS or MAP_PRIVATE or MAP_STACK, -1, 0)
+    if result == nil or result == cast[pointer](-1):
+      raiseOutOfMem()
+
+  proc osTryAllocPages(size: int): pointer {.inline.} =
+    result = mmap(nil, cast[csize_t](size), PROT_READ or PROT_WRITE,
+                             MAP_ANONYMOUS or MAP_PRIVATE or MAP_STACK, -1, 0)
+    if result == cast[pointer](-1): result = nil
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    when reallyOsDealloc: discard munmap(p, cast[csize_t](size))
+
+elif defined(windows) and not defined(StandaloneHeapSize):
+  const
+    MEM_RESERVE = 0x2000
+    MEM_COMMIT = 0x1000
+    MEM_TOP_DOWN = 0x100000
+    PAGE_READWRITE = 0x04
+
+    MEM_DECOMMIT = 0x4000
+    MEM_RELEASE = 0x8000
+
+  proc virtualAlloc(lpAddress: pointer, dwSize: int, flAllocationType,
+                    flProtect: int32): pointer {.
+                    header: "<windows.h>", stdcall, importc: "VirtualAlloc".}
+
+  proc virtualFree(lpAddress: pointer, dwSize: int,
+                   dwFreeType: int32): cint {.header: "<windows.h>", stdcall,
+                   importc: "VirtualFree".}
+
+  proc osAllocPages(size: int): pointer {.inline.} =
+    result = virtualAlloc(nil, size, MEM_RESERVE or MEM_COMMIT,
+                          PAGE_READWRITE)
+    if result == nil: raiseOutOfMem()
+
+  proc osTryAllocPages(size: int): pointer {.inline.} =
+    result = virtualAlloc(nil, size, MEM_RESERVE or MEM_COMMIT,
+                          PAGE_READWRITE)
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    # according to Microsoft, 0 is the only correct value for MEM_RELEASE:
+    # This means that the OS has some different view over how big the block is
+    # that we want to free! So, we cannot reliably release the memory back to
+    # Windows :-(. We have to live with MEM_DECOMMIT instead.
+    # Well that used to be the case but MEM_DECOMMIT fragments the address
+    # space heavily, so we now treat Windows as a strange unmap target.
+    when reallyOsDealloc:
+      if virtualFree(p, 0, MEM_RELEASE) == 0:
+        cprintf "virtualFree failing!"
+        rawQuit 1
+    #VirtualFree(p, size, MEM_DECOMMIT)
+
+elif hostOS == "standalone" or defined(StandaloneHeapSize):
+  const StandaloneHeapSize {.intdefine.}: int = 1024 * PageSize
+  var
+    theHeap: array[StandaloneHeapSize div sizeof(float64), float64] # 'float64' for alignment
+    bumpPointer = cast[int](addr theHeap)
+
+  proc osAllocPages(size: int): pointer {.inline.} =
+    if size+bumpPointer < cast[int](addr theHeap) + sizeof(theHeap):
+      result = cast[pointer](bumpPointer)
+      inc bumpPointer, size
+    else:
+      raiseOutOfMem()
+
+  proc osTryAllocPages(size: int): pointer {.inline.} =
+    if size+bumpPointer < cast[int](addr theHeap) + sizeof(theHeap):
+      result = cast[pointer](bumpPointer)
+      inc bumpPointer, size
+
+  proc osDeallocPages(p: pointer, size: int) {.inline.} =
+    if bumpPointer-size == cast[int](p):
+      dec bumpPointer, size
+
+else:
+  {.error: "Port memory manager to your platform".}
diff --git a/lib/system/platforms.nim b/lib/system/platforms.nim
new file mode 100644
index 000000000..0619f3fca
--- /dev/null
+++ b/lib/system/platforms.nim
@@ -0,0 +1,105 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Platform detection for NimScript. This module is included by the system module!
+## Do not import it directly!
+
+# CPU architectures have alias names mapped in tools/niminst/makefile.nimf
+
+type
+  CpuPlatform* {.pure.} = enum ## the CPU this program will run on.
+    none,                      ## unknown CPU
+    i386,                      ## 32 bit x86 compatible CPU
+    m68k,                      ## M68k based processor
+    alpha,                     ## Alpha processor
+    powerpc,                   ## 32 bit PowerPC
+    powerpc64,                 ## 64 bit PowerPC
+    powerpc64el,               ## Little Endian 64 bit PowerPC
+    sparc,                     ## Sparc based processor
+    sparc64,                   ## 64-bit Sparc based processor
+    hppa,                      ## HP PA-RISC
+    ia64,                      ## Intel Itanium
+    amd64,                     ## x86_64 (AMD64); 64 bit x86 compatible CPU
+    mips,                      ## Mips based processor
+    mipsel,                    ## Little Endian Mips based processor
+    mips64,                    ## 64-bit MIPS processor
+    mips64el,                  ## Little Endian 64-bit MIPS processor
+    arm,                       ## ARM based processor
+    arm64,                     ## ARM64 based processor
+    vm,                        ## Some Virtual machine: Nim's VM or JavaScript
+    avr,                       ## AVR based processor
+    msp430,                    ## TI MSP430 microcontroller
+    riscv32,                   ## RISC-V 32-bit processor
+    riscv64,                   ## RISC-V 64-bit processor
+    wasm32,                    ## WASM, 32-bit
+    e2k,                       ## MCST Elbrus 2000
+    loongarch64,               ## LoongArch 64-bit processor
+    s390x                      ## IBM Z
+
+  OsPlatform* {.pure.} = enum ## the OS this program will run on.
+    none, dos, windows, os2, linux, morphos, skyos, solaris,
+    irix, netbsd, freebsd, openbsd, aix, palmos, qnx, amiga,
+    atari, netware, macos, macosx, haiku, android, js, standalone, nintendoswitch
+
+const
+  targetOS* = when defined(windows): OsPlatform.windows
+              elif defined(dos): OsPlatform.dos
+              elif defined(os2): OsPlatform.os2
+              elif defined(linux): OsPlatform.linux
+              elif defined(morphos): OsPlatform.morphos
+              elif defined(skyos): OsPlatform.skyos
+              elif defined(solaris): OsPlatform.solaris
+              elif defined(irix): OsPlatform.irix
+              elif defined(netbsd): OsPlatform.netbsd
+              elif defined(freebsd): OsPlatform.freebsd
+              elif defined(openbsd): OsPlatform.openbsd
+              elif defined(aix): OsPlatform.aix
+              elif defined(palmos): OsPlatform.palmos
+              elif defined(qnx): OsPlatform.qnx
+              elif defined(amiga): OsPlatform.amiga
+              elif defined(atari): OsPlatform.atari
+              elif defined(netware): OsPlatform.netware
+              elif defined(macosx): OsPlatform.macosx
+              elif defined(macos): OsPlatform.macos
+              elif defined(haiku): OsPlatform.haiku
+              elif defined(android): OsPlatform.android
+              elif defined(js): OsPlatform.js
+              elif defined(standalone): OsPlatform.standalone
+              elif defined(nintendoswitch): OsPlatform.nintendoswitch
+              else: OsPlatform.none
+    ## the OS this program will run on.
+
+  targetCPU* = when defined(i386): CpuPlatform.i386
+               elif defined(m68k): CpuPlatform.m68k
+               elif defined(alpha): CpuPlatform.alpha
+               elif defined(powerpc): CpuPlatform.powerpc
+               elif defined(powerpc64): CpuPlatform.powerpc64
+               elif defined(powerpc64el): CpuPlatform.powerpc64el
+               elif defined(sparc): CpuPlatform.sparc
+               elif defined(sparc64): CpuPlatform.sparc64
+               elif defined(hppa): CpuPlatform.hppa
+               elif defined(ia64): CpuPlatform.ia64
+               elif defined(amd64): CpuPlatform.amd64
+               elif defined(mips): CpuPlatform.mips
+               elif defined(mipsel): CpuPlatform.mipsel
+               elif defined(mips64): CpuPlatform.mips64
+               elif defined(mips64el): CpuPlatform.mips64el
+               elif defined(arm): CpuPlatform.arm
+               elif defined(arm64): CpuPlatform.arm64
+               elif defined(vm): CpuPlatform.vm
+               elif defined(avr): CpuPlatform.avr
+               elif defined(msp430): CpuPlatform.msp430
+               elif defined(riscv32): CpuPlatform.riscv32
+               elif defined(riscv64): CpuPlatform.riscv64
+               elif defined(wasm32): CpuPlatform.wasm32
+               elif defined(e2k): CpuPlatform.e2k
+               elif defined(loongarch64): CpuPlatform.loongarch64
+               elif defined(s390x): CpuPlatform.s390x
+               else: CpuPlatform.none
+    ## the CPU this program will run on.
diff --git a/lib/system/profiler.nim b/lib/system/profiler.nim
index b87b30d4a..e7eb6ac82 100755..100644
--- a/lib/system/profiler.nim
+++ b/lib/system/profiler.nim
@@ -1,61 +1,103 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-# This file implements the Nimrod profiler. The profiler needs support by the
-# code generator. 
+# This file implements the Nim profiler. The profiler needs support by the
+# code generator. The idea is to inject the instruction stream
+# with 'nimProfile()' calls. These calls are injected at every loop end
+# (except perhaps loops that have no side-effects). At every Nth call a
+# stack trace is taken. A stack tace is a list of cstrings.
+
+when defined(profiler) and defined(memProfiler):
+  {.error: "profiler and memProfiler cannot be defined at the same time (See Embedded Stack Trace Profiler (ESTP) User Guide) for more details".}
+
+{.push profiler: off.}
+
+const
+  MaxTraceLen = 20 # tracking the last 20 calls is enough
 
 type
-  TProfileData {.compilerproc, final.} = object
-    procname: cstring
-    total: float
+  StackTrace* = object
+    lines*: array[0..MaxTraceLen-1, cstring]
+    files*: array[0..MaxTraceLen-1, cstring]
+  ProfilerHook* = proc (st: StackTrace) {.nimcall.}
+
+proc `[]`*(st: StackTrace, i: int): cstring = st.lines[i]
+
+proc captureStackTrace(f: PFrame, st: var StackTrace) =
+  const
+    firstCalls = 5
+  var
+    it = f
+    i = 0
+    total = 0
+  while it != nil and i <= high(st.lines)-(firstCalls-1):
+    # the (-1) is for the "..." entry
+    st.lines[i] = it.procname
+    st.files[i] = it.filename
+    inc(i)
+    inc(total)
+    it = it.prev
+  var b = it
+  while it != nil:
+    inc(total)
+    it = it.prev
+  for j in 1..total-i-(firstCalls-1):
+    if b != nil: b = b.prev
+  if total != i:
+    st.lines[i] = "..."
+    st.files[i] = "..."
+    inc(i)
+  while b != nil and i <= high(st.lines):
+    st.lines[i] = b.procname
+    st.files[i] = b.filename
+    inc(i)
+    b = b.prev
 
 var
-  profileData {.compilerproc.}: array [0..64*1024-1, TProfileData]
-
-proc sortProfile(a: var array[0..64*1024-1, TProfileData], N: int) = 
-  # we use shellsort here; fast enough and simple
-  var h = 1
-  while true: 
-    h = 3 * h + 1
-    if h > N: break 
-  while true: 
-    h = h div 3
-    for i in countup(h, N - 1): 
-      var v = a[i]
-      var j = i
-      while a[j-h].total <= v.total: 
-        a[j] = a[j-h]
-        j = j-h
-        if j < h: break 
-      a[j] = v
-    if h == 1: break
-
-proc writeProfile() {.noconv.} =
-  const filename = "profile_results"
-  var i = 0
-  var f: TFile
-  var j = 1
-  while open(f, filename & $j & ".txt"):
-    close(f)
-    inc(j)
-  if open(f, filename & $j & ".txt", fmWrite):
-    var N = 0
-    # we have to compute the actual length of the array:
-    while profileData[N].procname != nil: inc(N)
-    sortProfile(profileData, N)
-    writeln(f, "total running time of each proc" &
-               " (interpret these numbers relatively)")
-    while profileData[i].procname != nil:
-      write(f, profileData[i].procname)
-      write(f, ": ")
-      writeln(f, profileData[i].total)
-      inc(i)
-    close(f)
-
-addQuitProc(writeProfile)
+  profilingRequestedHook*: proc (): bool {.nimcall, gcsafe.}
+    ## set this variable to provide a procedure that implements a profiler in
+    ## user space. See the `nimprof` module for a reference implementation.
+
+when defined(memProfiler):
+  type
+    MemProfilerHook* = proc (st: StackTrace, requestedSize: int) {.nimcall, gcsafe.}
+
+  var
+    profilerHook*: MemProfilerHook
+      ## set this variable to provide a procedure that implements a profiler in
+      ## user space. See the `nimprof` module for a reference implementation.
+
+  proc callProfilerHook(hook: MemProfilerHook, requestedSize: int) =
+    var st: StackTrace
+    captureStackTrace(framePtr, st)
+    hook(st, requestedSize)
+
+  proc nimProfile(requestedSize: int) =
+    if not isNil(profilingRequestedHook) and profilingRequestedHook():
+      callProfilerHook(profilerHook, requestedSize)
+else:
+  var
+    profilerHook*: ProfilerHook
+      ## set this variable to provide a procedure that implements a profiler in
+      ## user space. See the `nimprof` module for a reference implementation.
+
+  proc callProfilerHook(hook: ProfilerHook) {.noinline.} =
+    # 'noinline' so that 'nimProfile' does not perform the stack allocation
+    # in the common case.
+    when not defined(nimdoc):
+      var st: StackTrace
+      captureStackTrace(framePtr, st)
+      hook(st)
+
+  proc nimProfile() =
+    ## This is invoked by the compiler in every loop and on every proc entry!
+    if not isNil(profilingRequestedHook) and profilingRequestedHook():
+      callProfilerHook(profilerHook)
+
+{.pop.}
diff --git a/lib/system/rawquits.nim b/lib/system/rawquits.nim
new file mode 100644
index 000000000..f0ead10c6
--- /dev/null
+++ b/lib/system/rawquits.nim
@@ -0,0 +1,27 @@
+import system/ctypes
+
+when defined(nimNoQuit):
+  proc rawQuit(errorcode: int = QuitSuccess) = discard "ignoring quit"
+
+elif defined(genode):
+  import genode/env
+
+  var systemEnv {.exportc: runtimeEnvSym.}: GenodeEnvPtr
+
+  type GenodeEnv = GenodeEnvPtr
+    ## Opaque type representing Genode environment.
+
+  proc rawQuit(env: GenodeEnv; errorcode: int) {.magic: "Exit", noreturn,
+    importcpp: "#->parent().exit(@); Genode::sleep_forever()", header: "<base/sleep.h>".}
+
+  proc rawQuit(errorcode: int = QuitSuccess) {.inline, noreturn.} =
+    systemEnv.rawQuit(errorcode)
+
+
+elif defined(js) and defined(nodejs) and not defined(nimscript):
+  proc rawQuit(errorcode: int = QuitSuccess) {.magic: "Exit",
+    importc: "process.exit", noreturn.}
+
+else:
+  proc rawQuit(errorcode: cint) {.
+    magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.}
\ No newline at end of file
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index e340f1d7c..13118e40b 100755..100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,65 +9,81 @@
 
 # The generic ``repr`` procedure. It is an invaluable debugging tool.
 
-#proc cstrToNimStrDummy(s: cstring): string {.inline.} =
-#  result = cast[string](cstrToNimStr(s))
+when not defined(useNimRtl):
+  proc reprAny(p: pointer, typ: PNimType): string {.compilerRtl, gcsafe.}
 
 proc reprInt(x: int64): string {.compilerproc.} = return $x
 proc reprFloat(x: float): string {.compilerproc.} = return $x
 
 proc reprPointer(x: pointer): string {.compilerproc.} =
-  var buf: array [0..59, char]
-  c_sprintf(buf, "%p", x)
-  return $buf
+  result = newString(60)
+  let n = c_snprintf(cast[cstring](addr result[0]), csize_t(60), "%p", x)
+  setLen(result, n)
 
-proc reprStrAux(result: var string, s: string) =
+proc reprStrAux(result: var string, s: cstring; len: int) =
   if cast[pointer](s) == nil:
     add result, "nil"
     return
-  add result, reprPointer(cast[pointer](s)) & "\""
-  for c in items(s):
+  if len > 0:
+    add result, reprPointer(cast[pointer](s))
+  add result, "\""
+  for i in 0 .. pred(len):
+    let c = s[i]
     case c
     of '"': add result, "\\\""
     of '\\': add result, "\\\\" # BUGFIX: forgotten
     of '\10': add result, "\\10\"\n\"" # " \n " # better readability
-    of '\128' .. '\255', '\0'..'\9', '\11'..'\31':
+    of '\127' .. '\255', '\0'..'\9', '\11'..'\31':
       add result, "\\" & reprInt(ord(c))
-    else: result.add(c)
+    else:
+      result.add(c)
   add result, "\""
 
-proc reprStr(s: string): string {.compilerproc.} =
+proc reprStr(s: string): string {.compilerRtl.} =
   result = ""
-  reprStrAux(result, s)
+  reprStrAux(result, s, s.len)
 
-proc reprBool(x: bool): string {.compilerproc.} =
+proc reprBool(x: bool): string {.compilerRtl.} =
   if x: result = "true"
   else: result = "false"
 
-proc reprChar(x: char): string {.compilerproc.} =
+proc reprChar(x: char): string {.compilerRtl.} =
   result = "\'"
   case x
   of '"': add result, "\\\""
   of '\\': add result, "\\\\"
-  of '\128' .. '\255', '\0'..'\31': add result, "\\" & reprInt(ord(x))
+  of '\127' .. '\255', '\0'..'\31': add result, "\\" & reprInt(ord(x))
   else: add result, x
   add result, "\'"
 
-proc reprEnum(e: int, typ: PNimType): string {.compilerproc.} =
-  if e <% typ.node.len: # BUGFIX
-    result = $typ.node.sons[e].name
+proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
+  ## Return string representation for enumeration values
+  var n = typ.node
+  if ntfEnumHole notin typ.flags:
+    let o = e - n.sons[0].offset
+    if o >= 0 and o <% typ.node.len:
+      return $n.sons[o].name
   else:
-    result = $e & " (invalid data!)"
+    # ugh we need a slow linear search:
+    var s = n.sons
+    for i in 0 .. n.len-1:
+      if s[i].offset == e:
+        return $s[i].name
+
+  result = $e & " (invalid data!)"
+
+include system/repr_impl
 
 type
-  pbyteArray = ptr array[0.. 0xffff, byte]
+  PByteArray = ptr UncheckedArray[byte] # array[0xffff, byte]
 
-proc addSetElem(result: var string, elem: int, typ: PNimType) =
+proc addSetElem(result: var string, elem: int, typ: PNimType) {.benign.} =
   case typ.kind
   of tyEnum: add result, reprEnum(elem, typ)
   of tyBool: add result, reprBool(bool(elem))
   of tyChar: add result, reprChar(chr(elem))
   of tyRange: addSetElem(result, elem, typ.base)
-  of tyInt..tyInt64: add result, reprInt(elem)
+  of tyInt..tyInt64, tyUInt8, tyUInt16: add result, reprInt(elem)
   else: # data corrupt --> inform the user
     add result, " (invalid data!)"
 
@@ -76,174 +92,236 @@ proc reprSetAux(result: var string, p: pointer, typ: PNimType) =
   var elemCounter = 0  # we need this flag for adding the comma at
                        # the right places
   add result, "{"
-  var u: int64
+  var u: uint64
   case typ.size
-  of 1: u = ze64(cast[ptr int8](p)^)
-  of 2: u = ze64(cast[ptr int16](p)^)
-  of 4: u = ze64(cast[ptr int32](p)^)
-  of 8: u = cast[ptr int64](p)^
+  of 1: u = cast[ptr uint8](p)[]
+  of 2: u = cast[ptr uint16](p)[]
+  of 4: u = cast[ptr uint32](p)[]
+  of 8: u = cast[ptr uint64](p)[]
   else:
-    var a = cast[pbyteArray](p)
+    u = uint64(0)
+    var a = cast[PByteArray](p)
     for i in 0 .. typ.size*8-1:
-      if (ze(a[i div 8]) and (1 shl (i mod 8))) != 0:
+      if (uint(a[i shr 3]) and (1'u shl (i and 7))) != 0:
         if elemCounter > 0: add result, ", "
         addSetElem(result, i+typ.node.len, typ.base)
         inc(elemCounter)
   if typ.size <= 8:
     for i in 0..sizeof(int64)*8-1:
-      if (u and (1 shl i)) != 0:
+      if (u and (1'u64 shl uint64(i))) != 0'u64:
         if elemCounter > 0: add result, ", "
         addSetElem(result, i+typ.node.len, typ.base)
         inc(elemCounter)
   add result, "}"
 
-proc reprSet(p: pointer, typ: PNimType): string {.compilerproc.} =
+proc reprSet(p: pointer, typ: PNimType): string {.compilerRtl.} =
   result = ""
   reprSetAux(result, p, typ)
 
 type
-  TReprClosure {.final.} = object # we cannot use a global variable here
+  ReprClosure {.final.} = object # we cannot use a global variable here
                                   # as this wouldn't be thread-safe
-    marked: TCellSet
-    recdepth: int       # do not recurse endless
+    when declared(CellSet):
+      marked: CellSet
+    recdepth: int       # do not recurse endlessly
     indent: int         # indentation
 
-proc initReprClosure(cl: var TReprClosure) =
-  Init(cl.marked)
-  cl.recdepth = -1      # default is to display everything!
-  cl.indent = 0
-
-proc deinitReprClosure(cl: var TReprClosure) =
-  Deinit(cl.marked)
-
-proc reprBreak(result: var string, cl: TReprClosure) =
-  add result, "\n"
-  for i in 0..cl.indent-1: add result, ' '
-
-proc reprAux(result: var string, p: pointer, typ: PNimType,
-             cl: var TReprClosure)
-
-proc reprArray(result: var string, p: pointer, typ: PNimType,
-               cl: var TReprClosure) =
-  add result, "["
-  var bs = typ.base.size
-  for i in 0..typ.size div bs - 1:
-    if i > 0: add result, ", "
-    reprAux(result, cast[pointer](cast[TAddress](p) + i*bs), typ.base, cl)
-  add result, "]"
-
-proc reprSequence(result: var string, p: pointer, typ: PNimType,
-                  cl: var TReprClosure) =
-  if p == nil:
-    add result, "nil"
-    return
-  result.add(reprPointer(p) & "[")
-  var bs = typ.base.size
-  for i in 0..cast[PGenericSeq](p).len-1:
-    if i > 0: add result, ", "
-    reprAux(result, cast[pointer](cast[TAddress](p) + GenericSeqSize + i*bs),
-            typ.Base, cl)
-  add result, "]"
-
-proc reprRecordAux(result: var string, p: pointer, n: ptr TNimNode,
-                   cl: var TReprClosure) =
-  case n.kind
-  of nkNone: assert(false)
-  of nkSlot:
-    add result, $n.name
-    add result, " = "
-    reprAux(result, cast[pointer](cast[TAddress](p) + n.offset), n.typ, cl)
-  of nkList:
-    for i in 0..n.len-1:
-      if i > 0: add result, ",\n"
-      reprRecordAux(result, p, n.sons[i], cl)
-  of nkCase:
-    var m = selectBranch(p, n)
-    reprAux(result, cast[pointer](cast[TAddress](p) + n.offset), n.typ, cl)
-    if m != nil: reprRecordAux(result, p, m, cl)
-
-proc reprRecord(result: var string, p: pointer, typ: PNimType,
-                cl: var TReprClosure) =
-  add result, "["
-  reprRecordAux(result, p, typ.node, cl)
-  add result, "]"
-
-proc reprRef(result: var string, p: pointer, typ: PNimType,
-             cl: var TReprClosure) =
-  # we know that p is not nil here:
-  when defined(boehmGC) or defined(nogc):
-    var cell = cast[PCell](p)
-  else:
-    var cell = usrToCell(p)
-  add result, "ref " & reprPointer(p)
-  if cell notin cl.marked:
-    # only the address is shown:
-    incl(cl.marked, cell)
-    add result, " --> "
-    reprAux(result, p, typ.base, cl)
-
-proc reprAux(result: var string, p: pointer, typ: PNimType,
-             cl: var TReprClosure) =
-  if cl.recdepth == 0:
-    add result, "..."
-    return
-  dec(cl.recdepth)
-  case typ.kind
-  of tySet: reprSetAux(result, p, typ)
-  of tyArray: reprArray(result, p, typ, cl)
-  of tyTuple, tyPureObject: reprRecord(result, p, typ, cl)
-  of tyObject: 
-    var t = cast[ptr PNimType](p)^
-    reprRecord(result, p, t, cl)
-  of tyRef, tyPtr:
-    assert(p != nil)
-    if cast[ppointer](p)^ == nil: add result, "nil"
-    else: reprRef(result, cast[ppointer](p)^, typ, cl)
-  of tySequence:
-    reprSequence(result, cast[ppointer](p)^, typ, cl)
-  of tyInt: add result, $(cast[ptr int](p)^)
-  of tyInt8: add result, $int(cast[ptr Int8](p)^)
-  of tyInt16: add result, $int(cast[ptr Int16](p)^)
-  of tyInt32: add result, $int(cast[ptr Int32](p)^)
-  of tyInt64: add result, $(cast[ptr Int64](p)^)
-  of tyFloat: add result, $(cast[ptr float](p)^)
-  of tyFloat32: add result, $(cast[ptr float32](p)^)
-  of tyFloat64: add result, $(cast[ptr float64](p)^)
-  of tyEnum: add result, reprEnum(cast[ptr int](p)^, typ)
-  of tyBool: add result, reprBool(cast[ptr bool](p)^)
-  of tyChar: add result, reprChar(cast[ptr char](p)^)
-  of tyString: reprStrAux(result, cast[ptr string](p)^)
-  of tyCString: reprStrAux(result, $(cast[ptr cstring](p)^))
-  of tyRange: reprAux(result, p, typ.base, cl)
-  of tyProc, tyPointer:
-    if cast[ppointer](p)^ == nil: add result, "nil"
-    else: add result, reprPointer(cast[ppointer](p)^)
-  else:
-    add result, "(invalid data!)"
-  inc(cl.recdepth)
-
-proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {.
-                   compilerproc.} =
-  var
-    cl: TReprClosure
-  initReprClosure(cl)
-  result = "["
-  var bs = elemtyp.size
-  for i in 0..length - 1:
-    if i > 0: add result, ", "
-    reprAux(result, cast[pointer](cast[TAddress](p) + i*bs), elemtyp, cl)
-  add result, "]"
-  deinitReprClosure(cl)
-
-proc reprAny(p: pointer, typ: PNimType): string =
-  var
-    cl: TReprClosure
-  initReprClosure(cl)
-  result = ""
-  if typ.kind in {tyObject, tyPureObject, tyTuple, tyArray, tySet}:
-    reprAux(result, p, typ, cl)
+when not defined(useNimRtl):
+  proc initReprClosure(cl: var ReprClosure) =
+    # Important: cellsets does not lock the heap when doing allocations! We
+    # have to do it here ...
+    when hasThreadSupport and hasSharedHeap and declared(heapLock):
+      AcquireSys(HeapLock)
+    when declared(CellSet):
+      init(cl.marked)
+    cl.recdepth = -1      # default is to display everything!
+    cl.indent = 0
+
+  proc deinitReprClosure(cl: var ReprClosure) =
+    when declared(CellSet): deinit(cl.marked)
+    when hasThreadSupport and hasSharedHeap and declared(heapLock):
+      ReleaseSys(HeapLock)
+
+  proc reprBreak(result: var string, cl: ReprClosure) =
+    add result, "\n"
+    for i in 0..cl.indent-1: add result, ' '
+
+  proc reprAux(result: var string, p: pointer, typ: PNimType,
+               cl: var ReprClosure) {.benign.}
+
+  proc reprArray(result: var string, p: pointer, typ: PNimType,
+                 cl: var ReprClosure) =
+    add result, "["
+    var bs = typ.base.size
+    for i in 0..typ.size div bs - 1:
+      if i > 0: add result, ", "
+      reprAux(result, cast[pointer](cast[int](p) + i*bs), typ.base, cl)
+    add result, "]"
+
+  when defined(nimSeqsV2):
+    type
+      GenericSeq = object
+        len: int
+        p: pointer
+      PGenericSeq = ptr GenericSeq
+    const payloadOffset = sizeof(int) + sizeof(pointer)
+      # see seqs.nim:    cap: int
+      #                  region: Allocator
+
+    template payloadPtr(x: untyped): untyped = cast[PGenericSeq](x).p
   else:
-    var p = p
-    reprAux(result, addr(p), typ, cl)
-  add result, "\n"
-  deinitReprClosure(cl)
+    const payloadOffset = GenericSeqSize ## the payload offset always depends on the alignment of the member type.
+    template payloadPtr(x: untyped): untyped = x
+
+  proc reprSequence(result: var string, p: pointer, typ: PNimType,
+                    cl: var ReprClosure) =
+    if p == nil:
+      add result, "[]"
+      return
+    result.add(reprPointer(p))
+    result.add "@["
+    var bs = typ.base.size
+    for i in 0..cast[PGenericSeq](p).len-1:
+      if i > 0: add result, ", "
+      reprAux(result, cast[pointer](cast[int](payloadPtr(p)) + align(payloadOffset, typ.align) + i*bs),
+              typ.base, cl)
+    add result, "]"
+
+  proc reprRecordAux(result: var string, p: pointer, n: ptr TNimNode,
+                     cl: var ReprClosure) {.benign.} =
+    case n.kind
+    of nkNone: sysAssert(false, "reprRecordAux")
+    of nkSlot:
+      add result, $n.name
+      add result, " = "
+      reprAux(result, cast[pointer](cast[int](p) + n.offset), n.typ, cl)
+    of nkList:
+      for i in 0..n.len-1:
+        if i > 0: add result, ",\n"
+        reprRecordAux(result, p, n.sons[i], cl)
+    of nkCase:
+      var m = selectBranch(p, n)
+      reprAux(result, cast[pointer](cast[int](p) + n.offset), n.typ, cl)
+      if m != nil: reprRecordAux(result, p, m, cl)
+
+  proc reprRecord(result: var string, p: pointer, typ: PNimType,
+                  cl: var ReprClosure) =
+    add result, "["
+    var curTyp = typ
+    var first = true
+    while curTyp != nil:
+      var part = ""
+      reprRecordAux(part, p, curTyp.node, cl)
+      if part.len > 0:
+        if not first:
+          add result, ",\n"
+        add result, part
+        first = false
+      curTyp = curTyp.base
+    add result, "]"
+
+  proc reprRef(result: var string, p: pointer, typ: PNimType,
+               cl: var ReprClosure) =
+    # we know that p is not nil here:
+    when declared(CellSet):
+      when defined(boehmGC) or defined(gogc) or defined(nogc) or usesDestructors:
+        var cell = cast[PCell](p)
+      else:
+        var cell = usrToCell(p)
+      add result, if typ.kind == tyPtr: "ptr " else: "ref "
+      add result, reprPointer(p)
+      if cell notin cl.marked:
+        # only the address is shown:
+        incl(cl.marked, cell)
+        add result, " --> "
+        reprAux(result, p, typ.base, cl)
+
+  proc getInt(p: pointer, size: int): int =
+    case size
+    of 1: return int(cast[ptr uint8](p)[])
+    of 2: return int(cast[ptr uint16](p)[])
+    of 4: return int(cast[ptr uint32](p)[])
+    of 8: return int(cast[ptr uint64](p)[])
+    else: discard
+
+  proc reprAux(result: var string, p: pointer, typ: PNimType,
+               cl: var ReprClosure) =
+    if cl.recdepth == 0:
+      add result, "..."
+      return
+    dec(cl.recdepth)
+    case typ.kind
+    of tySet: reprSetAux(result, p, typ)
+    of tyArray, tyArrayConstr: reprArray(result, p, typ, cl)
+    of tyTuple: reprRecord(result, p, typ, cl)
+    of tyObject:
+      var t = cast[ptr PNimType](p)[]
+      reprRecord(result, p, t, cl)
+    of tyRef, tyPtr:
+      sysAssert(p != nil, "reprAux")
+      if cast[PPointer](p)[] == nil: add result, "nil"
+      else: reprRef(result, cast[PPointer](p)[], typ, cl)
+    of tySequence:
+      reprSequence(result, cast[PPointer](p)[], typ, cl)
+    of tyInt: add result, $(cast[ptr int](p)[])
+    of tyInt8: add result, $int(cast[ptr int8](p)[])
+    of tyInt16: add result, $int(cast[ptr int16](p)[])
+    of tyInt32: add result, $int(cast[ptr int32](p)[])
+    of tyInt64: add result, $(cast[ptr int64](p)[])
+    of tyUInt: add result, $(cast[ptr uint](p)[])
+    of tyUInt8: add result, $(cast[ptr uint8](p)[])
+    of tyUInt16: add result, $(cast[ptr uint16](p)[])
+    of tyUInt32: add result, $(cast[ptr uint32](p)[])
+    of tyUInt64: add result, $(cast[ptr uint64](p)[])
+
+    of tyFloat: add result, $(cast[ptr float](p)[])
+    of tyFloat32: add result, $(cast[ptr float32](p)[])
+    of tyFloat64: add result, $(cast[ptr float64](p)[])
+    of tyEnum: add result, reprEnum(getInt(p, typ.size), typ)
+    of tyBool: add result, reprBool(cast[ptr bool](p)[])
+    of tyChar: add result, reprChar(cast[ptr char](p)[])
+    of tyString:
+      let sp = cast[ptr string](p)
+      reprStrAux(result, sp[].cstring, sp[].len)
+    of tyCstring:
+      let cs = cast[ptr cstring](p)[]
+      if cs.isNil: add result, "nil"
+      else: reprStrAux(result, cs, cs.len)
+    of tyRange: reprAux(result, p, typ.base, cl)
+    of tyProc, tyPointer:
+      if cast[PPointer](p)[] == nil: add result, "nil"
+      else: add result, reprPointer(cast[PPointer](p)[])
+    of tyUncheckedArray:
+      add result, "[...]"
+    else:
+      add result, "(invalid data!)"
+    inc(cl.recdepth)
+
+when not defined(useNimRtl):
+  proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {.
+                     compilerRtl.} =
+    var
+      cl: ReprClosure
+    initReprClosure(cl)
+    result = "["
+    var bs = elemtyp.size
+    for i in 0..length - 1:
+      if i > 0: add result, ", "
+      reprAux(result, cast[pointer](cast[int](p) + i*bs), elemtyp, cl)
+    add result, "]"
+    deinitReprClosure(cl)
+
+when not defined(useNimRtl):
+  proc reprAny(p: pointer, typ: PNimType): string =
+    var
+      cl: ReprClosure
+    initReprClosure(cl)
+    result = ""
+    if typ.kind in {tyObject, tyTuple, tyArray, tyArrayConstr, tySet}:
+      reprAux(result, p, typ, cl)
+    else:
+      var p = p
+      reprAux(result, addr(p), typ, cl)
+    when defined(nimLegacyReprWithNewline): # see PR #16034
+      add result, "\n"
+    deinitReprClosure(cl)
diff --git a/lib/system/repr_impl.nim b/lib/system/repr_impl.nim
new file mode 100644
index 000000000..b9ec1890f
--- /dev/null
+++ b/lib/system/repr_impl.nim
@@ -0,0 +1,15 @@
+#[
+other APIs common to system/repr and system/reprjs could be refactored here, eg:
+* reprChar
+* reprBool
+* reprStr
+
+Another possibility in future work would be to have a single include file instead
+of system/repr and system/reprjs, and use `when defined(js)` inside it.
+]#
+
+proc reprDiscriminant*(e: int, typ: PNimType): string {.compilerRtl.} =
+  case typ.kind
+  of tyEnum: reprEnum(e, typ)
+  of tyBool: $(e != 0)
+  else: $e
diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim
new file mode 100644
index 000000000..d2aef536c
--- /dev/null
+++ b/lib/system/repr_v2.nim
@@ -0,0 +1,194 @@
+include system/inclrtl
+
+when defined(nimPreviewSlimSystem):
+  import std/formatfloat
+
+proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}
+  ## imported from typetraits
+
+proc distinctBase(T: typedesc, recursive: static bool = true): typedesc {.magic: "TypeTrait".}
+  ## imported from typetraits
+
+proc rangeBase(T: typedesc): typedesc {.magic: "TypeTrait".}
+  # skip one level of range; return the base type of a range type
+
+proc repr*(x: NimNode): string {.magic: "Repr", noSideEffect.}
+
+proc repr*(x: int): string =
+  ## Same as $x
+  $x
+
+proc repr*(x: int64): string =
+  ## Same as $x
+  $x
+
+proc repr*(x: uint64): string {.noSideEffect.} =
+  ## Same as $x
+  $x
+
+proc repr*(x: float): string =
+  ## Same as $x
+  $x
+
+proc repr*(x: bool): string {.magic: "BoolToStr", noSideEffect.}
+  ## repr for a boolean argument. Returns `x`
+  ## converted to the string "false" or "true".
+
+proc repr*(x: char): string {.noSideEffect, raises: [].} =
+  ## repr for a character argument. Returns `x`
+  ## converted to an escaped string.
+  ##
+  ##   ```Nim
+  ##   assert repr('c') == "'c'"
+  ##   ```
+  result = "'"
+  # Elides string creations if not needed
+  if x in {'\\', '\0'..'\31', '\127'..'\255'}:
+    result.add '\\'
+  if x in {'\0'..'\31', '\127'..'\255'}:
+    result.add $x.uint8
+  else:
+    result.add x
+  result.add '\''
+
+proc repr*(x: string | cstring): string {.noSideEffect, raises: [].} =
+  ## repr for a string argument. Returns `x`
+  ## converted to a quoted and escaped string.
+  result = "\""
+  for i in 0..<x.len:
+    if x[i] in {'"', '\\', '\0'..'\31', '\127'..'\255'}:
+      result.add '\\'
+    case x[i]:
+    of '\n':
+      result.add "n\n"
+    of '\0'..'\9', '\11'..'\31', '\127'..'\255':
+      result.add $x[i].uint8
+    else:
+      result.add x[i]
+  result.add '\"'
+
+proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect, raises: [].}
+  ## repr for an enumeration argument. This works for
+  ## any enumeration type thanks to compiler magic.
+  ##
+  ## If a `repr` operator for a concrete enumeration is provided, this is
+  ## used instead. (In other words: *Overwriting* is possible.)
+
+proc reprDiscriminant*(e: int): string {.compilerproc.} =
+  # repr and reprjs can use `PNimType` to symbolize `e`; making this work here
+  # would require a way to pass the set of enum stringified values to cgen.
+  $e
+
+proc repr*(p: pointer): string =
+  ## repr of pointer as its hexadecimal value
+  if p == nil:
+    result = "nil"
+  else:
+    when nimvm:
+      result = "ptr"
+    else:
+      const HexChars = "0123456789ABCDEF"
+      const len = sizeof(pointer) * 2
+      var n = cast[uint](p)
+      result = newString(len)
+      for j in countdown(len-1, 0):
+        result[j] = HexChars[n and 0xF]
+        n = n shr 4
+
+proc repr*(p: proc | iterator {.closure.}): string =
+  ## repr of a proc as its address
+  repr(cast[ptr pointer](unsafeAddr p)[])
+
+template repr*[T: distinct|(range and not enum)](x: T): string =
+  when T is range: # add a branch to handle range
+    repr(rangeBase(typeof(x))(x))
+  elif T is distinct:
+    repr(distinctBase(typeof(x))(x))
+  else:
+    {.error: "cannot happen".}
+
+template repr*(t: typedesc): string = $t
+
+proc reprObject[T: tuple|object](res: var string, x: T) {.noSideEffect, raises: [].} =
+  res.add '('
+  var firstElement = true
+  const isNamed = T is object or isNamedTuple(T)
+  when not isNamed:
+    var count = 0
+  for name, value in fieldPairs(x):
+    if not firstElement: res.add(", ")
+    when isNamed:
+      res.add(name)
+      res.add(": ")
+    else:
+      count.inc
+    res.add repr(value)
+    firstElement = false
+  when not isNamed:
+    if count == 1:
+      res.add(',') # $(1,) should print as the semantically legal (1,)
+  res.add(')')
+
+
+proc repr*[T: tuple|object](x: T): string {.noSideEffect, raises: [].} =
+  ## Generic `repr` operator for tuples that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(23, 45) == "(23, 45)"
+  ##   $(a: 23, b: 45) == "(a: 23, b: 45)"
+  ##   $() == "()"
+  ##   ```
+  when T is object:
+    result = $typeof(x)
+  reprObject(result, x)
+
+proc repr*[T](x: ref T | ptr T): string {.noSideEffect, raises: [].} =
+  if isNil(x): return "nil"
+  when T is object:
+    result = $typeof(x)
+    reprObject(result, x[])
+  else:
+    result = when typeof(x) is ref: "ref " else: "ptr "
+    result.add repr(x[])
+
+proc collectionToRepr[T](x: T, prefix, separator, suffix: string): string {.noSideEffect, raises: [].} =
+  result = prefix
+  var firstElement = true
+  for value in items(x):
+    if firstElement:
+      firstElement = false
+    else:
+      result.add(separator)
+    result.add repr(value)
+  result.add(suffix)
+
+proc repr*[T](x: set[T]): string =
+  ## Generic `repr` operator for sets that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   ${23, 45} == "{23, 45}"
+  ##   ```
+  collectionToRepr(x, "{", ", ", "}")
+
+proc repr*[T](x: seq[T]): string =
+  ## Generic `repr` operator for seqs that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(@[23, 45]) == "@[23, 45]"
+  ##   ```
+  collectionToRepr(x, "@[", ", ", "]")
+
+proc repr*[T, IDX](x: array[IDX, T]): string =
+  ## Generic `repr` operator for arrays that is lifted from the components.
+  collectionToRepr(x, "[", ", ", "]")
+
+proc repr*[T](x: openArray[T]): string =
+  ## Generic `repr` operator for openarrays that is lifted from the components
+  ## of `x`. Example:
+  ##   ```Nim
+  ##   $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]"
+  ##   ```
+  collectionToRepr(x, "[", ", ", "]")
+
+proc repr*[T](x: UncheckedArray[T]): string =
+  "[...]"
diff --git a/lib/system/reprjs.nim b/lib/system/reprjs.nim
new file mode 100644
index 000000000..761d66aec
--- /dev/null
+++ b/lib/system/reprjs.nim
@@ -0,0 +1,251 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+# The generic ``repr`` procedure for the javascript backend.
+
+when defined(nimPreviewSlimSystem):
+  import std/formatfloat
+
+proc reprInt(x: int64): string {.compilerproc.} = $x
+proc reprInt(x: uint64): string {.compilerproc.} = $x
+proc reprInt(x: int): string {.compilerproc.} = $x
+proc reprFloat(x: float): string {.compilerproc.} = $x
+
+proc reprPointer(p: pointer): string {.compilerproc.} =
+  # Do we need to generate the full 8bytes ? In js a pointer is an int anyway
+  var tmp: int
+  {.emit: "`tmp` = `p`_Idx || 0;".}
+  result = $tmp
+
+proc reprBool(x: bool): string {.compilerRtl.} =
+  if x: result = "true"
+  else: result = "false"
+
+proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
+  var tmp: bool
+  let item = typ.node.sons[e]
+  {.emit: "`tmp` = `item` !== undefined;".}
+  if tmp:
+    result = makeNimstrLit(item.name)
+  else:
+    result = $e & " (invalid data!)"
+
+include system/repr_impl
+
+proc reprChar(x: char): string {.compilerRtl.} =
+  result = "\'"
+  case x
+  of '"': add(result, "\\\"")
+  of '\\': add(result, "\\\\")
+  of '\127'..'\255', '\0'..'\31': add(result, "\\" & reprInt(ord(x)))
+  else: add(result, x)
+  add(result, "\'")
+
+proc reprStrAux(result: var string, s: cstring | string, len: int) =
+  add(result, "\"")
+  for i in 0 .. len-1:
+    let c = s[i]
+    case c
+    of '"': add(result, "\\\"")
+    of '\\': add(result, "\\\\")
+    #of '\10': add(result, "\\10\"\n\"")
+    of '\127'..'\255', '\0'..'\31':
+      add(result, "\\" & reprInt(ord(c)))
+    else:
+      add(result, c)
+  add(result, "\"")
+
+proc reprStr(s: string): string {.compilerRtl.} =
+  reprStrAux(result, s, s.len)
+
+proc addSetElem(result: var string, elem: int, typ: PNimType) =
+  # Dispatch each set element to the correct repr<Type> proc
+  case typ.kind:
+  of tyEnum: add(result, reprEnum(elem, typ))
+  of tyBool: add(result, reprBool(bool(elem)))
+  of tyChar: add(result, reprChar(chr(elem)))
+  of tyRange: addSetElem(result, elem, typ.base) # Note the base to advance towards the element type
+  of tyInt..tyInt64, tyUInt8, tyUInt16: add result, reprInt(elem)
+  else: # data corrupt --> inform the user
+    add(result, " (invalid data!)")
+
+iterator setKeys(s: int): int {.inline.} =
+  # The type of s is a lie, but it's expected to be a set.
+  # Iterate over the JS object representing a set
+  # and returns the keys as int.
+  var len: int
+  var yieldRes: int
+  var i: int = 0
+  {. emit: """
+  var setObjKeys = Object.getOwnPropertyNames(`s`);
+  `len` = setObjKeys.length;
+  """ .}
+  while i < len:
+    {. emit: "`yieldRes` = parseInt(setObjKeys[`i`],10);\n" .}
+    yield yieldRes
+    inc i
+
+proc reprSetAux(result: var string, s: int, typ: PNimType) =
+  add(result, "{")
+  var first: bool = true
+  for el in setKeys(s):
+    if first:
+      first = false
+    else:
+      add(result, ", ")
+    addSetElem(result, el, typ.base)
+  add(result, "}")
+
+proc reprSet(e: int, typ: PNimType): string {.compilerRtl.} =
+  reprSetAux(result, e, typ)
+
+type
+  ReprClosure {.final.} = object
+    recDepth: int       # do not recurse endlessly
+    indent: int         # indentation
+
+proc initReprClosure(cl: var ReprClosure) =
+  cl.recDepth = -1 # default is to display everything!
+  cl.indent = 0
+
+proc reprAux(result: var string, p: pointer, typ: PNimType, cl: var ReprClosure)
+
+proc reprArray(a: pointer, typ: PNimType,
+              cl: var ReprClosure): string {.compilerRtl.} =
+  # We prepend @ to seq, the C backend prepends the pointer to the seq.
+  result = if typ.kind == tySequence: "@[" else: "["
+  var len: int = 0
+
+  {. emit: "`len` = `a`.length;\n" .}
+  var dereffed: pointer = a
+  for i in 0 .. len-1:
+    if i > 0 :
+      add(result, ", ")
+    # advance pointer and point to element at index
+    {. emit: """
+    `dereffed`_Idx = `i`;
+    `dereffed` = `a`[`dereffed`_Idx];
+    """ .}
+    reprAux(result, dereffed, typ.base, cl)
+
+  add(result, "]")
+
+proc isPointedToNil(p: pointer): bool =
+  {. emit: "if (`p` === null) {`result` = true;}\n" .}
+
+proc reprRef(result: var string, p: pointer, typ: PNimType,
+          cl: var ReprClosure) =
+  if p.isPointedToNil:
+    add(result, "nil")
+    return
+  add(result, "ref " & reprPointer(p))
+  add(result, " --> ")
+  if typ.base.kind != tyArray:
+    {. emit: """
+    if (`p` != null && `p`.length > 0) {
+      `p` = `p`[`p`_Idx];
+    }
+    """ .}
+  reprAux(result, p, typ.base, cl)
+
+proc reprRecordAux(result: var string, o: pointer, typ: PNimType, cl: var ReprClosure) =
+  add(result, "[")
+
+  var first = true
+  var val = o
+  if typ.node.len == 0:
+    # if the object has only one field, len is 0  and sons is nil, the field is in node
+    let key: cstring = typ.node.name
+    add(result, $key & " = ")
+    {. emit: "`val` = `o`[`key`];\n" .}
+    reprAux(result, val, typ.node.typ, cl)
+  else:
+    # if the object has more than one field, sons is not nil and contains the fields.
+    for i in 0 .. typ.node.len-1:
+      if first: first = false
+      else: add(result, ",\n")
+
+      let key: cstring = typ.node.sons[i].name
+      add(result, $key & " = ")
+      {. emit: "`val` = `o`[`key`];\n" .} # access the field by name
+      reprAux(result, val, typ.node.sons[i].typ, cl)
+  add(result, "]")
+
+proc reprRecord(o: pointer, typ: PNimType, cl: var ReprClosure): string {.compilerRtl.} =
+  reprRecordAux(result, o, typ, cl)
+
+
+proc reprJsonStringify(p: int): string {.compilerRtl.} =
+  # As a last resort, use stringify
+  # We use this for tyOpenArray, tyVarargs while genTypeInfo is not implemented
+  var tmp: cstring
+  {. emit: "`tmp` = JSON.stringify(`p`);\n" .}
+  result = $tmp
+
+proc reprAux(result: var string, p: pointer, typ: PNimType,
+            cl: var ReprClosure) =
+  if cl.recDepth == 0:
+    add(result, "...")
+    return
+  dec(cl.recDepth)
+  case typ.kind
+  of tyInt..tyInt32, tyUInt..tyUInt32:
+    add(result, reprInt(cast[int](p)))
+  of tyInt64:
+    add(result, reprInt(cast[int64](p)))
+  of tyUInt64:
+    add(result, reprInt(cast[uint64](p)))
+  of tyChar:
+    add(result, reprChar(cast[char](p)))
+  of tyBool:
+    add(result, reprBool(cast[bool](p)))
+  of tyFloat..tyFloat128:
+    add(result, reprFloat(cast[float](p)))
+  of tyString:
+    var fp: int
+    {. emit: "`fp` = `p`;\n" .}
+    add(result, reprStr(cast[string](p)))
+  of tyCstring:
+    var fp: cstring
+    {. emit: "`fp` = `p`;\n" .}
+    if fp.isNil:
+      add(result, "nil")
+    else:
+      reprStrAux(result, fp, fp.len)
+  of tyEnum, tyOrdinal:
+    var fp: int
+    {. emit: "`fp` = `p`;\n" .}
+    add(result, reprEnum(fp, typ))
+  of tySet:
+    var fp: int
+    {. emit: "`fp` = `p`;\n" .}
+    add(result, reprSet(fp, typ))
+  of tyRange: reprAux(result, p, typ.base, cl)
+  of tyObject, tyTuple:
+    add(result, reprRecord(p, typ, cl))
+  of tyArray, tyArrayConstr, tySequence:
+    add(result, reprArray(p, typ, cl))
+  of tyPointer:
+    add(result, reprPointer(p))
+  of tyPtr, tyRef:
+    reprRef(result, p, typ, cl)
+  of tyProc:
+    if p.isPointedToNil:
+      add(result, "nil")
+    else:
+      add(result, reprPointer(p))
+  else:
+    add(result, "(invalid data!)" & reprJsonStringify(cast[int](p)))
+  inc(cl.recDepth)
+
+proc reprAny(p: pointer, typ: PNimType): string {.compilerRtl.} =
+  var cl: ReprClosure
+  initReprClosure(cl)
+  reprAux(result, p, typ, cl)
+  when defined(nimLegacyReprWithNewline): # see PR #16034
+    add result, "\n"
diff --git a/lib/system/seqs_v2.nim b/lib/system/seqs_v2.nim
new file mode 100644
index 000000000..572e77408
--- /dev/null
+++ b/lib/system/seqs_v2.nim
@@ -0,0 +1,227 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+# import std/typetraits
+# strs already imported allocateds for us.
+
+
+# Some optimizations here may be not to empty-seq-initialize some symbols, then StrictNotNil complains.
+{.push warning[StrictNotNil]: off.}  # See https://github.com/nim-lang/Nim/issues/21401
+
+
+## Default seq implementation used by Nim's core.
+type
+  NimSeqPayloadBase = object
+    cap: int
+
+  NimSeqPayload[T] = object
+    cap: int
+    data: UncheckedArray[T]
+
+  NimSeqV2*[T] = object # \
+    # if you change this implementation, also change seqs_v2_reimpl.nim!
+    len: int
+    p: ptr NimSeqPayload[T]
+
+  NimRawSeq = object
+    len: int
+    p: pointer
+
+const nimSeqVersion {.core.} = 2
+
+# XXX make code memory safe for overflows in '*'
+
+proc newSeqPayload(cap, elemSize, elemAlign: int): pointer {.compilerRtl, raises: [].} =
+  # we have to use type erasure here as Nim does not support generic
+  # compilerProcs. Oh well, this will all be inlined anyway.
+  if cap > 0:
+    var p = cast[ptr NimSeqPayloadBase](alignedAlloc0(align(sizeof(NimSeqPayloadBase), elemAlign) + cap * elemSize, elemAlign))
+    p.cap = cap
+    result = p
+  else:
+    result = nil
+
+proc newSeqPayloadUninit(cap, elemSize, elemAlign: int): pointer {.compilerRtl, raises: [].} =
+  # Used in `newSeqOfCap()`.
+  if cap > 0:
+    var p = cast[ptr NimSeqPayloadBase](alignedAlloc(align(sizeof(NimSeqPayloadBase), elemAlign) + cap * elemSize, elemAlign))
+    p.cap = cap
+    result = p
+  else:
+    result = nil
+
+template `+!`(p: pointer, s: int): pointer =
+  cast[pointer](cast[int](p) +% s)
+
+template `-!`(p: pointer, s: int): pointer =
+  cast[pointer](cast[int](p) -% s)
+
+proc prepareSeqAdd(len: int; p: pointer; addlen, elemSize, elemAlign: int): pointer {.
+    noSideEffect, tags: [], raises: [], compilerRtl.} =
+  {.noSideEffect.}:
+    let headerSize = align(sizeof(NimSeqPayloadBase), elemAlign)
+    if addlen <= 0:
+      result = p
+    elif p == nil:
+      result = newSeqPayload(len+addlen, elemSize, elemAlign)
+    else:
+      # Note: this means we cannot support things that have internal pointers as
+      # they get reallocated here. This needs to be documented clearly.
+      var p = cast[ptr NimSeqPayloadBase](p)
+      let oldCap = p.cap and not strlitFlag
+      let newCap = max(resize(oldCap), len+addlen)
+      var q: ptr NimSeqPayloadBase
+      if (p.cap and strlitFlag) == strlitFlag:
+        q = cast[ptr NimSeqPayloadBase](alignedAlloc(headerSize + elemSize * newCap, elemAlign))
+        copyMem(q +! headerSize, p +! headerSize, len * elemSize)
+      else:
+        let oldSize = headerSize + elemSize * oldCap
+        let newSize = headerSize + elemSize * newCap
+        q = cast[ptr NimSeqPayloadBase](alignedRealloc(p, oldSize, newSize, elemAlign))
+
+      zeroMem(q +! headerSize +! len * elemSize, addlen * elemSize)
+      q.cap = newCap
+      result = q
+
+proc zeroNewElements(len: int; q: pointer; addlen, elemSize, elemAlign: int) {.
+    noSideEffect, tags: [], raises: [], compilerRtl.} =
+  {.noSideEffect.}:
+    let headerSize = align(sizeof(NimSeqPayloadBase), elemAlign)
+    zeroMem(q +! headerSize +! len * elemSize, addlen * elemSize)
+
+proc prepareSeqAddUninit(len: int; p: pointer; addlen, elemSize, elemAlign: int): pointer {.
+    noSideEffect, tags: [], raises: [], compilerRtl.} =
+  {.noSideEffect.}:
+    let headerSize = align(sizeof(NimSeqPayloadBase), elemAlign)
+    if addlen <= 0:
+      result = p
+    elif p == nil:
+      result = newSeqPayloadUninit(len+addlen, elemSize, elemAlign)
+    else:
+      # Note: this means we cannot support things that have internal pointers as
+      # they get reallocated here. This needs to be documented clearly.
+      var p = cast[ptr NimSeqPayloadBase](p)
+      let oldCap = p.cap and not strlitFlag
+      let newCap = max(resize(oldCap), len+addlen)
+      if (p.cap and strlitFlag) == strlitFlag:
+        var q = cast[ptr NimSeqPayloadBase](alignedAlloc(headerSize + elemSize * newCap, elemAlign))
+        copyMem(q +! headerSize, p +! headerSize, len * elemSize)
+        q.cap = newCap
+        result = q
+      else:
+        let oldSize = headerSize + elemSize * oldCap
+        let newSize = headerSize + elemSize * newCap
+        var q = cast[ptr NimSeqPayloadBase](alignedRealloc(p, oldSize, newSize, elemAlign))
+        q.cap = newCap
+        result = q
+
+proc shrink*[T](x: var seq[T]; newLen: Natural) {.tags: [], raises: [].} =
+  when nimvm:
+    {.cast(tags: []).}:
+      setLen(x, newLen)
+  else:
+    #sysAssert newLen <= x.len, "invalid newLen parameter for 'shrink'"
+    when not supportsCopyMem(T):
+      for i in countdown(x.len - 1, newLen):
+        reset x[i]
+    # XXX This is wrong for const seqs that were moved into 'x'!
+    {.noSideEffect.}:
+      cast[ptr NimSeqV2[T]](addr x).len = newLen
+
+proc grow*[T](x: var seq[T]; newLen: Natural; value: T) {.nodestroy.} =
+  let oldLen = x.len
+  #sysAssert newLen >= x.len, "invalid newLen parameter for 'grow'"
+  if newLen <= oldLen: return
+  var xu = cast[ptr NimSeqV2[T]](addr x)
+  if xu.p == nil or (xu.p.cap and not strlitFlag) < newLen:
+    xu.p = cast[typeof(xu.p)](prepareSeqAddUninit(oldLen, xu.p, newLen - oldLen, sizeof(T), alignof(T)))
+  xu.len = newLen
+  for i in oldLen .. newLen-1:
+    wasMoved(xu.p.data[i])
+    `=copy`(xu.p.data[i], value)
+
+proc add*[T](x: var seq[T]; y: sink T) {.magic: "AppendSeqElem", noSideEffect, nodestroy.} =
+  ## Generic proc for adding a data item `y` to a container `x`.
+  ##
+  ## For containers that have an order, `add` means *append*. New generic
+  ## containers should also call their adding proc `add` for consistency.
+  ## Generic code becomes much easier to write if the Nim naming scheme is
+  ## respected.
+  {.cast(noSideEffect).}:
+    let oldLen = x.len
+    var xu = cast[ptr NimSeqV2[T]](addr x)
+    if xu.p == nil or (xu.p.cap and not strlitFlag) < oldLen+1:
+      xu.p = cast[typeof(xu.p)](prepareSeqAddUninit(oldLen, xu.p, 1, sizeof(T), alignof(T)))
+    xu.len = oldLen+1
+    # .nodestroy means `xu.p.data[oldLen] = value` is compiled into a
+    # copyMem(). This is fine as know by construction that
+    # in `xu.p.data[oldLen]` there is nothing to destroy.
+    # We also save the `wasMoved + destroy` pair for the sink parameter.
+    xu.p.data[oldLen] = y
+
+proc setLen[T](s: var seq[T], newlen: Natural) {.nodestroy.} =
+  {.noSideEffect.}:
+    if newlen < s.len:
+      shrink(s, newlen)
+    else:
+      let oldLen = s.len
+      if newlen <= oldLen: return
+      var xu = cast[ptr NimSeqV2[T]](addr s)
+      if xu.p == nil or (xu.p.cap and not strlitFlag) < newlen:
+        xu.p = cast[typeof(xu.p)](prepareSeqAddUninit(oldLen, xu.p, newlen - oldLen, sizeof(T), alignof(T)))
+      xu.len = newlen
+      for i in oldLen..<newlen:
+        xu.p.data[i] = default(T)
+
+proc newSeq[T](s: var seq[T], len: Natural) =
+  shrink(s, 0)
+  setLen(s, len)
+
+proc sameSeqPayload(x: pointer, y: pointer): bool {.compilerRtl, inl.} =
+  result = cast[ptr NimRawSeq](x)[].p == cast[ptr NimRawSeq](y)[].p
+
+
+func capacity*[T](self: seq[T]): int {.inline.} =
+  ## Returns the current capacity of the seq.
+  # See https://github.com/nim-lang/RFCs/issues/460
+  runnableExamples:
+    var lst = newSeqOfCap[string](cap = 42)
+    lst.add "Nim"
+    assert lst.capacity == 42
+
+  let sek = cast[ptr NimSeqV2[T]](unsafeAddr self)
+  result = if sek.p != nil: sek.p.cap and not strlitFlag else: 0
+
+func setLenUninit*[T](s: var seq[T], newlen: Natural) {.nodestroy.} =
+  ## Sets the length of seq `s` to `newlen`. `T` may be any sequence type.
+  ## New slots will not be initialized.
+  ##
+  ## If the current length is greater than the new length,
+  ## `s` will be truncated.
+  ##   ```nim
+  ##   var x = @[10, 20]
+  ##   x.setLenUninit(5)
+  ##   x[4] = 50
+  ##   assert x[4] == 50
+  ##   x.setLenUninit(1)
+  ##   assert x == @[10]
+  ##   ```
+  {.noSideEffect.}:
+    if newlen < s.len:
+      shrink(s, newlen)
+    else:
+      let oldLen = s.len
+      if newlen <= oldLen: return
+      var xu = cast[ptr NimSeqV2[T]](addr s)
+      if xu.p == nil or (xu.p.cap and not strlitFlag) < newlen:
+        xu.p = cast[typeof(xu.p)](prepareSeqAddUninit(oldLen, xu.p, newlen - oldLen, sizeof(T), alignof(T)))
+      xu.len = newlen
+
+{.pop.}  # See https://github.com/nim-lang/Nim/issues/21401
diff --git a/lib/system/seqs_v2_reimpl.nim b/lib/system/seqs_v2_reimpl.nim
new file mode 100644
index 000000000..09b7e7ac4
--- /dev/null
+++ b/lib/system/seqs_v2_reimpl.nim
@@ -0,0 +1,24 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+type
+  NimSeqPayloadReimpl = object
+    cap: int
+    data: pointer
+
+  NimSeqV2Reimpl = object
+    len: int
+    p: ptr NimSeqPayloadReimpl
+
+template frees(s: NimSeqV2Reimpl) =
+  if s.p != nil and (s.p.cap and strlitFlag) != strlitFlag:
+    when compileOption("threads"):
+      deallocShared(s.p)
+    else:
+      dealloc(s.p)
\ No newline at end of file
diff --git a/lib/system/setops.nim b/lib/system/setops.nim
new file mode 100644
index 000000000..67aa3097a
--- /dev/null
+++ b/lib/system/setops.nim
@@ -0,0 +1,89 @@
+func incl*[T](x: var set[T], y: T) {.magic: "Incl".} =
+  ## Includes element `y` in the set `x`.
+  ##
+  ## This is the same as `x = x + {y}`, but it might be more efficient.
+  runnableExamples:
+    var a = {1, 3, 5}
+    a.incl(2)
+    assert a == {1, 2, 3, 5}
+    a.incl(4)
+    assert a == {1, 2, 3, 4, 5}
+
+when not defined(nimHasCallsitePragma):
+  {.pragma: callsite.}
+
+template incl*[T](x: var set[T], y: set[T]) {.callsite.} =
+  ## Includes the set `y` in the set `x`.
+  runnableExamples:
+    var a = {1, 3, 5, 7}
+    var b = {4, 5, 6}
+    a.incl(b)
+    assert a == {1, 3, 4, 5, 6, 7}
+  x = x + y
+
+func excl*[T](x: var set[T], y: T) {.magic: "Excl".} =
+  ## Excludes element `y` from the set `x`.
+  ##
+  ## This is the same as `x = x - {y}`, but it might be more efficient.
+  runnableExamples:
+    var b = {2, 3, 5, 6, 12, 54}
+    b.excl(5)
+    assert b == {2, 3, 6, 12, 54}
+
+template excl*[T](x: var set[T], y: set[T]) {.callsite.} =
+  ## Excludes the set `y` from the set `x`.
+  runnableExamples:
+    var a = {1, 3, 5, 7}
+    var b = {3, 4, 5}
+    a.excl(b) 
+    assert a == {1, 7}
+  x = x - y
+
+func card*[T](x: set[T]): int {.magic: "Card".} =
+  ## Returns the cardinality of the set `x`, i.e. the number of elements
+  ## in the set.
+  runnableExamples:
+    var a = {1, 3, 5, 7}
+    assert card(a) == 4
+    var b = {1, 3, 5, 7, 5}
+    assert card(b) == 4 # repeated 5 doesn't count
+
+func len*[T](x: set[T]): int {.magic: "Card".}
+  ## An alias for `card(x)`.
+
+
+func `*`*[T](x, y: set[T]): set[T] {.magic: "MulSet".} =
+  ## This operator computes the intersection of two sets.
+  runnableExamples:
+    assert {1, 2, 3} * {2, 3, 4} == {2, 3}
+
+func `+`*[T](x, y: set[T]): set[T] {.magic: "PlusSet".} =
+  ## This operator computes the union of two sets.
+  runnableExamples:
+    assert {1, 2, 3} + {2, 3, 4} == {1, 2, 3, 4}
+
+func `-`*[T](x, y: set[T]): set[T] {.magic: "MinusSet".} =
+  ## This operator computes the difference of two sets.
+  runnableExamples:
+    assert {1, 2, 3} - {2, 3, 4} == {1}
+
+func contains*[T](x: set[T], y: T): bool {.magic: "InSet".} =
+  ## One should overload this proc if one wants to overload the `in` operator.
+  ##
+  ## The parameters are in reverse order! `a in b` is a template for
+  ## `contains(b, a)`.
+  ## This is because the unification algorithm that Nim uses for overload
+  ## resolution works from left to right.
+  ## But for the `in` operator that would be the wrong direction for this
+  ## piece of code:
+  runnableExamples:
+    var s: set[range['a'..'z']] = {'a'..'c'}
+    assert s.contains('c')
+    assert 'b' in s
+    assert 'd' notin s
+    assert set['a'..'z'] is set[range['a'..'z']]
+  ## If `in` had been declared as `[T](elem: T, s: set[T])` then `T` would
+  ## have been bound to `char`. But `s` is not compatible to type
+  ## `set[char]`! The solution is to bind `T` to `range['a'..'z']`. This
+  ## is achieved by reversing the parameters for `contains`; `in` then
+  ## passes its arguments in reverse order.
diff --git a/lib/system/sets.nim b/lib/system/sets.nim
index f9f3eb32b..97431c296 100755..100644
--- a/lib/system/sets.nim
+++ b/lib/system/sets.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -9,20 +9,20 @@
 
 # set handling
 
-type
-  TNimSet = array [0..4*2048-1, int8]
 
-proc countBits32(n: int32): int {.compilerproc.} =
-  var v = n
-  v = v -% ((v shr 1'i32) and 0x55555555'i32)
-  v = (v and 0x33333333'i32) +% ((v shr 2'i32) and 0x33333333'i32)
-  result = ((v +% (v shr 4'i32) and 0xF0F0F0F'i32) *% 0x1010101'i32) shr 24'i32
+proc cardSetImpl(s: ptr UncheckedArray[uint8], len: int): int {.inline.} =
+  var i = 0
+  result = 0
+  var num = 0'u64
+  when defined(x86) or defined(amd64):
+    while i < len - 8:
+      copyMem(addr num, addr s[i], 8)
+      inc(result, countBits64(num))
+      inc(i, 8)
 
-proc countBits64(n: int64): int {.compilerproc.} = 
-  result = countBits32(toU32(n and 0xffff'i64)) +
-           countBits32(toU32(n shr 16'i64))
+  while i < len:
+    inc(result, countBits32(uint32(s[i])))
+    inc(i, 1)
 
-proc cardSet(s: TNimSet, len: int): int {.compilerproc.} =
-  result = 0
-  for i in countup(0, len-1):
-    inc(result, countBits32(int32(ze(s[i]))))
+proc cardSet(s: ptr UncheckedArray[uint8], len: int): int {.compilerproc, inline.} =
+  result = cardSetImpl(s, len)
diff --git a/lib/system/stacktraces.nim b/lib/system/stacktraces.nim
new file mode 100644
index 000000000..42be9d94f
--- /dev/null
+++ b/lib/system/stacktraces.nim
@@ -0,0 +1,83 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Additional code for customizable stack traces. Unstable API, for internal
+# usage only.
+
+const
+  reraisedFromBegin* = -10
+  reraisedFromEnd* = -100
+  maxStackTraceLines* = 128
+
+when defined(nimStackTraceOverride):
+  ## Procedure types for overriding the default stack trace.
+  type
+    cuintptr_t* {.importc: "uintptr_t", nodecl.} = uint
+      ## This is the same as the type `uintptr_t` in C.
+
+    StackTraceOverrideGetTracebackProc* = proc (): string {.
+      nimcall, gcsafe, raises: [], tags: [], noinline.}
+    StackTraceOverrideGetProgramCountersProc* = proc (maxLength: cint): seq[cuintptr_t] {.
+      nimcall, gcsafe, raises: [], tags: [], noinline.}
+    StackTraceOverrideGetDebuggingInfoProc* =
+      proc (programCounters: seq[cuintptr_t], maxLength: cint): seq[StackTraceEntry] {.
+        nimcall, gcsafe, raises: [], tags: [], noinline.}
+
+  # Default procedures (not normally used, because people opting in on this
+  # override are supposed to register their own versions).
+  var
+    stackTraceOverrideGetTraceback: StackTraceOverrideGetTracebackProc =
+      proc (): string {.nimcall, gcsafe, raises: [], tags: [], noinline.} =
+        discard
+        #result = "Stack trace override procedure not registered.\n"
+    stackTraceOverrideGetProgramCounters: StackTraceOverrideGetProgramCountersProc =
+      proc (maxLength: cint): seq[cuintptr_t] {.nimcall, gcsafe, raises: [], tags: [], noinline.} =
+        discard
+    stackTraceOverrideGetDebuggingInfo: StackTraceOverrideGetDebuggingInfoProc =
+      proc (programCounters: seq[cuintptr_t], maxLength: cint): seq[StackTraceEntry] {.
+        nimcall, gcsafe, raises: [], tags: [], noinline.} =
+          discard
+
+  # Custom procedure registration.
+  proc registerStackTraceOverride*(overrideProc: StackTraceOverrideGetTracebackProc) =
+    ## Override the default stack trace inside rawWriteStackTrace() with your
+    ## own procedure.
+    stackTraceOverrideGetTraceback = overrideProc
+  proc registerStackTraceOverrideGetProgramCounters*(overrideProc: StackTraceOverrideGetProgramCountersProc) =
+    stackTraceOverrideGetProgramCounters = overrideProc
+  proc registerStackTraceOverrideGetDebuggingInfo*(overrideProc: StackTraceOverrideGetDebuggingInfoProc) =
+    stackTraceOverrideGetDebuggingInfo = overrideProc
+
+  # Custom stack trace manipulation.
+  proc auxWriteStackTraceWithOverride*(s: var string) =
+    add(s, stackTraceOverrideGetTraceback())
+
+  proc auxWriteStackTraceWithOverride*(s: var seq[StackTraceEntry]) =
+    let programCounters = stackTraceOverrideGetProgramCounters(maxStackTraceLines)
+    if s.len == 0:
+      s = newSeqOfCap[StackTraceEntry](programCounters.len)
+    for programCounter in programCounters:
+      s.add(StackTraceEntry(programCounter: cast[uint](programCounter)))
+
+  # We may have more stack trace lines in the output, due to inlined procedures.
+  proc addDebuggingInfo*(s: seq[StackTraceEntry]): seq[StackTraceEntry] =
+    var programCounters: seq[cuintptr_t]
+    # We process program counters in groups from complete stack traces, because
+    # we have logic that keeps track of certain functions being inlined or not.
+    for entry in s:
+      if entry.procname.isNil and entry.programCounter != 0:
+        programCounters.add(cast[cuintptr_t](entry.programCounter))
+      elif entry.procname.isNil and (entry.line == reraisedFromBegin or entry.line == reraisedFromEnd):
+        result.add(stackTraceOverrideGetDebuggingInfo(programCounters, maxStackTraceLines))
+        programCounters = @[]
+        result.add(entry)
+      else:
+        result.add(entry)
+    if programCounters.len > 0:
+      result.add(stackTraceOverrideGetDebuggingInfo(programCounters, maxStackTraceLines))
diff --git a/lib/system/strmantle.nim b/lib/system/strmantle.nim
new file mode 100644
index 000000000..89046253b
--- /dev/null
+++ b/lib/system/strmantle.nim
@@ -0,0 +1,263 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2018 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Compilerprocs for strings that do not depend on the string implementation.
+
+import std/private/digitsutils
+
+
+proc cmpStrings(a, b: string): int {.inline, compilerproc.} =
+  let alen = a.len
+  let blen = b.len
+  let minlen = min(alen, blen)
+  if minlen > 0:
+    result = c_memcmp(unsafeAddr a[0], unsafeAddr b[0], cast[csize_t](minlen)).int
+    if result == 0:
+      result = alen - blen
+  else:
+    result = alen - blen
+
+proc leStrings(a, b: string): bool {.inline, compilerproc.} =
+  # required by upcoming backends (NIR).
+  cmpStrings(a, b) <= 0
+
+proc ltStrings(a, b: string): bool {.inline, compilerproc.} =
+  # required by upcoming backends (NIR).
+  cmpStrings(a, b) < 0
+
+proc eqStrings(a, b: string): bool {.inline, compilerproc.} =
+  let alen = a.len
+  let blen = b.len
+  if alen == blen:
+    if alen == 0: return true
+    return equalMem(unsafeAddr(a[0]), unsafeAddr(b[0]), alen)
+
+proc hashString(s: string): int {.compilerproc.} =
+  # the compiler needs exactly the same hash function!
+  # this used to be used for efficient generation of string case statements
+  var h = 0'u
+  for i in 0..len(s)-1:
+    h = h + uint(s[i])
+    h = h + h shl 10
+    h = h xor (h shr 6)
+  h = h + h shl 3
+  h = h xor (h shr 11)
+  h = h + h shl 15
+  result = cast[int](h)
+
+proc eqCstrings(a, b: cstring): bool {.inline, compilerproc.} =
+  if pointer(a) == pointer(b): result = true
+  elif a.isNil or b.isNil: result = false
+  else: result = c_strcmp(a, b) == 0
+
+proc hashCstring(s: cstring): int {.compilerproc.} =
+  # the compiler needs exactly the same hash function!
+  # this used to be used for efficient generation of cstring case statements
+  if s.isNil: return 0
+  var h : uint = 0
+  var i = 0
+  while true:
+    let c = s[i]
+    if c == '\0': break
+    h = h + uint(c)
+    h = h + h shl 10
+    h = h xor (h shr 6)
+    inc i
+  h = h + h shl 3
+  h = h xor (h shr 11)
+  h = h + h shl 15
+  result = cast[int](h)
+
+proc c_strtod(buf: cstring, endptr: ptr cstring): float64 {.
+  importc: "strtod", header: "<stdlib.h>", noSideEffect.}
+
+const
+  IdentChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
+  powtens =  [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+              1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+              1e20, 1e21, 1e22]
+
+
+{.push staticBoundChecks: off.}
+
+proc nimParseBiggestFloat(s: openArray[char], number: var BiggestFloat,
+                         ): int {.compilerproc.} =
+  # This routine attempt to parse float that can parsed quickly.
+  # i.e. whose integer part can fit inside a 53bits integer.
+  # their real exponent must also be <= 22. If the float doesn't follow
+  # these restrictions, transform the float into this form:
+  #  INTEGER * 10 ^ exponent and leave the work to standard `strtod()`.
+  # This avoid the problems of decimal character portability.
+  # see: http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/
+  var
+    i = 0
+    sign = 1.0
+    kdigits, fdigits = 0
+    exponent = 0
+    integer = uint64(0)
+    fracExponent = 0
+    expSign = 1
+    firstDigit = -1
+    hasSign = false
+
+  # Sign?
+  if i < s.len and (s[i] == '+' or s[i] == '-'):
+    hasSign = true
+    if s[i] == '-':
+      sign = -1.0
+    inc(i)
+
+  # NaN?
+  if i+2 < s.len and (s[i] == 'N' or s[i] == 'n'):
+    if s[i+1] == 'A' or s[i+1] == 'a':
+      if s[i+2] == 'N' or s[i+2] == 'n':
+        if i+3 >= s.len or s[i+3] notin IdentChars:
+          number = NaN
+          return i+3
+    return 0
+
+  # Inf?
+  if i+2 < s.len and (s[i] == 'I' or s[i] == 'i'):
+    if s[i+1] == 'N' or s[i+1] == 'n':
+      if s[i+2] == 'F' or s[i+2] == 'f':
+        if i+3 >= s.len or s[i+3] notin IdentChars:
+          number = Inf*sign
+          return i+3
+    return 0
+
+  if i < s.len and s[i] in {'0'..'9'}:
+    firstDigit = (s[i].ord - '0'.ord)
+  # Integer part?
+  while i < s.len and s[i] in {'0'..'9'}:
+    inc(kdigits)
+    integer = integer * 10'u64 + (s[i].ord - '0'.ord).uint64
+    inc(i)
+    while i < s.len and s[i] == '_': inc(i)
+
+  # Fractional part?
+  if i < s.len and s[i] == '.':
+    inc(i)
+    # if no integer part, Skip leading zeros
+    if kdigits <= 0:
+      while i < s.len and s[i] == '0':
+        inc(fracExponent)
+        inc(i)
+        while i < s.len and s[i] == '_': inc(i)
+
+    if firstDigit == -1 and i < s.len and s[i] in {'0'..'9'}:
+      firstDigit = (s[i].ord - '0'.ord)
+    # get fractional part
+    while i < s.len and s[i] in {'0'..'9'}:
+      inc(fdigits)
+      inc(fracExponent)
+      integer = integer * 10'u64 + (s[i].ord - '0'.ord).uint64
+      inc(i)
+      while i < s.len and s[i] == '_': inc(i)
+
+  # if has no digits: return error
+  if kdigits + fdigits <= 0 and
+     (i == 0 or # no char consumed (empty string).
+     (i == 1 and hasSign)): # or only '+' or '-
+    return 0
+
+  if i+1 < s.len and s[i] in {'e', 'E'}:
+    inc(i)
+    if s[i] == '+' or s[i] == '-':
+      if s[i] == '-':
+        expSign = -1
+
+      inc(i)
+    if s[i] notin {'0'..'9'}:
+      return 0
+    while i < s.len and s[i] in {'0'..'9'}:
+      exponent = exponent * 10 + (ord(s[i]) - ord('0'))
+      inc(i)
+      while i < s.len and s[i] == '_': inc(i) # underscores are allowed and ignored
+
+  var realExponent = expSign*exponent - fracExponent
+  let expNegative = realExponent < 0
+  var absExponent = abs(realExponent)
+
+  # if exponent greater than can be represented: +/- zero or infinity
+  if absExponent > 999:
+    if integer == 0:
+      number = 0.0
+    elif expNegative:
+      number = 0.0*sign
+    else:
+      number = Inf*sign
+    return i
+
+  # if integer is representable in 53 bits:  fast path
+  # max fast path integer is  1<<53 - 1 or  8999999999999999 (16 digits)
+  let digits = kdigits + fdigits
+  if digits <= 15 or (digits <= 16 and firstDigit <= 8):
+    # max float power of ten with set bits above the 53th bit is 10^22
+    if absExponent <= 22:
+      if expNegative:
+        number = sign * integer.float / powtens[absExponent]
+      else:
+        number = sign * integer.float * powtens[absExponent]
+      return i
+
+    # if exponent is greater try to fit extra exponent above 22 by multiplying
+    # integer part is there is space left.
+    let slop = 15 - kdigits - fdigits
+    if absExponent <= 22 + slop and not expNegative:
+      number = sign * integer.float * powtens[slop] * powtens[absExponent-slop]
+      return i
+
+  # if failed: slow path with strtod.
+  var t: array[500, char] # flaviu says: 325 is the longest reasonable literal
+  var ti = 0
+  let maxlen = t.high - "e+000".len # reserve enough space for exponent
+
+  let endPos = i
+  result = endPos
+  i = 0
+  # re-parse without error checking, any error should be handled by the code above.
+  if i < endPos and s[i] == '.': i.inc
+  while i < endPos and s[i] in {'0'..'9','+','-'}:
+    if ti < maxlen:
+      t[ti] = s[i]; inc(ti)
+    inc(i)
+    while i < endPos and s[i] in {'.', '_'}: # skip underscore and decimal point
+      inc(i)
+
+  # insert exponent
+  t[ti] = 'E'
+  inc(ti)
+  t[ti] = if expNegative: '-' else: '+'
+  inc(ti, 4)
+
+  # insert adjusted exponent
+  t[ti-1] = ('0'.ord + absExponent mod 10).char
+  absExponent = absExponent div 10
+  t[ti-2] = ('0'.ord + absExponent mod 10).char
+  absExponent = absExponent div 10
+  t[ti-3] = ('0'.ord + absExponent mod 10).char
+  number = c_strtod(cast[cstring](addr t), nil)
+
+{.pop.} # staticBoundChecks
+
+proc nimBoolToStr(x: bool): string {.compilerRtl.} =
+  return if x: "true" else: "false"
+
+proc nimCharToStr(x: char): string {.compilerRtl.} =
+  result = newString(1)
+  result[0] = x
+
+when defined(gcDestructors):
+  proc GC_getStatistics*(): string =
+    result = "[GC] total memory: "
+    result.addInt getTotalMem()
+    result.add "\n[GC] occupied memory: "
+    result.addInt getOccupiedMem()
+    result.add '\n'
+    #"[GC] cycle collections: " & $gch.stat.cycleCollections & "\n" &
diff --git a/lib/system/strs_v2.nim b/lib/system/strs_v2.nim
new file mode 100644
index 000000000..404b4f78d
--- /dev/null
+++ b/lib/system/strs_v2.nim
@@ -0,0 +1,224 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2017 Nim contributors
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Default new string implementation used by Nim's core.
+
+type
+  NimStrPayloadBase = object
+    cap: int
+
+  NimStrPayload {.core.} = object
+    cap: int
+    data: UncheckedArray[char]
+
+  NimStringV2 {.core.} = object
+    len: int
+    p: ptr NimStrPayload ## can be nil if len == 0.
+
+const nimStrVersion {.core.} = 2
+
+template isLiteral(s): bool = (s.p == nil) or (s.p.cap and strlitFlag) == strlitFlag
+
+template contentSize(cap): int = cap + 1 + sizeof(NimStrPayloadBase)
+
+template frees(s) =
+  if not isLiteral(s):
+    when compileOption("threads"):
+      deallocShared(s.p)
+    else:
+      dealloc(s.p)
+
+template allocPayload(newLen: int): ptr NimStrPayload =
+  when compileOption("threads"):
+    cast[ptr NimStrPayload](allocShared(contentSize(newLen)))
+  else:
+    cast[ptr NimStrPayload](alloc(contentSize(newLen)))
+
+template allocPayload0(newLen: int): ptr NimStrPayload =
+  when compileOption("threads"):
+    cast[ptr NimStrPayload](allocShared0(contentSize(newLen)))
+  else:
+    cast[ptr NimStrPayload](alloc0(contentSize(newLen)))
+
+template reallocPayload(p: pointer, newLen: int): ptr NimStrPayload =
+  when compileOption("threads"):
+    cast[ptr NimStrPayload](reallocShared(p, contentSize(newLen)))
+  else:
+    cast[ptr NimStrPayload](realloc(p, contentSize(newLen)))
+
+template reallocPayload0(p: pointer; oldLen, newLen: int): ptr NimStrPayload =
+  when compileOption("threads"):
+    cast[ptr NimStrPayload](reallocShared0(p, contentSize(oldLen), contentSize(newLen)))
+  else:
+    cast[ptr NimStrPayload](realloc0(p, contentSize(oldLen), contentSize(newLen)))
+
+proc resize(old: int): int {.inline.} =
+  if old <= 0: result = 4
+  elif old <= high(int16): result = old * 2
+  else: result = old * 3 div 2 # for large arrays * 3/2 is better
+
+proc prepareAdd(s: var NimStringV2; addLen: int) {.compilerRtl.} =
+  let newLen = s.len + addLen
+  if isLiteral(s):
+    let oldP = s.p
+    # can't mutate a literal, so we need a fresh copy here:
+    s.p = allocPayload(newLen)
+    s.p.cap = newLen
+    if s.len > 0:
+      # we are about to append, so there is no need to copy the \0 terminator:
+      copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], min(s.len, newLen))
+    elif oldP == nil:
+      # In the case of `newString(0) & ""`, since `src.len == 0`, `appendString`
+      # will not set the `\0` terminator, so we set it here.
+      s.p.data[0] = '\0'
+  else:
+    let oldCap = s.p.cap and not strlitFlag
+    if newLen > oldCap:
+      let newCap = max(newLen, resize(oldCap))
+      s.p = reallocPayload(s.p, newCap)
+      s.p.cap = newCap
+      if newLen < newCap:
+        zeroMem(cast[pointer](addr s.p.data[newLen+1]), newCap - newLen)
+
+proc nimAddCharV1(s: var NimStringV2; c: char) {.compilerRtl, inl.} =
+  #if (s.p == nil) or (s.len+1 > s.p.cap and not strlitFlag):
+  prepareAdd(s, 1)
+  s.p.data[s.len] = c
+  inc s.len
+  s.p.data[s.len] = '\0'
+
+proc toNimStr(str: cstring, len: int): NimStringV2 {.compilerproc.} =
+  if len <= 0:
+    result = NimStringV2(len: 0, p: nil)
+  else:
+    var p = allocPayload(len)
+    p.cap = len
+    copyMem(unsafeAddr p.data[0], str, len+1)
+    result = NimStringV2(len: len, p: p)
+
+proc cstrToNimstr(str: cstring): NimStringV2 {.compilerRtl.} =
+  if str == nil: toNimStr(str, 0)
+  else: toNimStr(str, str.len)
+
+proc nimToCStringConv(s: NimStringV2): cstring {.compilerproc, nonReloadable, inline.} =
+  if s.len == 0: result = cstring""
+  else: result = cast[cstring](unsafeAddr s.p.data)
+
+proc appendString(dest: var NimStringV2; src: NimStringV2) {.compilerproc, inline.} =
+  if src.len > 0:
+    # also copy the \0 terminator:
+    copyMem(unsafeAddr dest.p.data[dest.len], unsafeAddr src.p.data[0], src.len+1)
+    inc dest.len, src.len
+
+proc appendChar(dest: var NimStringV2; c: char) {.compilerproc, inline.} =
+  dest.p.data[dest.len] = c
+  inc dest.len
+  dest.p.data[dest.len] = '\0'
+
+proc rawNewString(space: int): NimStringV2 {.compilerproc.} =
+  # this is also 'system.newStringOfCap'.
+  if space <= 0:
+    result = NimStringV2(len: 0, p: nil)
+  else:
+    var p = allocPayload(space)
+    p.cap = space
+    p.data[0] = '\0'
+    result = NimStringV2(len: 0, p: p)
+
+proc mnewString(len: int): NimStringV2 {.compilerproc.} =
+  if len <= 0:
+    result = NimStringV2(len: 0, p: nil)
+  else:
+    var p = allocPayload0(len)
+    p.cap = len
+    result = NimStringV2(len: len, p: p)
+
+proc setLengthStrV2(s: var NimStringV2, newLen: int) {.compilerRtl.} =
+  if newLen == 0:
+    discard "do not free the buffer here, pattern 's.setLen 0' is common for avoiding allocations"
+  else:
+    if isLiteral(s):
+      let oldP = s.p
+      s.p = allocPayload(newLen)
+      s.p.cap = newLen
+      if s.len > 0:
+        copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], min(s.len, newLen))
+        if newLen > s.len:
+          zeroMem(cast[pointer](addr s.p.data[s.len]), newLen - s.len + 1)
+        else:
+          s.p.data[newLen] = '\0'
+      else:
+        zeroMem(cast[pointer](addr s.p.data[0]), newLen + 1)
+    elif newLen > s.len:
+      let oldCap = s.p.cap and not strlitFlag
+      if newLen > oldCap:
+        let newCap = max(newLen, resize(oldCap))
+        s.p = reallocPayload0(s.p, oldCap, newCap)
+        s.p.cap = newCap
+
+    s.p.data[newLen] = '\0'
+  s.len = newLen
+
+proc nimAsgnStrV2(a: var NimStringV2, b: NimStringV2) {.compilerRtl.} =
+  if a.p == b.p and a.len == b.len: return
+  if isLiteral(b):
+    # we can shallow copy literals:
+    frees(a)
+    a.len = b.len
+    a.p = b.p
+  else:
+    if isLiteral(a) or (a.p.cap and not strlitFlag) < b.len:
+      # we have to allocate the 'cap' here, consider
+      # 'let y = newStringOfCap(); var x = y'
+      # on the other hand... These get turned into moves now.
+      frees(a)
+      a.p = allocPayload(b.len)
+      a.p.cap = b.len
+    a.len = b.len
+    copyMem(unsafeAddr a.p.data[0], unsafeAddr b.p.data[0], b.len+1)
+
+proc nimPrepareStrMutationImpl(s: var NimStringV2) =
+  let oldP = s.p
+  # can't mutate a literal, so we need a fresh copy here:
+  s.p = allocPayload(s.len)
+  s.p.cap = s.len
+  copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], s.len+1)
+
+proc nimPrepareStrMutationV2(s: var NimStringV2) {.compilerRtl, inl.} =
+  if s.p != nil and (s.p.cap and strlitFlag) == strlitFlag:
+    nimPrepareStrMutationImpl(s)
+
+proc prepareMutation*(s: var string) {.inline.} =
+  # string literals are "copy on write", so you need to call
+  # `prepareMutation` before modifying the strings via `addr`.
+  {.cast(noSideEffect).}:
+    let s = unsafeAddr s
+    nimPrepareStrMutationV2(cast[ptr NimStringV2](s)[])
+
+proc nimAddStrV1(s: var NimStringV2; src: NimStringV2) {.compilerRtl, inl.} =
+  #if (s.p == nil) or (s.len+1 > s.p.cap and not strlitFlag):
+  prepareAdd(s, src.len)
+  appendString s, src
+
+proc nimDestroyStrV1(s: NimStringV2) {.compilerRtl, inl.} =
+  frees(s)
+
+proc nimStrAtLe(s: string; idx: int; ch: char): bool {.compilerRtl, inl.} =
+  result = idx < s.len and s[idx] <= ch
+
+func capacity*(self: string): int {.inline.} =
+  ## Returns the current capacity of the string.
+  # See https://github.com/nim-lang/RFCs/issues/460
+  runnableExamples:
+    var str = newStringOfCap(cap = 42)
+    str.add "Nim"
+    assert str.capacity == 42
+
+  let str = cast[ptr NimStringV2](unsafeAddr self)
+  result = if str.p != nil: str.p.cap and not strlitFlag else: 0
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
deleted file mode 100755
index 3c99a5eed..000000000
--- a/lib/system/sysio.nim
+++ /dev/null
@@ -1,187 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-
-## Nimrod's standard IO library. It contains high-performance
-## routines for reading and writing data to (buffered) files or
-## TTYs.
-
-{.push debugger:off .} # the user does not want to trace a part
-                       # of the standard library!
-
-
-proc fputs(c: cstring, f: TFile) {.importc: "fputs", noDecl.}
-proc fgets(c: cstring, n: int, f: TFile): cstring {.importc: "fgets", noDecl.}
-proc fgetc(stream: TFile): cint {.importc: "fgetc", nodecl.}
-proc ungetc(c: cint, f: TFile) {.importc: "ungetc", nodecl.}
-proc putc(c: Char, stream: TFile) {.importc: "putc", nodecl.}
-proc fprintf(f: TFile, frmt: CString) {.importc: "fprintf", nodecl, varargs.}
-proc strlen(c: cstring): int {.importc: "strlen", nodecl.}
-
-proc setvbuf(stream: TFile, buf: pointer, typ, size: cint): cint {.
-  importc, nodecl.}
-
-proc write(f: TFile, c: cstring) = fputs(c, f)
-
-var
-  IOFBF {.importc: "_IOFBF", nodecl.}: cint
-  IONBF {.importc: "_IONBF", nodecl.}: cint
-
-proc rawReadLine(f: TFile, result: var string) =
-  # of course this could be optimized a bit; but IO is slow anyway...
-  # and it was difficult to get this CORRECT with Ansi C's methods
-  setLen(result, 0) # reuse the buffer!
-  while True:
-    var c = fgetc(f)
-    if c < 0'i32: break # EOF
-    if c == 10'i32: break # LF
-    if c == 13'i32:  # CR
-      c = fgetc(f) # is the next char LF?
-      if c != 10'i32: ungetc(c, f) # no, put the character back
-      break
-    add result, chr(int(c))
-
-proc readLine(f: TFile): string =
-  result = ""
-  rawReadLine(f, result)
-
-proc write(f: TFile, i: int) = 
-  when sizeof(int) == 8:
-    fprintf(f, "%lld", i)
-  else:
-    fprintf(f, "%ld", i)
-    
-proc write(f: TFile, b: bool) =
-  if b: write(f, "true")
-  else: write(f, "false")
-proc write(f: TFile, r: float) = fprintf(f, "%g", r)
-proc write(f: TFile, c: Char) = putc(c, f)
-proc write(f: TFile, a: openArray[string]) =
-  for x in items(a): write(f, x)
-
-#{.error: "for debugging.".}
-
-proc readFile(filename: string): string =
-  var f: TFile
-  try:
-    if open(f, filename):
-      var len = getFileSize(f)
-      if len < high(int):
-        result = newString(int(len))
-        if readBuffer(f, addr(result[0]), int(len)) != len:
-          result = nil
-      close(f)
-    else:
-      result = nil
-  except EIO:
-    result = nil
-
-proc EndOfFile(f: TFile): bool =
-  # do not blame me; blame the ANSI C standard this is so brain-damaged
-  var c = fgetc(f)
-  ungetc(c, f)
-  return c == -1'i32
-
-proc writeln[Ty](f: TFile, x: Ty) =
-  write(f, x)
-  write(f, "\n")
-
-proc writeln[Ty](f: TFile, x: openArray[Ty]) =
-  for i in items(x): write(f, i)
-  write(f, "\n")
-
-proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x)
-proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n")
-
-# interface to the C procs:
-proc fopen(filename, mode: CString): pointer {.importc: "fopen", noDecl.}
-
-const
-  FormatOpen: array [TFileMode, string] = ["rb", "wb", "w+b", "r+b", "ab"]
-    #"rt", "wt", "w+t", "r+t", "at"
-    # we always use binary here as for Nimrod the OS line ending
-    # should not be translated.
-
-
-proc Open(f: var TFile, filename: string,
-          mode: TFileMode = fmRead,
-          bufSize: int = -1): Bool =
-  var
-    p: pointer
-  p = fopen(filename, FormatOpen[mode])
-  result = (p != nil)
-  f = cast[TFile](p)
-  if bufSize > 0:
-    if setvbuf(f, nil, IOFBF, bufSize) != 0'i32:
-      raise newException(EOutOfMemory, "out of memory")
-  elif bufSize == 0:
-    discard setvbuf(f, nil, IONBF, 0)
-
-proc fdopen(filehandle: TFileHandle, mode: cstring): TFile {.
-  importc: pccHack & "fdopen", header: "<stdio.h>".}
-
-proc open(f: var TFile, filehandle: TFileHandle, mode: TFileMode): bool =
-  f = fdopen(filehandle, FormatOpen[mode])
-  result = f != nil
-
-proc OpenFile(f: var TFile, filename: string,
-              mode: TFileMode = fmRead,
-              bufSize: int = -1): Bool =
-  result = open(f, filename, mode, bufSize)
-  
-proc openFile(f: var TFile, filehandle: TFileHandle, mode: TFileMode): bool =
-  result = open(f, filehandle, mode)
-
-# C routine that is used here:
-proc fread(buf: Pointer, size, n: int, f: TFile): int {.
-  importc: "fread", noDecl.}
-proc fseek(f: TFile, offset: clong, whence: int): int {.
-  importc: "fseek", noDecl.}
-proc ftell(f: TFile): int {.importc: "ftell", noDecl.}
-
-proc fwrite(buf: Pointer, size, n: int, f: TFile): int {.
-  importc: "fwrite", noDecl.}
-
-proc readBuffer(f: TFile, buffer: pointer, len: int): int =
-  result = fread(buffer, 1, len, f)
-
-proc ReadBytes(f: TFile, a: var openarray[byte], start, len: int): int =
-  result = readBuffer(f, addr(a[start]), len)
-
-proc ReadChars(f: TFile, a: var openarray[char], start, len: int): int =
-  result = readBuffer(f, addr(a[start]), len)
-
-proc writeBytes(f: TFile, a: openarray[byte], start, len: int): int =
-  var x = cast[ptr array[0..1000_000_000, byte]](a)
-  result = writeBuffer(f, addr(x[start]), len)
-proc writeChars(f: TFile, a: openarray[char], start, len: int): int =
-  var x = cast[ptr array[0..1000_000_000, byte]](a)
-  result = writeBuffer(f, addr(x[start]), len)
-proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
-  result = fwrite(buffer, 1, len, f)
-
-proc write(f: TFile, s: string) =
-  if writeBuffer(f, cstring(s), s.len) != s.len:
-    raise newException(EIO, "cannot write string to file")
-
-proc setFilePos(f: TFile, pos: int64) =
-  if fseek(f, clong(pos), 0) != 0:
-    raise newException(EIO, "cannot set file position")
-
-proc getFilePos(f: TFile): int64 =
-  result = ftell(f)
-  if result < 0: raise newException(EIO, "cannot retrieve file position")
-
-proc getFileSize(f: TFile): int64 =
-  var oldPos = getFilePos(f)
-  discard fseek(f, 0, 2) # seek the end of the file
-  result = getFilePos(f)
-  setFilePos(f, oldPos)
-
-{.pop.}
diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim
index 808941c06..3621c4960 100755..100644
--- a/lib/system/sysstr.nim
+++ b/lib/system/sysstr.nim
@@ -1,7 +1,7 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -15,96 +15,155 @@
 # we don't use refcounts because that's a behaviour
 # the programmer may not want
 
-# implementation:
+
+proc dataPointer(a: PGenericSeq, elemAlign: int): pointer =
+  cast[pointer](cast[int](a) +% align(GenericSeqSize, elemAlign))
+
+proc dataPointer(a: PGenericSeq, elemAlign, elemSize, index: int): pointer =
+  cast[pointer](cast[int](a) +% align(GenericSeqSize, elemAlign) +% (index*%elemSize))
 
 proc resize(old: int): int {.inline.} =
-  if old <= 0: return 4
-  elif old < 65536: return old * 2
-  else: return old * 3 div 2 # for large arrays * 3/2 is better
-
-proc cmpStrings(a, b: NimString): int {.inline, compilerProc.} =
-  if a == b: return 0
-  if a == nil: return -1
-  if b == nil: return 1
-  return c_strcmp(a.data, b.data)
-
-proc eqStrings(a, b: NimString): bool {.inline, compilerProc.} =
-  if a == b: return true
-  if a == nil or b == nil: return false
-  return a.len == b.len and
-    c_memcmp(a.data, b.data, a.len * sizeof(char)) == 0'i32
-
-proc rawNewString(space: int): NimString {.compilerProc.} =
-  var s = space
-  if s < 8: s = 7
-  result = cast[NimString](newObj(addr(strDesc), sizeof(TGenericSeq) +
-                           (s+1) * sizeof(char)))
-  result.space = s
-
-proc mnewString(len: int): NimString {.exportc.} =
-  #c_fprintf(c_stdout, "[NEWSTRING] len: %ld\n", len)
-  result = rawNewString(len)
+  if old <= 0: result = 4
+  elif old < 65536: result = old * 2
+  else: result = old * 3 div 2 # for large arrays * 3/2 is better
+
+when declared(allocAtomic):
+  template allocStr(size: untyped): untyped =
+    cast[NimString](allocAtomic(size))
+
+  template allocStrNoInit(size: untyped): untyped =
+    cast[NimString](boehmAllocAtomic(size))
+elif defined(gcRegions):
+  template allocStr(size: untyped): untyped =
+    cast[NimString](newStr(addr(strDesc), size, true))
+
+  template allocStrNoInit(size: untyped): untyped =
+    cast[NimString](newStr(addr(strDesc), size, false))
+
+else:
+  template allocStr(size: untyped): untyped =
+    cast[NimString](newObj(addr(strDesc), size))
+
+  template allocStrNoInit(size: untyped): untyped =
+    cast[NimString](newObjNoInit(addr(strDesc), size))
+
+proc rawNewStringNoInit(space: int): NimString =
+  let s = max(space, 7)
+  result = allocStrNoInit(sizeof(TGenericSeq) + s + 1)
+  result.reserved = s
+  when defined(gogc):
+    result.elemSize = 1
+
+proc rawNewString(space: int): NimString {.compilerproc.} =
+  result = rawNewStringNoInit(space)
+  result.len = 0
+  result.data[0] = '\0'
+
+proc mnewString(len: int): NimString {.compilerproc.} =
+  result = rawNewStringNoInit(len)
   result.len = len
+  zeroMem(addr result.data[0], len + 1)
 
-proc toNimStr(str: CString, len: int): NimString {.compilerProc.} =
-  result = rawNewString(len)
+proc copyStrLast(s: NimString, start, last: int): NimString {.compilerproc.} =
+  # This is not used by most recent versions of the compiler anymore, but
+  # required for bootstrapping purposes.
+  let start = max(start, 0)
+  if s == nil: return nil
+  let len = min(last, s.len-1) - start + 1
+  result = rawNewStringNoInit(len)
   result.len = len
-  c_memcpy(result.data, str, (len+1) * sizeof(Char))
-  result.data[len] = '\0' # readline relies on this!
-
-proc cstrToNimstr(str: CString): NimString {.compilerProc.} =
-  return toNimstr(str, c_strlen(str))
-
-proc copyString(src: NimString): NimString {.compilerProc.} =
-  if src == nil: return nil
-  result = rawNewString(src.space)
-  result.len = src.len
-  c_memcpy(result.data, src.data, (src.len + 1) * sizeof(Char))
-
-proc hashString(s: string): int {.compilerproc.} =
-  # the compiler needs exactly the same hash function!
-  # this used to be used for efficient generation of string case statements
-  var h = 0
-  for i in 0..Len(s)-1:
-    h = h +% Ord(s[i])
-    h = h +% h shl 10
-    h = h xor (h shr 6)
-  h = h +% h shl 3
-  h = h xor (h shr 11)
-  h = h +% h shl 15
-  result = h
-
-proc copyStrLast(s: NimString, start, last: int): NimString {.exportc.} =
-  var start = max(start, 0)
-  var len = min(last, s.len-1) - start + 1
-  if len > 0:
-    result = rawNewString(len)
-    result.len = len
-    c_memcpy(result.data, addr(s.data[start]), len * sizeof(Char))
-    result.data[len] = '\0'
-  else:
-    result = mnewString(0)
+  copyMem(addr(result.data), addr(s.data[start]), len)
+  result.data[len] = '\0'
 
-proc copyStr(s: NimString, start: int): NimString {.exportc.} =
-  return copyStrLast(s, start, s.len-1)
+proc copyStr(s: NimString, start: int): NimString {.compilerproc.} =
+  # This is not used by most recent versions of the compiler anymore, but
+  # required for bootstrapping purposes.
+  if s == nil: return nil
+  result = copyStrLast(s, start, s.len-1)
 
-proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
-  result = s
-  if result.len >= result.space:
-    result.space = resize(result.space)
-    result = cast[NimString](growObj(result,
-      sizeof(TGenericSeq) + (result.space+1) * sizeof(char)))
-    #var space = resize(result.space)
-    #result = rawNewString(space)
-    #copyMem(result, s, s.len * sizeof(char) + sizeof(TGenericSeq))
-    #result.space = space
+proc nimToCStringConv(s: NimString): cstring {.compilerproc, nonReloadable, inline.} =
+  if s == nil or s.len == 0: result = cstring""
+  else: result = cast[cstring](addr s.data)
+
+proc toNimStr(str: cstring, len: int): NimString {.compilerproc.} =
+  result = rawNewStringNoInit(len)
+  result.len = len
+  copyMem(addr(result.data), str, len)
+  result.data[len] = '\0'
+
+proc cstrToNimstr(str: cstring): NimString {.compilerRtl.} =
+  if str == nil: NimString(nil)
+  else: toNimStr(str, str.len)
+
+proc copyString(src: NimString): NimString {.compilerRtl.} =
+  if src != nil:
+    if (src.reserved and seqShallowFlag) != 0:
+      result = src
+    else:
+      result = rawNewStringNoInit(src.len)
+      result.len = src.len
+      copyMem(addr(result.data), addr(src.data), src.len + 1)
+      sysAssert((seqShallowFlag and result.reserved) == 0, "copyString")
+      when defined(nimShallowStrings):
+        if (src.reserved and strlitFlag) != 0:
+          result.reserved = (result.reserved and not strlitFlag) or seqShallowFlag
+
+proc newOwnedString(src: NimString; n: int): NimString =
+  result = rawNewStringNoInit(n)
+  result.len = n
+  copyMem(addr(result.data), addr(src.data), n)
+  result.data[n] = '\0'
+
+proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
+  if src != nil:
+    if (src.reserved and seqShallowFlag) != 0:
+      result = src
+      when declared(incRef):
+        incRef(usrToCell(result))
+    else:
+      when declared(newObjRC1) and not defined(gcRegions):
+        var s = src.len
+        if s < 7: s = 7
+        result = cast[NimString](newObjRC1(addr(strDesc), sizeof(TGenericSeq) +
+                                s+1))
+        result.reserved = s
+        when defined(gogc):
+          result.elemSize = 1
+      else:
+        result = rawNewStringNoInit(src.len)
+      result.len = src.len
+      copyMem(addr(result.data), addr(src.data), src.len + 1)
+      sysAssert((seqShallowFlag and result.reserved) == 0, "copyStringRC1")
+      when defined(nimShallowStrings):
+        if (src.reserved and strlitFlag) != 0:
+          result.reserved = (result.reserved and not strlitFlag) or seqShallowFlag
+
+proc copyDeepString(src: NimString): NimString {.inline.} =
+  if src != nil:
+    result = rawNewStringNoInit(src.len)
+    result.len = src.len
+    copyMem(addr(result.data), addr(src.data), src.len + 1)
+
+proc addChar(s: NimString, c: char): NimString =
+  # is compilerproc!
+  if s == nil:
+    result = rawNewStringNoInit(1)
+    result.len = 0
+  else:
+    result = s
+    if result.len >= result.space:
+      let r = resize(result.space)
+      result = rawNewStringNoInit(r)
+      result.len = s.len
+      copyMem(addr result.data[0], unsafeAddr(s.data[0]), s.len+1)
+      result.reserved = r
   result.data[result.len] = c
   result.data[result.len+1] = '\0'
   inc(result.len)
 
 # These routines should be used like following:
-#   <Nimrod code>
-#   s &= "hallo " & name & " how do you feel?"
+#   <Nim code>
+#   s &= "Hello " & name & ", how do you feel?"
 #
 #   <generated C code>
 #   {
@@ -114,8 +173,8 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
 #     appendString(s, strLit3);
 #   }
 #
-#   <Nimrod code>
-#   s = "hallo " & name & " how do you feel?"
+#   <Nim code>
+#   s = "Hello " & name & ", how do you feel?"
 #
 #   <generated C code>
 #   {
@@ -127,163 +186,178 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
 #     s = tmp0;
 #   }
 #
-#   <Nimrod code>
+#   <Nim code>
 #   s = ""
 #
 #   <generated C code>
 #   s = rawNewString(0);
 
-proc resizeString(dest: NimString, addlen: int): NimString {.compilerproc.} =
-  if dest.len + addLen + 1 <= dest.space: # BUGFIX: this is horrible!
+proc resizeString(dest: NimString, addlen: int): NimString {.compilerRtl.} =
+  if dest == nil:
+    result = rawNewString(addlen)
+  elif dest.len + addlen <= dest.space:
     result = dest
   else: # slow path:
-    var sp = max(resize(dest.space), dest.len + addLen + 1)
-    result = cast[NimString](growObj(dest, sizeof(TGenericSeq) +
-                           (sp+1) * sizeof(Char)))
-    result.space = sp
+    let sp = max(resize(dest.space), dest.len + addlen)
+    result = rawNewStringNoInit(sp)
+    result.len = dest.len
+    copyMem(addr result.data[0], unsafeAddr(dest.data[0]), dest.len+1)
+    result.reserved = sp
     #result = rawNewString(sp)
-    #copyMem(result, dest, dest.len * sizeof(char) + sizeof(TGenericSeq))
+    #copyMem(result, dest, dest.len + sizeof(TGenericSeq))
     # DO NOT UPDATE LEN YET: dest.len = newLen
 
 proc appendString(dest, src: NimString) {.compilerproc, inline.} =
-  c_memcpy(addr(dest.data[dest.len]), src.data, (src.len + 1) * sizeof(Char))
-  inc(dest.len, src.len)
+  if src != nil:
+    copyMem(addr(dest.data[dest.len]), addr(src.data), src.len + 1)
+    inc(dest.len, src.len)
 
 proc appendChar(dest: NimString, c: char) {.compilerproc, inline.} =
   dest.data[dest.len] = c
   dest.data[dest.len+1] = '\0'
   inc(dest.len)
 
-proc setLengthStr(s: NimString, newLen: int): NimString {.compilerProc.} =
-  var n = max(newLen, 0)
-  if n <= s.space:
+proc setLengthStr(s: NimString, newLen: int): NimString {.compilerRtl.} =
+  let n = max(newLen, 0)
+  if s == nil:
+    if n == 0:
+      return s
+    else:
+      result = mnewString(n)
+  elif n <= s.space:
     result = s
   else:
-    result = resizeString(s, n)
+    let sp = max(resize(s.space), n)
+    result = rawNewStringNoInit(sp)
+    result.len = s.len
+    copyMem(addr result.data[0], unsafeAddr(s.data[0]), s.len)
+    zeroMem(addr result.data[s.len], n - s.len)
+    result.reserved = sp
   result.len = n
   result.data[n] = '\0'
 
 # ----------------- sequences ----------------------------------------------
 
-proc incrSeq(seq: PGenericSeq, elemSize: int): PGenericSeq {.compilerProc.} =
+proc incrSeq(seq: PGenericSeq, elemSize, elemAlign: int): PGenericSeq {.compilerproc.} =
   # increments the length by one:
   # this is needed for supporting ``add``;
   #
   #  add(seq, x)  generates:
   #  seq = incrSeq(seq, sizeof(x));
   #  seq[seq->len-1] = x;
-  when false:
-    # broken version:
-    result = seq
-    if result.len >= result.space:
-      var s = resize(result.space)
-      result = cast[PGenericSeq](newSeq(extGetCellType(seq), s))
-      genericSeqAssign(result, seq, XXX)
-      #copyMem(result, seq, seq.len * elemSize + GenericSeqSize)
-    inc(result.len)  
-  else:  
-    result = seq
-    if result.len >= result.space:
-      result.space = resize(result.space)
-      result = cast[PGenericSeq](growObj(result, elemSize * result.space +
-                                 GenericSeqSize))
-      # set new elements to zero:
-      #var s = cast[TAddress](result)
-      #zeroMem(cast[pointer](s + GenericSeqSize + (result.len * elemSize)),
-      #  (result.space - result.len) * elemSize)
-      # for i in len .. space-1:
-      #   seq->data[i] = 0
-    inc(result.len)
-
-proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
-    compilerProc.} =
-  when false:
-    # broken version:
-    result = seq
-    if result.space < newLen:
-      var s = max(resize(result.space), newLen)
-      result = cast[PGenericSeq](newSeq(extGetCellType(seq), s))
-    result.len = newLen
+  result = seq
+  if result.len >= result.space:
+    let r = resize(result.space)
+    result = cast[PGenericSeq](growObj(result, align(GenericSeqSize, elemAlign) + elemSize * r))
+    result.reserved = r
+  inc(result.len)
+
+proc incrSeqV2(seq: PGenericSeq, elemSize, elemAlign: int): PGenericSeq {.compilerproc.} =
+  # incrSeq version 2
+  result = seq
+  if result.len >= result.space:
+    let r = resize(result.space)
+    result = cast[PGenericSeq](growObj(result, align(GenericSeqSize, elemAlign) + elemSize * r))
+    result.reserved = r
+
+proc incrSeqV3(s: PGenericSeq, typ: PNimType): PGenericSeq {.compilerproc.} =
+  if s == nil:
+    result = cast[PGenericSeq](newSeq(typ, 1))
+    result.len = 0
   else:
-    result = seq
-    if result.space < newLen:
-      result.space = max(resize(result.space), newLen)
-      result = cast[PGenericSeq](growObj(result, elemSize * result.space +
-                                 GenericSeqSize))
-    elif newLen < result.len:
-      # we need to decref here, otherwise the GC leaks!
-      when not defined(boehmGC) and not defined(nogc):
+    result = s
+    if result.len >= result.space:
+      let r = resize(result.space)
+      result = cast[PGenericSeq](newSeq(typ, r))
+      result.len = s.len
+      copyMem(dataPointer(result, typ.base.align), dataPointer(s, typ.base.align), s.len * typ.base.size)
+      # since we steal the content from 's', it's crucial to set s's len to 0.
+      s.len = 0
+
+proc setLengthSeq(seq: PGenericSeq, elemSize, elemAlign, newLen: int): PGenericSeq {.
+    compilerRtl, inl.} =
+  result = seq
+  if result.space < newLen:
+    let r = max(resize(result.space), newLen)
+    result = cast[PGenericSeq](growObj(result, align(GenericSeqSize, elemAlign) + elemSize * r))
+    result.reserved = r
+  elif newLen < result.len:
+    # we need to decref here, otherwise the GC leaks!
+    when not defined(boehmGC) and not defined(nogc) and
+         not defined(gcMarkAndSweep) and not defined(gogc) and
+         not defined(gcRegions):
+      if ntfNoRefs notin extGetCellType(result).base.flags:
         for i in newLen..result.len-1:
-          forAllChildrenAux(cast[pointer](cast[TAddress](result) +% 
-                            GenericSeqSize +% (i*%elemSize)),
+          forAllChildrenAux(dataPointer(result, elemAlign, elemSize, i),
                             extGetCellType(result).base, waZctDecRef)
-      # and set the memory to nil:
-      zeroMem(cast[pointer](cast[TAddress](result) +% GenericSeqSize +%
-             (newLen*%elemSize)), (result.len-%newLen) *% elemSize)
-    result.len = newLen
 
-# --------------- other string routines ----------------------------------
-proc nimIntToStr(x: int): string {.compilerproc.} =
-  result = newString(sizeof(x)*4)
-  var i = 0
-  var y = x
-  while True:
-    var d = y div 10
-    result[i] = chr(abs(int(y - d*10)) + ord('0'))
-    inc(i)
-    y = d
-    if y == 0: break
-  if x < 0:
-    result[i] = '-'
-    inc(i)
-  setLen(result, i)
-  # mirror the string:
-  for j in 0..i div 2 - 1:
-    swap(result[j], result[i-j-1])
-
-proc nimFloatToStr(x: float): string {.compilerproc.} =
-  var buf: array [0..59, char]
-  c_sprintf(buf, "%#g", x)
-  return $buf
-
-proc nimInt64ToStr(x: int64): string {.compilerproc.} =
-  # we don't rely on C's runtime here as some C compiler's
-  # int64 support is weak
-  result = newString(sizeof(x)*4)
-  var i = 0
-  var y = x
-  while True:
-    var d = y div 10
-    result[i] = chr(abs(int(y - d*10)) + ord('0'))
-    inc(i)
-    y = d
-    if y == 0: break
-  if x < 0:
-    result[i] = '-'
-    inc(i)
-  setLen(result, i)
-  # mirror the string:
-  for j in 0..i div 2 - 1:
-    swap(result[j], result[i-j-1])
-
-proc nimBoolToStr(x: bool): string {.compilerproc.} =
-  return if x: "true" else: "false"
-
-proc nimCharToStr(x: char): string {.compilerproc.} =
-  result = newString(1)
-  result[0] = x
-
-proc binaryStrSearch(x: openarray[string], y: string): int {.compilerproc.} =
-  var
-    a = 0
-    b = len(x)
-  while a < b:
-     var mid = (a + b) div 2
-     if x[mid] < y:
-       a = mid + 1
-     else:
-       b = mid
-  if (a < len(x)) and (x[a] == y):
-    return a
+    # XXX: zeroing out the memory can still result in crashes if a wiped-out
+    # cell is aliased by another pointer (ie proc parameter or a let variable).
+    # This is a tough problem, because even if we don't zeroMem here, in the
+    # presence of user defined destructors, the user will expect the cell to be
+    # "destroyed" thus creating the same problem. We can destroy the cell in the
+    # finalizer of the sequence, but this makes destruction non-deterministic.
+    zeroMem(dataPointer(result, elemAlign, elemSize, newLen), (result.len-%newLen) *% elemSize)
+  result.len = newLen
+
+proc setLengthSeqV2(s: PGenericSeq, typ: PNimType, newLen: int): PGenericSeq {.
+    compilerRtl.} =
+  sysAssert typ.kind == tySequence, "setLengthSeqV2: type is not a seq"
+  if s == nil:
+    if newLen == 0:
+      result = s
+    else:
+      result = cast[PGenericSeq](newSeq(typ, newLen))
   else:
-    return -1
+    let elemSize = typ.base.size
+    let elemAlign = typ.base.align
+    if s.space < newLen:
+      let r = max(resize(s.space), newLen)
+      result = cast[PGenericSeq](newSeq(typ, r))
+      copyMem(dataPointer(result, elemAlign), dataPointer(s, elemAlign), s.len * elemSize)
+      # since we steal the content from 's', it's crucial to set s's len to 0.
+      s.len = 0
+    elif newLen < s.len:
+      result = s
+      # we need to decref here, otherwise the GC leaks!
+      when not defined(boehmGC) and not defined(nogc) and
+          not defined(gcMarkAndSweep) and not defined(gogc) and
+          not defined(gcRegions):
+        if ntfNoRefs notin typ.base.flags:
+          for i in newLen..result.len-1:
+            forAllChildrenAux(dataPointer(result, elemAlign, elemSize, i),
+                              extGetCellType(result).base, waZctDecRef)
+
+      # XXX: zeroing out the memory can still result in crashes if a wiped-out
+      # cell is aliased by another pointer (ie proc parameter or a let variable).
+      # This is a tough problem, because even if we don't zeroMem here, in the
+      # presence of user defined destructors, the user will expect the cell to be
+      # "destroyed" thus creating the same problem. We can destroy the cell in the
+      # finalizer of the sequence, but this makes destruction non-deterministic.
+      zeroMem(dataPointer(result, elemAlign, elemSize, newLen), (result.len-%newLen) *% elemSize)
+    else:
+      result = s
+      zeroMem(dataPointer(result, elemAlign, elemSize, result.len), (newLen-%result.len) *% elemSize)
+    result.len = newLen
+
+func capacity*(self: string): int {.inline.} =
+  ## Returns the current capacity of the string.
+  # See https://github.com/nim-lang/RFCs/issues/460
+  runnableExamples:
+    var str = newStringOfCap(cap = 42)
+    str.add "Nim"
+    assert str.capacity == 42
+
+  let str = cast[NimString](self)
+  result = if str != nil: str.space else: 0
+
+func capacity*[T](self: seq[T]): int {.inline.} =
+  ## Returns the current capacity of the seq.
+  # See https://github.com/nim-lang/RFCs/issues/460
+  runnableExamples:
+    var lst = newSeqOfCap[string](cap = 42)
+    lst.add "Nim"
+    assert lst.capacity == 42
+
+  let sek = cast[PGenericSeq](self)
+  result = if sek != nil: sek.space else: 0
diff --git a/lib/system/threadids.nim b/lib/system/threadids.nim
new file mode 100644
index 000000000..3a6eadcbb
--- /dev/null
+++ b/lib/system/threadids.nim
@@ -0,0 +1,103 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2020 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# we need to cache current threadId to not perform syscall all the time
+var threadId {.threadvar.}: int
+
+when defined(windows):
+  proc getCurrentThreadId(): int32 {.
+    stdcall, dynlib: "kernel32", importc: "GetCurrentThreadId".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(getCurrentThreadId())
+    result = threadId
+
+elif defined(linux):
+  proc syscall(arg: clong): clong {.varargs, importc: "syscall", header: "<unistd.h>".}
+  when defined(amd64):
+    const NR_gettid = clong(186)
+  else:
+    var NR_gettid {.importc: "__NR_gettid", header: "<sys/syscall.h>".}: clong
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(syscall(NR_gettid))
+    result = threadId
+
+elif defined(dragonfly):
+  proc lwp_gettid(): int32 {.importc, header: "unistd.h".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(lwp_gettid())
+    result = threadId
+
+elif defined(openbsd):
+  proc getthrid(): int32 {.importc: "getthrid", header: "<unistd.h>".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(getthrid())
+    result = threadId
+
+elif defined(netbsd):
+  proc lwp_self(): int32 {.importc: "_lwp_self", header: "<lwp.h>".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(lwp_self())
+    result = threadId
+
+elif defined(freebsd):
+  proc syscall(arg: cint, arg0: ptr cint): cint {.varargs, importc: "syscall", header: "<unistd.h>".}
+  var SYS_thr_self {.importc:"SYS_thr_self", header:"<sys/syscall.h>".}: cint
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    var tid = 0.cint
+    if threadId == 0:
+      discard syscall(SYS_thr_self, addr tid)
+      threadId = tid
+    result = threadId
+
+elif defined(macosx):
+  proc syscall(arg: cint): cint {.varargs, importc: "syscall", header: "<unistd.h>".}
+  var SYS_thread_selfid {.importc:"SYS_thread_selfid", header:"<sys/syscall.h>".}: cint
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(syscall(SYS_thread_selfid))
+    result = threadId
+
+elif defined(solaris):
+  type thread_t {.importc: "thread_t", header: "<thread.h>".} = distinct int
+  proc thr_self(): thread_t {.importc, header: "<thread.h>".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(thr_self())
+    result = threadId
+
+elif defined(haiku):
+  type thr_id {.importc: "thread_id", header: "<OS.h>".} = distinct int32
+  proc find_thread(name: cstring): thr_id {.importc, header: "<OS.h>".}
+
+  proc getThreadId*(): int =
+    ## Gets the ID of the currently running thread.
+    if threadId == 0:
+      threadId = int(find_thread(nil))
+    result = threadId
diff --git a/lib/system/threadimpl.nim b/lib/system/threadimpl.nim
new file mode 100644
index 000000000..285b8f5e7
--- /dev/null
+++ b/lib/system/threadimpl.nim
@@ -0,0 +1,111 @@
+var
+  nimThreadDestructionHandlers* {.rtlThreadVar.}: seq[proc () {.closure, gcsafe, raises: [].}]
+when not defined(boehmgc) and not hasSharedHeap and not defined(gogc) and not defined(gcRegions):
+  proc deallocOsPages() {.rtl, raises: [].}
+proc threadTrouble() {.raises: [], gcsafe.}
+# create for the main thread. Note: do not insert this data into the list
+# of all threads; it's not to be stopped etc.
+when not defined(useNimRtl):
+  #when not defined(createNimRtl): initStackBottom()
+  when declared(initGC):
+    initGC()
+    when not emulatedThreadVars:
+      type ThreadType {.pure.} = enum
+        None = 0,
+        NimThread = 1,
+        ForeignThread = 2
+      var
+        threadType {.rtlThreadVar.}: ThreadType
+
+      threadType = ThreadType.NimThread
+
+when defined(gcDestructors):
+  proc deallocThreadStorage(p: pointer) = c_free(p)
+else:
+  template deallocThreadStorage(p: pointer) = deallocShared(p)
+
+template afterThreadRuns() =
+  for i in countdown(nimThreadDestructionHandlers.len-1, 0):
+    nimThreadDestructionHandlers[i]()
+
+proc onThreadDestruction*(handler: proc () {.closure, gcsafe, raises: [].}) =
+  ## Registers a *thread local* handler that is called at the thread's
+  ## destruction.
+  ##
+  ## A thread is destructed when the `.thread` proc returns
+  ## normally or when it raises an exception. Note that unhandled exceptions
+  ## in a thread nevertheless cause the whole process to die.
+  nimThreadDestructionHandlers.add handler
+
+when defined(boehmgc):
+  type GCStackBaseProc = proc(sb: pointer, t: pointer) {.noconv.}
+  proc boehmGC_call_with_stack_base(sbp: GCStackBaseProc, p: pointer)
+    {.importc: "GC_call_with_stack_base", boehmGC.}
+  proc boehmGC_register_my_thread(sb: pointer)
+    {.importc: "GC_register_my_thread", boehmGC.}
+  proc boehmGC_unregister_my_thread()
+    {.importc: "GC_unregister_my_thread", boehmGC.}
+
+  proc threadProcWrapDispatch[TArg](sb: pointer, thrd: pointer) {.noconv, raises: [].} =
+    boehmGC_register_my_thread(sb)
+    try:
+      let thrd = cast[ptr Thread[TArg]](thrd)
+      when TArg is void:
+        thrd.dataFn()
+      else:
+        thrd.dataFn(thrd.data)
+    except:
+      threadTrouble()
+    finally:
+      afterThreadRuns()
+    boehmGC_unregister_my_thread()
+else:
+  proc threadProcWrapDispatch[TArg](thrd: ptr Thread[TArg]) {.raises: [].} =
+    try:
+      when TArg is void:
+        thrd.dataFn()
+      else:
+        when defined(nimV2):
+          thrd.dataFn(thrd.data)
+        else:
+          var x: TArg
+          deepCopy(x, thrd.data)
+          thrd.dataFn(x)
+    except:
+      threadTrouble()
+    finally:
+      afterThreadRuns()
+      when hasAllocStack:
+        deallocThreadStorage(thrd.rawStack)
+
+proc threadProcWrapStackFrame[TArg](thrd: ptr Thread[TArg]) {.raises: [].} =
+  when defined(boehmgc):
+    boehmGC_call_with_stack_base(threadProcWrapDispatch[TArg], thrd)
+  elif not defined(nogc) and not defined(gogc) and not defined(gcRegions) and not usesDestructors:
+    var p {.volatile.}: pointer
+    # init the GC for refc/markandsweep
+    nimGC_setStackBottom(addr(p))
+    when declared(initGC):
+      initGC()
+    when declared(threadType):
+      threadType = ThreadType.NimThread
+    threadProcWrapDispatch[TArg](thrd)
+    when declared(deallocOsPages): deallocOsPages()
+  else:
+    threadProcWrapDispatch(thrd)
+
+template nimThreadProcWrapperBody*(closure: untyped): untyped =
+  var thrd = cast[ptr Thread[TArg]](closure)
+  var core = thrd.core
+  when declared(globalsSlot): threadVarSetValue(globalsSlot, thrd.core)
+  threadProcWrapStackFrame(thrd)
+  # Since an unhandled exception terminates the whole process (!), there is
+  # no need for a ``try finally`` here, nor would it be correct: The current
+  # exception is tried to be re-raised by the code-gen after the ``finally``!
+  # However this is doomed to fail, because we already unmapped every heap
+  # page!
+
+  # mark as not running anymore:
+  thrd.core = nil
+  thrd.dataFn = nil
+  deallocThreadStorage(cast[pointer](core))
diff --git a/lib/system/threadlocalstorage.nim b/lib/system/threadlocalstorage.nim
new file mode 100644
index 000000000..e6ad9dca5
--- /dev/null
+++ b/lib/system/threadlocalstorage.nim
@@ -0,0 +1,125 @@
+import std/private/threadtypes
+
+when defined(windows):
+  type
+    ThreadVarSlot = distinct int32
+
+  proc threadVarAlloc(): ThreadVarSlot {.
+    importc: "TlsAlloc", stdcall, header: "<windows.h>".}
+  proc threadVarSetValue(dwTlsIndex: ThreadVarSlot, lpTlsValue: pointer) {.
+    importc: "TlsSetValue", stdcall, header: "<windows.h>".}
+  proc tlsGetValue(dwTlsIndex: ThreadVarSlot): pointer {.
+    importc: "TlsGetValue", stdcall, header: "<windows.h>".}
+
+  proc getLastError(): uint32 {.
+    importc: "GetLastError", stdcall, header: "<windows.h>".}
+  proc setLastError(x: uint32) {.
+    importc: "SetLastError", stdcall, header: "<windows.h>".}
+
+  proc threadVarGetValue(dwTlsIndex: ThreadVarSlot): pointer =
+    let realLastError = getLastError()
+    result = tlsGetValue(dwTlsIndex)
+    setLastError(realLastError)
+
+elif defined(genode):
+  const
+    GenodeHeader = "genode_cpp/threads.h"
+
+  type
+    ThreadVarSlot = int
+
+  proc threadVarAlloc(): ThreadVarSlot = 0
+
+  proc offMainThread(): bool {.
+    importcpp: "Nim::SysThread::offMainThread",
+    header: GenodeHeader.}
+
+  proc threadVarSetValue(value: pointer) {.
+    importcpp: "Nim::SysThread::threadVarSetValue(@)",
+    header: GenodeHeader.}
+
+  proc threadVarGetValue(): pointer {.
+    importcpp: "Nim::SysThread::threadVarGetValue()",
+    header: GenodeHeader.}
+
+  var mainTls: pointer
+
+  proc threadVarSetValue(s: ThreadVarSlot, value: pointer) {.inline.} =
+    if offMainThread():
+      threadVarSetValue(value);
+    else:
+      mainTls = value
+
+  proc threadVarGetValue(s: ThreadVarSlot): pointer {.inline.} =
+    if offMainThread():
+      threadVarGetValue();
+    else:
+      mainTls
+
+else:
+  when not (defined(macosx) or defined(haiku)):
+    {.passl: "-pthread".}
+
+  when not defined(haiku):
+    {.passc: "-pthread".}
+
+  when (defined(linux) or defined(nintendoswitch)) and defined(amd64):
+    type
+      ThreadVarSlot {.importc: "pthread_key_t",
+                    header: "<sys/types.h>".} = distinct cuint
+  elif defined(openbsd) and defined(amd64):
+    type
+      ThreadVarSlot {.importc: "pthread_key_t",
+                     header: "<pthread.h>".} = cint
+  else:
+    type
+      ThreadVarSlot {.importc: "pthread_key_t",
+                     header: "<sys/types.h>".} = object
+
+  proc pthread_getspecific(a1: ThreadVarSlot): pointer {.
+    importc: "pthread_getspecific", header: pthreadh.}
+  proc pthread_key_create(a1: ptr ThreadVarSlot,
+                          destruct: proc (x: pointer) {.noconv.}): int32 {.
+    importc: "pthread_key_create", header: pthreadh.}
+  proc pthread_key_delete(a1: ThreadVarSlot): int32 {.
+    importc: "pthread_key_delete", header: pthreadh.}
+
+  proc pthread_setspecific(a1: ThreadVarSlot, a2: pointer): int32 {.
+    importc: "pthread_setspecific", header: pthreadh.}
+
+  proc threadVarAlloc(): ThreadVarSlot {.inline.} =
+    discard pthread_key_create(addr(result), nil)
+  proc threadVarSetValue(s: ThreadVarSlot, value: pointer) {.inline.} =
+    discard pthread_setspecific(s, value)
+  proc threadVarGetValue(s: ThreadVarSlot): pointer {.inline.} =
+    result = pthread_getspecific(s)
+
+
+when emulatedThreadVars:
+  # the compiler generates this proc for us, so that we can get the size of
+  # the thread local var block; we use this only for sanity checking though
+  proc nimThreadVarsSize(): int {.noconv, importc: "NimThreadVarsSize".}
+
+
+
+when emulatedThreadVars:
+  var globalsSlot: ThreadVarSlot
+
+  when not defined(useNimRtl):
+    var mainThread: GcThread
+
+  proc GetThreadLocalVars(): pointer {.compilerRtl, inl.} =
+    result = addr(cast[PGcThread](threadVarGetValue(globalsSlot)).tls)
+
+  proc initThreadVarsEmulation() {.compilerproc, inline.} =
+    when not defined(useNimRtl):
+      globalsSlot = threadVarAlloc()
+      when declared(mainThread):
+        threadVarSetValue(globalsSlot, addr(mainThread))
+
+when not defined(useNimRtl):
+  when emulatedThreadVars:
+    if nimThreadVarsSize() > sizeof(ThreadLocalStorage):
+      c_fprintf(cstderr, """too large thread local storage size requested,
+use -d:\"nimTlsSize=X\" to setup even more or stop using unittest.nim""")
+      rawQuit 1
diff --git a/lib/system/timers.nim b/lib/system/timers.nim
new file mode 100644
index 000000000..ffb0f7716
--- /dev/null
+++ b/lib/system/timers.nim
@@ -0,0 +1,99 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## Timer support for the realtime GC. Based on
+## `<https://github.com/jckarter/clay/blob/master/compiler/hirestimer.cpp>`_
+
+type
+  Ticks = distinct int64
+  Nanos = int64
+
+when defined(windows):
+
+  proc QueryPerformanceCounter(res: var Ticks) {.
+    importc: "QueryPerformanceCounter", stdcall, dynlib: "kernel32".}
+  proc QueryPerformanceFrequency(res: var int64) {.
+    importc: "QueryPerformanceFrequency", stdcall, dynlib: "kernel32".}
+
+  proc getTicks(): Ticks {.inline.} =
+    QueryPerformanceCounter(result)
+
+  proc `-`(a, b: Ticks): Nanos =
+    var frequency: int64
+    QueryPerformanceFrequency(frequency)
+    var performanceCounterRate = 1e+9'f64 / float64(frequency)
+
+    result = Nanos(float64(a.int64 - b.int64) * performanceCounterRate)
+
+elif defined(macosx) and not defined(emscripten):
+  type
+    MachTimebaseInfoData {.pure, final,
+        importc: "mach_timebase_info_data_t",
+        header: "<mach/mach_time.h>".} = object
+      numer, denom: int32 # note: `uint32` in sources
+
+  proc mach_absolute_time(): uint64 {.importc, header: "<mach/mach_time.h>".}
+  proc mach_timebase_info(info: var MachTimebaseInfoData) {.importc,
+    header: "<mach/mach_time.h>".}
+
+  proc getTicks(): Ticks {.inline.} =
+    result = Ticks(mach_absolute_time())
+
+  var timeBaseInfo: MachTimebaseInfoData
+  mach_timebase_info(timeBaseInfo)
+
+  proc `-`(a, b: Ticks): Nanos =
+    result = (a.int64 - b.int64) * timeBaseInfo.numer div timeBaseInfo.denom
+
+elif defined(posixRealtime):
+  type
+    Clockid {.importc: "clockid_t", header: "<time.h>", final.} = object
+
+    TimeSpec {.importc: "struct timespec", header: "<time.h>",
+               final, pure.} = object ## struct timespec
+      tv_sec: int  ## Seconds.
+      tv_nsec: int ## Nanoseconds.
+
+  var
+    CLOCK_REALTIME {.importc: "CLOCK_REALTIME", header: "<time.h>".}: Clockid
+
+  proc clock_gettime(clkId: Clockid, tp: var Timespec) {.
+    importc: "clock_gettime", header: "<time.h>".}
+
+  proc getTicks(): Ticks =
+    var t: Timespec
+    clock_gettime(CLOCK_REALTIME, t)
+    result = Ticks(int64(t.tv_sec) * 1000000000'i64 + int64(t.tv_nsec))
+
+  proc `-`(a, b: Ticks): Nanos {.borrow.}
+
+else:
+  # fallback Posix implementation:
+  when not declared(Time):
+    when defined(linux):
+      type Time = clong
+    else:
+      type Time = int
+
+  type
+    Timeval {.importc: "struct timeval", header: "<sys/select.h>",
+               final, pure.} = object ## struct timeval
+      tv_sec: Time  ## Seconds.
+      tv_usec: clong ## Microseconds.
+
+  proc posix_gettimeofday(tp: var Timeval, unused: pointer = nil) {.
+    importc: "gettimeofday", header: "<sys/time.h>".}
+
+  proc getTicks(): Ticks =
+    var t: Timeval
+    posix_gettimeofday(t)
+    result = Ticks(int64(t.tv_sec) * 1000_000_000'i64 +
+                    int64(t.tv_usec) * 1000'i64)
+
+  proc `-`(a, b: Ticks): Nanos {.borrow.}
diff --git a/lib/system_overview.rst b/lib/system_overview.rst
new file mode 100644
index 000000000..cc0643bf1
--- /dev/null
+++ b/lib/system_overview.rst
@@ -0,0 +1,177 @@
+.. default-role:: code
+.. include:: ../doc/rstcommon.rst
+
+The System module imports several separate modules, and their documentation
+is in separate files:
+
+* `iterators <iterators.html>`_
+* `exceptions <exceptions.html>`_
+* `assertions <assertions.html>`_
+* `dollars <dollars.html>`_
+* `ctypes <ctypes.html>`_
+
+
+Here is a short overview of the most commonly used functions from the
+`system` module. Function names in the tables below are clickable and
+will take you to the full documentation of the function.
+
+There are many more functions available than the ones listed in this overview.
+Use the table of contents on the left-hand side and/or `Ctrl+F` to navigate
+through this module.
+
+
+Strings and characters
+----------------------
+
+=============================     =======================================
+Proc                              Usage
+=============================     =======================================
+`len(s)<#len,string>`_            Return the length of a string
+`chr(i)<#chr,range[]>`_           Convert an `int` in the range `0..255`
+                                  to a character
+`ord(c)<#ord,T>`_                 Return `int` value of a character
+`a & b<#&,string,string>`_        Concatenate two strings
+`s.add(c)<#add,string,char>`_     Add character to the string
+`$<dollars.html>`_                Convert various types to string
+=============================     =======================================
+
+**See also:**
+* `strutils module <strutils.html>`_ for common string functions
+* `strformat module <strformat.html>`_ for string interpolation and formatting
+* `unicode module <unicode.html>`_ for Unicode UTF-8 handling
+* `strscans <strscans.html>`_ for `scanf` and `scanp` macros, which offer
+  easier substring extraction than regular expressions
+* `strtabs module <strtabs.html>`_ for efficient hash tables
+  (dictionaries, in some programming languages) mapping from strings to strings
+
+
+
+Seqs
+----
+
+=============================================================  ==========================================
+Proc                                                           Usage
+=============================================================  ==========================================
+`newSeq<#newSeq>`_                                             Create a new sequence of a given length
+`newSeqOfCap<#newSeqOfCap,Natural>`_                           Create a new sequence with zero length
+                                                               and a given capacity
+`setLen<#setLen,seq[T],Natural>`_                              Set the length of a sequence
+`len<#len,seq[T]>`_                                            Return the length of a sequence
+`@<#@,openArray[T]>`_                                          Turn an array into a sequence
+`add<#add,seq[T],sinkT>`_                                      Add an item to the sequence
+`insert<#insert,seq[T],sinkT>`_                                Insert an item at a specific position
+`delete<#delete,seq[T],Natural>`_                              Delete an item while preserving the
+                                                               order of elements (`O(n)` operation)
+`del<#del,seq[T],Natural>`_                                    `O(1)` removal, doesn't preserve the order
+`pop<#pop,seq[T]>`_                                            Remove and return last item of a sequence
+`x & y<#&,seq[T],seq[T]>`_                                     Concatenate two sequences
+`x[a .. b]<#[],openArray[T],HSlice[U: Ordinal,V: Ordinal]>`_   Slice of a sequence (both ends included)
+`x[a .. ^b]<#[],openArray[T],HSlice[U: Ordinal,V: Ordinal]>`_  Slice of a sequence but `b` is a 
+                                                               reversed index (both ends included)
+`x[a ..< b]<#[],openArray[T],HSlice[U: Ordinal,V: Ordinal]>`_  Slice of a sequence (excluded upper bound)
+=============================================================  ==========================================
+
+**See also:**
+* `sequtils module <sequtils.html>`_ for operations on container
+  types (including strings)
+* `json module <json.html>`_ for a structure which allows heterogeneous members
+* `lists module <lists.html>`_ for linked lists
+
+
+
+Sets
+----
+
+Built-in bit sets.
+
+===============================     ======================================
+Proc                                Usage
+===============================     ======================================
+`incl<#incl,set[T],T>`_             Include element `y` in the set `x`
+`excl<#excl,set[T],T>`_             Exclude element `y` from the set `x`
+`card<#card,set[T]>`_               Return the cardinality of the set,
+                                    i.e. the number of elements
+`a * b<#*,set[T],set[T]>`_          Intersection
+`a + b<#+,set[T],set[T]>`_          Union
+`a - b<#-,set[T],set[T]>`_          Difference
+`contains<#contains,set[T],T>`_     Check if an element is in the set
+[a < b](#<,set[T],set[T])           Check if `a` is a subset of `b`
+===============================     ======================================
+
+**See also:**
+* `setutils module <setutils.html>`_ for bit set convenience functions
+* `sets module <sets.html>`_ for hash sets
+* `intsets module <intsets.html>`_ for efficient int sets
+
+
+
+Numbers
+-------
+
+==============================    ==================================     =====================
+Proc                              Usage                                  Also known as
+                                                                         (in other languages)
+==============================    ==================================     =====================
+`div<#div,int,int>`_              Integer division                       `//`
+`mod<#mod,int,int>`_              Integer modulo (remainder)             `%`
+`shl<#shl,int,SomeInteger>`_      Shift left                             `<<`
+`shr<#shr,int,SomeInteger>`_      Shift right                            `>>`
+`ashr<#ashr,int,SomeInteger>`_    Arithmetic shift right
+`and<#and,int,int>`_              Bitwise `and`                          `&`
+`or<#or,int,int>`_                Bitwise `or`                           `|`
+`xor<#xor,int,int>`_              Bitwise `xor`                          `^`
+`not<#not,int>`_                  Bitwise `not` (complement)             `~`
+`toInt<#toInt,float>`_            Convert floating-point number
+                                  into an `int`
+`toFloat<#toFloat,int>`_          Convert an integer into a `float`
+==============================    ==================================     =====================
+
+**See also:**
+* `math module <math.html>`_ for mathematical operations like trigonometric
+  functions, logarithms, square and cubic roots, etc.
+* `complex module <complex.html>`_ for operations on complex numbers
+* `rationals module <rationals.html>`_ for rational numbers
+
+
+
+Ordinals
+--------
+
+`Ordinal type <#Ordinal>`_ includes integer, bool, character, and enumeration
+types, as well as their subtypes.
+
+=====================     =======================================
+Proc                      Usage
+=====================     =======================================
+`succ<#succ,T,int>`_      Successor of the value
+`pred<#pred,T,int>`_      Predecessor of the value
+`inc<#inc,T,int>`_        Increment the ordinal
+`dec<#dec,T,int>`_        Decrement the ordinal
+`high<#high,T>`_          Return the highest possible value
+`low<#low,T>`_            Return the lowest possible value
+`ord<#ord,T>`_            Return `int` value of an ordinal value
+=====================     =======================================
+
+
+
+Misc
+----
+
+====================================================  ============================================
+Proc                                                  Usage
+====================================================  ============================================
+`is<#is,T,S>`_                                        Check if two arguments are of the same type
+`isnot<#isnot.t,untyped,untyped>`_                    Negated version of `is`
+`!=<#!%3D.t,untyped,untyped>`_                        Not equals
+`addr<#addr,T>`_                                      Take the address of a memory location
+`T and F<#and,bool,bool>`_                            Boolean `and`
+`T or F<#or,bool,bool>`_                              Boolean `or`
+`T xor F<#xor,bool,bool>`_                            Boolean `xor` (exclusive or)
+`not T<#not,bool>`_                                   Boolean `not`
+`a[^x]<#^.t,int>`_                                    Take the element at the reversed index `x`
+`a .. b<#..,sinkT,sinkU>`_                            Binary slice that constructs an interval
+                                                      `[a, b]`
+`a ..^ b<#..^.t,untyped,untyped>`_                    Interval `[a, b]` but `b` as reversed index
+[a ..< b](#..<.t,untyped,untyped)                     Interval `[a, b)` (excluded upper bound)
+[runnableExamples](#runnableExamples,string,untyped)  Create testable documentation
+====================================================  ============================================
diff --git a/lib/ucmaps/8859-1.txt b/lib/ucmaps/8859-1.txt
deleted file mode 100755
index 473ecabc1..000000000
--- a/lib/ucmaps/8859-1.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-1:1998 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-1:1998 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-1 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-1 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x00A1	#	INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#	CENT SIGN
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x00A5	#	YEN SIGN
-0xA6	0x00A6	#	BROKEN BAR
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x00AA	#	FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x00AF	#	MACRON
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x00B9	#	SUPERSCRIPT ONE
-0xBA	0x00BA	#	MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#	VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#	VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#	INVERTED QUESTION MARK
-0xC0	0x00C0	#	LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#	LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#	LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#	LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x00D0	#	LATIN CAPITAL LETTER ETH (Icelandic)
-0xD1	0x00D1	#	LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#	LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#	LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#	LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x00DE	#	LATIN CAPITAL LETTER THORN (Icelandic)
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S (German)
-0xE0	0x00E0	#	LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#	LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#	LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#	LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x00F0	#	LATIN SMALL LETTER ETH (Icelandic)
-0xF1	0x00F1	#	LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#	LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#	LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#	LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x00FE	#	LATIN SMALL LETTER THORN (Icelandic)
-0xFF	0x00FF	#	LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/lib/ucmaps/8859-10.txt b/lib/ucmaps/8859-10.txt
deleted file mode 100755
index 374a42b1a..000000000
--- a/lib/ucmaps/8859-10.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-10:1998 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.1
-#	Table format:     Format A
-#	Date:             1999 October 11
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-10:1998 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-10 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-10 order.
-#
-#	Version history
-#	1.0 version new.
-#       1.1 corrected mistake in mapping of 0xA4
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x0104	#	LATIN CAPITAL LETTER A WITH OGONEK
-0xA2	0x0112	#	LATIN CAPITAL LETTER E WITH MACRON
-0xA3	0x0122	#	LATIN CAPITAL LETTER G WITH CEDILLA
-0xA4	0x012A	#	LATIN CAPITAL LETTER I WITH MACRON
-0xA5	0x0128	#	LATIN CAPITAL LETTER I WITH TILDE
-0xA6	0x0136	#	LATIN CAPITAL LETTER K WITH CEDILLA
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x013B	#	LATIN CAPITAL LETTER L WITH CEDILLA
-0xA9	0x0110	#	LATIN CAPITAL LETTER D WITH STROKE
-0xAA	0x0160	#	LATIN CAPITAL LETTER S WITH CARON
-0xAB	0x0166	#	LATIN CAPITAL LETTER T WITH STROKE
-0xAC	0x017D	#	LATIN CAPITAL LETTER Z WITH CARON
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x016A	#	LATIN CAPITAL LETTER U WITH MACRON
-0xAF	0x014A	#	LATIN CAPITAL LETTER ENG
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x0105	#	LATIN SMALL LETTER A WITH OGONEK
-0xB2	0x0113	#	LATIN SMALL LETTER E WITH MACRON
-0xB3	0x0123	#	LATIN SMALL LETTER G WITH CEDILLA
-0xB4	0x012B	#	LATIN SMALL LETTER I WITH MACRON
-0xB5	0x0129	#	LATIN SMALL LETTER I WITH TILDE
-0xB6	0x0137	#	LATIN SMALL LETTER K WITH CEDILLA
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x013C	#	LATIN SMALL LETTER L WITH CEDILLA
-0xB9	0x0111	#	LATIN SMALL LETTER D WITH STROKE
-0xBA	0x0161	#	LATIN SMALL LETTER S WITH CARON
-0xBB	0x0167	#	LATIN SMALL LETTER T WITH STROKE
-0xBC	0x017E	#	LATIN SMALL LETTER Z WITH CARON
-0xBD	0x2015	#	HORIZONTAL BAR
-0xBE	0x016B	#	LATIN SMALL LETTER U WITH MACRON
-0xBF	0x014B	#	LATIN SMALL LETTER ENG
-0xC0	0x0100	#	LATIN CAPITAL LETTER A WITH MACRON
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x012E	#	LATIN CAPITAL LETTER I WITH OGONEK
-0xC8	0x010C	#	LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0118	#	LATIN CAPITAL LETTER E WITH OGONEK
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x0116	#	LATIN CAPITAL LETTER E WITH DOT ABOVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x00D0	#	LATIN CAPITAL LETTER ETH (Icelandic)
-0xD1	0x0145	#	LATIN CAPITAL LETTER N WITH CEDILLA
-0xD2	0x014C	#	LATIN CAPITAL LETTER O WITH MACRON
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x0168	#	LATIN CAPITAL LETTER U WITH TILDE
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x0172	#	LATIN CAPITAL LETTER U WITH OGONEK
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#	LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x00DE	#	LATIN CAPITAL LETTER THORN (Icelandic)
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S (German)
-0xE0	0x0101	#	LATIN SMALL LETTER A WITH MACRON
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x012F	#	LATIN SMALL LETTER I WITH OGONEK
-0xE8	0x010D	#	LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x0119	#	LATIN SMALL LETTER E WITH OGONEK
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x0117	#	LATIN SMALL LETTER E WITH DOT ABOVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x00F0	#	LATIN SMALL LETTER ETH (Icelandic)
-0xF1	0x0146	#	LATIN SMALL LETTER N WITH CEDILLA
-0xF2	0x014D	#	LATIN SMALL LETTER O WITH MACRON
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x0169	#	LATIN SMALL LETTER U WITH TILDE
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x0173	#	LATIN SMALL LETTER U WITH OGONEK
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#	LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x00FE	#	LATIN SMALL LETTER THORN (Icelandic)
-0xFF	0x0138	#	LATIN SMALL LETTER KRA
diff --git a/lib/ucmaps/8859-13.txt b/lib/ucmaps/8859-13.txt
deleted file mode 100755
index cd11b53fd..000000000
--- a/lib/ucmaps/8859-13.txt
+++ /dev/null
@@ -1,299 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-13:1998  to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1998 - 1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-13:1998 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-13 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-13 order.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x201D	#	RIGHT DOUBLE QUOTATION MARK
-0xA2	0x00A2	#	CENT SIGN
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x201E	#	DOUBLE LOW-9 QUOTATION MARK
-0xA6	0x00A6	#	BROKEN BAR
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x0156	#	LATIN CAPITAL LETTER R WITH CEDILLA
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x00C6	#	LATIN CAPITAL LETTER AE
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x201C	#	LEFT DOUBLE QUOTATION MARK
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xB9	0x00B9	#	SUPERSCRIPT ONE
-0xBA	0x0157	#	LATIN SMALL LETTER R WITH CEDILLA
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#	VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#	VULGAR FRACTION THREE QUARTERS
-0xBF	0x00E6	#	LATIN SMALL LETTER AE
-0xC0	0x0104	#	LATIN CAPITAL LETTER A WITH OGONEK
-0xC1	0x012E	#	LATIN CAPITAL LETTER I WITH OGONEK
-0xC2	0x0100	#	LATIN CAPITAL LETTER A WITH MACRON
-0xC3	0x0106	#	LATIN CAPITAL LETTER C WITH ACUTE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x0118	#	LATIN CAPITAL LETTER E WITH OGONEK
-0xC7	0x0112	#	LATIN CAPITAL LETTER E WITH MACRON
-0xC8	0x010C	#	LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0179	#	LATIN CAPITAL LETTER Z WITH ACUTE
-0xCB	0x0116	#	LATIN CAPITAL LETTER E WITH DOT ABOVE
-0xCC	0x0122	#	LATIN CAPITAL LETTER G WITH CEDILLA
-0xCD	0x0136	#	LATIN CAPITAL LETTER K WITH CEDILLA
-0xCE	0x012A	#	LATIN CAPITAL LETTER I WITH MACRON
-0xCF	0x013B	#	LATIN CAPITAL LETTER L WITH CEDILLA
-0xD0	0x0160	#	LATIN CAPITAL LETTER S WITH CARON
-0xD1	0x0143	#	LATIN CAPITAL LETTER N WITH ACUTE
-0xD2	0x0145	#	LATIN CAPITAL LETTER N WITH CEDILLA
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x014C	#	LATIN CAPITAL LETTER O WITH MACRON
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x0172	#	LATIN CAPITAL LETTER U WITH OGONEK
-0xD9	0x0141	#	LATIN CAPITAL LETTER L WITH STROKE
-0xDA	0x015A	#	LATIN CAPITAL LETTER S WITH ACUTE
-0xDB	0x016A	#	LATIN CAPITAL LETTER U WITH MACRON
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x017B	#	LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xDE	0x017D	#	LATIN CAPITAL LETTER Z WITH CARON
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S (German)
-0xE0	0x0105	#	LATIN SMALL LETTER A WITH OGONEK
-0xE1	0x012F	#	LATIN SMALL LETTER I WITH OGONEK
-0xE2	0x0101	#	LATIN SMALL LETTER A WITH MACRON
-0xE3	0x0107	#	LATIN SMALL LETTER C WITH ACUTE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x0119	#	LATIN SMALL LETTER E WITH OGONEK
-0xE7	0x0113	#	LATIN SMALL LETTER E WITH MACRON
-0xE8	0x010D	#	LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x017A	#	LATIN SMALL LETTER Z WITH ACUTE
-0xEB	0x0117	#	LATIN SMALL LETTER E WITH DOT ABOVE
-0xEC	0x0123	#	LATIN SMALL LETTER G WITH CEDILLA
-0xED	0x0137	#	LATIN SMALL LETTER K WITH CEDILLA
-0xEE	0x012B	#	LATIN SMALL LETTER I WITH MACRON
-0xEF	0x013C	#	LATIN SMALL LETTER L WITH CEDILLA
-0xF0	0x0161	#	LATIN SMALL LETTER S WITH CARON
-0xF1	0x0144	#	LATIN SMALL LETTER N WITH ACUTE
-0xF2	0x0146	#	LATIN SMALL LETTER N WITH CEDILLA
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x014D	#	LATIN SMALL LETTER O WITH MACRON
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x0173	#	LATIN SMALL LETTER U WITH OGONEK
-0xF9	0x0142	#	LATIN SMALL LETTER L WITH STROKE
-0xFA	0x015B	#	LATIN SMALL LETTER S WITH ACUTE
-0xFB	0x016B	#	LATIN SMALL LETTER U WITH MACRON
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x017C	#	LATIN SMALL LETTER Z WITH DOT ABOVE
-0xFE	0x017E	#	LATIN SMALL LETTER Z WITH CARON
-0xFF	0x2019	#	RIGHT SINGLE QUOTATION MARK
diff --git a/lib/ucmaps/8859-14.txt b/lib/ucmaps/8859-14.txt
deleted file mode 100755
index 36038f413..000000000
--- a/lib/ucmaps/8859-14.txt
+++ /dev/null
@@ -1,301 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-14:1998 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Markus Kuhn <mkuhn@acm.org>
-#			  Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1998 - 1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-14:1998 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-14 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-14 order.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x1E02	#	LATIN CAPITAL LETTER B WITH DOT ABOVE
-0xA2	0x1E03	#	LATIN SMALL LETTER B WITH DOT ABOVE
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x010A	#	LATIN CAPITAL LETTER C WITH DOT ABOVE
-0xA5	0x010B	#	LATIN SMALL LETTER C WITH DOT ABOVE
-0xA6	0x1E0A	#	LATIN CAPITAL LETTER D WITH DOT ABOVE
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x1E80	#	LATIN CAPITAL LETTER W WITH GRAVE
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x1E82	#	LATIN CAPITAL LETTER W WITH ACUTE
-0xAB	0x1E0B	#	LATIN SMALL LETTER D WITH DOT ABOVE
-0xAC	0x1EF2	#	LATIN CAPITAL LETTER Y WITH GRAVE
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x0178	#	LATIN CAPITAL LETTER Y WITH DIAERESIS
-0xB0	0x1E1E	#	LATIN CAPITAL LETTER F WITH DOT ABOVE
-0xB1	0x1E1F	#	LATIN SMALL LETTER F WITH DOT ABOVE
-0xB2	0x0120	#	LATIN CAPITAL LETTER G WITH DOT ABOVE
-0xB3	0x0121	#	LATIN SMALL LETTER G WITH DOT ABOVE
-0xB4	0x1E40	#	LATIN CAPITAL LETTER M WITH DOT ABOVE
-0xB5	0x1E41	#	LATIN SMALL LETTER M WITH DOT ABOVE
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x1E56	#	LATIN CAPITAL LETTER P WITH DOT ABOVE
-0xB8	0x1E81	#	LATIN SMALL LETTER W WITH GRAVE
-0xB9	0x1E57	#	LATIN SMALL LETTER P WITH DOT ABOVE
-0xBA	0x1E83	#	LATIN SMALL LETTER W WITH ACUTE
-0xBB	0x1E60	#	LATIN CAPITAL LETTER S WITH DOT ABOVE
-0xBC	0x1EF3	#	LATIN SMALL LETTER Y WITH GRAVE
-0xBD	0x1E84	#	LATIN CAPITAL LETTER W WITH DIAERESIS
-0xBE	0x1E85	#	LATIN SMALL LETTER W WITH DIAERESIS
-0xBF	0x1E61	#	LATIN SMALL LETTER S WITH DOT ABOVE
-0xC0	0x00C0	#	LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#	LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#	LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#	LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x0174	#	LATIN CAPITAL LETTER W WITH CIRCUMFLEX
-0xD1	0x00D1	#	LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#	LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x1E6A	#	LATIN CAPITAL LETTER T WITH DOT ABOVE
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#	LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#	LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x0176	#	LATIN CAPITAL LETTER Y WITH CIRCUMFLEX
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#	LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#	LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#	LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#	LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x0175	#	LATIN SMALL LETTER W WITH CIRCUMFLEX
-0xF1	0x00F1	#	LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#	LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x1E6B	#	LATIN SMALL LETTER T WITH DOT ABOVE
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#	LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#	LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x0177	#	LATIN SMALL LETTER Y WITH CIRCUMFLEX
-0xFF	0x00FF	#	LATIN SMALL LETTER Y WITH DIAERESIS
-
diff --git a/lib/ucmaps/8859-15.txt b/lib/ucmaps/8859-15.txt
deleted file mode 100755
index 1e319707d..000000000
--- a/lib/ucmaps/8859-15.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-15:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Markus Kuhn <mkuhn@acm.org>
-#			  Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1998 - 1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-15:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-15 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-15 order.
-#
-#	Version history
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x00A1	#	INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#	CENT SIGN
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x20AC	#	EURO SIGN
-0xA5	0x00A5	#	YEN SIGN
-0xA6	0x0160	#	LATIN CAPITAL LETTER S WITH CARON
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x0161	#	LATIN SMALL LETTER S WITH CARON
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x00AA	#	FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x00AF	#	MACRON
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x017D	#	LATIN CAPITAL LETTER Z WITH CARON
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x017E	#	LATIN SMALL LETTER Z WITH CARON
-0xB9	0x00B9	#	SUPERSCRIPT ONE
-0xBA	0x00BA	#	MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x0152	#	LATIN CAPITAL LIGATURE OE
-0xBD	0x0153	#	LATIN SMALL LIGATURE OE
-0xBE	0x0178	#	LATIN CAPITAL LETTER Y WITH DIAERESIS
-0xBF	0x00BF	#	INVERTED QUESTION MARK
-0xC0	0x00C0	#	LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#	LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#	LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#	LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x00D0	#	LATIN CAPITAL LETTER ETH
-0xD1	0x00D1	#	LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#	LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#	LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#	LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x00DE	#	LATIN CAPITAL LETTER THORN
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#	LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#	LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#	LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#	LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x00F0	#	LATIN SMALL LETTER ETH
-0xF1	0x00F1	#	LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#	LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#	LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#	LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x00FE	#	LATIN SMALL LETTER THORN
-0xFF	0x00FF	#	LATIN SMALL LETTER Y WITH DIAERESIS
-
diff --git a/lib/ucmaps/8859-2.txt b/lib/ucmaps/8859-2.txt
deleted file mode 100755
index e45df25eb..000000000
--- a/lib/ucmaps/8859-2.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO 8859-2:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-2:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-2 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-2 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x0104	#	LATIN CAPITAL LETTER A WITH OGONEK
-0xA2	0x02D8	#	BREVE
-0xA3	0x0141	#	LATIN CAPITAL LETTER L WITH STROKE
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x013D	#	LATIN CAPITAL LETTER L WITH CARON
-0xA6	0x015A	#	LATIN CAPITAL LETTER S WITH ACUTE
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x0160	#	LATIN CAPITAL LETTER S WITH CARON
-0xAA	0x015E	#	LATIN CAPITAL LETTER S WITH CEDILLA
-0xAB	0x0164	#	LATIN CAPITAL LETTER T WITH CARON
-0xAC	0x0179	#	LATIN CAPITAL LETTER Z WITH ACUTE
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x017D	#	LATIN CAPITAL LETTER Z WITH CARON
-0xAF	0x017B	#	LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x0105	#	LATIN SMALL LETTER A WITH OGONEK
-0xB2	0x02DB	#	OGONEK
-0xB3	0x0142	#	LATIN SMALL LETTER L WITH STROKE
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x013E	#	LATIN SMALL LETTER L WITH CARON
-0xB6	0x015B	#	LATIN SMALL LETTER S WITH ACUTE
-0xB7	0x02C7	#	CARON
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x0161	#	LATIN SMALL LETTER S WITH CARON
-0xBA	0x015F	#	LATIN SMALL LETTER S WITH CEDILLA
-0xBB	0x0165	#	LATIN SMALL LETTER T WITH CARON
-0xBC	0x017A	#	LATIN SMALL LETTER Z WITH ACUTE
-0xBD	0x02DD	#	DOUBLE ACUTE ACCENT
-0xBE	0x017E	#	LATIN SMALL LETTER Z WITH CARON
-0xBF	0x017C	#	LATIN SMALL LETTER Z WITH DOT ABOVE
-0xC0	0x0154	#	LATIN CAPITAL LETTER R WITH ACUTE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x0102	#	LATIN CAPITAL LETTER A WITH BREVE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x0139	#	LATIN CAPITAL LETTER L WITH ACUTE
-0xC6	0x0106	#	LATIN CAPITAL LETTER C WITH ACUTE
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x010C	#	LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0118	#	LATIN CAPITAL LETTER E WITH OGONEK
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x011A	#	LATIN CAPITAL LETTER E WITH CARON
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x010E	#	LATIN CAPITAL LETTER D WITH CARON
-0xD0	0x0110	#	LATIN CAPITAL LETTER D WITH STROKE
-0xD1	0x0143	#	LATIN CAPITAL LETTER N WITH ACUTE
-0xD2	0x0147	#	LATIN CAPITAL LETTER N WITH CARON
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x0150	#	LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x0158	#	LATIN CAPITAL LETTER R WITH CARON
-0xD9	0x016E	#	LATIN CAPITAL LETTER U WITH RING ABOVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x0170	#	LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#	LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x0162	#	LATIN CAPITAL LETTER T WITH CEDILLA
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x0155	#	LATIN SMALL LETTER R WITH ACUTE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x0103	#	LATIN SMALL LETTER A WITH BREVE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x013A	#	LATIN SMALL LETTER L WITH ACUTE
-0xE6	0x0107	#	LATIN SMALL LETTER C WITH ACUTE
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x010D	#	LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x0119	#	LATIN SMALL LETTER E WITH OGONEK
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x011B	#	LATIN SMALL LETTER E WITH CARON
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x010F	#	LATIN SMALL LETTER D WITH CARON
-0xF0	0x0111	#	LATIN SMALL LETTER D WITH STROKE
-0xF1	0x0144	#	LATIN SMALL LETTER N WITH ACUTE
-0xF2	0x0148	#	LATIN SMALL LETTER N WITH CARON
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x0151	#	LATIN SMALL LETTER O WITH DOUBLE ACUTE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x0159	#	LATIN SMALL LETTER R WITH CARON
-0xF9	0x016F	#	LATIN SMALL LETTER U WITH RING ABOVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x0171	#	LATIN SMALL LETTER U WITH DOUBLE ACUTE
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#	LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x0163	#	LATIN SMALL LETTER T WITH CEDILLA
-0xFF	0x02D9	#	DOT ABOVE
diff --git a/lib/ucmaps/8859-3.txt b/lib/ucmaps/8859-3.txt
deleted file mode 100755
index 9b6ac69dd..000000000
--- a/lib/ucmaps/8859-3.txt
+++ /dev/null
@@ -1,296 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-3:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-3:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-3 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-3 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x0126	#	LATIN CAPITAL LETTER H WITH STROKE
-0xA2	0x02D8	#	BREVE
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA6	0x0124	#	LATIN CAPITAL LETTER H WITH CIRCUMFLEX
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x0130	#	LATIN CAPITAL LETTER I WITH DOT ABOVE
-0xAA	0x015E	#	LATIN CAPITAL LETTER S WITH CEDILLA
-0xAB	0x011E	#	LATIN CAPITAL LETTER G WITH BREVE
-0xAC	0x0134	#	LATIN CAPITAL LETTER J WITH CIRCUMFLEX
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAF	0x017B	#	LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x0127	#	LATIN SMALL LETTER H WITH STROKE
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x0125	#	LATIN SMALL LETTER H WITH CIRCUMFLEX
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x0131	#	LATIN SMALL LETTER DOTLESS I
-0xBA	0x015F	#	LATIN SMALL LETTER S WITH CEDILLA
-0xBB	0x011F	#	LATIN SMALL LETTER G WITH BREVE
-0xBC	0x0135	#	LATIN SMALL LETTER J WITH CIRCUMFLEX
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBF	0x017C	#	LATIN SMALL LETTER Z WITH DOT ABOVE
-0xC0	0x00C0	#	LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x010A	#	LATIN CAPITAL LETTER C WITH DOT ABOVE
-0xC6	0x0108	#	LATIN CAPITAL LETTER C WITH CIRCUMFLEX
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#	LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#	LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#	LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD1	0x00D1	#	LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#	LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x0120	#	LATIN CAPITAL LETTER G WITH DOT ABOVE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x011C	#	LATIN CAPITAL LETTER G WITH CIRCUMFLEX
-0xD9	0x00D9	#	LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x016C	#	LATIN CAPITAL LETTER U WITH BREVE
-0xDE	0x015C	#	LATIN CAPITAL LETTER S WITH CIRCUMFLEX
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#	LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x010B	#	LATIN SMALL LETTER C WITH DOT ABOVE
-0xE6	0x0109	#	LATIN SMALL LETTER C WITH CIRCUMFLEX
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#	LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#	LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#	LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF1	0x00F1	#	LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#	LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x0121	#	LATIN SMALL LETTER G WITH DOT ABOVE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x011D	#	LATIN SMALL LETTER G WITH CIRCUMFLEX
-0xF9	0x00F9	#	LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x016D	#	LATIN SMALL LETTER U WITH BREVE
-0xFE	0x015D	#	LATIN SMALL LETTER S WITH CIRCUMFLEX
-0xFF	0x02D9	#	DOT ABOVE
diff --git a/lib/ucmaps/8859-4.txt b/lib/ucmaps/8859-4.txt
deleted file mode 100755
index 662e698ab..000000000
--- a/lib/ucmaps/8859-4.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-4:1998 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-4:1998 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-4 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-4 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x0104	#	LATIN CAPITAL LETTER A WITH OGONEK
-0xA2	0x0138	#	LATIN SMALL LETTER KRA
-0xA3	0x0156	#	LATIN CAPITAL LETTER R WITH CEDILLA
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x0128	#	LATIN CAPITAL LETTER I WITH TILDE
-0xA6	0x013B	#	LATIN CAPITAL LETTER L WITH CEDILLA
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x0160	#	LATIN CAPITAL LETTER S WITH CARON
-0xAA	0x0112	#	LATIN CAPITAL LETTER E WITH MACRON
-0xAB	0x0122	#	LATIN CAPITAL LETTER G WITH CEDILLA
-0xAC	0x0166	#	LATIN CAPITAL LETTER T WITH STROKE
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x017D	#	LATIN CAPITAL LETTER Z WITH CARON
-0xAF	0x00AF	#	MACRON
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x0105	#	LATIN SMALL LETTER A WITH OGONEK
-0xB2	0x02DB	#	OGONEK
-0xB3	0x0157	#	LATIN SMALL LETTER R WITH CEDILLA
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x0129	#	LATIN SMALL LETTER I WITH TILDE
-0xB6	0x013C	#	LATIN SMALL LETTER L WITH CEDILLA
-0xB7	0x02C7	#	CARON
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x0161	#	LATIN SMALL LETTER S WITH CARON
-0xBA	0x0113	#	LATIN SMALL LETTER E WITH MACRON
-0xBB	0x0123	#	LATIN SMALL LETTER G WITH CEDILLA
-0xBC	0x0167	#	LATIN SMALL LETTER T WITH STROKE
-0xBD	0x014A	#	LATIN CAPITAL LETTER ENG
-0xBE	0x017E	#	LATIN SMALL LETTER Z WITH CARON
-0xBF	0x014B	#	LATIN SMALL LETTER ENG
-0xC0	0x0100	#	LATIN CAPITAL LETTER A WITH MACRON
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x012E	#	LATIN CAPITAL LETTER I WITH OGONEK
-0xC8	0x010C	#	LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0118	#	LATIN CAPITAL LETTER E WITH OGONEK
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x0116	#	LATIN CAPITAL LETTER E WITH DOT ABOVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x012A	#	LATIN CAPITAL LETTER I WITH MACRON
-0xD0	0x0110	#	LATIN CAPITAL LETTER D WITH STROKE
-0xD1	0x0145	#	LATIN CAPITAL LETTER N WITH CEDILLA
-0xD2	0x014C	#	LATIN CAPITAL LETTER O WITH MACRON
-0xD3	0x0136	#	LATIN CAPITAL LETTER K WITH CEDILLA
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x0172	#	LATIN CAPITAL LETTER U WITH OGONEK
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x0168	#	LATIN CAPITAL LETTER U WITH TILDE
-0xDE	0x016A	#	LATIN CAPITAL LETTER U WITH MACRON
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x0101	#	LATIN SMALL LETTER A WITH MACRON
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x012F	#	LATIN SMALL LETTER I WITH OGONEK
-0xE8	0x010D	#	LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x0119	#	LATIN SMALL LETTER E WITH OGONEK
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x0117	#	LATIN SMALL LETTER E WITH DOT ABOVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x012B	#	LATIN SMALL LETTER I WITH MACRON
-0xF0	0x0111	#	LATIN SMALL LETTER D WITH STROKE
-0xF1	0x0146	#	LATIN SMALL LETTER N WITH CEDILLA
-0xF2	0x014D	#	LATIN SMALL LETTER O WITH MACRON
-0xF3	0x0137	#	LATIN SMALL LETTER K WITH CEDILLA
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x0173	#	LATIN SMALL LETTER U WITH OGONEK
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x0169	#	LATIN SMALL LETTER U WITH TILDE
-0xFE	0x016B	#	LATIN SMALL LETTER U WITH MACRON
-0xFF	0x02D9	#	DOT ABOVE
diff --git a/lib/ucmaps/8859-5.txt b/lib/ucmaps/8859-5.txt
deleted file mode 100755
index a7ed1ce2a..000000000
--- a/lib/ucmaps/8859-5.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#	Name:             ISO 8859-5:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-5:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-5 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-5 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x0401	#	CYRILLIC CAPITAL LETTER IO
-0xA2	0x0402	#	CYRILLIC CAPITAL LETTER DJE
-0xA3	0x0403	#	CYRILLIC CAPITAL LETTER GJE
-0xA4	0x0404	#	CYRILLIC CAPITAL LETTER UKRAINIAN IE
-0xA5	0x0405	#	CYRILLIC CAPITAL LETTER DZE
-0xA6	0x0406	#	CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
-0xA7	0x0407	#	CYRILLIC CAPITAL LETTER YI
-0xA8	0x0408	#	CYRILLIC CAPITAL LETTER JE
-0xA9	0x0409	#	CYRILLIC CAPITAL LETTER LJE
-0xAA	0x040A	#	CYRILLIC CAPITAL LETTER NJE
-0xAB	0x040B	#	CYRILLIC CAPITAL LETTER TSHE
-0xAC	0x040C	#	CYRILLIC CAPITAL LETTER KJE
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x040E	#	CYRILLIC CAPITAL LETTER SHORT U
-0xAF	0x040F	#	CYRILLIC CAPITAL LETTER DZHE
-0xB0	0x0410	#	CYRILLIC CAPITAL LETTER A
-0xB1	0x0411	#	CYRILLIC CAPITAL LETTER BE
-0xB2	0x0412	#	CYRILLIC CAPITAL LETTER VE
-0xB3	0x0413	#	CYRILLIC CAPITAL LETTER GHE
-0xB4	0x0414	#	CYRILLIC CAPITAL LETTER DE
-0xB5	0x0415	#	CYRILLIC CAPITAL LETTER IE
-0xB6	0x0416	#	CYRILLIC CAPITAL LETTER ZHE
-0xB7	0x0417	#	CYRILLIC CAPITAL LETTER ZE
-0xB8	0x0418	#	CYRILLIC CAPITAL LETTER I
-0xB9	0x0419	#	CYRILLIC CAPITAL LETTER SHORT I
-0xBA	0x041A	#	CYRILLIC CAPITAL LETTER KA
-0xBB	0x041B	#	CYRILLIC CAPITAL LETTER EL
-0xBC	0x041C	#	CYRILLIC CAPITAL LETTER EM
-0xBD	0x041D	#	CYRILLIC CAPITAL LETTER EN
-0xBE	0x041E	#	CYRILLIC CAPITAL LETTER O
-0xBF	0x041F	#	CYRILLIC CAPITAL LETTER PE
-0xC0	0x0420	#	CYRILLIC CAPITAL LETTER ER
-0xC1	0x0421	#	CYRILLIC CAPITAL LETTER ES
-0xC2	0x0422	#	CYRILLIC CAPITAL LETTER TE
-0xC3	0x0423	#	CYRILLIC CAPITAL LETTER U
-0xC4	0x0424	#	CYRILLIC CAPITAL LETTER EF
-0xC5	0x0425	#	CYRILLIC CAPITAL LETTER HA
-0xC6	0x0426	#	CYRILLIC CAPITAL LETTER TSE
-0xC7	0x0427	#	CYRILLIC CAPITAL LETTER CHE
-0xC8	0x0428	#	CYRILLIC CAPITAL LETTER SHA
-0xC9	0x0429	#	CYRILLIC CAPITAL LETTER SHCHA
-0xCA	0x042A	#	CYRILLIC CAPITAL LETTER HARD SIGN
-0xCB	0x042B	#	CYRILLIC CAPITAL LETTER YERU
-0xCC	0x042C	#	CYRILLIC CAPITAL LETTER SOFT SIGN
-0xCD	0x042D	#	CYRILLIC CAPITAL LETTER E
-0xCE	0x042E	#	CYRILLIC CAPITAL LETTER YU
-0xCF	0x042F	#	CYRILLIC CAPITAL LETTER YA
-0xD0	0x0430	#	CYRILLIC SMALL LETTER A
-0xD1	0x0431	#	CYRILLIC SMALL LETTER BE
-0xD2	0x0432	#	CYRILLIC SMALL LETTER VE
-0xD3	0x0433	#	CYRILLIC SMALL LETTER GHE
-0xD4	0x0434	#	CYRILLIC SMALL LETTER DE
-0xD5	0x0435	#	CYRILLIC SMALL LETTER IE
-0xD6	0x0436	#	CYRILLIC SMALL LETTER ZHE
-0xD7	0x0437	#	CYRILLIC SMALL LETTER ZE
-0xD8	0x0438	#	CYRILLIC SMALL LETTER I
-0xD9	0x0439	#	CYRILLIC SMALL LETTER SHORT I
-0xDA	0x043A	#	CYRILLIC SMALL LETTER KA
-0xDB	0x043B	#	CYRILLIC SMALL LETTER EL
-0xDC	0x043C	#	CYRILLIC SMALL LETTER EM
-0xDD	0x043D	#	CYRILLIC SMALL LETTER EN
-0xDE	0x043E	#	CYRILLIC SMALL LETTER O
-0xDF	0x043F	#	CYRILLIC SMALL LETTER PE
-0xE0	0x0440	#	CYRILLIC SMALL LETTER ER
-0xE1	0x0441	#	CYRILLIC SMALL LETTER ES
-0xE2	0x0442	#	CYRILLIC SMALL LETTER TE
-0xE3	0x0443	#	CYRILLIC SMALL LETTER U
-0xE4	0x0444	#	CYRILLIC SMALL LETTER EF
-0xE5	0x0445	#	CYRILLIC SMALL LETTER HA
-0xE6	0x0446	#	CYRILLIC SMALL LETTER TSE
-0xE7	0x0447	#	CYRILLIC SMALL LETTER CHE
-0xE8	0x0448	#	CYRILLIC SMALL LETTER SHA
-0xE9	0x0449	#	CYRILLIC SMALL LETTER SHCHA
-0xEA	0x044A	#	CYRILLIC SMALL LETTER HARD SIGN
-0xEB	0x044B	#	CYRILLIC SMALL LETTER YERU
-0xEC	0x044C	#	CYRILLIC SMALL LETTER SOFT SIGN
-0xED	0x044D	#	CYRILLIC SMALL LETTER E
-0xEE	0x044E	#	CYRILLIC SMALL LETTER YU
-0xEF	0x044F	#	CYRILLIC SMALL LETTER YA
-0xF0	0x2116	#	NUMERO SIGN
-0xF1	0x0451	#	CYRILLIC SMALL LETTER IO
-0xF2	0x0452	#	CYRILLIC SMALL LETTER DJE
-0xF3	0x0453	#	CYRILLIC SMALL LETTER GJE
-0xF4	0x0454	#	CYRILLIC SMALL LETTER UKRAINIAN IE
-0xF5	0x0455	#	CYRILLIC SMALL LETTER DZE
-0xF6	0x0456	#	CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
-0xF7	0x0457	#	CYRILLIC SMALL LETTER YI
-0xF8	0x0458	#	CYRILLIC SMALL LETTER JE
-0xF9	0x0459	#	CYRILLIC SMALL LETTER LJE
-0xFA	0x045A	#	CYRILLIC SMALL LETTER NJE
-0xFB	0x045B	#	CYRILLIC SMALL LETTER TSHE
-0xFC	0x045C	#	CYRILLIC SMALL LETTER KJE
-0xFD	0x00A7	#	SECTION SIGN
-0xFE	0x045E	#	CYRILLIC SMALL LETTER SHORT U
-0xFF	0x045F	#	CYRILLIC SMALL LETTER DZHE
diff --git a/lib/ucmaps/8859-6.txt b/lib/ucmaps/8859-6.txt
deleted file mode 100755
index 69ac7f589..000000000
--- a/lib/ucmaps/8859-6.txt
+++ /dev/null
@@ -1,260 +0,0 @@
-#
-#	Name:             ISO 8859-6:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-6:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-6 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-6 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#	0x30..0x39 remapped to the ASCII digits (U+0030..U+0039) instead
-#	of the Arabic digits (U+0660..U+0669).
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA4	0x00A4	#	CURRENCY SIGN
-0xAC	0x060C	#	ARABIC COMMA
-0xAD	0x00AD	#	SOFT HYPHEN
-0xBB	0x061B	#	ARABIC SEMICOLON
-0xBF	0x061F	#	ARABIC QUESTION MARK
-0xC1	0x0621	#	ARABIC LETTER HAMZA
-0xC2	0x0622	#	ARABIC LETTER ALEF WITH MADDA ABOVE
-0xC3	0x0623	#	ARABIC LETTER ALEF WITH HAMZA ABOVE
-0xC4	0x0624	#	ARABIC LETTER WAW WITH HAMZA ABOVE
-0xC5	0x0625	#	ARABIC LETTER ALEF WITH HAMZA BELOW
-0xC6	0x0626	#	ARABIC LETTER YEH WITH HAMZA ABOVE
-0xC7	0x0627	#	ARABIC LETTER ALEF
-0xC8	0x0628	#	ARABIC LETTER BEH
-0xC9	0x0629	#	ARABIC LETTER TEH MARBUTA
-0xCA	0x062A	#	ARABIC LETTER TEH
-0xCB	0x062B	#	ARABIC LETTER THEH
-0xCC	0x062C	#	ARABIC LETTER JEEM
-0xCD	0x062D	#	ARABIC LETTER HAH
-0xCE	0x062E	#	ARABIC LETTER KHAH
-0xCF	0x062F	#	ARABIC LETTER DAL
-0xD0	0x0630	#	ARABIC LETTER THAL
-0xD1	0x0631	#	ARABIC LETTER REH
-0xD2	0x0632	#	ARABIC LETTER ZAIN
-0xD3	0x0633	#	ARABIC LETTER SEEN
-0xD4	0x0634	#	ARABIC LETTER SHEEN
-0xD5	0x0635	#	ARABIC LETTER SAD
-0xD6	0x0636	#	ARABIC LETTER DAD
-0xD7	0x0637	#	ARABIC LETTER TAH
-0xD8	0x0638	#	ARABIC LETTER ZAH
-0xD9	0x0639	#	ARABIC LETTER AIN
-0xDA	0x063A	#	ARABIC LETTER GHAIN
-0xE0	0x0640	#	ARABIC TATWEEL
-0xE1	0x0641	#	ARABIC LETTER FEH
-0xE2	0x0642	#	ARABIC LETTER QAF
-0xE3	0x0643	#	ARABIC LETTER KAF
-0xE4	0x0644	#	ARABIC LETTER LAM
-0xE5	0x0645	#	ARABIC LETTER MEEM
-0xE6	0x0646	#	ARABIC LETTER NOON
-0xE7	0x0647	#	ARABIC LETTER HEH
-0xE8	0x0648	#	ARABIC LETTER WAW
-0xE9	0x0649	#	ARABIC LETTER ALEF MAKSURA
-0xEA	0x064A	#	ARABIC LETTER YEH
-0xEB	0x064B	#	ARABIC FATHATAN
-0xEC	0x064C	#	ARABIC DAMMATAN
-0xED	0x064D	#	ARABIC KASRATAN
-0xEE	0x064E	#	ARABIC FATHA
-0xEF	0x064F	#	ARABIC DAMMA
-0xF0	0x0650	#	ARABIC KASRA
-0xF1	0x0651	#	ARABIC SHADDA
-0xF2	0x0652	#	ARABIC SUKUN
diff --git a/lib/ucmaps/8859-7.txt b/lib/ucmaps/8859-7.txt
deleted file mode 100755
index 52c42d08a..000000000
--- a/lib/ucmaps/8859-7.txt
+++ /dev/null
@@ -1,302 +0,0 @@
-#
-#	Name:             ISO 8859-7:1987 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO 8859-7:1987 characters map into Unicode.
-#
-#	ISO 8859-7:1987 is equivalent to ISO-IR-126, ELOT 928,
-#	and ECMA 118.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO 8859-7 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO 8859-7 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#	Remap 0xA1 to U+2018 (instead of 0x02BD) to match text of 8859-7
-#	Remap 0xA2 to U+2019 (instead of 0x02BC) to match text of 8859-7
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x2018	#	LEFT SINGLE QUOTATION MARK
-0xA2	0x2019	#	RIGHT SINGLE QUOTATION MARK
-0xA3	0x00A3	#	POUND SIGN
-0xA6	0x00A6	#	BROKEN BAR
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAF	0x2015	#	HORIZONTAL BAR
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x0384	#	GREEK TONOS
-0xB5	0x0385	#	GREEK DIALYTIKA TONOS
-0xB6	0x0386	#	GREEK CAPITAL LETTER ALPHA WITH TONOS
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x0388	#	GREEK CAPITAL LETTER EPSILON WITH TONOS
-0xB9	0x0389	#	GREEK CAPITAL LETTER ETA WITH TONOS
-0xBA	0x038A	#	GREEK CAPITAL LETTER IOTA WITH TONOS
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x038C	#	GREEK CAPITAL LETTER OMICRON WITH TONOS
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBE	0x038E	#	GREEK CAPITAL LETTER UPSILON WITH TONOS
-0xBF	0x038F	#	GREEK CAPITAL LETTER OMEGA WITH TONOS
-0xC0	0x0390	#	GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
-0xC1	0x0391	#	GREEK CAPITAL LETTER ALPHA
-0xC2	0x0392	#	GREEK CAPITAL LETTER BETA
-0xC3	0x0393	#	GREEK CAPITAL LETTER GAMMA
-0xC4	0x0394	#	GREEK CAPITAL LETTER DELTA
-0xC5	0x0395	#	GREEK CAPITAL LETTER EPSILON
-0xC6	0x0396	#	GREEK CAPITAL LETTER ZETA
-0xC7	0x0397	#	GREEK CAPITAL LETTER ETA
-0xC8	0x0398	#	GREEK CAPITAL LETTER THETA
-0xC9	0x0399	#	GREEK CAPITAL LETTER IOTA
-0xCA	0x039A	#	GREEK CAPITAL LETTER KAPPA
-0xCB	0x039B	#	GREEK CAPITAL LETTER LAMDA
-0xCC	0x039C	#	GREEK CAPITAL LETTER MU
-0xCD	0x039D	#	GREEK CAPITAL LETTER NU
-0xCE	0x039E	#	GREEK CAPITAL LETTER XI
-0xCF	0x039F	#	GREEK CAPITAL LETTER OMICRON
-0xD0	0x03A0	#	GREEK CAPITAL LETTER PI
-0xD1	0x03A1	#	GREEK CAPITAL LETTER RHO
-0xD3	0x03A3	#	GREEK CAPITAL LETTER SIGMA
-0xD4	0x03A4	#	GREEK CAPITAL LETTER TAU
-0xD5	0x03A5	#	GREEK CAPITAL LETTER UPSILON
-0xD6	0x03A6	#	GREEK CAPITAL LETTER PHI
-0xD7	0x03A7	#	GREEK CAPITAL LETTER CHI
-0xD8	0x03A8	#	GREEK CAPITAL LETTER PSI
-0xD9	0x03A9	#	GREEK CAPITAL LETTER OMEGA
-0xDA	0x03AA	#	GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
-0xDB	0x03AB	#	GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
-0xDC	0x03AC	#	GREEK SMALL LETTER ALPHA WITH TONOS
-0xDD	0x03AD	#	GREEK SMALL LETTER EPSILON WITH TONOS
-0xDE	0x03AE	#	GREEK SMALL LETTER ETA WITH TONOS
-0xDF	0x03AF	#	GREEK SMALL LETTER IOTA WITH TONOS
-0xE0	0x03B0	#	GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
-0xE1	0x03B1	#	GREEK SMALL LETTER ALPHA
-0xE2	0x03B2	#	GREEK SMALL LETTER BETA
-0xE3	0x03B3	#	GREEK SMALL LETTER GAMMA
-0xE4	0x03B4	#	GREEK SMALL LETTER DELTA
-0xE5	0x03B5	#	GREEK SMALL LETTER EPSILON
-0xE6	0x03B6	#	GREEK SMALL LETTER ZETA
-0xE7	0x03B7	#	GREEK SMALL LETTER ETA
-0xE8	0x03B8	#	GREEK SMALL LETTER THETA
-0xE9	0x03B9	#	GREEK SMALL LETTER IOTA
-0xEA	0x03BA	#	GREEK SMALL LETTER KAPPA
-0xEB	0x03BB	#	GREEK SMALL LETTER LAMDA
-0xEC	0x03BC	#	GREEK SMALL LETTER MU
-0xED	0x03BD	#	GREEK SMALL LETTER NU
-0xEE	0x03BE	#	GREEK SMALL LETTER XI
-0xEF	0x03BF	#	GREEK SMALL LETTER OMICRON
-0xF0	0x03C0	#	GREEK SMALL LETTER PI
-0xF1	0x03C1	#	GREEK SMALL LETTER RHO
-0xF2	0x03C2	#	GREEK SMALL LETTER FINAL SIGMA
-0xF3	0x03C3	#	GREEK SMALL LETTER SIGMA
-0xF4	0x03C4	#	GREEK SMALL LETTER TAU
-0xF5	0x03C5	#	GREEK SMALL LETTER UPSILON
-0xF6	0x03C6	#	GREEK SMALL LETTER PHI
-0xF7	0x03C7	#	GREEK SMALL LETTER CHI
-0xF8	0x03C8	#	GREEK SMALL LETTER PSI
-0xF9	0x03C9	#	GREEK SMALL LETTER OMEGA
-0xFA	0x03CA	#	GREEK SMALL LETTER IOTA WITH DIALYTIKA
-0xFB	0x03CB	#	GREEK SMALL LETTER UPSILON WITH DIALYTIKA
-0xFC	0x03CC	#	GREEK SMALL LETTER OMICRON WITH TONOS
-0xFD	0x03CD	#	GREEK SMALL LETTER UPSILON WITH TONOS
-0xFE	0x03CE	#	GREEK SMALL LETTER OMEGA WITH TONOS
diff --git a/lib/ucmaps/8859-8.txt b/lib/ucmaps/8859-8.txt
deleted file mode 100755
index bc8da4c7f..000000000
--- a/lib/ucmaps/8859-8.txt
+++ /dev/null
@@ -1,270 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-8:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.1
-#	Table format:     Format A
-#	Date:             2000-Jan-03
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-8:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-8 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-8 order.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#       1.1 version updates to the published 8859-8:1999, correcting
-#          the mapping of 0xAF and adding mappings for LRM and RLM.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA2	0x00A2	#	CENT SIGN
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x00A5	#	YEN SIGN
-0xA6	0x00A6	#	BROKEN BAR
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x00D7	#	MULTIPLICATION SIGN
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x00AF	#	MACRON
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x00B9	#	SUPERSCRIPT ONE
-0xBA	0x00F7	#	DIVISION SIGN
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#	VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#	VULGAR FRACTION THREE QUARTERS
-0xDF	0x2017	#	DOUBLE LOW LINE
-0xE0	0x05D0	#	HEBREW LETTER ALEF
-0xE1	0x05D1	#	HEBREW LETTER BET
-0xE2	0x05D2	#	HEBREW LETTER GIMEL
-0xE3	0x05D3	#	HEBREW LETTER DALET
-0xE4	0x05D4	#	HEBREW LETTER HE
-0xE5	0x05D5	#	HEBREW LETTER VAV
-0xE6	0x05D6	#	HEBREW LETTER ZAYIN
-0xE7	0x05D7	#	HEBREW LETTER HET
-0xE8	0x05D8	#	HEBREW LETTER TET
-0xE9	0x05D9	#	HEBREW LETTER YOD
-0xEA	0x05DA	#	HEBREW LETTER FINAL KAF
-0xEB	0x05DB	#	HEBREW LETTER KAF
-0xEC	0x05DC	#	HEBREW LETTER LAMED
-0xED	0x05DD	#	HEBREW LETTER FINAL MEM
-0xEE	0x05DE	#	HEBREW LETTER MEM
-0xEF	0x05DF	#	HEBREW LETTER FINAL NUN
-0xF0	0x05E0	#	HEBREW LETTER NUN
-0xF1	0x05E1	#	HEBREW LETTER SAMEKH
-0xF2	0x05E2	#	HEBREW LETTER AYIN
-0xF3	0x05E3	#	HEBREW LETTER FINAL PE
-0xF4	0x05E4	#	HEBREW LETTER PE
-0xF5	0x05E5	#	HEBREW LETTER FINAL TSADI
-0xF6	0x05E6	#	HEBREW LETTER TSADI
-0xF7	0x05E7	#	HEBREW LETTER QOF
-0xF8	0x05E8	#	HEBREW LETTER RESH
-0xF9	0x05E9	#	HEBREW LETTER SHIN
-0xFA	0x05EA	#	HEBREW LETTER TAV
-0xFD	0x200E	#	LEFT-TO-RIGHT MARK
-0xFE	0x200F	#	RIGHT-TO-LEFT MARK
-
diff --git a/lib/ucmaps/8859-9.txt b/lib/ucmaps/8859-9.txt
deleted file mode 100755
index 22901f107..000000000
--- a/lib/ucmaps/8859-9.txt
+++ /dev/null
@@ -1,307 +0,0 @@
-#
-#	Name:             ISO/IEC 8859-9:1999 to Unicode
-#	Unicode version:  3.0
-#	Table version:    1.0
-#	Table format:     Format A
-#	Date:             1999 July 27
-#	Authors:          Ken Whistler <kenw@sybase.com>
-#
-#	Copyright (c) 1991-1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on magnetic media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       ISO/IEC 8859-9:1999 characters map into Unicode.
-#
-#	Format:  Three tab-separated columns
-#		 Column #1 is the ISO/IEC 8859-9 code (in hex as 0xXX)
-#		 Column #2 is the Unicode (in hex as 0xXXXX)
-#		 Column #3 the Unicode name (follows a comment sign, '#')
-#
-#	The entries are in ISO/IEC 8859-9 order.
-#
-#	ISO/IEC 8859-9 is also equivalent to ISO-IR-148.
-#
-#	Version history
-#	1.0 version updates 0.1 version by adding mappings for all
-#	control characters.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#	NULL
-0x01	0x0001	#	START OF HEADING
-0x02	0x0002	#	START OF TEXT
-0x03	0x0003	#	END OF TEXT
-0x04	0x0004	#	END OF TRANSMISSION
-0x05	0x0005	#	ENQUIRY
-0x06	0x0006	#	ACKNOWLEDGE
-0x07	0x0007	#	BELL
-0x08	0x0008	#	BACKSPACE
-0x09	0x0009	#	HORIZONTAL TABULATION
-0x0A	0x000A	#	LINE FEED
-0x0B	0x000B	#	VERTICAL TABULATION
-0x0C	0x000C	#	FORM FEED
-0x0D	0x000D	#	CARRIAGE RETURN
-0x0E	0x000E	#	SHIFT OUT
-0x0F	0x000F	#	SHIFT IN
-0x10	0x0010	#	DATA LINK ESCAPE
-0x11	0x0011	#	DEVICE CONTROL ONE
-0x12	0x0012	#	DEVICE CONTROL TWO
-0x13	0x0013	#	DEVICE CONTROL THREE
-0x14	0x0014	#	DEVICE CONTROL FOUR
-0x15	0x0015	#	NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#	SYNCHRONOUS IDLE
-0x17	0x0017	#	END OF TRANSMISSION BLOCK
-0x18	0x0018	#	CANCEL
-0x19	0x0019	#	END OF MEDIUM
-0x1A	0x001A	#	SUBSTITUTE
-0x1B	0x001B	#	ESCAPE
-0x1C	0x001C	#	FILE SEPARATOR
-0x1D	0x001D	#	GROUP SEPARATOR
-0x1E	0x001E	#	RECORD SEPARATOR
-0x1F	0x001F	#	UNIT SEPARATOR
-0x20	0x0020	#	SPACE
-0x21	0x0021	#	EXCLAMATION MARK
-0x22	0x0022	#	QUOTATION MARK
-0x23	0x0023	#	NUMBER SIGN
-0x24	0x0024	#	DOLLAR SIGN
-0x25	0x0025	#	PERCENT SIGN
-0x26	0x0026	#	AMPERSAND
-0x27	0x0027	#	APOSTROPHE
-0x28	0x0028	#	LEFT PARENTHESIS
-0x29	0x0029	#	RIGHT PARENTHESIS
-0x2A	0x002A	#	ASTERISK
-0x2B	0x002B	#	PLUS SIGN
-0x2C	0x002C	#	COMMA
-0x2D	0x002D	#	HYPHEN-MINUS
-0x2E	0x002E	#	FULL STOP
-0x2F	0x002F	#	SOLIDUS
-0x30	0x0030	#	DIGIT ZERO
-0x31	0x0031	#	DIGIT ONE
-0x32	0x0032	#	DIGIT TWO
-0x33	0x0033	#	DIGIT THREE
-0x34	0x0034	#	DIGIT FOUR
-0x35	0x0035	#	DIGIT FIVE
-0x36	0x0036	#	DIGIT SIX
-0x37	0x0037	#	DIGIT SEVEN
-0x38	0x0038	#	DIGIT EIGHT
-0x39	0x0039	#	DIGIT NINE
-0x3A	0x003A	#	COLON
-0x3B	0x003B	#	SEMICOLON
-0x3C	0x003C	#	LESS-THAN SIGN
-0x3D	0x003D	#	EQUALS SIGN
-0x3E	0x003E	#	GREATER-THAN SIGN
-0x3F	0x003F	#	QUESTION MARK
-0x40	0x0040	#	COMMERCIAL AT
-0x41	0x0041	#	LATIN CAPITAL LETTER A
-0x42	0x0042	#	LATIN CAPITAL LETTER B
-0x43	0x0043	#	LATIN CAPITAL LETTER C
-0x44	0x0044	#	LATIN CAPITAL LETTER D
-0x45	0x0045	#	LATIN CAPITAL LETTER E
-0x46	0x0046	#	LATIN CAPITAL LETTER F
-0x47	0x0047	#	LATIN CAPITAL LETTER G
-0x48	0x0048	#	LATIN CAPITAL LETTER H
-0x49	0x0049	#	LATIN CAPITAL LETTER I
-0x4A	0x004A	#	LATIN CAPITAL LETTER J
-0x4B	0x004B	#	LATIN CAPITAL LETTER K
-0x4C	0x004C	#	LATIN CAPITAL LETTER L
-0x4D	0x004D	#	LATIN CAPITAL LETTER M
-0x4E	0x004E	#	LATIN CAPITAL LETTER N
-0x4F	0x004F	#	LATIN CAPITAL LETTER O
-0x50	0x0050	#	LATIN CAPITAL LETTER P
-0x51	0x0051	#	LATIN CAPITAL LETTER Q
-0x52	0x0052	#	LATIN CAPITAL LETTER R
-0x53	0x0053	#	LATIN CAPITAL LETTER S
-0x54	0x0054	#	LATIN CAPITAL LETTER T
-0x55	0x0055	#	LATIN CAPITAL LETTER U
-0x56	0x0056	#	LATIN CAPITAL LETTER V
-0x57	0x0057	#	LATIN CAPITAL LETTER W
-0x58	0x0058	#	LATIN CAPITAL LETTER X
-0x59	0x0059	#	LATIN CAPITAL LETTER Y
-0x5A	0x005A	#	LATIN CAPITAL LETTER Z
-0x5B	0x005B	#	LEFT SQUARE BRACKET
-0x5C	0x005C	#	REVERSE SOLIDUS
-0x5D	0x005D	#	RIGHT SQUARE BRACKET
-0x5E	0x005E	#	CIRCUMFLEX ACCENT
-0x5F	0x005F	#	LOW LINE
-0x60	0x0060	#	GRAVE ACCENT
-0x61	0x0061	#	LATIN SMALL LETTER A
-0x62	0x0062	#	LATIN SMALL LETTER B
-0x63	0x0063	#	LATIN SMALL LETTER C
-0x64	0x0064	#	LATIN SMALL LETTER D
-0x65	0x0065	#	LATIN SMALL LETTER E
-0x66	0x0066	#	LATIN SMALL LETTER F
-0x67	0x0067	#	LATIN SMALL LETTER G
-0x68	0x0068	#	LATIN SMALL LETTER H
-0x69	0x0069	#	LATIN SMALL LETTER I
-0x6A	0x006A	#	LATIN SMALL LETTER J
-0x6B	0x006B	#	LATIN SMALL LETTER K
-0x6C	0x006C	#	LATIN SMALL LETTER L
-0x6D	0x006D	#	LATIN SMALL LETTER M
-0x6E	0x006E	#	LATIN SMALL LETTER N
-0x6F	0x006F	#	LATIN SMALL LETTER O
-0x70	0x0070	#	LATIN SMALL LETTER P
-0x71	0x0071	#	LATIN SMALL LETTER Q
-0x72	0x0072	#	LATIN SMALL LETTER R
-0x73	0x0073	#	LATIN SMALL LETTER S
-0x74	0x0074	#	LATIN SMALL LETTER T
-0x75	0x0075	#	LATIN SMALL LETTER U
-0x76	0x0076	#	LATIN SMALL LETTER V
-0x77	0x0077	#	LATIN SMALL LETTER W
-0x78	0x0078	#	LATIN SMALL LETTER X
-0x79	0x0079	#	LATIN SMALL LETTER Y
-0x7A	0x007A	#	LATIN SMALL LETTER Z
-0x7B	0x007B	#	LEFT CURLY BRACKET
-0x7C	0x007C	#	VERTICAL LINE
-0x7D	0x007D	#	RIGHT CURLY BRACKET
-0x7E	0x007E	#	TILDE
-0x7F	0x007F	#	DELETE
-0x80	0x0080	#	<control>
-0x81	0x0081	#	<control>
-0x82	0x0082	#	<control>
-0x83	0x0083	#	<control>
-0x84	0x0084	#	<control>
-0x85	0x0085	#	<control>
-0x86	0x0086	#	<control>
-0x87	0x0087	#	<control>
-0x88	0x0088	#	<control>
-0x89	0x0089	#	<control>
-0x8A	0x008A	#	<control>
-0x8B	0x008B	#	<control>
-0x8C	0x008C	#	<control>
-0x8D	0x008D	#	<control>
-0x8E	0x008E	#	<control>
-0x8F	0x008F	#	<control>
-0x90	0x0090	#	<control>
-0x91	0x0091	#	<control>
-0x92	0x0092	#	<control>
-0x93	0x0093	#	<control>
-0x94	0x0094	#	<control>
-0x95	0x0095	#	<control>
-0x96	0x0096	#	<control>
-0x97	0x0097	#	<control>
-0x98	0x0098	#	<control>
-0x99	0x0099	#	<control>
-0x9A	0x009A	#	<control>
-0x9B	0x009B	#	<control>
-0x9C	0x009C	#	<control>
-0x9D	0x009D	#	<control>
-0x9E	0x009E	#	<control>
-0x9F	0x009F	#	<control>
-0xA0	0x00A0	#	NO-BREAK SPACE
-0xA1	0x00A1	#	INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#	CENT SIGN
-0xA3	0x00A3	#	POUND SIGN
-0xA4	0x00A4	#	CURRENCY SIGN
-0xA5	0x00A5	#	YEN SIGN
-0xA6	0x00A6	#	BROKEN BAR
-0xA7	0x00A7	#	SECTION SIGN
-0xA8	0x00A8	#	DIAERESIS
-0xA9	0x00A9	#	COPYRIGHT SIGN
-0xAA	0x00AA	#	FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#	LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#	NOT SIGN
-0xAD	0x00AD	#	SOFT HYPHEN
-0xAE	0x00AE	#	REGISTERED SIGN
-0xAF	0x00AF	#	MACRON
-0xB0	0x00B0	#	DEGREE SIGN
-0xB1	0x00B1	#	PLUS-MINUS SIGN
-0xB2	0x00B2	#	SUPERSCRIPT TWO
-0xB3	0x00B3	#	SUPERSCRIPT THREE
-0xB4	0x00B4	#	ACUTE ACCENT
-0xB5	0x00B5	#	MICRO SIGN
-0xB6	0x00B6	#	PILCROW SIGN
-0xB7	0x00B7	#	MIDDLE DOT
-0xB8	0x00B8	#	CEDILLA
-0xB9	0x00B9	#	SUPERSCRIPT ONE
-0xBA	0x00BA	#	MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#	RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#	VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#	VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#	VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#	INVERTED QUESTION MARK
-0xC0	0x00C0	#	LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#	LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#	LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#	LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#	LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#	LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#	LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#	LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#	LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#	LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#	LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#	LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#	LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#	LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#	LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#	LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x011E	#	LATIN CAPITAL LETTER G WITH BREVE
-0xD1	0x00D1	#	LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#	LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#	LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#	LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#	LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#	LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#	MULTIPLICATION SIGN
-0xD8	0x00D8	#	LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#	LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#	LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#	LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#	LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x0130	#	LATIN CAPITAL LETTER I WITH DOT ABOVE
-0xDE	0x015E	#	LATIN CAPITAL LETTER S WITH CEDILLA
-0xDF	0x00DF	#	LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#	LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#	LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#	LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#	LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#	LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#	LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#	LATIN SMALL LETTER AE
-0xE7	0x00E7	#	LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#	LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#	LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#	LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#	LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#	LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#	LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#	LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#	LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x011F	#	LATIN SMALL LETTER G WITH BREVE
-0xF1	0x00F1	#	LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#	LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#	LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#	LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#	LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#	LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#	DIVISION SIGN
-0xF8	0x00F8	#	LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#	LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#	LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#	LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#	LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x0131	#	LATIN SMALL LETTER DOTLESS I
-0xFE	0x015F	#	LATIN SMALL LETTER S WITH CEDILLA
-0xFF	0x00FF	#	LATIN SMALL LETTER Y WITH DIAERESIS
-
-
diff --git a/lib/ucmaps/cp1250.txt b/lib/ucmaps/cp1250.txt
deleted file mode 100755
index 081d7763b..000000000
--- a/lib/ucmaps/cp1250.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1250 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1250 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1250 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	      	#UNDEFINED
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	      	#UNDEFINED
-0x89	0x2030	#PER MILLE SIGN
-0x8A	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x015A	#LATIN CAPITAL LETTER S WITH ACUTE
-0x8D	0x0164	#LATIN CAPITAL LETTER T WITH CARON
-0x8E	0x017D	#LATIN CAPITAL LETTER Z WITH CARON
-0x8F	0x0179	#LATIN CAPITAL LETTER Z WITH ACUTE
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	      	#UNDEFINED
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	0x0161	#LATIN SMALL LETTER S WITH CARON
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x015B	#LATIN SMALL LETTER S WITH ACUTE
-0x9D	0x0165	#LATIN SMALL LETTER T WITH CARON
-0x9E	0x017E	#LATIN SMALL LETTER Z WITH CARON
-0x9F	0x017A	#LATIN SMALL LETTER Z WITH ACUTE
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x02C7	#CARON
-0xA2	0x02D8	#BREVE
-0xA3	0x0141	#LATIN CAPITAL LETTER L WITH STROKE
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x0104	#LATIN CAPITAL LETTER A WITH OGONEK
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x015E	#LATIN CAPITAL LETTER S WITH CEDILLA
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x017B	#LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x02DB	#OGONEK
-0xB3	0x0142	#LATIN SMALL LETTER L WITH STROKE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x0105	#LATIN SMALL LETTER A WITH OGONEK
-0xBA	0x015F	#LATIN SMALL LETTER S WITH CEDILLA
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x013D	#LATIN CAPITAL LETTER L WITH CARON
-0xBD	0x02DD	#DOUBLE ACUTE ACCENT
-0xBE	0x013E	#LATIN SMALL LETTER L WITH CARON
-0xBF	0x017C	#LATIN SMALL LETTER Z WITH DOT ABOVE
-0xC0	0x0154	#LATIN CAPITAL LETTER R WITH ACUTE
-0xC1	0x00C1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x0102	#LATIN CAPITAL LETTER A WITH BREVE
-0xC4	0x00C4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x0139	#LATIN CAPITAL LETTER L WITH ACUTE
-0xC6	0x0106	#LATIN CAPITAL LETTER C WITH ACUTE
-0xC7	0x00C7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x010C	#LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0118	#LATIN CAPITAL LETTER E WITH OGONEK
-0xCB	0x00CB	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x011A	#LATIN CAPITAL LETTER E WITH CARON
-0xCD	0x00CD	#LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x010E	#LATIN CAPITAL LETTER D WITH CARON
-0xD0	0x0110	#LATIN CAPITAL LETTER D WITH STROKE
-0xD1	0x0143	#LATIN CAPITAL LETTER N WITH ACUTE
-0xD2	0x0147	#LATIN CAPITAL LETTER N WITH CARON
-0xD3	0x00D3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x0150	#LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
-0xD6	0x00D6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x0158	#LATIN CAPITAL LETTER R WITH CARON
-0xD9	0x016E	#LATIN CAPITAL LETTER U WITH RING ABOVE
-0xDA	0x00DA	#LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x0170	#LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
-0xDC	0x00DC	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x0162	#LATIN CAPITAL LETTER T WITH CEDILLA
-0xDF	0x00DF	#LATIN SMALL LETTER SHARP S
-0xE0	0x0155	#LATIN SMALL LETTER R WITH ACUTE
-0xE1	0x00E1	#LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x0103	#LATIN SMALL LETTER A WITH BREVE
-0xE4	0x00E4	#LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x013A	#LATIN SMALL LETTER L WITH ACUTE
-0xE6	0x0107	#LATIN SMALL LETTER C WITH ACUTE
-0xE7	0x00E7	#LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x010D	#LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x0119	#LATIN SMALL LETTER E WITH OGONEK
-0xEB	0x00EB	#LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x011B	#LATIN SMALL LETTER E WITH CARON
-0xED	0x00ED	#LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x010F	#LATIN SMALL LETTER D WITH CARON
-0xF0	0x0111	#LATIN SMALL LETTER D WITH STROKE
-0xF1	0x0144	#LATIN SMALL LETTER N WITH ACUTE
-0xF2	0x0148	#LATIN SMALL LETTER N WITH CARON
-0xF3	0x00F3	#LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x0151	#LATIN SMALL LETTER O WITH DOUBLE ACUTE
-0xF6	0x00F6	#LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x0159	#LATIN SMALL LETTER R WITH CARON
-0xF9	0x016F	#LATIN SMALL LETTER U WITH RING ABOVE
-0xFA	0x00FA	#LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x0171	#LATIN SMALL LETTER U WITH DOUBLE ACUTE
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x0163	#LATIN SMALL LETTER T WITH CEDILLA
-0xFF	0x02D9	#DOT ABOVE
diff --git a/lib/ucmaps/cp1251.txt b/lib/ucmaps/cp1251.txt
deleted file mode 100755
index 37eadbdbc..000000000
--- a/lib/ucmaps/cp1251.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1251 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1251 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1251 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x0402	#CYRILLIC CAPITAL LETTER DJE
-0x81	0x0403	#CYRILLIC CAPITAL LETTER GJE
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0453	#CYRILLIC SMALL LETTER GJE
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x20AC	#EURO SIGN
-0x89	0x2030	#PER MILLE SIGN
-0x8A	0x0409	#CYRILLIC CAPITAL LETTER LJE
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x040A	#CYRILLIC CAPITAL LETTER NJE
-0x8D	0x040C	#CYRILLIC CAPITAL LETTER KJE
-0x8E	0x040B	#CYRILLIC CAPITAL LETTER TSHE
-0x8F	0x040F	#CYRILLIC CAPITAL LETTER DZHE
-0x90	0x0452	#CYRILLIC SMALL LETTER DJE
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	      	#UNDEFINED
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	0x0459	#CYRILLIC SMALL LETTER LJE
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x045A	#CYRILLIC SMALL LETTER NJE
-0x9D	0x045C	#CYRILLIC SMALL LETTER KJE
-0x9E	0x045B	#CYRILLIC SMALL LETTER TSHE
-0x9F	0x045F	#CYRILLIC SMALL LETTER DZHE
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x040E	#CYRILLIC CAPITAL LETTER SHORT U
-0xA2	0x045E	#CYRILLIC SMALL LETTER SHORT U
-0xA3	0x0408	#CYRILLIC CAPITAL LETTER JE
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x0490	#CYRILLIC CAPITAL LETTER GHE WITH UPTURN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x0401	#CYRILLIC CAPITAL LETTER IO
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x0404	#CYRILLIC CAPITAL LETTER UKRAINIAN IE
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x0407	#CYRILLIC CAPITAL LETTER YI
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x0406	#CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
-0xB3	0x0456	#CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
-0xB4	0x0491	#CYRILLIC SMALL LETTER GHE WITH UPTURN
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x0451	#CYRILLIC SMALL LETTER IO
-0xB9	0x2116	#NUMERO SIGN
-0xBA	0x0454	#CYRILLIC SMALL LETTER UKRAINIAN IE
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x0458	#CYRILLIC SMALL LETTER JE
-0xBD	0x0405	#CYRILLIC CAPITAL LETTER DZE
-0xBE	0x0455	#CYRILLIC SMALL LETTER DZE
-0xBF	0x0457	#CYRILLIC SMALL LETTER YI
-0xC0	0x0410	#CYRILLIC CAPITAL LETTER A
-0xC1	0x0411	#CYRILLIC CAPITAL LETTER BE
-0xC2	0x0412	#CYRILLIC CAPITAL LETTER VE
-0xC3	0x0413	#CYRILLIC CAPITAL LETTER GHE
-0xC4	0x0414	#CYRILLIC CAPITAL LETTER DE
-0xC5	0x0415	#CYRILLIC CAPITAL LETTER IE
-0xC6	0x0416	#CYRILLIC CAPITAL LETTER ZHE
-0xC7	0x0417	#CYRILLIC CAPITAL LETTER ZE
-0xC8	0x0418	#CYRILLIC CAPITAL LETTER I
-0xC9	0x0419	#CYRILLIC CAPITAL LETTER SHORT I
-0xCA	0x041A	#CYRILLIC CAPITAL LETTER KA
-0xCB	0x041B	#CYRILLIC CAPITAL LETTER EL
-0xCC	0x041C	#CYRILLIC CAPITAL LETTER EM
-0xCD	0x041D	#CYRILLIC CAPITAL LETTER EN
-0xCE	0x041E	#CYRILLIC CAPITAL LETTER O
-0xCF	0x041F	#CYRILLIC CAPITAL LETTER PE
-0xD0	0x0420	#CYRILLIC CAPITAL LETTER ER
-0xD1	0x0421	#CYRILLIC CAPITAL LETTER ES
-0xD2	0x0422	#CYRILLIC CAPITAL LETTER TE
-0xD3	0x0423	#CYRILLIC CAPITAL LETTER U
-0xD4	0x0424	#CYRILLIC CAPITAL LETTER EF
-0xD5	0x0425	#CYRILLIC CAPITAL LETTER HA
-0xD6	0x0426	#CYRILLIC CAPITAL LETTER TSE
-0xD7	0x0427	#CYRILLIC CAPITAL LETTER CHE
-0xD8	0x0428	#CYRILLIC CAPITAL LETTER SHA
-0xD9	0x0429	#CYRILLIC CAPITAL LETTER SHCHA
-0xDA	0x042A	#CYRILLIC CAPITAL LETTER HARD SIGN
-0xDB	0x042B	#CYRILLIC CAPITAL LETTER YERU
-0xDC	0x042C	#CYRILLIC CAPITAL LETTER SOFT SIGN
-0xDD	0x042D	#CYRILLIC CAPITAL LETTER E
-0xDE	0x042E	#CYRILLIC CAPITAL LETTER YU
-0xDF	0x042F	#CYRILLIC CAPITAL LETTER YA
-0xE0	0x0430	#CYRILLIC SMALL LETTER A
-0xE1	0x0431	#CYRILLIC SMALL LETTER BE
-0xE2	0x0432	#CYRILLIC SMALL LETTER VE
-0xE3	0x0433	#CYRILLIC SMALL LETTER GHE
-0xE4	0x0434	#CYRILLIC SMALL LETTER DE
-0xE5	0x0435	#CYRILLIC SMALL LETTER IE
-0xE6	0x0436	#CYRILLIC SMALL LETTER ZHE
-0xE7	0x0437	#CYRILLIC SMALL LETTER ZE
-0xE8	0x0438	#CYRILLIC SMALL LETTER I
-0xE9	0x0439	#CYRILLIC SMALL LETTER SHORT I
-0xEA	0x043A	#CYRILLIC SMALL LETTER KA
-0xEB	0x043B	#CYRILLIC SMALL LETTER EL
-0xEC	0x043C	#CYRILLIC SMALL LETTER EM
-0xED	0x043D	#CYRILLIC SMALL LETTER EN
-0xEE	0x043E	#CYRILLIC SMALL LETTER O
-0xEF	0x043F	#CYRILLIC SMALL LETTER PE
-0xF0	0x0440	#CYRILLIC SMALL LETTER ER
-0xF1	0x0441	#CYRILLIC SMALL LETTER ES
-0xF2	0x0442	#CYRILLIC SMALL LETTER TE
-0xF3	0x0443	#CYRILLIC SMALL LETTER U
-0xF4	0x0444	#CYRILLIC SMALL LETTER EF
-0xF5	0x0445	#CYRILLIC SMALL LETTER HA
-0xF6	0x0446	#CYRILLIC SMALL LETTER TSE
-0xF7	0x0447	#CYRILLIC SMALL LETTER CHE
-0xF8	0x0448	#CYRILLIC SMALL LETTER SHA
-0xF9	0x0449	#CYRILLIC SMALL LETTER SHCHA
-0xFA	0x044A	#CYRILLIC SMALL LETTER HARD SIGN
-0xFB	0x044B	#CYRILLIC SMALL LETTER YERU
-0xFC	0x044C	#CYRILLIC SMALL LETTER SOFT SIGN
-0xFD	0x044D	#CYRILLIC SMALL LETTER E
-0xFE	0x044E	#CYRILLIC SMALL LETTER YU
-0xFF	0x044F	#CYRILLIC SMALL LETTER YA
diff --git a/lib/ucmaps/cp1252.txt b/lib/ucmaps/cp1252.txt
deleted file mode 100755
index 2ca4486eb..000000000
--- a/lib/ucmaps/cp1252.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1252 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1252 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1252 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x02C6	#MODIFIER LETTER CIRCUMFLEX ACCENT
-0x89	0x2030	#PER MILLE SIGN
-0x8A	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x0152	#LATIN CAPITAL LIGATURE OE
-0x8D	      	#UNDEFINED
-0x8E	0x017D	#LATIN CAPITAL LETTER Z WITH CARON
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	0x02DC	#SMALL TILDE
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	0x0161	#LATIN SMALL LETTER S WITH CARON
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x0153	#LATIN SMALL LIGATURE OE
-0x9D	      	#UNDEFINED
-0x9E	0x017E	#LATIN SMALL LETTER Z WITH CARON
-0x9F	0x0178	#LATIN CAPITAL LETTER Y WITH DIAERESIS
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x00A1	#INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x00AA	#FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00AF	#MACRON
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x00BA	#MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#INVERTED QUESTION MARK
-0xC0	0x00C0	#LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x00D0	#LATIN CAPITAL LETTER ETH
-0xD1	0x00D1	#LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x00D8	#LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x00DD	#LATIN CAPITAL LETTER Y WITH ACUTE
-0xDE	0x00DE	#LATIN CAPITAL LETTER THORN
-0xDF	0x00DF	#LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#LATIN SMALL LETTER AE
-0xE7	0x00E7	#LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x00F0	#LATIN SMALL LETTER ETH
-0xF1	0x00F1	#LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x00F8	#LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x00FD	#LATIN SMALL LETTER Y WITH ACUTE
-0xFE	0x00FE	#LATIN SMALL LETTER THORN
-0xFF	0x00FF	#LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/lib/ucmaps/cp1253.txt b/lib/ucmaps/cp1253.txt
deleted file mode 100755
index 2ba51a0c8..000000000
--- a/lib/ucmaps/cp1253.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1253 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1253 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1253 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	      	#UNDEFINED
-0x89	0x2030	#PER MILLE SIGN
-0x8A	      	#UNDEFINED
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	      	#UNDEFINED
-0x8D	      	#UNDEFINED
-0x8E	      	#UNDEFINED
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	      	#UNDEFINED
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	      	#UNDEFINED
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	      	#UNDEFINED
-0x9D	      	#UNDEFINED
-0x9E	      	#UNDEFINED
-0x9F	      	#UNDEFINED
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x0385	#GREEK DIALYTIKA TONOS
-0xA2	0x0386	#GREEK CAPITAL LETTER ALPHA WITH TONOS
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	      	#UNDEFINED
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x2015	#HORIZONTAL BAR
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x0384	#GREEK TONOS
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x0388	#GREEK CAPITAL LETTER EPSILON WITH TONOS
-0xB9	0x0389	#GREEK CAPITAL LETTER ETA WITH TONOS
-0xBA	0x038A	#GREEK CAPITAL LETTER IOTA WITH TONOS
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x038C	#GREEK CAPITAL LETTER OMICRON WITH TONOS
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x038E	#GREEK CAPITAL LETTER UPSILON WITH TONOS
-0xBF	0x038F	#GREEK CAPITAL LETTER OMEGA WITH TONOS
-0xC0	0x0390	#GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
-0xC1	0x0391	#GREEK CAPITAL LETTER ALPHA
-0xC2	0x0392	#GREEK CAPITAL LETTER BETA
-0xC3	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xC4	0x0394	#GREEK CAPITAL LETTER DELTA
-0xC5	0x0395	#GREEK CAPITAL LETTER EPSILON
-0xC6	0x0396	#GREEK CAPITAL LETTER ZETA
-0xC7	0x0397	#GREEK CAPITAL LETTER ETA
-0xC8	0x0398	#GREEK CAPITAL LETTER THETA
-0xC9	0x0399	#GREEK CAPITAL LETTER IOTA
-0xCA	0x039A	#GREEK CAPITAL LETTER KAPPA
-0xCB	0x039B	#GREEK CAPITAL LETTER LAMDA
-0xCC	0x039C	#GREEK CAPITAL LETTER MU
-0xCD	0x039D	#GREEK CAPITAL LETTER NU
-0xCE	0x039E	#GREEK CAPITAL LETTER XI
-0xCF	0x039F	#GREEK CAPITAL LETTER OMICRON
-0xD0	0x03A0	#GREEK CAPITAL LETTER PI
-0xD1	0x03A1	#GREEK CAPITAL LETTER RHO
-0xD2	      	#UNDEFINED
-0xD3	0x03A3	#GREEK CAPITAL LETTER SIGMA
-0xD4	0x03A4	#GREEK CAPITAL LETTER TAU
-0xD5	0x03A5	#GREEK CAPITAL LETTER UPSILON
-0xD6	0x03A6	#GREEK CAPITAL LETTER PHI
-0xD7	0x03A7	#GREEK CAPITAL LETTER CHI
-0xD8	0x03A8	#GREEK CAPITAL LETTER PSI
-0xD9	0x03A9	#GREEK CAPITAL LETTER OMEGA
-0xDA	0x03AA	#GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
-0xDB	0x03AB	#GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
-0xDC	0x03AC	#GREEK SMALL LETTER ALPHA WITH TONOS
-0xDD	0x03AD	#GREEK SMALL LETTER EPSILON WITH TONOS
-0xDE	0x03AE	#GREEK SMALL LETTER ETA WITH TONOS
-0xDF	0x03AF	#GREEK SMALL LETTER IOTA WITH TONOS
-0xE0	0x03B0	#GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
-0xE1	0x03B1	#GREEK SMALL LETTER ALPHA
-0xE2	0x03B2	#GREEK SMALL LETTER BETA
-0xE3	0x03B3	#GREEK SMALL LETTER GAMMA
-0xE4	0x03B4	#GREEK SMALL LETTER DELTA
-0xE5	0x03B5	#GREEK SMALL LETTER EPSILON
-0xE6	0x03B6	#GREEK SMALL LETTER ZETA
-0xE7	0x03B7	#GREEK SMALL LETTER ETA
-0xE8	0x03B8	#GREEK SMALL LETTER THETA
-0xE9	0x03B9	#GREEK SMALL LETTER IOTA
-0xEA	0x03BA	#GREEK SMALL LETTER KAPPA
-0xEB	0x03BB	#GREEK SMALL LETTER LAMDA
-0xEC	0x03BC	#GREEK SMALL LETTER MU
-0xED	0x03BD	#GREEK SMALL LETTER NU
-0xEE	0x03BE	#GREEK SMALL LETTER XI
-0xEF	0x03BF	#GREEK SMALL LETTER OMICRON
-0xF0	0x03C0	#GREEK SMALL LETTER PI
-0xF1	0x03C1	#GREEK SMALL LETTER RHO
-0xF2	0x03C2	#GREEK SMALL LETTER FINAL SIGMA
-0xF3	0x03C3	#GREEK SMALL LETTER SIGMA
-0xF4	0x03C4	#GREEK SMALL LETTER TAU
-0xF5	0x03C5	#GREEK SMALL LETTER UPSILON
-0xF6	0x03C6	#GREEK SMALL LETTER PHI
-0xF7	0x03C7	#GREEK SMALL LETTER CHI
-0xF8	0x03C8	#GREEK SMALL LETTER PSI
-0xF9	0x03C9	#GREEK SMALL LETTER OMEGA
-0xFA	0x03CA	#GREEK SMALL LETTER IOTA WITH DIALYTIKA
-0xFB	0x03CB	#GREEK SMALL LETTER UPSILON WITH DIALYTIKA
-0xFC	0x03CC	#GREEK SMALL LETTER OMICRON WITH TONOS
-0xFD	0x03CD	#GREEK SMALL LETTER UPSILON WITH TONOS
-0xFE	0x03CE	#GREEK SMALL LETTER OMEGA WITH TONOS
-0xFF	      	#UNDEFINED
diff --git a/lib/ucmaps/cp1254.txt b/lib/ucmaps/cp1254.txt
deleted file mode 100755
index ca1a1ebdb..000000000
--- a/lib/ucmaps/cp1254.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1254 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1254 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1254 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x02C6	#MODIFIER LETTER CIRCUMFLEX ACCENT
-0x89	0x2030	#PER MILLE SIGN
-0x8A	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x0152	#LATIN CAPITAL LIGATURE OE
-0x8D	      	#UNDEFINED
-0x8E	      	#UNDEFINED
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	0x02DC	#SMALL TILDE
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	0x0161	#LATIN SMALL LETTER S WITH CARON
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x0153	#LATIN SMALL LIGATURE OE
-0x9D	      	#UNDEFINED
-0x9E	      	#UNDEFINED
-0x9F	0x0178	#LATIN CAPITAL LETTER Y WITH DIAERESIS
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x00A1	#INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x00AA	#FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00AF	#MACRON
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x00BA	#MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#INVERTED QUESTION MARK
-0xC0	0x00C0	#LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x00C3	#LATIN CAPITAL LETTER A WITH TILDE
-0xC4	0x00C4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x00CC	#LATIN CAPITAL LETTER I WITH GRAVE
-0xCD	0x00CD	#LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x011E	#LATIN CAPITAL LETTER G WITH BREVE
-0xD1	0x00D1	#LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x00D2	#LATIN CAPITAL LETTER O WITH GRAVE
-0xD3	0x00D3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x00D5	#LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x00D8	#LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x0130	#LATIN CAPITAL LETTER I WITH DOT ABOVE
-0xDE	0x015E	#LATIN CAPITAL LETTER S WITH CEDILLA
-0xDF	0x00DF	#LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x00E3	#LATIN SMALL LETTER A WITH TILDE
-0xE4	0x00E4	#LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#LATIN SMALL LETTER AE
-0xE7	0x00E7	#LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x00EC	#LATIN SMALL LETTER I WITH GRAVE
-0xED	0x00ED	#LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x011F	#LATIN SMALL LETTER G WITH BREVE
-0xF1	0x00F1	#LATIN SMALL LETTER N WITH TILDE
-0xF2	0x00F2	#LATIN SMALL LETTER O WITH GRAVE
-0xF3	0x00F3	#LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x00F5	#LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x00F8	#LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x0131	#LATIN SMALL LETTER DOTLESS I
-0xFE	0x015F	#LATIN SMALL LETTER S WITH CEDILLA
-0xFF	0x00FF	#LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/lib/ucmaps/cp1255.txt b/lib/ucmaps/cp1255.txt
deleted file mode 100755
index 341517f11..000000000
--- a/lib/ucmaps/cp1255.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1255 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          1/7/2000
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1255 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1255 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x02C6	#MODIFIER LETTER CIRCUMFLEX ACCENT
-0x89	0x2030	#PER MILLE SIGN
-0x8A	      	#UNDEFINED
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	      	#UNDEFINED
-0x8D	      	#UNDEFINED
-0x8E	      	#UNDEFINED
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	0x02DC	#SMALL TILDE
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	      	#UNDEFINED
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	      	#UNDEFINED
-0x9D	      	#UNDEFINED
-0x9E	      	#UNDEFINED
-0x9F	      	#UNDEFINED
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x00A1	#INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x20AA	#NEW SHEQEL SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x00D7	#MULTIPLICATION SIGN
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00AF	#MACRON
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x00F7	#DIVISION SIGN
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#INVERTED QUESTION MARK
-0xC0	0x05B0	#HEBREW POINT SHEVA
-0xC1	0x05B1	#HEBREW POINT HATAF SEGOL
-0xC2	0x05B2	#HEBREW POINT HATAF PATAH
-0xC3	0x05B3	#HEBREW POINT HATAF QAMATS
-0xC4	0x05B4	#HEBREW POINT HIRIQ
-0xC5	0x05B5	#HEBREW POINT TSERE
-0xC6	0x05B6	#HEBREW POINT SEGOL
-0xC7	0x05B7	#HEBREW POINT PATAH
-0xC8	0x05B8	#HEBREW POINT QAMATS
-0xC9	0x05B9	#HEBREW POINT HOLAM
-0xCA		#UNDEFINED
-0xCB	0x05BB	#HEBREW POINT QUBUTS
-0xCC	0x05BC	#HEBREW POINT DAGESH OR MAPIQ
-0xCD	0x05BD	#HEBREW POINT METEG
-0xCE	0x05BE	#HEBREW PUNCTUATION MAQAF
-0xCF	0x05BF	#HEBREW POINT RAFE
-0xD0	0x05C0	#HEBREW PUNCTUATION PASEQ
-0xD1	0x05C1	#HEBREW POINT SHIN DOT
-0xD2	0x05C2	#HEBREW POINT SIN DOT
-0xD3	0x05C3	#HEBREW PUNCTUATION SOF PASUQ
-0xD4	0x05F0	#HEBREW LIGATURE YIDDISH DOUBLE VAV
-0xD5	0x05F1	#HEBREW LIGATURE YIDDISH VAV YOD
-0xD6	0x05F2	#HEBREW LIGATURE YIDDISH DOUBLE YOD
-0xD7	0x05F3	#HEBREW PUNCTUATION GERESH
-0xD8	0x05F4	#HEBREW PUNCTUATION GERSHAYIM
-0xD9	      	#UNDEFINED
-0xDA	      	#UNDEFINED
-0xDB	      	#UNDEFINED
-0xDC	      	#UNDEFINED
-0xDD	      	#UNDEFINED
-0xDE	      	#UNDEFINED
-0xDF	      	#UNDEFINED
-0xE0	0x05D0	#HEBREW LETTER ALEF
-0xE1	0x05D1	#HEBREW LETTER BET
-0xE2	0x05D2	#HEBREW LETTER GIMEL
-0xE3	0x05D3	#HEBREW LETTER DALET
-0xE4	0x05D4	#HEBREW LETTER HE
-0xE5	0x05D5	#HEBREW LETTER VAV
-0xE6	0x05D6	#HEBREW LETTER ZAYIN
-0xE7	0x05D7	#HEBREW LETTER HET
-0xE8	0x05D8	#HEBREW LETTER TET
-0xE9	0x05D9	#HEBREW LETTER YOD
-0xEA	0x05DA	#HEBREW LETTER FINAL KAF
-0xEB	0x05DB	#HEBREW LETTER KAF
-0xEC	0x05DC	#HEBREW LETTER LAMED
-0xED	0x05DD	#HEBREW LETTER FINAL MEM
-0xEE	0x05DE	#HEBREW LETTER MEM
-0xEF	0x05DF	#HEBREW LETTER FINAL NUN
-0xF0	0x05E0	#HEBREW LETTER NUN
-0xF1	0x05E1	#HEBREW LETTER SAMEKH
-0xF2	0x05E2	#HEBREW LETTER AYIN
-0xF3	0x05E3	#HEBREW LETTER FINAL PE
-0xF4	0x05E4	#HEBREW LETTER PE
-0xF5	0x05E5	#HEBREW LETTER FINAL TSADI
-0xF6	0x05E6	#HEBREW LETTER TSADI
-0xF7	0x05E7	#HEBREW LETTER QOF
-0xF8	0x05E8	#HEBREW LETTER RESH
-0xF9	0x05E9	#HEBREW LETTER SHIN
-0xFA	0x05EA	#HEBREW LETTER TAV
-0xFB	      	#UNDEFINED
-0xFC	      	#UNDEFINED
-0xFD	0x200E	#LEFT-TO-RIGHT MARK
-0xFE	0x200F	#RIGHT-TO-LEFT MARK
-0xFF	      	#UNDEFINED
diff --git a/lib/ucmaps/cp1256.txt b/lib/ucmaps/cp1256.txt
deleted file mode 100755
index 0edd081b9..000000000
--- a/lib/ucmaps/cp1256.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1256 to Unicode table
-#    Unicode version: 2.1
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          01/5/99
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1256 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1256 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	0x067E	#ARABIC LETTER PEH
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x02C6	#MODIFIER LETTER CIRCUMFLEX ACCENT
-0x89	0x2030	#PER MILLE SIGN
-0x8A	0x0679	#ARABIC LETTER TTEH
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x0152	#LATIN CAPITAL LIGATURE OE
-0x8D	0x0686	#ARABIC LETTER TCHEH
-0x8E	0x0698	#ARABIC LETTER JEH
-0x8F	0x0688	#ARABIC LETTER DDAL
-0x90	0x06AF	#ARABIC LETTER GAF
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	0x06A9	#ARABIC LETTER KEHEH
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	0x0691	#ARABIC LETTER RREH
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x0153	#LATIN SMALL LIGATURE OE
-0x9D	0x200C	#ZERO WIDTH NON-JOINER
-0x9E	0x200D	#ZERO WIDTH JOINER
-0x9F	0x06BA	#ARABIC LETTER NOON GHUNNA
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x060C	#ARABIC COMMA
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x06BE	#ARABIC LETTER HEH DOACHASHMEE
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00AF	#MACRON
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x061B	#ARABIC SEMICOLON
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x061F	#ARABIC QUESTION MARK
-0xC0	0x06C1	#ARABIC LETTER HEH GOAL
-0xC1	0x0621	#ARABIC LETTER HAMZA
-0xC2	0x0622	#ARABIC LETTER ALEF WITH MADDA ABOVE
-0xC3	0x0623	#ARABIC LETTER ALEF WITH HAMZA ABOVE
-0xC4	0x0624	#ARABIC LETTER WAW WITH HAMZA ABOVE
-0xC5	0x0625	#ARABIC LETTER ALEF WITH HAMZA BELOW
-0xC6	0x0626	#ARABIC LETTER YEH WITH HAMZA ABOVE
-0xC7	0x0627	#ARABIC LETTER ALEF
-0xC8	0x0628	#ARABIC LETTER BEH
-0xC9	0x0629	#ARABIC LETTER TEH MARBUTA
-0xCA	0x062A	#ARABIC LETTER TEH
-0xCB	0x062B	#ARABIC LETTER THEH
-0xCC	0x062C	#ARABIC LETTER JEEM
-0xCD	0x062D	#ARABIC LETTER HAH
-0xCE	0x062E	#ARABIC LETTER KHAH
-0xCF	0x062F	#ARABIC LETTER DAL
-0xD0	0x0630	#ARABIC LETTER THAL
-0xD1	0x0631	#ARABIC LETTER REH
-0xD2	0x0632	#ARABIC LETTER ZAIN
-0xD3	0x0633	#ARABIC LETTER SEEN
-0xD4	0x0634	#ARABIC LETTER SHEEN
-0xD5	0x0635	#ARABIC LETTER SAD
-0xD6	0x0636	#ARABIC LETTER DAD
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x0637	#ARABIC LETTER TAH
-0xD9	0x0638	#ARABIC LETTER ZAH
-0xDA	0x0639	#ARABIC LETTER AIN
-0xDB	0x063A	#ARABIC LETTER GHAIN
-0xDC	0x0640	#ARABIC TATWEEL
-0xDD	0x0641	#ARABIC LETTER FEH
-0xDE	0x0642	#ARABIC LETTER QAF
-0xDF	0x0643	#ARABIC LETTER KAF
-0xE0	0x00E0	#LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x0644	#ARABIC LETTER LAM
-0xE2	0x00E2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x0645	#ARABIC LETTER MEEM
-0xE4	0x0646	#ARABIC LETTER NOON
-0xE5	0x0647	#ARABIC LETTER HEH
-0xE6	0x0648	#ARABIC LETTER WAW
-0xE7	0x00E7	#LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x0649	#ARABIC LETTER ALEF MAKSURA
-0xED	0x064A	#ARABIC LETTER YEH
-0xEE	0x00EE	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x064B	#ARABIC FATHATAN
-0xF1	0x064C	#ARABIC DAMMATAN
-0xF2	0x064D	#ARABIC KASRATAN
-0xF3	0x064E	#ARABIC FATHA
-0xF4	0x00F4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x064F	#ARABIC DAMMA
-0xF6	0x0650	#ARABIC KASRA
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x0651	#ARABIC SHADDA
-0xF9	0x00F9	#LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x0652	#ARABIC SUKUN
-0xFB	0x00FB	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x200E	#LEFT-TO-RIGHT MARK
-0xFE	0x200F	#RIGHT-TO-LEFT MARK
-0xFF	0x06D2	#ARABIC LETTER YEH BARREE
diff --git a/lib/ucmaps/cp1257.txt b/lib/ucmaps/cp1257.txt
deleted file mode 100755
index 97979d931..000000000
--- a/lib/ucmaps/cp1257.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1257 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1257 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1257 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	      	#UNDEFINED
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	      	#UNDEFINED
-0x89	0x2030	#PER MILLE SIGN
-0x8A	      	#UNDEFINED
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	      	#UNDEFINED
-0x8D	0x00A8	#DIAERESIS
-0x8E	0x02C7	#CARON
-0x8F	0x00B8	#CEDILLA
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	      	#UNDEFINED
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	      	#UNDEFINED
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	      	#UNDEFINED
-0x9D	0x00AF	#MACRON
-0x9E	0x02DB	#OGONEK
-0x9F	      	#UNDEFINED
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	      	#UNDEFINED
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	      	#UNDEFINED
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00D8	#LATIN CAPITAL LETTER O WITH STROKE
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x0156	#LATIN CAPITAL LETTER R WITH CEDILLA
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00C6	#LATIN CAPITAL LETTER AE
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00F8	#LATIN SMALL LETTER O WITH STROKE
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x0157	#LATIN SMALL LETTER R WITH CEDILLA
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x00E6	#LATIN SMALL LETTER AE
-0xC0	0x0104	#LATIN CAPITAL LETTER A WITH OGONEK
-0xC1	0x012E	#LATIN CAPITAL LETTER I WITH OGONEK
-0xC2	0x0100	#LATIN CAPITAL LETTER A WITH MACRON
-0xC3	0x0106	#LATIN CAPITAL LETTER C WITH ACUTE
-0xC4	0x00C4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x0118	#LATIN CAPITAL LETTER E WITH OGONEK
-0xC7	0x0112	#LATIN CAPITAL LETTER E WITH MACRON
-0xC8	0x010C	#LATIN CAPITAL LETTER C WITH CARON
-0xC9	0x00C9	#LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x0179	#LATIN CAPITAL LETTER Z WITH ACUTE
-0xCB	0x0116	#LATIN CAPITAL LETTER E WITH DOT ABOVE
-0xCC	0x0122	#LATIN CAPITAL LETTER G WITH CEDILLA
-0xCD	0x0136	#LATIN CAPITAL LETTER K WITH CEDILLA
-0xCE	0x012A	#LATIN CAPITAL LETTER I WITH MACRON
-0xCF	0x013B	#LATIN CAPITAL LETTER L WITH CEDILLA
-0xD0	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0xD1	0x0143	#LATIN CAPITAL LETTER N WITH ACUTE
-0xD2	0x0145	#LATIN CAPITAL LETTER N WITH CEDILLA
-0xD3	0x00D3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x014C	#LATIN CAPITAL LETTER O WITH MACRON
-0xD5	0x00D5	#LATIN CAPITAL LETTER O WITH TILDE
-0xD6	0x00D6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x0172	#LATIN CAPITAL LETTER U WITH OGONEK
-0xD9	0x0141	#LATIN CAPITAL LETTER L WITH STROKE
-0xDA	0x015A	#LATIN CAPITAL LETTER S WITH ACUTE
-0xDB	0x016A	#LATIN CAPITAL LETTER U WITH MACRON
-0xDC	0x00DC	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x017B	#LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xDE	0x017D	#LATIN CAPITAL LETTER Z WITH CARON
-0xDF	0x00DF	#LATIN SMALL LETTER SHARP S
-0xE0	0x0105	#LATIN SMALL LETTER A WITH OGONEK
-0xE1	0x012F	#LATIN SMALL LETTER I WITH OGONEK
-0xE2	0x0101	#LATIN SMALL LETTER A WITH MACRON
-0xE3	0x0107	#LATIN SMALL LETTER C WITH ACUTE
-0xE4	0x00E4	#LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x0119	#LATIN SMALL LETTER E WITH OGONEK
-0xE7	0x0113	#LATIN SMALL LETTER E WITH MACRON
-0xE8	0x010D	#LATIN SMALL LETTER C WITH CARON
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x017A	#LATIN SMALL LETTER Z WITH ACUTE
-0xEB	0x0117	#LATIN SMALL LETTER E WITH DOT ABOVE
-0xEC	0x0123	#LATIN SMALL LETTER G WITH CEDILLA
-0xED	0x0137	#LATIN SMALL LETTER K WITH CEDILLA
-0xEE	0x012B	#LATIN SMALL LETTER I WITH MACRON
-0xEF	0x013C	#LATIN SMALL LETTER L WITH CEDILLA
-0xF0	0x0161	#LATIN SMALL LETTER S WITH CARON
-0xF1	0x0144	#LATIN SMALL LETTER N WITH ACUTE
-0xF2	0x0146	#LATIN SMALL LETTER N WITH CEDILLA
-0xF3	0x00F3	#LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x014D	#LATIN SMALL LETTER O WITH MACRON
-0xF5	0x00F5	#LATIN SMALL LETTER O WITH TILDE
-0xF6	0x00F6	#LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x0173	#LATIN SMALL LETTER U WITH OGONEK
-0xF9	0x0142	#LATIN SMALL LETTER L WITH STROKE
-0xFA	0x015B	#LATIN SMALL LETTER S WITH ACUTE
-0xFB	0x016B	#LATIN SMALL LETTER U WITH MACRON
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x017C	#LATIN SMALL LETTER Z WITH DOT ABOVE
-0xFE	0x017E	#LATIN SMALL LETTER Z WITH CARON
-0xFF	0x02D9	#DOT ABOVE
diff --git a/lib/ucmaps/cp1258.txt b/lib/ucmaps/cp1258.txt
deleted file mode 100755
index 392310a8c..000000000
--- a/lib/ucmaps/cp1258.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp1258 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp1258 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp1258 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	0x201A	#SINGLE LOW-9 QUOTATION MARK
-0x83	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0x84	0x201E	#DOUBLE LOW-9 QUOTATION MARK
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	0x2020	#DAGGER
-0x87	0x2021	#DOUBLE DAGGER
-0x88	0x02C6	#MODIFIER LETTER CIRCUMFLEX ACCENT
-0x89	0x2030	#PER MILLE SIGN
-0x8A	      	#UNDEFINED
-0x8B	0x2039	#SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-0x8C	0x0152	#LATIN CAPITAL LIGATURE OE
-0x8D	      	#UNDEFINED
-0x8E	      	#UNDEFINED
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	0x02DC	#SMALL TILDE
-0x99	0x2122	#TRADE MARK SIGN
-0x9A	      	#UNDEFINED
-0x9B	0x203A	#SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-0x9C	0x0153	#LATIN SMALL LIGATURE OE
-0x9D	      	#UNDEFINED
-0x9E	      	#UNDEFINED
-0x9F	0x0178	#LATIN CAPITAL LETTER Y WITH DIAERESIS
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x00A1	#INVERTED EXCLAMATION MARK
-0xA2	0x00A2	#CENT SIGN
-0xA3	0x00A3	#POUND SIGN
-0xA4	0x00A4	#CURRENCY SIGN
-0xA5	0x00A5	#YEN SIGN
-0xA6	0x00A6	#BROKEN BAR
-0xA7	0x00A7	#SECTION SIGN
-0xA8	0x00A8	#DIAERESIS
-0xA9	0x00A9	#COPYRIGHT SIGN
-0xAA	0x00AA	#FEMININE ORDINAL INDICATOR
-0xAB	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAC	0x00AC	#NOT SIGN
-0xAD	0x00AD	#SOFT HYPHEN
-0xAE	0x00AE	#REGISTERED SIGN
-0xAF	0x00AF	#MACRON
-0xB0	0x00B0	#DEGREE SIGN
-0xB1	0x00B1	#PLUS-MINUS SIGN
-0xB2	0x00B2	#SUPERSCRIPT TWO
-0xB3	0x00B3	#SUPERSCRIPT THREE
-0xB4	0x00B4	#ACUTE ACCENT
-0xB5	0x00B5	#MICRO SIGN
-0xB6	0x00B6	#PILCROW SIGN
-0xB7	0x00B7	#MIDDLE DOT
-0xB8	0x00B8	#CEDILLA
-0xB9	0x00B9	#SUPERSCRIPT ONE
-0xBA	0x00BA	#MASCULINE ORDINAL INDICATOR
-0xBB	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xBC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xBD	0x00BD	#VULGAR FRACTION ONE HALF
-0xBE	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xBF	0x00BF	#INVERTED QUESTION MARK
-0xC0	0x00C0	#LATIN CAPITAL LETTER A WITH GRAVE
-0xC1	0x00C1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xC2	0x00C2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xC3	0x0102	#LATIN CAPITAL LETTER A WITH BREVE
-0xC4	0x00C4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0xC5	0x00C5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0xC6	0x00C6	#LATIN CAPITAL LETTER AE
-0xC7	0x00C7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0xC8	0x00C8	#LATIN CAPITAL LETTER E WITH GRAVE
-0xC9	0x00C9	#LATIN CAPITAL LETTER E WITH ACUTE
-0xCA	0x00CA	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xCB	0x00CB	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xCC	0x0300	#COMBINING GRAVE ACCENT
-0xCD	0x00CD	#LATIN CAPITAL LETTER I WITH ACUTE
-0xCE	0x00CE	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xCF	0x00CF	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0xD0	0x0110	#LATIN CAPITAL LETTER D WITH STROKE
-0xD1	0x00D1	#LATIN CAPITAL LETTER N WITH TILDE
-0xD2	0x0309	#COMBINING HOOK ABOVE
-0xD3	0x00D3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xD4	0x00D4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xD5	0x01A0	#LATIN CAPITAL LETTER O WITH HORN
-0xD6	0x00D6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0xD7	0x00D7	#MULTIPLICATION SIGN
-0xD8	0x00D8	#LATIN CAPITAL LETTER O WITH STROKE
-0xD9	0x00D9	#LATIN CAPITAL LETTER U WITH GRAVE
-0xDA	0x00DA	#LATIN CAPITAL LETTER U WITH ACUTE
-0xDB	0x00DB	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xDC	0x00DC	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0xDD	0x01AF	#LATIN CAPITAL LETTER U WITH HORN
-0xDE	0x0303	#COMBINING TILDE
-0xDF	0x00DF	#LATIN SMALL LETTER SHARP S
-0xE0	0x00E0	#LATIN SMALL LETTER A WITH GRAVE
-0xE1	0x00E1	#LATIN SMALL LETTER A WITH ACUTE
-0xE2	0x00E2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0xE3	0x0103	#LATIN SMALL LETTER A WITH BREVE
-0xE4	0x00E4	#LATIN SMALL LETTER A WITH DIAERESIS
-0xE5	0x00E5	#LATIN SMALL LETTER A WITH RING ABOVE
-0xE6	0x00E6	#LATIN SMALL LETTER AE
-0xE7	0x00E7	#LATIN SMALL LETTER C WITH CEDILLA
-0xE8	0x00E8	#LATIN SMALL LETTER E WITH GRAVE
-0xE9	0x00E9	#LATIN SMALL LETTER E WITH ACUTE
-0xEA	0x00EA	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0xEB	0x00EB	#LATIN SMALL LETTER E WITH DIAERESIS
-0xEC	0x0301	#COMBINING ACUTE ACCENT
-0xED	0x00ED	#LATIN SMALL LETTER I WITH ACUTE
-0xEE	0x00EE	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0xEF	0x00EF	#LATIN SMALL LETTER I WITH DIAERESIS
-0xF0	0x0111	#LATIN SMALL LETTER D WITH STROKE
-0xF1	0x00F1	#LATIN SMALL LETTER N WITH TILDE
-0xF2	0x0323	#COMBINING DOT BELOW
-0xF3	0x00F3	#LATIN SMALL LETTER O WITH ACUTE
-0xF4	0x00F4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0xF5	0x01A1	#LATIN SMALL LETTER O WITH HORN
-0xF6	0x00F6	#LATIN SMALL LETTER O WITH DIAERESIS
-0xF7	0x00F7	#DIVISION SIGN
-0xF8	0x00F8	#LATIN SMALL LETTER O WITH STROKE
-0xF9	0x00F9	#LATIN SMALL LETTER U WITH GRAVE
-0xFA	0x00FA	#LATIN SMALL LETTER U WITH ACUTE
-0xFB	0x00FB	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0xFC	0x00FC	#LATIN SMALL LETTER U WITH DIAERESIS
-0xFD	0x01B0	#LATIN SMALL LETTER U WITH HORN
-0xFE	0x20AB	#DONG SIGN
-0xFF	0x00FF	#LATIN SMALL LETTER Y WITH DIAERESIS
diff --git a/lib/ucmaps/cp437.txt b/lib/ucmaps/cp437.txt
deleted file mode 100755
index ae38e17ab..000000000
--- a/lib/ucmaps/cp437.txt
+++ /dev/null
@@ -1,273 +0,0 @@
-#
-#    Name:     cp437_DOSLatinUS to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp437_DOSLatinUS code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp437_DOSLatinUS order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00ef	#LATIN SMALL LETTER I WITH DIAERESIS
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x00ec	#LATIN SMALL LETTER I WITH GRAVE
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x00f2	#LATIN SMALL LETTER O WITH GRAVE
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x00ff	#LATIN SMALL LETTER Y WITH DIAERESIS
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00a2	#CENT SIGN
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00a5	#YEN SIGN
-0x9e	0x20a7	#PESETA SIGN
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x00aa	#FEMININE ORDINAL INDICATOR
-0xa7	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x2310	#REVERSED NOT SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
diff --git a/lib/ucmaps/cp737.txt b/lib/ucmaps/cp737.txt
deleted file mode 100755
index 0fc572fc3..000000000
--- a/lib/ucmaps/cp737.txt
+++ /dev/null
@@ -1,273 +0,0 @@
-#
-#    Name:     cp737_DOSGreek to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp737_DOSGreek code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp737_DOSGreek order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x0391	#GREEK CAPITAL LETTER ALPHA
-0x81	0x0392	#GREEK CAPITAL LETTER BETA
-0x82	0x0393	#GREEK CAPITAL LETTER GAMMA
-0x83	0x0394	#GREEK CAPITAL LETTER DELTA
-0x84	0x0395	#GREEK CAPITAL LETTER EPSILON
-0x85	0x0396	#GREEK CAPITAL LETTER ZETA
-0x86	0x0397	#GREEK CAPITAL LETTER ETA
-0x87	0x0398	#GREEK CAPITAL LETTER THETA
-0x88	0x0399	#GREEK CAPITAL LETTER IOTA
-0x89	0x039a	#GREEK CAPITAL LETTER KAPPA
-0x8a	0x039b	#GREEK CAPITAL LETTER LAMDA
-0x8b	0x039c	#GREEK CAPITAL LETTER MU
-0x8c	0x039d	#GREEK CAPITAL LETTER NU
-0x8d	0x039e	#GREEK CAPITAL LETTER XI
-0x8e	0x039f	#GREEK CAPITAL LETTER OMICRON
-0x8f	0x03a0	#GREEK CAPITAL LETTER PI
-0x90	0x03a1	#GREEK CAPITAL LETTER RHO
-0x91	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0x92	0x03a4	#GREEK CAPITAL LETTER TAU
-0x93	0x03a5	#GREEK CAPITAL LETTER UPSILON
-0x94	0x03a6	#GREEK CAPITAL LETTER PHI
-0x95	0x03a7	#GREEK CAPITAL LETTER CHI
-0x96	0x03a8	#GREEK CAPITAL LETTER PSI
-0x97	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0x98	0x03b1	#GREEK SMALL LETTER ALPHA
-0x99	0x03b2	#GREEK SMALL LETTER BETA
-0x9a	0x03b3	#GREEK SMALL LETTER GAMMA
-0x9b	0x03b4	#GREEK SMALL LETTER DELTA
-0x9c	0x03b5	#GREEK SMALL LETTER EPSILON
-0x9d	0x03b6	#GREEK SMALL LETTER ZETA
-0x9e	0x03b7	#GREEK SMALL LETTER ETA
-0x9f	0x03b8	#GREEK SMALL LETTER THETA
-0xa0	0x03b9	#GREEK SMALL LETTER IOTA
-0xa1	0x03ba	#GREEK SMALL LETTER KAPPA
-0xa2	0x03bb	#GREEK SMALL LETTER LAMDA
-0xa3	0x03bc	#GREEK SMALL LETTER MU
-0xa4	0x03bd	#GREEK SMALL LETTER NU
-0xa5	0x03be	#GREEK SMALL LETTER XI
-0xa6	0x03bf	#GREEK SMALL LETTER OMICRON
-0xa7	0x03c0	#GREEK SMALL LETTER PI
-0xa8	0x03c1	#GREEK SMALL LETTER RHO
-0xa9	0x03c3	#GREEK SMALL LETTER SIGMA
-0xaa	0x03c2	#GREEK SMALL LETTER FINAL SIGMA
-0xab	0x03c4	#GREEK SMALL LETTER TAU
-0xac	0x03c5	#GREEK SMALL LETTER UPSILON
-0xad	0x03c6	#GREEK SMALL LETTER PHI
-0xae	0x03c7	#GREEK SMALL LETTER CHI
-0xaf	0x03c8	#GREEK SMALL LETTER PSI
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03c9	#GREEK SMALL LETTER OMEGA
-0xe1	0x03ac	#GREEK SMALL LETTER ALPHA WITH TONOS
-0xe2	0x03ad	#GREEK SMALL LETTER EPSILON WITH TONOS
-0xe3	0x03ae	#GREEK SMALL LETTER ETA WITH TONOS
-0xe4	0x03ca	#GREEK SMALL LETTER IOTA WITH DIALYTIKA
-0xe5	0x03af	#GREEK SMALL LETTER IOTA WITH TONOS
-0xe6	0x03cc	#GREEK SMALL LETTER OMICRON WITH TONOS
-0xe7	0x03cd	#GREEK SMALL LETTER UPSILON WITH TONOS
-0xe8	0x03cb	#GREEK SMALL LETTER UPSILON WITH DIALYTIKA
-0xe9	0x03ce	#GREEK SMALL LETTER OMEGA WITH TONOS
-0xea	0x0386	#GREEK CAPITAL LETTER ALPHA WITH TONOS
-0xeb	0x0388	#GREEK CAPITAL LETTER EPSILON WITH TONOS
-0xec	0x0389	#GREEK CAPITAL LETTER ETA WITH TONOS
-0xed	0x038a	#GREEK CAPITAL LETTER IOTA WITH TONOS
-0xee	0x038c	#GREEK CAPITAL LETTER OMICRON WITH TONOS
-0xef	0x038e	#GREEK CAPITAL LETTER UPSILON WITH TONOS
-0xf0	0x038f	#GREEK CAPITAL LETTER OMEGA WITH TONOS
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x03aa	#GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
-0xf5	0x03ab	#GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
diff --git a/lib/ucmaps/cp775.txt b/lib/ucmaps/cp775.txt
deleted file mode 100755
index 1ad4e4e58..000000000
--- a/lib/ucmaps/cp775.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp775_DOSBaltRim to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp775_DOSBaltRim code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp775_DOSBaltRim order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x0106	#LATIN CAPITAL LETTER C WITH ACUTE
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x0101	#LATIN SMALL LETTER A WITH MACRON
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x0123	#LATIN SMALL LETTER G WITH CEDILLA
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x0107	#LATIN SMALL LETTER C WITH ACUTE
-0x88	0x0142	#LATIN SMALL LETTER L WITH STROKE
-0x89	0x0113	#LATIN SMALL LETTER E WITH MACRON
-0x8a	0x0156	#LATIN CAPITAL LETTER R WITH CEDILLA
-0x8b	0x0157	#LATIN SMALL LETTER R WITH CEDILLA
-0x8c	0x012b	#LATIN SMALL LETTER I WITH MACRON
-0x8d	0x0179	#LATIN CAPITAL LETTER Z WITH ACUTE
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x014d	#LATIN SMALL LETTER O WITH MACRON
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x0122	#LATIN CAPITAL LETTER G WITH CEDILLA
-0x96	0x00a2	#CENT SIGN
-0x97	0x015a	#LATIN CAPITAL LETTER S WITH ACUTE
-0x98	0x015b	#LATIN SMALL LETTER S WITH ACUTE
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00f8	#LATIN SMALL LETTER O WITH STROKE
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d8	#LATIN CAPITAL LETTER O WITH STROKE
-0x9e	0x00d7	#MULTIPLICATION SIGN
-0x9f	0x00a4	#CURRENCY SIGN
-0xa0	0x0100	#LATIN CAPITAL LETTER A WITH MACRON
-0xa1	0x012a	#LATIN CAPITAL LETTER I WITH MACRON
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x017b	#LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xa4	0x017c	#LATIN SMALL LETTER Z WITH DOT ABOVE
-0xa5	0x017a	#LATIN SMALL LETTER Z WITH ACUTE
-0xa6	0x201d	#RIGHT DOUBLE QUOTATION MARK
-0xa7	0x00a6	#BROKEN BAR
-0xa8	0x00a9	#COPYRIGHT SIGN
-0xa9	0x00ae	#REGISTERED SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x0141	#LATIN CAPITAL LETTER L WITH STROKE
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x0104	#LATIN CAPITAL LETTER A WITH OGONEK
-0xb6	0x010c	#LATIN CAPITAL LETTER C WITH CARON
-0xb7	0x0118	#LATIN CAPITAL LETTER E WITH OGONEK
-0xb8	0x0116	#LATIN CAPITAL LETTER E WITH DOT ABOVE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x012e	#LATIN CAPITAL LETTER I WITH OGONEK
-0xbe	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x0172	#LATIN CAPITAL LETTER U WITH OGONEK
-0xc7	0x016a	#LATIN CAPITAL LETTER U WITH MACRON
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x017d	#LATIN CAPITAL LETTER Z WITH CARON
-0xd0	0x0105	#LATIN SMALL LETTER A WITH OGONEK
-0xd1	0x010d	#LATIN SMALL LETTER C WITH CARON
-0xd2	0x0119	#LATIN SMALL LETTER E WITH OGONEK
-0xd3	0x0117	#LATIN SMALL LETTER E WITH DOT ABOVE
-0xd4	0x012f	#LATIN SMALL LETTER I WITH OGONEK
-0xd5	0x0161	#LATIN SMALL LETTER S WITH CARON
-0xd6	0x0173	#LATIN SMALL LETTER U WITH OGONEK
-0xd7	0x016b	#LATIN SMALL LETTER U WITH MACRON
-0xd8	0x017e	#LATIN SMALL LETTER Z WITH CARON
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S (GERMAN)
-0xe2	0x014c	#LATIN CAPITAL LETTER O WITH MACRON
-0xe3	0x0143	#LATIN CAPITAL LETTER N WITH ACUTE
-0xe4	0x00f5	#LATIN SMALL LETTER O WITH TILDE
-0xe5	0x00d5	#LATIN CAPITAL LETTER O WITH TILDE
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x0144	#LATIN SMALL LETTER N WITH ACUTE
-0xe8	0x0136	#LATIN CAPITAL LETTER K WITH CEDILLA
-0xe9	0x0137	#LATIN SMALL LETTER K WITH CEDILLA
-0xea	0x013b	#LATIN CAPITAL LETTER L WITH CEDILLA
-0xeb	0x013c	#LATIN SMALL LETTER L WITH CEDILLA
-0xec	0x0146	#LATIN SMALL LETTER N WITH CEDILLA
-0xed	0x0112	#LATIN CAPITAL LETTER E WITH MACRON
-0xee	0x0145	#LATIN CAPITAL LETTER N WITH CEDILLA
-0xef	0x2019	#RIGHT SINGLE QUOTATION MARK
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x201c	#LEFT DOUBLE QUOTATION MARK
-0xf3	0x00be	#VULGAR FRACTION THREE QUARTERS
-0xf4	0x00b6	#PILCROW SIGN
-0xf5	0x00a7	#SECTION SIGN
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x201e	#DOUBLE LOW-9 QUOTATION MARK
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x00b9	#SUPERSCRIPT ONE
-0xfc	0x00b3	#SUPERSCRIPT THREE
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp850.txt b/lib/ucmaps/cp850.txt
deleted file mode 100755
index 590b1afe5..000000000
--- a/lib/ucmaps/cp850.txt
+++ /dev/null
@@ -1,273 +0,0 @@
-#
-#    Name:     cp850_DOSLatin1 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp850_DOSLatin1 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp850_DOSLatin1 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00ef	#LATIN SMALL LETTER I WITH DIAERESIS
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x00ec	#LATIN SMALL LETTER I WITH GRAVE
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x00f2	#LATIN SMALL LETTER O WITH GRAVE
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x00ff	#LATIN SMALL LETTER Y WITH DIAERESIS
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00f8	#LATIN SMALL LETTER O WITH STROKE
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d8	#LATIN CAPITAL LETTER O WITH STROKE
-0x9e	0x00d7	#MULTIPLICATION SIGN
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x00aa	#FEMININE ORDINAL INDICATOR
-0xa7	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x00ae	#REGISTERED SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x00c1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xb6	0x00c2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xb7	0x00c0	#LATIN CAPITAL LETTER A WITH GRAVE
-0xb8	0x00a9	#COPYRIGHT SIGN
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x00a2	#CENT SIGN
-0xbe	0x00a5	#YEN SIGN
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x00e3	#LATIN SMALL LETTER A WITH TILDE
-0xc7	0x00c3	#LATIN CAPITAL LETTER A WITH TILDE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x00a4	#CURRENCY SIGN
-0xd0	0x00f0	#LATIN SMALL LETTER ETH
-0xd1	0x00d0	#LATIN CAPITAL LETTER ETH
-0xd2	0x00ca	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xd3	0x00cb	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xd4	0x00c8	#LATIN CAPITAL LETTER E WITH GRAVE
-0xd5	0x0131	#LATIN SMALL LETTER DOTLESS I
-0xd6	0x00cd	#LATIN CAPITAL LETTER I WITH ACUTE
-0xd7	0x00ce	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xd8	0x00cf	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x00a6	#BROKEN BAR
-0xde	0x00cc	#LATIN CAPITAL LETTER I WITH GRAVE
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x00d4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xe3	0x00d2	#LATIN CAPITAL LETTER O WITH GRAVE
-0xe4	0x00f5	#LATIN SMALL LETTER O WITH TILDE
-0xe5	0x00d5	#LATIN CAPITAL LETTER O WITH TILDE
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x00fe	#LATIN SMALL LETTER THORN
-0xe8	0x00de	#LATIN CAPITAL LETTER THORN
-0xe9	0x00da	#LATIN CAPITAL LETTER U WITH ACUTE
-0xea	0x00db	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xeb	0x00d9	#LATIN CAPITAL LETTER U WITH GRAVE
-0xec	0x00fd	#LATIN SMALL LETTER Y WITH ACUTE
-0xed	0x00dd	#LATIN CAPITAL LETTER Y WITH ACUTE
-0xee	0x00af	#MACRON
-0xef	0x00b4	#ACUTE ACCENT
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2017	#DOUBLE LOW LINE
-0xf3	0x00be	#VULGAR FRACTION THREE QUARTERS
-0xf4	0x00b6	#PILCROW SIGN
-0xf5	0x00a7	#SECTION SIGN
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x00b8	#CEDILLA
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x00a8	#DIAERESIS
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x00b9	#SUPERSCRIPT ONE
-0xfc	0x00b3	#SUPERSCRIPT THREE
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
diff --git a/lib/ucmaps/cp852.txt b/lib/ucmaps/cp852.txt
deleted file mode 100755
index 2f2dabaeb..000000000
--- a/lib/ucmaps/cp852.txt
+++ /dev/null
@@ -1,273 +0,0 @@
-#
-#    Name:     cp852_DOSLatin2 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp852_DOSLatin2 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp852_DOSLatin2 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x016f	#LATIN SMALL LETTER U WITH RING ABOVE
-0x86	0x0107	#LATIN SMALL LETTER C WITH ACUTE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x0142	#LATIN SMALL LETTER L WITH STROKE
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x0150	#LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
-0x8b	0x0151	#LATIN SMALL LETTER O WITH DOUBLE ACUTE
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x0179	#LATIN CAPITAL LETTER Z WITH ACUTE
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x0106	#LATIN CAPITAL LETTER C WITH ACUTE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x0139	#LATIN CAPITAL LETTER L WITH ACUTE
-0x92	0x013a	#LATIN SMALL LETTER L WITH ACUTE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x013d	#LATIN CAPITAL LETTER L WITH CARON
-0x96	0x013e	#LATIN SMALL LETTER L WITH CARON
-0x97	0x015a	#LATIN CAPITAL LETTER S WITH ACUTE
-0x98	0x015b	#LATIN SMALL LETTER S WITH ACUTE
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x0164	#LATIN CAPITAL LETTER T WITH CARON
-0x9c	0x0165	#LATIN SMALL LETTER T WITH CARON
-0x9d	0x0141	#LATIN CAPITAL LETTER L WITH STROKE
-0x9e	0x00d7	#MULTIPLICATION SIGN
-0x9f	0x010d	#LATIN SMALL LETTER C WITH CARON
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x0104	#LATIN CAPITAL LETTER A WITH OGONEK
-0xa5	0x0105	#LATIN SMALL LETTER A WITH OGONEK
-0xa6	0x017d	#LATIN CAPITAL LETTER Z WITH CARON
-0xa7	0x017e	#LATIN SMALL LETTER Z WITH CARON
-0xa8	0x0118	#LATIN CAPITAL LETTER E WITH OGONEK
-0xa9	0x0119	#LATIN SMALL LETTER E WITH OGONEK
-0xaa	0x00ac	#NOT SIGN
-0xab	0x017a	#LATIN SMALL LETTER Z WITH ACUTE
-0xac	0x010c	#LATIN CAPITAL LETTER C WITH CARON
-0xad	0x015f	#LATIN SMALL LETTER S WITH CEDILLA
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x00c1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xb6	0x00c2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xb7	0x011a	#LATIN CAPITAL LETTER E WITH CARON
-0xb8	0x015e	#LATIN CAPITAL LETTER S WITH CEDILLA
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x017b	#LATIN CAPITAL LETTER Z WITH DOT ABOVE
-0xbe	0x017c	#LATIN SMALL LETTER Z WITH DOT ABOVE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x0102	#LATIN CAPITAL LETTER A WITH BREVE
-0xc7	0x0103	#LATIN SMALL LETTER A WITH BREVE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x00a4	#CURRENCY SIGN
-0xd0	0x0111	#LATIN SMALL LETTER D WITH STROKE
-0xd1	0x0110	#LATIN CAPITAL LETTER D WITH STROKE
-0xd2	0x010e	#LATIN CAPITAL LETTER D WITH CARON
-0xd3	0x00cb	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xd4	0x010f	#LATIN SMALL LETTER D WITH CARON
-0xd5	0x0147	#LATIN CAPITAL LETTER N WITH CARON
-0xd6	0x00cd	#LATIN CAPITAL LETTER I WITH ACUTE
-0xd7	0x00ce	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xd8	0x011b	#LATIN SMALL LETTER E WITH CARON
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x0162	#LATIN CAPITAL LETTER T WITH CEDILLA
-0xde	0x016e	#LATIN CAPITAL LETTER U WITH RING ABOVE
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x00d4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xe3	0x0143	#LATIN CAPITAL LETTER N WITH ACUTE
-0xe4	0x0144	#LATIN SMALL LETTER N WITH ACUTE
-0xe5	0x0148	#LATIN SMALL LETTER N WITH CARON
-0xe6	0x0160	#LATIN CAPITAL LETTER S WITH CARON
-0xe7	0x0161	#LATIN SMALL LETTER S WITH CARON
-0xe8	0x0154	#LATIN CAPITAL LETTER R WITH ACUTE
-0xe9	0x00da	#LATIN CAPITAL LETTER U WITH ACUTE
-0xea	0x0155	#LATIN SMALL LETTER R WITH ACUTE
-0xeb	0x0170	#LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
-0xec	0x00fd	#LATIN SMALL LETTER Y WITH ACUTE
-0xed	0x00dd	#LATIN CAPITAL LETTER Y WITH ACUTE
-0xee	0x0163	#LATIN SMALL LETTER T WITH CEDILLA
-0xef	0x00b4	#ACUTE ACCENT
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x02dd	#DOUBLE ACUTE ACCENT
-0xf2	0x02db	#OGONEK
-0xf3	0x02c7	#CARON
-0xf4	0x02d8	#BREVE
-0xf5	0x00a7	#SECTION SIGN
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x00b8	#CEDILLA
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x00a8	#DIAERESIS
-0xfa	0x02d9	#DOT ABOVE
-0xfb	0x0171	#LATIN SMALL LETTER U WITH DOUBLE ACUTE
-0xfc	0x0158	#LATIN CAPITAL LETTER R WITH CARON
-0xfd	0x0159	#LATIN SMALL LETTER R WITH CARON
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
diff --git a/lib/ucmaps/cp855.txt b/lib/ucmaps/cp855.txt
deleted file mode 100755
index d43daf039..000000000
--- a/lib/ucmaps/cp855.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp855_DOSCyrillic to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp855_DOSCyrillic code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp855_DOSCyrillic order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x0452	#CYRILLIC SMALL LETTER DJE
-0x81	0x0402	#CYRILLIC CAPITAL LETTER DJE
-0x82	0x0453	#CYRILLIC SMALL LETTER GJE
-0x83	0x0403	#CYRILLIC CAPITAL LETTER GJE
-0x84	0x0451	#CYRILLIC SMALL LETTER IO
-0x85	0x0401	#CYRILLIC CAPITAL LETTER IO
-0x86	0x0454	#CYRILLIC SMALL LETTER UKRAINIAN IE
-0x87	0x0404	#CYRILLIC CAPITAL LETTER UKRAINIAN IE
-0x88	0x0455	#CYRILLIC SMALL LETTER DZE
-0x89	0x0405	#CYRILLIC CAPITAL LETTER DZE
-0x8a	0x0456	#CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
-0x8b	0x0406	#CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
-0x8c	0x0457	#CYRILLIC SMALL LETTER YI
-0x8d	0x0407	#CYRILLIC CAPITAL LETTER YI
-0x8e	0x0458	#CYRILLIC SMALL LETTER JE
-0x8f	0x0408	#CYRILLIC CAPITAL LETTER JE
-0x90	0x0459	#CYRILLIC SMALL LETTER LJE
-0x91	0x0409	#CYRILLIC CAPITAL LETTER LJE
-0x92	0x045a	#CYRILLIC SMALL LETTER NJE
-0x93	0x040a	#CYRILLIC CAPITAL LETTER NJE
-0x94	0x045b	#CYRILLIC SMALL LETTER TSHE
-0x95	0x040b	#CYRILLIC CAPITAL LETTER TSHE
-0x96	0x045c	#CYRILLIC SMALL LETTER KJE
-0x97	0x040c	#CYRILLIC CAPITAL LETTER KJE
-0x98	0x045e	#CYRILLIC SMALL LETTER SHORT U
-0x99	0x040e	#CYRILLIC CAPITAL LETTER SHORT U
-0x9a	0x045f	#CYRILLIC SMALL LETTER DZHE
-0x9b	0x040f	#CYRILLIC CAPITAL LETTER DZHE
-0x9c	0x044e	#CYRILLIC SMALL LETTER YU
-0x9d	0x042e	#CYRILLIC CAPITAL LETTER YU
-0x9e	0x044a	#CYRILLIC SMALL LETTER HARD SIGN
-0x9f	0x042a	#CYRILLIC CAPITAL LETTER HARD SIGN
-0xa0	0x0430	#CYRILLIC SMALL LETTER A
-0xa1	0x0410	#CYRILLIC CAPITAL LETTER A
-0xa2	0x0431	#CYRILLIC SMALL LETTER BE
-0xa3	0x0411	#CYRILLIC CAPITAL LETTER BE
-0xa4	0x0446	#CYRILLIC SMALL LETTER TSE
-0xa5	0x0426	#CYRILLIC CAPITAL LETTER TSE
-0xa6	0x0434	#CYRILLIC SMALL LETTER DE
-0xa7	0x0414	#CYRILLIC CAPITAL LETTER DE
-0xa8	0x0435	#CYRILLIC SMALL LETTER IE
-0xa9	0x0415	#CYRILLIC CAPITAL LETTER IE
-0xaa	0x0444	#CYRILLIC SMALL LETTER EF
-0xab	0x0424	#CYRILLIC CAPITAL LETTER EF
-0xac	0x0433	#CYRILLIC SMALL LETTER GHE
-0xad	0x0413	#CYRILLIC CAPITAL LETTER GHE
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x0445	#CYRILLIC SMALL LETTER HA
-0xb6	0x0425	#CYRILLIC CAPITAL LETTER HA
-0xb7	0x0438	#CYRILLIC SMALL LETTER I
-0xb8	0x0418	#CYRILLIC CAPITAL LETTER I
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x0439	#CYRILLIC SMALL LETTER SHORT I
-0xbe	0x0419	#CYRILLIC CAPITAL LETTER SHORT I
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x043a	#CYRILLIC SMALL LETTER KA
-0xc7	0x041a	#CYRILLIC CAPITAL LETTER KA
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x00a4	#CURRENCY SIGN
-0xd0	0x043b	#CYRILLIC SMALL LETTER EL
-0xd1	0x041b	#CYRILLIC CAPITAL LETTER EL
-0xd2	0x043c	#CYRILLIC SMALL LETTER EM
-0xd3	0x041c	#CYRILLIC CAPITAL LETTER EM
-0xd4	0x043d	#CYRILLIC SMALL LETTER EN
-0xd5	0x041d	#CYRILLIC CAPITAL LETTER EN
-0xd6	0x043e	#CYRILLIC SMALL LETTER O
-0xd7	0x041e	#CYRILLIC CAPITAL LETTER O
-0xd8	0x043f	#CYRILLIC SMALL LETTER PE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x041f	#CYRILLIC CAPITAL LETTER PE
-0xde	0x044f	#CYRILLIC SMALL LETTER YA
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x042f	#CYRILLIC CAPITAL LETTER YA
-0xe1	0x0440	#CYRILLIC SMALL LETTER ER
-0xe2	0x0420	#CYRILLIC CAPITAL LETTER ER
-0xe3	0x0441	#CYRILLIC SMALL LETTER ES
-0xe4	0x0421	#CYRILLIC CAPITAL LETTER ES
-0xe5	0x0442	#CYRILLIC SMALL LETTER TE
-0xe6	0x0422	#CYRILLIC CAPITAL LETTER TE
-0xe7	0x0443	#CYRILLIC SMALL LETTER U
-0xe8	0x0423	#CYRILLIC CAPITAL LETTER U
-0xe9	0x0436	#CYRILLIC SMALL LETTER ZHE
-0xea	0x0416	#CYRILLIC CAPITAL LETTER ZHE
-0xeb	0x0432	#CYRILLIC SMALL LETTER VE
-0xec	0x0412	#CYRILLIC CAPITAL LETTER VE
-0xed	0x044c	#CYRILLIC SMALL LETTER SOFT SIGN
-0xee	0x042c	#CYRILLIC CAPITAL LETTER SOFT SIGN
-0xef	0x2116	#NUMERO SIGN
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x044b	#CYRILLIC SMALL LETTER YERU
-0xf2	0x042b	#CYRILLIC CAPITAL LETTER YERU
-0xf3	0x0437	#CYRILLIC SMALL LETTER ZE
-0xf4	0x0417	#CYRILLIC CAPITAL LETTER ZE
-0xf5	0x0448	#CYRILLIC SMALL LETTER SHA
-0xf6	0x0428	#CYRILLIC CAPITAL LETTER SHA
-0xf7	0x044d	#CYRILLIC SMALL LETTER E
-0xf8	0x042d	#CYRILLIC CAPITAL LETTER E
-0xf9	0x0449	#CYRILLIC SMALL LETTER SHCHA
-0xfa	0x0429	#CYRILLIC CAPITAL LETTER SHCHA
-0xfb	0x0447	#CYRILLIC SMALL LETTER CHE
-0xfc	0x0427	#CYRILLIC CAPITAL LETTER CHE
-0xfd	0x00a7	#SECTION SIGN
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp856.txt b/lib/ucmaps/cp856.txt
deleted file mode 100755
index 3a6000bcb..000000000
--- a/lib/ucmaps/cp856.txt
+++ /dev/null
@@ -1,303 +0,0 @@
-#
-#    Name:     cp856_Hebrew_PC to Unicode table
-#    Unicode version: 3.0
-#    Table version: 1.0
-#    Table format:  Format A
-#    Date:          1999 July 27
-#    Authors:       Ken Whistler (kenw@sybase.com)
-#
-#	Copyright (c) 1998 - 1999 Unicode, Inc.  All Rights reserved.
-#
-#	This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-#	No claims are made as to fitness for any particular purpose.  No
-#	warranties of any kind are expressed or implied.  The recipient
-#	agrees to determine applicability of information provided.  If this
-#	file has been provided on optical media by Unicode, Inc., the sole
-#	remedy for any claim will be exchange of defective media within 90
-#	days of receipt.
-#
-#	Unicode, Inc. hereby grants the right to freely use the information
-#	supplied in this file in the creation of products supporting the
-#	Unicode Standard, and to make copies of this file in any form for
-#	internal or external distribution as long as this notice remains
-#	attached.
-#
-#	General notes:
-#
-#	This table contains the data the Unicode Consortium has on how
-#       CP424 characters map into Unicode.
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp856_Hebrew_PC code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp856_Hebrew_PC order
-#
-#	Version history
-#	1.0 version new.
-#
-#	Updated versions of this file may be found in:
-#		<ftp://ftp.unicode.org/Public/MAPPINGS/>
-#
-#	Any comments or problems, contact <errata@unicode.org>
-#	Please note that <errata@unicode.org> is an archival address;
-#	notices will be checked, but do not expect an immediate response.
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x05D0	#HEBREW LETTER ALEF
-0x81	0x05D1	#HEBREW LETTER BET
-0x82	0x05D2	#HEBREW LETTER GIMEL
-0x83	0x05D3	#HEBREW LETTER DALET
-0x84	0x05D4	#HEBREW LETTER HE
-0x85	0x05D5	#HEBREW LETTER VAV
-0x86	0x05D6	#HEBREW LETTER ZAYIN
-0x87	0x05D7	#HEBREW LETTER HET
-0x88	0x05D8	#HEBREW LETTER TET
-0x89	0x05D9	#HEBREW LETTER YOD
-0x8A	0x05DA	#HEBREW LETTER FINAL KAF
-0x8B	0x05DB	#HEBREW LETTER KAF
-0x8C	0x05DC	#HEBREW LETTER LAMED
-0x8D	0x05DD	#HEBREW LETTER FINAL MEM
-0x8E	0x05DE	#HEBREW LETTER MEM
-0x8F	0x05DF	#HEBREW LETTER FINAL NUN
-0x90	0x05E0	#HEBREW LETTER NUN
-0x91	0x05E1	#HEBREW LETTER SAMEKH
-0x92	0x05E2	#HEBREW LETTER AYIN
-0x93	0x05E3	#HEBREW LETTER FINAL PE
-0x94	0x05E4	#HEBREW LETTER PE
-0x95	0x05E5	#HEBREW LETTER FINAL TSADI
-0x96	0x05E6	#HEBREW LETTER TSADI
-0x97	0x05E7	#HEBREW LETTER QOF
-0x98	0x05E8	#HEBREW LETTER RESH
-0x99	0x05E9	#HEBREW LETTER SHIN
-0x9A	0x05EA	#HEBREW LETTER TAV
-0x9B		#UNDEFINED
-0x9C	0x00A3	#POUND SIGN
-0x9D		#UNDEFINED
-0x9E	0x00D7	#MULTIPLICATION SIGN
-0x9F		#UNDEFINED
-0xA0		#UNDEFINED
-0xA1		#UNDEFINED
-0xA2		#UNDEFINED
-0xA3		#UNDEFINED
-0xA4		#UNDEFINED
-0xA5		#UNDEFINED
-0xA6		#UNDEFINED
-0xA7		#UNDEFINED
-0xA8		#UNDEFINED
-0xA9	0x00AE	#REGISTERED SIGN
-0xAA	0x00AC	#NOT SIGN
-0xAB	0x00BD	#VULGAR FRACTION ONE HALF
-0xAC	0x00BC	#VULGAR FRACTION ONE QUARTER
-0xAD		#UNDEFINED
-0xAE	0x00AB	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xAF	0x00BB	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xB0	0x2591	#LIGHT SHADE
-0xB1	0x2592	#MEDIUM SHADE
-0xB2	0x2593	#DARK SHADE
-0xB3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xB4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xB5		#UNDEFINED
-0xB6		#UNDEFINED
-0xB7		#UNDEFINED
-0xB8	0x00A9	#COPYRIGHT SIGN
-0xB9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xBA	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xBB	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xBC	0x255D	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xBD	0x00A2	#CENT SIGN
-0xBE	0x00A5	#YEN SIGN
-0xBF	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xC0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xC1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xC2	0x252C	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xC3	0x251C	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xC4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xC5	0x253C	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xC6		#UNDEFINED
-0xC7		#UNDEFINED
-0xC8	0x255A	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xC9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xCA	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xCB	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xCC	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xCD	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xCE	0x256C	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xCF	0x00A4	#CURRENCY SIGN
-0xD0		#UNDEFINED
-0xD1		#UNDEFINED
-0xD2		#UNDEFINED
-0xD3		#UNDEFINEDS
-0xD4		#UNDEFINED
-0xD5		#UNDEFINED
-0xD6		#UNDEFINEDE
-0xD7		#UNDEFINED
-0xD8		#UNDEFINED
-0xD9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xDA	0x250C	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xDB	0x2588	#FULL BLOCK
-0xDC	0x2584	#LOWER HALF BLOCK
-0xDD	0x00A6	#BROKEN BAR
-0xDE		#UNDEFINED
-0xDF	0x2580	#UPPER HALF BLOCK
-0xE0		#UNDEFINED
-0xE1		#UNDEFINED
-0xE2		#UNDEFINED
-0xE3		#UNDEFINED
-0xE4		#UNDEFINED
-0xE5		#UNDEFINED
-0xE6	0x00B5	#MICRO SIGN
-0xE7		#UNDEFINED
-0xE8		#UNDEFINED
-0xE9		#UNDEFINED
-0xEA		#UNDEFINED
-0xEB		#UNDEFINED
-0xEC		#UNDEFINED
-0xED		#UNDEFINED
-0xEE	0x00AF	#MACRON
-0xEF	0x00B4	#ACUTE ACCENT
-0xF0	0x00AD	#SOFT HYPHEN
-0xF1	0x00B1	#PLUS-MINUS SIGN
-0xF2	0x2017	#DOUBLE LOW LINE
-0xF3	0x00BE	#VULGAR FRACTION THREE QUARTERS
-0xF4	0x00B6	#PILCROW SIGN
-0xF5	0x00A7	#SECTION SIGN
-0xF6	0x00F7	#DIVISION SIGN
-0xF7	0x00B8	#CEDILLA
-0xF8	0x00B0	#DEGREE SIGN
-0xF9	0x00A8	#DIAERESIS
-0xFA	0x00B7	#MIDDLE DOT
-0xFB	0x00B9	#SUPERSCRIPT ONE
-0xFC	0x00B3	#SUPERSCRIPT THREE
-0xFD	0x00B2	#SUPERSCRIPT TWO
-0xFE	0x25A0	#BLACK SQUARE
-0xFF	0x00A0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp857.txt b/lib/ucmaps/cp857.txt
deleted file mode 100755
index 305938396..000000000
--- a/lib/ucmaps/cp857.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp857_DOSTurkish to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp857_DOSTurkish code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp857_DOSTurkish order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00ef	#LATIN SMALL LETTER I WITH DIAERESIS
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x0131	#LATIN SMALL LETTER DOTLESS I
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x00f2	#LATIN SMALL LETTER O WITH GRAVE
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x0130	#LATIN CAPITAL LETTER I WITH DOT ABOVE
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00f8	#LATIN SMALL LETTER O WITH STROKE
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d8	#LATIN CAPITAL LETTER O WITH STROKE
-0x9e	0x015e	#LATIN CAPITAL LETTER S WITH CEDILLA
-0x9f	0x015f	#LATIN SMALL LETTER S WITH CEDILLA
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x011e	#LATIN CAPITAL LETTER G WITH BREVE
-0xa7	0x011f	#LATIN SMALL LETTER G WITH BREVE
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x00ae	#REGISTERED SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x00c1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xb6	0x00c2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0xb7	0x00c0	#LATIN CAPITAL LETTER A WITH GRAVE
-0xb8	0x00a9	#COPYRIGHT SIGN
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x00a2	#CENT SIGN
-0xbe	0x00a5	#YEN SIGN
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x00e3	#LATIN SMALL LETTER A WITH TILDE
-0xc7	0x00c3	#LATIN CAPITAL LETTER A WITH TILDE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x00a4	#CURRENCY SIGN
-0xd0	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xd1	0x00aa	#FEMININE ORDINAL INDICATOR
-0xd2	0x00ca	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0xd3	0x00cb	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0xd4	0x00c8	#LATIN CAPITAL LETTER E WITH GRAVE
-0xd5		#UNDEFINED
-0xd6	0x00cd	#LATIN CAPITAL LETTER I WITH ACUTE
-0xd7	0x00ce	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xd8	0x00cf	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x00a6	#BROKEN BAR
-0xde	0x00cc	#LATIN CAPITAL LETTER I WITH GRAVE
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x00d4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0xe3	0x00d2	#LATIN CAPITAL LETTER O WITH GRAVE
-0xe4	0x00f5	#LATIN SMALL LETTER O WITH TILDE
-0xe5	0x00d5	#LATIN CAPITAL LETTER O WITH TILDE
-0xe6	0x00b5	#MICRO SIGN
-0xe7		#UNDEFINED
-0xe8	0x00d7	#MULTIPLICATION SIGN
-0xe9	0x00da	#LATIN CAPITAL LETTER U WITH ACUTE
-0xea	0x00db	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0xeb	0x00d9	#LATIN CAPITAL LETTER U WITH GRAVE
-0xec	0x00ec	#LATIN SMALL LETTER I WITH GRAVE
-0xed	0x00ff	#LATIN SMALL LETTER Y WITH DIAERESIS
-0xee	0x00af	#MACRON
-0xef	0x00b4	#ACUTE ACCENT
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2		#UNDEFINED
-0xf3	0x00be	#VULGAR FRACTION THREE QUARTERS
-0xf4	0x00b6	#PILCROW SIGN
-0xf5	0x00a7	#SECTION SIGN
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x00b8	#CEDILLA
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x00a8	#DIAERESIS
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x00b9	#SUPERSCRIPT ONE
-0xfc	0x00b3	#SUPERSCRIPT THREE
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp860.txt b/lib/ucmaps/cp860.txt
deleted file mode 100755
index d7f2cb737..000000000
--- a/lib/ucmaps/cp860.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp860_DOSPortuguese to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp860_DOSPortuguese code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp860_DOSPortuguese order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e3	#LATIN SMALL LETTER A WITH TILDE
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00c1	#LATIN CAPITAL LETTER A WITH ACUTE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00ca	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00cd	#LATIN CAPITAL LETTER I WITH ACUTE
-0x8c	0x00d4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0x8d	0x00ec	#LATIN SMALL LETTER I WITH GRAVE
-0x8e	0x00c3	#LATIN CAPITAL LETTER A WITH TILDE
-0x8f	0x00c2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00c0	#LATIN CAPITAL LETTER A WITH GRAVE
-0x92	0x00c8	#LATIN CAPITAL LETTER E WITH GRAVE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f5	#LATIN SMALL LETTER O WITH TILDE
-0x95	0x00f2	#LATIN SMALL LETTER O WITH GRAVE
-0x96	0x00da	#LATIN CAPITAL LETTER U WITH ACUTE
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x00cc	#LATIN CAPITAL LETTER I WITH GRAVE
-0x99	0x00d5	#LATIN CAPITAL LETTER O WITH TILDE
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00a2	#CENT SIGN
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d9	#LATIN CAPITAL LETTER U WITH GRAVE
-0x9e	0x20a7	#PESETA SIGN
-0x9f	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x00aa	#FEMININE ORDINAL INDICATOR
-0xa7	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x00d2	#LATIN CAPITAL LETTER O WITH GRAVE
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp861.txt b/lib/ucmaps/cp861.txt
deleted file mode 100755
index fe0f02bb5..000000000
--- a/lib/ucmaps/cp861.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp861_DOSIcelandic to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp861_DOSIcelandic code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp861_DOSIcelandic order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00d0	#LATIN CAPITAL LETTER ETH
-0x8c	0x00f0	#LATIN SMALL LETTER ETH
-0x8d	0x00de	#LATIN CAPITAL LETTER THORN
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x00fe	#LATIN SMALL LETTER THORN
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00dd	#LATIN CAPITAL LETTER Y WITH ACUTE
-0x98	0x00fd	#LATIN SMALL LETTER Y WITH ACUTE
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00f8	#LATIN SMALL LETTER O WITH STROKE
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d8	#LATIN CAPITAL LETTER O WITH STROKE
-0x9e	0x20a7	#PESETA SIGN
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00c1	#LATIN CAPITAL LETTER A WITH ACUTE
-0xa5	0x00cd	#LATIN CAPITAL LETTER I WITH ACUTE
-0xa6	0x00d3	#LATIN CAPITAL LETTER O WITH ACUTE
-0xa7	0x00da	#LATIN CAPITAL LETTER U WITH ACUTE
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x2310	#REVERSED NOT SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp862.txt b/lib/ucmaps/cp862.txt
deleted file mode 100755
index 963110518..000000000
--- a/lib/ucmaps/cp862.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp862_DOSHebrew to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp862_DOSHebrew code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp862_DOSHebrew order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x05d0	#HEBREW LETTER ALEF
-0x81	0x05d1	#HEBREW LETTER BET
-0x82	0x05d2	#HEBREW LETTER GIMEL
-0x83	0x05d3	#HEBREW LETTER DALET
-0x84	0x05d4	#HEBREW LETTER HE
-0x85	0x05d5	#HEBREW LETTER VAV
-0x86	0x05d6	#HEBREW LETTER ZAYIN
-0x87	0x05d7	#HEBREW LETTER HET
-0x88	0x05d8	#HEBREW LETTER TET
-0x89	0x05d9	#HEBREW LETTER YOD
-0x8a	0x05da	#HEBREW LETTER FINAL KAF
-0x8b	0x05db	#HEBREW LETTER KAF
-0x8c	0x05dc	#HEBREW LETTER LAMED
-0x8d	0x05dd	#HEBREW LETTER FINAL MEM
-0x8e	0x05de	#HEBREW LETTER MEM
-0x8f	0x05df	#HEBREW LETTER FINAL NUN
-0x90	0x05e0	#HEBREW LETTER NUN
-0x91	0x05e1	#HEBREW LETTER SAMEKH
-0x92	0x05e2	#HEBREW LETTER AYIN
-0x93	0x05e3	#HEBREW LETTER FINAL PE
-0x94	0x05e4	#HEBREW LETTER PE
-0x95	0x05e5	#HEBREW LETTER FINAL TSADI
-0x96	0x05e6	#HEBREW LETTER TSADI
-0x97	0x05e7	#HEBREW LETTER QOF
-0x98	0x05e8	#HEBREW LETTER RESH
-0x99	0x05e9	#HEBREW LETTER SHIN
-0x9a	0x05ea	#HEBREW LETTER TAV
-0x9b	0x00a2	#CENT SIGN
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00a5	#YEN SIGN
-0x9e	0x20a7	#PESETA SIGN
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x00aa	#FEMININE ORDINAL INDICATOR
-0xa7	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x2310	#REVERSED NOT SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S (GERMAN)
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp863.txt b/lib/ucmaps/cp863.txt
deleted file mode 100755
index cc4eae186..000000000
--- a/lib/ucmaps/cp863.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp863_DOSCanadaF to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp863_DOSCanadaF code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp863_DOSCanadaF order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00c2	#LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00b6	#PILCROW SIGN
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00ef	#LATIN SMALL LETTER I WITH DIAERESIS
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x2017	#DOUBLE LOW LINE
-0x8e	0x00c0	#LATIN CAPITAL LETTER A WITH GRAVE
-0x8f	0x00a7	#SECTION SIGN
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00c8	#LATIN CAPITAL LETTER E WITH GRAVE
-0x92	0x00ca	#LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00cb	#LATIN CAPITAL LETTER E WITH DIAERESIS
-0x95	0x00cf	#LATIN CAPITAL LETTER I WITH DIAERESIS
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x00a4	#CURRENCY SIGN
-0x99	0x00d4	#LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00a2	#CENT SIGN
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d9	#LATIN CAPITAL LETTER U WITH GRAVE
-0x9e	0x00db	#LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00a6	#BROKEN BAR
-0xa1	0x00b4	#ACUTE ACCENT
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00a8	#DIAERESIS
-0xa5	0x00b8	#CEDILLA
-0xa6	0x00b3	#SUPERSCRIPT THREE
-0xa7	0x00af	#MACRON
-0xa8	0x00ce	#LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-0xa9	0x2310	#REVERSED NOT SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00be	#VULGAR FRACTION THREE QUARTERS
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp864.txt b/lib/ucmaps/cp864.txt
deleted file mode 100755
index 7aa055fba..000000000
--- a/lib/ucmaps/cp864.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp864_DOSArabic to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp864_DOSArabic code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp864_DOSArabic order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x066a	#ARABIC PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00b0	#DEGREE SIGN
-0x81	0x00b7	#MIDDLE DOT
-0x82	0x2219	#BULLET OPERATOR
-0x83	0x221a	#SQUARE ROOT
-0x84	0x2592	#MEDIUM SHADE
-0x85	0x2500	#FORMS LIGHT HORIZONTAL
-0x86	0x2502	#FORMS LIGHT VERTICAL
-0x87	0x253c	#FORMS LIGHT VERTICAL AND HORIZONTAL
-0x88	0x2524	#FORMS LIGHT VERTICAL AND LEFT
-0x89	0x252c	#FORMS LIGHT DOWN AND HORIZONTAL
-0x8a	0x251c	#FORMS LIGHT VERTICAL AND RIGHT
-0x8b	0x2534	#FORMS LIGHT UP AND HORIZONTAL
-0x8c	0x2510	#FORMS LIGHT DOWN AND LEFT
-0x8d	0x250c	#FORMS LIGHT DOWN AND RIGHT
-0x8e	0x2514	#FORMS LIGHT UP AND RIGHT
-0x8f	0x2518	#FORMS LIGHT UP AND LEFT
-0x90	0x03b2	#GREEK SMALL BETA
-0x91	0x221e	#INFINITY
-0x92	0x03c6	#GREEK SMALL PHI
-0x93	0x00b1	#PLUS-OR-MINUS SIGN
-0x94	0x00bd	#FRACTION 1/2
-0x95	0x00bc	#FRACTION 1/4
-0x96	0x2248	#ALMOST EQUAL TO
-0x97	0x00ab	#LEFT POINTING GUILLEMET
-0x98	0x00bb	#RIGHT POINTING GUILLEMET
-0x99	0xfef7	#ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
-0x9a	0xfef8	#ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
-0x9b		#UNDEFINED
-0x9c		#UNDEFINED
-0x9d	0xfefb	#ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
-0x9e	0xfefc	#ARABIC LIGATURE LAM WITH ALEF FINAL FORM
-0x9f		#UNDEFINED
-0xa0	0x00a0	#NON-BREAKING SPACE
-0xa1	0x00ad	#SOFT HYPHEN
-0xa2	0xfe82	#ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
-0xa3	0x00a3	#POUND SIGN
-0xa4	0x00a4	#CURRENCY SIGN
-0xa5	0xfe84	#ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
-0xa6		#UNDEFINED
-0xa7		#UNDEFINED
-0xa8	0xfe8e	#ARABIC LETTER ALEF FINAL FORM
-0xa9	0xfe8f	#ARABIC LETTER BEH ISOLATED FORM
-0xaa	0xfe95	#ARABIC LETTER TEH ISOLATED FORM
-0xab	0xfe99	#ARABIC LETTER THEH ISOLATED FORM
-0xac	0x060c	#ARABIC COMMA
-0xad	0xfe9d	#ARABIC LETTER JEEM ISOLATED FORM
-0xae	0xfea1	#ARABIC LETTER HAH ISOLATED FORM
-0xaf	0xfea5	#ARABIC LETTER KHAH ISOLATED FORM
-0xb0	0x0660	#ARABIC-INDIC DIGIT ZERO
-0xb1	0x0661	#ARABIC-INDIC DIGIT ONE
-0xb2	0x0662	#ARABIC-INDIC DIGIT TWO
-0xb3	0x0663	#ARABIC-INDIC DIGIT THREE
-0xb4	0x0664	#ARABIC-INDIC DIGIT FOUR
-0xb5	0x0665	#ARABIC-INDIC DIGIT FIVE
-0xb6	0x0666	#ARABIC-INDIC DIGIT SIX
-0xb7	0x0667	#ARABIC-INDIC DIGIT SEVEN
-0xb8	0x0668	#ARABIC-INDIC DIGIT EIGHT
-0xb9	0x0669	#ARABIC-INDIC DIGIT NINE
-0xba	0xfed1	#ARABIC LETTER FEH ISOLATED FORM
-0xbb	0x061b	#ARABIC SEMICOLON
-0xbc	0xfeb1	#ARABIC LETTER SEEN ISOLATED FORM
-0xbd	0xfeb5	#ARABIC LETTER SHEEN ISOLATED FORM
-0xbe	0xfeb9	#ARABIC LETTER SAD ISOLATED FORM
-0xbf	0x061f	#ARABIC QUESTION MARK
-0xc0	0x00a2	#CENT SIGN
-0xc1	0xfe80	#ARABIC LETTER HAMZA ISOLATED FORM
-0xc2	0xfe81	#ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
-0xc3	0xfe83	#ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
-0xc4	0xfe85	#ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
-0xc5	0xfeca	#ARABIC LETTER AIN FINAL FORM
-0xc6	0xfe8b	#ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
-0xc7	0xfe8d	#ARABIC LETTER ALEF ISOLATED FORM
-0xc8	0xfe91	#ARABIC LETTER BEH INITIAL FORM
-0xc9	0xfe93	#ARABIC LETTER TEH MARBUTA ISOLATED FORM
-0xca	0xfe97	#ARABIC LETTER TEH INITIAL FORM
-0xcb	0xfe9b	#ARABIC LETTER THEH INITIAL FORM
-0xcc	0xfe9f	#ARABIC LETTER JEEM INITIAL FORM
-0xcd	0xfea3	#ARABIC LETTER HAH INITIAL FORM
-0xce	0xfea7	#ARABIC LETTER KHAH INITIAL FORM
-0xcf	0xfea9	#ARABIC LETTER DAL ISOLATED FORM
-0xd0	0xfeab	#ARABIC LETTER THAL ISOLATED FORM
-0xd1	0xfead	#ARABIC LETTER REH ISOLATED FORM
-0xd2	0xfeaf	#ARABIC LETTER ZAIN ISOLATED FORM
-0xd3	0xfeb3	#ARABIC LETTER SEEN INITIAL FORM
-0xd4	0xfeb7	#ARABIC LETTER SHEEN INITIAL FORM
-0xd5	0xfebb	#ARABIC LETTER SAD INITIAL FORM
-0xd6	0xfebf	#ARABIC LETTER DAD INITIAL FORM
-0xd7	0xfec1	#ARABIC LETTER TAH ISOLATED FORM
-0xd8	0xfec5	#ARABIC LETTER ZAH ISOLATED FORM
-0xd9	0xfecb	#ARABIC LETTER AIN INITIAL FORM
-0xda	0xfecf	#ARABIC LETTER GHAIN INITIAL FORM
-0xdb	0x00a6	#BROKEN VERTICAL BAR
-0xdc	0x00ac	#NOT SIGN
-0xdd	0x00f7	#DIVISION SIGN
-0xde	0x00d7	#MULTIPLICATION SIGN
-0xdf	0xfec9	#ARABIC LETTER AIN ISOLATED FORM
-0xe0	0x0640	#ARABIC TATWEEL
-0xe1	0xfed3	#ARABIC LETTER FEH INITIAL FORM
-0xe2	0xfed7	#ARABIC LETTER QAF INITIAL FORM
-0xe3	0xfedb	#ARABIC LETTER KAF INITIAL FORM
-0xe4	0xfedf	#ARABIC LETTER LAM INITIAL FORM
-0xe5	0xfee3	#ARABIC LETTER MEEM INITIAL FORM
-0xe6	0xfee7	#ARABIC LETTER NOON INITIAL FORM
-0xe7	0xfeeb	#ARABIC LETTER HEH INITIAL FORM
-0xe8	0xfeed	#ARABIC LETTER WAW ISOLATED FORM
-0xe9	0xfeef	#ARABIC LETTER ALEF MAKSURA ISOLATED FORM
-0xea	0xfef3	#ARABIC LETTER YEH INITIAL FORM
-0xeb	0xfebd	#ARABIC LETTER DAD ISOLATED FORM
-0xec	0xfecc	#ARABIC LETTER AIN MEDIAL FORM
-0xed	0xfece	#ARABIC LETTER GHAIN FINAL FORM
-0xee	0xfecd	#ARABIC LETTER GHAIN ISOLATED FORM
-0xef	0xfee1	#ARABIC LETTER MEEM ISOLATED FORM
-0xf0	0xfe7d	#ARABIC SHADDA MEDIAL FORM
-0xf1	0x0651	#ARABIC SHADDAH
-0xf2	0xfee5	#ARABIC LETTER NOON ISOLATED FORM
-0xf3	0xfee9	#ARABIC LETTER HEH ISOLATED FORM
-0xf4	0xfeec	#ARABIC LETTER HEH MEDIAL FORM
-0xf5	0xfef0	#ARABIC LETTER ALEF MAKSURA FINAL FORM
-0xf6	0xfef2	#ARABIC LETTER YEH FINAL FORM
-0xf7	0xfed0	#ARABIC LETTER GHAIN MEDIAL FORM
-0xf8	0xfed5	#ARABIC LETTER QAF ISOLATED FORM
-0xf9	0xfef5	#ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
-0xfa	0xfef6	#ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
-0xfb	0xfedd	#ARABIC LETTER LAM ISOLATED FORM
-0xfc	0xfed9	#ARABIC LETTER KAF ISOLATED FORM
-0xfd	0xfef1	#ARABIC LETTER YEH ISOLATED FORM
-0xfe	0x25a0	#BLACK SQUARE
-0xff		#UNDEFINED
-
diff --git a/lib/ucmaps/cp865.txt b/lib/ucmaps/cp865.txt
deleted file mode 100755
index 67705f46a..000000000
--- a/lib/ucmaps/cp865.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp865_DOSNordic to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp865_DOSNordic code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp865_DOSNordic order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x00c7	#LATIN CAPITAL LETTER C WITH CEDILLA
-0x81	0x00fc	#LATIN SMALL LETTER U WITH DIAERESIS
-0x82	0x00e9	#LATIN SMALL LETTER E WITH ACUTE
-0x83	0x00e2	#LATIN SMALL LETTER A WITH CIRCUMFLEX
-0x84	0x00e4	#LATIN SMALL LETTER A WITH DIAERESIS
-0x85	0x00e0	#LATIN SMALL LETTER A WITH GRAVE
-0x86	0x00e5	#LATIN SMALL LETTER A WITH RING ABOVE
-0x87	0x00e7	#LATIN SMALL LETTER C WITH CEDILLA
-0x88	0x00ea	#LATIN SMALL LETTER E WITH CIRCUMFLEX
-0x89	0x00eb	#LATIN SMALL LETTER E WITH DIAERESIS
-0x8a	0x00e8	#LATIN SMALL LETTER E WITH GRAVE
-0x8b	0x00ef	#LATIN SMALL LETTER I WITH DIAERESIS
-0x8c	0x00ee	#LATIN SMALL LETTER I WITH CIRCUMFLEX
-0x8d	0x00ec	#LATIN SMALL LETTER I WITH GRAVE
-0x8e	0x00c4	#LATIN CAPITAL LETTER A WITH DIAERESIS
-0x8f	0x00c5	#LATIN CAPITAL LETTER A WITH RING ABOVE
-0x90	0x00c9	#LATIN CAPITAL LETTER E WITH ACUTE
-0x91	0x00e6	#LATIN SMALL LIGATURE AE
-0x92	0x00c6	#LATIN CAPITAL LIGATURE AE
-0x93	0x00f4	#LATIN SMALL LETTER O WITH CIRCUMFLEX
-0x94	0x00f6	#LATIN SMALL LETTER O WITH DIAERESIS
-0x95	0x00f2	#LATIN SMALL LETTER O WITH GRAVE
-0x96	0x00fb	#LATIN SMALL LETTER U WITH CIRCUMFLEX
-0x97	0x00f9	#LATIN SMALL LETTER U WITH GRAVE
-0x98	0x00ff	#LATIN SMALL LETTER Y WITH DIAERESIS
-0x99	0x00d6	#LATIN CAPITAL LETTER O WITH DIAERESIS
-0x9a	0x00dc	#LATIN CAPITAL LETTER U WITH DIAERESIS
-0x9b	0x00f8	#LATIN SMALL LETTER O WITH STROKE
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x00d8	#LATIN CAPITAL LETTER O WITH STROKE
-0x9e	0x20a7	#PESETA SIGN
-0x9f	0x0192	#LATIN SMALL LETTER F WITH HOOK
-0xa0	0x00e1	#LATIN SMALL LETTER A WITH ACUTE
-0xa1	0x00ed	#LATIN SMALL LETTER I WITH ACUTE
-0xa2	0x00f3	#LATIN SMALL LETTER O WITH ACUTE
-0xa3	0x00fa	#LATIN SMALL LETTER U WITH ACUTE
-0xa4	0x00f1	#LATIN SMALL LETTER N WITH TILDE
-0xa5	0x00d1	#LATIN CAPITAL LETTER N WITH TILDE
-0xa6	0x00aa	#FEMININE ORDINAL INDICATOR
-0xa7	0x00ba	#MASCULINE ORDINAL INDICATOR
-0xa8	0x00bf	#INVERTED QUESTION MARK
-0xa9	0x2310	#REVERSED NOT SIGN
-0xaa	0x00ac	#NOT SIGN
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x00bc	#VULGAR FRACTION ONE QUARTER
-0xad	0x00a1	#INVERTED EXCLAMATION MARK
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00a4	#CURRENCY SIGN
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b1	#GREEK SMALL LETTER ALPHA
-0xe1	0x00df	#LATIN SMALL LETTER SHARP S
-0xe2	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xe3	0x03c0	#GREEK SMALL LETTER PI
-0xe4	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xe5	0x03c3	#GREEK SMALL LETTER SIGMA
-0xe6	0x00b5	#MICRO SIGN
-0xe7	0x03c4	#GREEK SMALL LETTER TAU
-0xe8	0x03a6	#GREEK CAPITAL LETTER PHI
-0xe9	0x0398	#GREEK CAPITAL LETTER THETA
-0xea	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xeb	0x03b4	#GREEK SMALL LETTER DELTA
-0xec	0x221e	#INFINITY
-0xed	0x03c6	#GREEK SMALL LETTER PHI
-0xee	0x03b5	#GREEK SMALL LETTER EPSILON
-0xef	0x2229	#INTERSECTION
-0xf0	0x2261	#IDENTICAL TO
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x2265	#GREATER-THAN OR EQUAL TO
-0xf3	0x2264	#LESS-THAN OR EQUAL TO
-0xf4	0x2320	#TOP HALF INTEGRAL
-0xf5	0x2321	#BOTTOM HALF INTEGRAL
-0xf6	0x00f7	#DIVISION SIGN
-0xf7	0x2248	#ALMOST EQUAL TO
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x207f	#SUPERSCRIPT LATIN SMALL LETTER N
-0xfd	0x00b2	#SUPERSCRIPT TWO
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp866.txt b/lib/ucmaps/cp866.txt
deleted file mode 100755
index 880fb70e3..000000000
--- a/lib/ucmaps/cp866.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp866_DOSCyrillicRussian to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp866_DOSCyrillicRussian code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp866_DOSCyrillicRussian order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80	0x0410	#CYRILLIC CAPITAL LETTER A
-0x81	0x0411	#CYRILLIC CAPITAL LETTER BE
-0x82	0x0412	#CYRILLIC CAPITAL LETTER VE
-0x83	0x0413	#CYRILLIC CAPITAL LETTER GHE
-0x84	0x0414	#CYRILLIC CAPITAL LETTER DE
-0x85	0x0415	#CYRILLIC CAPITAL LETTER IE
-0x86	0x0416	#CYRILLIC CAPITAL LETTER ZHE
-0x87	0x0417	#CYRILLIC CAPITAL LETTER ZE
-0x88	0x0418	#CYRILLIC CAPITAL LETTER I
-0x89	0x0419	#CYRILLIC CAPITAL LETTER SHORT I
-0x8a	0x041a	#CYRILLIC CAPITAL LETTER KA
-0x8b	0x041b	#CYRILLIC CAPITAL LETTER EL
-0x8c	0x041c	#CYRILLIC CAPITAL LETTER EM
-0x8d	0x041d	#CYRILLIC CAPITAL LETTER EN
-0x8e	0x041e	#CYRILLIC CAPITAL LETTER O
-0x8f	0x041f	#CYRILLIC CAPITAL LETTER PE
-0x90	0x0420	#CYRILLIC CAPITAL LETTER ER
-0x91	0x0421	#CYRILLIC CAPITAL LETTER ES
-0x92	0x0422	#CYRILLIC CAPITAL LETTER TE
-0x93	0x0423	#CYRILLIC CAPITAL LETTER U
-0x94	0x0424	#CYRILLIC CAPITAL LETTER EF
-0x95	0x0425	#CYRILLIC CAPITAL LETTER HA
-0x96	0x0426	#CYRILLIC CAPITAL LETTER TSE
-0x97	0x0427	#CYRILLIC CAPITAL LETTER CHE
-0x98	0x0428	#CYRILLIC CAPITAL LETTER SHA
-0x99	0x0429	#CYRILLIC CAPITAL LETTER SHCHA
-0x9a	0x042a	#CYRILLIC CAPITAL LETTER HARD SIGN
-0x9b	0x042b	#CYRILLIC CAPITAL LETTER YERU
-0x9c	0x042c	#CYRILLIC CAPITAL LETTER SOFT SIGN
-0x9d	0x042d	#CYRILLIC CAPITAL LETTER E
-0x9e	0x042e	#CYRILLIC CAPITAL LETTER YU
-0x9f	0x042f	#CYRILLIC CAPITAL LETTER YA
-0xa0	0x0430	#CYRILLIC SMALL LETTER A
-0xa1	0x0431	#CYRILLIC SMALL LETTER BE
-0xa2	0x0432	#CYRILLIC SMALL LETTER VE
-0xa3	0x0433	#CYRILLIC SMALL LETTER GHE
-0xa4	0x0434	#CYRILLIC SMALL LETTER DE
-0xa5	0x0435	#CYRILLIC SMALL LETTER IE
-0xa6	0x0436	#CYRILLIC SMALL LETTER ZHE
-0xa7	0x0437	#CYRILLIC SMALL LETTER ZE
-0xa8	0x0438	#CYRILLIC SMALL LETTER I
-0xa9	0x0439	#CYRILLIC SMALL LETTER SHORT I
-0xaa	0x043a	#CYRILLIC SMALL LETTER KA
-0xab	0x043b	#CYRILLIC SMALL LETTER EL
-0xac	0x043c	#CYRILLIC SMALL LETTER EM
-0xad	0x043d	#CYRILLIC SMALL LETTER EN
-0xae	0x043e	#CYRILLIC SMALL LETTER O
-0xaf	0x043f	#CYRILLIC SMALL LETTER PE
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x2561	#BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
-0xb6	0x2562	#BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
-0xb7	0x2556	#BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
-0xb8	0x2555	#BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x255c	#BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
-0xbe	0x255b	#BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x255e	#BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
-0xc7	0x255f	#BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x2567	#BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
-0xd0	0x2568	#BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
-0xd1	0x2564	#BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
-0xd2	0x2565	#BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
-0xd3	0x2559	#BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
-0xd4	0x2558	#BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
-0xd5	0x2552	#BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
-0xd6	0x2553	#BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
-0xd7	0x256b	#BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
-0xd8	0x256a	#BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x258c	#LEFT HALF BLOCK
-0xde	0x2590	#RIGHT HALF BLOCK
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x0440	#CYRILLIC SMALL LETTER ER
-0xe1	0x0441	#CYRILLIC SMALL LETTER ES
-0xe2	0x0442	#CYRILLIC SMALL LETTER TE
-0xe3	0x0443	#CYRILLIC SMALL LETTER U
-0xe4	0x0444	#CYRILLIC SMALL LETTER EF
-0xe5	0x0445	#CYRILLIC SMALL LETTER HA
-0xe6	0x0446	#CYRILLIC SMALL LETTER TSE
-0xe7	0x0447	#CYRILLIC SMALL LETTER CHE
-0xe8	0x0448	#CYRILLIC SMALL LETTER SHA
-0xe9	0x0449	#CYRILLIC SMALL LETTER SHCHA
-0xea	0x044a	#CYRILLIC SMALL LETTER HARD SIGN
-0xeb	0x044b	#CYRILLIC SMALL LETTER YERU
-0xec	0x044c	#CYRILLIC SMALL LETTER SOFT SIGN
-0xed	0x044d	#CYRILLIC SMALL LETTER E
-0xee	0x044e	#CYRILLIC SMALL LETTER YU
-0xef	0x044f	#CYRILLIC SMALL LETTER YA
-0xf0	0x0401	#CYRILLIC CAPITAL LETTER IO
-0xf1	0x0451	#CYRILLIC SMALL LETTER IO
-0xf2	0x0404	#CYRILLIC CAPITAL LETTER UKRAINIAN IE
-0xf3	0x0454	#CYRILLIC SMALL LETTER UKRAINIAN IE
-0xf4	0x0407	#CYRILLIC CAPITAL LETTER YI
-0xf5	0x0457	#CYRILLIC SMALL LETTER YI
-0xf6	0x040e	#CYRILLIC CAPITAL LETTER SHORT U
-0xf7	0x045e	#CYRILLIC SMALL LETTER SHORT U
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x2219	#BULLET OPERATOR
-0xfa	0x00b7	#MIDDLE DOT
-0xfb	0x221a	#SQUARE ROOT
-0xfc	0x2116	#NUMERO SIGN
-0xfd	0x00a4	#CURRENCY SIGN
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp869.txt b/lib/ucmaps/cp869.txt
deleted file mode 100755
index 4c77ffd6c..000000000
--- a/lib/ucmaps/cp869.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp869_DOSGreek2 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.00
-#    Table format:  Format A
-#    Date:          04/24/96
-#    Authors:       Lori Brownell <loribr@microsoft.com>
-#                   K.D. Chang    <a-kchang@microsoft.com>
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp869_DOSGreek2 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp869_DOSGreek2 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0a	0x000a	#LINE FEED
-0x0b	0x000b	#VERTICAL TABULATION
-0x0c	0x000c	#FORM FEED
-0x0d	0x000d	#CARRIAGE RETURN
-0x0e	0x000e	#SHIFT OUT
-0x0f	0x000f	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1a	0x001a	#SUBSTITUTE
-0x1b	0x001b	#ESCAPE
-0x1c	0x001c	#FILE SEPARATOR
-0x1d	0x001d	#GROUP SEPARATOR
-0x1e	0x001e	#RECORD SEPARATOR
-0x1f	0x001f	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2a	0x002a	#ASTERISK
-0x2b	0x002b	#PLUS SIGN
-0x2c	0x002c	#COMMA
-0x2d	0x002d	#HYPHEN-MINUS
-0x2e	0x002e	#FULL STOP
-0x2f	0x002f	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3a	0x003a	#COLON
-0x3b	0x003b	#SEMICOLON
-0x3c	0x003c	#LESS-THAN SIGN
-0x3d	0x003d	#EQUALS SIGN
-0x3e	0x003e	#GREATER-THAN SIGN
-0x3f	0x003f	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4a	0x004a	#LATIN CAPITAL LETTER J
-0x4b	0x004b	#LATIN CAPITAL LETTER K
-0x4c	0x004c	#LATIN CAPITAL LETTER L
-0x4d	0x004d	#LATIN CAPITAL LETTER M
-0x4e	0x004e	#LATIN CAPITAL LETTER N
-0x4f	0x004f	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5a	0x005a	#LATIN CAPITAL LETTER Z
-0x5b	0x005b	#LEFT SQUARE BRACKET
-0x5c	0x005c	#REVERSE SOLIDUS
-0x5d	0x005d	#RIGHT SQUARE BRACKET
-0x5e	0x005e	#CIRCUMFLEX ACCENT
-0x5f	0x005f	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6a	0x006a	#LATIN SMALL LETTER J
-0x6b	0x006b	#LATIN SMALL LETTER K
-0x6c	0x006c	#LATIN SMALL LETTER L
-0x6d	0x006d	#LATIN SMALL LETTER M
-0x6e	0x006e	#LATIN SMALL LETTER N
-0x6f	0x006f	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7a	0x007a	#LATIN SMALL LETTER Z
-0x7b	0x007b	#LEFT CURLY BRACKET
-0x7c	0x007c	#VERTICAL LINE
-0x7d	0x007d	#RIGHT CURLY BRACKET
-0x7e	0x007e	#TILDE
-0x7f	0x007f	#DELETE
-0x80		#UNDEFINED
-0x81		#UNDEFINED
-0x82		#UNDEFINED
-0x83		#UNDEFINED
-0x84		#UNDEFINED
-0x85		#UNDEFINED
-0x86	0x0386	#GREEK CAPITAL LETTER ALPHA WITH TONOS
-0x87		#UNDEFINED
-0x88	0x00b7	#MIDDLE DOT
-0x89	0x00ac	#NOT SIGN
-0x8a	0x00a6	#BROKEN BAR
-0x8b	0x2018	#LEFT SINGLE QUOTATION MARK
-0x8c	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x8d	0x0388	#GREEK CAPITAL LETTER EPSILON WITH TONOS
-0x8e	0x2015	#HORIZONTAL BAR
-0x8f	0x0389	#GREEK CAPITAL LETTER ETA WITH TONOS
-0x90	0x038a	#GREEK CAPITAL LETTER IOTA WITH TONOS
-0x91	0x03aa	#GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
-0x92	0x038c	#GREEK CAPITAL LETTER OMICRON WITH TONOS
-0x93		#UNDEFINED
-0x94		#UNDEFINED
-0x95	0x038e	#GREEK CAPITAL LETTER UPSILON WITH TONOS
-0x96	0x03ab	#GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
-0x97	0x00a9	#COPYRIGHT SIGN
-0x98	0x038f	#GREEK CAPITAL LETTER OMEGA WITH TONOS
-0x99	0x00b2	#SUPERSCRIPT TWO
-0x9a	0x00b3	#SUPERSCRIPT THREE
-0x9b	0x03ac	#GREEK SMALL LETTER ALPHA WITH TONOS
-0x9c	0x00a3	#POUND SIGN
-0x9d	0x03ad	#GREEK SMALL LETTER EPSILON WITH TONOS
-0x9e	0x03ae	#GREEK SMALL LETTER ETA WITH TONOS
-0x9f	0x03af	#GREEK SMALL LETTER IOTA WITH TONOS
-0xa0	0x03ca	#GREEK SMALL LETTER IOTA WITH DIALYTIKA
-0xa1	0x0390	#GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
-0xa2	0x03cc	#GREEK SMALL LETTER OMICRON WITH TONOS
-0xa3	0x03cd	#GREEK SMALL LETTER UPSILON WITH TONOS
-0xa4	0x0391	#GREEK CAPITAL LETTER ALPHA
-0xa5	0x0392	#GREEK CAPITAL LETTER BETA
-0xa6	0x0393	#GREEK CAPITAL LETTER GAMMA
-0xa7	0x0394	#GREEK CAPITAL LETTER DELTA
-0xa8	0x0395	#GREEK CAPITAL LETTER EPSILON
-0xa9	0x0396	#GREEK CAPITAL LETTER ZETA
-0xaa	0x0397	#GREEK CAPITAL LETTER ETA
-0xab	0x00bd	#VULGAR FRACTION ONE HALF
-0xac	0x0398	#GREEK CAPITAL LETTER THETA
-0xad	0x0399	#GREEK CAPITAL LETTER IOTA
-0xae	0x00ab	#LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xaf	0x00bb	#RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-0xb0	0x2591	#LIGHT SHADE
-0xb1	0x2592	#MEDIUM SHADE
-0xb2	0x2593	#DARK SHADE
-0xb3	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0xb4	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0xb5	0x039a	#GREEK CAPITAL LETTER KAPPA
-0xb6	0x039b	#GREEK CAPITAL LETTER LAMDA
-0xb7	0x039c	#GREEK CAPITAL LETTER MU
-0xb8	0x039d	#GREEK CAPITAL LETTER NU
-0xb9	0x2563	#BOX DRAWINGS DOUBLE VERTICAL AND LEFT
-0xba	0x2551	#BOX DRAWINGS DOUBLE VERTICAL
-0xbb	0x2557	#BOX DRAWINGS DOUBLE DOWN AND LEFT
-0xbc	0x255d	#BOX DRAWINGS DOUBLE UP AND LEFT
-0xbd	0x039e	#GREEK CAPITAL LETTER XI
-0xbe	0x039f	#GREEK CAPITAL LETTER OMICRON
-0xbf	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0xc0	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0xc1	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0xc2	0x252c	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0xc3	0x251c	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0xc4	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0xc5	0x253c	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0xc6	0x03a0	#GREEK CAPITAL LETTER PI
-0xc7	0x03a1	#GREEK CAPITAL LETTER RHO
-0xc8	0x255a	#BOX DRAWINGS DOUBLE UP AND RIGHT
-0xc9	0x2554	#BOX DRAWINGS DOUBLE DOWN AND RIGHT
-0xca	0x2569	#BOX DRAWINGS DOUBLE UP AND HORIZONTAL
-0xcb	0x2566	#BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
-0xcc	0x2560	#BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
-0xcd	0x2550	#BOX DRAWINGS DOUBLE HORIZONTAL
-0xce	0x256c	#BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
-0xcf	0x03a3	#GREEK CAPITAL LETTER SIGMA
-0xd0	0x03a4	#GREEK CAPITAL LETTER TAU
-0xd1	0x03a5	#GREEK CAPITAL LETTER UPSILON
-0xd2	0x03a6	#GREEK CAPITAL LETTER PHI
-0xd3	0x03a7	#GREEK CAPITAL LETTER CHI
-0xd4	0x03a8	#GREEK CAPITAL LETTER PSI
-0xd5	0x03a9	#GREEK CAPITAL LETTER OMEGA
-0xd6	0x03b1	#GREEK SMALL LETTER ALPHA
-0xd7	0x03b2	#GREEK SMALL LETTER BETA
-0xd8	0x03b3	#GREEK SMALL LETTER GAMMA
-0xd9	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0xda	0x250c	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0xdb	0x2588	#FULL BLOCK
-0xdc	0x2584	#LOWER HALF BLOCK
-0xdd	0x03b4	#GREEK SMALL LETTER DELTA
-0xde	0x03b5	#GREEK SMALL LETTER EPSILON
-0xdf	0x2580	#UPPER HALF BLOCK
-0xe0	0x03b6	#GREEK SMALL LETTER ZETA
-0xe1	0x03b7	#GREEK SMALL LETTER ETA
-0xe2	0x03b8	#GREEK SMALL LETTER THETA
-0xe3	0x03b9	#GREEK SMALL LETTER IOTA
-0xe4	0x03ba	#GREEK SMALL LETTER KAPPA
-0xe5	0x03bb	#GREEK SMALL LETTER LAMDA
-0xe6	0x03bc	#GREEK SMALL LETTER MU
-0xe7	0x03bd	#GREEK SMALL LETTER NU
-0xe8	0x03be	#GREEK SMALL LETTER XI
-0xe9	0x03bf	#GREEK SMALL LETTER OMICRON
-0xea	0x03c0	#GREEK SMALL LETTER PI
-0xeb	0x03c1	#GREEK SMALL LETTER RHO
-0xec	0x03c3	#GREEK SMALL LETTER SIGMA
-0xed	0x03c2	#GREEK SMALL LETTER FINAL SIGMA
-0xee	0x03c4	#GREEK SMALL LETTER TAU
-0xef	0x0384	#GREEK TONOS
-0xf0	0x00ad	#SOFT HYPHEN
-0xf1	0x00b1	#PLUS-MINUS SIGN
-0xf2	0x03c5	#GREEK SMALL LETTER UPSILON
-0xf3	0x03c6	#GREEK SMALL LETTER PHI
-0xf4	0x03c7	#GREEK SMALL LETTER CHI
-0xf5	0x00a7	#SECTION SIGN
-0xf6	0x03c8	#GREEK SMALL LETTER PSI
-0xf7	0x0385	#GREEK DIALYTIKA TONOS
-0xf8	0x00b0	#DEGREE SIGN
-0xf9	0x00a8	#DIAERESIS
-0xfa	0x03c9	#GREEK SMALL LETTER OMEGA
-0xfb	0x03cb	#GREEK SMALL LETTER UPSILON WITH DIALYTIKA
-0xfc	0x03b0	#GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
-0xfd	0x03ce	#GREEK SMALL LETTER OMEGA WITH TONOS
-0xfe	0x25a0	#BLACK SQUARE
-0xff	0x00a0	#NO-BREAK SPACE
-
diff --git a/lib/ucmaps/cp874.txt b/lib/ucmaps/cp874.txt
deleted file mode 100755
index 1eb71dfe1..000000000
--- a/lib/ucmaps/cp874.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-#
-#    Name:     cp874 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          02/28/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp874 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp874 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	0x20AC	#EURO SIGN
-0x81	      	#UNDEFINED
-0x82	      	#UNDEFINED
-0x83	      	#UNDEFINED
-0x84	      	#UNDEFINED
-0x85	0x2026	#HORIZONTAL ELLIPSIS
-0x86	      	#UNDEFINED
-0x87	      	#UNDEFINED
-0x88	      	#UNDEFINED
-0x89	      	#UNDEFINED
-0x8A	      	#UNDEFINED
-0x8B	      	#UNDEFINED
-0x8C	      	#UNDEFINED
-0x8D	      	#UNDEFINED
-0x8E	      	#UNDEFINED
-0x8F	      	#UNDEFINED
-0x90	      	#UNDEFINED
-0x91	0x2018	#LEFT SINGLE QUOTATION MARK
-0x92	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x93	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x94	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x95	0x2022	#BULLET
-0x96	0x2013	#EN DASH
-0x97	0x2014	#EM DASH
-0x98	      	#UNDEFINED
-0x99	      	#UNDEFINED
-0x9A	      	#UNDEFINED
-0x9B	      	#UNDEFINED
-0x9C	      	#UNDEFINED
-0x9D	      	#UNDEFINED
-0x9E	      	#UNDEFINED
-0x9F	      	#UNDEFINED
-0xA0	0x00A0	#NO-BREAK SPACE
-0xA1	0x0E01	#THAI CHARACTER KO KAI
-0xA2	0x0E02	#THAI CHARACTER KHO KHAI
-0xA3	0x0E03	#THAI CHARACTER KHO KHUAT
-0xA4	0x0E04	#THAI CHARACTER KHO KHWAI
-0xA5	0x0E05	#THAI CHARACTER KHO KHON
-0xA6	0x0E06	#THAI CHARACTER KHO RAKHANG
-0xA7	0x0E07	#THAI CHARACTER NGO NGU
-0xA8	0x0E08	#THAI CHARACTER CHO CHAN
-0xA9	0x0E09	#THAI CHARACTER CHO CHING
-0xAA	0x0E0A	#THAI CHARACTER CHO CHANG
-0xAB	0x0E0B	#THAI CHARACTER SO SO
-0xAC	0x0E0C	#THAI CHARACTER CHO CHOE
-0xAD	0x0E0D	#THAI CHARACTER YO YING
-0xAE	0x0E0E	#THAI CHARACTER DO CHADA
-0xAF	0x0E0F	#THAI CHARACTER TO PATAK
-0xB0	0x0E10	#THAI CHARACTER THO THAN
-0xB1	0x0E11	#THAI CHARACTER THO NANGMONTHO
-0xB2	0x0E12	#THAI CHARACTER THO PHUTHAO
-0xB3	0x0E13	#THAI CHARACTER NO NEN
-0xB4	0x0E14	#THAI CHARACTER DO DEK
-0xB5	0x0E15	#THAI CHARACTER TO TAO
-0xB6	0x0E16	#THAI CHARACTER THO THUNG
-0xB7	0x0E17	#THAI CHARACTER THO THAHAN
-0xB8	0x0E18	#THAI CHARACTER THO THONG
-0xB9	0x0E19	#THAI CHARACTER NO NU
-0xBA	0x0E1A	#THAI CHARACTER BO BAIMAI
-0xBB	0x0E1B	#THAI CHARACTER PO PLA
-0xBC	0x0E1C	#THAI CHARACTER PHO PHUNG
-0xBD	0x0E1D	#THAI CHARACTER FO FA
-0xBE	0x0E1E	#THAI CHARACTER PHO PHAN
-0xBF	0x0E1F	#THAI CHARACTER FO FAN
-0xC0	0x0E20	#THAI CHARACTER PHO SAMPHAO
-0xC1	0x0E21	#THAI CHARACTER MO MA
-0xC2	0x0E22	#THAI CHARACTER YO YAK
-0xC3	0x0E23	#THAI CHARACTER RO RUA
-0xC4	0x0E24	#THAI CHARACTER RU
-0xC5	0x0E25	#THAI CHARACTER LO LING
-0xC6	0x0E26	#THAI CHARACTER LU
-0xC7	0x0E27	#THAI CHARACTER WO WAEN
-0xC8	0x0E28	#THAI CHARACTER SO SALA
-0xC9	0x0E29	#THAI CHARACTER SO RUSI
-0xCA	0x0E2A	#THAI CHARACTER SO SUA
-0xCB	0x0E2B	#THAI CHARACTER HO HIP
-0xCC	0x0E2C	#THAI CHARACTER LO CHULA
-0xCD	0x0E2D	#THAI CHARACTER O ANG
-0xCE	0x0E2E	#THAI CHARACTER HO NOKHUK
-0xCF	0x0E2F	#THAI CHARACTER PAIYANNOI
-0xD0	0x0E30	#THAI CHARACTER SARA A
-0xD1	0x0E31	#THAI CHARACTER MAI HAN-AKAT
-0xD2	0x0E32	#THAI CHARACTER SARA AA
-0xD3	0x0E33	#THAI CHARACTER SARA AM
-0xD4	0x0E34	#THAI CHARACTER SARA I
-0xD5	0x0E35	#THAI CHARACTER SARA II
-0xD6	0x0E36	#THAI CHARACTER SARA UE
-0xD7	0x0E37	#THAI CHARACTER SARA UEE
-0xD8	0x0E38	#THAI CHARACTER SARA U
-0xD9	0x0E39	#THAI CHARACTER SARA UU
-0xDA	0x0E3A	#THAI CHARACTER PHINTHU
-0xDB	      	#UNDEFINED
-0xDC	      	#UNDEFINED
-0xDD	      	#UNDEFINED
-0xDE	      	#UNDEFINED
-0xDF	0x0E3F	#THAI CURRENCY SYMBOL BAHT
-0xE0	0x0E40	#THAI CHARACTER SARA E
-0xE1	0x0E41	#THAI CHARACTER SARA AE
-0xE2	0x0E42	#THAI CHARACTER SARA O
-0xE3	0x0E43	#THAI CHARACTER SARA AI MAIMUAN
-0xE4	0x0E44	#THAI CHARACTER SARA AI MAIMALAI
-0xE5	0x0E45	#THAI CHARACTER LAKKHANGYAO
-0xE6	0x0E46	#THAI CHARACTER MAIYAMOK
-0xE7	0x0E47	#THAI CHARACTER MAITAIKHU
-0xE8	0x0E48	#THAI CHARACTER MAI EK
-0xE9	0x0E49	#THAI CHARACTER MAI THO
-0xEA	0x0E4A	#THAI CHARACTER MAI TRI
-0xEB	0x0E4B	#THAI CHARACTER MAI CHATTAWA
-0xEC	0x0E4C	#THAI CHARACTER THANTHAKHAT
-0xED	0x0E4D	#THAI CHARACTER NIKHAHIT
-0xEE	0x0E4E	#THAI CHARACTER YAMAKKAN
-0xEF	0x0E4F	#THAI CHARACTER FONGMAN
-0xF0	0x0E50	#THAI DIGIT ZERO
-0xF1	0x0E51	#THAI DIGIT ONE
-0xF2	0x0E52	#THAI DIGIT TWO
-0xF3	0x0E53	#THAI DIGIT THREE
-0xF4	0x0E54	#THAI DIGIT FOUR
-0xF5	0x0E55	#THAI DIGIT FIVE
-0xF6	0x0E56	#THAI DIGIT SIX
-0xF7	0x0E57	#THAI DIGIT SEVEN
-0xF8	0x0E58	#THAI DIGIT EIGHT
-0xF9	0x0E59	#THAI DIGIT NINE
-0xFA	0x0E5A	#THAI CHARACTER ANGKHANKHU
-0xFB	0x0E5B	#THAI CHARACTER KHOMUT
-0xFC	      	#UNDEFINED
-0xFD	      	#UNDEFINED
-0xFE	      	#UNDEFINED
-0xFF	      	#UNDEFINED
diff --git a/lib/ucmaps/cp932.txt b/lib/ucmaps/cp932.txt
deleted file mode 100755
index 36bfdbfab..000000000
--- a/lib/ucmaps/cp932.txt
+++ /dev/null
@@ -1,7998 +0,0 @@
-#
-#    Name:     cp932 to Unicode table
-#    Unicode version: 2.0
-#    Table version: 2.01
-#    Table format:  Format A
-#    Date:          04/15/98
-#
-#    Contact:       cpxlate@microsoft.com
-#
-#    General notes: none
-#
-#    Format: Three tab-separated columns
-#        Column #1 is the cp932 code (in hex)
-#        Column #2 is the Unicode (in hex as 0xXXXX)
-#        Column #3 is the Unicode name (follows a comment sign, '#')
-#
-#    The entries are in cp932 order
-#
-0x00	0x0000	#NULL
-0x01	0x0001	#START OF HEADING
-0x02	0x0002	#START OF TEXT
-0x03	0x0003	#END OF TEXT
-0x04	0x0004	#END OF TRANSMISSION
-0x05	0x0005	#ENQUIRY
-0x06	0x0006	#ACKNOWLEDGE
-0x07	0x0007	#BELL
-0x08	0x0008	#BACKSPACE
-0x09	0x0009	#HORIZONTAL TABULATION
-0x0A	0x000A	#LINE FEED
-0x0B	0x000B	#VERTICAL TABULATION
-0x0C	0x000C	#FORM FEED
-0x0D	0x000D	#CARRIAGE RETURN
-0x0E	0x000E	#SHIFT OUT
-0x0F	0x000F	#SHIFT IN
-0x10	0x0010	#DATA LINK ESCAPE
-0x11	0x0011	#DEVICE CONTROL ONE
-0x12	0x0012	#DEVICE CONTROL TWO
-0x13	0x0013	#DEVICE CONTROL THREE
-0x14	0x0014	#DEVICE CONTROL FOUR
-0x15	0x0015	#NEGATIVE ACKNOWLEDGE
-0x16	0x0016	#SYNCHRONOUS IDLE
-0x17	0x0017	#END OF TRANSMISSION BLOCK
-0x18	0x0018	#CANCEL
-0x19	0x0019	#END OF MEDIUM
-0x1A	0x001A	#SUBSTITUTE
-0x1B	0x001B	#ESCAPE
-0x1C	0x001C	#FILE SEPARATOR
-0x1D	0x001D	#GROUP SEPARATOR
-0x1E	0x001E	#RECORD SEPARATOR
-0x1F	0x001F	#UNIT SEPARATOR
-0x20	0x0020	#SPACE
-0x21	0x0021	#EXCLAMATION MARK
-0x22	0x0022	#QUOTATION MARK
-0x23	0x0023	#NUMBER SIGN
-0x24	0x0024	#DOLLAR SIGN
-0x25	0x0025	#PERCENT SIGN
-0x26	0x0026	#AMPERSAND
-0x27	0x0027	#APOSTROPHE
-0x28	0x0028	#LEFT PARENTHESIS
-0x29	0x0029	#RIGHT PARENTHESIS
-0x2A	0x002A	#ASTERISK
-0x2B	0x002B	#PLUS SIGN
-0x2C	0x002C	#COMMA
-0x2D	0x002D	#HYPHEN-MINUS
-0x2E	0x002E	#FULL STOP
-0x2F	0x002F	#SOLIDUS
-0x30	0x0030	#DIGIT ZERO
-0x31	0x0031	#DIGIT ONE
-0x32	0x0032	#DIGIT TWO
-0x33	0x0033	#DIGIT THREE
-0x34	0x0034	#DIGIT FOUR
-0x35	0x0035	#DIGIT FIVE
-0x36	0x0036	#DIGIT SIX
-0x37	0x0037	#DIGIT SEVEN
-0x38	0x0038	#DIGIT EIGHT
-0x39	0x0039	#DIGIT NINE
-0x3A	0x003A	#COLON
-0x3B	0x003B	#SEMICOLON
-0x3C	0x003C	#LESS-THAN SIGN
-0x3D	0x003D	#EQUALS SIGN
-0x3E	0x003E	#GREATER-THAN SIGN
-0x3F	0x003F	#QUESTION MARK
-0x40	0x0040	#COMMERCIAL AT
-0x41	0x0041	#LATIN CAPITAL LETTER A
-0x42	0x0042	#LATIN CAPITAL LETTER B
-0x43	0x0043	#LATIN CAPITAL LETTER C
-0x44	0x0044	#LATIN CAPITAL LETTER D
-0x45	0x0045	#LATIN CAPITAL LETTER E
-0x46	0x0046	#LATIN CAPITAL LETTER F
-0x47	0x0047	#LATIN CAPITAL LETTER G
-0x48	0x0048	#LATIN CAPITAL LETTER H
-0x49	0x0049	#LATIN CAPITAL LETTER I
-0x4A	0x004A	#LATIN CAPITAL LETTER J
-0x4B	0x004B	#LATIN CAPITAL LETTER K
-0x4C	0x004C	#LATIN CAPITAL LETTER L
-0x4D	0x004D	#LATIN CAPITAL LETTER M
-0x4E	0x004E	#LATIN CAPITAL LETTER N
-0x4F	0x004F	#LATIN CAPITAL LETTER O
-0x50	0x0050	#LATIN CAPITAL LETTER P
-0x51	0x0051	#LATIN CAPITAL LETTER Q
-0x52	0x0052	#LATIN CAPITAL LETTER R
-0x53	0x0053	#LATIN CAPITAL LETTER S
-0x54	0x0054	#LATIN CAPITAL LETTER T
-0x55	0x0055	#LATIN CAPITAL LETTER U
-0x56	0x0056	#LATIN CAPITAL LETTER V
-0x57	0x0057	#LATIN CAPITAL LETTER W
-0x58	0x0058	#LATIN CAPITAL LETTER X
-0x59	0x0059	#LATIN CAPITAL LETTER Y
-0x5A	0x005A	#LATIN CAPITAL LETTER Z
-0x5B	0x005B	#LEFT SQUARE BRACKET
-0x5C	0x005C	#REVERSE SOLIDUS
-0x5D	0x005D	#RIGHT SQUARE BRACKET
-0x5E	0x005E	#CIRCUMFLEX ACCENT
-0x5F	0x005F	#LOW LINE
-0x60	0x0060	#GRAVE ACCENT
-0x61	0x0061	#LATIN SMALL LETTER A
-0x62	0x0062	#LATIN SMALL LETTER B
-0x63	0x0063	#LATIN SMALL LETTER C
-0x64	0x0064	#LATIN SMALL LETTER D
-0x65	0x0065	#LATIN SMALL LETTER E
-0x66	0x0066	#LATIN SMALL LETTER F
-0x67	0x0067	#LATIN SMALL LETTER G
-0x68	0x0068	#LATIN SMALL LETTER H
-0x69	0x0069	#LATIN SMALL LETTER I
-0x6A	0x006A	#LATIN SMALL LETTER J
-0x6B	0x006B	#LATIN SMALL LETTER K
-0x6C	0x006C	#LATIN SMALL LETTER L
-0x6D	0x006D	#LATIN SMALL LETTER M
-0x6E	0x006E	#LATIN SMALL LETTER N
-0x6F	0x006F	#LATIN SMALL LETTER O
-0x70	0x0070	#LATIN SMALL LETTER P
-0x71	0x0071	#LATIN SMALL LETTER Q
-0x72	0x0072	#LATIN SMALL LETTER R
-0x73	0x0073	#LATIN SMALL LETTER S
-0x74	0x0074	#LATIN SMALL LETTER T
-0x75	0x0075	#LATIN SMALL LETTER U
-0x76	0x0076	#LATIN SMALL LETTER V
-0x77	0x0077	#LATIN SMALL LETTER W
-0x78	0x0078	#LATIN SMALL LETTER X
-0x79	0x0079	#LATIN SMALL LETTER Y
-0x7A	0x007A	#LATIN SMALL LETTER Z
-0x7B	0x007B	#LEFT CURLY BRACKET
-0x7C	0x007C	#VERTICAL LINE
-0x7D	0x007D	#RIGHT CURLY BRACKET
-0x7E	0x007E	#TILDE
-0x7F	0x007F	#DELETE
-0x80	      	#UNDEFINED
-0x81	      	#DBCS LEAD BYTE
-0x82	      	#DBCS LEAD BYTE
-0x83	      	#DBCS LEAD BYTE
-0x84	      	#DBCS LEAD BYTE
-0x85	      	#DBCS LEAD BYTE
-0x86	      	#DBCS LEAD BYTE
-0x87	      	#DBCS LEAD BYTE
-0x88	      	#DBCS LEAD BYTE
-0x89	      	#DBCS LEAD BYTE
-0x8A	      	#DBCS LEAD BYTE
-0x8B	      	#DBCS LEAD BYTE
-0x8C	      	#DBCS LEAD BYTE
-0x8D	      	#DBCS LEAD BYTE
-0x8E	      	#DBCS LEAD BYTE
-0x8F	      	#DBCS LEAD BYTE
-0x90	      	#DBCS LEAD BYTE
-0x91	      	#DBCS LEAD BYTE
-0x92	      	#DBCS LEAD BYTE
-0x93	      	#DBCS LEAD BYTE
-0x94	      	#DBCS LEAD BYTE
-0x95	      	#DBCS LEAD BYTE
-0x96	      	#DBCS LEAD BYTE
-0x97	      	#DBCS LEAD BYTE
-0x98	      	#DBCS LEAD BYTE
-0x99	      	#DBCS LEAD BYTE
-0x9A	      	#DBCS LEAD BYTE
-0x9B	      	#DBCS LEAD BYTE
-0x9C	      	#DBCS LEAD BYTE
-0x9D	      	#DBCS LEAD BYTE
-0x9E	      	#DBCS LEAD BYTE
-0x9F	      	#DBCS LEAD BYTE
-0xA0	      	#UNDEFINED
-0xA1	0xFF61	#HALFWIDTH IDEOGRAPHIC FULL STOP
-0xA2	0xFF62	#HALFWIDTH LEFT CORNER BRACKET
-0xA3	0xFF63	#HALFWIDTH RIGHT CORNER BRACKET
-0xA4	0xFF64	#HALFWIDTH IDEOGRAPHIC COMMA
-0xA5	0xFF65	#HALFWIDTH KATAKANA MIDDLE DOT
-0xA6	0xFF66	#HALFWIDTH KATAKANA LETTER WO
-0xA7	0xFF67	#HALFWIDTH KATAKANA LETTER SMALL A
-0xA8	0xFF68	#HALFWIDTH KATAKANA LETTER SMALL I
-0xA9	0xFF69	#HALFWIDTH KATAKANA LETTER SMALL U
-0xAA	0xFF6A	#HALFWIDTH KATAKANA LETTER SMALL E
-0xAB	0xFF6B	#HALFWIDTH KATAKANA LETTER SMALL O
-0xAC	0xFF6C	#HALFWIDTH KATAKANA LETTER SMALL YA
-0xAD	0xFF6D	#HALFWIDTH KATAKANA LETTER SMALL YU
-0xAE	0xFF6E	#HALFWIDTH KATAKANA LETTER SMALL YO
-0xAF	0xFF6F	#HALFWIDTH KATAKANA LETTER SMALL TU
-0xB0	0xFF70	#HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK
-0xB1	0xFF71	#HALFWIDTH KATAKANA LETTER A
-0xB2	0xFF72	#HALFWIDTH KATAKANA LETTER I
-0xB3	0xFF73	#HALFWIDTH KATAKANA LETTER U
-0xB4	0xFF74	#HALFWIDTH KATAKANA LETTER E
-0xB5	0xFF75	#HALFWIDTH KATAKANA LETTER O
-0xB6	0xFF76	#HALFWIDTH KATAKANA LETTER KA
-0xB7	0xFF77	#HALFWIDTH KATAKANA LETTER KI
-0xB8	0xFF78	#HALFWIDTH KATAKANA LETTER KU
-0xB9	0xFF79	#HALFWIDTH KATAKANA LETTER KE
-0xBA	0xFF7A	#HALFWIDTH KATAKANA LETTER KO
-0xBB	0xFF7B	#HALFWIDTH KATAKANA LETTER SA
-0xBC	0xFF7C	#HALFWIDTH KATAKANA LETTER SI
-0xBD	0xFF7D	#HALFWIDTH KATAKANA LETTER SU
-0xBE	0xFF7E	#HALFWIDTH KATAKANA LETTER SE
-0xBF	0xFF7F	#HALFWIDTH KATAKANA LETTER SO
-0xC0	0xFF80	#HALFWIDTH KATAKANA LETTER TA
-0xC1	0xFF81	#HALFWIDTH KATAKANA LETTER TI
-0xC2	0xFF82	#HALFWIDTH KATAKANA LETTER TU
-0xC3	0xFF83	#HALFWIDTH KATAKANA LETTER TE
-0xC4	0xFF84	#HALFWIDTH KATAKANA LETTER TO
-0xC5	0xFF85	#HALFWIDTH KATAKANA LETTER NA
-0xC6	0xFF86	#HALFWIDTH KATAKANA LETTER NI
-0xC7	0xFF87	#HALFWIDTH KATAKANA LETTER NU
-0xC8	0xFF88	#HALFWIDTH KATAKANA LETTER NE
-0xC9	0xFF89	#HALFWIDTH KATAKANA LETTER NO
-0xCA	0xFF8A	#HALFWIDTH KATAKANA LETTER HA
-0xCB	0xFF8B	#HALFWIDTH KATAKANA LETTER HI
-0xCC	0xFF8C	#HALFWIDTH KATAKANA LETTER HU
-0xCD	0xFF8D	#HALFWIDTH KATAKANA LETTER HE
-0xCE	0xFF8E	#HALFWIDTH KATAKANA LETTER HO
-0xCF	0xFF8F	#HALFWIDTH KATAKANA LETTER MA
-0xD0	0xFF90	#HALFWIDTH KATAKANA LETTER MI
-0xD1	0xFF91	#HALFWIDTH KATAKANA LETTER MU
-0xD2	0xFF92	#HALFWIDTH KATAKANA LETTER ME
-0xD3	0xFF93	#HALFWIDTH KATAKANA LETTER MO
-0xD4	0xFF94	#HALFWIDTH KATAKANA LETTER YA
-0xD5	0xFF95	#HALFWIDTH KATAKANA LETTER YU
-0xD6	0xFF96	#HALFWIDTH KATAKANA LETTER YO
-0xD7	0xFF97	#HALFWIDTH KATAKANA LETTER RA
-0xD8	0xFF98	#HALFWIDTH KATAKANA LETTER RI
-0xD9	0xFF99	#HALFWIDTH KATAKANA LETTER RU
-0xDA	0xFF9A	#HALFWIDTH KATAKANA LETTER RE
-0xDB	0xFF9B	#HALFWIDTH KATAKANA LETTER RO
-0xDC	0xFF9C	#HALFWIDTH KATAKANA LETTER WA
-0xDD	0xFF9D	#HALFWIDTH KATAKANA LETTER N
-0xDE	0xFF9E	#HALFWIDTH KATAKANA VOICED SOUND MARK
-0xDF	0xFF9F	#HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
-0xE0	      	#DBCS LEAD BYTE
-0xE1	      	#DBCS LEAD BYTE
-0xE2	      	#DBCS LEAD BYTE
-0xE3	      	#DBCS LEAD BYTE
-0xE4	      	#DBCS LEAD BYTE
-0xE5	      	#DBCS LEAD BYTE
-0xE6	      	#DBCS LEAD BYTE
-0xE7	      	#DBCS LEAD BYTE
-0xE8	      	#DBCS LEAD BYTE
-0xE9	      	#DBCS LEAD BYTE
-0xEA	      	#DBCS LEAD BYTE
-0xEB	      	#DBCS LEAD BYTE
-0xEC	      	#DBCS LEAD BYTE
-0xED	      	#DBCS LEAD BYTE
-0xEE	      	#DBCS LEAD BYTE
-0xEF	      	#DBCS LEAD BYTE
-0xF0	      	#DBCS LEAD BYTE
-0xF1	      	#DBCS LEAD BYTE
-0xF2	      	#DBCS LEAD BYTE
-0xF3	      	#DBCS LEAD BYTE
-0xF4	      	#DBCS LEAD BYTE
-0xF5	      	#DBCS LEAD BYTE
-0xF6	      	#DBCS LEAD BYTE
-0xF7	      	#DBCS LEAD BYTE
-0xF8	      	#DBCS LEAD BYTE
-0xF9	      	#DBCS LEAD BYTE
-0xFA	      	#DBCS LEAD BYTE
-0xFB	      	#DBCS LEAD BYTE
-0xFC	      	#DBCS LEAD BYTE
-0xFD	      	#UNDEFINED
-0xFE	      	#UNDEFINED
-0xFF	      	#UNDEFINED
-0x8140	0x3000	#IDEOGRAPHIC SPACE
-0x8141	0x3001	#IDEOGRAPHIC COMMA
-0x8142	0x3002	#IDEOGRAPHIC FULL STOP
-0x8143	0xFF0C	#FULLWIDTH COMMA
-0x8144	0xFF0E	#FULLWIDTH FULL STOP
-0x8145	0x30FB	#KATAKANA MIDDLE DOT
-0x8146	0xFF1A	#FULLWIDTH COLON
-0x8147	0xFF1B	#FULLWIDTH SEMICOLON
-0x8148	0xFF1F	#FULLWIDTH QUESTION MARK
-0x8149	0xFF01	#FULLWIDTH EXCLAMATION MARK
-0x814A	0x309B	#KATAKANA-HIRAGANA VOICED SOUND MARK
-0x814B	0x309C	#KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
-0x814C	0x00B4	#ACUTE ACCENT
-0x814D	0xFF40	#FULLWIDTH GRAVE ACCENT
-0x814E	0x00A8	#DIAERESIS
-0x814F	0xFF3E	#FULLWIDTH CIRCUMFLEX ACCENT
-0x8150	0xFFE3	#FULLWIDTH MACRON
-0x8151	0xFF3F	#FULLWIDTH LOW LINE
-0x8152	0x30FD	#KATAKANA ITERATION MARK
-0x8153	0x30FE	#KATAKANA VOICED ITERATION MARK
-0x8154	0x309D	#HIRAGANA ITERATION MARK
-0x8155	0x309E	#HIRAGANA VOICED ITERATION MARK
-0x8156	0x3003	#DITTO MARK
-0x8157	0x4EDD	#CJK UNIFIED IDEOGRAPH
-0x8158	0x3005	#IDEOGRAPHIC ITERATION MARK
-0x8159	0x3006	#IDEOGRAPHIC CLOSING MARK
-0x815A	0x3007	#IDEOGRAPHIC NUMBER ZERO
-0x815B	0x30FC	#KATAKANA-HIRAGANA PROLONGED SOUND MARK
-0x815C	0x2015	#HORIZONTAL BAR
-0x815D	0x2010	#HYPHEN
-0x815E	0xFF0F	#FULLWIDTH SOLIDUS
-0x815F	0xFF3C	#FULLWIDTH REVERSE SOLIDUS
-0x8160	0xFF5E	#FULLWIDTH TILDE
-0x8161	0x2225	#PARALLEL TO
-0x8162	0xFF5C	#FULLWIDTH VERTICAL LINE
-0x8163	0x2026	#HORIZONTAL ELLIPSIS
-0x8164	0x2025	#TWO DOT LEADER
-0x8165	0x2018	#LEFT SINGLE QUOTATION MARK
-0x8166	0x2019	#RIGHT SINGLE QUOTATION MARK
-0x8167	0x201C	#LEFT DOUBLE QUOTATION MARK
-0x8168	0x201D	#RIGHT DOUBLE QUOTATION MARK
-0x8169	0xFF08	#FULLWIDTH LEFT PARENTHESIS
-0x816A	0xFF09	#FULLWIDTH RIGHT PARENTHESIS
-0x816B	0x3014	#LEFT TORTOISE SHELL BRACKET
-0x816C	0x3015	#RIGHT TORTOISE SHELL BRACKET
-0x816D	0xFF3B	#FULLWIDTH LEFT SQUARE BRACKET
-0x816E	0xFF3D	#FULLWIDTH RIGHT SQUARE BRACKET
-0x816F	0xFF5B	#FULLWIDTH LEFT CURLY BRACKET
-0x8170	0xFF5D	#FULLWIDTH RIGHT CURLY BRACKET
-0x8171	0x3008	#LEFT ANGLE BRACKET
-0x8172	0x3009	#RIGHT ANGLE BRACKET
-0x8173	0x300A	#LEFT DOUBLE ANGLE BRACKET
-0x8174	0x300B	#RIGHT DOUBLE ANGLE BRACKET
-0x8175	0x300C	#LEFT CORNER BRACKET
-0x8176	0x300D	#RIGHT CORNER BRACKET
-0x8177	0x300E	#LEFT WHITE CORNER BRACKET
-0x8178	0x300F	#RIGHT WHITE CORNER BRACKET
-0x8179	0x3010	#LEFT BLACK LENTICULAR BRACKET
-0x817A	0x3011	#RIGHT BLACK LENTICULAR BRACKET
-0x817B	0xFF0B	#FULLWIDTH PLUS SIGN
-0x817C	0xFF0D	#FULLWIDTH HYPHEN-MINUS
-0x817D	0x00B1	#PLUS-MINUS SIGN
-0x817E	0x00D7	#MULTIPLICATION SIGN
-0x8180	0x00F7	#DIVISION SIGN
-0x8181	0xFF1D	#FULLWIDTH EQUALS SIGN
-0x8182	0x2260	#NOT EQUAL TO
-0x8183	0xFF1C	#FULLWIDTH LESS-THAN SIGN
-0x8184	0xFF1E	#FULLWIDTH GREATER-THAN SIGN
-0x8185	0x2266	#LESS-THAN OVER EQUAL TO
-0x8186	0x2267	#GREATER-THAN OVER EQUAL TO
-0x8187	0x221E	#INFINITY
-0x8188	0x2234	#THEREFORE
-0x8189	0x2642	#MALE SIGN
-0x818A	0x2640	#FEMALE SIGN
-0x818B	0x00B0	#DEGREE SIGN
-0x818C	0x2032	#PRIME
-0x818D	0x2033	#DOUBLE PRIME
-0x818E	0x2103	#DEGREE CELSIUS
-0x818F	0xFFE5	#FULLWIDTH YEN SIGN
-0x8190	0xFF04	#FULLWIDTH DOLLAR SIGN
-0x8191	0xFFE0	#FULLWIDTH CENT SIGN
-0x8192	0xFFE1	#FULLWIDTH POUND SIGN
-0x8193	0xFF05	#FULLWIDTH PERCENT SIGN
-0x8194	0xFF03	#FULLWIDTH NUMBER SIGN
-0x8195	0xFF06	#FULLWIDTH AMPERSAND
-0x8196	0xFF0A	#FULLWIDTH ASTERISK
-0x8197	0xFF20	#FULLWIDTH COMMERCIAL AT
-0x8198	0x00A7	#SECTION SIGN
-0x8199	0x2606	#WHITE STAR
-0x819A	0x2605	#BLACK STAR
-0x819B	0x25CB	#WHITE CIRCLE
-0x819C	0x25CF	#BLACK CIRCLE
-0x819D	0x25CE	#BULLSEYE
-0x819E	0x25C7	#WHITE DIAMOND
-0x819F	0x25C6	#BLACK DIAMOND
-0x81A0	0x25A1	#WHITE SQUARE
-0x81A1	0x25A0	#BLACK SQUARE
-0x81A2	0x25B3	#WHITE UP-POINTING TRIANGLE
-0x81A3	0x25B2	#BLACK UP-POINTING TRIANGLE
-0x81A4	0x25BD	#WHITE DOWN-POINTING TRIANGLE
-0x81A5	0x25BC	#BLACK DOWN-POINTING TRIANGLE
-0x81A6	0x203B	#REFERENCE MARK
-0x81A7	0x3012	#POSTAL MARK
-0x81A8	0x2192	#RIGHTWARDS ARROW
-0x81A9	0x2190	#LEFTWARDS ARROW
-0x81AA	0x2191	#UPWARDS ARROW
-0x81AB	0x2193	#DOWNWARDS ARROW
-0x81AC	0x3013	#GETA MARK
-0x81B8	0x2208	#ELEMENT OF
-0x81B9	0x220B	#CONTAINS AS MEMBER
-0x81BA	0x2286	#SUBSET OF OR EQUAL TO
-0x81BB	0x2287	#SUPERSET OF OR EQUAL TO
-0x81BC	0x2282	#SUBSET OF
-0x81BD	0x2283	#SUPERSET OF
-0x81BE	0x222A	#UNION
-0x81BF	0x2229	#INTERSECTION
-0x81C8	0x2227	#LOGICAL AND
-0x81C9	0x2228	#LOGICAL OR
-0x81CA	0xFFE2	#FULLWIDTH NOT SIGN
-0x81CB	0x21D2	#RIGHTWARDS DOUBLE ARROW
-0x81CC	0x21D4	#LEFT RIGHT DOUBLE ARROW
-0x81CD	0x2200	#FOR ALL
-0x81CE	0x2203	#THERE EXISTS
-0x81DA	0x2220	#ANGLE
-0x81DB	0x22A5	#UP TACK
-0x81DC	0x2312	#ARC
-0x81DD	0x2202	#PARTIAL DIFFERENTIAL
-0x81DE	0x2207	#NABLA
-0x81DF	0x2261	#IDENTICAL TO
-0x81E0	0x2252	#APPROXIMATELY EQUAL TO OR THE IMAGE OF
-0x81E1	0x226A	#MUCH LESS-THAN
-0x81E2	0x226B	#MUCH GREATER-THAN
-0x81E3	0x221A	#SQUARE ROOT
-0x81E4	0x223D	#REVERSED TILDE
-0x81E5	0x221D	#PROPORTIONAL TO
-0x81E6	0x2235	#BECAUSE
-0x81E7	0x222B	#INTEGRAL
-0x81E8	0x222C	#DOUBLE INTEGRAL
-0x81F0	0x212B	#ANGSTROM SIGN
-0x81F1	0x2030	#PER MILLE SIGN
-0x81F2	0x266F	#MUSIC SHARP SIGN
-0x81F3	0x266D	#MUSIC FLAT SIGN
-0x81F4	0x266A	#EIGHTH NOTE
-0x81F5	0x2020	#DAGGER
-0x81F6	0x2021	#DOUBLE DAGGER
-0x81F7	0x00B6	#PILCROW SIGN
-0x81FC	0x25EF	#LARGE CIRCLE
-0x824F	0xFF10	#FULLWIDTH DIGIT ZERO
-0x8250	0xFF11	#FULLWIDTH DIGIT ONE
-0x8251	0xFF12	#FULLWIDTH DIGIT TWO
-0x8252	0xFF13	#FULLWIDTH DIGIT THREE
-0x8253	0xFF14	#FULLWIDTH DIGIT FOUR
-0x8254	0xFF15	#FULLWIDTH DIGIT FIVE
-0x8255	0xFF16	#FULLWIDTH DIGIT SIX
-0x8256	0xFF17	#FULLWIDTH DIGIT SEVEN
-0x8257	0xFF18	#FULLWIDTH DIGIT EIGHT
-0x8258	0xFF19	#FULLWIDTH DIGIT NINE
-0x8260	0xFF21	#FULLWIDTH LATIN CAPITAL LETTER A
-0x8261	0xFF22	#FULLWIDTH LATIN CAPITAL LETTER B
-0x8262	0xFF23	#FULLWIDTH LATIN CAPITAL LETTER C
-0x8263	0xFF24	#FULLWIDTH LATIN CAPITAL LETTER D
-0x8264	0xFF25	#FULLWIDTH LATIN CAPITAL LETTER E
-0x8265	0xFF26	#FULLWIDTH LATIN CAPITAL LETTER F
-0x8266	0xFF27	#FULLWIDTH LATIN CAPITAL LETTER G
-0x8267	0xFF28	#FULLWIDTH LATIN CAPITAL LETTER H
-0x8268	0xFF29	#FULLWIDTH LATIN CAPITAL LETTER I
-0x8269	0xFF2A	#FULLWIDTH LATIN CAPITAL LETTER J
-0x826A	0xFF2B	#FULLWIDTH LATIN CAPITAL LETTER K
-0x826B	0xFF2C	#FULLWIDTH LATIN CAPITAL LETTER L
-0x826C	0xFF2D	#FULLWIDTH LATIN CAPITAL LETTER M
-0x826D	0xFF2E	#FULLWIDTH LATIN CAPITAL LETTER N
-0x826E	0xFF2F	#FULLWIDTH LATIN CAPITAL LETTER O
-0x826F	0xFF30	#FULLWIDTH LATIN CAPITAL LETTER P
-0x8270	0xFF31	#FULLWIDTH LATIN CAPITAL LETTER Q
-0x8271	0xFF32	#FULLWIDTH LATIN CAPITAL LETTER R
-0x8272	0xFF33	#FULLWIDTH LATIN CAPITAL LETTER S
-0x8273	0xFF34	#FULLWIDTH LATIN CAPITAL LETTER T
-0x8274	0xFF35	#FULLWIDTH LATIN CAPITAL LETTER U
-0x8275	0xFF36	#FULLWIDTH LATIN CAPITAL LETTER V
-0x8276	0xFF37	#FULLWIDTH LATIN CAPITAL LETTER W
-0x8277	0xFF38	#FULLWIDTH LATIN CAPITAL LETTER X
-0x8278	0xFF39	#FULLWIDTH LATIN CAPITAL LETTER Y
-0x8279	0xFF3A	#FULLWIDTH LATIN CAPITAL LETTER Z
-0x8281	0xFF41	#FULLWIDTH LATIN SMALL LETTER A
-0x8282	0xFF42	#FULLWIDTH LATIN SMALL LETTER B
-0x8283	0xFF43	#FULLWIDTH LATIN SMALL LETTER C
-0x8284	0xFF44	#FULLWIDTH LATIN SMALL LETTER D
-0x8285	0xFF45	#FULLWIDTH LATIN SMALL LETTER E
-0x8286	0xFF46	#FULLWIDTH LATIN SMALL LETTER F
-0x8287	0xFF47	#FULLWIDTH LATIN SMALL LETTER G
-0x8288	0xFF48	#FULLWIDTH LATIN SMALL LETTER H
-0x8289	0xFF49	#FULLWIDTH LATIN SMALL LETTER I
-0x828A	0xFF4A	#FULLWIDTH LATIN SMALL LETTER J
-0x828B	0xFF4B	#FULLWIDTH LATIN SMALL LETTER K
-0x828C	0xFF4C	#FULLWIDTH LATIN SMALL LETTER L
-0x828D	0xFF4D	#FULLWIDTH LATIN SMALL LETTER M
-0x828E	0xFF4E	#FULLWIDTH LATIN SMALL LETTER N
-0x828F	0xFF4F	#FULLWIDTH LATIN SMALL LETTER O
-0x8290	0xFF50	#FULLWIDTH LATIN SMALL LETTER P
-0x8291	0xFF51	#FULLWIDTH LATIN SMALL LETTER Q
-0x8292	0xFF52	#FULLWIDTH LATIN SMALL LETTER R
-0x8293	0xFF53	#FULLWIDTH LATIN SMALL LETTER S
-0x8294	0xFF54	#FULLWIDTH LATIN SMALL LETTER T
-0x8295	0xFF55	#FULLWIDTH LATIN SMALL LETTER U
-0x8296	0xFF56	#FULLWIDTH LATIN SMALL LETTER V
-0x8297	0xFF57	#FULLWIDTH LATIN SMALL LETTER W
-0x8298	0xFF58	#FULLWIDTH LATIN SMALL LETTER X
-0x8299	0xFF59	#FULLWIDTH LATIN SMALL LETTER Y
-0x829A	0xFF5A	#FULLWIDTH LATIN SMALL LETTER Z
-0x829F	0x3041	#HIRAGANA LETTER SMALL A
-0x82A0	0x3042	#HIRAGANA LETTER A
-0x82A1	0x3043	#HIRAGANA LETTER SMALL I
-0x82A2	0x3044	#HIRAGANA LETTER I
-0x82A3	0x3045	#HIRAGANA LETTER SMALL U
-0x82A4	0x3046	#HIRAGANA LETTER U
-0x82A5	0x3047	#HIRAGANA LETTER SMALL E
-0x82A6	0x3048	#HIRAGANA LETTER E
-0x82A7	0x3049	#HIRAGANA LETTER SMALL O
-0x82A8	0x304A	#HIRAGANA LETTER O
-0x82A9	0x304B	#HIRAGANA LETTER KA
-0x82AA	0x304C	#HIRAGANA LETTER GA
-0x82AB	0x304D	#HIRAGANA LETTER KI
-0x82AC	0x304E	#HIRAGANA LETTER GI
-0x82AD	0x304F	#HIRAGANA LETTER KU
-0x82AE	0x3050	#HIRAGANA LETTER GU
-0x82AF	0x3051	#HIRAGANA LETTER KE
-0x82B0	0x3052	#HIRAGANA LETTER GE
-0x82B1	0x3053	#HIRAGANA LETTER KO
-0x82B2	0x3054	#HIRAGANA LETTER GO
-0x82B3	0x3055	#HIRAGANA LETTER SA
-0x82B4	0x3056	#HIRAGANA LETTER ZA
-0x82B5	0x3057	#HIRAGANA LETTER SI
-0x82B6	0x3058	#HIRAGANA LETTER ZI
-0x82B7	0x3059	#HIRAGANA LETTER SU
-0x82B8	0x305A	#HIRAGANA LETTER ZU
-0x82B9	0x305B	#HIRAGANA LETTER SE
-0x82BA	0x305C	#HIRAGANA LETTER ZE
-0x82BB	0x305D	#HIRAGANA LETTER SO
-0x82BC	0x305E	#HIRAGANA LETTER ZO
-0x82BD	0x305F	#HIRAGANA LETTER TA
-0x82BE	0x3060	#HIRAGANA LETTER DA
-0x82BF	0x3061	#HIRAGANA LETTER TI
-0x82C0	0x3062	#HIRAGANA LETTER DI
-0x82C1	0x3063	#HIRAGANA LETTER SMALL TU
-0x82C2	0x3064	#HIRAGANA LETTER TU
-0x82C3	0x3065	#HIRAGANA LETTER DU
-0x82C4	0x3066	#HIRAGANA LETTER TE
-0x82C5	0x3067	#HIRAGANA LETTER DE
-0x82C6	0x3068	#HIRAGANA LETTER TO
-0x82C7	0x3069	#HIRAGANA LETTER DO
-0x82C8	0x306A	#HIRAGANA LETTER NA
-0x82C9	0x306B	#HIRAGANA LETTER NI
-0x82CA	0x306C	#HIRAGANA LETTER NU
-0x82CB	0x306D	#HIRAGANA LETTER NE
-0x82CC	0x306E	#HIRAGANA LETTER NO
-0x82CD	0x306F	#HIRAGANA LETTER HA
-0x82CE	0x3070	#HIRAGANA LETTER BA
-0x82CF	0x3071	#HIRAGANA LETTER PA
-0x82D0	0x3072	#HIRAGANA LETTER HI
-0x82D1	0x3073	#HIRAGANA LETTER BI
-0x82D2	0x3074	#HIRAGANA LETTER PI
-0x82D3	0x3075	#HIRAGANA LETTER HU
-0x82D4	0x3076	#HIRAGANA LETTER BU
-0x82D5	0x3077	#HIRAGANA LETTER PU
-0x82D6	0x3078	#HIRAGANA LETTER HE
-0x82D7	0x3079	#HIRAGANA LETTER BE
-0x82D8	0x307A	#HIRAGANA LETTER PE
-0x82D9	0x307B	#HIRAGANA LETTER HO
-0x82DA	0x307C	#HIRAGANA LETTER BO
-0x82DB	0x307D	#HIRAGANA LETTER PO
-0x82DC	0x307E	#HIRAGANA LETTER MA
-0x82DD	0x307F	#HIRAGANA LETTER MI
-0x82DE	0x3080	#HIRAGANA LETTER MU
-0x82DF	0x3081	#HIRAGANA LETTER ME
-0x82E0	0x3082	#HIRAGANA LETTER MO
-0x82E1	0x3083	#HIRAGANA LETTER SMALL YA
-0x82E2	0x3084	#HIRAGANA LETTER YA
-0x82E3	0x3085	#HIRAGANA LETTER SMALL YU
-0x82E4	0x3086	#HIRAGANA LETTER YU
-0x82E5	0x3087	#HIRAGANA LETTER SMALL YO
-0x82E6	0x3088	#HIRAGANA LETTER YO
-0x82E7	0x3089	#HIRAGANA LETTER RA
-0x82E8	0x308A	#HIRAGANA LETTER RI
-0x82E9	0x308B	#HIRAGANA LETTER RU
-0x82EA	0x308C	#HIRAGANA LETTER RE
-0x82EB	0x308D	#HIRAGANA LETTER RO
-0x82EC	0x308E	#HIRAGANA LETTER SMALL WA
-0x82ED	0x308F	#HIRAGANA LETTER WA
-0x82EE	0x3090	#HIRAGANA LETTER WI
-0x82EF	0x3091	#HIRAGANA LETTER WE
-0x82F0	0x3092	#HIRAGANA LETTER WO
-0x82F1	0x3093	#HIRAGANA LETTER N
-0x8340	0x30A1	#KATAKANA LETTER SMALL A
-0x8341	0x30A2	#KATAKANA LETTER A
-0x8342	0x30A3	#KATAKANA LETTER SMALL I
-0x8343	0x30A4	#KATAKANA LETTER I
-0x8344	0x30A5	#KATAKANA LETTER SMALL U
-0x8345	0x30A6	#KATAKANA LETTER U
-0x8346	0x30A7	#KATAKANA LETTER SMALL E
-0x8347	0x30A8	#KATAKANA LETTER E
-0x8348	0x30A9	#KATAKANA LETTER SMALL O
-0x8349	0x30AA	#KATAKANA LETTER O
-0x834A	0x30AB	#KATAKANA LETTER KA
-0x834B	0x30AC	#KATAKANA LETTER GA
-0x834C	0x30AD	#KATAKANA LETTER KI
-0x834D	0x30AE	#KATAKANA LETTER GI
-0x834E	0x30AF	#KATAKANA LETTER KU
-0x834F	0x30B0	#KATAKANA LETTER GU
-0x8350	0x30B1	#KATAKANA LETTER KE
-0x8351	0x30B2	#KATAKANA LETTER GE
-0x8352	0x30B3	#KATAKANA LETTER KO
-0x8353	0x30B4	#KATAKANA LETTER GO
-0x8354	0x30B5	#KATAKANA LETTER SA
-0x8355	0x30B6	#KATAKANA LETTER ZA
-0x8356	0x30B7	#KATAKANA LETTER SI
-0x8357	0x30B8	#KATAKANA LETTER ZI
-0x8358	0x30B9	#KATAKANA LETTER SU
-0x8359	0x30BA	#KATAKANA LETTER ZU
-0x835A	0x30BB	#KATAKANA LETTER SE
-0x835B	0x30BC	#KATAKANA LETTER ZE
-0x835C	0x30BD	#KATAKANA LETTER SO
-0x835D	0x30BE	#KATAKANA LETTER ZO
-0x835E	0x30BF	#KATAKANA LETTER TA
-0x835F	0x30C0	#KATAKANA LETTER DA
-0x8360	0x30C1	#KATAKANA LETTER TI
-0x8361	0x30C2	#KATAKANA LETTER DI
-0x8362	0x30C3	#KATAKANA LETTER SMALL TU
-0x8363	0x30C4	#KATAKANA LETTER TU
-0x8364	0x30C5	#KATAKANA LETTER DU
-0x8365	0x30C6	#KATAKANA LETTER TE
-0x8366	0x30C7	#KATAKANA LETTER DE
-0x8367	0x30C8	#KATAKANA LETTER TO
-0x8368	0x30C9	#KATAKANA LETTER DO
-0x8369	0x30CA	#KATAKANA LETTER NA
-0x836A	0x30CB	#KATAKANA LETTER NI
-0x836B	0x30CC	#KATAKANA LETTER NU
-0x836C	0x30CD	#KATAKANA LETTER NE
-0x836D	0x30CE	#KATAKANA LETTER NO
-0x836E	0x30CF	#KATAKANA LETTER HA
-0x836F	0x30D0	#KATAKANA LETTER BA
-0x8370	0x30D1	#KATAKANA LETTER PA
-0x8371	0x30D2	#KATAKANA LETTER HI
-0x8372	0x30D3	#KATAKANA LETTER BI
-0x8373	0x30D4	#KATAKANA LETTER PI
-0x8374	0x30D5	#KATAKANA LETTER HU
-0x8375	0x30D6	#KATAKANA LETTER BU
-0x8376	0x30D7	#KATAKANA LETTER PU
-0x8377	0x30D8	#KATAKANA LETTER HE
-0x8378	0x30D9	#KATAKANA LETTER BE
-0x8379	0x30DA	#KATAKANA LETTER PE
-0x837A	0x30DB	#KATAKANA LETTER HO
-0x837B	0x30DC	#KATAKANA LETTER BO
-0x837C	0x30DD	#KATAKANA LETTER PO
-0x837D	0x30DE	#KATAKANA LETTER MA
-0x837E	0x30DF	#KATAKANA LETTER MI
-0x8380	0x30E0	#KATAKANA LETTER MU
-0x8381	0x30E1	#KATAKANA LETTER ME
-0x8382	0x30E2	#KATAKANA LETTER MO
-0x8383	0x30E3	#KATAKANA LETTER SMALL YA
-0x8384	0x30E4	#KATAKANA LETTER YA
-0x8385	0x30E5	#KATAKANA LETTER SMALL YU
-0x8386	0x30E6	#KATAKANA LETTER YU
-0x8387	0x30E7	#KATAKANA LETTER SMALL YO
-0x8388	0x30E8	#KATAKANA LETTER YO
-0x8389	0x30E9	#KATAKANA LETTER RA
-0x838A	0x30EA	#KATAKANA LETTER RI
-0x838B	0x30EB	#KATAKANA LETTER RU
-0x838C	0x30EC	#KATAKANA LETTER RE
-0x838D	0x30ED	#KATAKANA LETTER RO
-0x838E	0x30EE	#KATAKANA LETTER SMALL WA
-0x838F	0x30EF	#KATAKANA LETTER WA
-0x8390	0x30F0	#KATAKANA LETTER WI
-0x8391	0x30F1	#KATAKANA LETTER WE
-0x8392	0x30F2	#KATAKANA LETTER WO
-0x8393	0x30F3	#KATAKANA LETTER N
-0x8394	0x30F4	#KATAKANA LETTER VU
-0x8395	0x30F5	#KATAKANA LETTER SMALL KA
-0x8396	0x30F6	#KATAKANA LETTER SMALL KE
-0x839F	0x0391	#GREEK CAPITAL LETTER ALPHA
-0x83A0	0x0392	#GREEK CAPITAL LETTER BETA
-0x83A1	0x0393	#GREEK CAPITAL LETTER GAMMA
-0x83A2	0x0394	#GREEK CAPITAL LETTER DELTA
-0x83A3	0x0395	#GREEK CAPITAL LETTER EPSILON
-0x83A4	0x0396	#GREEK CAPITAL LETTER ZETA
-0x83A5	0x0397	#GREEK CAPITAL LETTER ETA
-0x83A6	0x0398	#GREEK CAPITAL LETTER THETA
-0x83A7	0x0399	#GREEK CAPITAL LETTER IOTA
-0x83A8	0x039A	#GREEK CAPITAL LETTER KAPPA
-0x83A9	0x039B	#GREEK CAPITAL LETTER LAMDA
-0x83AA	0x039C	#GREEK CAPITAL LETTER MU
-0x83AB	0x039D	#GREEK CAPITAL LETTER NU
-0x83AC	0x039E	#GREEK CAPITAL LETTER XI
-0x83AD	0x039F	#GREEK CAPITAL LETTER OMICRON
-0x83AE	0x03A0	#GREEK CAPITAL LETTER PI
-0x83AF	0x03A1	#GREEK CAPITAL LETTER RHO
-0x83B0	0x03A3	#GREEK CAPITAL LETTER SIGMA
-0x83B1	0x03A4	#GREEK CAPITAL LETTER TAU
-0x83B2	0x03A5	#GREEK CAPITAL LETTER UPSILON
-0x83B3	0x03A6	#GREEK CAPITAL LETTER PHI
-0x83B4	0x03A7	#GREEK CAPITAL LETTER CHI
-0x83B5	0x03A8	#GREEK CAPITAL LETTER PSI
-0x83B6	0x03A9	#GREEK CAPITAL LETTER OMEGA
-0x83BF	0x03B1	#GREEK SMALL LETTER ALPHA
-0x83C0	0x03B2	#GREEK SMALL LETTER BETA
-0x83C1	0x03B3	#GREEK SMALL LETTER GAMMA
-0x83C2	0x03B4	#GREEK SMALL LETTER DELTA
-0x83C3	0x03B5	#GREEK SMALL LETTER EPSILON
-0x83C4	0x03B6	#GREEK SMALL LETTER ZETA
-0x83C5	0x03B7	#GREEK SMALL LETTER ETA
-0x83C6	0x03B8	#GREEK SMALL LETTER THETA
-0x83C7	0x03B9	#GREEK SMALL LETTER IOTA
-0x83C8	0x03BA	#GREEK SMALL LETTER KAPPA
-0x83C9	0x03BB	#GREEK SMALL LETTER LAMDA
-0x83CA	0x03BC	#GREEK SMALL LETTER MU
-0x83CB	0x03BD	#GREEK SMALL LETTER NU
-0x83CC	0x03BE	#GREEK SMALL LETTER XI
-0x83CD	0x03BF	#GREEK SMALL LETTER OMICRON
-0x83CE	0x03C0	#GREEK SMALL LETTER PI
-0x83CF	0x03C1	#GREEK SMALL LETTER RHO
-0x83D0	0x03C3	#GREEK SMALL LETTER SIGMA
-0x83D1	0x03C4	#GREEK SMALL LETTER TAU
-0x83D2	0x03C5	#GREEK SMALL LETTER UPSILON
-0x83D3	0x03C6	#GREEK SMALL LETTER PHI
-0x83D4	0x03C7	#GREEK SMALL LETTER CHI
-0x83D5	0x03C8	#GREEK SMALL LETTER PSI
-0x83D6	0x03C9	#GREEK SMALL LETTER OMEGA
-0x8440	0x0410	#CYRILLIC CAPITAL LETTER A
-0x8441	0x0411	#CYRILLIC CAPITAL LETTER BE
-0x8442	0x0412	#CYRILLIC CAPITAL LETTER VE
-0x8443	0x0413	#CYRILLIC CAPITAL LETTER GHE
-0x8444	0x0414	#CYRILLIC CAPITAL LETTER DE
-0x8445	0x0415	#CYRILLIC CAPITAL LETTER IE
-0x8446	0x0401	#CYRILLIC CAPITAL LETTER IO
-0x8447	0x0416	#CYRILLIC CAPITAL LETTER ZHE
-0x8448	0x0417	#CYRILLIC CAPITAL LETTER ZE
-0x8449	0x0418	#CYRILLIC CAPITAL LETTER I
-0x844A	0x0419	#CYRILLIC CAPITAL LETTER SHORT I
-0x844B	0x041A	#CYRILLIC CAPITAL LETTER KA
-0x844C	0x041B	#CYRILLIC CAPITAL LETTER EL
-0x844D	0x041C	#CYRILLIC CAPITAL LETTER EM
-0x844E	0x041D	#CYRILLIC CAPITAL LETTER EN
-0x844F	0x041E	#CYRILLIC CAPITAL LETTER O
-0x8450	0x041F	#CYRILLIC CAPITAL LETTER PE
-0x8451	0x0420	#CYRILLIC CAPITAL LETTER ER
-0x8452	0x0421	#CYRILLIC CAPITAL LETTER ES
-0x8453	0x0422	#CYRILLIC CAPITAL LETTER TE
-0x8454	0x0423	#CYRILLIC CAPITAL LETTER U
-0x8455	0x0424	#CYRILLIC CAPITAL LETTER EF
-0x8456	0x0425	#CYRILLIC CAPITAL LETTER HA
-0x8457	0x0426	#CYRILLIC CAPITAL LETTER TSE
-0x8458	0x0427	#CYRILLIC CAPITAL LETTER CHE
-0x8459	0x0428	#CYRILLIC CAPITAL LETTER SHA
-0x845A	0x0429	#CYRILLIC CAPITAL LETTER SHCHA
-0x845B	0x042A	#CYRILLIC CAPITAL LETTER HARD SIGN
-0x845C	0x042B	#CYRILLIC CAPITAL LETTER YERU
-0x845D	0x042C	#CYRILLIC CAPITAL LETTER SOFT SIGN
-0x845E	0x042D	#CYRILLIC CAPITAL LETTER E
-0x845F	0x042E	#CYRILLIC CAPITAL LETTER YU
-0x8460	0x042F	#CYRILLIC CAPITAL LETTER YA
-0x8470	0x0430	#CYRILLIC SMALL LETTER A
-0x8471	0x0431	#CYRILLIC SMALL LETTER BE
-0x8472	0x0432	#CYRILLIC SMALL LETTER VE
-0x8473	0x0433	#CYRILLIC SMALL LETTER GHE
-0x8474	0x0434	#CYRILLIC SMALL LETTER DE
-0x8475	0x0435	#CYRILLIC SMALL LETTER IE
-0x8476	0x0451	#CYRILLIC SMALL LETTER IO
-0x8477	0x0436	#CYRILLIC SMALL LETTER ZHE
-0x8478	0x0437	#CYRILLIC SMALL LETTER ZE
-0x8479	0x0438	#CYRILLIC SMALL LETTER I
-0x847A	0x0439	#CYRILLIC SMALL LETTER SHORT I
-0x847B	0x043A	#CYRILLIC SMALL LETTER KA
-0x847C	0x043B	#CYRILLIC SMALL LETTER EL
-0x847D	0x043C	#CYRILLIC SMALL LETTER EM
-0x847E	0x043D	#CYRILLIC SMALL LETTER EN
-0x8480	0x043E	#CYRILLIC SMALL LETTER O
-0x8481	0x043F	#CYRILLIC SMALL LETTER PE
-0x8482	0x0440	#CYRILLIC SMALL LETTER ER
-0x8483	0x0441	#CYRILLIC SMALL LETTER ES
-0x8484	0x0442	#CYRILLIC SMALL LETTER TE
-0x8485	0x0443	#CYRILLIC SMALL LETTER U
-0x8486	0x0444	#CYRILLIC SMALL LETTER EF
-0x8487	0x0445	#CYRILLIC SMALL LETTER HA
-0x8488	0x0446	#CYRILLIC SMALL LETTER TSE
-0x8489	0x0447	#CYRILLIC SMALL LETTER CHE
-0x848A	0x0448	#CYRILLIC SMALL LETTER SHA
-0x848B	0x0449	#CYRILLIC SMALL LETTER SHCHA
-0x848C	0x044A	#CYRILLIC SMALL LETTER HARD SIGN
-0x848D	0x044B	#CYRILLIC SMALL LETTER YERU
-0x848E	0x044C	#CYRILLIC SMALL LETTER SOFT SIGN
-0x848F	0x044D	#CYRILLIC SMALL LETTER E
-0x8490	0x044E	#CYRILLIC SMALL LETTER YU
-0x8491	0x044F	#CYRILLIC SMALL LETTER YA
-0x849F	0x2500	#BOX DRAWINGS LIGHT HORIZONTAL
-0x84A0	0x2502	#BOX DRAWINGS LIGHT VERTICAL
-0x84A1	0x250C	#BOX DRAWINGS LIGHT DOWN AND RIGHT
-0x84A2	0x2510	#BOX DRAWINGS LIGHT DOWN AND LEFT
-0x84A3	0x2518	#BOX DRAWINGS LIGHT UP AND LEFT
-0x84A4	0x2514	#BOX DRAWINGS LIGHT UP AND RIGHT
-0x84A5	0x251C	#BOX DRAWINGS LIGHT VERTICAL AND RIGHT
-0x84A6	0x252C	#BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
-0x84A7	0x2524	#BOX DRAWINGS LIGHT VERTICAL AND LEFT
-0x84A8	0x2534	#BOX DRAWINGS LIGHT UP AND HORIZONTAL
-0x84A9	0x253C	#BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
-0x84AA	0x2501	#BOX DRAWINGS HEAVY HORIZONTAL
-0x84AB	0x2503	#BOX DRAWINGS HEAVY VERTICAL
-0x84AC	0x250F	#BOX DRAWINGS HEAVY DOWN AND RIGHT
-0x84AD	0x2513	#BOX DRAWINGS HEAVY DOWN AND LEFT
-0x84AE	0x251B	#BOX DRAWINGS HEAVY UP AND LEFT
-0x84AF	0x2517	#BOX DRAWINGS HEAVY UP AND RIGHT
-0x84B0	0x2523	#BOX DRAWINGS HEAVY VERTICAL AND RIGHT
-0x84B1	0x2533	#BOX DRAWINGS HEAVY DOWN AND HORIZONTAL
-0x84B2	0x252B	#BOX DRAWINGS HEAVY VERTICAL AND LEFT
-0x84B3	0x253B	#BOX DRAWINGS HEAVY UP AND HORIZONTAL
-0x84B4	0x254B	#BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL
-0x84B5	0x2520	#BOX DRAWINGS VERTICAL HEAVY AND RIGHT LIGHT
-0x84B6	0x252F	#BOX DRAWINGS DOWN LIGHT AND HORIZONTAL HEAVY
-0x84B7	0x2528	#BOX DRAWINGS VERTICAL HEAVY AND LEFT LIGHT
-0x84B8	0x2537	#BOX DRAWINGS UP LIGHT AND HORIZONTAL HEAVY
-0x84B9	0x253F	#BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY
-0x84BA	0x251D	#BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY
-0x84BB	0x2530	#BOX DRAWINGS DOWN HEAVY AND HORIZONTAL LIGHT
-0x84BC	0x2525	#BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY
-0x84BD	0x2538	#BOX DRAWINGS UP HEAVY AND HORIZONTAL LIGHT
-0x84BE	0x2542	#BOX DRAWINGS VERTICAL HEAVY AND HORIZONTAL LIGHT
-0x8740	0x2460	#CIRCLED DIGIT ONE
-0x8741	0x2461	#CIRCLED DIGIT TWO
-0x8742	0x2462	#CIRCLED DIGIT THREE
-0x8743	0x2463	#CIRCLED DIGIT FOUR
-0x8744	0x2464	#CIRCLED DIGIT FIVE
-0x8745	0x2465	#CIRCLED DIGIT SIX
-0x8746	0x2466	#CIRCLED DIGIT SEVEN
-0x8747	0x2467	#CIRCLED DIGIT EIGHT
-0x8748	0x2468	#CIRCLED DIGIT NINE
-0x8749	0x2469	#CIRCLED NUMBER TEN
-0x874A	0x246A	#CIRCLED NUMBER ELEVEN
-0x874B	0x246B	#CIRCLED NUMBER TWELVE
-0x874C	0x246C	#CIRCLED NUMBER THIRTEEN
-0x874D	0x246D	#CIRCLED NUMBER FOURTEEN
-0x874E	0x246E	#CIRCLED NUMBER FIFTEEN
-0x874F	0x246F	#CIRCLED NUMBER SIXTEEN
-0x8750	0x2470	#CIRCLED NUMBER SEVENTEEN
-0x8751	0x2471	#CIRCLED NUMBER EIGHTEEN
-0x8752	0x2472	#CIRCLED NUMBER NINETEEN
-0x8753	0x2473	#CIRCLED NUMBER TWENTY
-0x8754	0x2160	#ROMAN NUMERAL ONE
-0x8755	0x2161	#ROMAN NUMERAL TWO
-0x8756	0x2162	#ROMAN NUMERAL THREE
-0x8757	0x2163	#ROMAN NUMERAL FOUR
-0x8758	0x2164	#ROMAN NUMERAL FIVE
-0x8759	0x2165	#ROMAN NUMERAL SIX
-0x875A	0x2166	#ROMAN NUMERAL SEVEN
-0x875B	0x2167	#ROMAN NUMERAL EIGHT
-0x875C	0x2168	#ROMAN NUMERAL NINE
-0x875D	0x2169	#ROMAN NUMERAL TEN
-0x875F	0x3349	#SQUARE MIRI
-0x8760	0x3314	#SQUARE KIRO
-0x8761	0x3322	#SQUARE SENTI
-0x8762	0x334D	#SQUARE MEETORU
-0x8763	0x3318	#SQUARE GURAMU
-0x8764	0x3327	#SQUARE TON
-0x8765	0x3303	#SQUARE AARU
-0x8766	0x3336	#SQUARE HEKUTAARU
-0x8767	0x3351	#SQUARE RITTORU
-0x8768	0x3357	#SQUARE WATTO
-0x8769	0x330D	#SQUARE KARORII
-0x876A	0x3326	#SQUARE DORU
-0x876B	0x3323	#SQUARE SENTO
-0x876C	0x332B	#SQUARE PAASENTO
-0x876D	0x334A	#SQUARE MIRIBAARU
-0x876E	0x333B	#SQUARE PEEZI
-0x876F	0x339C	#SQUARE MM
-0x8770	0x339D	#SQUARE CM
-0x8771	0x339E	#SQUARE KM
-0x8772	0x338E	#SQUARE MG
-0x8773	0x338F	#SQUARE KG
-0x8774	0x33C4	#SQUARE CC
-0x8775	0x33A1	#SQUARE M SQUARED
-0x877E	0x337B	#SQUARE ERA NAME HEISEI
-0x8780	0x301D	#REVERSED DOUBLE PRIME QUOTATION MARK
-0x8781	0x301F	#LOW DOUBLE PRIME QUOTATION MARK
-0x8782	0x2116	#NUMERO SIGN
-0x8783	0x33CD	#SQUARE KK
-0x8784	0x2121	#TELEPHONE SIGN
-0x8785	0x32A4	#CIRCLED IDEOGRAPH HIGH
-0x8786	0x32A5	#CIRCLED IDEOGRAPH CENTRE
-0x8787	0x32A6	#CIRCLED IDEOGRAPH LOW
-0x8788	0x32A7	#CIRCLED IDEOGRAPH LEFT
-0x8789	0x32A8	#CIRCLED IDEOGRAPH RIGHT
-0x878A	0x3231	#PARENTHESIZED IDEOGRAPH STOCK
-0x878B	0x3232	#PARENTHESIZED IDEOGRAPH HAVE
-0x878C	0x3239	#PARENTHESIZED IDEOGRAPH REPRESENT
-0x878D	0x337E	#SQUARE ERA NAME MEIZI
-0x878E	0x337D	#SQUARE ERA NAME TAISYOU
-0x878F	0x337C	#SQUARE ERA NAME SYOUWA
-0x8790	0x2252	#APPROXIMATELY EQUAL TO OR THE IMAGE OF
-0x8791	0x2261	#IDENTICAL TO
-0x8792	0x222B	#INTEGRAL
-0x8793	0x222E	#CONTOUR INTEGRAL
-0x8794	0x2211	#N-ARY SUMMATION
-0x8795	0x221A	#SQUARE ROOT
-0x8796	0x22A5	#UP TACK
-0x8797	0x2220	#ANGLE
-0x8798	0x221F	#RIGHT ANGLE
-0x8799	0x22BF	#RIGHT TRIANGLE
-0x879A	0x2235	#BECAUSE
-0x879B	0x2229	#INTERSECTION
-0x879C	0x222A	#UNION
-0x889F	0x4E9C	#CJK UNIFIED IDEOGRAPH
-0x88A0	0x5516	#CJK UNIFIED IDEOGRAPH
-0x88A1	0x5A03	#CJK UNIFIED IDEOGRAPH
-0x88A2	0x963F	#CJK UNIFIED IDEOGRAPH
-0x88A3	0x54C0	#CJK UNIFIED IDEOGRAPH
-0x88A4	0x611B	#CJK UNIFIED IDEOGRAPH
-0x88A5	0x6328	#CJK UNIFIED IDEOGRAPH
-0x88A6	0x59F6	#CJK UNIFIED IDEOGRAPH
-0x88A7	0x9022	#CJK UNIFIED IDEOGRAPH
-0x88A8	0x8475	#CJK UNIFIED IDEOGRAPH
-0x88A9	0x831C	#CJK UNIFIED IDEOGRAPH
-0x88AA	0x7A50	#CJK UNIFIED IDEOGRAPH
-0x88AB	0x60AA	#CJK UNIFIED IDEOGRAPH
-0x88AC	0x63E1	#CJK UNIFIED IDEOGRAPH
-0x88AD	0x6E25	#CJK UNIFIED IDEOGRAPH
-0x88AE	0x65ED	#CJK UNIFIED IDEOGRAPH
-0x88AF	0x8466	#CJK UNIFIED IDEOGRAPH
-0x88B0	0x82A6	#CJK UNIFIED IDEOGRAPH
-0x88B1	0x9BF5	#CJK UNIFIED IDEOGRAPH
-0x88B2	0x6893	#CJK UNIFIED IDEOGRAPH
-0x88B3	0x5727	#CJK UNIFIED IDEOGRAPH
-0x88B4	0x65A1	#CJK UNIFIED IDEOGRAPH
-0x88B5	0x6271	#CJK UNIFIED IDEOGRAPH
-0x88B6	0x5B9B	#CJK UNIFIED IDEOGRAPH
-0x88B7	0x59D0	#CJK UNIFIED IDEOGRAPH
-0x88B8	0x867B	#CJK UNIFIED IDEOGRAPH
-0x88B9	0x98F4	#CJK UNIFIED IDEOGRAPH
-0x88BA	0x7D62	#CJK UNIFIED IDEOGRAPH
-0x88BB	0x7DBE	#CJK UNIFIED IDEOGRAPH
-0x88BC	0x9B8E	#CJK UNIFIED IDEOGRAPH
-0x88BD	0x6216	#CJK UNIFIED IDEOGRAPH
-0x88BE	0x7C9F	#CJK UNIFIED IDEOGRAPH
-0x88BF	0x88B7	#CJK UNIFIED IDEOGRAPH
-0x88C0	0x5B89	#CJK UNIFIED IDEOGRAPH
-0x88C1	0x5EB5	#CJK UNIFIED IDEOGRAPH
-0x88C2	0x6309	#CJK UNIFIED IDEOGRAPH
-0x88C3	0x6697	#CJK UNIFIED IDEOGRAPH
-0x88C4	0x6848	#CJK UNIFIED IDEOGRAPH
-0x88C5	0x95C7	#CJK UNIFIED IDEOGRAPH
-0x88C6	0x978D	#CJK UNIFIED IDEOGRAPH
-0x88C7	0x674F	#CJK UNIFIED IDEOGRAPH
-0x88C8	0x4EE5	#CJK UNIFIED IDEOGRAPH
-0x88C9	0x4F0A	#CJK UNIFIED IDEOGRAPH
-0x88CA	0x4F4D	#CJK UNIFIED IDEOGRAPH
-0x88CB	0x4F9D	#CJK UNIFIED IDEOGRAPH
-0x88CC	0x5049	#CJK UNIFIED IDEOGRAPH
-0x88CD	0x56F2	#CJK UNIFIED IDEOGRAPH
-0x88CE	0x5937	#CJK UNIFIED IDEOGRAPH
-0x88CF	0x59D4	#CJK UNIFIED IDEOGRAPH
-0x88D0	0x5A01	#CJK UNIFIED IDEOGRAPH
-0x88D1	0x5C09	#CJK UNIFIED IDEOGRAPH
-0x88D2	0x60DF	#CJK UNIFIED IDEOGRAPH
-0x88D3	0x610F	#CJK UNIFIED IDEOGRAPH
-0x88D4	0x6170	#CJK UNIFIED IDEOGRAPH
-0x88D5	0x6613	#CJK UNIFIED IDEOGRAPH
-0x88D6	0x6905	#CJK UNIFIED IDEOGRAPH
-0x88D7	0x70BA	#CJK UNIFIED IDEOGRAPH
-0x88D8	0x754F	#CJK UNIFIED IDEOGRAPH
-0x88D9	0x7570	#CJK UNIFIED IDEOGRAPH
-0x88DA	0x79FB	#CJK UNIFIED IDEOGRAPH
-0x88DB	0x7DAD	#CJK UNIFIED IDEOGRAPH
-0x88DC	0x7DEF	#CJK UNIFIED IDEOGRAPH
-0x88DD	0x80C3	#CJK UNIFIED IDEOGRAPH
-0x88DE	0x840E	#CJK UNIFIED IDEOGRAPH
-0x88DF	0x8863	#CJK UNIFIED IDEOGRAPH
-0x88E0	0x8B02	#CJK UNIFIED IDEOGRAPH
-0x88E1	0x9055	#CJK UNIFIED IDEOGRAPH
-0x88E2	0x907A	#CJK UNIFIED IDEOGRAPH
-0x88E3	0x533B	#CJK UNIFIED IDEOGRAPH
-0x88E4	0x4E95	#CJK UNIFIED IDEOGRAPH
-0x88E5	0x4EA5	#CJK UNIFIED IDEOGRAPH
-0x88E6	0x57DF	#CJK UNIFIED IDEOGRAPH
-0x88E7	0x80B2	#CJK UNIFIED IDEOGRAPH
-0x88E8	0x90C1	#CJK UNIFIED IDEOGRAPH
-0x88E9	0x78EF	#CJK UNIFIED IDEOGRAPH
-0x88EA	0x4E00	#CJK UNIFIED IDEOGRAPH
-0x88EB	0x58F1	#CJK UNIFIED IDEOGRAPH
-0x88EC	0x6EA2	#CJK UNIFIED IDEOGRAPH
-0x88ED	0x9038	#CJK UNIFIED IDEOGRAPH
-0x88EE	0x7A32	#CJK UNIFIED IDEOGRAPH
-0x88EF	0x8328	#CJK UNIFIED IDEOGRAPH
-0x88F0	0x828B	#CJK UNIFIED IDEOGRAPH
-0x88F1	0x9C2F	#CJK UNIFIED IDEOGRAPH
-0x88F2	0x5141	#CJK UNIFIED IDEOGRAPH
-0x88F3	0x5370	#CJK UNIFIED IDEOGRAPH
-0x88F4	0x54BD	#CJK UNIFIED IDEOGRAPH
-0x88F5	0x54E1	#CJK UNIFIED IDEOGRAPH
-0x88F6	0x56E0	#CJK UNIFIED IDEOGRAPH
-0x88F7	0x59FB	#CJK UNIFIED IDEOGRAPH
-0x88F8	0x5F15	#CJK UNIFIED IDEOGRAPH
-0x88F9	0x98F2	#CJK UNIFIED IDEOGRAPH
-0x88FA	0x6DEB	#CJK UNIFIED IDEOGRAPH
-0x88FB	0x80E4	#CJK UNIFIED IDEOGRAPH
-0x88FC	0x852D	#CJK UNIFIED IDEOGRAPH
-0x8940	0x9662	#CJK UNIFIED IDEOGRAPH
-0x8941	0x9670	#CJK UNIFIED IDEOGRAPH
-0x8942	0x96A0	#CJK UNIFIED IDEOGRAPH
-0x8943	0x97FB	#CJK UNIFIED IDEOGRAPH
-0x8944	0x540B	#CJK UNIFIED IDEOGRAPH
-0x8945	0x53F3	#CJK UNIFIED IDEOGRAPH
-0x8946	0x5B87	#CJK UNIFIED IDEOGRAPH
-0x8947	0x70CF	#CJK UNIFIED IDEOGRAPH
-0x8948	0x7FBD	#CJK UNIFIED IDEOGRAPH
-0x8949	0x8FC2	#CJK UNIFIED IDEOGRAPH
-0x894A	0x96E8	#CJK UNIFIED IDEOGRAPH
-0x894B	0x536F	#CJK UNIFIED IDEOGRAPH
-0x894C	0x9D5C	#CJK UNIFIED IDEOGRAPH
-0x894D	0x7ABA	#CJK UNIFIED IDEOGRAPH
-0x894E	0x4E11	#CJK UNIFIED IDEOGRAPH
-0x894F	0x7893	#CJK UNIFIED IDEOGRAPH
-0x8950	0x81FC	#CJK UNIFIED IDEOGRAPH
-0x8951	0x6E26	#CJK UNIFIED IDEOGRAPH
-0x8952	0x5618	#CJK UNIFIED IDEOGRAPH
-0x8953	0x5504	#CJK UNIFIED IDEOGRAPH
-0x8954	0x6B1D	#CJK UNIFIED IDEOGRAPH
-0x8955	0x851A	#CJK UNIFIED IDEOGRAPH
-0x8956	0x9C3B	#CJK UNIFIED IDEOGRAPH
-0x8957	0x59E5	#CJK UNIFIED IDEOGRAPH
-0x8958	0x53A9	#CJK UNIFIED IDEOGRAPH
-0x8959	0x6D66	#CJK UNIFIED IDEOGRAPH
-0x895A	0x74DC	#CJK UNIFIED IDEOGRAPH
-0x895B	0x958F	#CJK UNIFIED IDEOGRAPH
-0x895C	0x5642	#CJK UNIFIED IDEOGRAPH
-0x895D	0x4E91	#CJK UNIFIED IDEOGRAPH
-0x895E	0x904B	#CJK UNIFIED IDEOGRAPH
-0x895F	0x96F2	#CJK UNIFIED IDEOGRAPH
-0x8960	0x834F	#CJK UNIFIED IDEOGRAPH
-0x8961	0x990C	#CJK UNIFIED IDEOGRAPH
-0x8962	0x53E1	#CJK UNIFIED IDEOGRAPH
-0x8963	0x55B6	#CJK UNIFIED IDEOGRAPH
-0x8964	0x5B30	#CJK UNIFIED IDEOGRAPH
-0x8965	0x5F71	#CJK UNIFIED IDEOGRAPH
-0x8966	0x6620	#CJK UNIFIED IDEOGRAPH
-0x8967	0x66F3	#CJK UNIFIED IDEOGRAPH
-0x8968	0x6804	#CJK UNIFIED IDEOGRAPH
-0x8969	0x6C38	#CJK UNIFIED IDEOGRAPH
-0x896A	0x6CF3	#CJK UNIFIED IDEOGRAPH
-0x896B	0x6D29	#CJK UNIFIED IDEOGRAPH
-0x896C	0x745B	#CJK UNIFIED IDEOGRAPH
-0x896D	0x76C8	#CJK UNIFIED IDEOGRAPH
-0x896E	0x7A4E	#CJK UNIFIED IDEOGRAPH
-0x896F	0x9834	#CJK UNIFIED IDEOGRAPH
-0x8970	0x82F1	#CJK UNIFIED IDEOGRAPH
-0x8971	0x885B	#CJK UNIFIED IDEOGRAPH
-0x8972	0x8A60	#CJK UNIFIED IDEOGRAPH
-0x8973	0x92ED	#CJK UNIFIED IDEOGRAPH
-0x8974	0x6DB2	#CJK UNIFIED IDEOGRAPH
-0x8975	0x75AB	#CJK UNIFIED IDEOGRAPH
-0x8976	0x76CA	#CJK UNIFIED IDEOGRAPH
-0x8977	0x99C5	#CJK UNIFIED IDEOGRAPH
-0x8978	0x60A6	#CJK UNIFIED IDEOGRAPH
-0x8979	0x8B01	#CJK UNIFIED IDEOGRAPH
-0x897A	0x8D8A	#CJK UNIFIED IDEOGRAPH
-0x897B	0x95B2	#CJK UNIFIED IDEOGRAPH
-0x897C	0x698E	#CJK UNIFIED IDEOGRAPH
-0x897D	0x53AD	#CJK UNIFIED IDEOGRAPH
-0x897E	0x5186	#CJK UNIFIED IDEOGRAPH
-0x8980	0x5712	#CJK UNIFIED IDEOGRAPH
-0x8981	0x5830	#CJK UNIFIED IDEOGRAPH
-0x8982	0x5944	#CJK UNIFIED IDEOGRAPH
-0x8983	0x5BB4	#CJK UNIFIED IDEOGRAPH
-0x8984	0x5EF6	#CJK UNIFIED IDEOGRAPH
-0x8985	0x6028	#CJK UNIFIED IDEOGRAPH
-0x8986	0x63A9	#CJK UNIFIED IDEOGRAPH
-0x8987	0x63F4	#CJK UNIFIED IDEOGRAPH
-0x8988	0x6CBF	#CJK UNIFIED IDEOGRAPH
-0x8989	0x6F14	#CJK UNIFIED IDEOGRAPH
-0x898A	0x708E	#CJK UNIFIED IDEOGRAPH
-0x898B	0x7114	#CJK UNIFIED IDEOGRAPH
-0x898C	0x7159	#CJK UNIFIED IDEOGRAPH
-0x898D	0x71D5	#CJK UNIFIED IDEOGRAPH
-0x898E	0x733F	#CJK UNIFIED IDEOGRAPH
-0x898F	0x7E01	#CJK UNIFIED IDEOGRAPH
-0x8990	0x8276	#CJK UNIFIED IDEOGRAPH
-0x8991	0x82D1	#CJK UNIFIED IDEOGRAPH
-0x8992	0x8597	#CJK UNIFIED IDEOGRAPH
-0x8993	0x9060	#CJK UNIFIED IDEOGRAPH
-0x8994	0x925B	#CJK UNIFIED IDEOGRAPH
-0x8995	0x9D1B	#CJK UNIFIED IDEOGRAPH
-0x8996	0x5869	#CJK UNIFIED IDEOGRAPH
-0x8997	0x65BC	#CJK UNIFIED IDEOGRAPH
-0x8998	0x6C5A	#CJK UNIFIED IDEOGRAPH
-0x8999	0x7525	#CJK UNIFIED IDEOGRAPH
-0x899A	0x51F9	#CJK UNIFIED IDEOGRAPH
-0x899B	0x592E	#CJK UNIFIED IDEOGRAPH
-0x899C	0x5965	#CJK UNIFIED IDEOGRAPH
-0x899D	0x5F80	#CJK UNIFIED IDEOGRAPH
-0x899E	0x5FDC	#CJK UNIFIED IDEOGRAPH
-0x899F	0x62BC	#CJK UNIFIED IDEOGRAPH
-0x89A0	0x65FA	#CJK UNIFIED IDEOGRAPH
-0x89A1	0x6A2A	#CJK UNIFIED IDEOGRAPH
-0x89A2	0x6B27	#CJK UNIFIED IDEOGRAPH
-0x89A3	0x6BB4	#CJK UNIFIED IDEOGRAPH
-0x89A4	0x738B	#CJK UNIFIED IDEOGRAPH
-0x89A5	0x7FC1	#CJK UNIFIED IDEOGRAPH
-0x89A6	0x8956	#CJK UNIFIED IDEOGRAPH
-0x89A7	0x9D2C	#CJK UNIFIED IDEOGRAPH
-0x89A8	0x9D0E	#CJK UNIFIED IDEOGRAPH
-0x89A9	0x9EC4	#CJK UNIFIED IDEOGRAPH
-0x89AA	0x5CA1	#CJK UNIFIED IDEOGRAPH
-0x89AB	0x6C96	#CJK UNIFIED IDEOGRAPH
-0x89AC	0x837B	#CJK UNIFIED IDEOGRAPH
-0x89AD	0x5104	#CJK UNIFIED IDEOGRAPH
-0x89AE	0x5C4B	#CJK UNIFIED IDEOGRAPH
-0x89AF	0x61B6	#CJK UNIFIED IDEOGRAPH
-0x89B0	0x81C6	#CJK UNIFIED IDEOGRAPH
-0x89B1	0x6876	#CJK UNIFIED IDEOGRAPH
-0x89B2	0x7261	#CJK UNIFIED IDEOGRAPH
-0x89B3	0x4E59	#CJK UNIFIED IDEOGRAPH
-0x89B4	0x4FFA	#CJK UNIFIED IDEOGRAPH
-0x89B5	0x5378	#CJK UNIFIED IDEOGRAPH
-0x89B6	0x6069	#CJK UNIFIED IDEOGRAPH
-0x89B7	0x6E29	#CJK UNIFIED IDEOGRAPH
-0x89B8	0x7A4F	#CJK UNIFIED IDEOGRAPH
-0x89B9	0x97F3	#CJK UNIFIED IDEOGRAPH
-0x89BA	0x4E0B	#CJK UNIFIED IDEOGRAPH
-0x89BB	0x5316	#CJK UNIFIED IDEOGRAPH
-0x89BC	0x4EEE	#CJK UNIFIED IDEOGRAPH
-0x89BD	0x4F55	#CJK UNIFIED IDEOGRAPH
-0x89BE	0x4F3D	#CJK UNIFIED IDEOGRAPH
-0x89BF	0x4FA1	#CJK UNIFIED IDEOGRAPH
-0x89C0	0x4F73	#CJK UNIFIED IDEOGRAPH
-0x89C1	0x52A0	#CJK UNIFIED IDEOGRAPH
-0x89C2	0x53EF	#CJK UNIFIED IDEOGRAPH
-0x89C3	0x5609	#CJK UNIFIED IDEOGRAPH
-0x89C4	0x590F	#CJK UNIFIED IDEOGRAPH
-0x89C5	0x5AC1	#CJK UNIFIED IDEOGRAPH
-0x89C6	0x5BB6	#CJK UNIFIED IDEOGRAPH
-0x89C7	0x5BE1	#CJK UNIFIED IDEOGRAPH
-0x89C8	0x79D1	#CJK UNIFIED IDEOGRAPH
-0x89C9	0x6687	#CJK UNIFIED IDEOGRAPH
-0x89CA	0x679C	#CJK UNIFIED IDEOGRAPH
-0x89CB	0x67B6	#CJK UNIFIED IDEOGRAPH
-0x89CC	0x6B4C	#CJK UNIFIED IDEOGRAPH
-0x89CD	0x6CB3	#CJK UNIFIED IDEOGRAPH
-0x89CE	0x706B	#CJK UNIFIED IDEOGRAPH
-0x89CF	0x73C2	#CJK UNIFIED IDEOGRAPH
-0x89D0	0x798D	#CJK UNIFIED IDEOGRAPH
-0x89D1	0x79BE	#CJK UNIFIED IDEOGRAPH
-0x89D2	0x7A3C	#CJK UNIFIED IDEOGRAPH
-0x89D3	0x7B87	#CJK UNIFIED IDEOGRAPH
-0x89D4	0x82B1	#CJK UNIFIED IDEOGRAPH
-0x89D5	0x82DB	#CJK UNIFIED IDEOGRAPH
-0x89D6	0x8304	#CJK UNIFIED IDEOGRAPH
-0x89D7	0x8377	#CJK UNIFIED IDEOGRAPH
-0x89D8	0x83EF	#CJK UNIFIED IDEOGRAPH
-0x89D9	0x83D3	#CJK UNIFIED IDEOGRAPH
-0x89DA	0x8766	#CJK UNIFIED IDEOGRAPH
-0x89DB	0x8AB2	#CJK UNIFIED IDEOGRAPH
-0x89DC	0x5629	#CJK UNIFIED IDEOGRAPH
-0x89DD	0x8CA8	#CJK UNIFIED IDEOGRAPH
-0x89DE	0x8FE6	#CJK UNIFIED IDEOGRAPH
-0x89DF	0x904E	#CJK UNIFIED IDEOGRAPH
-0x89E0	0x971E	#CJK UNIFIED IDEOGRAPH
-0x89E1	0x868A	#CJK UNIFIED IDEOGRAPH
-0x89E2	0x4FC4	#CJK UNIFIED IDEOGRAPH
-0x89E3	0x5CE8	#CJK UNIFIED IDEOGRAPH
-0x89E4	0x6211	#CJK UNIFIED IDEOGRAPH
-0x89E5	0x7259	#CJK UNIFIED IDEOGRAPH
-0x89E6	0x753B	#CJK UNIFIED IDEOGRAPH
-0x89E7	0x81E5	#CJK UNIFIED IDEOGRAPH
-0x89E8	0x82BD	#CJK UNIFIED IDEOGRAPH
-0x89E9	0x86FE	#CJK UNIFIED IDEOGRAPH
-0x89EA	0x8CC0	#CJK UNIFIED IDEOGRAPH
-0x89EB	0x96C5	#CJK UNIFIED IDEOGRAPH
-0x89EC	0x9913	#CJK UNIFIED IDEOGRAPH
-0x89ED	0x99D5	#CJK UNIFIED IDEOGRAPH
-0x89EE	0x4ECB	#CJK UNIFIED IDEOGRAPH
-0x89EF	0x4F1A	#CJK UNIFIED IDEOGRAPH
-0x89F0	0x89E3	#CJK UNIFIED IDEOGRAPH
-0x89F1	0x56DE	#CJK UNIFIED IDEOGRAPH
-0x89F2	0x584A	#CJK UNIFIED IDEOGRAPH
-0x89F3	0x58CA	#CJK UNIFIED IDEOGRAPH
-0x89F4	0x5EFB	#CJK UNIFIED IDEOGRAPH
-0x89F5	0x5FEB	#CJK UNIFIED IDEOGRAPH
-0x89F6	0x602A	#CJK UNIFIED IDEOGRAPH
-0x89F7	0x6094	#CJK UNIFIED IDEOGRAPH
-0x89F8	0x6062	#CJK UNIFIED IDEOGRAPH
-0x89F9	0x61D0	#CJK UNIFIED IDEOGRAPH
-0x89FA	0x6212	#CJK UNIFIED IDEOGRAPH
-0x89FB	0x62D0	#CJK UNIFIED IDEOGRAPH
-0x89FC	0x6539	#CJK UNIFIED IDEOGRAPH
-0x8A40	0x9B41	#CJK UNIFIED IDEOGRAPH
-0x8A41	0x6666	#CJK UNIFIED IDEOGRAPH
-0x8A42	0x68B0	#CJK UNIFIED IDEOGRAPH
-0x8A43	0x6D77	#CJK UNIFIED IDEOGRAPH
-0x8A44	0x7070	#CJK UNIFIED IDEOGRAPH
-0x8A45	0x754C	#CJK UNIFIED IDEOGRAPH
-0x8A46	0x7686	#CJK UNIFIED IDEOGRAPH
-0x8A47	0x7D75	#CJK UNIFIED IDEOGRAPH
-0x8A48	0x82A5	#CJK UNIFIED IDEOGRAPH
-0x8A49	0x87F9	#CJK UNIFIED IDEOGRAPH
-0x8A4A	0x958B	#CJK UNIFIED IDEOGRAPH
-0x8A4B	0x968E	#CJK UNIFIED IDEOGRAPH
-0x8A4C	0x8C9D	#CJK UNIFIED IDEOGRAPH
-0x8A4D	0x51F1	#CJK UNIFIED IDEOGRAPH
-0x8A4E	0x52BE	#CJK UNIFIED IDEOGRAPH
-0x8A4F	0x5916	#CJK UNIFIED IDEOGRAPH
-0x8A50	0x54B3	#CJK UNIFIED IDEOGRAPH
-0x8A51	0x5BB3	#CJK UNIFIED IDEOGRAPH
-0x8A52	0x5D16	#CJK UNIFIED IDEOGRAPH
-0x8A53	0x6168	#CJK UNIFIED IDEOGRAPH
-0x8A54	0x6982	#CJK UNIFIED IDEOGRAPH
-0x8A55	0x6DAF	#CJK UNIFIED IDEOGRAPH
-0x8A56	0x788D	#CJK UNIFIED IDEOGRAPH
-0x8A57	0x84CB	#CJK UNIFIED IDEOGRAPH
-0x8A58	0x8857	#CJK UNIFIED IDEOGRAPH
-0x8A59	0x8A72	#CJK UNIFIED IDEOGRAPH
-0x8A5A	0x93A7	#CJK UNIFIED IDEOGRAPH
-0x8A5B	0x9AB8	#CJK UNIFIED IDEOGRAPH
-0x8A5C	0x6D6C	#CJK UNIFIED IDEOGRAPH
-0x8A5D	0x99A8	#CJK UNIFIED IDEOGRAPH
-0x8A5E	0x86D9	#CJK UNIFIED IDEOGRAPH
-0x8A5F	0x57A3	#CJK UNIFIED IDEOGRAPH
-0x8A60	0x67FF	#CJK UNIFIED IDEOGRAPH
-0x8A61	0x86CE	#CJK UNIFIED IDEOGRAPH
-0x8A62	0x920E	#CJK UNIFIED IDEOGRAPH
-0x8A63	0x5283	#CJK UNIFIED IDEOGRAPH
-0x8A64	0x5687	#CJK UNIFIED IDEOGRAPH
-0x8A65	0x5404	#CJK UNIFIED IDEOGRAPH
-0x8A66	0x5ED3	#CJK UNIFIED IDEOGRAPH
-0x8A67	0x62E1	#CJK UNIFIED IDEOGRAPH
-0x8A68	0x64B9	#CJK UNIFIED IDEOGRAPH
-0x8A69	0x683C	#CJK UNIFIED IDEOGRAPH
-0x8A6A	0x6838	#CJK UNIFIED IDEOGRAPH
-0x8A6B	0x6BBB	#CJK UNIFIED IDEOGRAPH
-0x8A6C	0x7372	#CJK UNIFIED IDEOGRAPH
-0x8A6D	0x78BA	#CJK UNIFIED IDEOGRAPH
-0x8A6E	0x7A6B	#CJK UNIFIED IDEOGRAPH
-0x8A6F	0x899A	#CJK UNIFIED IDEOGRAPH
-0x8A70	0x89D2	#CJK UNIFIED IDEOGRAPH
-0x8A71	0x8D6B	#CJK UNIFIED IDEOGRAPH
-0x8A72	0x8F03	#CJK UNIFIED IDEOGRAPH
-0x8A73	0x90ED	#CJK UNIFIED IDEOGRAPH
-0x8A74	0x95A3	#CJK UNIFIED IDEOGRAPH
-0x8A75	0x9694	#CJK UNIFIED IDEOGRAPH
-0x8A76	0x9769	#CJK UNIFIED IDEOGRAPH
-0x8A77	0x5B66	#CJK UNIFIED IDEOGRAPH
-0x8A78	0x5CB3	#CJK UNIFIED IDEOGRAPH
-0x8A79	0x697D	#CJK UNIFIED IDEOGRAPH
-0x8A7A	0x984D	#CJK UNIFIED IDEOGRAPH
-0x8A7B	0x984E	#CJK UNIFIED IDEOGRAPH
-0x8A7C	0x639B	#CJK UNIFIED IDEOGRAPH
-0x8A7D	0x7B20	#CJK UNIFIED IDEOGRAPH
-0x8A7E	0x6A2B	#CJK UNIFIED IDEOGRAPH
-0x8A80	0x6A7F	#CJK UNIFIED IDEOGRAPH
-0x8A81	0x68B6	#CJK UNIFIED IDEOGRAPH
-0x8A82	0x9C0D	#CJK UNIFIED IDEOGRAPH
-0x8A83	0x6F5F	#CJK UNIFIED IDEOGRAPH
-0x8A84	0x5272	#CJK UNIFIED IDEOGRAPH
-0x8A85	0x559D	#CJK UNIFIED IDEOGRAPH
-0x8A86	0x6070	#CJK UNIFIED IDEOGRAPH
-0x8A87	0x62EC	#CJK UNIFIED IDEOGRAPH
-0x8A88	0x6D3B	#CJK UNIFIED IDEOGRAPH
-0x8A89	0x6E07	#CJK UNIFIED IDEOGRAPH
-0x8A8A	0x6ED1	#CJK UNIFIED IDEOGRAPH
-0x8A8B	0x845B	#CJK UNIFIED IDEOGRAPH
-0x8A8C	0x8910	#CJK UNIFIED IDEOGRAPH
-0x8A8D	0x8F44	#CJK UNIFIED IDEOGRAPH
-0x8A8E	0x4E14	#CJK UNIFIED IDEOGRAPH
-0x8A8F	0x9C39	#CJK UNIFIED IDEOGRAPH
-0x8A90	0x53F6	#CJK UNIFIED IDEOGRAPH
-0x8A91	0x691B	#CJK UNIFIED IDEOGRAPH
-0x8A92	0x6A3A	#CJK UNIFIED IDEOGRAPH
-0x8A93	0x9784	#CJK UNIFIED IDEOGRAPH
-0x8A94	0x682A	#CJK UNIFIED IDEOGRAPH
-0x8A95	0x515C	#CJK UNIFIED IDEOGRAPH
-0x8A96	0x7AC3	#CJK UNIFIED IDEOGRAPH
-0x8A97	0x84B2	#CJK UNIFIED IDEOGRAPH
-0x8A98	0x91DC	#CJK UNIFIED IDEOGRAPH
-0x8A99	0x938C	#CJK UNIFIED IDEOGRAPH
-0x8A9A	0x565B	#CJK UNIFIED IDEOGRAPH
-0x8A9B	0x9D28	#CJK UNIFIED IDEOGRAPH
-0x8A9C	0x6822	#CJK UNIFIED IDEOGRAPH
-0x8A9D	0x8305	#CJK UNIFIED IDEOGRAPH
-0x8A9E	0x8431	#CJK UNIFIED IDEOGRAPH
-0x8A9F	0x7CA5	#CJK UNIFIED IDEOGRAPH
-0x8AA0	0x5208	#CJK UNIFIED IDEOGRAPH
-0x8AA1	0x82C5	#CJK UNIFIED IDEOGRAPH
-0x8AA2	0x74E6	#CJK UNIFIED IDEOGRAPH
-0x8AA3	0x4E7E	#CJK UNIFIED IDEOGRAPH
-0x8AA4	0x4F83	#CJK UNIFIED IDEOGRAPH
-0x8AA5	0x51A0	#CJK UNIFIED IDEOGRAPH
-0x8AA6	0x5BD2	#CJK UNIFIED IDEOGRAPH
-0x8AA7	0x520A	#CJK UNIFIED IDEOGRAPH
-0x8AA8	0x52D8	#CJK UNIFIED IDEOGRAPH
-0x8AA9	0x52E7	#CJK UNIFIED IDEOGRAPH
-0x8AAA	0x5DFB	#CJK UNIFIED IDEOGRAPH
-0x8AAB	0x559A	#CJK UNIFIED IDEOGRAPH
-0x8AAC	0x582A	#CJK UNIFIED IDEOGRAPH
-0x8AAD	0x59E6	#CJK UNIFIED IDEOGRAPH
-0x8AAE	0x5B8C	#CJK UNIFIED IDEOGRAPH
-0x8AAF	0x5B98	#CJK UNIFIED IDEOGRAPH
-0x8AB0	0x5BDB	#CJK UNIFIED IDEOGRAPH
-0x8AB1	0x5E72	#CJK UNIFIED IDEOGRAPH
-0x8AB2	0x5E79	#CJK UNIFIED IDEOGRAPH
-0x8AB3	0x60A3	#CJK UNIFIED IDEOGRAPH
-0x8AB4	0x611F	#CJK UNIFIED IDEOGRAPH
-0x8AB5	0x6163	#CJK UNIFIED IDEOGRAPH
-0x8AB6	0x61BE	#CJK UNIFIED IDEOGRAPH
-0x8AB7	0x63DB	#CJK UNIFIED IDEOGRAPH
-0x8AB8	0x6562	#CJK UNIFIED IDEOGRAPH
-0x8AB9	0x67D1	#CJK UNIFIED IDEOGRAPH
-0x8ABA	0x6853	#CJK UNIFIED IDEOGRAPH
-0x8ABB	0x68FA	#CJK UNIFIED IDEOGRAPH
-0x8ABC	0x6B3E	#CJK UNIFIED IDEOGRAPH
-0x8ABD	0x6B53	#CJK UNIFIED IDEOGRAPH
-0x8ABE	0x6C57	#CJK UNIFIED IDEOGRAPH
-0x8ABF	0x6F22	#CJK UNIFIED IDEOGRAPH
-0x8AC0	0x6F97	#CJK UNIFIED IDEOGRAPH
-0x8AC1	0x6F45	#CJK UNIFIED IDEOGRAPH
-0x8AC2	0x74B0	#CJK UNIFIED IDEOGRAPH
-0x8AC3	0x7518	#CJK UNIFIED IDEOGRAPH
-0x8AC4	0x76E3	#CJK UNIFIED IDEOGRAPH
-0x8AC5	0x770B	#CJK UNIFIED IDEOGRAPH
-0x8AC6	0x7AFF	#CJK UNIFIED IDEOGRAPH
-0x8AC7	0x7BA1	#CJK UNIFIED IDEOGRAPH
-0x8AC8	0x7C21	#CJK UNIFIED IDEOGRAPH
-0x8AC9	0x7DE9	#CJK UNIFIED IDEOGRAPH
-0x8ACA	0x7F36	#CJK UNIFIED IDEOGRAPH
-0x8ACB	0x7FF0	#CJK UNIFIED IDEOGRAPH
-0x8ACC	0x809D	#CJK UNIFIED IDEOGRAPH
-0x8ACD	0x8266	#CJK UNIFIED IDEOGRAPH
-0x8ACE	0x839E	#CJK UNIFIED IDEOGRAPH
-0x8ACF	0x89B3	#CJK UNIFIED IDEOGRAPH
-0x8AD0	0x8ACC	#CJK UNIFIED IDEOGRAPH
-0x8AD1	0x8CAB	#CJK UNIFIED IDEOGRAPH
-0x8AD2	0x9084	#CJK UNIFIED IDEOGRAPH
-0x8AD3	0x9451	#CJK UNIFIED IDEOGRAPH
-0x8AD4	0x9593	#CJK UNIFIED IDEOGRAPH
-0x8AD5	0x9591	#CJK UNIFIED IDEOGRAPH
-0x8AD6	0x95A2	#CJK UNIFIED IDEOGRAPH
-0x8AD7	0x9665	#CJK UNIFIED IDEOGRAPH
-0x8AD8	0x97D3	#CJK UNIFIED IDEOGRAPH
-0x8AD9	0x9928	#CJK UNIFIED IDEOGRAPH
-0x8ADA	0x8218	#CJK UNIFIED IDEOGRAPH
-0x8ADB	0x4E38	#CJK UNIFIED IDEOGRAPH
-0x8ADC	0x542B	#CJK UNIFIED IDEOGRAPH
-0x8ADD	0x5CB8	#CJK UNIFIED IDEOGRAPH
-0x8ADE	0x5DCC	#CJK UNIFIED IDEOGRAPH
-0x8ADF	0x73A9	#CJK UNIFIED IDEOGRAPH
-0x8AE0	0x764C	#CJK UNIFIED IDEOGRAPH
-0x8AE1	0x773C	#CJK UNIFIED IDEOGRAPH
-0x8AE2	0x5CA9	#CJK UNIFIED IDEOGRAPH
-0x8AE3	0x7FEB	#CJK UNIFIED IDEOGRAPH
-0x8AE4	0x8D0B	#CJK UNIFIED IDEOGRAPH
-0x8AE5	0x96C1	#CJK UNIFIED IDEOGRAPH
-0x8AE6	0x9811	#CJK UNIFIED IDEOGRAPH
-0x8AE7	0x9854	#CJK UNIFIED IDEOGRAPH
-0x8AE8	0x9858	#CJK UNIFIED IDEOGRAPH
-0x8AE9	0x4F01	#CJK UNIFIED IDEOGRAPH
-0x8AEA	0x4F0E	#CJK UNIFIED IDEOGRAPH
-0x8AEB	0x5371	#CJK UNIFIED IDEOGRAPH
-0x8AEC	0x559C	#CJK UNIFIED IDEOGRAPH
-0x8AED	0x5668	#CJK UNIFIED IDEOGRAPH
-0x8AEE	0x57FA	#CJK UNIFIED IDEOGRAPH
-0x8AEF	0x5947	#CJK UNIFIED IDEOGRAPH
-0x8AF0	0x5B09	#CJK UNIFIED IDEOGRAPH
-0x8AF1	0x5BC4	#CJK UNIFIED IDEOGRAPH
-0x8AF2	0x5C90	#CJK UNIFIED IDEOGRAPH
-0x8AF3	0x5E0C	#CJK UNIFIED IDEOGRAPH
-0x8AF4	0x5E7E	#CJK UNIFIED IDEOGRAPH
-0x8AF5	0x5FCC	#CJK UNIFIED IDEOGRAPH
-0x8AF6	0x63EE	#CJK UNIFIED IDEOGRAPH
-0x8AF7	0x673A	#CJK UNIFIED IDEOGRAPH
-0x8AF8	0x65D7	#CJK UNIFIED IDEOGRAPH
-0x8AF9	0x65E2	#CJK UNIFIED IDEOGRAPH
-0x8AFA	0x671F	#CJK UNIFIED IDEOGRAPH
-0x8AFB	0x68CB	#CJK UNIFIED IDEOGRAPH
-0x8AFC	0x68C4	#CJK UNIFIED IDEOGRAPH
-0x8B40	0x6A5F	#CJK UNIFIED IDEOGRAPH
-0x8B41	0x5E30	#CJK UNIFIED IDEOGRAPH
-0x8B42	0x6BC5	#CJK UNIFIED IDEOGRAPH
-0x8B43	0x6C17	#CJK UNIFIED IDEOGRAPH
-0x8B44	0x6C7D	#CJK UNIFIED IDEOGRAPH
-0x8B45	0x757F	#CJK UNIFIED IDEOGRAPH
-0x8B46	0x7948	#CJK UNIFIED IDEOGRAPH
-0x8B47	0x5B63	#CJK UNIFIED IDEOGRAPH
-0x8B48	0x7A00	#CJK UNIFIED IDEOGRAPH
-0x8B49	0x7D00	#CJK UNIFIED IDEOGRAPH
-0x8B4A	0x5FBD	#CJK UNIFIED IDEOGRAPH
-0x8B4B	0x898F	#CJK UNIFIED IDEOGRAPH
-0x8B4C	0x8A18	#CJK UNIFIED IDEOGRAPH
-0x8B4D	0x8CB4	#CJK UNIFIED IDEOGRAPH
-0x8B4E	0x8D77	#CJK UNIFIED IDEOGRAPH
-0x8B4F	0x8ECC	#CJK UNIFIED IDEOGRAPH
-0x8B50	0x8F1D	#CJK UNIFIED IDEOGRAPH
-0x8B51	0x98E2	#CJK UNIFIED IDEOGRAPH
-0x8B52	0x9A0E	#CJK UNIFIED IDEOGRAPH
-0x8B53	0x9B3C	#CJK UNIFIED IDEOGRAPH
-0x8B54	0x4E80	#CJK UNIFIED IDEOGRAPH
-0x8B55	0x507D	#CJK UNIFIED IDEOGRAPH
-0x8B56	0x5100	#CJK UNIFIED IDEOGRAPH
-0x8B57	0x5993	#CJK UNIFIED IDEOGRAPH
-0x8B58	0x5B9C	#CJK UNIFIED IDEOGRAPH
-0x8B59	0x622F	#CJK UNIFIED IDEOGRAPH
-0x8B5A	0x6280	#CJK UNIFIED IDEOGRAPH
-0x8B5B	0x64EC	#CJK UNIFIED IDEOGRAPH
-0x8B5C	0x6B3A	#CJK UNIFIED IDEOGRAPH
-0x8B5D	0x72A0	#CJK UNIFIED IDEOGRAPH
-0x8B5E	0x7591	#CJK UNIFIED IDEOGRAPH
-0x8B5F	0x7947	#CJK UNIFIED IDEOGRAPH
-0x8B60	0x7FA9	#CJK UNIFIED IDEOGRAPH
-0x8B61	0x87FB	#CJK UNIFIED IDEOGRAPH
-0x8B62	0x8ABC	#CJK UNIFIED IDEOGRAPH
-0x8B63	0x8B70	#CJK UNIFIED IDEOGRAPH
-0x8B64	0x63AC	#CJK UNIFIED IDEOGRAPH
-0x8B65	0x83CA	#CJK UNIFIED IDEOGRAPH
-0x8B66	0x97A0	#CJK UNIFIED IDEOGRAPH
-0x8B67	0x5409	#CJK UNIFIED IDEOGRAPH
-0x8B68	0x5403	#CJK UNIFIED IDEOGRAPH
-0x8B69	0x55AB	#CJK UNIFIED IDEOGRAPH
-0x8B6A	0x6854	#CJK UNIFIED IDEOGRAPH
-0x8B6B	0x6A58	#CJK UNIFIED IDEOGRAPH
-0x8B6C	0x8A70	#CJK UNIFIED IDEOGRAPH
-0x8B6D	0x7827	#CJK UNIFIED IDEOGRAPH
-0x8B6E	0x6775	#CJK UNIFIED IDEOGRAPH
-0x8B6F	0x9ECD	#CJK UNIFIED IDEOGRAPH
-0x8B70	0x5374	#CJK UNIFIED IDEOGRAPH
-0x8B71	0x5BA2	#CJK UNIFIED IDEOGRAPH
-0x8B72	0x811A	#CJK UNIFIED IDEOGRAPH
-0x8B73	0x8650	#CJK UNIFIED IDEOGRAPH
-0x8B74	0x9006	#CJK UNIFIED IDEOGRAPH
-0x8B75	0x4E18	#CJK UNIFIED IDEOGRAPH
-0x8B76	0x4E45	#CJK UNIFIED IDEOGRAPH
-0x8B77	0x4EC7	#CJK UNIFIED IDEOGRAPH
-0x8B78	0x4F11	#CJK UNIFIED IDEOGRAPH
-0x8B79	0x53CA	#CJK UNIFIED IDEOGRAPH
-0x8B7A	0x5438	#CJK UNIFIED IDEOGRAPH
-0x8B7B	0x5BAE	#CJK UNIFIED IDEOGRAPH
-0x8B7C	0x5F13	#CJK UNIFIED IDEOGRAPH
-0x8B7D	0x6025	#CJK UNIFIED IDEOGRAPH
-0x8B7E	0x6551	#CJK UNIFIED IDEOGRAPH
-0x8B80	0x673D	#CJK UNIFIED IDEOGRAPH
-0x8B81	0x6C42	#CJK UNIFIED IDEOGRAPH
-0x8B82	0x6C72	#CJK UNIFIED IDEOGRAPH
-0x8B83	0x6CE3	#CJK UNIFIED IDEOGRAPH
-0x8B84	0x7078	#CJK UNIFIED IDEOGRAPH
-0x8B85	0x7403	#CJK UNIFIED IDEOGRAPH
-0x8B86	0x7A76	#CJK UNIFIED IDEOGRAPH
-0x8B87	0x7AAE	#CJK UNIFIED IDEOGRAPH
-0x8B88	0x7B08	#CJK UNIFIED IDEOGRAPH
-0x8B89	0x7D1A	#CJK UNIFIED IDEOGRAPH
-0x8B8A	0x7CFE	#CJK UNIFIED IDEOGRAPH
-0x8B8B	0x7D66	#CJK UNIFIED IDEOGRAPH
-0x8B8C	0x65E7	#CJK UNIFIED IDEOGRAPH
-0x8B8D	0x725B	#CJK UNIFIED IDEOGRAPH
-0x8B8E	0x53BB	#CJK UNIFIED IDEOGRAPH
-0x8B8F	0x5C45	#CJK UNIFIED IDEOGRAPH
-0x8B90	0x5DE8	#CJK UNIFIED IDEOGRAPH
-0x8B91	0x62D2	#CJK UNIFIED IDEOGRAPH
-0x8B92	0x62E0	#CJK UNIFIED IDEOGRAPH
-0x8B93	0x6319	#CJK UNIFIED IDEOGRAPH
-0x8B94	0x6E20	#CJK UNIFIED IDEOGRAPH
-0x8B95	0x865A	#CJK UNIFIED IDEOGRAPH
-0x8B96	0x8A31	#CJK UNIFIED IDEOGRAPH
-0x8B97	0x8DDD	#CJK UNIFIED IDEOGRAPH
-0x8B98	0x92F8	#CJK UNIFIED IDEOGRAPH
-0x8B99	0x6F01	#CJK UNIFIED IDEOGRAPH
-0x8B9A	0x79A6	#CJK UNIFIED IDEOGRAPH
-0x8B9B	0x9B5A	#CJK UNIFIED IDEOGRAPH
-0x8B9C	0x4EA8	#CJK UNIFIED IDEOGRAPH
-0x8B9D	0x4EAB	#CJK UNIFIED IDEOGRAPH
-0x8B9E	0x4EAC	#CJK UNIFIED IDEOGRAPH
-0x8B9F	0x4F9B	#CJK UNIFIED IDEOGRAPH
-0x8BA0	0x4FA0	#CJK UNIFIED IDEOGRAPH
-0x8BA1	0x50D1	#CJK UNIFIED IDEOGRAPH
-0x8BA2	0x5147	#CJK UNIFIED IDEOGRAPH
-0x8BA3	0x7AF6	#CJK UNIFIED IDEOGRAPH
-0x8BA4	0x5171	#CJK UNIFIED IDEOGRAPH
-0x8BA5	0x51F6	#CJK UNIFIED IDEOGRAPH
-0x8BA6	0x5354	#CJK UNIFIED IDEOGRAPH
-0x8BA7	0x5321	#CJK UNIFIED IDEOGRAPH
-0x8BA8	0x537F	#CJK UNIFIED IDEOGRAPH
-0x8BA9	0x53EB	#CJK UNIFIED IDEOGRAPH
-0x8BAA	0x55AC	#CJK UNIFIED IDEOGRAPH
-0x8BAB	0x5883	#CJK UNIFIED IDEOGRAPH
-0x8BAC	0x5CE1	#CJK UNIFIED IDEOGRAPH
-0x8BAD	0x5F37	#CJK UNIFIED IDEOGRAPH
-0x8BAE	0x5F4A	#CJK UNIFIED IDEOGRAPH
-0x8BAF	0x602F	#CJK UNIFIED IDEOGRAPH
-0x8BB0	0x6050	#CJK UNIFIED IDEOGRAPH
-0x8BB1	0x606D	#CJK UNIFIED IDEOGRAPH
-0x8BB2	0x631F	#CJK UNIFIED IDEOGRAPH
-0x8BB3	0x6559	#CJK UNIFIED IDEOGRAPH
-0x8BB4	0x6A4B	#CJK UNIFIED IDEOGRAPH
-0x8BB5	0x6CC1	#CJK UNIFIED IDEOGRAPH
-0x8BB6	0x72C2	#CJK UNIFIED IDEOGRAPH
-0x8BB7	0x72ED	#CJK UNIFIED IDEOGRAPH
-0x8BB8	0x77EF	#CJK UNIFIED IDEOGRAPH
-0x8BB9	0x80F8	#CJK UNIFIED IDEOGRAPH
-0x8BBA	0x8105	#CJK UNIFIED IDEOGRAPH
-0x8BBB	0x8208	#CJK UNIFIED IDEOGRAPH
-0x8BBC	0x854E	#CJK UNIFIED IDEOGRAPH
-0x8BBD	0x90F7	#CJK UNIFIED IDEOGRAPH
-0x8BBE	0x93E1	#CJK UNIFIED IDEOGRAPH
-0x8BBF	0x97FF	#CJK UNIFIED IDEOGRAPH
-0x8BC0	0x9957	#CJK UNIFIED IDEOGRAPH
-0x8BC1	0x9A5A	#CJK UNIFIED IDEOGRAPH
-0x8BC2	0x4EF0	#CJK UNIFIED IDEOGRAPH
-0x8BC3	0x51DD	#CJK UNIFIED IDEOGRAPH
-0x8BC4	0x5C2D	#CJK UNIFIED IDEOGRAPH
-0x8BC5	0x6681	#CJK UNIFIED IDEOGRAPH
-0x8BC6	0x696D	#CJK UNIFIED IDEOGRAPH
-0x8BC7	0x5C40	#CJK UNIFIED IDEOGRAPH
-0x8BC8	0x66F2	#CJK UNIFIED IDEOGRAPH
-0x8BC9	0x6975	#CJK UNIFIED IDEOGRAPH
-0x8BCA	0x7389	#CJK UNIFIED IDEOGRAPH
-0x8BCB	0x6850	#CJK UNIFIED IDEOGRAPH
-0x8BCC	0x7C81	#CJK UNIFIED IDEOGRAPH
-0x8BCD	0x50C5	#CJK UNIFIED IDEOGRAPH
-0x8BCE	0x52E4	#CJK UNIFIED IDEOGRAPH
-0x8BCF	0x5747	#CJK UNIFIED IDEOGRAPH
-0x8BD0	0x5DFE	#CJK UNIFIED IDEOGRAPH
-0x8BD1	0x9326	#CJK UNIFIED IDEOGRAPH
-0x8BD2	0x65A4	#CJK UNIFIED IDEOGRAPH
-0x8BD3	0x6B23	#CJK UNIFIED IDEOGRAPH
-0x8BD4	0x6B3D	#CJK UNIFIED IDEOGRAPH
-0x8BD5	0x7434	#CJK UNIFIED IDEOGRAPH
-0x8BD6	0x7981	#CJK UNIFIED IDEOGRAPH
-0x8BD7	0x79BD	#CJK UNIFIED IDEOGRAPH
-0x8BD8	0x7B4B	#CJK UNIFIED IDEOGRAPH
-0x8BD9	0x7DCA	#CJK UNIFIED IDEOGRAPH
-0x8BDA	0x82B9	#CJK UNIFIED IDEOGRAPH
-0x8BDB	0x83CC	#CJK UNIFIED IDEOGRAPH
-0x8BDC	0x887F	#CJK UNIFIED IDEOGRAPH
-0x8BDD	0x895F	#CJK UNIFIED IDEOGRAPH
-0x8BDE	0x8B39	#CJK UNIFIED IDEOGRAPH
-0x8BDF	0x8FD1	#CJK UNIFIED IDEOGRAPH
-0x8BE0	0x91D1	#CJK UNIFIED IDEOGRAPH
-0x8BE1	0x541F	#CJK UNIFIED IDEOGRAPH
-0x8BE2	0x9280	#CJK UNIFIED IDEOGRAPH
-0x8BE3	0x4E5D	#CJK UNIFIED IDEOGRAPH
-0x8BE4	0x5036	#CJK UNIFIED IDEOGRAPH
-0x8BE5	0x53E5	#CJK UNIFIED IDEOGRAPH
-0x8BE6	0x533A	#CJK UNIFIED IDEOGRAPH
-0x8BE7	0x72D7	#CJK UNIFIED IDEOGRAPH
-0x8BE8	0x7396	#CJK UNIFIED IDEOGRAPH
-0x8BE9	0x77E9	#CJK UNIFIED IDEOGRAPH
-0x8BEA	0x82E6	#CJK UNIFIED IDEOGRAPH
-0x8BEB	0x8EAF	#CJK UNIFIED IDEOGRAPH
-0x8BEC	0x99C6	#CJK UNIFIED IDEOGRAPH
-0x8BED	0x99C8	#CJK UNIFIED IDEOGRAPH
-0x8BEE	0x99D2	#CJK UNIFIED IDEOGRAPH
-0x8BEF	0x5177	#CJK UNIFIED IDEOGRAPH
-0x8BF0	0x611A	#CJK UNIFIED IDEOGRAPH
-0x8BF1	0x865E	#CJK UNIFIED IDEOGRAPH
-0x8BF2	0x55B0	#CJK UNIFIED IDEOGRAPH
-0x8BF3	0x7A7A	#CJK UNIFIED IDEOGRAPH
-0x8BF4	0x5076	#CJK UNIFIED IDEOGRAPH
-0x8BF5	0x5BD3	#CJK UNIFIED IDEOGRAPH
-0x8BF6	0x9047	#CJK UNIFIED IDEOGRAPH
-0x8BF7	0x9685	#CJK UNIFIED IDEOGRAPH
-0x8BF8	0x4E32	#CJK UNIFIED IDEOGRAPH
-0x8BF9	0x6ADB	#CJK UNIFIED IDEOGRAPH
-0x8BFA	0x91E7	#CJK UNIFIED IDEOGRAPH
-0x8BFB	0x5C51	#CJK UNIFIED IDEOGRAPH
-0x8BFC	0x5C48	#CJK UNIFIED IDEOGRAPH
-0x8C40	0x6398	#CJK UNIFIED IDEOGRAPH
-0x8C41	0x7A9F	#CJK UNIFIED IDEOGRAPH
-0x8C42	0x6C93	#CJK UNIFIED IDEOGRAPH
-0x8C43	0x9774	#CJK UNIFIED IDEOGRAPH
-0x8C44	0x8F61	#CJK UNIFIED IDEOGRAPH
-0x8C45	0x7AAA	#CJK UNIFIED IDEOGRAPH
-0x8C46	0x718A	#CJK UNIFIED IDEOGRAPH
-0x8C47	0x9688	#CJK UNIFIED IDEOGRAPH
-0x8C48	0x7C82	#CJK UNIFIED IDEOGRAPH
-0x8C49	0x6817	#CJK UNIFIED IDEOGRAPH
-0x8C4A	0x7E70	#CJK UNIFIED IDEOGRAPH
-0x8C4B	0x6851	#CJK UNIFIED IDEOGRAPH
-0x8C4C	0x936C	#CJK UNIFIED IDEOGRAPH
-0x8C4D	0x52F2	#CJK UNIFIED IDEOGRAPH
-0x8C4E	0x541B	#CJK UNIFIED IDEOGRAPH
-0x8C4F	0x85AB	#CJK UNIFIED IDEOGRAPH
-0x8C50	0x8A13	#CJK UNIFIED IDEOGRAPH
-0x8C51	0x7FA4	#CJK UNIFIED IDEOGRAPH
-0x8C52	0x8ECD	#CJK UNIFIED IDEOGRAPH
-0x8C53	0x90E1	#CJK UNIFIED IDEOGRAPH
-0x8C54	0x5366	#CJK UNIFIED IDEOGRAPH
-0x8C55	0x8888	#CJK UNIFIED IDEOGRAPH
-0x8C56	0x7941	#CJK UNIFIED IDEOGRAPH
-0x8C57	0x4FC2	#CJK UNIFIED IDEOGRAPH
-0x8C58	0x50BE	#CJK UNIFIED IDEOGRAPH
-0x8C59	0x5211	#CJK UNIFIED IDEOGRAPH
-0x8C5A	0x5144	#CJK UNIFIED IDEOGRAPH
-0x8C5B	0x5553	#CJK UNIFIED IDEOGRAPH
-0x8C5C	0x572D	#CJK UNIFIED IDEOGRAPH
-0x8C5D	0x73EA	#CJK UNIFIED IDEOGRAPH
-0x8C5E	0x578B	#CJK UNIFIED IDEOGRAPH
-0x8C5F	0x5951	#CJK UNIFIED IDEOGRAPH
-0x8C60	0x5F62	#CJK UNIFIED IDEOGRAPH
-0x8C61	0x5F84	#CJK UNIFIED IDEOGRAPH
-0x8C62	0x6075	#CJK UNIFIED IDEOGRAPH
-0x8C63	0x6176	#CJK UNIFIED IDEOGRAPH
-0x8C64	0x6167	#CJK UNIFIED IDEOGRAPH
-0x8C65	0x61A9	#CJK UNIFIED IDEOGRAPH
-0x8C66	0x63B2	#CJK UNIFIED IDEOGRAPH
-0x8C67	0x643A	#CJK UNIFIED IDEOGRAPH
-0x8C68	0x656C	#CJK UNIFIED IDEOGRAPH
-0x8C69	0x666F	#CJK UNIFIED IDEOGRAPH
-0x8C6A	0x6842	#CJK UNIFIED IDEOGRAPH
-0x8C6B	0x6E13	#CJK UNIFIED IDEOGRAPH
-0x8C6C	0x7566	#CJK UNIFIED IDEOGRAPH
-0x8C6D	0x7A3D	#CJK UNIFIED IDEOGRAPH
-0x8C6E	0x7CFB	#CJK UNIFIED IDEOGRAPH
-0x8C6F	0x7D4C	#CJK UNIFIED IDEOGRAPH
-0x8C70	0x7D99	#CJK UNIFIED IDEOGRAPH
-0x8C71	0x7E4B	#CJK UNIFIED IDEOGRAPH
-0x8C72	0x7F6B	#CJK UNIFIED IDEOGRAPH
-0x8C73	0x830E	#CJK UNIFIED IDEOGRAPH
-0x8C74	0x834A	#CJK UNIFIED IDEOGRAPH
-0x8C75	0x86CD	#CJK UNIFIED IDEOGRAPH
-0x8C76	0x8A08	#CJK UNIFIED IDEOGRAPH
-0x8C77	0x8A63	#CJK UNIFIED IDEOGRAPH
-0x8C78	0x8B66	#CJK UNIFIED IDEOGRAPH
-0x8C79	0x8EFD	#CJK UNIFIED IDEOGRAPH
-0x8C7A	0x981A	#CJK UNIFIED IDEOGRAPH
-0x8C7B	0x9D8F	#CJK UNIFIED IDEOGRAPH
-0x8C7C	0x82B8	#CJK UNIFIED IDEOGRAPH
-0x8C7D	0x8FCE	#CJK UNIFIED IDEOGRAPH
-0x8C7E	0x9BE8	#CJK UNIFIED IDEOGRAPH
-0x8C80	0x5287	#CJK UNIFIED IDEOGRAPH
-0x8C81	0x621F	#CJK UNIFIED IDEOGRAPH
-0x8C82	0x6483	#CJK UNIFIED IDEOGRAPH
-0x8C83	0x6FC0	#CJK UNIFIED IDEOGRAPH
-0x8C84	0x9699	#CJK UNIFIED IDEOGRAPH
-0x8C85	0x6841	#CJK UNIFIED IDEOGRAPH
-0x8C86	0x5091	#CJK UNIFIED IDEOGRAPH
-0x8C87	0x6B20	#CJK UNIFIED IDEOGRAPH
-0x8C88	0x6C7A	#CJK UNIFIED IDEOGRAPH
-0x8C89	0x6F54	#CJK UNIFIED IDEOGRAPH
-0x8C8A	0x7A74	#CJK UNIFIED IDEOGRAPH
-0x8C8B	0x7D50	#CJK UNIFIED IDEOGRAPH
-0x8C8C	0x8840	#CJK UNIFIED IDEOGRAPH
-0x8C8D	0x8A23	#CJK UNIFIED IDEOGRAPH
-0x8C8E	0x6708	#CJK UNIFIED IDEOGRAPH
-0x8C8F	0x4EF6	#CJK UNIFIED IDEOGRAPH
-0x8C90	0x5039	#CJK UNIFIED IDEOGRAPH
-0x8C91	0x5026	#CJK UNIFIED IDEOGRAPH
-0x8C92	0x5065	#CJK UNIFIED IDEOGRAPH
-0x8C93	0x517C	#CJK UNIFIED IDEOGRAPH
-0x8C94	0x5238	#CJK UNIFIED IDEOGRAPH
-0x8C95	0x5263	#CJK UNIFIED IDEOGRAPH
-0x8C96	0x55A7	#CJK UNIFIED IDEOGRAPH
-0x8C97	0x570F	#CJK UNIFIED IDEOGRAPH
-0x8C98	0x5805	#CJK UNIFIED IDEOGRAPH
-0x8C99	0x5ACC	#CJK UNIFIED IDEOGRAPH
-0x8C9A	0x5EFA	#CJK UNIFIED IDEOGRAPH
-0x8C9B	0x61B2	#CJK UNIFIED IDEOGRAPH
-0x8C9C	0x61F8	#CJK UNIFIED IDEOGRAPH
-0x8C9D	0x62F3	#CJK UNIFIED IDEOGRAPH
-0x8C9E	0x6372	#CJK UNIFIED IDEOGRAPH
-0x8C9F	0x691C	#CJK UNIFIED IDEOGRAPH
-0x8CA0	0x6A29	#CJK UNIFIED IDEOGRAPH
-0x8CA1	0x727D	#CJK UNIFIED IDEOGRAPH
-0x8CA2	0x72AC	#CJK UNIFIED IDEOGRAPH
-0x8CA3	0x732E	#CJK UNIFIED IDEOGRAPH
-0x8CA4	0x7814	#CJK UNIFIED IDEOGRAPH
-0x8CA5	0x786F	#CJK UNIFIED IDEOGRAPH
-0x8CA6	0x7D79	#CJK UNIFIED IDEOGRAPH
-0x8CA7	0x770C	#CJK UNIFIED IDEOGRAPH
-0x8CA8	0x80A9	#CJK UNIFIED IDEOGRAPH
-0x8CA9	0x898B	#CJK UNIFIED IDEOGRAPH
-0x8CAA	0x8B19	#CJK UNIFIED IDEOGRAPH
-0x8CAB	0x8CE2	#CJK UNIFIED IDEOGRAPH
-0x8CAC	0x8ED2	#CJK UNIFIED IDEOGRAPH
-0x8CAD	0x9063	#CJK UNIFIED IDEOGRAPH
-0x8CAE	0x9375	#CJK UNIFIED IDEOGRAPH
-0x8CAF	0x967A	#CJK UNIFIED IDEOGRAPH
-0x8CB0	0x9855	#CJK UNIFIED IDEOGRAPH
-0x8CB1	0x9A13	#CJK UNIFIED IDEOGRAPH
-0x8CB2	0x9E78	#CJK UNIFIED IDEOGRAPH
-0x8CB3	0x5143	#CJK UNIFIED IDEOGRAPH
-0x8CB4	0x539F	#CJK UNIFIED IDEOGRAPH
-0x8CB5	0x53B3	#CJK UNIFIED IDEOGRAPH
-0x8CB6	0x5E7B	#CJK UNIFIED IDEOGRAPH
-0x8CB7	0x5F26	#CJK UNIFIED IDEOGRAPH
-0x8CB8	0x6E1B	#CJK UNIFIED IDEOGRAPH
-0x8CB9	0x6E90	#CJK UNIFIED IDEOGRAPH
-0x8CBA	0x7384	#CJK UNIFIED IDEOGRAPH
-0x8CBB	0x73FE	#CJK UNIFIED IDEOGRAPH
-0x8CBC	0x7D43	#CJK UNIFIED IDEOGRAPH
-0x8CBD	0x8237	#CJK UNIFIED IDEOGRAPH
-0x8CBE	0x8A00	#CJK UNIFIED IDEOGRAPH
-0x8CBF	0x8AFA	#CJK UNIFIED IDEOGRAPH
-0x8CC0	0x9650	#CJK UNIFIED IDEOGRAPH
-0x8CC1	0x4E4E	#CJK UNIFIED IDEOGRAPH
-0x8CC2	0x500B	#CJK UNIFIED IDEOGRAPH
-0x8CC3	0x53E4	#CJK UNIFIED IDEOGRAPH
-0x8CC4	0x547C	#CJK UNIFIED IDEOGRAPH
-0x8CC5	0x56FA	#CJK UNIFIED IDEOGRAPH
-0x8CC6	0x59D1	#CJK UNIFIED IDEOGRAPH
-0x8CC7	0x5B64	#CJK UNIFIED IDEOGRAPH
-0x8CC8	0x5DF1	#CJK UNIFIED IDEOGRAPH
-0x8CC9	0x5EAB	#CJK UNIFIED IDEOGRAPH
-0x8CCA	0x5F27	#CJK UNIFIED IDEOGRAPH
-0x8CCB	0x6238	#CJK UNIFIED IDEOGRAPH
-0x8CCC	0x6545	#CJK UNIFIED IDEOGRAPH
-0x8CCD	0x67AF	#CJK UNIFIED IDEOGRAPH
-0x8CCE	0x6E56	#CJK UNIFIED IDEOGRAPH
-0x8CCF	0x72D0	#CJK UNIFIED IDEOGRAPH
-0x8CD0	0x7CCA	#CJK UNIFIED IDEOGRAPH
-0x8CD1	0x88B4	#CJK UNIFIED IDEOGRAPH
-0x8CD2	0x80A1	#CJK UNIFIED IDEOGRAPH
-0x8CD3	0x80E1	#CJK UNIFIED IDEOGRAPH
-0x8CD4	0x83F0	#CJK UNIFIED IDEOGRAPH
-0x8CD5	0x864E	#CJK UNIFIED IDEOGRAPH
-0x8CD6	0x8A87	#CJK UNIFIED IDEOGRAPH
-0x8CD7	0x8DE8	#CJK UNIFIED IDEOGRAPH
-0x8CD8	0x9237	#CJK UNIFIED IDEOGRAPH
-0x8CD9	0x96C7	#CJK UNIFIED IDEOGRAPH
-0x8CDA	0x9867	#CJK UNIFIED IDEOGRAPH
-0x8CDB	0x9F13	#CJK UNIFIED IDEOGRAPH
-0x8CDC	0x4E94	#CJK UNIFIED IDEOGRAPH
-0x8CDD	0x4E92	#CJK UNIFIED IDEOGRAPH
-0x8CDE	0x4F0D	#CJK UNIFIED IDEOGRAPH
-0x8CDF	0x5348	#CJK UNIFIED IDEOGRAPH
-0x8CE0	0x5449	#CJK UNIFIED IDEOGRAPH
-0x8CE1	0x543E	#CJK UNIFIED IDEOGRAPH
-0x8CE2	0x5A2F	#CJK UNIFIED IDEOGRAPH
-0x8CE3	0x5F8C	#CJK UNIFIED IDEOGRAPH
-0x8CE4	0x5FA1	#CJK UNIFIED IDEOGRAPH
-0x8CE5	0x609F	#CJK UNIFIED IDEOGRAPH
-0x8CE6	0x68A7	#CJK UNIFIED IDEOGRAPH
-0x8CE7	0x6A8E	#CJK UNIFIED IDEOGRAPH
-0x8CE8	0x745A	#CJK UNIFIED IDEOGRAPH
-0x8CE9	0x7881	#CJK UNIFIED IDEOGRAPH
-0x8CEA	0x8A9E	#CJK UNIFIED IDEOGRAPH
-0x8CEB	0x8AA4	#CJK UNIFIED IDEOGRAPH
-0x8CEC	0x8B77	#CJK UNIFIED IDEOGRAPH
-0x8CED	0x9190	#CJK UNIFIED IDEOGRAPH
-0x8CEE	0x4E5E	#CJK UNIFIED IDEOGRAPH
-0x8CEF	0x9BC9	#CJK UNIFIED IDEOGRAPH
-0x8CF0	0x4EA4	#CJK UNIFIED IDEOGRAPH
-0x8CF1	0x4F7C	#CJK UNIFIED IDEOGRAPH
-0x8CF2	0x4FAF	#CJK UNIFIED IDEOGRAPH
-0x8CF3	0x5019	#CJK UNIFIED IDEOGRAPH
-0x8CF4	0x5016	#CJK UNIFIED IDEOGRAPH
-0x8CF5	0x5149	#CJK UNIFIED IDEOGRAPH
-0x8CF6	0x516C	#CJK UNIFIED IDEOGRAPH
-0x8CF7	0x529F	#CJK UNIFIED IDEOGRAPH
-0x8CF8	0x52B9	#CJK UNIFIED IDEOGRAPH
-0x8CF9	0x52FE	#CJK UNIFIED IDEOGRAPH
-0x8CFA	0x539A	#CJK UNIFIED IDEOGRAPH
-0x8CFB	0x53E3	#CJK UNIFIED IDEOGRAPH
-0x8CFC	0x5411	#CJK UNIFIED IDEOGRAPH
-0x8D40	0x540E	#CJK UNIFIED IDEOGRAPH
-0x8D41	0x5589	#CJK UNIFIED IDEOGRAPH
-0x8D42	0x5751	#CJK UNIFIED IDEOGRAPH
-0x8D43	0x57A2	#CJK UNIFIED IDEOGRAPH
-0x8D44	0x597D	#CJK UNIFIED IDEOGRAPH
-0x8D45	0x5B54	#CJK UNIFIED IDEOGRAPH
-0x8D46	0x5B5D	#CJK UNIFIED IDEOGRAPH
-0x8D47	0x5B8F	#CJK UNIFIED IDEOGRAPH
-0x8D48	0x5DE5	#CJK UNIFIED IDEOGRAPH
-0x8D49	0x5DE7	#CJK UNIFIED IDEOGRAPH
-0x8D4A	0x5DF7	#CJK UNIFIED IDEOGRAPH
-0x8D4B	0x5E78	#CJK UNIFIED IDEOGRAPH
-0x8D4C	0x5E83	#CJK UNIFIED IDEOGRAPH
-0x8D4D	0x5E9A	#CJK UNIFIED IDEOGRAPH
-0x8D4E	0x5EB7	#CJK UNIFIED IDEOGRAPH
-0x8D4F	0x5F18	#CJK UNIFIED IDEOGRAPH
-0x8D50	0x6052	#CJK UNIFIED IDEOGRAPH
-0x8D51	0x614C	#CJK UNIFIED IDEOGRAPH
-0x8D52	0x6297	#CJK UNIFIED IDEOGRAPH
-0x8D53	0x62D8	#CJK UNIFIED IDEOGRAPH
-0x8D54	0x63A7	#CJK UNIFIED IDEOGRAPH
-0x8D55	0x653B	#CJK UNIFIED IDEOGRAPH
-0x8D56	0x6602	#CJK UNIFIED IDEOGRAPH
-0x8D57	0x6643	#CJK UNIFIED IDEOGRAPH
-0x8D58	0x66F4	#CJK UNIFIED IDEOGRAPH
-0x8D59	0x676D	#CJK UNIFIED IDEOGRAPH
-0x8D5A	0x6821	#CJK UNIFIED IDEOGRAPH
-0x8D5B	0x6897	#CJK UNIFIED IDEOGRAPH
-0x8D5C	0x69CB	#CJK UNIFIED IDEOGRAPH
-0x8D5D	0x6C5F	#CJK UNIFIED IDEOGRAPH
-0x8D5E	0x6D2A	#CJK UNIFIED IDEOGRAPH
-0x8D5F	0x6D69	#CJK UNIFIED IDEOGRAPH
-0x8D60	0x6E2F	#CJK UNIFIED IDEOGRAPH
-0x8D61	0x6E9D	#CJK UNIFIED IDEOGRAPH
-0x8D62	0x7532	#CJK UNIFIED IDEOGRAPH
-0x8D63	0x7687	#CJK UNIFIED IDEOGRAPH
-0x8D64	0x786C	#CJK UNIFIED IDEOGRAPH
-0x8D65	0x7A3F	#CJK UNIFIED IDEOGRAPH
-0x8D66	0x7CE0	#CJK UNIFIED IDEOGRAPH
-0x8D67	0x7D05	#CJK UNIFIED IDEOGRAPH
-0x8D68	0x7D18	#CJK UNIFIED IDEOGRAPH
-0x8D69	0x7D5E	#CJK UNIFIED IDEOGRAPH
-0x8D6A	0x7DB1	#CJK UNIFIED IDEOGRAPH
-0x8D6B	0x8015	#CJK UNIFIED IDEOGRAPH
-0x8D6C	0x8003	#CJK UNIFIED IDEOGRAPH
-0x8D6D	0x80AF	#CJK UNIFIED IDEOGRAPH
-0x8D6E	0x80B1	#CJK UNIFIED IDEOGRAPH
-0x8D6F	0x8154	#CJK UNIFIED IDEOGRAPH
-0x8D70	0x818F	#CJK UNIFIED IDEOGRAPH
-0x8D71	0x822A	#CJK UNIFIED IDEOGRAPH
-0x8D72	0x8352	#CJK UNIFIED IDEOGRAPH
-0x8D73	0x884C	#CJK UNIFIED IDEOGRAPH
-0x8D74	0x8861	#CJK UNIFIED IDEOGRAPH
-0x8D75	0x8B1B	#CJK UNIFIED IDEOGRAPH
-0x8D76	0x8CA2	#CJK UNIFIED IDEOGRAPH
-0x8D77	0x8CFC	#CJK UNIFIED IDEOGRAPH
-0x8D78	0x90CA	#CJK UNIFIED IDEOGRAPH
-0x8D79	0x9175	#CJK UNIFIED IDEOGRAPH
-0x8D7A	0x9271	#CJK UNIFIED IDEOGRAPH
-0x8D7B	0x783F	#CJK UNIFIED IDEOGRAPH
-0x8D7C	0x92FC	#CJK UNIFIED IDEOGRAPH
-0x8D7D	0x95A4	#CJK UNIFIED IDEOGRAPH
-0x8D7E	0x964D	#CJK UNIFIED IDEOGRAPH
-0x8D80	0x9805	#CJK UNIFIED IDEOGRAPH
-0x8D81	0x9999	#CJK UNIFIED IDEOGRAPH
-0x8D82	0x9AD8	#CJK UNIFIED IDEOGRAPH
-0x8D83	0x9D3B	#CJK UNIFIED IDEOGRAPH
-0x8D84	0x525B	#CJK UNIFIED IDEOGRAPH
-0x8D85	0x52AB	#CJK UNIFIED IDEOGRAPH
-0x8D86	0x53F7	#CJK UNIFIED IDEOGRAPH
-0x8D87	0x5408	#CJK UNIFIED IDEOGRAPH
-0x8D88	0x58D5	#CJK UNIFIED IDEOGRAPH
-0x8D89	0x62F7	#CJK UNIFIED IDEOGRAPH
-0x8D8A	0x6FE0	#CJK UNIFIED IDEOGRAPH
-0x8D8B	0x8C6A	#CJK UNIFIED IDEOGRAPH
-0x8D8C	0x8F5F	#CJK UNIFIED IDEOGRAPH
-0x8D8D	0x9EB9	#CJK UNIFIED IDEOGRAPH
-0x8D8E	0x514B	#CJK UNIFIED IDEOGRAPH
-0x8D8F	0x523B	#CJK UNIFIED IDEOGRAPH
-0x8D90	0x544A	#CJK UNIFIED IDEOGRAPH
-0x8D91	0x56FD	#CJK UNIFIED IDEOGRAPH
-0x8D92	0x7A40	#CJK UNIFIED IDEOGRAPH
-0x8D93	0x9177	#CJK UNIFIED IDEOGRAPH
-0x8D94	0x9D60	#CJK UNIFIED IDEOGRAPH
-0x8D95	0x9ED2	#CJK UNIFIED IDEOGRAPH
-0x8D96	0x7344	#CJK UNIFIED IDEOGRAPH
-0x8D97	0x6F09	#CJK UNIFIED IDEOGRAPH
-0x8D98	0x8170	#CJK UNIFIED IDEOGRAPH
-0x8D99	0x7511	#CJK UNIFIED IDEOGRAPH
-0x8D9A	0x5FFD	#CJK UNIFIED IDEOGRAPH
-0x8D9B	0x60DA	#CJK UNIFIED IDEOGRAPH
-0x8D9C	0x9AA8	#CJK UNIFIED IDEOGRAPH
-0x8D9D	0x72DB	#CJK UNIFIED IDEOGRAPH
-0x8D9E	0x8FBC	#CJK UNIFIED IDEOGRAPH
-0x8D9F	0x6B64	#CJK UNIFIED IDEOGRAPH
-0x8DA0	0x9803	#CJK UNIFIED IDEOGRAPH
-0x8DA1	0x4ECA	#CJK UNIFIED IDEOGRAPH
-0x8DA2	0x56F0	#CJK UNIFIED IDEOGRAPH
-0x8DA3	0x5764	#CJK UNIFIED IDEOGRAPH
-0x8DA4	0x58BE	#CJK UNIFIED IDEOGRAPH
-0x8DA5	0x5A5A	#CJK UNIFIED IDEOGRAPH
-0x8DA6	0x6068	#CJK UNIFIED IDEOGRAPH
-0x8DA7	0x61C7	#CJK UNIFIED IDEOGRAPH
-0x8DA8	0x660F	#CJK UNIFIED IDEOGRAPH
-0x8DA9	0x6606	#CJK UNIFIED IDEOGRAPH
-0x8DAA	0x6839	#CJK UNIFIED IDEOGRAPH
-0x8DAB	0x68B1	#CJK UNIFIED IDEOGRAPH
-0x8DAC	0x6DF7	#CJK UNIFIED IDEOGRAPH
-0x8DAD	0x75D5	#CJK UNIFIED IDEOGRAPH
-0x8DAE	0x7D3A	#CJK UNIFIED IDEOGRAPH
-0x8DAF	0x826E	#CJK UNIFIED IDEOGRAPH
-0x8DB0	0x9B42	#CJK UNIFIED IDEOGRAPH
-0x8DB1	0x4E9B	#CJK UNIFIED IDEOGRAPH
-0x8DB2	0x4F50	#CJK UNIFIED IDEOGRAPH
-0x8DB3	0x53C9	#CJK UNIFIED IDEOGRAPH
-0x8DB4	0x5506	#CJK UNIFIED IDEOGRAPH
-0x8DB5	0x5D6F	#CJK UNIFIED IDEOGRAPH
-0x8DB6	0x5DE6	#CJK UNIFIED IDEOGRAPH
-0x8DB7	0x5DEE	#CJK UNIFIED IDEOGRAPH
-0x8DB8	0x67FB	#CJK UNIFIED IDEOGRAPH
-0x8DB9	0x6C99	#CJK UNIFIED IDEOGRAPH
-0x8DBA	0x7473	#CJK UNIFIED IDEOGRAPH
-0x8DBB	0x7802	#CJK UNIFIED IDEOGRAPH
-0x8DBC	0x8A50	#CJK UNIFIED IDEOGRAPH
-0x8DBD	0x9396	#CJK UNIFIED IDEOGRAPH
-0x8DBE	0x88DF	#CJK UNIFIED IDEOGRAPH
-0x8DBF	0x5750	#CJK UNIFIED IDEOGRAPH
-0x8DC0	0x5EA7	#CJK UNIFIED IDEOGRAPH
-0x8DC1	0x632B	#CJK UNIFIED IDEOGRAPH
-0x8DC2	0x50B5	#CJK UNIFIED IDEOGRAPH
-0x8DC3	0x50AC	#CJK UNIFIED IDEOGRAPH
-0x8DC4	0x518D	#CJK UNIFIED IDEOGRAPH
-0x8DC5	0x6700	#CJK UNIFIED IDEOGRAPH
-0x8DC6	0x54C9	#CJK UNIFIED IDEOGRAPH
-0x8DC7	0x585E	#CJK UNIFIED IDEOGRAPH
-0x8DC8	0x59BB	#CJK UNIFIED IDEOGRAPH
-0x8DC9	0x5BB0	#CJK UNIFIED IDEOGRAPH
-0x8DCA	0x5F69	#CJK UNIFIED IDEOGRAPH
-0x8DCB	0x624D	#CJK UNIFIED IDEOGRAPH
-0x8DCC	0x63A1	#CJK UNIFIED IDEOGRAPH
-0x8DCD	0x683D	#CJK UNIFIED IDEOGRAPH
-0x8DCE	0x6B73	#CJK UNIFIED IDEOGRAPH
-0x8DCF	0x6E08	#CJK UNIFIED IDEOGRAPH
-0x8DD0	0x707D	#CJK UNIFIED IDEOGRAPH
-0x8DD1	0x91C7	#CJK UNIFIED IDEOGRAPH
-0x8DD2	0x7280	#CJK UNIFIED IDEOGRAPH
-0x8DD3	0x7815	#CJK UNIFIED IDEOGRAPH
-0x8DD4	0x7826	#CJK UNIFIED IDEOGRAPH
-0x8DD5	0x796D	#CJK UNIFIED IDEOGRAPH
-0x8DD6	0x658E	#CJK UNIFIED IDEOGRAPH
-0x8DD7	0x7D30	#CJK UNIFIED IDEOGRAPH
-0x8DD8	0x83DC	#CJK UNIFIED IDEOGRAPH
-0x8DD9	0x88C1	#CJK UNIFIED IDEOGRAPH
-0x8DDA	0x8F09	#CJK UNIFIED IDEOGRAPH
-0x8DDB	0x969B	#CJK UNIFIED IDEOGRAPH
-0x8DDC	0x5264	#CJK UNIFIED IDEOGRAPH
-0x8DDD	0x5728	#CJK UNIFIED IDEOGRAPH
-0x8DDE	0x6750	#CJK UNIFIED IDEOGRAPH
-0x8DDF	0x7F6A	#CJK UNIFIED IDEOGRAPH
-0x8DE0	0x8CA1	#CJK UNIFIED IDEOGRAPH
-0x8DE1	0x51B4	#CJK UNIFIED IDEOGRAPH
-0x8DE2	0x5742	#CJK UNIFIED IDEOGRAPH
-0x8DE3	0x962A	#CJK UNIFIED IDEOGRAPH
-0x8DE4	0x583A	#CJK UNIFIED IDEOGRAPH
-0x8DE5	0x698A	#CJK UNIFIED IDEOGRAPH
-0x8DE6	0x80B4	#CJK UNIFIED IDEOGRAPH
-0x8DE7	0x54B2	#CJK UNIFIED IDEOGRAPH
-0x8DE8	0x5D0E	#CJK UNIFIED IDEOGRAPH
-0x8DE9	0x57FC	#CJK UNIFIED IDEOGRAPH
-0x8DEA	0x7895	#CJK UNIFIED IDEOGRAPH
-0x8DEB	0x9DFA	#CJK UNIFIED IDEOGRAPH
-0x8DEC	0x4F5C	#CJK UNIFIED IDEOGRAPH
-0x8DED	0x524A	#CJK UNIFIED IDEOGRAPH
-0x8DEE	0x548B	#CJK UNIFIED IDEOGRAPH
-0x8DEF	0x643E	#CJK UNIFIED IDEOGRAPH
-0x8DF0	0x6628	#CJK UNIFIED IDEOGRAPH
-0x8DF1	0x6714	#CJK UNIFIED IDEOGRAPH
-0x8DF2	0x67F5	#CJK UNIFIED IDEOGRAPH
-0x8DF3	0x7A84	#CJK UNIFIED IDEOGRAPH
-0x8DF4	0x7B56	#CJK UNIFIED IDEOGRAPH
-0x8DF5	0x7D22	#CJK UNIFIED IDEOGRAPH
-0x8DF6	0x932F	#CJK UNIFIED IDEOGRAPH
-0x8DF7	0x685C	#CJK UNIFIED IDEOGRAPH
-0x8DF8	0x9BAD	#CJK UNIFIED IDEOGRAPH
-0x8DF9	0x7B39	#CJK UNIFIED IDEOGRAPH
-0x8DFA	0x5319	#CJK UNIFIED IDEOGRAPH
-0x8DFB	0x518A	#CJK UNIFIED IDEOGRAPH
-0x8DFC	0x5237	#CJK UNIFIED IDEOGRAPH
-0x8E40	0x5BDF	#CJK UNIFIED IDEOGRAPH
-0x8E41	0x62F6	#CJK UNIFIED IDEOGRAPH
-0x8E42	0x64AE	#CJK UNIFIED IDEOGRAPH
-0x8E43	0x64E6	#CJK UNIFIED IDEOGRAPH
-0x8E44	0x672D	#CJK UNIFIED IDEOGRAPH
-0x8E45	0x6BBA	#CJK UNIFIED IDEOGRAPH
-0x8E46	0x85A9	#CJK UNIFIED IDEOGRAPH
-0x8E47	0x96D1	#CJK UNIFIED IDEOGRAPH
-0x8E48	0x7690	#CJK UNIFIED IDEOGRAPH
-0x8E49	0x9BD6	#CJK UNIFIED IDEOGRAPH
-0x8E4A	0x634C	#CJK UNIFIED IDEOGRAPH
-0x8E4B	0x9306	#CJK UNIFIED IDEOGRAPH
-0x8E4C	0x9BAB	#CJK UNIFIED IDEOGRAPH
-0x8E4D	0x76BF	#CJK UNIFIED IDEOGRAPH
-0x8E4E	0x6652	#CJK UNIFIED IDEOGRAPH
-0x8E4F	0x4E09	#CJK UNIFIED IDEOGRAPH
-0x8E50	0x5098	#CJK UNIFIED IDEOGRAPH
-0x8E51	0x53C2	#CJK UNIFIED IDEOGRAPH
-0x8E52	0x5C71	#CJK UNIFIED IDEOGRAPH
-0x8E53	0x60E8	#CJK UNIFIED IDEOGRAPH
-0x8E54	0x6492	#CJK UNIFIED IDEOGRAPH
-0x8E55	0x6563	#CJK UNIFIED IDEOGRAPH
-0x8E56	0x685F	#CJK UNIFIED IDEOGRAPH
-0x8E57	0x71E6	#CJK UNIFIED IDEOGRAPH
-0x8E58	0x73CA	#CJK UNIFIED IDEOGRAPH
-0x8E59	0x7523	#CJK UNIFIED IDEOGRAPH
-0x8E5A	0x7B97	#CJK UNIFIED IDEOGRAPH
-0x8E5B	0x7E82	#CJK UNIFIED IDEOGRAPH
-0x8E5C	0x8695	#CJK UNIFIED IDEOGRAPH
-0x8E5D	0x8B83	#CJK UNIFIED IDEOGRAPH
-0x8E5E	0x8CDB	#CJK UNIFIED IDEOGRAPH
-0x8E5F	0x9178	#CJK UNIFIED IDEOGRAPH
-0x8E60	0x9910	#CJK UNIFIED IDEOGRAPH
-0x8E61	0x65AC	#CJK UNIFIED IDEOGRAPH
-0x8E62	0x66AB	#CJK UNIFIED IDEOGRAPH
-0x8E63	0x6B8B	#CJK UNIFIED IDEOGRAPH
-0x8E64	0x4ED5	#CJK UNIFIED IDEOGRAPH
-0x8E65	0x4ED4	#CJK UNIFIED IDEOGRAPH
-0x8E66	0x4F3A	#CJK UNIFIED IDEOGRAPH
-0x8E67	0x4F7F	#CJK UNIFIED IDEOGRAPH
-0x8E68	0x523A	#CJK UNIFIED IDEOGRAPH
-0x8E69	0x53F8	#CJK UNIFIED IDEOGRAPH
-0x8E6A	0x53F2	#CJK UNIFIED IDEOGRAPH
-0x8E6B	0x55E3	#CJK UNIFIED IDEOGRAPH
-0x8E6C	0x56DB	#CJK UNIFIED IDEOGRAPH
-0x8E6D	0x58EB	#CJK UNIFIED IDEOGRAPH
-0x8E6E	0x59CB	#CJK UNIFIED IDEOGRAPH
-0x8E6F	0x59C9	#CJK UNIFIED IDEOGRAPH
-0x8E70	0x59FF	#CJK UNIFIED IDEOGRAPH
-0x8E71	0x5B50	#CJK UNIFIED IDEOGRAPH
-0x8E72	0x5C4D	#CJK UNIFIED IDEOGRAPH
-0x8E73	0x5E02	#CJK UNIFIED IDEOGRAPH
-0x8E74	0x5E2B	#CJK UNIFIED IDEOGRAPH
-0x8E75	0x5FD7	#CJK UNIFIED IDEOGRAPH
-0x8E76	0x601D	#CJK UNIFIED IDEOGRAPH
-0x8E77	0x6307	#CJK UNIFIED IDEOGRAPH
-0x8E78	0x652F	#CJK UNIFIED IDEOGRAPH
-0x8E79	0x5B5C	#CJK UNIFIED IDEOGRAPH
-0x8E7A	0x65AF	#CJK UNIFIED IDEOGRAPH
-0x8E7B	0x65BD	#CJK UNIFIED IDEOGRAPH
-0x8E7C	0x65E8	#CJK UNIFIED IDEOGRAPH
-0x8E7D	0x679D	#CJK UNIFIED IDEOGRAPH
-0x8E7E	0x6B62	#CJK UNIFIED IDEOGRAPH
-0x8E80	0x6B7B	#CJK UNIFIED IDEOGRAPH
-0x8E81	0x6C0F	#CJK UNIFIED IDEOGRAPH
-0x8E82	0x7345	#CJK UNIFIED IDEOGRAPH
-0x8E83	0x7949	#CJK UNIFIED IDEOGRAPH
-0x8E84	0x79C1	#CJK UNIFIED IDEOGRAPH
-0x8E85	0x7CF8	#CJK UNIFIED IDEOGRAPH
-0x8E86	0x7D19	#CJK UNIFIED IDEOGRAPH
-0x8E87	0x7D2B	#CJK UNIFIED IDEOGRAPH
-0x8E88	0x80A2	#CJK UNIFIED IDEOGRAPH
-0x8E89	0x8102	#CJK UNIFIED IDEOGRAPH
-0x8E8A	0x81F3	#CJK UNIFIED IDEOGRAPH
-0x8E8B	0x8996	#CJK UNIFIED IDEOGRAPH
-0x8E8C	0x8A5E	#CJK UNIFIED IDEOGRAPH
-0x8E8D	0x8A69	#CJK UNIFIED IDEOGRAPH
-0x8E8E	0x8A66	#CJK UNIFIED IDEOGRAPH
-0x8E8F	0x8A8C	#CJK UNIFIED IDEOGRAPH
-0x8E90	0x8AEE	#CJK UNIFIED IDEOGRAPH
-0x8E91	0x8CC7	#CJK UNIFIED IDEOGRAPH
-0x8E92	0x8CDC	#CJK UNIFIED IDEOGRAPH
-0x8E93	0x96CC	#CJK UNIFIED IDEOGRAPH
-0x8E94	0x98FC	#CJK UNIFIED IDEOGRAPH
-0x8E95	0x6B6F	#CJK UNIFIED IDEOGRAPH
-0x8E96	0x4E8B	#CJK UNIFIED IDEOGRAPH
-0x8E97	0x4F3C	#CJK UNIFIED IDEOGRAPH
-0x8E98	0x4F8D	#CJK UNIFIED IDEOGRAPH
-0x8E99	0x5150	#CJK UNIFIED IDEOGRAPH
-0x8E9A	0x5B57	#CJK UNIFIED IDEOGRAPH
-0x8E9B	0x5BFA	#CJK UNIFIED IDEOGRAPH
-0x8E9C	0x6148	#CJK UNIFIED IDEOGRAPH
-0x8E9D	0x6301	#CJK UNIFIED IDEOGRAPH
-0x8E9E	0x6642	#CJK UNIFIED IDEOGRAPH
-0x8E9F	0x6B21	#CJK UNIFIED IDEOGRAPH
-0x8EA0	0x6ECB	#CJK UNIFIED IDEOGRAPH
-0x8EA1	0x6CBB	#CJK UNIFIED IDEOGRAPH
-0x8EA2	0x723E	#CJK UNIFIED IDEOGRAPH
-0x8EA3	0x74BD	#CJK UNIFIED IDEOGRAPH
-0x8EA4	0x75D4	#CJK UNIFIED IDEOGRAPH
-0x8EA5	0x78C1	#CJK UNIFIED IDEOGRAPH
-0x8EA6	0x793A	#CJK UNIFIED IDEOGRAPH
-0x8EA7	0x800C	#CJK UNIFIED IDEOGRAPH
-0x8EA8	0x8033	#CJK UNIFIED IDEOGRAPH
-0x8EA9	0x81EA	#CJK UNIFIED IDEOGRAPH
-0x8EAA	0x8494	#CJK UNIFIED IDEOGRAPH
-0x8EAB	0x8F9E	#CJK UNIFIED IDEOGRAPH
-0x8EAC	0x6C50	#CJK UNIFIED IDEOGRAPH
-0x8EAD	0x9E7F	#CJK UNIFIED IDEOGRAPH
-0x8EAE	0x5F0F	#CJK UNIFIED IDEOGRAPH
-0x8EAF	0x8B58	#CJK UNIFIED IDEOGRAPH
-0x8EB0	0x9D2B	#CJK UNIFIED IDEOGRAPH
-0x8EB1	0x7AFA	#CJK UNIFIED IDEOGRAPH
-0x8EB2	0x8EF8	#CJK UNIFIED IDEOGRAPH
-0x8EB3	0x5B8D	#CJK UNIFIED IDEOGRAPH
-0x8EB4	0x96EB	#CJK UNIFIED IDEOGRAPH
-0x8EB5	0x4E03	#CJK UNIFIED IDEOGRAPH
-0x8EB6	0x53F1	#CJK UNIFIED IDEOGRAPH
-0x8EB7	0x57F7	#CJK UNIFIED IDEOGRAPH
-0x8EB8	0x5931	#CJK UNIFIED IDEOGRAPH
-0x8EB9	0x5AC9	#CJK UNIFIED IDEOGRAPH
-0x8EBA	0x5BA4	#CJK UNIFIED IDEOGRAPH
-0x8EBB	0x6089	#CJK UNIFIED IDEOGRAPH
-0x8EBC	0x6E7F	#CJK UNIFIED IDEOGRAPH
-0x8EBD	0x6F06	#CJK UNIFIED IDEOGRAPH
-0x8EBE	0x75BE	#CJK UNIFIED IDEOGRAPH
-0x8EBF	0x8CEA	#CJK UNIFIED IDEOGRAPH
-0x8EC0	0x5B9F	#CJK UNIFIED IDEOGRAPH
-0x8EC1	0x8500	#CJK UNIFIED IDEOGRAPH
-0x8EC2	0x7BE0	#CJK UNIFIED IDEOGRAPH
-0x8EC3	0x5072	#CJK UNIFIED IDEOGRAPH
-0x8EC4	0x67F4	#CJK UNIFIED IDEOGRAPH
-0x8EC5	0x829D	#CJK UNIFIED IDEOGRAPH
-0x8EC6	0x5C61	#CJK UNIFIED IDEOGRAPH
-0x8EC7	0x854A	#CJK UNIFIED IDEOGRAPH
-0x8EC8	0x7E1E	#CJK UNIFIED IDEOGRAPH
-0x8EC9	0x820E	#CJK UNIFIED IDEOGRAPH
-0x8ECA	0x5199	#CJK UNIFIED IDEOGRAPH
-0x8ECB	0x5C04	#CJK UNIFIED IDEOGRAPH
-0x8ECC	0x6368	#CJK UNIFIED IDEOGRAPH
-0x8ECD	0x8D66	#CJK UNIFIED IDEOGRAPH
-0x8ECE	0x659C	#CJK UNIFIED IDEOGRAPH
-0x8ECF	0x716E	#CJK UNIFIED IDEOGRAPH
-0x8ED0	0x793E	#CJK UNIFIED IDEOGRAPH
-0x8ED1	0x7D17	#CJK UNIFIED IDEOGRAPH
-0x8ED2	0x8005	#CJK UNIFIED IDEOGRAPH
-0x8ED3	0x8B1D	#CJK UNIFIED IDEOGRAPH
-0x8ED4	0x8ECA	#CJK UNIFIED IDEOGRAPH
-0x8ED5	0x906E	#CJK UNIFIED IDEOGRAPH
-0x8ED6	0x86C7	#CJK UNIFIED IDEOGRAPH
-0x8ED7	0x90AA	#CJK UNIFIED IDEOGRAPH
-0x8ED8	0x501F	#CJK UNIFIED IDEOGRAPH
-0x8ED9	0x52FA	#CJK UNIFIED IDEOGRAPH
-0x8EDA	0x5C3A	#CJK UNIFIED IDEOGRAPH
-0x8EDB	0x6753	#CJK UNIFIED IDEOGRAPH
-0x8EDC	0x707C	#CJK UNIFIED IDEOGRAPH
-0x8EDD	0x7235	#CJK UNIFIED IDEOGRAPH
-0x8EDE	0x914C	#CJK UNIFIED IDEOGRAPH
-0x8EDF	0x91C8	#CJK UNIFIED IDEOGRAPH
-0x8EE0	0x932B	#CJK UNIFIED IDEOGRAPH
-0x8EE1	0x82E5	#CJK UNIFIED IDEOGRAPH
-0x8EE2	0x5BC2	#CJK UNIFIED IDEOGRAPH
-0x8EE3	0x5F31	#CJK UNIFIED IDEOGRAPH
-0x8EE4	0x60F9	#CJK UNIFIED IDEOGRAPH
-0x8EE5	0x4E3B	#CJK UNIFIED IDEOGRAPH
-0x8EE6	0x53D6	#CJK UNIFIED IDEOGRAPH
-0x8EE7	0x5B88	#CJK UNIFIED IDEOGRAPH
-0x8EE8	0x624B	#CJK UNIFIED IDEOGRAPH
-0x8EE9	0x6731	#CJK UNIFIED IDEOGRAPH
-0x8EEA	0x6B8A	#CJK UNIFIED IDEOGRAPH
-0x8EEB	0x72E9	#CJK UNIFIED IDEOGRAPH
-0x8EEC	0x73E0	#CJK UNIFIED IDEOGRAPH
-0x8EED	0x7A2E	#CJK UNIFIED IDEOGRAPH
-0x8EEE	0x816B	#CJK UNIFIED IDEOGRAPH
-0x8EEF	0x8DA3	#CJK UNIFIED IDEOGRAPH
-0x8EF0	0x9152	#CJK UNIFIED IDEOGRAPH
-0x8EF1	0x9996	#CJK UNIFIED IDEOGRAPH
-0x8EF2	0x5112	#CJK UNIFIED IDEOGRAPH
-0x8EF3	0x53D7	#CJK UNIFIED IDEOGRAPH
-0x8EF4	0x546A	#CJK UNIFIED IDEOGRAPH
-0x8EF5	0x5BFF	#CJK UNIFIED IDEOGRAPH
-0x8EF6	0x6388	#CJK UNIFIED IDEOGRAPH
-0x8EF7	0x6A39	#CJK UNIFIED IDEOGRAPH
-0x8EF8	0x7DAC	#CJK UNIFIED IDEOGRAPH
-0x8EF9	0x9700	#CJK UNIFIED IDEOGRAPH
-0x8EFA	0x56DA	#CJK UNIFIED IDEOGRAPH
-0x8EFB	0x53CE	#CJK UNIFIED IDEOGRAPH
-0x8EFC	0x5468	#CJK UNIFIED IDEOGRAPH
-0x8F40	0x5B97	#CJK UNIFIED IDEOGRAPH
-0x8F41	0x5C31	#CJK UNIFIED IDEOGRAPH
-0x8F42	0x5DDE	#CJK UNIFIED IDEOGRAPH
-0x8F43	0x4FEE	#CJK UNIFIED IDEOGRAPH
-0x8F44	0x6101	#CJK UNIFIED IDEOGRAPH
-0x8F45	0x62FE	#CJK UNIFIED IDEOGRAPH
-0x8F46	0x6D32	#CJK UNIFIED IDEOGRAPH
-0x8F47	0x79C0	#CJK UNIFIED IDEOGRAPH
-0x8F48	0x79CB	#CJK UNIFIED IDEOGRAPH
-0x8F49	0x7D42	#CJK UNIFIED IDEOGRAPH
-0x8F4A	0x7E4D	#CJK UNIFIED IDEOGRAPH
-0x8F4B	0x7FD2	#CJK UNIFIED IDEOGRAPH
-0x8F4C	0x81ED	#CJK UNIFIED IDEOGRAPH
-0x8F4D	0x821F	#CJK UNIFIED IDEOGRAPH
-0x8F4E	0x8490	#CJK UNIFIED IDEOGRAPH
-0x8F4F	0x8846	#CJK UNIFIED IDEOGRAPH
-0x8F50	0x8972	#CJK UNIFIED IDEOGRAPH
-0x8F51	0x8B90	#CJK UNIFIED IDEOGRAPH
-0x8F52	0x8E74	#CJK UNIFIED IDEOGRAPH
-0x8F53	0x8F2F	#CJK UNIFIED IDEOGRAPH
-0x8F54	0x9031	#CJK UNIFIED IDEOGRAPH
-0x8F55	0x914B	#CJK UNIFIED IDEOGRAPH
-0x8F56	0x916C	#CJK UNIFIED IDEOGRAPH
-0x8F57	0x96C6	#CJK UNIFIED IDEOGRAPH
-0x8F58	0x919C	#CJK UNIFIED IDEOGRAPH
-0x8F59	0x4EC0	#CJK UNIFIED IDEOGRAPH
-0x8F5A	0x4F4F	#CJK UNIFIED IDEOGRAPH
-0x8F5B	0x5145	#CJK UNIFIED IDEOGRAPH
-0x8F5C	0x5341	#CJK UNIFIED IDEOGRAPH
-0x8F5D	0x5F93	#CJK UNIFIED IDEOGRAPH
-0x8F5E	0x620E	#CJK UNIFIED IDEOGRAPH
-0x8F5F	0x67D4	#CJK UNIFIED IDEOGRAPH
-0x8F60	0x6C41	#CJK UNIFIED IDEOGRAPH
-0x8F61	0x6E0B	#CJK UNIFIED IDEOGRAPH
-0x8F62	0x7363	#CJK UNIFIED IDEOGRAPH
-0x8F63	0x7E26	#CJK UNIFIED IDEOGRAPH
-0x8F64	0x91CD	#CJK UNIFIED IDEOGRAPH
-0x8F65	0x9283	#CJK UNIFIED IDEOGRAPH
-0x8F66	0x53D4	#CJK UNIFIED IDEOGRAPH
-0x8F67	0x5919	#CJK UNIFIED IDEOGRAPH
-0x8F68	0x5BBF	#CJK UNIFIED IDEOGRAPH
-0x8F69	0x6DD1	#CJK UNIFIED IDEOGRAPH
-0x8F6A	0x795D	#CJK UNIFIED IDEOGRAPH
-0x8F6B	0x7E2E	#CJK UNIFIED IDEOGRAPH
-0x8F6C	0x7C9B	#CJK UNIFIED IDEOGRAPH
-0x8F6D	0x587E	#CJK UNIFIED IDEOGRAPH
-0x8F6E	0x719F	#CJK UNIFIED IDEOGRAPH
-0x8F6F	0x51FA	#CJK UNIFIED IDEOGRAPH
-0x8F70	0x8853	#CJK UNIFIED IDEOGRAPH
-0x8F71	0x8FF0	#CJK UNIFIED IDEOGRAPH
-0x8F72	0x4FCA	#CJK UNIFIED IDEOGRAPH
-0x8F73	0x5CFB	#CJK UNIFIED IDEOGRAPH
-0x8F74	0x6625	#CJK UNIFIED IDEOGRAPH
-0x8F75	0x77AC	#CJK UNIFIED IDEOGRAPH
-0x8F76	0x7AE3	#CJK UNIFIED IDEOGRAPH
-0x8F77	0x821C	#CJK UNIFIED IDEOGRAPH
-0x8F78	0x99FF	#CJK UNIFIED IDEOGRAPH
-0x8F79	0x51C6	#CJK UNIFIED IDEOGRAPH
-0x8F7A	0x5FAA	#CJK UNIFIED IDEOGRAPH
-0x8F7B	0x65EC	#CJK UNIFIED IDEOGRAPH
-0x8F7C	0x696F	#CJK UNIFIED IDEOGRAPH
-0x8F7D	0x6B89	#CJK UNIFIED IDEOGRAPH
-0x8F7E	0x6DF3	#CJK UNIFIED IDEOGRAPH
-0x8F80	0x6E96	#CJK UNIFIED IDEOGRAPH
-0x8F81	0x6F64	#CJK UNIFIED IDEOGRAPH
-0x8F82	0x76FE	#CJK UNIFIED IDEOGRAPH
-0x8F83	0x7D14	#CJK UNIFIED IDEOGRAPH
-0x8F84	0x5DE1	#CJK UNIFIED IDEOGRAPH
-0x8F85	0x9075	#CJK UNIFIED IDEOGRAPH
-0x8F86	0x9187	#CJK UNIFIED IDEOGRAPH
-0x8F87	0x9806	#CJK UNIFIED IDEOGRAPH
-0x8F88	0x51E6	#CJK UNIFIED IDEOGRAPH
-0x8F89	0x521D	#CJK UNIFIED IDEOGRAPH
-0x8F8A	0x6240	#CJK UNIFIED IDEOGRAPH
-0x8F8B	0x6691	#CJK UNIFIED IDEOGRAPH
-0x8F8C	0x66D9	#CJK UNIFIED IDEOGRAPH
-0x8F8D	0x6E1A	#CJK UNIFIED IDEOGRAPH
-0x8F8E	0x5EB6	#CJK UNIFIED IDEOGRAPH
-0x8F8F	0x7DD2	#CJK UNIFIED IDEOGRAPH
-0x8F90	0x7F72	#CJK UNIFIED IDEOGRAPH
-0x8F91	0x66F8	#CJK UNIFIED IDEOGRAPH
-0x8F92	0x85AF	#CJK UNIFIED IDEOGRAPH
-0x8F93	0x85F7	#CJK UNIFIED IDEOGRAPH
-0x8F94	0x8AF8	#CJK UNIFIED IDEOGRAPH
-0x8F95	0x52A9	#CJK UNIFIED IDEOGRAPH
-0x8F96	0x53D9	#CJK UNIFIED IDEOGRAPH
-0x8F97	0x5973	#CJK UNIFIED IDEOGRAPH
-0x8F98	0x5E8F	#CJK UNIFIED IDEOGRAPH
-0x8F99	0x5F90	#CJK UNIFIED IDEOGRAPH
-0x8F9A	0x6055	#CJK UNIFIED IDEOGRAPH
-0x8F9B	0x92E4	#CJK UNIFIED IDEOGRAPH
-0x8F9C	0x9664	#CJK UNIFIED IDEOGRAPH
-0x8F9D	0x50B7	#CJK UNIFIED IDEOGRAPH
-0x8F9E	0x511F	#CJK UNIFIED IDEOGRAPH
-0x8F9F	0x52DD	#CJK UNIFIED IDEOGRAPH
-0x8FA0	0x5320	#CJK UNIFIED IDEOGRAPH
-0x8FA1	0x5347	#CJK UNIFIED IDEOGRAPH
-0x8FA2	0x53EC	#CJK UNIFIED IDEOGRAPH
-0x8FA3	0x54E8	#CJK UNIFIED IDEOGRAPH
-0x8FA4	0x5546	#CJK UNIFIED IDEOGRAPH
-0x8FA5	0x5531	#CJK UNIFIED IDEOGRAPH
-0x8FA6	0x5617	#CJK UNIFIED IDEOGRAPH
-0x8FA7	0x5968	#CJK UNIFIED IDEOGRAPH
-0x8FA8	0x59BE	#CJK UNIFIED IDEOGRAPH
-0x8FA9	0x5A3C	#CJK UNIFIED IDEOGRAPH
-0x8FAA	0x5BB5	#CJK UNIFIED IDEOGRAPH
-0x8FAB	0x5C06	#CJK UNIFIED IDEOGRAPH
-0x8FAC	0x5C0F	#CJK UNIFIED IDEOGRAPH
-0x8FAD	0x5C11	#CJK UNIFIED IDEOGRAPH
-0x8FAE	0x5C1A	#CJK UNIFIED IDEOGRAPH
-0x8FAF	0x5E84	#CJK UNIFIED IDEOGRAPH
-0x8FB0	0x5E8A	#CJK UNIFIED IDEOGRAPH
-0x8FB1	0x5EE0	#CJK UNIFIED IDEOGRAPH
-0x8FB2	0x5F70	#CJK UNIFIED IDEOGRAPH
-0x8FB3	0x627F	#CJK UNIFIED IDEOGRAPH
-0x8FB4	0x6284	#CJK UNIFIED IDEOGRAPH
-0x8FB5	0x62DB	#CJK UNIFIED IDEOGRAPH
-0x8FB6	0x638C	#CJK UNIFIED IDEOGRAPH
-0x8FB7	0x6377	#CJK UNIFIED IDEOGRAPH
-0x8FB8	0x6607	#CJK UNIFIED IDEOGRAPH
-0x8FB9	0x660C	#CJK UNIFIED IDEOGRAPH
-0x8FBA	0x662D	#CJK UNIFIED IDEOGRAPH
-0x8FBB	0x6676	#CJK UNIFIED IDEOGRAPH
-0x8FBC	0x677E	#CJK UNIFIED IDEOGRAPH
-0x8FBD	0x68A2	#CJK UNIFIED IDEOGRAPH
-0x8FBE	0x6A1F	#CJK UNIFIED IDEOGRAPH
-0x8FBF	0x6A35	#CJK UNIFIED IDEOGRAPH
-0x8FC0	0x6CBC	#CJK UNIFIED IDEOGRAPH
-0x8FC1	0x6D88	#CJK UNIFIED IDEOGRAPH
-0x8FC2	0x6E09	#CJK UNIFIED IDEOGRAPH
-0x8FC3	0x6E58	#CJK UNIFIED IDEOGRAPH
-0x8FC4	0x713C	#CJK UNIFIED IDEOGRAPH
-0x8FC5	0x7126	#CJK UNIFIED IDEOGRAPH
-0x8FC6	0x7167	#CJK UNIFIED IDEOGRAPH
-0x8FC7	0x75C7	#CJK UNIFIED IDEOGRAPH
-0x8FC8	0x7701	#CJK UNIFIED IDEOGRAPH
-0x8FC9	0x785D	#CJK UNIFIED IDEOGRAPH
-0x8FCA	0x7901	#CJK UNIFIED IDEOGRAPH
-0x8FCB	0x7965	#CJK UNIFIED IDEOGRAPH
-0x8FCC	0x79F0	#CJK UNIFIED IDEOGRAPH
-0x8FCD	0x7AE0	#CJK UNIFIED IDEOGRAPH
-0x8FCE	0x7B11	#CJK UNIFIED IDEOGRAPH
-0x8FCF	0x7CA7	#CJK UNIFIED IDEOGRAPH
-0x8FD0	0x7D39	#CJK UNIFIED IDEOGRAPH
-0x8FD1	0x8096	#CJK UNIFIED IDEOGRAPH
-0x8FD2	0x83D6	#CJK UNIFIED IDEOGRAPH
-0x8FD3	0x848B	#CJK UNIFIED IDEOGRAPH
-0x8FD4	0x8549	#CJK UNIFIED IDEOGRAPH
-0x8FD5	0x885D	#CJK UNIFIED IDEOGRAPH
-0x8FD6	0x88F3	#CJK UNIFIED IDEOGRAPH
-0x8FD7	0x8A1F	#CJK UNIFIED IDEOGRAPH
-0x8FD8	0x8A3C	#CJK UNIFIED IDEOGRAPH
-0x8FD9	0x8A54	#CJK UNIFIED IDEOGRAPH
-0x8FDA	0x8A73	#CJK UNIFIED IDEOGRAPH
-0x8FDB	0x8C61	#CJK UNIFIED IDEOGRAPH
-0x8FDC	0x8CDE	#CJK UNIFIED IDEOGRAPH
-0x8FDD	0x91A4	#CJK UNIFIED IDEOGRAPH
-0x8FDE	0x9266	#CJK UNIFIED IDEOGRAPH
-0x8FDF	0x937E	#CJK UNIFIED IDEOGRAPH
-0x8FE0	0x9418	#CJK UNIFIED IDEOGRAPH
-0x8FE1	0x969C	#CJK UNIFIED IDEOGRAPH
-0x8FE2	0x9798	#CJK UNIFIED IDEOGRAPH
-0x8FE3	0x4E0A	#CJK UNIFIED IDEOGRAPH
-0x8FE4	0x4E08	#CJK UNIFIED IDEOGRAPH
-0x8FE5	0x4E1E	#CJK UNIFIED IDEOGRAPH
-0x8FE6	0x4E57	#CJK UNIFIED IDEOGRAPH
-0x8FE7	0x5197	#CJK UNIFIED IDEOGRAPH
-0x8FE8	0x5270	#CJK UNIFIED IDEOGRAPH
-0x8FE9	0x57CE	#CJK UNIFIED IDEOGRAPH
-0x8FEA	0x5834	#CJK UNIFIED IDEOGRAPH
-0x8FEB	0x58CC	#CJK UNIFIED IDEOGRAPH
-0x8FEC	0x5B22	#CJK UNIFIED IDEOGRAPH
-0x8FED	0x5E38	#CJK UNIFIED IDEOGRAPH
-0x8FEE	0x60C5	#CJK UNIFIED IDEOGRAPH
-0x8FEF	0x64FE	#CJK UNIFIED IDEOGRAPH
-0x8FF0	0x6761	#CJK UNIFIED IDEOGRAPH
-0x8FF1	0x6756	#CJK UNIFIED IDEOGRAPH
-0x8FF2	0x6D44	#CJK UNIFIED IDEOGRAPH
-0x8FF3	0x72B6	#CJK UNIFIED IDEOGRAPH
-0x8FF4	0x7573	#CJK UNIFIED IDEOGRAPH
-0x8FF5	0x7A63	#CJK UNIFIED IDEOGRAPH
-0x8FF6	0x84B8	#CJK UNIFIED IDEOGRAPH
-0x8FF7	0x8B72	#CJK UNIFIED IDEOGRAPH
-0x8FF8	0x91B8	#CJK UNIFIED IDEOGRAPH
-0x8FF9	0x9320	#CJK UNIFIED IDEOGRAPH
-0x8FFA	0x5631	#CJK UNIFIED IDEOGRAPH
-0x8FFB	0x57F4	#CJK UNIFIED IDEOGRAPH
-0x8FFC	0x98FE	#CJK UNIFIED IDEOGRAPH
-0x9040	0x62ED	#CJK UNIFIED IDEOGRAPH
-0x9041	0x690D	#CJK UNIFIED IDEOGRAPH
-0x9042	0x6B96	#CJK UNIFIED IDEOGRAPH
-0x9043	0x71ED	#CJK UNIFIED IDEOGRAPH
-0x9044	0x7E54	#CJK UNIFIED IDEOGRAPH
-0x9045	0x8077	#CJK UNIFIED IDEOGRAPH
-0x9046	0x8272	#CJK UNIFIED IDEOGRAPH
-0x9047	0x89E6	#CJK UNIFIED IDEOGRAPH
-0x9048	0x98DF	#CJK UNIFIED IDEOGRAPH
-0x9049	0x8755	#CJK UNIFIED IDEOGRAPH
-0x904A	0x8FB1	#CJK UNIFIED IDEOGRAPH
-0x904B	0x5C3B	#CJK UNIFIED IDEOGRAPH
-0x904C	0x4F38	#CJK UNIFIED IDEOGRAPH
-0x904D	0x4FE1	#CJK UNIFIED IDEOGRAPH
-0x904E	0x4FB5	#CJK UNIFIED IDEOGRAPH
-0x904F	0x5507	#CJK UNIFIED IDEOGRAPH
-0x9050	0x5A20	#CJK UNIFIED IDEOGRAPH
-0x9051	0x5BDD	#CJK UNIFIED IDEOGRAPH
-0x9052	0x5BE9	#CJK UNIFIED IDEOGRAPH
-0x9053	0x5FC3	#CJK UNIFIED IDEOGRAPH
-0x9054	0x614E	#CJK UNIFIED IDEOGRAPH
-0x9055	0x632F	#CJK UNIFIED IDEOGRAPH
-0x9056	0x65B0	#CJK UNIFIED IDEOGRAPH
-0x9057	0x664B	#CJK UNIFIED IDEOGRAPH
-0x9058	0x68EE	#CJK UNIFIED IDEOGRAPH
-0x9059	0x699B	#CJK UNIFIED IDEOGRAPH
-0x905A	0x6D78	#CJK UNIFIED IDEOGRAPH
-0x905B	0x6DF1	#CJK UNIFIED IDEOGRAPH
-0x905C	0x7533	#CJK UNIFIED IDEOGRAPH
-0x905D	0x75B9	#CJK UNIFIED IDEOGRAPH
-0x905E	0x771F	#CJK UNIFIED IDEOGRAPH
-0x905F	0x795E	#CJK UNIFIED IDEOGRAPH
-0x9060	0x79E6	#CJK UNIFIED IDEOGRAPH
-0x9061	0x7D33	#CJK UNIFIED IDEOGRAPH
-0x9062	0x81E3	#CJK UNIFIED IDEOGRAPH
-0x9063	0x82AF	#CJK UNIFIED IDEOGRAPH
-0x9064	0x85AA	#CJK UNIFIED IDEOGRAPH
-0x9065	0x89AA	#CJK UNIFIED IDEOGRAPH
-0x9066	0x8A3A	#CJK UNIFIED IDEOGRAPH
-0x9067	0x8EAB	#CJK UNIFIED IDEOGRAPH
-0x9068	0x8F9B	#CJK UNIFIED IDEOGRAPH
-0x9069	0x9032	#CJK UNIFIED IDEOGRAPH
-0x906A	0x91DD	#CJK UNIFIED IDEOGRAPH
-0x906B	0x9707	#CJK UNIFIED IDEOGRAPH
-0x906C	0x4EBA	#CJK UNIFIED IDEOGRAPH
-0x906D	0x4EC1	#CJK UNIFIED IDEOGRAPH
-0x906E	0x5203	#CJK UNIFIED IDEOGRAPH
-0x906F	0x5875	#CJK UNIFIED IDEOGRAPH
-0x9070	0x58EC	#CJK UNIFIED IDEOGRAPH
-0x9071	0x5C0B	#CJK UNIFIED IDEOGRAPH
-0x9072	0x751A	#CJK UNIFIED IDEOGRAPH
-0x9073	0x5C3D	#CJK UNIFIED IDEOGRAPH
-0x9074	0x814E	#CJK UNIFIED IDEOGRAPH
-0x9075	0x8A0A	#CJK UNIFIED IDEOGRAPH
-0x9076	0x8FC5	#CJK UNIFIED IDEOGRAPH
-0x9077	0x9663	#CJK UNIFIED IDEOGRAPH
-0x9078	0x976D	#CJK UNIFIED IDEOGRAPH
-0x9079	0x7B25	#CJK UNIFIED IDEOGRAPH
-0x907A	0x8ACF	#CJK UNIFIED IDEOGRAPH
-0x907B	0x9808	#CJK UNIFIED IDEOGRAPH
-0x907C	0x9162	#CJK UNIFIED IDEOGRAPH
-0x907D	0x56F3	#CJK UNIFIED IDEOGRAPH
-0x907E	0x53A8	#CJK UNIFIED IDEOGRAPH
-0x9080	0x9017	#CJK UNIFIED IDEOGRAPH
-0x9081	0x5439	#CJK UNIFIED IDEOGRAPH
-0x9082	0x5782	#CJK UNIFIED IDEOGRAPH
-0x9083	0x5E25	#CJK UNIFIED IDEOGRAPH
-0x9084	0x63A8	#CJK UNIFIED IDEOGRAPH
-0x9085	0x6C34	#CJK UNIFIED IDEOGRAPH
-0x9086	0x708A	#CJK UNIFIED IDEOGRAPH
-0x9087	0x7761	#CJK UNIFIED IDEOGRAPH
-0x9088	0x7C8B	#CJK UNIFIED IDEOGRAPH
-0x9089	0x7FE0	#CJK UNIFIED IDEOGRAPH
-0x908A	0x8870	#CJK UNIFIED IDEOGRAPH
-0x908B	0x9042	#CJK UNIFIED IDEOGRAPH
-0x908C	0x9154	#CJK UNIFIED IDEOGRAPH
-0x908D	0x9310	#CJK UNIFIED IDEOGRAPH
-0x908E	0x9318	#CJK UNIFIED IDEOGRAPH
-0x908F	0x968F	#CJK UNIFIED IDEOGRAPH
-0x9090	0x745E	#CJK UNIFIED IDEOGRAPH
-0x9091	0x9AC4	#CJK UNIFIED IDEOGRAPH
-0x9092	0x5D07	#CJK UNIFIED IDEOGRAPH
-0x9093	0x5D69	#CJK UNIFIED IDEOGRAPH
-0x9094	0x6570	#CJK UNIFIED IDEOGRAPH
-0x9095	0x67A2	#CJK UNIFIED IDEOGRAPH
-0x9096	0x8DA8	#CJK UNIFIED IDEOGRAPH
-0x9097	0x96DB	#CJK UNIFIED IDEOGRAPH
-0x9098	0x636E	#CJK UNIFIED IDEOGRAPH
-0x9099	0x6749	#CJK UNIFIED IDEOGRAPH
-0x909A	0x6919	#CJK UNIFIED IDEOGRAPH
-0x909B	0x83C5	#CJK UNIFIED IDEOGRAPH
-0x909C	0x9817	#CJK UNIFIED IDEOGRAPH
-0x909D	0x96C0	#CJK UNIFIED IDEOGRAPH
-0x909E	0x88FE	#CJK UNIFIED IDEOGRAPH
-0x909F	0x6F84	#CJK UNIFIED IDEOGRAPH
-0x90A0	0x647A	#CJK UNIFIED IDEOGRAPH
-0x90A1	0x5BF8	#CJK UNIFIED IDEOGRAPH
-0x90A2	0x4E16	#CJK UNIFIED IDEOGRAPH
-0x90A3	0x702C	#CJK UNIFIED IDEOGRAPH
-0x90A4	0x755D	#CJK UNIFIED IDEOGRAPH
-0x90A5	0x662F	#CJK UNIFIED IDEOGRAPH
-0x90A6	0x51C4	#CJK UNIFIED IDEOGRAPH
-0x90A7	0x5236	#CJK UNIFIED IDEOGRAPH
-0x90A8	0x52E2	#CJK UNIFIED IDEOGRAPH
-0x90A9	0x59D3	#CJK UNIFIED IDEOGRAPH
-0x90AA	0x5F81	#CJK UNIFIED IDEOGRAPH
-0x90AB	0x6027	#CJK UNIFIED IDEOGRAPH
-0x90AC	0x6210	#CJK UNIFIED IDEOGRAPH
-0x90AD	0x653F	#CJK UNIFIED IDEOGRAPH
-0x90AE	0x6574	#CJK UNIFIED IDEOGRAPH
-0x90AF	0x661F	#CJK UNIFIED IDEOGRAPH
-0x90B0	0x6674	#CJK UNIFIED IDEOGRAPH
-0x90B1	0x68F2	#CJK UNIFIED IDEOGRAPH
-0x90B2	0x6816	#CJK UNIFIED IDEOGRAPH
-0x90B3	0x6B63	#CJK UNIFIED IDEOGRAPH
-0x90B4	0x6E05	#CJK UNIFIED IDEOGRAPH
-0x90B5	0x7272	#CJK UNIFIED IDEOGRAPH
-0x90B6	0x751F	#CJK UNIFIED IDEOGRAPH
-0x90B7	0x76DB	#CJK UNIFIED IDEOGRAPH
-0x90B8	0x7CBE	#CJK UNIFIED IDEOGRAPH
-0x90B9	0x8056	#CJK UNIFIED IDEOGRAPH
-0x90BA	0x58F0	#CJK UNIFIED IDEOGRAPH
-0x90BB	0x88FD	#CJK UNIFIED IDEOGRAPH
-0x90BC	0x897F	#CJK UNIFIED IDEOGRAPH
-0x90BD	0x8AA0	#CJK UNIFIED IDEOGRAPH
-0x90BE	0x8A93	#CJK UNIFIED IDEOGRAPH
-0x90BF	0x8ACB	#CJK UNIFIED IDEOGRAPH
-0x90C0	0x901D	#CJK UNIFIED IDEOGRAPH
-0x90C1	0x9192	#CJK UNIFIED IDEOGRAPH
-0x90C2	0x9752	#CJK UNIFIED IDEOGRAPH
-0x90C3	0x9759	#CJK UNIFIED IDEOGRAPH
-0x90C4	0x6589	#CJK UNIFIED IDEOGRAPH
-0x90C5	0x7A0E	#CJK UNIFIED IDEOGRAPH
-0x90C6	0x8106	#CJK UNIFIED IDEOGRAPH
-0x90C7	0x96BB	#CJK UNIFIED IDEOGRAPH
-0x90C8	0x5E2D	#CJK UNIFIED IDEOGRAPH
-0x90C9	0x60DC	#CJK UNIFIED IDEOGRAPH
-0x90CA	0x621A	#CJK UNIFIED IDEOGRAPH
-0x90CB	0x65A5	#CJK UNIFIED IDEOGRAPH
-0x90CC	0x6614	#CJK UNIFIED IDEOGRAPH
-0x90CD	0x6790	#CJK UNIFIED IDEOGRAPH
-0x90CE	0x77F3	#CJK UNIFIED IDEOGRAPH
-0x90CF	0x7A4D	#CJK UNIFIED IDEOGRAPH
-0x90D0	0x7C4D	#CJK UNIFIED IDEOGRAPH
-0x90D1	0x7E3E	#CJK UNIFIED IDEOGRAPH
-0x90D2	0x810A	#CJK UNIFIED IDEOGRAPH
-0x90D3	0x8CAC	#CJK UNIFIED IDEOGRAPH
-0x90D4	0x8D64	#CJK UNIFIED IDEOGRAPH
-0x90D5	0x8DE1	#CJK UNIFIED IDEOGRAPH
-0x90D6	0x8E5F	#CJK UNIFIED IDEOGRAPH
-0x90D7	0x78A9	#CJK UNIFIED IDEOGRAPH
-0x90D8	0x5207	#CJK UNIFIED IDEOGRAPH
-0x90D9	0x62D9	#CJK UNIFIED IDEOGRAPH
-0x90DA	0x63A5	#CJK UNIFIED IDEOGRAPH
-0x90DB	0x6442	#CJK UNIFIED IDEOGRAPH
-0x90DC	0x6298	#CJK UNIFIED IDEOGRAPH
-0x90DD	0x8A2D	#CJK UNIFIED IDEOGRAPH
-0x90DE	0x7A83	#CJK UNIFIED IDEOGRAPH
-0x90DF	0x7BC0	#CJK UNIFIED IDEOGRAPH
-0x90E0	0x8AAC	#CJK UNIFIED IDEOGRAPH
-0x90E1	0x96EA	#CJK UNIFIED IDEOGRAPH
-0x90E2	0x7D76	#CJK UNIFIED IDEOGRAPH
-0x90E3	0x820C	#CJK UNIFIED IDEOGRAPH
-0x90E4	0x8749	#CJK UNIFIED IDEOGRAPH
-0x90E5	0x4ED9	#CJK UNIFIED IDEOGRAPH
-0x90E6	0x5148	#CJK UNIFIED IDEOGRAPH
-0x90E7	0x5343	#CJK UNIFIED IDEOGRAPH
-0x90E8	0x5360	#CJK UNIFIED IDEOGRAPH
-0x90E9	0x5BA3	#CJK UNIFIED IDEOGRAPH
-0x90EA	0x5C02	#CJK UNIFIED IDEOGRAPH
-0x90EB	0x5C16	#CJK UNIFIED IDEOGRAPH
-0x90EC	0x5DDD	#CJK UNIFIED IDEOGRAPH
-0x90ED	0x6226	#CJK UNIFIED IDEOGRAPH
-0x90EE	0x6247	#CJK UNIFIED IDEOGRAPH
-0x90EF	0x64B0	#CJK UNIFIED IDEOGRAPH
-0x90F0	0x6813	#CJK UNIFIED IDEOGRAPH
-0x90F1	0x6834	#CJK UNIFIED IDEOGRAPH
-0x90F2	0x6CC9	#CJK UNIFIED IDEOGRAPH
-0x90F3	0x6D45	#CJK UNIFIED IDEOGRAPH
-0x90F4	0x6D17	#CJK UNIFIED IDEOGRAPH
-0x90F5	0x67D3	#CJK UNIFIED IDEOGRAPH
-0x90F6	0x6F5C	#CJK UNIFIED IDEOGRAPH
-0x90F7	0x714E	#CJK UNIFIED IDEOGRAPH
-0x90F8	0x717D	#CJK UNIFIED IDEOGRAPH
-0x90F9	0x65CB	#CJK UNIFIED IDEOGRAPH
-0x90FA	0x7A7F	#CJK UNIFIED IDEOGRAPH
-0x90FB	0x7BAD	#CJK UNIFIED IDEOGRAPH
-0x90FC	0x7DDA	#CJK UNIFIED IDEOGRAPH
-0x9140	0x7E4A	#CJK UNIFIED IDEOGRAPH
-0x9141	0x7FA8	#CJK UNIFIED IDEOGRAPH
-0x9142	0x817A	#CJK UNIFIED IDEOGRAPH
-0x9143	0x821B	#CJK UNIFIED IDEOGRAPH
-0x9144	0x8239	#CJK UNIFIED IDEOGRAPH
-0x9145	0x85A6	#CJK UNIFIED IDEOGRAPH
-0x9146	0x8A6E	#CJK UNIFIED IDEOGRAPH
-0x9147	0x8CCE	#CJK UNIFIED IDEOGRAPH
-0x9148	0x8DF5	#CJK UNIFIED IDEOGRAPH
-0x9149	0x9078	#CJK UNIFIED IDEOGRAPH
-0x914A	0x9077	#CJK UNIFIED IDEOGRAPH
-0x914B	0x92AD	#CJK UNIFIED IDEOGRAPH
-0x914C	0x9291	#CJK UNIFIED IDEOGRAPH
-0x914D	0x9583	#CJK UNIFIED IDEOGRAPH
-0x914E	0x9BAE	#CJK UNIFIED IDEOGRAPH
-0x914F	0x524D	#CJK UNIFIED IDEOGRAPH
-0x9150	0x5584	#CJK UNIFIED IDEOGRAPH
-0x9151	0x6F38	#CJK UNIFIED IDEOGRAPH
-0x9152	0x7136	#CJK UNIFIED IDEOGRAPH
-0x9153	0x5168	#CJK UNIFIED IDEOGRAPH
-0x9154	0x7985	#CJK UNIFIED IDEOGRAPH
-0x9155	0x7E55	#CJK UNIFIED IDEOGRAPH
-0x9156	0x81B3	#CJK UNIFIED IDEOGRAPH
-0x9157	0x7CCE	#CJK UNIFIED IDEOGRAPH
-0x9158	0x564C	#CJK UNIFIED IDEOGRAPH
-0x9159	0x5851	#CJK UNIFIED IDEOGRAPH
-0x915A	0x5CA8	#CJK UNIFIED IDEOGRAPH
-0x915B	0x63AA	#CJK UNIFIED IDEOGRAPH
-0x915C	0x66FE	#CJK UNIFIED IDEOGRAPH
-0x915D	0x66FD	#CJK UNIFIED IDEOGRAPH
-0x915E	0x695A	#CJK UNIFIED IDEOGRAPH
-0x915F	0x72D9	#CJK UNIFIED IDEOGRAPH
-0x9160	0x758F	#CJK UNIFIED IDEOGRAPH
-0x9161	0x758E	#CJK UNIFIED IDEOGRAPH
-0x9162	0x790E	#CJK UNIFIED IDEOGRAPH
-0x9163	0x7956	#CJK UNIFIED IDEOGRAPH
-0x9164	0x79DF	#CJK UNIFIED IDEOGRAPH
-0x9165	0x7C97	#CJK UNIFIED IDEOGRAPH
-0x9166	0x7D20	#CJK UNIFIED IDEOGRAPH
-0x9167	0x7D44	#CJK UNIFIED IDEOGRAPH
-0x9168	0x8607	#CJK UNIFIED IDEOGRAPH
-0x9169	0x8A34	#CJK UNIFIED IDEOGRAPH
-0x916A	0x963B	#CJK UNIFIED IDEOGRAPH
-0x916B	0x9061	#CJK UNIFIED IDEOGRAPH
-0x916C	0x9F20	#CJK UNIFIED IDEOGRAPH
-0x916D	0x50E7	#CJK UNIFIED IDEOGRAPH
-0x916E	0x5275	#CJK UNIFIED IDEOGRAPH
-0x916F	0x53CC	#CJK UNIFIED IDEOGRAPH
-0x9170	0x53E2	#CJK UNIFIED IDEOGRAPH
-0x9171	0x5009	#CJK UNIFIED IDEOGRAPH
-0x9172	0x55AA	#CJK UNIFIED IDEOGRAPH
-0x9173	0x58EE	#CJK UNIFIED IDEOGRAPH
-0x9174	0x594F	#CJK UNIFIED IDEOGRAPH
-0x9175	0x723D	#CJK UNIFIED IDEOGRAPH
-0x9176	0x5B8B	#CJK UNIFIED IDEOGRAPH
-0x9177	0x5C64	#CJK UNIFIED IDEOGRAPH
-0x9178	0x531D	#CJK UNIFIED IDEOGRAPH
-0x9179	0x60E3	#CJK UNIFIED IDEOGRAPH
-0x917A	0x60F3	#CJK UNIFIED IDEOGRAPH
-0x917B	0x635C	#CJK UNIFIED IDEOGRAPH
-0x917C	0x6383	#CJK UNIFIED IDEOGRAPH
-0x917D	0x633F	#CJK UNIFIED IDEOGRAPH
-0x917E	0x63BB	#CJK UNIFIED IDEOGRAPH
-0x9180	0x64CD	#CJK UNIFIED IDEOGRAPH
-0x9181	0x65E9	#CJK UNIFIED IDEOGRAPH
-0x9182	0x66F9	#CJK UNIFIED IDEOGRAPH
-0x9183	0x5DE3	#CJK UNIFIED IDEOGRAPH
-0x9184	0x69CD	#CJK UNIFIED IDEOGRAPH
-0x9185	0x69FD	#CJK UNIFIED IDEOGRAPH
-0x9186	0x6F15	#CJK UNIFIED IDEOGRAPH
-0x9187	0x71E5	#CJK UNIFIED IDEOGRAPH
-0x9188	0x4E89	#CJK UNIFIED IDEOGRAPH
-0x9189	0x75E9	#CJK UNIFIED IDEOGRAPH
-0x918A	0x76F8	#CJK UNIFIED IDEOGRAPH
-0x918B	0x7A93	#CJK UNIFIED IDEOGRAPH
-0x918C	0x7CDF	#CJK UNIFIED IDEOGRAPH
-0x918D	0x7DCF	#CJK UNIFIED IDEOGRAPH
-0x918E	0x7D9C	#CJK UNIFIED IDEOGRAPH
-0x918F	0x8061	#CJK UNIFIED IDEOGRAPH
-0x9190	0x8349	#CJK UNIFIED IDEOGRAPH
-0x9191	0x8358	#CJK UNIFIED IDEOGRAPH
-0x9192	0x846C	#CJK UNIFIED IDEOGRAPH
-0x9193	0x84BC	#CJK UNIFIED IDEOGRAPH
-0x9194	0x85FB	#CJK UNIFIED IDEOGRAPH
-0x9195	0x88C5	#CJK UNIFIED IDEOGRAPH
-0x9196	0x8D70	#CJK UNIFIED IDEOGRAPH
-0x9197	0x9001	#CJK UNIFIED IDEOGRAPH
-0x9198	0x906D	#CJK UNIFIED IDEOGRAPH
-0x9199	0x9397	#CJK UNIFIED IDEOGRAPH
-0x919A	0x971C	#CJK UNIFIED IDEOGRAPH
-0x919B	0x9A12	#CJK UNIFIED IDEOGRAPH
-0x919C	0x50CF	#CJK UNIFIED IDEOGRAPH
-0x919D	0x5897	#CJK UNIFIED IDEOGRAPH
-0x919E	0x618E	#CJK UNIFIED IDEOGRAPH
-0x919F	0x81D3	#CJK UNIFIED IDEOGRAPH
-0x91A0	0x8535	#CJK UNIFIED IDEOGRAPH
-0x91A1	0x8D08	#CJK UNIFIED IDEOGRAPH
-0x91A2	0x9020	#CJK UNIFIED IDEOGRAPH
-0x91A3	0x4FC3	#CJK UNIFIED IDEOGRAPH
-0x91A4	0x5074	#CJK UNIFIED IDEOGRAPH
-0x91A5	0x5247	#CJK UNIFIED IDEOGRAPH
-0x91A6	0x5373	#CJK UNIFIED IDEOGRAPH
-0x91A7	0x606F	#CJK UNIFIED IDEOGRAPH
-0x91A8	0x6349	#CJK UNIFIED IDEOGRAPH
-0x91A9	0x675F	#CJK UNIFIED IDEOGRAPH
-0x91AA	0x6E2C	#CJK UNIFIED IDEOGRAPH
-0x91AB	0x8DB3	#CJK UNIFIED IDEOGRAPH
-0x91AC	0x901F	#CJK UNIFIED IDEOGRAPH
-0x91AD	0x4FD7	#CJK UNIFIED IDEOGRAPH
-0x91AE	0x5C5E	#CJK UNIFIED IDEOGRAPH
-0x91AF	0x8CCA	#CJK UNIFIED IDEOGRAPH
-0x91B0	0x65CF	#CJK UNIFIED IDEOGRAPH
-0x91B1	0x7D9A	#CJK UNIFIED IDEOGRAPH
-0x91B2	0x5352	#CJK UNIFIED IDEOGRAPH
-0x91B3	0x8896	#CJK UNIFIED IDEOGRAPH
-0x91B4	0x5176	#CJK UNIFIED IDEOGRAPH
-0x91B5	0x63C3	#CJK UNIFIED IDEOGRAPH
-0x91B6	0x5B58	#CJK UNIFIED IDEOGRAPH
-0x91B7	0x5B6B	#CJK UNIFIED IDEOGRAPH
-0x91B8	0x5C0A	#CJK UNIFIED IDEOGRAPH
-0x91B9	0x640D	#CJK UNIFIED IDEOGRAPH
-0x91BA	0x6751	#CJK UNIFIED IDEOGRAPH
-0x91BB	0x905C	#CJK UNIFIED IDEOGRAPH
-0x91BC	0x4ED6	#CJK UNIFIED IDEOGRAPH
-0x91BD	0x591A	#CJK UNIFIED IDEOGRAPH
-0x91BE	0x592A	#CJK UNIFIED IDEOGRAPH
-0x91BF	0x6C70	#CJK UNIFIED IDEOGRAPH
-0x91C0	0x8A51	#CJK UNIFIED IDEOGRAPH
-0x91C1	0x553E	#CJK UNIFIED IDEOGRAPH
-0x91C2	0x5815	#CJK UNIFIED IDEOGRAPH
-0x91C3	0x59A5	#CJK UNIFIED IDEOGRAPH
-0x91C4	0x60F0	#CJK UNIFIED IDEOGRAPH
-0x91C5	0x6253	#CJK UNIFIED IDEOGRAPH
-0x91C6	0x67C1	#CJK UNIFIED IDEOGRAPH
-0x91C7	0x8235	#CJK UNIFIED IDEOGRAPH
-0x91C8	0x6955	#CJK UNIFIED IDEOGRAPH
-0x91C9	0x9640	#CJK UNIFIED IDEOGRAPH
-0x91CA	0x99C4	#CJK UNIFIED IDEOGRAPH
-0x91CB	0x9A28	#CJK UNIFIED IDEOGRAPH
-0x91CC	0x4F53	#CJK UNIFIED IDEOGRAPH
-0x91CD	0x5806	#CJK UNIFIED IDEOGRAPH
-0x91CE	0x5BFE	#CJK UNIFIED IDEOGRAPH
-0x91CF	0x8010	#CJK UNIFIED IDEOGRAPH
-0x91D0	0x5CB1	#CJK UNIFIED IDEOGRAPH
-0x91D1	0x5E2F	#CJK UNIFIED IDEOGRAPH
-0x91D2	0x5F85	#CJK UNIFIED IDEOGRAPH
-0x91D3	0x6020	#CJK UNIFIED IDEOGRAPH
-0x91D4	0x614B	#CJK UNIFIED IDEOGRAPH
-0x91D5	0x6234	#CJK UNIFIED IDEOGRAPH
-0x91D6	0x66FF	#CJK UNIFIED IDEOGRAPH
-0x91D7	0x6CF0	#CJK UNIFIED IDEOGRAPH
-0x91D8	0x6EDE	#CJK UNIFIED IDEOGRAPH
-0x91D9	0x80CE	#CJK UNIFIED IDEOGRAPH
-0x91DA	0x817F	#CJK UNIFIED IDEOGRAPH
-0x91DB	0x82D4	#CJK UNIFIED IDEOGRAPH
-0x91DC	0x888B	#CJK UNIFIED IDEOGRAPH
-0x91DD	0x8CB8	#CJK UNIFIED IDEOGRAPH
-0x91DE	0x9000	#CJK UNIFIED IDEOGRAPH
-0x91DF	0x902E	#CJK UNIFIED IDEOGRAPH
-0x91E0	0x968A	#CJK UNIFIED IDEOGRAPH
-0x91E1	0x9EDB	#CJK UNIFIED IDEOGRAPH
-0x91E2	0x9BDB	#CJK UNIFIED IDEOGRAPH
-0x91E3	0x4EE3	#CJK UNIFIED IDEOGRAPH
-0x91E4	0x53F0	#CJK UNIFIED IDEOGRAPH
-0x91E5	0x5927	#CJK UNIFIED IDEOGRAPH
-0x91E6	0x7B2C	#CJK UNIFIED IDEOGRAPH
-0x91E7	0x918D	#CJK UNIFIED IDEOGRAPH
-0x91E8	0x984C	#CJK UNIFIED IDEOGRAPH
-0x91E9	0x9DF9	#CJK UNIFIED IDEOGRAPH
-0x91EA	0x6EDD	#CJK UNIFIED IDEOGRAPH
-0x91EB	0x7027	#CJK UNIFIED IDEOGRAPH
-0x91EC	0x5353	#CJK UNIFIED IDEOGRAPH
-0x91ED	0x5544	#CJK UNIFIED IDEOGRAPH
-0x91EE	0x5B85	#CJK UNIFIED IDEOGRAPH
-0x91EF	0x6258	#CJK UNIFIED IDEOGRAPH
-0x91F0	0x629E	#CJK UNIFIED IDEOGRAPH
-0x91F1	0x62D3	#CJK UNIFIED IDEOGRAPH
-0x91F2	0x6CA2	#CJK UNIFIED IDEOGRAPH
-0x91F3	0x6FEF	#CJK UNIFIED IDEOGRAPH
-0x91F4	0x7422	#CJK UNIFIED IDEOGRAPH
-0x91F5	0x8A17	#CJK UNIFIED IDEOGRAPH
-0x91F6	0x9438	#CJK UNIFIED IDEOGRAPH
-0x91F7	0x6FC1	#CJK UNIFIED IDEOGRAPH
-0x91F8	0x8AFE	#CJK UNIFIED IDEOGRAPH
-0x91F9	0x8338	#CJK UNIFIED IDEOGRAPH
-0x91FA	0x51E7	#CJK UNIFIED IDEOGRAPH
-0x91FB	0x86F8	#CJK UNIFIED IDEOGRAPH
-0x91FC	0x53EA	#CJK UNIFIED IDEOGRAPH
-0x9240	0x53E9	#CJK UNIFIED IDEOGRAPH
-0x9241	0x4F46	#CJK UNIFIED IDEOGRAPH
-0x9242	0x9054	#CJK UNIFIED IDEOGRAPH
-0x9243	0x8FB0	#CJK UNIFIED IDEOGRAPH
-0x9244	0x596A	#CJK UNIFIED IDEOGRAPH
-0x9245	0x8131	#CJK UNIFIED IDEOGRAPH
-0x9246	0x5DFD	#CJK UNIFIED IDEOGRAPH
-0x9247	0x7AEA	#CJK UNIFIED IDEOGRAPH
-0x9248	0x8FBF	#CJK UNIFIED IDEOGRAPH
-0x9249	0x68DA	#CJK UNIFIED IDEOGRAPH
-0x924A	0x8C37	#CJK UNIFIED IDEOGRAPH
-0x924B	0x72F8	#CJK UNIFIED IDEOGRAPH
-0x924C	0x9C48	#CJK UNIFIED IDEOGRAPH
-0x924D	0x6A3D	#CJK UNIFIED IDEOGRAPH
-0x924E	0x8AB0	#CJK UNIFIED IDEOGRAPH
-0x924F	0x4E39	#CJK UNIFIED IDEOGRAPH
-0x9250	0x5358	#CJK UNIFIED IDEOGRAPH
-0x9251	0x5606	#CJK UNIFIED IDEOGRAPH
-0x9252	0x5766	#CJK UNIFIED IDEOGRAPH
-0x9253	0x62C5	#CJK UNIFIED IDEOGRAPH
-0x9254	0x63A2	#CJK UNIFIED IDEOGRAPH
-0x9255	0x65E6	#CJK UNIFIED IDEOGRAPH
-0x9256	0x6B4E	#CJK UNIFIED IDEOGRAPH
-0x9257	0x6DE1	#CJK UNIFIED IDEOGRAPH
-0x9258	0x6E5B	#CJK UNIFIED IDEOGRAPH
-0x9259	0x70AD	#CJK UNIFIED IDEOGRAPH
-0x925A	0x77ED	#CJK UNIFIED IDEOGRAPH
-0x925B	0x7AEF	#CJK UNIFIED IDEOGRAPH
-0x925C	0x7BAA	#CJK UNIFIED IDEOGRAPH
-0x925D	0x7DBB	#CJK UNIFIED IDEOGRAPH
-0x925E	0x803D	#CJK UNIFIED IDEOGRAPH
-0x925F	0x80C6	#CJK UNIFIED IDEOGRAPH
-0x9260	0x86CB	#CJK UNIFIED IDEOGRAPH
-0x9261	0x8A95	#CJK UNIFIED IDEOGRAPH
-0x9262	0x935B	#CJK UNIFIED IDEOGRAPH
-0x9263	0x56E3	#CJK UNIFIED IDEOGRAPH
-0x9264	0x58C7	#CJK UNIFIED IDEOGRAPH
-0x9265	0x5F3E	#CJK UNIFIED IDEOGRAPH
-0x9266	0x65AD	#CJK UNIFIED IDEOGRAPH
-0x9267	0x6696	#CJK UNIFIED IDEOGRAPH
-0x9268	0x6A80	#CJK UNIFIED IDEOGRAPH
-0x9269	0x6BB5	#CJK UNIFIED IDEOGRAPH
-0x926A	0x7537	#CJK UNIFIED IDEOGRAPH
-0x926B	0x8AC7	#CJK UNIFIED IDEOGRAPH
-0x926C	0x5024	#CJK UNIFIED IDEOGRAPH
-0x926D	0x77E5	#CJK UNIFIED IDEOGRAPH
-0x926E	0x5730	#CJK UNIFIED IDEOGRAPH
-0x926F	0x5F1B	#CJK UNIFIED IDEOGRAPH
-0x9270	0x6065	#CJK UNIFIED IDEOGRAPH
-0x9271	0x667A	#CJK UNIFIED IDEOGRAPH
-0x9272	0x6C60	#CJK UNIFIED IDEOGRAPH
-0x9273	0x75F4	#CJK UNIFIED IDEOGRAPH
-0x9274	0x7A1A	#CJK UNIFIED IDEOGRAPH
-0x9275	0x7F6E	#CJK UNIFIED IDEOGRAPH
-0x9276	0x81F4	#CJK UNIFIED IDEOGRAPH
-0x9277	0x8718	#CJK UNIFIED IDEOGRAPH
-0x9278	0x9045	#CJK UNIFIED IDEOGRAPH
-0x9279	0x99B3	#CJK UNIFIED IDEOGRAPH
-0x927A	0x7BC9	#CJK UNIFIED IDEOGRAPH
-0x927B	0x755C	#CJK UNIFIED IDEOGRAPH
-0x927C	0x7AF9	#CJK UNIFIED IDEOGRAPH
-0x927D	0x7B51	#CJK UNIFIED IDEOGRAPH
-0x927E	0x84C4	#CJK UNIFIED IDEOGRAPH
-0x9280	0x9010	#CJK UNIFIED IDEOGRAPH
-0x9281	0x79E9	#CJK UNIFIED IDEOGRAPH
-0x9282	0x7A92	#CJK UNIFIED IDEOGRAPH
-0x9283	0x8336	#CJK UNIFIED IDEOGRAPH
-0x9284	0x5AE1	#CJK UNIFIED IDEOGRAPH
-0x9285	0x7740	#CJK UNIFIED IDEOGRAPH
-0x9286	0x4E2D	#CJK UNIFIED IDEOGRAPH
-0x9287	0x4EF2	#CJK UNIFIED IDEOGRAPH
-0x9288	0x5B99	#CJK UNIFIED IDEOGRAPH
-0x9289	0x5FE0	#CJK UNIFIED IDEOGRAPH
-0x928A	0x62BD	#CJK UNIFIED IDEOGRAPH
-0x928B	0x663C	#CJK UNIFIED IDEOGRAPH
-0x928C	0x67F1	#CJK UNIFIED IDEOGRAPH
-0x928D	0x6CE8	#CJK UNIFIED IDEOGRAPH
-0x928E	0x866B	#CJK UNIFIED IDEOGRAPH
-0x928F	0x8877	#CJK UNIFIED IDEOGRAPH
-0x9290	0x8A3B	#CJK UNIFIED IDEOGRAPH
-0x9291	0x914E	#CJK UNIFIED IDEOGRAPH
-0x9292	0x92F3	#CJK UNIFIED IDEOGRAPH
-0x9293	0x99D0	#CJK UNIFIED IDEOGRAPH
-0x9294	0x6A17	#CJK UNIFIED IDEOGRAPH
-0x9295	0x7026	#CJK UNIFIED IDEOGRAPH
-0x9296	0x732A	#CJK UNIFIED IDEOGRAPH
-0x9297	0x82E7	#CJK UNIFIED IDEOGRAPH
-0x9298	0x8457	#CJK UNIFIED IDEOGRAPH
-0x9299	0x8CAF	#CJK UNIFIED IDEOGRAPH
-0x929A	0x4E01	#CJK UNIFIED IDEOGRAPH
-0x929B	0x5146	#CJK UNIFIED IDEOGRAPH
-0x929C	0x51CB	#CJK UNIFIED IDEOGRAPH
-0x929D	0x558B	#CJK UNIFIED IDEOGRAPH
-0x929E	0x5BF5	#CJK UNIFIED IDEOGRAPH
-0x929F	0x5E16	#CJK UNIFIED IDEOGRAPH
-0x92A0	0x5E33	#CJK UNIFIED IDEOGRAPH
-0x92A1	0x5E81	#CJK UNIFIED IDEOGRAPH
-0x92A2	0x5F14	#CJK UNIFIED IDEOGRAPH
-0x92A3	0x5F35	#CJK UNIFIED IDEOGRAPH
-0x92A4	0x5F6B	#CJK UNIFIED IDEOGRAPH
-0x92A5	0x5FB4	#CJK UNIFIED IDEOGRAPH
-0x92A6	0x61F2	#CJK UNIFIED IDEOGRAPH
-0x92A7	0x6311	#CJK UNIFIED IDEOGRAPH
-0x92A8	0x66A2	#CJK UNIFIED IDEOGRAPH
-0x92A9	0x671D	#CJK UNIFIED IDEOGRAPH
-0x92AA	0x6F6E	#CJK UNIFIED IDEOGRAPH
-0x92AB	0x7252	#CJK UNIFIED IDEOGRAPH
-0x92AC	0x753A	#CJK UNIFIED IDEOGRAPH
-0x92AD	0x773A	#CJK UNIFIED IDEOGRAPH
-0x92AE	0x8074	#CJK UNIFIED IDEOGRAPH
-0x92AF	0x8139	#CJK UNIFIED IDEOGRAPH
-0x92B0	0x8178	#CJK UNIFIED IDEOGRAPH
-0x92B1	0x8776	#CJK UNIFIED IDEOGRAPH
-0x92B2	0x8ABF	#CJK UNIFIED IDEOGRAPH
-0x92B3	0x8ADC	#CJK UNIFIED IDEOGRAPH
-0x92B4	0x8D85	#CJK UNIFIED IDEOGRAPH
-0x92B5	0x8DF3	#CJK UNIFIED IDEOGRAPH
-0x92B6	0x929A	#CJK UNIFIED IDEOGRAPH
-0x92B7	0x9577	#CJK UNIFIED IDEOGRAPH
-0x92B8	0x9802	#CJK UNIFIED IDEOGRAPH
-0x92B9	0x9CE5	#CJK UNIFIED IDEOGRAPH
-0x92BA	0x52C5	#CJK UNIFIED IDEOGRAPH
-0x92BB	0x6357	#CJK UNIFIED IDEOGRAPH
-0x92BC	0x76F4	#CJK UNIFIED IDEOGRAPH
-0x92BD	0x6715	#CJK UNIFIED IDEOGRAPH
-0x92BE	0x6C88	#CJK UNIFIED IDEOGRAPH
-0x92BF	0x73CD	#CJK UNIFIED IDEOGRAPH
-0x92C0	0x8CC3	#CJK UNIFIED IDEOGRAPH
-0x92C1	0x93AE	#CJK UNIFIED IDEOGRAPH
-0x92C2	0x9673	#CJK UNIFIED IDEOGRAPH
-0x92C3	0x6D25	#CJK UNIFIED IDEOGRAPH
-0x92C4	0x589C	#CJK UNIFIED IDEOGRAPH
-0x92C5	0x690E	#CJK UNIFIED IDEOGRAPH
-0x92C6	0x69CC	#CJK UNIFIED IDEOGRAPH
-0x92C7	0x8FFD	#CJK UNIFIED IDEOGRAPH
-0x92C8	0x939A	#CJK UNIFIED IDEOGRAPH
-0x92C9	0x75DB	#CJK UNIFIED IDEOGRAPH
-0x92CA	0x901A	#CJK UNIFIED IDEOGRAPH
-0x92CB	0x585A	#CJK UNIFIED IDEOGRAPH
-0x92CC	0x6802	#CJK UNIFIED IDEOGRAPH
-0x92CD	0x63B4	#CJK UNIFIED IDEOGRAPH
-0x92CE	0x69FB	#CJK UNIFIED IDEOGRAPH
-0x92CF	0x4F43	#CJK UNIFIED IDEOGRAPH
-0x92D0	0x6F2C	#CJK UNIFIED IDEOGRAPH
-0x92D1	0x67D8	#CJK UNIFIED IDEOGRAPH
-0x92D2	0x8FBB	#CJK UNIFIED IDEOGRAPH
-0x92D3	0x8526	#CJK UNIFIED IDEOGRAPH
-0x92D4	0x7DB4	#CJK UNIFIED IDEOGRAPH
-0x92D5	0x9354	#CJK UNIFIED IDEOGRAPH
-0x92D6	0x693F	#CJK UNIFIED IDEOGRAPH
-0x92D7	0x6F70	#CJK UNIFIED IDEOGRAPH
-0x92D8	0x576A	#CJK UNIFIED IDEOGRAPH
-0x92D9	0x58F7	#CJK UNIFIED IDEOGRAPH
-0x92DA	0x5B2C	#CJK UNIFIED IDEOGRAPH
-0x92DB	0x7D2C	#CJK UNIFIED IDEOGRAPH
-0x92DC	0x722A	#CJK UNIFIED IDEOGRAPH
-0x92DD	0x540A	#CJK UNIFIED IDEOGRAPH
-0x92DE	0x91E3	#CJK UNIFIED IDEOGRAPH
-0x92DF	0x9DB4	#CJK UNIFIED IDEOGRAPH
-0x92E0	0x4EAD	#CJK UNIFIED IDEOGRAPH
-0x92E1	0x4F4E	#CJK UNIFIED IDEOGRAPH
-0x92E2	0x505C	#CJK UNIFIED IDEOGRAPH
-0x92E3	0x5075	#CJK UNIFIED IDEOGRAPH
-0x92E4	0x5243	#CJK UNIFIED IDEOGRAPH
-0x92E5	0x8C9E	#CJK UNIFIED IDEOGRAPH
-0x92E6	0x5448	#CJK UNIFIED IDEOGRAPH
-0x92E7	0x5824	#CJK UNIFIED IDEOGRAPH
-0x92E8	0x5B9A	#CJK UNIFIED IDEOGRAPH
-0x92E9	0x5E1D	#CJK UNIFIED IDEOGRAPH
-0x92EA	0x5E95	#CJK UNIFIED IDEOGRAPH
-0x92EB	0x5EAD	#CJK UNIFIED IDEOGRAPH
-0x92EC	0x5EF7	#CJK UNIFIED IDEOGRAPH
-0x92ED	0x5F1F	#CJK UNIFIED IDEOGRAPH
-0x92EE	0x608C	#CJK UNIFIED IDEOGRAPH
-0x92EF	0x62B5	#CJK UNIFIED IDEOGRAPH
-0x92F0	0x633A	#CJK UNIFIED IDEOGRAPH
-0x92F1	0x63D0	#CJK UNIFIED IDEOGRAPH
-0x92F2	0x68AF	#CJK UNIFIED IDEOGRAPH
-0x92F3	0x6C40	#CJK UNIFIED IDEOGRAPH
-0x92F4	0x7887	#CJK UNIFIED IDEOGRAPH
-0x92F5	0x798E	#CJK UNIFIED IDEOGRAPH
-0x92F6	0x7A0B	#CJK UNIFIED IDEOGRAPH
-0x92F7	0x7DE0	#CJK UNIFIED IDEOGRAPH
-0x92F8	0x8247	#CJK UNIFIED IDEOGRAPH
-0x92F9	0x8A02	#CJK UNIFIED IDEOGRAPH
-0x92FA	0x8AE6	#CJK UNIFIED IDEOGRAPH
-0x92FB	0x8E44	#CJK UNIFIED IDEOGRAPH
-0x92FC	0x9013	#CJK UNIFIED IDEOGRAPH
-0x9340	0x90B8	#CJK UNIFIED IDEOGRAPH
-0x9341	0x912D	#CJK UNIFIED IDEOGRAPH
-0x9342	0x91D8	#CJK UNIFIED IDEOGRAPH
-0x9343	0x9F0E	#CJK UNIFIED IDEOGRAPH
-0x9344	0x6CE5	#CJK UNIFIED IDEOGRAPH
-0x9345	0x6458	#CJK UNIFIED IDEOGRAPH
-0x9346	0x64E2	#CJK UNIFIED IDEOGRAPH
-0x9347	0x6575	#CJK UNIFIED IDEOGRAPH
-0x9348	0x6EF4	#CJK UNIFIED IDEOGRAPH
-0x9349	0x7684	#CJK UNIFIED IDEOGRAPH
-0x934A	0x7B1B	#CJK UNIFIED IDEOGRAPH
-0x934B	0x9069	#CJK UNIFIED IDEOGRAPH
-0x934C	0x93D1	#CJK UNIFIED IDEOGRAPH
-0x934D	0x6EBA	#CJK UNIFIED IDEOGRAPH
-0x934E	0x54F2	#CJK UNIFIED IDEOGRAPH
-0x934F	0x5FB9	#CJK UNIFIED IDEOGRAPH
-0x9350	0x64A4	#CJK UNIFIED IDEOGRAPH
-0x9351	0x8F4D	#CJK UNIFIED IDEOGRAPH
-0x9352	0x8FED	#CJK UNIFIED IDEOGRAPH
-0x9353	0x9244	#CJK UNIFIED IDEOGRAPH
-0x9354	0x5178	#CJK UNIFIED IDEOGRAPH
-0x9355	0x586B	#CJK UNIFIED IDEOGRAPH
-0x9356	0x5929	#CJK UNIFIED IDEOGRAPH
-0x9357	0x5C55	#CJK UNIFIED IDEOGRAPH
-0x9358	0x5E97	#CJK UNIFIED IDEOGRAPH
-0x9359	0x6DFB	#CJK UNIFIED IDEOGRAPH
-0x935A	0x7E8F	#CJK UNIFIED IDEOGRAPH
-0x935B	0x751C	#CJK UNIFIED IDEOGRAPH
-0x935C	0x8CBC	#CJK UNIFIED IDEOGRAPH
-0x935D	0x8EE2	#CJK UNIFIED IDEOGRAPH
-0x935E	0x985B	#CJK UNIFIED IDEOGRAPH
-0x935F	0x70B9	#CJK UNIFIED IDEOGRAPH
-0x9360	0x4F1D	#CJK UNIFIED IDEOGRAPH
-0x9361	0x6BBF	#CJK UNIFIED IDEOGRAPH
-0x9362	0x6FB1	#CJK UNIFIED IDEOGRAPH
-0x9363	0x7530	#CJK UNIFIED IDEOGRAPH
-0x9364	0x96FB	#CJK UNIFIED IDEOGRAPH
-0x9365	0x514E	#CJK UNIFIED IDEOGRAPH
-0x9366	0x5410	#CJK UNIFIED IDEOGRAPH
-0x9367	0x5835	#CJK UNIFIED IDEOGRAPH
-0x9368	0x5857	#CJK UNIFIED IDEOGRAPH
-0x9369	0x59AC	#CJK UNIFIED IDEOGRAPH
-0x936A	0x5C60	#CJK UNIFIED IDEOGRAPH
-0x936B	0x5F92	#CJK UNIFIED IDEOGRAPH
-0x936C	0x6597	#CJK UNIFIED IDEOGRAPH
-0x936D	0x675C	#CJK UNIFIED IDEOGRAPH
-0x936E	0x6E21	#CJK UNIFIED IDEOGRAPH
-0x936F	0x767B	#CJK UNIFIED IDEOGRAPH
-0x9370	0x83DF	#CJK UNIFIED IDEOGRAPH
-0x9371	0x8CED	#CJK UNIFIED IDEOGRAPH
-0x9372	0x9014	#CJK UNIFIED IDEOGRAPH
-0x9373	0x90FD	#CJK UNIFIED IDEOGRAPH
-0x9374	0x934D	#CJK UNIFIED IDEOGRAPH
-0x9375	0x7825	#CJK UNIFIED IDEOGRAPH
-0x9376	0x783A	#CJK UNIFIED IDEOGRAPH
-0x9377	0x52AA	#CJK UNIFIED IDEOGRAPH
-0x9378	0x5EA6	#CJK UNIFIED IDEOGRAPH
-0x9379	0x571F	#CJK UNIFIED IDEOGRAPH
-0x937A	0x5974	#CJK UNIFIED IDEOGRAPH
-0x937B	0x6012	#CJK UNIFIED IDEOGRAPH
-0x937C	0x5012	#CJK UNIFIED IDEOGRAPH
-0x937D	0x515A	#CJK UNIFIED IDEOGRAPH
-0x937E	0x51AC	#CJK UNIFIED IDEOGRAPH
-0x9380	0x51CD	#CJK UNIFIED IDEOGRAPH
-0x9381	0x5200	#CJK UNIFIED IDEOGRAPH
-0x9382	0x5510	#CJK UNIFIED IDEOGRAPH
-0x9383	0x5854	#CJK UNIFIED IDEOGRAPH
-0x9384	0x5858	#CJK UNIFIED IDEOGRAPH
-0x9385	0x5957	#CJK UNIFIED IDEOGRAPH
-0x9386	0x5B95	#CJK UNIFIED IDEOGRAPH
-0x9387	0x5CF6	#CJK UNIFIED IDEOGRAPH
-0x9388	0x5D8B	#CJK UNIFIED IDEOGRAPH
-0x9389	0x60BC	#CJK UNIFIED IDEOGRAPH
-0x938A	0x6295	#CJK UNIFIED IDEOGRAPH
-0x938B	0x642D	#CJK UNIFIED IDEOGRAPH
-0x938C	0x6771	#CJK UNIFIED IDEOGRAPH
-0x938D	0x6843	#CJK UNIFIED IDEOGRAPH
-0x938E	0x68BC	#CJK UNIFIED IDEOGRAPH
-0x938F	0x68DF	#CJK UNIFIED IDEOGRAPH
-0x9390	0x76D7	#CJK UNIFIED IDEOGRAPH
-0x9391	0x6DD8	#CJK UNIFIED IDEOGRAPH
-0x9392	0x6E6F	#CJK UNIFIED IDEOGRAPH
-0x9393	0x6D9B	#CJK UNIFIED IDEOGRAPH
-0x9394	0x706F	#CJK UNIFIED IDEOGRAPH
-0x9395	0x71C8	#CJK UNIFIED IDEOGRAPH
-0x9396	0x5F53	#CJK UNIFIED IDEOGRAPH
-0x9397	0x75D8	#CJK UNIFIED IDEOGRAPH
-0x9398	0x7977	#CJK UNIFIED IDEOGRAPH
-0x9399	0x7B49	#CJK UNIFIED IDEOGRAPH
-0x939A	0x7B54	#CJK UNIFIED IDEOGRAPH
-0x939B	0x7B52	#CJK UNIFIED IDEOGRAPH
-0x939C	0x7CD6	#CJK UNIFIED IDEOGRAPH
-0x939D	0x7D71	#CJK UNIFIED IDEOGRAPH
-0x939E	0x5230	#CJK UNIFIED IDEOGRAPH
-0x939F	0x8463	#CJK UNIFIED IDEOGRAPH
-0x93A0	0x8569	#CJK UNIFIED IDEOGRAPH
-0x93A1	0x85E4	#CJK UNIFIED IDEOGRAPH
-0x93A2	0x8A0E	#CJK UNIFIED IDEOGRAPH
-0x93A3	0x8B04	#CJK UNIFIED IDEOGRAPH
-0x93A4	0x8C46	#CJK UNIFIED IDEOGRAPH
-0x93A5	0x8E0F	#CJK UNIFIED IDEOGRAPH
-0x93A6	0x9003	#CJK UNIFIED IDEOGRAPH
-0x93A7	0x900F	#CJK UNIFIED IDEOGRAPH
-0x93A8	0x9419	#CJK UNIFIED IDEOGRAPH
-0x93A9	0x9676	#CJK UNIFIED IDEOGRAPH
-0x93AA	0x982D	#CJK UNIFIED IDEOGRAPH
-0x93AB	0x9A30	#CJK UNIFIED IDEOGRAPH
-0x93AC	0x95D8	#CJK UNIFIED IDEOGRAPH
-0x93AD	0x50CD	#CJK UNIFIED IDEOGRAPH
-0x93AE	0x52D5	#CJK UNIFIED IDEOGRAPH
-0x93AF	0x540C	#CJK UNIFIED IDEOGRAPH
-0x93B0	0x5802	#CJK UNIFIED IDEOGRAPH
-0x93B1	0x5C0E	#CJK UNIFIED IDEOGRAPH
-0x93B2	0x61A7	#CJK UNIFIED IDEOGRAPH
-0x93B3	0x649E	#CJK UNIFIED IDEOGRAPH
-0x93B4	0x6D1E	#CJK UNIFIED IDEOGRAPH
-0x93B5	0x77B3	#CJK UNIFIED IDEOGRAPH
-0x93B6	0x7AE5	#CJK UNIFIED IDEOGRAPH
-0x93B7	0x80F4	#CJK UNIFIED IDEOGRAPH
-0x93B8	0x8404	#CJK UNIFIED IDEOGRAPH
-0x93B9	0x9053	#CJK UNIFIED IDEOGRAPH
-0x93BA	0x9285	#CJK UNIFIED IDEOGRAPH
-0x93BB	0x5CE0	#CJK UNIFIED IDEOGRAPH
-0x93BC	0x9D07	#CJK UNIFIED IDEOGRAPH
-0x93BD	0x533F	#CJK UNIFIED IDEOGRAPH
-0x93BE	0x5F97	#CJK UNIFIED IDEOGRAPH
-0x93BF	0x5FB3	#CJK UNIFIED IDEOGRAPH
-0x93C0	0x6D9C	#CJK UNIFIED IDEOGRAPH
-0x93C1	0x7279	#CJK UNIFIED IDEOGRAPH
-0x93C2	0x7763	#CJK UNIFIED IDEOGRAPH
-0x93C3	0x79BF	#CJK UNIFIED IDEOGRAPH
-0x93C4	0x7BE4	#CJK UNIFIED IDEOGRAPH
-0x93C5	0x6BD2	#CJK UNIFIED IDEOGRAPH
-0x93C6	0x72EC	#CJK UNIFIED IDEOGRAPH
-0x93C7	0x8AAD	#CJK UNIFIED IDEOGRAPH
-0x93C8	0x6803	#CJK UNIFIED IDEOGRAPH
-0x93C9	0x6A61	#CJK UNIFIED IDEOGRAPH
-0x93CA	0x51F8	#CJK UNIFIED IDEOGRAPH
-0x93CB	0x7A81	#CJK UNIFIED IDEOGRAPH
-0x93CC	0x6934	#CJK UNIFIED IDEOGRAPH
-0x93CD	0x5C4A	#CJK UNIFIED IDEOGRAPH
-0x93CE	0x9CF6	#CJK UNIFIED IDEOGRAPH
-0x93CF	0x82EB	#CJK UNIFIED IDEOGRAPH
-0x93D0	0x5BC5	#CJK UNIFIED IDEOGRAPH
-0x93D1	0x9149	#CJK UNIFIED IDEOGRAPH
-0x93D2	0x701E	#CJK UNIFIED IDEOGRAPH
-0x93D3	0x5678	#CJK UNIFIED IDEOGRAPH
-0x93D4	0x5C6F	#CJK UNIFIED IDEOGRAPH
-0x93D5	0x60C7	#CJK UNIFIED IDEOGRAPH
-0x93D6	0x6566	#CJK UNIFIED IDEOGRAPH
-0x93D7	0x6C8C	#CJK UNIFIED IDEOGRAPH
-0x93D8	0x8C5A	#CJK UNIFIED IDEOGRAPH
-0x93D9	0x9041	#CJK UNIFIED IDEOGRAPH
-0x93DA	0x9813	#CJK UNIFIED IDEOGRAPH
-0x93DB	0x5451	#CJK UNIFIED IDEOGRAPH
-0x93DC	0x66C7	#CJK UNIFIED IDEOGRAPH
-0x93DD	0x920D	#CJK UNIFIED IDEOGRAPH
-0x93DE	0x5948	#CJK UNIFIED IDEOGRAPH
-0x93DF	0x90A3	#CJK UNIFIED IDEOGRAPH
-0x93E0	0x5185	#CJK UNIFIED IDEOGRAPH
-0x93E1	0x4E4D	#CJK UNIFIED IDEOGRAPH
-0x93E2	0x51EA	#CJK UNIFIED IDEOGRAPH
-0x93E3	0x8599	#CJK UNIFIED IDEOGRAPH
-0x93E4	0x8B0E	#CJK UNIFIED IDEOGRAPH
-0x93E5	0x7058	#CJK UNIFIED IDEOGRAPH
-0x93E6	0x637A	#CJK UNIFIED IDEOGRAPH
-0x93E7	0x934B	#CJK UNIFIED IDEOGRAPH
-0x93E8	0x6962	#CJK UNIFIED IDEOGRAPH
-0x93E9	0x99B4	#CJK UNIFIED IDEOGRAPH
-0x93EA	0x7E04	#CJK UNIFIED IDEOGRAPH
-0x93EB	0x7577	#CJK UNIFIED IDEOGRAPH
-0x93EC	0x5357	#CJK UNIFIED IDEOGRAPH
-0x93ED	0x6960	#CJK UNIFIED IDEOGRAPH
-0x93EE	0x8EDF	#CJK UNIFIED IDEOGRAPH
-0x93EF	0x96E3	#CJK UNIFIED IDEOGRAPH
-0x93F0	0x6C5D	#CJK UNIFIED IDEOGRAPH
-0x93F1	0x4E8C	#CJK UNIFIED IDEOGRAPH
-0x93F2	0x5C3C	#CJK UNIFIED IDEOGRAPH
-0x93F3	0x5F10	#CJK UNIFIED IDEOGRAPH
-0x93F4	0x8FE9	#CJK UNIFIED IDEOGRAPH
-0x93F5	0x5302	#CJK UNIFIED IDEOGRAPH
-0x93F6	0x8CD1	#CJK UNIFIED IDEOGRAPH
-0x93F7	0x8089	#CJK UNIFIED IDEOGRAPH
-0x93F8	0x8679	#CJK UNIFIED IDEOGRAPH
-0x93F9	0x5EFF	#CJK UNIFIED IDEOGRAPH
-0x93FA	0x65E5	#CJK UNIFIED IDEOGRAPH
-0x93FB	0x4E73	#CJK UNIFIED IDEOGRAPH
-0x93FC	0x5165	#CJK UNIFIED IDEOGRAPH
-0x9440	0x5982	#CJK UNIFIED IDEOGRAPH
-0x9441	0x5C3F	#CJK UNIFIED IDEOGRAPH
-0x9442	0x97EE	#CJK UNIFIED IDEOGRAPH
-0x9443	0x4EFB	#CJK UNIFIED IDEOGRAPH
-0x9444	0x598A	#CJK UNIFIED IDEOGRAPH
-0x9445	0x5FCD	#CJK UNIFIED IDEOGRAPH
-0x9446	0x8A8D	#CJK UNIFIED IDEOGRAPH
-0x9447	0x6FE1	#CJK UNIFIED IDEOGRAPH
-0x9448	0x79B0	#CJK UNIFIED IDEOGRAPH
-0x9449	0x7962	#CJK UNIFIED IDEOGRAPH
-0x944A	0x5BE7	#CJK UNIFIED IDEOGRAPH
-0x944B	0x8471	#CJK UNIFIED IDEOGRAPH
-0x944C	0x732B	#CJK UNIFIED IDEOGRAPH
-0x944D	0x71B1	#CJK UNIFIED IDEOGRAPH
-0x944E	0x5E74	#CJK UNIFIED IDEOGRAPH
-0x944F	0x5FF5	#CJK UNIFIED IDEOGRAPH
-0x9450	0x637B	#CJK UNIFIED IDEOGRAPH
-0x9451	0x649A	#CJK UNIFIED IDEOGRAPH
-0x9452	0x71C3	#CJK UNIFIED IDEOGRAPH
-0x9453	0x7C98	#CJK UNIFIED IDEOGRAPH
-0x9454	0x4E43	#CJK UNIFIED IDEOGRAPH
-0x9455	0x5EFC	#CJK UNIFIED IDEOGRAPH
-0x9456	0x4E4B	#CJK UNIFIED IDEOGRAPH
-0x9457	0x57DC	#CJK UNIFIED IDEOGRAPH
-0x9458	0x56A2	#CJK UNIFIED IDEOGRAPH
-0x9459	0x60A9	#CJK UNIFIED IDEOGRAPH
-0x945A	0x6FC3	#CJK UNIFIED IDEOGRAPH
-0x945B	0x7D0D	#CJK UNIFIED IDEOGRAPH
-0x945C	0x80FD	#CJK UNIFIED IDEOGRAPH
-0x945D	0x8133	#CJK UNIFIED IDEOGRAPH
-0x945E	0x81BF	#CJK UNIFIED IDEOGRAPH
-0x945F	0x8FB2	#CJK UNIFIED IDEOGRAPH
-0x9460	0x8997	#CJK UNIFIED IDEOGRAPH
-0x9461	0x86A4	#CJK UNIFIED IDEOGRAPH
-0x9462	0x5DF4	#CJK UNIFIED IDEOGRAPH
-0x9463	0x628A	#CJK UNIFIED IDEOGRAPH
-0x9464	0x64AD	#CJK UNIFIED IDEOGRAPH
-0x9465	0x8987	#CJK UNIFIED IDEOGRAPH
-0x9466	0x6777	#CJK UNIFIED IDEOGRAPH
-0x9467	0x6CE2	#CJK UNIFIED IDEOGRAPH
-0x9468	0x6D3E	#CJK UNIFIED IDEOGRAPH
-0x9469	0x7436	#CJK UNIFIED IDEOGRAPH
-0x946A	0x7834	#CJK UNIFIED IDEOGRAPH
-0x946B	0x5A46	#CJK UNIFIED IDEOGRAPH
-0x946C	0x7F75	#CJK UNIFIED IDEOGRAPH
-0x946D	0x82AD	#CJK UNIFIED IDEOGRAPH
-0x946E	0x99AC	#CJK UNIFIED IDEOGRAPH
-0x946F	0x4FF3	#CJK UNIFIED IDEOGRAPH
-0x9470	0x5EC3	#CJK UNIFIED IDEOGRAPH
-0x9471	0x62DD	#CJK UNIFIED IDEOGRAPH
-0x9472	0x6392	#CJK UNIFIED IDEOGRAPH
-0x9473	0x6557	#CJK UNIFIED IDEOGRAPH
-0x9474	0x676F	#CJK UNIFIED IDEOGRAPH
-0x9475	0x76C3	#CJK UNIFIED IDEOGRAPH
-0x9476	0x724C	#CJK UNIFIED IDEOGRAPH
-0x9477	0x80CC	#CJK UNIFIED IDEOGRAPH
-0x9478	0x80BA	#CJK UNIFIED IDEOGRAPH
-0x9479	0x8F29	#CJK UNIFIED IDEOGRAPH
-0x947A	0x914D	#CJK UNIFIED IDEOGRAPH
-0x947B	0x500D	#CJK UNIFIED IDEOGRAPH
-0x947C	0x57F9	#CJK UNIFIED IDEOGRAPH
-0x947D	0x5A92	#CJK UNIFIED IDEOGRAPH
-0x947E	0x6885	#CJK UNIFIED IDEOGRAPH
-0x9480	0x6973	#CJK UNIFIED IDEOGRAPH
-0x9481	0x7164	#CJK UNIFIED IDEOGRAPH
-0x9482	0x72FD	#CJK UNIFIED IDEOGRAPH
-0x9483	0x8CB7	#CJK UNIFIED IDEOGRAPH
-0x9484	0x58F2	#CJK UNIFIED IDEOGRAPH
-0x9485	0x8CE0	#CJK UNIFIED IDEOGRAPH
-0x9486	0x966A	#CJK UNIFIED IDEOGRAPH
-0x9487	0x9019	#CJK UNIFIED IDEOGRAPH
-0x9488	0x877F	#CJK UNIFIED IDEOGRAPH
-0x9489	0x79E4	#CJK UNIFIED IDEOGRAPH
-0x948A	0x77E7	#CJK UNIFIED IDEOGRAPH
-0x948B	0x8429	#CJK UNIFIED IDEOGRAPH
-0x948C	0x4F2F	#CJK UNIFIED IDEOGRAPH
-0x948D	0x5265	#CJK UNIFIED IDEOGRAPH
-0x948E	0x535A	#CJK UNIFIED IDEOGRAPH
-0x948F	0x62CD	#CJK UNIFIED IDEOGRAPH
-0x9490	0x67CF	#CJK UNIFIED IDEOGRAPH
-0x9491	0x6CCA	#CJK UNIFIED IDEOGRAPH
-0x9492	0x767D	#CJK UNIFIED IDEOGRAPH
-0x9493	0x7B94	#CJK UNIFIED IDEOGRAPH
-0x9494	0x7C95	#CJK UNIFIED IDEOGRAPH
-0x9495	0x8236	#CJK UNIFIED IDEOGRAPH
-0x9496	0x8584	#CJK UNIFIED IDEOGRAPH
-0x9497	0x8FEB	#CJK UNIFIED IDEOGRAPH
-0x9498	0x66DD	#CJK UNIFIED IDEOGRAPH
-0x9499	0x6F20	#CJK UNIFIED IDEOGRAPH
-0x949A	0x7206	#CJK UNIFIED IDEOGRAPH
-0x949B	0x7E1B	#CJK UNIFIED IDEOGRAPH
-0x949C	0x83AB	#CJK UNIFIED IDEOGRAPH
-0x949D	0x99C1	#CJK UNIFIED IDEOGRAPH
-0x949E	0x9EA6	#CJK UNIFIED IDEOGRAPH
-0x949F	0x51FD	#CJK UNIFIED IDEOGRAPH
-0x94A0	0x7BB1	#CJK UNIFIED IDEOGRAPH
-0x94A1	0x7872	#CJK UNIFIED IDEOGRAPH
-0x94A2	0x7BB8	#CJK UNIFIED IDEOGRAPH
-0x94A3	0x8087	#CJK UNIFIED IDEOGRAPH
-0x94A4	0x7B48	#CJK UNIFIED IDEOGRAPH
-0x94A5	0x6AE8	#CJK UNIFIED IDEOGRAPH
-0x94A6	0x5E61	#CJK UNIFIED IDEOGRAPH
-0x94A7	0x808C	#CJK UNIFIED IDEOGRAPH
-0x94A8	0x7551	#CJK UNIFIED IDEOGRAPH
-0x94A9	0x7560	#CJK UNIFIED IDEOGRAPH
-0x94AA	0x516B	#CJK UNIFIED IDEOGRAPH
-0x94AB	0x9262	#CJK UNIFIED IDEOGRAPH
-0x94AC	0x6E8C	#CJK UNIFIED IDEOGRAPH
-0x94AD	0x767A	#CJK UNIFIED IDEOGRAPH
-0x94AE	0x9197	#CJK UNIFIED IDEOGRAPH
-0x94AF	0x9AEA	#CJK UNIFIED IDEOGRAPH
-0x94B0	0x4F10	#CJK UNIFIED IDEOGRAPH
-0x94B1	0x7F70	#CJK UNIFIED IDEOGRAPH
-0x94B2	0x629C	#CJK UNIFIED IDEOGRAPH
-0x94B3	0x7B4F	#CJK UNIFIED IDEOGRAPH
-0x94B4	0x95A5	#CJK UNIFIED IDEOGRAPH
-0x94B5	0x9CE9	#CJK UNIFIED IDEOGRAPH
-0x94B6	0x567A	#CJK UNIFIED IDEOGRAPH
-0x94B7	0x5859	#CJK UNIFIED IDEOGRAPH
-0x94B8	0x86E4	#CJK UNIFIED IDEOGRAPH
-0x94B9	0x96BC	#CJK UNIFIED IDEOGRAPH
-0x94BA	0x4F34	#CJK UNIFIED IDEOGRAPH
-0x94BB	0x5224	#CJK UNIFIED IDEOGRAPH
-0x94BC	0x534A	#CJK UNIFIED IDEOGRAPH
-0x94BD	0x53CD	#CJK UNIFIED IDEOGRAPH
-0x94BE	0x53DB	#CJK UNIFIED IDEOGRAPH
-0x94BF	0x5E06	#CJK UNIFIED IDEOGRAPH
-0x94C0	0x642C	#CJK UNIFIED IDEOGRAPH
-0x94C1	0x6591	#CJK UNIFIED IDEOGRAPH
-0x94C2	0x677F	#CJK UNIFIED IDEOGRAPH
-0x94C3	0x6C3E	#CJK UNIFIED IDEOGRAPH
-0x94C4	0x6C4E	#CJK UNIFIED IDEOGRAPH
-0x94C5	0x7248	#CJK UNIFIED IDEOGRAPH
-0x94C6	0x72AF	#CJK UNIFIED IDEOGRAPH
-0x94C7	0x73ED	#CJK UNIFIED IDEOGRAPH
-0x94C8	0x7554	#CJK UNIFIED IDEOGRAPH
-0x94C9	0x7E41	#CJK UNIFIED IDEOGRAPH
-0x94CA	0x822C	#CJK UNIFIED IDEOGRAPH
-0x94CB	0x85E9	#CJK UNIFIED IDEOGRAPH
-0x94CC	0x8CA9	#CJK UNIFIED IDEOGRAPH
-0x94CD	0x7BC4	#CJK UNIFIED IDEOGRAPH
-0x94CE	0x91C6	#CJK UNIFIED IDEOGRAPH
-0x94CF	0x7169	#CJK UNIFIED IDEOGRAPH
-0x94D0	0x9812	#CJK UNIFIED IDEOGRAPH
-0x94D1	0x98EF	#CJK UNIFIED IDEOGRAPH
-0x94D2	0x633D	#CJK UNIFIED IDEOGRAPH
-0x94D3	0x6669	#CJK UNIFIED IDEOGRAPH
-0x94D4	0x756A	#CJK UNIFIED IDEOGRAPH
-0x94D5	0x76E4	#CJK UNIFIED IDEOGRAPH
-0x94D6	0x78D0	#CJK UNIFIED IDEOGRAPH
-0x94D7	0x8543	#CJK UNIFIED IDEOGRAPH
-0x94D8	0x86EE	#CJK UNIFIED IDEOGRAPH
-0x94D9	0x532A	#CJK UNIFIED IDEOGRAPH
-0x94DA	0x5351	#CJK UNIFIED IDEOGRAPH
-0x94DB	0x5426	#CJK UNIFIED IDEOGRAPH
-0x94DC	0x5983	#CJK UNIFIED IDEOGRAPH
-0x94DD	0x5E87	#CJK UNIFIED IDEOGRAPH
-0x94DE	0x5F7C	#CJK UNIFIED IDEOGRAPH
-0x94DF	0x60B2	#CJK UNIFIED IDEOGRAPH
-0x94E0	0x6249	#CJK UNIFIED IDEOGRAPH
-0x94E1	0x6279	#CJK UNIFIED IDEOGRAPH
-0x94E2	0x62AB	#CJK UNIFIED IDEOGRAPH
-0x94E3	0x6590	#CJK UNIFIED IDEOGRAPH
-0x94E4	0x6BD4	#CJK UNIFIED IDEOGRAPH
-0x94E5	0x6CCC	#CJK UNIFIED IDEOGRAPH
-0x94E6	0x75B2	#CJK UNIFIED IDEOGRAPH
-0x94E7	0x76AE	#CJK UNIFIED IDEOGRAPH
-0x94E8	0x7891	#CJK UNIFIED IDEOGRAPH
-0x94E9	0x79D8	#CJK UNIFIED IDEOGRAPH
-0x94EA	0x7DCB	#CJK UNIFIED IDEOGRAPH
-0x94EB	0x7F77	#CJK UNIFIED IDEOGRAPH
-0x94EC	0x80A5	#CJK UNIFIED IDEOGRAPH
-0x94ED	0x88AB	#CJK UNIFIED IDEOGRAPH
-0x94EE	0x8AB9	#CJK UNIFIED IDEOGRAPH
-0x94EF	0x8CBB	#CJK UNIFIED IDEOGRAPH
-0x94F0	0x907F	#CJK UNIFIED IDEOGRAPH
-0x94F1	0x975E	#CJK UNIFIED IDEOGRAPH
-0x94F2	0x98DB	#CJK UNIFIED IDEOGRAPH
-0x94F3	0x6A0B	#CJK UNIFIED IDEOGRAPH
-0x94F4	0x7C38	#CJK UNIFIED IDEOGRAPH
-0x94F5	0x5099	#CJK UNIFIED IDEOGRAPH
-0x94F6	0x5C3E	#CJK UNIFIED IDEOGRAPH
-0x94F7	0x5FAE	#CJK UNIFIED IDEOGRAPH
-0x94F8	0x6787	#CJK UNIFIED IDEOGRAPH
-0x94F9	0x6BD8	#CJK UNIFIED IDEOGRAPH
-0x94FA	0x7435	#CJK UNIFIED IDEOGRAPH
-0x94FB	0x7709	#CJK UNIFIED IDEOGRAPH
-0x94FC	0x7F8E	#CJK UNIFIED IDEOGRAPH
-0x9540	0x9F3B	#CJK UNIFIED IDEOGRAPH
-0x9541	0x67CA	#CJK UNIFIED IDEOGRAPH
-0x9542	0x7A17	#CJK UNIFIED IDEOGRAPH
-0x9543	0x5339	#CJK UNIFIED IDEOGRAPH
-0x9544	0x758B	#CJK UNIFIED IDEOGRAPH
-0x9545	0x9AED	#CJK UNIFIED IDEOGRAPH
-0x9546	0x5F66	#CJK UNIFIED IDEOGRAPH
-0x9547	0x819D	#CJK UNIFIED IDEOGRAPH
-0x9548	0x83F1	#CJK UNIFIED IDEOGRAPH
-0x9549	0x8098	#CJK UNIFIED IDEOGRAPH
-0x954A	0x5F3C	#CJK UNIFIED IDEOGRAPH
-0x954B	0x5FC5	#CJK UNIFIED IDEOGRAPH
-0x954C	0x7562	#CJK UNIFIED IDEOGRAPH
-0x954D	0x7B46	#CJK UNIFIED IDEOGRAPH
-0x954E	0x903C	#CJK UNIFIED IDEOGRAPH
-0x954F	0x6867	#CJK UNIFIED IDEOGRAPH
-0x9550	0x59EB	#CJK UNIFIED IDEOGRAPH
-0x9551	0x5A9B	#CJK UNIFIED IDEOGRAPH
-0x9552	0x7D10	#CJK UNIFIED IDEOGRAPH
-0x9553	0x767E	#CJK UNIFIED IDEOGRAPH
-0x9554	0x8B2C	#CJK UNIFIED IDEOGRAPH
-0x9555	0x4FF5	#CJK UNIFIED IDEOGRAPH
-0x9556	0x5F6A	#CJK UNIFIED IDEOGRAPH
-0x9557	0x6A19	#CJK UNIFIED IDEOGRAPH
-0x9558	0x6C37	#CJK UNIFIED IDEOGRAPH
-0x9559	0x6F02	#CJK UNIFIED IDEOGRAPH
-0x955A	0x74E2	#CJK UNIFIED IDEOGRAPH
-0x955B	0x7968	#CJK UNIFIED IDEOGRAPH
-0x955C	0x8868	#CJK UNIFIED IDEOGRAPH
-0x955D	0x8A55	#CJK UNIFIED IDEOGRAPH
-0x955E	0x8C79	#CJK UNIFIED IDEOGRAPH
-0x955F	0x5EDF	#CJK UNIFIED IDEOGRAPH
-0x9560	0x63CF	#CJK UNIFIED IDEOGRAPH
-0x9561	0x75C5	#CJK UNIFIED IDEOGRAPH
-0x9562	0x79D2	#CJK UNIFIED IDEOGRAPH
-0x9563	0x82D7	#CJK UNIFIED IDEOGRAPH
-0x9564	0x9328	#CJK UNIFIED IDEOGRAPH
-0x9565	0x92F2	#CJK UNIFIED IDEOGRAPH
-0x9566	0x849C	#CJK UNIFIED IDEOGRAPH
-0x9567	0x86ED	#CJK UNIFIED IDEOGRAPH
-0x9568	0x9C2D	#CJK UNIFIED IDEOGRAPH
-0x9569	0x54C1	#CJK UNIFIED IDEOGRAPH
-0x956A	0x5F6C	#CJK UNIFIED IDEOGRAPH
-0x956B	0x658C	#CJK UNIFIED IDEOGRAPH
-0x956C	0x6D5C	#CJK UNIFIED IDEOGRAPH
-0x956D	0x7015	#CJK UNIFIED IDEOGRAPH
-0x956E	0x8CA7	#CJK UNIFIED IDEOGRAPH
-0x956F	0x8CD3	#CJK UNIFIED IDEOGRAPH
-0x9570	0x983B	#CJK UNIFIED IDEOGRAPH
-0x9571	0x654F	#CJK UNIFIED IDEOGRAPH
-0x9572	0x74F6	#CJK UNIFIED IDEOGRAPH
-0x9573	0x4E0D	#CJK UNIFIED IDEOGRAPH
-0x9574	0x4ED8	#CJK UNIFIED IDEOGRAPH
-0x9575	0x57E0	#CJK UNIFIED IDEOGRAPH
-0x9576	0x592B	#CJK UNIFIED IDEOGRAPH
-0x9577	0x5A66	#CJK UNIFIED IDEOGRAPH
-0x9578	0x5BCC	#CJK UNIFIED IDEOGRAPH
-0x9579	0x51A8	#CJK UNIFIED IDEOGRAPH
-0x957A	0x5E03	#CJK UNIFIED IDEOGRAPH
-0x957B	0x5E9C	#CJK UNIFIED IDEOGRAPH
-0x957C	0x6016	#CJK UNIFIED IDEOGRAPH
-0x957D	0x6276	#CJK UNIFIED IDEOGRAPH
-0x957E	0x6577	#CJK UNIFIED IDEOGRAPH
-0x9580	0x65A7	#CJK UNIFIED IDEOGRAPH
-0x9581	0x666E	#CJK UNIFIED IDEOGRAPH
-0x9582	0x6D6E	#CJK UNIFIED IDEOGRAPH
-0x9583	0x7236	#CJK UNIFIED IDEOGRAPH
-0x9584	0x7B26	#CJK UNIFIED IDEOGRAPH
-0x9585	0x8150	#CJK UNIFIED IDEOGRAPH
-0x9586	0x819A	#CJK UNIFIED IDEOGRAPH
-0x9587	0x8299	#CJK UNIFIED IDEOGRAPH
-0x9588	0x8B5C	#CJK UNIFIED IDEOGRAPH
-0x9589	0x8CA0	#CJK UNIFIED IDEOGRAPH
-0x958A	0x8CE6	#CJK UNIFIED IDEOGRAPH
-0x958B	0x8D74	#CJK UNIFIED IDEOGRAPH
-0x958C	0x961C	#CJK UNIFIED IDEOGRAPH
-0x958D	0x9644	#CJK UNIFIED IDEOGRAPH
-0x958E	0x4FAE	#CJK UNIFIED IDEOGRAPH
-0x958F	0x64AB	#CJK UNIFIED IDEOGRAPH
-0x9590	0x6B66	#CJK UNIFIED IDEOGRAPH
-0x9591	0x821E	#CJK UNIFIED IDEOGRAPH
-0x9592	0x8461	#CJK UNIFIED IDEOGRAPH
-0x9593	0x856A	#CJK UNIFIED IDEOGRAPH
-0x9594	0x90E8	#CJK UNIFIED IDEOGRAPH
-0x9595	0x5C01	#CJK UNIFIED IDEOGRAPH
-0x9596	0x6953	#CJK UNIFIED IDEOGRAPH
-0x9597	0x98A8	#CJK UNIFIED IDEOGRAPH
-0x9598	0x847A	#CJK UNIFIED IDEOGRAPH
-0x9599	0x8557	#CJK UNIFIED IDEOGRAPH
-0x959A	0x4F0F	#CJK UNIFIED IDEOGRAPH
-0x959B	0x526F	#CJK UNIFIED IDEOGRAPH
-0x959C	0x5FA9	#CJK UNIFIED IDEOGRAPH
-0x959D	0x5E45	#CJK UNIFIED IDEOGRAPH
-0x959E	0x670D	#CJK UNIFIED IDEOGRAPH
-0x959F	0x798F	#CJK UNIFIED IDEOGRAPH
-0x95A0	0x8179	#CJK UNIFIED IDEOGRAPH
-0x95A1	0x8907	#CJK UNIFIED IDEOGRAPH
-0x95A2	0x8986	#CJK UNIFIED IDEOGRAPH
-0x95A3	0x6DF5	#CJK UNIFIED IDEOGRAPH
-0x95A4	0x5F17	#CJK UNIFIED IDEOGRAPH
-0x95A5	0x6255	#CJK UNIFIED IDEOGRAPH
-0x95A6	0x6CB8	#CJK UNIFIED IDEOGRAPH
-0x95A7	0x4ECF	#CJK UNIFIED IDEOGRAPH
-0x95A8	0x7269	#CJK UNIFIED IDEOGRAPH
-0x95A9	0x9B92	#CJK UNIFIED IDEOGRAPH
-0x95AA	0x5206	#CJK UNIFIED IDEOGRAPH
-0x95AB	0x543B	#CJK UNIFIED IDEOGRAPH
-0x95AC	0x5674	#CJK UNIFIED IDEOGRAPH
-0x95AD	0x58B3	#CJK UNIFIED IDEOGRAPH
-0x95AE	0x61A4	#CJK UNIFIED IDEOGRAPH
-0x95AF	0x626E	#CJK UNIFIED IDEOGRAPH
-0x95B0	0x711A	#CJK UNIFIED IDEOGRAPH
-0x95B1	0x596E	#CJK UNIFIED IDEOGRAPH
-0x95B2	0x7C89	#CJK UNIFIED IDEOGRAPH
-0x95B3	0x7CDE	#CJK UNIFIED IDEOGRAPH
-0x95B4	0x7D1B	#CJK UNIFIED IDEOGRAPH
-0x95B5	0x96F0	#CJK UNIFIED IDEOGRAPH
-0x95B6	0x6587	#CJK UNIFIED IDEOGRAPH
-0x95B7	0x805E	#CJK UNIFIED IDEOGRAPH
-0x95B8	0x4E19	#CJK UNIFIED IDEOGRAPH
-0x95B9	0x4F75	#CJK UNIFIED IDEOGRAPH
-0x95BA	0x5175	#CJK UNIFIED IDEOGRAPH
-0x95BB	0x5840	#CJK UNIFIED IDEOGRAPH
-0x95BC	0x5E63	#CJK UNIFIED IDEOGRAPH
-0x95BD	0x5E73	#CJK UNIFIED IDEOGRAPH
-0x95BE	0x5F0A	#CJK UNIFIED IDEOGRAPH
-0x95BF	0x67C4	#CJK UNIFIED IDEOGRAPH
-0x95C0	0x4E26	#CJK UNIFIED IDEOGRAPH
-0x95C1	0x853D	#CJK UNIFIED IDEOGRAPH
-0x95C2	0x9589	#CJK UNIFIED IDEOGRAPH
-0x95C3	0x965B	#CJK UNIFIED IDEOGRAPH
-0x95C4	0x7C73	#CJK UNIFIED IDEOGRAPH
-0x95C5	0x9801	#CJK UNIFIED IDEOGRAPH
-0x95C6	0x50FB	#CJK UNIFIED IDEOGRAPH
-0x95C7	0x58C1	#CJK UNIFIED IDEOGRAPH
-0x95C8	0x7656	#CJK UNIFIED IDEOGRAPH
-0x95C9	0x78A7	#CJK UNIFIED IDEOGRAPH
-0x95CA	0x5225	#CJK UNIFIED IDEOGRAPH
-0x95CB	0x77A5	#CJK UNIFIED IDEOGRAPH
-0x95CC	0x8511	#CJK UNIFIED IDEOGRAPH
-0x95CD	0x7B86	#CJK UNIFIED IDEOGRAPH
-0x95CE	0x504F	#CJK UNIFIED IDEOGRAPH
-0x95CF	0x5909	#CJK UNIFIED IDEOGRAPH
-0x95D0	0x7247	#CJK UNIFIED IDEOGRAPH
-0x95D1	0x7BC7	#CJK UNIFIED IDEOGRAPH
-0x95D2	0x7DE8	#CJK UNIFIED IDEOGRAPH
-0x95D3	0x8FBA	#CJK UNIFIED IDEOGRAPH
-0x95D4	0x8FD4	#CJK UNIFIED IDEOGRAPH
-0x95D5	0x904D	#CJK UNIFIED IDEOGRAPH
-0x95D6	0x4FBF	#CJK UNIFIED IDEOGRAPH
-0x95D7	0x52C9	#CJK UNIFIED IDEOGRAPH
-0x95D8	0x5A29	#CJK UNIFIED IDEOGRAPH
-0x95D9	0x5F01	#CJK UNIFIED IDEOGRAPH
-0x95DA	0x97AD	#CJK UNIFIED IDEOGRAPH
-0x95DB	0x4FDD	#CJK UNIFIED IDEOGRAPH
-0x95DC	0x8217	#CJK UNIFIED IDEOGRAPH
-0x95DD	0x92EA	#CJK UNIFIED IDEOGRAPH
-0x95DE	0x5703	#CJK UNIFIED IDEOGRAPH
-0x95DF	0x6355	#CJK UNIFIED IDEOGRAPH
-0x95E0	0x6B69	#CJK UNIFIED IDEOGRAPH
-0x95E1	0x752B	#CJK UNIFIED IDEOGRAPH
-0x95E2	0x88DC	#CJK UNIFIED IDEOGRAPH
-0x95E3	0x8F14	#CJK UNIFIED IDEOGRAPH
-0x95E4	0x7A42	#CJK UNIFIED IDEOGRAPH
-0x95E5	0x52DF	#CJK UNIFIED IDEOGRAPH
-0x95E6	0x5893	#CJK UNIFIED IDEOGRAPH
-0x95E7	0x6155	#CJK UNIFIED IDEOGRAPH
-0x95E8	0x620A	#CJK UNIFIED IDEOGRAPH
-0x95E9	0x66AE	#CJK UNIFIED IDEOGRAPH
-0x95EA	0x6BCD	#CJK UNIFIED IDEOGRAPH
-0x95EB	0x7C3F	#CJK UNIFIED IDEOGRAPH
-0x95EC	0x83E9	#CJK UNIFIED IDEOGRAPH
-0x95ED	0x5023	#CJK UNIFIED IDEOGRAPH
-0x95EE	0x4FF8	#CJK UNIFIED IDEOGRAPH
-0x95EF	0x5305	#CJK UNIFIED IDEOGRAPH
-0x95F0	0x5446	#CJK UNIFIED IDEOGRAPH
-0x95F1	0x5831	#CJK UNIFIED IDEOGRAPH
-0x95F2	0x5949	#CJK UNIFIED IDEOGRAPH
-0x95F3	0x5B9D	#CJK UNIFIED IDEOGRAPH
-0x95F4	0x5CF0	#CJK UNIFIED IDEOGRAPH
-0x95F5	0x5CEF	#CJK UNIFIED IDEOGRAPH
-0x95F6	0x5D29	#CJK UNIFIED IDEOGRAPH
-0x95F7	0x5E96	#CJK UNIFIED IDEOGRAPH
-0x95F8	0x62B1	#CJK UNIFIED IDEOGRAPH
-0x95F9	0x6367	#CJK UNIFIED IDEOGRAPH
-0x95FA	0x653E	#CJK UNIFIED IDEOGRAPH
-0x95FB	0x65B9	#CJK UNIFIED IDEOGRAPH
-0x95FC	0x670B	#CJK UNIFIED IDEOGRAPH
-0x9640	0x6CD5	#CJK UNIFIED IDEOGRAPH
-0x9641	0x6CE1	#CJK UNIFIED IDEOGRAPH
-0x9642	0x70F9	#CJK UNIFIED IDEOGRAPH
-0x9643	0x7832	#CJK UNIFIED IDEOGRAPH
-0x9644	0x7E2B	#CJK UNIFIED IDEOGRAPH
-0x9645	0x80DE	#CJK UNIFIED IDEOGRAPH
-0x9646	0x82B3	#CJK UNIFIED IDEOGRAPH
-0x9647	0x840C	#CJK UNIFIED IDEOGRAPH
-0x9648	0x84EC	#CJK UNIFIED IDEOGRAPH
-0x9649	0x8702	#CJK UNIFIED IDEOGRAPH
-0x964A	0x8912	#CJK UNIFIED IDEOGRAPH
-0x964B	0x8A2A	#CJK UNIFIED IDEOGRAPH
-0x964C	0x8C4A	#CJK UNIFIED IDEOGRAPH
-0x964D	0x90A6	#CJK UNIFIED IDEOGRAPH
-0x964E	0x92D2	#CJK UNIFIED IDEOGRAPH
-0x964F	0x98FD	#CJK UNIFIED IDEOGRAPH
-0x9650	0x9CF3	#CJK UNIFIED IDEOGRAPH
-0x9651	0x9D6C	#CJK UNIFIED IDEOGRAPH
-0x9652	0x4E4F	#CJK UNIFIED IDEOGRAPH
-0x9653	0x4EA1	#CJK UNIFIED IDEOGRAPH
-0x9654	0x508D	#CJK UNIFIED IDEOGRAPH
-0x9655	0x5256	#CJK UNIFIED IDEOGRAPH
-0x9656	0x574A	#CJK UNIFIED IDEOGRAPH
-0x9657	0x59A8	#CJK UNIFIED IDEOGRAPH
-0x9658	0x5E3D	#CJK UNIFIED IDEOGRAPH
-0x9659	0x5FD8	#CJK UNIFIED IDEOGRAPH
-0x965A	0x5FD9	#CJK UNIFIED IDEOGRAPH
-0x965B	0x623F	#CJK UNIFIED IDEOGRAPH
-0x965C	0x66B4	#CJK UNIFIED IDEOGRAPH
-0x965D	0x671B	#CJK UNIFIED IDEOGRAPH
-0x965E	0x67D0	#CJK UNIFIED IDEOGRAPH
-0x965F	0x68D2	#CJK UNIFIED IDEOGRAPH
-0x9660	0x5192	#CJK UNIFIED IDEOGRAPH
-0x9661	0x7D21	#CJK UNIFIED IDEOGRAPH
-0x9662	0x80AA	#CJK UNIFIED IDEOGRAPH
-0x9663	0x81A8	#CJK UNIFIED IDEOGRAPH
-0x9664	0x8B00	#CJK UNIFIED IDEOGRAPH
-0x9665	0x8C8C	#CJK UNIFIED IDEOGRAPH
-0x9666	0x8CBF	#CJK UNIFIED IDEOGRAPH
-0x9667	0x927E	#CJK UNIFIED IDEOGRAPH
-0x9668	0x9632	#CJK UNIFIED IDEOGRAPH
-0x9669	0x5420	#CJK UNIFIED IDEOGRAPH
-0x966A	0x982C	#CJK UNIFIED IDEOGRAPH
-0x966B	0x5317	#CJK UNIFIED IDEOGRAPH
-0x966C	0x50D5	#CJK UNIFIED IDEOGRAPH
-0x966D	0x535C	#CJK UNIFIED IDEOGRAPH
-0x966E	0x58A8	#CJK UNIFIED IDEOGRAPH
-0x966F	0x64B2	#CJK UNIFIED IDEOGRAPH
-0x9670	0x6734	#CJK UNIFIED IDEOGRAPH
-0x9671	0x7267	#CJK UNIFIED IDEOGRAPH
-0x9672	0x7766	#CJK UNIFIED IDEOGRAPH
-0x9673	0x7A46	#CJK UNIFIED IDEOGRAPH
-0x9674	0x91E6	#CJK UNIFIED IDEOGRAPH
-0x9675	0x52C3	#CJK UNIFIED IDEOGRAPH
-0x9676	0x6CA1	#CJK UNIFIED IDEOGRAPH
-0x9677	0x6B86	#CJK UNIFIED IDEOGRAPH
-0x9678	0x5800	#CJK UNIFIED IDEOGRAPH
-0x9679	0x5E4C	#CJK UNIFIED IDEOGRAPH
-0x967A	0x5954	#CJK UNIFIED IDEOGRAPH
-0x967B	0x672C	#CJK UNIFIED IDEOGRAPH
-0x967C	0x7FFB	#CJK UNIFIED IDEOGRAPH
-0x967D	0x51E1	#CJK UNIFIED IDEOGRAPH
-0x967E	0x76C6	#CJK UNIFIED IDEOGRAPH
-0x9680	0x6469	#CJK UNIFIED IDEOGRAPH
-0x9681	0x78E8	#CJK UNIFIED IDEOGRAPH
-0x9682	0x9B54	#CJK UNIFIED IDEOGRAPH
-0x9683	0x9EBB	#CJK UNIFIED IDEOGRAPH
-0x9684	0x57CB	#CJK UNIFIED IDEOGRAPH
-0x9685	0x59B9	#CJK UNIFIED IDEOGRAPH
-0x9686	0x6627	#CJK UNIFIED IDEOGRAPH
-0x9687	0x679A	#CJK UNIFIED IDEOGRAPH
-0x9688	0x6BCE	#CJK UNIFIED IDEOGRAPH
-0x9689	0x54E9	#CJK UNIFIED IDEOGRAPH
-0x968A	0x69D9	#CJK UNIFIED IDEOGRAPH
-0x968B	0x5E55	#CJK UNIFIED IDEOGRAPH
-0x968C	0x819C	#CJK UNIFIED IDEOGRAPH
-0x968D	0x6795	#CJK UNIFIED IDEOGRAPH
-0x968E	0x9BAA	#CJK UNIFIED IDEOGRAPH
-0x968F	0x67FE	#CJK UNIFIED IDEOGRAPH
-0x9690	0x9C52	#CJK UNIFIED IDEOGRAPH
-0x9691	0x685D	#CJK UNIFIED IDEOGRAPH
-0x9692	0x4EA6	#CJK UNIFIED IDEOGRAPH
-0x9693	0x4FE3	#CJK UNIFIED IDEOGRAPH
-0x9694	0x53C8	#CJK UNIFIED IDEOGRAPH
-0x9695	0x62B9	#CJK UNIFIED IDEOGRAPH
-0x9696	0x672B	#CJK UNIFIED IDEOGRAPH
-0x9697	0x6CAB	#CJK UNIFIED IDEOGRAPH
-0x9698	0x8FC4	#CJK UNIFIED IDEOGRAPH
-0x9699	0x4FAD	#CJK UNIFIED IDEOGRAPH
-0x969A	0x7E6D	#CJK UNIFIED IDEOGRAPH
-0x969B	0x9EBF	#CJK UNIFIED IDEOGRAPH
-0x969C	0x4E07	#CJK UNIFIED IDEOGRAPH
-0x969D	0x6162	#CJK UNIFIED IDEOGRAPH
-0x969E	0x6E80	#CJK UNIFIED IDEOGRAPH
-0x969F	0x6F2B	#CJK UNIFIED IDEOGRAPH
-0x96A0	0x8513	#CJK UNIFIED IDEOGRAPH
-0x96A1	0x5473	#CJK UNIFIED IDEOGRAPH
-0x96A2	0x672A	#CJK UNIFIED IDEOGRAPH
-0x96A3	0x9B45	#CJK UNIFIED IDEOGRAPH
-0x96A4	0x5DF3	#CJK UNIFIED IDEOGRAPH
-0x96A5	0x7B95	#CJK UNIFIED IDEOGRAPH
-0x96A6	0x5CAC	#CJK UNIFIED IDEOGRAPH
-0x96A7	0x5BC6	#CJK UNIFIED IDEOGRAPH
-0x96A8	0x871C	#CJK UNIFIED IDEOGRAPH
-0x96A9	0x6E4A	#CJK UNIFIED IDEOGRAPH
-0x96AA	0x84D1	#CJK UNIFIED IDEOGRAPH
-0x96AB	0x7A14	#CJK UNIFIED IDEOGRAPH
-0x96AC	0x8108	#CJK UNIFIED IDEOGRAPH
-0x96AD	0x5999	#CJK UNIFIED IDEOGRAPH
-0x96AE	0x7C8D	#CJK UNIFIED IDEOGRAPH
-0x96AF	0x6C11	#CJK UNIFIED IDEOGRAPH
-0x96B0	0x7720	#CJK UNIFIED IDEOGRAPH
-0x96B1	0x52D9	#CJK UNIFIED IDEOGRAPH
-0x96B2	0x5922	#CJK UNIFIED IDEOGRAPH
-0x96B3	0x7121	#CJK UNIFIED IDEOGRAPH
-0x96B4	0x725F	#CJK UNIFIED IDEOGRAPH
-0x96B5	0x77DB	#CJK UNIFIED IDEOGRAPH
-0x96B6	0x9727	#CJK UNIFIED IDEOGRAPH
-0x96B7	0x9D61	#CJK UNIFIED IDEOGRAPH
-0x96B8	0x690B	#CJK UNIFIED IDEOGRAPH
-0x96B9	0x5A7F	#CJK UNIFIED IDEOGRAPH
-0x96BA	0x5A18	#CJK UNIFIED IDEOGRAPH
-0x96BB	0x51A5	#CJK UNIFIED IDEOGRAPH
-0x96BC	0x540D	#CJK UNIFIED IDEOGRAPH
-0x96BD	0x547D	#CJK UNIFIED IDEOGRAPH
-0x96BE	0x660E	#CJK UNIFIED IDEOGRAPH
-0x96BF	0x76DF	#CJK UNIFIED IDEOGRAPH
-0x96C0	0x8FF7	#CJK UNIFIED IDEOGRAPH
-0x96C1	0x9298	#CJK UNIFIED IDEOGRAPH
-0x96C2	0x9CF4	#CJK UNIFIED IDEOGRAPH
-0x96C3	0x59EA	#CJK UNIFIED IDEOGRAPH
-0x96C4	0x725D	#CJK UNIFIED IDEOGRAPH
-0x96C5	0x6EC5	#CJK UNIFIED IDEOGRAPH
-0x96C6	0x514D	#CJK UNIFIED IDEOGRAPH
-0x96C7	0x68C9	#CJK UNIFIED IDEOGRAPH
-0x96C8	0x7DBF	#CJK UNIFIED IDEOGRAPH
-0x96C9	0x7DEC	#CJK UNIFIED IDEOGRAPH
-0x96CA	0x9762	#CJK UNIFIED IDEOGRAPH
-0x96CB	0x9EBA	#CJK UNIFIED IDEOGRAPH
-0x96CC	0x6478	#CJK UNIFIED IDEOGRAPH
-0x96CD	0x6A21	#CJK UNIFIED IDEOGRAPH
-0x96CE	0x8302	#CJK UNIFIED IDEOGRAPH
-0x96CF	0x5984	#CJK UNIFIED IDEOGRAPH
-0x96D0	0x5B5F	#CJK UNIFIED IDEOGRAPH
-0x96D1	0x6BDB	#CJK UNIFIED IDEOGRAPH
-0x96D2	0x731B	#CJK UNIFIED IDEOGRAPH
-0x96D3	0x76F2	#CJK UNIFIED IDEOGRAPH
-0x96D4	0x7DB2	#CJK UNIFIED IDEOGRAPH
-0x96D5	0x8017	#CJK UNIFIED IDEOGRAPH
-0x96D6	0x8499	#CJK UNIFIED IDEOGRAPH
-0x96D7	0x5132	#CJK UNIFIED IDEOGRAPH
-0x96D8	0x6728	#CJK UNIFIED IDEOGRAPH
-0x96D9	0x9ED9	#CJK UNIFIED IDEOGRAPH
-0x96DA	0x76EE	#CJK UNIFIED IDEOGRAPH
-0x96DB	0x6762	#CJK UNIFIED IDEOGRAPH
-0x96DC	0x52FF	#CJK UNIFIED IDEOGRAPH
-0x96DD	0x9905	#CJK UNIFIED IDEOGRAPH
-0x96DE	0x5C24	#CJK UNIFIED IDEOGRAPH
-0x96DF	0x623B	#CJK UNIFIED IDEOGRAPH
-0x96E0	0x7C7E	#CJK UNIFIED IDEOGRAPH
-0x96E1	0x8CB0	#CJK UNIFIED IDEOGRAPH
-0x96E2	0x554F	#CJK UNIFIED IDEOGRAPH
-0x96E3	0x60B6	#CJK UNIFIED IDEOGRAPH
-0x96E4	0x7D0B	#CJK UNIFIED IDEOGRAPH
-0x96E5	0x9580	#CJK UNIFIED IDEOGRAPH
-0x96E6	0x5301	#CJK UNIFIED IDEOGRAPH
-0x96E7	0x4E5F	#CJK UNIFIED IDEOGRAPH
-0x96E8	0x51B6	#CJK UNIFIED IDEOGRAPH
-0x96E9	0x591C	#CJK UNIFIED IDEOGRAPH
-0x96EA	0x723A	#CJK UNIFIED IDEOGRAPH
-0x96EB	0x8036	#CJK UNIFIED IDEOGRAPH
-0x96EC	0x91CE	#CJK UNIFIED IDEOGRAPH
-0x96ED	0x5F25	#CJK UNIFIED IDEOGRAPH
-0x96EE	0x77E2	#CJK UNIFIED IDEOGRAPH
-0x96EF	0x5384	#CJK UNIFIED IDEOGRAPH
-0x96F0	0x5F79	#CJK UNIFIED IDEOGRAPH
-0x96F1	0x7D04	#CJK UNIFIED IDEOGRAPH
-0x96F2	0x85AC	#CJK UNIFIED IDEOGRAPH
-0x96F3	0x8A33	#CJK UNIFIED IDEOGRAPH
-0x96F4	0x8E8D	#CJK UNIFIED IDEOGRAPH
-0x96F5	0x9756	#CJK UNIFIED IDEOGRAPH
-0x96F6	0x67F3	#CJK UNIFIED IDEOGRAPH
-0x96F7	0x85AE	#CJK UNIFIED IDEOGRAPH
-0x96F8	0x9453	#CJK UNIFIED IDEOGRAPH
-0x96F9	0x6109	#CJK UNIFIED IDEOGRAPH
-0x96FA	0x6108	#CJK UNIFIED IDEOGRAPH
-0x96FB	0x6CB9	#CJK UNIFIED IDEOGRAPH
-0x96FC	0x7652	#CJK UNIFIED IDEOGRAPH
-0x9740	0x8AED	#CJK UNIFIED IDEOGRAPH
-0x9741	0x8F38	#CJK UNIFIED IDEOGRAPH
-0x9742	0x552F	#CJK UNIFIED IDEOGRAPH
-0x9743	0x4F51	#CJK UNIFIED IDEOGRAPH
-0x9744	0x512A	#CJK UNIFIED IDEOGRAPH
-0x9745	0x52C7	#CJK UNIFIED IDEOGRAPH
-0x9746	0x53CB	#CJK UNIFIED IDEOGRAPH
-0x9747	0x5BA5	#CJK UNIFIED IDEOGRAPH
-0x9748	0x5E7D	#CJK UNIFIED IDEOGRAPH
-0x9749	0x60A0	#CJK UNIFIED IDEOGRAPH
-0x974A	0x6182	#CJK UNIFIED IDEOGRAPH
-0x974B	0x63D6	#CJK UNIFIED IDEOGRAPH
-0x974C	0x6709	#CJK UNIFIED IDEOGRAPH
-0x974D	0x67DA	#CJK UNIFIED IDEOGRAPH
-0x974E	0x6E67	#CJK UNIFIED IDEOGRAPH
-0x974F	0x6D8C	#CJK UNIFIED IDEOGRAPH
-0x9750	0x7336	#CJK UNIFIED IDEOGRAPH
-0x9751	0x7337	#CJK UNIFIED IDEOGRAPH
-0x9752	0x7531	#CJK UNIFIED IDEOGRAPH
-0x9753	0x7950	#CJK UNIFIED IDEOGRAPH
-0x9754	0x88D5	#CJK UNIFIED IDEOGRAPH
-0x9755	0x8A98	#CJK UNIFIED IDEOGRAPH
-0x9756	0x904A	#CJK UNIFIED IDEOGRAPH
-0x9757	0x9091	#CJK UNIFIED IDEOGRAPH
-0x9758	0x90F5	#CJK UNIFIED IDEOGRAPH
-0x9759	0x96C4	#CJK UNIFIED IDEOGRAPH
-0x975A	0x878D	#CJK UNIFIED IDEOGRAPH
-0x975B	0x5915	#CJK UNIFIED IDEOGRAPH
-0x975C	0x4E88	#CJK UNIFIED IDEOGRAPH
-0x975D	0x4F59	#CJK UNIFIED IDEOGRAPH
-0x975E	0x4E0E	#CJK UNIFIED IDEOGRAPH
-0x975F	0x8A89	#CJK UNIFIED IDEOGRAPH
-0x9760	0x8F3F	#CJK UNIFIED IDEOGRAPH
-0x9761	0x9810	#CJK UNIFIED IDEOGRAPH
-0x9762	0x50AD	#CJK UNIFIED IDEOGRAPH
-0x9763	0x5E7C	#CJK UNIFIED IDEOGRAPH
-0x9764	0x5996	#CJK UNIFIED IDEOGRAPH
-0x9765	0x5BB9	#CJK UNIFIED IDEOGRAPH
-0x9766	0x5EB8	#CJK UNIFIED IDEOGRAPH
-0x9767	0x63DA	#CJK UNIFIED IDEOGRAPH
-0x9768	0x63FA	#CJK UNIFIED IDEOGRAPH
-0x9769	0x64C1	#CJK UNIFIED IDEOGRAPH
-0x976A	0x66DC	#CJK UNIFIED IDEOGRAPH
-0x976B	0x694A	#CJK UNIFIED IDEOGRAPH
-0x976C	0x69D8	#CJK UNIFIED IDEOGRAPH
-0x976D	0x6D0B	#CJK UNIFIED IDEOGRAPH
-0x976E	0x6EB6	#CJK UNIFIED IDEOGRAPH
-0x976F	0x7194	#CJK UNIFIED IDEOGRAPH
-0x9770	0x7528	#CJK UNIFIED IDEOGRAPH
-0x9771	0x7AAF	#CJK UNIFIED IDEOGRAPH
-0x9772	0x7F8A	#CJK UNIFIED IDEOGRAPH
-0x9773	0x8000	#CJK UNIFIED IDEOGRAPH
-0x9774	0x8449	#CJK UNIFIED IDEOGRAPH
-0x9775	0x84C9	#CJK UNIFIED IDEOGRAPH
-0x9776	0x8981	#CJK UNIFIED IDEOGRAPH
-0x9777	0x8B21	#CJK UNIFIED IDEOGRAPH
-0x9778	0x8E0A	#CJK UNIFIED IDEOGRAPH
-0x9779	0x9065	#CJK UNIFIED IDEOGRAPH
-0x977A	0x967D	#CJK UNIFIED IDEOGRAPH
-0x977B	0x990A	#CJK UNIFIED IDEOGRAPH
-0x977C	0x617E	#CJK UNIFIED IDEOGRAPH
-0x977D	0x6291	#CJK UNIFIED IDEOGRAPH
-0x977E	0x6B32	#CJK UNIFIED IDEOGRAPH
-0x9780	0x6C83	#CJK UNIFIED IDEOGRAPH
-0x9781	0x6D74	#CJK UNIFIED IDEOGRAPH
-0x9782	0x7FCC	#CJK UNIFIED IDEOGRAPH
-0x9783	0x7FFC	#CJK UNIFIED IDEOGRAPH
-0x9784	0x6DC0	#CJK UNIFIED IDEOGRAPH
-0x9785	0x7F85	#CJK UNIFIED IDEOGRAPH
-0x9786	0x87BA	#CJK UNIFIED IDEOGRAPH
-0x9787	0x88F8	#CJK UNIFIED IDEOGRAPH
-0x9788	0x6765	#CJK UNIFIED IDEOGRAPH
-0x9789	0x83B1	#CJK UNIFIED IDEOGRAPH
-0x978A	0x983C	#CJK UNIFIED IDEOGRAPH
-0x978B	0x96F7	#CJK UNIFIED IDEOGRAPH
-0x978C	0x6D1B	#CJK UNIFIED IDEOGRAPH
-0x978D	0x7D61	#CJK UNIFIED IDEOGRAPH
-0x978E	0x843D	#CJK UNIFIED IDEOGRAPH
-0x978F	0x916A	#CJK UNIFIED IDEOGRAPH
-0x9790	0x4E71	#CJK UNIFIED IDEOGRAPH
-0x9791	0x5375	#CJK UNIFIED IDEOGRAPH
-0x9792	0x5D50	#CJK UNIFIED IDEOGRAPH
-0x9793	0x6B04	#CJK UNIFIED IDEOGRAPH
-0x9794	0x6FEB	#CJK UNIFIED IDEOGRAPH
-0x9795	0x85CD	#CJK UNIFIED IDEOGRAPH
-0x9796	0x862D	#CJK UNIFIED IDEOGRAPH
-0x9797	0x89A7	#CJK UNIFIED IDEOGRAPH
-0x9798	0x5229	#CJK UNIFIED IDEOGRAPH
-0x9799	0x540F	#CJK UNIFIED IDEOGRAPH
-0x979A	0x5C65	#CJK UNIFIED IDEOGRAPH
-0x979B	0x674E	#CJK UNIFIED IDEOGRAPH
-0x979C	0x68A8	#CJK UNIFIED IDEOGRAPH
-0x979D	0x7406	#CJK UNIFIED IDEOGRAPH
-0x979E	0x7483	#CJK UNIFIED IDEOGRAPH
-0x979F	0x75E2	#CJK UNIFIED IDEOGRAPH
-0x97A0	0x88CF	#CJK UNIFIED IDEOGRAPH
-0x97A1	0x88E1	#CJK UNIFIED IDEOGRAPH
-0x97A2	0x91CC	#CJK UNIFIED IDEOGRAPH
-0x97A3	0x96E2	#CJK UNIFIED IDEOGRAPH
-0x97A4	0x9678	#CJK UNIFIED IDEOGRAPH
-0x97A5	0x5F8B	#CJK UNIFIED IDEOGRAPH
-0x97A6	0x7387	#CJK UNIFIED IDEOGRAPH
-0x97A7	0x7ACB	#CJK UNIFIED IDEOGRAPH
-0x97A8	0x844E	#CJK UNIFIED IDEOGRAPH
-0x97A9	0x63A0	#CJK UNIFIED IDEOGRAPH
-0x97AA	0x7565	#CJK UNIFIED IDEOGRAPH
-0x97AB	0x5289	#CJK UNIFIED IDEOGRAPH
-0x97AC	0x6D41	#CJK UNIFIED IDEOGRAPH
-0x97AD	0x6E9C	#CJK UNIFIED IDEOGRAPH
-0x97AE	0x7409	#CJK UNIFIED IDEOGRAPH
-0x97AF	0x7559	#CJK UNIFIED IDEOGRAPH
-0x97B0	0x786B	#CJK UNIFIED IDEOGRAPH
-0x97B1	0x7C92	#CJK UNIFIED IDEOGRAPH
-0x97B2	0x9686	#CJK UNIFIED IDEOGRAPH
-0x97B3	0x7ADC	#CJK UNIFIED IDEOGRAPH
-0x97B4	0x9F8D	#CJK UNIFIED IDEOGRAPH
-0x97B5	0x4FB6	#CJK UNIFIED IDEOGRAPH
-0x97B6	0x616E	#CJK UNIFIED IDEOGRAPH
-0x97B7	0x65C5	#CJK UNIFIED IDEOGRAPH
-0x97B8	0x865C	#CJK UNIFIED IDEOGRAPH
-0x97B9	0x4E86	#CJK UNIFIED IDEOGRAPH
-0x97BA	0x4EAE	#CJK UNIFIED IDEOGRAPH
-0x97BB	0x50DA	#CJK UNIFIED IDEOGRAPH
-0x97BC	0x4E21	#CJK UNIFIED IDEOGRAPH
-0x97BD	0x51CC	#CJK UNIFIED IDEOGRAPH
-0x97BE	0x5BEE	#CJK UNIFIED IDEOGRAPH
-0x97BF	0x6599	#CJK UNIFIED IDEOGRAPH
-0x97C0	0x6881	#CJK UNIFIED IDEOGRAPH
-0x97C1	0x6DBC	#CJK UNIFIED IDEOGRAPH
-0x97C2	0x731F	#CJK UNIFIED IDEOGRAPH
-0x97C3	0x7642	#CJK UNIFIED IDEOGRAPH
-0x97C4	0x77AD	#CJK UNIFIED IDEOGRAPH
-0x97C5	0x7A1C	#CJK UNIFIED IDEOGRAPH
-0x97C6	0x7CE7	#CJK UNIFIED IDEOGRAPH
-0x97C7	0x826F	#CJK UNIFIED IDEOGRAPH
-0x97C8	0x8AD2	#CJK UNIFIED IDEOGRAPH
-0x97C9	0x907C	#CJK UNIFIED IDEOGRAPH
-0x97CA	0x91CF	#CJK UNIFIED IDEOGRAPH
-0x97CB	0x9675	#CJK UNIFIED IDEOGRAPH
-0x97CC	0x9818	#CJK UNIFIED IDEOGRAPH
-0x97CD	0x529B	#CJK UNIFIED IDEOGRAPH
-0x97CE	0x7DD1	#CJK UNIFIED IDEOGRAPH
-0x97CF	0x502B	#CJK UNIFIED IDEOGRAPH
-0x97D0	0x5398	#CJK UNIFIED IDEOGRAPH
-0x97D1	0x6797	#CJK UNIFIED IDEOGRAPH
-0x97D2	0x6DCB	#CJK UNIFIED IDEOGRAPH
-0x97D3	0x71D0	#CJK UNIFIED IDEOGRAPH
-0x97D4	0x7433	#CJK UNIFIED IDEOGRAPH
-0x97D5	0x81E8	#CJK UNIFIED IDEOGRAPH
-0x97D6	0x8F2A	#CJK UNIFIED IDEOGRAPH
-0x97D7	0x96A3	#CJK UNIFIED IDEOGRAPH
-0x97D8	0x9C57	#CJK UNIFIED IDEOGRAPH
-0x97D9	0x9E9F	#CJK UNIFIED IDEOGRAPH
-0x97DA	0x7460	#CJK UNIFIED IDEOGRAPH
-0x97DB	0x5841	#CJK UNIFIED IDEOGRAPH
-0x97DC	0x6D99	#CJK UNIFIED IDEOGRAPH
-0x97DD	0x7D2F	#CJK UNIFIED IDEOGRAPH
-0x97DE	0x985E	#CJK UNIFIED IDEOGRAPH
-0x97DF	0x4EE4	#CJK UNIFIED IDEOGRAPH
-0x97E0	0x4F36	#CJK UNIFIED IDEOGRAPH
-0x97E1	0x4F8B	#CJK UNIFIED IDEOGRAPH
-0x97E2	0x51B7	#CJK UNIFIED IDEOGRAPH
-0x97E3	0x52B1	#CJK UNIFIED IDEOGRAPH
-0x97E4	0x5DBA	#CJK UNIFIED IDEOGRAPH
-0x97E5	0x601C	#CJK UNIFIED IDEOGRAPH
-0x97E6	0x73B2	#CJK UNIFIED IDEOGRAPH
-0x97E7	0x793C	#CJK UNIFIED IDEOGRAPH
-0x97E8	0x82D3	#CJK UNIFIED IDEOGRAPH
-0x97E9	0x9234	#CJK UNIFIED IDEOGRAPH
-0x97EA	0x96B7	#CJK UNIFIED IDEOGRAPH
-0x97EB	0x96F6	#CJK UNIFIED IDEOGRAPH
-0x97EC	0x970A	#CJK UNIFIED IDEOGRAPH
-0x97ED	0x9E97	#CJK UNIFIED IDEOGRAPH
-0x97EE	0x9F62	#CJK UNIFIED IDEOGRAPH
-0x97EF	0x66A6	#CJK UNIFIED IDEOGRAPH
-0x97F0	0x6B74	#CJK UNIFIED IDEOGRAPH
-0x97F1	0x5217	#CJK UNIFIED IDEOGRAPH
-0x97F2	0x52A3	#CJK UNIFIED IDEOGRAPH
-0x97F3	0x70C8	#CJK UNIFIED IDEOGRAPH
-0x97F4	0x88C2	#CJK UNIFIED IDEOGRAPH
-0x97F5	0x5EC9	#CJK UNIFIED IDEOGRAPH
-0x97F6	0x604B	#CJK UNIFIED IDEOGRAPH
-0x97F7	0x6190	#CJK UNIFIED IDEOGRAPH
-0x97F8	0x6F23	#CJK UNIFIED IDEOGRAPH
-0x97F9	0x7149	#CJK UNIFIED IDEOGRAPH
-0x97FA	0x7C3E	#CJK UNIFIED IDEOGRAPH
-0x97FB	0x7DF4	#CJK UNIFIED IDEOGRAPH
-0x97FC	0x806F	#CJK UNIFIED IDEOGRAPH
-0x9840	0x84EE	#CJK UNIFIED IDEOGRAPH
-0x9841	0x9023	#CJK UNIFIED IDEOGRAPH
-0x9842	0x932C	#CJK UNIFIED IDEOGRAPH
-0x9843	0x5442	#CJK UNIFIED IDEOGRAPH
-0x9844	0x9B6F	#CJK UNIFIED IDEOGRAPH
-0x9845	0x6AD3	#CJK UNIFIED IDEOGRAPH
-0x9846	0x7089	#CJK UNIFIED IDEOGRAPH
-0x9847	0x8CC2	#CJK UNIFIED IDEOGRAPH
-0x9848	0x8DEF	#CJK UNIFIED IDEOGRAPH
-0x9849	0x9732	#CJK UNIFIED IDEOGRAPH
-0x984A	0x52B4	#CJK UNIFIED IDEOGRAPH
-0x984B	0x5A41	#CJK UNIFIED IDEOGRAPH
-0x984C	0x5ECA	#CJK UNIFIED IDEOGRAPH
-0x984D	0x5F04	#CJK UNIFIED IDEOGRAPH
-0x984E	0x6717	#CJK UNIFIED IDEOGRAPH
-0x984F	0x697C	#CJK UNIFIED IDEOGRAPH
-0x9850	0x6994	#CJK UNIFIED IDEOGRAPH
-0x9851	0x6D6A	#CJK UNIFIED IDEOGRAPH
-0x9852	0x6F0F	#CJK UNIFIED IDEOGRAPH
-0x9853	0x7262	#CJK UNIFIED IDEOGRAPH
-0x9854	0x72FC	#CJK UNIFIED IDEOGRAPH
-0x9855	0x7BED	#CJK UNIFIED IDEOGRAPH
-0x9856	0x8001	#CJK UNIFIED IDEOGRAPH
-0x9857	0x807E	#CJK UNIFIED IDEOGRAPH
-0x9858	0x874B	#CJK UNIFIED IDEOGRAPH
-0x9859	0x90CE	#CJK UNIFIED IDEOGRAPH
-0x985A	0x516D	#CJK UNIFIED IDEOGRAPH
-0x985B	0x9E93	#CJK UNIFIED IDEOGRAPH
-0x985C	0x7984	#CJK UNIFIED IDEOGRAPH
-0x985D	0x808B	#CJK UNIFIED IDEOGRAPH
-0x985E	0x9332	#CJK UNIFIED IDEOGRAPH
-0x985F	0x8AD6	#CJK UNIFIED IDEOGRAPH
-0x9860	0x502D	#CJK UNIFIED IDEOGRAPH
-0x9861	0x548C	#CJK UNIFIED IDEOGRAPH
-0x9862	0x8A71	#CJK UNIFIED IDEOGRAPH
-0x9863	0x6B6A	#CJK UNIFIED IDEOGRAPH
-0x9864	0x8CC4	#CJK UNIFIED IDEOGRAPH
-0x9865	0x8107	#CJK UNIFIED IDEOGRAPH
-0x9866	0x60D1	#CJK UNIFIED IDEOGRAPH
-0x9867	0x67A0	#CJK UNIFIED IDEOGRAPH
-0x9868	0x9DF2	#CJK UNIFIED IDEOGRAPH
-0x9869	0x4E99	#CJK UNIFIED IDEOGRAPH
-0x986A	0x4E98	#CJK UNIFIED IDEOGRAPH
-0x986B	0x9C10	#CJK UNIFIED IDEOGRAPH
-0x986C	0x8A6B	#CJK UNIFIED IDEOGRAPH
-0x986D	0x85C1	#CJK UNIFIED IDEOGRAPH
-0x986E	0x8568	#CJK UNIFIED IDEOGRAPH
-0x986F	0x6900	#CJK UNIFIED IDEOGRAPH
-0x9870	0x6E7E	#CJK UNIFIED IDEOGRAPH
-0x9871	0x7897	#CJK UNIFIED IDEOGRAPH
-0x9872	0x8155	#CJK UNIFIED IDEOGRAPH
-0x989F	0x5F0C	#CJK UNIFIED IDEOGRAPH
-0x98A0	0x4E10	#CJK UNIFIED IDEOGRAPH
-0x98A1	0x4E15	#CJK UNIFIED IDEOGRAPH
-0x98A2	0x4E2A	#CJK UNIFIED IDEOGRAPH
-0x98A3	0x4E31	#CJK UNIFIED IDEOGRAPH
-0x98A4	0x4E36	#CJK UNIFIED IDEOGRAPH
-0x98A5	0x4E3C	#CJK UNIFIED IDEOGRAPH
-0x98A6	0x4E3F	#CJK UNIFIED IDEOGRAPH
-0x98A7	0x4E42	#CJK UNIFIED IDEOGRAPH
-0x98A8	0x4E56	#CJK UNIFIED IDEOGRAPH
-0x98A9	0x4E58	#CJK UNIFIED IDEOGRAPH
-0x98AA	0x4E82	#CJK UNIFIED IDEOGRAPH
-0x98AB	0x4E85	#CJK UNIFIED IDEOGRAPH
-0x98AC	0x8C6B	#CJK UNIFIED IDEOGRAPH
-0x98AD	0x4E8A	#CJK UNIFIED IDEOGRAPH
-0x98AE	0x8212	#CJK UNIFIED IDEOGRAPH
-0x98AF	0x5F0D	#CJK UNIFIED IDEOGRAPH
-0x98B0	0x4E8E	#CJK UNIFIED IDEOGRAPH
-0x98B1	0x4E9E	#CJK UNIFIED IDEOGRAPH
-0x98B2	0x4E9F	#CJK UNIFIED IDEOGRAPH
-0x98B3	0x4EA0	#CJK UNIFIED IDEOGRAPH
-0x98B4	0x4EA2	#CJK UNIFIED IDEOGRAPH
-0x98B5	0x4EB0	#CJK UNIFIED IDEOGRAPH
-0x98B6	0x4EB3	#CJK UNIFIED IDEOGRAPH
-0x98B7	0x4EB6	#CJK UNIFIED IDEOGRAPH
-0x98B8	0x4ECE	#CJK UNIFIED IDEOGRAPH
-0x98B9	0x4ECD	#CJK UNIFIED IDEOGRAPH
-0x98BA	0x4EC4	#CJK UNIFIED IDEOGRAPH
-0x98BB	0x4EC6	#CJK UNIFIED IDEOGRAPH
-0x98BC	0x4EC2	#CJK UNIFIED IDEOGRAPH
-0x98BD	0x4ED7	#CJK UNIFIED IDEOGRAPH
-0x98BE	0x4EDE	#CJK UNIFIED IDEOGRAPH
-0x98BF	0x4EED	#CJK UNIFIED IDEOGRAPH
-0x98C0	0x4EDF	#CJK UNIFIED IDEOGRAPH
-0x98C1	0x4EF7	#CJK UNIFIED IDEOGRAPH
-0x98C2	0x4F09	#CJK UNIFIED IDEOGRAPH
-0x98C3	0x4F5A	#CJK UNIFIED IDEOGRAPH
-0x98C4	0x4F30	#CJK UNIFIED IDEOGRAPH
-0x98C5	0x4F5B	#CJK UNIFIED IDEOGRAPH
-0x98C6	0x4F5D	#CJK UNIFIED IDEOGRAPH
-0x98C7	0x4F57	#CJK UNIFIED IDEOGRAPH
-0x98C8	0x4F47	#CJK UNIFIED IDEOGRAPH
-0x98C9	0x4F76	#CJK UNIFIED IDEOGRAPH
-0x98CA	0x4F88	#CJK UNIFIED IDEOGRAPH
-0x98CB	0x4F8F	#CJK UNIFIED IDEOGRAPH
-0x98CC	0x4F98	#CJK UNIFIED IDEOGRAPH
-0x98CD	0x4F7B	#CJK UNIFIED IDEOGRAPH
-0x98CE	0x4F69	#CJK UNIFIED IDEOGRAPH
-0x98CF	0x4F70	#CJK UNIFIED IDEOGRAPH
-0x98D0	0x4F91	#CJK UNIFIED IDEOGRAPH
-0x98D1	0x4F6F	#CJK UNIFIED IDEOGRAPH
-0x98D2	0x4F86	#CJK UNIFIED IDEOGRAPH
-0x98D3	0x4F96	#CJK UNIFIED IDEOGRAPH
-0x98D4	0x5118	#CJK UNIFIED IDEOGRAPH
-0x98D5	0x4FD4	#CJK UNIFIED IDEOGRAPH
-0x98D6	0x4FDF	#CJK UNIFIED IDEOGRAPH
-0x98D7	0x4FCE	#CJK UNIFIED IDEOGRAPH
-0x98D8	0x4FD8	#CJK UNIFIED IDEOGRAPH
-0x98D9	0x4FDB	#CJK UNIFIED IDEOGRAPH
-0x98DA	0x4FD1	#CJK UNIFIED IDEOGRAPH
-0x98DB	0x4FDA	#CJK UNIFIED IDEOGRAPH
-0x98DC	0x4FD0	#CJK UNIFIED IDEOGRAPH
-0x98DD	0x4FE4	#CJK UNIFIED IDEOGRAPH
-0x98DE	0x4FE5	#CJK UNIFIED IDEOGRAPH
-0x98DF	0x501A	#CJK UNIFIED IDEOGRAPH
-0x98E0	0x5028	#CJK UNIFIED IDEOGRAPH
-0x98E1	0x5014	#CJK UNIFIED IDEOGRAPH
-0x98E2	0x502A	#CJK UNIFIED IDEOGRAPH
-0x98E3	0x5025	#CJK UNIFIED IDEOGRAPH
-0x98E4	0x5005	#CJK UNIFIED IDEOGRAPH
-0x98E5	0x4F1C	#CJK UNIFIED IDEOGRAPH
-0x98E6	0x4FF6	#CJK UNIFIED IDEOGRAPH
-0x98E7	0x5021	#CJK UNIFIED IDEOGRAPH
-0x98E8	0x5029	#CJK UNIFIED IDEOGRAPH
-0x98E9	0x502C	#CJK UNIFIED IDEOGRAPH
-0x98EA	0x4FFE	#CJK UNIFIED IDEOGRAPH
-0x98EB	0x4FEF	#CJK UNIFIED IDEOGRAPH
-0x98EC	0x5011	#CJK UNIFIED IDEOGRAPH
-0x98ED	0x5006	#CJK UNIFIED IDEOGRAPH
-0x98EE	0x5043	#CJK UNIFIED IDEOGRAPH
-0x98EF	0x5047	#CJK UNIFIED IDEOGRAPH
-0x98F0	0x6703	#CJK UNIFIED IDEOGRAPH
-0x98F1	0x5055	#CJK UNIFIED IDEOGRAPH
-0x98F2	0x5050	#CJK UNIFIED IDEOGRAPH
-0x98F3	0x5048	#CJK UNIFIED IDEOGRAPH
-0x98F4	0x505A	#CJK UNIFIED IDEOGRAPH
-0x98F5	0x5056	#CJK UNIFIED IDEOGRAPH
-0x98F6	0x506C	#CJK UNIFIED IDEOGRAPH
-0x98F7	0x5078	#CJK UNIFIED IDEOGRAPH
-0x98F8	0x5080	#CJK UNIFIED IDEOGRAPH
-0x98F9	0x509A	#CJK UNIFIED IDEOGRAPH
-0x98FA	0x5085	#CJK UNIFIED IDEOGRAPH
-0x98FB	0x50B4	#CJK UNIFIED IDEOGRAPH
-0x98FC	0x50B2	#CJK UNIFIED IDEOGRAPH
-0x9940	0x50C9	#CJK UNIFIED IDEOGRAPH
-0x9941	0x50CA	#CJK UNIFIED IDEOGRAPH
-0x9942	0x50B3	#CJK UNIFIED IDEOGRAPH
-0x9943	0x50C2	#CJK UNIFIED IDEOGRAPH
-0x9944	0x50D6	#CJK UNIFIED IDEOGRAPH
-0x9945	0x50DE	#CJK UNIFIED IDEOGRAPH
-0x9946	0x50E5	#CJK UNIFIED IDEOGRAPH
-0x9947	0x50ED	#CJK UNIFIED IDEOGRAPH
-0x9948	0x50E3	#CJK UNIFIED IDEOGRAPH
-0x9949	0x50EE	#CJK UNIFIED IDEOGRAPH
-0x994A	0x50F9	#CJK UNIFIED IDEOGRAPH
-0x994B	0x50F5	#CJK UNIFIED IDEOGRAPH
-0x994C	0x5109	#CJK UNIFIED IDEOGRAPH
-0x994D	0x5101	#CJK UNIFIED IDEOGRAPH
-0x994E	0x5102	#CJK UNIFIED IDEOGRAPH
-0x994F	0x5116	#CJK UNIFIED IDEOGRAPH
-0x9950	0x5115	#CJK UNIFIED IDEOGRAPH
-0x9951	0x5114	#CJK UNIFIED IDEOGRAPH
-0x9952	0x511A	#CJK UNIFIED IDEOGRAPH
-0x9953	0x5121	#CJK UNIFIED IDEOGRAPH
-0x9954	0x513A	#CJK UNIFIED IDEOGRAPH
-0x9955	0x5137	#CJK UNIFIED IDEOGRAPH
-0x9956	0x513C	#CJK UNIFIED IDEOGRAPH
-0x9957	0x513B	#CJK UNIFIED IDEOGRAPH
-0x9958	0x513F	#CJK UNIFIED IDEOGRAPH
-0x9959	0x5140	#CJK UNIFIED IDEOGRAPH
-0x995A	0x5152	#CJK UNIFIED IDEOGRAPH
-0x995B	0x514C	#CJK UNIFIED IDEOGRAPH
-0x995C	0x5154	#CJK UNIFIED IDEOGRAPH
-0x995D	0x5162	#CJK UNIFIED IDEOGRAPH
-0x995E	0x7AF8	#CJK UNIFIED IDEOGRAPH
-0x995F	0x5169	#CJK UNIFIED IDEOGRAPH
-0x9960	0x516A	#CJK UNIFIED IDEOGRAPH
-0x9961	0x516E	#CJK UNIFIED IDEOGRAPH
-0x9962	0x5180	#CJK UNIFIED IDEOGRAPH
-0x9963	0x5182	#CJK UNIFIED IDEOGRAPH
-0x9964	0x56D8	#CJK UNIFIED IDEOGRAPH
-0x9965	0x518C	#CJK UNIFIED IDEOGRAPH
-0x9966	0x5189	#CJK UNIFIED IDEOGRAPH
-0x9967	0x518F	#CJK UNIFIED IDEOGRAPH
-0x9968	0x5191	#CJK UNIFIED IDEOGRAPH
-0x9969	0x5193	#CJK UNIFIED IDEOGRAPH
-0x996A	0x5195	#CJK UNIFIED IDEOGRAPH
-0x996B	0x5196	#CJK UNIFIED IDEOGRAPH
-0x996C	0x51A4	#CJK UNIFIED IDEOGRAPH
-0x996D	0x51A6	#CJK UNIFIED IDEOGRAPH
-0x996E	0x51A2	#CJK UNIFIED IDEOGRAPH
-0x996F	0x51A9	#CJK UNIFIED IDEOGRAPH
-0x9970	0x51AA	#CJK UNIFIED IDEOGRAPH
-0x9971	0x51AB	#CJK UNIFIED IDEOGRAPH
-0x9972	0x51B3	#CJK UNIFIED IDEOGRAPH
-0x9973	0x51B1	#CJK UNIFIED IDEOGRAPH
-0x9974	0x51B2	#CJK UNIFIED IDEOGRAPH
-0x9975	0x51B0	#CJK UNIFIED IDEOGRAPH
-0x9976	0x51B5	#CJK UNIFIED IDEOGRAPH
-0x9977	0x51BD	#CJK UNIFIED IDEOGRAPH
-0x9978	0x51C5	#CJK UNIFIED IDEOGRAPH
-0x9979	0x51C9	#CJK UNIFIED IDEOGRAPH
-0x997A	0x51DB	#CJK UNIFIED IDEOGRAPH
-0x997B	0x51E0	#CJK UNIFIED IDEOGRAPH
-0x997C	0x8655	#CJK UNIFIED IDEOGRAPH
-0x997D	0x51E9	#CJK UNIFIED IDEOGRAPH
-0x997E	0x51ED	#CJK UNIFIED IDEOGRAPH
-0x9980	0x51F0	#CJK UNIFIED IDEOGRAPH
-0x9981	0x51F5	#CJK UNIFIED IDEOGRAPH
-0x9982	0x51FE	#CJK UNIFIED IDEOGRAPH
-0x9983	0x5204	#CJK UNIFIED IDEOGRAPH
-0x9984	0x520B	#CJK UNIFIED IDEOGRAPH
-0x9985	0x5214	#CJK UNIFIED IDEOGRAPH
-0x9986	0x520E	#CJK UNIFIED IDEOGRAPH
-0x9987	0x5227	#CJK UNIFIED IDEOGRAPH
-0x9988	0x522A	#CJK UNIFIED IDEOGRAPH
-0x9989	0x522E	#CJK UNIFIED IDEOGRAPH
-0x998A	0x5233	#CJK UNIFIED IDEOGRAPH
-0x998B	0x5239	#CJK UNIFIED IDEOGRAPH
-0x998C	0x524F	#CJK UNIFIED IDEOGRAPH
-0x998D	0x5244	#CJK UNIFIED IDEOGRAPH
-0x998E	0x524B	#CJK UNIFIED IDEOGRAPH
-0x998F	0x524C	#CJK UNIFIED IDEOGRAPH
-0x9990	0x525E	#CJK UNIFIED IDEOGRAPH
-0x9991	0x5254	#CJK UNIFIED IDEOGRAPH
-0x9992	0x526A	#CJK UNIFIED IDEOGRAPH
-0x9993	0x5274	#CJK UNIFIED IDEOGRAPH
-0x9994	0x5269	#CJK UNIFIED IDEOGRAPH
-0x9995	0x5273	#CJK UNIFIED IDEOGRAPH
-0x9996	0x527F	#CJK UNIFIED IDEOGRAPH
-0x9997	0x527D	#CJK UNIFIED IDEOGRAPH
-0x9998	0x528D	#CJK UNIFIED IDEOGRAPH
-0x9999	0x5294	#CJK UNIFIED IDEOGRAPH
-0x999A	0x5292	#CJK UNIFIED IDEOGRAPH
-0x999B	0x5271	#CJK UNIFIED IDEOGRAPH
-0x999C	0x5288	#CJK UNIFIED IDEOGRAPH
-0x999D	0x5291	#CJK UNIFIED IDEOGRAPH
-0x999E	0x8FA8	#CJK UNIFIED IDEOGRAPH
-0x999F	0x8FA7	#CJK UNIFIED IDEOGRAPH
-0x99A0	0x52AC	#CJK UNIFIED IDEOGRAPH
-0x99A1	0x52AD	#CJK UNIFIED IDEOGRAPH
-0x99A2	0x52BC	#CJK UNIFIED IDEOGRAPH
-0x99A3	0x52B5	#CJK UNIFIED IDEOGRAPH
-0x99A4	0x52C1	#CJK UNIFIED IDEOGRAPH
-0x99A5	0x52CD	#CJK UNIFIED IDEOGRAPH
-0x99A6	0x52D7	#CJK UNIFIED IDEOGRAPH
-0x99A7	0x52DE	#CJK UNIFIED IDEOGRAPH
-0x99A8	0x52E3	#CJK UNIFIED IDEOGRAPH
-0x99A9	0x52E6	#CJK UNIFIED IDEOGRAPH
-0x99AA	0x98ED	#CJK UNIFIED IDEOGRAPH
-0x99AB	0x52E0	#CJK UNIFIED IDEOGRAPH
-0x99AC	0x52F3	#CJK UNIFIED IDEOGRAPH
-0x99AD	0x52F5	#CJK UNIFIED IDEOGRAPH
-0x99AE	0x52F8	#CJK UNIFIED IDEOGRAPH
-0x99AF	0x52F9	#CJK UNIFIED IDEOGRAPH
-0x99B0	0x5306	#CJK UNIFIED IDEOGRAPH
-0x99B1	0x5308	#CJK UNIFIED IDEOGRAPH
-0x99B2	0x7538	#CJK UNIFIED IDEOGRAPH
-0x99B3	0x530D	#CJK UNIFIED IDEOGRAPH
-0x99B4	0x5310	#CJK UNIFIED IDEOGRAPH
-0x99B5	0x530F	#CJK UNIFIED IDEOGRAPH
-0x99B6	0x5315	#CJK UNIFIED IDEOGRAPH
-0x99B7	0x531A	#CJK UNIFIED IDEOGRAPH
-0x99B8	0x5323	#CJK UNIFIED IDEOGRAPH
-0x99B9	0x532F	#CJK UNIFIED IDEOGRAPH
-0x99BA	0x5331	#CJK UNIFIED IDEOGRAPH
-0x99BB	0x5333	#CJK UNIFIED IDEOGRAPH
-0x99BC	0x5338	#CJK UNIFIED IDEOGRAPH
-0x99BD	0x5340	#CJK UNIFIED IDEOGRAPH
-0x99BE	0x5346	#CJK UNIFIED IDEOGRAPH
-0x99BF	0x5345	#CJK UNIFIED IDEOGRAPH
-0x99C0	0x4E17	#CJK UNIFIED IDEOGRAPH
-0x99C1	0x5349	#CJK UNIFIED IDEOGRAPH
-0x99C2	0x534D	#CJK UNIFIED IDEOGRAPH
-0x99C3	0x51D6	#CJK UNIFIED IDEOGRAPH
-0x99C4	0x535E	#CJK UNIFIED IDEOGRAPH
-0x99C5	0x5369	#CJK UNIFIED IDEOGRAPH
-0x99C6	0x536E	#CJK UNIFIED IDEOGRAPH
-0x99C7	0x5918	#CJK UNIFIED IDEOGRAPH
-0x99C8	0x537B	#CJK UNIFIED IDEOGRAPH
-0x99C9	0x5377	#CJK UNIFIED IDEOGRAPH
-0x99CA	0x5382	#CJK UNIFIED IDEOGRAPH
-0x99CB	0x5396	#CJK UNIFIED IDEOGRAPH
-0x99CC	0x53A0	#CJK UNIFIED IDEOGRAPH
-0x99CD	0x53A6	#CJK UNIFIED IDEOGRAPH
-0x99CE	0x53A5	#CJK UNIFIED IDEOGRAPH
-0x99CF	0x53AE	#CJK UNIFIED IDEOGRAPH
-0x99D0	0x53B0	#CJK UNIFIED IDEOGRAPH
-0x99D1	0x53B6	#CJK UNIFIED IDEOGRAPH
-0x99D2	0x53C3	#CJK UNIFIED IDEOGRAPH
-0x99D3	0x7C12	#CJK UNIFIED IDEOGRAPH
-0x99D4	0x96D9	#CJK UNIFIED IDEOGRAPH
-0x99D5	0x53DF	#CJK UNIFIED IDEOGRAPH
-0x99D6	0x66FC	#CJK UNIFIED IDEOGRAPH
-0x99D7	0x71EE	#CJK UNIFIED IDEOGRAPH
-0x99D8	0x53EE	#CJK UNIFIED IDEOGRAPH
-0x99D9	0x53E8	#CJK UNIFIED IDEOGRAPH
-0x99DA	0x53ED	#CJK UNIFIED IDEOGRAPH
-0x99DB	0x53FA	#CJK UNIFIED IDEOGRAPH
-0x99DC	0x5401	#CJK UNIFIED IDEOGRAPH
-0x99DD	0x543D	#CJK UNIFIED IDEOGRAPH
-0x99DE	0x5440	#CJK UNIFIED IDEOGRAPH
-0x99DF	0x542C	#CJK UNIFIED IDEOGRAPH
-0x99E0	0x542D	#CJK UNIFIED IDEOGRAPH
-0x99E1	0x543C	#CJK UNIFIED IDEOGRAPH
-0x99E2	0x542E	#CJK UNIFIED IDEOGRAPH
-0x99E3	0x5436	#CJK UNIFIED IDEOGRAPH
-0x99E4	0x5429	#CJK UNIFIED IDEOGRAPH
-0x99E5	0x541D	#CJK UNIFIED IDEOGRAPH
-0x99E6	0x544E	#CJK UNIFIED IDEOGRAPH
-0x99E7	0x548F	#CJK UNIFIED IDEOGRAPH
-0x99E8	0x5475	#CJK UNIFIED IDEOGRAPH
-0x99E9	0x548E	#CJK UNIFIED IDEOGRAPH
-0x99EA	0x545F	#CJK UNIFIED IDEOGRAPH
-0x99EB	0x5471	#CJK UNIFIED IDEOGRAPH
-0x99EC	0x5477	#CJK UNIFIED IDEOGRAPH
-0x99ED	0x5470	#CJK UNIFIED IDEOGRAPH
-0x99EE	0x5492	#CJK UNIFIED IDEOGRAPH
-0x99EF	0x547B	#CJK UNIFIED IDEOGRAPH
-0x99F0	0x5480	#CJK UNIFIED IDEOGRAPH
-0x99F1	0x5476	#CJK UNIFIED IDEOGRAPH
-0x99F2	0x5484	#CJK UNIFIED IDEOGRAPH
-0x99F3	0x5490	#CJK UNIFIED IDEOGRAPH
-0x99F4	0x5486	#CJK UNIFIED IDEOGRAPH
-0x99F5	0x54C7	#CJK UNIFIED IDEOGRAPH
-0x99F6	0x54A2	#CJK UNIFIED IDEOGRAPH
-0x99F7	0x54B8	#CJK UNIFIED IDEOGRAPH
-0x99F8	0x54A5	#CJK UNIFIED IDEOGRAPH
-0x99F9	0x54AC	#CJK UNIFIED IDEOGRAPH
-0x99FA	0x54C4	#CJK UNIFIED IDEOGRAPH
-0x99FB	0x54C8	#CJK UNIFIED IDEOGRAPH
-0x99FC	0x54A8	#CJK UNIFIED IDEOGRAPH
-0x9A40	0x54AB	#CJK UNIFIED IDEOGRAPH
-0x9A41	0x54C2	#CJK UNIFIED IDEOGRAPH
-0x9A42	0x54A4	#CJK UNIFIED IDEOGRAPH
-0x9A43	0x54BE	#CJK UNIFIED IDEOGRAPH
-0x9A44	0x54BC	#CJK UNIFIED IDEOGRAPH
-0x9A45	0x54D8	#CJK UNIFIED IDEOGRAPH
-0x9A46	0x54E5	#CJK UNIFIED IDEOGRAPH
-0x9A47	0x54E6	#CJK UNIFIED IDEOGRAPH
-0x9A48	0x550F	#CJK UNIFIED IDEOGRAPH
-0x9A49	0x5514	#CJK UNIFIED IDEOGRAPH
-0x9A4A	0x54FD	#CJK UNIFIED IDEOGRAPH
-0x9A4B	0x54EE	#CJK UNIFIED IDEOGRAPH
-0x9A4C	0x54ED	#CJK UNIFIED IDEOGRAPH
-0x9A4D	0x54FA	#CJK UNIFIED IDEOGRAPH
-0x9A4E	0x54E2	#CJK UNIFIED IDEOGRAPH
-0x9A4F	0x5539	#CJK UNIFIED IDEOGRAPH
-0x9A50	0x5540	#CJK UNIFIED IDEOGRAPH
-0x9A51	0x5563	#CJK UNIFIED IDEOGRAPH
-0x9A52	0x554C	#CJK UNIFIED IDEOGRAPH
-0x9A53	0x552E	#CJK UNIFIED IDEOGRAPH
-0x9A54	0x555C	#CJK UNIFIED IDEOGRAPH
-0x9A55	0x5545	#CJK UNIFIED IDEOGRAPH
-0x9A56	0x5556	#CJK UNIFIED IDEOGRAPH
-0x9A57	0x5557	#CJK UNIFIED IDEOGRAPH
-0x9A58	0x5538	#CJK UNIFIED IDEOGRAPH
-0x9A59	0x5533	#CJK UNIFIED IDEOGRAPH
-0x9A5A	0x555D	#CJK UNIFIED IDEOGRAPH
-0x9A5B	0x5599	#CJK UNIFIED IDEOGRAPH
-0x9A5C	0x5580	#CJK UNIFIED IDEOGRAPH
-0x9A5D	0x54AF	#CJK UNIFIED IDEOGRAPH
-0x9A5E	0x558A	#CJK UNIFIED IDEOGRAPH
-0x9A5F	0x559F	#CJK UNIFIED IDEOGRAPH
-0x9A60	0x557B	#CJK UNIFIED IDEOGRAPH
-0x9A61	0x557E	#CJK UNIFIED IDEOGRAPH
-0x9A62	0x5598	#CJK UNIFIED IDEOGRAPH
-0x9A63	0x559E	#CJK UNIFIED IDEOGRAPH
-0x9A64	0x55AE	#CJK UNIFIED IDEOGRAPH
-0x9A65	0x557C	#CJK UNIFIED IDEOGRAPH
-0x9A66	0x5583	#CJK UNIFIED IDEOGRAPH
-0x9A67	0x55A9	#CJK UNIFIED IDEOGRAPH
-0x9A68	0x5587	#CJK UNIFIED IDEOGRAPH
-0x9A69	0x55A8	#CJK UNIFIED IDEOGRAPH
-0x9A6A	0x55DA	#CJK UNIFIED IDEOGRAPH
-0x9A6B	0x55C5	#CJK UNIFIED IDEOGRAPH
-0x9A6C	0x55DF	#CJK UNIFIED IDEOGRAPH
-0x9A6D	0x55C4	#CJK UNIFIED IDEOGRAPH
-0x9A6E	0x55DC	#CJK UNIFIED IDEOGRAPH
-0x9A6F	0x55E4	#CJK UNIFIED IDEOGRAPH
-0x9A70	0x55D4	#CJK UNIFIED IDEOGRAPH
-0x9A71	0x5614	#CJK UNIFIED IDEOGRAPH
-0x9A72	0x55F7	#CJK UNIFIED IDEOGRAPH
-0x9A73	0x5616	#CJK UNIFIED IDEOGRAPH
-0x9A74	0x55FE	#CJK UNIFIED IDEOGRAPH
-0x9A75	0x55FD	#CJK UNIFIED IDEOGRAPH
-0x9A76	0x561B	#CJK UNIFIED IDEOGRAPH
-0x9A77	0x55F9	#CJK UNIFIED IDEOGRAPH
-0x9A78	0x564E	#CJK UNIFIED IDEOGRAPH
-0x9A79	0x5650	#CJK UNIFIED IDEOGRAPH
-0x9A7A	0x71DF	#CJK UNIFIED IDEOGRAPH
-0x9A7B	0x5634	#CJK UNIFIED IDEOGRAPH
-0x9A7C	0x5636	#CJK UNIFIED IDEOGRAPH
-0x9A7D	0x5632	#CJK UNIFIED IDEOGRAPH
-0x9A7E	0x5638	#CJK UNIFIED IDEOGRAPH
-0x9A80	0x566B	#CJK UNIFIED IDEOGRAPH
-0x9A81	0x5664	#CJK UNIFIED IDEOGRAPH
-0x9A82	0x562F	#CJK UNIFIED IDEOGRAPH
-0x9A83	0x566C	#CJK UNIFIED IDEOGRAPH
-0x9A84	0x566A	#CJK UNIFIED IDEOGRAPH
-0x9A85	0x5686	#CJK UNIFIED IDEOGRAPH
-0x9A86	0x5680	#CJK UNIFIED IDEOGRAPH
-0x9A87	0x568A	#CJK UNIFIED IDEOGRAPH
-0x9A88	0x56A0	#CJK UNIFIED IDEOGRAPH
-0x9A89	0x5694	#CJK UNIFIED IDEOGRAPH
-0x9A8A	0x568F	#CJK UNIFIED IDEOGRAPH
-0x9A8B	0x56A5	#CJK UNIFIED IDEOGRAPH
-0x9A8C	0x56AE	#CJK UNIFIED IDEOGRAPH
-0x9A8D	0x56B6	#CJK UNIFIED IDEOGRAPH
-0x9A8E	0x56B4	#CJK UNIFIED IDEOGRAPH
-0x9A8F	0x56C2	#CJK UNIFIED IDEOGRAPH
-0x9A90	0x56BC	#CJK UNIFIED IDEOGRAPH
-0x9A91	0x56C1	#CJK UNIFIED IDEOGRAPH
-0x9A92	0x56C3	#CJK UNIFIED IDEOGRAPH
-0x9A93	0x56C0	#CJK UNIFIED IDEOGRAPH
-0x9A94	0x56C8	#CJK UNIFIED IDEOGRAPH
-0x9A95	0x56CE	#CJK UNIFIED IDEOGRAPH
-0x9A96	0x56D1	#CJK UNIFIED IDEOGRAPH
-0x9A97	0x56D3	#CJK UNIFIED IDEOGRAPH
-0x9A98	0x56D7	#CJK UNIFIED IDEOGRAPH
-0x9A99	0x56EE	#CJK UNIFIED IDEOGRAPH
-0x9A9A	0x56F9	#CJK UNIFIED IDEOGRAPH
-0x9A9B	0x5700	#CJK UNIFIED IDEOGRAPH
-0x9A9C	0x56FF	#CJK UNIFIED IDEOGRAPH
-0x9A9D	0x5704	#CJK UNIFIED IDEOGRAPH
-0x9A9E	0x5709	#CJK UNIFIED IDEOGRAPH
-0x9A9F	0x5708	#CJK UNIFIED IDEOGRAPH
-0x9AA0	0x570B	#CJK UNIFIED IDEOGRAPH
-0x9AA1	0x570D	#CJK UNIFIED IDEOGRAPH
-0x9AA2	0x5713	#CJK UNIFIED IDEOGRAPH
-0x9AA3	0x5718	#CJK UNIFIED IDEOGRAPH
-0x9AA4	0x5716	#CJK UNIFIED IDEOGRAPH
-0x9AA5	0x55C7	#CJK UNIFIED IDEOGRAPH
-0x9AA6	0x571C	#CJK UNIFIED IDEOGRAPH
-0x9AA7	0x5726	#CJK UNIFIED IDEOGRAPH
-0x9AA8	0x5737	#CJK UNIFIED IDEOGRAPH
-0x9AA9	0x5738	#CJK UNIFIED IDEOGRAPH
-0x9AAA	0x574E	#CJK UNIFIED IDEOGRAPH
-0x9AAB	0x573B	#CJK UNIFIED IDEOGRAPH
-0x9AAC	0x5740	#CJK UNIFIED IDEOGRAPH
-0x9AAD	0x574F	#CJK UNIFIED IDEOGRAPH
-0x9AAE	0x5769	#CJK UNIFIED IDEOGRAPH
-0x9AAF	0x57C0	#CJK UNIFIED IDEOGRAPH
-0x9AB0	0x5788	#CJK UNIFIED IDEOGRAPH
-0x9AB1	0x5761	#CJK UNIFIED IDEOGRAPH
-0x9AB2	0x577F	#CJK UNIFIED IDEOGRAPH
-0x9AB3	0x5789	#CJK UNIFIED IDEOGRAPH
-0x9AB4	0x5793	#CJK UNIFIED IDEOGRAPH
-0x9AB5	0x57A0	#CJK UNIFIED IDEOGRAPH
-0x9AB6	0x57B3	#CJK UNIFIED IDEOGRAPH
-0x9AB7	0x57A4	#CJK UNIFIED IDEOGRAPH
-0x9AB8	0x57AA	#CJK UNIFIED IDEOGRAPH
-0x9AB9	0x57B0	#CJK UNIFIED IDEOGRAPH
-0x9ABA	0x57C3	#CJK UNIFIED IDEOGRAPH
-0x9ABB	0x57C6	#CJK UNIFIED IDEOGRAPH
-0x9ABC	0x57D4	#CJK UNIFIED IDEOGRAPH
-0x9ABD	0x57D2	#CJK UNIFIED IDEOGRAPH
-0x9ABE	0x57D3	#CJK UNIFIED IDEOGRAPH
-0x9ABF	0x580A	#CJK UNIFIED IDEOGRAPH
-0x9AC0	0x57D6	#CJK UNIFIED IDEOGRAPH
-0x9AC1	0x57E3	#CJK UNIFIED IDEOGRAPH
-0x9AC2	0x580B	#CJK UNIFIED IDEOGRAPH
-0x9AC3	0x5819	#CJK UNIFIED IDEOGRAPH
-0x9AC4	0x581D	#CJK UNIFIED IDEOGRAPH
-0x9AC5	0x5872	#CJK UNIFIED IDEOGRAPH
-0x9AC6	0x5821	#CJK UNIFIED IDEOGRAPH
-0x9AC7	0x5862	#CJK UNIFIED IDEOGRAPH
-0x9AC8	0x584B	#CJK UNIFIED IDEOGRAPH
-0x9AC9	0x5870	#CJK UNIFIED IDEOGRAPH
-0x9ACA	0x6BC0	#CJK UNIFIED IDEOGRAPH
-0x9ACB	0x5852	#CJK UNIFIED IDEOGRAPH
-0x9ACC	0x583D	#CJK UNIFIED IDEOGRAPH
-0x9ACD	0x5879	#CJK UNIFIED IDEOGRAPH
-0x9ACE	0x5885	#CJK UNIFIED IDEOGRAPH
-0x9ACF	0x58B9	#CJK UNIFIED IDEOGRAPH
-0x9AD0	0x589F	#CJK UNIFIED IDEOGRAPH
-0x9AD1	0x58AB	#CJK UNIFIED IDEOGRAPH
-0x9AD2	0x58BA	#CJK UNIFIED IDEOGRAPH
-0x9AD3	0x58DE	#CJK UNIFIED IDEOGRAPH
-0x9AD4	0x58BB	#CJK UNIFIED IDEOGRAPH
-0x9AD5	0x58B8	#CJK UNIFIED IDEOGRAPH
-0x9AD6	0x58AE	#CJK UNIFIED IDEOGRAPH
-0x9AD7	0x58C5	#CJK UNIFIED IDEOGRAPH
-0x9AD8	0x58D3	#CJK UNIFIED IDEOGRAPH
-0x9AD9	0x58D1	#CJK UNIFIED IDEOGRAPH
-0x9ADA	0x58D7	#CJK UNIFIED IDEOGRAPH
-0x9ADB	0x58D9	#CJK UNIFIED IDEOGRAPH
-0x9ADC	0x58D8	#CJK UNIFIED IDEOGRAPH
-0x9ADD	0x58E5	#CJK UNIFIED IDEOGRAPH
-0x9ADE	0x58DC	#CJK UNIFIED IDEOGRAPH
-0x9ADF	0x58E4	#CJK UNIFIED IDEOGRAPH
-0x9AE0	0x58DF	#CJK UNIFIED IDEOGRAPH
-0x9AE1	0x58EF	#CJK UNIFIED IDEOGRAPH
-0x9AE2	0x58FA	#CJK UNIFIED IDEOGRAPH
-0x9AE3	0x58F9	#CJK UNIFIED IDEOGRAPH
-0x9AE4	0x58FB	#CJK UNIFIED IDEOGRAPH
-0x9AE5	0x58FC	#CJK UNIFIED IDEOGRAPH
-0x9AE6	0x58FD	#CJK UNIFIED IDEOGRAPH
-0x9AE7	0x5902	#CJK UNIFIED IDEOGRAPH
-0x9AE8	0x590A	#CJK UNIFIED IDEOGRAPH
-0x9AE9	0x5910	#CJK UNIFIED IDEOGRAPH
-0x9AEA	0x591B	#CJK UNIFIED IDEOGRAPH
-0x9AEB	0x68A6	#CJK UNIFIED IDEOGRAPH
-0x9AEC	0x5925	#CJK UNIFIED IDEOGRAPH
-0x9AED	0x592C	#CJK UNIFIED IDEOGRAPH
-0x9AEE	0x592D	#CJK UNIFIED IDEOGRAPH
-0x9AEF	0x5932	#CJK UNIFIED IDEOGRAPH
-0x9AF0	0x5938	#CJK UNIFIED IDEOGRAPH
-0x9AF1	0x593E	#CJK UNIFIED IDEOGRAPH
-0x9AF2	0x7AD2	#CJK UNIFIED IDEOGRAPH
-0x9AF3	0x5955	#CJK UNIFIED IDEOGRAPH
-0x9AF4	0x5950	#CJK UNIFIED IDEOGRAPH
-0x9AF5	0x594E	#CJK UNIFIED IDEOGRAPH
-0x9AF6	0x595A	#CJK UNIFIED IDEOGRAPH
-0x9AF7	0x5958	#CJK UNIFIED IDEOGRAPH
-0x9AF8	0x5962	#CJK UNIFIED IDEOGRAPH
-0x9AF9	0x5960	#CJK UNIFIED IDEOGRAPH
-0x9AFA	0x5967	#CJK UNIFIED IDEOGRAPH
-0x9AFB	0x596C	#CJK UNIFIED IDEOGRAPH
-0x9AFC	0x5969	#CJK UNIFIED IDEOGRAPH
-0x9B40	0x5978	#CJK UNIFIED IDEOGRAPH
-0x9B41	0x5981	#CJK UNIFIED IDEOGRAPH
-0x9B42	0x599D	#CJK UNIFIED IDEOGRAPH
-0x9B43	0x4F5E	#CJK UNIFIED IDEOGRAPH
-0x9B44	0x4FAB	#CJK UNIFIED IDEOGRAPH
-0x9B45	0x59A3	#CJK UNIFIED IDEOGRAPH
-0x9B46	0x59B2	#CJK UNIFIED IDEOGRAPH
-0x9B47	0x59C6	#CJK UNIFIED IDEOGRAPH
-0x9B48	0x59E8	#CJK UNIFIED IDEOGRAPH
-0x9B49	0x59DC	#CJK UNIFIED IDEOGRAPH
-0x9B4A	0x598D	#CJK UNIFIED IDEOGRAPH
-0x9B4B	0x59D9	#CJK UNIFIED IDEOGRAPH
-0x9B4C	0x59DA	#CJK UNIFIED IDEOGRAPH
-0x9B4D	0x5A25	#CJK UNIFIED IDEOGRAPH
-0x9B4E	0x5A1F	#CJK UNIFIED IDEOGRAPH
-0x9B4F	0x5A11	#CJK UNIFIED IDEOGRAPH
-0x9B50	0x5A1C	#CJK UNIFIED IDEOGRAPH
-0x9B51	0x5A09	#CJK UNIFIED IDEOGRAPH
-0x9B52	0x5A1A	#CJK UNIFIED IDEOGRAPH
-0x9B53	0x5A40	#CJK UNIFIED IDEOGRAPH
-0x9B54	0x5A6C	#CJK UNIFIED IDEOGRAPH
-0x9B55	0x5A49	#CJK UNIFIED IDEOGRAPH
-0x9B56	0x5A35	#CJK UNIFIED IDEOGRAPH
-0x9B57	0x5A36	#CJK UNIFIED IDEOGRAPH
-0x9B58	0x5A62	#CJK UNIFIED IDEOGRAPH
-0x9B59	0x5A6A	#CJK UNIFIED IDEOGRAPH
-0x9B5A	0x5A9A	#CJK UNIFIED IDEOGRAPH
-0x9B5B	0x5ABC	#CJK UNIFIED IDEOGRAPH
-0x9B5C	0x5ABE	#CJK UNIFIED IDEOGRAPH
-0x9B5D	0x5ACB	#CJK UNIFIED IDEOGRAPH
-0x9B5E	0x5AC2	#CJK UNIFIED IDEOGRAPH
-0x9B5F	0x5ABD	#CJK UNIFIED IDEOGRAPH
-0x9B60	0x5AE3	#CJK UNIFIED IDEOGRAPH
-0x9B61	0x5AD7	#CJK UNIFIED IDEOGRAPH
-0x9B62	0x5AE6	#CJK UNIFIED IDEOGRAPH
-0x9B63	0x5AE9	#CJK UNIFIED IDEOGRAPH
-0x9B64	0x5AD6	#CJK UNIFIED IDEOGRAPH
-0x9B65	0x5AFA	#CJK UNIFIED IDEOGRAPH
-0x9B66	0x5AFB	#CJK UNIFIED IDEOGRAPH
-0x9B67	0x5B0C	#CJK UNIFIED IDEOGRAPH
-0x9B68	0x5B0B	#CJK UNIFIED IDEOGRAPH
-0x9B69	0x5B16	#CJK UNIFIED IDEOGRAPH
-0x9B6A	0x5B32	#CJK UNIFIED IDEOGRAPH
-0x9B6B	0x5AD0	#CJK UNIFIED IDEOGRAPH
-0x9B6C	0x5B2A	#CJK UNIFIED IDEOGRAPH
-0x9B6D	0x5B36	#CJK UNIFIED IDEOGRAPH
-0x9B6E	0x5B3E	#CJK UNIFIED IDEOGRAPH
-0x9B6F	0x5B43	#CJK UNIFIED IDEOGRAPH
-0x9B70	0x5B45	#CJK UNIFIED IDEOGRAPH
-0x9B71	0x5B40	#CJK UNIFIED IDEOGRAPH
-0x9B72	0x5B51	#CJK UNIFIED IDEOGRAPH
-0x9B73	0x5B55	#CJK UNIFIED IDEOGRAPH
-0x9B74	0x5B5A	#CJK UNIFIED IDEOGRAPH
-0x9B75	0x5B5B	#CJK UNIFIED IDEOGRAPH
-0x9B76	0x5B65	#CJK UNIFIED IDEOGRAPH
-0x9B77	0x5B69	#CJK UNIFIED IDEOGRAPH
-0x9B78	0x5B70	#CJK UNIFIED IDEOGRAPH
-0x9B79	0x5B73	#CJK UNIFIED IDEOGRAPH
-0x9B7A	0x5B75	#CJK UNIFIED IDEOGRAPH
-0x9B7B	0x5B78	#CJK UNIFIED IDEOGRAPH
-0x9B7C	0x6588	#CJK UNIFIED IDEOGRAPH
-0x9B7D	0x5B7A	#CJK UNIFIED IDEOGRAPH
-0x9B7E	0x5B80	#CJK UNIFIED IDEOGRAPH
-0x9B80	0x5B83	#CJK UNIFIED IDEOGRAPH
-0x9B81	0x5BA6	#CJK UNIFIED IDEOGRAPH
-0x9B82	0x5BB8	#CJK UNIFIED IDEOGRAPH
-0x9B83	0x5BC3	#CJK UNIFIED IDEOGRAPH
-0x9B84	0x5BC7	#CJK UNIFIED IDEOGRAPH
-0x9B85	0x5BC9	#CJK UNIFIED IDEOGRAPH
-0x9B86	0x5BD4	#CJK UNIFIED IDEOGRAPH
-0x9B87	0x5BD0	#CJK UNIFIED IDEOGRAPH
-0x9B88	0x5BE4	#CJK UNIFIED IDEOGRAPH
-0x9B89	0x5BE6	#CJK UNIFIED IDEOGRAPH
-0x9B8A	0x5BE2	#CJK UNIFIED IDEOGRAPH
-0x9B8B	0x5BDE	#CJK UNIFIED IDEOGRAPH
-0x9B8C	0x5BE5	#CJK UNIFIED IDEOGRAPH
-0x9B8D	0x5BEB	#CJK UNIFIED IDEOGRAPH
-0x9B8E	0x5BF0	#CJK UNIFIED IDEOGRAPH
-0x9B8F	0x5BF6	#CJK UNIFIED IDEOGRAPH
-0x9B90	0x5BF3	#CJK UNIFIED IDEOGRAPH
-0x9B91	0x5C05	#CJK UNIFIED IDEOGRAPH
-0x9B92	0x5C07	#CJK UNIFIED IDEOGRAPH
-0x9B93	0x5C08	#CJK UNIFIED IDEOGRAPH
-0x9B94	0x5C0D	#CJK UNIFIED IDEOGRAPH
-0x9B95	0x5C13	#CJK UNIFIED IDEOGRAPH
-0x9B96	0x5C20	#CJK UNIFIED IDEOGRAPH
-0x9B97	0x5C22	#CJK UNIFIED IDEOGRAPH
-0x9B98	0x5C28	#CJK UNIFIED IDEOGRAPH
-0x9B99	0x5C38	#CJK UNIFIED IDEOGRAPH
-0x9B9A	0x5C39	#CJK UNIFIED IDEOGRAPH
-0x9B9B	0x5C41	#CJK UNIFIED IDEOGRAPH
-0x9B9C	0x5C46	#CJK UNIFIED IDEOGRAPH
-0x9B9D	0x5C4E	#CJK UNIFIED IDEOGRAPH
-0x9B9E	0x5C53	#CJK UNIFIED IDEOGRAPH
-0x9B9F	0x5C50	#CJK UNIFIED IDEOGRAPH
-0x9BA0	0x5C4F	#CJK UNIFIED IDEOGRAPH
-0x9BA1	0x5B71	#CJK UNIFIED IDEOGRAPH
-0x9BA2	0x5C6C	#CJK UNIFIED IDEOGRAPH
-0x9BA3	0x5C6E	#CJK UNIFIED IDEOGRAPH
-0x9BA4	0x4E62	#CJK UNIFIED IDEOGRAPH
-0x9BA5	0x5C76	#CJK UNIFIED IDEOGRAPH
-0x9BA6	0x5C79	#CJK UNIFIED IDEOGRAPH
-0x9BA7	0x5C8C	#CJK UNIFIED IDEOGRAPH
-0x9BA8	0x5C91	#CJK UNIFIED IDEOGRAPH
-0x9BA9	0x5C94	#CJK UNIFIED IDEOGRAPH
-0x9BAA	0x599B	#CJK UNIFIED IDEOGRAPH
-0x9BAB	0x5CAB	#CJK UNIFIED IDEOGRAPH
-0x9BAC	0x5CBB	#CJK UNIFIED IDEOGRAPH
-0x9BAD	0x5CB6	#CJK UNIFIED IDEOGRAPH
-0x9BAE	0x5CBC	#CJK UNIFIED IDEOGRAPH
-0x9BAF	0x5CB7	#CJK UNIFIED IDEOGRAPH
-0x9BB0	0x5CC5	#CJK UNIFIED IDEOGRAPH
-0x9BB1	0x5CBE	#CJK UNIFIED IDEOGRAPH
-0x9BB2	0x5CC7	#CJK UNIFIED IDEOGRAPH
-0x9BB3	0x5CD9	#CJK UNIFIED IDEOGRAPH
-0x9BB4	0x5CE9	#CJK UNIFIED IDEOGRAPH
-0x9BB5	0x5CFD	#CJK UNIFIED IDEOGRAPH
-0x9BB6	0x5CFA	#CJK UNIFIED IDEOGRAPH
-0x9BB7	0x5CED	#CJK UNIFIED IDEOGRAPH
-0x9BB8	0x5D8C	#CJK UNIFIED IDEOGRAPH
-0x9BB9	0x5CEA	#CJK UNIFIED IDEOGRAPH
-0x9BBA	0x5D0B	#CJK UNIFIED IDEOGRAPH
-0x9BBB	0x5D15	#CJK UNIFIED IDEOGRAPH
-0x9BBC	0x5D17	#CJK UNIFIED IDEOGRAPH
-0x9BBD	0x5D5C	#CJK UNIFIED IDEOGRAPH
-0x9BBE	0x5D1F	#CJK UNIFIED IDEOGRAPH
-0x9BBF	0x5D1B	#CJK UNIFIED IDEOGRAPH
-0x9BC0	0x5D11	#CJK UNIFIED IDEOGRAPH
-0x9BC1	0x5D14	#CJK UNIFIED IDEOGRAPH
-0x9BC2	0x5D22	#CJK UNIFIED IDEOGRAPH
-0x9BC3	0x5D1A	#CJK UNIFIED IDEOGRAPH
-0x9BC4	0x5D19	#CJK UNIFIED IDEOGRAPH
-0x9BC5	0x5D18	#CJK UNIFIED IDEOGRAPH
-0x9BC6	0x5D4C	#CJK UNIFIED IDEOGRAPH
-0x9BC7	0x5D52	#CJK UNIFIED IDEOGRAPH
-0x9BC8	0x5D4E	#CJK UNIFIED IDEOGRAPH
-0x9BC9	0x5D4B	#CJK UNIFIED IDEOGRAPH
-0x9BCA	0x5D6C	#CJK UNIFIED IDEOGRAPH
-0x9BCB	0x5D73	#CJK UNIFIED IDEOGRAPH
-0x9BCC	0x5D76	#CJK UNIFIED IDEOGRAPH
-0x9BCD	0x5D87	#CJK UNIFIED IDEOGRAPH
-0x9BCE	0x5D84	#CJK UNIFIED IDEOGRAPH
-0x9BCF	0x5D82	#CJK UNIFIED IDEOGRAPH
-0x9BD0	0x5DA2	#CJK UNIFIED IDEOGRAPH
-0x9BD1	0x5D9D	#CJK UNIFIED IDEOGRAPH
-0x9BD2	0x5DAC	#CJK UNIFIED IDEOGRAPH
-0x9BD3	0x5DAE	#CJK UNIFIED IDEOGRAPH
-0x9BD4	0x5DBD	#CJK UNIFIED IDEOGRAPH
-0x9BD5	0x5D90	#CJK UNIFIED IDEOGRAPH
-0x9BD6	0x5DB7	#CJK UNIFIED IDEOGRAPH
-0x9BD7	0x5DBC	#CJK UNIFIED IDEOGRAPH
-0x9BD8	0x5DC9	#CJK UNIFIED IDEOGRAPH
-0x9BD9	0x5DCD	#CJK UNIFIED IDEOGRAPH
-0x9BDA	0x5DD3	#CJK UNIFIED IDEOGRAPH
-0x9BDB	0x5DD2	#CJK UNIFIED IDEOGRAPH
-0x9BDC	0x5DD6	#CJK UNIFIED IDEOGRAPH
-0x9BDD	0x5DDB	#CJK UNIFIED IDEOGRAPH
-0x9BDE	0x5DEB	#CJK UNIFIED IDEOGRAPH
-0x9BDF	0x5DF2	#CJK UNIFIED IDEOGRAPH
-0x9BE0	0x5DF5	#CJK UNIFIED IDEOGRAPH
-0x9BE1	0x5E0B	#CJK UNIFIED IDEOGRAPH
-0x9BE2	0x5E1A	#CJK UNIFIED IDEOGRAPH
-0x9BE3	0x5E19	#CJK UNIFIED IDEOGRAPH
-0x9BE4	0x5E11	#CJK UNIFIED IDEOGRAPH
-0x9BE5	0x5E1B	#CJK UNIFIED IDEOGRAPH
-0x9BE6	0x5E36	#CJK UNIFIED IDEOGRAPH
-0x9BE7	0x5E37	#CJK UNIFIED IDEOGRAPH
-0x9BE8	0x5E44	#CJK UNIFIED IDEOGRAPH
-0x9BE9	0x5E43	#CJK UNIFIED IDEOGRAPH
-0x9BEA	0x5E40	#CJK UNIFIED IDEOGRAPH
-0x9BEB	0x5E4E	#CJK UNIFIED IDEOGRAPH
-0x9BEC	0x5E57	#CJK UNIFIED IDEOGRAPH
-0x9BED	0x5E54	#CJK UNIFIED IDEOGRAPH
-0x9BEE	0x5E5F	#CJK UNIFIED IDEOGRAPH
-0x9BEF	0x5E62	#CJK UNIFIED IDEOGRAPH
-0x9BF0	0x5E64	#CJK UNIFIED IDEOGRAPH
-0x9BF1	0x5E47	#CJK UNIFIED IDEOGRAPH
-0x9BF2	0x5E75	#CJK UNIFIED IDEOGRAPH
-0x9BF3	0x5E76	#CJK UNIFIED IDEOGRAPH
-0x9BF4	0x5E7A	#CJK UNIFIED IDEOGRAPH
-0x9BF5	0x9EBC	#CJK UNIFIED IDEOGRAPH
-0x9BF6	0x5E7F	#CJK UNIFIED IDEOGRAPH
-0x9BF7	0x5EA0	#CJK UNIFIED IDEOGRAPH
-0x9BF8	0x5EC1	#CJK UNIFIED IDEOGRAPH
-0x9BF9	0x5EC2	#CJK UNIFIED IDEOGRAPH
-0x9BFA	0x5EC8	#CJK UNIFIED IDEOGRAPH
-0x9BFB	0x5ED0	#CJK UNIFIED IDEOGRAPH
-0x9BFC	0x5ECF	#CJK UNIFIED IDEOGRAPH
-0x9C40	0x5ED6	#CJK UNIFIED IDEOGRAPH
-0x9C41	0x5EE3	#CJK UNIFIED IDEOGRAPH
-0x9C42	0x5EDD	#CJK UNIFIED IDEOGRAPH
-0x9C43	0x5EDA	#CJK UNIFIED IDEOGRAPH
-0x9C44	0x5EDB	#CJK UNIFIED IDEOGRAPH
-0x9C45	0x5EE2	#CJK UNIFIED IDEOGRAPH
-0x9C46	0x5EE1	#CJK UNIFIED IDEOGRAPH
-0x9C47	0x5EE8	#CJK UNIFIED IDEOGRAPH
-0x9C48	0x5EE9	#CJK UNIFIED IDEOGRAPH
-0x9C49	0x5EEC	#CJK UNIFIED IDEOGRAPH
-0x9C4A	0x5EF1	#CJK UNIFIED IDEOGRAPH
-0x9C4B	0x5EF3	#CJK UNIFIED IDEOGRAPH
-0x9C4C	0x5EF0	#CJK UNIFIED IDEOGRAPH
-0x9C4D	0x5EF4	#CJK UNIFIED IDEOGRAPH
-0x9C4E	0x5EF8	#CJK UNIFIED IDEOGRAPH
-0x9C4F	0x5EFE	#CJK UNIFIED IDEOGRAPH
-0x9C50	0x5F03	#CJK UNIFIED IDEOGRAPH
-0x9C51	0x5F09	#CJK UNIFIED IDEOGRAPH
-0x9C52	0x5F5D	#CJK UNIFIED IDEOGRAPH
-0x9C53	0x5F5C	#CJK UNIFIED IDEOGRAPH
-0x9C54	0x5F0B	#CJK UNIFIED IDEOGRAPH
-0x9C55	0x5F11	#CJK UNIFIED IDEOGRAPH
-0x9C56	0x5F16	#CJK UNIFIED IDEOGRAPH
-0x9C57	0x5F29	#CJK UNIFIED IDEOGRAPH
-0x9C58	0x5F2D	#CJK UNIFIED IDEOGRAPH
-0x9C59	0x5F38	#CJK UNIFIED IDEOGRAPH
-0x9C5A	0x5F41	#CJK UNIFIED IDEOGRAPH
-0x9C5B	0x5F48	#CJK UNIFIED IDEOGRAPH
-0x9C5C	0x5F4C	#CJK UNIFIED IDEOGRAPH
-0x9C5D	0x5F4E	#CJK UNIFIED IDEOGRAPH
-0x9C5E	0x5F2F	#CJK UNIFIED IDEOGRAPH
-0x9C5F	0x5F51	#CJK UNIFIED IDEOGRAPH
-0x9C60	0x5F56	#CJK UNIFIED IDEOGRAPH
-0x9C61	0x5F57	#CJK UNIFIED IDEOGRAPH
-0x9C62	0x5F59	#CJK UNIFIED IDEOGRAPH
-0x9C63	0x5F61	#CJK UNIFIED IDEOGRAPH
-0x9C64	0x5F6D	#CJK UNIFIED IDEOGRAPH
-0x9C65	0x5F73	#CJK UNIFIED IDEOGRAPH
-0x9C66	0x5F77	#CJK UNIFIED IDEOGRAPH
-0x9C67	0x5F83	#CJK UNIFIED IDEOGRAPH
-0x9C68	0x5F82	#CJK UNIFIED IDEOGRAPH
-0x9C69	0x5F7F	#CJK UNIFIED IDEOGRAPH
-0x9C6A	0x5F8A	#CJK UNIFIED IDEOGRAPH
-0x9C6B	0x5F88	#CJK UNIFIED IDEOGRAPH
-0x9C6C	0x5F91	#CJK UNIFIED IDEOGRAPH
-0x9C6D	0x5F87	#CJK UNIFIED IDEOGRAPH
-0x9C6E	0x5F9E	#CJK UNIFIED IDEOGRAPH
-0x9C6F	0x5F99	#CJK UNIFIED IDEOGRAPH
-0x9C70	0x5F98	#CJK UNIFIED IDEOGRAPH
-0x9C71	0x5FA0	#CJK UNIFIED IDEOGRAPH
-0x9C72	0x5FA8	#CJK UNIFIED IDEOGRAPH
-0x9C73	0x5FAD	#CJK UNIFIED IDEOGRAPH
-0x9C74	0x5FBC	#CJK UNIFIED IDEOGRAPH
-0x9C75	0x5FD6	#CJK UNIFIED IDEOGRAPH
-0x9C76	0x5FFB	#CJK UNIFIED IDEOGRAPH
-0x9C77	0x5FE4	#CJK UNIFIED IDEOGRAPH
-0x9C78	0x5FF8	#CJK UNIFIED IDEOGRAPH
-0x9C79	0x5FF1	#CJK UNIFIED IDEOGRAPH
-0x9C7A	0x5FDD	#CJK UNIFIED IDEOGRAPH
-0x9C7B	0x60B3	#CJK UNIFIED IDEOGRAPH
-0x9C7C	0x5FFF	#CJK UNIFIED IDEOGRAPH
-0x9C7D	0x6021	#CJK UNIFIED IDEOGRAPH
-0x9C7E	0x6060	#CJK UNIFIED IDEOGRAPH
-0x9C80	0x6019	#CJK UNIFIED IDEOGRAPH
-0x9C81	0x6010	#CJK UNIFIED IDEOGRAPH
-0x9C82	0x6029	#CJK UNIFIED IDEOGRAPH
-0x9C83	0x600E	#CJK UNIFIED IDEOGRAPH
-0x9C84	0x6031	#CJK UNIFIED IDEOGRAPH
-0x9C85	0x601B	#CJK UNIFIED IDEOGRAPH
-0x9C86	0x6015	#CJK UNIFIED IDEOGRAPH
-0x9C87	0x602B	#CJK UNIFIED IDEOGRAPH
-0x9C88	0x6026	#CJK UNIFIED IDEOGRAPH
-0x9C89	0x600F	#CJK UNIFIED IDEOGRAPH
-0x9C8A	0x603A	#CJK UNIFIED IDEOGRAPH
-0x9C8B	0x605A	#CJK UNIFIED IDEOGRAPH
-0x9C8C	0x6041	#CJK UNIFIED IDEOGRAPH
-0x9C8D	0x606A	#CJK UNIFIED IDEOGRAPH
-0x9C8E	0x6077	#CJK UNIFIED IDEOGRAPH
-0x9C8F	0x605F	#CJK UNIFIED IDEOGRAPH
-0x9C90	0x604A	#CJK UNIFIED IDEOGRAPH
-0x9C91	0x6046	#CJK UNIFIED IDEOGRAPH
-0x9C92	0x604D	#CJK UNIFIED IDEOGRAPH
-0x9C93	0x6063	#CJK UNIFIED IDEOGRAPH
-0x9C94	0x6043	#CJK UNIFIED IDEOGRAPH
-0x9C95	0x6064	#CJK UNIFIED IDEOGRAPH
-0x9C96	0x6042	#CJK UNIFIED IDEOGRAPH
-0x9C97	0x606C	#CJK UNIFIED IDEOGRAPH
-0x9C98	0x606B	#CJK UNIFIED IDEOGRAPH
-0x9C99	0x6059	#CJK UNIFIED IDEOGRAPH
-0x9C9A	0x6081	#CJK UNIFIED IDEOGRAPH
-0x9C9B	0x608D	#CJK UNIFIED IDEOGRAPH
-0x9C9C	0x60E7	#CJK UNIFIED IDEOGRAPH
-0x9C9D	0x6083	#CJK UNIFIED IDEOGRAPH
-0x9C9E	0x609A	#CJK UNIFIED IDEOGRAPH
-0x9C9F	0x6084	#CJK UNIFIED IDEOGRAPH
-0x9CA0	0x609B	#CJK UNIFIED IDEOGRAPH
-0x9CA1	0x6096	#CJK UNIFIED IDEOGRAPH
-0x9CA2	0x6097	#CJK UNIFIED IDEOGRAPH
-0x9CA3	0x6092	#CJK UNIFIED IDEOGRAPH
-0x9CA4	0x60A7	#CJK UNIFIED IDEOGRAPH
-0x9CA5	0x608B	#CJK UNIFIED IDEOGRAPH
-0x9CA6	0x60E1	#CJK UNIFIED IDEOGRAPH
-0x9CA7	0x60B8	#CJK UNIFIED IDEOGRAPH
-0x9CA8	0x60E0	#CJK UNIFIED IDEOGRAPH
-0x9CA9	0x60D3	#CJK UNIFIED IDEOGRAPH
-0x9CAA	0x60B4	#CJK UNIFIED IDEOGRAPH
-0x9CAB	0x5FF0	#CJK UNIFIED IDEOGRAPH
-0x9CAC	0x60BD	#CJK UNIFIED IDEOGRAPH
-0x9CAD	0x60C6	#CJK UNIFIED IDEOGRAPH
-0x9CAE	0x60B5	#CJK UNIFIED IDEOGRAPH
-0x9CAF	0x60D8	#CJK UNIFIED IDEOGRAPH
-0x9CB0	0x614D	#CJK UNIFIED IDEOGRAPH
-0x9CB1	0x6115	#CJK UNIFIED IDEOGRAPH
-0x9CB2	0x6106	#CJK UNIFIED IDEOGRAPH
-0x9CB3	0x60F6	#CJK UNIFIED IDEOGRAPH
-0x9CB4	0x60F7	#CJK UNIFIED IDEOGRAPH
-0x9CB5	0x6100	#CJK UNIFIED IDEOGRAPH
-0x9CB6	0x60F4	#CJK UNIFIED IDEOGRAPH
-0x9CB7	0x60FA	#CJK UNIFIED IDEOGRAPH
-0x9CB8	0x6103	#CJK UNIFIED IDEOGRAPH
-0x9CB9	0x6121	#CJK UNIFIED IDEOGRAPH
-0x9CBA	0x60FB	#CJK UNIFIED IDEOGRAPH
-0x9CBB	0x60F1	#CJK UNIFIED IDEOGRAPH
-0x9CBC	0x610D	#CJK UNIFIED IDEOGRAPH
-0x9CBD	0x610E	#CJK UNIFIED IDEOGRAPH
-0x9CBE	0x6147	#CJK UNIFIED IDEOGRAPH
-0x9CBF	0x613E	#CJK UNIFIED IDEOGRAPH
-0x9CC0	0x6128	#CJK UNIFIED IDEOGRAPH
-0x9CC1	0x6127	#CJK UNIFIED IDEOGRAPH
-0x9CC2	0x614A	#CJK UNIFIED IDEOGRAPH
-0x9CC3	0x613F	#CJK UNIFIED IDEOGRAPH
-0x9CC4	0x613C	#CJK UNIFIED IDEOGRAPH
-0x9CC5	0x612C	#CJK UNIFIED IDEOGRAPH
-0x9CC6	0x6134	#CJK UNIFIED IDEOGRAPH
-0x9CC7	0x613D	#CJK UNIFIED IDEOGRAPH
-0x9CC8	0x6142	#CJK UNIFIED IDEOGRAPH
-0x9CC9	0x6144	#CJK UNIFIED IDEOGRAPH
-0x9CCA	0x6173	#CJK UNIFIED IDEOGRAPH
-0x9CCB	0x6177	#CJK UNIFIED IDEOGRAPH
-0x9CCC	0x6158	#CJK UNIFIED IDEOGRAPH
-0x9CCD	0x6159	#CJK UNIFIED IDEOGRAPH
-0x9CCE	0x615A	#CJK UNIFIED IDEOGRAPH
-0x9CCF	0x616B	#CJK UNIFIED IDEOGRAPH
-0x9CD0	0x6174	#CJK UNIFIED IDEOGRAPH
-0x9CD1	0x616F	#CJK UNIFIED IDEOGRAPH
-0x9CD2	0x6165	#CJK UNIFIED IDEOGRAPH
-0x9CD3	0x6171	#CJK UNIFIED IDEOGRAPH
-0x9CD4	0x615F	#CJK UNIFIED IDEOGRAPH
-0x9CD5	0x615D	#CJK UNIFIED IDEOGRAPH
-0x9CD6	0x6153	#CJK UNIFIED IDEOGRAPH
-0x9CD7	0x6175	#CJK UNIFIED IDEOGRAPH
-0x9CD8	0x6199	#CJK UNIFIED IDEOGRAPH
-0x9CD9	0x6196	#CJK UNIFIED IDEOGRAPH
-0x9CDA	0x6187	#CJK UNIFIED IDEOGRAPH
-0x9CDB	0x61AC	#CJK UNIFIED IDEOGRAPH
-0x9CDC	0x6194	#CJK UNIFIED IDEOGRAPH
-0x9CDD	0x619A	#CJK UNIFIED IDEOGRAPH
-0x9CDE	0x618A	#CJK UNIFIED IDEOGRAPH
-0x9CDF	0x6191	#CJK UNIFIED IDEOGRAPH
-0x9CE0	0x61AB	#CJK UNIFIED IDEOGRAPH
-0x9CE1	0x61AE	#CJK UNIFIED IDEOGRAPH
-0x9CE2	0x61CC	#CJK UNIFIED IDEOGRAPH
-0x9CE3	0x61CA	#CJK UNIFIED IDEOGRAPH
-0x9CE4	0x61C9	#CJK UNIFIED IDEOGRAPH
-0x9CE5	0x61F7	#CJK UNIFIED IDEOGRAPH
-0x9CE6	0x61C8	#CJK UNIFIED IDEOGRAPH
-0x9CE7	0x61C3	#CJK UNIFIED IDEOGRAPH
-0x9CE8	0x61C6	#CJK UNIFIED IDEOGRAPH
-0x9CE9	0x61BA	#CJK UNIFIED IDEOGRAPH
-0x9CEA	0x61CB	#CJK UNIFIED IDEOGRAPH
-0x9CEB	0x7F79	#CJK UNIFIED IDEOGRAPH
-0x9CEC	0x61CD	#CJK UNIFIED IDEOGRAPH
-0x9CED	0x61E6	#CJK UNIFIED IDEOGRAPH
-0x9CEE	0x61E3	#CJK UNIFIED IDEOGRAPH
-0x9CEF	0x61F6	#CJK UNIFIED IDEOGRAPH
-0x9CF0	0x61FA	#CJK UNIFIED IDEOGRAPH
-0x9CF1	0x61F4	#CJK UNIFIED IDEOGRAPH
-0x9CF2	0x61FF	#CJK UNIFIED IDEOGRAPH
-0x9CF3	0x61FD	#CJK UNIFIED IDEOGRAPH
-0x9CF4	0x61FC	#CJK UNIFIED IDEOGRAPH
-0x9CF5	0x61FE	#CJK UNIFIED IDEOGRAPH
-0x9CF6	0x6200	#CJK UNIFIED IDEOGRAPH
-0x9CF7	0x6208	#CJK UNIFIED IDEOGRAPH
-0x9CF8	0x6209	#CJK UNIFIED IDEOGRAPH
-0x9CF9	0x620D	#CJK UNIFIED IDEOGRAPH
-0x9CFA	0x620C	#CJK UNIFIED IDEOGRAPH
-0x9CFB	0x6214	#CJK UNIFIED IDEOGRAPH
-0x9CFC	0x621B	#CJK UNIFIED IDEOGRAPH
-0x9D40	0x621E	#CJK UNIFIED IDEOGRAPH
-0x9D41	0x6221	#CJK UNIFIED IDEOGRAPH
-0x9D42	0x622A	#CJK UNIFIED IDEOGRAPH
-0x9D43	0x622E	#CJK UNIFIED IDEOGRAPH
-0x9D44	0x6230	#CJK UNIFIED IDEOGRAPH
-0x9D45	0x6232	#CJK UNIFIED IDEOGRAPH
-0x9D46	0x6233	#CJK UNIFIED IDEOGRAPH
-0x9D47	0x6241	#CJK UNIFIED IDEOGRAPH
-0x9D48	0x624E	#CJK UNIFIED IDEOGRAPH
-0x9D49	0x625E	#CJK UNIFIED IDEOGRAPH
-0x9D4A	0x6263	#CJK UNIFIED IDEOGRAPH
-0x9D4B	0x625B	#CJK UNIFIED IDEOGRAPH
-0x9D4C	0x6260	#CJK UNIFIED IDEOGRAPH
-0x9D4D	0x6268	#CJK UNIFIED IDEOGRAPH
-0x9D4E	0x627C	#CJK UNIFIED IDEOGRAPH
-0x9D4F	0x6282	#CJK UNIFIED IDEOGRAPH
-0x9D50	0x6289	#CJK UNIFIED IDEOGRAPH
-0x9D51	0x627E	#CJK UNIFIED IDEOGRAPH
-0x9D52	0x6292	#CJK UNIFIED IDEOGRAPH
-0x9D53	0x6293	#CJK UNIFIED IDEOGRAPH
-0x9D54	0x6296	#CJK UNIFIED IDEOGRAPH
-0x9D55	0x62D4	#CJK UNIFIED IDEOGRAPH
-0x9D56	0x6283	#CJK UNIFIED IDEOGRAPH
-0x9D57	0x6294	#CJK UNIFIED IDEOGRAPH
-0x9D58	0x62D7	#CJK UNIFIED IDEOGRAPH
-0x9D59	0x62D1	#CJK UNIFIED IDEOGRAPH
-0x9D5A	0x62BB	#CJK UNIFIED IDEOGRAPH
-0x9D5B	0x62CF	#CJK UNIFIED IDEOGRAPH
-0x9D5C	0x62FF	#CJK UNIFIED IDEOGRAPH
-0x9D5D	0x62C6	#CJK UNIFIED IDEOGRAPH
-0x9D5E	0x64D4	#CJK UNIFIED IDEOGRAPH
-0x9D5F	0x62C8	#CJK UNIFIED IDEOGRAPH
-0x9D60	0x62DC	#CJK UNIFIED IDEOGRAPH
-0x9D61	0x62CC	#CJK UNIFIED IDEOGRAPH
-0x9D62	0x62CA	#CJK UNIFIED IDEOGRAPH
-0x9D63	0x62C2	#CJK UNIFIED IDEOGRAPH
-0x9D64	0x62C7	#CJK UNIFIED IDEOGRAPH
-0x9D65	0x629B	#CJK UNIFIED IDEOGRAPH
-0x9D66	0x62C9	#CJK UNIFIED IDEOGRAPH
-0x9D67	0x630C	#CJK UNIFIED IDEOGRAPH
-0x9D68	0x62EE	#CJK UNIFIED IDEOGRAPH
-0x9D69	0x62F1	#CJK UNIFIED IDEOGRAPH
-0x9D6A	0x6327	#CJK UNIFIED IDEOGRAPH
-0x9D6B	0x6302	#CJK UNIFIED IDEOGRAPH
-0x9D6C	0x6308	#CJK UNIFIED IDEOGRAPH
-0x9D6D	0x62EF	#CJK UNIFIED IDEOGRAPH
-0x9D6E	0x62F5	#CJK UNIFIED IDEOGRAPH
-0x9D6F	0x6350	#CJK UNIFIED IDEOGRAPH
-0x9D70	0x633E	#CJK UNIFIED IDEOGRAPH
-0x9D71	0x634D	#CJK UNIFIED IDEOGRAPH
-0x9D72	0x641C	#CJK UNIFIED IDEOGRAPH
-0x9D73	0x634F	#CJK UNIFIED IDEOGRAPH
-0x9D74	0x6396	#CJK UNIFIED IDEOGRAPH
-0x9D75	0x638E	#CJK UNIFIED IDEOGRAPH
-0x9D76	0x6380	#CJK UNIFIED IDEOGRAPH
-0x9D77	0x63AB	#CJK UNIFIED IDEOGRAPH
-0x9D78	0x6376	#CJK UNIFIED IDEOGRAPH
-0x9D79	0x63A3	#CJK UNIFIED IDEOGRAPH
-0x9D7A	0x638F	#CJK UNIFIED IDEOGRAPH
-0x9D7B	0x6389	#CJK UNIFIED IDEOGRAPH
-0x9D7C	0x639F	#CJK UNIFIED IDEOGRAPH
-0x9D7D	0x63B5	#CJK UNIFIED IDEOGRAPH
-0x9D7E	0x636B	#CJK UNIFIED IDEOGRAPH
-0x9D80	0x6369	#CJK UNIFIED IDEOGRAPH
-0x9D81	0x63BE	#CJK UNIFIED IDEOGRAPH
-0x9D82	0x63E9	#CJK UNIFIED IDEOGRAPH
-0x9D83	0x63C0	#CJK UNIFIED IDEOGRAPH
-0x9D84	0x63C6	#CJK UNIFIED IDEOGRAPH
-0x9D85	0x63E3	#CJK UNIFIED IDEOGRAPH
-0x9D86	0x63C9	#CJK UNIFIED IDEOGRAPH
-0x9D87	0x63D2	#CJK UNIFIED IDEOGRAPH
-0x9D88	0x63F6	#CJK UNIFIED IDEOGRAPH
-0x9D89	0x63C4	#CJK UNIFIED IDEOGRAPH
-0x9D8A	0x6416	#CJK UNIFIED IDEOGRAPH
-0x9D8B	0x6434	#CJK UNIFIED IDEOGRAPH
-0x9D8C	0x6406	#CJK UNIFIED IDEOGRAPH
-0x9D8D	0x6413	#CJK UNIFIED IDEOGRAPH
-0x9D8E	0x6426	#CJK UNIFIED IDEOGRAPH
-0x9D8F	0x6436	#CJK UNIFIED IDEOGRAPH
-0x9D90	0x651D	#CJK UNIFIED IDEOGRAPH
-0x9D91	0x6417	#CJK UNIFIED IDEOGRAPH
-0x9D92	0x6428	#CJK UNIFIED IDEOGRAPH
-0x9D93	0x640F	#CJK UNIFIED IDEOGRAPH
-0x9D94	0x6467	#CJK UNIFIED IDEOGRAPH
-0x9D95	0x646F	#CJK UNIFIED IDEOGRAPH
-0x9D96	0x6476	#CJK UNIFIED IDEOGRAPH
-0x9D97	0x644E	#CJK UNIFIED IDEOGRAPH
-0x9D98	0x652A	#CJK UNIFIED IDEOGRAPH
-0x9D99	0x6495	#CJK UNIFIED IDEOGRAPH
-0x9D9A	0x6493	#CJK UNIFIED IDEOGRAPH
-0x9D9B	0x64A5	#CJK UNIFIED IDEOGRAPH
-0x9D9C	0x64A9	#CJK UNIFIED IDEOGRAPH
-0x9D9D	0x6488	#CJK UNIFIED IDEOGRAPH
-0x9D9E	0x64BC	#CJK UNIFIED IDEOGRAPH
-0x9D9F	0x64DA	#CJK UNIFIED IDEOGRAPH
-0x9DA0	0x64D2	#CJK UNIFIED IDEOGRAPH
-0x9DA1	0x64C5	#CJK UNIFIED IDEOGRAPH
-0x9DA2	0x64C7	#CJK UNIFIED IDEOGRAPH
-0x9DA3	0x64BB	#CJK UNIFIED IDEOGRAPH
-0x9DA4	0x64D8	#CJK UNIFIED IDEOGRAPH
-0x9DA5	0x64C2	#CJK UNIFIED IDEOGRAPH
-0x9DA6	0x64F1	#CJK UNIFIED IDEOGRAPH
-0x9DA7	0x64E7	#CJK UNIFIED IDEOGRAPH
-0x9DA8	0x8209	#CJK UNIFIED IDEOGRAPH
-0x9DA9	0x64E0	#CJK UNIFIED IDEOGRAPH
-0x9DAA	0x64E1	#CJK UNIFIED IDEOGRAPH
-0x9DAB	0x62AC	#CJK UNIFIED IDEOGRAPH
-0x9DAC	0x64E3	#CJK UNIFIED IDEOGRAPH
-0x9DAD	0x64EF	#CJK UNIFIED IDEOGRAPH
-0x9DAE	0x652C	#CJK UNIFIED IDEOGRAPH
-0x9DAF	0x64F6	#CJK UNIFIED IDEOGRAPH
-0x9DB0	0x64F4	#CJK UNIFIED IDEOGRAPH
-0x9DB1	0x64F2	#CJK UNIFIED IDEOGRAPH
-0x9DB2	0x64FA	#CJK UNIFIED IDEOGRAPH
-0x9DB3	0x6500	#CJK UNIFIED IDEOGRAPH
-0x9DB4	0x64FD	#CJK UNIFIED IDEOGRAPH
-0x9DB5	0x6518	#CJK UNIFIED IDEOGRAPH
-0x9DB6	0x651C	#CJK UNIFIED IDEOGRAPH
-0x9DB7	0x6505	#CJK UNIFIED IDEOGRAPH
-0x9DB8	0x6524	#CJK UNIFIED IDEOGRAPH
-0x9DB9	0x6523	#CJK UNIFIED IDEOGRAPH
-0x9DBA	0x652B	#CJK UNIFIED IDEOGRAPH
-0x9DBB	0x6534	#CJK UNIFIED IDEOGRAPH
-0x9DBC	0x6535	#CJK UNIFIED IDEOGRAPH
-0x9DBD	0x6537	#CJK UNIFIED IDEOGRAPH
-0x9DBE	0x6536	#CJK UNIFIED IDEOGRAPH
-0x9DBF	0x6538	#CJK UNIFIED IDEOGRAPH
-0x9DC0	0x754B	#CJK UNIFIED IDEOGRAPH
-0x9DC1	0x6548	#CJK UNIFIED IDEOGRAPH
-0x9DC2	0x6556	#CJK UNIFIED IDEOGRAPH
-0x9DC3	0x6555	#CJK UNIFIED IDEOGRAPH
-0x9DC4	0x654D	#CJK UNIFIED IDEOGRAPH
-0x9DC5	0x6558	#CJK UNIFIED IDEOGRAPH
-0x9DC6	0x655E	#CJK UNIFIED IDEOGRAPH
-0x9DC7	0x655D	#CJK UNIFIED IDEOGRAPH
-0x9DC8	0x6572	#CJK UNIFIED IDEOGRAPH
-0x9DC9	0x6578	#CJK UNIFIED IDEOGRAPH
-0x9DCA	0x6582	#CJK UNIFIED IDEOGRAPH
-0x9DCB	0x6583	#CJK UNIFIED IDEOGRAPH
-0x9DCC	0x8B8A	#CJK UNIFIED IDEOGRAPH
-0x9DCD	0x659B	#CJK UNIFIED IDEOGRAPH
-0x9DCE	0x659F	#CJK UNIFIED IDEOGRAPH
-0x9DCF	0x65AB	#CJK UNIFIED IDEOGRAPH
-0x9DD0	0x65B7	#CJK UNIFIED IDEOGRAPH
-0x9DD1	0x65C3	#CJK UNIFIED IDEOGRAPH
-0x9DD2	0x65C6	#CJK UNIFIED IDEOGRAPH
-0x9DD3	0x65C1	#CJK UNIFIED IDEOGRAPH
-0x9DD4	0x65C4	#CJK UNIFIED IDEOGRAPH
-0x9DD5	0x65CC	#CJK UNIFIED IDEOGRAPH
-0x9DD6	0x65D2	#CJK UNIFIED IDEOGRAPH
-0x9DD7	0x65DB	#CJK UNIFIED IDEOGRAPH
-0x9DD8	0x65D9	#CJK UNIFIED IDEOGRAPH
-0x9DD9	0x65E0	#CJK UNIFIED IDEOGRAPH
-0x9DDA	0x65E1	#CJK UNIFIED IDEOGRAPH
-0x9DDB	0x65F1	#CJK UNIFIED IDEOGRAPH
-0x9DDC	0x6772	#CJK UNIFIED IDEOGRAPH
-0x9DDD	0x660A	#CJK UNIFIED IDEOGRAPH
-0x9DDE	0x6603	#CJK UNIFIED IDEOGRAPH
-0x9DDF	0x65FB	#CJK UNIFIED IDEOGRAPH
-0x9DE0	0x6773	#CJK UNIFIED IDEOGRAPH
-0x9DE1	0x6635	#CJK UNIFIED IDEOGRAPH
-0x9DE2	0x6636	#CJK UNIFIED IDEOGRAPH
-0x9DE3	0x6634	#CJK UNIFIED IDEOGRAPH
-0x9DE4	0x661C	#CJK UNIFIED IDEOGRAPH
-0x9DE5	0x664F	#CJK UNIFIED IDEOGRAPH
-0x9DE6	0x6644	#CJK UNIFIED IDEOGRAPH
-0x9DE7	0x6649	#CJK UNIFIED IDEOGRAPH
-0x9DE8	0x6641	#CJK UNIFIED IDEOGRAPH
-0x9DE9	0x665E	#CJK UNIFIED IDEOGRAPH
-0x9DEA	0x665D	#CJK UNIFIED IDEOGRAPH
-0x9DEB	0x6664	#CJK UNIFIED IDEOGRAPH
-0x9DEC	0x6667	#CJK UNIFIED IDEOGRAPH
-0x9DED	0x6668	#CJK UNIFIED IDEOGRAPH
-0x9DEE	0x665F	#CJK UNIFIED IDEOGRAPH
-0x9DEF	0x6662	#CJK UNIFIED IDEOGRAPH
-0x9DF0	0x6670	#CJK UNIFIED IDEOGRAPH
-0x9DF1	0x6683	#CJK UNIFIED IDEOGRAPH
-0x9DF2	0x6688	#CJK UNIFIED IDEOGRAPH
-0x9DF3	0x668E	#CJK UNIFIED IDEOGRAPH
-0x9DF4	0x6689	#CJK UNIFIED IDEOGRAPH
-0x9DF5	0x6684	#CJK UNIFIED IDEOGRAPH
-0x9DF6	0x6698	#CJK UNIFIED IDEOGRAPH
-0x9DF7	0x669D	#CJK UNIFIED IDEOGRAPH
-0x9DF8	0x66C1	#CJK UNIFIED IDEOGRAPH
-0x9DF9	0x66B9	#CJK UNIFIED IDEOGRAPH
-0x9DFA	0x66C9	#CJK UNIFIED IDEOGRAPH
-0x9DFB	0x66BE	#CJK UNIFIED IDEOGRAPH
-0x9DFC	0x66BC	#CJK UNIFIED IDEOGRAPH
-0x9E40	0x66C4	#CJK UNIFIED IDEOGRAPH
-0x9E41	0x66B8	#CJK UNIFIED IDEOGRAPH
-0x9E42	0x66D6	#CJK UNIFIED IDEOGRAPH
-0x9E43	0x66DA	#CJK UNIFIED IDEOGRAPH
-0x9E44	0x66E0	#CJK UNIFIED IDEOGRAPH
-0x9E45	0x663F	#CJK UNIFIED IDEOGRAPH
-0x9E46	0x66E6	#CJK UNIFIED IDEOGRAPH
-0x9E47	0x66E9	#CJK UNIFIED IDEOGRAPH
-0x9E48	0x66F0	#CJK UNIFIED IDEOGRAPH
-0x9E49	0x66F5	#CJK UNIFIED IDEOGRAPH
-0x9E4A	0x66F7	#CJK UNIFIED IDEOGRAPH
-0x9E4B	0x670F	#CJK UNIFIED IDEOGRAPH
-0x9E4C	0x6716	#CJK UNIFIED IDEOGRAPH
-0x9E4D	0x671E	#CJK UNIFIED IDEOGRAPH
-0x9E4E	0x6726	#CJK UNIFIED IDEOGRAPH
-0x9E4F	0x6727	#CJK UNIFIED IDEOGRAPH
-0x9E50	0x9738	#CJK UNIFIED IDEOGRAPH
-0x9E51	0x672E	#CJK UNIFIED IDEOGRAPH
-0x9E52	0x673F	#CJK UNIFIED IDEOGRAPH
-0x9E53	0x6736	#CJK UNIFIED IDEOGRAPH
-0x9E54	0x6741	#CJK UNIFIED IDEOGRAPH
-0x9E55	0x6738	#CJK UNIFIED IDEOGRAPH
-0x9E56	0x6737	#CJK UNIFIED IDEOGRAPH
-0x9E57	0x6746	#CJK UNIFIED IDEOGRAPH
-0x9E58	0x675E	#CJK UNIFIED IDEOGRAPH
-0x9E59	0x6760	#CJK UNIFIED IDEOGRAPH
-0x9E5A	0x6759	#CJK UNIFIED IDEOGRAPH
-0x9E5B	0x6763	#CJK UNIFIED IDEOGRAPH
-0x9E5C	0x6764	#CJK UNIFIED IDEOGRAPH
-0x9E5D	0x6789	#CJK UNIFIED IDEOGRAPH
-0x9E5E	0x6770	#CJK UNIFIED IDEOGRAPH
-0x9E5F	0x67A9	#CJK UNIFIED IDEOGRAPH
-0x9E60	0x677C	#CJK UNIFIED IDEOGRAPH
-0x9E61	0x676A	#CJK UNIFIED IDEOGRAPH
-0x9E62	0x678C	#CJK UNIFIED IDEOGRAPH
-0x9E63	0x678B	#CJK UNIFIED IDEOGRAPH
-0x9E64	0x67A6	#CJK UNIFIED IDEOGRAPH
-0x9E65	0x67A1	#CJK UNIFIED IDEOGRAPH
-0x9E66	0x6785	#CJK UNIFIED IDEOGRAPH
-0x9E67	0x67B7	#CJK UNIFIED IDEOGRAPH
-0x9E68	0x67EF	#CJK UNIFIED IDEOGRAPH
-0x9E69	0x67B4	#CJK UNIFIED IDEOGRAPH
-0x9E6A	0x67EC	#CJK UNIFIED IDEOGRAPH
-0x9E6B	0x67B3	#CJK UNIFIED IDEOGRAPH
-0x9E6C	0x67E9	#CJK UNIFIED IDEOGRAPH
-0x9E6D	0x67B8	#CJK UNIFIED IDEOGRAPH
-0x9E6E	0x67E4	#CJK UNIFIED IDEOGRAPH
-0x9E6F	0x67DE	#CJK UNIFIED IDEOGRAPH
-0x9E70	0x67DD	#CJK UNIFIED IDEOGRAPH
-0x9E71	0x67E2	#CJK UNIFIED IDEOGRAPH
-0x9E72	0x67EE	#CJK UNIFIED IDEOGRAPH
-0x9E73	0x67B9	#CJK UNIFIED IDEOGRAPH
-0x9E74	0x67CE	#CJK UNIFIED IDEOGRAPH
-0x9E75	0x67C6	#CJK UNIFIED IDEOGRAPH
-0x9E76	0x67E7	#CJK UNIFIED IDEOGRAPH
-0x9E77	0x6A9C	#CJK UNIFIED IDEOGRAPH
-0x9E78	0x681E	#CJK UNIFIED IDEOGRAPH
-0x9E79	0x6846	#CJK UNIFIED IDEOGRAPH
-0x9E7A	0x6829	#CJK UNIFIED IDEOGRAPH
-0x9E7B	0x6840	#CJK UNIFIED IDEOGRAPH
-0x9E7C	0x684D	#CJK UNIFIED IDEOGRAPH
-0x9E7D	0x6832	#CJK UNIFIED IDEOGRAPH
-0x9E7E	0x684E	#CJK UNIFIED IDEOGRAPH
-0x9E80	0x68B3	#CJK UNIFIED IDEOGRAPH
-0x9E81	0x682B	#CJK UNIFIED IDEOGRAPH
-0x9E82	0x6859	#CJK UNIFIED IDEOGRAPH
-0x9E83	0x6863	#CJK UNIFIED IDEOGRAPH
-0x9E84	0x6877	#CJK UNIFIED IDEOGRAPH
-0x9E85	0x687F	#CJK UNIFIED IDEOGRAPH
-0x9E86	0x689F	#CJK UNIFIED IDEOGRAPH
-0x9E87	0x688F	#CJK UNIFIED IDEOGRAPH
-0x9E88	0x68AD	#CJK UNIFIED IDEOGRAPH
-0x9E89	0x6894	#CJK UNIFIED IDEOGRAPH
-0x9E8A	0x689D	#CJK UNIFIED IDEOGRAPH
-0x9E8B	0x689B	#CJK UNIFIED IDEOGRAPH
-0x9E8C	0x6883	#CJK UNIFIED IDEOGRAPH
-0x9E8D	0x6AAE	#CJK UNIFIED IDEOGRAPH
-0x9E8E	0x68B9	#CJK UNIFIED IDEOGRAPH
-0x9E8F	0x6874	#CJK UNIFIED IDEOGRAPH
-0x9E90	0x68B5	#CJK UNIFIED IDEOGRAPH
-0x9E91	0x68A0	#CJK UNIFIED IDEOGRAPH
-0x9E92	0x68BA	#CJK UNIFIED IDEOGRAPH
-0x9E93	0x690F	#CJK UNIFIED IDEOGRAPH
-0x9E94	0x688D	#CJK UNIFIED IDEOGRAPH
-0x9E95	0x687E	#CJK UNIFIED IDEOGRAPH
-0x9E96	0x6901	#CJK UNIFIED IDEOGRAPH
-0x9E97	0x68CA	#CJK UNIFIED IDEOGRAPH
-0x9E98	0x6908	#CJK UNIFIED IDEOGRAPH
-0x9E99	0x68D8	#CJK UNIFIED IDEOGRAPH
-0x9E9A	0x6922	#CJK UNIFIED IDEOGRAPH
-0x9E9B	0x6926	#CJK UNIFIED IDEOGRAPH
-0x9E9C	0x68E1	#CJK UNIFIED IDEOGRAPH
-0x9E9D	0x690C	#CJK UNIFIED IDEOGRAPH
-0x9E9E	0x68CD	#CJK UNIFIED IDEOGRAPH
-0x9E9F	0x68D4	#CJK UNIFIED IDEOGRAPH
-0x9EA0	0x68E7	#CJK UNIFIED IDEOGRAPH
-0x9EA1	0x68D5	#CJK UNIFIED IDEOGRAPH
-0x9EA2	0x6936	#CJK UNIFIED IDEOGRAPH
-0x9EA3	0x6912	#CJK UNIFIED IDEOGRAPH
-0x9EA4	0x6904	#CJK UNIFIED IDEOGRAPH
-0x9EA5	0x68D7	#CJK UNIFIED IDEOGRAPH
-0x9EA6	0x68E3	#CJK UNIFIED IDEOGRAPH
-0x9EA7	0x6925	#CJK UNIFIED IDEOGRAPH
-0x9EA8	0x68F9	#CJK UNIFIED IDEOGRAPH
-0x9EA9	0x68E0	#CJK UNIFIED IDEOGRAPH
-0x9EAA	0x68EF	#CJK UNIFIED IDEOGRAPH
-0x9EAB	0x6928	#CJK UNIFIED IDEOGRAPH
-0x9EAC	0x692A	#CJK UNIFIED IDEOGRAPH
-0x9EAD	0x691A	#CJK UNIFIED IDEOGRAPH
-0x9EAE	0x6923	#CJK UNIFIED IDEOGRAPH
-0x9EAF	0x6921	#CJK UNIFIED IDEOGRAPH
-0x9EB0	0x68C6	#CJK UNIFIED IDEOGRAPH
-0x9EB1	0x6979	#CJK UNIFIED IDEOGRAPH
-0x9EB2	0x6977	#CJK UNIFIED IDEOGRAPH
-0x9EB3	0x695C	#CJK UNIFIED IDEOGRAPH
-0x9EB4	0x6978	#CJK UNIFIED IDEOGRAPH
-0x9EB5	0x696B	#CJK UNIFIED IDEOGRAPH
-0x9EB6	0x6954	#CJK UNIFIED IDEOGRAPH
-0x9EB7	0x697E	#CJK UNIFIED IDEOGRAPH
-0x9EB8	0x696E	#CJK UNIFIED IDEOGRAPH
-0x9EB9	0x6939	#CJK UNIFIED IDEOGRAPH
-0x9EBA	0x6974	#CJK UNIFIED IDEOGRAPH
-0x9EBB	0x693D	#CJK UNIFIED IDEOGRAPH
-0x9EBC	0x6959	#CJK UNIFIED IDEOGRAPH
-0x9EBD	0x6930	#CJK UNIFIED IDEOGRAPH
-0x9EBE	0x6961	#CJK UNIFIED IDEOGRAPH
-0x9EBF	0x695E	#CJK UNIFIED IDEOGRAPH
-0x9EC0	0x695D	#CJK UNIFIED IDEOGRAPH
-0x9EC1	0x6981	#CJK UNIFIED IDEOGRAPH
-0x9EC2	0x696A	#CJK UNIFIED IDEOGRAPH
-0x9EC3	0x69B2	#CJK UNIFIED IDEOGRAPH
-0x9EC4	0x69AE	#CJK UNIFIED IDEOGRAPH
-0x9EC5	0x69D0	#CJK UNIFIED IDEOGRAPH
-0x9EC6	0x69BF	#CJK UNIFIED IDEOGRAPH
-0x9EC7	0x69C1	#CJK UNIFIED IDEOGRAPH
-0x9EC8	0x69D3	#CJK UNIFIED IDEOGRAPH
-0x9EC9	0x69BE	#CJK UNIFIED IDEOGRAPH
-0x9ECA	0x69CE	#CJK UNIFIED IDEOGRAPH
-0x9ECB	0x5BE8	#CJK UNIFIED IDEOGRAPH
-0x9ECC	0x69CA	#CJK UNIFIED IDEOGRAPH
-0x9ECD	0x69DD	#CJK UNIFIED IDEOGRAPH
-0x9ECE	0x69BB	#CJK UNIFIED IDEOGRAPH
-0x9ECF	0x69C3	#CJK UNIFIED IDEOGRAPH
-0x9ED0	0x69A7	#CJK UNIFIED IDEOGRAPH
-0x9ED1	0x6A2E	#CJK UNIFIED IDEOGRAPH
-0x9ED2	0x6991	#CJK UNIFIED IDEOGRAPH
-0x9ED3	0x69A0	#CJK UNIFIED IDEOGRAPH
-0x9ED4	0x699C	#CJK UNIFIED IDEOGRAPH
-0x9ED5	0x6995	#CJK UNIFIED IDEOGRAPH
-0x9ED6	0x69B4	#CJK UNIFIED IDEOGRAPH
-0x9ED7	0x69DE	#CJK UNIFIED IDEOGRAPH
-0x9ED8	0x69E8	#CJK UNIFIED IDEOGRAPH
-0x9ED9	0x6A02	#CJK UNIFIED IDEOGRAPH
-0x9EDA	0x6A1B	#CJK UNIFIED IDEOGRAPH
-0x9EDB	0x69FF	#CJK UNIFIED IDEOGRAPH
-0x9EDC	0x6B0A	#CJK UNIFIED IDEOGRAPH
-0x9EDD	0x69F9	#CJK UNIFIED IDEOGRAPH
-0x9EDE	0x69F2	#CJK UNIFIED IDEOGRAPH
-0x9EDF	0x69E7	#CJK UNIFIED IDEOGRAPH
-0x9EE0	0x6A05	#CJK UNIFIED IDEOGRAPH
-0x9EE1	0x69B1	#CJK UNIFIED IDEOGRAPH
-0x9EE2	0x6A1E	#CJK UNIFIED IDEOGRAPH
-0x9EE3	0x69ED	#CJK UNIFIED IDEOGRAPH
-0x9EE4	0x6A14	#CJK UNIFIED IDEOGRAPH
-0x9EE5	0x69EB	#CJK UNIFIED IDEOGRAPH
-0x9EE6	0x6A0A	#CJK UNIFIED IDEOGRAPH
-0x9EE7	0x6A12	#CJK UNIFIED IDEOGRAPH
-0x9EE8	0x6AC1	#CJK UNIFIED IDEOGRAPH
-0x9EE9	0x6A23	#CJK UNIFIED IDEOGRAPH
-0x9EEA	0x6A13	#CJK UNIFIED IDEOGRAPH
-0x9EEB	0x6A44	#CJK UNIFIED IDEOGRAPH
-0x9EEC	0x6A0C	#CJK UNIFIED IDEOGRAPH
-0x9EED	0x6A72	#CJK UNIFIED IDEOGRAPH
-0x9EEE	0x6A36	#CJK UNIFIED IDEOGRAPH
-0x9EEF	0x6A78	#CJK UNIFIED IDEOGRAPH
-0x9EF0	0x6A47	#CJK UNIFIED IDEOGRAPH
-0x9EF1	0x6A62	#CJK UNIFIED IDEOGRAPH
-0x9EF2	0x6A59	#CJK UNIFIED IDEOGRAPH
-0x9EF3	0x6A66	#CJK UNIFIED IDEOGRAPH
-0x9EF4	0x6A48	#CJK UNIFIED IDEOGRAPH
-0x9EF5	0x6A38	#CJK UNIFIED IDEOGRAPH
-0x9EF6	0x6A22	#CJK UNIFIED IDEOGRAPH
-0x9EF7	0x6A90	#CJK UNIFIED IDEOGRAPH
-0x9EF8	0x6A8D	#CJK UNIFIED IDEOGRAPH
-0x9EF9	0x6AA0	#CJK UNIFIED IDEOGRAPH
-0x9EFA	0x6A84	#CJK UNIFIED IDEOGRAPH
-0x9EFB	0x6AA2	#CJK UNIFIED IDEOGRAPH
-0x9EFC	0x6AA3	#CJK UNIFIED IDEOGRAPH
-0x9F40	0x6A97	#CJK UNIFIED IDEOGRAPH
-0x9F41	0x8617	#CJK UNIFIED IDEOGRAPH
-0x9F42	0x6ABB	#CJK UNIFIED IDEOGRAPH
-0x9F43	0x6AC3	#CJK UNIFIED IDEOGRAPH
-0x9F44	0x6AC2	#CJK UNIFIED IDEOGRAPH
-0x9F45	0x6AB8	#CJK UNIFIED IDEOGRAPH
-0x9F46	0x6AB3	#CJK UNIFIED IDEOGRAPH
-0x9F47	0x6AAC	#CJK UNIFIED IDEOGRAPH
-0x9F48	0x6ADE	#CJK UNIFIED IDEOGRAPH
-0x9F49	0x6AD1	#CJK UNIFIED IDEOGRAPH
-0x9F4A	0x6ADF	#CJK UNIFIED IDEOGRAPH
-0x9F4B	0x6AAA	#CJK UNIFIED IDEOGRAPH
-0x9F4C	0x6ADA	#CJK UNIFIED IDEOGRAPH
-0x9F4D	0x6AEA	#CJK UNIFIED IDEOGRAPH
-0x9F4E	0x6AFB	#CJK UNIFIED IDEOGRAPH
-0x9F4F	0x6B05	#CJK UNIFIED IDEOGRAPH
-0x9F50	0x8616	#CJK UNIFIED IDEOGRAPH
-0x9F51	0x6AFA	#CJK UNIFIED IDEOGRAPH
-0x9F52	0x6B12	#CJK UNIFIED IDEOGRAPH
-0x9F53	0x6B16	#CJK UNIFIED IDEOGRAPH
-0x9F54	0x9B31	#CJK UNIFIED IDEOGRAPH
-0x9F55	0x6B1F	#CJK UNIFIED IDEOGRAPH
-0x9F56	0x6B38	#CJK UNIFIED IDEOGRAPH
-0x9F57	0x6B37	#CJK UNIFIED IDEOGRAPH
-0x9F58	0x76DC	#CJK UNIFIED IDEOGRAPH
-0x9F59	0x6B39	#CJK UNIFIED IDEOGRAPH
-0x9F5A	0x98EE	#CJK UNIFIED IDEOGRAPH
-0x9F5B	0x6B47	#CJK UNIFIED IDEOGRAPH
-0x9F5C	0x6B43	#CJK UNIFIED IDEOGRAPH
-0x9F5D	0x6B49	#CJK UNIFIED IDEOGRAPH
-0x9F5E	0x6B50	#CJK UNIFIED IDEOGRAPH
-0x9F5F	0x6B59	#CJK UNIFIED IDEOGRAPH
-0x9F60	0x6B54	#CJK UNIFIED IDEOGRAPH
-0x9F61	0x6B5B	#CJK UNIFIED IDEOGRAPH
-0x9F62	0x6B5F	#CJK UNIFIED IDEOGRAPH
-0x9F63	0x6B61	#CJK UNIFIED IDEOGRAPH
-0x9F64	0x6B78	#CJK UNIFIED IDEOGRAPH
-0x9F65	0x6B79	#CJK UNIFIED IDEOGRAPH
-0x9F66	0x6B7F	#CJK UNIFIED IDEOGRAPH
-0x9F67	0x6B80	#CJK UNIFIED IDEOGRAPH
-0x9F68	0x6B84	#CJK UNIFIED IDEOGRAPH
-0x9F69	0x6B83	#CJK UNIFIED IDEOGRAPH
-0x9F6A	0x6B8D	#CJK UNIFIED IDEOGRAPH
-0x9F6B	0x6B98	#CJK UNIFIED IDEOGRAPH
-0x9F6C	0x6B95	#CJK UNIFIED IDEOGRAPH
-0x9F6D	0x6B9E	#CJK UNIFIED IDEOGRAPH
-0x9F6E	0x6BA4	#CJK UNIFIED IDEOGRAPH
-0x9F6F	0x6BAA	#CJK UNIFIED IDEOGRAPH
-0x9F70	0x6BAB	#CJK UNIFIED IDEOGRAPH
-0x9F71	0x6BAF	#CJK UNIFIED IDEOGRAPH
-0x9F72	0x6BB2	#CJK UNIFIED IDEOGRAPH
-0x9F73	0x6BB1	#CJK UNIFIED IDEOGRAPH
-0x9F74	0x6BB3	#CJK UNIFIED IDEOGRAPH
-0x9F75	0x6BB7	#CJK UNIFIED IDEOGRAPH
-0x9F76	0x6BBC	#CJK UNIFIED IDEOGRAPH
-0x9F77	0x6BC6	#CJK UNIFIED IDEOGRAPH
-0x9F78	0x6BCB	#CJK UNIFIED IDEOGRAPH
-0x9F79	0x6BD3	#CJK UNIFIED IDEOGRAPH
-0x9F7A	0x6BDF	#CJK UNIFIED IDEOGRAPH
-0x9F7B	0x6BEC	#CJK UNIFIED IDEOGRAPH
-0x9F7C	0x6BEB	#CJK UNIFIED IDEOGRAPH
-0x9F7D	0x6BF3	#CJK UNIFIED IDEOGRAPH
-0x9F7E	0x6BEF	#CJK UNIFIED IDEOGRAPH
-0x9F80	0x9EBE	#CJK UNIFIED IDEOGRAPH
-0x9F81	0x6C08	#CJK UNIFIED IDEOGRAPH
-0x9F82	0x6C13	#CJK UNIFIED IDEOGRAPH
-0x9F83	0x6C14	#CJK UNIFIED IDEOGRAPH
-0x9F84	0x6C1B	#CJK UNIFIED IDEOGRAPH
-0x9F85	0x6C24	#CJK UNIFIED IDEOGRAPH
-0x9F86	0x6C23	#CJK UNIFIED IDEOGRAPH
-0x9F87	0x6C5E	#CJK UNIFIED IDEOGRAPH
-0x9F88	0x6C55	#CJK UNIFIED IDEOGRAPH
-0x9F89	0x6C62	#CJK UNIFIED IDEOGRAPH
-0x9F8A	0x6C6A	#CJK UNIFIED IDEOGRAPH
-0x9F8B	0x6C82	#CJK UNIFIED IDEOGRAPH
-0x9F8C	0x6C8D	#CJK UNIFIED IDEOGRAPH
-0x9F8D	0x6C9A	#CJK UNIFIED IDEOGRAPH
-0x9F8E	0x6C81	#CJK UNIFIED IDEOGRAPH
-0x9F8F	0x6C9B	#CJK UNIFIED IDEOGRAPH
-0x9F90	0x6C7E	#CJK UNIFIED IDEOGRAPH
-0x9F91	0x6C68	#CJK UNIFIED IDEOGRAPH
-0x9F92	0x6C73	#CJK UNIFIED IDEOGRAPH
-0x9F93	0x6C92	#CJK UNIFIED IDEOGRAPH
-0x9F94	0x6C90	#CJK UNIFIED IDEOGRAPH
-0x9F95	0x6CC4	#CJK UNIFIED IDEOGRAPH
-0x9F96	0x6CF1	#CJK UNIFIED IDEOGRAPH
-0x9F97	0x6CD3	#CJK UNIFIED IDEOGRAPH
-0x9F98	0x6CBD	#CJK UNIFIED IDEOGRAPH
-0x9F99	0x6CD7	#CJK UNIFIED IDEOGRAPH
-0x9F9A	0x6CC5	#CJK UNIFIED IDEOGRAPH
-0x9F9B	0x6CDD	#CJK UNIFIED IDEOGRAPH
-0x9F9C	0x6CAE	#CJK UNIFIED IDEOGRAPH
-0x9F9D	0x6CB1	#CJK UNIFIED IDEOGRAPH
-0x9F9E	0x6CBE	#CJK UNIFIED IDEOGRAPH
-0x9F9F	0x6CBA	#CJK UNIFIED IDEOGRAPH
-0x9FA0	0x6CDB	#CJK UNIFIED IDEOGRAPH
-0x9FA1	0x6CEF	#CJK UNIFIED IDEOGRAPH
-0x9FA2	0x6CD9	#CJK UNIFIED IDEOGRAPH
-0x9FA3	0x6CEA	#CJK UNIFIED IDEOGRAPH
-0x9FA4	0x6D1F	#CJK UNIFIED IDEOGRAPH
-0x9FA5	0x884D	#CJK UNIFIED IDEOGRAPH
-0x9FA6	0x6D36	#CJK UNIFIED IDEOGRAPH
-0x9FA7	0x6D2B	#CJK UNIFIED IDEOGRAPH
-0x9FA8	0x6D3D	#CJK UNIFIED IDEOGRAPH
-0x9FA9	0x6D38	#CJK UNIFIED IDEOGRAPH
-0x9FAA	0x6D19	#CJK UNIFIED IDEOGRAPH
-0x9FAB	0x6D35	#CJK UNIFIED IDEOGRAPH
-0x9FAC	0x6D33	#CJK UNIFIED IDEOGRAPH
-0x9FAD	0x6D12	#CJK UNIFIED IDEOGRAPH
-0x9FAE	0x6D0C	#CJK UNIFIED IDEOGRAPH
-0x9FAF	0x6D63	#CJK UNIFIED IDEOGRAPH
-0x9FB0	0x6D93	#CJK UNIFIED IDEOGRAPH
-0x9FB1	0x6D64	#CJK UNIFIED IDEOGRAPH
-0x9FB2	0x6D5A	#CJK UNIFIED IDEOGRAPH
-0x9FB3	0x6D79	#CJK UNIFIED IDEOGRAPH
-0x9FB4	0x6D59	#CJK UNIFIED IDEOGRAPH
-0x9FB5	0x6D8E	#CJK UNIFIED IDEOGRAPH
-0x9FB6	0x6D95	#CJK UNIFIED IDEOGRAPH
-0x9FB7	0x6FE4	#CJK UNIFIED IDEOGRAPH
-0x9FB8	0x6D85	#CJK UNIFIED IDEOGRAPH
-0x9FB9	0x6DF9	#CJK UNIFIED IDEOGRAPH
-0x9FBA	0x6E15	#CJK UNIFIED IDEOGRAPH
-0x9FBB	0x6E0A	#CJK UNIFIED IDEOGRAPH
-0x9FBC	0x6DB5	#CJK UNIFIED IDEOGRAPH
-0x9FBD	0x6DC7	#CJK UNIFIED IDEOGRAPH
-0x9FBE	0x6DE6	#CJK UNIFIED IDEOGRAPH
-0x9FBF	0x6DB8	#CJK UNIFIED IDEOGRAPH
-0x9FC0	0x6DC6	#CJK UNIFIED IDEOGRAPH
-0x9FC1	0x6DEC	#CJK UNIFIED IDEOGRAPH
-0x9FC2	0x6DDE	#CJK UNIFIED IDEOGRAPH
-0x9FC3	0x6DCC	#CJK UNIFIED IDEOGRAPH
-0x9FC4	0x6DE8	#CJK UNIFIED IDEOGRAPH
-0x9FC5	0x6DD2	#CJK UNIFIED IDEOGRAPH
-0x9FC6	0x6DC5	#CJK UNIFIED IDEOGRAPH
-0x9FC7	0x6DFA	#CJK UNIFIED IDEOGRAPH
-0x9FC8	0x6DD9	#CJK UNIFIED IDEOGRAPH
-0x9FC9	0x6DE4	#CJK UNIFIED IDEOGRAPH
-0x9FCA	0x6DD5	#CJK UNIFIED IDEOGRAPH
-0x9FCB	0x6DEA	#CJK UNIFIED IDEOGRAPH
-0x9FCC	0x6DEE	#CJK UNIFIED IDEOGRAPH
-0x9FCD	0x6E2D	#CJK UNIFIED IDEOGRAPH
-0x9FCE	0x6E6E	#CJK UNIFIED IDEOGRAPH
-0x9FCF	0x6E2E	#CJK UNIFIED IDEOGRAPH
-0x9FD0	0x6E19	#CJK UNIFIED IDEOGRAPH
-0x9FD1	0x6E72	#CJK UNIFIED IDEOGRAPH
-0x9FD2	0x6E5F	#CJK UNIFIED IDEOGRAPH
-0x9FD3	0x6E3E	#CJK UNIFIED IDEOGRAPH
-0x9FD4	0x6E23	#CJK UNIFIED IDEOGRAPH
-0x9FD5	0x6E6B	#CJK UNIFIED IDEOGRAPH
-0x9FD6	0x6E2B	#CJK UNIFIED IDEOGRAPH
-0x9FD7	0x6E76	#CJK UNIFIED IDEOGRAPH
-0x9FD8	0x6E4D	#CJK UNIFIED IDEOGRAPH
-0x9FD9	0x6E1F	#CJK UNIFIED IDEOGRAPH
-0x9FDA	0x6E43	#CJK UNIFIED IDEOGRAPH
-0x9FDB	0x6E3A	#CJK UNIFIED IDEOGRAPH
-0x9FDC	0x6E4E	#CJK UNIFIED IDEOGRAPH
-0x9FDD	0x6E24	#CJK UNIFIED IDEOGRAPH
-0x9FDE	0x6EFF	#CJK UNIFIED IDEOGRAPH
-0x9FDF	0x6E1D	#CJK UNIFIED IDEOGRAPH
-0x9FE0	0x6E38	#CJK UNIFIED IDEOGRAPH
-0x9FE1	0x6E82	#CJK UNIFIED IDEOGRAPH
-0x9FE2	0x6EAA	#CJK UNIFIED IDEOGRAPH
-0x9FE3	0x6E98	#CJK UNIFIED IDEOGRAPH
-0x9FE4	0x6EC9	#CJK UNIFIED IDEOGRAPH
-0x9FE5	0x6EB7	#CJK UNIFIED IDEOGRAPH
-0x9FE6	0x6ED3	#CJK UNIFIED IDEOGRAPH
-0x9FE7	0x6EBD	#CJK UNIFIED IDEOGRAPH
-0x9FE8	0x6EAF	#CJK UNIFIED IDEOGRAPH
-0x9FE9	0x6EC4	#CJK UNIFIED IDEOGRAPH
-0x9FEA	0x6EB2	#CJK UNIFIED IDEOGRAPH
-0x9FEB	0x6ED4	#CJK UNIFIED IDEOGRAPH
-0x9FEC	0x6ED5	#CJK UNIFIED IDEOGRAPH
-0x9FED	0x6E8F	#CJK UNIFIED IDEOGRAPH
-0x9FEE	0x6EA5	#CJK UNIFIED IDEOGRAPH
-0x9FEF	0x6EC2	#CJK UNIFIED IDEOGRAPH
-0x9FF0	0x6E9F	#CJK UNIFIED IDEOGRAPH
-0x9FF1	0x6F41	#CJK UNIFIED IDEOGRAPH
-0x9FF2	0x6F11	#CJK UNIFIED IDEOGRAPH
-0x9FF3	0x704C	#CJK UNIFIED IDEOGRAPH
-0x9FF4	0x6EEC	#CJK UNIFIED IDEOGRAPH
-0x9FF5	0x6EF8	#CJK UNIFIED IDEOGRAPH
-0x9FF6	0x6EFE	#CJK UNIFIED IDEOGRAPH
-0x9FF7	0x6F3F	#CJK UNIFIED IDEOGRAPH
-0x9FF8	0x6EF2	#CJK UNIFIED IDEOGRAPH
-0x9FF9	0x6F31	#CJK UNIFIED IDEOGRAPH
-0x9FFA	0x6EEF	#CJK UNIFIED IDEOGRAPH
-0x9FFB	0x6F32	#CJK UNIFIED IDEOGRAPH
-0x9FFC	0x6ECC	#CJK UNIFIED IDEOGRAPH
-0xE040	0x6F3E	#CJK UNIFIED IDEOGRAPH
-0xE041	0x6F13	#CJK UNIFIED IDEOGRAPH
-0xE042	0x6EF7	#CJK UNIFIED IDEOGRAPH
-0xE043	0x6F86	#CJK UNIFIED IDEOGRAPH
-0xE044	0x6F7A	#CJK UNIFIED IDEOGRAPH
-0xE045	0x6F78	#CJK UNIFIED IDEOGRAPH
-0xE046	0x6F81	#CJK UNIFIED IDEOGRAPH
-0xE047	0x6F80	#CJK UNIFIED IDEOGRAPH
-0xE048	0x6F6F	#CJK UNIFIED IDEOGRAPH
-0xE049	0x6F5B	#CJK UNIFIED IDEOGRAPH
-0xE04A	0x6FF3	#CJK UNIFIED IDEOGRAPH
-0xE04B	0x6F6D	#CJK UNIFIED IDEOGRAPH
-0xE04C	0x6F82	#CJK UNIFIED IDEOGRAPH
-0xE04D	0x6F7C	#CJK UNIFIED IDEOGRAPH
-0xE04E	0x6F58	#CJK UNIFIED IDEOGRAPH
-0xE04F	0x6F8E	#CJK UNIFIED IDEOGRAPH
-0xE050	0x6F91	#CJK UNIFIED IDEOGRAPH
-0xE051	0x6FC2	#CJK UNIFIED IDEOGRAPH
-0xE052	0x6F66	#CJK UNIFIED IDEOGRAPH
-0xE053	0x6FB3	#CJK UNIFIED IDEOGRAPH
-0xE054	0x6FA3	#CJK UNIFIED IDEOGRAPH
-0xE055	0x6FA1	#CJK UNIFIED IDEOGRAPH
-0xE056	0x6FA4	#CJK UNIFIED IDEOGRAPH
-0xE057	0x6FB9	#CJK UNIFIED IDEOGRAPH
-0xE058	0x6FC6	#CJK UNIFIED IDEOGRAPH
-0xE059	0x6FAA	#CJK UNIFIED IDEOGRAPH
-0xE05A	0x6FDF	#CJK UNIFIED IDEOGRAPH
-0xE05B	0x6FD5	#CJK UNIFIED IDEOGRAPH
-0xE05C	0x6FEC	#CJK UNIFIED IDEOGRAPH
-0xE05D	0x6FD4	#CJK UNIFIED IDEOGRAPH
-0xE05E	0x6FD8	#CJK UNIFIED IDEOGRAPH
-0xE05F	0x6FF1	#CJK UNIFIED IDEOGRAPH
-0xE060	0x6FEE	#CJK UNIFIED IDEOGRAPH
-0xE061	0x6FDB	#CJK UNIFIED IDEOGRAPH
-0xE062	0x7009	#CJK UNIFIED IDEOGRAPH
-0xE063	0x700B	#CJK UNIFIED IDEOGRAPH
-0xE064	0x6FFA	#CJK UNIFIED IDEOGRAPH
-0xE065	0x7011	#CJK UNIFIED IDEOGRAPH
-0xE066	0x7001	#CJK UNIFIED IDEOGRAPH
-0xE067	0x700F	#CJK UNIFIED IDEOGRAPH
-0xE068	0x6FFE	#CJK UNIFIED IDEOGRAPH
-0xE069	0x701B	#CJK UNIFIED IDEOGRAPH
-0xE06A	0x701A	#CJK UNIFIED IDEOGRAPH
-0xE06B	0x6F74	#CJK UNIFIED IDEOGRAPH
-0xE06C	0x701D	#CJK UNIFIED IDEOGRAPH
-0xE06D	0x7018	#CJK UNIFIED IDEOGRAPH
-0xE06E	0x701F	#CJK UNIFIED IDEOGRAPH
-0xE06F	0x7030	#CJK UNIFIED IDEOGRAPH
-0xE070	0x703E	#CJK UNIFIED IDEOGRAPH
-0xE071	0x7032	#CJK UNIFIED IDEOGRAPH
-0xE072	0x7051	#CJK UNIFIED IDEOGRAPH
-0xE073	0x7063	#CJK UNIFIED IDEOGRAPH
-0xE074	0x7099	#CJK UNIFIED IDEOGRAPH
-0xE075	0x7092	#CJK UNIFIED IDEOGRAPH
-0xE076	0x70AF	#CJK UNIFIED IDEOGRAPH
-0xE077	0x70F1	#CJK UNIFIED IDEOGRAPH
-0xE078	0x70AC	#CJK UNIFIED IDEOGRAPH
-0xE079	0x70B8	#CJK UNIFIED IDEOGRAPH
-0xE07A	0x70B3	#CJK UNIFIED IDEOGRAPH
-0xE07B	0x70AE	#CJK UNIFIED IDEOGRAPH
-0xE07C	0x70DF	#CJK UNIFIED IDEOGRAPH
-0xE07D	0x70CB	#CJK UNIFIED IDEOGRAPH
-0xE07E	0x70DD	#CJK UNIFIED IDEOGRAPH
-0xE080	0x70D9	#CJK UNIFIED IDEOGRAPH
-0xE081	0x7109	#CJK UNIFIED IDEOGRAPH
-0xE082	0x70FD	#CJK UNIFIED IDEOGRAPH
-0xE083	0x711C	#CJK UNIFIED IDEOGRAPH
-0xE084	0x7119	#CJK UNIFIED IDEOGRAPH
-0xE085	0x7165	#CJK UNIFIED IDEOGRAPH
-0xE086	0x7155	#CJK UNIFIED IDEOGRAPH
-0xE087	0x7188	#CJK UNIFIED IDEOGRAPH
-0xE088	0x7166	#CJK UNIFIED IDEOGRAPH
-0xE089	0x7162	#CJK UNIFIED IDEOGRAPH
-0xE08A	0x714C	#CJK UNIFIED IDEOGRAPH
-0xE08B	0x7156	#CJK UNIFIED IDEOGRAPH
-0xE08C	0x716C	#CJK UNIFIED IDEOGRAPH
-0xE08D	0x718F	#CJK UNIFIED IDEOGRAPH
-0xE08E	0x71FB	#CJK UNIFIED IDEOGRAPH
-0xE08F	0x7184	#CJK UNIFIED IDEOGRAPH
-0xE090	0x7195	#CJK UNIFIED IDEOGRAPH
-0xE091	0x71A8	#CJK UNIFIED IDEOGRAPH
-0xE092	0x71AC	#CJK UNIFIED IDEOGRAPH
-0xE093	0x71D7	#CJK UNIFIED IDEOGRAPH
-0xE094	0x71B9	#CJK UNIFIED IDEOGRAPH
-0xE095	0x71BE	#CJK UNIFIED IDEOGRAPH
-0xE096	0x71D2	#CJK UNIFIED IDEOGRAPH
-0xE097	0x71C9	#CJK UNIFIED IDEOGRAPH
-0xE098	0x71D4	#CJK UNIFIED IDEOGRAPH
-0xE099	0x71CE	#CJK UNIFIED IDEOGRAPH
-0xE09A	0x71E0	#CJK UNIFIED IDEOGRAPH
-0xE09B	0x71EC	#CJK UNIFIED IDEOGRAPH
-0xE09C	0x71E7	#CJK UNIFIED IDEOGRAPH
-0xE09D	0x71F5	#CJK UNIFIED IDEOGRAPH
-0xE09E	0x71FC	#CJK UNIFIED IDEOGRAPH
-0xE09F	0x71F9	#CJK UNIFIED IDEOGRAPH
-0xE0A0	0x71FF	#CJK UNIFIED IDEOGRAPH
-0xE0A1	0x720D	#CJK UNIFIED IDEOGRAPH
-0xE0A2	0x7210	#CJK UNIFIED IDEOGRAPH
-0xE0A3	0x721B	#CJK UNIFIED IDEOGRAPH
-0xE0A4	0x7228	#CJK UNIFIED IDEOGRAPH
-0xE0A5	0x722D	#CJK UNIFIED IDEOGRAPH
-0xE0A6	0x722C	#CJK UNIFIED IDEOGRAPH
-0xE0A7	0x7230	#CJK UNIFIED IDEOGRAPH
-0xE0A8	0x7232	#CJK UNIFIED IDEOGRAPH
-0xE0A9	0x723B	#CJK UNIFIED IDEOGRAPH
-0xE0AA	0x723C	#CJK UNIFIED IDEOGRAPH
-0xE0AB	0x723F	#CJK UNIFIED IDEOGRAPH
-0xE0AC	0x7240	#CJK UNIFIED IDEOGRAPH
-0xE0AD	0x7246	#CJK UNIFIED IDEOGRAPH
-0xE0AE	0x724B	#CJK UNIFIED IDEOGRAPH
-0xE0AF	0x7258	#CJK UNIFIED IDEOGRAPH
-0xE0B0	0x7274	#CJK UNIFIED IDEOGRAPH
-0xE0B1	0x727E	#CJK UNIFIED IDEOGRAPH
-0xE0B2	0x7282	#CJK UNIFIED IDEOGRAPH
-0xE0B3	0x7281	#CJK UNIFIED IDEOGRAPH
-0xE0B4	0x7287	#CJK UNIFIED IDEOGRAPH
-0xE0B5	0x7292	#CJK UNIFIED IDEOGRAPH
-0xE0B6	0x7296	#CJK UNIFIED IDEOGRAPH
-0xE0B7	0x72A2	#CJK UNIFIED IDEOGRAPH
-0xE0B8	0x72A7	#CJK UNIFIED IDEOGRAPH
-0xE0B9	0x72B9	#CJK UNIFIED IDEOGRAPH
-0xE0BA	0x72B2	#CJK UNIFIED IDEOGRAPH
-0xE0BB	0x72C3	#CJK UNIFIED IDEOGRAPH
-0xE0BC	0x72C6	#CJK UNIFIED IDEOGRAPH
-0xE0BD	0x72C4	#CJK UNIFIED IDEOGRAPH
-0xE0BE	0x72CE	#CJK UNIFIED IDEOGRAPH
-0xE0BF	0x72D2	#CJK UNIFIED IDEOGRAPH
-0xE0C0	0x72E2	#CJK UNIFIED IDEOGRAPH
-0xE0C1	0x72E0	#CJK UNIFIED IDEOGRAPH
-0xE0C2	0x72E1	#CJK UNIFIED IDEOGRAPH
-0xE0C3	0x72F9	#CJK UNIFIED IDEOGRAPH
-0xE0C4	0x72F7	#CJK UNIFIED IDEOGRAPH
-0xE0C5	0x500F	#CJK UNIFIED IDEOGRAPH
-0xE0C6	0x7317	#CJK UNIFIED IDEOGRAPH
-0xE0C7	0x730A	#CJK UNIFIED IDEOGRAPH
-0xE0C8	0x731C	#CJK UNIFIED IDEOGRAPH
-0xE0C9	0x7316	#CJK UNIFIED IDEOGRAPH
-0xE0CA	0x731D	#CJK UNIFIED IDEOGRAPH
-0xE0CB	0x7334	#CJK UNIFIED IDEOGRAPH
-0xE0CC	0x732F	#CJK UNIFIED IDEOGRAPH
-0xE0CD	0x7329	#CJK UNIFIED IDEOGRAPH
-0xE0CE	0x7325	#CJK UNIFIED IDEOGRAPH
-0xE0CF	0x733E	#CJK UNIFIED IDEOGRAPH
-0xE0D0	0x734E	#CJK UNIFIED IDEOGRAPH
-0xE0D1	0x734F	#CJK UNIFIED IDEOGRAPH
-0xE0D2	0x9ED8	#CJK UNIFIED IDEOGRAPH
-0xE0D3	0x7357	#CJK UNIFIED IDEOGRAPH
-0xE0D4	0x736A	#CJK UNIFIED IDEOGRAPH
-0xE0D5	0x7368	#CJK UNIFIED IDEOGRAPH
-0xE0D6	0x7370	#CJK UNIFIED IDEOGRAPH
-0xE0D7	0x7378	#CJK UNIFIED IDEOGRAPH
-0xE0D8	0x7375	#CJK UNIFIED IDEOGRAPH
-0xE0D9	0x737B	#CJK UNIFIED IDEOGRAPH
-0xE0DA	0x737A	#CJK UNIFIED IDEOGRAPH
-0xE0DB	0x73C8	#CJK UNIFIED IDEOGRAPH
-0xE0DC	0x73B3	#CJK UNIFIED IDEOGRAPH
-0xE0DD	0x73CE	#CJK UNIFIED IDEOGRAPH
-0xE0DE	0x73BB	#CJK UNIFIED IDEOGRAPH
-0xE0DF	0x73C0	#CJK UNIFIED IDEOGRAPH
-0xE0E0	0x73E5	#CJK UNIFIED IDEOGRAPH
-0xE0E1	0x73EE	#CJK UNIFIED IDEOGRAPH
-0xE0E2	0x73DE	#CJK UNIFIED IDEOGRAPH
-0xE0E3	0x74A2	#CJK UNIFIED IDEOGRAPH
-0xE0E4	0x7405	#CJK UNIFIED IDEOGRAPH
-0xE0E5	0x746F	#CJK UNIFIED IDEOGRAPH
-0xE0E6	0x7425	#CJK UNIFIED IDEOGRAPH
-0xE0E7	0x73F8	#CJK UNIFIED IDEOGRAPH
-0xE0E8	0x7432	#CJK UNIFIED IDEOGRAPH
-0xE0E9	0x743A	#CJK UNIFIED IDEOGRAPH
-0xE0EA	0x7455	#CJK UNIFIED IDEOGRAPH
-0xE0EB	0x743F	#CJK UNIFIED IDEOGRAPH
-0xE0EC	0x745F	#CJK UNIFIED IDEOGRAPH
-0xE0ED	0x7459	#CJK UNIFIED IDEOGRAPH
-0xE0EE	0x7441	#CJK UNIFIED IDEOGRAPH
-0xE0EF	0x745C	#CJK UNIFIED IDEOGRAPH
-0xE0F0	0x7469	#CJK UNIFIED IDEOGRAPH
-0xE0F1	0x7470	#CJK UNIFIED IDEOGRAPH
-0xE0F2	0x7463	#CJK UNIFIED IDEOGRAPH
-0xE0F3	0x746A	#CJK UNIFIED IDEOGRAPH
-0xE0F4	0x7476	#CJK UNIFIED IDEOGRAPH
-0xE0F5	0x747E	#CJK UNIFIED IDEOGRAPH
-0xE0F6	0x748B	#CJK UNIFIED IDEOGRAPH
-0xE0F7	0x749E	#CJK UNIFIED IDEOGRAPH
-0xE0F8	0x74A7	#CJK UNIFIED IDEOGRAPH
-0xE0F9	0x74CA	#CJK UNIFIED IDEOGRAPH
-0xE0FA	0x74CF	#CJK UNIFIED IDEOGRAPH
-0xE0FB	0x74D4	#CJK UNIFIED IDEOGRAPH
-0xE0FC	0x73F1	#CJK UNIFIED IDEOGRAPH
-0xE140	0x74E0	#CJK UNIFIED IDEOGRAPH
-0xE141	0x74E3	#CJK UNIFIED IDEOGRAPH
-0xE142	0x74E7	#CJK UNIFIED IDEOGRAPH
-0xE143	0x74E9	#CJK UNIFIED IDEOGRAPH
-0xE144	0x74EE	#CJK UNIFIED IDEOGRAPH
-0xE145	0x74F2	#CJK UNIFIED IDEOGRAPH
-0xE146	0x74F0	#CJK UNIFIED IDEOGRAPH
-0xE147	0x74F1	#CJK UNIFIED IDEOGRAPH
-0xE148	0x74F8	#CJK UNIFIED IDEOGRAPH
-0xE149	0x74F7	#CJK UNIFIED IDEOGRAPH
-0xE14A	0x7504	#CJK UNIFIED IDEOGRAPH
-0xE14B	0x7503	#CJK UNIFIED IDEOGRAPH
-0xE14C	0x7505	#CJK UNIFIED IDEOGRAPH
-0xE14D	0x750C	#CJK UNIFIED IDEOGRAPH
-0xE14E	0x750E	#CJK UNIFIED IDEOGRAPH
-0xE14F	0x750D	#CJK UNIFIED IDEOGRAPH
-0xE150	0x7515	#CJK UNIFIED IDEOGRAPH
-0xE151	0x7513	#CJK UNIFIED IDEOGRAPH
-0xE152	0x751E	#CJK UNIFIED IDEOGRAPH
-0xE153	0x7526	#CJK UNIFIED IDEOGRAPH
-0xE154	0x752C	#CJK UNIFIED IDEOGRAPH
-0xE155	0x753C	#CJK UNIFIED IDEOGRAPH
-0xE156	0x7544	#CJK UNIFIED IDEOGRAPH
-0xE157	0x754D	#CJK UNIFIED IDEOGRAPH
-0xE158	0x754A	#CJK UNIFIED IDEOGRAPH
-0xE159	0x7549	#CJK UNIFIED IDEOGRAPH
-0xE15A	0x755B	#CJK UNIFIED IDEOGRAPH
-0xE15B	0x7546	#CJK UNIFIED IDEOGRAPH
-0xE15C	0x755A	#CJK UNIFIED IDEOGRAPH
-0xE15D	0x7569	#CJK UNIFIED IDEOGRAPH
-0xE15E	0x7564	#CJK UNIFIED IDEOGRAPH
-0xE15F	0x7567	#CJK UNIFIED IDEOGRAPH
-0xE160	0x756B	#CJK UNIFIED IDEOGRAPH
-0xE161	0x756D	#CJK UNIFIED IDEOGRAPH
-0xE162	0x7578	#CJK UNIFIED IDEOGRAPH
-0xE163	0x7576	#CJK UNIFIED IDEOGRAPH
-0xE164	0x7586	#CJK UNIFIED IDEOGRAPH
-0xE165	0x7587	#CJK UNIFIED IDEOGRAPH
-0xE166	0x7574	#CJK UNIFIED IDEOGRAPH
-0xE167	0x758A	#CJK UNIFIED IDEOGRAPH
-0xE168	0x7589	#CJK UNIFIED IDEOGRAPH
-0xE169	0x7582	#CJK UNIFIED IDEOGRAPH
-0xE16A	0x7594	#CJK UNIFIED IDEOGRAPH
-0xE16B	0x759A	#CJK UNIFIED IDEOGRAPH
-0xE16C	0x759D	#CJK UNIFIED IDEOGRAPH
-0xE16D	0x75A5	#CJK UNIFIED IDEOGRAPH
-0xE16E	0x75A3	#CJK UNIFIED IDEOGRAPH
-0xE16F	0x75C2	#CJK UNIFIED IDEOGRAPH
-0xE170	0x75B3	#CJK UNIFIED IDEOGRAPH
-0xE171	0x75C3	#CJK UNIFIED IDEOGRAPH
-0xE172	0x75B5	#CJK UNIFIED IDEOGRAPH
-0xE173	0x75BD	#CJK UNIFIED IDEOGRAPH
-0xE174	0x75B8	#CJK UNIFIED IDEOGRAPH
-0xE175	0x75BC	#CJK UNIFIED IDEOGRAPH
-0xE176	0x75B1	#CJK UNIFIED IDEOGRAPH
-0xE177	0x75CD	#CJK UNIFIED IDEOGRAPH
-0xE178	0x75CA	#CJK UNIFIED IDEOGRAPH
-0xE179	0x75D2	#CJK UNIFIED IDEOGRAPH
-0xE17A	0x75D9	#CJK UNIFIED IDEOGRAPH
-0xE17B	0x75E3	#CJK UNIFIED IDEOGRAPH
-0xE17C	0x75DE	#CJK UNIFIED IDEOGRAPH
-0xE17D	0x75FE	#CJK UNIFIED IDEOGRAPH
-0xE17E	0x75FF	#CJK UNIFIED IDEOGRAPH
-0xE180	0x75FC	#CJK UNIFIED IDEOGRAPH
-0xE181	0x7601	#CJK UNIFIED IDEOGRAPH
-0xE182	0x75F0	#CJK UNIFIED IDEOGRAPH
-0xE183	0x75FA	#CJK UNIFIED IDEOGRAPH
-0xE184	0x75F2	#CJK UNIFIED IDEOGRAPH
-0xE185	0x75F3	#CJK UNIFIED IDEOGRAPH
-0xE186	0x760B	#CJK UNIFIED IDEOGRAPH
-0xE187	0x760D	#CJK UNIFIED IDEOGRAPH
-0xE188	0x7609	#CJK UNIFIED IDEOGRAPH
-0xE189	0x761F	#CJK UNIFIED IDEOGRAPH
-0xE18A	0x7627	#CJK UNIFIED IDEOGRAPH
-0xE18B	0x7620	#CJK UNIFIED IDEOGRAPH
-0xE18C	0x7621	#CJK UNIFIED IDEOGRAPH
-0xE18D	0x7622	#CJK UNIFIED IDEOGRAPH
-0xE18E	0x7624	#CJK UNIFIED IDEOGRAPH
-0xE18F	0x7634	#CJK UNIFIED IDEOGRAPH
-0xE190	0x7630	#CJK UNIFIED IDEOGRAPH
-0xE191	0x763B	#CJK UNIFIED IDEOGRAPH
-0xE192	0x7647	#CJK UNIFIED IDEOGRAPH
-0xE193	0x7648	#CJK UNIFIED IDEOGRAPH
-0xE194	0x7646	#CJK UNIFIED IDEOGRAPH
-0xE195	0x765C	#CJK UNIFIED IDEOGRAPH
-0xE196	0x7658	#CJK UNIFIED IDEOGRAPH
-0xE197	0x7661	#CJK UNIFIED IDEOGRAPH
-0xE198	0x7662	#CJK UNIFIED IDEOGRAPH
-0xE199	0x7668	#CJK UNIFIED IDEOGRAPH
-0xE19A	0x7669	#CJK UNIFIED IDEOGRAPH
-0xE19B	0x766A	#CJK UNIFIED IDEOGRAPH
-0xE19C	0x7667	#CJK UNIFIED IDEOGRAPH
-0xE19D	0x766C	#CJK UNIFIED IDEOGRAPH
-0xE19E	0x7670	#CJK UNIFIED IDEOGRAPH
-0xE19F	0x7672	#CJK UNIFIED IDEOGRAPH
-0xE1A0	0x7676	#CJK UNIFIED IDEOGRAPH
-0xE1A1	0x7678	#CJK UNIFIED IDEOGRAPH
-0xE1A2	0x767C	#CJK UNIFIED IDEOGRAPH
-0xE1A3	0x7680	#CJK UNIFIED IDEOGRAPH
-0xE1A4	0x7683	#CJK UNIFIED IDEOGRAPH
-0xE1A5	0x7688	#CJK UNIFIED IDEOGRAPH
-0xE1A6	0x768B	#CJK UNIFIED IDEOGRAPH
-0xE1A7	0x768E	#CJK UNIFIED IDEOGRAPH
-0xE1A8	0x7696	#CJK UNIFIED IDEOGRAPH
-0xE1A9	0x7693	#CJK UNIFIED IDEOGRAPH
-0xE1AA	0x7699	#CJK UNIFIED IDEOGRAPH
-0xE1AB	0x769A	#CJK UNIFIED IDEOGRAPH
-0xE1AC	0x76B0	#CJK UNIFIED IDEOGRAPH
-0xE1AD	0x76B4	#CJK UNIFIED IDEOGRAPH
-0xE1AE	0x76B8	#CJK UNIFIED IDEOGRAPH
-0xE1AF	0x76B9	#CJK UNIFIED IDEOGRAPH
-0xE1B0	0x76BA	#CJK UNIFIED IDEOGRAPH
-0xE1B1	0x76C2	#CJK UNIFIED IDEOGRAPH
-0xE1B2	0x76CD	#CJK UNIFIED IDEOGRAPH
-0xE1B3	0x76D6	#CJK UNIFIED IDEOGRAPH
-0xE1B4	0x76D2	#CJK UNIFIED IDEOGRAPH
-0xE1B5	0x76DE	#CJK UNIFIED IDEOGRAPH
-0xE1B6	0x76E1	#CJK UNIFIED IDEOGRAPH
-0xE1B7	0x76E5	#CJK UNIFIED IDEOGRAPH
-0xE1B8	0x76E7	#CJK UNIFIED IDEOGRAPH
-0xE1B9	0x76EA	#CJK UNIFIED IDEOGRAPH
-0xE1BA	0x862F	#CJK UNIFIED IDEOGRAPH
-0xE1BB	0x76FB	#CJK UNIFIED IDEOGRAPH
-0xE1BC	0x7708	#CJK UNIFIED IDEOGRAPH
-0xE1BD	0x7707	#CJK UNIFIED IDEOGRAPH
-0xE1BE	0x7704	#CJK UNIFIED IDEOGRAPH
-0xE1BF	0x7729	#CJK UNIFIED IDEOGRAPH
-0xE1C0	0x7724	#CJK UNIFIED IDEOGRAPH
-0xE1C1	0x771E	#CJK UNIFIED IDEOGRAPH
-0xE1C2	0x7725	#CJK UNIFIED IDEOGRAPH
-0xE1C3	0x7726	#CJK UNIFIED IDEOGRAPH
-0xE1C4	0x771B	#CJK UNIFIED IDEOGRAPH
-0xE1C5	0x7737	#CJK UNIFIED IDEOGRAPH
-0xE1C6	0x7738	#CJK UNIFIED IDEOGRAPH
-0xE1C7	0x7747	#CJK UNIFIED IDEOGRAPH
-0xE1C8	0x775A	#CJK UNIFIED IDEOGRAPH
-0xE1C9	0x7768	#CJK UNIFIED IDEOGRAPH
-0xE1CA	0x776B	#CJK UNIFIED IDEOGRAPH
-0xE1CB	0x775B	#CJK UNIFIED IDEOGRAPH
-0xE1CC	0x7765	#CJK UNIFIED IDEOGRAPH
-0xE1CD	0x777F	#CJK UNIFIED IDEOGRAPH
-0xE1CE	0x777E	#CJK UNIFIED IDEOGRAPH
-0xE1CF	0x7779	#CJK UNIFIED IDEOGRAPH
-0xE1D0	0x778E	#CJK UNIFIED IDEOGRAPH
-0xE1D1	0x778B	#CJK UNIFIED IDEOGRAPH
-0xE1D2	0x7791	#CJK UNIFIED IDEOGRAPH
-0xE1D3	0x77A0	#CJK UNIFIED IDEOGRAPH
-0xE1D4	0x779E	#CJK UNIFIED IDEOGRAPH
-0xE1D5	0x77B0	#CJK UNIFIED IDEOGRAPH
-0xE1D6	0x77B6	#CJK UNIFIED IDEOGRAPH
-0xE1D7	0x77B9	#CJK UNIFIED IDEOGRAPH
-0xE1D8	0x77BF	#CJK UNIFIED IDEOGRAPH
-0xE1D9	0x77BC	#CJK UNIFIED IDEOGRAPH
-0xE1DA	0x77BD	#CJK UNIFIED IDEOGRAPH
-0xE1DB	0x77BB	#CJK UNIFIED IDEOGRAPH
-0xE1DC	0x77C7	#CJK UNIFIED IDEOGRAPH
-0xE1DD	0x77CD	#CJK UNIFIED IDEOGRAPH
-0xE1DE	0x77D7	#CJK UNIFIED IDEOGRAPH
-0xE1DF	0x77DA	#CJK UNIFIED IDEOGRAPH
-0xE1E0	0x77DC	#CJK UNIFIED IDEOGRAPH
-0xE1E1	0x77E3	#CJK UNIFIED IDEOGRAPH
-0xE1E2	0x77EE	#CJK UNIFIED IDEOGRAPH
-0xE1E3	0x77FC	#CJK UNIFIED IDEOGRAPH
-0xE1E4	0x780C	#CJK UNIFIED IDEOGRAPH
-0xE1E5	0x7812	#CJK UNIFIED IDEOGRAPH
-0xE1E6	0x7926	#CJK UNIFIED IDEOGRAPH
-0xE1E7	0x7820	#CJK UNIFIED IDEOGRAPH
-0xE1E8	0x792A	#CJK UNIFIED IDEOGRAPH
-0xE1E9	0x7845	#CJK UNIFIED IDEOGRAPH
-0xE1EA	0x788E	#CJK UNIFIED IDEOGRAPH
-0xE1EB	0x7874	#CJK UNIFIED IDEOGRAPH
-0xE1EC	0x7886	#CJK UNIFIED IDEOGRAPH
-0xE1ED	0x787C	#CJK UNIFIED IDEOGRAPH
-0xE1EE	0x789A	#CJK UNIFIED IDEOGRAPH
-0xE1EF	0x788C	#CJK UNIFIED IDEOGRAPH
-0xE1F0	0x78A3	#CJK UNIFIED IDEOGRAPH
-0xE1F1	0x78B5	#CJK UNIFIED IDEOGRAPH
-0xE1F2	0x78AA	#CJK UNIFIED IDEOGRAPH
-0xE1F3	0x78AF	#CJK UNIFIED IDEOGRAPH
-0xE1F4	0x78D1	#CJK UNIFIED IDEOGRAPH
-0xE1F5	0x78C6	#CJK UNIFIED IDEOGRAPH
-0xE1F6	0x78CB	#CJK UNIFIED IDEOGRAPH
-0xE1F7	0x78D4	#CJK UNIFIED IDEOGRAPH
-0xE1F8	0x78BE	#CJK UNIFIED IDEOGRAPH
-0xE1F9	0x78BC	#CJK UNIFIED IDEOGRAPH
-0xE1FA	0x78C5	#CJK UNIFIED IDEOGRAPH
-0xE1FB	0x78CA	#CJK UNIFIED IDEOGRAPH
-0xE1FC	0x78EC	#CJK UNIFIED IDEOGRAPH
-0xE240	0x78E7	#CJK UNIFIED IDEOGRAPH
-0xE241	0x78DA	#CJK UNIFIED IDEOGRAPH
-0xE242	0x78FD	#CJK UNIFIED IDEOGRAPH
-0xE243	0x78F4	#CJK UNIFIED IDEOGRAPH
-0xE244	0x7907	#CJK UNIFIED IDEOGRAPH
-0xE245	0x7912	#CJK UNIFIED IDEOGRAPH
-0xE246	0x7911	#CJK UNIFIED IDEOGRAPH
-0xE247	0x7919	#CJK UNIFIED IDEOGRAPH
-0xE248	0x792C	#CJK UNIFIED IDEOGRAPH
-0xE249	0x792B	#CJK UNIFIED IDEOGRAPH
-0xE24A	0x7940	#CJK UNIFIED IDEOGRAPH
-0xE24B	0x7960	#CJK UNIFIED IDEOGRAPH
-0xE24C	0x7957	#CJK UNIFIED IDEOGRAPH
-0xE24D	0x795F	#CJK UNIFIED IDEOGRAPH
-0xE24E	0x795A	#CJK UNIFIED IDEOGRAPH
-0xE24F	0x7955	#CJK UNIFIED IDEOGRAPH
-0xE250	0x7953	#CJK UNIFIED IDEOGRAPH
-0xE251	0x797A	#CJK UNIFIED IDEOGRAPH
-0xE252	0x797F	#CJK UNIFIED IDEOGRAPH
-0xE253	0x798A	#CJK UNIFIED IDEOGRAPH
-0xE254	0x799D	#CJK UNIFIED IDEOGRAPH
-0xE255	0x79A7	#CJK UNIFIED IDEOGRAPH
-0xE256	0x9F4B	#CJK UNIFIED IDEOGRAPH
-0xE257	0x79AA	#CJK UNIFIED IDEOGRAPH
-0xE258	0x79AE	#CJK UNIFIED IDEOGRAPH
-0xE259	0x79B3	#CJK UNIFIED IDEOGRAPH
-0xE25A	0x79B9	#CJK UNIFIED IDEOGRAPH
-0xE25B	0x79BA	#CJK UNIFIED IDEOGRAPH
-0xE25C	0x79C9	#CJK UNIFIED IDEOGRAPH
-0xE25D	0x79D5	#CJK UNIFIED IDEOGRAPH
-0xE25E	0x79E7	#CJK UNIFIED IDEOGRAPH
-0xE25F	0x79EC	#CJK UNIFIED IDEOGRAPH
-0xE260	0x79E1	#CJK UNIFIED IDEOGRAPH
-0xE261	0x79E3	#CJK UNIFIED IDEOGRAPH
-0xE262	0x7A08	#CJK UNIFIED IDEOGRAPH
-0xE263	0x7A0D	#CJK UNIFIED IDEOGRAPH
-0xE264	0x7A18	#CJK UNIFIED IDEOGRAPH
-0xE265	0x7A19	#CJK UNIFIED IDEOGRAPH
-0xE266	0x7A20	#CJK UNIFIED IDEOGRAPH
-0xE267	0x7A1F	#CJK UNIFIED IDEOGRAPH
-0xE268	0x7980	#CJK UNIFIED IDEOGRAPH
-0xE269	0x7A31	#CJK UNIFIED IDEOGRAPH
-0xE26A	0x7A3B	#CJK UNIFIED IDEOGRAPH
-0xE26B	0x7A3E	#CJK UNIFIED IDEOGRAPH
-0xE26C	0x7A37	#CJK UNIFIED IDEOGRAPH
-0xE26D	0x7A43	#CJK UNIFIED IDEOGRAPH
-0xE26E	0x7A57	#CJK UNIFIED IDEOGRAPH
-0xE26F	0x7A49	#CJK UNIFIED IDEOGRAPH
-0xE270	0x7A61	#CJK UNIFIED IDEOGRAPH
-0xE271	0x7A62	#CJK UNIFIED IDEOGRAPH
-0xE272	0x7A69	#CJK UNIFIED IDEOGRAPH
-0xE273	0x9F9D	#CJK UNIFIED IDEOGRAPH
-0xE274	0x7A70	#CJK UNIFIED IDEOGRAPH
-0xE275	0x7A79	#CJK UNIFIED IDEOGRAPH
-0xE276	0x7A7D	#CJK UNIFIED IDEOGRAPH
-0xE277	0x7A88	#CJK UNIFIED IDEOGRAPH
-0xE278	0x7A97	#CJK UNIFIED IDEOGRAPH
-0xE279	0x7A95	#CJK UNIFIED IDEOGRAPH
-0xE27A	0x7A98	#CJK UNIFIED IDEOGRAPH
-0xE27B	0x7A96	#CJK UNIFIED IDEOGRAPH
-0xE27C	0x7AA9	#CJK UNIFIED IDEOGRAPH
-0xE27D	0x7AC8	#CJK UNIFIED IDEOGRAPH
-0xE27E	0x7AB0	#CJK UNIFIED IDEOGRAPH
-0xE280	0x7AB6	#CJK UNIFIED IDEOGRAPH
-0xE281	0x7AC5	#CJK UNIFIED IDEOGRAPH
-0xE282	0x7AC4	#CJK UNIFIED IDEOGRAPH
-0xE283	0x7ABF	#CJK UNIFIED IDEOGRAPH
-0xE284	0x9083	#CJK UNIFIED IDEOGRAPH
-0xE285	0x7AC7	#CJK UNIFIED IDEOGRAPH
-0xE286	0x7ACA	#CJK UNIFIED IDEOGRAPH
-0xE287	0x7ACD	#CJK UNIFIED IDEOGRAPH
-0xE288	0x7ACF	#CJK UNIFIED IDEOGRAPH
-0xE289	0x7AD5	#CJK UNIFIED IDEOGRAPH
-0xE28A	0x7AD3	#CJK UNIFIED IDEOGRAPH
-0xE28B	0x7AD9	#CJK UNIFIED IDEOGRAPH
-0xE28C	0x7ADA	#CJK UNIFIED IDEOGRAPH
-0xE28D	0x7ADD	#CJK UNIFIED IDEOGRAPH
-0xE28E	0x7AE1	#CJK UNIFIED IDEOGRAPH
-0xE28F	0x7AE2	#CJK UNIFIED IDEOGRAPH
-0xE290	0x7AE6	#CJK UNIFIED IDEOGRAPH
-0xE291	0x7AED	#CJK UNIFIED IDEOGRAPH
-0xE292	0x7AF0	#CJK UNIFIED IDEOGRAPH
-0xE293	0x7B02	#CJK UNIFIED IDEOGRAPH
-0xE294	0x7B0F	#CJK UNIFIED IDEOGRAPH
-0xE295	0x7B0A	#CJK UNIFIED IDEOGRAPH
-0xE296	0x7B06	#CJK UNIFIED IDEOGRAPH
-0xE297	0x7B33	#CJK UNIFIED IDEOGRAPH
-0xE298	0x7B18	#CJK UNIFIED IDEOGRAPH
-0xE299	0x7B19	#CJK UNIFIED IDEOGRAPH
-0xE29A	0x7B1E	#CJK UNIFIED IDEOGRAPH
-0xE29B	0x7B35	#CJK UNIFIED IDEOGRAPH
-0xE29C	0x7B28	#CJK UNIFIED IDEOGRAPH
-0xE29D	0x7B36	#CJK UNIFIED IDEOGRAPH
-0xE29E	0x7B50	#CJK UNIFIED IDEOGRAPH
-0xE29F	0x7B7A	#CJK UNIFIED IDEOGRAPH
-0xE2A0	0x7B04	#CJK UNIFIED IDEOGRAPH
-0xE2A1	0x7B4D	#CJK UNIFIED IDEOGRAPH
-0xE2A2	0x7B0B	#CJK UNIFIED IDEOGRAPH
-0xE2A3	0x7B4C	#CJK UNIFIED IDEOGRAPH
-0xE2A4	0x7B45	#CJK UNIFIED IDEOGRAPH
-0xE2A5	0x7B75	#CJK UNIFIED IDEOGRAPH
-0xE2A6	0x7B65	#CJK UNIFIED IDEOGRAPH
-0xE2A7	0x7B74	#CJK UNIFIED IDEOGRAPH
-0xE2A8	0x7B67	#CJK UNIFIED IDEOGRAPH
-0xE2A9	0x7B70	#CJK UNIFIED IDEOGRAPH
-0xE2AA	0x7B71	#CJK UNIFIED IDEOGRAPH
-0xE2AB	0x7B6C	#CJK UNIFIED IDEOGRAPH
-0xE2AC	0x7B6E	#CJK UNIFIED IDEOGRAPH
-0xE2AD	0x7B9D	#CJK UNIFIED IDEOGRAPH
-0xE2AE	0x7B98	#CJK UNIFIED IDEOGRAPH
-0xE2AF	0x7B9F	#CJK UNIFIED IDEOGRAPH
-0xE2B0	0x7B8D	#CJK UNIFIED IDEOGRAPH
-0xE2B1	0x7B9C	#CJK UNIFIED IDEOGRAPH
-0xE2B2	0x7B9A	#CJK UNIFIED IDEOGRAPH
-0xE2B3	0x7B8B	#CJK UNIFIED IDEOGRAPH
-0xE2B4	0x7B92	#CJK UNIFIED IDEOGRAPH
-0xE2B5	0x7B8F	#CJK UNIFIED IDEOGRAPH
-0xE2B6	0x7B5D	#CJK UNIFIED IDEOGRAPH
-0xE2B7	0x7B99	#CJK UNIFIED IDEOGRAPH
-0xE2B8	0x7BCB	#CJK UNIFIED IDEOGRAPH
-0xE2B9	0x7BC1	#CJK UNIFIED IDEOGRAPH
-0xE2BA	0x7BCC	#CJK UNIFIED IDEOGRAPH
-0xE2BB	0x7BCF	#CJK UNIFIED IDEOGRAPH
-0xE2BC	0x7BB4	#CJK UNIFIED IDEOGRAPH
-0xE2BD	0x7BC6	#CJK UNIFIED IDEOGRAPH
-0xE2BE	0x7BDD	#CJK UNIFIED IDEOGRAPH
-0xE2BF	0x7BE9	#CJK UNIFIED IDEOGRAPH
-0xE2C0	0x7C11	#CJK UNIFIED IDEOGRAPH
-0xE2C1	0x7C14	#CJK UNIFIED IDEOGRAPH
-0xE2C2	0x7BE6	#CJK UNIFIED IDEOGRAPH
-0xE2C3	0x7BE5	#CJK UNIFIED IDEOGRAPH
-0xE2C4	0x7C60	#CJK UNIFIED IDEOGRAPH
-0xE2C5	0x7C00	#CJK UNIFIED IDEOGRAPH
-0xE2C6	0x7C07	#CJK UNIFIED IDEOGRAPH
-0xE2C7	0x7C13	#CJK UNIFIED IDEOGRAPH
-0xE2C8	0x7BF3	#CJK UNIFIED IDEOGRAPH
-0xE2C9	0x7BF7	#CJK UNIFIED IDEOGRAPH
-0xE2CA	0x7C17	#CJK UNIFIED IDEOGRAPH
-0xE2CB	0x7C0D	#CJK UNIFIED IDEOGRAPH
-0xE2CC	0x7BF6	#CJK UNIFIED IDEOGRAPH
-0xE2CD	0x7C23	#CJK UNIFIED IDEOGRAPH
-0xE2CE	0x7C27	#CJK UNIFIED IDEOGRAPH
-0xE2CF	0x7C2A	#CJK UNIFIED IDEOGRAPH
-0xE2D0	0x7C1F	#CJK UNIFIED IDEOGRAPH
-0xE2D1	0x7C37	#CJK UNIFIED IDEOGRAPH
-0xE2D2	0x7C2B	#CJK UNIFIED IDEOGRAPH
-0xE2D3	0x7C3D	#CJK UNIFIED IDEOGRAPH
-0xE2D4	0x7C4C	#CJK UNIFIED IDEOGRAPH
-0xE2D5	0x7C43	#CJK UNIFIED IDEOGRAPH
-0xE2D6	0x7C54	#CJK UNIFIED IDEOGRAPH
-0xE2D7	0x7C4F	#CJK UNIFIED IDEOGRAPH
-0xE2D8	0x7C40	#CJK UNIFIED IDEOGRAPH
-0xE2D9	0x7C50	#CJK UNIFIED IDEOGRAPH
-0xE2DA	0x7C58	#CJK UNIFIED IDEOGRAPH
-0xE2DB	0x7C5F	#CJK UNIFIED IDEOGRAPH
-0xE2DC	0x7C64	#CJK UNIFIED IDEOGRAPH
-0xE2DD	0x7C56	#CJK UNIFIED IDEOGRAPH
-0xE2DE	0x7C65	#CJK UNIFIED IDEOGRAPH
-0xE2DF	0x7C6C	#CJK UNIFIED IDEOGRAPH
-0xE2E0	0x7C75	#CJK UNIFIED IDEOGRAPH
-0xE2E1	0x7C83	#CJK UNIFIED IDEOGRAPH
-0xE2E2	0x7C90	#CJK UNIFIED IDEOGRAPH
-0xE2E3	0x7CA4	#CJK UNIFIED IDEOGRAPH
-0xE2E4	0x7CAD	#CJK UNIFIED IDEOGRAPH
-0xE2E5	0x7CA2	#CJK UNIFIED IDEOGRAPH
-0xE2E6	0x7CAB	#CJK UNIFIED IDEOGRAPH
-0xE2E7	0x7CA1	#CJK UNIFIED IDEOGRAPH
-0xE2E8	0x7CA8	#CJK UNIFIED IDEOGRAPH
-0xE2E9	0x7CB3	#CJK UNIFIED IDEOGRAPH
-0xE2EA	0x7CB2	#CJK UNIFIED IDEOGRAPH
-0xE2EB	0x7CB1	#CJK UNIFIED IDEOGRAPH
-0xE2EC	0x7CAE	#CJK UNIFIED IDEOGRAPH
-0xE2ED	0x7CB9	#CJK UNIFIED IDEOGRAPH
-0xE2EE	0x7CBD	#CJK UNIFIED IDEOGRAPH
-0xE2EF	0x7CC0	#CJK UNIFIED IDEOGRAPH
-0xE2F0	0x7CC5	#CJK UNIFIED IDEOGRAPH
-0xE2F1	0x7CC2	#CJK UNIFIED IDEOGRAPH
-0xE2F2	0x7CD8	#CJK UNIFIED IDEOGRAPH
-0xE2F3	0x7CD2	#CJK UNIFIED IDEOGRAPH
-0xE2F4	0x7CDC	#CJK UNIFIED IDEOGRAPH
-0xE2F5	0x7CE2	#CJK UNIFIED IDEOGRAPH
-0xE2F6	0x9B3B	#CJK UNIFIED IDEOGRAPH
-0xE2F7	0x7CEF	#CJK UNIFIED IDEOGRAPH
-0xE2F8	0x7CF2	#CJK UNIFIED IDEOGRAPH
-0xE2F9	0x7CF4	#CJK UNIFIED IDEOGRAPH
-0xE2FA	0x7CF6	#CJK UNIFIED IDEOGRAPH
-0xE2FB	0x7CFA	#CJK UNIFIED IDEOGRAPH
-0xE2FC	0x7D06	#CJK UNIFIED IDEOGRAPH
-0xE340	0x7D02	#CJK UNIFIED IDEOGRAPH
-0xE341	0x7D1C	#CJK UNIFIED IDEOGRAPH
-0xE342	0x7D15	#CJK UNIFIED IDEOGRAPH
-0xE343	0x7D0A	#CJK UNIFIED IDEOGRAPH
-0xE344	0x7D45	#CJK UNIFIED IDEOGRAPH
-0xE345	0x7D4B	#CJK UNIFIED IDEOGRAPH
-0xE346	0x7D2E	#CJK UNIFIED IDEOGRAPH
-0xE347	0x7D32	#CJK UNIFIED IDEOGRAPH
-0xE348	0x7D3F	#CJK UNIFIED IDEOGRAPH
-0xE349	0x7D35	#CJK UNIFIED IDEOGRAPH
-0xE34A	0x7D46	#CJK UNIFIED IDEOGRAPH
-0xE34B	0x7D73	#CJK UNIFIED IDEOGRAPH
-0xE34C	0x7D56	#CJK UNIFIED IDEOGRAPH
-0xE34D	0x7D4E	#CJK UNIFIED IDEOGRAPH
-0xE34E	0x7D72	#CJK UNIFIED IDEOGRAPH
-0xE34F	0x7D68	#CJK UNIFIED IDEOGRAPH
-0xE350	0x7D6E	#CJK UNIFIED IDEOGRAPH
-0xE351	0x7D4F	#CJK UNIFIED IDEOGRAPH
-0xE352	0x7D63	#CJK UNIFIED IDEOGRAPH
-0xE353	0x7D93	#CJK UNIFIED IDEOGRAPH
-0xE354	0x7D89	#CJK UNIFIED IDEOGRAPH
-0xE355	0x7D5B	#CJK UNIFIED IDEOGRAPH
-0xE356	0x7D8F	#CJK UNIFIED IDEOGRAPH
-0xE357	0x7D7D	#CJK UNIFIED IDEOGRAPH
-0xE358	0x7D9B	#CJK UNIFIED IDEOGRAPH
-0xE359	0x7DBA	#CJK UNIFIED IDEOGRAPH
-0xE35A	0x7DAE	#CJK UNIFIED IDEOGRAPH
-0xE35B	0x7DA3	#CJK UNIFIED IDEOGRAPH
-0xE35C	0x7DB5	#CJK UNIFIED IDEOGRAPH
-0xE35D	0x7DC7	#CJK UNIFIED IDEOGRAPH
-0xE35E	0x7DBD	#CJK UNIFIED IDEOGRAPH
-0xE35F	0x7DAB	#CJK UNIFIED IDEOGRAPH
-0xE360	0x7E3D	#CJK UNIFIED IDEOGRAPH
-0xE361	0x7DA2	#CJK UNIFIED IDEOGRAPH
-0xE362	0x7DAF	#CJK UNIFIED IDEOGRAPH
-0xE363	0x7DDC	#CJK UNIFIED IDEOGRAPH
-0xE364	0x7DB8	#CJK UNIFIED IDEOGRAPH
-0xE365	0x7D9F	#CJK UNIFIED IDEOGRAPH
-0xE366	0x7DB0	#CJK UNIFIED IDEOGRAPH
-0xE367	0x7DD8	#CJK UNIFIED IDEOGRAPH
-0xE368	0x7DDD	#CJK UNIFIED IDEOGRAPH
-0xE369	0x7DE4	#CJK UNIFIED IDEOGRAPH
-0xE36A	0x7DDE	#CJK UNIFIED IDEOGRAPH
-0xE36B	0x7DFB	#CJK UNIFIED IDEOGRAPH
-0xE36C	0x7DF2	#CJK UNIFIED IDEOGRAPH
-0xE36D	0x7DE1	#CJK UNIFIED IDEOGRAPH
-0xE36E	0x7E05	#CJK UNIFIED IDEOGRAPH
-0xE36F	0x7E0A	#CJK UNIFIED IDEOGRAPH
-0xE370	0x7E23	#CJK UNIFIED IDEOGRAPH
-0xE371	0x7E21	#CJK UNIFIED IDEOGRAPH
-0xE372	0x7E12	#CJK UNIFIED IDEOGRAPH
-0xE373	0x7E31	#CJK UNIFIED IDEOGRAPH
-0xE374	0x7E1F	#CJK UNIFIED IDEOGRAPH
-0xE375	0x7E09	#CJK UNIFIED IDEOGRAPH
-0xE376	0x7E0B	#CJK UNIFIED IDEOGRAPH
-0xE377	0x7E22	#CJK UNIFIED IDEOGRAPH
-0xE378	0x7E46	#CJK UNIFIED IDEOGRAPH
-0xE379	0x7E66	#CJK UNIFIED IDEOGRAPH
-0xE37A	0x7E3B	#CJK UNIFIED IDEOGRAPH
-0xE37B	0x7E35	#CJK UNIFIED IDEOGRAPH
-0xE37C	0x7E39	#CJK UNIFIED IDEOGRAPH
-0xE37D	0x7E43	#CJK UNIFIED IDEOGRAPH
-0xE37E	0x7E37	#CJK UNIFIED IDEOGRAPH
-0xE380	0x7E32	#CJK UNIFIED IDEOGRAPH
-0xE381	0x7E3A	#CJK UNIFIED IDEOGRAPH
-0xE382	0x7E67	#CJK UNIFIED IDEOGRAPH
-0xE383	0x7E5D	#CJK UNIFIED IDEOGRAPH
-0xE384	0x7E56	#CJK UNIFIED IDEOGRAPH
-0xE385	0x7E5E	#CJK UNIFIED IDEOGRAPH
-0xE386	0x7E59	#CJK UNIFIED IDEOGRAPH
-0xE387	0x7E5A	#CJK UNIFIED IDEOGRAPH
-0xE388	0x7E79	#CJK UNIFIED IDEOGRAPH
-0xE389	0x7E6A	#CJK UNIFIED IDEOGRAPH
-0xE38A	0x7E69	#CJK UNIFIED IDEOGRAPH
-0xE38B	0x7E7C	#CJK UNIFIED IDEOGRAPH
-0xE38C	0x7E7B	#CJK UNIFIED IDEOGRAPH
-0xE38D	0x7E83	#CJK UNIFIED IDEOGRAPH
-0xE38E	0x7DD5	#CJK UNIFIED IDEOGRAPH
-0xE38F	0x7E7D	#CJK UNIFIED IDEOGRAPH
-0xE390	0x8FAE	#CJK UNIFIED IDEOGRAPH
-0xE391	0x7E7F	#CJK UNIFIED IDEOGRAPH
-0xE392	0x7E88	#CJK UNIFIED IDEOGRAPH
-0xE393	0x7E89	#CJK UNIFIED IDEOGRAPH
-0xE394	0x7E8C	#CJK UNIFIED IDEOGRAPH
-0xE395	0x7E92	#CJK UNIFIED IDEOGRAPH
-0xE396	0x7E90	#CJK UNIFIED IDEOGRAPH
-0xE397	0x7E93	#CJK UNIFIED IDEOGRAPH
-0xE398	0x7E94	#CJK UNIFIED IDEOGRAPH
-0xE399	0x7E96	#CJK UNIFIED IDEOGRAPH
-0xE39A	0x7E8E	#CJK UNIFIED IDEOGRAPH
-0xE39B	0x7E9B	#CJK UNIFIED IDEOGRAPH
-0xE39C	0x7E9C	#CJK UNIFIED IDEOGRAPH
-0xE39D	0x7F38	#CJK UNIFIED IDEOGRAPH
-0xE39E	0x7F3A	#CJK UNIFIED IDEOGRAPH
-0xE39F	0x7F45	#CJK UNIFIED IDEOGRAPH
-0xE3A0	0x7F4C	#CJK UNIFIED IDEOGRAPH
-0xE3A1	0x7F4D	#CJK UNIFIED IDEOGRAPH
-0xE3A2	0x7F4E	#CJK UNIFIED IDEOGRAPH
-0xE3A3	0x7F50	#CJK UNIFIED IDEOGRAPH
-0xE3A4	0x7F51	#CJK UNIFIED IDEOGRAPH
-0xE3A5	0x7F55	#CJK UNIFIED IDEOGRAPH
-0xE3A6	0x7F54	#CJK UNIFIED IDEOGRAPH
-0xE3A7	0x7F58	#CJK UNIFIED IDEOGRAPH
-0xE3A8	0x7F5F	#CJK UNIFIED IDEOGRAPH
-0xE3A9	0x7F60	#CJK UNIFIED IDEOGRAPH
-0xE3AA	0x7F68	#CJK UNIFIED IDEOGRAPH
-0xE3AB	0x7F69	#CJK UNIFIED IDEOGRAPH
-0xE3AC	0x7F67	#CJK UNIFIED IDEOGRAPH
-0xE3AD	0x7F78	#CJK UNIFIED IDEOGRAPH
-0xE3AE	0x7F82	#CJK UNIFIED IDEOGRAPH
-0xE3AF	0x7F86	#CJK UNIFIED IDEOGRAPH
-0xE3B0	0x7F83	#CJK UNIFIED IDEOGRAPH
-0xE3B1	0x7F88	#CJK UNIFIED IDEOGRAPH
-0xE3B2	0x7F87	#CJK UNIFIED IDEOGRAPH
-0xE3B3	0x7F8C	#CJK UNIFIED IDEOGRAPH
-0xE3B4	0x7F94	#CJK UNIFIED IDEOGRAPH
-0xE3B5	0x7F9E	#CJK UNIFIED IDEOGRAPH
-0xE3B6	0x7F9D	#CJK UNIFIED IDEOGRAPH
-0xE3B7	0x7F9A	#CJK UNIFIED IDEOGRAPH
-0xE3B8	0x7FA3	#CJK UNIFIED IDEOGRAPH
-0xE3B9	0x7FAF	#CJK UNIFIED IDEOGRAPH
-0xE3BA	0x7FB2	#CJK UNIFIED IDEOGRAPH
-0xE3BB	0x7FB9	#CJK UNIFIED IDEOGRAPH
-0xE3BC	0x7FAE	#CJK UNIFIED IDEOGRAPH
-0xE3BD	0x7FB6	#CJK UNIFIED IDEOGRAPH
-0xE3BE	0x7FB8	#CJK UNIFIED IDEOGRAPH
-0xE3BF	0x8B71	#CJK UNIFIED IDEOGRAPH
-0xE3C0	0x7FC5	#CJK UNIFIED IDEOGRAPH
-0xE3C1	0x7FC6	#CJK UNIFIED IDEOGRAPH
-0xE3C2	0x7FCA	#CJK UNIFIED IDEOGRAPH
-0xE3C3	0x7FD5	#CJK UNIFIED IDEOGRAPH
-0xE3C4	0x7FD4	#CJK UNIFIED IDEOGRAPH
-0xE3C5	0x7FE1	#CJK UNIFIED IDEOGRAPH
-0xE3C6	0x7FE6	#CJK UNIFIED IDEOGRAPH
-0xE3C7	0x7FE9	#CJK UNIFIED IDEOGRAPH
-0xE3C8	0x7FF3	#CJK UNIFIED IDEOGRAPH
-0xE3C9	0x7FF9	#CJK UNIFIED IDEOGRAPH
-0xE3CA	0x98DC	#CJK UNIFIED IDEOGRAPH
-0xE3CB	0x8006	#CJK UNIFIED IDEOGRAPH
-0xE3CC	0x8004	#CJK UNIFIED IDEOGRAPH
-0xE3CD	0x800B	#CJK UNIFIED IDEOGRAPH
-0xE3CE	0x8012	#CJK UNIFIED IDEOGRAPH
-0xE3CF	0x8018	#CJK UNIFIED IDEOGRAPH
-0xE3D0	0x8019	#CJK UNIFIED IDEOGRAPH
-0xE3D1	0x801C	#CJK UNIFIED IDEOGRAPH
-0xE3D2	0x8021	#CJK UNIFIED IDEOGRAPH
-0xE3D3	0x8028	#CJK UNIFIED IDEOGRAPH
-0xE3D4	0x803F	#CJK UNIFIED IDEOGRAPH
-0xE3D5	0x803B	#CJK UNIFIED IDEOGRAPH
-0xE3D6	0x804A	#CJK UNIFIED IDEOGRAPH
-0xE3D7	0x8046	#CJK UNIFIED IDEOGRAPH
-0xE3D8	0x8052	#CJK UNIFIED IDEOGRAPH
-0xE3D9	0x8058	#CJK UNIFIED IDEOGRAPH
-0xE3DA	0x805A	#CJK UNIFIED IDEOGRAPH
-0xE3DB	0x805F	#CJK UNIFIED IDEOGRAPH
-0xE3DC	0x8062	#CJK UNIFIED IDEOGRAPH
-0xE3DD	0x8068	#CJK UNIFIED IDEOGRAPH
-0xE3DE	0x8073	#CJK UNIFIED IDEOGRAPH
-0xE3DF	0x8072	#CJK UNIFIED IDEOGRAPH
-0xE3E0	0x8070	#CJK UNIFIED IDEOGRAPH
-0xE3E1	0x8076	#CJK UNIFIED IDEOGRAPH
-0xE3E2	0x8079	#CJK UNIFIED IDEOGRAPH
-0xE3E3	0x807D	#CJK UNIFIED IDEOGRAPH
-0xE3E4	0x807F	#CJK UNIFIED IDEOGRAPH
-0xE3E5	0x8084	#CJK UNIFIED IDEOGRAPH
-0xE3E6	0x8086	#CJK UNIFIED IDEOGRAPH
-0xE3E7	0x8085	#CJK UNIFIED IDEOGRAPH
-0xE3E8	0x809B	#CJK UNIFIED IDEOGRAPH
-0xE3E9	0x8093	#CJK UNIFIED IDEOGRAPH
-0xE3EA	0x809A	#CJK UNIFIED IDEOGRAPH
-0xE3EB	0x80AD	#CJK UNIFIED IDEOGRAPH
-0xE3EC	0x5190	#CJK UNIFIED IDEOGRAPH
-0xE3ED	0x80AC	#CJK UNIFIED IDEOGRAPH
-0xE3EE	0x80DB	#CJK UNIFIED IDEOGRAPH
-0xE3EF	0x80E5	#CJK UNIFIED IDEOGRAPH
-0xE3F0	0x80D9	#CJK UNIFIED IDEOGRAPH
-0xE3F1	0x80DD	#CJK UNIFIED IDEOGRAPH
-0xE3F2	0x80C4	#CJK UNIFIED IDEOGRAPH
-0xE3F3	0x80DA	#CJK UNIFIED IDEOGRAPH
-0xE3F4	0x80D6	#CJK UNIFIED IDEOGRAPH
-0xE3F5	0x8109	#CJK UNIFIED IDEOGRAPH
-0xE3F6	0x80EF	#CJK UNIFIED IDEOGRAPH
-0xE3F7	0x80F1	#CJK UNIFIED IDEOGRAPH
-0xE3F8	0x811B	#CJK UNIFIED IDEOGRAPH
-0xE3F9	0x8129	#CJK UNIFIED IDEOGRAPH
-0xE3FA	0x8123	#CJK UNIFIED IDEOGRAPH
-0xE3FB	0x812F	#CJK UNIFIED IDEOGRAPH
-0xE3FC	0x814B	#CJK UNIFIED IDEOGRAPH
-0xE440	0x968B	#CJK UNIFIED IDEOGRAPH
-0xE441	0x8146	#CJK UNIFIED IDEOGRAPH
-0xE442	0x813E	#CJK UNIFIED IDEOGRAPH
-0xE443	0x8153	#CJK UNIFIED IDEOGRAPH
-0xE444	0x8151	#CJK UNIFIED IDEOGRAPH
-0xE445	0x80FC	#CJK UNIFIED IDEOGRAPH
-0xE446	0x8171	#CJK UNIFIED IDEOGRAPH
-0xE447	0x816E	#CJK UNIFIED IDEOGRAPH
-0xE448	0x8165	#CJK UNIFIED IDEOGRAPH
-0xE449	0x8166	#CJK UNIFIED IDEOGRAPH
-0xE44A	0x8174	#CJK UNIFIED IDEOGRAPH
-0xE44B	0x8183	#CJK UNIFIED IDEOGRAPH
-0xE44C	0x8188	#CJK UNIFIED IDEOGRAPH
-0xE44D	0x818A	#CJK UNIFIED IDEOGRAPH
-0xE44E	0x8180	#CJK UNIFIED IDEOGRAPH
-0xE44F	0x8182	#CJK UNIFIED IDEOGRAPH
-0xE450	0x81A0	#CJK UNIFIED IDEOGRAPH
-0xE451	0x8195	#CJK UNIFIED IDEOGRAPH
-0xE452	0x81A4	#CJK UNIFIED IDEOGRAPH
-0xE453	0x81A3	#CJK UNIFIED IDEOGRAPH
-0xE454	0x815F	#CJK UNIFIED IDEOGRAPH
-0xE455	0x8193	#CJK UNIFIED IDEOGRAPH
-0xE456	0x81A9	#CJK UNIFIED IDEOGRAPH
-0xE457	0x81B0	#CJK UNIFIED IDEOGRAPH
-0xE458	0x81B5	#CJK UNIFIED IDEOGRAPH
-0xE459	0x81BE	#CJK UNIFIED IDEOGRAPH
-0xE45A	0x81B8	#CJK UNIFIED IDEOGRAPH
-0xE45B	0x81BD	#CJK UNIFIED IDEOGRAPH
-0xE45C	0x81C0	#CJK UNIFIED IDEOGRAPH
-0xE45D	0x81C2	#CJK UNIFIED IDEOGRAPH
-0xE45E	0x81BA	#CJK UNIFIED IDEOGRAPH
-0xE45F	0x81C9	#CJK UNIFIED IDEOGRAPH
-0xE460	0x81CD	#CJK UNIFIED IDEOGRAPH
-0xE461	0x81D1	#CJK UNIFIED IDEOGRAPH
-0xE462	0x81D9	#CJK UNIFIED IDEOGRAPH
-0xE463	0x81D8	#CJK UNIFIED IDEOGRAPH
-0xE464	0x81C8	#CJK UNIFIED IDEOGRAPH
-0xE465	0x81DA	#CJK UNIFIED IDEOGRAPH
-0xE466	0x81DF	#CJK UNIFIED IDEOGRAPH
-0xE467	0x81E0	#CJK UNIFIED IDEOGRAPH
-0xE468	0x81E7	#CJK UNIFIED IDEOGRAPH
-0xE469	0x81FA	#CJK UNIFIED IDEOGRAPH
-0xE46A	0x81FB	#CJK UNIFIED IDEOGRAPH
-0xE46B	0x81FE	#CJK UNIFIED IDEOGRAPH
-0xE46C	0x8201	#CJK UNIFIED IDEOGRAPH
-0xE46D	0x8202	#CJK UNIFIED IDEOGRAPH
-0xE46E	0x8205	#CJK UNIFIED IDEOGRAPH
-0xE46F	0x8207	#CJK UNIFIED IDEOGRAPH
-0xE470	0x820A	#CJK UNIFIED IDEOGRAPH
-0xE471	0x820D	#CJK UNIFIED IDEOGRAPH
-0xE472	0x8210	#CJK UNIFIED IDEOGRAPH
-0xE473	0x8216	#CJK UNIFIED IDEOGRAPH
-0xE474	0x8229	#CJK UNIFIED IDEOGRAPH
-0xE475	0x822B	#CJK UNIFIED IDEOGRAPH
-0xE476	0x8238	#CJK UNIFIED IDEOGRAPH
-0xE477	0x8233	#CJK UNIFIED IDEOGRAPH
-0xE478	0x8240	#CJK UNIFIED IDEOGRAPH
-0xE479	0x8259	#CJK UNIFIED IDEOGRAPH
-0xE47A	0x8258	#CJK UNIFIED IDEOGRAPH
-0xE47B	0x825D	#CJK UNIFIED IDEOGRAPH
-0xE47C	0x825A	#CJK UNIFIED IDEOGRAPH
-0xE47D	0x825F	#CJK UNIFIED IDEOGRAPH
-0xE47E	0x8264	#CJK UNIFIED IDEOGRAPH
-0xE480	0x8262	#CJK UNIFIED IDEOGRAPH
-0xE481	0x8268	#CJK UNIFIED IDEOGRAPH
-0xE482	0x826A	#CJK UNIFIED IDEOGRAPH
-0xE483	0x826B	#CJK UNIFIED IDEOGRAPH
-0xE484	0x822E	#CJK UNIFIED IDEOGRAPH
-0xE485	0x8271	#CJK UNIFIED IDEOGRAPH
-0xE486	0x8277	#CJK UNIFIED IDEOGRAPH
-0xE487	0x8278	#CJK UNIFIED IDEOGRAPH
-0xE488	0x827E	#CJK UNIFIED IDEOGRAPH
-0xE489	0x828D	#CJK UNIFIED IDEOGRAPH
-0xE48A	0x8292	#CJK UNIFIED IDEOGRAPH
-0xE48B	0x82AB	#CJK UNIFIED IDEOGRAPH
-0xE48C	0x829F	#CJK UNIFIED IDEOGRAPH
-0xE48D	0x82BB	#CJK UNIFIED IDEOGRAPH
-0xE48E	0x82AC	#CJK UNIFIED IDEOGRAPH
-0xE48F	0x82E1	#CJK UNIFIED IDEOGRAPH
-0xE490	0x82E3	#CJK UNIFIED IDEOGRAPH
-0xE491	0x82DF	#CJK UNIFIED IDEOGRAPH
-0xE492	0x82D2	#CJK UNIFIED IDEOGRAPH
-0xE493	0x82F4	#CJK UNIFIED IDEOGRAPH
-0xE494	0x82F3	#CJK UNIFIED IDEOGRAPH
-0xE495	0x82FA	#CJK UNIFIED IDEOGRAPH
-0xE496	0x8393	#CJK UNIFIED IDEOGRAPH
-0xE497	0x8303	#CJK UNIFIED IDEOGRAPH
-0xE498	0x82FB	#CJK UNIFIED IDEOGRAPH
-0xE499	0x82F9	#CJK UNIFIED IDEOGRAPH
-0xE49A	0x82DE	#CJK UNIFIED IDEOGRAPH
-0xE49B	0x8306	#CJK UNIFIED IDEOGRAPH
-0xE49C	0x82DC	#CJK UNIFIED IDEOGRAPH
-0xE49D	0x8309	#CJK UNIFIED IDEOGRAPH
-0xE49E	0x82D9	#CJK UNIFIED IDEOGRAPH
-0xE49F	0x8335	#CJK UNIFIED IDEOGRAPH
-0xE4A0	0x8334	#CJK UNIFIED IDEOGRAPH
-0xE4A1	0x8316	#CJK UNIFIED IDEOGRAPH
-0xE4A2	0x8332	#CJK UNIFIED IDEOGRAPH
-0xE4A3	0x8331	#CJK UNIFIED IDEOGRAPH
-0xE4A4	0x8340	#CJK UNIFIED IDEOGRAPH
-0xE4A5	0x8339	#CJK UNIFIED IDEOGRAPH
-0xE4A6	0x8350	#CJK UNIFIED IDEOGRAPH
-0xE4A7	0x8345	#CJK UNIFIED IDEOGRAPH
-0xE4A8	0x832F	#CJK UNIFIED IDEOGRAPH
-0xE4A9	0x832B	#CJK UNIFIED IDEOGRAPH
-0xE4AA	0x8317	#CJK UNIFIED IDEOGRAPH
-0xE4AB	0x8318	#CJK UNIFIED IDEOGRAPH
-0xE4AC	0x8385	#CJK UNIFIED IDEOGRAPH
-0xE4AD	0x839A	#CJK UNIFIED IDEOGRAPH
-0xE4AE	0x83AA	#CJK UNIFIED IDEOGRAPH
-0xE4AF	0x839F	#CJK UNIFIED IDEOGRAPH
-0xE4B0	0x83A2	#CJK UNIFIED IDEOGRAPH
-0xE4B1	0x8396	#CJK UNIFIED IDEOGRAPH
-0xE4B2	0x8323	#CJK UNIFIED IDEOGRAPH
-0xE4B3	0x838E	#CJK UNIFIED IDEOGRAPH
-0xE4B4	0x8387	#CJK UNIFIED IDEOGRAPH
-0xE4B5	0x838A	#CJK UNIFIED IDEOGRAPH
-0xE4B6	0x837C	#CJK UNIFIED IDEOGRAPH
-0xE4B7	0x83B5	#CJK UNIFIED IDEOGRAPH
-0xE4B8	0x8373	#CJK UNIFIED IDEOGRAPH
-0xE4B9	0x8375	#CJK UNIFIED IDEOGRAPH
-0xE4BA	0x83A0	#CJK UNIFIED IDEOGRAPH
-0xE4BB	0x8389	#CJK UNIFIED IDEOGRAPH
-0xE4BC	0x83A8	#CJK UNIFIED IDEOGRAPH
-0xE4BD	0x83F4	#CJK UNIFIED IDEOGRAPH
-0xE4BE	0x8413	#CJK UNIFIED IDEOGRAPH
-0xE4BF	0x83EB	#CJK UNIFIED IDEOGRAPH
-0xE4C0	0x83CE	#CJK UNIFIED IDEOGRAPH
-0xE4C1	0x83FD	#CJK UNIFIED IDEOGRAPH
-0xE4C2	0x8403	#CJK UNIFIED IDEOGRAPH
-0xE4C3	0x83D8	#CJK UNIFIED IDEOGRAPH
-0xE4C4	0x840B	#CJK UNIFIED IDEOGRAPH
-0xE4C5	0x83C1	#CJK UNIFIED IDEOGRAPH
-0xE4C6	0x83F7	#CJK UNIFIED IDEOGRAPH
-0xE4C7	0x8407	#CJK UNIFIED IDEOGRAPH
-0xE4C8	0x83E0	#CJK UNIFIED IDEOGRAPH
-0xE4C9	0x83F2	#CJK UNIFIED IDEOGRAPH
-0xE4CA	0x840D	#CJK UNIFIED IDEOGRAPH
-0xE4CB	0x8422	#CJK UNIFIED IDEOGRAPH
-0xE4CC	0x8420	#CJK UNIFIED IDEOGRAPH
-0xE4CD	0x83BD	#CJK UNIFIED IDEOGRAPH
-0xE4CE	0x8438	#CJK UNIFIED IDEOGRAPH
-0xE4CF	0x8506	#CJK UNIFIED IDEOGRAPH
-0xE4D0	0x83FB	#CJK UNIFIED IDEOGRAPH
-0xE4D1	0x846D	#CJK UNIFIED IDEOGRAPH
-0xE4D2	0x842A	#CJK UNIFIED IDEOGRAPH
-0xE4D3	0x843C	#CJK UNIFIED IDEOGRAPH
-0xE4D4	0x855A	#CJK UNIFIED IDEOGRAPH
-0xE4D5	0x8484	#CJK UNIFIED IDEOGRAPH
-0xE4D6	0x8477	#CJK UNIFIED IDEOGRAPH
-0xE4D7	0x846B	#CJK UNIFIED IDEOGRAPH
-0xE4D8	0x84AD	#CJK UNIFIED IDEOGRAPH
-0xE4D9	0x846E	#CJK UNIFIED IDEOGRAPH
-0xE4DA	0x8482	#CJK UNIFIED IDEOGRAPH
-0xE4DB	0x8469	#CJK UNIFIED IDEOGRAPH
-0xE4DC	0x8446	#CJK UNIFIED IDEOGRAPH
-0xE4DD	0x842C	#CJK UNIFIED IDEOGRAPH
-0xE4DE	0x846F	#CJK UNIFIED IDEOGRAPH
-0xE4DF	0x8479	#CJK UNIFIED IDEOGRAPH
-0xE4E0	0x8435	#CJK UNIFIED IDEOGRAPH
-0xE4E1	0x84CA	#CJK UNIFIED IDEOGRAPH
-0xE4E2	0x8462	#CJK UNIFIED IDEOGRAPH
-0xE4E3	0x84B9	#CJK UNIFIED IDEOGRAPH
-0xE4E4	0x84BF	#CJK UNIFIED IDEOGRAPH
-0xE4E5	0x849F	#CJK UNIFIED IDEOGRAPH
-0xE4E6	0x84D9	#CJK UNIFIED IDEOGRAPH
-0xE4E7	0x84CD	#CJK UNIFIED IDEOGRAPH
-0xE4E8	0x84BB	#CJK UNIFIED IDEOGRAPH
-0xE4E9	0x84DA	#CJK UNIFIED IDEOGRAPH
-0xE4EA	0x84D0	#CJK UNIFIED IDEOGRAPH
-0xE4EB	0x84C1	#CJK UNIFIED IDEOGRAPH
-0xE4EC	0x84C6	#CJK UNIFIED IDEOGRAPH
-0xE4ED	0x84D6	#CJK UNIFIED IDEOGRAPH
-0xE4EE	0x84A1	#CJK UNIFIED IDEOGRAPH
-0xE4EF	0x8521	#CJK UNIFIED IDEOGRAPH
-0xE4F0	0x84FF	#CJK UNIFIED IDEOGRAPH
-0xE4F1	0x84F4	#CJK UNIFIED IDEOGRAPH
-0xE4F2	0x8517	#CJK UNIFIED IDEOGRAPH
-0xE4F3	0x8518	#CJK UNIFIED IDEOGRAPH
-0xE4F4	0x852C	#CJK UNIFIED IDEOGRAPH
-0xE4F5	0x851F	#CJK UNIFIED IDEOGRAPH
-0xE4F6	0x8515	#CJK UNIFIED IDEOGRAPH
-0xE4F7	0x8514	#CJK UNIFIED IDEOGRAPH
-0xE4F8	0x84FC	#CJK UNIFIED IDEOGRAPH
-0xE4F9	0x8540	#CJK UNIFIED IDEOGRAPH
-0xE4FA	0x8563	#CJK UNIFIED IDEOGRAPH
-0xE4FB	0x8558	#CJK UNIFIED IDEOGRAPH
-0xE4FC	0x8548	#CJK UNIFIED IDEOGRAPH
-0xE540	0x8541	#CJK UNIFIED IDEOGRAPH
-0xE541	0x8602	#CJK UNIFIED IDEOGRAPH
-0xE542	0x854B	#CJK UNIFIED IDEOGRAPH
-0xE543	0x8555	#CJK UNIFIED IDEOGRAPH
-0xE544	0x8580	#CJK UNIFIED IDEOGRAPH
-0xE545	0x85A4	#CJK UNIFIED IDEOGRAPH
-0xE546	0x8588	#CJK UNIFIED IDEOGRAPH
-0xE547	0x8591	#CJK UNIFIED IDEOGRAPH
-0xE548	0x858A	#CJK UNIFIED IDEOGRAPH
-0xE549	0x85A8	#CJK UNIFIED IDEOGRAPH
-0xE54A	0x856D	#CJK UNIFIED IDEOGRAPH
-0xE54B	0x8594	#CJK UNIFIED IDEOGRAPH
-0xE54C	0x859B	#CJK UNIFIED IDEOGRAPH
-0xE54D	0x85EA	#CJK UNIFIED IDEOGRAPH
-0xE54E	0x8587	#CJK UNIFIED IDEOGRAPH
-0xE54F	0x859C	#CJK UNIFIED IDEOGRAPH
-0xE550	0x8577	#CJK UNIFIED IDEOGRAPH
-0xE551	0x857E	#CJK UNIFIED IDEOGRAPH
-0xE552	0x8590	#CJK UNIFIED IDEOGRAPH
-0xE553	0x85C9	#CJK UNIFIED IDEOGRAPH
-0xE554	0x85BA	#CJK UNIFIED IDEOGRAPH
-0xE555	0x85CF	#CJK UNIFIED IDEOGRAPH
-0xE556	0x85B9	#CJK UNIFIED IDEOGRAPH
-0xE557	0x85D0	#CJK UNIFIED IDEOGRAPH
-0xE558	0x85D5	#CJK UNIFIED IDEOGRAPH
-0xE559	0x85DD	#CJK UNIFIED IDEOGRAPH
-0xE55A	0x85E5	#CJK UNIFIED IDEOGRAPH
-0xE55B	0x85DC	#CJK UNIFIED IDEOGRAPH
-0xE55C	0x85F9	#CJK UNIFIED IDEOGRAPH
-0xE55D	0x860A	#CJK UNIFIED IDEOGRAPH
-0xE55E	0x8613	#CJK UNIFIED IDEOGRAPH
-0xE55F	0x860B	#CJK UNIFIED IDEOGRAPH
-0xE560	0x85FE	#CJK UNIFIED IDEOGRAPH
-0xE561	0x85FA	#CJK UNIFIED IDEOGRAPH
-0xE562	0x8606	#CJK UNIFIED IDEOGRAPH
-0xE563	0x8622	#CJK UNIFIED IDEOGRAPH
-0xE564	0x861A	#CJK UNIFIED IDEOGRAPH
-0xE565	0x8630	#CJK UNIFIED IDEOGRAPH
-0xE566	0x863F	#CJK UNIFIED IDEOGRAPH
-0xE567	0x864D	#CJK UNIFIED IDEOGRAPH
-0xE568	0x4E55	#CJK UNIFIED IDEOGRAPH
-0xE569	0x8654	#CJK UNIFIED IDEOGRAPH
-0xE56A	0x865F	#CJK UNIFIED IDEOGRAPH
-0xE56B	0x8667	#CJK UNIFIED IDEOGRAPH
-0xE56C	0x8671	#CJK UNIFIED IDEOGRAPH
-0xE56D	0x8693	#CJK UNIFIED IDEOGRAPH
-0xE56E	0x86A3	#CJK UNIFIED IDEOGRAPH
-0xE56F	0x86A9	#CJK UNIFIED IDEOGRAPH
-0xE570	0x86AA	#CJK UNIFIED IDEOGRAPH
-0xE571	0x868B	#CJK UNIFIED IDEOGRAPH
-0xE572	0x868C	#CJK UNIFIED IDEOGRAPH
-0xE573	0x86B6	#CJK UNIFIED IDEOGRAPH
-0xE574	0x86AF	#CJK UNIFIED IDEOGRAPH
-0xE575	0x86C4	#CJK UNIFIED IDEOGRAPH
-0xE576	0x86C6	#CJK UNIFIED IDEOGRAPH
-0xE577	0x86B0	#CJK UNIFIED IDEOGRAPH
-0xE578	0x86C9	#CJK UNIFIED IDEOGRAPH
-0xE579	0x8823	#CJK UNIFIED IDEOGRAPH
-0xE57A	0x86AB	#CJK UNIFIED IDEOGRAPH
-0xE57B	0x86D4	#CJK UNIFIED IDEOGRAPH
-0xE57C	0x86DE	#CJK UNIFIED IDEOGRAPH
-0xE57D	0x86E9	#CJK UNIFIED IDEOGRAPH
-0xE57E	0x86EC	#CJK UNIFIED IDEOGRAPH
-0xE580	0x86DF	#CJK UNIFIED IDEOGRAPH
-0xE581	0x86DB	#CJK UNIFIED IDEOGRAPH
-0xE582	0x86EF	#CJK UNIFIED IDEOGRAPH
-0xE583	0x8712	#CJK UNIFIED IDEOGRAPH
-0xE584	0x8706	#CJK UNIFIED IDEOGRAPH
-0xE585	0x8708	#CJK UNIFIED IDEOGRAPH
-0xE586	0x8700	#CJK UNIFIED IDEOGRAPH
-0xE587	0x8703	#CJK UNIFIED IDEOGRAPH
-0xE588	0x86FB	#CJK UNIFIED IDEOGRAPH
-0xE589	0x8711	#CJK UNIFIED IDEOGRAPH
-0xE58A	0x8709	#CJK UNIFIED IDEOGRAPH
-0xE58B	0x870D	#CJK UNIFIED IDEOGRAPH
-0xE58C	0x86F9	#CJK UNIFIED IDEOGRAPH
-0xE58D	0x870A	#CJK UNIFIED IDEOGRAPH
-0xE58E	0x8734	#CJK UNIFIED IDEOGRAPH
-0xE58F	0x873F	#CJK UNIFIED IDEOGRAPH
-0xE590	0x8737	#CJK UNIFIED IDEOGRAPH
-0xE591	0x873B	#CJK UNIFIED IDEOGRAPH
-0xE592	0x8725	#CJK UNIFIED IDEOGRAPH
-0xE593	0x8729	#CJK UNIFIED IDEOGRAPH
-0xE594	0x871A	#CJK UNIFIED IDEOGRAPH
-0xE595	0x8760	#CJK UNIFIED IDEOGRAPH
-0xE596	0x875F	#CJK UNIFIED IDEOGRAPH
-0xE597	0x8778	#CJK UNIFIED IDEOGRAPH
-0xE598	0x874C	#CJK UNIFIED IDEOGRAPH
-0xE599	0x874E	#CJK UNIFIED IDEOGRAPH
-0xE59A	0x8774	#CJK UNIFIED IDEOGRAPH
-0xE59B	0x8757	#CJK UNIFIED IDEOGRAPH
-0xE59C	0x8768	#CJK UNIFIED IDEOGRAPH
-0xE59D	0x876E	#CJK UNIFIED IDEOGRAPH
-0xE59E	0x8759	#CJK UNIFIED IDEOGRAPH
-0xE59F	0x8753	#CJK UNIFIED IDEOGRAPH
-0xE5A0	0x8763	#CJK UNIFIED IDEOGRAPH
-0xE5A1	0x876A	#CJK UNIFIED IDEOGRAPH
-0xE5A2	0x8805	#CJK UNIFIED IDEOGRAPH
-0xE5A3	0x87A2	#CJK UNIFIED IDEOGRAPH
-0xE5A4	0x879F	#CJK UNIFIED IDEOGRAPH
-0xE5A5	0x8782	#CJK UNIFIED IDEOGRAPH
-0xE5A6	0x87AF	#CJK UNIFIED IDEOGRAPH
-0xE5A7	0x87CB	#CJK UNIFIED IDEOGRAPH
-0xE5A8	0x87BD	#CJK UNIFIED IDEOGRAPH
-0xE5A9	0x87C0	#CJK UNIFIED IDEOGRAPH
-0xE5AA	0x87D0	#CJK UNIFIED IDEOGRAPH
-0xE5AB	0x96D6	#CJK UNIFIED IDEOGRAPH
-0xE5AC	0x87AB	#CJK UNIFIED IDEOGRAPH
-0xE5AD	0x87C4	#CJK UNIFIED IDEOGRAPH
-0xE5AE	0x87B3	#CJK UNIFIED IDEOGRAPH
-0xE5AF	0x87C7	#CJK UNIFIED IDEOGRAPH
-0xE5B0	0x87C6	#CJK UNIFIED IDEOGRAPH
-0xE5B1	0x87BB	#CJK UNIFIED IDEOGRAPH
-0xE5B2	0x87EF	#CJK UNIFIED IDEOGRAPH
-0xE5B3	0x87F2	#CJK UNIFIED IDEOGRAPH
-0xE5B4	0x87E0	#CJK UNIFIED IDEOGRAPH
-0xE5B5	0x880F	#CJK UNIFIED IDEOGRAPH
-0xE5B6	0x880D	#CJK UNIFIED IDEOGRAPH
-0xE5B7	0x87FE	#CJK UNIFIED IDEOGRAPH
-0xE5B8	0x87F6	#CJK UNIFIED IDEOGRAPH
-0xE5B9	0x87F7	#CJK UNIFIED IDEOGRAPH
-0xE5BA	0x880E	#CJK UNIFIED IDEOGRAPH
-0xE5BB	0x87D2	#CJK UNIFIED IDEOGRAPH
-0xE5BC	0x8811	#CJK UNIFIED IDEOGRAPH
-0xE5BD	0x8816	#CJK UNIFIED IDEOGRAPH
-0xE5BE	0x8815	#CJK UNIFIED IDEOGRAPH
-0xE5BF	0x8822	#CJK UNIFIED IDEOGRAPH
-0xE5C0	0x8821	#CJK UNIFIED IDEOGRAPH
-0xE5C1	0x8831	#CJK UNIFIED IDEOGRAPH
-0xE5C2	0x8836	#CJK UNIFIED IDEOGRAPH
-0xE5C3	0x8839	#CJK UNIFIED IDEOGRAPH
-0xE5C4	0x8827	#CJK UNIFIED IDEOGRAPH
-0xE5C5	0x883B	#CJK UNIFIED IDEOGRAPH
-0xE5C6	0x8844	#CJK UNIFIED IDEOGRAPH
-0xE5C7	0x8842	#CJK UNIFIED IDEOGRAPH
-0xE5C8	0x8852	#CJK UNIFIED IDEOGRAPH
-0xE5C9	0x8859	#CJK UNIFIED IDEOGRAPH
-0xE5CA	0x885E	#CJK UNIFIED IDEOGRAPH
-0xE5CB	0x8862	#CJK UNIFIED IDEOGRAPH
-0xE5CC	0x886B	#CJK UNIFIED IDEOGRAPH
-0xE5CD	0x8881	#CJK UNIFIED IDEOGRAPH
-0xE5CE	0x887E	#CJK UNIFIED IDEOGRAPH
-0xE5CF	0x889E	#CJK UNIFIED IDEOGRAPH
-0xE5D0	0x8875	#CJK UNIFIED IDEOGRAPH
-0xE5D1	0x887D	#CJK UNIFIED IDEOGRAPH
-0xE5D2	0x88B5	#CJK UNIFIED IDEOGRAPH
-0xE5D3	0x8872	#CJK UNIFIED IDEOGRAPH
-0xE5D4	0x8882	#CJK UNIFIED IDEOGRAPH
-0xE5D5	0x8897	#CJK UNIFIED IDEOGRAPH
-0xE5D6	0x8892	#CJK UNIFIED IDEOGRAPH
-0xE5D7	0x88AE	#CJK UNIFIED IDEOGRAPH
-0xE5D8	0x8899	#CJK UNIFIED IDEOGRAPH
-0xE5D9	0x88A2	#CJK UNIFIED IDEOGRAPH
-0xE5DA	0x888D	#CJK UNIFIED IDEOGRAPH
-0xE5DB	0x88A4	#CJK UNIFIED IDEOGRAPH
-0xE5DC	0x88B0	#CJK UNIFIED IDEOGRAPH
-0xE5DD	0x88BF	#CJK UNIFIED IDEOGRAPH
-0xE5DE	0x88B1	#CJK UNIFIED IDEOGRAPH
-0xE5DF	0x88C3	#CJK UNIFIED IDEOGRAPH
-0xE5E0	0x88C4	#CJK UNIFIED IDEOGRAPH
-0xE5E1	0x88D4	#CJK UNIFIED IDEOGRAPH
-0xE5E2	0x88D8	#CJK UNIFIED IDEOGRAPH
-0xE5E3	0x88D9	#CJK UNIFIED IDEOGRAPH
-0xE5E4	0x88DD	#CJK UNIFIED IDEOGRAPH
-0xE5E5	0x88F9	#CJK UNIFIED IDEOGRAPH
-0xE5E6	0x8902	#CJK UNIFIED IDEOGRAPH
-0xE5E7	0x88FC	#CJK UNIFIED IDEOGRAPH
-0xE5E8	0x88F4	#CJK UNIFIED IDEOGRAPH
-0xE5E9	0x88E8	#CJK UNIFIED IDEOGRAPH
-0xE5EA	0x88F2	#CJK UNIFIED IDEOGRAPH
-0xE5EB	0x8904	#CJK UNIFIED IDEOGRAPH
-0xE5EC	0x890C	#CJK UNIFIED IDEOGRAPH
-0xE5ED	0x890A	#CJK UNIFIED IDEOGRAPH
-0xE5EE	0x8913	#CJK UNIFIED IDEOGRAPH
-0xE5EF	0x8943	#CJK UNIFIED IDEOGRAPH
-0xE5F0	0x891E	#CJK UNIFIED IDEOGRAPH
-0xE5F1	0x8925	#CJK UNIFIED IDEOGRAPH
-0xE5F2	0x892A	#CJK UNIFIED IDEOGRAPH
-0xE5F3	0x892B	#CJK UNIFIED IDEOGRAPH
-0xE5F4	0x8941	#CJK UNIFIED IDEOGRAPH
-0xE5F5	0x8944	#CJK UNIFIED IDEOGRAPH
-0xE5F6	0x893B	#CJK UNIFIED IDEOGRAPH
-0xE5F7	0x8936	#CJK UNIFIED IDEOGRAPH
-0xE5F8	0x8938	#CJK UNIFIED IDEOGRAPH
-0xE5F9	0x894C	#CJK UNIFIED IDEOGRAPH
-0xE5FA	0x891D	#CJK UNIFIED IDEOGRAPH
-0xE5FB	0x8960	#CJK UNIFIED IDEOGRAPH
-0xE5FC	0x895E	#CJK UNIFIED IDEOGRAPH
-0xE640	0x8966	#CJK UNIFIED IDEOGRAPH
-0xE641	0x8964	#CJK UNIFIED IDEOGRAPH
-0xE642	0x896D	#CJK UNIFIED IDEOGRAPH
-0xE643	0x896A	#CJK UNIFIED IDEOGRAPH
-0xE644	0x896F	#CJK UNIFIED IDEOGRAPH
-0xE645	0x8974	#CJK UNIFIED IDEOGRAPH
-0xE646	0x8977	#CJK UNIFIED IDEOGRAPH
-0xE647	0x897E	#CJK UNIFIED IDEOGRAPH
-0xE648	0x8983	#CJK UNIFIED IDEOGRAPH
-0xE649	0x8988	#CJK UNIFIED IDEOGRAPH
-0xE64A	0x898A	#CJK UNIFIED IDEOGRAPH
-0xE64B	0x8993	#CJK UNIFIED IDEOGRAPH
-0xE64C	0x8998	#CJK UNIFIED IDEOGRAPH
-0xE64D	0x89A1	#CJK UNIFIED IDEOGRAPH
-0xE64E	0x89A9	#CJK UNIFIED IDEOGRAPH
-0xE64F	0x89A6	#CJK UNIFIED IDEOGRAPH
-0xE650	0x89AC	#CJK UNIFIED IDEOGRAPH
-0xE651	0x89AF	#CJK UNIFIED IDEOGRAPH
-0xE652	0x89B2	#CJK UNIFIED IDEOGRAPH
-0xE653	0x89BA	#CJK UNIFIED IDEOGRAPH
-0xE654	0x89BD	#CJK UNIFIED IDEOGRAPH
-0xE655	0x89BF	#CJK UNIFIED IDEOGRAPH
-0xE656	0x89C0	#CJK UNIFIED IDEOGRAPH
-0xE657	0x89DA	#CJK UNIFIED IDEOGRAPH
-0xE658	0x89DC	#CJK UNIFIED IDEOGRAPH
-0xE659	0x89DD	#CJK UNIFIED IDEOGRAPH
-0xE65A	0x89E7	#CJK UNIFIED IDEOGRAPH
-0xE65B	0x89F4	#CJK UNIFIED IDEOGRAPH
-0xE65C	0x89F8	#CJK UNIFIED IDEOGRAPH
-0xE65D	0x8A03	#CJK UNIFIED IDEOGRAPH
-0xE65E	0x8A16	#CJK UNIFIED IDEOGRAPH
-0xE65F	0x8A10	#CJK UNIFIED IDEOGRAPH
-0xE660	0x8A0C	#CJK UNIFIED IDEOGRAPH
-0xE661	0x8A1B	#CJK UNIFIED IDEOGRAPH
-0xE662	0x8A1D	#CJK UNIFIED IDEOGRAPH
-0xE663	0x8A25	#CJK UNIFIED IDEOGRAPH
-0xE664	0x8A36	#CJK UNIFIED IDEOGRAPH
-0xE665	0x8A41	#CJK UNIFIED IDEOGRAPH
-0xE666	0x8A5B	#CJK UNIFIED IDEOGRAPH
-0xE667	0x8A52	#CJK UNIFIED IDEOGRAPH
-0xE668	0x8A46	#CJK UNIFIED IDEOGRAPH
-0xE669	0x8A48	#CJK UNIFIED IDEOGRAPH
-0xE66A	0x8A7C	#CJK UNIFIED IDEOGRAPH
-0xE66B	0x8A6D	#CJK UNIFIED IDEOGRAPH
-0xE66C	0x8A6C	#CJK UNIFIED IDEOGRAPH
-0xE66D	0x8A62	#CJK UNIFIED IDEOGRAPH
-0xE66E	0x8A85	#CJK UNIFIED IDEOGRAPH
-0xE66F	0x8A82	#CJK UNIFIED IDEOGRAPH
-0xE670	0x8A84	#CJK UNIFIED IDEOGRAPH
-0xE671	0x8AA8	#CJK UNIFIED IDEOGRAPH
-0xE672	0x8AA1	#CJK UNIFIED IDEOGRAPH
-0xE673	0x8A91	#CJK UNIFIED IDEOGRAPH
-0xE674	0x8AA5	#CJK UNIFIED IDEOGRAPH
-0xE675	0x8AA6	#CJK UNIFIED IDEOGRAPH
-0xE676	0x8A9A	#CJK UNIFIED IDEOGRAPH
-0xE677	0x8AA3	#CJK UNIFIED IDEOGRAPH
-0xE678	0x8AC4	#CJK UNIFIED IDEOGRAPH
-0xE679	0x8ACD	#CJK UNIFIED IDEOGRAPH
-0xE67A	0x8AC2	#CJK UNIFIED IDEOGRAPH
-0xE67B	0x8ADA	#CJK UNIFIED IDEOGRAPH
-0xE67C	0x8AEB	#CJK UNIFIED IDEOGRAPH
-0xE67D	0x8AF3	#CJK UNIFIED IDEOGRAPH
-0xE67E	0x8AE7	#CJK UNIFIED IDEOGRAPH
-0xE680	0x8AE4	#CJK UNIFIED IDEOGRAPH
-0xE681	0x8AF1	#CJK UNIFIED IDEOGRAPH
-0xE682	0x8B14	#CJK UNIFIED IDEOGRAPH
-0xE683	0x8AE0	#CJK UNIFIED IDEOGRAPH
-0xE684	0x8AE2	#CJK UNIFIED IDEOGRAPH
-0xE685	0x8AF7	#CJK UNIFIED IDEOGRAPH
-0xE686	0x8ADE	#CJK UNIFIED IDEOGRAPH
-0xE687	0x8ADB	#CJK UNIFIED IDEOGRAPH
-0xE688	0x8B0C	#CJK UNIFIED IDEOGRAPH
-0xE689	0x8B07	#CJK UNIFIED IDEOGRAPH
-0xE68A	0x8B1A	#CJK UNIFIED IDEOGRAPH
-0xE68B	0x8AE1	#CJK UNIFIED IDEOGRAPH
-0xE68C	0x8B16	#CJK UNIFIED IDEOGRAPH
-0xE68D	0x8B10	#CJK UNIFIED IDEOGRAPH
-0xE68E	0x8B17	#CJK UNIFIED IDEOGRAPH
-0xE68F	0x8B20	#CJK UNIFIED IDEOGRAPH
-0xE690	0x8B33	#CJK UNIFIED IDEOGRAPH
-0xE691	0x97AB	#CJK UNIFIED IDEOGRAPH
-0xE692	0x8B26	#CJK UNIFIED IDEOGRAPH
-0xE693	0x8B2B	#CJK UNIFIED IDEOGRAPH
-0xE694	0x8B3E	#CJK UNIFIED IDEOGRAPH
-0xE695	0x8B28	#CJK UNIFIED IDEOGRAPH
-0xE696	0x8B41	#CJK UNIFIED IDEOGRAPH
-0xE697	0x8B4C	#CJK UNIFIED IDEOGRAPH
-0xE698	0x8B4F	#CJK UNIFIED IDEOGRAPH
-0xE699	0x8B4E	#CJK UNIFIED IDEOGRAPH
-0xE69A	0x8B49	#CJK UNIFIED IDEOGRAPH
-0xE69B	0x8B56	#CJK UNIFIED IDEOGRAPH
-0xE69C	0x8B5B	#CJK UNIFIED IDEOGRAPH
-0xE69D	0x8B5A	#CJK UNIFIED IDEOGRAPH
-0xE69E	0x8B6B	#CJK UNIFIED IDEOGRAPH
-0xE69F	0x8B5F	#CJK UNIFIED IDEOGRAPH
-0xE6A0	0x8B6C	#CJK UNIFIED IDEOGRAPH
-0xE6A1	0x8B6F	#CJK UNIFIED IDEOGRAPH
-0xE6A2	0x8B74	#CJK UNIFIED IDEOGRAPH
-0xE6A3	0x8B7D	#CJK UNIFIED IDEOGRAPH
-0xE6A4	0x8B80	#CJK UNIFIED IDEOGRAPH
-0xE6A5	0x8B8C	#CJK UNIFIED IDEOGRAPH
-0xE6A6	0x8B8E	#CJK UNIFIED IDEOGRAPH
-0xE6A7	0x8B92	#CJK UNIFIED IDEOGRAPH
-0xE6A8	0x8B93	#CJK UNIFIED IDEOGRAPH
-0xE6A9	0x8B96	#CJK UNIFIED IDEOGRAPH
-0xE6AA	0x8B99	#CJK UNIFIED IDEOGRAPH
-0xE6AB	0x8B9A	#CJK UNIFIED IDEOGRAPH
-0xE6AC	0x8C3A	#CJK UNIFIED IDEOGRAPH
-0xE6AD	0x8C41	#CJK UNIFIED IDEOGRAPH
-0xE6AE	0x8C3F	#CJK UNIFIED IDEOGRAPH
-0xE6AF	0x8C48	#CJK UNIFIED IDEOGRAPH
-0xE6B0	0x8C4C	#CJK UNIFIED IDEOGRAPH
-0xE6B1	0x8C4E	#CJK UNIFIED IDEOGRAPH
-0xE6B2	0x8C50	#CJK UNIFIED IDEOGRAPH
-0xE6B3	0x8C55	#CJK UNIFIED IDEOGRAPH
-0xE6B4	0x8C62	#CJK UNIFIED IDEOGRAPH
-0xE6B5	0x8C6C	#CJK UNIFIED IDEOGRAPH
-0xE6B6	0x8C78	#CJK UNIFIED IDEOGRAPH
-0xE6B7	0x8C7A	#CJK UNIFIED IDEOGRAPH
-0xE6B8	0x8C82	#CJK UNIFIED IDEOGRAPH
-0xE6B9	0x8C89	#CJK UNIFIED IDEOGRAPH
-0xE6BA	0x8C85	#CJK UNIFIED IDEOGRAPH
-0xE6BB	0x8C8A	#CJK UNIFIED IDEOGRAPH
-0xE6BC	0x8C8D	#CJK UNIFIED IDEOGRAPH
-0xE6BD	0x8C8E	#CJK UNIFIED IDEOGRAPH
-0xE6BE	0x8C94	#CJK UNIFIED IDEOGRAPH
-0xE6BF	0x8C7C	#CJK UNIFIED IDEOGRAPH
-0xE6C0	0x8C98	#CJK UNIFIED IDEOGRAPH
-0xE6C1	0x621D	#CJK UNIFIED IDEOGRAPH
-0xE6C2	0x8CAD	#CJK UNIFIED IDEOGRAPH
-0xE6C3	0x8CAA	#CJK UNIFIED IDEOGRAPH
-0xE6C4	0x8CBD	#CJK UNIFIED IDEOGRAPH
-0xE6C5	0x8CB2	#CJK UNIFIED IDEOGRAPH
-0xE6C6	0x8CB3	#CJK UNIFIED IDEOGRAPH
-0xE6C7	0x8CAE	#CJK UNIFIED IDEOGRAPH
-0xE6C8	0x8CB6	#CJK UNIFIED IDEOGRAPH
-0xE6C9	0x8CC8	#CJK UNIFIED IDEOGRAPH
-0xE6CA	0x8CC1	#CJK UNIFIED IDEOGRAPH
-0xE6CB	0x8CE4	#CJK UNIFIED IDEOGRAPH
-0xE6CC	0x8CE3	#CJK UNIFIED IDEOGRAPH
-0xE6CD	0x8CDA	#CJK UNIFIED IDEOGRAPH
-0xE6CE	0x8CFD	#CJK UNIFIED IDEOGRAPH
-0xE6CF	0x8CFA	#CJK UNIFIED IDEOGRAPH
-0xE6D0	0x8CFB	#CJK UNIFIED IDEOGRAPH
-0xE6D1	0x8D04	#CJK UNIFIED IDEOGRAPH
-0xE6D2	0x8D05	#CJK UNIFIED IDEOGRAPH
-0xE6D3	0x8D0A	#CJK UNIFIED IDEOGRAPH
-0xE6D4	0x8D07	#CJK UNIFIED IDEOGRAPH
-0xE6D5	0x8D0F	#CJK UNIFIED IDEOGRAPH
-0xE6D6	0x8D0D	#CJK UNIFIED IDEOGRAPH
-0xE6D7	0x8D10	#CJK UNIFIED IDEOGRAPH
-0xE6D8	0x9F4E	#CJK UNIFIED IDEOGRAPH
-0xE6D9	0x8D13	#CJK UNIFIED IDEOGRAPH
-0xE6DA	0x8CCD	#CJK UNIFIED IDEOGRAPH
-0xE6DB	0x8D14	#CJK UNIFIED IDEOGRAPH
-0xE6DC	0x8D16	#CJK UNIFIED IDEOGRAPH
-0xE6DD	0x8D67	#CJK UNIFIED IDEOGRAPH
-0xE6DE	0x8D6D	#CJK UNIFIED IDEOGRAPH
-0xE6DF	0x8D71	#CJK UNIFIED IDEOGRAPH
-0xE6E0	0x8D73	#CJK UNIFIED IDEOGRAPH
-0xE6E1	0x8D81	#CJK UNIFIED IDEOGRAPH
-0xE6E2	0x8D99	#CJK UNIFIED IDEOGRAPH
-0xE6E3	0x8DC2	#CJK UNIFIED IDEOGRAPH
-0xE6E4	0x8DBE	#CJK UNIFIED IDEOGRAPH
-0xE6E5	0x8DBA	#CJK UNIFIED IDEOGRAPH
-0xE6E6	0x8DCF	#CJK UNIFIED IDEOGRAPH
-0xE6E7	0x8DDA	#CJK UNIFIED IDEOGRAPH
-0xE6E8	0x8DD6	#CJK UNIFIED IDEOGRAPH
-0xE6E9	0x8DCC	#CJK UNIFIED IDEOGRAPH
-0xE6EA	0x8DDB	#CJK UNIFIED IDEOGRAPH
-0xE6EB	0x8DCB	#CJK UNIFIED IDEOGRAPH
-0xE6EC	0x8DEA	#CJK UNIFIED IDEOGRAPH
-0xE6ED	0x8DEB	#CJK UNIFIED IDEOGRAPH
-0xE6EE	0x8DDF	#CJK UNIFIED IDEOGRAPH
-0xE6EF	0x8DE3	#CJK UNIFIED IDEOGRAPH
-0xE6F0	0x8DFC	#CJK UNIFIED IDEOGRAPH
-0xE6F1	0x8E08	#CJK UNIFIED IDEOGRAPH
-0xE6F2	0x8E09	#CJK UNIFIED IDEOGRAPH
-0xE6F3	0x8DFF	#CJK UNIFIED IDEOGRAPH
-0xE6F4	0x8E1D	#CJK UNIFIED IDEOGRAPH
-0xE6F5	0x8E1E	#CJK UNIFIED IDEOGRAPH
-0xE6F6	0x8E10	#CJK UNIFIED IDEOGRAPH
-0xE6F7	0x8E1F	#CJK UNIFIED IDEOGRAPH
-0xE6F8	0x8E42	#CJK UNIFIED IDEOGRAPH
-0xE6F9	0x8E35	#CJK UNIFIED IDEOGRAPH
-0xE6FA	0x8E30	#CJK UNIFIED IDEOGRAPH
-0xE6FB	0x8E34	#CJK UNIFIED IDEOGRAPH
-0xE6FC	0x8E4A	#CJK UNIFIED IDEOGRAPH
-0xE740	0x8E47	#CJK UNIFIED IDEOGRAPH
-0xE741	0x8E49	#CJK UNIFIED IDEOGRAPH
-0xE742	0x8E4C	#CJK UNIFIED IDEOGRAPH
-0xE743	0x8E50	#CJK UNIFIED IDEOGRAPH
-0xE744	0x8E48	#CJK UNIFIED IDEOGRAPH
-0xE745	0x8E59	#CJK UNIFIED IDEOGRAPH
-0xE746	0x8E64	#CJK UNIFIED IDEOGRAPH
-0xE747	0x8E60	#CJK UNIFIED IDEOGRAPH
-0xE748	0x8E2A	#CJK UNIFIED IDEOGRAPH
-0xE749	0x8E63	#CJK UNIFIED IDEOGRAPH
-0xE74A	0x8E55	#CJK UNIFIED IDEOGRAPH
-0xE74B	0x8E76	#CJK UNIFIED IDEOGRAPH
-0xE74C	0x8E72	#CJK UNIFIED IDEOGRAPH
-0xE74D	0x8E7C	#CJK UNIFIED IDEOGRAPH
-0xE74E	0x8E81	#CJK UNIFIED IDEOGRAPH
-0xE74F	0x8E87	#CJK UNIFIED IDEOGRAPH
-0xE750	0x8E85	#CJK UNIFIED IDEOGRAPH
-0xE751	0x8E84	#CJK UNIFIED IDEOGRAPH
-0xE752	0x8E8B	#CJK UNIFIED IDEOGRAPH
-0xE753	0x8E8A	#CJK UNIFIED IDEOGRAPH
-0xE754	0x8E93	#CJK UNIFIED IDEOGRAPH
-0xE755	0x8E91	#CJK UNIFIED IDEOGRAPH
-0xE756	0x8E94	#CJK UNIFIED IDEOGRAPH
-0xE757	0x8E99	#CJK UNIFIED IDEOGRAPH
-0xE758	0x8EAA	#CJK UNIFIED IDEOGRAPH
-0xE759	0x8EA1	#CJK UNIFIED IDEOGRAPH
-0xE75A	0x8EAC	#CJK UNIFIED IDEOGRAPH
-0xE75B	0x8EB0	#CJK UNIFIED IDEOGRAPH
-0xE75C	0x8EC6	#CJK UNIFIED IDEOGRAPH
-0xE75D	0x8EB1	#CJK UNIFIED IDEOGRAPH
-0xE75E	0x8EBE	#CJK UNIFIED IDEOGRAPH
-0xE75F	0x8EC5	#CJK UNIFIED IDEOGRAPH
-0xE760	0x8EC8	#CJK UNIFIED IDEOGRAPH
-0xE761	0x8ECB	#CJK UNIFIED IDEOGRAPH
-0xE762	0x8EDB	#CJK UNIFIED IDEOGRAPH
-0xE763	0x8EE3	#CJK UNIFIED IDEOGRAPH
-0xE764	0x8EFC	#CJK UNIFIED IDEOGRAPH
-0xE765	0x8EFB	#CJK UNIFIED IDEOGRAPH
-0xE766	0x8EEB	#CJK UNIFIED IDEOGRAPH
-0xE767	0x8EFE	#CJK UNIFIED IDEOGRAPH
-0xE768	0x8F0A	#CJK UNIFIED IDEOGRAPH
-0xE769	0x8F05	#CJK UNIFIED IDEOGRAPH
-0xE76A	0x8F15	#CJK UNIFIED IDEOGRAPH
-0xE76B	0x8F12	#CJK UNIFIED IDEOGRAPH
-0xE76C	0x8F19	#CJK UNIFIED IDEOGRAPH
-0xE76D	0x8F13	#CJK UNIFIED IDEOGRAPH
-0xE76E	0x8F1C	#CJK UNIFIED IDEOGRAPH
-0xE76F	0x8F1F	#CJK UNIFIED IDEOGRAPH
-0xE770	0x8F1B	#CJK UNIFIED IDEOGRAPH
-0xE771	0x8F0C	#CJK UNIFIED IDEOGRAPH
-0xE772	0x8F26	#CJK UNIFIED IDEOGRAPH
-0xE773	0x8F33	#CJK UNIFIED IDEOGRAPH
-0xE774	0x8F3B	#CJK UNIFIED IDEOGRAPH
-0xE775	0x8F39	#CJK UNIFIED IDEOGRAPH
-0xE776	0x8F45	#CJK UNIFIED IDEOGRAPH
-0xE777	0x8F42	#CJK UNIFIED IDEOGRAPH
-0xE778	0x8F3E	#CJK UNIFIED IDEOGRAPH
-0xE779	0x8F4C	#CJK UNIFIED IDEOGRAPH
-0xE77A	0x8F49	#CJK UNIFIED IDEOGRAPH
-0xE77B	0x8F46	#CJK UNIFIED IDEOGRAPH
-0xE77C	0x8F4E	#CJK UNIFIED IDEOGRAPH
-0xE77D	0x8F57	#CJK UNIFIED IDEOGRAPH
-0xE77E	0x8F5C	#CJK UNIFIED IDEOGRAPH
-0xE780	0x8F62	#CJK UNIFIED IDEOGRAPH
-0xE781	0x8F63	#CJK UNIFIED IDEOGRAPH
-0xE782	0x8F64	#CJK UNIFIED IDEOGRAPH
-0xE783	0x8F9C	#CJK UNIFIED IDEOGRAPH
-0xE784	0x8F9F	#CJK UNIFIED IDEOGRAPH
-0xE785	0x8FA3	#CJK UNIFIED IDEOGRAPH
-0xE786	0x8FAD	#CJK UNIFIED IDEOGRAPH
-0xE787	0x8FAF	#CJK UNIFIED IDEOGRAPH
-0xE788	0x8FB7	#CJK UNIFIED IDEOGRAPH
-0xE789	0x8FDA	#CJK UNIFIED IDEOGRAPH
-0xE78A	0x8FE5	#CJK UNIFIED IDEOGRAPH
-0xE78B	0x8FE2	#CJK UNIFIED IDEOGRAPH
-0xE78C	0x8FEA	#CJK UNIFIED IDEOGRAPH
-0xE78D	0x8FEF	#CJK UNIFIED IDEOGRAPH
-0xE78E	0x9087	#CJK UNIFIED IDEOGRAPH
-0xE78F	0x8FF4	#CJK UNIFIED IDEOGRAPH
-0xE790	0x9005	#CJK UNIFIED IDEOGRAPH
-0xE791	0x8FF9	#CJK UNIFIED IDEOGRAPH
-0xE792	0x8FFA	#CJK UNIFIED IDEOGRAPH
-0xE793	0x9011	#CJK UNIFIED IDEOGRAPH
-0xE794	0x9015	#CJK UNIFIED IDEOGRAPH
-0xE795	0x9021	#CJK UNIFIED IDEOGRAPH
-0xE796	0x900D	#CJK UNIFIED IDEOGRAPH
-0xE797	0x901E	#CJK UNIFIED IDEOGRAPH
-0xE798	0x9016	#CJK UNIFIED IDEOGRAPH
-0xE799	0x900B	#CJK UNIFIED IDEOGRAPH
-0xE79A	0x9027	#CJK UNIFIED IDEOGRAPH
-0xE79B	0x9036	#CJK UNIFIED IDEOGRAPH
-0xE79C	0x9035	#CJK UNIFIED IDEOGRAPH
-0xE79D	0x9039	#CJK UNIFIED IDEOGRAPH
-0xE79E	0x8FF8	#CJK UNIFIED IDEOGRAPH
-0xE79F	0x904F	#CJK UNIFIED IDEOGRAPH
-0xE7A0	0x9050	#CJK UNIFIED IDEOGRAPH
-0xE7A1	0x9051	#CJK UNIFIED IDEOGRAPH
-0xE7A2	0x9052	#CJK UNIFIED IDEOGRAPH
-0xE7A3	0x900E	#CJK UNIFIED IDEOGRAPH
-0xE7A4	0x9049	#CJK UNIFIED IDEOGRAPH
-0xE7A5	0x903E	#CJK UNIFIED IDEOGRAPH
-0xE7A6	0x9056	#CJK UNIFIED IDEOGRAPH
-0xE7A7	0x9058	#CJK UNIFIED IDEOGRAPH
-0xE7A8	0x905E	#CJK UNIFIED IDEOGRAPH
-0xE7A9	0x9068	#CJK UNIFIED IDEOGRAPH
-0xE7AA	0x906F	#CJK UNIFIED IDEOGRAPH
-0xE7AB	0x9076	#CJK UNIFIED IDEOGRAPH
-0xE7AC	0x96A8	#CJK UNIFIED IDEOGRAPH
-0xE7AD	0x9072	#CJK UNIFIED IDEOGRAPH
-0xE7AE	0x9082	#CJK UNIFIED IDEOGRAPH
-0xE7AF	0x907D	#CJK UNIFIED IDEOGRAPH
-0xE7B0	0x9081	#CJK UNIFIED IDEOGRAPH
-0xE7B1	0x9080	#CJK UNIFIED IDEOGRAPH
-0xE7B2	0x908A	#CJK UNIFIED IDEOGRAPH
-0xE7B3	0x9089	#CJK UNIFIED IDEOGRAPH
-0xE7B4	0x908F	#CJK UNIFIED IDEOGRAPH
-0xE7B5	0x90A8	#CJK UNIFIED IDEOGRAPH
-0xE7B6	0x90AF	#CJK UNIFIED IDEOGRAPH
-0xE7B7	0x90B1	#CJK UNIFIED IDEOGRAPH
-0xE7B8	0x90B5	#CJK UNIFIED IDEOGRAPH
-0xE7B9	0x90E2	#CJK UNIFIED IDEOGRAPH
-0xE7BA	0x90E4	#CJK UNIFIED IDEOGRAPH
-0xE7BB	0x6248	#CJK UNIFIED IDEOGRAPH
-0xE7BC	0x90DB	#CJK UNIFIED IDEOGRAPH
-0xE7BD	0x9102	#CJK UNIFIED IDEOGRAPH
-0xE7BE	0x9112	#CJK UNIFIED IDEOGRAPH
-0xE7BF	0x9119	#CJK UNIFIED IDEOGRAPH
-0xE7C0	0x9132	#CJK UNIFIED IDEOGRAPH
-0xE7C1	0x9130	#CJK UNIFIED IDEOGRAPH
-0xE7C2	0x914A	#CJK UNIFIED IDEOGRAPH
-0xE7C3	0x9156	#CJK UNIFIED IDEOGRAPH
-0xE7C4	0x9158	#CJK UNIFIED IDEOGRAPH
-0xE7C5	0x9163	#CJK UNIFIED IDEOGRAPH
-0xE7C6	0x9165	#CJK UNIFIED IDEOGRAPH
-0xE7C7	0x9169	#CJK UNIFIED IDEOGRAPH
-0xE7C8	0x9173	#CJK UNIFIED IDEOGRAPH
-0xE7C9	0x9172	#CJK UNIFIED IDEOGRAPH
-0xE7CA	0x918B	#CJK UNIFIED IDEOGRAPH
-0xE7CB	0x9189	#CJK UNIFIED IDEOGRAPH
-0xE7CC	0x9182	#CJK UNIFIED IDEOGRAPH
-0xE7CD	0x91A2	#CJK UNIFIED IDEOGRAPH
-0xE7CE	0x91AB	#CJK UNIFIED IDEOGRAPH
-0xE7CF	0x91AF	#CJK UNIFIED IDEOGRAPH
-0xE7D0	0x91AA	#CJK UNIFIED IDEOGRAPH
-0xE7D1	0x91B5	#CJK UNIFIED IDEOGRAPH
-0xE7D2	0x91B4	#CJK UNIFIED IDEOGRAPH
-0xE7D3	0x91BA	#CJK UNIFIED IDEOGRAPH
-0xE7D4	0x91C0	#CJK UNIFIED IDEOGRAPH
-0xE7D5	0x91C1	#CJK UNIFIED IDEOGRAPH
-0xE7D6	0x91C9	#CJK UNIFIED IDEOGRAPH
-0xE7D7	0x91CB	#CJK UNIFIED IDEOGRAPH
-0xE7D8	0x91D0	#CJK UNIFIED IDEOGRAPH
-0xE7D9	0x91D6	#CJK UNIFIED IDEOGRAPH
-0xE7DA	0x91DF	#CJK UNIFIED IDEOGRAPH
-0xE7DB	0x91E1	#CJK UNIFIED IDEOGRAPH
-0xE7DC	0x91DB	#CJK UNIFIED IDEOGRAPH
-0xE7DD	0x91FC	#CJK UNIFIED IDEOGRAPH
-0xE7DE	0x91F5	#CJK UNIFIED IDEOGRAPH
-0xE7DF	0x91F6	#CJK UNIFIED IDEOGRAPH
-0xE7E0	0x921E	#CJK UNIFIED IDEOGRAPH
-0xE7E1	0x91FF	#CJK UNIFIED IDEOGRAPH
-0xE7E2	0x9214	#CJK UNIFIED IDEOGRAPH
-0xE7E3	0x922C	#CJK UNIFIED IDEOGRAPH
-0xE7E4	0x9215	#CJK UNIFIED IDEOGRAPH
-0xE7E5	0x9211	#CJK UNIFIED IDEOGRAPH
-0xE7E6	0x925E	#CJK UNIFIED IDEOGRAPH
-0xE7E7	0x9257	#CJK UNIFIED IDEOGRAPH
-0xE7E8	0x9245	#CJK UNIFIED IDEOGRAPH
-0xE7E9	0x9249	#CJK UNIFIED IDEOGRAPH
-0xE7EA	0x9264	#CJK UNIFIED IDEOGRAPH
-0xE7EB	0x9248	#CJK UNIFIED IDEOGRAPH
-0xE7EC	0x9295	#CJK UNIFIED IDEOGRAPH
-0xE7ED	0x923F	#CJK UNIFIED IDEOGRAPH
-0xE7EE	0x924B	#CJK UNIFIED IDEOGRAPH
-0xE7EF	0x9250	#CJK UNIFIED IDEOGRAPH
-0xE7F0	0x929C	#CJK UNIFIED IDEOGRAPH
-0xE7F1	0x9296	#CJK UNIFIED IDEOGRAPH
-0xE7F2	0x9293	#CJK UNIFIED IDEOGRAPH
-0xE7F3	0x929B	#CJK UNIFIED IDEOGRAPH
-0xE7F4	0x925A	#CJK UNIFIED IDEOGRAPH
-0xE7F5	0x92CF	#CJK UNIFIED IDEOGRAPH
-0xE7F6	0x92B9	#CJK UNIFIED IDEOGRAPH
-0xE7F7	0x92B7	#CJK UNIFIED IDEOGRAPH
-0xE7F8	0x92E9	#CJK UNIFIED IDEOGRAPH
-0xE7F9	0x930F	#CJK UNIFIED IDEOGRAPH
-0xE7FA	0x92FA	#CJK UNIFIED IDEOGRAPH
-0xE7FB	0x9344	#CJK UNIFIED IDEOGRAPH
-0xE7FC	0x932E	#CJK UNIFIED IDEOGRAPH
-0xE840	0x9319	#CJK UNIFIED IDEOGRAPH
-0xE841	0x9322	#CJK UNIFIED IDEOGRAPH
-0xE842	0x931A	#CJK UNIFIED IDEOGRAPH
-0xE843	0x9323	#CJK UNIFIED IDEOGRAPH
-0xE844	0x933A	#CJK UNIFIED IDEOGRAPH
-0xE845	0x9335	#CJK UNIFIED IDEOGRAPH
-0xE846	0x933B	#CJK UNIFIED IDEOGRAPH
-0xE847	0x935C	#CJK UNIFIED IDEOGRAPH
-0xE848	0x9360	#CJK UNIFIED IDEOGRAPH
-0xE849	0x937C	#CJK UNIFIED IDEOGRAPH
-0xE84A	0x936E	#CJK UNIFIED IDEOGRAPH
-0xE84B	0x9356	#CJK UNIFIED IDEOGRAPH
-0xE84C	0x93B0	#CJK UNIFIED IDEOGRAPH
-0xE84D	0x93AC	#CJK UNIFIED IDEOGRAPH
-0xE84E	0x93AD	#CJK UNIFIED IDEOGRAPH
-0xE84F	0x9394	#CJK UNIFIED IDEOGRAPH
-0xE850	0x93B9	#CJK UNIFIED IDEOGRAPH
-0xE851	0x93D6	#CJK UNIFIED IDEOGRAPH
-0xE852	0x93D7	#CJK UNIFIED IDEOGRAPH
-0xE853	0x93E8	#CJK UNIFIED IDEOGRAPH
-0xE854	0x93E5	#CJK UNIFIED IDEOGRAPH
-0xE855	0x93D8	#CJK UNIFIED IDEOGRAPH
-0xE856	0x93C3	#CJK UNIFIED IDEOGRAPH
-0xE857	0x93DD	#CJK UNIFIED IDEOGRAPH
-0xE858	0x93D0	#CJK UNIFIED IDEOGRAPH
-0xE859	0x93C8	#CJK UNIFIED IDEOGRAPH
-0xE85A	0x93E4	#CJK UNIFIED IDEOGRAPH
-0xE85B	0x941A	#CJK UNIFIED IDEOGRAPH
-0xE85C	0x9414	#CJK UNIFIED IDEOGRAPH
-0xE85D	0x9413	#CJK UNIFIED IDEOGRAPH
-0xE85E	0x9403	#CJK UNIFIED IDEOGRAPH
-0xE85F	0x9407	#CJK UNIFIED IDEOGRAPH
-0xE860	0x9410	#CJK UNIFIED IDEOGRAPH
-0xE861	0x9436	#CJK UNIFIED IDEOGRAPH
-0xE862	0x942B	#CJK UNIFIED IDEOGRAPH
-0xE863	0x9435	#CJK UNIFIED IDEOGRAPH
-0xE864	0x9421	#CJK UNIFIED IDEOGRAPH
-0xE865	0x943A	#CJK UNIFIED IDEOGRAPH
-0xE866	0x9441	#CJK UNIFIED IDEOGRAPH
-0xE867	0x9452	#CJK UNIFIED IDEOGRAPH
-0xE868	0x9444	#CJK UNIFIED IDEOGRAPH
-0xE869	0x945B	#CJK UNIFIED IDEOGRAPH
-0xE86A	0x9460	#CJK UNIFIED IDEOGRAPH
-0xE86B	0x9462	#CJK UNIFIED IDEOGRAPH
-0xE86C	0x945E	#CJK UNIFIED IDEOGRAPH
-0xE86D	0x946A	#CJK UNIFIED IDEOGRAPH
-0xE86E	0x9229	#CJK UNIFIED IDEOGRAPH
-0xE86F	0x9470	#CJK UNIFIED IDEOGRAPH
-0xE870	0x9475	#CJK UNIFIED IDEOGRAPH
-0xE871	0x9477	#CJK UNIFIED IDEOGRAPH
-0xE872	0x947D	#CJK UNIFIED IDEOGRAPH
-0xE873	0x945A	#CJK UNIFIED IDEOGRAPH
-0xE874	0x947C	#CJK UNIFIED IDEOGRAPH
-0xE875	0x947E	#CJK UNIFIED IDEOGRAPH
-0xE876	0x9481	#CJK UNIFIED IDEOGRAPH
-0xE877	0x947F	#CJK UNIFIED IDEOGRAPH
-0xE878	0x9582	#CJK UNIFIED IDEOGRAPH
-0xE879	0x9587	#CJK UNIFIED IDEOGRAPH
-0xE87A	0x958A	#CJK UNIFIED IDEOGRAPH
-0xE87B	0x9594	#CJK UNIFIED IDEOGRAPH
-0xE87C	0x9596	#CJK UNIFIED IDEOGRAPH
-0xE87D	0x9598	#CJK UNIFIED IDEOGRAPH
-0xE87E	0x9599	#CJK UNIFIED IDEOGRAPH
-0xE880	0x95A0	#CJK UNIFIED IDEOGRAPH
-0xE881	0x95A8	#CJK UNIFIED IDEOGRAPH
-0xE882	0x95A7	#CJK UNIFIED IDEOGRAPH
-0xE883	0x95AD	#CJK UNIFIED IDEOGRAPH
-0xE884	0x95BC	#CJK UNIFIED IDEOGRAPH
-0xE885	0x95BB	#CJK UNIFIED IDEOGRAPH
-0xE886	0x95B9	#CJK UNIFIED IDEOGRAPH
-0xE887	0x95BE	#CJK UNIFIED IDEOGRAPH
-0xE888	0x95CA	#CJK UNIFIED IDEOGRAPH
-0xE889	0x6FF6	#CJK UNIFIED IDEOGRAPH
-0xE88A	0x95C3	#CJK UNIFIED IDEOGRAPH
-0xE88B	0x95CD	#CJK UNIFIED IDEOGRAPH
-0xE88C	0x95CC	#CJK UNIFIED IDEOGRAPH
-0xE88D	0x95D5	#CJK UNIFIED IDEOGRAPH
-0xE88E	0x95D4	#CJK UNIFIED IDEOGRAPH
-0xE88F	0x95D6	#CJK UNIFIED IDEOGRAPH
-0xE890	0x95DC	#CJK UNIFIED IDEOGRAPH
-0xE891	0x95E1	#CJK UNIFIED IDEOGRAPH
-0xE892	0x95E5	#CJK UNIFIED IDEOGRAPH
-0xE893	0x95E2	#CJK UNIFIED IDEOGRAPH
-0xE894	0x9621	#CJK UNIFIED IDEOGRAPH
-0xE895	0x9628	#CJK UNIFIED IDEOGRAPH
-0xE896	0x962E	#CJK UNIFIED IDEOGRAPH
-0xE897	0x962F	#CJK UNIFIED IDEOGRAPH
-0xE898	0x9642	#CJK UNIFIED IDEOGRAPH
-0xE899	0x964C	#CJK UNIFIED IDEOGRAPH
-0xE89A	0x964F	#CJK UNIFIED IDEOGRAPH
-0xE89B	0x964B	#CJK UNIFIED IDEOGRAPH
-0xE89C	0x9677	#CJK UNIFIED IDEOGRAPH
-0xE89D	0x965C	#CJK UNIFIED IDEOGRAPH
-0xE89E	0x965E	#CJK UNIFIED IDEOGRAPH
-0xE89F	0x965D	#CJK UNIFIED IDEOGRAPH
-0xE8A0	0x965F	#CJK UNIFIED IDEOGRAPH
-0xE8A1	0x9666	#CJK UNIFIED IDEOGRAPH
-0xE8A2	0x9672	#CJK UNIFIED IDEOGRAPH
-0xE8A3	0x966C	#CJK UNIFIED IDEOGRAPH
-0xE8A4	0x968D	#CJK UNIFIED IDEOGRAPH
-0xE8A5	0x9698	#CJK UNIFIED IDEOGRAPH
-0xE8A6	0x9695	#CJK UNIFIED IDEOGRAPH
-0xE8A7	0x9697	#CJK UNIFIED IDEOGRAPH
-0xE8A8	0x96AA	#CJK UNIFIED IDEOGRAPH
-0xE8A9	0x96A7	#CJK UNIFIED IDEOGRAPH
-0xE8AA	0x96B1	#CJK UNIFIED IDEOGRAPH
-0xE8AB	0x96B2	#CJK UNIFIED IDEOGRAPH
-0xE8AC	0x96B0	#CJK UNIFIED IDEOGRAPH
-0xE8AD	0x96B4	#CJK UNIFIED IDEOGRAPH
-0xE8AE	0x96B6	#CJK UNIFIED IDEOGRAPH
-0xE8AF	0x96B8	#CJK UNIFIED IDEOGRAPH
-0xE8B0	0x96B9	#CJK UNIFIED IDEOGRAPH
-0xE8B1	0x96CE	#CJK UNIFIED IDEOGRAPH
-0xE8B2	0x96CB	#CJK UNIFIED IDEOGRAPH
-0xE8B3	0x96C9	#CJK UNIFIED IDEOGRAPH
-0xE8B4	0x96CD	#CJK UNIFIED IDEOGRAPH
-0xE8B5	0x894D	#CJK UNIFIED IDEOGRAPH
-0xE8B6	0x96DC	#CJK UNIFIED IDEOGRAPH
-0xE8B7	0x970D	#CJK UNIFIED IDEOGRAPH
-0xE8B8	0x96D5	#CJK UNIFIED IDEOGRAPH
-0xE8B9	0x96F9	#CJK UNIFIED IDEOGRAPH
-0xE8BA	0x9704	#CJK UNIFIED IDEOGRAPH
-0xE8BB	0x9706	#CJK UNIFIED IDEOGRAPH
-0xE8BC	0x9708	#CJK UNIFIED IDEOGRAPH
-0xE8BD	0x9713	#CJK UNIFIED IDEOGRAPH
-0xE8BE	0x970E	#CJK UNIFIED IDEOGRAPH
-0xE8BF	0x9711	#CJK UNIFIED IDEOGRAPH
-0xE8C0	0x970F	#CJK UNIFIED IDEOGRAPH
-0xE8C1	0x9716	#CJK UNIFIED IDEOGRAPH
-0xE8C2	0x9719	#CJK UNIFIED IDEOGRAPH
-0xE8C3	0x9724	#CJK UNIFIED IDEOGRAPH
-0xE8C4	0x972A	#CJK UNIFIED IDEOGRAPH
-0xE8C5	0x9730	#CJK UNIFIED IDEOGRAPH
-0xE8C6	0x9739	#CJK UNIFIED IDEOGRAPH
-0xE8C7	0x973D	#CJK UNIFIED IDEOGRAPH
-0xE8C8	0x973E	#CJK UNIFIED IDEOGRAPH
-0xE8C9	0x9744	#CJK UNIFIED IDEOGRAPH
-0xE8CA	0x9746	#CJK UNIFIED IDEOGRAPH
-0xE8CB	0x9748	#CJK UNIFIED IDEOGRAPH
-0xE8CC	0x9742	#CJK UNIFIED IDEOGRAPH
-0xE8CD	0x9749	#CJK UNIFIED IDEOGRAPH
-0xE8CE	0x975C	#CJK UNIFIED IDEOGRAPH
-0xE8CF	0x9760	#CJK UNIFIED IDEOGRAPH
-0xE8D0	0x9764	#CJK UNIFIED IDEOGRAPH
-0xE8D1	0x9766	#CJK UNIFIED IDEOGRAPH
-0xE8D2	0x9768	#CJK UNIFIED IDEOGRAPH
-0xE8D3	0x52D2	#CJK UNIFIED IDEOGRAPH
-0xE8D4	0x976B	#CJK UNIFIED IDEOGRAPH
-0xE8D5	0x9771	#CJK UNIFIED IDEOGRAPH
-0xE8D6	0x9779	#CJK UNIFIED IDEOGRAPH
-0xE8D7	0x9785	#CJK UNIFIED IDEOGRAPH
-0xE8D8	0x977C	#CJK UNIFIED IDEOGRAPH
-0xE8D9	0x9781	#CJK UNIFIED IDEOGRAPH
-0xE8DA	0x977A	#CJK UNIFIED IDEOGRAPH
-0xE8DB	0x9786	#CJK UNIFIED IDEOGRAPH
-0xE8DC	0x978B	#CJK UNIFIED IDEOGRAPH
-0xE8DD	0x978F	#CJK UNIFIED IDEOGRAPH
-0xE8DE	0x9790	#CJK UNIFIED IDEOGRAPH
-0xE8DF	0x979C	#CJK UNIFIED IDEOGRAPH
-0xE8E0	0x97A8	#CJK UNIFIED IDEOGRAPH
-0xE8E1	0x97A6	#CJK UNIFIED IDEOGRAPH
-0xE8E2	0x97A3	#CJK UNIFIED IDEOGRAPH
-0xE8E3	0x97B3	#CJK UNIFIED IDEOGRAPH
-0xE8E4	0x97B4	#CJK UNIFIED IDEOGRAPH
-0xE8E5	0x97C3	#CJK UNIFIED IDEOGRAPH
-0xE8E6	0x97C6	#CJK UNIFIED IDEOGRAPH
-0xE8E7	0x97C8	#CJK UNIFIED IDEOGRAPH
-0xE8E8	0x97CB	#CJK UNIFIED IDEOGRAPH
-0xE8E9	0x97DC	#CJK UNIFIED IDEOGRAPH
-0xE8EA	0x97ED	#CJK UNIFIED IDEOGRAPH
-0xE8EB	0x9F4F	#CJK UNIFIED IDEOGRAPH
-0xE8EC	0x97F2	#CJK UNIFIED IDEOGRAPH
-0xE8ED	0x7ADF	#CJK UNIFIED IDEOGRAPH
-0xE8EE	0x97F6	#CJK UNIFIED IDEOGRAPH
-0xE8EF	0x97F5	#CJK UNIFIED IDEOGRAPH
-0xE8F0	0x980F	#CJK UNIFIED IDEOGRAPH
-0xE8F1	0x980C	#CJK UNIFIED IDEOGRAPH
-0xE8F2	0x9838	#CJK UNIFIED IDEOGRAPH
-0xE8F3	0x9824	#CJK UNIFIED IDEOGRAPH
-0xE8F4	0x9821	#CJK UNIFIED IDEOGRAPH
-0xE8F5	0x9837	#CJK UNIFIED IDEOGRAPH
-0xE8F6	0x983D	#CJK UNIFIED IDEOGRAPH
-0xE8F7	0x9846	#CJK UNIFIED IDEOGRAPH
-0xE8F8	0x984F	#CJK UNIFIED IDEOGRAPH
-0xE8F9	0x984B	#CJK UNIFIED IDEOGRAPH
-0xE8FA	0x986B	#CJK UNIFIED IDEOGRAPH
-0xE8FB	0x986F	#CJK UNIFIED IDEOGRAPH
-0xE8FC	0x9870	#CJK UNIFIED IDEOGRAPH
-0xE940	0x9871	#CJK UNIFIED IDEOGRAPH
-0xE941	0x9874	#CJK UNIFIED IDEOGRAPH
-0xE942	0x9873	#CJK UNIFIED IDEOGRAPH
-0xE943	0x98AA	#CJK UNIFIED IDEOGRAPH
-0xE944	0x98AF	#CJK UNIFIED IDEOGRAPH
-0xE945	0x98B1	#CJK UNIFIED IDEOGRAPH
-0xE946	0x98B6	#CJK UNIFIED IDEOGRAPH
-0xE947	0x98C4	#CJK UNIFIED IDEOGRAPH
-0xE948	0x98C3	#CJK UNIFIED IDEOGRAPH
-0xE949	0x98C6	#CJK UNIFIED IDEOGRAPH
-0xE94A	0x98E9	#CJK UNIFIED IDEOGRAPH
-0xE94B	0x98EB	#CJK UNIFIED IDEOGRAPH
-0xE94C	0x9903	#CJK UNIFIED IDEOGRAPH
-0xE94D	0x9909	#CJK UNIFIED IDEOGRAPH
-0xE94E	0x9912	#CJK UNIFIED IDEOGRAPH
-0xE94F	0x9914	#CJK UNIFIED IDEOGRAPH
-0xE950	0x9918	#CJK UNIFIED IDEOGRAPH
-0xE951	0x9921	#CJK UNIFIED IDEOGRAPH
-0xE952	0x991D	#CJK UNIFIED IDEOGRAPH
-0xE953	0x991E	#CJK UNIFIED IDEOGRAPH
-0xE954	0x9924	#CJK UNIFIED IDEOGRAPH
-0xE955	0x9920	#CJK UNIFIED IDEOGRAPH
-0xE956	0x992C	#CJK UNIFIED IDEOGRAPH
-0xE957	0x992E	#CJK UNIFIED IDEOGRAPH
-0xE958	0x993D	#CJK UNIFIED IDEOGRAPH
-0xE959	0x993E	#CJK UNIFIED IDEOGRAPH
-0xE95A	0x9942	#CJK UNIFIED IDEOGRAPH
-0xE95B	0x9949	#CJK UNIFIED IDEOGRAPH
-0xE95C	0x9945	#CJK UNIFIED IDEOGRAPH
-0xE95D	0x9950	#CJK UNIFIED IDEOGRAPH
-0xE95E	0x994B	#CJK UNIFIED IDEOGRAPH
-0xE95F	0x9951	#CJK UNIFIED IDEOGRAPH
-0xE960	0x9952	#CJK UNIFIED IDEOGRAPH
-0xE961	0x994C	#CJK UNIFIED IDEOGRAPH
-0xE962	0x9955	#CJK UNIFIED IDEOGRAPH
-0xE963	0x9997	#CJK UNIFIED IDEOGRAPH
-0xE964	0x9998	#CJK UNIFIED IDEOGRAPH
-0xE965	0x99A5	#CJK UNIFIED IDEOGRAPH
-0xE966	0x99AD	#CJK UNIFIED IDEOGRAPH
-0xE967	0x99AE	#CJK UNIFIED IDEOGRAPH
-0xE968	0x99BC	#CJK UNIFIED IDEOGRAPH
-0xE969	0x99DF	#CJK UNIFIED IDEOGRAPH
-0xE96A	0x99DB	#CJK UNIFIED IDEOGRAPH
-0xE96B	0x99DD	#CJK UNIFIED IDEOGRAPH
-0xE96C	0x99D8	#CJK UNIFIED IDEOGRAPH
-0xE96D	0x99D1	#CJK UNIFIED IDEOGRAPH
-0xE96E	0x99ED	#CJK UNIFIED IDEOGRAPH
-0xE96F	0x99EE	#CJK UNIFIED IDEOGRAPH
-0xE970	0x99F1	#CJK UNIFIED IDEOGRAPH
-0xE971	0x99F2	#CJK UNIFIED IDEOGRAPH
-0xE972	0x99FB	#CJK UNIFIED IDEOGRAPH
-0xE973	0x99F8	#CJK UNIFIED IDEOGRAPH
-0xE974	0x9A01	#CJK UNIFIED IDEOGRAPH
-0xE975	0x9A0F	#CJK UNIFIED IDEOGRAPH
-0xE976	0x9A05	#CJK UNIFIED IDEOGRAPH
-0xE977	0x99E2	#CJK UNIFIED IDEOGRAPH
-0xE978	0x9A19	#CJK UNIFIED IDEOGRAPH
-0xE979	0x9A2B	#CJK UNIFIED IDEOGRAPH
-0xE97A	0x9A37	#CJK UNIFIED IDEOGRAPH
-0xE97B	0x9A45	#CJK UNIFIED IDEOGRAPH
-0xE97C	0x9A42	#CJK UNIFIED IDEOGRAPH
-0xE97D	0x9A40	#CJK UNIFIED IDEOGRAPH
-0xE97E	0x9A43	#CJK UNIFIED IDEOGRAPH
-0xE980	0x9A3E	#CJK UNIFIED IDEOGRAPH
-0xE981	0x9A55	#CJK UNIFIED IDEOGRAPH
-0xE982	0x9A4D	#CJK UNIFIED IDEOGRAPH
-0xE983	0x9A5B	#CJK UNIFIED IDEOGRAPH
-0xE984	0x9A57	#CJK UNIFIED IDEOGRAPH
-0xE985	0x9A5F	#CJK UNIFIED IDEOGRAPH
-0xE986	0x9A62	#CJK UNIFIED IDEOGRAPH
-0xE987	0x9A65	#CJK UNIFIED IDEOGRAPH
-0xE988	0x9A64	#CJK UNIFIED IDEOGRAPH
-0xE989	0x9A69	#CJK UNIFIED IDEOGRAPH
-0xE98A	0x9A6B	#CJK UNIFIED IDEOGRAPH
-0xE98B	0x9A6A	#CJK UNIFIED IDEOGRAPH
-0xE98C	0x9AAD	#CJK UNIFIED IDEOGRAPH
-0xE98D	0x9AB0	#CJK UNIFIED IDEOGRAPH
-0xE98E	0x9ABC	#CJK UNIFIED IDEOGRAPH
-0xE98F	0x9AC0	#CJK UNIFIED IDEOGRAPH
-0xE990	0x9ACF	#CJK UNIFIED IDEOGRAPH
-0xE991	0x9AD1	#CJK UNIFIED IDEOGRAPH
-0xE992	0x9AD3	#CJK UNIFIED IDEOGRAPH
-0xE993	0x9AD4	#CJK UNIFIED IDEOGRAPH
-0xE994	0x9ADE	#CJK UNIFIED IDEOGRAPH
-0xE995	0x9ADF	#CJK UNIFIED IDEOGRAPH
-0xE996	0x9AE2	#CJK UNIFIED IDEOGRAPH
-0xE997	0x9AE3	#CJK UNIFIED IDEOGRAPH
-0xE998	0x9AE6	#CJK UNIFIED IDEOGRAPH
-0xE999	0x9AEF	#CJK UNIFIED IDEOGRAPH
-0xE99A	0x9AEB	#CJK UNIFIED IDEOGRAPH
-0xE99B	0x9AEE	#CJK UNIFIED IDEOGRAPH
-0xE99C	0x9AF4	#CJK UNIFIED IDEOGRAPH
-0xE99D	0x9AF1	#CJK UNIFIED IDEOGRAPH
-0xE99E	0x9AF7	#CJK UNIFIED IDEOGRAPH
-0xE99F	0x9AFB	#CJK UNIFIED IDEOGRAPH
-0xE9A0	0x9B06	#CJK UNIFIED IDEOGRAPH
-0xE9A1	0x9B18	#CJK UNIFIED IDEOGRAPH
-0xE9A2	0x9B1A	#CJK UNIFIED IDEOGRAPH
-0xE9A3	0x9B1F	#CJK UNIFIED IDEOGRAPH
-0xE9A4	0x9B22	#CJK UNIFIED IDEOGRAPH
-0xE9A5	0x9B23	#CJK UNIFIED IDEOGRAPH
-0xE9A6	0x9B25	#CJK UNIFIED IDEOGRAPH
-0xE9A7	0x9B27	#CJK UNIFIED IDEOGRAPH
-0xE9A8	0x9B28	#CJK UNIFIED IDEOGRAPH
-0xE9A9	0x9B29	#CJK UNIFIED IDEOGRAPH
-0xE9AA	0x9B2A	#CJK UNIFIED IDEOGRAPH
-0xE9AB	0x9B2E	#CJK UNIFIED IDEOGRAPH
-0xE9AC	0x9B2F	#CJK UNIFIED IDEOGRAPH
-0xE9AD	0x9B32	#CJK UNIFIED IDEOGRAPH
-0xE9AE	0x9B44	#CJK UNIFIED IDEOGRAPH
-0xE9AF	0x9B43	#CJK UNIFIED IDEOGRAPH
-0xE9B0	0x9B4F	#CJK UNIFIED IDEOGRAPH
-0xE9B1	0x9B4D	#CJK UNIFIED IDEOGRAPH
-0xE9B2	0x9B4E	#CJK UNIFIED IDEOGRAPH
-0xE9B3	0x9B51	#CJK UNIFIED IDEOGRAPH
-0xE9B4	0x9B58	#CJK UNIFIED IDEOGRAPH
-0xE9B5	0x9B74	#CJK UNIFIED IDEOGRAPH
-0xE9B6	0x9B93	#CJK UNIFIED IDEOGRAPH
-0xE9B7	0x9B83	#CJK UNIFIED IDEOGRAPH
-0xE9B8	0x9B91	#CJK UNIFIED IDEOGRAPH
-0xE9B9	0x9B96	#CJK UNIFIED IDEOGRAPH
-0xE9BA	0x9B97	#CJK UNIFIED IDEOGRAPH
-0xE9BB	0x9B9F	#CJK UNIFIED IDEOGRAPH
-0xE9BC	0x9BA0	#CJK UNIFIED IDEOGRAPH
-0xE9BD	0x9BA8	#CJK UNIFIED IDEOGRAPH
-0xE9BE	0x9BB4	#CJK UNIFIED IDEOGRAPH
-0xE9BF	0x9BC0	#CJK UNIFIED IDEOGRAPH
-0xE9C0	0x9BCA	#CJK UNIFIED IDEOGRAPH
-0xE9C1	0x9BB9	#CJK UNIFIED IDEOGRAPH
-0xE9C2	0x9BC6	#CJK UNIFIED IDEOGRAPH
-0xE9C3	0x9BCF	#CJK UNIFIED IDEOGRAPH
-0xE9C4	0x9BD1	#CJK UNIFIED IDEOGRAPH
-0xE9C5	0x9BD2	#CJK UNIFIED IDEOGRAPH
-0xE9C6	0x9BE3	#CJK UNIFIED IDEOGRAPH
-0xE9C7	0x9BE2	#CJK UNIFIED IDEOGRAPH
-0xE9C8	0x9BE4	#CJK UNIFIED IDEOGRAPH
-0xE9C9	0x9BD4	#CJK UNIFIED IDEOGRAPH
-0xE9CA	0x9BE1	#CJK UNIFIED IDEOGRAPH
-0xE9CB	0x9C3A	#CJK UNIFIED IDEOGRAPH
-0xE9CC	0x9BF2	#CJK UNIFIED IDEOGRAPH
-0xE9CD	0x9BF1	#CJK UNIFIED IDEOGRAPH
-0xE9CE	0x9BF0	#CJK UNIFIED IDEOGRAPH
-0xE9CF	0x9C15	#CJK UNIFIED IDEOGRAPH
-0xE9D0	0x9C14	#CJK UNIFIED IDEOGRAPH
-0xE9D1	0x9C09	#CJK UNIFIED IDEOGRAPH
-0xE9D2	0x9C13	#CJK UNIFIED IDEOGRAPH
-0xE9D3	0x9C0C	#CJK UNIFIED IDEOGRAPH
-0xE9D4	0x9C06	#CJK UNIFIED IDEOGRAPH
-0xE9D5	0x9C08	#CJK UNIFIED IDEOGRAPH
-0xE9D6	0x9C12	#CJK UNIFIED IDEOGRAPH
-0xE9D7	0x9C0A	#CJK UNIFIED IDEOGRAPH
-0xE9D8	0x9C04	#CJK UNIFIED IDEOGRAPH
-0xE9D9	0x9C2E	#CJK UNIFIED IDEOGRAPH
-0xE9DA	0x9C1B	#CJK UNIFIED IDEOGRAPH
-0xE9DB	0x9C25	#CJK UNIFIED IDEOGRAPH
-0xE9DC	0x9C24	#CJK UNIFIED IDEOGRAPH
-0xE9DD	0x9C21	#CJK UNIFIED IDEOGRAPH
-0xE9DE	0x9C30	#CJK UNIFIED IDEOGRAPH
-0xE9DF	0x9C47	#CJK UNIFIED IDEOGRAPH
-0xE9E0	0x9C32	#CJK UNIFIED IDEOGRAPH
-0xE9E1	0x9C46	#CJK UNIFIED IDEOGRAPH
-0xE9E2	0x9C3E	#CJK UNIFIED IDEOGRAPH
-0xE9E3	0x9C5A	#CJK UNIFIED IDEOGRAPH
-0xE9E4	0x9C60	#CJK UNIFIED IDEOGRAPH
-0xE9E5	0x9C67	#CJK UNIFIED IDEOGRAPH
-0xE9E6	0x9C76	#CJK UNIFIED IDEOGRAPH
-0xE9E7	0x9C78	#CJK UNIFIED IDEOGRAPH
-0xE9E8	0x9CE7	#CJK UNIFIED IDEOGRAPH
-0xE9E9	0x9CEC	#CJK UNIFIED IDEOGRAPH
-0xE9EA	0x9CF0	#CJK UNIFIED IDEOGRAPH
-0xE9EB	0x9D09	#CJK UNIFIED IDEOGRAPH
-0xE9EC	0x9D08	#CJK UNIFIED IDEOGRAPH
-0xE9ED	0x9CEB	#CJK UNIFIED IDEOGRAPH
-0xE9EE	0x9D03	#CJK UNIFIED IDEOGRAPH
-0xE9EF	0x9D06	#CJK UNIFIED IDEOGRAPH
-0xE9F0	0x9D2A	#CJK UNIFIED IDEOGRAPH
-0xE9F1	0x9D26	#CJK UNIFIED IDEOGRAPH
-0xE9F2	0x9DAF	#CJK UNIFIED IDEOGRAPH
-0xE9F3	0x9D23	#CJK UNIFIED IDEOGRAPH
-0xE9F4	0x9D1F	#CJK UNIFIED IDEOGRAPH
-0xE9F5	0x9D44	#CJK UNIFIED IDEOGRAPH
-0xE9F6	0x9D15	#CJK UNIFIED IDEOGRAPH
-0xE9F7	0x9D12	#CJK UNIFIED IDEOGRAPH
-0xE9F8	0x9D41	#CJK UNIFIED IDEOGRAPH
-0xE9F9	0x9D3F	#CJK UNIFIED IDEOGRAPH
-0xE9FA	0x9D3E	#CJK UNIFIED IDEOGRAPH
-0xE9FB	0x9D46	#CJK UNIFIED IDEOGRAPH
-0xE9FC	0x9D48	#CJK UNIFIED IDEOGRAPH
-0xEA40	0x9D5D	#CJK UNIFIED IDEOGRAPH
-0xEA41	0x9D5E	#CJK UNIFIED IDEOGRAPH
-0xEA42	0x9D64	#CJK UNIFIED IDEOGRAPH
-0xEA43	0x9D51	#CJK UNIFIED IDEOGRAPH
-0xEA44	0x9D50	#CJK UNIFIED IDEOGRAPH
-0xEA45	0x9D59	#CJK UNIFIED IDEOGRAPH
-0xEA46	0x9D72	#CJK UNIFIED IDEOGRAPH
-0xEA47	0x9D89	#CJK UNIFIED IDEOGRAPH
-0xEA48	0x9D87	#CJK UNIFIED IDEOGRAPH
-0xEA49	0x9DAB	#CJK UNIFIED IDEOGRAPH
-0xEA4A	0x9D6F	#CJK UNIFIED IDEOGRAPH
-0xEA4B	0x9D7A	#CJK UNIFIED IDEOGRAPH
-0xEA4C	0x9D9A	#CJK UNIFIED IDEOGRAPH
-0xEA4D	0x9DA4	#CJK UNIFIED IDEOGRAPH
-0xEA4E	0x9DA9	#CJK UNIFIED IDEOGRAPH
-0xEA4F	0x9DB2	#CJK UNIFIED IDEOGRAPH
-0xEA50	0x9DC4	#CJK UNIFIED IDEOGRAPH
-0xEA51	0x9DC1	#CJK UNIFIED IDEOGRAPH
-0xEA52	0x9DBB	#CJK UNIFIED IDEOGRAPH
-0xEA53	0x9DB8	#CJK UNIFIED IDEOGRAPH
-0xEA54	0x9DBA	#CJK UNIFIED IDEOGRAPH
-0xEA55	0x9DC6	#CJK UNIFIED IDEOGRAPH
-0xEA56	0x9DCF	#CJK UNIFIED IDEOGRAPH
-0xEA57	0x9DC2	#CJK UNIFIED IDEOGRAPH
-0xEA58	0x9DD9	#CJK UNIFIED IDEOGRAPH
-0xEA59	0x9DD3	#CJK UNIFIED IDEOGRAPH
-0xEA5A	0x9DF8	#CJK UNIFIED IDEOGRAPH
-0xEA5B	0x9DE6	#CJK UNIFIED IDEOGRAPH
-0xEA5C	0x9DED	#CJK UNIFIED IDEOGRAPH
-0xEA5D	0x9DEF	#CJK UNIFIED IDEOGRAPH
-0xEA5E	0x9DFD	#CJK UNIFIED IDEOGRAPH
-0xEA5F	0x9E1A	#CJK UNIFIED IDEOGRAPH
-0xEA60	0x9E1B	#CJK UNIFIED IDEOGRAPH
-0xEA61	0x9E1E	#CJK UNIFIED IDEOGRAPH
-0xEA62	0x9E75	#CJK UNIFIED IDEOGRAPH
-0xEA63	0x9E79	#CJK UNIFIED IDEOGRAPH
-0xEA64	0x9E7D	#CJK UNIFIED IDEOGRAPH
-0xEA65	0x9E81	#CJK UNIFIED IDEOGRAPH
-0xEA66	0x9E88	#CJK UNIFIED IDEOGRAPH
-0xEA67	0x9E8B	#CJK UNIFIED IDEOGRAPH
-0xEA68	0x9E8C	#CJK UNIFIED IDEOGRAPH
-0xEA69	0x9E92	#CJK UNIFIED IDEOGRAPH
-0xEA6A	0x9E95	#CJK UNIFIED IDEOGRAPH
-0xEA6B	0x9E91	#CJK UNIFIED IDEOGRAPH
-0xEA6C	0x9E9D	#CJK UNIFIED IDEOGRAPH
-0xEA6D	0x9EA5	#CJK UNIFIED IDEOGRAPH
-0xEA6E	0x9EA9	#CJK UNIFIED IDEOGRAPH
-0xEA6F	0x9EB8	#CJK UNIFIED IDEOGRAPH
-0xEA70	0x9EAA	#CJK UNIFIED IDEOGRAPH
-0xEA71	0x9EAD	#CJK UNIFIED IDEOGRAPH
-0xEA72	0x9761	#CJK UNIFIED IDEOGRAPH
-0xEA73	0x9ECC	#CJK UNIFIED IDEOGRAPH
-0xEA74	0x9ECE	#CJK UNIFIED IDEOGRAPH
-0xEA75	0x9ECF	#CJK UNIFIED IDEOGRAPH
-0xEA76	0x9ED0	#CJK UNIFIED IDEOGRAPH
-0xEA77	0x9ED4	#CJK UNIFIED IDEOGRAPH
-0xEA78	0x9EDC	#CJK UNIFIED IDEOGRAPH
-0xEA79	0x9EDE	#CJK UNIFIED IDEOGRAPH
-0xEA7A	0x9EDD	#CJK UNIFIED IDEOGRAPH
-0xEA7B	0x9EE0	#CJK UNIFIED IDEOGRAPH
-0xEA7C	0x9EE5	#CJK UNIFIED IDEOGRAPH
-0xEA7D	0x9EE8	#CJK UNIFIED IDEOGRAPH
-0xEA7E	0x9EEF	#CJK UNIFIED IDEOGRAPH
-0xEA80	0x9EF4	#CJK UNIFIED IDEOGRAPH
-0xEA81	0x9EF6	#CJK UNIFIED IDEOGRAPH
-0xEA82	0x9EF7	#CJK UNIFIED IDEOGRAPH
-0xEA83	0x9EF9	#CJK UNIFIED IDEOGRAPH
-0xEA84	0x9EFB	#CJK UNIFIED IDEOGRAPH
-0xEA85	0x9EFC	#CJK UNIFIED IDEOGRAPH
-0xEA86	0x9EFD	#CJK UNIFIED IDEOGRAPH
-0xEA87	0x9F07	#CJK UNIFIED IDEOGRAPH
-0xEA88	0x9F08	#CJK UNIFIED IDEOGRAPH
-0xEA89	0x76B7	#CJK UNIFIED IDEOGRAPH
-0xEA8A	0x9F15	#CJK UNIFIED IDEOGRAPH
-0xEA8B	0x9F21	#CJK UNIFIED IDEOGRAPH
-0xEA8C	0x9F2C	#CJK UNIFIED IDEOGRAPH
-0xEA8D	0x9F3E	#CJK UNIFIED IDEOGRAPH
-0xEA8E	0x9F4A	#CJK UNIFIED IDEOGRAPH
-0xEA8F	0x9F52	#CJK UNIFIED IDEOGRAPH
-0xEA90	0x9F54	#CJK UNIFIED IDEOGRAPH
-0xEA91	0x9F63	#CJK UNIFIED IDEOGRAPH
-0xEA92	0x9F5F	#CJK UNIFIED IDEOGRAPH
-0xEA93	0x9F60	#CJK UNIFIED IDEOGRAPH
-0xEA94	0x9F61	#CJK UNIFIED IDEOGRAPH
-0xEA95	0x9F66	#CJK UNIFIED IDEOGRAPH
-0xEA96	0x9F67	#CJK UNIFIED IDEOGRAPH
-0xEA97	0x9F6C	#CJK UNIFIED IDEOGRAPH
-0xEA98	0x9F6A	#CJK UNIFIED IDEOGRAPH
-0xEA99	0x9F77	#CJK UNIFIED IDEOGRAPH
-0xEA9A	0x9F72	#CJK UNIFIED IDEOGRAPH
-0xEA9B	0x9F76	#CJK UNIFIED IDEOGRAPH
-0xEA9C	0x9F95	#CJK UNIFIED IDEOGRAPH
-0xEA9D	0x9F9C	#CJK UNIFIED IDEOGRAPH
-0xEA9E	0x9FA0	#CJK UNIFIED IDEOGRAPH
-0xEA9F	0x582F	#CJK UNIFIED IDEOGRAPH
-0xEAA0	0x69C7	#CJK UNIFIED IDEOGRAPH
-0xEAA1	0x9059	#CJK UNIFIED IDEOGRAPH
-0xEAA2	0x7464	#CJK UNIFIED IDEOGRAPH
-0xEAA3	0x51DC	#CJK UNIFIED IDEOGRAPH
-0xEAA4	0x7199	#CJK UNIFIED IDEOGRAPH
-0xED40	0x7E8A	#CJK UNIFIED IDEOGRAPH
-0xED41	0x891C	#CJK UNIFIED IDEOGRAPH
-0xED42	0x9348	#CJK UNIFIED IDEOGRAPH
-0xED43	0x9288	#CJK UNIFIED IDEOGRAPH
-0xED44	0x84DC	#CJK UNIFIED IDEOGRAPH
-0xED45	0x4FC9	#CJK UNIFIED IDEOGRAPH
-0xED46	0x70BB	#CJK UNIFIED IDEOGRAPH
-0xED47	0x6631	#CJK UNIFIED IDEOGRAPH
-0xED48	0x68C8	#CJK UNIFIED IDEOGRAPH
-0xED49	0x92F9	#CJK UNIFIED IDEOGRAPH
-0xED4A	0x66FB	#CJK UNIFIED IDEOGRAPH
-0xED4B	0x5F45	#CJK UNIFIED IDEOGRAPH
-0xED4C	0x4E28	#CJK UNIFIED IDEOGRAPH
-0xED4D	0x4EE1	#CJK UNIFIED IDEOGRAPH
-0xED4E	0x4EFC	#CJK UNIFIED IDEOGRAPH
-0xED4F	0x4F00	#CJK UNIFIED IDEOGRAPH
-0xED50	0x4F03	#CJK UNIFIED IDEOGRAPH
-0xED51	0x4F39	#CJK UNIFIED IDEOGRAPH
-0xED52	0x4F56	#CJK UNIFIED IDEOGRAPH
-0xED53	0x4F92	#CJK UNIFIED IDEOGRAPH
-0xED54	0x4F8A	#CJK UNIFIED IDEOGRAPH
-0xED55	0x4F9A	#CJK UNIFIED IDEOGRAPH
-0xED56	0x4F94	#CJK UNIFIED IDEOGRAPH
-0xED57	0x4FCD	#CJK UNIFIED IDEOGRAPH
-0xED58	0x5040	#CJK UNIFIED IDEOGRAPH
-0xED59	0x5022	#CJK UNIFIED IDEOGRAPH
-0xED5A	0x4FFF	#CJK UNIFIED IDEOGRAPH
-0xED5B	0x501E	#CJK UNIFIED IDEOGRAPH
-0xED5C	0x5046	#CJK UNIFIED IDEOGRAPH
-0xED5D	0x5070	#CJK UNIFIED IDEOGRAPH
-0xED5E	0x5042	#CJK UNIFIED IDEOGRAPH
-0xED5F	0x5094	#CJK UNIFIED IDEOGRAPH
-0xED60	0x50F4	#CJK UNIFIED IDEOGRAPH
-0xED61	0x50D8	#CJK UNIFIED IDEOGRAPH
-0xED62	0x514A	#CJK UNIFIED IDEOGRAPH
-0xED63	0x5164	#CJK UNIFIED IDEOGRAPH
-0xED64	0x519D	#CJK UNIFIED IDEOGRAPH
-0xED65	0x51BE	#CJK UNIFIED IDEOGRAPH
-0xED66	0x51EC	#CJK UNIFIED IDEOGRAPH
-0xED67	0x5215	#CJK UNIFIED IDEOGRAPH
-0xED68	0x529C	#CJK UNIFIED IDEOGRAPH
-0xED69	0x52A6	#CJK UNIFIED IDEOGRAPH
-0xED6A	0x52C0	#CJK UNIFIED IDEOGRAPH
-0xED6B	0x52DB	#CJK UNIFIED IDEOGRAPH
-0xED6C	0x5300	#CJK UNIFIED IDEOGRAPH
-0xED6D	0x5307	#CJK UNIFIED IDEOGRAPH
-0xED6E	0x5324	#CJK UNIFIED IDEOGRAPH
-0xED6F	0x5372	#CJK UNIFIED IDEOGRAPH
-0xED70	0x5393	#CJK UNIFIED IDEOGRAPH
-0xED71	0x53B2	#CJK UNIFIED IDEOGRAPH
-0xED72	0x53DD	#CJK UNIFIED IDEOGRAPH
-0xED73	0xFA0E	#CJK COMPATIBILITY IDEOGRAPH
-0xED74	0x549C	#CJK UNIFIED IDEOGRAPH
-0xED75	0x548A	#CJK UNIFIED IDEOGRAPH
-0xED76	0x54A9	#CJK UNIFIED IDEOGRAPH
-0xED77	0x54FF	#CJK UNIFIED IDEOGRAPH
-0xED78	0x5586	#CJK UNIFIED IDEOGRAPH
-0xED79	0x5759	#CJK UNIFIED IDEOGRAPH
-0xED7A	0x5765	#CJK UNIFIED IDEOGRAPH
-0xED7B	0x57AC	#CJK UNIFIED IDEOGRAPH
-0xED7C	0x57C8	#CJK UNIFIED IDEOGRAPH
-0xED7D	0x57C7	#CJK UNIFIED IDEOGRAPH
-0xED7E	0xFA0F	#CJK COMPATIBILITY IDEOGRAPH
-0xED80	0xFA10	#CJK COMPATIBILITY IDEOGRAPH
-0xED81	0x589E	#CJK UNIFIED IDEOGRAPH
-0xED82	0x58B2	#CJK UNIFIED IDEOGRAPH
-0xED83	0x590B	#CJK UNIFIED IDEOGRAPH
-0xED84	0x5953	#CJK UNIFIED IDEOGRAPH
-0xED85	0x595B	#CJK UNIFIED IDEOGRAPH
-0xED86	0x595D	#CJK UNIFIED IDEOGRAPH
-0xED87	0x5963	#CJK UNIFIED IDEOGRAPH
-0xED88	0x59A4	#CJK UNIFIED IDEOGRAPH
-0xED89	0x59BA	#CJK UNIFIED IDEOGRAPH
-0xED8A	0x5B56	#CJK UNIFIED IDEOGRAPH
-0xED8B	0x5BC0	#CJK UNIFIED IDEOGRAPH
-0xED8C	0x752F	#CJK UNIFIED IDEOGRAPH
-0xED8D	0x5BD8	#CJK UNIFIED IDEOGRAPH
-0xED8E	0x5BEC	#CJK UNIFIED IDEOGRAPH
-0xED8F	0x5C1E	#CJK UNIFIED IDEOGRAPH
-0xED90	0x5CA6	#CJK UNIFIED IDEOGRAPH
-0xED91	0x5CBA	#CJK UNIFIED IDEOGRAPH
-0xED92	0x5CF5	#CJK UNIFIED IDEOGRAPH
-0xED93	0x5D27	#CJK UNIFIED IDEOGRAPH
-0xED94	0x5D53	#CJK UNIFIED IDEOGRAPH
-0xED95	0xFA11	#CJK COMPATIBILITY IDEOGRAPH
-0xED96	0x5D42	#CJK UNIFIED IDEOGRAPH
-0xED97	0x5D6D	#CJK UNIFIED IDEOGRAPH
-0xED98	0x5DB8	#CJK UNIFIED IDEOGRAPH
-0xED99	0x5DB9	#CJK UNIFIED IDEOGRAPH
-0xED9A	0x5DD0	#CJK UNIFIED IDEOGRAPH
-0xED9B	0x5F21	#CJK UNIFIED IDEOGRAPH
-0xED9C	0x5F34	#CJK UNIFIED IDEOGRAPH
-0xED9D	0x5F67	#CJK UNIFIED IDEOGRAPH
-0xED9E	0x5FB7	#CJK UNIFIED IDEOGRAPH
-0xED9F	0x5FDE	#CJK UNIFIED IDEOGRAPH
-0xEDA0	0x605D	#CJK UNIFIED IDEOGRAPH
-0xEDA1	0x6085	#CJK UNIFIED IDEOGRAPH
-0xEDA2	0x608A	#CJK UNIFIED IDEOGRAPH
-0xEDA3	0x60DE	#CJK UNIFIED IDEOGRAPH
-0xEDA4	0x60D5	#CJK UNIFIED IDEOGRAPH
-0xEDA5	0x6120	#CJK UNIFIED IDEOGRAPH
-0xEDA6	0x60F2	#CJK UNIFIED IDEOGRAPH
-0xEDA7	0x6111	#CJK UNIFIED IDEOGRAPH
-0xEDA8	0x6137	#CJK UNIFIED IDEOGRAPH
-0xEDA9	0x6130	#CJK UNIFIED IDEOGRAPH
-0xEDAA	0x6198	#CJK UNIFIED IDEOGRAPH
-0xEDAB	0x6213	#CJK UNIFIED IDEOGRAPH
-0xEDAC	0x62A6	#CJK UNIFIED IDEOGRAPH
-0xEDAD	0x63F5	#CJK UNIFIED IDEOGRAPH
-0xEDAE	0x6460	#CJK UNIFIED IDEOGRAPH
-0xEDAF	0x649D	#CJK UNIFIED IDEOGRAPH
-0xEDB0	0x64CE	#CJK UNIFIED IDEOGRAPH
-0xEDB1	0x654E	#CJK UNIFIED IDEOGRAPH
-0xEDB2	0x6600	#CJK UNIFIED IDEOGRAPH
-0xEDB3	0x6615	#CJK UNIFIED IDEOGRAPH
-0xEDB4	0x663B	#CJK UNIFIED IDEOGRAPH
-0xEDB5	0x6609	#CJK UNIFIED IDEOGRAPH
-0xEDB6	0x662E	#CJK UNIFIED IDEOGRAPH
-0xEDB7	0x661E	#CJK UNIFIED IDEOGRAPH
-0xEDB8	0x6624	#CJK UNIFIED IDEOGRAPH
-0xEDB9	0x6665	#CJK UNIFIED IDEOGRAPH
-0xEDBA	0x6657	#CJK UNIFIED IDEOGRAPH
-0xEDBB	0x6659	#CJK UNIFIED IDEOGRAPH
-0xEDBC	0xFA12	#CJK COMPATIBILITY IDEOGRAPH
-0xEDBD	0x6673	#CJK UNIFIED IDEOGRAPH
-0xEDBE	0x6699	#CJK UNIFIED IDEOGRAPH
-0xEDBF	0x66A0	#CJK UNIFIED IDEOGRAPH
-0xEDC0	0x66B2	#CJK UNIFIED IDEOGRAPH
-0xEDC1	0x66BF	#CJK UNIFIED IDEOGRAPH
-0xEDC2	0x66FA	#CJK UNIFIED IDEOGRAPH
-0xEDC3	0x670E	#CJK UNIFIED IDEOGRAPH
-0xEDC4	0xF929	#CJK COMPATIBILITY IDEOGRAPH
-0xEDC5	0x6766	#CJK UNIFIED IDEOGRAPH
-0xEDC6	0x67BB	#CJK UNIFIED IDEOGRAPH
-0xEDC7	0x6852	#CJK UNIFIED IDEOGRAPH
-0xEDC8	0x67C0	#CJK UNIFIED IDEOGRAPH
-0xEDC9	0x6801	#CJK UNIFIED IDEOGRAPH
-0xEDCA	0x6844	#CJK UNIFIED IDEOGRAPH
-0xEDCB	0x68CF	#CJK UNIFIED IDEOGRAPH
-0xEDCC	0xFA13	#CJK COMPATIBILITY IDEOGRAPH
-0xEDCD	0x6968	#CJK UNIFIED IDEOGRAPH
-0xEDCE	0xFA14	#CJK COMPATIBILITY IDEOGRAPH
-0xEDCF	0x6998	#CJK UNIFIED IDEOGRAPH
-0xEDD0	0x69E2	#CJK UNIFIED IDEOGRAPH
-0xEDD1	0x6A30	#CJK UNIFIED IDEOGRAPH
-0xEDD2	0x6A6B	#CJK UNIFIED IDEOGRAPH
-0xEDD3	0x6A46	#CJK UNIFIED IDEOGRAPH
-0xEDD4	0x6A73	#CJK UNIFIED IDEOGRAPH
-0xEDD5	0x6A7E	#CJK UNIFIED IDEOGRAPH
-0xEDD6	0x6AE2	#CJK UNIFIED IDEOGRAPH
-0xEDD7	0x6AE4	#CJK UNIFIED IDEOGRAPH
-0xEDD8	0x6BD6	#CJK UNIFIED IDEOGRAPH
-0xEDD9	0x6C3F	#CJK UNIFIED IDEOGRAPH
-0xEDDA	0x6C5C	#CJK UNIFIED IDEOGRAPH
-0xEDDB	0x6C86	#CJK UNIFIED IDEOGRAPH
-0xEDDC	0x6C6F	#CJK UNIFIED IDEOGRAPH
-0xEDDD	0x6CDA	#CJK UNIFIED IDEOGRAPH
-0xEDDE	0x6D04	#CJK UNIFIED IDEOGRAPH
-0xEDDF	0x6D87	#CJK UNIFIED IDEOGRAPH
-0xEDE0	0x6D6F	#CJK UNIFIED IDEOGRAPH
-0xEDE1	0x6D96	#CJK UNIFIED IDEOGRAPH
-0xEDE2	0x6DAC	#CJK UNIFIED IDEOGRAPH
-0xEDE3	0x6DCF	#CJK UNIFIED IDEOGRAPH
-0xEDE4	0x6DF8	#CJK UNIFIED IDEOGRAPH
-0xEDE5	0x6DF2	#CJK UNIFIED IDEOGRAPH
-0xEDE6	0x6DFC	#CJK UNIFIED IDEOGRAPH
-0xEDE7	0x6E39	#CJK UNIFIED IDEOGRAPH
-0xEDE8	0x6E5C	#CJK UNIFIED IDEOGRAPH
-0xEDE9	0x6E27	#CJK UNIFIED IDEOGRAPH
-0xEDEA	0x6E3C	#CJK UNIFIED IDEOGRAPH
-0xEDEB	0x6EBF	#CJK UNIFIED IDEOGRAPH
-0xEDEC	0x6F88	#CJK UNIFIED IDEOGRAPH
-0xEDED	0x6FB5	#CJK UNIFIED IDEOGRAPH
-0xEDEE	0x6FF5	#CJK UNIFIED IDEOGRAPH
-0xEDEF	0x7005	#CJK UNIFIED IDEOGRAPH
-0xEDF0	0x7007	#CJK UNIFIED IDEOGRAPH
-0xEDF1	0x7028	#CJK UNIFIED IDEOGRAPH
-0xEDF2	0x7085	#CJK UNIFIED IDEOGRAPH
-0xEDF3	0x70AB	#CJK UNIFIED IDEOGRAPH
-0xEDF4	0x710F	#CJK UNIFIED IDEOGRAPH
-0xEDF5	0x7104	#CJK UNIFIED IDEOGRAPH
-0xEDF6	0x715C	#CJK UNIFIED IDEOGRAPH
-0xEDF7	0x7146	#CJK UNIFIED IDEOGRAPH
-0xEDF8	0x7147	#CJK UNIFIED IDEOGRAPH
-0xEDF9	0xFA15	#CJK COMPATIBILITY IDEOGRAPH
-0xEDFA	0x71C1	#CJK UNIFIED IDEOGRAPH
-0xEDFB	0x71FE	#CJK UNIFIED IDEOGRAPH
-0xEDFC	0x72B1	#CJK UNIFIED IDEOGRAPH
-0xEE40	0x72BE	#CJK UNIFIED IDEOGRAPH
-0xEE41	0x7324	#CJK UNIFIED IDEOGRAPH
-0xEE42	0xFA16	#CJK COMPATIBILITY IDEOGRAPH
-0xEE43	0x7377	#CJK UNIFIED IDEOGRAPH
-0xEE44	0x73BD	#CJK UNIFIED IDEOGRAPH
-0xEE45	0x73C9	#CJK UNIFIED IDEOGRAPH
-0xEE46	0x73D6	#CJK UNIFIED IDEOGRAPH
-0xEE47	0x73E3	#CJK UNIFIED IDEOGRAPH
-0xEE48	0x73D2	#CJK UNIFIED IDEOGRAPH
-0xEE49	0x7407	#CJK UNIFIED IDEOGRAPH
-0xEE4A	0x73F5	#CJK UNIFIED IDEOGRAPH
-0xEE4B	0x7426	#CJK UNIFIED IDEOGRAPH
-0xEE4C	0x742A	#CJK UNIFIED IDEOGRAPH
-0xEE4D	0x7429	#CJK UNIFIED IDEOGRAPH
-0xEE4E	0x742E	#CJK UNIFIED IDEOGRAPH
-0xEE4F	0x7462	#CJK UNIFIED IDEOGRAPH
-0xEE50	0x7489	#CJK UNIFIED IDEOGRAPH
-0xEE51	0x749F	#CJK UNIFIED IDEOGRAPH
-0xEE52	0x7501	#CJK UNIFIED IDEOGRAPH
-0xEE53	0x756F	#CJK UNIFIED IDEOGRAPH
-0xEE54	0x7682	#CJK UNIFIED IDEOGRAPH
-0xEE55	0x769C	#CJK UNIFIED IDEOGRAPH
-0xEE56	0x769E	#CJK UNIFIED IDEOGRAPH
-0xEE57	0x769B	#CJK UNIFIED IDEOGRAPH
-0xEE58	0x76A6	#CJK UNIFIED IDEOGRAPH
-0xEE59	0xFA17	#CJK COMPATIBILITY IDEOGRAPH
-0xEE5A	0x7746	#CJK UNIFIED IDEOGRAPH
-0xEE5B	0x52AF	#CJK UNIFIED IDEOGRAPH
-0xEE5C	0x7821	#CJK UNIFIED IDEOGRAPH
-0xEE5D	0x784E	#CJK UNIFIED IDEOGRAPH
-0xEE5E	0x7864	#CJK UNIFIED IDEOGRAPH
-0xEE5F	0x787A	#CJK UNIFIED IDEOGRAPH
-0xEE60	0x7930	#CJK UNIFIED IDEOGRAPH
-0xEE61	0xFA18	#CJK COMPATIBILITY IDEOGRAPH
-0xEE62	0xFA19	#CJK COMPATIBILITY IDEOGRAPH
-0xEE63	0xFA1A	#CJK COMPATIBILITY IDEOGRAPH
-0xEE64	0x7994	#CJK UNIFIED IDEOGRAPH
-0xEE65	0xFA1B	#CJK COMPATIBILITY IDEOGRAPH
-0xEE66	0x799B	#CJK UNIFIED IDEOGRAPH
-0xEE67	0x7AD1	#CJK UNIFIED IDEOGRAPH
-0xEE68	0x7AE7	#CJK UNIFIED IDEOGRAPH
-0xEE69	0xFA1C	#CJK COMPATIBILITY IDEOGRAPH
-0xEE6A	0x7AEB	#CJK UNIFIED IDEOGRAPH
-0xEE6B	0x7B9E	#CJK UNIFIED IDEOGRAPH
-0xEE6C	0xFA1D	#CJK COMPATIBILITY IDEOGRAPH
-0xEE6D	0x7D48	#CJK UNIFIED IDEOGRAPH
-0xEE6E	0x7D5C	#CJK UNIFIED IDEOGRAPH
-0xEE6F	0x7DB7	#CJK UNIFIED IDEOGRAPH
-0xEE70	0x7DA0	#CJK UNIFIED IDEOGRAPH
-0xEE71	0x7DD6	#CJK UNIFIED IDEOGRAPH
-0xEE72	0x7E52	#CJK UNIFIED IDEOGRAPH
-0xEE73	0x7F47	#CJK UNIFIED IDEOGRAPH
-0xEE74	0x7FA1	#CJK UNIFIED IDEOGRAPH
-0xEE75	0xFA1E	#CJK COMPATIBILITY IDEOGRAPH
-0xEE76	0x8301	#CJK UNIFIED IDEOGRAPH
-0xEE77	0x8362	#CJK UNIFIED IDEOGRAPH
-0xEE78	0x837F	#CJK UNIFIED IDEOGRAPH
-0xEE79	0x83C7	#CJK UNIFIED IDEOGRAPH
-0xEE7A	0x83F6	#CJK UNIFIED IDEOGRAPH
-0xEE7B	0x8448	#CJK UNIFIED IDEOGRAPH
-0xEE7C	0x84B4	#CJK UNIFIED IDEOGRAPH
-0xEE7D	0x8553	#CJK UNIFIED IDEOGRAPH
-0xEE7E	0x8559	#CJK UNIFIED IDEOGRAPH
-0xEE80	0x856B	#CJK UNIFIED IDEOGRAPH
-0xEE81	0xFA1F	#CJK COMPATIBILITY IDEOGRAPH
-0xEE82	0x85B0	#CJK UNIFIED IDEOGRAPH
-0xEE83	0xFA20	#CJK COMPATIBILITY IDEOGRAPH
-0xEE84	0xFA21	#CJK COMPATIBILITY IDEOGRAPH
-0xEE85	0x8807	#CJK UNIFIED IDEOGRAPH
-0xEE86	0x88F5	#CJK UNIFIED IDEOGRAPH
-0xEE87	0x8A12	#CJK UNIFIED IDEOGRAPH
-0xEE88	0x8A37	#CJK UNIFIED IDEOGRAPH
-0xEE89	0x8A79	#CJK UNIFIED IDEOGRAPH
-0xEE8A	0x8AA7	#CJK UNIFIED IDEOGRAPH
-0xEE8B	0x8ABE	#CJK UNIFIED IDEOGRAPH
-0xEE8C	0x8ADF	#CJK UNIFIED IDEOGRAPH
-0xEE8D	0xFA22	#CJK COMPATIBILITY IDEOGRAPH
-0xEE8E	0x8AF6	#CJK UNIFIED IDEOGRAPH
-0xEE8F	0x8B53	#CJK UNIFIED IDEOGRAPH
-0xEE90	0x8B7F	#CJK UNIFIED IDEOGRAPH
-0xEE91	0x8CF0	#CJK UNIFIED IDEOGRAPH
-0xEE92	0x8CF4	#CJK UNIFIED IDEOGRAPH
-0xEE93	0x8D12	#CJK UNIFIED IDEOGRAPH
-0xEE94	0x8D76	#CJK UNIFIED IDEOGRAPH
-0xEE95	0xFA23	#CJK COMPATIBILITY IDEOGRAPH
-0xEE96	0x8ECF	#CJK UNIFIED IDEOGRAPH
-0xEE97	0xFA24	#CJK COMPATIBILITY IDEOGRAPH
-0xEE98	0xFA25	#CJK COMPATIBILITY IDEOGRAPH
-0xEE99	0x9067	#CJK UNIFIED IDEOGRAPH
-0xEE9A	0x90DE	#CJK UNIFIED IDEOGRAPH
-0xEE9B	0xFA26	#CJK COMPATIBILITY IDEOGRAPH
-0xEE9C	0x9115	#CJK UNIFIED IDEOGRAPH
-0xEE9D	0x9127	#CJK UNIFIED IDEOGRAPH
-0xEE9E	0x91DA	#CJK UNIFIED IDEOGRAPH
-0xEE9F	0x91D7	#CJK UNIFIED IDEOGRAPH
-0xEEA0	0x91DE	#CJK UNIFIED IDEOGRAPH
-0xEEA1	0x91ED	#CJK UNIFIED IDEOGRAPH
-0xEEA2	0x91EE	#CJK UNIFIED IDEOGRAPH
-0xEEA3	0x91E4	#CJK UNIFIED IDEOGRAPH
-0xEEA4	0x91E5	#CJK UNIFIED IDEOGRAPH
-0xEEA5	0x9206	#CJK UNIFIED IDEOGRAPH
-0xEEA6	0x9210	#CJK UNIFIED IDEOGRAPH
-0xEEA7	0x920A	#CJK UNIFIED IDEOGRAPH
-0xEEA8	0x923A	#CJK UNIFIED IDEOGRAPH
-0xEEA9	0x9240	#CJK UNIFIED IDEOGRAPH
-0xEEAA	0x923C	#CJK UNIFIED IDEOGRAPH
-0xEEAB	0x924E	#CJK UNIFIED IDEOGRAPH
-0xEEAC	0x9259	#CJK UNIFIED IDEOGRAPH
-0xEEAD	0x9251	#CJK UNIFIED IDEOGRAPH
-0xEEAE	0x9239	#CJK UNIFIED IDEOGRAPH
-0xEEAF	0x9267	#CJK UNIFIED IDEOGRAPH
-0xEEB0	0x92A7	#CJK UNIFIED IDEOGRAPH
-0xEEB1	0x9277	#CJK UNIFIED IDEOGRAPH
-0xEEB2	0x9278	#CJK UNIFIED IDEOGRAPH
-0xEEB3	0x92E7	#CJK UNIFIED IDEOGRAPH
-0xEEB4	0x92D7	#CJK UNIFIED IDEOGRAPH
-0xEEB5	0x92D9	#CJK UNIFIED IDEOGRAPH
-0xEEB6	0x92D0	#CJK UNIFIED IDEOGRAPH
-0xEEB7	0xFA27	#CJK COMPATIBILITY IDEOGRAPH
-0xEEB8	0x92D5	#CJK UNIFIED IDEOGRAPH
-0xEEB9	0x92E0	#CJK UNIFIED IDEOGRAPH
-0xEEBA	0x92D3	#CJK UNIFIED IDEOGRAPH
-0xEEBB	0x9325	#CJK UNIFIED IDEOGRAPH
-0xEEBC	0x9321	#CJK UNIFIED IDEOGRAPH
-0xEEBD	0x92FB	#CJK UNIFIED IDEOGRAPH
-0xEEBE	0xFA28	#CJK COMPATIBILITY IDEOGRAPH
-0xEEBF	0x931E	#CJK UNIFIED IDEOGRAPH
-0xEEC0	0x92FF	#CJK UNIFIED IDEOGRAPH
-0xEEC1	0x931D	#CJK UNIFIED IDEOGRAPH
-0xEEC2	0x9302	#CJK UNIFIED IDEOGRAPH
-0xEEC3	0x9370	#CJK UNIFIED IDEOGRAPH
-0xEEC4	0x9357	#CJK UNIFIED IDEOGRAPH
-0xEEC5	0x93A4	#CJK UNIFIED IDEOGRAPH
-0xEEC6	0x93C6	#CJK UNIFIED IDEOGRAPH
-0xEEC7	0x93DE	#CJK UNIFIED IDEOGRAPH
-0xEEC8	0x93F8	#CJK UNIFIED IDEOGRAPH
-0xEEC9	0x9431	#CJK UNIFIED IDEOGRAPH
-0xEECA	0x9445	#CJK UNIFIED IDEOGRAPH
-0xEECB	0x9448	#CJK UNIFIED IDEOGRAPH
-0xEECC	0x9592	#CJK UNIFIED IDEOGRAPH
-0xEECD	0xF9DC	#CJK COMPATIBILITY IDEOGRAPH
-0xEECE	0xFA29	#CJK COMPATIBILITY IDEOGRAPH
-0xEECF	0x969D	#CJK UNIFIED IDEOGRAPH
-0xEED0	0x96AF	#CJK UNIFIED IDEOGRAPH
-0xEED1	0x9733	#CJK UNIFIED IDEOGRAPH
-0xEED2	0x973B	#CJK UNIFIED IDEOGRAPH
-0xEED3	0x9743	#CJK UNIFIED IDEOGRAPH
-0xEED4	0x974D	#CJK UNIFIED IDEOGRAPH
-0xEED5	0x974F	#CJK UNIFIED IDEOGRAPH
-0xEED6	0x9751	#CJK UNIFIED IDEOGRAPH
-0xEED7	0x9755	#CJK UNIFIED IDEOGRAPH
-0xEED8	0x9857	#CJK UNIFIED IDEOGRAPH
-0xEED9	0x9865	#CJK UNIFIED IDEOGRAPH
-0xEEDA	0xFA2A	#CJK COMPATIBILITY IDEOGRAPH
-0xEEDB	0xFA2B	#CJK COMPATIBILITY IDEOGRAPH
-0xEEDC	0x9927	#CJK UNIFIED IDEOGRAPH
-0xEEDD	0xFA2C	#CJK COMPATIBILITY IDEOGRAPH
-0xEEDE	0x999E	#CJK UNIFIED IDEOGRAPH
-0xEEDF	0x9A4E	#CJK UNIFIED IDEOGRAPH
-0xEEE0	0x9AD9	#CJK UNIFIED IDEOGRAPH
-0xEEE1	0x9ADC	#CJK UNIFIED IDEOGRAPH
-0xEEE2	0x9B75	#CJK UNIFIED IDEOGRAPH
-0xEEE3	0x9B72	#CJK UNIFIED IDEOGRAPH
-0xEEE4	0x9B8F	#CJK UNIFIED IDEOGRAPH
-0xEEE5	0x9BB1	#CJK UNIFIED IDEOGRAPH
-0xEEE6	0x9BBB	#CJK UNIFIED IDEOGRAPH
-0xEEE7	0x9C00	#CJK UNIFIED IDEOGRAPH
-0xEEE8	0x9D70	#CJK UNIFIED IDEOGRAPH
-0xEEE9	0x9D6B	#CJK UNIFIED IDEOGRAPH
-0xEEEA	0xFA2D	#CJK COMPATIBILITY IDEOGRAPH
-0xEEEB	0x9E19	#CJK UNIFIED IDEOGRAPH
-0xEEEC	0x9ED1	#CJK UNIFIED IDEOGRAPH
-0xEEEF	0x2170	#SMALL ROMAN NUMERAL ONE
-0xEEF0	0x2171	#SMALL ROMAN NUMERAL TWO
-0xEEF1	0x2172	#SMALL ROMAN NUMERAL THREE
-0xEEF2	0x2173	#SMALL ROMAN NUMERAL FOUR
-0xEEF3	0x2174	#SMALL ROMAN NUMERAL FIVE
-0xEEF4	0x2175	#SMALL ROMAN NUMERAL SIX
-0xEEF5	0x2176	#SMALL ROMAN NUMERAL SEVEN
-0xEEF6	0x2177	#SMALL ROMAN NUMERAL EIGHT
-0xEEF7	0x2178	#SMALL ROMAN NUMERAL NINE
-0xEEF8	0x2179	#SMALL ROMAN NUMERAL TEN
-0xEEF9	0xFFE2	#FULLWIDTH NOT SIGN
-0xEEFA	0xFFE4	#FULLWIDTH BROKEN BAR
-0xEEFB	0xFF07	#FULLWIDTH APOSTROPHE
-0xEEFC	0xFF02	#FULLWIDTH QUOTATION MARK
-0xFA40	0x2170	#SMALL ROMAN NUMERAL ONE
-0xFA41	0x2171	#SMALL ROMAN NUMERAL TWO
-0xFA42	0x2172	#SMALL ROMAN NUMERAL THREE
-0xFA43	0x2173	#SMALL ROMAN NUMERAL FOUR
-0xFA44	0x2174	#SMALL ROMAN NUMERAL FIVE
-0xFA45	0x2175	#SMALL ROMAN NUMERAL SIX
-0xFA46	0x2176	#SMALL ROMAN NUMERAL SEVEN
-0xFA47	0x2177	#SMALL ROMAN NUMERAL EIGHT
-0xFA48	0x2178	#SMALL ROMAN NUMERAL NINE
-0xFA49	0x2179	#SMALL ROMAN NUMERAL TEN
-0xFA4A	0x2160	#ROMAN NUMERAL ONE
-0xFA4B	0x2161	#ROMAN NUMERAL TWO
-0xFA4C	0x2162	#ROMAN NUMERAL THREE
-0xFA4D	0x2163	#ROMAN NUMERAL FOUR
-0xFA4E	0x2164	#ROMAN NUMERAL FIVE
-0xFA4F	0x2165	#ROMAN NUMERAL SIX
-0xFA50	0x2166	#ROMAN NUMERAL SEVEN
-0xFA51	0x2167	#ROMAN NUMERAL EIGHT
-0xFA52	0x2168	#ROMAN NUMERAL NINE
-0xFA53	0x2169	#ROMAN NUMERAL TEN
-0xFA54	0xFFE2	#FULLWIDTH NOT SIGN
-0xFA55	0xFFE4	#FULLWIDTH BROKEN BAR
-0xFA56	0xFF07	#FULLWIDTH APOSTROPHE
-0xFA57	0xFF02	#FULLWIDTH QUOTATION MARK
-0xFA58	0x3231	#PARENTHESIZED IDEOGRAPH STOCK
-0xFA59	0x2116	#NUMERO SIGN
-0xFA5A	0x2121	#TELEPHONE SIGN
-0xFA5B	0x2235	#BECAUSE
-0xFA5C	0x7E8A	#CJK UNIFIED IDEOGRAPH
-0xFA5D	0x891C	#CJK UNIFIED IDEOGRAPH
-0xFA5E	0x9348	#CJK UNIFIED IDEOGRAPH
-0xFA5F	0x9288	#CJK UNIFIED IDEOGRAPH
-0xFA60	0x84DC	#CJK UNIFIED IDEOGRAPH
-0xFA61	0x4FC9	#CJK UNIFIED IDEOGRAPH
-0xFA62	0x70BB	#CJK UNIFIED IDEOGRAPH
-0xFA63	0x6631	#CJK UNIFIED IDEOGRAPH
-0xFA64	0x68C8	#CJK UNIFIED IDEOGRAPH
-0xFA65	0x92F9	#CJK UNIFIED IDEOGRAPH
-0xFA66	0x66FB	#CJK UNIFIED IDEOGRAPH
-0xFA67	0x5F45	#CJK UNIFIED IDEOGRAPH
-0xFA68	0x4E28	#CJK UNIFIED IDEOGRAPH
-0xFA69	0x4EE1	#CJK UNIFIED IDEOGRAPH
-0xFA6A	0x4EFC	#CJK UNIFIED IDEOGRAPH
-0xFA6B	0x4F00	#CJK UNIFIED IDEOGRAPH
-0xFA6C	0x4F03	#CJK UNIFIED IDEOGRAPH
-0xFA6D	0x4F39	#CJK UNIFIED IDEOGRAPH
-0xFA6E	0x4F56	#CJK UNIFIED IDEOGRAPH
-0xFA6F	0x4F92	#CJK UNIFIED IDEOGRAPH
-0xFA70	0x4F8A	#CJK UNIFIED IDEOGRAPH
-0xFA71	0x4F9A	#CJK UNIFIED IDEOGRAPH
-0xFA72	0x4F94	#CJK UNIFIED IDEOGRAPH
-0xFA73	0x4FCD	#CJK UNIFIED IDEOGRAPH
-0xFA74	0x5040	#CJK UNIFIED IDEOGRAPH
-0xFA75	0x5022	#CJK UNIFIED IDEOGRAPH
-0xFA76	0x4FFF	#CJK UNIFIED IDEOGRAPH
-0xFA77	0x501E	#CJK UNIFIED IDEOGRAPH
-0xFA78	0x5046	#CJK UNIFIED IDEOGRAPH
-0xFA79	0x5070	#CJK UNIFIED IDEOGRAPH
-0xFA7A	0x5042	#CJK UNIFIED IDEOGRAPH
-0xFA7B	0x5094	#CJK UNIFIED IDEOGRAPH
-0xFA7C	0x50F4	#CJK UNIFIED IDEOGRAPH
-0xFA7D	0x50D8	#CJK UNIFIED IDEOGRAPH
-0xFA7E	0x514A	#CJK UNIFIED IDEOGRAPH
-0xFA80	0x5164	#CJK UNIFIED IDEOGRAPH
-0xFA81	0x519D	#CJK UNIFIED IDEOGRAPH
-0xFA82	0x51BE	#CJK UNIFIED IDEOGRAPH
-0xFA83	0x51EC	#CJK UNIFIED IDEOGRAPH
-0xFA84	0x5215	#CJK UNIFIED IDEOGRAPH
-0xFA85	0x529C	#CJK UNIFIED IDEOGRAPH
-0xFA86	0x52A6	#CJK UNIFIED IDEOGRAPH
-0xFA87	0x52C0	#CJK UNIFIED IDEOGRAPH
-0xFA88	0x52DB	#CJK UNIFIED IDEOGRAPH
-0xFA89	0x5300	#CJK UNIFIED IDEOGRAPH
-0xFA8A	0x5307	#CJK UNIFIED IDEOGRAPH
-0xFA8B	0x5324	#CJK UNIFIED IDEOGRAPH
-0xFA8C	0x5372	#CJK UNIFIED IDEOGRAPH
-0xFA8D	0x5393	#CJK UNIFIED IDEOGRAPH
-0xFA8E	0x53B2	#CJK UNIFIED IDEOGRAPH
-0xFA8F	0x53DD	#CJK UNIFIED IDEOGRAPH
-0xFA90	0xFA0E	#CJK COMPATIBILITY IDEOGRAPH
-0xFA91	0x549C	#CJK UNIFIED IDEOGRAPH
-0xFA92	0x548A	#CJK UNIFIED IDEOGRAPH
-0xFA93	0x54A9	#CJK UNIFIED IDEOGRAPH
-0xFA94	0x54FF	#CJK UNIFIED IDEOGRAPH
-0xFA95	0x5586	#CJK UNIFIED IDEOGRAPH
-0xFA96	0x5759	#CJK UNIFIED IDEOGRAPH
-0xFA97	0x5765	#CJK UNIFIED IDEOGRAPH
-0xFA98	0x57AC	#CJK UNIFIED IDEOGRAPH
-0xFA99	0x57C8	#CJK UNIFIED IDEOGRAPH
-0xFA9A	0x57C7	#CJK UNIFIED IDEOGRAPH
-0xFA9B	0xFA0F	#CJK COMPATIBILITY IDEOGRAPH
-0xFA9C	0xFA10	#CJK COMPATIBILITY IDEOGRAPH
-0xFA9D	0x589E	#CJK UNIFIED IDEOGRAPH
-0xFA9E	0x58B2	#CJK UNIFIED IDEOGRAPH
-0xFA9F	0x590B	#CJK UNIFIED IDEOGRAPH
-0xFAA0	0x5953	#CJK UNIFIED IDEOGRAPH
-0xFAA1	0x595B	#CJK UNIFIED IDEOGRAPH
-0xFAA2	0x595D	#CJK UNIFIED IDEOGRAPH
-0xFAA3	0x5963	#CJK UNIFIED IDEOGRAPH
-0xFAA4	0x59A4	#CJK UNIFIED IDEOGRAPH
-0xFAA5	0x59BA	#CJK UNIFIED IDEOGRAPH
-0xFAA6	0x5B56	#CJK UNIFIED IDEOGRAPH
-0xFAA7	0x5BC0	#CJK UNIFIED IDEOGRAPH
-0xFAA8	0x752F	#CJK UNIFIED IDEOGRAPH
-0xFAA9	0x5BD8	#CJK UNIFIED IDEOGRAPH
-0xFAAA	0x5BEC	#CJK UNIFIED IDEOGRAPH
-0xFAAB	0x5C1E	#CJK UNIFIED IDEOGRAPH
-0xFAAC	0x5CA6	#CJK UNIFIED IDEOGRAPH
-0xFAAD	0x5CBA	#CJK UNIFIED IDEOGRAPH
-0xFAAE	0x5CF5	#CJK UNIFIED IDEOGRAPH
-0xFAAF	0x5D27	#CJK UNIFIED IDEOGRAPH
-0xFAB0	0x5D53	#CJK UNIFIED IDEOGRAPH
-0xFAB1	0xFA11	#CJK COMPATIBILITY IDEOGRAPH
-0xFAB2	0x5D42	#CJK UNIFIED IDEOGRAPH
-0xFAB3	0x5D6D	#CJK UNIFIED IDEOGRAPH
-0xFAB4	0x5DB8	#CJK UNIFIED IDEOGRAPH
-0xFAB5	0x5DB9	#CJK UNIFIED IDEOGRAPH
-0xFAB6	0x5DD0	#CJK UNIFIED IDEOGRAPH
-0xFAB7	0x5F21	#CJK UNIFIED IDEOGRAPH
-0xFAB8	0x5F34	#CJK UNIFIED IDEOGRAPH
-0xFAB9	0x5F67	#CJK UNIFIED IDEOGRAPH
-0xFABA	0x5FB7	#CJK UNIFIED IDEOGRAPH
-0xFABB	0x5FDE	#CJK UNIFIED IDEOGRAPH
-0xFABC	0x605D	#CJK UNIFIED IDEOGRAPH
-0xFABD	0x6085	#CJK UNIFIED IDEOGRAPH
-0xFABE	0x608A	#CJK UNIFIED IDEOGRAPH
-0xFABF	0x60DE	#CJK UNIFIED IDEOGRAPH
-0xFAC0	0x60D5	#CJK UNIFIED IDEOGRAPH
-0xFAC1	0x6120	#CJK UNIFIED IDEOGRAPH
-0xFAC2	0x60F2	#CJK UNIFIED IDEOGRAPH
-0xFAC3	0x6111	#CJK UNIFIED IDEOGRAPH
-0xFAC4	0x6137	#CJK UNIFIED IDEOGRAPH
-0xFAC5	0x6130	#CJK UNIFIED IDEOGRAPH
-0xFAC6	0x6198	#CJK UNIFIED IDEOGRAPH
-0xFAC7	0x6213	#CJK UNIFIED IDEOGRAPH
-0xFAC8	0x62A6	#CJK UNIFIED IDEOGRAPH
-0xFAC9	0x63F5	#CJK UNIFIED IDEOGRAPH
-0xFACA	0x6460	#CJK UNIFIED IDEOGRAPH
-0xFACB	0x649D	#CJK UNIFIED IDEOGRAPH
-0xFACC	0x64CE	#CJK UNIFIED IDEOGRAPH
-0xFACD	0x654E	#CJK UNIFIED IDEOGRAPH
-0xFACE	0x6600	#CJK UNIFIED IDEOGRAPH
-0xFACF	0x6615	#CJK UNIFIED IDEOGRAPH
-0xFAD0	0x663B	#CJK UNIFIED IDEOGRAPH
-0xFAD1	0x6609	#CJK UNIFIED IDEOGRAPH
-0xFAD2	0x662E	#CJK UNIFIED IDEOGRAPH
-0xFAD3	0x661E	#CJK UNIFIED IDEOGRAPH
-0xFAD4	0x6624	#CJK UNIFIED IDEOGRAPH
-0xFAD5	0x6665	#CJK UNIFIED IDEOGRAPH
-0xFAD6	0x6657	#CJK UNIFIED IDEOGRAPH
-0xFAD7	0x6659	#CJK UNIFIED IDEOGRAPH
-0xFAD8	0xFA12	#CJK COMPATIBILITY IDEOGRAPH
-0xFAD9	0x6673	#CJK UNIFIED IDEOGRAPH
-0xFADA	0x6699	#CJK UNIFIED IDEOGRAPH
-0xFADB	0x66A0	#CJK UNIFIED IDEOGRAPH
-0xFADC	0x66B2	#CJK UNIFIED IDEOGRAPH
-0xFADD	0x66BF	#CJK UNIFIED IDEOGRAPH
-0xFADE	0x66FA	#CJK UNIFIED IDEOGRAPH
-0xFADF	0x670E	#CJK UNIFIED IDEOGRAPH
-0xFAE0	0xF929	#CJK COMPATIBILITY IDEOGRAPH
-0xFAE1	0x6766	#CJK UNIFIED IDEOGRAPH
-0xFAE2	0x67BB	#CJK UNIFIED IDEOGRAPH
-0xFAE3	0x6852	#CJK UNIFIED IDEOGRAPH
-0xFAE4	0x67C0	#CJK UNIFIED IDEOGRAPH
-0xFAE5	0x6801	#CJK UNIFIED IDEOGRAPH
-0xFAE6	0x6844	#CJK UNIFIED IDEOGRAPH
-0xFAE7	0x68CF	#CJK UNIFIED IDEOGRAPH
-0xFAE8	0xFA13	#CJK COMPATIBILITY IDEOGRAPH
-0xFAE9	0x6968	#CJK UNIFIED IDEOGRAPH
-0xFAEA	0xFA14	#CJK COMPATIBILITY IDEOGRAPH
-0xFAEB	0x6998	#CJK UNIFIED IDEOGRAPH
-0xFAEC	0x69E2	#CJK UNIFIED IDEOGRAPH
-0xFAED	0x6A30	#CJK UNIFIED IDEOGRAPH
-0xFAEE	0x6A6B	#CJK UNIFIED IDEOGRAPH
-0xFAEF	0x6A46	#CJK UNIFIED IDEOGRAPH
-0xFAF0	0x6A73	#CJK UNIFIED IDEOGRAPH
-0xFAF1	0x6A7E	#CJK UNIFIED IDEOGRAPH
-0xFAF2	0x6AE2	#CJK UNIFIED IDEOGRAPH
-0xFAF3	0x6AE4	#CJK UNIFIED IDEOGRAPH
-0xFAF4	0x6BD6	#CJK UNIFIED IDEOGRAPH
-0xFAF5	0x6C3F	#CJK UNIFIED IDEOGRAPH
-0xFAF6	0x6C5C	#CJK UNIFIED IDEOGRAPH
-0xFAF7	0x6C86	#CJK UNIFIED IDEOGRAPH
-0xFAF8	0x6C6F	#CJK UNIFIED IDEOGRAPH
-0xFAF9	0x6CDA	#CJK UNIFIED IDEOGRAPH
-0xFAFA	0x6D04	#CJK UNIFIED IDEOGRAPH
-0xFAFB	0x6D87	#CJK UNIFIED IDEOGRAPH
-0xFAFC	0x6D6F	#CJK UNIFIED IDEOGRAPH
-0xFB40	0x6D96	#CJK UNIFIED IDEOGRAPH
-0xFB41	0x6DAC	#CJK UNIFIED IDEOGRAPH
-0xFB42	0x6DCF	#CJK UNIFIED IDEOGRAPH
-0xFB43	0x6DF8	#CJK UNIFIED IDEOGRAPH
-0xFB44	0x6DF2	#CJK UNIFIED IDEOGRAPH
-0xFB45	0x6DFC	#CJK UNIFIED IDEOGRAPH
-0xFB46	0x6E39	#CJK UNIFIED IDEOGRAPH
-0xFB47	0x6E5C	#CJK UNIFIED IDEOGRAPH
-0xFB48	0x6E27	#CJK UNIFIED IDEOGRAPH
-0xFB49	0x6E3C	#CJK UNIFIED IDEOGRAPH
-0xFB4A	0x6EBF	#CJK UNIFIED IDEOGRAPH
-0xFB4B	0x6F88	#CJK UNIFIED IDEOGRAPH
-0xFB4C	0x6FB5	#CJK UNIFIED IDEOGRAPH
-0xFB4D	0x6FF5	#CJK UNIFIED IDEOGRAPH
-0xFB4E	0x7005	#CJK UNIFIED IDEOGRAPH
-0xFB4F	0x7007	#CJK UNIFIED IDEOGRAPH
-0xFB50	0x7028	#CJK UNIFIED IDEOGRAPH
-0xFB51	0x7085	#CJK UNIFIED IDEOGRAPH
-0xFB52	0x70AB	#CJK UNIFIED IDEOGRAPH
-0xFB53	0x710F	#CJK UNIFIED IDEOGRAPH
-0xFB54	0x7104	#CJK UNIFIED IDEOGRAPH
-0xFB55	0x715C	#CJK UNIFIED IDEOGRAPH
-0xFB56	0x7146	#CJK UNIFIED IDEOGRAPH
-0xFB57	0x7147	#CJK UNIFIED IDEOGRAPH
-0xFB58	0xFA15	#CJK COMPATIBILITY IDEOGRAPH
-0xFB59	0x71C1	#CJK UNIFIED IDEOGRAPH
-0xFB5A	0x71FE	#CJK UNIFIED IDEOGRAPH
-0xFB5B	0x72B1	#CJK UNIFIED IDEOGRAPH
-0xFB5C	0x72BE	#CJK UNIFIED IDEOGRAPH
-0xFB5D	0x7324	#CJK UNIFIED IDEOGRAPH
-0xFB5E	0xFA16	#CJK COMPATIBILITY IDEOGRAPH
-0xFB5F	0x7377	#CJK UNIFIED IDEOGRAPH
-0xFB60	0x73BD	#CJK UNIFIED IDEOGRAPH
-0xFB61	0x73C9	#CJK UNIFIED IDEOGRAPH
-0xFB62	0x73D6	#CJK UNIFIED IDEOGRAPH
-0xFB63	0x73E3	#CJK UNIFIED IDEOGRAPH
-0xFB64	0x73D2	#CJK UNIFIED IDEOGRAPH
-0xFB65	0x7407	#CJK UNIFIED IDEOGRAPH
-0xFB66	0x73F5	#CJK UNIFIED IDEOGRAPH
-0xFB67	0x7426	#CJK UNIFIED IDEOGRAPH
-0xFB68	0x742A	#CJK UNIFIED IDEOGRAPH
-0xFB69	0x7429	#CJK UNIFIED IDEOGRAPH
-0xFB6A	0x742E	#CJK UNIFIED IDEOGRAPH
-0xFB6B	0x7462	#CJK UNIFIED IDEOGRAPH
-0xFB6C	0x7489	#CJK UNIFIED IDEOGRAPH
-0xFB6D	0x749F	#CJK UNIFIED IDEOGRAPH
-0xFB6E	0x7501	#CJK UNIFIED IDEOGRAPH
-0xFB6F	0x756F	#CJK UNIFIED IDEOGRAPH
-0xFB70	0x7682	#CJK UNIFIED IDEOGRAPH
-0xFB71	0x769C	#CJK UNIFIED IDEOGRAPH
-0xFB72	0x769E	#CJK UNIFIED IDEOGRAPH
-0xFB73	0x769B	#CJK UNIFIED IDEOGRAPH
-0xFB74	0x76A6	#CJK UNIFIED IDEOGRAPH
-0xFB75	0xFA17	#CJK COMPATIBILITY IDEOGRAPH
-0xFB76	0x7746	#CJK UNIFIED IDEOGRAPH
-0xFB77	0x52AF	#CJK UNIFIED IDEOGRAPH
-0xFB78	0x7821	#CJK UNIFIED IDEOGRAPH
-0xFB79	0x784E	#CJK UNIFIED IDEOGRAPH
-0xFB7A	0x7864	#CJK UNIFIED IDEOGRAPH
-0xFB7B	0x787A	#CJK UNIFIED IDEOGRAPH
-0xFB7C	0x7930	#CJK UNIFIED IDEOGRAPH
-0xFB7D	0xFA18	#CJK COMPATIBILITY IDEOGRAPH
-0xFB7E	0xFA19	#CJK COMPATIBILITY IDEOGRAPH
-0xFB80	0xFA1A	#CJK COMPATIBILITY IDEOGRAPH
-0xFB81	0x7994	#CJK UNIFIED IDEOGRAPH
-0xFB82	0xFA1B	#CJK COMPATIBILITY IDEOGRAPH
-0xFB83	0x799B	#CJK UNIFIED IDEOGRAPH
-0xFB84	0x7AD1	#CJK UNIFIED IDEOGRAPH
-0xFB85	0x7AE7	#CJK UNIFIED IDEOGRAPH
-0xFB86	0xFA1C	#CJK COMPATIBILITY IDEOGRAPH
-0xFB87	0x7AEB	#CJK UNIFIED IDEOGRAPH
-0xFB88	0x7B9E	#CJK UNIFIED IDEOGRAPH
-0xFB89	0xFA1D	#CJK COMPATIBILITY IDEOGRAPH
-0xFB8A	0x7D48	#CJK UNIFIED IDEOGRAPH
-0xFB8B	0x7D5C	#CJK UNIFIED IDEOGRAPH
-0xFB8C	0x7DB7	#CJK UNIFIED IDEOGRAPH
-0xFB8D	0x7DA0	#CJK UNIFIED IDEOGRAPH
-0xFB8E	0x7DD6	#CJK UNIFIED IDEOGRAPH
-0xFB8F	0x7E52	#CJK UNIFIED IDEOGRAPH
-0xFB90	0x7F47	#CJK UNIFIED IDEOGRAPH
-0xFB91	0x7FA1	#CJK UNIFIED IDEOGRAPH
-0xFB92	0xFA1E	#CJK COMPATIBILITY IDEOGRAPH
-0xFB93	0x8301	#CJK UNIFIED IDEOGRAPH
-0xFB94	0x8362	#CJK UNIFIED IDEOGRAPH
-0xFB95	0x837F	#CJK UNIFIED IDEOGRAPH
-0xFB96	0x83C7	#CJK UNIFIED IDEOGRAPH
-0xFB97	0x83F6	#CJK UNIFIED IDEOGRAPH
-0xFB98	0x8448	#CJK UNIFIED IDEOGRAPH
-0xFB99	0x84B4	#CJK UNIFIED IDEOGRAPH
-0xFB9A	0x8553	#CJK UNIFIED IDEOGRAPH
-0xFB9B	0x8559	#CJK UNIFIED IDEOGRAPH
-0xFB9C	0x856B	#CJK UNIFIED IDEOGRAPH
-0xFB9D	0xFA1F	#CJK COMPATIBILITY IDEOGRAPH
-0xFB9E	0x85B0	#CJK UNIFIED IDEOGRAPH
-0xFB9F	0xFA20	#CJK COMPATIBILITY IDEOGRAPH
-0xFBA0	0xFA21	#CJK COMPATIBILITY IDEOGRAPH
-0xFBA1	0x8807	#CJK UNIFIED IDEOGRAPH
-0xFBA2	0x88F5	#CJK UNIFIED IDEOGRAPH
-0xFBA3	0x8A12	#CJK UNIFIED IDEOGRAPH
-0xFBA4	0x8A37	#CJK UNIFIED IDEOGRAPH
-0xFBA5	0x8A79	#CJK UNIFIED IDEOGRAPH
-0xFBA6	0x8AA7	#CJK UNIFIED IDEOGRAPH
-0xFBA7	0x8ABE	#CJK UNIFIED IDEOGRAPH
-0xFBA8	0x8ADF	#CJK UNIFIED IDEOGRAPH
-0xFBA9	0xFA22	#CJK COMPATIBILITY IDEOGRAPH
-0xFBAA	0x8AF6	#CJK UNIFIED IDEOGRAPH
-0xFBAB	0x8B53	#CJK UNIFIED IDEOGRAPH
-0xFBAC	0x8B7F	#CJK UNIFIED IDEOGRAPH
-0xFBAD	0x8CF0	#CJK UNIFIED IDEOGRAPH
-0xFBAE	0x8CF4	#CJK UNIFIED IDEOGRAPH
-0xFBAF	0x8D12	#CJK UNIFIED IDEOGRAPH
-0xFBB0	0x8D76	#CJK UNIFIED IDEOGRAPH
-0xFBB1	0xFA23	#CJK COMPATIBILITY IDEOGRAPH
-0xFBB2	0x8ECF	#CJK UNIFIED IDEOGRAPH
-0xFBB3	0xFA24	#CJK COMPATIBILITY IDEOGRAPH
-0xFBB4	0xFA25	#CJK COMPATIBILITY IDEOGRAPH
-0xFBB5	0x9067	#CJK UNIFIED IDEOGRAPH
-0xFBB6	0x90DE	#CJK UNIFIED IDEOGRAPH
-0xFBB7	0xFA26	#CJK COMPATIBILITY IDEOGRAPH
-0xFBB8	0x9115	#CJK UNIFIED IDEOGRAPH
-0xFBB9	0x9127	#CJK UNIFIED IDEOGRAPH
-0xFBBA	0x91DA	#CJK UNIFIED IDEOGRAPH
-0xFBBB	0x91D7	#CJK UNIFIED IDEOGRAPH
-0xFBBC	0x91DE	#CJK UNIFIED IDEOGRAPH
-0xFBBD	0x91ED	#CJK UNIFIED IDEOGRAPH
-0xFBBE	0x91EE	#CJK UNIFIED IDEOGRAPH
-0xFBBF	0x91E4	#CJK UNIFIED IDEOGRAPH
-0xFBC0	0x91E5	#CJK UNIFIED IDEOGRAPH
-0xFBC1	0x9206	#CJK UNIFIED IDEOGRAPH
-0xFBC2	0x9210	#CJK UNIFIED IDEOGRAPH
-0xFBC3	0x920A	#CJK UNIFIED IDEOGRAPH
-0xFBC4	0x923A	#CJK UNIFIED IDEOGRAPH
-0xFBC5	0x9240	#CJK UNIFIED IDEOGRAPH
-0xFBC6	0x923C	#CJK UNIFIED IDEOGRAPH
-0xFBC7	0x924E	#CJK UNIFIED IDEOGRAPH
-0xFBC8	0x9259	#CJK UNIFIED IDEOGRAPH
-0xFBC9	0x9251	#CJK UNIFIED IDEOGRAPH
-0xFBCA	0x9239	#CJK UNIFIED IDEOGRAPH
-0xFBCB	0x9267	#CJK UNIFIED IDEOGRAPH
-0xFBCC	0x92A7	#CJK UNIFIED IDEOGRAPH
-0xFBCD	0x9277	#CJK UNIFIED IDEOGRAPH
-0xFBCE	0x9278	#CJK UNIFIED IDEOGRAPH
-0xFBCF	0x92E7	#CJK UNIFIED IDEOGRAPH
-0xFBD0	0x92D7	#CJK UNIFIED IDEOGRAPH
-0xFBD1	0x92D9	#CJK UNIFIED IDEOGRAPH
-0xFBD2	0x92D0	#CJK UNIFIED IDEOGRAPH
-0xFBD3	0xFA27	#CJK COMPATIBILITY IDEOGRAPH
-0xFBD4	0x92D5	#CJK UNIFIED IDEOGRAPH
-0xFBD5	0x92E0	#CJK UNIFIED IDEOGRAPH
-0xFBD6	0x92D3	#CJK UNIFIED IDEOGRAPH
-0xFBD7	0x9325	#CJK UNIFIED IDEOGRAPH
-0xFBD8	0x9321	#CJK UNIFIED IDEOGRAPH
-0xFBD9	0x92FB	#CJK UNIFIED IDEOGRAPH
-0xFBDA	0xFA28	#CJK COMPATIBILITY IDEOGRAPH
-0xFBDB	0x931E	#CJK UNIFIED IDEOGRAPH
-0xFBDC	0x92FF	#CJK UNIFIED IDEOGRAPH
-0xFBDD	0x931D	#CJK UNIFIED IDEOGRAPH
-0xFBDE	0x9302	#CJK UNIFIED IDEOGRAPH
-0xFBDF	0x9370	#CJK UNIFIED IDEOGRAPH
-0xFBE0	0x9357	#CJK UNIFIED IDEOGRAPH
-0xFBE1	0x93A4	#CJK UNIFIED IDEOGRAPH
-0xFBE2	0x93C6	#CJK UNIFIED IDEOGRAPH
-0xFBE3	0x93DE	#CJK UNIFIED IDEOGRAPH
-0xFBE4	0x93F8	#CJK UNIFIED IDEOGRAPH
-0xFBE5	0x9431	#CJK UNIFIED IDEOGRAPH
-0xFBE6	0x9445	#CJK UNIFIED IDEOGRAPH
-0xFBE7	0x9448	#CJK UNIFIED IDEOGRAPH
-0xFBE8	0x9592	#CJK UNIFIED IDEOGRAPH
-0xFBE9	0xF9DC	#CJK COMPATIBILITY IDEOGRAPH
-0xFBEA	0xFA29	#CJK COMPATIBILITY IDEOGRAPH
-0xFBEB	0x969D	#CJK UNIFIED IDEOGRAPH
-0xFBEC	0x96AF	#CJK UNIFIED IDEOGRAPH
-0xFBED	0x9733	#CJK UNIFIED IDEOGRAPH
-0xFBEE	0x973B	#CJK UNIFIED IDEOGRAPH
-0xFBEF	0x9743	#CJK UNIFIED IDEOGRAPH
-0xFBF0	0x974D	#CJK UNIFIED IDEOGRAPH
-0xFBF1	0x974F	#CJK UNIFIED IDEOGRAPH
-0xFBF2	0x9751	#CJK UNIFIED IDEOGRAPH
-0xFBF3	0x9755	#CJK UNIFIED IDEOGRAPH
-0xFBF4	0x9857	#CJK UNIFIED IDEOGRAPH
-0xFBF5	0x9865	#CJK UNIFIED IDEOGRAPH
-0xFBF6	0xFA2A	#CJK COMPATIBILITY IDEOGRAPH
-0xFBF7	0xFA2B	#CJK COMPATIBILITY IDEOGRAPH
-0xFBF8	0x9927	#CJK UNIFIED IDEOGRAPH
-0xFBF9	0xFA2C	#CJK COMPATIBILITY IDEOGRAPH
-0xFBFA	0x999E	#CJK UNIFIED IDEOGRAPH
-0xFBFB	0x9A4E	#CJK UNIFIED IDEOGRAPH
-0xFBFC	0x9AD9	#CJK UNIFIED IDEOGRAPH
-0xFC40	0x9ADC	#CJK UNIFIED IDEOGRAPH
-0xFC41	0x9B75	#CJK UNIFIED IDEOGRAPH
-0xFC42	0x9B72	#CJK UNIFIED IDEOGRAPH
-0xFC43	0x9B8F	#CJK UNIFIED IDEOGRAPH
-0xFC44	0x9BB1	#CJK UNIFIED IDEOGRAPH
-0xFC45	0x9BBB	#CJK UNIFIED IDEOGRAPH
-0xFC46	0x9C00	#CJK UNIFIED IDEOGRAPH
-0xFC47	0x9D70	#CJK UNIFIED IDEOGRAPH
-0xFC48	0x9D6B	#CJK UNIFIED IDEOGRAPH
-0xFC49	0xFA2D	#CJK COMPATIBILITY IDEOGRAPH
-0xFC4A	0x9E19	#CJK UNIFIED IDEOGRAPH
-0xFC4B	0x9ED1	#CJK UNIFIED IDEOGRAPH
diff --git a/lib/windows/mmsystem.nim b/lib/windows/mmsystem.nim
deleted file mode 100755
index c7dd5b1be..000000000
--- a/lib/windows/mmsystem.nim
+++ /dev/null
@@ -1,2655 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-#*********************************
-#*******************************
-# Generated by c2pas32  v0.9b
-#     Fixed by P.V.Ozerski
-# (c) 2001 Oleg Bulychov
-#     Original C header file
-# Gladiators Software
-#     (created at Dec-03-1998)
-# http://www.astonshell.com/
-#   from LCC-win32 is used
-#*********************************
-#   LCC-win32 (c) Jacob Navia
-#*******************************
-
-{.deadCodeElim: on.}
-
-import
-  windows
-
-type
-  MMRESULT* = UINT
-  MMVERSION* = UINT
-  HWAVEOUT* = THandle
-  LPHWAVEOUT* = ptr HWAVEOUT
-  HWAVEIN* = THandle
-  LPHWAVEIN* = ptr HWAVEOUT
-  HWAVE* = THandle
-  LPHWAVE* = ptr THandle
-  LPUINT* = ptr UINT
-
-const
-  MAXPNAMELEN* = 32
-  MAXERRORLENGTH* = 256
-  MAX_JOYSTICKOEMVXDNAME* = 260
-  MM_MIDI_MAPPER* = 1
-  MM_WAVE_MAPPER* = 2
-  MM_SNDBLST_MIDIOUT* = 3
-  MM_SNDBLST_MIDIIN* = 4
-  MM_SNDBLST_SYNTH* = 5
-  MM_SNDBLST_WAVEOUT* = 6
-  MM_SNDBLST_WAVEIN* = 7
-  MM_ADLIB* = 9
-  MM_MPU401_MIDIOUT* = 10
-  MM_MPU401_MIDIIN* = 11
-  MM_PC_JOYSTICK* = 12
-  TIME_MS* = 1
-  TIME_SAMPLES* = 2
-  TIME_BYTES* = 4
-  TIME_SMPTE* = 8
-  TIME_MIDI* = 16
-  TIME_TICKS* = 32
-  MM_MCINOTIFY* = 0x000003B9
-  MM_WOM_OPEN* = 0x000003BB
-  MM_WOM_CLOSE* = 0x000003BC
-  MM_WOM_DONE* = 0x000003BD
-  MM_WIM_OPEN* = 0x000003BE
-  MM_WIM_CLOSE* = 0x000003BF
-  MM_WIM_DATA* = 0x000003C0
-  MM_MIM_OPEN* = 0x000003C1
-  MM_MIM_CLOSE* = 0x000003C2
-  MM_MIM_DATA* = 0x000003C3
-  MM_MIM_LONGDATA* = 0x000003C4
-  MM_MIM_ERROR* = 0x000003C5
-  MM_MIM_LONGERROR* = 0x000003C6
-  MM_MOM_OPEN* = 0x000003C7
-  MM_MOM_CLOSE* = 0x000003C8
-  MM_MOM_DONE* = 0x000003C9
-  MM_DRVM_OPEN* = 0x000003D0
-  MM_DRVM_CLOSE* = 0x000003D1
-  MM_DRVM_DATA* = 0x000003D2
-  MM_DRVM_ERROR* = 0x000003D3
-  MM_STREAM_OPEN* = 0x000003D4
-  MM_STREAM_CLOSE* = 0x000003D5
-  MM_STREAM_DONE* = 0x000003D6
-  MM_STREAM_ERROR* = 0x000003D7
-  MM_MOM_POSITIONCB* = 0x000003CA
-  MM_MCISIGNAL* = 0x000003CB
-  WAVE_INVALIDFORMAT* = 0
-  WAVE_FORMAT_1M08* = 1
-  WAVE_FORMAT_1S08* = 2
-  WAVE_FORMAT_1M16* = 4
-  WAVE_FORMAT_1S16* = 8
-  WAVE_FORMAT_2M08* = 16
-  WAVE_FORMAT_2S08* = 32
-  WAVE_FORMAT_2M16* = 64
-  WAVE_FORMAT_2S16* = 128
-  WAVE_FORMAT_4M08* = 256
-  WAVE_FORMAT_4S08* = 512
-  WAVE_FORMAT_4M16* = 0x00000400
-  WAVE_FORMAT_4S16* = 0x00000800
-  MM_MIM_MOREDATA* = 0x000003CC
-  MM_MIXM_LINE_CHANGE* = 0x000003D0
-  MM_MIXM_CONTROL_CHANGE* = 0x000003D1
-  MMSYSERR_BASE* = 0
-  WAVERR_BASE* = 32
-  MIDIERR_BASE* = 64
-  TIMERR_BASE* = 96
-  JOYERR_BASE* = 160
-  MCIERR_BASE* = 256
-  MIXERR_BASE* = 1024
-  MCI_STRING_OFFSET* = 512
-  MCI_VD_OFFSET* = 1024
-  MCI_CD_OFFSET* = 1088
-  MCI_WAVE_OFFSET* = 1152
-  MCI_SEQ_OFFSET* = 1216
-  MMSYSERR_NOERROR* = 0
-  MMSYSERR_ERROR* = (MMSYSERR_BASE + 1)
-  MMSYSERR_BADDEVICEID* = (MMSYSERR_BASE + 2)
-  MMSYSERR_NOTENABLED* = (MMSYSERR_BASE + 3)
-  MMSYSERR_ALLOCATED* = (MMSYSERR_BASE + 4)
-  MMSYSERR_INVALHANDLE* = (MMSYSERR_BASE + 5)
-  MMSYSERR_NODRIVER* = (MMSYSERR_BASE + 6)
-  MMSYSERR_NOMEM* = (MMSYSERR_BASE + 7)
-  MMSYSERR_NOTSUPPORTED* = (MMSYSERR_BASE + 8)
-  MMSYSERR_BADERRNUM* = (MMSYSERR_BASE + 9)
-  MMSYSERR_INVALFLAG* = (MMSYSERR_BASE + 10)
-  MMSYSERR_INVALPARAM* = (MMSYSERR_BASE + 11)
-  MMSYSERR_HANDLEBUSY* = (MMSYSERR_BASE + 12)
-  MMSYSERR_INVALIDALIAS* = (MMSYSERR_BASE + 13)
-  MMSYSERR_BADDB* = (MMSYSERR_BASE + 14)
-  MMSYSERR_KEYNOTFOUND* = (MMSYSERR_BASE + 15)
-  MMSYSERR_READERROR* = (MMSYSERR_BASE + 16)
-  MMSYSERR_WRITEERROR* = (MMSYSERR_BASE + 17)
-  MMSYSERR_DELETEERROR* = (MMSYSERR_BASE + 18)
-  MMSYSERR_VALNOTFOUND* = (MMSYSERR_BASE + 19)
-  MMSYSERR_NODRIVERCB* = (MMSYSERR_BASE + 20)
-  MMSYSERR_LASTERROR* = (MMSYSERR_BASE + 20)
-  MM_JOY1MOVE* = 0x000003A0
-  MM_JOY2MOVE* = 0x000003A1
-  MM_JOY1ZMOVE* = 0x000003A2
-  MM_JOY2ZMOVE* = 0x000003A3
-  MM_JOY1BUTTONDOWN* = 0x000003B5
-  MM_JOY2BUTTONDOWN* = 0x000003B6
-  MM_JOY1BUTTONUP* = 0x000003B7
-  MM_JOY2BUTTONUP* = 0x000003B8
-  CALLBACK_TYPEMASK* = 0x00070000
-  CALLBACK_NULL* = 0
-  CALLBACK_EVENT* = 0x00050000
-  CALLBACK_WINDOW* = 0x00010000
-  CALLBACK_TASK* = 0x00020000
-  CALLBACK_THREAD* = CALLBACK_TASK
-  CALLBACK_FUNCTION* = 0x00030000
-
-type
-  HDRVR* = THandle
-
-const
-  DRV_LOAD* = 1
-  DRV_ENABLE* = 2
-  DRV_OPEN* = 0x00000003
-  DRV_CLOSE* = 4
-  DRV_DISABLE* = 0x00000005
-  DRV_FREE* = 0x00000006
-  DRV_CONFIGURE* = 0x00000007
-  DRV_QUERYCONFIGURE* = 8
-  DRV_INSTALL* = 0x00000009
-  DRV_REMOVE* = 0x0000000A
-  DRV_EXITSESSION* = 0x0000000B
-  DRV_POWER* = 0x0000000F
-  DRV_RESERVED* = 0x00000800
-  DRV_USER* = 0x00004000
-  DRVCNF_CANCEL* = 0
-  DRVCNF_OK* = 1
-  DRVCNF_RESTART* = 2
-  DRV_CANCEL* = DRVCNF_CANCEL
-  DRV_OK* = DRVCNF_OK
-  DRV_RESTART* = DRVCNF_RESTART
-  DRV_MCI_FIRST* = DRV_RESERVED
-  DRV_MCI_LAST* = (DRV_RESERVED + 0x00000FFF)
-
-type
-  PDRVCALLBACK* = proc (hdrvr: tHandle, uMsg: UINT, dwUser, dw1, dw2: DWORD){.
-      stdcall.}
-
-proc sndPlaySoundA*(Name: LPCSTR, flags: UINT): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "sndPlaySoundA".}
-proc sndPlaySoundW*(Name: LPCWSTR, flags: UINT): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "sndPlaySoundW".}
-when defined(winUNICODE):
-  proc sndPlaySound*(Name: cstring, flags: UINT): BOOL{.stdcall,
-      dynlib: "winmm.dll", importc: "sndPlaySoundW".}
-else:
-  proc sndPlaySound*(Name: cstring, flags: UINT): BOOL{.stdcall,
-      dynlib: "winmm.dll", importc: "sndPlaySoundA".}
-const
-  SND_NODEFAULT* = 2
-  SND_MEMORY* = 4
-  SND_LOOP* = 8
-  SND_NOSTOP* = 16
-  SND_SYNC* = 0
-  SND_ASYNC* = 1
-  SND_PURGE* = 64
-  SND_APPLICATION* = 128
-  SND_ALIAS_START* = 0
-  SND_ALIAS_SYSTEMHAND* = 18515
-  SND_ALIAS_SYSTEMEXCLAMATION* = 8531
-  SND_ALIAS_SYSTEMASTERISK* = 10835
-  SND_ALIAS_SYSTEMQUESTION* = 16211
-  SND_ALIAS_SYSTEMDEFAULT* = 17491
-  SND_ALIAS_SYSTEMEXIT* = 17747
-  SND_ALIAS_SYSTEMSTART* = 21331
-  SND_ALIAS_SYSTEMWELCOME* = 22355
-  SND_NOWAIT* = 0x00002000
-  SND_ALIAS* = 0x00010000
-  SND_ALIAS_ID* = 0x00110000
-  SND_FILENAME* = 0x00020000
-  SND_RESOURCE* = 0x00040004
-  WAVERR_BADFORMAT* = (WAVERR_BASE + 0)
-  WAVERR_STILLPLAYING* = (WAVERR_BASE + 1)
-  WAVERR_UNPREPARED* = (WAVERR_BASE + 2)
-  WAVERR_SYNC* = (WAVERR_BASE + 3)
-  WAVERR_LASTERROR* = (WAVERR_BASE + 3)
-  WOM_OPEN* = MM_WOM_OPEN
-  WOM_CLOSE* = MM_WOM_CLOSE
-  WOM_DONE* = MM_WOM_DONE
-  WIM_OPEN* = MM_WIM_OPEN
-  WIM_CLOSE* = MM_WIM_CLOSE
-  WIM_DATA* = MM_WIM_DATA
-  WAVE_MAPPER* = UINT(- 1)
-  WAVE_FORMAT_QUERY* = 1
-  WAVE_ALLOWSYNC* = 2
-  WAVE_MAPPED* = 4
-  WAVE_FORMAT_DIRECT* = 8
-  WAVE_FORMAT_DIRECT_QUERY* = (WAVE_FORMAT_QUERY Or WAVE_FORMAT_DIRECT)
-  MIM_OPEN* = MM_MIM_OPEN
-  MIM_CLOSE* = MM_MIM_CLOSE
-  MIM_DATA* = MM_MIM_DATA
-  MIM_LONGDATA* = MM_MIM_LONGDATA
-  MIM_ERROR* = MM_MIM_ERROR
-  MIM_LONGERROR* = MM_MIM_LONGERROR
-  MOM_OPEN* = MM_MOM_OPEN
-  MOM_CLOSE* = MM_MOM_CLOSE
-  MOM_DONE* = MM_MOM_DONE
-  MIM_MOREDATA* = MM_MIM_MOREDATA
-  MOM_POSITIONCB* = MM_MOM_POSITIONCB
-  MIDIMAPPER* = UINT(- 1)
-  MIDI_IO_STATUS* = 32
-  MIDI_CACHE_ALL* = 1
-  MIDI_CACHE_BESTFIT* = 2
-  MIDI_CACHE_QUERY* = 3
-  MIDI_UNCACHE* = 4
-  WHDR_DONE* = 1
-  WHDR_PREPARED* = 2
-  WHDR_BEGINLOOP* = 0x00000004
-  WHDR_ENDLOOP* = 0x00000008
-  WHDR_INQUEUE* = 0x00000010
-  MOD_MIDIPORT* = 1
-  MOD_SYNTH* = 2
-  MOD_SQSYNTH* = 3
-  MOD_FMSYNTH* = 4
-  MOD_MAPPER* = 5
-  MIDICAPS_VOLUME* = 1
-  MIDICAPS_LRVOLUME* = 2
-  MIDICAPS_CACHE* = 4
-  MIDICAPS_STREAM* = 8
-  MHDR_DONE* = 1
-  MHDR_PREPARED* = 2
-  MHDR_INQUEUE* = 0x00000004
-  MHDR_ISSTRM* = 0x00000008
-  MEVT_F_SHORT* = 0
-  MEVT_F_LONG* = 0x80000000
-  MEVT_F_CALLBACK* = 0x40000000
-
-proc MEVT_EVENTTYPE*(x: int8): int8
-proc MEVT_EVENTPARM*(x: DWORD): DWORD
-const
-  MEVT_SHORTMSG* = 0
-  MEVT_TEMPO* = 0x00000001
-  MEVT_NOP* = 0x00000002
-  MEVT_LONGMSG* = 0x00000080
-  MEVT_COMMENT* = 0x00000082
-  MEVT_VERSION* = 0x00000084
-  MIDISTRM_ERROR* = - 2
-  MIDIPROP_SET* = 0x80000000
-  MIDIPROP_GET* = 0x40000000
-  MIDIPROP_TIMEDIV* = 1
-  MIDIPROP_TEMPO* = 2
-  MIXERLINE_LINEF_ACTIVE* = 1
-  MIXERLINE_LINEF_DISCONNECTED* = 0x00008000
-  MIXERLINE_LINEF_SOURCE* = 0x80000000
-  MIXERLINE_COMPONENTTYPE_DST_FIRST* = 0
-  MIXERLINE_COMPONENTTYPE_DST_UNDEFINED* = (MIXERLINE_COMPONENTTYPE_DST_FIRST)
-  MIXERLINE_COMPONENTTYPE_DST_DIGITAL* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
-  MIXERLINE_COMPONENTTYPE_DST_LINE* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
-  MIXERLINE_COMPONENTTYPE_DST_MONITOR* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
-  MIXERLINE_COMPONENTTYPE_DST_SPEAKERS* = (MIXERLINE_COMPONENTTYPE_DST_FIRST +
-      4)
-  MIXERLINE_COMPONENTTYPE_DST_HEADPHONES* = (
-    MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
-  MIXERLINE_COMPONENTTYPE_DST_TELEPHONE* = (
-    MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
-  MIXERLINE_COMPONENTTYPE_DST_WAVEIN* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
-  MIXERLINE_COMPONENTTYPE_DST_VOICEIN* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
-  MIXERLINE_COMPONENTTYPE_DST_LAST* = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
-  MIXERLINE_COMPONENTTYPE_SRC_FIRST* = 0x00001000
-  MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0)
-  MIXERLINE_COMPONENTTYPE_SRC_DIGITAL* = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
-  MIXERLINE_COMPONENTTYPE_SRC_LINE* = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
-  MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
-  MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
-  MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
-  MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
-  MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
-  MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT* = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
-  MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY* = (
-    MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
-  MIXERLINE_COMPONENTTYPE_SRC_ANALOG* = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
-  MIXERLINE_COMPONENTTYPE_SRC_LAST* = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
-  MIXERLINE_TARGETTYPE_UNDEFINED* = 0
-  MIXERLINE_TARGETTYPE_WAVEOUT* = 1
-  MIXERLINE_TARGETTYPE_WAVEIN* = 2
-  MIXERLINE_TARGETTYPE_MIDIOUT* = 3
-  MIXERLINE_TARGETTYPE_MIDIIN* = 4
-  MIXERLINE_TARGETTYPE_AUX* = 5
-  MIDIERR_UNPREPARED* = (MIDIERR_BASE + 0)
-  MIDIERR_STILLPLAYING* = (MIDIERR_BASE + 1)
-  MIDIERR_NOMAP* = (MIDIERR_BASE + 2)
-  MIDIERR_NOTREADY* = (MIDIERR_BASE + 3)
-  MIDIERR_NODEVICE* = (MIDIERR_BASE + 4)
-  MIDIERR_INVALIDSETUP* = (MIDIERR_BASE + 5)
-  MIDIERR_BADOPENMODE* = (MIDIERR_BASE + 6)
-  MIDIERR_DONT_CONTINUE* = (MIDIERR_BASE + 7)
-  MIDIERR_LASTERROR* = (MIDIERR_BASE + 7)
-  MIXERCONTROL_CONTROLF_UNIFORM* = 1
-  MIXERCONTROL_CONTROLF_MULTIPLE* = 2
-  MIXERCONTROL_CONTROLF_DISABLED* = 0x80000000
-  MIXERCONTROL_CT_CLASS_MASK* = 0xF0000000
-  MIXERCONTROL_CT_CLASS_CUSTOM* = 0
-  MIXERCONTROL_CT_CLASS_METER* = 0x10000000
-  MIXERCONTROL_CT_CLASS_SWITCH* = 0x20000000
-  MIXERCONTROL_CT_CLASS_NUMBER* = 0x30000000
-  MIXERCONTROL_CT_CLASS_SLIDER* = 0x40000000
-  MIXERCONTROL_CT_CLASS_FADER* = 0x50000000
-  MIXERCONTROL_CT_CLASS_TIME* = 0x60000000
-  MIXERCONTROL_CT_CLASS_LIST* = 0x70000000
-  MIXERCONTROL_CT_SUBCLASS_MASK* = 0x0F000000
-  MIXERCONTROL_CT_SC_SWITCH_BOOLEAN* = 0
-  MIXERCONTROL_CT_SC_SWITCH_BUTTON* = 0x01000000
-  MIXERCONTROL_CT_SC_METER_POLLED* = 0
-  MIXERCONTROL_CT_SC_TIME_MICROSECS* = 0
-  MIXERCONTROL_CT_SC_TIME_MILLISECS* = 0x01000000
-  MIXERCONTROL_CT_SC_LIST_SINGLE* = 0
-  MIXERCONTROL_CT_SC_LIST_MULTIPLE* = 0x01000000
-  MIXERCONTROL_CT_UNITS_MASK* = 0x00FF0000
-  MIXERCONTROL_CT_UNITS_CUSTOM* = 0
-  MIXERCONTROL_CT_UNITS_BOOLEAN* = 0x00010000
-  MIXERCONTROL_CT_UNITS_SIGNED* = 0x00020000
-  MIXERCONTROL_CT_UNITS_UNSIGNED* = 0x00030000
-  MIXERCONTROL_CT_UNITS_DECIBELS* = 0x00040000
-  MIXERCONTROL_CT_UNITS_PERCENT* = 0x00050000
-  MIXERCONTROL_CONTROLTYPE_CUSTOM* = (
-    MIXERCONTROL_CT_CLASS_CUSTOM Or MIXERCONTROL_CT_UNITS_CUSTOM)
-  MIXERCONTROL_CONTROLTYPE_BOOLEANMETER* = (MIXERCONTROL_CT_CLASS_METER Or
-      MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_BOOLEAN)
-  MIXERCONTROL_CONTROLTYPE_SIGNEDMETER* = (MIXERCONTROL_CT_CLASS_METER Or
-      MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
-  MIXERCONTROL_CONTROLTYPE_PEAKMETER* = (
-    MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
-  MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER* = (MIXERCONTROL_CT_CLASS_METER Or
-      MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_UNSIGNED)
-  MIXERCONTROL_CONTROLTYPE_BOOLEAN* = (MIXERCONTROL_CT_CLASS_SWITCH Or
-      MIXERCONTROL_CT_SC_SWITCH_BOOLEAN Or MIXERCONTROL_CT_UNITS_BOOLEAN)
-  MIXERCONTROL_CONTROLTYPE_ONOFF* = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1)
-  MIXERCONTROL_CONTROLTYPE_MUTE* = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
-  MIXERCONTROL_CONTROLTYPE_MONO* = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
-  MIXERCONTROL_CONTROLTYPE_LOUDNESS* = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
-  MIXERCONTROL_CONTROLTYPE_STEREOENH* = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)
-  MIXERCONTROL_CONTROLTYPE_BUTTON* = (MIXERCONTROL_CT_CLASS_SWITCH Or
-      MIXERCONTROL_CT_SC_SWITCH_BUTTON Or MIXERCONTROL_CT_UNITS_BOOLEAN)
-  MIXERCONTROL_CONTROLTYPE_DECIBELS* = (
-    MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
-  MIXERCONTROL_CONTROLTYPE_SIGNED* = (
-    MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_SIGNED)
-  MIXERCONTROL_CONTROLTYPE_UNSIGNED* = (
-    MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
-  MIXERCONTROL_CONTROLTYPE_PERCENT* = (
-    MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_PERCENT)
-  MIXERCONTROL_CONTROLTYPE_SLIDER* = (
-    MIXERCONTROL_CT_CLASS_SLIDER Or MIXERCONTROL_CT_UNITS_SIGNED)
-  MIXERCONTROL_CONTROLTYPE_PAN* = (MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
-  MIXERCONTROL_CONTROLTYPE_QSOUNDPAN* = (MIXERCONTROL_CONTROLTYPE_SLIDER + 2)
-  MIXERCONTROL_CONTROLTYPE_FADER* = (
-    MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
-  MIXERCONTROL_CONTROLTYPE_VOLUME* = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
-  MIXERCONTROL_CONTROLTYPE_BASS* = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
-  MIXERCONTROL_CONTROLTYPE_TREBLE* = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
-  MIXERCONTROL_CONTROLTYPE_EQUALIZER* = (MIXERCONTROL_CONTROLTYPE_FADER + 4)
-  MIXERCONTROL_CONTROLTYPE_SINGLESELECT* = (MIXERCONTROL_CT_CLASS_LIST Or
-      MIXERCONTROL_CT_SC_LIST_SINGLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
-  MIXERCONTROL_CONTROLTYPE_MUX* = (MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)
-  MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT* = (MIXERCONTROL_CT_CLASS_LIST Or
-      MIXERCONTROL_CT_SC_LIST_MULTIPLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
-  MIXERCONTROL_CONTROLTYPE_MIXER* = (MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT +
-      1)
-  MIXERCONTROL_CONTROLTYPE_MICROTIME* = (MIXERCONTROL_CT_CLASS_TIME Or
-      MIXERCONTROL_CT_SC_TIME_MICROSECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
-  MIXERCONTROL_CONTROLTYPE_MILLITIME* = (MIXERCONTROL_CT_CLASS_TIME Or
-      MIXERCONTROL_CT_SC_TIME_MILLISECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
-  MIXER_SHORT_NAME_CHARS* = 16
-  MIXER_LONG_NAME_CHARS* = 64
-  MIXERR_INVALLINE* = (MIXERR_BASE + 0)
-  MIXERR_INVALCONTROL* = (MIXERR_BASE + 1)
-  MIXERR_INVALVALUE* = (MIXERR_BASE + 2)
-  MIXERR_LASTERROR* = (MIXERR_BASE + 2)
-  MIXER_OBJECTF_HANDLE* = 0x80000000
-  MIXER_OBJECTF_MIXER* = 0
-  MIXER_OBJECTF_HMIXER* = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIXER)
-  MIXER_OBJECTF_WAVEOUT* = 0x10000000
-  MIXER_OBJECTF_HWAVEOUT* = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEOUT)
-  MIXER_OBJECTF_WAVEIN* = 0x20000000
-  MIXER_OBJECTF_HWAVEIN* = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEIN)
-  MIXER_OBJECTF_MIDIOUT* = 0x30000000
-  MIXER_OBJECTF_HMIDIOUT* = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIOUT)
-  MIXER_OBJECTF_MIDIIN* = 0x40000000
-  MIXER_OBJECTF_HMIDIIN* = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIIN)
-  MIXER_OBJECTF_AUX* = 0x50000000
-  MIXER_GETCONTROLDETAILSF_VALUE* = 0
-  MIXER_GETCONTROLDETAILSF_LISTTEXT* = 1
-  MIXER_GETCONTROLDETAILSF_QUERYMASK* = 0x0000000F
-  MIXER_SETCONTROLDETAILSF_VALUE* = 0
-  MIXER_SETCONTROLDETAILSF_CUSTOM* = 1
-  MIXER_SETCONTROLDETAILSF_QUERYMASK* = 0x0000000F
-  JOYERR_NOERROR* = (0)
-  JOYERR_PARMS* = (JOYERR_BASE + 5)
-  JOYERR_NOCANDO* = (JOYERR_BASE + 6)
-  JOYERR_UNPLUGGED* = (JOYERR_BASE + 7)
-  JOY_BUTTON1* = 1
-  JOY_BUTTON2* = 2
-  JOY_BUTTON3* = 4
-  JOY_BUTTON4* = 8
-  JOY_BUTTON1CHG* = 256
-  JOY_BUTTON2CHG* = 512
-  JOY_BUTTON3CHG* = 0x00000400
-  JOY_BUTTON4CHG* = 0x00000800
-  JOY_BUTTON5* = 16
-  JOY_BUTTON6* = 32
-  JOY_BUTTON7* = 64
-  JOY_BUTTON8* = 128
-  JOY_BUTTON9* = 256
-  JOY_BUTTON10* = 512
-  JOY_BUTTON11* = 0x00000400
-  JOY_BUTTON12* = 0x00000800
-  JOY_BUTTON13* = 0x00001000
-  JOY_BUTTON14* = 0x00002000
-  JOY_BUTTON15* = 0x00004000
-  JOY_BUTTON16* = 0x00008000
-  JOY_BUTTON17* = 0x00010000
-  JOY_BUTTON18* = 0x00020000
-  JOY_BUTTON19* = 0x00040000
-  JOY_BUTTON20* = 0x00080000
-  JOY_BUTTON21* = 0x00100000
-  JOY_BUTTON22* = 0x00200000
-  JOY_BUTTON23* = 0x00400000
-  JOY_BUTTON24* = 0x00800000
-  JOY_BUTTON25* = 0x01000000
-  JOY_BUTTON26* = 0x02000000
-  JOY_BUTTON27* = 0x04000000
-  JOY_BUTTON28* = 0x08000000
-  JOY_BUTTON29* = 0x10000000
-  JOY_BUTTON30* = 0x20000000
-  JOY_BUTTON31* = 0x40000000
-  JOY_BUTTON32* = 0x80000000
-  JOY_POVCENTERED* = - 1
-  JOY_POVFORWARD* = 0
-  JOY_POVRIGHT* = 9000
-  JOY_POVBACKWARD* = 18000
-  JOY_POVLEFT* = 27000
-  JOY_RETURNX* = 1
-  JOY_RETURNY* = 2
-  JOY_RETURNZ* = 4
-  JOY_RETURNR* = 8
-  JOY_RETURNU* = 16
-  JOY_RETURNV* = 32
-  JOY_RETURNPOV* = 64
-  JOY_RETURNBUTTONS* = 128
-  JOY_RETURNRAWDATA* = 256
-  JOY_RETURNPOVCTS* = 512
-  JOY_RETURNCENTERED* = 0x00000400
-  JOY_USEDEADZONE* = 0x00000800
-  JOY_RETURNALL* = (JOY_RETURNX Or JOY_RETURNY Or JOY_RETURNZ Or JOY_RETURNR Or
-      JOY_RETURNU Or JOY_RETURNV Or JOY_RETURNPOV Or JOY_RETURNBUTTONS)
-  JOY_CAL_READALWAYS* = 0x00010000
-  JOY_CAL_READXYONLY* = 0x00020000
-  JOY_CAL_READ3* = 0x00040000
-  JOY_CAL_READ4* = 0x00080000
-  JOY_CAL_READXONLY* = 0x00100000
-  JOY_CAL_READYONLY* = 0x00200000
-  JOY_CAL_READ5* = 0x00400000
-  JOY_CAL_READ6* = 0x00800000
-  JOY_CAL_READZONLY* = 0x01000000
-  JOY_CAL_READRONLY* = 0x02000000
-  JOY_CAL_READUONLY* = 0x04000000
-  JOY_CAL_READVONLY* = 0x08000000
-  JOYSTICKID1* = 0
-  JOYSTICKID2* = 1
-  JOYCAPS_HASZ* = 1
-  JOYCAPS_HASR* = 2
-  JOYCAPS_HASU* = 4
-  JOYCAPS_HASV* = 8
-  JOYCAPS_HASPOV* = 16
-  JOYCAPS_POV4DIR* = 32
-  JOYCAPS_POVCTS* = 64
-  MMIOERR_BASE* = 256
-  MMIOERR_FILENOTFOUND* = (MMIOERR_BASE + 1)
-  MMIOERR_OUTOFMEMORY* = (MMIOERR_BASE + 2)
-  MMIOERR_CANNOTOPEN* = (MMIOERR_BASE + 3)
-  MMIOERR_CANNOTCLOSE* = (MMIOERR_BASE + 4)
-  MMIOERR_CANNOTREAD* = (MMIOERR_BASE + 5)
-  MMIOERR_CANNOTWRITE* = (MMIOERR_BASE + 6)
-  MMIOERR_CANNOTSEEK* = (MMIOERR_BASE + 7)
-  MMIOERR_CANNOTEXPAND* = (MMIOERR_BASE + 8)
-  MMIOERR_CHUNKNOTFOUND* = (MMIOERR_BASE + 9)
-  MMIOERR_UNBUFFERED* = (MMIOERR_BASE + 10)
-  MMIOERR_PATHNOTFOUND* = (MMIOERR_BASE + 11)
-  MMIOERR_ACCESSDENIED* = (MMIOERR_BASE + 12)
-  MMIOERR_SHARINGVIOLATION* = (MMIOERR_BASE + 13)
-  MMIOERR_NETWORKERROR* = (MMIOERR_BASE + 14)
-  MMIOERR_TOOMANYOPENFILES* = (MMIOERR_BASE + 15)
-  MMIOERR_INVALIDFILE* = (MMIOERR_BASE + 16)
-  CFSEPCHAR* = '+'
-  WAVECAPS_PITCH* = 1
-  WAVECAPS_PLAYBACKRATE* = 2
-  WAVECAPS_VOLUME* = 4
-  WAVECAPS_LRVOLUME* = 8
-  WAVECAPS_SYNC* = 16
-  WAVECAPS_SAMPLEACCURATE* = 32
-  WAVECAPS_DIRECTSOUND* = 64
-  MIXER_GETLINEINFOF_DESTINATION* = 0
-  MIXER_GETLINEINFOF_SOURCE* = 1
-  MIXER_GETLINEINFOF_LINEID* = 2
-  MIXER_GETLINEINFOF_COMPONENTTYPE* = 3
-  MIXER_GETLINEINFOF_TARGETTYPE* = 4
-  MIXER_GETLINEINFOF_QUERYMASK* = 0x0000000F
-  MMIO_RWMODE* = 3
-  MMIO_SHAREMODE* = 0x00000070
-  MMIO_CREATE* = 0x00001000
-  MMIO_PARSE* = 256
-  MMIO_DELETE* = 512
-  MMIO_EXIST* = 0x00004000
-  MMIO_ALLOCBUF* = 0x00010000
-  MMIO_GETTEMP* = 0x00020000
-  MMIO_DIRTY* = 0x10000000
-  cMMIO_READ* = 0
-  cMMIO_WRITE* = 1
-  MMIO_READWRITE* = 2
-  MMIO_COMPAT* = 0
-  MMIO_EXCLUSIVE* = 16
-  MMIO_DENYWRITE* = 32
-  MMIO_DENYREAD* = 0x00000030
-  MMIO_DENYNONE* = 64
-  MMIO_FHOPEN* = 16
-  MMIO_EMPTYBUF* = 16
-  MMIO_TOUPPER* = 16
-  MMIO_INSTALLPROC* = 0x00010000
-  MMIO_GLOBALPROC* = 0x10000000
-  MMIO_REMOVEPROC* = 0x00020000
-  MMIO_UNICODEPROC* = 0x01000000
-  MMIO_FINDPROC* = 0x00040000
-  MMIO_FINDCHUNK* = 16
-  MMIO_FINDRIFF* = 32
-  MMIO_FINDLIST* = 64
-  MMIO_CREATERIFF* = 32
-  MMIO_CREATELIST* = 64
-  MMIOM_READ* = cMMIO_READ
-  MMIOM_WRITE* = cMMIO_WRITE
-  MMIOM_SEEK* = 2
-  MMIOM_OPEN* = 3
-  MMIOM_CLOSE* = 4
-  MMIOM_WRITEFLUSH* = 5
-  MMIOM_RENAME* = 6
-  MMIOM_USER* = 0x00008000
-  FOURCC_RIFF* = 0x46464952   #'R','I','F','F'
-  FOURCC_LIST* = 0x5453494C   #'L','I','S','T'
-  FOURCC_DOS* = 0x20532F44    #'D','O','S',' '
-  FOURCC_MEM* = 0x204D454D    #'M','E','M',' '
-  SEEK_SET* = 0
-  SEEK_CUR* = 1
-  SEEK_END* = 2
-  MMIO_DEFAULTBUFFER* = 8192
-  MCIERR_INVALID_DEVICE_ID* = (MCIERR_BASE + 1)
-  MCIERR_UNRECOGNIZED_KEYWORD* = (MCIERR_BASE + 3)
-  MCIERR_UNRECOGNIZED_COMMAND* = (MCIERR_BASE + 5)
-  MCIERR_HARDWARE* = (MCIERR_BASE + 6)
-  MCIERR_INVALID_DEVICE_NAME* = (MCIERR_BASE + 7)
-  MCIERR_OUT_OF_MEMORY* = (MCIERR_BASE + 8)
-  MCIERR_DEVICE_OPEN* = (MCIERR_BASE + 9)
-  MCIERR_CANNOT_LOAD_DRIVER* = (MCIERR_BASE + 10)
-  MCIERR_MISSING_COMMAND_STRING* = (MCIERR_BASE + 11)
-  MCIERR_PARAM_OVERFLOW* = (MCIERR_BASE + 12)
-  MCIERR_MISSING_STRING_ARGUMENT* = (MCIERR_BASE + 13)
-  MCIERR_BAD_INTEGER* = (MCIERR_BASE + 14)
-  MCIERR_PARSER_INTERNAL* = (MCIERR_BASE + 15)
-  MCIERR_DRIVER_INTERNAL* = (MCIERR_BASE + 16)
-  MCIERR_MISSING_PARAMETER* = (MCIERR_BASE + 17)
-  MCIERR_UNSUPPORTED_FUNCTION* = (MCIERR_BASE + 18)
-  MCIERR_FILE_NOT_FOUND* = (MCIERR_BASE + 19)
-  MCIERR_DEVICE_NOT_READY* = (MCIERR_BASE + 20)
-  MCIERR_INTERNAL* = (MCIERR_BASE + 21)
-  MCIERR_DRIVER* = (MCIERR_BASE + 22)
-  MCIERR_CANNOT_USE_ALL* = (MCIERR_BASE + 23)
-  MCIERR_MULTIPLE* = (MCIERR_BASE + 24)
-  MCIERR_EXTENSION_NOT_FOUND* = (MCIERR_BASE + 25)
-  MCIERR_OUTOFRANGE* = (MCIERR_BASE + 26)
-  MCIERR_FLAGS_NOT_COMPATIBLE* = (MCIERR_BASE + 28)
-  MCIERR_FILE_NOT_SAVED* = (MCIERR_BASE + 30)
-  MCIERR_DEVICE_TYPE_REQUIRED* = (MCIERR_BASE + 31)
-  MCIERR_DEVICE_LOCKED* = (MCIERR_BASE + 32)
-  MCIERR_DUPLICATE_ALIAS* = (MCIERR_BASE + 33)
-  MCIERR_BAD_CONSTANT* = (MCIERR_BASE + 34)
-  MCIERR_MUST_USE_SHAREABLE* = (MCIERR_BASE + 35)
-  MCIERR_MISSING_DEVICE_NAME* = (MCIERR_BASE + 36)
-  MCIERR_BAD_TIME_FORMAT* = (MCIERR_BASE + 37)
-  MCIERR_NO_CLOSING_QUOTE* = (MCIERR_BASE + 38)
-  MCIERR_DUPLICATE_FLAGS* = (MCIERR_BASE + 39)
-  MCIERR_INVALID_FILE* = (MCIERR_BASE + 40)
-  MCIERR_NULL_PARAMETER_BLOCK* = (MCIERR_BASE + 41)
-  MCIERR_UNNAMED_RESOURCE* = (MCIERR_BASE + 42)
-  MCIERR_NEW_REQUIRES_ALIAS* = (MCIERR_BASE + 43)
-  MCIERR_NOTIFY_ON_AUTO_OPEN* = (MCIERR_BASE + 44)
-  MCIERR_NO_ELEMENT_ALLOWED* = (MCIERR_BASE + 45)
-  MCIERR_NONAPPLICABLE_FUNCTION* = (MCIERR_BASE + 46)
-  MCIERR_ILLEGAL_FOR_AUTO_OPEN* = (MCIERR_BASE + 47)
-  MCIERR_FILENAME_REQUIRED* = (MCIERR_BASE + 48)
-  MCIERR_EXTRA_CHARACTERS* = (MCIERR_BASE + 49)
-  MCIERR_DEVICE_NOT_INSTALLED* = (MCIERR_BASE + 50)
-  MCIERR_GET_CD* = (MCIERR_BASE + 51)
-  MCIERR_SET_CD* = (MCIERR_BASE + 52)
-  MCIERR_SET_DRIVE* = (MCIERR_BASE + 53)
-  MCIERR_DEVICE_LENGTH* = (MCIERR_BASE + 54)
-  MCIERR_DEVICE_ORD_LENGTH* = (MCIERR_BASE + 55)
-  MCIERR_NO_INTEGER* = (MCIERR_BASE + 56)
-  MCIERR_WAVE_OUTPUTSINUSE* = (MCIERR_BASE + 64)
-  MCIERR_WAVE_SETOUTPUTINUSE* = (MCIERR_BASE + 65)
-  MCIERR_WAVE_INPUTSINUSE* = (MCIERR_BASE + 66)
-  MCIERR_WAVE_SETINPUTINUSE* = (MCIERR_BASE + 67)
-  MCIERR_WAVE_OUTPUTUNSPECIFIED* = (MCIERR_BASE + 68)
-  MCIERR_WAVE_INPUTUNSPECIFIED* = (MCIERR_BASE + 69)
-  MCIERR_WAVE_OUTPUTSUNSUITABLE* = (MCIERR_BASE + 70)
-  MCIERR_WAVE_SETOUTPUTUNSUITABLE* = (MCIERR_BASE + 71)
-  MCIERR_WAVE_INPUTSUNSUITABLE* = (MCIERR_BASE + 72)
-  MCIERR_WAVE_SETINPUTUNSUITABLE* = (MCIERR_BASE + 73)
-  MCIERR_SEQ_DIV_INCOMPATIBLE* = (MCIERR_BASE + 80)
-  MCIERR_SEQ_PORT_INUSE* = (MCIERR_BASE + 81)
-  MCIERR_SEQ_PORT_NONEXISTENT* = (MCIERR_BASE + 82)
-  MCIERR_SEQ_PORT_MAPNODEVICE* = (MCIERR_BASE + 83)
-  MCIERR_SEQ_PORT_MISCERROR* = (MCIERR_BASE + 84)
-  MCIERR_SEQ_TIMER* = (MCIERR_BASE + 85)
-  MCIERR_SEQ_PORTUNSPECIFIED* = (MCIERR_BASE + 86)
-  MCIERR_SEQ_NOMIDIPRESENT* = (MCIERR_BASE + 87)
-  MCIERR_NO_WINDOW* = (MCIERR_BASE + 90)
-  MCIERR_CREATEWINDOW* = (MCIERR_BASE + 91)
-  MCIERR_FILE_READ* = (MCIERR_BASE + 92)
-  MCIERR_FILE_WRITE* = (MCIERR_BASE + 93)
-  MCIERR_NO_IDENTITY* = (MCIERR_BASE + 94)
-  MCIERR_CUSTOM_DRIVER_BASE* = (MCIERR_BASE + 256)
-  MCI_FIRST* = DRV_MCI_FIRST
-  MCI_ESCAPE* = 0x00000805
-  MCI_PLAY* = 0x00000806
-  MCI_SEEK* = 0x00000807
-  MCI_STOP* = 0x00000808
-  MCI_PAUSE* = 0x00000809
-  MCI_INFO* = 0x0000080A
-  MCI_GETDEVCAPS* = 0x0000080B
-  MCI_BREAK* = 0x00000811
-  MCI_WHERE* = 0x00000843
-  MCI_FREEZE* = 0x00000844
-  MCI_UNFREEZE* = 0x00000845
-  MCI_LOAD* = 0x00000850
-  MCI_CUT* = 0x00000851
-  MCI_COPY* = 0x00000852
-  MCI_PASTE* = 0x00000853
-  MCI_UPDATE* = 0x00000854
-  MCI_RESUME* = 0x00000855
-  MCI_DELETE* = 0x00000856
-  MCI_SET* = 0x0000080D
-  MCI_STEP* = 0x0000080E
-  MCI_SAVE* = 0x00000813
-  MCI_SPIN* = 0x0000080C
-  MCI_STATUS* = 0x00000814
-  MCI_CUE* = 0x00000830
-  MCI_REALIZE* = 0x00000840
-  MCI_WINDOW* = 0x00000841
-  MCI_PUT* = 0x00000842
-  MCI_RECORD* = 0x0000080F
-  MCI_SYSINFO* = 0x00000810
-  MCI_OPEN* = 0x00000803
-  MCI_CLOSE* = 0x00000804
-  MCI_USER_MESSAGES* = (DRV_MCI_FIRST + 0x00000400)
-  MCI_LAST* = 0x00000FFF
-  MCI_ALL_DEVICE_ID* = - 1
-  MCI_DEVTYPE_VCR* = 513
-  MCI_DEVTYPE_VIDEODISC* = 514
-  MCI_DEVTYPE_OVERLAY* = 515
-  MCI_DEVTYPE_CD_AUDIO* = 516
-  MCI_DEVTYPE_DAT* = 517
-  MCI_DEVTYPE_SCANNER* = 518
-  MCI_DEVTYPE_ANIMATION* = 519
-  MCI_DEVTYPE_DIGITAL_VIDEO* = 520
-  MCI_DEVTYPE_OTHER* = 521
-  MCI_DEVTYPE_WAVEFORM_AUDIO* = 522
-  MCI_DEVTYPE_SEQUENCER* = 523
-  MCI_DEVTYPE_FIRST* = MCI_DEVTYPE_VCR
-  MCI_DEVTYPE_LAST* = MCI_DEVTYPE_SEQUENCER
-  MCI_DEVTYPE_FIRST_USER* = 0x00001000
-  MCI_MODE_NOT_READY* = (MCI_STRING_OFFSET + 12)
-  MCI_MODE_STOP* = (MCI_STRING_OFFSET + 13)
-  MCI_MODE_PLAY* = (MCI_STRING_OFFSET + 14)
-  MCI_MODE_RECORD* = (MCI_STRING_OFFSET + 15)
-  MCI_MODE_SEEK* = (MCI_STRING_OFFSET + 16)
-  MCI_MODE_PAUSE* = (MCI_STRING_OFFSET + 17)
-  MCI_MODE_OPEN* = (MCI_STRING_OFFSET + 18)
-  MCI_FORMAT_MILLISECONDS* = 0
-  MCI_FORMAT_HMS* = 1
-  MCI_FORMAT_MSF* = 2
-  MCI_FORMAT_FRAMES* = 3
-  MCI_FORMAT_SMPTE_24* = 4
-  MCI_FORMAT_SMPTE_25* = 5
-  MCI_FORMAT_SMPTE_30* = 6
-  MCI_FORMAT_SMPTE_30DROP* = 7
-  MCI_FORMAT_BYTES* = 8
-  MCI_FORMAT_SAMPLES* = 9
-  MCI_FORMAT_TMSF* = 10
-
-proc MCI_MSF_MINUTE*(msf: int32): int8
-proc MCI_MSF_SECOND*(msf: int32): int8
-proc MCI_MSF_FRAME*(msf: int32): int8
-proc MCI_MAKE_MSF*(m, s, f: int8): int32
-const
-  MCI_SET_DOOR_OPEN* = 256
-  MCI_SET_DOOR_CLOSED* = 512
-  MCI_SET_TIME_FORMAT* = 0x00000400
-  MCI_SET_AUDIO* = 0x00000800
-  MCI_SET_VIDEO* = 0x00001000
-  MCI_SET_ON* = 0x00002000
-  MCI_SET_OFF* = 0x00004000
-  MCI_SET_AUDIO_ALL* = 0
-  MCI_SET_AUDIO_LEFT* = 1
-  MCI_SET_AUDIO_RIGHT* = 2
-
-proc MCI_TMSF_TRACK*(tmsf: int32): int8
-proc MCI_TMSF_MINUTE*(tmsf: int32): int8
-proc MCI_TMSF_SECOND*(tmsf: int32): int8
-proc MCI_TMSF_FRAME*(tmsf: int32): int8
-proc MCI_HMS_HOUR*(h: int32): int8
-proc MCI_HMS_MINUTE*(h: int32): int8
-proc MCI_HMS_SECOND*(h: int32): int8
-proc MCI_MAKE_HMS*(h, m, s: int8): int32
-const
-  MCI_INFO_PRODUCT* = 256
-  MCI_INFO_FILE* = 512
-  MCI_INFO_MEDIA_UPC* = 0x00000400
-  MCI_INFO_MEDIA_IDENTITY* = 0x00000800
-  MCI_INFO_NAME* = 0x00001000
-  MCI_INFO_COPYRIGHT* = 0x00002000
-
-proc MCI_MAKE_TMSF*(t, m, s, f: int8): int32
-const
-  MCI_WAIT* = 2
-  MCI_FROM* = 4
-  MCI_TO* = 8
-  MCI_TRACK* = 16
-  MCI_SEEK_TO_START* = 256
-  MCI_SEEK_TO_END* = 512
-  MCI_STATUS_ITEM* = 256
-  MCI_STATUS_START* = 512
-  MCI_STATUS_LENGTH* = 1
-  MCI_STATUS_POSITION* = 2
-  MCI_STATUS_NUMBER_OF_TRACKS* = 3
-  MCI_STATUS_MODE* = 4
-  MCI_STATUS_MEDIA_PRESENT* = 5
-  MCI_STATUS_TIME_FORMAT* = 6
-  MCI_STATUS_READY* = 7
-  MCI_STATUS_CURRENT_TRACK* = 8
-  MCI_OPEN_SHAREABLE* = 256
-  MCI_OPEN_ELEMENT* = 512
-  MCI_OPEN_ALIAS* = 0x00000400
-  MCI_OPEN_ELEMENT_ID* = 0x00000800
-  MCI_OPEN_TYPE_ID* = 0x00001000
-  MCI_OPEN_TYPE* = 0x00002000
-  MCI_GETDEVCAPS_ITEM* = 256
-  MCI_GETDEVCAPS_CAN_RECORD* = 1
-  MCI_GETDEVCAPS_HAS_AUDIO* = 2
-  MCI_GETDEVCAPS_HAS_VIDEO* = 3
-  MCI_GETDEVCAPS_DEVICE_TYPE* = 4
-  MCI_GETDEVCAPS_USES_FILES* = 5
-  MCI_GETDEVCAPS_COMPOUND_DEVICE* = 6
-  MCI_GETDEVCAPS_CAN_EJECT* = 7
-  MCI_GETDEVCAPS_CAN_PLAY* = 8
-  MCI_GETDEVCAPS_CAN_SAVE* = 9
-  MCI_SYSINFO_QUANTITY* = 256
-  MCI_SYSINFO_OPEN* = 512
-  MCI_SYSINFO_NAME* = 0x00000400
-  MCI_SYSINFO_INSTALLNAME* = 0x00000800
-  MCI_NOTIFY_SUCCESSFUL* = 1
-  MCI_NOTIFY_SUPERSEDED* = 2
-  MCI_NOTIFY_ABORTED* = 4
-  MCI_NOTIFY_FAILURE* = 8
-  MCI_NOTIFY* = 1
-  MCI_BREAK_KEY* = 256
-  MCI_BREAK_HWND* = 512
-  MCI_BREAK_OFF* = 0x00000400
-  MCI_RECORD_INSERT* = 256
-  MCI_RECORD_OVERWRITE* = 512
-  MCI_SAVE_FILE* = 256
-  MCI_LOAD_FILE* = 256
-  MCI_VD_GETDEVCAPS_FAST_RATE* = 0x00004003
-  MCI_VD_GETDEVCAPS_SLOW_RATE* = 0x00004004
-  MCI_VD_GETDEVCAPS_NORMAL_RATE* = 0x00004005
-  MCI_VD_STEP_FRAMES* = 0x00010000
-  MCI_VD_STEP_REVERSE* = 0x00020000
-  MCI_VD_ESCAPE_STRING* = 256
-  MCI_VD_FORMAT_TRACK* = 0x00004001
-  MCI_VD_PLAY_REVERSE* = 0x00010000
-  MCI_VD_PLAY_FAST* = 0x00020000
-  MCI_VD_MODE_PARK* = (MCI_VD_OFFSET + 1)
-  MCI_VD_GETDEVCAPS_CAV* = 0x00020000
-  MCI_VD_SPIN_UP* = 0x00010000
-  MCI_VD_SPIN_DOWN* = 0x00020000
-  MCI_VD_SEEK_REVERSE* = 0x00010000
-  MCI_VD_STATUS_SPEED* = 0x00004002
-  MCI_VD_STATUS_FORWARD* = 0x00004003
-  MCI_VD_STATUS_MEDIA_TYPE* = 0x00004004
-  MCI_VD_STATUS_SIDE* = 0x00004005
-  MCI_VD_GETDEVCAPS_CAN_REVERSE* = 0x00004002
-  MCI_VD_MEDIA_CLV* = (MCI_VD_OFFSET + 2)
-  MCI_VD_MEDIA_CAV* = (MCI_VD_OFFSET + 3)
-  MCI_VD_MEDIA_OTHER* = (MCI_VD_OFFSET + 4)
-  MCI_VD_STATUS_DISC_SIZE* = 0x00004006
-  MCI_VD_GETDEVCAPS_CLV* = 0x00010000
-  MCI_VD_PLAY_SPEED* = 0x00040000
-  MCI_VD_PLAY_SCAN* = 0x00080000
-  MCI_VD_PLAY_SLOW* = 0x00100000
-  MCI_WAVE_STATUS_CHANNELS* = 0x00004002
-  MCI_WAVE_STATUS_SAMPLESPERSEC* = 0x00004003
-  MCI_WAVE_PCM* = MCI_WAVE_OFFSET
-  MCI_WAVE_MAPPER* = (MCI_WAVE_OFFSET + 1)
-  MCI_WAVE_OPEN_BUFFER* = 0x00010000
-  MCI_WAVE_STATUS_BITSPERSAMPLE* = 0x00004006
-  MCI_WAVE_STATUS_LEVEL* = 0x00004007
-  MCI_WAVE_SET_FORMATTAG* = 0x00010000
-  MCI_WAVE_SET_CHANNELS* = 0x00020000
-  MCI_WAVE_SET_SAMPLESPERSEC* = 0x00040000
-  MCI_WAVE_SET_AVGBYTESPERSEC* = 0x00080000
-  MCI_WAVE_SET_BLOCKALIGN* = 0x00100000
-  MCI_WAVE_SET_BITSPERSAMPLE* = 0x00200000
-  MCI_WAVE_INPUT* = 0x00400000
-  MCI_WAVE_OUTPUT* = 0x00800000
-  MCI_WAVE_STATUS_FORMATTAG* = 0x00004001
-  MCI_WAVE_SET_ANYINPUT* = 0x04000000
-  MCI_WAVE_SET_ANYOUTPUT* = 0x08000000
-  MCI_WAVE_GETDEVCAPS_INPUTS* = 0x00004001
-  MCI_WAVE_GETDEVCAPS_OUTPUTS* = 0x00004002
-  MCI_WAVE_STATUS_AVGBYTESPERSEC* = 0x00004004
-  MCI_WAVE_STATUS_BLOCKALIGN* = 0x00004005
-  MCI_CDA_STATUS_TYPE_TRACK* = 0x00004001
-  MCI_CDA_TRACK_AUDIO* = (MCI_CD_OFFSET)
-  MCI_CDA_TRACK_OTHER* = (MCI_CD_OFFSET + 1)
-  MCI_SEQ_DIV_PPQN* = (MCI_SEQ_OFFSET)
-  MCI_SEQ_DIV_SMPTE_24* = (MCI_SEQ_OFFSET + 1)
-  MCI_SEQ_DIV_SMPTE_25* = (MCI_SEQ_OFFSET + 2)
-  MCI_SEQ_DIV_SMPTE_30DROP* = (MCI_SEQ_OFFSET + 3)
-  MCI_SEQ_DIV_SMPTE_30* = (MCI_SEQ_OFFSET + 4)
-  MCI_SEQ_FORMAT_SONGPTR* = 0x00004001
-  MCI_SEQ_FILE* = 0x00004002
-  MCI_SEQ_MIDI* = 0x00004003
-  MCI_SEQ_SMPTE* = 0x00004004
-  MCI_SEQ_NONE* = 65533
-  MCI_SEQ_MAPPER* = 65535
-  MCI_SEQ_STATUS_TEMPO* = 0x00004002
-  MCI_SEQ_STATUS_PORT* = 0x00004003
-  MCI_SEQ_STATUS_SLAVE* = 0x00004007
-  MCI_SEQ_STATUS_MASTER* = 0x00004008
-  MCI_SEQ_STATUS_OFFSET* = 0x00004009
-  MCI_SEQ_STATUS_DIVTYPE* = 0x0000400A
-  MCI_SEQ_STATUS_NAME* = 0x0000400B
-  MCI_SEQ_STATUS_COPYRIGHT* = 0x0000400C
-  MCI_SEQ_SET_TEMPO* = 0x00010000
-  MCI_SEQ_SET_PORT* = 0x00020000
-  MCI_SEQ_SET_SLAVE* = 0x00040000
-  MCI_SEQ_SET_MASTER* = 0x00080000
-  MCI_SEQ_SET_OFFSET* = 0x01000000
-  MCI_ANIM_PLAY_SLOW* = 0x00080000
-  MCI_ANIM_PLAY_SCAN* = 0x00100000
-  MCI_ANIM_GETDEVCAPS_SLOW_RATE* = 0x00004003
-  MCI_ANIM_GETDEVCAPS_NORMAL_RATE* = 0x00004004
-  MCI_ANIM_STEP_REVERSE* = 0x00010000
-  MCI_ANIM_STEP_FRAMES* = 0x00020000
-  MCI_ANIM_STATUS_SPEED* = 0x00004001
-  MCI_ANIM_GETDEVCAPS_PALETTES* = 0x00004006
-  MCI_ANIM_OPEN_WS* = 0x00010000
-  MCI_ANIM_OPEN_PARENT* = 0x00020000
-  MCI_ANIM_OPEN_NOSTATIC* = 0x00040000
-  MCI_ANIM_GETDEVCAPS_FAST_RATE* = 0x00004002
-  MCI_ANIM_PLAY_SPEED* = 0x00010000
-  MCI_ANIM_PLAY_REVERSE* = 0x00020000
-  MCI_ANIM_PLAY_FAST* = 0x00040000
-  MCI_ANIM_STATUS_FORWARD* = 0x00004002
-  MCI_ANIM_STATUS_HWND* = 0x00004003
-  MCI_ANIM_STATUS_HPAL* = 0x00004004
-  MCI_ANIM_STATUS_STRETCH* = 0x00004005
-  MCI_ANIM_INFO_TEXT* = 0x00010000
-  MCI_ANIM_GETDEVCAPS_CAN_REVERSE* = 0x00004001
-  MCI_ANIM_WINDOW_TEXT* = 0x00080000
-  MCI_ANIM_WINDOW_ENABLE_STRETCH* = 0x00100000
-  MCI_ANIM_WINDOW_DISABLE_STRETCH* = 0x00200000
-  MCI_ANIM_WINDOW_DEFAULT* = 0
-  MCI_ANIM_RECT* = 0x00010000
-  MCI_ANIM_PUT_SOURCE* = 0x00020000
-  MCI_ANIM_PUT_DESTINATION* = 0x00040000
-  MCI_ANIM_WHERE_SOURCE* = 0x00020000
-  MCI_ANIM_WHERE_DESTINATION* = 0x00040000
-  MCI_ANIM_UPDATE_HDC* = 0x00020000
-  MCI_ANIM_GETDEVCAPS_CAN_STRETCH* = 0x00004007
-  MCI_ANIM_GETDEVCAPS_MAX_WINDOWS* = 0x00004008
-  MCI_ANIM_REALIZE_NORM* = 0x00010000
-  MCI_ANIM_REALIZE_BKGD* = 0x00020000
-  MCI_ANIM_WINDOW_HWND* = 0x00010000
-  MCI_ANIM_WINDOW_STATE* = 0x00040000
-  TIMERR_NOERROR* = 0
-  TIMERR_NOCANDO* = (TIMERR_BASE + 1)
-  TIMERR_STRUCT* = (TIMERR_BASE + 33)
-  TIME_ONESHOT* = 0
-  TIME_PERIODIC* = 1
-  TIME_CALLBACK_FUNCTION* = 0
-  TIME_CALLBACK_EVENT_SET* = 16
-  TIME_CALLBACK_EVENT_PULSE* = 32
-  MCI_OVLY_OPEN_WS* = 0x00010000
-  MCI_OVLY_OPEN_PARENT* = 0x00020000
-  MCI_OVLY_STATUS_HWND* = 0x00004001
-  MCI_OVLY_STATUS_STRETCH* = 0x00004002
-  MCI_OVLY_INFO_TEXT* = 0x00010000
-  MCI_OVLY_GETDEVCAPS_CAN_STRETCH* = 0x00004001
-  MCI_OVLY_GETDEVCAPS_CAN_FREEZE* = 0x00004002
-  MCI_OVLY_GETDEVCAPS_MAX_WINDOWS* = 0x00004003
-  MCI_OVLY_WINDOW_HWND* = 0x00010000
-  MCI_OVLY_WINDOW_STATE* = 0x00040000
-  MCI_OVLY_WINDOW_TEXT* = 0x00080000
-  MCI_OVLY_WINDOW_ENABLE_STRETCH* = 0x00100000
-  MCI_OVLY_WINDOW_DISABLE_STRETCH* = 0x00200000
-  MCI_OVLY_WINDOW_DEFAULT* = 0
-  MCI_OVLY_RECT* = 0x00010000
-  MCI_OVLY_PUT_SOURCE* = 0x00020000
-  MCI_OVLY_PUT_DESTINATION* = 0x00040000
-  MCI_OVLY_PUT_FRAME* = 0x00080000
-  MCI_OVLY_PUT_VIDEO* = 0x00100000
-  MCI_OVLY_WHERE_SOURCE* = 0x00020000
-  MCI_OVLY_WHERE_DESTINATION* = 0x00040000
-  MCI_OVLY_WHERE_FRAME* = 0x00080000
-  MCI_OVLY_WHERE_VIDEO* = 0x00100000
-  AUX_MAPPER* = - 1
-  MIXER_GETLINECONTROLSF_ONEBYID* = 1
-  MIXER_GETLINECONTROLSF_ONEBYTYPE* = 2
-  MIXER_GETLINECONTROLSF_ALL* = 0
-  MIXER_GETLINECONTROLSF_QUERYMASK* = 0x0000000F
-  NEWTRANSPARENT* = 3
-  QUERYROPSUPPORT* = 40
-  SELECTDIB* = 41
-
-proc DIBINDEX*(n: int32): int32
-const
-  SC_SCREENSAVE* = 0x0000F140
-  AUXCAPS_CDAUDIO* = 1
-  AUXCAPS_AUXIN* = 2
-  AUXCAPS_VOLUME* = 1
-  AUXCAPS_LRVOLUME* = 2 #/////////////////////////////////////////////////////////
-                        # Structures and typedefs
-                        #/////////////////////////////////////////////////////////
-
-type
-  mmtime* {.final.} = object
-    wType*: UINT
-    hour*, min*, sec*, frame*, fps*, dummy*: int8
-    pad*: array[0..1, int8]
-
-  PMMTIME* = ptr mmtime
-  NPMMTIME* = ptr mmtime
-  LPMMTIME* = ptr mmtime
-  PWAVEHDR* = ptr wavehdr
-  TMMTime* = mmtime
-  wavehdr* {.final.} = object
-    lpData*: cstring
-    dwBufferLength*: DWORD
-    dwBytesRecorded*: DWORD
-    dwUser*: DWORD
-    dwFlags*: DWORD
-    dwLoops*: DWORD
-    lpNext*: PWAVEHDR
-    reserved*: DWORD
-
-  TWAVEHDR* = WAVEHDR
-  NPWAVEHDR* = ptr wavehdr
-  LPWAVEHDR* = ptr wavehdr
-  WAVEOUTCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    dwFormats*: DWORD
-    wChannels*: int16
-    wReserved1*: int16
-    dwSupport*: DWORD
-
-  TWAVEOUTCAPSA* = WAVEOUTCAPSA
-  PWAVEOUTCAPSA* = ptr WAVEOUTCAPSA
-  NPWAVEOUTCAPSA* = ptr WAVEOUTCAPSA
-  LPWAVEOUTCAPSA* = ptr WAVEOUTCAPSA
-  WAVEOUTCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    dwFormats*: DWORD
-    wChannels*: int16
-    wReserved1*: int16
-    dwSupport*: DWORD
-
-  PWAVEOUTCAPSW* = ptr WAVEOUTCAPSW
-  NPWAVEOUTCAPSW* = ptr WAVEOUTCAPSW
-  LPWAVEOUTCAPSW* = ptr WAVEOUTCAPSW
-  TWAVEOUTCAPSW* = WAVEOUTCAPSW
-
-when defined(UNICODE):
-  type
-    WAVEOUTCAPS* = WAVEOUTCAPSW
-    PWAVEOUTCAPS* = PWAVEOUTCAPSW
-    NPWAVEOUTCAPS* = NPWAVEOUTCAPSW
-    LPWAVEOUTCAPS* = LPWAVEOUTCAPSW
-else:
-  type
-    WAVEOUTCAPS* = WAVEOUTCAPSA
-    PWAVEOUTCAPS* = PWAVEOUTCAPSA
-    NPWAVEOUTCAPS* = NPWAVEOUTCAPSA
-    LPWAVEOUTCAPS* = LPWAVEOUTCAPSA
-type
-  TWAVEOUTCAPS* = WAVEOUTCAPS
-  WAVEINCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    dwFormats*: DWORD
-    wChannels*: int16
-    wReserved1*: int16
-
-  PWAVEINCAPSA* = ptr WAVEINCAPSA
-  NPWAVEINCAPSA* = ptr WAVEINCAPSA
-  LPWAVEINCAPSA* = ptr WAVEINCAPSA
-  TWAVEINCAPSA* = WAVEINCAPSA
-  WAVEINCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    dwFormats*: DWORD
-    wChannels*: int16
-    wReserved1*: int16
-
-  PWAVEINCAPSW* = ptr WAVEINCAPSW
-  NPWAVEINCAPSW* = ptr WAVEINCAPSW
-  LPWAVEINCAPSW* = ptr WAVEINCAPSW
-  TWAVEINCAPSW* = WAVEINCAPSW
-
-when defined(UNICODE):
-  type
-    WAVEINCAPS* = WAVEINCAPSW
-    PWAVEINCAPS* = PWAVEINCAPSW
-    NPWAVEINCAPS* = NPWAVEINCAPSW
-    LPWAVEINCAPS* = LPWAVEINCAPSW
-else:
-  type
-    WAVEINCAPS* = WAVEINCAPSA
-    PWAVEINCAPS* = PWAVEINCAPSA
-    NPWAVEINCAPS* = NPWAVEINCAPSA
-    LPWAVEINCAPS* = LPWAVEINCAPSA
-type
-  TWAVEINCAPS* = WAVEINCAPS
-  waveformat* {.final.} = object
-    wFormatTag*: int16
-    nChannels*: int16
-    nSamplesPerSec*: DWORD
-    nAvgBytesPerSec*: DWORD
-    nBlockAlign*: int16
-
-  PWAVEFORMAT* = ptr waveformat
-  NPWAVEFORMAT* = ptr waveformat
-  LPWAVEFORMAT* = ptr waveformat
-  TWAVEFORMAT* = waveformat
-
-const
-  WAVE_FORMAT_PCM* = 1
-
-type
-  pcmwaveformat* {.final.} = object
-    wf*: WAVEFORMAT
-    wBitsPerSample*: int16
-
-  PPCMWAVEFORMAT* = ptr pcmwaveformat
-  NPPCMWAVEFORMAT* = ptr pcmwaveformat
-  LPPCMWAVEFORMAT* = ptr pcmwaveformat
-  TPCMWAVEFORMAT* = PCMWAVEFORMAT
-  WAVEFORMATEX* {.final.} = object
-    wFormatTag*: int16
-    nChannels*: int16
-    nSamplesPerSec*: DWORD
-    nAvgBytesPerSec*: DWORD
-    nBlockAlign*: int16
-    wBitsPerSample*: int16
-    cbSize*: int16
-
-  PWAVEFORMATEX* = ptr WAVEFORMATEX
-  NPWAVEFORMATEX* = ptr WAVEFORMATEX
-  LPWAVEFORMATEX* = ptr WAVEFORMATEX
-  LPCWAVEFORMATEX* = ptr WAVEFORMATEX
-  TWAVEFORMATEX* = WAVEFORMATEX
-  HMIDI* = THandle
-  HMIDIIN* = THandle
-  HMIDIOUT* = THandle
-  HMIDISTRM* = THandle
-  LPHMIDI* = ptr HMIDI
-  LPHMIDIIN* = ptr HMIDIIN
-  LPHMIDIOUT* = ptr HMIDIOUT
-  LPHMIDISTRM* = ptr HMIDISTRM
-  LPMIDICALLBACK* = PDRVCALLBACK
-
-const
-  MIDIPATCHSIZE* = 128
-
-type
-  PATCHARRAY* = array[0..Pred(MIDIPATCHSIZE), int16]
-  LPPATCHARRAY* = ptr int16
-  KEYARRAY* = array[0..Pred(MIDIPATCHSIZE), int16]
-  LPKEYARRAY* = ptr int16
-  MIDIOUTCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    wTechnology*: int16
-    wVoices*: int16
-    wNotes*: int16
-    wChannelMask*: int16
-    dwSupport*: DWORD
-
-  PMIDIOUTCAPSA* = ptr MIDIOUTCAPSA
-  NPMIDIOUTCAPSA* = ptr MIDIOUTCAPSA
-  LPMIDIOUTCAPSA* = ptr MIDIOUTCAPSA
-  TMIDIOUTCAPSA* = MIDIOUTCAPSA
-  MIDIOUTCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    wTechnology*: int16
-    wVoices*: int16
-    wNotes*: int16
-    wChannelMask*: int16
-    dwSupport*: DWORD
-
-  PMIDIOUTCAPSW* = ptr MIDIOUTCAPSW
-  NPMIDIOUTCAPSW* = ptr MIDIOUTCAPSW
-  LPMIDIOUTCAPSW* = ptr MIDIOUTCAPSW
-  TMIDIOUTCAPSW* = MIDIOUTCAPSW
-  MIDIINCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    dwSupport*: DWORD
-
-  PMIDIINCAPSA* = ptr MIDIINCAPSA
-  NPMIDIINCAPSA* = ptr MIDIINCAPSA
-  LPMIDIINCAPSA* = ptr MIDIINCAPSA
-  TMIDIINCAPSA* = MIDIINCAPSA
-  MIDIINCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    dwSupport*: DWORD
-
-  PMIDIINCAPSW* = ptr MIDIINCAPSW
-  NPMIDIINCAPSW* = ptr MIDIINCAPSW
-  LPMIDIINCAPSW* = ptr MIDIINCAPSW
-  TMIDIINCAPSW* = MIDIINCAPSW
-
-when defined(UNICODE):
-  type
-    MIDIINCAPS* = MIDIINCAPSW
-    PMIDIINCAPS* = PMIDIINCAPSW
-    NPMIDIINCAPS* = NPMIDIINCAPSW
-    LPMIDIINCAPS* = LPMIDIINCAPSW
-    MIDIOUTCAPS* = MIDIOUTCAPSW
-    PMIDIOUTCAPS* = PMIDIOUTCAPSW
-    NPMIDIOUTCAPS* = NPMIDIOUTCAPSW
-    LPMIDIOUTCAPS* = LPMIDIOUTCAPSW
-else:
-  type
-    MIDIOUTCAPS* = MIDIOUTCAPSA
-    PMIDIOUTCAPS* = PMIDIOUTCAPSA
-    NPMIDIOUTCAPS* = NPMIDIOUTCAPSA
-    LPMIDIOUTCAPS* = LPMIDIOUTCAPSA
-    MIDIINCAPS* = MIDIINCAPSA
-    PMIDIINCAPS* = PMIDIINCAPSA
-    NPMIDIINCAPS* = NPMIDIINCAPSA
-    LPMIDIINCAPS* = LPMIDIINCAPSA
-type
-  TMIDIINCAPS* = MIDIINCAPS
-  PMIDIHDR* = ptr midihdr
-  midihdr* {.final.} = object
-    lpData*: cstring
-    dwBufferLength*: DWORD
-    dwBytesRecorded*: DWORD
-    dwUser*: DWORD
-    dwFlags*: DWORD
-    lpNext*: PMIDIHDR
-    reserved*: DWORD
-    dwOffset*: DWORD
-    dwReserved*: array[0..Pred(8), DWORD]
-
-  NPMIDIHDR* = ptr midihdr
-  LPMIDIHDR* = ptr midihdr
-  TMIDIHDR* = MIDIHDR
-  midievent* {.final.} = object
-    dwDeltaTime*: DWORD
-    dwStreamID*: DWORD
-    dwEvent*: DWORD
-    dwParms*: array[0..Pred(1), DWORD]
-
-  TMIDIEVENT* = MIDIEVENT
-  midistrmbuffver* {.final.} = object
-    dwVersion*: DWORD
-    dwMid*: DWORD
-    dwOEMVersion*: DWORD
-
-  TMIDISTRMBUFFVER* = MIDISTRMBUFFVER
-  Tmidiproptimediv* {.final.} = object
-    cbStruct*: DWORD
-    dwTimeDiv*: DWORD
-
-  LPMIDIPROPTIMEDIV* = ptr Tmidiproptimediv
-  Tmidiproptempo* {.final.} = object
-    cbStruct*: DWORD
-    dwTempo*: DWORD
-
-  LPMIDIPROPTEMPO* = ptr Tmidiproptempo
-  AUXCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    wTechnology*: int16
-    wReserved1*: int16
-    dwSupport*: DWORD
-
-  PAUXCAPSA* = ptr AUXCAPSA
-  NPAUXCAPSA* = ptr AUXCAPSA
-  LPAUXCAPSA* = ptr AUXCAPSA
-  TAUXCAPSA* = AUXCAPSA
-  AUXCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    wTechnology*: int16
-    wReserved1*: int16
-    dwSupport*: DWORD
-
-  PAUXCAPSW* = ptr AUXCAPSW
-  NPAUXCAPSW* = ptr AUXCAPSW
-  LPAUXCAPSW* = ptr AUXCAPSW
-  TAUXCAPSW* = AUXCAPSW
-
-when defined(UNICODE):
-  type
-    AUXCAPS* = AUXCAPSW
-    PAUXCAPS* = PAUXCAPSW
-    NPAUXCAPS* = NPAUXCAPSW
-    LPAUXCAPS* = LPAUXCAPSW
-else:
-  type
-    AUXCAPS* = AUXCAPSA
-    PAUXCAPS* = PAUXCAPSA
-    NPAUXCAPS* = NPAUXCAPSA
-    LPAUXCAPS* = LPAUXCAPSA
-type
-  TAUXCAPS* = AUXCAPS
-  HMIXEROBJ* = THandle
-  LPHMIXEROBJ* = ptr HMIXEROBJ
-  HMIXER* = THandle
-  LPHMIXER* = ptr HMIXER
-
-proc mixerGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                               importc: "mixerGetNumDevs".}
-type
-  MIXERCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    fdwSupport*: DWORD
-    cDestinations*: DWORD
-
-  PMIXERCAPSA* = ptr MIXERCAPSA
-  LPMIXERCAPSA* = ptr MIXERCAPSA
-  TMIXERCAPSA* = MIXERCAPSA
-  MIXERCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    fdwSupport*: DWORD
-    cDestinations*: DWORD
-
-  PMIXERCAPSW* = ptr MIXERCAPSW
-  LPMIXERCAPSW* = ptr MIXERCAPSW
-  TMIXERCAPSW* = MIXERCAPSW
-
-when defined(UNICODE):
-  type
-    MIXERCAPS* = MIXERCAPSW
-    PMIXERCAPS* = PMIXERCAPSW
-    LPMIXERCAPS* = LPMIXERCAPSW
-else:
-  type
-    MIXERCAPS* = MIXERCAPSA
-    PMIXERCAPS* = PMIXERCAPSA
-    LPMIXERCAPS* = LPMIXERCAPSA
-type
-  TMIXERCAPS* = MIXERCAPS
-  MIXERLINEA* {.final.} = object
-    cbStruct*: DWORD
-    dwDestination*: DWORD
-    dwSource*: DWORD
-    dwLineID*: DWORD
-    fdwLine*: DWORD
-    dwUser*: DWORD
-    dwComponentType*: DWORD
-    cChannels*: DWORD
-    cConnections*: DWORD
-    cControls*: DWORD
-    szShortName*: array[0..Pred(MIXER_SHORT_NAME_CHARS), CHAR]
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), CHAR]
-    dwType*, dwDeviceID*: DWORD
-    wMid*, wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..pred(MAXPNAMELEN), Char]
-
-  PMIXERLINEA* = ptr MIXERLINEA
-  LPMIXERLINEA* = ptr MIXERLINEA
-  TMIXERLINEA* = MIXERLINEA
-  MIXERLINEW* {.final.} = object
-    cbStruct*: DWORD
-    dwDestination*: DWORD
-    dwSource*: DWORD
-    dwLineID*: DWORD
-    fdwLine*: DWORD
-    dwUser*: DWORD
-    dwComponentType*: DWORD
-    cChannels*: DWORD
-    cConnections*: DWORD
-    cControls*: DWORD
-    szShortName*: array[0..Pred(MIXER_SHORT_NAME_CHARS), WCHAR]
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), WCHAR]
-    dwType*, dwDeviceID*: DWORD
-    wMid*, wPid*: int16
-    vDriverVersion*: MMVERSION
-    szPname*: array[0..pred(MAXPNAMELEN), WChar]
-
-  TMIXERLINEW* = MIXERLINEW
-  PMIXERLINEW* = ptr MIXERLINEW
-  LPMIXERLINEW* = ptr MIXERLINEW
-
-when defined(UNICODE):
-  type
-    MIXERLINE* = MIXERLINEW
-    PMIXERLINE* = PMIXERLINEW
-    LPMIXERLINE* = LPMIXERLINEW
-else:
-  type
-    MIXERLINE* = MIXERLINEA
-    PMIXERLINE* = PMIXERLINEA
-    LPMIXERLINE* = LPMIXERLINEA
-type
-  TMIXERLINE* = MIXERLINE
-  MIXERCONTROLA* {.final.} = object
-    cbStruct*: DWORD
-    dwControlID*: DWORD
-    dwControlType*: DWORD
-    fdwControl*: DWORD
-    cMultipleItems*: DWORD
-    szShortName*: array[0..Pred(MIXER_SHORT_NAME_CHARS), CHAR]
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), CHAR]
-    dwMinimum*, dwMaximum*: DWORD
-    dwReserved*: array[0..3, DWORD]
-    cSteps*: DWORD
-    dwReserved2*: array[0..4, DWORD]
-
-  PMIXERCONTROLA* = ptr MIXERCONTROLA
-  LPMIXERCONTROLA* = ptr MIXERCONTROLA
-  TMIXERCONTROLA* = MIXERCONTROLA
-  MIXERCONTROLW* {.final.} = object
-    cbStruct*: DWORD
-    dwControlID*: DWORD
-    dwControlType*: DWORD
-    fdwControl*: DWORD
-    cMultipleItems*: DWORD
-    szShortName*: array[0..Pred(MIXER_SHORT_NAME_CHARS), WCHAR]
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), WCHAR]
-    dwMinimum*, dwMaximum*: DWORD
-    dwReserved*: array[0..3, DWORD]
-    cSteps*: DWORD
-    dwReserved2*: array[0..4, DWORD]
-
-  PMIXERCONTROLW* = ptr MIXERCONTROLW
-  LPMIXERCONTROLW* = ptr MIXERCONTROLW
-  TMIXERCONTROLW* = MIXERCONTROLW
-
-when defined(UNICODE):
-  type
-    MIXERCONTROL* = MIXERCONTROLW
-    PMIXERCONTROL* = PMIXERCONTROLW
-    LPMIXERCONTROL* = LPMIXERCONTROLW
-else:
-  type
-    MIXERCONTROL* = MIXERCONTROLA
-    PMIXERCONTROL* = PMIXERCONTROLA
-    LPMIXERCONTROL* = LPMIXERCONTROLA
-type
-  TMIXERCONTROL* = MIXERCONTROL
-  MIXERLINECONTROLSA* {.final.} = object
-    cbStruct*: DWORD
-    dwLineID*: DWORD
-    dwControlType*, cControls*, cbmxctrl*: DWORD
-    pamxctrl*: PMIXERCONTROLA
-
-  PMIXERLINECONTROLSA* = ptr MIXERLINECONTROLSA
-  LPMIXERLINECONTROLSA* = ptr MIXERLINECONTROLSA
-  TMIXERLINECONTROLSA* = MIXERLINECONTROLSA
-  MIXERLINECONTROLSW* {.final.} = object
-    cbStruct*: DWORD
-    dwLineID*: DWORD
-    dwControlType*, cControls*, cbmxctrl*: DWORD
-    pamxctrl*: PMIXERCONTROLW
-
-  PMIXERLINECONTROLSW* = ptr MIXERLINECONTROLSW
-  LPMIXERLINECONTROLSW* = ptr MIXERLINECONTROLSW
-  TMIXERLINECONTROLSW* = MIXERLINECONTROLSW
-
-when defined(UNICODE):
-  type
-    MIXERLINECONTROLS* = MIXERLINECONTROLSW
-    PMIXERLINECONTROLS* = PMIXERLINECONTROLSW
-    LPMIXERLINECONTROLS* = LPMIXERLINECONTROLSW
-else:
-  type
-    MIXERLINECONTROLS* = MIXERLINECONTROLSA
-    PMIXERLINECONTROLS* = PMIXERLINECONTROLSA
-    LPMIXERLINECONTROLS* = LPMIXERLINECONTROLSA
-type
-  TMIXERLINECONTROLS* = MIXERLINECONTROLS
-  TMIXERCONTROLDETAILS* {.final.} = object
-    cbStruct*: DWORD
-    dwControlID*: DWORD
-    cChannels*: DWORD
-    cMultipleItems*, cbDetails*: DWORD
-    paDetails*: Pointer
-
-  MIXERCONTROLDETAILS* = tMIXERCONTROLDETAILS
-  PMIXERCONTROLDETAILS* = ptr tMIXERCONTROLDETAILS
-  LPMIXERCONTROLDETAILS* = ptr tMIXERCONTROLDETAILS
-  MIXERCONTROLDETAILS_LISTTEXTA* {.final.} = object
-    dwParam1*: DWORD
-    dwParam2*: DWORD
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), CHAR]
-
-  PMIXERCONTROLDETAILS_LISTTEXTA* = ptr MIXERCONTROLDETAILS_LISTTEXTA
-  LPMIXERCONTROLDETAILS_LISTTEXTA* = ptr MIXERCONTROLDETAILS_LISTTEXTA
-  TMIXERCONTROLDETAILS_LISTTEXTA* = MIXERCONTROLDETAILS_LISTTEXTA
-  MIXERCONTROLDETAILS_LISTTEXTW* {.final.} = object
-    dwParam1*: DWORD
-    dwParam2*: DWORD
-    szName*: array[0..Pred(MIXER_LONG_NAME_CHARS), WCHAR]
-
-  PMIXERCONTROLDETAILS_LISTTEXTW* = ptr MIXERCONTROLDETAILS_LISTTEXTW
-  LPMIXERCONTROLDETAILS_LISTTEXTW* = ptr MIXERCONTROLDETAILS_LISTTEXTW
-  TMIXERCONTROLDETAILS_LISTTEXTW* = MIXERCONTROLDETAILS_LISTTEXTW
-
-when defined(UNICODE):
-  type
-    MIXERCONTROLDETAILS_LISTTEXT* = MIXERCONTROLDETAILS_LISTTEXTW
-    PMIXERCONTROLDETAILS_LISTTEXT* = PMIXERCONTROLDETAILS_LISTTEXTW
-    LPMIXERCONTROLDETAILS_LISTTEXT* = LPMIXERCONTROLDETAILS_LISTTEXTW
-else:
-  type
-    MIXERCONTROLDETAILS_LISTTEXT* = MIXERCONTROLDETAILS_LISTTEXTA
-    PMIXERCONTROLDETAILS_LISTTEXT* = PMIXERCONTROLDETAILS_LISTTEXTA
-    LPMIXERCONTROLDETAILS_LISTTEXT* = LPMIXERCONTROLDETAILS_LISTTEXTA
-type
-  TMIXERCONTROLDETAILS_LISTTEXT* = MIXERCONTROLDETAILS_LISTTEXT
-  MIXERCONTROLDETAILS_BOOLEAN* {.final.} = object
-    fValue*: int32
-
-  PMIXERCONTROLDETAILS_BOOLEAN* = ptr MIXERCONTROLDETAILS_BOOLEAN
-  LPMIXERCONTROLDETAILS_BOOLEAN* = ptr MIXERCONTROLDETAILS_BOOLEAN
-  TMIXERCONTROLDETAILS_BOOLEAN* = MIXERCONTROLDETAILS_BOOLEAN
-  MIXERCONTROLDETAILS_SIGNED* {.final.} = object
-    lValue*: int32
-
-  PMIXERCONTROLDETAILS_SIGNED* = ptr MIXERCONTROLDETAILS_SIGNED
-  LPMIXERCONTROLDETAILS_SIGNED* = ptr MIXERCONTROLDETAILS_SIGNED
-  TMIXERCONTROLDETAILS_SIGNED* = MIXERCONTROLDETAILS_SIGNED
-  MIXERCONTROLDETAILS_UNSIGNED* {.final.} = object
-    dwValue*: DWORD
-
-  PMIXERCONTROLDETAILS_UNSIGNED* = ptr MIXERCONTROLDETAILS_UNSIGNED
-  LPMIXERCONTROLDETAILS_UNSIGNED* = ptr MIXERCONTROLDETAILS_UNSIGNED
-  TMIXERCONTROLDETAILS_UNSIGNED* = MIXERCONTROLDETAILS_UNSIGNED
-  LPTIMECALLBACK* = proc (uTimerID, uMsg: UINT, dwUser, dw1, dw2: DWORD){.
-      stdcall.}
-  TTIMECALLBACK* = LPTIMECALLBACK
-  timecaps* {.final.} = object
-    wPeriodMin*: UINT
-    wPeriodMax*: UINT
-
-  PTIMECAPS* = ptr timecaps
-  NPTIMECAPS* = ptr timecaps
-  LPTIMECAPS* = ptr timecaps
-  TTIMECAS* = TIMECAPS
-  JOYCAPSA* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    szPname*: array[0..Pred(MAXPNAMELEN), CHAR]
-    wXmin*: UINT
-    wXmax*: UINT
-    wYmin*: UINT
-    wYmax*: UINT
-    wZmin*: UINT
-    wZmax*: UINT
-    wNumButtons*: UINT
-    wPeriodMin*: UINT
-    wPeriodMax*: UINT
-    wRmin*: UINT
-    wRmax*: UINT
-    wUmin*: UINT
-    wUmax*: UINT
-    wVmin*: UINT
-    wVmax*: UINT
-    wCaps*: UINT
-    wMaxAxes*: UINT
-    wNumAxes*: UINT
-    wMaxButtons*: UINT
-    szRegKey*: array[0..Pred(MAXPNAMELEN), CHAR]
-    szOEMVxD*: array[0..Pred(MAX_JOYSTICKOEMVXDNAME), CHAR]
-
-  PJOYCAPSA* = ptr JOYCAPSA
-  NPJOYCAPSA* = ptr JOYCAPSA
-  LPJOYCAPSA* = ptr JOYCAPSA
-  TJOYCAPSA* = JOYCAPSA
-  JOYCAPSW* {.final.} = object
-    wMid*: int16
-    wPid*: int16
-    szPname*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    wXmin*: UINT
-    wXmax*: UINT
-    wYmin*: UINT
-    wYmax*: UINT
-    wZmin*: UINT
-    wZmax*: UINT
-    wNumButtons*: UINT
-    wPeriodMin*: UINT
-    wPeriodMax*: UINT
-    wRmin*: UINT
-    wRmax*: UINT
-    wUmin*: UINT
-    wUmax*: UINT
-    wVmin*: UINT
-    wVmax*: UINT
-    wCaps*: UINT
-    wMaxAxes*: UINT
-    wNumAxes*: UINT
-    wMaxButtons*: UINT
-    szRegKey*: array[0..Pred(MAXPNAMELEN), WCHAR]
-    szOEMVxD*: array[0..Pred(MAX_JOYSTICKOEMVXDNAME), WCHAR]
-
-  PJOYCAPSW* = ptr JOYCAPSW
-  NPJOYCAPSW* = ptr JOYCAPSW
-  LPJOYCAPSW* = ptr JOYCAPSW
-  TJOYCAPSW* = JOYCAPSW
-
-when defined(UNICODE):
-  type
-    JOYCAPS* = JOYCAPSW
-    PJOYCAPS* = PJOYCAPSW
-    NPJOYCAPS* = NPJOYCAPSW
-    LPJOYCAPS* = LPJOYCAPSW
-else:
-  type
-    JOYCAPS* = JOYCAPSA
-    PJOYCAPS* = PJOYCAPSA
-    NPJOYCAPS* = NPJOYCAPSA
-    LPJOYCAPS* = LPJOYCAPSA
-type
-  TJOYCAPS* = JOYCAPS
-  joyinfo* {.final.} = object
-    wXpos*: UINT
-    wYpos*: UINT
-    wZpos*: UINT
-    wButtons*: UINT
-
-  PJOYINFO* = ptr joyinfo
-  NPJOYINFO* = ptr joyinfo
-  LPJOYINFO* = ptr joyinfo
-  TJOYINFO* = JOYINFO
-  joyinfoex* {.final.} = object
-    dwSize*: DWORD
-    dwFlags*: DWORD
-    wXpos*: UINT
-    wYpos*: UINT
-    wZpos*: UINT
-    dwRpos*: DWORD
-    dwUpos*: DWORD
-    dwVpos*: DWORD
-    wButtons*: UINT
-    dwButtonNumber*: DWORD
-    dwPOV*: DWORD
-    dwReserved1*: DWORD
-    dwReserved2*: DWORD
-
-  PJOYINFOEX* = ptr joyinfoex
-  NPJOYINFOEX* = ptr joyinfoex
-  LPJOYINFOEX* = ptr joyinfoex
-  TJOYINFOEX* = JOYINFOEX
-  FOURCC* = DWORD
-  HPSTR* = cstring
-  HMMIO* = THandle
-  LPMMIOPROC* = proc (x1: LPSTR, x2: UINT, x3, x4: LPARAM): LRESULT{.stdcall.}
-  TMMIOPROC* = LPMMIOPROC
-  MMIOINFO* {.final.} = object
-    dwFlags*: DWORD
-    fccIOProc*: FOURCC
-    pIOProc*: LPMMIOPROC
-    wErrorRet*: UINT
-    htask*: HTASK
-    cchBuffer*: int32
-    pchBuffer*: HPSTR
-    pchNext*: HPSTR
-    pchEndRead*: HPSTR
-    pchEndWrite*: HPSTR
-    lBufOffset*: int32
-    lDiskOffset*: int32
-    adwInfo*: array[0..Pred(3), DWORD]
-    dwReserved1*: DWORD
-    dwReserved2*: DWORD
-    hmmio*: HMMIO
-
-  PMMIOINFO* = ptr MMIOINFO
-  NPMMIOINFO* = ptr MMIOINFO
-  LPMMIOINFO* = ptr MMIOINFO
-  LPCMMIOINFO* = ptr MMIOINFO
-  TMMIOINFO* = MMIOINFO
-  MMCKINFO* {.final.} = object
-    ckid*: FOURCC
-    cksize*: DWORD
-    fccType*: FOURCC
-    dwDataOffset*: DWORD
-    dwFlags*: DWORD
-
-  PMMCKINFO* = ptr MMCKINFO
-  NPMMCKINFO* = ptr MMCKINFO
-  LPMMCKINFO* = ptr MMCKINFO
-  LPCMMCKINFO* = ptr MMCKINFO
-  TMMCKINFO* = MMCKINFO
-  MCIERROR* = DWORD
-  MCIDEVICEID* = UINT
-  YIELDPROC* = proc (mciId: MCIDEVICEID, dwYieldData: DWORD): UINT{.stdcall.}
-  TYIELDPROC* = YIELDPROC
-  MCI_GENERIC_PARMS* {.final.} = object
-    dwCallback*: DWORD
-
-  PMCI_GENERIC_PARMS* = ptr MCI_GENERIC_PARMS
-  LPMCI_GENERIC_PARMS* = ptr MCI_GENERIC_PARMS
-  TMCI_GENERIC_PARMS* = MCI_GENERIC_PARMS
-  MCI_OPEN_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCSTR
-    lpstrElementName*: LPCSTR
-    lpstrAlias*: LPCSTR
-
-  PMCI_OPEN_PARMSA* = ptr MCI_OPEN_PARMSA
-  LPMCI_OPEN_PARMSA* = ptr MCI_OPEN_PARMSA
-  TMCI_OPEN_PARMSA* = MCI_OPEN_PARMSA
-  MCI_OPEN_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCWSTR
-    lpstrElementName*: LPCWSTR
-    lpstrAlias*: LPCWSTR
-
-  PMCI_OPEN_PARMSW* = ptr MCI_OPEN_PARMSW
-  LPMCI_OPEN_PARMSW* = ptr MCI_OPEN_PARMSW
-  TMCI_OPEN_PARMSW* = MCI_OPEN_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_OPEN_PARMS* = MCI_OPEN_PARMSW
-    PMCI_OPEN_PARMS* = PMCI_OPEN_PARMSW
-    LPMCI_OPEN_PARMS* = LPMCI_OPEN_PARMSW
-else:
-  type
-    MCI_OPEN_PARMS* = MCI_OPEN_PARMSA
-    PMCI_OPEN_PARMS* = PMCI_OPEN_PARMSA
-    LPMCI_OPEN_PARMS* = LPMCI_OPEN_PARMSA
-type
-  TMCI_OPEN_PARMS* = MCI_OPEN_PARMS
-  MCI_PLAY_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrom*: DWORD
-    dwTo*: DWORD
-
-  PMCI_PLAY_PARMS* = ptr MCI_PLAY_PARMS
-  LPMCI_PLAY_PARMS* = ptr MCI_PLAY_PARMS
-  TMCI_PLAY_PARMS* = MCI_PLAY_PARMS
-  MCI_SEEK_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwTo*: DWORD
-
-  PMCI_SEEK_PARMS* = ptr MCI_SEEK_PARMS
-  LPMCI_SEEK_PARMS* = ptr MCI_SEEK_PARMS
-  TMCI_SEEK_PARMS* = MCI_SEEK_PARMS
-  MCI_STATUS_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwReturn*: DWORD
-    dwItem*: DWORD
-    dwTrack*: DWORD
-
-  PMCI_STATUS_PARMS* = ptr MCI_STATUS_PARMS
-  LPMCI_STATUS_PARMS* = ptr MCI_STATUS_PARMS
-  TMCI_STATUS_PARMS* = MCI_STATUS_PARMS
-  MCI_INFO_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpstrReturn*: cstring
-    dwRetSize*: DWORD
-
-  LPMCI_INFO_PARMSA* = ptr MCI_INFO_PARMSA
-  TMCI_INFO_PARMSA* = MCI_INFO_PARMSA
-  MCI_INFO_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpstrReturn*: LPWSTR
-    dwRetSize*: DWORD
-
-  LPMCI_INFO_PARMSW* = ptr MCI_INFO_PARMSW
-  TMCI_INFO_PARMSW* = MCI_INFO_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_INFO_PARMS* = MCI_INFO_PARMSW
-    LPMCI_INFO_PARMS* = LPMCI_INFO_PARMSW
-else:
-  type
-    MCI_INFO_PARMS* = MCI_INFO_PARMSA
-    LPMCI_INFO_PARMS* = LPMCI_INFO_PARMSA
-type
-  TMCI_INFO_PARMS* = MCI_INFO_PARMS
-  MCI_GETDEVCAPS_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwReturn*: DWORD
-    dwItem*: DWORD
-
-  PMCI_GETDEVCAPS_PARMS* = ptr MCI_GETDEVCAPS_PARMS
-  LPMCI_GETDEVCAPS_PARMS* = ptr MCI_GETDEVCAPS_PARMS
-  TMCI_GETDEVCAPS_PARMS* = MCI_GETDEVCAPS_PARMS
-  MCI_SYSINFO_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpstrReturn*: cstring
-    dwRetSize*: DWORD
-    dwNumber*: DWORD
-    wDeviceType*: UINT
-
-  PMCI_SYSINFO_PARMSA* = ptr MCI_SYSINFO_PARMSA
-  LPMCI_SYSINFO_PARMSA* = ptr MCI_SYSINFO_PARMSA
-  TMCI_SYSINFO_PARMSA* = MCI_SYSINFO_PARMSA
-  MCI_SYSINFO_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpstrReturn*: LPWSTR
-    dwRetSize*: DWORD
-    dwNumber*: DWORD
-    wDeviceType*: UINT
-
-  PMCI_SYSINFO_PARMSW* = ptr MCI_SYSINFO_PARMSW
-  LPMCI_SYSINFO_PARMSW* = ptr MCI_SYSINFO_PARMSW
-  TMCI_SYSINFO_PARMSW* = MCI_SYSINFO_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_SYSINFO_PARMS* = MCI_SYSINFO_PARMSW
-    PMCI_SYSINFO_PARMS* = PMCI_SYSINFO_PARMSW
-    LPMCI_SYSINFO_PARMS* = LPMCI_SYSINFO_PARMSW
-else:
-  type
-    MCI_SYSINFO_PARMS* = MCI_SYSINFO_PARMSA
-    PMCI_SYSINFO_PARMS* = PMCI_SYSINFO_PARMSA
-    LPMCI_SYSINFO_PARMS* = LPMCI_SYSINFO_PARMSA
-type
-  TMCI_SYSINFO_PARMS* = MCI_SYSINFO_PARMS
-  MCI_SET_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwTimeFormat*: DWORD
-    dwAudio*: DWORD
-
-  PMCI_SET_PARMS* = ptr MCI_SET_PARMS
-  LPMCI_SET_PARMS* = ptr MCI_SET_PARMS
-  TMCI_SET_PARMS* = MCI_SET_PARMS
-  MCI_BREAK_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    nVirtKey*: int32
-    hwndBreak*: HWND
-
-  PMCI_BREAK_PARMS* = ptr MCI_BREAK_PARMS
-  LPMCI_BREAK_PARMS* = ptr MCI_BREAK_PARMS
-  TMCI_BREAK_PARMS* = MCI_BREAK_PARMS
-  MCI_SAVE_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCSTR
-
-  PMCI_SAVE_PARMSA* = ptr MCI_SAVE_PARMSA
-  LPMCI_SAVE_PARMSA* = ptr MCI_SAVE_PARMSA
-  TMCI_SAVE_PARMSA* = MCI_SAVE_PARMSA
-  MCI_SAVE_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCWSTR
-
-  PMCI_SAVE_PARMSW* = ptr MCI_SAVE_PARMSW
-  LPMCI_SAVE_PARMSW* = ptr MCI_SAVE_PARMSW
-  TMCI_SAVE_PARMSW* = MCI_SAVE_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_SAVE_PARMS* = MCI_SAVE_PARMSW
-    PMCI_SAVE_PARMS* = PMCI_SAVE_PARMSW
-    LPMCI_SAVE_PARMS* = LPMCI_SAVE_PARMSW
-else:
-  type
-    MCI_SAVE_PARMS* = MCI_SAVE_PARMSA
-    PMCI_SAVE_PARMS* = PMCI_SAVE_PARMSA
-    LPMCI_SAVE_PARMS* = LPMCI_SAVE_PARMSA
-type
-  TMCI_SAVE_PARMS* = MCI_SAVE_PARMS
-  MCI_LOAD_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCSTR
-
-  PMCI_LOAD_PARMSA* = ptr MCI_LOAD_PARMSA
-  LPMCI_LOAD_PARMSA* = ptr MCI_LOAD_PARMSA
-  TMCI_LOAD_PARMSA* = MCI_LOAD_PARMSA
-  MCI_LOAD_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCWSTR
-
-  PMCI_LOAD_PARMSW* = ptr MCI_LOAD_PARMSW
-  LPMCI_LOAD_PARMSW* = ptr MCI_LOAD_PARMSW
-  TMCI_LOAD_PARMSW* = MCI_LOAD_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_LOAD_PARMS* = MCI_LOAD_PARMSW
-    PMCI_LOAD_PARMS* = PMCI_LOAD_PARMSW
-    LPMCI_LOAD_PARMS* = LPMCI_LOAD_PARMSW
-else:
-  type
-    MCI_LOAD_PARMS* = MCI_LOAD_PARMSA
-    PMCI_LOAD_PARMS* = PMCI_LOAD_PARMSA
-    LPMCI_LOAD_PARMS* = LPMCI_LOAD_PARMSA
-type
-  TMCI_LOAD_PARMS* = MCI_LOAD_PARMS
-  MCI_RECORD_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrom*: DWORD
-    dwTo*: DWORD
-
-  LPMCI_RECORD_PARMS* = ptr MCI_RECORD_PARMS
-  TMCI_RECORD_PARMS* = MCI_RECORD_PARMS
-  MCI_VD_PLAY_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrom*: DWORD
-    dwTo*: DWORD
-    dwSpeed*: DWORD
-
-  PMCI_VD_PLAY_PARMS* = ptr MCI_VD_PLAY_PARMS
-  LPMCI_VD_PLAY_PARMS* = ptr MCI_VD_PLAY_PARMS
-  TMCI_VD_PLAY_PARMS* = MCI_VD_PLAY_PARMS
-  MCI_VD_STEP_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrames*: DWORD
-
-  PMCI_VD_STEP_PARMS* = ptr MCI_VD_STEP_PARMS
-  LPMCI_VD_STEP_PARMS* = ptr MCI_VD_STEP_PARMS
-  MCI_VD_ESCAPE_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpstrCommand*: LPCSTR
-
-  PMCI_VD_ESCAPE_PARMSA* = ptr MCI_VD_ESCAPE_PARMSA
-  LPMCI_VD_ESCAPE_PARMSA* = ptr MCI_VD_ESCAPE_PARMSA
-  TMCI_VD_ESCAPE_PARMSA* = MCI_VD_ESCAPE_PARMSA
-  MCI_VD_ESCAPE_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpstrCommand*: LPCWSTR
-
-  PMCI_VD_ESCAPE_PARMSW* = ptr MCI_VD_ESCAPE_PARMSW
-  LPMCI_VD_ESCAPE_PARMSW* = ptr MCI_VD_ESCAPE_PARMSW
-  TMCI_VD_ESCAPE_PARMSW* = MCI_VD_ESCAPE_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_VD_ESCAPE_PARMS* = MCI_VD_ESCAPE_PARMSW
-    PMCI_VD_ESCAPE_PARMS* = PMCI_VD_ESCAPE_PARMSW
-    LPMCI_VD_ESCAPE_PARMS* = LPMCI_VD_ESCAPE_PARMSW
-else:
-  type
-    MCI_VD_ESCAPE_PARMS* = MCI_VD_ESCAPE_PARMSA
-    PMCI_VD_ESCAPE_PARMS* = PMCI_VD_ESCAPE_PARMSA
-    LPMCI_VD_ESCAPE_PARMS* = LPMCI_VD_ESCAPE_PARMSA
-type
-  TMCI_VD_ESCAPE_PARMS* = MCI_VD_ESCAPE_PARMS
-  MCI_WAVE_OPEN_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCSTR
-    lpstrElementName*: LPCSTR
-    lpstrAlias*: LPCSTR
-    dwBufferSeconds*: DWORD
-
-  PMCI_WAVE_OPEN_PARMSA* = ptr MCI_WAVE_OPEN_PARMSA
-  LPMCI_WAVE_OPEN_PARMSA* = ptr MCI_WAVE_OPEN_PARMSA
-  TMCI_WAVE_OPEN_PARMSA* = MCI_WAVE_OPEN_PARMSA
-  MCI_WAVE_OPEN_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCWSTR
-    lpstrElementName*: LPCWSTR
-    lpstrAlias*: LPCWSTR
-    dwBufferSeconds*: DWORD
-
-  PMCI_WAVE_OPEN_PARMSW* = ptr MCI_WAVE_OPEN_PARMSW
-  LPMCI_WAVE_OPEN_PARMSW* = ptr MCI_WAVE_OPEN_PARMSW
-  TMCI_WAVE_OPEN_PARMSW* = MCI_WAVE_OPEN_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_WAVE_OPEN_PARMS* = MCI_WAVE_OPEN_PARMSW
-    PMCI_WAVE_OPEN_PARMS* = PMCI_WAVE_OPEN_PARMSW
-    LPMCI_WAVE_OPEN_PARMS* = LPMCI_WAVE_OPEN_PARMSW
-else:
-  type
-    MCI_WAVE_OPEN_PARMS* = MCI_WAVE_OPEN_PARMSA
-    PMCI_WAVE_OPEN_PARMS* = PMCI_WAVE_OPEN_PARMSA
-    LPMCI_WAVE_OPEN_PARMS* = LPMCI_WAVE_OPEN_PARMSA
-type
-  TMCI_WAVE_OPEN_PARMS* = MCI_WAVE_OPEN_PARMS
-  MCI_WAVE_DELETE_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrom*: DWORD
-    dwTo*: DWORD
-
-  PMCI_WAVE_DELETE_PARMS* = ptr MCI_WAVE_DELETE_PARMS
-  LPMCI_WAVE_DELETE_PARMS* = ptr MCI_WAVE_DELETE_PARMS
-  TMCI_WAVE_DELETE_PARMS* = MCI_WAVE_DELETE_PARMS
-  MCI_WAVE_SET_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwTimeFormat*: DWORD
-    dwAudio*: DWORD
-    wInput*: UINT
-    wOutput*: UINT
-    wFormatTag*: int16
-    wReserved2*: int16
-    nChannels*: int16
-    wReserved3*: int16
-    nSamplesPerSec*: DWORD
-    nAvgBytesPerSec*: DWORD
-    nBlockAlign*: int16
-    wReserved4*: int16
-    wBitsPerSample*: int16
-    wReserved5*: int16
-
-  PMCI_WAVE_SET_PARMS* = ptr MCI_WAVE_SET_PARMS
-  LPMCI_WAVE_SET_PARMS* = ptr MCI_WAVE_SET_PARMS
-  TMCI_WAVE_SET_PARMS* = MCI_WAVE_SET_PARMS
-  MCI_SEQ_SET_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwTimeFormat*: DWORD
-    dwAudio*: DWORD
-    dwTempo*: DWORD
-    dwPort*: DWORD
-    dwSlave*: DWORD
-    dwMaster*: DWORD
-    dwOffset*: DWORD
-
-  PMCI_SEQ_SET_PARMS* = ptr MCI_SEQ_SET_PARMS
-  LPMCI_SEQ_SET_PARMS* = ptr MCI_SEQ_SET_PARMS
-  TMCI_SEQ_SET_PARMS* = MCI_SEQ_SET_PARMS
-  MCI_ANIM_OPEN_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCSTR
-    lpstrElementName*: LPCSTR
-    lpstrAlias*: LPCSTR
-    dwStyle*: DWORD
-    hWndParent*: HWND
-
-  PMCI_ANIM_OPEN_PARMSA* = ptr MCI_ANIM_OPEN_PARMSA
-  LPMCI_ANIM_OPEN_PARMSA* = ptr MCI_ANIM_OPEN_PARMSA
-  TMCI_ANIM_OPEN_PARMSA* = MCI_ANIM_OPEN_PARMSA
-  MCI_ANIM_OPEN_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCWSTR
-    lpstrElementName*: LPCWSTR
-    lpstrAlias*: LPCWSTR
-    dwStyle*: DWORD
-    hWndParent*: HWND
-
-  PMCI_ANIM_OPEN_PARMSW* = ptr MCI_ANIM_OPEN_PARMSW
-  LPMCI_ANIM_OPEN_PARMSW* = ptr MCI_ANIM_OPEN_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_ANIM_OPEN_PARMS* = MCI_ANIM_OPEN_PARMSW
-    PMCI_ANIM_OPEN_PARMS* = PMCI_ANIM_OPEN_PARMSW
-    LPMCI_ANIM_OPEN_PARMS* = LPMCI_ANIM_OPEN_PARMSW
-else:
-  type
-    MCI_ANIM_OPEN_PARMS* = MCI_ANIM_OPEN_PARMSA
-    PMCI_ANIM_OPEN_PARMS* = PMCI_ANIM_OPEN_PARMSA
-    LPMCI_ANIM_OPEN_PARMS* = LPMCI_ANIM_OPEN_PARMSA
-type
-  TMCI_ANIM_OPEN_PARMS* = MCI_ANIM_OPEN_PARMS
-  MCI_ANIM_WINDOW_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    hWnd*: HWND
-    nCmdShow*: UINT
-    lpstrText*: LPCWSTR
-
-  PMCI_ANIM_WINDOW_PARMSW* = ptr MCI_ANIM_WINDOW_PARMSW
-  LPMCI_ANIM_WINDOW_PARMSW* = ptr MCI_ANIM_WINDOW_PARMSW
-  TMCI_ANIM_WINDOW_PARMSW* = MCI_ANIM_WINDOW_PARMSW
-  MCI_ANIM_STEP_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrames*: DWORD
-
-  PMCI_ANIM_STEP_PARMS* = ptr MCI_ANIM_STEP_PARMS
-  LPMCI_ANIM_STEP_PARMS* = ptr MCI_ANIM_STEP_PARMS
-  TMCI_ANIM_STEP_PARMS* = MCI_ANIM_STEP_PARMS
-  MCI_ANIM_WINDOW_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    hWnd*: HWND
-    nCmdShow*: UINT
-    lpstrText*: LPCSTR
-
-  PMCI_ANIM_WINDOW_PARMSA* = ptr MCI_ANIM_WINDOW_PARMSA
-  LPMCI_ANIM_WINDOW_PARMSA* = ptr MCI_ANIM_WINDOW_PARMSA
-  TMCI_ANIM_WINDOW_PARMSA* = MCI_ANIM_WINDOW_PARMSA
-  MCI_ANIM_PLAY_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    dwFrom*: DWORD
-    dwTo*: DWORD
-    dwSpeed*: DWORD
-
-  PMCI_ANIM_PLAY_PARMS* = ptr MCI_ANIM_PLAY_PARMS
-  LPMCI_ANIM_PLAY_PARMS* = ptr MCI_ANIM_PLAY_PARMS
-
-when defined(UNICODE):
-  type
-    MCI_ANIM_WINDOW_PARMS* = MCI_ANIM_WINDOW_PARMSW
-    PMCI_ANIM_WINDOW_PARMS* = PMCI_ANIM_WINDOW_PARMSW
-    LPMCI_ANIM_WINDOW_PARMS* = LPMCI_ANIM_WINDOW_PARMSW
-else:
-  type
-    MCI_ANIM_WINDOW_PARMS* = MCI_ANIM_WINDOW_PARMSA
-    PMCI_ANIM_WINDOW_PARMS* = PMCI_ANIM_WINDOW_PARMSA
-    LPMCI_ANIM_WINDOW_PARMS* = LPMCI_ANIM_WINDOW_PARMSA
-type
-  MCI_ANIM_RECT_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    rc*: TRECT
-
-  PMCI_ANIM_RECT_PARMS* = ptr MCI_ANIM_RECT_PARMS
-  LPMCI_ANIM_RECT_PARMS* = ptr MCI_ANIM_RECT_PARMS
-  TMCI_ANIM_RECT_PARMS* = MCI_ANIM_RECT_PARMS
-  MCI_ANIM_UPDATE_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    rc*: TRECT
-    hDC*: HDC
-
-  PMCI_ANIM_UPDATE_PARMS* = ptr MCI_ANIM_UPDATE_PARMS
-  LPMCI_ANIM_UPDATE_PARMS* = ptr MCI_ANIM_UPDATE_PARMS
-  TMCI_ANIM_UPDATE_PARMS* = MCI_ANIM_UPDATE_PARMS
-  MCI_OVLY_OPEN_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCSTR
-    lpstrElementName*: LPCSTR
-    lpstrAlias*: LPCSTR
-    dwStyle*: DWORD
-    hWndParent*: HWND
-
-  PMCI_OVLY_OPEN_PARMSA* = ptr MCI_OVLY_OPEN_PARMSA
-  LPMCI_OVLY_OPEN_PARMSA* = ptr MCI_OVLY_OPEN_PARMSA
-  TMCI_OVLY_OPEN_PARMSA* = MCI_OVLY_OPEN_PARMSA
-  MCI_OVLY_OPEN_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    wDeviceID*: MCIDEVICEID
-    lpstrDeviceType*: LPCWSTR
-    lpstrElementName*: LPCWSTR
-    lpstrAlias*: LPCWSTR
-    dwStyle*: DWORD
-    hWndParent*: HWND
-
-  PMCI_OVLY_OPEN_PARMSW* = ptr MCI_OVLY_OPEN_PARMSW
-  LPMCI_OVLY_OPEN_PARMSW* = ptr MCI_OVLY_OPEN_PARMSW
-  TMCI_OVLY_OPEN_PARMSW* = MCI_OVLY_OPEN_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_OVLY_OPEN_PARMS* = MCI_OVLY_OPEN_PARMSW
-    PMCI_OVLY_OPEN_PARMS* = PMCI_OVLY_OPEN_PARMSW
-    LPMCI_OVLY_OPEN_PARMS* = LPMCI_OVLY_OPEN_PARMSW
-else:
-  type
-    MCI_OVLY_OPEN_PARMS* = MCI_OVLY_OPEN_PARMSA
-    PMCI_OVLY_OPEN_PARMS* = PMCI_OVLY_OPEN_PARMSA
-    LPMCI_OVLY_OPEN_PARMS* = LPMCI_OVLY_OPEN_PARMSA
-type
-  TMCI_OVLY_OPEN_PARMS* = MCI_OVLY_OPEN_PARMS
-  MCI_OVLY_WINDOW_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    hWnd*: HWND
-    nCmdShow*: UINT
-    lpstrText*: LPCSTR
-
-  PMCI_OVLY_WINDOW_PARMSA* = ptr MCI_OVLY_WINDOW_PARMSA
-  LPMCI_OVLY_WINDOW_PARMSA* = ptr MCI_OVLY_WINDOW_PARMSA
-  TMCI_OVLY_WINDOW_PARMSA* = MCI_OVLY_WINDOW_PARMSA
-  MCI_OVLY_WINDOW_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    hWnd*: HWND
-    nCmdShow*: UINT
-    lpstrText*: LPCWSTR
-
-  PMCI_OVLY_WINDOW_PARMSW* = ptr MCI_OVLY_WINDOW_PARMSW
-  LPMCI_OVLY_WINDOW_PARMSW* = ptr MCI_OVLY_WINDOW_PARMSW
-  TMCI_OVLY_WINDOW_PARMSW* = MCI_OVLY_WINDOW_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_OVLY_WINDOW_PARMS* = MCI_OVLY_WINDOW_PARMSW
-    PMCI_OVLY_WINDOW_PARMS* = PMCI_OVLY_WINDOW_PARMSW
-    LPMCI_OVLY_WINDOW_PARMS* = LPMCI_OVLY_WINDOW_PARMSW
-else:
-  type
-    MCI_OVLY_WINDOW_PARMS* = MCI_OVLY_WINDOW_PARMSA
-    PMCI_OVLY_WINDOW_PARMS* = PMCI_OVLY_WINDOW_PARMSA
-    LPMCI_OVLY_WINDOW_PARMS* = LPMCI_OVLY_WINDOW_PARMSA
-type
-  TMCI_OVLY_WINDOW_PARMS* = MCI_OVLY_WINDOW_PARMSW
-  MCI_OVLY_RECT_PARMS* {.final.} = object
-    dwCallback*: DWORD
-    rc*: TRECT
-
-  PMCI_OVLY_RECT_PARMS* = ptr MCI_OVLY_RECT_PARMS
-  LPMCI_OVLY_RECT_PARMS* = ptr MCI_OVLY_RECT_PARMS
-  TMCI_OVLY_RECT_PARMS* = MCI_OVLY_RECT_PARMS
-  MCI_OVLY_SAVE_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCSTR
-    rc*: TRECT
-
-  PMCI_OVLY_SAVE_PARMSA* = ptr MCI_OVLY_SAVE_PARMSA
-  LPMCI_OVLY_SAVE_PARMSA* = ptr MCI_OVLY_SAVE_PARMSA
-  TMCI_OVLY_SAVE_PARMSA* = MCI_OVLY_SAVE_PARMSA
-  MCI_OVLY_SAVE_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCWSTR
-    rc*: TRECT
-
-  PMCI_OVLY_SAVE_PARMSW* = ptr MCI_OVLY_SAVE_PARMSW
-  LPMCI_OVLY_SAVE_PARMSW* = ptr MCI_OVLY_SAVE_PARMSW
-  TMCI_OVLY_SAVE_PARMSW* = MCI_OVLY_SAVE_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_OVLY_SAVE_PARMS* = MCI_OVLY_SAVE_PARMSW
-    PMCI_OVLY_SAVE_PARMS* = PMCI_OVLY_SAVE_PARMSW
-    LPMCI_OVLY_SAVE_PARMS* = LPMCI_OVLY_SAVE_PARMSW
-else:
-  type
-    MCI_OVLY_SAVE_PARMS* = MCI_OVLY_SAVE_PARMSA
-    PMCI_OVLY_SAVE_PARMS* = PMCI_OVLY_SAVE_PARMSA
-    LPMCI_OVLY_SAVE_PARMS* = LPMCI_OVLY_SAVE_PARMSA
-type
-  TMCI_OVLY_SAVE_PARMS* = MCI_OVLY_SAVE_PARMS
-  MCI_OVLY_LOAD_PARMSA* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCSTR
-    rc*: TRECT
-
-  PMCI_OVLY_LOAD_PARMSA* = ptr MCI_OVLY_LOAD_PARMSA
-  LPMCI_OVLY_LOAD_PARMSA* = ptr MCI_OVLY_LOAD_PARMSA
-  TMCI_OVLY_LOAD_PARMSA* = MCI_OVLY_LOAD_PARMSA
-  MCI_OVLY_LOAD_PARMSW* {.final.} = object
-    dwCallback*: DWORD
-    lpfilename*: LPCWSTR
-    rc*: TRECT
-
-  PMCI_OVLY_LOAD_PARMSW* = ptr MCI_OVLY_LOAD_PARMSW
-  LPMCI_OVLY_LOAD_PARMSW* = ptr MCI_OVLY_LOAD_PARMSW
-  TMCI_OVLY_LOAD_PARMSW* = MCI_OVLY_LOAD_PARMSW
-
-when defined(UNICODE):
-  type
-    MCI_OVLY_LOAD_PARMS* = MCI_OVLY_LOAD_PARMSW
-    PMCI_OVLY_LOAD_PARMS* = PMCI_OVLY_LOAD_PARMSW
-    LPMCI_OVLY_LOAD_PARMS* = LPMCI_OVLY_LOAD_PARMSW
-else:
-  type
-    MCI_OVLY_LOAD_PARMS* = MCI_OVLY_LOAD_PARMSA
-    PMCI_OVLY_LOAD_PARMS* = PMCI_OVLY_LOAD_PARMSA
-    LPMCI_OVLY_LOAD_PARMS* = LPMCI_OVLY_LOAD_PARMSA
-type
-  TMCI_OVLY_LOAD_PARMS* = MCI_OVLY_LOAD_PARMS
-
-type
-  pcmwaveformat_tag* = PCMWAVEFORMAT
-
-proc mmioStringToFOURCCA*(x1: LPCSTR, x2: UINT): FOURCC{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioStringToFOURCCA".}
-proc mmioStringToFOURCCW*(x1: LPCWSTR, x2: UINT): FOURCC{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioStringToFOURCCW".}
-proc mmioStringToFOURCC*(x1: cstring, x2: UINT): FOURCC{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioStringToFOURCCA".}
-proc mmioInstallIOProcA*(x1: FOURCC, x2: LPMMIOPROC, x3: DWORD): LPMMIOPROC{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioInstallIOProcA".}
-proc mmioInstallIOProcW*(x1: FOURCC, x2: LPMMIOPROC, x3: DWORD): LPMMIOPROC{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioInstallIOProcW".}
-proc mmioInstallIOProc*(x1: FOURCC, x2: LPMMIOPROC, x3: DWORD): LPMMIOPROC{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioInstallIOProcA".}
-proc mmioOpenA*(x1: LPSTR, x2: LPMMIOINFO, x3: DWORD): HMMIO{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioOpenA".}
-proc mmioOpenW*(x1: LPWSTR, x2: LPMMIOINFO, x3: DWORD): HMMIO{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioOpenW".}
-proc mmioOpen*(x1: cstring, x2: LPMMIOINFO, x3: DWORD): HMMIO{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioOpenA".}
-proc mmioRenameA*(x1: LPCSTR, x2: LPCSTR, x3: LPCMMIOINFO, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioRenameA".}
-proc mmioRenameW*(x1: LPCWSTR, x2: LPCWSTR, x3: LPCMMIOINFO, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioRenameW".}
-proc mmioRename*(x1: cstring, x2: cstring, x3: LPCMMIOINFO, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioRenameA".}
-proc mmioClose*(x1: HMMIO, x2: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "mmioClose".}
-proc mmioRead*(x1: HMMIO, x2: HPSTR, x3: LONG): LONG{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioRead".}
-proc mmioWrite*(x1: HMMIO, x2: cstring, x3: LONG): LONG{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioWrite".}
-proc mmioSeek*(x1: HMMIO, x2: LONG, x3: WINT): LONG{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioSeek".}
-proc mmioGetInfo*(x1: HMMIO, x2: LPMMIOINFO, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioGetInfo".}
-proc mmioSetInfo*(x1: HMMIO, x2: LPCMMIOINFO, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioSetInfo".}
-proc mmioSetBuffer*(x1: HMMIO, x2: LPSTR, x3: LONG, x4: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioSetBuffer".}
-proc mmioFlush*(x1: HMMIO, x2: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "mmioFlush".}
-proc mmioAdvance*(x1: HMMIO, x2: LPMMIOINFO, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioAdvance".}
-proc mmioSendMessage*(x1: HMMIO, x2: UINT, x3: LPARAM, x4: LPARAM): LRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioSendMessage".}
-proc mmioDescend*(x1: HMMIO, x2: LPMMCKINFO, x3: PMMCKINFO, x4: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mmioDescend".}
-proc mmioAscend*(x1: HMMIO, x2: LPMMCKINFO, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioAscend".}
-proc mmioCreateChunk*(x1: HMMIO, x2: LPMMCKINFO, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mmioCreateChunk".}
-proc mciSendCommandA*(x1: MCIDEVICEID, x2: UINT, x3: DWORD, x4: DWORD): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendCommandA".}
-proc mciSendCommandW*(x1: MCIDEVICEID, x2: UINT, x3: DWORD, x4: DWORD): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendCommandW".}
-proc mciSendCommand*(x1: MCIDEVICEID, x2: UINT, x3: DWORD, x4: DWORD): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendCommandA".}
-proc mciSendStringA*(x1: LPCSTR, x2: LPSTR, x3: UINT, x4: HWND): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendStringA".}
-proc mciSendStringW*(x1: LPCWSTR, x2: LPWSTR, x3: UINT, x4: HWND): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendStringW".}
-proc mciSendString*(x1: cstring, x2: cstring, x3: UINT, x4: HWND): MCIERROR{.
-    stdcall, dynlib: "winmm.dll", importc: "mciSendStringA".}
-proc mciGetDeviceIDA*(x1: LPCSTR): MCIDEVICEID{.stdcall, dynlib: "winmm.dll",
-    importc: "mciGetDeviceIDA".}
-proc mciGetDeviceIDW*(x1: LPCWSTR): MCIDEVICEID{.stdcall, dynlib: "winmm.dll",
-    importc: "mciGetDeviceIDW".}
-proc mciGetDeviceID*(x1: cstring): MCIDEVICEID{.stdcall, dynlib: "winmm.dll",
-    importc: "mciGetDeviceIDA".}
-proc mciGetDeviceIDFromElementIDA*(x1: DWORD, x2: LPCSTR): MCIDEVICEID{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetDeviceIDFromElementIDA".}
-proc mciGetDeviceIDFromElementIDW*(x1: DWORD, x2: LPCWSTR): MCIDEVICEID{.
-    stdcall, dynlib: "winmm.dll", importc: "mciGetDeviceIDFromElementIDW".}
-proc mciGetDeviceIDFromElementID*(x1: DWORD, x2: cstring): MCIDEVICEID{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetDeviceIDFromElementIDA".}
-proc mciGetErrorStringA*(x1: MCIERROR, x2: LPSTR, x3: UINT): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetErrorStringA".}
-proc mciGetErrorStringW*(x1: MCIERROR, x2: LPWSTR, x3: UINT): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetErrorStringW".}
-proc mciGetErrorString*(x1: MCIERROR, x2: cstring, x3: UINT): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetErrorStringA".}
-proc mciSetYieldProc*(x1: MCIDEVICEID, x2: YIELDPROC, x3: DWORD): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "mciSetYieldProc".}
-proc mciGetCreatorTask*(x1: MCIDEVICEID): HTASK{.stdcall, dynlib: "winmm.dll",
-    importc: "mciGetCreatorTask".}
-proc mciGetYieldProc*(x1: MCIDEVICEID, x2: LPDWORD): YIELDPROC{.stdcall,
-    dynlib: "winmm.dll", importc: "mciGetYieldProc".}
-proc mciExecute*(x1: LPCSTR): BOOL{.stdcall, dynlib: "winmm.dll",
-                                    importc: "mciExecute".}
-proc joyGetPos*(x1: UINT, x2: LPJOYINFO): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetPos".}
-proc joyGetPosEx*(x1: UINT, x2: LPJOYINFOEX): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetPosEx".}
-proc joyGetThreshold*(x1: UINT, x2: LPUINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetThreshold".}
-proc joyReleaseCapture*(x1: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "joyReleaseCapture".}
-proc joySetCapture*(x1: HWND, x2: UINT, x3: UINT, x4: BOOL): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joySetCapture".}
-proc joySetThreshold*(x1: UINT, x2: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joySetThreshold".}
-proc waveOutGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                                 importc: "waveOutGetNumDevs".}
-proc waveOutGetDevCapsA*(x1: UINT, x2: LPWAVEOUTCAPSA, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetDevCapsA".}
-proc waveOutGetDevCapsW*(x1: UINT, x2: LPWAVEOUTCAPSW, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetDevCapsW".}
-proc waveOutGetDevCaps*(x1: UINT, x2: LPWAVEOUTCAPS, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetDevCapsA".}
-proc waveOutGetVolume*(x1: HWAVEOUT, x2: LPDWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutGetVolume".}
-proc waveOutSetVolume*(x1: HWAVEOUT, x2: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutSetVolume".}
-proc waveOutGetErrorTextA*(x1: MMRESULT, x2: LPSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetErrorTextA".}
-proc waveOutGetErrorTextW*(x1: MMRESULT, x2: LPWSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetErrorTextW".}
-proc waveOutGetErrorText*(x1: MMRESULT, x2: cstring, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetErrorTextA".}
-proc waveOutOpen*(x1: LPHWAVEOUT, x2: UINT, x3: LPCWAVEFORMATEX, x4: DWORD,
-                  x5: DWORD, x6: DWORD): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutOpen".}
-proc waveOutClose*(x1: HWAVEOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutClose".}
-proc waveOutPrepareHeader*(x1: HWAVEOUT, x2: LPWAVEHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutPrepareHeader".}
-proc waveOutUnprepareHeader*(x1: HWAVEOUT, x2: LPWAVEHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutUnprepareHeader".}
-proc waveOutWrite*(x1: HWAVEOUT, x2: LPWAVEHDR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutWrite".}
-proc waveOutPause*(x1: HWAVEOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutPause".}
-proc waveOutRestart*(x1: HWAVEOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutRestart".}
-proc waveOutReset*(x1: HWAVEOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutReset".}
-proc waveOutBreakLoop*(x1: HWAVEOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveOutBreakLoop".}
-proc waveOutGetPosition*(x1: HWAVEOUT, x2: LPMMTIME, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutGetPosition".}
-proc waveOutGetPitch*(x1: HWAVEOUT, x2: LPDWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutGetPitch".}
-proc waveOutSetPitch*(x1: HWAVEOUT, x2: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutSetPitch".}
-proc waveOutGetPlaybackRate*(x1: HWAVEOUT, x2: LPDWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutGetPlaybackRate".}
-proc waveOutSetPlaybackRate*(x1: HWAVEOUT, x2: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutSetPlaybackRate".}
-proc waveOutGetID*(x1: HWAVEOUT, x2: LPUINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveOutGetID".}
-proc waveOutMessage*(x1: HWAVEOUT, x2: UINT, x3: DWORD, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveOutMessage".}
-proc waveInGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                                importc: "waveInGetNumDevs".}
-proc waveInGetDevCapsA*(x1: UINT, x2: LPWAVEINCAPSA, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInGetDevCapsA".}
-proc waveInGetDevCapsW*(x1: UINT, x2: LPWAVEINCAPSW, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInGetDevCapsW".}
-proc waveInGetDevCaps*(x1: UINT, x2: LPWAVEINCAPS, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveInGetDevCapsA".}
-proc waveInGetErrorTextA*(x1: MMRESULT, x2: LPSTR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveInGetErrorTextA".}
-proc waveInGetErrorTextW*(x1: MMRESULT, x2: LPWSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInGetErrorTextW".}
-proc waveInGetErrorText*(x1: MMRESULT, x2: cstring, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInGetErrorTextA".}
-proc waveInOpen*(x1: LPHWAVEIN, x2: UINT, x3: LPCWAVEFORMATEX, x4: DWORD,
-                 x5: DWORD, x6: DWORD): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveInOpen".}
-proc waveInClose*(x1: HWAVEIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveInClose".}
-proc waveInPrepareHeader*(x1: HWAVEIN, x2: LPWAVEHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInPrepareHeader".}
-proc waveInUnprepareHeader*(x1: HWAVEIN, x2: LPWAVEHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInUnprepareHeader".}
-proc waveInAddBuffer*(x1: HWAVEIN, x2: LPWAVEHDR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveInAddBuffer".}
-proc waveInStart*(x1: HWAVEIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveInStart".}
-proc waveInStop*(x1: HWAVEIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveInStop".}
-proc waveInReset*(x1: HWAVEIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "waveInReset".}
-proc waveInGetPosition*(x1: HWAVEIN, x2: LPMMTIME, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveInGetPosition".}
-proc waveInGetID*(x1: HWAVEIN, x2: LPUINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "waveInGetID".}
-proc waveInMessage*(x1: HWAVEIN, x2: UINT, x3: DWORD, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "waveInMessage".}
-proc mixerGetLineControlsA*(x1: HMIXEROBJ, x2: LPMIXERLINECONTROLSA, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineControlsA".}
-proc mixerGetLineControlsW*(x1: HMIXEROBJ, x2: LPMIXERLINECONTROLSW, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineControlsW".}
-proc mixerGetLineControls*(x1: HMIXEROBJ, x2: LPMIXERLINECONTROLS, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineControlsA".}
-proc joyGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                             importc: "joyGetNumDevs".}
-proc joyGetDevCapsA*(x1: UINT, x2: LPJOYCAPSA, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetDevCapsA".}
-proc joyGetDevCapsW*(x1: UINT, x2: LPJOYCAPSW, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetDevCapsW".}
-proc joyGetDevCaps*(x1: UINT, x2: LPJOYCAPS, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "joyGetDevCapsA".}
-proc mixerGetControlDetailsA*(x1: HMIXEROBJ, x2: LPMIXERCONTROLDETAILS,
-                              x3: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetControlDetailsA".}
-proc mixerGetControlDetailsW*(x1: HMIXEROBJ, x2: LPMIXERCONTROLDETAILS,
-                              x3: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetControlDetailsW".}
-proc mixerGetControlDetails*(x1: HMIXEROBJ, x2: LPMIXERCONTROLDETAILS, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetControlDetailsA".}
-proc timeGetSystemTime*(x1: LPMMTIME, x2: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "timeGetSystemTime".}
-proc timeGetTime*(): DWORD{.stdcall, dynlib: "winmm.dll", importc: "timeGetTime".}
-proc timeSetEvent*(x1: UINT, x2: UINT, x3: LPTIMECALLBACK, x4: DWORD, x5: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "timeSetEvent".}
-proc timeKillEvent*(x1: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "timeKillEvent".}
-proc timeGetDevCaps*(x1: LPTIMECAPS, x2: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "timeGetDevCaps".}
-proc timeBeginPeriod*(x1: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "timeBeginPeriod".}
-proc timeEndPeriod*(x1: UINT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "timeEndPeriod".}
-proc mixerGetDevCapsA*(x1: UINT, x2: LPMIXERCAPSA, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetDevCapsA".}
-proc mixerGetDevCapsW*(x1: UINT, x2: LPMIXERCAPSW, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetDevCapsW".}
-proc mixerGetDevCaps*(x1: UINT, x2: LPMIXERCAPS, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetDevCapsA".}
-proc mixerOpen*(x1: LPHMIXER, x2: UINT, x3: DWORD, x4: DWORD, x5: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerOpen".}
-proc mixerClose*(x1: HMIXER): MMRESULT{.stdcall, dynlib: "winmm.dll",
-                                        importc: "mixerClose".}
-proc mixerMessage*(x1: HMIXER, x2: UINT, x3: DWORD, x4: DWORD): DWORD{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerMessage".}
-proc auxGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                             importc: "auxGetNumDevs".}
-proc auxGetDevCapsA*(x1: UINT, x2: LPAUXCAPSA, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "auxGetDevCapsA".}
-proc auxGetDevCapsW*(x1: UINT, x2: LPAUXCAPSW, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "auxGetDevCapsW".}
-proc auxGetDevCaps*(x1: UINT, x2: LPAUXCAPS, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "auxGetDevCapsA".}
-proc auxSetVolume*(x1: UINT, x2: DWORD): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "auxSetVolume".}
-proc auxGetVolume*(x1: UINT, x2: LPDWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "auxGetVolume".}
-proc auxOutMessage*(x1: UINT, x2: UINT, x3: DWORD, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "auxOutMessage".}
-proc midiOutGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                                 importc: "midiOutGetNumDevs".}
-proc midiStreamOpen*(x1: LPHMIDISTRM, x2: LPUINT, x3: DWORD, x4: DWORD,
-                     x5: DWORD, x6: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiStreamOpen".}
-proc midiStreamClose*(x1: HMIDISTRM): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiStreamClose".}
-proc midiStreamProperty*(x1: HMIDISTRM, x2: LPBYTE, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiStreamProperty".}
-proc midiStreamPosition*(x1: HMIDISTRM, x2: LPMMTIME, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiStreamPosition".}
-proc midiStreamOut*(x1: HMIDISTRM, x2: LPMIDIHDR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiStreamOut".}
-proc midiStreamPause*(x1: HMIDISTRM): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiStreamPause".}
-proc midiStreamRestart*(x1: HMIDISTRM): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiStreamRestart".}
-proc midiStreamStop*(x1: HMIDISTRM): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiStreamStop".}
-proc midiConnect*(x1: HMIDI, x2: HMIDIOUT, x3: pointer): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiConnect".}
-proc midiDisconnect*(x1: HMIDI, x2: HMIDIOUT, x3: pointer): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiDisconnect".}
-proc midiOutGetDevCapsA*(x1: UINT, x2: LPMIDIOUTCAPSA, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetDevCapsA".}
-proc midiOutGetDevCapsW*(x1: UINT, x2: LPMIDIOUTCAPSW, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetDevCapsW".}
-proc midiOutGetDevCaps*(x1: UINT, x2: LPMIDIOUTCAPS, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetDevCapsA".}
-proc midiOutGetVolume*(x1: HMIDIOUT, x2: LPDWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiOutGetVolume".}
-proc midiOutSetVolume*(x1: HMIDIOUT, x2: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiOutSetVolume".}
-proc midiOutGetErrorTextA*(x1: MMRESULT, x2: LPSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetErrorTextA".}
-proc midiOutGetErrorTextW*(x1: MMRESULT, x2: LPWSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetErrorTextW".}
-proc midiOutGetErrorText*(x1: MMRESULT, x2: cstring, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutGetErrorTextA".}
-proc midiOutOpen*(x1: LPHMIDIOUT, x2: UINT, x3: DWORD, x4: DWORD, x5: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutOpen".}
-proc midiOutClose*(x1: HMIDIOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiOutClose".}
-proc midiOutPrepareHeader*(x1: HMIDIOUT, x2: LPMIDIHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutPrepareHeader".}
-proc midiOutUnprepareHeader*(x1: HMIDIOUT, x2: LPMIDIHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutUnprepareHeader".}
-proc midiOutShortMsg*(x1: HMIDIOUT, x2: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiOutShortMsg".}
-proc midiOutLongMsg*(x1: HMIDIOUT, x2: LPMIDIHDR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiOutLongMsg".}
-proc midiOutReset*(x1: HMIDIOUT): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiOutReset".}
-proc midiOutCachePatches*(x1: HMIDIOUT, x2: UINT, x3: LPWORD, x4: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutCachePatches".}
-proc midiOutCacheDrumPatches*(x1: HMIDIOUT, x2: UINT, x3: LPWORD, x4: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutCacheDrumPatches".}
-proc midiOutGetID*(x1: HMIDIOUT, x2: LPUINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiOutGetID".}
-proc midiOutMessage*(x1: HMIDIOUT, x2: UINT, x3: DWORD, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiOutMessage".}
-proc midiInGetNumDevs*(): UINT{.stdcall, dynlib: "winmm.dll",
-                                importc: "midiInGetNumDevs".}
-proc midiInGetDevCapsA*(x1: UINT, x2: LPMIDIINCAPSA, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInGetDevCapsA".}
-proc midiInGetDevCapsW*(x1: UINT, x2: LPMIDIINCAPSW, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInGetDevCapsW".}
-proc midiInGetDevCaps*(x1: UINT, x2: LPMIDIINCAPS, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiInGetDevCapsA".}
-proc midiInGetErrorTextA*(x1: MMRESULT, x2: LPSTR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiInGetErrorTextA".}
-proc midiInGetErrorTextW*(x1: MMRESULT, x2: LPWSTR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInGetErrorTextW".}
-proc midiInGetErrorText*(x1: MMRESULT, x2: cstring, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInGetErrorTextA".}
-proc midiInOpen*(x1: LPHMIDIIN, x2: UINT, x3: DWORD, x4: DWORD, x5: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInOpen".}
-proc midiInClose*(x1: HMIDIIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiInClose".}
-proc midiInPrepareHeader*(x1: HMIDIIN, x2: LPMIDIHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInPrepareHeader".}
-proc midiInUnprepareHeader*(x1: HMIDIIN, x2: LPMIDIHDR, x3: UINT): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInUnprepareHeader".}
-proc midiInAddBuffer*(x1: HMIDIIN, x2: LPMIDIHDR, x3: UINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiInAddBuffer".}
-proc midiInStart*(x1: HMIDIIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiInStart".}
-proc midiInStop*(x1: HMIDIIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiInStop".}
-proc midiInReset*(x1: HMIDIIN): MMRESULT{.stdcall, dynlib: "winmm.dll",
-    importc: "midiInReset".}
-proc midiInGetID*(x1: HMIDIIN, x2: LPUINT): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "midiInGetID".}
-proc midiInMessage*(x1: HMIDIIN, x2: UINT, x3: DWORD, x4: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "midiInMessage".}
-proc mixerGetLineInfoA*(x1: HMIXEROBJ, x2: LPMIXERLINEA, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineInfoA".}
-proc mixerGetLineInfoW*(x1: HMIXEROBJ, x2: LPMIXERLINEW, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineInfoW".}
-proc mixerGetLineInfo*(x1: HMIXEROBJ, x2: LPMIXERLINE, x3: DWORD): MMRESULT{.
-    stdcall, dynlib: "winmm.dll", importc: "mixerGetLineInfoA".}
-proc mixerGetID*(x1: HMIXEROBJ, x2: var UINT, x3: DWORD): MMRESULT{.stdcall,
-    dynlib: "winmm.dll", importc: "mixerGetID".}
-proc PlaySoundA*(x1: LPCSTR, x2: HMODULE, x3: DWORD): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "PlaySoundA".}
-proc PlaySoundW*(x1: LPCWSTR, x2: HMODULE, x3: DWORD): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "PlaySoundW".}
-proc PlaySound*(x1: cstring, x2: HMODULE, x3: DWORD): BOOL{.stdcall,
-    dynlib: "winmm.dll", importc: "PlaySoundA".}
-# implementation
-
-proc MEVT_EVENTTYPE(x: int8): int8 =
-  result = toU8(x shr 24)
-
-proc MEVT_EVENTPARM(x: DWORD): DWORD =
-  result = x And 0x00FFFFFF
-
-proc MCI_MSF_MINUTE(msf: int32): int8 =
-  result = toU8(msf and 0xff)
-
-proc MCI_TMSF_TRACK(tmsf: int32): int8 =
-  result = toU8(tmsf and 0xff)
-
-proc MCI_HMS_HOUR(h: int32): int8 =
-  result = toU8(h and 0xff)
-
-proc MCI_MSF_SECOND(msf: int32): int8 =
-  result = toU8(msf shr 8)
-
-proc MCI_TMSF_MINUTE(tmsf: int32): int8 =
-  result = toU8(tmsf shr 8)
-
-proc MCI_HMS_MINUTE(h: int32): int8 =
-  result = toU8(h shr 8)
-
-proc MCI_MSF_FRAME(msf: int32): int8 =
-  result = toU8(msf shr 16)
-
-proc MCI_TMSF_SECOND(tmsf: int32): int8 =
-  result = toU8(tmsf shr 16)
-
-proc MCI_HMS_SECOND(h: int32): int8 =
-  result = toU8(h shr 16)
-
-proc MCI_MAKE_MSF(m, s, f: int8): int32 =
-  result = toU32(ze(m) or ze(s) shl 8 or ze(f) shl 16)
-
-proc MCI_MAKE_HMS(h, m, s: int8): int32 =
-  result = toU32(ze(h) or ze(m) shl 8 or ze(s) shl 16)
-
-proc MCI_TMSF_FRAME(tmsf: int32): int8 =
-  result = toU8(tmsf shr 24)
-
-proc mci_Make_TMSF(t, m, s, f: int8): int32 =
-  result = ze(t) or ze(m) shl 8 or ze(s) shl 16 or ze(f) shl 24
-
-proc DIBINDEX(n: int32): int32 =
-  result = n Or 0x000010FF'i32 shl 16'i32
diff --git a/lib/windows/nb30.nim b/lib/windows/nb30.nim
deleted file mode 100755
index 527e3a9e2..000000000
--- a/lib/windows/nb30.nim
+++ /dev/null
@@ -1,232 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-#       NetBIOS 3.0 interface unit 
-
-# This module contains the definitions for portable NetBIOS 3.0 support. 
-
-{.deadCodeElim: on.}
-
-import                        # Data structure templates 
-  Windows
-
-const 
-  NCBNAMSZ* = 16              # absolute length of a net name
-  MAX_LANA* = 254             # lana's in range 0 to MAX_LANA inclusive
-
-type                          # Network Control Block
-  PNCB* = ptr TNCB
-  TNCBPostProc* = proc (P: PNCB)
-  TNCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
-                           # by an array of NAME_BUFFER structures.
-    ncb_command*: Char        # command code
-    ncb_retcode*: Char        # return code
-    ncb_lsn*: Char            # local session number
-    ncb_num*: Char            # number of our network name
-    ncb_buffer*: cstring      # address of message buffer
-    ncb_length*: int16        # size of message buffer
-    ncb_callname*: array[0..NCBNAMSZ - 1, char] # blank-padded name of remote
-    ncb_name*: array[0..NCBNAMSZ - 1, char] # our blank-padded netname
-    ncb_rto*: Char            # rcv timeout/retry count
-    ncb_sto*: Char            # send timeout/sys timeout
-    ncb_post*: TNCBPostProc   # POST routine address
-    ncb_lana_num*: Char       # lana (adapter) number
-    ncb_cmd_cplt*: Char       # 0xff => commmand pending
-    ncb_reserve*: array[0..9, Char] # reserved, used by BIOS
-    ncb_event*: THandle       # HANDLE to Win32 event which
-                              # will be set to the signalled
-                              # state when an ASYNCH command
-                              # completes
-  
-  PAdapterStatus* = ptr TAdapterStatus
-  TAdapterStatus* {.final.} = object 
-    adapter_address*: array[0..5, Char]
-    rev_major*: Char
-    reserved0*: Char
-    adapter_type*: Char
-    rev_minor*: Char
-    duration*: int16
-    frmr_recv*: int16
-    frmr_xmit*: int16
-    iframe_recv_err*: int16
-    xmit_aborts*: int16
-    xmit_success*: DWORD
-    recv_success*: DWORD
-    iframe_xmit_err*: int16
-    recv_buff_unavail*: int16
-    t1_timeouts*: int16
-    ti_timeouts*: int16
-    reserved1*: DWORD
-    free_ncbs*: int16
-    max_cfg_ncbs*: int16
-    max_ncbs*: int16
-    xmit_buf_unavail*: int16
-    max_dgram_size*: int16
-    pending_sess*: int16
-    max_cfg_sess*: int16
-    max_sess*: int16
-    max_sess_pkt_size*: int16
-    name_count*: int16
-
-  PNameBuffer* = ptr TNameBuffer
-  TNameBuffer* {.final.} = object 
-    name*: array[0..NCBNAMSZ - 1, Char]
-    name_num*: Char
-    name_flags*: Char
-
-
-const                         # values for name_flags bits.
-  NAME_FLAGS_MASK* = 0x00000087
-  GROUP_NAME* = 0x00000080
-  UNIQUE_NAME* = 0x00000000
-  REGISTERING* = 0x00000000
-  REGISTERED* = 0x00000004
-  DEREGISTERED* = 0x00000005
-  DUPLICATE* = 0x00000006
-  DUPLICATE_DEREG* = 0x00000007
-
-type # Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
-     # by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
-     # asterisk then an array of these structures is returned containing the
-     # status for all names.
-  PSessionHeader* = ptr TSessionHeader
-  TSessionHeader* {.final.} = object 
-    sess_name*: Char
-    num_sess*: Char
-    rcv_dg_outstanding*: Char
-    rcv_any_outstanding*: Char
-
-  PSessionBuffer* = ptr TSessionBuffer
-  TSessionBuffer* {.final.} = object 
-    lsn*: Char
-    state*: Char
-    local_name*: array[0..NCBNAMSZ - 1, Char]
-    remote_name*: array[0..NCBNAMSZ - 1, Char]
-    rcvs_outstanding*: Char
-    sends_outstanding*: Char
-
-
-const                         # Values for state
-  LISTEN_OUTSTANDING* = 0x00000001
-  CALL_PENDING* = 0x00000002
-  SESSION_ESTABLISHED* = 0x00000003
-  HANGUP_PENDING* = 0x00000004
-  HANGUP_COMPLETE* = 0x00000005
-  SESSION_ABORTED* = 0x00000006
-
-type # Structure returned to the NCB command NCBENUM.
-     # On a system containing lana's 0, 2 and 3, a structure with
-     # length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
-  PLanaEnum* = ptr TLanaEnum
-  TLanaEnum* {.final.} = object # Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
-                                # by an array of FIND_NAME_BUFFER structures.
-    len*: Char                #  Number of valid entries in lana[]
-    lana*: array[0..MAX_LANA, Char]
-
-  PFindNameHeader* = ptr TFindNameHeader
-  TFindNameHeader* {.final.} = object 
-    node_count*: int16
-    reserved*: Char
-    unique_group*: Char
-
-  PFindNameBuffer* = ptr TFindNameBuffer
-  TFindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide
-                                      # transport specific extensions to netbios.
-    len*: Char
-    access_control*: Char
-    frame_control*: Char
-    destination_addr*: array[0..5, Char]
-    source_addr*: array[0..5, Char]
-    routing_info*: array[0..17, Char]
-
-  PActionHeader* = ptr TActionHeader
-  TActionHeader* {.final.} = object 
-    transport_id*: int32
-    action_code*: int16
-    reserved*: int16
-
-
-const                         # Values for transport_id
-  ALL_TRANSPORTS* = "M\0\0\0"
-  MS_NBF* = "MNBF"            # Special values and constants 
-
-const                         # NCB Command codes
-  NCBCALL* = 0x00000010       # NCB CALL
-  NCBLISTEN* = 0x00000011     # NCB LISTEN
-  NCBHANGUP* = 0x00000012     # NCB HANG UP
-  NCBSEND* = 0x00000014       # NCB SEND
-  NCBRECV* = 0x00000015       # NCB RECEIVE
-  NCBRECVANY* = 0x00000016    # NCB RECEIVE ANY
-  NCBCHAINSEND* = 0x00000017  # NCB CHAIN SEND
-  NCBDGSEND* = 0x00000020     # NCB SEND DATAGRAM
-  NCBDGRECV* = 0x00000021     # NCB RECEIVE DATAGRAM
-  NCBDGSENDBC* = 0x00000022   # NCB SEND BROADCAST DATAGRAM
-  NCBDGRECVBC* = 0x00000023   # NCB RECEIVE BROADCAST DATAGRAM
-  NCBADDNAME* = 0x00000030    # NCB ADD NAME
-  NCBDELNAME* = 0x00000031    # NCB DELETE NAME
-  NCBRESET* = 0x00000032      # NCB RESET
-  NCBASTAT* = 0x00000033      # NCB ADAPTER STATUS
-  NCBSSTAT* = 0x00000034      # NCB SESSION STATUS
-  NCBCANCEL* = 0x00000035     # NCB CANCEL
-  NCBADDGRNAME* = 0x00000036  # NCB ADD GROUP NAME
-  NCBENUM* = 0x00000037       # NCB ENUMERATE LANA NUMBERS
-  NCBUNLINK* = 0x00000070     # NCB UNLINK
-  NCBSENDNA* = 0x00000071     # NCB SEND NO ACK
-  NCBCHAINSENDNA* = 0x00000072 # NCB CHAIN SEND NO ACK
-  NCBLANSTALERT* = 0x00000073 # NCB LAN STATUS ALERT
-  NCBACTION* = 0x00000077     # NCB ACTION
-  NCBFINDNAME* = 0x00000078   # NCB FIND NAME
-  NCBTRACE* = 0x00000079      # NCB TRACE
-  ASYNCH* = 0x00000080        # high bit set = asynchronous
-                              # NCB Return codes
-  NRC_GOODRET* = 0x00000000   # good return
-                              # also returned when ASYNCH request accepted
-  NRC_BUFLEN* = 0x00000001    # illegal buffer length
-  NRC_ILLCMD* = 0x00000003    # illegal command
-  NRC_CMDTMO* = 0x00000005    # command timed out
-  NRC_INCOMP* = 0x00000006    # message incomplete, issue another command
-  NRC_BADDR* = 0x00000007     # illegal buffer address
-  NRC_SNUMOUT* = 0x00000008   # session number out of range
-  NRC_NORES* = 0x00000009     # no resource available
-  NRC_SCLOSED* = 0x0000000A   # session closed
-  NRC_CMDCAN* = 0x0000000B    # command cancelled
-  NRC_DUPNAME* = 0x0000000D   # duplicate name
-  NRC_NAMTFUL* = 0x0000000E   # name table full
-  NRC_ACTSES* = 0x0000000F    # no deletions, name has active sessions
-  NRC_LOCTFUL* = 0x00000011   # local session table full
-  NRC_REMTFUL* = 0x00000012   # remote session table full
-  NRC_ILLNN* = 0x00000013     # illegal name number
-  NRC_NOCALL* = 0x00000014    # no callname
-  NRC_NOWILD* = 0x00000015    # cannot put * in NCB_NAME
-  NRC_INUSE* = 0x00000016     # name in use on remote adapter
-  NRC_NAMERR* = 0x00000017    # name deleted
-  NRC_SABORT* = 0x00000018    # session ended abnormally
-  NRC_NAMCONF* = 0x00000019   # name conflict detected
-  NRC_IFBUSY* = 0x00000021    # interface busy, IRET before retrying
-  NRC_TOOMANY* = 0x00000022   # too many commands outstanding, retry later
-  NRC_BRIDGE* = 0x00000023    # NCB_lana_num field invalid
-  NRC_CANOCCR* = 0x00000024   # command completed while cancel occurring
-  NRC_CANCEL* = 0x00000026    # command not valid to cancel
-  NRC_DUPENV* = 0x00000030    # name defined by anther local process
-  NRC_ENVNOTDEF* = 0x00000034 # environment undefined. RESET required
-  NRC_OSRESNOTAV* = 0x00000035 # required OS resources exhausted
-  NRC_MAXAPPS* = 0x00000036   # max number of applications exceeded
-  NRC_NOSAPS* = 0x00000037    # no saps available for netbios
-  NRC_NORESOURCES* = 0x00000038 # requested resources are not available
-  NRC_INVADDRESS* = 0x00000039 # invalid ncb address or length > segment
-  NRC_INVDDID* = 0x0000003B   # invalid NCB DDID
-  NRC_LOCKFAIL* = 0x0000003C  # lock of user area failed
-  NRC_OPENERR* = 0x0000003F   # NETBIOS not loaded
-  NRC_SYSTEM* = 0x00000040    # system error
-  NRC_PENDING* = 0x000000FF   # asynchronous command is not yet finished
-                              # main user entry point for NetBIOS 3.0
-                              #   Usage: Result = Netbios( pncb ); 
-
-proc Netbios*(P: PNCB): Char{.stdcall, dynlib: "netapi32.dll", 
-                              importc: "Netbios".}
-# implementation
diff --git a/lib/windows/ole2.nim b/lib/windows/ole2.nim
deleted file mode 100755
index ec0ab8f5d..000000000
--- a/lib/windows/ole2.nim
+++ /dev/null
@@ -1,208 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-import 
-  windows
-
-const 
-  GUID_NULL*: TGUID = (D1: 0x00000000, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000000])
-  IID_IUnknown*: TGUID = (D1: 0x00000000, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IClassFactory*: TGUID = (D1: 0x00000001, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IMarshal*: TGUID = (D1: 0x00000003, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IMalloc*: TGUID = (D1: 0x00000002, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IStdMarshalInfo*: TGUID = (D1: 0x00000018, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IExternalConnection*: TGUID = (D1: 0x00000019, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IEnumUnknown*: TGUID = (D1: 0x00000100, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IBindCtx*: TGUID = (D1: 0x0000000E, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumMoniker*: TGUID = (D1: 0x00000102, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IRunnableObject*: TGUID = (D1: 0x00000126, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IRunningObjectTable*: TGUID = (D1: 0x00000010, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IPersist*: TGUID = (D1: 0x0000010C, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IPersistStream*: TGUID = (D1: 0x00000109, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IMoniker*: TGUID = (D1: 0x0000000F, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumString*: TGUID = (D1: 0x00000101, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IStream*: TGUID = (D1: 0x0000000C, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumStatStg*: TGUID = (D1: 0x0000000D, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IStorage*: TGUID = (D1: 0x0000000B, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IPersistFile*: TGUID = (D1: 0x0000010B, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IPersistStorage*: TGUID = (D1: 0x0000010A, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_ILockBytes*: TGUID = (D1: 0x0000000A, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumFormatEtc*: TGUID = (D1: 0x00000103, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumStatData*: TGUID = (D1: 0x00000105, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IRootStorage*: TGUID = (D1: 0x00000012, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IAdviseSink*: TGUID = (D1: 0x0000010F, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IAdviseSink2*: TGUID = (D1: 0x00000125, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IDataObject*: TGUID = (D1: 0x0000010E, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IDataAdviseHolder*: TGUID = (D1: 0x00000110, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IMessageFilter*: TGUID = (D1: 0x00000016, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IRpcChannelBuffer*: TGUID = (D1: 0xD5F56B60, D2: 0x0000593B, 
-    D3: 0x0000101A, D4: [0x000000B5, 0x00000069, 0x00000008, 0x00000000, 
-                         0x0000002B, 0x0000002D, 0x000000BF, 0x0000007A])
-  IID_IRpcProxyBuffer*: TGUID = (D1: 0xD5F56A34, D2: 0x0000593B, D3: 0x0000101A, D4: [
-      0x000000B5, 0x00000069, 0x00000008, 0x00000000, 0x0000002B, 0x0000002D, 
-      0x000000BF, 0x0000007A])
-  IID_IRpcStubBuffer*: TGUID = (D1: 0xD5F56AFC, D2: 0x0000593B, D3: 0x0000101A, D4: [
-      0x000000B5, 0x00000069, 0x00000008, 0x00000000, 0x0000002B, 0x0000002D, 
-      0x000000BF, 0x0000007A])
-  IID_IPSFactoryBuffer*: TGUID = (D1: 0xD5F569D0, D2: 0x0000593B, 
-    D3: 0x0000101A, D4: [0x000000B5, 0x00000069, 0x00000008, 0x00000000, 
-                         0x0000002B, 0x0000002D, 0x000000BF, 0x0000007A])
-  IID_ICreateTypeInfo*: TGUID = (D1: 0x00020405, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_ICreateTypeLib*: TGUID = (D1: 0x00020406, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IDispatch*: TGUID = (D1: 0x00020400, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumVariant*: TGUID = (D1: 0x00020404, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_ITypeComp*: TGUID = (D1: 0x00020403, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_ITypeInfo*: TGUID = (D1: 0x00020401, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_ITypeLib*: TGUID = (D1: 0x00020402, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IErrorInfo*: TGUID = (D1: 0x1CF2B120, D2: 0x0000547D, D3: 0x0000101B, D4: [
-      0x0000008E, 0x00000065, 0x00000008, 0x00000000, 0x0000002B, 0x0000002B, 
-      0x000000D1, 0x00000019])
-  IID_ICreateErrorInfo*: TGUID = (D1: 0x22F03340, D2: 0x0000547D, 
-    D3: 0x0000101B, D4: [0x0000008E, 0x00000065, 0x00000008, 0x00000000, 
-                         0x0000002B, 0x0000002B, 0x000000D1, 0x00000019])
-  IID_ISupportErrorInfo*: TGUID = (D1: 0xDF0B3D60, D2: 0x0000548F, 
-    D3: 0x0000101B, D4: [0x0000008E, 0x00000065, 0x00000008, 0x00000000, 
-                         0x0000002B, 0x0000002B, 0x000000D1, 0x00000019])
-  IID_IOleAdviseHolder*: TGUID = (D1: 0x00000111, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleCache*: TGUID = (D1: 0x0000011E, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleCache2*: TGUID = (D1: 0x00000128, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleCacheControl*: TGUID = (D1: 0x00000129, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IParseDisplayName*: TGUID = (D1: 0x0000011A, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleContainer*: TGUID = (D1: 0x0000011B, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleClientSite*: TGUID = (D1: 0x00000118, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleObject*: TGUID = (D1: 0x00000112, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleWindow*: TGUID = (D1: 0x00000114, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleLink*: TGUID = (D1: 0x0000011D, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IOleItemContainer*: TGUID = (D1: 0x0000011C, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleInPlaceUIWindow*: TGUID = (D1: 0x00000115, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleInPlaceActiveObject*: TGUID = (D1: 0x00000117, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleInPlaceFrame*: TGUID = (D1: 0x00000116, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleInPlaceObject*: TGUID = (D1: 0x00000113, D2: 0x00000000, 
-    D3: 0x00000000, D4: [0x000000C0, 0x00000000, 0x00000000, 0x00000000, 
-                         0x00000000, 0x00000000, 0x00000000, 0x00000046])
-  IID_IOleInPlaceSite*: TGUID = (D1: 0x00000119, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IViewObject*: TGUID = (D1: 0x0000010D, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IViewObject2*: TGUID = (D1: 0x00000127, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IDropSource*: TGUID = (D1: 0x00000121, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IDropTarget*: TGUID = (D1: 0x00000122, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
-  IID_IEnumOleVerb*: TGUID = (D1: 0x00000104, D2: 0x00000000, D3: 0x00000000, D4: [
-      0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 
-      0x00000000, 0x00000046])
diff --git a/lib/windows/registry.nim b/lib/windows/registry.nim
new file mode 100644
index 000000000..207172f8c
--- /dev/null
+++ b/lib/windows/registry.nim
@@ -0,0 +1,82 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2016 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## This module is experimental and its interface may change.
+
+import std/oserrors
+
+when defined(nimPreviewSlimSystem):
+  import std/widestrs
+
+type
+  HKEY* = uint
+
+const
+  HKEY_LOCAL_MACHINE* = HKEY(0x80000002u)
+  HKEY_CURRENT_USER* = HKEY(2147483649)
+
+  RRF_RT_ANY = 0x0000ffff
+  KEY_WOW64_64KEY = 0x0100
+  KEY_WOW64_32KEY = 0x0200
+  KEY_READ = 0x00020019
+  REG_SZ = 1
+
+proc regOpenKeyEx(hKey: HKEY, lpSubKey: WideCString, ulOptions: int32,
+                  samDesired: int32,
+                  phkResult: var HKEY): int32 {.
+  importc: "RegOpenKeyExW", dynlib: "Advapi32.dll", stdcall.}
+
+proc regCloseKey(hkey: HKEY): int32 {.
+  importc: "RegCloseKey", dynlib: "Advapi32.dll", stdcall.}
+
+proc regGetValue(key: HKEY, lpSubKey, lpValue: WideCString;
+                 dwFlags: int32 = RRF_RT_ANY, pdwType: ptr int32,
+                 pvData: pointer,
+                 pcbData: ptr int32): int32 {.
+  importc: "RegGetValueW", dynlib: "Advapi32.dll", stdcall.}
+
+template call(f) =
+  let err = f
+  if err != 0:
+    raiseOSError(err.OSErrorCode, astToStr(f))
+
+proc getUnicodeValue*(path, key: string; handle: HKEY): string =
+  let hh = newWideCString path
+  let kk = newWideCString key
+  var bufSize: int32
+  # try a couple of different flag settings:
+  var flags: int32 = RRF_RT_ANY
+  let err = regGetValue(handle, hh, kk, flags, nil, nil, addr bufSize)
+  if err != 0:
+    var newHandle: HKEY
+    call regOpenKeyEx(handle, hh, 0, KEY_READ or KEY_WOW64_64KEY, newHandle)
+    call regGetValue(newHandle, nil, kk, flags, nil, nil, addr bufSize)
+    if bufSize > 0:
+      var res = newWideCString(bufSize)
+      call regGetValue(newHandle, nil, kk, flags, nil, addr res[0],
+                    addr bufSize)
+      result = res $ bufSize
+    call regCloseKey(newHandle)
+  else:
+    if bufSize > 0:
+      var res = newWideCString(bufSize)
+      call regGetValue(handle, hh, kk, flags, nil, addr res[0],
+                    addr bufSize)
+      result = res $ bufSize
+
+proc regSetValue(key: HKEY, lpSubKey, lpValueName: WideCString,
+                 dwType: int32; lpData: WideCString; cbData: int32): int32 {.
+  importc: "RegSetKeyValueW", dynlib: "Advapi32.dll", stdcall.}
+
+proc setUnicodeValue*(path, key, val: string; handle: HKEY) =
+  let hh = newWideCString path
+  let kk = newWideCString key
+  let vv = newWideCString val
+  call regSetValue(handle, hh, kk, REG_SZ, vv, (vv.len.int32+1)*2)
+
diff --git a/lib/windows/shellapi.nim b/lib/windows/shellapi.nim
deleted file mode 100755
index c6d2d69a1..000000000
--- a/lib/windows/shellapi.nim
+++ /dev/null
@@ -1,863 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-{.deadCodeElim: on.}
-
-# leave out unused functions so the unit can be used on win2000 as well
-
-#+-------------------------------------------------------------------------
-#
-#  Microsoft Windows
-#  Copyright (c) Microsoft Corporation. All rights reserved.
-#
-#  File: shellapi.h
-#
-#  Header translation by Marco van de Voort for Free Pascal Platform
-#  SDK dl'ed January 2002
-#
-#--------------------------------------------------------------------------
-
-#
-#    shellapi.h -  SHELL.DLL functions, types, and definitions
-#    Copyright (c) Microsoft Corporation. All rights reserved.
-
-import
-  Windows
-
-type
-  HDROP* = THandle
-  UINT_PTR* = ptr UINT
-  DWORD_PTR* = ptr DWORD
-  pHICON* = ptr HICON
-  pBool* = ptr BOOL
-  STARTUPINFOW* {.final.} = object      # a guess. Omission should get fixed in Windows.
-    cb*: DWORD
-    lpReserved*: LPTSTR
-    lpDesktop*: LPTSTR
-    lpTitle*: LPTSTR
-    dwX*: DWORD
-    dwY*: DWORD
-    dwXSize*: DWORD
-    dwYSize*: DWORD
-    dwXCountChars*: DWORD
-    dwYCountChars*: DWORD
-    dwFillAttribute*: DWORD
-    dwFlags*: DWORD
-    wShowWindow*: int16
-    cbReserved2*: int16
-    lpReserved2*: LPBYTE
-    hStdInput*: HANDLE
-    hStdOutput*: HANDLE
-    hStdError*: HANDLE
-
-  LPSTARTUPINFOW* = ptr STARTUPINFOW
-  TSTARTUPINFOW* = STARTUPINFOW
-  PSTARTUPINFOW* = ptr STARTUPINFOW #unicode
-
-proc DragQueryFileA*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{.
-    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
-proc DragQueryFileW*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{.
-    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
-proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPSTR, arg4: UINT): UINT{.
-    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
-proc DragQueryFile*(arg1: HDROP, arg2: UINT, arg3: LPWSTR, arg4: UINT): UINT{.
-    stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
-proc DragQueryPoint*(arg1: HDROP, arg2: LPPOINT): BOOL{.stdcall,
-    dynlib: "shell32.dll", importc: "DragQueryPoint".}
-proc DragFinish*(arg1: HDROP){.stdcall, dynlib: "shell32.dll",
-                               importc: "DragFinish".}
-proc DragAcceptFiles*(hwnd: HWND, arg2: BOOL){.stdcall, dynlib: "shell32.dll",
-    importc: "DragAcceptFiles".}
-proc ShellExecuteA*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR,
-                    lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
-proc ShellExecuteW*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
-                    lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
-proc ShellExecute*(HWND: hwnd, lpOperation: LPCSTR, lpFile: LPCSTR,
-                   lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
-proc ShellExecute*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
-                   lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
-proc FindExecutableA*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
-proc FindExecutableW*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
-proc FindExecutable*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
-proc FindExecutable*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
-    stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
-proc CommandLineToArgvW*(lpCmdLine: LPCWSTR, pNumArgs: ptr int32): pLPWSTR{.
-    stdcall, dynlib: "shell32.dll", importc: "CommandLineToArgvW".}
-proc ShellAboutA*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
-proc ShellAboutW*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR,
-                  HICON: hIcon): int32{.stdcall, dynlib: "shell32.dll",
-                                        importc: "ShellAboutW".}
-proc ShellAbout*(HWND: hWnd, szApp: LPCSTR, szOtherStuff: LPCSTR, HICON: hIcon): int32{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
-proc ShellAbout*(HWND: hWnd, szApp: LPCWSTR, szOtherStuff: LPCWSTR, HICON: hIcon): int32{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellAboutW".}
-proc DuplicateIcon*(hinst: HINST, HICON: hIcon): HIcon{.stdcall,
-    dynlib: "shell32.dll", importc: "DuplicateIcon".}
-proc ExtractAssociatedIconA*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
-proc ExtractAssociatedIconW*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
-proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
-proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
-proc ExtractIconA*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
-proc ExtractIconW*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
-proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: UINT): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
-proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: UINT): HICON{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
-  # if(WINVER >= 0x0400)
-type                          # init with sizeof(DRAGINFO)
-  DRAGINFOA* {.final.} = object
-    uSize*: UINT
-    pt*: POINT
-    fNC*: BOOL
-    lpFileList*: LPSTR
-    grfKeyState*: DWORD
-
-  TDRAGINFOA* = DRAGINFOA
-  LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO)
-  DRAGINFOW* {.final.} = object
-    uSize*: UINT
-    pt*: POINT
-    fNC*: BOOL
-    lpFileList*: LPWSTR
-    grfKeyState*: DWORD
-
-  TDRAGINFOW* = DRAGINFOW
-  LPDRAGINFOW* = ptr DRAGINFOW
-
-when defined(UNICODE):
-  type
-    DRAGINFO* = DRAGINFOW
-    TDRAGINFO* = DRAGINFOW
-    LPDRAGINFO* = LPDRAGINFOW
-else:
-  type
-    DRAGINFO* = DRAGINFOA
-    TDRAGINFO* = DRAGINFOW
-    LPDRAGINFO* = LPDRAGINFOA
-const
-  ABM_NEW* = 0x00000000
-  ABM_REMOVE* = 0x00000001
-  ABM_QUERYPOS* = 0x00000002
-  ABM_SETPOS* = 0x00000003
-  ABM_GETSTATE* = 0x00000004
-  ABM_GETTASKBARPOS* = 0x00000005
-  ABM_ACTIVATE* = 0x00000006  # lParam == TRUE/FALSE means activate/deactivate
-  ABM_GETAUTOHIDEBAR* = 0x00000007
-  ABM_SETAUTOHIDEBAR* = 0x00000008 # this can fail at any time.  MUST check the result
-                                   # lParam = TRUE/FALSE  Set/Unset
-                                   # uEdge = what edge
-  ABM_WINDOWPOSCHANGED* = 0x00000009
-  ABM_SETSTATE* = 0x0000000A
-  ABN_STATECHANGE* = 0x00000000 # these are put in the wparam of callback messages
-  ABN_POSCHANGED* = 0x00000001
-  ABN_FULLSCREENAPP* = 0x00000002
-  ABN_WINDOWARRANGE* = 0x00000003 # lParam == TRUE means hide
-                                  # flags for get state
-  ABS_AUTOHIDE* = 0x00000001
-  ABS_ALWAYSONTOP* = 0x00000002
-  ABE_LEFT* = 0
-  ABE_TOP* = 1
-  ABE_RIGHT* = 2
-  ABE_BOTTOM* = 3
-
-type
-  AppBarData* {.final.} = object
-    cbSize*: DWORD
-    hWnd*: HWND
-    uCallbackMessage*: UINT
-    uEdge*: UINT
-    rc*: RECT
-    lParam*: LPARAM           # message specific
-
-  TAPPBARDATA* = AppBarData
-  PAPPBARDATA* = ptr AppBarData
-
-proc SHAppBarMessage*(dwMessage: DWORD, pData: APPBARDATA): UINT_PTR{.stdcall,
-    dynlib: "shell32.dll", importc: "SHAppBarMessage".}
-  #
-  #  EndAppBar
-  #
-proc DoEnvironmentSubstA*(szString: LPSTR, cchString: UINT): DWORD{.stdcall,
-    dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
-proc DoEnvironmentSubstW*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall,
-    dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
-proc DoEnvironmentSubst*(szString: LPSTR, cchString: UINT): DWORD{.stdcall,
-    dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
-proc DoEnvironmentSubst*(szString: LPWSTR, cchString: UINT): DWORD{.stdcall,
-    dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
-  #Macro
-proc EIRESID*(x: int32): int32
-proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON,
-                     phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
-    dynlib: "shell32.dll", importc: "ExtractIconExA".}
-proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON,
-                     phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
-    dynlib: "shell32.dll", importc: "ExtractIconExW".}
-proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32,
-                     phiconLarge: var HICON, phiconSmall: var HIcon,
-                     nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll",
-    importc: "ExtractIconExA".}
-proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32,
-                     phiconLarge: var HICON, phiconSmall: var HIcon,
-                     nIcons: UINT): UINT{.stdcall, dynlib: "shell32.dll",
-    importc: "ExtractIconExW".}
-proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: pHICON,
-                    phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
-    dynlib: "shell32.dll", importc: "ExtractIconExA".}
-proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: pHICON,
-                    phiconSmall: pHIcon, nIcons: UINT): UINT{.stdcall,
-    dynlib: "shell32.dll", importc: "ExtractIconExW".}
-proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: var HICON,
-                    phiconSmall: var HIcon, nIcons: UINT): UINT{.stdcall,
-    dynlib: "shell32.dll", importc: "ExtractIconExA".}
-proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32,
-                    phiconLarge: var HICON, phiconSmall: var HIcon, nIcons: UINT): UINT{.
-    stdcall, dynlib: "shell32.dll", importc: "ExtractIconExW".}
-  #
-  # Shell File Operations
-  #
-  #ifndef FO_MOVE  //these need to be kept in sync with the ones in shlobj.h}
-const
-  FO_MOVE* = 0x00000001
-  FO_COPY* = 0x00000002
-  FO_DELETE* = 0x00000003
-  FO_RENAME* = 0x00000004
-  FOF_MULTIDESTFILES* = 0x00000001
-  FOF_CONFIRMMOUSE* = 0x00000002
-  FOF_SILENT* = 0x00000004    # don't create progress/report
-  FOF_RENAMEONCOLLISION* = 0x00000008
-  FOF_NOCONFIRMATION* = 0x00000010 # Don't prompt the user.
-  FOF_WANTMAPPINGHANDLE* = 0x00000020 # Fill in SHFILEOPSTRUCT.hNameMappings
-  FOF_ALLOWUNDO* = 0x00000040 # Must be freed using SHFreeNameMappings
-  FOF_FILESONLY* = 0x00000080 # on *.*, do only files
-  FOF_SIMPLEPROGRESS* = 0x00000100 # means don't show names of files
-  FOF_NOCONFIRMMKDIR* = 0x00000200 # don't confirm making any needed dirs
-  FOF_NOERRORUI* = 0x00000400 # don't put up error UI
-  FOF_NOCOPYSECURITYATTRIBS* = 0x00000800 # dont copy NT file Security Attributes
-  FOF_NORECURSION* = 0x00001000 # don't recurse into directories.
-                                #if (_WIN32_IE >= 0x0500)
-  FOF_NO_CONNECTED_ELEMENTS* = 0x00002000 # don't operate on connected elements.
-  FOF_WANTNUKEWARNING* = 0x00004000 # during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
-                                    #endif
-                                    #if (_WIN32_WINNT >= 0x0501)
-  FOF_NORECURSEREPARSE* = 0x00008000 # treat reparse points as objects, not containers
-                                     #endif
-
-type
-  FILEOP_FLAGS* = int16
-
-const
-  PO_DELETE* = 0x00000013     # printer is being deleted
-  PO_RENAME* = 0x00000014     # printer is being renamed
-  PO_PORTCHANGE* = 0x00000020 # port this printer connected to is being changed
-                              # if this id is set, the strings received by
-                              # the copyhook are a doubly-null terminated
-                              # list of strings.  The first is the printer
-                              # name and the second is the printer port.
-  PO_REN_PORT* = 0x00000034   # PO_RENAME and PO_PORTCHANGE at same time.
-                              # no POF_ flags currently defined
-
-type
-  PRINTEROP_FLAGS* = int16 #endif}
-                           # FO_MOVE
-                           # implicit parameters are:
-                           #      if pFrom or pTo are unqualified names the current directories are
-                           #      taken from the global current drive/directory settings managed
-                           #      by Get/SetCurrentDrive/Directory
-                           #
-                           #      the global confirmation settings
-                           # only used if FOF_SIMPLEPROGRESS
-
-type
-  SHFILEOPSTRUCTA* {.final.} = object
-    hwnd*: HWND
-    wFunc*: UINT
-    pFrom*: LPCSTR
-    pTo*: LPCSTR
-    fFlags*: FILEOP_FLAGS
-    fAnyOperationsAborted*: BOOL
-    hNameMappings*: LPVOID
-    lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS
-
-  TSHFILEOPSTRUCTA* = SHFILEOPSTRUCTA
-  LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA
-  SHFILEOPSTRUCTW* {.final.} = object
-    hwnd*: HWND
-    wFunc*: UINT
-    pFrom*: LPCWSTR
-    pTo*: LPCWSTR
-    fFlags*: FILEOP_FLAGS
-    fAnyOperationsAborted*: BOOL
-    hNameMappings*: LPVOID
-    lpszProgressTitle*: LPCWSTR
-
-  TSHFILEOPSTRUCTW* = SHFILEOPSTRUCTW
-  LPSHFILEOPSTRUCTW* = ptr SHFILEOPSTRUCTW
-
-when defined(UNICODE):
-  type
-    SHFILEOPSTRUCT* = SHFILEOPSTRUCTW
-    TSHFILEOPSTRUCT* = SHFILEOPSTRUCTW
-    LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTW
-else:
-  type
-    SHFILEOPSTRUCT* = SHFILEOPSTRUCTA
-    TSHFILEOPSTRUCT* = SHFILEOPSTRUCTA
-    LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTA
-proc SHFileOperationA*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
-    dynlib: "shell32.dll", importc: "SHFileOperationA".}
-proc SHFileOperationW*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
-    dynlib: "shell32.dll", importc: "SHFileOperationW".}
-proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
-    dynlib: "shell32.dll", importc: "SHFileOperationA".}
-proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
-    dynlib: "shell32.dll", importc: "SHFileOperationW".}
-proc SHFreeNameMappings*(hNameMappings: THandle){.stdcall,
-    dynlib: "shell32.dll", importc: "SHFreeNameMappings".}
-type
-  SHNAMEMAPPINGA* {.final.} = object
-    pszOldPath*: LPSTR
-    pszNewPath*: LPSTR
-    cchOldPath*: int32
-    cchNewPath*: int32
-
-  TSHNAMEMAPPINGA* = SHNAMEMAPPINGA
-  LPSHNAMEMAPPINGA* = ptr SHNAMEMAPPINGA
-  SHNAMEMAPPINGW* {.final.} = object
-    pszOldPath*: LPWSTR
-    pszNewPath*: LPWSTR
-    cchOldPath*: int32
-    cchNewPath*: int32
-
-  TSHNAMEMAPPINGW* = SHNAMEMAPPINGW
-  LPSHNAMEMAPPINGW* = ptr SHNAMEMAPPINGW
-
-when not(defined(UNICODE)):
-  type
-    SHNAMEMAPPING* = SHNAMEMAPPINGW
-    TSHNAMEMAPPING* = SHNAMEMAPPINGW
-    LPSHNAMEMAPPING* = LPSHNAMEMAPPINGW
-else:
-  type
-    SHNAMEMAPPING* = SHNAMEMAPPINGA
-    TSHNAMEMAPPING* = SHNAMEMAPPINGA
-    LPSHNAMEMAPPING* = LPSHNAMEMAPPINGA
-#
-# End Shell File Operations
-#
-#
-#  Begin ShellExecuteEx and family
-#
-# ShellExecute() and ShellExecuteEx() error codes
-# regular WinExec() codes
-
-const
-  SE_ERR_FNF* = 2             # file not found
-  SE_ERR_PNF* = 3             # path not found
-  SE_ERR_ACCESSDENIED* = 5    # access denied
-  SE_ERR_OOM* = 8             # out of memory
-  SE_ERR_DLLNOTFOUND* = 32    # endif   WINVER >= 0x0400
-                              # error values for ShellExecute() beyond the regular WinExec() codes
-  SE_ERR_SHARE* = 26
-  SE_ERR_ASSOCINCOMPLETE* = 27
-  SE_ERR_DDETIMEOUT* = 28
-  SE_ERR_DDEFAIL* = 29
-  SE_ERR_DDEBUSY* = 30
-  SE_ERR_NOASSOC* = 31        #if(WINVER >= 0x0400)}
-                              # Note CLASSKEY overrides CLASSNAME
-  SEE_MASK_CLASSNAME* = 0x00000001
-  SEE_MASK_CLASSKEY* = 0x00000003 # Note INVOKEIDLIST overrides IDLIST
-  SEE_MASK_IDLIST* = 0x00000004
-  SEE_MASK_INVOKEIDLIST* = 0x0000000C
-  SEE_MASK_ICON* = 0x00000010
-  SEE_MASK_HOTKEY* = 0x00000020
-  SEE_MASK_NOCLOSEPROCESS* = 0x00000040
-  SEE_MASK_CONNECTNETDRV* = 0x00000080
-  SEE_MASK_FLAG_DDEWAIT* = 0x00000100
-  SEE_MASK_DOENVSUBST* = 0x00000200
-  SEE_MASK_FLAG_NO_UI* = 0x00000400
-  SEE_MASK_UNICODE* = 0x00004000
-  SEE_MASK_NO_CONSOLE* = 0x00008000
-  SEE_MASK_ASYNCOK* = 0x00100000
-  SEE_MASK_HMONITOR* = 0x00200000 #if (_WIN32_IE >= 0x0500)
-  SEE_MASK_NOQUERYCLASSSTORE* = 0x01000000
-  SEE_MASK_WAITFORINPUTIDLE* = 0x02000000 #endif  (_WIN32_IE >= 0x500)
-                                          #if (_WIN32_IE >= 0x0560)
-  SEE_MASK_FLAG_LOG_USAGE* = 0x04000000 #endif
-                                        # (_WIN32_IE >= 0x560)
-
-type
-  SHELLEXECUTEINFOA* {.final.} = object
-    cbSize*: DWORD
-    fMask*: ULONG
-    hwnd*: HWND
-    lpVerb*: LPCSTR
-    lpFile*: LPCSTR
-    lpParameters*: LPCSTR
-    lpDirectory*: LPCSTR
-    nShow*: int32
-    hInstApp*: HINST
-    lpIDList*: LPVOID
-    lpClass*: LPCSTR
-    hkeyClass*: HKEY
-    dwHotKey*: DWORD
-    hMonitor*: HANDLE         # also: hIcon
-    hProcess*: HANDLE
-
-  TSHELLEXECUTEINFOA* = SHELLEXECUTEINFOA
-  LPSHELLEXECUTEINFOA* = ptr SHELLEXECUTEINFOA
-  SHELLEXECUTEINFOW* {.final.} = object
-    cbSize*: DWORD
-    fMask*: ULONG
-    hwnd*: HWND
-    lpVerb*: lpcwstr
-    lpFile*: lpcwstr
-    lpParameters*: lpcwstr
-    lpDirectory*: lpcwstr
-    nShow*: int32
-    hInstApp*: HINST
-    lpIDList*: LPVOID
-    lpClass*: LPCWSTR
-    hkeyClass*: HKEY
-    dwHotKey*: DWORD
-    hMonitor*: HANDLE         # also: hIcon
-    hProcess*: HANDLE
-
-  TSHELLEXECUTEINFOW* = SHELLEXECUTEINFOW
-  LPSHELLEXECUTEINFOW* = ptr SHELLEXECUTEINFOW
-
-when defined(UNICODE):
-  type
-    SHELLEXECUTEINFO* = SHELLEXECUTEINFOW
-    TSHELLEXECUTEINFO* = SHELLEXECUTEINFOW
-    LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOW
-else:
-  type
-    SHELLEXECUTEINFO* = SHELLEXECUTEINFOA
-    TSHELLEXECUTEINFO* = SHELLEXECUTEINFOA
-    LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA
-proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "ShellExecuteExA".}
-proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "ShellExecuteExW".}
-proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOA): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "ShellExecuteExA".}
-proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOW): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "ShellExecuteExW".}
-proc WinExecErrorA*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR,
-                    lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
-    importc: "WinExecErrorA".}
-proc WinExecErrorW*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR,
-                    lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
-    importc: "WinExecErrorW".}
-proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCSTR,
-                   lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
-                                        importc: "WinExecErrorA".}
-proc WinExecError*(HWND: hwnd, error: int32, lpstrFileName: LPCWSTR,
-                   lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
-    importc: "WinExecErrorW".}
-type
-  SHCREATEPROCESSINFOW* {.final.} = object
-    cbSize*: DWORD
-    fMask*: ULONG
-    hwnd*: HWND
-    pszFile*: LPCWSTR
-    pszParameters*: LPCWSTR
-    pszCurrentDirectory*: LPCWSTR
-    hUserToken*: HANDLE
-    lpProcessAttributes*: LPSECURITY_ATTRIBUTES
-    lpThreadAttributes*: LPSECURITY_ATTRIBUTES
-    bInheritHandles*: BOOL
-    dwCreationFlags*: DWORD
-    lpStartupInfo*: LPSTARTUPINFOW
-    lpProcessInformation*: LPPROCESS_INFORMATION
-
-  TSHCREATEPROCESSINFOW* = SHCREATEPROCESSINFOW
-  PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW
-
-proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".}
-  #
-  #  End ShellExecuteEx and family }
-  #
-  #
-  # RecycleBin
-  #
-  # struct for query recycle bin info
-type
-  SHQUERYRBINFO* {.final.} = object
-    cbSize*: DWORD
-    i64Size*: int64
-    i64NumItems*: int64
-
-  TSHQUERYRBINFO* = SHQUERYRBINFO
-  LPSHQUERYRBINFO* = ptr SHQUERYRBINFO # flags for SHEmptyRecycleBin
-
-const
-  SHERB_NOCONFIRMATION* = 0x00000001
-  SHERB_NOPROGRESSUI* = 0x00000002
-  SHERB_NOSOUND* = 0x00000004
-
-proc SHQueryRecycleBinA*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
-proc SHQueryRecycleBinW*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
-proc SHQueryRecycleBin*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
-proc SHQueryRecycleBin*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
-proc SHEmptyRecycleBinA*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
-proc SHEmptyRecycleBinW*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
-proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
-proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
-  #
-  # end of RecycleBin
-  #
-  #
-  # Tray notification definitions
-  #
-type
-  NOTIFYICONDATAA* {.final.} = object
-    cbSize*: DWORD
-    hWnd*: HWND
-    uID*: UINT
-    uFlags*: UINT
-    uCallbackMessage*: UINT
-    hIcon*: HICON
-    szTip*: array[0..127, CHAR]
-    dwState*: DWORD
-    dwStateMask*: DWORD
-    szInfo*: array[0..255, CHAR]
-    uTimeout*: UINT           # also: uVersion
-    szInfoTitle*: array[0..63, CHAR]
-    dwInfoFlags*: DWORD
-    guidItem*: TGUID
-
-  TNOTIFYICONDATAA* = NOTIFYICONDATAA
-  PNOTIFYICONDATAA* = ptr NOTIFYICONDATAA
-  NOTIFYICONDATAW* {.final.} = object
-    cbSize*: DWORD
-    hWnd*: HWND
-    uID*: UINT
-    uFlags*: UINT
-    uCallbackMessage*: UINT
-    hIcon*: HICON
-    szTip*: array[0..127, WCHAR]
-    dwState*: DWORD
-    dwStateMask*: DWORD
-    szInfo*: array[0..255, WCHAR]
-    uTimeout*: UINT           # also uVersion : UINT
-    szInfoTitle*: array[0..63, CHAR]
-    dwInfoFlags*: DWORD
-    guidItem*: TGUID
-
-  TNOTIFYICONDATAW* = NOTIFYICONDATAW
-  PNOTIFYICONDATAW* = ptr NOTIFYICONDATAW
-
-when defined(UNICODE):
-  type
-    NOTIFYICONDATA* = NOTIFYICONDATAW
-    TNOTIFYICONDATA* = NOTIFYICONDATAW
-    PNOTIFYICONDATA* = PNOTIFYICONDATAW
-else:
-  type
-    NOTIFYICONDATA* = NOTIFYICONDATAA
-    TNOTIFYICONDATA* = NOTIFYICONDATAA
-    PNOTIFYICONDATA* = PNOTIFYICONDATAA
-const
-  NIN_SELECT* = WM_USER + 0
-  NINF_KEY* = 0x00000001
-  NIN_KEYSELECT* = NIN_SELECT or NINF_KEY
-  NIN_BALLOONSHOW* = WM_USER + 2
-  NIN_BALLOONHIDE* = WM_USER + 3
-  NIN_BALLOONTIMEOUT* = WM_USER + 4
-  NIN_BALLOONUSERCLICK* = WM_USER + 5
-  NIM_ADD* = 0x00000000
-  NIM_MODIFY* = 0x00000001
-  NIM_DELETE* = 0x00000002
-  NIM_SETFOCUS* = 0x00000003
-  NIM_SETVERSION* = 0x00000004
-  NOTIFYICON_VERSION* = 3
-  NIF_MESSAGE* = 0x00000001
-  NIF_ICON* = 0x00000002
-  NIF_TIP* = 0x00000004
-  NIF_STATE* = 0x00000008
-  NIF_INFO* = 0x00000010
-  NIF_GUID* = 0x00000020
-  NIS_HIDDEN* = 0x00000001
-  NIS_SHAREDICON* = 0x00000002 # says this is the source of a shared icon
-                               # Notify Icon Infotip flags
-  NIIF_NONE* = 0x00000000     # icon flags are mutually exclusive
-                              # and take only the lowest 2 bits
-  NIIF_INFO* = 0x00000001
-  NIIF_WARNING* = 0x00000002
-  NIIF_ERROR* = 0x00000003
-  NIIF_ICON_MASK* = 0x0000000F
-  NIIF_NOSOUND* = 0x00000010
-
-proc Shell_NotifyIconA*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
-proc Shell_NotifyIconW*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
-proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
-proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
-  #
-  #       The SHGetFileInfo API provides an easy way to get attributes
-  #       for a file given a pathname.
-  #
-  #         PARAMETERS
-  #
-  #           pszPath              file name to get info about
-  #           dwFileAttributes     file attribs, only used with SHGFI_USEFILEATTRIBUTES
-  #           psfi                 place to return file info
-  #           cbFileInfo           size of structure
-  #           uFlags               flags
-  #
-  #         RETURN
-  #           TRUE if things worked
-  #
-  # out: icon
-  # out: icon index
-  # out: SFGAO_ flags
-  # out: display name (or path)
-  # out: type name
-type
-  SHFILEINFOA* {.final.} = object
-    hIcon*: HICON             # out: icon
-    iIcon*: int32             # out: icon index
-    dwAttributes*: DWORD      # out: SFGAO_ flags
-    szDisplayName*: array[0..(MAX_PATH) - 1, CHAR] # out: display name (or path)
-    szTypeName*: array[0..79, CHAR] # out: type name
-
-  TSHFILEINFOA* = SHFILEINFOA
-  pSHFILEINFOA* = ptr SHFILEINFOA
-  SHFILEINFOW* {.final.} = object
-    hIcon*: HICON             # out: icon
-    iIcon*: int32             # out: icon index
-    dwAttributes*: DWORD      # out: SFGAO_ flags
-    szDisplayName*: array[0..(MAX_PATH) - 1, WCHAR] # out: display name (or path)
-    szTypeName*: array[0..79, WCHAR] # out: type name
-
-  TSHFILEINFOW* = SHFILEINFOW
-  pSHFILEINFOW* = ptr SHFILEINFOW
-
-when defined(UNICODE):
-  type
-    SHFILEINFO* = SHFILEINFOW
-    TSHFILEINFO* = SHFILEINFOW
-    pFILEINFO* = SHFILEINFOW
-else:
-  type
-    SHFILEINFO* = SHFILEINFOA
-    TSHFILEINFO* = SHFILEINFOA
-    pFILEINFO* = SHFILEINFOA
-# NOTE: This is also in shlwapi.h.  Please keep in synch.
-
-const
-  SHGFI_ICON* = 0x00000100    # get Icon
-  SHGFI_DISPLAYNAME* = 0x00000200 # get display name
-  SHGFI_TYPENAME* = 0x00000400 # get type name
-  SHGFI_ATTRIBUTES* = 0x00000800 # get attributes
-  SHGFI_ICONLOCATION* = 0x00001000 # get icon location
-  SHGFI_EXETYPE* = 0x00002000 # return exe type
-  SHGFI_SYSICONINDEX* = 0x00004000 # get system icon index
-  SHGFI_LINKOVERLAY* = 0x00008000 # put a link overlay on icon
-  SHGFI_SELECTED* = 0x00010000 # show icon in selected state
-  SHGFI_ATTR_SPECIFIED* = 0x00020000 # get only specified attributes
-  SHGFI_LARGEICON* = 0x00000000 # get large icon
-  SHGFI_SMALLICON* = 0x00000001 # get small icon
-  SHGFI_OPENICON* = 0x00000002 # get open icon
-  SHGFI_SHELLICONSIZE* = 0x00000004 # get shell size icon
-  SHGFI_PIDL* = 0x00000008    # pszPath is a pidl
-  SHGFI_USEFILEATTRIBUTES* = 0x00000010 # use passed dwFileAttribute
-  SHGFI_ADDOVERLAYS* = 0x00000020 # apply the appropriate overlays
-  SHGFI_OVERLAYINDEX* = 0x00000040 # Get the index of the overlay
-                                   # in the upper 8 bits of the iIcon
-
-proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
-                     psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
-proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
-                     psfi: pSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
-proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
-                    psfi: pSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
-proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
-                     psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
-proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
-                     psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
-proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
-                    psfi: var TSHFILEINFOA, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
-proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
-                    psfi: var TSHFILEINFOW, cbFileInfo, UFlags: UINT): DWORD{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
-proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR,
-                            pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                            pulTotalNumberOfBytes: pULARGE_INTEGER,
-                            pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
-proc SHGetDiskFreeSpaceExW*(pszDirectoryName: LPCWSTR,
-                            pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                            pulTotalNumberOfBytes: pULARGE_INTEGER,
-                            pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
-proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCSTR,
-                           pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                           pulTotalNumberOfBytes: pULARGE_INTEGER,
-                           pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
-proc SHGetDiskFreeSpace*(pszDirectoryName: LPCSTR,
-                         pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                         pulTotalNumberOfBytes: pULARGE_INTEGER,
-                         pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
-proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCWSTR,
-                           pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                           pulTotalNumberOfBytes: pULARGE_INTEGER,
-                           pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
-proc SHGetDiskFreeSpace*(pszDirectoryName: LPCWSTR,
-                         pulFreeBytesAvailableToCaller: pULARGE_INTEGER,
-                         pulTotalNumberOfBytes: pULARGE_INTEGER,
-                         pulTotalNumberOfFreeBytes: pULARGE_INTEGER): Bool{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
-proc SHGetNewLinkInfoA*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
-                        pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
-proc SHGetNewLinkInfoW*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
-                        pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
-proc SHGetNewLinkInfo*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
-                       pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
-proc SHGetNewLinkInfo*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
-                       pfMustCopy: pBool, uFlags: UINT): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
-const
-  SHGNLI_PIDL* = 0x00000001   # pszLinkTo is a pidl
-  SHGNLI_PREFIXNAME* = 0x00000002 # Make name "Shortcut to xxx"
-  SHGNLI_NOUNIQUE* = 0x00000004 # don't do the unique name generation
-  SHGNLI_NOLNK* = 0x00000008  # don't add ".lnk" extension
-  PRINTACTION_OPEN* = 0
-  PRINTACTION_PROPERTIES* = 1
-  PRINTACTION_NETINSTALL* = 2
-  PRINTACTION_NETINSTALLLINK* = 3
-  PRINTACTION_TESTPAGE* = 4
-  PRINTACTION_OPENNETPRN* = 5
-  PRINTACTION_DOCUMENTDEFAULTS* = 6
-  PRINTACTION_SERVERPROPERTIES* = 7
-
-proc SHInvokePrinterCommandA*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR,
-                              lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
-proc SHInvokePrinterCommandW*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR,
-                              lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
-proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCSTR,
-                             lpBuf2: LPCSTR, fModal: Bool): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
-proc SHInvokePrinterCommand*(HWND: hwnd, uAction: UINT, lpBuf1: LPCWSTR,
-                             lpBuf2: LPCWSTR, fModal: Bool): Bool{.stdcall,
-    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
-proc SHLoadNonloadedIconOverlayIdentifiers*(): HResult{.stdcall,
-    dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
-proc SHIsFileAvailableOffline*(pwszPath: LPCWSTR, pdwStatus: LPDWORD): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHIsFileAvailableOffline".}
-const
-  OFFLINE_STATUS_LOCAL* = 0x00000001 # If open, it's open locally
-  OFFLINE_STATUS_REMOTE* = 0x00000002 # If open, it's open remotely
-  OFFLINE_STATUS_INCOMPLETE* = 0x00000004 # The local copy is currently incomplete.
-                                          # The file will not be available offline
-                                          # until it has been synchronized.
-                                          #  sets the specified path to use the string resource
-                                          #  as the UI instead of the file system name
-
-proc SHSetLocalizedName*(pszPath: LPWSTR, pszResModule: LPCWSTR, idsRes: int32): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHSetLocalizedName".}
-proc SHEnumerateUnreadMailAccountsA*(hKeyUser: HKEY, dwIndex: DWORD,
-                                     pszMailAddress: LPSTR,
-                                     cchMailAddress: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsA".}
-proc SHEnumerateUnreadMailAccountsW*(hKeyUser: HKEY, dwIndex: DWORD,
-                                     pszMailAddress: LPWSTR,
-                                     cchMailAddress: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
-proc SHEnumerateUnreadMailAccounts*(hKeyUser: HKEY, dwIndex: DWORD,
-                                    pszMailAddress: LPWSTR,
-                                    cchMailAddress: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
-proc SHGetUnreadMailCountA*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
-                            pdwCount: PDWORD, pFileTime: PFILETIME,
-                            pszShellExecuteCommand: LPSTR,
-                            cchShellExecuteCommand: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
-proc SHGetUnreadMailCountW*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
-                            pdwCount: PDWORD, pFileTime: PFILETIME,
-                            pszShellExecuteCommand: LPWSTR,
-                            cchShellExecuteCommand: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
-proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
-                           pdwCount: PDWORD, pFileTime: PFILETIME,
-                           pszShellExecuteCommand: LPSTR,
-                           cchShellExecuteCommand: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
-proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
-                           pdwCount: PDWORD, pFileTime: PFILETIME,
-                           pszShellExecuteCommand: LPWSTR,
-                           cchShellExecuteCommand: int32): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
-proc SHSetUnreadMailCountA*(pszMailAddress: LPCSTR, dwCount: DWORD,
-                            pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
-proc SHSetUnreadMailCountW*(pszMailAddress: LPCWSTR, dwCount: DWORD,
-                            pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
-proc SHSetUnreadMailCount*(pszMailAddress: LPCSTR, dwCount: DWORD,
-                           pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
-proc SHSetUnreadMailCount*(pszMailAddress: LPCWSTR, dwCount: DWORD,
-                           pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
-    dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
-proc SHGetImageList*(iImageList: int32, riid: TIID, ppvObj: ptr pointer): HRESULT{.
-    stdcall, dynlib: "shell32.dll", importc: "SHGetImageList".}
-const
-  SHIL_LARGE* = 0             # normally 32x32
-  SHIL_SMALL* = 1             # normally 16x16
-  SHIL_EXTRALARGE* = 2
-  SHIL_SYSSMALL* = 3          # like SHIL_SMALL, but tracks system small icon metric correctly
-  SHIL_LAST* = SHIL_SYSSMALL
-
-# implementation
-
-proc EIRESID(x: int32): int32 =
-  result = - int(x)
diff --git a/lib/windows/shfolder.nim b/lib/windows/shfolder.nim
deleted file mode 100755
index 253b1c77a..000000000
--- a/lib/windows/shfolder.nim
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2006 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-# ---------------------------------------------------------------------
-#  shfolder.dll is distributed standard with IE5.5, so it should ship
-#  with 2000/XP or higher but is likely to be installed on NT/95/98 or
-#  ME as well.  It works on all these systems.
-#
-#  The info found here is also in the registry:
-#  HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\
-#  HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\
-#
-#  Note that not all CSIDL_* constants are supported by shlfolder.dll,
-#  they should be supported by the shell32.dll, though again not on all
-#  systems.
-#  ---------------------------------------------------------------------
-
-{.deadCodeElim: on.}
-
-import 
-  windows
-
-const 
-  LibName* = "SHFolder.dll"
-
-const 
-  CSIDL_PROGRAMS* = 0x00000002 # %SYSTEMDRIVE%\Program Files                                      
-  CSIDL_PERSONAL* = 0x00000005 # %USERPROFILE%\My Documents                                       
-  CSIDL_FAVORITES* = 0x00000006 # %USERPROFILE%\Favorites                                          
-  CSIDL_STARTUP* = 0x00000007 # %USERPROFILE%\Start menu\Programs\Startup                        
-  CSIDL_RECENT* = 0x00000008  # %USERPROFILE%\Recent                                             
-  CSIDL_SENDTO* = 0x00000009  # %USERPROFILE%\Sendto                                             
-  CSIDL_STARTMENU* = 0x0000000B # %USERPROFILE%\Start menu                                         
-  CSIDL_MYMUSIC* = 0x0000000D # %USERPROFILE%\Documents\My Music                                 
-  CSIDL_MYVIDEO* = 0x0000000E # %USERPROFILE%\Documents\My Videos                                
-  CSIDL_DESKTOPDIRECTORY* = 0x00000010 # %USERPROFILE%\Desktop                                            
-  CSIDL_NETHOOD* = 0x00000013 # %USERPROFILE%\NetHood                                            
-  CSIDL_TEMPLATES* = 0x00000015 # %USERPROFILE%\Templates                                          
-  CSIDL_COMMON_STARTMENU* = 0x00000016 # %PROFILEPATH%\All users\Start menu                               
-  CSIDL_COMMON_PROGRAMS* = 0x00000017 # %PROFILEPATH%\All users\Start menu\Programs                      
-  CSIDL_COMMON_STARTUP* = 0x00000018 # %PROFILEPATH%\All users\Start menu\Programs\Startup              
-  CSIDL_COMMON_DESKTOPDIRECTORY* = 0x00000019 # %PROFILEPATH%\All users\Desktop                                  
-  CSIDL_APPDATA* = 0x0000001A # %USERPROFILE%\Application Data (roaming)                         
-  CSIDL_PRINTHOOD* = 0x0000001B # %USERPROFILE%\Printhood                                          
-  CSIDL_LOCAL_APPDATA* = 0x0000001C # %USERPROFILE%\Local Settings\Application Data (non roaming)      
-  CSIDL_COMMON_FAVORITES* = 0x0000001F # %PROFILEPATH%\All users\Favorites                                
-  CSIDL_INTERNET_CACHE* = 0x00000020 # %USERPROFILE%\Local Settings\Temporary Internet Files            
-  CSIDL_COOKIES* = 0x00000021 # %USERPROFILE%\Cookies                                            
-  CSIDL_HISTORY* = 0x00000022 # %USERPROFILE%\Local settings\History                             
-  CSIDL_COMMON_APPDATA* = 0x00000023 # %PROFILESPATH%\All Users\Application Data                        
-  CSIDL_WINDOWS* = 0x00000024 # %SYSTEMROOT%                                                     
-  CSIDL_SYSTEM* = 0x00000025  # %SYSTEMROOT%\SYSTEM32 (may be system on 95/98/ME)                
-  CSIDL_PROGRAM_FILES* = 0x00000026 # %SYSTEMDRIVE%\Program Files                                      
-  CSIDL_MYPICTURES* = 0x00000027 # %USERPROFILE%\My Documents\My Pictures                           
-  CSIDL_PROFILE* = 0x00000028 # %USERPROFILE%                                                    
-  CSIDL_PROGRAM_FILES_COMMON* = 0x0000002B # %SYSTEMDRIVE%\Program Files\Common                               
-  CSIDL_COMMON_TEMPLATES* = 0x0000002D # %PROFILEPATH%\All Users\Templates                                
-  CSIDL_COMMON_DOCUMENTS* = 0x0000002E # %PROFILEPATH%\All Users\Documents                                
-  CSIDL_COMMON_ADMINTOOLS* = 0x0000002F # %PROFILEPATH%\All Users\Start Menu\Programs\Administrative Tools 
-  CSIDL_ADMINTOOLS* = 0x00000030 # %USERPROFILE%\Start Menu\Programs\Administrative Tools           
-  CSIDL_COMMON_MUSIC* = 0x00000035 # %PROFILEPATH%\All Users\Documents\my music                       
-  CSIDL_COMMON_PICTURES* = 0x00000036 # %PROFILEPATH%\All Users\Documents\my pictures                    
-  CSIDL_COMMON_VIDEO* = 0x00000037 # %PROFILEPATH%\All Users\Documents\my videos                      
-  CSIDL_CDBURN_AREA* = 0x0000003B # %USERPROFILE%\Local Settings\Application Data\Microsoft\CD Burning 
-  CSIDL_PROFILES* = 0x0000003E # %PROFILEPATH%                                                    
-  CSIDL_FLAG_CREATE* = 0x00008000 # (force creation of requested folder if it doesn't exist yet)     
-                                  # Original entry points 
-
-proc SHGetFolderPathA*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, 
-                       Path: cstring): HRESULT{.stdcall, dynlib: LibName, 
-    importc: "SHGetFolderPathA".}
-proc SHGetFolderPathW*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, 
-                       Path: cstring): HRESULT{.stdcall, dynlib: LibName, 
-    importc: "SHGetFolderPathW".}
-proc SHGetFolderPath*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, 
-                      Path: cstring): HRESULT{.stdcall, dynlib: LibName, 
-    importc: "SHGetFolderPathA".}
-type 
-  PFNSHGetFolderPathA* = proc (Ahwnd: HWND, Csidl: int, Token: THandle, 
-                               Flags: DWord, Path: cstring): HRESULT{.stdcall.}
-  PFNSHGetFolderPathW* = proc (Ahwnd: HWND, Csidl: int, Token: THandle, 
-                               Flags: DWord, Path: cstring): HRESULT{.stdcall.}
-  PFNSHGetFolderPath* = PFNSHGetFolderPathA
-  TSHGetFolderPathA* = PFNSHGetFolderPathA
-  TSHGetFolderPathW* = PFNSHGetFolderPathW
-  TSHGetFolderPath* = TSHGetFolderPathA
-
diff --git a/lib/windows/windows.nim b/lib/windows/windows.nim
deleted file mode 100755
index 20f9a9d7d..000000000
--- a/lib/windows/windows.nim
+++ /dev/null
@@ -1,23776 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Define ``winUnicode`` before importing this module for the
-## unicode version.
-
-{.deadCodeElim: on.}
-
-type
-  ATOM* = int16
-  TAtom* = ATOM
-  WINBOOL* = int32            # XXX: longbool;
-  WORDBOOL* = int16  # XXX: not a bool
-  CALTYPE* = int
-  CALID* = int
-  CCHAR* = char
-  COLORREF* = int
-  TCOLORREF* = int
-  SHORT* = int16
-  WINT* = int32
-  LONG* = int32
-  DWORD* = int32
-  PINTEGER* = ptr int32
-  PBOOL* = ptr WINBOOL
-  LONGLONG* = int64
-  PLONGLONG* = ptr LONGLONG
-  LPLONGLONG* = ptr LONGLONG
-  ULONGLONG* = int64          # used in AMD64 CONTEXT
-  PULONGLONG* = ptr ULONGLONG #
-  DWORD64* = int64            #
-  PDWORD64* = ptr DWORD64     #
-  INT_PTR* = TAddress
-  UINT_PTR* = TAddress
-  LONG_PTR* = TAddress
-  ULONG_PTR* = TAddress
-  DWORDLONG* = int64          # was unsigned long
-  PDWORDLONG* = ptr DWORDLONG
-  HANDLE* = int
-  THandle* = HANDLE
-  HRESULT* = int
-  PHRESULT* = ptr HRESULT
-  HACCEL* = HANDLE
-  HBITMAP* = HANDLE
-  HBRUSH* = HANDLE
-  HCOLORSPACE* = HANDLE
-  HCONV* = HANDLE
-  HCONVLIST* = HANDLE
-  HCURSOR* = HANDLE
-  HDBC* = HANDLE
-  HDC* = HANDLE
-  HDDEDATA* = HANDLE
-  HDESK* = HANDLE
-  HDROP* = HANDLE
-  HDWP* = HANDLE
-  HENHMETAFILE* = HANDLE
-  HENV* = HANDLE
-  HFILE* = HANDLE
-  HFONT* = HANDLE
-  HGDIOBJ* = HANDLE
-  HGLOBAL* = HANDLE
-  HGLRC* = HANDLE
-  HHOOK* = HANDLE
-  HICON* = HANDLE
-  HIMAGELIST* = HANDLE
-  HINST* = HANDLE             # Not HINSTANCE, else it has problems with the var HInstance
-  HKEY* = HANDLE
-  HKL* = HANDLE
-  HLOCAL* = HANDLE
-  HMENU* = HANDLE
-  HMETAFILE* = HANDLE
-  HMODULE* = HANDLE
-  HPALETTE* = HANDLE
-  HPEN* = HANDLE
-  HRASCONN* = HANDLE
-  HRGN* = HANDLE
-  HRSRC* = HANDLE
-  HSTMT* = HANDLE
-  HSTR* = HANDLE
-  HSZ* = HANDLE
-  HWINSTA* = HANDLE
-  HWND* = HANDLE
-  HTASK* = HANDLE
-  LANGID* = int16
-  LCID* = DWORD
-  LCTYPE* = DWORD
-  LPARAM* = LONG_PTR
-  LP* = ptr int16
-  LPBOOL* = ptr WINBOOL
-  LPBYTE* = ptr int8
-  LPCCH* = cstring
-  LPCH* = cstring
-  LPCOLORREF* = ptr COLORREF
-  LPCSTR* = cstring
-  PWideChar* = ptr int16 # XXX
-  WideChar* = int16
-
-when defined(winUnicode):
-  type
-    LPCTSTR* = Pwidechar
-else:
-  type
-    LPCTSTR* = cstring
-type
-  LPCWCH* = Pwidechar
-  LPCWSTR* = Pwidechar
-  LPPCSTR* = ptr LPCSTR
-  LPPCTSTR* = ptr LPCTSTR
-  LPPCWSTR* = ptr LPCWSTR
-  LPDWORD* = ptr DWORD
-  LPHANDLE* = ptr HANDLE
-  LPINT* = ptr int32
-  LPLONG* = ptr int32
-  LPSTR* = cstring
-
-when defined(winUnicode):
-  type
-    LPTCH* = Pwidechar
-    LPTSTR* = Pwidechar
-else:
-  type
-    LPTCH* = cstring
-    LPTSTR* = cstring
-type
-  LRESULT* = LONG_PTR
-  LPVOID* = pointer
-  LPCVOID* = pointer
-  LPWCH* = Pwidechar
-  LPWORD* = ptr int16
-  LPWSTR* = Pwidechar
-  NWPSTR* = Pwidechar
-  PWINBOOL* = ptr WINBOOL
-  PBOOLEAN* = ptr int8
-  PBYTE* = ptr int8
-  PCCH* = cstring
-  PCH* = cstring
-  PCSTR* = cstring
-  PCWCH* = Pwidechar
-  PCWSTR* = Pwidechar
-  PDWORD* = ptr DWORD
-  PHANDLE* = ptr HANDLE
-  PHKEY* = ptr HKEY
-  PINT* = ptr int32
-  PLONG* = ptr int32
-  PSHORT* = ptr SHORT
-  PSTR* = cstring
-  PSZ* = cstring
-
-when defined(winUnicode):
-  type
-    PTBYTE* = ptr int16
-    PTCH* = Pwidechar
-    PTCHAR* = Pwidechar
-    PTSTR* = Pwidechar
-else:
-  type
-    PTBYTE* = ptr int8
-    PTCH* = cstring
-    PTCHAR* = cstring
-    PTSTR* = cstring
-type
-  PUCHAR* = ptr int8
-  PWCH* = Pwidechar
-  PWCHAR* = Pwidechar
-  PWORD* = ptr int16
-  PUINT* = ptr int
-  PULONG* = ptr int
-  PUSHORT* = ptr int16
-  PVOID* = pointer
-  RETCODE* = SHORT
-  SC_HANDLE* = HANDLE
-  SC_LOCK* = LPVOID
-  LPSC_HANDLE* = ptr SC_HANDLE
-  SERVICE_STATUS_HANDLE* = DWORD
-
-when defined(winUnicode):
-  type
-    TBYTE* = int16
-    TCHAR* = widechar
-    BCHAR* = int16
-else:
-  type
-    TBYTE* = int8
-    TCHAR* = char
-    BCHAR* = int8
-type
-  UCHAR* = int8
-  WCHAR* = WideChar
-  UINT* = int
-  ULONG* = int
-  USHORT* = int16
-  WPARAM* = LONG_PTR
-  PLPSTR* = ptr LPSTR
-  PLPWStr* = ptr LPWStr
-  ACL_INFORMATION_CLASS* = enum
-    AclRevisionInformation = 1, AclSizeInformation
-  MEDIA_TYPE* = enum
-    Unknown, F5_1Pt2_512, F3_1Pt44_512, F3_2Pt88_512, F3_20Pt8_512, F3_720_512,
-    F5_360_512, F5_320_512, F5_320_1024, F5_180_512, F5_160_512, RemovableMedia,
-    FixedMedia
-
-const
-  RASCS_DONE* = 0x00002000
-  RASCS_PAUSED* = 0x00001000
-
-type
-  RASCONNSTATE* = enum
-    RASCS_OpenPort = 0, RASCS_PortOpened, RASCS_ConnectDevice,
-    RASCS_DeviceConnected, RASCS_AllDevicesConnected, RASCS_Authenticate,
-    RASCS_AuthNotify, RASCS_AuthRetry, RASCS_AuthCallback,
-    RASCS_AuthChangePassword, RASCS_AuthProject, RASCS_AuthLinkSpeed,
-    RASCS_AuthAck, RASCS_ReAuthenticate, RASCS_Authenticated,
-    RASCS_PrepareForCallback, RASCS_WaitForModemReset, RASCS_WaitForCallback,
-    RASCS_Projected, RASCS_StartAuthentication, RASCS_CallbackComplete,
-    RASCS_LogonNetwork, RASCS_Interactive = RASCS_PAUSED,
-    RASCS_RetryAuthentication, RASCS_CallbackSetByCaller, RASCS_PasswordExpired,
-    RASCS_Connected = RASCS_DONE, RASCS_Disconnected
-  RASPROJECTION* = enum
-    RASP_PppIp = 0x00008021, RASP_PppIpx = 0x0000802B, RASP_PppNbf = 0x0000803F,
-    RASP_Amb = 0x00010000
-  SECURITY_IMPERSONATION_LEVEL* = enum
-    SecurityAnonymous, SecurityIdentification, SecurityImpersonation,
-    SecurityDelegation
-  SID_NAME_USE* = enum
-    SidTypeUser = 1, SidTypeGroup, SidTypeDomain, SidTypeAlias,
-    SidTypeWellKnownGroup, SidTypeDeletedAccount, SidTypeInvalid, SidTypeUnknown
-  PSID_NAME_USE* = ptr SID_NAME_USE
-  TOKEN_INFORMATION_CLASS* = enum
-    TokenUser = 1, TokenGroups, TokenPrivileges, TokenOwner, TokenPrimaryGroup,
-    TokenDefaultDacl, TokenSource, TokenType, TokenImpersonationLevel,
-    TokenStatistics
-  TTOKEN_TYPE* = enum
-    TokenPrimary = 1, TokenImpersonation
-  MakeIntResourceA* = cstring
-  MakeIntResourceW* = PWideChar
-  MakeIntResource* = MakeIntResourceA
-
-proc GetBValue*(rgb: int32): int8
-proc GetGValue*(rgb: int32): int8
-proc GetRValue*(rgb: int32): int8
-proc RGB*(r, g, b: int32): DWORD
-proc HIBYTE*(w: int32): int8
-proc HIWORD*(L: int32): int16
-proc LOBYTE*(w: int32): int8
-proc LOWORD*(L: int32): int16
-proc MAKELONG*(a, b: int32): LONG
-proc MAKEWORD*(a, b: int32): int16
-proc SEXT_HIWORD*(L: int32): int32
-proc ZEXT_HIWORD*(L: int32): int32
-proc SEXT_LOWORD*(L: int32): int32
-proc INDEXTOOVERLAYMASK*(i: int32): int32
-proc INDEXTOSTATEIMAGEMASK*(i: int32): int32
-proc MAKEINTATOM*(i: int32): LPTSTR
-proc MAKELANGID*(p, s: int32): int32
-proc PRIMARYLANGID*(lgid: int32): int16
-proc SUBLANGID*(lgid: int32): int32
-proc LANGIDFROMLCID*(lcid: int32): int16
-proc SORTIDFROMLCID*(lcid: int32): int16
-proc MAKELCID*(lgid, srtid: int32): DWORD
-proc MAKELPARAM*(L, h: int32): LPARAM
-proc MAKELRESULT*(L, h: int32): LRESULT
-proc MAKEROP4*(fore, back: int32): DWORD
-proc MAKEWPARAM*(L, h: int32): WPARAM
-proc GET_X_LPARAM*(lp: Windows.LParam): int32
-proc GET_Y_LPARAM*(lp: Windows.LParam): int32
-proc PALETTEINDEX*(i: int32): COLORREF
-proc PALETTERGB*(r, g, b: int32): int32
-  #
-  #    Definitions for callback procedures
-  #
-type
-  BFFCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPARAM, para4: LPARAM): int32{.
-      stdcall.}
-  LPCCHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.
-      stdcall.}
-  LPCFHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.
-      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{.
-      stdcall.}
-  LPOFNHOOKPROC* = proc (para1: HWND, para2: UINT, para3: WPARAM, para4: LPARAM): UINT{.
-      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{.
-      stdcall.}
-  PFNPROPSHEETCALLBACK* = proc (para1: HWND, para2: UINT, 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{.
-      stdcall.}
-  FARPROC* = pointer
-  TFarProc* = FARPROC
-  TProc* = pointer
-  ENUMRESTYPEPROC* = proc (para1: HANDLE, para2: LPTSTR, para3: LONG): WINBOOL{.
-      stdcall.}
-  ENUMRESNAMEPROC* = proc (para1: HANDLE, para2: LPCTSTR, para3: LPTSTR,
-                           para4: LONG): WINBOOL{.stdcall.}
-  ENUMRESLANGPROC* = proc (para1: HANDLE, para2: LPCTSTR, para3: LPCTSTR,
-                           para4: int16, para5: LONG): WINBOOL{.stdcall.}
-  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){.
-      stdcall.}
-  TIMERPROC* = proc (para1: HWND, para2: UINT, para3: UINT, para4: DWORD){.
-      stdcall.}
-  GRAYSTRINGPROC* = FARPROC
-  DRAWSTATEPROC* = proc (para1: HDC, para2: LPARAM, para3: WPARAM, para4: int32,
-                         para5: int32): WINBOOL{.stdcall.}
-  PROPENUMPROCEX* = proc (para1: HWND, para2: LPCTSTR, para3: HANDLE,
-                          para4: DWORD): WINBOOL{.stdcall.}
-  PROPENUMPROC* = proc (para1: HWND, para2: LPCTSTR, para3: HANDLE): WINBOOL{.
-      stdcall.}
-  HOOKPROC* = proc (para1: int32, para2: WPARAM, para3: LPARAM): LRESULT{.
-      stdcall.}
-  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.}
-  ICMENUMPROC* = proc (para1: LPTSTR, para2: LPARAM): int32{.stdcall.}
-  EDITWORDBREAKPROCEX* = proc (para1: cstring, para2: LONG, para3: int8,
-                               para4: WINT): LONG{.stdcall.}
-  PFNLVCOMPARE* = proc (para1: LPARAM, para2: LPARAM, para3: LPARAM): int32{.
-      stdcall.}
-  LOCALE_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}
-  CODEPAGE_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}
-  DATEFMT_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}
-  TIMEFMT_ENUMPROC* = proc (para1: LPTSTR): WINBOOL{.stdcall.}
-  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{.
-      stdcall.}
-  PFNRECONCILEPROFILE* = proc (para1: LPCTSTR, para2: LPCTSTR, para3: DWORD): UINT{.
-      stdcall.}
-  PFNPROCESSPOLICIES* = proc (para1: HWND, para2: LPCTSTR, para3: LPCTSTR,
-                              para4: LPCTSTR, para5: DWORD): WINBOOL{.stdcall.} #Not convertable by H2PAS
-                                                                                #  #define SECURITY_NULL_SID_AUTHORITY     {0,0,0,0,0,0}
-                                                                                #  #define SECURITY_WORLD_SID_AUTHORITY    {0,0,0,0,0,1}
-                                                                                #  #define SECURITY_LOCAL_SID_AUTHORITY    {0,0,0,0,0,2}
-                                                                                #  #define SECURITY_CREATOR_SID_AUTHORITY  {0,0,0,0,0,3}
-                                                                                #  #define SECURITY_NON_UNIQUE_AUTHORITY   {0,0,0,0,0,4}
-                                                                                #  #define SECURITY_NT_AUTHORITY           {0,0,0,0,0,5}
-                                                                                #
-
-const
-  SE_CREATE_TOKEN_NAME* = "SeCreateTokenPrivilege"
-  SE_ASSIGNPRIMARYTOKEN_NAME* = "SeAssignPrimaryTokenPrivilege"
-  SE_LOCK_MEMORY_NAME* = "SeLockMemoryPrivilege"
-  SE_INCREASE_QUOTA_NAME* = "SeIncreaseQuotaPrivilege"
-  SE_UNSOLICITED_INPUT_NAME* = "SeUnsolicitedInputPrivilege"
-  SE_MACHINE_ACCOUNT_NAME* = "SeMachineAccountPrivilege"
-  SE_TCB_NAME* = "SeTcbPrivilege"
-  SE_SECURITY_NAME* = "SeSecurityPrivilege"
-  SE_TAKE_OWNERSHIP_NAME* = "SeTakeOwnershipPrivilege"
-  SE_LOAD_DRIVER_NAME* = "SeLoadDriverPrivilege"
-  SE_SYSTEM_PROFILE_NAME* = "SeSystemProfilePrivilege"
-  SE_SYSTEMTIME_NAME* = "SeSystemtimePrivilege"
-  SE_PROF_SINGLE_PROCESS_NAME* = "SeProfileSingleProcessPrivilege"
-  SE_INC_BASE_PRIORITY_NAME* = "SeIncreaseBasePriorityPrivilege"
-  SE_CREATE_PAGEFILE_NAME* = "SeCreatePagefilePrivilege"
-  SE_CREATE_PERMANENT_NAME* = "SeCreatePermanentPrivilege"
-  SE_BACKUP_NAME* = "SeBackupPrivilege"
-  SE_RESTORE_NAME* = "SeRestorePrivilege"
-  SE_SHUTDOWN_NAME* = "SeShutdownPrivilege"
-  SE_DEBUG_NAME* = "SeDebugPrivilege"
-  SE_AUDIT_NAME* = "SeAuditPrivilege"
-  SE_SYSTEM_ENVIRONMENT_NAME* = "SeSystemEnvironmentPrivilege"
-  SE_CHANGE_NOTIFY_NAME* = "SeChangeNotifyPrivilege"
-  SE_REMOTE_SHUTDOWN_NAME* = "SeRemoteShutdownPrivilege"
-  SERVICES_ACTIVE_DATABASEW* = "ServicesActive"
-  SERVICES_FAILED_DATABASEW* = "ServicesFailed"
-  SERVICES_ACTIVE_DATABASEA* = "ServicesActive"
-  SERVICES_FAILED_DATABASEA* = "ServicesFailed"
-  SC_GROUP_IDENTIFIERW* = "+"
-  SC_GROUP_IDENTIFIERA* = "+"
-
-when defined(winUnicode):
-  const
-    SERVICES_ACTIVE_DATABASE* = SERVICES_ACTIVE_DATABASEW
-    SERVICES_FAILED_DATABASE* = SERVICES_FAILED_DATABASEW
-    SC_GROUP_IDENTIFIER* = SC_GROUP_IDENTIFIERW
-else:
-  const
-    SERVICES_ACTIVE_DATABASE* = SERVICES_ACTIVE_DATABASEA
-    SERVICES_FAILED_DATABASE* = SERVICES_FAILED_DATABASEA
-    SC_GROUP_IDENTIFIER* = SC_GROUP_IDENTIFIERA
-type                          # PFNCALLBACK = CALLB;
-  PFNCALLBACK* = proc (para1, para2: UINT, para3: HCONV, para4, para5: HSZ,
-                       para6: HDDEDATA, para7, para8: DWORD): HDDEData{.stdcall.} #
-                                                                                  # CALLB
-                                                                                  # =
-                                                                                  # procedure
-                                                                                  # ;CDECL;
-  CALLB* = PFNCALLBACK
-  SECURITY_CONTEXT_TRACKING_MODE* = WINBOOL # End of stuff from ddeml.h in old Cygnus headers
-                                            #
-                                            # -----------------------------------------------
-  WNDENUMPROC* = FARPROC
-  ENHMFENUMPROC* = FARPROC
-  CCSTYLE* = DWORD
-  PCCSTYLE* = ptr CCSTYLE
-  LPCCSTYLE* = ptr CCSTYLE
-  CCSTYLEFLAGA* = DWORD
-  PCCSTYLEFLAGA* = ptr CCSTYLEFLAGA
-  LPCCSTYLEFLAGA* = ptr CCSTYLEFLAGA
-
-const
-  LZERROR_UNKNOWNALG* = - (8)
-  LZERROR_BADVALUE* = - (7)
-  LZERROR_GLOBLOCK* = - (6)
-  LZERROR_GLOBALLOC* = - (5)
-  LZERROR_WRITE* = - (4)
-  LZERROR_READ* = - (3)
-  LZERROR_BADOUTHANDLE* = - (2)
-  LZERROR_BADINHANDLE* = - (1)
-  NO_ERROR* = 0
-  ERROR_SUCCESS* = 0
-  ERROR_INVALID_FUNCTION* = 1
-  ERROR_FILE_NOT_FOUND* = 2
-  ERROR_PATH_NOT_FOUND* = 3
-  ERROR_TOO_MANY_OPEN_FILES* = 4
-  ERROR_ACCESS_DENIED* = 5
-  ERROR_INVALID_HANDLE* = 6
-  ERROR_ARENA_TRASHED* = 7
-  ERROR_NOT_ENOUGH_MEMORY* = 8
-  ERROR_INVALID_BLOCK* = 9
-  ERROR_BAD_ENVIRONMENT* = 10
-  ERROR_BAD_FORMAT* = 11
-  ERROR_INVALID_ACCESS* = 12
-  ERROR_INVALID_DATA* = 13
-  ERROR_OUTOFMEMORY* = 14
-  ERROR_INVALID_DRIVE* = 15
-  ERROR_CURRENT_DIRECTORY* = 16
-  ERROR_NOT_SAME_DEVICE* = 17
-  ERROR_NO_MORE_FILES* = 18
-  ERROR_WRITE_PROTECT* = 19
-  ERROR_BAD_UNIT* = 20
-  ERROR_NOT_READY* = 21
-  ERROR_BAD_COMMAND* = 22
-  ERROR_CRC* = 23
-  ERROR_BAD_LENGTH* = 24
-  ERROR_SEEK* = 25
-  ERROR_NOT_DOS_DISK* = 26
-  ERROR_SECTOR_NOT_FOUND* = 27
-  ERROR_OUT_OF_PAPER* = 28
-  ERROR_WRITE_FAULT* = 29
-  ERROR_READ_FAULT* = 30
-  ERROR_GEN_FAILURE* = 31
-  ERROR_SHARING_VIOLATION* = 32
-  ERROR_LOCK_VIOLATION* = 33
-  ERROR_WRONG_DISK* = 34
-  ERROR_SHARING_BUFFER_EXCEEDED* = 36
-  ERROR_HANDLE_EOF* = 38
-  ERROR_HANDLE_DISK_FULL* = 39
-  ERROR_NOT_SUPPORTED* = 50
-  ERROR_REM_NOT_LIST* = 51
-  ERROR_DUP_NAME* = 52
-  ERROR_BAD_NETPATH* = 53
-  ERROR_NETWORK_BUSY* = 54
-  ERROR_DEV_NOT_EXIST* = 55
-  ERROR_TOO_MANY_CMDS* = 56
-  ERROR_ADAP_HDW_ERR* = 57
-  ERROR_BAD_NET_RESP* = 58
-  ERROR_UNEXP_NET_ERR* = 59
-  ERROR_BAD_REM_ADAP* = 60
-  ERROR_PRINTQ_FULL* = 61
-  ERROR_NO_SPOOL_SPACE* = 62
-  ERROR_PRINT_CANCELLED* = 63
-  ERROR_NETNAME_DELETED* = 64
-  ERROR_NETWORK_ACCESS_DENIED* = 65
-  ERROR_BAD_DEV_TYPE* = 66
-  ERROR_BAD_NET_NAME* = 67
-  ERROR_TOO_MANY_NAMES* = 68
-  ERROR_TOO_MANY_SESS* = 69
-  ERROR_SHARING_PAUSED* = 70
-  ERROR_REQ_NOT_ACCEP* = 71
-  ERROR_REDIR_PAUSED* = 72
-  ERROR_FILE_EXISTS* = 80
-  ERROR_CANNOT_MAKE* = 82
-  ERROR_FAIL_I24* = 83
-  ERROR_OUT_OF_STRUCTURES* = 84
-  ERROR_ALREADY_ASSIGNED* = 85
-  ERROR_INVALID_PASSWORD* = 86
-  ERROR_INVALID_PARAMETER* = 87
-  ERROR_NET_WRITE_FAULT* = 88
-  ERROR_NO_PROC_SLOTS* = 89
-  ERROR_TOO_MANY_SEMAPHORES* = 100
-  ERROR_EXCL_SEM_ALREADY_OWNED* = 101
-  ERROR_SEM_IS_SET* = 102
-  ERROR_TOO_MANY_SEM_REQUESTS* = 103
-  ERROR_INVALID_AT_INTERRUPT_TIME* = 104
-  ERROR_SEM_OWNER_DIED* = 105
-  ERROR_SEM_USER_LIMIT* = 106
-  ERROR_DISK_CHANGE* = 107
-  ERROR_DRIVE_LOCKED* = 108
-  ERROR_BROKEN_PIPE* = 109
-  ERROR_OPEN_FAILED* = 110
-  ERROR_BUFFER_OVERFLOW* = 111
-  ERROR_DISK_FULL* = 112
-  ERROR_NO_MORE_SEARCH_HANDLES* = 113
-  ERROR_INVALID_TARGET_HANDLE* = 114
-  ERROR_INVALID_CATEGORY* = 117
-  ERROR_INVALID_VERIFY_SWITCH* = 118
-  ERROR_BAD_DRIVER_LEVEL* = 119
-  ERROR_CALL_NOT_IMPLEMENTED* = 120
-  ERROR_SEM_TIMEOUT* = 121
-  ERROR_INSUFFICIENT_BUFFER* = 122
-  ERROR_INVALID_NAME* = 123
-  ERROR_INVALID_LEVEL* = 124
-  ERROR_NO_VOLUME_LABEL* = 125
-  ERROR_MOD_NOT_FOUND* = 126
-  ERROR_PROC_NOT_FOUND* = 127
-  ERROR_WAIT_NO_CHILDREN* = 128
-  ERROR_CHILD_NOT_COMPLETE* = 129
-  ERROR_DIRECT_ACCESS_HANDLE* = 130
-  ERROR_NEGATIVE_SEEK* = 131
-  ERROR_SEEK_ON_DEVICE* = 132
-  ERROR_IS_JOIN_TARGET* = 133
-  ERROR_IS_JOINED* = 134
-  ERROR_IS_SUBSTED* = 135
-  ERROR_NOT_JOINED* = 136
-  ERROR_NOT_SUBSTED* = 137
-  ERROR_JOIN_TO_JOIN* = 138
-  ERROR_SUBST_TO_SUBST* = 139
-  ERROR_JOIN_TO_SUBST* = 140
-  ERROR_SUBST_TO_JOIN* = 141
-  ERROR_BUSY_DRIVE* = 142
-  ERROR_SAME_DRIVE* = 143
-  ERROR_DIR_NOT_ROOT* = 144
-  ERROR_DIR_NOT_EMPTY* = 145
-  ERROR_IS_SUBST_PATH* = 146
-  ERROR_IS_JOIN_PATH* = 147
-  ERROR_PATH_BUSY* = 148
-  ERROR_IS_SUBST_TARGET* = 149
-  ERROR_SYSTEM_TRACE* = 150
-  ERROR_INVALID_EVENT_COUNT* = 151
-  ERROR_TOO_MANY_MUXWAITERS* = 152
-  ERROR_INVALID_LIST_FORMAT* = 153
-  ERROR_LABEL_TOO_LONG* = 154
-  ERROR_TOO_MANY_TCBS* = 155
-  ERROR_SIGNAL_REFUSED* = 156
-  ERROR_DISCARDED* = 157
-  ERROR_NOT_LOCKED* = 158
-  ERROR_BAD_THREADID_ADDR* = 159
-  ERROR_BAD_ARGUMENTS* = 160
-  ERROR_BAD_PATHNAME* = 161
-  ERROR_SIGNAL_PENDING* = 162
-  ERROR_MAX_THRDS_REACHED* = 164
-  ERROR_LOCK_FAILED* = 167
-  ERROR_BUSY* = 170
-  ERROR_CANCEL_VIOLATION* = 173
-  ERROR_ATOMIC_LOCKS_NOT_SUPPORTED* = 174
-  ERROR_INVALID_SEGMENT_NUMBER* = 180
-  ERROR_INVALID_ORDINAL* = 182
-  ERROR_ALREADY_EXISTS* = 183
-  ERROR_INVALID_FLAG_NUMBER* = 186
-  ERROR_SEM_NOT_FOUND* = 187
-  ERROR_INVALID_STARTING_CODESEG* = 188
-  ERROR_INVALID_STACKSEG* = 189
-  ERROR_INVALID_MODULETYPE* = 190
-  ERROR_INVALID_EXE_SIGNATURE* = 191
-  ERROR_EXE_MARKED_INVALID* = 192
-  ERROR_BAD_EXE_FORMAT* = 193
-  ERROR_ITERATED_DATA_EXCEEDS_64k* = 194
-  ERROR_INVALID_MINALLOCSIZE* = 195
-  ERROR_DYNLINK_FROM_INVALID_RING* = 196
-  ERROR_IOPL_NOT_ENABLED* = 197
-  ERROR_INVALID_SEGDPL* = 198
-  ERROR_AUTODATASEG_EXCEEDS_64k* = 199
-  ERROR_RING2SEG_MUST_BE_MOVABLE* = 200
-  ERROR_RELOC_CHAIN_XEEDS_SEGLIM* = 201
-  ERROR_INFLOOP_IN_RELOC_CHAIN* = 202
-  ERROR_ENVVAR_NOT_FOUND* = 203
-  ERROR_NO_SIGNAL_SENT* = 205
-  ERROR_FILENAME_EXCED_RANGE* = 206
-  ERROR_RING2_STACK_IN_USE* = 207
-  ERROR_META_EXPANSION_TOO_LONG* = 208
-  ERROR_INVALID_SIGNAL_NUMBER* = 209
-  ERROR_THREAD_1_INACTIVE* = 210
-  ERROR_LOCKED* = 212
-  ERROR_TOO_MANY_MODULES* = 214
-  ERROR_NESTING_NOT_ALLOWED* = 215
-  ERROR_BAD_PIPE* = 230
-  ERROR_PIPE_BUSY* = 231
-  ERROR_NO_DATA* = 232
-  ERROR_PIPE_NOT_CONNECTED* = 233
-  ERROR_MORE_DATA* = 234
-  ERROR_VC_DISCONNECTED* = 240
-  ERROR_INVALID_EA_NAME* = 254
-  ERROR_EA_LIST_INCONSISTENT* = 255
-  ERROR_NO_MORE_ITEMS* = 259
-  ERROR_CANNOT_COPY* = 266
-  ERROR_DIRECTORY* = 267
-  ERROR_EAS_DIDNT_FIT* = 275
-  ERROR_EA_FILE_CORRUPT* = 276
-  ERROR_EA_TABLE_FULL* = 277
-  ERROR_INVALID_EA_HANDLE* = 278
-  ERROR_EAS_NOT_SUPPORTED* = 282
-  ERROR_NOT_OWNER* = 288
-  ERROR_TOO_MANY_POSTS* = 298
-  ERROR_PARTIAL_COPY* = 299
-  ERROR_MR_MID_NOT_FOUND* = 317
-  ERROR_INVALID_ADDRESS* = 487
-  ERROR_ARITHMETIC_OVERFLOW* = 534
-  ERROR_PIPE_CONNECTED* = 535
-  ERROR_PIPE_LISTENING* = 536
-  ERROR_EA_ACCESS_DENIED* = 994
-  ERROR_OPERATION_ABORTED* = 995
-  ERROR_IO_INCOMPLETE* = 996
-  ERROR_IO_PENDING* = 997
-  ERROR_NOACCESS* = 998
-  ERROR_SWAPERROR* = 999
-  ERROR_STACK_OVERFLOW* = 1001
-  ERROR_INVALID_MESSAGE* = 1002
-  ERROR_CAN_NOT_COMPLETE* = 1003
-  ERROR_INVALID_FLAGS* = 1004
-  ERROR_UNRECOGNIZED_VOLUME* = 1005
-  ERROR_FILE_INVALID* = 1006
-  ERROR_FULLSCREEN_MODE* = 1007
-  ERROR_NO_TOKEN* = 1008
-  ERROR_BADDB* = 1009
-  ERROR_BADKEY* = 1010
-  ERROR_CANTOPEN* = 1011
-  ERROR_CANTREAD* = 1012
-  ERROR_CANTWRITE* = 1013
-  ERROR_REGISTRY_RECOVERED* = 1014
-  ERROR_REGISTRY_CORRUPT* = 1015
-  ERROR_REGISTRY_IO_FAILED* = 1016
-  ERROR_NOT_REGISTRY_FILE* = 1017
-  ERROR_KEY_DELETED* = 1018
-  ERROR_NO_LOG_SPACE* = 1019
-  ERROR_KEY_HAS_CHILDREN* = 1020
-  ERROR_CHILD_MUST_BE_VOLATILE* = 1021
-  ERROR_NOTIFY_ENUM_DIR* = 1022
-  ERROR_DEPENDENT_SERVICES_RUNNING* = 1051
-  ERROR_INVALID_SERVICE_CONTROL* = 1052
-  ERROR_SERVICE_REQUEST_TIMEOUT* = 1053
-  ERROR_SERVICE_NO_THREAD* = 1054
-  ERROR_SERVICE_DATABASE_LOCKED* = 1055
-  ERROR_SERVICE_ALREADY_RUNNING* = 1056
-  ERROR_INVALID_SERVICE_ACCOUNT* = 1057
-  ERROR_SERVICE_DISABLED* = 1058
-  ERROR_CIRCULAR_DEPENDENCY* = 1059
-  ERROR_SERVICE_DOES_NOT_EXIST* = 1060
-  ERROR_SERVICE_CANNOT_ACCEPT_CTRL* = 1061
-  ERROR_SERVICE_NOT_ACTIVE* = 1062
-  ERROR_FAILED_SERVICE_CONTROLLER_CONNECT* = 1063
-  ERROR_EXCEPTION_IN_SERVICE* = 1064
-  ERROR_DATABASE_DOES_NOT_EXIST* = 1065
-  ERROR_SERVICE_SPECIFIC_ERROR* = 1066
-  ERROR_PROCESS_ABORTED* = 1067
-  ERROR_SERVICE_DEPENDENCY_FAIL* = 1068
-  ERROR_SERVICE_LOGON_FAILED* = 1069
-  ERROR_SERVICE_START_HANG* = 1070
-  ERROR_INVALID_SERVICE_LOCK* = 1071
-  ERROR_SERVICE_MARKED_FOR_DELETE* = 1072
-  ERROR_SERVICE_EXISTS* = 1073
-  ERROR_ALREADY_RUNNING_LKG* = 1074
-  ERROR_SERVICE_DEPENDENCY_DELETED* = 1075
-  ERROR_BOOT_ALREADY_ACCEPTED* = 1076
-  ERROR_SERVICE_NEVER_STARTED* = 1077
-  ERROR_DUPLICATE_SERVICE_NAME* = 1078
-  ERROR_END_OF_MEDIA* = 1100
-  ERROR_FILEMARK_DETECTED* = 1101
-  ERROR_BEGINNING_OF_MEDIA* = 1102
-  ERROR_SETMARK_DETECTED* = 1103
-  ERROR_NO_DATA_DETECTED* = 1104
-  ERROR_PARTITION_FAILURE* = 1105
-  ERROR_INVALID_BLOCK_LENGTH* = 1106
-  ERROR_DEVICE_NOT_PARTITIONED* = 1107
-  ERROR_UNABLE_TO_LOCK_MEDIA* = 1108
-  ERROR_UNABLE_TO_UNLOAD_MEDIA* = 1109
-  ERROR_MEDIA_CHANGED* = 1110
-  ERROR_BUS_RESET* = 1111
-  ERROR_NO_MEDIA_IN_DRIVE* = 1112
-  ERROR_NO_UNICODE_TRANSLATION* = 1113
-  ERROR_DLL_INIT_FAILED* = 1114
-  ERROR_SHUTDOWN_IN_PROGRESS* = 1115
-  ERROR_NO_SHUTDOWN_IN_PROGRESS* = 1116
-  ERROR_IO_DEVICE* = 1117
-  ERROR_SERIAL_NO_DEVICE* = 1118
-  ERROR_IRQ_BUSY* = 1119
-  ERROR_MORE_WRITES* = 1120
-  ERROR_COUNTER_TIMEOUT* = 1121
-  ERROR_FLOPPY_ID_MARK_NOT_FOUND* = 1122
-  ERROR_FLOPPY_WRONG_CYLINDER* = 1123
-  ERROR_FLOPPY_UNKNOWN_ERROR* = 1124
-  ERROR_FLOPPY_BAD_REGISTERS* = 1125
-  ERROR_DISK_RECALIBRATE_FAILED* = 1126
-  ERROR_DISK_OPERATION_FAILED* = 1127
-  ERROR_DISK_RESET_FAILED* = 1128
-  ERROR_EOM_OVERFLOW* = 1129
-  ERROR_NOT_ENOUGH_SERVER_MEMORY* = 1130
-  ERROR_POSSIBLE_DEADLOCK* = 1131
-  ERROR_MAPPED_ALIGNMENT* = 1132
-  ERROR_SET_POWER_STATE_VETOED* = 1140
-  ERROR_SET_POWER_STATE_FAILED* = 1141
-  ERROR_OLD_WIN_VERSION* = 1150
-  ERROR_APP_WRONG_OS* = 1151
-  ERROR_SINGLE_INSTANCE_APP* = 1152
-  ERROR_RMODE_APP* = 1153
-  ERROR_INVALID_DLL* = 1154
-  ERROR_NO_ASSOCIATION* = 1155
-  ERROR_DDE_FAIL* = 1156
-  ERROR_DLL_NOT_FOUND* = 1157
-  ERROR_BAD_USERNAME* = 2202
-  ERROR_NOT_CONNECTED* = 2250
-  ERROR_OPEN_FILES* = 2401
-  ERROR_ACTIVE_CONNECTIONS* = 2402
-  ERROR_DEVICE_IN_USE* = 2404
-  ERROR_BAD_DEVICE* = 1200
-  ERROR_CONNECTION_UNAVAIL* = 1201
-  ERROR_DEVICE_ALREADY_REMEMBERED* = 1202
-  ERROR_NO_NET_OR_BAD_PATH* = 1203
-  ERROR_BAD_PROVIDER* = 1204
-  ERROR_CANNOT_OPEN_PROFILE* = 1205
-  ERROR_BAD_PROFILE* = 1206
-  ERROR_NOT_CONTAINER* = 1207
-  ERROR_EXTENDED_ERROR* = 1208
-  ERROR_INVALID_GROUPNAME* = 1209
-  ERROR_INVALID_COMPUTERNAME* = 1210
-  ERROR_INVALID_EVENTNAME* = 1211
-  ERROR_INVALID_DOMAINNAME* = 1212
-  ERROR_INVALID_SERVICENAME* = 1213
-  ERROR_INVALID_NETNAME* = 1214
-  ERROR_INVALID_SHARENAME* = 1215
-  ERROR_INVALID_PASSWORDNAME* = 1216
-  ERROR_INVALID_MESSAGENAME* = 1217
-  ERROR_INVALID_MESSAGEDEST* = 1218
-  ERROR_SESSION_CREDENTIAL_CONFLICT* = 1219
-  ERROR_REMOTE_SESSION_LIMIT_EXCEEDED* = 1220
-  ERROR_DUP_DOMAINNAME* = 1221
-  ERROR_NO_NETWORK* = 1222
-  ERROR_CANCELLED* = 1223
-  ERROR_USER_MAPPED_FILE* = 1224
-  ERROR_CONNECTION_REFUSED* = 1225
-  ERROR_GRACEFUL_DISCONNECT* = 1226
-  ERROR_ADDRESS_ALREADY_ASSOCIATED* = 1227
-  ERROR_ADDRESS_NOT_ASSOCIATED* = 1228
-  ERROR_CONNECTION_INVALID* = 1229
-  ERROR_CONNECTION_ACTIVE* = 1230
-  ERROR_NETWORK_UNREACHABLE* = 1231
-  ERROR_HOST_UNREACHABLE* = 1232
-  ERROR_PROTOCOL_UNREACHABLE* = 1233
-  ERROR_PORT_UNREACHABLE* = 1234
-  ERROR_REQUEST_ABORTED* = 1235
-  ERROR_CONNECTION_ABORTED* = 1236
-  ERROR_RETRY* = 1237
-  ERROR_CONNECTION_COUNT_LIMIT* = 1238
-  ERROR_LOGIN_TIME_RESTRICTION* = 1239
-  ERROR_LOGIN_WKSTA_RESTRICTION* = 1240
-  ERROR_INCORRECT_ADDRESS* = 1241
-  ERROR_ALREADY_REGISTERED* = 1242
-  ERROR_SERVICE_NOT_FOUND* = 1243
-  ERROR_NOT_AUTHENTICATED* = 1244
-  ERROR_NOT_LOGGED_ON* = 1245
-  ERROR_CONTINUE* = 1246
-  ERROR_ALREADY_INITIALIZED* = 1247
-  ERROR_NO_MORE_DEVICES* = 1248
-  ERROR_NOT_ALL_ASSIGNED* = 1300
-  ERROR_SOME_NOT_MAPPED* = 1301
-  ERROR_NO_QUOTAS_FOR_ACCOUNT* = 1302
-  ERROR_LOCAL_USER_SESSION_KEY* = 1303
-  ERROR_NULL_LM_PASSWORD* = 1304
-  ERROR_UNKNOWN_REVISION* = 1305
-  ERROR_REVISION_MISMATCH* = 1306
-  ERROR_INVALID_OWNER* = 1307
-  ERROR_INVALID_PRIMARY_GROUP* = 1308
-  ERROR_NO_IMPERSONATION_TOKEN* = 1309
-  ERROR_CANT_DISABLE_MANDATORY* = 1310
-  ERROR_NO_LOGON_SERVERS* = 1311
-  ERROR_NO_SUCH_LOGON_SESSION* = 1312
-  ERROR_NO_SUCH_PRIVILEGE* = 1313
-  ERROR_PRIVILEGE_NOT_HELD* = 1314
-  ERROR_INVALID_ACCOUNT_NAME* = 1315
-  ERROR_USER_EXISTS* = 1316
-  ERROR_NO_SUCH_USER* = 1317
-  ERROR_GROUP_EXISTS* = 1318
-  ERROR_NO_SUCH_GROUP* = 1319
-  ERROR_MEMBER_IN_GROUP* = 1320
-  ERROR_MEMBER_NOT_IN_GROUP* = 1321
-  ERROR_LAST_ADMIN* = 1322
-  ERROR_WRONG_PASSWORD* = 1323
-  ERROR_ILL_FORMED_PASSWORD* = 1324
-  ERROR_PASSWORD_RESTRICTION* = 1325
-  ERROR_LOGON_FAILURE* = 1326
-  ERROR_ACCOUNT_RESTRICTION* = 1327
-  ERROR_INVALID_LOGON_HOURS* = 1328
-  ERROR_INVALID_WORKSTATION* = 1329
-  ERROR_PASSWORD_EXPIRED* = 1330
-  ERROR_ACCOUNT_DISABLED* = 1331
-  ERROR_NONE_MAPPED* = 1332
-  ERROR_TOO_MANY_LUIDS_REQUESTED* = 1333
-  ERROR_LUIDS_EXHAUSTED* = 1334
-  ERROR_INVALID_SUB_AUTHORITY* = 1335
-  ERROR_INVALID_ACL* = 1336
-  ERROR_INVALID_SID* = 1337
-  ERROR_INVALID_SECURITY_DESCR* = 1338
-  ERROR_BAD_INHERITANCE_ACL* = 1340
-  ERROR_SERVER_DISABLED* = 1341
-  ERROR_SERVER_NOT_DISABLED* = 1342
-  ERROR_INVALID_ID_AUTHORITY* = 1343
-  ERROR_ALLOTTED_SPACE_EXCEEDED* = 1344
-  ERROR_INVALID_GROUP_ATTRIBUTES* = 1345
-  ERROR_BAD_IMPERSONATION_LEVEL* = 1346
-  ERROR_CANT_OPEN_ANONYMOUS* = 1347
-  ERROR_BAD_VALIDATION_CLASS* = 1348
-  ERROR_BAD_TOKEN_TYPE* = 1349
-  ERROR_NO_SECURITY_ON_OBJECT* = 1350
-  ERROR_CANT_ACCESS_DOMAIN_INFO* = 1351
-  ERROR_INVALID_SERVER_STATE* = 1352
-  ERROR_INVALID_DOMAIN_STATE* = 1353
-  ERROR_INVALID_DOMAIN_ROLE* = 1354
-  ERROR_NO_SUCH_DOMAIN* = 1355
-  ERROR_DOMAIN_EXISTS* = 1356
-  ERROR_DOMAIN_LIMIT_EXCEEDED* = 1357
-  ERROR_INTERNAL_DB_CORRUPTION* = 1358
-  ERROR_INTERNAL_ERROR* = 1359
-  ERROR_GENERIC_NOT_MAPPED* = 1360
-  ERROR_BAD_DESCRIPTOR_FORMAT* = 1361
-  ERROR_NOT_LOGON_PROCESS* = 1362
-  ERROR_LOGON_SESSION_EXISTS* = 1363
-  ERROR_NO_SUCH_PACKAGE* = 1364
-  ERROR_BAD_LOGON_SESSION_STATE* = 1365
-  ERROR_LOGON_SESSION_COLLISION* = 1366
-  ERROR_INVALID_LOGON_TYPE* = 1367
-  ERROR_CANNOT_IMPERSONATE* = 1368
-  ERROR_RXACT_INVALID_STATE* = 1369
-  ERROR_RXACT_COMMIT_FAILURE* = 1370
-  ERROR_SPECIAL_ACCOUNT* = 1371
-  ERROR_SPECIAL_GROUP* = 1372
-  ERROR_SPECIAL_USER* = 1373
-  ERROR_MEMBERS_PRIMARY_GROUP* = 1374
-  ERROR_TOKEN_ALREADY_IN_USE* = 1375
-  ERROR_NO_SUCH_ALIAS* = 1376
-  ERROR_MEMBER_NOT_IN_ALIAS* = 1377
-  ERROR_MEMBER_IN_ALIAS* = 1378
-  ERROR_ALIAS_EXISTS* = 1379
-  ERROR_LOGON_NOT_GRANTED* = 1380
-  ERROR_TOO_MANY_SECRETS* = 1381
-  ERROR_SECRET_TOO_LONG* = 1382
-  ERROR_INTERNAL_DB_ERROR* = 1383
-  ERROR_TOO_MANY_CONTEXT_IDS* = 1384
-  ERROR_LOGON_TYPE_NOT_GRANTED* = 1385
-  ERROR_NT_CROSS_ENCRYPTION_REQUIRED* = 1386
-  ERROR_NO_SUCH_MEMBER* = 1387
-  ERROR_INVALID_MEMBER* = 1388
-  ERROR_TOO_MANY_SIDS* = 1389
-  ERROR_LM_CROSS_ENCRYPTION_REQUIRED* = 1390
-  ERROR_NO_INHERITANCE* = 1391
-  ERROR_FILE_CORRUPT* = 1392
-  ERROR_DISK_CORRUPT* = 1393
-  ERROR_NO_USER_SESSION_KEY* = 1394
-  ERROR_LICENSE_QUOTA_EXCEEDED* = 1395
-  ERROR_INVALID_WINDOW_HANDLE* = 1400
-  ERROR_INVALID_MENU_HANDLE* = 1401
-  ERROR_INVALID_CURSOR_HANDLE* = 1402
-  ERROR_INVALID_ACCEL_HANDLE* = 1403
-  ERROR_INVALID_HOOK_HANDLE* = 1404
-  ERROR_INVALID_DWP_HANDLE* = 1405
-  ERROR_TLW_WITH_WSCHILD* = 1406
-  ERROR_CANNOT_FIND_WND_CLASS* = 1407
-  ERROR_WINDOW_OF_OTHER_THREAD* = 1408
-  ERROR_HOTKEY_ALREADY_REGISTERED* = 1409
-  ERROR_CLASS_ALREADY_EXISTS* = 1410
-  ERROR_CLASS_DOES_NOT_EXIST* = 1411
-  ERROR_CLASS_HAS_WINDOWS* = 1412
-  ERROR_INVALID_INDEX* = 1413
-  ERROR_INVALID_ICON_HANDLE* = 1414
-  ERROR_PRIVATE_DIALOG_INDEX* = 1415
-  ERROR_LISTBOX_ID_NOT_FOUND* = 1416
-  ERROR_NO_WILDCARD_CHARACTERS* = 1417
-  ERROR_CLIPBOARD_NOT_OPEN* = 1418
-  ERROR_HOTKEY_NOT_REGISTERED* = 1419
-  ERROR_WINDOW_NOT_DIALOG* = 1420
-  ERROR_CONTROL_ID_NOT_FOUND* = 1421
-  ERROR_INVALID_COMBOBOX_MESSAGE* = 1422
-  ERROR_WINDOW_NOT_COMBOBOX* = 1423
-  ERROR_INVALID_EDIT_HEIGHT* = 1424
-  ERROR_DC_NOT_FOUND* = 1425
-  ERROR_INVALID_HOOK_FILTER* = 1426
-  ERROR_INVALID_FILTER_PROC* = 1427
-  ERROR_HOOK_NEEDS_HMOD* = 1428
-  ERROR_GLOBAL_ONLY_HOOK* = 1429
-  ERROR_JOURNAL_HOOK_SET* = 1430
-  ERROR_HOOK_NOT_INSTALLED* = 1431
-  ERROR_INVALID_LB_MESSAGE* = 1432
-  ERROR_SETCOUNT_ON_BAD_LB* = 1433
-  ERROR_LB_WITHOUT_TABSTOPS* = 1434
-  ERROR_DESTROY_OBJECT_OF_OTHER_THREAD* = 1435
-  ERROR_CHILD_WINDOW_MENU* = 1436
-  ERROR_NO_SYSTEM_MENU* = 1437
-  ERROR_INVALID_MSGBOX_STYLE* = 1438
-  ERROR_INVALID_SPI_VALUE* = 1439
-  ERROR_SCREEN_ALREADY_LOCKED* = 1440
-  ERROR_HWNDS_HAVE_DIFF_PARENT* = 1441
-  ERROR_NOT_CHILD_WINDOW* = 1442
-  ERROR_INVALID_GW_COMMAND* = 1443
-  ERROR_INVALID_THREAD_ID* = 1444
-  ERROR_NON_MDICHILD_WINDOW* = 1445
-  ERROR_POPUP_ALREADY_ACTIVE* = 1446
-  ERROR_NO_SCROLLBARS* = 1447
-  ERROR_INVALID_SCROLLBAR_RANGE* = 1448
-  ERROR_INVALID_SHOWWIN_COMMAND* = 1449
-  ERROR_NO_SYSTEM_RESOURCES* = 1450
-  ERROR_NONPAGED_SYSTEM_RESOURCES* = 1451
-  ERROR_PAGED_SYSTEM_RESOURCES* = 1452
-  ERROR_WORKING_SET_QUOTA* = 1453
-  ERROR_PAGEFILE_QUOTA* = 1454
-  ERROR_COMMITMENT_LIMIT* = 1455
-  ERROR_MENU_ITEM_NOT_FOUND* = 1456
-  ERROR_INVALID_KEYBOARD_HANDLE* = 1457
-  ERROR_HOOK_TYPE_NOT_ALLOWED* = 1458
-  ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION* = 1459
-  ERROR_TIMEOUT* = 1460
-  ERROR_EVENTLOG_FILE_CORRUPT* = 1500
-  ERROR_EVENTLOG_CANT_START* = 1501
-  ERROR_LOG_FILE_FULL* = 1502
-  ERROR_EVENTLOG_FILE_CHANGED* = 1503
-  RPC_S_INVALID_STRING_BINDING* = 1700
-  RPC_S_WRONG_KIND_OF_BINDING* = 1701
-  RPC_S_INVALID_BINDING* = 1702
-  RPC_S_PROTSEQ_NOT_SUPPORTED* = 1703
-  RPC_S_INVALID_RPC_PROTSEQ* = 1704
-  RPC_S_INVALID_STRING_UUID* = 1705
-  RPC_S_INVALID_ENDPOINT_FORMAT* = 1706
-  RPC_S_INVALID_NET_ADDR* = 1707
-  RPC_S_NO_ENDPOINT_FOUND* = 1708
-  RPC_S_INVALID_TIMEOUT* = 1709
-  RPC_S_OBJECT_NOT_FOUND* = 1710
-  RPC_S_ALREADY_REGISTERED* = 1711
-  RPC_S_TYPE_ALREADY_REGISTERED* = 1712
-  RPC_S_ALREADY_LISTENING* = 1713
-  RPC_S_NO_PROTSEQS_REGISTERED* = 1714
-  RPC_S_NOT_LISTENING* = 1715
-  RPC_S_UNKNOWN_MGR_TYPE* = 1716
-  RPC_S_UNKNOWN_IF* = 1717
-  RPC_S_NO_BINDINGS* = 1718
-  RPC_S_NO_PROTSEQS* = 1719
-  RPC_S_CANT_CREATE_ENDPOINT* = 1720
-  RPC_S_OUT_OF_RESOURCES* = 1721
-  RPC_S_SERVER_UNAVAILABLE* = 1722
-  RPC_S_SERVER_TOO_BUSY* = 1723
-  RPC_S_INVALID_NETWORK_OPTIONS* = 1724
-  RPC_S_NO_CALL_ACTIVE* = 1725
-  RPC_S_CALL_FAILED* = 1726
-  RPC_S_CALL_FAILED_DNE* = 1727
-  RPC_S_PROTOCOL_ERROR* = 1728
-  RPC_S_UNSUPPORTED_TRANS_SYN* = 1730
-  RPC_S_UNSUPPORTED_TYPE* = 1732
-  RPC_S_INVALID_TAG* = 1733
-  RPC_S_INVALID_BOUND* = 1734
-  RPC_S_NO_ENTRY_NAME* = 1735
-  RPC_S_INVALID_NAME_SYNTAX* = 1736
-  RPC_S_UNSUPPORTED_NAME_SYNTAX* = 1737
-  RPC_S_UUID_NO_ADDRESS* = 1739
-  RPC_S_DUPLICATE_ENDPOINT* = 1740
-  RPC_S_UNKNOWN_AUTHN_TYPE* = 1741
-  RPC_S_MAX_CALLS_TOO_SMALL* = 1742
-  RPC_S_STRING_TOO_LONG* = 1743
-  RPC_S_PROTSEQ_NOT_FOUND* = 1744
-  RPC_S_PROCNUM_OUT_OF_RANGE* = 1745
-  RPC_S_BINDING_HAS_NO_AUTH* = 1746
-  RPC_S_UNKNOWN_AUTHN_SERVICE* = 1747
-  RPC_S_UNKNOWN_AUTHN_LEVEL* = 1748
-  RPC_S_INVALID_AUTH_IDENTITY* = 1749
-  RPC_S_UNKNOWN_AUTHZ_SERVICE* = 1750
-  EPT_S_INVALID_ENTRY* = 1751
-  EPT_S_CANT_PERFORM_OP* = 1752
-  EPT_S_NOT_REGISTERED* = 1753
-  RPC_S_NOTHING_TO_EXPORT* = 1754
-  RPC_S_INCOMPLETE_NAME* = 1755
-  RPC_S_INVALID_VERS_OPTION* = 1756
-  RPC_S_NO_MORE_MEMBERS* = 1757
-  RPC_S_NOT_ALL_OBJS_UNEXPORTED* = 1758
-  RPC_S_INTERFACE_NOT_FOUND* = 1759
-  RPC_S_ENTRY_ALREADY_EXISTS* = 1760
-  RPC_S_ENTRY_NOT_FOUND* = 1761
-  RPC_S_NAME_SERVICE_UNAVAILABLE* = 1762
-  RPC_S_INVALID_NAF_ID* = 1763
-  RPC_S_CANNOT_SUPPORT* = 1764
-  RPC_S_NO_CONTEXT_AVAILABLE* = 1765
-  RPC_S_INTERNAL_ERROR* = 1766
-  RPC_S_ZERO_DIVIDE* = 1767
-  RPC_S_ADDRESS_ERROR* = 1768
-  RPC_S_FP_DIV_ZERO* = 1769
-  RPC_S_FP_UNDERFLOW* = 1770
-  RPC_S_FP_OVERFLOW* = 1771
-  RPC_X_NO_MORE_ENTRIES* = 1772
-  RPC_X_SS_CHAR_TRANS_OPEN_FAIL* = 1773
-  RPC_X_SS_CHAR_TRANS_SHORT_FILE* = 1774
-  RPC_X_SS_IN_NULL_CONTEXT* = 1775
-  RPC_X_SS_CONTEXT_DAMAGED* = 1777
-  RPC_X_SS_HANDLES_MISMATCH* = 1778
-  RPC_X_SS_CANNOT_GET_CALL_HANDLE* = 1779
-  RPC_X_NULL_REF_POINTER* = 1780
-  RPC_X_ENUM_VALUE_OUT_OF_RANGE* = 1781
-  RPC_X_BYTE_COUNT_TOO_SMALL* = 1782
-  RPC_X_BAD_STUB_DATA* = 1783
-  ERROR_INVALID_USER_BUFFER* = 1784
-  ERROR_UNRECOGNIZED_MEDIA* = 1785
-  ERROR_NO_TRUST_LSA_SECRET* = 1786
-  ERROR_NO_TRUST_SAM_ACCOUNT* = 1787
-  ERROR_TRUSTED_DOMAIN_FAILURE* = 1788
-  ERROR_TRUSTED_RELATIONSHIP_FAILURE* = 1789
-  ERROR_TRUST_FAILURE* = 1790
-  RPC_S_CALL_IN_PROGRESS* = 1791
-  ERROR_NETLOGON_NOT_STARTED* = 1792
-  ERROR_ACCOUNT_EXPIRED* = 1793
-  ERROR_REDIRECTOR_HAS_OPEN_HANDLES* = 1794
-  ERROR_PRINTER_DRIVER_ALREADY_INSTALLED* = 1795
-  ERROR_UNKNOWN_PORT* = 1796
-  ERROR_UNKNOWN_PRINTER_DRIVER* = 1797
-  ERROR_UNKNOWN_PRINTPROCESSOR* = 1798
-  ERROR_INVALID_SEPARATOR_FILE* = 1799
-  ERROR_INVALID_PRIORITY* = 1800
-  ERROR_INVALID_PRINTER_NAME* = 1801
-  ERROR_PRINTER_ALREADY_EXISTS* = 1802
-  ERROR_INVALID_PRINTER_COMMAND* = 1803
-  ERROR_INVALID_DATATYPE* = 1804
-  ERROR_INVALID_ENVIRONMENT* = 1805
-  RPC_S_NO_MORE_BINDINGS* = 1806
-  ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT* = 1807
-  ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT* = 1808
-  ERROR_NOLOGON_SERVER_TRUST_ACCOUNT* = 1809
-  ERROR_DOMAIN_TRUST_INCONSISTENT* = 1810
-  ERROR_SERVER_HAS_OPEN_HANDLES* = 1811
-  ERROR_RESOURCE_DATA_NOT_FOUND* = 1812
-  ERROR_RESOURCE_TYPE_NOT_FOUND* = 1813
-  ERROR_RESOURCE_NAME_NOT_FOUND* = 1814
-  ERROR_RESOURCE_LANG_NOT_FOUND* = 1815
-  ERROR_NOT_ENOUGH_QUOTA* = 1816
-  RPC_S_NO_INTERFACES* = 1817
-  RPC_S_CALL_CANCELLED* = 1818
-  RPC_S_BINDING_INCOMPLETE* = 1819
-  RPC_S_COMM_FAILURE* = 1820
-  RPC_S_UNSUPPORTED_AUTHN_LEVEL* = 1821
-  RPC_S_NO_PRINC_NAME* = 1822
-  RPC_S_NOT_RPC_ERROR* = 1823
-  RPC_S_UUID_LOCAL_ONLY* = 1824
-  RPC_S_SEC_PKG_ERROR* = 1825
-  RPC_S_NOT_CANCELLED* = 1826
-  RPC_X_INVALID_ES_ACTION* = 1827
-  RPC_X_WRONG_ES_VERSION* = 1828
-  RPC_X_WRONG_STUB_VERSION* = 1829
-  RPC_X_INVALID_PIPE_OBJECT* = 1830
-  RPC_X_INVALID_PIPE_OPERATION* = 1831
-  RPC_S_GROUP_MEMBER_NOT_FOUND* = 1898
-  EPT_S_CANT_CREATE* = 1899
-  RPC_S_INVALID_OBJECT* = 1900
-  ERROR_INVALID_TIME* = 1901
-  ERROR_INVALID_FORM_NAME* = 1902
-  ERROR_INVALID_FORM_SIZE* = 1903
-  ERROR_ALREADY_WAITING* = 1904
-  ERROR_PRINTER_DELETED* = 1905
-  ERROR_INVALID_PRINTER_STATE* = 1906
-  ERROR_PASSWORD_MUST_CHANGE* = 1907
-  ERROR_DOMAIN_CONTROLLER_NOT_FOUND* = 1908
-  ERROR_ACCOUNT_LOCKED_OUT* = 1909
-  OR_INVALID_OXID* = 1910
-  OR_INVALID_OID* = 1911
-  OR_INVALID_SET* = 1912
-  RPC_S_SEND_INCOMPLETE* = 1913
-  ERROR_NO_BROWSER_SERVERS_FOUND* = 6118
-  ERROR_INVALID_PIXEL_FORMAT* = 2000
-  ERROR_BAD_DRIVER* = 2001
-  ERROR_INVALID_WINDOW_STYLE* = 2002
-  ERROR_METAFILE_NOT_SUPPORTED* = 2003
-  ERROR_TRANSFORM_NOT_SUPPORTED* = 2004
-  ERROR_CLIPPING_NOT_SUPPORTED* = 2005
-  ERROR_UNKNOWN_PRINT_MONITOR* = 3000
-  ERROR_PRINTER_DRIVER_IN_USE* = 3001
-  ERROR_SPOOL_FILE_NOT_FOUND* = 3002
-  ERROR_SPL_NO_STARTDOC* = 3003
-  ERROR_SPL_NO_ADDJOB* = 3004
-  ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED* = 3005
-  ERROR_PRINT_MONITOR_ALREADY_INSTALLED* = 3006
-  ERROR_INVALID_PRINT_MONITOR* = 3007
-  ERROR_PRINT_MONITOR_IN_USE* = 3008
-  ERROR_PRINTER_HAS_JOBS_QUEUED* = 3009
-  ERROR_SUCCESS_REBOOT_REQUIRED* = 3010
-  ERROR_SUCCESS_RESTART_REQUIRED* = 3011
-  ERROR_WINS_INTERNAL* = 4000
-  ERROR_CAN_NOT_DEL_LOCAL_WINS* = 4001
-  ERROR_STATIC_INIT* = 4002
-  ERROR_INC_BACKUP* = 4003
-  ERROR_FULL_BACKUP* = 4004
-  ERROR_REC_NON_EXISTENT* = 4005
-  ERROR_RPL_NOT_ALLOWED* = 4006 #ERROR_NO_BROWSER_SERVERS_FOUND              = 6118; already above
-  E_UNEXPECTED* = HRESULT(0x8000FFFF)
-  E_NOTIMPL* = HRESULT(0x80004001)
-  E_OUTOFMEMORY* = HRESULT(0x8007000E)
-  E_INVALIDARG* = HRESULT(0x80070057)
-  E_NOINTERFACE* = HRESULT(0x80004002)
-  E_POINTER* = HRESULT(0x80004003)
-  E_HANDLE* = HRESULT(0x80070006)
-  E_ABORT* = HRESULT(0x80004004)
-  E_FAIL* = HRESULT(0x80004005)
-  E_ACCESSDENIED* = HRESULT(0x80070005)
-  E_PENDING* = HRESULT(0x8000000A)
-  CO_E_INIT_TLS* = HRESULT(0x80004006)
-  CO_E_INIT_SHARED_ALLOCATOR* = HRESULT(0x80004007)
-  CO_E_INIT_MEMORY_ALLOCATOR* = HRESULT(0x80004008)
-  CO_E_INIT_CLASS_CACHE* = HRESULT(0x80004009)
-  CO_E_INIT_RPC_CHANNEL* = HRESULT(0x8000400A)
-  CO_E_INIT_TLS_SET_CHANNEL_CONTROL* = HRESULT(0x8000400B)
-  CO_E_INIT_TLS_CHANNEL_CONTROL* = HRESULT(0x8000400C)
-  CO_E_INIT_UNACCEPTED_USER_ALLOCATOR* = HRESULT(0x8000400D)
-  CO_E_INIT_SCM_MUTEX_EXISTS* = HRESULT(0x8000400E)
-  CO_E_INIT_SCM_FILE_MAPPING_EXISTS* = HRESULT(0x8000400F)
-  CO_E_INIT_SCM_MAP_VIEW_OF_FILE* = HRESULT(0x80004010)
-  CO_E_INIT_SCM_EXEC_FAILURE* = HRESULT(0x80004011)
-  CO_E_INIT_ONLY_SINGLE_THREADED* = HRESULT(0x80004012)
-  CO_E_CANT_REMOTE* = HRESULT(0x80004013)
-  CO_E_BAD_SERVER_NAME* = HRESULT(0x80004014)
-  CO_E_WRONG_SERVER_IDENTITY* = HRESULT(0x80004015)
-  CO_E_OLE1DDE_DISABLED* = HRESULT(0x80004016)
-  CO_E_RUNAS_SYNTAX* = HRESULT(0x80004017)
-  CO_E_CREATEPROCESS_FAILURE* = HRESULT(0x80004018)
-  CO_E_RUNAS_CREATEPROCESS_FAILURE* = HRESULT(0x80004019)
-  CO_E_RUNAS_LOGON_FAILURE* = HRESULT(0x8000401A)
-  CO_E_LAUNCH_PERMSSION_DENIED* = HRESULT(0x8000401B)
-  CO_E_START_SERVICE_FAILURE* = HRESULT(0x8000401C)
-  CO_E_REMOTE_COMMUNICATION_FAILURE* = HRESULT(0x8000401D)
-  CO_E_SERVER_START_TIMEOUT* = HRESULT(0x8000401E)
-  CO_E_CLSREG_INCONSISTENT* = HRESULT(0x8000401F)
-  CO_E_IIDREG_INCONSISTENT* = HRESULT(0x80004020)
-  CO_E_NOT_SUPPORTED* = HRESULT(0x80004021)
-  CO_E_FIRST* = DWORD(0x800401F0)
-  CO_E_LAST* = DWORD(0x800401FF)
-  CO_S_FIRST* = DWORD(0x000401F0)
-  CO_S_LAST* = DWORD(0x000401FF)
-  S_OK* = HRESULT(0x00000000)
-  S_FALSE* = HRESULT(0x00000001)
-  CO_E_NOTINITIALIZED* = HRESULT(0x800401F0)
-  CO_E_ALREADYINITIALIZED* = HRESULT(0x800401F1)
-  CO_E_CANTDETERMINECLASS* = HRESULT(0x800401F2)
-  CO_E_CLASSSTRING* = HRESULT(0x800401F3)
-  CO_E_IIDSTRING* = HRESULT(0x800401F4)
-  CO_E_APPNOTFOUND* = HRESULT(0x800401F5)
-  CO_E_APPSINGLEUSE* = HRESULT(0x800401F6)
-  CO_E_ERRORINAPP* = HRESULT(0x800401F7)
-  CO_E_DLLNOTFOUND* = HRESULT(0x800401F8)
-  CO_E_ERRORINDLL* = HRESULT(0x800401F9)
-  CO_E_WRONGOSFORAPP* = HRESULT(0x800401FA)
-  CO_E_OBJNOTREG* = HRESULT(0x800401FB)
-  CO_E_OBJISREG* = HRESULT(0x800401FC)
-  CO_E_OBJNOTCONNECTED* = HRESULT(0x800401FD)
-  CO_E_APPDIDNTREG* = HRESULT(0x800401FE)
-  CO_E_RELEASED* = HRESULT(0x800401FF)
-  OLE_E_FIRST* = HRESULT(0x80040000)
-  OLE_E_LAST* = HRESULT(0x800400FF)
-  OLE_S_FIRST* = HRESULT(0x00040000)
-  OLE_S_LAST* = HRESULT(0x000400FF)
-  OLE_E_OLEVERB* = HRESULT(0x80040000)
-  OLE_E_ADVF* = HRESULT(0x80040001)
-  OLE_E_ENUM_NOMORE* = HRESULT(0x80040002)
-  OLE_E_ADVISENOTSUPPORTED* = HRESULT(0x80040003)
-  OLE_E_NOCONNECTION* = HRESULT(0x80040004)
-  OLE_E_NOTRUNNING* = HRESULT(0x80040005)
-  OLE_E_NOCACHE* = HRESULT(0x80040006)
-  OLE_E_BLANK* = HRESULT(0x80040007)
-  OLE_E_CLASSDIFF* = HRESULT(0x80040008)
-  OLE_E_CANT_GETMONIKER* = HRESULT(0x80040009)
-  OLE_E_CANT_BINDTOSOURCE* = HRESULT(0x8004000A)
-  OLE_E_STATIC* = HRESULT(0x8004000B)
-  OLE_E_PROMPTSAVECANCELLED* = HRESULT(0x8004000C)
-  OLE_E_INVALIDRECT* = HRESULT(0x8004000D)
-  OLE_E_WRONGCOMPOBJ* = HRESULT(0x8004000E)
-  OLE_E_INVALIDHWND* = HRESULT(0x8004000F)
-  OLE_E_NOT_INPLACEACTIVE* = HRESULT(0x80040010)
-  OLE_E_CANTCONVERT* = HRESULT(0x80040011)
-  OLE_E_NOSTORAGE* = HRESULT(0x80040012)
-  DV_E_FORMATETC* = HRESULT(0x80040064)
-  DV_E_DVTARGETDEVICE* = HRESULT(0x80040065)
-  DV_E_STGMEDIUM* = HRESULT(0x80040066)
-  DV_E_STATDATA* = HRESULT(0x80040067)
-  DV_E_LINDEX* = HRESULT(0x80040068)
-  DV_E_TYMED* = HRESULT(0x80040069)
-  DV_E_CLIPFORMAT* = HRESULT(0x8004006A)
-  DV_E_DVASPECT* = HRESULT(0x8004006B)
-  DV_E_DVTARGETDEVICE_SIZE* = HRESULT(0x8004006C)
-  DV_E_NOIVIEWOBJECT* = HRESULT(0x8004006D)
-  DRAGDROP_E_FIRST* = DWORD(0x80040100)
-  DRAGDROP_E_LAST* = DWORD(0x8004010F)
-  DRAGDROP_S_FIRST* = DWORD(0x00040100)
-  DRAGDROP_S_LAST* = DWORD(0x0004010F)
-  DRAGDROP_E_NOTREGISTERED* = HRESULT(0x80040100)
-  DRAGDROP_E_ALREADYREGISTERED* = HRESULT(0x80040101)
-  DRAGDROP_E_INVALIDHWND* = HRESULT(0x80040102)
-  CLASSFACTORY_E_FIRST* = DWORD(0x80040110)
-  CLASSFACTORY_E_LAST* = DWORD(0x8004011F)
-  CLASSFACTORY_S_FIRST* = DWORD(0x00040110)
-  CLASSFACTORY_S_LAST* = DWORD(0x0004011F)
-  CLASS_E_NOAGGREGATION* = HRESULT(0x80040110)
-  CLASS_E_CLASSNOTAVAILABLE* = HRESULT(0x80040111)
-  MARSHAL_E_FIRST* = DWORD(0x80040120)
-  MARSHAL_E_LAST* = DWORD(0x8004012F)
-  MARSHAL_S_FIRST* = DWORD(0x00040120)
-  MARSHAL_S_LAST* = DWORD(0x0004012F)
-  DATA_E_FIRST* = DWORD(0x80040130)
-  DATA_E_LAST* = DWORD(0x8004013F)
-  DATA_S_FIRST* = DWORD(0x00040130)
-  DATA_S_LAST* = DWORD(0x0004013F)
-  VIEW_E_FIRST* = DWORD(0x80040140)
-  VIEW_E_LAST* = DWORD(0x8004014F)
-  VIEW_S_FIRST* = DWORD(0x00040140)
-  VIEW_S_LAST* = DWORD(0x0004014F)
-  VIEW_E_DRAW* = HRESULT(0x80040140)
-  REGDB_E_FIRST* = DWORD(0x80040150)
-  REGDB_E_LAST* = DWORD(0x8004015F)
-  REGDB_S_FIRST* = DWORD(0x00040150)
-  REGDB_S_LAST* = DWORD(0x0004015F)
-  REGDB_E_READREGDB* = HRESULT(0x80040150)
-  REGDB_E_WRITEREGDB* = HRESULT(0x80040151)
-  REGDB_E_KEYMISSING* = HRESULT(0x80040152)
-  REGDB_E_INVALIDVALUE* = HRESULT(0x80040153)
-  REGDB_E_CLASSNOTREG* = HRESULT(0x80040154)
-  REGDB_E_IIDNOTREG* = HRESULT(0x80040155)
-  CACHE_E_FIRST* = DWORD(0x80040170)
-  CACHE_E_LAST* = DWORD(0x8004017F)
-  CACHE_S_FIRST* = DWORD(0x00040170)
-  CACHE_S_LAST* = DWORD(0x0004017F)
-  CACHE_E_NOCACHE_UPDATED* = HRESULT(0x80040170)
-  OLEOBJ_E_FIRST* = DWORD(0x80040180)
-  OLEOBJ_E_LAST* = DWORD(0x8004018F)
-  OLEOBJ_S_FIRST* = DWORD(0x00040180)
-  OLEOBJ_S_LAST* = DWORD(0x0004018F)
-  OLEOBJ_E_NOVERBS* = HRESULT(0x80040180)
-  OLEOBJ_E_INVALIDVERB* = HRESULT(0x80040181)
-  CLIENTSITE_E_FIRST* = DWORD(0x80040190)
-  CLIENTSITE_E_LAST* = DWORD(0x8004019F)
-  CLIENTSITE_S_FIRST* = DWORD(0x00040190)
-  CLIENTSITE_S_LAST* = DWORD(0x0004019F)
-  INPLACE_E_NOTUNDOABLE* = HRESULT(0x800401A0)
-  INPLACE_E_NOTOOLSPACE* = HRESULT(0x800401A1)
-  INPLACE_E_FIRST* = DWORD(0x800401A0)
-  INPLACE_E_LAST* = DWORD(0x800401AF)
-  INPLACE_S_FIRST* = DWORD(0x000401A0)
-  INPLACE_S_LAST* = DWORD(0x000401AF)
-  ENUM_E_FIRST* = DWORD(0x800401B0)
-  ENUM_E_LAST* = DWORD(0x800401BF)
-  ENUM_S_FIRST* = DWORD(0x000401B0)
-  ENUM_S_LAST* = DWORD(0x000401BF)
-  CONVERT10_E_FIRST* = DWORD(0x800401C0)
-  CONVERT10_E_LAST* = DWORD(0x800401CF)
-  CONVERT10_S_FIRST* = DWORD(0x000401C0)
-  CONVERT10_S_LAST* = DWORD(0x000401CF)
-  CONVERT10_E_OLESTREAM_GET* = HRESULT(0x800401C0)
-  CONVERT10_E_OLESTREAM_PUT* = HRESULT(0x800401C1)
-  CONVERT10_E_OLESTREAM_FMT* = HRESULT(0x800401C2)
-  CONVERT10_E_OLESTREAM_BITMAP_TO_DIB* = HRESULT(0x800401C3)
-  CONVERT10_E_STG_FMT* = HRESULT(0x800401C4)
-  CONVERT10_E_STG_NO_STD_STREAM* = HRESULT(0x800401C5)
-  CONVERT10_E_STG_DIB_TO_BITMAP* = HRESULT(0x800401C6)
-  CLIPBRD_E_FIRST* = DWORD(0x800401D0)
-  CLIPBRD_E_LAST* = DWORD(0x800401DF)
-  CLIPBRD_S_FIRST* = DWORD(0x000401D0)
-  CLIPBRD_S_LAST* = DWORD(0x000401DF)
-  CLIPBRD_E_CANT_OPEN* = HRESULT(0x800401D0)
-  CLIPBRD_E_CANT_EMPTY* = HRESULT(0x800401D1)
-  CLIPBRD_E_CANT_SET* = HRESULT(0x800401D2)
-  CLIPBRD_E_BAD_DATA* = HRESULT(0x800401D3)
-  CLIPBRD_E_CANT_CLOSE* = HRESULT(0x800401D4)
-  MK_E_FIRST* = DWORD(0x800401E0)
-  MK_E_LAST* = DWORD(0x800401EF)
-  MK_S_FIRST* = DWORD(0x000401E0)
-  MK_S_LAST* = DWORD(0x000401EF)
-  MK_E_CONNECTMANUALLY* = HRESULT(0x800401E0)
-  MK_E_EXCEEDEDDEADLINE* = HRESULT(0x800401E1)
-  MK_E_NEEDGENERIC* = HRESULT(0x800401E2)
-  MK_E_UNAVAILABLE* = HRESULT(0x800401E3)
-  MK_E_SYNTAX* = HRESULT(0x800401E4)
-  MK_E_NOOBJECT* = HRESULT(0x800401E5)
-  MK_E_INVALIDEXTENSION* = HRESULT(0x800401E6)
-  MK_E_INTERMEDIATEINTERFACENOTSUPPORTED* = HRESULT(0x800401E7)
-  MK_E_NOTBINDABLE* = HRESULT(0x800401E8)
-  MK_E_NOTBOUND* = HRESULT(0x800401E9)
-  MK_E_CANTOPENFILE* = HRESULT(0x800401EA)
-  MK_E_MUSTBOTHERUSER* = HRESULT(0x800401EB)
-  MK_E_NOINVERSE* = HRESULT(0x800401EC)
-  MK_E_NOSTORAGE* = HRESULT(0x800401ED)
-  MK_E_NOPREFIX* = HRESULT(0x800401EE)
-  MK_E_ENUMERATION_FAILED* = HRESULT(0x800401EF)
-  OLE_S_USEREG* = HRESULT(0x00040000)
-  OLE_S_STATIC* = HRESULT(0x00040001)
-  OLE_S_MAC_CLIPFORMAT* = HRESULT(0x00040002)
-  DRAGDROP_S_DROP* = HRESULT(0x00040100)
-  DRAGDROP_S_CANCEL* = HRESULT(0x00040101)
-  DRAGDROP_S_USEDEFAULTCURSORS* = HRESULT(0x00040102)
-  DATA_S_SAMEFORMATETC* = HRESULT(0x00040130)
-  VIEW_S_ALREADY_FROZEN* = HRESULT(0x00040140)
-  CACHE_S_FORMATETC_NOTSUPPORTED* = HRESULT(0x00040170)
-  CACHE_S_SAMECACHE* = HRESULT(0x00040171)
-  CACHE_S_SOMECACHES_NOTUPDATED* = HRESULT(0x00040172)
-  OLEOBJ_S_INVALIDVERB* = HRESULT(0x00040180)
-  OLEOBJ_S_CANNOT_DOVERB_NOW* = HRESULT(0x00040181)
-  OLEOBJ_S_INVALIDHWND* = HRESULT(0x00040182)
-  INPLACE_S_TRUNCATED* = HRESULT(0x000401A0)
-  CONVERT10_S_NO_PRESENTATION* = HRESULT(0x000401C0)
-  MK_S_REDUCED_TO_SELF* = HRESULT(0x000401E2)
-  MK_S_ME* = HRESULT(0x000401E4)
-  MK_S_HIM* = HRESULT(0x000401E5)
-  MK_S_US* = HRESULT(0x000401E6)
-  MK_S_MONIKERALREADYREGISTERED* = HRESULT(0x000401E7)
-  CO_E_CLASS_CREATE_FAILED* = HRESULT(0x80080001)
-  CO_E_SCM_ERROR* = HRESULT(0x80080002)
-  CO_E_SCM_RPC_FAILURE* = HRESULT(0x80080003)
-  CO_E_BAD_PATH* = HRESULT(0x80080004)
-  CO_E_SERVER_EXEC_FAILURE* = HRESULT(0x80080005)
-  CO_E_OBJSRV_RPC_FAILURE* = HRESULT(0x80080006)
-  MK_E_NO_NORMALIZED* = HRESULT(0x80080007)
-  CO_E_SERVER_STOPPING* = HRESULT(0x80080008)
-  MEM_E_INVALID_ROOT* = HRESULT(0x80080009)
-  MEM_E_INVALID_LINK* = HRESULT(0x80080010)
-  MEM_E_INVALID_SIZE* = HRESULT(0x80080011)
-  CO_S_NOTALLINTERFACES* = HRESULT(0x00080012)
-  DISP_E_UNKNOWNINTERFACE* = HRESULT(0x80020001)
-  DISP_E_MEMBERNOTFOUND* = HRESULT(0x80020003)
-  DISP_E_PARAMNOTFOUND* = HRESULT(0x80020004)
-  DISP_E_TYPEMISMATCH* = HRESULT(0x80020005)
-  DISP_E_UNKNOWNNAME* = HRESULT(0x80020006)
-  DISP_E_NONAMEDARGS* = HRESULT(0x80020007)
-  DISP_E_BADVARTYPE* = HRESULT(0x80020008)
-  DISP_E_EXCEPTION* = HRESULT(0x80020009)
-  DISP_E_OVERFLOW* = HRESULT(0x8002000A)
-  DISP_E_BADINDEX* = HRESULT(0x8002000B)
-  DISP_E_UNKNOWNLCID* = HRESULT(0x8002000C)
-  DISP_E_ARRAYISLOCKED* = HRESULT(0x8002000D)
-  DISP_E_BADPARAMCOUNT* = HRESULT(0x8002000E)
-  DISP_E_PARAMNOTOPTIONAL* = HRESULT(0x8002000F)
-  DISP_E_BADCALLEE* = HRESULT(0x80020010)
-  DISP_E_NOTACOLLECTION* = HRESULT(0x80020011)
-  TYPE_E_BUFFERTOOSMALL* = HRESULT(0x80028016)
-  TYPE_E_INVDATAREAD* = HRESULT(0x80028018)
-  TYPE_E_UNSUPFORMAT* = HRESULT(0x80028019)
-  TYPE_E_REGISTRYACCESS* = HRESULT(0x8002801C)
-  TYPE_E_LIBNOTREGISTERED* = HRESULT(0x8002801D)
-  TYPE_E_UNDEFINEDTYPE* = HRESULT(0x80028027)
-  TYPE_E_QUALIFIEDNAMEDISALLOWED* = HRESULT(0x80028028)
-  TYPE_E_INVALIDSTATE* = HRESULT(0x80028029)
-  TYPE_E_WRONGTYPEKIND* = HRESULT(0x8002802A)
-  TYPE_E_ELEMENTNOTFOUND* = HRESULT(0x8002802B)
-  TYPE_E_AMBIGUOUSNAME* = HRESULT(0x8002802C)
-  TYPE_E_NAMECONFLICT* = HRESULT(0x8002802D)
-  TYPE_E_UNKNOWNLCID* = HRESULT(0x8002802E)
-  TYPE_E_DLLFUNCTIONNOTFOUND* = HRESULT(0x8002802F)
-  TYPE_E_BADMODULEKIND* = HRESULT(0x800288BD)
-  TYPE_E_SIZETOOBIG* = HRESULT(0x800288C5)
-  TYPE_E_DUPLICATEID* = HRESULT(0x800288C6)
-  TYPE_E_INVALIDID* = HRESULT(0x800288CF)
-  TYPE_E_TYPEMISMATCH* = HRESULT(0x80028CA0)
-  TYPE_E_OUTOFBOUNDS* = HRESULT(0x80028CA1)
-  TYPE_E_IOERROR* = HRESULT(0x80028CA2)
-  TYPE_E_CANTCREATETMPFILE* = HRESULT(0x80028CA3)
-  TYPE_E_CANTLOADLIBRARY* = HRESULT(0x80029C4A)
-  TYPE_E_INCONSISTENTPROPFUNCS* = HRESULT(0x80029C83)
-  TYPE_E_CIRCULARTYPE* = HRESULT(0x80029C84)
-  STG_E_INVALIDFUNCTION* = HRESULT(0x80030001)
-  STG_E_FILENOTFOUND* = HRESULT(0x80030002)
-  STG_E_PATHNOTFOUND* = HRESULT(0x80030003)
-  STG_E_TOOMANYOPENFILES* = HRESULT(0x80030004)
-  STG_E_ACCESSDENIED* = HRESULT(0x80030005)
-  STG_E_INVALIDHANDLE* = HRESULT(0x80030006)
-  STG_E_INSUFFICIENTMEMORY* = HRESULT(0x80030008)
-  STG_E_INVALIDPOINTER* = HRESULT(0x80030009)
-  STG_E_NOMOREFILES* = HRESULT(0x80030012)
-  STG_E_DISKISWRITEPROTECTED* = HRESULT(0x80030013)
-  STG_E_SEEKERROR* = HRESULT(0x80030019)
-  STG_E_WRITEFAULT* = HRESULT(0x8003001D)
-  STG_E_READFAULT* = HRESULT(0x8003001E)
-  STG_E_SHAREVIOLATION* = HRESULT(0x80030020)
-  STG_E_LOCKVIOLATION* = HRESULT(0x80030021)
-  STG_E_FILEALREADYEXISTS* = HRESULT(0x80030050)
-  STG_E_INVALIDPARAMETER* = HRESULT(0x80030057)
-  STG_E_MEDIUMFULL* = HRESULT(0x80030070)
-  STG_E_PROPSETMISMATCHED* = HRESULT(0x800300F0)
-  STG_E_ABNORMALAPIEXIT* = HRESULT(0x800300FA)
-  STG_E_INVALIDHEADER* = HRESULT(0x800300FB)
-  STG_E_INVALIDNAME* = HRESULT(0x800300FC)
-  STG_E_UNKNOWN* = HRESULT(0x800300FD)
-  STG_E_UNIMPLEMENTEDFUNCTION* = HRESULT(0x800300FE)
-  STG_E_INVALIDFLAG* = HRESULT(0x800300FF)
-  STG_E_INUSE* = HRESULT(0x80030100)
-  STG_E_NOTCURRENT* = HRESULT(0x80030101)
-  STG_E_REVERTED* = HRESULT(0x80030102)
-  STG_E_CANTSAVE* = HRESULT(0x80030103)
-  STG_E_OLDFORMAT* = HRESULT(0x80030104)
-  STG_E_OLDDLL* = HRESULT(0x80030105)
-  STG_E_SHAREREQUIRED* = HRESULT(0x80030106)
-  STG_E_NOTFILEBASEDSTORAGE* = HRESULT(0x80030107)
-  STG_E_EXTANTMARSHALLINGS* = HRESULT(0x80030108)
-  STG_E_DOCFILECORRUPT* = HRESULT(0x80030109)
-  STG_E_BADBASEADDRESS* = HRESULT(0x80030110)
-  STG_E_INCOMPLETE* = HRESULT(0x80030201)
-  STG_E_TERMINATED* = HRESULT(0x80030202)
-  STG_S_CONVERTED* = HRESULT(0x00030200)
-  STG_S_BLOCK* = HRESULT(0x00030201)
-  STG_S_RETRYNOW* = HRESULT(0x00030202)
-  STG_S_MONITORING* = HRESULT(0x00030203)
-  RPC_E_CALL_REJECTED* = HRESULT(0x80010001)
-  RPC_E_CALL_CANCELED* = HRESULT(0x80010002)
-  RPC_E_CANTPOST_INSENDCALL* = HRESULT(0x80010003)
-  RPC_E_CANTCALLOUT_INASYNCCALL* = HRESULT(0x80010004)
-  RPC_E_CANTCALLOUT_INEXTERNALCALL* = HRESULT(0x80010005)
-  RPC_E_CONNECTION_TERMINATED* = HRESULT(0x80010006)
-  RPC_E_SERVER_DIED* = HRESULT(0x80010007)
-  RPC_E_CLIENT_DIED* = HRESULT(0x80010008)
-  RPC_E_INVALID_DATAPACKET* = HRESULT(0x80010009)
-  RPC_E_CANTTRANSMIT_CALL* = HRESULT(0x8001000A)
-  RPC_E_CLIENT_CANTMARSHAL_DATA* = HRESULT(0x8001000B)
-  RPC_E_CLIENT_CANTUNMARSHAL_DATA* = HRESULT(0x8001000C)
-  RPC_E_SERVER_CANTMARSHAL_DATA* = HRESULT(0x8001000D)
-  RPC_E_SERVER_CANTUNMARSHAL_DATA* = HRESULT(0x8001000E)
-  RPC_E_INVALID_DATA* = HRESULT(0x8001000F)
-  RPC_E_INVALID_PARAMETER* = HRESULT(0x80010010)
-  RPC_E_CANTCALLOUT_AGAIN* = HRESULT(0x80010011)
-  RPC_E_SERVER_DIED_DNE* = HRESULT(0x80010012)
-  RPC_E_SYS_CALL_FAILED* = HRESULT(0x80010100)
-  RPC_E_OUT_OF_RESOURCES* = HRESULT(0x80010101)
-  RPC_E_ATTEMPTED_MULTITHREAD* = HRESULT(0x80010102)
-  RPC_E_NOT_REGISTERED* = HRESULT(0x80010103)
-  RPC_E_FAULT* = HRESULT(0x80010104)
-  RPC_E_SERVERFAULT* = HRESULT(0x80010105)
-  RPC_E_CHANGED_MODE* = HRESULT(0x80010106)
-  RPC_E_INVALIDMETHOD* = HRESULT(0x80010107)
-  RPC_E_DISCONNECTED* = HRESULT(0x80010108)
-  RPC_E_RETRY* = HRESULT(0x80010109)
-  RPC_E_SERVERCALL_RETRYLATER* = HRESULT(0x8001010A)
-  RPC_E_SERVERCALL_REJECTED* = HRESULT(0x8001010B)
-  RPC_E_INVALID_CALLDATA* = HRESULT(0x8001010C)
-  RPC_E_CANTCALLOUT_ININPUTSYNCCALL* = HRESULT(0x8001010D)
-  RPC_E_WRONG_THREAD* = HRESULT(0x8001010E)
-  RPC_E_THREAD_NOT_INIT* = HRESULT(0x8001010F)
-  RPC_E_VERSION_MISMATCH* = HRESULT(0x80010110)
-  RPC_E_INVALID_HEADER* = HRESULT(0x80010111)
-  RPC_E_INVALID_EXTENSION* = HRESULT(0x80010112)
-  RPC_E_INVALID_IPID* = HRESULT(0x80010113)
-  RPC_E_INVALID_OBJECT* = HRESULT(0x80010114)
-  RPC_S_CALLPENDING* = HRESULT(0x80010115)
-  RPC_S_WAITONTIMER* = HRESULT(0x80010116)
-  RPC_E_CALL_COMPLETE* = HRESULT(0x80010117)
-  RPC_E_UNSECURE_CALL* = HRESULT(0x80010118)
-  RPC_E_TOO_LATE* = HRESULT(0x80010119)
-  RPC_E_NO_GOOD_SECURITY_PACKAGES* = HRESULT(0x8001011A)
-  RPC_E_ACCESS_DENIED* = HRESULT(0x8001011B)
-  RPC_E_REMOTE_DISABLED* = HRESULT(0x8001011C)
-  RPC_E_INVALID_OBJREF* = HRESULT(0x8001011D)
-  RPC_E_UNEXPECTED* = HRESULT(0x8001FFFF)
-  NTE_BAD_UID* = HRESULT(0x80090001)
-  NTE_BAD_HASH* = HRESULT(0x80090002)
-  NTE_BAD_KEY* = HRESULT(0x80090003)
-  NTE_BAD_LEN* = HRESULT(0x80090004)
-  NTE_BAD_DATA* = HRESULT(0x80090005)
-  NTE_BAD_SIGNATURE* = HRESULT(0x80090006)
-  NTE_BAD_VER* = HRESULT(0x80090007)
-  NTE_BAD_ALGID* = HRESULT(0x80090008)
-  NTE_BAD_FLAGS* = HRESULT(0x80090009)
-  NTE_BAD_TYPE* = HRESULT(0x8009000A)
-  NTE_BAD_KEY_STATE* = HRESULT(0x8009000B)
-  NTE_BAD_HASH_STATE* = HRESULT(0x8009000C)
-  NTE_NO_KEY* = HRESULT(0x8009000D)
-  NTE_NO_MEMORY* = HRESULT(0x8009000E)
-  NTE_EXISTS* = HRESULT(0x8009000F)
-  NTE_PERM* = HRESULT(0x80090010)
-  NTE_NOT_FOUND* = HRESULT(0x80090011)
-  NTE_DOUBLE_ENCRYPT* = HRESULT(0x80090012)
-  NTE_BAD_PROVIDER* = HRESULT(0x80090013)
-  NTE_BAD_PROV_TYPE* = HRESULT(0x80090014)
-  NTE_BAD_PUBLIC_KEY* = HRESULT(0x80090015)
-  NTE_BAD_KEYSET* = HRESULT(0x80090016)
-  NTE_PROV_TYPE_NOT_DEF* = HRESULT(0x80090017)
-  NTE_PROV_TYPE_ENTRY_BAD* = HRESULT(0x80090018)
-  NTE_KEYSET_NOT_DEF* = HRESULT(0x80090019)
-  NTE_KEYSET_ENTRY_BAD* = HRESULT(0x8009001A)
-  NTE_PROV_TYPE_NO_MATCH* = HRESULT(0x8009001B)
-  NTE_SIGNATURE_FILE_BAD* = HRESULT(0x8009001C)
-  NTE_PROVIDER_DLL_FAIL* = HRESULT(0x8009001D)
-  NTE_PROV_DLL_NOT_FOUND* = HRESULT(0x8009001E)
-  NTE_BAD_KEYSET_PARAM* = HRESULT(0x8009001F)
-  NTE_FAIL* = HRESULT(0x80090020)
-  NTE_SYS_ERR* = HRESULT(0x80090021)
-  NTE_OP_OK* = HRESULT(0)
-  TRUST_E_PROVIDER_UNKNOWN* = HRESULT(0x800B0001)
-  TRUST_E_ACTION_UNKNOWN* = HRESULT(0x800B0002)
-  TRUST_E_SUBJECT_FORM_UNKNOWN* = HRESULT(0x800B0003)
-  TRUST_E_SUBJECT_NOT_TRUSTED* = HRESULT(0x800B0004)
-  DIGSIG_E_ENCODE* = HRESULT(0x800B0005)
-  DIGSIG_E_DECODE* = HRESULT(0x800B0006)
-  DIGSIG_E_EXTENSIBILITY* = HRESULT(0x800B0007)
-  DIGSIG_E_CRYPTO* = HRESULT(0x800B0008)
-  PERSIST_E_SIZEDEFINITE* = HRESULT(0x800B0009)
-  PERSIST_E_SIZEINDEFINITE* = HRESULT(0x800B000A)
-  PERSIST_E_NOTSELFSIZING* = HRESULT(0x800B000B)
-  TRUST_E_NOSIGNATURE* = HRESULT(0x800B0100)
-  CERT_E_EXPIRED* = HRESULT(0x800B0101)
-  CERT_E_VALIDIYPERIODNESTING* = HRESULT(0x800B0102)
-  CERT_E_ROLE* = HRESULT(0x800B0103)
-  CERT_E_PATHLENCONST* = HRESULT(0x800B0104)
-  CERT_E_CRITICAL* = HRESULT(0x800B0105)
-  CERT_E_PURPOSE* = HRESULT(0x800B0106)
-  CERT_E_ISSUERCHAINING* = HRESULT(0x800B0107)
-  CERT_E_MALFORMED* = HRESULT(0x800B0108)
-  CERT_E_UNTRUSTEDROOT* = HRESULT(0x800B0109)
-  CERT_E_CHAINING* = HRESULT(0x800B010A) # was #define dname def_expr
-
-proc UNICODE_NULL*(): WCHAR
-const
-  MAX_PATH* = 260
-  LF_FACESIZE* = 32
-  LF_FULLFACESIZE* = 64
-  ELF_VENDOR_SIZE* = 4
-  SECURITY_STATIC_TRACKING* = 0
-  SECURITY_DYNAMIC_TRACKING* = 1
-  MAX_DEFAULTCHAR* = 2
-  MAX_LEADBYTES* = 12
-  EXCEPTION_MAXIMUM_PARAMETERS* = 15
-  CCHDEVICENAME* = 32
-  CCHFORMNAME* = 32
-  MENU_TEXT_LEN* = 40
-  MAX_LANA* = 254
-  NCBNAMSZ* = 16
-  NETBIOS_NAME_LEN* = 16
-  OFS_MAXPATHNAME* = 128
-  MAX_TAB_STOPS* = 32
-  ANYSIZE_ARRAY* = 1
-  RAS_MaxCallbackNumber* = 128
-  RAS_MaxDeviceName* = 128
-  RAS_MaxDeviceType* = 16
-  RAS_MaxEntryName* = 256
-  RAS_MaxIpAddress* = 15
-  RAS_MaxIpxAddress* = 21
-  RAS_MaxPhoneNumber* = 128
-  UNLEN* = 256
-  PWLEN* = 256
-  CNLEN* = 15
-  DNLEN* = 15                 # Unsigned types max
-  MAXDWORD* = 0xFFFFFFFF
-  MAXWORD* = 0x0000FFFF
-  MAXBYTE* = 0x000000FF       # Signed types max/min
-  MINCHAR* = 0x00000080
-  MAXCHAR* = 0x0000007F
-  MINSHORT* = 0x00008000
-  MAXSHORT* = 0x00007FFF
-  MINLONG* = 0x80000000
-  MAXLONG* = 0x7FFFFFFF       # _llseek
-  FILE_BEGIN* = 0
-  FILE_CURRENT* = 1
-  FILE_END* = 2               # _lopen, LZOpenFile, OpenFile
-  OF_READ* = 0
-  OF_READWRITE* = 2
-  OF_WRITE* = 1
-  OF_SHARE_COMPAT* = 0
-  OF_SHARE_DENY_NONE* = 64
-  OF_SHARE_DENY_READ* = 48
-  OF_SHARE_DENY_WRITE* = 32
-  OF_SHARE_EXCLUSIVE* = 16
-  OF_CANCEL* = 2048
-  OF_CREATE* = 4096
-  OF_DELETE* = 512
-  OF_EXIST* = 16384
-  OF_PARSE* = 256
-  OF_PROMPT* = 8192
-  OF_REOPEN* = 32768
-  OF_VERIFY* = 1024           # ActivateKeyboardLayout, LoadKeyboardLayout
-  HKL_NEXT* = 1
-  HKL_PREV* = 0
-  KLF_REORDER* = 8
-  KLF_UNLOADPREVIOUS* = 4
-  KLF_ACTIVATE* = 1
-  KLF_NOTELLSHELL* = 128
-  KLF_REPLACELANG* = 16
-  KLF_SUBSTITUTE_OK* = 2      # AppendMenu
-  MF_BITMAP* = 0x00000004
-  MF_DISABLED* = 0x00000002
-  MF_ENABLED* = 0
-  MF_GRAYED* = 0x00000001
-  MF_HELP* = 0x00004000
-  MF_MENUBARBREAK* = 0x00000020
-  MF_MENUBREAK* = 0x00000040
-  MF_MOUSESELECT* = 0x00008000
-  MF_OWNERDRAW* = 0x00000100
-  MF_POPUP* = 0x00000010
-  MF_SEPARATOR* = 0x00000800
-  MF_STRING* = 0
-  MF_SYSMENU* = 0x00002000
-  MF_USECHECKBITMAPS* = 0x00000200 # Ternary Raster Operations - BitBlt
-  BLACKNESS* = 0x00000042
-  NOTSRCERASE* = 0x001100A6
-  NOTSRCCOPY* = 0x00330008
-  SRCERASE* = 0x00440328
-  DSTINVERT* = 0x00550009
-  PATINVERT* = 0x005A0049
-  SRCINVERT* = 0x00660046
-  SRCAND* = 0x008800C6
-  MERGEPAINT* = 0x00BB0226
-  MERGECOPY* = 0x00C000CA
-  SRCCOPY* = 0x00CC0020
-  SRCPAINT* = 0x00EE0086
-  PATCOPY* = 0x00F00021
-  PATPAINT* = 0x00FB0A09
-  WHITENESS* = 0x00FF0062     # Binary Raster Operations
-  R2_BLACK* = 1
-  R2_COPYPEN* = 13
-  R2_MASKNOTPEN* = 3
-  R2_MASKPEN* = 9
-  R2_MASKPENNOT* = 5
-  R2_MERGENOTPEN* = 12
-  R2_MERGEPEN* = 15
-  R2_MERGEPENNOT* = 14
-  R2_NOP* = 11
-  R2_NOT* = 6
-  R2_NOTCOPYPEN* = 4
-  R2_NOTMASKPEN* = 8
-  R2_NOTMERGEPEN* = 2
-  R2_NOTXORPEN* = 10
-  R2_WHITE* = 16
-  R2_XORPEN* = 7              # BroadcastSystemMessage
-  BSF_FLUSHDISK* = 4
-  BSF_FORCEIFHUNG* = 32
-  BSF_IGNORECURRENTTASK* = 2
-  BSF_NOHANG* = 8
-  BSF_POSTMESSAGE* = 16
-  BSF_QUERY* = 1
-  BSM_ALLCOMPONENTS* = 0
-  BSM_APPLICATIONS* = 8
-  BSM_INSTALLABLEDRIVERS* = 4
-  BSM_NETDRIVER* = 2
-  BSM_VXDS* = 1
-  BROADCAST_QUERY_DENY* = 1112363332 # BrowseCallbackProc
-                                     # CallNamedPipe
-  NMPWAIT_NOWAIT* = 1
-  NMPWAIT_WAIT_FOREVER* = - (1)
-  NMPWAIT_USE_DEFAULT_WAIT* = 0 # CascadeWindows, TileWindows
-  MDITILE_SKIPDISABLED* = 2
-  MDITILE_HORIZONTAL* = 1
-  MDITILE_VERTICAL* = 0       # CBTProc
-  HCBT_ACTIVATE* = 5
-  HCBT_CLICKSKIPPED* = 6
-  HCBT_CREATEWND* = 3
-  HCBT_DESTROYWND* = 4
-  HCBT_KEYSKIPPED* = 7
-  HCBT_MINMAX* = 1
-  HCBT_MOVESIZE* = 0
-  HCBT_QS* = 2
-  HCBT_SETFOCUS* = 9
-  HCBT_SYSCOMMAND* = 8        # ChangeDisplaySettings
-  DM_BITSPERPEL* = 0x00040000
-  DM_PELSWIDTH* = 0x00080000
-  DM_PELSHEIGHT* = 0x00100000
-  DM_DISPLAYFLAGS* = 0x00200000
-  DM_DISPLAYFREQUENCY* = 0x00400000
-  CDS_UPDATEREGISTRY* = 1
-  CDS_TEST* = 2
-  CDS_FULLSCREEN* = 4
-  CDS_GLOBAL* = 8
-  CDS_SET_PRIMARY* = 0x00000010
-  CDS_RESET* = 0x40000000
-  CDS_SETRECT* = 0x20000000
-  CDS_NORESET* = 0x10000000
-  DISP_CHANGE_SUCCESSFUL* = 0
-  DISP_CHANGE_RESTART* = 1
-  DISP_CHANGE_BADFLAGS* = - (4)
-  DISP_CHANGE_FAILED* = - (1)
-  DISP_CHANGE_BADMODE* = - (2)
-  DISP_CHANGE_NOTUPDATED* = - (3) # ChangeServiceConfig
-  SERVICE_NO_CHANGE* = - (1)
-  SERVICE_WIN32_OWN_PROCESS* = 16
-  SERVICE_WIN32_SHARE_PROCESS* = 32
-  SERVICE_KERNEL_DRIVER* = 1
-  SERVICE_FILE_SYSTEM_DRIVER* = 2
-  SERVICE_INTERACTIVE_PROCESS* = 256
-  SERVICE_BOOT_START* = 0
-  SERVICE_SYSTEM_START* = 1
-  SERVICE_AUTO_START* = 2
-  SERVICE_DEMAND_START* = 3
-  SERVICE_DISABLED* = 4       # SERVICE_STATUS structure
-  SERVICE_STOPPED* = 1
-  SERVICE_START_PENDING* = 2
-  SERVICE_STOP_PENDING* = 3
-  SERVICE_RUNNING* = 4
-  SERVICE_CONTINUE_PENDING* = 5
-  SERVICE_PAUSE_PENDING* = 6
-  SERVICE_PAUSED* = 7
-  SERVICE_ACCEPT_STOP* = 1
-  SERVICE_ACCEPT_PAUSE_CONTINUE* = 2
-  SERVICE_ACCEPT_SHUTDOWN* = 4 # CheckDlgButton
-  BST_CHECKED* = 1
-  BST_INDETERMINATE* = 2
-  BST_UNCHECKED* = 0
-  BST_FOCUS* = 8
-  BST_PUSHED* = 4             # CheckMenuItem, HiliteMenuItem
-  MF_BYCOMMAND* = 0
-  MF_BYPOSITION* = 0x00000400
-  MF_CHECKED* = 0x00000008
-  MF_UNCHECKED* = 0
-  MF_HILITE* = 0x00000080
-  MF_UNHILITE* = 0            # ChildWindowFromPointEx
-  CWP_ALL* = 0
-  CWP_SKIPINVISIBLE* = 1
-  CWP_SKIPDISABLED* = 2
-  CWP_SKIPTRANSPARENT* = 4    # ClearCommError
-  CE_BREAK* = 16
-  CE_DNS* = 2048
-  CE_FRAME* = 8
-  CE_IOE* = 1024
-  CE_MODE* = 32768
-  CE_OOP* = 4096
-  CE_OVERRUN* = 2
-  CE_PTO* = 512
-  CE_RXOVER* = 1
-  CE_RXPARITY* = 4
-  CE_TXFULL* = 256            # ChooseMatchToTarget
-                              # CombineRgn
-  RGN_AND* = 1
-  RGN_COPY* = 5
-  RGN_DIFF* = 4
-  RGN_OR* = 2
-  RGN_XOR* = 3
-  NULLREGION* = 1
-  SIMPLEREGION* = 2
-  COMPLEXREGION* = 3
-  ERROR* = 0                  # CommonDlgExtendedError
-  CDERR_DIALOGFAILURE* = 0x0000FFFF
-  CDERR_FINDRESFAILURE* = 6
-  CDERR_INITIALIZATION* = 2
-  CDERR_LOADRESFAILURE* = 7
-  CDERR_LOADSTRFAILURE* = 5
-  CDERR_LOCKRESFAILURE* = 8
-  CDERR_MEMALLOCFAILURE* = 9
-  CDERR_MEMLOCKFAILURE* = 10
-  CDERR_NOHINSTANCE* = 4
-  CDERR_NOHOOK* = 11
-  CDERR_NOTEMPLATE* = 3
-  CDERR_REGISTERMSGFAIL* = 12
-  CDERR_STRUCTSIZE* = 1
-  PDERR_CREATEICFAILURE* = 0x00001000 + 10
-  PDERR_DEFAULTDIFFERENT* = 0x00001000 + 12
-  PDERR_DNDMMISMATCH* = 0x00001000 + 9
-  PDERR_GETDEVMODEFAIL* = 0x00001000 + 5
-  PDERR_INITFAILURE* = 0x00001000 + 6
-  PDERR_LOADDRVFAILURE* = 0x00001000 + 4
-  PDERR_NODEFAULTPRN* = 0x00001000 + 8
-  PDERR_NODEVICES* = 0x00001000 + 7
-  PDERR_PARSEFAILURE* = 0x00001000 + 2
-  PDERR_PRINTERNOTFOUND* = 0x00001000 + 11
-  PDERR_RETDEFFAILURE* = 0x00001000 + 3
-  PDERR_SETUPFAILURE* = 0x00001000 + 1
-  CFERR_MAXLESSTHANMIN* = 0x00002000 + 2
-  CFERR_NOFONTS* = 0x00002000 + 1
-  FNERR_BUFFERTOOSMALL* = 0x00003000 + 3
-  FNERR_INVALIDFILENAME* = 0x00003000 + 2
-  FNERR_SUBCLASSFAILURE* = 0x00003000 + 1
-  FRERR_BUFFERLENGTHZERO* = 0x00004000 + 1 # CompareString, LCMapString
-  LOCALE_SYSTEM_DEFAULT* = 0x00000800
-  LOCALE_USER_DEFAULT* = 0x00000400
-  NORM_IGNORECASE* = 1
-  NORM_IGNOREKANATYPE* = 65536
-  NORM_IGNORENONSPACE* = 2
-  NORM_IGNORESYMBOLS* = 4
-  NORM_IGNOREWIDTH* = 131072
-  SORT_STRINGSORT* = 4096
-  LCMAP_BYTEREV* = 2048
-  LCMAP_FULLWIDTH* = 8388608
-  LCMAP_HALFWIDTH* = 4194304
-  LCMAP_HIRAGANA* = 1048576
-  LCMAP_KATAKANA* = 2097152
-  LCMAP_LOWERCASE* = 256
-  LCMAP_SORTKEY* = 1024
-  LCMAP_UPPERCASE* = 512      # ContinueDebugEvent
-  DBG_CONTINUE* = 0x00010002
-  DBG_CONTROL_BREAK* = 0x40010008
-  DBG_CONTROL_C* = 0x40010005
-  DBG_EXCEPTION_NOT_HANDLED* = 0x80010001
-  DBG_TERMINATE_THREAD* = 0x40010003
-  DBG_TERMINATE_PROCESS* = 0x40010004 # ControlService
-  SERVICE_CONTROL_STOP* = 1
-  SERVICE_CONTROL_PAUSE* = 2
-  SERVICE_CONTROL_CONTINUE* = 3
-  SERVICE_CONTROL_INTERROGATE* = 4
-  SERVICE_CONTROL_SHUTDOWN* = 5 # CopyImage, LoadImage
-  IMAGE_BITMAP* = 0
-  IMAGE_CURSOR* = 2
-  IMAGE_ENHMETAFILE* = 1
-  IMAGE_ICON* = 1
-  LR_MONOCHROME* = 1
-  LR_COLOR* = 2
-  LR_COPYRETURNORG* = 4
-  LR_COPYDELETEORG* = 8
-  LR_DEFAULTSIZE* = 64
-  LR_CREATEDIBSECTION* = 8192
-  LR_COPYFROMRESOURCE* = 0x00004000
-  LR_SHARED* = 0x00008000     # CreateDesktop
-  DF_ALLOWOTHERACCOUNTHOOK* = 0x00000001
-  DESKTOP_CREATEMENU* = 0x00000004
-  DESKTOP_CREATEWINDOW* = 0x00000002
-  DESKTOP_ENUMERATE* = 0x00000040
-  DESKTOP_HOOKCONTROL* = 0x00000008
-  DESKTOP_JOURNALPLAYBACK* = 0x00000020
-  DESKTOP_JOURNALRECORD* = 0x00000010
-  DESKTOP_READOBJECTS* = 0x00000001
-  DESKTOP_SWITCHDESKTOP* = 0x00000100
-  DESKTOP_WRITEOBJECTS* = 0x00000080
-  WSF_VISIBLE* = 0x00000001   # CreateDIBitmap
-  CBM_INIT* = 0x00000004
-  DIB_PAL_COLORS* = 1
-  DIB_RGB_COLORS* = 0         # CreateFile, GetFileAttributes, SetFileAttributes
-  GENERIC_READ* = 0x80000000
-  GENERIC_WRITE* = 0x40000000 # file & pipe
-  FILE_READ_DATA* = 0x00000001 # directory
-  FILE_LIST_DIRECTORY* = 0x00000001 # file & pipe
-  FILE_WRITE_DATA* = 0x00000002 # directory
-  FILE_ADD_FILE* = 0x00000002 # file
-  FILE_APPEND_DATA* = 0x00000004 # directory
-  FILE_ADD_SUBDIRECTORY* = 0x00000004 # named pipe
-  FILE_CREATE_PIPE_INSTANCE* = 0x00000004 # file & directory
-  FILE_READ_EA* = 0x00000008
-  FILE_READ_PROPERTIES* = FILE_READ_EA # file & directory
-  FILE_WRITE_EA* = 0x00000010
-  FILE_WRITE_PROPERTIES* = FILE_WRITE_EA # file
-  FILE_EXECUTE* = 0x00000020  # directory
-  FILE_TRAVERSE* = 0x00000020 # directory
-  FILE_DELETE_CHILD* = 0x00000040 # all
-  FILE_READ_ATTRIBUTES* = 0x00000080 # all
-  FILE_WRITE_ATTRIBUTES* = 0x00000100 # displaced lower
-                                      #  #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
-                                      #
-                                      #  #define FILE_GENERIC_READ         (STANDARD_RIGHTS_READ     |\
-                                      #                                     FILE_READ_DATA           |\
-                                      #                                     FILE_READ_ATTRIBUTES     |\
-                                      #                                     FILE_READ_EA             |\
-                                      #                                     SYNCHRONIZE)
-                                      #
-                                      #
-                                      #  #define FILE_GENERIC_WRITE        (STANDARD_RIGHTS_WRITE    |\
-                                      #                                     FILE_WRITE_DATA          |\
-                                      #                                     FILE_WRITE_ATTRIBUTES    |\
-                                      #                                     FILE_WRITE_EA            |\
-                                      #                                     FILE_APPEND_DATA         |\
-                                      #                                     SYNCHRONIZE)
-                                      #
-                                      #
-                                      #  #define FILE_GENERIC_EXECUTE      (STANDARD_RIGHTS_EXECUTE  |\
-                                      #                                     FILE_READ_ATTRIBUTES     |\
-                                      #                                     FILE_EXECUTE             |\
-                                      #                                     SYNCHRONIZE)
-                                      #
-  FILE_SHARE_DELETE* = 4
-  FILE_SHARE_READ* = 1
-  FILE_SHARE_WRITE* = 2
-  CONSOLE_TEXTMODE_BUFFER* = 1
-  CREATE_NEW* = 1
-  CREATE_ALWAYS* = 2
-  OPEN_EXISTING* = 3
-  OPEN_ALWAYS* = 4
-  TRUNCATE_EXISTING* = 5
-  FILE_ATTRIBUTE_ARCHIVE* = 32
-  FILE_ATTRIBUTE_COMPRESSED* = 2048
-  FILE_ATTRIBUTE_NORMAL* = 128
-  FILE_ATTRIBUTE_DIRECTORY* = 16
-  FILE_ATTRIBUTE_HIDDEN* = 2
-  FILE_ATTRIBUTE_READONLY* = 1
-  FILE_ATTRIBUTE_SYSTEM* = 4
-  FILE_ATTRIBUTE_TEMPORARY* = 256
-  FILE_FLAG_WRITE_THROUGH* = 0x80000000
-  FILE_FLAG_OVERLAPPED* = 1073741824
-  FILE_FLAG_NO_BUFFERING* = 536870912
-  FILE_FLAG_RANDOM_ACCESS* = 268435456
-  FILE_FLAG_SEQUENTIAL_SCAN* = 134217728
-  FILE_FLAG_DELETE_ON_CLOSE* = 67108864
-  FILE_FLAG_BACKUP_SEMANTICS* = 33554432
-  FILE_FLAG_POSIX_SEMANTICS* = 16777216
-  cSECURITY_ANONYMOUS* = 0
-  cSECURITY_IDENTIFICATION* = 65536
-  cSECURITY_IMPERSONATION* = 131072
-  cSECURITY_DELEGATION* = 196608
-  cSECURITY_CONTEXT_TRACKING* = 262144
-  cSECURITY_EFFECTIVE_ONLY* = 524288
-  cSECURITY_SQOS_PRESENT* = 1048576 # CreateFileMapping, VirtualAlloc, VirtualFree, VirtualProtect
-  SEC_COMMIT* = 134217728
-  SEC_IMAGE* = 16777216
-  SEC_NOCACHE* = 268435456
-  SEC_RESERVE* = 67108864
-  PAGE_READONLY* = 2
-  PAGE_READWRITE* = 4
-  PAGE_WRITECOPY* = 8
-  PAGE_EXECUTE* = 16
-  PAGE_EXECUTE_READ* = 32
-  PAGE_EXECUTE_READWRITE* = 64
-  PAGE_EXECUTE_WRITECOPY* = 128
-  PAGE_GUARD* = 256
-  PAGE_NOACCESS* = 1
-  PAGE_NOCACHE* = 512
-  MEM_COMMIT* = 4096
-  MEM_FREE* = 65536
-  MEM_RESERVE* = 8192
-  MEM_IMAGE* = 16777216
-  MEM_MAPPED* = 262144
-  MEM_PRIVATE* = 131072
-  MEM_DECOMMIT* = 16384
-  MEM_RELEASE* = 32768
-  MEM_TOP_DOWN* = 1048576
-  EXCEPTION_GUARD_PAGE* = 0x80000001
-  SECTION_EXTEND_SIZE* = 0x00000010
-  SECTION_MAP_READ* = 0x00000004
-  SECTION_MAP_WRITE* = 0x00000002
-  SECTION_QUERY* = 0x00000001
-  SECTION_ALL_ACCESS* = 0x000F001F # CreateFont
-  FW_DONTCARE* = 0
-  FW_THIN* = 100
-  FW_EXTRALIGHT* = 200
-  FW_LIGHT* = 300
-  FW_NORMAL* = 400
-  FW_REGULAR* = FW_NORMAL
-  FW_MEDIUM* = 500
-  FW_SEMIBOLD* = 600
-  FW_BOLD* = 700
-  FW_EXTRABOLD* = 800
-  FW_HEAVY* = 900
-  ANSI_CHARSET* = 0
-  DEFAULT_CHARSET* = 1
-  SYMBOL_CHARSET* = 2
-  SHIFTJIS_CHARSET* = 128
-  HANGEUL_CHARSET* = 129
-  GB2312_CHARSET* = 134
-  CHINESEBIG5_CHARSET* = 136
-  GREEK_CHARSET* = 161
-  TURKISH_CHARSET* = 162
-  HEBREW_CHARSET* = 177
-  ARABIC_CHARSET* = 178
-  BALTIC_CHARSET* = 186
-  RUSSIAN_CHARSET* = 204
-  THAI_CHARSET* = 222
-  EASTEUROPE_CHARSET* = 238
-  OEM_CHARSET* = 255
-  OUT_DEFAULT_PRECIS* = 0
-  OUT_STRING_PRECIS* = 1
-  OUT_CHARACTER_PRECIS* = 2
-  OUT_STROKE_PRECIS* = 3
-  OUT_TT_PRECIS* = 4
-  OUT_DEVICE_PRECIS* = 5
-  OUT_RASTER_PRECIS* = 6
-  OUT_TT_ONLY_PRECIS* = 7
-  OUT_OUTLINE_PRECIS* = 8
-  CLIP_DEFAULT_PRECIS* = 0
-  CLIP_CHARACTER_PRECIS* = 1
-  CLIP_STROKE_PRECIS* = 2
-  CLIP_MASK* = 15
-  CLIP_LH_ANGLES* = 16
-  CLIP_TT_ALWAYS* = 32
-  CLIP_EMBEDDED* = 128
-  DEFAULT_QUALITY* = 0
-  DRAFT_QUALITY* = 1
-  PROOF_QUALITY* = 2
-  NONANTIALIASED_QUALITY* = 3
-  ANTIALIASED_QUALITY* = 4
-  DEFAULT_PITCH* = 0
-  FIXED_PITCH* = 1
-  VARIABLE_PITCH* = 2
-  MONO_FONT* = 8
-  FF_DECORATIVE* = 80
-  FF_DONTCARE* = 0
-  FF_MODERN* = 48
-  FF_ROMAN* = 16
-  FF_SCRIPT* = 64
-  FF_SWISS* = 32              # CreateHatchBrush
-  HS_BDIAGONAL* = 3
-  HS_CROSS* = 4
-  HS_DIAGCROSS* = 5
-  HS_FDIAGONAL* = 2
-  HS_HORIZONTAL* = 0
-  HS_VERTICAL* = 1            # CreateIconFromResourceEx
-  LR_DEFAULTCOLOR* = 0
-  LR_LOADREALSIZE* = 128      # already defined above !!
-                              #  #define LR_MONOCHROME (1)
-                              #
-                              # CreateMailslot, GetMailslotInfo
-  MAILSLOT_WAIT_FOREVER* = 0xFFFFFFFF
-  MAILSLOT_NO_MESSAGE* = 0xFFFFFFFF # CreateMappedBitmap
-  CMB_MASKED* = 2             # CreateNamedPipe
-  PIPE_ACCESS_DUPLEX* = 3
-  PIPE_ACCESS_INBOUND* = 1
-  PIPE_ACCESS_OUTBOUND* = 2
-  WRITE_DAC* = 0x00040000
-  WRITE_OWNER* = 0x00080000
-  ACCESS_SYSTEM_SECURITY* = 0x01000000
-  PIPE_TYPE_BYTE* = 0
-  PIPE_TYPE_MESSAGE* = 4
-  PIPE_READMODE_BYTE* = 0
-  PIPE_READMODE_MESSAGE* = 2
-  PIPE_WAIT* = 0
-  PIPE_NOWAIT* = 1            # CreatePen, ExtCreatePen
-  PS_GEOMETRIC* = 65536
-  PS_COSMETIC* = 0
-  PS_ALTERNATE* = 8
-  PS_SOLID* = 0
-  PS_DASH* = 1
-  PS_DOT* = 2
-  PS_DASHDOT* = 3
-  PS_DASHDOTDOT* = 4
-  PS_NULL* = 5
-  PS_USERSTYLE* = 7
-  PS_INSIDEFRAME* = 6
-  PS_ENDCAP_ROUND* = 0
-  PS_ENDCAP_SQUARE* = 256
-  PS_ENDCAP_FLAT* = 512
-  PS_JOIN_BEVEL* = 4096
-  PS_JOIN_MITER* = 8192
-  PS_JOIN_ROUND* = 0
-  PS_STYLE_MASK* = 15
-  PS_ENDCAP_MASK* = 3840
-  PS_TYPE_MASK* = 983040      # CreatePolygonRgn
-  ALTERNATE* = 1
-  WINDING* = 2                # CreateProcess
-  CREATE_DEFAULT_ERROR_MODE* = 67108864
-  CREATE_NEW_CONSOLE* = 16
-  CREATE_NEW_PROCESS_GROUP* = 512
-  CREATE_SEPARATE_WOW_VDM* = 2048
-  CREATE_SUSPENDED* = 4
-  CREATE_UNICODE_ENVIRONMENT* = 1024
-  DEBUG_PROCESS* = 1
-  DEBUG_ONLY_THIS_PROCESS* = 2
-  DETACHED_PROCESS* = 8
-  HIGH_PRIORITY_CLASS* = 128
-  IDLE_PRIORITY_CLASS* = 64
-  NORMAL_PRIORITY_CLASS* = 32
-  REALTIME_PRIORITY_CLASS* = 256 # CreateService
-  SERVICE_ALL_ACCESS* = 0x000F01FF
-  SERVICE_CHANGE_CONFIG* = 2
-  SERVICE_ENUMERATE_DEPENDENTS* = 8
-  SERVICE_INTERROGATE* = 128
-  SERVICE_PAUSE_CONTINUE* = 64
-  SERVICE_QUERY_CONFIG* = 1
-  SERVICE_QUERY_STATUS* = 4
-  SERVICE_START* = 16
-  SERVICE_STOP* = 32
-  SERVICE_USER_DEFINED_CONTROL* = 256
-  SERVICE_DELETE* = 0x00010000
-  SERVICE_READ_CONTROL* = 0x00020000
-  SERVICE_GENERIC_EXECUTE* = 0x20000000 # already defined above !!
-                                        #  #define SERVICE_WIN32_OWN_PROCESS     (16)
-                                        #  #define SERVICE_WIN32_SHARE_PROCESS   (32)
-                                        #  #define SERVICE_KERNEL_DRIVER (1)
-                                        #  #define SERVICE_FILE_SYSTEM_DRIVER    (2)
-                                        #  #define SERVICE_INTERACTIVE_PROCESS   (256)
-                                        #  #define SERVICE_BOOT_START    (0)
-                                        #  #define SERVICE_SYSTEM_START  (1)
-                                        #  #define SERVICE_AUTO_START    (2)
-                                        #  #define SERVICE_DEMAND_START  (3)
-                                        #  #define SERVICE_DISABLED      (4)
-                                        #
-  SERVICE_ERROR_IGNORE* = 0
-  SERVICE_ERROR_NORMAL* = 1
-  SERVICE_ERROR_SEVERE* = 2
-  SERVICE_ERROR_CRITICAL* = 3 # CreateTapePartition, WriteTapemark
-  TAPE_FIXED_PARTITIONS* = 0
-  TAPE_INITIATOR_PARTITIONS* = 0x00000002
-  TAPE_SELECT_PARTITIONS* = 0x00000001
-  TAPE_FILEMARKS* = 0x00000001
-  TAPE_LONG_FILEMARKS* = 0x00000003
-  TAPE_SETMARKS* = 0
-  TAPE_SHORT_FILEMARKS* = 0x00000002 # CreateWindow
-  CW_USEDEFAULT* = int32(0x80000000)
-  WS_BORDER* = 0x00800000
-  WS_CAPTION* = 0x00C00000
-  WS_CHILD* = 0x40000000
-  WS_CHILDWINDOW* = 0x40000000
-  WS_CLIPCHILDREN* = 0x02000000
-  WS_CLIPSIBLINGS* = 0x04000000
-  WS_DISABLED* = 0x08000000
-  WS_DLGFRAME* = 0x00400000
-  WS_GROUP* = 0x00020000
-  WS_HSCROLL* = 0x00100000
-  WS_ICONIC* = 0x20000000
-  WS_MAXIMIZE* = 0x01000000
-  WS_MAXIMIZEBOX* = 0x00010000
-  WS_MINIMIZE* = 0x20000000
-  WS_MINIMIZEBOX* = 0x00020000
-  WS_OVERLAPPED* = 0
-  WS_OVERLAPPEDWINDOW* = 0x00CF0000
-  WS_POPUP* = LONG(0x80000000)
-  WS_POPUPWINDOW* = LONG(0x80880000)
-  WS_SIZEBOX* = 0x00040000
-  WS_SYSMENU* = 0x00080000
-  WS_TABSTOP* = 0x00010000
-  WS_THICKFRAME* = 0x00040000
-  WS_TILED* = 0
-  WS_TILEDWINDOW* = 0x00CF0000
-  WS_VISIBLE* = 0x10000000
-  WS_VSCROLL* = 0x00200000
-  MDIS_ALLCHILDSTYLES* = 0x00000001
-  BS_3STATE* = 0x00000005
-  BS_AUTO3STATE* = 0x00000006
-  BS_AUTOCHECKBOX* = 0x00000003
-  BS_AUTORADIOBUTTON* = 0x00000009
-  BS_BITMAP* = 0x00000080
-  BS_BOTTOM* = 0x00000800
-  BS_CENTER* = 0x00000300
-  BS_CHECKBOX* = 0x00000002
-  BS_DEFPUSHBUTTON* = 0x00000001
-  BS_GROUPBOX* = 0x00000007
-  BS_ICON* = 0x00000040
-  BS_LEFT* = 0x00000100
-  BS_LEFTTEXT* = 0x00000020
-  BS_MULTILINE* = 0x00002000
-  BS_NOTIFY* = 0x00004000
-  BS_OWNERDRAW* = 0x0000000B
-  BS_PUSHBUTTON* = 0
-  BS_PUSHLIKE* = 0x00001000
-  BS_RADIOBUTTON* = 0x00000004
-  BS_RIGHT* = 0x00000200
-  BS_RIGHTBUTTON* = 0x00000020
-  BS_TEXT* = 0
-  BS_TOP* = 0x00000400
-  BS_USERBUTTON* = 0x00000008
-  BS_VCENTER* = 0x00000C00
-  BS_FLAT* = 0x00008000
-  CBS_AUTOHSCROLL* = 0x00000040
-  CBS_DISABLENOSCROLL* = 0x00000800
-  CBS_DROPDOWN* = 0x00000002
-  CBS_DROPDOWNLIST* = 0x00000003
-  CBS_HASSTRINGS* = 0x00000200
-  CBS_LOWERCASE* = 0x00004000
-  CBS_NOINTEGRALHEIGHT* = 0x00000400
-  CBS_OEMCONVERT* = 0x00000080
-  CBS_OWNERDRAWFIXED* = 0x00000010
-  CBS_OWNERDRAWVARIABLE* = 0x00000020
-  CBS_SIMPLE* = 0x00000001
-  CBS_SORT* = 0x00000100
-  CBS_UPPERCASE* = 0x00002000
-  ES_AUTOHSCROLL* = 0x00000080
-  ES_AUTOVSCROLL* = 0x00000040
-  ES_CENTER* = 0x00000001
-  ES_LEFT* = 0
-  ES_LOWERCASE* = 0x00000010
-  ES_MULTILINE* = 0x00000004
-  ES_NOHIDESEL* = 0x00000100
-  ES_NUMBER* = 0x00002000
-  ES_OEMCONVERT* = 0x00000400
-  ES_PASSWORD* = 0x00000020
-  ES_READONLY* = 0x00000800
-  ES_RIGHT* = 0x00000002
-  ES_UPPERCASE* = 0x00000008
-  ES_WANTRETURN* = 0x00001000
-  LBS_DISABLENOSCROLL* = 0x00001000
-  LBS_EXTENDEDSEL* = 0x00000800
-  LBS_HASSTRINGS* = 0x00000040
-  LBS_MULTICOLUMN* = 0x00000200
-  LBS_MULTIPLESEL* = 0x00000008
-  LBS_NODATA* = 0x00002000
-  LBS_NOINTEGRALHEIGHT* = 0x00000100
-  LBS_NOREDRAW* = 0x00000004
-  LBS_NOSEL* = 0x00004000
-  LBS_NOTIFY* = 0x00000001
-  LBS_OWNERDRAWFIXED* = 0x00000010
-  LBS_OWNERDRAWVARIABLE* = 0x00000020
-  LBS_SORT* = 0x00000002
-  LBS_STANDARD* = 0x00A00003
-  LBS_USETABSTOPS* = 0x00000080
-  LBS_WANTKEYBOARDINPUT* = 0x00000400
-  SBS_BOTTOMALIGN* = 0x00000004
-  SBS_HORZ* = 0
-  SBS_LEFTALIGN* = 0x00000002
-  SBS_RIGHTALIGN* = 0x00000004
-  SBS_SIZEBOX* = 0x00000008
-  SBS_SIZEBOXBOTTOMRIGHTALIGN* = 0x00000004
-  SBS_SIZEBOXTOPLEFTALIGN* = 0x00000002
-  SBS_SIZEGRIP* = 0x00000010
-  SBS_TOPALIGN* = 0x00000002
-  SBS_VERT* = 0x00000001
-  SS_BITMAP* = 0x0000000E
-  SS_BLACKFRAME* = 0x00000007
-  SS_BLACKRECT* = 0x00000004
-  SS_CENTER* = 0x00000001
-  SS_CENTERIMAGE* = 0x00000200
-  SS_ENHMETAFILE* = 0x0000000F
-  SS_ETCHEDFRAME* = 0x00000012
-  SS_ETCHEDHORZ* = 0x00000010
-  SS_ETCHEDVERT* = 0x00000011
-  SS_GRAYFRAME* = 0x00000008
-  SS_GRAYRECT* = 0x00000005
-  SS_ICON* = 0x00000003
-  SS_LEFT* = 0
-  SS_LEFTNOWORDWRAP* = 0x0000000C
-  SS_NOPREFIX* = 0x00000080
-  SS_NOTIFY* = 0x00000100
-  SS_OWNERDRAW* = 0x0000000D
-  SS_REALSIZEIMAGE* = 0x00000800
-  SS_RIGHT* = 0x00000002
-  SS_RIGHTJUST* = 0x00000400
-  SS_SIMPLE* = 0x0000000B
-  SS_SUNKEN* = 0x00001000
-  SS_USERITEM* = 0x0000000A
-  SS_WHITEFRAME* = 0x00000009
-  SS_WHITERECT* = 0x00000006
-  DS_3DLOOK* = 0x00000004
-  DS_ABSALIGN* = 0x00000001
-  DS_CENTER* = 0x00000800
-  DS_CENTERMOUSE* = 0x00001000
-  DS_CONTEXTHELP* = 0x00002000
-  DS_CONTROL* = 0x00000400
-  DS_FIXEDSYS* = 0x00000008
-  DS_LOCALEDIT* = 0x00000020
-  DS_MODALFRAME* = 0x00000080
-  DS_NOFAILCREATE* = 0x00000010
-  DS_NOIDLEMSG* = 0x00000100
-  DS_SETFONT* = 0x00000040
-  DS_SETFOREGROUND* = 0x00000200
-  DS_SYSMODAL* = 0x00000002   # CreateWindowEx
-  WS_EX_ACCEPTFILES* = 0x00000010
-  WS_EX_APPWINDOW* = 0x00040000
-  WS_EX_CLIENTEDGE* = 0x00000200
-  WS_EX_CONTEXTHELP* = 0x00000400
-  WS_EX_CONTROLPARENT* = 0x00010000
-  WS_EX_DLGMODALFRAME* = 0x00000001
-  WS_EX_LEFT* = 0
-  WS_EX_LEFTSCROLLBAR* = 0x00004000
-  WS_EX_LTRREADING* = 0
-  WS_EX_MDICHILD* = 0x00000040
-  WS_EX_NOPARENTNOTIFY* = 0x00000004
-  WS_EX_OVERLAPPEDWINDOW* = 0x00000300
-  WS_EX_PALETTEWINDOW* = 0x00000188
-  WS_EX_RIGHT* = 0x00001000
-  WS_EX_RIGHTSCROLLBAR* = 0
-  WS_EX_RTLREADING* = 0x00002000
-  WS_EX_STATICEDGE* = 0x00020000
-  WS_EX_TOOLWINDOW* = 0x00000080
-  WS_EX_TOPMOST* = 0x00000008
-  WS_EX_TRANSPARENT* = 0x00000020
-  WS_EX_WINDOWEDGE* = 0x00000100 # CreateWindowStation
-  WINSTA_ACCESSCLIPBOARD* = 0x00000004
-  WINSTA_ACCESSGLOBALATOMS* = 0x00000020
-  WINSTA_CREATEDESKTOP* = 0x00000008
-  WINSTA_ENUMDESKTOPS* = 0x00000001
-  WINSTA_ENUMERATE* = 0x00000100
-  WINSTA_EXITWINDOWS* = 0x00000040
-  WINSTA_READATTRIBUTES* = 0x00000002
-  WINSTA_READSCREEN* = 0x00000200
-  WINSTA_WRITEATTRIBUTES* = 0x00000010 # DdeCallback
-                                       # DdeClientTransaction
-                                       # DdeEnableCallback
-                                       # DdeGetLastError
-                                       # DdeInitialize
-                                       # DdeNameService
-                                       # DebugProc
-  WH_CALLWNDPROC* = 4
-  WH_CALLWNDPROCRET* = 12
-  WH_CBT* = 5
-  WH_DEBUG* = 9
-  WH_GETMESSAGE* = 3
-  WH_JOURNALPLAYBACK* = 1
-  WH_JOURNALRECORD* = 0
-  WH_KEYBOARD* = 2
-  WH_MOUSE* = 7
-  WH_MSGFILTER* = - (1)
-  WH_SHELL* = 10
-  WH_SYSMSGFILTER* = 6        # already defined above !!
-                              #  #define WH_MSGFILTER  (-1)
-  WH_FOREGROUNDIDLE* = 11     # DefineDosDevice
-  DDD_RAW_TARGET_PATH* = 1
-  DDD_REMOVE_DEFINITION* = 2
-  DDD_EXACT_MATCH_ON_REMOVE* = 4 # DeviceCapbilities
-  DC_BINNAMES* = 12
-  DC_BINS* = 6
-  DC_COPIES* = 18
-  DC_DRIVER* = 11
-  DC_DATATYPE_PRODUCED* = 21
-  DC_DUPLEX* = 7
-  DC_EMF_COMPLIANT* = 20
-  DC_ENUMRESOLUTIONS* = 13
-  DC_EXTRA* = 9
-  DC_FIELDS* = 1
-  DC_FILEDEPENDENCIES* = 14
-  DC_MAXEXTENT* = 5
-  DC_MINEXTENT* = 4
-  DC_ORIENTATION* = 17
-  DC_PAPERNAMES* = 16
-  DC_PAPERS* = 2
-  DC_PAPERSIZE* = 3
-  DC_SIZE* = 8
-  DC_TRUETYPE* = 15
-  DCTT_BITMAP* = 0x00000001
-  DCTT_DOWNLOAD* = 0x00000002
-  DCTT_SUBDEV* = 0x00000004
-  DC_VERSION* = 10
-  DC_BINADJUST* = 19          # already defined above !!
-                              #  #define DC_DATATYPE_PRODUCED  (21)
-                              #
-                              # DeviceIoControl
-                              # DlgDirList
-  DDL_ARCHIVE* = 32
-  DDL_DIRECTORY* = 16
-  DDL_DRIVES* = 16384
-  DDL_EXCLUSIVE* = 32768
-  DDL_HIDDEN* = 2
-  DDL_READONLY* = 1
-  DDL_READWRITE* = 0
-  DDL_SYSTEM* = 4
-  DDL_POSTMSGS* = 8192        # DllEntryPoint
-  DLL_PROCESS_ATTACH* = 1
-  DLL_THREAD_ATTACH* = 2
-  DLL_PROCESS_DETACH* = 0
-  DLL_THREAD_DETACH* = 3      # DocumentProperties
-  DM_IN_BUFFER* = 8
-  DM_MODIFY* = 8
-  DM_IN_PROMPT* = 4
-  DM_PROMPT* = 4
-  DM_OUT_BUFFER* = 2
-  DM_COPY* = 2
-  DM_UPDATE* = 1              # DrawAnimatedRects
-  IDANI_OPEN* = 1
-  IDANI_CLOSE* = 2            # DrawCaption
-  DC_ACTIVE* = 1
-  DC_SMALLCAP* = 2            # DrawEdge
-  BDR_RAISEDINNER* = 4
-  BDR_SUNKENINNER* = 8
-  BDR_RAISEDOUTER* = 1
-  BDR_SUNKENOUTER* = 2
-  BDR_OUTER* = BDR_RAISEDOUTER or BDR_SUNKENOUTER
-  BDR_INNER* = BDR_RAISEDINNER or BDR_SUNKENINNER
-  BDR_RAISED* = BDR_RAISEDOUTER or BDR_RAISEDINNER
-  BDR_SUNKEN* = BDR_SUNKENOUTER or BDR_SUNKENINNER
-  EDGE_BUMP* = 9
-  EDGE_ETCHED* = 6
-  EDGE_RAISED* = 5
-  EDGE_SUNKEN* = 10
-  BF_ADJUST* = 8192
-  BF_BOTTOM* = 8
-  BF_BOTTOMLEFT* = 9
-  BF_BOTTOMRIGHT* = 12
-  BF_DIAGONAL* = 16
-  BF_DIAGONAL_ENDBOTTOMLEFT* = 25
-  BF_DIAGONAL_ENDBOTTOMRIGHT* = 28
-  BF_DIAGONAL_ENDTOPLEFT* = 19
-  BF_DIAGONAL_ENDTOPRIGHT* = 22
-  BF_FLAT* = 16384
-  BF_LEFT* = 1
-  BF_MIDDLE* = 2048
-  BF_MONO* = 32768
-  BF_RECT* = 15
-  BF_RIGHT* = 4
-  BF_SOFT* = 4096
-  BF_TOP* = 2
-  BF_TOPLEFT* = 3
-  BF_TOPRIGHT* = 6            # DrawFrameControl
-  DFC_BUTTON* = 4
-  DFC_CAPTION* = 1
-  DFC_MENU* = 2
-  DFC_SCROLL* = 3
-  DFCS_BUTTON3STATE* = 8
-  DFCS_BUTTONCHECK* = 0
-  DFCS_BUTTONPUSH* = 16
-  DFCS_BUTTONRADIO* = 4
-  DFCS_BUTTONRADIOIMAGE* = 1
-  DFCS_BUTTONRADIOMASK* = 2
-  DFCS_CAPTIONCLOSE* = 0
-  DFCS_CAPTIONHELP* = 4
-  DFCS_CAPTIONMAX* = 2
-  DFCS_CAPTIONMIN* = 1
-  DFCS_CAPTIONRESTORE* = 3
-  DFCS_MENUARROW* = 0
-  DFCS_MENUBULLET* = 2
-  DFCS_MENUCHECK* = 1
-  DFCS_SCROLLCOMBOBOX* = 5
-  DFCS_SCROLLDOWN* = 1
-  DFCS_SCROLLLEFT* = 2
-  DFCS_SCROLLRIGHT* = 3
-  DFCS_SCROLLSIZEGRIP* = 8
-  DFCS_SCROLLUP* = 0
-  DFCS_ADJUSTRECT* = 8192
-  DFCS_CHECKED* = 1024
-  DFCS_FLAT* = 16384
-  DFCS_INACTIVE* = 256
-  DFCS_MONO* = 32768
-  DFCS_PUSHED* = 512          # DrawIconEx
-  DI_COMPAT* = 4
-  DI_DEFAULTSIZE* = 8
-  DI_IMAGE* = 2
-  DI_MASK* = 1
-  DI_NORMAL* = 3              # DrawState
-  DST_BITMAP* = 4
-  DST_COMPLEX* = 0
-  DST_ICON* = 3
-  DST_PREFIXTEXT* = 2
-  DST_TEXT* = 1
-  DSS_NORMAL* = 0
-  DSS_UNION* = 16
-  DSS_DISABLED* = 32
-  DSS_MONO* = 128             # DrawStatusText
-  SBT_NOBORDERS* = 256
-  SBT_OWNERDRAW* = 4096
-  SBT_POPOUT* = 512
-  SBT_RTLREADING* = 1024      # DrawText, DrawTextEx
-  DT_BOTTOM* = 8
-  DT_CALCRECT* = 1024
-  DT_CENTER* = 1
-  DT_EDITCONTROL* = 8192
-  DT_END_ELLIPSIS* = 32768
-  DT_PATH_ELLIPSIS* = 16384
-  DT_EXPANDTABS* = 64
-  DT_EXTERNALLEADING* = 512
-  DT_LEFT* = 0
-  DT_MODIFYSTRING* = 65536
-  DT_NOCLIP* = 256
-  DT_NOPREFIX* = 2048
-  DT_RIGHT* = 2
-  DT_RTLREADING* = 131072
-  DT_SINGLELINE* = 32
-  DT_TABSTOP* = 128
-  DT_TOP* = 0
-  DT_VCENTER* = 4
-  DT_WORDBREAK* = 16
-  DT_INTERNAL* = 4096
-  DT_WORD_ELLIPSIS* = 0x00040000
-  DT_HIDEPREFIX* = 0x00100000
-  DT_PREFIXONLY* = 0x00200000 # DuplicateHandle, MapViewOfFile
-  DUPLICATE_CLOSE_SOURCE* = 1
-  DUPLICATE_SAME_ACCESS* = 2
-  FILE_MAP_ALL_ACCESS* = 0x000F001F
-  FILE_MAP_READ* = 4
-  FILE_MAP_WRITE* = 2
-  FILE_MAP_COPY* = 1
-  MUTEX_ALL_ACCESS* = 0x001F0001
-  MUTEX_MODIFY_STATE* = 1
-  SYNCHRONIZE* = 0x00100000
-  SEMAPHORE_ALL_ACCESS* = 0x001F0003
-  SEMAPHORE_MODIFY_STATE* = 2
-  EVENT_ALL_ACCESS* = 0x001F0003
-  EVENT_MODIFY_STATE* = 2
-  KEY_ALL_ACCESS* = 0x000F003F
-  KEY_CREATE_LINK* = 32
-  KEY_CREATE_SUB_KEY* = 4
-  KEY_ENUMERATE_SUB_KEYS* = 8
-  KEY_EXECUTE* = 0x00020019
-  KEY_NOTIFY* = 16
-  KEY_QUERY_VALUE* = 1
-  KEY_READ* = 0x00020019
-  KEY_SET_VALUE* = 2
-  KEY_WRITE* = 0x00020006
-  PROCESS_ALL_ACCESS* = 0x001F0FFF
-  PROCESS_CREATE_PROCESS* = 128
-  PROCESS_CREATE_THREAD* = 2
-  PROCESS_DUP_HANDLE* = 64
-  PROCESS_QUERY_INFORMATION* = 1024
-  PROCESS_SET_INFORMATION* = 512
-  PROCESS_TERMINATE* = 1
-  PROCESS_VM_OPERATION* = 8
-  PROCESS_VM_READ* = 16
-  PROCESS_VM_WRITE* = 32
-  THREAD_ALL_ACCESS* = 0x001F03FF
-  THREAD_DIRECT_IMPERSONATION* = 512
-  THREAD_GET_CONTEXT* = 8
-  THREAD_IMPERSONATE* = 256
-  THREAD_QUERY_INFORMATION* = 64
-  THREAD_SET_CONTEXT* = 16
-  THREAD_SET_INFORMATION* = 32
-  THREAD_SET_THREAD_TOKEN* = 128
-  THREAD_SUSPEND_RESUME* = 2
-  THREAD_TERMINATE* = 1       # EditWordBreakProc
-  WB_ISDELIMITER* = 2
-  WB_LEFT* = 0
-  WB_RIGHT* = 1               # EnableScrollBar
-  SB_BOTH* = 3
-  SB_CTL* = 2
-  SB_HORZ* = 0
-  SB_VERT* = 1
-  ESB_DISABLE_BOTH* = 3
-  ESB_DISABLE_DOWN* = 2
-  ESB_DISABLE_LEFT* = 1
-  ESB_DISABLE_LTUP* = 1
-  ESB_DISABLE_RIGHT* = 2
-  ESB_DISABLE_RTDN* = 2
-  ESB_DISABLE_UP* = 1
-  ESB_ENABLE_BOTH* = 0        # Scroll Bar notifications
-  SB_LINEUP* = 0
-  SB_LINEDOWN* = 1
-  SB_LINELEFT* = 0
-  SB_LINERIGHT* = 1
-  SB_PAGEUP* = 2
-  SB_PAGEDOWN* = 3
-  SB_PAGELEFT* = 2
-  SB_PAGERIGHT* = 3
-  SB_THUMBPOSITION* = 4
-  SB_THUMBTRACK* = 5
-  SB_ENDSCROLL* = 8
-  SB_LEFT* = 6
-  SB_RIGHT* = 7
-  SB_BOTTOM* = 7
-  SB_TOP* = 6                 # EnumCalendarInfo
-  ENUM_ALL_CALENDARS* = - (1) # EnumDateFormats
-  DATE_SHORTDATE* = 1
-  DATE_LONGDATE* = 2          # EnumDependentServices
-  SERVICE_ACTIVE* = 1
-  SERVICE_INACTIVE* = 2       # EnumFontFamExProc
-  DEVICE_FONTTYPE* = 2
-  RASTER_FONTTYPE* = 1
-  TRUETYPE_FONTTYPE* = 4      # EnumObjects, GetCurrentObject, GetObjectType
-  OBJ_BRUSH* = 2
-  OBJ_PEN* = 1
-  OBJ_PAL* = 5
-  OBJ_FONT* = 6
-  OBJ_BITMAP* = 7
-  OBJ_EXTPEN* = 11
-  OBJ_REGION* = 8
-  OBJ_DC* = 3
-  OBJ_MEMDC* = 10
-  OBJ_METAFILE* = 9
-  OBJ_METADC* = 4
-  OBJ_ENHMETAFILE* = 13
-  OBJ_ENHMETADC* = 12         # EnumPrinters
-                              # EnumProtocols
-                              # EnumResLangProc
-                              #
-                              # Predefined Resource Types
-                              #
-
-const
-  RT_CURSOR* = cast[MAKEINTRESOURCE](1)
-  RT_BITMAP* = cast[MAKEINTRESOURCE](2)
-  RT_ICON* = cast[MAKEINTRESOURCE](3)
-  RT_MENU* = cast[MAKEINTRESOURCE](4)
-  RT_DIALOG* = cast[MAKEINTRESOURCE](5)
-  RT_STRING* = cast[MAKEINTRESOURCE](6)
-  RT_FONTDIR* = cast[MAKEINTRESOURCE](7)
-  RT_FONT* = cast[MAKEINTRESOURCE](8)
-  RT_ACCELERATOR* = cast[MAKEINTRESOURCE](9)
-  RT_RCDATA* = cast[MAKEINTRESOURCE](10)
-  RT_MESSAGETABLE* = cast[MAKEINTRESOURCE](11)
-  DIFFERENCE* = 11
-  RT_GROUP_CURSOR* = cast[MAKEINTRESOURCE](12)
-  RT_GROUP_ICON* = cast[MAKEINTRESOURCE](14)
-  RT_VERSION* = cast[MAKEINTRESOURCE](16)
-  RT_DLGINCLUDE* = cast[MAKEINTRESOURCE](17)
-  RT_PLUGPLAY* = cast[MAKEINTRESOURCE](19)
-  RT_VXD* = cast[MAKEINTRESOURCE](20)
-  RT_ANICURSOR* = cast[MAKEINTRESOURCE](21)
-  RT_ANIICON* = cast[MAKEINTRESOURCE](22)
-  RT_HTML* = cast[MAKEINTRESOURCE](23)
-  RT_MANIFEST* = cast[MAKEINTRESOURCE](24) # EnumServicesStatus
-
-const
-  SERVICE_WIN32* = 48
-  SERVICE_DRIVER* = 11        # EnumSystemCodePages
-  CP_INSTALLED* = 1
-  CP_SUPPORTED* = 2           # EnumSystemLocales
-  LCID_INSTALLED* = 1
-  LCID_SUPPORTED* = 2         # EraseTape
-  TAPE_ERASE_LONG* = 0x00000001
-  TAPE_ERASE_SHORT* = 0       # Escape
-  SP_ERROR* = - (1)
-  SP_OUTOFDISK* = - (4)
-  SP_OUTOFMEMORY* = - (5)
-  SP_USERABORT* = - (3)
-  PHYSICALWIDTH* = 110
-  PHYSICALHEIGHT* = 111
-  PHYSICALOFFSETX* = 112
-  PHYSICALOFFSETY* = 113
-  SCALINGFACTORX* = 114
-  SCALINGFACTORY* = 115
-  QUERYESCSUPPORT* = 8        #ABORTDOC = 2; conflicts with AbortDoc function
-  cABORTDOC* = 2              #ENDDOC = 11; conflicts with AbortDoc function
-  cENDDOC* = 11
-  GETPHYSPAGESIZE* = 12
-  GETPRINTINGOFFSET* = 13
-  GETSCALINGFACTOR* = 14
-  NEWFRAME* = 1
-  NEXTBAND* = 3
-  PASSTHROUGH* = 19           #SETABORTPROC = 9; conflicts with AbortDoc function
-  cSETABORTPROC* = 9          #STARTDOC = 10; conflicts with AbortDoc function
-  cSTARTDOC* = 10             # EscapeCommFunction
-  CLRDTR* = 6
-  CLRRTS* = 4
-  SETDTR* = 5
-  SETRTS* = 3
-  SETXOFF* = 1
-  SETXON* = 2
-  SETBREAK* = 8
-  CLRBREAK* = 9               # ExitWindowsEx
-  EWX_FORCE* = 4
-  EWX_LOGOFF* = 0
-  EWX_POWEROFF* = 8
-  EWX_REBOOT* = 2
-  EWX_SHUTDOWN* = 1           # ExtFloodFill
-  FLOODFILLBORDER* = 0
-  FLOODFILLSURFACE* = 1       # ExtTextOut
-  ETO_CLIPPED* = 4
-  ETO_GLYPH_INDEX* = 16
-  ETO_OPAQUE* = 2
-  ETO_RTLREADING* = 128       # FillConsoleOutputAttribute
-  FOREGROUND_BLUE* = 1
-  FOREGROUND_GREEN* = 2
-  FOREGROUND_RED* = 4
-  FOREGROUND_INTENSITY* = 8
-  BACKGROUND_BLUE* = 16
-  BACKGROUND_GREEN* = 32
-  BACKGROUND_RED* = 64
-  BACKGROUND_INTENSITY* = 128 # FindFirstChangeNotification
-  FILE_NOTIFY_CHANGE_FILE_NAME* = 1
-  FILE_NOTIFY_CHANGE_DIR_NAME* = 2
-  FILE_NOTIFY_CHANGE_ATTRIBUTES* = 4
-  FILE_NOTIFY_CHANGE_SIZE* = 8
-  FILE_NOTIFY_CHANGE_LAST_WRITE* = 16
-  FILE_NOTIFY_CHANGE_SECURITY* = 256 # FindFirstPrinterChangeNotification
-                                     # FindNextPrinterNotification
-                                     # FMExtensionProc
-                                     # FoldString
-  MAP_FOLDCZONE* = 16
-  MAP_FOLDDIGITS* = 128
-  MAP_PRECOMPOSED* = 32
-  MAP_COMPOSITE* = 64         # ForegroundIdleProc
-  HC_ACTION* = 0              # FormatMessage
-  FORMAT_MESSAGE_ALLOCATE_BUFFER* = 256
-  FORMAT_MESSAGE_IGNORE_INSERTS* = 512
-  FORMAT_MESSAGE_FROM_STRING* = 1024
-  FORMAT_MESSAGE_FROM_HMODULE* = 2048
-  FORMAT_MESSAGE_FROM_SYSTEM* = 4096
-  FORMAT_MESSAGE_ARGUMENT_ARRAY* = 8192
-  FORMAT_MESSAGE_MAX_WIDTH_MASK* = 255 # GdiComment
-  GDICOMMENT_WINDOWS_METAFILE* = - (2147483647)
-  GDICOMMENT_BEGINGROUP* = 2
-  GDICOMMENT_ENDGROUP* = 3
-  GDICOMMENT_MULTIFORMATS* = 1073741828
-  GDICOMMENT_IDENTIFIER* = 1128875079 # GenerateConsoleCtrlEvent, HandlerRoutine
-  CTRL_C_EVENT* = 0
-  CTRL_BREAK_EVENT* = 1
-  CTRL_CLOSE_EVENT* = 2
-  CTRL_LOGOFF_EVENT* = 5
-  CTRL_SHUTDOWN_EVENT* = 6    # GetAddressByName
-                              # GetArcDirection
-  AD_COUNTERCLOCKWISE* = 1
-  AD_CLOCKWISE* = 2           # GetBinaryTypes
-  SCS_32BIT_BINARY* = 0
-  SCS_DOS_BINARY* = 1
-  SCS_OS216_BINARY* = 5
-  SCS_PIF_BINARY* = 3
-  SCS_POSIX_BINARY* = 4
-  SCS_WOW_BINARY* = 2         # GetBoundsRect, SetBoundsRect
-  DCB_DISABLE* = 8
-  DCB_ENABLE* = 4
-  DCB_RESET* = 1
-  DCB_SET* = 3
-  DCB_ACCUMULATE* = 2         # GetCharacterPlacement, GetFontLanguageInfo
-  GCP_DBCS* = 1
-  GCP_ERROR* = 0x00008000
-  GCP_CLASSIN* = 0x00080000
-  GCP_DIACRITIC* = 256
-  GCP_DISPLAYZWG* = 0x00400000
-  GCP_GLYPHSHAPE* = 16
-  GCP_JUSTIFY* = 0x00010000
-  GCP_JUSTIFYIN* = 0x00200000
-  GCP_KASHIDA* = 1024
-  GCP_LIGATE* = 32
-  GCP_MAXEXTENT* = 0x00100000
-  GCP_NEUTRALOVERRIDE* = 0x02000000
-  GCP_NUMERICOVERRIDE* = 0x01000000
-  GCP_NUMERICSLATIN* = 0x04000000
-  GCP_NUMERICSLOCAL* = 0x08000000
-  GCP_REORDER* = 2
-  GCP_SYMSWAPOFF* = 0x00800000
-  GCP_USEKERNING* = 8
-  FLI_GLYPHS* = 0x00040000
-  FLI_MASK* = 0x0000103B      # GetClassLong, GetClassWord
-  GCW_ATOM* = - (32)
-  GCL_CBCLSEXTRA* = - (20)
-  GCL_CBWNDEXTRA* = - (18)
-  GCL_HBRBACKGROUND* = - (10)
-  GCL_HCURSOR* = - (12)
-  GCL_HICON* = - (14)
-  GCL_HICONSM* = - (34)
-  GCL_HMODULE* = - (16)
-  GCL_MENUNAME* = - (8)
-  GCL_STYLE* = - (26)
-  GCL_WNDPROC* = - (24)       # GetClipboardFormat, SetClipboardData
-  CF_BITMAP* = 2
-  CF_DIB* = 8
-  CF_PALETTE* = 9
-  CF_ENHMETAFILE* = 14
-  CF_METAFILEPICT* = 3
-  CF_OEMTEXT* = 7
-  CF_TEXT* = 1
-  CF_UNICODETEXT* = 13
-  CF_DIF* = 5
-  CF_DSPBITMAP* = 130
-  CF_DSPENHMETAFILE* = 142
-  CF_DSPMETAFILEPICT* = 131
-  CF_DSPTEXT* = 129
-  CF_GDIOBJFIRST* = 768
-  CF_GDIOBJLAST* = 1023
-  CF_HDROP* = 15
-  CF_LOCALE* = 16
-  CF_OWNERDISPLAY* = 128
-  CF_PENDATA* = 10
-  CF_PRIVATEFIRST* = 512
-  CF_PRIVATELAST* = 767
-  CF_RIFF* = 11
-  CF_SYLK* = 4
-  CF_WAVE* = 12
-  CF_TIFF* = 6                # GetCommMask
-  EV_BREAK* = 64
-  EV_CTS* = 8
-  EV_DSR* = 16
-  EV_ERR* = 128
-  EV_EVENT1* = 2048
-  EV_EVENT2* = 4096
-  EV_PERR* = 512
-  EV_RING* = 256
-  EV_RLSD* = 32
-  EV_RX80FULL* = 1024
-  EV_RXCHAR* = 1
-  EV_RXFLAG* = 2
-  EV_TXEMPTY* = 4             # GetCommModemStatus
-  MS_CTS_ON* = 0x00000010
-  MS_DSR_ON* = 0x00000020
-  MS_RING_ON* = 0x00000040
-  MS_RLSD_ON* = 0x00000080    # GetComputerName
-  MAX_COMPUTERNAME_LENGTH* = 15 # GetConsoleMode
-  ENABLE_LINE_INPUT* = 2
-  ENABLE_ECHO_INPUT* = 4
-  ENABLE_PROCESSED_INPUT* = 1
-  ENABLE_WINDOW_INPUT* = 8
-  ENABLE_MOUSE_INPUT* = 16
-  ENABLE_PROCESSED_OUTPUT* = 1
-  ENABLE_WRAP_AT_EOL_OUTPUT* = 2 # GetCPInfo
-  CP_ACP* = 0
-  CP_MACCP* = 2
-  CP_OEMCP* = 1               # GetDateFormat
-                              # already defined above !!
-                              #  #define DATE_SHORTDATE        (1)
-                              #  #define DATE_LONGDATE (2)
-                              #
-  DATE_USE_ALT_CALENDAR* = 4  # GetDCEx
-  DCX_WINDOW* = 0x00000001
-  DCX_CACHE* = 0x00000002
-  DCX_PARENTCLIP* = 0x00000020
-  DCX_CLIPSIBLINGS* = 0x00000010
-  DCX_CLIPCHILDREN* = 0x00000008
-  DCX_NORESETATTRS* = 0x00000004
-  DCX_LOCKWINDOWUPDATE* = 0x00000400
-  DCX_EXCLUDERGN* = 0x00000040
-  DCX_INTERSECTRGN* = 0x00000080
-  DCX_VALIDATE* = 0x00200000  # GetDeviceCaps
-  DRIVERVERSION* = 0
-  TECHNOLOGY* = 2
-  DT_PLOTTER* = 0
-  DT_RASDISPLAY* = 1
-  DT_RASPRINTER* = 2
-  DT_RASCAMERA* = 3
-  DT_CHARSTREAM* = 4
-  DT_METAFILE* = 5
-  DT_DISPFILE* = 6
-  HORZSIZE* = 4
-  VERTSIZE* = 6
-  HORZRES* = 8
-  VERTRES* = 10
-  LOGPIXELSX* = 88
-  LOGPIXELSY* = 90
-  BITSPIXEL* = 12
-  PLANES* = 14
-  NUMBRUSHES* = 16
-  NUMPENS* = 18
-  NUMFONTS* = 22
-  NUMCOLORS* = 24
-  ASPECTX* = 40
-  ASPECTY* = 42
-  ASPECTXY* = 44
-  PDEVICESIZE* = 26
-  CLIPCAPS* = 36
-  SIZEPALETTE* = 104
-  NUMRESERVED* = 106
-  COLORRES* = 108             # already defined above !!
-                              #  #define PHYSICALWIDTH (110)
-                              #  #define PHYSICALHEIGHT        (111)
-                              #  #define PHYSICALOFFSETX       (112)
-                              #  #define PHYSICALOFFSETY       (113)
-                              #  #define SCALINGFACTORX        (114)
-                              #  #define SCALINGFACTORY        (115)
-                              #
-  VREFRESH* = 116
-  DESKTOPHORZRES* = 118
-  DESKTOPVERTRES* = 117
-  BLTALIGNMENT* = 119
-  RASTERCAPS* = 38
-  RC_BANDING* = 2
-  RC_BITBLT* = 1
-  RC_BITMAP64* = 8
-  RC_DI_BITMAP* = 128
-  RC_DIBTODEV* = 512
-  RC_FLOODFILL* = 4096
-  RC_GDI20_OUTPUT* = 16
-  RC_PALETTE* = 256
-  RC_SCALING* = 4
-  RC_STRETCHBLT* = 2048
-  RC_STRETCHDIB* = 8192
-  CURVECAPS* = 28
-  CC_NONE* = 0
-  CC_CIRCLES* = 1
-  CC_PIE* = 2
-  CC_CHORD* = 4
-  CC_ELLIPSES* = 8
-  CC_WIDE* = 16
-  CC_STYLED* = 32
-  CC_WIDESTYLED* = 64
-  CC_INTERIORS* = 128
-  CC_ROUNDRECT* = 256
-  LINECAPS* = 30
-  LC_NONE* = 0
-  LC_POLYLINE* = 2
-  LC_MARKER* = 4
-  LC_POLYMARKER* = 8
-  LC_WIDE* = 16
-  LC_STYLED* = 32
-  LC_WIDESTYLED* = 64
-  LC_INTERIORS* = 128
-  POLYGONALCAPS* = 32
-  PC_NONE* = 0
-  PC_POLYGON* = 1
-  PC_RECTANGLE* = 2
-  PC_WINDPOLYGON* = 4
-  PC_SCANLINE* = 8
-  PC_WIDE* = 16
-  PC_STYLED* = 32
-  PC_WIDESTYLED* = 64
-  PC_INTERIORS* = 128
-  TEXTCAPS* = 34
-  TC_OP_CHARACTER* = 1
-  TC_OP_STROKE* = 2
-  TC_CP_STROKE* = 4
-  TC_CR_90* = 8
-  TC_CR_ANY* = 16
-  TC_SF_X_YINDEP* = 32
-  TC_SA_DOUBLE* = 64
-  TC_SA_INTEGER* = 128
-  TC_SA_CONTIN* = 256
-  TC_EA_DOUBLE* = 512
-  TC_IA_ABLE* = 1024
-  TC_UA_ABLE* = 2048
-  TC_SO_ABLE* = 4096
-  TC_RA_ABLE* = 8192
-  TC_VA_ABLE* = 16384
-  TC_RESERVED* = 32768
-  TC_SCROLLBLT* = 65536
-  PC_PATHS* = 512             # GetDriveType
-  DRIVE_REMOVABLE* = 2
-  DRIVE_FIXED* = 3
-  DRIVE_REMOTE* = 4
-  DRIVE_CDROM* = 5
-  DRIVE_RAMDISK* = 6
-  DRIVE_UNKNOWN* = 0
-  DRIVE_NO_ROOT_DIR* = 1      # GetExceptionCode
-  EXCEPTION_ACCESS_VIOLATION* = 0xC0000005
-  EXCEPTION_BREAKPOINT* = 0x80000003
-  EXCEPTION_DATATYPE_MISALIGNMENT* = 0x80000002
-  EXCEPTION_SINGLE_STEP* = 0x80000004
-  EXCEPTION_ARRAY_BOUNDS_EXCEEDED* = 0xC000008C
-  EXCEPTION_FLT_DENORMAL_OPERAND* = 0xC000008D
-  EXCEPTION_FLT_DIVIDE_BY_ZERO* = 0xC000008E
-  EXCEPTION_FLT_INEXACT_RESULT* = 0xC000008F
-  EXCEPTION_FLT_INVALID_OPERATION* = 0xC0000090
-  EXCEPTION_FLT_OVERFLOW* = 0xC0000091
-  EXCEPTION_FLT_STACK_CHECK* = 0xC0000092
-  EXCEPTION_FLT_UNDERFLOW* = 0xC0000093
-  EXCEPTION_INT_DIVIDE_BY_ZERO* = 0xC0000094
-  EXCEPTION_INT_OVERFLOW* = 0xC0000095
-  EXCEPTION_INVALID_HANDLE* = 0xC0000008
-  EXCEPTION_PRIV_INSTRUCTION* = 0xC0000096
-  EXCEPTION_NONCONTINUABLE_EXCEPTION* = 0xC0000025
-  EXCEPTION_NONCONTINUABLE* = 0x00000001
-  EXCEPTION_STACK_OVERFLOW* = 0xC00000FD
-  EXCEPTION_INVALID_DISPOSITION* = 0xC0000026
-  EXCEPTION_IN_PAGE_ERROR* = 0xC0000006
-  EXCEPTION_ILLEGAL_INSTRUCTION* = 0xC000001D
-  EXCEPTION_POSSIBLE_DEADLOCK* = 0xC0000194 # GetFileType
-  FILE_TYPE_UNKNOWN* = 0
-  FILE_TYPE_DISK* = 1
-  FILE_TYPE_CHAR* = 2
-  FILE_TYPE_PIPE* = 3         # GetGlyphOutline
-  GGO_BITMAP* = 1
-  GGO_NATIVE* = 2
-  GGO_METRICS* = 0
-  GGO_GRAY2_BITMAP* = 4
-  GGO_GRAY4_BITMAP* = 5
-  GGO_GRAY8_BITMAP* = 6
-  GDI_ERROR* = 0xFFFFFFFF     # GetGraphicsMode
-  GM_COMPATIBLE* = 1
-  GM_ADVANCED* = 2            # GetHandleInformation
-  HANDLE_FLAG_INHERIT* = 1
-  HANDLE_FLAG_PROTECT_FROM_CLOSE* = 2 # GetIconInfo
-                                      # was #define dname def_expr
-
-proc IDC_ARROW*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_IBEAM*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_WAIT*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_CROSS*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_UPARROW*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZENWSE*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZENESW*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZEWE*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZENS*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZEALL*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_NO*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_APPSTARTING*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_HELP*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_APPLICATION*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_HAND*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_QUESTION*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_EXCLAMATION*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_ASTERISK*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDI_WINLOGO*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_SIZE*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_ICON*(): LPTSTR
-  # return type might be wrong
-  # was #define dname def_expr
-proc IDC_HAND*(): LPTSTR
-  # return type might be wrong
-  # GetMapMode
-const
-  MM_ANISOTROPIC* = 8
-  MM_HIENGLISH* = 5
-  MM_HIMETRIC* = 3
-  MM_ISOTROPIC* = 7
-  MM_LOENGLISH* = 4
-  MM_LOMETRIC* = 2
-  MM_TEXT* = 1
-  MM_TWIPS* = 6               # GetMenuDefaultItem
-  GMDI_GOINTOPOPUPS* = 0x00000002
-  GMDI_USEDISABLED* = 0x00000001 # PeekMessage
-  PM_NOREMOVE* = 0
-  PM_REMOVE* = 1
-  PM_NOYIELD* = 2             # GetNamedPipeHandleState
-                              #   PIPE_NOWAIT = 1; already above
-                              #   PIPE_READMODE_MESSAGE = 2;already above
-                              # GetNamedPipeInfo
-  PIPE_CLIENT_END* = 0
-  PIPE_SERVER_END* = 1        #   PIPE_TYPE_MESSAGE = 4;already above
-                              # GetNextWindow, GetWindow
-  GW_HWNDNEXT* = 2
-  GW_HWNDPREV* = 3
-  GW_CHILD* = 5
-  GW_HWNDFIRST* = 0
-  GW_HWNDLAST* = 1
-  GW_OWNER* = 4               # GetPath
-  PT_MOVETO* = 6
-  PT_LINETO* = 2
-  PT_BEZIERTO* = 4
-  PT_CLOSEFIGURE* = 1         # GetProcessShutdownParameters
-  SHUTDOWN_NORETRY* = 1       # GetQueueStatus
-  QS_ALLEVENTS* = 191
-  QS_ALLINPUT* = 255
-  QS_HOTKEY* = 128
-  QS_INPUT* = 7
-  QS_KEY* = 1
-  QS_MOUSE* = 6
-  QS_MOUSEBUTTON* = 4
-  QS_MOUSEMOVE* = 2
-  QS_PAINT* = 32
-  QS_POSTMESSAGE* = 8
-  QS_SENDMESSAGE* = 64
-  QS_TIMER* = 16              # GetScrollInfo, SetScrollInfo
-  SIF_ALL* = 23
-  SIF_PAGE* = 2
-  SIF_POS* = 4
-  SIF_RANGE* = 1
-  SIF_DISABLENOSCROLL* = 8    # GetStdHandle
-                              # was #define dname def_expr
-
-proc STD_INPUT_HANDLE*(): DWORD
-  # was #define dname def_expr
-proc STD_OUTPUT_HANDLE*(): DWORD
-  # was #define dname def_expr
-proc STD_ERROR_HANDLE*(): DWORD
-  # was #define dname def_expr
-const
-  INVALID_HANDLE_VALUE* = HANDLE(- 1) # GetStockObject
-
-const
-  BLACK_BRUSH* = 4
-  DKGRAY_BRUSH* = 3
-  GRAY_BRUSH* = 2
-  HOLLOW_BRUSH* = 5
-  LTGRAY_BRUSH* = 1
-  NULL_BRUSH* = 5
-  WHITE_BRUSH* = 0
-  BLACK_PEN* = 7
-  NULL_PEN* = 8
-  WHITE_PEN* = 6
-  ANSI_FIXED_FONT* = 11
-  ANSI_VAR_FONT* = 12
-  DEVICE_DEFAULT_FONT* = 14
-  DEFAULT_GUI_FONT* = 17
-  OEM_FIXED_FONT* = 10
-  SYSTEM_FONT* = 13
-  SYSTEM_FIXED_FONT* = 16
-  DEFAULT_PALETTE* = 15       # GetStringTypeA
-  CT_CTYPE1* = 1
-  CT_CTYPE2* = 2
-  CT_CTYPE3* = 4
-  C1_UPPER* = 1
-  C1_LOWER* = 2
-  C1_DIGIT* = 4
-  C1_SPACE* = 8
-  C1_PUNCT* = 16
-  C1_CNTRL* = 32
-  C1_BLANK* = 64
-  C1_XDIGIT* = 128
-  C1_ALPHA* = 256
-  C2_LEFTTORIGHT* = 1
-  C2_RIGHTTOLEFT* = 2
-  C2_EUROPENUMBER* = 3
-  C2_EUROPESEPARATOR* = 4
-  C2_EUROPETERMINATOR* = 5
-  C2_ARABICNUMBER* = 6
-  C2_COMMONSEPARATOR* = 7
-  C2_BLOCKSEPARATOR* = 8
-  C2_SEGMENTSEPARATOR* = 9
-  C2_WHITESPACE* = 10
-  C2_OTHERNEUTRAL* = 11
-  C2_NOTAPPLICABLE* = 0
-  C3_NONSPACING* = 1
-  C3_DIACRITIC* = 2
-  C3_VOWELMARK* = 4
-  C3_SYMBOL* = 8
-  C3_KATAKANA* = 16
-  C3_HIRAGANA* = 32
-  C3_HALFWIDTH* = 64
-  C3_FULLWIDTH* = 128
-  C3_IDEOGRAPH* = 256
-  C3_KASHIDA* = 512
-  C3_ALPHA* = 32768
-  C3_NOTAPPLICABLE* = 0       # GetSysColor
-  COLOR_3DDKSHADOW* = 21
-  COLOR_3DFACE* = 15
-  COLOR_3DHILIGHT* = 20
-  COLOR_3DLIGHT* = 22
-  COLOR_BTNHILIGHT* = 20
-  COLOR_3DSHADOW* = 16
-  COLOR_ACTIVEBORDER* = 10
-  COLOR_ACTIVECAPTION* = 2
-  COLOR_APPWORKSPACE* = 12
-  COLOR_BACKGROUND* = 1
-  COLOR_DESKTOP* = 1
-  COLOR_BTNFACE* = 15
-  COLOR_BTNHIGHLIGHT* = 20
-  COLOR_BTNSHADOW* = 16
-  COLOR_BTNTEXT* = 18
-  COLOR_CAPTIONTEXT* = 9
-  COLOR_GRAYTEXT* = 17
-  COLOR_HIGHLIGHT* = 13
-  COLOR_HIGHLIGHTTEXT* = 14
-  COLOR_INACTIVEBORDER* = 11
-  COLOR_INACTIVECAPTION* = 3
-  COLOR_INACTIVECAPTIONTEXT* = 19
-  COLOR_INFOBK* = 24
-  COLOR_INFOTEXT* = 23
-  COLOR_MENU* = 4
-  COLOR_MENUTEXT* = 7
-  COLOR_SCROLLBAR* = 0
-  COLOR_WINDOW* = 5
-  COLOR_WINDOWFRAME* = 6
-  COLOR_WINDOWTEXT* = 8       # GetSystemMetrics
-  SM_CYMIN* = 29
-  SM_CXMIN* = 28
-  SM_ARRANGE* = 56
-  SM_CLEANBOOT* = 67 # The right value for SM_CEMETRICS for NT 3.5 is 75.  For Windows 95
-                     #     and NT 4.0, it is 76.  The meaning is undocumented, anyhow.
-  SM_CMETRICS* = 76
-  SM_CMOUSEBUTTONS* = 43
-  SM_CXBORDER* = 5
-  SM_CYBORDER* = 6
-  SM_CXCURSOR* = 13
-  SM_CYCURSOR* = 14
-  SM_CXDLGFRAME* = 7
-  SM_CYDLGFRAME* = 8
-  SM_CXDOUBLECLK* = 36
-  SM_CYDOUBLECLK* = 37
-  SM_CXDRAG* = 68
-  SM_CYDRAG* = 69
-  SM_CXEDGE* = 45
-  SM_CYEDGE* = 46
-  SM_CXFIXEDFRAME* = 7
-  SM_CYFIXEDFRAME* = 8
-  SM_CXFRAME* = 32
-  SM_CYFRAME* = 33
-  SM_CXFULLSCREEN* = 16
-  SM_CYFULLSCREEN* = 17
-  SM_CXHSCROLL* = 21
-  SM_CYHSCROLL* = 3
-  SM_CXHTHUMB* = 10
-  SM_CXICON* = 11
-  SM_CYICON* = 12
-  SM_CXICONSPACING* = 38
-  SM_CYICONSPACING* = 39
-  SM_CXMAXIMIZED* = 61
-  SM_CYMAXIMIZED* = 62
-  SM_CXMAXTRACK* = 59
-  SM_CYMAXTRACK* = 60
-  SM_CXMENUCHECK* = 71
-  SM_CYMENUCHECK* = 72
-  SM_CXMENUSIZE* = 54
-  SM_CYMENUSIZE* = 55
-  SM_CXMINIMIZED* = 57
-  SM_CYMINIMIZED* = 58
-  SM_CXMINSPACING* = 47
-  SM_CYMINSPACING* = 48
-  SM_CXMINTRACK* = 34
-  SM_CYMINTRACK* = 35
-  SM_CXSCREEN* = 0
-  SM_CYSCREEN* = 1
-  SM_CXSIZE* = 30
-  SM_CYSIZE* = 31
-  SM_CXSIZEFRAME* = 32
-  SM_CYSIZEFRAME* = 33
-  SM_CXSMICON* = 49
-  SM_CYSMICON* = 50
-  SM_CXSMSIZE* = 52
-  SM_CYSMSIZE* = 53
-  SM_CXVSCROLL* = 2           #SM_CYHSCROLL = 3;already above
-                              #SM_CXHSCROLL = 21;already above
-  SM_CYVSCROLL* = 20
-  SM_CYVTHUMB* = 9
-  SM_CYCAPTION* = 4
-  SM_CYKANJIWINDOW* = 18
-  SM_CYMENU* = 15
-  SM_CYSMCAPTION* = 51
-  SM_DBCSENABLED* = 42
-  SM_DEBUG* = 22
-  SM_MENUDROPALIGNMENT* = 40
-  SM_MIDEASTENABLED* = 74
-  SM_MOUSEPRESENT* = 19
-  SM_MOUSEWHEELPRESENT* = 75
-  SM_NETWORK* = 63
-  SM_PENWINDOWS* = 41
-  SM_SECURE* = 44
-  SM_SHOWSOUNDS* = 70
-  SM_SLOWMACHINE* = 73
-  SM_SWAPBUTTON* = 23
-  ARW_BOTTOMLEFT* = 0
-  ARW_BOTTOMRIGHT* = 0x00000001
-  ARW_HIDE* = 0x00000008
-  ARW_TOPLEFT* = 0x00000002
-  ARW_TOPRIGHT* = 0x00000003
-  ARW_DOWN* = 0x00000004
-  ARW_LEFT* = 0
-  ARW_RIGHT* = 0
-  ARW_UP* = 0x00000004        # GetSystemPaletteUse
-  SYSPAL_NOSTATIC* = 2
-  SYSPAL_STATIC* = 1
-  SYSPAL_ERROR* = 0           # GetTapeParameters, SetTapeParameters
-  GET_TAPE_MEDIA_INFORMATION* = 0
-  GET_TAPE_DRIVE_INFORMATION* = 1
-  SET_TAPE_MEDIA_INFORMATION* = 0
-  SET_TAPE_DRIVE_INFORMATION* = 1 # GetTapePosition
-  TAPE_ABSOLUTE_POSITION* = 0
-  TAPE_LOGICAL_POSITION* = 0x00000001 # GetTextAlign
-  TA_BASELINE* = 24
-  TA_BOTTOM* = 8
-  TA_TOP* = 0
-  TA_CENTER* = 6
-  TA_LEFT* = 0
-  TA_RIGHT* = 2
-  TA_RTLREADING* = 256
-  TA_NOUPDATECP* = 0
-  TA_UPDATECP* = 1
-  VTA_BASELINE* = 24
-  VTA_CENTER* = 6             # GetThreadPriority
-  THREAD_PRIORITY_ABOVE_NORMAL* = 1
-  THREAD_PRIORITY_BELOW_NORMAL* = - (1)
-  THREAD_PRIORITY_HIGHEST* = 2
-  THREAD_PRIORITY_IDLE* = - (15)
-  THREAD_PRIORITY_LOWEST* = - (2)
-  THREAD_PRIORITY_NORMAL* = 0
-  THREAD_PRIORITY_TIME_CRITICAL* = 15
-  THREAD_PRIORITY_ERROR_RETURN* = 2147483647
-  TLS_MINIMUM_AVAILABLE* = 64 # GetTimeFormat
-  TIME_NOMINUTESORSECONDS* = 1
-  TIME_NOSECONDS* = 2
-  TIME_NOTIMEMARKER* = 4
-  TIME_FORCE24HOURFORMAT* = 8 # GetTimeZoneInformation
-                              # was #define dname def_expr
-
-const
-  TIME_ZONE_ID_INVALID* = DWORD(- 1)
-  TIME_ZONE_ID_UNKNOWN* = 0
-  TIME_ZONE_ID_STANDARD* = 1
-  TIME_ZONE_ID_DAYLIGHT* = 2  # GetUserObjectInformation
-  UOI_FLAGS* = 1
-  UOI_NAME* = 2
-  UOI_TYPE* = 3               # GetVolumeInformation
-  FS_CASE_IS_PRESERVED* = 2
-  FS_CASE_SENSITIVE* = 1
-  FS_UNICODE_STORED_ON_DISK* = 4
-  FS_PERSISTENT_ACLS* = 8
-  FS_FILE_COMPRESSION* = 16
-  FS_VOL_IS_COMPRESSED* = 32768 # GetWindowLong
-  GWL_EXSTYLE* = - (20)
-  GWL_STYLE* = - (16)
-  GWL_WNDPROC* = - (4)
-  GWL_HINSTANCE* = - (6)
-  GWL_HWNDPARENT* = - (8)
-  GWL_ID* = - (12)
-  GWL_USERDATA* = - (21)
-  DWL_DLGPROC* = 4
-  DWL_MSGRESULT* = 0
-  DWL_USER* = 8               # GlobalAlloc, GlobalFlags
-  GMEM_FIXED* = 0
-  GMEM_MOVEABLE* = 2
-  GPTR* = 64
-  GHND* = 66
-  GMEM_DDESHARE* = 8192
-  GMEM_DISCARDABLE* = 256
-  GMEM_LOWER* = 4096
-  GMEM_NOCOMPACT* = 16
-  GMEM_NODISCARD* = 32
-  GMEM_NOT_BANKED* = 4096
-  GMEM_NOTIFY* = 16384
-  GMEM_SHARE* = 8192
-  GMEM_ZEROINIT* = 64
-  GMEM_DISCARDED* = 16384
-  GMEM_INVALID_HANDLE* = 32768
-  GMEM_LOCKCOUNT* = 255       # HeapAlloc, HeapReAlloc
-  HEAP_GENERATE_EXCEPTIONS* = 4
-  HEAP_NO_SERIALIZE* = 1
-  HEAP_ZERO_MEMORY* = 8
-  STATUS_NO_MEMORY* = 0xC0000017
-  STATUS_ACCESS_VIOLATION* = 0xC0000005
-  HEAP_REALLOC_IN_PLACE_ONLY* = 16 # ImageList_Create
-  ILC_COLOR* = 0
-  ILC_COLOR4* = 4
-  ILC_COLOR8* = 8
-  ILC_COLOR16* = 16
-  ILC_COLOR24* = 24
-  ILC_COLOR32* = 32
-  ILC_COLORDDB* = 254
-  ILC_MASK* = 1
-  ILC_PALETTE* = 2048         # ImageList_Draw, ImageList_DrawEx
-  ILD_BLEND25* = 2
-  ILD_BLEND50* = 4
-  ILD_SELECTED* = 4
-  ILD_BLEND* = 4
-  ILD_FOCUS* = 2
-  ILD_MASK* = 16
-  ILD_NORMAL* = 0
-  ILD_TRANSPARENT* = 1
-  CLR_NONE* = 0xFFFFFFFF
-  CLR_DEFAULT* = 0xFF000000
-  CLR_INVALID* = 0xFFFFFFFF   # ImageList_LoadImage
-                              #LR_DEFAULTCOLOR = 0;already above
-  LR_LOADFROMFILE* = 16
-  LR_LOADMAP3DCOLORS* = 4096
-  LR_LOADTRANSPARENT* = 32    # ImmConfigureIME
-  IME_CONFIG_GENERAL* = 1
-  IME_CONFIG_REGISTERWORD* = 2
-  IME_CONFIG_SELECTDICTIONARY* = 3 # ImmGetConversionList
-  GCL_CONVERSION* = 1
-  GCL_REVERSECONVERSION* = 2
-  GCL_REVERSE_LENGTH* = 3     # ImmGetGuideLine
-  GGL_LEVEL* = 1
-  GGL_INDEX* = 2
-  GGL_STRING* = 3
-  GGL_PRIVATE* = 4
-  GL_LEVEL_ERROR* = 2
-  GL_LEVEL_FATAL* = 1
-  GL_LEVEL_INFORMATION* = 4
-  GL_LEVEL_NOGUIDELINE* = 0
-  GL_LEVEL_WARNING* = 3
-  GL_ID_CANNOTSAVE* = 17
-  GL_ID_NOCONVERT* = 32
-  GL_ID_NODICTIONARY* = 16
-  GL_ID_NOMODULE* = 1
-  GL_ID_READINGCONFLICT* = 35
-  GL_ID_TOOMANYSTROKE* = 34
-  GL_ID_TYPINGERROR* = 33
-  GL_ID_UNKNOWN* = 0
-  GL_ID_INPUTREADING* = 36
-  GL_ID_INPUTRADICAL* = 37
-  GL_ID_INPUTCODE* = 38
-  GL_ID_CHOOSECANDIDATE* = 40
-  GL_ID_REVERSECONVERSION* = 41 # ImmGetProperty
-  IGP_PROPERTY* = 4
-  IGP_CONVERSION* = 8
-  IGP_SENTENCE* = 12
-  IGP_UI* = 16
-  IGP_SETCOMPSTR* = 20
-  IGP_SELECT* = 24
-  IME_PROP_AT_CARET* = 65536
-  IME_PROP_SPECIAL_UI* = 131072
-  IME_PROP_CANDLIST_START_FROM_1* = 262144
-  IME_PROP_UNICODE* = 524288
-  UI_CAP_2700* = 1
-  UI_CAP_ROT90* = 2
-  UI_CAP_ROTANY* = 4
-  SCS_CAP_COMPSTR* = 1
-  SCS_CAP_MAKEREAD* = 2
-  SELECT_CAP_CONVERSION* = 1
-  SELECT_CAP_SENTENCE* = 2    # ImmNotifyIME
-  NI_CHANGECANDIDATELIST* = 19
-  NI_CLOSECANDIDATE* = 17
-  NI_COMPOSITIONSTR* = 21
-  NI_OPENCANDIDATE* = 16
-  NI_SELECTCANDIDATESTR* = 18
-  NI_SETCANDIDATE_PAGESIZE* = 23
-  NI_SETCANDIDATE_PAGESTART* = 22
-  CPS_CANCEL* = 4
-  CPS_COMPLETE* = 1
-  CPS_CONVERT* = 2
-  CPS_REVERT* = 3             # ImmSetCompositionString
-  SCS_SETSTR* = 9
-  SCS_CHANGEATTR* = 18
-  SCS_CHANGECLAUSE* = 36      # ImmUnregisterWord
-  IME_REGWORD_STYLE_EUDC* = 1
-  IME_REGWORD_STYLE_USER_FIRST* = 0x80000000
-  IME_REGWORD_STYLE_USER_LAST* = - (1) # InitializeSecurityDescriptor
-  SECURITY_DESCRIPTOR_REVISION* = 1 # IsTextUnicode
-  IS_TEXT_UNICODE_ASCII16* = 1
-  IS_TEXT_UNICODE_REVERSE_ASCII16* = 16
-  IS_TEXT_UNICODE_STATISTICS* = 2
-  IS_TEXT_UNICODE_REVERSE_STATISTICS* = 32
-  IS_TEXT_UNICODE_CONTROLS* = 4
-  IS_TEXT_UNICODE_REVERSE_CONTROLS* = 64
-  IS_TEXT_UNICODE_SIGNATURE* = 8
-  IS_TEXT_UNICODE_REVERSE_SIGNATURE* = 128
-  IS_TEXT_UNICODE_ILLEGAL_CHARS* = 256
-  IS_TEXT_UNICODE_ODD_LENGTH* = 512
-  IS_TEXT_UNICODE_NULL_BYTES* = 4096
-  IS_TEXT_UNICODE_UNICODE_MASK* = 15
-  IS_TEXT_UNICODE_REVERSE_MASK* = 240
-  IS_TEXT_UNICODE_NOT_UNICODE_MASK* = 3840
-  IS_TEXT_UNICODE_NOT_ASCII_MASK* = 61440 # JournalPlaybackProc, KeyboardProc
-  HC_GETNEXT* = 1
-  HC_SKIP* = 2
-  HC_SYSMODALOFF* = 5
-  HC_SYSMODALON* = 4
-  HC_NOREMOVE* = 3            # keybd_event
-  KEYEVENTF_EXTENDEDKEY* = 1
-  KEYEVENTF_KEYUP* = 2        # LoadBitmap
-  OBM_BTNCORNERS* = 32758
-  OBM_BTSIZE* = 32761
-  OBM_CHECK* = 32760
-  OBM_CHECKBOXES* = 32759
-  OBM_CLOSE* = 32754
-  OBM_COMBO* = 32738
-  OBM_DNARROW* = 32752
-  OBM_DNARROWD* = 32742
-  OBM_DNARROWI* = 32736
-  OBM_LFARROW* = 32750
-  OBM_LFARROWI* = 32734
-  OBM_LFARROWD* = 32740
-  OBM_MNARROW* = 32739
-  OBM_OLD_CLOSE* = 32767
-  OBM_OLD_DNARROW* = 32764
-  OBM_OLD_LFARROW* = 32762
-  OBM_OLD_REDUCE* = 32757
-  OBM_OLD_RESTORE* = 32755
-  OBM_OLD_RGARROW* = 32763
-  OBM_OLD_UPARROW* = 32765
-  OBM_OLD_ZOOM* = 32756
-  OBM_REDUCE* = 32749
-  OBM_REDUCED* = 32746
-  OBM_RESTORE* = 32747
-  OBM_RESTORED* = 32744
-  OBM_RGARROW* = 32751
-  OBM_RGARROWD* = 32741
-  OBM_RGARROWI* = 32735
-  OBM_SIZE* = 32766
-  OBM_UPARROW* = 32753
-  OBM_UPARROWD* = 32743
-  OBM_UPARROWI* = 32737
-  OBM_ZOOM* = 32748
-  OBM_ZOOMD* = 32745          # LoadLibraryEx
-  DONT_RESOLVE_DLL_REFERENCES* = 1
-  LOAD_LIBRARY_AS_DATAFILE* = 2
-  LOAD_WITH_ALTERED_SEARCH_PATH* = 8 # LocalAlloc, LocalFlags
-  LPTR* = 64
-  LHND* = 66
-  NONZEROLHND* = 2
-  NONZEROLPTR* = 0
-  LMEM_NONZEROLHND* = 2
-  LMEM_NONZEROLPTR* = 0
-  LMEM_FIXED* = 0
-  LMEM_MOVEABLE* = 2
-  LMEM_NOCOMPACT* = 16
-  LMEM_NODISCARD* = 32
-  LMEM_ZEROINIT* = 64
-  LMEM_MODIFY* = 128
-  LMEM_LOCKCOUNT* = 255
-  LMEM_DISCARDABLE* = 3840
-  LMEM_DISCARDED* = 16384
-  LMEM_INVALID_HANDLE* = 32768 # LockFileEx
-  LOCKFILE_FAIL_IMMEDIATELY* = 1
-  LOCKFILE_EXCLUSIVE_LOCK* = 2 # LogonUser
-                               # LZCopy, LZInit, LZRead
-                               # MessageBeep, MessageBox
-  MB_USERICON* = 0x00000080
-  MB_ICONASTERISK* = 0x00000040
-  MB_ICONEXCLAMATION* = 0x00000030
-  MB_ICONWARNING* = 0x00000030
-  MB_ICONERROR* = 0x00000010
-  MB_ICONHAND* = 0x00000010
-  MB_ICONQUESTION* = 0x00000020
-  MB_OK* = 0
-  MB_ABORTRETRYIGNORE* = 0x00000002
-  MB_APPLMODAL* = 0
-  MB_DEFAULT_DESKTOP_ONLY* = 0x00020000
-  MB_HELP* = 0x00004000
-  MB_RIGHT* = 0x00080000
-  MB_RTLREADING* = 0x00100000
-  MB_TOPMOST* = 0x00040000
-  MB_DEFBUTTON1* = 0
-  MB_DEFBUTTON2* = 0x00000100
-  MB_DEFBUTTON3* = 0x00000200
-  MB_DEFBUTTON4* = 0x00000300
-  MB_ICONINFORMATION* = 0x00000040
-  MB_ICONSTOP* = 0x00000010
-  MB_OKCANCEL* = 0x00000001
-  MB_RETRYCANCEL* = 0x00000005
-  MB_SERVICE_NOTIFICATION* = 0x00040000
-  MB_SETFOREGROUND* = 0x00010000
-  MB_SYSTEMMODAL* = 0x00001000
-  MB_TASKMODAL* = 0x00002000
-  MB_YESNO* = 0x00000004
-  MB_YESNOCANCEL* = 0x00000003
-  IDABORT* = 3
-  IDCANCEL* = 2
-  IDCLOSE* = 8
-  IDHELP* = 9
-  IDIGNORE* = 5
-  IDNO* = 7
-  IDOK* = 1
-  IDRETRY* = 4
-  IDYES* = 6                  # MessageProc
-  MSGF_DIALOGBOX* = 0
-  MSGF_MENU* = 2
-  MSGF_NEXTWINDOW* = 6
-  MSGF_SCROLLBAR* = 5
-  MSGF_MAINLOOP* = 8
-  MSGF_USER* = 4096           # ModifyWorldTransform
-  MWT_IDENTITY* = 1
-  MWT_LEFTMULTIPLY* = 2
-  MWT_RIGHTMULTIPLY* = 3      # mouse_event
-  MOUSEEVENTF_ABSOLUTE* = 32768
-  MOUSEEVENTF_MOVE* = 1
-  MOUSEEVENTF_LEFTDOWN* = 2
-  MOUSEEVENTF_LEFTUP* = 4
-  MOUSEEVENTF_RIGHTDOWN* = 8
-  MOUSEEVENTF_RIGHTUP* = 16
-  MOUSEEVENTF_MIDDLEDOWN* = 32
-  MOUSEEVENTF_MIDDLEUP* = 64  # MoveFileEx
-  MOVEFILE_REPLACE_EXISTING* = 1
-  MOVEFILE_COPY_ALLOWED* = 2
-  MOVEFILE_DELAY_UNTIL_REBOOT* = 4 # MsgWaitForMultipleObjects, WaitForMultipleObjectsEx
-  WAIT_OBJECT_0* = 0
-  WAIT_ABANDONED_0* = 0x00000080
-  WAIT_TIMEOUT* = 0x00000102
-  WAIT_IO_COMPLETION* = 0x000000C0
-  WAIT_ABANDONED* = 0x00000080
-  WAIT_FAILED* = 0xFFFFFFFF
-  MAXIMUM_WAIT_OBJECTS* = 0x00000040
-  MAXIMUM_SUSPEND_COUNT* = 0x0000007F # MultiByteToWideChar
-  MB_PRECOMPOSED* = 1
-  MB_COMPOSITE* = 2
-  MB_ERR_INVALID_CHARS* = 8
-  MB_USEGLYPHCHARS* = 4       # NDdeSetTrustedShare
-                              # NetAccessCheck
-                              # NetServerEnum
-                              # NetServiceControl
-                              # NetUserEnum
-                              # OpenProcessToken
-  TOKEN_ADJUST_DEFAULT* = 128
-  TOKEN_ADJUST_GROUPS* = 64
-  TOKEN_ADJUST_PRIVILEGES* = 32
-  TOKEN_ALL_ACCESS* = 0x000F00FF
-  TOKEN_ASSIGN_PRIMARY* = 1
-  TOKEN_DUPLICATE* = 2
-  TOKEN_EXECUTE* = 0x00020000
-  TOKEN_IMPERSONATE* = 4
-  TOKEN_QUERY* = 8
-  TOKEN_QUERY_SOURCE* = 16
-  TOKEN_READ* = 0x00020008
-  TOKEN_WRITE* = 0x000200E0   # OpenSCManager
-  SC_MANAGER_ALL_ACCESS* = 0x000F003F
-  SC_MANAGER_CONNECT* = 1
-  SC_MANAGER_CREATE_SERVICE* = 2
-  SC_MANAGER_ENUMERATE_SERVICE* = 4
-  SC_MANAGER_LOCK* = 8
-  SC_MANAGER_QUERY_LOCK_STATUS* = 16
-  SC_MANAGER_MODIFY_BOOT_CONFIG* = 32 # PostMessage
-                                      # was #define dname def_expr
-
-proc HWND_BROADCAST*(): HWND
-  # PrepareTape
-const
-  TAPE_FORMAT* = 0x00000005
-  TAPE_LOAD* = 0
-  TAPE_LOCK* = 0x00000003
-  TAPE_TENSION* = 0x00000002
-  TAPE_UNLOAD* = 0x00000001
-  TAPE_UNLOCK* = 0x00000004   # PropertySheet
-  IS_PSREBOOTSYSTEM* = 3
-  IS_PSRESTARTWINDOWS* = 2    # PropSheetPageProc
-  PSPCB_CREATE* = 2
-  PSPCB_RELEASE* = 1          # PurgeComm
-  PURGE_TXABORT* = 1
-  PURGE_RXABORT* = 2
-  PURGE_TXCLEAR* = 4
-  PURGE_RXCLEAR* = 8          # QueryServiceObjectSecurity
-  OWNER_SECURITY_INFORMATION* = 0x00000001
-  GROUP_SECURITY_INFORMATION* = 0x00000002
-  DACL_SECURITY_INFORMATION* = 0x00000004
-  SACL_SECURITY_INFORMATION* = 0x00000008 # ReadEventLog, ReportEvent
-  EVENTLOG_FORWARDS_READ* = 4
-  EVENTLOG_BACKWARDS_READ* = 8
-  EVENTLOG_SEEK_READ* = 2
-  EVENTLOG_SEQUENTIAL_READ* = 1
-  EVENTLOG_ERROR_TYPE* = 1
-  EVENTLOG_WARNING_TYPE* = 2
-  EVENTLOG_INFORMATION_TYPE* = 4
-  EVENTLOG_AUDIT_SUCCESS* = 8
-  EVENTLOG_AUDIT_FAILURE* = 16 # RedrawWindow
-  RDW_ERASE* = 4
-  RDW_FRAME* = 1024
-  RDW_INTERNALPAINT* = 2
-  RDW_INVALIDATE* = 1
-  RDW_NOERASE* = 32
-  RDW_NOFRAME* = 2048
-  RDW_NOINTERNALPAINT* = 16
-  RDW_VALIDATE* = 8
-  RDW_ERASENOW* = 512
-  RDW_UPDATENOW* = 256
-  RDW_ALLCHILDREN* = 128
-  RDW_NOCHILDREN* = 64        # RegCreateKey
-                              # was #define dname def_expr
-
-proc HKEY_CLASSES_ROOT*(): HKEY
-  # was #define dname def_expr
-proc HKEY_CURRENT_USER*(): HKEY
-  # was #define dname def_expr
-proc HKEY_LOCAL_MACHINE*(): HKEY
-  # was #define dname def_expr
-proc HKEY_USERS*(): HKEY
-  # was #define dname def_expr
-proc HKEY_PERFORMANCE_DATA*(): HKEY
-  # was #define dname def_expr
-proc HKEY_CURRENT_CONFIG*(): HKEY
-  # was #define dname def_expr
-proc HKEY_DYN_DATA*(): HKEY
-  # RegCreateKeyEx
-const
-  REG_OPTION_VOLATILE* = 0x00000001
-  REG_OPTION_NON_VOLATILE* = 0
-  REG_CREATED_NEW_KEY* = 0x00000001
-  REG_OPENED_EXISTING_KEY* = 0x00000002 # RegEnumValue
-  REG_BINARY* = 3
-  REG_DWORD* = 4
-  REG_DWORD_LITTLE_ENDIAN* = 4
-  REG_DWORD_BIG_ENDIAN* = 5
-  REG_EXPAND_SZ* = 2
-  REG_FULL_RESOURCE_DESCRIPTOR* = 9
-  REG_LINK* = 6
-  REG_MULTI_SZ* = 7
-  REG_NONE* = 0
-  REG_RESOURCE_LIST* = 8
-  REG_RESOURCE_REQUIREMENTS_LIST* = 10
-  REG_SZ* = 1                 # RegisterHotKey
-  MOD_ALT* = 1
-  MOD_CONTROL* = 2
-  MOD_SHIFT* = 4
-  MOD_WIN* = 8
-  IDHOT_SNAPDESKTOP* = - (2)
-  IDHOT_SNAPWINDOW* = - (1)   # RegNotifyChangeKeyValue
-  REG_NOTIFY_CHANGE_NAME* = 0x00000001
-  REG_NOTIFY_CHANGE_ATTRIBUTES* = 0x00000002
-  REG_NOTIFY_CHANGE_LAST_SET* = 0x00000004
-  REG_NOTIFY_CHANGE_SECURITY* = 0x00000008 # ScrollWindowEx
-  SW_ERASE* = 4
-  SW_INVALIDATE* = 2
-  SW_SCROLLCHILDREN* = 1      # SendMessageTimeout
-  SMTO_ABORTIFHUNG* = 2
-  SMTO_BLOCK* = 1
-  SMTO_NORMAL* = 0            # SetBkMode
-  OPAQUE* = 2
-  TRANSPARENT* = 1            # SetDebugErrorLevel
-  SLE_ERROR* = 1
-  SLE_MINORERROR* = 2
-  SLE_WARNING* = 3            # SetErrorMode
-  SEM_FAILCRITICALERRORS* = 1
-  SEM_NOALIGNMENTFAULTEXCEPT* = 4
-  SEM_NOGPFAULTERRORBOX* = 2
-  SEM_NOOPENFILEERRORBOX* = 32768 # SetICMMode
-  ICM_ON* = 2
-  ICM_OFF* = 1
-  ICM_QUERY* = 3              # SetJob
-                              # Locale Information
-  LOCALE_ILANGUAGE* = 1
-  LOCALE_SLANGUAGE* = 2
-  LOCALE_SENGLANGUAGE* = 4097
-  LOCALE_SABBREVLANGNAME* = 3
-  LOCALE_SNATIVELANGNAME* = 4
-  LOCALE_ICOUNTRY* = 5
-  LOCALE_SCOUNTRY* = 6
-  LOCALE_SENGCOUNTRY* = 4098
-  LOCALE_SABBREVCTRYNAME* = 7
-  LOCALE_SNATIVECTRYNAME* = 8
-  LOCALE_IDEFAULTLANGUAGE* = 9
-  LOCALE_IDEFAULTCOUNTRY* = 10
-  LOCALE_IDEFAULTANSICODEPAGE* = 4100
-  LOCALE_IDEFAULTCODEPAGE* = 11
-  LOCALE_SLIST* = 12
-  LOCALE_IMEASURE* = 13
-  LOCALE_SDECIMAL* = 14
-  LOCALE_STHOUSAND* = 15
-  LOCALE_SGROUPING* = 16
-  LOCALE_IDIGITS* = 17
-  LOCALE_ILZERO* = 18
-  LOCALE_INEGNUMBER* = 4112
-  LOCALE_SCURRENCY* = 20
-  LOCALE_SMONDECIMALSEP* = 22
-  LOCALE_SMONTHOUSANDSEP* = 23
-  LOCALE_SMONGROUPING* = 24
-  LOCALE_ICURRDIGITS* = 25
-  LOCALE_ICURRENCY* = 27
-  LOCALE_INEGCURR* = 28
-  LOCALE_SDATE* = 29
-  LOCALE_STIME* = 30
-  LOCALE_STIMEFORMAT* = 4099
-  LOCALE_SSHORTDATE* = 31
-  LOCALE_SLONGDATE* = 32
-  LOCALE_IDATE* = 33
-  LOCALE_ILDATE* = 34
-  LOCALE_ITIME* = 35
-  LOCALE_ITLZERO* = 37
-  LOCALE_IDAYLZERO* = 38
-  LOCALE_IMONLZERO* = 39
-  LOCALE_S1159* = 40
-  LOCALE_S2359* = 41
-  LOCALE_ICALENDARTYPE* = 4105
-  LOCALE_IOPTIONALCALENDAR* = 4107
-  LOCALE_IFIRSTDAYOFWEEK* = 4108
-  LOCALE_IFIRSTWEEKOFYEAR* = 4109
-  LOCALE_SDAYNAME1* = 42
-  LOCALE_SDAYNAME2* = 43
-  LOCALE_SDAYNAME3* = 44
-  LOCALE_SDAYNAME4* = 45
-  LOCALE_SDAYNAME5* = 46
-  LOCALE_SDAYNAME6* = 47
-  LOCALE_SDAYNAME7* = 48
-  LOCALE_SABBREVDAYNAME1* = 49
-  LOCALE_SABBREVDAYNAME2* = 50
-  LOCALE_SABBREVDAYNAME3* = 51
-  LOCALE_SABBREVDAYNAME4* = 52
-  LOCALE_SABBREVDAYNAME5* = 53
-  LOCALE_SABBREVDAYNAME6* = 54
-  LOCALE_SABBREVDAYNAME7* = 55
-  LOCALE_SMONTHNAME1* = 56
-  LOCALE_SMONTHNAME2* = 57
-  LOCALE_SMONTHNAME3* = 58
-  LOCALE_SMONTHNAME4* = 59
-  LOCALE_SMONTHNAME5* = 60
-  LOCALE_SMONTHNAME6* = 61
-  LOCALE_SMONTHNAME7* = 62
-  LOCALE_SMONTHNAME8* = 63
-  LOCALE_SMONTHNAME9* = 64
-  LOCALE_SMONTHNAME10* = 65
-  LOCALE_SMONTHNAME11* = 66
-  LOCALE_SMONTHNAME12* = 67
-  LOCALE_SMONTHNAME13* = 4110
-  LOCALE_SABBREVMONTHNAME1* = 68
-  LOCALE_SABBREVMONTHNAME2* = 69
-  LOCALE_SABBREVMONTHNAME3* = 70
-  LOCALE_SABBREVMONTHNAME4* = 71
-  LOCALE_SABBREVMONTHNAME5* = 72
-  LOCALE_SABBREVMONTHNAME6* = 73
-  LOCALE_SABBREVMONTHNAME7* = 74
-  LOCALE_SABBREVMONTHNAME8* = 75
-  LOCALE_SABBREVMONTHNAME9* = 76
-  LOCALE_SABBREVMONTHNAME10* = 77
-  LOCALE_SABBREVMONTHNAME11* = 78
-  LOCALE_SABBREVMONTHNAME12* = 79
-  LOCALE_SABBREVMONTHNAME13* = 4111
-  LOCALE_SPOSITIVESIGN* = 80
-  LOCALE_SNEGATIVESIGN* = 81
-  LOCALE_IPOSSIGNPOSN* = 82
-  LOCALE_INEGSIGNPOSN* = 83
-  LOCALE_IPOSSYMPRECEDES* = 84
-  LOCALE_IPOSSEPBYSPACE* = 85
-  LOCALE_INEGSYMPRECEDES* = 86
-  LOCALE_INEGSEPBYSPACE* = 87
-  LOCALE_NOUSEROVERRIDE* = 0x80000000
-  LOCALE_USE_CP_ACP* = 0x40000000 # use the system ACP
-  LOCALE_RETURN_NUMBER* = 0x20000000 # return number instead
-  LOCALE_SISO639LANGNAME* = 0x00000059
-  LOCALE_SISO3166CTRYNAME* = 0x0000005A # Calendar Type Information
-  CAL_ICALINTVALUE* = 1
-  CAL_IYEAROFFSETRANGE* = 3
-  CAL_SABBREVDAYNAME1* = 14
-  CAL_SABBREVDAYNAME2* = 15
-  CAL_SABBREVDAYNAME3* = 16
-  CAL_SABBREVDAYNAME4* = 17
-  CAL_SABBREVDAYNAME5* = 18
-  CAL_SABBREVDAYNAME6* = 19
-  CAL_SABBREVDAYNAME7* = 20
-  CAL_SABBREVMONTHNAME1* = 34
-  CAL_SABBREVMONTHNAME2* = 35
-  CAL_SABBREVMONTHNAME3* = 36
-  CAL_SABBREVMONTHNAME4* = 37
-  CAL_SABBREVMONTHNAME5* = 38
-  CAL_SABBREVMONTHNAME6* = 39
-  CAL_SABBREVMONTHNAME7* = 40
-  CAL_SABBREVMONTHNAME8* = 41
-  CAL_SABBREVMONTHNAME9* = 42
-  CAL_SABBREVMONTHNAME10* = 43
-  CAL_SABBREVMONTHNAME11* = 44
-  CAL_SABBREVMONTHNAME12* = 45
-  CAL_SABBREVMONTHNAME13* = 46
-  CAL_SCALNAME* = 2
-  CAL_SDAYNAME1* = 7
-  CAL_SDAYNAME2* = 8
-  CAL_SDAYNAME3* = 9
-  CAL_SDAYNAME4* = 10
-  CAL_SDAYNAME5* = 11
-  CAL_SDAYNAME6* = 12
-  CAL_SDAYNAME7* = 13
-  CAL_SERASTRING* = 4
-  CAL_SLONGDATE* = 6
-  CAL_SMONTHNAME1* = 21
-  CAL_SMONTHNAME2* = 22
-  CAL_SMONTHNAME3* = 23
-  CAL_SMONTHNAME4* = 24
-  CAL_SMONTHNAME5* = 25
-  CAL_SMONTHNAME6* = 26
-  CAL_SMONTHNAME7* = 27
-  CAL_SMONTHNAME8* = 28
-  CAL_SMONTHNAME9* = 29
-  CAL_SMONTHNAME10* = 30
-  CAL_SMONTHNAME11* = 31
-  CAL_SMONTHNAME12* = 32
-  CAL_SMONTHNAME13* = 33
-  CAL_SSHORTDATE* = 5         # SetProcessWorkingSetSize
-  PROCESS_SET_QUOTA* = 256    # SetPrinter
-                              # SetService
-                              # SetStretchBltMode
-  BLACKONWHITE* = 1
-  COLORONCOLOR* = 3
-  HALFTONE* = 4
-  STRETCH_ANDSCANS* = 1
-  STRETCH_DELETESCANS* = 3
-  STRETCH_HALFTONE* = 4
-  STRETCH_ORSCANS* = 2
-  WHITEONBLACK* = 2           # SetSystemCursor
-  OCR_NORMAL* = 32512
-  OCR_IBEAM* = 32513
-  OCR_WAIT* = 32514
-  OCR_CROSS* = 32515
-  OCR_UP* = 32516
-  OCR_SIZE* = 32640
-  OCR_ICON* = 32641
-  OCR_SIZENWSE* = 32642
-  OCR_SIZENESW* = 32643
-  OCR_SIZEWE* = 32644
-  OCR_SIZENS* = 32645
-  OCR_SIZEALL* = 32646
-  OCR_NO* = 32648
-  OCR_APPSTARTING* = 32650    # SetTapePosition
-  TAPE_ABSOLUTE_BLOCK* = 0x00000001
-  TAPE_LOGICAL_BLOCK* = 0x00000002
-  TAPE_REWIND* = 0
-  TAPE_SPACE_END_OF_DATA* = 0x00000004
-  TAPE_SPACE_FILEMARKS* = 0x00000006
-  TAPE_SPACE_RELATIVE_BLOCKS* = 0x00000005
-  TAPE_SPACE_SEQUENTIAL_FMKS* = 0x00000007
-  TAPE_SPACE_SEQUENTIAL_SMKS* = 0x00000009
-  TAPE_SPACE_SETMARKS* = 0x00000008 # SetUnhandledExceptionFilter
-  EXCEPTION_EXECUTE_HANDLER* = 1
-  EXCEPTION_CONTINUE_EXECUTION* = - (1)
-  EXCEPTION_CONTINUE_SEARCH* = 0 # SetWindowPos, DeferWindowPos
-                                 # was #define dname def_expr
-
-proc HWND_BOTTOM*(): HWND
-  # was #define dname def_expr
-proc HWND_NOTOPMOST*(): HWND
-  # was #define dname def_expr
-proc HWND_TOP*(): HWND
-  # was #define dname def_expr
-proc HWND_TOPMOST*(): HWND
-const
-  SWP_DRAWFRAME* = 32
-  SWP_FRAMECHANGED* = 32
-  SWP_HIDEWINDOW* = 128
-  SWP_NOACTIVATE* = 16
-  SWP_NOCOPYBITS* = 256
-  SWP_NOMOVE* = 2
-  SWP_NOSIZE* = 1
-  SWP_NOREDRAW* = 8
-  SWP_NOZORDER* = 4
-  SWP_SHOWWINDOW* = 64
-  SWP_NOOWNERZORDER* = 512
-  SWP_NOREPOSITION* = 512
-  SWP_NOSENDCHANGING* = 1024  # SHAddToRecentDocs
-                              # SHAppBarMessage
-                              # SHChangeNotify
-                              # ShellProc
-  HSHELL_ACTIVATESHELLWINDOW* = 3
-  HSHELL_GETMINRECT* = 5
-  HSHELL_LANGUAGE* = 8
-  HSHELL_REDRAW* = 6
-  HSHELL_TASKMAN* = 7
-  HSHELL_WINDOWACTIVATED* = 4
-  HSHELL_WINDOWCREATED* = 1
-  HSHELL_WINDOWDESTROYED* = 2 # SHGetFileInfo
-                              # SHGetSpecialFolderLocation
-                              # ShowWindow
-  SW_HIDE* = 0
-  SW_MAXIMIZE* = 3
-  SW_MINIMIZE* = 6
-  SW_NORMAL* = 1
-  SW_RESTORE* = 9
-  SW_SHOW* = 5
-  SW_SHOWDEFAULT* = 10
-  SW_SHOWMAXIMIZED* = 3
-  SW_SHOWMINIMIZED* = 2
-  SW_SHOWMINNOACTIVE* = 7
-  SW_SHOWNA* = 8
-  SW_SHOWNOACTIVATE* = 4
-  SW_SHOWNORMAL* = 1
-  WPF_RESTORETOMAXIMIZED* = 2
-  WPF_SETMINPOSITION* = 1     # Sleep
-  INFINITE* = -1'i32      # SystemParametersInfo
-  SPI_GETBEEP* = 1
-  SPI_SETBEEP* = 2
-  SPI_GETMOUSE* = 3
-  SPI_SETMOUSE* = 4
-  SPI_GETBORDER* = 5
-  SPI_SETBORDER* = 6
-  SPI_GETKEYBOARDSPEED* = 10
-  SPI_SETKEYBOARDSPEED* = 11
-  SPI_LANGDRIVER* = 12
-  SPI_ICONHORIZONTALSPACING* = 13
-  SPI_GETSCREENSAVETIMEOUT* = 14
-  SPI_SETSCREENSAVETIMEOUT* = 15
-  SPI_GETSCREENSAVEACTIVE* = 16
-  SPI_SETSCREENSAVEACTIVE* = 17
-  SPI_GETGRIDGRANULARITY* = 18
-  SPI_SETGRIDGRANULARITY* = 19
-  SPI_SETDESKWALLPAPER* = 20
-  SPI_SETDESKPATTERN* = 21
-  SPI_GETKEYBOARDDELAY* = 22
-  SPI_SETKEYBOARDDELAY* = 23
-  SPI_ICONVERTICALSPACING* = 24
-  SPI_GETICONTITLEWRAP* = 25
-  SPI_SETICONTITLEWRAP* = 26
-  SPI_GETMENUDROPALIGNMENT* = 27
-  SPI_SETMENUDROPALIGNMENT* = 28
-  SPI_SETDOUBLECLKWIDTH* = 29
-  SPI_SETDOUBLECLKHEIGHT* = 30
-  SPI_GETICONTITLELOGFONT* = 31
-  SPI_SETDOUBLECLICKTIME* = 32
-  SPI_SETMOUSEBUTTONSWAP* = 33
-  SPI_SETICONTITLELOGFONT* = 34
-  SPI_GETFASTTASKSWITCH* = 35
-  SPI_SETFASTTASKSWITCH* = 36
-  SPI_SETDRAGFULLWINDOWS* = 37
-  SPI_GETDRAGFULLWINDOWS* = 38
-  SPI_GETNONCLIENTMETRICS* = 41
-  SPI_SETNONCLIENTMETRICS* = 42
-  SPI_GETMINIMIZEDMETRICS* = 43
-  SPI_SETMINIMIZEDMETRICS* = 44
-  SPI_GETICONMETRICS* = 45
-  SPI_SETICONMETRICS* = 46
-  SPI_SETWORKAREA* = 47
-  SPI_GETWORKAREA* = 48
-  SPI_SETPENWINDOWS* = 49
-  SPI_GETFILTERKEYS* = 50
-  SPI_SETFILTERKEYS* = 51
-  SPI_GETTOGGLEKEYS* = 52
-  SPI_SETTOGGLEKEYS* = 53
-  SPI_GETMOUSEKEYS* = 54
-  SPI_SETMOUSEKEYS* = 55
-  SPI_GETSHOWSOUNDS* = 56
-  SPI_SETSHOWSOUNDS* = 57
-  SPI_GETSTICKYKEYS* = 58
-  SPI_SETSTICKYKEYS* = 59
-  SPI_GETACCESSTIMEOUT* = 60
-  SPI_SETACCESSTIMEOUT* = 61
-  SPI_GETSERIALKEYS* = 62
-  SPI_SETSERIALKEYS* = 63
-  SPI_GETSOUNDSENTRY* = 64
-  SPI_SETSOUNDSENTRY* = 65
-  SPI_GETHIGHCONTRAST* = 66
-  SPI_SETHIGHCONTRAST* = 67
-  SPI_GETKEYBOARDPREF* = 68
-  SPI_SETKEYBOARDPREF* = 69
-  SPI_GETSCREENREADER* = 70
-  SPI_SETSCREENREADER* = 71
-  SPI_GETANIMATION* = 72
-  SPI_SETANIMATION* = 73
-  SPI_GETFONTSMOOTHING* = 74
-  SPI_SETFONTSMOOTHING* = 75
-  SPI_SETDRAGWIDTH* = 76
-  SPI_SETDRAGHEIGHT* = 77
-  SPI_SETHANDHELD* = 78
-  SPI_GETLOWPOWERTIMEOUT* = 79
-  SPI_GETPOWEROFFTIMEOUT* = 80
-  SPI_SETLOWPOWERTIMEOUT* = 81
-  SPI_SETPOWEROFFTIMEOUT* = 82
-  SPI_GETLOWPOWERACTIVE* = 83
-  SPI_GETPOWEROFFACTIVE* = 84
-  SPI_SETLOWPOWERACTIVE* = 85
-  SPI_SETPOWEROFFACTIVE* = 86
-  SPI_SETCURSORS* = 87
-  SPI_SETICONS* = 88
-  SPI_GETDEFAULTINPUTLANG* = 89
-  SPI_SETDEFAULTINPUTLANG* = 90
-  SPI_SETLANGTOGGLE* = 91
-  SPI_GETWINDOWSEXTENSION* = 92
-  SPI_SETMOUSETRAILS* = 93
-  SPI_GETMOUSETRAILS* = 94
-  SPI_GETSNAPTODEFBUTTON* = 95
-  SPI_SETSNAPTODEFBUTTON* = 96
-  SPI_SCREENSAVERRUNNING* = 97
-  SPI_SETSCREENSAVERRUNNING* = 97
-  SPI_GETMOUSEHOVERWIDTH* = 98
-  SPI_SETMOUSEHOVERWIDTH* = 99
-  SPI_GETMOUSEHOVERHEIGHT* = 100
-  SPI_SETMOUSEHOVERHEIGHT* = 101
-  SPI_GETMOUSEHOVERTIME* = 102
-  SPI_SETMOUSEHOVERTIME* = 103
-  SPI_GETWHEELSCROLLLINES* = 104
-  SPI_SETWHEELSCROLLLINES* = 105
-  SPI_GETMENUSHOWDELAY* = 106
-  SPI_SETMENUSHOWDELAY* = 107
-  SPI_GETSHOWIMEUI* = 110
-  SPI_SETSHOWIMEUI* = 111     # Windows Me/2000 and higher
-  SPI_GETMOUSESPEED* = 112
-  SPI_SETMOUSESPEED* = 113
-  SPI_GETSCREENSAVERRUNNING* = 114
-  SPI_GETDESKWALLPAPER* = 115
-  SPI_GETACTIVEWINDOWTRACKING* = 4096
-  SPI_SETACTIVEWINDOWTRACKING* = 4097
-  SPI_GETMENUANIMATION* = 4098
-  SPI_SETMENUANIMATION* = 4099
-  SPI_GETCOMBOBOXANIMATION* = 4100
-  SPI_SETCOMBOBOXANIMATION* = 4101
-  SPI_GETLISTBOXSMOOTHSCROLLING* = 4102
-  SPI_SETLISTBOXSMOOTHSCROLLING* = 4103
-  SPI_GETGRADIENTCAPTIONS* = 4104
-  SPI_SETGRADIENTCAPTIONS* = 4105
-  SPI_GETKEYBOARDCUES* = 4106
-  SPI_SETKEYBOARDCUES* = 4107
-  SPI_GETMENUUNDERLINES* = 4106
-  SPI_SETMENUUNDERLINES* = 4107
-  SPI_GETACTIVEWNDTRKZORDER* = 4108
-  SPI_SETACTIVEWNDTRKZORDER* = 4109
-  SPI_GETHOTTRACKING* = 4110
-  SPI_SETHOTTRACKING* = 4111
-  SPI_GETMENUFADE* = 4114
-  SPI_SETMENUFADE* = 4115
-  SPI_GETSELECTIONFADE* = 4116
-  SPI_SETSELECTIONFADE* = 4117
-  SPI_GETTOOLTIPANIMATION* = 4118
-  SPI_SETTOOLTIPANIMATION* = 4119
-  SPI_GETTOOLTIPFADE* = 4120
-  SPI_SETTOOLTIPFADE* = 4121
-  SPI_GETCURSORSHADOW* = 4122
-  SPI_SETCURSORSHADOW* = 4123
-  SPI_GETUIEFFECTS* = 4158
-  SPI_SETUIEFFECTS* = 4159
-  SPI_GETFOREGROUNDLOCKTIMEOUT* = 8192
-  SPI_SETFOREGROUNDLOCKTIMEOUT* = 8193
-  SPI_GETACTIVEWNDTRKTIMEOUT* = 8194
-  SPI_SETACTIVEWNDTRKTIMEOUT* = 8195
-  SPI_GETFOREGROUNDFLASHCOUNT* = 8196
-  SPI_SETFOREGROUNDFLASHCOUNT* = 8197
-  SPI_GETCARETWIDTH* = 8198
-  SPI_SETCARETWIDTH* = 8199   # Windows XP and higher
-  SPI_GETMOUSESONAR* = 4124
-  SPI_SETMOUSESONAR* = 4125
-  SPI_GETMOUSECLICKLOCK* = 4126
-  SPI_SETMOUSECLICKLOCK* = 4127
-  SPI_GETMOUSEVANISH* = 4128
-  SPI_SETMOUSEVANISH* = 4129
-  SPI_GETFLATMENU* = 4130
-  SPI_SETFLATMENU* = 4131
-  SPI_GETDROPSHADOW* = 4132
-  SPI_SETDROPSHADOW* = 4133
-  SPI_GETBLOCKSENDINPUTRESETS* = 4134
-  SPI_SETBLOCKSENDINPUTRESETS* = 4135
-  SPI_GETMOUSECLICKLOCKTIME* = 8200
-  SPI_SETMOUSECLICKLOCKTIME* = 8201
-  SPI_GETFONTSMOOTHINGTYPE* = 8202
-  SPI_SETFONTSMOOTHINGTYPE* = 8203
-  SPI_GETFONTSMOOTHINGCONTRAST* = 8204
-  SPI_SETFONTSMOOTHINGCONTRAST* = 8205
-  SPI_GETFOCUSBORDERWIDTH* = 8206
-  SPI_SETFOCUSBORDERWIDTH* = 8207
-  SPI_GETFOCUSBORDERHEIGHT* = 8208
-  SPI_SETFOCUSBORDERHEIGHT* = 8209
-  SPI_GETFONTSMOOTHINGORIENTATION* = 8210
-  SPI_SETFONTSMOOTHINGORIENTATION* = 8211 # constants for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE:
-  FE_FONTSMOOTHINGSTANDARD* = 1
-  FE_FONTSMOOTHINGCLEARTYPE* = 2
-  FE_FONTSMOOTHINGDOCKING* = 32768 # constants for SPI_GETFONTSMOOTHINGORIENTATION and SPI_SETFONTSMOOTHINGORIENTATION:
-  FE_FONTSMOOTHINGORIENTATIONBGR* = 0
-  FE_FONTSMOOTHINGORIENTATIONRGB* = 1 # Flags
-  SPIF_UPDATEINIFILE* = 1
-  SPIF_SENDWININICHANGE* = 2
-  SPIF_SENDCHANGE* = 2        # TrackPopupMenu, TrackPopMenuEx
-  TPM_CENTERALIGN* = 0x00000004
-  TPM_LEFTALIGN* = 0
-  TPM_RIGHTALIGN* = 0x00000008
-  TPM_LEFTBUTTON* = 0
-  TPM_RIGHTBUTTON* = 0x00000002
-  TPM_HORIZONTAL* = 0
-  TPM_VERTICAL* = 0x00000040  # TranslateCharsetInfo
-  TCI_SRCCHARSET* = 1
-  TCI_SRCCODEPAGE* = 2
-  TCI_SRCFONTSIG* = 3         # VerFindFile
-  VFFF_ISSHAREDFILE* = 1
-  VFF_CURNEDEST* = 1
-  VFF_FILEINUSE* = 2
-  VFF_BUFFTOOSMALL* = 4       # VerInstallFile
-  VIFF_FORCEINSTALL* = 1
-  VIFF_DONTDELETEOLD* = 2
-  VIF_TEMPFILE* = 0x00000001
-  VIF_MISMATCH* = 0x00000002
-  VIF_SRCOLD* = 0x00000004
-  VIF_DIFFLANG* = 0x00000008
-  VIF_DIFFCODEPG* = 0x00000010
-  VIF_DIFFTYPE* = 0x00000020
-  VIF_WRITEPROT* = 0x00000040
-  VIF_FILEINUSE* = 0x00000080
-  VIF_OUTOFSPACE* = 0x00000100
-  VIF_ACCESSVIOLATION* = 0x00000200
-  VIF_SHARINGVIOLATION* = 0x00000400
-  VIF_CANNOTCREATE* = 0x00000800
-  VIF_CANNOTDELETE* = 0x00001000
-  VIF_CANNOTDELETECUR* = 0x00004000
-  VIF_CANNOTRENAME* = 0x00002000
-  VIF_OUTOFMEMORY* = 0x00008000
-  VIF_CANNOTREADSRC* = 0x00010000
-  VIF_CANNOTREADDST* = 0x00020000
-  VIF_BUFFTOOSMALL* = 0x00040000 # WideCharToMultiByte
-  WC_COMPOSITECHECK* = 512
-  WC_DISCARDNS* = 16
-  WC_SEPCHARS* = 32
-  WC_DEFAULTCHAR* = 64        # WinHelp
-  HELP_COMMAND* = 0x00000102
-  HELP_CONTENTS* = 0x00000003
-  HELP_CONTEXT* = 0x00000001
-  HELP_CONTEXTPOPUP* = 0x00000008
-  HELP_FORCEFILE* = 0x00000009
-  HELP_HELPONHELP* = 0x00000004
-  HELP_INDEX* = 0x00000003
-  HELP_KEY* = 0x00000101
-  HELP_MULTIKEY* = 0x00000201
-  HELP_PARTIALKEY* = 0x00000105
-  HELP_QUIT* = 0x00000002
-  HELP_SETCONTENTS* = 0x00000005
-  HELP_SETINDEX* = 0x00000005
-  HELP_CONTEXTMENU* = 0x0000000A
-  HELP_FINDER* = 0x0000000B
-  HELP_WM_HELP* = 0x0000000C
-  HELP_TCARD* = 0x00008000
-  HELP_TCARD_DATA* = 0x00000010
-  HELP_TCARD_OTHER_CALLER* = 0x00000011 # WNetAddConnectino2
-  CONNECT_UPDATE_PROFILE* = 1 # WNetConnectionDialog, WNetDisconnectDialog, WNetOpenEnum
-  RESOURCETYPE_DISK* = 1
-  RESOURCETYPE_PRINT* = 2
-  RESOURCETYPE_ANY* = 0
-  RESOURCE_CONNECTED* = 1
-  RESOURCE_GLOBALNET* = 2
-  RESOURCE_REMEMBERED* = 3
-  RESOURCEUSAGE_CONNECTABLE* = 1
-  RESOURCEUSAGE_CONTAINER* = 2 # WNetGetResourceInformation, WNetGetResourceParent
-  WN_BAD_NETNAME* = 0x00000043
-  WN_EXTENDED_ERROR* = 0x000004B8
-  WN_MORE_DATA* = 0x000000EA
-  WN_NO_NETWORK* = 0x000004C6
-  WN_SUCCESS* = 0
-  WN_ACCESS_DENIED* = 0x00000005
-  WN_BAD_PROVIDER* = 0x000004B4
-  WN_NOT_AUTHENTICATED* = 0x000004DC # WNetGetUniversalName
-  UNIVERSAL_NAME_INFO_LEVEL* = 1
-  REMOTE_NAME_INFO_LEVEL* = 2 # GetExitCodeThread
-  STILL_ACTIVE* = 0x00000103  # COMMPROP structure
-  SP_SERIALCOMM* = 0x00000001
-  BAUD_075* = 0x00000001
-  BAUD_110* = 0x00000002
-  BAUD_134_5* = 0x00000004
-  BAUD_150* = 0x00000008
-  BAUD_300* = 0x00000010
-  BAUD_600* = 0x00000020
-  BAUD_1200* = 0x00000040
-  BAUD_1800* = 0x00000080
-  BAUD_2400* = 0x00000100
-  BAUD_4800* = 0x00000200
-  BAUD_7200* = 0x00000400
-  BAUD_9600* = 0x00000800
-  BAUD_14400* = 0x00001000
-  BAUD_19200* = 0x00002000
-  BAUD_38400* = 0x00004000
-  BAUD_56K* = 0x00008000
-  BAUD_57600* = 0x00040000
-  BAUD_115200* = 0x00020000
-  BAUD_128K* = 0x00010000
-  BAUD_USER* = 0x10000000
-  PST_FAX* = 0x00000021
-  PST_LAT* = 0x00000101
-  PST_MODEM* = 0x00000006
-  PST_NETWORK_BRIDGE* = 0x00000100
-  PST_PARALLELPORT* = 0x00000002
-  PST_RS232* = 0x00000001
-  PST_RS422* = 0x00000003
-  PST_RS423* = 0x00000004
-  PST_RS449* = 0x00000005
-  PST_SCANNER* = 0x00000022
-  PST_TCPIP_TELNET* = 0x00000102
-  PST_UNSPECIFIED* = 0
-  PST_X25* = 0x00000103
-  PCF_16BITMODE* = 0x00000200
-  PCF_DTRDSR* = 0x00000001
-  PCF_INTTIMEOUTS* = 0x00000080
-  PCF_PARITY_CHECK* = 0x00000008
-  PCF_RLSD* = 0x00000004
-  PCF_RTSCTS* = 0x00000002
-  PCF_SETXCHAR* = 0x00000020
-  PCF_SPECIALCHARS* = 0x00000100
-  PCF_TOTALTIMEOUTS* = 0x00000040
-  PCF_XONXOFF* = 0x00000010
-  SP_BAUD* = 0x00000002
-  SP_DATABITS* = 0x00000004
-  SP_HANDSHAKING* = 0x00000010
-  SP_PARITY* = 0x00000001
-  SP_PARITY_CHECK* = 0x00000020
-  SP_RLSD* = 0x00000040
-  SP_STOPBITS* = 0x00000008
-  DATABITS_5* = 1
-  DATABITS_6* = 2
-  DATABITS_7* = 4
-  DATABITS_8* = 8
-  DATABITS_16* = 16
-  DATABITS_16X* = 32
-  STOPBITS_10* = 1
-  STOPBITS_15* = 2
-  STOPBITS_20* = 4
-  PARITY_NONE* = 256
-  PARITY_ODD* = 512
-  PARITY_EVEN* = 1024
-  PARITY_MARK* = 2048
-  PARITY_SPACE* = 4096
-  COMMPROP_INITIALIZED* = 0xE73CF52E # DCB structure
-  CBR_110* = 110
-  CBR_300* = 300
-  CBR_600* = 600
-  CBR_1200* = 1200
-  CBR_2400* = 2400
-  CBR_4800* = 4800
-  CBR_9600* = 9600
-  CBR_14400* = 14400
-  CBR_19200* = 19200
-  CBR_38400* = 38400
-  CBR_56000* = 56000
-  CBR_57600* = 57600
-  CBR_115200* = 115200
-  CBR_128000* = 128000
-  CBR_256000* = 256000
-  DTR_CONTROL_DISABLE* = 0
-  DTR_CONTROL_ENABLE* = 1
-  DTR_CONTROL_HANDSHAKE* = 2
-  RTS_CONTROL_DISABLE* = 0
-  RTS_CONTROL_ENABLE* = 1
-  RTS_CONTROL_HANDSHAKE* = 2
-  RTS_CONTROL_TOGGLE* = 3
-  EVENPARITY* = 2
-  MARKPARITY* = 3
-  NOPARITY* = 0
-  ODDPARITY* = 1
-  SPACEPARITY* = 4
-  ONESTOPBIT* = 0
-  ONE5STOPBITS* = 1
-  TWOSTOPBITS* = 2            # Debugging events
-  CREATE_PROCESS_DEBUG_EVENT* = 3
-  CREATE_THREAD_DEBUG_EVENT* = 2
-  EXCEPTION_DEBUG_EVENT* = 1
-  EXIT_PROCESS_DEBUG_EVENT* = 5
-  EXIT_THREAD_DEBUG_EVENT* = 4
-  LOAD_DLL_DEBUG_EVENT* = 6
-  OUTPUT_DEBUG_STRING_EVENT* = 8
-  UNLOAD_DLL_DEBUG_EVENT* = 7
-  RIP_EVENT* = 9              # PROCESS_HEAP_ENTRY structure
-  PROCESS_HEAP_REGION* = 1
-  PROCESS_HEAP_UNCOMMITTED_RANGE* = 2
-  PROCESS_HEAP_ENTRY_BUSY* = 4
-  PROCESS_HEAP_ENTRY_MOVEABLE* = 16
-  PROCESS_HEAP_ENTRY_DDESHARE* = 32 # Win32s
-  HINSTANCE_ERROR* = 32       # WIN32_STREAM_ID structure
-  BACKUP_DATA* = 1
-  BACKUP_EA_DATA* = 2
-  BACKUP_SECURITY_DATA* = 3
-  BACKUP_ALTERNATE_DATA* = 4
-  BACKUP_LINK* = 5
-  STREAM_MODIFIED_WHEN_READ* = 1
-  STREAM_CONTAINS_SECURITY* = 2 # STARTUPINFO structure
-  STARTF_USESHOWWINDOW* = 1
-  STARTF_USEPOSITION* = 4
-  STARTF_USESIZE* = 2
-  STARTF_USECOUNTCHARS* = 8
-  STARTF_USEFILLATTRIBUTE* = 16
-  STARTF_RUNFULLSCREEN* = 32
-  STARTF_FORCEONFEEDBACK* = 64
-  STARTF_FORCEOFFFEEDBACK* = 128
-  STARTF_USESTDHANDLES* = 256
-  STARTF_USEHOTKEY* = 512     # OSVERSIONINFO structure
-  VER_PLATFORM_WIN32s* = 0
-  VER_PLATFORM_WIN32_WINDOWS* = 1
-  VER_PLATFORM_WIN32_NT* = 2  # More versions
-  VER_SERVER_NT* = 0x80000000
-  VER_WORKSTATION_NT* = 0x40000000
-  VER_SUITE_SMALLBUSINESS* = 0x00000001
-  VER_SUITE_ENTERPRISE* = 0x00000002
-  VER_SUITE_BACKOFFICE* = 0x00000004
-  VER_SUITE_COMMUNICATIONS* = 0x00000008
-  VER_SUITE_TERMINAL* = 0x00000010
-  VER_SUITE_SMALLBUSINESS_RESTRICTED* = 0x00000020
-  VER_SUITE_EMBEDDEDNT* = 0x00000040
-  VER_SUITE_DATACENTER* = 0x00000080
-  VER_SUITE_SINGLEUSERTS* = 0x00000100
-  VER_SUITE_PERSONAL* = 0x00000200
-  VER_SUITE_BLADE* = 0x00000400
-  VER_SUITE_EMBEDDED_RESTRICTED* = 0x00000800 # PROPSHEETPAGE structure
-  MAXPROPPAGES* = 100
-  PSP_DEFAULT* = 0
-  PSP_DLGINDIRECT* = 1
-  PSP_HASHELP* = 32
-  PSP_USECALLBACK* = 128
-  PSP_USEHICON* = 2
-  PSP_USEICONID* = 4
-  PSP_USEREFPARENT* = 64
-  PSP_USETITLE* = 8
-  PSP_RTLREADING* = 16        # PROPSHEETHEADER structure
-  PSH_DEFAULT* = 0
-  PSH_HASHELP* = 512
-  PSH_MODELESS* = 1024
-  PSH_NOAPPLYNOW* = 128
-  PSH_PROPSHEETPAGE* = 8
-  PSH_PROPTITLE* = 1
-  PSH_USECALLBACK* = 256
-  PSH_USEHICON* = 2
-  PSH_USEICONID* = 4
-  PSH_USEPSTARTPAGE* = 64
-  PSH_WIZARD* = 32
-  PSH_RTLREADING* = 2048
-  PSCB_INITIALIZED* = 1
-  PSCB_PRECREATE* = 2         # PSN_APPLY message
-  PSNRET_NOERROR* = 0
-  PSNRET_INVALID_NOCHANGEPAGE* = 2 # Property Sheet
-  PSBTN_APPLYNOW* = 4
-  PSBTN_BACK* = 0
-  PSBTN_CANCEL* = 5
-  PSBTN_FINISH* = 2
-  PSBTN_HELP* = 6
-  PSBTN_NEXT* = 1
-  PSBTN_OK* = 3
-  PSWIZB_BACK* = 1
-  PSWIZB_NEXT* = 2
-  PSWIZB_FINISH* = 4
-  PSWIZB_DISABLEDFINISH* = 8
-  ID_PSREBOOTSYSTEM* = 3
-  ID_PSRESTARTWINDOWS* = 2
-  WIZ_BODYCX* = 184
-  WIZ_BODYX* = 92
-  WIZ_CXBMP* = 80
-  WIZ_CXDLG* = 276
-  WIZ_CYDLG* = 140            # VX_FIXEDFILEINFO structure
-                              # was #define dname def_expr
-
-proc VS_FILE_INFO*(): LPTSTR
-  # return type might be wrong
-const
-  VS_VERSION_INFO* = 1
-  VS_FF_DEBUG* = 0x00000001
-  VS_FF_INFOINFERRED* = 0x00000010
-  VS_FF_PATCHED* = 0x00000004
-  VS_FF_PRERELEASE* = 0x00000002
-  VS_FF_PRIVATEBUILD* = 0x00000008
-  VS_FF_SPECIALBUILD* = 0x00000020
-  VOS_UNKNOWN* = 0
-  VOS_DOS* = 0x00010000
-  VOS_OS216* = 0x00020000
-  VOS_OS232* = 0x00030000
-  VOS_NT* = 0x00040000
-  VOS_DOS_WINDOWS16* = 0x00010001
-  VOS_DOS_WINDOWS32* = 0x00010004
-  VOS_OS216_PM16* = 0x00020002
-  VOS_OS232_PM32* = 0x00030003
-  VOS_NT_WINDOWS32* = 0x00040004
-  VFT_UNKNOWN* = 0
-  VFT_APP* = 0x00000001
-  VFT_DLL* = 0x00000002
-  VFT_DRV* = 0x00000003
-  VFT_FONT* = 0x00000004
-  VFT_VXD* = 0x00000005
-  VFT_STATIC_LIB* = 0x00000007
-  VFT2_UNKNOWN* = 0
-  VFT2_DRV_PRINTER* = 0x00000001
-  VFT2_DRV_KEYBOARD* = 0x00000002
-  VFT2_DRV_LANGUAGE* = 0x00000003
-  VFT2_DRV_DISPLAY* = 0x00000004
-  VFT2_DRV_MOUSE* = 0x00000005
-  VFT2_DRV_NETWORK* = 0x00000006
-  VFT2_DRV_SYSTEM* = 0x00000007
-  VFT2_DRV_INSTALLABLE* = 0x00000008
-  VFT2_DRV_SOUND* = 0x00000009
-  VFT2_FONT_RASTER* = 0x00000001
-  VFT2_FONT_VECTOR* = 0x00000002
-  VFT2_FONT_TRUETYPE* = 0x00000003 # PANOSE structure
-  PAN_ANY* = 0
-  PAN_NO_FIT* = 1
-  PAN_FAMILY_TEXT_DISPLAY* = 2
-  PAN_FAMILY_SCRIPT* = 3
-  PAN_FAMILY_DECORATIVE* = 4
-  PAN_FAMILY_PICTORIAL* = 5
-  PAN_SERIF_COVE* = 2
-  PAN_SERIF_OBTUSE_COVE* = 3
-  PAN_SERIF_SQUARE_COVE* = 4
-  PAN_SERIF_OBTUSE_SQUARE_COVE* = 5
-  PAN_SERIF_SQUARE* = 6
-  PAN_SERIF_THIN* = 7
-  PAN_SERIF_BONE* = 8
-  PAN_SERIF_EXAGGERATED* = 9
-  PAN_SERIF_TRIANGLE* = 10
-  PAN_SERIF_NORMAL_SANS* = 11
-  PAN_SERIF_OBTUSE_SANS* = 12
-  PAN_SERIF_PERP_SANS* = 13
-  PAN_SERIF_FLARED* = 14
-  PAN_SERIF_ROUNDED* = 15
-  PAN_WEIGHT_VERY_LIGHT* = 2
-  PAN_WEIGHT_LIGHT* = 3
-  PAN_WEIGHT_THIN* = 4
-  PAN_WEIGHT_BOOK* = 5
-  PAN_WEIGHT_MEDIUM* = 6
-  PAN_WEIGHT_DEMI* = 7
-  PAN_WEIGHT_BOLD* = 8
-  PAN_WEIGHT_HEAVY* = 9
-  PAN_WEIGHT_BLACK* = 10
-  PAN_WEIGHT_NORD* = 11
-  PAN_PROP_OLD_STYLE* = 2
-  PAN_PROP_MODERN* = 3
-  PAN_PROP_EVEN_WIDTH* = 4
-  PAN_PROP_EXPANDED* = 5
-  PAN_PROP_CONDENSED* = 6
-  PAN_PROP_VERY_EXPANDED* = 7
-  PAN_PROP_VERY_CONDENSED* = 8
-  PAN_PROP_MONOSPACED* = 9
-  PAN_CONTRAST_NONE* = 2
-  PAN_CONTRAST_VERY_LOW* = 3
-  PAN_CONTRAST_LOW* = 4
-  PAN_CONTRAST_MEDIUM_LOW* = 5
-  PAN_CONTRAST_MEDIUM* = 6
-  PAN_CONTRAST_MEDIUM_HIGH* = 7
-  PAN_CONTRAST_HIGH* = 8
-  PAN_CONTRAST_VERY_HIGH* = 9
-  PAN_STROKE_GRADUAL_DIAG* = 2
-  PAN_STROKE_GRADUAL_TRAN* = 3
-  PAN_STROKE_GRADUAL_VERT* = 4
-  PAN_STROKE_GRADUAL_HORZ* = 5
-  PAN_STROKE_RAPID_VERT* = 6
-  PAN_STROKE_RAPID_HORZ* = 7
-  PAN_STROKE_INSTANT_VERT* = 8
-  PAN_STRAIGHT_ARMS_HORZ* = 2
-  PAN_STRAIGHT_ARMS_WEDGE* = 3
-  PAN_STRAIGHT_ARMS_VERT* = 4
-  PAN_STRAIGHT_ARMS_SINGLE_SERIF* = 5
-  PAN_STRAIGHT_ARMS_DOUBLE_SERIF* = 6
-  PAN_BENT_ARMS_HORZ* = 7
-  PAN_BENT_ARMS_VERT* = 9
-  PAN_BENT_ARMS_WEDGE* = 8
-  PAN_BENT_ARMS_SINGLE_SERIF* = 10
-  PAN_BENT_ARMS_DOUBLE_SERIF* = 11
-  PAN_LETT_NORMAL_CONTACT* = 2
-  PAN_LETT_NORMAL_WEIGHTED* = 3
-  PAN_LETT_NORMAL_BOXED* = 4
-  PAN_LETT_NORMAL_FLATTENED* = 5
-  PAN_LETT_NORMAL_ROUNDED* = 6
-  PAN_LETT_NORMAL_OFF_CENTER* = 7
-  PAN_LETT_NORMAL_SQUARE* = 8
-  PAN_LETT_OBLIQUE_CONTACT* = 9
-  PAN_LETT_OBLIQUE_WEIGHTED* = 10
-  PAN_LETT_OBLIQUE_BOXED* = 11
-  PAN_LETT_OBLIQUE_FLATTENED* = 12
-  PAN_LETT_OBLIQUE_ROUNDED* = 13
-  PAN_LETT_OBLIQUE_OFF_CENTER* = 14
-  PAN_LETT_OBLIQUE_SQUARE* = 15
-  PAN_MIDLINE_STANDARD_TRIMMED* = 2
-  PAN_MIDLINE_STANDARD_POINTED* = 3
-  PAN_MIDLINE_STANDARD_SERIFED* = 4
-  PAN_MIDLINE_HIGH_TRIMMED* = 5
-  PAN_MIDLINE_HIGH_POINTED* = 6
-  PAN_MIDLINE_HIGH_SERIFED* = 7
-  PAN_MIDLINE_CONSTANT_TRIMMED* = 8
-  PAN_MIDLINE_CONSTANT_POINTED* = 9
-  PAN_MIDLINE_CONSTANT_SERIFED* = 10
-  PAN_MIDLINE_LOW_TRIMMED* = 11
-  PAN_MIDLINE_LOW_POINTED* = 12
-  PAN_MIDLINE_LOW_SERIFED* = 13
-  PAN_XHEIGHT_CONSTANT_SMALL* = 2
-  PAN_XHEIGHT_CONSTANT_STD* = 3
-  PAN_XHEIGHT_CONSTANT_LARGE* = 4
-  PAN_XHEIGHT_DUCKING_SMALL* = 5
-  PAN_XHEIGHT_DUCKING_STD* = 6
-  PAN_XHEIGHT_DUCKING_LARGE* = 7 # PALETTENTRY structure
-  PC_EXPLICIT* = 2
-  PC_NOCOLLAPSE* = 4
-  PC_RESERVED* = 1            # LOGBRUSH structure
-  BS_DIBPATTERN* = 5
-  BS_DIBPATTERN8X8* = 8
-  BS_DIBPATTERNPT* = 6
-  BS_HATCHED* = 2
-  BS_HOLLOW* = 1
-  BS_NULL* = 1
-  BS_PATTERN* = 3
-  BS_PATTERN8X8* = 7
-  BS_SOLID* = 0               # DEVMODE structure
-  DM_ORIENTATION* = 0x00000001
-  DM_PAPERSIZE* = 0x00000002
-  DM_PAPERLENGTH* = 0x00000004
-  DM_PAPERWIDTH* = 0x00000008
-  DM_SCALE* = 0x00000010
-  DM_COPIES* = 0x00000100
-  DM_DEFAULTSOURCE* = 0x00000200
-  DM_PRINTQUALITY* = 0x00000400
-  DM_COLOR* = 0x00000800
-  DM_DUPLEX* = 0x00001000
-  DM_YRESOLUTION* = 0x00002000
-  DM_TTOPTION* = 0x00004000
-  DM_COLLATE* = 0x00008000
-  DM_FORMNAME* = 0x00010000
-  DM_LOGPIXELS* = 0x00020000  #DM_BITSPERPEL = $40000;
-                              #     DM_PELSWIDTH = $80000;
-                              #     DM_PELSHEIGHT = $100000;
-                              #     DM_DISPLAYFLAGS = $200000;
-                              #     DM_DISPLAYFREQUENCY = $400000;already above
-  DM_ICMMETHOD* = 0x00800000
-  DM_ICMINTENT* = 0x01000000
-  DM_MEDIATYPE* = 0x02000000
-  DM_DITHERTYPE* = 0x04000000
-  DMORIENT_LANDSCAPE* = 2
-  DMORIENT_PORTRAIT* = 1
-  DMPAPER_LETTER* = 1
-  DMPAPER_LEGAL* = 5
-  DMPAPER_A4* = 9
-  DMPAPER_CSHEET* = 24
-  DMPAPER_DSHEET* = 25
-  DMPAPER_ESHEET* = 26
-  DMPAPER_LETTERSMALL* = 2
-  DMPAPER_TABLOID* = 3
-  DMPAPER_LEDGER* = 4
-  DMPAPER_STATEMENT* = 6
-  DMPAPER_EXECUTIVE* = 7
-  DMPAPER_A3* = 8
-  DMPAPER_A4SMALL* = 10
-  DMPAPER_A5* = 11
-  DMPAPER_B4* = 12
-  DMPAPER_B5* = 13
-  DMPAPER_FOLIO* = 14
-  DMPAPER_QUARTO* = 15
-  DMPAPER_10X14* = 16
-  DMPAPER_11X17* = 17
-  DMPAPER_NOTE* = 18
-  DMPAPER_ENV_9* = 19
-  DMPAPER_ENV_10* = 20
-  DMPAPER_ENV_11* = 21
-  DMPAPER_ENV_12* = 22
-  DMPAPER_ENV_14* = 23
-  DMPAPER_ENV_DL* = 27
-  DMPAPER_ENV_C5* = 28
-  DMPAPER_ENV_C3* = 29
-  DMPAPER_ENV_C4* = 30
-  DMPAPER_ENV_C6* = 31
-  DMPAPER_ENV_C65* = 32
-  DMPAPER_ENV_B4* = 33
-  DMPAPER_ENV_B5* = 34
-  DMPAPER_ENV_B6* = 35
-  DMPAPER_ENV_ITALY* = 36
-  DMPAPER_ENV_MONARCH* = 37
-  DMPAPER_ENV_PERSONAL* = 38
-  DMPAPER_FANFOLD_US* = 39
-  DMPAPER_FANFOLD_STD_GERMAN* = 40
-  DMPAPER_FANFOLD_LGL_GERMAN* = 41
-  DMRES_HIGH* = - (4)
-  DMRES_MEDIUM* = - (3)
-  DMRES_LOW* = - (2)
-  DMRES_DRAFT* = - (1)
-  DMCOLOR_COLOR* = 2
-  DMCOLOR_MONOCHROME* = 1
-  DMDUP_SIMPLEX* = 1
-  DMDUP_HORIZONTAL* = 3
-  DMDUP_VERTICAL* = 2
-  DMTT_BITMAP* = 1
-  DMTT_DOWNLOAD* = 2
-  DMTT_SUBDEV* = 3
-  DMCOLLATE_TRUE* = 1
-  DMCOLLATE_FALSE* = 0
-  DM_GRAYSCALE* = 1
-  DM_INTERLACED* = 2
-  DMICMMETHOD_NONE* = 1
-  DMICMMETHOD_SYSTEM* = 2
-  DMICMMETHOD_DRIVER* = 3
-  DMICMMETHOD_DEVICE* = 4
-  DMICMMETHOD_USER* = 256
-  DMICM_SATURATE* = 1
-  DMICM_CONTRAST* = 2
-  DMICM_COLORMETRIC* = 3
-  DMICM_USER* = 256
-  DMMEDIA_STANDARD* = 1
-  DMMEDIA_GLOSSY* = 3
-  DMMEDIA_TRANSPARENCY* = 2
-  DMMEDIA_USER* = 256
-  DMDITHER_NONE* = 1
-  DMDITHER_COARSE* = 2
-  DMDITHER_FINE* = 3
-  DMDITHER_LINEART* = 4
-  DMDITHER_GRAYSCALE* = 10
-  DMDITHER_USER* = 256        # RGNDATAHEADER structure
-  RDH_RECTANGLES* = 1         # TTPOLYGONHEADER structure
-  TT_POLYGON_TYPE* = 24       # TTPOLYCURVE structure
-  TT_PRIM_LINE* = 1
-  TT_PRIM_QSPLINE* = 2        # GCP_RESULTS structure
-  GCPCLASS_ARABIC* = 2
-  GCPCLASS_HEBREW* = 2
-  GCPCLASS_LATIN* = 1
-  GCPCLASS_LATINNUMBER* = 5
-  GCPCLASS_LOCALNUMBER* = 4
-  GCPCLASS_LATINNUMERICSEPARATOR* = 7
-  GCPCLASS_LATINNUMERICTERMINATOR* = 6
-  GCPCLASS_NEUTRAL* = 3
-  GCPCLASS_NUMERICSEPARATOR* = 8
-  GCPCLASS_PREBOUNDLTR* = 128
-  GCPCLASS_PREBOUNDRTL* = 64
-  GCPCLASS_POSTBOUNDLTR* = 32
-  GCPCLASS_POSTBOUNDRTL* = 16
-  GCPGLYPH_LINKBEFORE* = 32768
-  GCPGLYPH_LINKAFTER* = 16384 # RASTERIZER_STATUS structure
-  TT_AVAILABLE* = 1
-  TT_ENABLED* = 2             # COLORADJUSTMENT structure
-  CA_NEGATIVE* = 1
-  CA_LOG_FILTER* = 2
-  ILLUMINANT_DEVICE_DEFAULT* = 0
-  ILLUMINANT_A* = 1
-  ILLUMINANT_B* = 2
-  ILLUMINANT_C* = 3
-  ILLUMINANT_D50* = 4
-  ILLUMINANT_D55* = 5
-  ILLUMINANT_D65* = 6
-  ILLUMINANT_D75* = 7
-  ILLUMINANT_F2* = 8
-  ILLUMINANT_TUNGSTEN* = 1
-  ILLUMINANT_DAYLIGHT* = 3
-  ILLUMINANT_FLUORESCENT* = 8
-  ILLUMINANT_NTSC* = 3        # DOCINFO structure
-  DI_APPBANDING* = 1          # EMRMETAHEADER structure
-  EMR_HEADER* = 1
-  ENHMETA_SIGNATURE* = 1179469088 # RTF event masks
-  ENM_CHANGE* = 1
-  ENM_CORRECTTEXT* = 4194304
-  ENM_DROPFILES* = 1048576
-  ENM_KEYEVENTS* = 65536
-  ENM_MOUSEEVENTS* = 131072
-  ENM_PROTECTED* = 2097152
-  ENM_REQUESTRESIZE* = 262144
-  ENM_SCROLL* = 4
-  ENM_SELCHANGE* = 524288
-  ENM_UPDATE* = 2
-  ENM_NONE* = 0               # RTF styles
-  ES_DISABLENOSCROLL* = 8192
-  ES_EX_NOCALLOLEINIT* = 16777216
-  ES_NOIME* = 524288
-  ES_SAVESEL* = 32768
-  ES_SELFIME* = 262144
-  ES_SUNKEN* = 16384
-  ES_VERTICAL* = 4194304
-  ES_SELECTIONBAR* = 16777216 # EM_SETOPTIONS message
-  ECOOP_SET* = 1
-  ECOOP_OR* = 2
-  ECOOP_AND* = 3
-  ECOOP_XOR* = 4
-  ECO_AUTOWORDSELECTION* = 1
-  ECO_AUTOVSCROLL* = 64
-  ECO_AUTOHSCROLL* = 128
-  ECO_NOHIDESEL* = 256
-  ECO_READONLY* = 2048
-  ECO_WANTRETURN* = 4096
-  ECO_SAVESEL* = 32768
-  ECO_SELECTIONBAR* = 16777216
-  ECO_VERTICAL* = 4194304     # EM_SETCHARFORMAT message
-  SCF_WORD* = 2
-  SCF_SELECTION* = 1          # EM_STREAMOUT message
-  SF_TEXT* = 1
-  SF_RTF* = 2
-  SF_RTFNOOBJS* = 3
-  SF_TEXTIZED* = 4
-  SFF_SELECTION* = 32768
-  SFF_PLAINRTF* = 16384       # EM_FINDWORDBREAK message
-  WB_CLASSIFY* = 3            #WB_ISDELIMITER = 2;
-                              #     WB_LEFT = 0; already above
-  WB_LEFTBREAK* = 6
-  WB_PREVBREAK* = 6
-  WB_MOVEWORDLEFT* = 4
-  WB_MOVEWORDPREV* = 4
-  WB_MOVEWORDRIGHT* = 5
-  WB_MOVEWORDNEXT* = 5        #WB_RIGHT = 1;already above
-  WB_RIGHTBREAK* = 7
-  WB_NEXTBREAK* = 7           # EM_GETPUNCTUATION message
-  PC_LEADING* = 2
-  PC_FOLLOWING* = 1
-  PC_DELIMITER* = 4
-  PC_OVERFLOW* = 3            # EM_SETWORDWRAPMODE message
-  WBF_WORDWRAP* = 16
-  WBF_WORDBREAK* = 32
-  WBF_OVERFLOW* = 64
-  WBF_LEVEL1* = 128
-  WBF_LEVEL2* = 256
-  WBF_CUSTOM* = 512
-  WBF_BREAKAFTER* = 64
-  WBF_BREAKLINE* = 32
-  WBF_ISWHITE* = 16           # CHARFORMAT structure
-  CFM_BOLD* = 1
-  CFM_COLOR* = 1073741824
-  CFM_FACE* = 536870912
-  CFM_ITALIC* = 2
-  CFM_OFFSET* = 268435456
-  CFM_PROTECTED* = 16
-  CFM_SIZE* = 0x80000000
-  CFM_STRIKEOUT* = 8
-  CFM_UNDERLINE* = 4
-  CFE_AUTOCOLOR* = 1073741824
-  CFE_BOLD* = 1
-  CFE_ITALIC* = 2
-  CFE_STRIKEOUT* = 8
-  CFE_UNDERLINE* = 4
-  CFE_PROTECTED* = 16         # PARAFORMAT structure
-  PFM_ALIGNMENT* = 8
-  PFM_NUMBERING* = 32
-  PFM_OFFSET* = 4
-  PFM_OFFSETINDENT* = 0x80000000
-  PFM_RIGHTINDENT* = 2
-  PFM_STARTINDENT* = 1
-  PFM_TABSTOPS* = 16
-  PFN_BULLET* = 1
-  PFA_LEFT* = 1
-  PFA_RIGHT* = 2
-  PFA_CENTER* = 3             # SELCHANGE structure
-  SEL_EMPTY* = 0
-  SEL_TEXT* = 1
-  SEL_OBJECT* = 2
-  SEL_MULTICHAR* = 4
-  SEL_MULTIOBJECT* = 8        # RTF clipboard formats
-  CF_RTF* = "Rich Text Format"
-  CF_RETEXTOBJ* = "RichEdit Text and Objects" # DRAWITEMSTRUCT structure
-  ODT_BUTTON* = 4
-  ODT_COMBOBOX* = 3
-  ODT_LISTBOX* = 2
-  ODT_LISTVIEW* = 102
-  ODT_MENU* = 1
-  ODT_STATIC* = 5
-  ODT_TAB* = 101
-  ODT_HEADER* = 100
-  ODA_DRAWENTIRE* = 1
-  ODA_FOCUS* = 4
-  ODA_SELECT* = 2
-  ODS_SELECTED* = 1
-  ODS_GRAYED* = 2
-  ODS_DISABLED* = 4
-  ODS_CHECKED* = 8
-  ODS_FOCUS* = 16
-  ODS_DEFAULT* = 32
-  ODS_HOTLIGHT* = 0x00000040
-  ODS_INACTIVE* = 0x00000080
-  ODS_NOACCEL* = 0x00000100
-  ODS_NOFOCUSRECT* = 0x00000200
-  ODS_COMBOBOXEDIT* = 0x00001000 # Common control window classes
-  ANIMATE_CLASSW* = "SysAnimate32"
-  HOTKEY_CLASSW* = "msctls_hotkey32"
-  PROGRESS_CLASSW* = "msctls_progress32"
-  STATUSCLASSNAMEW* = "msctls_statusbar32"
-  TOOLBARCLASSNAMEW* = "ToolbarWindow32"
-  TOOLTIPS_CLASSW* = "tooltips_class32"
-  TRACKBAR_CLASSW* = "msctls_trackbar32"
-  UPDOWN_CLASSW* = "msctls_updown32"
-  WC_HEADERW* = "SysHeader32"
-  WC_LISTVIEWW* = "SysListView32"
-  WC_TABCONTROLW* = "SysTabControl32"
-  WC_TREEVIEWW* = "SysTreeView32" # Common control styles
-  CCS_ADJUSTABLE* = 0x00000020
-  CCS_BOTTOM* = 0x00000003
-  CCS_NODIVIDER* = 0x00000040
-  CCS_NOMOVEY* = 0x00000002
-  CCS_NOPARENTALIGN* = 0x00000008
-  CCS_NORESIZE* = 0x00000004
-  CCS_TOP* = 0x00000001
-  ANIMATE_CLASSA* = "SysAnimate32"
-  HOTKEY_CLASSA* = "msctls_hotkey32"
-  PROGRESS_CLASSA* = "msctls_progress32"
-  STATUSCLASSNAMEA* = "msctls_statusbar32"
-  TOOLBARCLASSNAMEA* = "ToolbarWindow32"
-  TOOLTIPS_CLASSA* = "tooltips_class32"
-  TRACKBAR_CLASSA* = "msctls_trackbar32"
-  UPDOWN_CLASSA* = "msctls_updown32"
-  WC_HEADERA* = "SysHeader32"
-  WC_LISTVIEWA* = "SysListView32"
-  WC_TABCONTROLA* = "SysTabControl32"
-  WC_TREEVIEWA* = "SysTreeView32"
-
-when defined(winUnicode):
-  const
-    ANIMATE_CLASS* = ANIMATE_CLASSW
-    HOTKEY_CLASS* = HOTKEY_CLASSW
-    PROGRESS_CLASS* = PROGRESS_CLASSW
-    STATUSCLASSNAME* = STATUSCLASSNAMEW
-    TOOLBARCLASSNAME* = TOOLBARCLASSNAMEW
-    TOOLTIPS_CLASS* = TOOLTIPS_CLASSW
-    TRACKBAR_CLASS* = TRACKBAR_CLASSW
-    UPDOWN_CLASS* = UPDOWN_CLASSW
-    WC_HEADER* = WC_HEADERW
-    WC_LISTVIEW* = WC_LISTVIEWW
-    WC_TABCONTROL* = WC_TABCONTROLW
-    WC_TREEVIEW* = WC_TREEVIEWW
-else:
-  const
-    ANIMATE_CLASS* = ANIMATE_CLASSA
-    HOTKEY_CLASS* = HOTKEY_CLASSA
-    PROGRESS_CLASS* = PROGRESS_CLASSA
-    STATUSCLASSNAME* = STATUSCLASSNAMEA
-    TOOLBARCLASSNAME* = TOOLBARCLASSNAMEA
-    TOOLTIPS_CLASS* = TOOLTIPS_CLASSA
-    TRACKBAR_CLASS* = TRACKBAR_CLASSA
-    UPDOWN_CLASS* = UPDOWN_CLASSA
-    WC_HEADER* = WC_HEADERA
-    WC_LISTVIEW* = WC_LISTVIEWA
-    WC_TABCONTROL* = WC_TABCONTROLA
-    WC_TREEVIEW* = WC_TREEVIEWA
-# winUnicode
-# Header control styles
-
-const
-  HDS_BUTTONS* = 2
-  HDS_HIDDEN* = 8
-  HDS_HORZ* = 0               # HD_ITEM structure
-  HDI_BITMAP* = 16
-  HDI_FORMAT* = 4
-  HDI_HEIGHT* = 1
-  HDI_LPARAM* = 8
-  HDI_TEXT* = 2
-  HDI_WIDTH* = 1
-  HDF_CENTER* = 2
-  HDF_LEFT* = 0
-  HDF_RIGHT* = 1
-  HDF_RTLREADING* = 4
-  HDF_BITMAP* = 8192
-  HDF_OWNERDRAW* = 32768
-  HDF_STRING* = 16384
-  HDF_JUSTIFYMASK* = 3        # HD_HITTESTINFO structure
-  HHT_NOWHERE* = 1
-  HHT_ONDIVIDER* = 4
-  HHT_ONDIVOPEN* = 8
-  HHT_ONHEADER* = 2
-  HHT_TOLEFT* = 2048
-  HHT_TORIGHT* = 1024         # TBADDBITMAP structure
-                              # was #define dname def_expr
-
-proc HINST_COMMCTRL*(): HINST
-const
-  IDB_STD_LARGE_COLOR* = 1
-  IDB_STD_SMALL_COLOR* = 0
-  IDB_VIEW_LARGE_COLOR* = 5
-  IDB_VIEW_SMALL_COLOR* = 4
-  STD_COPY* = 1
-  STD_CUT* = 0
-  STD_DELETE* = 5
-  STD_FILENEW* = 6
-  STD_FILEOPEN* = 7
-  STD_FILESAVE* = 8
-  STD_FIND* = 12
-  STD_HELP* = 11
-  STD_PASTE* = 2
-  STD_PRINT* = 14
-  STD_PRINTPRE* = 9
-  STD_PROPERTIES* = 10
-  STD_REDOW* = 4
-  STD_REPLACE* = 13
-  STD_UNDO* = 3
-  VIEW_LARGEICONS* = 0
-  VIEW_SMALLICONS* = 1
-  VIEW_LIST* = 2
-  VIEW_DETAILS* = 3
-  VIEW_SORTNAME* = 4
-  VIEW_SORTSIZE* = 5
-  VIEW_SORTDATE* = 6
-  VIEW_SORTTYPE* = 7          # Toolbar styles
-  TBSTYLE_ALTDRAG* = 1024
-  TBSTYLE_TOOLTIPS* = 256
-  TBSTYLE_WRAPABLE* = 512
-  TBSTYLE_BUTTON* = 0
-  TBSTYLE_CHECK* = 2
-  TBSTYLE_CHECKGROUP* = 6
-  TBSTYLE_GROUP* = 4
-  TBSTYLE_SEP* = 1            # Toolbar states
-  TBSTATE_CHECKED* = 1
-  TBSTATE_ENABLED* = 4
-  TBSTATE_HIDDEN* = 8
-  TBSTATE_INDETERMINATE* = 16
-  TBSTATE_PRESSED* = 2
-  TBSTATE_WRAP* = 32          # Tooltip styles
-  TTS_ALWAYSTIP* = 1
-  TTS_NOPREFIX* = 2           # TOOLINFO structure
-  TTF_IDISHWND* = 1
-  TTF_CENTERTIP* = 2
-  TTF_RTLREADING* = 4
-  TTF_SUBCLASS* = 16          # TTM_SETDELAYTIME message
-  TTDT_AUTOMATIC* = 0
-  TTDT_AUTOPOP* = 2
-  TTDT_INITIAL* = 3
-  TTDT_RESHOW* = 1            # Status window
-  SBARS_SIZEGRIP* = 256       #SBARS_SIZEGRIP = 256;already above
-                              # DL_DRAGGING message
-  DL_MOVECURSOR* = 3
-  DL_COPYCURSOR* = 2
-  DL_STOPCURSOR* = 1          # Up-down control styles
-  UDS_ALIGNLEFT* = 8
-  UDS_ALIGNRIGHT* = 4
-  UDS_ARROWKEYS* = 32
-  UDS_AUTOBUDDY* = 16
-  UDS_HORZ* = 64
-  UDS_NOTHOUSANDS* = 128
-  UDS_SETBUDDYINT* = 2
-  UDS_WRAP* = 1               # UDM_SETRANGE message
-  UD_MAXVAL* = 32767
-  UD_MINVAL* = - (32767)      # HKM_GETHOTKEY message
-  HOTKEYF_ALT* = 4
-  HOTKEYF_CONTROL* = 2
-  HOTKEYF_EXT* = 8
-  HOTKEYF_SHIFT* = 1          # HKM_SETRULES message
-  HKCOMB_A* = 8
-  HKCOMB_C* = 4
-  HKCOMB_CA* = 64
-  HKCOMB_NONE* = 1
-  HKCOMB_S* = 2
-  HKCOMB_SA* = 32
-  HKCOMB_SC* = 16
-  HKCOMB_SCA* = 128           # Trackbar styles
-  TBS_HORZ* = 0
-  TBS_VERT* = 2
-  TBS_AUTOTICKS* = 1
-  TBS_NOTICKS* = 16
-  TBS_TOP* = 4
-  TBS_BOTTOM* = 0
-  TBS_LEFT* = 4
-  TBS_RIGHT* = 0
-  TBS_BOTH* = 8
-  TBS_ENABLESELRANGE* = 32
-  TBS_FIXEDLENGTH* = 64
-  TBS_NOTHUMB* = 128
-  TB_BOTTOM* = 7
-  TB_ENDTRACK* = 8
-  TB_LINEDOWN* = 1
-  TB_LINEUP* = 0
-  TB_PAGEDOWN* = 3
-  TB_PAGEUP* = 2
-  TB_THUMBPOSITION* = 4
-  TB_THUMBTRACK* = 5
-  TB_TOP* = 6                 # List view styles
-  LVS_ALIGNLEFT* = 2048
-  LVS_ALIGNTOP* = 0
-  LVS_AUTOARRANGE* = 256
-  LVS_EDITLABELS* = 512
-  LVS_ICON* = 0
-  LVS_LIST* = 3
-  LVS_NOCOLUMNHEADER* = 16384
-  LVS_NOLABELWRAP* = 128
-  LVS_NOSCROLL* = 8192
-  LVS_NOSORTHEADER* = 32768
-  LVS_OWNERDRAWFIXED* = 1024
-  LVS_REPORT* = 1
-  LVS_SHAREIMAGELISTS* = 64
-  LVS_SHOWSELALWAYS* = 8
-  LVS_SINGLESEL* = 4
-  LVS_SMALLICON* = 2
-  LVS_SORTASCENDING* = 16
-  LVS_SORTDESCENDING* = 32
-  LVS_TYPESTYLEMASK* = 64512
-  LVSIL_NORMAL* = 0
-  LVSIL_SMALL* = 1
-  LVSIL_STATE* = 2
-  LVIS_CUT* = 4
-  LVIS_DROPHILITED* = 8
-  LVIS_FOCUSED* = 1
-  LVIS_SELECTED* = 2
-  LVIS_OVERLAYMASK* = 3840
-  LVIS_STATEIMAGEMASK* = 61440 # was #define dname def_expr
-
-proc LPSTR_TEXTCALLBACKW*(): LPWSTR
-  # was #define dname def_expr
-proc LPSTR_TEXTCALLBACKA*(): LPSTR
-when defined(winUnicode):
-  proc LPSTR_TEXTCALLBACK*(): LPWSTR
-else:
-  proc LPSTR_TEXTCALLBACK*(): LPSTR
-const
-  LVIF_TEXT* = 1
-  LVIF_IMAGE* = 2
-  LVIF_PARAM* = 4
-  LVIF_STATE* = 8
-  LVIF_DI_SETITEM* = 4096     # LVM_GETNEXTITEM structure
-  LVNI_ABOVE* = 256
-  LVNI_ALL* = 0
-  LVNI_BELOW* = 512
-  LVNI_TOLEFT* = 1024
-  LVNI_TORIGHT* = 2048
-  LVNI_CUT* = 4
-  LVNI_DROPHILITED* = 8
-  LVNI_FOCUSED* = 1
-  LVNI_SELECTED* = 2          # LV_FINDINFO structure
-  LVFI_PARAM* = 1
-  LVFI_PARTIAL* = 8
-  LVFI_STRING* = 2
-  LVFI_WRAP* = 32
-  LVFI_NEARESTXY* = 64        # LV_HITTESTINFO structure
-  LVHT_ABOVE* = 8
-  LVHT_BELOW* = 16
-  LVHT_NOWHERE* = 1
-  LVHT_ONITEMICON* = 2
-  LVHT_ONITEMLABEL* = 4
-  LVHT_ONITEMSTATEICON* = 8
-  LVHT_TOLEFT* = 64
-  LVHT_TORIGHT* = 32          # LV_COLUMN structure
-  LVCF_FMT* = 1
-  LVCF_SUBITEM* = 8
-  LVCF_TEXT* = 4
-  LVCF_WIDTH* = 2
-  LVCFMT_CENTER* = 2
-  LVCFMT_LEFT* = 0
-  LVCFMT_RIGHT* = 1           # ListView_GetItemRect
-  LVIR_BOUNDS* = 0
-  LVIR_ICON* = 1
-  LVIR_LABEL* = 2
-  LVIR_SELECTBOUNDS* = 3      # LVM_ARRANGE message
-  LVA_ALIGNLEFT* = 1
-  LVA_ALIGNTOP* = 2
-  LVA_DEFAULT* = 0
-  LVA_SNAPTOGRID* = 5         # LVM_SETCOLUMNWIDTH message
-  LVSCW_AUTOSIZE* = - (1)
-  LVSCW_AUTOSIZE_USEHEADER* = - (2) # Tree View styles
-  TVS_DISABLEDRAGDROP* = 16
-  TVS_EDITLABELS* = 8
-  TVS_HASBUTTONS* = 1
-  TVS_HASLINES* = 2
-  TVS_LINESATROOT* = 4
-  TVS_SHOWSELALWAYS* = 32     # Tree View states
-  TVIS_BOLD* = 16
-  TVIS_CUT* = 4
-  TVIS_DROPHILITED* = 8
-  TVIS_EXPANDED* = 32
-  TVIS_EXPANDEDONCE* = 64
-  TVIS_FOCUSED* = 1
-  TVIS_OVERLAYMASK* = 3840
-  TVIS_SELECTED* = 2
-  TVIS_STATEIMAGEMASK* = 61440
-  TVIS_USERMASK* = 61440      # TV_ITEM structure
-  TVIF_CHILDREN* = 64
-  TVIF_HANDLE* = 16
-  TVIF_IMAGE* = 2
-  TVIF_PARAM* = 4
-  TVIF_SELECTEDIMAGE* = 32
-  TVIF_STATE* = 8
-  TVIF_TEXT* = 1
-  I_CHILDRENCALLBACK* = - (1)
-  I_IMAGECALLBACK* = - (1)    # TV_INSERTSTRUCT structure
-                              # added manually PM, TREEITEM is not defined in the C headers
-
-type
-  TTREEITEM* {.final, pure.} = object
-  HTREEITEM* = ptr TTREEITEM
-  PTREEITEM* = ptr TTREEITEM
-
-proc TVI_ROOT*(): HTREEITEM
-  # was #define dname def_expr
-proc TVI_FIRST*(): HTREEITEM
-  # was #define dname def_expr
-proc TVI_LAST*(): HTREEITEM
-  # was #define dname def_expr
-proc TVI_SORT*(): HTREEITEM
-  # TV_HITTESTINFO structure
-const
-  TVHT_ABOVE* = 256
-  TVHT_BELOW* = 512
-  TVHT_NOWHERE* = 1
-  TVHT_ONITEM* = 70
-  TVHT_ONITEMBUTTON* = 16
-  TVHT_ONITEMICON* = 2
-  TVHT_ONITEMINDENT* = 8
-  TVHT_ONITEMLABEL* = 4
-  TVHT_ONITEMRIGHT* = 32
-  TVHT_ONITEMSTATEICON* = 64
-  TVHT_TOLEFT* = 2048
-  TVHT_TORIGHT* = 1024        # TVM_EXPAND message
-  TVE_COLLAPSE* = 1
-  TVE_COLLAPSERESET* = 32768
-  TVE_EXPAND* = 2
-  TVE_TOGGLE* = 3             # TVM_GETIMAGELIST message
-  TVSIL_NORMAL* = 0
-  TVSIL_STATE* = 2            # TVM_GETNEXTITEM message
-  TVGN_CARET* = 9
-  TVGN_CHILD* = 4
-  TVGN_DROPHILITE* = 8
-  TVGN_FIRSTVISIBLE* = 5
-  TVGN_NEXT* = 1
-  TVGN_NEXTVISIBLE* = 6
-  TVGN_PARENT* = 3
-  TVGN_PREVIOUS* = 2
-  TVGN_PREVIOUSVISIBLE* = 7
-  TVGN_ROOT* = 0              # TVN_SELCHANGED message
-  TVC_BYKEYBOARD* = 2
-  TVC_BYMOUSE* = 1
-  TVC_UNKNOWN* = 0            # Tab control styles
-  TCS_BUTTONS* = 256
-  TCS_FIXEDWIDTH* = 1024
-  TCS_FOCUSNEVER* = 32768
-  TCS_FOCUSONBUTTONDOWN* = 4096
-  TCS_FORCEICONLEFT* = 16
-  TCS_FORCELABELLEFT* = 32
-  TCS_MULTILINE* = 512
-  TCS_OWNERDRAWFIXED* = 8192
-  TCS_RAGGEDRIGHT* = 2048
-  TCS_RIGHTJUSTIFY* = 0
-  TCS_SINGLELINE* = 0
-  TCS_TABS* = 0
-  TCS_TOOLTIPS* = 16384       # TC_ITEM structure
-  TCIF_TEXT* = 1
-  TCIF_IMAGE* = 2
-  TCIF_PARAM* = 8
-  TCIF_RTLREADING* = 4        # TC_HITTESTINFO structure
-  TCHT_NOWHERE* = 1
-  TCHT_ONITEM* = 6
-  TCHT_ONITEMICON* = 2
-  TCHT_ONITEMLABEL* = 4       # Animation control styles
-  ACS_AUTOPLAY* = 4
-  ACS_CENTER* = 1
-  ACS_TRANSPARENT* = 2        # MODEMDEVCAPS structure
-  DIALOPTION_BILLING* = 64
-  DIALOPTION_QUIET* = 128
-  DIALOPTION_DIALTONE* = 256
-  MDMVOLFLAG_LOW* = 1
-  MDMVOLFLAG_MEDIUM* = 2
-  MDMVOLFLAG_HIGH* = 4
-  MDMVOL_LOW* = 0
-  MDMVOL_MEDIUM* = 1
-  MDMVOL_HIGH* = 2
-  MDMSPKRFLAG_OFF* = 1
-  MDMSPKRFLAG_DIAL* = 2
-  MDMSPKRFLAG_ON* = 4
-  MDMSPKRFLAG_CALLSETUP* = 8
-  MDMSPKR_OFF* = 0
-  MDMSPKR_DIAL* = 1
-  MDMSPKR_ON* = 2
-  MDMSPKR_CALLSETUP* = 3
-  MDM_BLIND_DIAL* = 512
-  MDM_CCITT_OVERRIDE* = 64
-  MDM_CELLULAR* = 8
-  MDM_COMPRESSION* = 1
-  MDM_ERROR_CONTROL* = 2
-  MDM_FLOWCONTROL_HARD* = 16
-  MDM_FLOWCONTROL_SOFT* = 32
-  MDM_FORCED_EC* = 4
-  MDM_SPEED_ADJUST* = 128
-  MDM_TONE_DIAL* = 256
-  MDM_V23_OVERRIDE* = 1024 # Languages
-                           #
-                           #  Language IDs.
-                           #
-                           #  The following two combinations of primary language ID and
-                           #  sublanguage ID have special semantics:
-                           #
-                           #    Primary Language ID   Sublanguage ID      Result
-                           #    -------------------   ---------------     ------------------------
-                           #    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
-                           #    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
-                           #    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
-                           #    LANG_INVARIANT        SUBLANG_NEUTRAL     Invariant locale
-                           #
-                           #
-                           #  Primary language IDs.
-                           #
-  LANG_NEUTRAL* = 0x00000000
-  LANG_INVARIANT* = 0x0000007F
-  LANG_AFRIKAANS* = 0x00000036
-  LANG_ALBANIAN* = 0x0000001C
-  LANG_ARABIC* = 0x00000001
-  LANG_ARMENIAN* = 0x0000002B
-  LANG_ASSAMESE* = 0x0000004D
-  LANG_AZERI* = 0x0000002C
-  LANG_BASQUE* = 0x0000002D
-  LANG_BELARUSIAN* = 0x00000023
-  LANG_BENGALI* = 0x00000045
-  LANG_BULGARIAN* = 0x00000002
-  LANG_CATALAN* = 0x00000003
-  LANG_CHINESE* = 0x00000004
-  LANG_CROATIAN* = 0x0000001A
-  LANG_CZECH* = 0x00000005
-  LANG_DANISH* = 0x00000006
-  LANG_DIVEHI* = 0x00000065
-  LANG_DUTCH* = 0x00000013
-  LANG_ENGLISH* = 0x00000009
-  LANG_ESTONIAN* = 0x00000025
-  LANG_FAEROESE* = 0x00000038
-  LANG_FARSI* = 0x00000029
-  LANG_FINNISH* = 0x0000000B
-  LANG_FRENCH* = 0x0000000C
-  LANG_GALICIAN* = 0x00000056
-  LANG_GEORGIAN* = 0x00000037
-  LANG_GERMAN* = 0x00000007
-  LANG_GREEK* = 0x00000008
-  LANG_GUJARATI* = 0x00000047
-  LANG_HEBREW* = 0x0000000D
-  LANG_HINDI* = 0x00000039
-  LANG_HUNGARIAN* = 0x0000000E
-  LANG_ICELANDIC* = 0x0000000F
-  LANG_INDONESIAN* = 0x00000021
-  LANG_ITALIAN* = 0x00000010
-  LANG_JAPANESE* = 0x00000011
-  LANG_KANNADA* = 0x0000004B
-  LANG_KASHMIRI* = 0x00000060
-  LANG_KAZAK* = 0x0000003F
-  LANG_KONKANI* = 0x00000057
-  LANG_KOREAN* = 0x00000012
-  LANG_KYRGYZ* = 0x00000040
-  LANG_LATVIAN* = 0x00000026
-  LANG_LITHUANIAN* = 0x00000027
-  LANG_MACEDONIAN* = 0x0000002F # the Former Yugoslav Republic of Macedonia
-  LANG_MALAY* = 0x0000003E
-  LANG_MALAYALAM* = 0x0000004C
-  LANG_MANIPURI* = 0x00000058
-  LANG_MARATHI* = 0x0000004E
-  LANG_MONGOLIAN* = 0x00000050
-  LANG_NEPALI* = 0x00000061
-  LANG_NORWEGIAN* = 0x00000014
-  LANG_ORIYA* = 0x00000048
-  LANG_POLISH* = 0x00000015
-  LANG_PORTUGUESE* = 0x00000016
-  LANG_PUNJABI* = 0x00000046
-  LANG_ROMANIAN* = 0x00000018
-  LANG_RUSSIAN* = 0x00000019
-  LANG_SANSKRIT* = 0x0000004F
-  LANG_SERBIAN* = 0x0000001A
-  LANG_SINDHI* = 0x00000059
-  LANG_SLOVAK* = 0x0000001B
-  LANG_SLOVENIAN* = 0x00000024
-  LANG_SPANISH* = 0x0000000A
-  LANG_SWAHILI* = 0x00000041
-  LANG_SWEDISH* = 0x0000001D
-  LANG_SYRIAC* = 0x0000005A
-  LANG_TAMIL* = 0x00000049
-  LANG_TATAR* = 0x00000044
-  LANG_TELUGU* = 0x0000004A
-  LANG_THAI* = 0x0000001E
-  LANG_TURKISH* = 0x0000001F
-  LANG_UKRAINIAN* = 0x00000022
-  LANG_URDU* = 0x00000020
-  LANG_UZBEK* = 0x00000043
-  LANG_VIETNAMESE* = 0x0000002A #
-                                #  Sublanguage IDs.
-                                #
-                                #  The name immediately following SUBLANG_ dictates which primary
-                                #  language ID that sublanguage ID can be combined with to form a
-                                #  valid language ID.
-                                #
-  SUBLANG_NEUTRAL* = 0x00000000 # language neutral
-  SUBLANG_DEFAULT* = 0x00000001 # user default
-  SUBLANG_SYS_DEFAULT* = 0x00000002 # system default
-  SUBLANG_ARABIC_SAUDI_ARABIA* = 0x00000001 # Arabic (Saudi Arabia)
-  SUBLANG_ARABIC_IRAQ* = 0x00000002 # Arabic (Iraq)
-  SUBLANG_ARABIC_EGYPT* = 0x00000003 # Arabic (Egypt)
-  SUBLANG_ARABIC_LIBYA* = 0x00000004 # Arabic (Libya)
-  SUBLANG_ARABIC_ALGERIA* = 0x00000005 # Arabic (Algeria)
-  SUBLANG_ARABIC_MOROCCO* = 0x00000006 # Arabic (Morocco)
-  SUBLANG_ARABIC_TUNISIA* = 0x00000007 # Arabic (Tunisia)
-  SUBLANG_ARABIC_OMAN* = 0x00000008 # Arabic (Oman)
-  SUBLANG_ARABIC_YEMEN* = 0x00000009 # Arabic (Yemen)
-  SUBLANG_ARABIC_SYRIA* = 0x0000000A # Arabic (Syria)
-  SUBLANG_ARABIC_JORDAN* = 0x0000000B # Arabic (Jordan)
-  SUBLANG_ARABIC_LEBANON* = 0x0000000C # Arabic (Lebanon)
-  SUBLANG_ARABIC_KUWAIT* = 0x0000000D # Arabic (Kuwait)
-  SUBLANG_ARABIC_UAE* = 0x0000000E # Arabic (U.A.E)
-  SUBLANG_ARABIC_BAHRAIN* = 0x0000000F # Arabic (Bahrain)
-  SUBLANG_ARABIC_QATAR* = 0x00000010 # Arabic (Qatar)
-  SUBLANG_AZERI_LATIN* = 0x00000001 # Azeri (Latin)
-  SUBLANG_AZERI_CYRILLIC* = 0x00000002 # Azeri (Cyrillic)
-  SUBLANG_CHINESE_TRADITIONAL* = 0x00000001 # Chinese (Taiwan)
-  SUBLANG_CHINESE_SIMPLIFIED* = 0x00000002 # Chinese (PR China)
-  SUBLANG_CHINESE_HONGKONG* = 0x00000003 # Chinese (Hong Kong S.A.R., P.R.C.)
-  SUBLANG_CHINESE_SINGAPORE* = 0x00000004 # Chinese (Singapore)
-  SUBLANG_CHINESE_MACAU* = 0x00000005 # Chinese (Macau S.A.R.)
-  SUBLANG_DUTCH* = 0x00000001 # Dutch
-  SUBLANG_DUTCH_BELGIAN* = 0x00000002 # Dutch (Belgian)
-  SUBLANG_ENGLISH_US* = 0x00000001 # English (USA)
-  SUBLANG_ENGLISH_UK* = 0x00000002 # English (UK)
-  SUBLANG_ENGLISH_AUS* = 0x00000003 # English (Australian)
-  SUBLANG_ENGLISH_CAN* = 0x00000004 # English (Canadian)
-  SUBLANG_ENGLISH_NZ* = 0x00000005 # English (New Zealand)
-  SUBLANG_ENGLISH_EIRE* = 0x00000006 # English (Irish)
-  SUBLANG_ENGLISH_SOUTH_AFRICA* = 0x00000007 # English (South Africa)
-  SUBLANG_ENGLISH_JAMAICA* = 0x00000008 # English (Jamaica)
-  SUBLANG_ENGLISH_CARIBBEAN* = 0x00000009 # English (Caribbean)
-  SUBLANG_ENGLISH_BELIZE* = 0x0000000A # English (Belize)
-  SUBLANG_ENGLISH_TRINIDAD* = 0x0000000B # English (Trinidad)
-  SUBLANG_ENGLISH_ZIMBABWE* = 0x0000000C # English (Zimbabwe)
-  SUBLANG_ENGLISH_PHILIPPINES* = 0x0000000D # English (Philippines)
-  SUBLANG_FRENCH* = 0x00000001 # French
-  SUBLANG_FRENCH_BELGIAN* = 0x00000002 # French (Belgian)
-  SUBLANG_FRENCH_CANADIAN* = 0x00000003 # French (Canadian)
-  SUBLANG_FRENCH_SWISS* = 0x00000004 # French (Swiss)
-  SUBLANG_FRENCH_LUXEMBOURG* = 0x00000005 # French (Luxembourg)
-  SUBLANG_FRENCH_MONACO* = 0x00000006 # French (Monaco)
-  SUBLANG_GERMAN* = 0x00000001 # German
-  SUBLANG_GERMAN_SWISS* = 0x00000002 # German (Swiss)
-  SUBLANG_GERMAN_AUSTRIAN* = 0x00000003 # German (Austrian)
-  SUBLANG_GERMAN_LUXEMBOURG* = 0x00000004 # German (Luxembourg)
-  SUBLANG_GERMAN_LIECHTENSTEIN* = 0x00000005 # German (Liechtenstein)
-  SUBLANG_ITALIAN* = 0x00000001 # Italian
-  SUBLANG_ITALIAN_SWISS* = 0x00000002 # Italian (Swiss)
-  SUBLANG_KASHMIRI_SASIA* = 0x00000002 # Kashmiri (South Asia)
-  SUBLANG_KASHMIRI_INDIA* = 0x00000002 # For app compatibility only
-  SUBLANG_KOREAN* = 0x00000001 # Korean (Extended Wansung)
-  SUBLANG_LITHUANIAN* = 0x00000001 # Lithuanian
-  SUBLANG_MALAY_MALAYSIA* = 0x00000001 # Malay (Malaysia)
-  SUBLANG_MALAY_BRUNEI_DARUSSALAM* = 0x00000002 # Malay (Brunei Darussalam)
-  SUBLANG_NEPALI_INDIA* = 0x00000002 # Nepali (India)
-  SUBLANG_NORWEGIAN_BOKMAL* = 0x00000001 # Norwegian (Bokmal)
-  SUBLANG_NORWEGIAN_NYNORSK* = 0x00000002 # Norwegian (Nynorsk)
-  SUBLANG_PORTUGUESE* = 0x00000002 # Portuguese
-  SUBLANG_PORTUGUESE_BRAZILIAN* = 0x00000001 # Portuguese (Brazilian)
-  SUBLANG_SERBIAN_LATIN* = 0x00000002 # Serbian (Latin)
-  SUBLANG_SERBIAN_CYRILLIC* = 0x00000003 # Serbian (Cyrillic)
-  SUBLANG_SPANISH* = 0x00000001 # Spanish (Castilian)
-  SUBLANG_SPANISH_MEXICAN* = 0x00000002 # Spanish (Mexican)
-  SUBLANG_SPANISH_MODERN* = 0x00000003 # Spanish (Spain)
-  SUBLANG_SPANISH_GUATEMALA* = 0x00000004 # Spanish (Guatemala)
-  SUBLANG_SPANISH_COSTA_RICA* = 0x00000005 # Spanish (Costa Rica)
-  SUBLANG_SPANISH_PANAMA* = 0x00000006 # Spanish (Panama)
-  SUBLANG_SPANISH_DOMINICAN_REPUBLIC* = 0x00000007 # Spanish (Dominican Republic)
-  SUBLANG_SPANISH_VENEZUELA* = 0x00000008 # Spanish (Venezuela)
-  SUBLANG_SPANISH_COLOMBIA* = 0x00000009 # Spanish (Colombia)
-  SUBLANG_SPANISH_PERU* = 0x0000000A # Spanish (Peru)
-  SUBLANG_SPANISH_ARGENTINA* = 0x0000000B # Spanish (Argentina)
-  SUBLANG_SPANISH_ECUADOR* = 0x0000000C # Spanish (Ecuador)
-  SUBLANG_SPANISH_CHILE* = 0x0000000D # Spanish (Chile)
-  SUBLANG_SPANISH_URUGUAY* = 0x0000000E # Spanish (Uruguay)
-  SUBLANG_SPANISH_PARAGUAY* = 0x0000000F # Spanish (Paraguay)
-  SUBLANG_SPANISH_BOLIVIA* = 0x00000010 # Spanish (Bolivia)
-  SUBLANG_SPANISH_EL_SALVADOR* = 0x00000011 # Spanish (El Salvador)
-  SUBLANG_SPANISH_HONDURAS* = 0x00000012 # Spanish (Honduras)
-  SUBLANG_SPANISH_NICARAGUA* = 0x00000013 # Spanish (Nicaragua)
-  SUBLANG_SPANISH_PUERTO_RICO* = 0x00000014 # Spanish (Puerto Rico)
-  SUBLANG_SWEDISH* = 0x00000001 # Swedish
-  SUBLANG_SWEDISH_FINLAND* = 0x00000002 # Swedish (Finland)
-  SUBLANG_URDU_PAKISTAN* = 0x00000001 # Urdu (Pakistan)
-  SUBLANG_URDU_INDIA* = 0x00000002 # Urdu (India)
-  SUBLANG_UZBEK_LATIN* = 0x00000001 # Uzbek (Latin)
-  SUBLANG_UZBEK_CYRILLIC* = 0x00000002 # Uzbek (Cyrillic)
-                                       #
-                                       #  Sorting IDs.
-                                       #
-  SORT_DEFAULT* = 0x00000000  # sorting default
-  SORT_JAPANESE_XJIS* = 0x00000000 # Japanese XJIS order
-  SORT_JAPANESE_UNICODE* = 0x00000001 # Japanese Unicode order
-  SORT_CHINESE_BIG5* = 0x00000000 # Chinese BIG5 order
-  SORT_CHINESE_PRCP* = 0x00000000 # PRC Chinese Phonetic order
-  SORT_CHINESE_UNICODE* = 0x00000001 # Chinese Unicode order
-  SORT_CHINESE_PRC* = 0x00000002 # PRC Chinese Stroke Count order
-  SORT_CHINESE_BOPOMOFO* = 0x00000003 # Traditional Chinese Bopomofo order
-  SORT_KOREAN_KSC* = 0x00000000 # Korean KSC order
-  SORT_KOREAN_UNICODE* = 0x00000001 # Korean Unicode order
-  SORT_GERMAN_PHONE_BOOK* = 0x00000001 # German Phone Book order
-  SORT_HUNGARIAN_DEFAULT* = 0x00000000 # Hungarian Default order
-  SORT_HUNGARIAN_TECHNICAL* = 0x00000001 # Hungarian Technical order
-  SORT_GEORGIAN_TRADITIONAL* = 0x00000000 # Georgian Traditional order
-  SORT_GEORGIAN_MODERN* = 0x00000001 # Georgian Modern order
-                                     # SYSTEM_INFO structure
-  PROCESSOR_INTEL_386* = 386
-  PROCESSOR_INTEL_486* = 486
-  PROCESSOR_INTEL_PENTIUM* = 586
-  PROCESSOR_MIPS_R4000* = 4000
-  PROCESSOR_ALPHA_21064* = 21064 # FSCTL_SET_COMPRESSION
-  COMPRESSION_FORMAT_NONE* = 0
-  COMPRESSION_FORMAT_DEFAULT* = 1
-  COMPRESSION_FORMAT_LZNT1* = 2 # TAPE_GET_DRIVE_PARAMETERS structure
-  TAPE_DRIVE_COMPRESSION* = 131072
-  TAPE_DRIVE_ECC* = 65536
-  TAPE_DRIVE_ERASE_BOP_ONLY* = 64
-  TAPE_DRIVE_ERASE_LONG* = 32
-  TAPE_DRIVE_ERASE_IMMEDIATE* = 128
-  TAPE_DRIVE_ERASE_SHORT* = 16
-  TAPE_DRIVE_FIXED* = 1
-  TAPE_DRIVE_FIXED_BLOCK* = 1024
-  TAPE_DRIVE_INITIATOR* = 4
-  TAPE_DRIVE_PADDING* = 262144
-  TAPE_DRIVE_GET_ABSOLUTE_BLK* = 1048576
-  TAPE_DRIVE_GET_LOGICAL_BLK* = 2097152
-  TAPE_DRIVE_REPORT_SMKS* = 524288
-  TAPE_DRIVE_SELECT* = 2
-  TAPE_DRIVE_SET_EOT_WZ_SIZE* = 4194304
-  TAPE_DRIVE_TAPE_CAPACITY* = 256
-  TAPE_DRIVE_TAPE_REMAINING* = 512
-  TAPE_DRIVE_VARIABLE_BLOCK* = 2048
-  TAPE_DRIVE_WRITE_PROTECT* = 4096
-  TAPE_DRIVE_ABS_BLK_IMMED* = - (2147475456)
-  TAPE_DRIVE_ABSOLUTE_BLK* = - (2147479552)
-  TAPE_DRIVE_END_OF_DATA* = - (2147418112)
-  TAPE_DRIVE_FILEMARKS* = - (2147221504)
-  TAPE_DRIVE_LOAD_UNLOAD* = - (2147483647)
-  TAPE_DRIVE_LOAD_UNLD_IMMED* = - (2147483616)
-  TAPE_DRIVE_LOCK_UNLOCK* = - (2147483644)
-  TAPE_DRIVE_LOCK_UNLK_IMMED* = - (2147483520)
-  TAPE_DRIVE_LOG_BLK_IMMED* = - (2147450880)
-  TAPE_DRIVE_LOGICAL_BLK* = - (2147467264)
-  TAPE_DRIVE_RELATIVE_BLKS* = - (2147352576)
-  TAPE_DRIVE_REVERSE_POSITION* = - (2143289344)
-  TAPE_DRIVE_REWIND_IMMEDIATE* = - (2147483640)
-  TAPE_DRIVE_SEQUENTIAL_FMKS* = - (2146959360)
-  TAPE_DRIVE_SEQUENTIAL_SMKS* = - (2145386496)
-  TAPE_DRIVE_SET_BLOCK_SIZE* = - (2147483632)
-  TAPE_DRIVE_SET_COMPRESSION* = - (2147483136)
-  TAPE_DRIVE_SET_ECC* = - (2147483392)
-  TAPE_DRIVE_SET_PADDING* = - (2147482624)
-  TAPE_DRIVE_SET_REPORT_SMKS* = - (2147481600)
-  TAPE_DRIVE_SETMARKS* = - (2146435072)
-  TAPE_DRIVE_SPACE_IMMEDIATE* = - (2139095040)
-  TAPE_DRIVE_TENSION* = - (2147483646)
-  TAPE_DRIVE_TENSION_IMMED* = - (2147483584)
-  TAPE_DRIVE_WRITE_FILEMARKS* = - (2113929216)
-  TAPE_DRIVE_WRITE_LONG_FMKS* = - (2013265920)
-  TAPE_DRIVE_WRITE_MARK_IMMED* = - (1879048192)
-  TAPE_DRIVE_WRITE_SETMARKS* = - (2130706432)
-  TAPE_DRIVE_WRITE_SHORT_FMKS* = - (2080374784) # Standard rights
-  STANDARD_RIGHTS_REQUIRED* = 0x000F0000
-  STANDARD_RIGHTS_WRITE* = 0x00020000
-  STANDARD_RIGHTS_READ* = 0x00020000
-  STANDARD_RIGHTS_EXECUTE* = 0x00020000
-  STANDARD_RIGHTS_ALL* = 0x001F0000
-  SPECIFIC_RIGHTS_ALL* = 0x0000FFFF # ACCESS_MASK
-  MAXIMUM_ALLOWED* = 0x02000000
-  GENERIC_ALL* = 0x10000000   # SID
-  SECURITY_NULL_RID* = 0
-  SECURITY_WORLD_RID* = 0
-  SECURITY_LOCAL_RID* = 0
-  SECURITY_CREATOR_OWNER_RID* = 0
-  SECURITY_CREATOR_GROUP_RID* = 0x00000001
-  SECURITY_DIALUP_RID* = 0x00000001
-  SECURITY_NETWORK_RID* = 0x00000002
-  SECURITY_BATCH_RID* = 0x00000003
-  SECURITY_INTERACTIVE_RID* = 0x00000004
-  SECURITY_LOGON_IDS_RID* = 0x00000005
-  SECURITY_LOGON_IDS_RID_COUNT* = 0x00000003
-  SECURITY_SERVICE_RID* = 0x00000006
-  SECURITY_LOCAL_SYSTEM_RID* = 0x00000012
-  SECURITY_BUILTIN_DOMAIN_RID* = 0x00000020
-  DOMAIN_USER_RID_ADMIN* = 0x000001F4
-  DOMAIN_USER_RID_GUEST* = 0x000001F5
-  DOMAIN_GROUP_RID_ADMINS* = 0x00000200
-  DOMAIN_GROUP_RID_USERS* = 0x00000201
-  DOMAIN_ALIAS_RID_ADMINS* = 0x00000220
-  DOMAIN_ALIAS_RID_USERS* = 0x00000221
-  DOMAIN_ALIAS_RID_GUESTS* = 0x00000222
-  DOMAIN_ALIAS_RID_POWER_USERS* = 0x00000223
-  DOMAIN_ALIAS_RID_ACCOUNT_OPS* = 0x00000224
-  DOMAIN_ALIAS_RID_SYSTEM_OPS* = 0x00000225
-  DOMAIN_ALIAS_RID_PRINT_OPS* = 0x00000226
-  DOMAIN_ALIAS_RID_BACKUP_OPS* = 0x00000227
-  DOMAIN_ALIAS_RID_REPLICATOR* = 0x00000228 # TOKEN_GROUPS structure
-  SE_GROUP_MANDATORY* = 0x00000001
-  SE_GROUP_ENABLED_BY_DEFAULT* = 0x00000002
-  SE_GROUP_ENABLED* = 0x00000004
-  SE_GROUP_OWNER* = 0x00000008
-  SE_GROUP_LOGON_ID* = 0xC0000000 # ACL Defines
-  ACL_REVISION* = 2           # ACE_HEADER structure
-  ACCESS_ALLOWED_ACE_TYPE* = 0x00000000
-  ACCESS_DENIED_ACE_TYPE* = 0x00000001
-  SYSTEM_AUDIT_ACE_TYPE* = 0x00000002
-  SYSTEM_ALARM_ACE_TYPE* = 0x00000003 # ACE flags in the ACE_HEADER structure
-  OBJECT_INHERIT_ACE* = 0x00000001
-  CONTAINER_INHERIT_ACE* = 0x00000002
-  NO_PROPAGATE_INHERIT_ACE* = 0x00000004
-  INHERIT_ONLY_ACE* = 0x00000008
-  SUCCESSFUL_ACCESS_ACE_FLAG* = 0x00000040
-  FAILED_ACCESS_ACE_FLAG* = 0x00000080 # SECURITY_DESCRIPTOR_CONTROL
-                                       #SECURITY_DESCRIPTOR_REVISION = 1;already defined above
-  SECURITY_DESCRIPTOR_MIN_LENGTH* = 20
-  SE_OWNER_DEFAULTED* = 1
-  SE_GROUP_DEFAULTED* = 2
-  SE_DACL_PRESENT* = 4
-  SE_DACL_DEFAULTED* = 8
-  SE_SACL_PRESENT* = 16
-  SE_SACL_DEFAULTED* = 32
-  SE_SELF_RELATIVE* = 32768   # PRIVILEGE_SET
-  SE_PRIVILEGE_ENABLED_BY_DEFAULT* = 0x00000001
-  SE_PRIVILEGE_ENABLED* = 0x00000002
-  SE_PRIVILEGE_USED_FOR_ACCESS* = 0x80000000
-  PRIVILEGE_SET_ALL_NECESSARY* = 0x00000001 # OPENFILENAME structure
-  OFN_ALLOWMULTISELECT* = 0x00000200
-  OFN_CREATEPROMPT* = 0x00002000
-  OFN_ENABLEHOOK* = 0x00000020
-  OFN_ENABLETEMPLATE* = 0x00000040
-  OFN_ENABLETEMPLATEHANDLE* = 0x00000080
-  OFN_EXPLORER* = 0x00080000
-  OFN_EXTENSIONDIFFERENT* = 0x00000400
-  OFN_FILEMUSTEXIST* = 0x00001000
-  OFN_HIDEREADONLY* = 0x00000004
-  OFN_LONGNAMES* = 0x00200000
-  OFN_NOCHANGEDIR* = 0x00000008
-  OFN_NODEREFERENCELINKS* = 0x00100000
-  OFN_NOLONGNAMES* = 0x00040000
-  OFN_NONETWORKBUTTON* = 0x00020000
-  OFN_NOREADONLYRETURN* = 0x00008000
-  OFN_NOTESTFILECREATE* = 0x00010000
-  OFN_NOVALIDATE* = 0x00000100
-  OFN_OVERWRITEPROMPT* = 0x00000002
-  OFN_PATHMUSTEXIST* = 0x00000800
-  OFN_READONLY* = 0x00000001
-  OFN_SHAREAWARE* = 0x00004000
-  OFN_SHOWHELP* = 0x00000010  # SHAREVISTRING message
-  OFN_SHAREFALLTHROUGH* = 0x00000002
-  OFN_SHARENOWARN* = 0x00000001
-  OFN_SHAREWARN* = 0          # Open/Save notifications
-  CDN_INITDONE* = 0xFFFFFDA7
-  CDN_SELCHANGE* = 0xFFFFFDA6
-  CDN_FOLDERCHANGE* = 0xFFFFFDA5
-  CDN_SHAREVIOLATION* = 0xFFFFFDA4
-  CDN_HELP* = 0xFFFFFDA3
-  CDN_FILEOK* = 0xFFFFFDA2
-  CDN_TYPECHANGE* = 0xFFFFFDA1 # Open/Save messages
-  CDM_GETFILEPATH* = 0x00000465
-  CDM_GETFOLDERIDLIST* = 0x00000467
-  CDM_GETFOLDERPATH* = 0x00000466
-  CDM_GETSPEC* = 0x00000464
-  CDM_HIDECONTROL* = 0x00000469
-  CDM_SETCONTROLTEXT* = 0x00000468
-  CDM_SETDEFEXT* = 0x0000046A # CHOOSECOLOR structure
-  CC_ENABLEHOOK* = 0x00000010
-  CC_ENABLETEMPLATE* = 0x00000020
-  CC_ENABLETEMPLATEHANDLE* = 0x00000040
-  CC_FULLOPEN* = 0x00000002
-  CC_PREVENTFULLOPEN* = 0x00000004
-  CC_RGBINIT* = 0x00000001
-  CC_SHOWHELP* = 0x00000008
-  CC_SOLIDCOLOR* = 0x00000080 # FINDREPLACE structure
-  FR_DIALOGTERM* = 0x00000040
-  FR_DOWN* = 0x00000001
-  FR_ENABLEHOOK* = 0x00000100
-  FR_ENABLETEMPLATE* = 0x00000200
-  FR_ENABLETEMPLATEHANDLE* = 0x00002000
-  FR_FINDNEXT* = 0x00000008
-  FR_HIDEUPDOWN* = 0x00004000
-  FR_HIDEMATCHCASE* = 0x00008000
-  FR_HIDEWHOLEWORD* = 0x00010000
-  FR_MATCHCASE* = 0x00000004
-  FR_NOMATCHCASE* = 0x00000800
-  FR_NOUPDOWN* = 0x00000400
-  FR_NOWHOLEWORD* = 0x00001000
-  FR_REPLACE* = 0x00000010
-  FR_REPLACEALL* = 0x00000020
-  FR_SHOWHELP* = 0x00000080
-  FR_WHOLEWORD* = 0x00000002  # CHOOSEFONT structure
-  CF_APPLY* = 0x00000200
-  CF_ANSIONLY* = 0x00000400
-  CF_BOTH* = 0x00000003
-  CF_TTONLY* = 0x00040000
-  CF_EFFECTS* = 0x00000100
-  CF_ENABLEHOOK* = 0x00000008
-  CF_ENABLETEMPLATE* = 0x00000010
-  CF_ENABLETEMPLATEHANDLE* = 0x00000020
-  CF_FIXEDPITCHONLY* = 0x00004000
-  CF_FORCEFONTEXIST* = 0x00010000
-  CF_INITTOLOGFONTSTRUCT* = 0x00000040
-  CF_LIMITSIZE* = 0x00002000
-  CF_NOOEMFONTS* = 0x00000800
-  CF_NOFACESEL* = 0x00080000
-  CF_NOSCRIPTSEL* = 0x00800000
-  CF_NOSTYLESEL* = 0x00100000
-  CF_NOSIZESEL* = 0x00200000
-  CF_NOSIMULATIONS* = 0x00001000
-  CF_NOVECTORFONTS* = 0x00000800
-  CF_NOVERTFONTS* = 0x01000000
-  CF_PRINTERFONTS* = 0x00000002
-  CF_SCALABLEONLY* = 0x00020000
-  CF_SCREENFONTS* = 0x00000001
-  CF_SCRIPTSONLY* = 0x00000400
-  CF_SELECTSCRIPT* = 0x00400000
-  CF_SHOWHELP* = 0x00000004
-  CF_USESTYLE* = 0x00000080
-  CF_WYSIWYG* = 0x00008000
-  BOLD_FONTTYPE* = 0x00000100
-  ITALIC_FONTTYPE* = 0x00000200
-  PRINTER_FONTTYPE* = 0x00004000
-  REGULAR_FONTTYPE* = 0x00000400
-  SCREEN_FONTTYPE* = 0x00002000
-  SIMULATED_FONTTYPE* = 0x00008000 # Common dialog messages
-  COLOROKSTRINGW* = "commdlg_ColorOK"
-  FILEOKSTRINGW* = "commdlg_FileNameOK"
-  FINDMSGSTRINGW* = "commdlg_FindReplace"
-  HELPMSGSTRINGW* = "commdlg_help"
-  LBSELCHSTRINGW* = "commdlg_LBSelChangedNotify"
-  SETRGBSTRINGW* = "commdlg_SetRGBColor"
-  SHAREVISTRINGW* = "commdlg_ShareViolation"
-  COLOROKSTRINGA* = "commdlg_ColorOK"
-  FILEOKSTRINGA* = "commdlg_FileNameOK"
-  FINDMSGSTRINGA* = "commdlg_FindReplace"
-  HELPMSGSTRINGA* = "commdlg_help"
-  LBSELCHSTRINGA* = "commdlg_LBSelChangedNotify"
-  SETRGBSTRINGA* = "commdlg_SetRGBColor"
-  SHAREVISTRINGA* = "commdlg_ShareViolation"
-
-when defined(winUnicode):
-  const
-    COLOROKSTRING* = COLOROKSTRINGW
-    FILEOKSTRING* = FILEOKSTRINGW
-    FINDMSGSTRING* = FINDMSGSTRINGW
-    HELPMSGSTRING* = HELPMSGSTRINGW
-    LBSELCHSTRING* = LBSELCHSTRINGW
-    SETRGBSTRING* = SETRGBSTRINGW
-    SHAREVISTRING* = SHAREVISTRINGW
-else:
-  const
-    COLOROKSTRING* = COLOROKSTRINGA
-    FILEOKSTRING* = FILEOKSTRINGA
-    FINDMSGSTRING* = FINDMSGSTRINGA
-    HELPMSGSTRING* = HELPMSGSTRINGA
-    LBSELCHSTRING* = LBSELCHSTRINGA
-    SETRGBSTRING* = SETRGBSTRINGA
-    SHAREVISTRING* = SHAREVISTRINGA
-# LBSELCHSTRING message
-
-const
-  CD_LBSELCHANGE* = 0
-  CD_LBSELADD* = 2
-  CD_LBSELSUB* = 1
-  CD_LBSELNOITEMS* = - (1)    # DEVNAMES structure
-  DN_DEFAULTPRN* = 1          # PRINTDLG structure
-  PD_ALLPAGES* = 0
-  PD_COLLATE* = 16
-  PD_DISABLEPRINTTOFILE* = 524288
-  PD_ENABLEPRINTHOOK* = 4096
-  PD_ENABLEPRINTTEMPLATE* = 16384
-  PD_ENABLEPRINTTEMPLATEHANDLE* = 65536
-  PD_ENABLESETUPHOOK* = 8192
-  PD_ENABLESETUPTEMPLATE* = 32768
-  PD_ENABLESETUPTEMPLATEHANDLE* = 131072
-  PD_HIDEPRINTTOFILE* = 1048576
-  PD_NOPAGENUMS* = 8
-  PD_NOSELECTION* = 4
-  PD_NOWARNING* = 128
-  PD_PAGENUMS* = 2
-  PD_PRINTSETUP* = 64
-  PD_PRINTTOFILE* = 32
-  PD_RETURNDC* = 256
-  PD_RETURNDEFAULT* = 1024
-  PD_RETURNIC* = 512
-  PD_SELECTION* = 1
-  PD_SHOWHELP* = 2048
-  PD_USEDEVMODECOPIES* = 262144
-  PD_USEDEVMODECOPIESANDCOLLATE* = 262144 # PAGESETUPDLG structure
-  PSD_DEFAULTMINMARGINS* = 0
-  PSD_DISABLEMARGINS* = 16
-  PSD_DISABLEORIENTATION* = 256
-  PSD_DISABLEPAGEPAINTING* = 524288
-  PSD_DISABLEPAPER* = 512
-  PSD_DISABLEPRINTER* = 32
-  PSD_ENABLEPAGEPAINTHOOK* = 262144
-  PSD_ENABLEPAGESETUPHOOK* = 8192
-  PSD_ENABLEPAGESETUPTEMPLATE* = 32768
-  PSD_ENABLEPAGESETUPTEMPLATEHANDLE* = 131072
-  PSD_INHUNDREDTHSOFMILLIMETERS* = 8
-  PSD_INTHOUSANDTHSOFINCHES* = 4
-  PSD_INWININIINTLMEASURE* = 0
-  PSD_MARGINS* = 2
-  PSD_MINMARGINS* = 1
-  PSD_NOWARNING* = 128
-  PSD_RETURNDEFAULT* = 1024
-  PSD_SHOWHELP* = 2048        # WM_SHOWWINDOW message
-  SW_OTHERUNZOOM* = 4
-  SW_OTHERZOOM* = 2
-  SW_PARENTCLOSING* = 1
-  SW_PARENTOPENING* = 3       # Virtual Key codes
-  VK_LBUTTON* = 1
-  VK_RBUTTON* = 2
-  VK_CANCEL* = 3
-  VK_MBUTTON* = 4
-  VK_BACK* = 8
-  VK_TAB* = 9
-  VK_CLEAR* = 12
-  VK_RETURN* = 13
-  VK_SHIFT* = 16
-  VK_CONTROL* = 17
-  VK_MENU* = 18
-  VK_PAUSE* = 19
-  VK_CAPITAL* = 20
-  VK_ESCAPE* = 27
-  VK_SPACE* = 32
-  VK_PRIOR* = 33
-  VK_NEXT* = 34
-  VK_END* = 35
-  VK_HOME* = 36
-  VK_LEFT* = 37
-  VK_UP* = 38
-  VK_RIGHT* = 39
-  VK_DOWN* = 40
-  VK_SELECT* = 41
-  VK_PRINT* = 42
-  VK_EXECUTE* = 43
-  VK_SNAPSHOT* = 44
-  VK_INSERT* = 45
-  VK_DELETE* = 46
-  VK_HELP* = 47
-  VK_0* = 48
-  VK_1* = 49
-  VK_2* = 50
-  VK_3* = 51
-  VK_4* = 52
-  VK_5* = 53
-  VK_6* = 54
-  VK_7* = 55
-  VK_8* = 56
-  VK_9* = 57
-  VK_A* = 65
-  VK_B* = 66
-  VK_C* = 67
-  VK_D* = 68
-  VK_E* = 69
-  VK_F* = 70
-  VK_G* = 71
-  VK_H* = 72
-  VK_I* = 73
-  VK_J* = 74
-  VK_K* = 75
-  VK_L* = 76
-  VK_M* = 77
-  VK_N* = 78
-  VK_O* = 79
-  VK_P* = 80
-  VK_Q* = 81
-  VK_R* = 82
-  VK_S* = 83
-  VK_T* = 84
-  VK_U* = 85
-  VK_V* = 86
-  VK_W* = 87
-  VK_X* = 88
-  VK_Y* = 89
-  VK_Z* = 90
-  VK_LWIN* = 91
-  VK_RWIN* = 92
-  VK_APPS* = 93
-  VK_NUMPAD0* = 96
-  VK_NUMPAD1* = 97
-  VK_NUMPAD2* = 98
-  VK_NUMPAD3* = 99
-  VK_NUMPAD4* = 100
-  VK_NUMPAD5* = 101
-  VK_NUMPAD6* = 102
-  VK_NUMPAD7* = 103
-  VK_NUMPAD8* = 104
-  VK_NUMPAD9* = 105
-  VK_MULTIPLY* = 106
-  VK_ADD* = 107
-  VK_SEPARATOR* = 108
-  VK_SUBTRACT* = 109
-  VK_DECIMAL* = 110
-  VK_DIVIDE* = 111
-  VK_F1* = 112
-  VK_F2* = 113
-  VK_F3* = 114
-  VK_F4* = 115
-  VK_F5* = 116
-  VK_F6* = 117
-  VK_F7* = 118
-  VK_F8* = 119
-  VK_F9* = 120
-  VK_F10* = 121
-  VK_F11* = 122
-  VK_F12* = 123
-  VK_F13* = 124
-  VK_F14* = 125
-  VK_F15* = 126
-  VK_F16* = 127
-  VK_F17* = 128
-  VK_F18* = 129
-  VK_F19* = 130
-  VK_F20* = 131
-  VK_F21* = 132
-  VK_F22* = 133
-  VK_F23* = 134
-  VK_F24* = 135               # GetAsyncKeyState
-  VK_NUMLOCK* = 144
-  VK_SCROLL* = 145
-  VK_LSHIFT* = 160
-  VK_LCONTROL* = 162
-  VK_LMENU* = 164
-  VK_RSHIFT* = 161
-  VK_RCONTROL* = 163
-  VK_RMENU* = 165             # ImmGetVirtualKey
-  VK_PROCESSKEY* = 229        # Keystroke Message Flags
-  KF_ALTDOWN* = 8192
-  KF_DLGMODE* = 2048
-  KF_EXTENDED* = 256
-  KF_MENUMODE* = 4096
-  KF_REPEAT* = 16384
-  KF_UP* = 32768              # GetKeyboardLayoutName
-  KL_NAMELENGTH* = 9          # WM_ACTIVATE message
-  WA_ACTIVE* = 1
-  WA_CLICKACTIVE* = 2
-  WA_INACTIVE* = 0            # WM_ACTIVATE message
-  PWR_CRITICALRESUME* = 3
-  PWR_SUSPENDREQUEST* = 1
-  PWR_SUSPENDRESUME* = 2
-  PWR_FAIL* = - (1)
-  PWR_OK* = 1                 # WM_NOTIFYFORMAT message
-  NF_QUERY* = 3
-  NF_REQUERY* = 4
-  NFR_ANSI* = 1
-  NFR_UNICODE* = 2            # WM_SIZING message
-  WMSZ_BOTTOM* = 6
-  WMSZ_BOTTOMLEFT* = 7
-  WMSZ_BOTTOMRIGHT* = 8
-  WMSZ_LEFT* = 1
-  WMSZ_RIGHT* = 2
-  WMSZ_TOP* = 3
-  WMSZ_TOPLEFT* = 4
-  WMSZ_TOPRIGHT* = 5          # WM_MOUSEACTIVATE message
-  MA_ACTIVATE* = 1
-  MA_ACTIVATEANDEAT* = 2
-  MA_NOACTIVATE* = 3
-  MA_NOACTIVATEANDEAT* = 4    # WM_SIZE message
-  SIZE_MAXHIDE* = 4
-  SIZE_MAXIMIZED* = 2
-  SIZE_MAXSHOW* = 3
-  SIZE_MINIMIZED* = 1
-  SIZE_RESTORED* = 0          # WM_NCCALCSIZE message
-  WVR_ALIGNTOP* = 16
-  WVR_ALIGNLEFT* = 32
-  WVR_ALIGNBOTTOM* = 64
-  WVR_ALIGNRIGHT* = 128
-  WVR_HREDRAW* = 256
-  WVR_VREDRAW* = 512
-  WVR_REDRAW* = 768
-  WVR_VALIDRECTS* = 1024      # WM_NCHITTEST message
-  HTBOTTOM* = 15
-  HTBOTTOMLEFT* = 16
-  HTBOTTOMRIGHT* = 17
-  HTCAPTION* = 2
-  HTCLIENT* = 1
-  HTERROR* = - (2)
-  HTGROWBOX* = 4
-  HTHSCROLL* = 6
-  HTLEFT* = 10
-  HTMENU* = 5
-  HTNOWHERE* = 0
-  HTREDUCE* = 8
-  HTRIGHT* = 11
-  HTSIZE* = 4
-  HTSYSMENU* = 3
-  HTTOP* = 12
-  HTTOPLEFT* = 13
-  HTTOPRIGHT* = 14
-  HTTRANSPARENT* = - (1)
-  HTVSCROLL* = 7
-  HTZOOM* = 9                 # Mouse messages
-  MK_CONTROL* = 8
-  MK_LBUTTON* = 1
-  MK_MBUTTON* = 16
-  MK_RBUTTON* = 2
-  MK_SHIFT* = 4               # WNDCLASS structure
-  CS_BYTEALIGNCLIENT* = 4096
-  CS_BYTEALIGNWINDOW* = 8192
-  CS_CLASSDC* = 64
-  CS_DBLCLKS* = 8
-  CS_GLOBALCLASS* = 16384
-  CS_HREDRAW* = 2
-  CS_KEYCVTWINDOW* = 4
-  CS_NOCLOSE* = 512
-  CS_NOKEYCVT* = 256
-  CS_OWNDC* = 32
-  CS_PARENTDC* = 128
-  CS_SAVEBITS* = 2048
-  CS_VREDRAW* = 1
-  DLGWINDOWEXTRA* = 30        # ACCEL structure
-  FALT* = 16
-  FCONTROL* = 8
-  FNOINVERT* = 2
-  FSHIFT* = 4
-  FVIRTKEY* = 1               # WM_MENUCHAR return constants
-  MNC_IGNORE* = 0
-  MNC_CLOSE* = 1
-  MNC_EXECUTE* = 2
-  MNC_SELECT* = 3             # MENUINFO structure
-  MIM_MAXHEIGHT* = 1
-  MIM_BACKGROUND* = 2
-  MIM_HELPID* = 4
-  MIM_MENUDATA* = 8
-  MIM_STYLE* = 16
-  MIM_APPLYTOSUBMENUS* = 0x80000000
-  MNS_CHECKORBMP* = 0x04000000
-  MNS_NOTIFYBYPOS* = 0x08000000
-  MNS_AUTODISMISS* = 0x10000000
-  MNS_DRAGDROP* = 0x20000000
-  MNS_MODELESS* = 0x40000000
-  MNS_NOCHECK* = 0x80000000   # MENUITEMINFO structure
-  MIIM_CHECKMARKS* = 8
-  MIIM_DATA* = 32
-  MIIM_ID* = 2
-  MIIM_STATE* = 1
-  MIIM_SUBMENU* = 4
-  MIIM_TYPE* = 16
-  MIIM_STRING* = 64
-  MIIM_BITMAP* = 128
-  MIIM_FTYPE* = 256
-  MFT_BITMAP* = 0x00000004
-  MFT_MENUBARBREAK* = 0x00000020
-  MFT_MENUBREAK* = 0x00000040
-  MFT_OWNERDRAW* = 0x00000100
-  MFT_RADIOCHECK* = 0x00000200
-  MFT_RIGHTJUSTIFY* = 0x00004000
-  MFT_SEPARATOR* = 0x00000800
-  MFT_RIGHTORDER* = 0x00002000
-  MFT_STRING* = 0
-  MFS_CHECKED* = 0x00000008
-  MFS_DEFAULT* = 0x00001000
-  MFS_DISABLED* = 0x00000003
-  MFS_ENABLED* = 0
-  MFS_GRAYED* = 0x00000003
-  MFS_HILITE* = 0x00000080
-  MFS_UNCHECKED* = 0
-  MFS_UNHILITE* = 0
-  HBMMENU_CALLBACK* = - 1
-  HBMMENU_SYSTEM* = 1
-  HBMMENU_MBAR_RESTORE* = 2
-  HBMMENU_MBAR_MINIMIZE* = 3
-  HBMMENU_MBAR_CLOSE* = 5
-  HBMMENU_MBAR_CLOSE_D* = 6
-  HBMMENU_MBAR_MINIMIZE_D* = 7
-  HBMMENU_POPUP_CLOSE* = 8
-  HBMMENU_POPUP_RESTORE* = 9
-  HBMMENU_POPUP_MAXIMIZE* = 10
-  HBMMENU_POPUP_MINIMIZE* = 11 # SERIALKEYS structure
-  SERKF_AVAILABLE* = 2
-  SERKF_INDICATOR* = 4
-  SERKF_SERIALKEYSON* = 1     # FILTERKEYS structure
-  FKF_AVAILABLE* = 2
-  FKF_CLICKON* = 64
-  FKF_FILTERKEYSON* = 1
-  FKF_HOTKEYACTIVE* = 4
-  FKF_HOTKEYSOUND* = 16
-  FKF_CONFIRMHOTKEY* = 8
-  FKF_INDICATOR* = 32         # HELPINFO structure
-  HELPINFO_MENUITEM* = 2
-  HELPINFO_WINDOW* = 1        # WM_PRINT message
-  PRF_CHECKVISIBLE* = 0x00000001
-  PRF_CHILDREN* = 0x00000010
-  PRF_CLIENT* = 0x00000004
-  PRF_ERASEBKGND* = 0x00000008
-  PRF_NONCLIENT* = 0x00000002
-  PRF_OWNED* = 0x00000020     # MapWindowPoints
-                              # was #define dname def_expr
-
-proc HWND_DESKTOP*(): HWND
-  # WM_SYSCOMMAND message
-const
-  SC_CLOSE* = 61536
-  SC_CONTEXTHELP* = 61824
-  SC_DEFAULT* = 61792
-  SC_HOTKEY* = 61776
-  SC_HSCROLL* = 61568
-  SC_KEYMENU* = 61696
-  SC_MAXIMIZE* = 61488
-  SC_ZOOM* = 61488
-  SC_MINIMIZE* = 61472
-  SC_ICON* = 61472
-  SC_MONITORPOWER* = 61808
-  SC_MOUSEMENU* = 61584
-  SC_MOVE* = 61456
-  SC_NEXTWINDOW* = 61504
-  SC_PREVWINDOW* = 61520
-  SC_RESTORE* = 61728
-  SC_SCREENSAVE* = 61760
-  SC_SIZE* = 61440
-  SC_TASKLIST* = 61744
-  SC_VSCROLL* = 61552         # DM_GETDEFID message
-  DC_HASDEFID* = 21323        # WM_GETDLGCODE message
-  DLGC_BUTTON* = 8192
-  DLGC_DEFPUSHBUTTON* = 16
-  DLGC_HASSETSEL* = 8
-  DLGC_RADIOBUTTON* = 64
-  DLGC_STATIC* = 256
-  DLGC_UNDEFPUSHBUTTON* = 32
-  DLGC_WANTALLKEYS* = 4
-  DLGC_WANTARROWS* = 1
-  DLGC_WANTCHARS* = 128
-  DLGC_WANTMESSAGE* = 4
-  DLGC_WANTTAB* = 2           # EM_SETMARGINS message
-  EC_LEFTMARGIN* = 1
-  EC_RIGHTMARGIN* = 2
-  EC_USEFONTINFO* = 65535     # LB_SETCOUNT message
-  LB_ERR* = - (1)
-  LB_ERRSPACE* = - (2)
-  LB_OKAY* = 0                # CB_DIR message
-  CB_ERR* = - (1)
-  CB_ERRSPACE* = - (2)        # WM_IME_CONTROL message
-  IMC_GETCANDIDATEPOS* = 7
-  IMC_GETCOMPOSITIONFONT* = 9
-  IMC_GETCOMPOSITIONWINDOW* = 11
-  IMC_GETSTATUSWINDOWPOS* = 15
-  IMC_CLOSESTATUSWINDOW* = 33
-  IMC_OPENSTATUSWINDOW* = 34
-  IMC_SETCANDIDATEPOS* = 8
-  IMC_SETCOMPOSITIONFONT* = 10
-  IMC_SETCOMPOSITIONWINDOW* = 12
-  IMC_SETSTATUSWINDOWPOS* = 16 # WM_IME_CONTROL message
-  IMN_CHANGECANDIDATE* = 3
-  IMN_CLOSECANDIDATE* = 4
-  IMN_CLOSESTATUSWINDOW* = 1
-  IMN_GUIDELINE* = 13
-  IMN_OPENCANDIDATE* = 5
-  IMN_OPENSTATUSWINDOW* = 2
-  IMN_SETCANDIDATEPOS* = 9
-  IMN_SETCOMPOSITIONFONT* = 10
-  IMN_SETCOMPOSITIONWINDOW* = 11
-  IMN_SETCONVERSIONMODE* = 6
-  IMN_SETOPENSTATUS* = 8
-  IMN_SETSENTENCEMODE* = 7
-  IMN_SETSTATUSWINDOWPOS* = 12
-  IMN_PRIVATE* = 14           # STICKYKEYS structure
-  SKF_AUDIBLEFEEDBACK* = 64
-  SKF_AVAILABLE* = 2
-  SKF_CONFIRMHOTKEY* = 8
-  SKF_HOTKEYACTIVE* = 4
-  SKF_HOTKEYSOUND* = 16
-  SKF_INDICATOR* = 32
-  SKF_STICKYKEYSON* = 1
-  SKF_TRISTATE* = 128
-  SKF_TWOKEYSOFF* = 256       # MOUSEKEYS structure
-  MKF_AVAILABLE* = 2
-  MKF_CONFIRMHOTKEY* = 8
-  MKF_HOTKEYACTIVE* = 4
-  MKF_HOTKEYSOUND* = 16
-  MKF_INDICATOR* = 32
-  MKF_MOUSEKEYSON* = 1
-  MKF_MODIFIERS* = 64
-  MKF_REPLACENUMBERS* = 128   # SOUNDSENTRY structure
-  SSF_AVAILABLE* = 2
-  SSF_SOUNDSENTRYON* = 1
-  SSTF_BORDER* = 2
-  SSTF_CHARS* = 1
-  SSTF_DISPLAY* = 3
-  SSTF_NONE* = 0
-  SSGF_DISPLAY* = 3
-  SSGF_NONE* = 0
-  SSWF_CUSTOM* = 4
-  SSWF_DISPLAY* = 3
-  SSWF_NONE* = 0
-  SSWF_TITLE* = 1
-  SSWF_WINDOW* = 2            # ACCESSTIMEOUT structure
-  ATF_ONOFFFEEDBACK* = 2
-  ATF_TIMEOUTON* = 1          # HIGHCONTRAST structure
-  HCF_AVAILABLE* = 2
-  HCF_CONFIRMHOTKEY* = 8
-  HCF_HIGHCONTRASTON* = 1
-  HCF_HOTKEYACTIVE* = 4
-  HCF_HOTKEYAVAILABLE* = 64
-  HCF_HOTKEYSOUND* = 16
-  HCF_INDICATOR* = 32         # TOGGLEKEYS structure
-  TKF_AVAILABLE* = 2
-  TKF_CONFIRMHOTKEY* = 8
-  TKF_HOTKEYACTIVE* = 4
-  TKF_HOTKEYSOUND* = 16
-  TKF_TOGGLEKEYSON* = 1       # Installable Policy
-  PP_DISPLAYERRORS* = 1       # SERVICE_INFO structure
-  RESOURCEDISPLAYTYPE_DOMAIN* = 1
-  RESOURCEDISPLAYTYPE_FILE* = 4
-  RESOURCEDISPLAYTYPE_GENERIC* = 0
-  RESOURCEDISPLAYTYPE_GROUP* = 5
-  RESOURCEDISPLAYTYPE_SERVER* = 2
-  RESOURCEDISPLAYTYPE_SHARE* = 3 # KEY_EVENT_RECORD structure
-  CAPSLOCK_ON* = 128
-  ENHANCED_KEY* = 256
-  LEFT_ALT_PRESSED* = 2
-  LEFT_CTRL_PRESSED* = 8
-  NUMLOCK_ON* = 32
-  RIGHT_ALT_PRESSED* = 1
-  RIGHT_CTRL_PRESSED* = 4
-  SCROLLLOCK_ON* = 64
-  SHIFT_PRESSED* = 16         # MOUSE_EVENT_RECORD structure
-  FROM_LEFT_1ST_BUTTON_PRESSED* = 1
-  RIGHTMOST_BUTTON_PRESSED* = 2
-  FROM_LEFT_2ND_BUTTON_PRESSED* = 4
-  FROM_LEFT_3RD_BUTTON_PRESSED* = 8
-  FROM_LEFT_4TH_BUTTON_PRESSED* = 16
-  DOUBLE_CLICK* = 2
-  MOUSE_MOVED* = 1            # INPUT_RECORD structure
-  KEY_EVENT* = 1
-  cMOUSE_EVENT* = 2
-  WINDOW_BUFFER_SIZE_EVENT* = 4
-  MENU_EVENT* = 8
-  FOCUS_EVENT* = 16           # BITMAPINFOHEADER structure
-  BI_RGB* = 0
-  BI_RLE8* = 1
-  BI_RLE4* = 2
-  BI_BITFIELDS* = 3           # Extensions to OpenGL
-                              # ChoosePixelFormat
-  PFD_DOUBLEBUFFER* = 0x00000001
-  PFD_STEREO* = 0x00000002
-  PFD_DRAW_TO_WINDOW* = 0x00000004
-  PFD_DRAW_TO_BITMAP* = 0x00000008
-  PFD_SUPPORT_GDI* = 0x00000010
-  PFD_SUPPORT_OPENGL* = 0x00000020
-  PFD_DEPTH_DONTCARE* = 0x20000000
-  PFD_DOUBLEBUFFER_DONTCARE* = 0x40000000
-  PFD_STEREO_DONTCARE* = 0x80000000
-  PFD_TYPE_RGBA* = 0
-  PFD_TYPE_COLORINDEX* = 1
-  PFD_MAIN_PLANE* = 0
-  PFD_OVERLAY_PLANE* = 1
-  PFD_UNDERLAY_PLANE* = - (1) # wglUseFontOutlines
-  WGL_FONT_LINES* = 0
-  WGL_FONT_POLYGONS* = 1      # LAYERPLANEDESCRIPTOR structure
-                              # PIXELFORMATDESCRIPTOR structure
-  PFD_GENERIC_FORMAT* = 0x00000040
-  PFD_NEED_PALETTE* = 0x00000080
-  PFD_NEED_SYSTEM_PALETTE* = 0x00000100
-  PFD_SWAP_EXCHANGE* = 0x00000200
-  PFD_SWAP_COPY* = 0x00000400
-  PFD_SWAP_LAYER_BUFFERS* = 0x00000800
-  PFD_GENERIC_ACCELERATED* = 0x00001000
-  PFD_SUPPORT_DIRECTDRAW* = 0x00002000 # TEXTMETRIC structure
-  TMPF_FIXED_PITCH* = 0x00000001
-  TMPF_VECTOR* = 0x00000002
-  TMPF_TRUETYPE* = 0x00000004
-  TMPF_DEVICE* = 0x00000008
-  WM_CTLCOLOR* = 25
-  LWA_COLORKEY* = 0x00000001
-  LWA_ALPHA* = 0x00000002
-  ULW_COLORKEY* = 0x00000001
-  ULW_ALPHA* = 0x00000002
-  ULW_OPAQUE* = 0x00000004
-  WS_EX_LAYERED* = 0x00080000
-  WS_EX_NOINHERITLAYOUT* = 0x00100000
-  WS_EX_LAYOUTRTL* = 0x00400000
-  WS_EX_COMPOSITED* = 0x02000000
-  WS_EX_NOACTIVATE* = 0x08000000
-  C3_LEXICAL* = 1024 # --------------------- old stuff, need to organize! ---------------
-                     # BEGINNING of windowsx.h stuff from old headers:
-                     #  Not convertable by H2PAS
-                     #  #define CRACK_VOID_F(fn,args) (void)(fn args)
-                     #  #define CRACK_BOOL_F(fn,args) (WINBOOL)(fn args)
-                     #  #define CRACK_HMENU_F(fn,args) (HMENU)(fn args)
-                     #  #define CRACK_HWND_F(fn,args) (HWND)(fn args)
-                     #  #define CRACK_LONG_F(fn, args) (LRESULT)(fn args)
-                     #  #define CRACK_ZERO_F(fn, args)  (fn args,0)
-                     #
-                     # was #define dname(params) def_expr
-
-proc GetFirstChild*(h: HWND): HWND
-  # was #define dname(params) def_expr
-proc GetNextSibling*(h: HWND): HWND
-  # was #define dname(params) def_expr
-proc GetWindowID*(h: HWND): int32
-  # was #define dname(params) def_expr
-proc SubclassWindow*(h: HWND, p: LONG): LONG
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_COMMAND_CMD*(w, L: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_COMMAND_ID*(w, L: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_CTLCOLOR_HDC*(w, L, msg: int32): HDC
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_CTLCOLOR_HWND*(w, L, msg: int32): HWND
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_HSCROLL_CODE*(w, L: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_HSCROLL_HWND*(w, L: int32): HWND
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_HSCROLL_POS*(w, L: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_MDIACTIVATE_FACTIVATE*(h, a, b: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_MDIACTIVATE_HWNDACTIVATE*(a, b: int32): HWND
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_MDIACTIVATE_HWNDDEACT*(a, b: int32): HWND
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_VSCROLL_CODE*(w, L: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-proc GET_WM_VSCROLL_HWND*(w, L: int32): HWND
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc GET_WM_VSCROLL_POS*(w, L: int32): int32
-  # return type might be wrong
-  #  Not convertable by H2PAS
-  #  #define FORWARD_WM_CLOSE(h, fn)                 CRACK_VOID_F(fn,(h, WM_CLOSE, 0, 0))
-  #  #define FORWARD_WM_COMMAND(h, id, c, n, fn)     CRACK_VOID_F(fn,(h, WM_COMMAND, MAKEWPARAM(id,n), (LPARAM)c))
-  #  #define FORWARD_WM_CREATE(h, p, fn)             CRACK_BOOL_F(fn,(h, WM_CREATE, 0, (LPARAM)p))
-  #  #define FORWARD_WM_DESTROY(h, fn)               CRACK_VOID_F(fn,(h, WM_DESTROY, 0, 0))
-  #  #define FORWARD_WM_ENABLE(h, e, fn)             CRACK_VOID_F(fn,(h, WM_ENABLE, (WPARAM)e, 0))
-  #  #define FORWARD_WM_INITDIALOG(h, c, L, fn)      CRACK_BOOL_F(fn,(h, WM_INITDIALOG, (WPARAM)c, L))
-  #  #define FORWARD_WM_MDICASCADE(h, c, fn)         CRACK_BOOL_F(fn,(h, WM_MDICASCADE, (WPARAM)c, 0))
-  #  #define FORWARD_WM_MDIDESTROY(h, d, fn)         CRACK_VOID_F(fn,(h, WM_MDIDESTROY, (WPARAM)d, 0))
-  #  #define FORWARD_WM_MDIGETACTIVE(h, fn)          CRACK_HWND_F(fn,(h, WM_MDIGETACTIVE, 0, 0))
-  #  #define FORWARD_WM_MDIICONARRANGE(h, fn)        CRACK_VOID_F(fn,(h, WM_MDIICONARRANGE, 0, 0))
-  #  #define FORWARD_WM_MDISETMENU(h, fr, hf, hw, fn) CRACK_HMENU_F(fn,(h, WM_MDISETMENU, (WPARAM)((fr) ? (hf) : 0), (LPARAM)(hw)))
-  #  #define FORWARD_WM_MDITILE(h, c, fn)            CRACK_BOOL_F(fn,(h, WM_MDITILE, (WPARAM)(c), 0))
-  #  #define FORWARD_WM_PAINT(h, fn)                 CRACK_VOID_F(fn,(h, WM_PAINT, 0, 0))
-  #  #define FORWARD_WM_QUERYENDSESSION(h, fn)       CRACK_BOOL_F(fn,(h, WM_QUERYENDSESSION, 0, 0))
-  #  #define FORWARD_WM_SIZE(h, state, cx, cy, fn)   CRACK_VOID_F(fn,(h, WM_SIZE, (WPARAM)state, MAKELPARAM(cx, cy)))
-  #  #define FORWARD_WM_SYSCOMMAND(h, c, x, y, fn)   CRACK_VOID_F(fn,(h, WM_SYSCOMMAND, (WPARAM)c, MAKELPARAM(x, y)))
-  #
-  #  #define HANDLE_WM_CLOSE(h, w, L, fn)            CRACK_ZERO_F(fn,(h));
-  #  #define HANDLE_WM_COMMAND(h, w, L, fn)          CRACK_ZERO_F(fn,(h, SEXT_LOWORD(w), (HWND)L, HIWORD(w)))
-  #  #define HANDLE_WM_CREATE(h, w, L, fn)           (LRESULT)((fn(h, (CREATESTRUCT  )L)) ? 0 : -1)
-  #  #define HANDLE_WM_DESTROY(h, w, L, fn)          CRACK_ZERO_F(fn,(h))
-  #  #define HANDLE_WM_ENABLE(h, w, L, fn)           CRACK_ZERO_F(fn,(h, (WINBOOL)w))
-  #  #define HANDLE_WM_INITDIALOG(h, w, L, fn)       CRACK_LONG_F(fn,(h, (HWND)w, L))
-  #  #define HANDLE_WM_MDICASCADE(h, w, L, fn)       CRACK_LONG_F(fn, (h, (UINT)w)
-  #  #define HANDLE_WM_MDIDESTROY(h, w, L, fn)       CRACK_ZERO_F(fn,(h, (HWND)w))
-  #  #define HANDLE_WM_MDIGETACTIVE(h, w, L, fn)     CRACK_LONG_F(fn,(h))
-  #  #define HANDLE_WM_MDIICONARRANGE(h, w, L, fn)   CRACK_ZERO_F(fn,(h))
-  #  #define HANDLE_WM_MDISETMENU(h, w, L, fn)       CRACK_LONG_F(fn,(h, (WINBOOL)w, (HMENU)w, (HMENU)L)
-  #  #define HANDLE_WM_MDITILE(h, w, L, fn)          CRACK_LONG_F(fn,(h, (UINT)w))
-  #  #define HANDLE_WM_PAINT(h, w, L, fn)            CRACK_ZERO_F(fn,(h))
-  #  #define HANDLE_WM_QUERYENDSESSION(h, w, L, fn)  MAKELRESULT(fn(h), 0)
-  #  #define HANDLE_WM_SIZE(h, w, L, fn)             CRACK_ZERO_F(fn,(h, (UINT)w, SEXT_LOWORD(L), SEXT_HIWORD(L)))
-  #  #define HANDLE_WM_SYSCOMMAND(h, w, L, fn)       CRACK_ZERO_F(fn,(h, (UINT)w, SEXT_LOWORD(L), SEXT_HIWORD(L)))
-  #
-  # Totally disgusting! get wParam and lParam from the environment !
-  #  Not convertable by H2PAS
-  #  #define HANDLE_MSG(h, message, fn) case message: return HANDLE_##message(h, wParam, lParam, fn)
-  #
-  # END OF windowsx.h stuff from old headers
-  # ------------------------------------------------------------------
-  # BEGINNING of shellapi.h stuff from old headers
-const
-  SE_ERR_SHARE* = 26
-  SE_ERR_ASSOCINCOMPLETE* = 27
-  SE_ERR_DDETIMEOUT* = 28
-  SE_ERR_DDEFAIL* = 29
-  SE_ERR_DDEBUSY* = 30
-  SE_ERR_NOASSOC* = 31 # END OF shellapi.h stuff from old headers
-                       #
-                       # ------------------------------------------------------------------
-                       # From ddeml.h in old Cygnus headers
-  XCLASS_BOOL* = 0x00001000
-  XCLASS_DATA* = 0x00002000
-  XCLASS_FLAGS* = 0x00004000
-  XCLASS_MASK* = 0x0000FC00
-  XCLASS_NOTIFICATION* = 0x00008000
-  XTYPF_NOBLOCK* = 0x00000002
-  XTYP_ADVDATA* = 0x00004010
-  XTYP_ADVREQ* = 0x00002022
-  XTYP_ADVSTART* = 0x00001030
-  XTYP_ADVSTOP* = 0x00008040
-  XTYP_CONNECT* = 0x00001062
-  XTYP_CONNECT_CONFIRM* = 0x00008072
-  XTYP_DISCONNECT* = 0x000080C2
-  XTYP_EXECUTE* = 0x00004050
-  XTYP_POKE* = 0x00004090
-  XTYP_REQUEST* = 0x000020B0
-  XTYP_WILDCONNECT* = 0x000020E2
-  XTYP_REGISTER* = 0x000080A2
-  XTYP_ERROR* = 0x00008002
-  XTYP_XACT_COMPLETE* = 0x00008080
-  XTYP_UNREGISTER* = 0x000080D2
-  DMLERR_DLL_USAGE* = 0x00004004
-  DMLERR_INVALIDPARAMETER* = 0x00004006
-  DMLERR_NOTPROCESSED* = 0x00004009
-  DMLERR_POSTMSG_FAILED* = 0x0000400C
-  DMLERR_SERVER_DIED* = 0x0000400E
-  DMLERR_SYS_ERROR* = 0x0000400F
-  DMLERR_BUSY* = 0x00004001
-  DMLERR_DATAACKTIMEOUT* = 0x00004002
-  DMLERR_ADVACKTIMEOUT* = 0x00004000
-  DMLERR_DLL_NOT_INITIALIZED* = 0x00004003
-  DMLERR_LOW_MEMORY* = 0x00004007
-  DMLERR_MEMORY_ERROR* = 0x00004008
-  DMLERR_POKEACKTIMEOUT* = 0x0000400B
-  DMLERR_NO_CONV_ESTABLISHED* = 0x0000400A
-  DMLERR_REENTRANCY* = 0x0000400D
-  DMLERR_UNFOUND_QUEUE_ID* = 0x00004011
-  DMLERR_UNADVACKTIMEOUT* = 0x00004010
-  DMLERR_EXECACKTIMEOUT* = 0x00004005
-  DDE_FACK* = 0x00008000
-  DDE_FNOTPROCESSED* = 0x00000000
-  DNS_REGISTER* = 0x00000001
-  DNS_UNREGISTER* = 0x00000002
-  CP_WINANSI* = 1004
-  CP_WINUNICODE* = 1200       #  Not convertable by H2PAS
-                              #  #define EXPENTRY CALLBACK
-                              #
-  APPCLASS_STANDARD* = 0x00000000 # End of stuff from ddeml.h in old Cygnus headers
-                                  #
-                                  # -----------------------------------------------
-  BKMODE_LAST* = 2
-  CTLCOLOR_MSGBOX* = 0
-  CTLCOLOR_EDIT* = 1
-  CTLCOLOR_LISTBOX* = 2
-  CTLCOLOR_BTN* = 3
-  CTLCOLOR_DLG* = 4
-  CTLCOLOR_SCROLLBAR* = 5
-  CTLCOLOR_STATIC* = 6
-  CTLCOLOR_MAX* = 7
-  META_SETMAPMODE* = 0x00000103
-  META_SETWINDOWORG* = 0x0000020B
-  META_SETWINDOWEXT* = 0x0000020C
-  POLYFILL_LAST* = 2
-  STATUS_WAIT_0* = 0x00000000
-  STATUS_ABANDONED_WAIT_0* = 0x00000080
-  STATUS_USER_APC* = 0x000000C0
-  STATUS_TIMEOUT* = 0x00000102
-  STATUS_PENDING* = 0x00000103
-  STATUS_GUARD_PAGE_VIOLATION* = 0x80000001
-  STATUS_DATATYPE_MISALIGNMENT* = 0x80000002
-  STATUS_BREAKPOINT* = 0x80000003
-  STATUS_SINGLE_STEP* = 0x80000004
-  STATUS_IN_PAGE_ERROR* = 0xC0000006
-  STATUS_INVALID_HANDLE* = 0xC0000008
-  STATUS_ILLEGAL_INSTRUCTION* = 0xC000001D
-  STATUS_NONCONTINUABLE_EXCEPTION* = 0xC0000025
-  STATUS_INVALID_DISPOSITION* = 0xC0000026
-  STATUS_ARRAY_BOUNDS_EXCEEDED* = 0xC000008C
-  STATUS_FLOAT_DENORMAL_OPERAND* = 0xC000008D
-  STATUS_FLOAT_DIVIDE_BY_ZERO* = 0xC000008E
-  STATUS_FLOAT_INEXACT_RESULT* = 0xC000008F
-  STATUS_FLOAT_INVALID_OPERATION* = 0xC0000090
-  STATUS_FLOAT_OVERFLOW* = 0xC0000091
-  STATUS_FLOAT_STACK_CHECK* = 0xC0000092
-  STATUS_FLOAT_UNDERFLOW* = 0xC0000093
-  STATUS_INTEGER_DIVIDE_BY_ZERO* = 0xC0000094
-  STATUS_INTEGER_OVERFLOW* = 0xC0000095
-  STATUS_PRIVILEGED_INSTRUCTION* = 0xC0000096
-  STATUS_STACK_OVERFLOW* = 0xC00000FD
-  STATUS_CONTROL_C_EXIT* = 0xC000013A
-  PROCESSOR_ARCHITECTURE_INTEL* = 0
-  PROCESSOR_ARCHITECTURE_MIPS* = 1
-  PROCESSOR_ARCHITECTURE_ALPHA* = 2
-  PROCESSOR_ARCHITECTURE_PPC* = 3
-
-# was #define dname(params) def_expr
-
-proc FreeModule*(h: HINST): WINBOOL
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc MakeProcInstance*(p, i: int32): int32
-  # return type might be wrong
-  # was #define dname(params) def_expr
-  # argument types are unknown
-  # return type might be wrong
-proc FreeProcInstance*(p: int32): int32
-  # return type might be wrong
-const                         # _fmemcpy = memcpy; these are functions
-                              # Used by wxwindows.
-  SIZEFULLSCREEN* = SIZE_MAXIMIZED
-  SIZENORMAL* = SIZE_RESTORED
-  SIZEICONIC* = SIZE_MINIMIZED # NPLOGPALETTE = PLOGPALETTE; probably a type
-                               # In the old winnt.h
-                               #  Not convertable by H2PAS anyhow with if 0
-                               #  #if 0
-                               #  #ifdef ANAL
-                               #  #define DECLARE_HANDLE(h) struct h## { int dummy; }; typedef struct h##  h
-                               #  #else
-                               #  #define DECLARE_HANDLE(h)  typedef void  h
-                               #  #endif
-                               #  DECLARE_HANDLE(HANDLE);
-                               #  #endif
-                               #
-
-const
-  EXCEPTION_READ_FAULT* = 0   # Access violation was caused by a read
-  EXCEPTION_WRITE_FAULT* = 1  # Access violation was caused by a write
-
-when defined(cpuia64):
-  const
-    EXCEPTION_EXECUTE_FAULT* = 2 # Access violation was caused by an instruction fetch
-else:
-  const
-    EXCEPTION_EXECUTE_FAULT* = 8
-when defined(cpupowerpc32):
-  # ppc
-  const
-    CONTEXT_CONTROL* = 1
-    CONTEXT_FLOATING_POINT* = 2
-    CONTEXT_INTEGER* = 4
-    CONTEXT_DEBUG_REGISTERS* = 8
-    CONTEXT_FULL* = (CONTEXT_CONTROL or CONTEXT_FLOATING_POINT) or
-        CONTEXT_INTEGER
-    CONTEXT_DEBUGGER* = CONTEXT_FULL
-when defined(cpui386):
-  # x86
-  # The doc refered me to winnt.h, so I had to look...
-  const
-    SIZE_OF_80387_REGISTERS* = 80 # Values for contextflags
-    CONTEXT_i386* = 0x00010000 # this assumes that i386 and
-    CONTEXT_i486* = 0x00010000 # i486 have identical context records
-    CONTEXT_CONTROL* = CONTEXT_i386 or 1 # SS:SP, CS:IP, FLAGS, BP
-    CONTEXT_INTEGER* = CONTEXT_i386 or 2 # AX, BX, CX, DX, SI, DI
-    CONTEXT_SEGMENTS* = CONTEXT_i386 or 4 # DS, ES, FS, GS
-    CONTEXT_FLOATING_POINT* = CONTEXT_i386 or 8 # 387 state
-    CONTEXT_DEBUG_REGISTERS* = CONTEXT_i386 or 0x00000010 # DB 0-3,6,7
-    CONTEXT_EXTENDED_REGISTERS* = CONTEXT_i386 or 0x00000020 # cpu specific extensions
-    CONTEXT_FULL* = (CONTEXT_CONTROL or CONTEXT_INTEGER) or CONTEXT_SEGMENTS
-    CONTEXT_ALL* = CONTEXT_FULL or CONTEXT_FLOATING_POINT or
-        CONTEXT_DEBUG_REGISTERS or CONTEXT_EXTENDED_REGISTERS # our own invention
-    FLAG_TRACE_BIT* = 0x00000100
-    CONTEXT_DEBUGGER* = CONTEXT_FULL or CONTEXT_FLOATING_POINT
-when defined(cpux86_64):
-  const
-    INITIAL_MXCSR* = 0x00001F80 # initial MXCSR value
-    INITIAL_FPCSR* = 0x0000027F # initial FPCSR value
-    CONTEXT_AMD64* = 0x00100000
-    CONTEXT_CONTROL* = (CONTEXT_AMD64 or 0x00000001)
-    CONTEXT_INTEGER* = (CONTEXT_AMD64 or 0x00000002)
-    CONTEXT_SEGMENTS* = (CONTEXT_AMD64 or 0x00000004)
-    CONTEXT_FLOATING_POINT* = (CONTEXT_AMD64 or 0x00000008)
-    CONTEXT_DEBUG_REGISTERS* = (CONTEXT_AMD64 or 0x00000010)
-    CONTEXT_FULL* = (
-      CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_FLOATING_POINT)
-    CONTEXT_ALL* = (CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS or
-        CONTEXT_FLOATING_POINT or CONTEXT_DEBUG_REGISTERS)
-    CONTEXT_EXCEPTION_ACTIVE* = 0x08000000
-    CONTEXT_SERVICE_ACTIVE* = 0x10000000
-    CONTEXT_EXCEPTION_REQUEST* = 0x40000000
-    CONTEXT_EXCEPTION_REPORTING* = 0x80000000
-const
-  FILTER_TEMP_DUPLICATE_ACCOUNT* = 0x00000001
-  FILTER_NORMAL_ACCOUNT* = 0x00000002
-  FILTER_INTERDOMAIN_TRUST_ACCOUNT* = 0x00000008
-  FILTER_WORKSTATION_TRUST_ACCOUNT* = 0x00000010
-  FILTER_SERVER_TRUST_ACCOUNT* = 0x00000020
-  LOGON32_LOGON_INTERACTIVE* = 0x00000002
-  LOGON32_LOGON_BATCH* = 0x00000004
-  LOGON32_LOGON_SERVICE* = 0x00000005
-  LOGON32_PROVIDER_DEFAULT* = 0x00000000
-  LOGON32_PROVIDER_WINNT35* = 0x00000001
-  QID_SYNC* = 0xFFFFFFFF      # Magic numbers in PE executable header.
-                              # e_magic field
-  IMAGE_DOS_SIGNATURE* = 0x00005A4D # nt_signature field
-  IMAGE_NT_SIGNATURE* = 0x00004550 # Severity values
-  SEVERITY_SUCCESS* = 0
-  SEVERITY_ERROR* = 1         # Variant type codes (wtypes.h).
-                              #    Some, not all though
-  VT_EMPTY* = 0
-  VT_NULL* = 1
-  VT_I2* = 2
-  VT_I4* = 3
-  VT_R4* = 4
-  VT_R8* = 5
-  VT_BSTR* = 8
-  VT_ERROR* = 10
-  VT_BOOL* = 11
-  VT_UI1* = 17
-  VT_BYREF* = 0x00004000
-  VT_RESERVED* = 0x00008000   # Define the facility codes
-
-const
-  FACILITY_WINDOWS* = 8
-  FACILITY_STORAGE* = 3
-  FACILITY_RPC* = 1
-  FACILITY_SSPI* = 9
-  FACILITY_WIN32* = 7
-  FACILITY_CONTROL* = 10
-  FACILITY_NULL* = 0
-  FACILITY_INTERNET* = 12
-  FACILITY_ITF* = 4
-  FACILITY_DISPATCH* = 2
-  FACILITY_CERT* = 11         # Manually added, bug 2672
-  ICON_SMALL* = 0
-  ICON_BIG* = 1               # For the TRackMouseEvent
-  TME_HOVER* = 0x00000001
-  TME_LEAVE* = 0x00000002
-  TME_QUERY* = 0x40000000
-  TME_CANCEL* = DWORD(0x80000000)
-  HOVER_DEFAULT* = DWORD(0xFFFFFFFF) # Manually added, bug 3270
-  COLOR_HOTLIGHT* = 26
-  COLOR_GRADIENTACTIVECAPTION* = 27
-  COLOR_GRADIENTINACTIVECAPTION* = 28
-  COLOR_MENUHILIGHT* = 29
-  COLOR_MENUBAR* = 30
-  WM_APP* = 0x00008000
-  SYSRGN* = 4
-  UIS_SET* = 1
-  UIS_CLEAR* = 2
-  UIS_INITIALIZE* = 3
-  UISF_HIDEFOCUS* = 0x00000001
-  UISF_HIDEACCEL* = 0x00000002
-  UISF_ACTIVE* = 0x00000004
-
-type                          # WARNING
-                              #      the variable argument list
-                              #      is not implemented for FPC
-                              #      va_list is just a dummy record
-                              #      MvdV: Nevertheless it should be a pointer type, not a record
-  va_list* = cstring
-  TABC* {.final, pure.} = object
-    abcA*: int32
-    abcB*: UINT
-    abcC*: int32
-
-  LPABC* = ptr TABC
-  PABC* = ptr TABC
-  TABCFLOAT* {.final, pure.} = object
-    abcfA*: float32
-    abcfB*: float32
-    abcfC*: float32
-  LPABCFLOAT* = ptr TABCFLOAT
-  PABCFLOAT* = ptr TABCFLOAT
-
-  TACCEL* {.final, pure.} = object
-    fVirt*: int8
-    key*: int16
-    cmd*: int16
-  LPACCEL* = ptr TACCEL
-  PACCEL* = ptr TACCEL
-  ACE_HEADER* {.final, pure.} = object
-    AceType*: int8
-    AceFlags*: int8
-    AceSize*: int16
-
-  TACE_HEADER* = ACE_HEADER
-  PACE_HEADER* = ptr ACE_HEADER
-  ACCESS_MASK* = DWORD
-  REGSAM* = ACCESS_MASK
-  ACCESS_ALLOWED_ACE* {.final, pure.} = object
-    Header*: ACE_HEADER
-    Mask*: ACCESS_MASK
-    SidStart*: DWORD
-
-  TACCESS_ALLOWED_ACE* = ACCESS_ALLOWED_ACE
-  PACCESS_ALLOWED_ACE* = ptr ACCESS_ALLOWED_ACE
-  ACCESS_DENIED_ACE* {.final, pure.} = object
-    Header*: ACE_HEADER
-    Mask*: ACCESS_MASK
-    SidStart*: DWORD
-
-  TACCESS_DENIED_ACE* = ACCESS_DENIED_ACE
-  ACCESSTIMEOUT* {.final, pure.} = object
-    cbSize*: UINT
-    dwFlags*: DWORD
-    iTimeOutMSec*: DWORD
-
-  TACCESSTIMEOUT* = ACCESSTIMEOUT
-  PACCESSTIMEOUT* = ptr ACCESSTIMEOUT
-  ACL* {.final, pure.} = object
-    AclRevision*: int8
-    Sbz1*: int8
-    AclSize*: int16
-    AceCount*: int16
-    Sbz2*: int16
-
-  PACL* = ptr ACL
-  TACL* = ACL
-  TACL_REVISION_INFORMATION* {.final, pure.} = object
-    AclRevision*: DWORD
-  PACLREVISIONINFORMATION* = ptr TACL_REVISION_INFORMATION
-
-  TACL_SIZE_INFORMATION* {.final, pure.} = object
-    AceCount*: DWORD
-    AclBytesInUse*: DWORD
-    AclBytesFree*: DWORD
-  PACLSIZEINFORMATION* = ptr TACL_SIZE_INFORMATION
-  ACTION_HEADER* {.final, pure.} = object
-    transport_id*: ULONG
-    action_code*: USHORT
-    reserved*: USHORT
-
-  TACTIONHEADER* = ACTION_HEADER
-  PACTIONHEADER* = ptr ACTION_HEADER
-  ADAPTER_STATUS* {.final, pure.} = object
-    adapter_address*: array[0..5, UCHAR]
-    rev_major*: UCHAR
-    reserved0*: UCHAR
-    adapter_type*: UCHAR
-    rev_minor*: UCHAR
-    duration*: int16
-    frmr_recv*: int16
-    frmr_xmit*: int16
-    iframe_recv_err*: int16
-    xmit_aborts*: int16
-    xmit_success*: DWORD
-    recv_success*: DWORD
-    iframe_xmit_err*: int16
-    recv_buff_unavail*: int16
-    t1_timeouts*: int16
-    ti_timeouts*: int16
-    reserved1*: DWORD
-    free_ncbs*: int16
-    max_cfg_ncbs*: int16
-    max_ncbs*: int16
-    xmit_buf_unavail*: int16
-    max_dgram_size*: int16
-    pending_sess*: int16
-    max_cfg_sess*: int16
-    max_sess*: int16
-    max_sess_pkt_size*: int16
-    name_count*: int16
-
-  TADAPTERSTATUS* = ADAPTER_STATUS
-  PADAPTERSTATUS* = ptr ADAPTER_STATUS
-  ADDJOB_INFO_1* {.final, pure.} = object
-    Path*: LPTSTR
-    JobId*: DWORD
-
-  TADDJOB_INFO_1* = ADDJOB_INFO_1
-  PADDJOB_INFO_1* = ptr ADDJOB_INFO_1
-  ANIMATIONINFO* {.final, pure.} = object
-    cbSize*: UINT
-    iMinAnimate*: int32
-
-  LPANIMATIONINFO* = ptr ANIMATIONINFO
-  TANIMATIONINFO* = ANIMATIONINFO
-  PANIMATIONINFO* = ptr ANIMATIONINFO
-  POINT* {.final, pure.} = object
-    x*: LONG
-    y*: LONG
-
-  LPPOINT* = ptr POINT
-  TPOINT* = POINT
-  PPOINT* = ptr POINT
-  RECT* {.final, pure.} = object
-    TopLeft*, BottomRight*: TPoint
-
-  LPRECT* = ptr RECT
-  TRECT* = RECT
-  PRECT* = ptr RECT
-  RECTL* {.final, pure.} = object
-    left*: LONG
-    top*: LONG
-    right*: LONG
-    bottom*: LONG
-
-  TRECTL* = RECTL
-  PRECTL* = ptr RECTL
-  APPBARDATA* {.final, pure.} = object
-    cbSize*: DWORD
-    hWnd*: HWND
-    uCallbackMessage*: UINT
-    uEdge*: UINT
-    rc*: RECT
-    lParam*: LPARAM
-
-  TAppBarData* = APPBARDATA
-  PAppBarData* = ptr APPBARDATA
-  BITMAP* {.final, pure.} = object
-    bmType*: LONG
-    bmWidth*: LONG
-    bmHeight*: LONG
-    bmWidthBytes*: LONG
-    bmPlanes*: int16
-    bmBitsPixel*: int16
-    bmBits*: LPVOID
-
-  PBITMAP* = ptr BITMAP
-  NPBITMAP* = ptr BITMAP
-  LPBITMAP* = ptr BITMAP
-  TBITMAP* = BITMAP
-  BITMAPCOREHEADER* {.final, pure.} = object
-    bcSize*: DWORD
-    bcWidth*: int16
-    bcHeight*: int16
-    bcPlanes*: int16
-    bcBitCount*: int16
-
-  TBITMAPCOREHEADER* = BITMAPCOREHEADER
-  PBITMAPCOREHEADER* = ptr BITMAPCOREHEADER
-  RGBTRIPLE* {.final, pure.} = object
-    rgbtBlue*: int8
-    rgbtGreen*: int8
-    rgbtRed*: int8
-
-  TRGBTRIPLE* = RGBTRIPLE
-  PRGBTRIPLE* = ptr RGBTRIPLE
-  BITMAPCOREINFO* {.final, pure.} = object
-    bmciHeader*: BITMAPCOREHEADER
-    bmciColors*: array[0..0, RGBTRIPLE]
-
-  PBITMAPCOREINFO* = ptr BITMAPCOREINFO
-  LPBITMAPCOREINFO* = ptr BITMAPCOREINFO
-  TBITMAPCOREINFO* = BITMAPCOREINFO # error
-                                    #  WORD    bfReserved1;
-                                    #  WORD    bfReserved2;
-                                    # in declarator_list
-  BITMAPINFOHEADER* {.final, pure.} = object
-    biSize*: DWORD
-    biWidth*: LONG
-    biHeight*: LONG
-    biPlanes*: int16
-    biBitCount*: int16
-    biCompression*: DWORD
-    biSizeImage*: DWORD
-    biXPelsPerMeter*: LONG
-    biYPelsPerMeter*: LONG
-    biClrUsed*: DWORD
-    biClrImportant*: DWORD
-
-  LPBITMAPINFOHEADER* = ptr BITMAPINFOHEADER
-  TBITMAPINFOHEADER* = BITMAPINFOHEADER
-  PBITMAPINFOHEADER* = ptr BITMAPINFOHEADER
-  RGBQUAD* {.final, pure.} = object
-    rgbBlue*: int8
-    rgbGreen*: int8
-    rgbRed*: int8
-    rgbReserved*: int8
-
-  TRGBQUAD* = RGBQUAD
-  PRGBQUAD* = ptr RGBQUAD
-  BITMAPINFO* {.final, pure.} = object
-    bmiHeader*: BITMAPINFOHEADER
-    bmiColors*: array[0..0, RGBQUAD]
-
-  LPBITMAPINFO* = ptr BITMAPINFO
-  PBITMAPINFO* = ptr BITMAPINFO
-  TBITMAPINFO* = BITMAPINFO
-  FXPT2DOT30* = int32
-  LPFXPT2DOT30* = ptr FXPT2DOT30
-  TPFXPT2DOT30* = FXPT2DOT30
-  PPFXPT2DOT30* = ptr FXPT2DOT30
-  CIEXYZ* {.final, pure.} = object
-    ciexyzX*: FXPT2DOT30
-    ciexyzY*: FXPT2DOT30
-    ciexyzZ*: FXPT2DOT30
-
-  LPCIEXYZ* = ptr CIEXYZ
-  TPCIEXYZ* = CIEXYZ
-  PCIEXYZ* = ptr CIEXYZ
-  CIEXYZTRIPLE* {.final, pure.} = object
-    ciexyzRed*: CIEXYZ
-    ciexyzGreen*: CIEXYZ
-    ciexyzBlue*: CIEXYZ
-
-  LPCIEXYZTRIPLE* = ptr CIEXYZTRIPLE
-  TCIEXYZTRIPLE* = CIEXYZTRIPLE
-  PCIEXYZTRIPLE* = ptr CIEXYZTRIPLE
-  BITMAPV4HEADER* {.final, pure.} = object
-    bV4Size*: DWORD
-    bV4Width*: LONG
-    bV4Height*: LONG
-    bV4Planes*: int16
-    bV4BitCount*: int16
-    bV4V4Compression*: DWORD
-    bV4SizeImage*: DWORD
-    bV4XPelsPerMeter*: LONG
-    bV4YPelsPerMeter*: LONG
-    bV4ClrUsed*: DWORD
-    bV4ClrImportant*: DWORD
-    bV4RedMask*: DWORD
-    bV4GreenMask*: DWORD
-    bV4BlueMask*: DWORD
-    bV4AlphaMask*: DWORD
-    bV4CSType*: DWORD
-    bV4Endpoints*: CIEXYZTRIPLE
-    bV4GammaRed*: DWORD
-    bV4GammaGreen*: DWORD
-    bV4GammaBlue*: DWORD
-
-  LPBITMAPV4HEADER* = ptr BITMAPV4HEADER
-  TBITMAPV4HEADER* = BITMAPV4HEADER
-  PBITMAPV4HEADER* = ptr BITMAPV4HEADER
-  BITMAPFILEHEADER* {.final, pure.} = object
-    bfType*: int16
-    bfSize*: DWord
-    bfReserved1*: int16
-    bfReserved2*: int16
-    bfOffBits*: DWord
-
-  BLOB* {.final, pure.} = object
-    cbSize*: ULONG
-    pBlobData*: ptr int8
-
-  TBLOB* = BLOB
-  PBLOB* = ptr BLOB
-  SHITEMID* {.final, pure.} = object
-    cb*: USHORT
-    abID*: array[0..0, int8]
-
-  LPSHITEMID* = ptr SHITEMID
-  LPCSHITEMID* = ptr SHITEMID
-  TSHITEMID* = SHITEMID
-  PSHITEMID* = ptr SHITEMID
-  ITEMIDLIST* {.final, pure.} = object
-    mkid*: SHITEMID
-
-  LPITEMIDLIST* = ptr ITEMIDLIST
-  LPCITEMIDLIST* = ptr ITEMIDLIST
-  TITEMIDLIST* = ITEMIDLIST
-  PITEMIDLIST* = ptr ITEMIDLIST
-  BROWSEINFO* {.final, pure.} = object
-    hwndOwner*: HWND
-    pidlRoot*: LPCITEMIDLIST
-    pszDisplayName*: LPSTR
-    lpszTitle*: LPCSTR
-    ulFlags*: UINT
-    lpfn*: BFFCALLBACK
-    lParam*: LPARAM
-    iImage*: int32
-
-  LPBROWSEINFO* = ptr BROWSEINFO
-  Tbrowseinfo* = BROWSEINFO
-  PBROWSEINFO* = ptr BROWSEINFO
-  FILETIME* {.final, pure.} = object
-    dwLowDateTime*: DWORD
-    dwHighDateTime*: DWORD
-
-  LPFILETIME* = ptr FILETIME
-  TFILETIME* = FILETIME
-  PFILETIME* = ptr FILETIME
-  BY_HANDLE_FILE_INFORMATION* {.final, pure.} = object
-    dwFileAttributes*: DWORD
-    ftCreationTime*: FILETIME
-    ftLastAccessTime*: FILETIME
-    ftLastWriteTime*: FILETIME
-    dwVolumeSerialNumber*: DWORD
-    nFileSizeHigh*: DWORD
-    nFileSizeLow*: DWORD
-    nNumberOfLinks*: DWORD
-    nFileIndexHigh*: DWORD
-    nFileIndexLow*: DWORD
-
-  LPBY_HANDLE_FILE_INFORMATION* = ptr BY_HANDLE_FILE_INFORMATION
-  TBYHANDLEFILEINFORMATION* = BY_HANDLE_FILE_INFORMATION
-  PBYHANDLEFILEINFORMATION* = ptr BY_HANDLE_FILE_INFORMATION
-  FIXED* {.final, pure.} = object
-    fract*: int16
-    value*: SHORT
-
-  TFIXED* = FIXED
-  PFIXED* = ptr FIXED
-  POINTFX* {.final, pure.} = object
-    x*: FIXED
-    y*: FIXED
-
-  TPOINTFX* = POINTFX
-  PPOINTFX* = ptr POINTFX
-  POINTL* {.final, pure.} = object
-    x*: LONG
-    y*: LONG
-
-  TPOINTL* = POINTL
-  PPOINTL* = ptr POINTL
-  TSmallPoint* {.final, pure.} = object
-    X*, Y*: SHORT
-
-  POINTS* {.final, pure.} = object
-    x*: SHORT
-    y*: SHORT
-
-  TPOINTS* = POINTS
-  PPOINTS* = ptr POINTS
-  CANDIDATEFORM* {.final, pure.} = object
-    dwIndex*: DWORD
-    dwStyle*: DWORD
-    ptCurrentPos*: POINT
-    rcArea*: RECT
-
-  LPCANDIDATEFORM* = ptr CANDIDATEFORM
-  TCANDIDATEFORM* = CANDIDATEFORM
-  PCANDIDATEFORM* = ptr CANDIDATEFORM
-  CANDIDATELIST* {.final, pure.} = object
-    dwSize*: DWORD
-    dwStyle*: DWORD
-    dwCount*: DWORD
-    dwSelection*: DWORD
-    dwPageStart*: DWORD
-    dwPageSize*: DWORD
-    dwOffset*: array[0..0, DWORD]
-
-  LPCANDIDATELIST* = ptr CANDIDATELIST
-  TCANDIDATELIST* = CANDIDATELIST
-  PCANDIDATELIST* = ptr CANDIDATELIST
-  CREATESTRUCT* {.final, pure.} = object
-    lpCreateParams*: LPVOID
-    hInstance*: HINST
-    hMenu*: HMENU
-    hwndParent*: HWND
-    cy*: int32
-    cx*: int32
-    y*: int32
-    x*: int32
-    style*: LONG
-    lpszName*: LPCTSTR
-    lpszClass*: LPCTSTR
-    dwExStyle*: DWORD
-
-  LPCREATESTRUCT* = ptr CREATESTRUCT
-  TCREATESTRUCT* = CREATESTRUCT
-  PCREATESTRUCT* = ptr CREATESTRUCT
-  CBT_CREATEWND* {.final, pure.} = object
-    lpcs*: LPCREATESTRUCT
-    hwndInsertAfter*: HWND
-
-  TCBT_CREATEWND* = CBT_CREATEWND
-  PCBT_CREATEWND* = ptr CBT_CREATEWND
-  CBTACTIVATESTRUCT* {.final, pure.} = object
-    fMouse*: WINBOOL
-    hWndActive*: HWND
-
-  TCBTACTIVATESTRUCT* = CBTACTIVATESTRUCT
-  PCBTACTIVATESTRUCT* = ptr CBTACTIVATESTRUCT
-  CHAR_INFO* {.final, pure.} = object
-    UnicodeChar*: WCHAR
-    Attributes*: int16        # other union part: AsciiChar : CHAR
-
-  TCHAR_INFO* = CHAR_INFO
-  PCHAR_INFO* = ptr CHAR_INFO
-  CHARFORMAT* {.final, pure.} = object
-    cbSize*: UINT
-    dwMask*: DWORD
-    dwEffects*: DWORD
-    yHeight*: LONG
-    yOffset*: LONG
-    crTextColor*: COLORREF
-    bCharSet*: int8
-    bPitchAndFamily*: int8
-    szFaceName*: array[0..(LF_FACESIZE) - 1, TCHAR]
-
-  Tcharformat* = CHARFORMAT
-  Pcharformat* = ptr CHARFORMAT
-  CHARRANGE* {.final, pure.} = object
-    cpMin*: LONG
-    cpMax*: LONG
-
-  Tcharrange* = CHARRANGE
-  Pcharrange* = ptr CHARRANGE
-  CHARSET* {.final, pure.} = object
-    aflBlock*: array[0..2, DWORD]
-    flLang*: DWORD
-
-  TCHARSET* = CHARSET
-  PCHARSET* = ptr CHARSET
-  FONTSIGNATURE* {.final, pure.} = object
-    fsUsb*: array[0..3, DWORD]
-    fsCsb*: array[0..1, DWORD]
-
-  LPFONTSIGNATURE* = ptr FONTSIGNATURE
-  TFONTSIGNATURE* = FONTSIGNATURE
-  PFONTSIGNATURE* = ptr FONTSIGNATURE
-  CHARSETINFO* {.final, pure.} = object
-    ciCharset*: UINT
-    ciACP*: UINT
-    fs*: FONTSIGNATURE
-
-  LPCHARSETINFO* = ptr CHARSETINFO
-  TCHARSETINFO* = CHARSETINFO
-  PCHARSETINFO* = ptr CHARSETINFO #CHOOSECOLOR = record confilcts with function ChooseColor
-  TCHOOSECOLOR* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hInstance*: HWND
-    rgbResult*: COLORREF
-    lpCustColors*: ptr COLORREF
-    Flags*: DWORD
-    lCustData*: LPARAM
-    lpfnHook*: LPCCHOOKPROC
-    lpTemplateName*: LPCTSTR
-
-  LPCHOOSECOLOR* = ptr TCHOOSECOLOR
-  PCHOOSECOLOR* = ptr TCHOOSECOLOR
-  LOGFONT* {.final, pure.} = object
-    lfHeight*: LONG
-    lfWidth*: LONG
-    lfEscapement*: LONG
-    lfOrientation*: LONG
-    lfWeight*: LONG
-    lfItalic*: int8
-    lfUnderline*: int8
-    lfStrikeOut*: int8
-    lfCharSet*: int8
-    lfOutPrecision*: int8
-    lfClipPrecision*: int8
-    lfQuality*: int8
-    lfPitchAndFamily*: int8
-    lfFaceName*: array[0..(LF_FACESIZE) - 1, TCHAR]
-
-  LPLOGFONT* = ptr LOGFONT
-  TLOGFONT* = LOGFONT
-  TLOGFONTA* = LOGFONT
-  PLOGFONT* = ptr LOGFONT
-  PLOGFONTA* = PLOGFONT
-  LOGFONTW* {.final, pure.} = object
-    lfHeight*: LONG
-    lfWidth*: LONG
-    lfEscapement*: LONG
-    lfOrientation*: LONG
-    lfWeight*: LONG
-    lfItalic*: int8
-    lfUnderline*: int8
-    lfStrikeOut*: int8
-    lfCharSet*: int8
-    lfOutPrecision*: int8
-    lfClipPrecision*: int8
-    lfQuality*: int8
-    lfPitchAndFamily*: int8
-    lfFaceName*: array[0..LF_FACESIZE - 1, WCHAR]
-
-  LPLOGFONTW* = ptr LOGFONTW
-  NPLOGFONTW* = ptr LOGFONTW
-  TLogFontW* = LOGFONTW
-  PLogFontW* = ptr TLogFontW
-  TCHOOSEFONT* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hDC*: HDC
-    lpLogFont*: LPLOGFONT
-    iPointSize*: WINT
-    Flags*: DWORD
-    rgbColors*: DWORD
-    lCustData*: LPARAM
-    lpfnHook*: LPCFHOOKPROC
-    lpTemplateName*: LPCTSTR
-    hInstance*: HINST
-    lpszStyle*: LPTSTR
-    nFontType*: int16
-    MISSING_ALIGNMENT*: int16
-    nSizeMin*: WINT
-    nSizeMax*: WINT
-
-  LPCHOOSEFONT* = ptr TCHOOSEFONT
-  PCHOOSEFONT* = ptr TCHOOSEFONT
-  CIDA* {.final, pure.} = object
-    cidl*: UINT
-    aoffset*: array[0..0, UINT]
-
-  LPIDA* = ptr CIDA
-  TIDA* = CIDA
-  PIDA* = ptr CIDA
-  CLIENTCREATESTRUCT* {.final, pure.} = object
-    hWindowMenu*: HANDLE
-    idFirstChild*: UINT
-
-  LPCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT
-  TCLIENTCREATESTRUCT* = CLIENTCREATESTRUCT
-  PCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT
-  CMINVOKECOMMANDINFO* {.final, pure.} = object
-    cbSize*: DWORD
-    fMask*: DWORD
-    hwnd*: HWND
-    lpVerb*: LPCSTR
-    lpParameters*: LPCSTR
-    lpDirectory*: LPCSTR
-    nShow*: int32
-    dwHotKey*: DWORD
-    hIcon*: HANDLE
-
-  LPCMINVOKECOMMANDINFO* = ptr CMINVOKECOMMANDINFO
-  TCMInvokeCommandInfo* = CMINVOKECOMMANDINFO
-  PCMInvokeCommandInfo* = ptr CMINVOKECOMMANDINFO
-  COLORADJUSTMENT* {.final, pure.} = object
-    caSize*: int16
-    caFlags*: int16
-    caIlluminantIndex*: int16
-    caRedGamma*: int16
-    caGreenGamma*: int16
-    caBlueGamma*: int16
-    caReferenceBlack*: int16
-    caReferenceWhite*: int16
-    caContrast*: SHORT
-    caBrightness*: SHORT
-    caColorfulness*: SHORT
-    caRedGreenTint*: SHORT
-
-  LPCOLORADJUSTMENT* = ptr COLORADJUSTMENT
-  TCOLORADJUSTMENT* = COLORADJUSTMENT
-  PCOLORADJUSTMENT* = ptr COLORADJUSTMENT
-  COLORMAP* {.final, pure.} = object
-    `from`*: COLORREF
-    `to`*: COLORREF          # XXX!
-
-  LPCOLORMAP* = ptr COLORMAP
-  TCOLORMAP* = COLORMAP
-  PCOLORMAP* = ptr COLORMAP
-  DCB* {.final, pure.} = object
-    DCBlength*: DWORD
-    BaudRate*: DWORD
-    flags*: DWORD
-    wReserved*: int16
-    XonLim*: int16
-    XoffLim*: int16
-    ByteSize*: int8
-    Parity*: int8
-    StopBits*: int8
-    XonChar*: char
-    XoffChar*: char
-    ErrorChar*: char
-    EofChar*: char
-    EvtChar*: char
-    wReserved1*: int16
-
-  LPDCB* = ptr DCB
-  TDCB* = DCB
-  PDCB* = ptr DCB
-
-const
-  bm_DCB_fBinary* = 0x00000001
-  bp_DCB_fBinary* = 0
-  bm_DCB_fParity* = 0x00000002
-  bp_DCB_fParity* = 1
-  bm_DCB_fOutxCtsFlow* = 0x00000004
-  bp_DCB_fOutxCtsFlow* = 2
-  bm_DCB_fOutxDsrFlow* = 0x00000008
-  bp_DCB_fOutxDsrFlow* = 3
-  bm_DCB_fDtrControl* = 0x00000030
-  bp_DCB_fDtrControl* = 4
-  bm_DCB_fDsrSensitivity* = 0x00000040
-  bp_DCB_fDsrSensitivity* = 6
-  bm_DCB_fTXContinueOnXoff* = 0x00000080
-  bp_DCB_fTXContinueOnXoff* = 7
-  bm_DCB_fOutX* = 0x00000100
-  bp_DCB_fOutX* = 8
-  bm_DCB_fInX* = 0x00000200
-  bp_DCB_fInX* = 9
-  bm_DCB_fErrorChar* = 0x00000400
-  bp_DCB_fErrorChar* = 10
-  bm_DCB_fNull* = 0x00000800
-  bp_DCB_fNull* = 11
-  bm_DCB_fRtsControl* = 0x00003000
-  bp_DCB_fRtsControl* = 12
-  bm_DCB_fAbortOnError* = 0x00004000
-  bp_DCB_fAbortOnError* = 14
-  bm_DCB_fDummy2* = 0xFFFF8000
-  bp_DCB_fDummy2* = 15
-
-proc fBinary*(a: var DCB): DWORD
-proc set_fBinary*(a: var DCB, fBinary: DWORD)
-proc fParity*(a: var DCB): DWORD
-proc set_fParity*(a: var DCB, fParity: DWORD)
-proc fOutxCtsFlow*(a: var DCB): DWORD
-proc set_fOutxCtsFlow*(a: var DCB, fOutxCtsFlow: DWORD)
-proc fOutxDsrFlow*(a: var DCB): DWORD
-proc set_fOutxDsrFlow*(a: var DCB, fOutxDsrFlow: DWORD)
-proc fDtrControl*(a: var DCB): DWORD
-proc set_fDtrControl*(a: var DCB, fDtrControl: DWORD)
-proc fDsrSensitivity*(a: var DCB): DWORD
-proc set_fDsrSensitivity*(a: var DCB, fDsrSensitivity: DWORD)
-proc fTXContinueOnXoff*(a: var DCB): DWORD
-proc set_fTXContinueOnXoff*(a: var DCB, fTXContinueOnXoff: DWORD)
-proc fOutX*(a: var DCB): DWORD
-proc set_fOutX*(a: var DCB, fOutX: DWORD)
-proc fInX*(a: var DCB): DWORD
-proc set_fInX*(a: var DCB, fInX: DWORD)
-proc fErrorChar*(a: var DCB): DWORD
-proc set_fErrorChar*(a: var DCB, fErrorChar: DWORD)
-proc fNull*(a: var DCB): DWORD
-proc set_fNull*(a: var DCB, fNull: DWORD)
-proc fRtsControl*(a: var DCB): DWORD
-proc set_fRtsControl*(a: var DCB, fRtsControl: DWORD)
-proc fAbortOnError*(a: var DCB): DWORD
-proc set_fAbortOnError*(a: var DCB, fAbortOnError: DWORD)
-proc fDummy2*(a: var DCB): DWORD
-proc set_fDummy2*(a: var DCB, fDummy2: DWORD)
-type
-  COMMCONFIG* {.final, pure.} = object
-    dwSize*: DWORD
-    wVersion*: int16
-    wReserved*: int16
-    dcb*: DCB
-    dwProviderSubType*: DWORD
-    dwProviderOffset*: DWORD
-    dwProviderSize*: DWORD
-    wcProviderData*: array[0..0, WCHAR]
-
-  LPCOMMCONFIG* = ptr COMMCONFIG
-  TCOMMCONFIG* = COMMCONFIG
-  PCOMMCONFIG* = ptr COMMCONFIG
-  COMMPROP* {.final, pure.} = object
-    wPacketLength*: int16
-    wPacketVersion*: int16
-    dwServiceMask*: DWORD
-    dwReserved1*: DWORD
-    dwMaxTxQueue*: DWORD
-    dwMaxRxQueue*: DWORD
-    dwMaxBaud*: DWORD
-    dwProvSubType*: DWORD
-    dwProvCapabilities*: DWORD
-    dwSettableParams*: DWORD
-    dwSettableBaud*: DWORD
-    wSettableData*: int16
-    wSettableStopParity*: int16
-    dwCurrentTxQueue*: DWORD
-    dwCurrentRxQueue*: DWORD
-    dwProvSpec1*: DWORD
-    dwProvSpec2*: DWORD
-    wcProvChar*: array[0..0, WCHAR]
-
-  LPCOMMPROP* = ptr COMMPROP
-  TCOMMPROP* = COMMPROP
-  PCOMMPROP* = ptr COMMPROP
-  COMMTIMEOUTS* {.final, pure.} = object
-    ReadIntervalTimeout*: DWORD
-    ReadTotalTimeoutMultiplier*: DWORD
-    ReadTotalTimeoutConstant*: DWORD
-    WriteTotalTimeoutMultiplier*: DWORD
-    WriteTotalTimeoutConstant*: DWORD
-
-  LPCOMMTIMEOUTS* = ptr COMMTIMEOUTS
-  TCOMMTIMEOUTS* = COMMTIMEOUTS
-  PCOMMTIMEOUTS* = ptr COMMTIMEOUTS
-  COMPAREITEMSTRUCT* {.final, pure.} = object
-    CtlType*: UINT
-    CtlID*: UINT
-    hwndItem*: HWND
-    itemID1*: UINT
-    itemData1*: ULONG_PTR
-    itemID2*: UINT
-    itemData2*: ULONG_PTR
-
-  TCOMPAREITEMSTRUCT* = COMPAREITEMSTRUCT
-  PCOMPAREITEMSTRUCT* = ptr COMPAREITEMSTRUCT
-  COMPCOLOR* {.final, pure.} = object
-    crText*: COLORREF
-    crBackground*: COLORREF
-    dwEffects*: DWORD
-
-  TCOMPCOLOR* = COMPCOLOR
-  PCOMPCOLOR* = ptr COMPCOLOR
-  COMPOSITIONFORM* {.final, pure.} = object
-    dwStyle*: DWORD
-    ptCurrentPos*: POINT
-    rcArea*: RECT
-
-  LPCOMPOSITIONFORM* = ptr COMPOSITIONFORM
-  TCOMPOSITIONFORM* = COMPOSITIONFORM
-  PCOMPOSITIONFORM* = ptr COMPOSITIONFORM #     TComStatFlags = set of (fCtsHold, fDsrHold, fRlsdHold , fXoffHold ,
-                                          #                    fXoffSent , fEof ,  fTxim  , fReserved);
-  COMSTAT* {.final, pure.} = object
-    flag0*: DWORD             # can't use tcomstatflags, set packing issues
-                              # and conflicts with macro's
-    cbInQue*: DWORD
-    cbOutQue*: DWORD
-
-  LPCOMSTAT* = ptr COMSTAT
-  TCOMSTAT* = COMSTAT
-  PCOMSTAT* = ptr COMSTAT
-
-const
-  bm_COMSTAT_fCtsHold* = 0x00000001
-  bp_COMSTAT_fCtsHold* = 0
-  bm_COMSTAT_fDsrHold* = 0x00000002
-  bp_COMSTAT_fDsrHold* = 1
-  bm_COMSTAT_fRlsdHold* = 0x00000004
-  bp_COMSTAT_fRlsdHold* = 2
-  bm_COMSTAT_fXoffHold* = 0x00000008
-  bp_COMSTAT_fXoffHold* = 3
-  bm_COMSTAT_fXoffSent* = 0x00000010
-  bp_COMSTAT_fXoffSent* = 4
-  bm_COMSTAT_fEof* = 0x00000020
-  bp_COMSTAT_fEof* = 5
-  bm_COMSTAT_fTxim* = 0x00000040
-  bp_COMSTAT_fTxim* = 6
-  bm_COMSTAT_fReserved* = 0xFFFFFF80
-  bp_COMSTAT_fReserved* = 7
-
-proc fCtsHold*(a: var COMSTAT): DWORD
-  # should be renamed to get_<x>?
-proc set_fCtsHold*(a: var COMSTAT, fCtsHold: DWORD)
-proc fDsrHold*(a: var COMSTAT): DWORD
-proc set_fDsrHold*(a: var COMSTAT, fDsrHold: DWORD)
-proc fRlsdHold*(a: var COMSTAT): DWORD
-proc set_fRlsdHold*(a: var COMSTAT, fRlsdHold: DWORD)
-proc fXoffHold*(a: var COMSTAT): DWORD
-proc set_fXoffHold*(a: var COMSTAT, fXoffHold: DWORD)
-proc fXoffSent*(a: var COMSTAT): DWORD
-proc set_fXoffSent*(a: var COMSTAT, fXoffSent: DWORD)
-proc fEof*(a: var COMSTAT): DWORD
-proc set_fEof*(a: var COMSTAT, fEof: DWORD)
-proc fTxim*(a: var COMSTAT): DWORD
-proc set_fTxim*(a: var COMSTAT, fTxim: DWORD)
-proc fReserved*(a: var COMSTAT): DWORD
-proc set_fReserved*(a: var COMSTAT, fReserved: DWORD)
-type
-  CONSOLE_CURSOR_INFO* {.final, pure.} = object
-    dwSize*: DWORD
-    bVisible*: WINBOOL
-
-  PCONSOLE_CURSOR_INFO* = ptr CONSOLE_CURSOR_INFO
-  TCONSOLECURSORINFO* = CONSOLE_CURSOR_INFO
-  TCURSORINFO* = CONSOLE_CURSOR_INFO
-  COORD* {.final, pure.} = object
-    X*: SHORT
-    Y*: SHORT
-
-  TCOORD* = COORD
-  PCOORD* = ptr COORD
-  SMALL_RECT* {.final, pure.} = object
-    Left*: SHORT
-    Top*: SHORT
-    Right*: SHORT
-    Bottom*: SHORT
-
-  TSMALL_RECT* = SMALL_RECT
-  PSMALL_RECT* = ptr SMALL_RECT
-  CONSOLE_SCREEN_BUFFER_INFO* {.final, pure.} = object
-    dwSize*: COORD
-    dwCursorPosition*: COORD
-    wAttributes*: int16
-    srWindow*: SMALL_RECT
-    dwMaximumWindowSize*: COORD
-
-  PCONSOLE_SCREEN_BUFFER_INFO* = ptr CONSOLE_SCREEN_BUFFER_INFO
-  TCONSOLESCREENBUFFERINFO* = CONSOLE_SCREEN_BUFFER_INFO
-
-when defined(i386):
-  type
-    FLOATING_SAVE_AREA* {.final, pure.} = object
-      ControlWord*: DWORD
-      StatusWord*: DWORD
-      TagWord*: DWORD
-      ErrorOffset*: DWORD
-      ErrorSelector*: DWORD
-      DataOffset*: DWORD
-      DataSelector*: DWORD
-      RegisterArea*: array[0..79, int8]
-      Cr0NpxState*: DWORD
-
-    TFLOATINGSAVEAREA* = FLOATING_SAVE_AREA
-    PFLOATINGSAVEAREA* = ptr FLOATING_SAVE_AREA
-    CONTEXT* {.final, pure.} = object
-      ContextFlags*: DWORD
-      Dr0*: DWORD
-      Dr1*: DWORD
-      Dr2*: DWORD
-      Dr3*: DWORD
-      Dr6*: DWORD
-      Dr7*: DWORD
-      FloatSave*: FLOATING_SAVE_AREA
-      SegGs*: DWORD
-      SegFs*: DWORD
-      SegEs*: DWORD
-      SegDs*: DWORD
-      Edi*: DWORD
-      Esi*: DWORD
-      Ebx*: DWORD
-      Edx*: DWORD
-      Ecx*: DWORD
-      Eax*: DWORD
-      Ebp*: DWORD
-      Eip*: DWORD
-      SegCs*: DWORD
-      EFlags*: DWORD
-      Esp*: DWORD
-      SegSs*: DWORD
-
-when defined(x86_64):
-  #
-  # Define 128-bit 16-byte aligned xmm register type.
-  #
-  type
-    M128A* {.final, pure.} = object
-      Low*: ULONGLONG
-      High*: LONGLONG
-
-    TM128A* = M128A
-    PM128A* = TM128A #
-                     # Format of data for 32-bit fxsave/fxrstor instructions.
-                     #
-                     #typedef struct _XMM_SAVE_AREA32 {
-  type
-    XMM_SAVE_AREA32* {.final, pure.} = object
-      ControlWord*: int16
-      StatusWord*: int16
-      TagWord*: int8
-      Reserved1*: int8
-      ErrorOpcode*: int16
-      ErrorOffset*: DWORD
-      ErrorSelector*: int16
-      Reserved2*: int16
-      DataOffset*: DWORD
-      DataSelector*: int16
-      Reserved3*: int16
-      MxCsr*: DWORD
-      MxCsr_Mask*: DWORD
-      FloatRegisters*: array[0..7, M128A]
-      XmmRegisters*: array[0..16, M128A]
-      Reserved4*: array[0..95, int8]
-
-    TXmmSaveArea* = XMM_SAVE_AREA32
-    PXmmSaveArea* = ptr TXmmSaveArea
-  type
-    CONTEXT* {.final, pure.} = object
-      P1Home*: DWORD64
-      P2Home*: DWORD64
-      P3Home*: DWORD64
-      P4Home*: DWORD64
-      P5Home*: DWORD64
-      P6Home*: DWORD64        #
-                              # Control flags.
-                              #
-      ContextFlags*: DWORD
-      MxCsr*: DWORD           #
-                              # Segment Registers and processor flags.
-                              #
-      SegCs*: int16
-      SegDs*: int16
-      SegEs*: int16
-      SegFs*: int16
-      SegGs*: int16
-      SegSs*: int16
-      EFlags*: DWORD          #
-                              # Debug registers
-                              #
-      Dr0*: DWORD64
-      Dr1*: DWORD64
-      Dr2*: DWORD64
-      Dr3*: DWORD64
-      Dr6*: DWORD64
-      Dr7*: DWORD64           #
-                              # Integer registers.
-                              #
-      Rax*: DWORD64
-      Rcx*: DWORD64
-      Rdx*: DWORD64
-      Rbx*: DWORD64
-      Rsp*: DWORD64
-      Rbp*: DWORD64
-      Rsi*: DWORD64
-      Rdi*: DWORD64
-      R8*: DWORD64
-      R9*: DWORD64
-      R10*: DWORD64
-      R11*: DWORD64
-      R12*: DWORD64
-      R13*: DWORD64
-      R14*: DWORD64
-      R15*: DWORD64           #
-                              # Program counter.
-                              #
-      Rip*: DWORD64           #
-                              # Floating point state.
-                              #
-      FltSave*: XMM_SAVE_AREA32 # MWE: only translated the FltSave part of the union
-                                #
-                                # Vector registers.
-                                #
-      VectorRegister*: array[0..25, M128A]
-      VectorControl*: DWORD64 #
-                              # Special debug control registers.
-                              #
-      DebugControl*: DWORD64
-      LastBranchToRip*: DWORD64
-      LastBranchFromRip*: DWORD64
-      LastExceptionToRip*: DWORD64
-      LastExceptionFromRip*: DWORD64
-
-when defined(powerpc32):
-  # ppc
-  # Floating point registers returned when CONTEXT_FLOATING_POINT is set
-  # Integer registers returned when CONTEXT_INTEGER is set.
-  # Condition register
-  # Fixed point exception register
-  # The following are set when CONTEXT_CONTROL is set.
-  # Machine status register
-  # Instruction address register
-  # Link register
-  # Control register
-  # Control which context values are returned
-  # Registers returned if CONTEXT_DEBUG_REGISTERS is set.
-  # Breakpoint Register 1
-  # Breakpoint Register 2
-  # Breakpoint Register 3
-  # Breakpoint Register 4
-  # Breakpoint Register 5
-  # Breakpoint Register 6
-  # Debug Status Register
-  # Debug Control Register
-  type
-    CONTEXT* {.final, pure.} = object
-      Fpr0*: float64
-      Fpr1*: float64
-      Fpr2*: float64
-      Fpr3*: float64
-      Fpr4*: float64
-      Fpr5*: float64
-      Fpr6*: float64
-      Fpr7*: float64
-      Fpr8*: float64
-      Fpr9*: float64
-      Fpr10*: float64
-      Fpr11*: float64
-      Fpr12*: float64
-      Fpr13*: float64
-      Fpr14*: float64
-      Fpr15*: float64
-      Fpr16*: float64
-      Fpr17*: float64
-      Fpr18*: float64
-      Fpr19*: float64
-      Fpr20*: float64
-      Fpr21*: float64
-      Fpr22*: float64
-      Fpr23*: float64
-      Fpr24*: float64
-      Fpr25*: float64
-      Fpr26*: float64
-      Fpr27*: float64
-      Fpr28*: float64
-      Fpr29*: float64
-      Fpr30*: float64
-      Fpr31*: float64
-      Fpscr*: float64
-      Gpr0*: DWORD
-      Gpr1*: DWORD
-      Gpr2*: DWORD
-      Gpr3*: DWORD
-      Gpr4*: DWORD
-      Gpr5*: DWORD
-      Gpr6*: DWORD
-      Gpr7*: DWORD
-      Gpr8*: DWORD
-      Gpr9*: DWORD
-      Gpr10*: DWORD
-      Gpr11*: DWORD
-      Gpr12*: DWORD
-      Gpr13*: DWORD
-      Gpr14*: DWORD
-      Gpr15*: DWORD
-      Gpr16*: DWORD
-      Gpr17*: DWORD
-      Gpr18*: DWORD
-      Gpr19*: DWORD
-      Gpr20*: DWORD
-      Gpr21*: DWORD
-      Gpr22*: DWORD
-      Gpr23*: DWORD
-      Gpr24*: DWORD
-      Gpr25*: DWORD
-      Gpr26*: DWORD
-      Gpr27*: DWORD
-      Gpr28*: DWORD
-      Gpr29*: DWORD
-      Gpr30*: DWORD
-      Gpr31*: DWORD
-      Cr*: DWORD
-      Xer*: DWORD
-      Msr*: DWORD
-      Iar*: DWORD
-      Lr*: DWORD
-      Ctr*: DWORD
-      ContextFlags*: DWORD
-      Fill*: array[0..2, DWORD]
-      Dr0*: DWORD
-      Dr1*: DWORD
-      Dr2*: DWORD
-      Dr3*: DWORD
-      Dr4*: DWORD
-      Dr5*: DWORD
-      Dr6*: DWORD
-      Dr7*: DWORD
-
-type
-  LPCONTEXT* = ptr CONTEXT
-  TCONTEXT* = CONTEXT
-  PCONTEXT* = ptr CONTEXT
-
-type
-  LIST_ENTRY* {.final, pure.} = object
-    Flink*: ptr LIST_ENTRY
-    Blink*: ptr LIST_ENTRY
-
-  TLISTENTRY* = LIST_ENTRY
-  PLISTENTRY* = ptr LIST_ENTRY
-  CRITICAL_SECTION_DEBUG* {.final, pure.} = object
-    `type`*: int16
-    CreatorBackTraceIndex*: int16
-    CriticalSection*: ptr TCRITICAL_SECTION
-    ProcessLocksList*: LIST_ENTRY
-    EntryCount*: DWORD
-    ContentionCount*: DWORD
-    Depth*: DWORD
-    OwnerBackTrace*: array[0..4, PVOID]
-
-  TRTL_CRITICAL_SECTION* {.final, pure.} = object
-    DebugInfo*: ptr CRITICAL_SECTION_DEBUG
-    LockCount*: int32
-    RecursionCount*: int32
-    OwningThread*: Handle
-    LockSemaphore*: Handle
-    Reserved*: DWORD
-
-  PRTLCriticalSection* = ptr TRTLCriticalSection
-
-  LPCRITICAL_SECTION_DEBUG* = ptr CRITICAL_SECTION_DEBUG
-  PCRITICAL_SECTION_DEBUG* = ptr CRITICAL_SECTION_DEBUG
-  TCRITICALSECTIONDEBUG* = CRITICAL_SECTION_DEBUG
-  TCRITICAL_SECTION* = TRTLCriticalSection
-  PCRITICAL_SECTION* = PRTLCriticalSection
-  LPCRITICAL_SECTION* = PRTLCriticalSection
-  SECURITY_QUALITY_OF_SERVICE* {.final, pure.} = object
-    len*: DWORD
-    ImpersonationLevel*: SECURITY_IMPERSONATION_LEVEL
-    ContextTrackingMode*: WINBOOL
-    EffectiveOnly*: bool
-
-  PSECURITY_QUALITY_OF_SERVICE* = ptr SECURITY_QUALITY_OF_SERVICE
-  TSECURITYQUALITYOFSERVICE* = SECURITY_QUALITY_OF_SERVICE
-  CONVCONTEXT* {.final, pure.} = object
-    cb*: UINT
-    wFlags*: UINT
-    wCountryID*: UINT
-    iCodePage*: int32
-    dwLangID*: DWORD
-    dwSecurity*: DWORD
-    qos*: SECURITY_QUALITY_OF_SERVICE
-
-  TCONVCONTEXT* = CONVCONTEXT
-  PCONVCONTEXT* = ptr CONVCONTEXT
-  CONVINFO* {.final, pure.} = object
-    cb*: DWORD
-    hUser*: DWORD
-    hConvPartner*: HCONV
-    hszSvcPartner*: HSZ
-    hszServiceReq*: HSZ
-    hszTopic*: HSZ
-    hszItem*: HSZ
-    wFmt*: UINT
-    wType*: UINT
-    wStatus*: UINT
-    wConvst*: UINT
-    wLastError*: UINT
-    hConvList*: HCONVLIST
-    ConvCtxt*: CONVCONTEXT
-    hwnd*: HWND
-    hwndPartner*: HWND
-
-  TCONVINFO* = CONVINFO
-  PCONVINFO* = ptr CONVINFO
-  COPYDATASTRUCT* {.final, pure.} = object
-    dwData*: DWORD
-    cbData*: DWORD
-    lpData*: PVOID
-
-  TCOPYDATASTRUCT* = COPYDATASTRUCT
-  PCOPYDATASTRUCT* = ptr COPYDATASTRUCT
-  CPINFO* {.final, pure.} = object
-    MaxCharSize*: UINT
-    DefaultChar*: array[0..(MAX_DEFAULTCHAR) - 1, int8]
-    LeadByte*: array[0..(MAX_LEADBYTES) - 1, int8]
-
-  LPCPINFO* = ptr CPINFO
-  Tcpinfo* = CPINFO
-  Pcpinfo* = ptr CPINFO
-  CPLINFO* {.final, pure.} = object
-    idIcon*: int32
-    idName*: int32
-    idInfo*: int32
-    lData*: LONG
-
-  TCPLINFO* = CPLINFO
-  PCPLINFO* = ptr CPLINFO
-  CREATE_PROCESS_DEBUG_INFO* {.final, pure.} = object
-    hFile*: HANDLE
-    hProcess*: HANDLE
-    hThread*: HANDLE
-    lpBaseOfImage*: LPVOID
-    dwDebugInfoFileOffset*: DWORD
-    nDebugInfoSize*: DWORD
-    lpThreadLocalBase*: LPVOID
-    lpStartAddress*: LPTHREAD_START_ROUTINE
-    lpImageName*: LPVOID
-    fUnicode*: int16
-
-  TCREATEPROCESSDEBUGINFO* = CREATE_PROCESS_DEBUG_INFO
-  PCREATEPROCESSDEBUGINFO* = ptr CREATE_PROCESS_DEBUG_INFO
-  CREATE_THREAD_DEBUG_INFO* {.final, pure.} = object
-    hThread*: HANDLE
-    lpThreadLocalBase*: LPVOID
-    lpStartAddress*: LPTHREAD_START_ROUTINE
-
-  TCREATETHREADDEBUGINFO* = CREATE_THREAD_DEBUG_INFO
-  PCREATETHREADDEBUGINFO* = ptr CREATE_THREAD_DEBUG_INFO #
-                                                         #   TODO: sockets
-                                                         #  typedef struct _SOCKET_ADDRESS {
-                                                         #    LPSOCKADDR lpSockaddr ;
-                                                         #    INT iSockaddrLength ;
-                                                         #  } SOCKET_ADDRESS,  PSOCKET_ADDRESS,  LPSOCKET_ADDRESS;
-                                                         #   }
-                                                         #  {
-                                                         #  typedef struct _CSADDR_INFO {
-                                                         #    SOCKET_ADDRESS  LocalAddr;
-                                                         #    SOCKET_ADDRESS  RemoteAddr;
-                                                         #    INT             iSocketType;
-                                                         #    INT             iProtocol;
-                                                         #  } CSADDR_INFO;
-                                                         #
-  CURRENCYFMT* {.final, pure.} = object
-    NumDigits*: UINT
-    LeadingZero*: UINT
-    Grouping*: UINT
-    lpDecimalSep*: LPTSTR
-    lpThousandSep*: LPTSTR
-    NegativeOrder*: UINT
-    PositiveOrder*: UINT
-    lpCurrencySymbol*: LPTSTR
-
-  Tcurrencyfmt* = CURRENCYFMT
-  Pcurrencyfmt* = ptr CURRENCYFMT
-  CURSORSHAPE* {.final, pure.} = object
-    xHotSpot*: int32
-    yHotSpot*: int32
-    cx*: int32
-    cy*: int32
-    cbWidth*: int32
-    Planes*: int8
-    BitsPixel*: int8
-
-  LPCURSORSHAPE* = ptr CURSORSHAPE
-  TCURSORSHAPE* = CURSORSHAPE
-  PCURSORSHAPE* = ptr CURSORSHAPE
-  CWPRETSTRUCT* {.final, pure.} = object
-    lResult*: LRESULT
-    lParam*: LPARAM
-    wParam*: WPARAM
-    message*: DWORD
-    hwnd*: HWND
-
-  TCWPRETSTRUCT* = CWPRETSTRUCT
-  PCWPRETSTRUCT* = ptr CWPRETSTRUCT
-  CWPSTRUCT* {.final, pure.} = object
-    lParam*: LPARAM
-    wParam*: WPARAM
-    message*: UINT
-    hwnd*: HWND
-
-  TCWPSTRUCT* = CWPSTRUCT
-  PCWPSTRUCT* = ptr CWPSTRUCT
-  DATATYPES_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-
-  TDATATYPESINFO1* = DATATYPES_INFO_1
-  PDATATYPESINFO1* = ptr DATATYPES_INFO_1
-  DDEACK* {.final, pure.} = object
-    flag0*: int16
-
-  TDDEACK* = DDEACK
-  PDDEACK* = ptr DDEACK
-
-const
-  bm_DDEACK_bAppReturnCode* = 0x000000FF'i16
-  bp_DDEACK_bAppReturnCode* = 0'i16
-  bm_DDEACK_reserved* = 0x00003F00'i16
-  bp_DDEACK_reserved* = 8'i16
-  bm_DDEACK_fBusy* = 0x00004000'i16
-  bp_DDEACK_fBusy* = 14'i16
-  bm_DDEACK_fAck* = 0x00008000'i16
-  bp_DDEACK_fAck* = 15'i16
-
-proc bAppReturnCode*(a: var DDEACK): int16
-proc set_bAppReturnCode*(a: var DDEACK, bAppReturnCode: int16)
-proc reserved*(a: var DDEACK): int16
-proc set_reserved*(a: var DDEACK, reserved: int16)
-proc fBusy*(a: var DDEACK): int16
-proc set_fBusy*(a: var DDEACK, fBusy: int16)
-proc fAck*(a: var DDEACK): int16
-proc set_fAck*(a: var DDEACK, fAck: int16)
-type
-  DDEADVISE* {.final, pure.} = object
-    flag0*: int16
-    cfFormat*: SHORT
-
-  TDDEADVISE* = DDEADVISE
-  PDDEADVISE* = ptr DDEADVISE
-
-const
-  bm_DDEADVISE_reserved* = 0x00003FFF'i16
-  bp_DDEADVISE_reserved* = 0'i16
-  bm_DDEADVISE_fDeferUpd* = 0x00004000'i16
-  bp_DDEADVISE_fDeferUpd* = 14'i16
-  bm_DDEADVISE_fAckReq* = 0x00008000'i16
-  bp_DDEADVISE_fAckReq* = 15'i16
-
-proc reserved*(a: var DDEADVISE): int16
-proc set_reserved*(a: var DDEADVISE, reserved: int16)
-proc fDeferUpd*(a: var DDEADVISE): int16
-proc set_fDeferUpd*(a: var DDEADVISE, fDeferUpd: int16)
-proc fAckReq*(a: var DDEADVISE): int16
-proc set_fAckReq*(a: var DDEADVISE, fAckReq: int16)
-type
-  DDEDATA* {.final, pure.} = object
-    flag0*: int16
-    cfFormat*: SHORT
-    Value*: array[0..0, int8]
-
-  PDDEDATA* = ptr DDEDATA
-
-const
-  bm_DDEDATA_unused* = 0x00000FFF'i16
-  bp_DDEDATA_unused* = 0'i16
-  bm_DDEDATA_fResponse* = 0x00001000'i16
-  bp_DDEDATA_fResponse* = 12'i16
-  bm_DDEDATA_fRelease* = 0x00002000'i16
-  bp_DDEDATA_fRelease* = 13'i16
-  bm_DDEDATA_reserved* = 0x00004000'i16
-  bp_DDEDATA_reserved* = 14'i16
-  bm_DDEDATA_fAckReq* = 0x00008000'i16
-  bp_DDEDATA_fAckReq* = 15'i16
-
-proc unused*(a: var DDEDATA): int16
-proc set_unused*(a: var DDEDATA, unused: int16)
-proc fResponse*(a: var DDEDATA): int16
-proc set_fResponse*(a: var DDEDATA, fResponse: int16)
-proc fRelease*(a: var DDEDATA): int16
-proc set_fRelease*(a: var DDEDATA, fRelease: int16)
-proc reserved*(a: var DDEDATA): int16
-proc set_reserved*(a: var DDEDATA, reserved: int16)
-proc fAckReq*(a: var DDEDATA): int16
-proc set_fAckReq*(a: var DDEDATA, fAckReq: int16)
-type
-  DDELN* {.final, pure.} = object
-    flag0*: int16
-    cfFormat*: SHORT
-
-  TDDELN* = DDELN
-  PDDELN* = ptr DDELN
-
-const
-  bm_DDELN_unused* = 0x00001FFF'i16
-  bp_DDELN_unused* = 0'i16
-  bm_DDELN_fRelease* = 0x00002000'i16
-  bp_DDELN_fRelease* = 13'i16
-  bm_DDELN_fDeferUpd* = 0x00004000'i16
-  bp_DDELN_fDeferUpd* = 14'i16
-  bm_DDELN_fAckReq* = 0x00008000'i16
-  bp_DDELN_fAckReq* = 15'i16
-
-proc unused*(a: var DDELN): int16
-proc set_unused*(a: var DDELN, unused: int16)
-proc fRelease*(a: var DDELN): int16
-proc set_fRelease*(a: var DDELN, fRelease: int16)
-proc fDeferUpd*(a: var DDELN): int16
-proc set_fDeferUpd*(a: var DDELN, fDeferUpd: int16)
-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
-    cbData*: DWORD
-    Data*: array[0..7, DWORD]
-
-  TDDEMLMSGHOOKDATA* = DDEML_MSG_HOOK_DATA
-  PDDEMLMSGHOOKDATA* = ptr DDEML_MSG_HOOK_DATA
-  DDEPOKE* {.final, pure.} = object
-    flag0*: int16
-    cfFormat*: SHORT
-    Value*: array[0..0, int8]
-
-  TDDEPOKE* = DDEPOKE
-  PDDEPOKE* = ptr DDEPOKE
-
-const
-  bm_DDEPOKE_unused* = 0x00001FFF'i16
-  bp_DDEPOKE_unused* = 0'i16
-  bm_DDEPOKE_fRelease* = 0x00002000'i16
-  bp_DDEPOKE_fRelease* = 13'i16
-  bm_DDEPOKE_fReserved* = 0x0000C000'i16
-  bp_DDEPOKE_fReserved* = 14'i16
-
-proc unused*(a: var DDEPOKE): int16
-proc set_unused*(a: var DDEPOKE, unused: int16)
-proc fRelease*(a: var DDEPOKE): int16
-proc set_fRelease*(a: var DDEPOKE, fRelease: int16)
-proc fReserved*(a: var DDEPOKE): int16
-proc set_fReserved*(a: var DDEPOKE, fReserved: int16)
-type
-  DDEUP* {.final, pure.} = object
-    flag0*: int16
-    cfFormat*: SHORT
-    rgb*: array[0..0, int8]
-
-  TDDEUP* = DDEUP
-  PDDEUP* = ptr DDEUP
-
-const
-  bm_DDEUP_unused* = 0x00000FFF'i16
-  bp_DDEUP_unused* = 0'i16
-  bm_DDEUP_fAck* = 0x00001000'i16
-  bp_DDEUP_fAck* = 12'i16
-  bm_DDEUP_fRelease* = 0x00002000'i16
-  bp_DDEUP_fRelease* = 13'i16
-  bm_DDEUP_fReserved* = 0x00004000'i16
-  bp_DDEUP_fReserved* = 14'i16
-  bm_DDEUP_fAckReq* = 0x00008000'i16
-  bp_DDEUP_fAckReq* = 15'i16
-
-proc unused*(a: var DDEUP): int16
-proc set_unused*(a: var DDEUP, unused: int16)
-proc fAck*(a: var DDEUP): int16
-proc set_fAck*(a: var DDEUP, fAck: int16)
-proc fRelease*(a: var DDEUP): int16
-proc set_fRelease*(a: var DDEUP, fRelease: int16)
-proc fReserved*(a: var DDEUP): int16
-proc set_fReserved*(a: var DDEUP, fReserved: int16)
-proc fAckReq*(a: var DDEUP): int16
-proc set_fAckReq*(a: var DDEUP, fAckReq: int16)
-type
-  EXCEPTION_RECORD* {.final, pure.} = object
-    ExceptionCode*: DWORD
-    ExceptionFlags*: DWORD
-    ExceptionRecord*: ptr EXCEPTION_RECORD
-    ExceptionAddress*: PVOID
-    NumberParameters*: DWORD
-    ExceptionInformation*: array[0..(EXCEPTION_MAXIMUM_PARAMETERS) - 1,
-                                 ULONG_PTR]
-
-  PEXCEPTION_RECORD* = ptr EXCEPTION_RECORD
-  TEXCEPTIONRECORD* = EXCEPTION_RECORD
-  EXCEPTION_DEBUG_INFO* {.final, pure.} = object
-    ExceptionRecord*: EXCEPTION_RECORD
-    dwFirstChance*: DWORD
-
-  PEXCEPTION_DEBUG_INFO* = ptr EXCEPTION_DEBUG_INFO
-  TEXCEPTIONDEBUGINFO* = EXCEPTION_DEBUG_INFO
-  EXCEPTION_RECORD32* {.final, pure.} = object
-    ExceptionCode*: DWORD
-    ExceptionFlags*: DWORD
-    ExceptionRecord*: DWORD
-    ExceptionAddress*: DWORD
-    NumberParameters*: DWORD
-    ExceptionInformation*: array[0..(EXCEPTION_MAXIMUM_PARAMETERS) - 1, DWORD]
-
-  PEXCEPTION_RECORD32* = ptr EXCEPTION_RECORD32
-  TExceptionRecord32* = EXCEPTION_RECORD32
-  EXCEPTION_DEBUG_INFO32* {.final, pure.} = object
-    ExceptionRecord*: EXCEPTION_RECORD32
-    dwFirstChance*: DWORD
-
-  PEXCEPTION_DEBUG_INFO32* = ptr EXCEPTION_DEBUG_INFO32
-  TExceptionDebugInfo32* = EXCEPTION_DEBUG_INFO32
-  EXCEPTION_RECORD64* {.final, pure.} = object
-    ExceptionCode*: DWORD
-    ExceptionFlags*: DWORD
-    ExceptionRecord*: DWORD64
-    ExceptionAddress*: DWORD64
-    NumberParameters*: DWORD
-    unusedAlignment*: DWORD
-    ExceptionInformation*: array[0..(EXCEPTION_MAXIMUM_PARAMETERS) - 1, DWORD64]
-
-  PEXCEPTION_RECORD64* = ptr EXCEPTION_RECORD64
-  TExceptionRecord64* = EXCEPTION_RECORD64
-  EXCEPTION_DEBUG_INFO64* {.final, pure.} = object
-    ExceptionRecord*: EXCEPTION_RECORD64
-    dwFirstChance*: DWORD
-
-  PEXCEPTION_DEBUG_INFO64* = ptr EXCEPTION_DEBUG_INFO64
-  TExceptionDebugInfo64* = EXCEPTION_DEBUG_INFO64
-  EXIT_PROCESS_DEBUG_INFO* {.final, pure.} = object
-    dwExitCode*: DWORD
-
-  TEXITPROCESSDEBUGINFO* = EXIT_PROCESS_DEBUG_INFO
-  PEXITPROCESSDEBUGINFO* = ptr EXIT_PROCESS_DEBUG_INFO
-  EXIT_THREAD_DEBUG_INFO* {.final, pure.} = object
-    dwExitCode*: DWORD
-
-  TEXITTHREADDEBUGINFO* = EXIT_THREAD_DEBUG_INFO
-  PEXITTHREADDEBUGINFO* = ptr EXIT_THREAD_DEBUG_INFO
-  LOAD_DLL_DEBUG_INFO* {.final, pure.} = object
-    hFile*: HANDLE
-    lpBaseOfDll*: LPVOID
-    dwDebugInfoFileOffset*: DWORD
-    nDebugInfoSize*: DWORD
-    lpImageName*: LPVOID
-    fUnicode*: int16
-
-  TLOADDLLDEBUGINFO* = LOAD_DLL_DEBUG_INFO
-  PLOADDLLDEBUGINFO* = ptr LOAD_DLL_DEBUG_INFO
-  UNLOAD_DLL_DEBUG_INFO* {.final, pure.} = object
-    lpBaseOfDll*: LPVOID
-
-  TUNLOADDLLDEBUGINFO* = UNLOAD_DLL_DEBUG_INFO
-  PUNLOADDLLDEBUGINFO* = ptr UNLOAD_DLL_DEBUG_INFO
-  OUTPUT_DEBUG_STRING_INFO* {.final, pure.} = object
-    lpDebugStringData*: LPSTR
-    fUnicode*: int16
-    nDebugStringLength*: int16
-
-  TOUTPUTDEBUGSTRINGINFO* = OUTPUT_DEBUG_STRING_INFO
-  POUTPUTDEBUGSTRINGINFO* = ptr OUTPUT_DEBUG_STRING_INFO
-  RIP_INFO* {.final, pure.} = object
-    dwError*: DWORD
-    dwType*: DWORD
-
-  TRIPINFO* = RIP_INFO
-  PRIPINFO* = ptr RIP_INFO
-  DEBUG_EVENT* {.final, pure.} = object
-    dwDebugEventCode*: DWORD
-    dwProcessId*: DWORD
-    dwThreadId*: DWORD
-    data*: array[0..15, DWORD] #
-                               # case longint of
-                               # 0 : ( Exception : EXCEPTION_DEBUG_INFO );
-                               # 1 : ( CreateThread : CREATE_THREAD_DEBUG_INFO );
-                               # 2 : ( CreateProcessInfo : CREATE_PROCESS_DEBUG_INFO );
-                               # 3 : ( ExitThread : EXIT_THREAD_DEBUG_INFO );
-                               # 4 : ( ExitProcess : EXIT_PROCESS_DEBUG_INFO );
-                               # 5 : ( LoadDll : LOAD_DLL_DEBUG_INFO );
-                               # 6 : ( UnloadDll : UNLOAD_DLL_DEBUG_INFO );
-                               # 7 : ( DebugString : OUTPUT_DEBUG_STRING_INFO );
-                               # 8 : ( RipInfo : RIP_INFO );
-
-  LPDEBUG_EVENT* = ptr DEBUG_EVENT
-  TDEBUGEVENT* = DEBUG_EVENT
-  PDEBUGEVENT* = ptr DEBUG_EVENT
-  DEBUGHOOKINFO* {.final, pure.} = object
-    idThread*: DWORD
-    idThreadInstaller*: DWORD
-    lParam*: LPARAM
-    wParam*: WPARAM
-    code*: int32
-
-  TDEBUGHOOKINFO* = DEBUGHOOKINFO
-  PDEBUGHOOKINFO* = ptr DEBUGHOOKINFO
-  DELETEITEMSTRUCT* {.final, pure.} = object
-    CtlType*: UINT
-    CtlID*: UINT
-    itemID*: UINT
-    hwndItem*: HWND
-    itemData*: ULONG_PTR
-
-  TDELETEITEMSTRUCT* = DELETEITEMSTRUCT
-  PDELETEITEMSTRUCT* = ptr DELETEITEMSTRUCT
-  DEV_BROADCAST_HDR* {.final, pure.} = object
-    dbch_size*: ULONG
-    dbch_devicetype*: ULONG
-    dbch_reserved*: ULONG
-
-  PDEV_BROADCAST_HDR* = ptr DEV_BROADCAST_HDR
-  TDEVBROADCASTHDR* = DEV_BROADCAST_HDR
-  DEV_BROADCAST_OEM* {.final, pure.} = object
-    dbco_size*: ULONG
-    dbco_devicetype*: ULONG
-    dbco_reserved*: ULONG
-    dbco_identifier*: ULONG
-    dbco_suppfunc*: ULONG
-
-  PDEV_BROADCAST_OEM* = ptr DEV_BROADCAST_OEM
-  TDEVBROADCASTOEM* = DEV_BROADCAST_OEM
-  DEV_BROADCAST_PORT* {.final, pure.} = object
-    dbcp_size*: ULONG
-    dbcp_devicetype*: ULONG
-    dbcp_reserved*: ULONG
-    dbcp_name*: array[0..0, char]
-
-  PDEV_BROADCAST_PORT* = ptr DEV_BROADCAST_PORT
-  TDEVBROADCASTPORT* = DEV_BROADCAST_PORT
-  DEV_BROADCAST_USERDEFINED* {.final, pure.} = object
-    dbud_dbh*: DEV_BROADCAST_HDR
-    dbud_szName*: array[0..0, char]
-    dbud_rgbUserDefined*: array[0..0, int8]
-
-  TDEVBROADCASTUSERDEFINED* = DEV_BROADCAST_USERDEFINED
-  PDEVBROADCASTUSERDEFINED* = ptr DEV_BROADCAST_USERDEFINED
-  DEV_BROADCAST_VOLUME* {.final, pure.} = object
-    dbcv_size*: ULONG
-    dbcv_devicetype*: ULONG
-    dbcv_reserved*: ULONG
-    dbcv_unitmask*: ULONG
-    dbcv_flags*: USHORT
-
-  PDEV_BROADCAST_VOLUME* = ptr DEV_BROADCAST_VOLUME
-  TDEVBROADCASTVOLUME* = DEV_BROADCAST_VOLUME
-  DEVMODE* {.final, pure.} = object
-    dmDeviceName*: array[0..(CCHDEVICENAME) - 1, BCHAR]
-    dmSpecVersion*: int16
-    dmDriverVersion*: int16
-    dmSize*: int16
-    dmDriverExtra*: int16
-    dmFields*: DWORD
-    dmOrientation*: int16
-    dmPaperSize*: int16
-    dmPaperLength*: int16
-    dmPaperWidth*: int16
-    dmScale*: int16
-    dmCopies*: int16
-    dmDefaultSource*: int16
-    dmPrintQuality*: int16
-    dmColor*: int16
-    dmDuplex*: int16
-    dmYResolution*: int16
-    dmTTOption*: int16
-    dmCollate*: int16
-    dmFormName*: array[0..(CCHFORMNAME) - 1, BCHAR]
-    dmLogPixels*: int16
-    dmBitsPerPel*: DWORD
-    dmPelsWidth*: DWORD
-    dmPelsHeight*: DWORD
-    dmDisplayFlags*: DWORD
-    dmDisplayFrequency*: DWORD
-    dmICMMethod*: DWORD
-    dmICMIntent*: DWORD
-    dmMediaType*: DWORD
-    dmDitherType*: DWORD
-    dmICCManufacturer*: DWORD
-    dmICCModel*: DWORD        # other union part:
-                              # dmPosition: POINTL;
-                              # dmDisplayOrientation: DWORD;
-                              # dmDisplayFixedOutput: DWORD;
-
-  LPDEVMODE* = ptr DEVMODE
-  devicemode* = DEVMODE
-  tdevicemode* = DEVMODE
-  tdevicemodeA* = DEVMODE
-  PDeviceModeA* = LPDEVMODE
-  PDeviceMode* = LPDEVMODE
-  TDEVMODE* = DEVMODE
-  PDEVMODE* = LPDEVMODE
-  devmodeW* {.final, pure.} = object
-    dmDeviceName*: array[0..CCHDEVICENAME - 1, WCHAR]
-    dmSpecVersion*: int16
-    dmDriverVersion*: int16
-    dmSize*: int16
-    dmDriverExtra*: int16
-    dmFields*: DWORD
-    dmOrientation*: short
-    dmPaperSize*: short
-    dmPaperLength*: short
-    dmPaperWidth*: short
-    dmScale*: short
-    dmCopies*: short
-    dmDefaultSource*: short
-    dmPrintQuality*: short
-    dmColor*: short
-    dmDuplex*: short
-    dmYResolution*: short
-    dmTTOption*: short
-    dmCollate*: short
-    dmFormName*: array[0..CCHFORMNAME - 1, wchar]
-    dmLogPixels*: int16
-    dmBitsPerPel*: DWORD
-    dmPelsWidth*: DWORD
-    dmPelsHeight*: DWORD
-    dmDisplayFlags*: DWORD
-    dmDisplayFrequency*: DWORD
-    dmICMMethod*: DWORD
-    dmICMIntent*: DWORD
-    dmMediaType*: DWORD
-    dmDitherType*: DWORD
-    dmReserved1*: DWORD
-    dmReserved2*: DWORD
-    dmPanningWidth*: DWORD
-    dmPanningHeight*: DWORD
-
-  LPDEVMODEW* = ptr DEVMODEW
-  devicemodeW* = DEVMODEW
-  TDeviceModeW* = DEVMODEW
-  PDeviceModeW* = LPDEVMODEW
-  TDEVMODEW* = DEVMODEW
-  PDEVMODEW* = LPDEVMODEW
-  DEVNAMES* {.final, pure.} = object
-    wDriverOffset*: int16
-    wDeviceOffset*: int16
-    wOutputOffset*: int16
-    wDefault*: int16
-
-  LPDEVNAMES* = ptr DEVNAMES
-  TDEVNAMES* = DEVNAMES
-  PDEVNAMES* = ptr DEVNAMES
-  DIBSECTION* {.final, pure.} = object
-    dsBm*: BITMAP
-    dsBmih*: BITMAPINFOHEADER
-    dsBitfields*: array[0..2, DWORD]
-    dshSection*: HANDLE
-    dsOffset*: DWORD
-
-  TDIBSECTION* = DIBSECTION
-  PDIBSECTION* = ptr DIBSECTION #
-                                #     LARGE_INTEGER = record
-                                #        case byte of
-                                #          0: (LowPart : DWORD;
-                                #              HighPart : LONG);
-                                #          1: (QuadPart : LONGLONG);
-                                #       end;     ULARGE_INTEGER = record
-                                #        case byte of
-                                #          0: (LowPart : DWORD;
-                                #              HighPart : DWORD);
-                                #          1: (QuadPart : LONGLONG);
-                                #       end;
-                                #
-  LARGE_INTEGER* = int64
-  ULARGE_INTEGER* = int64
-  PLARGE_INTEGER* = ptr LARGE_INTEGER
-  TLargeInteger* = Int64
-  PULARGE_INTEGER* = ptr ULARGE_INTEGER
-  TULargeInteger* = int64
-  DISK_GEOMETRY* {.final, pure.} = object
-    Cylinders*: LARGE_INTEGER
-    MediaType*: MEDIA_TYPE
-    TracksPerCylinder*: DWORD
-    SectorsPerTrack*: DWORD
-    BytesPerSector*: DWORD
-
-  TDISKGEOMETRY* = DISK_GEOMETRY
-  PDISKGEOMETRY* = ptr DISK_GEOMETRY
-  DISK_PERFORMANCE* {.final, pure.} = object
-    BytesRead*: LARGE_INTEGER
-    BytesWritten*: LARGE_INTEGER
-    ReadTime*: LARGE_INTEGER
-    WriteTime*: LARGE_INTEGER
-    ReadCount*: DWORD
-    WriteCount*: DWORD
-    QueueDepth*: DWORD
-
-  TDISKPERFORMANCE* = DISK_PERFORMANCE
-  PDISKPERFORMANCE* = ptr DISK_PERFORMANCE
-  DLGITEMTEMPLATE* {.final, pure.} = object
-    style*: DWORD
-    dwExtendedStyle*: DWORD
-    x*: int16
-    y*: int16
-    cx*: int16
-    cy*: int16
-    id*: int16
-
-  LPDLGITEMTEMPLATE* = ptr DLGITEMTEMPLATE
-  TDLGITEMTEMPLATE* = DLGITEMTEMPLATE
-  PDLGITEMTEMPLATE* = ptr DLGITEMTEMPLATE
-  DLGTEMPLATE* {.final, pure.} = object
-    style*: DWORD
-    dwExtendedStyle*: DWORD
-    cdit*: int16
-    x*: int16
-    y*: int16
-    cx*: int16
-    cy*: int16
-
-  LPDLGTEMPLATE* = ptr DLGTEMPLATE
-  LPCDLGTEMPLATE* = ptr DLGTEMPLATE
-  TDLGTEMPLATE* = DLGTEMPLATE
-  PDLGTEMPLATE* = ptr DLGTEMPLATE
-  DOC_INFO_1* {.final, pure.} = object
-    pDocName*: LPTSTR
-    pOutputFile*: LPTSTR
-    pDatatype*: LPTSTR
-
-  TDOCINFO1* = DOC_INFO_1
-  PDOCINFO1* = ptr DOC_INFO_1
-  DOC_INFO_2* {.final, pure.} = object
-    pDocName*: LPTSTR
-    pOutputFile*: LPTSTR
-    pDatatype*: LPTSTR
-    dwMode*: DWORD
-    JobId*: DWORD
-
-  TDOCINFO2* = DOC_INFO_2
-  PDOCINFO2* = ptr DOC_INFO_2
-  DOCINFO* {.final, pure.} = object
-    cbSize*: int32
-    lpszDocName*: LPCTSTR
-    lpszOutput*: LPCTSTR
-    lpszDatatype*: LPCTSTR
-    fwType*: DWORD
-
-  TDOCINFO* = DOCINFO
-  TDOCINFOA* = DOCINFO
-  PDOCINFO* = ptr DOCINFO
-  DRAGLISTINFO* {.final, pure.} = object
-    uNotification*: UINT
-    hWnd*: HWND
-    ptCursor*: POINT
-
-  LPDRAGLISTINFO* = ptr DRAGLISTINFO
-  TDRAGLISTINFO* = DRAGLISTINFO
-  PDRAGLISTINFO* = ptr DRAGLISTINFO
-  DRAWITEMSTRUCT* {.final, pure.} = object
-    CtlType*: UINT
-    CtlID*: UINT
-    itemID*: UINT
-    itemAction*: UINT
-    itemState*: UINT
-    hwndItem*: HWND
-    hDC*: HDC
-    rcItem*: RECT
-    itemData*: ULONG_PTR
-
-  LPDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT
-  TDRAWITEMSTRUCT* = DRAWITEMSTRUCT
-  PDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT
-  DRAWTEXTPARAMS* {.final, pure.} = object
-    cbSize*: UINT
-    iTabLength*: int32
-    iLeftMargin*: int32
-    iRightMargin*: int32
-    uiLengthDrawn*: UINT
-
-  LPDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS
-  TDRAWTEXTPARAMS* = DRAWTEXTPARAMS
-  PDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS
-  PARTITION_INFORMATION* {.final, pure.} = object
-    PartitionType*: int8
-    BootIndicator*: bool
-    RecognizedPartition*: bool
-    RewritePartition*: bool
-    StartingOffset*: LARGE_INTEGER
-    PartitionLength*: LARGE_INTEGER
-    HiddenSectors*: LARGE_INTEGER
-
-  TPARTITIONINFORMATION* = PARTITION_INFORMATION
-  PPARTITIONINFORMATION* = ptr PARTITION_INFORMATION
-  DRIVE_LAYOUT_INFORMATION* {.final, pure.} = object
-    PartitionCount*: DWORD
-    Signature*: DWORD
-    PartitionEntry*: array[0..0, PARTITION_INFORMATION]
-
-  TDRIVELAYOUTINFORMATION* = DRIVE_LAYOUT_INFORMATION
-  PDRIVELAYOUTINFORMATION* = ptr DRIVE_LAYOUT_INFORMATION
-  DRIVER_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-
-  TDRIVERINFO1* = DRIVER_INFO_1
-  PDRIVERINFO1* = ptr DRIVER_INFO_1
-  DRIVER_INFO_2* {.final, pure.} = object
-    cVersion*: DWORD
-    pName*: LPTSTR
-    pEnvironment*: LPTSTR
-    pDriverPath*: LPTSTR
-    pDataFile*: LPTSTR
-    pConfigFile*: LPTSTR
-
-  TDRIVERINFO2* = DRIVER_INFO_2
-  PDRIVERINFO2* = ptr DRIVER_INFO_2
-  DRIVER_INFO_3* {.final, pure.} = object
-    cVersion*: DWORD
-    pName*: LPTSTR
-    pEnvironment*: LPTSTR
-    pDriverPath*: LPTSTR
-    pDataFile*: LPTSTR
-    pConfigFile*: LPTSTR
-    pHelpFile*: LPTSTR
-    pDependentFiles*: LPTSTR
-    pMonitorName*: LPTSTR
-    pDefaultDataType*: LPTSTR
-
-  TDRIVERINFO3* = DRIVER_INFO_3
-  PDRIVERINFO3* = ptr DRIVER_INFO_3
-  EDITSTREAM* {.final, pure.} = object
-    dwCookie*: DWORD
-    dwError*: DWORD
-    pfnCallback*: EDITSTREAMCALLBACK
-
-  Teditstream* = EDITSTREAM
-  Peditstream* = ptr EDITSTREAM
-  EMR* {.final, pure.} = object
-    iType*: DWORD
-    nSize*: DWORD
-
-  TEMR* = EMR
-  PEMR* = ptr EMR
-  EMRANGLEARC* {.final, pure.} = object
-    emr*: EMR
-    ptlCenter*: POINTL
-    nRadius*: DWORD
-    eStartAngle*: float32
-    eSweepAngle*: float32
-
-  TEMRANGLEARC* = EMRANGLEARC
-  PEMRANGLEARC* = ptr EMRANGLEARC
-  EMRARC* {.final, pure.} = object
-    emr*: EMR
-    rclBox*: RECTL
-    ptlStart*: POINTL
-    ptlEnd*: POINTL
-
-  TEMRARC* = EMRARC
-  PEMRARC* = ptr EMRARC
-  EMRARCTO* = EMRARC
-  TEMRARCTO* = EMRARC
-  PEMRARCTO* = ptr EMRARC
-  EMRCHORD* = EMRARC
-  TEMRCHORD* = EMRARC
-  PEMRCHORD* = ptr EMRARC
-  EMRPIE* = EMRARC
-  TEMRPIE* = EMRARC
-  PEMRPIE* = ptr EMRARC
-  XFORM* {.final, pure.} = object
-    eM11*: float32
-    eM12*: float32
-    eM21*: float32
-    eM22*: float32
-    eDx*: float32
-    eDy*: float32
-
-  LPXFORM* = ptr XFORM
-  TXFORM* = XFORM
-  PXFORM* = ptr XFORM
-  EMRBITBLT* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    xDest*: LONG
-    yDest*: LONG
-    cxDest*: LONG
-    cyDest*: LONG
-    dwRop*: DWORD
-    xSrc*: LONG
-    ySrc*: LONG
-    xformSrc*: XFORM
-    crBkColorSrc*: COLORREF
-    iUsageSrc*: DWORD
-    offBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-
-  TEMRBITBLT* = EMRBITBLT
-  PEMRBITBLT* = ptr EMRBITBLT
-  LOGBRUSH* {.final, pure.} = object
-    lbStyle*: UINT
-    lbColor*: COLORREF
-    lbHatch*: LONG
-
-  TLOGBRUSH* = LOGBRUSH
-  PLOGBRUSH* = ptr LOGBRUSH
-  EMRCREATEBRUSHINDIRECT* {.final, pure.} = object
-    emr*: EMR
-    ihBrush*: DWORD
-    lb*: LOGBRUSH
-
-  TEMRCREATEBRUSHINDIRECT* = EMRCREATEBRUSHINDIRECT
-  PEMRCREATEBRUSHINDIRECT* = ptr EMRCREATEBRUSHINDIRECT
-  LCSCSTYPE* = LONG
-  LCSGAMUTMATCH* = LONG
-  LOGCOLORSPACE* {.final, pure.} = object
-    lcsSignature*: DWORD
-    lcsVersion*: DWORD
-    lcsSize*: DWORD
-    lcsCSType*: LCSCSTYPE
-    lcsIntent*: LCSGAMUTMATCH
-    lcsEndpoints*: CIEXYZTRIPLE
-    lcsGammaRed*: DWORD
-    lcsGammaGreen*: DWORD
-    lcsGammaBlue*: DWORD
-    lcsFilename*: array[0..(MAX_PATH) - 1, TCHAR]
-
-  LPLOGCOLORSPACE* = ptr LOGCOLORSPACE
-  TLOGCOLORSPACE* = LOGCOLORSPACE
-  TLOGCOLORSPACEA* = LOGCOLORSPACE
-  PLOGCOLORSPACE* = ptr LOGCOLORSPACE
-  EMRCREATECOLORSPACE* {.final, pure.} = object
-    emr*: EMR
-    ihCS*: DWORD
-    lcs*: LOGCOLORSPACE
-
-  TEMRCREATECOLORSPACE* = EMRCREATECOLORSPACE
-  PEMRCREATECOLORSPACE* = ptr EMRCREATECOLORSPACE
-  EMRCREATEDIBPATTERNBRUSHPT* {.final, pure.} = object
-    emr*: EMR
-    ihBrush*: DWORD
-    iUsage*: DWORD
-    offBmi*: DWORD
-    cbBmi*: DWORD
-    offBits*: DWORD
-    cbBits*: DWORD
-
-  TEMRCREATEDIBPATTERNBRUSHPT* = EMRCREATEDIBPATTERNBRUSHPT
-  PEMRCREATEDIBPATTERNBRUSHPT* = EMRCREATEDIBPATTERNBRUSHPT
-  EMRCREATEMONOBRUSH* {.final, pure.} = object
-    emr*: EMR
-    ihBrush*: DWORD
-    iUsage*: DWORD
-    offBmi*: DWORD
-    cbBmi*: DWORD
-    offBits*: DWORD
-    cbBits*: DWORD
-
-  TEMRCREATEMONOBRUSH* = EMRCREATEMONOBRUSH
-  PEMRCREATEMONOBRUSH* = ptr EMRCREATEMONOBRUSH
-  PALETTEENTRY* {.final, pure.} = object
-    peRed*: int8
-    peGreen*: int8
-    peBlue*: int8
-    peFlags*: int8
-
-  LPPALETTEENTRY* = ptr PALETTEENTRY
-  TPALETTEENTRY* = PALETTEENTRY
-  PPALETTEENTRY* = ptr PALETTEENTRY
-  LOGPALETTE* {.final, pure.} = object
-    palVersion*: int16
-    palNumEntries*: int16
-    palPalEntry*: array[0..0, PALETTEENTRY]
-
-  LPLOGPALETTE* = ptr LOGPALETTE
-  TLOGPALETTE* = LOGPALETTE
-  PLOGPALETTE* = ptr LOGPALETTE
-  EMRCREATEPALETTE* {.final, pure.} = object
-    emr*: EMR
-    ihPal*: DWORD
-    lgpl*: LOGPALETTE
-
-  TEMRCREATEPALETTE* = EMRCREATEPALETTE
-  PEMRCREATEPALETTE* = ptr EMRCREATEPALETTE
-  LOGPEN* {.final, pure.} = object
-    lopnStyle*: UINT
-    lopnWidth*: POINT
-    lopnColor*: COLORREF
-
-  TLOGPEN* = LOGPEN
-  PLOGPEN* = ptr LOGPEN
-  EMRCREATEPEN* {.final, pure.} = object
-    emr*: EMR
-    ihPen*: DWORD
-    lopn*: LOGPEN
-
-  TEMRCREATEPEN* = EMRCREATEPEN
-  PEMRCREATEPEN* = ptr EMRCREATEPEN
-  EMRELLIPSE* {.final, pure.} = object
-    emr*: EMR
-    rclBox*: RECTL
-
-  TEMRELLIPSE* = EMRELLIPSE
-  PEMRELLIPSE* = ptr EMRELLIPSE
-  EMRRECTANGLE* = EMRELLIPSE
-  TEMRRECTANGLE* = EMRELLIPSE
-  PEMRRECTANGLE* = ptr EMRELLIPSE
-  EMREOF* {.final, pure.} = object
-    emr*: EMR
-    nPalEntries*: DWORD
-    offPalEntries*: DWORD
-    nSizeLast*: DWORD
-
-  TEMREOF* = EMREOF
-  PEMREOF* = ptr EMREOF
-  EMREXCLUDECLIPRECT* {.final, pure.} = object
-    emr*: EMR
-    rclClip*: RECTL
-
-  TEMREXCLUDECLIPRECT* = EMREXCLUDECLIPRECT
-  PEMREXCLUDECLIPRECT* = ptr EMREXCLUDECLIPRECT
-  EMRINTERSECTCLIPRECT* = EMREXCLUDECLIPRECT
-  TEMRINTERSECTCLIPRECT* = EMREXCLUDECLIPRECT
-  PEMRINTERSECTCLIPRECT* = ptr EMREXCLUDECLIPRECT
-  PANOSE* {.final, pure.} = object
-    bFamilyType*: int8
-    bSerifStyle*: int8
-    bWeight*: int8
-    bProportion*: int8
-    bContrast*: int8
-    bStrokeVariation*: int8
-    bArmStyle*: int8
-    bLetterform*: int8
-    bMidline*: int8
-    bXHeight*: int8
-
-  TPANOSE* = PANOSE
-  PPANOSE* = ptr PANOSE
-  EXTLOGFONT* {.final, pure.} = object
-    elfLogFont*: LOGFONT
-    elfFullName*: array[0..(LF_FULLFACESIZE) - 1, BCHAR]
-    elfStyle*: array[0..(LF_FACESIZE) - 1, BCHAR]
-    elfVersion*: DWORD
-    elfStyleSize*: DWORD
-    elfMatch*: DWORD
-    elfReserved*: DWORD
-    elfVendorId*: array[0..(ELF_VENDOR_SIZE) - 1, int8]
-    elfCulture*: DWORD
-    elfPanose*: PANOSE
-
-  TEXTLOGFONT* = EXTLOGFONT
-  PEXTLOGFONT* = ptr EXTLOGFONT
-  EMREXTCREATEFONTINDIRECTW* {.final, pure.} = object
-    emr*: EMR
-    ihFont*: DWORD
-    elfw*: EXTLOGFONT
-
-  TEMREXTCREATEFONTINDIRECTW* = EMREXTCREATEFONTINDIRECTW
-  PEMREXTCREATEFONTINDIRECTW* = ptr EMREXTCREATEFONTINDIRECTW
-  EXTLOGPEN* {.final, pure.} = object
-    elpPenStyle*: UINT
-    elpWidth*: UINT
-    elpBrushStyle*: UINT
-    elpColor*: COLORREF
-    elpHatch*: LONG
-    elpNumEntries*: DWORD
-    elpStyleEntry*: array[0..0, DWORD]
-
-  TEXTLOGPEN* = EXTLOGPEN
-  PEXTLOGPEN* = ptr EXTLOGPEN
-  EMREXTCREATEPEN* {.final, pure.} = object
-    emr*: EMR
-    ihPen*: DWORD
-    offBmi*: DWORD
-    cbBmi*: DWORD
-    offBits*: DWORD
-    cbBits*: DWORD
-    elp*: EXTLOGPEN
-
-  TEMREXTCREATEPEN* = EMREXTCREATEPEN
-  PEMREXTCREATEPEN* = ptr EMREXTCREATEPEN
-  EMREXTFLOODFILL* {.final, pure.} = object
-    emr*: EMR
-    ptlStart*: POINTL
-    crColor*: COLORREF
-    iMode*: DWORD
-
-  TEMREXTFLOODFILL* = EMREXTFLOODFILL
-  PEMREXTFLOODFILL* = ptr EMREXTFLOODFILL
-  EMREXTSELECTCLIPRGN* {.final, pure.} = object
-    emr*: EMR
-    cbRgnData*: DWORD
-    iMode*: DWORD
-    RgnData*: array[0..0, int8]
-
-  TEMREXTSELECTCLIPRGN* = EMREXTSELECTCLIPRGN
-  PEMREXTSELECTCLIPRGN* = ptr EMREXTSELECTCLIPRGN
-  EMRTEXT* {.final, pure.} = object
-    ptlReference*: POINTL
-    nChars*: DWORD
-    offString*: DWORD
-    fOptions*: DWORD
-    rcl*: RECTL
-    offDx*: DWORD
-
-  TEMRTEXT* = EMRTEXT
-  PEMRTEXT* = ptr EMRTEXT
-  EMREXTTEXTOUTA* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    iGraphicsMode*: DWORD
-    exScale*: float32
-    eyScale*: float32
-    emrtext*: EMRTEXT
-
-  TEMREXTTEXTOUTA* = EMREXTTEXTOUTA
-  PEMREXTTEXTOUTA* = ptr EMREXTTEXTOUTA
-  EMREXTTEXTOUTW* = EMREXTTEXTOUTA
-  TEMREXTTEXTOUTW* = EMREXTTEXTOUTA
-  PEMREXTTEXTOUTW* = ptr EMREXTTEXTOUTA
-  EMRFILLPATH* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-
-  TEMRFILLPATH* = EMRFILLPATH
-  PEMRFILLPATH* = ptr EMRFILLPATH
-  EMRSTROKEANDFILLPATH* = EMRFILLPATH
-  TEMRSTROKEANDFILLPATH* = EMRFILLPATH
-  PEMRSTROKEANDFILLPATH* = ptr EMRFILLPATH
-  EMRSTROKEPATH* = EMRFILLPATH
-  TEMRSTROKEPATH* = EMRFILLPATH
-  PEMRSTROKEPATH* = ptr EMRFILLPATH
-  EMRFILLRGN* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cbRgnData*: DWORD
-    ihBrush*: DWORD
-    RgnData*: array[0..0, int8]
-
-  TEMRFILLRGN* = EMRFILLRGN
-  PEMRFILLRGN* = ptr EMRFILLRGN
-  EMRFORMAT* {.final, pure.} = object
-    dSignature*: DWORD
-    nVersion*: DWORD
-    cbData*: DWORD
-    offData*: DWORD
-
-  TEMRFORMAT* = EMRFORMAT
-  PEMRFORMAT* = ptr EMRFORMAT
-  SIZE* {.final, pure.} = object
-    cx*: LONG
-    cy*: LONG
-
-  LPSIZE* = ptr SIZE
-  TSIZE* = SIZE
-  PSIZE* = ptr SIZE
-  SIZEL* = SIZE
-  TSIZEL* = SIZE
-  PSIZEL* = ptr SIZE
-  LPSIZEL* = ptr SIZE
-  EMRFRAMERGN* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cbRgnData*: DWORD
-    ihBrush*: DWORD
-    szlStroke*: SIZEL
-    RgnData*: array[0..0, int8]
-
-  TEMRFRAMERGN* = EMRFRAMERGN
-  PEMRFRAMERGN* = ptr EMRFRAMERGN
-  EMRGDICOMMENT* {.final, pure.} = object
-    emr*: EMR
-    cbData*: DWORD
-    Data*: array[0..0, int8]
-
-  TEMRGDICOMMENT* = EMRGDICOMMENT
-  PEMRGDICOMMENT* = ptr EMRGDICOMMENT
-  EMRINVERTRGN* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cbRgnData*: DWORD
-    RgnData*: array[0..0, int8]
-
-  TEMRINVERTRGN* = EMRINVERTRGN
-  PEMRINVERTRGN* = ptr EMRINVERTRGN
-  EMRPAINTRGN* = EMRINVERTRGN
-  TEMRPAINTRGN* = EMRINVERTRGN
-  PEMRPAINTRGN* = ptr EMRINVERTRGN
-  EMRLINETO* {.final, pure.} = object
-    emr*: EMR
-    ptl*: POINTL
-
-  TEMRLINETO* = EMRLINETO
-  PEMRLINETO* = ptr EMRLINETO
-  EMRMOVETOEX* = EMRLINETO
-  TEMRMOVETOEX* = EMRLINETO
-  PEMRMOVETOEX* = ptr EMRLINETO
-  EMRMASKBLT* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    xDest*: LONG
-    yDest*: LONG
-    cxDest*: LONG
-    cyDest*: LONG
-    dwRop*: DWORD
-    xSrc*: LONG
-    ySrc*: LONG
-    xformSrc*: XFORM
-    crBkColorSrc*: COLORREF
-    iUsageSrc*: DWORD
-    offBmiSrc*: DWORD
-    cbBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-    xMask*: LONG
-    yMask*: LONG
-    iUsageMask*: DWORD
-    offBmiMask*: DWORD
-    cbBmiMask*: DWORD
-    offBitsMask*: DWORD
-    cbBitsMask*: DWORD
-
-  TEMRMASKBLT* = EMRMASKBLT
-  PEMRMASKBLT* = ptr EMRMASKBLT
-  EMRMODIFYWORLDTRANSFORM* {.final, pure.} = object
-    emr*: EMR
-    xform*: XFORM
-    iMode*: DWORD
-
-  TEMRMODIFYWORLDTRANSFORM* = EMRMODIFYWORLDTRANSFORM
-  PEMRMODIFYWORLDTRANSFORM* = EMRMODIFYWORLDTRANSFORM
-  EMROFFSETCLIPRGN* {.final, pure.} = object
-    emr*: EMR
-    ptlOffset*: POINTL
-
-  TEMROFFSETCLIPRGN* = EMROFFSETCLIPRGN
-  PEMROFFSETCLIPRGN* = ptr EMROFFSETCLIPRGN
-  EMRPLGBLT* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    aptlDest*: array[0..2, POINTL]
-    xSrc*: LONG
-    ySrc*: LONG
-    cxSrc*: LONG
-    cySrc*: LONG
-    xformSrc*: XFORM
-    crBkColorSrc*: COLORREF
-    iUsageSrc*: DWORD
-    offBmiSrc*: DWORD
-    cbBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-    xMask*: LONG
-    yMask*: LONG
-    iUsageMask*: DWORD
-    offBmiMask*: DWORD
-    cbBmiMask*: DWORD
-    offBitsMask*: DWORD
-    cbBitsMask*: DWORD
-
-  TEMRPLGBLT* = EMRPLGBLT
-  PEMRPLGBLT* = ptr EMRPLGBLT
-  EMRPOLYDRAW* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cptl*: DWORD
-    aptl*: array[0..0, POINTL]
-    abTypes*: array[0..0, int8]
-
-  TEMRPOLYDRAW* = EMRPOLYDRAW
-  PEMRPOLYDRAW* = ptr EMRPOLYDRAW
-  EMRPOLYDRAW16* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cpts*: DWORD
-    apts*: array[0..0, POINTS]
-    abTypes*: array[0..0, int8]
-
-  TEMRPOLYDRAW16* = EMRPOLYDRAW16
-  PEMRPOLYDRAW16* = ptr EMRPOLYDRAW16
-  EMRPOLYLINE* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cptl*: DWORD
-    aptl*: array[0..0, POINTL]
-
-  TEMRPOLYLINE* = EMRPOLYLINE
-  PEMRPOLYLINE* = ptr EMRPOLYLINE
-  EMRPOLYBEZIER* = EMRPOLYLINE
-  TEMRPOLYBEZIER* = EMRPOLYLINE
-  PEMRPOLYBEZIER* = ptr EMRPOLYLINE
-  EMRPOLYGON* = EMRPOLYLINE
-  TEMRPOLYGON* = EMRPOLYLINE
-  PEMRPOLYGON* = ptr EMRPOLYLINE
-  EMRPOLYBEZIERTO* = EMRPOLYLINE
-  TEMRPOLYBEZIERTO* = EMRPOLYLINE
-  PEMRPOLYBEZIERTO* = ptr EMRPOLYLINE
-  EMRPOLYLINETO* = EMRPOLYLINE
-  TEMRPOLYLINETO* = EMRPOLYLINE
-  PEMRPOLYLINETO* = ptr EMRPOLYLINE
-  EMRPOLYLINE16* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    cpts*: DWORD
-    apts*: array[0..0, POINTL]
-
-  TEMRPOLYLINE16* = EMRPOLYLINE16
-  PEMRPOLYLINE16* = ptr EMRPOLYLINE16
-  EMRPOLYBEZIER16* = EMRPOLYLINE16
-  TEMRPOLYBEZIER16* = EMRPOLYLINE16
-  PEMRPOLYBEZIER16* = ptr EMRPOLYLINE16
-  EMRPOLYGON16* = EMRPOLYLINE16
-  TEMRPOLYGON16* = EMRPOLYLINE16
-  PEMRPOLYGON16* = ptr EMRPOLYLINE16
-  EMRPOLYBEZIERTO16* = EMRPOLYLINE16
-  TEMRPOLYBEZIERTO16* = EMRPOLYLINE16
-  PEMRPOLYBEZIERTO16* = ptr EMRPOLYLINE16
-  EMRPOLYLINETO16* = EMRPOLYLINE16
-  TEMRPOLYLINETO16* = EMRPOLYLINE16
-  PEMRPOLYLINETO16* = ptr EMRPOLYLINE16
-  EMRPOLYPOLYLINE* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    nPolys*: DWORD
-    cptl*: DWORD
-    aPolyCounts*: array[0..0, DWORD]
-    aptl*: array[0..0, POINTL]
-
-  TEMRPOLYPOLYLINE* = EMRPOLYPOLYLINE
-  PEMRPOLYPOLYLINE* = ptr EMRPOLYPOLYLINE
-  EMRPOLYPOLYGON* = EMRPOLYPOLYLINE
-  TEMRPOLYPOLYGON* = EMRPOLYPOLYLINE
-  PEMRPOLYPOLYGON* = ptr EMRPOLYPOLYLINE
-  EMRPOLYPOLYLINE16* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    nPolys*: DWORD
-    cpts*: DWORD
-    aPolyCounts*: array[0..0, DWORD]
-    apts*: array[0..0, POINTS]
-
-  TEMRPOLYPOLYLINE16* = EMRPOLYPOLYLINE16
-  PEMRPOLYPOLYLINE16* = ptr EMRPOLYPOLYLINE16
-  EMRPOLYPOLYGON16* = EMRPOLYPOLYLINE16
-  TEMRPOLYPOLYGON16* = EMRPOLYPOLYLINE16
-  PEMRPOLYPOLYGON16* = ptr EMRPOLYPOLYLINE16
-  EMRPOLYTEXTOUTA* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    iGraphicsMode*: DWORD
-    exScale*: float32
-    eyScale*: float32
-    cStrings*: LONG
-    aemrtext*: array[0..0, EMRTEXT]
-
-  TEMRPOLYTEXTOUTA* = EMRPOLYTEXTOUTA
-  PEMRPOLYTEXTOUTA* = ptr EMRPOLYTEXTOUTA
-  EMRPOLYTEXTOUTW* = EMRPOLYTEXTOUTA
-  TEMRPOLYTEXTOUTW* = EMRPOLYTEXTOUTA
-  PEMRPOLYTEXTOUTW* = ptr EMRPOLYTEXTOUTA
-  EMRRESIZEPALETTE* {.final, pure.} = object
-    emr*: EMR
-    ihPal*: DWORD
-    cEntries*: DWORD
-
-  TEMRRESIZEPALETTE* = EMRRESIZEPALETTE
-  PEMRRESIZEPALETTE* = ptr EMRRESIZEPALETTE
-  EMRRESTOREDC* {.final, pure.} = object
-    emr*: EMR
-    iRelative*: LONG
-
-  TEMRRESTOREDC* = EMRRESTOREDC
-  PEMRRESTOREDC* = ptr EMRRESTOREDC
-  EMRROUNDRECT* {.final, pure.} = object
-    emr*: EMR
-    rclBox*: RECTL
-    szlCorner*: SIZEL
-
-  TEMRROUNDRECT* = EMRROUNDRECT
-  PEMRROUNDRECT* = ptr EMRROUNDRECT
-  EMRSCALEVIEWPORTEXTEX* {.final, pure.} = object
-    emr*: EMR
-    xNum*: LONG
-    xDenom*: LONG
-    yNum*: LONG
-    yDenom*: LONG
-
-  TEMRSCALEVIEWPORTEXTEX* = EMRSCALEVIEWPORTEXTEX
-  PEMRSCALEVIEWPORTEXTEX* = ptr EMRSCALEVIEWPORTEXTEX
-  EMRSCALEWINDOWEXTEX* = EMRSCALEVIEWPORTEXTEX
-  TEMRSCALEWINDOWEXTEX* = EMRSCALEVIEWPORTEXTEX
-  PEMRSCALEWINDOWEXTEX* = ptr EMRSCALEVIEWPORTEXTEX
-  EMRSELECTCOLORSPACE* {.final, pure.} = object
-    emr*: EMR
-    ihCS*: DWORD
-
-  TEMRSELECTCOLORSPACE* = EMRSELECTCOLORSPACE
-  PEMRSELECTCOLORSPACE* = ptr EMRSELECTCOLORSPACE
-  EMRDELETECOLORSPACE* = EMRSELECTCOLORSPACE
-  TEMRDELETECOLORSPACE* = EMRSELECTCOLORSPACE
-  PEMRDELETECOLORSPACE* = ptr EMRSELECTCOLORSPACE
-  EMRSELECTOBJECT* {.final, pure.} = object
-    emr*: EMR
-    ihObject*: DWORD
-
-  TEMRSELECTOBJECT* = EMRSELECTOBJECT
-  PEMRSELECTOBJECT* = ptr EMRSELECTOBJECT
-  EMRDELETEOBJECT* = EMRSELECTOBJECT
-  TEMRDELETEOBJECT* = EMRSELECTOBJECT
-  PEMRDELETEOBJECT* = ptr EMRSELECTOBJECT
-  EMRSELECTPALETTE* {.final, pure.} = object
-    emr*: EMR
-    ihPal*: DWORD
-
-  TEMRSELECTPALETTE* = EMRSELECTPALETTE
-  PEMRSELECTPALETTE* = ptr EMRSELECTPALETTE
-  EMRSETARCDIRECTION* {.final, pure.} = object
-    emr*: EMR
-    iArcDirection*: DWORD
-
-  TEMRSETARCDIRECTION* = EMRSETARCDIRECTION
-  PEMRSETARCDIRECTION* = ptr EMRSETARCDIRECTION
-  EMRSETBKCOLOR* {.final, pure.} = object
-    emr*: EMR
-    crColor*: COLORREF
-
-  TEMRSETBKCOLOR* = EMRSETBKCOLOR
-  PEMRSETBKCOLOR* = ptr EMRSETBKCOLOR
-  EMRSETTEXTCOLOR* = EMRSETBKCOLOR
-  TEMRSETTEXTCOLOR* = EMRSETBKCOLOR
-  PEMRSETTEXTCOLOR* = ptr EMRSETBKCOLOR
-  EMRSETCOLORADJUSTMENT* {.final, pure.} = object
-    emr*: EMR
-    ColorAdjustment*: COLORADJUSTMENT
-
-  TEMRSETCOLORADJUSTMENT* = EMRSETCOLORADJUSTMENT
-  PEMRSETCOLORADJUSTMENT* = ptr EMRSETCOLORADJUSTMENT
-  EMRSETDIBITSTODEVICE* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    xDest*: LONG
-    yDest*: LONG
-    xSrc*: LONG
-    ySrc*: LONG
-    cxSrc*: LONG
-    cySrc*: LONG
-    offBmiSrc*: DWORD
-    cbBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-    iUsageSrc*: DWORD
-    iStartScan*: DWORD
-    cScans*: DWORD
-
-  TEMRSETDIBITSTODEVICE* = EMRSETDIBITSTODEVICE
-  PEMRSETDIBITSTODEVICE* = ptr EMRSETDIBITSTODEVICE
-  EMRSETMAPPERFLAGS* {.final, pure.} = object
-    emr*: EMR
-    dwFlags*: DWORD
-
-  TEMRSETMAPPERFLAGS* = EMRSETMAPPERFLAGS
-  PEMRSETMAPPERFLAGS* = ptr EMRSETMAPPERFLAGS
-  EMRSETMITERLIMIT* {.final, pure.} = object
-    emr*: EMR
-    eMiterLimit*: float32
-
-  TEMRSETMITERLIMIT* = EMRSETMITERLIMIT
-  PEMRSETMITERLIMIT* = ptr EMRSETMITERLIMIT
-  EMRSETPALETTEENTRIES* {.final, pure.} = object
-    emr*: EMR
-    ihPal*: DWORD
-    iStart*: DWORD
-    cEntries*: DWORD
-    aPalEntries*: array[0..0, PALETTEENTRY]
-
-  TEMRSETPALETTEENTRIES* = EMRSETPALETTEENTRIES
-  PEMRSETPALETTEENTRIES* = ptr EMRSETPALETTEENTRIES
-  EMRSETPIXELV* {.final, pure.} = object
-    emr*: EMR
-    ptlPixel*: POINTL
-    crColor*: COLORREF
-
-  TEMRSETPIXELV* = EMRSETPIXELV
-  PEMRSETPIXELV* = ptr EMRSETPIXELV
-  EMRSETVIEWPORTEXTEX* {.final, pure.} = object
-    emr*: EMR
-    szlExtent*: SIZEL
-
-  TEMRSETVIEWPORTEXTEX* = EMRSETVIEWPORTEXTEX
-  PEMRSETVIEWPORTEXTEX* = ptr EMRSETVIEWPORTEXTEX
-  EMRSETWINDOWEXTEX* = EMRSETVIEWPORTEXTEX
-  TEMRSETWINDOWEXTEX* = EMRSETVIEWPORTEXTEX
-  PEMRSETWINDOWEXTEX* = ptr EMRSETVIEWPORTEXTEX
-  EMRSETVIEWPORTORGEX* {.final, pure.} = object
-    emr*: EMR
-    ptlOrigin*: POINTL
-
-  TEMRSETVIEWPORTORGEX* = EMRSETVIEWPORTORGEX
-  PEMRSETVIEWPORTORGEX* = ptr EMRSETVIEWPORTORGEX
-  EMRSETWINDOWORGEX* = EMRSETVIEWPORTORGEX
-  TEMRSETWINDOWORGEX* = EMRSETVIEWPORTORGEX
-  PEMRSETWINDOWORGEX* = ptr EMRSETVIEWPORTORGEX
-  EMRSETBRUSHORGEX* = EMRSETVIEWPORTORGEX
-  TEMRSETBRUSHORGEX* = EMRSETVIEWPORTORGEX
-  PEMRSETBRUSHORGEX* = ptr EMRSETVIEWPORTORGEX
-  EMRSETWORLDTRANSFORM* {.final, pure.} = object
-    emr*: EMR
-    xform*: XFORM
-
-  TEMRSETWORLDTRANSFORM* = EMRSETWORLDTRANSFORM
-  PEMRSETWORLDTRANSFORM* = ptr EMRSETWORLDTRANSFORM
-  EMRSTRETCHBLT* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    xDest*: LONG
-    yDest*: LONG
-    cxDest*: LONG
-    cyDest*: LONG
-    dwRop*: DWORD
-    xSrc*: LONG
-    ySrc*: LONG
-    xformSrc*: XFORM
-    crBkColorSrc*: COLORREF
-    iUsageSrc*: DWORD
-    offBmiSrc*: DWORD
-    cbBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-    cxSrc*: LONG
-    cySrc*: LONG
-
-  TEMRSTRETCHBLT* = EMRSTRETCHBLT
-  PEMRSTRETCHBLT* = ptr EMRSTRETCHBLT
-  EMRSTRETCHDIBITS* {.final, pure.} = object
-    emr*: EMR
-    rclBounds*: RECTL
-    xDest*: LONG
-    yDest*: LONG
-    xSrc*: LONG
-    ySrc*: LONG
-    cxSrc*: LONG
-    cySrc*: LONG
-    offBmiSrc*: DWORD
-    cbBmiSrc*: DWORD
-    offBitsSrc*: DWORD
-    cbBitsSrc*: DWORD
-    iUsageSrc*: DWORD
-    dwRop*: DWORD
-    cxDest*: LONG
-    cyDest*: LONG
-
-  TEMRSTRETCHDIBITS* = EMRSTRETCHDIBITS
-  PEMRSTRETCHDIBITS* = ptr EMRSTRETCHDIBITS
-  EMRABORTPATH* {.final, pure.} = object
-    emr*: EMR
-
-  TEMRABORTPATH* = EMRABORTPATH
-  PEMRABORTPATH* = ptr EMRABORTPATH
-  TABORTPATH* = EMRABORTPATH
-  EMRBEGINPATH* = EMRABORTPATH
-  TEMRBEGINPATH* = EMRABORTPATH
-  PEMRBEGINPATH* = ptr EMRABORTPATH
-  EMRENDPATH* = EMRABORTPATH
-  TEMRENDPATH* = EMRABORTPATH
-  PEMRENDPATH* = ptr EMRABORTPATH
-  EMRCLOSEFIGURE* = EMRABORTPATH
-  TEMRCLOSEFIGURE* = EMRABORTPATH
-  PEMRCLOSEFIGURE* = ptr EMRABORTPATH
-  EMRFLATTENPATH* = EMRABORTPATH
-  TEMRFLATTENPATH* = EMRABORTPATH
-  PEMRFLATTENPATH* = ptr EMRABORTPATH
-  EMRWIDENPATH* = EMRABORTPATH
-  TEMRWIDENPATH* = EMRABORTPATH
-  PEMRWIDENPATH* = ptr EMRABORTPATH
-  EMRSETMETARGN* = EMRABORTPATH
-  TEMRSETMETARGN* = EMRABORTPATH
-  PEMRSETMETARGN* = ptr EMRABORTPATH
-  EMRSAVEDC* = EMRABORTPATH
-  TEMRSAVEDC* = EMRABORTPATH
-  PEMRSAVEDC* = ptr EMRABORTPATH
-  EMRREALIZEPALETTE* = EMRABORTPATH
-  TEMRREALIZEPALETTE* = EMRABORTPATH
-  PEMRREALIZEPALETTE* = ptr EMRABORTPATH
-  EMRSELECTCLIPPATH* {.final, pure.} = object
-    emr*: EMR
-    iMode*: DWORD
-
-  TEMRSELECTCLIPPATH* = EMRSELECTCLIPPATH
-  PEMRSELECTCLIPPATH* = ptr EMRSELECTCLIPPATH
-  EMRSETBKMODE* = EMRSELECTCLIPPATH
-  TEMRSETBKMODE* = EMRSELECTCLIPPATH
-  PEMRSETBKMODE* = ptr EMRSELECTCLIPPATH
-  EMRSETMAPMODE* = EMRSELECTCLIPPATH
-  TEMRSETMAPMODE* = EMRSELECTCLIPPATH
-  PEMRSETMAPMODE* = ptr EMRSELECTCLIPPATH
-  EMRSETPOLYFILLMODE* = EMRSELECTCLIPPATH
-  TEMRSETPOLYFILLMODE* = EMRSELECTCLIPPATH
-  PEMRSETPOLYFILLMODE* = ptr EMRSELECTCLIPPATH
-  EMRSETROP2* = EMRSELECTCLIPPATH
-  TEMRSETROP2* = EMRSELECTCLIPPATH
-  PEMRSETROP2* = ptr EMRSELECTCLIPPATH
-  EMRSETSTRETCHBLTMODE* = EMRSELECTCLIPPATH
-  TEMRSETSTRETCHBLTMODE* = EMRSELECTCLIPPATH
-  PEMRSETSTRETCHBLTMODE* = ptr EMRSELECTCLIPPATH
-  EMRSETTEXTALIGN* = EMRSELECTCLIPPATH
-  TEMRSETTEXTALIGN* = EMRSELECTCLIPPATH
-  PEMRSETTEXTALIGN* = ptr EMRSELECTCLIPPATH
-  EMRENABLEICM* = EMRSELECTCLIPPATH
-  TEMRENABLEICM* = EMRSELECTCLIPPATH
-  PEMRENABLEICM* = ptr EMRSELECTCLIPPATH
-  NMHDR* {.final, pure.} = object
-    hwndFrom*: HWND
-    idFrom*: UINT
-    code*: UINT
-
-  TNMHDR* = NMHDR
-  PNMHDR* = ptr NMHDR
-  TENCORRECTTEXT* {.final, pure.} = object
-    nmhdr*: NMHDR
-    chrg*: CHARRANGE
-    seltyp*: int16
-
-  Pencorrecttext* = ptr TENCORRECTTEXT
-  TENDROPFILES* {.final, pure.} = object
-    nmhdr*: NMHDR
-    hDrop*: HANDLE
-    cp*: LONG
-    fProtected*: WINBOOL
-
-  Pendropfiles* = ptr TENDROPFILES
-  TENSAVECLIPBOARD* {.final, pure.} = object
-    nmhdr*: NMHDR
-    cObjectCount*: LONG
-    cch*: LONG
-
-  PENSAVECLIPBOARD* = ptr TENSAVECLIPBOARD
-  TENOLEOPFAILED* {.final, pure.} = object
-    nmhdr*: NMHDR
-    iob*: LONG
-    lOper*: LONG
-    hr*: HRESULT
-
-  PENOLEOPFAILED* = ptr TENOLEOPFAILED
-  TENHMETAHEADER* {.final, pure.} = object
-    iType*: DWORD
-    nSize*: DWORD
-    rclBounds*: RECTL
-    rclFrame*: RECTL
-    dSignature*: DWORD
-    nVersion*: DWORD
-    nBytes*: DWORD
-    nRecords*: DWORD
-    nHandles*: int16
-    sReserved*: int16
-    nDescription*: DWORD
-    offDescription*: DWORD
-    nPalEntries*: DWORD
-    szlDevice*: SIZEL
-    szlMillimeters*: SIZEL
-
-  LPENHMETAHEADER* = ptr TENHMETAHEADER
-  PENHMETAHEADER* = ptr TENHMETAHEADER
-  TENHMETARECORD* {.final, pure.} = object
-    iType*: DWORD
-    nSize*: DWORD
-    dParm*: array[0..0, DWORD]
-
-  LPENHMETARECORD* = ptr TENHMETARECORD
-  PENHMETARECORD* = ptr TENHMETARECORD
-  TENPROTECTED* {.final, pure.} = object
-    nmhdr*: NMHDR
-    msg*: UINT
-    wParam*: WPARAM
-    lParam*: LPARAM
-    chrg*: CHARRANGE
-
-  Penprotected* = ptr TENPROTECTED
-  SERVICE_STATUS* {.final, pure.} = object
-    dwServiceType*: DWORD
-    dwCurrentState*: DWORD
-    dwControlsAccepted*: DWORD
-    dwWin32ExitCode*: DWORD
-    dwServiceSpecificExitCode*: DWORD
-    dwCheckPoint*: DWORD
-    dwWaitHint*: DWORD
-
-  LPSERVICE_STATUS* = ptr SERVICE_STATUS
-  TSERVICESTATUS* = SERVICE_STATUS
-  PSERVICESTATUS* = ptr SERVICE_STATUS
-  ENUM_SERVICE_STATUS* {.final, pure.} = object
-    lpServiceName*: LPTSTR
-    lpDisplayName*: LPTSTR
-    ServiceStatus*: SERVICE_STATUS
-
-  LPENUM_SERVICE_STATUS* = ptr ENUM_SERVICE_STATUS
-  TENUMSERVICESTATUS* = ENUM_SERVICE_STATUS
-  PENUMSERVICESTATUS* = ptr ENUM_SERVICE_STATUS
-  ENUMLOGFONT* {.final, pure.} = object
-    elfLogFont*: LOGFONT
-    elfFullName*: array[0..(LF_FULLFACESIZE) - 1, BCHAR]
-    elfStyle*: array[0..(LF_FACESIZE) - 1, BCHAR]
-
-  TENUMLOGFONT* = ENUMLOGFONT
-  PENUMLOGFONT* = ptr ENUMLOGFONT
-  ENUMLOGFONTEX* {.final, pure.} = object
-    elfLogFont*: LOGFONT
-    elfFullName*: array[0..(LF_FULLFACESIZE) - 1, BCHAR]
-    elfStyle*: array[0..(LF_FACESIZE) - 1, BCHAR]
-    elfScript*: array[0..(LF_FACESIZE) - 1, BCHAR]
-
-  TENUMLOGFONTEX* = ENUMLOGFONTEX
-  PENUMLOGFONTEX* = ptr ENUMLOGFONTEX #
-                                      #    Then follow:
-                                      #
-                                      #    TCHAR SourceName[]
-                                      #    TCHAR Computername[]
-                                      #    SID   UserSid
-                                      #    TCHAR Strings[]
-                                      #    BYTE  Data[]
-                                      #    CHAR  Pad[]
-                                      #    DWORD Length;
-                                      #
-  EVENTLOGRECORD* {.final, pure.} = object
-    len*: DWORD
-    Reserved*: DWORD
-    RecordNumber*: DWORD
-    TimeGenerated*: DWORD
-    TimeWritten*: DWORD
-    EventID*: DWORD
-    EventType*: int16
-    NumStrings*: int16
-    EventCategory*: int16
-    ReservedFlags*: int16
-    ClosingRecordNumber*: DWORD
-    StringOffset*: DWORD
-    UserSidLength*: DWORD
-    UserSidOffset*: DWORD
-    DataLength*: DWORD
-    DataOffset*: DWORD
-
-  TEVENTLOGRECORD* = EVENTLOGRECORD
-  PEVENTLOGRECORD* = ptr EVENTLOGRECORD
-  EVENTMSG* {.final, pure.} = object
-    message*: UINT
-    paramL*: UINT
-    paramH*: UINT
-    time*: DWORD
-    hwnd*: HWND
-
-  TEVENTMSG* = EVENTMSG
-  PEVENTMSG* = ptr EVENTMSG
-  EXCEPTION_POINTERS* {.final, pure.} = object
-    ExceptionRecord*: PEXCEPTION_RECORD
-    ContextRecord*: PCONTEXT
-
-  LPEXCEPTION_POINTERS* = ptr EXCEPTION_POINTERS
-  PEXCEPTION_POINTERS* = ptr EXCEPTION_POINTERS
-  TEXCEPTIONPOINTERS* = EXCEPTION_POINTERS
-  EXT_BUTTON* {.final, pure.} = object
-    idCommand*: int16
-    idsHelp*: int16
-    fsStyle*: int16
-
-  LPEXT_BUTTON* = ptr EXT_BUTTON
-  TEXTBUTTON* = EXT_BUTTON
-  PEXTBUTTON* = ptr EXT_BUTTON
-  FILTERKEYS* {.final, pure.} = object
-    cbSize*: UINT
-    dwFlags*: DWORD
-    iWaitMSec*: DWORD
-    iDelayMSec*: DWORD
-    iRepeatMSec*: DWORD
-    iBounceMSec*: DWORD
-
-  TFILTERKEYS* = FILTERKEYS
-  PFILTERKEYS* = ptr FILTERKEYS
-  FIND_NAME_BUFFER* {.final, pure.} = object
-    len*: UCHAR
-    access_control*: UCHAR
-    frame_control*: UCHAR
-    destination_addr*: array[0..5, UCHAR]
-    source_addr*: array[0..5, UCHAR]
-    routing_info*: array[0..17, UCHAR]
-
-  TFINDNAMEBUFFER* = FIND_NAME_BUFFER
-  PFINDNAMEBUFFER* = ptr FIND_NAME_BUFFER
-  FIND_NAME_HEADER* {.final, pure.} = object
-    node_count*: int16
-    reserved*: UCHAR
-    unique_group*: UCHAR
-
-  TFINDNAMEHEADER* = FIND_NAME_HEADER
-  PFINDNAMEHEADER* = ptr FIND_NAME_HEADER
-  FINDREPLACE* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hInstance*: HINST
-    Flags*: DWORD
-    lpstrFindWhat*: LPTSTR
-    lpstrReplaceWith*: LPTSTR
-    wFindWhatLen*: int16
-    wReplaceWithLen*: int16
-    lCustData*: LPARAM
-    lpfnHook*: LPFRHOOKPROC
-    lpTemplateName*: LPCTSTR
-
-  LPFINDREPLACE* = ptr FINDREPLACE
-  TFINDREPLACE* = FINDREPLACE
-  PFINDREPLACE* = ptr FINDREPLACE #FINDTEXT = record conflicts with FindText function
-  TFINDTEXT* {.final, pure.} = object
-    chrg*: CHARRANGE
-    lpstrText*: LPSTR
-
-  Pfindtext* = ptr TFINDTEXT
-  FINDTEXTEX* {.final, pure.} = object
-    chrg*: CHARRANGE
-    lpstrText*: LPSTR
-    chrgText*: CHARRANGE
-
-  Tfindtextex* = FINDTEXTEX
-  Pfindtextex* = ptr FINDTEXTEX
-  FMS_GETDRIVEINFO* {.final, pure.} = object
-    dwTotalSpace*: DWORD
-    dwFreeSpace*: DWORD
-    szPath*: array[0..259, TCHAR]
-    szVolume*: array[0..13, TCHAR]
-    szShare*: array[0..127, TCHAR]
-
-  TFMSGETDRIVEINFO* = FMS_GETDRIVEINFO
-  PFMSGETDRIVEINFO* = ptr FMS_GETDRIVEINFO
-  FMS_GETFILESEL* {.final, pure.} = object
-    ftTime*: FILETIME
-    dwSize*: DWORD
-    bAttr*: int8
-    szName*: array[0..259, TCHAR]
-
-  TFMSGETFILESEL* = FMS_GETFILESEL
-  PFMSGETFILESEL* = ptr FMS_GETFILESEL
-  FMS_LOAD* {.final, pure.} = object
-    dwSize*: DWORD
-    szMenuName*: array[0..(MENU_TEXT_LEN) - 1, TCHAR]
-    hMenu*: HMENU
-    wMenuDelta*: UINT
-
-  TFMSLOAD* = FMS_LOAD
-  PFMSLOAD* = ptr FMS_LOAD
-  FMS_TOOLBARLOAD* {.final, pure.} = object
-    dwSize*: DWORD
-    lpButtons*: LPEXT_BUTTON
-    cButtons*: int16
-    cBitmaps*: int16
-    idBitmap*: int16
-    hBitmap*: HBITMAP
-
-  TFMSTOOLBARLOAD* = FMS_TOOLBARLOAD
-  PFMSTOOLBARLOAD* = ptr FMS_TOOLBARLOAD
-  FOCUS_EVENT_RECORD* {.final, pure.} = object
-    bSetFocus*: WINBOOL
-
-  TFOCUSEVENTRECORD* = FOCUS_EVENT_RECORD
-  PFOCUSEVENTRECORD* = ptr FOCUS_EVENT_RECORD
-  FORM_INFO_1* {.final, pure.} = object
-    Flags*: DWORD
-    pName*: LPTSTR
-    Size*: SIZEL
-    ImageableArea*: RECTL
-
-  TFORMINFO1* = FORM_INFO_1
-  PFORMINFO1* = ptr FORM_INFO_1
-  FORMAT_PARAMETERS* {.final, pure.} = object
-    MediaType*: MEDIA_TYPE
-    StartCylinderNumber*: DWORD
-    EndCylinderNumber*: DWORD
-    StartHeadNumber*: DWORD
-    EndHeadNumber*: DWORD
-
-  TFORMATPARAMETERS* = FORMAT_PARAMETERS
-  PFORMATPARAMETERS* = ptr FORMAT_PARAMETERS
-  FORMATRANGE* {.final, pure.} = object
-    hdc*: HDC
-    hdcTarget*: HDC
-    rc*: RECT
-    rcPage*: RECT
-    chrg*: CHARRANGE
-
-  Tformatrange* = FORMATRANGE
-  Pformatrange* = ptr FORMATRANGE
-  GCP_RESULTS* {.final, pure.} = object
-    lStructSize*: DWORD
-    lpOutString*: LPTSTR
-    lpOrder*: ptr UINT
-    lpDx*: ptr WINT
-    lpCaretPos*: ptr WINT
-    lpClass*: LPTSTR
-    lpGlyphs*: ptr UINT
-    nGlyphs*: UINT
-    nMaxFit*: UINT
-
-  LPGCP_RESULTS* = ptr GCP_RESULTS
-  TGCPRESULTS* = GCP_RESULTS
-  PGCPRESULTS* = ptr GCP_RESULTS
-  GENERIC_MAPPING* {.final, pure.} = object
-    GenericRead*: ACCESS_MASK
-    GenericWrite*: ACCESS_MASK
-    GenericExecute*: ACCESS_MASK
-    GenericAll*: ACCESS_MASK
-
-  PGENERIC_MAPPING* = ptr GENERIC_MAPPING
-  TGENERICMAPPING* = GENERIC_MAPPING
-  GLYPHMETRICS* {.final, pure.} = object
-    gmBlackBoxX*: UINT
-    gmBlackBoxY*: UINT
-    gmptGlyphOrigin*: POINT
-    gmCellIncX*: SHORT
-    gmCellIncY*: SHORT
-
-  LPGLYPHMETRICS* = ptr GLYPHMETRICS
-  TGLYPHMETRICS* = GLYPHMETRICS
-  PGLYPHMETRICS* = ptr GLYPHMETRICS
-  HANDLETABLE* {.final, pure.} = object
-    objectHandle*: array[0..0, HGDIOBJ]
-
-  THANDLETABLE* = HANDLETABLE
-  LPHANDLETABLE* = ptr HANDLETABLE
-  HD_HITTESTINFO* {.final, pure.} = object
-    pt*: POINT
-    flags*: UINT
-    iItem*: int32
-
-  THDHITTESTINFO* = HD_HITTESTINFO
-  PHDHITTESTINFO* = ptr HD_HITTESTINFO
-  HD_ITEM* {.final, pure.} = object
-    mask*: UINT
-    cxy*: int32
-    pszText*: LPTSTR
-    hbm*: HBITMAP
-    cchTextMax*: int32
-    fmt*: int32
-    lParam*: LPARAM
-
-  THDITEM* = HD_ITEM
-  PHDITEM* = ptr HD_ITEM
-  WINDOWPOS* {.final, pure.} = object
-    hwnd*: HWND
-    hwndInsertAfter*: HWND
-    x*: int32
-    y*: int32
-    cx*: int32
-    cy*: int32
-    flags*: UINT
-
-  LPWINDOWPOS* = ptr WINDOWPOS
-  TWINDOWPOS* = WINDOWPOS
-  PWINDOWPOS* = ptr WINDOWPOS
-  HD_LAYOUT* {.final, pure.} = object
-    prc*: ptr RECT
-    pwpos*: ptr WINDOWPOS
-
-  THDLAYOUT* = HD_LAYOUT
-  PHDLAYOUT* = ptr HD_LAYOUT
-  HD_NOTIFY* {.final, pure.} = object
-    hdr*: NMHDR
-    iItem*: int32
-    iButton*: int32
-    pitem*: ptr HD_ITEM
-
-  THDNOTIFY* = HD_NOTIFY
-  PHDNOTIFY* = ptr HD_NOTIFY
-  HELPINFO* {.final, pure.} = object
-    cbSize*: UINT
-    iContextType*: int32
-    iCtrlId*: int32
-    hItemHandle*: HANDLE
-    dwContextId*: DWORD
-    MousePos*: POINT
-
-  LPHELPINFO* = ptr HELPINFO
-  THELPINFO* = HELPINFO
-  PHELPINFO* = ptr HELPINFO
-  HELPWININFO* {.final, pure.} = object
-    wStructSize*: int32
-    x*: int32
-    y*: int32
-    dx*: int32
-    dy*: int32
-    wMax*: int32
-    rgchMember*: array[0..1, TCHAR]
-
-  THELPWININFO* = HELPWININFO
-  PHELPWININFO* = ptr HELPWININFO
-  HIGHCONTRAST* {.final, pure.} = object
-    cbSize*: UINT
-    dwFlags*: DWORD
-    lpszDefaultScheme*: LPTSTR
-
-  LPHIGHCONTRAST* = ptr HIGHCONTRAST
-  THIGHCONTRAST* = HIGHCONTRAST
-  PHIGHCONTRAST* = ptr HIGHCONTRAST
-  HSZPAIR* {.final, pure.} = object
-    hszSvc*: HSZ
-    hszTopic*: HSZ
-
-  THSZPAIR* = HSZPAIR
-  PHSZPAIR* = ptr HSZPAIR
-  ICONINFO* {.final, pure.} = object
-    fIcon*: WINBOOL
-    xHotspot*: DWORD
-    yHotspot*: DWORD
-    hbmMask*: HBITMAP
-    hbmColor*: HBITMAP
-
-  TICONINFO* = ICONINFO
-  PICONINFO* = ptr ICONINFO
-  ICONMETRICS* {.final, pure.} = object
-    cbSize*: UINT
-    iHorzSpacing*: int32
-    iVertSpacing*: int32
-    iTitleWrap*: int32
-    lfFont*: LOGFONT
-
-  LPICONMETRICS* = ptr ICONMETRICS
-  TICONMETRICS* = ICONMETRICS
-  PICONMETRICS* = ptr ICONMETRICS
-  IMAGEINFO* {.final, pure.} = object
-    hbmImage*: HBITMAP
-    hbmMask*: HBITMAP
-    Unused1*: int32
-    Unused2*: int32
-    rcImage*: RECT
-
-  TIMAGEINFO* = IMAGEINFO
-  PIMAGEINFO* = ptr IMAGEINFO
-  KEY_EVENT_RECORD* {.final, pure.} = object
-    bKeyDown*: WINBOOL
-    wRepeatCount*: int16
-    wVirtualKeyCode*: int16
-    wVirtualScanCode*: int16
-    UnicodeChar*: WCHAR
-    dwControlKeyState*: DWORD # other union part: AsciiChar: CHAR
-
-  TKEYEVENTRECORD* = KEY_EVENT_RECORD
-  PKEYEVENTRECORD* = ptr KEY_EVENT_RECORD
-  MOUSE_EVENT_RECORD* {.final, pure.} = object
-    dwMousePosition*: COORD
-    dwButtonState*: DWORD
-    dwControlKeyState*: DWORD
-    dwEventFlags*: DWORD
-
-  TMOUSEEVENTRECORD* = MOUSE_EVENT_RECORD
-  PMOUSEEVENTRECORD* = ptr MOUSE_EVENT_RECORD
-  WINDOW_BUFFER_SIZE_RECORD* {.final, pure.} = object
-    dwSize*: COORD
-
-  TWINDOWBUFFERSIZERECORD* = WINDOW_BUFFER_SIZE_RECORD
-  PWINDOWBUFFERSIZERECORD* = ptr WINDOW_BUFFER_SIZE_RECORD
-  MENU_EVENT_RECORD* {.final, pure.} = object
-    dwCommandId*: UINT
-
-  PMENU_EVENT_RECORD* = ptr MENU_EVENT_RECORD
-  TMENUEVENTRECORD* = MENU_EVENT_RECORD
-  INPUT_RECORD* {.final, pure.} = object
-    EventType*: int16
-    Reserved*: int16
-    event*: array[0..5, DWORD] #Event : record case longint of
-                               #                 0 : ( KeyEvent : KEY_EVENT_RECORD );
-                               #                 1 : ( MouseEvent : MOUSE_EVENT_RECORD );
-                               #                 2 : ( WindowBufferSizeEvent : WINDOW_BUFFER_SIZE_RECORD );
-                               #                 3 : ( MenuEvent : MENU_EVENT_RECORD );
-                               #                 4 : ( FocusEvent : FOCUS_EVENT_RECORD );
-                               #       end;
-
-  PINPUT_RECORD* = ptr INPUT_RECORD
-  TINPUTRECORD* = INPUT_RECORD
-  SYSTEMTIME* {.final, pure.} = object
-    wYear*: int16
-    wMonth*: int16
-    wDayOfWeek*: int16
-    wDay*: int16
-    wHour*: int16
-    wMinute*: int16
-    wSecond*: int16
-    wMilliseconds*: int16
-
-  LPSYSTEMTIME* = ptr SYSTEMTIME
-  TSYSTEMTIME* = SYSTEMTIME
-  PSYSTEMTIME* = ptr SYSTEMTIME
-  JOB_INFO_1* {.final, pure.} = object
-    JobId*: DWORD
-    pPrinterName*: LPTSTR
-    pMachineName*: LPTSTR
-    pUserName*: LPTSTR
-    pDocument*: LPTSTR
-    pDatatype*: LPTSTR
-    pStatus*: LPTSTR
-    Status*: DWORD
-    Priority*: DWORD
-    Position*: DWORD
-    TotalPages*: DWORD
-    PagesPrinted*: DWORD
-    Submitted*: SYSTEMTIME
-
-  TJOBINFO1* = JOB_INFO_1
-  PJOBINFO1* = ptr JOB_INFO_1
-  SID_IDENTIFIER_AUTHORITY* {.final, pure.} = object
-    Value*: array[0..5, int8]
-
-  LPSID_IDENTIFIER_AUTHORITY* = ptr SID_IDENTIFIER_AUTHORITY
-  PSID_IDENTIFIER_AUTHORITY* = ptr SID_IDENTIFIER_AUTHORITY
-  TSIDIDENTIFIERAUTHORITY* = SID_IDENTIFIER_AUTHORITY
-  SID* {.final, pure.} = object
-    Revision*: int8
-    SubAuthorityCount*: int8
-    IdentifierAuthority*: SID_IDENTIFIER_AUTHORITY
-    SubAuthority*: array[0..(ANYSIZE_ARRAY) - 1, DWORD]
-
-  TSID* = SID
-  PSID* = ptr SID
-  SECURITY_DESCRIPTOR_CONTROL* = int16
-  PSECURITY_DESCRIPTOR_CONTROL* = ptr SECURITY_DESCRIPTOR_CONTROL
-  TSECURITYDESCRIPTORCONTROL* = SECURITY_DESCRIPTOR_CONTROL
-  SECURITY_DESCRIPTOR* {.final, pure.} = object
-    Revision*: int8
-    Sbz1*: int8
-    Control*: SECURITY_DESCRIPTOR_CONTROL
-    Owner*: PSID
-    Group*: PSID
-    Sacl*: PACL
-    Dacl*: PACL
-
-  PSECURITY_DESCRIPTOR* = ptr SECURITY_DESCRIPTOR
-  TSECURITYDESCRIPTOR* = SECURITY_DESCRIPTOR
-  JOB_INFO_2* {.final, pure.} = object
-    JobId*: DWORD
-    pPrinterName*: LPTSTR
-    pMachineName*: LPTSTR
-    pUserName*: LPTSTR
-    pDocument*: LPTSTR
-    pNotifyName*: LPTSTR
-    pDatatype*: LPTSTR
-    pPrintProcessor*: LPTSTR
-    pParameters*: LPTSTR
-    pDriverName*: LPTSTR
-    pDevMode*: LPDEVMODE
-    pStatus*: LPTSTR
-    pSecurityDescriptor*: PSECURITY_DESCRIPTOR
-    Status*: DWORD
-    Priority*: DWORD
-    Position*: DWORD
-    StartTime*: DWORD
-    UntilTime*: DWORD
-    TotalPages*: DWORD
-    Size*: DWORD
-    Submitted*: SYSTEMTIME
-    Time*: DWORD
-    PagesPrinted*: DWORD
-
-  TJOBINFO2* = JOB_INFO_2
-  PJOBINFO2* = ptr JOB_INFO_2
-  KERNINGPAIR* {.final, pure.} = object
-    wFirst*: int16
-    wSecond*: int16
-    iKernAmount*: int32
-
-  LPKERNINGPAIR* = ptr KERNINGPAIR
-  TKERNINGPAIR* = KERNINGPAIR
-  PKERNINGPAIR* = ptr KERNINGPAIR
-  LANA_ENUM* {.final, pure.} = object
-    len*: UCHAR
-    lana*: array[0..(MAX_LANA) - 1, UCHAR]
-
-  TLANAENUM* = LANA_ENUM
-  PLANAENUM* = ptr LANA_ENUM
-  LDT_ENTRY* {.final, pure.} = object
-    LimitLow*: int16
-    BaseLow*: int16
-    BaseMid*: int8
-    Flags1*: int8
-    Flags2*: int8
-    BaseHi*: int8
-
-  LPLDT_ENTRY* = ptr LDT_ENTRY
-  PLDT_ENTRY* = ptr LDT_ENTRY
-  TLDTENTRY* = LDT_ENTRY
-
-const
-  bm_LDT_ENTRY_BaseMid* = 0x000000FF
-  bp_LDT_ENTRY_BaseMid* = 0
-  bm_LDT_ENTRY_Type* = 0x00001F00
-  bp_LDT_ENTRY_Type* = 8
-  bm_LDT_ENTRY_Dpl* = 0x00006000
-  bp_LDT_ENTRY_Dpl* = 13
-  bm_LDT_ENTRY_Pres* = 0x00008000
-  bp_LDT_ENTRY_Pres* = 15
-  bm_LDT_ENTRY_LimitHi* = 0x000F0000
-  bp_LDT_ENTRY_LimitHi* = 16
-  bm_LDT_ENTRY_Sys* = 0x00100000
-  bp_LDT_ENTRY_Sys* = 20
-  bm_LDT_ENTRY_Reserved_0* = 0x00200000
-  bp_LDT_ENTRY_Reserved_0* = 21
-  bm_LDT_ENTRY_Default_Big* = 0x00400000
-  bp_LDT_ENTRY_Default_Big* = 22
-  bm_LDT_ENTRY_Granularity* = 0x00800000
-  bp_LDT_ENTRY_Granularity* = 23
-  bm_LDT_ENTRY_BaseHi* = 0xFF000000
-  bp_LDT_ENTRY_BaseHi* = 24
-
-type
-  LOCALESIGNATURE* {.final, pure.} = object
-    lsUsb*: array[0..3, DWORD]
-    lsCsbDefault*: array[0..1, DWORD]
-    lsCsbSupported*: array[0..1, DWORD]
-
-  TLOCALESIGNATURE* = LOCALESIGNATURE
-  PLOCALESIGNATURE* = ptr LOCALESIGNATURE
-  LOCALGROUP_MEMBERS_INFO_0* {.final, pure.} = object
-    lgrmi0_sid*: PSID
-
-  TLOCALGROUPMEMBERSINFO0* = LOCALGROUP_MEMBERS_INFO_0
-  PLOCALGROUPMEMBERSINFO0* = ptr LOCALGROUP_MEMBERS_INFO_0
-  LOCALGROUP_MEMBERS_INFO_3* {.final, pure.} = object
-    lgrmi3_domainandname*: LPWSTR
-
-  TLOCALGROUPMEMBERSINFO3* = LOCALGROUP_MEMBERS_INFO_3
-  PLOCALGROUPMEMBERSINFO3* = ptr LOCALGROUP_MEMBERS_INFO_3
-  FXPT16DOT16* = int32
-  LPFXPT16DOT16* = ptr FXPT16DOT16
-  TFXPT16DOT16* = FXPT16DOT16
-  PFXPT16DOT16* = ptr FXPT16DOT16
-  LUID* = TlargeInteger
-  TLUID* = LUID
-  PLUID* = ptr LUID
-  LUID_AND_ATTRIBUTES* {.final, pure.} = object
-    Luid*: LUID
-    Attributes*: DWORD
-
-  TLUIDANDATTRIBUTES* = LUID_AND_ATTRIBUTES
-  PLUIDANDATTRIBUTES* = ptr LUID_AND_ATTRIBUTES
-  LUID_AND_ATTRIBUTES_ARRAY* = array[0..(ANYSIZE_ARRAY) - 1, LUID_AND_ATTRIBUTES]
-  PLUID_AND_ATTRIBUTES_ARRAY* = ptr LUID_AND_ATTRIBUTES_ARRAY
-  TLUIDANDATTRIBUTESARRAY* = LUID_AND_ATTRIBUTES_ARRAY
-  LV_COLUMN* {.final, pure.} = object
-    mask*: UINT
-    fmt*: int32
-    cx*: int32
-    pszText*: LPTSTR
-    cchTextMax*: int32
-    iSubItem*: int32
-
-  TLVCOLUMN* = LV_COLUMN
-  PLVCOLUMN* = ptr LV_COLUMN
-  LV_ITEM* {.final, pure.} = object
-    mask*: UINT
-    iItem*: int32
-    iSubItem*: int32
-    state*: UINT
-    stateMask*: UINT
-    pszText*: LPTSTR
-    cchTextMax*: int32
-    iImage*: int32
-    lParam*: LPARAM
-
-  TLVITEM* = LV_ITEM
-  PLVITEM* = ptr LV_ITEM
-  LV_DISPINFO* {.final, pure.} = object
-    hdr*: NMHDR
-    item*: LV_ITEM
-
-  TLVDISPINFO* = LV_DISPINFO
-  PLVDISPINFO* = ptr LV_DISPINFO
-  LV_FINDINFO* {.final, pure.} = object
-    flags*: UINT
-    psz*: LPCTSTR
-    lParam*: LPARAM
-    pt*: POINT
-    vkDirection*: UINT
-
-  TLVFINDINFO* = LV_FINDINFO
-  PLVFINDINFO* = ptr LV_FINDINFO
-  LV_HITTESTINFO* {.final, pure.} = object
-    pt*: POINT
-    flags*: UINT
-    iItem*: int32
-
-  TLVHITTESTINFO* = LV_HITTESTINFO
-  PLVHITTESTINFO* = ptr LV_HITTESTINFO
-  LV_KEYDOWN* {.final, pure.} = object
-    hdr*: NMHDR
-    wVKey*: int16
-    flags*: UINT
-
-  TLVKEYDOWN* = LV_KEYDOWN
-  PLVKEYDOWN* = ptr LV_KEYDOWN
-  MAT2* {.final, pure.} = object
-    eM11*: FIXED
-    eM12*: FIXED
-    eM21*: FIXED
-    eM22*: FIXED
-
-  TMAT2* = MAT2
-  PMAT2* = ptr MAT2
-  MDICREATESTRUCT* {.final, pure.} = object
-    szClass*: LPCTSTR
-    szTitle*: LPCTSTR
-    hOwner*: HANDLE
-    x*: int32
-    y*: int32
-    cx*: int32
-    cy*: int32
-    style*: DWORD
-    lParam*: LPARAM
-
-  LPMDICREATESTRUCT* = ptr MDICREATESTRUCT
-  TMDICREATESTRUCT* = MDICREATESTRUCT
-  PMDICREATESTRUCT* = ptr MDICREATESTRUCT
-  MEASUREITEMSTRUCT* {.final, pure.} = object
-    CtlType*: UINT
-    CtlID*: UINT
-    itemID*: UINT
-    itemWidth*: UINT
-    itemHeight*: UINT
-    itemData*: ULONG_PTR
-
-  LPMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT
-  TMEASUREITEMSTRUCT* = MEASUREITEMSTRUCT
-  PMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT
-  MEMORY_BASIC_INFORMATION* {.final, pure.} = object
-    BaseAddress*: PVOID
-    AllocationBase*: PVOID
-    AllocationProtect*: DWORD
-    RegionSize*: DWORD
-    State*: DWORD
-    Protect*: DWORD
-    `type`*: DWORD
-
-  PMEMORY_BASIC_INFORMATION* = ptr MEMORY_BASIC_INFORMATION
-  TMEMORYBASICINFORMATION* = MEMORY_BASIC_INFORMATION
-  MEMORYSTATUS* {.final, pure.} = object
-    dwLength*: DWORD
-    dwMemoryLoad*: DWORD
-    dwTotalPhys*: int
-    dwAvailPhys*: int
-    dwTotalPageFile*: int
-    dwAvailPageFile*: int
-    dwTotalVirtual*: int
-    dwAvailVirtual*: int
-
-  TGUID* {.final, pure.} = object
-    D1*: int32
-    D2*: int16
-    D3*: int16
-    D4*: array [0..7, int8]
-
-  LPMEMORYSTATUS* = ptr MEMORYSTATUS
-  TMEMORYSTATUS* = MEMORYSTATUS
-  PMEMORYSTATUS* = ptr MEMORYSTATUS
-  MENUEX_TEMPLATE_HEADER* {.final, pure.} = object
-    wVersion*: int16
-    wOffset*: int16
-    dwHelpId*: DWORD
-
-  TMENUXTEMPLATEHEADER* = MENUEX_TEMPLATE_HEADER
-  PMENUXTEMPLATEHEADER* = ptr MENUEX_TEMPLATE_HEADER
-  MENUEX_TEMPLATE_ITEM* {.final, pure.} = object
-    dwType*: DWORD
-    dwState*: DWORD
-    uId*: UINT
-    bResInfo*: int8
-    szText*: array[0..0, WCHAR]
-    dwHelpId*: DWORD
-
-  TMENUEXTEMPLATEITEM* = MENUEX_TEMPLATE_ITEM
-  PMENUEXTEMPLATEITEM* = ptr MENUEX_TEMPLATE_ITEM
-  MENUINFO* {.final, pure.} = object
-    cbSize*: DWORD
-    fMask*: DWORD
-    dwStyle*: DWORD
-    cyMax*: UINT
-    hbrBack*: HBRUSH
-    dwContextHelpID*: DWORD
-    dwMenuData*: ULONG_PTR
-
-  LPMENUINFO* = ptr MENUINFO
-  LPCMENUINFO* = ptr MENUINFO
-  TMENUINFO* = MENUINFO
-  PMENUINFO* = ptr MENUINFO
-  MENUITEMINFO* {.final, pure.} = object
-    cbSize*: UINT
-    fMask*: UINT
-    fType*: UINT
-    fState*: UINT
-    wID*: UINT
-    hSubMenu*: HMENU
-    hbmpChecked*: HBITMAP
-    hbmpUnchecked*: HBITMAP
-    dwItemData*: ULONG_PTR
-    dwTypeData*: LPTSTR
-    cch*: UINT
-    hbmpItem*: HBITMAP
-
-  LPMENUITEMINFO* = ptr MENUITEMINFO
-  LPCMENUITEMINFO* = ptr MENUITEMINFO
-  TMENUITEMINFO* = MENUITEMINFO
-  TMENUITEMINFOA* = MENUITEMINFO
-  PMENUITEMINFO* = ptr MENUITEMINFO
-  MENUITEMTEMPLATE* {.final, pure.} = object
-    mtOption*: int16
-    mtID*: int16
-    mtString*: array[0..0, WCHAR]
-
-  TMENUITEMTEMPLATE* = MENUITEMTEMPLATE
-  PMENUITEMTEMPLATE* = ptr MENUITEMTEMPLATE
-  MENUITEMTEMPLATEHEADER* {.final, pure.} = object
-    versionNumber*: int16
-    offset*: int16
-
-  TMENUITEMTEMPLATEHEADER* = MENUITEMTEMPLATEHEADER
-  PMENUITEMTEMPLATEHEADER* = ptr MENUITEMTEMPLATEHEADER
-  MENUTEMPLATE* {.final, pure.} = object
-  LPMENUTEMPLATE* = ptr MENUTEMPLATE
-  TMENUTEMPLATE* = MENUTEMPLATE
-  PMENUTEMPLATE* = ptr MENUTEMPLATE
-  METAFILEPICT* {.final, pure.} = object
-    mm*: LONG
-    xExt*: LONG
-    yExt*: LONG
-    hMF*: HMETAFILE
-
-  LPMETAFILEPICT* = ptr METAFILEPICT
-  TMETAFILEPICT* = METAFILEPICT
-  PMETAFILEPICT* = ptr METAFILEPICT
-  METAHEADER* {.final, pure.} = object
-    mtType*: int16
-    mtHeaderSize*: int16
-    mtVersion*: int16
-    mtSize*: DWORD
-    mtNoObjects*: int16
-    mtMaxRecord*: DWORD
-    mtNoParameters*: int16
-
-  TMETAHEADER* = METAHEADER
-  PMETAHEADER* = ptr METAHEADER
-  METARECORD* {.final, pure.} = object
-    rdSize*: DWORD
-    rdFunction*: int16
-    rdParm*: array[0..0, int16]
-
-  LPMETARECORD* = ptr METARECORD
-  TMETARECORD* = METARECORD
-  PMETARECORD* = ptr METARECORD
-  MINIMIZEDMETRICS* {.final, pure.} = object
-    cbSize*: UINT
-    iWidth*: int32
-    iHorzGap*: int32
-    iVertGap*: int32
-    iArrange*: int32
-
-  LPMINIMIZEDMETRICS* = ptr MINIMIZEDMETRICS
-  TMINIMIZEDMETRICS* = MINIMIZEDMETRICS
-  PMINIMIZEDMETRICS* = ptr MINIMIZEDMETRICS
-  MINMAXINFO* {.final, pure.} = object
-    ptReserved*: POINT
-    ptMaxSize*: POINT
-    ptMaxPosition*: POINT
-    ptMinTrackSize*: POINT
-    ptMaxTrackSize*: POINT
-
-  TMINMAXINFO* = MINMAXINFO
-  PMINMAXINFO* = ptr MINMAXINFO
-  MODEMDEVCAPS* {.final, pure.} = object
-    dwActualSize*: DWORD
-    dwRequiredSize*: DWORD
-    dwDevSpecificOffset*: DWORD
-    dwDevSpecificSize*: DWORD
-    dwModemProviderVersion*: DWORD
-    dwModemManufacturerOffset*: DWORD
-    dwModemManufacturerSize*: DWORD
-    dwModemModelOffset*: DWORD
-    dwModemModelSize*: DWORD
-    dwModemVersionOffset*: DWORD
-    dwModemVersionSize*: DWORD
-    dwDialOptions*: DWORD
-    dwCallSetupFailTimer*: DWORD
-    dwInactivityTimeout*: DWORD
-    dwSpeakerVolume*: DWORD
-    dwSpeakerMode*: DWORD
-    dwModemOptions*: DWORD
-    dwMaxDTERate*: DWORD
-    dwMaxDCERate*: DWORD
-    abVariablePortion*: array[0..0, int8]
-
-  LPMODEMDEVCAPS* = ptr MODEMDEVCAPS
-  TMODEMDEVCAPS* = MODEMDEVCAPS
-  PMODEMDEVCAPS* = ptr MODEMDEVCAPS
-  MODEMSETTINGS* {.final, pure.} = object
-    dwActualSize*: DWORD
-    dwRequiredSize*: DWORD
-    dwDevSpecificOffset*: DWORD
-    dwDevSpecificSize*: DWORD
-    dwCallSetupFailTimer*: DWORD
-    dwInactivityTimeout*: DWORD
-    dwSpeakerVolume*: DWORD
-    dwSpeakerMode*: DWORD
-    dwPreferredModemOptions*: DWORD
-    dwNegotiatedModemOptions*: DWORD
-    dwNegotiatedDCERate*: DWORD
-    abVariablePortion*: array[0..0, int8]
-
-  LPMODEMSETTINGS* = ptr MODEMSETTINGS
-  TMODEMSETTINGS* = MODEMSETTINGS
-  PMODEMSETTINGS* = ptr MODEMSETTINGS
-  MONCBSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    dwTime*: DWORD
-    hTask*: HANDLE
-    dwRet*: DWORD
-    wType*: UINT
-    wFmt*: UINT
-    hConv*: HCONV
-    hsz1*: HSZ
-    hsz2*: HSZ
-    hData*: HDDEDATA
-    dwData1*: DWORD
-    dwData2*: DWORD
-    cc*: CONVCONTEXT
-    cbData*: DWORD
-    Data*: array[0..7, DWORD]
-
-  TMONCBSTRUCT* = MONCBSTRUCT
-  PMONCBSTRUCT* = ptr MONCBSTRUCT
-  MONCONVSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    fConnect*: WINBOOL
-    dwTime*: DWORD
-    hTask*: HANDLE
-    hszSvc*: HSZ
-    hszTopic*: HSZ
-    hConvClient*: HCONV
-    hConvServer*: HCONV
-
-  TMONCONVSTRUCT* = MONCONVSTRUCT
-  PMONCONVSTRUCT* = ptr MONCONVSTRUCT
-  MONERRSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    wLastError*: UINT
-    dwTime*: DWORD
-    hTask*: HANDLE
-
-  TMONERRSTRUCT* = MONERRSTRUCT
-  PMONERRSTRUCT* = ptr MONERRSTRUCT
-  MONHSZSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    fsAction*: WINBOOL
-    dwTime*: DWORD
-    hsz*: HSZ
-    hTask*: HANDLE
-    str*: array[0..0, TCHAR]
-
-  TMONHSZSTRUCT* = MONHSZSTRUCT
-  PMONHSZSTRUCT* = ptr MONHSZSTRUCT
-  MONITOR_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-
-  TMONITORINFO1* = MONITOR_INFO_1
-  PMONITORINFO1* = ptr MONITOR_INFO_1
-  MONITOR_INFO_2* {.final, pure.} = object
-    pName*: LPTSTR
-    pEnvironment*: LPTSTR
-    pDLLName*: LPTSTR
-
-  TMONITORINFO2* = MONITOR_INFO_2
-  PMONITORINFO2* = ptr MONITOR_INFO_2
-  MONLINKSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    dwTime*: DWORD
-    hTask*: HANDLE
-    fEstablished*: WINBOOL
-    fNoData*: WINBOOL
-    hszSvc*: HSZ
-    hszTopic*: HSZ
-    hszItem*: HSZ
-    wFmt*: UINT
-    fServer*: WINBOOL
-    hConvServer*: HCONV
-    hConvClient*: HCONV
-
-  TMONLINKSTRUCT* = MONLINKSTRUCT
-  PMONLINKSTRUCT* = ptr MONLINKSTRUCT
-  MONMSGSTRUCT* {.final, pure.} = object
-    cb*: UINT
-    hwndTo*: HWND
-    dwTime*: DWORD
-    hTask*: HANDLE
-    wMsg*: UINT
-    wParam*: WPARAM
-    lParam*: LPARAM
-    dmhd*: DDEML_MSG_HOOK_DATA
-
-  TMONMSGSTRUCT* = MONMSGSTRUCT
-  PMONMSGSTRUCT* = ptr MONMSGSTRUCT
-  MOUSEHOOKSTRUCT* {.final, pure.} = object
-    pt*: POINT
-    hwnd*: HWND
-    wHitTestCode*: UINT
-    dwExtraInfo*: DWORD
-
-  LPMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT
-  TMOUSEHOOKSTRUCT* = MOUSEHOOKSTRUCT
-  PMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT
-  MOUSEKEYS* {.final, pure.} = object
-    cbSize*: DWORD
-    dwFlags*: DWORD
-    iMaxSpeed*: DWORD
-    iTimeToMaxSpeed*: DWORD
-    iCtrlSpeed*: DWORD
-    dwReserved1*: DWORD
-    dwReserved2*: DWORD
-
-  TMOUSEKEYS* = MOUSEKEYS
-  PMOUSEKEYS* = ptr MOUSEKEYS
-  MSGBOXCALLBACK* = proc (lpHelpInfo: LPHELPINFO){.stdcall.}
-  TMSGBOXCALLBACK* = MSGBOXCALLBACK
-  MSGBOXPARAMS* {.final, pure.} = object
-    cbSize*: UINT
-    hwndOwner*: HWND
-    hInstance*: HINST
-    lpszText*: LPCSTR
-    lpszCaption*: LPCSTR
-    dwStyle*: DWORD
-    lpszIcon*: LPCSTR
-    dwContextHelpId*: DWORD
-    lpfnMsgBoxCallback*: MSGBOXCALLBACK
-    dwLanguageId*: DWORD
-
-  LPMSGBOXPARAMS* = ptr MSGBOXPARAMS
-  TMSGBOXPARAMS* = MSGBOXPARAMS
-  TMSGBOXPARAMSA* = MSGBOXPARAMS
-  PMSGBOXPARAMS* = ptr MSGBOXPARAMS
-  MSGFILTER* {.final, pure.} = object
-    nmhdr*: NMHDR
-    msg*: UINT
-    wParam*: WPARAM
-    lParam*: LPARAM
-
-  Tmsgfilter* = MSGFILTER
-  Pmsgfilter* = ptr MSGFILTER
-  MULTIKEYHELP* {.final, pure.} = object
-    mkSize*: DWORD
-    mkKeylist*: TCHAR
-    szKeyphrase*: array[0..0, TCHAR]
-
-  TMULTIKEYHELP* = MULTIKEYHELP
-  PMULTIKEYHELP* = ptr MULTIKEYHELP
-  NAME_BUFFER* {.final, pure.} = object
-    name*: array[0..(NCBNAMSZ) - 1, UCHAR]
-    name_num*: UCHAR
-    name_flags*: UCHAR
-
-  TNAMEBUFFER* = NAME_BUFFER
-  PNAMEBUFFER* = ptr NAME_BUFFER
-  p_NCB* = ptr NCB
-  NCB* {.final, pure.} = object
-    ncb_command*: UCHAR
-    ncb_retcode*: UCHAR
-    ncb_lsn*: UCHAR
-    ncb_num*: UCHAR
-    ncb_buffer*: PUCHAR
-    ncb_length*: int16
-    ncb_callname*: array[0..(NCBNAMSZ) - 1, UCHAR]
-    ncb_name*: array[0..(NCBNAMSZ) - 1, UCHAR]
-    ncb_rto*: UCHAR
-    ncb_sto*: UCHAR
-    ncb_post*: proc (para1: p_NCB){.CDECL.}
-    ncb_lana_num*: UCHAR
-    ncb_cmd_cplt*: UCHAR
-    ncb_reserve*: array[0..9, UCHAR]
-    ncb_event*: HANDLE
-
-  TNCB* = NCB
-  NCCALCSIZE_PARAMS* {.final, pure.} = object
-    rgrc*: array[0..2, RECT]
-    lppos*: PWINDOWPOS
-
-  TNCCALCSIZEPARAMS* = NCCALCSIZE_PARAMS
-  PNCCALCSIZEPARAMS* = ptr NCCALCSIZE_PARAMS
-  NDDESHAREINFO* {.final, pure.} = object
-    lRevision*: LONG
-    lpszShareName*: LPTSTR
-    lShareType*: LONG
-    lpszAppTopicList*: LPTSTR
-    fSharedFlag*: LONG
-    fService*: LONG
-    fStartAppFlag*: LONG
-    nCmdShow*: LONG
-    qModifyId*: array[0..1, LONG]
-    cNumItems*: LONG
-    lpszItemList*: LPTSTR
-
-  TNDDESHAREINFO* = NDDESHAREINFO
-  PNDDESHAREINFO* = ptr NDDESHAREINFO
-  NETRESOURCE* {.final, pure.} = object
-    dwScope*: DWORD
-    dwType*: DWORD
-    dwDisplayType*: DWORD
-    dwUsage*: DWORD
-    lpLocalName*: LPTSTR
-    lpRemoteName*: LPTSTR
-    lpComment*: LPTSTR
-    lpProvider*: LPTSTR
-
-  LPNETRESOURCE* = ptr NETRESOURCE
-  TNETRESOURCE* = NETRESOURCE
-  TNETRESOURCEA* = NETRESOURCE
-  PNETRESOURCE* = ptr NETRESOURCE
-  PNETRESOURCEA* = ptr NETRESOURCE
-  NEWCPLINFO* {.final, pure.} = object
-    dwSize*: DWORD
-    dwFlags*: DWORD
-    dwHelpContext*: DWORD
-    lData*: LONG
-    hIcon*: HICON
-    szName*: array[0..31, TCHAR]
-    szInfo*: array[0..63, TCHAR]
-    szHelpFile*: array[0..127, TCHAR]
-
-  TNEWCPLINFO* = NEWCPLINFO
-  PNEWCPLINFO* = ptr NEWCPLINFO
-  NEWTEXTMETRIC* {.final, pure.} = object
-    tmHeight*: LONG
-    tmAscent*: LONG
-    tmDescent*: LONG
-    tmInternalLeading*: LONG
-    tmExternalLeading*: LONG
-    tmAveCharWidth*: LONG
-    tmMaxCharWidth*: LONG
-    tmWeight*: LONG
-    tmOverhang*: LONG
-    tmDigitizedAspectX*: LONG
-    tmDigitizedAspectY*: LONG
-    tmFirstChar*: BCHAR
-    tmLastChar*: BCHAR
-    tmDefaultChar*: BCHAR
-    tmBreakChar*: BCHAR
-    tmItalic*: int8
-    tmUnderlined*: int8
-    tmStruckOut*: int8
-    tmPitchAndFamily*: int8
-    tmCharSet*: int8
-    ntmFlags*: DWORD
-    ntmSizeEM*: UINT
-    ntmCellHeight*: UINT
-    ntmAvgWidth*: UINT
-
-  TNEWTEXTMETRIC* = NEWTEXTMETRIC
-  PNEWTEXTMETRIC* = ptr NEWTEXTMETRIC
-  NEWTEXTMETRICEX* {.final, pure.} = object
-    ntmentm*: NEWTEXTMETRIC
-    ntmeFontSignature*: FONTSIGNATURE
-
-  TNEWTEXTMETRICEX* = NEWTEXTMETRICEX
-  PNEWTEXTMETRICEX* = ptr NEWTEXTMETRICEX
-  NM_LISTVIEW* {.final, pure.} = object
-    hdr*: NMHDR
-    iItem*: int32
-    iSubItem*: int32
-    uNewState*: UINT
-    uOldState*: UINT
-    uChanged*: UINT
-    ptAction*: POINT
-    lParam*: LPARAM
-
-  TNMLISTVIEW* = NM_LISTVIEW
-  PNMLISTVIEW* = ptr NM_LISTVIEW
-  TV_ITEM* {.final, pure.} = object
-    mask*: UINT
-    hItem*: HTREEITEM
-    state*: UINT
-    stateMask*: UINT
-    pszText*: LPTSTR
-    cchTextMax*: int32
-    iImage*: int32
-    iSelectedImage*: int32
-    cChildren*: int32
-    lParam*: LPARAM
-
-  LPTV_ITEM* = ptr TV_ITEM
-  TTVITEM* = TV_ITEM
-  PTVITEM* = ptr TV_ITEM
-  NM_TREEVIEW* {.final, pure.} = object
-    hdr*: NMHDR
-    action*: UINT
-    itemOld*: TV_ITEM
-    itemNew*: TV_ITEM
-    ptDrag*: POINT
-
-  LPNM_TREEVIEW* = ptr NM_TREEVIEW
-  TNMTREEVIEW* = NM_TREEVIEW
-  PNMTREEVIEW* = ptr NM_TREEVIEW
-  NM_UPDOWNW* {.final, pure.} = object
-    hdr*: NMHDR
-    iPos*: int32
-    iDelta*: int32
-
-  TNMUPDOWN* = NM_UPDOWNW
-  PNMUPDOWN* = ptr NM_UPDOWNW
-  NONCLIENTMETRICS* {.final, pure.} = object
-    cbSize*: UINT
-    iBorderWidth*: int32
-    iScrollWidth*: int32
-    iScrollHeight*: int32
-    iCaptionWidth*: int32
-    iCaptionHeight*: int32
-    lfCaptionFont*: LOGFONT
-    iSmCaptionWidth*: int32
-    iSmCaptionHeight*: int32
-    lfSmCaptionFont*: LOGFONT
-    iMenuWidth*: int32
-    iMenuHeight*: int32
-    lfMenuFont*: LOGFONT
-    lfStatusFont*: LOGFONT
-    lfMessageFont*: LOGFONT
-
-  LPNONCLIENTMETRICS* = ptr NONCLIENTMETRICS
-  TNONCLIENTMETRICS* = NONCLIENTMETRICS
-  PNONCLIENTMETRICS* = ptr NONCLIENTMETRICS
-  SERVICE_ADDRESS* {.final, pure.} = object
-    dwAddressType*: DWORD
-    dwAddressFlags*: DWORD
-    dwAddressLength*: DWORD
-    dwPrincipalLength*: DWORD
-    lpAddress*: ptr int8
-    lpPrincipal*: ptr int8
-
-  TSERVICEADDRESS* = SERVICE_ADDRESS
-  PSERVICEADDRESS* = ptr SERVICE_ADDRESS
-  SERVICE_ADDRESSES* {.final, pure.} = object
-    dwAddressCount*: DWORD
-    Addresses*: array[0..0, SERVICE_ADDRESS]
-
-  LPSERVICE_ADDRESSES* = ptr SERVICE_ADDRESSES
-  TSERVICEADDRESSES* = SERVICE_ADDRESSES
-  PSERVICEADDRESSES* = ptr SERVICE_ADDRESSES
-  LPGUID* = ptr TGUID
-  PGUID* = ptr TGUID
-  CLSID* = TGUID
-  LPCLSID* = ptr CLSID
-  TCLSID* = CLSID
-  PCLSID* = ptr CLSID
-  SERVICE_INFO* {.final, pure.} = object
-    lpServiceType*: LPGUID
-    lpServiceName*: LPTSTR
-    lpComment*: LPTSTR
-    lpLocale*: LPTSTR
-    dwDisplayHint*: DWORD
-    dwVersion*: DWORD
-    dwTime*: DWORD
-    lpMachineName*: LPTSTR
-    lpServiceAddress*: LPSERVICE_ADDRESSES
-    ServiceSpecificInfo*: BLOB
-
-  TSERVICEINFO* = SERVICE_INFO
-  PSERVICEINFO* = ptr SERVICE_INFO
-  NS_SERVICE_INFO* {.final, pure.} = object
-    dwNameSpace*: DWORD
-    ServiceInfo*: SERVICE_INFO
-
-  TNSSERVICEINFO* = NS_SERVICE_INFO
-  PNSSERVICEINFO* = ptr NS_SERVICE_INFO
-  NUMBERFMT* {.final, pure.} = object
-    NumDigits*: UINT
-    LeadingZero*: UINT
-    Grouping*: UINT
-    lpDecimalSep*: LPTSTR
-    lpThousandSep*: LPTSTR
-    NegativeOrder*: UINT
-
-  Tnumberfmt* = NUMBERFMT
-  Pnumberfmt* = ptr NUMBERFMT
-  OFSTRUCT* {.final, pure.} = object
-    cBytes*: int8
-    fFixedDisk*: int8
-    nErrCode*: int16
-    Reserved1*: int16
-    Reserved2*: int16
-    szPathName*: array[0..(OFS_MAXPATHNAME) - 1, CHAR]
-
-  LPOFSTRUCT* = ptr OFSTRUCT
-  TOFSTRUCT* = OFSTRUCT
-  POFSTRUCT* = ptr OFSTRUCT
-  OPENFILENAME_NT4* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hInstance*: HINST
-    lpstrFilter*: LPCTSTR
-    lpstrCustomFilter*: LPTSTR
-    nMaxCustFilter*: DWORD
-    nFilterIndex*: DWORD
-    lpstrFile*: LPTSTR
-    nMaxFile*: DWORD
-    lpstrFileTitle*: LPTSTR
-    nMaxFileTitle*: DWORD
-    lpstrInitialDir*: LPCTSTR
-    lpstrTitle*: LPCTSTR
-    Flags*: DWORD
-    nFileOffset*: int16
-    nFileExtension*: int16
-    lpstrDefExt*: LPCTSTR
-    lCustData*: LPARAM
-    lpfnHook*: LPOFNHOOKPROC
-    lpTemplateName*: LPCTSTR
-
-  LPOPENFILENAME_NT4* = ptr OPENFILENAME_NT4
-  TOPENFILENAME_NT4* = OPENFILENAME_NT4
-  POPENFILENAME_NT4* = ptr OPENFILENAME_NT4
-  TOPENFILENAME* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hInstance*: HINST
-    lpstrFilter*: LPCTSTR
-    lpstrCustomFilter*: LPTSTR
-    nMaxCustFilter*: DWORD
-    nFilterIndex*: DWORD
-    lpstrFile*: LPTSTR
-    nMaxFile*: DWORD
-    lpstrFileTitle*: LPTSTR
-    nMaxFileTitle*: DWORD
-    lpstrInitialDir*: LPCTSTR
-    lpstrTitle*: LPCTSTR
-    Flags*: DWORD
-    nFileOffset*: int16
-    nFileExtension*: int16
-    lpstrDefExt*: LPCTSTR
-    lCustData*: LPARAM
-    lpfnHook*: LPOFNHOOKPROC
-    lpTemplateName*: LPCTSTR
-    pvReserved*: pointer
-    dwreserved*: dword
-    FlagsEx*: dword
-
-  LPOPENFILENAME* = ptr TOPENFILENAME
-  POPENFILENAME* = ptr TOPENFILENAME
-  OFN* = TOPENFILENAME
-  POFN* = ptr TOPENFILENAME
-  OFNOTIFY* {.final, pure.} = object
-    hdr*: NMHDR
-    lpOFN*: LPOPENFILENAME
-    pszFile*: LPTSTR
-
-  LPOFNOTIFY* = ptr OFNOTIFY
-  TOFNOTIFY* = OFNOTIFY
-  POFNOTIFY* = ptr OFNOTIFY
-  OSVERSIONINFO* {.final, pure.} = object
-    dwOSVersionInfoSize*: DWORD
-    dwMajorVersion*: DWORD
-    dwMinorVersion*: DWORD
-    dwBuildNumber*: DWORD
-    dwPlatformId*: DWORD
-    szCSDVersion*: array[0..127, TCHAR]
-
-  LPOSVERSIONINFO* = ptr OSVERSIONINFO
-  TOSVERSIONINFO* = OSVERSIONINFO
-  POSVERSIONINFO* = ptr OSVERSIONINFO
-  OSVERSIONINFOW* {.final, pure.} = object
-    dwOSVersionInfoSize*: DWORD
-    dwMajorVersion*: DWORD
-    dwMinorVersion*: DWORD
-    dwBuildNumber*: DWORD
-    dwPlatformId*: DWORD
-    szCSDVersion*: array[0..127, WCHAR]
-
-  LPOSVERSIONINFOW* = ptr OSVERSIONINFOW
-  TOSVERSIONINFOW* = OSVERSIONINFOW
-  POSVERSIONINFOW* = ptr OSVERSIONINFOW
-  TEXTMETRIC* {.final, pure.} = object
-    tmHeight*: LONG
-    tmAscent*: LONG
-    tmDescent*: LONG
-    tmInternalLeading*: LONG
-    tmExternalLeading*: LONG
-    tmAveCharWidth*: LONG
-    tmMaxCharWidth*: LONG
-    tmWeight*: LONG
-    tmOverhang*: LONG
-    tmDigitizedAspectX*: LONG
-    tmDigitizedAspectY*: LONG
-    tmFirstChar*: BCHAR
-    tmLastChar*: BCHAR
-    tmDefaultChar*: BCHAR
-    tmBreakChar*: BCHAR
-    tmItalic*: int8
-    tmUnderlined*: int8
-    tmStruckOut*: int8
-    tmPitchAndFamily*: int8
-    tmCharSet*: int8
-
-  LPTEXTMETRIC* = ptr TEXTMETRIC
-  TTEXTMETRIC* = TEXTMETRIC
-  PTEXTMETRIC* = ptr TEXTMETRIC
-  TEXTMETRICW* {.final, pure.} = object
-    tmHeight*: LONG
-    tmAscent*: LONG
-    tmDescent*: LONG
-    tmInternalLeading*: LONG
-    tmExternalLeading*: LONG
-    tmAveCharWidth*: LONG
-    tmMaxCharWidth*: LONG
-    tmWeight*: LONG
-    tmOverhang*: LONG
-    tmDigitizedAspectX*: LONG
-    tmDigitizedAspectY*: LONG
-    tmFirstChar*: WCHAR
-    tmLastChar*: WCHAR
-    tmDefaultChar*: WCHAR
-    tmBreakChar*: WCHAR
-    tmItalic*: int8
-    tmUnderlined*: int8
-    tmStruckOut*: int8
-    tmPitchAndFamily*: int8
-    tmCharSet*: int8
-
-  LPTEXTMETRICW* = ptr TEXTMETRICW
-  TTEXTMETRICW* = TEXTMETRICW
-  PTEXTMETRICW* = ptr TEXTMETRICW
-  OUTLINETEXTMETRIC* {.final, pure.} = object
-    otmSize*: UINT
-    otmTextMetrics*: TEXTMETRIC
-    otmFiller*: int8
-    otmPanoseNumber*: PANOSE
-    otmfsSelection*: UINT
-    otmfsType*: UINT
-    otmsCharSlopeRise*: int32
-    otmsCharSlopeRun*: int32
-    otmItalicAngle*: int32
-    otmEMSquare*: UINT
-    otmAscent*: int32
-    otmDescent*: int32
-    otmLineGap*: UINT
-    otmsCapEmHeight*: UINT
-    otmsXHeight*: UINT
-    otmrcFontBox*: RECT
-    otmMacAscent*: int32
-    otmMacDescent*: int32
-    otmMacLineGap*: UINT
-    otmusMinimumPPEM*: UINT
-    otmptSubscriptSize*: POINT
-    otmptSubscriptOffset*: POINT
-    otmptSuperscriptSize*: POINT
-    otmptSuperscriptOffset*: POINT
-    otmsStrikeoutSize*: UINT
-    otmsStrikeoutPosition*: int32
-    otmsUnderscoreSize*: int32
-    otmsUnderscorePosition*: int32
-    otmpFamilyName*: PSTR
-    otmpFaceName*: PSTR
-    otmpStyleName*: PSTR
-    otmpFullName*: PSTR
-
-  LPOUTLINETEXTMETRIC* = ptr OUTLINETEXTMETRIC
-  TOUTLINETEXTMETRIC* = OUTLINETEXTMETRIC
-  POUTLINETEXTMETRIC* = ptr OUTLINETEXTMETRIC
-  OVERLAPPED* {.final, pure.} = object
-    Internal*: DWORD
-    InternalHigh*: DWORD
-    Offset*: DWORD
-    OffsetHigh*: DWORD
-    hEvent*: HANDLE
-
-  LPOVERLAPPED* = ptr OVERLAPPED
-  TOVERLAPPED* = OVERLAPPED
-  POVERLAPPED* = ptr OVERLAPPED #PAGESETUPDLG = record conflicts with function PageSetupDlg
-  TPAGESETUPDLG* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hDevMode*: HGLOBAL
-    hDevNames*: HGLOBAL
-    Flags*: DWORD
-    ptPaperSize*: POINT
-    rtMinMargin*: RECT
-    rtMargin*: RECT
-    hInstance*: HINST
-    lCustData*: LPARAM
-    lpfnPageSetupHook*: LPPAGESETUPHOOK
-    lpfnPagePaintHook*: LPPAGEPAINTHOOK
-    lpPageSetupTemplateName*: LPCTSTR
-    hPageSetupTemplate*: HGLOBAL
-
-  LPPAGESETUPDLG* = ptr TPAGESETUPDLG
-  PPAGESETUPDLG* = ptr TPAGESETUPDLG
-  TPSD* = TPAGESETUPDLG
-  PPSD* = ptr TPAGESETUPDLG
-  PAINTSTRUCT* {.final, pure.} = object
-    hdc*: HDC
-    fErase*: WINBOOL
-    rcPaint*: RECT
-    fRestore*: WINBOOL
-    fIncUpdate*: WINBOOL
-    rgbReserved*: array[0..31, int8]
-
-  LPPAINTSTRUCT* = ptr PAINTSTRUCT
-  TPAINTSTRUCT* = PAINTSTRUCT
-  PPAINTSTRUCT* = ptr PAINTSTRUCT
-  PARAFORMAT* {.final, pure.} = object
-    cbSize*: UINT
-    dwMask*: DWORD
-    wNumbering*: int16
-    wReserved*: int16
-    dxStartIndent*: LONG
-    dxRightIndent*: LONG
-    dxOffset*: LONG
-    wAlignment*: int16
-    cTabCount*: SHORT
-    rgxTabs*: array[0..(MAX_TAB_STOPS) - 1, LONG]
-
-  Tparaformat* = PARAFORMAT
-  Pparaformat* = ptr PARAFORMAT
-  PERF_COUNTER_BLOCK* {.final, pure.} = object
-    ByteLength*: DWORD
-
-  TPERFCOUNTERBLOCK* = PERF_COUNTER_BLOCK
-  PPERFCOUNTERBLOCK* = ptr PERF_COUNTER_BLOCK
-  PERF_COUNTER_DEFINITION* {.final, pure.} = object
-    ByteLength*: DWORD
-    CounterNameTitleIndex*: DWORD
-    CounterNameTitle*: LPWSTR
-    CounterHelpTitleIndex*: DWORD
-    CounterHelpTitle*: LPWSTR
-    DefaultScale*: DWORD
-    DetailLevel*: DWORD
-    CounterType*: DWORD
-    CounterSize*: DWORD
-    CounterOffset*: DWORD
-
-  TPERFCOUNTERDEFINITION* = PERF_COUNTER_DEFINITION
-  PPERFCOUNTERDEFINITION* = ptr PERF_COUNTER_DEFINITION
-  PERF_DATA_BLOCK* {.final, pure.} = object
-    Signature*: array[0..3, WCHAR]
-    LittleEndian*: DWORD
-    Version*: DWORD
-    Revision*: DWORD
-    TotalByteLength*: DWORD
-    HeaderLength*: DWORD
-    NumObjectTypes*: DWORD
-    DefaultObject*: DWORD
-    SystemTime*: SYSTEMTIME
-    PerfTime*: LARGE_INTEGER
-    PerfFreq*: LARGE_INTEGER
-    PerfTime100nSec*: LARGE_INTEGER
-    SystemNameLength*: DWORD
-    SystemNameOffset*: DWORD
-
-  TPERFDATABLOCK* = PERF_DATA_BLOCK
-  PPERFDATABLOCK* = ptr PERF_DATA_BLOCK
-  PERF_INSTANCE_DEFINITION* {.final, pure.} = object
-    ByteLength*: DWORD
-    ParentObjectTitleIndex*: DWORD
-    ParentObjectInstance*: DWORD
-    UniqueID*: DWORD
-    NameOffset*: DWORD
-    NameLength*: DWORD
-
-  TPERFINSTANCEDEFINITION* = PERF_INSTANCE_DEFINITION
-  PPERFINSTANCEDEFINITION* = PERF_INSTANCE_DEFINITION
-  PERF_OBJECT_TYPE* {.final, pure.} = object
-    TotalByteLength*: DWORD
-    DefinitionLength*: DWORD
-    HeaderLength*: DWORD
-    ObjectNameTitleIndex*: DWORD
-    ObjectNameTitle*: LPWSTR
-    ObjectHelpTitleIndex*: DWORD
-    ObjectHelpTitle*: LPWSTR
-    DetailLevel*: DWORD
-    NumCounters*: DWORD
-    DefaultCounter*: DWORD
-    NumInstances*: DWORD
-    CodePage*: DWORD
-    PerfTime*: LARGE_INTEGER
-    PerfFreq*: LARGE_INTEGER
-
-  TPERFOBJECTTYPE* = PERF_OBJECT_TYPE
-  PPERFOBJECTTYPE* = ptr PERF_OBJECT_TYPE
-  POLYTEXT* {.final, pure.} = object
-    x*: int32
-    y*: int32
-    n*: UINT
-    lpstr*: LPCTSTR
-    uiFlags*: UINT
-    rcl*: RECT
-    pdx*: ptr int32
-
-  TPOLYTEXT* = POLYTEXT
-  PPOLYTEXT* = ptr POLYTEXT
-  PORT_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-
-  TPORTINFO1* = PORT_INFO_1
-  PPORTINFO1* = ptr PORT_INFO_1
-  PORT_INFO_2* {.final, pure.} = object
-    pPortName*: LPSTR
-    pMonitorName*: LPSTR
-    pDescription*: LPSTR
-    fPortType*: DWORD
-    Reserved*: DWORD
-
-  TPORTINFO2* = PORT_INFO_2
-  PPORTINFO2* = ptr PORT_INFO_2
-  PREVENT_MEDIA_REMOVAL* {.final, pure.} = object
-    PreventMediaRemoval*: bool
-
-  TPREVENTMEDIAREMOVAL* = PREVENT_MEDIA_REMOVAL
-  PPREVENTMEDIAREMOVAL* = ptr PREVENT_MEDIA_REMOVAL #PRINTDLG = record conflicts with PrintDlg function
-  TPRINTDLG* {.final, pure.} = object
-    lStructSize*: DWORD
-    hwndOwner*: HWND
-    hDevMode*: HANDLE
-    hDevNames*: HANDLE
-    hDC*: HDC
-    Flags*: DWORD
-    nFromPage*: int16
-    nToPage*: int16
-    nMinPage*: int16
-    nMaxPage*: int16
-    nCopies*: int16
-    hInstance*: HINST
-    lCustData*: DWORD
-    lpfnPrintHook*: LPPRINTHOOKPROC
-    lpfnSetupHook*: LPSETUPHOOKPROC
-    lpPrintTemplateName*: LPCTSTR
-    lpSetupTemplateName*: LPCTSTR
-    hPrintTemplate*: HANDLE
-    hSetupTemplate*: HANDLE
-
-  LPPRINTDLG* = ptr TPRINTDLG
-  PPRINTDLG* = ptr TPRINTDLG
-  TPD* = TPRINTDLG
-  PPD* = ptr TPRINTDLG
-  PRINTER_DEFAULTS* {.final, pure.} = object
-    pDatatype*: LPTSTR
-    pDevMode*: LPDEVMODE
-    DesiredAccess*: ACCESS_MASK
-
-  TPRINTERDEFAULTS* = PRINTER_DEFAULTS
-  PPRINTERDEFAULTS* = ptr PRINTER_DEFAULTS
-  PRINTER_INFO_1* {.final, pure.} = object
-    Flags*: DWORD
-    pDescription*: LPTSTR
-    pName*: LPTSTR
-    pComment*: LPTSTR
-
-  LPPRINTER_INFO_1* = ptr PRINTER_INFO_1
-  PPRINTER_INFO_1* = ptr PRINTER_INFO_1
-  TPRINTERINFO1* = PRINTER_INFO_1
-  PRINTER_INFO_2* {.final, pure.} = object
-    pServerName*: LPTSTR
-    pPrinterName*: LPTSTR
-    pShareName*: LPTSTR
-    pPortName*: LPTSTR
-    pDriverName*: LPTSTR
-    pComment*: LPTSTR
-    pLocation*: LPTSTR
-    pDevMode*: LPDEVMODE
-    pSepFile*: LPTSTR
-    pPrintProcessor*: LPTSTR
-    pDatatype*: LPTSTR
-    pParameters*: LPTSTR
-    pSecurityDescriptor*: PSECURITY_DESCRIPTOR
-    Attributes*: DWORD
-    Priority*: DWORD
-    DefaultPriority*: DWORD
-    StartTime*: DWORD
-    UntilTime*: DWORD
-    Status*: DWORD
-    cJobs*: DWORD
-    AveragePPM*: DWORD
-
-  TPRINTERINFO2* = PRINTER_INFO_2
-  PPRINTERINFO2* = ptr PRINTER_INFO_2
-  PRINTER_INFO_3* {.final, pure.} = object
-    pSecurityDescriptor*: PSECURITY_DESCRIPTOR
-
-  TPRINTERINFO3* = PRINTER_INFO_3
-  PPRINTERINFO3* = ptr PRINTER_INFO_3
-  PRINTER_INFO_4* {.final, pure.} = object
-    pPrinterName*: LPTSTR
-    pServerName*: LPTSTR
-    Attributes*: DWORD
-
-  TPRINTERINFO4* = PRINTER_INFO_4
-  PPRINTERINFO4* = ptr PRINTER_INFO_4
-  PRINTER_INFO_5* {.final, pure.} = object
-    pPrinterName*: LPTSTR
-    pPortName*: LPTSTR
-    Attributes*: DWORD
-    DeviceNotSelectedTimeout*: DWORD
-    TransmissionRetryTimeout*: DWORD
-
-  TPRINTERINFO5* = PRINTER_INFO_5
-  PPRINTERINFO5* = ptr PRINTER_INFO_5
-  PRINTER_NOTIFY_INFO_DATA* {.final, pure.} = object
-    `type`*: int16
-    Field*: int16
-    Reserved*: DWORD
-    Id*: DWORD
-    cbBuf*: DWORD
-    pBuf*: LPVOID
-
-  TPRINTERNOTIFYINFODATA* = PRINTER_NOTIFY_INFO_DATA
-  PPRINTERNOTIFYINFODATA* = ptr PRINTER_NOTIFY_INFO_DATA
-  PRINTER_NOTIFY_INFO* {.final, pure.} = object
-    Version*: DWORD
-    Flags*: DWORD
-    Count*: DWORD
-    aData*: array[0..0, PRINTER_NOTIFY_INFO_DATA]
-
-  TPRINTERNOTIFYINFO* = PRINTER_NOTIFY_INFO
-  PPRINTERNOTIFYINFO* = ptr PRINTER_NOTIFY_INFO
-  PRINTER_NOTIFY_OPTIONS_TYPE* {.final, pure.} = object
-    `type`*: int16
-    Reserved0*: int16
-    Reserved1*: DWORD
-    Reserved2*: DWORD
-    Count*: DWORD
-    pFields*: PWORD
-
-  PPRINTER_NOTIFY_OPTIONS_TYPE* = ptr PRINTER_NOTIFY_OPTIONS_TYPE
-  TPRINTERNOTIFYOPTIONSTYPE* = PRINTER_NOTIFY_OPTIONS_TYPE
-  PRINTER_NOTIFY_OPTIONS* {.final, pure.} = object
-    Version*: DWORD
-    Flags*: DWORD
-    Count*: DWORD
-    pTypes*: PPRINTER_NOTIFY_OPTIONS_TYPE
-
-  TPRINTERNOTIFYOPTIONS* = PRINTER_NOTIFY_OPTIONS
-  PPRINTERNOTIFYOPTIONS* = ptr PRINTER_NOTIFY_OPTIONS
-  PRINTPROCESSOR_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-
-  TPRINTPROCESSORINFO1* = PRINTPROCESSOR_INFO_1
-  PPRINTPROCESSORINFO1* = ptr PRINTPROCESSOR_INFO_1
-  PRIVILEGE_SET* {.final, pure.} = object
-    PrivilegeCount*: DWORD
-    Control*: DWORD
-    Privilege*: array[0..(ANYSIZE_ARRAY) - 1, LUID_AND_ATTRIBUTES]
-
-  LPPRIVILEGE_SET* = ptr PRIVILEGE_SET
-  PPRIVILEGE_SET* = ptr PRIVILEGE_SET
-  TPRIVILEGESET* = PRIVILEGE_SET
-  PROCESS_HEAPENTRY* {.final, pure.} = object
-    lpData*: PVOID
-    cbData*: DWORD
-    cbOverhead*: int8
-    iRegionIndex*: int8
-    wFlags*: int16
-    dwCommittedSize*: DWORD
-    dwUnCommittedSize*: DWORD
-    lpFirstBlock*: LPVOID
-    lpLastBlock*: LPVOID
-    hMem*: HANDLE
-
-  LPPROCESS_HEAP_ENTRY* = ptr PROCESS_HEAPENTRY
-  TPROCESSHEAPENTRY* = PROCESS_HEAPENTRY
-  PPROCESSHEAPENTRY* = ptr PROCESS_HEAPENTRY
-  PROCESS_INFORMATION* {.final, pure.} = object
-    hProcess*: HANDLE
-    hThread*: HANDLE
-    dwProcessId*: DWORD
-    dwThreadId*: DWORD
-
-  LPPROCESS_INFORMATION* = ptr PROCESS_INFORMATION
-  TPROCESSINFORMATION* = PROCESS_INFORMATION
-  PPROCESSINFORMATION* = ptr PROCESS_INFORMATION
-  LPFNPSPCALLBACK* = proc (para1: HWND, para2: UINT, para3: LPVOID): UINT{.
-      stdcall.}
-  TFNPSPCALLBACK* = LPFNPSPCALLBACK
-  PROPSHEETPAGE* {.final, pure.} = object
-    dwSize*: DWORD
-    dwFlags*: DWORD
-    hInstance*: HINST
-    pszIcon*: LPCTSTR
-    pszTitle*: LPCTSTR
-    pfnDlgProc*: DLGPROC
-    lParam*: LPARAM
-    pfnCallback*: LPFNPSPCALLBACK
-    pcRefParent*: ptr UINT
-
-  LPPROPSHEETPAGE* = ptr PROPSHEETPAGE
-  LPCPROPSHEETPAGE* = ptr PROPSHEETPAGE
-  TPROPSHEETPAGE* = PROPSHEETPAGE
-  PPROPSHEETPAGE* = ptr PROPSHEETPAGE
-  emptyrecord* {.final, pure.} = object
-  lpemptyrecord* = ptr emptyrecord
-  HPROPSHEETPAGE* = ptr emptyrecord
-  PROPSHEETHEADER* {.final, pure.} = object
-    dwSize*: DWORD
-    dwFlags*: DWORD
-    hwndParent*: HWND
-    hInstance*: HINST
-    pszIcon*: LPCTSTR
-    pszCaption*: LPCTSTR
-    nPages*: UINT
-    pStartPage*: LPCTSTR
-    phpage*: ptr HPROPSHEETPAGE
-    pfnCallback*: PFNPROPSHEETCALLBACK
-    pszbmWatermark*: LPCTSTR
-    hplWatermark*: HPALETTE
-    pszbmHeader*: cstring
-
-  LPPROPSHEETHEADER* = ptr PROPSHEETHEADER
-  LPCPROPSHEETHEADER* = ptr PROPSHEETHEADER
-  TPROPSHEETHEADER* = PROPSHEETHEADER
-  PPROPSHEETHEADER* = ptr PROPSHEETHEADER # PropertySheet callbacks
-  LPFNADDPROPSHEETPAGE* = proc (para1: HPROPSHEETPAGE, para2: LPARAM): WINBOOL{.
-      stdcall.}
-  TFNADDPROPSHEETPAGE* = LPFNADDPROPSHEETPAGE
-  LPFNADDPROPSHEETPAGES* = proc (para1: LPVOID, para2: LPFNADDPROPSHEETPAGE,
-                                 para3: LPARAM): WINBOOL{.stdcall.}
-  TFNADDPROPSHEETPAGES* = LPFNADDPROPSHEETPAGES
-  PROTOCOL_INFO* {.final, pure.} = object
-    dwServiceFlags*: DWORD
-    iAddressFamily*: WINT
-    iMaxSockAddr*: WINT
-    iMinSockAddr*: WINT
-    iSocketType*: WINT
-    iProtocol*: WINT
-    dwMessageSize*: DWORD
-    lpProtocol*: LPTSTR
-
-  TPROTOCOLINFO* = PROTOCOL_INFO
-  PPROTOCOLINFO* = ptr PROTOCOL_INFO
-  PROVIDOR_INFO_1* {.final, pure.} = object
-    pName*: LPTSTR
-    pEnvironment*: LPTSTR
-    pDLLName*: LPTSTR
-
-  TPROVIDORINFO1* = PROVIDOR_INFO_1
-  PPROVIDORINFO1* = ptr PROVIDOR_INFO_1
-  PSHNOTIFY* {.final, pure.} = object
-    hdr*: NMHDR
-    lParam*: LPARAM
-
-  LPPSHNOTIFY* = ptr PSHNOTIFY
-  TPSHNOTIFY* = PSHNOTIFY
-  PPSHNOTIFY* = ptr PSHNOTIFY
-  PUNCTUATION* {.final, pure.} = object
-    iSize*: UINT
-    szPunctuation*: LPSTR
-
-  Tpunctuation* = PUNCTUATION
-  Ppunctuation* = ptr PUNCTUATION
-  TQUERY_SERVICE_CONFIG* {.final, pure.} = object
-    dwServiceType*: DWORD
-    dwStartType*: DWORD
-    dwErrorControl*: DWORD
-    lpBinaryPathName*: LPTSTR
-    lpLoadOrderGroup*: LPTSTR
-    dwTagId*: DWORD
-    lpDependencies*: LPTSTR
-    lpServiceStartName*: LPTSTR
-    lpDisplayName*: LPTSTR
-
-  LPQUERY_SERVICE_CONFIG* = ptr TQUERY_SERVICE_CONFIG
-  PQUERYSERVICECONFIG* = ptr TQUERY_SERVICE_CONFIG
-  TQUERY_SERVICE_LOCK_STATUS* {.final, pure.} = object
-    fIsLocked*: DWORD
-    lpLockOwner*: LPTSTR
-    dwLockDuration*: DWORD
-
-  LPQUERY_SERVICE_LOCK_STATUS* = ptr TQUERY_SERVICE_LOCK_STATUS
-  PQUERYSERVICELOCKSTATUS* = ptr TQUERY_SERVICE_LOCK_STATUS
-  RASAMB* {.final, pure.} = object
-    dwSize*: DWORD
-    dwError*: DWORD
-    szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR]
-    bLana*: int8
-
-  TRASAMB* = RASAMB
-  PRASAMB* = ptr RASAMB
-  RASCONN* {.final, pure.} = object
-    dwSize*: DWORD
-    hrasconn*: HRASCONN
-    szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR]
-    szDeviceType*: array[0..(RAS_MaxDeviceType + 1) - 1, CHAR]
-    szDeviceName*: array[0..(RAS_MaxDeviceName + 1) - 1, CHAR]
-
-  TRASCONN* = RASCONN
-  PRASCONN* = ptr RASCONN
-  RASCONNSTATUS* {.final, pure.} = object
-    dwSize*: DWORD
-    rasconnstate*: RASCONNSTATE
-    dwError*: DWORD
-    szDeviceType*: array[0..(RAS_MaxDeviceType + 1) - 1, TCHAR]
-    szDeviceName*: array[0..(RAS_MaxDeviceName + 1) - 1, TCHAR]
-
-  TRASCONNSTATUS* = RASCONNSTATUS
-  PRASCONNSTATUS* = ptr RASCONNSTATUS
-  RASDIALEXTENSIONS* {.final, pure.} = object
-    dwSize*: DWORD
-    dwfOptions*: DWORD
-    hwndParent*: HWND
-    reserved*: DWORD
-
-  TRASDIALEXTENSIONS* = RASDIALEXTENSIONS
-  PRASDIALEXTENSIONS* = ptr RASDIALEXTENSIONS
-  RASDIALPARAMS* {.final, pure.} = object
-    dwSize*: DWORD
-    szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR]
-    szPhoneNumber*: array[0..(RAS_MaxPhoneNumber + 1) - 1, TCHAR]
-    szCallbackNumber*: array[0..(RAS_MaxCallbackNumber + 1) - 1, TCHAR]
-    szUserName*: array[0..(UNLEN + 1) - 1, TCHAR]
-    szPassword*: array[0..(PWLEN + 1) - 1, TCHAR]
-    szDomain*: array[0..(DNLEN + 1) - 1, TCHAR]
-
-  TRASDIALPARAMS* = RASDIALPARAMS
-  PRASDIALPARAMS* = ptr RASDIALPARAMS
-  RASENTRYNAME* {.final, pure.} = object
-    dwSize*: DWORD
-    szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR]
-
-  TRASENTRYNAME* = RASENTRYNAME
-  PRASENTRYNAME* = ptr RASENTRYNAME
-  RASPPPIP* {.final, pure.} = object
-    dwSize*: DWORD
-    dwError*: DWORD
-    szIpAddress*: array[0..(RAS_MaxIpAddress + 1) - 1, TCHAR]
-
-  TRASPPPIP* = RASPPPIP
-  PRASPPPIP* = ptr RASPPPIP
-  RASPPPIPX* {.final, pure.} = object
-    dwSize*: DWORD
-    dwError*: DWORD
-    szIpxAddress*: array[0..(RAS_MaxIpxAddress + 1) - 1, TCHAR]
-
-  TRASPPPIPX* = RASPPPIPX
-  PRASPPPIPX* = ptr RASPPPIPX
-  RASPPPNBF* {.final, pure.} = object
-    dwSize*: DWORD
-    dwError*: DWORD
-    dwNetBiosError*: DWORD
-    szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR]
-    szWorkstationName*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR]
-    bLana*: int8
-
-  TRASPPPNBF* = RASPPPNBF
-  PRASPPPNBF* = ptr RASPPPNBF
-  RASTERIZER_STATUS* {.final, pure.} = object
-    nSize*: short
-    wFlags*: short
-    nLanguageID*: short
-
-  LPRASTERIZER_STATUS* = ptr RASTERIZER_STATUS
-  TRASTERIZERSTATUS* = RASTERIZER_STATUS
-  PRASTERIZERSTATUS* = ptr RASTERIZER_STATUS
-  REASSIGN_BLOCKS* {.final, pure.} = object
-    Reserved*: int16
-    Count*: int16
-    BlockNumber*: array[0..0, DWORD]
-
-  TREASSIGNBLOCKS* = REASSIGN_BLOCKS
-  PREASSIGNBLOCKS* = ptr REASSIGN_BLOCKS
-  REMOTE_NAME_INFO* {.final, pure.} = object
-    lpUniversalName*: LPTSTR
-    lpConnectionName*: LPTSTR
-    lpRemainingPath*: LPTSTR
-
-  TREMOTENAMEINFO* = REMOTE_NAME_INFO
-  PREMOTENAMEINFO* = ptr REMOTE_NAME_INFO #
-                                          #   TODO: OLE
-                                          #  typedef struct _reobject {
-                                          #    DWORD  cbStruct;
-                                          #    LONG   cp;
-                                          #    CLSID  clsid;
-                                          #    LPOLEOBJECT      poleobj;
-                                          #    LPSTORAGE        pstg;
-                                          #    LPOLECLIENTSITE  polesite;
-                                          #    SIZEL  sizel;
-                                          #    DWORD  dvaspect;
-                                          #    DWORD  dwFlags;
-                                          #    DWORD  dwUser;
-                                          #  } REOBJECT;
-                                          #
-  REPASTESPECIAL* {.final, pure.} = object
-    dwAspect*: DWORD
-    dwParam*: DWORD
-
-  Trepastespecial* = REPASTESPECIAL
-  Prepastespecial* = ptr REPASTESPECIAL
-  REQRESIZE* {.final, pure.} = object
-    nmhdr*: NMHDR
-    rc*: RECT
-
-  Treqresize* = REQRESIZE
-  Preqresize* = ptr REQRESIZE
-  RGNDATAHEADER* {.final, pure.} = object
-    dwSize*: DWORD
-    iType*: DWORD
-    nCount*: DWORD
-    nRgnSize*: DWORD
-    rcBound*: RECT
-
-  TRGNDATAHEADER* = RGNDATAHEADER
-  PRGNDATAHEADER* = ptr RGNDATAHEADER
-  RGNDATA* {.final, pure.} = object
-    rdh*: RGNDATAHEADER
-    Buffer*: array[0..0, char]
-
-  LPRGNDATA* = ptr RGNDATA
-  TRGNDATA* = RGNDATA
-  PRGNDATA* = ptr RGNDATA
-  SCROLLINFO* {.final, pure.} = object
-    cbSize*: UINT
-    fMask*: UINT
-    nMin*: int32
-    nMax*: int32
-    nPage*: UINT
-    nPos*: int32
-    nTrackPos*: int32
-
-  LPSCROLLINFO* = ptr SCROLLINFO
-  LPCSCROLLINFO* = ptr SCROLLINFO
-  TSCROLLINFO* = SCROLLINFO
-  PSCROLLINFO* = ptr SCROLLINFO
-  SECURITY_ATTRIBUTES* {.final, pure.} = object
-    nLength*: DWORD
-    lpSecurityDescriptor*: LPVOID
-    bInheritHandle*: WINBOOL
-
-  LPSECURITY_ATTRIBUTES* = ptr SECURITY_ATTRIBUTES
-  TSECURITYATTRIBUTES* = SECURITY_ATTRIBUTES
-  PSECURITYATTRIBUTES* = ptr SECURITY_ATTRIBUTES
-  SECURITY_INFORMATION* = DWORD
-  PSECURITY_INFORMATION* = ptr SECURITY_INFORMATION
-  TSECURITYINFORMATION* = SECURITY_INFORMATION
-  SELCHANGE* {.final, pure.} = object
-    nmhdr*: NMHDR
-    chrg*: CHARRANGE
-    seltyp*: int16
-
-  Tselchange* = SELCHANGE
-  Pselchange* = ptr SELCHANGE
-  SERIALKEYS* {.final, pure.} = object
-    cbSize*: DWORD
-    dwFlags*: DWORD
-    lpszActivePort*: LPSTR
-    lpszPort*: LPSTR
-    iBaudRate*: DWORD
-    iPortState*: DWORD
-
-  LPSERIALKEYS* = ptr SERIALKEYS
-  TSERIALKEYS* = SERIALKEYS
-  PSERIALKEYS* = ptr SERIALKEYS
-  SERVICE_TABLE_ENTRY* {.final, pure.} = object
-    lpServiceName*: LPTSTR
-    lpServiceProc*: LPSERVICE_MAIN_FUNCTION
-
-  LPSERVICE_TABLE_ENTRY* = ptr SERVICE_TABLE_ENTRY
-  TSERVICETABLEENTRY* = SERVICE_TABLE_ENTRY
-  PSERVICETABLEENTRY* = ptr SERVICE_TABLE_ENTRY
-  SERVICE_TYPE_VALUE_ABS* {.final, pure.} = object
-    dwNameSpace*: DWORD
-    dwValueType*: DWORD
-    dwValueSize*: DWORD
-    lpValueName*: LPTSTR
-    lpValue*: PVOID
-
-  TSERVICETYPEVALUEABS* = SERVICE_TYPE_VALUE_ABS
-  PSERVICETYPEVALUEABS* = ptr SERVICE_TYPE_VALUE_ABS
-  SERVICE_TYPE_INFO_ABS* {.final, pure.} = object
-    lpTypeName*: LPTSTR
-    dwValueCount*: DWORD
-    Values*: array[0..0, SERVICE_TYPE_VALUE_ABS]
-
-  TSERVICETYPEINFOABS* = SERVICE_TYPE_INFO_ABS
-  PSERVICETYPEINFOABS* = ptr SERVICE_TYPE_INFO_ABS
-  SESSION_BUFFER* {.final, pure.} = object
-    lsn*: UCHAR
-    state*: UCHAR
-    local_name*: array[0..(NCBNAMSZ) - 1, UCHAR]
-    remote_name*: array[0..(NCBNAMSZ) - 1, UCHAR]
-    rcvs_outstanding*: UCHAR
-    sends_outstanding*: UCHAR
-
-  TSESSIONBUFFER* = SESSION_BUFFER
-  PSESSIONBUFFER* = ptr SESSION_BUFFER
-  SESSION_HEADER* {.final, pure.} = object
-    sess_name*: UCHAR
-    num_sess*: UCHAR
-    rcv_dg_outstanding*: UCHAR
-    rcv_any_outstanding*: UCHAR
-
-  TSESSIONHEADER* = SESSION_HEADER
-  PSESSIONHEADER* = ptr SESSION_HEADER
-  SET_PARTITION_INFORMATION* {.final, pure.} = object
-    PartitionType*: int8
-
-  TSETPARTITIONINFORMATION* = SET_PARTITION_INFORMATION
-  PSETPARTITIONINFORMATION* = ptr SET_PARTITION_INFORMATION
-  SHCONTF* = enum
-    SHCONTF_FOLDERS = 32, SHCONTF_NONFOLDERS = 64, SHCONTF_INCLUDEHIDDEN = 128
-  TSHCONTF* = SHCONTF
-  SHFILEINFO* {.final, pure.} = object
-    hIcon*: HICON
-    iIcon*: int32
-    dwAttributes*: DWORD
-    szDisplayName*: array[0..(MAX_PATH) - 1, char]
-    szTypeName*: array[0..79, char]
-
-  TSHFILEINFO* = SHFILEINFO
-  PSHFILEINFO* = ptr SHFILEINFO
-  FILEOP_FLAGS* = int16
-  TFILEOPFLAGS* = FILEOP_FLAGS
-  PFILEOPFLAGS* = ptr FILEOP_FLAGS
-  SHFILEOPSTRUCT* {.final, pure.} = object
-    hwnd*: HWND
-    wFunc*: UINT
-    pFrom*: LPCSTR
-    pTo*: LPCSTR
-    fFlags*: FILEOP_FLAGS
-    fAnyOperationsAborted*: WINBOOL
-    hNameMappings*: LPVOID
-    lpszProgressTitle*: LPCSTR
-
-  LPSHFILEOPSTRUCT* = ptr SHFILEOPSTRUCT
-  TSHFILEOPSTRUCT* = SHFILEOPSTRUCT
-  PSHFILEOPSTRUCT* = ptr SHFILEOPSTRUCT
-  SHGNO* = enum
-    SHGDN_NORMAL = 0, SHGDN_INFOLDER = 1, SHGDN_FORPARSING = 0x00008000
-  TSHGDN* = SHGNO
-  SHNAMEMAPPING* {.final, pure.} = object
-    pszOldPath*: LPSTR
-    pszNewPath*: LPSTR
-    cchOldPath*: int32
-    cchNewPath*: int32
-
-  LPSHNAMEMAPPING* = ptr SHNAMEMAPPING
-  TSHNAMEMAPPING* = SHNAMEMAPPING
-  PSHNAMEMAPPING* = ptr SHNAMEMAPPING
-  SID_AND_ATTRIBUTES* {.final, pure.} = object
-    Sid*: PSID
-    Attributes*: DWORD
-
-  TSIDANDATTRIBUTES* = SID_AND_ATTRIBUTES
-  PSIDANDATTRIBUTES* = ptr SID_AND_ATTRIBUTES
-  SID_AND_ATTRIBUTES_ARRAY* = array[0..(ANYSIZE_ARRAY) - 1, SID_AND_ATTRIBUTES]
-  PSID_AND_ATTRIBUTES_ARRAY* = ptr SID_AND_ATTRIBUTES_ARRAY
-  TSIDANDATTRIBUTESARRAY* = SID_AND_ATTRIBUTES_ARRAY
-  SINGLE_LIST_ENTRY* {.final, pure.} = object
-    Next*: ptr SINGLE_LIST_ENTRY
-
-  TSINGLELISTENTRY* = SINGLE_LIST_ENTRY
-  PSINGLELISTENTRY* = ptr SINGLE_LIST_ENTRY
-  SOUNDSENTRY* {.final, pure.} = object
-    cbSize*: UINT
-    dwFlags*: DWORD
-    iFSTextEffect*: DWORD
-    iFSTextEffectMSec*: DWORD
-    iFSTextEffectColorBits*: DWORD
-    iFSGrafEffect*: DWORD
-    iFSGrafEffectMSec*: DWORD
-    iFSGrafEffectColor*: DWORD
-    iWindowsEffect*: DWORD
-    iWindowsEffectMSec*: DWORD
-    lpszWindowsEffectDLL*: LPTSTR
-    iWindowsEffectOrdinal*: DWORD
-
-  LPSOUNDSENTRY* = ptr SOUNDSENTRY
-  TSOUNDSENTRY* = SOUNDSENTRY
-  PSOUNDSENTRY* = ptr SOUNDSENTRY
-  STARTUPINFO* {.final, pure.} = object
-    cb*: DWORD
-    lpReserved*: LPTSTR
-    lpDesktop*: LPTSTR
-    lpTitle*: LPTSTR
-    dwX*: DWORD
-    dwY*: DWORD
-    dwXSize*: DWORD
-    dwYSize*: DWORD
-    dwXCountChars*: DWORD
-    dwYCountChars*: DWORD
-    dwFillAttribute*: DWORD
-    dwFlags*: DWORD
-    wShowWindow*: int16
-    cbReserved2*: int16
-    lpReserved2*: LPBYTE
-    hStdInput*: HANDLE
-    hStdOutput*: HANDLE
-    hStdError*: HANDLE
-
-  LPSTARTUPINFO* = ptr STARTUPINFO
-  TSTARTUPINFO* = STARTUPINFO
-  PSTARTUPINFO* = ptr STARTUPINFO
-  STICKYKEYS* {.final, pure.} = object
-    cbSize*: DWORD
-    dwFlags*: DWORD
-
-  LPSTICKYKEYS* = ptr STICKYKEYS
-  TSTICKYKEYS* = STICKYKEYS
-  PSTICKYKEYS* = ptr STICKYKEYS
-  STRRET* {.final, pure.} = object
-    uType*: UINT
-    cStr*: array[0..(MAX_PATH) - 1, char]
-
-  LPSTRRET* = ptr STRRET
-  TSTRRET* = STRRET
-  PSTRRET* = ptr STRRET
-  STYLEBUF* {.final, pure.} = object
-    dwStyle*: DWORD
-    szDescription*: array[0..31, CHAR]
-
-  LPSTYLEBUF* = ptr STYLEBUF
-  TSTYLEBUF* = STYLEBUF
-  PSTYLEBUF* = ptr STYLEBUF
-  STYLESTRUCT* {.final, pure.} = object
-    styleOld*: DWORD
-    styleNew*: DWORD
-
-  LPSTYLESTRUCT* = ptr STYLESTRUCT
-  TSTYLESTRUCT* = STYLESTRUCT
-  PSTYLESTRUCT* = ptr STYLESTRUCT
-  SYSTEM_AUDIT_ACE* {.final, pure.} = object
-    Header*: ACE_HEADER
-    Mask*: ACCESS_MASK
-    SidStart*: DWORD
-
-  TSYSTEMAUDITACE* = SYSTEM_AUDIT_ACE
-  PSYSTEMAUDITACE* = ptr SYSTEM_AUDIT_ACE
-  SYSTEM_INFO* {.final, pure.} = object
-    dwOemId*: DWORD
-    dwPageSize*: DWORD
-    lpMinimumApplicationAddress*: LPVOID
-    lpMaximumApplicationAddress*: LPVOID
-    dwActiveProcessorMask*: DWORD
-    dwNumberOfProcessors*: DWORD
-    dwProcessorType*: DWORD
-    dwAllocationGranularity*: DWORD
-    wProcessorLevel*: int16
-    wProcessorRevision*: int16
-
-  LPSYSTEM_INFO* = ptr SYSTEM_INFO
-  TSYSTEMINFO* = SYSTEM_INFO
-  PSYSTEMINFO* = ptr SYSTEM_INFO
-  SYSTEM_POWER_STATUS* {.final, pure.} = object
-    ACLineStatus*: int8
-    BatteryFlag*: int8
-    BatteryLifePercent*: int8
-    Reserved1*: int8
-    BatteryLifeTime*: DWORD
-    BatteryFullLifeTime*: DWORD
-
-  TSYSTEMPOWERSTATUS* = SYSTEM_POWER_STATUS
-  PSYSTEMPOWERSTATUS* = ptr SYSTEM_POWER_STATUS
-  LPSYSTEM_POWER_STATUS* = ptr emptyrecord
-  TAPE_ERASE* {.final, pure.} = object
-    `type`*: ULONG
-
-  TTAPEERASE* = TAPE_ERASE
-  PTAPEERASE* = ptr TAPE_ERASE
-  TAPE_GET_DRIVE_PARAMETERS* {.final, pure.} = object
-    ECC*: bool
-    Compression*: bool
-    DataPadding*: bool
-    ReportSetmarks*: bool
-    DefaultBlockSize*: ULONG
-    MaximumBlockSize*: ULONG
-    MinimumBlockSize*: ULONG
-    MaximumPartitionCount*: ULONG
-    FeaturesLow*: ULONG
-    FeaturesHigh*: ULONG
-    EOTWarningZoneSize*: ULONG
-
-  TTAPEGETDRIVEPARAMETERS* = TAPE_GET_DRIVE_PARAMETERS
-  PTAPEGETDRIVEPARAMETERS* = ptr TAPE_GET_DRIVE_PARAMETERS
-  TAPE_GET_MEDIA_PARAMETERS* {.final, pure.} = object
-    Capacity*: LARGE_INTEGER
-    Remaining*: LARGE_INTEGER
-    BlockSize*: DWORD
-    PartitionCount*: DWORD
-    WriteProtected*: bool
-
-  TTAPEGETMEDIAPARAMETERS* = TAPE_GET_MEDIA_PARAMETERS
-  PTAPEGETMEDIAPARAMETERS* = ptr TAPE_GET_MEDIA_PARAMETERS
-  TAPE_GET_POSITION* {.final, pure.} = object
-    `type`*: ULONG
-    Partition*: ULONG
-    OffsetLow*: ULONG
-    OffsetHigh*: ULONG
-
-  TTAPEGETPOSITION* = TAPE_GET_POSITION
-  PTAPEGETPOSITION* = ptr TAPE_GET_POSITION
-  TAPE_PREPARE* {.final, pure.} = object
-    Operation*: ULONG
-
-  TTAPEPREPARE* = TAPE_PREPARE
-  PTAPEPREPARE* = ptr TAPE_PREPARE
-  TAPE_SET_DRIVE_PARAMETERS* {.final, pure.} = object
-    ECC*: bool
-    Compression*: bool
-    DataPadding*: bool
-    ReportSetmarks*: bool
-    EOTWarningZoneSize*: ULONG
-
-  TTAPESETDRIVEPARAMETERS* = TAPE_SET_DRIVE_PARAMETERS
-  PTAPESETDRIVEPARAMETERS* = ptr TAPE_SET_DRIVE_PARAMETERS
-  TAPE_SET_MEDIA_PARAMETERS* {.final, pure.} = object
-    BlockSize*: ULONG
-
-  TTAPESETMEDIAPARAMETERS* = TAPE_SET_MEDIA_PARAMETERS
-  PTAPESETMEDIAPARAMETERS* = ptr TAPE_SET_MEDIA_PARAMETERS
-  TAPE_SET_POSITION* {.final, pure.} = object
-    `Method`*: ULONG
-    Partition*: ULONG
-    OffsetLow*: ULONG
-    OffsetHigh*: ULONG
-
-  TTAPESETPOSITION* = TAPE_SET_POSITION
-  PTAPESETPOSITION* = ptr TAPE_SET_POSITION
-  TAPE_WRITE_MARKS* {.final, pure.} = object
-    `type`*: ULONG
-    Count*: ULONG
-
-  TTAPEWRITEMARKS* = TAPE_WRITE_MARKS
-  PTAPEWRITEMARKS* = ptr TAPE_WRITE_MARKS
-  TTBADDBITMAP* {.final, pure.} = object
-    hInst*: HINST
-    nID*: UINT
-
-  LPTBADDBITMAP* = ptr TTBADDBITMAP
-  PTBADDBITMAP* = ptr TTBADDBITMAP
-  TBBUTTON* {.final, pure.} = object
-    iBitmap*: int32
-    idCommand*: int32
-    fsState*: int8
-    fsStyle*: int8
-    dwData*: DWORD
-    iString*: int32
-
-  LPTBBUTTON* = ptr TBBUTTON
-  LPCTBBUTTON* = ptr TBBUTTON
-  TTBBUTTON* = TBBUTTON
-  PTBBUTTON* = ptr TBBUTTON
-  TBNOTIFY* {.final, pure.} = object
-    hdr*: NMHDR
-    iItem*: int32
-    tbButton*: TBBUTTON
-    cchText*: int32
-    pszText*: LPTSTR
-
-  LPTBNOTIFY* = ptr TBNOTIFY
-  TTBNOTIFY* = TBNOTIFY
-  PTBNOTIFY* = ptr TBNOTIFY
-  TBSAVEPARAMS* {.final, pure.} = object
-    hkr*: HKEY
-    pszSubKey*: LPCTSTR
-    pszValueName*: LPCTSTR
-
-  TTBSAVEPARAMS* = TBSAVEPARAMS
-  PTBSAVEPARAMS* = ptr TBSAVEPARAMS
-  TC_HITTESTINFO* {.final, pure.} = object
-    pt*: POINT
-    flags*: UINT
-
-  TTCHITTESTINFO* = TC_HITTESTINFO
-  PTCHITTESTINFO* = ptr TC_HITTESTINFO
-  TC_ITEM* {.final, pure.} = object
-    mask*: UINT
-    lpReserved1*: UINT
-    lpReserved2*: UINT
-    pszText*: LPTSTR
-    cchTextMax*: int32
-    iImage*: int32
-    lParam*: LPARAM
-
-  TTCITEM* = TC_ITEM
-  PTCITEM* = ptr TC_ITEM
-  TC_ITEMHEADER* {.final, pure.} = object
-    mask*: UINT
-    lpReserved1*: UINT
-    lpReserved2*: UINT
-    pszText*: LPTSTR
-    cchTextMax*: int32
-    iImage*: int32
-
-  TTCITEMHEADER* = TC_ITEMHEADER
-  PTCITEMHEADER* = ptr TC_ITEMHEADER
-  TC_KEYDOWN* {.final, pure.} = object
-    hdr*: NMHDR
-    wVKey*: int16
-    flags*: UINT
-
-  TTCKEYDOWN* = TC_KEYDOWN
-  PTCKEYDOWN* = ptr TC_KEYDOWN
-  TEXTRANGE* {.final, pure.} = object
-    chrg*: CHARRANGE
-    lpstrText*: LPSTR
-
-  Ttextrange* = TEXTRANGE
-  Ptextrange* = ptr TEXTRANGE
-  TIME_ZONE_INFORMATION* {.final, pure.} = object
-    Bias*: LONG
-    StandardName*: array[0..31, WCHAR]
-    StandardDate*: SYSTEMTIME
-    StandardBias*: LONG
-    DaylightName*: array[0..31, WCHAR]
-    DaylightDate*: SYSTEMTIME
-    DaylightBias*: LONG
-
-  LPTIME_ZONE_INFORMATION* = ptr TIME_ZONE_INFORMATION
-  TTIMEZONEINFORMATION* = TIME_ZONE_INFORMATION
-  PTIMEZONEINFORMATION* = ptr TIME_ZONE_INFORMATION
-  TOGGLEKEYS* {.final, pure.} = object
-    cbSize*: DWORD
-    dwFlags*: DWORD
-
-  TTOGGLEKEYS* = TOGGLEKEYS
-  PTOGGLEKEYS* = ptr TOGGLEKEYS
-  TTOKEN_SOURCE* {.final, pure.} = object
-    SourceName*: array[0..7, CHAR]
-    SourceIdentifier*: LUID
-
-  PTOKENSOURCE* = ptr TTOKEN_SOURCE
-  TOKEN_CONTROL* {.final, pure.} = object
-    TokenId*: LUID
-    AuthenticationId*: LUID
-    ModifiedId*: LUID
-    TokenSource*: TTOKEN_SOURCE
-
-  TTOKENCONTROL* = TOKEN_CONTROL
-  PTOKENCONTROL* = ptr TOKEN_CONTROL
-  TTOKEN_DEFAULT_DACL* {.final, pure.} = object
-    DefaultDacl*: PACL
-
-  PTOKENDEFAULTDACL* = ptr TTOKEN_DEFAULT_DACL
-  TTOKEN_GROUPS* {.final, pure.} = object
-    GroupCount*: DWORD
-    Groups*: array[0..(ANYSIZE_ARRAY) - 1, SID_AND_ATTRIBUTES]
-
-  LPTOKEN_GROUPS* = ptr TTOKEN_GROUPS
-  PTOKENGROUPS* = ptr TTOKEN_GROUPS
-  TTOKEN_OWNER* {.final, pure.} = object
-    Owner*: PSID
-
-  PTOKENOWNER* = ptr TTOKEN_OWNER
-  TTOKEN_PRIMARY_GROUP* {.final, pure.} = object
-    PrimaryGroup*: PSID
-
-  PTOKENPRIMARYGROUP* = ptr TTOKEN_PRIMARY_GROUP
-  TTOKEN_PRIVILEGES* {.final, pure.} = object
-    PrivilegeCount*: DWORD
-    Privileges*: array[0..(ANYSIZE_ARRAY) - 1, LUID_AND_ATTRIBUTES]
-
-  PTOKEN_PRIVILEGES* = ptr TTOKEN_PRIVILEGES
-  LPTOKEN_PRIVILEGES* = ptr TTOKEN_PRIVILEGES
-  TTOKEN_STATISTICS* {.final, pure.} = object
-    TokenId*: LUID
-    AuthenticationId*: LUID
-    ExpirationTime*: LARGE_INTEGER
-    TokenType*: TTOKEN_TYPE
-    ImpersonationLevel*: SECURITY_IMPERSONATION_LEVEL
-    DynamicCharged*: DWORD
-    DynamicAvailable*: DWORD
-    GroupCount*: DWORD
-    PrivilegeCount*: DWORD
-    ModifiedId*: LUID
-
-  PTOKENSTATISTICS* = ptr TTOKEN_STATISTICS
-  TTOKEN_USER* {.final, pure.} = object
-    User*: SID_AND_ATTRIBUTES
-
-  PTOKENUSER* = ptr TTOKEN_USER
-  TOOLINFO* {.final, pure.} = object
-    cbSize*: UINT
-    uFlags*: UINT
-    hwnd*: HWND
-    uId*: UINT
-    rect*: RECT
-    hinst*: HINST
-    lpszText*: LPTSTR
-
-  LPTOOLINFO* = ptr TOOLINFO
-  TTOOLINFO* = TOOLINFO
-  PTOOLINFO* = ptr TOOLINFO
-  TOOLTIPTEXT* {.final, pure.} = object
-    hdr*: NMHDR
-    lpszText*: LPTSTR
-    szText*: array[0..79, char]
-    hinst*: HINST
-    uFlags*: UINT
-
-  LPTOOLTIPTEXT* = ptr TOOLTIPTEXT
-  TTOOLTIPTEXT* = TOOLTIPTEXT
-  PTOOLTIPTEXT* = ptr TOOLTIPTEXT
-  TPMPARAMS* {.final, pure.} = object
-    cbSize*: UINT
-    rcExclude*: RECT
-
-  LPTPMPARAMS* = ptr TPMPARAMS
-  TTPMPARAMS* = TPMPARAMS
-  PTPMPARAMS* = ptr TPMPARAMS
-  TRANSMIT_FILE_BUFFERS* {.final, pure.} = object
-    Head*: PVOID
-    HeadLength*: DWORD
-    Tail*: PVOID
-    TailLength*: DWORD
-
-  TTRANSMITFILEBUFFERS* = TRANSMIT_FILE_BUFFERS
-  PTRANSMITFILEBUFFERS* = ptr TRANSMIT_FILE_BUFFERS
-  TTHITTESTINFO* {.final, pure.} = object
-    hwnd*: HWND
-    pt*: POINT
-    ti*: TOOLINFO
-
-  LPHITTESTINFO* = ptr TTHITTESTINFO
-  TTTHITTESTINFO* = TTHITTESTINFO
-  PTTHITTESTINFO* = ptr TTHITTESTINFO
-  TTPOLYCURVE* {.final, pure.} = object
-    wType*: int16
-    cpfx*: int16
-    apfx*: array[0..0, POINTFX]
-
-  LPTTPOLYCURVE* = ptr TTPOLYCURVE
-  TTTPOLYCURVE* = TTPOLYCURVE
-  PTTPOLYCURVE* = ptr TTPOLYCURVE
-  TTPOLYGONHEADER* {.final, pure.} = object
-    cb*: DWORD
-    dwType*: DWORD
-    pfxStart*: POINTFX
-
-  LPTTPOLYGONHEADER* = ptr TTPOLYGONHEADER
-  TTTPOLYGONHEADER* = TTPOLYGONHEADER
-  PTTPOLYGONHEADER* = ptr TTPOLYGONHEADER
-  TV_DISPINFO* {.final, pure.} = object
-    hdr*: NMHDR
-    item*: TV_ITEM
-
-  TTVDISPINFO* = TV_DISPINFO
-  PTVDISPINFO* = ptr TV_DISPINFO
-  TV_HITTESTINFO* {.final, pure.} = object
-    pt*: POINT
-    flags*: UINT
-    hItem*: HTREEITEM
-
-  LPTV_HITTESTINFO* = ptr TV_HITTESTINFO
-  TTVHITTESTINFO* = TV_HITTESTINFO
-  PTVHITTESTINFO* = ptr TV_HITTESTINFO
-  TV_INSERTSTRUCT* {.final, pure.} = object
-    hParent*: HTREEITEM
-    hInsertAfter*: HTREEITEM
-    item*: TV_ITEM
-
-  LPTV_INSERTSTRUCT* = ptr TV_INSERTSTRUCT
-  TTVINSERTSTRUCT* = TV_INSERTSTRUCT
-  PTVINSERTSTRUCT* = ptr TV_INSERTSTRUCT
-  TV_KEYDOWN* {.final, pure.} = object
-    hdr*: NMHDR
-    wVKey*: int16
-    flags*: UINT
-
-  TTVKEYDOWN* = TV_KEYDOWN
-  PTVKEYDOWN* = ptr TV_KEYDOWN
-  TV_SORTCB* {.final, pure.} = object
-    hParent*: HTREEITEM
-    lpfnCompare*: PFNTVCOMPARE
-    lParam*: LPARAM
-
-  LPTV_SORTCB* = ptr TV_SORTCB
-  TTVSORTCB* = TV_SORTCB
-  PTVSORTCB* = ptr TV_SORTCB
-  UDACCEL* {.final, pure.} = object
-    nSec*: UINT
-    nInc*: UINT
-
-  TUDACCEL* = UDACCEL
-  PUDACCEL* = ptr UDACCEL
-  UNIVERSAL_NAME_INFO* {.final, pure.} = object
-    lpUniversalName*: LPTSTR
-
-  TUNIVERSALNAMEINFO* = UNIVERSAL_NAME_INFO
-  PUNIVERSALNAMEINFO* = ptr UNIVERSAL_NAME_INFO
-  USEROBJECTFLAGS* {.final, pure.} = object
-    fInherit*: WINBOOL
-    fReserved*: WINBOOL
-    dwFlags*: DWORD
-
-  TUSEROBJECTFLAGS* = USEROBJECTFLAGS
-  PUSEROBJECTFLAGS* = ptr USEROBJECTFLAGS
-  VALENT* {.final, pure.} = object
-    ve_valuename*: LPTSTR
-    ve_valuelen*: DWORD
-    ve_valueptr*: DWORD
-    ve_type*: DWORD
-
-  TVALENT* = VALENT
-  PVALENT* = ptr VALENT
-  value_ent* = VALENT
-  Tvalue_ent* = VALENT
-  Pvalue_ent* = ptr VALENT
-  VERIFY_INFORMATION* {.final, pure.} = object
-    StartingOffset*: LARGE_INTEGER
-    len*: DWORD
-
-  TVERIFYINFORMATION* = VERIFY_INFORMATION
-  PVERIFYINFORMATION* = ptr VERIFY_INFORMATION
-  VS_FIXEDFILEINFO* {.final, pure.} = object
-    dwSignature*: DWORD
-    dwStrucVersion*: DWORD
-    dwFileVersionMS*: DWORD
-    dwFileVersionLS*: DWORD
-    dwProductVersionMS*: DWORD
-    dwProductVersionLS*: DWORD
-    dwFileFlagsMask*: DWORD
-    dwFileFlags*: DWORD
-    dwFileOS*: DWORD
-    dwFileType*: DWORD
-    dwFileSubtype*: DWORD
-    dwFileDateMS*: DWORD
-    dwFileDateLS*: DWORD
-
-  TVSFIXEDFILEINFO* = VS_FIXEDFILEINFO
-  PVSFIXEDFILEINFO* = ptr VS_FIXEDFILEINFO
-  WIN32_FIND_DATA* {.final, pure.} = object
-    dwFileAttributes*: DWORD
-    ftCreationTime*: FILETIME
-    ftLastAccessTime*: FILETIME
-    ftLastWriteTime*: FILETIME
-    nFileSizeHigh*: DWORD
-    nFileSizeLow*: DWORD
-    dwReserved0*: DWORD
-    dwReserved1*: DWORD
-    cFileName*: array[0..(MAX_PATH) - 1, TCHAR]
-    cAlternateFileName*: array[0..13, TCHAR]
-
-  LPWIN32_FIND_DATA* = ptr WIN32_FIND_DATA
-  PWIN32_FIND_DATA* = ptr WIN32_FIND_DATA
-  TWIN32FINDDATA* = WIN32_FIND_DATA
-  TWIN32FINDDATAA* = WIN32_FIND_DATA
-  WIN32_FIND_DATAW* {.final, pure.} = object
-    dwFileAttributes*: DWORD
-    ftCreationTime*: FILETIME
-    ftLastAccessTime*: FILETIME
-    ftLastWriteTime*: FILETIME
-    nFileSizeHigh*: DWORD
-    nFileSizeLow*: DWORD
-    dwReserved0*: DWORD
-    dwReserved1*: DWORD
-    cFileName*: array[0..(MAX_PATH) - 1, WCHAR]
-    cAlternateFileName*: array[0..13, WCHAR]
-
-  LPWIN32_FIND_DATAW* = ptr WIN32_FIND_DATAW
-  PWIN32_FIND_DATAW* = ptr WIN32_FIND_DATAW
-  TWIN32FINDDATAW* = WIN32_FIND_DATAW
-  WIN32_STREAM_ID* {.final, pure.} = object
-    dwStreamId*: DWORD
-    dwStreamAttributes*: DWORD
-    Size*: LARGE_INTEGER
-    dwStreamNameSize*: DWORD
-    cStreamName*: ptr WCHAR
-
-  TWIN32STREAMID* = WIN32_STREAM_ID
-  PWIN32STREAMID* = ptr WIN32_STREAM_ID
-  WINDOWPLACEMENT* {.final, pure.} = object
-    len*: UINT
-    flags*: UINT
-    showCmd*: UINT
-    ptMinPosition*: POINT
-    ptMaxPosition*: POINT
-    rcNormalPosition*: RECT
-
-  TWINDOWPLACEMENT* = WINDOWPLACEMENT
-  PWINDOWPLACEMENT* = ptr WINDOWPLACEMENT
-  WNDCLASS* {.final, pure.} = object
-    style*: UINT
-    lpfnWndProc*: WNDPROC
-    cbClsExtra*: int32
-    cbWndExtra*: int32
-    hInstance*: HANDLE
-    hIcon*: HICON
-    hCursor*: HCURSOR
-    hbrBackground*: HBRUSH
-    lpszMenuName*: LPCTSTR
-    lpszClassName*: LPCTSTR
-
-  LPWNDCLASS* = ptr WNDCLASS
-  TWNDCLASS* = WNDCLASS
-  TWNDCLASSA* = WNDCLASS
-  PWNDCLASS* = ptr WNDCLASS
-  WNDCLASSW* {.final, pure.} = object
-    style*: UINT
-    lpfnWndProc*: WNDPROC
-    cbClsExtra*: int32
-    cbWndExtra*: int32
-    hInstance*: HANDLE
-    hIcon*: HICON
-    hCursor*: HCURSOR
-    hbrBackground*: HBRUSH
-    lpszMenuName*: LPCWSTR
-    lpszClassName*: LPCWSTR
-
-  LPWNDCLASSW* = ptr WNDCLASSW
-  TWNDCLASSW* = WNDCLASSW
-  PWNDCLASSW* = ptr WNDCLASSW
-  WNDCLASSEX* {.final, pure.} = object
-    cbSize*: UINT
-    style*: UINT
-    lpfnWndProc*: WNDPROC
-    cbClsExtra*: int32
-    cbWndExtra*: int32
-    hInstance*: HANDLE
-    hIcon*: HICON
-    hCursor*: HCURSOR
-    hbrBackground*: HBRUSH
-    lpszMenuName*: LPCTSTR
-    lpszClassName*: LPCTSTR
-    hIconSm*: HANDLE
-
-  LPWNDCLASSEX* = ptr WNDCLASSEX
-  TWNDCLASSEX* = WNDCLASSEX
-  TWNDCLASSEXA* = WNDCLASSEX
-  PWNDCLASSEX* = ptr WNDCLASSEX
-  WNDCLASSEXW* {.final, pure.} = object
-    cbSize*: UINT
-    style*: UINT
-    lpfnWndProc*: WNDPROC
-    cbClsExtra*: int32
-    cbWndExtra*: int32
-    hInstance*: HANDLE
-    hIcon*: HICON
-    hCursor*: HCURSOR
-    hbrBackground*: HBRUSH
-    lpszMenuName*: LPCWSTR
-    lpszClassName*: LPCWSTR
-    hIconSm*: HANDLE
-
-  LPWNDCLASSEXW* = ptr WNDCLASSEXW
-  TWNDCLASSEXW* = WNDCLASSEXW
-  PWNDCLASSEXW* = ptr WNDCLASSEXW
-  CONNECTDLGSTRUCT* {.final, pure.} = object
-    cbStructure*: DWORD
-    hwndOwner*: HWND
-    lpConnRes*: LPNETRESOURCE
-    dwFlags*: DWORD
-    dwDevNum*: DWORD
-
-  LPCONNECTDLGSTRUCT* = ptr CONNECTDLGSTRUCT
-  TCONNECTDLGSTRUCT* = CONNECTDLGSTRUCT
-  PCONNECTDLGSTRUCT* = ptr CONNECTDLGSTRUCT
-  DISCDLGSTRUCT* {.final, pure.} = object
-    cbStructure*: DWORD
-    hwndOwner*: HWND
-    lpLocalName*: LPTSTR
-    lpRemoteName*: LPTSTR
-    dwFlags*: DWORD
-
-  LPDISCDLGSTRUCT* = ptr DISCDLGSTRUCT
-  TDISCDLGSTRUCT* = DISCDLGSTRUCT
-  TDISCDLGSTRUCTA* = DISCDLGSTRUCT
-  PDISCDLGSTRUCT* = ptr DISCDLGSTRUCT
-  NETINFOSTRUCT* {.final, pure.} = object
-    cbStructure*: DWORD
-    dwProviderVersion*: DWORD
-    dwStatus*: DWORD
-    dwCharacteristics*: DWORD
-    dwHandle*: DWORD
-    wNetType*: int16
-    dwPrinters*: DWORD
-    dwDrives*: DWORD
-
-  LPNETINFOSTRUCT* = ptr NETINFOSTRUCT
-  TNETINFOSTRUCT* = NETINFOSTRUCT
-  PNETINFOSTRUCT* = ptr NETINFOSTRUCT
-  NETCONNECTINFOSTRUCT* {.final, pure.} = object
-    cbStructure*: DWORD
-    dwFlags*: DWORD
-    dwSpeed*: DWORD
-    dwDelay*: DWORD
-    dwOptDataSize*: DWORD
-
-  LPNETCONNECTINFOSTRUCT* = ptr NETCONNECTINFOSTRUCT
-  TNETCONNECTINFOSTRUCT* = NETCONNECTINFOSTRUCT
-  PNETCONNECTINFOSTRUCT* = ptr NETCONNECTINFOSTRUCT
-  ENUMMETAFILEPROC* = proc (para1: HDC, para2: HANDLETABLE, para3: METARECORD,
-                            para4: int32, para5: LPARAM): int32{.stdcall.}
-  ENHMETAFILEPROC* = proc (para1: HDC, para2: HANDLETABLE, para3: TENHMETARECORD,
-                           para4: int32, para5: LPARAM): int32{.stdcall.}
-  ENUMFONTSPROC* = proc (para1: LPLOGFONT, para2: LPTEXTMETRIC, para3: DWORD,
-                         para4: LPARAM): int32{.stdcall.}
-  FONTENUMPROC* = proc (para1: var ENUMLOGFONT, para2: var NEWTEXTMETRIC,
-                        para3: int32, para4: LPARAM): int32{.stdcall.}
-  FONTENUMEXPROC* = proc (para1: var ENUMLOGFONTEX, para2: var NEWTEXTMETRICEX,
-                          para3: int32, para4: LPARAM): int32{.stdcall.}
-  LPOVERLAPPED_COMPLETION_ROUTINE* = proc (para1: DWORD, para2: DWORD,
-      para3: LPOVERLAPPED){.stdcall.} # Structures for the extensions to OpenGL
-  POINTFLOAT* {.final, pure.} = object
-    x*: float32
-    y*: float32
-
-  TPOINTFLOAT* = POINTFLOAT
-  PPOINTFLOAT* = ptr POINTFLOAT
-  GLYPHMETRICSFLOAT* {.final, pure.} = object
-    gmfBlackBoxX*: float32
-    gmfBlackBoxY*: float32
-    gmfptGlyphOrigin*: POINTFLOAT
-    gmfCellIncX*: float32
-    gmfCellIncY*: float32
-
-  LPGLYPHMETRICSFLOAT* = ptr GLYPHMETRICSFLOAT
-  TGLYPHMETRICSFLOAT* = GLYPHMETRICSFLOAT
-  PGLYPHMETRICSFLOAT* = ptr GLYPHMETRICSFLOAT
-  LAYERPLANEDESCRIPTOR* {.final, pure.} = object
-    nSize*: int16
-    nVersion*: int16
-    dwFlags*: DWORD
-    iPixelType*: int8
-    cColorBits*: int8
-    cRedBits*: int8
-    cRedShift*: int8
-    cGreenBits*: int8
-    cGreenShift*: int8
-    cBlueBits*: int8
-    cBlueShift*: int8
-    cAlphaBits*: int8
-    cAlphaShift*: int8
-    cAccumBits*: int8
-    cAccumRedBits*: int8
-    cAccumGreenBits*: int8
-    cAccumBlueBits*: int8
-    cAccumAlphaBits*: int8
-    cDepthBits*: int8
-    cStencilBits*: int8
-    cAuxBuffers*: int8
-    iLayerPlane*: int8
-    bReserved*: int8
-    crTransparent*: COLORREF
-
-  LPLAYERPLANEDESCRIPTOR* = ptr LAYERPLANEDESCRIPTOR
-  TLAYERPLANEDESCRIPTOR* = LAYERPLANEDESCRIPTOR
-  PLAYERPLANEDESCRIPTOR* = ptr LAYERPLANEDESCRIPTOR
-  PIXELFORMATDESCRIPTOR* {.final, pure.} = object
-    nSize*: int16
-    nVersion*: int16
-    dwFlags*: DWORD
-    iPixelType*: int8
-    cColorBits*: int8
-    cRedBits*: int8
-    cRedShift*: int8
-    cGreenBits*: int8
-    cGreenShift*: int8
-    cBlueBits*: int8
-    cBlueShift*: int8
-    cAlphaBits*: int8
-    cAlphaShift*: int8
-    cAccumBits*: int8
-    cAccumRedBits*: int8
-    cAccumGreenBits*: int8
-    cAccumBlueBits*: int8
-    cAccumAlphaBits*: int8
-    cDepthBits*: int8
-    cStencilBits*: int8
-    cAuxBuffers*: int8
-    iLayerType*: int8
-    bReserved*: int8
-    dwLayerMask*: DWORD
-    dwVisibleMask*: DWORD
-    dwDamageMask*: DWORD
-
-  LPPIXELFORMATDESCRIPTOR* = ptr PIXELFORMATDESCRIPTOR
-  TPIXELFORMATDESCRIPTOR* = PIXELFORMATDESCRIPTOR
-  PPIXELFORMATDESCRIPTOR* = ptr PIXELFORMATDESCRIPTOR
-  USER_INFO_2* {.final, pure.} = object
-    usri2_name*: LPWSTR
-    usri2_password*: LPWSTR
-    usri2_password_age*: DWORD
-    usri2_priv*: DWORD
-    usri2_home_dir*: LPWSTR
-    usri2_comment*: LPWSTR
-    usri2_flags*: DWORD
-    usri2_script_path*: LPWSTR
-    usri2_auth_flags*: DWORD
-    usri2_full_name*: LPWSTR
-    usri2_usr_comment*: LPWSTR
-    usri2_parms*: LPWSTR
-    usri2_workstations*: LPWSTR
-    usri2_last_logon*: DWORD
-    usri2_last_logoff*: DWORD
-    usri2_acct_expires*: DWORD
-    usri2_max_storage*: DWORD
-    usri2_units_per_week*: DWORD
-    usri2_logon_hours*: PBYTE
-    usri2_bad_pw_count*: DWORD
-    usri2_num_logons*: DWORD
-    usri2_logon_server*: LPWSTR
-    usri2_country_code*: DWORD
-    usri2_code_page*: DWORD
-
-  PUSER_INFO_2* = ptr USER_INFO_2
-  LPUSER_INFO_2* = ptr USER_INFO_2
-  TUSERINFO2* = USER_INFO_2
-  USER_INFO_0* {.final, pure.} = object
-    usri0_name*: LPWSTR
-
-  PUSER_INFO_0* = ptr USER_INFO_0
-  LPUSER_INFO_0* = ptr USER_INFO_0
-  TUSERINFO0* = USER_INFO_0
-  USER_INFO_3* {.final, pure.} = object
-    usri3_name*: LPWSTR
-    usri3_password*: LPWSTR
-    usri3_password_age*: DWORD
-    usri3_priv*: DWORD
-    usri3_home_dir*: LPWSTR
-    usri3_comment*: LPWSTR
-    usri3_flags*: DWORD
-    usri3_script_path*: LPWSTR
-    usri3_auth_flags*: DWORD
-    usri3_full_name*: LPWSTR
-    usri3_usr_comment*: LPWSTR
-    usri3_parms*: LPWSTR
-    usri3_workstations*: LPWSTR
-    usri3_last_logon*: DWORD
-    usri3_last_logoff*: DWORD
-    usri3_acct_expires*: DWORD
-    usri3_max_storage*: DWORD
-    usri3_units_per_week*: DWORD
-    usri3_logon_hours*: PBYTE
-    usri3_bad_pw_count*: DWORD
-    usri3_num_logons*: DWORD
-    usri3_logon_server*: LPWSTR
-    usri3_country_code*: DWORD
-    usri3_code_page*: DWORD
-    usri3_user_id*: DWORD
-    usri3_primary_group_id*: DWORD
-    usri3_profile*: LPWSTR
-    usri3_home_dir_drive*: LPWSTR
-    usri3_password_expired*: DWORD
-
-  PUSER_INFO_3* = ptr USER_INFO_3
-  LPUSER_INFO_3* = ptr USER_INFO_3
-  TUSERINFO3* = USER_INFO_3
-  GROUP_INFO_2* {.final, pure.} = object
-    grpi2_name*: LPWSTR
-    grpi2_comment*: LPWSTR
-    grpi2_group_id*: DWORD
-    grpi2_attributes*: DWORD
-
-  PGROUP_INFO_2* = ptr GROUP_INFO_2
-  TGROUPINFO2* = GROUP_INFO_2
-  LOCALGROUP_INFO_0* {.final, pure.} = object
-    lgrpi0_name*: LPWSTR
-
-  PLOCALGROUP_INFO_0* = ptr LOCALGROUP_INFO_0
-  LPLOCALGROUP_INFO_0* = ptr LOCALGROUP_INFO_0
-  TLOCALGROUPINFO0* = LOCALGROUP_INFO_0
-  IMAGE_DOS_HEADER* {.final, pure.} = object
-    e_magic*: int16
-    e_cblp*: int16
-    e_cp*: int16
-    e_crlc*: int16
-    e_cparhdr*: int16
-    e_minalloc*: int16
-    e_maxalloc*: int16
-    e_ss*: int16
-    e_sp*: int16
-    e_csum*: int16
-    e_ip*: int16
-    e_cs*: int16
-    e_lfarlc*: int16
-    e_ovno*: int16
-    e_res*: array[0..3, int16]
-    e_oemid*: int16
-    e_oeminfo*: int16
-    e_res2*: array[0..9, int16]
-    e_lfanew*: LONG
-
-  PIMAGE_DOS_HEADER* = ptr IMAGE_DOS_HEADER
-  TIMAGEDOSHEADER* = IMAGE_DOS_HEADER
-  NOTIFYICONDATAA* {.final, pure.} = object
-    cbSize*: DWORD
-    Wnd*: HWND
-    uID*: UINT
-    uFlags*: UINT
-    uCallbackMessage*: UINT
-    hIcon*: HICON
-    szTip*: array[0..63, Char]
-
-  NOTIFYICONDATA* = NOTIFYICONDATAA
-  NOTIFYICONDATAW* {.final, pure.} = object
-    cbSize*: DWORD
-    Wnd*: HWND
-    uID*: UINT
-    uFlags*: UINT
-    uCallbackMessage*: UINT
-    hIcon*: HICON
-    szTip*: array[0..63, int16]
-
-  TNotifyIconDataA* = NOTIFYICONDATAA
-  TNotifyIconDataW* = NOTIFYICONDATAW
-  TNotifyIconData* = TNotifyIconDataA
-  PNotifyIconDataA* = ptr TNotifyIconDataA
-  PNotifyIconDataW* = ptr TNotifyIconDataW
-  PNotifyIconData* = PNotifyIconDataA
-  TWOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, HANDLE]
-  PWOHandleArray* = ptr TWOHandleArray
-  MMRESULT* = int32
-
-type
-  PWaveFormatEx* = ptr TWaveFormatEx
-  TWaveFormatEx* {.final, pure.} = object
-    wFormatTag*: int16        # format type
-    nChannels*: int16         # number of channels (i.e. mono, stereo, etc.)
-    nSamplesPerSec*: DWORD    # sample rate
-    nAvgBytesPerSec*: DWORD   # for buffer estimation
-    nBlockAlign*: int16       # block size of data
-    wBitsPerSample*: int16    # number of bits per sample of mono data
-    cbSize*: int16            # the count in bytes of the size of
-
-  WIN32_FILE_ATTRIBUTE_DATA* {.final, pure.} = object
-    dwFileAttributes*: DWORD
-    ftCreationTime*: FILETIME
-    ftLastAccessTime*: FILETIME
-    ftLastWriteTime*: FILETIME
-    nFileSizeHigh*: DWORD
-    nFileSizeLow*: DWORD
-
-  LPWIN32_FILE_ATTRIBUTE_DATA* = ptr WIN32_FILE_ATTRIBUTE_DATA
-  TWIN32FILEATTRIBUTEDATA* = WIN32_FILE_ATTRIBUTE_DATA
-  PWIN32FILEATTRIBUTEDATA* = ptr WIN32_FILE_ATTRIBUTE_DATA # TrackMouseEvent. NT or higher only.
-  TTrackMouseEvent* {.final, pure.} = object
-    cbSize*: DWORD
-    dwFlags*: DWORD
-    hwndTrack*: HWND
-    dwHoverTime*: DWORD
-
-  PTrackMouseEvent* = ptr TTrackMouseEvent
-
-const
-  ACM_OPENW* = 1127
-  ACM_OPENA* = 1124
-
-when defined(winUnicode):
-  const
-    ACM_OPEN* = ACM_OPENW
-else:
-  const
-    ACM_OPEN* = ACM_OPENA
-# UNICODE
-
-const
-  ACM_PLAY* = 1125
-  ACM_STOP* = 1126
-  ACN_START* = 1
-  ACN_STOP* = 2               # Buttons
-  BM_CLICK* = 245
-  BM_GETCHECK* = 240
-  BM_GETIMAGE* = 246
-  BM_GETSTATE* = 242
-  BM_SETCHECK* = 241
-  BM_SETIMAGE* = 247
-  BM_SETSTATE* = 243
-  BM_SETSTYLE* = 244
-  BN_CLICKED* = 0
-  BN_DBLCLK* = 5
-  BN_DISABLE* = 4
-  BN_DOUBLECLICKED* = 5
-  BN_HILITE* = 2
-  BN_KILLFOCUS* = 7
-  BN_PAINT* = 1
-  BN_PUSHED* = 2
-  BN_SETFOCUS* = 6
-  BN_UNHILITE* = 3
-  BN_UNPUSHED* = 3            # Combo Box
-  CB_ADDSTRING* = 323
-  CB_DELETESTRING* = 324
-  CB_DIR* = 325
-  CB_FINDSTRING* = 332
-  CB_FINDSTRINGEXACT* = 344
-  CB_GETCOUNT* = 326
-  CB_GETCURSEL* = 327
-  CB_GETDROPPEDCONTROLRECT* = 338
-  CB_GETDROPPEDSTATE* = 343
-  CB_GETDROPPEDWIDTH* = 351
-  CB_GETEDITSEL* = 320
-  CB_GETEXTENDEDUI* = 342
-  CB_GETHORIZONTALEXTENT* = 349
-  CB_GETITEMDATA* = 336
-  CB_GETITEMHEIGHT* = 340
-  CB_GETLBTEXT* = 328
-  CB_GETLBTEXTLEN* = 329
-  CB_GETLOCALE* = 346
-  CB_GETTOPINDEX* = 347
-  CB_INITSTORAGE* = 353
-  CB_INSERTSTRING* = 330
-  CB_LIMITTEXT* = 321
-  CB_RESETCONTENT* = 331
-  CB_SELECTSTRING* = 333
-  CB_SETCURSEL* = 334
-  CB_SETDROPPEDWIDTH* = 352
-  CB_SETEDITSEL* = 322
-  CB_SETEXTENDEDUI* = 341
-  CB_SETHORIZONTALEXTENT* = 350
-  CB_SETITEMDATA* = 337
-  CB_SETITEMHEIGHT* = 339
-  CB_SETLOCALE* = 345
-  CB_SETTOPINDEX* = 348
-  CB_SHOWDROPDOWN* = 335      # Combo Box notifications
-  CBN_CLOSEUP* = 8
-  CBN_DBLCLK* = 2
-  CBN_DROPDOWN* = 7
-  CBN_EDITCHANGE* = 5
-  CBN_EDITUPDATE* = 6
-  CBN_ERRSPACE* = - (1)
-  CBN_KILLFOCUS* = 4
-  CBN_SELCHANGE* = 1
-  CBN_SELENDCANCEL* = 10
-  CBN_SELENDOK* = 9
-  CBN_SETFOCUS* = 3           # Control Panel
-                              # Device messages
-                              # Drag list box
-  DL_BEGINDRAG* = 1157
-  DL_CANCELDRAG* = 1160
-  DL_DRAGGING* = 1158
-  DL_DROPPED* = 1159          # Default push button
-  DM_GETDEFID* = 1024
-  DM_REPOSITION* = 1026
-  DM_SETDEFID* = 1025         # RTF control
-  EM_CANPASTE* = 1074
-  EM_CANUNDO* = 198
-  EM_CHARFROMPOS* = 215
-  EM_DISPLAYBAND* = 1075
-  EM_EMPTYUNDOBUFFER* = 205
-  EM_EXGETSEL* = 1076
-  EM_EXLIMITTEXT* = 1077
-  EM_EXLINEFROMCHAR* = 1078
-  EM_EXSETSEL* = 1079
-  EM_FINDTEXT* = 1080
-  EM_FINDTEXTEX* = 1103
-  EM_FINDWORDBREAK* = 1100
-  EM_FMTLINES* = 200
-  EM_FORMATRANGE* = 1081
-  EM_GETCHARFORMAT* = 1082
-  EM_GETEVENTMASK* = 1083
-  EM_GETFIRSTVISIBLELINE* = 206
-  EM_GETHANDLE* = 189
-  EM_GETLIMITTEXT* = 213
-  EM_GETLINE* = 196
-  EM_GETLINECOUNT* = 186
-  EM_GETMARGINS* = 212
-  EM_GETMODIFY* = 184
-  EM_GETIMECOLOR* = 1129
-  EM_GETIMEOPTIONS* = 1131
-  EM_GETOPTIONS* = 1102
-  EM_GETOLEINTERFACE* = 1084
-  EM_GETPARAFORMAT* = 1085
-  EM_GETPASSWORDCHAR* = 210
-  EM_GETPUNCTUATION* = 1125
-  EM_GETRECT* = 178
-  EM_GETSEL* = 176
-  EM_GETSELTEXT* = 1086
-  EM_GETTEXTRANGE* = 1099
-  EM_GETTHUMB* = 190
-  EM_GETWORDBREAKPROC* = 209
-  EM_GETWORDBREAKPROCEX* = 1104
-  EM_GETWORDWRAPMODE* = 1127
-  EM_HIDESELECTION* = 1087
-  EM_LIMITTEXT* = 197
-  EM_LINEFROMCHAR* = 201
-  EM_LINEINDEX* = 187
-  EM_LINELENGTH* = 193
-  EM_LINESCROLL* = 182
-  EM_PASTESPECIAL* = 1088
-  EM_POSFROMCHAR* = 214
-  EM_REPLACESEL* = 194
-  EM_REQUESTRESIZE* = 1089
-  EM_SCROLL* = 181
-  EM_SCROLLCARET* = 183
-  EM_SELECTIONTYPE* = 1090
-  EM_SETBKGNDCOLOR* = 1091
-  EM_SETCHARFORMAT* = 1092
-  EM_SETEVENTMASK* = 1093
-  EM_SETHANDLE* = 188
-  EM_SETIMECOLOR* = 1128
-  EM_SETIMEOPTIONS* = 1130
-  EM_SETLIMITTEXT* = 197
-  EM_SETMARGINS* = 211
-  EM_SETMODIFY* = 185
-  EM_SETOLECALLBACK* = 1094
-  EM_SETOPTIONS* = 1101
-  EM_SETPARAFORMAT* = 1095
-  EM_SETPASSWORDCHAR* = 204
-  EM_SETPUNCTUATION* = 1124
-  EM_SETREADONLY* = 207
-  EM_SETRECT* = 179
-  EM_SETRECTNP* = 180
-  EM_SETSEL* = 177
-  EM_SETTABSTOPS* = 203
-  EM_SETTARGETDEVICE* = 1096
-  EM_SETWORDBREAKPROC* = 208
-  EM_SETWORDBREAKPROCEX* = 1105
-  EM_SETWORDWRAPMODE* = 1126
-  EM_STREAMIN* = 1097
-  EM_STREAMOUT* = 1098
-  EM_UNDO* = 199              # Edit control
-  EN_CHANGE* = 768
-  EN_CORRECTTEXT* = 1797
-  EN_DROPFILES* = 1795
-  EN_ERRSPACE* = 1280
-  EN_HSCROLL* = 1537
-  EN_IMECHANGE* = 1799
-  EN_KILLFOCUS* = 512
-  EN_MAXTEXT* = 1281
-  EN_MSGFILTER* = 1792
-  EN_OLEOPFAILED* = 1801
-  EN_PROTECTED* = 1796
-  EN_REQUESTRESIZE* = 1793
-  EN_SAVECLIPBOARD* = 1800
-  EN_SELCHANGE* = 1794
-  EN_SETFOCUS* = 256
-  EN_STOPNOUNDO* = 1798
-  EN_UPDATE* = 1024
-  EN_VSCROLL* = 1538          # File Manager extensions
-                              # File Manager extensions DLL events
-                              # Header control
-  HDM_DELETEITEM* = 4610
-  HDM_GETITEMW* = 4619
-  HDM_INSERTITEMW* = 4618
-  HDM_SETITEMW* = 4620
-  HDM_GETITEMA* = 4611
-  HDM_INSERTITEMA* = 4609
-  HDM_SETITEMA* = 4612
-
-when defined(winUnicode):
-  const
-    HDM_GETITEM* = HDM_GETITEMW
-    HDM_INSERTITEM* = HDM_INSERTITEMW
-    HDM_SETITEM* = HDM_SETITEMW
-else:
-  const
-    HDM_GETITEM* = HDM_GETITEMA
-    HDM_INSERTITEM* = HDM_INSERTITEMA
-    HDM_SETITEM* = HDM_SETITEMA
-# UNICODE
-
-const
-  HDM_GETITEMCOUNT* = 4608
-  HDM_HITTEST* = 4614
-  HDM_LAYOUT* = 4613          # Header control notifications
-  HDN_BEGINTRACKW* = - (326)
-  HDN_DIVIDERDBLCLICKW* = - (325)
-  HDN_ENDTRACKW* = - (327)
-  HDN_ITEMCHANGEDW* = - (321)
-  HDN_ITEMCHANGINGW* = - (320)
-  HDN_ITEMCLICKW* = - (322)
-  HDN_ITEMDBLCLICKW* = - (323)
-  HDN_TRACKW* = - (328)
-  HDN_BEGINTRACKA* = - (306)
-  HDN_DIVIDERDBLCLICKA* = - (305)
-  HDN_ENDTRACKA* = - (307)
-  HDN_ITEMCHANGEDA* = - (301)
-  HDN_ITEMCHANGINGA* = - (300)
-  HDN_ITEMCLICKA* = - (302)
-  HDN_ITEMDBLCLICKA* = - (303)
-  HDN_TRACKA* = - (308)
-
-when defined(winUnicode):
-  const
-    HDN_BEGINTRACK* = HDN_BEGINTRACKW
-    HDN_DIVIDERDBLCLICK* = HDN_DIVIDERDBLCLICKW
-    HDN_ENDTRACK* = HDN_ENDTRACKW
-    HDN_ITEMCHANGED* = HDN_ITEMCHANGEDW
-    HDN_ITEMCHANGING* = HDN_ITEMCHANGINGW
-    HDN_ITEMCLICK* = HDN_ITEMCLICKW
-    HDN_ITEMDBLCLICK* = HDN_ITEMDBLCLICKW
-    HDN_TRACK* = HDN_TRACKW
-else:
-  const
-    HDN_BEGINTRACK* = HDN_BEGINTRACKA
-    HDN_DIVIDERDBLCLICK* = HDN_DIVIDERDBLCLICKA
-    HDN_ENDTRACK* = HDN_ENDTRACKA
-    HDN_ITEMCHANGED* = HDN_ITEMCHANGEDA
-    HDN_ITEMCHANGING* = HDN_ITEMCHANGINGA
-    HDN_ITEMCLICK* = HDN_ITEMCLICKA
-    HDN_ITEMDBLCLICK* = HDN_ITEMDBLCLICKA
-    HDN_TRACK* = HDN_TRACKA
-# UNICODE
-# Hot key control
-
-const
-  HKM_GETHOTKEY* = 1026
-  HKM_SETHOTKEY* = 1025
-  HKM_SETRULES* = 1027        # List box
-  LB_ADDFILE* = 406
-  LB_ADDSTRING* = 384
-  LB_DELETESTRING* = 386
-  LB_DIR* = 397
-  LB_FINDSTRING* = 399
-  LB_FINDSTRINGEXACT* = 418
-  LB_GETANCHORINDEX* = 413
-  LB_GETCARETINDEX* = 415
-  LB_GETCOUNT* = 395
-  LB_GETCURSEL* = 392
-  LB_GETHORIZONTALEXTENT* = 403
-  LB_GETITEMDATA* = 409
-  LB_GETITEMHEIGHT* = 417
-  LB_GETITEMRECT* = 408
-  LB_GETLOCALE* = 422
-  LB_GETSEL* = 391
-  LB_GETSELCOUNT* = 400
-  LB_GETSELITEMS* = 401
-  LB_GETTEXT* = 393
-  LB_GETTEXTLEN* = 394
-  LB_GETTOPINDEX* = 398
-  LB_INITSTORAGE* = 424
-  LB_INSERTSTRING* = 385
-  LB_ITEMFROMPOINT* = 425
-  LB_RESETCONTENT* = 388
-  LB_SELECTSTRING* = 396
-  LB_SELITEMRANGE* = 411
-  LB_SELITEMRANGEEX* = 387
-  LB_SETANCHORINDEX* = 412
-  LB_SETCARETINDEX* = 414
-  LB_SETCOLUMNWIDTH* = 405
-  LB_SETCOUNT* = 423
-  LB_SETCURSEL* = 390
-  LB_SETHORIZONTALEXTENT* = 404
-  LB_SETITEMDATA* = 410
-  LB_SETITEMHEIGHT* = 416
-  LB_SETLOCALE* = 421
-  LB_SETSEL* = 389
-  LB_SETTABSTOPS* = 402
-  LB_SETTOPINDEX* = 407       # List box notifications
-  LBN_DBLCLK* = 2
-  LBN_ERRSPACE* = - (2)
-  LBN_KILLFOCUS* = 5
-  LBN_SELCANCEL* = 3
-  LBN_SELCHANGE* = 1
-  LBN_SETFOCUS* = 4           # List view control
-  LVM_ARRANGE* = 4118
-  LVM_CREATEDRAGIMAGE* = 4129
-  LVM_DELETEALLITEMS* = 4105
-  LVM_DELETECOLUMN* = 4124
-  LVM_DELETEITEM* = 4104
-  LVM_ENSUREVISIBLE* = 4115
-  LVM_GETBKCOLOR* = 4096
-  LVM_GETCALLBACKMASK* = 4106
-  LVM_GETCOLUMNWIDTH* = 4125
-  LVM_GETCOUNTPERPAGE* = 4136
-  LVM_GETEDITCONTROL* = 4120
-  LVM_GETIMAGELIST* = 4098
-  LVM_EDITLABELW* = 4214
-  LVM_FINDITEMW* = 4179
-  LVM_GETCOLUMNW* = 4191
-  LVM_GETISEARCHSTRINGW* = 4213
-  LVM_GETITEMW* = 4171
-  LVM_GETITEMTEXTW* = 4211
-  LVM_GETSTRINGWIDTHW* = 4183
-  LVM_INSERTCOLUMNW* = 4193
-  LVM_INSERTITEMW* = 4173
-  LVM_SETCOLUMNW* = 4192
-  LVM_SETITEMW* = 4172
-  LVM_SETITEMTEXTW* = 4212
-  LVM_EDITLABELA* = 4119
-  LVM_FINDITEMA* = 4109
-  LVM_GETCOLUMNA* = 4121
-  LVM_GETISEARCHSTRINGA* = 4148
-  LVM_GETITEMA* = 4101
-  LVM_GETITEMTEXTA* = 4141
-  LVM_GETSTRINGWIDTHA* = 4113
-  LVM_INSERTCOLUMNA* = 4123
-  LVM_INSERTITEMA* = 4103
-  LVM_SETCOLUMNA* = 4122
-  LVM_SETITEMA* = 4102
-  LVM_SETITEMTEXTA* = 4142
-
-when defined(winUnicode):
-  const
-    LVM_EDITLABEL* = LVM_EDITLABELW
-    LVM_FINDITEM* = LVM_FINDITEMW
-    LVM_GETCOLUMN* = LVM_GETCOLUMNW
-    LVM_GETISEARCHSTRING* = LVM_GETISEARCHSTRINGW
-    LVM_GETITEM* = LVM_GETITEMW
-    LVM_GETITEMTEXT* = LVM_GETITEMTEXTW
-    LVM_GETSTRINGWIDTH* = LVM_GETSTRINGWIDTHW
-    LVM_INSERTCOLUMN* = LVM_INSERTCOLUMNW
-    LVM_INSERTITEM* = LVM_INSERTITEMW
-    LVM_SETCOLUMN* = LVM_SETCOLUMNW
-    LVM_SETITEM* = LVM_SETITEMW
-    LVM_SETITEMTEXT* = LVM_SETITEMTEXTW
-else:
-  const
-    LVM_EDITLABEL* = LVM_EDITLABELA
-    LVM_FINDITEM* = LVM_FINDITEMA
-    LVM_GETCOLUMN* = LVM_GETCOLUMNA
-    LVM_GETISEARCHSTRING* = LVM_GETISEARCHSTRINGA
-    LVM_GETITEM* = LVM_GETITEMA
-    LVM_GETITEMTEXT* = LVM_GETITEMTEXTA
-    LVM_GETSTRINGWIDTH* = LVM_GETSTRINGWIDTHA
-    LVM_INSERTCOLUMN* = LVM_INSERTCOLUMNA
-    LVM_INSERTITEM* = LVM_INSERTITEMA
-    LVM_SETCOLUMN* = LVM_SETCOLUMNA
-    LVM_SETITEM* = LVM_SETITEMA
-    LVM_SETITEMTEXT* = LVM_SETITEMTEXTA
-# UNICODE
-
-const
-  LVM_GETITEMCOUNT* = 4100
-  LVM_GETITEMPOSITION* = 4112
-  LVM_GETITEMRECT* = 4110
-  LVM_GETITEMSPACING* = 4147
-  LVM_GETITEMSTATE* = 4140
-  LVM_GETNEXTITEM* = 4108
-  LVM_GETORIGIN* = 4137
-  LVM_GETSELECTEDCOUNT* = 4146
-  LVM_GETTEXTBKCOLOR* = 4133
-  LVM_GETTEXTCOLOR* = 4131
-  LVM_GETTOPINDEX* = 4135
-  LVM_GETVIEWRECT* = 4130
-  LVM_HITTEST* = 4114
-  LVM_REDRAWITEMS* = 4117
-  LVM_SCROLL* = 4116
-  LVM_SETBKCOLOR* = 4097
-  LVM_SETCALLBACKMASK* = 4107
-  LVM_SETCOLUMNWIDTH* = 4126
-  LVM_SETIMAGELIST* = 4099
-  LVM_SETITEMCOUNT* = 4143
-  LVM_SETITEMPOSITION* = 4111
-  LVM_SETITEMPOSITION32* = 4145
-  LVM_SETITEMSTATE* = 4139
-  LVM_SETTEXTBKCOLOR* = 4134
-  LVM_SETTEXTCOLOR* = 4132
-  LVM_SORTITEMS* = 4144
-  LVM_UPDATE* = 4138          # List view control notifications
-  LVN_BEGINDRAG* = - (109)
-  LVN_BEGINRDRAG* = - (111)
-  LVN_COLUMNCLICK* = - (108)
-  LVN_DELETEALLITEMS* = - (104)
-  LVN_DELETEITEM* = - (103)
-  LVN_BEGINLABELEDITW* = - (175)
-  LVN_ENDLABELEDITW* = - (176)
-  LVN_GETDISPINFOW* = - (177)
-  LVN_SETDISPINFOW* = - (178)
-  LVN_BEGINLABELEDITA* = - (105)
-  LVN_ENDLABELEDITA* = - (106)
-  LVN_GETDISPINFOA* = - (150)
-  LVN_SETDISPINFOA* = - (151)
-
-when defined(winUnicode):
-  const
-    LVN_BEGINLABELEDIT* = LVN_BEGINLABELEDITW
-    LVN_ENDLABELEDIT* = LVN_ENDLABELEDITW
-    LVN_GETDISPINFO* = LVN_GETDISPINFOW
-    LVN_SETDISPINFO* = LVN_SETDISPINFOW
-else:
-  const
-    LVN_BEGINLABELEDIT* = LVN_BEGINLABELEDITA
-    LVN_ENDLABELEDIT* = LVN_ENDLABELEDITA
-    LVN_GETDISPINFO* = LVN_GETDISPINFOA
-    LVN_SETDISPINFO* = LVN_SETDISPINFOA
-# UNICODE
-
-const
-  LVN_INSERTITEM* = - (102)
-  LVN_ITEMCHANGED* = - (101)
-  LVN_ITEMCHANGING* = - (100)
-  LVN_KEYDOWN* = - (155)      # Control notification
-  NM_CLICK* = - (2)
-  NM_DBLCLK* = - (3)
-  NM_KILLFOCUS* = - (8)
-  NM_OUTOFMEMORY* = - (1)
-  NM_RCLICK* = - (5)
-  NM_RDBLCLK* = - (6)
-  NM_RETURN* = - (4)
-  NM_SETFOCUS* = - (7)        # Power status
-                              # Progress bar control
-  PBM_DELTAPOS* = 1027
-  PBM_SETPOS* = 1026
-  PBM_SETRANGE* = 1025
-  PBM_SETRANGE32* = 1030
-  PBM_SETSTEP* = 1028
-  PBM_STEPIT* = 1029          # Property sheets
-  PSM_ADDPAGE* = 1127
-  PSM_APPLY* = 1134
-  PSM_CANCELTOCLOSE* = 1131
-  PSM_CHANGED* = 1128
-  PSM_GETTABCONTROL* = 1140
-  PSM_GETCURRENTPAGEHWND* = 1142
-  PSM_ISDIALOGMESSAGE* = 1141
-  PSM_PRESSBUTTON* = 1137
-  PSM_QUERYSIBLINGS* = 1132
-  PSM_REBOOTSYSTEM* = 1130
-  PSM_REMOVEPAGE* = 1126
-  PSM_RESTARTWINDOWS* = 1129
-  PSM_SETCURSEL* = 1125
-  PSM_SETCURSELID* = 1138
-  PSM_SETFINISHTEXTW* = 1145
-  PSM_SETTITLEW* = 1144
-  PSM_SETFINISHTEXTA* = 1139
-  PSM_SETTITLEA* = 1135
-
-when defined(winUnicode):
-  const
-    PSM_SETFINISHTEXT* = PSM_SETFINISHTEXTW
-    PSM_SETTITLE* = PSM_SETTITLEW
-else:
-  const
-    PSM_SETFINISHTEXT* = PSM_SETFINISHTEXTA
-    PSM_SETTITLE* = PSM_SETTITLEA
-# UNICODE
-
-const
-  PSM_SETWIZBUTTONS* = 1136
-  PSM_UNCHANGED* = 1133       # Property sheet notifications
-  PSN_APPLY* = - (202)
-  PSN_HELP* = - (205)
-  PSN_KILLACTIVE* = - (201)
-  PSN_QUERYCANCEL* = - (209)
-  PSN_RESET* = - (203)
-  PSN_SETACTIVE* = - (200)
-  PSN_WIZBACK* = - (206)
-  PSN_WIZFINISH* = - (208)
-  PSN_WIZNEXT* = - (207)      # Status window
-  SB_GETBORDERS* = 1031
-  SB_GETPARTS* = 1030
-  SB_GETRECT* = 1034
-  SB_GETTEXTW* = 1037
-  SB_GETTEXTLENGTHW* = 1036
-  SB_SETTEXTW* = 1035
-  SB_GETTEXTA* = 1026
-  SB_GETTEXTLENGTHA* = 1027
-  SB_SETTEXTA* = 1025
-
-when defined(winUnicode):
-  const
-    SB_GETTEXT* = SB_GETTEXTW
-    SB_GETTEXTLENGTH* = SB_GETTEXTLENGTHW
-    SB_SETTEXT* = SB_SETTEXTW
-else:
-  const
-    SB_GETTEXT* = SB_GETTEXTA
-    SB_GETTEXTLENGTH* = SB_GETTEXTLENGTHA
-    SB_SETTEXT* = SB_SETTEXTA
-# UNICODE
-
-const
-  SB_SETMINHEIGHT* = 1032
-  SB_SETPARTS* = 1028
-  SB_SIMPLE* = 1033           # Scroll bar control
-  SBM_ENABLE_ARROWS* = 228
-  SBM_GETPOS* = 225
-  SBM_GETRANGE* = 227
-  SBM_GETSCROLLINFO* = 234
-  SBM_SETPOS* = 224
-  SBM_SETRANGE* = 226
-  SBM_SETRANGEREDRAW* = 230
-  SBM_SETSCROLLINFO* = 233    # Static control
-  STM_GETICON* = 369
-  STM_GETIMAGE* = 371
-  STM_SETICON* = 368
-  STM_SETIMAGE* = 370         # Static control notifications
-  STN_CLICKED* = 0
-  STN_DBLCLK* = 1
-  STN_DISABLE* = 3
-  STN_ENABLE* = 2             # Toolbar control
-  TB_ADDBITMAP* = 1043
-  TB_ADDBUTTONS* = 1044
-  TB_AUTOSIZE* = 1057
-  TB_BUTTONCOUNT* = 1048
-  TB_BUTTONSTRUCTSIZE* = 1054
-  TB_CHANGEBITMAP* = 1067
-  TB_CHECKBUTTON* = 1026
-  TB_COMMANDTOINDEX* = 1049
-  TB_CUSTOMIZE* = 1051
-  TB_DELETEBUTTON* = 1046
-  TB_ENABLEBUTTON* = 1025
-  TB_GETBITMAP* = 1068
-  TB_GETBITMAPFLAGS* = 1065
-  TB_GETBUTTON* = 1047
-  TB_ADDSTRINGW* = 1101
-  TB_GETBUTTONTEXTW* = 1099
-  TB_SAVERESTOREW* = 1100
-  TB_ADDSTRINGA* = 1052
-  TB_GETBUTTONTEXTA* = 1069
-  TB_SAVERESTOREA* = 1050
-
-when defined(winUnicode):
-  const
-    TB_ADDSTRING* = TB_ADDSTRINGW
-    TB_GETBUTTONTEXT* = TB_GETBUTTONTEXTW
-    TB_SAVERESTORE* = TB_SAVERESTOREW
-else:
-  const
-    TB_ADDSTRING* = TB_ADDSTRINGA
-    TB_GETBUTTONTEXT* = TB_GETBUTTONTEXTA
-    TB_SAVERESTORE* = TB_SAVERESTOREA
-# UNICODE
-
-const
-  TB_GETITEMRECT* = 1053
-  TB_GETROWS* = 1064
-  TB_GETSTATE* = 1042
-  TB_GETTOOLTIPS* = 1059
-  TB_HIDEBUTTON* = 1028
-  TB_INDETERMINATE* = 1029
-  TB_INSERTBUTTON* = 1045
-  TB_ISBUTTONCHECKED* = 1034
-  TB_ISBUTTONENABLED* = 1033
-  TB_ISBUTTONHIDDEN* = 1036
-  TB_ISBUTTONINDETERMINATE* = 1037
-  TB_ISBUTTONPRESSED* = 1035
-  TB_PRESSBUTTON* = 1027
-  TB_SETBITMAPSIZE* = 1056
-  TB_SETBUTTONSIZE* = 1055
-  TB_SETCMDID* = 1066
-  TB_SETPARENT* = 1061
-  TB_SETROWS* = 1063
-  TB_SETSTATE* = 1041
-  TB_SETTOOLTIPS* = 1060      # Track bar control
-  TBM_CLEARSEL* = 1043
-  TBM_CLEARTICS* = 1033
-  TBM_GETCHANNELRECT* = 1050
-  TBM_GETLINESIZE* = 1048
-  TBM_GETNUMTICS* = 1040
-  TBM_GETPAGESIZE* = 1046
-  TBM_GETPOS* = 1024
-  TBM_GETPTICS* = 1038
-  TBM_GETRANGEMAX* = 1026
-  TBM_GETRANGEMIN* = 1025
-  TBM_GETSELEND* = 1042
-  TBM_GETSELSTART* = 1041
-  TBM_GETTHUMBLENGTH* = 1052
-  TBM_GETTHUMBRECT* = 1049
-  TBM_GETTIC* = 1027
-  TBM_GETTICPOS* = 1039
-  TBM_SETLINESIZE* = 1047
-  TBM_SETPAGESIZE* = 1045
-  TBM_SETPOS* = 1029
-  TBM_SETRANGE* = 1030
-  TBM_SETRANGEMAX* = 1032
-  TBM_SETRANGEMIN* = 1031
-  TBM_SETSEL* = 1034
-  TBM_SETSELEND* = 1036
-  TBM_SETSELSTART* = 1035
-  TBM_SETTHUMBLENGTH* = 1051
-  TBM_SETTIC* = 1028
-  TBM_SETTICFREQ* = 1044      # Tool bar control notifications
-  TBN_BEGINADJUST* = - (703)
-  TBN_BEGINDRAG* = - (701)
-  TBN_CUSTHELP* = - (709)
-  TBN_ENDADJUST* = - (704)
-  TBN_ENDDRAG* = - (702)
-  TBN_GETBUTTONINFOW* = - (720)
-  TBN_GETBUTTONINFOA* = - (700)
-
-when defined(winUnicode):
-  const
-    TBN_GETBUTTONINFO* = TBN_GETBUTTONINFOW
-else:
-  const
-    TBN_GETBUTTONINFO* = TBN_GETBUTTONINFOA
-# UNICODE
-
-const
-  TBN_QUERYDELETE* = - (707)
-  TBN_QUERYINSERT* = - (706)
-  TBN_RESET* = - (705)
-  TBN_TOOLBARCHANGE* = - (708) # Tab control
-  TCM_ADJUSTRECT* = 4904
-  TCM_DELETEALLITEMS* = 4873
-  TCM_DELETEITEM* = 4872
-  TCM_GETCURFOCUS* = 4911
-  TCM_GETCURSEL* = 4875
-  TCM_GETIMAGELIST* = 4866
-  TCM_GETITEMW* = 4924
-  TCM_INSERTITEMW* = 4926
-  TCM_SETITEMW* = 4925
-  TCM_GETITEMA* = 4869
-  TCM_INSERTITEMA* = 4871
-  TCM_SETITEMA* = 4870
-
-when defined(winUnicode):
-  const
-    TCM_GETITEM* = TCM_GETITEM
-    TCM_INSERTITEM* = TCM_INSERTITEMW
-    TCM_SETITEM* = TCM_SETITEMW
-else:
-  const
-    TCM_GETITEM* = TCM_GETITEMA
-    TCM_INSERTITEM* = TCM_INSERTITEMA
-    TCM_SETITEM* = TCM_SETITEMA
-# UNICODE
-
-const
-  TCM_GETITEMCOUNT* = 4868
-  TCM_GETITEMRECT* = 4874
-  TCM_GETROWCOUNT* = 4908
-  TCM_GETTOOLTIPS* = 4909
-  TCM_HITTEST* = 4877
-  TCM_REMOVEIMAGE* = 4906
-  TCM_SETCURFOCUS* = 4912
-  TCM_SETCURSEL* = 4876
-  TCM_SETIMAGELIST* = 4867
-  TCM_SETITEMEXTRA* = 4878
-  TCM_SETITEMSIZE* = 4905
-  TCM_SETPADDING* = 4907
-  TCM_SETTOOLTIPS* = 4910     # Tab control notifications
-  TCN_KEYDOWN* = - (550)
-  TCN_SELCHANGE* = - (551)
-  TCN_SELCHANGING* = - (552)  # Tool tip control
-  TTM_ACTIVATE* = 1025
-  TTM_ADDTOOLW* = 1074
-  TTM_DELTOOLW* = 1075
-  TTM_ENUMTOOLSW* = 1082
-  TTM_GETCURRENTTOOLW* = 1083
-  TTM_GETTEXTW* = 1080
-  TTM_GETTOOLINFOW* = 1077
-  TTM_HITTESTW* = 1079
-  TTM_NEWTOOLRECTW* = 1076
-  TTM_SETTOOLINFOW* = 1078
-  TTM_UPDATETIPTEXTW* = 1081
-  TTM_ADDTOOLA* = 1028
-  TTM_DELTOOLA* = 1029
-  TTM_ENUMTOOLSA* = 1038
-  TTM_GETCURRENTTOOLA* = 1039
-  TTM_GETTEXTA* = 1035
-  TTM_GETTOOLINFOA* = 1032
-  TTM_HITTESTA* = 1034
-  TTM_NEWTOOLRECTA* = 1030
-  TTM_SETTOOLINFOA* = 1033
-  TTM_UPDATETIPTEXTA* = 1036
-
-when defined(winUnicode):
-  const
-    TTM_ADDTOOL* = TTM_ADDTOOLW
-    TTM_DELTOOL* = TTM_DELTOOLW
-    TTM_ENUMTOOLS* = TTM_ENUMTOOLSW
-    TTM_GETCURRENTTOOL* = TTM_GETCURRENTTOOLW
-    TTM_GETTEXT* = TTM_GETTEXTW
-    TTM_GETTOOLINFO* = TTM_GETTOOLINFOW
-    TTM_HITTEST* = TTM_HITTESTW
-    TTM_NEWTOOLRECT* = TTM_NEWTOOLRECTW
-    TTM_SETTOOLINFO* = TTM_SETTOOLINFOW
-    TTM_UPDATETIPTEXT* = TTM_UPDATETIPTEXTW
-else:
-  const
-    TTM_ADDTOOL* = TTM_ADDTOOLA
-    TTM_DELTOOL* = TTM_DELTOOLA
-    TTM_ENUMTOOLS* = TTM_ENUMTOOLSA
-    TTM_GETCURRENTTOOL* = TTM_GETCURRENTTOOLA
-    TTM_GETTEXT* = TTM_GETTEXTA
-    TTM_GETTOOLINFO* = TTM_GETTOOLINFOA
-    TTM_HITTEST* = TTM_HITTESTA
-    TTM_NEWTOOLRECT* = TTM_NEWTOOLRECTA
-    TTM_SETTOOLINFO* = TTM_SETTOOLINFOA
-    TTM_UPDATETIPTEXT* = TTM_UPDATETIPTEXTA
-# UNICODE
-
-const
-  TTM_GETTOOLCOUNT* = 1037
-  TTM_RELAYEVENT* = 1031
-  TTM_SETDELAYTIME* = 1027
-  TTM_WINDOWFROMPOINT* = 1040 # Tool tip control notification
-  TTN_NEEDTEXTW* = - (530)
-  TTN_NEEDTEXTA* = - (520)
-
-when defined(winUnicode):
-  const
-    TTN_NEEDTEXT* = TTN_NEEDTEXTW
-else:
-  const
-    TTN_NEEDTEXT* = TTN_NEEDTEXTA
-# UNICODE
-
-const
-  TTN_POP* = - (522)
-  TTN_SHOW* = - (521)         # Tree view control
-  TVM_CREATEDRAGIMAGE* = 4370
-  TVM_DELETEITEM* = 4353
-  TVM_ENDEDITLABELNOW* = 4374
-  TVM_ENSUREVISIBLE* = 4372
-  TVM_EXPAND* = 4354
-  TVM_GETCOUNT* = 4357
-  TVM_GETEDITCONTROL* = 4367
-  TVM_GETIMAGELIST* = 4360
-  TVM_GETINDENT* = 4358
-  TVM_GETITEMRECT* = 4356
-  TVM_GETNEXTITEM* = 4362
-  TVM_GETVISIBLECOUNT* = 4368
-  TVM_HITTEST* = 4369
-  TVM_EDITLABELW* = 4417
-  TVM_GETISEARCHSTRINGW* = 4416
-  TVM_GETITEMW* = 4414
-  TVM_INSERTITEMW* = 4402
-  TVM_SETITEMW* = 4415
-  TVM_EDITLABELA* = 4366
-  TVM_GETISEARCHSTRINGA* = 4375
-  TVM_GETITEMA* = 4364
-  TVM_INSERTITEMA* = 4352
-  TVM_SETITEMA* = 4365
-
-when defined(winUnicode):
-  const
-    TVM_EDITLABEL* = TVM_EDITLABELW
-    TVM_GETISEARCHSTRING* = TVM_GETISEARCHSTRINGW
-    TVM_GETITEM* = TVM_GETITEMW
-    TVM_INSERTITEM* = TVM_INSERTITEMW
-    TVM_SETITEM* = TVM_SETITEMW
-else:
-  const
-    TVM_EDITLABEL* = TVM_EDITLABELA
-    TVM_GETISEARCHSTRING* = TVM_GETISEARCHSTRINGA
-    TVM_GETITEM* = TVM_GETITEMA
-    TVM_INSERTITEM* = TVM_INSERTITEMA
-    TVM_SETITEM* = TVM_SETITEMA
-# UNICODE
-
-const
-  TVM_SELECTITEM* = 4363
-  TVM_SETIMAGELIST* = 4361
-  TVM_SETINDENT* = 4359
-  TVM_SORTCHILDREN* = 4371
-  TVM_SORTCHILDRENCB* = 4373  # Tree view control notification
-  TVN_KEYDOWN* = - (412)
-  TVN_BEGINDRAGW* = - (456)
-  TVN_BEGINLABELEDITW* = - (459)
-  TVN_BEGINRDRAGW* = - (457)
-  TVN_DELETEITEMW* = - (458)
-  TVN_ENDLABELEDITW* = - (460)
-  TVN_GETDISPINFOW* = - (452)
-  TVN_ITEMEXPANDEDW* = - (455)
-  TVN_ITEMEXPANDINGW* = - (454)
-  TVN_SELCHANGEDW* = - (451)
-  TVN_SELCHANGINGW* = - (450)
-  TVN_SETDISPINFOW* = - (453)
-  TVN_BEGINDRAGA* = - (407)
-  TVN_BEGINLABELEDITA* = - (410)
-  TVN_BEGINRDRAGA* = - (408)
-  TVN_DELETEITEMA* = - (409)
-  TVN_ENDLABELEDITA* = - (411)
-  TVN_GETDISPINFOA* = - (403)
-  TVN_ITEMEXPANDEDA* = - (406)
-  TVN_ITEMEXPANDINGA* = - (405)
-  TVN_SELCHANGEDA* = - (402)
-  TVN_SELCHANGINGA* = - (401)
-  TVN_SETDISPINFOA* = - (404)
-
-when defined(winUnicode):
-  const
-    TVN_BEGINDRAG* = TVN_BEGINDRAGW
-    TVN_BEGINLABELEDIT* = TVN_BEGINLABELEDITW
-    TVN_BEGINRDRAG* = TVN_BEGINRDRAGW
-    TVN_DELETEITEM* = TVN_DELETEITEMW
-    TVN_ENDLABELEDIT* = TVN_ENDLABELEDITW
-    TVN_GETDISPINFO* = TVN_GETDISPINFOW
-    TVN_ITEMEXPANDED* = TVN_ITEMEXPANDEDW
-    TVN_ITEMEXPANDING* = TVN_ITEMEXPANDINGW
-    TVN_SELCHANGED* = TVN_SELCHANGEDW
-    TVN_SELCHANGING* = TVN_SELCHANGINGW
-    TVN_SETDISPINFO* = TVN_SETDISPINFOW
-else:
-  const
-    TVN_BEGINDRAG* = TVN_BEGINDRAGA
-    TVN_BEGINLABELEDIT* = TVN_BEGINLABELEDITA
-    TVN_BEGINRDRAG* = TVN_BEGINRDRAGA
-    TVN_DELETEITEM* = TVN_DELETEITEMA
-    TVN_ENDLABELEDIT* = TVN_ENDLABELEDITA
-    TVN_GETDISPINFO* = TVN_GETDISPINFOA
-    TVN_ITEMEXPANDED* = TVN_ITEMEXPANDEDA
-    TVN_ITEMEXPANDING* = TVN_ITEMEXPANDINGA
-    TVN_SELCHANGED* = TVN_SELCHANGEDA
-    TVN_SELCHANGING* = TVN_SELCHANGINGA
-    TVN_SETDISPINFO* = TVN_SETDISPINFOA
-# UNICODE
-# Up/down control
-
-const
-  UDM_GETACCEL* = 1132
-  UDM_GETBASE* = 1134
-  UDM_GETBUDDY* = 1130
-  UDM_GETPOS* = 1128
-  UDM_GETPOS32* = 1138
-  UDM_GETRANGE* = 1126
-  UDM_GETRANGE32* = 1136
-  UDM_SETACCEL* = 1131
-  UDM_SETBASE* = 1133
-  UDM_SETBUDDY* = 1129
-  UDM_SETPOS* = 1127
-  UDM_SETPOS32* = 1137
-  UDM_SETRANGE* = 1125
-  UDM_SETRANGE32* = 1135      # Up/down control notification
-  UDN_DELTAPOS* = - (722)     # Window messages
-  WM_ACTIVATE* = 6
-  WM_ACTIVATEAPP* = 28
-  WM_ASKCBFORMATNAME* = 780
-  WM_CANCELJOURNAL* = 75
-  WM_CANCELMODE* = 31
-  WM_CAPTURECHANGED* = 533
-  WM_CHANGECBCHAIN* = 781
-  WM_CHAR* = 258
-  WM_CHARTOITEM* = 47
-  WM_CHILDACTIVATE* = 34
-  WM_CHOOSEFONT_GETLOGFONT* = 1025
-  WM_CHOOSEFONT_SETLOGFONT* = 1125
-  WM_CHOOSEFONT_SETFLAGS* = 1126
-  WM_CLEAR* = 771
-  WM_CLOSE* = 16
-  WM_COMMAND* = 273
-  WM_COMPACTING* = 65
-  WM_COMPAREITEM* = 57
-  WM_CONTEXTMENU* = 123
-  WM_COPY* = 769
-  WM_COPYDATA* = 74
-  WM_CREATE* = 1
-  WM_CTLCOLORBTN* = 309
-  WM_CTLCOLORDLG* = 310
-  WM_CTLCOLOREDIT* = 307
-  WM_CTLCOLORLISTBOX* = 308
-  WM_CTLCOLORMSGBOX* = 306
-  WM_CTLCOLORSCROLLBAR* = 311
-  WM_CTLCOLORSTATIC* = 312
-  WM_CUT* = 768
-  WM_DEADCHAR* = 259
-  WM_DELETEITEM* = 45
-  WM_DESTROY* = 2
-  WM_DESTROYCLIPBOARD* = 775
-  WM_DEVICECHANGE* = 537
-  WM_DEVMODECHANGE* = 27
-  WM_DISPLAYCHANGE* = 126
-  WM_DRAWCLIPBOARD* = 776
-  WM_DRAWITEM* = 43
-  WM_DROPFILES* = 563
-  WM_ENABLE* = 10
-  WM_ENDSESSION* = 22
-  WM_ENTERIDLE* = 289
-  WM_ENTERMENULOOP* = 529
-  WM_ENTERSIZEMOVE* = 561
-  WM_ERASEBKGND* = 20
-  WM_EXITMENULOOP* = 530
-  WM_EXITSIZEMOVE* = 562
-  WM_FONTCHANGE* = 29
-  WM_GETDLGCODE* = 135
-  WM_GETFONT* = 49
-  WM_GETHOTKEY* = 51
-  WM_GETICON* = 127
-  WM_GETMINMAXINFO* = 36
-  WM_GETTEXT* = 13
-  WM_GETTEXTLENGTH* = 14
-  WM_HELP* = 83
-  WM_HOTKEY* = 786
-  WM_HSCROLL* = 276
-  WM_HSCROLLCLIPBOARD* = 782
-  WM_ICONERASEBKGND* = 39
-  WM_IME_CHAR* = 646
-  WM_IME_COMPOSITION* = 271
-  WM_IME_COMPOSITIONFULL* = 644
-  WM_IME_CONTROL* = 643
-  WM_IME_ENDCOMPOSITION* = 270
-  WM_IME_KEYDOWN* = 656
-  WM_IME_KEYUP* = 657
-  WM_IME_NOTIFY* = 642
-  WM_IME_SELECT* = 645
-  WM_IME_SETCONTEXT* = 641
-  WM_IME_STARTCOMPOSITION* = 269
-  WM_INITDIALOG* = 272
-  WM_INITMENU* = 278
-  WM_INITMENUPOPUP* = 279
-  WM_INPUTLANGCHANGE* = 81
-  WM_INPUTLANGCHANGEREQUEST* = 80
-  WM_KEYDOWN* = 256
-  WM_KEYUP* = 257
-  WM_KILLFOCUS* = 8
-  WM_LBUTTONDBLCLK* = 515
-  WM_LBUTTONDOWN* = 513
-  WM_LBUTTONUP* = 514
-  WM_MBUTTONDBLCLK* = 521
-  WM_MBUTTONDOWN* = 519
-  WM_MBUTTONUP* = 520
-  WM_MDIACTIVATE* = 546
-  WM_MDICASCADE* = 551
-  WM_MDICREATE* = 544
-  WM_MDIDESTROY* = 545
-  WM_MDIGETACTIVE* = 553
-  WM_MDIICONARRANGE* = 552
-  WM_MDIMAXIMIZE* = 549
-  WM_MDINEXT* = 548
-  WM_MDIREFRESHMENU* = 564
-  WM_MDIRESTORE* = 547
-  WM_MDISETMENU* = 560
-  WM_MDITILE* = 550
-  WM_MEASUREITEM* = 44
-  WM_MENUCHAR* = 288
-  WM_MENUSELECT* = 287
-  WM_MOUSEACTIVATE* = 33
-  WM_MOUSEMOVE* = 512
-  WM_MOUSEWHEEL* = 522
-  WM_MOUSEHOVER* = 673
-  WM_MOUSELEAVE* = 675
-  WM_MOVE* = 3
-  WM_MOVING* = 534
-  WM_NCACTIVATE* = 134
-  WM_NCCALCSIZE* = 131
-  WM_NCCREATE* = 129
-  WM_NCDESTROY* = 130
-  WM_NCHITTEST* = 132
-  WM_NCLBUTTONDBLCLK* = 163
-  WM_NCLBUTTONDOWN* = 161
-  WM_NCLBUTTONUP* = 162
-  WM_NCMBUTTONDBLCLK* = 169
-  WM_NCMBUTTONDOWN* = 167
-  WM_NCMBUTTONUP* = 168
-  WM_NCMOUSEMOVE* = 160
-  WM_NCPAINT* = 133
-  WM_NCRBUTTONDBLCLK* = 166
-  WM_NCRBUTTONDOWN* = 164
-  WM_NCRBUTTONUP* = 165
-  WM_NEXTDLGCTL* = 40
-  WM_NOTIFY* = 78
-  WM_NOTIFYFORMAT* = 85
-  WM_NULL* = 0
-  WM_PAINT* = 15
-  WM_PAINTCLIPBOARD* = 777
-  WM_PAINTICON* = 38
-  WM_PALETTECHANGED* = 785
-  WM_PALETTEISCHANGING* = 784
-  WM_PARENTNOTIFY* = 528
-  WM_PASTE* = 770
-  WM_PENWINFIRST* = 896
-  WM_PENWINLAST* = 911
-  WM_POWER* = 72
-  WM_POWERBROADCAST* = 536
-  WM_PRINT* = 791
-  WM_PRINTCLIENT* = 792
-  WM_PSD_ENVSTAMPRECT* = 1029
-  WM_PSD_FULLPAGERECT* = 1025
-  WM_PSD_GREEKTEXTRECT* = 1028
-  WM_PSD_MARGINRECT* = 1027
-  WM_PSD_MINMARGINRECT* = 1026
-  WM_PSD_PAGESETUPDLG* = 1024
-  WM_PSD_YAFULLPAGERECT* = 1030
-  WM_QUERYDRAGICON* = 55
-  WM_QUERYENDSESSION* = 17
-  WM_QUERYNEWPALETTE* = 783
-  WM_QUERYOPEN* = 19
-  WM_QUEUESYNC* = 35
-  WM_QUIT* = 18
-  WM_RBUTTONDBLCLK* = 518
-  WM_RBUTTONDOWN* = 516
-  WM_RBUTTONUP* = 517
-  WM_RENDERALLFORMATS* = 774
-  WM_RENDERFORMAT* = 773
-  WM_SETCURSOR* = 32
-  WM_SETFOCUS* = 7
-  WM_SETFONT* = 48
-  WM_SETHOTKEY* = 50
-  WM_SETICON* = 128
-  WM_SETREDRAW* = 11
-  WM_SETTEXT* = 12
-  WM_SETTINGCHANGE* = 26
-  WM_SHOWWINDOW* = 24
-  WM_SIZE* = 5
-  WM_SIZECLIPBOARD* = 779
-  WM_SIZING* = 532
-  WM_SPOOLERSTATUS* = 42
-  WM_STYLECHANGED* = 125
-  WM_STYLECHANGING* = 124
-  WM_SYSCHAR* = 262
-  WM_SYSCOLORCHANGE* = 21
-  WM_SYSCOMMAND* = 274
-  WM_SYSDEADCHAR* = 263
-  WM_SYSKEYDOWN* = 260
-  WM_SYSKEYUP* = 261
-  WM_TCARD* = 82
-  WM_TIMECHANGE* = 30
-  WM_TIMER* = 275
-  WM_UNDO* = 772
-  WM_USER* = 1024
-  WM_USERCHANGED* = 84
-  WM_VKEYTOITEM* = 46
-  WM_VSCROLL* = 277
-  WM_VSCROLLCLIPBOARD* = 778
-  WM_WINDOWPOSCHANGED* = 71
-  WM_WINDOWPOSCHANGING* = 70
-  WM_WININICHANGE* = 26       # Window message ranges
-  WM_KEYFIRST* = 256
-  WM_KEYLAST* = 264
-  WM_MOUSEFIRST* = 512
-  WM_MOUSELAST* = 525
-  WM_XBUTTONDOWN* = 523
-  WM_XBUTTONUP* = 524
-  WM_XBUTTONDBLCLK* = 525
-
-when defined(cpu64):
-  type
-    HALFLRESULT* = DWORD
-    HALFPARAM* = DWORD
-    HALFPARAMBOOL* = WINBOOL
-else:
-  type
-    HALFLRESULT* = int16
-    HALFPARAM* = int16
-    HALFPARAMBOOL* = WORDBOOL
-type
-  MSG* {.final, pure.} = object
-    hwnd*: HWND
-    message*: UINT
-    wParam*: WPARAM
-    lParam*: LPARAM
-    time*: DWORD
-    pt*: POINT
-
-  LPMSG* = ptr MSG
-  TMSG* = MSG
-  PMSG* = ptr MSG
-  PMessage* = ptr TMessage
-  TMessage* {.final, pure.} = object          #fields according to ICS
-    msg*: UINT
-    wParam*: WPARAM
-    lParam*: LPARAM
-    Result*: LRESULT
-
-  TWMSize* {.final, pure.} = object
-    Msg*: UINT
-    SizeType*: WPARAM
-    Width*: HALFPARAM
-    Height*: HALFPARAM
-    Result*: LRESULT
-
-  TWMNoParams* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: array[0..3, HALFPARAM]
-    Result*: LRESULT
-
-  TWMCancelMode* = TWMNoParams
-  TWMNCDestroy* = TWMNoParams
-  TWMDestroy* = TWMNoParams
-  TWMClose* = TWMNoParams
-  TWMQueryUIState* = TWMNoParams
-  TWMUIState* {.final, pure.} = object
-    Msg*: UINT
-    Action*: int16
-    Flags*: int16
-    Unused*: HRESULT
-
-  TWMChangeUIState* = TWMUIState
-  TWMUpdateUIState* = TWMUIState
-  TWMKey* {.final, pure.} = object
-    Msg*: UINT
-    CharCode*: int16
-    Unused*: int16
-    KeyData*: int32
-    Result*: LRESULT
-
-  TWMKeyDown* = TWMKey
-  TWMKeyUp* = TWMKey
-  TWMChar* = TWMKey
-  TWMSysChar* = TWMKey
-  TWMSysKeyDown* = TWMKey
-  TWMSysKeyUp* = TWMKey
-  TWMMenuChar* {.final, pure.} = object
-    Msg*: UINT
-    User*: Char
-    MenuFlag*: int16
-    Menu*: HMENU
-    Result*: LRESULT
-
-  TWMGetDlgCode* = TWMNoParams
-  TWMFontChange* = TWMNoParams
-  TWMGetFont* = TWMNoParams
-  TWMSysColorChange* = TWMNoParams
-  TWMQueryDragIcon* = TWMNoParams
-  TWMScroll* {.final, pure.} = object
-    Msg*: UINT
-    ScrollCode*: HALFPARAM
-    Pos*: HALFPARAM
-    ScrollBar*: HWND
-    Result*: LRESULT
-
-  TWMHScroll* = TWMScroll
-  TWMVScroll* = TWMScroll
-  TWMGetText* {.final, pure.} = object
-    Msg*: UINT
-    TextMax*: LPARAM
-    Text*: cstring
-    Result*: LRESULT
-
-  TWMGetTextLength* = TWMNoParams
-  TWMKillFocus* {.final, pure.} = object
-    Msg*: UINT
-    FocusedWnd*: HWND
-    UnUsed*: WPARAM
-    Result*: LRESULT
-
-  TWMSetCursor* {.final, pure.} = object
-    Msg*: UINT
-    CursorWnd*: HWND
-    HitTest*: HALFPARAM
-    MouseMsg*: HALFPARAM
-    Result*: LRESULT
-
-  TWMSetFocus* {.final, pure.} = object
-    Msg*: UINT
-    FocusedWnd*: HWND
-    Unused*: WPARAM
-    Result*: LRESULT
-
-  TWMSetFont* {.final, pure.} = object
-    Msg*: UINT
-    Font*: HFONT
-    Redraw*: HALFPARAMBOOL
-    Unused*: HALFPARAM
-    Result*: LRESULT
-
-  TWMShowWindow* {.final, pure.} = object
-    Msg*: UINT
-    Show*: HALFPARAMBOOL
-    Unused*: HALFPARAM
-    Status*: WPARAM
-    Result*: LRESULT
-
-  TWMEraseBkgnd* {.final, pure.} = object
-    Msg*: UINT
-    DC*: HDC
-    Unused*: LPARAM
-    Result*: LRESULT
-
-  TWMNCHitTest* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int32
-    Pos*: TSmallPoint
-    Result*: LRESULT
-
-  TWMMouse* {.final, pure.} = object
-    Msg*: UINT
-    Keys*: int32
-    Pos*: TSmallPoint
-    Result*: LRESULT
-
-  TWMLButtonDblClk* = TWMMouse
-  TWMLButtonDown* = TWMMouse
-  TWMLButtonUp* = TWMMouse
-  TWMMButtonDblClk* = TWMMouse
-  TWMMButtonDown* = TWMMouse
-  TWMMButtonUp* = TWMMouse
-  TWMMouseWheel* {.final, pure.} = object
-    Msg*: UINT
-    Keys*: int16
-    WheelDelta*: int16
-    Pos*: TSmallPoint
-    Result*: LRESULT
-
-  TWMNCHitMessage* {.final, pure.} = object
-    Msg*: UINT
-    HitTest*: int32
-    XCursor*: int16
-    YCursor*: int16
-    Result*: LRESULT
-
-  TWMNCLButtonDblClk* = TWMNCHitMessage
-  TWMNCLButtonDown* = TWMNCHitMessage
-  TWMNCLButtonUp* = TWMNCHitMessage
-  TWMNCMButtonDblClk* = TWMNCHitMessage
-  TWMNCMButtonDown* = TWMNCHitMessage
-  TWMNCMButtonUp* = TWMNCHitMessage
-  TWMNCMouseMove* = TWMNCHitMessage
-  TWMRButtonDblClk* = TWMMouse
-  TWMRButtonDown* = TWMMouse
-  TWMRButtonUp* = TWMMouse
-  TWMMouseMove* = TWMMouse
-  TWMPaint* {.final, pure.} = object
-    Msg*: UINT
-    DC*: HDC
-    Unused*: int32
-    Result*: LRESULT
-
-  TWMCommand* {.final, pure.} = object
-    Msg*: UINT
-    ItemID*: int16
-    NotifyCode*: int16
-    Ctl*: HWND
-    Result*: LRESULT
-
-  TWMNotify* {.final, pure.} = object
-    Msg*: UINT
-    IDCtrl*: int32
-    NMHdr*: PNMHdr
-    Result*: LRESULT
-
-  TWMPrint* {.final, pure.} = object
-    Msg*: UINT
-    DC*: HDC
-    Flags*: int
-    Result*: LRESULT
-
-  TWMPrintClient* = TWMPrint
-  TWMWinIniChange* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    Section*: cstring
-    Result*: LRESULT
-
-  TWMContextMenu* {.final, pure.} = object
-    Msg*: UINT
-    hWnd*: HWND
-    Pos*: TSmallPoint
-    Result*: LRESULT
-
-  TWMNCCalcSize* {.final, pure.} = object
-    Msg*: UINT
-    CalcValidRects*: WINBOOL
-    CalcSize_Params*: PNCCalcSizeParams
-    Result*: LRESULT
-
-  TWMCharToItem* {.final, pure.} = object
-    Msg*: UINT
-    Key*: int16
-    CaretPos*: int16
-    ListBox*: HWND
-    Result*: LRESULT
-
-  TWMVKeyToItem* = TWMCharToItem
-  TMyEventRange = range[0'i16..16000'i16]
-  TWMParentNotify* {.final, pure.} = object
-    Msg*: UINT
-    case Event*: TMyEventRange
-    of TMyEventRange(WM_CREATE), TMyEventRange(WM_DESTROY):
-        ChildID*: int16
-        ChildWnd*: HWnd
-
-    of TMyEventRange(WM_LBUTTONDOWN),
-      TMyEventRange(WM_MBUTTONDOWN),
-      TMyEventRange(WM_RBUTTONDOWN):
-        Value*: int16
-        XPos*: int16
-        YPos*: int16
-
-    else:
-        Value1*: int16
-        Value2*: int32
-        Result*: LRESULT
-
-  TWMSysCommand* {.final, pure.} = object
-    Msg*: UINT
-    CmdType*: int32
-    XPos*: int16
-    YPos*: int16
-    Result*: LRESULT
-  #  case CmdType*: int32
-  #  of SC_HOTKEY:
-  #      ActivateWnd*: HWND
-  #  of SC_CLOSE, SC_HSCROLL, SC_MAXIMIZE, SC_MINIMIZE, SC_MOUSEMENU, SC_MOVE,
-  #     SC_NEXTWINDOW, SC_PREVWINDOW, SC_RESTORE, SC_SCREENSAVE, SC_SIZE,
-  #     SC_TASKLIST, SC_VSCROLL:
-  #      XPos*: int16
-  #      YPos*: int16
-  #      Result*: LRESULT
-  #  else: # of SC_KEYMENU:
-  #      Key*: int16
-
-  TWMMove* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    Pos*: TSmallPoint
-    Result*: LRESULT
-
-  TWMWindowPosMsg* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    WindowPos*: PWindowPos
-    Result*: LRESULT
-
-  TWMWindowPosChanged* = TWMWindowPosMsg
-  TWMWindowPosChanging* = TWMWindowPosMsg
-  TWMCompareItem* {.final, pure.} = object
-    Msg*: UINT
-    Ctl*: HWnd
-    CompareItemStruct*: PCompareItemStruct
-    Result*: LRESULT
-
-  TWMDeleteItem* {.final, pure.} = object
-    Msg*: UINT
-    Ctl*: HWND
-    DeleteItemStruct*: PDeleteItemStruct
-    Result*: LRESULT
-
-  TWMDrawItem* {.final, pure.} = object
-    Msg*: UINT
-    Ctl*: HWND
-    DrawItemStruct*: PDrawItemStruct
-    Result*: LRESULT
-
-  TWMMeasureItem* {.final, pure.} = object
-    Msg*: UINT
-    IDCtl*: HWnd
-    MeasureItemStruct*: PMeasureItemStruct
-    Result*: LRESULT
-
-  TWMNCCreate* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    CreateStruct*: PCreateStruct
-    Result*: LRESULT
-
-  TWMInitMenuPopup* {.final, pure.} = object
-    Msg*: UINT
-    MenuPopup*: HMENU
-    Pos*: int16
-    SystemMenu*: WordBool
-    Result*: LRESULT
-
-  TWMMenuSelect* {.final, pure.} = object
-    Msg*: UINT
-    IDItem*: int16
-    MenuFlag*: int16
-    Menu*: HMENU
-    Result*: LRESULT
-
-  TWMActivate* {.final, pure.} = object
-    Msg*: UINT
-    Active*: int16
-    Minimized*: WordBool
-    ActiveWindow*: HWND
-    Result*: LRESULT
-
-  TWMQueryEndSession* {.final, pure.} = object
-    Msg*: UINT
-    Source*: int32
-    Unused*: int32
-    Result*: LRESULT
-
-  TWMMDIActivate* {.final, pure.} = object
-    Msg*: UINT
-    DeactiveWnd*: HWND
-    ActiveWnd*: HWND
-    Result*: LRESULT
-
-  TWMNextDlgCtl* {.final, pure.} = object
-    Msg*: UINT
-    CtlFocus*: int32
-    Handle*: WordBool
-    Unused*: int16
-    Result*: LRESULT
-
-  TWMHelp* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    HelpInfo*: PHelpInfo
-    Result*: LRESULT
-
-  TWMGetMinMaxInfo* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    MinMaxInfo*: PMinMaxInfo
-    Result*: LRESULT
-
-  TWMSettingChange* {.final, pure.} = object
-    Msg*: UINT
-    Flag*: int
-    Section*: cstring
-    Result*: LRESULT
-
-  TWMCreate* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int
-    CreateStruct*: PCreateStruct
-    Result*: LRESULT
-
-  TWMCtlColor* {.final, pure.} = object
-    Msg*: UINT
-    ChildDC*: HDC
-    ChildWnd*: HWND
-    Result*: LRESULT
-
-  TWMCtlColorScrollbar* = TWMCtlColor
-  TWMCtlColorStatic* = TWMCtlColor
-  TWMCtlColorBtn* = TWMCtlColor
-  TWMCtlColorListbox* = TWMCtlColor
-  TWMCtlColorMsgbox* = TWMCtlColor
-  TWMCtlColorDlg* = TWMCtlColor
-  TWMCtlColorEdit* = TWMCtlColor
-  TWMInitDialog* {.final, pure.} = object
-    Msg*: UINT
-    Focus*: HWND
-    InitParam*: int32
-    Result*: LRESULT
-
-  TWMNCPaint* {.final, pure.} = object
-    Msg*: UINT
-    RGN*: HRGN
-    Unused*: int32
-    Result*: LRESULT
-
-  TWMSetText* {.final, pure.} = object
-    Msg*: UINT
-    Unused*: int32
-    Text*: cstring
-    Result*: LRESULT
-
-  TWMSizeClipboard* {.final, pure.} = object
-    Msg*: UINT
-    Viewer*: HWND
-    RC*: THandle
-    Result*: LRESULT
-
-  TWMSpoolerStatus* {.final, pure.} = object
-    Msg*: UINT
-    JobStatus*: LPARAM
-    JobsLeft*: WPARAM
-    Unused*: WPARAM
-    Result*: LRESULT
-
-  TWMStyleChange* {.final, pure.} = object
-    Msg*: UINT
-    StyleType*: LPARAM
-    StyleStruct*: PStyleStruct
-    Result*: LRESULT
-
-  TWMStyleChanged* = TWMStyleChange
-  TWMStyleChanging* = TWMStyleChange
-  TWMSysDeadChar* {.final, pure.} = object
-    Msg*: UINT
-    CharCode*: WPARAM
-    Unused*: WPARAM
-    KeyData*: LPARAM
-    Result*: LRESULT
-
-  TWMSystemError* {.final, pure.} = object
-    Msg*: UINT
-    ErrSpec*: WPARAM
-    Unused*: LPARAM
-    Result*: LRESULT
-
-  TWMTimeChange* = TWMNoParams
-  TWMTimer* {.final, pure.} = object
-    Msg*: UINT
-    TimerID*: LPARAM
-    TimerProc*: TFarProc
-    Result*: LRESULT
-
-  TWMUndo* = TWMNoParams
-  TWMVScrollClipboard* {.final, pure.} = object
-    Msg*: UINT
-    Viewer*: HWND
-    ScollCode*: WPARAM
-    ThumbPos*: WPARAM
-    Result*: LRESULT
-
-  TWMDisplayChange* {.final, pure.} = object
-    Msg*: UINT
-    BitsPerPixel*: int
-    Width*: WPARAM
-    Height*: WPARAM
-    Result*: LRESULT
-
-  TWMDropFiles* {.final, pure.} = object
-    Msg*: UINT
-    Drop*: THANDLE
-    Unused*: LPARAM
-    Result*: LRESULT
-
-  TWMEnable* {.final, pure.} = object
-    Msg*: int
-    Enabled*: WINBOOL
-    Unused*: int32
-    Result*: int32
-
-  TWMMouseActivate* {.final, pure.} = object
-    Msg*: int
-    TopLevel*: HWND
-    HitTestCode*: int16
-    MouseMsg*: int16
-    Result*: int32
-
-
-proc GetBinaryTypeA*(lpApplicationName: LPCSTR, lpBinaryType: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".}
-
-proc GetShortPathNameA*(lpszLongPath: LPCSTR, lpszShortPath: LPSTR,
-                        cchBuffer: DWORD): DWORD{.stdcall,
-                        dynlib: "kernel32", importc.}
-proc GetEnvironmentStringsA*(): LPSTR{.stdcall, dynlib: "kernel32", importc.}
-proc FreeEnvironmentStringsA*(para1: LPSTR): WINBOOL{.stdcall, dynlib: "kernel32", importc.}
-proc FormatMessageA*(dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD,
-                     dwLanguageId: DWORD, lpBuffer: LPSTR, nSize: DWORD,
-                     Arguments: va_list): DWORD{.stdcall,dynlib: "kernel32", importc.}
-proc CreateMailslotA*(lpName: LPCSTR, nMaxMessageSize: DWORD,
-                      lReadTimeout: DWORD,
-                      lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc lstrcmpA*(lpString1: LPCSTR, lpString2: LPCSTR): int32{.stdcall,
-  dynlib: "kernel32", importc.}
-proc lstrcmpiA*(lpString1: LPCSTR, lpString2: LPCSTR): int32{.stdcall, dynlib: "kernel32", importc.}
-proc lstrcpynA*(lpString1: LPSTR, lpString2: LPCSTR, iMaxLength: int32): LPSTR{.
-    stdcall, dynlib: "kernel32", importc.}
-proc CreateMutexA*(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
-                   bInitialOwner: WINBOOL, lpName: LPCSTR): HANDLE{.stdcall,
-                   dynlib: "kernel32", importc.}
-proc OpenMutexA*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL, lpName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc CreateEventA*(lpEventAttributes: LPSECURITY_ATTRIBUTES,
-                   bManualReset: WINBOOL, bInitialState: WINBOOL, lpName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc OpenEventA*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL, lpName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc CreateSemaphoreA*(lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
-                       lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc OpenSemaphoreA*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                     lpName: LPCSTR): HANDLE{.stdcall,
-                     dynlib: "kernel32", importc.}
-proc CreateFileMappingA*(hFile: HANDLE,
-                         lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
-                         flProtect: DWORD, dwMaximumSizeHigh: DWORD,
-                         dwMaximumSizeLow: DWORD, lpName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc.}
-proc OpenFileMappingA*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                       lpName: LPCSTR): HANDLE{.stdcall,
-                       dynlib: "kernel32", importc.}
-proc GetLogicalDriveStringsA*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc.}
-proc LoadLibraryA*(lpLibFileName: LPCSTR): HINST{.stdcall,
-  dynlib: "kernel32", importc.}
-proc LoadLibraryExA*(lpLibFileName: LPCSTR, hFile: HANDLE, dwFlags: DWORD): HINST{.
-    stdcall, dynlib: "kernel32", importc.}
-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,
-     dynlib: "kernel32", importc.}
-proc GetCommandLineA*(): LPSTR{.stdcall, dynlib: "kernel32", importc.}
-proc GetEnvironmentVariableA*(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc.}
-proc SetEnvironmentVariableA*(lpName: LPCSTR, lpValue: LPCSTR): WINBOOL{.stdcall,
-  dynlib: "kernel32", importc.}
-proc ExpandEnvironmentStringsA*(lpSrc: LPCSTR, lpDst: LPSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc.}
-proc OutputDebugStringA*(lpOutputString: LPCSTR){.stdcall,
-   dynlib: "kernel32", importc.}
-proc FindResourceA*(hModule: HINST, lpName: LPCSTR, lpType: LPCSTR): HRSRC{.
-    stdcall, dynlib: "kernel32", importc.}
-proc FindResourceExA*(hModule: HINST, lpType: LPCSTR, lpName: LPCSTR,
-                      wLanguage: int16): HRSRC{.stdcall,
-                      dynlib: "kernel32", importc.}
-proc EnumResourceTypesA*(hModule: HINST, lpEnumFunc: ENUMRESTYPEPROC,
-                         lParam: LONG): WINBOOL{.stdcall,
-                         dynlib: "kernel32", importc.}
-proc EnumResourceNamesA*(hModule: HINST, lpType: LPCSTR,
-                         lpEnumFunc: ENUMRESNAMEPROC, lParam: LONG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc.}
-proc EnumResourceLanguagesA*(hModule: HINST, lpType: LPCSTR, lpName: LPCSTR,
-                             lpEnumFunc: ENUMRESLANGPROC, lParam: LONG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumResourceLanguagesA".}
-
-proc BeginUpdateResourceA*(pFileName: LPCSTR, bDeleteExistingResources: WINBOOL): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "BeginUpdateResourceA".}
-
-proc UpdateResourceA*(hUpdate: HANDLE, lpType: LPCSTR, lpName: LPCSTR,
-                      wLanguage: int16, lpData: LPVOID, cbData: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "UpdateResourceA".}
-proc EndUpdateResourceA*(hUpdate: HANDLE, fDiscard: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "EndUpdateResourceA".}
-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{.
-    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,
-    dynlib: "kernel32", importc: "GetAtomNameA".}
-proc GetProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.
-    stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}
-proc GetProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, lpDefault: LPCSTR,
-                        lpReturnedString: LPSTR, nSize: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetProfileStringA".}
-proc WriteProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR, lpString: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteProfileStringA".}
-proc GetProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
-                         nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetProfileSectionA".}
-proc WriteProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}
-proc GetPrivateProfileIntA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                            nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,
-    dynlib: "kernel32", importc: "GetPrivateProfileIntA".}
-proc GetPrivateProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                               lpDefault: LPCSTR, lpReturnedString: LPSTR,
-                               nSize: DWORD, lpFileName: LPCSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStringA".}
-proc WritePrivateProfileStringA*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                                 lpString: LPCSTR, lpFileName: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStringA".}
-proc GetPrivateProfileSectionA*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
-                                nSize: DWORD, lpFileName: LPCSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileSectionA".}
-proc WritePrivateProfileSectionA*(lpAppName: LPCSTR, lpString: LPCSTR,
-                                  lpFileName: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}
-proc GetDriveTypeA*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",
-    importc: "GetDriveTypeA".}
-proc GetSystemDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.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,
-    dynlib: "kernel32", importc: "GetTempFileNameA".}
-proc GetWindowsDirectoryA*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,
-    dynlib: "kernel32", importc: "GetWindowsDirectoryA".}
-proc SetCurrentDirectoryA*(lpPathName: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetCurrentDirectoryA".}
-proc GetCurrentDirectoryA*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetCurrentDirectoryA".}
-proc GetDiskFreeSpaceA*(lpRootPathName: LPCSTR, lpSectorsPerCluster: LPDWORD,
-                        lpBytesPerSector: LPDWORD,
-                        lpNumberOfFreeClusters: LPDWORD,
-                        lpTotalNumberOfClusters: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDiskFreeSpaceA".}
-proc CreateDirectoryA*(lpPathName: LPCSTR,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateDirectoryA".}
-proc CreateDirectoryExA*(lpTemplateDirectory: LPCSTR, lpNewDirectory: LPCSTR,
-                         lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateDirectoryExA".}
-proc RemoveDirectoryA*(lpPathName: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "RemoveDirectoryA".}
-proc GetFullPathNameA*(lpFileName: LPCSTR, nBufferLength: DWORD,
-                       lpBuffer: LPSTR, lpFilePart: var LPSTR): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetFullPathNameA".}
-proc DefineDosDeviceA*(dwFlags: DWORD, lpDeviceName: LPCSTR,
-                       lpTargetPath: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DefineDosDeviceA".}
-proc QueryDosDeviceA*(lpDeviceName: LPCSTR, lpTargetPath: LPSTR, ucchMax: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "QueryDosDeviceA".}
-proc CreateFileA*(lpFileName: LPCSTR, dwDesiredAccess: DWORD,
-                  dwShareMode: DWORD,
-                  lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                  dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD,
-                  hTemplateFile: HANDLE): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "CreateFileA".}
-proc SetFileAttributesA*(lpFileName: LPCSTR, dwFileAttributes: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetFileAttributesA".}
-proc GetFileAttributesA*(lpFileName: LPCSTR): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetFileAttributesA".}
-proc GetCompressedFileSizeA*(lpFileName: LPCSTR, lpFileSizeHigh: LPDWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetCompressedFileSizeA".}
-proc DeleteFileA*(lpFileName: LPCSTR): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "DeleteFileA".}
-proc SearchPathA*(lpPath: LPCSTR, lpFileName: LPCSTR, lpExtension: LPCSTR,
-                  nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: LPSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "SearchPathA".}
-proc CopyFileA*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR,
-                bFailIfExists: WINBOOL): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CopyFileA".}
-proc MoveFileA*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "MoveFileA".}
-proc MoveFileExA*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR,
-                  dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "MoveFileExA".}
-proc CreateNamedPipeA*(lpName: LPCSTR, dwOpenMode: DWORD, dwPipeMode: DWORD,
-                       nMaxInstances: DWORD, nOutBufferSize: DWORD,
-                       nInBufferSize: DWORD, nDefaultTimeOut: DWORD,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "CreateNamedPipeA".}
-proc GetNamedPipeHandleStateA*(hNamedPipe: HANDLE, lpState: LPDWORD,
-                               lpCurInstances: LPDWORD,
-                               lpMaxCollectionCount: LPDWORD,
-                               lpCollectDataTimeout: LPDWORD, lpUserName: LPSTR,
-                               nMaxUserNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetNamedPipeHandleStateA".}
-proc CallNamedPipeA*(lpNamedPipeName: LPCSTR, lpInBuffer: LPVOID,
-                     nInBufferSize: DWORD, lpOutBuffer: LPVOID,
-                     nOutBufferSize: DWORD, lpBytesRead: LPDWORD,
-                     nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CallNamedPipeA".}
-proc WaitNamedPipeA*(lpNamedPipeName: LPCSTR, nTimeOut: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WaitNamedPipeA".}
-proc SetVolumeLabelA*(lpRootPathName: LPCSTR, lpVolumeName: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetVolumeLabelA".}
-proc GetVolumeInformationA*(lpRootPathName: LPCSTR, lpVolumeNameBuffer: LPSTR,
-                            nVolumeNameSize: DWORD,
-                            lpVolumeSerialNumber: LPDWORD,
-                            lpMaximumComponentLength: LPDWORD,
-                            lpFileSystemFlags: LPDWORD,
-                            lpFileSystemNameBuffer: LPSTR,
-                            nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVolumeInformationA".}
-proc ClearEventLogA*(hEventLog: HANDLE, lpBackupFileName: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ClearEventLogA".}
-proc BackupEventLogA*(hEventLog: HANDLE, lpBackupFileName: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "BackupEventLogA".}
-proc OpenEventLogA*(lpUNCServerName: LPCSTR, lpSourceName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "OpenEventLogA".}
-proc RegisterEventSourceA*(lpUNCServerName: LPCSTR, lpSourceName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "RegisterEventSourceA".}
-proc OpenBackupEventLogA*(lpUNCServerName: LPCSTR, lpFileName: LPCSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "OpenBackupEventLogA".}
-proc ReadEventLogA*(hEventLog: HANDLE, dwReadFlags: DWORD,
-                    dwRecordOffset: DWORD, lpBuffer: LPVOID,
-                    nNumberOfBytesToRead: DWORD, pnBytesRead: LPDWORD,
-                    pnMinNumberOfBytesNeeded: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ReadEventLogA".}
-proc ReportEventA*(hEventLog: HANDLE, wType: int16, wCategory: int16,
-                   dwEventID: DWORD, lpUserSid: PSID, wNumStrings: int16,
-                   dwDataSize: DWORD, lpStrings: LPPCSTR, lpRawData: LPVOID): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ReportEventA".}
-proc AccessCheckAndAuditAlarmA*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                                ObjectTypeName: LPSTR, ObjectName: LPSTR,
-                                SecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                DesiredAccess: DWORD,
-                                GenericMapping: PGENERIC_MAPPING,
-                                ObjectCreation: WINBOOL, GrantedAccess: LPDWORD,
-                                AccessStatus: LPBOOL, pfGenerateOnClose: LPBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AccessCheckAndAuditAlarmA".}
-proc ObjectOpenAuditAlarmA*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                            ObjectTypeName: LPSTR, ObjectName: LPSTR,
-                            pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                            ClientToken: HANDLE, DesiredAccess: DWORD,
-                            GrantedAccess: DWORD, Privileges: PPRIVILEGE_SET,
-                            ObjectCreation: WINBOOL, AccessGranted: WINBOOL,
-                            GenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".}
-proc ObjectPrivilegeAuditAlarmA*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                                 ClientToken: HANDLE, DesiredAccess: DWORD,
-                                 Privileges: PPRIVILEGE_SET,
-                                 AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".}
-proc ObjectCloseAuditAlarmA*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                             GenerateOnClose: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectCloseAuditAlarmA".}
-proc PrivilegedServiceAuditAlarmA*(SubsystemName: LPCSTR, ServiceName: LPCSTR,
-                                   ClientToken: HANDLE,
-                                   Privileges: PPRIVILEGE_SET,
-                                   AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".}
-proc SetFileSecurityA*(lpFileName: LPCSTR,
-                       SecurityInformation: SECURITY_INFORMATION,
-                       pSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetFileSecurityA".}
-proc GetFileSecurityA*(lpFileName: LPCSTR,
-                       RequestedInformation: SECURITY_INFORMATION,
-                       pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                       nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetFileSecurityA".}
-proc FindFirstChangeNotificationA*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,
-                                   dwNotifyFilter: DWORD): HANDLE{.stdcall,
-    dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}
-proc IsBadStringPtrA*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsBadStringPtrA".}
-proc LookupAccountSidA*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,
-                        cbName: LPDWORD, ReferencedDomainName: LPSTR,
-                        cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupAccountSidA".}
-proc LookupAccountNameA*(lpSystemName: LPCSTR, lpAccountName: LPCSTR, Sid: PSID,
-                         cbSid: LPDWORD, ReferencedDomainName: LPSTR,
-                         cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupAccountNameA".}
-proc LookupPrivilegeValueA*(lpSystemName: LPCSTR, lpName: LPCSTR, lpLuid: PLUID): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupPrivilegeValueA".}
-proc LookupPrivilegeNameA*(lpSystemName: LPCSTR, lpLuid: PLUID, lpName: LPSTR,
-                           cbName: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeNameA".}
-proc LookupPrivilegeDisplayNameA*(lpSystemName: LPCSTR, lpName: LPCSTR,
-                                  lpDisplayName: LPSTR, cbDisplayName: LPDWORD,
-                                  lpLanguageId: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameA".}
-proc BuildCommDCBA*(lpDef: LPCSTR, lpDCB: LPDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "BuildCommDCBA".}
-proc BuildCommDCBAndTimeoutsA*(lpDef: LPCSTR, lpDCB: LPDCB,
-                               lpCommTimeouts: LPCOMMTIMEOUTS): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".}
-proc CommConfigDialogA*(lpszName: LPCSTR, hWnd: HWND, lpCC: LPCOMMCONFIG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".}
-proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: LPCOMMCONFIG,
-                            lpdwSize: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDefaultCommConfigA".}
-proc SetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: LPCOMMCONFIG, dwSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetDefaultCommConfigA".}
-proc GetComputerNameA*(lpBuffer: LPSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetComputerNameA".}
-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,
-    dynlib: "user32", importc: "LoadKeyboardLayoutA".}
-proc GetKeyboardLayoutNameA*(pwszKLID: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetKeyboardLayoutNameA".}
-proc CreateDesktopA*(lpszDesktop: LPSTR, lpszDevice: LPSTR, pDevmode: LPDEVMODE,
-                     dwFlags: DWORD, dwDesiredAccess: DWORD,
-                     lpsa: LPSECURITY_ATTRIBUTES): HDESK{.stdcall,
-    dynlib: "user32", importc: "CreateDesktopA".}
-proc OpenDesktopA*(lpszDesktop: LPSTR, dwFlags: DWORD, fInherit: WINBOOL,
-                   dwDesiredAccess: DWORD): HDESK{.stdcall, dynlib: "user32",
-    importc: "OpenDesktopA".}
-proc EnumDesktopsA*(hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROC,
-                    lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "EnumDesktopsA".}
-proc CreateWindowStationA*(lpwinsta: LPSTR, dwReserved: DWORD,
-                           dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HWINSTA{.
-    stdcall, dynlib: "user32", importc: "CreateWindowStationA".}
-proc OpenWindowStationA*(lpszWinSta: LPSTR, fInherit: WINBOOL,
-                         dwDesiredAccess: DWORD): HWINSTA{.stdcall,
-    dynlib: "user32", importc: "OpenWindowStationA".}
-proc EnumWindowStationsA*(lpEnumFunc: ENUMWINDOWSTATIONPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumWindowStationsA".}
-proc GetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".}
-proc SetUserObjectInformationA*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                nLength: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetUserObjectInformationA".}
-proc RegisterWindowMessageA*(lpString: LPCSTR): UINT{.stdcall, dynlib: "user32",
-    importc: "RegisterWindowMessageA".}
-proc GetMessageA*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetMessageA".}
-proc DispatchMessageA*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",
-    importc: "DispatchMessageA".}
-proc PeekMessageA*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "PeekMessageA".}
-proc SendMessageA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageA".}
-proc SendMessageTimeoutA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM,
-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}
-proc SendNotifyMessageA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}
-proc SendMessageCallbackA*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                           lParam: LPARAM, lpResultCallBack: SENDASYNCPROC,
-                           dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SendMessageCallbackA".}
-proc PostMessageA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "PostMessageA".}
-proc PostThreadMessageA*(idThread: DWORD, Msg: UINT, wParam: WPARAM,
-                         lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "PostThreadMessageA".}
-proc DefWindowProcA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-    stdcall, dynlib: "user32", importc: "DefWindowProcA".}
-proc CallWindowProcA*(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT,
-                      wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-    dynlib: "user32", importc: "CallWindowProcA".}
-proc RegisterClassA*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassA".}
-proc UnregisterClassA*(lpClassName: LPCSTR, hInstance: HINST): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "UnregisterClassA".}
-proc GetClassInfoA*(hInstance: HINST, lpClassName: LPCSTR,
-                    lpWndClass: LPWNDCLASS): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetClassInfoA".}
-proc RegisterClassExA*(para1: LPWNDCLASSEX): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassExA".}
-proc GetClassInfoExA*(para1: HINST, para2: LPCSTR, para3: LPWNDCLASSEX): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetClassInfoExA".}
-proc CreateWindowExA*(dwExStyle: DWORD, lpClassName: LPCSTR,
-                      lpWindowName: LPCSTR, dwStyle: DWORD, X: int32, Y: int32,
-                      nWidth: int32, nHeight: int32, hWndParent: HWND,
-                      hMenu: HMENU, hInstance: HINST, lpParam: LPVOID): HWND{.
-    stdcall, dynlib: "user32", importc: "CreateWindowExA".}
-proc CreateDialogParamA*(hInstance: HINST, lpTemplateName: LPCSTR,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC,
-                         dwInitParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-    importc: "CreateDialogParamA".}
-proc CreateDialogIndirectParamA*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                                 hWndParent: HWND, lpDialogFunc: DLGPROC,
-                                 dwInitParam: LPARAM): HWND{.stdcall,
-    dynlib: "user32", importc: "CreateDialogIndirectParamA".}
-proc DialogBoxParamA*(hInstance: HINST, lpTemplateName: LPCSTR,
-                      hWndParent: HWND, lpDialogFunc: DLGPROC,
-                      dwInitParam: LPARAM): int32{.stdcall, dynlib: "user32",
-    importc: "DialogBoxParamA".}
-proc DialogBoxIndirectParamA*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                              hWndParent: HWND, lpDialogFunc: DLGPROC,
-                              dwInitParam: LPARAM): int32{.stdcall,
-    dynlib: "user32", importc: "DialogBoxIndirectParamA".}
-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",
-    importc: "GetDlgItemTextA".}
-proc SendDlgItemMessageA*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,
-                          wParam: WPARAM, lParam: LPARAM): LONG{.stdcall,
-    dynlib: "user32", importc: "SendDlgItemMessageA".}
-proc DefDlgProcA*(hDlg: HWND, Msg: UINT, wParam: WPARAM, lParam: 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,
-    dynlib: "user32", importc: "RegisterClipboardFormatA".}
-proc GetClipboardFormatNameA*(format: UINT, lpszFormatName: LPSTR,
-                              cchMaxCount: int32): int32{.stdcall,
-    dynlib: "user32", importc: "GetClipboardFormatNameA".}
-proc CharToOemA*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CharToOemA".}
-proc OemToCharA*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "OemToCharA".}
-proc CharToOemBuffA*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "CharToOemBuffA".}
-proc OemToCharBuffA*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "OemToCharBuffA".}
-proc CharUpperA*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                      importc: "CharUpperA".}
-proc CharUpperBuffA*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharUpperBuffA".}
-proc CharLowerA*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                      importc: "CharLowerA".}
-proc CharLowerBuffA*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharLowerBuffA".}
-proc CharNextA*(lpsz: LPCSTR): LPSTR{.stdcall, dynlib: "user32",
-                                      importc: "CharNextA".}
-proc CharPrevA*(lpszStart: LPCSTR, lpszCurrent: LPCSTR): LPSTR{.stdcall,
-    dynlib: "user32", importc: "CharPrevA".}
-proc IsCharAlphaA*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                       importc: "IsCharAlphaA".}
-proc IsCharAlphaNumericA*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsCharAlphaNumericA".}
-proc IsCharUpperA*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                       importc: "IsCharUpperA".}
-proc IsCharLowerA*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                       importc: "IsCharLowerA".}
-proc GetKeyNameTextA*(lParam: LONG, lpString: LPSTR, nSize: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetKeyNameTextA".}
-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,
-    dynlib: "user32", importc: "MapVirtualKeyA".}
-proc MapVirtualKeyExA*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,
-    dynlib: "user32", importc: "MapVirtualKeyExA".}
-proc LoadAcceleratorsA*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.stdcall,
-    dynlib: "user32", importc: "LoadAcceleratorsA".}
-proc CreateAcceleratorTableA*(para1: LPACCEL, para2: int32): HACCEL{.stdcall,
-    dynlib: "user32", importc: "CreateAcceleratorTableA".}
-proc CopyAcceleratorTableA*(hAccelSrc: HACCEL, lpAccelDst: LPACCEL,
-                            cAccelEntries: int32): int32{.stdcall,
-    dynlib: "user32", importc: "CopyAcceleratorTableA".}
-proc TranslateAcceleratorA*(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG): int32{.
-    stdcall, dynlib: "user32", importc: "TranslateAcceleratorA".}
-proc LoadMenuA*(hInstance: HINST, lpMenuName: LPCSTR): HMENU{.stdcall,
-    dynlib: "user32", importc: "LoadMenuA".}
-proc LoadMenuIndirectA*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,
-    dynlib: "user32", importc: "LoadMenuIndirectA".}
-proc ChangeMenuA*(hMenu: HMENU, cmd: UINT, lpszNewItem: LPCSTR, cmdInsert: UINT,
-                  flags: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ChangeMenuA".}
-proc GetMenuStringA*(hMenu: HMENU, uIDItem: UINT, lpString: LPSTR,
-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,
-    dynlib: "user32", importc: "GetMenuStringA".}
-proc InsertMenuA*(hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "InsertMenuA".}
-proc AppendMenuA*(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "AppendMenuA".}
-proc ModifyMenuA*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ModifyMenuA".}
-proc InsertMenuItemA*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                      para4: LPCMENUITEMINFO): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "InsertMenuItemA".}
-proc GetMenuItemInfoA*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                       para4: LPMENUITEMINFO): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetMenuItemInfoA".}
-proc SetMenuItemInfoA*(para1: HMENU, para2: UINT, 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",
-                                       importc: "DrawTextA".}
-proc DrawTextExA*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,
-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,
-    dynlib: "user32", importc: "DrawTextExA".}
-proc GrayStringA*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
-                  lpData: LPARAM, nCount: int32, X: int32, Y: int32,
-                  nWidth: int32, nHeight: int32): WINBOOL{.stdcall,
-    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,
-    dynlib: "user32", importc: "DrawStateA".}
-proc TabbedTextOutA*(hDC: HDC, X: int32, Y: int32, lpString: LPCSTR,
-                     nCount: int32, nTabPositions: int32,
-                     lpnTabStopPositions: LPINT, nTabOrigin: int32): LONG{.
-    stdcall, dynlib: "user32", importc: "TabbedTextOutA".}
-proc GetTabbedTextExtentA*(hDC: HDC, lpString: LPCSTR, nCount: int32,
-                           nTabPositions: int32, lpnTabStopPositions: LPINT): DWORD{.
-    stdcall, dynlib: "user32", importc: "GetTabbedTextExtentA".}
-proc SetPropA*(hWnd: HWND, lpString: LPCSTR, hData: HANDLE): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetPropA".}
-proc GetPropA*(hWnd: HWND, lpString: LPCSTR): HANDLE{.stdcall, dynlib: "user32",
-    importc: "GetPropA".}
-proc RemovePropA*(hWnd: HWND, lpString: LPCSTR): HANDLE{.stdcall,
-    dynlib: "user32", importc: "RemovePropA".}
-proc EnumPropsExA*(hWnd: HWND, lpEnumFunc: PROPENUMPROCEX, lParam: LPARAM): int32{.
-    stdcall, dynlib: "user32", importc: "EnumPropsExA".}
-proc EnumPropsA*(hWnd: HWND, lpEnumFunc: PROPENUMPROC): int32{.stdcall,
-    dynlib: "user32", importc: "EnumPropsA".}
-proc SetWindowTextA*(hWnd: HWND, lpString: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetWindowTextA".}
-proc GetWindowTextA*(hWnd: HWND, lpString: LPSTR, nMaxCount: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetWindowTextA".}
-proc GetWindowTextLengthA*(hWnd: HWND): int32{.stdcall, dynlib: "user32",
-    importc: "GetWindowTextLengthA".}
-proc MessageBoxA*(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT): int32{.
-    stdcall, dynlib: "user32", importc: "MessageBoxA".}
-proc MessageBoxExA*(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,
-                    wLanguageId: int16): int32{.stdcall, dynlib: "user32",
-    importc: "MessageBoxExA".}
-proc MessageBoxIndirectA*(para1: LPMSGBOXPARAMS): int32{.stdcall,
-    dynlib: "user32", importc: "MessageBoxIndirectA".}
-proc GetWindowLongA*(hWnd: HWND, nIndex: int32): LONG{.stdcall,
-    dynlib: "user32", importc: "GetWindowLongA".}
-proc SetWindowLongA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): LONG{.stdcall,
-    dynlib: "user32", importc: "SetWindowLongA".}
-proc GetClassLongA*(hWnd: HWND, nIndex: int32): DWORD{.stdcall,
-    dynlib: "user32", importc: "GetClassLongA".}
-proc SetClassLongA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): DWORD{.stdcall,
-    dynlib: "user32", importc: "SetClassLongA".}
-when defined(cpu64):
-  proc GetWindowLongPtrA*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongPtrA".}
-  proc SetWindowLongPtrA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongPtrA".}
-  proc GetClassLongPtrA*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetClassLongPtrA".}
-  proc SetClassLongPtrA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetClassLongPtrA".}
-else:
-  proc GetWindowLongPtrA*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongA".}
-  proc SetWindowLongPtrA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongA".}
-  proc GetClassLongPtrA*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetClassLongA".}
-  proc SetClassLongPtrA*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetClassLongA".}
-proc FindWindowA*(lpClassName: LPCSTR, lpWindowName: LPCSTR): HWND{.stdcall,
-    dynlib: "user32", importc: "FindWindowA".}
-proc FindWindowExA*(para1: HWND, para2: HWND, para3: LPCSTR, para4: LPCSTR): HWND{.
-    stdcall, dynlib: "user32", importc: "FindWindowExA".}
-proc GetClassNameA*(hWnd: HWND, lpClassName: LPSTR, nMaxCount: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetClassNameA".}
-proc SetWindowsHookExA*(idHook: int32, lpfn: HOOKPROC, hmod: HINST,
-                        dwThreadId: DWORD): HHOOK{.stdcall, dynlib: "user32",
-    importc: "SetWindowsHookExA".}
-proc LoadBitmapA*(hInstance: HINST, lpBitmapName: LPCSTR): HBITMAP{.stdcall,
-    dynlib: "user32", importc: "LoadBitmapA".}
-proc LoadCursorA*(hInstance: HINST, lpCursorName: LPCSTR): HCURSOR{.stdcall,
-    dynlib: "user32", importc: "LoadCursorA".}
-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",
-    importc: "LoadImageA".}
-proc LoadStringA*(hInstance: HINST, uID: UINT, 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,
-    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{.
-    stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}
-proc DlgDirSelectComboBoxExA*(hDlg: HWND, lpString: LPSTR, nCount: int32,
-                              nIDComboBox: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}
-proc DefFrameProcA*(hWnd: HWND, hWndMDIClient: HWND, uMsg: UINT, wParam: WPARAM,
-                    lParam: LPARAM): LRESULT{.stdcall, dynlib: "user32",
-    importc: "DefFrameProcA".}
-proc DefMDIChildProcA*(hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: 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, lParam: LPARAM): HWND{.
-    stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}
-proc WinHelpA*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, 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",
-    importc: "SystemParametersInfoA".}
-proc AddFontResourceA*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",
-    importc: "AddFontResourceA".}
-proc CopyMetaFileA*(para1: HMETAFILE, para2: LPCSTR): HMETAFILE{.stdcall,
-    dynlib: "gdi32", importc: "CopyMetaFileA".}
-proc CreateFontA*(para1: int32, para2: int32, para3: int32, para4: int32,
-                  para5: int32, para6: DWORD, para7: DWORD, para8: DWORD,
-                  para9: DWORD, para10: DWORD, para11: DWORD, para12: DWORD,
-                  para13: DWORD, para14: LPCSTR): HFONT{.stdcall,
-    dynlib: "gdi32", importc: "CreateFontA".}
-proc CreateFontIndirectA*(para1: LPLOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-    importc: "CreateFontIndirectA".}
-proc CreateFontIndirectA*(para1: var LOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-    importc: "CreateFontIndirectA".}
-proc CreateICA*(para1: LPCSTR, para2: LPCSTR, para3: LPCSTR, para4: LPDEVMODE): HDC{.
-    stdcall, dynlib: "gdi32", importc: "CreateICA".}
-proc CreateMetaFileA*(para1: LPCSTR): HDC{.stdcall, dynlib: "gdi32",
-    importc: "CreateMetaFileA".}
-proc CreateScalableFontResourceA*(para1: DWORD, para2: LPCSTR, para3: LPCSTR,
-                                  para4: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "CreateScalableFontResourceA".}
-proc EnumFontFamiliesExA*(para1: HDC, para2: LPLOGFONT, para3: FONTENUMEXPROC,
-                          para4: LPARAM, para5: DWORD): int32{.stdcall,
-    dynlib: "gdi32", importc: "EnumFontFamiliesExA".}
-proc EnumFontFamiliesA*(para1: HDC, para2: LPCSTR, para3: FONTENUMPROC,
-                        para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-    importc: "EnumFontFamiliesA".}
-proc EnumFontsA*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: LPARAM): int32{.
-    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{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}
-proc GetCharWidth32A*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}
-proc GetCharWidthFloatA*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}
-proc GetCharABCWidthsA*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}
-proc GetCharABCWidthsFloatA*(para1: HDC, para2: UINT, para3: UINT,
-                             para4: LPABCFLOAT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}
-proc GetGlyphOutlineA*(para1: HDC, para2: UINT, para3: UINT,
-                       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{.
-    stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}
-proc GetTextExtentPointA*(para1: HDC, para2: LPCSTR, para3: int32, para4: LPSIZE): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".}
-proc GetTextExtentPoint32A*(para1: HDC, para2: LPCSTR, para3: int32,
-                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentPoint32A".}
-proc GetTextExtentExPointA*(para1: HDC, para2: LPCSTR, para3: int32,
-                            para4: int32, para5: LPINT, para6: LPINT,
-                            para7: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentExPointA".}
-proc GetCharacterPlacementA*(para1: HDC, para2: LPCSTR, para3: int32,
-                             para4: int32, para5: LPGCP_RESULTS, para6: DWORD): DWORD{.
-    stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementA".}
-proc ResetDCA*(para1: HDC, para2: LPDEVMODE): HDC{.stdcall, dynlib: "gdi32",
-    importc: "ResetDCA".}
-proc RemoveFontResourceA*(para1: LPCSTR): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "RemoveFontResourceA".}
-proc CopyEnhMetaFileA*(para1: HENHMETAFILE, para2: LPCSTR): HENHMETAFILE{.
-    stdcall, dynlib: "gdi32", importc: "CopyEnhMetaFileA".}
-proc CreateEnhMetaFileA*(para1: HDC, para2: LPCSTR, para3: LPRECT, para4: LPCSTR): HDC{.
-    stdcall, dynlib: "gdi32", importc: "CreateEnhMetaFileA".}
-proc GetEnhMetaFileA*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",
-    importc: "GetEnhMetaFileA".}
-proc GetEnhMetaFileDescriptionA*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.
-    stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}
-proc GetTextMetricsA*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetTextMetricsA".}
-proc StartDocA*(para1: HDC, para2: PDOCINFO): int32{.stdcall, dynlib: "gdi32",
-    importc: "StartDocA".}
-proc GetObjectA*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
-    dynlib: "gdi32", importc: "GetObjectA".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}
-proc PolyTextOutA*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}
-proc GetTextFaceA*(para1: HDC, para2: int32, para3: LPSTR): int32{.stdcall,
-    dynlib: "gdi32", importc: "GetTextFaceA".}
-proc GetKerningPairsA*(para1: HDC, para2: DWORD, para3: LPKERNINGPAIR): DWORD{.
-    stdcall, dynlib: "gdi32", importc: "GetKerningPairsA".}
-proc CreateColorSpaceA*(para1: LPLOGCOLORSPACE): HCOLORSPACE{.stdcall,
-    dynlib: "gdi32", importc: "CreateColorSpaceA".}
-proc GetLogColorSpaceA*(para1: HCOLORSPACE, para2: LPLOGCOLORSPACE, para3: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetLogColorSpaceA".}
-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{.
-    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{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}
-proc CreateStatusWindowA*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,
-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",
-    importc: "CreateStatusWindowA".}
-proc DrawStatusTextA*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.
-    stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}
-proc GetOpenFileNameA*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "GetOpenFileNameA".}
-proc GetSaveFileNameA*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "GetSaveFileNameA".}
-proc GetFileTitleA*(para1: LPCSTR, para2: LPSTR, para3: int16): int{.stdcall,
-    dynlib: "comdlg32", importc: "GetFileTitleA".}
-proc ChooseColorA*(para1: LPCHOOSECOLOR): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "ChooseColorA".}
-proc FindTextA*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-    importc: "FindTextA".}
-proc ReplaceTextA*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-    importc: "ReplaceTextA".}
-proc ChooseFontA*(para1: LPCHOOSEFONT): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "ChooseFontA".}
-proc PrintDlgA*(para1: LPPRINTDLG): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "PrintDlgA".}
-proc PageSetupDlgA*(para1: LPPAGESETUPDLG): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "PageSetupDlgA".}
-proc CreateProcessA*(lpApplicationName: LPCSTR, lpCommandLine: LPSTR,
-                     lpProcessAttributes: LPSECURITY_ATTRIBUTES,
-                     lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                     bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                     lpEnvironment: LPVOID, lpCurrentDirectory: LPCSTR,
-                     lpStartupInfo: LPSTARTUPINFO,
-                     lpProcessInformation: LPPROCESS_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
-proc GetStartupInfoA*(lpStartupInfo: LPSTARTUPINFO){.stdcall,
-    dynlib: "kernel32", importc: "GetStartupInfoA".}
-proc FindFirstFileA*(lpFileName: LPCSTR, lpFindFileData: LPWIN32_FIND_DATA): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
-proc FindNextFileA*(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATA): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
-proc GetVersionExA*(VersionInformation: LPOSVERSIONINFO): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVersionExA".}
-proc CreateWindowA*(lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD,
-                    X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                    hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                    lpParam: LPVOID): HWND
-proc CreateDialogA*(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                    lpDialogFunc: DLGPROC): HWND
-proc CreateDialogIndirectA*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                            hWndParent: HWND, lpDialogFunc: DLGPROC): HWND
-proc DialogBoxA*(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                 lpDialogFunc: DLGPROC): int32
-proc DialogBoxIndirectA*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC): int32
-proc CreateDCA*(para1: LPCSTR, para2: LPCSTR, para3: LPCSTR, para4: pDEVMODE): HDC{.
-    stdcall, dynlib: "gdi32", importc: "CreateDCA".}
-proc VerInstallFileA*(uFlags: DWORD, szSrcFileName: LPSTR,
-                      szDestFileName: LPSTR, szSrcDir: LPSTR, szDestDir: LPSTR,
-                      szCurDir: LPSTR, szTmpFile: LPSTR, lpuTmpFileLen: PUINT): DWORD{.
-    stdcall, dynlib: "version", importc: "VerInstallFileA".}
-proc GetFileVersionInfoSizeA*(lptstrFilename: LPSTR, lpdwHandle: LPDWORD): DWORD{.
-    stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeA".}
-proc GetFileVersionInfoA*(lptstrFilename: LPSTR, dwHandle: DWORD, dwLen: DWORD,
-                          lpData: LPVOID): WINBOOL{.stdcall, dynlib: "version",
-    importc: "GetFileVersionInfoA".}
-proc VerLanguageNameA*(wLang: DWORD, szLang: LPSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "VerLanguageNameA".}
-proc VerQueryValueA*(pBlock: LPVOID, lpSubBlock: LPSTR, lplpBuffer: LPVOID,
-                     puLen: PUINT): WINBOOL{.stdcall, dynlib: "version",
-    importc: "VerQueryValueA".}
-proc VerFindFileA*(uFlags: DWORD, szFileName: LPSTR, szWinDir: LPSTR,
-                   szAppDir: LPSTR, szCurDir: LPSTR, lpuCurDirLen: PUINT,
-                   szDestDir: LPSTR, lpuDestDirLen: PUINT): DWORD{.stdcall,
-    dynlib: "version", importc: "VerFindFileA".}
-proc RegConnectRegistryA*(lpMachineName: LPSTR, hKey: HKEY, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegConnectRegistryA".}
-proc RegCreateKeyA*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyA".}
-proc RegCreateKeyExA*(hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD,
-                      lpClass: LPSTR, dwOptions: DWORD, samDesired: REGSAM,
-                      lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                      phkResult: PHKEY, lpdwDisposition: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyExA".}
-proc RegDeleteKeyA*(hKey: HKEY, lpSubKey: LPCSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegDeleteKeyA".}
-proc RegDeleteValueA*(hKey: HKEY, lpValueName: LPCSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegDeleteValueA".}
-proc RegEnumKeyA*(hKey: HKEY, dwIndex: DWORD, lpName: LPSTR, cbName: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyA".}
-proc RegEnumKeyExA*(hKey: HKEY, dwIndex: DWORD, lpName: LPSTR,
-                    lpcbName: LPDWORD, lpReserved: LPDWORD, lpClass: LPSTR,
-                    lpcbClass: LPDWORD, lpftLastWriteTime: PFILETIME): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyExA".}
-proc RegEnumValueA*(hKey: HKEY, dwIndex: DWORD, lpValueName: LPSTR,
-                    lpcbValueName: LPDWORD, lpReserved: LPDWORD,
-                    lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumValueA".}
-proc RegLoadKeyA*(hKey: HKEY, lpSubKey: LPCSTR, lpFile: LPCSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegLoadKeyA".}
-proc RegOpenKeyA*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegOpenKeyA".}
-proc RegOpenKeyExA*(hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD,
-                    samDesired: REGSAM, phkResult: PHKEY): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegOpenKeyExA".}
-proc RegQueryInfoKeyA*(hKey: HKEY, lpClass: LPSTR, lpcbClass: LPDWORD,
-                       lpReserved: LPDWORD, lpcSubKeys: LPDWORD,
-                       lpcbMaxSubKeyLen: LPDWORD, lpcbMaxClassLen: LPDWORD,
-                       lpcValues: LPDWORD, lpcbMaxValueNameLen: LPDWORD,
-                       lpcbMaxValueLen: LPDWORD,
-                       lpcbSecurityDescriptor: LPDWORD,
-                       lpftLastWriteTime: PFILETIME): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegQueryInfoKeyA".}
-proc RegQueryValueA*(hKey: HKEY, lpSubKey: LPCSTR, lpValue: LPSTR,
-                     lpcbValue: PLONG): LONG{.stdcall, dynlib: "advapi32",
-    importc: "RegQueryValueA".}
-proc RegQueryMultipleValuesA*(hKey: HKEY, val_list: PVALENT, num_vals: DWORD,
-                              lpValueBuf: LPSTR, ldwTotsize: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesA".}
-proc RegQueryValueExA*(hKey: HKEY, lpValueName: LPCSTR, lpReserved: LPDWORD,
-                       lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryValueExA".}
-proc RegReplaceKeyA*(hKey: HKEY, lpSubKey: LPCSTR, lpNewFile: LPCSTR,
-                     lpOldFile: LPCSTR): LONG{.stdcall, dynlib: "advapi32",
-    importc: "RegReplaceKeyA".}
-proc RegRestoreKeyA*(hKey: HKEY, lpFile: LPCSTR, dwFlags: DWORD): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegRestoreKeyA".}
-proc RegSaveKeyA*(hKey: HKEY, lpFile: LPCSTR,
-                  lpSecurityAttributes: LPSECURITY_ATTRIBUTES): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegSaveKeyA".}
-proc RegSetValueA*(hKey: HKEY, lpSubKey: LPCSTR, dwType: DWORD, lpData: LPCSTR,
-                   cbData: DWORD): LONG{.stdcall, dynlib: "advapi32",
-    importc: "RegSetValueA".}
-proc RegSetValueExA*(hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD,
-                     dwType: DWORD, lpData: LPBYTE, cbData: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetValueExA".}
-proc RegUnLoadKeyA*(hKey: HKEY, lpSubKey: LPCSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegUnLoadKeyA".}
-proc InitiateSystemShutdownA*(lpMachineName: LPSTR, lpMessage: LPSTR,
-                              dwTimeout: DWORD, bForceAppsClosed: WINBOOL,
-                              bRebootAfterShutdown: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "InitiateSystemShutdownA".}
-proc AbortSystemShutdownA*(lpMachineName: LPSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AbortSystemShutdownA".}
-proc CompareStringA*(Locale: LCID, dwCmpFlags: DWORD, lpString1: LPCSTR,
-                     cchCount1: int32, lpString2: LPCSTR, cchCount2: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "CompareStringA".}
-proc LCMapStringA*(Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCSTR,
-                   cchSrc: int32, lpDestStr: LPSTR, cchDest: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "LCMapStringA".}
-proc GetLocaleInfoA*(Locale: LCID, LCType: LCTYPE, lpLCData: LPSTR,
-                     cchData: int32): int32{.stdcall, dynlib: "kernel32",
-    importc: "GetLocaleInfoA".}
-proc SetLocaleInfoA*(Locale: LCID, LCType: LCTYPE, lpLCData: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetLocaleInfoA".}
-proc GetTimeFormatA*(Locale: LCID, dwFlags: DWORD, lpTime: LPSYSTEMTIME,
-                     lpFormat: LPCSTR, lpTimeStr: LPSTR, cchTime: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "GetTimeFormatA".}
-proc GetDateFormatA*(Locale: LCID, dwFlags: DWORD, lpDate: LPSYSTEMTIME,
-                     lpFormat: LPCSTR, lpDateStr: LPSTR, cchDate: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "GetDateFormatA".}
-proc GetNumberFormatA*(Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR,
-                       lpFormat: PNUMBERFMT, lpNumberStr: LPSTR,
-                       cchNumber: int32): int32{.stdcall, dynlib: "kernel32",
-    importc: "GetNumberFormatA".}
-proc GetCurrencyFormatA*(Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR,
-                         lpFormat: PCURRENCYFMT, lpCurrencyStr: LPSTR,
-                         cchCurrency: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "GetCurrencyFormatA".}
-proc EnumCalendarInfoA*(lpCalInfoEnumProc: CALINFO_ENUMPROC, Locale: LCID,
-                        Calendar: CALID, CalType: CALTYPE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "EnumCalendarInfoA".}
-proc EnumTimeFormatsA*(lpTimeFmtEnumProc: TIMEFMT_ENUMPROC, Locale: LCID,
-                       dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "EnumTimeFormatsA".}
-proc EnumDateFormatsA*(lpDateFmtEnumProc: DATEFMT_ENUMPROC, Locale: LCID,
-                       dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "EnumDateFormatsA".}
-proc GetStringTypeExA*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                       cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeExA".}
-proc GetStringTypeA*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                     cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeA".}
-proc FoldStringA*(dwMapFlags: DWORD, lpSrcStr: LPCSTR, cchSrc: int32,
-                  lpDestStr: LPSTR, cchDest: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "FoldStringA".}
-proc EnumSystemLocalesA*(lpLocaleEnumProc: LOCALE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumSystemLocalesA".}
-proc EnumSystemCodePagesA*(lpCodePageEnumProc: CODEPAGE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumSystemCodePagesA".}
-proc PeekConsoleInputA*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                        nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".}
-proc ReadConsoleInputA*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                        nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".}
-proc WriteConsoleInputA*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".}
-proc ReadConsoleOutputA*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                         dwBufferSize: COORD, dwBufferCoord: COORD,
-                         lpReadRegion: PSMALL_RECT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadConsoleOutputA".}
-proc WriteConsoleOutputA*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                          dwBufferSize: COORD, dwBufferCoord: COORD,
-                          lpWriteRegion: PSMALL_RECT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteConsoleOutputA".}
-proc ReadConsoleOutputCharacterA*(hConsoleOutput: HANDLE, lpCharacter: LPSTR,
-                                  nLength: DWORD, dwReadCoord: COORD,
-                                  lpNumberOfCharsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".}
-proc WriteConsoleOutputCharacterA*(hConsoleOutput: HANDLE, lpCharacter: LPCSTR,
-                                   nLength: DWORD, dwWriteCoord: COORD,
-                                   lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".}
-proc FillConsoleOutputCharacterA*(hConsoleOutput: HANDLE, cCharacter: CHAR,
-                                  nLength: DWORD, dwWriteCoord: COORD,
-                                  lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".}
-proc ScrollConsoleScreenBufferA*(hConsoleOutput: HANDLE,
-                                 lpScrollRectangle: PSMALL_RECT,
-                                 lpClipRectangle: PSMALL_RECT,
-                                 dwDestinationOrigin: COORD, lpFill: PCHAR_INFO): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".}
-proc GetConsoleTitleA*(lpConsoleTitle: LPSTR, nSize: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetConsoleTitleA".}
-proc SetConsoleTitleA*(lpConsoleTitle: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleTitleA".}
-proc ReadConsoleA*(hConsoleInput: HANDLE, lpBuffer: LPVOID,
-                   nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD,
-                   lpReserved: LPVOID): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReadConsoleA".}
-proc WriteConsoleA*(hConsoleOutput: HANDLE, lpBuffer: pointer,
-                    nNumberOfCharsToWrite: DWORD,
-                    lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleA".}
-proc WNetAddConnectionA*(lpRemoteName: LPCSTR, lpPassword: LPCSTR,
-                         lpLocalName: LPCSTR): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetAddConnectionA".}
-proc WNetAddConnection2A*(lpNetResource: LPNETRESOURCE, lpPassword: LPCSTR,
-                          lpUserName: LPCSTR, dwFlags: DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetAddConnection2A".}
-proc WNetAddConnection3A*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                          lpPassword: LPCSTR, lpUserName: LPCSTR, dwFlags: DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetAddConnection3A".}
-proc WNetCancelConnectionA*(lpName: LPCSTR, fForce: WINBOOL): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetCancelConnectionA".}
-proc WNetCancelConnection2A*(lpName: LPCSTR, dwFlags: DWORD, fForce: WINBOOL): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetCancelConnection2A".}
-proc WNetGetConnectionA*(lpLocalName: LPCSTR, lpRemoteName: LPSTR,
-                         lpnLength: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetConnectionA".}
-proc WNetUseConnectionA*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                         lpUserID: LPCSTR, lpPassword: LPCSTR, dwFlags: DWORD,
-                         lpAccessName: LPSTR, lpBufferSize: LPDWORD,
-                         lpResult: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetUseConnectionA".}
-proc WNetSetConnectionA*(lpName: LPCSTR, dwProperties: DWORD, pvValues: LPVOID): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetSetConnectionA".}
-proc WNetConnectionDialog1A*(lpConnDlgStruct: LPCONNECTDLGSTRUCT): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".}
-proc WNetDisconnectDialog1A*(lpConnDlgStruct: LPDISCDLGSTRUCT): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetDisconnectDialog1A".}
-proc WNetOpenEnumA*(dwScope: DWORD, dwType: DWORD, dwUsage: DWORD,
-                    lpNetResource: LPNETRESOURCE, lphEnum: LPHANDLE): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetOpenEnumA".}
-proc WNetEnumResourceA*(hEnum: HANDLE, lpcCount: LPDWORD, lpBuffer: LPVOID,
-                        lpBufferSize: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetEnumResourceA".}
-proc WNetGetUniversalNameA*(lpLocalPath: LPCSTR, dwInfoLevel: DWORD,
-                            lpBuffer: LPVOID, lpBufferSize: LPDWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameA".}
-proc WNetGetUserA*(lpName: LPCSTR, lpUserName: LPSTR, lpnLength: LPDWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUserA".}
-proc WNetGetProviderNameA*(dwNetType: DWORD, lpProviderName: LPSTR,
-                           lpBufferSize: LPDWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetProviderNameA".}
-proc WNetGetNetworkInformationA*(lpProvider: LPCSTR,
-                                 lpNetInfoStruct: LPNETINFOSTRUCT): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".}
-proc WNetGetLastErrorA*(lpError: LPDWORD, lpErrorBuf: LPSTR,
-                        nErrorBufSize: DWORD, lpNameBuf: LPSTR,
-                        nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetLastErrorA".}
-proc MultinetGetConnectionPerformanceA*(lpNetResource: LPNETRESOURCE,
-    lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT): DWORD{.stdcall,
-    dynlib: "mpr", importc: "MultinetGetConnectionPerformanceA".}
-proc ChangeServiceConfigA*(hService: SC_HANDLE, dwServiceType: DWORD,
-                           dwStartType: DWORD, dwErrorControl: DWORD,
-                           lpBinaryPathName: LPCSTR, lpLoadOrderGroup: LPCSTR,
-                           lpdwTagId: LPDWORD, lpDependencies: LPCSTR,
-                           lpServiceStartName: LPCSTR, lpPassword: LPCSTR,
-                           lpDisplayName: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ChangeServiceConfigA".}
-proc CreateServiceA*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                     lpDisplayName: LPCSTR, dwDesiredAccess: DWORD,
-                     dwServiceType: DWORD, dwStartType: DWORD,
-                     dwErrorControl: DWORD, lpBinaryPathName: LPCSTR,
-                     lpLoadOrderGroup: LPCSTR, lpdwTagId: LPDWORD,
-                     lpDependencies: LPCSTR, lpServiceStartName: LPCSTR,
-                     lpPassword: LPCSTR): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "CreateServiceA".}
-proc EnumDependentServicesA*(hService: SC_HANDLE, dwServiceState: DWORD,
-                             lpServices: LPENUM_SERVICE_STATUS,
-                             cbBufSize: DWORD, pcbBytesNeeded: LPDWORD,
-                             lpServicesReturned: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "EnumDependentServicesA".}
-proc EnumServicesStatusA*(hSCManager: SC_HANDLE, dwServiceType: DWORD,
-                          dwServiceState: DWORD,
-                          lpServices: LPENUM_SERVICE_STATUS, cbBufSize: DWORD,
-                          pcbBytesNeeded: LPDWORD, lpServicesReturned: LPDWORD,
-                          lpResumeHandle: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "EnumServicesStatusA".}
-proc GetServiceKeyNameA*(hSCManager: SC_HANDLE, lpDisplayName: LPCSTR,
-                         lpServiceName: LPSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetServiceKeyNameA".}
-proc GetServiceDisplayNameA*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                             lpDisplayName: LPSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetServiceDisplayNameA".}
-proc OpenSCManagerA*(lpMachineName: LPCSTR, lpDatabaseName: LPCSTR,
-                     dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "OpenSCManagerA".}
-proc OpenServiceA*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                   dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "OpenServiceA".}
-proc QueryServiceConfigA*(hService: SC_HANDLE,
-                          lpServiceConfig: LPQUERY_SERVICE_CONFIG,
-                          cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceConfigA".}
-proc QueryServiceLockStatusA*(hSCManager: SC_HANDLE,
-                              lpLockStatus: LPQUERY_SERVICE_LOCK_STATUS,
-                              cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceLockStatusA".}
-proc RegisterServiceCtrlHandlerA*(lpServiceName: LPCSTR,
-                                  lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "RegisterServiceCtrlHandlerA".}
-proc StartServiceCtrlDispatcherA*(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "StartServiceCtrlDispatcherA".}
-proc StartServiceA*(hService: SC_HANDLE, dwNumServiceArgs: DWORD,
-                    lpServiceArgVectors: LPCSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "StartServiceA".}
-proc DragQueryFileA*(para1: HDROP, para2: int, para3: cstring, para4: int): int{.
-    stdcall, dynlib: "shell32", importc: "DragQueryFileA".}
-proc ExtractAssociatedIconA*(para1: HINST, para2: cstring, para3: LPWORD): HICON{.
-    stdcall, dynlib: "shell32", importc: "ExtractAssociatedIconA".}
-proc ExtractIconA*(para1: HINST, para2: cstring, para3: int): HICON{.stdcall,
-    dynlib: "shell32", importc: "ExtractIconA".}
-proc FindExecutableA*(para1: cstring, para2: cstring, para3: cstring): HINST{.
-    stdcall, dynlib: "shell32", importc: "FindExecutableA".}
-proc ShellAboutA*(para1: HWND, para2: cstring, para3: cstring, para4: HICON): int32{.
-    stdcall, dynlib: "shell32", importc: "ShellAboutA".}
-proc ShellExecuteA*(para1: HWND, para2: cstring, para3: cstring, para4: cstring,
-                    para5: cstring, para6: int32): HINST{.stdcall,
-    dynlib: "shell32", importc: "ShellExecuteA".}
-proc Shell_NotifyIconA*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
-    stdcall, dynlib: "shell32", importc: "Shell_NotifyIconA".}
-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",
-    importc: "DdeInitializeA".}
-proc DdeQueryStringA*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,
-                      para5: int32): DWORD{.stdcall, dynlib: "user32",
-    importc: "DdeQueryStringA".}
-proc LogonUserA*(para1: LPSTR, para2: LPSTR, para3: LPSTR, para4: DWORD,
-                 para5: DWORD, para6: PHANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LogonUserA".}
-proc CreateProcessAsUserA*(para1: HANDLE, para2: LPCTSTR, para3: LPTSTR,
-                           para4: LPSECURITY_ATTRIBUTES,
-                           para5: LPSECURITY_ATTRIBUTES, para6: WINBOOL,
-                           para7: DWORD, para8: LPVOID, para9: LPCTSTR,
-                           para10: LPSTARTUPINFO, para11: LPPROCESS_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "CreateProcessAsUserA".}
-proc GetBinaryTypeW*(lpApplicationName: LPCWSTR, lpBinaryType: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetBinaryTypeW".}
-proc GetShortPathNameW*(lpszLongPath: LPCWSTR, lpszShortPath: LPWSTR,
-                        cchBuffer: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetShortPathNameW".}
-proc GetEnvironmentStringsW*(): LPWSTR{.stdcall, dynlib: "kernel32",
-                                        importc: "GetEnvironmentStringsW".}
-proc FreeEnvironmentStringsW*(para1: LPWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FreeEnvironmentStringsW".}
-proc FormatMessageW*(dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD,
-                     dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD,
-                     Arguments: va_list): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "FormatMessageW".}
-proc CreateMailslotW*(lpName: LPCWSTR, nMaxMessageSize: DWORD,
-                      lReadTimeout: DWORD,
-                      lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "CreateMailslotW".}
-proc lstrcmpW*(lpString1: LPCWSTR, lpString2: LPCWSTR): int32{.stdcall,
-    dynlib: "kernel32", importc: "lstrcmpW".}
-proc lstrcmpiW*(lpString1: LPCWSTR, lpString2: LPCWSTR): int32{.stdcall,
-    dynlib: "kernel32", importc: "lstrcmpiW".}
-proc lstrcpynW*(lpString1: LPWSTR, lpString2: LPCWSTR, iMaxLength: int32): LPWSTR{.
-    stdcall, dynlib: "kernel32", importc: "lstrcpynW".}
-proc lstrcpyW*(lpString1: LPWSTR, lpString2: LPCWSTR): LPWSTR{.stdcall,
-    dynlib: "kernel32", importc: "lstrcpyW".}
-proc lstrcatW*(lpString1: LPWSTR, lpString2: LPCWSTR): LPWSTR{.stdcall,
-    dynlib: "kernel32", importc: "lstrcatW".}
-proc lstrlenW*(lpString: LPCWSTR): int32{.stdcall, dynlib: "kernel32",
-    importc: "lstrlenW".}
-proc CreateMutexW*(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
-                   bInitialOwner: WINBOOL, lpName: LPCWSTR): HANDLE{.stdcall,
-    dynlib: "kernel32", importc: "CreateMutexW".}
-proc OpenMutexW*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                 lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "OpenMutexW".}
-proc CreateEventW*(lpEventAttributes: LPSECURITY_ATTRIBUTES,
-                   bManualReset: WINBOOL, bInitialState: WINBOOL,
-                   lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "CreateEventW".}
-proc OpenEventW*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                 lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "OpenEventW".}
-proc CreateSemaphoreW*(lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
-                       lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCWSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "CreateSemaphoreW".}
-proc OpenSemaphoreW*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                     lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "OpenSemaphoreW".}
-proc CreateFileMappingW*(hFile: HANDLE,
-                         lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
-                         flProtect: DWORD, dwMaximumSizeHigh: DWORD,
-                         dwMaximumSizeLow: DWORD, lpName: LPCWSTR): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "CreateFileMappingW".}
-proc OpenFileMappingW*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                       lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "OpenFileMappingW".}
-proc GetLogicalDriveStringsW*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetLogicalDriveStringsW".}
-proc LoadLibraryW*(lpLibFileName: LPCWSTR): HINST{.stdcall, dynlib: "kernel32",
-    importc: "LoadLibraryW".}
-proc LoadLibraryExW*(lpLibFileName: LPCWSTR, hFile: HANDLE, dwFlags: DWORD): HINST{.
-    stdcall, dynlib: "kernel32", importc: "LoadLibraryExW".}
-proc GetModuleFileNameW*(hModule: HINST, lpFilename: LPWSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}
-proc GetModuleHandleW*(lpModuleName: LPCWSTR): HMODULE{.stdcall,
-    dynlib: "kernel32", importc: "GetModuleHandleW".}
-proc FatalAppExitW*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,
-    dynlib: "kernel32", importc: "FatalAppExitW".}
-proc GetCommandLineW*(): LPWSTR{.stdcall, dynlib: "kernel32",
-                                 importc: "GetCommandLineW".}
-proc GetEnvironmentVariableW*(lpName: LPCWSTR, lpBuffer: LPWSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetEnvironmentVariableW".}
-proc SetEnvironmentVariableW*(lpName: LPCWSTR, lpValue: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW".}
-proc ExpandEnvironmentStringsW*(lpSrc: LPCWSTR, lpDst: LPWSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "ExpandEnvironmentStringsW".}
-proc OutputDebugStringW*(lpOutputString: LPCWSTR){.stdcall, dynlib: "kernel32",
-    importc: "OutputDebugStringW".}
-proc FindResourceW*(hModule: HINST, lpName: LPCWSTR, lpType: LPCWSTR): HRSRC{.
-    stdcall, dynlib: "kernel32", importc: "FindResourceW".}
-proc FindResourceExW*(hModule: HINST, lpType: LPCWSTR, lpName: LPCWSTR,
-                      wLanguage: int16): HRSRC{.stdcall, dynlib: "kernel32",
-    importc: "FindResourceExW".}
-proc EnumResourceTypesW*(hModule: HINST, lpEnumFunc: ENUMRESTYPEPROC,
-                         lParam: LONG): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "EnumResourceTypesW".}
-proc EnumResourceNamesW*(hModule: HINST, lpType: LPCWSTR,
-                         lpEnumFunc: ENUMRESNAMEPROC, lParam: LONG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumResourceNamesW".}
-proc EnumResourceLanguagesW*(hModule: HINST, lpType: LPCWSTR, lpName: LPCWSTR,
-                             lpEnumFunc: ENUMRESLANGPROC, lParam: LONG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumResourceLanguagesW".}
-proc BeginUpdateResourceW*(pFileName: LPCWSTR, bDeleteExistingResources: WINBOOL): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "BeginUpdateResourceW".}
-proc UpdateResourceW*(hUpdate: HANDLE, lpType: LPCWSTR, lpName: LPCWSTR,
-                      wLanguage: int16, lpData: LPVOID, cbData: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "UpdateResourceW".}
-proc EndUpdateResourceW*(hUpdate: HANDLE, fDiscard: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "EndUpdateResourceW".}
-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{.
-    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,
-    dynlib: "kernel32", importc: "GetAtomNameW".}
-proc GetProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.
-    stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}
-proc GetProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                        lpDefault: LPCWSTR, lpReturnedString: LPWSTR,
-                        nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetProfileStringW".}
-proc WriteProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                          lpString: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteProfileStringW".}
-proc GetProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
-                         nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetProfileSectionW".}
-proc WriteProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}
-proc GetPrivateProfileIntW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                            nDefault: WINT, lpFileName: LPCWSTR): UINT{.stdcall,
-    dynlib: "kernel32", importc: "GetPrivateProfileIntW".}
-proc GetPrivateProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                               lpDefault: LPCWSTR, lpReturnedString: LPWSTR,
-                               nSize: DWORD, lpFileName: LPCWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStringW".}
-proc WritePrivateProfileStringW*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                                 lpString: LPCWSTR, lpFileName: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStringW".}
-proc GetPrivateProfileSectionW*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
-                                nSize: DWORD, lpFileName: LPCWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileSectionW".}
-proc WritePrivateProfileSectionW*(lpAppName: LPCWSTR, lpString: LPCWSTR,
-                                  lpFileName: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}
-proc GetDriveTypeW*(lpRootPathName: LPCWSTR): UINT{.stdcall, dynlib: "kernel32",
-    importc: "GetDriveTypeW".}
-proc GetSystemDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.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,
-    dynlib: "kernel32", importc: "GetTempFileNameW".}
-proc GetWindowsDirectoryW*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,
-    dynlib: "kernel32", importc: "GetWindowsDirectoryW".}
-proc SetCurrentDirectoryW*(lpPathName: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetCurrentDirectoryW".}
-proc GetCurrentDirectoryW*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetCurrentDirectoryW".}
-proc GetDiskFreeSpaceW*(lpRootPathName: LPCWSTR, lpSectorsPerCluster: LPDWORD,
-                        lpBytesPerSector: LPDWORD,
-                        lpNumberOfFreeClusters: LPDWORD,
-                        lpTotalNumberOfClusters: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDiskFreeSpaceW".}
-proc CreateDirectoryW*(lpPathName: LPCWSTR,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateDirectoryW".}
-proc CreateDirectoryExW*(lpTemplateDirectory: LPCWSTR, lpNewDirectory: LPCWSTR,
-                         lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateDirectoryExW".}
-proc RemoveDirectoryW*(lpPathName: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "RemoveDirectoryW".}
-proc GetFullPathNameW*(lpFileName: LPCWSTR, nBufferLength: DWORD,
-                       lpBuffer: LPWSTR, lpFilePart: var LPWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetFullPathNameW".}
-proc DefineDosDeviceW*(dwFlags: DWORD, lpDeviceName: LPCWSTR,
-                       lpTargetPath: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DefineDosDeviceW".}
-proc QueryDosDeviceW*(lpDeviceName: LPCWSTR, lpTargetPath: LPWSTR,
-                      ucchMax: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "QueryDosDeviceW".}
-proc CreateFileW*(lpFileName: LPCWSTR, dwDesiredAccess: DWORD,
-                  dwShareMode: DWORD,
-                  lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                  dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD,
-                  hTemplateFile: HANDLE): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "CreateFileW".}
-proc SetFileAttributesW*(lpFileName: LPCWSTR, dwFileAttributes: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetFileAttributesW".}
-proc GetFileAttributesW*(lpFileName: LPCWSTR): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetFileAttributesW".}
-proc GetCompressedFileSizeW*(lpFileName: LPCWSTR, lpFileSizeHigh: LPDWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetCompressedFileSizeW".}
-proc DeleteFileW*(lpFileName: LPCWSTR): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "DeleteFileW".}
-proc SearchPathW*(lpPath: LPCWSTR, lpFileName: LPCWSTR, lpExtension: LPCWSTR,
-                  nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: LPWSTR): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "SearchPathW".}
-proc CopyFileW*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR,
-                bFailIfExists: WINBOOL): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CopyFileW".}
-proc MoveFileW*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "MoveFileW".}
-proc MoveFileExW*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR,
-                  dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "MoveFileExW".}
-proc CreateNamedPipeW*(lpName: LPCWSTR, dwOpenMode: DWORD, dwPipeMode: DWORD,
-                       nMaxInstances: DWORD, nOutBufferSize: DWORD,
-                       nInBufferSize: DWORD, nDefaultTimeOut: DWORD,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW".}
-proc GetNamedPipeHandleStateW*(hNamedPipe: HANDLE, lpState: LPDWORD,
-                               lpCurInstances: LPDWORD,
-                               lpMaxCollectionCount: LPDWORD,
-                               lpCollectDataTimeout: LPDWORD,
-                               lpUserName: LPWSTR, nMaxUserNameSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetNamedPipeHandleStateW".}
-proc CallNamedPipeW*(lpNamedPipeName: LPCWSTR, lpInBuffer: LPVOID,
-                     nInBufferSize: DWORD, lpOutBuffer: LPVOID,
-                     nOutBufferSize: DWORD, lpBytesRead: LPDWORD,
-                     nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CallNamedPipeW".}
-proc WaitNamedPipeW*(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WaitNamedPipeW".}
-proc SetVolumeLabelW*(lpRootPathName: LPCWSTR, lpVolumeName: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetVolumeLabelW".}
-proc GetVolumeInformationW*(lpRootPathName: LPCWSTR, lpVolumeNameBuffer: LPWSTR,
-                            nVolumeNameSize: DWORD,
-                            lpVolumeSerialNumber: LPDWORD,
-                            lpMaximumComponentLength: LPDWORD,
-                            lpFileSystemFlags: LPDWORD,
-                            lpFileSystemNameBuffer: LPWSTR,
-                            nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVolumeInformationW".}
-proc ClearEventLogW*(hEventLog: HANDLE, lpBackupFileName: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ClearEventLogW".}
-proc BackupEventLogW*(hEventLog: HANDLE, lpBackupFileName: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "BackupEventLogW".}
-proc OpenEventLogW*(lpUNCServerName: LPCWSTR, lpSourceName: LPCWSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "OpenEventLogW".}
-proc RegisterEventSourceW*(lpUNCServerName: LPCWSTR, lpSourceName: LPCWSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "RegisterEventSourceW".}
-proc OpenBackupEventLogW*(lpUNCServerName: LPCWSTR, lpFileName: LPCWSTR): HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "OpenBackupEventLogW".}
-proc ReadEventLogW*(hEventLog: HANDLE, dwReadFlags: DWORD,
-                    dwRecordOffset: DWORD, lpBuffer: LPVOID,
-                    nNumberOfBytesToRead: DWORD, pnBytesRead: LPDWORD,
-                    pnMinNumberOfBytesNeeded: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ReadEventLogW".}
-proc ReportEventW*(hEventLog: HANDLE, wType: int16, wCategory: int16,
-                   dwEventID: DWORD, lpUserSid: PSID, wNumStrings: int16,
-                   dwDataSize: DWORD, lpStrings: LPPCWSTR, lpRawData: LPVOID): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ReportEventW".}
-proc AccessCheckAndAuditAlarmW*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                                ObjectTypeName: LPWSTR, ObjectName: LPWSTR,
-                                SecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                DesiredAccess: DWORD,
-                                GenericMapping: PGENERIC_MAPPING,
-                                ObjectCreation: WINBOOL, GrantedAccess: LPDWORD,
-                                AccessStatus: LPBOOL, pfGenerateOnClose: LPBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AccessCheckAndAuditAlarmW".}
-proc ObjectOpenAuditAlarmW*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                            ObjectTypeName: LPWSTR, ObjectName: LPWSTR,
-                            pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                            ClientToken: HANDLE, DesiredAccess: DWORD,
-                            GrantedAccess: DWORD, Privileges: PPRIVILEGE_SET,
-                            ObjectCreation: WINBOOL, AccessGranted: WINBOOL,
-                            GenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectOpenAuditAlarmW".}
-proc ObjectPrivilegeAuditAlarmW*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                                 ClientToken: HANDLE, DesiredAccess: DWORD,
-                                 Privileges: PPRIVILEGE_SET,
-                                 AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmW".}
-proc ObjectCloseAuditAlarmW*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                             GenerateOnClose: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectCloseAuditAlarmW".}
-proc PrivilegedServiceAuditAlarmW*(SubsystemName: LPCWSTR, ServiceName: LPCWSTR,
-                                   ClientToken: HANDLE,
-                                   Privileges: PPRIVILEGE_SET,
-                                   AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmW".}
-proc SetFileSecurityW*(lpFileName: LPCWSTR,
-                       SecurityInformation: SECURITY_INFORMATION,
-                       pSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetFileSecurityW".}
-proc GetFileSecurityW*(lpFileName: LPCWSTR,
-                       RequestedInformation: SECURITY_INFORMATION,
-                       pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                       nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetFileSecurityW".}
-proc FindFirstChangeNotificationW*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,
-                                   dwNotifyFilter: DWORD): HANDLE{.stdcall,
-    dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}
-proc IsBadStringPtrW*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsBadStringPtrW".}
-proc LookupAccountSidW*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,
-                        cbName: LPDWORD, ReferencedDomainName: LPWSTR,
-                        cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupAccountSidW".}
-proc LookupAccountNameW*(lpSystemName: LPCWSTR, lpAccountName: LPCWSTR,
-                         Sid: PSID, cbSid: LPDWORD,
-                         ReferencedDomainName: LPWSTR,
-                         cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupAccountNameW".}
-proc LookupPrivilegeValueW*(lpSystemName: LPCWSTR, lpName: LPCWSTR,
-                            lpLuid: PLUID): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeValueW".}
-proc LookupPrivilegeNameW*(lpSystemName: LPCWSTR, lpLuid: PLUID, lpName: LPWSTR,
-                           cbName: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeNameW".}
-proc LookupPrivilegeDisplayNameW*(lpSystemName: LPCWSTR, lpName: LPCWSTR,
-                                  lpDisplayName: LPWSTR, cbDisplayName: LPDWORD,
-                                  lpLanguageId: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameW".}
-proc BuildCommDCBW*(lpDef: LPCWSTR, lpDCB: LPDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "BuildCommDCBW".}
-proc BuildCommDCBAndTimeoutsW*(lpDef: LPCWSTR, lpDCB: LPDCB,
-                               lpCommTimeouts: LPCOMMTIMEOUTS): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsW".}
-proc CommConfigDialogW*(lpszName: LPCWSTR, hWnd: HWND, lpCC: LPCOMMCONFIG): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CommConfigDialogW".}
-proc GetDefaultCommConfigW*(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG,
-                            lpdwSize: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDefaultCommConfigW".}
-proc SetDefaultCommConfigW*(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG, dwSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetDefaultCommConfigW".}
-proc GetComputerNameW*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetComputerNameW".}
-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,
-    dynlib: "user32", importc: "LoadKeyboardLayoutW".}
-proc GetKeyboardLayoutNameW*(pwszKLID: LPWSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetKeyboardLayoutNameW".}
-proc CreateDesktopW*(lpszDesktop: LPWSTR, lpszDevice: LPWSTR,
-                     pDevmodew: LPDEVMODEw, dwFlags: DWORD,
-                     dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HDESK{.
-    stdcall, dynlib: "user32", importc: "CreateDesktopW".}
-proc OpenDesktopW*(lpszDesktop: LPWSTR, dwFlags: DWORD, fInherit: WINBOOL,
-                   dwDesiredAccess: DWORD): HDESK{.stdcall, dynlib: "user32",
-    importc: "OpenDesktopW".}
-proc EnumDesktopsW*(hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROC,
-                    lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "EnumDesktopsW".}
-proc CreateWindowStationW*(lpwinsta: LPWSTR, dwReserved: DWORD,
-                           dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HWINSTA{.
-    stdcall, dynlib: "user32", importc: "CreateWindowStationW".}
-proc OpenWindowStationW*(lpszWinSta: LPWSTR, fInherit: WINBOOL,
-                         dwDesiredAccess: DWORD): HWINSTA{.stdcall,
-    dynlib: "user32", importc: "OpenWindowStationW".}
-proc EnumWindowStationsW*(lpEnumFunc: ENUMWINDOWSTATIONPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumWindowStationsW".}
-proc GetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUserObjectInformationW".}
-proc SetUserObjectInformationW*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                nLength: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetUserObjectInformationW".}
-proc RegisterWindowMessageW*(lpString: LPCWSTR): UINT{.stdcall,
-    dynlib: "user32", importc: "RegisterWindowMessageW".}
-proc GetMessageW*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                  wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetMessageW".}
-proc DispatchMessageW*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",
-    importc: "DispatchMessageW".}
-proc PeekMessageW*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                   wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "PeekMessageW".}
-proc SendMessageW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageW".}
-proc SendMessageTimeoutW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM,
-                          fuFlags: UINT, uTimeout: UINT, lpdwResult: LPDWORD): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".}
-proc SendNotifyMessageW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}
-proc SendMessageCallbackW*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                           lParam: LPARAM, lpResultCallBack: SENDASYNCPROC,
-                           dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SendMessageCallbackW".}
-proc PostMessageW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "PostMessageW".}
-proc PostThreadMessageW*(idThread: DWORD, Msg: UINT, wParam: WPARAM,
-                         lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "PostThreadMessageW".}
-proc DefWindowProcW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-    stdcall, dynlib: "user32", importc: "DefWindowProcW".}
-proc CallWindowProcW*(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT,
-                      wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-    dynlib: "user32", importc: "CallWindowProcW".}
-proc RegisterClassW*(lpWndClass: LPWNDCLASSW): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassW".}
-proc UnregisterClassW*(lpClassName: LPCWSTR, hInstance: HINST): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "UnregisterClassW".}
-proc GetClassInfoW*(hInstance: HINST, lpClassName: LPCWSTR,
-                    lpWndClass: LPWNDCLASS): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetClassInfoW".}
-proc RegisterClassExW*(para1: LPWNDCLASSEXW): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassExW".}
-proc GetClassInfoExW*(para1: HINST, para2: LPCWSTR, para3: LPWNDCLASSEX): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetClassInfoExW".}
-proc CreateWindowExW*(dwExStyle: DWORD, lpClassName: LPCWSTR,
-                      lpWindowName: LPCWSTR, dwStyle: DWORD, X: int32, Y: int32,
-                      nWidth: int32, nHeight: int32, hWndParent: HWND,
-                      hMenu: HMENU, hInstance: HINST, lpParam: LPVOID): HWND{.
-    stdcall, dynlib: "user32", importc: "CreateWindowExW".}
-proc CreateDialogParamW*(hInstance: HINST, lpTemplateName: LPCWSTR,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC,
-                         dwInitParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-    importc: "CreateDialogParamW".}
-proc CreateDialogIndirectParamW*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                                 hWndParent: HWND, lpDialogFunc: DLGPROC,
-                                 dwInitParam: LPARAM): HWND{.stdcall,
-    dynlib: "user32", importc: "CreateDialogIndirectParamW".}
-proc DialogBoxParamW*(hInstance: HINST, lpTemplateName: LPCWSTR,
-                      hWndParent: HWND, lpDialogFunc: DLGPROC,
-                      dwInitParam: LPARAM): int32{.stdcall, dynlib: "user32",
-    importc: "DialogBoxParamW".}
-proc DialogBoxIndirectParamW*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                              hWndParent: HWND, lpDialogFunc: DLGPROC,
-                              dwInitParam: LPARAM): int32{.stdcall,
-    dynlib: "user32", importc: "DialogBoxIndirectParamW".}
-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",
-    importc: "GetDlgItemTextW".}
-proc SendDlgItemMessageW*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,
-                          wParam: WPARAM, lParam: LPARAM): LONG{.stdcall,
-    dynlib: "user32", importc: "SendDlgItemMessageW".}
-proc DefDlgProcW*(hDlg: HWND, Msg: UINT, wParam: WPARAM, lParam: 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,
-    dynlib: "user32", importc: "RegisterClipboardFormatW".}
-proc GetClipboardFormatNameW*(format: UINT, lpszFormatName: LPWSTR,
-                              cchMaxCount: int32): int32{.stdcall,
-    dynlib: "user32", importc: "GetClipboardFormatNameW".}
-proc CharToOemW*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CharToOemW".}
-proc OemToCharW*(lpszSrc: LPCSTR, lpszDst: LPWSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "OemToCharW".}
-proc CharToOemBuffW*(lpszSrc: LPCWSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "CharToOemBuffW".}
-proc OemToCharBuffW*(lpszSrc: LPCSTR, lpszDst: LPWSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "OemToCharBuffW".}
-proc CharUpperW*(lpsz: LPWSTR): LPWSTR{.stdcall, dynlib: "user32",
-                                        importc: "CharUpperW".}
-proc CharUpperBuffW*(lpsz: LPWSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharUpperBuffW".}
-proc CharLowerW*(lpsz: LPWSTR): LPWSTR{.stdcall, dynlib: "user32",
-                                        importc: "CharLowerW".}
-proc CharLowerBuffW*(lpsz: LPWSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharLowerBuffW".}
-proc CharNextW*(lpsz: LPCWSTR): LPWSTR{.stdcall, dynlib: "user32",
-                                        importc: "CharNextW".}
-proc CharPrevW*(lpszStart: LPCWSTR, lpszCurrent: LPCWSTR): LPWSTR{.stdcall,
-    dynlib: "user32", importc: "CharPrevW".}
-proc IsCharAlphaW*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharAlphaW".}
-proc IsCharAlphaNumericW*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsCharAlphaNumericW".}
-proc IsCharUpperW*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharUpperW".}
-proc IsCharLowerW*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharLowerW".}
-proc GetKeyNameTextW*(lParam: LONG, lpString: LPWSTR, nSize: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetKeyNameTextW".}
-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,
-    dynlib: "user32", importc: "MapVirtualKeyW".}
-proc MapVirtualKeyExW*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,
-    dynlib: "user32", importc: "MapVirtualKeyExW".}
-proc LoadAcceleratorsW*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.
-    stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}
-proc CreateAcceleratorTableW*(para1: LPACCEL, para2: int32): HACCEL{.stdcall,
-    dynlib: "user32", importc: "CreateAcceleratorTableW".}
-proc CopyAcceleratorTableW*(hAccelSrc: HACCEL, lpAccelDst: LPACCEL,
-                            cAccelEntries: int32): int32{.stdcall,
-    dynlib: "user32", importc: "CopyAcceleratorTableW".}
-proc TranslateAcceleratorW*(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG): int32{.
-    stdcall, dynlib: "user32", importc: "TranslateAcceleratorW".}
-proc LoadMenuW*(hInstance: HINST, lpMenuName: LPCWSTR): HMENU{.stdcall,
-    dynlib: "user32", importc: "LoadMenuW".}
-proc LoadMenuIndirectW*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,
-    dynlib: "user32", importc: "LoadMenuIndirectW".}
-proc ChangeMenuW*(hMenu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,
-                  cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ChangeMenuW".}
-proc GetMenuStringW*(hMenu: HMENU, uIDItem: UINT, lpString: LPWSTR,
-                     nMaxCount: int32, uFlag: UINT): int32{.stdcall,
-    dynlib: "user32", importc: "GetMenuStringW".}
-proc InsertMenuW*(hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "InsertMenuW".}
-proc AppendMenuW*(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "AppendMenuW".}
-proc ModifyMenuW*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                  lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ModifyMenuW".}
-proc InsertMenuItemW*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                      para4: LPCMENUITEMINFO): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "InsertMenuItemW".}
-proc GetMenuItemInfoW*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                       para4: LPMENUITEMINFO): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetMenuItemInfoW".}
-proc SetMenuItemInfoW*(para1: HMENU, para2: UINT, 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",
-                                       importc: "DrawTextW".}
-proc DrawTextExW*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,
-                  para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,
-    dynlib: "user32", importc: "DrawTextExW".}
-proc GrayStringW*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
-                  lpData: LPARAM, nCount: int32, X: int32, Y: int32,
-                  nWidth: int32, nHeight: int32): WINBOOL{.stdcall,
-    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,
-    dynlib: "user32", importc: "DrawStateW".}
-proc TabbedTextOutW*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,
-                     nCount: int32, nTabPositions: int32,
-                     lpnTabStopPositions: LPINT, nTabOrigin: int32): LONG{.
-    stdcall, dynlib: "user32", importc: "TabbedTextOutW".}
-proc GetTabbedTextExtentW*(hDC: HDC, lpString: LPCWSTR, nCount: int32,
-                           nTabPositions: int32, lpnTabStopPositions: LPINT): DWORD{.
-    stdcall, dynlib: "user32", importc: "GetTabbedTextExtentW".}
-proc SetPropW*(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetPropW".}
-proc GetPropW*(hWnd: HWND, lpString: LPCWSTR): HANDLE{.stdcall,
-    dynlib: "user32", importc: "GetPropW".}
-proc RemovePropW*(hWnd: HWND, lpString: LPCWSTR): HANDLE{.stdcall,
-    dynlib: "user32", importc: "RemovePropW".}
-proc EnumPropsExW*(hWnd: HWND, lpEnumFunc: PROPENUMPROCEX, lParam: LPARAM): int32{.
-    stdcall, dynlib: "user32", importc: "EnumPropsExW".}
-proc EnumPropsW*(hWnd: HWND, lpEnumFunc: PROPENUMPROC): int32{.stdcall,
-    dynlib: "user32", importc: "EnumPropsW".}
-proc SetWindowTextW*(hWnd: HWND, lpString: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetWindowTextW".}
-proc GetWindowTextW*(hWnd: HWND, lpString: LPWSTR, nMaxCount: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetWindowTextW".}
-proc GetWindowTextLengthW*(hWnd: HWND): int32{.stdcall, dynlib: "user32",
-    importc: "GetWindowTextLengthW".}
-proc MessageBoxW*(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.
-    stdcall, dynlib: "user32", importc: "MessageBoxW".}
-proc MessageBoxExW*(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,
-                    uType: UINT, wLanguageId: int16): int32{.stdcall,
-    dynlib: "user32", importc: "MessageBoxExW".}
-proc MessageBoxIndirectW*(para1: LPMSGBOXPARAMS): int32{.stdcall,
-    dynlib: "user32", importc: "MessageBoxIndirectW".}
-proc GetWindowLongW*(hWnd: HWND, nIndex: int32): LONG{.stdcall,
-    dynlib: "user32", importc: "GetWindowLongW".}
-proc SetWindowLongW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): LONG{.stdcall,
-    dynlib: "user32", importc: "SetWindowLongW".}
-proc GetClassLongW*(hWnd: HWND, nIndex: int32): DWORD{.stdcall,
-    dynlib: "user32", importc: "GetClassLongW".}
-proc SetClassLongW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): DWORD{.stdcall,
-    dynlib: "user32", importc: "SetClassLongW".}
-when defined(cpu64):
-  proc GetWindowLongPtrW*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongPtrW".}
-  proc SetWindowLongPtrW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongPtrW".}
-  proc GetClassLongPtrW*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetClassLongPtrW".}
-  proc SetClassLongPtrW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetClassLongPtrW".}
-else:
-  proc GetWindowLongPtrW*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongW".}
-  proc SetWindowLongPtrW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongW".}
-  proc GetClassLongPtrW*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-      dynlib: "user32", importc: "GetClassLongW".}
-  proc SetClassLongPtrW*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-      stdcall, dynlib: "user32", importc: "SetClassLongW".}
-proc FindWindowW*(lpClassName: LPCWSTR, lpWindowName: LPCWSTR): HWND{.stdcall,
-    dynlib: "user32", importc: "FindWindowW".}
-proc FindWindowExW*(para1: HWND, para2: HWND, para3: LPCWSTR, para4: LPCWSTR): HWND{.
-    stdcall, dynlib: "user32", importc: "FindWindowExW".}
-proc GetClassNameW*(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetClassNameW".}
-proc SetWindowsHookExW*(idHook: int32, lpfn: HOOKPROC, hmod: HINST,
-                        dwThreadId: DWORD): HHOOK{.stdcall, dynlib: "user32",
-    importc: "SetWindowsHookExW".}
-proc LoadBitmapW*(hInstance: HINST, lpBitmapName: LPCWSTR): HBITMAP{.stdcall,
-    dynlib: "user32", importc: "LoadBitmapW".}
-proc LoadCursorW*(hInstance: HINST, lpCursorName: LPCWSTR): HCURSOR{.stdcall,
-    dynlib: "user32", importc: "LoadCursorW".}
-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",
-    importc: "LoadImageW".}
-proc LoadStringW*(hInstance: HINST, uID: UINT, 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,
-    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{.
-    stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}
-proc DlgDirSelectComboBoxExW*(hDlg: HWND, lpString: LPWSTR, nCount: int32,
-                              nIDComboBox: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}
-proc DefFrameProcW*(hWnd: HWND, hWndMDIClient: HWND, uMsg: UINT, wParam: WPARAM,
-                    lParam: LPARAM): LRESULT{.stdcall, dynlib: "user32",
-    importc: "DefFrameProcW".}
-proc DefMDIChildProcW*(hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: 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,
-                       lParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-    importc: "CreateMDIWindowW".}
-proc WinHelpW*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, 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",
-    importc: "SystemParametersInfoW".}
-proc AddFontResourceW*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",
-    importc: "AddFontResourceW".}
-proc CopyMetaFileW*(para1: HMETAFILE, para2: LPCWSTR): HMETAFILE{.stdcall,
-    dynlib: "gdi32", importc: "CopyMetaFileW".}
-proc CreateFontIndirectW*(para1: PLOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-    importc: "CreateFontIndirectW".}
-proc CreateFontIndirectW*(para1: var LOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-    importc: "CreateFontIndirectW".}
-proc CreateFontW*(para1: int32, para2: int32, para3: int32, para4: int32,
-                  para5: int32, para6: DWORD, para7: DWORD, para8: DWORD,
-                  para9: DWORD, para10: DWORD, para11: DWORD, para12: DWORD,
-                  para13: DWORD, para14: LPCWSTR): HFONT{.stdcall,
-    dynlib: "gdi32", importc: "CreateFontW".}
-proc CreateICW*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR,
-                para4: LPDEVMODEw): HDC{.stdcall, dynlib: "gdi32",
-    importc: "CreateICW".}
-proc CreateMetaFileW*(para1: LPCWSTR): HDC{.stdcall, dynlib: "gdi32",
-    importc: "CreateMetaFileW".}
-proc CreateScalableFontResourceW*(para1: DWORD, para2: LPCWSTR, para3: LPCWSTR,
-                                  para4: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "CreateScalableFontResourceW".}
-proc EnumFontFamiliesExW*(para1: HDC, para2: LPLOGFONT, para3: FONTENUMEXPROC,
-                          para4: LPARAM, para5: DWORD): int32{.stdcall,
-    dynlib: "gdi32", importc: "EnumFontFamiliesExW".}
-proc EnumFontFamiliesW*(para1: HDC, para2: LPCWSTR, para3: FONTENUMPROC,
-                        para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-    importc: "EnumFontFamiliesW".}
-proc EnumFontsW*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC, para4: LPARAM): int32{.
-    stdcall, dynlib: "gdi32", importc: "EnumFontsW".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}
-proc GetCharWidth32W*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}
-proc GetCharWidthFloatW*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}
-proc GetCharABCWidthsW*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}
-proc GetCharABCWidthsFloatW*(para1: HDC, para2: UINT, para3: UINT,
-                             para4: LPABCFLOAT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}
-proc GetGlyphOutlineW*(para1: HDC, para2: UINT, para3: UINT,
-                       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{.
-    stdcall, dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}
-proc GetTextExtentPointW*(para1: HDC, para2: LPCWSTR, para3: int32,
-                          para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentPointW".}
-proc GetTextExtentPoint32W*(para1: HDC, para2: LPCWSTR, para3: int32,
-                            para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentPoint32W".}
-proc GetTextExtentExPointW*(para1: HDC, para2: LPCWSTR, para3: int32,
-                            para4: int32, para5: LPINT, para6: LPINT,
-                            para7: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentExPointW".}
-proc GetCharacterPlacementW*(para1: HDC, para2: LPCWSTR, para3: int32,
-                             para4: int32, para5: LPGCP_RESULTS, para6: DWORD): DWORD{.
-    stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementW".}
-proc ResetDCW*(para1: HDC, para2: LPDEVMODEW): HDC{.stdcall, dynlib: "gdi32",
-    importc: "ResetDCW".}
-proc RemoveFontResourceW*(para1: LPCWSTR): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "RemoveFontResourceW".}
-proc CopyEnhMetaFileW*(para1: HENHMETAFILE, para2: LPCWSTR): HENHMETAFILE{.
-    stdcall, dynlib: "gdi32", importc: "CopyEnhMetaFileW".}
-proc CreateEnhMetaFileW*(para1: HDC, para2: LPCWSTR, para3: LPRECT,
-                         para4: LPCWSTR): HDC{.stdcall, dynlib: "gdi32",
-    importc: "CreateEnhMetaFileW".}
-proc GetEnhMetaFileW*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",
-    importc: "GetEnhMetaFileW".}
-proc GetEnhMetaFileDescriptionW*(para1: HENHMETAFILE, para2: UINT, para3: LPWSTR): UINT{.
-    stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}
-proc GetTextMetricsW*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetTextMetricsW".}
-proc StartDocW*(para1: HDC, para2: PDOCINFO): int32{.stdcall, dynlib: "gdi32",
-    importc: "StartDocW".}
-proc GetObjectW*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
-    dynlib: "gdi32", importc: "GetObjectW".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}
-proc PolyTextOutW*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}
-proc GetTextFaceW*(para1: HDC, para2: int32, para3: LPWSTR): int32{.stdcall,
-    dynlib: "gdi32", importc: "GetTextFaceW".}
-proc GetKerningPairsW*(para1: HDC, para2: DWORD, para3: LPKERNINGPAIR): DWORD{.
-    stdcall, dynlib: "gdi32", importc: "GetKerningPairsW".}
-proc GetLogColorSpaceW*(para1: HCOLORSPACE, para2: LPLOGCOLORSPACE, para3: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetLogColorSpaceW".}
-proc CreateColorSpaceW*(para1: LPLOGCOLORSPACE): HCOLORSPACE{.stdcall,
-    dynlib: "gdi32", importc: "CreateColorSpaceW".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}
-proc EnumICMProfilesW*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.
-    stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}
-proc CreatePropertySheetPageW*(lppsp: LPCPROPSHEETPAGE): HPROPSHEETPAGE{.
-    stdcall, dynlib: "comctl32", importc: "CreatePropertySheetPageW".}
-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{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}
-proc CreateStatusWindowW*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,
-                          wID: UINT): HWND{.stdcall, dynlib: "comctl32",
-    importc: "CreateStatusWindowW".}
-proc DrawStatusTextW*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.
-    stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}
-proc GetOpenFileNameW*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "GetOpenFileNameW".}
-proc GetSaveFileNameW*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "GetSaveFileNameW".}
-proc GetFileTitleW*(para1: LPCWSTR, para2: LPWSTR, para3: int16): int{.stdcall,
-    dynlib: "comdlg32", importc: "GetFileTitleW".}
-proc ChooseColorW*(para1: LPCHOOSECOLOR): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "ChooseColorW".}
-proc ReplaceTextW*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-    importc: "ReplaceTextW".}
-proc ChooseFontW*(para1: LPCHOOSEFONT): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "ChooseFontW".}
-proc FindTextW*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-    importc: "FindTextW".}
-proc PrintDlgW*(para1: LPPRINTDLG): WINBOOL{.stdcall, dynlib: "comdlg32",
-    importc: "PrintDlgW".}
-proc PageSetupDlgW*(para1: LPPAGESETUPDLG): WINBOOL{.stdcall,
-    dynlib: "comdlg32", importc: "PageSetupDlgW".}
-proc CreateProcessW*(lpApplicationName: LPCWSTR, lpCommandLine: LPWSTR,
-                     lpProcessAttributes: LPSECURITY_ATTRIBUTES,
-                     lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                     bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                     lpEnvironment: LPVOID, lpCurrentDirectory: LPCWSTR,
-                     lpStartupInfo: LPSTARTUPINFO,
-                     lpProcessInformation: LPPROCESS_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessW".}
-proc GetStartupInfoW*(lpStartupInfo: LPSTARTUPINFO){.stdcall,
-    dynlib: "kernel32", importc: "GetStartupInfoW".}
-proc FindFirstFileW*(lpFileName: LPCWSTR, lpFindFileData: LPWIN32_FIND_DATAW): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileW".}
-proc FindNextFileW*(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATAW): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileW".}
-proc GetVersionExW*(VersionInformation: LPOSVERSIONINFOW): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVersionExW".}
-proc CreateWindowW*(lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD,
-                    X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                    hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                    lpParam: LPVOID): HWND
-proc CreateDialogW*(hInstance: HINST, lpName: LPCWSTR, hWndParent: HWND,
-                    lpDialogFunc: DLGPROC): HWND
-proc CreateDialogIndirectW*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                            hWndParent: HWND, lpDialogFunc: DLGPROC): HWND
-proc DialogBoxW*(hInstance: HINST, lpTemplate: LPCWSTR, hWndParent: HWND,
-                 lpDialogFunc: DLGPROC): int32
-proc DialogBoxIndirectW*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC): int32
-proc CreateDCW*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR, para4: pDEVMODEW): HDC{.
-    stdcall, dynlib: "gdi32", importc: "CreateDCW".}
-proc VerInstallFileW*(uFlags: DWORD, szSrcFileName: LPWSTR,
-                      szDestFileName: LPWSTR, szSrcDir: LPWSTR,
-                      szDestDir: LPWSTR, szCurDir: LPWSTR, szTmpFile: LPWSTR,
-                      lpuTmpFileLen: PUINT): DWORD{.stdcall, dynlib: "version",
-    importc: "VerInstallFileW".}
-proc GetFileVersionInfoSizeW*(lptstrFilename: LPWSTR, lpdwHandle: LPDWORD): DWORD{.
-    stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeW".}
-proc GetFileVersionInfoW*(lptstrFilename: LPWSTR, dwHandle: DWORD, dwLen: DWORD,
-                          lpData: LPVOID): WINBOOL{.stdcall, dynlib: "version",
-    importc: "GetFileVersionInfoW".}
-proc VerLanguageNameW*(wLang: DWORD, szLang: LPWSTR, nSize: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "VerLanguageNameW".}
-proc VerQueryValueW*(pBlock: LPVOID, lpSubBlock: LPWSTR, lplpBuffer: LPVOID,
-                     puLen: PUINT): WINBOOL{.stdcall, dynlib: "version",
-    importc: "VerQueryValueW".}
-proc VerFindFileW*(uFlags: DWORD, szFileName: LPWSTR, szWinDir: LPWSTR,
-                   szAppDir: LPWSTR, szCurDir: LPWSTR, lpuCurDirLen: PUINT,
-                   szDestDir: LPWSTR, lpuDestDirLen: PUINT): DWORD{.stdcall,
-    dynlib: "version", importc: "VerFindFileW".}
-proc RegSetValueExW*(hKey: HKEY, lpValueName: LPCWSTR, Reserved: DWORD,
-                     dwType: DWORD, lpData: LPBYTE, cbData: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetValueExW".}
-proc RegUnLoadKeyW*(hKey: HKEY, lpSubKey: LPCWSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegUnLoadKeyW".}
-proc InitiateSystemShutdownW*(lpMachineName: LPWSTR, lpMessage: LPWSTR,
-                              dwTimeout: DWORD, bForceAppsClosed: WINBOOL,
-                              bRebootAfterShutdown: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "InitiateSystemShutdownW".}
-proc AbortSystemShutdownW*(lpMachineName: LPWSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AbortSystemShutdownW".}
-proc RegRestoreKeyW*(hKey: HKEY, lpFile: LPCWSTR, dwFlags: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegRestoreKeyW".}
-proc RegSaveKeyW*(hKey: HKEY, lpFile: LPCWSTR,
-                  lpSecurityAttributes: LPSECURITY_ATTRIBUTES): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegSaveKeyW".}
-proc RegSetValueW*(hKey: HKEY, lpSubKey: LPCWSTR, dwType: DWORD,
-                   lpData: LPCWSTR, cbData: DWORD): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegSetValueW".}
-proc RegQueryValueW*(hKey: HKEY, lpSubKey: LPCWSTR, lpValue: LPWSTR,
-                     lpcbValue: PLONG): LONG{.stdcall, dynlib: "advapi32",
-    importc: "RegQueryValueW".}
-proc RegQueryMultipleValuesW*(hKey: HKEY, val_list: PVALENT, num_vals: DWORD,
-                              lpValueBuf: LPWSTR, ldwTotsize: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesW".}
-proc RegQueryValueExW*(hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD,
-                       lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryValueExW".}
-proc RegReplaceKeyW*(hKey: HKEY, lpSubKey: LPCWSTR, lpNewFile: LPCWSTR,
-                     lpOldFile: LPCWSTR): LONG{.stdcall, dynlib: "advapi32",
-    importc: "RegReplaceKeyW".}
-proc RegConnectRegistryW*(lpMachineName: LPWSTR, hKey: HKEY, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegConnectRegistryW".}
-proc RegCreateKeyW*(hKey: HKEY, lpSubKey: LPCWSTR, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyW".}
-proc RegCreateKeyExW*(hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD,
-                      lpClass: LPWSTR, dwOptions: DWORD, samDesired: REGSAM,
-                      lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                      phkResult: PHKEY, lpdwDisposition: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyExW".}
-proc RegDeleteKeyW*(hKey: HKEY, lpSubKey: LPCWSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegDeleteKeyW".}
-proc RegDeleteValueW*(hKey: HKEY, lpValueName: LPCWSTR): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegDeleteValueW".}
-proc RegEnumKeyW*(hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR, cbName: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyW".}
-proc RegEnumKeyExW*(hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR,
-                    lpcbName: LPDWORD, lpReserved: LPDWORD, lpClass: LPWSTR,
-                    lpcbClass: LPDWORD, lpftLastWriteTime: PFILETIME): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyExW".}
-proc RegEnumValueW*(hKey: HKEY, dwIndex: DWORD, lpValueName: LPWSTR,
-                    lpcbValueName: LPDWORD, lpReserved: LPDWORD,
-                    lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumValueW".}
-proc RegLoadKeyW*(hKey: HKEY, lpSubKey: LPCWSTR, lpFile: LPCWSTR): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegLoadKeyW".}
-proc RegOpenKeyW*(hKey: HKEY, lpSubKey: LPCWSTR, phkResult: PHKEY): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegOpenKeyW".}
-proc RegOpenKeyExW*(hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD,
-                    samDesired: REGSAM, phkResult: PHKEY): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegOpenKeyExW".}
-proc RegQueryInfoKeyW*(hKey: HKEY, lpClass: LPWSTR, lpcbClass: LPDWORD,
-                       lpReserved: LPDWORD, lpcSubKeys: LPDWORD,
-                       lpcbMaxSubKeyLen: LPDWORD, lpcbMaxClassLen: LPDWORD,
-                       lpcValues: LPDWORD, lpcbMaxValueNameLen: LPDWORD,
-                       lpcbMaxValueLen: LPDWORD,
-                       lpcbSecurityDescriptor: LPDWORD,
-                       lpftLastWriteTime: PFILETIME): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegQueryInfoKeyW".}
-proc CompareStringW*(Locale: LCID, dwCmpFlags: DWORD, lpString1: LPCWSTR,
-                     cchCount1: int32, lpString2: LPCWSTR, cchCount2: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "CompareStringW".}
-proc LCMapStringW*(Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCWSTR,
-                   cchSrc: int32, lpDestStr: LPWSTR, cchDest: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "LCMapStringW".}
-proc GetLocaleInfoW*(Locale: LCID, LCType: LCTYPE, lpLCData: LPWSTR,
-                     cchData: int32): int32{.stdcall, dynlib: "kernel32",
-    importc: "GetLocaleInfoW".}
-proc SetLocaleInfoW*(Locale: LCID, LCType: LCTYPE, lpLCData: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetLocaleInfoW".}
-proc GetTimeFormatW*(Locale: LCID, dwFlags: DWORD, lpTime: LPSYSTEMTIME,
-                     lpFormat: LPCWSTR, lpTimeStr: LPWSTR, cchTime: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "GetTimeFormatW".}
-proc GetDateFormatW*(Locale: LCID, dwFlags: DWORD, lpDate: LPSYSTEMTIME,
-                     lpFormat: LPCWSTR, lpDateStr: LPWSTR, cchDate: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "GetDateFormatW".}
-proc GetNumberFormatW*(Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR,
-                       lpFormat: PNUMBERFMT, lpNumberStr: LPWSTR,
-                       cchNumber: int32): int32{.stdcall, dynlib: "kernel32",
-    importc: "GetNumberFormatW".}
-proc GetCurrencyFormatW*(Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR,
-                         lpFormat: PCURRENCYFMT, lpCurrencyStr: LPWSTR,
-                         cchCurrency: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "GetCurrencyFormatW".}
-proc EnumCalendarInfoW*(lpCalInfoEnumProc: CALINFO_ENUMPROC, Locale: LCID,
-                        Calendar: CALID, CalType: CALTYPE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "EnumCalendarInfoW".}
-proc EnumTimeFormatsW*(lpTimeFmtEnumProc: TIMEFMT_ENUMPROC, Locale: LCID,
-                       dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "EnumTimeFormatsW".}
-proc EnumDateFormatsW*(lpDateFmtEnumProc: DATEFMT_ENUMPROC, Locale: LCID,
-                       dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "EnumDateFormatsW".}
-proc GetStringTypeExW*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCWSTR,
-                       cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeExW".}
-proc GetStringTypeW*(dwInfoType: DWORD, lpSrcStr: LPCWSTR, cchSrc: int32,
-                     lpCharType: LPWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "GetStringTypeW".}
-proc FoldStringW*(dwMapFlags: DWORD, lpSrcStr: LPCWSTR, cchSrc: int32,
-                  lpDestStr: LPWSTR, cchDest: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "FoldStringW".}
-proc EnumSystemLocalesW*(lpLocaleEnumProc: LOCALE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumSystemLocalesW".}
-proc EnumSystemCodePagesW*(lpCodePageEnumProc: CODEPAGE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "EnumSystemCodePagesW".}
-proc PeekConsoleInputW*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                        nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".}
-proc ReadConsoleInputW*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                        nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".}
-proc WriteConsoleInputW*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleInputW".}
-proc ReadConsoleOutputW*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                         dwBufferSize: COORD, dwBufferCoord: COORD,
-                         lpReadRegion: PSMALL_RECT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadConsoleOutputW".}
-proc WriteConsoleOutputW*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                          dwBufferSize: COORD, dwBufferCoord: COORD,
-                          lpWriteRegion: PSMALL_RECT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteConsoleOutputW".}
-proc ReadConsoleOutputCharacterW*(hConsoleOutput: HANDLE, lpCharacter: LPWSTR,
-                                  nLength: DWORD, dwReadCoord: COORD,
-                                  lpNumberOfCharsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterW".}
-proc WriteConsoleOutputCharacterW*(hConsoleOutput: HANDLE, lpCharacter: LPCWSTR,
-                                   nLength: DWORD, dwWriteCoord: COORD,
-                                   lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterW".}
-proc FillConsoleOutputCharacterW*(hConsoleOutput: HANDLE, cCharacter: WCHAR,
-                                  nLength: DWORD, dwWriteCoord: COORD,
-                                  lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterW".}
-proc ScrollConsoleScreenBufferW*(hConsoleOutput: HANDLE,
-                                 lpScrollRectangle: PSMALL_RECT,
-                                 lpClipRectangle: PSMALL_RECT,
-                                 dwDestinationOrigin: COORD, lpFill: PCHAR_INFO): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferW".}
-proc GetConsoleTitleW*(lpConsoleTitle: LPWSTR, nSize: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetConsoleTitleW".}
-proc SetConsoleTitleW*(lpConsoleTitle: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleTitleW".}
-proc ReadConsoleW*(hConsoleInput: HANDLE, lpBuffer: LPVOID,
-                   nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD,
-                   lpReserved: LPVOID): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReadConsoleW".}
-proc WriteConsoleW*(hConsoleOutput: HANDLE, lpBuffer: pointer,
-                    nNumberOfCharsToWrite: DWORD,
-                    lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleW".}
-proc WNetAddConnectionW*(lpRemoteName: LPCWSTR, lpPassword: LPCWSTR,
-                         lpLocalName: LPCWSTR): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetAddConnectionW".}
-proc WNetAddConnection2W*(lpNetResource: LPNETRESOURCE, lpPassword: LPCWSTR,
-                          lpUserName: LPCWSTR, dwFlags: DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetAddConnection2W".}
-proc WNetAddConnection3W*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                          lpPassword: LPCWSTR, lpUserName: LPCWSTR,
-                          dwFlags: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetAddConnection3W".}
-proc WNetCancelConnectionW*(lpName: LPCWSTR, fForce: WINBOOL): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetCancelConnectionW".}
-proc WNetCancelConnection2W*(lpName: LPCWSTR, dwFlags: DWORD, fForce: WINBOOL): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetCancelConnection2W".}
-proc WNetGetConnectionW*(lpLocalName: LPCWSTR, lpRemoteName: LPWSTR,
-                         lpnLength: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetConnectionW".}
-proc WNetUseConnectionW*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                         lpUserID: LPCWSTR, lpPassword: LPCWSTR, dwFlags: DWORD,
-                         lpAccessName: LPWSTR, lpBufferSize: LPDWORD,
-                         lpResult: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetUseConnectionW".}
-proc WNetSetConnectionW*(lpName: LPCWSTR, dwProperties: DWORD, pvValues: LPVOID): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetSetConnectionW".}
-proc WNetConnectionDialog1W*(lpConnDlgStruct: LPCONNECTDLGSTRUCT): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1W".}
-proc WNetDisconnectDialog1W*(lpConnDlgStruct: LPDISCDLGSTRUCT): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetDisconnectDialog1W".}
-proc WNetOpenEnumW*(dwScope: DWORD, dwType: DWORD, dwUsage: DWORD,
-                    lpNetResource: LPNETRESOURCE, lphEnum: LPHANDLE): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetOpenEnumW".}
-proc WNetEnumResourceW*(hEnum: HANDLE, lpcCount: LPDWORD, lpBuffer: LPVOID,
-                        lpBufferSize: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetEnumResourceW".}
-proc WNetGetUniversalNameW*(lpLocalPath: LPCWSTR, dwInfoLevel: DWORD,
-                            lpBuffer: LPVOID, lpBufferSize: LPDWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameW".}
-proc WNetGetUserW*(lpName: LPCWSTR, lpUserName: LPWSTR, lpnLength: LPDWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUserW".}
-proc WNetGetProviderNameW*(dwNetType: DWORD, lpProviderName: LPWSTR,
-                           lpBufferSize: LPDWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetProviderNameW".}
-proc WNetGetNetworkInformationW*(lpProvider: LPCWSTR,
-                                 lpNetInfoStruct: LPNETINFOSTRUCT): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationW".}
-proc WNetGetLastErrorW*(lpError: LPDWORD, lpErrorBuf: LPWSTR,
-                        nErrorBufSize: DWORD, lpNameBuf: LPWSTR,
-                        nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetLastErrorW".}
-proc MultinetGetConnectionPerformanceW*(lpNetResource: LPNETRESOURCE,
-    lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT): DWORD{.stdcall,
-    dynlib: "mpr", importc: "MultinetGetConnectionPerformanceW".}
-proc ChangeServiceConfigW*(hService: SC_HANDLE, dwServiceType: DWORD,
-                           dwStartType: DWORD, dwErrorControl: DWORD,
-                           lpBinaryPathName: LPCWSTR, lpLoadOrderGroup: LPCWSTR,
-                           lpdwTagId: LPDWORD, lpDependencies: LPCWSTR,
-                           lpServiceStartName: LPCWSTR, lpPassword: LPCWSTR,
-                           lpDisplayName: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ChangeServiceConfigW".}
-proc CreateServiceW*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                     lpDisplayName: LPCWSTR, dwDesiredAccess: DWORD,
-                     dwServiceType: DWORD, dwStartType: DWORD,
-                     dwErrorControl: DWORD, lpBinaryPathName: LPCWSTR,
-                     lpLoadOrderGroup: LPCWSTR, lpdwTagId: LPDWORD,
-                     lpDependencies: LPCWSTR, lpServiceStartName: LPCWSTR,
-                     lpPassword: LPCWSTR): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "CreateServiceW".}
-proc EnumDependentServicesW*(hService: SC_HANDLE, dwServiceState: DWORD,
-                             lpServices: LPENUM_SERVICE_STATUS,
-                             cbBufSize: DWORD, pcbBytesNeeded: LPDWORD,
-                             lpServicesReturned: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "EnumDependentServicesW".}
-proc EnumServicesStatusW*(hSCManager: SC_HANDLE, dwServiceType: DWORD,
-                          dwServiceState: DWORD,
-                          lpServices: LPENUM_SERVICE_STATUS, cbBufSize: DWORD,
-                          pcbBytesNeeded: LPDWORD, lpServicesReturned: LPDWORD,
-                          lpResumeHandle: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "EnumServicesStatusW".}
-proc GetServiceKeyNameW*(hSCManager: SC_HANDLE, lpDisplayName: LPCWSTR,
-                         lpServiceName: LPWSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetServiceKeyNameW".}
-proc GetServiceDisplayNameW*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                             lpDisplayName: LPWSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetServiceDisplayNameW".}
-proc OpenSCManagerW*(lpMachineName: LPCWSTR, lpDatabaseName: LPCWSTR,
-                     dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "OpenSCManagerW".}
-proc OpenServiceW*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                   dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-    dynlib: "advapi32", importc: "OpenServiceW".}
-proc QueryServiceConfigW*(hService: SC_HANDLE,
-                          lpServiceConfig: LPQUERY_SERVICE_CONFIG,
-                          cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceConfigW".}
-proc QueryServiceLockStatusW*(hSCManager: SC_HANDLE,
-                              lpLockStatus: LPQUERY_SERVICE_LOCK_STATUS,
-                              cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceLockStatusW".}
-proc RegisterServiceCtrlHandlerW*(lpServiceName: LPCWSTR,
-                                  lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE{.
-    stdcall, dynlib: "advapi32", importc: "RegisterServiceCtrlHandlerW".}
-proc StartServiceCtrlDispatcherW*(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "StartServiceCtrlDispatcherW".}
-proc StartServiceW*(hService: SC_HANDLE, dwNumServiceArgs: DWORD,
-                    lpServiceArgVectors: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "StartServiceW".}
-proc DragQueryFileW*(para1: HDROP, para2: int, para3: LPCWSTR, para4: int): int{.
-    stdcall, dynlib: "shell32", importc: "DragQueryFileW".}
-proc ExtractAssociatedIconW*(para1: HINST, para2: LPCWSTR, para3: LPWORD): HICON{.
-    stdcall, dynlib: "shell32", importc: "ExtractAssociatedIconW".}
-proc ExtractIconW*(para1: HINST, para2: LPCWSTR, para3: int): HICON{.stdcall,
-    dynlib: "shell32", importc: "ExtractIconW".}
-proc FindExecutableW*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR): HINST{.
-    stdcall, dynlib: "shell32", importc: "FindExecutableW".}
-proc ShellAboutW*(para1: HWND, para2: LPCWSTR, para3: LPCWSTR, para4: HICON): int32{.
-    stdcall, dynlib: "shell32", importc: "ShellAboutW".}
-proc ShellExecuteW*(para1: HWND, para2: LPCWSTR, para3: LPCWSTR, para4: LPCWSTR,
-                    para5: LPCWSTR, para6: int32): HINST{.stdcall,
-    dynlib: "shell32", importc: "ShellExecuteW".}
-proc Shell_NotifyIconW*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
-    stdcall, dynlib: "shell32", importc: "Shell_NotifyIconW".}
-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",
-    importc: "DdeInitializeW".}
-proc DdeQueryStringW*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,
-                      para5: int32): DWORD{.stdcall, dynlib: "user32",
-    importc: "DdeQueryStringW".}
-proc LogonUserW*(para1: LPWSTR, para2: LPWSTR, para3: LPWSTR, para4: DWORD,
-                 para5: DWORD, para6: PHANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LogonUserW".}
-proc CreateProcessAsUserW*(para1: HANDLE, para2: LPCWSTR, para3: LPWSTR,
-                           para4: LPSECURITY_ATTRIBUTES,
-                           para5: LPSECURITY_ATTRIBUTES, para6: WINBOOL,
-                           para7: DWORD, para8: LPVOID, para9: LPCWSTR,
-                           para10: LPSTARTUPINFO, para11: LPPROCESS_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "CreateProcessAsUserW".}
-when defined(winUnicode):
-  proc GetBinaryType*(lpApplicationName: LPCWSTR, lpBinaryType: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "GetBinaryTypeW".}
-  proc GetShortPathName*(lpszLongPath: LPCWSTR, lpszShortPath: LPWSTR,
-                         cchBuffer: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetShortPathNameW".}
-  proc GetEnvironmentStrings*(): LPWSTR{.stdcall, dynlib: "kernel32",
-      importc: "GetEnvironmentStringsW".}
-  proc FreeEnvironmentStrings*(para1: LPWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "FreeEnvironmentStringsW".}
-  proc FormatMessage*(dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD,
-                      dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD,
-                      Arguments: va_list): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "FormatMessageW".}
-  proc CreateMailslot*(lpName: LPCWSTR, nMaxMessageSize: DWORD,
-                       lReadTimeout: DWORD,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateMailslotW".}
-  proc lstrcmp*(lpString1: LPCWSTR, lpString2: LPCWSTR): int32{.stdcall,
-      dynlib: "kernel32", importc: "lstrcmpW".}
-  proc lstrcmpi*(lpString1: LPCWSTR, lpString2: LPCWSTR): int32{.stdcall,
-      dynlib: "kernel32", importc: "lstrcmpiW".}
-  proc lstrcpyn*(lpString1: LPWSTR, lpString2: LPCWSTR, iMaxLength: int32): LPWSTR{.
-      stdcall, dynlib: "kernel32", importc: "lstrcpynW".}
-  proc lstrcpy*(lpString1: LPWSTR, lpString2: LPCWSTR): LPWSTR{.stdcall,
-      dynlib: "kernel32", importc: "lstrcpyW".}
-  proc lstrcat*(lpString1: LPWSTR, lpString2: LPCWSTR): LPWSTR{.stdcall,
-      dynlib: "kernel32", importc: "lstrcatW".}
-  proc lstrlen*(lpString: LPCWSTR): int32{.stdcall, dynlib: "kernel32",
-      importc: "lstrlenW".}
-  proc CreateMutex*(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
-                    bInitialOwner: WINBOOL, lpName: LPCWSTR): HANDLE{.stdcall,
-      dynlib: "kernel32", importc: "CreateMutexW".}
-  proc OpenMutex*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                  lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenMutexW".}
-  proc CreateEvent*(lpEventAttributes: LPSECURITY_ATTRIBUTES,
-                    bManualReset: WINBOOL, bInitialState: WINBOOL,
-                    lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "CreateEventW".}
-  proc OpenEvent*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                  lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenEventW".}
-  proc CreateSemaphore*(lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
-                        lInitialCount: LONG, lMaximumCount: LONG,
-                        lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "CreateSemaphoreW".}
-  proc OpenSemaphore*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                      lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenSemaphoreW".}
-  proc CreateFileMapping*(hFile: HANDLE,
-                          lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
-                          flProtect: DWORD, dwMaximumSizeHigh: DWORD,
-                          dwMaximumSizeLow: DWORD, lpName: LPCWSTR): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateFileMappingW".}
-  proc OpenFileMapping*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                        lpName: LPCWSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenFileMappingW".}
-  proc GetLogicalDriveStrings*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetLogicalDriveStringsW".}
-  proc LoadLibrary*(lpLibFileName: LPCWSTR): HINST{.stdcall, dynlib: "kernel32",
-      importc: "LoadLibraryW".}
-  proc LoadLibraryEx*(lpLibFileName: LPCWSTR, hFile: HANDLE, dwFlags: DWORD): HINST{.
-      stdcall, dynlib: "kernel32", importc: "LoadLibraryExW".}
-  proc GetModuleFileName*(hModule: HINST, lpFilename: LPWSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetModuleFileNameW".}
-  proc GetModuleHandle*(lpModuleName: LPCWSTR): HMODULE{.stdcall,
-      dynlib: "kernel32", importc: "GetModuleHandleW".}
-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCWSTR){.stdcall,
-      dynlib: "kernel32", importc: "FatalAppExitW".}
-  proc GetCommandLine*(): LPWSTR{.stdcall, dynlib: "kernel32",
-                                  importc: "GetCommandLineW".}
-  proc GetEnvironmentVariable*(lpName: LPCWSTR, lpBuffer: LPWSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetEnvironmentVariableW".}
-  proc SetEnvironmentVariable*(lpName: LPCWSTR, lpValue: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW".}
-  proc ExpandEnvironmentStrings*(lpSrc: LPCWSTR, lpDst: LPWSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "ExpandEnvironmentStringsW".}
-  proc OutputDebugString*(lpOutputString: LPCWSTR){.stdcall, dynlib: "kernel32",
-      importc: "OutputDebugStringW".}
-  proc FindResource*(hModule: HINST, lpName: LPCWSTR, lpType: LPCWSTR): HRSRC{.
-      stdcall, dynlib: "kernel32", importc: "FindResourceW".}
-  proc FindResourceEx*(hModule: HINST, lpType: LPCWSTR, lpName: LPCWSTR,
-                       wLanguage: int16): HRSRC{.stdcall, dynlib: "kernel32",
-      importc: "FindResourceExW".}
-  proc EnumResourceTypes*(hModule: HINST, lpEnumFunc: ENUMRESTYPEPROC,
-                          lParam: LONG): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumResourceTypesW".}
-  proc EnumResourceNames*(hModule: HINST, lpType: LPCWSTR,
-                          lpEnumFunc: ENUMRESNAMEPROC, lParam: LONG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumResourceNamesW".}
-  proc EnumResourceLanguages*(hModule: HINST, lpType: LPCWSTR, lpName: LPCWSTR,
-                              lpEnumFunc: ENUMRESLANGPROC, lParam: LONG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumResourceLanguagesW".}
-  proc BeginUpdateResource*(pFileName: LPCWSTR,
-                            bDeleteExistingResources: WINBOOL): HANDLE{.stdcall,
-      dynlib: "kernel32", importc: "BeginUpdateResourceW".}
-  proc UpdateResource*(hUpdate: HANDLE, lpType: LPCWSTR, lpName: LPCWSTR,
-                       wLanguage: int16, lpData: LPVOID, cbData: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "UpdateResourceW".}
-  proc EndUpdateResource*(hUpdate: HANDLE, fDiscard: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EndUpdateResourceW".}
-  proc GlobalAddAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",
-      importc: "GlobalAddAtomW".}
-  proc GlobalFindAtom*(lpString: LPCWSTR): ATOM{.stdcall, dynlib: "kernel32",
-      importc: "GlobalFindAtomW".}
-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPWSTR, nSize: int32): UINT{.
-      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,
-      dynlib: "kernel32", importc: "GetAtomNameW".}
-  proc GetProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR, nDefault: WINT): UINT{.
-      stdcall, dynlib: "kernel32", importc: "GetProfileIntW".}
-  proc GetProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                         lpDefault: LPCWSTR, lpReturnedString: LPWSTR,
-                         nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetProfileStringW".}
-  proc WriteProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                           lpString: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WriteProfileStringW".}
-  proc GetProfileSection*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
-                          nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetProfileSectionW".}
-  proc WriteProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteProfileSectionW".}
-  proc GetPrivateProfileInt*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                             nDefault: WINT, lpFileName: LPCWSTR): UINT{.
-      stdcall, dynlib: "kernel32", importc: "GetPrivateProfileIntW".}
-  proc GetPrivateProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                                lpDefault: LPCWSTR, lpReturnedString: LPWSTR,
-                                nSize: DWORD, lpFileName: LPCWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStringW".}
-  proc WritePrivateProfileString*(lpAppName: LPCWSTR, lpKeyName: LPCWSTR,
-                                  lpString: LPCWSTR, lpFileName: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStringW".}
-  proc GetPrivateProfileSection*(lpAppName: LPCWSTR, lpReturnedString: LPWSTR,
-                                 nSize: DWORD, lpFileName: LPCWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetPrivateProfileSectionW".}
-  proc WritePrivateProfileSection*(lpAppName: LPCWSTR, lpString: LPCWSTR,
-                                   lpFileName: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WritePrivateProfileSectionW".}
-  proc GetDriveType*(lpRootPathName: LPCWSTR): UINT{.stdcall,
-      dynlib: "kernel32", importc: "GetDriveTypeW".}
-  proc GetSystemDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.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,
-      dynlib: "kernel32", importc: "GetTempFileNameW".}
-  proc GetWindowsDirectory*(lpBuffer: LPWSTR, uSize: UINT): UINT{.stdcall,
-      dynlib: "kernel32", importc: "GetWindowsDirectoryW".}
-  proc SetCurrentDirectory*(lpPathName: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetCurrentDirectoryW".}
-  proc GetCurrentDirectory*(nBufferLength: DWORD, lpBuffer: LPWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetCurrentDirectoryW".}
-  proc GetDiskFreeSpace*(lpRootPathName: LPCWSTR, lpSectorsPerCluster: LPDWORD,
-                         lpBytesPerSector: LPDWORD,
-                         lpNumberOfFreeClusters: LPDWORD,
-                         lpTotalNumberOfClusters: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetDiskFreeSpaceW".}
-  proc CreateDirectory*(lpPathName: LPCWSTR,
-                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateDirectoryW".}
-  proc CreateDirectoryEx*(lpTemplateDirectory: LPCWSTR, lpNewDirectory: LPCWSTR,
-                          lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateDirectoryExW".}
-  proc RemoveDirectory*(lpPathName: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "RemoveDirectoryW".}
-  proc GetFullPathName*(lpFileName: LPCWSTR, nBufferLength: DWORD,
-                        lpBuffer: LPWSTR, lpFilePart: var LPWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetFullPathNameW".}
-  proc DefineDosDevice*(dwFlags: DWORD, lpDeviceName: LPCWSTR,
-                        lpTargetPath: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "DefineDosDeviceW".}
-  proc QueryDosDevice*(lpDeviceName: LPCWSTR, lpTargetPath: LPWSTR,
-                       ucchMax: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "QueryDosDeviceW".}
-  proc CreateFile*(lpFileName: LPCWSTR, dwDesiredAccess: DWORD,
-                   dwShareMode: DWORD,
-                   lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                   dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD,
-                   hTemplateFile: HANDLE): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "CreateFileW".}
-  proc SetFileAttributes*(lpFileName: LPCWSTR, dwFileAttributes: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetFileAttributesW".}
-  proc GetFileAttributes*(lpFileName: LPCWSTR): DWORD{.stdcall,
-      dynlib: "kernel32", importc: "GetFileAttributesW".}
-  proc GetCompressedFileSize*(lpFileName: LPCWSTR, lpFileSizeHigh: LPDWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetCompressedFileSizeW".}
-  proc DeleteFile*(lpFileName: LPCWSTR): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "DeleteFileW".}
-  proc SearchPath*(lpPath: LPCWSTR, lpFileName: LPCWSTR, lpExtension: LPCWSTR,
-                   nBufferLength: DWORD, lpBuffer: LPWSTR, lpFilePart: LPWSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "SearchPathW".}
-  proc CopyFile*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR,
-                 bFailIfExists: WINBOOL): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "CopyFileW".}
-  proc MoveFile*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "MoveFileW".}
-  proc MoveFileEx*(lpExistingFileName: LPCWSTR, lpNewFileName: LPCWSTR,
-                   dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "MoveFileExW".}
-  proc CreateNamedPipe*(lpName: LPCWSTR, dwOpenMode: DWORD, dwPipeMode: DWORD,
-                        nMaxInstances: DWORD, nOutBufferSize: DWORD,
-                        nInBufferSize: DWORD, nDefaultTimeOut: DWORD,
-                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW".}
-  proc GetNamedPipeHandleState*(hNamedPipe: HANDLE, lpState: LPDWORD,
-                                lpCurInstances: LPDWORD,
-                                lpMaxCollectionCount: LPDWORD,
-                                lpCollectDataTimeout: LPDWORD,
-                                lpUserName: LPWSTR, nMaxUserNameSize: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "GetNamedPipeHandleStateW".}
-  proc CallNamedPipe*(lpNamedPipeName: LPCWSTR, lpInBuffer: LPVOID,
-                      nInBufferSize: DWORD, lpOutBuffer: LPVOID,
-                      nOutBufferSize: DWORD, lpBytesRead: LPDWORD,
-                      nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "CallNamedPipeW".}
-  proc WaitNamedPipe*(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WaitNamedPipeW".}
-  proc SetVolumeLabel*(lpRootPathName: LPCWSTR, lpVolumeName: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetVolumeLabelW".}
-  proc GetVolumeInformation*(lpRootPathName: LPCWSTR,
-                             lpVolumeNameBuffer: LPWSTR, nVolumeNameSize: DWORD,
-                             lpVolumeSerialNumber: LPDWORD,
-                             lpMaximumComponentLength: LPDWORD,
-                             lpFileSystemFlags: LPDWORD,
-                             lpFileSystemNameBuffer: LPWSTR,
-                             nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetVolumeInformationW".}
-  proc ClearEventLog*(hEventLog: HANDLE, lpBackupFileName: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "ClearEventLogW".}
-  proc BackupEventLog*(hEventLog: HANDLE, lpBackupFileName: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "BackupEventLogW".}
-  proc OpenEventLog*(lpUNCServerName: LPCWSTR, lpSourceName: LPCWSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "OpenEventLogW".}
-  proc RegisterEventSource*(lpUNCServerName: LPCWSTR, lpSourceName: LPCWSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "RegisterEventSourceW".}
-  proc OpenBackupEventLog*(lpUNCServerName: LPCWSTR, lpFileName: LPCWSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "OpenBackupEventLogW".}
-  proc ReadEventLog*(hEventLog: HANDLE, dwReadFlags: DWORD,
-                     dwRecordOffset: DWORD, lpBuffer: LPVOID,
-                     nNumberOfBytesToRead: DWORD, pnBytesRead: LPDWORD,
-                     pnMinNumberOfBytesNeeded: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ReadEventLogW".}
-  proc ReportEvent*(hEventLog: HANDLE, wType: int16, wCategory: int16,
-                    dwEventID: DWORD, lpUserSid: PSID, wNumStrings: int16,
-                    dwDataSize: DWORD, lpStrings: LPPCWSTR, lpRawData: LPVOID): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "ReportEventW".}
-  proc AccessCheckAndAuditAlarm*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                                 ObjectTypeName: LPWSTR, ObjectName: LPWSTR,
-                                 SecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 DesiredAccess: DWORD,
-                                 GenericMapping: PGENERIC_MAPPING,
-                                 ObjectCreation: WINBOOL,
-                                 GrantedAccess: LPDWORD, AccessStatus: LPBOOL,
-                                 pfGenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "AccessCheckAndAuditAlarmW".}
-  proc ObjectOpenAuditAlarm*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                             ObjectTypeName: LPWSTR, ObjectName: LPWSTR,
-                             pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                             ClientToken: HANDLE, DesiredAccess: DWORD,
-                             GrantedAccess: DWORD, Privileges: PPRIVILEGE_SET,
-                             ObjectCreation: WINBOOL, AccessGranted: WINBOOL,
-                             GenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectOpenAuditAlarmW".}
-  proc ObjectPrivilegeAuditAlarm*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                                  ClientToken: HANDLE, DesiredAccess: DWORD,
-                                  Privileges: PPRIVILEGE_SET,
-                                  AccessGranted: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmW".}
-  proc ObjectCloseAuditAlarm*(SubsystemName: LPCWSTR, HandleId: LPVOID,
-                              GenerateOnClose: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectCloseAuditAlarmW".}
-  proc PrivilegedServiceAuditAlarm*(SubsystemName: LPCWSTR,
-                                    ServiceName: LPCWSTR, ClientToken: HANDLE,
-                                    Privileges: PPRIVILEGE_SET,
-                                    AccessGranted: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmW".}
-  proc SetFileSecurity*(lpFileName: LPCWSTR,
-                        SecurityInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "SetFileSecurityW".}
-  proc GetFileSecurity*(lpFileName: LPCWSTR,
-                        RequestedInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                        nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetFileSecurityW".}
-  proc FindFirstChangeNotification*(lpPathName: LPCWSTR, bWatchSubtree: WINBOOL,
-                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,
-      dynlib: "kernel32", importc: "FindFirstChangeNotificationW".}
-  proc IsBadStringPtr*(lpsz: LPCWSTR, ucchMax: UINT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "IsBadStringPtrW".}
-  proc LookupAccountSid*(lpSystemName: LPCWSTR, Sid: PSID, Name: LPWSTR,
-                         cbName: LPDWORD, ReferencedDomainName: LPWSTR,
-                         cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupAccountSidW".}
-  proc LookupAccountName*(lpSystemName: LPCWSTR, lpAccountName: LPCWSTR,
-                          Sid: PSID, cbSid: LPDWORD,
-                          ReferencedDomainName: LPWSTR,
-                          cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupAccountNameW".}
-  proc LookupPrivilegeValue*(lpSystemName: LPCWSTR, lpName: LPCWSTR,
-                             lpLuid: PLUID): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LookupPrivilegeValueW".}
-  proc LookupPrivilegeName*(lpSystemName: LPCWSTR, lpLuid: PLUID,
-                            lpName: LPWSTR, cbName: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LookupPrivilegeNameW".}
-  proc LookupPrivilegeDisplayName*(lpSystemName: LPCWSTR, lpName: LPCWSTR,
-                                   lpDisplayName: LPWSTR,
-                                   cbDisplayName: LPDWORD, lpLanguageId: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameW".}
-  proc BuildCommDCB*(lpDef: LPCWSTR, lpDCB: LPDCB): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "BuildCommDCBW".}
-  proc BuildCommDCBAndTimeouts*(lpDef: LPCWSTR, lpDCB: LPDCB,
-                                lpCommTimeouts: LPCOMMTIMEOUTS): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsW".}
-  proc CommConfigDialog*(lpszName: LPCWSTR, hWnd: HWND, lpCC: LPCOMMCONFIG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CommConfigDialogW".}
-  proc GetDefaultCommConfig*(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG,
-                             lpdwSize: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetDefaultCommConfigW".}
-  proc SetDefaultCommConfig*(lpszName: LPCWSTR, lpCC: LPCOMMCONFIG,
-                             dwSize: DWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetDefaultCommConfigW".}
-  proc GetComputerName*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetComputerNameW".}
-  proc SetComputerName*(lpComputerName: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetComputerNameW".}
-  proc GetUserName*(lpBuffer: LPWSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "GetUserNameW".}
-  proc LoadKeyboardLayout*(pwszKLID: LPCWSTR, Flags: UINT): HKL{.stdcall,
-      dynlib: "user32", importc: "LoadKeyboardLayoutW".}
-  proc GetKeyboardLayoutName*(pwszKLID: LPWSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetKeyboardLayoutNameW".}
-  proc CreateDesktop*(lpszDesktop: LPWSTR, lpszDevice: LPWSTR,
-                      pDevmode: LPDEVMODE, dwFlags: DWORD,
-                      dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HDESK{.
-      stdcall, dynlib: "user32", importc: "CreateDesktopW".}
-  proc OpenDesktop*(lpszDesktop: LPWSTR, dwFlags: DWORD, fInherit: WINBOOL,
-                    dwDesiredAccess: DWORD): HDESK{.stdcall, dynlib: "user32",
-      importc: "OpenDesktopW".}
-  proc EnumDesktops*(hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROC,
-                     lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "EnumDesktopsW".}
-  proc CreateWindowStation*(lpwinsta: LPWSTR, dwReserved: DWORD,
-                            dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HWINSTA{.
-      stdcall, dynlib: "user32", importc: "CreateWindowStationW".}
-  proc OpenWindowStation*(lpszWinSta: LPWSTR, fInherit: WINBOOL,
-                          dwDesiredAccess: DWORD): HWINSTA{.stdcall,
-      dynlib: "user32", importc: "OpenWindowStationW".}
-  proc EnumWindowStations*(lpEnumFunc: ENUMWINDOWSTATIONPROC, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "EnumWindowStationsW".}
-  proc GetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                 nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "GetUserObjectInformationW".}
-  proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                 nLength: DWORD): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetUserObjectInformationW".}
-  proc RegisterWindowMessage*(lpString: LPCWSTR): UINT{.stdcall,
-      dynlib: "user32", importc: "RegisterWindowMessageW".}
-  proc GetMessage*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "GetMessageW".}
-  proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",
-      importc: "DispatchMessageW".}
-  proc PeekMessage*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "PeekMessageW".}
-  proc SendMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-      stdcall, dynlib: "user32", importc: "SendMessageW".}
-  proc SendMessageTimeout*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                           lParam: LPARAM, fuFlags: UINT, uTimeout: UINT,
-                           lpdwResult: LPDWORD): LRESULT{.stdcall,
-      dynlib: "user32", importc: "SendMessageTimeoutW".}
-  proc SendNotifyMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "SendNotifyMessageW".}
-  proc SendMessageCallback*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                            lParam: LPARAM, lpResultCallBack: SENDASYNCPROC,
-                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "SendMessageCallbackW".}
-  proc PostMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "PostMessageW".}
-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wParam: WPARAM,
-                          lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "PostThreadMessageW".}
-  proc DefWindowProc*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-      stdcall, dynlib: "user32", importc: "DefWindowProcW".}
-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT,
-                       wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-      dynlib: "user32", importc: "CallWindowProcW".}
-  proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",
-      importc: "RegisterClassW".}
-  proc UnregisterClass*(lpClassName: LPCWSTR, hInstance: HINST): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "UnregisterClassW".}
-  proc GetClassInfo*(hInstance: HINST, lpClassName: LPCWSTR,
-                     lpWndClass: LPWNDCLASS): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetClassInfoW".}
-  proc RegisterClassEx*(para1: LPWNDCLASSEXW): ATOM{.stdcall, dynlib: "user32",
-      importc: "RegisterClassExW".}
-  proc GetClassInfoEx*(para1: HINST, para2: LPCWSTR, para3: LPWNDCLASSEX): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "GetClassInfoExW".}
-  proc CreateWindowEx*(dwExStyle: DWORD, lpClassName: LPCWSTR,
-                       lpWindowName: LPCWSTR, dwStyle: DWORD, X: int32,
-                       Y: int32, nWidth: int32, nHeight: int32,
-                       hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                       lpParam: LPVOID): HWND{.stdcall, dynlib: "user32",
-      importc: "CreateWindowExW".}
-  proc CreateDialogParam*(hInstance: HINST, lpTemplateName: LPCWSTR,
-                          hWndParent: HWND, lpDialogFunc: DLGPROC,
-                          dwInitParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-      importc: "CreateDialogParamW".}
-  proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                                  hWndParent: HWND, lpDialogFunc: DLGPROC,
-                                  dwInitParam: LPARAM): HWND{.stdcall,
-      dynlib: "user32", importc: "CreateDialogIndirectParamW".}
-  proc DialogBoxParam*(hInstance: HINST, lpTemplateName: LPCWSTR,
-                       hWndParent: HWND, lpDialogFunc: DLGPROC,
-                       dwInitParam: LPARAM): int32{.stdcall, dynlib: "user32",
-      importc: "DialogBoxParamW".}
-  proc DialogBoxIndirectParam*(hInstance: HINST,
-                               hDialogTemplate: LPCDLGTEMPLATE,
-                               hWndParent: HWND, lpDialogFunc: DLGPROC,
-                               dwInitParam: LPARAM): int32{.stdcall,
-      dynlib: "user32", importc: "DialogBoxIndirectParamW".}
-  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",
-      importc: "GetDlgItemTextW".}
-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,
-                           wParam: WPARAM, lParam: LPARAM): LONG{.stdcall,
-      dynlib: "user32", importc: "SendDlgItemMessageW".}
-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wParam: WPARAM, lParam: 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,
-      dynlib: "user32", importc: "RegisterClipboardFormatW".}
-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPWSTR,
-                               cchMaxCount: int32): int32{.stdcall,
-      dynlib: "user32", importc: "GetClipboardFormatNameW".}
-  proc CharToOem*(lpszSrc: LPCWSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "CharToOemW".}
-  proc OemToChar*(lpszSrc: LPCSTR, lpszDst: LPWSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "OemToCharW".}
-  proc CharToOemBuff*(lpszSrc: LPCWSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "CharToOemBuffW".}
-  proc OemToCharBuff*(lpszSrc: LPCSTR, lpszDst: LPWSTR, cchDstLength: DWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "OemToCharBuffW".}
-  proc CharUpper*(lpsz: LPWSTR): LPWSTR{.stdcall, dynlib: "user32",
-      importc: "CharUpperW".}
-  proc CharUpperBuff*(lpsz: LPWSTR, cchLength: DWORD): DWORD{.stdcall,
-      dynlib: "user32", importc: "CharUpperBuffW".}
-  proc CharLower*(lpsz: LPWSTR): LPWSTR{.stdcall, dynlib: "user32",
-      importc: "CharLowerW".}
-  proc CharLowerBuff*(lpsz: LPWSTR, cchLength: DWORD): DWORD{.stdcall,
-      dynlib: "user32", importc: "CharLowerBuffW".}
-  proc CharNext*(lpsz: LPCWSTR): LPWSTR{.stdcall, dynlib: "user32",
-      importc: "CharNextW".}
-  proc CharPrev*(lpszStart: LPCWSTR, lpszCurrent: LPCWSTR): LPWSTR{.stdcall,
-      dynlib: "user32", importc: "CharPrevW".}
-  proc IsCharAlpha*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "IsCharAlphaW".}
-  proc IsCharAlphaNumeric*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "IsCharAlphaNumericW".}
-  proc IsCharUpper*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "IsCharUpperW".}
-  proc IsCharLower*(ch: WCHAR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "IsCharLowerW".}
-  proc GetKeyNameText*(lParam: LONG, lpString: LPWSTR, nSize: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetKeyNameTextW".}
-  proc VkKeyScan*(ch: WCHAR): SHORT{.stdcall, dynlib: "user32",
-                                     importc: "VkKeyScanW".}
-  proc VkKeyScanEx*(ch: WCHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",
-      importc: "VkKeyScanExW".}
-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,
-      dynlib: "user32", importc: "MapVirtualKeyW".}
-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,
-      dynlib: "user32", importc: "MapVirtualKeyExW".}
-  proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCWSTR): HACCEL{.
-      stdcall, dynlib: "user32", importc: "LoadAcceleratorsW".}
-  proc CreateAcceleratorTable*(para1: LPACCEL, para2: int32): HACCEL{.stdcall,
-      dynlib: "user32", importc: "CreateAcceleratorTableW".}
-  proc CopyAcceleratorTable*(hAccelSrc: HACCEL, lpAccelDst: LPACCEL,
-                             cAccelEntries: int32): int32{.stdcall,
-      dynlib: "user32", importc: "CopyAcceleratorTableW".}
-  proc TranslateAccelerator*(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG): int32{.
-      stdcall, dynlib: "user32", importc: "TranslateAcceleratorW".}
-  proc LoadMenu*(hInstance: HINST, lpMenuName: LPCWSTR): HMENU{.stdcall,
-      dynlib: "user32", importc: "LoadMenuW".}
-  proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,
-      dynlib: "user32", importc: "LoadMenuIndirectW".}
-  proc ChangeMenu*(hMenu: HMENU, cmd: UINT, lpszNewItem: LPCWSTR,
-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "ChangeMenuW".}
-  proc GetMenuString*(hMenu: HMENU, uIDItem: UINT, lpString: LPWSTR,
-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,
-      dynlib: "user32", importc: "GetMenuStringW".}
-  proc InsertMenu*(hMenu: HMENU, uPosition: UINT, uFlags: UINT,
-                   uIDNewItem: UINT, lpNewItem: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "InsertMenuW".}
-  proc AppendMenu*(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT,
-                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "AppendMenuW".}
-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                   lpNewItem: LPCWSTR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "ModifyMenuW".}
-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "InsertMenuItemW".}
-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetMenuItemInfoW".}
-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, 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",
-                                        importc: "DrawTextW".}
-  proc DrawTextEx*(para1: HDC, para2: LPWSTR, para3: int32, para4: LPRECT,
-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,
-      dynlib: "user32", importc: "DrawTextExW".}
-  proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
-                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,
-                   nWidth: int32, nHeight: int32): WINBOOL{.stdcall,
-      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,
-      dynlib: "user32", importc: "DrawStateW".}
-  proc TabbedTextOut*(hDC: HDC, X: int32, Y: int32, lpString: LPCWSTR,
-                      nCount: int32, nTabPositions: int32,
-                      lpnTabStopPositions: LPINT, nTabOrigin: int32): LONG{.
-      stdcall, dynlib: "user32", importc: "TabbedTextOutW".}
-  proc GetTabbedTextExtent*(hDC: HDC, lpString: LPCWSTR, nCount: int32,
-                            nTabPositions: int32, lpnTabStopPositions: LPINT): DWORD{.
-      stdcall, dynlib: "user32", importc: "GetTabbedTextExtentW".}
-  proc SetProp*(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetPropW".}
-  proc GetProp*(hWnd: HWND, lpString: LPCWSTR): HANDLE{.stdcall,
-      dynlib: "user32", importc: "GetPropW".}
-  proc RemoveProp*(hWnd: HWND, lpString: LPCWSTR): HANDLE{.stdcall,
-      dynlib: "user32", importc: "RemovePropW".}
-  proc EnumPropsEx*(hWnd: HWND, lpEnumFunc: PROPENUMPROCEX, lParam: LPARAM): int32{.
-      stdcall, dynlib: "user32", importc: "EnumPropsExW".}
-  proc EnumProps*(hWnd: HWND, lpEnumFunc: PROPENUMPROC): int32{.stdcall,
-      dynlib: "user32", importc: "EnumPropsW".}
-  proc SetWindowText*(hWnd: HWND, lpString: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetWindowTextW".}
-  proc GetWindowText*(hWnd: HWND, lpString: LPWSTR, nMaxCount: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetWindowTextW".}
-  proc GetWindowTextLength*(hWnd: HWND): int32{.stdcall, dynlib: "user32",
-      importc: "GetWindowTextLengthW".}
-  proc MessageBox*(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT): int32{.
-      stdcall, dynlib: "user32", importc: "MessageBoxW".}
-  proc MessageBoxEx*(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR,
-                     uType: UINT, wLanguageId: int16): int32{.stdcall,
-      dynlib: "user32", importc: "MessageBoxExW".}
-  proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,
-      dynlib: "user32", importc: "MessageBoxIndirectW".}
-  proc GetWindowLong*(hWnd: HWND, nIndex: int32): LONG{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongW".}
-  proc SetWindowLong*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): LONG{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongW".}
-  proc GetClassLong*(hWnd: HWND, nIndex: int32): DWORD{.stdcall,
-      dynlib: "user32", importc: "GetClassLongW".}
-  proc SetClassLong*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): DWORD{.
-      stdcall, dynlib: "user32", importc: "SetClassLongW".}
-  when defined(cpu64):
-    proc GetWindowLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetWindowLongPtrW".}
-    proc SetWindowLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetWindowLongPtrW".}
-    proc GetClassLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetClassLongPtrW".}
-    proc SetClassLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetClassLongPtrW".}
-  else:
-    proc GetWindowLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetWindowLongW".}
-    proc SetWindowLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetWindowLongW".}
-    proc GetClassLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetClassLongW".}
-    proc SetClassLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetClassLongW".}
-  proc FindWindow*(lpClassName: LPCWSTR, lpWindowName: LPCWSTR): HWND{.stdcall,
-      dynlib: "user32", importc: "FindWindowW".}
-  proc FindWindowEx*(para1: HWND, para2: HWND, para3: LPCWSTR, para4: LPCWSTR): HWND{.
-      stdcall, dynlib: "user32", importc: "FindWindowExW".}
-  proc GetClassName*(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetClassNameW".}
-  proc SetWindowsHookEx*(idHook: int32, lpfn: HOOKPROC, hmod: HINST,
-                         dwThreadId: DWORD): HHOOK{.stdcall, dynlib: "user32",
-      importc: "SetWindowsHookExW".}
-  proc LoadBitmap*(hInstance: HINST, lpBitmapName: LPCWSTR): HBITMAP{.stdcall,
-      dynlib: "user32", importc: "LoadBitmapW".}
-  proc LoadCursor*(hInstance: HINST, lpCursorName: LPCWSTR): HCURSOR{.stdcall,
-      dynlib: "user32", importc: "LoadCursorW".}
-  proc LoadCursorFromFile*(lpFileName: LPCWSTR): HCURSOR{.stdcall,
-      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",
-      importc: "LoadImageW".}
-  proc LoadString*(hInstance: HINST, uID: UINT, 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,
-      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{.
-      stdcall, dynlib: "user32", importc: "DlgDirListComboBoxW".}
-  proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPWSTR, nCount: int32,
-                               nIDComboBox: int32): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "DlgDirSelectComboBoxExW".}
-  proc DefFrameProc*(hWnd: HWND, hWndMDIClient: HWND, uMsg: UINT,
-                     wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-      dynlib: "user32", importc: "DefFrameProcW".}
-  proc DefMDIChildProc*(hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: 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,
-                        lParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-      importc: "CreateMDIWindowW".}
-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCWSTR, uCommand: UINT, 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",
-      importc: "SystemParametersInfoW".}
-  proc AddFontResource*(para1: LPCWSTR): int32{.stdcall, dynlib: "gdi32",
-      importc: "AddFontResourceW".}
-  proc CopyMetaFile*(para1: HMETAFILE, para2: LPCWSTR): HMETAFILE{.stdcall,
-      dynlib: "gdi32", importc: "CopyMetaFileW".}
-  proc CreateFontIndirect*(para1: PLOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-      importc: "CreateFontIndirectW".}
-  proc CreateFontIndirect*(para1: var LOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-      importc: "CreateFontIndirectW".}
-  proc CreateFont*(para1: int32, para2: int32, para3: int32, para4: int32,
-                   para5: int32, para6: DWORD, para7: DWORD, para8: DWORD,
-                   para9: DWORD, para10: DWORD, para11: DWORD, para12: DWORD,
-                   para13: DWORD, para14: LPCWSTR): HFONT{.stdcall,
-      dynlib: "gdi32", importc: "CreateFontW".}
-  proc CreateIC*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR,
-                 para4: LPDEVMODE): HDC{.stdcall, dynlib: "gdi32",
-      importc: "CreateICW".}
-  proc CreateMetaFile*(para1: LPCWSTR): HDC{.stdcall, dynlib: "gdi32",
-      importc: "CreateMetaFileW".}
-  proc CreateScalableFontResource*(para1: DWORD, para2: LPCWSTR, para3: LPCWSTR,
-                                   para4: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "CreateScalableFontResourceW".}
-  proc EnumFontFamiliesEx*(para1: HDC, para2: LPLOGFONT, para3: FONTENUMEXPROC,
-                           para4: LPARAM, para5: DWORD): int32{.stdcall,
-      dynlib: "gdi32", importc: "EnumFontFamiliesExW".}
-  proc EnumFontFamilies*(para1: HDC, para2: LPCWSTR, para3: FONTENUMPROC,
-                         para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-      importc: "EnumFontFamiliesW".}
-  proc EnumFonts*(para1: HDC, para2: LPCWSTR, para3: ENUMFONTSPROC,
-                  para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-      importc: "EnumFontsW".}
-  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{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidthW".}
-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidth32W".}
-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatW".}
-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}
-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,
-                              para4: LPABCFLOAT): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "GetCharABCWidthsFloatW".}
-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,
-                        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,
-      dynlib: "gdi32", importc: "GetOutlineTextMetricsW".}
-  proc GetTextExtentPoint*(para1: HDC, para2: LPCWSTR, para3: int32,
-                           para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentPointW".}
-  proc GetTextExtentPoint32*(para1: HDC, para2: LPCWSTR, para3: int32,
-                             para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentPoint32W".}
-  proc GetTextExtentExPoint*(para1: HDC, para2: LPCWSTR, para3: int32,
-                             para4: int32, para5: LPINT, para6: LPINT,
-                             para7: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentExPointW".}
-  proc GetCharacterPlacement*(para1: HDC, para2: LPCWSTR, para3: int32,
-                              para4: int32, para5: LPGCP_RESULTS, para6: DWORD): DWORD{.
-      stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementW".}
-  proc ResetDC*(para1: HDC, para2: LPDEVMODE): HDC{.stdcall, dynlib: "gdi32",
-      importc: "ResetDCW".}
-  proc RemoveFontResource*(para1: LPCWSTR): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "RemoveFontResourceW".}
-  proc CopyEnhMetaFile*(para1: HENHMETAFILE, para2: LPCWSTR): HENHMETAFILE{.
-      stdcall, dynlib: "gdi32", importc: "CopyEnhMetaFileW".}
-  proc CreateEnhMetaFile*(para1: HDC, para2: LPCWSTR, para3: LPRECT,
-                          para4: LPCWSTR): HDC{.stdcall, dynlib: "gdi32",
-      importc: "CreateEnhMetaFileW".}
-  proc GetEnhMetaFile*(para1: LPCWSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",
-      importc: "GetEnhMetaFileW".}
-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT,
-                                  para3: LPWSTR): UINT{.stdcall,
-      dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionW".}
-  proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "GetTextMetricsW".}
-  proc StartDoc*(para1: HDC, para2: PDOCINFO): int32{.stdcall, dynlib: "gdi32",
-      importc: "StartDocW".}
-  proc GetObject*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
-      dynlib: "gdi32", importc: "GetObjectW".}
-  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{.
-      stdcall, dynlib: "gdi32", importc: "ExtTextOutW".}
-  proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}
-  proc GetTextFace*(para1: HDC, para2: int32, para3: LPWSTR): int32{.stdcall,
-      dynlib: "gdi32", importc: "GetTextFaceW".}
-  proc GetKerningPairs*(para1: HDC, para2: DWORD, para3: LPKERNINGPAIR): DWORD{.
-      stdcall, dynlib: "gdi32", importc: "GetKerningPairsW".}
-  proc GetLogColorSpace*(para1: HCOLORSPACE, para2: LPLOGCOLORSPACE,
-                         para3: DWORD): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetLogColorSpaceW".}
-  proc CreateColorSpace*(para1: LPLOGCOLORSPACE): HCOLORSPACE{.stdcall,
-      dynlib: "gdi32", importc: "CreateColorSpaceW".}
-  proc GetICMProfile*(para1: HDC, para2: DWORD, para3: LPWSTR): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetICMProfileW".}
-  proc SetICMProfile*(para1: HDC, para2: LPWSTR): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "SetICMProfileW".}
-  proc UpdateICMRegKey*(para1: DWORD, para2: DWORD, para3: LPWSTR, para4: UINT): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "UpdateICMRegKeyW".}
-  proc EnumICMProfiles*(para1: HDC, para2: ICMENUMPROC, para3: LPARAM): int32{.
-      stdcall, dynlib: "gdi32", importc: "EnumICMProfilesW".}
-  proc CreatePropertySheetPage*(lppsp: LPCPROPSHEETPAGE): HPROPSHEETPAGE{.
-      stdcall, dynlib: "comctl32", importc: "CreatePropertySheetPageW".}
-  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{.
-      stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageW".}
-  proc CreateStatusWindow*(style: LONG, lpszText: LPCWSTR, hwndParent: HWND,
-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",
-      importc: "CreateStatusWindowW".}
-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCWSTR, uFlags: UINT){.
-      stdcall, dynlib: "comctl32", importc: "DrawStatusTextW".}
-  proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "GetOpenFileNameW".}
-  proc GetSaveFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "GetSaveFileNameW".}
-  proc GetFileTitle*(para1: LPCWSTR, para2: LPWSTR, para3: int16): int{.stdcall,
-      dynlib: "comdlg32", importc: "GetFileTitleW".}
-  proc ChooseColor*(para1: LPCHOOSECOLOR): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "ChooseColorW".}
-  proc ReplaceText*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-      importc: "ReplaceTextW".}
-  proc ChooseFont*(para1: LPCHOOSEFONT): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "ChooseFontW".}
-  proc FindText*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-      importc: "FindTextW".}
-  proc PrintDlg*(para1: LPPRINTDLG): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "PrintDlgW".}
-  proc PageSetupDlg*(para1: LPPAGESETUPDLG): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "PageSetupDlgW".}
-  proc CreateProcess*(lpApplicationName: LPCWSTR, lpCommandLine: LPWSTR,
-                      lpProcessAttributes: LPSECURITY_ATTRIBUTES,
-                      lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                      bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                      lpEnvironment: LPVOID, lpCurrentDirectory: LPCWSTR,
-                      lpStartupInfo: LPSTARTUPINFO,
-                      lpProcessInformation: LPPROCESS_INFORMATION): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateProcessW".}
-  proc GetStartupInfo*(lpStartupInfo: LPSTARTUPINFO){.stdcall,
-      dynlib: "kernel32", importc: "GetStartupInfoW".}
-  proc FindFirstFile*(lpFileName: LPCWSTR, lpFindFileData: LPWIN32_FIND_DATA): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "FindFirstFileW".}
-  proc FindNextFile*(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATA): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "FindNextFileW".}
-  proc GetVersionEx*(VersionInformation: LPOSVERSIONINFOW): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetVersionExW".}
-  proc GetVersionExW*(VersionInformation: LPOSVERSIONINFOW): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetVersionExW".}
-  proc CreateWindow*(lpClassName: LPCWSTR, lpWindowName: LPCWSTR,
-                     dwStyle: DWORD, X: int32, Y: int32, nWidth: int32,
-                     nHeight: int32, hWndParent: HWND, hMenu: HMENU,
-                     hInstance: HINST, lpParam: LPVOID): HWND
-  proc CreateDialog*(hInstance: HINST, lpName: LPCWSTR, hWndParent: HWND,
-                     lpDialogFunc: DLGPROC): HWND
-  proc CreateDialogIndirect*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                             hWndParent: HWND, lpDialogFunc: DLGPROC): HWND
-  proc DialogBox*(hInstance: HINST, lpTemplate: LPCWSTR, hWndParent: HWND,
-                  lpDialogFunc: DLGPROC): int32
-  proc DialogBoxIndirect*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                          hWndParent: HWND, lpDialogFunc: DLGPROC): int32
-  proc CreateDC*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR, para4: pDEVMODE): HDC{.
-      stdcall, dynlib: "gdi32", importc: "CreateDCW".}
-  proc VerInstallFile*(uFlags: DWORD, szSrcFileName: LPWSTR,
-                       szDestFileName: LPWSTR, szSrcDir: LPWSTR,
-                       szDestDir: LPWSTR, szCurDir: LPWSTR, szTmpFile: LPWSTR,
-                       lpuTmpFileLen: PUINT): DWORD{.stdcall, dynlib: "version",
-      importc: "VerInstallFileW".}
-  proc GetFileVersionInfoSize*(lptstrFilename: LPWSTR, lpdwHandle: LPDWORD): DWORD{.
-      stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeW".}
-  proc GetFileVersionInfo*(lptstrFilename: LPWSTR, dwHandle: DWORD,
-                           dwLen: DWORD, lpData: LPVOID): WINBOOL{.stdcall,
-      dynlib: "version", importc: "GetFileVersionInfoW".}
-  proc VerLanguageName*(wLang: DWORD, szLang: LPWSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "VerLanguageNameW".}
-  proc VerQueryValue*(pBlock: LPVOID, lpSubBlock: LPWSTR, lplpBuffer: LPVOID,
-                      puLen: PUINT): WINBOOL{.stdcall, dynlib: "version",
-      importc: "VerQueryValueW".}
-  proc VerFindFile*(uFlags: DWORD, szFileName: LPWSTR, szWinDir: LPWSTR,
-                    szAppDir: LPWSTR, szCurDir: LPWSTR, lpuCurDirLen: PUINT,
-                    szDestDir: LPWSTR, lpuDestDirLen: PUINT): DWORD{.stdcall,
-      dynlib: "version", importc: "VerFindFileW".}
-  proc RegSetValueEx*(hKey: HKEY, lpValueName: LPCWSTR, Reserved: DWORD,
-                      dwType: DWORD, lpData: LPBYTE, cbData: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegSetValueExW".}
-  proc RegUnLoadKey*(hKey: HKEY, lpSubKey: LPCWSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegUnLoadKeyW".}
-  proc InitiateSystemShutdown*(lpMachineName: LPWSTR, lpMessage: LPWSTR,
-                               dwTimeout: DWORD, bForceAppsClosed: WINBOOL,
-                               bRebootAfterShutdown: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "InitiateSystemShutdownW".}
-  proc AbortSystemShutdown*(lpMachineName: LPWSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "AbortSystemShutdownW".}
-  proc RegRestoreKey*(hKey: HKEY, lpFile: LPCWSTR, dwFlags: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegRestoreKeyW".}
-  proc RegSaveKey*(hKey: HKEY, lpFile: LPCWSTR,
-                   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegSaveKeyW".}
-  proc RegSetValue*(hKey: HKEY, lpSubKey: LPCWSTR, dwType: DWORD,
-                    lpData: LPCWSTR, cbData: DWORD): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegSetValueW".}
-  proc RegQueryValue*(hKey: HKEY, lpSubKey: LPCWSTR, lpValue: LPWSTR,
-                      lpcbValue: PLONG): LONG{.stdcall, dynlib: "advapi32",
-      importc: "RegQueryValueW".}
-  proc RegQueryMultipleValues*(hKey: HKEY, val_list: PVALENT, num_vals: DWORD,
-                               lpValueBuf: LPWSTR, ldwTotsize: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesW".}
-  proc RegQueryValueEx*(hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD,
-                        lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegQueryValueExW".}
-  proc RegReplaceKey*(hKey: HKEY, lpSubKey: LPCWSTR, lpNewFile: LPCWSTR,
-                      lpOldFile: LPCWSTR): LONG{.stdcall, dynlib: "advapi32",
-      importc: "RegReplaceKeyW".}
-  proc RegConnectRegistry*(lpMachineName: LPWSTR, hKey: HKEY, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegConnectRegistryW".}
-  proc RegCreateKey*(hKey: HKEY, lpSubKey: LPCWSTR, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegCreateKeyW".}
-  proc RegCreateKeyEx*(hKey: HKEY, lpSubKey: LPCWSTR, Reserved: DWORD,
-                       lpClass: LPWSTR, dwOptions: DWORD, samDesired: REGSAM,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                       phkResult: PHKEY, lpdwDisposition: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegCreateKeyExW".}
-  proc RegDeleteKey*(hKey: HKEY, lpSubKey: LPCWSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegDeleteKeyW".}
-  proc RegDeleteValue*(hKey: HKEY, lpValueName: LPCWSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegDeleteValueW".}
-  proc RegEnumKey*(hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR, cbName: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumKeyW".}
-  proc RegEnumKeyEx*(hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR,
-                     lpcbName: LPDWORD, lpReserved: LPDWORD, lpClass: LPWSTR,
-                     lpcbClass: LPDWORD, lpftLastWriteTime: PFILETIME): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumKeyExW".}
-  proc RegEnumValue*(hKey: HKEY, dwIndex: DWORD, lpValueName: LPWSTR,
-                     lpcbValueName: LPDWORD, lpReserved: LPDWORD,
-                     lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumValueW".}
-  proc RegLoadKey*(hKey: HKEY, lpSubKey: LPCWSTR, lpFile: LPCWSTR): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegLoadKeyW".}
-  proc RegOpenKey*(hKey: HKEY, lpSubKey: LPCWSTR, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegOpenKeyW".}
-  proc RegOpenKeyEx*(hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD,
-                     samDesired: REGSAM, phkResult: PHKEY): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegOpenKeyExW".}
-  proc RegQueryInfoKey*(hKey: HKEY, lpClass: LPWSTR, lpcbClass: LPDWORD,
-                        lpReserved: LPDWORD, lpcSubKeys: LPDWORD,
-                        lpcbMaxSubKeyLen: LPDWORD, lpcbMaxClassLen: LPDWORD,
-                        lpcValues: LPDWORD, lpcbMaxValueNameLen: LPDWORD,
-                        lpcbMaxValueLen: LPDWORD,
-                        lpcbSecurityDescriptor: LPDWORD,
-                        lpftLastWriteTime: PFILETIME): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegQueryInfoKeyW".}
-  proc CompareString*(Locale: LCID, dwCmpFlags: DWORD, lpString1: LPCWSTR,
-                      cchCount1: int32, lpString2: LPCWSTR, cchCount2: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "CompareStringW".}
-  proc LCMapString*(Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCWSTR,
-                    cchSrc: int32, lpDestStr: LPWSTR, cchDest: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "LCMapStringW".}
-  proc GetLocaleInfo*(Locale: LCID, LCType: LCTYPE, lpLCData: LPWSTR,
-                      cchData: int32): int32{.stdcall, dynlib: "kernel32",
-      importc: "GetLocaleInfoW".}
-  proc SetLocaleInfo*(Locale: LCID, LCType: LCTYPE, lpLCData: LPCWSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetLocaleInfoW".}
-  proc GetTimeFormat*(Locale: LCID, dwFlags: DWORD, lpTime: LPSYSTEMTIME,
-                      lpFormat: LPCWSTR, lpTimeStr: LPWSTR, cchTime: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "GetTimeFormatW".}
-  proc GetDateFormat*(Locale: LCID, dwFlags: DWORD, lpDate: LPSYSTEMTIME,
-                      lpFormat: LPCWSTR, lpDateStr: LPWSTR, cchDate: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "GetDateFormatW".}
-  proc GetNumberFormat*(Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR,
-                        lpFormat: PNUMBERFMT, lpNumberStr: LPWSTR,
-                        cchNumber: int32): int32{.stdcall, dynlib: "kernel32",
-      importc: "GetNumberFormatW".}
-  proc GetCurrencyFormat*(Locale: LCID, dwFlags: DWORD, lpValue: LPCWSTR,
-                          lpFormat: PCURRENCYFMT, lpCurrencyStr: LPWSTR,
-                          cchCurrency: int32): int32{.stdcall,
-      dynlib: "kernel32", importc: "GetCurrencyFormatW".}
-  proc EnumCalendarInfo*(lpCalInfoEnumProc: CALINFO_ENUMPROC, Locale: LCID,
-                         Calendar: CALID, CalType: CALTYPE): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EnumCalendarInfoW".}
-  proc EnumTimeFormats*(lpTimeFmtEnumProc: TIMEFMT_ENUMPROC, Locale: LCID,
-                        dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumTimeFormatsW".}
-  proc EnumDateFormats*(lpDateFmtEnumProc: DATEFMT_ENUMPROC, Locale: LCID,
-                        dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumDateFormatsW".}
-  proc GetStringTypeEx*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCWSTR,
-                        cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetStringTypeExW".}
-  proc GetStringType*(dwInfoType: DWORD, lpSrcStr: LPCWSTR, cchSrc: int32,
-                      lpCharType: LPWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "GetStringTypeW".}
-  proc FoldString*(dwMapFlags: DWORD, lpSrcStr: LPCWSTR, cchSrc: int32,
-                   lpDestStr: LPWSTR, cchDest: int32): int32{.stdcall,
-      dynlib: "kernel32", importc: "FoldStringW".}
-  proc EnumSystemLocales*(lpLocaleEnumProc: LOCALE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumSystemLocalesW".}
-  proc EnumSystemCodePages*(lpCodePageEnumProc: CODEPAGE_ENUMPROC,
-                            dwFlags: DWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EnumSystemCodePagesW".}
-  proc PeekConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".}
-  proc ReadConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".}
-  proc WriteConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                          nLength: DWORD, lpNumberOfEventsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleInputW".}
-  proc ReadConsoleOutput*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                          dwBufferSize: COORD, dwBufferCoord: COORD,
-                          lpReadRegion: PSMALL_RECT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "ReadConsoleOutputW".}
-  proc WriteConsoleOutput*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                           dwBufferSize: COORD, dwBufferCoord: COORD,
-                           lpWriteRegion: PSMALL_RECT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WriteConsoleOutputW".}
-  proc ReadConsoleOutputCharacter*(hConsoleOutput: HANDLE, lpCharacter: LPWSTR,
-                                   nLength: DWORD, dwReadCoord: COORD,
-                                   lpNumberOfCharsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterW".}
-  proc WriteConsoleOutputCharacter*(hConsoleOutput: HANDLE,
-                                    lpCharacter: LPCWSTR, nLength: DWORD,
-                                    dwWriteCoord: COORD,
-                                    lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterW".}
-  proc FillConsoleOutputCharacter*(hConsoleOutput: HANDLE, cCharacter: WCHAR,
-                                   nLength: DWORD, dwWriteCoord: COORD,
-                                   lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterW".}
-  proc ScrollConsoleScreenBuffer*(hConsoleOutput: HANDLE,
-                                  lpScrollRectangle: PSMALL_RECT,
-                                  lpClipRectangle: PSMALL_RECT,
-                                  dwDestinationOrigin: COORD, lpFill: PCHAR_INFO): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferW".}
-  proc GetConsoleTitle*(lpConsoleTitle: LPWSTR, nSize: DWORD): DWORD{.stdcall,
-      dynlib: "kernel32", importc: "GetConsoleTitleW".}
-  proc SetConsoleTitle*(lpConsoleTitle: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetConsoleTitleW".}
-  proc ReadConsole*(hConsoleInput: HANDLE, lpBuffer: LPVOID,
-                    nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD,
-                    lpReserved: LPVOID): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "ReadConsoleW".}
-  proc WriteConsole*(hConsoleOutput: HANDLE, lpBuffer: pointer,
-                     nNumberOfCharsToWrite: DWORD,
-                     lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleW".}
-  proc WNetAddConnection*(lpRemoteName: LPCWSTR, lpPassword: LPCWSTR,
-                          lpLocalName: LPCWSTR): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetAddConnectionW".}
-  proc WNetAddConnection2*(lpNetResource: LPNETRESOURCE, lpPassword: LPCWSTR,
-                           lpUserName: LPCWSTR, dwFlags: DWORD): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetAddConnection2W".}
-  proc WNetAddConnection3*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                           lpPassword: LPCWSTR, lpUserName: LPCWSTR,
-                           dwFlags: DWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetAddConnection3W".}
-  proc WNetCancelConnection*(lpName: LPCWSTR, fForce: WINBOOL): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetCancelConnectionW".}
-  proc WNetCancelConnection2*(lpName: LPCWSTR, dwFlags: DWORD, fForce: WINBOOL): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetCancelConnection2W".}
-  proc WNetGetConnection*(lpLocalName: LPCWSTR, lpRemoteName: LPWSTR,
-                          lpnLength: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetGetConnectionW".}
-  proc WNetUseConnection*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                          lpUserID: LPCWSTR, lpPassword: LPCWSTR,
-                          dwFlags: DWORD, lpAccessName: LPWSTR,
-                          lpBufferSize: LPDWORD, lpResult: LPDWORD): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetUseConnectionW".}
-  proc WNetSetConnection*(lpName: LPCWSTR, dwProperties: DWORD, pvValues: LPVOID): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetSetConnectionW".}
-  proc WNetConnectionDialog1*(lpConnDlgStruct: LPCONNECTDLGSTRUCT): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1W".}
-  proc WNetDisconnectDialog1*(lpConnDlgStruct: LPDISCDLGSTRUCT): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetDisconnectDialog1W".}
-  proc WNetOpenEnum*(dwScope: DWORD, dwType: DWORD, dwUsage: DWORD,
-                     lpNetResource: LPNETRESOURCE, lphEnum: LPHANDLE): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetOpenEnumW".}
-  proc WNetEnumResource*(hEnum: HANDLE, lpcCount: LPDWORD, lpBuffer: LPVOID,
-                         lpBufferSize: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetEnumResourceW".}
-  proc WNetGetUniversalName*(lpLocalPath: LPCWSTR, dwInfoLevel: DWORD,
-                             lpBuffer: LPVOID, lpBufferSize: LPDWORD): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameW".}
-  proc WNetGetUser*(lpName: LPCWSTR, lpUserName: LPWSTR, lpnLength: LPDWORD): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetUserW".}
-  proc WNetGetProviderName*(dwNetType: DWORD, lpProviderName: LPWSTR,
-                            lpBufferSize: LPDWORD): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetGetProviderNameW".}
-  proc WNetGetNetworkInformation*(lpProvider: LPCWSTR,
-                                  lpNetInfoStruct: LPNETINFOSTRUCT): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationW".}
-  proc WNetGetLastError*(lpError: LPDWORD, lpErrorBuf: LPWSTR,
-                         nErrorBufSize: DWORD, lpNameBuf: LPWSTR,
-                         nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetGetLastErrorW".}
-  proc MultinetGetConnectionPerformance*(lpNetResource: LPNETRESOURCE,
-      lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT): DWORD{.stdcall,
-      dynlib: "mpr", importc: "MultinetGetConnectionPerformanceW".}
-  proc ChangeServiceConfig*(hService: SC_HANDLE, dwServiceType: DWORD,
-                            dwStartType: DWORD, dwErrorControl: DWORD,
-                            lpBinaryPathName: LPCWSTR,
-                            lpLoadOrderGroup: LPCWSTR, lpdwTagId: LPDWORD,
-                            lpDependencies: LPCWSTR,
-                            lpServiceStartName: LPCWSTR, lpPassword: LPCWSTR,
-                            lpDisplayName: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ChangeServiceConfigW".}
-  proc CreateService*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                      lpDisplayName: LPCWSTR, dwDesiredAccess: DWORD,
-                      dwServiceType: DWORD, dwStartType: DWORD,
-                      dwErrorControl: DWORD, lpBinaryPathName: LPCWSTR,
-                      lpLoadOrderGroup: LPCWSTR, lpdwTagId: LPDWORD,
-                      lpDependencies: LPCWSTR, lpServiceStartName: LPCWSTR,
-                      lpPassword: LPCWSTR): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "CreateServiceW".}
-  proc EnumDependentServices*(hService: SC_HANDLE, dwServiceState: DWORD,
-                              lpServices: LPENUM_SERVICE_STATUS,
-                              cbBufSize: DWORD, pcbBytesNeeded: LPDWORD,
-                              lpServicesReturned: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "EnumDependentServicesW".}
-  proc EnumServicesStatus*(hSCManager: SC_HANDLE, dwServiceType: DWORD,
-                           dwServiceState: DWORD,
-                           lpServices: LPENUM_SERVICE_STATUS, cbBufSize: DWORD,
-                           pcbBytesNeeded: LPDWORD, lpServicesReturned: LPDWORD,
-                           lpResumeHandle: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "EnumServicesStatusW".}
-  proc GetServiceKeyName*(hSCManager: SC_HANDLE, lpDisplayName: LPCWSTR,
-                          lpServiceName: LPWSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetServiceKeyNameW".}
-  proc GetServiceDisplayName*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                              lpDisplayName: LPWSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetServiceDisplayNameW".}
-  proc OpenSCManager*(lpMachineName: LPCWSTR, lpDatabaseName: LPCWSTR,
-                      dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "OpenSCManagerW".}
-  proc OpenService*(hSCManager: SC_HANDLE, lpServiceName: LPCWSTR,
-                    dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "OpenServiceW".}
-  proc QueryServiceConfig*(hService: SC_HANDLE,
-                           lpServiceConfig: LPQUERY_SERVICE_CONFIG,
-                           cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "QueryServiceConfigW".}
-  proc QueryServiceLockStatus*(hSCManager: SC_HANDLE,
-                               lpLockStatus: LPQUERY_SERVICE_LOCK_STATUS,
-                               cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "QueryServiceLockStatusW".}
-  proc RegisterServiceCtrlHandler*(lpServiceName: LPCWSTR,
-                                   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "RegisterServiceCtrlHandlerW".}
-  proc StartServiceCtrlDispatcher*(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "StartServiceCtrlDispatcherW".}
-  proc StartService*(hService: SC_HANDLE, dwNumServiceArgs: DWORD,
-                     lpServiceArgVectors: LPCWSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "StartServiceW".}
-  proc DragQueryFile*(para1: HDROP, para2: int, para3: LPCWSTR, para4: int): int{.
-      stdcall, dynlib: "shell32", importc: "DragQueryFileW".}
-  proc ExtractAssociatedIcon*(para1: HINST, para2: LPCWSTR, para3: LPWORD): HICON{.
-      stdcall, dynlib: "shell32", importc: "ExtractAssociatedIconW".}
-  proc ExtractIcon*(para1: HINST, para2: LPCWSTR, para3: int): HICON{.stdcall,
-      dynlib: "shell32", importc: "ExtractIconW".}
-  proc FindExecutable*(para1: LPCWSTR, para2: LPCWSTR, para3: LPCWSTR): HINST{.
-      stdcall, dynlib: "shell32", importc: "FindExecutableW".}
-  proc ShellAbout*(para1: HWND, para2: LPCWSTR, para3: LPCWSTR, para4: HICON): int32{.
-      stdcall, dynlib: "shell32", importc: "ShellAboutW".}
-  proc ShellExecute*(para1: HWND, para2: LPCWSTR, para3: LPCWSTR,
-                     para4: LPCWSTR, para5: LPCWSTR, para6: int32): HINST{.
-      stdcall, dynlib: "shell32", importc: "ShellExecuteW".}
-  proc Shell_NotifyIcon*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
-      stdcall, dynlib: "shell32", importc: "Shell_NotifyIconW".}
-  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",
-      importc: "DdeInitializeW".}
-  proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: LPCWSTR, para4: DWORD,
-                       para5: int32): DWORD{.stdcall, dynlib: "user32",
-      importc: "DdeQueryStringW".}
-  proc LogonUser*(para1: LPWSTR, para2: LPWSTR, para3: LPWSTR, para4: DWORD,
-                  para5: DWORD, para6: PHANDLE): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LogonUserW".}
-  proc CreateProcessAsUser*(para1: HANDLE, para2: LPCWSTR, para3: LPWSTR,
-                            para4: LPSECURITY_ATTRIBUTES,
-                            para5: LPSECURITY_ATTRIBUTES, para6: WINBOOL,
-                            para7: DWORD, para8: LPVOID, para9: LPCWSTR,
-                            para10: LPSTARTUPINFO, para11: LPPROCESS_INFORMATION): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "CreateProcessAsUserW".}
-else:
-  proc GetBinaryType*(lpApplicationName: LPCSTR, lpBinaryType: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".}
-  proc GetShortPathName*(lpszLongPath: LPCSTR, lpszShortPath: LPSTR,
-                         cchBuffer: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetShortPathNameA".}
-  proc GetEnvironmentStrings*(): LPSTR{.stdcall, dynlib: "kernel32",
-                                        importc: "GetEnvironmentStringsA".}
-  proc FreeEnvironmentStrings*(para1: LPSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "FreeEnvironmentStringsA".}
-  proc FormatMessage*(dwFlags: DWORD, lpSource: LPCVOID, dwMessageId: DWORD,
-                      dwLanguageId: DWORD, lpBuffer: LPSTR, nSize: DWORD,
-                      Arguments: va_list): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "FormatMessageA".}
-  proc CreateMailslot*(lpName: LPCSTR, nMaxMessageSize: DWORD,
-                       lReadTimeout: DWORD,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateMailslotA".}
-  proc lstrcmp*(lpString1: LPCSTR, lpString2: LPCSTR): int32{.stdcall,
-      dynlib: "kernel32", importc: "lstrcmpA".}
-  proc lstrcmpi*(lpString1: LPCSTR, lpString2: LPCSTR): int32{.stdcall,
-      dynlib: "kernel32", importc: "lstrcmpiA".}
-  proc lstrcpyn*(lpString1: LPSTR, lpString2: LPCSTR, iMaxLength: int32): LPSTR{.
-      stdcall, dynlib: "kernel32", importc: "lstrcpynA".}
-  proc lstrcpy*(lpString1: LPSTR, lpString2: LPCSTR): LPSTR{.stdcall,
-      dynlib: "kernel32", importc: "lstrcpyA".}
-  proc lstrcat*(lpString1: LPSTR, lpString2: LPCSTR): LPSTR{.stdcall,
-      dynlib: "kernel32", importc: "lstrcatA".}
-  proc lstrlen*(lpString: LPCSTR): int32{.stdcall, dynlib: "kernel32",
-      importc: "lstrlenA".}
-  proc CreateMutex*(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
-                    bInitialOwner: WINBOOL, lpName: LPCSTR): HANDLE{.stdcall,
-      dynlib: "kernel32", importc: "CreateMutexA".}
-  proc OpenMutex*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                  lpName: LPCSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenMutexA".}
-  proc CreateEvent*(lpEventAttributes: LPSECURITY_ATTRIBUTES,
-                    bManualReset: WINBOOL, bInitialState: WINBOOL,
-                    lpName: LPCSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "CreateEventA".}
-  proc OpenEvent*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                  lpName: LPCSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenEventA".}
-  proc CreateSemaphore*(lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
-                        lInitialCount: LONG, lMaximumCount: LONG, lpName: LPCSTR): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateSemaphoreA".}
-  proc OpenSemaphore*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                      lpName: LPCSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenSemaphoreA".}
-  proc CreateFileMapping*(hFile: HANDLE,
-                          lpFileMappingAttributes: LPSECURITY_ATTRIBUTES,
-                          flProtect: DWORD, dwMaximumSizeHigh: DWORD,
-                          dwMaximumSizeLow: DWORD, lpName: LPCSTR): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateFileMappingA".}
-  proc OpenFileMapping*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                        lpName: LPCSTR): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "OpenFileMappingA".}
-  proc GetLogicalDriveStrings*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetLogicalDriveStringsA".}
-  proc LoadLibrary*(lpLibFileName: LPCSTR): HINST{.stdcall, dynlib: "kernel32",
-      importc: "LoadLibraryA".}
-  proc LoadLibraryEx*(lpLibFileName: LPCSTR, hFile: HANDLE, dwFlags: DWORD): HINST{.
-      stdcall, dynlib: "kernel32", importc: "LoadLibraryExA".}
-  proc GetModuleFileName*(hModule: HINST, lpFilename: LPSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetModuleFileNameA".}
-  proc GetModuleHandle*(lpModuleName: LPCSTR): HMODULE{.stdcall,
-      dynlib: "kernel32", importc: "GetModuleHandleA".}
-  proc FatalAppExit*(uAction: UINT, lpMessageText: LPCSTR){.stdcall,
-      dynlib: "kernel32", importc: "FatalAppExitA".}
-  proc GetCommandLine*(): LPSTR{.stdcall, dynlib: "kernel32",
-                                 importc: "GetCommandLineA".}
-  proc GetEnvironmentVariable*(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetEnvironmentVariableA".}
-  proc SetEnvironmentVariable*(lpName: LPCSTR, lpValue: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableA".}
-  proc ExpandEnvironmentStrings*(lpSrc: LPCSTR, lpDst: LPSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "ExpandEnvironmentStringsA".}
-  proc OutputDebugString*(lpOutputString: LPCSTR){.stdcall, dynlib: "kernel32",
-      importc: "OutputDebugStringA".}
-  proc FindResource*(hModule: HINST, lpName: LPCSTR, lpType: LPCSTR): HRSRC{.
-      stdcall, dynlib: "kernel32", importc: "FindResourceA".}
-  proc FindResourceEx*(hModule: HINST, lpType: LPCSTR, lpName: LPCSTR,
-                       wLanguage: int16): HRSRC{.stdcall, dynlib: "kernel32",
-      importc: "FindResourceExA".}
-  proc EnumResourceTypes*(hModule: HINST, lpEnumFunc: ENUMRESTYPEPROC,
-                          lParam: LONG): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumResourceTypesA".}
-  proc EnumResourceNames*(hModule: HINST, lpType: LPCSTR,
-                          lpEnumFunc: ENUMRESNAMEPROC, lParam: LONG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumResourceNamesA".}
-  proc EnumResourceLanguages*(hModule: HINST, lpType: LPCSTR, lpName: LPCSTR,
-                              lpEnumFunc: ENUMRESLANGPROC, lParam: LONG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumResourceLanguagesA".}
-  proc BeginUpdateResource*(pFileName: LPCSTR, bDeleteExistingResources: WINBOOL): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "BeginUpdateResourceA".}
-  proc UpdateResource*(hUpdate: HANDLE, lpType: LPCSTR, lpName: LPCSTR,
-                       wLanguage: int16, lpData: LPVOID, cbData: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "UpdateResourceA".}
-  proc EndUpdateResource*(hUpdate: HANDLE, fDiscard: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EndUpdateResourceA".}
-  proc GlobalAddAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",
-      importc: "GlobalAddAtomA".}
-  proc GlobalFindAtom*(lpString: LPCSTR): ATOM{.stdcall, dynlib: "kernel32",
-      importc: "GlobalFindAtomA".}
-  proc GlobalGetAtomName*(nAtom: ATOM, lpBuffer: LPSTR, nSize: int32): UINT{.
-      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,
-      dynlib: "kernel32", importc: "GetAtomNameA".}
-  proc GetProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR, nDefault: WINT): UINT{.
-      stdcall, dynlib: "kernel32", importc: "GetProfileIntA".}
-  proc GetProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                         lpDefault: LPCSTR, lpReturnedString: LPSTR,
-                         nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetProfileStringA".}
-  proc WriteProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                           lpString: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WriteProfileStringA".}
-  proc GetProfileSection*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
-                          nSize: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-      importc: "GetProfileSectionA".}
-  proc WriteProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteProfileSectionA".}
-  proc GetPrivateProfileInt*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                             nDefault: WINT, lpFileName: LPCSTR): UINT{.stdcall,
-      dynlib: "kernel32", importc: "GetPrivateProfileIntA".}
-  proc GetPrivateProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                                lpDefault: LPCSTR, lpReturnedString: LPSTR,
-                                nSize: DWORD, lpFileName: LPCSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStringA".}
-  proc WritePrivateProfileString*(lpAppName: LPCSTR, lpKeyName: LPCSTR,
-                                  lpString: LPCSTR, lpFileName: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStringA".}
-  proc GetPrivateProfileSection*(lpAppName: LPCSTR, lpReturnedString: LPSTR,
-                                 nSize: DWORD, lpFileName: LPCSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetPrivateProfileSectionA".}
-  proc WritePrivateProfileSection*(lpAppName: LPCSTR, lpString: LPCSTR,
-                                   lpFileName: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WritePrivateProfileSectionA".}
-  proc GetDriveType*(lpRootPathName: LPCSTR): UINT{.stdcall, dynlib: "kernel32",
-      importc: "GetDriveTypeA".}
-  proc GetSystemDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.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,
-      dynlib: "kernel32", importc: "GetTempFileNameA".}
-  proc GetWindowsDirectory*(lpBuffer: LPSTR, uSize: UINT): UINT{.stdcall,
-      dynlib: "kernel32", importc: "GetWindowsDirectoryA".}
-  proc SetCurrentDirectory*(lpPathName: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetCurrentDirectoryA".}
-  proc GetCurrentDirectory*(nBufferLength: DWORD, lpBuffer: LPSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetCurrentDirectoryA".}
-  proc GetDiskFreeSpace*(lpRootPathName: LPCSTR, lpSectorsPerCluster: LPDWORD,
-                         lpBytesPerSector: LPDWORD,
-                         lpNumberOfFreeClusters: LPDWORD,
-                         lpTotalNumberOfClusters: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetDiskFreeSpaceA".}
-  proc CreateDirectory*(lpPathName: LPCSTR,
-                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateDirectoryA".}
-  proc CreateDirectoryEx*(lpTemplateDirectory: LPCSTR, lpNewDirectory: LPCSTR,
-                          lpSecurityAttributes: LPSECURITY_ATTRIBUTES): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateDirectoryExA".}
-  proc RemoveDirectory*(lpPathName: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "RemoveDirectoryA".}
-  proc GetFullPathName*(lpFileName: LPCSTR, nBufferLength: DWORD,
-                        lpBuffer: LPSTR, lpFilePart: var LPSTR): DWORD{.stdcall,
-      dynlib: "kernel32", importc: "GetFullPathNameA".}
-  proc DefineDosDevice*(dwFlags: DWORD, lpDeviceName: LPCSTR,
-                        lpTargetPath: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "DefineDosDeviceA".}
-  proc QueryDosDevice*(lpDeviceName: LPCSTR, lpTargetPath: LPSTR, ucchMax: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "QueryDosDeviceA".}
-  proc CreateFile*(lpFileName: LPCSTR, dwDesiredAccess: DWORD,
-                   dwShareMode: DWORD,
-                   lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                   dwCreationDisposition: DWORD, dwFlagsAndAttributes: DWORD,
-                   hTemplateFile: HANDLE): HANDLE{.stdcall, dynlib: "kernel32",
-      importc: "CreateFileA".}
-  proc SetFileAttributes*(lpFileName: LPCSTR, dwFileAttributes: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetFileAttributesA".}
-  proc GetFileAttributes*(lpFileName: LPCSTR): DWORD{.stdcall,
-      dynlib: "kernel32", importc: "GetFileAttributesA".}
-  proc GetCompressedFileSize*(lpFileName: LPCSTR, lpFileSizeHigh: LPDWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "GetCompressedFileSizeA".}
-  proc DeleteFile*(lpFileName: LPCSTR): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "DeleteFileA".}
-  proc SearchPath*(lpPath: LPCSTR, lpFileName: LPCSTR, lpExtension: LPCSTR,
-                   nBufferLength: DWORD, lpBuffer: LPSTR, lpFilePart: LPSTR): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "SearchPathA".}
-  proc CopyFile*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR,
-                 bFailIfExists: WINBOOL): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "CopyFileA".}
-  proc MoveFile*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "MoveFileA".}
-  proc MoveFileEx*(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR,
-                   dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "MoveFileExA".}
-  proc CreateNamedPipe*(lpName: LPCSTR, dwOpenMode: DWORD, dwPipeMode: DWORD,
-                        nMaxInstances: DWORD, nOutBufferSize: DWORD,
-                        nInBufferSize: DWORD, nDefaultTimeOut: DWORD,
-                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "CreateNamedPipeA".}
-  proc GetNamedPipeHandleState*(hNamedPipe: HANDLE, lpState: LPDWORD,
-                                lpCurInstances: LPDWORD,
-                                lpMaxCollectionCount: LPDWORD,
-                                lpCollectDataTimeout: LPDWORD,
-                                lpUserName: LPSTR, nMaxUserNameSize: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "GetNamedPipeHandleStateA".}
-  proc CallNamedPipe*(lpNamedPipeName: LPCSTR, lpInBuffer: LPVOID,
-                      nInBufferSize: DWORD, lpOutBuffer: LPVOID,
-                      nOutBufferSize: DWORD, lpBytesRead: LPDWORD,
-                      nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "CallNamedPipeA".}
-  proc WaitNamedPipe*(lpNamedPipeName: LPCSTR, nTimeOut: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WaitNamedPipeA".}
-  proc SetVolumeLabel*(lpRootPathName: LPCSTR, lpVolumeName: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetVolumeLabelA".}
-  proc GetVolumeInformation*(lpRootPathName: LPCSTR, lpVolumeNameBuffer: LPSTR,
-                             nVolumeNameSize: DWORD,
-                             lpVolumeSerialNumber: LPDWORD,
-                             lpMaximumComponentLength: LPDWORD,
-                             lpFileSystemFlags: LPDWORD,
-                             lpFileSystemNameBuffer: LPSTR,
-                             nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetVolumeInformationA".}
-  proc ClearEventLog*(hEventLog: HANDLE, lpBackupFileName: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "ClearEventLogA".}
-  proc BackupEventLog*(hEventLog: HANDLE, lpBackupFileName: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "BackupEventLogA".}
-  proc OpenEventLog*(lpUNCServerName: LPCSTR, lpSourceName: LPCSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "OpenEventLogA".}
-  proc RegisterEventSource*(lpUNCServerName: LPCSTR, lpSourceName: LPCSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "RegisterEventSourceA".}
-  proc OpenBackupEventLog*(lpUNCServerName: LPCSTR, lpFileName: LPCSTR): HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "OpenBackupEventLogA".}
-  proc ReadEventLog*(hEventLog: HANDLE, dwReadFlags: DWORD,
-                     dwRecordOffset: DWORD, lpBuffer: LPVOID,
-                     nNumberOfBytesToRead: DWORD, pnBytesRead: LPDWORD,
-                     pnMinNumberOfBytesNeeded: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ReadEventLogA".}
-  proc ReportEvent*(hEventLog: HANDLE, wType: int16, wCategory: int16,
-                    dwEventID: DWORD, lpUserSid: PSID, wNumStrings: int16,
-                    dwDataSize: DWORD, lpStrings: LPPCSTR, lpRawData: LPVOID): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "ReportEventA".}
-  proc AccessCheckAndAuditAlarm*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                                 ObjectTypeName: LPSTR, ObjectName: LPSTR,
-                                 SecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 DesiredAccess: DWORD,
-                                 GenericMapping: PGENERIC_MAPPING,
-                                 ObjectCreation: WINBOOL,
-                                 GrantedAccess: LPDWORD, AccessStatus: LPBOOL,
-                                 pfGenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "AccessCheckAndAuditAlarmA".}
-  proc ObjectOpenAuditAlarm*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                             ObjectTypeName: LPSTR, ObjectName: LPSTR,
-                             pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                             ClientToken: HANDLE, DesiredAccess: DWORD,
-                             GrantedAccess: DWORD, Privileges: PPRIVILEGE_SET,
-                             ObjectCreation: WINBOOL, AccessGranted: WINBOOL,
-                             GenerateOnClose: LPBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".}
-  proc ObjectPrivilegeAuditAlarm*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                                  ClientToken: HANDLE, DesiredAccess: DWORD,
-                                  Privileges: PPRIVILEGE_SET,
-                                  AccessGranted: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".}
-  proc ObjectCloseAuditAlarm*(SubsystemName: LPCSTR, HandleId: LPVOID,
-                              GenerateOnClose: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ObjectCloseAuditAlarmA".}
-  proc PrivilegedServiceAuditAlarm*(SubsystemName: LPCSTR, ServiceName: LPCSTR,
-                                    ClientToken: HANDLE,
-                                    Privileges: PPRIVILEGE_SET,
-                                    AccessGranted: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".}
-  proc SetFileSecurity*(lpFileName: LPCSTR,
-                        SecurityInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "SetFileSecurityA".}
-  proc GetFileSecurity*(lpFileName: LPCSTR,
-                        RequestedInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                        nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetFileSecurityA".}
-  proc FindFirstChangeNotification*(lpPathName: LPCSTR, bWatchSubtree: WINBOOL,
-                                    dwNotifyFilter: DWORD): HANDLE{.stdcall,
-      dynlib: "kernel32", importc: "FindFirstChangeNotificationA".}
-  proc IsBadStringPtr*(lpsz: LPCSTR, ucchMax: UINT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "IsBadStringPtrA".}
-  proc LookupAccountSid*(lpSystemName: LPCSTR, Sid: PSID, Name: LPSTR,
-                         cbName: LPDWORD, ReferencedDomainName: LPSTR,
-                         cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupAccountSidA".}
-  proc LookupAccountName*(lpSystemName: LPCSTR, lpAccountName: LPCSTR,
-                          Sid: PSID, cbSid: LPDWORD,
-                          ReferencedDomainName: LPSTR,
-                          cbReferencedDomainName: LPDWORD, peUse: PSID_NAME_USE): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupAccountNameA".}
-  proc LookupPrivilegeValue*(lpSystemName: LPCSTR, lpName: LPCSTR, lpLuid: PLUID): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "LookupPrivilegeValueA".}
-  proc LookupPrivilegeName*(lpSystemName: LPCSTR, lpLuid: PLUID, lpName: LPSTR,
-                            cbName: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LookupPrivilegeNameA".}
-  proc LookupPrivilegeDisplayName*(lpSystemName: LPCSTR, lpName: LPCSTR,
-                                   lpDisplayName: LPSTR, cbDisplayName: LPDWORD,
-                                   lpLanguageId: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameA".}
-  proc BuildCommDCB*(lpDef: LPCSTR, lpDCB: LPDCB): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "BuildCommDCBA".}
-  proc BuildCommDCBAndTimeouts*(lpDef: LPCSTR, lpDCB: LPDCB,
-                                lpCommTimeouts: LPCOMMTIMEOUTS): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".}
-  proc CommConfigDialog*(lpszName: LPCSTR, hWnd: HWND, lpCC: LPCOMMCONFIG): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".}
-  proc GetDefaultCommConfig*(lpszName: LPCSTR, lpCC: LPCOMMCONFIG,
-                             lpdwSize: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetDefaultCommConfigA".}
-  proc SetDefaultCommConfig*(lpszName: LPCSTR, lpCC: LPCOMMCONFIG, dwSize: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetDefaultCommConfigA".}
-  proc GetComputerName*(lpBuffer: LPSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetComputerNameA".}
-  proc SetComputerName*(lpComputerName: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetComputerNameA".}
-  proc GetUserName*(lpBuffer: LPSTR, nSize: LPDWORD): WINBOOL{.stdcall,
-      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,
-      dynlib: "user32", importc: "LoadKeyboardLayoutA".}
-  proc GetKeyboardLayoutName*(pwszKLID: LPSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetKeyboardLayoutNameA".}
-  proc CreateDesktop*(lpszDesktop: LPSTR, lpszDevice: LPSTR,
-                      pDevmode: LPDEVMODE, dwFlags: DWORD,
-                      dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HDESK{.
-      stdcall, dynlib: "user32", importc: "CreateDesktopA".}
-  proc OpenDesktop*(lpszDesktop: LPSTR, dwFlags: DWORD, fInherit: WINBOOL,
-                    dwDesiredAccess: DWORD): HDESK{.stdcall, dynlib: "user32",
-      importc: "OpenDesktopA".}
-  proc EnumDesktops*(hwinsta: HWINSTA, lpEnumFunc: DESKTOPENUMPROC,
-                     lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "EnumDesktopsA".}
-  proc CreateWindowStation*(lpwinsta: LPSTR, dwReserved: DWORD,
-                            dwDesiredAccess: DWORD, lpsa: LPSECURITY_ATTRIBUTES): HWINSTA{.
-      stdcall, dynlib: "user32", importc: "CreateWindowStationA".}
-  proc OpenWindowStation*(lpszWinSta: LPSTR, fInherit: WINBOOL,
-                          dwDesiredAccess: DWORD): HWINSTA{.stdcall,
-      dynlib: "user32", importc: "OpenWindowStationA".}
-  proc EnumWindowStations*(lpEnumFunc: ENUMWINDOWSTATIONPROC, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "EnumWindowStationsA".}
-  proc GetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                 nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".}
-  proc SetUserObjectInformation*(hObj: HANDLE, nIndex: int32, pvInfo: PVOID,
-                                 nLength: DWORD): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetUserObjectInformationA".}
-  proc RegisterWindowMessage*(lpString: LPCSTR): UINT{.stdcall,
-      dynlib: "user32", importc: "RegisterWindowMessageA".}
-  proc GetMessage*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                   wMsgFilterMax: UINT): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "GetMessageA".}
-  proc DispatchMessage*(lpMsg: LPMSG): LONG{.stdcall, dynlib: "user32",
-      importc: "DispatchMessageA".}
-  proc PeekMessage*(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT,
-                    wMsgFilterMax: UINT, wRemoveMsg: UINT): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "PeekMessageA".}
-  proc SendMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-      stdcall, dynlib: "user32", importc: "SendMessageA".}
-  proc SendMessageTimeout*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                           lParam: LPARAM, fuFlags: UINT, uTimeout: UINT,
-                           lpdwResult: LPDWORD): LRESULT{.stdcall,
-      dynlib: "user32", importc: "SendMessageTimeoutA".}
-  proc SendNotifyMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "SendNotifyMessageA".}
-  proc SendMessageCallback*(hWnd: HWND, Msg: UINT, wParam: WPARAM,
-                            lParam: LPARAM, lpResultCallBack: SENDASYNCPROC,
-                            dwData: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "SendMessageCallbackA".}
-  proc PostMessage*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "PostMessageA".}
-  proc PostThreadMessage*(idThread: DWORD, Msg: UINT, wParam: WPARAM,
-                          lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "PostThreadMessageA".}
-  proc DefWindowProc*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-      stdcall, dynlib: "user32", importc: "DefWindowProcA".}
-  proc CallWindowProc*(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT,
-                       wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-      dynlib: "user32", importc: "CallWindowProcA".}
-  proc RegisterClass*(lpWndClass: LPWNDCLASS): ATOM{.stdcall, dynlib: "user32",
-      importc: "RegisterClassA".}
-  proc UnregisterClass*(lpClassName: LPCSTR, hInstance: HINST): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "UnregisterClassA".}
-  proc GetClassInfo*(hInstance: HINST, lpClassName: LPCSTR,
-                     lpWndClass: LPWNDCLASS): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetClassInfoA".}
-  proc RegisterClassEx*(para1: LPWNDCLASSEX): ATOM{.stdcall, dynlib: "user32",
-      importc: "RegisterClassExA".}
-  proc GetClassInfoEx*(para1: HINST, para2: LPCSTR, para3: LPWNDCLASSEX): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "GetClassInfoExA".}
-  proc CreateWindowEx*(dwExStyle: DWORD, lpClassName: LPCSTR,
-                       lpWindowName: LPCSTR, dwStyle: DWORD, X: int32, Y: int32,
-                       nWidth: int32, nHeight: int32, hWndParent: HWND,
-                       hMenu: HMENU, hInstance: HINST, lpParam: LPVOID): HWND{.
-      stdcall, dynlib: "user32", importc: "CreateWindowExA".}
-  proc CreateDialogParam*(hInstance: HINST, lpTemplateName: LPCSTR,
-                          hWndParent: HWND, lpDialogFunc: DLGPROC,
-                          dwInitParam: LPARAM): HWND{.stdcall, dynlib: "user32",
-      importc: "CreateDialogParamA".}
-  proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                                  hWndParent: HWND, lpDialogFunc: DLGPROC,
-                                  dwInitParam: LPARAM): HWND{.stdcall,
-      dynlib: "user32", importc: "CreateDialogIndirectParamA".}
-  proc DialogBoxParam*(hInstance: HINST, lpTemplateName: LPCSTR,
-                       hWndParent: HWND, lpDialogFunc: DLGPROC,
-                       dwInitParam: LPARAM): int32{.stdcall, dynlib: "user32",
-      importc: "DialogBoxParamA".}
-  proc DialogBoxIndirectParam*(hInstance: HINST,
-                               hDialogTemplate: LPCDLGTEMPLATE,
-                               hWndParent: HWND, lpDialogFunc: DLGPROC,
-                               dwInitParam: LPARAM): int32{.stdcall,
-      dynlib: "user32", importc: "DialogBoxIndirectParamA".}
-  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",
-      importc: "GetDlgItemTextA".}
-  proc SendDlgItemMessage*(hDlg: HWND, nIDDlgItem: int32, Msg: UINT,
-                           wParam: WPARAM, lParam: LPARAM): LONG{.stdcall,
-      dynlib: "user32", importc: "SendDlgItemMessageA".}
-  proc DefDlgProc*(hDlg: HWND, Msg: UINT, wParam: WPARAM, lParam: 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,
-      dynlib: "user32", importc: "RegisterClipboardFormatA".}
-  proc GetClipboardFormatName*(format: UINT, lpszFormatName: LPSTR,
-                               cchMaxCount: int32): int32{.stdcall,
-      dynlib: "user32", importc: "GetClipboardFormatNameA".}
-  proc CharToOem*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "CharToOemA".}
-  proc OemToChar*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "OemToCharA".}
-  proc CharToOemBuff*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "CharToOemBuffA".}
-  proc OemToCharBuff*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-      stdcall, dynlib: "user32", importc: "OemToCharBuffA".}
-  proc CharUpper*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                       importc: "CharUpperA".}
-  proc CharUpperBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-      dynlib: "user32", importc: "CharUpperBuffA".}
-  proc CharLower*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                       importc: "CharLowerA".}
-  proc CharLowerBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-      dynlib: "user32", importc: "CharLowerBuffA".}
-  proc CharNext*(lpsz: LPCSTR): LPSTR{.stdcall, dynlib: "user32",
-                                       importc: "CharNextA".}
-  proc CharPrev*(lpszStart: LPCSTR, lpszCurrent: LPCSTR): LPSTR{.stdcall,
-      dynlib: "user32", importc: "CharPrevA".}
-  proc IsCharAlpha*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharAlphaA".}
-  proc IsCharAlphaNumeric*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "IsCharAlphaNumericA".}
-  proc IsCharUpper*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharUpperA".}
-  proc IsCharLower*(ch: CHAR): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "IsCharLowerA".}
-  proc GetKeyNameText*(lParam: LONG, lpString: LPSTR, nSize: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetKeyNameTextA".}
-  proc VkKeyScan*(ch: CHAR): SHORT{.stdcall, dynlib: "user32",
-                                    importc: "VkKeyScanA".}
-  proc VkKeyScanEx*(ch: CHAR, dwhkl: HKL): SHORT{.stdcall, dynlib: "user32",
-      importc: "VkKeyScanExA".}
-  proc MapVirtualKey*(uCode: UINT, uMapType: UINT): UINT{.stdcall,
-      dynlib: "user32", importc: "MapVirtualKeyA".}
-  proc MapVirtualKeyEx*(uCode: UINT, uMapType: UINT, dwhkl: HKL): UINT{.stdcall,
-      dynlib: "user32", importc: "MapVirtualKeyExA".}
-  proc LoadAccelerators*(hInstance: HINST, lpTableName: LPCSTR): HACCEL{.
-      stdcall, dynlib: "user32", importc: "LoadAcceleratorsA".}
-  proc CreateAcceleratorTable*(para1: LPACCEL, para2: int32): HACCEL{.stdcall,
-      dynlib: "user32", importc: "CreateAcceleratorTableA".}
-  proc CopyAcceleratorTable*(hAccelSrc: HACCEL, lpAccelDst: LPACCEL,
-                             cAccelEntries: int32): int32{.stdcall,
-      dynlib: "user32", importc: "CopyAcceleratorTableA".}
-  proc TranslateAccelerator*(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG): int32{.
-      stdcall, dynlib: "user32", importc: "TranslateAcceleratorA".}
-  proc LoadMenu*(hInstance: HINST, lpMenuName: LPCSTR): HMENU{.stdcall,
-      dynlib: "user32", importc: "LoadMenuA".}
-  proc LoadMenuIndirect*(lpMenuTemplate: LPMENUTEMPLATE): HMENU{.stdcall,
-      dynlib: "user32", importc: "LoadMenuIndirectA".}
-  proc ChangeMenu*(hMenu: HMENU, cmd: UINT, lpszNewItem: LPCSTR,
-                   cmdInsert: UINT, flags: UINT): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "ChangeMenuA".}
-  proc GetMenuString*(hMenu: HMENU, uIDItem: UINT, lpString: LPSTR,
-                      nMaxCount: int32, uFlag: UINT): int32{.stdcall,
-      dynlib: "user32", importc: "GetMenuStringA".}
-  proc InsertMenu*(hMenu: HMENU, uPosition: UINT, uFlags: UINT,
-                   uIDNewItem: UINT, lpNewItem: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "InsertMenuA".}
-  proc AppendMenu*(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT,
-                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "AppendMenuA".}
-  proc ModifyMenu*(hMnu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT,
-                   lpNewItem: LPCSTR): WINBOOL{.stdcall, dynlib: "user32",
-      importc: "ModifyMenuA".}
-  proc InsertMenuItem*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                       para4: LPCMENUITEMINFO): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "InsertMenuItemA".}
-  proc GetMenuItemInfo*(para1: HMENU, para2: UINT, para3: WINBOOL,
-                        para4: LPMENUITEMINFO): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "GetMenuItemInfoA".}
-  proc SetMenuItemInfo*(para1: HMENU, para2: UINT, 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",
-                                        importc: "DrawTextA".}
-  proc DrawTextEx*(para1: HDC, para2: LPSTR, para3: int32, para4: LPRECT,
-                   para5: UINT, para6: LPDRAWTEXTPARAMS): int32{.stdcall,
-      dynlib: "user32", importc: "DrawTextExA".}
-  proc GrayString*(hDC: HDC, hBrush: HBRUSH, lpOutputFunc: GRAYSTRINGPROC,
-                   lpData: LPARAM, nCount: int32, X: int32, Y: int32,
-                   nWidth: int32, nHeight: int32): WINBOOL{.stdcall,
-      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,
-      dynlib: "user32", importc: "DrawStateA".}
-  proc TabbedTextOut*(hDC: HDC, X: int32, Y: int32, lpString: LPCSTR,
-                      nCount: int32, nTabPositions: int32,
-                      lpnTabStopPositions: LPINT, nTabOrigin: int32): LONG{.
-      stdcall, dynlib: "user32", importc: "TabbedTextOutA".}
-  proc GetTabbedTextExtent*(hDC: HDC, lpString: LPCSTR, nCount: int32,
-                            nTabPositions: int32, lpnTabStopPositions: LPINT): DWORD{.
-      stdcall, dynlib: "user32", importc: "GetTabbedTextExtentA".}
-  proc SetProp*(hWnd: HWND, lpString: LPCSTR, hData: HANDLE): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetPropA".}
-  proc GetProp*(hWnd: HWND, lpString: LPCSTR): HANDLE{.stdcall,
-      dynlib: "user32", importc: "GetPropA".}
-  proc RemoveProp*(hWnd: HWND, lpString: LPCSTR): HANDLE{.stdcall,
-      dynlib: "user32", importc: "RemovePropA".}
-  proc EnumPropsEx*(hWnd: HWND, lpEnumFunc: PROPENUMPROCEX, lParam: LPARAM): int32{.
-      stdcall, dynlib: "user32", importc: "EnumPropsExA".}
-  proc EnumProps*(hWnd: HWND, lpEnumFunc: PROPENUMPROC): int32{.stdcall,
-      dynlib: "user32", importc: "EnumPropsA".}
-  proc SetWindowText*(hWnd: HWND, lpString: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "SetWindowTextA".}
-  proc GetWindowText*(hWnd: HWND, lpString: LPSTR, nMaxCount: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetWindowTextA".}
-  proc GetWindowTextLength*(hWnd: HWND): int32{.stdcall, dynlib: "user32",
-      importc: "GetWindowTextLengthA".}
-  proc MessageBox*(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT): int32{.
-      stdcall, dynlib: "user32", importc: "MessageBoxA".}
-  proc MessageBoxEx*(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT,
-                     wLanguageId: int16): int32{.stdcall, dynlib: "user32",
-      importc: "MessageBoxExA".}
-  proc MessageBoxIndirect*(para1: LPMSGBOXPARAMS): int32{.stdcall,
-      dynlib: "user32", importc: "MessageBoxIndirectA".}
-  proc GetWindowLong*(hWnd: HWND, nIndex: int32): LONG{.stdcall,
-      dynlib: "user32", importc: "GetWindowLongA".}
-  proc SetWindowLong*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): LONG{.
-      stdcall, dynlib: "user32", importc: "SetWindowLongA".}
-  proc GetClassLong*(hWnd: HWND, nIndex: int32): DWORD{.stdcall,
-      dynlib: "user32", importc: "GetClassLongA".}
-  proc SetClassLong*(hWnd: HWND, nIndex: int32, dwNewLong: LONG): DWORD{.
-      stdcall, dynlib: "user32", importc: "SetClassLongA".}
-  when defined(cpu64):
-    proc GetWindowLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetWindowLongPtrA".}
-    proc SetWindowLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetWindowLongPtrA".}
-    proc GetClassLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetClassLongPtrA".}
-    proc SetClassLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetClassLongPtrA".}
-  else:
-    proc GetWindowLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetWindowLongA".}
-    proc SetWindowLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetWindowLongA".}
-    proc GetClassLongPtr*(hWnd: HWND, nIndex: int32): LONG_PTR{.stdcall,
-        dynlib: "user32", importc: "GetClassLongA".}
-    proc SetClassLongPtr*(hWnd: HWND, nIndex: int32, dwNewLong: LONG_PTR): LONG_PTR{.
-        stdcall, dynlib: "user32", importc: "SetClassLongA".}
-  proc FindWindow*(lpClassName: LPCSTR, lpWindowName: LPCSTR): HWND{.stdcall,
-      dynlib: "user32", importc: "FindWindowA".}
-  proc FindWindowEx*(para1: HWND, para2: HWND, para3: LPCSTR, para4: LPCSTR): HWND{.
-      stdcall, dynlib: "user32", importc: "FindWindowExA".}
-  proc GetClassName*(hWnd: HWND, lpClassName: LPSTR, nMaxCount: int32): int32{.
-      stdcall, dynlib: "user32", importc: "GetClassNameA".}
-  proc SetWindowsHookEx*(idHook: int32, lpfn: HOOKPROC, hmod: HINST,
-                         dwThreadId: DWORD): HHOOK{.stdcall, dynlib: "user32",
-      importc: "SetWindowsHookExA".}
-  proc LoadBitmap*(hInstance: HINST, lpBitmapName: LPCSTR): HBITMAP{.stdcall,
-      dynlib: "user32", importc: "LoadBitmapA".}
-  proc LoadCursor*(hInstance: HINST, lpCursorName: LPCSTR): HCURSOR{.stdcall,
-      dynlib: "user32", importc: "LoadCursorA".}
-  proc LoadCursorFromFile*(lpFileName: LPCSTR): HCURSOR{.stdcall,
-      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",
-      importc: "LoadImageA".}
-  proc LoadString*(hInstance: HINST, uID: UINT, 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,
-      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{.
-      stdcall, dynlib: "user32", importc: "DlgDirListComboBoxA".}
-  proc DlgDirSelectComboBoxEx*(hDlg: HWND, lpString: LPSTR, nCount: int32,
-                               nIDComboBox: int32): WINBOOL{.stdcall,
-      dynlib: "user32", importc: "DlgDirSelectComboBoxExA".}
-  proc DefFrameProc*(hWnd: HWND, hWndMDIClient: HWND, uMsg: UINT,
-                     wParam: WPARAM, lParam: LPARAM): LRESULT{.stdcall,
-      dynlib: "user32", importc: "DefFrameProcA".}
-  proc DefMDIChildProc*(hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: 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, lParam: LPARAM): HWND{.
-      stdcall, dynlib: "user32", importc: "CreateMDIWindowA".}
-  proc WinHelp*(hWndMain: HWND, lpszHelp: LPCSTR, uCommand: UINT, 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",
-      importc: "SystemParametersInfoA".}
-  proc AddFontResource*(para1: LPCSTR): int32{.stdcall, dynlib: "gdi32",
-      importc: "AddFontResourceA".}
-  proc CopyMetaFile*(para1: HMETAFILE, para2: LPCSTR): HMETAFILE{.stdcall,
-      dynlib: "gdi32", importc: "CopyMetaFileA".}
-  proc CreateFont*(para1: int32, para2: int32, para3: int32, para4: int32,
-                   para5: int32, para6: DWORD, para7: DWORD, para8: DWORD,
-                   para9: DWORD, para10: DWORD, para11: DWORD, para12: DWORD,
-                   para13: DWORD, para14: LPCSTR): HFONT{.stdcall,
-      dynlib: "gdi32", importc: "CreateFontA".}
-  proc CreateFontIndirect*(para1: LPLOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-      importc: "CreateFontIndirectA".}
-  proc CreateFontIndirect*(para1: var LOGFONT): HFONT{.stdcall, dynlib: "gdi32",
-      importc: "CreateFontIndirectA".}
-  proc CreateIC*(para1: LPCSTR, para2: LPCSTR, para3: LPCSTR, para4: LPDEVMODE): HDC{.
-      stdcall, dynlib: "gdi32", importc: "CreateICA".}
-  proc CreateMetaFile*(para1: LPCSTR): HDC{.stdcall, dynlib: "gdi32",
-      importc: "CreateMetaFileA".}
-  proc CreateScalableFontResource*(para1: DWORD, para2: LPCSTR, para3: LPCSTR,
-                                   para4: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "CreateScalableFontResourceA".}
-  proc EnumFontFamiliesEx*(para1: HDC, para2: LPLOGFONT, para3: FONTENUMEXPROC,
-                           para4: LPARAM, para5: DWORD): int32{.stdcall,
-      dynlib: "gdi32", importc: "EnumFontFamiliesExA".}
-  proc EnumFontFamilies*(para1: HDC, para2: LPCSTR, para3: FONTENUMPROC,
-                         para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-      importc: "EnumFontFamiliesA".}
-  proc EnumFonts*(para1: HDC, para2: LPCSTR, para3: ENUMFONTSPROC, para4: LPARAM): int32{.
-      stdcall, dynlib: "gdi32", importc: "EnumFontsA".}
-  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{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidthA".}
-  proc GetCharWidth32*(para1: HDC, para2: UINT, para3: UINT, para4: LPINT): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidth32A".}
-  proc GetCharWidthFloat*(para1: HDC, para2: UINT, para3: UINT, para4: ptr float32): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}
-  proc GetCharABCWidths*(para1: HDC, para2: UINT, para3: UINT, para4: LPABC): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}
-  proc GetCharABCWidthsFloat*(para1: HDC, para2: UINT, para3: UINT,
-                              para4: LPABCFLOAT): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}
-  proc GetGlyphOutline*(para1: HDC, para2: UINT, para3: UINT,
-                        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,
-      dynlib: "gdi32", importc: "GetOutlineTextMetricsA".}
-  proc GetTextExtentPoint*(para1: HDC, para2: LPCSTR, para3: int32,
-                           para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentPointA".}
-  proc GetTextExtentPoint32*(para1: HDC, para2: LPCSTR, para3: int32,
-                             para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentPoint32A".}
-  proc GetTextExtentExPoint*(para1: HDC, para2: LPCSTR, para3: int32,
-                             para4: int32, para5: LPINT, para6: LPINT,
-                             para7: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetTextExtentExPointA".}
-  proc GetCharacterPlacement*(para1: HDC, para2: LPCSTR, para3: int32,
-                              para4: int32, para5: LPGCP_RESULTS, para6: DWORD): DWORD{.
-      stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementA".}
-  proc ResetDC*(para1: HDC, para2: LPDEVMODE): HDC{.stdcall, dynlib: "gdi32",
-      importc: "ResetDCA".}
-  proc RemoveFontResource*(para1: LPCSTR): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "RemoveFontResourceA".}
-  proc CopyEnhMetaFile*(para1: HENHMETAFILE, para2: LPCSTR): HENHMETAFILE{.
-      stdcall, dynlib: "gdi32", importc: "CopyEnhMetaFileA".}
-  proc CreateEnhMetaFile*(para1: HDC, para2: LPCSTR, para3: LPRECT,
-                          para4: LPCSTR): HDC{.stdcall, dynlib: "gdi32",
-      importc: "CreateEnhMetaFileA".}
-  proc GetEnhMetaFile*(para1: LPCSTR): HENHMETAFILE{.stdcall, dynlib: "gdi32",
-      importc: "GetEnhMetaFileA".}
-  proc GetEnhMetaFileDescription*(para1: HENHMETAFILE, para2: UINT, para3: LPSTR): UINT{.
-      stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileDescriptionA".}
-  proc GetTextMetrics*(para1: HDC, para2: LPTEXTMETRIC): WINBOOL{.stdcall,
-      dynlib: "gdi32", importc: "GetTextMetricsA".}
-  proc StartDoc*(para1: HDC, para2: PDOCINFO): int32{.stdcall, dynlib: "gdi32",
-      importc: "StartDocA".}
-  proc GetObject*(para1: HGDIOBJ, para2: int32, para3: LPVOID): int32{.stdcall,
-      dynlib: "gdi32", importc: "GetObjectA".}
-  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{.
-      stdcall, dynlib: "gdi32", importc: "ExtTextOutA".}
-  proc PolyTextOut*(para1: HDC, para2: PPOLYTEXT, para3: int32): WINBOOL{.
-      stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}
-  proc GetTextFace*(para1: HDC, para2: int32, para3: LPSTR): int32{.stdcall,
-      dynlib: "gdi32", importc: "GetTextFaceA".}
-  proc GetKerningPairs*(para1: HDC, para2: DWORD, para3: LPKERNINGPAIR): DWORD{.
-      stdcall, dynlib: "gdi32", importc: "GetKerningPairsA".}
-  proc CreateColorSpace*(para1: LPLOGCOLORSPACE): HCOLORSPACE{.stdcall,
-      dynlib: "gdi32", importc: "CreateColorSpaceA".}
-  proc GetLogColorSpace*(para1: HCOLORSPACE, para2: LPLOGCOLORSPACE,
-                         para3: DWORD): WINBOOL{.stdcall, dynlib: "gdi32",
-      importc: "GetLogColorSpaceA".}
-  proc GetICMProfile*(para1: HDC, para2: DWORD, para3: LPSTR): WINBOOL{.stdcall,
-      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{.
-      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{.
-      stdcall, dynlib: "comctl32", importc: "ImageList_LoadImageA".}
-  proc CreateStatusWindow*(style: LONG, lpszText: LPCSTR, hwndParent: HWND,
-                           wID: UINT): HWND{.stdcall, dynlib: "comctl32",
-      importc: "CreateStatusWindowA".}
-  proc DrawStatusText*(hDC: HDC, lprc: LPRECT, pszText: LPCSTR, uFlags: UINT){.
-      stdcall, dynlib: "comctl32", importc: "DrawStatusTextA".}
-  proc GetOpenFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "GetOpenFileNameA".}
-  proc GetSaveFileName*(para1: LPOPENFILENAME): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "GetSaveFileNameA".}
-  proc GetFileTitle*(para1: LPCSTR, para2: LPSTR, para3: int16): int{.stdcall,
-      dynlib: "comdlg32", importc: "GetFileTitleA".}
-  proc ChooseColor*(para1: LPCHOOSECOLOR): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "ChooseColorA".}
-  proc FindText*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-      importc: "FindTextA".}
-  proc ReplaceText*(para1: LPFINDREPLACE): HWND{.stdcall, dynlib: "comdlg32",
-      importc: "ReplaceTextA".}
-  proc ChooseFont*(para1: LPCHOOSEFONT): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "ChooseFontA".}
-  proc PrintDlg*(para1: LPPRINTDLG): WINBOOL{.stdcall, dynlib: "comdlg32",
-      importc: "PrintDlgA".}
-  proc PageSetupDlg*(para1: LPPAGESETUPDLG): WINBOOL{.stdcall,
-      dynlib: "comdlg32", importc: "PageSetupDlgA".}
-  proc CreateProcess*(lpApplicationName: LPCSTR, lpCommandLine: LPSTR,
-                      lpProcessAttributes: LPSECURITY_ATTRIBUTES,
-                      lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                      bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                      lpEnvironment: LPVOID, lpCurrentDirectory: LPCSTR,
-                      lpStartupInfo: LPSTARTUPINFO,
-                      lpProcessInformation: LPPROCESS_INFORMATION): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
-  proc GetStartupInfo*(lpStartupInfo: LPSTARTUPINFO){.stdcall,
-      dynlib: "kernel32", importc: "GetStartupInfoA".}
-  proc FindFirstFile*(lpFileName: LPCSTR, lpFindFileData: LPWIN32_FIND_DATA): HANDLE{.
-      stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
-  proc FindNextFile*(hFindFile: HANDLE, lpFindFileData: LPWIN32_FIND_DATA): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
-  proc GetVersionEx*(VersionInformation: LPOSVERSIONINFO): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetVersionExA".}
-  proc CreateWindow*(lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD,
-                     X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                     hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                     lpParam: LPVOID): HWND
-  proc CreateDialog*(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                     lpDialogFunc: DLGPROC): HWND
-  proc CreateDialogIndirect*(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                             hWndParent: HWND, lpDialogFunc: DLGPROC): HWND
-  proc DialogBox*(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                  lpDialogFunc: DLGPROC): int32
-  proc DialogBoxIndirect*(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                          hWndParent: HWND, lpDialogFunc: DLGPROC): int32
-  proc CreateDC*(para1: LPCSTR, para2: LPCSTR, para3: LPCSTR, para4: pDEVMODE): HDC{.
-      stdcall, dynlib: "gdi32", importc: "CreateDCA".}
-  proc VerInstallFile*(uFlags: DWORD, szSrcFileName: LPSTR,
-                       szDestFileName: LPSTR, szSrcDir: LPSTR, szDestDir: LPSTR,
-                       szCurDir: LPSTR, szTmpFile: LPSTR, lpuTmpFileLen: PUINT): DWORD{.
-      stdcall, dynlib: "version", importc: "VerInstallFileA".}
-  proc GetFileVersionInfoSize*(lptstrFilename: LPSTR, lpdwHandle: LPDWORD): DWORD{.
-      stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeA".}
-  proc GetFileVersionInfo*(lptstrFilename: LPSTR, dwHandle: DWORD, dwLen: DWORD,
-                           lpData: LPVOID): WINBOOL{.stdcall, dynlib: "version",
-      importc: "GetFileVersionInfoA".}
-  proc VerLanguageName*(wLang: DWORD, szLang: LPSTR, nSize: DWORD): DWORD{.
-      stdcall, dynlib: "kernel32", importc: "VerLanguageNameA".}
-  proc VerQueryValue*(pBlock: LPVOID, lpSubBlock: LPSTR, lplpBuffer: LPVOID,
-                      puLen: PUINT): WINBOOL{.stdcall, dynlib: "version",
-      importc: "VerQueryValueA".}
-  proc VerFindFile*(uFlags: DWORD, szFileName: LPSTR, szWinDir: LPSTR,
-                    szAppDir: LPSTR, szCurDir: LPSTR, lpuCurDirLen: PUINT,
-                    szDestDir: LPSTR, lpuDestDirLen: PUINT): DWORD{.stdcall,
-      dynlib: "version", importc: "VerFindFileA".}
-  proc RegConnectRegistry*(lpMachineName: LPSTR, hKey: HKEY, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegConnectRegistryA".}
-  proc RegCreateKey*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegCreateKeyA".}
-  proc RegCreateKeyEx*(hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD,
-                       lpClass: LPSTR, dwOptions: DWORD, samDesired: REGSAM,
-                       lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
-                       phkResult: PHKEY, lpdwDisposition: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegCreateKeyExA".}
-  proc RegDeleteKey*(hKey: HKEY, lpSubKey: LPCSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegDeleteKeyA".}
-  proc RegDeleteValue*(hKey: HKEY, lpValueName: LPCSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegDeleteValueA".}
-  proc RegEnumKey*(hKey: HKEY, dwIndex: DWORD, lpName: LPSTR, cbName: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumKeyA".}
-  proc RegEnumKeyEx*(hKey: HKEY, dwIndex: DWORD, lpName: LPSTR,
-                     lpcbName: LPDWORD, lpReserved: LPDWORD, lpClass: LPSTR,
-                     lpcbClass: LPDWORD, lpftLastWriteTime: PFILETIME): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumKeyExA".}
-  proc RegEnumValue*(hKey: HKEY, dwIndex: DWORD, lpValueName: LPSTR,
-                     lpcbValueName: LPDWORD, lpReserved: LPDWORD,
-                     lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegEnumValueA".}
-  proc RegLoadKey*(hKey: HKEY, lpSubKey: LPCSTR, lpFile: LPCSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegLoadKeyA".}
-  proc RegOpenKey*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: PHKEY): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegOpenKeyA".}
-  proc RegOpenKeyEx*(hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD,
-                     samDesired: REGSAM, phkResult: PHKEY): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegOpenKeyExA".}
-  proc RegQueryInfoKey*(hKey: HKEY, lpClass: LPSTR, lpcbClass: LPDWORD,
-                        lpReserved: LPDWORD, lpcSubKeys: LPDWORD,
-                        lpcbMaxSubKeyLen: LPDWORD, lpcbMaxClassLen: LPDWORD,
-                        lpcValues: LPDWORD, lpcbMaxValueNameLen: LPDWORD,
-                        lpcbMaxValueLen: LPDWORD,
-                        lpcbSecurityDescriptor: LPDWORD,
-                        lpftLastWriteTime: PFILETIME): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegQueryInfoKeyA".}
-  proc RegQueryValue*(hKey: HKEY, lpSubKey: LPCSTR, lpValue: LPSTR,
-                      lpcbValue: PLONG): LONG{.stdcall, dynlib: "advapi32",
-      importc: "RegQueryValueA".}
-  proc RegQueryMultipleValues*(hKey: HKEY, val_list: PVALENT, num_vals: DWORD,
-                               lpValueBuf: LPSTR, ldwTotsize: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesA".}
-  proc RegQueryValueEx*(hKey: HKEY, lpValueName: LPCSTR, lpReserved: LPDWORD,
-                        lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegQueryValueExA".}
-  proc RegReplaceKey*(hKey: HKEY, lpSubKey: LPCSTR, lpNewFile: LPCSTR,
-                      lpOldFile: LPCSTR): LONG{.stdcall, dynlib: "advapi32",
-      importc: "RegReplaceKeyA".}
-  proc RegRestoreKey*(hKey: HKEY, lpFile: LPCSTR, dwFlags: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegRestoreKeyA".}
-  proc RegSaveKey*(hKey: HKEY, lpFile: LPCSTR,
-                   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegSaveKeyA".}
-  proc RegSetValue*(hKey: HKEY, lpSubKey: LPCSTR, dwType: DWORD, lpData: LPCSTR,
-                    cbData: DWORD): LONG{.stdcall, dynlib: "advapi32",
-      importc: "RegSetValueA".}
-  proc RegSetValueEx*(hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD,
-                      dwType: DWORD, lpData: LPBYTE, cbData: DWORD): LONG{.
-      stdcall, dynlib: "advapi32", importc: "RegSetValueExA".}
-  proc RegUnLoadKey*(hKey: HKEY, lpSubKey: LPCSTR): LONG{.stdcall,
-      dynlib: "advapi32", importc: "RegUnLoadKeyA".}
-  proc InitiateSystemShutdown*(lpMachineName: LPSTR, lpMessage: LPSTR,
-                               dwTimeout: DWORD, bForceAppsClosed: WINBOOL,
-                               bRebootAfterShutdown: WINBOOL): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "InitiateSystemShutdownA".}
-  proc AbortSystemShutdown*(lpMachineName: LPSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "AbortSystemShutdownA".}
-  proc CompareString*(Locale: LCID, dwCmpFlags: DWORD, lpString1: LPCSTR,
-                      cchCount1: int32, lpString2: LPCSTR, cchCount2: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "CompareStringA".}
-  proc LCMapString*(Locale: LCID, dwMapFlags: DWORD, lpSrcStr: LPCSTR,
-                    cchSrc: int32, lpDestStr: LPSTR, cchDest: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "LCMapStringA".}
-  proc GetLocaleInfo*(Locale: LCID, LCType: LCTYPE, lpLCData: LPSTR,
-                      cchData: int32): int32{.stdcall, dynlib: "kernel32",
-      importc: "GetLocaleInfoA".}
-  proc SetLocaleInfo*(Locale: LCID, LCType: LCTYPE, lpLCData: LPCSTR): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "SetLocaleInfoA".}
-  proc GetTimeFormat*(Locale: LCID, dwFlags: DWORD, lpTime: LPSYSTEMTIME,
-                      lpFormat: LPCSTR, lpTimeStr: LPSTR, cchTime: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "GetTimeFormatA".}
-  proc GetDateFormat*(Locale: LCID, dwFlags: DWORD, lpDate: LPSYSTEMTIME,
-                      lpFormat: LPCSTR, lpDateStr: LPSTR, cchDate: int32): int32{.
-      stdcall, dynlib: "kernel32", importc: "GetDateFormatA".}
-  proc GetNumberFormat*(Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR,
-                        lpFormat: PNUMBERFMT, lpNumberStr: LPSTR,
-                        cchNumber: int32): int32{.stdcall, dynlib: "kernel32",
-      importc: "GetNumberFormatA".}
-  proc GetCurrencyFormat*(Locale: LCID, dwFlags: DWORD, lpValue: LPCSTR,
-                          lpFormat: PCURRENCYFMT, lpCurrencyStr: LPSTR,
-                          cchCurrency: int32): int32{.stdcall,
-      dynlib: "kernel32", importc: "GetCurrencyFormatA".}
-  proc EnumCalendarInfo*(lpCalInfoEnumProc: CALINFO_ENUMPROC, Locale: LCID,
-                         Calendar: CALID, CalType: CALTYPE): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EnumCalendarInfoA".}
-  proc EnumTimeFormats*(lpTimeFmtEnumProc: TIMEFMT_ENUMPROC, Locale: LCID,
-                        dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumTimeFormatsA".}
-  proc EnumDateFormats*(lpDateFmtEnumProc: DATEFMT_ENUMPROC, Locale: LCID,
-                        dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "EnumDateFormatsA".}
-  proc GetStringTypeEx*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                        cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetStringTypeExA".}
-  proc GetStringType*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                      cchSrc: int32, lpCharType: LPWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "GetStringTypeA".}
-  proc FoldString*(dwMapFlags: DWORD, lpSrcStr: LPCSTR, cchSrc: int32,
-                   lpDestStr: LPSTR, cchDest: int32): int32{.stdcall,
-      dynlib: "kernel32", importc: "FoldStringA".}
-  proc EnumSystemLocales*(lpLocaleEnumProc: LOCALE_ENUMPROC, dwFlags: DWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "EnumSystemLocalesA".}
-  proc EnumSystemCodePages*(lpCodePageEnumProc: CODEPAGE_ENUMPROC,
-                            dwFlags: DWORD): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "EnumSystemCodePagesA".}
-  proc PeekConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".}
-  proc ReadConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                         nLength: DWORD, lpNumberOfEventsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".}
-  proc WriteConsoleInput*(hConsoleInput: HANDLE, lpBuffer: PINPUTRECORD,
-                          nLength: DWORD, lpNumberOfEventsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".}
-  proc ReadConsoleOutput*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                          dwBufferSize: COORD, dwBufferCoord: COORD,
-                          lpReadRegion: PSMALL_RECT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "ReadConsoleOutputA".}
-  proc WriteConsoleOutput*(hConsoleOutput: HANDLE, lpBuffer: PCHAR_INFO,
-                           dwBufferSize: COORD, dwBufferCoord: COORD,
-                           lpWriteRegion: PSMALL_RECT): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "WriteConsoleOutputA".}
-  proc ReadConsoleOutputCharacter*(hConsoleOutput: HANDLE, lpCharacter: LPSTR,
-                                   nLength: DWORD, dwReadCoord: COORD,
-                                   lpNumberOfCharsRead: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".}
-  proc WriteConsoleOutputCharacter*(hConsoleOutput: HANDLE, lpCharacter: LPCSTR,
-                                    nLength: DWORD, dwWriteCoord: COORD,
-                                    lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".}
-  proc FillConsoleOutputCharacter*(hConsoleOutput: HANDLE, cCharacter: CHAR,
-                                   nLength: DWORD, dwWriteCoord: COORD,
-                                   lpNumberOfCharsWritten: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".}
-  proc ScrollConsoleScreenBuffer*(hConsoleOutput: HANDLE,
-                                  lpScrollRectangle: PSMALL_RECT,
-                                  lpClipRectangle: PSMALL_RECT,
-                                  dwDestinationOrigin: COORD, lpFill: PCHAR_INFO): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".}
-  proc GetConsoleTitle*(lpConsoleTitle: LPSTR, nSize: DWORD): DWORD{.stdcall,
-      dynlib: "kernel32", importc: "GetConsoleTitleA".}
-  proc SetConsoleTitle*(lpConsoleTitle: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "kernel32", importc: "SetConsoleTitleA".}
-  proc ReadConsole*(hConsoleInput: HANDLE, lpBuffer: LPVOID,
-                    nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: LPDWORD,
-                    lpReserved: LPVOID): WINBOOL{.stdcall, dynlib: "kernel32",
-      importc: "ReadConsoleA".}
-  proc WriteConsole*(hConsoleOutput: HANDLE, lpBuffer: pointer,
-                     nNumberOfCharsToWrite: DWORD,
-                     lpNumberOfCharsWritten: LPDWORD, lpReserved: LPVOID): WINBOOL{.
-      stdcall, dynlib: "kernel32", importc: "WriteConsoleA".}
-  proc WNetAddConnection*(lpRemoteName: LPCSTR, lpPassword: LPCSTR,
-                          lpLocalName: LPCSTR): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetAddConnectionA".}
-  proc WNetAddConnection2*(lpNetResource: LPNETRESOURCE, lpPassword: LPCSTR,
-                           lpUserName: LPCSTR, dwFlags: DWORD): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetAddConnection2A".}
-  proc WNetAddConnection3*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                           lpPassword: LPCSTR, lpUserName: LPCSTR,
-                           dwFlags: DWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetAddConnection3A".}
-  proc WNetCancelConnection*(lpName: LPCSTR, fForce: WINBOOL): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetCancelConnectionA".}
-  proc WNetCancelConnection2*(lpName: LPCSTR, dwFlags: DWORD, fForce: WINBOOL): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetCancelConnection2A".}
-  proc WNetGetConnection*(lpLocalName: LPCSTR, lpRemoteName: LPSTR,
-                          lpnLength: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetGetConnectionA".}
-  proc WNetUseConnection*(hwndOwner: HWND, lpNetResource: LPNETRESOURCE,
-                          lpUserID: LPCSTR, lpPassword: LPCSTR, dwFlags: DWORD,
-                          lpAccessName: LPSTR, lpBufferSize: LPDWORD,
-                          lpResult: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetUseConnectionA".}
-  proc WNetSetConnection*(lpName: LPCSTR, dwProperties: DWORD, pvValues: LPVOID): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetSetConnectionA".}
-  proc WNetConnectionDialog1*(lpConnDlgStruct: LPCONNECTDLGSTRUCT): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".}
-  proc WNetDisconnectDialog1*(lpConnDlgStruct: LPDISCDLGSTRUCT): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetDisconnectDialog1A".}
-  proc WNetOpenEnum*(dwScope: DWORD, dwType: DWORD, dwUsage: DWORD,
-                     lpNetResource: LPNETRESOURCE, lphEnum: LPHANDLE): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetOpenEnumA".}
-  proc WNetEnumResource*(hEnum: HANDLE, lpcCount: LPDWORD, lpBuffer: LPVOID,
-                         lpBufferSize: LPDWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetEnumResourceA".}
-  proc WNetGetUniversalName*(lpLocalPath: LPCSTR, dwInfoLevel: DWORD,
-                             lpBuffer: LPVOID, lpBufferSize: LPDWORD): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameA".}
-  proc WNetGetUser*(lpName: LPCSTR, lpUserName: LPSTR, lpnLength: LPDWORD): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetUserA".}
-  proc WNetGetProviderName*(dwNetType: DWORD, lpProviderName: LPSTR,
-                            lpBufferSize: LPDWORD): DWORD{.stdcall,
-      dynlib: "mpr", importc: "WNetGetProviderNameA".}
-  proc WNetGetNetworkInformation*(lpProvider: LPCSTR,
-                                  lpNetInfoStruct: LPNETINFOSTRUCT): DWORD{.
-      stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".}
-  proc WNetGetLastError*(lpError: LPDWORD, lpErrorBuf: LPSTR,
-                         nErrorBufSize: DWORD, lpNameBuf: LPSTR,
-                         nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-      importc: "WNetGetLastErrorA".}
-  proc MultinetGetConnectionPerformance*(lpNetResource: LPNETRESOURCE,
-      lpNetConnectInfoStruct: LPNETCONNECTINFOSTRUCT): DWORD{.stdcall,
-      dynlib: "mpr", importc: "MultinetGetConnectionPerformanceA".}
-  proc ChangeServiceConfig*(hService: SC_HANDLE, dwServiceType: DWORD,
-                            dwStartType: DWORD, dwErrorControl: DWORD,
-                            lpBinaryPathName: LPCSTR, lpLoadOrderGroup: LPCSTR,
-                            lpdwTagId: LPDWORD, lpDependencies: LPCSTR,
-                            lpServiceStartName: LPCSTR, lpPassword: LPCSTR,
-                            lpDisplayName: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "ChangeServiceConfigA".}
-  proc CreateService*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                      lpDisplayName: LPCSTR, dwDesiredAccess: DWORD,
-                      dwServiceType: DWORD, dwStartType: DWORD,
-                      dwErrorControl: DWORD, lpBinaryPathName: LPCSTR,
-                      lpLoadOrderGroup: LPCSTR, lpdwTagId: LPDWORD,
-                      lpDependencies: LPCSTR, lpServiceStartName: LPCSTR,
-                      lpPassword: LPCSTR): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "CreateServiceA".}
-  proc EnumDependentServices*(hService: SC_HANDLE, dwServiceState: DWORD,
-                              lpServices: LPENUM_SERVICE_STATUS,
-                              cbBufSize: DWORD, pcbBytesNeeded: LPDWORD,
-                              lpServicesReturned: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "EnumDependentServicesA".}
-  proc EnumServicesStatus*(hSCManager: SC_HANDLE, dwServiceType: DWORD,
-                           dwServiceState: DWORD,
-                           lpServices: LPENUM_SERVICE_STATUS, cbBufSize: DWORD,
-                           pcbBytesNeeded: LPDWORD, lpServicesReturned: LPDWORD,
-                           lpResumeHandle: LPDWORD): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "EnumServicesStatusA".}
-  proc GetServiceKeyName*(hSCManager: SC_HANDLE, lpDisplayName: LPCSTR,
-                          lpServiceName: LPSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetServiceKeyNameA".}
-  proc GetServiceDisplayName*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                              lpDisplayName: LPSTR, lpcchBuffer: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "GetServiceDisplayNameA".}
-  proc OpenSCManager*(lpMachineName: LPCSTR, lpDatabaseName: LPCSTR,
-                      dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "OpenSCManagerA".}
-  proc OpenService*(hSCManager: SC_HANDLE, lpServiceName: LPCSTR,
-                    dwDesiredAccess: DWORD): SC_HANDLE{.stdcall,
-      dynlib: "advapi32", importc: "OpenServiceA".}
-  proc QueryServiceConfig*(hService: SC_HANDLE,
-                           lpServiceConfig: LPQUERY_SERVICE_CONFIG,
-                           cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "QueryServiceConfigA".}
-  proc QueryServiceLockStatus*(hSCManager: SC_HANDLE,
-                               lpLockStatus: LPQUERY_SERVICE_LOCK_STATUS,
-                               cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "QueryServiceLockStatusA".}
-  proc RegisterServiceCtrlHandler*(lpServiceName: LPCSTR,
-                                   lpHandlerProc: LPHANDLER_FUNCTION): SERVICE_STATUS_HANDLE{.
-      stdcall, dynlib: "advapi32", importc: "RegisterServiceCtrlHandlerA".}
-  proc StartServiceCtrlDispatcher*(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "StartServiceCtrlDispatcherA".}
-  proc StartService*(hService: SC_HANDLE, dwNumServiceArgs: DWORD,
-                     lpServiceArgVectors: LPCSTR): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "StartServiceA".}
-  proc DragQueryFile*(para1: HDROP, para2: int, para3: cstring, para4: int): int{.
-      stdcall, dynlib: "shell32", importc: "DragQueryFileA".}
-  proc ExtractAssociatedIcon*(para1: HINST, para2: cstring, para3: LPWORD): HICON{.
-      stdcall, dynlib: "shell32", importc: "ExtractAssociatedIconA".}
-  proc ExtractIcon*(para1: HINST, para2: cstring, para3: int): HICON{.stdcall,
-      dynlib: "shell32", importc: "ExtractIconA".}
-  proc FindExecutable*(para1: cstring, para2: cstring, para3: cstring): HINST{.
-      stdcall, dynlib: "shell32", importc: "FindExecutableA".}
-  proc ShellAbout*(para1: HWND, para2: cstring, para3: cstring, para4: HICON): int32{.
-      stdcall, dynlib: "shell32", importc: "ShellAboutA".}
-  proc ShellExecute*(para1: HWND, para2: cstring, para3: cstring,
-                     para4: cstring, para5: cstring, para6: int32): HINST{.
-      stdcall, dynlib: "shell32", importc: "ShellExecuteA".}
-  proc Shell_NotifyIcon*(dwMessage: DWORD, lpData: PNotifyIconDataA): WINBOOL{.
-      stdcall, dynlib: "shell32", importc: "Shell_NotifyIconA".}
-  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",
-      importc: "DdeInitializeA".}
-  proc DdeQueryString*(para1: DWORD, para2: HSZ, para3: cstring, para4: DWORD,
-                       para5: int32): DWORD{.stdcall, dynlib: "user32",
-      importc: "DdeQueryStringA".}
-  proc LogonUser*(para1: LPSTR, para2: LPSTR, para3: LPSTR, para4: DWORD,
-                  para5: DWORD, para6: PHANDLE): WINBOOL{.stdcall,
-      dynlib: "advapi32", importc: "LogonUserA".}
-  proc CreateProcessAsUser*(para1: HANDLE, para2: LPCTSTR, para3: LPTSTR,
-                            para4: LPSECURITY_ATTRIBUTES,
-                            para5: LPSECURITY_ATTRIBUTES, para6: WINBOOL,
-                            para7: DWORD, para8: LPVOID, para9: LPCTSTR,
-                            para10: LPSTARTUPINFO, para11: LPPROCESS_INFORMATION): WINBOOL{.
-      stdcall, dynlib: "advapi32", importc: "CreateProcessAsUserA".}
-proc GetRandomRgn*(aHDC: HDC, aHRGN: HRGN, iNum: WINT): WINT{.stdcall,
-     importc, dynlib: "gdi32".}
-
-proc AccessCheck*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                  ClientToken: HANDLE, DesiredAccess: DWORD,
-                  GenericMapping: PGENERIC_MAPPING,
-                  PrivilegeSet: PPRIVILEGE_SET, PrivilegeSetLength: LPDWORD,
-                  GrantedAccess: LPDWORD, AccessStatus: LPBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AccessCheck".}
-proc FreeResource*(hResData: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "FreeResource".}
-proc LockResource*(hResData: HGLOBAL): LPVOID{.stdcall, dynlib: "kernel32",
-    importc: "LockResource".}
-proc FreeLibrary*(hLibModule: HINST): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "FreeLibrary".}
-proc FreeLibraryAndExitThread*(hLibModule: HMODULE, dwExitCode: DWORD){.stdcall,
-    dynlib: "kernel32", importc: "FreeLibraryAndExitThread".}
-proc DisableThreadLibraryCalls*(hLibModule: HMODULE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DisableThreadLibraryCalls".}
-proc GetProcAddress*(hModule: HINST, lpProcName: LPCSTR): FARPROC{.stdcall,
-    dynlib: "kernel32", importc: "GetProcAddress".}
-proc GetVersion*(): DWORD{.stdcall, dynlib: "kernel32", importc: "GetVersion".}
-proc GlobalAlloc*(uFlags: UINT, dwBytes: DWORD): HGLOBAL{.stdcall,
-    dynlib: "kernel32", importc: "GlobalAlloc".}
-proc GlobalDiscard*(hglbMem: HGLOBAL): HGLOBAL
-proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: DWORD, uFlags: UINT): HGLOBAL{.
-    stdcall, dynlib: "kernel32", importc: "GlobalReAlloc".}
-proc GlobalSize*(hMem: HGLOBAL): DWORD{.stdcall, dynlib: "kernel32",
-                                        importc: "GlobalSize".}
-proc GlobalFlags*(hMem: HGLOBAL): UINT{.stdcall, dynlib: "kernel32",
-                                        importc: "GlobalFlags".}
-proc GlobalLock*(hMem: HGLOBAL): LPVOID{.stdcall, dynlib: "kernel32",
-    importc: "GlobalLock".}
-proc GlobalHandle*(pMem: LPCVOID): HGLOBAL{.stdcall, dynlib: "kernel32",
-    importc: "GlobalHandle".}
-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",
-    importc: "GlobalCompact".}
-proc GlobalFix*(hMem: HGLOBAL){.stdcall, dynlib: "kernel32",
-                                importc: "GlobalFix".}
-proc GlobalUnfix*(hMem: HGLOBAL){.stdcall, dynlib: "kernel32",
-                                  importc: "GlobalUnfix".}
-proc GlobalWire*(hMem: HGLOBAL): LPVOID{.stdcall, dynlib: "kernel32",
-    importc: "GlobalWire".}
-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,
-    dynlib: "kernel32", importc: "LocalAlloc".}
-proc LocalDiscard*(hlocMem: HLOCAL): HLOCAL
-proc LocalReAlloc*(hMem: HLOCAL, uBytes: UINT, uFlags: UINT): HLOCAL{.stdcall,
-    dynlib: "kernel32", importc: "LocalReAlloc".}
-proc LocalLock*(hMem: HLOCAL): LPVOID{.stdcall, dynlib: "kernel32",
-                                       importc: "LocalLock".}
-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",
-                                     importc: "LocalSize".}
-proc LocalFlags*(hMem: HLOCAL): UINT{.stdcall, dynlib: "kernel32",
-                                      importc: "LocalFlags".}
-proc LocalFree*(hMem: HLOCAL): HLOCAL{.stdcall, dynlib: "kernel32",
-                                       importc: "LocalFree".}
-proc LocalShrink*(hMem: HLOCAL, cbNewSize: UINT): UINT{.stdcall,
-    dynlib: "kernel32", importc: "LocalShrink".}
-proc LocalCompact*(uMinFree: UINT): UINT{.stdcall, dynlib: "kernel32",
-    importc: "LocalCompact".}
-proc FlushInstructionCache*(hProcess: HANDLE, lpBaseAddress: LPCVOID,
-                            dwSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FlushInstructionCache".}
-proc VirtualAlloc*(lpAddress: LPVOID, dwSize: DWORD, flAllocationType: DWORD,
-                   flProtect: DWORD): LPVOID{.stdcall, dynlib: "kernel32",
-    importc: "VirtualAlloc".}
-proc VirtualFree*(lpAddress: LPVOID, dwSize: DWORD, dwFreeType: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "VirtualFree".}
-proc VirtualProtect*(lpAddress: LPVOID, dwSize: DWORD, flNewProtect: DWORD,
-                     lpflOldProtect: PDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "VirtualProtect".}
-proc VirtualQuery*(lpAddress: LPCVOID, lpBuffer: PMEMORY_BASIC_INFORMATION,
-                   dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "VirtualQuery".}
-proc VirtualProtectEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: DWORD,
-                       flNewProtect: DWORD, lpflOldProtect: PDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "VirtualProtectEx".}
-proc VirtualQueryEx*(hProcess: HANDLE, lpAddress: LPCVOID,
-                     lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "VirtualQueryEx".}
-proc HeapCreate*(flOptions: DWORD, dwInitialSize: DWORD, dwMaximumSize: DWORD): HANDLE{.
-    stdcall, dynlib: "kernel32", importc: "HeapCreate".}
-proc HeapDestroy*(hHeap: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "HeapDestroy".}
-proc HeapAlloc*(hHeap: HANDLE, dwFlags: DWORD, dwBytes: DWORD): LPVOID{.stdcall,
-    dynlib: "kernel32", importc: "HeapAlloc".}
-proc HeapReAlloc*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: DWORD): LPVOID{.
-    stdcall, dynlib: "kernel32", importc: "HeapReAlloc".}
-proc HeapFree*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "HeapFree".}
-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,
-    dynlib: "kernel32", importc: "HeapCompact".}
-proc GetProcessHeap*(): HANDLE{.stdcall, dynlib: "kernel32",
-                                importc: "GetProcessHeap".}
-proc GetProcessHeaps*(NumberOfHeaps: DWORD, ProcessHeaps: PHANDLE): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessHeaps".}
-proc HeapLock*(hHeap: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-                                        importc: "HeapLock".}
-proc HeapUnlock*(hHeap: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "HeapUnlock".}
-proc HeapWalk*(hHeap: HANDLE, lpEntry: LPPROCESS_HEAP_ENTRY): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "HeapWalk".}
-proc GetProcessAffinityMask*(hProcess: HANDLE, lpProcessAffinityMask: LPDWORD,
-                             lpSystemAffinityMask: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetProcessAffinityMask".}
-proc GetProcessTimes*(hProcess: HANDLE, lpCreationTime: LPFILETIME,
-                      lpExitTime: LPFILETIME, lpKernelTime: LPFILETIME,
-                      lpUserTime: LPFILETIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetProcessTimes".}
-proc GetProcessWorkingSetSize*(hProcess: HANDLE,
-                               lpMinimumWorkingSetSize: LPDWORD,
-                               lpMaximumWorkingSetSize: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessWorkingSetSize".}
-proc SetProcessWorkingSetSize*(hProcess: HANDLE, dwMinimumWorkingSetSize: DWORD,
-                               dwMaximumWorkingSetSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetProcessWorkingSetSize".}
-proc OpenProcess*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                  dwProcessId: DWORD): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "OpenProcess".}
-proc GetCurrentProcess*(): HANDLE{.stdcall, dynlib: "kernel32",
-                                   importc: "GetCurrentProcess".}
-proc GetCurrentProcessId*(): DWORD{.stdcall, dynlib: "kernel32",
-                                    importc: "GetCurrentProcessId".}
-proc ExitProcess*(uExitCode: UINT){.stdcall, dynlib: "kernel32",
-                                    importc: "ExitProcess".}
-proc TerminateProcess*(hProcess: HANDLE, uExitCode: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TerminateProcess".}
-proc SetProcessAffinityMask*(hProcess: THandle, dwProcessAffinityMask: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetProcessAffinityMask".}
-proc GetExitCodeProcess*(hProcess: HANDLE, lpExitCode: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}
-proc FatalExit*(ExitCode: int32){.stdcall, dynlib: "kernel32",
-                                  importc: "FatalExit".}
-proc RaiseException*(dwExceptionCode: DWORD, dwExceptionFlags: DWORD,
-                     nNumberOfArguments: DWORD, lpArguments: LPDWORD){.stdcall,
-    dynlib: "kernel32", importc: "RaiseException".}
-proc UnhandledExceptionFilter*(ExceptionInfo: lpemptyrecord): LONG{.stdcall,
-    dynlib: "kernel32", importc: "UnhandledExceptionFilter".}
-proc CreateRemoteThread*(hProcess: HANDLE,
-                         lpThreadAttributes: LPSECURITY_ATTRIBUTES,
-                         dwStackSize: DWORD,
-                         lpStartAddress: LPTHREAD_START_ROUTINE,
-                         lpParameter: LPVOID, dwCreationFlags: DWORD,
-                         lpThreadId: LPDWORD): HANDLE{.stdcall,
-    dynlib: "kernel32", importc: "CreateRemoteThread".}
-proc GetCurrentThread*(): HANDLE{.stdcall, dynlib: "kernel32",
-                                  importc: "GetCurrentThread".}
-proc GetCurrentThreadId*(): DWORD{.stdcall, dynlib: "kernel32",
-                                   importc: "GetCurrentThreadId".}
-proc SetThreadAffinityMask*(hThread: HANDLE, dwThreadAffinityMask: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "SetThreadAffinityMask".}
-proc SetThreadPriority*(hThread: HANDLE, nPriority: int32): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetThreadPriority".}
-proc GetThreadPriority*(hThread: HANDLE): int32{.stdcall, dynlib: "kernel32",
-    importc: "GetThreadPriority".}
-proc GetThreadTimes*(hThread: HANDLE, lpCreationTime: LPFILETIME,
-                     lpExitTime: LPFILETIME, lpKernelTime: LPFILETIME,
-                     lpUserTime: LPFILETIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetThreadTimes".}
-proc ExitThread*(dwExitCode: DWORD){.stdcall, dynlib: "kernel32",
-                                     importc: "ExitThread".}
-proc TerminateThread*(hThread: HANDLE, dwExitCode: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TerminateThread".}
-proc GetExitCodeThread*(hThread: HANDLE, lpExitCode: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetExitCodeThread".}
-proc GetThreadSelectorEntry*(hThread: HANDLE, dwSelector: DWORD,
-                             lpSelectorEntry: LPLDT_ENTRY): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetThreadSelectorEntry".}
-proc GetLastError*(): DWORD{.stdcall, dynlib: "kernel32",
-                             importc: "GetLastError".}
-proc SetLastError*(dwErrCode: DWORD){.stdcall, dynlib: "kernel32",
-                                      importc: "SetLastError".}
-proc CreateIoCompletionPort*(FileHandle: HANDLE, ExistingCompletionPort: HANDLE,
-                             CompletionKey: DWORD,
-                             NumberOfConcurrentThreads: DWORD): HANDLE{.stdcall,
-    dynlib: "kernel32", importc: "CreateIoCompletionPort".}
-proc SetErrorMode*(uMode: UINT): UINT{.stdcall, dynlib: "kernel32",
-                                       importc: "SetErrorMode".}
-proc ReadProcessMemory*(hProcess: HANDLE, lpBaseAddress: LPCVOID,
-                        lpBuffer: LPVOID, nSize: DWORD,
-                        lpNumberOfBytesRead: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadProcessMemory".}
-proc WriteProcessMemory*(hProcess: HANDLE, lpBaseAddress: LPVOID,
-                         lpBuffer: LPVOID, nSize: DWORD,
-                         lpNumberOfBytesWritten: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteProcessMemory".}
-proc GetThreadContext*(hThread: HANDLE, lpContext: LPCONTEXT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetThreadContext".}
-proc SuspendThread*(hThread: HANDLE): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "SuspendThread".}
-proc ResumeThread*(hThread: HANDLE): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "ResumeThread".}
-proc DebugBreak*(){.stdcall, dynlib: "kernel32", importc: "DebugBreak".}
-proc WaitForDebugEvent*(lpDebugEvent: LPDEBUG_EVENT, dwMilliseconds: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WaitForDebugEvent".}
-proc ContinueDebugEvent*(dwProcessId: DWORD, dwThreadId: DWORD,
-                         dwContinueStatus: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ContinueDebugEvent".}
-proc DebugActiveProcess*(dwProcessId: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DebugActiveProcess".}
-proc InitializeCriticalSection*(lpCriticalSection: LPCRITICAL_SECTION){.stdcall,
-    dynlib: "kernel32", importc: "InitializeCriticalSection".}
-proc EnterCriticalSection*(lpCriticalSection: LPCRITICAL_SECTION){.stdcall,
-    dynlib: "kernel32", importc: "EnterCriticalSection".}
-proc LeaveCriticalSection*(lpCriticalSection: LPCRITICAL_SECTION){.stdcall,
-    dynlib: "kernel32", importc: "LeaveCriticalSection".}
-proc DeleteCriticalSection*(lpCriticalSection: LPCRITICAL_SECTION){.stdcall,
-    dynlib: "kernel32", importc: "DeleteCriticalSection".}
-proc TryEnterCriticalSection*(lpCriticalSection: LPCRITICAL_SECTION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "TryEnterCriticalSection".}
-proc SetEvent*(hEvent: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "SetEvent".}
-proc ResetEvent*(hEvent: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ResetEvent".}
-proc PulseEvent*(hEvent: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "PulseEvent".}
-proc ReleaseSemaphore*(hSemaphore: HANDLE, lReleaseCount: LONG,
-                       lpPreviousCount: LPLONG): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReleaseSemaphore".}
-proc ReleaseMutex*(hMutex: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReleaseMutex".}
-proc WaitForSingleObject*(hHandle: HANDLE, dwMilliseconds: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".}
-proc WaitForMultipleObjects*(nCount: DWORD, lpHandles: PWOHandleArray,
-                             bWaitAll: WINBOOL, dwMilliseconds: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".}
-proc Sleep*(dwMilliseconds: DWORD){.stdcall, dynlib: "kernel32",
-                                    importc: "Sleep".}
-proc LoadResource*(hModule: HINST, hResInfo: HRSRC): HGLOBAL{.stdcall,
-    dynlib: "kernel32", importc: "LoadResource".}
-proc SizeofResource*(hModule: HINST, hResInfo: HRSRC): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SizeofResource".}
-proc GlobalDeleteAtom*(nAtom: ATOM): ATOM{.stdcall, dynlib: "kernel32",
-    importc: "GlobalDeleteAtom".}
-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",
-    importc: "SetHandleCount".}
-proc GetLogicalDrives*(): DWORD{.stdcall, dynlib: "kernel32",
-                                 importc: "GetLogicalDrives".}
-proc LockFile*(hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD,
-               nNumberOfBytesToLockLow: DWORD, nNumberOfBytesToLockHigh: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "LockFile".}
-proc UnlockFile*(hFile: HANDLE, dwFileOffsetLow: DWORD, dwFileOffsetHigh: DWORD,
-                 nNumberOfBytesToUnlockLow: DWORD,
-                 nNumberOfBytesToUnlockHigh: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "UnlockFile".}
-proc LockFileEx*(hFile: HANDLE, dwFlags: DWORD, dwReserved: DWORD,
-                 nNumberOfBytesToLockLow: DWORD,
-                 nNumberOfBytesToLockHigh: DWORD, lpOverlapped: LPOVERLAPPED): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "LockFileEx".}
-proc UnlockFileEx*(hFile: HANDLE, dwReserved: DWORD,
-                   nNumberOfBytesToUnlockLow: DWORD,
-                   nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: LPOVERLAPPED): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "UnlockFileEx".}
-proc GetFileInformationByHandle*(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle".}
-proc GetFileType*(hFile: HANDLE): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetFileType".}
-proc GetFileSize*(hFile: HANDLE, lpFileSizeHigh: LPDWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetFileSize".}
-proc GetStdHandle*(nStdHandle: DWORD): HANDLE{.stdcall, dynlib: "kernel32",
-    importc: "GetStdHandle".}
-proc SetStdHandle*(nStdHandle: DWORD, hHandle: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetStdHandle".}
-proc FlushFileBuffers*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "FlushFileBuffers".}
-proc DeviceIoControl*(hDevice: HANDLE, dwIoControlCode: DWORD,
-                      lpInBuffer: LPVOID, nInBufferSize: DWORD,
-                      lpOutBuffer: LPVOID, nOutBufferSize: DWORD,
-                      lpBytesReturned: LPDWORD, lpOverlapped: LPOVERLAPPED): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "DeviceIoControl".}
-proc SetEndOfFile*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "SetEndOfFile".}
-proc SetFilePointer*(hFile: HANDLE, lDistanceToMove: LONG,
-                     lpDistanceToMoveHigh: PLONG, dwMoveMethod: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "SetFilePointer".}
-proc FindClose*(hFindFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "FindClose".}
-proc GetFileTime*(hFile: HANDLE, lpCreationTime: LPFILETIME,
-                  lpLastAccessTime: LPFILETIME, lpLastWriteTime: LPFILETIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetFileTime".}
-proc SetFileTime*(hFile: HANDLE, lpCreationTime: LPFILETIME,
-                  lpLastAccessTime: LPFILETIME, lpLastWriteTime: LPFILETIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetFileTime".}
-proc CloseHandle*(hObject: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CloseHandle".}
-proc DuplicateHandle*(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE,
-                      hTargetProcessHandle: HANDLE, lpTargetHandle: LPHANDLE,
-                      dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
-                      dwOptions: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "DuplicateHandle".}
-proc GetHandleInformation*(hObject: HANDLE, lpdwFlags: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetHandleInformation".}
-proc SetHandleInformation*(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD): WINBOOL{.
-    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,
-    dynlib: "kernel32", importc: "WinExec".}
-proc ClearCommBreak*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ClearCommBreak".}
-proc ClearCommError*(hFile: HANDLE, lpErrors: LPDWORD, lpStat: LPCOMSTAT): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ClearCommError".}
-proc SetupComm*(hFile: HANDLE, dwInQueue: DWORD, dwOutQueue: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetupComm".}
-proc EscapeCommFunction*(hFile: HANDLE, dwFunc: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "EscapeCommFunction".}
-proc GetCommConfig*(hCommDev: HANDLE, lpCC: LPCOMMCONFIG, lpdwSize: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommConfig".}
-proc GetCommProperties*(hFile: HANDLE, lpCommProp: LPCOMMPROP): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommProperties".}
-proc GetCommModemStatus*(hFile: HANDLE, lpModemStat: PDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetCommModemStatus".}
-proc GetCommState*(hFile: HANDLE, lpDCB: PDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetCommState".}
-proc GetCommTimeouts*(hFile: HANDLE, lpCommTimeouts: PCOMMTIMEOUTS): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommTimeouts".}
-proc PurgeComm*(hFile: HANDLE, dwFlags: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "PurgeComm".}
-proc SetCommBreak*(hFile: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "SetCommBreak".}
-proc SetCommConfig*(hCommDev: HANDLE, lpCC: LPCOMMCONFIG, dwSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetCommConfig".}
-proc SetCommMask*(hFile: HANDLE, dwEvtMask: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetCommMask".}
-proc SetCommState*(hFile: HANDLE, lpDCB: LPDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetCommState".}
-proc SetCommTimeouts*(hFile: HANDLE, lpCommTimeouts: LPCOMMTIMEOUTS): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetCommTimeouts".}
-proc TransmitCommChar*(hFile: HANDLE, cChar: char): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TransmitCommChar".}
-proc WaitCommEvent*(hFile: HANDLE, lpEvtMask: LPDWORD,
-                    lpOverlapped: LPOVERLAPPED): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WaitCommEvent".}
-proc SetTapePosition*(hDevice: HANDLE, dwPositionMethod: DWORD,
-                      dwPartition: DWORD, dwOffsetLow: DWORD,
-                      dwOffsetHigh: DWORD, bImmediate: WINBOOL): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SetTapePosition".}
-proc GetTapePosition*(hDevice: HANDLE, dwPositionType: DWORD,
-                      lpdwPartition: LPDWORD, lpdwOffsetLow: LPDWORD,
-                      lpdwOffsetHigh: LPDWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetTapePosition".}
-proc PrepareTape*(hDevice: HANDLE, dwOperation: DWORD, bImmediate: WINBOOL): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "PrepareTape".}
-proc EraseTape*(hDevice: HANDLE, dwEraseType: DWORD, bImmediate: WINBOOL): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "EraseTape".}
-proc CreateTapePartition*(hDevice: HANDLE, dwPartitionMethod: DWORD,
-                          dwCount: DWORD, dwSize: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "CreateTapePartition".}
-proc WriteTapemark*(hDevice: HANDLE, dwTapemarkType: DWORD,
-                    dwTapemarkCount: DWORD, bImmediate: WINBOOL): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "WriteTapemark".}
-proc GetTapeStatus*(hDevice: HANDLE): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "GetTapeStatus".}
-proc GetTapeParameters*(hDevice: HANDLE, dwOperation: DWORD, lpdwSize: LPDWORD,
-                        lpTapeInformation: LPVOID): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetTapeParameters".}
-proc SetTapeParameters*(hDevice: HANDLE, dwOperation: DWORD,
-                        lpTapeInformation: LPVOID): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SetTapeParameters".}
-proc Beep*(dwFreq: DWORD, dwDuration: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "Beep".}
-proc MulDiv*(nNumber: int32, nNumerator: int32, nDenominator: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "MulDiv".}
-proc GetSystemTime*(lpSystemTime: LPSYSTEMTIME){.stdcall, dynlib: "kernel32",
-    importc: "GetSystemTime".}
-proc GetSystemTimeAsFileTime*(lpSystemTimeAsFileTime: LPFILETIME){.stdcall,
-    dynlib: "kernel32", importc: "GetSystemTimeAsFileTime".}
-proc SetSystemTime*(lpSystemTime: LPSYSTEMTIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetSystemTime".}
-proc GetLocalTime*(lpSystemTime: LPSYSTEMTIME){.stdcall, dynlib: "kernel32",
-    importc: "GetLocalTime".}
-proc SetLocalTime*(lpSystemTime: LPSYSTEMTIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetLocalTime".}
-proc GetSystemInfo*(lpSystemInfo: LPSYSTEM_INFO){.stdcall, dynlib: "kernel32",
-    importc: "GetSystemInfo".}
-proc SystemTimeToTzSpecificLocalTime*(lpTimeZoneInformation: LPTIME_ZONE_INFORMATION,
-                                      lpUniversalTime: LPSYSTEMTIME,
-                                      lpLocalTime: LPSYSTEMTIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SystemTimeToTzSpecificLocalTime".}
-proc GetTimeZoneInformation*(lpTimeZoneInformation: LPTIME_ZONE_INFORMATION): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetTimeZoneInformation".}
-proc SetTimeZoneInformation*(lpTimeZoneInformation: LPTIME_ZONE_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetTimeZoneInformation".}
-proc SystemTimeToFileTime*(lpSystemTime: LPSYSTEMTIME, lpFileTime: LPFILETIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SystemTimeToFileTime".}
-proc FileTimeToLocalFileTime*(lpFileTime: LPFILETIME,
-                              lpLocalFileTime: LPFILETIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FileTimeToLocalFileTime".}
-proc LocalFileTimeToFileTime*(lpLocalFileTime: LPFILETIME,
-                              lpFileTime: LPFILETIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "LocalFileTimeToFileTime".}
-proc FileTimeToSystemTime*(lpFileTime: LPFILETIME, lpSystemTime: LPSYSTEMTIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FileTimeToSystemTime".}
-proc CompareFileTime*(lpFileTime1: LPFILETIME, lpFileTime2: LPFILETIME): LONG{.
-    stdcall, dynlib: "kernel32", importc: "CompareFileTime".}
-proc FileTimeToDosDateTime*(lpFileTime: LPFILETIME, lpFatDate: LPWORD,
-                            lpFatTime: LPWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FileTimeToDosDateTime".}
-proc DosDateTimeToFileTime*(wFatDate: int16, wFatTime: int16,
-                            lpFileTime: LPFILETIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DosDateTimeToFileTime".}
-proc GetTickCount*(): DWORD{.stdcall, dynlib: "kernel32",
-                             importc: "GetTickCount".}
-proc SetSystemTimeAdjustment*(dwTimeAdjustment: DWORD,
-                              bTimeAdjustmentDisabled: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetSystemTimeAdjustment".}
-proc GetSystemTimeAdjustment*(lpTimeAdjustment: PDWORD, lpTimeIncrement: PDWORD,
-                              lpTimeAdjustmentDisabled: PWINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetSystemTimeAdjustment".}
-proc CreatePipe*(hReadPipe: PHANDLE, hWritePipe: PHANDLE,
-                 lpPipeAttributes: LPSECURITY_ATTRIBUTES, nSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreatePipe".}
-proc ConnectNamedPipe*(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ConnectNamedPipe".}
-proc DisconnectNamedPipe*(hNamedPipe: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "DisconnectNamedPipe".}
-proc SetNamedPipeHandleState*(hNamedPipe: HANDLE, lpMode: LPDWORD,
-                              lpMaxCollectionCount: LPDWORD,
-                              lpCollectDataTimeout: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetNamedPipeHandleState".}
-proc GetNamedPipeInfo*(hNamedPipe: HANDLE, lpFlags: LPDWORD,
-                       lpOutBufferSize: LPDWORD, lpInBufferSize: LPDWORD,
-                       lpMaxInstances: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetNamedPipeInfo".}
-proc PeekNamedPipe*(hNamedPipe: HANDLE, lpBuffer: LPVOID, nBufferSize: DWORD,
-                    lpBytesRead: LPDWORD, lpTotalBytesAvail: LPDWORD,
-                    lpBytesLeftThisMessage: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "PeekNamedPipe".}
-proc TransactNamedPipe*(hNamedPipe: HANDLE, lpInBuffer: LPVOID,
-                        nInBufferSize: DWORD, lpOutBuffer: LPVOID,
-                        nOutBufferSize: DWORD, lpBytesRead: LPDWORD,
-                        lpOverlapped: LPOVERLAPPED): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TransactNamedPipe".}
-proc GetMailslotInfo*(hMailslot: HANDLE, lpMaxMessageSize: LPDWORD,
-                      lpNextSize: LPDWORD, lpMessageCount: LPDWORD,
-                      lpReadTimeout: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetMailslotInfo".}
-proc SetMailslotInfo*(hMailslot: HANDLE, lReadTimeout: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetMailslotInfo".}
-proc MapViewOfFile*(hFileMappingObject: HANDLE, dwDesiredAccess: DWORD,
-                    dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD,
-                    dwNumberOfBytesToMap: DWORD): LPVOID{.stdcall,
-    dynlib: "kernel32", importc: "MapViewOfFile".}
-proc FlushViewOfFile*(lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FlushViewOfFile".}
-proc UnmapViewOfFile*(lpBaseAddress: LPVOID): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "UnmapViewOfFile".}
-proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: LPOFSTRUCT, uStyle: UINT): 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,
-    dynlib: "kernel32", importc: "_lread".}
-proc lwrite*(hFile: HFILE, lpBuffer: LPCSTR, uBytes: UINT): UINT{.stdcall,
-    dynlib: "kernel32", importc: "_lwrite".}
-proc hread*(hFile: HFILE, lpBuffer: LPVOID, lBytes: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "_hread".}
-proc hwrite*(hFile: HFILE, lpBuffer: LPCSTR, lBytes: int32): int32{.stdcall,
-    dynlib: "kernel32", importc: "_hwrite".}
-proc lclose*(hFile: HFILE): HFILE{.stdcall, dynlib: "kernel32",
-                                   importc: "_lclose".}
-proc llseek*(hFile: HFILE, lOffset: LONG, iOrigin: int32): LONG{.stdcall,
-    dynlib: "kernel32", importc: "_llseek".}
-proc IsTextUnicode*(lpBuffer: LPVOID, cb: int32, lpi: LPINT): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "IsTextUnicode".}
-proc TlsAlloc*(): DWORD{.stdcall, dynlib: "kernel32", importc: "TlsAlloc".}
-proc TlsGetValue*(dwTlsIndex: DWORD): LPVOID{.stdcall, dynlib: "kernel32",
-    importc: "TlsGetValue".}
-proc TlsSetValue*(dwTlsIndex: DWORD, lpTlsValue: LPVOID): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TlsSetValue".}
-proc TlsFree*(dwTlsIndex: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "TlsFree".}
-proc SleepEx*(dwMilliseconds: DWORD, bAlertable: WINBOOL): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SleepEx".}
-proc WaitForSingleObjectEx*(hHandle: HANDLE, dwMilliseconds: DWORD,
-                            bAlertable: WINBOOL): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "WaitForSingleObjectEx".}
-proc WaitForMultipleObjectsEx*(nCount: DWORD, lpHandles: LPHANDLE,
-                               bWaitAll: WINBOOL, dwMilliseconds: DWORD,
-                               bAlertable: WINBOOL): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "WaitForMultipleObjectsEx".}
-proc ReadFileEx*(hFile: HANDLE, lpBuffer: LPVOID, nNumberOfBytesToRead: DWORD,
-                 lpOverlapped: LPOVERLAPPED,
-                 lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadFileEx".}
-proc WriteFileEx*(hFile: HANDLE, lpBuffer: LPCVOID,
-                  nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED,
-                  lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteFileEx".}
-proc BackupRead*(hFile: HANDLE, lpBuffer: LPBYTE, nNumberOfBytesToRead: DWORD,
-                 lpNumberOfBytesRead: LPDWORD, bAbort: WINBOOL,
-                 bProcessSecurity: WINBOOL, lpContext: var LPVOID): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BackupRead".}
-proc BackupSeek*(hFile: HANDLE, dwLowBytesToSeek: DWORD,
-                 dwHighBytesToSeek: DWORD, lpdwLowByteSeeked: LPDWORD,
-                 lpdwHighByteSeeked: LPDWORD, lpContext: var LPVOID): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BackupSeek".}
-proc BackupWrite*(hFile: HANDLE, lpBuffer: LPBYTE, nNumberOfBytesToWrite: DWORD,
-                  lpNumberOfBytesWritten: LPDWORD, bAbort: WINBOOL,
-                  bProcessSecurity: WINBOOL, lpContext: var LPVOID): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BackupWrite".}
-proc SetProcessShutdownParameters*(dwLevel: DWORD, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetProcessShutdownParameters".}
-proc GetProcessShutdownParameters*(lpdwLevel: LPDWORD, lpdwFlags: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessShutdownParameters".}
-proc SetFileApisToOEM*(){.stdcall, dynlib: "kernel32",
-                          importc: "SetFileApisToOEM".}
-proc SetFileApisToANSI*(){.stdcall, dynlib: "kernel32",
-                           importc: "SetFileApisToANSI".}
-proc AreFileApisANSI*(): WINBOOL{.stdcall, dynlib: "kernel32",
-                                  importc: "AreFileApisANSI".}
-proc CloseEventLog*(hEventLog: HANDLE): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "CloseEventLog".}
-proc DeregisterEventSource*(hEventLog: HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "DeregisterEventSource".}
-proc NotifyChangeEventLog*(hEventLog: HANDLE, hEvent: HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "NotifyChangeEventLog".}
-proc GetNumberOfEventLogRecords*(hEventLog: HANDLE, NumberOfRecords: PDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetNumberOfEventLogRecords".}
-proc GetOldestEventLogRecord*(hEventLog: HANDLE, OldestRecord: PDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetOldestEventLogRecord".}
-proc DuplicateToken*(ExistingTokenHandle: HANDLE,
-                     ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL,
-                     DuplicateTokenHandle: PHANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "DuplicateToken".}
-proc GetKernelObjectSecurity*(Handle: HANDLE,
-                              RequestedInformation: SECURITY_INFORMATION,
-                              pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                              nLength: DWORD, lpnLengthNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetKernelObjectSecurity".}
-proc ImpersonateNamedPipeClient*(hNamedPipe: HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ImpersonateNamedPipeClient".}
-proc ImpersonateLoggedOnUser*(hToken: HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ImpersonateLoggedOnUser".}
-proc ImpersonateSelf*(ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ImpersonateSelf".}
-proc RevertToSelf*(): WINBOOL{.stdcall, dynlib: "advapi32",
-                               importc: "RevertToSelf".}
-proc SetThreadToken*(Thread: PHANDLE, Token: HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetThreadToken".}
-proc OpenProcessToken*(ProcessHandle: HANDLE, DesiredAccess: DWORD,
-                       TokenHandle: PHANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "OpenProcessToken".}
-proc OpenThreadToken*(ThreadHandle: HANDLE, DesiredAccess: DWORD,
-                      OpenAsSelf: WINBOOL, TokenHandle: PHANDLE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "OpenThreadToken".}
-proc GetTokenInformation*(TokenHandle: HANDLE,
-                          TokenInformationClass: TOKEN_INFORMATION_CLASS,
-                          TokenInformation: LPVOID,
-                          TokenInformationLength: DWORD, ReturnLength: PDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetTokenInformation".}
-proc SetTokenInformation*(TokenHandle: HANDLE,
-                          TokenInformationClass: TOKEN_INFORMATION_CLASS,
-                          TokenInformation: LPVOID,
-                          TokenInformationLength: DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetTokenInformation".}
-proc AdjustTokenPrivileges*(TokenHandle: HANDLE, DisableAllPrivileges: WINBOOL,
-                            NewState: PTOKEN_PRIVILEGES, BufferLength: DWORD,
-                            PreviousState: PTOKEN_PRIVILEGES,
-                            ReturnLength: PDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AdjustTokenPrivileges".}
-proc AdjustTokenGroups*(TokenHandle: HANDLE, ResetToDefault: WINBOOL,
-                        NewState: PTOKEN_GROUPS, BufferLength: DWORD,
-                        PreviousState: PTOKEN_GROUPS, ReturnLength: PDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AdjustTokenGroups".}
-proc PrivilegeCheck*(ClientToken: HANDLE, RequiredPrivileges: PPRIVILEGE_SET,
-                     pfResult: LPBOOL): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "PrivilegeCheck".}
-proc IsValidSid*(pSid: PSID): WINBOOL{.stdcall, dynlib: "advapi32",
-                                       importc: "IsValidSid".}
-proc EqualSid*(pSid1: PSID, pSid2: PSID): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "EqualSid".}
-proc EqualPrefixSid*(pSid1: PSID, pSid2: PSID): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "EqualPrefixSid".}
-proc GetSidLengthRequired*(nSubAuthorityCount: UCHAR): DWORD{.stdcall,
-    dynlib: "advapi32", importc: "GetSidLengthRequired".}
-proc AllocateAndInitializeSid*(pIdentifierAuthority: PSID_IDENTIFIER_AUTHORITY,
-                               nSubAuthorityCount: int8, nSubAuthority0: DWORD,
-                               nSubAuthority1: DWORD, nSubAuthority2: DWORD,
-                               nSubAuthority3: DWORD, nSubAuthority4: DWORD,
-                               nSubAuthority5: DWORD, nSubAuthority6: DWORD,
-                               nSubAuthority7: DWORD, pSid: var PSID): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AllocateAndInitializeSid".}
-proc FreeSid*(pSid: PSID): PVOID{.stdcall, dynlib: "advapi32",
-                                  importc: "FreeSid".}
-proc InitializeSid*(Sid: PSID, pIdentifierAuthority: PSID_IDENTIFIER_AUTHORITY,
-                    nSubAuthorityCount: int8): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "InitializeSid".}
-proc GetSidIdentifierAuthority*(pSid: PSID): PSID_IDENTIFIER_AUTHORITY{.stdcall,
-    dynlib: "advapi32", importc: "GetSidIdentifierAuthority".}
-proc GetSidSubAuthority*(pSid: PSID, nSubAuthority: DWORD): PDWORD{.stdcall,
-    dynlib: "advapi32", importc: "GetSidSubAuthority".}
-proc GetSidSubAuthorityCount*(pSid: PSID): PUCHAR{.stdcall, dynlib: "advapi32",
-    importc: "GetSidSubAuthorityCount".}
-proc GetLengthSid*(pSid: PSID): DWORD{.stdcall, dynlib: "advapi32",
-                                       importc: "GetLengthSid".}
-proc CopySid*(nDestinationSidLength: DWORD, pDestinationSid: PSID,
-              pSourceSid: PSID): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "CopySid".}
-proc AreAllAccessesGranted*(GrantedAccess: DWORD, DesiredAccess: DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AreAllAccessesGranted".}
-proc AreAnyAccessesGranted*(GrantedAccess: DWORD, DesiredAccess: DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "AreAnyAccessesGranted".}
-proc MapGenericMask*(AccessMask: PDWORD, GenericMapping: PGENERIC_MAPPING){.
-    stdcall, dynlib: "advapi32", importc: "MapGenericMask".}
-proc IsValidAcl*(pAcl: PACL): WINBOOL{.stdcall, dynlib: "advapi32",
-                                       importc: "IsValidAcl".}
-proc InitializeAcl*(pAcl: PACL, nAclLength: DWORD, dwAclRevision: DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "InitializeAcl".}
-proc GetAclInformation*(pAcl: PACL, pAclInformation: LPVOID,
-                        nAclInformationLength: DWORD,
-                        dwAclInformationClass: ACL_INFORMATION_CLASS): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetAclInformation".}
-proc SetAclInformation*(pAcl: PACL, pAclInformation: LPVOID,
-                        nAclInformationLength: DWORD,
-                        dwAclInformationClass: ACL_INFORMATION_CLASS): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetAclInformation".}
-proc AddAce*(pAcl: PACL, dwAceRevision: DWORD, dwStartingAceIndex: DWORD,
-             pAceList: LPVOID, nAceListLength: DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AddAce".}
-proc DeleteAce*(pAcl: PACL, dwAceIndex: DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "DeleteAce".}
-proc GetAce*(pAcl: PACL, dwAceIndex: DWORD, pAce: var LPVOID): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetAce".}
-proc AddAccessAllowedAce*(pAcl: PACL, dwAceRevision: DWORD, AccessMask: DWORD,
-                          pSid: PSID): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "AddAccessAllowedAce".}
-proc AddAccessDeniedAce*(pAcl: PACL, dwAceRevision: DWORD, AccessMask: DWORD,
-                         pSid: PSID): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "AddAccessDeniedAce".}
-proc AddAuditAccessAce*(pAcl: PACL, dwAceRevision: DWORD, dwAccessMask: DWORD,
-                        pSid: PSID, bAuditSuccess: WINBOOL,
-                        bAuditFailure: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AddAuditAccessAce".}
-proc FindFirstFreeAce*(pAcl: PACL, pAce: var LPVOID): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "FindFirstFreeAce".}
-proc InitializeSecurityDescriptor*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                   dwRevision: DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "InitializeSecurityDescriptor".}
-proc IsValidSecurityDescriptor*(pSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "IsValidSecurityDescriptor".}
-proc GetSecurityDescriptorLength*(pSecurityDescriptor: PSECURITY_DESCRIPTOR): DWORD{.
-    stdcall, dynlib: "advapi32", importc: "GetSecurityDescriptorLength".}
-proc GetSecurityDescriptorControl*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                   pControl: PSECURITY_DESCRIPTOR_CONTROL,
-                                   lpdwRevision: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetSecurityDescriptorControl".}
-proc SetSecurityDescriptorDacl*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                bDaclPresent: WINBOOL, pDacl: PACL,
-                                bDaclDefaulted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetSecurityDescriptorDacl".}
-proc GetSecurityDescriptorDacl*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                lpbDaclPresent: LPBOOL, pDacl: var PACL,
-                                lpbDaclDefaulted: LPBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetSecurityDescriptorDacl".}
-proc SetSecurityDescriptorSacl*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                bSaclPresent: WINBOOL, pSacl: PACL,
-                                bSaclDefaulted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetSecurityDescriptorSacl".}
-proc GetSecurityDescriptorSacl*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                lpbSaclPresent: LPBOOL, pSacl: var PACL,
-                                lpbSaclDefaulted: LPBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetSecurityDescriptorSacl".}
-proc SetSecurityDescriptorOwner*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 pOwner: PSID, bOwnerDefaulted: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetSecurityDescriptorOwner".}
-proc GetSecurityDescriptorOwner*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 pOwner: var PSID, lpbOwnerDefaulted: LPBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetSecurityDescriptorOwner".}
-proc SetSecurityDescriptorGroup*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 pGroup: PSID, bGroupDefaulted: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetSecurityDescriptorGroup".}
-proc GetSecurityDescriptorGroup*(pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 pGroup: var PSID, lpbGroupDefaulted: LPBOOL): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetSecurityDescriptorGroup".}
-proc CreatePrivateObjectSecurity*(ParentDescriptor: PSECURITY_DESCRIPTOR,
-                                  CreatorDescriptor: PSECURITY_DESCRIPTOR,
-                                  NewDescriptor: var PSECURITY_DESCRIPTOR,
-                                  IsDirectoryObject: WINBOOL, Token: HANDLE,
-                                  GenericMapping: PGENERIC_MAPPING): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "CreatePrivateObjectSecurity".}
-proc SetPrivateObjectSecurity*(SecurityInformation: SECURITY_INFORMATION,
-                               ModificationDescriptor: PSECURITY_DESCRIPTOR,
-    ObjectsSecurityDescriptor: var PSECURITY_DESCRIPTOR,
-                               GenericMapping: PGENERIC_MAPPING, Token: HANDLE): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetPrivateObjectSecurity".}
-proc GetPrivateObjectSecurity*(ObjectDescriptor: PSECURITY_DESCRIPTOR,
-                               SecurityInformation: SECURITY_INFORMATION,
-                               ResultantDescriptor: PSECURITY_DESCRIPTOR,
-                               DescriptorLength: DWORD, ReturnLength: PDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "GetPrivateObjectSecurity".}
-proc DestroyPrivateObjectSecurity*(ObjectDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "DestroyPrivateObjectSecurity".}
-proc MakeSelfRelativeSD*(pAbsoluteSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                         pSelfRelativeSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                         lpdwBufferLength: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "MakeSelfRelativeSD".}
-proc MakeAbsoluteSD*(pSelfRelativeSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                     pAbsoluteSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                     lpdwAbsoluteSecurityDescriptorSize: LPDWORD, pDacl: PACL,
-                     lpdwDaclSize: LPDWORD, pSacl: PACL, lpdwSaclSize: LPDWORD,
-                     pOwner: PSID, lpdwOwnerSize: LPDWORD, pPrimaryGroup: PSID,
-                     lpdwPrimaryGroupSize: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "MakeAbsoluteSD".}
-proc SetKernelObjectSecurity*(Handle: HANDLE,
-                              SecurityInformation: SECURITY_INFORMATION,
-                              SecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetKernelObjectSecurity".}
-proc FindNextChangeNotification*(hChangeHandle: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FindNextChangeNotification".}
-proc FindCloseChangeNotification*(hChangeHandle: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FindCloseChangeNotification".}
-proc VirtualLock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "VirtualLock".}
-proc VirtualUnlock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "VirtualUnlock".}
-proc MapViewOfFileEx*(hFileMappingObject: HANDLE, dwDesiredAccess: DWORD,
-                      dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD,
-                      dwNumberOfBytesToMap: DWORD, lpBaseAddress: LPVOID): LPVOID{.
-    stdcall, dynlib: "kernel32", importc: "MapViewOfFileEx".}
-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,
-    dynlib: "kernel32", importc: "IsBadReadPtr".}
-proc IsBadWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsBadWritePtr".}
-proc IsBadHugeReadPtr*(lp: pointer, ucb: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsBadHugeReadPtr".}
-proc IsBadHugeWritePtr*(lp: LPVOID, ucb: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsBadHugeWritePtr".}
-proc IsBadCodePtr*(lpfn: FARPROC): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "IsBadCodePtr".}
-proc AllocateLocallyUniqueId*(Luid: PLUID): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AllocateLocallyUniqueId".}
-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,
-    dynlib: "user32", importc: "ActivateKeyboardLayout".}
-proc UnloadKeyboardLayout*(hkl: HKL): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "UnloadKeyboardLayout".}
-proc GetKeyboardLayoutList*(nBuff: int32, lpList: var HKL): int32{.stdcall,
-    dynlib: "user32", importc: "GetKeyboardLayoutList".}
-proc GetKeyboardLayout*(dwLayout: DWORD): HKL{.stdcall, dynlib: "user32",
-    importc: "GetKeyboardLayout".}
-proc OpenInputDesktop*(dwFlags: DWORD, fInherit: WINBOOL, dwDesiredAccess: DWORD): HDESK{.
-    stdcall, dynlib: "user32", importc: "OpenInputDesktop".}
-proc EnumDesktopWindows*(hDesktop: HDESK, lpfn: ENUMWINDOWSPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumDesktopWindows".}
-proc SwitchDesktop*(hDesktop: HDESK): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SwitchDesktop".}
-proc SetThreadDesktop*(hDesktop: HDESK): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetThreadDesktop".}
-proc CloseDesktop*(hDesktop: HDESK): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "CloseDesktop".}
-proc GetThreadDesktop*(dwThreadId: DWORD): HDESK{.stdcall, dynlib: "user32",
-    importc: "GetThreadDesktop".}
-proc CloseWindowStation*(hWinSta: HWINSTA): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "CloseWindowStation".}
-proc SetProcessWindowStation*(hWinSta: HWINSTA): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetProcessWindowStation".}
-proc GetProcessWindowStation*(): HWINSTA{.stdcall, dynlib: "user32",
-    importc: "GetProcessWindowStation".}
-proc SetUserObjectSecurity*(hObj: HANDLE, pSIRequested: PSECURITY_INFORMATION,
-                            pSID: PSECURITY_DESCRIPTOR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetUserObjectSecurity".}
-proc GetUserObjectSecurity*(hObj: HANDLE, pSIRequested: PSECURITY_INFORMATION,
-                            pSID: PSECURITY_DESCRIPTOR, nLength: DWORD,
-                            lpnLengthNeeded: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetUserObjectSecurity".}
-proc TranslateMessage*(lpMsg: LPMSG): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "TranslateMessage".}
-proc SetMessageQueue*(cMessagesMax: int32): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetMessageQueue".}
-proc RegisterHotKey*(hWnd: HWND, anID: int32, fsModifiers: UINT, vk: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "RegisterHotKey".}
-proc UnregisterHotKey*(hWnd: HWND, anID: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "UnregisterHotKey".}
-proc ExitWindowsEx*(uFlags: UINT, dwReserved: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ExitWindowsEx".}
-proc SwapMouseButton*(fSwap: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SwapMouseButton".}
-proc GetMessagePos*(): DWORD{.stdcall, dynlib: "user32",
-                              importc: "GetMessagePos".}
-proc GetMessageTime*(): LONG{.stdcall, dynlib: "user32",
-                              importc: "GetMessageTime".}
-proc GetMessageExtraInfo*(): LONG{.stdcall, dynlib: "user32",
-                                   importc: "GetMessageExtraInfo".}
-proc SetMessageExtraInfo*(lParam: LPARAM): LPARAM{.stdcall, dynlib: "user32",
-    importc: "SetMessageExtraInfo".}
-proc BroadcastSystemMessage*(para1: DWORD, para2: LPDWORD, para3: UINT,
-                             para4: WPARAM, para5: LPARAM): int32{.stdcall,
-    dynlib: "user32", importc: "BroadcastSystemMessage".}
-proc AttachThreadInput*(idAttach: DWORD, idAttachTo: DWORD, fAttach: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "AttachThreadInput".}
-proc ReplyMessage*(lResult: LRESULT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ReplyMessage".}
-proc WaitMessage*(): WINBOOL{.stdcall, dynlib: "user32", importc: "WaitMessage".}
-proc WaitForInputIdle*(hProcess: HANDLE, dwMilliseconds: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "WaitForInputIdle".}
-proc PostQuitMessage*(nExitCode: int32){.stdcall, dynlib: "user32",
-    importc: "PostQuitMessage".}
-proc InSendMessage*(): WINBOOL{.stdcall, dynlib: "user32",
-                                importc: "InSendMessage".}
-proc GetDoubleClickTime*(): UINT{.stdcall, dynlib: "user32",
-                                  importc: "GetDoubleClickTime".}
-proc SetDoubleClickTime*(para1: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetDoubleClickTime".}
-proc IsWindow*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                     importc: "IsWindow".}
-proc IsMenu*(hMenu: HMENU): WINBOOL{.stdcall, dynlib: "user32",
-                                     importc: "IsMenu".}
-proc IsChild*(hWndParent: HWND, hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsChild".}
-proc DestroyWindow*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DestroyWindow".}
-proc ShowWindow*(hWnd: HWND, nCmdShow: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ShowWindow".}
-proc ShowWindowAsync*(hWnd: HWND, nCmdShow: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ShowWindowAsync".}
-proc FlashWindow*(hWnd: HWND, bInvert: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "FlashWindow".}
-proc ShowOwnedPopups*(hWnd: HWND, fShow: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ShowOwnedPopups".}
-proc OpenIcon*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                     importc: "OpenIcon".}
-proc CloseWindow*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "CloseWindow".}
-proc MoveWindow*(hWnd: HWND, X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                 bRepaint: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "MoveWindow".}
-proc SetWindowPos*(hWnd: HWND, hWndInsertAfter: HWND, X: int32, Y: int32,
-                   cx: int32, cy: int32, uFlags: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetWindowPos".}
-proc GetWindowPlacement*(hWnd: HWND, lpwndpl: var WINDOWPLACEMENT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetWindowPlacement".}
-proc SetWindowPlacement*(hWnd: HWND, lpwndpl: var WINDOWPLACEMENT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetWindowPlacement".}
-proc GetWindowPlacement*(hWnd: HWND, lpwndpl: PWINDOWPLACEMENT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetWindowPlacement".}
-proc SetWindowPlacement*(hWnd: HWND, lpwndpl: PWINDOWPLACEMENT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetWindowPlacement".}
-proc BeginDeferWindowPos*(nNumWindows: int32): HDWP{.stdcall, dynlib: "user32",
-    importc: "BeginDeferWindowPos".}
-proc DeferWindowPos*(hWinPosInfo: HDWP, hWnd: HWND, hWndInsertAfter: HWND,
-                     x: int32, y: int32, cx: int32, cy: int32, uFlags: UINT): HDWP{.
-    stdcall, dynlib: "user32", importc: "DeferWindowPos".}
-proc EndDeferWindowPos*(hWinPosInfo: HDWP): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "EndDeferWindowPos".}
-proc IsWindowVisible*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsWindowVisible".}
-proc IsIconic*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                     importc: "IsIconic".}
-proc AnyPopup*(): WINBOOL{.stdcall, dynlib: "user32", importc: "AnyPopup".}
-proc BringWindowToTop*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "BringWindowToTop".}
-proc IsZoomed*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                     importc: "IsZoomed".}
-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,
-                    bSigned: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetDlgItemInt".}
-proc GetDlgItemInt*(hDlg: HWND, nIDDlgItem: int32, lpTranslated: var WINBOOL,
-                    bSigned: WINBOOL): UINT{.stdcall, dynlib: "user32",
-    importc: "GetDlgItemInt".}
-proc CheckDlgButton*(hDlg: HWND, nIDButton: int32, uCheck: UINT): 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,
-    dynlib: "user32", importc: "IsDlgButtonChecked".}
-proc GetNextDlgGroupItem*(hDlg: HWND, hCtl: HWND, bPrevious: WINBOOL): HWND{.
-    stdcall, dynlib: "user32", importc: "GetNextDlgGroupItem".}
-proc GetNextDlgTabItem*(hDlg: HWND, hCtl: HWND, bPrevious: WINBOOL): HWND{.
-    stdcall, dynlib: "user32", importc: "GetNextDlgTabItem".}
-proc GetDlgCtrlID*(hWnd: HWND): int32{.stdcall, dynlib: "user32",
-                                       importc: "GetDlgCtrlID".}
-proc GetDialogBaseUnits*(): int32{.stdcall, dynlib: "user32",
-                                   importc: "GetDialogBaseUnits".}
-proc OpenClipboard*(hWndNewOwner: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "OpenClipboard".}
-proc CloseClipboard*(): WINBOOL{.stdcall, dynlib: "user32",
-                                 importc: "CloseClipboard".}
-proc GetClipboardOwner*(): HWND{.stdcall, dynlib: "user32",
-                                 importc: "GetClipboardOwner".}
-proc SetClipboardViewer*(hWndNewViewer: HWND): HWND{.stdcall, dynlib: "user32",
-    importc: "SetClipboardViewer".}
-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,
-    dynlib: "user32", importc: "SetClipboardData".}
-proc GetClipboardData*(uFormat: UINT): HANDLE{.stdcall, dynlib: "user32",
-    importc: "GetClipboardData".}
-proc CountClipboardFormats*(): int32{.stdcall, dynlib: "user32",
-                                      importc: "CountClipboardFormats".}
-proc EnumClipboardFormats*(format: UINT): UINT{.stdcall, dynlib: "user32",
-    importc: "EnumClipboardFormats".}
-proc EmptyClipboard*(): WINBOOL{.stdcall, dynlib: "user32",
-                                 importc: "EmptyClipboard".}
-proc IsClipboardFormatAvailable*(format: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "IsClipboardFormatAvailable".}
-proc GetPriorityClipboardFormat*(paFormatPriorityList: var UINT, cFormats: int32): int32{.
-    stdcall, dynlib: "user32", importc: "GetPriorityClipboardFormat".}
-proc GetOpenClipboardWindow*(): HWND{.stdcall, dynlib: "user32",
-                                      importc: "GetOpenClipboardWindow".}
-proc CharNextExA*(CodePage: int16, lpCurrentChar: LPCSTR, dwFlags: DWORD): LPSTR{.
-    stdcall, dynlib: "user32", importc: "CharNextExA".}
-proc CharPrevExA*(CodePage: int16, lpStart: LPCSTR, lpCurrentChar: LPCSTR,
-                  dwFlags: DWORD): LPSTR{.stdcall, dynlib: "user32",
-    importc: "CharPrevExA".}
-proc SetFocus*(hWnd: 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 GetKeyState*(nVirtKey: int32): SHORT{.stdcall, dynlib: "user32",
-    importc: "GetKeyState".}
-proc GetAsyncKeyState*(vKey: int32): SHORT{.stdcall, dynlib: "user32",
-    importc: "GetAsyncKeyState".}
-proc GetKeyboardState*(lpKeyState: PBYTE): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetKeyboardState".}
-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",
-    importc: "ToAscii".}
-proc ToAsciiEx*(uVirtKey: UINT, uScanCode: UINT, lpKeyState: PBYTE,
-                lpChar: LPWORD, uFlags: UINT, dwhkl: HKL): int32{.stdcall,
-    dynlib: "user32", importc: "ToAsciiEx".}
-proc ToUnicode*(wVirtKey: UINT, wScanCode: UINT, lpKeyState: PBYTE,
-                pwszBuff: LPWSTR, cchBuff: int32, wFlags: UINT): int32{.stdcall,
-    dynlib: "user32", importc: "ToUnicode".}
-proc OemKeyScan*(wOemChar: int16): DWORD{.stdcall, dynlib: "user32",
-    importc: "OemKeyScan".}
-proc keybd_event*(bVk: int8, bScan: int8, dwFlags: DWORD, dwExtraInfo: DWORD){.
-    stdcall, dynlib: "user32", importc: "keybd_event".}
-proc mouse_event*(dwFlags: DWORD, dx: DWORD, dy: DWORD, cButtons: DWORD,
-                  dwExtraInfo: DWORD){.stdcall, dynlib: "user32",
-                                       importc: "mouse_event".}
-proc GetInputState*(): WINBOOL{.stdcall, dynlib: "user32",
-                                importc: "GetInputState".}
-proc GetQueueStatus*(flags: UINT): DWORD{.stdcall, dynlib: "user32",
-    importc: "GetQueueStatus".}
-proc GetCapture*(): HWND{.stdcall, dynlib: "user32", importc: "GetCapture".}
-proc SetCapture*(hWnd: HWND): HWND{.stdcall, dynlib: "user32",
-                                    importc: "SetCapture".}
-proc ReleaseCapture*(): WINBOOL{.stdcall, dynlib: "user32",
-                                 importc: "ReleaseCapture".}
-proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: LPHANDLE,
-                                fWaitAll: WINBOOL, dwMilliseconds: DWORD,
-                                dwWakeMask: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "MsgWaitForMultipleObjects".}
-proc SetTimer*(hWnd: HWND, nIDEvent: UINT, uElapse: UINT, lpTimerFunc: TIMERPROC): UINT{.
-    stdcall, dynlib: "user32", importc: "SetTimer".}
-proc KillTimer*(hWnd: HWND, uIDEvent: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "KillTimer".}
-proc IsWindowUnicode*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsWindowUnicode".}
-proc EnableWindow*(hWnd: HWND, bEnable: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EnableWindow".}
-proc IsWindowEnabled*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsWindowEnabled".}
-proc DestroyAcceleratorTable*(hAccel: HACCEL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DestroyAcceleratorTable".}
-proc GetSystemMetrics*(nIndex: int32): int32{.stdcall, dynlib: "user32",
-    importc: "GetSystemMetrics".}
-proc GetMenu*(hWnd: HWND): HMENU{.stdcall, dynlib: "user32", importc: "GetMenu".}
-proc SetMenu*(hWnd: HWND, hMenu: HMENU): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetMenu".}
-proc HiliteMenuItem*(hWnd: HWND, hMenu: HMENU, uIDHiliteItem: UINT,
-                     uHilite: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "HiliteMenuItem".}
-proc GetMenuState*(hMenu: HMENU, uId: UINT, uFlags: UINT): UINT{.stdcall,
-    dynlib: "user32", importc: "GetMenuState".}
-proc DrawMenuBar*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "DrawMenuBar".}
-proc GetSystemMenu*(hWnd: HWND, bRevert: WINBOOL): HMENU{.stdcall,
-    dynlib: "user32", importc: "GetSystemMenu".}
-proc CreateMenu*(): HMENU{.stdcall, dynlib: "user32", importc: "CreateMenu".}
-proc CreatePopupMenu*(): HMENU{.stdcall, dynlib: "user32",
-                                importc: "CreatePopupMenu".}
-proc DestroyMenu*(hMenu: HMENU): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DestroyMenu".}
-proc CheckMenuItem*(hMenu: HMENU, uIDCheckItem: UINT, uCheck: UINT): DWORD{.
-    stdcall, dynlib: "user32", importc: "CheckMenuItem".}
-proc EnableMenuItem*(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnableMenuItem".}
-proc GetSubMenu*(hMenu: HMENU, nPos: int32): HMENU{.stdcall, dynlib: "user32",
-    importc: "GetSubMenu".}
-proc GetMenuItemID*(hMenu: HMENU, nPos: int32): UINT{.stdcall, dynlib: "user32",
-    importc: "GetMenuItemID".}
-proc GetMenuItemCount*(hMenu: HMENU): int32{.stdcall, dynlib: "user32",
-    importc: "GetMenuItemCount".}
-proc RemoveMenu*(hMenu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "RemoveMenu".}
-proc DeleteMenu*(hMenu: HMENU, uPosition: UINT, uFlags: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DeleteMenu".}
-proc SetMenuItemBitmaps*(hMenu: HMENU, uPosition: UINT, uFlags: UINT,
-                         hBitmapUnchecked: HBITMAP, hBitmapChecked: HBITMAP): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetMenuItemBitmaps".}
-proc GetMenuCheckMarkDimensions*(): LONG{.stdcall, dynlib: "user32",
-    importc: "GetMenuCheckMarkDimensions".}
-proc TrackPopupMenu*(hMenu: HMENU, uFlags: UINT, x: int32, y: int32,
-                     nReserved: int32, hWnd: HWND, prcRect: var RECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "TrackPopupMenu".}
-proc GetMenuDefaultItem*(hMenu: HMENU, fByPos: UINT, gmdiFlags: UINT): UINT{.
-    stdcall, dynlib: "user32", importc: "GetMenuDefaultItem".}
-proc SetMenuDefaultItem*(hMenu: HMENU, uItem: UINT, fByPos: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetMenuDefaultItem".}
-proc GetMenuItemRect*(hWnd: HWND, hMenu: HMENU, uItem: UINT, lprcItem: LPRECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetMenuItemRect".}
-proc MenuItemFromPoint*(hWnd: HWND, hMenu: HMENU, ptScreen: POINT): int32{.
-    stdcall, dynlib: "user32", importc: "MenuItemFromPoint".}
-proc DragObject*(para1: HWND, para2: HWND, para3: UINT, para4: DWORD,
-                 para5: HCURSOR): DWORD{.stdcall, dynlib: "user32",
-    importc: "DragObject".}
-proc DragDetect*(hwnd: HWND, pt: POINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DragDetect".}
-proc DrawIcon*(hDC: HDC, X: int32, Y: int32, hIcon: HICON): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DrawIcon".}
-proc UpdateWindow*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "UpdateWindow".}
-proc SetActiveWindow*(hWnd: HWND): HWND{.stdcall, dynlib: "user32",
-    importc: "SetActiveWindow".}
-proc GetForegroundWindow*(): HWND{.stdcall, dynlib: "user32",
-                                   importc: "GetForegroundWindow".}
-proc PaintDesktop*(hdc: HDC): WINBOOL{.stdcall, dynlib: "user32",
-                                       importc: "PaintDesktop".}
-proc SetForegroundWindow*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetForegroundWindow".}
-proc WindowFromDC*(hDC: HDC): HWND{.stdcall, dynlib: "user32",
-                                    importc: "WindowFromDC".}
-proc GetDC*(hWnd: HWND): HDC{.stdcall, dynlib: "user32", importc: "GetDC".}
-proc GetDCEx*(hWnd: HWND, hrgnClip: HRGN, flags: DWORD): HDC{.stdcall,
-    dynlib: "user32", importc: "GetDCEx".}
-proc GetWindowDC*(hWnd: HWND): HDC{.stdcall, dynlib: "user32",
-                                    importc: "GetWindowDC".}
-proc ReleaseDC*(hWnd: HWND, hDC: HDC): int32{.stdcall, dynlib: "user32",
-    importc: "ReleaseDC".}
-proc BeginPaint*(hWnd: HWND, lpPaint: LPPAINTSTRUCT): HDC{.stdcall,
-    dynlib: "user32", importc: "BeginPaint".}
-proc EndPaint*(hWnd: HWND, lpPaint: LPPAINTSTRUCT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EndPaint".}
-proc GetUpdateRect*(hWnd: HWND, lpRect: LPRECT, bErase: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUpdateRect".}
-proc GetUpdateRgn*(hWnd: HWND, hRgn: HRGN, bErase: WINBOOL): int32{.stdcall,
-    dynlib: "user32", importc: "GetUpdateRgn".}
-proc SetWindowRgn*(hWnd: HWND, hRgn: HRGN, bRedraw: WINBOOL): int32{.stdcall,
-    dynlib: "user32", importc: "SetWindowRgn".}
-proc GetWindowRgn*(hWnd: HWND, hRgn: HRGN): int32{.stdcall, dynlib: "user32",
-    importc: "GetWindowRgn".}
-proc ExcludeUpdateRgn*(hDC: HDC, hWnd: HWND): int32{.stdcall, dynlib: "user32",
-    importc: "ExcludeUpdateRgn".}
-proc InvalidateRect*(hWnd: HWND, lpRect: var RECT, bErase: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "InvalidateRect".}
-proc InvalidateRect*(hWnd: HWND, lpRect: LPRECT, bErase: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "InvalidateRect".}
-proc ValidateRect*(hWnd: HWND, lpRect: var RECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ValidateRect".}
-proc ValidateRect*(hWnd: HWND, lpRect: LPRECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ValidateRect".}
-proc InvalidateRgn*(hWnd: HWND, hRgn: HRGN, bErase: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "InvalidateRgn".}
-proc ValidateRgn*(hWnd: HWND, hRgn: HRGN): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ValidateRgn".}
-proc RedrawWindow*(hWnd: HWND, lprcUpdate: var RECT, hrgnUpdate: HRGN,
-                   flags: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "RedrawWindow".}
-proc RedrawWindow*(hWnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "RedrawWindow".}
-proc LockWindowUpdate*(hWndLock: HWND): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "LockWindowUpdate".}
-proc ScrollWindow*(hWnd: HWND, XAmount: int32, YAmount: int32, lpRect: var RECT,
-                   lpClipRect: var RECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ScrollWindow".}
-proc ScrollDC*(hDC: HDC, dx: int32, dy: int32, lprcScroll: var RECT,
-               lprcClip: var RECT, hrgnUpdate: HRGN, lprcUpdate: LPRECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "ScrollDC".}
-proc ScrollWindowEx*(hWnd: HWND, dx: int32, dy: int32, prcScroll: var RECT,
-                     prcClip: var RECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,
-                     flags: UINT): int32{.stdcall, dynlib: "user32",
-    importc: "ScrollWindowEx".}
-proc SetScrollPos*(hWnd: HWND, nBar: int32, nPos: int32, bRedraw: WINBOOL): int32{.
-    stdcall, dynlib: "user32", importc: "SetScrollPos".}
-proc GetScrollPos*(hWnd: HWND, nBar: int32): int32{.stdcall, dynlib: "user32",
-    importc: "GetScrollPos".}
-proc SetScrollRange*(hWnd: HWND, nBar: int32, nMinPos: int32, nMaxPos: int32,
-                     bRedraw: WINBOOL): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetScrollRange".}
-proc GetScrollRange*(hWnd: HWND, nBar: int32, lpMinPos: LPINT, lpMaxPos: LPINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetScrollRange".}
-proc ShowScrollBar*(hWnd: HWND, wBar: int32, bShow: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ShowScrollBar".}
-proc EnableScrollBar*(hWnd: HWND, wSBflags: UINT, wArrows: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnableScrollBar".}
-proc GetClientRect*(hWnd: HWND, lpRect: LPRECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetClientRect".}
-proc GetWindowRect*(hWnd: HWND, lpRect: LPRECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetWindowRect".}
-proc AdjustWindowRect*(lpRect: LPRECT, dwStyle: DWORD, bMenu: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "AdjustWindowRect".}
-proc AdjustWindowRectEx*(lpRect: LPRECT, dwStyle: DWORD, bMenu: WINBOOL,
-                         dwExStyle: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "AdjustWindowRectEx".}
-proc SetWindowContextHelpId*(para1: HWND, para2: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetWindowContextHelpId".}
-proc GetWindowContextHelpId*(para1: HWND): DWORD{.stdcall, dynlib: "user32",
-    importc: "GetWindowContextHelpId".}
-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",
-    importc: "MessageBeep".}
-proc ShowCursor*(bShow: WINBOOL): int32{.stdcall, dynlib: "user32",
-    importc: "ShowCursor".}
-proc SetCursorPos*(X: int32, Y: int32): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetCursorPos".}
-proc SetCursor*(hCursor: HCURSOR): HCURSOR{.stdcall, dynlib: "user32",
-    importc: "SetCursor".}
-proc GetCursorPos*(lpPoint: LPPOINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetCursorPos".}
-proc ClipCursor*(lpRect: LPRECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ClipCursor".}
-proc GetClipCursor*(lpRect: LPRECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetClipCursor".}
-proc GetCursor*(): HCURSOR{.stdcall, dynlib: "user32", importc: "GetCursor".}
-proc CreateCaret*(hWnd: HWND, hBitmap: HBITMAP, nWidth: int32, nHeight: int32): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "CreateCaret".}
-proc GetCaretBlinkTime*(): UINT{.stdcall, dynlib: "user32",
-                                 importc: "GetCaretBlinkTime".}
-proc SetCaretBlinkTime*(uMSeconds: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetCaretBlinkTime".}
-proc DestroyCaret*(): WINBOOL{.stdcall, dynlib: "user32",
-                               importc: "DestroyCaret".}
-proc HideCaret*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                      importc: "HideCaret".}
-proc ShowCaret*(hWnd: HWND): WINBOOL{.stdcall, dynlib: "user32",
-                                      importc: "ShowCaret".}
-proc SetCaretPos*(X: int32, Y: int32): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetCaretPos".}
-proc GetCaretPos*(lpPoint: LPPOINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetCaretPos".}
-proc ClientToScreen*(hWnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ClientToScreen".}
-proc ScreenToClient*(hWnd: HWND, lpPoint: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ScreenToClient".}
-proc MapWindowPoints*(hWndFrom: HWND, hWndTo: HWND, lpPoints: LPPOINT,
-                      cPoints: UINT): int32{.stdcall, dynlib: "user32",
-    importc: "MapWindowPoints".}
-proc WindowFromPoint*(Point: POINT): HWND{.stdcall, dynlib: "user32",
-    importc: "WindowFromPoint".}
-proc ChildWindowFromPoint*(hWndParent: HWND, Point: POINT): HWND{.stdcall,
-    dynlib: "user32", importc: "ChildWindowFromPoint".}
-proc GetSysColor*(nIndex: int32): DWORD{.stdcall, dynlib: "user32",
-    importc: "GetSysColor".}
-proc GetSysColorBrush*(nIndex: int32): HBRUSH{.stdcall, dynlib: "user32",
-    importc: "GetSysColorBrush".}
-proc SetSysColors*(cElements: int32, lpaElements: var wINT,
-                   lpaRgbValues: var COLORREF): WINBOOL{.stdcall,
-    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,
-    dynlib: "user32", importc: "FillRect".}
-proc FrameRect*(hDC: HDC, lprc: var RECT, hbr: HBRUSH): int32{.stdcall,
-    dynlib: "user32", importc: "FrameRect".}
-proc InvertRect*(hDC: HDC, lprc: var RECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "InvertRect".}
-proc SetRect*(lprc: LPRECT, xLeft: int32, yTop: int32, xRight: int32,
-              yBottom: int32): WINBOOL{.stdcall, dynlib: "user32",
-                                        importc: "SetRect".}
-proc SetRectEmpty*(lprc: LPRECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetRectEmpty".}
-proc CopyRect*(lprcDst: LPRECT, lprcSrc: var RECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CopyRect".}
-proc InflateRect*(lprc: LPRECT, dx: int32, dy: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "InflateRect".}
-proc IntersectRect*(lprcDst: LPRECT, lprcSrc1: var RECT, lprcSrc2: var RECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "IntersectRect".}
-proc UnionRect*(lprcDst: LPRECT, lprcSrc1: var RECT, lprcSrc2: var RECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "UnionRect".}
-proc SubtractRect*(lprcDst: LPRECT, lprcSrc1: var RECT, lprcSrc2: var RECT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SubtractRect".}
-proc OffsetRect*(lprc: LPRECT, dx: int32, dy: int32): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "OffsetRect".}
-proc IsRectEmpty*(lprc: var RECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "IsRectEmpty".}
-proc EqualRect*(lprc1: var RECT, lprc2: var RECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EqualRect".}
-proc PtInRect*(lprc: var RECT, pt: POINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "PtInRect".}
-proc PtInRect*(lprc: LPRECT, pt: POINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "PtInRect".}
-proc GetWindowWord*(hWnd: HWND, nIndex: int32): int16{.stdcall,
-    dynlib: "user32", importc: "GetWindowWord".}
-proc SetWindowWord*(hWnd: HWND, nIndex: int32, wNewWord: int16): int16{.stdcall,
-    dynlib: "user32", importc: "SetWindowWord".}
-proc GetClassWord*(hWnd: HWND, nIndex: int32): int16{.stdcall, dynlib: "user32",
-    importc: "GetClassWord".}
-proc SetClassWord*(hWnd: HWND, nIndex: int32, wNewWord: int16): int16{.stdcall,
-    dynlib: "user32", importc: "SetClassWord".}
-proc GetDesktopWindow*(): HWND{.stdcall, dynlib: "user32",
-                                importc: "GetDesktopWindow".}
-proc GetParent*(hWnd: HWND): HWND{.stdcall, dynlib: "user32",
-                                   importc: "GetParent".}
-proc SetParent*(hWndChild: HWND, hWndNewParent: HWND): HWND{.stdcall,
-    dynlib: "user32", importc: "SetParent".}
-proc EnumChildWindows*(hWndParent: HWND, lpEnumFunc: ENUMWINDOWSPROC,
-                       lParam: LPARAM): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "EnumChildWindows".}
-proc EnumWindows*(lpEnumFunc: ENUMWINDOWSPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumWindows".}
-proc EnumThreadWindows*(dwThreadId: DWORD, lpfn: ENUMWINDOWSPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumThreadWindows".}
-proc EnumTaskWindows*(hTask: HWND, lpfn: FARPROC, lParam: LPARAM): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "EnumThreadWindows".}
-proc GetTopWindow*(hWnd: HWND): HWND{.stdcall, dynlib: "user32",
-                                      importc: "GetTopWindow".}
-proc GetWindowThreadProcessId*(hWnd: HWND, lpdwProcessId: LPDWORD): DWORD{.
-    stdcall, dynlib: "user32", importc: "GetWindowThreadProcessId".}
-proc GetLastActivePopup*(hWnd: HWND): HWND{.stdcall, dynlib: "user32",
-    importc: "GetLastActivePopup".}
-proc GetWindow*(hWnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",
-    importc: "GetWindow".}
-proc UnhookWindowsHook*(nCode: int32, pfnFilterProc: HOOKPROC): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "UnhookWindowsHook".}
-proc UnhookWindowsHookEx*(hhk: HHOOK): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "UnhookWindowsHookEx".}
-proc CallNextHookEx*(hhk: HHOOK, nCode: int32, wParam: WPARAM, lParam: LPARAM): LRESULT{.
-    stdcall, dynlib: "user32", importc: "CallNextHookEx".}
-proc CheckMenuRadioItem*(para1: HMENU, para2: UINT, para3: UINT, para4: UINT,
-                         para5: UINT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "CheckMenuRadioItem".}
-proc CreateCursor*(hInst: HINST, xHotSpot: int32, yHotSpot: int32,
-                   nWidth: int32, nHeight: int32, pvANDPlane: pointer,
-                   pvXORPlane: pointer): HCURSOR{.stdcall, dynlib: "user32",
-    importc: "CreateCursor".}
-proc DestroyCursor*(hCursor: HCURSOR): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DestroyCursor".}
-proc SetSystemCursor*(hcur: HCURSOR, anID: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetSystemCursor".}
-proc CreateIcon*(hInstance: HINST, nWidth: int32, nHeight: int32, cPlanes: int8,
-                 cBitsPixel: int8, lpbANDbits: var int8, lpbXORbits: var int8): HICON{.
-    stdcall, dynlib: "user32", importc: "CreateIcon".}
-proc DestroyIcon*(hIcon: HICON): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DestroyIcon".}
-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,
-    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,
-    dynlib: "user32", importc: "CreateIconFromResourceEx".}
-proc CopyImage*(para1: HANDLE, para2: UINT, para3: int32, para4: int32,
-                para5: UINT): HICON{.stdcall, dynlib: "user32",
-                                     importc: "CopyImage".}
-proc CreateIconIndirect*(piconinfo: PICONINFO): HICON{.stdcall,
-    dynlib: "user32", importc: "CreateIconIndirect".}
-proc CopyIcon*(hIcon: HICON): HICON{.stdcall, dynlib: "user32",
-                                     importc: "CopyIcon".}
-proc GetIconInfo*(hIcon: HICON, piconinfo: PICONINFO): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetIconInfo".}
-proc MapDialogRect*(hDlg: HWND, lpRect: LPRECT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "MapDialogRect".}
-proc SetScrollInfo*(para1: HWND, para2: int32, para3: LPCSCROLLINFO,
-                    para4: WINBOOL): int32{.stdcall, dynlib: "user32",
-    importc: "SetScrollInfo".}
-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*(hWnd: HWND): UINT{.stdcall, dynlib: "user32",
-    importc: "ArrangeIconicWindows".}
-proc TileWindows*(hwndParent: HWND, wHow: UINT, lpRect: var RECT, cKids: UINT,
-                  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,
-    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{.
-    stdcall, dynlib: "user32", importc: "DrawEdge".}
-proc DrawFrameControl*(para1: HDC, para2: LPRECT, para3: UINT, para4: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "DrawFrameControl".}
-proc DrawCaption*(para1: HWND, para2: HDC, para3: var RECT, para4: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "DrawCaption".}
-proc DrawAnimatedRects*(hwnd: 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,
-                       para5: HWND, para6: LPTPMPARAMS): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "TrackPopupMenuEx".}
-proc ChildWindowFromPointEx*(para1: HWND, para2: POINT, para3: UINT): HWND{.
-    stdcall, dynlib: "user32", importc: "ChildWindowFromPointEx".}
-proc DrawIconEx*(hdc: HDC, xLeft: int32, yTop: int32, hIcon: HICON,
-                 cxWidth: int32, cyWidth: int32, istepIfAniCur: UINT,
-                 hbrFlickerFreeDraw: HBRUSH, diFlags: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "DrawIconEx".}
-proc AnimatePalette*(para1: HPALETTE, para2: UINT, para3: UINT,
-                     para4: var PALETTEENTRY): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "AnimatePalette".}
-proc Arc*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-          para6: int32, para7: int32, para8: int32, para9: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "Arc".}
-proc BitBlt*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-             para6: HDC, para7: int32, para8: int32, para9: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "BitBlt".}
-proc CancelDC*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                     importc: "CancelDC".}
-proc Chord*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-            para6: int32, para7: int32, para8: int32, para9: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "Chord".}
-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,
-                   para5: pointer): HBITMAP{.stdcall, dynlib: "gdi32",
-    importc: "CreateBitmap".}
-proc CreateBitmapIndirect*(para1: var BITMAP): HBITMAP{.stdcall,
-    dynlib: "gdi32", importc: "CreateBitmapIndirect".}
-proc CreateBrushIndirect*(para1: var LOGBRUSH): HBRUSH{.stdcall,
-    dynlib: "gdi32", importc: "CreateBrushIndirect".}
-proc CreateCompatibleBitmap*(para1: HDC, para2: int32, para3: int32): HBITMAP{.
-    stdcall, dynlib: "gdi32", importc: "CreateCompatibleBitmap".}
-proc CreateDiscardableBitmap*(para1: HDC, para2: int32, para3: int32): HBITMAP{.
-    stdcall, dynlib: "gdi32", importc: "CreateDiscardableBitmap".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "CreateDIBitmap".}
-proc CreateDIBPatternBrush*(para1: HGLOBAL, para2: UINT): HBRUSH{.stdcall,
-    dynlib: "gdi32", importc: "CreateDIBPatternBrush".}
-proc CreateDIBPatternBrushPt*(para1: pointer, para2: UINT): HBRUSH{.stdcall,
-    dynlib: "gdi32", importc: "CreateDIBPatternBrushPt".}
-proc CreateEllipticRgn*(para1: int32, para2: int32, para3: int32, para4: int32): HRGN{.
-    stdcall, dynlib: "gdi32", importc: "CreateEllipticRgn".}
-proc CreateEllipticRgnIndirect*(para1: var RECT): HRGN{.stdcall,
-    dynlib: "gdi32", importc: "CreateEllipticRgnIndirect".}
-proc CreateHatchBrush*(para1: int32, para2: COLORREF): HBRUSH{.stdcall,
-    dynlib: "gdi32", importc: "CreateHatchBrush".}
-proc CreatePalette*(para1: var LOGPALETTE): HPALETTE{.stdcall, dynlib: "gdi32",
-    importc: "CreatePalette".}
-proc CreatePen*(para1: int32, para2: int32, para3: COLORREF): HPEN{.stdcall,
-    dynlib: "gdi32", importc: "CreatePen".}
-proc CreatePenIndirect*(para1: var LOGPEN): HPEN{.stdcall, dynlib: "gdi32",
-    importc: "CreatePenIndirect".}
-proc CreatePolyPolygonRgn*(para1: var POINT, para2: var wINT, para3: int32,
-                           para4: int32): HRGN{.stdcall, dynlib: "gdi32",
-    importc: "CreatePolyPolygonRgn".}
-proc CreatePatternBrush*(para1: HBITMAP): HBRUSH{.stdcall, dynlib: "gdi32",
-    importc: "CreatePatternBrush".}
-proc CreateRectRgn*(para1: int32, para2: int32, para3: int32, para4: int32): HRGN{.
-    stdcall, dynlib: "gdi32", importc: "CreateRectRgn".}
-proc CreateRectRgnIndirect*(para1: var RECT): HRGN{.stdcall, dynlib: "gdi32",
-    importc: "CreateRectRgnIndirect".}
-proc CreateRoundRectRgn*(para1: int32, para2: int32, para3: int32, para4: int32,
-                         para5: int32, para6: int32): HRGN{.stdcall,
-    dynlib: "gdi32", importc: "CreateRoundRectRgn".}
-proc CreateSolidBrush*(para1: COLORREF): HBRUSH{.stdcall, dynlib: "gdi32",
-    importc: "CreateSolidBrush".}
-proc DeleteDC*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                     importc: "DeleteDC".}
-proc DeleteMetaFile*(para1: HMETAFILE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "DeleteMetaFile".}
-proc DeleteObject*(para1: HGDIOBJ): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "DeleteObject".}
-proc DrawEscape*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR): int32{.
-    stdcall, dynlib: "gdi32", importc: "DrawEscape".}
-proc Ellipse*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "Ellipse".}
-proc EnumObjects*(para1: HDC, para2: int32, para3: ENUMOBJECTSPROC,
-                  para4: LPARAM): int32{.stdcall, dynlib: "gdi32",
-    importc: "EnumObjects".}
-proc EqualRgn*(para1: HRGN, para2: HRGN): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "EqualRgn".}
-proc Escape*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,
-             para5: LPVOID): int32{.stdcall, dynlib: "gdi32", importc: "Escape".}
-proc ExtEscape*(para1: HDC, para2: int32, para3: int32, para4: LPCSTR,
-                para5: int32, para6: LPSTR): int32{.stdcall, dynlib: "gdi32",
-    importc: "ExtEscape".}
-proc ExcludeClipRect*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                      para5: int32): int32{.stdcall, dynlib: "gdi32",
-    importc: "ExcludeClipRect".}
-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",
-    importc: "ExtFloodFill".}
-proc FillRgn*(para1: HDC, para2: HRGN, para3: HBRUSH): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "FillRgn".}
-proc FloodFill*(para1: HDC, para2: int32, para3: int32, para4: COLORREF): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "FloodFill".}
-proc FrameRgn*(para1: HDC, para2: HRGN, para3: HBRUSH, para4: int32,
-               para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",
-                                       importc: "FrameRgn".}
-proc GetROP2*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "GetROP2".}
-proc GetAspectRatioFilterEx*(para1: HDC, para2: LPSIZE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetAspectRatioFilterEx".}
-proc GetBkColor*(para1: HDC): COLORREF{.stdcall, dynlib: "gdi32",
-                                        importc: "GetBkColor".}
-proc GetBkMode*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
-                                    importc: "GetBkMode".}
-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,
-    dynlib: "gdi32", importc: "GetBoundsRect".}
-proc GetBrushOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetBrushOrgEx".}
-proc GetClipBox*(para1: HDC, para2: LPRECT): int32{.stdcall, dynlib: "gdi32",
-    importc: "GetClipBox".}
-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,
-    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{.
-    stdcall, dynlib: "gdi32", importc: "GetDIBits".}
-proc GetFontData*(para1: HDC, para2: DWORD, para3: DWORD, para4: LPVOID,
-                  para5: DWORD): DWORD{.stdcall, dynlib: "gdi32",
-                                        importc: "GetFontData".}
-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{.
-    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,
-    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",
-    importc: "GetPaletteEntries".}
-proc GetPixel*(para1: HDC, para2: int32, para3: int32): COLORREF{.stdcall,
-    dynlib: "gdi32", importc: "GetPixel".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "GetRasterizerCaps".}
-proc GetRegionData*(para1: HRGN, para2: DWORD, para3: LPRGNDATA): DWORD{.
-    stdcall, dynlib: "gdi32", importc: "GetRegionData".}
-proc GetRgnBox*(para1: HRGN, para2: LPRECT): int32{.stdcall, dynlib: "gdi32",
-    importc: "GetRgnBox".}
-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,
-    dynlib: "gdi32", importc: "GetSystemPaletteEntries".}
-proc GetSystemPaletteUse*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",
-    importc: "GetSystemPaletteUse".}
-proc GetTextCharacterExtra*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
-    importc: "GetTextCharacterExtra".}
-proc GetTextAlign*(para1: HDC): UINT{.stdcall, dynlib: "gdi32",
-                                      importc: "GetTextAlign".}
-proc GetTextColor*(para1: HDC): COLORREF{.stdcall, dynlib: "gdi32",
-    importc: "GetTextColor".}
-proc GetTextCharset*(hdc: HDC): int32{.stdcall, dynlib: "gdi32",
-                                       importc: "GetTextCharset".}
-proc GetTextCharsetInfo*(hdc: HDC, lpSig: LPFONTSIGNATURE, dwFlags: DWORD): int32{.
-    stdcall, dynlib: "gdi32", importc: "GetTextCharsetInfo".}
-proc TranslateCharsetInfo*(lpSrc: var DWORD, lpCs: LPCHARSETINFO, dwFlags: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "TranslateCharsetInfo".}
-proc GetFontLanguageInfo*(para1: HDC): DWORD{.stdcall, dynlib: "gdi32",
-    importc: "GetFontLanguageInfo".}
-proc GetViewportExtEx*(para1: HDC, para2: LPSIZE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetViewportExtEx".}
-proc GetViewportOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetViewportOrgEx".}
-proc GetWindowExtEx*(para1: HDC, para2: LPSIZE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWindowExtEx".}
-proc GetWindowOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWindowOrgEx".}
-proc IntersectClipRect*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                        para5: int32): int32{.stdcall, dynlib: "gdi32",
-    importc: "IntersectClipRect".}
-proc InvertRgn*(para1: HDC, para2: HRGN): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "InvertRgn".}
-proc LineDDA*(para1: int32, para2: int32, para3: int32, para4: int32,
-              para5: LINEDDAPROC, para6: LPARAM): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "LineDDA".}
-proc LineTo*(para1: HDC, para2: int32, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "LineTo".}
-proc MaskBlt*(para1: HDC, para2: int32, para3: int32, para4: int32,
-              para5: int32, para6: HDC, para7: int32, para8: int32,
-              para9: HBITMAP, para10: int32, para11: int32, para12: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "MaskBlt".}
-proc PlgBlt*(para1: HDC, para2: var POINT, para3: HDC, para4: int32,
-             para5: int32, para6: int32, para7: int32, para8: HBITMAP,
-             para9: int32, para10: int32): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "PlgBlt".}
-proc OffsetClipRgn*(para1: HDC, para2: int32, para3: int32): int32{.stdcall,
-    dynlib: "gdi32", importc: "OffsetClipRgn".}
-proc OffsetRgn*(para1: HRGN, para2: int32, para3: int32): int32{.stdcall,
-    dynlib: "gdi32", importc: "OffsetRgn".}
-proc PatBlt*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-             para6: DWORD): WINBOOL{.stdcall, dynlib: "gdi32", importc: "PatBlt".}
-proc Pie*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-          para6: int32, para7: int32, para8: int32, para9: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "Pie".}
-proc PlayMetaFile*(para1: HDC, para2: HMETAFILE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PlayMetaFile".}
-proc PaintRgn*(para1: HDC, para2: HRGN): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "PaintRgn".}
-proc PolyPolygon*(para1: HDC, para2: var POINT, para3: var wINT, para4: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyPolygon".}
-proc PtInRegion*(para1: HRGN, para2: int32, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PtInRegion".}
-proc PtVisible*(para1: HDC, para2: int32, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PtVisible".}
-proc RectInRegion*(para1: HRGN, para2: var RECT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "RectInRegion".}
-proc RectVisible*(para1: HDC, para2: var RECT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "RectVisible".}
-proc Rectangle*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",
-                                        importc: "Rectangle".}
-proc RestoreDC*(para1: HDC, para2: int32): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "RestoreDC".}
-proc RealizePalette*(para1: HDC): UINT{.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,
-    dynlib: "gdi32", importc: "ResizePalette".}
-proc SaveDC*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "SaveDC".}
-proc SelectClipRgn*(para1: HDC, para2: HRGN): int32{.stdcall, dynlib: "gdi32",
-    importc: "SelectClipRgn".}
-proc ExtSelectClipRgn*(para1: HDC, para2: HRGN, para3: int32): int32{.stdcall,
-    dynlib: "gdi32", importc: "ExtSelectClipRgn".}
-proc SetMetaRgn*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
-                                     importc: "SetMetaRgn".}
-proc SelectObject*(para1: HDC, para2: HGDIOBJ): HGDIOBJ{.stdcall,
-    dynlib: "gdi32", importc: "SelectObject".}
-proc SelectPalette*(para1: HDC, para2: HPALETTE, para3: WINBOOL): HPALETTE{.
-    stdcall, dynlib: "gdi32", importc: "SelectPalette".}
-proc SetBkColor*(para1: HDC, para2: COLORREF): COLORREF{.stdcall,
-    dynlib: "gdi32", importc: "SetBkColor".}
-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,
-    dynlib: "gdi32", importc: "SetBoundsRect".}
-proc SetDIBits*(para1: HDC, para2: HBITMAP, para3: UINT, para4: UINT,
-                para5: pointer, para6: PBITMAPINFO, para7: UINT): 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",
-    importc: "SetDIBitsToDevice".}
-proc SetMapperFlags*(para1: HDC, para2: DWORD): DWORD{.stdcall, dynlib: "gdi32",
-    importc: "SetMapperFlags".}
-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,
-    dynlib: "gdi32", importc: "SetMetaFileBitsEx".}
-proc SetPaletteEntries*(para1: HPALETTE, para2: UINT, para3: UINT,
-                        para4: var PALETTEENTRY): UINT{.stdcall,
-    dynlib: "gdi32", importc: "SetPaletteEntries".}
-proc SetPixel*(para1: HDC, para2: int32, para3: int32, para4: COLORREF): COLORREF{.
-    stdcall, dynlib: "gdi32", importc: "SetPixel".}
-proc SetPixelV*(para1: HDC, para2: int32, para3: int32, para4: COLORREF): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetPixelV".}
-proc SetPolyFillMode*(para1: HDC, para2: int32): int32{.stdcall,
-    dynlib: "gdi32", importc: "SetPolyFillMode".}
-proc StretchBlt*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                 para5: int32, para6: HDC, para7: int32, para8: int32,
-                 para9: int32, para10: int32, para11: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "StretchBlt".}
-proc SetRectRgn*(para1: HRGN, para2: int32, para3: int32, para4: int32,
-                 para5: int32): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "SetRectRgn".}
-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,
-    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,
-    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",
-    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",
-    importc: "PlayMetaFileRecord".}
-proc EnumMetaFile*(para1: HDC, para2: HMETAFILE, para3: ENUMMETAFILEPROC,
-                   para4: LPARAM): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "EnumMetaFile".}
-proc CloseEnhMetaFile*(para1: HDC): HENHMETAFILE{.stdcall, dynlib: "gdi32",
-    importc: "CloseEnhMetaFile".}
-proc DeleteEnhMetaFile*(para1: HENHMETAFILE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "DeleteEnhMetaFile".}
-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,
-    dynlib: "gdi32", importc: "GetEnhMetaFileHeader".}
-proc GetEnhMetaFilePaletteEntries*(para1: HENHMETAFILE, para2: UINT,
-                                   para3: LPPALETTEENTRY): UINT{.stdcall,
-    dynlib: "gdi32", importc: "GetEnhMetaFilePaletteEntries".}
-proc GetEnhMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE): UINT{.
-    stdcall, dynlib: "gdi32", importc: "GetEnhMetaFileBits".}
-proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: UINT, para3: LPBYTE,
-                         para4: wINT, para5: HDC): UINT{.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{.
-    stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFileRecord".}
-proc SetEnhMetaFileBits*(para1: UINT, para2: var int8): HENHMETAFILE{.stdcall,
-    dynlib: "gdi32", importc: "SetEnhMetaFileBits".}
-proc SetWinMetaFileBits*(para1: UINT, 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,
-    dynlib: "gdi32", importc: "GdiComment".}
-proc AngleArc*(para1: HDC, para2: int32, para3: int32, para4: DWORD,
-               para5: float32, para6: float32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "AngleArc".}
-proc PolyPolyline*(para1: HDC, para2: var POINT, para3: var DWORD, para4: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyPolyline".}
-proc GetWorldTransform*(para1: HDC, para2: LPXFORM): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWorldTransform".}
-proc SetWorldTransform*(para1: HDC, para2: var XFORM): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "SetWorldTransform".}
-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,
-                       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{.
-    stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}
-proc SetDIBColorTable*(para1: HDC, para2: UINT, para3: UINT, para4: var RGBQUAD): UINT{.
-    stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}
-proc SetColorAdjustment*(para1: HDC, para2: var COLORADJUSTMENT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetColorAdjustment".}
-proc GetColorAdjustment*(para1: HDC, para2: LPCOLORADJUSTMENT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetColorAdjustment".}
-proc CreateHalftonePalette*(para1: HDC): HPALETTE{.stdcall, dynlib: "gdi32",
-    importc: "CreateHalftonePalette".}
-proc EndDoc*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "EndDoc".}
-proc StartPage*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
-                                    importc: "StartPage".}
-proc EndPage*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "EndPage".}
-proc AbortDoc*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "AbortDoc".}
-proc SetAbortProc*(para1: HDC, para2: TABORTPROC): int32{.stdcall,
-    dynlib: "gdi32", importc: "SetAbortProc".}
-proc ArcTo*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32,
-            para6: int32, para7: int32, para8: int32, para9: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "ArcTo".}
-proc BeginPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                      importc: "BeginPath".}
-proc CloseFigure*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                        importc: "CloseFigure".}
-proc EndPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32", importc: "EndPath".}
-proc FillPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                     importc: "FillPath".}
-proc FlattenPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                        importc: "FlattenPath".}
-proc GetPath*(para1: HDC, para2: LPPOINT, para3: LPBYTE, para4: int32): int32{.
-    stdcall, dynlib: "gdi32", importc: "GetPath".}
-proc PathToRegion*(para1: HDC): HRGN{.stdcall, dynlib: "gdi32",
-                                      importc: "PathToRegion".}
-proc PolyDraw*(para1: HDC, para2: var POINT, para3: var int8, para4: int32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyDraw".}
-proc SelectClipPath*(para1: HDC, para2: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "SelectClipPath".}
-proc SetArcDirection*(para1: HDC, para2: int32): int32{.stdcall,
-    dynlib: "gdi32", importc: "SetArcDirection".}
-proc SetMiterLimit*(para1: HDC, para2: float32, para3: ptr float32): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetMiterLimit".}
-proc StrokeAndFillPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "StrokeAndFillPath".}
-proc StrokePath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                       importc: "StrokePath".}
-proc WidenPath*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                      importc: "WidenPath".}
-proc ExtCreatePen*(para1: DWORD, para2: DWORD, para3: var LOGBRUSH,
-                   para4: DWORD, para5: var DWORD): HPEN{.stdcall,
-    dynlib: "gdi32", importc: "ExtCreatePen".}
-proc GetMiterLimit*(para1: HDC, para2: ptr float32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetMiterLimit".}
-proc GetArcDirection*(para1: HDC): int32{.stdcall, dynlib: "gdi32",
-    importc: "GetArcDirection".}
-proc MoveToEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "MoveToEx".}
-proc CreatePolygonRgn*(para1: var POINT, para2: int32, para3: int32): HRGN{.
-    stdcall, dynlib: "gdi32", importc: "CreatePolygonRgn".}
-proc DPtoLP*(para1: HDC, para2: LPPOINT, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "DPtoLP".}
-proc LPtoDP*(para1: HDC, para2: LPPOINT, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "LPtoDP".}
-proc Polygon*(para1: HDC, para2: LPPOINT, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "Polygon".}
-proc Polyline*(para1: HDC, para2: LPPOINT, para3: int32): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "Polyline".}
-proc PolyBezier*(para1: HDC, para2: LPPOINT, para3: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolyBezier".}
-proc PolyBezierTo*(para1: HDC, para2: POINT, para3: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolyBezierTo".}
-proc PolylineTo*(para1: HDC, para2: LPPOINT, para3: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolylineTo".}
-proc SetViewportExtEx*(para1: HDC, para2: int32, para3: int32, para4: LPSIZE): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetViewportExtEx".}
-proc SetViewportOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetViewportOrgEx".}
-proc SetWindowExtEx*(para1: HDC, para2: int32, para3: int32, para4: LPSIZE): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetWindowExtEx".}
-proc SetWindowOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetWindowOrgEx".}
-proc OffsetViewportOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "OffsetViewportOrgEx".}
-proc OffsetWindowOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "OffsetWindowOrgEx".}
-proc ScaleViewportExtEx*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                         para5: int32, para6: LPSIZE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "ScaleViewportExtEx".}
-proc ScaleWindowExtEx*(para1: HDC, para2: int32, para3: int32, para4: int32,
-                       para5: int32, para6: LPSIZE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "ScaleWindowExtEx".}
-proc SetBitmapDimensionEx*(para1: HBITMAP, para2: int32, para3: int32,
-                           para4: LPSIZE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "SetBitmapDimensionEx".}
-proc SetBrushOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetBrushOrgEx".}
-proc GetDCOrgEx*(para1: HDC, para2: LPPOINT): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetDCOrgEx".}
-proc FixBrushOrgEx*(para1: HDC, para2: int32, para3: int32, para4: LPPOINT): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "FixBrushOrgEx".}
-proc UnrealizeObject*(para1: HGDIOBJ): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "UnrealizeObject".}
-proc GdiFlush*(): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GdiFlush".}
-proc GdiSetBatchLimit*(para1: DWORD): DWORD{.stdcall, dynlib: "gdi32",
-    importc: "GdiSetBatchLimit".}
-proc GdiGetBatchLimit*(): DWORD{.stdcall, dynlib: "gdi32",
-                                 importc: "GdiGetBatchLimit".}
-proc SetICMMode*(para1: HDC, para2: int32): int32{.stdcall, dynlib: "gdi32",
-    importc: "SetICMMode".}
-proc CheckColorsInGamut*(para1: HDC, para2: LPVOID, para3: LPVOID, para4: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "CheckColorsInGamut".}
-proc GetColorSpace*(para1: HDC): HANDLE{.stdcall, dynlib: "gdi32",
-    importc: "GetColorSpace".}
-proc SetColorSpace*(para1: HDC, para2: HCOLORSPACE): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "SetColorSpace".}
-proc DeleteColorSpace*(para1: HCOLORSPACE): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "DeleteColorSpace".}
-proc GetDeviceGammaRamp*(para1: HDC, para2: LPVOID): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetDeviceGammaRamp".}
-proc SetDeviceGammaRamp*(para1: HDC, para2: LPVOID): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "SetDeviceGammaRamp".}
-proc ColorMatchToTarget*(para1: HDC, para2: HDC, para3: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "ColorMatchToTarget".}
-proc CreatePropertySheetPageA*(lppsp: LPCPROPSHEETPAGE): HPROPSHEETPAGE{.
-    stdcall, dynlib: "comctl32", importc: "CreatePropertySheetPageA".}
-proc DestroyPropertySheetPage*(hPSPage: HPROPSHEETPAGE): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "DestroyPropertySheetPage".}
-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,
-                       cGrow: int32): HIMAGELIST{.stdcall, dynlib: "comctl32",
-    importc: "ImageList_Create".}
-proc ImageList_Destroy*(himl: HIMAGELIST): WINBOOL{.stdcall, dynlib: "comctl32",
-    importc: "ImageList_Destroy".}
-proc ImageList_GetImageCount*(himl: HIMAGELIST): int32{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_GetImageCount".}
-proc ImageList_Add*(himl: HIMAGELIST, hbmImage: HBITMAP, hbmMask: HBITMAP): int32{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_Add".}
-proc ImageList_ReplaceIcon*(himl: HIMAGELIST, i: int32, hicon: HICON): int32{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_ReplaceIcon".}
-proc ImageList_SetBkColor*(himl: HIMAGELIST, clrBk: COLORREF): COLORREF{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_SetBkColor".}
-proc ImageList_GetBkColor*(himl: HIMAGELIST): COLORREF{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_GetBkColor".}
-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,
-    dynlib: "comctl32", importc: "ImageList_Draw".}
-proc ImageList_Replace*(himl: HIMAGELIST, i: int32, hbmImage: HBITMAP,
-                        hbmMask: HBITMAP): WINBOOL{.stdcall, dynlib: "comctl32",
-    importc: "ImageList_Replace".}
-proc ImageList_AddMasked*(himl: HIMAGELIST, hbmImage: HBITMAP, crMask: COLORREF): int32{.
-    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,
-    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{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_GetIcon".}
-proc ImageList_BeginDrag*(himlTrack: HIMAGELIST, iTrack: int32,
-                          dxHotspot: int32, dyHotspot: int32): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_BeginDrag".}
-proc ImageList_EndDrag*(){.stdcall, dynlib: "comctl32",
-                           importc: "ImageList_EndDrag".}
-proc ImageList_DragEnter*(hwndLock: HWND, x: int32, y: int32): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_DragEnter".}
-proc ImageList_DragLeave*(hwndLock: HWND): WINBOOL{.stdcall, dynlib: "comctl32",
-    importc: "ImageList_DragLeave".}
-proc ImageList_DragMove*(x: int32, y: int32): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_DragMove".}
-proc ImageList_SetDragCursorImage*(himlDrag: HIMAGELIST, iDrag: int32,
-                                   dxHotspot: int32, dyHotspot: int32): WINBOOL{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_SetDragCursorImage".}
-proc ImageList_DragShowNolock*(fShow: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_DragShowNolock".}
-proc ImageList_GetDragImage*(ppt: LPPOINT, pptHotspot: LPPOINT): HIMAGELIST{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_GetDragImage".}
-proc ImageList_GetIconSize*(himl: HIMAGELIST, cx: var int32, cy: var int32): WINBOOL{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_GetIconSize".}
-proc ImageList_SetIconSize*(himl: HIMAGELIST, cx: int32, cy: int32): WINBOOL{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_SetIconSize".}
-proc ImageList_GetImageInfo*(himl: HIMAGELIST, i: int32,
-                             pImageInfo: var IMAGEINFO): WINBOOL{.stdcall,
-    dynlib: "comctl32", importc: "ImageList_GetImageInfo".}
-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,
-    dynlib: "comctl32.dll", importc: "ImageList_SetImageCount".}
-proc CreateToolbarEx*(hwnd: HWND, ws: DWORD, wID: UINT, nBitmaps: int32,
-                      hBMInst: HINST, wBMID: UINT, lpButtons: LPCTBBUTTON,
-                      iNumButtons: int32, dxButton: int32, dyButton: int32,
-                      dxBitmap: int32, dyBitmap: int32, uStructSize: UINT): HWND{.
-    stdcall, dynlib: "comctl32", importc: "CreateToolbarEx".}
-proc CreateMappedBitmap*(hInstance: HINST, idBitmap: int32, wFlags: UINT,
-                         lpColorMap: LPCOLORMAP, iNumMaps: int32): HBITMAP{.
-    stdcall, dynlib: "comctl32", importc: "CreateMappedBitmap".}
-proc MenuHelp*(uMsg: UINT, wParam: WPARAM, lParam: LPARAM, hMainMenu: HMENU,
-               hInst: HINST, hwndStatus: HWND, lpwIDs: var UINT){.stdcall,
-    dynlib: "comctl32", importc: "MenuHelp".}
-proc ShowHideMenuCtl*(hWnd: HWND, uFlags: UINT, lpInfo: LPINT): WINBOOL{.
-    stdcall, dynlib: "comctl32", importc: "ShowHideMenuCtl".}
-proc GetEffectiveClientRect*(hWnd: HWND, lprc: LPRECT, lpInfo: LPINT){.stdcall,
-    dynlib: "comctl32", importc: "GetEffectiveClientRect".}
-proc MakeDragList*(hLB: HWND): WINBOOL{.stdcall, dynlib: "comctl32",
-                                        importc: "MakeDragList".}
-proc DrawInsert*(handParent: HWND, hLB: HWND, nItem: int32){.stdcall,
-    dynlib: "comctl32", importc: "DrawInsert".}
-proc LBItemFromPt*(hLB: HWND, pt: POINT, bAutoScroll: WINBOOL): int32{.stdcall,
-    dynlib: "comctl32", importc: "LBItemFromPt".}
-proc CreateUpDownControl*(dwStyle: DWORD, x: int32, y: int32, cx: int32,
-                          cy: int32, hParent: HWND, nID: int32, hInst: HINST,
-                          hBuddy: HWND, nUpper: int32, nLower: int32,
-                          nPos: int32): HWND{.stdcall, dynlib: "comctl32",
-    importc: "CreateUpDownControl".}
-proc RegCloseKey*(hKey: HKEY): LONG{.stdcall, dynlib: "advapi32",
-                                     importc: "RegCloseKey".}
-proc RegSetKeySecurity*(hKey: HKEY, SecurityInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetKeySecurity".}
-proc RegFlushKey*(hKey: HKEY): LONG{.stdcall, dynlib: "advapi32",
-                                     importc: "RegFlushKey".}
-proc RegGetKeySecurity*(hKey: HKEY, SecurityInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                        lpcbSecurityDescriptor: LPDWORD): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegGetKeySecurity".}
-proc RegNotifyChangeKeyValue*(hKey: HKEY, bWatchSubtree: WINBOOL,
-                              dwNotifyFilter: DWORD, hEvent: HANDLE,
-                              fAsynchronus: WINBOOL): LONG{.stdcall,
-    dynlib: "advapi32", importc: "RegNotifyChangeKeyValue".}
-proc IsValidCodePage*(CodePage: UINT): 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,
-    dynlib: "kernel32", importc: "GetCPInfo".}
-proc IsDBCSLeadByte*(TestChar: int8): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "IsDBCSLeadByte".}
-proc IsDBCSLeadByteEx*(CodePage: UINT, TestChar: int8): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsDBCSLeadByteEx".}
-proc MultiByteToWideChar*(CodePage: UINT, dwFlags: DWORD,
-                          lpMultiByteStr: LPCSTR, cchMultiByte: int32,
-                          lpWideCharStr: LPWSTR, cchWideChar: int32): int32{.
-    stdcall, dynlib: "kernel32", importc: "MultiByteToWideChar".}
-proc WideCharToMultiByte*(CodePage: UINT, dwFlags: DWORD,
-                          lpWideCharStr: LPCWSTR, cchWideChar: int32,
-                          lpMultiByteStr: LPSTR, cchMultiByte: int32,
-                          lpDefaultChar: LPCSTR, lpUsedDefaultChar: LPBOOL): int32{.
-    stdcall, dynlib: "kernel32", importc: "WideCharToMultiByte".}
-proc IsValidLocale*(Locale: LCID, dwFlags: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "IsValidLocale".}
-proc ConvertDefaultLocale*(Locale: LCID): LCID{.stdcall, dynlib: "kernel32",
-    importc: "ConvertDefaultLocale".}
-proc GetThreadLocale*(): LCID{.stdcall, dynlib: "kernel32",
-                               importc: "GetThreadLocale".}
-proc SetThreadLocale*(Locale: LCID): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "SetThreadLocale".}
-proc GetSystemDefaultLangID*(): LANGID{.stdcall, dynlib: "kernel32",
-                                        importc: "GetSystemDefaultLangID".}
-proc GetUserDefaultLangID*(): LANGID{.stdcall, dynlib: "kernel32",
-                                      importc: "GetUserDefaultLangID".}
-proc GetSystemDefaultLCID*(): LCID{.stdcall, dynlib: "kernel32",
-                                    importc: "GetSystemDefaultLCID".}
-proc GetUserDefaultLCID*(): LCID{.stdcall, dynlib: "kernel32",
-                                  importc: "GetUserDefaultLCID".}
-proc ReadConsoleOutputAttribute*(hConsoleOutput: HANDLE, lpAttribute: LPWORD,
-                                 nLength: DWORD, dwReadCoord: COORD,
-                                 lpNumberOfAttrsRead: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputAttribute".}
-proc WriteConsoleOutputAttribute*(hConsoleOutput: HANDLE,
-                                  lpAttribute: var int16, nLength: DWORD,
-                                  dwWriteCoord: COORD,
-                                  lpNumberOfAttrsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputAttribute".}
-proc FillConsoleOutputAttribute*(hConsoleOutput: HANDLE, wAttribute: int16,
-                                 nLength: DWORD, dwWriteCoord: COORD,
-                                 lpNumberOfAttrsWritten: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputAttribute".}
-proc GetConsoleMode*(hConsoleHandle: HANDLE, lpMode: LPDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetConsoleMode".}
-proc GetNumberOfConsoleInputEvents*(hConsoleInput: HANDLE,
-                                    lpNumberOfEvents: PDWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetNumberOfConsoleInputEvents".}
-proc GetConsoleScreenBufferInfo*(hConsoleOutput: HANDLE,
-    lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".}
-proc GetLargestConsoleWindowSize*(hConsoleOutput: HANDLE): COORD
-proc GetConsoleCursorInfo*(hConsoleOutput: HANDLE,
-                           lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetConsoleCursorInfo".}
-proc GetNumberOfConsoleMouseButtons*(lpNumberOfMouseButtons: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetNumberOfConsoleMouseButtons".}
-proc SetConsoleMode*(hConsoleHandle: HANDLE, dwMode: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleMode".}
-proc SetConsoleActiveScreenBuffer*(hConsoleOutput: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleActiveScreenBuffer".}
-proc FlushConsoleInputBuffer*(hConsoleInput: HANDLE): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FlushConsoleInputBuffer".}
-proc SetConsoleScreenBufferSize*(hConsoleOutput: HANDLE, dwSize: COORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetConsoleScreenBufferSize".}
-proc SetConsoleCursorPosition*(hConsoleOutput: HANDLE, dwCursorPosition: COORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetConsoleCursorPosition".}
-proc SetConsoleCursorInfo*(hConsoleOutput: HANDLE,
-                           lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetConsoleCursorInfo".}
-proc SetConsoleWindowInfo*(hConsoleOutput: HANDLE, bAbsolute: WINBOOL,
-                           lpConsoleWindow: var SMALL_RECT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleWindowInfo".}
-proc SetConsoleTextAttribute*(hConsoleOutput: HANDLE, wAttributes: int16): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetConsoleTextAttribute".}
-proc SetConsoleCtrlHandler*(HandlerRoutine: PHANDLER_ROUTINE, Add: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetConsoleCtrlHandler".}
-proc GenerateConsoleCtrlEvent*(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GenerateConsoleCtrlEvent".}
-proc AllocConsole*(): WINBOOL{.stdcall, dynlib: "kernel32",
-                               importc: "AllocConsole".}
-proc FreeConsole*(): WINBOOL{.stdcall, dynlib: "kernel32",
-                              importc: "FreeConsole".}
-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",
-    importc: "SetConsoleCP".}
-proc GetConsoleOutputCP*(): UINT{.stdcall, dynlib: "kernel32",
-                                  importc: "GetConsoleOutputCP".}
-proc SetConsoleOutputCP*(wCodePageID: UINT): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetConsoleOutputCP".}
-proc WNetConnectionDialog*(hwnd: HWND, dwType: DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetConnectionDialog".}
-proc WNetDisconnectDialog*(hwnd: HWND, dwType: DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetDisconnectDialog".}
-proc WNetCloseEnum*(hEnum: HANDLE): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetCloseEnum".}
-proc CloseServiceHandle*(hSCObject: SC_HANDLE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "CloseServiceHandle".}
-proc ControlService*(hService: SC_HANDLE, dwControl: DWORD,
-                     lpServiceStatus: LPSERVICE_STATUS): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ControlService".}
-proc DeleteService*(hService: SC_HANDLE): WINBOOL{.stdcall, dynlib: "advapi32",
-    importc: "DeleteService".}
-proc LockServiceDatabase*(hSCManager: SC_HANDLE): SC_LOCK{.stdcall,
-    dynlib: "advapi32", importc: "LockServiceDatabase".}
-proc NotifyBootConfigStatus*(BootAcceptable: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "NotifyBootConfigStatus".}
-proc QueryServiceObjectSecurity*(hService: SC_HANDLE,
-                                 dwSecurityInformation: SECURITY_INFORMATION,
-                                 lpSecurityDescriptor: PSECURITY_DESCRIPTOR,
-                                 cbBufSize: DWORD, pcbBytesNeeded: LPDWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceObjectSecurity".}
-proc QueryServiceStatus*(hService: SC_HANDLE, lpServiceStatus: LPSERVICE_STATUS): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "QueryServiceStatus".}
-proc SetServiceObjectSecurity*(hService: SC_HANDLE,
-                               dwSecurityInformation: SECURITY_INFORMATION,
-                               lpSecurityDescriptor: PSECURITY_DESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "SetServiceObjectSecurity".}
-proc SetServiceStatus*(hServiceStatus: SERVICE_STATUS_HANDLE,
-                       lpServiceStatus: LPSERVICE_STATUS): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetServiceStatus".}
-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,
-                          para4: LPPIXELFORMATDESCRIPTOR): int32{.stdcall,
-    dynlib: "gdi32", importc: "DescribePixelFormat".}
-proc SetPixelFormat*(para1: HDC, para2: int32, para3: PPIXELFORMATDESCRIPTOR): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "SetPixelFormat".}
-proc SwapBuffers*(para1: HDC): WINBOOL{.stdcall, dynlib: "gdi32",
-                                        importc: "SwapBuffers".}
-proc DragQueryPoint*(para1: HDROP, para2: LPPOINT): WINBOOL{.stdcall,
-    dynlib: "shell32", importc: "DragQueryPoint".}
-proc DragFinish*(para1: HDROP){.stdcall, dynlib: "shell32",
-                                importc: "DragFinish".}
-proc DragAcceptFiles*(para1: HWND, para2: WINBOOL){.stdcall, dynlib: "shell32",
-    importc: "DragAcceptFiles".}
-proc DuplicateIcon*(para1: HINST, para2: HICON): HICON{.stdcall,
-    dynlib: "shell32", importc: "DuplicateIcon".}
-proc DdeAbandonTransaction*(para1: DWORD, para2: HCONV, para3: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "DdeAbandonTransaction".}
-proc DdeAccessData*(para1: HDDEDATA, para2: PDWORD): PBYTE{.stdcall,
-    dynlib: "user32", importc: "DdeAccessData".}
-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{.
-    stdcall, dynlib: "user32", importc: "DdeClientTransaction".}
-proc DdeCmpStringHandles*(para1: HSZ, para2: HSZ): int32{.stdcall,
-    dynlib: "user32", importc: "DdeCmpStringHandles".}
-proc DdeConnect*(para1: DWORD, para2: HSZ, para3: HSZ, para4: var CONVCONTEXT): HCONV{.
-    stdcall, dynlib: "user32", importc: "DdeConnect".}
-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{.
-    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{.
-    stdcall, dynlib: "user32", importc: "DdeEnableCallback".}
-proc DdeFreeDataHandle*(para1: HDDEDATA): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "DdeFreeDataHandle".}
-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",
-    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{.
-    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{.
-    stdcall, dynlib: "user32", importc: "DdeQueryConvInfo".}
-proc DdeQueryNextServer*(para1: HCONVLIST, para2: HCONV): HCONV{.stdcall,
-    dynlib: "user32", importc: "DdeQueryNextServer".}
-proc DdeReconnect*(para1: HCONV): HCONV{.stdcall, dynlib: "user32",
-    importc: "DdeReconnect".}
-proc DdeSetUserHandle*(para1: HCONV, para2: DWORD, para3: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "DdeSetUserHandle".}
-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,
-    dynlib: "shell32", importc: "SHAddToRecentDocs".}
-proc SHBrowseForFolder*(para1: LPBROWSEINFO): LPITEMIDLIST{.stdcall,
-    dynlib: "shell32", importc: "SHBrowseForFolder".}
-proc SHChangeNotify*(para1: LONG, para2: UINT, 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,
-    dynlib: "shell32", importc: "SHGetFileInfo".}
-proc SHGetPathFromIDList*(para1: LPCITEMIDLIST, para2: LPTSTR): WINBOOL{.
-    stdcall, dynlib: "shell32", importc: "SHGetPathFromIDList".}
-proc SHGetSpecialFolderLocation*(para1: HWND, para2: int32,
-                                 para3: var LPITEMIDLIST): HRESULT{.stdcall,
-    dynlib: "shell32", importc: "SHGetSpecialFolderLocation".}
-  # was missing, bug report 1808 PM
-proc CommDlgExtendedError*(): DWORD{.stdcall, dynlib: "comdlg32",
-                                     importc: "CommDlgExtendedError".}
-  # wgl Windows OpenGL helper functions
-proc wglUseFontBitmaps*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD): WINBOOL{.
-    stdcall, dynlib: "opengl32", importc: "wglUseFontBitmapsA".}
-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,
-    dynlib: "opengl32", importc: "wglCopyContext".}
-proc wglDeleteContext*(para1: HGLRC): WINBOOL{.stdcall, dynlib: "opengl32",
-    importc: "wglDeleteContext".}
-proc wglGetCurrentContext*(): HGLRC{.stdcall, dynlib: "opengl32",
-                                     importc: "wglGetCurrentContext".}
-proc wglGetCurrentDC*(): HDC{.stdcall, dynlib: "opengl32",
-                              importc: "wglGetCurrentDC".}
-proc wglMakeCurrent*(para1: HDC, para2: HGLRC): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglMakeCurrent".}
-proc wglShareLists*(para1: HGLRC, para2: HGLRC): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglShareLists".}
-proc wglUseFontBitmapsW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD): WINBOOL{.
-    stdcall, dynlib: "opengl32", importc: "wglUseFontBitmapsW".}
-  # Delphi doesn't declare these, but we do:
-proc wglUseFontOutlines*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
-                         para5: float32, para6: float32, para7: int32,
-                         para8: LPGLYPHMETRICSFLOAT): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglUseFontOutlinesA".}
-proc wglUseFontBitmapsA*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD): WINBOOL{.
-    stdcall, dynlib: "opengl32", importc: "wglUseFontBitmapsA".}
-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,
-                            para5: LPLAYERPLANEDESCRIPTOR): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglDescribeLayerPlane".}
-proc wglGetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32,
-                                para4: int32, para5: var COLORREF): int32{.
-    stdcall, dynlib: "opengl32", importc: "wglGetLayerPaletteEntries".}
-proc wglGetProcAddress*(para1: LPCSTR): TProc{.stdcall, dynlib: "opengl32",
-    importc: "wglGetProcAddress".}
-proc wglRealizeLayerPalette*(para1: HDC, para2: int32, para3: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "opengl32", importc: "wglRealizeLayerPalette".}
-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,
-    dynlib: "opengl32", importc: "wglSwapLayerBuffers".}
-proc wglUseFontOutlinesW*(para1: HDC, para2: DWORD, para3: DWORD, para4: DWORD,
-                          para5: float32, para6: float32, para7: int32,
-                          para8: LPGLYPHMETRICSFLOAT): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglUseFontOutlinesW".}
-  # translated macros
-proc Animate_Create*(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): HWND
-proc Animate_Open*(hwnd: HWND, szName: LPTSTR): LRESULT
-proc Animate_Play*(hwnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT
-
-proc Animate_Stop*(hwnd: HWND): LRESULT
-proc Animate_Close*(hwnd: HWND): LRESULT
-proc Animate_Seek*(hwnd: HWND, frame: int32): LRESULT
-proc PropSheet_AddPage*(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE): LRESULT
-proc PropSheet_Apply*(hPropSheetDlg: HWND): LRESULT
-proc PropSheet_CancelToClose*(hPropSheetDlg: HWND): LRESULT
-proc PropSheet_Changed*(hPropSheetDlg, hwndPage: HWND): LRESULT
-proc PropSheet_GetCurrentPageHwnd*(hDlg: HWND): LRESULT
-proc PropSheet_GetTabControl*(hPropSheetDlg: HWND): LRESULT
-proc PropSheet_IsDialogMessage*(hDlg: HWND, pMsg: int32): LRESULT
-proc PropSheet_PressButton*(hPropSheetDlg: HWND, iButton: int32): LRESULT
-proc PropSheet_QuerySiblings*(hPropSheetDlg: HWND, param1, param2: int32): LRESULT
-proc PropSheet_RebootSystem*(hPropSheetDlg: HWND): LRESULT
-proc PropSheet_RemovePage*(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE,
-                           index: int32): LRESULT
-proc PropSheet_RestartWindows*(hPropSheetDlg: HWND): LRESULT
-proc PropSheet_SetCurSel*(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE,
-                          index: int32): LRESULT
-proc PropSheet_SetCurSelByID*(hPropSheetDlg: HWND, id: int32): LRESULT
-proc PropSheet_SetFinishText*(hPropSheetDlg: HWND, lpszText: LPTSTR): LRESULT
-proc PropSheet_SetTitle*(hPropSheetDlg: HWND, dwStyle: DWORD, lpszText: LPCTSTR): LRESULT
-proc PropSheet_SetWizButtons*(hPropSheetDlg: HWND, dwFlags: DWORD): LRESULT
-proc PropSheet_UnChanged*(hPropSheetDlg: HWND, hwndPage: HWND): LRESULT
-proc Header_DeleteItem*(hwndHD: HWND, index: int32): WINBOOL
-proc Header_GetItem*(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL
-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_CreateDragImage*(hwnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT
-proc ListView_DeleteAllItems*(hwnd: HWND): LRESULT
-proc ListView_DeleteColumn*(hwnd: HWND, iCol: int32): LRESULT
-proc ListView_DeleteItem*(hwnd: HWND, iItem: int32): LRESULT
-proc ListView_EditLabel*(hwndLV: HWND, i: int32): LRESULT
-proc ListView_EnsureVisible*(hwndLV: HWND, i, fPartialOK: int32): LRESULT
-proc ListView_FindItem*(hwnd: HWND, iStart: int32, lvfi: var LV_FINDINFO): int32
-proc ListView_GetBkColor*(hwnd: HWND): LRESULT
-proc ListView_GetCallbackMask*(hwnd: HWND): LRESULT
-proc ListView_GetColumn*(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT
-proc ListView_GetColumnWidth*(hwnd: HWND, iCol: int32): LRESULT
-proc ListView_GetCountPerPage*(hwndLV: HWND): LRESULT
-proc ListView_GetEditControl*(hwndLV: HWND): LRESULT
-proc ListView_GetImageList*(hwnd: HWND, iImageList: wINT): LRESULT
-proc ListView_GetISearchString*(hwndLV: HWND, lpsz: LPTSTR): LRESULT
-proc ListView_GetItem*(hwnd: HWND, item: var LV_ITEM): LRESULT
-proc ListView_GetItemCount*(hwnd: HWND): LRESULT
-proc ListView_GetItemPosition*(hwndLV: HWND, i: int32, pt: var POINT): int32
-proc ListView_GetItemSpacing*(hwndLV: HWND, fSmall: int32): LRESULT
-proc ListView_GetItemState*(hwndLV: HWND, i, mask: int32): LRESULT
-proc ListView_GetNextItem*(hwnd: HWND, iStart, flags: int32): LRESULT
-proc ListView_GetOrigin*(hwndLV: HWND, pt: var POINT): LRESULT
-proc ListView_GetSelectedCount*(hwndLV: HWND): LRESULT
-proc ListView_GetStringWidth*(hwndLV: HWND, psz: LPCTSTR): LRESULT
-proc ListView_GetTextBkColor*(hwnd: HWND): LRESULT
-proc ListView_GetTextColor*(hwnd: HWND): LRESULT
-proc ListView_GetTopIndex*(hwndLV: HWND): LRESULT
-proc ListView_GetViewRect*(hwnd: HWND, rc: var RECT): LRESULT
-proc ListView_HitTest*(hwndLV: HWND, info: var LV_HITTESTINFO): LRESULT
-proc ListView_InsertColumn*(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT
-proc ListView_InsertItem*(hwnd: 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*(hwnd: HWND, clrBk: COLORREF): LRESULT
-proc ListView_SetCallbackMask*(hwnd: HWND, mask: UINT): LRESULT
-proc ListView_SetColumn*(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT
-proc ListView_SetColumnWidth*(hwnd: HWND, iCol, cx: int32): LRESULT
-proc ListView_SetImageList*(hwnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT
-proc ListView_SetItem*(hwnd: HWND, item: var LV_ITEM): LRESULT
-proc ListView_SetItemCount*(hwndLV: HWND, cItems: int32): LRESULT
-proc ListView_SetItemPosition*(hwndLV: HWND, i, x, y: int32): LRESULT
-proc ListView_SetItemPosition32*(hwndLV: HWND, i, x, y: int32): LRESULT
-proc ListView_SetItemState*(hwndLV: HWND, i, data, mask: int32): LRESULT
-proc ListView_SetItemText*(hwndLV: HWND, i, iSubItem: int32, pszText: LPTSTR): LRESULT
-proc ListView_SetTextBkColor*(hwnd: HWND, clrTextBk: COLORREF): LRESULT
-proc ListView_SetTextColor*(hwnd: HWND, clrText: COLORREF): LRESULT
-proc ListView_SortItems*(hwndLV: HWND, pfnCompare: PFNLVCOMPARE, lPrm: LPARAM): LRESULT
-proc ListView_Update*(hwndLV: HWND, i: int32): LRESULT
-proc TreeView_InsertItem*(hwnd: HWND, lpis: LPTV_INSERTSTRUCT): LRESULT
-proc TreeView_DeleteItem*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_DeleteAllItems*(hwnd: HWND): LRESULT
-proc TreeView_Expand*(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT
-proc TreeView_GetCount*(hwnd: HWND): LRESULT
-proc TreeView_GetIndent*(hwnd: HWND): LRESULT
-proc TreeView_SetIndent*(hwnd: HWND, indent: int32): LRESULT
-proc TreeView_GetImageList*(hwnd: HWND, iImage: WPARAM): LRESULT
-proc TreeView_SetImageList*(hwnd: HWND, himl: HIMAGELIST, iImage: WPARAM): LRESULT
-proc TreeView_GetNextItem*(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT
-proc TreeView_GetChild*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetNextSibling*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetPrevSibling*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetParent*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetFirstVisible*(hwnd: HWND): LRESULT
-proc TreeView_GetNextVisible*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetPrevVisible*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetSelection*(hwnd: HWND): LRESULT
-proc TreeView_GetDropHilight*(hwnd: HWND): LRESULT
-proc TreeView_GetRoot*(hwnd: HWND): LRESULT
-proc TreeView_Select*(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT
-proc TreeView_SelectItem*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_SelectDropTarget*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_SelectSetFirstVisible*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetItem*(hwnd: HWND, item: var TV_ITEM): LRESULT
-proc TreeView_SetItem*(hwnd: HWND, item: var TV_ITEM): LRESULT
-proc TreeView_EditLabel*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_GetEditControl*(hwnd: HWND): LRESULT
-proc TreeView_GetVisibleCount*(hwnd: HWND): LRESULT
-proc TreeView_HitTest*(hwnd: HWND, lpht: LPTV_HITTESTINFO): LRESULT
-proc TreeView_CreateDragImage*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_SortChildren*(hwnd: HWND, hitem: HTREEITEM, recurse: int32): LRESULT
-proc TreeView_EnsureVisible*(hwnd: HWND, hitem: HTREEITEM): LRESULT
-proc TreeView_SortChildrenCB*(hwnd: HWND, psort: LPTV_SORTCB, recurse: int32): LRESULT
-proc TreeView_EndEditLabelNow*(hwnd: HWND, fCancel: int32): LRESULT
-proc TreeView_GetISearchString*(hwndTV: HWND, lpsz: LPTSTR): LRESULT
-proc TabCtrl_GetImageList*(hwnd: HWND): LRESULT
-proc TabCtrl_SetImageList*(hwnd: HWND, himl: HIMAGELIST): LRESULT
-proc TabCtrl_GetItemCount*(hwnd: HWND): LRESULT
-proc TabCtrl_GetItem*(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT
-proc TabCtrl_SetItem*(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT
-proc TabCtrl_InsertItem*(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT
-proc TabCtrl_DeleteItem*(hwnd: HWND, i: int32): LRESULT
-proc TabCtrl_DeleteAllItems*(hwnd: HWND): LRESULT
-proc TabCtrl_GetItemRect*(hwnd: HWND, i: int32, rc: var RECT): LRESULT
-proc TabCtrl_GetCurSel*(hwnd: HWND): LRESULT
-proc TabCtrl_SetCurSel*(hwnd: HWND, i: int32): LRESULT
-proc TabCtrl_HitTest*(hwndTC: HWND, info: var TC_HITTESTINFO): LRESULT
-proc TabCtrl_SetItemExtra*(hwndTC: HWND, cb: int32): LRESULT
-proc TabCtrl_AdjustRect*(hwnd: HWND, bLarger: WINBOOL, rc: var RECT): LRESULT
-proc TabCtrl_SetItemSize*(hwnd: HWND, x, y: int32): LRESULT
-proc TabCtrl_RemoveImage*(hwnd: HWND, i: WPARAM): LRESULT
-proc TabCtrl_SetPadding*(hwnd: HWND, cx, cy: int32): LRESULT
-proc TabCtrl_GetRowCount*(hwnd: HWND): LRESULT
-proc TabCtrl_GetToolTips*(hwnd: HWND): LRESULT
-proc TabCtrl_SetToolTips*(hwnd: HWND, hwndTT: int32): LRESULT
-proc TabCtrl_GetCurFocus*(hwnd: HWND): LRESULT
-proc TabCtrl_SetCurFocus*(hwnd: HWND, i: int32): LRESULT
-proc SNDMSG*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: 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 not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetSpec*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT
-else:
-  proc CommDlg_OpenSave_GetSpec*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT
-proc CommDlg_OpenSave_GetFilePathA*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT
-proc CommDlg_OpenSave_GetFilePathW*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT
-when not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetFilePath*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT
-else:
-  proc CommDlg_OpenSave_GetFilePath*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT
-proc CommDlg_OpenSave_GetFolderPathA*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT
-proc CommDlg_OpenSave_GetFolderPathW*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT
-when not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetFolderPath*(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT
-else:
-  proc CommDlg_OpenSave_GetFolderPath*(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT
-proc CommDlg_OpenSave_GetFolderIDList*(hdlg: HWND, pidl: LPVOID, cbmax: int32): LRESULT
-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*(hWnd: HWND, uCmd: UINT): HWND{.stdcall, dynlib: "user32",
-    importc: "GetWindow".}
-proc GlobalAllocPtr*(flags, cb: DWord): Pointer
-proc GlobalFreePtr*(lp: Pointer): Pointer
-proc GlobalUnlockPtr*(lp: pointer): Pointer
-proc GlobalLockPtr*(lp: pointer): Pointer
-proc GlobalReAllocPtr*(lp: Pointer, cbNew, flags: DWord): Pointer
-proc GlobalPtrHandle*(lp: pointer): Pointer
-proc SetLayeredWindowAttributes*(HWND: hwnd, crKey: COLORREF, bAlpha: int8,
-                                 dwFlags: DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetLayeredWindowAttributes".}
-type
-  PIID* = PGUID
-  TIID* = TGUID
-  TFNDlgProc* = FARPROC
-  TFNThreadStartRoutine* = FARPROC
-  TFNTimerAPCRoutine* = FARPROC
-  TFNFiberStartRoutine* = FARPROC
-  TFNHookProc* = HOOKPROC
-  PObjectTypeList* = ptr TObjectTypeList
-  OBJECT_TYPE_LIST* {.final, pure.} = object
-    Level*: int16
-    Sbz*: int16
-    ObjectType*: PGUID
-
-  TObjectTypeList* = OBJECT_TYPE_LIST
-  AUDIT_EVENT_TYPE* = DWORD
-  PBlendFunction* = ptr TBlendFunction
-  BLENDFUNCTION* {.final, pure.} = object
-    BlendOp*: int8
-    BlendFlags*: int8
-    SourceConstantAlpha*: int8
-    AlphaFormat*: int8
-
-  TBlendFunction* = BLENDFUNCTION
-  WIN_CERTIFICATE* {.final, pure.} = object
-    dwLength*: DWord
-    wRevision*: int16
-    wCertificateType*: int16
-    bCertificate*: array[0..0, int8]
-
-  TWinCertificate* = WIN_CERTIFICATE
-  PWinCertificate* = ptr TWinCertificate
-  TMaxLogPalette* {.final, pure.} = object
-    palVersion*: int16
-    palNumEntries*: int16
-    palPalEntry*: array[int8, TPaletteEntry]
-
-  PMaxLogPalette* = ptr TMaxLogPalette
-  POSVersionInfoA* = POSVERSIONINFO
-  TBitmapFileHeader* = BITMAPFILEHEADER
-  PBitmapFileHeader* = ptr TBitmapFileHeader
-
-const                         # dll names
-  advapi32* = "advapi32.dll"
-  kernel32* = "kernel32.dll"
-  mpr* = "mpr.dll"
-  version* = "version.dll"
-  comctl32* = "comctl32.dll"
-  gdi32* = "gdi32.dll"
-  opengl32* = "opengl32.dll"
-  user32* = "user32.dll"
-  wintrust* = "wintrust.dll"  # Openfile Share modes normally declared in sysutils
-  fmShareCompat* = 0x00000000
-  fmShareExclusive* = 0x00000010
-  fmShareDenyWrite* = 0x00000020
-  fmShareDenyRead* = 0x00000030
-  fmShareDenyNone* = 0x00000040 # HRESULT codes, delphilike
-  SIF_TRACKPOS* = 0x00000010
-  HTBORDER* = 18
-  CP_UTF7* = 65000
-  CP_UTF8* = 65001
-  CREATE_NO_WINDOW* = 0x08000000
-  VK_ATTN* = 246
-  VK_CRSEL* = 247
-  VK_EXSEL* = 248
-  VK_EREOF* = 249
-  VK_PLAY* = 250
-  VK_ZOOM* = 251
-  VK_NONAME* = 252
-  VK_PA1* = 253
-  VK_OEM_CLEAR* = 254
-
-const                         # Severity values
-  FACILITY_NT_BIT* = 0x10000000
-  HFILE_ERROR* = HFILE(- 1) #
-                            #  A language ID is a 16 bit value which is the combination of a
-                            #  primary language ID and a secondary language ID.  The bits are
-                            #  allocated as follows:
-                            #
-                            #       +-----------------------+-------------------------+
-                            #       |     Sublanguage ID    |   Primary Language ID   |
-                            #       +-----------------------+-------------------------+
-                            #        15                   10 9                       0   bit
-                            #
-                            #
-                            #  Language ID creation/extraction macros:
-                            #
-                            #    MAKELANGID    - construct language id from a primary language id and
-                            #                    a sublanguage id.
-                            #    PRIMARYLANGID - extract primary language id from a language id.
-                            #    SUBLANGID     - extract sublanguage id from a language id.
-                            #
-
-proc MAKELANGID*(PrimaryLang, SubLang: USHORT): int16
-proc PRIMARYLANGID*(LangId: int16): int16
-proc SUBLANGID*(LangId: int16): int16
-  #
-  #  A locale ID is a 32 bit value which is the combination of a
-  #  language ID, a sort ID, and a reserved area.  The bits are
-  #  allocated as follows:
-  #
-  #       +-------------+---------+-------------------------+
-  #       |   Reserved  | Sort ID |      Language ID        |
-  #       +-------------+---------+-------------------------+
-  #        31         20 19     16 15                      0   bit
-  #
-  #
-  #  Locale ID creation/extraction macros:
-  #
-  #    MAKELCID            - construct the locale id from a language id and a sort id.
-  #    MAKESORTLCID        - construct the locale id from a language id, sort id, and sort version.
-  #    LANGIDFROMLCID      - extract the language id from a locale id.
-  #    SORTIDFROMLCID      - extract the sort id from a locale id.
-  #    SORTVERSIONFROMLCID - extract the sort version from a locale id.
-  #
-const
-  NLS_VALID_LOCALE_MASK* = 0x000FFFFF
-
-proc MAKELCID*(LangId, SortId: int16): DWORD
-proc MAKESORTLCID*(LangId, SortId, SortVersion: int16): DWORD
-proc LANGIDFROMLCID*(LocaleId: LCID): int16
-proc SORTIDFROMLCID*(LocaleId: LCID): int16
-proc SORTVERSIONFROMLCID*(LocaleId: LCID): int16
-  #
-  #  Default System and User IDs for language and locale.
-  #
-proc LANG_SYSTEM_DEFAULT*(): int16
-proc LANG_USER_DEFAULT*(): int16
-proc LOCALE_NEUTRAL*(): DWORD
-proc LOCALE_INVARIANT*(): DWORD
-proc Succeeded*(Status: HRESULT): WINBOOL
-proc Failed*(Status: HRESULT): WINBOOL
-proc IsError*(Status: HRESULT): WINBOOL
-proc HResultCode*(hr: HRESULT): int32
-proc HResultFacility*(hr: HRESULT): int32
-proc HResultSeverity*(hr: HRESULT): int32
-proc MakeResult*(p1, p2, mask: int32): HRESULT
-proc HResultFromWin32*(x: int32): HRESULT
-proc HResultFromNT*(x: int32): HRESULT
-proc InitializeCriticalSection*(CriticalSection: var TRTLCriticalSection){.
-    stdcall, dynlib: "kernel32", importc: "InitializeCriticalSection".}
-proc EnterCriticalSection*(CriticalSection: var TRTLCriticalSection){.stdcall,
-    dynlib: "kernel32", importc: "EnterCriticalSection".}
-proc LeaveCriticalSection*(CriticalSection: var TRTLCriticalSection){.stdcall,
-    dynlib: "kernel32", importc: "LeaveCriticalSection".}
-proc DeleteCriticalSection*(CriticalSection: var TRTLCriticalSection){.stdcall,
-    dynlib: "kernel32", importc: "DeleteCriticalSection".}
-proc InitializeCriticalSectionAndSpinCount*(
-    CriticalSection: var TRTLCriticalSection, dwSpinCount: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32",
-    importc: "InitializeCriticalSectionAndSpinCount".}
-proc SetCriticalSectionSpinCount*(CriticalSection: var TRTLCriticalSection,
-                                  dwSpinCount: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SetCriticalSectionSpinCount".}
-proc TryEnterCriticalSection*(CriticalSection: var TRTLCriticalSection): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "TryEnterCriticalSection".}
-proc ControlService*(hService: SC_HANDLE, dwControl: DWORD,
-                     ServiceStatus: var TSERVICESTATUS): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ControlService".}
-proc QueryServiceStatus*(hService: SC_HANDLE,
-                         lpServiceStatus: var TSERVICESTATUS): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "QueryServiceStatus".}
-proc SetServiceStatus*(hServiceStatus: SERVICE_STATUS_HANDLE,
-                       ServiceStatus: TSERVICESTATUS): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "SetServiceStatus".}
-proc AdjustTokenPrivileges*(TokenHandle: THandle, DisableAllPrivileges: WINBOOL,
-                            NewState: TTokenPrivileges, BufferLength: DWORD,
-                            PreviousState: var TTokenPrivileges,
-                            ReturnLength: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AdjustTokenPrivileges".}
-proc AdjustWindowRect*(lpRect: var TRect, dwStyle: DWORD, bMenu: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "AdjustWindowRect".}
-proc AdjustWindowRectEx*(lpRect: var TRect, dwStyle: DWORD, bMenu: WINBOOL,
-                         dwExStyle: DWORD): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "AdjustWindowRectEx".}
-proc AllocateAndInitializeSid*(pIdentifierAuthority: TSIDIdentifierAuthority,
-                               nSubAuthorityCount: int8,
-                               nSubAuthority0, nSubAuthority1: DWORD,
-    nSubAuthority2, nSubAuthority3, nSubAuthority4: DWORD, nSubAuthority5,
-    nSubAuthority6, nSubAuthority7: DWORD, pSid: var Pointer): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AllocateAndInitializeSid".}
-proc AllocateLocallyUniqueId*(Luid: var TLargeInteger): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "AllocateLocallyUniqueId".}
-proc BackupRead*(hFile: THandle, lpBuffer: PByte, nNumberOfBytesToRead: DWORD,
-                 lpNumberOfBytesRead: var DWORD, bAbort: WINBOOL,
-                 bProcessSecurity: WINBOOL, lpContext: var Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BackupRead".}
-proc BackupSeek*(hFile: THandle, dwLowBytesToSeek, dwHighBytesToSeek: DWORD,
-                 lpdwLowByteSeeked, lpdwHighByteSeeked: var DWORD,
-                 lpContext: Pointer): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "BackupSeek".}
-proc BackupWrite*(hFile: THandle, lpBuffer: PByte, nNumberOfBytesToWrite: DWORD,
-                  lpNumberOfBytesWritten: var DWORD,
-                  bAbort, bProcessSecurity: WINBOOL, lpContext: var Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BackupWrite".}
-proc BeginPaint*(hWnd: HWND, lpPaint: var TPaintStruct): HDC{.stdcall,
-    dynlib: "user32", importc: "BeginPaint".}
-proc BuildCommDCB*(lpDef: cstring, lpDCB: var TDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "BuildCommDCBA".}
-proc BuildCommDCBA*(lpDef: LPCSTR, lpDCB: var TDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "BuildCommDCBA".}
-proc BuildCommDCBAndTimeouts*(lpDef: cstring, lpDCB: var TDCB,
-                              lpCommTimeouts: var TCommTimeouts): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".}
-proc BuildCommDCBAndTimeoutsA*(lpDef: LPCSTR, lpDCB: var TDCB,
-                               lpCommTimeouts: var TCommTimeouts): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".}
-proc BuildCommDCBAndTimeoutsW*(lpDef: LPWSTR, lpDCB: var TDCB,
-                               lpCommTimeouts: var TCommTimeouts): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsW".}
-proc BuildCommDCBW*(lpDef: LPWSTR, lpDCB: var TDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "BuildCommDCBW".}
-proc CallMsgFilter*(lpMsg: var TMsg, nCode: int): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CallMsgFilterA".}
-proc CallMsgFilterA*(lpMsg: var TMsg, nCode: int): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CallMsgFilterA".}
-proc CallMsgFilterW*(lpMsg: var TMsg, nCode: int): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CallMsgFilterW".}
-proc CallNamedPipe*(lpNamedPipeName: cstring, lpInBuffer: Pointer,
-                    nInBufferSize: DWORD, lpOutBuffer: Pointer,
-                    nOutBufferSize: DWORD, lpBytesRead: var DWORD,
-                    nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CallNamedPipeA".}
-proc CallNamedPipeA*(lpNamedPipeName: LPCSTR, lpInBuffer: Pointer,
-                     nInBufferSize: DWORD, lpOutBuffer: Pointer,
-                     nOutBufferSize: DWORD, lpBytesRead: var DWORD,
-                     nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CallNamedPipeA".}
-proc CallNamedPipeW*(lpNamedPipeName: LPWSTR, lpInBuffer: Pointer,
-                     nInBufferSize: DWORD, lpOutBuffer: Pointer,
-                     nOutBufferSize: DWORD, lpBytesRead: var DWORD,
-                     nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "CallNamedPipeW".}
-proc CoRegisterClassObject*(para1: TCLSID, para2: pointer, para3: DWORD,
-                            para4: DWORD, out_para5: DWORD): HRESULT{.stdcall,
-    dynlib: "ole32.dll", importc: "CoRegisterClassObject".}
-proc ChangeDisplaySettings*(lpDevMode: var TDeviceMode, dwFlags: DWORD): int32{.
-    stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}
-proc ChangeDisplaySettingsA*(lpDevMode: var TDeviceModeA, dwFlags: DWORD): int32{.
-    stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".}
-proc ChangeDisplaySettingsEx*(lpszDeviceName: cstring,
-                              lpDevMode: var TDeviceMode, wnd: HWND,
-                              dwFlags: DWORD, lParam: Pointer): int32{.stdcall,
-    dynlib: "user32", importc: "ChangeDisplaySettingsExA".}
-proc ChangeDisplaySettingsExA*(lpszDeviceName: LPCSTR,
-                               lpDevMode: var TDeviceModeA, wnd: HWND,
-                               dwFlags: DWORD, lParam: Pointer): int32{.stdcall,
-    dynlib: "user32", importc: "ChangeDisplaySettingsExA".}
-proc ChangeDisplaySettingsExW*(lpszDeviceName: LPWSTR,
-                               lpDevMode: var TDeviceModeW, wnd: HWND,
-                               dwFlags: DWORD, lParam: Pointer): int32{.stdcall,
-    dynlib: "user32", importc: "ChangeDisplaySettingsExW".}
-proc ChangeDisplaySettingsW*(lpDevMode: var TDeviceModeW, dwFlags: DWORD): int32{.
-    stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".}
-  #function CheckColorsInGamut(DC: HDC; var RGBQuads, Results; Count: DWORD): WINBOOL; stdcall; external 'gdi32' name 'CheckColorsInGamut';
-proc ChoosePixelFormat*(para1: HDC, para2: var PIXELFORMATDESCRIPTOR): int32{.
-    stdcall, dynlib: "gdi32", importc: "ChoosePixelFormat".}
-proc ClearCommError*(hFile: THandle, lpErrors: var DWORD, lpStat: PComStat): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ClearCommError".}
-proc ClientToScreen*(hWnd: HWND, lpPoint: var TPoint): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ClientToScreen".}
-proc ClipCursor*(lpRect: var RECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ClipCursor".}
-  #function CombineTransform(var p1: TXForm; const p2, p3: TXForm): WINBOOL; stdcall; external 'gdi32' name 'CombineTransform';
-proc CommConfigDialog*(lpszName: cstring, hWnd: HWND, lpCC: var TCommConfig): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".}
-proc CommConfigDialogA*(lpszName: LPCSTR, hWnd: HWND, lpCC: var TCommConfig): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".}
-proc CommConfigDialogW*(lpszName: LPWSTR, hWnd: HWND, lpCC: var TCommConfig): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CommConfigDialogW".}
-  #function CompareFileTime(const lpFileTime1, lpFileTime2: TFileTime): Longint; stdcall; external 'kernel32' name 'CompareFileTime';
-  #function ConvertToAutoInheritPrivateObjectSecurity(ParentDescriptor, CurrentSecurityDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsDirectoryObject: WINBOOL; const GenericMapping: TGenericMapping): WINBOOL;
-  #  stdcall; external 'advapi32' name 'ConvertToAutoInheritPrivateObjectSecurity';
-proc CopyAcceleratorTable*(hAccelSrc: HACCEL, lpAccelDst: pointer,
-                           cAccelEntries: int): int{.stdcall, dynlib: "user32",
-    importc: "CopyAcceleratorTableA".}
-proc CopyAcceleratorTableA*(hAccelSrc: HACCEL, lpAccelDst: pointer,
-                            cAccelEntries: int): int{.stdcall, dynlib: "user32",
-    importc: "CopyAcceleratorTableA".}
-proc CopyAcceleratorTableW*(hAccelSrc: HACCEL, lpAccelDst: pointer,
-                            cAccelEntries: int): int{.stdcall, dynlib: "user32",
-    importc: "CopyAcceleratorTableW".}
-proc CopyRect*(lprcDst: var TRect, lprcSrc: TRect): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CopyRect".}
-proc CreateAcceleratorTable*(Accel: pointer, Count: int): HACCEL{.stdcall,
-    dynlib: "user32", importc: "CreateAcceleratorTableA".}
-proc CreateAcceleratorTableA*(Accel: pointer, Count: int): HACCEL{.stdcall,
-    dynlib: "user32", importc: "CreateAcceleratorTableA".}
-proc CreateAcceleratorTableW*(Accel: pointer, Count: int): HACCEL{.stdcall,
-    dynlib: "user32", importc: "CreateAcceleratorTableW".}
-  #function CreateBitmapIndirect(const p1: TBitmap): HBITMAP; stdcall; external 'gdi32' name 'CreateBitmapIndirect';
-  #function CreateBrushIndirect(const p1: TLogBrush): HBRUSH; stdcall; external 'gdi32' name 'CreateBrushIndirect';
-proc CreateColorSpace*(ColorSpace: var TLogColorSpace): HCOLORSPACE{.stdcall,
-    dynlib: "gdi32", importc: "CreateColorSpaceA".}
-proc CreateColorSpaceA*(ColorSpace: var TLogColorSpaceA): HCOLORSPACE{.stdcall,
-    dynlib: "gdi32", importc: "CreateColorSpaceA".}
-  #function CreateColorSpaceW(var ColorSpace: TLogColorSpaceW): HCOLORSPACE; stdcall; external 'gdi32' name 'CreateColorSpaceW';
-proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: TDlgTemplate,
-                                hWndParent: HWND, lpDialogFunc: TFNDlgProc,
-                                dwInitParam: LPARAM): HWND{.stdcall,
-    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 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';
-  #function CreateFontIndirectEx(const p1: PEnumLogFontExDV): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExA';
-  #function CreateFontIndirectExA(const p1: PEnumLogFontExDVA): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExA';
-  #function CreateFontIndirectExW(const p1: PEnumLogFontExDVW): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExW';
-  #function CreateFontIndirectW(const p1: TLogFontW): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectW';
-proc CreateIconIndirect*(piconinfo: var TIconInfo): HICON{.stdcall,
-    dynlib: "user32", importc: "CreateIconIndirect".}
-  #function CreatePalette(const LogPalette: TLogPalette): HPalette; stdcall; external 'gdi32' name 'CreatePalette';
-  #function CreatePenIndirect(const LogPen: TLogPen): HPEN; stdcall; external 'gdi32' name 'CreatePenIndirect';
-proc CreatePipe*(hReadPipe, hWritePipe: var THandle,
-                 lpPipeAttributes: PSecurityAttributes, nSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreatePipe".}
-proc CreatePolygonRgn*(Points: pointer, Count, FillMode: int): HRGN{.stdcall,
-    dynlib: "gdi32", importc: "CreatePolygonRgn".}
-proc CreatePolyPolygonRgn*(pPtStructs: pointer, pIntArray: pointer, p3, p4: int): HRGN{.
-    stdcall, dynlib: "gdi32", importc: "CreatePolyPolygonRgn".}
-  #function CreatePrivateObjectSecurity(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; IsDirectoryObject: WINBOOL; Token: THandle; const GenericMapping: TGenericMapping): WINBOOL;
-  #  stdcall; external 'advapi32' name 'CreatePrivateObjectSecurity';
-  #function CreatePrivateObjectSecurityEx(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsContainerObject: WINBOOL; AutoInheritFlags: ULONG; Token: THandle;
-  #  const GenericMapping: TGenericMapping): WINBOOL;stdcall; external 'advapi32' name 'CreatePrivateObjectSecurityEx';
-proc CreateProcess*(lpApplicationName: cstring, lpCommandLine: cstring,
-    lpProcessAttributes, lpThreadAttributes: PSecurityAttributes,
-                    bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                    lpEnvironment: Pointer, lpCurrentDirectory: cstring,
-                    lpStartupInfo: TStartupInfo,
-                    lpProcessInformation: var TProcessInformation): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
-proc CreateProcessA*(lpApplicationName: LPCSTR, lpCommandLine: LPCSTR,
-    lpProcessAttributes, lpThreadAttributes: PSecurityAttributes,
-                     bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                     lpEnvironment: Pointer, lpCurrentDirectory: LPCSTR,
-                     lpStartupInfo: TStartupInfo,
-                     lpProcessInformation: var TProcessInformation): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
-  #function CreateProcessAsUser(hToken: THandle; lpApplicationName: PChar; lpCommandLine: PChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD;
-  # lpEnvironment: Pointer; lpCurrentDirectory: PChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL;stdcall; external 'advapi32' name 'CreateProcessAsUserA';
-  #function CreateProcessAsUserA(hToken: THandle; lpApplicationName: LPCSTR; lpCommandLine: LPCSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD;
-  #  lpEnvironment: Pointer; lpCurrentDirectory: LPCSTR; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserA';
-  #function CreateProcessAsUserW(hToken: THandle; lpApplicationName: LPWSTR; lpCommandLine: LPWSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD;
-  #  lpEnvironment: Pointer; lpCurrentDirectory: LPWSTR; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserW';
-proc CreateProcessW*(lpApplicationName: LPWSTR, lpCommandLine: LPWSTR,
-    lpProcessAttributes, lpThreadAttributes: PSecurityAttributes,
-                     bInheritHandles: WINBOOL, dwCreationFlags: DWORD,
-                     lpEnvironment: Pointer, lpCurrentDirectory: LPWSTR,
-                     lpStartupInfo: TStartupInfo,
-                     lpProcessInformation: var TProcessInformation): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessW".}
-  #function CreateRectRgnIndirect(const p1: TRect): HRGN; stdcall; external 'gdi32' name 'CreateRectRgnIndirect';
-proc CreateRemoteThread*(hProcess: THandle, lpThreadAttributes: Pointer,
-                         dwStackSize: DWORD,
-                         lpStartAddress: TFNThreadStartRoutine,
-                         lpParameter: Pointer, dwCreationFlags: DWORD,
-                         lpThreadId: var DWORD): THandle{.stdcall,
-    dynlib: "kernel32", importc: "CreateRemoteThread".}
-proc CreateThread*(lpThreadAttributes: Pointer, dwStackSize: DWORD,
-                   lpStartAddress: TFNThreadStartRoutine, lpParameter: Pointer,
-                   dwCreationFlags: DWORD, lpThreadId: var DWORD): THandle{.
-    stdcall, dynlib: "kernel32", importc: "CreateThread".}
-proc DdeSetQualityOfService*(hWndClient: HWnd,
-                             pqosNew: TSecurityQualityOfService,
-                             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,
-                          p4: var TPixelFormatDescriptor): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "DescribePixelFormat".}
-  #function DestroyPrivateObjectSecurity(var ObjectDescriptor: PSecurityDescriptor): WINBOOL; stdcall; external 'advapi32' name 'DestroyPrivateObjectSecurity';
-proc DeviceIoControl*(hDevice: THandle, dwIoControlCode: DWORD,
-                      lpInBuffer: Pointer, nInBufferSize: DWORD,
-                      lpOutBuffer: Pointer, nOutBufferSize: DWORD,
-                      lpBytesReturned: var DWORD, lpOverlapped: POverlapped): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "DeviceIoControl".}
-proc DialogBoxIndirectParam*(hInstance: HINST, lpDialogTemplate: TDlgTemplate,
-                             hWndParent: HWND, lpDialogFunc: TFNDlgProc,
-                             dwInitParam: LPARAM): int{.stdcall,
-    dynlib: "user32", importc: "DialogBoxIndirectParamA".}
-proc DialogBoxIndirectParamA*(hInstance: HINST, lpDialogTemplate: TDlgTemplate,
-                              hWndParent: HWND, lpDialogFunc: TFNDlgProc,
-                              dwInitParam: LPARAM): int{.stdcall,
-    dynlib: "user32", importc: "DialogBoxIndirectParamA".}
-proc DialogBoxIndirectParamW*(hInstance: HINST, lpDialogTemplate: TDlgTemplate,
-                              hWndParent: HWND, lpDialogFunc: TFNDlgProc,
-                              dwInitParam: LPARAM): int{.stdcall,
-    dynlib: "user32", importc: "DialogBoxIndirectParamW".}
-proc DispatchMessage*(lpMsg: TMsg): int32{.stdcall, dynlib: "user32",
-    importc: "DispatchMessageA".}
-proc DispatchMessageA*(lpMsg: TMsg): int32{.stdcall, dynlib: "user32",
-    importc: "DispatchMessageA".}
-proc DispatchMessageW*(lpMsg: TMsg): int32{.stdcall, dynlib: "user32",
-    importc: "DispatchMessageW".}
-proc DosDateTimeToFileTime*(wFatDate, wFatTime: int16, lpFileTime: var TFileTime): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "DosDateTimeToFileTime".}
-proc DPtoLP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "DPtoLP".}
-  # function DrawAnimatedRects(hwnd: 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{.
-    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{.
-    stdcall, dynlib: "user32", importc: "DrawFrameControl".}
-proc DrawText*(hDC: HDC, lpString: cstring, nCount: int, lpRect: var TRect,
-               uFormat: UINT): int{.stdcall, dynlib: "user32",
-                                    importc: "DrawTextA".}
-proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int, lpRect: var TRect,
-                uFormat: UINT): int{.stdcall, dynlib: "user32",
-                                     importc: "DrawTextA".}
-proc DrawTextEx*(DC: HDC, lpchText: cstring, cchText: int, p4: var TRect,
-                 dwDTFormat: UINT, 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,
-    dynlib: "user32", importc: "DrawTextExA".}
-proc DrawTextExW*(DC: HDC, lpchText: LPWSTR, cchText: int, p4: var TRect,
-                  dwDTFormat: UINT, 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",
-                                     importc: "DrawTextW".}
-  #function DuplicateTokenEx(hExistingToken: THandle; dwDesiredAccess: DWORD; lpTokenAttributes: PSecurityAttributes; ImpersonationLevel: TSecurityImpersonationLevel; TokenType: TTokenType; var phNewToken: THandle): WINBOOL;
-  #  stdcall; external 'advapi32' name 'DuplicateTokenEx';
-proc EndPaint*(hWnd: HWND, lpPaint: TPaintStruct): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EndPaint".}
-  #function EnumDisplayDevices(Unused: Pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDevice; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesA';
-  #function EnumDisplayDevicesA(Unused: Pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDeviceA; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesA';
-  #function EnumDisplayDevicesW(Unused: Pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDeviceW; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesW';
-proc EnumDisplaySettings*(lpszDeviceName: cstring, iModeNum: DWORD,
-                          lpDevMode: var TDeviceMode): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EnumDisplaySettingsA".}
-proc EnumDisplaySettingsA*(lpszDeviceName: LPCSTR, iModeNum: DWORD,
-                           lpDevMode: var TDeviceModeA): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EnumDisplaySettingsA".}
-proc EnumDisplaySettingsW*(lpszDeviceName: LPWSTR, iModeNum: DWORD,
-                           lpDevMode: var TDeviceModeW): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "EnumDisplaySettingsW".}
-  #function EnumEnhMetaFile(DC: HDC; p2: HENHMETAFILE; p3: TFNEnhMFEnumProc; p4: Pointer; const p5: TRect): WINBOOL; stdcall; external 'gdi32' name 'EnumEnhMetaFile';
-  #function EnumFontFamiliesEx(DC: HDC; var p2: TLogFont; p3: TFNFontEnumProc; p4: LPARAM; p5: DWORD): WINBOOL;stdcall; external 'gdi32' name 'EnumFontFamiliesExA';
-  #function EnumFontFamiliesExA(DC: HDC; var p2: TLogFontA; p3: TFNFontEnumProcA; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExA';
-  #function EnumFontFamiliesExW(DC: HDC; var p2: TLogFontW; p3: TFNFontEnumProcW; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExW';
-  #function EqualRect(const lprc1, lprc2: TRect): WINBOOL; stdcall; external 'user32' name 'EqualRect';
-proc ExtCreatePen*(PenStyle, Width: DWORD, Brush: TLogBrush, StyleCount: DWORD,
-                   Style: Pointer): HPEN{.stdcall, dynlib: "gdi32",
-    importc: "ExtCreatePen".}
-proc ExtCreateRegion*(p1: PXForm, p2: DWORD, p3: TRgnData): HRGN{.stdcall,
-    dynlib: "gdi32", importc: "ExtCreateRegion".}
-  # function ExtEscape(DC: HDC; p2, p3: Integer; const p4: LPCSTR; p5: Integer; p6: LPSTR): Integer; stdcall; external 'gdi32' name 'ExtEscape';
-proc FileTimeToDosDateTime*(lpFileTime: TFileTime,
-                            lpFatDate, lpFatTime: var int16): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FileTimeToDosDateTime".}
-proc FileTimeToLocalFileTime*(lpFileTime: TFileTime,
-                              lpLocalFileTime: var TFileTime): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "FileTimeToLocalFileTime".}
-proc FileTimeToSystemTime*(lpFileTime: TFileTime, lpSystemTime: var TSystemTime): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FileTimeToSystemTime".}
-proc FillConsoleOutputAttribute*(hConsoleOutput: THandle, wAttribute: int16,
-                                 nLength: DWORD, dwWriteCoord: TCoord,
-                                 lpNumberOfAttrsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputAttribute".}
-proc FillConsoleOutputCharacter*(hConsoleOutput: THandle, cCharacter: Char,
-                                 nLength: DWORD, dwWriteCoord: TCoord,
-                                 lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".}
-proc FillConsoleOutputCharacterA*(hConsoleOutput: THandle, cCharacter: char,
-                                  nLength: DWORD, dwWriteCoord: TCoord,
-                                  lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".}
-proc FillConsoleOutputCharacterW*(hConsoleOutput: THandle, cCharacter: WideChar,
-                                  nLength: DWORD, dwWriteCoord: TCoord,
-                                  lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterW".}
-  #function FillRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FillRect';
-proc FindFirstFile*(lpFileName: cstring, lpFindFileData: var TWIN32FindData): THandle{.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
-proc FindFirstFileA*(lpFileName: LPCSTR, lpFindFileData: var TWIN32FindDataA): THandle{.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
-proc FindFirstFileW*(lpFileName: LPWSTR, lpFindFileData: var TWIN32FindDataW): THandle{.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileW".}
-  #function FindFirstFreeAce(var pAcl: TACL; var pAce: Pointer): WINBOOL; stdcall; external 'advapi32' name 'FindFirstFreeAce';
-proc FindNextFile*(hFindFile: THandle, lpFindFileData: var TWIN32FindData): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
-proc FindNextFileA*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataA): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
-proc FindNextFileW*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataW): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileW".}
-  #function FlushInstructionCache(hProcess: THandle; const lpBaseAddress: Pointer; dwSize: DWORD): WINBOOL; stdcall; external 'kernel32' name 'FlushInstructionCache';
-  #function FlushViewOfFile(const lpBaseAddress: Pointer; dwNumberOfBytesToFlush: DWORD): WINBOOL; stdcall; external 'kernel32' name 'FlushViewOfFile';
-  #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(hwnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';
-  #function GetAltTabInfoA(hwnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: UINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA';
-  #function GetAltTabInfoW(hwnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: UINT): 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{.
-    stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".}
-proc GetBinaryTypeA*(lpApplicationName: LPCSTR, lpBinaryType: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".}
-proc GetBinaryTypeW*(lpApplicationName: LPWSTR, lpBinaryType: var DWORD): WINBOOL{.
-    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,
-    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{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}
-proc GetCharABCWidthsA*(DC: HDC, p2, p3: UINT, ABCStructs: pointer): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".}
-proc GetCharABCWidthsFloat*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}
-proc GetCharABCWidthsFloatA*(DC: HDC, p2, p3: UINT, ABCFloatSturcts: pointer): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsFloatA".}
-proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: UINT, 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{.
-    stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".}
-proc GetCharacterPlacement*(DC: HDC, p2: cstring, p3, p4: WINBOOL,
-                            p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,
-    dynlib: "gdi32", importc: "GetCharacterPlacementA".}
-proc GetCharacterPlacementA*(DC: HDC, p2: LPCSTR, p3, p4: WINBOOL,
-                             p5: var TGCPResults, p6: DWORD): DWORD{.stdcall,
-    dynlib: "gdi32", importc: "GetCharacterPlacementA".}
-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,
-    dynlib: "gdi32", importc: "GetCharWidthA".}
-proc GetCharWidth32*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharWidth32A".}
-proc GetCharWidth32A*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharWidth32A".}
-proc GetCharWidth32W*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharWidth32W".}
-proc GetCharWidthA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetCharWidthA".}
-proc GetCharWidthFloat*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}
-proc GetCharWidthFloatA*(DC: HDC, p2, p3: UINT, Widths: pointer): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetCharWidthFloatA".}
-proc GetCharWidthFloatW*(DC: HDC, p2, p3: UINT, 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,
-    dynlib: "gdi32", importc: "GetCharWidthW".}
-proc GetClassInfo*(hInstance: HINST, lpClassName: cstring,
-                   lpWndClass: var TWndClass): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetClassInfoA".}
-proc GetClassInfoA*(hInstance: HINST, lpClassName: LPCSTR,
-                    lpWndClass: var TWndClassA): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetClassInfoA".}
-proc GetClassInfoEx*(Instance: HINST, Classname: cstring,
-                     WndClass: var TWndClassEx): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetClassInfoExA".}
-  #function GetClassInfoExA(Instance: HINST; Classname: LPCSTR; var WndClass: TWndClassExA): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExA';
-  #function GetClassInfoExW(Instance: HINST; Classname: LPWSTR; var WndClass: TWndClassExW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExW';
-  #function GetClassInfoW(hInstance: HINST; lpClassName: LPWSTR; var lpWndClass: TWndClassW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoW';
-proc GetClientRect*(hWnd: HWND, lpRect: var TRect): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetClientRect".}
-proc GetClipBox*(DC: HDC, Rect: var TRect): int{.stdcall, dynlib: "gdi32",
-    importc: "GetClipBox".}
-proc GetClipCursor*(lpRect: var TRect): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetClipCursor".}
-proc GetColorAdjustment*(DC: HDC, p2: var TColorAdjustment): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetColorAdjustment".}
-proc GetCommConfig*(hCommDev: THandle, lpCC: var TCommConfig,
-                    lpdwSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "GetCommConfig".}
-proc GetCommMask*(hFile: THandle, lpEvtMask: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetCommMask".}
-proc GetCommModemStatus*(hFile: THandle, lpModemStat: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommModemStatus".}
-proc GetCommProperties*(hFile: THandle, lpCommProp: var TCommProp): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommProperties".}
-proc GetCommState*(hFile: THandle, lpDCB: var TDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetCommState".}
-proc GetCommTimeouts*(hFile: THandle, lpCommTimeouts: var TCommTimeouts): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetCommTimeouts".}
-proc GetComputerName*(lpBuffer: cstring, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetComputerNameA".}
-proc GetComputerNameA*(lpBuffer: LPCSTR, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetComputerNameA".}
-proc GetComputerNameW*(lpBuffer: LPWSTR, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetComputerNameW".}
-proc GetConsoleCursorInfo*(hConsoleOutput: THandle,
-                           lpConsoleCursorInfo: var TConsoleCursorInfo): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetConsoleCursorInfo".}
-proc GetConsoleMode*(hConsoleHandle: THandle, lpMode: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetConsoleMode".}
-proc GetConsoleScreenBufferInfo*(hConsoleOutput: THandle,
-    lpConsoleScreenBufferInfo: var TConsoleScreenBufferInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".}
-proc GetCPInfo*(CodePage: UINT, 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';
-  #function GetCurrentHwProfileW(var lpHwProfileInfo: THWProfileInfoW): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileW';
-proc GetCursorInfo*(pci: var TCursorInfo): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetCursorInfo".}
-proc GetCursorPos*(lpPoint: var TPoint): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "GetCursorPos".}
-proc GetDCOrgEx*(DC: HDC, Origin: var TPoint): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetDCOrgEx".}
-proc GetDefaultCommConfig*(lpszName: cstring, lpCC: var TCommConfig,
-                           lpdwSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDefaultCommConfigA".}
-proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: var TCommConfig,
-                            lpdwSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetDefaultCommConfigA".}
-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{.
-    stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".}
-proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: UINT,
-                Bits: Pointer, BitInfo: var TBitmapInfo, Usage: UINT): int{.
-    stdcall, dynlib: "gdi32", importc: "GetDIBits".}
-proc GetDiskFreeSpace*(lpRootPathName: cstring, lpSectorsPerCluster,
-    lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceA".}
-proc GetDiskFreeSpaceA*(lpRootPathName: LPCSTR, lpSectorsPerCluster,
-    lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceA".}
-proc GetDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller,
-    lpTotalNumberOfBytes: var TLargeInteger,
-                         lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".}
-proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller,
-    lpTotalNumberOfBytes: var TLargeInteger,
-                          lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".}
-proc GetDiskFreeSpaceExW*(lpDirectoryName: LPWSTR, lpFreeBytesAvailableToCaller,
-    lpTotalNumberOfBytes: var TLargeInteger,
-                          lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExW".}
-proc GetDiskFreeSpaceW*(lpRootPathName: LPWSTR, lpSectorsPerCluster,
-    lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceW".}
-proc GetDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller,
-    lpTotalNumberOfBytes: pLargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".}
-proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller,
-    lpTotalNumberOfBytes: pLargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".}
-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';
-proc GetExitCodeProcess*(hProcess: THandle, lpExitCode: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}
-proc GetExitCodeThread*(hThread: THandle, lpExitCode: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetExitCodeThread".}
-proc GetFileInformationByHandle*(hFile: THandle, lpFileInformation: var TByHandleFileInformation): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle".}
-  #function GetFileSecurity(lpFileName: PChar; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL;stdcall; external 'advapi32' name 'GetFileSecurityA';
-  #function GetFileSecurityA(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetFileSecurityA';
-  #function GetFileSecurityW(lpFileName: LPWSTR; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetFileSecurityW';
-proc GetFileVersionInfoSize*(lptstrFilename: cstring, lpdwHandle: var DWORD): DWORD{.
-    stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeA".}
-proc GetFileVersionInfoSizeA*(lptstrFilename: LPCSTR, lpdwHandle: var DWORD): DWORD{.
-    stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeA".}
-proc GetFileVersionInfoSizeW*(lptstrFilename: LPWSTR, lpdwHandle: var DWORD): DWORD{.
-    stdcall, dynlib: "version", importc: "GetFileVersionInfoSizeW".}
-  # removed because old definition was wrong !
-  # 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,
-                      p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",
-    importc: "GetGlyphOutlineA".}
-proc GetGlyphOutlineA*(DC: HDC, p2, p3: UINT, 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,
-                       p6: Pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32",
-    importc: "GetGlyphOutlineW".}
-  #function GetGUIThreadInfo(idThread: DWORD; var pgui: TGUIThreadinfo): WINBOOL;stdcall; external 'user32' name 'GetGUIThreadInfo';
-proc GetHandleInformation*(hObject: THandle, lpdwFlags: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetHandleInformation".}
-  #function GetICMProfile(DC: HDC; var Size: DWORD; Name: PChar): WINBOOL;stdcall; external 'gdi32' name 'GetICMProfileA';
-  #function GetICMProfileA(DC: HDC; var Size: DWORD; Name: LPCSTR): WINBOOL; stdcall; external 'gdi32' name 'GetICMProfileA';
-  #function GetICMProfileW(DC: HDC; var Size: DWORD; Name: LPWSTR): WINBOOL; stdcall; external 'gdi32' name 'GetICMProfileW';
-proc GetIconInfo*(hIcon: HICON, piconinfo: var TIconInfo): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetIconInfo".}
-  #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,
-    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';
-proc GetSystemTime*(lpSystemTime: var SYSTEMTIME){.stdcall, dynlib: "kernel32",
-    importc: "GetSystemTime".}
-proc GetLocalTime*(SystemTime: var SYSTEMTIME){.stdcall, dynlib: "kernel32",
-    importc: "GetLocalTime".}
-proc GetSystemInfo*(SystemInfo: var SYSTEM_INFO){.stdcall, dynlib: "kernel32",
-    importc: "GetSystemInfo".}
-proc SetSystemTime*(lpSystemTime: var SYSTEMTIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetSystemTime".}
-proc SetLocalTime*(lpSystemTime: var SYSTEMTIME): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetLocalTime".}
-proc GetLogColorSpace*(p1: HCOLORSPACE, ColorSpace: var TLogColorSpace,
-                       Size: DWORD): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetLogColorSpaceA".}
-proc GetLogColorSpaceA*(p1: HCOLORSPACE, ColorSpace: var TLogColorSpaceA,
-                        Size: DWORD): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetLogColorSpaceA".}
-  #function GetLogColorSpaceW(p1: HCOLORSPACE; var ColorSpace: TLogColorSpaceW; Size: DWORD): WINBOOL; stdcall; external 'gdi32' name 'GetLogColorSpaceW';
-proc GetMailslotInfo*(hMailslot: THandle, lpMaxMessageSize: Pointer,
-                      lpNextSize: var DWORD,
-                      lpMessageCount, lpReadTimeout: Pointer): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetMailslotInfo".}
-  #function GetMenuBarInfo(hend: HWND; idObject, idItem: Longint; var pmbi: TMenuBarInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuBarInfo';
-  #function GetMenuInfo(hMenu: HMENU; var lpmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuInfo';
-proc GetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".}
-proc GetMenuItemInfoA*(p1: HMENU, p2: UINT, 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*(hWnd: HWND, hMenu: HMENU, uItem: UINT, lprcItem: var TRect): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetMenuItemRect".}
-proc GetMessage*(lpMsg: var TMsg, hWnd: HWND, wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetMessageA".}
-proc GetMessageA*(lpMsg: var TMsg, hWnd: HWND,
-                  wMsgFilterMin, wMsgFilterMax: UINT): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetMessageA".}
-proc GetMessageW*(lpMsg: var TMsg, hWnd: HWND,
-                  wMsgFilterMin, wMsgFilterMax: UINT): 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';
-proc GetNamedPipeInfo*(hNamedPipe: THandle, lpFlags: var DWORD,
-                       lpOutBufferSize, lpInBufferSize, lpMaxInstances: Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetNamedPipeInfo".}
-proc GetNumberOfConsoleInputEvents*(hConsoleInput: THandle,
-                                    lpNumberOfEvents: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetNumberOfConsoleInputEvents".}
-proc GetNumberOfConsoleMouseButtons*(lpNumberOfMouseButtons: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetNumberOfConsoleMouseButtons".}
-  #function GetNumberOfEventLogRecords(hEventLog: THandle; var NumberOfRecords: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetNumberOfEventLogRecords';
-  #function GetOldestEventLogRecord(hEventLog: THandle; var OldestRecord: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetOldestEventLogRecord';
-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,
-    dynlib: "gdi32", importc: "GetPaletteEntries".}
-proc GetPath*(DC: HDC, Points, Types: pointer, nSize: int): int{.stdcall,
-    dynlib: "gdi32", importc: "GetPath".}
-proc GetPriorityClipboardFormat*(paFormatPriorityList: pointer, cFormats: int): int{.
-    stdcall, dynlib: "user32", importc: "GetPriorityClipboardFormat".}
-  #function GetPrivateObjectSecurity(ObjectDescriptor: PSecurityDescriptor; SecurityInformation: SECURITY_INFORMATION; ResultantDescriptor: PSecurityDescriptor; DescriptorLength: DWORD; var ReturnLength: DWORD): WINBOOL;
-  #  stdcall; external 'advapi32' name 'GetPrivateObjectSecurity';
-proc GetPrivateProfileSectionNamesA*(lpszReturnBuffer: LPSTR, nSize: DWORD,
-                                     lpFileName: LPCSTR): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetPrivateProfileSectionNamesA".}
-proc GetPrivateProfileSectionNamesW*(lpszReturnBuffer: LPWSTR, nSize: DWORD,
-                                     lpFileName: LPCWSTR): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetPrivateProfileSectionNamesW".}
-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{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}
-proc GetPrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR, lpStruct: LPVOID,
-                               uSizeStruct: UINT, szFile: LPCWSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructW".}
-proc GetPrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,
-                              uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".}
-proc GetProcessAffinityMask*(hProcess: THandle, lpProcessAffinityMask,
-    lpSystemAffinityMask: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "GetProcessAffinityMask".}
-proc GetProcessHeaps*(NumberOfHeaps: DWORD, ProcessHeaps: var THandle): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessHeaps".}
-proc GetProcessPriorityBoost*(hThread: THandle,
-                              DisablePriorityBoost: var WINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessPriorityBoost".}
-proc GetProcessShutdownParameters*(lpdwLevel, lpdwFlags: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetProcessShutdownParameters".}
-proc GetProcessTimes*(hProcess: THandle, lpCreationTime, lpExitTime,
-    lpKernelTime, lpUserTime: var TFileTime): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetProcessTimes".}
-proc GetProcessWorkingSetSize*(hProcess: THandle, lpMinimumWorkingSetSize,
-    lpMaximumWorkingSetSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "GetProcessWorkingSetSize".}
-proc GetQueuedCompletionStatus*(CompletionPort: THandle,
-    lpNumberOfBytesTransferred, lpCompletionKey: var DWORD,
-                                lpOverlapped: var POverlapped,
-                                dwMilliseconds: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetQueuedCompletionStatus".}
-proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: UINT): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetRasterizerCaps".}
-proc GetRgnBox*(RGN: HRGN, p2: var TRect): int{.stdcall, dynlib: "gdi32",
-    importc: "GetRgnBox".}
-proc GetScrollInfo*(hWnd: HWND, BarFlag: int, ScrollInfo: var TScrollInfo): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetScrollInfo".}
-proc GetScrollRange*(hWnd: HWND, nBar: int, lpMinPos, lpMaxPos: var int): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetScrollRange".}
-  #function GetSecurityDescriptorControl(pSecurityDescriptor: PSecurityDescriptor; var pControl: SECURITY_DESCRIPTOR_CONTROL; var lpdwRevision: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorControl';
-  #function GetSecurityDescriptorDacl(pSecurityDescriptor: PSecurityDescriptor; var lpbDaclPresent: WINBOOL; var pDacl: PACL; var lpbDaclDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorDacl';
-  #function GetSecurityDescriptorGroup(pSecurityDescriptor: PSecurityDescriptor; var pGroup: PSID; var lpbGroupDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorGroup';
-  #function GetSecurityDescriptorOwner(pSecurityDescriptor: PSecurityDescriptor; var pOwner: PSID; var lpbOwnerDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorOwner';
-  #function GetSecurityDescriptorSacl(pSecurityDescriptor: PSecurityDescriptor; var lpbSaclPresent: WINBOOL; var pSacl: PACL; var lpbSaclDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorSacl';
-proc GetStartupInfo*(lpStartupInfo: var TSTARTUPINFO){.stdcall,
-    dynlib: "kernel32", importc: "GetStartupInfoA".}
-proc GetStringTypeA*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                     cchSrc: WINBOOL, lpCharType: var int16): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeA".}
-proc GetStringTypeEx*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: cstring,
-                      cchSrc: int, lpCharType: var int16): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeExA".}
-proc GetStringTypeExA*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR,
-                       cchSrc: int, lpCharType: var int16): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeExA".}
-proc GetStringTypeExW*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPWSTR,
-                       cchSrc: int, lpCharType: var int16): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetStringTypeExW".}
-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,
-    dynlib: "gdi32", importc: "GetSystemPaletteEntries".}
-proc GetSystemPowerStatus*(lpSystemPowerStatus: var TSystemPowerStatus): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetSystemPowerStatus".}
-proc GetSystemTimeAdjustment*(lpTimeAdjustment, lpTimeIncrement: var DWORD,
-                              lpTimeAdjustmentDisabled: var WINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetSystemTimeAdjustment".}
-proc GetSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var TFILETIME){.stdcall,
-    dynlib: "kernel32", importc: "GetSystemTimeAsFileTime".}
-proc GetTabbedTextExtent*(hDC: HDC, lpString: cstring,
-                          nCount, nTabPositions: int,
-                          lpnTabStopPositions: pointer): DWORD{.stdcall,
-    dynlib: "user32", importc: "GetTabbedTextExtentA".}
-proc GetTabbedTextExtentA*(hDC: HDC, lpString: LPCSTR,
-                           nCount, nTabPositions: int,
-                           lpnTabStopPositions: pointer): DWORD{.stdcall,
-    dynlib: "user32", importc: "GetTabbedTextExtentA".}
-proc GetTabbedTextExtentW*(hDC: HDC, lpString: LPWSTR,
-                           nCount, nTabPositions: int,
-                           lpnTabStopPositions: pointer): DWORD{.stdcall,
-    dynlib: "user32", importc: "GetTabbedTextExtentW".}
-proc GetTapeParameters*(hDevice: THandle, dwOperation: DWORD,
-                        lpdwSize: var DWORD, lpTapeInformation: Pointer): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetTapeParameters".}
-proc GetTapePosition*(hDevice: THandle, dwPositionType: DWORD,
-                      lpdwPartition, lpdwOffsetLow: var DWORD,
-                      lpdwOffsetHigh: Pointer): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "GetTapePosition".}
-proc GetTextExtentExPoint*(DC: HDC, p2: cstring, p3, p4: int, p5, p6: PInteger,
-                           p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentExPointA".}
-proc GetTextExtentExPointA*(DC: HDC, p2: LPCSTR, p3, p4: int, p5, p6: PInteger,
-                            p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentExPointA".}
-  #function GetTextExtentExPointI(DC: HDC; p2: PWORD; p3, p4: Integer; p5, p6: PINT; var p7: TSize): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentExPointI';
-proc GetTextExtentExPointW*(DC: HDC, p2: LPWSTR, p3, p4: int, p5, p6: PInteger,
-                            p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "GetTextExtentExPointW".}
-proc GetTextExtentPoint*(DC: HDC, Str: cstring, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".}
-proc GetTextExtentPoint32*(DC: HDC, Str: cstring, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32A".}
-proc GetTextExtentPoint32A*(DC: HDC, Str: LPCSTR, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32A".}
-proc GetTextExtentPoint32W*(DC: HDC, Str: LPWSTR, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32W".}
-proc GetTextExtentPointA*(DC: HDC, Str: LPCSTR, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".}
-  #function GetTextExtentPointI(DC: HDC; p2: PWORD; p3: Integer; var p4: TSize): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentPointI';
-proc GetTextExtentPointW*(DC: HDC, Str: LPWSTR, Count: int, Size: var TSize): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "GetTextExtentPointW".}
-proc GetTextMetrics*(DC: HDC, TM: var TTextMetric): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetTextMetricsA".}
-  #function GetTextMetricsA(DC: HDC; var TM: TTextMetricA): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsA';
-  #function GetTextMetricsW(DC: HDC; var TM: TTextMetricW): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsW';
-proc GetThreadContext*(hThread: THandle, lpContext: var TContext): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetThreadContext".}
-proc GetThreadPriorityBoost*(hThread: THandle, DisablePriorityBoost: var WINBOOL): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetThreadPriorityBoost".}
-proc GetThreadSelectorEntry*(hThread: THandle, dwSelector: DWORD,
-                             lpSelectorEntry: var TLDTEntry): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetThreadSelectorEntry".}
-proc GetThreadTimes*(hThread: THandle, lpCreationTime, lpExitTime, lpKernelTime,
-                                       lpUserTime: var TFileTime): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetThreadTimes".}
-proc GetTimeZoneInformation*(lpTimeZoneInformation: var TTimeZoneInformation): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "GetTimeZoneInformation".}
-  #function GetTitleBarInfo(hwnd: HWND; var pti: TTitleBarInfo): WINBOOL;stdcall; external 'user32' name 'GetTitleBarInfo';
-  #function GetTokenInformation(TokenHandle: THandle; TokenInformationClass: TTokenInformationClass; TokenInformation: Pointer; TokenInformationLength: DWORD; var ReturnLength: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetTokenInformation';
-proc GetUpdateRect*(hWnd: HWND, lpRect: var TRect, bErase: WINBOOL): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUpdateRect".}
-proc GetUserName*(lpBuffer: cstring, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetUserNameA".}
-proc GetUserNameA*(lpBuffer: LPCSTR, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetUserNameA".}
-proc GetUserNameW*(lpBuffer: LPWSTR, nSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "GetUserNameW".}
-proc GetUserObjectInformation*(hObj: THandle, nIndex: int, pvInfo: Pointer,
-                               nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".}
-proc GetUserObjectInformationA*(hObj: THandle, nIndex: int, pvInfo: Pointer,
-                                nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".}
-proc GetUserObjectInformationW*(hObj: THandle, nIndex: int, pvInfo: Pointer,
-                                nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "GetUserObjectInformationW".}
-proc GetUserObjectSecurity*(hObj: THandle, pSIRequested: var DWORD,
-                            pSID: PSecurityDescriptor, nLength: DWORD,
-                            lpnLengthNeeded: var DWORD): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetUserObjectSecurity".}
-proc GetVersionEx*(lpVersionInformation: var TOSVersionInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVersionExA".}
-proc GetVersionExA*(lpVersionInformation: var TOSVersionInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVersionExA".}
-proc GetVersionExW*(lpVersionInformation: var TOSVersionInfoW): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "GetVersionExW".}
-proc GetViewportExtEx*(DC: HDC, Size: var TSize): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetViewportExtEx".}
-proc GetViewportOrgEx*(DC: HDC, Point: var TPoint): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetViewportOrgEx".}
-proc GetVolumeInformation*(lpRootPathName: cstring, lpVolumeNameBuffer: cstring,
-                           nVolumeNameSize: DWORD, lpVolumeSerialNumber: PDWORD,
-    lpMaximumComponentLength, lpFileSystemFlags: var DWORD,
-                           lpFileSystemNameBuffer: cstring,
-                           nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVolumeInformationA".}
-proc GetVolumeInformationA*(lpRootPathName: LPCSTR, lpVolumeNameBuffer: LPCSTR,
-                            nVolumeNameSize: DWORD,
-                            lpVolumeSerialNumber: PDWORD,
-    lpMaximumComponentLength, lpFileSystemFlags: var DWORD,
-                            lpFileSystemNameBuffer: LPCSTR,
-                            nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVolumeInformationA".}
-proc GetVolumeInformationW*(lpRootPathName: LPWSTR, lpVolumeNameBuffer: LPWSTR,
-                            nVolumeNameSize: DWORD,
-                            lpVolumeSerialNumber: PDWORD,
-    lpMaximumComponentLength, lpFileSystemFlags: var DWORD,
-                            lpFileSystemNameBuffer: LPWSTR,
-                            nFileSystemNameSize: DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "GetVolumeInformationW".}
-proc GetWindowExtEx*(DC: HDC, Size: var TSize): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWindowExtEx".}
-  #function GetWindowInfo(hwnd: HWND; var pwi: TWindowInfo): WINBOOL;stdcall; external 'user32' name 'GetWindowInfo';
-proc GetWindowOrgEx*(DC: HDC, Point: var TPoint): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWindowOrgEx".}
-proc GetWindowRect*(hWnd: HWND, lpRect: var TRect): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "GetWindowRect".}
-proc GetWorldTransform*(DC: HDC, p2: var TXForm): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "GetWorldTransform".}
-  #function GradientFill(DC: HDC; var p2: TTriVertex; p3: ULONG; p4: Pointer; p5, p6: ULONG): WINBOOL;stdcall; external 'gdi32' name 'GradientFill';
-proc GlobalMemoryStatus*(Buffer: var MEMORYSTATUS){.stdcall, dynlib: "kernel32",
-    importc: "GlobalMemoryStatus".}
-proc HeapWalk*(hHeap: THandle, lpEntry: var TProcessHeapEntry): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "HeapWalk".}
-proc ImageList_GetDragImage*(ppt: var POINT, pptHotspot: var POINT): HIMAGELIST{.
-    stdcall, dynlib: "comctl32", importc: "ImageList_GetDragImage".}
-proc InflateRect*(lprc: var TRect, dx, dy: int): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "InflateRect".}
-proc InitializeAcl*(pAcl: var TACL, nAclLength, dwAclRevision: DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "InitializeAcl".}
-proc InitializeCriticalSectionAndSpinCount*(
-    lpCriticalSection: var TRTLCriticalSection, dwSpinCount: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32",
-    importc: "InitializeCriticalSectionAndSpinCount".}
-proc InitializeSid*(Sid: Pointer, pIdentifierAuthority: TSIDIdentifierAuthority,
-                    nSubAuthorityCount: int8): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "InitializeSid".}
-proc InsertMenuItem*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "InsertMenuItemA".}
-proc InsertMenuItemA*(p1: HMENU, p2: UINT, 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';
-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';
-proc IsDialogMessage*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "IsDialogMessageA".}
-proc IsDialogMessageA*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "IsDialogMessageA".}
-proc IsDialogMessageW*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "IsDialogMessageW".}
-  #function IsRectEmpty(const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'IsRectEmpty';
-proc IsValidAcl*(pAcl: TACL): WINBOOL{.stdcall, dynlib: "advapi32",
-                                       importc: "IsValidAcl".}
-proc LocalFileTimeToFileTime*(lpLocalFileTime: TFileTime,
-                              lpFileTime: var TFileTime): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "LocalFileTimeToFileTime".}
-proc LockFileEx*(hFile: THandle, dwFlags, dwReserved: DWORD,
-                 nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh: DWORD,
-                 lpOverlapped: TOverlapped): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "LockFileEx".}
-proc LogonUser*(lpszUsername, lpszDomain, lpszPassword: cstring,
-                dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LogonUserA".}
-proc LogonUserA*(lpszUsername, lpszDomain, lpszPassword: LPCSTR,
-                 dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LogonUserA".}
-proc LogonUserW*(lpszUsername, lpszDomain, lpszPassword: LPWSTR,
-                 dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LogonUserW".}
-proc LookupAccountName*(lpSystemName, lpAccountName: cstring, Sid: PSID,
-                        cbSid: var DWORD, ReferencedDomainName: cstring,
-                        cbReferencedDomainName: var DWORD,
-                        peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountNameA".}
-proc LookupAccountNameA*(lpSystemName, lpAccountName: LPCSTR, Sid: PSID,
-                         cbSid: var DWORD, ReferencedDomainName: LPCSTR,
-                         cbReferencedDomainName: var DWORD,
-                         peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountNameA".}
-proc LookupAccountNameW*(lpSystemName, lpAccountName: LPWSTR, Sid: PSID,
-                         cbSid: var DWORD, ReferencedDomainName: LPWSTR,
-                         cbReferencedDomainName: var DWORD,
-                         peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountNameW".}
-proc LookupAccountSid*(lpSystemName: cstring, Sid: PSID, Name: cstring,
-                       cbName: var DWORD, ReferencedDomainName: cstring,
-                       cbReferencedDomainName: var DWORD,
-                       peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountSidA".}
-proc LookupAccountSidA*(lpSystemName: LPCSTR, Sid: PSID, Name: LPCSTR,
-                        cbName: var DWORD, ReferencedDomainName: LPCSTR,
-                        cbReferencedDomainName: var DWORD,
-                        peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountSidA".}
-proc LookupAccountSidW*(lpSystemName: LPWSTR, Sid: PSID, Name: LPWSTR,
-                        cbName: var DWORD, ReferencedDomainName: LPWSTR,
-                        cbReferencedDomainName: var DWORD,
-                        peUse: var SID_NAME_USE): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupAccountSidW".}
-proc LookupPrivilegeDisplayName*(lpSystemName, lpName: LPCSTR,
-                                 lpDisplayName: cstring,
-                                 cbDisplayName, lpLanguageId: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameA".}
-proc LookupPrivilegeDisplayNameA*(lpSystemName, lpName: LPCSTR,
-                                  lpDisplayName: LPCSTR,
-                                  cbDisplayName, lpLanguageId: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameA".}
-proc LookupPrivilegeDisplayNameW*(lpSystemName, lpName: LPCSTR,
-                                  lpDisplayName: LPWSTR,
-                                  cbDisplayName, lpLanguageId: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameW".}
-proc LookupPrivilegeName*(lpSystemName: cstring, lpLuid: var TLargeInteger,
-                          lpName: cstring, cbName: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeNameA".}
-proc LookupPrivilegeNameA*(lpSystemName: LPCSTR, lpLuid: var TLargeInteger,
-                           lpName: LPCSTR, cbName: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeNameA".}
-proc LookupPrivilegeNameW*(lpSystemName: LPWSTR, lpLuid: var TLargeInteger,
-                           lpName: LPWSTR, cbName: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeNameW".}
-proc LookupPrivilegeValue*(lpSystemName, lpName: cstring,
-                           lpLuid: var TLargeInteger): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeValueA".}
-proc LookupPrivilegeValueA*(lpSystemName, lpName: LPCSTR,
-                            lpLuid: var TLargeInteger): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeValueA".}
-proc LookupPrivilegeValueW*(lpSystemName, lpName: LPWSTR,
-                            lpLuid: var TLargeInteger): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "LookupPrivilegeValueW".}
-proc LPtoDP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "LPtoDP".}
-proc MakeAbsoluteSD*(pSelfRelativeSecurityDescriptor: PSecurityDescriptor,
-                     pAbsoluteSecurityDescriptor: PSecurityDescriptor,
-                     lpdwAbsoluteSecurityDescriptorSi: var DWORD,
-                     pDacl: var TACL, lpdwDaclSize: var DWORD, pSacl: var TACL,
-                     lpdwSaclSize: var DWORD, pOwner: PSID,
-                     lpdwOwnerSize: var DWORD, pPrimaryGroup: Pointer,
-                     lpdwPrimaryGroupSize: var DWORD): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "MakeAbsoluteSD".}
-proc MakeSelfRelativeSD*(pAbsoluteSecurityDescriptor: PSecurityDescriptor,
-                         pSelfRelativeSecurityDescriptor: PSecurityDescriptor,
-                         lpdwBufferLength: var DWORD): WINBOOL{.stdcall,
-    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{.
-    stdcall, dynlib: "user32", importc: "MapWindowPoints".}
-proc MessageBoxIndirect*(MsgBoxParams: TMsgBoxParams): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "MessageBoxIndirectA".}
-proc MessageBoxIndirectA*(MsgBoxParams: TMsgBoxParamsA): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "MessageBoxIndirectA".}
-  #function MessageBoxIndirectW(const MsgBoxParams: TMsgBoxParamsW): WINBOOL; stdcall; external 'user32' name 'MessageBoxIndirectW';
-  #function ModifyWorldTransform(DC: HDC; const p2: TXForm; p3: DWORD): WINBOOL; stdcall; external 'gdi32' name 'ModifyWorldTransform';
-proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: pointer,
-                                fWaitAll: WINBOOL,
-                                dwMilliseconds, dwWakeMask: DWORD): DWORD{.
-    stdcall, dynlib: "user32", importc: "MsgWaitForMultipleObjects".}
-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';
-proc ObjectOpenAuditAlarm*(SubsystemName: cstring, HandleId: Pointer,
-                           ObjectTypeName: cstring, ObjectName: cstring,
-                           pSecurityDescriptor: PSecurityDescriptor,
-                           ClientToken: THandle,
-                           DesiredAccess, GrantedAccess: DWORD,
-                           Privileges: var TPrivilegeSet,
-                           ObjectCreation, AccessGranted: WINBOOL,
-                           GenerateOnClose: var WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".}
-proc ObjectOpenAuditAlarmA*(SubsystemName: LPCSTR, HandleId: Pointer,
-                            ObjectTypeName: LPCSTR, ObjectName: LPCSTR,
-                            pSecurityDescriptor: PSecurityDescriptor,
-                            ClientToken: THandle,
-                            DesiredAccess, GrantedAccess: DWORD,
-                            Privileges: var TPrivilegeSet,
-                            ObjectCreation, AccessGranted: WINBOOL,
-                            GenerateOnClose: var WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".}
-proc ObjectOpenAuditAlarmW*(SubsystemName: LPWSTR, HandleId: Pointer,
-                            ObjectTypeName: LPWSTR, ObjectName: LPWSTR,
-                            pSecurityDescriptor: PSecurityDescriptor,
-                            ClientToken: THandle,
-                            DesiredAccess, GrantedAccess: DWORD,
-                            Privileges: var TPrivilegeSet,
-                            ObjectCreation, AccessGranted: WINBOOL,
-                            GenerateOnClose: var WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectOpenAuditAlarmW".}
-proc ObjectPrivilegeAuditAlarm*(SubsystemName: cstring, HandleId: Pointer,
-                                ClientToken: THandle, DesiredAccess: DWORD,
-                                Privileges: var TPrivilegeSet,
-                                AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".}
-proc ObjectPrivilegeAuditAlarmA*(SubsystemName: LPCSTR, HandleId: Pointer,
-                                 ClientToken: THandle, DesiredAccess: DWORD,
-                                 Privileges: var TPrivilegeSet,
-                                 AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".}
-proc ObjectPrivilegeAuditAlarmW*(SubsystemName: LPWSTR, HandleId: Pointer,
-                                 ClientToken: THandle, DesiredAccess: DWORD,
-                                 Privileges: var TPrivilegeSet,
-                                 AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmW".}
-proc OffsetRect*(lprc: var TRect, dx, dy: int): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "OffsetRect".}
-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{.
-    stdcall, dynlib: "kernel32", importc: "OpenFile".}
-proc OpenProcessToken*(ProcessHandle: THandle, DesiredAccess: DWORD,
-                       TokenHandle: var THandle): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "OpenProcessToken".}
-proc OpenThreadToken*(ThreadHandle: THandle, DesiredAccess: DWORD,
-                      OpenAsSelf: WINBOOL, TokenHandle: var THandle): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "OpenThreadToken".}
-proc PeekConsoleInput*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                       nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".}
-proc PeekConsoleInputA*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                        nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".}
-proc PeekConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                        nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".}
-proc PeekMessage*(lpMsg: var TMsg, hWnd: HWND,
-                  wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "PeekMessageA".}
-proc PeekMessageA*(lpMsg: var TMsg, hWnd: HWND,
-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "PeekMessageA".}
-proc PeekMessageW*(lpMsg: var TMsg, hWnd: HWND,
-                   wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): 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",
-    importc: "PlayEnhMetaFileRecord".}
-proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: UINT): 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",
-    importc: "PlgBlt".}
-proc PolyBezier*(DC: HDC, Points: pointer, Count: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolyBezier".}
-proc PolyBezierTo*(DC: HDC, Points: pointer, Count: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolyBezierTo".}
-proc PolyDraw*(DC: HDC, Points, Types: pointer, cCount: int): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolyDraw".}
-proc Polygon*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "Polygon".}
-proc Polyline*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "Polyline".}
-proc PolyLineTo*(DC: HDC, Points: pointer, Count: DWORD): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "PolylineTo".}
-proc PolyPolygon*(DC: HDC, Points: pointer, nPoints: pointer, p4: int): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyPolygon".}
-proc PolyPolyline*(DC: HDC, PointStructs: pointer, Points: pointer, p4: DWORD): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyPolyline".}
-proc PolyTextOut*(DC: HDC, PolyTextArray: pointer, Strings: int): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}
-proc PolyTextOutA*(DC: HDC, PolyTextArray: pointer, Strings: int): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyTextOutA".}
-proc PolyTextOutW*(DC: HDC, PolyTextArray: pointer, Strings: int): WINBOOL{.
-    stdcall, dynlib: "gdi32", importc: "PolyTextOutW".}
-proc PrivilegeCheck*(ClientToken: THandle, RequiredPrivileges: TPrivilegeSet,
-                     pfResult: var WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegeCheck".}
-proc PrivilegedServiceAuditAlarm*(SubsystemName, ServiceName: cstring,
-                                  ClientToken: THandle,
-                                  Privileges: var TPrivilegeSet,
-                                  AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".}
-proc PrivilegedServiceAuditAlarmA*(SubsystemName, ServiceName: LPCSTR,
-                                   ClientToken: THandle,
-                                   Privileges: var TPrivilegeSet,
-                                   AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".}
-proc PrivilegedServiceAuditAlarmW*(SubsystemName, ServiceName: LPWSTR,
-                                   ClientToken: THandle,
-                                   Privileges: var TPrivilegeSet,
-                                   AccessGranted: WINBOOL): WINBOOL{.stdcall,
-    dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmW".}
-  #function PtInRect(const lprc: TRect; pt: TPoint): WINBOOL; stdcall; external 'user32' name 'PtInRect';
-proc QueryPerformanceCounter*(lpPerformanceCount: var TLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "QueryPerformanceCounter".}
-proc QueryPerformanceFrequency*(lpFrequency: var TLargeInteger): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "QueryPerformanceFrequency".}
-  #function QueryRecoveryAgents(p1: PChar; var p2: Pointer; var p3: TRecoveryAgentInformation): DWORD;stdcall; external 'kernel32' name 'QueryRecoveryAgentsA';
-  #function QueryRecoveryAgentsA(p1: LPCSTR; var p2: Pointer; var p3: TRecoveryAgentInformationA): DWORD;stdcall; external 'kernel32' name 'QueryRecoveryAgentsA';
-  #function QueryRecoveryAgentsW(p1: LPWSTR; var p2: Pointer; var p3: TRecoveryAgentInformationW): DWORD;stdcall; external 'kernel32' name 'QueryRecoveryAgentsW';
-proc RaiseException*(dwExceptionCode: DWORD, dwExceptionFlags: DWORD,
-                     nNumberOfArguments: DWORD, lpArguments: var DWORD){.
-    stdcall, dynlib: "kernel32", importc: "RaiseException".}
-proc UnhandledExceptionFilter*(ExceptionInfo: var emptyrecord): LONG{.stdcall,
-    dynlib: "kernel32", importc: "UnhandledExceptionFilter".}
-proc ReadConsole*(hConsoleInput: THandle, lpBuffer: Pointer,
-                  nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD,
-                  lpReserved: Pointer): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReadConsoleA".}
-proc ReadConsoleA*(hConsoleInput: THandle, lpBuffer: Pointer,
-                   nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD,
-                   lpReserved: Pointer): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReadConsoleA".}
-proc ReadConsoleInput*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                       nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".}
-proc ReadConsoleInputA*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                        nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".}
-proc ReadConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord,
-                        nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".}
-proc ReadConsoleOutput*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                        dwBufferSize, dwBufferCoord: TCoord,
-                        lpReadRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadConsoleOutputA".}
-proc ReadConsoleOutputA*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                         dwBufferSize, dwBufferCoord: TCoord,
-                         lpReadRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadConsoleOutputA".}
-proc ReadConsoleOutputAttribute*(hConsoleOutput: THandle, lpAttribute: Pointer,
-                                 nLength: DWORD, dwReadCoord: TCoord,
-                                 lpNumberOfAttrsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputAttribute".}
-proc ReadConsoleOutputCharacter*(hConsoleOutput: THandle, lpCharacter: LPCSTR,
-                                 nLength: DWORD, dwReadCoord: TCoord,
-                                 lpNumberOfCharsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".}
-proc ReadConsoleOutputCharacterA*(hConsoleOutput: THandle, lpCharacter: LPCSTR,
-                                  nLength: DWORD, dwReadCoord: TCoord,
-                                  lpNumberOfCharsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".}
-proc ReadConsoleOutputCharacterW*(hConsoleOutput: THandle, lpCharacter: LPCSTR,
-                                  nLength: DWORD, dwReadCoord: TCoord,
-                                  lpNumberOfCharsRead: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterW".}
-proc ReadConsoleOutputW*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                         dwBufferSize, dwBufferCoord: TCoord,
-                         lpReadRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadConsoleOutputW".}
-proc ReadConsoleW*(hConsoleInput: THandle, lpBuffer: Pointer,
-                   nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD,
-                   lpReserved: Pointer): WINBOOL{.stdcall, dynlib: "kernel32",
-    importc: "ReadConsoleW".}
-proc ReadEventLog*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD,
-                   lpBuffer: Pointer, nNumberOfBytesToRead: DWORD,
-                   pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ReadEventLogA".}
-proc ReadEventLogA*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD,
-                    lpBuffer: Pointer, nNumberOfBytesToRead: DWORD,
-                    pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ReadEventLogA".}
-proc ReadEventLogW*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD,
-                    lpBuffer: Pointer, nNumberOfBytesToRead: DWORD,
-                    pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{.
-    stdcall, dynlib: "advapi32", importc: "ReadEventLogW".}
-proc ReadFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToRead: DWORD,
-               lpNumberOfBytesRead: var DWORD, lpOverlapped: POverlapped): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadFile".}
-proc ReadProcessMemory*(hProcess: THandle, lpBaseAddress: Pointer,
-                        lpBuffer: Pointer, nSize: DWORD,
-                        lpNumberOfBytesRead: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ReadProcessMemory".}
-  #function RectInRegion(RGN: HRGN; const p2: TRect): WINBOOL; stdcall; external 'gdi32' name 'RectInRegion';
-  #function RectVisible(DC: HDC; const Rect: TRect): WINBOOL; stdcall; external 'gdi32' name 'RectVisible';
-proc RegConnectRegistry*(lpMachineName: cstring, hKey: HKEY, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegConnectRegistryA".}
-proc RegConnectRegistryA*(lpMachineName: LPCSTR, hKey: HKEY, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegConnectRegistryA".}
-proc RegConnectRegistryW*(lpMachineName: LPWSTR, hKey: HKEY, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegConnectRegistryW".}
-proc RegCreateKey*(hKey: HKEY, lpSubKey: cstring, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyA".}
-proc RegCreateKeyA*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyA".}
-proc RegCreateKeyEx*(hKey: HKEY, lpSubKey: cstring, Reserved: DWORD,
-                     lpClass: cstring, dwOptions: DWORD, samDesired: REGSAM,
-                     lpSecurityAttributes: PSecurityAttributes,
-                     phkResult: var HKEY, lpdwDisposition: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyExA".}
-proc RegCreateKeyExA*(hKey: HKEY, lpSubKey: LPCSTR, Reserved: DWORD,
-                      lpClass: LPCSTR, dwOptions: DWORD, samDesired: REGSAM,
-                      lpSecurityAttributes: PSecurityAttributes,
-                      phkResult: var HKEY, lpdwDisposition: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyExA".}
-proc RegCreateKeyExW*(hKey: HKEY, lpSubKey: LPWSTR, Reserved: DWORD,
-                      lpClass: LPWSTR, dwOptions: DWORD, samDesired: REGSAM,
-                      lpSecurityAttributes: PSecurityAttributes,
-                      phkResult: var HKEY, lpdwDisposition: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyExW".}
-proc RegCreateKeyW*(hKey: HKEY, lpSubKey: LPWSTR, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegCreateKeyW".}
-proc RegEnumKeyEx*(hKey: HKEY, dwIndex: DWORD, lpName: cstring,
-                   lpcbName: var DWORD, lpReserved: Pointer, lpClass: cstring,
-                   lpcbClass: PDWORD, lpftLastWriteTime: PFileTime): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyExA".}
-proc RegEnumKeyExA*(hKey: HKEY, dwIndex: DWORD, lpName: LPCSTR,
-                    lpcbName: var DWORD, lpReserved: Pointer, lpClass: LPCSTR,
-                    lpcbClass: PDWORD, lpftLastWriteTime: PFileTime): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyExA".}
-proc RegEnumKeyExW*(hKey: HKEY, dwIndex: DWORD, lpName: LPWSTR,
-                    lpcbName: var DWORD, lpReserved: Pointer, lpClass: LPWSTR,
-                    lpcbClass: PDWORD, lpftLastWriteTime: PFileTime): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumKeyExW".}
-proc RegEnumValue*(hKey: HKEY, dwIndex: DWORD, lpValueName: cstring,
-                   lpcbValueName: var DWORD, lpReserved: Pointer,
-                   lpType: PDWORD, lpData: PByte, lpcbData: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumValueA".}
-proc RegEnumValueA*(hKey: HKEY, dwIndex: DWORD, lpValueName: cstring,
-                    lpcbValueName: var DWORD, lpReserved: Pointer,
-                    lpType: PDWORD, lpData: PByte, lpcbData: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumValueA".}
-proc RegEnumValueW*(hKey: HKEY, dwIndex: DWORD, lpValueName: cstring,
-                    lpcbValueName: var DWORD, lpReserved: Pointer,
-                    lpType: PDWORD, lpData: PByte, lpcbData: PDWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegEnumValueW".}
-proc RegGetKeySecurity*(hKey: HKEY, SecurityInformation: SECURITY_INFORMATION,
-                        pSecurityDescriptor: PSecurityDescriptor,
-                        lpcbSecurityDescriptor: var DWORD): int32{.stdcall,
-    dynlib: "advapi32", importc: "RegGetKeySecurity".}
-proc RegSetValueEx*(hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD,
-                    dwType: DWORD, lpData: pointer, cbData: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetValueExA".}
-proc RegSetValueExA*(hKey: HKEY, lpValueName: LPCSTR, Reserved: DWORD,
-                     dwType: DWORD, lpData: pointer, cbData: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetValueExA".}
-proc RegSetValueExW*(hKey: HKEY, lpValueName: LPCWSTR, Reserved: DWORD,
-                     dwType: DWORD, lpData: pointer, cbData: DWORD): LONG{.
-    stdcall, dynlib: "advapi32", importc: "RegSetValueExW".}
-proc RegisterClass*(lpWndClass: TWndClass): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassA".}
-proc RegisterClassA*(lpWndClass: TWndClassA): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassA".}
-proc RegisterClassEx*(WndClass: TWndClassEx): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassExA".}
-proc RegisterClassExA*(WndClass: TWndClassExA): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassExA".}
-proc RegisterClassExW*(WndClass: TWndClassExW): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassExW".}
-proc RegisterClassW*(lpWndClass: TWndClassW): ATOM{.stdcall, dynlib: "user32",
-    importc: "RegisterClassW".}
-proc RegOpenKey*(hKey: HKEY, lpSubKey: cstring, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegOpenKeyA".}
-proc RegOpenKeyA*(hKey: HKEY, lpSubKey: LPCSTR, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegOpenKeyA".}
-proc RegOpenKeyEx*(hKey: HKEY, lpSubKey: cstring, ulOptions: DWORD,
-                   samDesired: REGSAM, phkResult: var HKEY): int32{.stdcall,
-    dynlib: "advapi32", importc: "RegOpenKeyExA".}
-proc RegOpenKeyExA*(hKey: HKEY, lpSubKey: LPCSTR, ulOptions: DWORD,
-                    samDesired: REGSAM, phkResult: var HKEY): int32{.stdcall,
-    dynlib: "advapi32", importc: "RegOpenKeyExA".}
-proc RegOpenKeyExW*(hKey: HKEY, lpSubKey: LPWSTR, ulOptions: DWORD,
-                    samDesired: REGSAM, phkResult: var HKEY): int32{.stdcall,
-    dynlib: "advapi32", importc: "RegOpenKeyExW".}
-proc RegOpenKeyW*(hKey: HKEY, lpSubKey: LPWSTR, phkResult: var HKEY): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegOpenKeyW".}
-proc RegQueryMultipleValues*(hKey: HKEY, ValList: pointer, NumVals: DWORD,
-                             lpValueBuf: cstring, ldwTotsize: var DWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesA".}
-proc RegQueryMultipleValuesA*(hKey: HKEY, ValList: pointer, NumVals: DWORD,
-                              lpValueBuf: LPCSTR, ldwTotsize: var DWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesA".}
-proc RegQueryMultipleValuesW*(hKey: HKEY, ValList: pointer, NumVals: DWORD,
-                              lpValueBuf: LPWSTR, ldwTotsize: var DWORD): int32{.
-    stdcall, dynlib: "advapi32", importc: "RegQueryMultipleValuesW".}
-proc RegQueryValue*(hKey: HKEY, lpSubKey: cstring, lpValue: cstring,
-                    lpcbValue: var int32): int32{.stdcall, dynlib: "advapi32",
-    importc: "RegQueryValueA".}
-proc RegQueryValueA*(hKey: HKEY, lpSubKey: LPCSTR, lpValue: LPCSTR,
-                     lpcbValue: var int32): int32{.stdcall, dynlib: "advapi32",
-    importc: "RegQueryValueA".}
-proc RegQueryValueW*(hKey: HKEY, lpSubKey: LPWSTR, lpValue: LPWSTR,
-                     lpcbValue: var int32): int32{.stdcall, dynlib: "advapi32",
-    importc: "RegQueryValueW".}
-proc ResetDC*(DC: HDC, p2: TDeviceMode): HDC{.stdcall, dynlib: "gdi32",
-    importc: "ResetDCA".}
-proc ResetDCA*(DC: HDC, p2: TDeviceModeA): HDC{.stdcall, dynlib: "gdi32",
-    importc: "ResetDCA".}
-  #function ResetDCW(DC: HDC; const p2: TDeviceModeW): HDC; stdcall; external 'gdi32' name 'ResetDCW';
-proc ScreenToClient*(hWnd: HWND, lpPoint: var TPoint): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "ScreenToClient".}
-proc ScrollConsoleScreenBuffer*(hConsoleOutput: THandle,
-                                lpScrollRectangle: TSmallRect,
-                                lpClipRectangle: TSmallRect,
-                                dwDestinationOrigin: TCoord,
-                                lpFill: var TCharInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".}
-proc ScrollConsoleScreenBufferA*(hConsoleOutput: THandle,
-                                 lpScrollRectangle: TSmallRect,
-                                 lpClipRectangle: TSmallRect,
-                                 dwDestinationOrigin: TCoord,
-                                 lpFill: var TCharInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".}
-proc ScrollConsoleScreenBufferW*(hConsoleOutput: THandle,
-                                 lpScrollRectangle: TSmallRect,
-                                 lpClipRectangle: TSmallRect,
-                                 dwDestinationOrigin: TCoord,
-                                 lpFill: var TCharInfo): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "ScrollConsoleScreenBufferW".}
-proc ScrollWindow*(hWnd: HWND, XAmount: int32, YAmount: int32, lpRect: lpRECT,
-                   lpClipRect: lpRECT): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "ScrollWindow".}
-proc ScrollWindowEx*(hWnd: HWND, dx: int32, dy: int32, prcScroll: lpRECT,
-                     prcClip: lpRECT, hrgnUpdate: HRGN, prcUpdate: LPRECT,
-                     flags: UINT): 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*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM,
-                         fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}
-proc SendMessageTimeoutA*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM,
-                          fuFlags, uTimeout: UINT, lpdwResult: var DWORD): LRESULT{.
-    stdcall, dynlib: "user32", importc: "SendMessageTimeoutA".}
-proc SendMessageTimeoutW*(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM,
-                          fuFlags, uTimeout: UINT, 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';
-proc SetCommConfig*(hCommDev: THandle, lpCC: TCommConfig, dwSize: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetCommConfig".}
-proc SetCommState*(hFile: THandle, lpDCB: TDCB): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetCommState".}
-proc SetCommTimeouts*(hFile: THandle, lpCommTimeouts: TCommTimeouts): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetCommTimeouts".}
-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 SetCriticalSectionSpinCount*(lpCriticalSection: var TRTLCriticalSection,
-                                  dwSpinCount: DWORD): DWORD{.stdcall,
-    dynlib: "kernel32", importc: "SetCriticalSectionSpinCount".}
-proc SetDeviceGammaRamp*(DC: HDC, Ramp: pointer): WINBOOL{.stdcall,
-    dynlib: "gdi32", importc: "SetDeviceGammaRamp".}
-proc SetDIBColorTable*(DC: HDC, p2, p3: UINT, RGBQuadSTructs: pointer): UINT{.
-    stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".}
-proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: UINT,
-                Bits: Pointer, BitsInfo: var TBitmapInfo, Usage: UINT): 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,
-    dynlib: "gdi32", importc: "SetEnhMetaFileBits".}
-proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME,
-                  lpLastAccessTime: var FILETIME, lpLastWriteTime: var FILETIME): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SetFileTime".}
-  #function SetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'SetKeyboardState';
-  #function SetLocalTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetLocalTime';
-  #function SetMenuInfo(hMenu: HMENU; const lpcmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'SetMenuInfo';
-proc SetMenuItemInfo*(p1: HMENU, p2: UINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".}
-proc SetMenuItemInfoA*(p1: HMENU, p2: UINT, 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,
-    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,
-    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';
-  #function SetPrivateObjectSecurityEx(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; AutoInheritFlags: ULONG;
-  #  const GenericMapping: TGenericMapping; Token: THandle): WINBOOL;stdcall; external 'advapi32' name 'SetPrivateObjectSecurityEx';
-proc SetRect*(lprc: var TRect, xLeft, yTop, xRight, yBottom: int): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetRect".}
-proc SetRectEmpty*(lprc: var TRect): WINBOOL{.stdcall, dynlib: "user32",
-    importc: "SetRectEmpty".}
-proc SetScrollInfo*(hWnd: HWND, BarFlag: int, ScrollInfo: TScrollInfo,
-                    Redraw: WINBOOL): int{.stdcall, dynlib: "user32",
-    importc: "SetScrollInfo".}
-proc SetSysColors*(cElements: int, lpaElements: pointer, lpaRgbValues: pointer): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SetSysColors".}
-  #function SetSystemTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetSystemTime';
-proc SetThreadContext*(hThread: THandle, lpContext: TContext): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SetThreadContext".}
-  #function SetTimeZoneInformation(const lpTimeZoneInformation: TTimeZoneInformation): WINBOOL; stdcall; external 'kernel32' name 'SetTimeZoneInformation';
-proc SetUserObjectSecurity*(hObj: THandle, pSIRequested: var DWORD,
-                            pSID: PSecurityDescriptor): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "SetUserObjectSecurity".}
-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{.
-    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",
-    importc: "StartDocA".}
-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';
-proc SubtractRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "SubtractRect".}
-proc SystemTimeToFileTime*(lpSystemTime: TSystemTime, lpFileTime: var TFileTime): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "SystemTimeToFileTime".}
-proc SystemTimeToTzSpecificLocalTime*(lpTimeZoneInformation: PTimeZoneInformation,
-    lpUniversalTime, lpLocalTime: var TSystemTime): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "SystemTimeToTzSpecificLocalTime".}
-proc TabbedTextOut*(hDC: HDC, X, Y: int, lpString: cstring,
-                    nCount, nTabPositions: int, lpnTabStopPositions: pointer,
-                    nTabOrigin: int): int32{.stdcall, dynlib: "user32",
-    importc: "TabbedTextOutA".}
-proc TabbedTextOutA*(hDC: HDC, X, Y: int, lpString: LPCSTR,
-                     nCount, nTabPositions: int, lpnTabStopPositions: pointer,
-                     nTabOrigin: int): int32{.stdcall, dynlib: "user32",
-    importc: "TabbedTextOutA".}
-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';
-  # 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*(hMenu: HMENU, uFlags: UINT, x: int32, y: int32,
-                     nReserved: int32, hWnd: HWND, prcRect: PRect): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "TrackPopupMenu".}
-proc TransactNamedPipe*(hNamedPipe: THandle, lpInBuffer: Pointer,
-                        nInBufferSize: DWORD, lpOutBuffer: Pointer,
-                        nOutBufferSize: DWORD, lpBytesRead: var DWORD,
-                        lpOverlapped: POverlapped): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "TransactNamedPipe".}
-proc TranslateAccelerator*(hWnd: HWND, hAccTable: HACCEL, lpMsg: var TMsg): int{.
-    stdcall, dynlib: "user32", importc: "TranslateAcceleratorA".}
-proc TranslateAcceleratorA*(hWnd: HWND, hAccTable: HACCEL, lpMsg: var TMsg): int{.
-    stdcall, dynlib: "user32", importc: "TranslateAcceleratorA".}
-proc TranslateAcceleratorW*(hWnd: HWND, hAccTable: HACCEL, lpMsg: var TMsg): int{.
-    stdcall, dynlib: "user32", importc: "TranslateAcceleratorW".}
-proc TranslateCharsetInfo*(lpSrc: var DWORD, lpCs: var TCharsetInfo,
-                           dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "gdi32",
-    importc: "TranslateCharsetInfo".}
-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';
-proc TryEnterCriticalSection*(lpCriticalSection: var TRTLCriticalSection): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "TryEnterCriticalSection".}
-proc UnhandledExceptionFilter*(ExceptionInfo: TExceptionPointers): int32{.
-    stdcall, dynlib: "kernel32", importc: "UnhandledExceptionFilter".}
-proc UnionRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "UnionRect".}
-proc UnlockFileEx*(hFile: THandle, dwReserved, nNumberOfBytesToUnlockLow: DWORD,
-                   nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: TOverlapped): WINBOOL{.
-    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",
-    importc: "VerFindFileA".}
-proc VerFindFileA*(uFlags: DWORD,
-                   szFileName, szWinDir, szAppDir, szCurDir: LPCSTR,
-                   lpuCurDirLen: var UINT, szDestDir: LPCSTR,
-                   lpuDestDirLen: var UINT): 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",
-    importc: "VerFindFileW".}
-proc VerInstallFile*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,
-                                    szDestDir, szCurDir, szTmpFile: cstring,
-                     lpuTmpFileLen: var UINT): DWORD{.stdcall,
-    dynlib: "version", importc: "VerInstallFileA".}
-proc VerInstallFileA*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,
-                                     szDestDir, szCurDir, szTmpFile: LPCSTR,
-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,
-    dynlib: "version", importc: "VerInstallFileA".}
-proc VerInstallFileW*(uFlags: DWORD, szSrcFileName, szDestFileName, szSrcDir,
-                                     szDestDir, szCurDir, szTmpFile: LPWSTR,
-                      lpuTmpFileLen: var UINT): DWORD{.stdcall,
-    dynlib: "version", importc: "VerInstallFileW".}
-proc VerQueryValue*(pBlock: Pointer, lpSubBlock: cstring,
-                    lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.stdcall,
-    dynlib: "version", importc: "VerQueryValueA".}
-proc VerQueryValueA*(pBlock: Pointer, lpSubBlock: LPCSTR,
-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.
-    stdcall, dynlib: "version", importc: "VerQueryValueA".}
-proc VerQueryValueW*(pBlock: Pointer, lpSubBlock: LPWSTR,
-                     lplpBuffer: var Pointer, puLen: var UINT): WINBOOL{.
-    stdcall, dynlib: "version", importc: "VerQueryValueW".}
-proc VirtualQuery*(lpAddress: Pointer, lpBuffer: var TMemoryBasicInformation,
-                   dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32",
-    importc: "VirtualQuery".}
-proc VirtualQueryEx*(hProcess: THandle, lpAddress: Pointer,
-                     lpBuffer: var TMemoryBasicInformation, dwLength: DWORD): DWORD{.
-    stdcall, dynlib: "kernel32", importc: "VirtualQueryEx".}
-proc WaitCommEvent*(hFile: THandle, lpEvtMask: var DWORD,
-                    lpOverlapped: POverlapped): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WaitCommEvent".}
-proc WaitForDebugEvent*(lpDebugEvent: var TDebugEvent, dwMilliseconds: DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WaitForDebugEvent".}
-proc wglDescribeLayerPlane*(p1: HDC, p2, p3: int, p4: int,
-                            p5: var TLayerPlaneDescriptor): WINBOOL{.stdcall,
-    dynlib: "opengl32", importc: "wglDescribeLayerPlane".}
-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 WinSubmitCertificate(var lpCertificate: TWinCertificate): WINBOOL;stdcall; external 'imaghlp' name 'WinSubmitCertificate';
-  #function WinVerifyTrust(hwnd: HWND; const ActionID: TGUID; ActionData: Pointer): Longint;stdcall; external 'imaghlp' name 'WinVerifyTrust';
-proc WNetAddConnection2*(lpNetResource: var TNetResource,
-                         lpPassword, lpUserName: cstring, dwFlags: DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetAddConnection2A".}
-proc WNetAddConnection2A*(lpNetResource: var TNetResourceA,
-                          lpPassword, lpUserName: LPCSTR, dwFlags: DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetAddConnection2A".}
-  #function WNetAddConnection2W(var lpNetResource: TNetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection2W';
-proc WNetAddConnection3*(hwndOwner: HWND, lpNetResource: var TNetResource,
-                         lpPassword, lpUserName: cstring, dwFlags: DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetAddConnection3A".}
-proc WNetAddConnection3A*(hwndOwner: HWND, lpNetResource: var TNetResourceA,
-                          lpPassword, lpUserName: LPCSTR, dwFlags: DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetAddConnection3A".}
-  #function WNetAddConnection3W(hwndOwner: HWND; var lpNetResource: TNetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection3W';
-proc WNetConnectionDialog1*(lpConnDlgStruct: var TConnectDlgStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".}
-proc WNetConnectionDialog1A*(lpConnDlgStruct: var TConnectDlgStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".}
-  #function WNetConnectionDialog1W(var lpConnDlgStruct: TConnectDlgStruct): DWORD; stdcall; external 'mpr' name 'WNetConnectionDialog1W';
-proc WNetDisconnectDialog1*(lpConnDlgStruct: var TDiscDlgStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetDisconnectDialog1A".}
-proc WNetDisconnectDialog1A*(lpConnDlgStruct: var TDiscDlgStructA): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetDisconnectDialog1A".}
-  #function WNetDisconnectDialog1W(var lpConnDlgStruct: TDiscDlgStructW): DWORD; stdcall; external 'mpr' name 'WNetDisconnectDialog1W';
-proc WNetEnumResource*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: Pointer,
-                       lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetEnumResourceA".}
-proc WNetEnumResourceA*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: Pointer,
-                        lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetEnumResourceA".}
-proc WNetEnumResourceW*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: Pointer,
-                        lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetEnumResourceW".}
-proc WNetGetConnection*(lpLocalName: cstring, lpRemoteName: cstring,
-                        lpnLength: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetConnectionA".}
-proc WNetGetConnectionA*(lpLocalName: LPCSTR, lpRemoteName: LPCSTR,
-                         lpnLength: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetConnectionA".}
-proc WNetGetConnectionW*(lpLocalName: LPWSTR, lpRemoteName: LPWSTR,
-                         lpnLength: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetConnectionW".}
-proc WNetGetLastError*(lpError: var DWORD, lpErrorBuf: cstring,
-                       nErrorBufSize: DWORD, lpNameBuf: cstring,
-                       nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetLastErrorA".}
-proc WNetGetLastErrorA*(lpError: var DWORD, lpErrorBuf: LPCSTR,
-                        nErrorBufSize: DWORD, lpNameBuf: LPCSTR,
-                        nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetLastErrorA".}
-proc WNetGetLastErrorW*(lpError: var DWORD, lpErrorBuf: LPWSTR,
-                        nErrorBufSize: DWORD, lpNameBuf: LPWSTR,
-                        nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetLastErrorW".}
-proc WNetGetNetworkInformation*(lpProvider: cstring,
-                                lpNetInfoStruct: var TNetInfoStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".}
-proc WNetGetNetworkInformationA*(lpProvider: LPCSTR,
-                                 lpNetInfoStruct: var TNetInfoStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".}
-proc WNetGetNetworkInformationW*(lpProvider: LPWSTR,
-                                 lpNetInfoStruct: var TNetInfoStruct): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationW".}
-proc WNetGetProviderName*(dwNetType: DWORD, lpProviderName: cstring,
-                          lpBufferSize: var DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetProviderNameA".}
-proc WNetGetProviderNameA*(dwNetType: DWORD, lpProviderName: LPCSTR,
-                           lpBufferSize: var DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetProviderNameA".}
-proc WNetGetProviderNameW*(dwNetType: DWORD, lpProviderName: LPWSTR,
-                           lpBufferSize: var DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetProviderNameW".}
-proc WNetGetResourceParent*(lpNetResource: PNetResource, lpBuffer: Pointer,
-                            cbBuffer: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetGetResourceParentA".}
-proc WNetGetResourceParentA*(lpNetResource: PNetResourceA, lpBuffer: Pointer,
-                             cbBuffer: var DWORD): DWORD{.stdcall,
-    dynlib: "mpr", importc: "WNetGetResourceParentA".}
-  #function WNetGetResourceParentW(lpNetResource: PNetResourceW; lpBuffer: Pointer; var cbBuffer: DWORD): DWORD;stdcall; external 'mpr' name 'WNetGetResourceParentW';
-proc WNetGetUniversalName*(lpLocalPath: cstring, dwInfoLevel: DWORD,
-                           lpBuffer: Pointer, lpBufferSize: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameA".}
-proc WNetGetUniversalNameA*(lpLocalPath: LPCSTR, dwInfoLevel: DWORD,
-                            lpBuffer: Pointer, lpBufferSize: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameA".}
-proc WNetGetUniversalNameW*(lpLocalPath: LPWSTR, dwInfoLevel: DWORD,
-                            lpBuffer: Pointer, lpBufferSize: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUniversalNameW".}
-proc WNetGetUser*(lpName: cstring, lpUserName: cstring, lpnLength: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUserA".}
-proc WNetGetUserA*(lpName: LPCSTR, lpUserName: LPCSTR, lpnLength: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUserA".}
-proc WNetGetUserW*(lpName: LPWSTR, lpUserName: LPWSTR, lpnLength: var DWORD): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetGetUserW".}
-proc WNetOpenEnum*(dwScope, dwType, dwUsage: DWORD, lpNetResource: PNetResource,
-                   lphEnum: var THandle): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetOpenEnumA".}
-proc WNetOpenEnumA*(dwScope, dwType, dwUsage: DWORD,
-                    lpNetResource: PNetResourceA, lphEnum: var THandle): DWORD{.
-    stdcall, dynlib: "mpr", importc: "WNetOpenEnumA".}
-  #function WNetOpenEnumW(dwScope, dwType, dwUsage: DWORD; lpNetResource: PNetResourceW; var lphEnum: THandle): DWORD; stdcall; external 'mpr' name 'WNetOpenEnumW';
-proc WNetUseConnection*(hwndOwner: HWND, lpNetResource: var TNetResource,
-                        lpUserID: cstring, lpPassword: cstring, dwFlags: DWORD,
-                        lpAccessName: cstring, lpBufferSize: var DWORD,
-                        lpResult: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetUseConnectionA".}
-proc WNetUseConnectionA*(hwndOwner: HWND, lpNetResource: var TNetResourceA,
-                         lpUserID: LPCSTR, lpPassword: LPCSTR, dwFlags: DWORD,
-                         lpAccessName: LPCSTR, lpBufferSize: var DWORD,
-                         lpResult: var DWORD): DWORD{.stdcall, dynlib: "mpr",
-    importc: "WNetUseConnectionA".}
-  #function WNetUseConnectionW(hwndOwner: HWND; var lpNetResource: TNetResourceW; lpUserID: LPWSTR; lpPassword: LPWSTR; dwFlags: DWORD; lpAccessName: LPWSTR; var lpBufferSize: DWORD; var lpResult: DWORD): DWORD; stdcall; external 'mpr' name 'WNetUseConnectionW';
-proc WriteConsole*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                   nNumberOfCharsToWrite: DWORD,
-                   lpNumberOfCharsWritten: var DWORD, lpReserved: Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleA".}
-proc WriteConsoleA*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                    nNumberOfCharsToWrite: DWORD,
-                    lpNumberOfCharsWritten: var DWORD, lpReserved: Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleA".}
-proc WriteConsoleInput*(hConsoleInput: THandle, lpBuffer: TInputRecord,
-                        nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".}
-proc WriteConsoleInputA*(hConsoleInput: THandle, lpBuffer: TInputRecord,
-                         nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".}
-proc WriteConsoleInputW*(hConsoleInput: THandle, lpBuffer: TInputRecord,
-                         nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleInputW".}
-proc WriteConsoleOutput*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                         dwBufferSize, dwBufferCoord: TCoord,
-                         lpWriteRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteConsoleOutputA".}
-proc WriteConsoleOutputA*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                          dwBufferSize, dwBufferCoord: TCoord,
-                          lpWriteRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteConsoleOutputA".}
-proc WriteConsoleOutputAttribute*(hConsoleOutput: THandle, lpAttribute: Pointer,
-                                  nLength: DWORD, dwWriteCoord: TCoord,
-                                  lpNumberOfAttrsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputAttribute".}
-proc WriteConsoleOutputCharacter*(hConsoleOutput: THandle, lpCharacter: cstring,
-                                  nLength: DWORD, dwWriteCoord: TCoord,
-                                  lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".}
-proc WriteConsoleOutputCharacterA*(hConsoleOutput: THandle, lpCharacter: LPCSTR,
-                                   nLength: DWORD, dwWriteCoord: TCoord,
-                                   lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".}
-proc WriteConsoleOutputCharacterW*(hConsoleOutput: THandle, lpCharacter: LPWSTR,
-                                   nLength: DWORD, dwWriteCoord: TCoord,
-                                   lpNumberOfCharsWritten: var DWORD): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterW".}
-proc WriteConsoleOutputW*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                          dwBufferSize, dwBufferCoord: TCoord,
-                          lpWriteRegion: var TSmallRect): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteConsoleOutputW".}
-proc WriteConsoleW*(hConsoleOutput: THandle, lpBuffer: Pointer,
-                    nNumberOfCharsToWrite: DWORD,
-                    lpNumberOfCharsWritten: var DWORD, lpReserved: Pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteConsoleW".}
-proc WriteFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToWrite: DWORD,
-                lpNumberOfBytesWritten: var DWORD, lpOverlapped: POverlapped): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteFile".}
-proc WriteFileEx*(hFile: THandle, lpBuffer: Pointer,
-                  nNumberOfBytesToWrite: DWORD, lpOverlapped: TOverlapped,
-                  lpCompletionRoutine: FARPROC): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteFileEx".}
-proc WritePrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID,
-                                 uSizeStruct: UINT, szFile: LPCSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}
-proc WritePrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR,
-                                 lpStruct: LPVOID, uSizeStruct: UINT,
-                                 szFile: LPCWSTR): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WritePrivateProfileStructW".}
-proc WritePrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID,
-                                uSizeStruct: UINT, szFile: LPCTSTR): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".}
-proc WriteProcessMemory*(hProcess: THandle, lpBaseAddress: Pointer,
-                         lpBuffer: Pointer, nSize: DWORD,
-                         lpNumberOfBytesWritten: var DWORD): WINBOOL{.stdcall,
-    dynlib: "kernel32", importc: "WriteProcessMemory".}
-proc SHFileOperation*(para1: var SHFILEOPSTRUCT): int32{.stdcall,
-    dynlib: "shell32", importc: "SHFileOperation".}
-  # these are old Win16 funcs that under win32 are aliases for several char* funcs.
-  # exist under Win32 (even in SDK's from 2002), but are officially "depreciated"
-proc AnsiNext*(lpsz: LPCSTR): LPSTR{.stdcall, dynlib: "user32",
-                                     importc: "CharNextA".}
-proc AnsiPrev*(lpszStart: LPCSTR, lpszCurrent: LPCSTR): LPSTR{.stdcall,
-    dynlib: "user32", importc: "CharPrevA".}
-proc AnsiToOem*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "CharToOemA".}
-proc OemToAnsi*(lpszSrc: LPCSTR, lpszDst: LPSTR): WINBOOL{.stdcall,
-    dynlib: "user32", importc: "OemToCharA".}
-proc AnsiToOemBuff*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "CharToOemBuffA".}
-proc OemToAnsiBuff*(lpszSrc: LPCSTR, lpszDst: LPSTR, cchDstLength: DWORD): WINBOOL{.
-    stdcall, dynlib: "user32", importc: "OemToCharBuffA".}
-proc AnsiUpper*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                     importc: "CharUpperA".}
-proc AnsiUpperBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharUpperBuffA".}
-proc AnsiLower*(lpsz: LPSTR): LPSTR{.stdcall, dynlib: "user32",
-                                     importc: "CharLowerA".}
-proc AnsiLowerBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
-    dynlib: "user32", importc: "CharLowerBuffA".}
-# implementation
-# was #define dname(params) def_expr
-# argument types are unknown
-
-proc GetBValue(rgb: int32): int8 =
-  result = toU8(rgb shr 16'i32)
-
-proc GetGValue(rgb: int32): int8 =
-  result = toU8(rgb shr 8'i32)
-
-proc GetRValue(rgb: int32): int8 =
-  result = toU8(rgb)
-
-proc RGB(r, g, b: int32): DWORD =
-  result = toU8(r) or toU8(g shl 8'i32) or toU8(b shl 16'i32)
-
-proc HIBYTE(w: int32): int8 =
-  result = toU8(w shr 8'i32 and 0x000000FF'i32)
-
-proc HIWORD(L: int32): int16 =
-  result = toU16(L shr 16'i32 and 0x0000FFFF'i32)
-
-proc LOBYTE(w: int32): int8 =
-  result = toU8(w)
-
-proc LOWORD(L: int32): int16 =
-  result = toU16(L)
-
-proc MAKELONG(a, b: int32): LONG =
-  result = a and 0x0000ffff'i32 or b shl 16'i32
-
-proc MAKEWORD(a, b: int32): int16 =
-  result = toU16(a and 0xff'i32) or toU16(b shl 8'i32)
-
-proc SEXT_HIWORD(L: int32): int32 =
-  # return type might be wrong
-  result = HIWORD(L)
-
-proc ZEXT_HIWORD(L: int32): int32 =
-  # return type might be wrong
-  result = ze(HIWORD(L))
-
-proc SEXT_LOWORD(L: int32): int32 =
-  result = LOWORD(L)
-
-proc INDEXTOOVERLAYMASK(i: int32): int32 =
-  # return type might be wrong
-  result = i shl 8'i32
-
-proc INDEXTOSTATEIMAGEMASK(i: int32): int32 =
-  # return type might be wrong
-  result = i shl 12'i32
-
-proc MAKEINTATOM(i: int32): LPTSTR =
-  result = cast[LPTSTR](cast[ULONG_PTR](ToU16(i)))
-
-proc MAKELANGID(p, s: int32): int32 =
-  # return type might be wrong
-  result = toU16(s) shl 10'i16 or toU16(p)
-
-proc PRIMARYLANGID(lgid: int32): int16 =
-  # PRIMARYLANGID:=WORD(lgid(@($3ff)));
-  #         h2pas error here corrected by hand PM
-  result = toU16(lgid) and 0x000003FF'i16
-
-proc SUBLANGID(lgid: int32): int32 =
-  # return type might be wrong
-  result = toU16(lgid) shr 10'i16
-
-proc LANGIDFROMLCID(lcid: int32): int16 =
-  result = toU16(lcid)
-
-proc SORTIDFROMLCID(lcid: int32): int16 =
-  result = toU16((lcid and 0x000FFFFF'i32) shr 16'i32)
-
-proc MAKELCID(lgid, srtid: int32): DWORD =
-  result = toU32(srtid shl 16'i32 or lgid and 0xffff'i32)
-
-proc MAKELPARAM(L, h: int32): LPARAM =
-  result = LPARAM(MAKELONG(L, h))
-
-proc MAKELRESULT(L, h: int32): LRESULT =
-  result = LRESULT(MAKELONG(L, h))
-
-proc MAKEROP4(fore, back: int32): DWORD =
-  result = back shl 8'i32 and 0xFF000000'i32 or fore
-
-proc MAKEWPARAM(L, h: int32): WPARAM =
-  result = WPARAM(MAKELONG(L, h))
-
-proc GET_X_LPARAM(lp: Windows.LParam): int32 =
-  result = int16(LOWORD(lp))
-
-proc GET_Y_LPARAM(lp: Windows.LParam): int32 =
-  result = int16(HIWORD(lp))
-
-proc PALETTEINDEX(i: int32): COLORREF =
-  result = COLORREF(0x01000000'i32 or i and 0xffff'i32)
-
-proc PALETTERGB(r, g, b: int32): int32 =
-  # return type might be wrong
-  result = 0x02000000 or (RGB(r, g, b))
-
-proc UNICODE_NULL(): WCHAR =
-  result = 0'i16
-
-proc IDC_ARROW(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32512)
-
-proc IDC_IBEAM(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32513)
-
-proc IDC_WAIT(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32514)
-
-proc IDC_CROSS(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32515)
-
-proc IDC_UPARROW(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32516)
-
-proc IDC_SIZENWSE(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32642)
-
-proc IDC_SIZENESW(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32643)
-
-proc IDC_SIZEWE(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32644)
-
-proc IDC_SIZENS(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32645)
-
-proc IDC_SIZEALL(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32646)
-
-proc IDC_NO(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32648)
-
-proc IDC_APPSTARTING(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32650)
-
-proc IDC_HELP(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32651)
-
-proc IDI_APPLICATION(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32512)
-
-proc IDI_HAND(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32513)
-
-proc IDI_QUESTION(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32514)
-
-proc IDI_EXCLAMATION(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32515)
-
-proc IDI_ASTERISK(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32516)
-
-proc IDI_WINLOGO(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32517)
-
-proc IDC_SIZE(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32640)
-
-proc IDC_ICON(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32641)
-
-proc IDC_HAND(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](32649)
-
-proc STD_INPUT_HANDLE(): DWORD =
-  result = DWORD(- (10))
-
-proc STD_OUTPUT_HANDLE(): DWORD =
-  result = DWORD(- (11))
-
-proc STD_ERROR_HANDLE(): DWORD =
-  result = DWORD(- (12))
-
-proc HWND_BROADCAST(): HWND =
-  result = HWND(0x0000FFFF)
-
-proc HKEY_CLASSES_ROOT(): HKEY =
-  result = HKEY(0x80000000)
-
-proc HKEY_CURRENT_USER(): HKEY =
-  result = HKEY(0x80000001)
-
-proc HKEY_LOCAL_MACHINE(): HKEY =
-  result = HKEY(0x80000002)
-
-proc HKEY_USERS(): HKEY =
-  result = HKEY(0x80000003)
-
-proc HKEY_PERFORMANCE_DATA(): HKEY =
-  result = HKEY(0x80000004)
-
-proc HKEY_CURRENT_CONFIG(): HKEY =
-  result = HKEY(0x80000005)
-
-proc HKEY_DYN_DATA(): HKEY =
-  result = HKEY(0x80000006)
-
-proc HWND_BOTTOM(): HWND =
-  result = HWND(1)
-
-proc HWND_NOTOPMOST(): HWND =
-  result = HWND(- (2))
-
-proc HWND_TOP(): HWND =
-  result = HWND(0)
-
-proc HWND_TOPMOST(): HWND =
-  result = HWND(- (1))
-
-proc VS_FILE_INFO(): LPTSTR =
-  # return type might be wrong
-  result = cast[MAKEINTRESOURCE](16)
-
-proc HINST_COMMCTRL(): HINST =
-  result = HINST(- (1))
-
-proc LPSTR_TEXTCALLBACKW(): LPWSTR =
-  result = cast[LPWSTR](- (1))
-
-proc LPSTR_TEXTCALLBACKA(): LPSTR =
-  result = cast[LPSTR](- (1))
-
-when defined(winUnicode):
-  #const this is a function in fact !!
-  #     LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKW;
-  proc LPSTR_TEXTCALLBACK(): LPWSTR =
-    result = cast[LPWSTR](- (1))
-
-else:
-  #const
-  #     LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKA;
-  proc LPSTR_TEXTCALLBACK(): LPSTR =
-    result = cast[LPSTR](- (1))
-
-# was #define dname def_expr
-
-proc TVI_ROOT(): HTREEITEM =
-  result = cast[HTREEITEM](0xFFFF0000)
-
-proc TVI_FIRST(): HTREEITEM =
-  result = cast[HTREEITEM](0xFFFF0001)
-
-proc TVI_LAST(): HTREEITEM =
-  result = cast[HTREEITEM](0xFFFF0002)
-
-proc TVI_SORT(): HTREEITEM =
-  result = cast[HTREEITEM](0xFFFF0003)
-
-proc HWND_DESKTOP(): HWND =
-  result = HWND(0)
-
-proc GetFirstChild(h: HWND): HWND =
-  result = GetTopWindow(h)
-
-proc GetNextSibling(h: HWND): HWND =
-  result = GetWindow(h, GW_HWNDNEXT)
-
-proc GetWindowID(h: HWND): int32 =
-  result = GetDlgCtrlID(h)
-
-proc SubclassWindow(h: HWND, p: LONG): LONG =
-  result = SetWindowLong(h, GWL_WNDPROC, p)
-
-proc GET_WM_COMMAND_CMD(w, L: int32): int32 =
-  # return type might be wrong
-  result = HIWORD(w)
-
-proc GET_WM_COMMAND_ID(w, L: int32): int32 =
-  # return type might be wrong
-  result = LOWORD(w)
-
-proc GET_WM_CTLCOLOR_HDC(w, L, msg: int32): HDC =
-  result = HDC(w)
-
-proc GET_WM_CTLCOLOR_HWND(w, L, msg: int32): HWND =
-  result = HWND(L)
-
-proc GET_WM_HSCROLL_CODE(w, L: int32): int32 =
-  # return type might be wrong
-  result = LOWORD(w)
-
-proc GET_WM_HSCROLL_HWND(w, L: int32): HWND =
-  result = HWND(L)
-
-proc GET_WM_HSCROLL_POS(w, L: int32): int32 =
-  # return type might be wrong
-  result = HIWORD(w)
-
-proc GET_WM_MDIACTIVATE_FACTIVATE(h, a, b: int32): int32 =
-  # return type might be wrong
-  result = ord(b == h)
-
-proc GET_WM_MDIACTIVATE_HWNDACTIVATE(a, b: int32): HWND =
-  result = HWND(b)
-
-proc GET_WM_MDIACTIVATE_HWNDDEACT(a, b: int32): HWND =
-  result = HWND(a)
-
-proc GET_WM_VSCROLL_CODE(w, L: int32): int32 =
-  # return type might be wrong
-  result = LOWORD(w)
-
-proc GET_WM_VSCROLL_HWND(w, L: int32): HWND =
-  result = HWND(L)
-
-proc GET_WM_VSCROLL_POS(w, L: int32): int32 =
-  # return type might be wrong
-  result = HIWORD(w)
-
-proc FreeModule(h: HINST): WINBOOL =
-  result = FreeLibrary(h)
-
-proc MakeProcInstance(p, i: int32): int32 =
-  # return type might be wrong
-  result = p
-
-proc FreeProcInstance(p: int32): int32 =
-  # return type might be wrong
-  result = p
-
-proc fBinary(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fBinary) shr bp_DCB_fBinary
-
-proc set_fBinary(a: var DCB, fBinary: DWORD) =
-  a.flags = a.flags or ((fBinary shl bp_DCB_fBinary) and bm_DCB_fBinary)
-
-proc fParity(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fParity) shr bp_DCB_fParity
-
-proc set_fParity(a: var DCB, fParity: DWORD) =
-  a.flags = a.flags or ((fParity shl bp_DCB_fParity) and bm_DCB_fParity)
-
-proc fOutxCtsFlow(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fOutxCtsFlow) shr bp_DCB_fOutxCtsFlow
-
-proc set_fOutxCtsFlow(a: var DCB, fOutxCtsFlow: DWORD) =
-  a.flags = a.flags or
-      ((fOutxCtsFlow shl bp_DCB_fOutxCtsFlow) and bm_DCB_fOutxCtsFlow)
-
-proc fOutxDsrFlow(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fOutxDsrFlow) shr bp_DCB_fOutxDsrFlow
-
-proc set_fOutxDsrFlow(a: var DCB, fOutxDsrFlow: DWORD) =
-  a.flags = a.flags or
-      ((fOutxDsrFlow shl bp_DCB_fOutxDsrFlow) and bm_DCB_fOutxDsrFlow)
-
-proc fDtrControl(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fDtrControl) shr bp_DCB_fDtrControl
-
-proc set_fDtrControl(a: var DCB, fDtrControl: DWORD) =
-  a.flags = a.flags or
-      ((fDtrControl shl bp_DCB_fDtrControl) and bm_DCB_fDtrControl)
-
-proc fDsrSensitivity(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fDsrSensitivity) shr bp_DCB_fDsrSensitivity
-
-proc set_fDsrSensitivity(a: var DCB, fDsrSensitivity: DWORD) =
-  a.flags = a.flags or
-      ((fDsrSensitivity shl bp_DCB_fDsrSensitivity) and
-      bm_DCB_fDsrSensitivity)
-
-proc fTXContinueOnXoff(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fTXContinueOnXoff) shr
-      bp_DCB_fTXContinueOnXoff
-
-proc set_fTXContinueOnXoff(a: var DCB, fTXContinueOnXoff: DWORD) =
-  a.flags = a.flags or
-      ((fTXContinueOnXoff shl bp_DCB_fTXContinueOnXoff) and
-      bm_DCB_fTXContinueOnXoff)
-
-proc fOutX(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fOutX) shr bp_DCB_fOutX
-
-proc set_fOutX(a: var DCB, fOutX: DWORD) =
-  a.flags = a.flags or ((fOutX shl bp_DCB_fOutX) and bm_DCB_fOutX)
-
-proc fInX(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fInX) shr bp_DCB_fInX
-
-proc set_fInX(a: var DCB, fInX: DWORD) =
-  a.flags = a.flags or ((fInX shl bp_DCB_fInX) and bm_DCB_fInX)
-
-proc fErrorChar(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fErrorChar) shr bp_DCB_fErrorChar
-
-proc set_fErrorChar(a: var DCB, fErrorChar: DWORD) =
-  a.flags = a.flags or
-      ((fErrorChar shl bp_DCB_fErrorChar) and bm_DCB_fErrorChar)
-
-proc fNull(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fNull) shr bp_DCB_fNull
-
-proc set_fNull(a: var DCB, fNull: DWORD) =
-  a.flags = a.flags or ((fNull shl bp_DCB_fNull) and bm_DCB_fNull)
-
-proc fRtsControl(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fRtsControl) shr bp_DCB_fRtsControl
-
-proc set_fRtsControl(a: var DCB, fRtsControl: DWORD) =
-  a.flags = a.flags or
-      ((fRtsControl shl bp_DCB_fRtsControl) and bm_DCB_fRtsControl)
-
-proc fAbortOnError(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fAbortOnError) shr bp_DCB_fAbortOnError
-
-proc set_fAbortOnError(a: var DCB, fAbortOnError: DWORD) =
-  a.flags = a.flags or
-      ((fAbortOnError shl bp_DCB_fAbortOnError) and bm_DCB_fAbortOnError)
-
-proc fDummy2(a: var DCB): DWORD =
-  result = (a.flags and bm_DCB_fDummy2) shr bp_DCB_fDummy2
-
-proc set_fDummy2(a: var DCB, fDummy2: DWORD) =
-  a.flags = a.flags or ((fDummy2 shl bp_DCB_fDummy2) and bm_DCB_fDummy2)
-
-proc fCtsHold(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fCtsHold) shr bp_COMSTAT_fCtsHold
-
-proc set_fCtsHold(a: var COMSTAT, fCtsHold: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fCtsHold shl bp_COMSTAT_fCtsHold) and bm_COMSTAT_fCtsHold)
-
-proc fDsrHold(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fDsrHold) shr bp_COMSTAT_fDsrHold
-
-proc set_fDsrHold(a: var COMSTAT, fDsrHold: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fDsrHold shl bp_COMSTAT_fDsrHold) and bm_COMSTAT_fDsrHold)
-
-proc fRlsdHold(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fRlsdHold) shr bp_COMSTAT_fRlsdHold
-
-proc set_fRlsdHold(a: var COMSTAT, fRlsdHold: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fRlsdHold shl bp_COMSTAT_fRlsdHold) and bm_COMSTAT_fRlsdHold)
-
-proc fXoffHold(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fXoffHold) shr bp_COMSTAT_fXoffHold
-
-proc set_fXoffHold(a: var COMSTAT, fXoffHold: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fXoffHold shl bp_COMSTAT_fXoffHold) and bm_COMSTAT_fXoffHold)
-
-proc fXoffSent(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fXoffSent) shr bp_COMSTAT_fXoffSent
-
-proc set_fXoffSent(a: var COMSTAT, fXoffSent: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fXoffSent shl bp_COMSTAT_fXoffSent) and bm_COMSTAT_fXoffSent)
-
-proc fEof(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fEof) shr bp_COMSTAT_fEof
-
-proc set_fEof(a: var COMSTAT, fEof: DWORD) =
-  a.flag0 = a.flag0 or ((fEof shl bp_COMSTAT_fEof) and bm_COMSTAT_fEof)
-
-proc fTxim(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fTxim) shr bp_COMSTAT_fTxim
-
-proc set_fTxim(a: var COMSTAT, fTxim: DWORD) =
-  a.flag0 = a.flag0 or ((fTxim shl bp_COMSTAT_fTxim) and bm_COMSTAT_fTxim)
-
-proc fReserved(a: var COMSTAT): DWORD =
-  result = (a.flag0 and bm_COMSTAT_fReserved) shr bp_COMSTAT_fReserved
-
-proc set_fReserved(a: var COMSTAT, fReserved: DWORD) =
-  a.flag0 = a.flag0 or
-      ((fReserved shl bp_COMSTAT_fReserved) and bm_COMSTAT_fReserved)
-
-proc bAppReturnCode(a: var DDEACK): int16 =
-  result = (a.flag0 and bm_DDEACK_bAppReturnCode) shr
-      bp_DDEACK_bAppReturnCode
-
-proc set_bAppReturnCode(a: var DDEACK, bAppReturnCode: int16) =
-  a.flag0 = a.flag0 or
-      ((bAppReturnCode shl bp_DDEACK_bAppReturnCode) and
-      bm_DDEACK_bAppReturnCode)
-
-proc reserved(a: var DDEACK): int16 =
-  result = (a.flag0 and bm_DDEACK_reserved) shr bp_DDEACK_reserved
-
-proc set_reserved(a: var DDEACK, reserved: int16) =
-  a.flag0 = a.flag0 or
-      ((reserved shl bp_DDEACK_reserved) and bm_DDEACK_reserved)
-
-proc fBusy(a: var DDEACK): int16 =
-  result = (a.flag0 and bm_DDEACK_fBusy) shr bp_DDEACK_fBusy
-
-proc set_fBusy(a: var DDEACK, fBusy: int16) =
-  a.flag0 = a.flag0 or ((fBusy shl bp_DDEACK_fBusy) and bm_DDEACK_fBusy)
-
-proc fAck(a: var DDEACK): int16 =
-  result = (a.flag0 and bm_DDEACK_fAck) shr bp_DDEACK_fAck
-
-proc set_fAck(a: var DDEACK, fAck: int16) =
-  a.flag0 = a.flag0 or ((fAck shl bp_DDEACK_fAck) and bm_DDEACK_fAck)
-
-proc reserved(a: var DDEADVISE): int16 =
-  result = (a.flag0 and bm_DDEADVISE_reserved) shr bp_DDEADVISE_reserved
-
-proc set_reserved(a: var DDEADVISE, reserved: int16) =
-  a.flag0 = a.flag0 or
-      ((reserved shl bp_DDEADVISE_reserved) and bm_DDEADVISE_reserved)
-
-proc fDeferUpd(a: var DDEADVISE): int16 =
-  result = (a.flag0 and bm_DDEADVISE_fDeferUpd) shr bp_DDEADVISE_fDeferUpd
-
-proc set_fDeferUpd(a: var DDEADVISE, fDeferUpd: int16) =
-  a.flag0 = a.flag0 or
-      ((fDeferUpd shl bp_DDEADVISE_fDeferUpd) and bm_DDEADVISE_fDeferUpd)
-
-proc fAckReq(a: var DDEADVISE): int16 =
-  result = (a.flag0 and bm_DDEADVISE_fAckReq) shr bp_DDEADVISE_fAckReq
-
-proc set_fAckReq(a: var DDEADVISE, fAckReq: int16) =
-  a.flag0 = a.flag0 or
-      ((fAckReq shl bp_DDEADVISE_fAckReq) and bm_DDEADVISE_fAckReq)
-
-proc unused(a: var DDEDATA): int16 =
-  result = (a.flag0 and bm_DDEDATA_unused) shr bp_DDEDATA_unused
-
-proc set_unused(a: var DDEDATA, unused: int16) =
-  a.flag0 = a.flag0 or ((unused shl bp_DDEDATA_unused) and bm_DDEDATA_unused)
-
-proc fResponse(a: var DDEDATA): int16 =
-  result = (a.flag0 and bm_DDEDATA_fResponse) shr bp_DDEDATA_fResponse
-
-proc set_fResponse(a: var DDEDATA, fResponse: int16) =
-  a.flag0 = a.flag0 or
-      ((fResponse shl bp_DDEDATA_fResponse) and bm_DDEDATA_fResponse)
-
-proc fRelease(a: var DDEDATA): int16 =
-  result = (a.flag0 and bm_DDEDATA_fRelease) shr bp_DDEDATA_fRelease
-
-proc set_fRelease(a: var DDEDATA, fRelease: int16) =
-  a.flag0 = a.flag0 or
-      ((fRelease shl bp_DDEDATA_fRelease) and bm_DDEDATA_fRelease)
-
-proc reserved(a: var DDEDATA): int16 =
-  result = (a.flag0 and bm_DDEDATA_reserved) shr bp_DDEDATA_reserved
-
-proc set_reserved(a: var DDEDATA, reserved: int16) =
-  a.flag0 = a.flag0 or
-      ((reserved shl bp_DDEDATA_reserved) and bm_DDEDATA_reserved)
-
-proc fAckReq(a: var DDEDATA): int16 =
-  result = (a.flag0 and bm_DDEDATA_fAckReq) shr bp_DDEDATA_fAckReq
-
-proc set_fAckReq(a: var DDEDATA, fAckReq: int16) =
-  a.flag0 = a.flag0 or
-      ((fAckReq shl bp_DDEDATA_fAckReq) and bm_DDEDATA_fAckReq)
-
-proc unused(a: var DDELN): int16 =
-  result = (a.flag0 and bm_DDELN_unused) shr bp_DDELN_unused
-
-proc set_unused(a: var DDELN, unused: int16) =
-  a.flag0 = a.flag0 or ((unused shl bp_DDELN_unused) and bm_DDELN_unused)
-
-proc fRelease(a: var DDELN): int16 =
-  result = (a.flag0 and bm_DDELN_fRelease) shr bp_DDELN_fRelease
-
-proc set_fRelease(a: var DDELN, fRelease: int16) =
-  a.flag0 = a.flag0 or
-      ((fRelease shl bp_DDELN_fRelease) and bm_DDELN_fRelease)
-
-proc fDeferUpd(a: var DDELN): int16 =
-  result = (a.flag0 and bm_DDELN_fDeferUpd) shr bp_DDELN_fDeferUpd
-
-proc set_fDeferUpd(a: var DDELN, fDeferUpd: int16) =
-  a.flag0 = a.flag0 or
-      ((fDeferUpd shl bp_DDELN_fDeferUpd) and bm_DDELN_fDeferUpd)
-
-proc fAckReq(a: var DDELN): int16 =
-  result = (a.flag0 and bm_DDELN_fAckReq) shr bp_DDELN_fAckReq
-
-proc set_fAckReq(a: var DDELN, fAckReq: int16) =
-  a.flag0 = a.flag0 or ((fAckReq shl bp_DDELN_fAckReq) and bm_DDELN_fAckReq)
-
-proc unused(a: var DDEPOKE): int16 =
-  result = (a.flag0 and bm_DDEPOKE_unused) shr bp_DDEPOKE_unused
-
-proc set_unused(a: var DDEPOKE, unused: int16) =
-  a.flag0 = a.flag0 or ((unused shl bp_DDEPOKE_unused) and bm_DDEPOKE_unused)
-
-proc fRelease(a: var DDEPOKE): int16 =
-  result = (a.flag0 and bm_DDEPOKE_fRelease) shr bp_DDEPOKE_fRelease
-
-proc set_fRelease(a: var DDEPOKE, fRelease: int16) =
-  a.flag0 = a.flag0 or
-      ((fRelease shl bp_DDEPOKE_fRelease) and bm_DDEPOKE_fRelease)
-
-proc fReserved(a: var DDEPOKE): int16 =
-  result = (a.flag0 and bm_DDEPOKE_fReserved) shr bp_DDEPOKE_fReserved
-
-proc set_fReserved(a: var DDEPOKE, fReserved: int16) =
-  a.flag0 = a.flag0 or
-      ((fReserved shl bp_DDEPOKE_fReserved) and bm_DDEPOKE_fReserved)
-
-proc unused(a: var DDEUP): int16 =
-  result = (a.flag0 and bm_DDEUP_unused) shr bp_DDEUP_unused
-
-proc set_unused(a: var DDEUP, unused: int16) =
-  a.flag0 = a.flag0 or ((unused shl bp_DDEUP_unused) and bm_DDEUP_unused)
-
-proc fAck(a: var DDEUP): int16 =
-  result = (a.flag0 and bm_DDEUP_fAck) shr bp_DDEUP_fAck
-
-proc set_fAck(a: var DDEUP, fAck: int16) =
-  a.flag0 = a.flag0 or ((fAck shl bp_DDEUP_fAck) and bm_DDEUP_fAck)
-
-proc fRelease(a: var DDEUP): int16 =
-  result = (a.flag0 and bm_DDEUP_fRelease) shr bp_DDEUP_fRelease
-
-proc set_fRelease(a: var DDEUP, fRelease: int16) =
-  a.flag0 = a.flag0 or
-      ((fRelease shl bp_DDEUP_fRelease) and bm_DDEUP_fRelease)
-
-proc fReserved(a: var DDEUP): int16 =
-  result = (a.flag0 and bm_DDEUP_fReserved) shr bp_DDEUP_fReserved
-
-proc set_fReserved(a: var DDEUP, fReserved: int16) =
-  a.flag0 = a.flag0 or
-      ((fReserved shl bp_DDEUP_fReserved) and bm_DDEUP_fReserved)
-
-proc fAckReq(a: var DDEUP): int16 =
-  result = (a.flag0 and bm_DDEUP_fAckReq) shr bp_DDEUP_fAckReq
-
-proc set_fAckReq(a: var DDEUP, fAckReq: int16) =
-  a.flag0 = a.flag0 or ((fAckReq shl bp_DDEUP_fAckReq) and bm_DDEUP_fAckReq)
-
-proc CreateWindowA(lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD,
-                   X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                   hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                   lpParam: LPVOID): HWND =
-  result = CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth,
-                           nHeight, hWndParent, hMenu, hInstance, lpParam)
-
-proc CreateDialogA(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                   lpDialogFunc: DLGPROC): HWND =
-  result = CreateDialogParamA(hInstance, lpTemplateName, hWndParent,
-                              lpDialogFunc, 0)
-
-proc CreateDialogIndirectA(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                           hWndParent: HWND, lpDialogFunc: DLGPROC): HWND =
-  result = CreateDialogIndirectParamA(hInstance, lpTemplate, hWndParent,
-                                      lpDialogFunc, 0)
-
-proc DialogBoxA(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                lpDialogFunc: DLGPROC): int32 =
-  result = DialogBoxParamA(hInstance, lpTemplateName, hWndParent, lpDialogFunc,
-                           0)
-
-proc DialogBoxIndirectA(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                        hWndParent: HWND, lpDialogFunc: DLGPROC): int32 =
-  result = DialogBoxIndirectParamA(hInstance, hDialogTemplate, hWndParent,
-                                   lpDialogFunc, 0)
-
-proc CreateWindowW(lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD,
-                   X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                   hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                   lpParam: LPVOID): HWND =
-  result = CreateWindowExW(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth,
-                           nHeight, hWndParent, hMenu, hInstance, lpParam)
-
-proc CreateDialogW(hInstance: HINST, lpName: LPCWSTR, hWndParent: HWND,
-                   lpDialogFunc: DLGPROC): HWND =
-  result = CreateDialogParamW(hInstance, lpName, hWndParent, lpDialogFunc, 0)
-
-proc CreateDialogIndirectW(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                           hWndParent: HWND, lpDialogFunc: DLGPROC): HWND =
-  result = CreateDialogIndirectParamW(hInstance, lpTemplate, hWndParent,
-                                      lpDialogFunc, 0)
-
-proc DialogBoxW(hInstance: HINST, lpTemplate: LPCWSTR, hWndParent: HWND,
-                lpDialogFunc: DLGPROC): int32 =
-  result = DialogBoxParamW(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0)
-
-proc DialogBoxIndirectW(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                        hWndParent: HWND, lpDialogFunc: DLGPROC): int32 =
-  result = DialogBoxIndirectParamW(hInstance, lpTemplate, hWndParent,
-                                   lpDialogFunc, 0)
-
-when defined(winUnicode):
-  proc CreateWindow(lpClassName: LPCWSTR, lpWindowName: LPCWSTR, dwStyle: DWORD,
-                    X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                    hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                    lpParam: LPVOID): HWND =
-    result = CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth,
-                            nHeight, hWndParent, hMenu, hInstance, lpParam)
-
-  proc CreateDialog(hInstance: HINST, lpName: LPCWSTR, hWndParent: HWND,
-                    lpDialogFunc: DLGPROC): HWND =
-    result = CreateDialogParam(hInstance, lpName, hWndParent, lpDialogFunc, 0)
-
-  proc CreateDialogIndirect(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                            hWndParent: HWND, lpDialogFunc: DLGPROC): HWND =
-    result = CreateDialogIndirectParam(hInstance, lpTemplate, hWndParent,
-                                       lpDialogFunc, 0)
-
-  proc DialogBox(hInstance: HINST, lpTemplate: LPCWSTR, hWndParent: HWND,
-                 lpDialogFunc: DLGPROC): int32 =
-    result = DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0)
-
-  proc DialogBoxIndirect(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC): int32 =
-    result = DialogBoxIndirectParam(hInstance, lpTemplate, hWndParent,
-                                    lpDialogFunc, 0)
-
-else:
-  proc CreateWindow(lpClassName: LPCSTR, lpWindowName: LPCSTR, dwStyle: DWORD,
-                    X: int32, Y: int32, nWidth: int32, nHeight: int32,
-                    hWndParent: HWND, hMenu: HMENU, hInstance: HINST,
-                    lpParam: LPVOID): HWND =
-    result = CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth,
-                            nHeight, hWndParent, hMenu, hInstance, lpParam)
-
-  proc CreateDialog(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                    lpDialogFunc: DLGPROC): HWND =
-    result = CreateDialogParam(hInstance, lpTemplateName, hWndParent,
-                               lpDialogFunc, 0)
-
-  proc CreateDialogIndirect(hInstance: HINST, lpTemplate: LPCDLGTEMPLATE,
-                            hWndParent: HWND, lpDialogFunc: DLGPROC): HWND =
-    result = CreateDialogIndirectParam(hInstance, lpTemplate, hWndParent,
-                                       lpDialogFunc, 0)
-
-  proc DialogBox(hInstance: HINST, lpTemplateName: LPCSTR, hWndParent: HWND,
-                 lpDialogFunc: DLGPROC): int32 =
-    result = DialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc,
-                            0)
-
-  proc DialogBoxIndirect(hInstance: HINST, hDialogTemplate: LPCDLGTEMPLATE,
-                         hWndParent: HWND, lpDialogFunc: DLGPROC): int32 =
-    result = DialogBoxIndirectParam(hInstance, hDialogTemplate, hWndParent,
-                                    lpDialogFunc, 0)
-
-proc GlobalDiscard(hglbMem: HGLOBAL): HGLOBAL =
-  result = GlobalReAlloc(hglbMem, 0, GMEM_MOVEABLE)
-
-proc LocalDiscard(hlocMem: HLOCAL): HLOCAL =
-  result = LocalReAlloc(hlocMem, 0, LMEM_MOVEABLE)
-
-proc GlobalAllocPtr(flags, cb: DWord): Pointer =
-  result = GlobalLock(GlobalAlloc(flags, cb))
-
-proc GlobalFreePtr(lp: Pointer): Pointer =
-  result = cast[Pointer](GlobalFree(cast[HWND](GlobalUnlockPtr(lp))))
-
-proc GlobalUnlockPtr(lp: pointer): Pointer =
-  discard GlobalUnlock(GlobalHandle(lp))
-  result = lp
-
-proc GlobalLockPtr(lp: pointer): Pointer =
-  result = GlobalLock(GlobalHandle(lp))
-
-proc GlobalReAllocPtr(lp: Pointer, cbNew, flags: DWord): Pointer =
-  result = GlobalLock(GlobalReAlloc(cast[HWND](GlobalUnlockPtr(lp)), cbNew, flags))
-
-proc GlobalPtrHandle(lp: pointer): Pointer =
-  result = cast[Pointer](GlobalHandle(lp))
-
-proc ImageList_AddIcon(himl: HIMAGELIST, hicon: HICON): int32 =
-  result = ImageList_ReplaceIcon(himl, - (1), hicon)
-
-proc Animate_Create(hWndP: HWND, id: HMENU, dwStyle: DWORD, hInstance: HINST): HWND =
-  result = CreateWindow(cast[LPCSTR](ANIMATE_CLASS), nil, dwStyle, 0, 0, 0, 0, hwndP,
-                        id, hInstance, nil)
-
-proc Animate_Open(hwnd: HWND, szName: LPTSTR): LRESULT =
-  result = SendMessage(hwnd, ACM_OPEN, 0, cast[LPARAM](szName))
-
-proc Animate_Play(hwnd: HWND, `from`, `to`: int32, rep: UINT): LRESULT =
-  result = SendMessage(hwnd, ACM_PLAY, WPARAM(rep),
-                       LPARAM(MAKELONG(`from`, `to`)))
-
-proc Animate_Stop(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, ACM_STOP, 0, 0)
-
-proc Animate_Close(hwnd: HWND): LRESULT =
-  result = Animate_Open(hwnd, nil)
-
-proc Animate_Seek(hwnd: HWND, frame: int32): LRESULT =
-  result = Animate_Play(hwnd, frame, frame, 1)
-
-proc PropSheet_AddPage(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_ADDPAGE, 0, cast[LPARAM](hpage))
-
-proc PropSheet_Apply(hPropSheetDlg: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_APPLY, 0, 0)
-
-proc PropSheet_CancelToClose(hPropSheetDlg: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_CANCELTOCLOSE, 0, 0)
-
-proc PropSheet_Changed(hPropSheetDlg, hwndPage: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_CHANGED, WPARAM(hwndPage), 0)
-
-proc PropSheet_GetCurrentPageHwnd(hDlg: HWND): LRESULT =
-  result = SendMessage(hDlg, PSM_GETCURRENTPAGEHWND, 0, 0)
-
-proc PropSheet_GetTabControl(hPropSheetDlg: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_GETTABCONTROL, 0, 0)
-
-proc PropSheet_IsDialogMessage(hDlg: HWND, pMsg: int32): LRESULT =
-  result = SendMessage(hDlg, PSM_ISDIALOGMESSAGE, 0, LPARAM(pMsg))
-
-proc PropSheet_PressButton(hPropSheetDlg: HWND, iButton: int32): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_PRESSBUTTON, WPARAM(int32(iButton)), 0)
-
-proc PropSheet_QuerySiblings(hPropSheetDlg: HWND, param1, param2: int32): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_QUERYSIBLINGS, WPARAM(param1),
-                       LPARAM(param2))
-
-proc PropSheet_RebootSystem(hPropSheetDlg: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_REBOOTSYSTEM, 0, 0)
-
-proc PropSheet_RemovePage(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE,
-                          index: int32): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_REMOVEPAGE, WPARAM(index),
-                       cast[LPARAM](hpage))
-
-proc PropSheet_RestartWindows(hPropSheetDlg: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_RESTARTWINDOWS, 0, 0)
-
-proc PropSheet_SetCurSel(hPropSheetDlg: HWND, hpage: HPROPSHEETPAGE,
-                         index: int32): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_SETCURSEL, WPARAM(index),
-                       cast[LPARAM](hpage))
-
-proc PropSheet_SetCurSelByID(hPropSheetDlg: HWND, id: int32): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_SETCURSELID, 0, LPARAM(id))
-
-proc PropSheet_SetFinishText(hPropSheetDlg: HWND, lpszText: LPTSTR): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_SETFINISHTEXT, 0, cast[LPARAM](lpszText))
-
-proc PropSheet_SetTitle(hPropSheetDlg: HWND, dwStyle: DWORD, lpszText: LPCTSTR): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_SETTITLE, WPARAM(dwStyle),
-                       cast[LPARAM](lpszText))
-
-proc PropSheet_SetWizButtons(hPropSheetDlg: HWND, dwFlags: DWORD): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_SETWIZBUTTONS, 0, LPARAM(dwFlags))
-
-proc PropSheet_UnChanged(hPropSheetDlg: HWND, hwndPage: HWND): LRESULT =
-  result = SendMessage(hPropSheetDlg, PSM_UNCHANGED, WPARAM(hwndPage), 0)
-
-proc Header_DeleteItem(hwndHD: HWND, index: int32): WINBOOL =
-  result = WINBOOL(SendMessage(hwndHD, HDM_DELETEITEM, WPARAM(index), 0))
-
-proc Header_GetItem(hwndHD: HWND, index: int32, hdi: var HD_ITEM): WINBOOL =
-  result = WINBOOL(SendMessage(hwndHD, HDM_GETITEM, WPARAM(index),
-                               cast[LPARAM](addr(hdi))))
-
-proc Header_GetItemCount(hwndHD: HWND): int32 =
-  result = int32(SendMessage(hwndHD, HDM_GETITEMCOUNT, 0, 0))
-
-proc Header_InsertItem(hwndHD: HWND, index: int32, hdi: var HD_ITEM): int32 =
-  result = int32(SendMessage(hwndHD, HDM_INSERTITEM, WPARAM(index),
-                             cast[LPARAM](addr(hdi))))
-
-proc Header_Layout(hwndHD: HWND, layout: var HD_LAYOUT): WINBOOL =
-  result = WINBOOL(SendMessage(hwndHD, HDM_LAYOUT, 0,
-                   cast[LPARAM](addr(layout))))
-
-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 =
-  result = SendMessage(hwndLV, LVM_ARRANGE, WPARAM(code), 0)
-
-proc ListView_CreateDragImage(hwnd: HWND, i: int32, lpptUpLeft: LPPOINT): LRESULT =
-  result = SendMessage(hwnd, LVM_CREATEDRAGIMAGE, WPARAM(i), cast[LPARAM](lpptUpLeft))
-
-proc ListView_DeleteAllItems(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0)
-
-proc ListView_DeleteColumn(hwnd: HWND, iCol: int32): LRESULT =
-  result = SendMessage(hwnd, LVM_DELETECOLUMN, WPARAM(iCol), 0)
-
-proc ListView_DeleteItem(hwnd: HWND, iItem: int32): LRESULT =
-  result = SendMessage(hwnd, LVM_DELETEITEM, WPARAM(iItem), 0)
-
-proc ListView_EditLabel(hwndLV: HWND, i: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_EDITLABEL, WPARAM(int32(i)), 0)
-
-proc ListView_EnsureVisible(hwndLV: HWND, i, fPartialOK: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_ENSUREVISIBLE, WPARAM(i),
-                       MAKELPARAM(fPartialOK, 0))
-
-proc ListView_FindItem(hwnd: HWND, iStart: int32, lvfi: var LV_FINDINFO): int32 =
-  result = SendMessage(hwnd, LVM_FINDITEM, WPARAM(iStart), cast[LPARAM](addr(lvfi)))
-
-proc ListView_GetBkColor(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_GETBKCOLOR, 0, 0)
-
-proc ListView_GetCallbackMask(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_GETCALLBACKMASK, 0, 0)
-
-proc ListView_GetColumn(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT =
-  result = SendMessage(hwnd, LVM_GETCOLUMN, WPARAM(iCol), cast[LPARAM](addr(col)))
-
-proc ListView_GetColumnWidth(hwnd: HWND, iCol: int32): LRESULT =
-  result = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, WPARAM(iCol), 0)
-
-proc ListView_GetCountPerPage(hwndLV: HWND): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETCOUNTPERPAGE, 0, 0)
-
-proc ListView_GetEditControl(hwndLV: HWND): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETEDITCONTROL, 0, 0)
-
-proc ListView_GetImageList(hwnd: HWND, iImageList: wINT): LRESULT =
-  result = SendMessage(hwnd, LVM_GETIMAGELIST, WPARAM(iImageList), 0)
-
-proc ListView_GetISearchString(hwndLV: HWND, lpsz: LPTSTR): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETISEARCHSTRING, 0, cast[LPARAM](lpsz))
-
-proc ListView_GetItem(hwnd: HWND, item: var LV_ITEM): LRESULT =
-  result = SendMessage(hwnd, LVM_GETITEM, 0, cast[LPARAM](addr(item)))
-
-proc ListView_GetItemCount(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0)
-
-proc ListView_GetItemPosition(hwndLV: HWND, i: int32, pt: var POINT): int32 =
-  result = SendMessage(hwndLV, LVM_GETITEMPOSITION, WPARAM(int32(i)),
-                       cast[LPARAM](addr(pt)))
-
-proc ListView_GetItemSpacing(hwndLV: HWND, fSmall: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETITEMSPACING, fSmall, 0)
-
-proc ListView_GetItemState(hwndLV: HWND, i, mask: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETITEMSTATE, WPARAM(i), LPARAM(mask))
-
-proc ListView_GetNextItem(hwnd: HWND, iStart, flags: int32): LRESULT =
-  result = SendMessage(hwnd, LVM_GETNEXTITEM, WPARAM(iStart), LPARAM(flags))
-
-proc ListView_GetOrigin(hwndLV: HWND, pt: var POINT): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETORIGIN, WPARAM(0), cast[LPARAM](addr(pt)))
-
-proc ListView_GetSelectedCount(hwndLV: HWND): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETSELECTEDCOUNT, 0, 0)
-
-proc ListView_GetStringWidth(hwndLV: HWND, psz: LPCTSTR): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETSTRINGWIDTH, 0, cast[LPARAM](psz))
-
-proc ListView_GetTextBkColor(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_GETTEXTBKCOLOR, 0, 0)
-
-proc ListView_GetTextColor(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, LVM_GETTEXTCOLOR, 0, 0)
-
-proc ListView_GetTopIndex(hwndLV: HWND): LRESULT =
-  result = SendMessage(hwndLV, LVM_GETTOPINDEX, 0, 0)
-
-proc ListView_GetViewRect(hwnd: HWND, rc: var RECT): LRESULT =
-  result = SendMessage(hwnd, LVM_GETVIEWRECT, 0, cast[LPARAM](addr(rc)))
-
-proc ListView_HitTest(hwndLV: HWND, info: var LV_HITTESTINFO): LRESULT =
-  result = SendMessage(hwndLV, LVM_HITTEST, 0, cast[LPARAM](addr(info)))
-
-proc ListView_InsertColumn(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT =
-  result = SendMessage(hwnd, LVM_INSERTCOLUMN, WPARAM(iCol), cast[LPARAM](addr(col)))
-
-proc ListView_InsertItem(hwnd: HWND, item: var LV_ITEM): LRESULT =
-  result = SendMessage(hwnd, LVM_INSERTITEM, 0, cast[LPARAM](addr(item)))
-
-proc ListView_RedrawItems(hwndLV: HWND, iFirst, iLast: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_REDRAWITEMS, WPARAM(iFirst), LPARAM(iLast))
-
-proc ListView_Scroll(hwndLV: HWND, dx, dy: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_SCROLL, WPARAM(dx), LPARAM(dy))
-
-proc ListView_SetBkColor(hwnd: HWND, clrBk: COLORREF): LRESULT =
-  result = SendMessage(hwnd, LVM_SETBKCOLOR, 0, LPARAM(clrBk))
-
-proc ListView_SetCallbackMask(hwnd: HWND, mask: UINT): LRESULT =
-  result = SendMessage(hwnd, LVM_SETCALLBACKMASK, WPARAM(mask), 0)
-
-proc ListView_SetColumn(hwnd: HWND, iCol: int32, col: var LV_COLUMN): LRESULT =
-  result = SendMessage(hwnd, LVM_SETCOLUMN, WPARAM(iCol), cast[LPARAM](addr(col)))
-
-proc ListView_SetColumnWidth(hwnd: HWND, iCol, cx: int32): LRESULT =
-  result = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, WPARAM(iCol), MAKELPARAM(cx, 0))
-
-proc ListView_SetImageList(hwnd: HWND, himl: int32, iImageList: HIMAGELIST): LRESULT =
-  result = SendMessage(hwnd, LVM_SETIMAGELIST, WPARAM(iImageList),
-                       LPARAM(UINT(himl)))
-
-proc ListView_SetItem(hwnd: HWND, item: var LV_ITEM): LRESULT =
-  result = SendMessage(hwnd, LVM_SETITEM, 0, cast[LPARAM](addr(item)))
-
-proc ListView_SetItemCount(hwndLV: HWND, cItems: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_SETITEMCOUNT, WPARAM(cItems), 0)
-
-proc ListView_SetItemPosition(hwndLV: HWND, i, x, y: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_SETITEMPOSITION, WPARAM(i), MAKELPARAM(x, y))
-
-proc ListView_SetItemPosition32(hwndLV: HWND, i, x, y: int32): LRESULT =
-  var ptNewPos: POINT
-  ptNewPos.x = x
-  ptNewPos.y = y
-  result = SendMessage(hwndLV, LVM_SETITEMPOSITION32, WPARAM(i),
-                       cast[LPARAM](addr(ptNewPos)))
-
-proc ListView_SetItemState(hwndLV: HWND, i, data, mask: int32): LRESULT =
-  var gnu_lvi: LV_ITEM
-  gnu_lvi.stateMask = mask
-  gnu_lvi.state = data
-  result = SendMessage(hwndLV, LVM_SETITEMSTATE, WPARAM(i),
-                       cast[LPARAM](addr(gnu_lvi)))
-
-proc ListView_SetItemText(hwndLV: HWND, i, iSubItem: int32, 
-                          pszText: LPTSTR): LRESULT =
-  var gnu_lvi: LV_ITEM
-  gnu_lvi.iSubItem = iSubItem
-  gnu_lvi.pszText = pszText
-  result = SendMessage(hwndLV, LVM_SETITEMTEXT, WPARAM(i),
-                       cast[LPARAM](addr(gnu_lvi)))
-
-proc ListView_SetTextBkColor(hwnd: HWND, clrTextBk: COLORREF): LRESULT =
-  result = SendMessage(hwnd, LVM_SETTEXTBKCOLOR, 0, LPARAM(clrTextBk))
-
-proc ListView_SetTextColor(hwnd: HWND, clrText: COLORREF): LRESULT =
-  result = SendMessage(hwnd, LVM_SETTEXTCOLOR, 0, LPARAM(clrText))
-
-proc ListView_SortItems(hwndLV: HWND, pfnCompare: PFNLVCOMPARE, 
-                        lPrm: LPARAM): LRESULT =
-  result = SendMessage(hwndLV, LVM_SORTITEMS, WPARAM(lPrm), 
-                       cast[LPARAM](pfnCompare))
-
-proc ListView_Update(hwndLV: HWND, i: int32): LRESULT =
-  result = SendMessage(hwndLV, LVM_UPDATE, WPARAM(i), 0)
-
-proc TreeView_InsertItem(hwnd: HWND, lpis: LPTV_INSERTSTRUCT): LRESULT =
-  result = SendMessage(hwnd, TVM_INSERTITEM, 0, cast[LPARAM](lpis))
-
-proc TreeView_DeleteItem(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = SendMessage(hwnd, TVM_DELETEITEM, 0, cast[LPARAM](hitem))
-
-proc TreeView_DeleteAllItems(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TVM_DELETEITEM, 0, cast[LPARAM](TVI_ROOT))
-
-proc TreeView_Expand(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_EXPAND, WPARAM(code), cast[LPARAM](hitem))
-
-proc TreeView_GetCount(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TVM_GETCOUNT, 0, 0)
-
-proc TreeView_GetIndent(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TVM_GETINDENT, 0, 0)
-
-proc TreeView_SetIndent(hwnd: HWND, indent: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_SETINDENT, WPARAM(indent), 0)
-
-proc TreeView_GetImageList(hwnd: HWND, iImage: WPARAM): LRESULT =
-  result = SendMessage(hwnd, TVM_GETIMAGELIST, iImage, 0)
-
-proc TreeView_SetImageList(hwnd: HWND, himl: HIMAGELIST, iImage: WPARAM): LRESULT =
-  result = SendMessage(hwnd, TVM_SETIMAGELIST, iImage, LPARAM(UINT(himl)))
-
-proc TreeView_GetNextItem(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_GETNEXTITEM, WPARAM(code), cast[LPARAM](hitem))
-
-proc TreeView_GetChild(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_CHILD)
-
-proc TreeView_GetNextSibling(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_NEXT)
-
-proc TreeView_GetPrevSibling(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUS)
-
-proc TreeView_GetParent(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_PARENT)
-
-proc TreeView_GetFirstVisible(hwnd: HWND): LRESULT =
-  result = TreeView_GetNextItem(hwnd, HTREEITEM(nil), TVGN_FIRSTVISIBLE)
-
-proc TreeView_GetNextVisible(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_NEXTVISIBLE)
-
-proc TreeView_GetPrevVisible(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUSVISIBLE)
-
-proc TreeView_GetSelection(hwnd: HWND): LRESULT =
-  result = TreeView_GetNextItem(hwnd, HTREEITEM(nil), TVGN_CARET)
-
-proc TreeView_GetDropHilight(hwnd: HWND): LRESULT =
-  result = TreeView_GetNextItem(hwnd, HTREEITEM(nil), TVGN_DROPHILITE)
-
-proc TreeView_GetRoot(hwnd: HWND): LRESULT =
-  result = TreeView_GetNextItem(hwnd, HTREEITEM(nil), TVGN_ROOT)
-
-proc TreeView_Select(hwnd: HWND, hitem: HTREEITEM, code: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_SELECTITEM, WPARAM(code), cast[LPARAM](hitem))
-
-proc TreeView_SelectItem(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_Select(hwnd, hitem, TVGN_CARET)
-
-proc TreeView_SelectDropTarget(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_Select(hwnd, hitem, TVGN_DROPHILITE)
-
-proc TreeView_SelectSetFirstVisible(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = TreeView_Select(hwnd, hitem, TVGN_FIRSTVISIBLE)
-
-proc TreeView_GetItem(hwnd: HWND, item: var TV_ITEM): LRESULT =
-  result = SendMessage(hwnd, TVM_GETITEM, 0, cast[LPARAM](addr(item)))
-
-proc TreeView_SetItem(hwnd: HWND, item: var TV_ITEM): LRESULT =
-  result = SendMessage(hwnd, TVM_SETITEM, 0, cast[LPARAM](addr(item)))
-
-proc TreeView_EditLabel(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  Result = SendMessage(hwnd, TVM_EDITLABEL, 0, cast[LPARAM](hitem))
-
-proc TreeView_GetEditControl(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TVM_GETEDITCONTROL, 0, 0)
-
-proc TreeView_GetVisibleCount(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TVM_GETVISIBLECOUNT, 0, 0)
-
-proc TreeView_HitTest(hwnd: HWND, lpht: LPTV_HITTESTINFO): LRESULT =
-  result = SendMessage(hwnd, TVM_HITTEST, 0, cast[LPARAM](lpht))
-
-proc TreeView_CreateDragImage(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = SendMessage(hwnd, TVM_CREATEDRAGIMAGE, 0, cast[LPARAM](hitem))
-
-proc TreeView_SortChildren(hwnd: HWND, hitem: HTREEITEM, recurse: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_SORTCHILDREN, WPARAM(recurse), cast[LPARAM](hitem))
-
-proc TreeView_EnsureVisible(hwnd: HWND, hitem: HTREEITEM): LRESULT =
-  result = SendMessage(hwnd, TVM_ENSUREVISIBLE, 0, cast[LPARAM](hitem))
-
-proc TreeView_SortChildrenCB(hwnd: HWND, psort: LPTV_SORTCB, recurse: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_SORTCHILDRENCB, WPARAM(recurse), cast[LPARAM](psort))
-
-proc TreeView_EndEditLabelNow(hwnd: HWND, fCancel: int32): LRESULT =
-  result = SendMessage(hwnd, TVM_ENDEDITLABELNOW, WPARAM(fCancel), 0)
-
-proc TreeView_GetISearchString(hwndTV: HWND, lpsz: LPTSTR): LRESULT =
-  result = SendMessage(hwndTV, TVM_GETISEARCHSTRING, 0, cast[LPARAM](lpsz))
-
-proc TabCtrl_GetImageList(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETIMAGELIST, 0, 0)
-
-proc TabCtrl_SetImageList(hwnd: HWND, himl: HIMAGELIST): LRESULT =
-  result = SendMessage(hwnd, TCM_SETIMAGELIST, 0, LPARAM(UINT(himl)))
-
-proc TabCtrl_GetItemCount(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETITEMCOUNT, 0, 0)
-
-proc TabCtrl_GetItem(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT =
-  result = SendMessage(hwnd, TCM_GETITEM, WPARAM(iItem), cast[LPARAM](addr(item)))
-
-proc TabCtrl_SetItem(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT =
-  result = SendMessage(hwnd, TCM_SETITEM, WPARAM(iItem), cast[LPARAM](addr(item)))
-
-proc TabCtrl_InsertItem(hwnd: HWND, iItem: int32, item: var TC_ITEM): LRESULT =
-  result = SendMessage(hwnd, TCM_INSERTITEM, WPARAM(iItem), cast[LPARAM](addr(item)))
-
-proc TabCtrl_DeleteItem(hwnd: HWND, i: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_DELETEITEM, WPARAM(i), 0)
-
-proc TabCtrl_DeleteAllItems(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_DELETEALLITEMS, 0, 0)
-
-proc TabCtrl_GetItemRect(hwnd: HWND, i: int32, rc: var RECT): LRESULT =
-  result = SendMessage(hwnd, TCM_GETITEMRECT, WPARAM(int32(i)), cast[LPARAM](addr(rc)))
-
-proc TabCtrl_GetCurSel(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETCURSEL, 0, 0)
-
-proc TabCtrl_SetCurSel(hwnd: HWND, i: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_SETCURSEL, WPARAM(i), 0)
-
-proc TabCtrl_HitTest(hwndTC: HWND, info: var TC_HITTESTINFO): LRESULT =
-  result = SendMessage(hwndTC, TCM_HITTEST, 0, cast[LPARAM](addr(info)))
-
-proc TabCtrl_SetItemExtra(hwndTC: HWND, cb: int32): LRESULT =
-  result = SendMessage(hwndTC, TCM_SETITEMEXTRA, WPARAM(cb), 0)
-
-proc TabCtrl_AdjustRect(hwnd: HWND, bLarger: WINBOOL, rc: var RECT): LRESULT =
-  result = SendMessage(hwnd, TCM_ADJUSTRECT, WPARAM(bLarger), cast[LPARAM](addr(rc)))
-
-proc TabCtrl_SetItemSize(hwnd: HWND, x, y: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_SETITEMSIZE, 0, MAKELPARAM(x, y))
-
-proc TabCtrl_RemoveImage(hwnd: HWND, i: WPARAM): LRESULT =
-  result = SendMessage(hwnd, TCM_REMOVEIMAGE, i, 0)
-
-proc TabCtrl_SetPadding(hwnd: HWND, cx, cy: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_SETPADDING, 0, MAKELPARAM(cx, cy))
-
-proc TabCtrl_GetRowCount(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETROWCOUNT, 0, 0)
-
-proc TabCtrl_GetToolTips(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETTOOLTIPS, 0, 0)
-
-proc TabCtrl_SetToolTips(hwnd: HWND, hwndTT: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_SETTOOLTIPS, WPARAM(hwndTT), 0)
-
-proc TabCtrl_GetCurFocus(hwnd: HWND): LRESULT =
-  result = SendMessage(hwnd, TCM_GETCURFOCUS, 0, 0)
-
-proc TabCtrl_SetCurFocus(hwnd: HWND, i: int32): LRESULT =
-  result = SendMessage(hwnd, TCM_SETCURFOCUS, i, 0)
-
-proc SNDMSG(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT =
-  result = SendMessage(hWnd, Msg, wParam, lParam)
-
-proc CommDlg_OpenSave_GetSpecA(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETSPEC, WPARAM(cbmax), cast[LPARAM](psz))
-
-proc CommDlg_OpenSave_GetSpecW(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETSPEC, WPARAM(cbmax), cast[LPARAM](psz))
-
-when not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetSpec(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETSPEC, WPARAM(cbmax), cast[LPARAM](psz))
-
-else:
-  proc CommDlg_OpenSave_GetSpec(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETSPEC, WPARAM(cbmax), cast[LPARAM](psz))
-
-proc CommDlg_OpenSave_GetFilePathA(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETFILEPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-proc CommDlg_OpenSave_GetFilePathW(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETFILEPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-when not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetFilePath(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETFILEPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-else:
-  proc CommDlg_OpenSave_GetFilePath(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETFILEPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-proc CommDlg_OpenSave_GetFolderPathA(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETFOLDERPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-proc CommDlg_OpenSave_GetFolderPathW(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETFOLDERPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-when not(defined(winUnicode)):
-  proc CommDlg_OpenSave_GetFolderPath(hdlg: HWND, psz: LPSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETFOLDERPATH, WPARAM(cbmax), cast[LPARAM](psz))
-
-else:
-  proc CommDlg_OpenSave_GetFolderPath(hdlg: HWND, psz: LPWSTR, cbmax: int32): LRESULT =
-    result = SNDMSG(hdlg, CDM_GETFOLDERPATH, WPARAM(cbmax), cast[LPARAM]((psz)))
-
-proc CommDlg_OpenSave_GetFolderIDList(hdlg: HWND, pidl: LPVOID, cbmax: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_GETFOLDERIDLIST, WPARAM(cbmax), cast[LPARAM](pidl))
-
-proc CommDlg_OpenSave_SetControlText(hdlg: HWND, id: int32, text: LPSTR): LRESULT =
-  result = SNDMSG(hdlg, CDM_SETCONTROLTEXT, WPARAM(id), cast[LPARAM](text))
-
-proc CommDlg_OpenSave_HideControl(hdlg: HWND, id: int32): LRESULT =
-  result = SNDMSG(hdlg, CDM_HIDECONTROL, WPARAM(id), 0)
-
-proc CommDlg_OpenSave_SetDefExt(hdlg: HWND, pszext: LPSTR): LRESULT =
-  result = SNDMSG(hdlg, CDM_SETDEFEXT, 0, cast[LPARAM](pszext))
-
-proc InternalGetLargestConsoleWindowSize(hConsoleOutput: HANDLE): DWord{.
-    stdcall, dynlib: "kernel32", importc: "GetLargestConsoleWindowSize".}
-proc GetLargestConsoleWindowSize(hConsoleOutput: HANDLE): COORD =
-  var res: dword
-  res = InternalGetLargestConsoleWindowSize(hConsoleOutput)
-  result.y = toU16(res and 0x0000ffff) # XXX: correct?
-  result.x = toU16(res shr 16)
-
-proc Succeeded(Status: HRESULT): WINBOOL =
-  result = (Status and 0x80000000'i32)
-
-proc Failed(Status: HRESULT): WINBOOL =
-  result = (Status and 0x80000000'i32)
-
-proc IsError(Status: HRESULT): WINBOOL =
-  result = ord((int(Status) shr 31) == SEVERITY_ERROR)
-
-proc HResultCode(hr: HRESULT): int32 =
-  result = hr and 0x0000FFFF'i32
-
-proc HResultFacility(hr: HRESULT): int32 =
-  result = (hr shr 16'i32) and 0x00001FFF'i32
-
-proc HResultSeverity(hr: HRESULT): int32 =
-  result = (hr shr 31'i32) and 0x00000001'i32
-
-proc MakeResult(p1, p2, mask: int32): HRESULT =
-  result = (p1 shl 31'i32) or (p2 shl 16'i32) or mask
-
-proc HResultFromWin32(x: int32): HRESULT =
-  result = x
-  if result != 0'i32:
-    result = ((result and 0x0000FFFF'i32) or (int32(FACILITY_WIN32) shl 16'i32) or
-        0x80000000'i32)
-
-proc HResultFromNT(x: int32): HRESULT =
-  result = x or int32(FACILITY_NT_BIT)
-
-proc MAKELANGID(PrimaryLang, SubLang: USHORT): int16 =
-  result = (SubLang shl 10'i16) or PrimaryLang
-
-proc PRIMARYLANGID(LangId: int16): int16 =
-  result = LangId and 0x000003FF'i16
-
-proc SUBLANGID(LangId: int16): int16 =
-  result = LangId shr 10'i16
-
-proc MAKELCID(LangId, SortId: int16): DWORD =
-  result = toU32((ze(SortId) shl 16) or ze(LangId))
-
-proc MAKESORTLCID(LangId, SortId, SortVersion: int16): DWORD =
-  result = MAKELCID(LangId, SortId) or int(SortVersion shl 20'i32)
-
-proc LANGIDFROMLCID(LocaleId: LCID): int16 =
-  result = toU16(LocaleId)
-
-proc SORTIDFROMLCID(LocaleId: LCID): int16 =
-  result = toU16((DWORD(LocaleId) shr 16) and 0x0000000F)
-
-proc SORTVERSIONFROMLCID(LocaleId: LCID): int16 =
-  result = toU16((DWORD(LocaleId) shr 20) and 0x0000000F)
-
-proc LANG_SYSTEM_DEFAULT(): int16 =
-  result = toU16(MAKELANGID(toU16(LANG_NEUTRAL), SUBLANG_SYS_DEFAULT))
-
-proc LANG_USER_DEFAULT(): int16 =
-  result = toU16(MAKELANGID(toU16(LANG_NEUTRAL), SUBLANG_DEFAULT))
-
-proc LOCALE_NEUTRAL(): DWORD =
-  result = MAKELCID(MAKELANGID(toU16(LANG_NEUTRAL), SUBLANG_NEUTRAL), SORT_DEFAULT)
-
-proc LOCALE_INVARIANT(): DWORD =
-  result = MAKELCID(MAKELANGID(toU16(LANG_INVARIANT), SUBLANG_NEUTRAL), SORT_DEFAULT)
diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim
index 10915272f..79681376b 100755..100644
--- a/lib/windows/winlean.nim
+++ b/lib/windows/winlean.nim
@@ -1,25 +1,53 @@
 #
 #
-#            Nimrod's Runtime Library
-#        (c) Copyright 2010 Andreas Rumpf
+#            Nim's Runtime Library
+#        (c) Copyright 2012 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
 ## This module implements a small wrapper for some needed Win API procedures,
-## so that the Nimrod compiler does not depend on the huge Windows module.
+## so that the Nim compiler does not depend on the huge Windows module.
 
+import std/dynlib
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+{.passc: "-DWIN32_LEAN_AND_MEAN".}
+
+when defined(nimPreviewSlimSystem):
+  from std/syncio import FileHandle
+  import std/widestrs
+
+type WinChar* = Utf16Char
+
+# See https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types
 type
-  THandle* = int
+  Handle* = int
+  LONG* = int32
+  ULONG* = int32
+  PULONG* = ptr int
   WINBOOL* = int32
+    ## `WINBOOL` uses opposite convention as posix, !=0 meaning success.
+    # xxx this should be distinct int32, distinct would make code less error prone
+  PBOOL* = ptr WINBOOL
+  DWORD* = int32
+  PDWORD* = ptr DWORD
+  LPINT* = ptr int32
+  ULONG_PTR* = uint
+  PULONG_PTR* = ptr uint
+  HDC* = Handle
+  HGLRC* = Handle
+  BYTE* = uint8
 
-  TSECURITY_ATTRIBUTES* {.final, pure.} = object
+  SECURITY_ATTRIBUTES* = object
     nLength*: int32
     lpSecurityDescriptor*: pointer
     bInheritHandle*: WINBOOL
-  
-  TSTARTUPINFO* {.final, pure.} = object
+
+  STARTUPINFO* = object
     cb*: int32
     lpReserved*: cstring
     lpDesktop*: cstring
@@ -35,16 +63,46 @@ type
     wShowWindow*: int16
     cbReserved2*: int16
     lpReserved2*: pointer
-    hStdInput*: THANDLE
-    hStdOutput*: THANDLE
-    hStdError*: THANDLE
+    hStdInput*: Handle
+    hStdOutput*: Handle
+    hStdError*: Handle
 
-  TPROCESS_INFORMATION* {.final, pure.} = object
-    hProcess*: THANDLE
-    hThread*: THANDLE
+  PROCESS_INFORMATION* = object
+    hProcess*: Handle
+    hThread*: Handle
     dwProcessId*: int32
     dwThreadId*: int32
 
+  FILETIME* = object ## CANNOT BE int64 BECAUSE OF ALIGNMENT
+    dwLowDateTime*: DWORD
+    dwHighDateTime*: DWORD
+
+  BY_HANDLE_FILE_INFORMATION* = object
+    dwFileAttributes*: DWORD
+    ftCreationTime*: FILETIME
+    ftLastAccessTime*: FILETIME
+    ftLastWriteTime*: FILETIME
+    dwVolumeSerialNumber*: DWORD
+    nFileSizeHigh*: DWORD
+    nFileSizeLow*: DWORD
+    nNumberOfLinks*: DWORD
+    nFileIndexHigh*: DWORD
+    nFileIndexLow*: DWORD
+
+  OSVERSIONINFO* = object
+    dwOSVersionInfoSize*: DWORD
+    dwMajorVersion*: DWORD
+    dwMinorVersion*: DWORD
+    dwBuildNumber*: DWORD
+    dwPlatformId*: DWORD
+    szCSDVersion*: array[0..127, WinChar]
+
+  Protoent* = object
+    p_name*: cstring
+    p_aliases*: cstringArray
+    p_proto*: cshort
+
+
 const
   STARTF_USESHOWWINDOW* = 1'i32
   STARTF_USESTDHANDLES* = 256'i32
@@ -52,101 +110,180 @@ const
   IDLE_PRIORITY_CLASS* = 64'i32
   NORMAL_PRIORITY_CLASS* = 32'i32
   REALTIME_PRIORITY_CLASS* = 256'i32
+  WAIT_OBJECT_0* = 0'i32
   WAIT_TIMEOUT* = 0x00000102'i32
+  WAIT_FAILED* = 0xFFFFFFFF'i32
   INFINITE* = -1'i32
+  STILL_ACTIVE* = 0x00000103'i32
 
   STD_INPUT_HANDLE* = -10'i32
   STD_OUTPUT_HANDLE* = -11'i32
   STD_ERROR_HANDLE* = -12'i32
 
   DETACHED_PROCESS* = 8'i32
-  
+
   SW_SHOWNORMAL* = 1'i32
+  INVALID_HANDLE_VALUE* = Handle(-1)
+
+  CREATE_UNICODE_ENVIRONMENT* = 1024'i32
+
+  PIPE_ACCESS_DUPLEX* = 0x00000003'i32
+  PIPE_ACCESS_INBOUND* = 1'i32
+  PIPE_ACCESS_OUTBOUND* = 2'i32
+  PIPE_NOWAIT* = 0x00000001'i32
+  SYNCHRONIZE* = 0x00100000'i32
+
+  CREATE_NO_WINDOW* = 0x08000000'i32
+
+  HANDLE_FLAG_INHERIT* = 0x00000001'i32
+
+proc isSuccess*(a: WINBOOL): bool {.inline.} =
+  ## Returns true if `a != 0`. Windows uses a different convention than POSIX,
+  ## where `a == 0` is commonly used on success.
+  a != 0
+proc getVersionExW*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.
+    stdcall, dynlib: "kernel32", importc: "GetVersionExW", sideEffect.}
+proc getVersionExA*(lpVersionInfo: ptr OSVERSIONINFO): WINBOOL {.
+    stdcall, dynlib: "kernel32", importc: "GetVersionExA", sideEffect.}
+
+proc getVersion*(): DWORD {.stdcall, dynlib: "kernel32", importc: "GetVersion", sideEffect.}
 
-proc CloseHandle*(hObject: THANDLE): WINBOOL {.stdcall, dynlib: "kernel32",
+proc closeHandle*(hObject: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
     importc: "CloseHandle".}
-    
-proc ReadFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToRead: int32,
-               lpNumberOfBytesRead: var int32, lpOverlapped: pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "ReadFile".}
-    
-proc WriteFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToWrite: int32,
-                lpNumberOfBytesWritten: var int32, 
+
+proc readFile*(hFile: Handle, buffer: pointer, nNumberOfBytesToRead: int32,
+               lpNumberOfBytesRead: ptr int32, lpOverlapped: pointer): WINBOOL{.
+    stdcall, dynlib: "kernel32", importc: "ReadFile", sideEffect.}
+
+proc writeFile*(hFile: Handle, buffer: pointer, nNumberOfBytesToWrite: int32,
+                lpNumberOfBytesWritten: ptr int32,
                 lpOverlapped: pointer): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "WriteFile".}
+    stdcall, dynlib: "kernel32", importc: "WriteFile", sideEffect.}
 
-proc CreatePipe*(hReadPipe, hWritePipe: var THandle,
-                 lpPipeAttributes: var TSECURITY_ATTRIBUTES, 
+proc createPipe*(hReadPipe, hWritePipe: var Handle,
+                 lpPipeAttributes: var SECURITY_ATTRIBUTES,
                  nSize: int32): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreatePipe".}
-    
-proc CreateProcess*(lpApplicationName, lpCommandLine: cstring,
-                    lpProcessAttributes: ptr TSECURITY_ATTRIBUTES,
-                    lpThreadAttributes: ptr TSECURITY_ATTRIBUTES,
-                    bInheritHandles: WINBOOL, dwCreationFlags: int32,
-                    lpEnvironment: pointer, lpCurrentDirectory: cstring,
-                    lpStartupInfo: var TSTARTUPINFO,
-                    lpProcessInformation: var TPROCESS_INFORMATION): WINBOOL{.
-    stdcall, dynlib: "kernel32", importc: "CreateProcessA".}
-
-proc SuspendThread*(hThread: THANDLE): int32 {.stdcall, dynlib: "kernel32",
-    importc: "SuspendThread".}
-proc ResumeThread*(hThread: THANDLE): int32 {.stdcall, dynlib: "kernel32",
-    importc: "ResumeThread".}
-
-proc WaitForSingleObject*(hHandle: THANDLE, dwMilliseconds: int32): int32 {.
-    stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".}
-
-proc TerminateProcess*(hProcess: THANDLE, uExitCode: int): WINBOOL {.stdcall,
-    dynlib: "kernel32", importc: "TerminateProcess".}
-
-proc GetExitCodeProcess*(hProcess: THANDLE, lpExitCode: var int32): WINBOOL {.
+    stdcall, dynlib: "kernel32", importc: "CreatePipe", sideEffect.}
+
+proc createNamedPipe*(lpName: WideCString,
+                     dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize,
+                     nInBufferSize, nDefaultTimeOut: int32,
+                     lpSecurityAttributes: ptr SECURITY_ATTRIBUTES): Handle {.
+    stdcall, dynlib: "kernel32", importc: "CreateNamedPipeW", sideEffect.}
+
+proc peekNamedPipe*(hNamedPipe: Handle, lpBuffer: pointer=nil,
+                    nBufferSize: int32 = 0,
+                    lpBytesRead: ptr int32 = nil,
+                    lpTotalBytesAvail: ptr int32 = nil,
+                    lpBytesLeftThisMessage: ptr int32 = nil): bool {.
+    stdcall, dynlib: "kernel32", importc: "PeekNamedPipe".}
+
+proc createProcessW*(lpApplicationName, lpCommandLine: WideCString,
+                   lpProcessAttributes: ptr SECURITY_ATTRIBUTES,
+                   lpThreadAttributes: ptr SECURITY_ATTRIBUTES,
+                   bInheritHandles: WINBOOL, dwCreationFlags: int32,
+                   lpEnvironment, lpCurrentDirectory: WideCString,
+                   lpStartupInfo: var STARTUPINFO,
+                   lpProcessInformation: var PROCESS_INFORMATION): WINBOOL{.
+  stdcall, dynlib: "kernel32", importc: "CreateProcessW", sideEffect.}
+
+proc suspendThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
+    importc: "SuspendThread", sideEffect.}
+proc resumeThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32",
+    importc: "ResumeThread", sideEffect.}
+
+proc waitForSingleObject*(hHandle: Handle, dwMilliseconds: int32): int32 {.
+    stdcall, dynlib: "kernel32", importc: "WaitForSingleObject", sideEffect.}
+
+proc terminateProcess*(hProcess: Handle, uExitCode: int): WINBOOL {.stdcall,
+    dynlib: "kernel32", importc: "TerminateProcess", sideEffect.}
+
+proc getExitCodeProcess*(hProcess: Handle, lpExitCode: var int32): WINBOOL {.
     stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".}
 
-proc GetStdHandle*(nStdHandle: int32): THANDLE {.stdcall, dynlib: "kernel32",
+proc getStdHandle*(nStdHandle: int32): Handle {.stdcall, dynlib: "kernel32",
     importc: "GetStdHandle".}
-proc SetStdHandle*(nStdHandle: int32, hHandle: THANDLE): WINBOOL {.stdcall,
-    dynlib: "kernel32", importc: "SetStdHandle".}
-proc FlushFileBuffers*(hFile: THANDLE): WINBOOL {.stdcall, dynlib: "kernel32",
-    importc: "FlushFileBuffers".}
+proc setStdHandle*(nStdHandle: int32, hHandle: Handle): WINBOOL {.stdcall,
+    dynlib: "kernel32", importc: "SetStdHandle", sideEffect.}
+proc flushFileBuffers*(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
+    importc: "FlushFileBuffers", sideEffect.}
+
+proc getLastError*(): int32 {.importc: "GetLastError",
+    stdcall, dynlib: "kernel32", sideEffect.}
+
+proc setLastError*(error: int32) {.importc: "SetLastError",
+    stdcall, dynlib: "kernel32", sideEffect.}
 
-proc GetLastError*(): int32 {.importc, stdcall, dynlib: "kernel32".}
-proc FormatMessageA*(dwFlags: int32, lpSource: pointer,
+proc formatMessageW*(dwFlags: int32, lpSource: pointer,
                     dwMessageId, dwLanguageId: int32,
                     lpBuffer: pointer, nSize: int32,
-                    Arguments: pointer): int32 {.
-                    importc, stdcall, dynlib: "kernel32".}
-proc LocalFree*(p: pointer) {.importc, stdcall, dynlib: "kernel32".}
-
-proc GetCurrentDirectoryA*(nBufferLength: int32, lpBuffer: cstring): int32 {.
-  importc, dynlib: "kernel32", stdcall.}
-proc SetCurrentDirectoryA*(lpPathName: cstring): int32 {.
-  importc, dynlib: "kernel32", stdcall.}
-proc CreateDirectoryA*(pathName: cstring, security: Pointer): int32 {.
-  importc: "CreateDirectoryA", dynlib: "kernel32", stdcall.}
-proc RemoveDirectoryA*(lpPathName: cstring): int32 {.
-  importc, dynlib: "kernel32", stdcall.}
-proc SetEnvironmentVariableA*(lpName, lpValue: cstring): int32 {.
-  stdcall, dynlib: "kernel32", importc.}
-
-proc GetModuleFileNameA*(handle: THandle, buf: CString, size: int32): int32 {.
-  importc, dynlib: "kernel32", stdcall.}
+                    arguments: pointer): int32 {.
+                    importc: "FormatMessageW", stdcall, dynlib: "kernel32".}
+
+proc localFree*(p: pointer) {.
+  importc: "LocalFree", stdcall, dynlib: "kernel32".}
+
+proc getCurrentDirectoryW*(nBufferLength: int32,
+                           lpBuffer: WideCString): int32 {.
+  importc: "GetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
+proc setCurrentDirectoryW*(lpPathName: WideCString): int32 {.
+  importc: "SetCurrentDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
+proc createDirectoryW*(pathName: WideCString, security: pointer=nil): int32 {.
+  importc: "CreateDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
+proc removeDirectoryW*(lpPathName: WideCString): int32 {.
+  importc: "RemoveDirectoryW", dynlib: "kernel32", stdcall, sideEffect.}
+proc setEnvironmentVariableW*(lpName, lpValue: WideCString): int32 {.
+  stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW", sideEffect.}
+
+proc getModuleFileNameW*(handle: Handle, buf: WideCString,
+                         size: int32): int32 {.importc: "GetModuleFileNameW",
+  dynlib: "kernel32", stdcall.}
+
+proc createSymbolicLinkW*(lpSymlinkFileName, lpTargetFileName: WideCString,
+                       flags: DWORD): int32 {.
+  importc:"CreateSymbolicLinkW", dynlib: "kernel32", stdcall, sideEffect.}
+proc createHardLinkW*(lpFileName, lpExistingFileName: WideCString,
+                       security: pointer=nil): int32 {.
+  importc:"CreateHardLinkW", dynlib: "kernel32", stdcall, sideEffect.}
 
 const
-  FILE_ATTRIBUTE_ARCHIVE* = 32'i32
-  FILE_ATTRIBUTE_COMPRESSED* = 2048'i32
-  FILE_ATTRIBUTE_NORMAL* = 128'i32
-  FILE_ATTRIBUTE_DIRECTORY* = 16'i32
-  FILE_ATTRIBUTE_HIDDEN* = 2'i32
-  FILE_ATTRIBUTE_READONLY* = 1'i32
-  FILE_ATTRIBUTE_SYSTEM* = 4'i32
+  FILE_ATTRIBUTE_READONLY* = 0x00000001'i32
+  FILE_ATTRIBUTE_HIDDEN* = 0x00000002'i32
+  FILE_ATTRIBUTE_SYSTEM* = 0x00000004'i32
+  FILE_ATTRIBUTE_DIRECTORY* = 0x00000010'i32
+  FILE_ATTRIBUTE_ARCHIVE* = 0x00000020'i32
+  FILE_ATTRIBUTE_DEVICE* = 0x00000040'i32
+  FILE_ATTRIBUTE_NORMAL* = 0x00000080'i32
+  FILE_ATTRIBUTE_TEMPORARY* = 0x00000100'i32
+  FILE_ATTRIBUTE_SPARSE_FILE* = 0x00000200'i32
+  FILE_ATTRIBUTE_REPARSE_POINT* = 0x00000400'i32
+  FILE_ATTRIBUTE_COMPRESSED* = 0x00000800'i32
+  FILE_ATTRIBUTE_OFFLINE* = 0x00001000'i32
+  FILE_ATTRIBUTE_NOT_CONTENT_INDEXED* = 0x00002000'i32
+
+  FILE_FLAG_FIRST_PIPE_INSTANCE* = 0x00080000'i32
+  FILE_FLAG_OPEN_NO_RECALL* = 0x00100000'i32
+  FILE_FLAG_OPEN_REPARSE_POINT* = 0x00200000'i32
+  FILE_FLAG_POSIX_SEMANTICS* = 0x01000000'i32
+  FILE_FLAG_BACKUP_SEMANTICS* = 0x02000000'i32
+  FILE_FLAG_DELETE_ON_CLOSE* = 0x04000000'i32
+  FILE_FLAG_SEQUENTIAL_SCAN* = 0x08000000'i32
+  FILE_FLAG_RANDOM_ACCESS* = 0x10000000'i32
+  FILE_FLAG_NO_BUFFERING* = 0x20000000'i32
+  FILE_FLAG_OVERLAPPED* = 0x40000000'i32
+  FILE_FLAG_WRITE_THROUGH* = 0x80000000'i32
 
   MAX_PATH* = 260
+
+  MOVEFILE_COPY_ALLOWED* = 0x2'i32
+  MOVEFILE_CREATE_HARDLINK* = 0x10'i32
+  MOVEFILE_DELAY_UNTIL_REBOOT* = 0x4'i32
+  MOVEFILE_FAIL_IF_NOT_TRACKABLE* = 0x20'i32
+  MOVEFILE_REPLACE_EXISTING* = 0x1'i32
+  MOVEFILE_WRITE_THROUGH* = 0x8'i32
+
 type
-  FILETIME* {.final, pure.} = object ## CANNOT BE int64 BECAUSE OF ALIGNMENT
-    dwLowDateTime*: int32
-    dwHighDateTime*: int32
-  TWIN32_FIND_DATA* {.pure.} = object
+  WIN32_FIND_DATA* {.pure.} = object
     dwFileAttributes*: int32
     ftCreationTime*: FILETIME
     ftLastAccessTime*: FILETIME
@@ -155,102 +292,131 @@ type
     nFileSizeLow*: int32
     dwReserved0: int32
     dwReserved1: int32
-    cFileName*: array[0..(MAX_PATH) - 1, char]
-    cAlternateFileName*: array[0..13, char]
-
-proc FindFirstFileA*(lpFileName: cstring,
-                    lpFindFileData: var TWIN32_FIND_DATA): THANDLE {.
-    stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
-proc FindNextFileA*(hFindFile: THANDLE,
-                   lpFindFileData: var TWIN32_FIND_DATA): int32 {.
-    stdcall, dynlib: "kernel32", importc: "FindNextFileA".}
-proc FindClose*(hFindFile: THANDLE) {.stdcall, dynlib: "kernel32",
+    cFileName*: array[0..(MAX_PATH) - 1, WinChar]
+    cAlternateFileName*: array[0..13, WinChar]
+
+proc findFirstFileW*(lpFileName: WideCString,
+                    lpFindFileData: var WIN32_FIND_DATA): Handle {.
+    stdcall, dynlib: "kernel32", importc: "FindFirstFileW", sideEffect.}
+proc findNextFileW*(hFindFile: Handle,
+                   lpFindFileData: var WIN32_FIND_DATA): int32 {.
+    stdcall, dynlib: "kernel32", importc: "FindNextFileW", sideEffect.}
+
+proc findClose*(hFindFile: Handle) {.stdcall, dynlib: "kernel32",
   importc: "FindClose".}
 
-proc GetFullPathNameA*(lpFileName: cstring, nBufferLength: int32,
-                      lpBuffer: cstring, lpFilePart: var cstring): int32 {.
-                      stdcall, dynlib: "kernel32", importc.}
-proc GetFileAttributesA*(lpFileName: cstring): int32 {.
-                        stdcall, dynlib: "kernel32", importc.}
-proc SetFileAttributesA*(lpFileName: cstring, dwFileAttributes: int32): WINBOOL {.
-    stdcall, dynlib: "kernel32", importc: "SetFileAttributesA".}
+proc getFullPathNameW*(lpFileName: WideCString, nBufferLength: int32,
+                      lpBuffer: WideCString,
+                      lpFilePart: var WideCString): int32 {.
+                      stdcall, dynlib: "kernel32",
+                      importc: "GetFullPathNameW", sideEffect.}
+proc getFileAttributesW*(lpFileName: WideCString): int32 {.
+                        stdcall, dynlib: "kernel32",
+                        importc: "GetFileAttributesW", sideEffect.}
+proc setFileAttributesW*(lpFileName: WideCString,
+                         dwFileAttributes: int32): WINBOOL {.
+    stdcall, dynlib: "kernel32", importc: "SetFileAttributesW", sideEffect.}
+
+proc copyFileW*(lpExistingFileName, lpNewFileName: WideCString,
+               bFailIfExists: WINBOOL): WINBOOL {.
+  importc: "CopyFileW", stdcall, dynlib: "kernel32", sideEffect.}
 
-proc CopyFileA*(lpExistingFileName, lpNewFileName: CString,
-               bFailIfExists: cint): cint {.
-  importc, stdcall, dynlib: "kernel32".}
+proc moveFileW*(lpExistingFileName, lpNewFileName: WideCString): WINBOOL {.
+  importc: "MoveFileW", stdcall, dynlib: "kernel32", sideEffect.}
+proc moveFileExW*(lpExistingFileName, lpNewFileName: WideCString,
+                  flags: DWORD): WINBOOL {.
+  importc: "MoveFileExW", stdcall, dynlib: "kernel32", sideEffect.}
 
-proc GetEnvironmentStringsA*(): cstring {.
-  stdcall, dynlib: "kernel32", importc.}
-proc FreeEnvironmentStringsA*(para1: cstring): int32 {.
-  stdcall, dynlib: "kernel32", importc.}
+proc getEnvironmentStringsW*(): WideCString {.
+  stdcall, dynlib: "kernel32", importc: "GetEnvironmentStringsW", sideEffect.}
+proc freeEnvironmentStringsW*(para1: WideCString): int32 {.
+  stdcall, dynlib: "kernel32", importc: "FreeEnvironmentStringsW", sideEffect.}
 
-proc GetCommandLineA*(): CString {.importc, stdcall, dynlib: "kernel32".}
+proc getCommandLineW*(): WideCString {.importc: "GetCommandLineW",
+  stdcall, dynlib: "kernel32", sideEffect.}
 
-proc rdFileTime*(f: FILETIME): int64 = 
-  result = ze64(f.dwLowDateTime) or (ze64(f.dwHighDateTime) shl 32)
+proc rdFileTime*(f: FILETIME): int64 =
+  result = int64(cast[uint32](f.dwLowDateTime)) or (int64(cast[uint32](f.dwHighDateTime)) shl 32)
 
-proc rdFileSize*(f: TWin32FindData): int64 = 
-  result = ze64(f.nFileSizeLow) or (ze64(f.nFileSizeHigh) shl 32)
+proc rdFileSize*(f: WIN32_FIND_DATA): int64 =
+  result = int64(cast[uint32](f.nFileSizeLow)) or (int64(cast[uint32](f.nFileSizeHigh)) shl 32)
 
-proc Sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32",
-                                    importc: "Sleep".}
+proc getSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var FILETIME) {.
+  importc: "GetSystemTimeAsFileTime", dynlib: "kernel32", stdcall, sideEffect.}
 
-proc ShellExecute*(HWND: THandle, lpOperation, lpFile,
-                   lpParameters, lpDirectory: cstring,
-                   nShowCmd: int32): THandle{.
-    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
+proc sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32",
+                                    importc: "Sleep", sideEffect.}
+
+proc shellExecuteW*(hwnd: Handle, lpOperation, lpFile,
+                   lpParameters, lpDirectory: WideCString,
+                   nShowCmd: int32): Handle{.
+    stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW", sideEffect.}
+
+proc getFileInformationByHandle*(hFile: Handle,
+  lpFileInformation: ptr BY_HANDLE_FILE_INFORMATION): WINBOOL{.
+    stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle", sideEffect.}
 
 const
   WSADESCRIPTION_LEN* = 256
   WSASYS_STATUS_LEN* = 128
   FD_SETSIZE* = 64
   MSG_PEEK* = 2
-  
-  INADDR_ANY* = 0
+
+  INADDR_ANY* = 0'u32
   INADDR_LOOPBACK* = 0x7F000001
   INADDR_BROADCAST* = -1
   INADDR_NONE* = -1
-  
+
   ws2dll = "Ws2_32.dll"
-  
-type 
-  TWSAData* {.pure, final.} = object 
+
+proc wsaGetLastError*(): cint {.importc: "WSAGetLastError", dynlib: ws2dll, sideEffect.}
+
+type
+  SocketHandle* = distinct int
+
+type
+  WSAData* {.importc: "WSADATA", header: "winsock2.h".} = object
     wVersion, wHighVersion: int16
     szDescription: array[0..WSADESCRIPTION_LEN, char]
     szSystemStatus: array[0..WSASYS_STATUS_LEN, char]
     iMaxSockets, iMaxUdpDg: int16
     lpVendorInfo: cstring
-    
-  TSockAddr* {.pure, final.} = object 
-    sa_family*: int16 # unsigned
-    sa_data: array[0..13, char]
-
-  TInAddr* {.pure, final.} = object ## struct in_addr
-    s_addr*: int32  # IP address
-  
-  Tsockaddr_in* {.pure, final.} = object
-    sin_family*: int16
-    sin_port*: int16 # unsigned
-    sin_addr*: TInAddr
+
+  SockAddr* {.importc: "SOCKADDR", header: "winsock2.h".} = object
+    sa_family*: uint16
+    sa_data*: array[0..13, char]
+
+  PSockAddr = ptr SockAddr
+
+  InAddr* {.importc: "IN_ADDR", header: "winsock2.h", union.} = object
+    s_addr*: uint32  # IP address
+
+  Sockaddr_in* {.importc: "SOCKADDR_IN",
+                  header: "winsock2.h".} = object
+    sin_family*: uint16
+    sin_port*: uint16
+    sin_addr*: InAddr
     sin_zero*: array[0..7, char]
 
-  Tin6_addr* {.pure, final.} = object 
-    bytes*: array[0..15, char]
+  In6_addr* {.importc: "IN6_ADDR", header: "winsock2.h".} = object
+    bytes* {.importc: "u.Byte".}: array[0..15, char]
 
-  Tsockaddr_in6* {.pure, final.} = object
-    sin6_family*: int16
-    sin6_port*: int16 # unsigned
+  Sockaddr_in6* {.importc: "SOCKADDR_IN6",
+                   header: "ws2tcpip.h".} = object
+    sin6_family*: uint16
+    sin6_port*: uint16
     sin6_flowinfo*: int32 # unsigned
-    sin6_addr*: Tin6_addr
+    sin6_addr*: In6_addr
     sin6_scope_id*: int32 # unsigned
 
-  Tsockaddr_in6_old* {.pure, final.} = object
-    sin6_family*: int16
-    sin6_port*: int16 # unsigned
-    sin6_flowinfo*: int32 # unsigned
-    sin6_addr*: Tin6_addr
+  Sockaddr_storage* {.importc: "SOCKADDR_STORAGE",
+                      header: "winsock2.h".} = object
+    ss_family*: uint16
+    ss_pad1 {.importc: "__ss_pad1".}: array[6, byte]
+    ss_align {.importc: "__ss_align".}: int64
+    ss_pad2 {.importc: "__ss_pad2".}: array[112, byte]
 
-  TServent* {.pure, final.} = object
+  Servent* = object
     s_name*: cstring
     s_aliases*: cstringArray
     when defined(cpu64):
@@ -260,114 +426,648 @@ type
       s_port*: int16
       s_proto*: cstring
 
-  Thostent* {.pure, final.} = object
+  Hostent* = object
     h_name*: cstring
     h_aliases*: cstringArray
     h_addrtype*: int16
     h_length*: int16
     h_addr_list*: cstringArray
-    
-  TWinSocket* = cint
-  
-  TFdSet* {.pure, final.} = object
+
+  TFdSet* = object
     fd_count*: cint # unsigned
-    fd_array*: array[0..FD_SETSIZE-1, TWinSocket]
-    
-  TTimeval* {.pure, final.} = object
-    tv_sec*, tv_usec*: int32
-    
-  TAddrInfo* {.pure, final.} = object
-    ai_flags*: cint         ## Input flags. 
-    ai_family*: cint        ## Address family of socket. 
-    ai_socktype*: cint      ## Socket type. 
-    ai_protocol*: cint      ## Protocol of socket. 
-    ai_addrlen*: int        ## Length of socket address. 
+    fd_array*: array[0..FD_SETSIZE-1, SocketHandle]
+
+  AddrInfo* = object
+    ai_flags*: cint         ## Input flags.
+    ai_family*: cint        ## Address family of socket.
+    ai_socktype*: cint      ## Socket type.
+    ai_protocol*: cint      ## Protocol of socket.
+    ai_addrlen*: csize_t        ## Length of socket address.
     ai_canonname*: cstring  ## Canonical name of service location.
-    ai_addr*: ptr TSockAddr ## Socket address of socket. 
-    ai_next*: ptr TAddrInfo ## Pointer to next in list. 
+    ai_addr*: ptr SockAddr ## Socket address of socket.
+    ai_next*: ptr AddrInfo ## Pointer to next in list.
+
+  SockLen* = cuint
+
+when defined(cpp):
+  type
+    Timeval* {.importc: "timeval", header: "<time.h>".} = object
+      tv_sec*, tv_usec*: int32
+else:
+  type
+    Timeval* = object
+      tv_sec*, tv_usec*: int32
+
+var
+  SOMAXCONN* {.importc, header: "winsock2.h".}: cint
+  INVALID_SOCKET* {.importc, header: "winsock2.h".}: SocketHandle
+  SOL_SOCKET* {.importc, header: "winsock2.h".}: cint
+  SO_DEBUG* {.importc, header: "winsock2.h".}: cint ## turn on debugging info recording
+  SO_ACCEPTCONN* {.importc, header: "winsock2.h".}: cint # socket has had listen()
+  SO_REUSEADDR* {.importc, header: "winsock2.h".}: cint # allow local address reuse
+  SO_REUSEPORT* {.importc: "SO_REUSEADDR", header: "winsock2.h".}: cint # allow port reuse. Since Windows does not really support it, mapped to SO_REUSEADDR. This shouldn't cause problems.
+
+  SO_KEEPALIVE* {.importc, header: "winsock2.h".}: cint # keep connections alive
+  SO_DONTROUTE* {.importc, header: "winsock2.h".}: cint # just use interface addresses
+  SO_BROADCAST* {.importc, header: "winsock2.h".}: cint # permit sending of broadcast msgs
+  SO_USELOOPBACK* {.importc, header: "winsock2.h".}: cint # bypass hardware when possible
+  SO_LINGER* {.importc, header: "winsock2.h".}: cint # linger on close if data present
+  SO_OOBINLINE* {.importc, header: "winsock2.h".}: cint # leave received OOB data in line
+
+  SO_DONTLINGER* {.importc, header: "winsock2.h".}: cint
+  SO_EXCLUSIVEADDRUSE* {.importc, header: "winsock2.h".}: cint # disallow local address reuse
+  SO_ERROR* {.importc, header: "winsock2.h".}: cint
+  TCP_NODELAY* {.importc, header: "winsock2.h".}: cint
 
-  Tsocklen* = cint
+proc `==`*(x, y: SocketHandle): bool {.borrow.}
 
-proc getservbyname*(name, proto: cstring): ptr TServent {.
-  stdcall, importc: "getservbyname", dynlib: ws2dll.}
+proc getservbyname*(name, proto: cstring): ptr Servent {.
+  stdcall, importc: "getservbyname", dynlib: ws2dll, sideEffect.}
 
-proc getservbyport*(port: cint, proto: cstring): ptr TServent {.
-  stdcall, importc: "getservbyport", dynlib: ws2dll.}
+proc getservbyport*(port: cint, proto: cstring): ptr Servent {.
+  stdcall, importc: "getservbyport", dynlib: ws2dll, sideEffect.}
 
-proc gethostbyname*(name: cstring): ptr THostEnt {.
-  stdcall, importc: "gethostbyname", dynlib: ws2dll.}
+proc gethostbyaddr*(ip: ptr InAddr, len: cuint, theType: cint): ptr Hostent {.
+  stdcall, importc: "gethostbyaddr", dynlib: ws2dll, sideEffect.}
 
-proc socket*(af, typ, protocol: cint): TWinSocket {.
+proc gethostbyname*(name: cstring): ptr Hostent {.
+  stdcall, importc: "gethostbyname", dynlib: ws2dll, sideEffect.}
+
+proc gethostname*(hostname: cstring, len: cint): cint {.
+  stdcall, importc: "gethostname", dynlib: ws2dll, sideEffect.}
+
+proc getprotobyname*(
+  name: cstring
+): ptr Protoent {.stdcall, importc: "getprotobyname", dynlib: ws2dll, sideEffect.}
+
+proc getprotobynumber*(
+  proto: cint
+): ptr Protoent {.stdcall, importc: "getprotobynumber", dynlib: ws2dll, sideEffect.}
+
+proc socket*(af, typ, protocol: cint): SocketHandle {.
   stdcall, importc: "socket", dynlib: ws2dll.}
 
-proc closesocket*(s: TWinSocket): cint {.
+proc closesocket*(s: SocketHandle): cint {.
   stdcall, importc: "closesocket", dynlib: ws2dll.}
 
-proc accept*(s: TWinSocket, a: ptr TSockAddr, addrlen: ptr cint): TWinSocket {.
+proc accept*(s: SocketHandle, a: ptr SockAddr, addrlen: ptr SockLen): SocketHandle {.
   stdcall, importc: "accept", dynlib: ws2dll.}
-proc bindSocket*(s: TWinSocket, name: ptr TSockAddr, namelen: cint): cint {.
+proc bindSocket*(s: SocketHandle, name: ptr SockAddr, namelen: SockLen): cint {.
   stdcall, importc: "bind", dynlib: ws2dll.}
-proc connect*(s: TWinSocket, name: ptr TSockAddr, namelen: cint): cint {.
+proc connect*(s: SocketHandle, name: ptr SockAddr, namelen: SockLen): cint {.
   stdcall, importc: "connect", dynlib: ws2dll.}
-proc getsockname*(s: TWinSocket, name: ptr TSockAddr, 
-                  namelen: ptr cint): cint {.
+proc getsockname*(s: SocketHandle, name: ptr SockAddr,
+                  namelen: ptr SockLen): cint {.
   stdcall, importc: "getsockname", dynlib: ws2dll.}
-proc getsockopt*(s: TWinSocket, level, optname: cint, optval: pointer,
-                 optlen: ptr cint): cint {.
+proc getpeername*(s: SocketHandle, name: ptr SockAddr,
+                  namelen: ptr SockLen): cint {.
+  stdcall, importc, dynlib: ws2dll.}
+proc getsockopt*(s: SocketHandle, level, optname: cint, optval: pointer,
+                 optlen: ptr SockLen): cint {.
   stdcall, importc: "getsockopt", dynlib: ws2dll.}
-proc setsockopt*(s: TWinSocket, level, optname: cint, optval: pointer,
-                 optlen: cint): cint {.
+proc setsockopt*(s: SocketHandle, level, optname: cint, optval: pointer,
+                 optlen: SockLen): cint {.
   stdcall, importc: "setsockopt", dynlib: ws2dll.}
 
-proc listen*(s: TWinSocket, backlog: cint): cint {.
+proc listen*(s: SocketHandle, backlog: cint): cint {.
   stdcall, importc: "listen", dynlib: ws2dll.}
-proc recv*(s: TWinSocket, buf: pointer, len, flags: cint): cint {.
+proc recv*(s: SocketHandle, buf: pointer, len, flags: cint): cint {.
   stdcall, importc: "recv", dynlib: ws2dll.}
-proc recvfrom*(s: TWinSocket, buf: cstring, len, flags: cint, 
-               fromm: ptr TSockAddr, fromlen: ptr cint): cint {.
+proc recvfrom*(s: SocketHandle, buf: cstring, len, flags: cint,
+               fromm: ptr SockAddr, fromlen: ptr SockLen): cint {.
   stdcall, importc: "recvfrom", dynlib: ws2dll.}
 proc select*(nfds: cint, readfds, writefds, exceptfds: ptr TFdSet,
-             timeout: ptr TTimeval): cint {.
+             timeout: ptr Timeval): cint {.
   stdcall, importc: "select", dynlib: ws2dll.}
-proc send*(s: TWinSocket, buf: pointer, len, flags: cint): cint {.
+proc send*(s: SocketHandle, buf: pointer, len, flags: cint): cint {.
   stdcall, importc: "send", dynlib: ws2dll.}
-proc sendto*(s: TWinSocket, buf: cstring, len, flags: cint,
-             to: ptr TSockAddr, tolen: cint): cint {.
+proc sendto*(s: SocketHandle, buf: pointer, len, flags: cint,
+             to: ptr SockAddr, tolen: SockLen): cint {.
   stdcall, importc: "sendto", dynlib: ws2dll.}
 
-proc shutdown*(s: TWinSocket, how: cint): cint {.
+proc shutdown*(s: SocketHandle, how: cint): cint {.
   stdcall, importc: "shutdown", dynlib: ws2dll.}
-  
-proc getnameinfo*(a1: ptr Tsockaddr, a2: Tsocklen,
-                  a3: cstring, a4: Tsocklen, a5: cstring,
-                  a6: Tsocklen, a7: cint): cint {.
+
+proc getnameinfo*(a1: ptr SockAddr, a2: SockLen,
+                  a3: cstring, a4: SockLen, a5: cstring,
+                  a6: SockLen, a7: cint): cint {.
   stdcall, importc: "getnameinfo", dynlib: ws2dll.}
-  
-proc inet_addr*(cp: cstring): int32 {.
-  stdcall, importc: "inet_addr", dynlib: ws2dll.} 
 
-proc WSAFDIsSet(s: TWinSocket, FDSet: var TFDSet): bool {.
-  stdcall, importc: "__WSAFDIsSet", dynlib: ws2dll.}
+proc inet_addr*(cp: cstring): uint32 {.
+  stdcall, importc: "inet_addr", dynlib: ws2dll.}
 
-proc FD_ISSET*(Socket: TWinSocket, FDSet: var TFDSet): cint = 
-  result = if WSAFDIsSet(Socket, FDSet): 1'i32 else: 0'i32
+proc WSAFDIsSet(s: SocketHandle, set: var TFdSet): bool {.
+  stdcall, importc: "__WSAFDIsSet", dynlib: ws2dll, noSideEffect.}
 
-proc FD_SET*(Socket: TWinSocket, FDSet: var TFDSet) = 
-  if FDSet.fd_count < FD_SETSIZE:
-    FDSet.fd_array[int(FDSet.fd_count)] = Socket
-    inc(FDSet.fd_count)
+proc FD_ISSET*(socket: SocketHandle, set: var TFdSet): cint =
+  result = if WSAFDIsSet(socket, set): 1'i32 else: 0'i32
 
-proc FD_ZERO*(FDSet: var TFDSet) =
-  FDSet.fd_count = 0
+proc FD_SET*(socket: SocketHandle, s: var TFdSet) =
+  if s.fd_count < FD_SETSIZE:
+    s.fd_array[int(s.fd_count)] = socket
+    inc(s.fd_count)
 
-proc WSAStartup*(wVersionRequired: int16, WSData: var TWSAData): cint {.
+proc FD_ZERO*(s: var TFdSet) =
+  s.fd_count = 0
+
+proc wsaStartup*(wVersionRequired: int16, WSData: ptr WSAData): cint {.
   stdcall, importc: "WSAStartup", dynlib: ws2dll.}
 
-proc getaddrinfo*(nodename, servname: cstring, hints: ptr TAddrInfo,
-                  res: var ptr TAddrInfo): cint {.
+proc getaddrinfo*(nodename, servname: cstring, hints: ptr AddrInfo,
+                  res: var ptr AddrInfo): cint {.
   stdcall, importc: "getaddrinfo", dynlib: ws2dll.}
 
-proc freeaddrinfo*(ai: ptr TAddrInfo) {.
+proc freeAddrInfo*(ai: ptr AddrInfo) {.
   stdcall, importc: "freeaddrinfo", dynlib: ws2dll.}
 
+proc inet_ntoa*(i: InAddr): cstring {.
+  stdcall, importc, dynlib: ws2dll.}
+
+const
+  MAXIMUM_WAIT_OBJECTS* = 0x00000040
+
+type
+  WOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, Handle]
+  PWOHandleArray* = ptr WOHandleArray
+
+proc waitForMultipleObjects*(nCount: DWORD, lpHandles: PWOHandleArray,
+                             bWaitAll: WINBOOL, dwMilliseconds: DWORD): DWORD{.
+    stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".}
+
+
+# for memfiles.nim:
+
+const
+  GENERIC_READ* = 0x80000000'i32
+  GENERIC_WRITE* = 0x40000000'i32
+  GENERIC_ALL* = 0x10000000'i32
+  FILE_SHARE_READ* = 1'i32
+  FILE_SHARE_DELETE* = 4'i32
+  FILE_SHARE_WRITE* = 2'i32
+
+  CREATE_ALWAYS* = 2'i32
+  CREATE_NEW* = 1'i32
+  OPEN_EXISTING* = 3'i32
+  OPEN_ALWAYS* = 4'i32
+  FILE_BEGIN* = 0'i32
+  INVALID_SET_FILE_POINTER* = -1'i32
+  NO_ERROR* = 0'i32
+  PAGE_NOACCESS* = 0x01'i32
+  PAGE_EXECUTE* = 0x10'i32
+  PAGE_EXECUTE_READ* = 0x20'i32
+  PAGE_EXECUTE_READWRITE* = 0x40'i32
+  PAGE_READONLY* = 2'i32
+  PAGE_READWRITE* = 4'i32
+  FILE_MAP_READ* = 4'i32
+  FILE_MAP_WRITE* = 2'i32
+  INVALID_FILE_SIZE* = -1'i32
+
+  DUPLICATE_SAME_ACCESS* = 2
+  FILE_READ_DATA* = 0x00000001 # file & pipe
+  FILE_WRITE_DATA* = 0x00000002 # file & pipe
+
+# Error Constants
+const
+  ERROR_FILE_NOT_FOUND* = 2 ## https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
+  ERROR_PATH_NOT_FOUND* = 3
+  ERROR_ACCESS_DENIED* = 5
+  ERROR_NO_MORE_FILES* = 18
+  ERROR_LOCK_VIOLATION* = 33
+  ERROR_HANDLE_EOF* = 38
+  ERROR_FILE_EXISTS* = 80
+  ERROR_BAD_ARGUMENTS* = 165
+
+proc duplicateHandle*(hSourceProcessHandle: Handle, hSourceHandle: Handle,
+                      hTargetProcessHandle: Handle,
+                      lpTargetHandle: ptr Handle,
+                      dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
+                      dwOptions: DWORD): WINBOOL{.stdcall, dynlib: "kernel32",
+    importc: "DuplicateHandle".}
+
+proc getHandleInformation*(hObject: Handle, lpdwFlags: ptr DWORD): WINBOOL {.
+    stdcall, dynlib: "kernel32", importc: "GetHandleInformation".}
+
+proc setHandleInformation*(hObject: Handle, dwMask: DWORD,
+                           dwFlags: DWORD): WINBOOL {.stdcall,
+    dynlib: "kernel32", importc: "SetHandleInformation".}
+
+proc getCurrentProcess*(): Handle{.stdcall, dynlib: "kernel32",
+                                   importc: "GetCurrentProcess".}
+
+proc createFileW*(lpFileName: WideCString, dwDesiredAccess, dwShareMode: DWORD,
+                  lpSecurityAttributes: pointer,
+                  dwCreationDisposition, dwFlagsAndAttributes: DWORD,
+                  hTemplateFile: Handle): Handle {.
+    stdcall, dynlib: "kernel32", importc: "CreateFileW".}
+proc deleteFileW*(pathName: WideCString): int32 {.
+  importc: "DeleteFileW", dynlib: "kernel32", stdcall.}
+proc createFileA*(lpFileName: cstring, dwDesiredAccess, dwShareMode: DWORD,
+                  lpSecurityAttributes: pointer,
+                  dwCreationDisposition, dwFlagsAndAttributes: DWORD,
+                  hTemplateFile: Handle): Handle {.
+    stdcall, dynlib: "kernel32", importc: "CreateFileA".}
+proc deleteFileA*(pathName: cstring): int32 {.
+  importc: "DeleteFileA", dynlib: "kernel32", stdcall.}
+
+proc setEndOfFile*(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32",
+    importc: "SetEndOfFile".}
+
+proc setFilePointer*(hFile: Handle, lDistanceToMove: LONG,
+                     lpDistanceToMoveHigh: ptr LONG,
+                     dwMoveMethod: DWORD): DWORD {.
+    stdcall, dynlib: "kernel32", importc: "SetFilePointer".}
+
+proc getFileSize*(hFile: Handle, lpFileSizeHigh: ptr DWORD): DWORD{.stdcall,
+    dynlib: "kernel32", importc: "GetFileSize".}
+
+when defined(cpu32):
+  type
+    WinSizeT* = uint32
+else:
+  type
+    WinSizeT* = uint64
+
+proc mapViewOfFileEx*(hFileMappingObject: Handle, dwDesiredAccess: DWORD,
+                      dwFileOffsetHigh, dwFileOffsetLow: DWORD,
+                      dwNumberOfBytesToMap: WinSizeT,
+                      lpBaseAddress: pointer): pointer{.
+    stdcall, dynlib: "kernel32", importc: "MapViewOfFileEx".}
+
+proc createFileMappingW*(hFile: Handle,
+                       lpFileMappingAttributes: pointer,
+                       flProtect, dwMaximumSizeHigh: DWORD,
+                       dwMaximumSizeLow: DWORD,
+                       lpName: pointer): Handle {.
+  stdcall, dynlib: "kernel32", importc: "CreateFileMappingW".}
+
+proc unmapViewOfFile*(lpBaseAddress: pointer): WINBOOL {.stdcall,
+    dynlib: "kernel32", importc: "UnmapViewOfFile".}
+
+proc flushViewOfFile*(lpBaseAddress: pointer, dwNumberOfBytesToFlush: DWORD): WINBOOL {.
+  stdcall, dynlib: "kernel32", importc: "FlushViewOfFile".}
+
+type
+  OVERLAPPED* {.pure, inheritable.} = object
+    internal*: PULONG
+    internalHigh*: PULONG
+    offset*: DWORD
+    offsetHigh*: DWORD
+    hEvent*: Handle
+
+  POVERLAPPED* = ptr OVERLAPPED
+
+  POVERLAPPED_COMPLETION_ROUTINE* = proc (para1: DWORD, para2: DWORD,
+      para3: POVERLAPPED){.stdcall.}
+
+  GUID* = object
+    D1*: int32
+    D2*: int16
+    D3*: int16
+    D4*: array[0..7, int8]
+
+const
+  ERROR_IO_PENDING* = 997 # a.k.a WSA_IO_PENDING
+  WSAECONNABORTED* = 10053
+  WSAEADDRINUSE* = 10048
+  WSAECONNRESET* = 10054
+  WSAEDISCON* = 10101
+  WSAENETRESET* = 10052
+  WSAETIMEDOUT* = 10060
+  WSANOTINITIALISED* = 10093
+  WSAENOTSOCK* = 10038
+  WSAEINPROGRESS* = 10036
+  WSAEINTR* = 10004
+  WSAEWOULDBLOCK* = 10035
+  WSAESHUTDOWN* = 10058
+  ERROR_NETNAME_DELETED* = 64
+  STATUS_PENDING* = 0x103
+
+proc createIoCompletionPort*(FileHandle: Handle, ExistingCompletionPort: Handle,
+                             CompletionKey: ULONG_PTR,
+                             NumberOfConcurrentThreads: DWORD): Handle{.stdcall,
+    dynlib: "kernel32", importc: "CreateIoCompletionPort".}
+
+proc getQueuedCompletionStatus*(CompletionPort: Handle,
+    lpNumberOfBytesTransferred: PDWORD, lpCompletionKey: PULONG_PTR,
+                                lpOverlapped: ptr POVERLAPPED,
+                                dwMilliseconds: DWORD): WINBOOL{.stdcall,
+    dynlib: "kernel32", importc: "GetQueuedCompletionStatus".}
+
+proc getOverlappedResult*(hFile: Handle, lpOverlapped: POVERLAPPED,
+              lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.
+    stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}
+
+# this is copy of HasOverlappedIoCompleted() macro from <winbase.h>
+# because we have declared own OVERLAPPED structure with member names not
+# compatible with original names.
+template hasOverlappedIoCompleted*(lpOverlapped): bool =
+  (cast[uint](lpOverlapped.internal) != STATUS_PENDING)
+
+const
+ IOC_OUT* = 0x40000000'i32
+ IOC_IN*  = 0x80000000'i32
+ IOC_WS2* = 0x08000000'i32
+ IOC_INOUT* = IOC_IN or IOC_OUT
+
+template WSAIORW*(x,y): untyped = (IOC_INOUT or x or y)
+
+const
+  SIO_GET_EXTENSION_FUNCTION_POINTER* = WSAIORW(IOC_WS2,6).DWORD
+  SO_UPDATE_ACCEPT_CONTEXT* = 0x700B
+  AI_V4MAPPED* = 0x0008
+  AF_UNSPEC* = 0
+  AF_INET* = 2
+  AF_INET6* = 23
+
+var
+  WSAID_CONNECTEX*: GUID = GUID(D1: 0x25a207b9, D2: 0xddf3'i16, D3: 0x4660, D4: [
+    0x8e'i8, 0xe9'i8, 0x76'i8, 0xe5'i8, 0x8c'i8, 0x74'i8, 0x06'i8, 0x3e'i8])
+  WSAID_ACCEPTEX*: GUID = GUID(D1: 0xb5367df1'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [
+    0x95'i8, 0xca'i8, 0x00'i8, 0x80'i8, 0x5f'i8, 0x48'i8, 0xa1'i8, 0x92'i8])
+  WSAID_GETACCEPTEXSOCKADDRS*: GUID = GUID(D1: 0xb5367df2'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [
+    0x95'i8, 0xca'i8, 0x00'i8, 0x80'i8, 0x5f'i8, 0x48'i8, 0xa1'i8, 0x92'i8])
+
+proc WSAIoctl*(s: SocketHandle, dwIoControlCode: DWORD, lpvInBuffer: pointer,
+  cbInBuffer: DWORD, lpvOutBuffer: pointer, cbOutBuffer: DWORD,
+  lpcbBytesReturned: PDWORD, lpOverlapped: POVERLAPPED,
+  lpCompletionRoutine: POVERLAPPED_COMPLETION_ROUTINE): cint
+  {.stdcall, importc: "WSAIoctl", dynlib: "Ws2_32.dll".}
+
+type
+  TWSABuf* {.importc: "WSABUF", header: "winsock2.h".} = object
+    len*: ULONG
+    buf*: cstring
+
+proc WSARecv*(s: SocketHandle, buf: ptr TWSABuf, bufCount: DWORD,
+  bytesReceived, flags: PDWORD, lpOverlapped: POVERLAPPED,
+  completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.
+  stdcall, importc: "WSARecv", dynlib: "Ws2_32.dll".}
+
+proc WSARecvFrom*(s: SocketHandle, buf: ptr TWSABuf, bufCount: DWORD,
+                  bytesReceived: PDWORD, flags: PDWORD, name: ptr SockAddr,
+                  namelen: ptr cint, lpOverlapped: POVERLAPPED,
+                  completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.
+     stdcall, importc: "WSARecvFrom", dynlib: "Ws2_32.dll".}
+
+proc WSASend*(s: SocketHandle, buf: ptr TWSABuf, bufCount: DWORD,
+  bytesSent: PDWORD, flags: DWORD, lpOverlapped: POVERLAPPED,
+  completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.
+  stdcall, importc: "WSASend", dynlib: "Ws2_32.dll".}
+
+proc WSASendTo*(s: SocketHandle, buf: ptr TWSABuf, bufCount: DWORD,
+                bytesSent: PDWORD, flags: DWORD, name: ptr SockAddr,
+                namelen: cint, lpOverlapped: POVERLAPPED,
+                completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {.
+     stdcall, importc: "WSASendTo", dynlib: "Ws2_32.dll".}
+
+proc get_osfhandle*(fd:FileHandle): Handle {.
+  importc: "_get_osfhandle", header:"<io.h>".}
+
+proc getSystemTimes*(lpIdleTime, lpKernelTime,
+                     lpUserTime: var FILETIME): WINBOOL {.stdcall,
+  dynlib: "kernel32", importc: "GetSystemTimes".}
+
+proc getProcessTimes*(hProcess: Handle; lpCreationTime, lpExitTime,
+  lpKernelTime, lpUserTime: var FILETIME): WINBOOL {.stdcall,
+  dynlib: "kernel32", importc: "GetProcessTimes".}
+
+proc getSystemTimePreciseAsFileTime*(lpSystemTimeAsFileTime: var FILETIME) {.
+  importc: "GetSystemTimePreciseAsFileTime", dynlib: "kernel32", stdcall, sideEffect.}
+
+type inet_ntop_proc = proc(family: cint, paddr: pointer, pStringBuffer: cstring,
+                      stringBufSize: int32): cstring {.gcsafe, stdcall, tags: [].}
+
+var inet_ntop_real: inet_ntop_proc = nil
+
+let ws2 = loadLib(ws2dll)
+if ws2 != nil:
+  inet_ntop_real = cast[inet_ntop_proc](symAddr(ws2, "inet_ntop"))
+
+proc WSAAddressToStringA(pAddr: ptr SockAddr, addrSize: DWORD, unused: pointer, pBuff: cstring, pBuffSize: ptr DWORD): cint {.stdcall, importc, dynlib: ws2dll.}
+proc inet_ntop_emulated(family: cint, paddr: pointer, pStringBuffer: cstring,
+                  stringBufSize: int32): cstring {.stdcall.} =
+  case family
+  of AF_INET:
+    var sa: Sockaddr_in
+    sa.sin_family = AF_INET
+    sa.sin_addr = cast[ptr InAddr](paddr)[]
+    var bs = stringBufSize.DWORD
+    let r = WSAAddressToStringA(cast[ptr SockAddr](sa.addr), sa.sizeof.DWORD, nil, pStringBuffer, bs.addr)
+    if r != 0:
+      result = nil
+    else:
+      result = pStringBuffer
+  of AF_INET6:
+    var sa: Sockaddr_in6
+    sa.sin6_family = AF_INET6
+    sa.sin6_addr = cast[ptr In6_addr](paddr)[]
+    var bs = stringBufSize.DWORD
+    let r = WSAAddressToStringA(cast[ptr SockAddr](sa.addr), sa.sizeof.DWORD, nil, pStringBuffer, bs.addr)
+    if r != 0:
+      result = nil
+    else:
+      result = pStringBuffer
+  else:
+    setLastError(ERROR_BAD_ARGUMENTS)
+    result = nil
+
+proc inet_ntop*(family: cint, paddr: pointer, pStringBuffer: cstring,
+                  stringBufSize: int32): cstring {.stdcall.} =
+  var ver: OSVERSIONINFO
+  ver.dwOSVersionInfoSize = sizeof(ver).DWORD
+  let res = getVersionExW(ver.addr)
+  if res == 0:
+    result = nil
+  elif ver.dwMajorVersion >= 6:
+    if inet_ntop_real == nil:
+      quit("Can't load inet_ntop proc from " & ws2dll)
+    result = inet_ntop_real(family, paddr, pStringBuffer, stringBufSize)
+  else:
+    result = inet_ntop_emulated(family, paddr, pStringBuffer, stringBufSize)
+
+type
+  WSAPROC_ACCEPTEX* = proc (sListenSocket: SocketHandle,
+                            sAcceptSocket: SocketHandle,
+                            lpOutputBuffer: pointer, dwReceiveDataLength: DWORD,
+                            dwLocalAddressLength: DWORD,
+                            dwRemoteAddressLength: DWORD,
+                            lpdwBytesReceived: ptr DWORD,
+                            lpOverlapped: POVERLAPPED): bool {.
+                            stdcall, gcsafe, raises: [].}
+
+  WSAPROC_CONNECTEX* = proc (s: SocketHandle, name: ptr SockAddr, namelen: cint,
+                             lpSendBuffer: pointer, dwSendDataLength: DWORD,
+                             lpdwBytesSent: ptr DWORD,
+                             lpOverlapped: POVERLAPPED): bool {.
+                             stdcall, gcsafe, raises: [].}
+
+  WSAPROC_GETACCEPTEXSOCKADDRS* = proc(lpOutputBuffer: pointer,
+                                       dwReceiveDataLength: DWORD,
+                                       dwLocalAddressLength: DWORD,
+                                       dwRemoteAddressLength: DWORD,
+                                       LocalSockaddr: ptr PSockAddr,
+                                       LocalSockaddrLength: ptr cint,
+                                       RemoteSockaddr: ptr PSockAddr,
+                                       RemoteSockaddrLength: ptr cint) {.
+                                       stdcall, gcsafe, raises: [].}
+
+const
+  WT_EXECUTEDEFAULT* = 0x00000000'i32
+  WT_EXECUTEINIOTHREAD* = 0x00000001'i32
+  WT_EXECUTEINUITHREAD* = 0x00000002'i32
+  WT_EXECUTEINWAITTHREAD* = 0x00000004'i32
+  WT_EXECUTEONLYONCE* = 0x00000008'i32
+  WT_EXECUTELONGFUNCTION* = 0x00000010'i32
+  WT_EXECUTEINTIMERTHREAD* = 0x00000020'i32
+  WT_EXECUTEINPERSISTENTIOTHREAD* = 0x00000040'i32
+  WT_EXECUTEINPERSISTENTTHREAD* = 0x00000080'i32
+  WT_TRANSFER_IMPERSONATION* = 0x00000100'i32
+  PROCESS_TERMINATE* = 0x00000001'i32
+  PROCESS_CREATE_THREAD* = 0x00000002'i32
+  PROCESS_SET_SESSIONID* = 0x00000004'i32
+  PROCESS_VM_OPERATION* = 0x00000008'i32
+  PROCESS_VM_READ* = 0x00000010'i32
+  PROCESS_VM_WRITE* = 0x00000020'i32
+  PROCESS_DUP_HANDLE* = 0x00000040'i32
+  PROCESS_CREATE_PROCESS* = 0x00000080'i32
+  PROCESS_SET_QUOTA* = 0x00000100'i32
+  PROCESS_SET_INFORMATION* = 0x00000200'i32
+  PROCESS_QUERY_INFORMATION* = 0x00000400'i32
+  PROCESS_SUSPEND_RESUME* = 0x00000800'i32
+  PROCESS_QUERY_LIMITED_INFORMATION* = 0x00001000'i32
+  PROCESS_SET_LIMITED_INFORMATION* = 0x00002000'i32
+type
+  WAITORTIMERCALLBACK* = proc(para1: pointer, para2: int32) {.stdcall.}
+
+proc postQueuedCompletionStatus*(CompletionPort: Handle,
+                                dwNumberOfBytesTransferred: DWORD,
+                                dwCompletionKey: ULONG_PTR,
+                                lpOverlapped: pointer): bool
+     {.stdcall, dynlib: "kernel32", importc: "PostQueuedCompletionStatus".}
+
+proc registerWaitForSingleObject*(phNewWaitObject: ptr Handle, hObject: Handle,
+                                 Callback: WAITORTIMERCALLBACK,
+                                 Context: pointer,
+                                 dwMilliseconds: ULONG,
+                                 dwFlags: ULONG): bool
+     {.stdcall, dynlib: "kernel32", importc: "RegisterWaitForSingleObject".}
+
+proc unregisterWait*(WaitHandle: Handle): DWORD
+     {.stdcall, dynlib: "kernel32", importc: "UnregisterWait".}
+
+proc openProcess*(dwDesiredAccess: DWORD, bInheritHandle: WINBOOL,
+                    dwProcessId: DWORD): Handle
+     {.stdcall, dynlib: "kernel32", importc: "OpenProcess".}
+
+proc createEvent*(lpEventAttributes: ptr SECURITY_ATTRIBUTES,
+                  bManualReset: DWORD, bInitialState: DWORD,
+                  lpName: ptr Utf16Char): Handle
+     {.stdcall, dynlib: "kernel32", importc: "CreateEventW".}
+
+proc setEvent*(hEvent: Handle): cint
+     {.stdcall, dynlib: "kernel32", importc: "SetEvent".}
+
+const
+  FD_READ* = 0x00000001'i32
+  FD_WRITE* = 0x00000002'i32
+  FD_OOB* = 0x00000004'i32
+  FD_ACCEPT* = 0x00000008'i32
+  FD_CONNECT* = 0x00000010'i32
+  FD_CLOSE* = 0x00000020'i32
+  FD_QQS* = 0x00000040'i32
+  FD_GROUP_QQS* = 0x00000080'i32
+  FD_ROUTING_INTERFACE_CHANGE* = 0x00000100'i32
+  FD_ADDRESS_LIST_CHANGE* = 0x00000200'i32
+  FD_ALL_EVENTS* = 0x000003FF'i32
+
+proc wsaEventSelect*(s: SocketHandle, hEventObject: Handle,
+                     lNetworkEvents: clong): cint
+    {.stdcall, importc: "WSAEventSelect", dynlib: "ws2_32.dll".}
+
+proc wsaCreateEvent*(): Handle
+    {.stdcall, importc: "WSACreateEvent", dynlib: "ws2_32.dll".}
+
+proc wsaCloseEvent*(hEvent: Handle): bool
+     {.stdcall, importc: "WSACloseEvent", dynlib: "ws2_32.dll".}
+
+proc wsaResetEvent*(hEvent: Handle): bool
+     {.stdcall, importc: "WSAResetEvent", dynlib: "ws2_32.dll".}
+
+type
+  KEY_EVENT_RECORD* = object
+    eventType*: int16
+    bKeyDown*: WINBOOL
+    wRepeatCount*: int16
+    wVirtualKeyCode*: int16
+    wVirtualScanCode*: int16
+    uChar*: int16
+    dwControlKeyState*: DWORD
+
+proc readConsoleInput*(hConsoleInput: Handle, lpBuffer: pointer, nLength: cint,
+                      lpNumberOfEventsRead: ptr cint): cint
+     {.stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".}
+
+type
+  LPFIBER_START_ROUTINE* = proc (param: pointer) {.stdcall.}
+
+const
+  FIBER_FLAG_FLOAT_SWITCH* = 0x01
+
+proc CreateFiber*(stackSize: int, fn: LPFIBER_START_ROUTINE, param: pointer): pointer {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc CreateFiberEx*(stkCommit: int, stkReserve: int, flags: int32, fn: LPFIBER_START_ROUTINE, param: pointer): pointer {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc ConvertThreadToFiber*(param: pointer): pointer {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc ConvertThreadToFiberEx*(param: pointer, flags: int32): pointer {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc DeleteFiber*(fiber: pointer) {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc SwitchToFiber*(fiber: pointer) {.stdcall, discardable, dynlib: "kernel32", importc.}
+proc GetCurrentFiber*(): pointer {.stdcall, importc, header: "windows.h".}
+
+proc toFILETIME*(t: int64): FILETIME =
+  ## Convert the Windows file time timestamp `t` to `FILETIME`.
+  result = FILETIME(dwLowDateTime: cast[DWORD](t), dwHighDateTime: DWORD(t shr 32))
+
+type
+  LPFILETIME* = ptr FILETIME
+
+proc setFileTime*(hFile: Handle, lpCreationTime: LPFILETIME,
+                 lpLastAccessTime: LPFILETIME, lpLastWriteTime: LPFILETIME): WINBOOL
+     {.stdcall, dynlib: "kernel32", importc: "SetFileTime".}
+
+type
+  # https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-sid_identifier_authority
+  SID_IDENTIFIER_AUTHORITY* {.importc, header: "<windows.h>".} = object
+    value* {.importc: "Value".}: array[6, BYTE]
+  # https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-sid
+  SID* {.importc, header: "<windows.h>".} = object
+    Revision: BYTE
+    SubAuthorityCount: BYTE
+    IdentifierAuthority: SID_IDENTIFIER_AUTHORITY
+    SubAuthority: ptr ptr DWORD
+  PSID* = ptr SID
+
+const
+  # https://docs.microsoft.com/en-us/windows/win32/secauthz/sid-components
+  # https://github.com/mirror/mingw-w64/blob/84c950bdab7c999ace49fe8383856be77f88c4a8/mingw-w64-headers/include/winnt.h#L2994
+  SECURITY_NT_AUTHORITY* = [BYTE(0), BYTE(0), BYTE(0), BYTE(0), BYTE(0), BYTE(5)]
+  SECURITY_BUILTIN_DOMAIN_RID* = 32
+  DOMAIN_ALIAS_RID_ADMINS* = 544
+
+proc allocateAndInitializeSid*(pIdentifierAuthority: ptr SID_IDENTIFIER_AUTHORITY,
+                               nSubAuthorityCount: BYTE,
+                               nSubAuthority0: DWORD,
+                               nSubAuthority1: DWORD,
+                               nSubAuthority2: DWORD,
+                               nSubAuthority3: DWORD,
+                               nSubAuthority4: DWORD,
+                               nSubAuthority5: DWORD,
+                               nSubAuthority6: DWORD,
+                               nSubAuthority7: DWORD,
+                               pSid: ptr PSID): WINBOOL
+     {.stdcall, dynlib: "Advapi32", importc: "AllocateAndInitializeSid".}
+proc checkTokenMembership*(tokenHandle: Handle, sidToCheck: PSID,
+                           isMember: PBOOL): WINBOOL
+     {.stdcall, dynlib: "Advapi32", importc: "CheckTokenMembership".}
+proc freeSid*(pSid: PSID): PSID
+     {.stdcall, dynlib: "Advapi32", importc: "FreeSid".}
 
+when defined(nimHasStyleChecks):
+  {.pop.} # {.push styleChecks: off.}
diff --git a/lib/wrappers/cairo/cairo.nim b/lib/wrappers/cairo/cairo.nim
deleted file mode 100755
index 2c9d76bf7..000000000
--- a/lib/wrappers/cairo/cairo.nim
+++ /dev/null
@@ -1,737 +0,0 @@
-#* cairo - a vector graphics library with display and print output
-# *
-# * Copyright © 2002 University of Southern California
-# * Copyright © 2005 Red Hat, Inc.
-# *
-# * This library is free software; you can redistribute it and/or
-# * modify it either under the terms of the GNU Lesser General Public
-# * License version 2.1 as published by the Free Software Foundation
-# * (the "LGPL") or, at your option, under the terms of the Mozilla
-# * Public License Version 1.1 (the "MPL"). If you do not alter this
-# * notice, a recipient may use your version of this file under either
-# * the MPL or the LGPL.
-# *
-# * You should have received a copy of the LGPL along with this library
-# * in the file COPYING-LGPL-2.1; if not, write to the Free Software
-# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# * You should have received a copy of the MPL along with this library
-# * in the file COPYING-MPL-1.1
-# *
-# * The contents of this file are subject to the Mozilla Public License
-# * Version 1.1 (the "License"); you may not use this file except in
-# * compliance with the License. You may obtain a copy of the License at
-# * http://www.mozilla.org/MPL/
-# *
-# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
-# * OF ANY KIND, either express or implied. See the LGPL or the MPL for
-# * the specific language governing rights and limitations.
-# *
-# * The Original Code is the cairo graphics library.
-# *
-# * The Initial Developer of the Original Code is University of Southern
-# * California.
-# *
-# * Contributor(s):
-# *	Carl D. Worth <cworth@cworth.org>
-# #*
-# *  This FreePascal binding generated August 26, 2005
-# *  by Jeffrey Pohlmeyer <yetanothergeek@yahoo.com>
-#
-
-#
-#  - Updated to cairo version 1.4
-#  - Grouped OS specific fuctions in separated units
-#  - Organized the functions by group and ordered exactly as the c header
-#  - Cleared parameter list syntax according to pascal standard
-#
-#  By Luiz Américo Pereira Câmara
-#  October 2007
-#
-
-when defined(windows): 
-  const 
-    LIB_CAIRO* = "libcairo-2.dll"
-else: 
-  const 
-    LIB_CAIRO* = "libcairo.so"
-type 
-  PByte = cstring
-  TStatus* = enum 
-    STATUS_SUCCESS = 0,
-    STATUS_NO_MEMORY,
-    STATUS_INVALID_RESTORE,
-    STATUS_INVALID_POP_GROUP,
-    STATUS_NO_CURRENT_POINT,
-    STATUS_INVALID_MATRIX,
-    STATUS_INVALID_STATUS,
-    STATUS_NULL_POINTER,
-    STATUS_INVALID_STRING,
-    STATUS_INVALID_PATH_DATA,
-    STATUS_READ_ERROR,
-    STATUS_WRITE_ERROR,
-    STATUS_SURFACE_FINISHED,
-    STATUS_SURFACE_TYPE_MISMATCH,
-    STATUS_PATTERN_TYPE_MISMATCH,
-    STATUS_INVALID_CONTENT,
-    STATUS_INVALID_FORMAT,
-    STATUS_INVALID_VISUAL,
-    STATUS_FILE_NOT_FOUND,
-    STATUS_INVALID_DASH,
-    STATUS_INVALID_DSC_COMMENT,
-    STATUS_INVALID_INDEX,
-    STATUS_CLIP_NOT_REPRESENTABLE,
-    STATUS_TEMP_FILE_ERROR,
-    STATUS_INVALID_STRIDE,
-    STATUS_FONT_TYPE_MISMATCH,
-    STATUS_USER_FONT_IMMUTABLE,
-    STATUS_USER_FONT_ERROR,
-    STATUS_NEGATIVE_COUNT,
-    STATUS_INVALID_CLUSTERS,
-    STATUS_INVALID_SLANT,
-    STATUS_INVALID_WEIGHT
-
-    
-  TOperator* = enum 
-    OPERATOR_CLEAR, OPERATOR_SOURCE, OPERATOR_OVER, OPERATOR_IN, OPERATOR_OUT, 
-    OPERATOR_ATOP, OPERATOR_DEST, OPERATOR_DEST_OVER, OPERATOR_DEST_IN, 
-    OPERATOR_DEST_OUT, OPERATOR_DEST_ATOP, OPERATOR_XOR, OPERATOR_ADD, 
-    OPERATOR_SATURATE
-  TAntialias* = enum 
-    ANTIALIAS_DEFAULT, ANTIALIAS_NONE, ANTIALIAS_GRAY, ANTIALIAS_SUBPIXEL
-  TFillRule* = enum 
-    FILL_RULE_WINDING, FILL_RULE_EVEN_ODD
-  TLineCap* = enum 
-    LINE_CAP_BUTT, LINE_CAP_ROUND, LINE_CAP_SQUARE
-  TLineJoin* = enum 
-    LINE_JOIN_MITER, LINE_JOIN_ROUND, LINE_JOIN_BEVEL
-  TFontSlant* = enum 
-    FONT_SLANT_NORMAL, FONT_SLANT_ITALIC, FONT_SLANT_OBLIQUE
-  TFontWeight* = enum 
-    FONT_WEIGHT_NORMAL, FONT_WEIGHT_BOLD
-  TSubpixelOrder* = enum 
-    SUBPIXEL_ORDER_DEFAULT, SUBPIXEL_ORDER_RGB, SUBPIXEL_ORDER_BGR, 
-    SUBPIXEL_ORDER_VRGB, SUBPIXEL_ORDER_VBGR
-  THintStyle* = enum 
-    HINT_STYLE_DEFAULT, HINT_STYLE_NONE, HINT_STYLE_SLIGHT, HINT_STYLE_MEDIUM, 
-    HINT_STYLE_FULL
-  THintMetrics* = enum 
-    HINT_METRICS_DEFAULT, HINT_METRICS_OFF, HINT_METRICS_ON
-  TPathDataType* = enum 
-    PATH_MOVE_TO, PATH_LINE_TO, PATH_CURVE_TO, PATH_CLOSE_PATH
-  TContent* = enum 
-    CONTENT_COLOR = 0x00001000, CONTENT_ALPHA = 0x00002000, 
-    CONTENT_COLOR_ALPHA = 0x00003000
-  TFormat* = enum 
-    FORMAT_ARGB32, FORMAT_RGB24, FORMAT_A8, FORMAT_A1
-  TExtend* = enum 
-    EXTEND_NONE, EXTEND_REPEAT, EXTEND_REFLECT, EXTEND_PAD
-  TFilter* = enum 
-    FILTER_FAST, FILTER_GOOD, FILTER_BEST, FILTER_NEAREST, FILTER_BILINEAR, 
-    FILTER_GAUSSIAN
-  TFontType* = enum 
-    FONT_TYPE_TOY, FONT_TYPE_FT, FONT_TYPE_WIN32, FONT_TYPE_ATSUI
-  TPatternType* = enum 
-    PATTERN_TYPE_SOLID, PATTERN_TYPE_SURFACE, PATTERN_TYPE_LINEAR, 
-    PATTERN_TYPE_RADIAL
-  TSurfaceType* = enum 
-    SURFACE_TYPE_IMAGE, SURFACE_TYPE_PDF, SURFACE_TYPE_PS, SURFACE_TYPE_XLIB, 
-    SURFACE_TYPE_XCB, SURFACE_TYPE_GLITZ, SURFACE_TYPE_QUARTZ, 
-    SURFACE_TYPE_WIN32, SURFACE_TYPE_BEOS, SURFACE_TYPE_DIRECTFB, 
-    SURFACE_TYPE_SVG, SURFACE_TYPE_OS2
-  TSvgVersion* = enum 
-    SVG_VERSION_1_1, SVG_VERSION_1_2
-  PSurface* = ptr TSurface
-  PPSurface* = ptr PSurface
-  PContext* = ptr TContext
-  PPattern* = ptr TPattern
-  PFontOptions* = ptr TFontOptions
-  PFontFace* = ptr TFontFace
-  PScaledFont* = ptr TScaledFont
-  PBool* = ptr TBool
-  TBool* = int32
-  PMatrix* = ptr TMatrix
-  PUserDataKey* = ptr TUserDataKey
-  PGlyph* = ptr TGlyph
-  PTextExtents* = ptr TTextExtents
-  PFontExtents* = ptr TFontExtents
-  PPathDataType* = ptr TPathDataType
-  PPathData* = ptr TPathData
-  PPath* = ptr TPath
-  PRectangle* = ptr TRectangle
-  PRectangleList* = ptr TRectangleList
-  TDestroyFunc* = proc (data: Pointer){.cdecl.}
-  TWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
-  TReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
-  TContext*{.final.} = object        #OPAQUE
-  TSurface*{.final.} = object  #OPAQUE
-  TPattern*{.final.} = object  #OPAQUE
-  TScaledFont*{.final.} = object  #OPAQUE
-  TFontFace*{.final.} = object  #OPAQUE
-  TFontOptions*{.final.} = object  #OPAQUE
-  TMatrix*{.final.} = object 
-    xx: float64
-    yx: float64
-    xy: float64
-    yy: float64
-    x0: float64
-    y0: float64
-
-  TUserDataKey*{.final.} = object 
-    unused: int32
-
-  TGlyph*{.final.} = object 
-    index: int32
-    x: float64
-    y: float64
-
-  TTextExtents*{.final.} = object 
-    x_bearing: float64
-    y_bearing: float64
-    width: float64
-    height: float64
-    x_advance: float64
-    y_advance: float64
-
-  TFontExtents*{.final.} = object 
-    ascent: float64
-    descent: float64
-    height: float64
-    max_x_advance: float64
-    max_y_advance: float64
-
-  TPathData*{.final.} = object  #* _type : TCairoPathDataType;
-                                #       length : LongInt;
-                                #    end
-    x: float64
-    y: float64
-
-  TPath*{.final.} = object 
-    status: TStatus
-    data: PPathData
-    num_data: int32
-
-  TRectangle*{.final.} = object 
-    x, y, width, height: float64
-
-  TRectangleList*{.final.} = object 
-    status: TStatus
-    rectangles: PRectangle
-    num_rectangles: int32
-
-
-proc version*(): int32{.cdecl, importc: "cairo_version", dynlib: LIB_CAIRO.}
-proc version_string*(): cstring{.cdecl, importc: "cairo_version_string", 
-                                 dynlib: LIB_CAIRO.}
-  #Helper function to retrieve decoded version
-proc version*(major, minor, micro: var int32)
-  #* Functions for manipulating state objects
-proc create*(target: PSurface): PContext{.cdecl, importc: "cairo_create", 
-                                   dynlib: LIB_CAIRO.}
-proc reference*(cr: PContext): PContext{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
-proc destroy*(cr: PContext){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
-proc get_reference_count*(cr: PContext): int32{.cdecl, 
-    importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.}
-proc get_user_data*(cr: PContext, key: PUserDataKey): pointer{.cdecl, 
-    importc: "cairo_get_user_data", dynlib: LIB_CAIRO.}
-proc set_user_data*(cr: PContext, key: PUserDataKey, user_data: Pointer, 
-                    destroy: TDestroyFunc): TStatus{.cdecl, 
-    importc: "cairo_set_user_data", dynlib: LIB_CAIRO.}
-proc save*(cr: PContext){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
-proc restore*(cr: PContext){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
-proc push_group*(cr: PContext){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
-proc push_group_with_content*(cr: PContext, content: TContent){.cdecl, 
-    importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.}
-proc pop_group*(cr: PContext): PPattern{.cdecl, importc: "cairo_pop_group", 
-                                  dynlib: LIB_CAIRO.}
-proc pop_group_to_source*(cr: PContext){.cdecl, importc: "cairo_pop_group_to_source", 
-                                  dynlib: LIB_CAIRO.}
-  #* Modify state
-proc set_operator*(cr: PContext, op: TOperator){.cdecl, importc: "cairo_set_operator", 
-    dynlib: LIB_CAIRO.}
-proc set_source*(cr: PContext, source: PPattern){.cdecl, importc: "cairo_set_source", 
-    dynlib: LIB_CAIRO.}
-proc set_source_rgb*(cr: PContext, red, green, blue: float64){.cdecl, 
-    importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.}
-proc set_source_rgba*(cr: PContext, red, green, blue, alpha: float64){.cdecl, 
-    importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.}
-proc set_source*(cr: PContext, surface: PSurface, x, y: float64){.cdecl, 
-    importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.}
-proc set_tolerance*(cr: PContext, tolerance: float64){.cdecl, 
-    importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.}
-proc set_antialias*(cr: PContext, antialias: TAntialias){.cdecl, 
-    importc: "cairo_set_antialias", dynlib: LIB_CAIRO.}
-proc set_fill_rule*(cr: PContext, fill_rule: TFillRule){.cdecl, 
-    importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.}
-proc set_line_width*(cr: PContext, width: float64){.cdecl, 
-    importc: "cairo_set_line_width", dynlib: LIB_CAIRO.}
-proc set_line_cap*(cr: PContext, line_cap: TLineCap){.cdecl, 
-    importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.}
-proc set_line_join*(cr: PContext, line_join: TLineJoin){.cdecl, 
-    importc: "cairo_set_line_join", dynlib: LIB_CAIRO.}
-proc set_dash*(cr: PContext, dashes: openarray[float64], offset: float64){.cdecl, 
-    importc: "cairo_set_dash", dynlib: LIB_CAIRO.}
-proc set_miter_limit*(cr: PContext, limit: float64){.cdecl, 
-    importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.}
-proc translate*(cr: PContext, tx, ty: float64){.cdecl, importc: "cairo_translate", 
-    dynlib: LIB_CAIRO.}
-proc scale*(cr: PContext, sx, sy: float64){.cdecl, importc: "cairo_scale", 
-                                     dynlib: LIB_CAIRO.}
-proc rotate*(cr: PContext, angle: float64){.cdecl, importc: "cairo_rotate", 
-                                     dynlib: LIB_CAIRO.}
-proc transform*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_transform", 
-    dynlib: LIB_CAIRO.}
-proc set_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix", 
-    dynlib: LIB_CAIRO.}
-proc identity_matrix*(cr: PContext){.cdecl, importc: "cairo_identity_matrix", 
-                              dynlib: LIB_CAIRO.}
-proc user_to_device*(cr: PContext, x, y: var float64){.cdecl, 
-    importc: "cairo_user_to_device", dynlib: LIB_CAIRO.}
-proc user_to_device_distance*(cr: PContext, dx, dy: var float64){.cdecl, 
-    importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.}
-proc device_to_user*(cr: PContext, x, y: var float64){.cdecl, 
-    importc: "cairo_device_to_user", dynlib: LIB_CAIRO.}
-proc device_to_user_distance*(cr: PContext, dx, dy: var float64){.cdecl, 
-    importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.}
-  #* Path creation functions
-proc new_path*(cr: PContext){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
-proc move_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_move_to", 
-                                     dynlib: LIB_CAIRO.}
-proc new_sub_path*(cr: PContext){.cdecl, importc: "cairo_new_sub_path", 
-                           dynlib: LIB_CAIRO.}
-proc line_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_line_to", 
-                                     dynlib: LIB_CAIRO.}
-proc curve_to*(cr: PContext, x1, y1, x2, y2, x3, y3: float64){.cdecl, 
-    importc: "cairo_curve_to", dynlib: LIB_CAIRO.}
-proc arc*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl, 
-    importc: "cairo_arc", dynlib: LIB_CAIRO.}
-proc arc_negative*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl, 
-    importc: "cairo_arc_negative", dynlib: LIB_CAIRO.}
-proc rel_move_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to", 
-    dynlib: LIB_CAIRO.}
-proc rel_line_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to", 
-    dynlib: LIB_CAIRO.}
-proc rel_curve_to*(cr: PContext, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl, 
-    importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.}
-proc rectangle*(cr: PContext, x, y, width, height: float64){.cdecl, 
-    importc: "cairo_rectangle", dynlib: LIB_CAIRO.}
-proc close_path*(cr: PContext){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
-  #* Painting functions
-proc paint*(cr: PContext){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
-proc paint_with_alpha*(cr: PContext, alpha: float64){.cdecl, 
-    importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.}
-proc mask*(cr: PContext, pattern: PPattern){.cdecl, importc: "cairo_mask", 
-                                      dynlib: LIB_CAIRO.}
-proc mask*(cr: PContext, surface: PSurface, surface_x, surface_y: float64){.
-    cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.}
-proc stroke*(cr: PContext){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
-proc stroke_preserve*(cr: PContext){.cdecl, importc: "cairo_stroke_preserve", 
-                              dynlib: LIB_CAIRO.}
-proc fill*(cr: PContext){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
-proc fill_preserve*(cr: PContext){.cdecl, importc: "cairo_fill_preserve", 
-                            dynlib: LIB_CAIRO.}
-proc copy_page*(cr: PContext){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
-proc show_page*(cr: PContext){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
-  #* Insideness testing
-proc in_stroke*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke", 
-    dynlib: LIB_CAIRO.}
-proc in_fill*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill", 
-    dynlib: LIB_CAIRO.}
-  #* Rectangular extents
-proc stroke_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl, 
-    importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.}
-proc fill_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl, 
-    importc: "cairo_fill_extents", dynlib: LIB_CAIRO.}
-  #* Clipping
-proc reset_clip*(cr: PContext){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
-proc clip*(cr: PContext){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
-proc clip_preserve*(cr: PContext){.cdecl, importc: "cairo_clip_preserve", 
-                            dynlib: LIB_CAIRO.}
-proc clip_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl, 
-    importc: "cairo_clip_extents", dynlib: LIB_CAIRO.}
-proc copy_clip_rectangle_list*(cr: PContext): PRectangleList{.cdecl, 
-    importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.}
-proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl, 
-    importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.}
-  #* Font/Text functions
-proc font_options_create*(): PFontOptions{.cdecl, 
-    importc: "cairo_font_options_create", dynlib: LIB_CAIRO.}
-proc copy*(original: PFontOptions): PFontOptions{.cdecl, 
-    importc: "cairo_font_options_copy", dynlib: LIB_CAIRO.}
-proc destroy*(options: PFontOptions){.cdecl, 
-    importc: "cairo_font_options_destroy", dynlib: LIB_CAIRO.}
-proc status*(options: PFontOptions): TStatus{.cdecl, 
-    importc: "cairo_font_options_status", dynlib: LIB_CAIRO.}
-proc merge*(options, other: PFontOptions){.cdecl, 
-    importc: "cairo_font_options_merge", dynlib: LIB_CAIRO.}
-proc equal*(options, other: PFontOptions): TBool{.cdecl, 
-    importc: "cairo_font_options_equal", dynlib: LIB_CAIRO.}
-proc hash*(options: PFontOptions): int32{.cdecl, 
-    importc: "cairo_font_options_hash", dynlib: LIB_CAIRO.}
-proc set_antialias*(options: PFontOptions, antialias: TAntialias){.
-    cdecl, importc: "cairo_font_options_set_antialias", dynlib: LIB_CAIRO.}
-proc get_antialias*(options: PFontOptions): TAntialias{.cdecl, 
-    importc: "cairo_font_options_get_antialias", dynlib: LIB_CAIRO.}
-proc set_subpixel_order*(options: PFontOptions, 
-                                      subpixel_order: TSubpixelOrder){.cdecl, 
-    importc: "cairo_font_options_set_subpixel_order", dynlib: LIB_CAIRO.}
-proc get_subpixel_order*(options: PFontOptions): TSubpixelOrder{.
-    cdecl, importc: "cairo_font_options_get_subpixel_order", dynlib: LIB_CAIRO.}
-proc set_hint_style*(options: PFontOptions, hint_style: THintStyle){.
-    cdecl, importc: "cairo_font_options_set_hint_style", dynlib: LIB_CAIRO.}
-proc get_hint_style*(options: PFontOptions): THintStyle{.cdecl, 
-    importc: "cairo_font_options_get_hint_style", dynlib: LIB_CAIRO.}
-proc set_hint_metrics*(options: PFontOptions, 
-                                    hint_metrics: THintMetrics){.cdecl, 
-    importc: "cairo_font_options_set_hint_metrics", dynlib: LIB_CAIRO.}
-proc get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl, 
-    importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.}
-  #* This interface is for dealing with text as text, not caring about the
-  #   font object inside the the TCairo.
-proc select_font_face*(cr: PContext, family: cstring, slant: TFontSlant, 
-                       weight: TFontWeight){.cdecl, 
-    importc: "cairo_select_font_face", dynlib: LIB_CAIRO.}
-proc set_font_size*(cr: PContext, size: float64){.cdecl, 
-    importc: "cairo_set_font_size", dynlib: LIB_CAIRO.}
-proc set_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl, 
-    importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.}
-proc get_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl, 
-    importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.}
-proc set_font_options*(cr: PContext, options: PFontOptions){.cdecl, 
-    importc: "cairo_set_font_options", dynlib: LIB_CAIRO.}
-proc get_font_options*(cr: PContext, options: PFontOptions){.cdecl, 
-    importc: "cairo_get_font_options", dynlib: LIB_CAIRO.}
-proc set_font_face*(cr: PContext, font_face: PFontFace){.cdecl, 
-    importc: "cairo_set_font_face", dynlib: LIB_CAIRO.}
-proc get_font_face*(cr: PContext): PFontFace{.cdecl, importc: "cairo_get_font_face", 
-                                       dynlib: LIB_CAIRO.}
-proc set_scaled_font*(cr: PContext, scaled_font: PScaledFont){.cdecl, 
-    importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.}
-proc get_scaled_font*(cr: PContext): PScaledFont{.cdecl, 
-    importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.}
-proc show_text*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_show_text", 
-                                       dynlib: LIB_CAIRO.}
-proc show_glyphs*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl, 
-    importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.}
-proc text_path*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_text_path", 
-                                       dynlib: LIB_CAIRO.}
-proc glyph_path*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl, 
-    importc: "cairo_glyph_path", dynlib: LIB_CAIRO.}
-proc text_extents*(cr: PContext, utf8: cstring, extents: PTextExtents){.cdecl, 
-    importc: "cairo_text_extents", dynlib: LIB_CAIRO.}
-proc glyph_extents*(cr: PContext, glyphs: PGlyph, num_glyphs: int32, 
-                    extents: PTextExtents){.cdecl, 
-    importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.}
-proc font_extents*(cr: PContext, extents: PFontExtents){.cdecl, 
-    importc: "cairo_font_extents", dynlib: LIB_CAIRO.}
-  #* Generic identifier for a font style
-proc reference*(font_face: PFontFace): PFontFace{.cdecl, 
-    importc: "cairo_font_face_reference", dynlib: LIB_CAIRO.}
-proc destroy*(font_face: PFontFace){.cdecl, 
-    importc: "cairo_font_face_destroy", dynlib: LIB_CAIRO.}
-proc get_reference_count*(font_face: PFontFace): int32{.cdecl, 
-    importc: "cairo_font_face_get_reference_count", dynlib: LIB_CAIRO.}
-proc status*(font_face: PFontFace): TStatus{.cdecl, 
-    importc: "cairo_font_face_status", dynlib: LIB_CAIRO.}
-proc get_type*(font_face: PFontFace): TFontType{.cdecl, 
-    importc: "cairo_font_face_get_type", dynlib: LIB_CAIRO.}
-proc get_user_data*(font_face: PFontFace, key: PUserDataKey): pointer{.
-    cdecl, importc: "cairo_font_face_get_user_data", dynlib: LIB_CAIRO.}
-proc set_user_data*(font_face: PFontFace, key: PUserDataKey, 
-                    user_data: pointer, destroy: TDestroyFunc): TStatus{.
-    cdecl, importc: "cairo_font_face_set_user_data", dynlib: LIB_CAIRO.}
-  #* Portable interface to general font features
-proc scaled_font_create*(font_face: PFontFace, font_matrix: PMatrix, 
-                         ctm: PMatrix, options: PFontOptions): PScaledFont{.
-    cdecl, importc: "cairo_scaled_font_create", dynlib: LIB_CAIRO.}
-proc reference*(scaled_font: PScaledFont): PScaledFont{.cdecl, 
-    importc: "cairo_scaled_font_reference", dynlib: LIB_CAIRO.}
-proc destroy*(scaled_font: PScaledFont){.cdecl, 
-    importc: "cairo_scaled_font_destroy", dynlib: LIB_CAIRO.}
-proc get_reference_count*(scaled_font: PScaledFont): int32{.cdecl, 
-    importc: "cairo_scaled_font_get_reference_count", dynlib: LIB_CAIRO.}
-proc status*(scaled_font: PScaledFont): TStatus{.cdecl, 
-    importc: "cairo_scaled_font_status", dynlib: LIB_CAIRO.}
-proc get_type*(scaled_font: PScaledFont): TFontType{.cdecl, 
-    importc: "cairo_scaled_font_get_type", dynlib: LIB_CAIRO.}
-proc get_user_data*(scaled_font: PScaledFont, key: PUserDataKey): Pointer{.
-    cdecl, importc: "cairo_scaled_font_get_user_data", dynlib: LIB_CAIRO.}
-proc set_user_data*(scaled_font: PScaledFont, key: PUserDataKey, 
-                    user_data: Pointer, destroy: TDestroyFunc): TStatus{.
-    cdecl, importc: "cairo_scaled_font_set_user_data", dynlib: LIB_CAIRO.}
-proc extents*(scaled_font: PScaledFont, extents: PFontExtents){.
-    cdecl, importc: "cairo_scaled_font_extents", dynlib: LIB_CAIRO.}
-proc text_extents*(scaled_font: PScaledFont, utf8: cstring, 
-                   extents: PTextExtents){.cdecl, 
-    importc: "cairo_scaled_font_text_extents", dynlib: LIB_CAIRO.}
-proc glyph_extents*(scaled_font: PScaledFont, glyphs: PGlyph, 
-                                num_glyphs: int32, extents: PTextExtents){.
-    cdecl, importc: "cairo_scaled_font_glyph_extents", dynlib: LIB_CAIRO.}
-proc get_font_face*(scaled_font: PScaledFont): PFontFace{.cdecl, 
-    importc: "cairo_scaled_font_get_font_face", dynlib: LIB_CAIRO.}
-proc get_font_matrix*(scaled_font: PScaledFont, font_matrix: PMatrix){.
-    cdecl, importc: "cairo_scaled_font_get_font_matrix", dynlib: LIB_CAIRO.}
-proc get_ctm*(scaled_font: PScaledFont, ctm: PMatrix){.cdecl, 
-    importc: "cairo_scaled_font_get_ctm", dynlib: LIB_CAIRO.}
-proc get_font_options*(scaled_font: PScaledFont, 
-                                   options: PFontOptions){.cdecl, 
-    importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.}
-  #* Query functions
-proc get_operator*(cr: PContext): TOperator{.cdecl, importc: "cairo_get_operator", 
-                                      dynlib: LIB_CAIRO.}
-proc get_source*(cr: PContext): PPattern{.cdecl, importc: "cairo_get_source", 
-                                   dynlib: LIB_CAIRO.}
-proc get_tolerance*(cr: PContext): float64{.cdecl, importc: "cairo_get_tolerance", 
-                                     dynlib: LIB_CAIRO.}
-proc get_antialias*(cr: PContext): TAntialias{.cdecl, importc: "cairo_get_antialias", 
-                                        dynlib: LIB_CAIRO.}
-proc get_current_point*(cr: PContext, x, y: var float64){.cdecl, 
-    importc: "cairo_get_current_point", dynlib: LIB_CAIRO.}
-proc get_fill_rule*(cr: PContext): TFillRule{.cdecl, importc: "cairo_get_fill_rule", 
-                                       dynlib: LIB_CAIRO.}
-proc get_line_width*(cr: PContext): float64{.cdecl, importc: "cairo_get_line_width", 
-                                      dynlib: LIB_CAIRO.}
-proc get_line_cap*(cr: PContext): TLineCap{.cdecl, importc: "cairo_get_line_cap", 
-                                     dynlib: LIB_CAIRO.}
-proc get_line_join*(cr: PContext): TLineJoin{.cdecl, importc: "cairo_get_line_join", 
-                                       dynlib: LIB_CAIRO.}
-proc get_miter_limit*(cr: PContext): float64{.cdecl, importc: "cairo_get_miter_limit", 
-                                       dynlib: LIB_CAIRO.}
-proc get_dash_count*(cr: PContext): int32{.cdecl, importc: "cairo_get_dash_count", 
-                                    dynlib: LIB_CAIRO.}
-proc get_dash*(cr: PContext, dashes, offset: var float64){.cdecl, 
-    importc: "cairo_get_dash", dynlib: LIB_CAIRO.}
-proc get_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix", 
-    dynlib: LIB_CAIRO.}
-proc get_target*(cr: PContext): PSurface{.cdecl, importc: "cairo_get_target", 
-                                   dynlib: LIB_CAIRO.}
-proc get_group_target*(cr: PContext): PSurface{.cdecl, 
-    importc: "cairo_get_group_target", dynlib: LIB_CAIRO.}
-proc copy_path*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path", 
-                               dynlib: LIB_CAIRO.}
-proc copy_path_flat*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path_flat", 
-                                    dynlib: LIB_CAIRO.}
-proc append_path*(cr: PContext, path: PPath){.cdecl, importc: "cairo_append_path", 
-                                       dynlib: LIB_CAIRO.}
-proc destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy", 
-                                 dynlib: LIB_CAIRO.}
-  #* Error status queries
-proc status*(cr: PContext): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
-proc status_to_string*(status: TStatus): cstring{.cdecl, 
-    importc: "cairo_status_to_string", dynlib: LIB_CAIRO.}
-  #* Surface manipulation
-proc surface_create_similar*(other: PSurface, content: TContent, 
-                             width, height: int32): PSurface{.cdecl, 
-    importc: "cairo_surface_create_similar", dynlib: LIB_CAIRO.}
-proc reference*(surface: PSurface): PSurface{.cdecl, 
-    importc: "cairo_surface_reference", dynlib: LIB_CAIRO.}
-proc finish*(surface: PSurface){.cdecl, importc: "cairo_surface_finish", 
-    dynlib: LIB_CAIRO.}
-proc destroy*(surface: PSurface){.cdecl, 
-    importc: "cairo_surface_destroy", dynlib: LIB_CAIRO.}
-proc get_reference_count*(surface: PSurface): int32{.cdecl, 
-    importc: "cairo_surface_get_reference_count", dynlib: LIB_CAIRO.}
-proc status*(surface: PSurface): TStatus{.cdecl, 
-    importc: "cairo_surface_status", dynlib: LIB_CAIRO.}
-proc get_type*(surface: PSurface): TSurfaceType{.cdecl, 
-    importc: "cairo_surface_get_type", dynlib: LIB_CAIRO.}
-proc get_content*(surface: PSurface): TContent{.cdecl, 
-    importc: "cairo_surface_get_content", dynlib: LIB_CAIRO.}
-proc write_to_png*(surface: PSurface, filename: cstring): TStatus{.
-    cdecl, importc: "cairo_surface_write_to_png", dynlib: LIB_CAIRO.}
-proc write_to_png*(surface: PSurface, write_func: TWriteFunc, 
-                   closure: pointer): TStatus{.cdecl, 
-    importc: "cairo_surface_write_to_png_stream", dynlib: LIB_CAIRO.}
-proc get_user_data*(surface: PSurface, key: PUserDataKey): pointer{.
-    cdecl, importc: "cairo_surface_get_user_data", dynlib: LIB_CAIRO.}
-proc set_user_data*(surface: PSurface, key: PUserDataKey, 
-                            user_data: pointer, destroy: TDestroyFunc): TStatus{.
-    cdecl, importc: "cairo_surface_set_user_data", dynlib: LIB_CAIRO.}
-proc get_font_options*(surface: PSurface, options: PFontOptions){.cdecl, 
-    importc: "cairo_surface_get_font_options", dynlib: LIB_CAIRO.}
-proc flush*(surface: PSurface){.cdecl, importc: "cairo_surface_flush", 
-                                        dynlib: LIB_CAIRO.}
-proc mark_dirty*(surface: PSurface){.cdecl, 
-    importc: "cairo_surface_mark_dirty", dynlib: LIB_CAIRO.}
-proc mark_dirty_rectangle*(surface: PSurface, x, y, width, height: int32){.
-    cdecl, importc: "cairo_surface_mark_dirty_rectangle", dynlib: LIB_CAIRO.}
-proc set_device_offset*(surface: PSurface, x_offset, y_offset: float64){.
-    cdecl, importc: "cairo_surface_set_device_offset", dynlib: LIB_CAIRO.}
-proc get_device_offset*(surface: PSurface, 
-                                x_offset, y_offset: var float64){.cdecl, 
-    importc: "cairo_surface_get_device_offset", dynlib: LIB_CAIRO.}
-proc set_fallback_resolution*(surface: PSurface, x_pixels_per_inch, 
-    y_pixels_per_inch: float64){.cdecl, importc: "cairo_surface_set_fallback_resolution", 
-                                 dynlib: LIB_CAIRO.}
-  #* Image-surface functions
-proc image_surface_create*(format: TFormat, width, height: int32): PSurface{.
-    cdecl, importc: "cairo_image_surface_create", dynlib: LIB_CAIRO.}
-proc image_surface_create*(data: Pbyte, format: TFormat, 
-                           width, height, stride: int32): PSurface{.
-    cdecl, importc: "cairo_image_surface_create_for_data", dynlib: LIB_CAIRO.}
-proc get_data*(surface: PSurface): cstring{.cdecl, 
-    importc: "cairo_image_surface_get_data", dynlib: LIB_CAIRO.}
-proc get_format*(surface: PSurface): TFormat{.cdecl, 
-    importc: "cairo_image_surface_get_format", dynlib: LIB_CAIRO.}
-proc get_width*(surface: PSurface): int32{.cdecl, 
-    importc: "cairo_image_surface_get_width", dynlib: LIB_CAIRO.}
-proc get_height*(surface: PSurface): int32{.cdecl, 
-    importc: "cairo_image_surface_get_height", dynlib: LIB_CAIRO.}
-proc get_stride*(surface: PSurface): int32{.cdecl, 
-    importc: "cairo_image_surface_get_stride", dynlib: LIB_CAIRO.}
-proc image_surface_create_from_png*(filename: cstring): PSurface{.cdecl, 
-    importc: "cairo_image_surface_create_from_png", dynlib: LIB_CAIRO.}
-proc image_surface_create_from_png*(read_func: TReadFunc, 
-    closure: pointer): PSurface{.cdecl, importc: "cairo_image_surface_create_from_png_stream", 
-                                 dynlib: LIB_CAIRO.}
-  #* Pattern creation functions
-proc pattern_create_rgb*(red, green, blue: float64): PPattern{.cdecl, 
-    importc: "cairo_pattern_create_rgb", dynlib: LIB_CAIRO.}
-proc pattern_create_rgba*(red, green, blue, alpha: float64): PPattern{.cdecl, 
-    importc: "cairo_pattern_create_rgba", dynlib: LIB_CAIRO.}
-proc pattern_create_for_surface*(surface: PSurface): PPattern{.cdecl, 
-    importc: "cairo_pattern_create_for_surface", dynlib: LIB_CAIRO.}
-proc pattern_create_linear*(x0, y0, x1, y1: float64): PPattern{.cdecl, 
-    importc: "cairo_pattern_create_linear", dynlib: LIB_CAIRO.}
-proc pattern_create_radial*(cx0, cy0, radius0, cx1, cy1, radius1: float64): PPattern{.
-    cdecl, importc: "cairo_pattern_create_radial", dynlib: LIB_CAIRO.}
-proc reference*(pattern: PPattern): PPattern{.cdecl, 
-    importc: "cairo_pattern_reference", dynlib: LIB_CAIRO.}
-proc destroy*(pattern: PPattern){.cdecl, 
-    importc: "cairo_pattern_destroy", dynlib: LIB_CAIRO.}
-proc get_reference_count*(pattern: PPattern): int32{.cdecl, 
-    importc: "cairo_pattern_get_reference_count", dynlib: LIB_CAIRO.}
-proc status*(pattern: PPattern): TStatus{.cdecl, 
-    importc: "cairo_pattern_status", dynlib: LIB_CAIRO.}
-proc get_user_data*(pattern: PPattern, key: PUserDataKey): Pointer{.
-    cdecl, importc: "cairo_pattern_get_user_data", dynlib: LIB_CAIRO.}
-proc set_user_data*(pattern: PPattern, key: PUserDataKey, 
-                    user_data: Pointer, destroy: TDestroyFunc): TStatus{.
-    cdecl, importc: "cairo_pattern_set_user_data", dynlib: LIB_CAIRO.}
-proc get_type*(pattern: PPattern): TPatternType{.cdecl, 
-    importc: "cairo_pattern_get_type", dynlib: LIB_CAIRO.}
-proc add_color_stop_rgb*(pattern: PPattern, 
-                                 offset, red, green, blue: float64){.cdecl, 
-    importc: "cairo_pattern_add_color_stop_rgb", dynlib: LIB_CAIRO.}
-proc add_color_stop_rgba*(pattern: PPattern, 
-                                  offset, red, green, blue, alpha: float64){.
-    cdecl, importc: "cairo_pattern_add_color_stop_rgba", dynlib: LIB_CAIRO.}
-proc set_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl, 
-    importc: "cairo_pattern_set_matrix", dynlib: LIB_CAIRO.}
-proc get_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl, 
-    importc: "cairo_pattern_get_matrix", dynlib: LIB_CAIRO.}
-proc set_extend*(pattern: PPattern, extend: TExtend){.cdecl, 
-    importc: "cairo_pattern_set_extend", dynlib: LIB_CAIRO.}
-proc get_extend*(pattern: PPattern): TExtend{.cdecl, 
-    importc: "cairo_pattern_get_extend", dynlib: LIB_CAIRO.}
-proc set_filter*(pattern: PPattern, filter: TFilter){.cdecl, 
-    importc: "cairo_pattern_set_filter", dynlib: LIB_CAIRO.}
-proc get_filter*(pattern: PPattern): TFilter{.cdecl, 
-    importc: "cairo_pattern_get_filter", dynlib: LIB_CAIRO.}
-proc get_rgba*(pattern: PPattern, 
-               red, green, blue, alpha: var float64): TStatus{.
-    cdecl, importc: "cairo_pattern_get_rgba", dynlib: LIB_CAIRO.}
-proc get_surface*(pattern: PPattern, surface: PPSurface): TStatus{.
-    cdecl, importc: "cairo_pattern_get_surface", dynlib: LIB_CAIRO.}
-proc get_color_stop_rgba*(pattern: PPattern, index: int32, 
-                       offset, red, green, blue, alpha: var float64): TStatus{.
-    cdecl, importc: "cairo_pattern_get_color_stop_rgba", dynlib: LIB_CAIRO.}
-proc get_color_stop_count*(pattern: PPattern, count: var int32): TStatus{.
-    cdecl, importc: "cairo_pattern_get_color_stop_count", dynlib: LIB_CAIRO.}
-proc get_linear_points*(pattern: PPattern, 
-                        x0, y0, x1, y1: var float64): TStatus{.
-    cdecl, importc: "cairo_pattern_get_linear_points", dynlib: LIB_CAIRO.}
-proc get_radial_circles*(pattern: PPattern, 
-                         x0, y0, r0, x1, y1, r1: var float64): TStatus{.
-    cdecl, importc: "cairo_pattern_get_radial_circles", dynlib: LIB_CAIRO.}
-  #* Matrix functions
-proc init*(matrix: PMatrix, xx, yx, xy, yy, x0, y0: float64){.cdecl, 
-    importc: "cairo_matrix_init", dynlib: LIB_CAIRO.}
-proc init_identity*(matrix: PMatrix){.cdecl, 
-    importc: "cairo_matrix_init_identity", dynlib: LIB_CAIRO.}
-proc init_translate*(matrix: PMatrix, tx, ty: float64){.cdecl, 
-    importc: "cairo_matrix_init_translate", dynlib: LIB_CAIRO.}
-proc init_scale*(matrix: PMatrix, sx, sy: float64){.cdecl, 
-    importc: "cairo_matrix_init_scale", dynlib: LIB_CAIRO.}
-proc init_rotate*(matrix: PMatrix, radians: float64){.cdecl, 
-    importc: "cairo_matrix_init_rotate", dynlib: LIB_CAIRO.}
-proc translate*(matrix: PMatrix, tx, ty: float64){.cdecl, 
-    importc: "cairo_matrix_translate", dynlib: LIB_CAIRO.}
-proc scale*(matrix: PMatrix, sx, sy: float64){.cdecl, 
-    importc: "cairo_matrix_scale", dynlib: LIB_CAIRO.}
-proc rotate*(matrix: PMatrix, radians: float64){.cdecl, 
-    importc: "cairo_matrix_rotate", dynlib: LIB_CAIRO.}
-proc invert*(matrix: PMatrix): TStatus{.cdecl, 
-    importc: "cairo_matrix_invert", dynlib: LIB_CAIRO.}
-proc multiply*(result, a, b: PMatrix){.cdecl, 
-    importc: "cairo_matrix_multiply", dynlib: LIB_CAIRO.}
-proc transform_distance*(matrix: PMatrix, dx, dy: var float64){.cdecl, 
-    importc: "cairo_matrix_transform_distance", dynlib: LIB_CAIRO.}
-proc transform_point*(matrix: PMatrix, x, y: var float64){.cdecl, 
-    importc: "cairo_matrix_transform_point", dynlib: LIB_CAIRO.}
-  #* PDF functions
-proc pdf_surface_create*(filename: cstring, 
-                         width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_pdf_surface_create", dynlib: LIB_CAIRO.}
-proc pdf_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer, 
-                                    width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_pdf_surface_create_for_stream", dynlib: LIB_CAIRO.}
-proc pdf_surface_set_size*(surface: PSurface, 
-                           width_in_points, height_in_points: float64){.cdecl, 
-    importc: "cairo_pdf_surface_set_size", dynlib: LIB_CAIRO.}
-  #* PS functions
-proc ps_surface_create*(filename: cstring, 
-                        width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_ps_surface_create", dynlib: LIB_CAIRO.}
-proc ps_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer, 
-                                   width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_ps_surface_create_for_stream", dynlib: LIB_CAIRO.}
-proc ps_surface_set_size*(surface: PSurface, 
-                          width_in_points, height_in_points: float64){.cdecl, 
-    importc: "cairo_ps_surface_set_size", dynlib: LIB_CAIRO.}
-proc ps_surface_dsc_comment*(surface: PSurface, comment: cstring){.cdecl, 
-    importc: "cairo_ps_surface_dsc_comment", dynlib: LIB_CAIRO.}
-proc ps_surface_dsc_begin_setup*(surface: PSurface){.cdecl, 
-    importc: "cairo_ps_surface_dsc_begin_setup", dynlib: LIB_CAIRO.}
-proc ps_surface_dsc_begin_page_setup*(surface: PSurface){.cdecl, 
-    importc: "cairo_ps_surface_dsc_begin_page_setup", dynlib: LIB_CAIRO.}
-  #* SVG functions
-proc svg_surface_create*(filename: cstring, 
-                         width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_svg_surface_create", dynlib: LIB_CAIRO.}
-proc svg_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer, 
-                                    width_in_points, height_in_points: float64): PSurface{.
-    cdecl, importc: "cairo_svg_surface_create_for_stream", dynlib: LIB_CAIRO.}
-proc svg_surface_restrict_to_version*(surface: PSurface, version: TSvgVersion){.
-    cdecl, importc: "cairo_svg_surface_restrict_to_version", dynlib: LIB_CAIRO.}
-  #todo: see how translate this
-  #procedure cairo_svg_get_versions(TCairoSvgVersion const	**versions,
-  #                        int                      	 *num_versions);
-proc svg_version_to_string*(version: TSvgVersion): cstring{.cdecl, 
-    importc: "cairo_svg_version_to_string", dynlib: LIB_CAIRO.}
-  #* Functions to be used while debugging (not intended for use in production code)
-proc debug_reset_static_data*(){.cdecl, 
-                                 importc: "cairo_debug_reset_static_data", 
-                                 dynlib: LIB_CAIRO.}
-# implementation
-
-proc version(major, minor, micro: var int32) = 
-  var version: int32
-  version = version()
-  major = version div 10000'i32
-  minor = (version mod (major * 10000'i32)) div 100'i32
-  micro = (version mod ((major * 10000'i32) + (minor * 100'i32)))
-  
-proc checkStatus*(s: cairo.TStatus) {.noinline.} = 
-  ## if ``s != StatusSuccess`` the error is turned into an appropirate Nimrod
-  ## exception and raised.
-  case s
-  of StatusSuccess: nil
-  of StatusNoMemory: 
-    raise newException(EOutOfMemory, $statusToString(s))
-  of STATUS_READ_ERROR, STATUS_WRITE_ERROR, STATUS_FILE_NOT_FOUND, 
-     STATUS_TEMP_FILE_ERROR:
-    raise newException(EIO, $statusToString(s))
-  else:
-    raise newException(EAssertionFailed, $statusToString(s))
-
-
diff --git a/lib/wrappers/gtk/gdk2.nim b/lib/wrappers/gtk/gdk2.nim
deleted file mode 100755
index 5841aeee3..000000000
--- a/lib/wrappers/gtk/gdk2.nim
+++ /dev/null
@@ -1,3868 +0,0 @@
-{.deadCodeElim: on.}
-import 
-  glib2, gdk2pixbuf, pango
-
-when defined(win32): 
-  const 
-    lib = "libgdk-win32-2.0-0.dll"
-elif defined(darwin): 
-  #    linklib gtk-x11-2.0
-  #    linklib gdk-x11-2.0
-  #    linklib pango-1.0.0
-  #    linklib glib-2.0.0
-  #    linklib gobject-2.0.0
-  #    linklib gdk_pixbuf-2.0.0
-  #    linklib atk-1.0.0
-  const 
-    lib = "gdk-x11-2.0"
-else: 
-  const 
-    lib = "libgdk-x11-2.0.so(|.0)"
-const 
-  NUMPTSTOBUFFER* = 200
-  MAX_TIMECOORD_AXES* = 128
-
-type 
-  PDeviceClass* = ptr TDeviceClass
-  TDeviceClass* = object of TGObjectClass
-  PVisualClass* = ptr TVisualClass
-  TVisualClass* = object of TGObjectClass
-  PColor* = ptr TColor
-  TColor*{.final, pure.} = object 
-    pixel*: guint32
-    red*: guint16
-    green*: guint16
-    blue*: guint16
-
-  PColormap* = ptr TColormap
-  PDrawable* = ptr TDrawable
-  TDrawable* = object of TGObject
-  PWindow* = ptr TWindow
-  TWindow* = TDrawable
-  PPixmap* = ptr TPixmap
-  TPixmap* = TDrawable
-  PBitmap* = ptr TBitmap
-  TBitmap* = TDrawable
-  PFontType* = ptr TFontType
-  TFontType* = enum 
-    FONT_FONT, FONT_FONTSET
-  PFont* = ptr TFont
-  TFont*{.final, pure.} = object 
-    `type`*: TFontType
-    ascent*: gint
-    descent*: gint
-
-  PFunction* = ptr TFunction
-  TFunction* = enum 
-    funcCOPY, funcINVERT, funcXOR, funcCLEAR, funcAND, 
-    funcAND_REVERSE, funcAND_INVERT, funcNOOP, funcOR, funcEQUIV, 
-    funcOR_REVERSE, funcCOPY_INVERT, funcOR_INVERT, funcNAND, funcNOR, funcSET
-  PCapStyle* = ptr TCapStyle
-  TCapStyle* = enum 
-    CAP_NOT_LAST, CAP_BUTT, CAP_ROUND, CAP_PROJECTING
-  PFill* = ptr TFill
-  TFill* = enum 
-    SOLID, TILED, STIPPLED, OPAQUE_STIPPLED
-  PJoinStyle* = ptr TJoinStyle
-  TJoinStyle* = enum 
-    JOIN_MITER, JOIN_ROUND, JOIN_BEVEL
-  PLineStyle* = ptr TLineStyle
-  TLineStyle* = enum 
-    LINE_SOLID, LINE_ON_OFF_DASH, LINE_DOUBLE_DASH
-  PSubwindowMode* = ptr TSubwindowMode
-  TSubwindowMode* = int
-  PGCValuesMask* = ptr TGCValuesMask
-  TGCValuesMask* = int32
-  PGCValues* = ptr TGCValues
-  TGCValues*{.final, pure.} = object 
-    foreground*: TColor
-    background*: TColor
-    font*: PFont
-    `function`*: TFunction
-    fill*: TFill
-    tile*: PPixmap
-    stipple*: PPixmap
-    clip_mask*: PPixmap
-    subwindow_mode*: TSubwindowMode
-    ts_x_origin*: gint
-    ts_y_origin*: gint
-    clip_x_origin*: gint
-    clip_y_origin*: gint
-    graphics_exposures*: gint
-    line_width*: gint
-    line_style*: TLineStyle
-    cap_style*: TCapStyle
-    join_style*: TJoinStyle
-
-  PGC* = ptr TGC
-  TGC* = object of TGObject
-    clip_x_origin*: gint
-    clip_y_origin*: gint
-    ts_x_origin*: gint
-    ts_y_origin*: gint
-    colormap*: PColormap
-
-  PImageType* = ptr TImageType
-  TImageType* = enum 
-    IMAGE_NORMAL, IMAGE_SHARED, IMAGE_FASTEST
-  PImage* = ptr TImage
-  PDevice* = ptr TDevice
-  PTimeCoord* = ptr TTimeCoord
-  PPTimeCoord* = ptr PTimeCoord
-  PRgbDither* = ptr TRgbDither
-  TRgbDither* = enum 
-    RGB_DITHER_NONE, RGB_DITHER_NORMAL, RGB_DITHER_MAX
-  PDisplay* = ptr TDisplay
-  PScreen* = ptr TScreen
-  TScreen* = object of TGObject
-  PInputCondition* = ptr TInputCondition
-  TInputCondition* = int32
-  PStatus* = ptr TStatus
-  TStatus* = int32
-  TPoint*{.final, pure.} = object 
-    x*: gint
-    y*: gint
-
-  PPoint* = ptr TPoint
-  PPPoint* = ptr PPoint
-  PSpan* = ptr TSpan
-  PWChar* = ptr TWChar
-  TWChar* = guint32
-  PSegment* = ptr TSegment
-  TSegment*{.final, pure.} = object 
-    x1*: gint
-    y1*: gint
-    x2*: gint
-    y2*: gint
-
-  PRectangle* = ptr TRectangle
-  TRectangle*{.final, pure.} = object 
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-
-  PAtom* = ptr TAtom
-  TAtom* = gulong
-  PByteOrder* = ptr TByteOrder
-  TByteOrder* = enum 
-    LSB_FIRST, MSB_FIRST
-  PModifierType* = ptr TModifierType
-  TModifierType* = gint
-  PVisualType* = ptr TVisualType
-  TVisualType* = enum 
-    VISUAL_STATIC_GRAY, VISUAL_GRAYSCALE, VISUAL_STATIC_COLOR, 
-    VISUAL_PSEUDO_COLOR, VISUAL_TRUE_COLOR, VISUAL_DIRECT_COLOR
-  PVisual* = ptr TVisual
-  TVisual* = object of TGObject
-    TheType*: TVisualType
-    depth*: gint
-    byte_order*: TByteOrder
-    colormap_size*: gint
-    bits_per_rgb*: gint
-    red_mask*: guint32
-    red_shift*: gint
-    red_prec*: gint
-    green_mask*: guint32
-    green_shift*: gint
-    green_prec*: gint
-    blue_mask*: guint32
-    blue_shift*: gint
-    blue_prec*: gint
-    screen*: PScreen
-
-  PColormapClass* = ptr TColormapClass
-  TColormapClass* = object of TGObjectClass
-  TColormap* = object of TGObject
-    size*: gint
-    colors*: PColor
-    visual*: PVisual
-    windowing_data*: gpointer
-    screen*: PScreen
-
-  PCursorType* = ptr TCursorType
-  TCursorType* = gint
-  PCursor* = ptr TCursor
-  TCursor*{.final, pure.} = object 
-    `type`*: TCursorType
-    ref_count*: guint
-
-  PDragAction* = ptr TDragAction
-  TDragAction* = int32
-  PDragProtocol* = ptr TDragProtocol
-  TDragProtocol* = enum 
-    DRAG_PROTO_MOTIF, DRAG_PROTO_XDND, DRAG_PROTO_ROOTWIN, DRAG_PROTO_NONE, 
-    DRAG_PROTO_WIN32_DROPFILES, DRAG_PROTO_OLE2, DRAG_PROTO_LOCAL
-  PDragContext* = ptr TDragContext
-  TDragContext* = object of TGObject
-    protocol*: TDragProtocol
-    is_source*: gboolean
-    source_window*: PWindow
-    dest_window*: PWindow
-    targets*: PGList
-    actions*: TDragAction
-    suggested_action*: TDragAction
-    action*: TDragAction
-    start_time*: guint32
-    windowing_data*: gpointer
-
-  PDragContextClass* = ptr TDragContextClass
-  TDragContextClass* = object of TGObjectClass
-  PRegionBox* = ptr TRegionBox
-  TRegionBox* = TSegment
-  PRegion* = ptr TRegion
-  TRegion*{.final, pure.} = object 
-    size*: int32
-    numRects*: int32
-    rects*: PRegionBox
-    extents*: TRegionBox
-
-  PPOINTBLOCK* = ptr TPOINTBLOCK
-  TPOINTBLOCK*{.final, pure.} = object 
-    pts*: array[0..(NUMPTSTOBUFFER) - 1, TPoint]
-    next*: PPOINTBLOCK
-
-  PDrawableClass* = ptr TDrawableClass
-  TDrawableClass* = object of TGObjectClass
-    create_gc*: proc (drawable: PDrawable, values: PGCValues, 
-                      mask: TGCValuesMask): PGC{.cdecl.}
-    draw_rectangle*: proc (drawable: PDrawable, gc: PGC, filled: gint, x: gint, 
-                           y: gint, width: gint, height: gint){.cdecl.}
-    draw_arc*: proc (drawable: PDrawable, gc: PGC, filled: gint, x: gint, 
-                     y: gint, width: gint, height: gint, angle1: gint, 
-                     angle2: gint){.cdecl.}
-    draw_polygon*: proc (drawable: PDrawable, gc: PGC, filled: gint, 
-                         points: PPoint, npoints: gint){.cdecl.}
-    draw_text*: proc (drawable: PDrawable, font: PFont, gc: PGC, x: gint, 
-                      y: gint, text: cstring, text_length: gint){.cdecl.}
-    draw_text_wc*: proc (drawable: PDrawable, font: PFont, gc: PGC, x: gint, 
-                         y: gint, text: PWChar, text_length: gint){.cdecl.}
-    draw_drawable*: proc (drawable: PDrawable, gc: PGC, src: PDrawable, 
-                          xsrc: gint, ysrc: gint, xdest: gint, ydest: gint, 
-                          width: gint, height: gint){.cdecl.}
-    draw_points*: proc (drawable: PDrawable, gc: PGC, points: PPoint, 
-                        npoints: gint){.cdecl.}
-    draw_segments*: proc (drawable: PDrawable, gc: PGC, segs: PSegment, 
-                          nsegs: gint){.cdecl.}
-    draw_lines*: proc (drawable: PDrawable, gc: PGC, points: PPoint, 
-                       npoints: gint){.cdecl.}
-    draw_glyphs*: proc (drawable: PDrawable, gc: PGC, font: PFont, x: gint, 
-                        y: gint, glyphs: PGlyphString){.cdecl.}
-    draw_image*: proc (drawable: PDrawable, gc: PGC, image: PImage, xsrc: gint, 
-                       ysrc: gint, xdest: gint, ydest: gint, width: gint, 
-                       height: gint){.cdecl.}
-    get_depth*: proc (drawable: PDrawable): gint{.cdecl.}
-    get_size*: proc (drawable: PDrawable, width: Pgint, height: Pgint){.cdecl.}
-    set_colormap*: proc (drawable: PDrawable, cmap: PColormap){.cdecl.}
-    get_colormap*: proc (drawable: PDrawable): PColormap{.cdecl.}
-    get_visual*: proc (drawable: PDrawable): PVisual{.cdecl.}
-    get_screen*: proc (drawable: PDrawable): PScreen{.cdecl.}
-    get_image*: proc (drawable: PDrawable, x: gint, y: gint, width: gint, 
-                      height: gint): PImage{.cdecl.}
-    get_clip_region*: proc (drawable: PDrawable): PRegion{.cdecl.}
-    get_visible_region*: proc (drawable: PDrawable): PRegion{.cdecl.}
-    get_composite_drawable*: proc (drawable: PDrawable, x: gint, y: gint, 
-                                   width: gint, height: gint, 
-                                   composite_x_offset: Pgint, 
-                                   composite_y_offset: Pgint): PDrawable{.cdecl.}
-    `draw_pixbuf`*: proc (drawable: PDrawable, gc: PGC, pixbuf: PPixbuf, 
-                          src_x: gint, src_y: gint, dest_x: gint, dest_y: gint, 
-                          width: gint, height: gint, dither: TRgbDither, 
-                          x_dither: gint, y_dither: gint){.cdecl.}
-    `copy_to_image`*: proc (drawable: PDrawable, image: PImage, src_x: gint, 
-                            src_y: gint, dest_x: gint, dest_y: gint, 
-                            width: gint, height: gint): PImage{.cdecl.}
-    `reserved1`: proc (){.cdecl.}
-    `reserved2`: proc (){.cdecl.}
-    `reserved3`: proc (){.cdecl.}
-    `reserved4`: proc (){.cdecl.}
-    `reserved5`: proc (){.cdecl.}
-    `reserved6`: proc (){.cdecl.}
-    `reserved7`: proc (){.cdecl.}
-    `reserved9`: proc (){.cdecl.}
-    `reserved10`: proc (){.cdecl.}
-    `reserved11`: proc (){.cdecl.}
-    `reserved12`: proc (){.cdecl.}
-    `reserved13`: proc (){.cdecl.}
-    `reserved14`: proc (){.cdecl.}
-    `reserved15`: proc (){.cdecl.}
-    `reserved16`: proc (){.cdecl.}
-
-  PEvent* = ptr TEvent
-  TEventFunc* = proc (event: PEvent, data: gpointer){.cdecl.}
-  PXEvent* = ptr TXEvent
-  TXEvent* = proc ()
-  PFilterReturn* = ptr TFilterReturn
-  TFilterReturn* = enum 
-    FILTER_CONTINUE, FILTER_TRANSLATE, FILTER_REMOVE
-  TFilterFunc* = proc (xevent: PXEvent, event: PEvent, data: gpointer): TFilterReturn{.
-      cdecl.}
-  PEventType* = ptr TEventType
-  TEventType* = gint
-  PEventMask* = ptr TEventMask
-  TEventMask* = gint32
-  PVisibilityState* = ptr TVisibilityState
-  TVisibilityState* = enum 
-    VISIBILITY_UNOBSCURED, VISIBILITY_PARTIAL, VISIBILITY_FULLY_OBSCURED
-  PScrollDirection* = ptr TScrollDirection
-  TScrollDirection* = enum 
-    SCROLL_UP, SCROLL_DOWN, SCROLL_LEFT, SCROLL_RIGHT
-  PNotifyType* = ptr TNotifyType
-  TNotifyType* = int
-  PCrossingMode* = ptr TCrossingMode
-  TCrossingMode* = enum 
-    CROSSING_NORMAL, CROSSING_GRAB, CROSSING_UNGRAB
-  PPropertyState* = ptr TPropertyState
-  TPropertyState* = enum 
-    PROPERTY_NEW_VALUE, PROPERTY_STATE_DELETE
-  PWindowState* = ptr TWindowState
-  TWindowState* = gint
-  PSettingAction* = ptr TSettingAction
-  TSettingAction* = enum 
-    SETTING_ACTION_NEW, SETTING_ACTION_CHANGED, SETTING_ACTION_DELETED
-  PEventAny* = ptr TEventAny
-  TEventAny*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-
-  PEventExpose* = ptr TEventExpose
-  TEventExpose*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    area*: TRectangle
-    region*: PRegion
-    count*: gint
-
-  PEventNoExpose* = ptr TEventNoExpose
-  TEventNoExpose*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-
-  PEventVisibility* = ptr TEventVisibility
-  TEventVisibility*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    state*: TVisibilityState
-
-  PEventMotion* = ptr TEventMotion
-  TEventMotion*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    axes*: Pgdouble
-    state*: guint
-    is_hint*: gint16
-    device*: PDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PEventButton* = ptr TEventButton
-  TEventButton*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    axes*: Pgdouble
-    state*: guint
-    button*: guint
-    device*: PDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PEventScroll* = ptr TEventScroll
-  TEventScroll*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    state*: guint
-    direction*: TScrollDirection
-    device*: PDevice
-    x_root*: gdouble
-    y_root*: gdouble
-
-  PEventKey* = ptr TEventKey
-  TEventKey*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    time*: guint32
-    state*: guint
-    keyval*: guint
-    length*: gint
-    `string`*: cstring
-    hardware_keycode*: guint16
-    group*: guint8
-
-  PEventCrossing* = ptr TEventCrossing
-  TEventCrossing*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    subwindow*: PWindow
-    time*: guint32
-    x*: gdouble
-    y*: gdouble
-    x_root*: gdouble
-    y_root*: gdouble
-    mode*: TCrossingMode
-    detail*: TNotifyType
-    focus*: gboolean
-    state*: guint
-
-  PEventFocus* = ptr TEventFocus
-  TEventFocus*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    `in`*: gint16
-
-  PEventConfigure* = ptr TEventConfigure
-  TEventConfigure*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-
-  PEventProperty* = ptr TEventProperty
-  TEventProperty*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    atom*: TAtom
-    time*: guint32
-    state*: guint
-
-  TNativeWindow* = pointer
-  PEventSelection* = ptr TEventSelection
-  TEventSelection*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    selection*: TAtom
-    target*: TAtom
-    `property`*: TAtom
-    time*: guint32
-    requestor*: TNativeWindow
-
-  PEventProximity* = ptr TEventProximity
-  TEventProximity*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    time*: guint32
-    device*: PDevice
-
-  PmatDUMMY* = ptr TmatDUMMY
-  TmatDUMMY*{.final, pure.} = object 
-    b*: array[0..19, char]
-
-  PEventClient* = ptr TEventClient
-  TEventClient*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    message_type*: TAtom
-    data_format*: gushort
-    b*: array[0..19, char]
-
-  PEventSetting* = ptr TEventSetting
-  TEventSetting*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    action*: TSettingAction
-    name*: cstring
-
-  PEventWindowState* = ptr TEventWindowState
-  TEventWindowState*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    changed_mask*: TWindowState
-    new_window_state*: TWindowState
-
-  PEventDND* = ptr TEventDND
-  TEventDND*{.final, pure.} = object 
-    `type`*: TEventType
-    window*: PWindow
-    send_event*: gint8
-    context*: PDragContext
-    time*: guint32
-    x_root*: gshort
-    y_root*: gshort
-
-  TEvent*{.final, pure.} = object 
-    data*: array[0..255, char] # union of
-                               # `type`: TEventType
-                               #  any: TEventAny
-                               #  expose: TEventExpose
-                               #  no_expose: TEventNoExpose
-                               #  visibility: TEventVisibility
-                               #  motion: TEventMotion
-                               #  button: TEventButton
-                               #  scroll: TEventScroll
-                               #  key: TEventKey
-                               #  crossing: TEventCrossing
-                               #  focus_change: TEventFocus
-                               #  configure: TEventConfigure
-                               #  `property`: TEventProperty
-                               #  selection: TEventSelection
-                               #  proximity: TEventProximity
-                               #  client: TEventClient
-                               #  dnd: TEventDND
-                               #  window_state: TEventWindowState
-                               #  setting: TEventSetting
-  
-  PGCClass* = ptr TGCClass
-  TGCClass* = object of TGObjectClass
-    get_values*: proc (gc: PGC, values: PGCValues){.cdecl.}
-    set_values*: proc (gc: PGC, values: PGCValues, mask: TGCValuesMask){.cdecl.}
-    set_dashes*: proc (gc: PGC, dash_offset: gint, dash_list: openarray[gint8]){.
-        cdecl.}
-    `reserved1`*: proc (){.cdecl.}
-    `reserved2`*: proc (){.cdecl.}
-    `reserved3`*: proc (){.cdecl.}
-    `reserved4`*: proc (){.cdecl.}
-
-  PImageClass* = ptr TImageClass
-  TImageClass* = object of TGObjectClass
-  TImage* = object of TGObject
-    `type`*: TImageType
-    visual*: PVisual
-    byte_order*: TByteOrder
-    width*: gint
-    height*: gint
-    depth*: guint16
-    bpp*: guint16
-    bpl*: guint16
-    bits_per_pixel*: guint16
-    mem*: gpointer
-    colormap*: PColormap
-    windowing_data*: gpointer
-
-  PExtensionMode* = ptr TExtensionMode
-  TExtensionMode* = enum 
-    EXTENSION_EVENTS_NONE, EXTENSION_EVENTS_ALL, EXTENSION_EVENTS_CURSOR
-  PInputSource* = ptr TInputSource
-  TInputSource* = enum 
-    SOURCE_MOUSE, SOURCE_PEN, SOURCE_ERASER, SOURCE_CURSOR
-  PInputMode* = ptr TInputMode
-  TInputMode* = enum 
-    MODE_DISABLED, MODE_SCREEN, MODE_WINDOW
-  PAxisUse* = ptr TAxisUse
-  TAxisUse* = int32
-  PDeviceKey* = ptr TDeviceKey
-  TDeviceKey*{.final, pure.} = object 
-    keyval*: guint
-    modifiers*: TModifierType
-
-  PDeviceAxis* = ptr TDeviceAxis
-  TDeviceAxis*{.final, pure.} = object 
-    use*: TAxisUse
-    min*: gdouble
-    max*: gdouble
-
-  TDevice* = object of TGObject
-    name*: cstring
-    source*: TInputSource
-    mode*: TInputMode
-    has_cursor*: gboolean
-    num_axes*: gint
-    axes*: PDeviceAxis
-    num_keys*: gint
-    keys*: PDeviceKey
-
-  TTimeCoord*{.final, pure.} = object 
-    time*: guint32
-    axes*: array[0..(MAX_TIMECOORD_AXES) - 1, gdouble]
-
-  PKeymapKey* = ptr TKeymapKey
-  TKeymapKey*{.final, pure.} = object 
-    keycode*: guint
-    group*: gint
-    level*: gint
-
-  PKeymap* = ptr TKeymap
-  TKeymap* = object of TGObject
-    display*: PDisplay
-
-  PKeymapClass* = ptr TKeymapClass
-  TKeymapClass* = object of TGObjectClass
-    direction_changed*: proc (keymap: PKeymap){.cdecl.}
-
-  PAttrStipple* = ptr TAttrStipple
-  TAttrStipple*{.final, pure.} = object 
-    attr*: TAttribute
-    stipple*: PBitmap
-
-  PAttrEmbossed* = ptr TAttrEmbossed
-  TAttrEmbossed*{.final, pure.} = object 
-    attr*: TAttribute
-    embossed*: gboolean
-
-  PPixmapObject* = ptr TPixmapObject
-  TPixmapObject* = object of TDrawable
-    impl*: PDrawable
-    depth*: gint
-
-  PPixmapObjectClass* = ptr TPixmapObjectClass
-  TPixmapObjectClass* = object of TDrawableClass
-  PPropMode* = ptr TPropMode
-  TPropMode* = enum 
-    PROP_MODE_REPLACE, PROP_MODE_PREPEND, PROP_MODE_APPEND
-  PFillRule* = ptr TFillRule
-  TFillRule* = enum 
-    EVEN_ODD_RULE, WINDING_RULE
-  POverlapType* = ptr TOverlapType
-  TOverlapType* = enum 
-    OVERLAP_RECTANGLE_IN, OVERLAP_RECTANGLE_OUT, OVERLAP_RECTANGLE_PART
-  TSpanFunc* = proc (span: PSpan, data: gpointer){.cdecl.}
-  PRgbCmap* = ptr TRgbCmap
-  TRgbCmap*{.final, pure.} = object 
-    colors*: array[0..255, guint32]
-    n_colors*: gint
-    info_list*: PGSList
-
-  TDisplay* = object of TGObject
-    queued_events*: PGList
-    queued_tail*: PGList
-    button_click_time*: array[0..1, guint32]
-    button_window*: array[0..1, PWindow]
-    button_number*: array[0..1, guint]
-    double_click_time*: guint
-
-  PDisplayClass* = ptr TDisplayClass
-  TDisplayClass* = object of TGObjectClass
-    get_display_name*: proc (display: PDisplay): cstring{.cdecl.}
-    get_n_screens*: proc (display: PDisplay): gint{.cdecl.}
-    get_screen*: proc (display: PDisplay, screen_num: gint): PScreen{.cdecl.}
-    get_default_screen*: proc (display: PDisplay): PScreen{.cdecl.}
-
-  PScreenClass* = ptr TScreenClass
-  TScreenClass* = object of TGObjectClass
-    get_display*: proc (screen: PScreen): PDisplay{.cdecl.}
-    get_width*: proc (screen: PScreen): gint{.cdecl.}
-    get_height*: proc (screen: PScreen): gint{.cdecl.}
-    get_width_mm*: proc (screen: PScreen): gint{.cdecl.}
-    get_height_mm*: proc (screen: PScreen): gint{.cdecl.}
-    get_root_depth*: proc (screen: PScreen): gint{.cdecl.}
-    get_screen_num*: proc (screen: PScreen): gint{.cdecl.}
-    get_root_window*: proc (screen: PScreen): PWindow{.cdecl.}
-    get_default_colormap*: proc (screen: PScreen): PColormap{.cdecl.}
-    set_default_colormap*: proc (screen: PScreen, colormap: PColormap){.cdecl.}
-    get_window_at_pointer*: proc (screen: PScreen, win_x: Pgint, win_y: Pgint): PWindow{.
-        cdecl.}
-    get_n_monitors*: proc (screen: PScreen): gint{.cdecl.}
-    get_monitor_geometry*: proc (screen: PScreen, monitor_num: gint, 
-                                 dest: PRectangle){.cdecl.}
-
-  PGrabStatus* = ptr TGrabStatus
-  TGrabStatus* = int
-  TInputFunction* = proc (data: gpointer, source: gint, 
-                          condition: TInputCondition){.cdecl.}
-  TDestroyNotify* = proc (data: gpointer){.cdecl.}
-  TSpan*{.final, pure.} = object 
-    x*: gint
-    y*: gint
-    width*: gint
-
-  PWindowClass* = ptr TWindowClass
-  TWindowClass* = enum 
-    INPUT_OUTPUT, INPUT_ONLY
-  PWindowType* = ptr TWindowType
-  TWindowType* = enum 
-    WINDOW_ROOT, WINDOW_TOPLEVEL, WINDOW_CHILD, WINDOW_DIALOG, WINDOW_TEMP, 
-    WINDOW_FOREIGN
-  PWindowAttributesType* = ptr TWindowAttributesType
-  TWindowAttributesType* = int32
-  PWindowHints* = ptr TWindowHints
-  TWindowHints* = int32
-  PWindowTypeHint* = ptr TWindowTypeHint
-  TWindowTypeHint* = enum 
-    WINDOW_TYPE_HINT_NORMAL, WINDOW_TYPE_HINT_DIALOG, WINDOW_TYPE_HINT_MENU, 
-    WINDOW_TYPE_HINT_TOOLBAR
-  PWMDecoration* = ptr TWMDecoration
-  TWMDecoration* = int32
-  PWMFunction* = ptr TWMFunction
-  TWMFunction* = int32
-  PGravity* = ptr TGravity
-  TGravity* = int
-  PWindowEdge* = ptr TWindowEdge
-  TWindowEdge* = enum 
-    WINDOW_EDGE_NORTH_WEST, WINDOW_EDGE_NORTH, WINDOW_EDGE_NORTH_EAST, 
-    WINDOW_EDGE_WEST, WINDOW_EDGE_EAST, WINDOW_EDGE_SOUTH_WEST, 
-    WINDOW_EDGE_SOUTH, WINDOW_EDGE_SOUTH_EAST
-  PWindowAttr* = ptr TWindowAttr
-  TWindowAttr*{.final, pure.} = object 
-    title*: cstring
-    event_mask*: gint
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-    wclass*: TWindowClass
-    visual*: PVisual
-    colormap*: PColormap
-    window_type*: TWindowType
-    cursor*: PCursor
-    wmclass_name*: cstring
-    wmclass_class*: cstring
-    override_redirect*: gboolean
-
-  PGeometry* = ptr TGeometry
-  TGeometry*{.final, pure.} = object 
-    min_width*: gint
-    min_height*: gint
-    max_width*: gint
-    max_height*: gint
-    base_width*: gint
-    base_height*: gint
-    width_inc*: gint
-    height_inc*: gint
-    min_aspect*: gdouble
-    max_aspect*: gdouble
-    win_gravity*: TGravity
-
-  PPointerHooks* = ptr TPointerHooks
-  TPointerHooks*{.final, pure.} = object 
-    get_pointer*: proc (window: PWindow, x: Pgint, y: Pgint, mask: PModifierType): PWindow{.
-        cdecl.}
-    window_at_pointer*: proc (screen: PScreen, win_x: Pgint, win_y: Pgint): PWindow{.
-        cdecl.}
-
-  PWindowObject* = ptr TWindowObject
-  TWindowObject* = object of TDrawable
-    impl*: PDrawable
-    parent*: PWindowObject
-    user_data*: gpointer
-    x*: gint
-    y*: gint
-    extension_events*: gint
-    filters*: PGList
-    children*: PGList
-    bg_color*: TColor
-    bg_pixmap*: PPixmap
-    paint_stack*: PGSList
-    update_area*: PRegion
-    update_freeze_count*: guint
-    window_type*: guint8
-    depth*: guint8
-    resize_count*: guint8
-    state*: TWindowState
-    flag0*: guint16
-    event_mask*: TEventMask
-
-  PWindowObjectClass* = ptr TWindowObjectClass
-  TWindowObjectClass* = object of TDrawableClass
-  window_invalidate_maybe_recurse_child_func* = proc (para1: PWindow, 
-      para2: gpointer): gboolean
-
-proc TYPE_COLORMAP*(): GType
-proc COLORMAP*(anObject: pointer): PColormap
-proc COLORMAP_CLASS*(klass: pointer): PColormapClass
-proc IS_COLORMAP*(anObject: pointer): bool
-proc IS_COLORMAP_CLASS*(klass: pointer): bool
-proc COLORMAP_GET_CLASS*(obj: pointer): PColormapClass
-proc TYPE_COLOR*(): GType
-proc colormap_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gdk_colormap_get_type".}
-proc colormap_new*(visual: PVisual, allocate: gboolean): PColormap{.cdecl, 
-    dynlib: lib, importc: "gdk_colormap_new".}
-proc alloc_colors*(colormap: PColormap, colors: PColor, ncolors: gint, 
-                            writeable: gboolean, best_match: gboolean, 
-                            success: Pgboolean): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_colormap_alloc_colors".}
-proc alloc_color*(colormap: PColormap, color: PColor, 
-                           writeable: gboolean, best_match: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_colormap_alloc_color".}
-proc free_colors*(colormap: PColormap, colors: PColor, ncolors: gint){.
-    cdecl, dynlib: lib, importc: "gdk_colormap_free_colors".}
-proc query_color*(colormap: PColormap, pixel: gulong, result: PColor){.
-    cdecl, dynlib: lib, importc: "gdk_colormap_query_color".}
-proc get_visual*(colormap: PColormap): PVisual{.cdecl, dynlib: lib, 
-    importc: "gdk_colormap_get_visual".}
-proc copy*(color: PColor): PColor{.cdecl, dynlib: lib, 
-    importc: "gdk_color_copy".}
-proc free*(color: PColor){.cdecl, dynlib: lib, importc: "gdk_color_free".}
-proc color_parse*(spec: cstring, color: PColor): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_color_parse".}
-proc hash*(colora: PColor): guint{.cdecl, dynlib: lib, 
-    importc: "gdk_color_hash".}
-proc equal*(colora: PColor, colorb: PColor): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_color_equal".}
-proc color_get_type*(): GType{.cdecl, dynlib: lib, importc: "gdk_color_get_type".}
-const 
-  CURSOR_IS_PIXMAP* = - (1)
-  X_CURSOR* = 0
-  ARROW* = 2
-  BASED_ARROW_DOWN* = 4
-  BASED_ARROW_UP* = 6
-  BOAT* = 8
-  BOGOSITY* = 10
-  BOTTOM_LEFT_CORNER* = 12
-  BOTTOM_RIGHT_CORNER* = 14
-  BOTTOM_SIDE* = 16
-  BOTTOM_TEE* = 18
-  BOX_SPIRAL* = 20
-  CENTER_PTR* = 22
-  CIRCLE* = 24
-  CLOCK* = 26
-  COFFEE_MUG* = 28
-  CROSS* = 30
-  CROSS_REVERSE* = 32
-  CROSSHAIR* = 34
-  DIAMOND_CROSS* = 36
-  DOT* = 38
-  DOTBOX* = 40
-  DOUBLE_ARROW* = 42
-  DRAFT_LARGE* = 44
-  DRAFT_SMALL* = 46
-  DRAPED_BOX* = 48
-  EXCHANGE* = 50
-  FLEUR* = 52
-  GOBBLER* = 54
-  GUMBY* = 56
-  HAND1* = 58
-  HAND2* = 60
-  HEART* = 62
-  ICON* = 64
-  IRON_CROSS* = 66
-  LEFT_PTR* = 68
-  LEFT_SIDE* = 70
-  LEFT_TEE* = 72
-  LEFTBUTTON* = 74
-  LL_ANGLE* = 76
-  LR_ANGLE* = 78
-  MAN* = 80
-  MIDDLEBUTTON* = 82
-  MOUSE* = 84
-  PENCIL* = 86
-  PIRATE* = 88
-  PLUS* = 90
-  QUESTION_ARROW* = 92
-  RIGHT_PTR* = 94
-  RIGHT_SIDE* = 96
-  RIGHT_TEE* = 98
-  RIGHTBUTTON* = 100
-  RTL_LOGO* = 102
-  SAILBOAT* = 104
-  SB_DOWN_ARROW* = 106
-  SB_H_DOUBLE_ARROW* = 108
-  SB_LEFT_ARROW* = 110
-  SB_RIGHT_ARROW* = 112
-  SB_UP_ARROW* = 114
-  SB_V_DOUBLE_ARROW* = 116
-  SHUTTLE* = 118
-  SIZING* = 120
-  SPIDER* = 122
-  SPRAYCAN* = 124
-  STAR* = 126
-  TARGET* = 128
-  TCROSS* = 130
-  TOP_LEFT_ARROW* = 132
-  TOP_LEFT_CORNER* = 134
-  TOP_RIGHT_CORNER* = 136
-  TOP_SIDE* = 138
-  TOP_TEE* = 140
-  TREK* = 142
-  UL_ANGLE* = 144
-  UMBRELLA* = 146
-  UR_ANGLE* = 148
-  WATCH* = 150
-  XTERM* = 152
-  LAST_CURSOR* = XTERM + 1
-
-proc TYPE_CURSOR*(): GType
-proc cursor_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gdk_cursor_get_type".}
-proc cursor_new_for_screen*(screen: PScreen, cursor_type: TCursorType): PCursor{.
-    cdecl, dynlib: lib, importc: "gdk_cursor_new_for_screen".}
-proc cursor_new_from_pixmap*(source: PPixmap, mask: PPixmap, fg: PColor, 
-                             bg: PColor, x: gint, y: gint): PCursor{.cdecl, 
-    dynlib: lib, importc: "gdk_cursor_new_from_pixmap".}
-proc get_screen*(cursor: PCursor): PScreen{.cdecl, dynlib: lib, 
-    importc: "gdk_cursor_get_screen".}
-proc reference*(cursor: PCursor): PCursor{.cdecl, dynlib: lib, 
-    importc: "gdk_cursor_ref".}
-proc unref*(cursor: PCursor){.cdecl, dynlib: lib, 
-                                     importc: "gdk_cursor_unref".}
-const 
-  ACTION_DEFAULT* = 1 shl 0
-  ACTION_COPY* = 1 shl 1
-  ACTION_MOVE* = 1 shl 2
-  ACTION_LINK* = 1 shl 3
-  ACTION_PRIVATE* = 1 shl 4
-  ACTION_ASK* = 1 shl 5
-
-proc TYPE_DRAG_CONTEXT*(): GType
-proc DRAG_CONTEXT*(anObject: Pointer): PDragContext
-proc DRAG_CONTEXT_CLASS*(klass: Pointer): PDragContextClass
-proc IS_DRAG_CONTEXT*(anObject: Pointer): bool
-proc IS_DRAG_CONTEXT_CLASS*(klass: Pointer): bool
-proc DRAG_CONTEXT_GET_CLASS*(obj: Pointer): PDragContextClass
-proc drag_context_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "gdk_drag_context_get_type".}
-proc drag_context_new*(): PDragContext{.cdecl, dynlib: lib, 
-                                        importc: "gdk_drag_context_new".}
-proc status*(context: PDragContext, action: TDragAction, time: guint32){.
-    cdecl, dynlib: lib, importc: "gdk_drag_status".}
-proc drop_reply*(context: PDragContext, ok: gboolean, time: guint32){.cdecl, 
-    dynlib: lib, importc: "gdk_drop_reply".}
-proc drop_finish*(context: PDragContext, success: gboolean, time: guint32){.
-    cdecl, dynlib: lib, importc: "gdk_drop_finish".}
-proc get_selection*(context: PDragContext): TAtom{.cdecl, dynlib: lib, 
-    importc: "gdk_drag_get_selection".}
-proc drag_begin*(window: PWindow, targets: PGList): PDragContext{.cdecl, 
-    dynlib: lib, importc: "gdk_drag_begin".}
-proc drag_get_protocol_for_display*(display: PDisplay, xid: guint32, 
-                                    protocol: PDragProtocol): guint32{.cdecl, 
-    dynlib: lib, importc: "gdk_drag_get_protocol_for_display".}
-proc find_window*(context: PDragContext, drag_window: PWindow, 
-                       x_root: gint, y_root: gint, w: var PWindow, 
-                       protocol: PDragProtocol){.cdecl, dynlib: lib, 
-    importc: "gdk_drag_find_window".}
-proc motion*(context: PDragContext, dest_window: PWindow, 
-                  protocol: TDragProtocol, x_root: gint, y_root: gint, 
-                  suggested_action: TDragAction, possible_actions: TDragAction, 
-                  time: guint32): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_drag_motion".}
-proc drop*(context: PDragContext, time: guint32){.cdecl, dynlib: lib, 
-    importc: "gdk_drag_drop".}
-proc abort*(context: PDragContext, time: guint32){.cdecl, dynlib: lib, 
-    importc: "gdk_drag_abort".}
-proc region_EXTENTCHECK*(r1, r2: PRegionBox): bool
-proc EXTENTS*(r: PRegionBox, idRect: PRegion)
-proc MEMCHECK*(reg: PRegion, ARect, firstrect: var PRegionBox): bool
-proc CHECK_PREVIOUS*(Reg: PRegion, R: PRegionBox, 
-                            Rx1, Ry1, Rx2, Ry2: gint): bool
-proc ADDRECT*(reg: PRegion, r: PRegionBox, rx1, ry1, rx2, ry2: gint)
-proc ADDRECTNOX*(reg: PRegion, r: PRegionBox, rx1, ry1, rx2, ry2: gint)
-proc EMPTY_REGION*(pReg: PRegion): bool
-proc REGION_NOT_EMPTY*(pReg: PRegion): bool
-proc region_INBOX*(r: TRegionBox, x, y: gint): bool
-proc TYPE_DRAWABLE*(): GType
-proc DRAWABLE*(anObject: Pointer): PDrawable
-proc DRAWABLE_CLASS*(klass: Pointer): PDrawableClass
-proc IS_DRAWABLE*(anObject: Pointer): bool
-proc IS_DRAWABLE_CLASS*(klass: Pointer): bool
-proc DRAWABLE_GET_CLASS*(obj: Pointer): PDrawableClass
-proc drawable_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gdk_drawable_get_type".}
-proc get_size*(drawable: PDrawable, width: Pgint, height: Pgint){.
-    cdecl, dynlib: lib, importc: "gdk_drawable_get_size".}
-proc set_colormap*(drawable: PDrawable, colormap: PColormap){.cdecl, 
-    dynlib: lib, importc: "gdk_drawable_set_colormap".}
-proc get_colormap*(drawable: PDrawable): PColormap{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_colormap".}
-proc get_visual*(drawable: PDrawable): PVisual{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_visual".}
-proc get_depth*(drawable: PDrawable): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_depth".}
-proc get_screen*(drawable: PDrawable): PScreen{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_screen".}
-proc get_display*(drawable: PDrawable): PDisplay{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_display".}
-proc point*(drawable: PDrawable, gc: PGC, x: gint, y: gint){.cdecl, 
-    dynlib: lib, importc: "gdk_draw_point".}
-proc line*(drawable: PDrawable, gc: PGC, x1: gint, y1: gint, x2: gint, 
-                y2: gint){.cdecl, dynlib: lib, importc: "gdk_draw_line".}
-proc rectangle*(drawable: PDrawable, gc: PGC, filled: gint, x: gint, 
-                     y: gint, width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_rectangle".}
-proc arc*(drawable: PDrawable, gc: PGC, filled: gint, x: gint, y: gint, 
-               width: gint, height: gint, angle1: gint, angle2: gint){.cdecl, 
-    dynlib: lib, importc: "gdk_draw_arc".}
-proc polygon*(drawable: PDrawable, gc: PGC, filled: gint, points: PPoint, 
-                   npoints: gint){.cdecl, dynlib: lib, 
-                                   importc: "gdk_draw_polygon".}
-proc drawable*(drawable: PDrawable, gc: PGC, src: PDrawable, xsrc: gint, 
-                    ysrc: gint, xdest: gint, ydest: gint, width: gint, 
-                    height: gint){.cdecl, dynlib: lib, 
-                                   importc: "gdk_draw_drawable".}
-proc image*(drawable: PDrawable, gc: PGC, image: PImage, xsrc: gint, 
-                 ysrc: gint, xdest: gint, ydest: gint, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gdk_draw_image".}
-proc points*(drawable: PDrawable, gc: PGC, points: PPoint, npoints: gint){.
-    cdecl, dynlib: lib, importc: "gdk_draw_points".}
-proc segments*(drawable: PDrawable, gc: PGC, segs: PSegment, nsegs: gint){.
-    cdecl, dynlib: lib, importc: "gdk_draw_segments".}
-proc lines*(drawable: PDrawable, gc: PGC, points: PPoint, npoints: gint){.
-    cdecl, dynlib: lib, importc: "gdk_draw_lines".}
-proc glyphs*(drawable: PDrawable, gc: PGC, font: PFont, x: gint, 
-                  y: gint, glyphs: PGlyphString){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_glyphs".}
-proc layout_line*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                       line: PLayoutLine){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_layout_line".}
-proc layout*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                  layout: PLayout){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_layout".}
-proc layout_line*(drawable: PDrawable, gc: PGC, x: gint, 
-                                   y: gint, line: PLayoutLine, 
-                                   foreground: PColor, background: PColor){.
-    cdecl, dynlib: lib, importc: "gdk_draw_layout_line_with_colors".}
-proc layout*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                              layout: PLayout, foreground: PColor, 
-                              background: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_layout_with_colors".}
-proc get_image*(drawable: PDrawable, x: gint, y: gint, width: gint, 
-                         height: gint): PImage{.cdecl, dynlib: lib, 
-    importc: "gdk_drawable_get_image".}
-proc get_clip_region*(drawable: PDrawable): PRegion{.cdecl, 
-    dynlib: lib, importc: "gdk_drawable_get_clip_region".}
-proc get_visible_region*(drawable: PDrawable): PRegion{.cdecl, 
-    dynlib: lib, importc: "gdk_drawable_get_visible_region".}
-const 
-  NOTHING* = - (1)
-  DELETE* = 0
-  constDESTROY* = 1
-  EXPOSE* = 2
-  MOTION_NOTIFY* = 3
-  BUTTON_PRESS* = 4
-  BUTTON2_PRESS* = 5
-  BUTTON3_PRESS* = 6
-  BUTTON_RELEASE* = 7
-  KEY_PRESS* = 8
-  KEY_RELEASE* = 9
-  ENTER_NOTIFY* = 10
-  LEAVE_NOTIFY* = 11
-  FOCUS_CHANGE* = 12
-  CONFIGURE* = 13
-  MAP* = 14
-  UNMAP* = 15
-  PROPERTY_NOTIFY* = 16
-  SELECTION_CLEAR* = 17
-  SELECTION_REQUEST* = 18
-  SELECTION_NOTIFY* = 19
-  PROXIMITY_IN* = 20
-  PROXIMITY_OUT* = 21
-  DRAG_ENTER* = 22
-  DRAG_LEAVE* = 23
-  DRAG_MOTION_EVENT* = 24
-  DRAG_STATUS_EVENT* = 25
-  DROP_START* = 26
-  DROP_FINISHED* = 27
-  CLIENT_EVENT* = 28
-  VISIBILITY_NOTIFY* = 29
-  NO_EXPOSE* = 30
-  constSCROLL* = 31
-  WINDOW_STATE* = 32
-  SETTING* = 33
-  NOTIFY_ANCESTOR* = 0
-  NOTIFY_VIRTUAL* = 1
-  NOTIFY_INFERIOR* = 2
-  NOTIFY_NONLINEAR* = 3
-  NOTIFY_NONLINEAR_VIRTUAL* = 4
-  NOTIFY_UNKNOWN* = 5
-
-proc TYPE_EVENT*(): GType
-const 
-  G_PRIORITY_DEFAULT* = 0
-  PRIORITY_EVENTS* = G_PRIORITY_DEFAULT #GDK_PRIORITY_REDRAW* = G_PRIORITY_HIGH_IDLE + 20
-  EXPOSURE_MASK* = 1 shl 1
-  POINTER_MOTION_MASK* = 1 shl 2
-  POINTER_MOTION_HINT_MASK* = 1 shl 3
-  BUTTON_MOTION_MASK* = 1 shl 4
-  BUTTON1_MOTION_MASK* = 1 shl 5
-  BUTTON2_MOTION_MASK* = 1 shl 6
-  BUTTON3_MOTION_MASK* = 1 shl 7
-  BUTTON_PRESS_MASK* = 1 shl 8
-  BUTTON_RELEASE_MASK* = 1 shl 9
-  KEY_PRESS_MASK* = 1 shl 10
-  KEY_RELEASE_MASK* = 1 shl 11
-  ENTER_NOTIFY_MASK* = 1 shl 12
-  LEAVE_NOTIFY_MASK* = 1 shl 13
-  FOCUS_CHANGE_MASK* = 1 shl 14
-  STRUCTURE_MASK* = 1 shl 15
-  PROPERTY_CHANGE_MASK* = 1 shl 16
-  VISIBILITY_NOTIFY_MASK* = 1 shl 17
-  PROXIMITY_IN_MASK* = 1 shl 18
-  PROXIMITY_OUT_MASK* = 1 shl 19
-  SUBSTRUCTURE_MASK* = 1 shl 20
-  SCROLL_MASK* = 1 shl 21
-  ALL_EVENTS_MASK* = 0x003FFFFE
-  WINDOW_STATE_WITHDRAWN* = 1 shl 0
-  WINDOW_STATE_ICONIFIED* = 1 shl 1
-  WINDOW_STATE_MAXIMIZED* = 1 shl 2
-  WINDOW_STATE_STICKY* = 1 shl 3
-
-proc event_get_type*(): GType{.cdecl, dynlib: lib, importc: "gdk_event_get_type".}
-proc events_pending*(): gboolean{.cdecl, dynlib: lib, 
-                                  importc: "gdk_events_pending".}
-proc event_get*(): PEvent{.cdecl, dynlib: lib, importc: "gdk_event_get".}
-proc event_peek*(): PEvent{.cdecl, dynlib: lib, importc: "gdk_event_peek".}
-proc event_get_graphics_expose*(window: PWindow): PEvent{.cdecl, dynlib: lib, 
-    importc: "gdk_event_get_graphics_expose".}
-proc put*(event: PEvent){.cdecl, dynlib: lib, importc: "gdk_event_put".}
-proc copy*(event: PEvent): PEvent{.cdecl, dynlib: lib, 
-    importc: "gdk_event_copy".}
-proc free*(event: PEvent){.cdecl, dynlib: lib, importc: "gdk_event_free".}
-proc get_time*(event: PEvent): guint32{.cdecl, dynlib: lib, 
-    importc: "gdk_event_get_time".}
-proc get_state*(event: PEvent, state: PModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_event_get_state".}
-proc get_coords*(event: PEvent, x_win: Pgdouble, y_win: Pgdouble): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_event_get_coords".}
-proc get_root_coords*(event: PEvent, x_root: Pgdouble, y_root: Pgdouble): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_event_get_root_coords".}
-proc get_axis*(event: PEvent, axis_use: TAxisUse, value: Pgdouble): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_event_get_axis".}
-proc event_handler_set*(func: TEventFunc, data: gpointer, 
-                        notify: TGDestroyNotify){.cdecl, dynlib: lib, 
-    importc: "gdk_event_handler_set".}
-proc set_show_events*(show_events: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_set_show_events".}
-proc get_show_events*(): gboolean{.cdecl, dynlib: lib, 
-                                   importc: "gdk_get_show_events".}
-proc TYPE_FONT*(): GType
-proc font_get_type*(): GType{.cdecl, dynlib: lib, importc: "gdk_font_get_type".}
-proc font_load_for_display*(display: PDisplay, font_name: cstring): PFont{.
-    cdecl, dynlib: lib, importc: "gdk_font_load_for_display".}
-proc fontset_load_for_display*(display: PDisplay, fontset_name: cstring): PFont{.
-    cdecl, dynlib: lib, importc: "gdk_fontset_load_for_display".}
-proc font_from_description_for_display*(display: PDisplay, 
-                                        font_desc: PFontDescription): PFont{.
-    cdecl, dynlib: lib, importc: "gdk_font_from_description_for_display".}
-proc reference*(font: PFont): PFont{.cdecl, dynlib: lib, importc: "gdk_font_ref".}
-proc unref*(font: PFont){.cdecl, dynlib: lib, importc: "gdk_font_unref".}
-proc id*(font: PFont): gint{.cdecl, dynlib: lib, importc: "gdk_font_id".}
-proc equal*(fonta: PFont, fontb: PFont): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_font_equal".}
-proc string_width*(font: PFont, `string`: cstring): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_string_width".}
-proc text_width*(font: PFont, text: cstring, text_length: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_width".}
-proc text_width_wc*(font: PFont, text: PWChar, text_length: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_width_wc".}
-proc char_width*(font: PFont, character: gchar): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_char_width".}
-proc char_width_wc*(font: PFont, character: TWChar): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_char_width_wc".}
-proc string_measure*(font: PFont, `string`: cstring): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_string_measure".}
-proc text_measure*(font: PFont, text: cstring, text_length: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_measure".}
-proc char_measure*(font: PFont, character: gchar): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_char_measure".}
-proc string_height*(font: PFont, `string`: cstring): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_string_height".}
-proc text_height*(font: PFont, text: cstring, text_length: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_height".}
-proc char_height*(font: PFont, character: gchar): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_char_height".}
-proc text_extents*(font: PFont, text: cstring, text_length: gint, 
-                   lbearing: Pgint, rbearing: Pgint, width: Pgint, 
-                   ascent: Pgint, descent: Pgint){.cdecl, dynlib: lib, 
-    importc: "gdk_text_extents".}
-proc text_extents_wc*(font: PFont, text: PWChar, text_length: gint, 
-                      lbearing: Pgint, rbearing: Pgint, width: Pgint, 
-                      ascent: Pgint, descent: Pgint){.cdecl, dynlib: lib, 
-    importc: "gdk_text_extents_wc".}
-proc string_extents*(font: PFont, `string`: cstring, lbearing: Pgint, 
-                     rbearing: Pgint, width: Pgint, ascent: Pgint, 
-                     descent: Pgint){.cdecl, dynlib: lib, 
-                                      importc: "gdk_string_extents".}
-proc get_display*(font: PFont): PDisplay{.cdecl, dynlib: lib, 
-    importc: "gdk_font_get_display".}
-const 
-  GC_FOREGROUND* = 1 shl 0
-  GC_BACKGROUND* = 1 shl 1
-  GC_FONT* = 1 shl 2
-  GC_FUNCTION* = 1 shl 3
-  GC_FILL* = 1 shl 4
-  GC_TILE* = 1 shl 5
-  GC_STIPPLE* = 1 shl 6
-  GC_CLIP_MASK* = 1 shl 7
-  GC_SUBWINDOW* = 1 shl 8
-  GC_TS_X_ORIGIN* = 1 shl 9
-  GC_TS_Y_ORIGIN* = 1 shl 10
-  GC_CLIP_X_ORIGIN* = 1 shl 11
-  GC_CLIP_Y_ORIGIN* = 1 shl 12
-  GC_EXPOSURES* = 1 shl 13
-  GC_LINE_WIDTH* = 1 shl 14
-  GC_LINE_STYLE* = 1 shl 15
-  GC_CAP_STYLE* = 1 shl 16
-  GC_JOIN_STYLE* = 1 shl 17
-  CLIP_BY_CHILDREN* = 0
-  INCLUDE_INFERIORS* = 1
-
-proc TYPE_GC*(): GType
-proc GC*(anObject: Pointer): PGC
-proc GC_CLASS*(klass: Pointer): PGCClass
-proc IS_GC*(anObject: Pointer): bool
-proc IS_GC_CLASS*(klass: Pointer): bool
-proc GC_GET_CLASS*(obj: Pointer): PGCClass
-proc gc_get_type*(): GType{.cdecl, dynlib: lib, importc: "gdk_gc_get_type".}
-proc gc_new*(drawable: PDrawable): PGC{.cdecl, dynlib: lib, 
-                                        importc: "gdk_gc_new".}
-proc gc_new*(drawable: PDrawable, values: PGCValues, 
-                         values_mask: TGCValuesMask): PGC{.cdecl, dynlib: lib, 
-    importc: "gdk_gc_new_with_values".}
-proc get_values*(gc: PGC, values: PGCValues){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_get_values".}
-proc set_values*(gc: PGC, values: PGCValues, values_mask: TGCValuesMask){.
-    cdecl, dynlib: lib, importc: "gdk_gc_set_values".}
-proc set_foreground*(gc: PGC, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_foreground".}
-proc set_background*(gc: PGC, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_background".}
-proc set_function*(gc: PGC, `function`: TFunction){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_function".}
-proc set_fill*(gc: PGC, fill: TFill){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_fill".}
-proc set_tile*(gc: PGC, tile: PPixmap){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_tile".}
-proc set_stipple*(gc: PGC, stipple: PPixmap){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_stipple".}
-proc set_ts_origin*(gc: PGC, x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_ts_origin".}
-proc set_clip_origin*(gc: PGC, x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_clip_origin".}
-proc set_clip_mask*(gc: PGC, mask: PBitmap){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_clip_mask".}
-proc set_clip_rectangle*(gc: PGC, rectangle: PRectangle){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_clip_rectangle".}
-proc set_clip_region*(gc: PGC, region: PRegion){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_clip_region".}
-proc set_subwindow*(gc: PGC, mode: TSubwindowMode){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_subwindow".}
-proc set_exposures*(gc: PGC, exposures: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_exposures".}
-proc set_line_attributes*(gc: PGC, line_width: gint, line_style: TLineStyle, 
-                             cap_style: TCapStyle, join_style: TJoinStyle){.
-    cdecl, dynlib: lib, importc: "gdk_gc_set_line_attributes".}
-proc set_dashes*(gc: PGC, dash_offset: gint, dash_list: openarray[gint8]){.
-    cdecl, dynlib: lib, importc: "gdk_gc_set_dashes".}
-proc offset*(gc: PGC, x_offset: gint, y_offset: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_offset".}
-proc copy*(dst_gc: PGC, src_gc: PGC){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_copy".}
-proc set_colormap*(gc: PGC, colormap: PColormap){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_colormap".}
-proc get_colormap*(gc: PGC): PColormap{.cdecl, dynlib: lib, 
-    importc: "gdk_gc_get_colormap".}
-proc set_rgb_fg_color*(gc: PGC, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_rgb_fg_color".}
-proc set_rgb_bg_color*(gc: PGC, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_gc_set_rgb_bg_color".}
-proc get_screen*(gc: PGC): PScreen{.cdecl, dynlib: lib, 
-                                       importc: "gdk_gc_get_screen".}
-proc TYPE_IMAGE*(): GType
-proc IMAGE*(anObject: Pointer): PImage
-proc IMAGE_CLASS*(klass: Pointer): PImageClass
-proc IS_IMAGE*(anObject: Pointer): bool
-proc IS_IMAGE_CLASS*(klass: Pointer): bool
-proc IMAGE_GET_CLASS*(obj: Pointer): PImageClass
-proc image_get_type*(): GType{.cdecl, dynlib: lib, importc: "gdk_image_get_type".}
-proc image_new*(`type`: TImageType, visual: PVisual, width: gint, height: gint): PImage{.
-    cdecl, dynlib: lib, importc: "gdk_image_new".}
-proc put_pixel*(image: PImage, x: gint, y: gint, pixel: guint32){.cdecl, 
-    dynlib: lib, importc: "gdk_image_put_pixel".}
-proc get_pixel*(image: PImage, x: gint, y: gint): guint32{.cdecl, 
-    dynlib: lib, importc: "gdk_image_get_pixel".}
-proc set_colormap*(image: PImage, colormap: PColormap){.cdecl, 
-    dynlib: lib, importc: "gdk_image_set_colormap".}
-proc get_colormap*(image: PImage): PColormap{.cdecl, dynlib: lib, 
-    importc: "gdk_image_get_colormap".}
-const 
-  AXIS_IGNORE* = 0
-  AXIS_X* = 1
-  AXIS_Y* = 2
-  AXIS_PRESSURE* = 3
-  AXIS_XTILT* = 4
-  AXIS_YTILT* = 5
-  AXIS_WHEEL* = 6
-  AXIS_LAST* = 7
-
-proc TYPE_DEVICE*(): GType
-proc DEVICE*(anObject: Pointer): PDevice
-proc DEVICE_CLASS*(klass: Pointer): PDeviceClass
-proc IS_DEVICE*(anObject: Pointer): bool
-proc IS_DEVICE_CLASS*(klass: Pointer): bool
-proc DEVICE_GET_CLASS*(obj: Pointer): PDeviceClass
-proc device_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gdk_device_get_type".}
-proc set_source*(device: PDevice, source: TInputSource){.cdecl, 
-    dynlib: lib, importc: "gdk_device_set_source".}
-proc set_mode*(device: PDevice, mode: TInputMode): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_device_set_mode".}
-proc set_key*(device: PDevice, index: guint, keyval: guint, 
-                     modifiers: TModifierType){.cdecl, dynlib: lib, 
-    importc: "gdk_device_set_key".}
-proc set_axis_use*(device: PDevice, index: guint, use: TAxisUse){.cdecl, 
-    dynlib: lib, importc: "gdk_device_set_axis_use".}
-proc get_state*(device: PDevice, window: PWindow, axes: Pgdouble, 
-                       mask: PModifierType){.cdecl, dynlib: lib, 
-    importc: "gdk_device_get_state".}
-proc get_history*(device: PDevice, window: PWindow, start: guint32, 
-                         stop: guint32, s: var PPTimeCoord, n_events: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_device_get_history".}
-proc device_free_history*(events: PPTimeCoord, n_events: gint){.cdecl, 
-    dynlib: lib, importc: "gdk_device_free_history".}
-proc get_axis*(device: PDevice, axes: Pgdouble, use: TAxisUse, 
-                      value: Pgdouble): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_device_get_axis".}
-proc input_set_extension_events*(window: PWindow, mask: gint, 
-                                 mode: TExtensionMode){.cdecl, dynlib: lib, 
-    importc: "gdk_input_set_extension_events".}
-proc device_get_core_pointer*(): PDevice{.cdecl, dynlib: lib, 
-    importc: "gdk_device_get_core_pointer".}
-proc TYPE_KEYMAP*(): GType
-proc KEYMAP*(anObject: Pointer): PKeymap
-proc KEYMAP_CLASS*(klass: Pointer): PKeymapClass
-proc IS_KEYMAP*(anObject: Pointer): bool
-proc IS_KEYMAP_CLASS*(klass: Pointer): bool
-proc KEYMAP_GET_CLASS*(obj: Pointer): PKeymapClass
-proc keymap_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gdk_keymap_get_type".}
-proc keymap_get_for_display*(display: PDisplay): PKeymap{.cdecl, dynlib: lib, 
-    importc: "gdk_keymap_get_for_display".}
-proc lookup_key*(keymap: PKeymap, key: PKeymapKey): guint{.cdecl, 
-    dynlib: lib, importc: "gdk_keymap_lookup_key".}
-proc translate_keyboard_state*(keymap: PKeymap, hardware_keycode: guint, 
-                                      state: TModifierType, group: gint, 
-                                      keyval: Pguint, effective_group: Pgint, 
-                                      level: Pgint, 
-                                      consumed_modifiers: PModifierType): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_keymap_translate_keyboard_state".}
-proc get_entries_for_keyval*(keymap: PKeymap, keyval: guint, 
-                                    s: var PKeymapKey, n_keys: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_keymap_get_entries_for_keyval".}
-proc get_entries_for_keycode*(keymap: PKeymap, hardware_keycode: guint, 
-                                     s: var PKeymapKey, sasdf: var Pguint, 
-                                     n_entries: Pgint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_keymap_get_entries_for_keycode".}
-proc get_direction*(keymap: PKeymap): TDirection{.cdecl, 
-    dynlib: lib, importc: "gdk_keymap_get_direction".}
-proc keyval_name*(keyval: guint): cstring{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_name".}
-proc keyval_from_name*(keyval_name: cstring): guint{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_from_name".}
-proc keyval_convert_case*(symbol: guint, lower: Pguint, upper: Pguint){.cdecl, 
-    dynlib: lib, importc: "gdk_keyval_convert_case".}
-proc keyval_to_upper*(keyval: guint): guint{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_to_upper".}
-proc keyval_to_lower*(keyval: guint): guint{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_to_lower".}
-proc keyval_is_upper*(keyval: guint): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_is_upper".}
-proc keyval_is_lower*(keyval: guint): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_is_lower".}
-proc keyval_to_unicode*(keyval: guint): guint32{.cdecl, dynlib: lib, 
-    importc: "gdk_keyval_to_unicode".}
-proc unicode_to_keyval*(wc: guint32): guint{.cdecl, dynlib: lib, 
-    importc: "gdk_unicode_to_keyval".}
-const 
-  KEY_VoidSymbol* = 0x00FFFFFF
-  KEY_BackSpace* = 0x0000FF08
-  KEY_Tab* = 0x0000FF09
-  KEY_Linefeed* = 0x0000FF0A
-  KEY_Clear* = 0x0000FF0B
-  KEY_Return* = 0x0000FF0D
-  KEY_Pause* = 0x0000FF13
-  KEY_Scroll_Lock* = 0x0000FF14
-  KEY_Sys_Req* = 0x0000FF15
-  KEY_Escape* = 0x0000FF1B
-  KEY_Delete* = 0x0000FFFF
-  KEY_Multi_key* = 0x0000FF20
-  KEY_Codeinput* = 0x0000FF37
-  KEY_SingleCandidate* = 0x0000FF3C
-  KEY_MultipleCandidate* = 0x0000FF3D
-  KEY_PreviousCandidate* = 0x0000FF3E
-  KEY_Kanji* = 0x0000FF21
-  KEY_Muhenkan* = 0x0000FF22
-  KEY_Henkan_Mode* = 0x0000FF23
-  KEY_Henkan* = 0x0000FF23
-  KEY_Romaji* = 0x0000FF24
-  KEY_Hiragana* = 0x0000FF25
-  KEY_Katakana* = 0x0000FF26
-  KEY_Hiragana_Katakana* = 0x0000FF27
-  KEY_Zenkaku* = 0x0000FF28
-  KEY_Hankaku* = 0x0000FF29
-  KEY_Zenkaku_Hankaku* = 0x0000FF2A
-  KEY_Touroku* = 0x0000FF2B
-  KEY_Massyo* = 0x0000FF2C
-  KEY_Kana_Lock* = 0x0000FF2D
-  KEY_Kana_Shift* = 0x0000FF2E
-  KEY_Eisu_Shift* = 0x0000FF2F
-  KEY_Eisu_toggle* = 0x0000FF30
-  KEY_Kanji_Bangou* = 0x0000FF37
-  KEY_Zen_Koho* = 0x0000FF3D
-  KEY_Mae_Koho* = 0x0000FF3E
-  KEY_Home* = 0x0000FF50
-  KEY_Left* = 0x0000FF51
-  KEY_Up* = 0x0000FF52
-  KEY_Right* = 0x0000FF53
-  KEY_Down* = 0x0000FF54
-  KEY_Prior* = 0x0000FF55
-  KEY_Page_Up* = 0x0000FF55
-  KEY_Next* = 0x0000FF56
-  KEY_Page_Down* = 0x0000FF56
-  KEY_End* = 0x0000FF57
-  KEY_Begin* = 0x0000FF58
-  KEY_Select* = 0x0000FF60
-  KEY_Print* = 0x0000FF61
-  KEY_Execute* = 0x0000FF62
-  KEY_Insert* = 0x0000FF63
-  KEY_Undo* = 0x0000FF65
-  KEY_Redo* = 0x0000FF66
-  KEY_Menu* = 0x0000FF67
-  KEY_Find* = 0x0000FF68
-  KEY_Cancel* = 0x0000FF69
-  KEY_Help* = 0x0000FF6A
-  KEY_Break* = 0x0000FF6B
-  KEY_Mode_switch* = 0x0000FF7E
-  KEY_script_switch* = 0x0000FF7E
-  KEY_Num_Lock* = 0x0000FF7F
-  KEY_KP_Space* = 0x0000FF80
-  KEY_KP_Tab* = 0x0000FF89
-  KEY_KP_Enter* = 0x0000FF8D
-  KEY_KP_F1* = 0x0000FF91
-  KEY_KP_F2* = 0x0000FF92
-  KEY_KP_F3* = 0x0000FF93
-  KEY_KP_F4* = 0x0000FF94
-  KEY_KP_Home* = 0x0000FF95
-  KEY_KP_Left* = 0x0000FF96
-  KEY_KP_Up* = 0x0000FF97
-  KEY_KP_Right* = 0x0000FF98
-  KEY_KP_Down* = 0x0000FF99
-  KEY_KP_Prior* = 0x0000FF9A
-  KEY_KP_Page_Up* = 0x0000FF9A
-  KEY_KP_Next* = 0x0000FF9B
-  KEY_KP_Page_Down* = 0x0000FF9B
-  KEY_KP_End* = 0x0000FF9C
-  KEY_KP_Begin* = 0x0000FF9D
-  KEY_KP_Insert* = 0x0000FF9E
-  KEY_KP_Delete* = 0x0000FF9F
-  KEY_KP_Equal* = 0x0000FFBD
-  KEY_KP_Multiply* = 0x0000FFAA
-  KEY_KP_Add* = 0x0000FFAB
-  KEY_KP_Separator* = 0x0000FFAC
-  KEY_KP_Subtract* = 0x0000FFAD
-  KEY_KP_Decimal* = 0x0000FFAE
-  KEY_KP_Divide* = 0x0000FFAF
-  KEY_KP_0* = 0x0000FFB0
-  KEY_KP_1* = 0x0000FFB1
-  KEY_KP_2* = 0x0000FFB2
-  KEY_KP_3* = 0x0000FFB3
-  KEY_KP_4* = 0x0000FFB4
-  KEY_KP_5* = 0x0000FFB5
-  KEY_KP_6* = 0x0000FFB6
-  KEY_KP_7* = 0x0000FFB7
-  KEY_KP_8* = 0x0000FFB8
-  KEY_KP_9* = 0x0000FFB9
-  KEY_F1* = 0x0000FFBE
-  KEY_F2* = 0x0000FFBF
-  KEY_F3* = 0x0000FFC0
-  KEY_F4* = 0x0000FFC1
-  KEY_F5* = 0x0000FFC2
-  KEY_F6* = 0x0000FFC3
-  KEY_F7* = 0x0000FFC4
-  KEY_F8* = 0x0000FFC5
-  KEY_F9* = 0x0000FFC6
-  KEY_F10* = 0x0000FFC7
-  KEY_F11* = 0x0000FFC8
-  KEY_L1* = 0x0000FFC8
-  KEY_F12* = 0x0000FFC9
-  KEY_L2* = 0x0000FFC9
-  KEY_F13* = 0x0000FFCA
-  KEY_L3* = 0x0000FFCA
-  KEY_F14* = 0x0000FFCB
-  KEY_L4* = 0x0000FFCB
-  KEY_F15* = 0x0000FFCC
-  KEY_L5* = 0x0000FFCC
-  KEY_F16* = 0x0000FFCD
-  KEY_L6* = 0x0000FFCD
-  KEY_F17* = 0x0000FFCE
-  KEY_L7* = 0x0000FFCE
-  KEY_F18* = 0x0000FFCF
-  KEY_L8* = 0x0000FFCF
-  KEY_F19* = 0x0000FFD0
-  KEY_L9* = 0x0000FFD0
-  KEY_F20* = 0x0000FFD1
-  KEY_L10* = 0x0000FFD1
-  KEY_F21* = 0x0000FFD2
-  KEY_R1* = 0x0000FFD2
-  KEY_F22* = 0x0000FFD3
-  KEY_R2* = 0x0000FFD3
-  KEY_F23* = 0x0000FFD4
-  KEY_R3* = 0x0000FFD4
-  KEY_F24* = 0x0000FFD5
-  KEY_R4* = 0x0000FFD5
-  KEY_F25* = 0x0000FFD6
-  KEY_R5* = 0x0000FFD6
-  KEY_F26* = 0x0000FFD7
-  KEY_R6* = 0x0000FFD7
-  KEY_F27* = 0x0000FFD8
-  KEY_R7* = 0x0000FFD8
-  KEY_F28* = 0x0000FFD9
-  KEY_R8* = 0x0000FFD9
-  KEY_F29* = 0x0000FFDA
-  KEY_R9* = 0x0000FFDA
-  KEY_F30* = 0x0000FFDB
-  KEY_R10* = 0x0000FFDB
-  KEY_F31* = 0x0000FFDC
-  KEY_R11* = 0x0000FFDC
-  KEY_F32* = 0x0000FFDD
-  KEY_R12* = 0x0000FFDD
-  KEY_F33* = 0x0000FFDE
-  KEY_R13* = 0x0000FFDE
-  KEY_F34* = 0x0000FFDF
-  KEY_R14* = 0x0000FFDF
-  KEY_F35* = 0x0000FFE0
-  KEY_R15* = 0x0000FFE0
-  KEY_Shift_L* = 0x0000FFE1
-  KEY_Shift_R* = 0x0000FFE2
-  KEY_Control_L* = 0x0000FFE3
-  KEY_Control_R* = 0x0000FFE4
-  KEY_Caps_Lock* = 0x0000FFE5
-  KEY_Shift_Lock* = 0x0000FFE6
-  KEY_Meta_L* = 0x0000FFE7
-  KEY_Meta_R* = 0x0000FFE8
-  KEY_Alt_L* = 0x0000FFE9
-  KEY_Alt_R* = 0x0000FFEA
-  KEY_Super_L* = 0x0000FFEB
-  KEY_Super_R* = 0x0000FFEC
-  KEY_Hyper_L* = 0x0000FFED
-  KEY_Hyper_R* = 0x0000FFEE
-  KEY_ISO_Lock* = 0x0000FE01
-  KEY_ISO_Level2_Latch* = 0x0000FE02
-  KEY_ISO_Level3_Shift* = 0x0000FE03
-  KEY_ISO_Level3_Latch* = 0x0000FE04
-  KEY_ISO_Level3_Lock* = 0x0000FE05
-  KEY_ISO_Group_Shift* = 0x0000FF7E
-  KEY_ISO_Group_Latch* = 0x0000FE06
-  KEY_ISO_Group_Lock* = 0x0000FE07
-  KEY_ISO_Next_Group* = 0x0000FE08
-  KEY_ISO_Next_Group_Lock* = 0x0000FE09
-  KEY_ISO_Prev_Group* = 0x0000FE0A
-  KEY_ISO_Prev_Group_Lock* = 0x0000FE0B
-  KEY_ISO_First_Group* = 0x0000FE0C
-  KEY_ISO_First_Group_Lock* = 0x0000FE0D
-  KEY_ISO_Last_Group* = 0x0000FE0E
-  KEY_ISO_Last_Group_Lock* = 0x0000FE0F
-  KEY_ISO_Left_Tab* = 0x0000FE20
-  KEY_ISO_Move_Line_Up* = 0x0000FE21
-  KEY_ISO_Move_Line_Down* = 0x0000FE22
-  KEY_ISO_Partial_Line_Up* = 0x0000FE23
-  KEY_ISO_Partial_Line_Down* = 0x0000FE24
-  KEY_ISO_Partial_Space_Left* = 0x0000FE25
-  KEY_ISO_Partial_Space_Right* = 0x0000FE26
-  KEY_ISO_Set_Margin_Left* = 0x0000FE27
-  KEY_ISO_Set_Margin_Right* = 0x0000FE28
-  KEY_ISO_Release_Margin_Left* = 0x0000FE29
-  KEY_ISO_Release_Margin_Right* = 0x0000FE2A
-  KEY_ISO_Release_Both_Margins* = 0x0000FE2B
-  KEY_ISO_Fast_Cursor_Left* = 0x0000FE2C
-  KEY_ISO_Fast_Cursor_Right* = 0x0000FE2D
-  KEY_ISO_Fast_Cursor_Up* = 0x0000FE2E
-  KEY_ISO_Fast_Cursor_Down* = 0x0000FE2F
-  KEY_ISO_Continuous_Underline* = 0x0000FE30
-  KEY_ISO_Discontinuous_Underline* = 0x0000FE31
-  KEY_ISO_Emphasize* = 0x0000FE32
-  KEY_ISO_Center_Object* = 0x0000FE33
-  KEY_ISO_Enter* = 0x0000FE34
-  KEY_dead_grave* = 0x0000FE50
-  KEY_dead_acute* = 0x0000FE51
-  KEY_dead_circumflex* = 0x0000FE52
-  KEY_dead_tilde* = 0x0000FE53
-  KEY_dead_macron* = 0x0000FE54
-  KEY_dead_breve* = 0x0000FE55
-  KEY_dead_abovedot* = 0x0000FE56
-  KEY_dead_diaeresis* = 0x0000FE57
-  KEY_dead_abovering* = 0x0000FE58
-  KEY_dead_doubleacute* = 0x0000FE59
-  KEY_dead_caron* = 0x0000FE5A
-  KEY_dead_cedilla* = 0x0000FE5B
-  KEY_dead_ogonek* = 0x0000FE5C
-  KEY_dead_iota* = 0x0000FE5D
-  KEY_dead_voiced_sound* = 0x0000FE5E
-  KEY_dead_semivoiced_sound* = 0x0000FE5F
-  KEY_dead_belowdot* = 0x0000FE60
-  KEY_First_Virtual_Screen* = 0x0000FED0
-  KEY_Prev_Virtual_Screen* = 0x0000FED1
-  KEY_Next_Virtual_Screen* = 0x0000FED2
-  KEY_Last_Virtual_Screen* = 0x0000FED4
-  KEY_Terminate_Server* = 0x0000FED5
-  KEY_AccessX_Enable* = 0x0000FE70
-  KEY_AccessX_Feedback_Enable* = 0x0000FE71
-  KEY_RepeatKeys_Enable* = 0x0000FE72
-  KEY_SlowKeys_Enable* = 0x0000FE73
-  KEY_BounceKeys_Enable* = 0x0000FE74
-  KEY_StickyKeys_Enable* = 0x0000FE75
-  KEY_MouseKeys_Enable* = 0x0000FE76
-  KEY_MouseKeys_Accel_Enable* = 0x0000FE77
-  KEY_Overlay1_Enable* = 0x0000FE78
-  KEY_Overlay2_Enable* = 0x0000FE79
-  KEY_AudibleBell_Enable* = 0x0000FE7A
-  KEY_Pointer_Left* = 0x0000FEE0
-  KEY_Pointer_Right* = 0x0000FEE1
-  KEY_Pointer_Up* = 0x0000FEE2
-  KEY_Pointer_Down* = 0x0000FEE3
-  KEY_Pointer_UpLeft* = 0x0000FEE4
-  KEY_Pointer_UpRight* = 0x0000FEE5
-  KEY_Pointer_DownLeft* = 0x0000FEE6
-  KEY_Pointer_DownRight* = 0x0000FEE7
-  KEY_Pointer_Button_Dflt* = 0x0000FEE8
-  KEY_Pointer_Button1* = 0x0000FEE9
-  KEY_Pointer_Button2* = 0x0000FEEA
-  KEY_Pointer_Button3* = 0x0000FEEB
-  KEY_Pointer_Button4* = 0x0000FEEC
-  KEY_Pointer_Button5* = 0x0000FEED
-  KEY_Pointer_DblClick_Dflt* = 0x0000FEEE
-  KEY_Pointer_DblClick1* = 0x0000FEEF
-  KEY_Pointer_DblClick2* = 0x0000FEF0
-  KEY_Pointer_DblClick3* = 0x0000FEF1
-  KEY_Pointer_DblClick4* = 0x0000FEF2
-  KEY_Pointer_DblClick5* = 0x0000FEF3
-  KEY_Pointer_Drag_Dflt* = 0x0000FEF4
-  KEY_Pointer_Drag1* = 0x0000FEF5
-  KEY_Pointer_Drag2* = 0x0000FEF6
-  KEY_Pointer_Drag3* = 0x0000FEF7
-  KEY_Pointer_Drag4* = 0x0000FEF8
-  KEY_Pointer_Drag5* = 0x0000FEFD
-  KEY_Pointer_EnableKeys* = 0x0000FEF9
-  KEY_Pointer_Accelerate* = 0x0000FEFA
-  KEY_Pointer_DfltBtnNext* = 0x0000FEFB
-  KEY_Pointer_DfltBtnPrev* = 0x0000FEFC
-  KEY_3270_Duplicate* = 0x0000FD01
-  KEY_3270_FieldMark* = 0x0000FD02
-  KEY_3270_Right2* = 0x0000FD03
-  KEY_3270_Left2* = 0x0000FD04
-  KEY_3270_BackTab* = 0x0000FD05
-  KEY_3270_EraseEOF* = 0x0000FD06
-  KEY_3270_EraseInput* = 0x0000FD07
-  KEY_3270_Reset* = 0x0000FD08
-  KEY_3270_Quit* = 0x0000FD09
-  KEY_3270_PA1* = 0x0000FD0A
-  KEY_3270_PA2* = 0x0000FD0B
-  KEY_3270_PA3* = 0x0000FD0C
-  KEY_3270_Test* = 0x0000FD0D
-  KEY_3270_Attn* = 0x0000FD0E
-  KEY_3270_CursorBlink* = 0x0000FD0F
-  KEY_3270_AltCursor* = 0x0000FD10
-  KEY_3270_KeyClick* = 0x0000FD11
-  KEY_3270_Jump* = 0x0000FD12
-  KEY_3270_Ident* = 0x0000FD13
-  KEY_3270_Rule* = 0x0000FD14
-  KEY_3270_Copy* = 0x0000FD15
-  KEY_3270_Play* = 0x0000FD16
-  KEY_3270_Setup* = 0x0000FD17
-  KEY_3270_Record* = 0x0000FD18
-  KEY_3270_ChangeScreen* = 0x0000FD19
-  KEY_3270_DeleteWord* = 0x0000FD1A
-  KEY_3270_ExSelect* = 0x0000FD1B
-  KEY_3270_CursorSelect* = 0x0000FD1C
-  KEY_3270_PrintScreen* = 0x0000FD1D
-  KEY_3270_Enter* = 0x0000FD1E
-  KEY_space* = 0x00000020
-  KEY_exclam* = 0x00000021
-  KEY_quotedbl* = 0x00000022
-  KEY_numbersign* = 0x00000023
-  KEY_dollar* = 0x00000024
-  KEY_percent* = 0x00000025
-  KEY_ampersand* = 0x00000026
-  KEY_apostrophe* = 0x00000027
-  KEY_quoteright* = 0x00000027
-  KEY_parenleft* = 0x00000028
-  KEY_parenright* = 0x00000029
-  KEY_asterisk* = 0x0000002A
-  KEY_plus* = 0x0000002B
-  KEY_comma* = 0x0000002C
-  KEY_minus* = 0x0000002D
-  KEY_period* = 0x0000002E
-  KEY_slash* = 0x0000002F
-  KEY_0* = 0x00000030
-  KEY_1* = 0x00000031
-  KEY_2* = 0x00000032
-  KEY_3* = 0x00000033
-  KEY_4* = 0x00000034
-  KEY_5* = 0x00000035
-  KEY_6* = 0x00000036
-  KEY_7* = 0x00000037
-  KEY_8* = 0x00000038
-  KEY_9* = 0x00000039
-  KEY_colon* = 0x0000003A
-  KEY_semicolon* = 0x0000003B
-  KEY_less* = 0x0000003C
-  KEY_equal* = 0x0000003D
-  KEY_greater* = 0x0000003E
-  KEY_question* = 0x0000003F
-  KEY_at* = 0x00000040
-  KEY_CAPITAL_A* = 0x00000041
-  KEY_CAPITAL_B* = 0x00000042
-  KEY_CAPITAL_C* = 0x00000043
-  KEY_CAPITAL_D* = 0x00000044
-  KEY_CAPITAL_E* = 0x00000045
-  KEY_CAPITAL_F* = 0x00000046
-  KEY_CAPITAL_G* = 0x00000047
-  KEY_CAPITAL_H* = 0x00000048
-  KEY_CAPITAL_I* = 0x00000049
-  KEY_CAPITAL_J* = 0x0000004A
-  KEY_CAPITAL_K* = 0x0000004B
-  KEY_CAPITAL_L* = 0x0000004C
-  KEY_CAPITAL_M* = 0x0000004D
-  KEY_CAPITAL_N* = 0x0000004E
-  KEY_CAPITAL_O* = 0x0000004F
-  KEY_CAPITAL_P* = 0x00000050
-  KEY_CAPITAL_Q* = 0x00000051
-  KEY_CAPITAL_R* = 0x00000052
-  KEY_CAPITAL_S* = 0x00000053
-  KEY_CAPITAL_T* = 0x00000054
-  KEY_CAPITAL_U* = 0x00000055
-  KEY_CAPITAL_V* = 0x00000056
-  KEY_CAPITAL_W* = 0x00000057
-  KEY_CAPITAL_X* = 0x00000058
-  KEY_CAPITAL_Y* = 0x00000059
-  KEY_CAPITAL_Z* = 0x0000005A
-  KEY_bracketleft* = 0x0000005B
-  KEY_backslash* = 0x0000005C
-  KEY_bracketright* = 0x0000005D
-  KEY_asciicircum* = 0x0000005E
-  KEY_underscore* = 0x0000005F
-  KEY_grave* = 0x00000060
-  KEY_quoteleft* = 0x00000060
-  KEY_a* = 0x00000061
-  KEY_b* = 0x00000062
-  KEY_c* = 0x00000063
-  KEY_d* = 0x00000064
-  KEY_e* = 0x00000065
-  KEY_f* = 0x00000066
-  KEY_g* = 0x00000067
-  KEY_h* = 0x00000068
-  KEY_i* = 0x00000069
-  KEY_j* = 0x0000006A
-  KEY_k* = 0x0000006B
-  KEY_l* = 0x0000006C
-  KEY_m* = 0x0000006D
-  KEY_n* = 0x0000006E
-  KEY_o* = 0x0000006F
-  KEY_p* = 0x00000070
-  KEY_q* = 0x00000071
-  KEY_r* = 0x00000072
-  KEY_s* = 0x00000073
-  KEY_t* = 0x00000074
-  KEY_u* = 0x00000075
-  KEY_v* = 0x00000076
-  KEY_w* = 0x00000077
-  KEY_x* = 0x00000078
-  KEY_y* = 0x00000079
-  KEY_z* = 0x0000007A
-  KEY_braceleft* = 0x0000007B
-  KEY_bar* = 0x0000007C
-  KEY_braceright* = 0x0000007D
-  KEY_asciitilde* = 0x0000007E
-  KEY_nobreakspace* = 0x000000A0
-  KEY_exclamdown* = 0x000000A1
-  KEY_cent* = 0x000000A2
-  KEY_sterling* = 0x000000A3
-  KEY_currency* = 0x000000A4
-  KEY_yen* = 0x000000A5
-  KEY_brokenbar* = 0x000000A6
-  KEY_section* = 0x000000A7
-  KEY_diaeresis* = 0x000000A8
-  KEY_copyright* = 0x000000A9
-  KEY_ordfeminine* = 0x000000AA
-  KEY_guillemotleft* = 0x000000AB
-  KEY_notsign* = 0x000000AC
-  KEY_hyphen* = 0x000000AD
-  KEY_registered* = 0x000000AE
-  KEY_macron* = 0x000000AF
-  KEY_degree* = 0x000000B0
-  KEY_plusminus* = 0x000000B1
-  KEY_twosuperior* = 0x000000B2
-  KEY_threesuperior* = 0x000000B3
-  KEY_acute* = 0x000000B4
-  KEY_mu* = 0x000000B5
-  KEY_paragraph* = 0x000000B6
-  KEY_periodcentered* = 0x000000B7
-  KEY_cedilla* = 0x000000B8
-  KEY_onesuperior* = 0x000000B9
-  KEY_masculine* = 0x000000BA
-  KEY_guillemotright* = 0x000000BB
-  KEY_onequarter* = 0x000000BC
-  KEY_onehalf* = 0x000000BD
-  KEY_threequarters* = 0x000000BE
-  KEY_questiondown* = 0x000000BF
-  KEY_CAPITAL_Agrave* = 0x000000C0
-  KEY_CAPITAL_Aacute* = 0x000000C1
-  KEY_CAPITAL_Acircumflex* = 0x000000C2
-  KEY_CAPITAL_Atilde* = 0x000000C3
-  KEY_CAPITAL_Adiaeresis* = 0x000000C4
-  KEY_CAPITAL_Aring* = 0x000000C5
-  KEY_CAPITAL_AE* = 0x000000C6
-  KEY_CAPITAL_Ccedilla* = 0x000000C7
-  KEY_CAPITAL_Egrave* = 0x000000C8
-  KEY_CAPITAL_Eacute* = 0x000000C9
-  KEY_CAPITAL_Ecircumflex* = 0x000000CA
-  KEY_CAPITAL_Ediaeresis* = 0x000000CB
-  KEY_CAPITAL_Igrave* = 0x000000CC
-  KEY_CAPITAL_Iacute* = 0x000000CD
-  KEY_CAPITAL_Icircumflex* = 0x000000CE
-  KEY_CAPITAL_Idiaeresis* = 0x000000CF
-  KEY_CAPITAL_ETH* = 0x000000D0
-  KEY_CAPITAL_Ntilde* = 0x000000D1
-  KEY_CAPITAL_Ograve* = 0x000000D2
-  KEY_CAPITAL_Oacute* = 0x000000D3
-  KEY_CAPITAL_Ocircumflex* = 0x000000D4
-  KEY_CAPITAL_Otilde* = 0x000000D5
-  KEY_CAPITAL_Odiaeresis* = 0x000000D6
-  KEY_multiply* = 0x000000D7
-  KEY_Ooblique* = 0x000000D8
-  KEY_CAPITAL_Ugrave* = 0x000000D9
-  KEY_CAPITAL_Uacute* = 0x000000DA
-  KEY_CAPITAL_Ucircumflex* = 0x000000DB
-  KEY_CAPITAL_Udiaeresis* = 0x000000DC
-  KEY_CAPITAL_Yacute* = 0x000000DD
-  KEY_CAPITAL_THORN* = 0x000000DE
-  KEY_ssharp* = 0x000000DF
-  KEY_agrave* = 0x000000E0
-  KEY_aacute* = 0x000000E1
-  KEY_acircumflex* = 0x000000E2
-  KEY_atilde* = 0x000000E3
-  KEY_adiaeresis* = 0x000000E4
-  KEY_aring* = 0x000000E5
-  KEY_ae* = 0x000000E6
-  KEY_ccedilla* = 0x000000E7
-  KEY_egrave* = 0x000000E8
-  KEY_eacute* = 0x000000E9
-  KEY_ecircumflex* = 0x000000EA
-  KEY_ediaeresis* = 0x000000EB
-  KEY_igrave* = 0x000000EC
-  KEY_iacute* = 0x000000ED
-  KEY_icircumflex* = 0x000000EE
-  KEY_idiaeresis* = 0x000000EF
-  KEY_eth* = 0x000000F0
-  KEY_ntilde* = 0x000000F1
-  KEY_ograve* = 0x000000F2
-  KEY_oacute* = 0x000000F3
-  KEY_ocircumflex* = 0x000000F4
-  KEY_otilde* = 0x000000F5
-  KEY_odiaeresis* = 0x000000F6
-  KEY_division* = 0x000000F7
-  KEY_oslash* = 0x000000F8
-  KEY_ugrave* = 0x000000F9
-  KEY_uacute* = 0x000000FA
-  KEY_ucircumflex* = 0x000000FB
-  KEY_udiaeresis* = 0x000000FC
-  KEY_yacute* = 0x000000FD
-  KEY_thorn* = 0x000000FE
-  KEY_ydiaeresis* = 0x000000FF
-  KEY_CAPITAL_Aogonek* = 0x000001A1
-  KEY_breve* = 0x000001A2
-  KEY_CAPITAL_Lstroke* = 0x000001A3
-  KEY_CAPITAL_Lcaron* = 0x000001A5
-  KEY_CAPITAL_Sacute* = 0x000001A6
-  KEY_CAPITAL_Scaron* = 0x000001A9
-  KEY_CAPITAL_Scedilla* = 0x000001AA
-  KEY_CAPITAL_Tcaron* = 0x000001AB
-  KEY_CAPITAL_Zacute* = 0x000001AC
-  KEY_CAPITAL_Zcaron* = 0x000001AE
-  KEY_CAPITAL_Zabovedot* = 0x000001AF
-  KEY_aogonek* = 0x000001B1
-  KEY_ogonek* = 0x000001B2
-  KEY_lstroke* = 0x000001B3
-  KEY_lcaron* = 0x000001B5
-  KEY_sacute* = 0x000001B6
-  KEY_caron* = 0x000001B7
-  KEY_scaron* = 0x000001B9
-  KEY_scedilla* = 0x000001BA
-  KEY_tcaron* = 0x000001BB
-  KEY_zacute* = 0x000001BC
-  KEY_doubleacute* = 0x000001BD
-  KEY_zcaron* = 0x000001BE
-  KEY_zabovedot* = 0x000001BF
-  KEY_CAPITAL_Racute* = 0x000001C0
-  KEY_CAPITAL_Abreve* = 0x000001C3
-  KEY_CAPITAL_Lacute* = 0x000001C5
-  KEY_CAPITAL_Cacute* = 0x000001C6
-  KEY_CAPITAL_Ccaron* = 0x000001C8
-  KEY_CAPITAL_Eogonek* = 0x000001CA
-  KEY_CAPITAL_Ecaron* = 0x000001CC
-  KEY_CAPITAL_Dcaron* = 0x000001CF
-  KEY_CAPITAL_Dstroke* = 0x000001D0
-  KEY_CAPITAL_Nacute* = 0x000001D1
-  KEY_CAPITAL_Ncaron* = 0x000001D2
-  KEY_CAPITAL_Odoubleacute* = 0x000001D5
-  KEY_CAPITAL_Rcaron* = 0x000001D8
-  KEY_CAPITAL_Uring* = 0x000001D9
-  KEY_CAPITAL_Udoubleacute* = 0x000001DB
-  KEY_CAPITAL_Tcedilla* = 0x000001DE
-  KEY_racute* = 0x000001E0
-  KEY_abreve* = 0x000001E3
-  KEY_lacute* = 0x000001E5
-  KEY_cacute* = 0x000001E6
-  KEY_ccaron* = 0x000001E8
-  KEY_eogonek* = 0x000001EA
-  KEY_ecaron* = 0x000001EC
-  KEY_dcaron* = 0x000001EF
-  KEY_dstroke* = 0x000001F0
-  KEY_nacute* = 0x000001F1
-  KEY_ncaron* = 0x000001F2
-  KEY_odoubleacute* = 0x000001F5
-  KEY_udoubleacute* = 0x000001FB
-  KEY_rcaron* = 0x000001F8
-  KEY_uring* = 0x000001F9
-  KEY_tcedilla* = 0x000001FE
-  KEY_abovedot* = 0x000001FF
-  KEY_CAPITAL_Hstroke* = 0x000002A1
-  KEY_CAPITAL_Hcircumflex* = 0x000002A6
-  KEY_CAPITAL_Iabovedot* = 0x000002A9
-  KEY_CAPITAL_Gbreve* = 0x000002AB
-  KEY_CAPITAL_Jcircumflex* = 0x000002AC
-  KEY_hstroke* = 0x000002B1
-  KEY_hcircumflex* = 0x000002B6
-  KEY_idotless* = 0x000002B9
-  KEY_gbreve* = 0x000002BB
-  KEY_jcircumflex* = 0x000002BC
-  KEY_CAPITAL_Cabovedot* = 0x000002C5
-  KEY_CAPITAL_Ccircumflex* = 0x000002C6
-  KEY_CAPITAL_Gabovedot* = 0x000002D5
-  KEY_CAPITAL_Gcircumflex* = 0x000002D8
-  KEY_CAPITAL_Ubreve* = 0x000002DD
-  KEY_CAPITAL_Scircumflex* = 0x000002DE
-  KEY_cabovedot* = 0x000002E5
-  KEY_ccircumflex* = 0x000002E6
-  KEY_gabovedot* = 0x000002F5
-  KEY_gcircumflex* = 0x000002F8
-  KEY_ubreve* = 0x000002FD
-  KEY_scircumflex* = 0x000002FE
-  KEY_kra* = 0x000003A2
-  KEY_kappa* = 0x000003A2
-  KEY_CAPITAL_Rcedilla* = 0x000003A3
-  KEY_CAPITAL_Itilde* = 0x000003A5
-  KEY_CAPITAL_Lcedilla* = 0x000003A6
-  KEY_CAPITAL_Emacron* = 0x000003AA
-  KEY_CAPITAL_Gcedilla* = 0x000003AB
-  KEY_CAPITAL_Tslash* = 0x000003AC
-  KEY_rcedilla* = 0x000003B3
-  KEY_itilde* = 0x000003B5
-  KEY_lcedilla* = 0x000003B6
-  KEY_emacron* = 0x000003BA
-  KEY_gcedilla* = 0x000003BB
-  KEY_tslash* = 0x000003BC
-  KEY_CAPITAL_ENG* = 0x000003BD
-  KEY_eng* = 0x000003BF
-  KEY_CAPITAL_Amacron* = 0x000003C0
-  KEY_CAPITAL_Iogonek* = 0x000003C7
-  KEY_CAPITAL_Eabovedot* = 0x000003CC
-  KEY_CAPITAL_Imacron* = 0x000003CF
-  KEY_CAPITAL_Ncedilla* = 0x000003D1
-  KEY_CAPITAL_Omacron* = 0x000003D2
-  KEY_CAPITAL_Kcedilla* = 0x000003D3
-  KEY_CAPITAL_Uogonek* = 0x000003D9
-  KEY_CAPITAL_Utilde* = 0x000003DD
-  KEY_CAPITAL_Umacron* = 0x000003DE
-  KEY_amacron* = 0x000003E0
-  KEY_iogonek* = 0x000003E7
-  KEY_eabovedot* = 0x000003EC
-  KEY_imacron* = 0x000003EF
-  KEY_ncedilla* = 0x000003F1
-  KEY_omacron* = 0x000003F2
-  KEY_kcedilla* = 0x000003F3
-  KEY_uogonek* = 0x000003F9
-  KEY_utilde* = 0x000003FD
-  KEY_umacron* = 0x000003FE
-  KEY_CAPITAL_OE* = 0x000013BC
-  KEY_oe* = 0x000013BD
-  KEY_CAPITAL_Ydiaeresis* = 0x000013BE
-  KEY_overline* = 0x0000047E
-  KEY_kana_fullstop* = 0x000004A1
-  KEY_kana_openingbracket* = 0x000004A2
-  KEY_kana_closingbracket* = 0x000004A3
-  KEY_kana_comma* = 0x000004A4
-  KEY_kana_conjunctive* = 0x000004A5
-  KEY_kana_middledot* = 0x000004A5
-  KEY_kana_WO* = 0x000004A6
-  KEY_kana_a* = 0x000004A7
-  KEY_kana_i* = 0x000004A8
-  KEY_kana_u* = 0x000004A9
-  KEY_kana_e* = 0x000004AA
-  KEY_kana_o* = 0x000004AB
-  KEY_kana_ya* = 0x000004AC
-  KEY_kana_yu* = 0x000004AD
-  KEY_kana_yo* = 0x000004AE
-  KEY_kana_tsu* = 0x000004AF
-  KEY_kana_tu* = 0x000004AF
-  KEY_prolongedsound* = 0x000004B0
-  KEY_kana_CAPITAL_A* = 0x000004B1
-  KEY_kana_CAPITAL_I* = 0x000004B2
-  KEY_kana_CAPITAL_U* = 0x000004B3
-  KEY_kana_CAPITAL_E* = 0x000004B4
-  KEY_kana_CAPITAL_O* = 0x000004B5
-  KEY_kana_KA* = 0x000004B6
-  KEY_kana_KI* = 0x000004B7
-  KEY_kana_KU* = 0x000004B8
-  KEY_kana_KE* = 0x000004B9
-  KEY_kana_KO* = 0x000004BA
-  KEY_kana_SA* = 0x000004BB
-  KEY_kana_SHI* = 0x000004BC
-  KEY_kana_SU* = 0x000004BD
-  KEY_kana_SE* = 0x000004BE
-  KEY_kana_SO* = 0x000004BF
-  KEY_kana_TA* = 0x000004C0
-  KEY_kana_CHI* = 0x000004C1
-  KEY_kana_TI* = 0x000004C1
-  KEY_kana_CAPITAL_TSU* = 0x000004C2
-  KEY_kana_CAPITAL_TU* = 0x000004C2
-  KEY_kana_TE* = 0x000004C3
-  KEY_kana_TO* = 0x000004C4
-  KEY_kana_NA* = 0x000004C5
-  KEY_kana_NI* = 0x000004C6
-  KEY_kana_NU* = 0x000004C7
-  KEY_kana_NE* = 0x000004C8
-  KEY_kana_NO* = 0x000004C9
-  KEY_kana_HA* = 0x000004CA
-  KEY_kana_HI* = 0x000004CB
-  KEY_kana_FU* = 0x000004CC
-  KEY_kana_HU* = 0x000004CC
-  KEY_kana_HE* = 0x000004CD
-  KEY_kana_HO* = 0x000004CE
-  KEY_kana_MA* = 0x000004CF
-  KEY_kana_MI* = 0x000004D0
-  KEY_kana_MU* = 0x000004D1
-  KEY_kana_ME* = 0x000004D2
-  KEY_kana_MO* = 0x000004D3
-  KEY_kana_CAPITAL_YA* = 0x000004D4
-  KEY_kana_CAPITAL_YU* = 0x000004D5
-  KEY_kana_CAPITAL_YO* = 0x000004D6
-  KEY_kana_RA* = 0x000004D7
-  KEY_kana_RI* = 0x000004D8
-  KEY_kana_RU* = 0x000004D9
-  KEY_kana_RE* = 0x000004DA
-  KEY_kana_RO* = 0x000004DB
-  KEY_kana_WA* = 0x000004DC
-  KEY_kana_N* = 0x000004DD
-  KEY_voicedsound* = 0x000004DE
-  KEY_semivoicedsound* = 0x000004DF
-  KEY_kana_switch* = 0x0000FF7E
-  KEY_Arabic_comma* = 0x000005AC
-  KEY_Arabic_semicolon* = 0x000005BB
-  KEY_Arabic_question_mark* = 0x000005BF
-  KEY_Arabic_hamza* = 0x000005C1
-  KEY_Arabic_maddaonalef* = 0x000005C2
-  KEY_Arabic_hamzaonalef* = 0x000005C3
-  KEY_Arabic_hamzaonwaw* = 0x000005C4
-  KEY_Arabic_hamzaunderalef* = 0x000005C5
-  KEY_Arabic_hamzaonyeh* = 0x000005C6
-  KEY_Arabic_alef* = 0x000005C7
-  KEY_Arabic_beh* = 0x000005C8
-  KEY_Arabic_tehmarbuta* = 0x000005C9
-  KEY_Arabic_teh* = 0x000005CA
-  KEY_Arabic_theh* = 0x000005CB
-  KEY_Arabic_jeem* = 0x000005CC
-  KEY_Arabic_hah* = 0x000005CD
-  KEY_Arabic_khah* = 0x000005CE
-  KEY_Arabic_dal* = 0x000005CF
-  KEY_Arabic_thal* = 0x000005D0
-  KEY_Arabic_ra* = 0x000005D1
-  KEY_Arabic_zain* = 0x000005D2
-  KEY_Arabic_seen* = 0x000005D3
-  KEY_Arabic_sheen* = 0x000005D4
-  KEY_Arabic_sad* = 0x000005D5
-  KEY_Arabic_dad* = 0x000005D6
-  KEY_Arabic_tah* = 0x000005D7
-  KEY_Arabic_zah* = 0x000005D8
-  KEY_Arabic_ain* = 0x000005D9
-  KEY_Arabic_ghain* = 0x000005DA
-  KEY_Arabic_tatweel* = 0x000005E0
-  KEY_Arabic_feh* = 0x000005E1
-  KEY_Arabic_qaf* = 0x000005E2
-  KEY_Arabic_kaf* = 0x000005E3
-  KEY_Arabic_lam* = 0x000005E4
-  KEY_Arabic_meem* = 0x000005E5
-  KEY_Arabic_noon* = 0x000005E6
-  KEY_Arabic_ha* = 0x000005E7
-  KEY_Arabic_heh* = 0x000005E7
-  KEY_Arabic_waw* = 0x000005E8
-  KEY_Arabic_alefmaksura* = 0x000005E9
-  KEY_Arabic_yeh* = 0x000005EA
-  KEY_Arabic_fathatan* = 0x000005EB
-  KEY_Arabic_dammatan* = 0x000005EC
-  KEY_Arabic_kasratan* = 0x000005ED
-  KEY_Arabic_fatha* = 0x000005EE
-  KEY_Arabic_damma* = 0x000005EF
-  KEY_Arabic_kasra* = 0x000005F0
-  KEY_Arabic_shadda* = 0x000005F1
-  KEY_Arabic_sukun* = 0x000005F2
-  KEY_Arabic_switch* = 0x0000FF7E
-  KEY_Serbian_dje* = 0x000006A1
-  KEY_Macedonia_gje* = 0x000006A2
-  KEY_Cyrillic_io* = 0x000006A3
-  KEY_Ukrainian_ie* = 0x000006A4
-  KEY_Ukranian_je* = 0x000006A4
-  KEY_Macedonia_dse* = 0x000006A5
-  KEY_Ukrainian_i* = 0x000006A6
-  KEY_Ukranian_i* = 0x000006A6
-  KEY_Ukrainian_yi* = 0x000006A7
-  KEY_Ukranian_yi* = 0x000006A7
-  KEY_Cyrillic_je* = 0x000006A8
-  KEY_Serbian_je* = 0x000006A8
-  KEY_Cyrillic_lje* = 0x000006A9
-  KEY_Serbian_lje* = 0x000006A9
-  KEY_Cyrillic_nje* = 0x000006AA
-  KEY_Serbian_nje* = 0x000006AA
-  KEY_Serbian_tshe* = 0x000006AB
-  KEY_Macedonia_kje* = 0x000006AC
-  KEY_Byelorussian_shortu* = 0x000006AE
-  KEY_Cyrillic_dzhe* = 0x000006AF
-  KEY_Serbian_dze* = 0x000006AF
-  KEY_numerosign* = 0x000006B0
-  KEY_Serbian_CAPITAL_DJE* = 0x000006B1
-  KEY_Macedonia_CAPITAL_GJE* = 0x000006B2
-  KEY_Cyrillic_CAPITAL_IO* = 0x000006B3
-  KEY_Ukrainian_CAPITAL_IE* = 0x000006B4
-  KEY_Ukranian_CAPITAL_JE* = 0x000006B4
-  KEY_Macedonia_CAPITAL_DSE* = 0x000006B5
-  KEY_Ukrainian_CAPITAL_I* = 0x000006B6
-  KEY_Ukranian_CAPITAL_I* = 0x000006B6
-  KEY_Ukrainian_CAPITAL_YI* = 0x000006B7
-  KEY_Ukranian_CAPITAL_YI* = 0x000006B7
-  KEY_Cyrillic_CAPITAL_JE* = 0x000006B8
-  KEY_Serbian_CAPITAL_JE* = 0x000006B8
-  KEY_Cyrillic_CAPITAL_LJE* = 0x000006B9
-  KEY_Serbian_CAPITAL_LJE* = 0x000006B9
-  KEY_Cyrillic_CAPITAL_NJE* = 0x000006BA
-  KEY_Serbian_CAPITAL_NJE* = 0x000006BA
-  KEY_Serbian_CAPITAL_TSHE* = 0x000006BB
-  KEY_Macedonia_CAPITAL_KJE* = 0x000006BC
-  KEY_Byelorussian_CAPITAL_SHORTU* = 0x000006BE
-  KEY_Cyrillic_CAPITAL_DZHE* = 0x000006BF
-  KEY_Serbian_CAPITAL_DZE* = 0x000006BF
-  KEY_Cyrillic_yu* = 0x000006C0
-  KEY_Cyrillic_a* = 0x000006C1
-  KEY_Cyrillic_be* = 0x000006C2
-  KEY_Cyrillic_tse* = 0x000006C3
-  KEY_Cyrillic_de* = 0x000006C4
-  KEY_Cyrillic_ie* = 0x000006C5
-  KEY_Cyrillic_ef* = 0x000006C6
-  KEY_Cyrillic_ghe* = 0x000006C7
-  KEY_Cyrillic_ha* = 0x000006C8
-  KEY_Cyrillic_i* = 0x000006C9
-  KEY_Cyrillic_shorti* = 0x000006CA
-  KEY_Cyrillic_ka* = 0x000006CB
-  KEY_Cyrillic_el* = 0x000006CC
-  KEY_Cyrillic_em* = 0x000006CD
-  KEY_Cyrillic_en* = 0x000006CE
-  KEY_Cyrillic_o* = 0x000006CF
-  KEY_Cyrillic_pe* = 0x000006D0
-  KEY_Cyrillic_ya* = 0x000006D1
-  KEY_Cyrillic_er* = 0x000006D2
-  KEY_Cyrillic_es* = 0x000006D3
-  KEY_Cyrillic_te* = 0x000006D4
-  KEY_Cyrillic_u* = 0x000006D5
-  KEY_Cyrillic_zhe* = 0x000006D6
-  KEY_Cyrillic_ve* = 0x000006D7
-  KEY_Cyrillic_softsign* = 0x000006D8
-  KEY_Cyrillic_yeru* = 0x000006D9
-  KEY_Cyrillic_ze* = 0x000006DA
-  KEY_Cyrillic_sha* = 0x000006DB
-  KEY_Cyrillic_e* = 0x000006DC
-  KEY_Cyrillic_shcha* = 0x000006DD
-  KEY_Cyrillic_che* = 0x000006DE
-  KEY_Cyrillic_hardsign* = 0x000006DF
-  KEY_Cyrillic_CAPITAL_YU* = 0x000006E0
-  KEY_Cyrillic_CAPITAL_A* = 0x000006E1
-  KEY_Cyrillic_CAPITAL_BE* = 0x000006E2
-  KEY_Cyrillic_CAPITAL_TSE* = 0x000006E3
-  KEY_Cyrillic_CAPITAL_DE* = 0x000006E4
-  KEY_Cyrillic_CAPITAL_IE* = 0x000006E5
-  KEY_Cyrillic_CAPITAL_EF* = 0x000006E6
-  KEY_Cyrillic_CAPITAL_GHE* = 0x000006E7
-  KEY_Cyrillic_CAPITAL_HA* = 0x000006E8
-  KEY_Cyrillic_CAPITAL_I* = 0x000006E9
-  KEY_Cyrillic_CAPITAL_SHORTI* = 0x000006EA
-  KEY_Cyrillic_CAPITAL_KA* = 0x000006EB
-  KEY_Cyrillic_CAPITAL_EL* = 0x000006EC
-  KEY_Cyrillic_CAPITAL_EM* = 0x000006ED
-  KEY_Cyrillic_CAPITAL_EN* = 0x000006EE
-  KEY_Cyrillic_CAPITAL_O* = 0x000006EF
-  KEY_Cyrillic_CAPITAL_PE* = 0x000006F0
-  KEY_Cyrillic_CAPITAL_YA* = 0x000006F1
-  KEY_Cyrillic_CAPITAL_ER* = 0x000006F2
-  KEY_Cyrillic_CAPITAL_ES* = 0x000006F3
-  KEY_Cyrillic_CAPITAL_TE* = 0x000006F4
-  KEY_Cyrillic_CAPITAL_U* = 0x000006F5
-  KEY_Cyrillic_CAPITAL_ZHE* = 0x000006F6
-  KEY_Cyrillic_CAPITAL_VE* = 0x000006F7
-  KEY_Cyrillic_CAPITAL_SOFTSIGN* = 0x000006F8
-  KEY_Cyrillic_CAPITAL_YERU* = 0x000006F9
-  KEY_Cyrillic_CAPITAL_ZE* = 0x000006FA
-  KEY_Cyrillic_CAPITAL_SHA* = 0x000006FB
-  KEY_Cyrillic_CAPITAL_E* = 0x000006FC
-  KEY_Cyrillic_CAPITAL_SHCHA* = 0x000006FD
-  KEY_Cyrillic_CAPITAL_CHE* = 0x000006FE
-  KEY_Cyrillic_CAPITAL_HARDSIGN* = 0x000006FF
-  KEY_Greek_CAPITAL_ALPHAaccent* = 0x000007A1
-  KEY_Greek_CAPITAL_EPSILONaccent* = 0x000007A2
-  KEY_Greek_CAPITAL_ETAaccent* = 0x000007A3
-  KEY_Greek_CAPITAL_IOTAaccent* = 0x000007A4
-  KEY_Greek_CAPITAL_IOTAdiaeresis* = 0x000007A5
-  KEY_Greek_CAPITAL_OMICRONaccent* = 0x000007A7
-  KEY_Greek_CAPITAL_UPSILONaccent* = 0x000007A8
-  KEY_Greek_CAPITAL_UPSILONdieresis* = 0x000007A9
-  KEY_Greek_CAPITAL_OMEGAaccent* = 0x000007AB
-  KEY_Greek_accentdieresis* = 0x000007AE
-  KEY_Greek_horizbar* = 0x000007AF
-  KEY_Greek_alphaaccent* = 0x000007B1
-  KEY_Greek_epsilonaccent* = 0x000007B2
-  KEY_Greek_etaaccent* = 0x000007B3
-  KEY_Greek_iotaaccent* = 0x000007B4
-  KEY_Greek_iotadieresis* = 0x000007B5
-  KEY_Greek_iotaaccentdieresis* = 0x000007B6
-  KEY_Greek_omicronaccent* = 0x000007B7
-  KEY_Greek_upsilonaccent* = 0x000007B8
-  KEY_Greek_upsilondieresis* = 0x000007B9
-  KEY_Greek_upsilonaccentdieresis* = 0x000007BA
-  KEY_Greek_omegaaccent* = 0x000007BB
-  KEY_Greek_CAPITAL_ALPHA* = 0x000007C1
-  KEY_Greek_CAPITAL_BETA* = 0x000007C2
-  KEY_Greek_CAPITAL_GAMMA* = 0x000007C3
-  KEY_Greek_CAPITAL_DELTA* = 0x000007C4
-  KEY_Greek_CAPITAL_EPSILON* = 0x000007C5
-  KEY_Greek_CAPITAL_ZETA* = 0x000007C6
-  KEY_Greek_CAPITAL_ETA* = 0x000007C7
-  KEY_Greek_CAPITAL_THETA* = 0x000007C8
-  KEY_Greek_CAPITAL_IOTA* = 0x000007C9
-  KEY_Greek_CAPITAL_KAPPA* = 0x000007CA
-  KEY_Greek_CAPITAL_LAMDA* = 0x000007CB
-  KEY_Greek_CAPITAL_LAMBDA* = 0x000007CB
-  KEY_Greek_CAPITAL_MU* = 0x000007CC
-  KEY_Greek_CAPITAL_NU* = 0x000007CD
-  KEY_Greek_CAPITAL_XI* = 0x000007CE
-  KEY_Greek_CAPITAL_OMICRON* = 0x000007CF
-  KEY_Greek_CAPITAL_PI* = 0x000007D0
-  KEY_Greek_CAPITAL_RHO* = 0x000007D1
-  KEY_Greek_CAPITAL_SIGMA* = 0x000007D2
-  KEY_Greek_CAPITAL_TAU* = 0x000007D4
-  KEY_Greek_CAPITAL_UPSILON* = 0x000007D5
-  KEY_Greek_CAPITAL_PHI* = 0x000007D6
-  KEY_Greek_CAPITAL_CHI* = 0x000007D7
-  KEY_Greek_CAPITAL_PSI* = 0x000007D8
-  KEY_Greek_CAPITAL_OMEGA* = 0x000007D9
-  KEY_Greek_alpha* = 0x000007E1
-  KEY_Greek_beta* = 0x000007E2
-  KEY_Greek_gamma* = 0x000007E3
-  KEY_Greek_delta* = 0x000007E4
-  KEY_Greek_epsilon* = 0x000007E5
-  KEY_Greek_zeta* = 0x000007E6
-  KEY_Greek_eta* = 0x000007E7
-  KEY_Greek_theta* = 0x000007E8
-  KEY_Greek_iota* = 0x000007E9
-  KEY_Greek_kappa* = 0x000007EA
-  KEY_Greek_lamda* = 0x000007EB
-  KEY_Greek_lambda* = 0x000007EB
-  KEY_Greek_mu* = 0x000007EC
-  KEY_Greek_nu* = 0x000007ED
-  KEY_Greek_xi* = 0x000007EE
-  KEY_Greek_omicron* = 0x000007EF
-  KEY_Greek_pi* = 0x000007F0
-  KEY_Greek_rho* = 0x000007F1
-  KEY_Greek_sigma* = 0x000007F2
-  KEY_Greek_finalsmallsigma* = 0x000007F3
-  KEY_Greek_tau* = 0x000007F4
-  KEY_Greek_upsilon* = 0x000007F5
-  KEY_Greek_phi* = 0x000007F6
-  KEY_Greek_chi* = 0x000007F7
-  KEY_Greek_psi* = 0x000007F8
-  KEY_Greek_omega* = 0x000007F9
-  KEY_Greek_switch* = 0x0000FF7E
-  KEY_leftradical* = 0x000008A1
-  KEY_topleftradical* = 0x000008A2
-  KEY_horizconnector* = 0x000008A3
-  KEY_topintegral* = 0x000008A4
-  KEY_botintegral* = 0x000008A5
-  KEY_vertconnector* = 0x000008A6
-  KEY_topleftsqbracket* = 0x000008A7
-  KEY_botleftsqbracket* = 0x000008A8
-  KEY_toprightsqbracket* = 0x000008A9
-  KEY_botrightsqbracket* = 0x000008AA
-  KEY_topleftparens* = 0x000008AB
-  KEY_botleftparens* = 0x000008AC
-  KEY_toprightparens* = 0x000008AD
-  KEY_botrightparens* = 0x000008AE
-  KEY_leftmiddlecurlybrace* = 0x000008AF
-  KEY_rightmiddlecurlybrace* = 0x000008B0
-  KEY_topleftsummation* = 0x000008B1
-  KEY_botleftsummation* = 0x000008B2
-  KEY_topvertsummationconnector* = 0x000008B3
-  KEY_botvertsummationconnector* = 0x000008B4
-  KEY_toprightsummation* = 0x000008B5
-  KEY_botrightsummation* = 0x000008B6
-  KEY_rightmiddlesummation* = 0x000008B7
-  KEY_lessthanequal* = 0x000008BC
-  KEY_notequal* = 0x000008BD
-  KEY_greaterthanequal* = 0x000008BE
-  KEY_integral* = 0x000008BF
-  KEY_therefore* = 0x000008C0
-  KEY_variation* = 0x000008C1
-  KEY_infinity* = 0x000008C2
-  KEY_nabla* = 0x000008C5
-  KEY_approximate* = 0x000008C8
-  KEY_similarequal* = 0x000008C9
-  KEY_ifonlyif* = 0x000008CD
-  KEY_implies* = 0x000008CE
-  KEY_identical* = 0x000008CF
-  KEY_radical* = 0x000008D6
-  KEY_includedin* = 0x000008DA
-  KEY_includes* = 0x000008DB
-  KEY_intersection* = 0x000008DC
-  KEY_union* = 0x000008DD
-  KEY_logicaland* = 0x000008DE
-  KEY_logicalor* = 0x000008DF
-  KEY_partialderivative* = 0x000008EF
-  KEY_function* = 0x000008F6
-  KEY_leftarrow* = 0x000008FB
-  KEY_uparrow* = 0x000008FC
-  KEY_rightarrow* = 0x000008FD
-  KEY_downarrow* = 0x000008FE
-  KEY_blank* = 0x000009DF
-  KEY_soliddiamond* = 0x000009E0
-  KEY_checkerboard* = 0x000009E1
-  KEY_ht* = 0x000009E2
-  KEY_ff* = 0x000009E3
-  KEY_cr* = 0x000009E4
-  KEY_lf* = 0x000009E5
-  KEY_nl* = 0x000009E8
-  KEY_vt* = 0x000009E9
-  KEY_lowrightcorner* = 0x000009EA
-  KEY_uprightcorner* = 0x000009EB
-  KEY_upleftcorner* = 0x000009EC
-  KEY_lowleftcorner* = 0x000009ED
-  KEY_crossinglines* = 0x000009EE
-  KEY_horizlinescan1* = 0x000009EF
-  KEY_horizlinescan3* = 0x000009F0
-  KEY_horizlinescan5* = 0x000009F1
-  KEY_horizlinescan7* = 0x000009F2
-  KEY_horizlinescan9* = 0x000009F3
-  KEY_leftt* = 0x000009F4
-  KEY_rightt* = 0x000009F5
-  KEY_bott* = 0x000009F6
-  KEY_topt* = 0x000009F7
-  KEY_vertbar* = 0x000009F8
-  KEY_emspace* = 0x00000AA1
-  KEY_enspace* = 0x00000AA2
-  KEY_em3space* = 0x00000AA3
-  KEY_em4space* = 0x00000AA4
-  KEY_digitspace* = 0x00000AA5
-  KEY_punctspace* = 0x00000AA6
-  KEY_thinspace* = 0x00000AA7
-  KEY_hairspace* = 0x00000AA8
-  KEY_emdash* = 0x00000AA9
-  KEY_endash* = 0x00000AAA
-  KEY_signifblank* = 0x00000AAC
-  KEY_ellipsis* = 0x00000AAE
-  KEY_doubbaselinedot* = 0x00000AAF
-  KEY_onethird* = 0x00000AB0
-  KEY_twothirds* = 0x00000AB1
-  KEY_onefifth* = 0x00000AB2
-  KEY_twofifths* = 0x00000AB3
-  KEY_threefifths* = 0x00000AB4
-  KEY_fourfifths* = 0x00000AB5
-  KEY_onesixth* = 0x00000AB6
-  KEY_fivesixths* = 0x00000AB7
-  KEY_careof* = 0x00000AB8
-  KEY_figdash* = 0x00000ABB
-  KEY_leftanglebracket* = 0x00000ABC
-  KEY_decimalpoint* = 0x00000ABD
-  KEY_rightanglebracket* = 0x00000ABE
-  KEY_marker* = 0x00000ABF
-  KEY_oneeighth* = 0x00000AC3
-  KEY_threeeighths* = 0x00000AC4
-  KEY_fiveeighths* = 0x00000AC5
-  KEY_seveneighths* = 0x00000AC6
-  KEY_trademark* = 0x00000AC9
-  KEY_signaturemark* = 0x00000ACA
-  KEY_trademarkincircle* = 0x00000ACB
-  KEY_leftopentriangle* = 0x00000ACC
-  KEY_rightopentriangle* = 0x00000ACD
-  KEY_emopencircle* = 0x00000ACE
-  KEY_emopenrectangle* = 0x00000ACF
-  KEY_leftsinglequotemark* = 0x00000AD0
-  KEY_rightsinglequotemark* = 0x00000AD1
-  KEY_leftdoublequotemark* = 0x00000AD2
-  KEY_rightdoublequotemark* = 0x00000AD3
-  KEY_prescription* = 0x00000AD4
-  KEY_minutes* = 0x00000AD6
-  KEY_seconds* = 0x00000AD7
-  KEY_latincross* = 0x00000AD9
-  KEY_hexagram* = 0x00000ADA
-  KEY_filledrectbullet* = 0x00000ADB
-  KEY_filledlefttribullet* = 0x00000ADC
-  KEY_filledrighttribullet* = 0x00000ADD
-  KEY_emfilledcircle* = 0x00000ADE
-  KEY_emfilledrect* = 0x00000ADF
-  KEY_enopencircbullet* = 0x00000AE0
-  KEY_enopensquarebullet* = 0x00000AE1
-  KEY_openrectbullet* = 0x00000AE2
-  KEY_opentribulletup* = 0x00000AE3
-  KEY_opentribulletdown* = 0x00000AE4
-  KEY_openstar* = 0x00000AE5
-  KEY_enfilledcircbullet* = 0x00000AE6
-  KEY_enfilledsqbullet* = 0x00000AE7
-  KEY_filledtribulletup* = 0x00000AE8
-  KEY_filledtribulletdown* = 0x00000AE9
-  KEY_leftpointer* = 0x00000AEA
-  KEY_rightpointer* = 0x00000AEB
-  KEY_club* = 0x00000AEC
-  KEY_diamond* = 0x00000AED
-  KEY_heart* = 0x00000AEE
-  KEY_maltesecross* = 0x00000AF0
-  KEY_dagger* = 0x00000AF1
-  KEY_doubledagger* = 0x00000AF2
-  KEY_checkmark* = 0x00000AF3
-  KEY_ballotcross* = 0x00000AF4
-  KEY_musicalsharp* = 0x00000AF5
-  KEY_musicalflat* = 0x00000AF6
-  KEY_malesymbol* = 0x00000AF7
-  KEY_femalesymbol* = 0x00000AF8
-  KEY_telephone* = 0x00000AF9
-  KEY_telephonerecorder* = 0x00000AFA
-  KEY_phonographcopyright* = 0x00000AFB
-  KEY_caret* = 0x00000AFC
-  KEY_singlelowquotemark* = 0x00000AFD
-  KEY_doublelowquotemark* = 0x00000AFE
-  KEY_cursor* = 0x00000AFF
-  KEY_leftcaret* = 0x00000BA3
-  KEY_rightcaret* = 0x00000BA6
-  KEY_downcaret* = 0x00000BA8
-  KEY_upcaret* = 0x00000BA9
-  KEY_overbar* = 0x00000BC0
-  KEY_downtack* = 0x00000BC2
-  KEY_upshoe* = 0x00000BC3
-  KEY_downstile* = 0x00000BC4
-  KEY_underbar* = 0x00000BC6
-  KEY_jot* = 0x00000BCA
-  KEY_quad* = 0x00000BCC
-  KEY_uptack* = 0x00000BCE
-  KEY_circle* = 0x00000BCF
-  KEY_upstile* = 0x00000BD3
-  KEY_downshoe* = 0x00000BD6
-  KEY_rightshoe* = 0x00000BD8
-  KEY_leftshoe* = 0x00000BDA
-  KEY_lefttack* = 0x00000BDC
-  KEY_righttack* = 0x00000BFC
-  KEY_hebrew_doublelowline* = 0x00000CDF
-  KEY_hebrew_aleph* = 0x00000CE0
-  KEY_hebrew_bet* = 0x00000CE1
-  KEY_hebrew_beth* = 0x00000CE1
-  KEY_hebrew_gimel* = 0x00000CE2
-  KEY_hebrew_gimmel* = 0x00000CE2
-  KEY_hebrew_dalet* = 0x00000CE3
-  KEY_hebrew_daleth* = 0x00000CE3
-  KEY_hebrew_he* = 0x00000CE4
-  KEY_hebrew_waw* = 0x00000CE5
-  KEY_hebrew_zain* = 0x00000CE6
-  KEY_hebrew_zayin* = 0x00000CE6
-  KEY_hebrew_chet* = 0x00000CE7
-  KEY_hebrew_het* = 0x00000CE7
-  KEY_hebrew_tet* = 0x00000CE8
-  KEY_hebrew_teth* = 0x00000CE8
-  KEY_hebrew_yod* = 0x00000CE9
-  KEY_hebrew_finalkaph* = 0x00000CEA
-  KEY_hebrew_kaph* = 0x00000CEB
-  KEY_hebrew_lamed* = 0x00000CEC
-  KEY_hebrew_finalmem* = 0x00000CED
-  KEY_hebrew_mem* = 0x00000CEE
-  KEY_hebrew_finalnun* = 0x00000CEF
-  KEY_hebrew_nun* = 0x00000CF0
-  KEY_hebrew_samech* = 0x00000CF1
-  KEY_hebrew_samekh* = 0x00000CF1
-  KEY_hebrew_ayin* = 0x00000CF2
-  KEY_hebrew_finalpe* = 0x00000CF3
-  KEY_hebrew_pe* = 0x00000CF4
-  KEY_hebrew_finalzade* = 0x00000CF5
-  KEY_hebrew_finalzadi* = 0x00000CF5
-  KEY_hebrew_zade* = 0x00000CF6
-  KEY_hebrew_zadi* = 0x00000CF6
-  KEY_hebrew_qoph* = 0x00000CF7
-  KEY_hebrew_kuf* = 0x00000CF7
-  KEY_hebrew_resh* = 0x00000CF8
-  KEY_hebrew_shin* = 0x00000CF9
-  KEY_hebrew_taw* = 0x00000CFA
-  KEY_hebrew_taf* = 0x00000CFA
-  KEY_Hebrew_switch* = 0x0000FF7E
-  KEY_Thai_kokai* = 0x00000DA1
-  KEY_Thai_khokhai* = 0x00000DA2
-  KEY_Thai_khokhuat* = 0x00000DA3
-  KEY_Thai_khokhwai* = 0x00000DA4
-  KEY_Thai_khokhon* = 0x00000DA5
-  KEY_Thai_khorakhang* = 0x00000DA6
-  KEY_Thai_ngongu* = 0x00000DA7
-  KEY_Thai_chochan* = 0x00000DA8
-  KEY_Thai_choching* = 0x00000DA9
-  KEY_Thai_chochang* = 0x00000DAA
-  KEY_Thai_soso* = 0x00000DAB
-  KEY_Thai_chochoe* = 0x00000DAC
-  KEY_Thai_yoying* = 0x00000DAD
-  KEY_Thai_dochada* = 0x00000DAE
-  KEY_Thai_topatak* = 0x00000DAF
-  KEY_Thai_thothan* = 0x00000DB0
-  KEY_Thai_thonangmontho* = 0x00000DB1
-  KEY_Thai_thophuthao* = 0x00000DB2
-  KEY_Thai_nonen* = 0x00000DB3
-  KEY_Thai_dodek* = 0x00000DB4
-  KEY_Thai_totao* = 0x00000DB5
-  KEY_Thai_thothung* = 0x00000DB6
-  KEY_Thai_thothahan* = 0x00000DB7
-  KEY_Thai_thothong* = 0x00000DB8
-  KEY_Thai_nonu* = 0x00000DB9
-  KEY_Thai_bobaimai* = 0x00000DBA
-  KEY_Thai_popla* = 0x00000DBB
-  KEY_Thai_phophung* = 0x00000DBC
-  KEY_Thai_fofa* = 0x00000DBD
-  KEY_Thai_phophan* = 0x00000DBE
-  KEY_Thai_fofan* = 0x00000DBF
-  KEY_Thai_phosamphao* = 0x00000DC0
-  KEY_Thai_moma* = 0x00000DC1
-  KEY_Thai_yoyak* = 0x00000DC2
-  KEY_Thai_rorua* = 0x00000DC3
-  KEY_Thai_ru* = 0x00000DC4
-  KEY_Thai_loling* = 0x00000DC5
-  KEY_Thai_lu* = 0x00000DC6
-  KEY_Thai_wowaen* = 0x00000DC7
-  KEY_Thai_sosala* = 0x00000DC8
-  KEY_Thai_sorusi* = 0x00000DC9
-  KEY_Thai_sosua* = 0x00000DCA
-  KEY_Thai_hohip* = 0x00000DCB
-  KEY_Thai_lochula* = 0x00000DCC
-  KEY_Thai_oang* = 0x00000DCD
-  KEY_Thai_honokhuk* = 0x00000DCE
-  KEY_Thai_paiyannoi* = 0x00000DCF
-  KEY_Thai_saraa* = 0x00000DD0
-  KEY_Thai_maihanakat* = 0x00000DD1
-  KEY_Thai_saraaa* = 0x00000DD2
-  KEY_Thai_saraam* = 0x00000DD3
-  KEY_Thai_sarai* = 0x00000DD4
-  KEY_Thai_saraii* = 0x00000DD5
-  KEY_Thai_saraue* = 0x00000DD6
-  KEY_Thai_sarauee* = 0x00000DD7
-  KEY_Thai_sarau* = 0x00000DD8
-  KEY_Thai_sarauu* = 0x00000DD9
-  KEY_Thai_phinthu* = 0x00000DDA
-  KEY_Thai_maihanakat_maitho* = 0x00000DDE
-  KEY_Thai_baht* = 0x00000DDF
-  KEY_Thai_sarae* = 0x00000DE0
-  KEY_Thai_saraae* = 0x00000DE1
-  KEY_Thai_sarao* = 0x00000DE2
-  KEY_Thai_saraaimaimuan* = 0x00000DE3
-  KEY_Thai_saraaimaimalai* = 0x00000DE4
-  KEY_Thai_lakkhangyao* = 0x00000DE5
-  KEY_Thai_maiyamok* = 0x00000DE6
-  KEY_Thai_maitaikhu* = 0x00000DE7
-  KEY_Thai_maiek* = 0x00000DE8
-  KEY_Thai_maitho* = 0x00000DE9
-  KEY_Thai_maitri* = 0x00000DEA
-  KEY_Thai_maichattawa* = 0x00000DEB
-  KEY_Thai_thanthakhat* = 0x00000DEC
-  KEY_Thai_nikhahit* = 0x00000DED
-  KEY_Thai_leksun* = 0x00000DF0
-  KEY_Thai_leknung* = 0x00000DF1
-  KEY_Thai_leksong* = 0x00000DF2
-  KEY_Thai_leksam* = 0x00000DF3
-  KEY_Thai_leksi* = 0x00000DF4
-  KEY_Thai_lekha* = 0x00000DF5
-  KEY_Thai_lekhok* = 0x00000DF6
-  KEY_Thai_lekchet* = 0x00000DF7
-  KEY_Thai_lekpaet* = 0x00000DF8
-  KEY_Thai_lekkao* = 0x00000DF9
-  KEY_Hangul* = 0x0000FF31
-  KEY_Hangul_Start* = 0x0000FF32
-  KEY_Hangul_End* = 0x0000FF33
-  KEY_Hangul_Hanja* = 0x0000FF34
-  KEY_Hangul_Jamo* = 0x0000FF35
-  KEY_Hangul_Romaja* = 0x0000FF36
-  KEY_Hangul_Codeinput* = 0x0000FF37
-  KEY_Hangul_Jeonja* = 0x0000FF38
-  KEY_Hangul_Banja* = 0x0000FF39
-  KEY_Hangul_PreHanja* = 0x0000FF3A
-  KEY_Hangul_PostHanja* = 0x0000FF3B
-  KEY_Hangul_SingleCandidate* = 0x0000FF3C
-  KEY_Hangul_MultipleCandidate* = 0x0000FF3D
-  KEY_Hangul_PreviousCandidate* = 0x0000FF3E
-  KEY_Hangul_Special* = 0x0000FF3F
-  KEY_Hangul_switch* = 0x0000FF7E
-  KEY_Hangul_Kiyeog* = 0x00000EA1
-  KEY_Hangul_SsangKiyeog* = 0x00000EA2
-  KEY_Hangul_KiyeogSios* = 0x00000EA3
-  KEY_Hangul_Nieun* = 0x00000EA4
-  KEY_Hangul_NieunJieuj* = 0x00000EA5
-  KEY_Hangul_NieunHieuh* = 0x00000EA6
-  KEY_Hangul_Dikeud* = 0x00000EA7
-  KEY_Hangul_SsangDikeud* = 0x00000EA8
-  KEY_Hangul_Rieul* = 0x00000EA9
-  KEY_Hangul_RieulKiyeog* = 0x00000EAA
-  KEY_Hangul_RieulMieum* = 0x00000EAB
-  KEY_Hangul_RieulPieub* = 0x00000EAC
-  KEY_Hangul_RieulSios* = 0x00000EAD
-  KEY_Hangul_RieulTieut* = 0x00000EAE
-  KEY_Hangul_RieulPhieuf* = 0x00000EAF
-  KEY_Hangul_RieulHieuh* = 0x00000EB0
-  KEY_Hangul_Mieum* = 0x00000EB1
-  KEY_Hangul_Pieub* = 0x00000EB2
-  KEY_Hangul_SsangPieub* = 0x00000EB3
-  KEY_Hangul_PieubSios* = 0x00000EB4
-  KEY_Hangul_Sios* = 0x00000EB5
-  KEY_Hangul_SsangSios* = 0x00000EB6
-  KEY_Hangul_Ieung* = 0x00000EB7
-  KEY_Hangul_Jieuj* = 0x00000EB8
-  KEY_Hangul_SsangJieuj* = 0x00000EB9
-  KEY_Hangul_Cieuc* = 0x00000EBA
-  KEY_Hangul_Khieuq* = 0x00000EBB
-  KEY_Hangul_Tieut* = 0x00000EBC
-  KEY_Hangul_Phieuf* = 0x00000EBD
-  KEY_Hangul_Hieuh* = 0x00000EBE
-  KEY_Hangul_A* = 0x00000EBF
-  KEY_Hangul_AE* = 0x00000EC0
-  KEY_Hangul_YA* = 0x00000EC1
-  KEY_Hangul_YAE* = 0x00000EC2
-  KEY_Hangul_EO* = 0x00000EC3
-  KEY_Hangul_E* = 0x00000EC4
-  KEY_Hangul_YEO* = 0x00000EC5
-  KEY_Hangul_YE* = 0x00000EC6
-  KEY_Hangul_O* = 0x00000EC7
-  KEY_Hangul_WA* = 0x00000EC8
-  KEY_Hangul_WAE* = 0x00000EC9
-  KEY_Hangul_OE* = 0x00000ECA
-  KEY_Hangul_YO* = 0x00000ECB
-  KEY_Hangul_U* = 0x00000ECC
-  KEY_Hangul_WEO* = 0x00000ECD
-  KEY_Hangul_WE* = 0x00000ECE
-  KEY_Hangul_WI* = 0x00000ECF
-  KEY_Hangul_YU* = 0x00000ED0
-  KEY_Hangul_EU* = 0x00000ED1
-  KEY_Hangul_YI* = 0x00000ED2
-  KEY_Hangul_I* = 0x00000ED3
-  KEY_Hangul_J_Kiyeog* = 0x00000ED4
-  KEY_Hangul_J_SsangKiyeog* = 0x00000ED5
-  KEY_Hangul_J_KiyeogSios* = 0x00000ED6
-  KEY_Hangul_J_Nieun* = 0x00000ED7
-  KEY_Hangul_J_NieunJieuj* = 0x00000ED8
-  KEY_Hangul_J_NieunHieuh* = 0x00000ED9
-  KEY_Hangul_J_Dikeud* = 0x00000EDA
-  KEY_Hangul_J_Rieul* = 0x00000EDB
-  KEY_Hangul_J_RieulKiyeog* = 0x00000EDC
-  KEY_Hangul_J_RieulMieum* = 0x00000EDD
-  KEY_Hangul_J_RieulPieub* = 0x00000EDE
-  KEY_Hangul_J_RieulSios* = 0x00000EDF
-  KEY_Hangul_J_RieulTieut* = 0x00000EE0
-  KEY_Hangul_J_RieulPhieuf* = 0x00000EE1
-  KEY_Hangul_J_RieulHieuh* = 0x00000EE2
-  KEY_Hangul_J_Mieum* = 0x00000EE3
-  KEY_Hangul_J_Pieub* = 0x00000EE4
-  KEY_Hangul_J_PieubSios* = 0x00000EE5
-  KEY_Hangul_J_Sios* = 0x00000EE6
-  KEY_Hangul_J_SsangSios* = 0x00000EE7
-  KEY_Hangul_J_Ieung* = 0x00000EE8
-  KEY_Hangul_J_Jieuj* = 0x00000EE9
-  KEY_Hangul_J_Cieuc* = 0x00000EEA
-  KEY_Hangul_J_Khieuq* = 0x00000EEB
-  KEY_Hangul_J_Tieut* = 0x00000EEC
-  KEY_Hangul_J_Phieuf* = 0x00000EED
-  KEY_Hangul_J_Hieuh* = 0x00000EEE
-  KEY_Hangul_RieulYeorinHieuh* = 0x00000EEF
-  KEY_Hangul_SunkyeongeumMieum* = 0x00000EF0
-  KEY_Hangul_SunkyeongeumPieub* = 0x00000EF1
-  KEY_Hangul_PanSios* = 0x00000EF2
-  KEY_Hangul_KkogjiDalrinIeung* = 0x00000EF3
-  KEY_Hangul_SunkyeongeumPhieuf* = 0x00000EF4
-  KEY_Hangul_YeorinHieuh* = 0x00000EF5
-  KEY_Hangul_AraeA* = 0x00000EF6
-  KEY_Hangul_AraeAE* = 0x00000EF7
-  KEY_Hangul_J_PanSios* = 0x00000EF8
-  KEY_Hangul_J_KkogjiDalrinIeung* = 0x00000EF9
-  KEY_Hangul_J_YeorinHieuh* = 0x00000EFA
-  KEY_Korean_Won* = 0x00000EFF
-  KEY_EcuSign* = 0x000020A0
-  KEY_ColonSign* = 0x000020A1
-  KEY_CruzeiroSign* = 0x000020A2
-  KEY_FFrancSign* = 0x000020A3
-  KEY_LiraSign* = 0x000020A4
-  KEY_MillSign* = 0x000020A5
-  KEY_NairaSign* = 0x000020A6
-  KEY_PesetaSign* = 0x000020A7
-  KEY_RupeeSign* = 0x000020A8
-  KEY_WonSign* = 0x000020A9
-  KEY_NewSheqelSign* = 0x000020AA
-  KEY_DongSign* = 0x000020AB
-  KEY_EuroSign* = 0x000020AC
-
-proc pango_context_get_for_screen*(screen: PScreen): PContext{.cdecl, 
-    dynlib: lib, importc: "gdk_pango_context_get_for_screen".}
-proc pango_context_set_colormap*(context: PContext, colormap: PColormap){.
-    cdecl, dynlib: lib, importc: "gdk_pango_context_set_colormap".}
-proc pango_layout_line_get_clip_region*(line: PLayoutLine, x_origin: gint, 
-                                        y_origin: gint, index_ranges: Pgint, 
-                                        n_ranges: gint): PRegion{.cdecl, 
-    dynlib: lib, importc: "gdk_pango_layout_line_get_clip_region".}
-proc pango_layout_get_clip_region*(layout: PLayout, x_origin: gint, 
-                                   y_origin: gint, index_ranges: Pgint, 
-                                   n_ranges: gint): PRegion{.cdecl, dynlib: lib, 
-    importc: "gdk_pango_layout_get_clip_region".}
-proc pango_attr_stipple_new*(stipple: PBitmap): PAttribute{.cdecl, 
-    dynlib: lib, importc: "gdk_pango_attr_stipple_new".}
-proc pango_attr_embossed_new*(embossed: gboolean): PAttribute{.cdecl, 
-    dynlib: lib, importc: "gdk_pango_attr_embossed_new".}
-proc render_threshold_alpha*(pixbuf: PPixbuf, bitmap: PBitmap, 
-                                    src_x: int32, src_y: int32, dest_x: int32, 
-                                    dest_y: int32, width: int32, height: int32, 
-                                    alpha_threshold: int32){.cdecl, dynlib: lib, 
-    importc: "gdk_pixbuf_render_threshold_alpha".}
-proc render_to_drawable*(pixbuf: PPixbuf, drawable: PDrawable, gc: PGC, 
-                                src_x: int32, src_y: int32, dest_x: int32, 
-                                dest_y: int32, width: int32, height: int32, 
-                                dither: TRgbDither, x_dither: int32, 
-                                y_dither: int32){.cdecl, dynlib: lib, 
-    importc: "gdk_pixbuf_render_to_drawable".}
-proc render_to_drawable_alpha*(pixbuf: PPixbuf, drawable: PDrawable, 
-                                      src_x: int32, src_y: int32, dest_x: int32, 
-                                      dest_y: int32, width: int32, 
-                                      height: int32, 
-                                      alpha_mode: TPixbufAlphaMode, 
-                                      alpha_threshold: int32, 
-                                      dither: TRgbDither, x_dither: int32, 
-                                      y_dither: int32){.cdecl, dynlib: lib, 
-    importc: "gdk_pixbuf_render_to_drawable_alpha".}
-proc render_pixmap_and_mask_for_colormap*(pixbuf: PPixbuf, 
-    colormap: PColormap, n: var PPixmap, nasdfdsafw4e: var PBitmap, 
-    alpha_threshold: int32){.cdecl, dynlib: lib, importc: "gdk_pixbuf_render_pixmap_and_mask_for_colormap".}
-proc get_from_drawable*(dest: PPixbuf, src: PDrawable, cmap: PColormap, 
-                               src_x: int32, src_y: int32, dest_x: int32, 
-                               dest_y: int32, width: int32, height: int32): PPixbuf{.
-    cdecl, dynlib: lib, importc: "gdk_pixbuf_get_from_drawable".}
-proc get_from_image*(dest: PPixbuf, src: PImage, cmap: PColormap, 
-                            src_x: int32, src_y: int32, dest_x: int32, 
-                            dest_y: int32, width: int32, height: int32): PPixbuf{.
-    cdecl, dynlib: lib, importc: "gdk_pixbuf_get_from_image".}
-proc TYPE_PIXMAP*(): GType
-proc PIXMAP*(anObject: Pointer): PPixmap
-proc PIXMAP_CLASS*(klass: Pointer): PPixmapObjectClass
-proc IS_PIXMAP*(anObject: Pointer): bool
-proc IS_PIXMAP_CLASS*(klass: Pointer): bool
-proc PIXMAP_GET_CLASS*(obj: Pointer): PPixmapObjectClass
-proc PIXMAP_OBJECT*(anObject: Pointer): PPixmapObject
-proc pixmap_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gdk_pixmap_get_type".}
-proc pixmap_new*(window: PWindow, width: gint, height: gint, depth: gint): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_new".}
-proc bitmap_create_from_data*(window: PWindow, data: cstring, width: gint, 
-                              height: gint): PBitmap{.cdecl, dynlib: lib, 
-    importc: "gdk_bitmap_create_from_data".}
-proc pixmap_create_from_data*(window: PWindow, data: cstring, width: gint, 
-                              height: gint, depth: gint, fg: PColor, bg: PColor): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_create_from_data".}
-proc pixmap_create_from_xpm*(window: PWindow, k: var PBitmap, 
-                             transparent_color: PColor, filename: cstring): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_create_from_xpm".}
-proc pixmap_colormap_create_from_xpm*(window: PWindow, colormap: PColormap, 
-                                      k: var PBitmap, transparent_color: PColor, 
-                                      filename: cstring): PPixmap{.cdecl, 
-    dynlib: lib, importc: "gdk_pixmap_colormap_create_from_xpm".}
-proc pixmap_create_from_xpm_d*(window: PWindow, k: var PBitmap, 
-                               transparent_color: PColor, data: PPgchar): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_create_from_xpm_d".}
-proc pixmap_colormap_create_from_xpm_d*(window: PWindow, colormap: PColormap, 
-                                        k: var PBitmap, 
-                                        transparent_color: PColor, data: PPgchar): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_colormap_create_from_xpm_d".}
-proc pixmap_foreign_new_for_display*(display: PDisplay, anid: TNativeWindow): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_foreign_new_for_display".}
-proc pixmap_lookup_for_display*(display: PDisplay, anid: TNativeWindow): PPixmap{.
-    cdecl, dynlib: lib, importc: "gdk_pixmap_lookup_for_display".}
-proc atom_intern*(atom_name: cstring, only_if_exists: gboolean): TAtom{.cdecl, 
-    dynlib: lib, importc: "gdk_atom_intern".}
-proc atom_name*(atom: TAtom): cstring{.cdecl, dynlib: lib, 
-                                       importc: "gdk_atom_name".}
-proc property_get*(window: PWindow, `property`: TAtom, `type`: TAtom, 
-                   offset: gulong, length: gulong, pdelete: gint, 
-                   actual_property_type: PAtom, actual_format: Pgint, 
-                   actual_length: Pgint, data: PPguchar): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_property_get".}
-proc property_change*(window: PWindow, `property`: TAtom, `type`: TAtom, 
-                      format: gint, mode: TPropMode, data: Pguchar, 
-                      nelements: gint){.cdecl, dynlib: lib, 
-                                        importc: "gdk_property_change".}
-proc property_delete*(window: PWindow, `property`: TAtom){.cdecl, dynlib: lib, 
-    importc: "gdk_property_delete".}
-proc text_property_to_text_list_for_display*(display: PDisplay, encoding: TAtom, 
-    format: gint, text: Pguchar, length: gint, t: var PPgchar): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_property_to_text_list_for_display".}
-proc text_property_to_utf8_list_for_display*(display: PDisplay, encoding: TAtom, 
-    format: gint, text: Pguchar, length: gint, t: var PPgchar): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_text_property_to_utf8_list_for_display".}
-proc utf8_to_string_target*(str: cstring): cstring{.cdecl, dynlib: lib, 
-    importc: "gdk_utf8_to_string_target".}
-proc string_to_compound_text_for_display*(display: PDisplay, str: cstring, 
-    encoding: PAtom, format: Pgint, ctext: PPguchar, length: Pgint): gint{.
-    cdecl, dynlib: lib, importc: "gdk_string_to_compound_text_for_display".}
-proc utf8_to_compound_text_for_display*(display: PDisplay, str: cstring, 
-                                        encoding: PAtom, format: Pgint, 
-                                        ctext: PPguchar, length: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_utf8_to_compound_text_for_display".}
-proc free_text_list*(list: PPgchar){.cdecl, dynlib: lib, 
-                                     importc: "gdk_free_text_list".}
-proc free_compound_text*(ctext: Pguchar){.cdecl, dynlib: lib, 
-    importc: "gdk_free_compound_text".}
-proc region_new*(): PRegion{.cdecl, dynlib: lib, importc: "gdk_region_new".}
-proc region_polygon*(points: PPoint, npoints: gint, fill_rule: TFillRule): PRegion{.
-    cdecl, dynlib: lib, importc: "gdk_region_polygon".}
-proc copy*(region: PRegion): PRegion{.cdecl, dynlib: lib, 
-    importc: "gdk_region_copy".}
-proc region_rectangle*(rectangle: PRectangle): PRegion{.cdecl, dynlib: lib, 
-    importc: "gdk_region_rectangle".}
-proc destroy*(region: PRegion){.cdecl, dynlib: lib, 
-                                       importc: "gdk_region_destroy".}
-proc get_clipbox*(region: PRegion, rectangle: PRectangle){.cdecl, 
-    dynlib: lib, importc: "gdk_region_get_clipbox".}
-proc get_rectangles*(region: PRegion, s: var PRectangle, 
-                            n_rectangles: Pgint){.cdecl, dynlib: lib, 
-    importc: "gdk_region_get_rectangles".}
-proc empty*(region: PRegion): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_region_empty".}
-proc equal*(region1: PRegion, region2: PRegion): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_region_equal".}
-proc point_in*(region: PRegion, x: int32, y: int32): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_region_point_in".}
-proc rect_in*(region: PRegion, rect: PRectangle): TOverlapType{.cdecl, 
-    dynlib: lib, importc: "gdk_region_rect_in".}
-proc offset*(region: PRegion, dx: gint, dy: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_region_offset".}
-proc shrink*(region: PRegion, dx: gint, dy: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_region_shrink".}
-proc union*(region: PRegion, rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "gdk_region_union_with_rect".}
-proc intersect*(source1: PRegion, source2: PRegion){.cdecl, dynlib: lib, 
-    importc: "gdk_region_intersect".}
-proc union*(source1: PRegion, source2: PRegion){.cdecl, dynlib: lib, 
-    importc: "gdk_region_union".}
-proc subtract*(source1: PRegion, source2: PRegion){.cdecl, dynlib: lib, 
-    importc: "gdk_region_subtract".}
-proc `xor`*(source1: PRegion, source2: PRegion){.cdecl, dynlib: lib, 
-    importc: "gdk_region_xor".}
-proc spans_intersect_foreach*(region: PRegion, spans: PSpan, 
-                                     n_spans: int32, sorted: gboolean, 
-                                     `function`: TSpanFunc, data: gpointer){.
-    cdecl, dynlib: lib, importc: "gdk_region_spans_intersect_foreach".}
-proc rgb_find_color*(colormap: PColormap, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_rgb_find_color".}
-proc rgb_image*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                     width: gint, height: gint, dith: TRgbDither, 
-                     rgb_buf: Pguchar, rowstride: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_rgb_image".}
-proc rgb_image_dithalign*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                               width: gint, height: gint, dith: TRgbDither, 
-                               rgb_buf: Pguchar, rowstride: gint, xdith: gint, 
-                               ydith: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_rgb_image_dithalign".}
-proc rgb_32_image*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                        width: gint, height: gint, dith: TRgbDither, 
-                        buf: Pguchar, rowstride: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_draw_rgb_32_image".}
-proc rgb_32_image_dithalign*(drawable: PDrawable, gc: PGC, x: gint, 
-                                  y: gint, width: gint, height: gint, 
-                                  dith: TRgbDither, buf: Pguchar, 
-                                  rowstride: gint, xdith: gint, ydith: gint){.
-    cdecl, dynlib: lib, importc: "gdk_draw_rgb_32_image_dithalign".}
-proc gray_image*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                      width: gint, height: gint, dith: TRgbDither, buf: Pguchar, 
-                      rowstride: gint){.cdecl, dynlib: lib, 
-                                        importc: "gdk_draw_gray_image".}
-proc indexed_image*(drawable: PDrawable, gc: PGC, x: gint, y: gint, 
-                         width: gint, height: gint, dith: TRgbDither, 
-                         buf: Pguchar, rowstride: gint, cmap: PRgbCmap){.cdecl, 
-    dynlib: lib, importc: "gdk_draw_indexed_image".}
-proc rgb_cmap_new*(colors: Pguint32, n_colors: gint): PRgbCmap{.cdecl, 
-    dynlib: lib, importc: "gdk_rgb_cmap_new".}
-proc free*(cmap: PRgbCmap){.cdecl, dynlib: lib, 
-                                     importc: "gdk_rgb_cmap_free".}
-proc rgb_set_verbose*(verbose: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_rgb_set_verbose".}
-proc rgb_set_install*(install: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_rgb_set_install".}
-proc rgb_set_min_colors*(min_colors: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_rgb_set_min_colors".}
-proc TYPE_DISPLAY*(): GType
-proc DISPLAY_OBJECT*(anObject: pointer): PDisplay
-proc DISPLAY_CLASS*(klass: pointer): PDisplayClass
-proc IS_DISPLAY*(anObject: pointer): bool
-proc IS_DISPLAY_CLASS*(klass: pointer): bool
-proc DISPLAY_GET_CLASS*(obj: pointer): PDisplayClass
-proc display_open*(display_name: cstring): PDisplay{.cdecl, dynlib: lib, 
-    importc: "gdk_display_open".}
-proc get_name*(display: PDisplay): cstring{.cdecl, dynlib: lib, 
-    importc: "gdk_display_get_name".}
-proc get_n_screens*(display: PDisplay): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_display_get_n_screens".}
-proc get_screen*(display: PDisplay, screen_num: gint): PScreen{.cdecl, 
-    dynlib: lib, importc: "gdk_display_get_screen".}
-proc get_default_screen*(display: PDisplay): PScreen{.cdecl, 
-    dynlib: lib, importc: "gdk_display_get_default_screen".}
-proc pointer_ungrab*(display: PDisplay, time: guint32){.cdecl, 
-    dynlib: lib, importc: "gdk_display_pointer_ungrab".}
-proc keyboard_ungrab*(display: PDisplay, time: guint32){.cdecl, 
-    dynlib: lib, importc: "gdk_display_keyboard_ungrab".}
-proc pointer_is_grabbed*(display: PDisplay): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_display_pointer_is_grabbed".}
-proc beep*(display: PDisplay){.cdecl, dynlib: lib, 
-                                       importc: "gdk_display_beep".}
-proc sync*(display: PDisplay){.cdecl, dynlib: lib, 
-                                       importc: "gdk_display_sync".}
-proc close*(display: PDisplay){.cdecl, dynlib: lib, 
-                                        importc: "gdk_display_close".}
-proc list_devices*(display: PDisplay): PGList{.cdecl, dynlib: lib, 
-    importc: "gdk_display_list_devices".}
-proc get_event*(display: PDisplay): PEvent{.cdecl, dynlib: lib, 
-    importc: "gdk_display_get_event".}
-proc peek_event*(display: PDisplay): PEvent{.cdecl, dynlib: lib, 
-    importc: "gdk_display_peek_event".}
-proc put_event*(display: PDisplay, event: PEvent){.cdecl, dynlib: lib, 
-    importc: "gdk_display_put_event".}
-proc add_client_message_filter*(display: PDisplay, message_type: TAtom, 
-                                        func: TFilterFunc, data: gpointer){.
-    cdecl, dynlib: lib, importc: "gdk_display_add_client_message_filter".}
-proc set_double_click_time*(display: PDisplay, msec: guint){.cdecl, 
-    dynlib: lib, importc: "gdk_display_set_double_click_time".}
-proc set_sm_client_id*(display: PDisplay, sm_client_id: cstring){.cdecl, 
-    dynlib: lib, importc: "gdk_display_set_sm_client_id".}
-proc set_default_display*(display: PDisplay){.cdecl, dynlib: lib, 
-    importc: "gdk_set_default_display".}
-proc get_default_display*(): PDisplay{.cdecl, dynlib: lib, 
-                                       importc: "gdk_get_default_display".}
-proc TYPE_SCREEN*(): GType
-proc SCREEN*(anObject: Pointer): PScreen
-proc SCREEN_CLASS*(klass: Pointer): PScreenClass
-proc IS_SCREEN*(anObject: Pointer): bool
-proc IS_SCREEN_CLASS*(klass: Pointer): bool
-proc SCREEN_GET_CLASS*(obj: Pointer): PScreenClass
-proc get_default_colormap*(screen: PScreen): PColormap{.cdecl, 
-    dynlib: lib, importc: "gdk_screen_get_default_colormap".}
-proc set_default_colormap*(screen: PScreen, colormap: PColormap){.cdecl, 
-    dynlib: lib, importc: "gdk_screen_set_default_colormap".}
-proc get_system_colormap*(screen: PScreen): PColormap{.cdecl, 
-    dynlib: lib, importc: "gdk_screen_get_system_colormap".}
-proc get_system_visual*(screen: PScreen): PVisual{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_system_visual".}
-proc get_rgb_colormap*(screen: PScreen): PColormap{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_rgb_colormap".}
-proc get_rgb_visual*(screen: PScreen): PVisual{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_rgb_visual".}
-proc get_root_window*(screen: PScreen): PWindow{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_root_window".}
-proc get_display*(screen: PScreen): PDisplay{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_display".}
-proc get_number*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_number".}
-proc get_window_at_pointer*(screen: PScreen, win_x: Pgint, win_y: Pgint): PWindow{.
-    cdecl, dynlib: lib, importc: "gdk_screen_get_window_at_pointer".}
-proc get_width*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_width".}
-proc get_height*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_height".}
-proc get_width_mm*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_width_mm".}
-proc get_height_mm*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_height_mm".}
-proc close*(screen: PScreen){.cdecl, dynlib: lib, 
-                                     importc: "gdk_screen_close".}
-proc list_visuals*(screen: PScreen): PGList{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_list_visuals".}
-proc get_toplevel_windows*(screen: PScreen): PGList{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_toplevel_windows".}
-proc get_n_monitors*(screen: PScreen): gint{.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_n_monitors".}
-proc get_monitor_geometry*(screen: PScreen, monitor_num: gint, 
-                                  dest: PRectangle){.cdecl, dynlib: lib, 
-    importc: "gdk_screen_get_monitor_geometry".}
-proc get_monitor_at_point*(screen: PScreen, x: gint, y: gint): gint{.
-    cdecl, dynlib: lib, importc: "gdk_screen_get_monitor_at_point".}
-proc get_monitor_at_window*(screen: PScreen, window: PWindow): gint{.
-    cdecl, dynlib: lib, importc: "gdk_screen_get_monitor_at_window".}
-proc broadcast_client_message*(screen: PScreen, event: PEvent){.cdecl, 
-    dynlib: lib, importc: "gdk_screen_broadcast_client_message".}
-proc get_default_screen*(): PScreen{.cdecl, dynlib: lib, 
-                                     importc: "gdk_get_default_screen".}
-proc get_setting*(screen: PScreen, name: cstring, value: PGValue): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_screen_get_setting".}
-proc SELECTION_PRIMARY*(): TAtom
-proc SELECTION_SECONDARY*(): TAtom
-proc SELECTION_CLIPBOARD*(): TAtom
-proc TARGET_BITMAP*(): TAtom
-proc TARGET_COLORMAP*(): TAtom
-proc TARGET_DRAWABLE*(): TAtom
-proc TARGET_PIXMAP*(): TAtom
-proc TARGET_STRING*(): TAtom
-proc SELECTION_TYPE_ATOM*(): TAtom
-proc SELECTION_TYPE_BITMAP*(): TAtom
-proc SELECTION_TYPE_COLORMAP*(): TAtom
-proc SELECTION_TYPE_DRAWABLE*(): TAtom
-proc SELECTION_TYPE_INTEGER*(): TAtom
-proc SELECTION_TYPE_PIXMAP*(): TAtom
-proc SELECTION_TYPE_WINDOW*(): TAtom
-proc SELECTION_TYPE_STRING*(): TAtom
-proc selection_owner_set_for_display*(display: PDisplay, owner: PWindow, 
-                                      selection: TAtom, time: guint32, 
-                                      send_event: gboolean): gboolean{.cdecl, 
-    dynlib: lib, importc: "gdk_selection_owner_set_for_display".}
-proc selection_owner_get_for_display*(display: PDisplay, selection: TAtom): PWindow{.
-    cdecl, dynlib: lib, importc: "gdk_selection_owner_get_for_display".}
-proc selection_convert*(requestor: PWindow, selection: TAtom, target: TAtom, 
-                        time: guint32){.cdecl, dynlib: lib, 
-                                        importc: "gdk_selection_convert".}
-proc selection_property_get*(requestor: PWindow, data: PPguchar, 
-                             prop_type: PAtom, prop_format: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_selection_property_get".}
-proc selection_send_notify_for_display*(display: PDisplay, requestor: guint32, 
-                                        selection: TAtom, target: TAtom, 
-                                        `property`: TAtom, time: guint32){.
-    cdecl, dynlib: lib, importc: "gdk_selection_send_notify_for_display".}
-const 
-  CURRENT_TIME* = 0
-  PARENT_RELATIVE* = 1
-  OK* = 0
-  ERROR* = - (1)
-  ERROR_PARAM* = - (2)
-  ERROR_FILE* = - (3)
-  ERROR_MEM* = - (4)
-  SHIFT_MASK* = 1 shl 0
-  LOCK_MASK* = 1 shl 1
-  CONTROL_MASK* = 1 shl 2
-  MOD1_MASK* = 1 shl 3
-  MOD2_MASK* = 1 shl 4
-  MOD3_MASK* = 1 shl 5
-  MOD4_MASK* = 1 shl 6
-  MOD5_MASK* = 1 shl 7
-  BUTTON1_MASK* = 1 shl 8
-  BUTTON2_MASK* = 1 shl 9
-  BUTTON3_MASK* = 1 shl 10
-  BUTTON4_MASK* = 1 shl 11
-  BUTTON5_MASK* = 1 shl 12
-  RELEASE_MASK* = 1 shl 30
-  MODIFIER_MASK* = ord(RELEASE_MASK) or 0x00001FFF
-  INPUT_READ* = 1 shl 0
-  INPUT_WRITE* = 1 shl 1
-  INPUT_EXCEPTION* = 1 shl 2
-  GRAB_SUCCESS* = 0
-  GRAB_ALREADY_GRABBED* = 1
-  GRAB_INVALID_TIME* = 2
-  GRAB_NOT_VIEWABLE* = 3
-  GRAB_FROZEN* = 4
-
-proc ATOM_TO_POINTER*(atom: TAtom): Pointer
-proc POINTER_TO_ATOM*(p: Pointer): TAtom
-proc `MAKE_ATOM`*(val: guint): TAtom
-proc NONE*(): TAtom
-proc TYPE_VISUAL*(): GType
-proc VISUAL*(anObject: Pointer): PVisual
-proc VISUAL_CLASS*(klass: Pointer): PVisualClass
-proc IS_VISUAL*(anObject: Pointer): bool
-proc IS_VISUAL_CLASS*(klass: Pointer): bool
-proc VISUAL_GET_CLASS*(obj: Pointer): PVisualClass
-proc visual_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gdk_visual_get_type".}
-const 
-  WA_TITLE* = 1 shl 1
-  WA_X* = 1 shl 2
-  WA_Y* = 1 shl 3
-  WA_CURSOR* = 1 shl 4
-  WA_COLORMAP* = 1 shl 5
-  WA_VISUAL* = 1 shl 6
-  WA_WMCLASS* = 1 shl 7
-  WA_NOREDIR* = 1 shl 8
-  HINT_POS* = 1 shl 0
-  HINT_MIN_SIZE* = 1 shl 1
-  HINT_MAX_SIZE* = 1 shl 2
-  HINT_BASE_SIZE* = 1 shl 3
-  HINT_ASPECT* = 1 shl 4
-  HINT_RESIZE_INC* = 1 shl 5
-  HINT_WIN_GRAVITY* = 1 shl 6
-  HINT_USER_POS* = 1 shl 7
-  HINT_USER_SIZE* = 1 shl 8
-  DECOR_ALL* = 1 shl 0
-  DECOR_BORDER* = 1 shl 1
-  DECOR_RESIZEH* = 1 shl 2
-  DECOR_TITLE* = 1 shl 3
-  DECOR_MENU* = 1 shl 4
-  DECOR_MINIMIZE* = 1 shl 5
-  DECOR_MAXIMIZE* = 1 shl 6
-  FUNC_ALL* = 1 shl 0
-  FUNC_RESIZE* = 1 shl 1
-  FUNC_MOVE* = 1 shl 2
-  FUNC_MINIMIZE* = 1 shl 3
-  FUNC_MAXIMIZE* = 1 shl 4
-  FUNC_CLOSE* = 1 shl 5
-  GRAVITY_NORTH_WEST* = 1
-  GRAVITY_NORTH* = 2
-  GRAVITY_NORTH_EAST* = 3
-  GRAVITY_WEST* = 4
-  GRAVITY_CENTER* = 5
-  GRAVITY_EAST* = 6
-  GRAVITY_SOUTH_WEST* = 7
-  GRAVITY_SOUTH* = 8
-  GRAVITY_SOUTH_EAST* = 9
-  GRAVITY_STATIC* = 10
-
-proc TYPE_WINDOW*(): GType
-proc WINDOW*(anObject: Pointer): PWindow
-proc WINDOW_CLASS*(klass: Pointer): PWindowObjectClass
-proc IS_WINDOW*(anObject: Pointer): bool
-proc IS_WINDOW_CLASS*(klass: Pointer): bool
-proc WINDOW_GET_CLASS*(obj: Pointer): PWindowObjectClass
-proc WINDOW_OBJECT*(anObject: Pointer): PWindowObject
-const 
-  bm_TWindowObject_guffaw_gravity* = 0x0001'i16
-  bp_TWindowObject_guffaw_gravity* = 0'i16
-  bm_TWindowObject_input_only* = 0x0002'i16
-  bp_TWindowObject_input_only* = 1'i16
-  bm_TWindowObject_modal_hint* = 0x0004'i16
-  bp_TWindowObject_modal_hint* = 2'i16
-  bm_TWindowObject_destroyed* = 0x0018'i16
-  bp_TWindowObject_destroyed* = 3'i16
-
-proc WindowObject_guffaw_gravity*(a: PWindowObject): guint
-proc WindowObject_set_guffaw_gravity*(a: PWindowObject, 
-                                      `guffaw_gravity`: guint)
-proc WindowObject_input_only*(a: PWindowObject): guint
-proc WindowObject_set_input_only*(a: PWindowObject, `input_only`: guint)
-proc WindowObject_modal_hint*(a: PWindowObject): guint
-proc WindowObject_set_modal_hint*(a: PWindowObject, `modal_hint`: guint)
-proc WindowObject_destroyed*(a: PWindowObject): guint
-proc WindowObject_set_destroyed*(a: PWindowObject, `destroyed`: guint)
-proc window_object_get_type*(): GType{.cdecl, dynlib: lib, 
-                                       importc: "gdk_window_object_get_type".}
-proc new*(parent: PWindow, attributes: PWindowAttr, attributes_mask: gint): PWindow{.
-    cdecl, dynlib: lib, importc: "gdk_window_new".}
-proc destroy*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gdk_window_destroy".}
-proc get_window_type*(window: PWindow): TWindowType{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_window_type".}
-proc window_at_pointer*(win_x: Pgint, win_y: Pgint): PWindow{.cdecl, 
-    dynlib: lib, importc: "gdk_window_at_pointer".}
-proc show*(window: PWindow){.cdecl, dynlib: lib, 
-                                    importc: "gdk_window_show".}
-proc hide*(window: PWindow){.cdecl, dynlib: lib, 
-                                    importc: "gdk_window_hide".}
-proc withdraw*(window: PWindow){.cdecl, dynlib: lib, 
-                                        importc: "gdk_window_withdraw".}
-proc show_unraised*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_show_unraised".}
-proc move*(window: PWindow, x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_window_move".}
-proc resize*(window: PWindow, width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_resize".}
-proc move_resize*(window: PWindow, x: gint, y: gint, width: gint, 
-                         height: gint){.cdecl, dynlib: lib, 
-                                        importc: "gdk_window_move_resize".}
-proc reparent*(window: PWindow, new_parent: PWindow, x: gint, y: gint){.
-    cdecl, dynlib: lib, importc: "gdk_window_reparent".}
-proc clear*(window: PWindow){.cdecl, dynlib: lib, 
-                                     importc: "gdk_window_clear".}
-proc clear_area*(window: PWindow, x: gint, y: gint, width: gint, 
-                        height: gint){.cdecl, dynlib: lib, 
-                                       importc: "gdk_window_clear_area".}
-proc clear_area_e*(window: PWindow, x: gint, y: gint, width: gint, 
-                          height: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_window_clear_area_e".}
-proc `raise`*(window: PWindow){.cdecl, dynlib: lib, 
-                                importc: "gdk_window_raise".}
-proc lower*(window: PWindow){.cdecl, dynlib: lib, 
-                                     importc: "gdk_window_lower".}
-proc focus*(window: PWindow, timestamp: guint32){.cdecl, dynlib: lib, 
-    importc: "gdk_window_focus".}
-proc set_user_data*(window: PWindow, user_data: gpointer){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_user_data".}
-proc set_override_redirect*(window: PWindow, override_redirect: gboolean){.
-    cdecl, dynlib: lib, importc: "gdk_window_set_override_redirect".}
-proc add_filter*(window: PWindow, `function`: TFilterFunc, data: gpointer){.
-    cdecl, dynlib: lib, importc: "gdk_window_add_filter".}
-proc remove_filter*(window: PWindow, `function`: TFilterFunc, 
-                           data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gdk_window_remove_filter".}
-proc scroll*(window: PWindow, dx: gint, dy: gint){.cdecl, dynlib: lib, 
-    importc: "gdk_window_scroll".}
-proc shape_combine_mask*(window: PWindow, mask: PBitmap, x: gint, y: gint){.
-    cdecl, dynlib: lib, importc: "gdk_window_shape_combine_mask".}
-proc shape_combine_region*(window: PWindow, shape_region: PRegion, 
-                                  offset_x: gint, offset_y: gint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_shape_combine_region".}
-proc set_child_shapes*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_child_shapes".}
-proc merge_child_shapes*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_merge_child_shapes".}
-proc is_visible*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_window_is_visible".}
-proc is_viewable*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_window_is_viewable".}
-proc get_state*(window: PWindow): TWindowState{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_state".}
-proc set_static_gravities*(window: PWindow, use_static: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_window_set_static_gravities".}
-proc window_foreign_new_for_display*(display: PDisplay, anid: TNativeWindow): PWindow{.
-    cdecl, dynlib: lib, importc: "gdk_window_foreign_new_for_display".}
-proc window_lookup_for_display*(display: PDisplay, anid: TNativeWindow): PWindow{.
-    cdecl, dynlib: lib, importc: "gdk_window_lookup_for_display".}
-proc set_type_hint*(window: PWindow, hint: TWindowTypeHint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_type_hint".}
-proc set_modal_hint*(window: PWindow, modal: gboolean){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_modal_hint".}
-proc set_geometry_hints*(window: PWindow, geometry: PGeometry, 
-                                geom_mask: TWindowHints){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_geometry_hints".}
-proc set_sm_client_id*(sm_client_id: cstring){.cdecl, dynlib: lib, 
-    importc: "gdk_set_sm_client_id".}
-proc begin_paint_rect*(window: PWindow, rectangle: PRectangle){.cdecl, 
-    dynlib: lib, importc: "gdk_window_begin_paint_rect".}
-proc begin_paint_region*(window: PWindow, region: PRegion){.cdecl, 
-    dynlib: lib, importc: "gdk_window_begin_paint_region".}
-proc end_paint*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_end_paint".}
-proc set_title*(window: PWindow, title: cstring){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_title".}
-proc set_role*(window: PWindow, role: cstring){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_role".}
-proc set_transient_for*(window: PWindow, parent: PWindow){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_transient_for".}
-proc set_background*(window: PWindow, color: PColor){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_background".}
-proc set_back_pixmap*(window: PWindow, pixmap: PPixmap, 
-                             parent_relative: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_back_pixmap".}
-proc set_cursor*(window: PWindow, cursor: PCursor){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_cursor".}
-proc get_user_data*(window: PWindow, data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_user_data".}
-proc get_geometry*(window: PWindow, x: Pgint, y: Pgint, width: Pgint, 
-                          height: Pgint, depth: Pgint){.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_geometry".}
-proc get_position*(window: PWindow, x: Pgint, y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_get_position".}
-proc get_origin*(window: PWindow, x: Pgint, y: Pgint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_window_get_origin".}
-proc get_root_origin*(window: PWindow, x: Pgint, y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_get_root_origin".}
-proc get_frame_extents*(window: PWindow, rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "gdk_window_get_frame_extents".}
-proc get_pointer*(window: PWindow, x: Pgint, y: Pgint, 
-                         mask: PModifierType): PWindow{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_pointer".}
-proc get_parent*(window: PWindow): PWindow{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_parent".}
-proc get_toplevel*(window: PWindow): PWindow{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_toplevel".}
-proc get_children*(window: PWindow): PGList{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_children".}
-proc peek_children*(window: PWindow): PGList{.cdecl, dynlib: lib, 
-    importc: "gdk_window_peek_children".}
-proc get_events*(window: PWindow): TEventMask{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_events".}
-proc set_events*(window: PWindow, event_mask: TEventMask){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_events".}
-proc set_icon_list*(window: PWindow, pixbufs: PGList){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_icon_list".}
-proc set_icon*(window: PWindow, icon_window: PWindow, pixmap: PPixmap, 
-                      mask: PBitmap){.cdecl, dynlib: lib, 
-                                      importc: "gdk_window_set_icon".}
-proc set_icon_name*(window: PWindow, name: cstring){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_icon_name".}
-proc set_group*(window: PWindow, leader: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_group".}
-proc set_decorations*(window: PWindow, decorations: TWMDecoration){.
-    cdecl, dynlib: lib, importc: "gdk_window_set_decorations".}
-proc get_decorations*(window: PWindow, decorations: PWMDecoration): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_window_get_decorations".}
-proc set_functions*(window: PWindow, functions: TWMFunction){.cdecl, 
-    dynlib: lib, importc: "gdk_window_set_functions".}
-proc iconify*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gdk_window_iconify".}
-proc deiconify*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_deiconify".}
-proc stick*(window: PWindow){.cdecl, dynlib: lib, 
-                                     importc: "gdk_window_stick".}
-proc unstick*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gdk_window_unstick".}
-proc maximize*(window: PWindow){.cdecl, dynlib: lib, 
-                                        importc: "gdk_window_maximize".}
-proc unmaximize*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_unmaximize".}
-proc register_dnd*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_register_dnd".}
-proc begin_resize_drag*(window: PWindow, edge: TWindowEdge, button: gint, 
-                               root_x: gint, root_y: gint, timestamp: guint32){.
-    cdecl, dynlib: lib, importc: "gdk_window_begin_resize_drag".}
-proc begin_move_drag*(window: PWindow, button: gint, root_x: gint, 
-                             root_y: gint, timestamp: guint32){.cdecl, 
-    dynlib: lib, importc: "gdk_window_begin_move_drag".}
-proc invalidate_rect*(window: PWindow, rect: PRectangle, 
-                             invalidate_children: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_window_invalidate_rect".}
-proc invalidate_region*(window: PWindow, region: PRegion, 
-                               invalidate_children: gboolean){.cdecl, 
-    dynlib: lib, importc: "gdk_window_invalidate_region".}
-proc invalidate_maybe_recurse*(window: PWindow, region: PRegion, 
-    child_func: window_invalidate_maybe_recurse_child_func, user_data: gpointer){.
-    cdecl, dynlib: lib, importc: "gdk_window_invalidate_maybe_recurse".}
-proc get_update_area*(window: PWindow): PRegion{.cdecl, dynlib: lib, 
-    importc: "gdk_window_get_update_area".}
-proc freeze_updates*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_freeze_updates".}
-proc thaw_updates*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gdk_window_thaw_updates".}
-proc window_process_all_updates*(){.cdecl, dynlib: lib, 
-                                    importc: "gdk_window_process_all_updates".}
-proc process_updates*(window: PWindow, update_children: gboolean){.cdecl, 
-    dynlib: lib, importc: "gdk_window_process_updates".}
-proc window_set_debug_updates*(setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gdk_window_set_debug_updates".}
-proc window_constrain_size*(geometry: PGeometry, flags: guint, width: gint, 
-                            height: gint, new_width: Pgint, new_height: Pgint){.
-    cdecl, dynlib: lib, importc: "gdk_window_constrain_size".}
-proc get_internal_paint_info*(window: PWindow, e: var PDrawable, 
-                                     x_offset: Pgint, y_offset: Pgint){.cdecl, 
-    dynlib: lib, importc: "gdk_window_get_internal_paint_info".}
-proc set_pointer_hooks*(new_hooks: PPointerHooks): PPointerHooks{.cdecl, 
-    dynlib: lib, importc: "gdk_set_pointer_hooks".}
-proc get_default_root_window*(): PWindow{.cdecl, dynlib: lib, 
-    importc: "gdk_get_default_root_window".}
-proc parse_args*(argc: Pgint, v: var PPgchar){.cdecl, dynlib: lib, 
-    importc: "gdk_parse_args".}
-proc init*(argc: Pgint, v: var PPgchar){.cdecl, dynlib: lib, importc: "gdk_init".}
-proc init_check*(argc: Pgint, v: var PPgchar): gboolean{.cdecl, dynlib: lib, 
-    importc: "gdk_init_check".}
-when not defined(DISABLE_DEPRECATED): 
-  proc exit*(error_code: gint){.cdecl, dynlib: lib, importc: "gdk_exit".}
-proc set_locale*(): cstring{.cdecl, dynlib: lib, importc: "gdk_set_locale".}
-proc get_program_class*(): cstring{.cdecl, dynlib: lib, 
-                                    importc: "gdk_get_program_class".}
-proc set_program_class*(program_class: cstring){.cdecl, dynlib: lib, 
-    importc: "gdk_set_program_class".}
-proc error_trap_push*(){.cdecl, dynlib: lib, importc: "gdk_error_trap_push".}
-proc error_trap_pop*(): gint{.cdecl, dynlib: lib, importc: "gdk_error_trap_pop".}
-when not defined(DISABLE_DEPRECATED): 
-  proc set_use_xshm*(use_xshm: gboolean){.cdecl, dynlib: lib, 
-      importc: "gdk_set_use_xshm".}
-  proc get_use_xshm*(): gboolean{.cdecl, dynlib: lib, 
-                                  importc: "gdk_get_use_xshm".}
-proc get_display*(): cstring{.cdecl, dynlib: lib, importc: "gdk_get_display".}
-proc get_display_arg_name*(): cstring{.cdecl, dynlib: lib, 
-                                       importc: "gdk_get_display_arg_name".}
-when not defined(DISABLE_DEPRECATED): 
-  proc input_add_full*(source: gint, condition: TInputCondition, 
-                       `function`: TInputFunction, data: gpointer, 
-                       destroy: TDestroyNotify): gint{.cdecl, dynlib: lib, 
-      importc: "gdk_input_add_full".}
-  proc input_add*(source: gint, condition: TInputCondition, 
-                  `function`: TInputFunction, data: gpointer): gint{.cdecl, 
-      dynlib: lib, importc: "gdk_input_add".}
-  proc input_remove*(tag: gint){.cdecl, dynlib: lib, importc: "gdk_input_remove".}
-proc pointer_grab*(window: PWindow, owner_events: gboolean, 
-                   event_mask: TEventMask, confine_to: PWindow, cursor: PCursor, 
-                   time: guint32): TGrabStatus{.cdecl, dynlib: lib, 
-    importc: "gdk_pointer_grab".}
-proc keyboard_grab*(window: PWindow, owner_events: gboolean, time: guint32): TGrabStatus{.
-    cdecl, dynlib: lib, importc: "gdk_keyboard_grab".}
-when not defined(MULTIHEAD_SAFE): 
-  proc pointer_ungrab*(time: guint32){.cdecl, dynlib: lib, 
-                                       importc: "gdk_pointer_ungrab".}
-  proc keyboard_ungrab*(time: guint32){.cdecl, dynlib: lib, 
-                                        importc: "gdk_keyboard_ungrab".}
-  proc pointer_is_grabbed*(): gboolean{.cdecl, dynlib: lib, 
-                                        importc: "gdk_pointer_is_grabbed".}
-  proc screen_width*(): gint{.cdecl, dynlib: lib, importc: "gdk_screen_width".}
-  proc screen_height*(): gint{.cdecl, dynlib: lib, importc: "gdk_screen_height".}
-  proc screen_width_mm*(): gint{.cdecl, dynlib: lib, 
-                                 importc: "gdk_screen_width_mm".}
-  proc screen_height_mm*(): gint{.cdecl, dynlib: lib, 
-                                  importc: "gdk_screen_height_mm".}
-  proc beep*(){.cdecl, dynlib: lib, importc: "gdk_beep".}
-proc flush*(){.cdecl, dynlib: lib, importc: "gdk_flush".}
-when not defined(MULTIHEAD_SAFE): 
-  proc set_double_click_time*(msec: guint){.cdecl, dynlib: lib, 
-      importc: "gdk_set_double_click_time".}
-proc intersect*(src1: PRectangle, src2: PRectangle, dest: PRectangle): gboolean{.
-    cdecl, dynlib: lib, importc: "gdk_rectangle_intersect".}
-proc union*(src1: PRectangle, src2: PRectangle, dest: PRectangle){.
-    cdecl, dynlib: lib, importc: "gdk_rectangle_union".}
-proc rectangle_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "gdk_rectangle_get_type".}
-proc TYPE_RECTANGLE*(): GType
-proc wcstombs*(src: PWChar): cstring{.cdecl, dynlib: lib, 
-                                      importc: "gdk_wcstombs".}
-proc mbstowcs*(dest: PWChar, src: cstring, dest_max: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gdk_mbstowcs".}
-when not defined(MULTIHEAD_SAFE): 
-  proc event_send_client_message*(event: PEvent, xid: guint32): gboolean{.cdecl, 
-      dynlib: lib, importc: "gdk_event_send_client_message".}
-  proc event_send_clientmessage_toall*(event: PEvent){.cdecl, dynlib: lib, 
-      importc: "gdk_event_send_clientmessage_toall".}
-proc event_send_client_message_for_display*(display: PDisplay, event: PEvent, 
-    xid: guint32): gboolean{.cdecl, dynlib: lib, importc: "gdk_event_send_client_message_for_display".}
-proc threads_enter*(){.cdecl, dynlib: lib, importc: "gdk_threads_enter".}
-proc threads_leave*(){.cdecl, dynlib: lib, importc: "gdk_threads_leave".}
-proc threads_init*(){.cdecl, dynlib: lib, importc: "gdk_threads_init".}
-proc TYPE_RECTANGLE*(): GType = 
-  result = rectangle_get_type()
-
-proc TYPE_COLORMAP*(): GType = 
-  result = colormap_get_type()
-
-proc COLORMAP*(anObject: pointer): PColormap = 
-  result = cast[PColormap](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_COLORMAP()))
-
-proc COLORMAP_CLASS*(klass: pointer): PColormapClass = 
-  result = cast[PColormapClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_COLORMAP()))
-
-proc IS_COLORMAP*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_COLORMAP())
-
-proc IS_COLORMAP_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_COLORMAP())
-
-proc COLORMAP_GET_CLASS*(obj: pointer): PColormapClass = 
-  result = cast[PColormapClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_COLORMAP()))
-
-proc TYPE_COLOR*(): GType = 
-  result = gdk2.color_get_type()
-
-proc destroy*(cursor: PCursor) = 
-  unref(cursor)
-
-proc TYPE_CURSOR*(): GType = 
-  result = cursor_get_type()
-
-proc TYPE_DRAG_CONTEXT*(): GType = 
-  result = drag_context_get_type()
-
-proc DRAG_CONTEXT*(anObject: Pointer): PDragContext = 
-  result = cast[PDragContext](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_DRAG_CONTEXT()))
-
-proc DRAG_CONTEXT_CLASS*(klass: Pointer): PDragContextClass = 
-  result = cast[PDragContextClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_DRAG_CONTEXT()))
-
-proc IS_DRAG_CONTEXT*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_DRAG_CONTEXT())
-
-proc IS_DRAG_CONTEXT_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_DRAG_CONTEXT())
-
-proc DRAG_CONTEXT_GET_CLASS*(obj: Pointer): PDragContextClass = 
-  result = cast[PDragContextClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_DRAG_CONTEXT()))
-
-proc region_EXTENTCHECK*(r1, r2: PRegionBox): bool = 
-  result = ((r1.x2) > r2.x1) and ((r1.x1) < r2.x2) and ((r1.y2) > r2.y1) and
-      ((r1.y1) < r2.y2)
-
-proc EXTENTS*(r: PRegionBox, idRect: PRegion) = 
-  if ((r.x1) < idRect.extents.x1): 
-    idRect.extents.x1 = r.x1
-  if (r.y1) < idRect.extents.y1: 
-    idRect.extents.y1 = r.y1
-  if (r.x2) > idRect.extents.x2: 
-    idRect.extents.x2 = r.x2
-
-proc MEMCHECK*(reg: PRegion, ARect, firstrect: var PRegionBox): bool = 
-  assert(false)               # to implement
-  
-proc CHECK_PREVIOUS*(Reg: PRegion, R: PRegionBox, 
-                            Rx1, Ry1, Rx2, Ry2: gint): bool = 
-  assert(false)               # to implement
-  
-proc ADDRECT*(reg: PRegion, r: PRegionBox, rx1, ry1, rx2, ry2: gint) = 
-  if (((rx1) < rx2) and ((ry1) < ry2) and
-      CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)): 
-    r.x1 = rx1
-    r.y1 = ry1
-    r.x2 = rx2
-    r.y2 = ry2
-
-proc ADDRECTNOX*(reg: PRegion, r: PRegionBox, rx1, ry1, rx2, ry2: gint) = 
-  if (((rx1) < rx2) and ((ry1) < ry2) and
-      CHECK_PREVIOUS(reg, r, rx1, ry1, rx2, ry2)): 
-    r.x1 = rx1
-    r.y1 = ry1
-    r.x2 = rx2
-    r.y2 = ry2
-    inc(reg.numRects)
-
-proc EMPTY_REGION*(pReg: PRegion): bool = 
-  result = pReg.numRects == 0'i32
-
-proc REGION_NOT_EMPTY*(pReg: PRegion): bool = 
-  result = pReg.numRects != 0'i32
-
-proc region_INBOX*(r: TRegionBox, x, y: gint): bool = 
-  result = ((((r.x2) > x) and ((r.x1) <= x)) and ((r.y2) > y)) and
-      ((r.y1) <= y)
-
-proc TYPE_DRAWABLE*(): GType = 
-  result = drawable_get_type()
-
-proc DRAWABLE*(anObject: Pointer): PDrawable = 
-  result = cast[PDrawable](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_DRAWABLE()))
-
-proc DRAWABLE_CLASS*(klass: Pointer): PDrawableClass = 
-  result = cast[PDrawableClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_DRAWABLE()))
-
-proc IS_DRAWABLE*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_DRAWABLE())
-
-proc IS_DRAWABLE_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_DRAWABLE())
-
-proc DRAWABLE_GET_CLASS*(obj: Pointer): PDrawableClass = 
-  result = cast[PDrawableClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_DRAWABLE()))
-
-proc pixmap*(drawable: PDrawable, gc: PGC, src: PDrawable, xsrc: gint, 
-                  ysrc: gint, xdest: gint, ydest: gint, width: gint, 
-                  height: gint) = 
-  drawable(drawable, gc, src, xsrc, ysrc, xdest, ydest, width, height)
-
-proc bitmap*(drawable: PDrawable, gc: PGC, src: PDrawable, xsrc: gint, 
-                  ysrc: gint, xdest: gint, ydest: gint, width: gint, 
-                  height: gint) = 
-  drawable(drawable, gc, src, xsrc, ysrc, xdest, ydest, width, height)
-
-proc TYPE_EVENT*(): GType = 
-  result = event_get_type()
-
-proc TYPE_FONT*(): GType = 
-  result = gdk2.font_get_type()
-
-proc TYPE_GC*(): GType = 
-  result = gc_get_type()
-
-proc GC*(anObject: Pointer): PGC = 
-  result = cast[PGC](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_GC()))
-
-proc GC_CLASS*(klass: Pointer): PGCClass = 
-  result = cast[PGCClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_GC()))
-
-proc IS_GC*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_GC())
-
-proc IS_GC_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_GC())
-
-proc GC_GET_CLASS*(obj: Pointer): PGCClass = 
-  result = cast[PGCClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_GC()))
-
-proc destroy*(gc: PGC) = 
-  g_object_unref(G_OBJECT(gc))
-
-proc TYPE_IMAGE*(): GType = 
-  result = image_get_type()
-
-proc IMAGE*(anObject: Pointer): PImage = 
-  result = cast[PImage](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_IMAGE()))
-
-proc IMAGE_CLASS*(klass: Pointer): PImageClass = 
-  result = cast[PImageClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_IMAGE()))
-
-proc IS_IMAGE*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_IMAGE())
-
-proc IS_IMAGE_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_IMAGE())
-
-proc IMAGE_GET_CLASS*(obj: Pointer): PImageClass = 
-  result = cast[PImageClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_IMAGE()))
-
-proc destroy*(image: PImage) = 
-  g_object_unref(G_OBJECT(image))
-
-proc TYPE_DEVICE*(): GType = 
-  result = device_get_type()
-
-proc DEVICE*(anObject: Pointer): PDevice = 
-  result = cast[PDevice](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_DEVICE()))
-
-proc DEVICE_CLASS*(klass: Pointer): PDeviceClass = 
-  result = cast[PDeviceClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_DEVICE()))
-
-proc IS_DEVICE*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_DEVICE())
-
-proc IS_DEVICE_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_DEVICE())
-
-proc DEVICE_GET_CLASS*(obj: Pointer): PDeviceClass = 
-  result = cast[PDeviceClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_DEVICE()))
-
-proc TYPE_KEYMAP*(): GType = 
-  result = keymap_get_type()
-
-proc KEYMAP*(anObject: Pointer): PKeymap = 
-  result = cast[PKeymap](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_KEYMAP()))
-
-proc KEYMAP_CLASS*(klass: Pointer): PKeymapClass = 
-  result = cast[PKeymapClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_KEYMAP()))
-
-proc IS_KEYMAP*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_KEYMAP())
-
-proc IS_KEYMAP_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_KEYMAP())
-
-proc KEYMAP_GET_CLASS*(obj: Pointer): PKeymapClass = 
-  result = cast[PKeymapClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_KEYMAP()))
-
-proc TYPE_PIXMAP*(): GType = 
-  result = pixmap_get_type()
-
-proc PIXMAP*(anObject: Pointer): PPixmap = 
-  result = cast[PPixmap](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_PIXMAP()))
-
-proc PIXMAP_CLASS*(klass: Pointer): PPixmapObjectClass = 
-  result = cast[PPixmapObjectClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_PIXMAP()))
-
-proc IS_PIXMAP*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXMAP())
-
-proc IS_PIXMAP_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_PIXMAP())
-
-proc PIXMAP_GET_CLASS*(obj: Pointer): PPixmapObjectClass = 
-  result = cast[PPixmapObjectClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_PIXMAP()))
-
-proc PIXMAP_OBJECT*(anObject: Pointer): PPixmapObject = 
-  result = cast[PPixmapObject](PIXMAP(anObject))
-
-proc bitmap_ref*(drawable: PDrawable): PDrawable = 
-  result = DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc bitmap_unref*(drawable: PDrawable) = 
-  g_object_unref(G_OBJECT(drawable))
-
-proc pixmap_ref*(drawable: PDrawable): PDrawable = 
-  result = DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc pixmap_unref*(drawable: PDrawable) = 
-  g_object_unref(G_OBJECT(drawable))
-
-proc rgb_get_cmap*(): PColormap = 
-  result = nil                #gdk_rgb_get_colormap()
-  
-proc TYPE_DISPLAY*(): GType = 
-  nil
-  #result = nil
-  
-proc DISPLAY_OBJECT*(anObject: pointer): PDisplay = 
-  result = cast[PDisplay](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_DISPLAY()))
-
-proc DISPLAY_CLASS*(klass: pointer): PDisplayClass = 
-  result = cast[PDisplayClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_DISPLAY()))
-
-proc IS_DISPLAY*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_DISPLAY())
-
-proc IS_DISPLAY_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_DISPLAY())
-
-proc DISPLAY_GET_CLASS*(obj: pointer): PDisplayClass = 
-  result = cast[PDisplayClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_DISPLAY()))
-
-proc TYPE_SCREEN*(): GType = 
-  nil
-
-proc SCREEN*(anObject: Pointer): PScreen = 
-  result = cast[PScreen](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_SCREEN()))
-
-proc SCREEN_CLASS*(klass: Pointer): PScreenClass = 
-  result = cast[PScreenClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_SCREEN()))
-
-proc IS_SCREEN*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_SCREEN())
-
-proc IS_SCREEN_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_SCREEN())
-
-proc SCREEN_GET_CLASS*(obj: Pointer): PScreenClass = 
-  result = cast[PScreenClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_SCREEN()))
-
-proc SELECTION_PRIMARY*(): TAtom = 
-  result = `MAKE_ATOM`(1)
-
-proc SELECTION_SECONDARY*(): TAtom = 
-  result = `MAKE_ATOM`(2)
-
-proc SELECTION_CLIPBOARD*(): TAtom = 
-  result = `MAKE_ATOM`(69)
-
-proc TARGET_BITMAP*(): TAtom = 
-  result = `MAKE_ATOM`(5)
-
-proc TARGET_COLORMAP*(): TAtom = 
-  result = `MAKE_ATOM`(7)
-
-proc TARGET_DRAWABLE*(): TAtom = 
-  result = `MAKE_ATOM`(17)
-
-proc TARGET_PIXMAP*(): TAtom = 
-  result = `MAKE_ATOM`(20)
-
-proc TARGET_STRING*(): TAtom = 
-  result = `MAKE_ATOM`(31)
-
-proc SELECTION_TYPE_ATOM*(): TAtom = 
-  result = `MAKE_ATOM`(4)
-
-proc SELECTION_TYPE_BITMAP*(): TAtom = 
-  result = `MAKE_ATOM`(5)
-
-proc SELECTION_TYPE_COLORMAP*(): TAtom = 
-  result = `MAKE_ATOM`(7)
-
-proc SELECTION_TYPE_DRAWABLE*(): TAtom = 
-  result = `MAKE_ATOM`(17)
-
-proc SELECTION_TYPE_INTEGER*(): TAtom = 
-  result = `MAKE_ATOM`(19)
-
-proc SELECTION_TYPE_PIXMAP*(): TAtom = 
-  result = `MAKE_ATOM`(20)
-
-proc SELECTION_TYPE_WINDOW*(): TAtom = 
-  result = `MAKE_ATOM`(33)
-
-proc SELECTION_TYPE_STRING*(): TAtom = 
-  result = `MAKE_ATOM`(31)
-
-proc ATOM_TO_POINTER*(atom: TAtom): pointer = 
-  result = cast[Pointer](atom)
-
-proc POINTER_TO_ATOM*(p: Pointer): TAtom = 
-  result = cast[TAtom](p)
-
-proc `MAKE_ATOM`*(val: guint): TAtom = 
-  result = cast[TAtom](val)
-
-proc NONE*(): TAtom = 
-  result = `MAKE_ATOM`(0)
-
-proc TYPE_VISUAL*(): GType = 
-  result = visual_get_type()
-
-proc VISUAL*(anObject: Pointer): PVisual = 
-  result = cast[PVisual](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_VISUAL()))
-
-proc VISUAL_CLASS*(klass: Pointer): PVisualClass = 
-  result = cast[PVisualClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_VISUAL()))
-
-proc IS_VISUAL*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_VISUAL())
-
-proc IS_VISUAL_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_VISUAL())
-
-proc VISUAL_GET_CLASS*(obj: Pointer): PVisualClass = 
-  result = cast[PVisualClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_VISUAL()))
-
-proc reference*(v: PVisual) = 
-  discard g_object_ref(v)
-
-proc unref*(v: PVisual) = 
-  g_object_unref(v)
-
-proc TYPE_WINDOW*(): GType = 
-  result = window_object_get_type()
-
-proc WINDOW*(anObject: Pointer): PWindow = 
-  result = cast[PWindow](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_WINDOW()))
-
-proc WINDOW_CLASS*(klass: Pointer): PWindowObjectClass = 
-  result = cast[PWindowObjectClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_WINDOW()))
-
-proc IS_WINDOW*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_WINDOW())
-
-proc IS_WINDOW_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_WINDOW())
-
-proc WINDOW_GET_CLASS*(obj: Pointer): PWindowObjectClass = 
-  result = cast[PWindowObjectClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_WINDOW()))
-
-proc WINDOW_OBJECT*(anObject: Pointer): PWindowObject = 
-  result = cast[PWindowObject](WINDOW(anObject))
-
-proc WindowObject_guffaw_gravity*(a: PWindowObject): guint = 
-  result = (a.flag0 and bm_TWindowObject_guffaw_gravity) shr
-      bp_TWindowObject_guffaw_gravity
-
-proc WindowObject_set_guffaw_gravity*(a: PWindowObject, 
-                                      `guffaw_gravity`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`guffaw_gravity` shl bp_TWindowObject_guffaw_gravity) and
-      bm_TWindowObject_guffaw_gravity)
-
-proc WindowObject_input_only*(a: PWindowObject): guint = 
-  result = (a.flag0 and bm_TWindowObject_input_only) shr
-      bp_TWindowObject_input_only
-
-proc WindowObject_set_input_only*(a: PWindowObject, `input_only`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`input_only` shl bp_TWindowObject_input_only) and
-      bm_TWindowObject_input_only)
-
-proc WindowObject_modal_hint*(a: PWindowObject): guint = 
-  result = (a.flag0 and bm_TWindowObject_modal_hint) shr
-      bp_TWindowObject_modal_hint
-
-proc WindowObject_set_modal_hint*(a: PWindowObject, `modal_hint`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`modal_hint` shl bp_TWindowObject_modal_hint) and
-      bm_TWindowObject_modal_hint)
-
-proc WindowObject_destroyed*(a: PWindowObject): guint = 
-  result = (a.flag0 and bm_TWindowObject_destroyed) shr
-      bp_TWindowObject_destroyed
-
-proc WindowObject_set_destroyed*(a: PWindowObject, `destroyed`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`destroyed` shl bp_TWindowObject_destroyed) and
-      bm_TWindowObject_destroyed)
-
-proc ROOT_PARENT*(): PWindow = 
-  result = get_default_root_window()
-
-proc window_get_size*(drawable: PDrawable, width: Pgint, height: Pgint) = 
-  get_size(drawable, width, height)
-
-proc get_type*(window: PWindow): TWindowType = 
-  result = get_window_type(window)
-
-proc window_get_colormap*(drawable: PDrawable): PColormap = 
-  result = get_colormap(drawable)
-
-proc window_set_colormap*(drawable: PDrawable, colormap: PColormap) = 
-  set_colormap(drawable, colormap)
-
-proc window_get_visual*(drawable: PDrawable): PVisual = 
-  result = get_visual(drawable)
-
-proc window_ref*(drawable: PDrawable): PDrawable = 
-  result = DRAWABLE(g_object_ref(G_OBJECT(drawable)))
-
-proc window_unref*(drawable: PDrawable) = 
-  g_object_unref(G_OBJECT(drawable))
-
-proc window_copy_area*(drawable: PDrawable, gc: PGC, x, y: gint, 
-                       source_drawable: PDrawable, source_x, source_y: gint, 
-                       width, height: gint) = 
-  pixmap(drawable, gc, source_drawable, source_x, source_y, x, y, width, 
-         height)
diff --git a/lib/wrappers/gtk/gdk2pixbuf.nim b/lib/wrappers/gtk/gdk2pixbuf.nim
deleted file mode 100755
index e866e51ff..000000000
--- a/lib/wrappers/gtk/gdk2pixbuf.nim
+++ /dev/null
@@ -1,271 +0,0 @@
-{.deadCodeElim: on.}
-import 
-  glib2
-
-when defined(win32): 
-  const 
-    pixbuflib = "libgdk_pixbuf-2.0-0.dll"
-elif defined(darwin): 
-  const 
-    pixbuflib = "gdk_pixbuf-2.0.0"
-  # linklib gtk-x11-2.0
-  # linklib gdk-x11-2.0
-  # linklib pango-1.0.0
-  # linklib glib-2.0.0
-  # linklib gobject-2.0.0
-  # linklib gdk_pixbuf-2.0.0
-  # linklib atk-1.0.0
-else: 
-  const 
-    pixbuflib = "libgdk_pixbuf-2.0.so"
-type 
-  PPixbuf* = pointer
-  PPixbufAnimation* = pointer
-  PPixbufAnimationIter* = pointer
-  PPixbufAlphaMode* = ptr TPixbufAlphaMode
-  TPixbufAlphaMode* = enum 
-    PIXBUF_ALPHA_BILEVEL, PIXBUF_ALPHA_FULL
-  PColorspace* = ptr TColorspace
-  TColorspace* = enum 
-    COLORSPACE_RGB
-  TPixbufDestroyNotify* = proc (pixels: Pguchar, data: gpointer){.cdecl.}
-  PPixbufError* = ptr TPixbufError
-  TPixbufError* = enum 
-    PIXBUF_ERROR_CORRUPT_IMAGE, PIXBUF_ERROR_INSUFFICIENT_MEMORY, 
-    PIXBUF_ERROR_BAD_OPTION, PIXBUF_ERROR_UNKNOWN_TYPE, 
-    PIXBUF_ERROR_UNSUPPORTED_OPERATION, PIXBUF_ERROR_FAILED
-  PInterpType* = ptr TInterpType
-  TInterpType* = enum 
-    INTERP_NEAREST, INTERP_TILES, INTERP_BILINEAR, INTERP_HYPER
-
-proc TYPE_PIXBUF*(): GType
-proc PIXBUF*(anObject: pointer): PPixbuf
-proc IS_PIXBUF*(anObject: pointer): bool
-proc TYPE_PIXBUF_ANIMATION*(): GType
-proc PIXBUF_ANIMATION*(anObject: pointer): PPixbufAnimation
-proc IS_PIXBUF_ANIMATION*(anObject: pointer): bool
-proc TYPE_PIXBUF_ANIMATION_ITER*(): GType
-proc PIXBUF_ANIMATION_ITER*(anObject: pointer): PPixbufAnimationIter
-proc IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool
-proc PIXBUF_ERROR*(): TGQuark
-proc pixbuf_error_quark*(): TGQuark{.cdecl, dynlib: pixbuflib, 
-                                     importc: "gdk_pixbuf_error_quark".}
-proc pixbuf_get_type*(): GType{.cdecl, dynlib: pixbuflib, 
-                                importc: "gdk_pixbuf_get_type".}
-when not defined(PIXBUF_DISABLE_DEPRECATED): 
-  proc pixbuf_ref*(pixbuf: PPixbuf): PPixbuf{.cdecl, dynlib: pixbuflib, 
-      importc: "gdk_pixbuf_ref".}
-  proc pixbuf_unref*(pixbuf: PPixbuf){.cdecl, dynlib: pixbuflib, 
-                                       importc: "gdk_pixbuf_unref".}
-proc get_colorspace*(pixbuf: PPixbuf): TColorspace{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_get_colorspace".}
-proc get_n_channels*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_n_channels".}
-proc get_has_alpha*(pixbuf: PPixbuf): gboolean{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_has_alpha".}
-proc get_bits_per_sample*(pixbuf: PPixbuf): int32{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_get_bits_per_sample".}
-proc get_pixels*(pixbuf: PPixbuf): Pguchar{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_pixels".}
-proc get_width*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_width".}
-proc get_height*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_height".}
-proc get_rowstride*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_get_rowstride".}
-proc pixbuf_new*(colorspace: TColorspace, has_alpha: gboolean, 
-                 bits_per_sample: int32, width: int32, height: int32): PPixbuf{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_new".}
-proc copy*(pixbuf: PPixbuf): PPixbuf{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_copy".}
-proc new_subpixbuf*(src_pixbuf: PPixbuf, src_x: int32, src_y: int32, 
-                           width: int32, height: int32): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_new_subpixbuf".}
-proc pixbuf_new_from_file*(filename: cstring, error: pointer): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file".}
-proc pixbuf_new_from_data*(data: Pguchar, colorspace: TColorspace, 
-                           has_alpha: gboolean, bits_per_sample: int32, 
-                           width: int32, height: int32, rowstride: int32, 
-                           destroy_fn: TPixbufDestroyNotify, 
-                           destroy_fn_data: gpointer): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_data".}
-proc pixbuf_new_from_xpm_data*(data: PPchar): PPixbuf{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_new_from_xpm_data".}
-proc pixbuf_new_from_inline*(data_length: gint, a: var guint8, 
-                             copy_pixels: gboolean, error: pointer): PPixbuf{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_inline".}
-proc pixbuf_new_from_file_at_size*(filename: cstring, width, height: gint, 
-                                   error: pointer): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file_at_size".}
-proc pixbuf_new_from_file_at_scale*(filename: cstring, width, height: gint, 
-                                    preserve_aspect_ratio: gboolean, 
-                                    error: pointer): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file_at_scale".}
-proc fill*(pixbuf: PPixbuf, pixel: guint32){.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_fill".}
-proc save*(pixbuf: PPixbuf, filename: cstring, `type`: cstring, 
-                  error: pointer): gboolean{.cdecl, varargs, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_save".}
-proc savev*(pixbuf: PPixbuf, filename: cstring, `type`: cstring, 
-                   option_keys: PPchar, option_values: PPchar, error: pointer): gboolean{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_savev".}
-proc add_alpha*(pixbuf: PPixbuf, substitute_color: gboolean, r: guchar, 
-                       g: guchar, b: guchar): PPixbuf{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_add_alpha".}
-proc copy_area*(src_pixbuf: PPixbuf, src_x: int32, src_y: int32, 
-                       width: int32, height: int32, dest_pixbuf: PPixbuf, 
-                       dest_x: int32, dest_y: int32){.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_copy_area".}
-proc saturate_and_pixelate*(src: PPixbuf, dest: PPixbuf, 
-                                   saturation: gfloat, pixelate: gboolean){.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_saturate_and_pixelate".}
-proc scale*(src: PPixbuf, dest: PPixbuf, dest_x: int32, dest_y: int32, 
-                   dest_width: int32, dest_height: int32, offset_x: float64, 
-                   offset_y: float64, scale_x: float64, scale_y: float64, 
-                   interp_type: TInterpType){.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_scale".}
-proc composite*(src: PPixbuf, dest: PPixbuf, dest_x: int32, 
-                       dest_y: int32, dest_width: int32, dest_height: int32, 
-                       offset_x: float64, offset_y: float64, scale_x: float64, 
-                       scale_y: float64, interp_type: TInterpType, 
-                       overall_alpha: int32){.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_composite".}
-proc composite_color*(src: PPixbuf, dest: PPixbuf, dest_x: int32, 
-                             dest_y: int32, dest_width: int32, 
-                             dest_height: int32, offset_x: float64, 
-                             offset_y: float64, scale_x: float64, 
-                             scale_y: float64, interp_type: TInterpType, 
-                             overall_alpha: int32, check_x: int32, 
-                             check_y: int32, check_size: int32, color1: guint32, 
-                             color2: guint32){.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_composite_color".}
-proc scale_simple*(src: PPixbuf, dest_width: int32, dest_height: int32, 
-                          interp_type: TInterpType): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_scale_simple".}
-proc composite_color_simple*(src: PPixbuf, dest_width: int32, 
-                                    dest_height: int32, 
-                                    interp_type: TInterpType, 
-                                    overall_alpha: int32, check_size: int32, 
-                                    color1: guint32, color2: guint32): PPixbuf{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_composite_color_simple".}
-proc pixbuf_animation_get_type*(): GType{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_animation_get_type".}
-proc pixbuf_animation_new_from_file*(filename: cstring, error: pointer): PPixbufAnimation{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_new_from_file".}
-when not defined(PIXBUF_DISABLE_DEPRECATED): 
-  proc pixbuf_animation_ref*(animation: PPixbufAnimation): PPixbufAnimation{.
-      cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_ref".}
-  proc pixbuf_animation_unref*(animation: PPixbufAnimation){.cdecl, 
-      dynlib: pixbuflib, importc: "gdk_pixbuf_animation_unref".}
-proc get_width*(animation: PPixbufAnimation): int32{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_width".}
-proc get_height*(animation: PPixbufAnimation): int32{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_height".}
-proc is_static_image*(animation: PPixbufAnimation): gboolean{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_is_static_image".}
-proc get_static_image*(animation: PPixbufAnimation): PPixbuf{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_static_image".}
-proc get_iter*(animation: PPixbufAnimation, e: var TGTimeVal): PPixbufAnimationIter{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_iter".}
-proc pixbuf_animation_iter_get_type*(): GType{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_animation_iter_get_type".}
-proc iter_get_delay_time*(iter: PPixbufAnimationIter): int32{.
-    cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_animation_iter_get_delay_time".}
-proc iter_get_pixbuf*(iter: PPixbufAnimationIter): PPixbuf{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_iter_get_pixbuf".}
-proc pixbuf_animation_iter_on_currently_loading_frame*(
-    iter: PPixbufAnimationIter): gboolean{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_animation_iter_on_currently_loading_frame".}
-proc iter_advance*(iter: PPixbufAnimationIter, e: var TGTimeVal): gboolean{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_iter_advance".}
-proc get_option*(pixbuf: PPixbuf, key: cstring): cstring{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_get_option".}
-type 
-  PPixbufLoader* = ptr TPixbufLoader
-  TPixbufLoader*{.final, pure.} = object 
-    parent_instance*: TGObject
-    priv*: gpointer
-
-  PPixbufLoaderClass* = ptr TPixbufLoaderClass
-  TPixbufLoaderClass*{.final, pure.} = object 
-    parent_class*: TGObjectClass
-    area_prepared*: proc (loader: PPixbufLoader){.cdecl.}
-    area_updated*: proc (loader: PPixbufLoader, x: int32, y: int32, 
-                         width: int32, height: int32){.cdecl.}
-    closed*: proc (loader: PPixbufLoader){.cdecl.}
-
-
-proc TYPE_PIXBUF_LOADER*(): GType
-proc PIXBUF_LOADER*(obj: pointer): PPixbufLoader
-proc PIXBUF_LOADER_CLASS*(klass: pointer): PPixbufLoaderClass
-proc IS_PIXBUF_LOADER*(obj: pointer): bool
-proc IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool
-proc PIXBUF_LOADER_GET_CLASS*(obj: pointer): PPixbufLoaderClass
-proc pixbuf_loader_get_type*(): GType{.cdecl, dynlib: pixbuflib, 
-                                       importc: "gdk_pixbuf_loader_get_type".}
-proc pixbuf_loader_new*(): PPixbufLoader{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_loader_new".}
-proc pixbuf_loader_new*(image_type: cstring, error: pointer): PPixbufLoader{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_new_with_type".}
-proc write*(loader: PPixbufLoader, buf: Pguchar, count: gsize, 
-                          error: pointer): gboolean{.cdecl, dynlib: pixbuflib, 
-    importc: "gdk_pixbuf_loader_write".}
-proc get_pixbuf*(loader: PPixbufLoader): PPixbuf{.cdecl, 
-    dynlib: pixbuflib, importc: "gdk_pixbuf_loader_get_pixbuf".}
-proc get_animation*(loader: PPixbufLoader): PPixbufAnimation{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_get_animation".}
-proc close*(loader: PPixbufLoader, error: pointer): gboolean{.
-    cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_close".}
-proc TYPE_PIXBUF_LOADER*(): GType = 
-  result = pixbuf_loader_get_type()
-
-proc PIXBUF_LOADER*(obj: pointer): PPixbufLoader = 
-  result = cast[PPixbufLoader](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_PIXBUF_LOADER()))
-
-proc PIXBUF_LOADER_CLASS*(klass: pointer): PPixbufLoaderClass = 
-  result = cast[PPixbufLoaderClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_PIXBUF_LOADER()))
-
-proc IS_PIXBUF_LOADER*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_PIXBUF_LOADER())
-
-proc IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_PIXBUF_LOADER())
-
-proc PIXBUF_LOADER_GET_CLASS*(obj: pointer): PPixbufLoaderClass = 
-  result = cast[PPixbufLoaderClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_PIXBUF_LOADER()))
-
-proc TYPE_PIXBUF*(): GType = 
-  result = pixbuf_get_type()
-
-proc PIXBUF*(anObject: pointer): PPixbuf = 
-  result = cast[PPixbuf](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_PIXBUF()))
-
-proc IS_PIXBUF*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF())
-
-proc TYPE_PIXBUF_ANIMATION*(): GType = 
-  result = pixbuf_animation_get_type()
-
-proc PIXBUF_ANIMATION*(anObject: pointer): PPixbufAnimation = 
-  result = cast[PPixbufAnimation](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_PIXBUF_ANIMATION()))
-
-proc IS_PIXBUF_ANIMATION*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF_ANIMATION())
-
-proc TYPE_PIXBUF_ANIMATION_ITER*(): GType = 
-  result = pixbuf_animation_iter_get_type()
-
-proc PIXBUF_ANIMATION_ITER*(anObject: pointer): PPixbufAnimationIter = 
-  result = cast[PPixbufAnimationIter](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_PIXBUF_ANIMATION_ITER()))
-
-proc IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF_ANIMATION_ITER())
-
-proc PIXBUF_ERROR*(): TGQuark = 
-  result = pixbuf_error_quark()
diff --git a/lib/wrappers/gtk/glib2.nim b/lib/wrappers/gtk/glib2.nim
deleted file mode 100755
index d7414cbcb..000000000
--- a/lib/wrappers/gtk/glib2.nim
+++ /dev/null
@@ -1,4498 +0,0 @@
-{.deadCodeElim: on.}
-when defined(windows): 
-  const 
-    gliblib = "libglib-2.0-0.dll"
-    gmodulelib = "libgmodule-2.0-0.dll"
-    gobjectlib = "libgobject-2.0-0.dll"
-else: 
-  const 
-    gliblib = "libglib-2.0.so(|.0)"
-    gmodulelib = "libgmodule-2.0.so(|.0)"
-    gobjectlib = "libgobject-2.0.so(|.0)"
-# gthreadlib = "libgthread-2.0.so"
-
-type 
-  PGTypePlugin* = pointer
-  PGParamSpecPool* = pointer
-  PPchar* = ptr cstring
-  PPPchar* = ptr PPchar
-  PPPgchar* = ptr PPgchar
-  PPgchar* = ptr cstring
-  gchar* = char
-  gshort* = cshort
-  glong* = clong
-  gint* = cint
-  gboolean* = bool
-  guchar* = char
-  gushort* = int16
-  gulong* = int
-  guint* = cint
-  gfloat* = cfloat
-  gdouble* = cdouble
-  gpointer* = pointer
-  Pgshort* = ptr gshort
-  Pglong* = ptr glong
-  Pgint* = ptr gint
-  PPgint* = ptr Pgint
-  Pgboolean* = ptr gboolean
-  Pguchar* = ptr guchar
-  PPguchar* = ptr Pguchar
-  Pgushort* = ptr gushort
-  Pgulong* = ptr gulong
-  Pguint* = ptr guint
-  Pgfloat* = ptr gfloat
-  Pgdouble* = ptr gdouble
-  pgpointer* = ptr gpointer
-  gconstpointer* = pointer
-  PGCompareFunc* = ptr TGCompareFunc
-  TGCompareFunc* = proc (a, b: gconstpointer): gint{.cdecl.}
-  PGCompareDataFunc* = ptr TGCompareDataFunc
-  TGCompareDataFunc* = proc (a, b: gconstpointer, user_data: gpointer): gint{.
-      cdecl.}
-  PGEqualFunc* = ptr TGEqualFunc
-  TGEqualFunc* = proc (a, b: gconstpointer): gboolean{.cdecl.}
-  PGDestroyNotify* = ptr TGDestroyNotify
-  TGDestroyNotify* = proc (data: gpointer){.cdecl.}
-  PGFunc* = ptr TGFunc
-  TGFunc* = proc (data, userdata: gpointer, key: gconstpointer){.cdecl.}
-  PGHashFunc* = ptr TGHashFunc
-  TGHashFunc* = proc (key: gconstpointer): guint{.cdecl.}
-  PGHFunc* = ptr TGHFunc
-  TGHFunc* = proc (key, value, user_data: gpointer){.cdecl.}
-  PGFreeFunc* = proc (data: gpointer){.cdecl.}
-  PGTimeVal* = ptr TGTimeVal
-  TGTimeVal*{.final.} = object 
-    tv_sec*: glong
-    tv_usec*: glong
-
-  guint64* = int64
-  gint8* = int8
-  guint8* = int8
-  gint16* = int16
-  guint16* = int16
-  gint32* = int32
-  guint32* = int32
-  gint64* = int64
-  gssize* = int32
-  gsize* = int32
-  Pgint8* = ptr gint8
-  Pguint8* = ptr guint8
-  Pgint16* = ptr gint16
-  Pguint16* = ptr guint16
-  Pgint32* = ptr gint32
-  Pguint32* = ptr guint32
-  Pgint64* = ptr gint64
-  Pguint64* = ptr guint64
-  pgssize* = ptr gssize
-  pgsize* = ptr gsize
-  TGQuark* = guint32
-  PGQuark* = ptr TGQuark
-  PGTypeCValue* = ptr TGTypeCValue
-  TGTypeCValue*{.final.} = object 
-    v_double*: gdouble
-
-  GType* = gulong
-  PGType* = ptr GType
-  PGTypeClass* = ptr TGTypeClass
-  TGTypeClass*{.final.} = object 
-    g_type*: GType
-
-  PGTypeInstance* = ptr TGTypeInstance
-  TGTypeInstance*{.final.} = object 
-    g_class*: PGTypeClass
-
-  PGTypeInterface* = ptr TGTypeInterface
-  TGTypeInterface*{.pure.} = object 
-    g_type*: GType
-    g_instance_type*: GType
-
-  PGTypeQuery* = ptr TGTypeQuery
-  TGTypeQuery*{.final.} = object 
-    theType*: GType
-    type_name*: cstring
-    class_size*: guint
-    instance_size*: guint
-
-  PGValue* = ptr TGValue
-  TGValue*{.final.} = object 
-    g_type*: GType
-    data*: array[0..1, gdouble]
-
-  PGData* = pointer
-  PPGData* = ptr PGData
-  PGSList* = ptr TGSList
-  PPGSList* = ptr PGSList
-  TGSList*{.final.} = object 
-    data*: gpointer
-    next*: PGSList
-
-  PGList* = ptr TGList
-  TGList*{.final.} = object 
-    data*: gpointer
-    next*: PGList
-    prev*: PGList
-
-  TGParamFlags* = int32
-  PGParamFlags* = ptr TGParamFlags
-  PGParamSpec* = ptr TGParamSpec
-  PPGParamSpec* = ptr PGParamSpec
-  TGParamSpec*{.final.} = object 
-    g_type_instance*: TGTypeInstance
-    name*: cstring
-    flags*: TGParamFlags
-    value_type*: GType
-    owner_type*: GType
-    nick*: cstring
-    blurb*: cstring
-    qdata*: PGData
-    ref_count*: guint
-    param_id*: guint
-
-  PGParamSpecClass* = ptr TGParamSpecClass
-  TGParamSpecClass*{.final.} = object 
-    g_type_class*: TGTypeClass
-    value_type*: GType
-    finalize*: proc (pspec: PGParamSpec){.cdecl.}
-    value_set_default*: proc (pspec: PGParamSpec, value: PGValue){.cdecl.}
-    value_validate*: proc (pspec: PGParamSpec, value: PGValue): gboolean{.cdecl.}
-    values_cmp*: proc (pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-        cdecl.}
-    dummy*: array[0..3, gpointer]
-
-  PGParameter* = ptr TGParameter
-  TGParameter*{.final.} = object 
-    name*: cstring
-    value*: TGValue
-
-  TGBoxedCopyFunc* = proc (boxed: gpointer): gpointer{.cdecl.}
-  TGBoxedFreeFunc* = proc (boxed: gpointer){.cdecl.}
-  PGsource = pointer          # I don't know and don't care
-
-const 
-  G_TYPE_FUNDAMENTAL_SHIFT* = 2
-  G_TYPE_FUNDAMENTAL_MAX* = 255 shl G_TYPE_FUNDAMENTAL_SHIFT
-  G_TYPE_INVALID* = GType(0 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_NONE* = GType(1 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INTERFACE* = GType(2 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_CHAR* = GType(3 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UCHAR* = GType(4 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_BOOLEAN* = GType(5 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INT* = GType(6 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UINT* = GType(7 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_LONG* = GType(8 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_ULONG* = GType(9 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_INT64* = GType(10 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_UINT64* = GType(11 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_ENUM* = GType(12 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_FLAGS* = GType(13 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_FLOAT* = GType(14 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_DOUBLE* = GType(15 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_STRING* = GType(16 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_POINTER* = GType(17 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_BOXED* = GType(18 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_PARAM* = GType(19 shl G_TYPE_FUNDAMENTAL_SHIFT)
-  G_TYPE_OBJECT* = GType(20 shl G_TYPE_FUNDAMENTAL_SHIFT)
-
-proc G_TYPE_MAKE_FUNDAMENTAL*(x: int): GType
-const 
-  G_TYPE_RESERVED_GLIB_FIRST* = 21
-  G_TYPE_RESERVED_GLIB_LAST* = 31
-  G_TYPE_RESERVED_BSE_FIRST* = 32
-  G_TYPE_RESERVED_BSE_LAST* = 48
-  G_TYPE_RESERVED_USER_FIRST* = 49
-
-proc G_TYPE_IS_FUNDAMENTAL*(theType: GType): bool
-proc G_TYPE_IS_DERIVED*(theType: GType): bool
-proc G_TYPE_IS_INTERFACE*(theType: GType): bool
-proc G_TYPE_IS_CLASSED*(theType: GType): gboolean
-proc G_TYPE_IS_INSTANTIATABLE*(theType: GType): bool
-proc G_TYPE_IS_DERIVABLE*(theType: GType): bool
-proc G_TYPE_IS_DEEP_DERIVABLE*(theType: GType): bool
-proc G_TYPE_IS_ABSTRACT*(theType: GType): bool
-proc G_TYPE_IS_VALUE_ABSTRACT*(theType: GType): bool
-proc G_TYPE_IS_VALUE_TYPE*(theType: GType): bool
-proc G_TYPE_HAS_VALUE_TABLE*(theType: GType): bool
-proc G_TYPE_CHECK_INSTANCE*(instance: Pointer): gboolean
-proc G_TYPE_CHECK_INSTANCE_CAST*(instance: Pointer, g_type: GType): PGTypeInstance
-proc G_TYPE_CHECK_INSTANCE_TYPE*(instance: Pointer, g_type: GType): bool
-proc G_TYPE_INSTANCE_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass
-proc G_TYPE_INSTANCE_GET_INTERFACE*(instance: Pointer, g_type: GType): Pointer
-proc G_TYPE_CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer
-proc G_TYPE_CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool
-proc G_TYPE_CHECK_VALUE*(value: Pointer): bool
-proc G_TYPE_CHECK_VALUE_TYPE*(value: pointer, g_type: GType): bool
-proc G_TYPE_FROM_INSTANCE*(instance: Pointer): GType
-proc G_TYPE_FROM_CLASS*(g_class: Pointer): GType
-proc G_TYPE_FROM_INTERFACE*(g_iface: Pointer): GType
-type 
-  TGTypeDebugFlags* = int32
-  PGTypeDebugFlags* = ptr TGTypeDebugFlags
-
-const 
-  G_TYPE_DEBUG_NONE* = 0
-  G_TYPE_DEBUG_OBJECTS* = 1 shl 0
-  G_TYPE_DEBUG_SIGNALS* = 1 shl 1
-  G_TYPE_DEBUG_MASK* = 0x00000003
-
-proc g_type_init*(){.cdecl, dynlib: gobjectlib, importc: "g_type_init".}
-proc g_type_init*(debug_flags: TGTypeDebugFlags){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_init_with_debug_flags".}
-proc g_type_name*(theType: GType): cstring{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_name".}
-proc g_type_qname*(theType: GType): TGQuark{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_qname".}
-proc g_type_from_name*(name: cstring): GType{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_from_name".}
-proc g_type_parent*(theType: GType): GType{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_parent".}
-proc g_type_depth*(theType: GType): guint{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_depth".}
-proc g_type_next_base*(leaf_type: GType, root_type: GType): GType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_next_base".}
-proc g_type_is_a*(theType: GType, is_a_type: GType): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_is_a".}
-proc g_type_class_ref*(theType: GType): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_class_ref".}
-proc g_type_class_peek*(theType: GType): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_class_peek".}
-proc g_type_class_unref*(g_class: gpointer){.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_class_unref".}
-proc g_type_class_peek_parent*(g_class: gpointer): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_class_peek_parent".}
-proc g_type_interface_peek*(instance_class: gpointer, iface_type: GType): gpointer{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_interface_peek".}
-proc g_type_interface_peek_parent*(g_iface: gpointer): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_interface_peek_parent".}
-proc g_type_children*(theType: GType, n_children: Pguint): PGType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_children".}
-proc g_type_interfaces*(theType: GType, n_interfaces: Pguint): PGType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_interfaces".}
-proc g_type_set_qdata*(theType: GType, quark: TGQuark, data: gpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_set_qdata".}
-proc g_type_get_qdata*(theType: GType, quark: TGQuark): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_get_qdata".}
-proc g_type_query*(theType: GType, query: PGTypeQuery){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_query".}
-type 
-  TGBaseInitFunc* = proc (g_class: gpointer){.cdecl.}
-  TGBaseFinalizeFunc* = proc (g_class: gpointer){.cdecl.}
-  TGClassInitFunc* = proc (g_class: gpointer, class_data: gpointer){.cdecl.}
-  TGClassFinalizeFunc* = proc (g_class: gpointer, class_data: gpointer){.cdecl.}
-  TGInstanceInitFunc* = proc (instance: PGTypeInstance, g_class: gpointer){.
-      cdecl.}
-  TGInterfaceInitFunc* = proc (g_iface: gpointer, iface_data: gpointer){.cdecl.}
-  TGInterfaceFinalizeFunc* = proc (g_iface: gpointer, iface_data: gpointer){.
-      cdecl.}
-  TGTypeClassCacheFunc* = proc (cache_data: gpointer, g_class: PGTypeClass): gboolean{.
-      cdecl.}
-  TGTypeFundamentalFlags* = int32
-  PGTypeFundamentalFlags* = ptr TGTypeFundamentalFlags
-
-const 
-  G_TYPE_FLAG_CLASSED* = 1 shl 0
-  G_TYPE_FLAG_INSTANTIATABLE* = 1 shl 1
-  G_TYPE_FLAG_DERIVABLE* = 1 shl 2
-  G_TYPE_FLAG_DEEP_DERIVABLE* = 1 shl 3
-
-type 
-  TGTypeFlags* = int32
-  PGTypeFlags* = ptr TGTypeFlags
-
-const 
-  G_TYPE_FLAG_ABSTRACT* = 1 shl 4
-  G_TYPE_FLAG_VALUE_ABSTRACT* = 1 shl 5
-
-type 
-  PGTypeValueTable* = ptr TGTypeValueTable
-  TGTypeValueTable*{.final.} = object 
-    value_init*: proc (value: PGValue){.cdecl.}
-    value_free*: proc (value: PGValue){.cdecl.}
-    value_copy*: proc (src_value: PGValue, dest_value: PGValue){.cdecl.}
-    value_peek_pointer*: proc (value: PGValue): gpointer{.cdecl.}
-    collect_format*: cstring
-    collect_value*: proc (value: PGValue, n_collect_values: guint, 
-                          collect_values: PGTypeCValue, collect_flags: guint): cstring{.
-        cdecl.}
-    lcopy_format*: cstring
-    lcopy_value*: proc (value: PGValue, n_collect_values: guint, 
-                        collect_values: PGTypeCValue, collect_flags: guint): cstring{.
-        cdecl.}
-
-  PGTypeInfo* = ptr TGTypeInfo
-  TGTypeInfo*{.final.} = object 
-    class_size*: guint16
-    base_init*: TGBaseInitFunc
-    base_finalize*: TGBaseFinalizeFunc
-    class_init*: TGClassInitFunc
-    class_finalize*: TGClassFinalizeFunc
-    class_data*: gconstpointer
-    instance_size*: guint16
-    n_preallocs*: guint16
-    instance_init*: TGInstanceInitFunc
-    value_table*: PGTypeValueTable
-
-  PGTypeFundamentalInfo* = ptr TGTypeFundamentalInfo
-  TGTypeFundamentalInfo*{.final.} = object 
-    type_flags*: TGTypeFundamentalFlags
-
-  PGInterfaceInfo* = ptr TGInterfaceInfo
-  TGInterfaceInfo*{.final.} = object 
-    interface_init*: TGInterfaceInitFunc
-    interface_finalize*: TGInterfaceFinalizeFunc
-    interface_data*: gpointer
-
-
-proc g_type_register_static*(parent_type: GType, type_name: cstring, 
-                             info: PGTypeInfo, flags: TGTypeFlags): GType{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_register_static".}
-proc g_type_register_dynamic*(parent_type: GType, type_name: cstring, 
-                              plugin: PGTypePlugin, flags: TGTypeFlags): GType{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_register_dynamic".}
-proc g_type_register_fundamental*(type_id: GType, type_name: cstring, 
-                                  info: PGTypeInfo, 
-                                  finfo: PGTypeFundamentalInfo, 
-                                  flags: TGTypeFlags): GType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_register_fundamental".}
-proc g_type_add_interface_static*(instance_type: GType, interface_type: GType, 
-                                  info: PGInterfaceInfo){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_add_interface_static".}
-proc g_type_add_interface_dynamic*(instance_type: GType, interface_type: GType, 
-                                   plugin: PGTypePlugin){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_add_interface_dynamic".}
-proc g_type_interface_add_prerequisite*(interface_type: GType, 
-                                        prerequisite_type: GType){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_interface_add_prerequisite".}
-proc g_type_get_plugin*(theType: GType): PGTypePlugin{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_get_plugin".}
-proc g_type_interface_get_plugin*(instance_type: GType, 
-                                  implementation_type: GType): PGTypePlugin{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_interface_get_plugin".}
-proc g_type_fundamental_next*(): GType{.cdecl, dynlib: gobjectlib, 
-                                        importc: "g_type_fundamental_next".}
-proc g_type_fundamental*(type_id: GType): GType{.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_fundamental".}
-proc g_type_create_instance*(theType: GType): PGTypeInstance{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_create_instance".}
-proc free_instance*(instance: PGTypeInstance){.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_free_instance".}
-proc g_type_add_class_cache_func*(cache_data: gpointer, 
-                                  cache_func: TGTypeClassCacheFunc){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_add_class_cache_func".}
-proc g_type_remove_class_cache_func*(cache_data: gpointer, 
-                                     cache_func: TGTypeClassCacheFunc){.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_remove_class_cache_func".}
-proc g_type_class_unref_uncached*(g_class: gpointer){.cdecl, dynlib: gobjectlib, 
-    importc: "g_type_class_unref_uncached".}
-proc g_type_value_table_peek*(theType: GType): PGTypeValueTable{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_value_table_peek".}
-proc private_g_type_check_instance*(instance: PGTypeInstance): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_check_instance".}
-proc private_g_type_check_instance_cast*(instance: PGTypeInstance, 
-    iface_type: GType): PGTypeInstance{.cdecl, dynlib: gobjectlib, 
-                                        importc: "g_type_check_instance_cast".}
-proc private_g_type_check_instance_is_a*(instance: PGTypeInstance, 
-    iface_type: GType): gboolean{.cdecl, dynlib: gobjectlib, 
-                                  importc: "g_type_check_instance_is_a".}
-proc private_g_type_check_class_cast*(g_class: PGTypeClass, is_a_type: GType): PGTypeClass{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_class_cast".}
-proc private_g_type_check_class_is_a*(g_class: PGTypeClass, is_a_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_class_is_a".}
-proc private_g_type_check_is_value_type*(theType: GType): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_check_is_value_type".}
-proc private_g_type_check_value*(value: PGValue): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_check_value".}
-proc private_g_type_check_value_holds*(value: PGValue, theType: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_type_check_value_holds".}
-proc private_g_type_test_flags*(theType: GType, flags: guint): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_test_flags".}
-proc name_from_instance*(instance: PGTypeInstance): cstring{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_name_from_instance".}
-proc name_from_class*(g_class: PGTypeClass): cstring{.cdecl, 
-    dynlib: gobjectlib, importc: "g_type_name_from_class".}
-const 
-  G_TYPE_FLAG_RESERVED_ID_BIT* = GType(1 shl 0)
-
-proc G_TYPE_IS_VALUE*(theType: GType): bool
-proc G_IS_VALUE*(value: pointer): bool
-proc G_VALUE_TYPE*(value: Pointer): GType
-proc G_VALUE_TYPE_NAME*(value: Pointer): cstring
-proc G_VALUE_HOLDS*(value: pointer, g_type: GType): bool
-type 
-  TGValueTransform* = proc (src_value: PGValue, dest_value: PGValue){.cdecl.}
-
-proc init*(value: PGValue, g_type: GType): PGValue{.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_init".}
-proc copy*(src_value: PGValue, dest_value: PGValue){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_copy".}
-proc reset*(value: PGValue): PGValue{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_reset".}
-proc unset*(value: PGValue){.cdecl, dynlib: gobjectlib, 
-                                     importc: "g_value_unset".}
-proc set_instance*(value: PGValue, instance: gpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_instance".}
-proc fits_pointer*(value: PGValue): gboolean{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_fits_pointer".}
-proc peek_pointer*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_peek_pointer".}
-proc g_value_type_compatible*(src_type: GType, dest_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_type_compatible".}
-proc g_value_type_transformable*(src_type: GType, dest_type: GType): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_type_transformable".}
-proc transform*(src_value: PGValue, dest_value: PGValue): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_transform".}
-proc g_value_register_transform_func*(src_type: GType, dest_type: GType, 
-                                      transform_func: TGValueTransform){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_register_transform_func".}
-const 
-  G_VALUE_NOCOPY_CONTENTS* = 1 shl 27
-
-type 
-  PGValueArray* = ptr TGValueArray
-  TGValueArray*{.final.} = object 
-    n_values*: guint
-    values*: PGValue
-    n_prealloced*: guint
-
-
-proc array_get_nth*(value_array: PGValueArray, index: guint): PGValue{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_get_nth".}
-proc g_value_array_new*(n_prealloced: guint): PGValueArray{.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_array_new".}
-proc array_free*(value_array: PGValueArray){.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_array_free".}
-proc array_copy*(value_array: PGValueArray): PGValueArray{.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_array_copy".}
-proc array_prepend*(value_array: PGValueArray, value: PGValue): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_prepend".}
-proc array_append*(value_array: PGValueArray, value: PGValue): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_append".}
-proc array_insert*(value_array: PGValueArray, index: guint, 
-                           value: PGValue): PGValueArray{.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_array_insert".}
-proc array_remove*(value_array: PGValueArray, index: guint): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_remove".}
-proc array_sort*(value_array: PGValueArray, compare_func: TGCompareFunc): PGValueArray{.
-    cdecl, dynlib: gobjectlib, importc: "g_value_array_sort".}
-proc array_sort*(value_array: PGValueArray, 
-                                   compare_func: TGCompareDataFunc, 
-                                   user_data: gpointer): PGValueArray{.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_array_sort_with_data".}
-const 
-  G_VALUE_COLLECT_INT* = 'i'
-  G_VALUE_COLLECT_LONG* = 'l'
-  G_VALUE_COLLECT_INT64* = 'q'
-  G_VALUE_COLLECT_DOUBLE* = 'd'
-  G_VALUE_COLLECT_POINTER* = 'p'
-  G_VALUE_COLLECT_FORMAT_MAX_LENGTH* = 8
-
-proc HOLDS_CHAR*(value: PGValue): bool
-proc HOLDS_UCHAR*(value: PGValue): bool
-proc HOLDS_BOOLEAN*(value: PGValue): bool
-proc HOLDS_INT*(value: PGValue): bool
-proc HOLDS_UINT*(value: PGValue): bool
-proc HOLDS_LONG*(value: PGValue): bool
-proc HOLDS_ULONG*(value: PGValue): bool
-proc HOLDS_INT64*(value: PGValue): bool
-proc HOLDS_UINT64*(value: PGValue): bool
-proc HOLDS_FLOAT*(value: PGValue): bool
-proc HOLDS_DOUBLE*(value: PGValue): bool
-proc HOLDS_STRING*(value: PGValue): bool
-proc HOLDS_POINTER*(value: PGValue): bool
-proc set_char*(value: PGValue, v_char: gchar){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_char".}
-proc get_char*(value: PGValue): gchar{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_char".}
-proc set_uchar*(value: PGValue, v_uchar: guchar){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_uchar".}
-proc get_uchar*(value: PGValue): guchar{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_uchar".}
-proc set_boolean*(value: PGValue, v_boolean: gboolean){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_boolean".}
-proc get_boolean*(value: PGValue): gboolean{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_boolean".}
-proc set_int*(value: PGValue, v_int: gint){.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_set_int".}
-proc get_int*(value: PGValue): gint{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_int".}
-proc set_uint*(value: PGValue, v_uint: guint){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_uint".}
-proc get_uint*(value: PGValue): guint{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_uint".}
-proc set_long*(value: PGValue, v_long: glong){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_long".}
-proc get_long*(value: PGValue): glong{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_long".}
-proc set_ulong*(value: PGValue, v_ulong: gulong){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_ulong".}
-proc get_ulong*(value: PGValue): gulong{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_ulong".}
-proc set_int64*(value: PGValue, v_int64: gint64){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_int64".}
-proc get_int64*(value: PGValue): gint64{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_int64".}
-proc set_uint64*(value: PGValue, v_uint64: guint64){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_uint64".}
-proc get_uint64*(value: PGValue): guint64{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_uint64".}
-proc set_float*(value: PGValue, v_float: gfloat){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_float".}
-proc get_float*(value: PGValue): gfloat{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_float".}
-proc set_double*(value: PGValue, v_double: gdouble){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_double".}
-proc get_double*(value: PGValue): gdouble{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_double".}
-proc set_string*(value: PGValue, v_string: cstring){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_string".}
-proc set_static_string*(value: PGValue, v_string: cstring){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_static_string".}
-proc get_string*(value: PGValue): cstring{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_string".}
-proc dup_string*(value: PGValue): cstring{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_dup_string".}
-proc set_pointer*(value: PGValue, v_pointer: gpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_pointer".}
-proc get_pointer*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_pointer".}
-proc g_pointer_type_register_static*(name: cstring): GType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_pointer_type_register_static".}
-proc strdup_value_contents*(value: PGValue): cstring{.cdecl, 
-    dynlib: gobjectlib, importc: "g_strdup_value_contents".}
-proc set_string_take_ownership*(value: PGValue, v_string: cstring){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_string_take_ownership".}
-type 
-  Tgchararray* = gchar
-  Pgchararray* = ptr Tgchararray
-
-proc G_TYPE_IS_PARAM*(theType: GType): bool
-proc G_PARAM_SPEC*(pspec: Pointer): PGParamSpec
-proc G_IS_PARAM_SPEC*(pspec: Pointer): bool
-proc G_PARAM_SPEC_CLASS*(pclass: Pointer): PGParamSpecClass
-proc G_IS_PARAM_SPEC_CLASS*(pclass: Pointer): bool
-proc G_PARAM_SPEC_GET_CLASS*(pspec: Pointer): PGParamSpecClass
-proc G_PARAM_SPEC_TYPE*(pspec: Pointer): GType
-proc G_PARAM_SPEC_TYPE_NAME*(pspec: Pointer): cstring
-proc G_PARAM_SPEC_VALUE_TYPE*(pspec: Pointer): GType
-proc G_VALUE_HOLDS_PARAM*(value: Pointer): bool
-const 
-  G_PARAM_READABLE* = 1 shl 0
-  G_PARAM_WRITABLE* = 1 shl 1
-  G_PARAM_CONSTRUCT* = 1 shl 2
-  G_PARAM_CONSTRUCT_ONLY* = 1 shl 3
-  G_PARAM_LAX_VALIDATION* = 1 shl 4
-  G_PARAM_PRIVATE* = 1 shl 5
-  G_PARAM_READWRITE* = G_PARAM_READABLE or G_PARAM_WRITABLE
-  G_PARAM_MASK* = 0x000000FF
-  G_PARAM_USER_SHIFT* = 8
-
-proc spec_ref*(pspec: PGParamSpec): PGParamSpec{.cdecl, dynlib: gliblib, 
-    importc: "g_param_spec_ref".}
-proc spec_unref*(pspec: PGParamSpec){.cdecl, dynlib: gliblib, 
-    importc: "g_param_spec_unref".}
-proc spec_sink*(pspec: PGParamSpec){.cdecl, dynlib: gliblib, 
-    importc: "g_param_spec_sink".}
-proc spec_get_qdata*(pspec: PGParamSpec, quark: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_get_qdata".}
-proc spec_set_qdata*(pspec: PGParamSpec, quark: TGQuark, data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_set_qdata".}
-proc spec_set_qdata_full*(pspec: PGParamSpec, quark: TGQuark, 
-                                  data: gpointer, destroy: TGDestroyNotify){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_set_qdata_full".}
-proc spec_steal_qdata*(pspec: PGParamSpec, quark: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_steal_qdata".}
-proc value_set_default*(pspec: PGParamSpec, value: PGValue){.cdecl, 
-    dynlib: gliblib, importc: "g_param_value_set_default".}
-proc value_defaults*(pspec: PGParamSpec, value: PGValue): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_defaults".}
-proc value_validate*(pspec: PGParamSpec, value: PGValue): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_validate".}
-proc value_convert*(pspec: PGParamSpec, src_value: PGValue, 
-                            dest_value: PGValue, strict_validation: gboolean): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_param_value_convert".}
-proc values_cmp*(pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-    cdecl, dynlib: gliblib, importc: "g_param_values_cmp".}
-proc spec_get_name*(pspec: PGParamSpec): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_param_spec_get_name".}
-proc spec_get_nick*(pspec: PGParamSpec): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_param_spec_get_nick".}
-proc spec_get_blurb*(pspec: PGParamSpec): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_param_spec_get_blurb".}
-proc set_param*(value: PGValue, param: PGParamSpec){.cdecl, 
-    dynlib: gliblib, importc: "g_value_set_param".}
-proc get_param*(value: PGValue): PGParamSpec{.cdecl, dynlib: gliblib, 
-    importc: "g_value_get_param".}
-proc dup_param*(value: PGValue): PGParamSpec{.cdecl, dynlib: gliblib, 
-    importc: "g_value_dup_param".}
-proc set_param_take_ownership*(value: PGValue, param: PGParamSpec){.
-    cdecl, dynlib: gliblib, importc: "g_value_set_param_take_ownership".}
-type 
-  PGParamSpecTypeInfo* = ptr TGParamSpecTypeInfo
-  TGParamSpecTypeInfo*{.final.} = object 
-    instance_size*: guint16
-    n_preallocs*: guint16
-    instance_init*: proc (pspec: PGParamSpec){.cdecl.}
-    value_type*: GType
-    finalize*: proc (pspec: PGParamSpec){.cdecl.}
-    value_set_default*: proc (pspec: PGParamSpec, value: PGValue){.cdecl.}
-    value_validate*: proc (pspec: PGParamSpec, value: PGValue): gboolean{.cdecl.}
-    values_cmp*: proc (pspec: PGParamSpec, value1: PGValue, value2: PGValue): gint{.
-        cdecl.}
-
-
-proc g_param_type_register_static*(name: cstring, 
-                                   pspec_info: PGParamSpecTypeInfo): GType{.
-    cdecl, dynlib: gliblib, importc: "g_param_type_register_static".}
-proc g_param_type_register_static_constant*(name: cstring, 
-    pspec_info: PGParamSpecTypeInfo, opt_type: GType): GType{.cdecl, 
-    dynlib: gliblib, importc: "`g_param_type_register_static_constant`".}
-proc g_param_spec_internal*(param_type: GType, name: cstring, nick: cstring, 
-                            blurb: cstring, flags: TGParamFlags): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_internal".}
-proc g_param_spec_pool_new*(type_prefixing: gboolean): PGParamSpecPool{.cdecl, 
-    dynlib: gliblib, importc: "g_param_spec_pool_new".}
-proc spec_pool_insert*(pool: PGParamSpecPool, pspec: PGParamSpec, 
-                               owner_type: GType){.cdecl, dynlib: gliblib, 
-    importc: "g_param_spec_pool_insert".}
-proc spec_pool_remove*(pool: PGParamSpecPool, pspec: PGParamSpec){.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_remove".}
-proc spec_pool_lookup*(pool: PGParamSpecPool, param_name: cstring, 
-                               owner_type: GType, walk_ancestors: gboolean): PGParamSpec{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_lookup".}
-proc spec_pool_list_owned*(pool: PGParamSpecPool, owner_type: GType): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_param_spec_pool_list_owned".}
-proc spec_pool_list*(pool: PGParamSpecPool, owner_type: GType, 
-                             n_pspecs_p: Pguint): PPGParamSpec{.cdecl, 
-    dynlib: gliblib, importc: "g_param_spec_pool_list".}
-type 
-  PGClosure* = ptr TGClosure
-  PGClosureNotifyData* = ptr TGClosureNotifyData
-  TGClosureNotify* = proc (data: gpointer, closure: PGClosure){.cdecl.}
-  TGClosure*{.final.} = object 
-    flag0*: int32
-    marshal*: proc (closure: PGClosure, return_value: PGValue, 
-                    n_param_values: guint, param_values: PGValue, 
-                    invocation_hint, marshal_data: gpointer){.cdecl.}
-    data*: gpointer
-    notifiers*: PGClosureNotifyData
-
-  TGCallBackProcedure* = proc (){.cdecl.}
-  TGCallback* = proc (){.cdecl.}
-  TGClosureMarshal* = proc (closure: PGClosure, return_value: PGValue, 
-                            n_param_values: guint, param_values: PGValue, 
-                            invocation_hint: gpointer, marshal_data: gpointer){.
-      cdecl.}
-  TGClosureNotifyData*{.final.} = object 
-    data*: gpointer
-    notify*: TGClosureNotify
-
-
-proc G_CLOSURE_NEEDS_MARSHAL*(closure: Pointer): bool
-proc N_NOTIFIERS*(cl: PGClosure): int32
-proc CCLOSURE_SWAP_DATA*(cclosure: PGClosure): int32
-proc G_CALLBACK*(f: pointer): TGCallback
-const 
-  bm_TGClosure_ref_count* = 0x00007FFF'i32
-  bp_TGClosure_ref_count* = 0'i32
-  bm_TGClosure_meta_marshal* = 0x00008000'i32
-  bp_TGClosure_meta_marshal* = 15'i32
-  bm_TGClosure_n_guards* = 0x00010000'i32
-  bp_TGClosure_n_guards* = 16'i32
-  bm_TGClosure_n_fnotifiers* = 0x00060000'i32
-  bp_TGClosure_n_fnotifiers* = 17'i32
-  bm_TGClosure_n_inotifiers* = 0x07F80000'i32
-  bp_TGClosure_n_inotifiers* = 19'i32
-  bm_TGClosure_in_inotify* = 0x08000000'i32
-  bp_TGClosure_in_inotify* = 27'i32
-  bm_TGClosure_floating* = 0x10000000'i32
-  bp_TGClosure_floating* = 28'i32
-  bm_TGClosure_derivative_flag* = 0x20000000'i32
-  bp_TGClosure_derivative_flag* = 29'i32
-  bm_TGClosure_in_marshal* = 0x40000000'i32
-  bp_TGClosure_in_marshal* = 30'i32
-  bm_TGClosure_is_invalid* = 0x80000000'i32
-  bp_TGClosure_is_invalid* = 31'i32
-
-proc ref_count*(a: PGClosure): guint
-proc set_ref_count*(a: PGClosure, ref_count: guint)
-proc meta_marshal*(a: PGClosure): guint
-proc set_meta_marshal*(a: PGClosure, meta_marshal: guint)
-proc n_guards*(a: PGClosure): guint
-proc set_n_guards*(a: PGClosure, n_guards: guint)
-proc n_fnotifiers*(a: PGClosure): guint
-proc set_n_fnotifiers*(a: PGClosure, n_fnotifiers: guint)
-proc n_inotifiers*(a: PGClosure): guint
-proc in_inotify*(a: PGClosure): guint
-proc set_in_inotify*(a: PGClosure, in_inotify: guint)
-proc floating*(a: PGClosure): guint
-proc set_floating*(a: PGClosure, floating: guint)
-proc derivative_flag*(a: PGClosure): guint
-proc set_derivative_flag*(a: PGClosure, derivative_flag: guint)
-proc in_marshal*(a: PGClosure): guint
-proc set_in_marshal*(a: PGClosure, in_marshal: guint)
-proc is_invalid*(a: PGClosure): guint
-proc set_is_invalid*(a: PGClosure, is_invalid: guint)
-type 
-  PGCClosure* = ptr TGCClosure
-  TGCClosure*{.final.} = object 
-    closure*: TGClosure
-    callback*: gpointer
-
-
-proc g_cclosure_new*(callback_func: TGCallback, user_data: gpointer, 
-                     destroy_data: TGClosureNotify): PGClosure{.cdecl, 
-    dynlib: gliblib, importc: "g_cclosure_new".}
-proc g_cclosure_new_swap*(callback_func: TGCallback, user_data: gpointer, 
-                          destroy_data: TGClosureNotify): PGClosure{.cdecl, 
-    dynlib: gliblib, importc: "g_cclosure_new_swap".}
-proc g_signal_type_cclosure_new*(itype: GType, struct_offset: guint): PGClosure{.
-    cdecl, dynlib: gliblib, importc: "g_signal_type_cclosure_new".}
-proc reference*(closure: PGClosure): PGClosure{.cdecl, dynlib: gliblib, 
-    importc: "g_closure_ref".}
-proc sink*(closure: PGClosure){.cdecl, dynlib: gliblib, 
-    importc: "g_closure_sink".}
-proc unref*(closure: PGClosure){.cdecl, dynlib: gliblib, 
-    importc: "g_closure_unref".}
-proc g_closure_new_simple*(sizeof_closure: guint, data: gpointer): PGClosure{.
-    cdecl, dynlib: gliblib, importc: "g_closure_new_simple".}
-proc add_finalize_notifier*(closure: PGClosure, notify_data: gpointer, 
-                                      notify_func: TGClosureNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_add_finalize_notifier".}
-proc remove_finalize_notifier*(closure: PGClosure, 
-    notify_data: gpointer, notify_func: TGClosureNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_remove_finalize_notifier".}
-proc add_invalidate_notifier*(closure: PGClosure, 
-                                        notify_data: gpointer, 
-                                        notify_func: TGClosureNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_add_invalidate_notifier".}
-proc remove_invalidate_notifier*(closure: PGClosure, 
-    notify_data: gpointer, notify_func: TGClosureNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_remove_invalidate_notifier".}
-proc add_marshal_guards*(closure: PGClosure, 
-                                   pre_marshal_data: gpointer, 
-                                   pre_marshal_notify: TGClosureNotify, 
-                                   post_marshal_data: gpointer, 
-                                   post_marshal_notify: TGClosureNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_add_marshal_guards".}
-proc set_marshal*(closure: PGClosure, marshal: TGClosureMarshal){.
-    cdecl, dynlib: gliblib, importc: "g_closure_set_marshal".}
-proc set_meta_marshal*(closure: PGClosure, marshal_data: gpointer, 
-                                 meta_marshal: TGClosureMarshal){.cdecl, 
-    dynlib: gliblib, importc: "g_closure_set_meta_marshal".}
-proc invalidate*(closure: PGClosure){.cdecl, dynlib: gliblib, 
-    importc: "g_closure_invalidate".}
-proc invoke*(closure: PGClosure, return_value: PGValue, 
-                       n_param_values: guint, param_values: PGValue, 
-                       invocation_hint: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_closure_invoke".}
-type 
-  PGSignalInvocationHint* = ptr TGSignalInvocationHint
-  PGSignalCMarshaller* = ptr TGSignalCMarshaller
-  TGSignalCMarshaller* = TGClosureMarshal
-  TGSignalEmissionHook* = proc (ihint: PGSignalInvocationHint, 
-                                n_param_values: guint, param_values: PGValue, 
-                                data: gpointer): gboolean{.cdecl.}
-  TGSignalAccumulator* = proc (ihint: PGSignalInvocationHint, 
-                               return_accu: PGValue, handler_return: PGValue, 
-                               data: gpointer): gboolean{.cdecl.}
-  PGSignalFlags* = ptr TGSignalFlags
-  TGSignalFlags* = int32
-  TGSignalInvocationHint*{.final.} = object 
-    signal_id*: guint
-    detail*: TGQuark
-    run_type*: TGSignalFlags
-
-  PGSignalQuery* = ptr TGSignalQuery
-  TGSignalQuery*{.final.} = object 
-    signal_id*: guint
-    signal_name*: cstring
-    itype*: GType
-    signal_flags*: TGSignalFlags
-    return_type*: GType
-    n_params*: guint
-    param_types*: PGType
-
-
-const 
-  G_SIGNAL_RUN_FIRST* = 1 shl 0
-  G_SIGNAL_RUN_LAST* = 1 shl 1
-  G_SIGNAL_RUN_CLEANUP* = 1 shl 2
-  G_SIGNAL_NO_RECURSE* = 1 shl 3
-  G_SIGNAL_DETAILED* = 1 shl 4
-  G_SIGNAL_ACTION* = 1 shl 5
-  G_SIGNAL_NO_HOOKS* = 1 shl 6
-  G_SIGNAL_FLAGS_MASK* = 0x0000007F
-
-type 
-  PGConnectFlags* = ptr TGConnectFlags
-  TGConnectFlags* = int32
-
-const 
-  G_CONNECT_AFTER* = 1 shl 0
-  G_CONNECT_SWAPPED* = 1 shl 1
-
-type 
-  PGSignalMatchType* = ptr TGSignalMatchType
-  TGSignalMatchType* = int32
-
-const 
-  G_SIGNAL_MATCH_ID* = 1 shl 0
-  G_SIGNAL_MATCH_DETAIL* = 1 shl 1
-  G_SIGNAL_MATCH_CLOSURE* = 1 shl 2
-  G_SIGNAL_MATCH_FUNC* = 1 shl 3
-  G_SIGNAL_MATCH_DATA* = 1 shl 4
-  G_SIGNAL_MATCH_UNBLOCKED* = 1 shl 5
-  G_SIGNAL_MATCH_MASK* = 0x0000003F
-  G_SIGNAL_TYPE_STATIC_SCOPE* = G_TYPE_FLAG_RESERVED_ID_BIT
-
-proc g_signal_newv*(signal_name: cstring, itype: GType, 
-                    signal_flags: TGSignalFlags, class_closure: PGClosure, 
-                    accumulator: TGSignalAccumulator, accu_data: gpointer, 
-                    c_marshaller: TGSignalCMarshaller, return_type: GType, 
-                    n_params: guint, param_types: PGType): guint{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_newv".}
-proc signal_emitv*(instance_and_params: PGValue, signal_id: guint, 
-                     detail: TGQuark, return_value: PGValue){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_emitv".}
-proc g_signal_lookup*(name: cstring, itype: GType): guint{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_lookup".}
-proc g_signal_name*(signal_id: guint): cstring{.cdecl, dynlib: gobjectlib, 
-    importc: "g_signal_name".}
-proc g_signal_query*(signal_id: guint, query: PGSignalQuery){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_query".}
-proc g_signal_list_ids*(itype: GType, n_ids: Pguint): Pguint{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_list_ids".}
-proc g_signal_parse_name*(detailed_signal: cstring, itype: GType, 
-                          signal_id_p: Pguint, detail_p: PGQuark, 
-                          force_detail_quark: gboolean): gboolean{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_parse_name".}
-proc g_signal_get_invocation_hint*(instance: gpointer): PGSignalInvocationHint{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_get_invocation_hint".}
-proc g_signal_stop_emission*(instance: gpointer, signal_id: guint, 
-                             detail: TGQuark){.cdecl, dynlib: gobjectlib, 
-    importc: "g_signal_stop_emission".}
-proc g_signal_stop_emission_by_name*(instance: gpointer, 
-                                     detailed_signal: cstring){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_stop_emission_by_name".}
-proc g_signal_add_emission_hook*(signal_id: guint, quark: TGQuark, 
-                                 hook_func: TGSignalEmissionHook, 
-                                 hook_data: gpointer, 
-                                 data_destroy: TGDestroyNotify): gulong{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_add_emission_hook".}
-proc g_signal_remove_emission_hook*(signal_id: guint, hook_id: gulong){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_remove_emission_hook".}
-proc g_signal_has_handler_pending*(instance: gpointer, signal_id: guint, 
-                                   detail: TGQuark, may_be_blocked: gboolean): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_has_handler_pending".}
-proc g_signal_connect_closure_by_id*(instance: gpointer, signal_id: guint, 
-                                     detail: TGQuark, closure: PGClosure, 
-                                     after: gboolean): gulong{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_connect_closure_by_id".}
-proc g_signal_connect_closure*(instance: gpointer, detailed_signal: cstring, 
-                               closure: PGClosure, after: gboolean): gulong{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_connect_closure".}
-proc g_signal_connect_data*(instance: gpointer, detailed_signal: cstring, 
-                            c_handler: TGCallback, data: gpointer, 
-                            destroy_data: TGClosureNotify, 
-                            connect_flags: TGConnectFlags): gulong{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_connect_data".}
-proc g_signal_handler_block*(instance: gpointer, handler_id: gulong){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_handler_block".}
-proc g_signal_handler_unblock*(instance: gpointer, handler_id: gulong){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_handler_unblock".}
-proc g_signal_handler_disconnect*(instance: gpointer, handler_id: gulong){.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_disconnect".}
-proc g_signal_handler_is_connected*(instance: gpointer, handler_id: gulong): gboolean{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_is_connected".}
-proc g_signal_handler_find*(instance: gpointer, mask: TGSignalMatchType, 
-                            signal_id: guint, detail: TGQuark, 
-                            closure: PGClosure, func: gpointer, data: gpointer): gulong{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handler_find".}
-proc g_signal_handlers_block_matched*(instance: gpointer, 
-                                      mask: TGSignalMatchType, signal_id: guint, 
-                                      detail: TGQuark, closure: PGClosure, 
-                                      func: gpointer, data: gpointer): guint{.
-    cdecl, dynlib: gobjectlib, importc: "g_signal_handlers_block_matched".}
-proc g_signal_handlers_unblock_matched*(instance: gpointer, 
-                                        mask: TGSignalMatchType, 
-                                        signal_id: guint, detail: TGQuark, 
-                                        closure: PGClosure, func: gpointer, 
-                                        data: gpointer): guint{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_handlers_unblock_matched".}
-proc g_signal_handlers_disconnect_matched*(instance: gpointer, 
-    mask: TGSignalMatchType, signal_id: guint, detail: TGQuark, 
-    closure: PGClosure, func: gpointer, data: gpointer): guint{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_handlers_disconnect_matched".}
-proc g_signal_override_class_closure*(signal_id: guint, instance_type: GType, 
-                                      class_closure: PGClosure){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_override_class_closure".}
-proc signal_chain_from_overridden*(instance_and_params: PGValue, 
-                                     return_value: PGValue){.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_chain_from_overridden".}
-proc g_signal_connect*(instance: gpointer, detailed_signal: cstring, 
-                       c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_connect_after*(instance: gpointer, detailed_signal: cstring, 
-                             c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_connect_swapped*(instance: gpointer, detailed_signal: cstring, 
-                               c_handler: TGCallback, data: gpointer): gulong
-proc g_signal_handlers_disconnect_by_func*(instance: gpointer, 
-    func, data: gpointer): guint
-proc g_signal_handlers_block_by_func*(instance: gpointer, func, data: gpointer)
-proc g_signal_handlers_unblock_by_func*(instance: gpointer, func, data: gpointer)
-proc g_signal_handlers_destroy*(instance: gpointer){.cdecl, dynlib: gobjectlib, 
-    importc: "g_signal_handlers_destroy".}
-proc g_signals_destroy*(itype: GType){.cdecl, dynlib: gobjectlib, 
-                                       importc: "`g_signals_destroy`".}
-type 
-  TGTypePluginUse* = proc (plugin: PGTypePlugin){.cdecl.}
-  TGTypePluginUnuse* = proc (plugin: PGTypePlugin){.cdecl.}
-  TGTypePluginCompleteTypeInfo* = proc (plugin: PGTypePlugin, g_type: GType, 
-                                        info: PGTypeInfo, 
-                                        value_table: PGTypeValueTable){.cdecl.}
-  TGTypePluginCompleteInterfaceInfo* = proc (plugin: PGTypePlugin, 
-      instance_type: GType, interface_type: GType, info: PGInterfaceInfo){.cdecl.}
-  PGTypePluginClass* = ptr TGTypePluginClass
-  TGTypePluginClass*{.final.} = object 
-    base_iface*: TGTypeInterface
-    use_plugin*: TGTypePluginUse
-    unuse_plugin*: TGTypePluginUnuse
-    complete_type_info*: TGTypePluginCompleteTypeInfo
-    complete_interface_info*: TGTypePluginCompleteInterfaceInfo
-
-
-proc G_TYPE_TYPE_PLUGIN*(): GType
-proc G_TYPE_PLUGIN*(inst: Pointer): PGTypePlugin
-proc G_TYPE_PLUGIN_CLASS*(vtable: Pointer): PGTypePluginClass
-proc G_IS_TYPE_PLUGIN*(inst: Pointer): bool
-proc G_IS_TYPE_PLUGIN_CLASS*(vtable: Pointer): bool
-proc G_TYPE_PLUGIN_GET_CLASS*(inst: Pointer): PGTypePluginClass
-proc g_type_plugin_get_type*(): GType{.cdecl, dynlib: gliblib, 
-                                       importc: "g_type_plugin_get_type".}
-proc plugin_use*(plugin: PGTypePlugin){.cdecl, dynlib: gliblib, 
-    importc: "g_type_plugin_use".}
-proc plugin_unuse*(plugin: PGTypePlugin){.cdecl, dynlib: gliblib, 
-    importc: "g_type_plugin_unuse".}
-proc plugin_complete_type_info*(plugin: PGTypePlugin, g_type: GType, 
-                                       info: PGTypeInfo, 
-                                       value_table: PGTypeValueTable){.cdecl, 
-    dynlib: gliblib, importc: "g_type_plugin_complete_type_info".}
-proc plugin_complete_interface_info*(plugin: PGTypePlugin, 
-    instance_type: GType, interface_type: GType, info: PGInterfaceInfo){.cdecl, 
-    dynlib: gliblib, importc: "g_type_plugin_complete_interface_info".}
-type 
-  PGObject* = ptr TGObject
-  TGObject*{.pure.} = object 
-    g_type_instance*: TGTypeInstance
-    ref_count*: guint
-    qdata*: PGData
-
-  TGObjectGetPropertyFunc* = proc (anObject: PGObject, property_id: guint, 
-                                   value: PGValue, pspec: PGParamSpec){.cdecl.}
-  TGObjectSetPropertyFunc* = proc (anObject: PGObject, property_id: guint, 
-                                   value: PGValue, pspec: PGParamSpec){.cdecl.}
-  TGObjectFinalizeFunc* = proc (anObject: PGObject){.cdecl.}
-  TGWeakNotify* = proc (data: gpointer, where_the_object_was: PGObject){.cdecl.}
-  PGObjectConstructParam* = ptr TGObjectConstructParam
-  PGObjectClass* = ptr TGObjectClass
-  TGObjectClass*{.pure.} = object 
-    g_type_class*: TGTypeClass
-    construct_properties*: PGSList
-    constructor*: proc (theType: GType, n_construct_properties: guint, 
-                        construct_properties: PGObjectConstructParam): PGObject{.
-        cdecl.}
-    set_property*: proc (anObject: PGObject, property_id: guint, value: PGValue, 
-                         pspec: PGParamSpec){.cdecl.}
-    get_property*: proc (anObject: PGObject, property_id: guint, value: PGValue, 
-                         pspec: PGParamSpec){.cdecl.}
-    dispose*: proc (anObject: PGObject){.cdecl.}
-    finalize*: proc (anObject: PGObject){.cdecl.}
-    dispatch_properties_changed*: proc (anObject: PGObject, n_pspecs: guint, 
-                                        pspecs: PPGParamSpec){.cdecl.}
-    notify*: proc (anObject: PGObject, pspec: PGParamSpec){.cdecl.}
-    pdummy*: array[0..7, gpointer]
-
-  TGObjectConstructParam*{.final.} = object 
-    pspec*: PGParamSpec
-    value*: PGValue
-
-
-proc G_TYPE_IS_OBJECT*(theType: GType): bool
-proc G_OBJECT*(anObject: pointer): PGObject
-proc G_OBJECT_CLASS*(class: Pointer): PGObjectClass
-proc G_IS_OBJECT*(anObject: pointer): bool
-proc G_IS_OBJECT_CLASS*(class: Pointer): bool
-proc G_OBJECT_GET_CLASS*(anObject: pointer): PGObjectClass
-proc G_OBJECT_TYPE*(anObject: pointer): GType
-proc G_OBJECT_TYPE_NAME*(anObject: pointer): cstring
-proc G_OBJECT_CLASS_TYPE*(class: Pointer): GType
-proc G_OBJECT_CLASS_NAME*(class: Pointer): cstring
-proc G_VALUE_HOLDS_OBJECT*(value: Pointer): bool
-proc class_install_property*(oclass: PGObjectClass, property_id: guint, 
-                                      pspec: PGParamSpec){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_class_install_property".}
-proc class_find_property*(oclass: PGObjectClass, property_name: cstring): PGParamSpec{.
-    cdecl, dynlib: gobjectlib, importc: "g_object_class_find_property".}
-proc class_list_properties*(oclass: PGObjectClass, n_properties: Pguint): PPGParamSpec{.
-    cdecl, dynlib: gobjectlib, importc: "g_object_class_list_properties".}
-proc set_property*(anObject: PGObject, property_name: cstring, 
-                            value: PGValue){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_set_property".}
-proc get_property*(anObject: PGObject, property_name: cstring, 
-                            value: PGValue){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_get_property".}
-proc freeze_notify*(anObject: PGObject){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_freeze_notify".}
-proc notify*(anObject: PGObject, property_name: cstring){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_notify".}
-proc thaw_notify*(anObject: PGObject){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_thaw_notify".}
-proc g_object_ref*(anObject: gpointer): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_ref".}
-proc g_object_unref*(anObject: gpointer){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_unref".}
-proc weak_ref*(anObject: PGObject, notify: TGWeakNotify, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_weak_ref".}
-proc weak_unref*(anObject: PGObject, notify: TGWeakNotify, 
-                          data: gpointer){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_weak_unref".}
-proc add_weak_pointer*(anObject: PGObject, 
-                                weak_pointer_location: Pgpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_add_weak_pointer".}
-proc remove_weak_pointer*(anObject: PGObject, 
-                                   weak_pointer_location: Pgpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_remove_weak_pointer".}
-proc get_qdata*(anObject: PGObject, quark: TGQuark): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_get_qdata".}
-proc set_qdata*(anObject: PGObject, quark: TGQuark, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_set_qdata".}
-proc set_qdata_full*(anObject: PGObject, quark: TGQuark, 
-                              data: gpointer, destroy: TGDestroyNotify){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_set_qdata_full".}
-proc steal_qdata*(anObject: PGObject, quark: TGQuark): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_steal_qdata".}
-proc get_data*(anObject: PGObject, key: cstring): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_get_data".}
-proc set_data*(anObject: PGObject, key: cstring, data: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_object_set_data".}
-proc set_data_full*(anObject: PGObject, key: cstring, data: gpointer, 
-                             destroy: TGDestroyNotify){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_set_data_full".}
-proc steal_data*(anObject: PGObject, key: cstring): gpointer{.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_steal_data".}
-proc watch_closure*(anObject: PGObject, closure: PGClosure){.cdecl, 
-    dynlib: gobjectlib, importc: "g_object_watch_closure".}
-proc g_cclosure_new_object*(callback_func: TGCallback, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_cclosure_new_object".}
-proc g_cclosure_new_object_swap*(callback_func: TGCallback, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_cclosure_new_object_swap".}
-proc g_closure_new_object*(sizeof_closure: guint, anObject: PGObject): PGClosure{.
-    cdecl, dynlib: gobjectlib, importc: "g_closure_new_object".}
-proc set_object*(value: PGValue, v_object: gpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_object".}
-proc get_object*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_object".}
-proc dup_object*(value: PGValue): PGObject{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_dup_object".}
-proc g_signal_connect_object*(instance: gpointer, detailed_signal: cstring, 
-                              c_handler: TGCallback, gobject: gpointer, 
-                              connect_flags: TGConnectFlags): gulong{.cdecl, 
-    dynlib: gobjectlib, importc: "g_signal_connect_object".}
-proc run_dispose*(anObject: PGObject){.cdecl, dynlib: gobjectlib, 
-    importc: "g_object_run_dispose".}
-proc set_object_take_ownership*(value: PGValue, v_object: gpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_object_take_ownership".}
-proc G_OBJECT_WARN_INVALID_PSPEC*(anObject: gpointer, pname: cstring, 
-                                  property_id: gint, pspec: gpointer)
-proc G_OBJECT_WARN_INVALID_PROPERTY_ID*(anObject: gpointer, property_id: gint, 
-                                        pspec: gpointer)
-type 
-  G_FLAGS_TYPE* = GType
-
-const 
-  G_E* = 2.71828
-  G_LN2* = 0.693147
-  G_LN10* = 2.30259
-  G_PI* = 3.14159
-  G_PI_2* = 1.57080
-  G_PI_4* = 0.785398
-  G_SQRT2* = 1.41421
-  G_LITTLE_ENDIAN* = 1234
-  G_BIG_ENDIAN* = 4321
-  G_PDP_ENDIAN* = 3412
-
-proc GUINT16_SWAP_LE_BE_CONSTANT*(val: guint16): guint16
-proc GUINT32_SWAP_LE_BE_CONSTANT*(val: guint32): guint32
-type 
-  PGEnumClass* = ptr TGEnumClass
-  PGEnumValue* = ptr TGEnumValue
-  TGEnumClass*{.final.} = object 
-    g_type_class*: TGTypeClass
-    minimum*: gint
-    maximum*: gint
-    n_values*: guint
-    values*: PGEnumValue
-
-  TGEnumValue*{.final.} = object 
-    value*: gint
-    value_name*: cstring
-    value_nick*: cstring
-
-  PGFlagsClass* = ptr TGFlagsClass
-  PGFlagsValue* = ptr TGFlagsValue
-  TGFlagsClass*{.final.} = object 
-    g_type_class*: TGTypeClass
-    mask*: guint
-    n_values*: guint
-    values*: PGFlagsValue
-
-  TGFlagsValue*{.final.} = object 
-    value*: guint
-    value_name*: cstring
-    value_nick*: cstring
-
-
-proc G_TYPE_IS_ENUM*(theType: GType): gboolean
-proc G_ENUM_CLASS*(class: pointer): PGEnumClass
-proc G_IS_ENUM_CLASS*(class: pointer): gboolean
-proc G_ENUM_CLASS_TYPE*(class: pointer): GType
-proc G_ENUM_CLASS_TYPE_NAME*(class: pointer): cstring
-proc G_TYPE_IS_FLAGS*(theType: GType): gboolean
-proc G_FLAGS_CLASS*(class: pointer): PGFlagsClass
-proc G_IS_FLAGS_CLASS*(class: pointer): gboolean
-proc G_FLAGS_CLASS_TYPE*(class: pointer): GType
-proc G_FLAGS_CLASS_TYPE_NAME*(class: pointer): cstring
-proc G_VALUE_HOLDS_ENUM*(value: pointer): gboolean
-proc G_VALUE_HOLDS_FLAGS*(value: pointer): gboolean
-proc get_value*(enum_class: PGEnumClass, value: gint): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value".}
-proc get_value_by_name*(enum_class: PGEnumClass, name: cstring): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value_by_name".}
-proc get_value_by_nick*(enum_class: PGEnumClass, nick: cstring): PGEnumValue{.
-    cdecl, dynlib: gliblib, importc: "g_enum_get_value_by_nick".}
-proc get_first_value*(flags_class: PGFlagsClass, value: guint): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_first_value".}
-proc get_value_by_name*(flags_class: PGFlagsClass, name: cstring): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_value_by_name".}
-proc get_value_by_nick*(flags_class: PGFlagsClass, nick: cstring): PGFlagsValue{.
-    cdecl, dynlib: gliblib, importc: "g_flags_get_value_by_nick".}
-proc set_enum*(value: PGValue, v_enum: gint){.cdecl, dynlib: gliblib, 
-    importc: "g_value_set_enum".}
-proc get_enum*(value: PGValue): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_value_get_enum".}
-proc set_flags*(value: PGValue, v_flags: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_value_set_flags".}
-proc get_flags*(value: PGValue): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_value_get_flags".}
-proc g_enum_register_static*(name: cstring, const_static_values: PGEnumValue): GType{.
-    cdecl, dynlib: gliblib, importc: "g_enum_register_static".}
-proc g_flags_register_static*(name: cstring, const_static_values: PGFlagsValue): GType{.
-    cdecl, dynlib: gliblib, importc: "g_flags_register_static".}
-proc g_enum_complete_type_info*(g_enum_type: GType, info: PGTypeInfo, 
-                                const_values: PGEnumValue){.cdecl, 
-    dynlib: gliblib, importc: "g_enum_complete_type_info".}
-proc g_flags_complete_type_info*(g_flags_type: GType, info: PGTypeInfo, 
-                                 const_values: PGFlagsValue){.cdecl, 
-    dynlib: gliblib, importc: "g_flags_complete_type_info".}
-const 
-  G_MINFLOAT* = 0.00000
-  G_MAXFLOAT* = 1.70000e+308
-  G_MINDOUBLE* = G_MINFLOAT
-  G_MAXDOUBLE* = G_MAXFLOAT
-  G_MAXSHORT* = 32767
-  G_MINSHORT* = - G_MAXSHORT - 1
-  G_MAXUSHORT* = 2 * G_MAXSHORT + 1
-  G_MAXINT* = 2147483647
-  G_MININT* = - G_MAXINT - 1
-  G_MAXUINT* = - 1
-  G_MINLONG* = G_MININT
-  G_MAXLONG* = G_MAXINT
-  G_MAXULONG* = G_MAXUINT
-  G_MAXINT64* = high(int64)
-  G_MININT64* = low(int64)
-
-const 
-  G_GINT16_FORMAT* = "hi"
-  G_GUINT16_FORMAT* = "hu"
-  G_GINT32_FORMAT* = 'i'
-  G_GUINT32_FORMAT* = 'u'
-  G_HAVE_GINT64* = 1
-  G_GINT64_FORMAT* = "I64i"
-  G_GUINT64_FORMAT* = "I64u"
-  GLIB_SIZEOF_VOID_P* = SizeOf(Pointer)
-  GLIB_SIZEOF_LONG* = SizeOf(int32)
-  GLIB_SIZEOF_SIZE_T* = SizeOf(int32)
-
-type 
-  PGSystemThread* = ptr TGSystemThread
-  TGSystemThread*{.final.} = object 
-    data*: array[0..3, char]
-    dummy_double*: float64
-    dummy_pointer*: pointer
-    dummy_long*: int32
-
-
-const 
-  GLIB_SYSDEF_POLLIN* = 1
-  GLIB_SYSDEF_POLLOUT* = 4
-  GLIB_SYSDEF_POLLPRI* = 2
-  GLIB_SYSDEF_POLLERR* = 8
-  GLIB_SYSDEF_POLLHUP* = 16
-  GLIB_SYSDEF_POLLNVAL* = 32
-
-proc GUINT_TO_POINTER*(i: guint): pointer
-type 
-  PGAsciiType* = ptr TGAsciiType
-  TGAsciiType* = int32
-
-const 
-  G_ASCII_ALNUM* = 1 shl 0
-  G_ASCII_ALPHA* = 1 shl 1
-  G_ASCII_CNTRL* = 1 shl 2
-  G_ASCII_DIGIT* = 1 shl 3
-  G_ASCII_GRAPH* = 1 shl 4
-  G_ASCII_LOWER* = 1 shl 5
-  G_ASCII_PRINT* = 1 shl 6
-  G_ASCII_PUNCT* = 1 shl 7
-  G_ASCII_SPACE* = 1 shl 8
-  G_ASCII_UPPER* = 1 shl 9
-  G_ASCII_XDIGIT* = 1 shl 10
-
-proc g_ascii_tolower*(c: gchar): gchar{.cdecl, dynlib: gliblib, 
-                                        importc: "g_ascii_tolower".}
-proc g_ascii_toupper*(c: gchar): gchar{.cdecl, dynlib: gliblib, 
-                                        importc: "g_ascii_toupper".}
-proc g_ascii_digit_value*(c: gchar): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_ascii_digit_value".}
-proc g_ascii_xdigit_value*(c: gchar): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_ascii_xdigit_value".}
-const 
-  G_STR_DELIMITERS* = "``-|> <."
-
-proc g_strdelimit*(str: cstring, delimiters: cstring, new_delimiter: gchar): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strdelimit".}
-proc g_strcanon*(str: cstring, valid_chars: cstring, substitutor: gchar): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strcanon".}
-proc g_strerror*(errnum: gint): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strerror".}
-proc g_strsignal*(signum: gint): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strsignal".}
-proc g_strreverse*(str: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strreverse".}
-proc g_strlcpy*(dest: cstring, src: cstring, dest_size: gsize): gsize{.cdecl, 
-    dynlib: gliblib, importc: "g_strlcpy".}
-proc g_strlcat*(dest: cstring, src: cstring, dest_size: gsize): gsize{.cdecl, 
-    dynlib: gliblib, importc: "g_strlcat".}
-proc g_strstr_len*(haystack: cstring, haystack_len: gssize, needle: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strstr_len".}
-proc g_strrstr*(haystack: cstring, needle: cstring): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_strrstr".}
-proc g_strrstr_len*(haystack: cstring, haystack_len: gssize, needle: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_strrstr_len".}
-proc g_str_has_suffix*(str: cstring, suffix: cstring): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_str_has_suffix".}
-proc g_str_has_prefix*(str: cstring, prefix: cstring): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_str_has_prefix".}
-proc g_strtod*(nptr: cstring, endptr: PPgchar): gdouble{.cdecl, dynlib: gliblib, 
-    importc: "g_strtod".}
-proc g_ascii_strtod*(nptr: cstring, endptr: PPgchar): gdouble{.cdecl, 
-    dynlib: gliblib, importc: "g_ascii_strtod".}
-const 
-  G_ASCII_DTOSTR_BUF_SIZE* = 29 + 10
-
-proc g_ascii_dtostr*(buffer: cstring, buf_len: gint, d: gdouble): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_ascii_dtostr".}
-proc g_ascii_formatd*(buffer: cstring, buf_len: gint, format: cstring, 
-                      d: gdouble): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_ascii_formatd".}
-proc g_strchug*(str: cstring): cstring{.cdecl, dynlib: gliblib, 
-                                        importc: "g_strchug".}
-proc g_strchomp*(str: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strchomp".}
-proc g_ascii_strcasecmp*(s1: cstring, s2: cstring): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_ascii_strcasecmp".}
-proc g_ascii_strncasecmp*(s1: cstring, s2: cstring, n: gsize): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_ascii_strncasecmp".}
-proc g_ascii_strdown*(str: cstring, len: gssize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_ascii_strdown".}
-proc g_ascii_strup*(str: cstring, len: gssize): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_ascii_strup".}
-proc g_strdup*(str: cstring): cstring{.cdecl, dynlib: gliblib, 
-                                       importc: "g_strdup".}
-proc g_strndup*(str: cstring, n: gsize): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strndup".}
-proc g_strnfill*(length: gsize, fill_char: gchar): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_strnfill".}
-proc g_strcompress*(source: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_strcompress".}
-proc g_strescape*(source: cstring, exceptions: cstring): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_strescape".}
-proc g_memdup*(mem: gconstpointer, byte_size: guint): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_memdup".}
-proc g_strsplit*(str: cstring, delimiter: cstring, max_tokens: gint): PPgchar{.
-    cdecl, dynlib: gliblib, importc: "g_strsplit".}
-proc g_strjoinv*(separator: cstring, str_array: PPgchar): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_strjoinv".}
-proc g_strfreev*(str_array: PPgchar){.cdecl, dynlib: gliblib, 
-                                      importc: "g_strfreev".}
-proc g_strdupv*(str_array: PPgchar): PPgchar{.cdecl, dynlib: gliblib, 
-    importc: "g_strdupv".}
-proc g_stpcpy*(dest: cstring, src: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_stpcpy".}
-proc g_get_user_name*(): cstring{.cdecl, dynlib: gliblib, 
-                                  importc: "g_get_user_name".}
-proc g_get_real_name*(): cstring{.cdecl, dynlib: gliblib, 
-                                  importc: "g_get_real_name".}
-proc g_get_home_dir*(): cstring{.cdecl, dynlib: gliblib, 
-                                 importc: "g_get_home_dir".}
-proc g_get_tmp_dir*(): cstring{.cdecl, dynlib: gliblib, importc: "g_get_tmp_dir".}
-proc g_get_prgname*(): cstring{.cdecl, dynlib: gliblib, importc: "g_get_prgname".}
-proc g_set_prgname*(prgname: cstring){.cdecl, dynlib: gliblib, 
-                                       importc: "g_set_prgname".}
-type 
-  PGDebugKey* = ptr TGDebugKey
-  TGDebugKey*{.final.} = object 
-    key*: cstring
-    value*: guint
-
-
-proc g_parse_debug_string*(str: cstring, keys: PGDebugKey, nkeys: guint): guint{.
-    cdecl, dynlib: gliblib, importc: "g_parse_debug_string".}
-proc g_path_is_absolute*(file_name: cstring): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_path_is_absolute".}
-proc g_path_skip_root*(file_name: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_path_skip_root".}
-proc g_basename*(file_name: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_basename".}
-proc g_dirname*(file_name: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_path_get_dirname".}
-proc g_get_current_dir*(): cstring{.cdecl, dynlib: gliblib, 
-                                    importc: "g_get_current_dir".}
-proc g_path_get_basename*(file_name: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_path_get_basename".}
-proc g_path_get_dirname*(file_name: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_path_get_dirname".}
-proc nullify_pointer*(nullify_location: Pgpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_nullify_pointer".}
-proc g_getenv*(variable: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_getenv".}
-type 
-  TGVoidFunc* = proc (){.cdecl.}
-
-proc g_atexit*(func: TGVoidFunc){.cdecl, dynlib: gliblib, importc: "g_atexit".}
-proc g_find_program_in_path*(program: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_find_program_in_path".}
-proc g_bit_nth_lsf*(mask: gulong, nth_bit: gint): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_bit_nth_lsf".}
-proc g_bit_nth_msf*(mask: gulong, nth_bit: gint): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_bit_nth_msf".}
-proc g_bit_storage*(number: gulong): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_bit_storage".}
-type 
-  PPGTrashStack* = ptr PGTrashStack
-  PGTrashStack* = ptr TGTrashStack
-  TGTrashStack*{.final.} = object 
-    next*: PGTrashStack
-
-
-proc g_trash_stack_push*(stack_p: PPGTrashStack, data_p: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_trash_stack_push".}
-proc g_trash_stack_pop*(stack_p: PPGTrashStack): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_trash_stack_pop".}
-proc g_trash_stack_peek*(stack_p: PPGTrashStack): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_trash_stack_peek".}
-proc g_trash_stack_height*(stack_p: PPGTrashStack): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_trash_stack_height".}
-type 
-  PGHashTable* = pointer
-  TGHRFunc* = proc (key, value, user_data: gpointer): gboolean{.cdecl.}
-
-proc g_hash_table_new*(hash_func: TGHashFunc, key_equal_func: TGEqualFunc): PGHashTable{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_new".}
-proc g_hash_table_new_full*(hash_func: TGHashFunc, key_equal_func: TGEqualFunc, 
-                            key_destroy_func: TGDestroyNotify, 
-                            value_destroy_func: TGDestroyNotify): PGHashTable{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_new_full".}
-proc table_destroy*(hash_table: PGHashTable){.cdecl, dynlib: gliblib, 
-    importc: "g_hash_table_destroy".}
-proc table_insert*(hash_table: PGHashTable, key: gpointer, 
-                          value: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_hash_table_insert".}
-proc table_replace*(hash_table: PGHashTable, key: gpointer, 
-                           value: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_hash_table_replace".}
-proc table_remove*(hash_table: PGHashTable, key: gconstpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_remove".}
-proc table_steal*(hash_table: PGHashTable, key: gconstpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_steal".}
-proc table_lookup*(hash_table: PGHashTable, key: gconstpointer): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_lookup".}
-proc table_lookup_extended*(hash_table: PGHashTable, 
-                                   lookup_key: gconstpointer, 
-                                   orig_key: Pgpointer, value: Pgpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_hash_table_lookup_extended".}
-proc table_foreach*(hash_table: PGHashTable, func: TGHFunc, 
-                           user_data: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_hash_table_foreach".}
-proc table_foreach_remove*(hash_table: PGHashTable, func: TGHRFunc, 
-                                  user_data: gpointer): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_hash_table_foreach_remove".}
-proc table_foreach_steal*(hash_table: PGHashTable, func: TGHRFunc, 
-                                 user_data: gpointer): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_hash_table_foreach_steal".}
-proc table_size*(hash_table: PGHashTable): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_hash_table_size".}
-proc g_str_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_str_equal".}
-proc g_str_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_str_hash".}
-proc g_int_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_int_equal".}
-proc g_int_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_int_hash".}
-proc g_direct_hash*(v: gconstpointer): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_direct_hash".}
-proc g_direct_equal*(v: gconstpointer, v2: gconstpointer): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_direct_equal".}
-proc g_quark_try_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib, 
-    importc: "g_quark_try_string".}
-proc g_quark_from_static_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib, 
-    importc: "g_quark_from_static_string".}
-proc g_quark_from_string*(str: cstring): TGQuark{.cdecl, dynlib: gliblib, 
-    importc: "g_quark_from_string".}
-proc g_quark_to_string*(quark: TGQuark): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_quark_to_string".}
-const 
-  G_MEM_ALIGN* = GLIB_SIZEOF_VOID_P
-
-type 
-  PGMemVTable* = ptr TGMemVTable
-  TGMemVTable*{.final.} = object 
-    malloc*: proc (n_bytes: gsize): gpointer{.cdecl.}
-    realloc*: proc (mem: gpointer, n_bytes: gsize): gpointer{.cdecl.}
-    free*: proc (mem: gpointer){.cdecl.}
-    calloc*: proc (n_blocks: gsize, n_block_bytes: gsize): gpointer{.cdecl.}
-    try_malloc*: proc (n_bytes: gsize): gpointer{.cdecl.}
-    try_realloc*: proc (mem: gpointer, n_bytes: gsize): gpointer{.cdecl.}
-
-  PGMemChunk* = pointer
-  PGAllocator* = pointer
-
-proc g_malloc*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_malloc".}
-proc g_malloc0*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_malloc0".}
-proc g_realloc*(mem: gpointer, n_bytes: gulong): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_realloc".}
-proc g_free*(mem: gpointer){.cdecl, dynlib: gliblib, importc: "g_free".}
-proc g_try_malloc*(n_bytes: gulong): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_try_malloc".}
-proc g_try_realloc*(mem: gpointer, n_bytes: gulong): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_try_realloc".}
-#proc g_new*(bytes_per_struct, n_structs: gsize): gpointer
-#proc g_new0*(bytes_per_struct, n_structs: gsize): gpointer
-#proc g_renew*(struct_size: gsize, OldMem: gpointer, n_structs: gsize): gpointer
-
-proc set_vtable*(vtable: PGMemVTable){.cdecl, dynlib: gliblib, 
-    importc: "g_mem_set_vtable".}
-proc g_mem_is_system_malloc*(): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_mem_is_system_malloc".}
-proc g_mem_profile*(){.cdecl, dynlib: gliblib, importc: "g_mem_profile".}
-proc g_chunk_new*(chunk: Pointer): Pointer
-proc g_chunk_new0*(chunk: Pointer): Pointer
-
-const 
-  G_ALLOC_ONLY* = 1
-  G_ALLOC_AND_FREE* = 2
-
-proc g_mem_chunk_new*(name: cstring, atom_size: gint, area_size: gulong, 
-                      theType: gint): PGMemChunk{.cdecl, dynlib: gliblib, 
-    importc: "g_mem_chunk_new".}
-proc chunk_destroy*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib, 
-    importc: "g_mem_chunk_destroy".}
-proc chunk_alloc*(mem_chunk: PGMemChunk): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_mem_chunk_alloc".}
-proc chunk_alloc0*(mem_chunk: PGMemChunk): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_mem_chunk_alloc0".}
-proc chunk_free*(mem_chunk: PGMemChunk, mem: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_mem_chunk_free".}
-proc chunk_clean*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib, 
-    importc: "g_mem_chunk_clean".}
-proc chunk_reset*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib, 
-    importc: "g_mem_chunk_reset".}
-proc chunk_print*(mem_chunk: PGMemChunk){.cdecl, dynlib: gliblib, 
-    importc: "g_mem_chunk_print".}
-proc g_mem_chunk_info*(){.cdecl, dynlib: gliblib, importc: "g_mem_chunk_info".}
-proc g_blow_chunks*(){.cdecl, dynlib: gliblib, importc: "g_blow_chunks".}
-proc g_allocator_new*(name: cstring, n_preallocs: guint): PGAllocator{.cdecl, 
-    dynlib: gliblib, importc: "g_allocator_new".}
-proc free*(allocator: PGAllocator){.cdecl, dynlib: gliblib, 
-    importc: "g_allocator_free".}
-const 
-  G_ALLOCATOR_LIST* = 1
-  G_ALLOCATOR_SLIST* = 2
-  G_ALLOCATOR_NODE* = 3
-
-proc slist_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib, 
-    importc: "g_slist_push_allocator".}
-proc g_slist_pop_allocator*(){.cdecl, dynlib: gliblib, 
-                               importc: "g_slist_pop_allocator".}
-proc g_slist_alloc*(): PGSList{.cdecl, dynlib: gliblib, importc: "g_slist_alloc".}
-proc free*(list: PGSList){.cdecl, dynlib: gliblib, 
-                                   importc: "g_slist_free".}
-proc free_1*(list: PGSList){.cdecl, dynlib: gliblib, 
-                                     importc: "g_slist_free_1".}
-proc append*(list: PGSList, data: gpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_append".}
-proc prepend*(list: PGSList, data: gpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_prepend".}
-proc insert*(list: PGSList, data: gpointer, position: gint): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert".}
-proc insert_sorted*(list: PGSList, data: gpointer, func: TGCompareFunc): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert_sorted".}
-proc insert_before*(slist: PGSList, sibling: PGSList, data: gpointer): PGSList{.
-    cdecl, dynlib: gliblib, importc: "g_slist_insert_before".}
-proc concat*(list1: PGSList, list2: PGSList): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_concat".}
-proc remove*(list: PGSList, data: gconstpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_remove".}
-proc remove_all*(list: PGSList, data: gconstpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_remove_all".}
-proc remove_link*(list: PGSList, link: PGSList): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_remove_link".}
-proc delete_link*(list: PGSList, link: PGSList): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_delete_link".}
-proc reverse*(list: PGSList): PGSList{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_reverse".}
-proc copy*(list: PGSList): PGSList{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_copy".}
-proc nth*(list: PGSList, n: guint): PGSList{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_nth".}
-proc find*(list: PGSList, data: gconstpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_find".}
-proc find_custom*(list: PGSList, data: gconstpointer, 
-                          func: TGCompareFunc): PGSList{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_find_custom".}
-proc position*(list: PGSList, llink: PGSList): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_position".}
-proc index*(list: PGSList, data: gconstpointer): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_index".}
-proc last*(list: PGSList): PGSList{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_last".}
-proc length*(list: PGSList): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_slist_length".}
-proc foreach*(list: PGSList, func: TGFunc, user_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_slist_foreach".}
-proc sort*(list: PGSList, compare_func: TGCompareFunc): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_sort".}
-proc sort*(list: PGSList, compare_func: TGCompareDataFunc, 
-                             user_data: gpointer): PGSList{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_sort_with_data".}
-proc nth_data*(list: PGSList, n: guint): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_slist_nth_data".}
-proc next*(slist: PGSList): PGSList
-proc list_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib, 
-    importc: "g_list_push_allocator".}
-proc g_list_pop_allocator*(){.cdecl, dynlib: gliblib, 
-                              importc: "g_list_pop_allocator".}
-proc g_list_alloc*(): PGList{.cdecl, dynlib: gliblib, importc: "g_list_alloc".}
-proc free*(list: PGList){.cdecl, dynlib: gliblib, importc: "g_list_free".}
-proc free_1*(list: PGList){.cdecl, dynlib: gliblib, 
-                                   importc: "g_list_free_1".}
-proc append*(list: PGList, data: gpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_append".}
-proc prepend*(list: PGList, data: gpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_prepend".}
-proc insert*(list: PGList, data: gpointer, position: gint): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert".}
-proc insert_sorted*(list: PGList, data: gpointer, func: TGCompareFunc): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert_sorted".}
-proc insert_before*(list: PGList, sibling: PGList, data: gpointer): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_insert_before".}
-proc concat*(list1: PGList, list2: PGList): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_concat".}
-proc remove*(list: PGList, data: gconstpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_remove".}
-proc remove_all*(list: PGList, data: gconstpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_remove_all".}
-proc remove_link*(list: PGList, llink: PGList): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_remove_link".}
-proc delete_link*(list: PGList, link: PGList): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_delete_link".}
-proc reverse*(list: PGList): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_reverse".}
-proc copy*(list: PGList): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_copy".}
-proc nth*(list: PGList, n: guint): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_nth".}
-proc nth_prev*(list: PGList, n: guint): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_nth_prev".}
-proc find*(list: PGList, data: gconstpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_find".}
-proc find_custom*(list: PGList, data: gconstpointer, func: TGCompareFunc): PGList{.
-    cdecl, dynlib: gliblib, importc: "g_list_find_custom".}
-proc position*(list: PGList, llink: PGList): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_list_position".}
-proc index*(list: PGList, data: gconstpointer): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_list_index".}
-proc last*(list: PGList): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_last".}
-proc first*(list: PGList): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_list_first".}
-proc length*(list: PGList): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_list_length".}
-proc foreach*(list: PGList, func: TGFunc, user_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_list_foreach".}
-proc sort*(list: PGList, compare_func: TGCompareFunc): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_sort".}
-proc sort*(list: PGList, compare_func: TGCompareDataFunc, 
-                            user_data: gpointer): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_list_sort_with_data".}
-proc nth_data*(list: PGList, n: guint): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_list_nth_data".}
-proc previous*(list: PGList): PGList
-proc next*(list: PGList): PGList
-type 
-  PGCache* = pointer
-  TGCacheNewFunc* = proc (key: gpointer): gpointer{.cdecl.}
-  TGCacheDupFunc* = proc (value: gpointer): gpointer{.cdecl.}
-  TGCacheDestroyFunc* = proc (value: gpointer){.cdecl.}
-
-proc g_cache_new*(value_new_func: TGCacheNewFunc, 
-                  value_destroy_func: TGCacheDestroyFunc, 
-                  key_dup_func: TGCacheDupFunc, 
-                  key_destroy_func: TGCacheDestroyFunc, 
-                  hash_key_func: TGHashFunc, hash_value_func: TGHashFunc, 
-                  key_equal_func: TGEqualFunc): PGCache{.cdecl, dynlib: gliblib, 
-    importc: "g_cache_new".}
-proc destroy*(cache: PGCache){.cdecl, dynlib: gliblib, 
-                                       importc: "g_cache_destroy".}
-proc insert*(cache: PGCache, key: gpointer): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_cache_insert".}
-proc remove*(cache: PGCache, value: gconstpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_cache_remove".}
-proc key_foreach*(cache: PGCache, func: TGHFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_cache_key_foreach".}
-proc value_foreach*(cache: PGCache, func: TGHFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_cache_value_foreach".}
-type 
-  PGCompletionFunc* = ptr TGCompletionFunc
-  TGCompletionFunc* = gchar
-  TGCompletionStrncmpFunc* = proc (s1: cstring, s2: cstring, n: gsize): gint{.
-      cdecl.}
-  PGCompletion* = ptr TGCompletion
-  TGCompletion*{.final.} = object 
-    items*: PGList
-    func*: TGCompletionFunc
-    prefix*: cstring
-    cache*: PGList
-    strncmp_func*: TGCompletionStrncmpFunc
-
-
-proc g_completion_new*(func: TGCompletionFunc): PGCompletion{.cdecl, 
-    dynlib: gliblib, importc: "g_completion_new".}
-proc add_items*(cmp: PGCompletion, items: PGList){.cdecl, 
-    dynlib: gliblib, importc: "g_completion_add_items".}
-proc remove_items*(cmp: PGCompletion, items: PGList){.cdecl, 
-    dynlib: gliblib, importc: "g_completion_remove_items".}
-proc clear_items*(cmp: PGCompletion){.cdecl, dynlib: gliblib, 
-    importc: "g_completion_clear_items".}
-proc complete*(cmp: PGCompletion, prefix: cstring, 
-                            new_prefix: PPgchar): PGList{.cdecl, 
-    dynlib: gliblib, importc: "g_completion_complete".}
-proc set_compare*(cmp: PGCompletion, 
-                               strncmp_func: TGCompletionStrncmpFunc){.cdecl, 
-    dynlib: gliblib, importc: "g_completion_set_compare".}
-proc free*(cmp: PGCompletion){.cdecl, dynlib: gliblib, 
-    importc: "g_completion_free".}
-type 
-  PGConvertError* = ptr TGConvertError
-  TGConvertError* = enum 
-    G_CONVERT_ERROR_NO_CONVERSION, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, 
-    G_CONVERT_ERROR_FAILED, G_CONVERT_ERROR_PARTIAL_INPUT, 
-    G_CONVERT_ERROR_BAD_URI, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
-
-proc G_CONVERT_ERROR*(): TGQuark
-proc g_convert_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-                                        importc: "g_convert_error_quark".}
-type 
-  PGIConv* = ptr TGIConv
-  TGIConv* = pointer
-
-proc g_iconv_open*(to_codeset: cstring, from_codeset: cstring): TGIConv{.cdecl, 
-    dynlib: gliblib, importc: "g_iconv_open".}
-proc g_iconv*(`converter`: TGIConv, inbuf: PPgchar, inbytes_left: Pgsize, 
-              outbuf: PPgchar, outbytes_left: Pgsize): gsize{.cdecl, 
-    dynlib: gliblib, importc: "g_iconv".}
-proc g_iconv_close*(`converter`: TGIConv): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_iconv_close".}
-proc g_convert*(str: cstring, len: gssize, to_codeset: cstring, 
-                from_codeset: cstring, bytes_read: Pgsize, 
-                bytes_written: Pgsize, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_convert".}
-proc g_convert*(str: cstring, len: gssize, `converter`: TGIConv, 
-                           bytes_read: Pgsize, bytes_written: Pgsize, 
-                           error: pointer): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_convert_with_iconv".}
-proc g_convert*(str: cstring, len: gssize, to_codeset: cstring, 
-                              from_codeset: cstring, fallback: cstring, 
-                              bytes_read: Pgsize, bytes_written: Pgsize, 
-                              error: pointer): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_convert_with_fallback".}
-proc g_locale_to_utf8*(opsysstring: cstring, len: gssize, bytes_read: Pgsize, 
-                       bytes_written: Pgsize, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_locale_to_utf8".}
-proc g_locale_from_utf8*(utf8string: cstring, len: gssize, bytes_read: Pgsize, 
-                         bytes_written: Pgsize, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_locale_from_utf8".}
-proc g_filename_to_utf8*(opsysstring: cstring, len: gssize, bytes_read: Pgsize, 
-                         bytes_written: Pgsize, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_filename_to_utf8".}
-proc g_filename_from_utf8*(utf8string: cstring, len: gssize, bytes_read: Pgsize, 
-                           bytes_written: Pgsize, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_from_utf8".}
-proc g_filename_from_uri*(uri: cstring, hostname: PPchar, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_from_uri".}
-proc g_filename_to_uri*(filename: cstring, hostname: cstring, error: pointer): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_filename_to_uri".}
-type 
-  TGDataForeachFunc* = proc (key_id: TGQuark, data: gpointer, 
-                             user_data: gpointer){.cdecl.}
-
-proc g_datalist_init*(datalist: PPGData){.cdecl, dynlib: gliblib, 
-    importc: "g_datalist_init".}
-proc g_datalist_clear*(datalist: PPGData){.cdecl, dynlib: gliblib, 
-    importc: "g_datalist_clear".}
-proc g_datalist_id_get_data*(datalist: PPGData, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_get_data".}
-proc g_datalist_id_set_data_full*(datalist: PPGData, key_id: TGQuark, 
-                                  data: gpointer, destroy_func: TGDestroyNotify){.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_set_data_full".}
-proc g_datalist_id_remove_no_notify*(datalist: PPGData, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_datalist_id_remove_no_notify".}
-proc g_datalist_foreach*(datalist: PPGData, func: TGDataForeachFunc, 
-                         user_data: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_datalist_foreach".}
-proc g_datalist_id_set_data*(datalist: PPGData, key_id: TGQuark, data: gpointer)
-proc g_datalist_id_remove_data*(datalist: PPGData, key_id: TGQuark)
-proc g_datalist_get_data*(datalist: PPGData, key_str: cstring): PPGData
-proc g_datalist_set_data_full*(datalist: PPGData, key_str: cstring, 
-                               data: gpointer, destroy_func: TGDestroyNotify)
-proc g_datalist_set_data*(datalist: PPGData, key_str: cstring, data: gpointer)
-proc g_datalist_remove_no_notify*(datalist: PPGData, key_str: cstring)
-proc g_datalist_remove_data*(datalist: PPGData, key_str: cstring)
-proc g_dataset_id_get_data*(dataset_location: gconstpointer, key_id: TGQuark): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_dataset_id_get_data".}
-proc g_dataset_id_set_data_full*(dataset_location: gconstpointer, 
-                                 key_id: TGQuark, data: gpointer, 
-                                 destroy_func: TGDestroyNotify){.cdecl, 
-    dynlib: gliblib, importc: "g_dataset_id_set_data_full".}
-proc g_dataset_id_remove_no_notify*(dataset_location: gconstpointer, 
-                                    key_id: TGQuark): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_dataset_id_remove_no_notify".}
-proc g_dataset_foreach*(dataset_location: gconstpointer, 
-                        func: TGDataForeachFunc, user_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_dataset_foreach".}
-proc g_dataset_id_set_data*(location: gconstpointer, key_id: TGQuark, 
-                            data: gpointer)
-proc g_dataset_id_remove_data*(location: gconstpointer, key_id: TGQuark)
-proc g_dataset_get_data*(location: gconstpointer, key_str: cstring): gpointer
-proc g_dataset_set_data_full*(location: gconstpointer, key_str: cstring, 
-                              data: gpointer, destroy_func: TGDestroyNotify)
-proc g_dataset_remove_no_notify*(location: gconstpointer, key_str: cstring)
-proc g_dataset_set_data*(location: gconstpointer, key_str: cstring, 
-                         data: gpointer)
-proc g_dataset_remove_data*(location: gconstpointer, key_str: cstring)
-type 
-  PGTime* = ptr TGTime
-  TGTime* = gint32
-  PGDateYear* = ptr TGDateYear
-  TGDateYear* = guint16
-  PGDateDay* = ptr TGDateDay
-  TGDateDay* = guint8
-  Ptm* = ptr Ttm
-  Ttm*{.final.} = object 
-    tm_sec*: gint
-    tm_min*: gint
-    tm_hour*: gint
-    tm_mday*: gint
-    tm_mon*: gint
-    tm_year*: gint
-    tm_wday*: gint
-    tm_yday*: gint
-    tm_isdst*: gint
-    tm_gmtoff*: glong
-    tm_zone*: cstring
-
-
-type 
-  PGDateDMY* = ptr TGDateDMY
-  TGDateDMY* = int
-
-const 
-  G_DATE_DAY* = 0
-  G_DATE_MONTH* = 1
-  G_DATE_YEAR* = 2
-
-type 
-  PGDateWeekday* = ptr TGDateWeekday
-  TGDateWeekday* = int
-
-const 
-  G_DATE_BAD_WEEKDAY* = 0
-  G_DATE_MONDAY* = 1
-  G_DATE_TUESDAY* = 2
-  G_DATE_WEDNESDAY* = 3
-  G_DATE_THURSDAY* = 4
-  G_DATE_FRIDAY* = 5
-  G_DATE_SATURDAY* = 6
-  G_DATE_SUNDAY* = 7
-
-type 
-  PGDateMonth* = ptr TGDateMonth
-  TGDateMonth* = int
-
-const 
-  G_DATE_BAD_MONTH* = 0
-  G_DATE_JANUARY* = 1
-  G_DATE_FEBRUARY* = 2
-  G_DATE_MARCH* = 3
-  G_DATE_APRIL* = 4
-  G_DATE_MAY* = 5
-  G_DATE_JUNE* = 6
-  G_DATE_JULY* = 7
-  G_DATE_AUGUST* = 8
-  G_DATE_SEPTEMBER* = 9
-  G_DATE_OCTOBER* = 10
-  G_DATE_NOVEMBER* = 11
-  G_DATE_DECEMBER* = 12
-
-const 
-  G_DATE_BAD_JULIAN* = 0
-  G_DATE_BAD_DAY* = 0
-  G_DATE_BAD_YEAR* = 0
-
-type 
-  PGDate* = ptr TGDate
-  TGDate*{.final.} = object 
-    flag0*: int32
-    flag1*: int32
-
-
-proc g_date_new*(): PGDate{.cdecl, dynlib: gliblib, importc: "g_date_new".}
-proc g_date_new_dmy*(day: TGDateDay, month: TGDateMonth, year: TGDateYear): PGDate{.
-    cdecl, dynlib: gliblib, importc: "g_date_new_dmy".}
-proc g_date_new_julian*(julian_day: guint32): PGDate{.cdecl, dynlib: gliblib, 
-    importc: "g_date_new_julian".}
-proc free*(date: PGDate){.cdecl, dynlib: gliblib, importc: "g_date_free".}
-proc valid*(date: PGDate): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_valid".}
-proc g_date_valid_month*(month: TGDateMonth): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_valid_month".}
-proc g_date_valid_year*(year: TGDateYear): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_valid_year".}
-proc g_date_valid_weekday*(weekday: TGDateWeekday): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_date_valid_weekday".}
-proc g_date_valid_julian*(julian_date: guint32): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_date_valid_julian".}
-proc get_weekday*(date: PGDate): TGDateWeekday{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_weekday".}
-proc get_month*(date: PGDate): TGDateMonth{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_month".}
-proc get_year*(date: PGDate): TGDateYear{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_year".}
-proc get_day*(date: PGDate): TGDateDay{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_day".}
-proc get_julian*(date: PGDate): guint32{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_julian".}
-proc get_day_of_year*(date: PGDate): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_date_get_day_of_year".}
-proc get_monday_week_of_year*(date: PGDate): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_date_get_monday_week_of_year".}
-proc get_sunday_week_of_year*(date: PGDate): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_date_get_sunday_week_of_year".}
-proc clear*(date: PGDate, n_dates: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_date_clear".}
-proc set_parse*(date: PGDate, str: cstring){.cdecl, dynlib: gliblib, 
-    importc: "g_date_set_parse".}
-proc set_time*(date: PGDate, time: TGTime){.cdecl, dynlib: gliblib, 
-    importc: "g_date_set_time".}
-proc set_month*(date: PGDate, month: TGDateMonth){.cdecl, 
-    dynlib: gliblib, importc: "g_date_set_month".}
-proc set_day*(date: PGDate, day: TGDateDay){.cdecl, dynlib: gliblib, 
-    importc: "g_date_set_day".}
-proc set_year*(date: PGDate, year: TGDateYear){.cdecl, dynlib: gliblib, 
-    importc: "g_date_set_year".}
-proc set_dmy*(date: PGDate, day: TGDateDay, month: TGDateMonth, 
-                     y: TGDateYear){.cdecl, dynlib: gliblib, 
-                                     importc: "g_date_set_dmy".}
-proc set_julian*(date: PGDate, julian_date: guint32){.cdecl, 
-    dynlib: gliblib, importc: "g_date_set_julian".}
-proc is_first_of_month*(date: PGDate): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_is_first_of_month".}
-proc is_last_of_month*(date: PGDate): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_is_last_of_month".}
-proc add_days*(date: PGDate, n_days: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_date_add_days".}
-proc subtract_days*(date: PGDate, n_days: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_date_subtract_days".}
-proc add_months*(date: PGDate, n_months: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_date_add_months".}
-proc subtract_months*(date: PGDate, n_months: guint){.cdecl, 
-    dynlib: gliblib, importc: "g_date_subtract_months".}
-proc add_years*(date: PGDate, n_years: guint){.cdecl, dynlib: gliblib, 
-    importc: "g_date_add_years".}
-proc subtract_years*(date: PGDate, n_years: guint){.cdecl, 
-    dynlib: gliblib, importc: "g_date_subtract_years".}
-proc g_date_is_leap_year*(year: TGDateYear): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_date_is_leap_year".}
-proc g_date_get_days_in_month*(month: TGDateMonth, year: TGDateYear): guint8{.
-    cdecl, dynlib: gliblib, importc: "g_date_get_days_in_month".}
-proc g_date_get_monday_weeks_in_year*(year: TGDateYear): guint8{.cdecl, 
-    dynlib: gliblib, importc: "g_date_get_monday_weeks_in_year".}
-proc g_date_get_sunday_weeks_in_year*(year: TGDateYear): guint8{.cdecl, 
-    dynlib: gliblib, importc: "g_date_get_sunday_weeks_in_year".}
-proc days_between*(date1: PGDate, date2: PGDate): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_date_days_between".}
-proc compare*(lhs: PGDate, rhs: PGDate): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_date_compare".}
-proc to_struct_tm*(date: PGDate, tm: Ptm){.cdecl, dynlib: gliblib, 
-    importc: "g_date_to_struct_tm".}
-proc clamp*(date: PGDate, min_date: PGDate, max_date: PGDate){.cdecl, 
-    dynlib: gliblib, importc: "g_date_clamp".}
-proc order*(date1: PGDate, date2: PGDate){.cdecl, dynlib: gliblib, 
-    importc: "g_date_order".}
-proc g_date_strftime*(s: cstring, slen: gsize, format: cstring, date: PGDate): gsize{.
-    cdecl, dynlib: gliblib, importc: "g_date_strftime".}
-type 
-  PGDir* = pointer
-
-proc g_dir_open*(path: cstring, flags: guint, error: pointer): PGDir{.cdecl, 
-    dynlib: gliblib, importc: "g_dir_open".}
-proc read_name*(dir: PGDir): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_dir_read_name".}
-proc rewind*(dir: PGDir){.cdecl, dynlib: gliblib, importc: "g_dir_rewind".}
-proc close*(dir: PGDir){.cdecl, dynlib: gliblib, importc: "g_dir_close".}
-type 
-  PGFileError* = ptr TGFileError
-  TGFileError* = gint
-
-type 
-  PGFileTest* = ptr TGFileTest
-  TGFileTest* = int
-
-const 
-  G_FILE_TEST_IS_REGULAR* = 1 shl 0
-  G_FILE_TEST_IS_SYMLINK* = 1 shl 1
-  G_FILE_TEST_IS_DIR* = 1 shl 2
-  G_FILE_TEST_IS_EXECUTABLE* = 1 shl 3
-  G_FILE_TEST_EXISTS* = 1 shl 4
-
-const 
-  G_FILE_ERROR_EXIST* = 0
-  G_FILE_ERROR_ISDIR* = 1
-  G_FILE_ERROR_ACCES* = 2
-  G_FILE_ERROR_NAMETOOLONG* = 3
-  G_FILE_ERROR_NOENT* = 4
-  G_FILE_ERROR_NOTDIR* = 5
-  G_FILE_ERROR_NXIO* = 6
-  G_FILE_ERROR_NODEV* = 7
-  G_FILE_ERROR_ROFS* = 8
-  G_FILE_ERROR_TXTBSY* = 9
-  G_FILE_ERROR_FAULT* = 10
-  G_FILE_ERROR_LOOP* = 11
-  G_FILE_ERROR_NOSPC* = 12
-  G_FILE_ERROR_NOMEM* = 13
-  G_FILE_ERROR_MFILE* = 14
-  G_FILE_ERROR_NFILE* = 15
-  G_FILE_ERROR_BADF* = 16
-  G_FILE_ERROR_INVAL* = 17
-  G_FILE_ERROR_PIPE* = 18
-  G_FILE_ERROR_AGAIN* = 19
-  G_FILE_ERROR_INTR* = 20
-  G_FILE_ERROR_IO* = 21
-  G_FILE_ERROR_PERM* = 22
-  G_FILE_ERROR_FAILED* = 23
-
-proc G_FILE_ERROR*(): TGQuark
-proc g_file_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-                                     importc: "g_file_error_quark".}
-proc g_file_error_from_errno*(err_no: gint): TGFileError{.cdecl, 
-    dynlib: gliblib, importc: "g_file_error_from_errno".}
-proc g_file_test*(filename: cstring, test: TGFileTest): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_file_test".}
-proc g_file_get_contents*(filename: cstring, contents: PPgchar, length: Pgsize, 
-                          error: pointer): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_file_get_contents".}
-proc g_mkstemp*(tmpl: cstring): int32{.cdecl, dynlib: gliblib, 
-                                       importc: "g_mkstemp".}
-proc g_file_open_tmp*(tmpl: cstring, name_used: PPchar, error: pointer): int32{.
-    cdecl, dynlib: gliblib, importc: "g_file_open_tmp".}
-type 
-  PGHook* = ptr TGHook
-  TGHook*{.final.} = object 
-    data*: gpointer
-    next*: PGHook
-    prev*: PGHook
-    ref_count*: guint
-    hook_id*: gulong
-    flags*: guint
-    func*: gpointer
-    destroy*: TGDestroyNotify
-
-  PGHookList* = ptr TGHookList
-  TGHookCompareFunc* = proc (new_hook: PGHook, sibling: PGHook): gint{.cdecl.}
-  TGHookFindFunc* = proc (hook: PGHook, data: gpointer): gboolean{.cdecl.}
-  TGHookMarshaller* = proc (hook: PGHook, marshal_data: gpointer){.cdecl.}
-  TGHookCheckMarshaller* = proc (hook: PGHook, marshal_data: gpointer): gboolean{.
-      cdecl.}
-  TGHookFunc* = proc (data: gpointer){.cdecl.}
-  TGHookCheckFunc* = proc (data: gpointer): gboolean{.cdecl.}
-  TGHookFinalizeFunc* = proc (hook_list: PGHookList, hook: PGHook){.cdecl.}
-  TGHookList*{.final.} = object 
-    seq_id*: gulong
-    flag0*: int32
-    hooks*: PGHook
-    hook_memchunk*: PGMemChunk
-    finalize_hook*: TGHookFinalizeFunc
-    dummy*: array[0..1, gpointer]
-
-
-type 
-  PGHookFlagMask* = ptr TGHookFlagMask
-  TGHookFlagMask* = int
-
-const 
-  G_HOOK_FLAG_ACTIVE* = 1'i32 shl 0'i32
-  G_HOOK_FLAG_IN_CALL* = 1'i32 shl 1'i32
-  G_HOOK_FLAG_MASK* = 0x0000000F'i32
-
-const 
-  G_HOOK_FLAG_USER_SHIFT* = 4'i32
-  bm_TGHookList_hook_size* = 0x0000FFFF'i32
-  bp_TGHookList_hook_size* = 0'i32
-  bm_TGHookList_is_setup* = 0x00010000'i32
-  bp_TGHookList_is_setup* = 16'i32
-
-proc TGHookList_hook_size*(a: PGHookList): guint
-proc TGHookList_set_hook_size*(a: PGHookList, `hook_size`: guint)
-proc TGHookList_is_setup*(a: PGHookList): guint
-proc TGHookList_set_is_setup*(a: PGHookList, `is_setup`: guint)
-proc G_HOOK*(hook: pointer): PGHook
-proc FLAGS*(hook: PGHook): guint
-proc ACTIVE*(hook: PGHook): bool
-proc IN_CALL*(hook: PGHook): bool
-proc IS_VALID*(hook: PGHook): bool
-proc IS_UNLINKED*(hook: PGHook): bool
-proc list_init*(hook_list: PGHookList, hook_size: guint){.cdecl, 
-    dynlib: gliblib, importc: "g_hook_list_init".}
-proc list_clear*(hook_list: PGHookList){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_list_clear".}
-proc alloc*(hook_list: PGHookList): PGHook{.cdecl, dynlib: gliblib, 
-    importc: "g_hook_alloc".}
-proc free*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_free".}
-proc reference*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_ref".}
-proc unref*(hook_list: PGHookList, hook: PGHook){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_unref".}
-proc destroy*(hook_list: PGHookList, hook_id: gulong): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_destroy".}
-proc destroy_link*(hook_list: PGHookList, hook: PGHook){.cdecl, 
-    dynlib: gliblib, importc: "g_hook_destroy_link".}
-proc prepend*(hook_list: PGHookList, hook: PGHook){.cdecl, 
-    dynlib: gliblib, importc: "g_hook_prepend".}
-proc insert_before*(hook_list: PGHookList, sibling: PGHook, hook: PGHook){.
-    cdecl, dynlib: gliblib, importc: "g_hook_insert_before".}
-proc insert_sorted*(hook_list: PGHookList, hook: PGHook, 
-                           func: TGHookCompareFunc){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_insert_sorted".}
-proc get*(hook_list: PGHookList, hook_id: gulong): PGHook{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_get".}
-proc find*(hook_list: PGHookList, need_valids: gboolean, 
-                  func: TGHookFindFunc, data: gpointer): PGHook{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_find".}
-proc find_data*(hook_list: PGHookList, need_valids: gboolean, 
-                       data: gpointer): PGHook{.cdecl, dynlib: gliblib, 
-    importc: "g_hook_find_data".}
-proc find_func*(hook_list: PGHookList, need_valids: gboolean, 
-                       func: gpointer): PGHook{.cdecl, dynlib: gliblib, 
-    importc: "g_hook_find_func".}
-proc find_func_data*(hook_list: PGHookList, need_valids: gboolean, 
-                            func: gpointer, data: gpointer): PGHook{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_find_func_data".}
-proc first_valid*(hook_list: PGHookList, may_be_in_call: gboolean): PGHook{.
-    cdecl, dynlib: gliblib, importc: "g_hook_first_valid".}
-proc next_valid*(hook_list: PGHookList, hook: PGHook, 
-                        may_be_in_call: gboolean): PGHook{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_next_valid".}
-proc compare_ids*(new_hook: PGHook, sibling: PGHook): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_hook_compare_ids".}
-proc append*(hook_list: PGHookList, hook: PGHook)
-proc list_invoke_check*(hook_list: PGHookList, may_recurse: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_hook_list_invoke_check".}
-proc list_marshal*(hook_list: PGHookList, may_recurse: gboolean, 
-                          marshaller: TGHookMarshaller, marshal_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_hook_list_marshal".}
-proc list_marshal_check*(hook_list: PGHookList, may_recurse: gboolean, 
-                                marshaller: TGHookCheckMarshaller, 
-                                marshal_data: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_hook_list_marshal_check".}
-type 
-  PGThreadPool* = ptr TGThreadPool
-  TGThreadPool*{.final.} = object 
-    func*: TGFunc
-    user_data*: gpointer
-    exclusive*: gboolean
-
-
-proc g_thread_pool_new*(func: TGFunc, user_data: gpointer, max_threads: gint, 
-                        exclusive: gboolean, error: pointer): PGThreadPool{.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_new".}
-proc pool_push*(pool: PGThreadPool, data: gpointer, error: pointer){.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_push".}
-proc pool_set_max_threads*(pool: PGThreadPool, max_threads: gint, 
-                                    error: pointer){.cdecl, dynlib: gliblib, 
-    importc: "g_thread_pool_set_max_threads".}
-proc pool_get_max_threads*(pool: PGThreadPool): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_thread_pool_get_max_threads".}
-proc pool_get_num_threads*(pool: PGThreadPool): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_thread_pool_get_num_threads".}
-proc pool_unprocessed*(pool: PGThreadPool): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_thread_pool_unprocessed".}
-proc pool_free*(pool: PGThreadPool, immediate: gboolean, wait: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_thread_pool_free".}
-proc g_thread_pool_set_max_unused_threads*(max_threads: gint){.cdecl, 
-    dynlib: gliblib, importc: "g_thread_pool_set_max_unused_threads".}
-proc g_thread_pool_get_max_unused_threads*(): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_thread_pool_get_max_unused_threads".}
-proc g_thread_pool_get_num_unused_threads*(): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_thread_pool_get_num_unused_threads".}
-proc g_thread_pool_stop_unused_threads*(){.cdecl, dynlib: gliblib, 
-    importc: "g_thread_pool_stop_unused_threads".}
-type 
-  PGTimer* = pointer
-
-const 
-  G_USEC_PER_SEC* = 1000000
-
-proc g_timer_new*(): PGTimer{.cdecl, dynlib: gliblib, importc: "g_timer_new".}
-proc destroy*(timer: PGTimer){.cdecl, dynlib: gliblib, 
-                                       importc: "g_timer_destroy".}
-proc start*(timer: PGTimer){.cdecl, dynlib: gliblib, 
-                                     importc: "g_timer_start".}
-proc stop*(timer: PGTimer){.cdecl, dynlib: gliblib, 
-                                    importc: "g_timer_stop".}
-proc reset*(timer: PGTimer){.cdecl, dynlib: gliblib, 
-                                     importc: "g_timer_reset".}
-proc elapsed*(timer: PGTimer, microseconds: Pgulong): gdouble{.cdecl, 
-    dynlib: gliblib, importc: "g_timer_elapsed".}
-proc g_usleep*(microseconds: gulong){.cdecl, dynlib: gliblib, 
-                                      importc: "g_usleep".}
-proc val_add*(time: PGTimeVal, microseconds: glong){.cdecl, 
-    dynlib: gliblib, importc: "g_time_val_add".}
-type 
-  Pgunichar* = ptr gunichar
-  gunichar* = guint32
-  Pgunichar2* = ptr gunichar2
-  gunichar2* = guint16
-  PGUnicodeType* = ptr TGUnicodeType
-  TGUnicodeType* = enum 
-    G_UNICODE_CONTROL, G_UNICODE_FORMAT, G_UNICODE_UNASSIGNED, 
-    G_UNICODE_PRIVATE_USE, G_UNICODE_SURROGATE, G_UNICODE_LOWERCASE_LETTER, 
-    G_UNICODE_MODIFIER_LETTER, G_UNICODE_OTHER_LETTER, 
-    G_UNICODE_TITLECASE_LETTER, G_UNICODE_UPPERCASE_LETTER, 
-    G_UNICODE_COMBINING_MARK, G_UNICODE_ENCLOSING_MARK, 
-    G_UNICODE_NON_SPACING_MARK, G_UNICODE_DECIMAL_NUMBER, 
-    G_UNICODE_LETTER_NUMBER, G_UNICODE_OTHER_NUMBER, 
-    G_UNICODE_CONNECT_PUNCTUATION, G_UNICODE_DASH_PUNCTUATION, 
-    G_UNICODE_CLOSE_PUNCTUATION, G_UNICODE_FINAL_PUNCTUATION, 
-    G_UNICODE_INITIAL_PUNCTUATION, G_UNICODE_OTHER_PUNCTUATION, 
-    G_UNICODE_OPEN_PUNCTUATION, G_UNICODE_CURRENCY_SYMBOL, 
-    G_UNICODE_MODIFIER_SYMBOL, G_UNICODE_MATH_SYMBOL, G_UNICODE_OTHER_SYMBOL, 
-    G_UNICODE_LINE_SEPARATOR, G_UNICODE_PARAGRAPH_SEPARATOR, 
-    G_UNICODE_SPACE_SEPARATOR
-  PGUnicodeBreakType* = ptr TGUnicodeBreakType
-  TGUnicodeBreakType* = enum 
-    G_UNICODE_BREAK_MANDATORY, G_UNICODE_BREAK_CARRIAGE_RETURN, 
-    G_UNICODE_BREAK_LINE_FEED, G_UNICODE_BREAK_COMBINING_MARK, 
-    G_UNICODE_BREAK_SURROGATE, G_UNICODE_BREAK_ZERO_WIDTH_SPACE, 
-    G_UNICODE_BREAK_INSEPARABLE, G_UNICODE_BREAK_NON_BREAKING_GLUE, 
-    G_UNICODE_BREAK_CONTINGENT, G_UNICODE_BREAK_SPACE, G_UNICODE_BREAK_AFTER, 
-    G_UNICODE_BREAK_BEFORE, G_UNICODE_BREAK_BEFORE_AND_AFTER, 
-    G_UNICODE_BREAK_HYPHEN, G_UNICODE_BREAK_NON_STARTER, 
-    G_UNICODE_BREAK_OPEN_PUNCTUATION, G_UNICODE_BREAK_CLOSE_PUNCTUATION, 
-    G_UNICODE_BREAK_QUOTATION, G_UNICODE_BREAK_EXCLAMATION, 
-    G_UNICODE_BREAK_IDEOGRAPHIC, G_UNICODE_BREAK_NUMERIC, 
-    G_UNICODE_BREAK_INFIX_SEPARATOR, G_UNICODE_BREAK_SYMBOL, 
-    G_UNICODE_BREAK_ALPHABETIC, G_UNICODE_BREAK_PREFIX, G_UNICODE_BREAK_POSTFIX, 
-    G_UNICODE_BREAK_COMPLEX_CONTEXT, G_UNICODE_BREAK_AMBIGUOUS, 
-    G_UNICODE_BREAK_UNKNOWN
-
-proc g_get_charset*(charset: PPchar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_get_charset".}
-proc g_unichar_isalnum*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isalnum".}
-proc g_unichar_isalpha*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isalpha".}
-proc g_unichar_iscntrl*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_iscntrl".}
-proc g_unichar_isdigit*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isdigit".}
-proc g_unichar_isgraph*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isgraph".}
-proc g_unichar_islower*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_islower".}
-proc g_unichar_isprint*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isprint".}
-proc g_unichar_ispunct*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_ispunct".}
-proc g_unichar_isspace*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isspace".}
-proc g_unichar_isupper*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isupper".}
-proc g_unichar_isxdigit*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isxdigit".}
-proc g_unichar_istitle*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_istitle".}
-proc g_unichar_isdefined*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_isdefined".}
-proc g_unichar_iswide*(c: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_iswide".}
-proc g_unichar_toupper*(c: gunichar): gunichar{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_toupper".}
-proc g_unichar_tolower*(c: gunichar): gunichar{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_tolower".}
-proc g_unichar_totitle*(c: gunichar): gunichar{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_totitle".}
-proc g_unichar_digit_value*(c: gunichar): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_digit_value".}
-proc g_unichar_xdigit_value*(c: gunichar): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_xdigit_value".}
-proc g_unichar_type*(c: gunichar): TGUnicodeType{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_type".}
-proc g_unichar_break_type*(c: gunichar): TGUnicodeBreakType{.cdecl, 
-    dynlib: gliblib, importc: "g_unichar_break_type".}
-proc unicode_canonical_ordering*(str: Pgunichar, len: gsize){.cdecl, 
-    dynlib: gliblib, importc: "g_unicode_canonical_ordering".}
-proc g_unicode_canonical_decomposition*(ch: gunichar, result_len: Pgsize): Pgunichar{.
-    cdecl, dynlib: gliblib, importc: "g_unicode_canonical_decomposition".}
-proc utf8_next_char*(p: pguchar): pguchar
-proc g_utf8_get_char*(p: cstring): gunichar{.cdecl, dynlib: gliblib, 
-    importc: "g_utf8_get_char".}
-proc g_utf8_get_char_validated*(p: cstring, max_len: gssize): gunichar{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_get_char_validated".}
-proc g_utf8_offset_to_pointer*(str: cstring, offset: glong): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_offset_to_pointer".}
-proc g_utf8_pointer_to_offset*(str: cstring, pos: cstring): glong{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_pointer_to_offset".}
-proc g_utf8_prev_char*(p: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_utf8_prev_char".}
-proc g_utf8_find_next_char*(p: cstring, `end`: cstring): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_find_next_char".}
-proc g_utf8_find_prev_char*(str: cstring, p: cstring): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_find_prev_char".}
-proc g_utf8_strlen*(p: cstring, max: gssize): glong{.cdecl, dynlib: gliblib, 
-    importc: "g_utf8_strlen".}
-proc g_utf8_strncpy*(dest: cstring, src: cstring, n: gsize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_strncpy".}
-proc g_utf8_strchr*(p: cstring, len: gssize, c: gunichar): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_strchr".}
-proc g_utf8_strrchr*(p: cstring, len: gssize, c: gunichar): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_strrchr".}
-proc g_utf8_to_utf16*(str: cstring, len: glong, items_read: Pglong, 
-                      items_written: Pglong, error: pointer): Pgunichar2{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_to_utf16".}
-proc g_utf8_to_ucs4*(str: cstring, len: glong, items_read: Pglong, 
-                     items_written: Pglong, error: pointer): Pgunichar{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_to_ucs4".}
-proc g_utf8_to_ucs4_fast*(str: cstring, len: glong, items_written: Pglong): Pgunichar{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_to_ucs4_fast".}
-proc utf16_to_ucs4*(str: Pgunichar2, len: glong, items_read: Pglong, 
-                      items_written: Pglong, error: pointer): Pgunichar{.cdecl, 
-    dynlib: gliblib, importc: "g_utf16_to_ucs4".}
-proc utf16_to_utf8*(str: Pgunichar2, len: glong, items_read: Pglong, 
-                      items_written: Pglong, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf16_to_utf8".}
-proc ucs4_to_utf16*(str: Pgunichar, len: glong, items_read: Pglong, 
-                      items_written: Pglong, error: pointer): Pgunichar2{.cdecl, 
-    dynlib: gliblib, importc: "g_ucs4_to_utf16".}
-proc ucs4_to_utf8*(str: Pgunichar, len: glong, items_read: Pglong, 
-                     items_written: Pglong, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_ucs4_to_utf8".}
-proc g_unichar_to_utf8*(c: gunichar, outbuf: cstring): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_unichar_to_utf8".}
-proc g_utf8_validate*(str: cstring, max_len: gssize, `end`: PPgchar): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_validate".}
-proc g_unichar_validate*(ch: gunichar): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_unichar_validate".}
-proc g_utf8_strup*(str: cstring, len: gssize): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_utf8_strup".}
-proc g_utf8_strdown*(str: cstring, len: gssize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_strdown".}
-proc g_utf8_casefold*(str: cstring, len: gssize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_casefold".}
-type 
-  PGNormalizeMode* = ptr TGNormalizeMode
-  TGNormalizeMode* = gint
-
-const 
-  G_NORMALIZE_DEFAULT* = 0
-  G_NORMALIZE_NFD* = G_NORMALIZE_DEFAULT
-  G_NORMALIZE_DEFAULT_COMPOSE* = 1
-  G_NORMALIZE_NFC* = G_NORMALIZE_DEFAULT_COMPOSE
-  G_NORMALIZE_ALL* = 2
-  G_NORMALIZE_NFKD* = G_NORMALIZE_ALL
-  G_NORMALIZE_ALL_COMPOSE* = 3
-  G_NORMALIZE_NFKC* = G_NORMALIZE_ALL_COMPOSE
-
-proc g_utf8_normalize*(str: cstring, len: gssize, mode: TGNormalizeMode): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_utf8_normalize".}
-proc g_utf8_collate*(str1: cstring, str2: cstring): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_collate".}
-proc g_utf8_collate_key*(str: cstring, len: gssize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_utf8_collate_key".}
-type 
-  PGString* = ptr TGString
-  TGString*{.final.} = object 
-    str*: cstring
-    len*: gsize
-    allocated_len*: gsize
-
-  PGStringChunk* = pointer
-
-proc g_string_chunk_new*(size: gsize): PGStringChunk{.cdecl, dynlib: gliblib, 
-    importc: "g_string_chunk_new".}
-proc chunk_free*(chunk: PGStringChunk){.cdecl, dynlib: gliblib, 
-    importc: "g_string_chunk_free".}
-proc chunk_insert*(chunk: PGStringChunk, str: cstring): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_string_chunk_insert".}
-proc chunk_insert_const*(chunk: PGStringChunk, str: cstring): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_string_chunk_insert_const".}
-proc g_string_new*(init: cstring): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_new".}
-proc g_string_new_len*(init: cstring, len: gssize): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_new_len".}
-proc g_string_sized_new*(dfl_size: gsize): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_sized_new".}
-proc free*(str: PGString, free_segment: gboolean): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_string_free".}
-proc equal*(v: PGString, v2: PGString): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_string_equal".}
-proc hash*(str: PGString): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_string_hash".}
-proc assign*(str: PGString, rval: cstring): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_assign".}
-proc truncate*(str: PGString, len: gsize): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_truncate".}
-proc set_size*(str: PGString, len: gsize): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_set_size".}
-proc insert_len*(str: PGString, pos: gssize, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert_len".}
-proc append*(str: PGString, val: cstring): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_append".}
-proc append_len*(str: PGString, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_append_len".}
-proc append_c*(str: PGString, c: gchar): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_append_c".}
-proc append_unichar*(str: PGString, wc: gunichar): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_append_unichar".}
-proc prepend*(str: PGString, val: cstring): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_prepend".}
-proc prepend_c*(str: PGString, c: gchar): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_prepend_c".}
-proc prepend_unichar*(str: PGString, wc: gunichar): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_prepend_unichar".}
-proc prepend_len*(str: PGString, val: cstring, len: gssize): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_prepend_len".}
-proc insert*(str: PGString, pos: gssize, val: cstring): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert".}
-proc insert_c*(str: PGString, pos: gssize, c: gchar): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_insert_c".}
-proc insert_unichar*(str: PGString, pos: gssize, wc: gunichar): PGString{.
-    cdecl, dynlib: gliblib, importc: "g_string_insert_unichar".}
-proc erase*(str: PGString, pos: gssize, len: gssize): PGString{.cdecl, 
-    dynlib: gliblib, importc: "g_string_erase".}
-proc ascii_down*(str: PGString): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_ascii_down".}
-proc ascii_up*(str: PGString): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_ascii_up".}
-proc down*(str: PGString): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_down".}
-proc up*(str: PGString): PGString{.cdecl, dynlib: gliblib, 
-    importc: "g_string_up".}
-type 
-  PGIOError* = ptr TGIOError
-  TGIOError* = enum 
-    G_IO_ERROR_NONE, G_IO_ERROR_AGAIN, G_IO_ERROR_INVAL, G_IO_ERROR_UNKNOWN
-
-proc G_IO_CHANNEL_ERROR*(): TGQuark
-type 
-  PGIOChannelError* = ptr TGIOChannelError
-  TGIOChannelError* = enum 
-    G_IO_CHANNEL_ERROR_FBIG, G_IO_CHANNEL_ERROR_INVAL, G_IO_CHANNEL_ERROR_IO, 
-    G_IO_CHANNEL_ERROR_ISDIR, G_IO_CHANNEL_ERROR_NOSPC, G_IO_CHANNEL_ERROR_NXIO, 
-    G_IO_CHANNEL_ERROR_OVERFLOW, G_IO_CHANNEL_ERROR_PIPE, 
-    G_IO_CHANNEL_ERROR_FAILED
-  PGIOStatus* = ptr TGIOStatus
-  TGIOStatus* = enum 
-    G_IO_STATUS_ERROR, G_IO_STATUS_NORMAL, G_IO_STATUS_EOF, G_IO_STATUS_AGAIN
-  PGSeekType* = ptr TGSeekType
-  TGSeekType* = enum 
-    G_SEEK_CUR, G_SEEK_SET, G_SEEK_END
-  PGIOCondition* = ptr TGIOCondition
-  TGIOCondition* = gint
-
-const 
-  G_IO_IN* = GLIB_SYSDEF_POLLIN
-  G_IO_OUT* = GLIB_SYSDEF_POLLOUT
-  G_IO_PRI* = GLIB_SYSDEF_POLLPRI
-  G_IO_ERR* = GLIB_SYSDEF_POLLERR
-  G_IO_HUP* = GLIB_SYSDEF_POLLHUP
-  G_IO_NVAL* = GLIB_SYSDEF_POLLNVAL
-
-type 
-  PGIOFlags* = ptr TGIOFlags
-  TGIOFlags* = gint
-
-const 
-  G_IO_FLAG_APPEND* = 1 shl 0
-  G_IO_FLAG_NONBLOCK* = 1 shl 1
-  G_IO_FLAG_IS_READABLE* = 1 shl 2
-  G_IO_FLAG_IS_WRITEABLE* = 1 shl 3
-  G_IO_FLAG_IS_SEEKABLE* = 1 shl 4
-  G_IO_FLAG_MASK* = (1 shl 5) - 1
-  G_IO_FLAG_GET_MASK* = G_IO_FLAG_MASK
-  G_IO_FLAG_SET_MASK* = G_IO_FLAG_APPEND or G_IO_FLAG_NONBLOCK
-
-type 
-  PGIOChannel* = ptr TGIOChannel
-  TGIOFunc* = proc (source: PGIOChannel, condition: TGIOCondition, 
-                    data: gpointer): gboolean{.cdecl.}
-  PGIOFuncs* = ptr TGIOFuncs
-  TGIOFuncs*{.final.} = object 
-    io_read*: proc (channel: PGIOChannel, buf: cstring, count: gsize, 
-                    bytes_read: Pgsize, err: pointer): TGIOStatus{.cdecl.}
-    io_write*: proc (channel: PGIOChannel, buf: cstring, count: gsize, 
-                     bytes_written: Pgsize, err: pointer): TGIOStatus{.cdecl.}
-    io_seek*: proc (channel: PGIOChannel, offset: gint64, theType: TGSeekType, 
-                    err: pointer): TGIOStatus{.cdecl.}
-    io_close*: proc (channel: PGIOChannel, err: pointer): TGIOStatus{.cdecl.}
-    io_create_watch*: proc (channel: PGIOChannel, condition: TGIOCondition): PGSource{.
-        cdecl.}
-    io_free*: proc (channel: PGIOChannel){.cdecl.}
-    io_set_flags*: proc (channel: PGIOChannel, flags: TGIOFlags, err: pointer): TGIOStatus{.
-        cdecl.}
-    io_get_flags*: proc (channel: PGIOChannel): TGIOFlags{.cdecl.}
-
-  TGIOChannel*{.final.} = object 
-    ref_count*: guint
-    funcs*: PGIOFuncs
-    encoding*: cstring
-    read_cd*: TGIConv
-    write_cd*: TGIConv
-    line_term*: cstring
-    line_term_len*: guint
-    buf_size*: gsize
-    read_buf*: PGString
-    encoded_read_buf*: PGString
-    write_buf*: PGString
-    partial_write_buf*: array[0..5, gchar]
-    flag0*: guint16
-    reserved1*: gpointer
-    reserved2*: gpointer
-
-
-const 
-  bm_TGIOChannel_use_buffer* = 0x0001'i16
-  bp_TGIOChannel_use_buffer* = 0'i16
-  bm_TGIOChannel_do_encode* = 0x0002'i16
-  bp_TGIOChannel_do_encode* = 1'i16
-  bm_TGIOChannel_close_on_unref* = 0x0004'i16
-  bp_TGIOChannel_close_on_unref* = 2'i16
-  bm_TGIOChannel_is_readable* = 0x0008'i16
-  bp_TGIOChannel_is_readable* = 3'i16
-  bm_TGIOChannel_is_writeable* = 0x0010'i16
-  bp_TGIOChannel_is_writeable* = 4'i16
-  bm_TGIOChannel_is_seekable* = 0x0020'i16
-  bp_TGIOChannel_is_seekable* = 5'i16
-
-proc TGIOChannel_use_buffer*(a: PGIOChannel): guint
-proc TGIOChannel_set_use_buffer*(a: PGIOChannel, `use_buffer`: guint)
-proc TGIOChannel_do_encode*(a: PGIOChannel): guint
-proc TGIOChannel_set_do_encode*(a: PGIOChannel, `do_encode`: guint)
-proc TGIOChannel_close_on_unref*(a: PGIOChannel): guint
-proc TGIOChannel_set_close_on_unref*(a: PGIOChannel, `close_on_unref`: guint)
-proc TGIOChannel_is_readable*(a: PGIOChannel): guint
-proc TGIOChannel_set_is_readable*(a: PGIOChannel, `is_readable`: guint)
-proc TGIOChannel_is_writeable*(a: PGIOChannel): guint
-proc TGIOChannel_set_is_writeable*(a: PGIOChannel, `is_writeable`: guint)
-proc TGIOChannel_is_seekable*(a: PGIOChannel): guint
-proc TGIOChannel_set_is_seekable*(a: PGIOChannel, `is_seekable`: guint)
-proc channel_init*(channel: PGIOChannel){.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_init".}
-proc channel_ref*(channel: PGIOChannel){.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_ref".}
-proc channel_unref*(channel: PGIOChannel){.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_unref".}
-proc channel_read*(channel: PGIOChannel, buf: cstring, count: gsize, 
-                        bytes_read: Pgsize): TGIOError{.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_read".}
-proc channel_write*(channel: PGIOChannel, buf: cstring, count: gsize, 
-                         bytes_written: Pgsize): TGIOError{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_write".}
-proc channel_seek*(channel: PGIOChannel, offset: gint64, 
-                        theType: TGSeekType): TGIOError{.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_seek".}
-proc channel_close*(channel: PGIOChannel){.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_close".}
-proc channel_shutdown*(channel: PGIOChannel, flush: gboolean, err: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_shutdown".}
-proc add_watch_full*(channel: PGIOChannel, priority: gint, 
-                          condition: TGIOCondition, func: TGIOFunc, 
-                          user_data: gpointer, notify: TGDestroyNotify): guint{.
-    cdecl, dynlib: gliblib, importc: "g_io_add_watch_full".}
-proc create_watch*(channel: PGIOChannel, condition: TGIOCondition): PGSource{.
-    cdecl, dynlib: gliblib, importc: "g_io_create_watch".}
-proc add_watch*(channel: PGIOChannel, condition: TGIOCondition, 
-                     func: TGIOFunc, user_data: gpointer): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_io_add_watch".}
-proc channel_set_buffer_size*(channel: PGIOChannel, size: gsize){.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_set_buffer_size".}
-proc channel_get_buffer_size*(channel: PGIOChannel): gsize{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_get_buffer_size".}
-proc channel_get_buffer_condition*(channel: PGIOChannel): TGIOCondition{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_get_buffer_condition".}
-proc channel_set_flags*(channel: PGIOChannel, flags: TGIOFlags, 
-                             error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_set_flags".}
-proc channel_get_flags*(channel: PGIOChannel): TGIOFlags{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_get_flags".}
-proc channel_set_line_term*(channel: PGIOChannel, line_term: cstring, 
-                                 length: gint){.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_set_line_term".}
-proc channel_get_line_term*(channel: PGIOChannel, length: Pgint): cstring{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_get_line_term".}
-proc channel_set_buffered*(channel: PGIOChannel, buffered: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_set_buffered".}
-proc channel_get_buffered*(channel: PGIOChannel): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_get_buffered".}
-proc channel_set_encoding*(channel: PGIOChannel, encoding: cstring, 
-                                error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_set_encoding".}
-proc channel_get_encoding*(channel: PGIOChannel): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_get_encoding".}
-proc channel_set_close_on_unref*(channel: PGIOChannel, do_close: gboolean){.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_set_close_on_unref".}
-proc channel_get_close_on_unref*(channel: PGIOChannel): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_get_close_on_unref".}
-proc channel_flush*(channel: PGIOChannel, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_flush".}
-proc channel_read_line*(channel: PGIOChannel, str_return: PPgchar, 
-                             length: Pgsize, terminator_pos: Pgsize, 
-                             error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_read_line".}
-proc channel_read_line_string*(channel: PGIOChannel, buffer: PGString, 
-                                    terminator_pos: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_line_string".}
-proc channel_read_to_end*(channel: PGIOChannel, str_return: PPgchar, 
-                               length: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_to_end".}
-proc channel_read_chars*(channel: PGIOChannel, buf: cstring, count: gsize, 
-                              bytes_read: Pgsize, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_read_chars".}
-proc channel_read_unichar*(channel: PGIOChannel, thechar: Pgunichar, 
-                                error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_read_unichar".}
-proc channel_write_chars*(channel: PGIOChannel, buf: cstring, 
-                               count: gssize, bytes_written: Pgsize, 
-                               error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_write_chars".}
-proc channel_write_unichar*(channel: PGIOChannel, thechar: gunichar, 
-                                 error: pointer): TGIOStatus{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_write_unichar".}
-proc channel_seek_position*(channel: PGIOChannel, offset: gint64, 
-                                 theType: TGSeekType, error: pointer): TGIOStatus{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_seek_position".}
-proc g_io_channel_new_file*(filename: cstring, mode: cstring, error: pointer): PGIOChannel{.
-    cdecl, dynlib: gliblib, importc: "g_io_channel_new_file".}
-proc g_io_channel_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_error_quark".}
-proc g_io_channel_error_from_errno*(en: gint): TGIOChannelError{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_error_from_errno".}
-proc g_io_channel_unix_new*(fd: int32): PGIOChannel{.cdecl, dynlib: gliblib, 
-    importc: "g_io_channel_unix_new".}
-proc channel_unix_get_fd*(channel: PGIOChannel): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_io_channel_unix_get_fd".}
-const 
-  G_LOG_LEVEL_USER_SHIFT* = 8
-
-type 
-  PGLogLevelFlags* = ptr TGLogLevelFlags
-  TGLogLevelFlags* = int32
-
-const 
-  G_LOG_FLAG_RECURSION* = 1 shl 0
-  G_LOG_FLAG_FATAL* = 1 shl 1
-  G_LOG_LEVEL_ERROR* = 1 shl 2
-  G_LOG_LEVEL_CRITICAL* = 1 shl 3
-  G_LOG_LEVEL_WARNING* = 1 shl 4
-  G_LOG_LEVEL_MESSAGE* = 1 shl 5
-  G_LOG_LEVEL_INFO* = 1 shl 6
-  G_LOG_LEVEL_DEBUG* = 1 shl 7
-  G_LOG_LEVEL_MASK* = not 3
-
-const 
-  G_LOG_FATAL_MASK* = 5
-
-type 
-  TGLogFunc* = proc (log_domain: cstring, log_level: TGLogLevelFlags, 
-                     TheMessage: cstring, user_data: gpointer){.cdecl.}
-
-proc g_log_set_handler*(log_domain: cstring, log_levels: TGLogLevelFlags, 
-                        log_func: TGLogFunc, user_data: gpointer): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_log_set_handler".}
-proc g_log_remove_handler*(log_domain: cstring, handler_id: guint){.cdecl, 
-    dynlib: gliblib, importc: "g_log_remove_handler".}
-proc g_log_default_handler*(log_domain: cstring, log_level: TGLogLevelFlags, 
-                            TheMessage: cstring, unused_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_log_default_handler".}
-proc g_log_set_fatal_mask*(log_domain: cstring, fatal_mask: TGLogLevelFlags): TGLogLevelFlags{.
-    cdecl, dynlib: gliblib, importc: "g_log_set_fatal_mask".}
-proc g_log_set_always_fatal*(fatal_mask: TGLogLevelFlags): TGLogLevelFlags{.
-    cdecl, dynlib: gliblib, importc: "g_log_set_always_fatal".}
-proc `g_log_fallback_handler`*(log_domain: cstring, log_level: TGLogLevelFlags, 
-                               message: cstring, unused_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_log_fallback_handler".}
-const 
-  G_LOG_DOMAIN* = nil
-
-when false: 
-  proc g_error*(format: cstring){.varargs.}
-  proc g_message*(format: cstring){.varargs.}
-  proc g_critical*(format: cstring){.varargs.}
-  proc g_warning*(format: cstring){.varargs.}
-type 
-  TGPrintFunc* = proc (str: cstring)
-
-proc g_set_print_handler*(func: TGPrintFunc): TGPrintFunc{.cdecl, 
-    dynlib: gliblib, importc: "g_set_print_handler".}
-proc g_set_printerr_handler*(func: TGPrintFunc): TGPrintFunc{.cdecl, 
-    dynlib: gliblib, importc: "g_set_printerr_handler".}
-type 
-  PGMarkupError* = ptr TGMarkupError
-  TGMarkupError* = enum 
-    G_MARKUP_ERROR_BAD_UTF8, G_MARKUP_ERROR_EMPTY, G_MARKUP_ERROR_PARSE, 
-    G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, 
-    G_MARKUP_ERROR_INVALID_CONTENT
-
-proc G_MARKUP_ERROR*(): TGQuark
-proc g_markup_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-                                       importc: "g_markup_error_quark".}
-type 
-  PGMarkupParseFlags* = ptr TGMarkupParseFlags
-  TGMarkupParseFlags* = int
-
-const 
-  G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG* = 1 shl 0
-
-type 
-  PGMarkupParseContext* = ptr TGMarkupParseContext
-  TGMarkupParseContext* = pointer
-  PGMarkupParser* = ptr TGMarkupParser
-  TGMarkupParser*{.final.} = object 
-    start_element*: proc (context: PGMarkupParseContext, element_name: cstring, 
-                          attribute_names: PPgchar, attribute_values: PPgchar, 
-                          user_data: gpointer, error: pointer){.cdecl.}
-    end_element*: proc (context: PGMarkupParseContext, element_name: cstring, 
-                        user_data: gpointer, error: pointer){.cdecl.}
-    text*: proc (context: PGMarkupParseContext, text: cstring, text_len: gsize, 
-                 user_data: gpointer, error: pointer){.cdecl.}
-    passthrough*: proc (context: PGMarkupParseContext, 
-                        passthrough_text: cstring, text_len: gsize, 
-                        user_data: gpointer, error: pointer){.cdecl.}
-    error*: proc (context: PGMarkupParseContext, error: pointer, 
-                  user_data: gpointer){.cdecl.}
-
-
-proc parse_context_new*(parser: PGMarkupParser, 
-                                 flags: TGMarkupParseFlags, user_data: gpointer, 
-                                 user_data_dnotify: TGDestroyNotify): PGMarkupParseContext{.
-    cdecl, dynlib: gliblib, importc: "g_markup_parse_context_new".}
-proc parse_context_free*(context: PGMarkupParseContext){.cdecl, 
-    dynlib: gliblib, importc: "g_markup_parse_context_free".}
-proc parse_context_parse*(context: PGMarkupParseContext, text: cstring, 
-                                   text_len: gssize, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_markup_parse_context_parse".}
-proc parse_context_end_parse*(context: PGMarkupParseContext, 
-                                       error: pointer): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_markup_parse_context_end_parse".}
-proc parse_context_get_position*(context: PGMarkupParseContext, 
-    line_number: Pgint, char_number: Pgint){.cdecl, dynlib: gliblib, 
-    importc: "g_markup_parse_context_get_position".}
-proc g_markup_escape_text*(text: cstring, length: gssize): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_markup_escape_text".}
-type 
-  PGNode* = ptr TGNode
-  TGNode*{.final.} = object 
-    data*: gpointer
-    next*: PGNode
-    prev*: PGNode
-    parent*: PGNode
-    children*: PGNode
-
-  PGTraverseFlags* = ptr TGTraverseFlags
-  TGTraverseFlags* = gint
-
-const 
-  G_TRAVERSE_LEAFS* = 1 shl 0
-  G_TRAVERSE_NON_LEAFS* = 1 shl 1
-  G_TRAVERSE_ALL* = G_TRAVERSE_LEAFS or G_TRAVERSE_NON_LEAFS
-  G_TRAVERSE_MASK* = 0x00000003
-
-type 
-  PGTraverseType* = ptr TGTraverseType
-  TGTraverseType* = enum 
-    G_IN_ORDER, G_PRE_ORDER, G_POST_ORDER, G_LEVEL_ORDER
-  TGNodeTraverseFunc* = proc (node: PGNode, data: gpointer): gboolean{.cdecl.}
-  TGNodeForeachFunc* = proc (node: PGNode, data: gpointer){.cdecl.}
-
-proc IS_ROOT*(node: PGNode): bool
-proc IS_LEAF*(node: PGNode): bool
-proc node_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: gliblib, 
-    importc: "g_node_push_allocator".}
-proc g_node_pop_allocator*(){.cdecl, dynlib: gliblib, 
-                              importc: "g_node_pop_allocator".}
-proc g_node_new*(data: gpointer): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_new".}
-proc destroy*(root: PGNode){.cdecl, dynlib: gliblib, 
-                                    importc: "g_node_destroy".}
-proc unlink*(node: PGNode){.cdecl, dynlib: gliblib, 
-                                   importc: "g_node_unlink".}
-proc copy*(node: PGNode): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_copy".}
-proc insert*(parent: PGNode, position: gint, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert".}
-proc insert_before*(parent: PGNode, sibling: PGNode, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert_before".}
-proc insert_after*(parent: PGNode, sibling: PGNode, node: PGNode): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_insert_after".}
-proc prepend*(parent: PGNode, node: PGNode): PGNode{.cdecl, 
-    dynlib: gliblib, importc: "g_node_prepend".}
-proc n_nodes*(root: PGNode, flags: TGTraverseFlags): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_node_n_nodes".}
-proc get_root*(node: PGNode): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_get_root".}
-proc is_ancestor*(node: PGNode, descendant: PGNode): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_node_is_ancestor".}
-proc depth*(node: PGNode): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_node_depth".}
-proc find*(root: PGNode, order: TGTraverseType, flags: TGTraverseFlags, 
-                  data: gpointer): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_find".}
-proc append*(parent: PGNode, node: PGNode): PGNode
-proc insert_data*(parent: PGNode, position: gint, data: gpointer): PGNode
-proc insert_data_before*(parent: PGNode, sibling: PGNode, data: gpointer): PGNode
-proc prepend_data*(parent: PGNode, data: gpointer): PGNode
-proc append_data*(parent: PGNode, data: gpointer): PGNode
-proc traverse*(root: PGNode, order: TGTraverseType, 
-                      flags: TGTraverseFlags, max_depth: gint, 
-                      func: TGNodeTraverseFunc, data: gpointer): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_node_traverse".}
-proc max_height*(root: PGNode): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_node_max_height".}
-proc children_foreach*(node: PGNode, flags: TGTraverseFlags, 
-                              func: TGNodeForeachFunc, data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_node_children_foreach".}
-proc reverse_children*(node: PGNode){.cdecl, dynlib: gliblib, 
-    importc: "g_node_reverse_children".}
-proc n_children*(node: PGNode): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_node_n_children".}
-proc nth_child*(node: PGNode, n: guint): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_nth_child".}
-proc last_child*(node: PGNode): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_last_child".}
-proc find_child*(node: PGNode, flags: TGTraverseFlags, data: gpointer): PGNode{.
-    cdecl, dynlib: gliblib, importc: "g_node_find_child".}
-proc child_position*(node: PGNode, child: PGNode): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_node_child_position".}
-proc child_index*(node: PGNode, data: gpointer): gint{.cdecl, 
-    dynlib: gliblib, importc: "g_node_child_index".}
-proc first_sibling*(node: PGNode): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_first_sibling".}
-proc last_sibling*(node: PGNode): PGNode{.cdecl, dynlib: gliblib, 
-    importc: "g_node_last_sibling".}
-proc prev_sibling*(node: PGNode): PGNode
-proc next_sibling*(node: PGNode): PGNode
-proc first_child*(node: PGNode): PGNode
-type 
-  PGTree* = pointer
-  TGTraverseFunc* = proc (key: gpointer, value: gpointer, data: gpointer): gboolean{.
-      cdecl.}
-
-proc g_tree_new*(key_compare_func: TGCompareFunc): PGTree{.cdecl, 
-    dynlib: gliblib, importc: "g_tree_new".}
-proc g_tree_new*(key_compare_func: TGCompareDataFunc, 
-                           key_compare_data: gpointer): PGTree{.cdecl, 
-    dynlib: gliblib, importc: "g_tree_new_with_data".}
-proc g_tree_new_full*(key_compare_func: TGCompareDataFunc, 
-                      key_compare_data: gpointer, 
-                      key_destroy_func: TGDestroyNotify, 
-                      value_destroy_func: TGDestroyNotify): PGTree{.cdecl, 
-    dynlib: gliblib, importc: "g_tree_new_full".}
-proc destroy*(tree: PGTree){.cdecl, dynlib: gliblib, 
-                                    importc: "g_tree_destroy".}
-proc insert*(tree: PGTree, key: gpointer, value: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_tree_insert".}
-proc replace*(tree: PGTree, key: gpointer, value: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_tree_replace".}
-proc remove*(tree: PGTree, key: gconstpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_tree_remove".}
-proc steal*(tree: PGTree, key: gconstpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_tree_steal".}
-proc lookup*(tree: PGTree, key: gconstpointer): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_tree_lookup".}
-proc lookup_extended*(tree: PGTree, lookup_key: gconstpointer, 
-                             orig_key: Pgpointer, value: Pgpointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_tree_lookup_extended".}
-proc foreach*(tree: PGTree, func: TGTraverseFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_tree_foreach".}
-proc search*(tree: PGTree, search_func: TGCompareFunc, 
-                    user_data: gconstpointer): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_tree_search".}
-proc height*(tree: PGTree): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_tree_height".}
-proc nnodes*(tree: PGTree): gint{.cdecl, dynlib: gliblib, 
-    importc: "g_tree_nnodes".}
-type 
-  PGPatternSpec* = pointer
-
-proc g_pattern_spec_new*(pattern: cstring): PGPatternSpec{.cdecl, 
-    dynlib: gliblib, importc: "g_pattern_spec_new".}
-proc spec_free*(pspec: PGPatternSpec){.cdecl, dynlib: gliblib, 
-    importc: "g_pattern_spec_free".}
-proc spec_equal*(pspec1: PGPatternSpec, pspec2: PGPatternSpec): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_pattern_spec_equal".}
-proc match*(pspec: PGPatternSpec, string_length: guint, str: cstring, 
-                      string_reversed: cstring): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_pattern_match".}
-proc match_string*(pspec: PGPatternSpec, str: cstring): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_pattern_match_string".}
-proc g_pattern_match_simple*(pattern: cstring, str: cstring): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_pattern_match_simple".}
-proc g_spaced_primes_closest*(num: guint): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_spaced_primes_closest".}
-proc g_qsort*(pbase: gconstpointer, total_elems: gint, size: gsize, 
-                        compare_func: TGCompareDataFunc, user_data: gpointer){.
-    cdecl, dynlib: gliblib, importc: "g_qsort_with_data".}
-type 
-  PGQueue* = ptr TGQueue
-  TGQueue*{.final.} = object 
-    head*: PGList
-    tail*: PGList
-    length*: guint
-
-
-proc g_queue_new*(): PGQueue{.cdecl, dynlib: gliblib, importc: "g_queue_new".}
-proc free*(queue: PGQueue){.cdecl, dynlib: gliblib, 
-                                    importc: "g_queue_free".}
-proc push_head*(queue: PGQueue, data: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_queue_push_head".}
-proc push_tail*(queue: PGQueue, data: gpointer){.cdecl, dynlib: gliblib, 
-    importc: "g_queue_push_tail".}
-proc pop_head*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_pop_head".}
-proc pop_tail*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_pop_tail".}
-proc is_empty*(queue: PGQueue): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_is_empty".}
-proc peek_head*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_peek_head".}
-proc peek_tail*(queue: PGQueue): gpointer{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_peek_tail".}
-proc push_head_link*(queue: PGQueue, link: PGList){.cdecl, 
-    dynlib: gliblib, importc: "g_queue_push_head_link".}
-proc push_tail_link*(queue: PGQueue, link: PGList){.cdecl, 
-    dynlib: gliblib, importc: "g_queue_push_tail_link".}
-proc pop_head_link*(queue: PGQueue): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_pop_head_link".}
-proc pop_tail_link*(queue: PGQueue): PGList{.cdecl, dynlib: gliblib, 
-    importc: "g_queue_pop_tail_link".}
-type 
-  PGRand* = pointer
-
-proc g_rand_new*(seed: guint32): PGRand{.cdecl, dynlib: gliblib, 
-    importc: "g_rand_new_with_seed".}
-proc g_rand_new*(): PGRand{.cdecl, dynlib: gliblib, importc: "g_rand_new".}
-proc free*(rand: PGRand){.cdecl, dynlib: gliblib, importc: "g_rand_free".}
-proc set_seed*(rand: PGRand, seed: guint32){.cdecl, dynlib: gliblib, 
-    importc: "g_rand_set_seed".}
-proc boolean*(rand: PGRand): gboolean
-proc randint*(rand: PGRand): guint32{.cdecl, dynlib: gliblib, 
-    importc: "g_rand_int".}
-proc int_range*(rand: PGRand, `begin`: gint32, `end`: gint32): gint32{.
-    cdecl, dynlib: gliblib, importc: "g_rand_int_range".}
-proc double*(rand: PGRand): gdouble{.cdecl, dynlib: gliblib, 
-    importc: "g_rand_double".}
-proc double_range*(rand: PGRand, `begin`: gdouble, `end`: gdouble): gdouble{.
-    cdecl, dynlib: gliblib, importc: "g_rand_double_range".}
-proc g_random_set_seed*(seed: guint32){.cdecl, dynlib: gliblib, 
-                                        importc: "g_random_set_seed".}
-proc g_random_boolean*(): gboolean
-proc g_random_int*(): guint32{.cdecl, dynlib: gliblib, importc: "g_random_int".}
-proc g_random_int_range*(`begin`: gint32, `end`: gint32): gint32{.cdecl, 
-    dynlib: gliblib, importc: "g_random_int_range".}
-proc g_random_double*(): gdouble{.cdecl, dynlib: gliblib, 
-                                  importc: "g_random_double".}
-proc g_random_double_range*(`begin`: gdouble, `end`: gdouble): gdouble{.cdecl, 
-    dynlib: gliblib, importc: "g_random_double_range".}
-type 
-  PGTuples* = ptr TGTuples
-  TGTuples*{.final.} = object 
-    len*: guint
-
-  PGRelation* = pointer
-
-proc g_relation_new*(fields: gint): PGRelation{.cdecl, dynlib: gliblib, 
-    importc: "g_relation_new".}
-proc destroy*(relation: PGRelation){.cdecl, dynlib: gliblib, 
-    importc: "g_relation_destroy".}
-proc index*(relation: PGRelation, field: gint, hash_func: TGHashFunc, 
-                       key_equal_func: TGEqualFunc){.cdecl, dynlib: gliblib, 
-    importc: "g_relation_index".}
-proc delete*(relation: PGRelation, key: gconstpointer, field: gint): gint{.
-    cdecl, dynlib: gliblib, importc: "g_relation_delete".}
-proc select*(relation: PGRelation, key: gconstpointer, field: gint): PGTuples{.
-    cdecl, dynlib: gliblib, importc: "g_relation_select".}
-proc count*(relation: PGRelation, key: gconstpointer, field: gint): gint{.
-    cdecl, dynlib: gliblib, importc: "g_relation_count".}
-proc print*(relation: PGRelation){.cdecl, dynlib: gliblib, 
-    importc: "g_relation_print".}
-proc destroy*(tuples: PGTuples){.cdecl, dynlib: gliblib, 
-    importc: "g_tuples_destroy".}
-proc index*(tuples: PGTuples, index: gint, field: gint): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_tuples_index".}
-type 
-  PGTokenType* = ptr TGTokenType
-  TGTokenType* = gint
-
-const 
-  G_TOKEN_LEFT_PAREN* = 40
-  G_TOKEN_RIGHT_PAREN* = 41
-  G_TOKEN_LEFT_CURLY* = 123
-  G_TOKEN_RIGHT_CURLY* = 125
-  G_TOKEN_LEFT_BRACE* = 91
-  G_TOKEN_RIGHT_BRACE* = 93
-  G_TOKEN_EQUAL_SIGN* = 61
-  G_TOKEN_COMMA* = 44
-  G_TOKEN_NONE* = 256
-  G_TOKEN_ERROR* = 257
-  G_TOKEN_CHAR* = 258
-  G_TOKEN_OCTAL* = 260
-  G_TOKEN_INT* = 261
-  G_TOKEN_HEX* = 262
-  G_TOKEN_FLOAT* = 263
-  G_TOKEN_STRING* = 264
-  G_TOKEN_SYMBOL* = 265
-  G_TOKEN_IDENTIFIER* = 266
-  G_TOKEN_IDENTIFIER_NULL* = 267
-  G_TOKEN_COMMENT_SINGLE* = 268
-  G_TOKEN_COMMENT_MULTI* = 269
-  G_TOKEN_LAST* = 270
-
-type 
-  PGScanner* = ptr TGScanner
-  PGScannerConfig* = ptr TGScannerConfig
-  PGTokenValue* = ptr TGTokenValue
-  TGTokenValue*{.final.} = object 
-    v_float*: gdouble
-
-  TGScannerMsgFunc* = proc (scanner: PGScanner, message: cstring, 
-                            error: gboolean){.cdecl.}
-  TGScanner*{.final.} = object 
-    user_data*: gpointer
-    max_parse_errors*: guint
-    parse_errors*: guint
-    input_name*: cstring
-    qdata*: PGData
-    config*: PGScannerConfig
-    token*: TGTokenType
-    value*: TGTokenValue
-    line*: guint
-    position*: guint
-    next_token*: TGTokenType
-    next_value*: TGTokenValue
-    next_line*: guint
-    next_position*: guint
-    symbol_table*: PGHashTable
-    input_fd*: gint
-    text*: cstring
-    text_end*: cstring
-    buffer*: cstring
-    scope_id*: guint
-    msg_handler*: TGScannerMsgFunc
-
-  TGScannerConfig*{.final.} = object 
-    cset_skip_characters*: cstring
-    cset_identifier_first*: cstring
-    cset_identifier_nth*: cstring
-    cpair_comment_single*: cstring
-    flag0*: int32
-    padding_dummy*: guint
-
-
-const 
-  G_CSET_A_2_Z_UCASE* = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-  G_CSET_a_2_z_lcase* = "abcdefghijklmnopqrstuvwxyz"
-  G_CSET_DIGITS* = "0123456789"
-
-const 
-  bm_TGScannerConfig_case_sensitive* = 0x00000001'i32
-  bp_TGScannerConfig_case_sensitive* = 0'i32
-  bm_TGScannerConfig_skip_comment_multi* = 0x00000002'i32
-  bp_TGScannerConfig_skip_comment_multi* = 1'i32
-  bm_TGScannerConfig_skip_comment_single* = 0x00000004'i32
-  bp_TGScannerConfig_skip_comment_single* = 2'i32
-  bm_TGScannerConfig_scan_comment_multi* = 0x00000008'i32
-  bp_TGScannerConfig_scan_comment_multi* = 3'i32
-  bm_TGScannerConfig_scan_identifier* = 0x00000010'i32
-  bp_TGScannerConfig_scan_identifier* = 4'i32
-  bm_TGScannerConfig_scan_identifier_1char* = 0x00000020'i32
-  bp_TGScannerConfig_scan_identifier_1char* = 5'i32
-  bm_TGScannerConfig_scan_identifier_NULL* = 0x00000040'i32
-  bp_TGScannerConfig_scan_identifier_NULL* = 6'i32
-  bm_TGScannerConfig_scan_symbols* = 0x00000080'i32
-  bp_TGScannerConfig_scan_symbols* = 7'i32
-  bm_TGScannerConfig_scan_binary* = 0x00000100'i32
-  bp_TGScannerConfig_scan_binary* = 8'i32
-  bm_TGScannerConfig_scan_octal* = 0x00000200'i32
-  bp_TGScannerConfig_scan_octal* = 9'i32
-  bm_TGScannerConfig_scan_float* = 0x00000400'i32
-  bp_TGScannerConfig_scan_float* = 10'i32
-  bm_TGScannerConfig_scan_hex* = 0x00000800'i32
-  bp_TGScannerConfig_scan_hex* = 11'i32
-  bm_TGScannerConfig_scan_hex_dollar* = 0x00001000'i32
-  bp_TGScannerConfig_scan_hex_dollar* = 12'i32
-  bm_TGScannerConfig_scan_string_sq* = 0x00002000'i32
-  bp_TGScannerConfig_scan_string_sq* = 13'i32
-  bm_TGScannerConfig_scan_string_dq* = 0x00004000'i32
-  bp_TGScannerConfig_scan_string_dq* = 14'i32
-  bm_TGScannerConfig_numbers_2_int* = 0x00008000'i32
-  bp_TGScannerConfig_numbers_2_int* = 15'i32
-  bm_TGScannerConfig_int_2_float* = 0x00010000'i32
-  bp_TGScannerConfig_int_2_float* = 16'i32
-  bm_TGScannerConfig_identifier_2_string* = 0x00020000'i32
-  bp_TGScannerConfig_identifier_2_string* = 17'i32
-  bm_TGScannerConfig_char_2_token* = 0x00040000'i32
-  bp_TGScannerConfig_char_2_token* = 18'i32
-  bm_TGScannerConfig_symbol_2_token* = 0x00080000'i32
-  bp_TGScannerConfig_symbol_2_token* = 19'i32
-  bm_TGScannerConfig_scope_0_fallback* = 0x00100000'i32
-  bp_TGScannerConfig_scope_0_fallback* = 20'i32
-
-proc TGScannerConfig_case_sensitive*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_case_sensitive*(a: PGScannerConfig, 
-    `case_sensitive`: guint)
-proc TGScannerConfig_skip_comment_multi*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_skip_comment_multi*(a: PGScannerConfig, 
-    `skip_comment_multi`: guint)
-proc TGScannerConfig_skip_comment_single*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_skip_comment_single*(a: PGScannerConfig, 
-    `skip_comment_single`: guint)
-proc TGScannerConfig_scan_comment_multi*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_comment_multi*(a: PGScannerConfig, 
-    `scan_comment_multi`: guint)
-proc TGScannerConfig_scan_identifier*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier*(a: PGScannerConfig, 
-    `scan_identifier`: guint)
-proc TGScannerConfig_scan_identifier_1char*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier_1char*(a: PGScannerConfig, 
-    `scan_identifier_1char`: guint)
-proc TGScannerConfig_scan_identifier_NULL*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_identifier_NULL*(a: PGScannerConfig, 
-    `scan_identifier_NULL`: guint)
-proc TGScannerConfig_scan_symbols*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_symbols*(a: PGScannerConfig, 
-                                       `scan_symbols`: guint)
-proc TGScannerConfig_scan_binary*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_binary*(a: PGScannerConfig, 
-                                      `scan_binary`: guint)
-proc TGScannerConfig_scan_octal*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_octal*(a: PGScannerConfig, `scan_octal`: guint)
-proc TGScannerConfig_scan_float*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_float*(a: PGScannerConfig, `scan_float`: guint)
-proc TGScannerConfig_scan_hex*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_hex*(a: PGScannerConfig, `scan_hex`: guint)
-proc TGScannerConfig_scan_hex_dollar*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_hex_dollar*(a: PGScannerConfig, 
-    `scan_hex_dollar`: guint)
-proc TGScannerConfig_scan_string_sq*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_string_sq*(a: PGScannerConfig, 
-    `scan_string_sq`: guint)
-proc TGScannerConfig_scan_string_dq*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scan_string_dq*(a: PGScannerConfig, 
-    `scan_string_dq`: guint)
-proc TGScannerConfig_numbers_2_int*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_numbers_2_int*(a: PGScannerConfig, 
-                                        `numbers_2_int`: guint)
-proc TGScannerConfig_int_2_float*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_int_2_float*(a: PGScannerConfig, 
-                                      `int_2_float`: guint)
-proc TGScannerConfig_identifier_2_string*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_identifier_2_string*(a: PGScannerConfig, 
-    `identifier_2_string`: guint)
-proc TGScannerConfig_char_2_token*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_char_2_token*(a: PGScannerConfig, 
-                                       `char_2_token`: guint)
-proc TGScannerConfig_symbol_2_token*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_symbol_2_token*(a: PGScannerConfig, 
-    `symbol_2_token`: guint)
-proc TGScannerConfig_scope_0_fallback*(a: PGScannerConfig): guint
-proc TGScannerConfig_set_scope_0_fallback*(a: PGScannerConfig, 
-    `scope_0_fallback`: guint)
-proc new*(config_templ: PGScannerConfig): PGScanner{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_new".}
-proc destroy*(scanner: PGScanner){.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_destroy".}
-proc input_file*(scanner: PGScanner, input_fd: gint){.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_input_file".}
-proc sync_file_offset*(scanner: PGScanner){.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_sync_file_offset".}
-proc input_text*(scanner: PGScanner, text: cstring, text_len: guint){.
-    cdecl, dynlib: gliblib, importc: "g_scanner_input_text".}
-proc get_next_token*(scanner: PGScanner): TGTokenType{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_get_next_token".}
-proc peek_next_token*(scanner: PGScanner): TGTokenType{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_peek_next_token".}
-proc cur_token*(scanner: PGScanner): TGTokenType{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_cur_token".}
-proc cur_value*(scanner: PGScanner): TGTokenValue{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_cur_value".}
-proc cur_line*(scanner: PGScanner): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_cur_line".}
-proc cur_position*(scanner: PGScanner): guint{.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_cur_position".}
-proc eof*(scanner: PGScanner): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_eof".}
-proc set_scope*(scanner: PGScanner, scope_id: guint): guint{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_set_scope".}
-proc scope_add_symbol*(scanner: PGScanner, scope_id: guint, 
-                                 symbol: cstring, value: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_scope_add_symbol".}
-proc scope_remove_symbol*(scanner: PGScanner, scope_id: guint, 
-                                    symbol: cstring){.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_scope_remove_symbol".}
-proc scope_lookup_symbol*(scanner: PGScanner, scope_id: guint, 
-                                    symbol: cstring): gpointer{.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_scope_lookup_symbol".}
-proc scope_foreach_symbol*(scanner: PGScanner, scope_id: guint, 
-                                     func: TGHFunc, user_data: gpointer){.cdecl, 
-    dynlib: gliblib, importc: "g_scanner_scope_foreach_symbol".}
-proc lookup_symbol*(scanner: PGScanner, symbol: cstring): gpointer{.
-    cdecl, dynlib: gliblib, importc: "g_scanner_lookup_symbol".}
-proc unexp_token*(scanner: PGScanner, expected_token: TGTokenType, 
-                            identifier_spec: cstring, symbol_spec: cstring, 
-                            symbol_name: cstring, `message`: cstring, 
-                            is_error: gint){.cdecl, dynlib: gliblib, 
-    importc: "g_scanner_unexp_token".}
-proc G_SHELL_ERROR*(): TGQuark
-type 
-  PGShellError* = ptr TGShellError
-  TGShellError* = enum 
-    G_SHELL_ERROR_BAD_QUOTING, G_SHELL_ERROR_EMPTY_STRING, G_SHELL_ERROR_FAILED
-
-proc g_shell_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-                                      importc: "g_shell_error_quark".}
-proc g_shell_quote*(unquoted_string: cstring): cstring{.cdecl, dynlib: gliblib, 
-    importc: "g_shell_quote".}
-proc g_shell_unquote*(quoted_string: cstring, error: pointer): cstring{.cdecl, 
-    dynlib: gliblib, importc: "g_shell_unquote".}
-proc g_shell_parse_argv*(command_line: cstring, argcp: Pgint, argvp: PPPgchar, 
-                         error: pointer): gboolean{.cdecl, dynlib: gliblib, 
-    importc: "g_shell_parse_argv".}
-proc G_SPAWN_ERROR*(): TGQuark
-type 
-  PGSpawnError* = ptr TGSpawnError
-  TGSpawnError* = enum 
-    G_SPAWN_ERROR_FORK, G_SPAWN_ERROR_READ, G_SPAWN_ERROR_CHDIR, 
-    G_SPAWN_ERROR_ACCES, G_SPAWN_ERROR_PERM, G_SPAWN_ERROR_2BIG, 
-    G_SPAWN_ERROR_NOEXEC, G_SPAWN_ERROR_NAMETOOLONG, G_SPAWN_ERROR_NOENT, 
-    G_SPAWN_ERROR_NOMEM, G_SPAWN_ERROR_NOTDIR, G_SPAWN_ERROR_LOOP, 
-    G_SPAWN_ERROR_TXTBUSY, G_SPAWN_ERROR_IO, G_SPAWN_ERROR_NFILE, 
-    G_SPAWN_ERROR_MFILE, G_SPAWN_ERROR_INVAL, G_SPAWN_ERROR_ISDIR, 
-    G_SPAWN_ERROR_LIBBAD, G_SPAWN_ERROR_FAILED
-  TGSpawnChildSetupFunc* = proc (user_data: gpointer){.cdecl.}
-  PGSpawnFlags* = ptr TGSpawnFlags
-  TGSpawnFlags* = int
-
-const 
-  G_SPAWN_LEAVE_DESCRIPTORS_OPEN* = 1 shl 0
-  G_SPAWN_DO_NOT_REAP_CHILD* = 1 shl 1
-  G_SPAWN_SEARCH_PATH* = 1 shl 2
-  G_SPAWN_STDOUT_TO_DEV_NULL* = 1 shl 3
-  G_SPAWN_STDERR_TO_DEV_NULL* = 1 shl 4
-  G_SPAWN_CHILD_INHERITS_STDIN* = 1 shl 5
-  G_SPAWN_FILE_AND_ARGV_ZERO* = 1 shl 6
-
-proc g_spawn_error_quark*(): TGQuark{.cdecl, dynlib: gliblib, 
-                                      importc: "g_spawn_error_quark".}
-proc g_spawn_async*(working_directory: cstring, argv: PPgchar, envp: PPgchar, 
-                    flags: TGSpawnFlags, child_setup: TGSpawnChildSetupFunc, 
-                    user_data: gpointer, child_pid: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_async".}
-proc g_spawn_async*(working_directory: cstring, argv: PPgchar, 
-                               envp: PPgchar, flags: TGSpawnFlags, 
-                               child_setup: TGSpawnChildSetupFunc, 
-                               user_data: gpointer, child_pid: Pgint, 
-                               standard_input: Pgint, standard_output: Pgint, 
-                               standard_error: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_async_with_pipes".}
-proc g_spawn_sync*(working_directory: cstring, argv: PPgchar, envp: PPgchar, 
-                   flags: TGSpawnFlags, child_setup: TGSpawnChildSetupFunc, 
-                   user_data: gpointer, standard_output: PPgchar, 
-                   standard_error: PPgchar, exit_status: Pgint, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_sync".}
-proc g_spawn_command_line_sync*(command_line: cstring, standard_output: PPgchar, 
-                                standard_error: PPgchar, exit_status: Pgint, 
-                                error: pointer): gboolean{.cdecl, 
-    dynlib: gliblib, importc: "g_spawn_command_line_sync".}
-proc g_spawn_command_line_async*(command_line: cstring, error: pointer): gboolean{.
-    cdecl, dynlib: gliblib, importc: "g_spawn_command_line_async".}
-proc G_TYPE_IS_BOXED*(theType: GType): gboolean
-proc HOLDS_BOXED*(value: PGValue): gboolean
-proc G_TYPE_CLOSURE*(): GType
-proc G_TYPE_VALUE*(): GType
-proc G_TYPE_VALUE_ARRAY*(): GType
-proc G_TYPE_GSTRING*(): GType
-proc g_boxed_copy*(boxed_type: GType, src_boxed: gconstpointer): gpointer{.
-    cdecl, dynlib: gobjectlib, importc: "g_boxed_copy".}
-proc g_boxed_free*(boxed_type: GType, boxed: gpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_boxed_free".}
-proc set_boxed*(value: PGValue, v_boxed: gconstpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_boxed".}
-proc set_static_boxed*(value: PGValue, v_boxed: gconstpointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_value_set_static_boxed".}
-proc get_boxed*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_get_boxed".}
-proc dup_boxed*(value: PGValue): gpointer{.cdecl, dynlib: gobjectlib, 
-    importc: "g_value_dup_boxed".}
-proc g_boxed_type_register_static*(name: cstring, boxed_copy: TGBoxedCopyFunc, 
-                                   boxed_free: TGBoxedFreeFunc): GType{.cdecl, 
-    dynlib: gobjectlib, importc: "g_boxed_type_register_static".}
-proc set_boxed_take_ownership*(value: PGValue, v_boxed: gconstpointer){.
-    cdecl, dynlib: gobjectlib, importc: "g_value_set_boxed_take_ownership".}
-proc g_closure_get_type*(): GType{.cdecl, dynlib: gobjectlib, 
-                                   importc: "g_closure_get_type".}
-proc g_value_get_type*(): GType{.cdecl, dynlib: gobjectlib, 
-                                 importc: "g_value_get_type".}
-proc g_value_array_get_type*(): GType{.cdecl, dynlib: gobjectlib, 
-                                       importc: "g_value_array_get_type".}
-proc g_gstring_get_type*(): GType{.cdecl, dynlib: gobjectlib, 
-                                   importc: "g_gstring_get_type".}
-type 
-  PGModule* = pointer
-  TGModuleFlags* = int32
-  TGModuleCheckInit* = proc (module: PGModule): cstring{.cdecl.}
-  TGModuleUnload* = proc (module: PGModule){.cdecl.}
-
-const 
-  G_MODULE_BIND_LAZY* = 1 shl 0
-  G_MODULE_BIND_MASK* = 1
-
-proc g_module_supported*(): gboolean{.cdecl, dynlib: gmodulelib, 
-                                      importc: "g_module_supported".}
-proc g_module_open*(file_name: cstring, flags: TGModuleFlags): PGModule{.cdecl, 
-    dynlib: gmodulelib, importc: "g_module_open".}
-proc close*(module: PGModule): gboolean{.cdecl, dynlib: gmodulelib, 
-    importc: "g_module_close".}
-proc make_resident*(module: PGModule){.cdecl, dynlib: gmodulelib, 
-    importc: "g_module_make_resident".}
-proc g_module_error*(): cstring{.cdecl, dynlib: gmodulelib, 
-                                 importc: "g_module_error".}
-proc symbol*(module: PGModule, symbol_name: cstring, symbol: Pgpointer): gboolean{.
-    cdecl, dynlib: gmodulelib, importc: "g_module_symbol".}
-proc name*(module: PGModule): cstring{.cdecl, dynlib: gmodulelib, 
-    importc: "g_module_name".}
-proc g_module_build_path*(directory: cstring, module_name: cstring): cstring{.
-    cdecl, dynlib: gmodulelib, importc: "g_module_build_path".}
-proc cclosure_marshal_VOID_VOID*(closure: PGClosure, return_value: PGValue, 
-                                    n_param_values: GUInt, 
-                                    param_values: PGValue, 
-                                    invocation_hint: GPointer, 
-                                    marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__VOID".}
-proc cclosure_marshal_VOID_BOOLEAN*(closure: PGClosure, 
-                                       return_value: PGValue, 
-                                       n_param_values: GUInt, 
-                                       param_values: PGValue, 
-                                       invocation_hint: GPointer, 
-                                       marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__BOOLEAN".}
-proc cclosure_marshal_VOID_CHAR*(closure: PGClosure, return_value: PGValue, 
-                                    n_param_values: GUInt, 
-                                    param_values: PGValue, 
-                                    invocation_hint: GPointer, 
-                                    marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__CHAR".}
-proc cclosure_marshal_VOID_UCHAR*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UCHAR".}
-proc cclosure_marshal_VOID_INT*(closure: PGClosure, return_value: PGValue, 
-                                   n_param_values: GUInt, param_values: PGValue, 
-                                   invocation_hint: GPointer, 
-                                   marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__INT".}
-proc cclosure_marshal_VOID_UINT*(closure: PGClosure, return_value: PGValue, 
-                                    n_param_values: GUInt, 
-                                    param_values: PGValue, 
-                                    invocation_hint: GPointer, 
-                                    marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UINT".}
-proc cclosure_marshal_VOID_LONG*(closure: PGClosure, return_value: PGValue, 
-                                    n_param_values: GUInt, 
-                                    param_values: PGValue, 
-                                    invocation_hint: GPointer, 
-                                    marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__LONG".}
-proc cclosure_marshal_VOID_ULONG*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__ULONG".}
-proc cclosure_marshal_VOID_ENUM*(closure: PGClosure, return_value: PGValue, 
-                                    n_param_values: GUInt, 
-                                    param_values: PGValue, 
-                                    invocation_hint: GPointer, 
-                                    marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__ENUM".}
-proc cclosure_marshal_VOID_FLAGS*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__FLAGS".}
-proc cclosure_marshal_VOID_FLOAT*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__FLOAT".}
-proc cclosure_marshal_VOID_DOUBLE*(closure: PGClosure, return_value: PGValue, 
-                                      n_param_values: GUInt, 
-                                      param_values: PGValue, 
-                                      invocation_hint: GPointer, 
-                                      marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__DOUBLE".}
-proc cclosure_marshal_VOID_STRING*(closure: PGClosure, return_value: PGValue, 
-                                      n_param_values: GUInt, 
-                                      param_values: PGValue, 
-                                      invocation_hint: GPointer, 
-                                      marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__STRING".}
-proc cclosure_marshal_VOID_PARAM*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__PARAM".}
-proc cclosure_marshal_VOID_BOXED*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__BOXED".}
-proc cclosure_marshal_VOID_POINTER*(closure: PGClosure, 
-                                       return_value: PGValue, 
-                                       n_param_values: GUInt, 
-                                       param_values: PGValue, 
-                                       invocation_hint: GPointer, 
-                                       marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__POINTER".}
-proc cclosure_marshal_VOID_OBJECT*(closure: PGClosure, return_value: PGValue, 
-                                      n_param_values: GUInt, 
-                                      param_values: PGValue, 
-                                      invocation_hint: GPointer, 
-                                      marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__OBJECT".}
-proc cclosure_marshal_STRING_OBJECT_POINTER*(closure: PGClosure, 
-    return_value: PGValue, n_param_values: GUInt, param_values: PGValue, 
-    invocation_hint: GPointer, marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_STRING__OBJECT_POINTER".}
-proc cclosure_marshal_VOID_UINT_POINTER*(closure: PGClosure, 
-    return_value: PGValue, n_param_values: GUInt, param_values: PGValue, 
-    invocation_hint: GPointer, marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_VOID__UINT_POINTER".}
-proc cclosure_marshal_BOOLEAN_FLAGS*(closure: PGClosure, 
-                                        return_value: PGValue, 
-                                        n_param_values: GUInt, 
-                                        param_values: PGValue, 
-                                        invocation_hint: GPointer, 
-                                        marshal_data: GPointer){.cdecl, 
-    dynlib: gobjectlib, importc: "g_cclosure_marshal_BOOLEAN__FLAGS".}
-proc cclosure_marshal_BOOL_FLAGS*(closure: PGClosure, return_value: PGValue, 
-                                     n_param_values: GUInt, 
-                                     param_values: PGValue, 
-                                     invocation_hint: GPointer, 
-                                     marshal_data: GPointer){.cdecl, 
-    dynlib: gliblib, importc: "g_cclosure_marshal_BOOLEAN__FLAGS".}
-proc GUINT16_SWAP_LE_BE_CONSTANT*(val: guint16): guint16 = 
-  Result = ((val and 0x00FF'i16) shl 8'i16) or
-      ((val and 0xFF00'i16) shr 8'i16)
-
-proc GUINT32_SWAP_LE_BE_CONSTANT*(val: guint32): guint32 = 
-  Result = ((val and 0x000000FF'i32) shl 24'i32) or
-      ((val and 0x0000FF00'i32) shl 8'i32) or
-      ((val and 0x00FF0000'i32) shr 8'i32) or
-      ((val and 0xFF000000'i32) shr 24'i32)
-
-proc GUINT_TO_POINTER*(i: guint): pointer = 
-  Result = cast[Pointer](TAddress(i))
-
-when false: 
-  type 
-    PGArray* = pointer
-  proc g_array_append_val*(a: PGArray, v: gpointer): PGArray = 
-    result = g_array_append_vals(a, addr(v), 1)
-
-  proc g_array_prepend_val*(a: PGArray, v: gpointer): PGArray = 
-    result = g_array_prepend_vals(a, addr(v), 1)
-
-  proc g_array_insert_val*(a: PGArray, i: guint, v: gpointer): PGArray = 
-    result = g_array_insert_vals(a, i, addr(v), 1)
-
-  proc g_ptr_array_index*(parray: PGPtrArray, index: guint): gpointer = 
-    result = cast[PGPointer](cast[int](parray ^. pdata) +
-        index * SizeOf(GPointer))^ 
-
-  proc G_THREAD_ERROR*(): TGQuark = 
-    result = g_thread_error_quark()
-
-  proc g_mutex_lock*(mutex: PGMutex) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.mutex_lock(mutex)
-
-  proc g_mutex_trylock*(mutex: PGMutex): gboolean = 
-    if g_threads_got_initialized: 
-      result = g_thread_functions_for_glib_use.mutex_trylock(mutex)
-    else: 
-      result = true
-
-  proc g_mutex_unlock*(mutex: PGMutex) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.mutex_unlock(mutex)
-
-  proc g_mutex_free*(mutex: PGMutex) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.mutex_free(mutex)
-
-  proc g_cond_wait*(cond: PGCond, mutex: PGMutex) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.cond_wait(cond, mutex)
-
-  proc g_cond_timed_wait*(cond: PGCond, mutex: PGMutex, end_time: PGTimeVal): gboolean = 
-    if g_threads_got_initialized: 
-      result = g_thread_functions_for_glib_use.cond_timed_wait(cond, mutex, 
-          end_time)
-    else: 
-      result = true
-
-  proc g_thread_supported*(): gboolean = 
-    result = g_threads_got_initialized
-
-  proc g_mutex_new*(): PGMutex = 
-    result = g_thread_functions_for_glib_use.mutex_new()
-
-  proc g_cond_new*(): PGCond = 
-    result = g_thread_functions_for_glib_use.cond_new()
-
-  proc g_cond_signal*(cond: PGCond) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.cond_signal(cond)
-
-  proc g_cond_broadcast*(cond: PGCond) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.cond_broadcast(cond)
-
-  proc g_cond_free*(cond: PGCond) = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.cond_free(cond)
-
-  proc g_private_new*(dest: TGDestroyNotify): PGPrivate = 
-    result = g_thread_functions_for_glib_use.private_new(dest)
-
-  proc g_private_get*(private_key: PGPrivate): gpointer = 
-    if g_threads_got_initialized: 
-      result = g_thread_functions_for_glib_use.private_get(private_key)
-    else: 
-      result = private_key
-
-  proc g_private_set*(private_key: var PGPrivate, data: gpointer) = 
-    if g_threads_got_initialized: 
-      nil
-    else: 
-      private_key = data
-
-  proc g_thread_yield*() = 
-    if g_threads_got_initialized: 
-      g_thread_functions_for_glib_use.thread_yield
-
-  proc g_thread_create*(func: TGThreadFunc, data: gpointer, joinable: gboolean, 
-                        error: pointer): PGThread = 
-    result = g_thread_create_full(func, data, 0, joinable, false, 
-                                  G_THREAD_PRIORITY_NORMAL, error)
-
-  proc g_static_mutex_get_mutex*(mutex: PPGMutex): PGMutex = 
-    result = g_static_mutex_get_mutex_impl(mutex)
-
-  proc g_static_mutex_lock*(mutex: PGStaticMutex) = 
-    g_mutex_lock(g_static_mutex_get_mutex_impl(PPGMutex(mutex)))
-
-  proc g_static_mutex_trylock*(mutex: PGStaticMutex): gboolean = 
-    result = g_mutex_trylock(g_static_mutex_get_mutex(PPGMutex(mutex)))
-
-  proc g_static_mutex_unlock*(mutex: PGStaticMutex) = 
-    g_mutex_unlock(g_static_mutex_get_mutex_impl(PPGMutex(mutex)))
-
-  proc g_main_new*(is_running: gboolean): PGMainLoop = 
-    result = g_main_loop_new(nil, is_running)
-
-  proc g_main_iteration*(may_block: gboolean): gboolean = 
-    result = g_main_context_iteration(nil, may_block)
-
-  proc g_main_pending*(): gboolean = 
-    result = g_main_context_pending(nil)
-
-  proc g_main_set_poll_func*(func: TGPollFunc) = 
-    g_main_context_set_poll_func(nil, func)
-
-proc next*(slist: PGSList): PGSList = 
-  if slist != nil: 
-    result = slist.next
-  else: 
-    result = nil
-
-proc g_new*(bytes_per_struct, n_structs: int): gpointer = 
-  result = g_malloc(n_structs * bytes_per_struct)
-
-proc g_new0*(bytes_per_struct, n_structs: int): gpointer = 
-  result = g_malloc0(n_structs * bytes_per_struct)
-
-proc g_renew*(struct_size: int, OldMem: gpointer, n_structs: int): gpointer = 
-  result = g_realloc(OldMem, struct_size * n_structs)
-
-proc g_chunk_new*(chunk: Pointer): Pointer = 
-  result = chunk_alloc(chunk)
-
-proc g_chunk_new0*(chunk: Pointer): Pointer = 
-  result = chunk_alloc0(chunk)
-
-proc previous*(list: PGList): PGList = 
-  if list != nil: 
-    result = list.prev
-  else: 
-    result = nil
-
-proc next*(list: PGList): PGList = 
-  if list != nil: 
-    result = list.next
-  else: 
-    result = nil
-
-proc G_CONVERT_ERROR*(): TGQuark = 
-  result = g_convert_error_quark()
-
-proc g_datalist_id_set_data*(datalist: PPGData, key_id: TGQuark, data: gpointer) = 
-  g_datalist_id_set_data_full(datalist, key_id, data, TGDestroyNotify(nil))
-
-proc g_datalist_id_remove_data*(datalist: PPGData, key_id: TGQuark) = 
-  g_datalist_id_set_data(datalist, key_id, nil)
-
-proc g_datalist_get_data*(datalist: PPGData, key_str: cstring): PPGData = 
-  result = cast[PPGData](g_datalist_id_get_data(datalist, 
-      g_quark_try_string(key_str)))
-
-proc g_datalist_set_data_full*(datalist: PPGData, key_str: cstring, 
-                               data: gpointer, destroy_func: TGDestroyNotify) = 
-  g_datalist_id_set_data_full(datalist, g_quark_from_string(key_str), data, 
-                              destroy_func)
-
-proc g_datalist_set_data*(datalist: PPGData, key_str: cstring, data: gpointer) = 
-  g_datalist_set_data_full(datalist, key_str, data, nil)
-
-proc g_datalist_remove_no_notify*(datalist: PPGData, key_str: cstring) = 
-  discard g_datalist_id_remove_no_notify(datalist, g_quark_try_string(key_str))
-
-proc g_datalist_remove_data*(datalist: PPGData, key_str: cstring) = 
-  g_datalist_id_set_data(datalist, g_quark_try_string(key_str), nil)
-
-proc g_dataset_id_set_data*(location: gconstpointer, key_id: TGQuark, 
-                            data: gpointer) = 
-  g_dataset_id_set_data_full(location, key_id, data, nil)
-
-proc g_dataset_id_remove_data*(location: gconstpointer, key_id: TGQuark) = 
-  g_dataset_id_set_data(location, key_id, nil)
-
-proc g_dataset_get_data*(location: gconstpointer, key_str: cstring): gpointer = 
-  result = g_dataset_id_get_data(location, g_quark_try_string(key_str))
-
-proc g_dataset_set_data_full*(location: gconstpointer, key_str: cstring, 
-                              data: gpointer, destroy_func: TGDestroyNotify) = 
-  g_dataset_id_set_data_full(location, g_quark_from_string(key_str), data, 
-                             destroy_func)
-
-proc g_dataset_remove_no_notify*(location: gconstpointer, key_str: cstring) = 
-  discard g_dataset_id_remove_no_notify(location, g_quark_try_string(key_str))
-
-proc g_dataset_set_data*(location: gconstpointer, key_str: cstring, 
-                         data: gpointer) = 
-  g_dataset_set_data_full(location, key_str, data, nil)
-
-proc g_dataset_remove_data*(location: gconstpointer, key_str: cstring) = 
-  g_dataset_id_set_data(location, g_quark_try_string(key_str), nil)
-
-proc G_FILE_ERROR*(): TGQuark = 
-  result = g_file_error_quark()
-
-proc TGHookList_hook_size*(a: PGHookList): guint = 
-  result = (a.flag0 and bm_TGHookList_hook_size) shr bp_TGHookList_hook_size
-
-proc TGHookList_set_hook_size*(a: PGHookList, `hook_size`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`hook_size` shl bp_TGHookList_hook_size) and bm_TGHookList_hook_size)
-
-proc TGHookList_is_setup*(a: PGHookList): guint = 
-  result = (a.flag0 and bm_TGHookList_is_setup) shr bp_TGHookList_is_setup
-
-proc TGHookList_set_is_setup*(a: PGHookList, `is_setup`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`is_setup` shl bp_TGHookList_is_setup) and bm_TGHookList_is_setup)
-
-proc G_HOOK*(hook: pointer): PGHook = 
-  result = cast[PGHook](hook)
-
-proc FLAGS*(hook: PGHook): guint = 
-  result = hook.flags
-
-proc ACTIVE*(hook: PGHook): bool = 
-  result = (hook.flags and G_HOOK_FLAG_ACTIVE) != 0'i32
-
-proc IN_CALL*(hook: PGHook): bool = 
-  result = (hook.flags and G_HOOK_FLAG_IN_CALL) != 0'i32
-
-proc IS_VALID*(hook: PGHook): bool = 
-  result = (hook.hook_id != 0) and ACTIVE(hook)
-
-proc IS_UNLINKED*(hook: PGHook): bool = 
-  result = (hook.next == nil) and (hook.prev == nil) and (hook.hook_id == 0) and
-      (hook.ref_count == 0'i32)
-
-proc append*(hook_list: PGHookList, hook: PGHook) = 
-  insert_before(hook_list, nil, hook)
-
-proc G_IO_CHANNEL_ERROR*(): TGQuark = 
-  result = g_io_channel_error_quark()
-
-proc TGIOChannel_use_buffer*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_use_buffer) shr
-      bp_TGIOChannel_use_buffer
-
-proc TGIOChannel_set_use_buffer*(a: PGIOChannel, `use_buffer`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`use_buffer` shl bp_TGIOChannel_use_buffer) and
-      bm_TGIOChannel_use_buffer)
-
-proc TGIOChannel_do_encode*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_do_encode) shr
-      bp_TGIOChannel_do_encode
-
-proc TGIOChannel_set_do_encode*(a: PGIOChannel, `do_encode`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`do_encode` shl bp_TGIOChannel_do_encode) and
-      bm_TGIOChannel_do_encode)
-
-proc TGIOChannel_close_on_unref*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_close_on_unref) shr
-      bp_TGIOChannel_close_on_unref
-
-proc TGIOChannel_set_close_on_unref*(a: PGIOChannel, `close_on_unref`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`close_on_unref` shl bp_TGIOChannel_close_on_unref) and
-      bm_TGIOChannel_close_on_unref)
-
-proc TGIOChannel_is_readable*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_is_readable) shr
-      bp_TGIOChannel_is_readable
-
-proc TGIOChannel_set_is_readable*(a: PGIOChannel, `is_readable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_readable` shl bp_TGIOChannel_is_readable) and
-      bm_TGIOChannel_is_readable)
-
-proc TGIOChannel_is_writeable*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_is_writeable) shr
-      bp_TGIOChannel_is_writeable
-
-proc TGIOChannel_set_is_writeable*(a: PGIOChannel, `is_writeable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_writeable` shl bp_TGIOChannel_is_writeable) and
-      bm_TGIOChannel_is_writeable)
-
-proc TGIOChannel_is_seekable*(a: PGIOChannel): guint = 
-  result = (a.flag0 and bm_TGIOChannel_is_seekable) shr
-      bp_TGIOChannel_is_seekable
-
-proc TGIOChannel_set_is_seekable*(a: PGIOChannel, `is_seekable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_seekable` shl bp_TGIOChannel_is_seekable) and
-      bm_TGIOChannel_is_seekable)
-
-proc utf8_next_char*(p: pguchar): pguchar = 
-  result = cast[pguchar](cast[TAddress](p) + 1) # p + ord((g_utf8_skip + p^ )^ )
-  
-when false: 
-  proc GLIB_CHECK_VERSION*(major, minor, micro: guint): bool = 
-    result = ((GLIB_MAJOR_VERSION > major) or
-        ((GLIB_MAJOR_VERSION == major) and (GLIB_MINOR_VERSION > minor)) or
-        ((GLIB_MAJOR_VERSION == major) and (GLIB_MINOR_VERSION == minor) and
-        (GLIB_MICRO_VERSION >= micro)))
-
-  proc g_error*(format: cstring) = 
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format)
-
-  proc g_message*(format: cstring) = 
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format)
-
-  proc g_critical*(format: cstring) = 
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format)
-
-  proc g_warning*(format: cstring) = 
-    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format)
-
-proc G_MARKUP_ERROR*(): TGQuark = 
-  result = g_markup_error_quark()
-
-proc IS_ROOT*(node: PGNode): bool = 
-  result = (node.parent == nil) and (node.next == nil) and (node.prev == nil)
-
-proc IS_LEAF*(node: PGNode): bool = 
-  result = node.children == nil
-
-proc append*(parent: PGNode, node: PGNode): PGNode = 
-  result = insert_before(parent, nil, node)
-
-proc insert_data*(parent: PGNode, position: gint, data: gpointer): PGNode = 
-  result = insert(parent, position, g_node_new(data))
-
-proc insert_data_before*(parent: PGNode, sibling: PGNode, 
-                         data: gpointer): PGNode = 
-  result = insert_before(parent, sibling, g_node_new(data))
-
-proc prepend_data*(parent: PGNode, data: gpointer): PGNode = 
-  result = prepend(parent, g_node_new(data))
-
-proc append_data*(parent: PGNode, data: gpointer): PGNode = 
-  result = insert_before(parent, nil, g_node_new(data))
-
-proc prev_sibling*(node: PGNode): PGNode = 
-  if node != nil: 
-    result = node.prev
-  else: 
-    result = nil
-
-proc next_sibling*(node: PGNode): PGNode = 
-  if node != nil: 
-    result = node.next
-  else: 
-    result = nil
-
-proc first_child*(node: PGNode): PGNode = 
-  if node != nil: 
-    result = node.children
-  else: 
-    result = nil
-
-proc boolean*(rand: PGRand): gboolean = 
-  result = (int(rand_int(rand)) and (1 shl 15)) != 0
-
-proc g_random_boolean*(): gboolean = 
-  result = (int(g_random_int()) and (1 shl 15)) != 0
-
-proc TGScannerConfig_case_sensitive*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_case_sensitive) shr
-      bp_TGScannerConfig_case_sensitive
-
-proc TGScannerConfig_set_case_sensitive*(a: PGScannerConfig, 
-    `case_sensitive`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`case_sensitive` shl bp_TGScannerConfig_case_sensitive) and
-      bm_TGScannerConfig_case_sensitive)
-
-proc TGScannerConfig_skip_comment_multi*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_skip_comment_multi) shr
-      bp_TGScannerConfig_skip_comment_multi
-
-proc TGScannerConfig_set_skip_comment_multi*(a: PGScannerConfig, 
-    `skip_comment_multi`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`skip_comment_multi` shl bp_TGScannerConfig_skip_comment_multi) and
-      bm_TGScannerConfig_skip_comment_multi)
-
-proc TGScannerConfig_skip_comment_single*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_skip_comment_single) shr
-      bp_TGScannerConfig_skip_comment_single
-
-proc TGScannerConfig_set_skip_comment_single*(a: PGScannerConfig, 
-    `skip_comment_single`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`skip_comment_single` shl bp_TGScannerConfig_skip_comment_single) and
-      bm_TGScannerConfig_skip_comment_single)
-
-proc TGScannerConfig_scan_comment_multi*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_comment_multi) shr
-      bp_TGScannerConfig_scan_comment_multi
-
-proc TGScannerConfig_set_scan_comment_multi*(a: PGScannerConfig, 
-    `scan_comment_multi`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_comment_multi` shl bp_TGScannerConfig_scan_comment_multi) and
-      bm_TGScannerConfig_scan_comment_multi)
-
-proc TGScannerConfig_scan_identifier*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier) shr
-      bp_TGScannerConfig_scan_identifier
-
-proc TGScannerConfig_set_scan_identifier*(a: PGScannerConfig, 
-    `scan_identifier`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_identifier` shl bp_TGScannerConfig_scan_identifier) and
-      bm_TGScannerConfig_scan_identifier)
-
-proc TGScannerConfig_scan_identifier_1char*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier_1char) shr
-      bp_TGScannerConfig_scan_identifier_1char
-
-proc TGScannerConfig_set_scan_identifier_1char*(a: PGScannerConfig, 
-    `scan_identifier_1char`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_identifier_1char` shl bp_TGScannerConfig_scan_identifier_1char) and
-      bm_TGScannerConfig_scan_identifier_1char)
-
-proc TGScannerConfig_scan_identifier_NULL*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_identifier_NULL) shr
-      bp_TGScannerConfig_scan_identifier_NULL
-
-proc TGScannerConfig_set_scan_identifier_NULL*(a: PGScannerConfig, 
-    `scan_identifier_NULL`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_identifier_NULL` shl bp_TGScannerConfig_scan_identifier_NULL) and
-      bm_TGScannerConfig_scan_identifier_NULL)
-
-proc TGScannerConfig_scan_symbols*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_symbols) shr
-      bp_TGScannerConfig_scan_symbols
-
-proc TGScannerConfig_set_scan_symbols*(a: PGScannerConfig, 
-                                       `scan_symbols`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_symbols` shl bp_TGScannerConfig_scan_symbols) and
-      bm_TGScannerConfig_scan_symbols)
-
-proc TGScannerConfig_scan_binary*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_binary) shr
-      bp_TGScannerConfig_scan_binary
-
-proc TGScannerConfig_set_scan_binary*(a: PGScannerConfig, 
-                                      `scan_binary`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_binary` shl bp_TGScannerConfig_scan_binary) and
-      bm_TGScannerConfig_scan_binary)
-
-proc TGScannerConfig_scan_octal*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_octal) shr
-      bp_TGScannerConfig_scan_octal
-
-proc TGScannerConfig_set_scan_octal*(a: PGScannerConfig, `scan_octal`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_octal` shl bp_TGScannerConfig_scan_octal) and
-      bm_TGScannerConfig_scan_octal)
-
-proc TGScannerConfig_scan_float*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_float) shr
-      bp_TGScannerConfig_scan_float
-
-proc TGScannerConfig_set_scan_float*(a: PGScannerConfig, `scan_float`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_float` shl bp_TGScannerConfig_scan_float) and
-      bm_TGScannerConfig_scan_float)
-
-proc TGScannerConfig_scan_hex*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_hex) shr
-      bp_TGScannerConfig_scan_hex
-
-proc TGScannerConfig_set_scan_hex*(a: PGScannerConfig, `scan_hex`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_hex` shl bp_TGScannerConfig_scan_hex) and
-      bm_TGScannerConfig_scan_hex)
-
-proc TGScannerConfig_scan_hex_dollar*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_hex_dollar) shr
-      bp_TGScannerConfig_scan_hex_dollar
-
-proc TGScannerConfig_set_scan_hex_dollar*(a: PGScannerConfig, 
-    `scan_hex_dollar`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_hex_dollar` shl bp_TGScannerConfig_scan_hex_dollar) and
-      bm_TGScannerConfig_scan_hex_dollar)
-
-proc TGScannerConfig_scan_string_sq*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_string_sq) shr
-      bp_TGScannerConfig_scan_string_sq
-
-proc TGScannerConfig_set_scan_string_sq*(a: PGScannerConfig, 
-    `scan_string_sq`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_string_sq` shl bp_TGScannerConfig_scan_string_sq) and
-      bm_TGScannerConfig_scan_string_sq)
-
-proc TGScannerConfig_scan_string_dq*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scan_string_dq) shr
-      bp_TGScannerConfig_scan_string_dq
-
-proc TGScannerConfig_set_scan_string_dq*(a: PGScannerConfig, 
-    `scan_string_dq`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scan_string_dq` shl bp_TGScannerConfig_scan_string_dq) and
-      bm_TGScannerConfig_scan_string_dq)
-
-proc TGScannerConfig_numbers_2_int*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_numbers_2_int) shr
-      bp_TGScannerConfig_numbers_2_int
-
-proc TGScannerConfig_set_numbers_2_int*(a: PGScannerConfig, 
-                                        `numbers_2_int`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`numbers_2_int` shl bp_TGScannerConfig_numbers_2_int) and
-      bm_TGScannerConfig_numbers_2_int)
-
-proc TGScannerConfig_int_2_float*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_int_2_float) shr
-      bp_TGScannerConfig_int_2_float
-
-proc TGScannerConfig_set_int_2_float*(a: PGScannerConfig, 
-                                      `int_2_float`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`int_2_float` shl bp_TGScannerConfig_int_2_float) and
-      bm_TGScannerConfig_int_2_float)
-
-proc TGScannerConfig_identifier_2_string*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_identifier_2_string) shr
-      bp_TGScannerConfig_identifier_2_string
-
-proc TGScannerConfig_set_identifier_2_string*(a: PGScannerConfig, 
-    `identifier_2_string`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`identifier_2_string` shl bp_TGScannerConfig_identifier_2_string) and
-      bm_TGScannerConfig_identifier_2_string)
-
-proc TGScannerConfig_char_2_token*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_char_2_token) shr
-      bp_TGScannerConfig_char_2_token
-
-proc TGScannerConfig_set_char_2_token*(a: PGScannerConfig, 
-                                       `char_2_token`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`char_2_token` shl bp_TGScannerConfig_char_2_token) and
-      bm_TGScannerConfig_char_2_token)
-
-proc TGScannerConfig_symbol_2_token*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_symbol_2_token) shr
-      bp_TGScannerConfig_symbol_2_token
-
-proc TGScannerConfig_set_symbol_2_token*(a: PGScannerConfig, 
-    `symbol_2_token`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`symbol_2_token` shl bp_TGScannerConfig_symbol_2_token) and
-      bm_TGScannerConfig_symbol_2_token)
-
-proc TGScannerConfig_scope_0_fallback*(a: PGScannerConfig): guint = 
-  result = (a.flag0 and bm_TGScannerConfig_scope_0_fallback) shr
-      bp_TGScannerConfig_scope_0_fallback
-
-proc TGScannerConfig_set_scope_0_fallback*(a: PGScannerConfig, 
-    `scope_0_fallback`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`scope_0_fallback` shl bp_TGScannerConfig_scope_0_fallback) and
-      bm_TGScannerConfig_scope_0_fallback)
-
-proc freeze_symbol_table*(scanner: PGScanner) = 
-  if Scanner == nil: nil
-  
-proc thaw_symbol_table*(scanner: PGScanner) = 
-  if Scanner == nil: nil
-  
-proc G_SHELL_ERROR*(): TGQuark = 
-  result = g_shell_error_quark()
-
-proc G_SPAWN_ERROR*(): TGQuark = 
-  result = g_spawn_error_quark()
-
-when false: 
-  proc g_ascii_isalnum*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_ALNUM) != 0
-
-  proc g_ascii_isalpha*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_ALPHA) != 0
-
-  proc g_ascii_iscntrl*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_CNTRL) != 0
-
-  proc g_ascii_isdigit*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_DIGIT) != 0
-
-  proc g_ascii_isgraph*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_GRAPH) != 0
-
-  proc g_ascii_islower*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_LOWER) != 0
-
-  proc g_ascii_isprint*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_PRINT) != 0
-
-  proc g_ascii_ispunct*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_PUNCT) != 0
-
-  proc g_ascii_isspace*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_SPACE) != 0
-
-  proc g_ascii_isupper*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_UPPER) != 0
-
-  proc g_ascii_isxdigit*(c: gchar): bool = 
-    result = ((g_ascii_table[guchar(c)]) and G_ASCII_XDIGIT) != 0
-
-  proc g_strstrip*(str: cstring): cstring = 
-    result = g_strchomp(g_strchug(str))
-
-proc G_TYPE_MAKE_FUNDAMENTAL*(x: int): GType = 
-  result = GType(x shl G_TYPE_FUNDAMENTAL_SHIFT)
-
-proc G_TYPE_IS_FUNDAMENTAL*(theType: GType): bool = 
-  result = theType <= G_TYPE_FUNDAMENTAL_MAX
-
-proc G_TYPE_IS_DERIVED*(theType: GType): bool = 
-  result = theType > G_TYPE_FUNDAMENTAL_MAX
-
-proc G_TYPE_IS_INTERFACE*(theType: GType): bool = 
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_INTERFACE
-
-proc G_TYPE_IS_CLASSED*(theType: GType): gboolean = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_CLASSED)
-
-proc G_TYPE_IS_INSTANTIATABLE*(theType: GType): bool = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_INSTANTIATABLE)
-
-proc G_TYPE_IS_DERIVABLE*(theType: GType): bool = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_DERIVABLE)
-
-proc G_TYPE_IS_DEEP_DERIVABLE*(theType: GType): bool = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_DEEP_DERIVABLE)
-
-proc G_TYPE_IS_ABSTRACT*(theType: GType): bool = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_ABSTRACT)
-
-proc G_TYPE_IS_VALUE_ABSTRACT*(theType: GType): bool = 
-  result = private_g_type_test_flags(theType, G_TYPE_FLAG_VALUE_ABSTRACT)
-
-proc G_TYPE_IS_VALUE_TYPE*(theType: GType): bool = 
-  result = private_g_type_check_is_value_type(theType)
-
-proc G_TYPE_HAS_VALUE_TABLE*(theType: GType): bool = 
-  result = (g_type_value_table_peek(theType)) != nil
-
-proc G_TYPE_CHECK_INSTANCE*(instance: Pointer): gboolean = 
-  result = private_g_type_check_instance(cast[PGTypeInstance](instance))
-
-proc G_TYPE_CHECK_INSTANCE_CAST*(instance: Pointer, g_type: GType): PGTypeInstance = 
-  result = cast[PGTypeInstance](private_g_type_check_instance_cast(
-      cast[PGTypeInstance](instance), g_type))
-
-proc G_TYPE_CHECK_INSTANCE_TYPE*(instance: Pointer, g_type: GType): bool = 
-  result = private_g_type_check_instance_is_a(cast[PGTypeInstance](instance), 
-      g_type)
-
-proc G_TYPE_INSTANCE_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass = 
-  result = cast[PGTypeInstance](Instance).g_class
-  result = private_g_type_check_class_cast(result, g_type)
-
-proc G_TYPE_INSTANCE_GET_INTERFACE*(instance: Pointer, g_type: GType): Pointer = 
-  result = g_type_interface_peek((cast[PGTypeInstance](instance)).g_class, 
-                                 g_type)
-
-proc G_TYPE_CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer = 
-  result = private_g_type_check_class_cast(cast[PGTypeClass](g_class), g_type)
-
-proc G_TYPE_CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool = 
-  result = private_g_type_check_class_is_a(cast[PGTypeClass](g_class), g_type)
-
-proc G_TYPE_CHECK_VALUE*(value: Pointer): bool = 
-  result = private_g_type_check_value(cast[PGValue](Value))
-
-proc G_TYPE_CHECK_VALUE_TYPE*(value: pointer, g_type: GType): bool = 
-  result = private_g_type_check_value_holds(cast[PGValue](value), g_type)
-
-proc G_TYPE_FROM_INSTANCE*(instance: Pointer): GType = 
-  result = G_TYPE_FROM_CLASS((cast[PGTypeInstance](instance)).g_class)
-
-proc G_TYPE_FROM_CLASS*(g_class: Pointer): GType = 
-  result = (cast[PGTypeClass](g_class)).g_type
-
-proc G_TYPE_FROM_INTERFACE*(g_iface: Pointer): GType = 
-  result = (cast[PGTypeInterface](g_iface)).g_type
-
-proc G_TYPE_IS_VALUE*(theType: GType): bool = 
-  result = private_g_type_check_is_value_type(theType)
-
-proc G_IS_VALUE*(value: Pointer): bool = 
-  result = G_TYPE_CHECK_VALUE(value)
-
-proc G_VALUE_TYPE*(value: Pointer): GType = 
-  result = (cast[PGValue](value)).g_type
-
-proc G_VALUE_TYPE_NAME*(value: Pointer): cstring = 
-  result = g_type_name(G_VALUE_TYPE(value))
-
-proc G_VALUE_HOLDS*(value: pointer, g_type: GType): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, g_type)
-
-proc G_TYPE_IS_PARAM*(theType: GType): bool = 
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_PARAM
-
-proc G_PARAM_SPEC*(pspec: Pointer): PGParamSpec = 
-  result = cast[PGParamSpec](G_TYPE_CHECK_INSTANCE_CAST(pspec, G_TYPE_PARAM))
-
-proc G_IS_PARAM_SPEC*(pspec: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(pspec, G_TYPE_PARAM)
-
-proc G_PARAM_SPEC_CLASS*(pclass: Pointer): PGParamSpecClass = 
-  result = cast[PGParamSpecClass](G_TYPE_CHECK_CLASS_CAST(pclass, G_TYPE_PARAM))
-
-proc G_IS_PARAM_SPEC_CLASS*(pclass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(pclass, G_TYPE_PARAM)
-
-proc G_PARAM_SPEC_GET_CLASS*(pspec: Pointer): PGParamSpecClass = 
-  result = cast[PGParamSpecClass](G_TYPE_INSTANCE_GET_CLASS(pspec, G_TYPE_PARAM))
-
-proc G_PARAM_SPEC_TYPE*(pspec: Pointer): GType = 
-  result = G_TYPE_FROM_INSTANCE(pspec)
-
-proc G_PARAM_SPEC_TYPE_NAME*(pspec: Pointer): cstring = 
-  result = g_type_name(G_PARAM_SPEC_TYPE(pspec))
-
-proc G_PARAM_SPEC_VALUE_TYPE*(pspec: Pointer): GType = 
-  result = (G_PARAM_SPEC(pspec)).value_type
-
-proc G_VALUE_HOLDS_PARAM*(value: Pointer): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_PARAM)
-
-proc G_CLOSURE_NEEDS_MARSHAL*(closure: Pointer): bool = 
-  result = cast[PGClosure](closure).marshal == nil
-
-proc N_NOTIFIERS*(cl: PGClosure): int32 = 
-  result = ((meta_marshal(cl) + ((n_guards(cl)) shl 1'i32)) +
-      (n_fnotifiers(cl))) + (n_inotifiers(cl))
-
-proc CCLOSURE_SWAP_DATA*(cclosure: PGClosure): int32 = 
-  result = derivative_flag(cclosure)
-
-proc G_CALLBACK*(f: pointer): TGCallback = 
-  result = cast[TGCallback](f)
-
-proc ref_count*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_ref_count) shr bp_TGClosure_ref_count
-
-proc set_ref_count*(a: PGClosure, `ref_count`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`ref_count` shl bp_TGClosure_ref_count) and bm_TGClosure_ref_count)
-
-proc meta_marshal*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_meta_marshal) shr
-      bp_TGClosure_meta_marshal
-
-proc set_meta_marshal*(a: PGClosure, `meta_marshal`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`meta_marshal` shl bp_TGClosure_meta_marshal) and
-      bm_TGClosure_meta_marshal)
-
-proc n_guards*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_n_guards) shr bp_TGClosure_n_guards
-
-proc set_n_guards*(a: PGClosure, `n_guards`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`n_guards` shl bp_TGClosure_n_guards) and bm_TGClosure_n_guards)
-
-proc n_fnotifiers*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_n_fnotifiers) shr
-      bp_TGClosure_n_fnotifiers
-
-proc set_n_fnotifiers*(a: PGClosure, `n_fnotifiers`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`n_fnotifiers` shl bp_TGClosure_n_fnotifiers) and
-      bm_TGClosure_n_fnotifiers)
-
-proc n_inotifiers*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_n_inotifiers) shr
-      bp_TGClosure_n_inotifiers
-
-proc set_n_inotifiers*(a: PGClosure, `n_inotifiers`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`n_inotifiers` shl bp_TGClosure_n_inotifiers) and
-      bm_TGClosure_n_inotifiers)
-
-proc in_inotify*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_in_inotify) shr bp_TGClosure_in_inotify
-
-proc set_in_inotify*(a: PGClosure, `in_inotify`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`in_inotify` shl bp_TGClosure_in_inotify) and bm_TGClosure_in_inotify)
-
-proc floating*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_floating) shr bp_TGClosure_floating
-
-proc set_floating*(a: PGClosure, `floating`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`floating` shl bp_TGClosure_floating) and bm_TGClosure_floating)
-
-proc derivative_flag*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_derivative_flag) shr
-      bp_TGClosure_derivative_flag
-
-proc set_derivative_flag*(a: PGClosure, `derivative_flag`: guint) = 
-  a.flag0 = a.flag0 or
-      ((`derivative_flag` shl bp_TGClosure_derivative_flag) and
-      bm_TGClosure_derivative_flag)
-
-proc in_marshal*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_in_marshal) shr bp_TGClosure_in_marshal
-
-proc set_in_marshal*(a: PGClosure, in_marshal: guint) = 
-  a.flag0 = a.flag0 or
-      ((in_marshal shl bp_TGClosure_in_marshal) and bm_TGClosure_in_marshal)
-
-proc is_invalid*(a: PGClosure): guint = 
-  result = (a.flag0 and bm_TGClosure_is_invalid) shr bp_TGClosure_is_invalid
-
-proc set_is_invalid*(a: PGClosure, is_invalid: guint) = 
-  a.flag0 = a.flag0 or
-      ((is_invalid shl bp_TGClosure_is_invalid) and bm_TGClosure_is_invalid)
-
-proc g_signal_connect*(instance: gpointer, detailed_signal: cstring, 
-                       c_handler: TGCallback, data: gpointer): gulong = 
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data, 
-                                 nil, TGConnectFlags(0))
-
-proc g_signal_connect_after*(instance: gpointer, detailed_signal: cstring, 
-                             c_handler: TGCallback, data: gpointer): gulong = 
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data, 
-                                 nil, G_CONNECT_AFTER)
-
-proc g_signal_connect_swapped*(instance: gpointer, detailed_signal: cstring, 
-                               c_handler: TGCallback, data: gpointer): gulong = 
-  result = g_signal_connect_data(instance, detailed_signal, c_handler, data, 
-                                 nil, G_CONNECT_SWAPPED)
-
-proc g_signal_handlers_disconnect_by_func*(instance: gpointer, 
-    func, data: gpointer): guint = 
-  result = g_signal_handlers_disconnect_matched(instance, 
-      TGSignalMatchType(G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil, 
-      func, data)
-
-proc g_signal_handlers_block_by_func*(instance: gpointer, func, data: gpointer) = 
-  discard g_signal_handlers_block_matched(instance, 
-      TGSignalMatchType(G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil, 
-      func, data)
-
-proc g_signal_handlers_unblock_by_func*(instance: gpointer, func, data: gpointer) = 
-  discard g_signal_handlers_unblock_matched(instance, 
-      TGSignalMatchType(G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0, 0, nil, 
-      func, data)
-
-proc G_TYPE_IS_OBJECT*(theType: GType): bool = 
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_OBJECT
-
-proc G_OBJECT*(anObject: pointer): PGObject = 
-  result = cast[PGObject](G_TYPE_CHECK_INSTANCE_CAST(anObject, G_TYPE_OBJECT))
-
-proc G_OBJECT_CLASS*(class: Pointer): PGObjectClass = 
-  result = cast[PGObjectClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_OBJECT))
-
-proc G_IS_OBJECT*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, G_TYPE_OBJECT)
-
-proc G_IS_OBJECT_CLASS*(class: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_OBJECT)
-
-proc G_OBJECT_GET_CLASS*(anObject: pointer): PGObjectClass = 
-  result = cast[PGObjectClass](G_TYPE_INSTANCE_GET_CLASS(anObject, G_TYPE_OBJECT))
-
-proc G_OBJECT_TYPE*(anObject: pointer): GType = 
-  result = G_TYPE_FROM_INSTANCE(anObject)
-
-proc G_OBJECT_TYPE_NAME*(anObject: pointer): cstring = 
-  result = g_type_name(G_OBJECT_TYPE(anObject))
-
-proc G_OBJECT_CLASS_TYPE*(class: Pointer): GType = 
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_OBJECT_CLASS_NAME*(class: Pointer): cstring = 
-  result = g_type_name(G_OBJECT_CLASS_TYPE(class))
-
-proc G_VALUE_HOLDS_OBJECT*(value: Pointer): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_OBJECT)
-
-proc G_OBJECT_WARN_INVALID_PROPERTY_ID*(anObject: gpointer, property_id: gint, 
-                                        pspec: gpointer) = 
-  G_OBJECT_WARN_INVALID_PSPEC(anObject, "property", property_id, pspec)
-
-proc G_OBJECT_WARN_INVALID_PSPEC*(anObject: gpointer, pname: cstring, 
-                                  property_id: gint, pspec: gpointer) = 
-  var 
-    theObject: PGObject
-    pspec2: PGParamSpec
-    property_id: guint
-  theObject = cast[PGObject](anObject)
-  pspec2 = cast[PGParamSpec](pspec)
-  property_id = (property_id)
-  write(stdout, "invalid thingy\x0A")
-  #g_warning("%s: invalid %s id %u for \"%s\" of type `%s\' in `%s\'", "", pname,
-  #          `property_id`, `pspec` . name,
-  #          g_type_name(G_PARAM_SPEC_TYPE(`pspec`)),
-  #          G_OBJECT_TYPE_NAME(theobject))
-  
-proc G_TYPE_TYPE_PLUGIN*(): GType = 
-  result = g_type_plugin_get_type()
-
-proc G_TYPE_PLUGIN*(inst: Pointer): PGTypePlugin = 
-  result = PGTypePlugin(G_TYPE_CHECK_INSTANCE_CAST(inst, G_TYPE_TYPE_PLUGIN()))
-
-proc G_TYPE_PLUGIN_CLASS*(vtable: Pointer): PGTypePluginClass = 
-  result = cast[PGTypePluginClass](G_TYPE_CHECK_CLASS_CAST(vtable, 
-      G_TYPE_TYPE_PLUGIN()))
-
-proc G_IS_TYPE_PLUGIN*(inst: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(inst, G_TYPE_TYPE_PLUGIN())
-
-proc G_IS_TYPE_PLUGIN_CLASS*(vtable: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(vtable, G_TYPE_TYPE_PLUGIN())
-
-proc G_TYPE_PLUGIN_GET_CLASS*(inst: Pointer): PGTypePluginClass = 
-  result = cast[PGTypePluginClass](G_TYPE_INSTANCE_GET_INTERFACE(inst, 
-      G_TYPE_TYPE_PLUGIN()))
-
-proc G_TYPE_IS_ENUM*(theType: GType): gboolean = 
-  result = (G_TYPE_FUNDAMENTAL(theType) == G_TYPE_ENUM)
-
-proc G_ENUM_CLASS*(class: pointer): PGEnumClass = 
-  result = cast[PGEnumClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_ENUM))
-
-proc G_IS_ENUM_CLASS*(class: pointer): gboolean = 
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_ENUM)
-
-proc G_ENUM_CLASS_TYPE*(class: pointer): GType = 
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_ENUM_CLASS_TYPE_NAME*(class: pointer): cstring = 
-  result = g_type_name(G_ENUM_CLASS_TYPE(class))
-
-proc G_TYPE_IS_FLAGS*(theType: GType): gboolean = 
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_FLAGS
-
-proc G_FLAGS_CLASS*(class: pointer): PGFlagsClass = 
-  result = cast[PGFlagsClass](G_TYPE_CHECK_CLASS_CAST(class, G_TYPE_FLAGS))
-
-proc G_IS_FLAGS_CLASS*(class: pointer): gboolean = 
-  result = G_TYPE_CHECK_CLASS_TYPE(class, G_TYPE_FLAGS)
-
-proc G_FLAGS_CLASS_TYPE*(class: pointer): GType = 
-  result = G_TYPE_FROM_CLASS(class)
-
-proc G_FLAGS_CLASS_TYPE_NAME*(class: pointer): cstring = 
-  result = g_type_name(G_FLAGS_TYPE(cast[TAddress](class)))
-
-proc G_VALUE_HOLDS_ENUM*(value: pointer): gboolean = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_ENUM)
-
-proc G_VALUE_HOLDS_FLAGS*(value: pointer): gboolean = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_FLAGS)
-
-proc CLAMP*(x, MinX, MaxX: int): int = 
-  if x < MinX: 
-    result = MinX
-  elif x > MaxX: 
-    result = MaxX
-  else: 
-    result = x
-
-proc GPOINTER_TO_SIZE*(p: GPointer): GSize = 
-  result = GSize(cast[TAddress](p))
-
-proc GSIZE_TO_POINTER*(s: GSize): GPointer = 
-  result = cast[GPointer](s)
-
-proc HOLDS_CHAR*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_CHAR)
-
-proc HOLDS_UCHAR*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UCHAR)
-
-proc HOLDS_BOOLEAN*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_BOOLEAN)
-
-proc HOLDS_INT*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_INT)
-
-proc HOLDS_UINT*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UINT)
-
-proc HOLDS_LONG*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_LONG)
-
-proc HOLDS_ULONG*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_ULONG)
-
-proc HOLDS_INT64*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_INT64)
-
-proc HOLDS_UINT64*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_UINT64)
-
-proc HOLDS_FLOAT*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_FLOAT)
-
-proc HOLDS_DOUBLE*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_DOUBLE)
-
-proc HOLDS_STRING*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_STRING)
-
-proc HOLDS_POINTER*(value: PGValue): bool = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_POINTER)
-
-proc G_TYPE_IS_BOXED*(theType: GType): gboolean = 
-  result = (G_TYPE_FUNDAMENTAL(theType)) == G_TYPE_BOXED
-
-proc HOLDS_BOXED*(value: PGValue): gboolean = 
-  result = G_TYPE_CHECK_VALUE_TYPE(value, G_TYPE_BOXED)
-
-proc G_TYPE_CLOSURE*(): GType = 
-  result = g_closure_get_type()
-
-proc G_TYPE_VALUE*(): GType = 
-  result = g_value_get_type()
-
-proc G_TYPE_VALUE_ARRAY*(): GType = 
-  result = g_value_array_get_type()
-
-proc G_TYPE_GSTRING*(): GType = 
-  result = g_gstring_get_type()
diff --git a/lib/wrappers/gtk/gtk2.nim b/lib/wrappers/gtk/gtk2.nim
deleted file mode 100755
index d835f7b2f..000000000
--- a/lib/wrappers/gtk/gtk2.nim
+++ /dev/null
@@ -1,16873 +0,0 @@
-{.deadCodeElim: on.}
-import 
-  glib2, atk, pango, gdk2pixbuf, gdk2
-
-when defined(win32): 
-  const 
-    lib = "libgtk-win32-2.0-0.dll"
-elif defined(darwin): 
-  const 
-    lib = "gtk-x11-2.0"
-  # linklib gtk-x11-2.0
-  # linklib gdk-x11-2.0
-  # linklib pango-1.0.0
-  # linklib glib-2.0.0
-  # linklib gobject-2.0.0
-  # linklib gdk_pixbuf-2.0.0
-  # linklib atk-1.0.0
-else: 
-  const 
-    lib = "libgtk-x11-2.0.so(|.0)"
-
-const 
-  MAX_COMPOSE_LEN* = 7
-
-type 
-  PObject* = ptr TObject
-  PPGtkObject* = ptr PObject
-  PArg* = ptr TArg
-  PType* = ptr TType
-  TType* = GType
-  PWidget* = ptr TWidget
-  PMisc* = ptr TMisc
-  PLabel* = ptr TLabel
-  PMenu* = ptr TMenu
-  PAnchorType* = ptr TAnchorType
-  TAnchorType* = int32
-  PArrowType* = ptr TArrowType
-  TArrowType* = int32
-  PAttachOptions* = ptr TAttachOptions
-  TAttachOptions* = int32
-  PButtonBoxStyle* = ptr TButtonBoxStyle
-  TButtonBoxStyle* = int32
-  PCurveType* = ptr TCurveType
-  TCurveType* = int32
-  PDeleteType* = ptr TDeleteType
-  TDeleteType* = int32
-  PDirectionType* = ptr TDirectionType
-  TDirectionType* = int32
-  PExpanderStyle* = ptr TExpanderStyle
-  TExpanderStyle* = int32
-  PPGtkIconSize* = ptr PIconSize
-  PIconSize* = ptr TIconSize
-  TIconSize* = int32
-  PTextDirection* = ptr TTextDirection
-  TTextDirection* = int32
-  PJustification* = ptr TJustification
-  TJustification* = int32
-  PMenuDirectionType* = ptr TMenuDirectionType
-  TMenuDirectionType* = int32
-  PMetricType* = ptr TMetricType
-  TMetricType* = int32
-  PMovementStep* = ptr TMovementStep
-  TMovementStep* = int32
-  POrientation* = ptr TOrientation
-  TOrientation* = int32
-  PCornerType* = ptr TCornerType
-  TCornerType* = int32
-  PPackType* = ptr TPackType
-  TPackType* = int32
-  PPathPriorityType* = ptr TPathPriorityType
-  TPathPriorityType* = int32
-  PPathType* = ptr TPathType
-  TPathType* = int32
-  PPolicyType* = ptr TPolicyType
-  TPolicyType* = int32
-  PPositionType* = ptr TPositionType
-  TPositionType* = int32
-  PReliefStyle* = ptr TReliefStyle
-  TReliefStyle* = int32
-  PResizeMode* = ptr TResizeMode
-  TResizeMode* = int32
-  PScrollType* = ptr TScrollType
-  TScrollType* = int32
-  PSelectionMode* = ptr TSelectionMode
-  TSelectionMode* = int32
-  PShadowType* = ptr TShadowType
-  TShadowType* = int32
-  PStateType* = ptr TStateType
-  TStateType* = int32
-  PSubmenuDirection* = ptr TSubmenuDirection
-  TSubmenuDirection* = int32
-  PSubmenuPlacement* = ptr TSubmenuPlacement
-  TSubmenuPlacement* = int32
-  PToolbarStyle* = ptr TToolbarStyle
-  TToolbarStyle* = int32
-  PUpdateType* = ptr TUpdateType
-  TUpdateType* = int32
-  PVisibility* = ptr TVisibility
-  TVisibility* = int32
-  PWindowPosition* = ptr TWindowPosition
-  TWindowPosition* = int32
-  PWindowType* = ptr TWindowType
-  TWindowType* = int32
-  PWrapMode* = ptr TWrapMode
-  TWrapMode* = int32
-  PSortType* = ptr TSortType
-  TSortType* = int32
-  PStyle* = ptr TStyle
-  PPGtkTreeModel* = ptr PTreeModel
-  PTreeModel* = pointer
-  PTreePath* = pointer
-  PTreeIter* = ptr TTreeIter
-  PSelectionData* = ptr TSelectionData
-  PTextTagTable* = ptr TTextTagTable
-  PTextBTreeNode* = pointer
-  PTextBTree* = pointer
-  PTextLine* = ptr TTextLine
-  PTreeViewColumn* = ptr TTreeViewColumn
-  PTreeView* = ptr TTreeView
-  TTreeViewColumnDropFunc* = proc (tree_view: PTreeView, 
-                                   column: PTreeViewColumn, 
-                                   prev_column: PTreeViewColumn, 
-                                   next_column: PTreeViewColumn, data: gpointer): gboolean{.
-      cdecl.}
-  TTreeViewMappingFunc* = proc (tree_view: PTreeView, path: PTreePath, 
-                                user_data: gpointer){.cdecl.}
-  TTreeViewSearchEqualFunc* = proc (model: PTreeModel, column: gint, 
-                                    key: cstring, iter: PTreeIter, 
-                                    search_data: gpointer): gboolean{.cdecl.}
-  TTreeDestroyCountFunc* = proc (tree_view: PTreeView, path: PTreePath, 
-                                 children: gint, user_data: gpointer){.cdecl.}
-  PTreeViewDropPosition* = ptr TTreeViewDropPosition
-  TTreeViewDropPosition* = enum 
-    TREE_VIEW_DROP_BEFORE, TREE_VIEW_DROP_AFTER, TREE_VIEW_DROP_INTO_OR_BEFORE, 
-    TREE_VIEW_DROP_INTO_OR_AFTER
-  PObjectFlags* = ptr TObjectFlags
-  TObjectFlags* = int32
-  TObject* = object of TGObject
-    flags*: guint32
-
-  PObjectClass* = ptr TObjectClass
-  TObjectClass* = object of TGObjectClass
-    set_arg*: proc (anObject: PObject, arg: PArg, arg_id: guint){.cdecl.}
-    get_arg*: proc (anObject: PObject, arg: PArg, arg_id: guint){.cdecl.}
-    destroy*: proc (anObject: PObject){.cdecl.}
-
-  PFundamentalType* = ptr TFundamentalType
-  TFundamentalType* = GType
-  TFunction* = proc (data: gpointer): gboolean{.cdecl.}
-  TDestroyNotify* = proc (data: gpointer){.cdecl.}
-  TCallbackMarshal* = proc (anObject: PObject, data: gpointer, n_args: guint, 
-                            args: PArg){.cdecl.}
-  TSignalFunc* = proc (para1: pointer){.cdecl.}
-  PSignalMarshaller* = ptr TSignalMarshaller
-  TSignalMarshaller* = TGSignalCMarshaller
-  TArgSignalData*{.final, pure.} = object 
-    f*: TSignalFunc
-    d*: gpointer
-
-  TArg*{.final, pure.} = object 
-    `type`*: TType
-    name*: cstring
-    d*: gdouble               # was a union type
-  
-  PTypeInfo* = ptr TTypeInfo
-  TTypeInfo*{.final, pure.} = object 
-    type_name*: cstring
-    object_size*: guint
-    class_size*: guint
-    class_init_func*: pointer #TGtkClassInitFunc
-    object_init_func*: pointer #TGtkObjectInitFunc
-    reserved_1*: gpointer
-    reserved_2*: gpointer
-    base_class_init_func*: pointer #TGtkClassInitFunc
-  
-  PEnumValue* = ptr TEnumValue
-  TEnumValue* = TGEnumValue
-  PFlagValue* = ptr TFlagValue
-  TFlagValue* = TGFlagsValue
-  PWidgetFlags* = ptr TWidgetFlags
-  TWidgetFlags* = int32
-  PWidgetHelpType* = ptr TWidgetHelpType
-  TWidgetHelpType* = enum 
-    WIDGET_HELP_TOOLTIP, WIDGET_HELP_WHATS_THIS
-  PAllocation* = ptr TAllocation
-  TAllocation* = Gdk2.TRectangle
-  TCallback* = proc (widget: PWidget, data: gpointer){.cdecl.}
-  PRequisition* = ptr TRequisition
-  TRequisition*{.final, pure.} = object 
-    width*: gint
-    height*: gint
-
-  TWidget* = object of TObject
-    private_flags*: guint16
-    state*: guint8
-    saved_state*: guint8
-    name*: cstring
-    style*: PStyle
-    requisition*: TRequisition
-    allocation*: TAllocation
-    window*: Gdk2.PWindow
-    parent*: PWidget
-
-  PWidgetClass* = ptr TWidgetClass
-  TWidgetClass* = object of TObjectClass
-    activate_signal*: guint
-    set_scroll_adjustments_signal*: guint
-    dispatch_child_properties_changed*: proc (widget: PWidget, n_pspecs: guint, 
-        pspecs: PPGParamSpec){.cdecl.}
-    show*: proc (widget: PWidget){.cdecl.}
-    show_all*: proc (widget: PWidget){.cdecl.}
-    hide*: proc (widget: PWidget){.cdecl.}
-    hide_all*: proc (widget: PWidget){.cdecl.}
-    map*: proc (widget: PWidget){.cdecl.}
-    unmap*: proc (widget: PWidget){.cdecl.}
-    realize*: proc (widget: PWidget){.cdecl.}
-    unrealize*: proc (widget: PWidget){.cdecl.}
-    size_request*: proc (widget: PWidget, requisition: PRequisition){.cdecl.}
-    size_allocate*: proc (widget: PWidget, allocation: PAllocation){.cdecl.}
-    state_changed*: proc (widget: PWidget, previous_state: TStateType){.cdecl.}
-    parent_set*: proc (widget: PWidget, previous_parent: PWidget){.cdecl.}
-    hierarchy_changed*: proc (widget: PWidget, previous_toplevel: PWidget){.
-        cdecl.}
-    style_set*: proc (widget: PWidget, previous_style: PStyle){.cdecl.}
-    direction_changed*: proc (widget: PWidget, 
-                              previous_direction: TTextDirection){.cdecl.}
-    grab_notify*: proc (widget: PWidget, was_grabbed: gboolean){.cdecl.}
-    child_notify*: proc (widget: PWidget, pspec: PGParamSpec){.cdecl.}
-    mnemonic_activate*: proc (widget: PWidget, group_cycling: gboolean): gboolean{.
-        cdecl.}
-    grab_focus*: proc (widget: PWidget){.cdecl.}
-    focus*: proc (widget: PWidget, direction: TDirectionType): gboolean{.cdecl.}
-    event*: proc (widget: PWidget, event: Gdk2.PEvent): gboolean{.cdecl.}
-    button_press_event*: proc (widget: PWidget, event: PEventButton): gboolean{.
-        cdecl.}
-    button_release_event*: proc (widget: PWidget, event: PEventButton): gboolean{.
-        cdecl.}
-    scroll_event*: proc (widget: PWidget, event: PEventScroll): gboolean{.
-        cdecl.}
-    motion_notify_event*: proc (widget: PWidget, event: PEventMotion): gboolean{.
-        cdecl.}
-    delete_event*: proc (widget: PWidget, event: PEventAny): gboolean{.cdecl.}
-    destroy_event*: proc (widget: PWidget, event: PEventAny): gboolean{.cdecl.}
-    expose_event*: proc (widget: PWidget, event: PEventExpose): gboolean{.
-        cdecl.}
-    key_press_event*: proc (widget: PWidget, event: PEventKey): gboolean{.
-        cdecl.}
-    key_release_event*: proc (widget: PWidget, event: PEventKey): gboolean{.
-        cdecl.}
-    enter_notify_event*: proc (widget: PWidget, event: PEventCrossing): gboolean{.
-        cdecl.}
-    leave_notify_event*: proc (widget: PWidget, event: PEventCrossing): gboolean{.
-        cdecl.}
-    configure_event*: proc (widget: PWidget, event: PEventConfigure): gboolean{.
-        cdecl.}
-    focus_in_event*: proc (widget: PWidget, event: PEventFocus): gboolean{.
-        cdecl.}
-    focus_out_event*: proc (widget: PWidget, event: PEventFocus): gboolean{.
-        cdecl.}
-    map_event*: proc (widget: PWidget, event: PEventAny): gboolean{.cdecl.}
-    unmap_event*: proc (widget: PWidget, event: PEventAny): gboolean{.cdecl.}
-    property_notify_event*: proc (widget: PWidget, event: PEventProperty): gboolean{.
-        cdecl.}
-    selection_clear_event*: proc (widget: PWidget, event: PEventSelection): gboolean{.
-        cdecl.}
-    selection_request_event*: proc (widget: PWidget, event: PEventSelection): gboolean{.
-        cdecl.}
-    selection_notify_event*: proc (widget: PWidget, event: PEventSelection): gboolean{.
-        cdecl.}
-    proximity_in_event*: proc (widget: PWidget, event: PEventProximity): gboolean{.
-        cdecl.}
-    proximity_out_event*: proc (widget: PWidget, event: PEventProximity): gboolean{.
-        cdecl.}
-    visibility_notify_event*: proc (widget: PWidget, event: PEventVisibility): gboolean{.
-        cdecl.}
-    client_event*: proc (widget: PWidget, event: PEventClient): gboolean{.
-        cdecl.}
-    no_expose_event*: proc (widget: PWidget, event: PEventAny): gboolean{.
-        cdecl.}
-    window_state_event*: proc (widget: PWidget, event: PEventWindowState): gboolean{.
-        cdecl.}
-    selection_get*: proc (widget: PWidget, selection_data: PSelectionData, 
-                          info: guint, time: guint){.cdecl.}
-    selection_received*: proc (widget: PWidget, selection_data: PSelectionData, 
-                               time: guint){.cdecl.}
-    drag_begin*: proc (widget: PWidget, context: PDragContext){.cdecl.}
-    drag_end*: proc (widget: PWidget, context: PDragContext){.cdecl.}
-    drag_data_get*: proc (widget: PWidget, context: PDragContext, 
-                          selection_data: PSelectionData, info: guint, 
-                          time: guint){.cdecl.}
-    drag_data_delete*: proc (widget: PWidget, context: PDragContext){.cdecl.}
-    drag_leave*: proc (widget: PWidget, context: PDragContext, time: guint){.
-        cdecl.}
-    drag_motion*: proc (widget: PWidget, context: PDragContext, x: gint, 
-                        y: gint, time: guint): gboolean{.cdecl.}
-    drag_drop*: proc (widget: PWidget, context: PDragContext, x: gint, 
-                      y: gint, time: guint): gboolean{.cdecl.}
-    drag_data_received*: proc (widget: PWidget, context: PDragContext, 
-                               x: gint, y: gint, selection_data: PSelectionData, 
-                               info: guint, time: guint){.cdecl.}
-    popup_menu*: proc (widget: PWidget): gboolean{.cdecl.}
-    show_help*: proc (widget: PWidget, help_type: TWidgetHelpType): gboolean{.
-        cdecl.}
-    get_accessible*: proc (widget: PWidget): atk.PObject{.cdecl.}
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-    reserved5*: proc (){.cdecl.}
-    reserved6*: proc (){.cdecl.}
-    reserved7*: proc (){.cdecl.}
-    reserved8*: proc (){.cdecl.}
-
-  PWidgetAuxInfo* = ptr TWidgetAuxInfo
-  TWidgetAuxInfo*{.final, pure.} = object 
-    x*: gint
-    y*: gint
-    width*: gint
-    height*: gint
-    flag0*: guint16
-
-  PWidgetShapeInfo* = ptr TWidgetShapeInfo
-  TWidgetShapeInfo*{.final, pure.} = object 
-    offset_x*: gint16
-    offset_y*: gint16
-    shape_mask*: gdk2.PBitmap
-
-  TMisc* = object of TWidget
-    xalign*: gfloat
-    yalign*: gfloat
-    xpad*: guint16
-    ypad*: guint16
-
-  PMiscClass* = ptr TMiscClass
-  TMiscClass* = object of TWidgetClass
-  PAccelFlags* = ptr TAccelFlags
-  TAccelFlags* = int32
-  PAccelGroup* = ptr TAccelGroup
-  PAccelGroupEntry* = ptr TAccelGroupEntry
-  TAccelGroupActivate* = proc (accel_group: PAccelGroup, 
-                               acceleratable: PGObject, keyval: guint, 
-                               modifier: gdk2.TModifierType): gboolean{.cdecl.}
-  TAccelGroup* = object of TGObject
-    lock_count*: guint
-    modifier_mask*: gdk2.TModifierType
-    acceleratables*: PGSList
-    n_accels*: guint
-    priv_accels*: PAccelGroupEntry
-
-  PAccelGroupClass* = ptr TAccelGroupClass
-  TAccelGroupClass* = object of TGObjectClass
-    accel_changed*: proc (accel_group: PAccelGroup, keyval: guint, 
-                          modifier: gdk2.TModifierType, accel_closure: PGClosure){.
-        cdecl.}
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PAccelKey* = ptr TAccelKey
-  TAccelKey*{.final, pure.} = object 
-    accel_key*: guint
-    accel_mods*: gdk2.TModifierType
-    flag0*: guint16
-
-  TAccelGroupEntry*{.final, pure.} = object 
-    key*: TAccelKey
-    closure*: PGClosure
-    accel_path_quark*: TGQuark
-
-  Taccel_group_find_func* = proc (key: PAccelKey, closure: PGClosure, 
-                                  data: gpointer): gboolean{.cdecl.}
-  PContainer* = ptr TContainer
-  TContainer* = object of TWidget
-    focus_child*: PWidget
-    Container_flag0*: int32
-
-  PContainerClass* = ptr TContainerClass
-  TContainerClass* = object of TWidgetClass
-    add*: proc (container: PContainer, widget: PWidget){.cdecl.}
-    remove*: proc (container: PContainer, widget: PWidget){.cdecl.}
-    check_resize*: proc (container: PContainer){.cdecl.}
-    forall*: proc (container: PContainer, include_internals: gboolean, 
-                   callback: TCallback, callback_data: gpointer){.cdecl.}
-    set_focus_child*: proc (container: PContainer, widget: PWidget){.cdecl.}
-    child_type*: proc (container: PContainer): TType{.cdecl.}
-    composite_name*: proc (container: PContainer, child: PWidget): cstring{.
-        cdecl.}
-    set_child_property*: proc (container: PContainer, child: PWidget, 
-                               property_id: guint, value: PGValue, 
-                               pspec: PGParamSpec){.cdecl.}
-    get_child_property*: proc (container: PContainer, child: PWidget, 
-                               property_id: guint, value: PGValue, 
-                               pspec: PGParamSpec){.cdecl.}
-    reserved20: proc (){.cdecl.}
-    reserved21: proc (){.cdecl.}
-    reserved23: proc (){.cdecl.}
-    reserved24: proc (){.cdecl.}
-
-  PBin* = ptr TBin
-  TBin* = object of TContainer
-    child*: PWidget
-
-  PBinClass* = ptr TBinClass
-  TBinClass* = object of TContainerClass
-  PWindowGeometryInfo* = pointer
-  PWindowGroup* = ptr TWindowGroup
-  PWindow* = ptr TWindow
-  TWindow* = object of TBin
-    title*: cstring
-    wmclass_name*: cstring
-    wmclass_class*: cstring
-    wm_role*: cstring
-    focus_widget*: PWidget
-    default_widget*: PWidget
-    transient_parent*: PWindow
-    geometry_info*: PWindowGeometryInfo
-    frame*: gdk2.PWindow
-    group*: PWindowGroup
-    configure_request_count*: guint16
-    window_flag0*: int32
-    frame_left*: guint
-    frame_top*: guint
-    frame_right*: guint
-    frame_bottom*: guint
-    keys_changed_handler*: guint
-    mnemonic_modifier*: gdk2.TModifierType
-    screen*: gdk2.PScreen
-
-  PWindowClass* = ptr TWindowClass
-  TWindowClass* = object of TBinClass
-    set_focus*: proc (window: PWindow, focus: PWidget){.cdecl.}
-    frame_event*: proc (window: PWindow, event: gdk2.PEvent): gboolean{.cdecl.}
-    activate_focus*: proc (window: PWindow){.cdecl.}
-    activate_default*: proc (window: PWindow){.cdecl.}
-    move_focus*: proc (window: PWindow, direction: TDirectionType){.cdecl.}
-    keys_changed*: proc (window: PWindow){.cdecl.}
-    reserved30: proc (){.cdecl.}
-    reserved31: proc (){.cdecl.}
-    reserved32: proc (){.cdecl.}
-    reserved33: proc (){.cdecl.}
-
-  TWindowGroup* = object of TGObject
-    grabs*: PGSList
-
-  PWindowGroupClass* = ptr TWindowGroupClass
-  TWindowGroupClass* = object of TGObjectClass
-    reserved40: proc (){.cdecl.}
-    reserved41: proc (){.cdecl.}
-    reserved42: proc (){.cdecl.}
-    reserved43: proc (){.cdecl.}
-
-  TWindowKeysForeachFunc* = proc (window: PWindow, keyval: guint, 
-                                  modifiers: gdk2.TModifierType, 
-                                  is_mnemonic: gboolean, data: gpointer){.cdecl.}
-  PLabelSelectionInfo* = pointer
-  TLabel* = object of TMisc
-    `label`*: cstring
-    Label_flag0*: guint16
-    mnemonic_keyval*: guint
-    text*: cstring
-    attrs*: pango.PAttrList
-    effective_attrs*: pango.PAttrList
-    layout*: pango.PLayout
-    mnemonic_widget*: PWidget
-    mnemonic_window*: PWindow
-    select_info*: PLabelSelectionInfo
-
-  PLabelClass* = ptr TLabelClass
-  TLabelClass* = object of TMiscClass
-    move_cursor*: proc (`label`: PLabel, step: TMovementStep, count: gint, 
-                        extend_selection: gboolean){.cdecl.}
-    copy_clipboard*: proc (`label`: PLabel){.cdecl.}
-    populate_popup*: proc (`label`: PLabel, menu: PMenu){.cdecl.}
-    reserved50: proc (){.cdecl.}
-    reserved51: proc (){.cdecl.}
-    reserved52: proc (){.cdecl.}
-    reserved53: proc (){.cdecl.}
-
-  PAccelLabel* = ptr TAccelLabel
-  TAccelLabel* = object of TLabel
-    queue_id*: guint
-    accel_padding*: guint
-    accel_widget*: PWidget
-    accel_closure*: PGClosure
-    accel_group*: PAccelGroup
-    accel_string*: cstring
-    accel_string_width*: guint16
-
-  PAccelLabelClass* = ptr TAccelLabelClass
-  TAccelLabelClass* = object of TLabelClass
-    signal_quote1*: cstring
-    signal_quote2*: cstring
-    mod_name_shift*: cstring
-    mod_name_control*: cstring
-    mod_name_alt*: cstring
-    mod_separator*: cstring
-    accel_seperator*: cstring
-    AccelLabelClass_flag0*: guint16
-    reserved61: proc (){.cdecl.}
-    reserved62: proc (){.cdecl.}
-    reserved63: proc (){.cdecl.}
-    reserved64: proc (){.cdecl.}
-
-  TAccelMapForeach* = proc (data: gpointer, accel_path: cstring, 
-                            accel_key: guint, accel_mods: gdk2.TModifierType, 
-                            changed: gboolean){.cdecl.}
-  PAccessible* = ptr TAccessible
-  TAccessible* = object of atk.TObject
-    widget*: PWidget
-
-  PAccessibleClass* = ptr TAccessibleClass
-  TAccessibleClass* = object of atk.TObjectClass
-    connect_widget_destroyed*: proc (accessible: PAccessible){.cdecl.}
-    reserved71: proc (){.cdecl.}
-    reserved72: proc (){.cdecl.}
-    reserved73: proc (){.cdecl.}
-    reserved74: proc (){.cdecl.}
-
-  PAdjustment* = ptr TAdjustment
-  TAdjustment* = object of TObject
-    lower*: gdouble
-    upper*: gdouble
-    value*: gdouble
-    step_increment*: gdouble
-    page_increment*: gdouble
-    page_size*: gdouble
-
-  PAdjustmentClass* = ptr TAdjustmentClass
-  TAdjustmentClass* = object of TObjectClass
-    changed*: proc (adjustment: PAdjustment){.cdecl.}
-    value_changed*: proc (adjustment: PAdjustment){.cdecl.}
-    reserved81: proc (){.cdecl.}
-    reserved82: proc (){.cdecl.}
-    reserved83: proc (){.cdecl.}
-    reserved84: proc (){.cdecl.}
-
-  PAlignment* = ptr TAlignment
-  TAlignment* = object of TBin
-    xalign*: gfloat
-    yalign*: gfloat
-    xscale*: gfloat
-    yscale*: gfloat
-
-  PAlignmentClass* = ptr TAlignmentClass
-  TAlignmentClass* = object of TBinClass
-  PFrame* = ptr TFrame
-  TFrame* = object of TBin
-    label_widget*: PWidget
-    shadow_type*: gint16
-    label_xalign*: gfloat
-    label_yalign*: gfloat
-    child_allocation*: TAllocation
-
-  PFrameClass* = ptr TFrameClass
-  TFrameClass* = object of TBinClass
-    compute_child_allocation*: proc (frame: PFrame, allocation: PAllocation){.
-        cdecl.}
-
-  PAspectFrame* = ptr TAspectFrame
-  TAspectFrame* = object of TFrame
-    xalign*: gfloat
-    yalign*: gfloat
-    ratio*: gfloat
-    obey_child*: gboolean
-    center_allocation*: TAllocation
-
-  PAspectFrameClass* = ptr TAspectFrameClass
-  TAspectFrameClass* = object of TFrameClass
-  PArrow* = ptr TArrow
-  TArrow* = object of TMisc
-    arrow_type*: gint16
-    shadow_type*: gint16
-
-  PArrowClass* = ptr TArrowClass
-  TArrowClass* = object of TMiscClass
-  PBindingEntry* = ptr TBindingEntry
-  PBindingSignal* = ptr TBindingSignal
-  PBindingArg* = ptr TBindingArg
-  PBindingSet* = ptr TBindingSet
-  TBindingSet*{.final, pure.} = object 
-    set_name*: cstring
-    priority*: gint
-    widget_path_pspecs*: PGSList
-    widget_class_pspecs*: PGSList
-    class_branch_pspecs*: PGSList
-    entries*: PBindingEntry
-    current*: PBindingEntry
-    flag0*: guint16
-
-  TBindingEntry*{.final, pure.} = object 
-    keyval*: guint
-    modifiers*: gdk2.TModifierType
-    binding_set*: PBindingSet
-    flag0*: guint16
-    set_next*: PBindingEntry
-    hash_next*: PBindingEntry
-    signals*: PBindingSignal
-
-  TBindingSignal*{.final, pure.} = object 
-    next*: PBindingSignal
-    signal_name*: cstring
-    n_args*: guint
-    args*: PBindingArg
-
-  TBindingArg*{.final, pure.} = object 
-    arg_type*: TType
-    d*: gdouble
-
-  PBox* = ptr TBox
-  TBox* = object of TContainer
-    children*: PGList
-    spacing*: gint16
-    box_flag0*: guint16
-
-  PBoxClass* = ptr TBoxClass
-  TBoxClass* = object of TContainerClass
-  PBoxChild* = ptr TBoxChild
-  TBoxChild*{.final, pure.} = object 
-    widget*: PWidget
-    padding*: guint16
-    flag0*: guint16
-
-  PButtonBox* = ptr TButtonBox
-  TButtonBox* = object of TBox
-    child_min_width*: gint
-    child_min_height*: gint
-    child_ipad_x*: gint
-    child_ipad_y*: gint
-    layout_style*: TButtonBoxStyle
-
-  PButtonBoxClass* = ptr TButtonBoxClass
-  TButtonBoxClass* = object of TBoxClass
-  PButton* = ptr TButton
-  TButton* = object of TBin
-    event_window*: gdk2.PWindow
-    label_text*: cstring
-    activate_timeout*: guint
-    button_flag0*: guint16
-
-  PButtonClass* = ptr TButtonClass
-  TButtonClass* = object of TBinClass
-    pressed*: proc (button: PButton){.cdecl.}
-    released*: proc (button: PButton){.cdecl.}
-    clicked*: proc (button: PButton){.cdecl.}
-    enter*: proc (button: PButton){.cdecl.}
-    leave*: proc (button: PButton){.cdecl.}
-    activate*: proc (button: PButton){.cdecl.}
-    reserved101: proc (){.cdecl.}
-    reserved102: proc (){.cdecl.}
-    reserved103: proc (){.cdecl.}
-    reserved104: proc (){.cdecl.}
-
-  PCalendarDisplayOptions* = ptr TCalendarDisplayOptions
-  TCalendarDisplayOptions* = int32
-  PCalendar* = ptr TCalendar
-  TCalendar* = object of TWidget
-    header_style*: PStyle
-    label_style*: PStyle
-    month*: gint
-    year*: gint
-    selected_day*: gint
-    day_month*: array[0..5, array[0..6, gint]]
-    day*: array[0..5, array[0..6, gint]]
-    num_marked_dates*: gint
-    marked_date*: array[0..30, gint]
-    display_flags*: TCalendarDisplayOptions
-    marked_date_color*: array[0..30, gdk2.TColor]
-    gc*: gdk2.PGC
-    xor_gc*: gdk2.PGC
-    focus_row*: gint
-    focus_col*: gint
-    highlight_row*: gint
-    highlight_col*: gint
-    private_data*: gpointer
-    grow_space*: array[0..31, gchar]
-    reserved111: proc (){.cdecl.}
-    reserved112: proc (){.cdecl.}
-    reserved113: proc (){.cdecl.}
-    reserved114: proc (){.cdecl.}
-
-  PCalendarClass* = ptr TCalendarClass
-  TCalendarClass* = object of TWidgetClass
-    month_changed*: proc (calendar: PCalendar){.cdecl.}
-    day_selected*: proc (calendar: PCalendar){.cdecl.}
-    day_selected_double_click*: proc (calendar: PCalendar){.cdecl.}
-    prev_month*: proc (calendar: PCalendar){.cdecl.}
-    next_month*: proc (calendar: PCalendar){.cdecl.}
-    prev_year*: proc (calendar: PCalendar){.cdecl.}
-    next_year*: proc (calendar: PCalendar){.cdecl.}
-
-  PCellEditable* = pointer
-  PCellEditableIface* = ptr TCellEditableIface
-  TCellEditableIface* = object of TGTypeInterface
-    editing_done*: proc (cell_editable: PCellEditable){.cdecl.}
-    remove_widget*: proc (cell_editable: PCellEditable){.cdecl.}
-    start_editing*: proc (cell_editable: PCellEditable, event: gdk2.PEvent){.cdecl.}
-
-  PCellRendererState* = ptr TCellRendererState
-  TCellRendererState* = int32
-  PCellRendererMode* = ptr TCellRendererMode
-  TCellRendererMode* = enum 
-    CELL_RENDERER_MODE_INERT, CELL_RENDERER_MODE_ACTIVATABLE, 
-    CELL_RENDERER_MODE_EDITABLE
-  PCellRenderer* = ptr TCellRenderer
-  TCellRenderer* = object of TObject
-    xalign*: gfloat
-    yalign*: gfloat
-    width*: gint
-    height*: gint
-    xpad*: guint16
-    ypad*: guint16
-    CellRenderer_flag0*: guint16
-
-  PCellRendererClass* = ptr TCellRendererClass
-  TCellRendererClass* = object of TObjectClass
-    get_size*: proc (cell: PCellRenderer, widget: PWidget, 
-                     cell_area: gdk2.PRectangle, x_offset: Pgint, y_offset: Pgint, 
-                     width: Pgint, height: Pgint){.cdecl.}
-    render*: proc (cell: PCellRenderer, window: gdk2.PWindow, widget: PWidget, 
-                   background_area: gdk2.PRectangle, cell_area: gdk2.PRectangle, 
-                   expose_area: gdk2.PRectangle, flags: TCellRendererState){.cdecl.}
-    activate*: proc (cell: PCellRenderer, event: gdk2.PEvent, widget: PWidget, 
-                     path: cstring, background_area: gdk2.PRectangle, 
-                     cell_area: gdk2.PRectangle, flags: TCellRendererState): gboolean{.
-        cdecl.}
-    start_editing*: proc (cell: PCellRenderer, event: gdk2.PEvent, 
-                          widget: PWidget, path: cstring, 
-                          background_area: gdk2.PRectangle, 
-                          cell_area: gdk2.PRectangle, flags: TCellRendererState): PCellEditable{.
-        cdecl.}
-    reserved121: proc (){.cdecl.}
-    reserved122: proc (){.cdecl.}
-    reserved123: proc (){.cdecl.}
-    reserved124: proc (){.cdecl.}
-
-  PCellRendererText* = ptr TCellRendererText
-  TCellRendererText* = object of TCellRenderer
-    text*: cstring
-    font*: pango.PFontDescription
-    font_scale*: gdouble
-    foreground*: pango.TColor
-    background*: pango.TColor
-    extra_attrs*: pango.PAttrList
-    underline_style*: pango.TUnderline
-    rise*: gint
-    fixed_height_rows*: gint
-    CellRendererText_flag0*: guint16
-
-  PCellRendererTextClass* = ptr TCellRendererTextClass
-  TCellRendererTextClass* = object of TCellRendererClass
-    edited*: proc (cell_renderer_text: PCellRendererText, path: cstring, 
-                   new_text: cstring){.cdecl.}
-    reserved131: proc (){.cdecl.}
-    reserved132: proc (){.cdecl.}
-    reserved133: proc (){.cdecl.}
-    reserved134: proc (){.cdecl.}
-
-  PCellRendererToggle* = ptr TCellRendererToggle
-  TCellRendererToggle* = object of TCellRenderer
-    CellRendererToggle_flag0*: guint16
-
-  PCellRendererToggleClass* = ptr TCellRendererToggleClass
-  TCellRendererToggleClass* = object of TCellRendererClass
-    toggled*: proc (cell_renderer_toggle: PCellRendererToggle, path: cstring){.
-        cdecl.}
-    reserved141: proc (){.cdecl.}
-    reserved142: proc (){.cdecl.}
-    reserved143: proc (){.cdecl.}
-    reserved144: proc (){.cdecl.}
-
-  PCellRendererPixbuf* = ptr TCellRendererPixbuf
-  TCellRendererPixbuf* = object of TCellRenderer
-    pixbuf*: gdk2pixbuf.PPixbuf
-    pixbuf_expander_open*: gdk2pixbuf.PPixbuf
-    pixbuf_expander_closed*: gdk2pixbuf.PPixbuf
-
-  PCellRendererPixbufClass* = ptr TCellRendererPixbufClass
-  TCellRendererPixbufClass* = object of TCellRendererClass
-    reserved151: proc (){.cdecl.}
-    reserved152: proc (){.cdecl.}
-    reserved153: proc (){.cdecl.}
-    reserved154: proc (){.cdecl.}
-
-  PItem* = ptr TItem
-  TItem* = object of TBin
-  PItemClass* = ptr TItemClass
-  TItemClass* = object of TBinClass
-    select*: proc (item: PItem){.cdecl.}
-    deselect*: proc (item: PItem){.cdecl.}
-    toggle*: proc (item: PItem){.cdecl.}
-    reserved161: proc (){.cdecl.}
-    reserved162: proc (){.cdecl.}
-    reserved163: proc (){.cdecl.}
-    reserved164: proc (){.cdecl.}
-
-  PMenuItem* = ptr TMenuItem
-  TMenuItem* = object of TItem
-    submenu*: PWidget
-    event_window*: gdk2.PWindow
-    toggle_size*: guint16
-    accelerator_width*: guint16
-    accel_path*: cstring
-    MenuItem_flag0*: guint16
-    timer*: guint
-
-  PMenuItemClass* = ptr TMenuItemClass
-  TMenuItemClass* = object of TItemClass
-    MenuItemClass_flag0*: guint16
-    activate*: proc (menu_item: PMenuItem){.cdecl.}
-    activate_item*: proc (menu_item: PMenuItem){.cdecl.}
-    toggle_size_request*: proc (menu_item: PMenuItem, requisition: Pgint){.cdecl.}
-    toggle_size_allocate*: proc (menu_item: PMenuItem, allocation: gint){.cdecl.}
-    reserved171: proc (){.cdecl.}
-    reserved172: proc (){.cdecl.}
-    reserved173: proc (){.cdecl.}
-    reserved174: proc (){.cdecl.}
-
-  PToggleButton* = ptr TToggleButton
-  TToggleButton* = object of TButton
-    ToggleButton_flag0*: guint16
-
-  PToggleButtonClass* = ptr TToggleButtonClass
-  TToggleButtonClass* = object of TButtonClass
-    toggled*: proc (toggle_button: PToggleButton){.cdecl.}
-    reserved171: proc (){.cdecl.}
-    reserved172: proc (){.cdecl.}
-    reserved173: proc (){.cdecl.}
-    reserved174: proc (){.cdecl.}
-
-  PCheckButton* = ptr TCheckButton
-  TCheckButton* = object of TToggleButton
-  PCheckButtonClass* = ptr TCheckButtonClass
-  TCheckButtonClass* = object of TToggleButtonClass
-    draw_indicator*: proc (check_button: PCheckButton, area: gdk2.PRectangle){.
-        cdecl.}
-    reserved181: proc (){.cdecl.}
-    reserved182: proc (){.cdecl.}
-    reserved183: proc (){.cdecl.}
-    reserved184: proc (){.cdecl.}
-
-  PCheckMenuItem* = ptr TCheckMenuItem
-  TCheckMenuItem* = object of TMenuItem
-    CheckMenuItem_flag0*: guint16
-
-  PCheckMenuItemClass* = ptr TCheckMenuItemClass
-  TCheckMenuItemClass* = object of TMenuItemClass
-    toggled*: proc (check_menu_item: PCheckMenuItem){.cdecl.}
-    draw_indicator*: proc (check_menu_item: PCheckMenuItem, area: gdk2.PRectangle){.
-        cdecl.}
-    reserved191: proc (){.cdecl.}
-    reserved192: proc (){.cdecl.}
-    reserved193: proc (){.cdecl.}
-    reserved194: proc (){.cdecl.}
-
-  PClipboard* = pointer
-  TClipboardReceivedFunc* = proc (clipboard: PClipboard, 
-                                  selection_data: PSelectionData, data: gpointer){.
-      cdecl.}
-  TClipboardTextReceivedFunc* = proc (clipboard: PClipboard, text: cstring, 
-                                      data: gpointer){.cdecl.}
-  TClipboardGetFunc* = proc (clipboard: PClipboard, 
-                             selection_data: PSelectionData, info: guint, 
-                             user_data_or_owner: gpointer){.cdecl.}
-  TClipboardClearFunc* = proc (clipboard: PClipboard, 
-                               user_data_or_owner: gpointer){.cdecl.}
-  PCList* = ptr TCList
-  PCListColumn* = ptr TCListColumn
-  PCListRow* = ptr TCListRow
-  PCell* = ptr TCell
-  PCellType* = ptr TCellType
-  TCellType* = enum 
-    CELL_EMPTY, CELL_TEXT, CELL_PIXMAP, CELL_PIXTEXT, CELL_WIDGET
-  PCListDragPos* = ptr TCListDragPos
-  TCListDragPos* = enum 
-    CLIST_DRAG_NONE, CLIST_DRAG_BEFORE, CLIST_DRAG_INTO, CLIST_DRAG_AFTER
-  PButtonAction* = ptr TButtonAction
-  TButtonAction* = int32
-  TCListCompareFunc* = proc (clist: PCList, ptr1: gconstpointer, 
-                             ptr2: gconstpointer): gint{.cdecl.}
-  PCListCellInfo* = ptr TCListCellInfo
-  TCListCellInfo*{.final, pure.} = object 
-    row*: gint
-    column*: gint
-
-  PCListDestInfo* = ptr TCListDestInfo
-  TCListDestInfo*{.final, pure.} = object 
-    cell*: TCListCellInfo
-    insert_pos*: TCListDragPos
-
-  TCList* = object of TContainer
-    CList_flags*: guint16
-    row_mem_chunk*: PGMemChunk
-    cell_mem_chunk*: PGMemChunk
-    freeze_count*: guint
-    internal_allocation*: gdk2.TRectangle
-    rows*: gint
-    row_height*: gint
-    row_list*: PGList
-    row_list_end*: PGList
-    columns*: gint
-    column_title_area*: gdk2.TRectangle
-    title_window*: gdk2.PWindow
-    column*: PCListColumn
-    clist_window*: gdk2.PWindow
-    clist_window_width*: gint
-    clist_window_height*: gint
-    hoffset*: gint
-    voffset*: gint
-    shadow_type*: TShadowType
-    selection_mode*: TSelectionMode
-    selection*: PGList
-    selection_end*: PGList
-    undo_selection*: PGList
-    undo_unselection*: PGList
-    undo_anchor*: gint
-    button_actions*: array[0..4, guint8]
-    drag_button*: guint8
-    click_cell*: TCListCellInfo
-    hadjustment*: PAdjustment
-    vadjustment*: PAdjustment
-    xor_gc*: gdk2.PGC
-    fg_gc*: gdk2.PGC
-    bg_gc*: gdk2.PGC
-    cursor_drag*: gdk2.PCursor
-    x_drag*: gint
-    focus_row*: gint
-    focus_header_column*: gint
-    anchor*: gint
-    anchor_state*: TStateType
-    drag_pos*: gint
-    htimer*: gint
-    vtimer*: gint
-    sort_type*: TSortType
-    compare*: TCListCompareFunc
-    sort_column*: gint
-    drag_highlight_row*: gint
-    drag_highlight_pos*: TCListDragPos
-
-  PCListClass* = ptr TCListClass
-  TCListClass* = object of TContainerClass
-    set_scroll_adjustments*: proc (clist: PCList, hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-    refresh*: proc (clist: PCList){.cdecl.}
-    select_row*: proc (clist: PCList, row: gint, column: gint, event: gdk2.PEvent){.
-        cdecl.}
-    unselect_row*: proc (clist: PCList, row: gint, column: gint, 
-                         event: gdk2.PEvent){.cdecl.}
-    row_move*: proc (clist: PCList, source_row: gint, dest_row: gint){.cdecl.}
-    click_column*: proc (clist: PCList, column: gint){.cdecl.}
-    resize_column*: proc (clist: PCList, column: gint, width: gint){.cdecl.}
-    toggle_focus_row*: proc (clist: PCList){.cdecl.}
-    select_all*: proc (clist: PCList){.cdecl.}
-    unselect_all*: proc (clist: PCList){.cdecl.}
-    undo_selection*: proc (clist: PCList){.cdecl.}
-    start_selection*: proc (clist: PCList){.cdecl.}
-    end_selection*: proc (clist: PCList){.cdecl.}
-    extend_selection*: proc (clist: PCList, scroll_type: TScrollType, 
-                             position: gfloat, auto_start_selection: gboolean){.
-        cdecl.}
-    scroll_horizontal*: proc (clist: PCList, scroll_type: TScrollType, 
-                              position: gfloat){.cdecl.}
-    scroll_vertical*: proc (clist: PCList, scroll_type: TScrollType, 
-                            position: gfloat){.cdecl.}
-    toggle_add_mode*: proc (clist: PCList){.cdecl.}
-    abort_column_resize*: proc (clist: PCList){.cdecl.}
-    resync_selection*: proc (clist: PCList, event: gdk2.PEvent){.cdecl.}
-    selection_find*: proc (clist: PCList, row_number: gint, 
-                           row_list_element: PGList): PGList{.cdecl.}
-    draw_row*: proc (clist: PCList, area: gdk2.PRectangle, row: gint, 
-                     clist_row: PCListRow){.cdecl.}
-    draw_drag_highlight*: proc (clist: PCList, target_row: PCListRow, 
-                                target_row_number: gint, drag_pos: TCListDragPos){.
-        cdecl.}
-    clear*: proc (clist: PCList){.cdecl.}
-    fake_unselect_all*: proc (clist: PCList, row: gint){.cdecl.}
-    sort_list*: proc (clist: PCList){.cdecl.}
-    insert_row*: proc (clist: PCList, row: gint): gint{.cdecl, varargs.}
-    remove_row*: proc (clist: PCList, row: gint){.cdecl.}
-    set_cell_contents*: proc (clist: PCList, clist_row: PCListRow, column: gint, 
-                              thetype: TCellType, text: cstring, 
-                              spacing: guint8, pixmap: gdk2.PPixmap, 
-                              mask: gdk2.PBitmap){.cdecl.}
-    cell_size_request*: proc (clist: PCList, clist_row: PCListRow, column: gint, 
-                              requisition: PRequisition){.cdecl.}
-
-  PGPtrArray = pointer
-  PGArray = pointer
-  TCListColumn*{.final, pure.} = object 
-    title*: cstring
-    area*: gdk2.TRectangle
-    button*: PWidget
-    window*: gdk2.PWindow
-    width*: gint
-    min_width*: gint
-    max_width*: gint
-    justification*: TJustification
-    flag0*: guint16
-
-  TCListRow*{.final, pure.} = object 
-    cell*: PCell
-    state*: TStateType
-    foreground*: gdk2.TColor
-    background*: gdk2.TColor
-    style*: PStyle
-    data*: gpointer
-    destroy*: TDestroyNotify
-    flag0*: guint16
-
-  PCellText* = ptr TCellText
-  TCellText*{.final, pure.} = object 
-    `type`*: TCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PStyle
-    text*: cstring
-
-  PCellPixmap* = ptr TCellPixmap
-  TCellPixmap*{.final, pure.} = object 
-    `type`*: TCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PStyle
-    pixmap*: gdk2.PPixmap
-    mask*: gdk2.PBitmap
-
-  PCellPixText* = ptr TCellPixText
-  TCellPixText*{.final, pure.} = object 
-    `type`*: TCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PStyle
-    text*: cstring
-    spacing*: guint8
-    pixmap*: gdk2.PPixmap
-    mask*: gdk2.PBitmap
-
-  PCellWidget* = ptr TCellWidget
-  TCellWidget*{.final, pure.} = object 
-    `type`*: TCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PStyle
-    widget*: PWidget
-
-  TCell*{.final, pure.} = object 
-    `type`*: TCellType
-    vertical*: gint16
-    horizontal*: gint16
-    style*: PStyle
-    text*: cstring
-    spacing*: guint8
-    pixmap*: gdk2.PPixmap
-    mask*: gdk2.PBitmap
-
-  PDialogFlags* = ptr TDialogFlags
-  TDialogFlags* = int32
-  PResponseType* = ptr TResponseType
-  TResponseType* = int32
-  PDialog* = ptr TDialog
-  TDialog* = object of TWindow
-    vbox*: PWidget
-    action_area*: PWidget
-    separator*: PWidget
-
-  PDialogClass* = ptr TDialogClass
-  TDialogClass* = object of TWindowClass
-    response*: proc (dialog: PDialog, response_id: gint){.cdecl.}
-    closeFile*: proc (dialog: PDialog){.cdecl.}
-    reserved201: proc (){.cdecl.}
-    reserved202: proc (){.cdecl.}
-    reserved203: proc (){.cdecl.}
-    reserved204: proc (){.cdecl.}
-
-  PVBox* = ptr TVBox
-  TVBox* = object of TBox
-  PVBoxClass* = ptr TVBoxClass
-  TVBoxClass* = object of TBoxClass
-  TColorSelectionChangePaletteFunc* = proc (colors: gdk2.PColor, n_colors: gint){.
-      cdecl.}
-  TColorSelectionChangePaletteWithScreenFunc* = proc (screen: gdk2.PScreen, 
-      colors: gdk2.PColor, n_colors: gint){.cdecl.}
-  PColorSelection* = ptr TColorSelection
-  TColorSelection* = object of TVBox
-    private_data*: gpointer
-
-  PColorSelectionClass* = ptr TColorSelectionClass
-  TColorSelectionClass* = object of TVBoxClass
-    color_changed*: proc (color_selection: PColorSelection){.cdecl.}
-    reserved211: proc (){.cdecl.}
-    reserved212: proc (){.cdecl.}
-    reserved213: proc (){.cdecl.}
-    reserved214: proc (){.cdecl.}
-
-  PColorSelectionDialog* = ptr TColorSelectionDialog
-  TColorSelectionDialog* = object of TDialog
-    colorsel*: PWidget
-    ok_button*: PWidget
-    cancel_button*: PWidget
-    help_button*: PWidget
-
-  PColorSelectionDialogClass* = ptr TColorSelectionDialogClass
-  TColorSelectionDialogClass* = object of TDialogClass
-    reserved221: proc (){.cdecl.}
-    reserved222: proc (){.cdecl.}
-    reserved223: proc (){.cdecl.}
-    reserved224: proc (){.cdecl.}
-
-  PHBox* = ptr THBox
-  THBox* = object of TBox
-  PHBoxClass* = ptr THBoxClass
-  THBoxClass* = object of TBoxClass
-  PCombo* = ptr TCombo
-  TCombo* = object of THBox
-    entry*: PWidget
-    button*: PWidget
-    popup*: PWidget
-    popwin*: PWidget
-    list*: PWidget
-    entry_change_id*: guint
-    list_change_id*: guint
-    Combo_flag0*: guint16
-    current_button*: guint16
-    activate_id*: guint
-
-  PComboClass* = ptr TComboClass
-  TComboClass* = object of THBoxClass
-    reserved231: proc (){.cdecl.}
-    reserved232: proc (){.cdecl.}
-    reserved233: proc (){.cdecl.}
-    reserved234: proc (){.cdecl.}
-
-  PCTreePos* = ptr TCTreePos
-  TCTreePos* = enum 
-    CTREE_POS_BEFORE, CTREE_POS_AS_CHILD, CTREE_POS_AFTER
-  PCTreeLineStyle* = ptr TCTreeLineStyle
-  TCTreeLineStyle* = enum 
-    CTREE_LINES_NONE, CTREE_LINES_SOLID, CTREE_LINES_DOTTED, CTREE_LINES_TABBED
-  PCTreeExpanderStyle* = ptr TCTreeExpanderStyle
-  TCTreeExpanderStyle* = enum 
-    CTREE_EXPANDER_NONE, CTREE_EXPANDER_SQUARE, CTREE_EXPANDER_TRIANGLE, 
-    CTREE_EXPANDER_CIRCULAR
-  PCTreeExpansionType* = ptr TCTreeExpansionType
-  TCTreeExpansionType* = enum 
-    CTREE_EXPANSION_EXPAND, CTREE_EXPANSION_EXPAND_RECURSIVE, 
-    CTREE_EXPANSION_COLLAPSE, CTREE_EXPANSION_COLLAPSE_RECURSIVE, 
-    CTREE_EXPANSION_TOGGLE, CTREE_EXPANSION_TOGGLE_RECURSIVE
-  PCTree* = ptr TCTree
-  PCTreeNode* = ptr TCTreeNode
-  TCTreeFunc* = proc (ctree: PCTree, node: PCTreeNode, data: gpointer){.cdecl.}
-  TCTreeGNodeFunc* = proc (ctree: PCTree, depth: guint, gnode: PGNode, 
-                           cnode: PCTreeNode, data: gpointer): gboolean{.cdecl.}
-  TCTreeCompareDragFunc* = proc (ctree: PCTree, source_node: PCTreeNode, 
-                                 new_parent: PCTreeNode, new_sibling: PCTreeNode): gboolean{.
-      cdecl.}
-  TCTree* = object of TCList
-    lines_gc*: gdk2.PGC
-    tree_indent*: gint
-    tree_spacing*: gint
-    tree_column*: gint
-    CTree_flag0*: guint16
-    drag_compare*: TCTreeCompareDragFunc
-
-  PCTreeClass* = ptr TCTreeClass
-  TCTreeClass* = object of TCListClass
-    tree_select_row*: proc (ctree: PCTree, row: PCTreeNode, column: gint){.cdecl.}
-    tree_unselect_row*: proc (ctree: PCTree, row: PCTreeNode, column: gint){.
-        cdecl.}
-    tree_expand*: proc (ctree: PCTree, node: PCTreeNode){.cdecl.}
-    tree_collapse*: proc (ctree: PCTree, node: PCTreeNode){.cdecl.}
-    tree_move*: proc (ctree: PCTree, node: PCTreeNode, new_parent: PCTreeNode, 
-                      new_sibling: PCTreeNode){.cdecl.}
-    change_focus_row_expansion*: proc (ctree: PCTree, 
-                                       action: TCTreeExpansionType){.cdecl.}
-
-  PCTreeRow* = ptr TCTreeRow
-  TCTreeRow*{.final, pure.} = object 
-    row*: TCListRow
-    parent*: PCTreeNode
-    sibling*: PCTreeNode
-    children*: PCTreeNode
-    pixmap_closed*: gdk2.PPixmap
-    mask_closed*: gdk2.PBitmap
-    pixmap_opened*: gdk2.PPixmap
-    mask_opened*: gdk2.PBitmap
-    level*: guint16
-    CTreeRow_flag0*: guint16
-
-  TCTreeNode*{.final, pure.} = object 
-    list*: TGList
-
-  PDrawingArea* = ptr TDrawingArea
-  TDrawingArea* = object of TWidget
-    draw_data*: gpointer
-
-  PDrawingAreaClass* = ptr TDrawingAreaClass
-  TDrawingAreaClass* = object of TWidgetClass
-    reserved241: proc (){.cdecl.}
-    reserved242: proc (){.cdecl.}
-    reserved243: proc (){.cdecl.}
-    reserved244: proc (){.cdecl.}
-
-  Tctlpoint* = array[0..1, gfloat]
-  Pctlpoint* = ptr Tctlpoint
-  PCurve* = ptr TCurve
-  TCurve* = object of TDrawingArea
-    cursor_type*: gint
-    min_x*: gfloat
-    max_x*: gfloat
-    min_y*: gfloat
-    max_y*: gfloat
-    pixmap*: gdk2.PPixmap
-    curve_type*: TCurveType
-    height*: gint
-    grab_point*: gint
-    last*: gint
-    num_points*: gint
-    point*: gdk2.PPoint
-    num_ctlpoints*: gint
-    ctlpoint*: Pctlpoint
-
-  PCurveClass* = ptr TCurveClass
-  TCurveClass* = object of TDrawingAreaClass
-    curve_type_changed*: proc (curve: PCurve){.cdecl.}
-    reserved251: proc (){.cdecl.}
-    reserved252: proc (){.cdecl.}
-    reserved253: proc (){.cdecl.}
-    reserved254: proc (){.cdecl.}
-
-  PDestDefaults* = ptr TDestDefaults
-  TDestDefaults* = int32
-  PTargetFlags* = ptr TTargetFlags
-  TTargetFlags* = int32
-  PEditable* = pointer
-  PEditableClass* = ptr TEditableClass
-  TEditableClass* = object of TGTypeInterface
-    insert_text*: proc (editable: PEditable, text: cstring, length: gint, 
-                        position: Pgint){.cdecl.}
-    delete_text*: proc (editable: PEditable, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    changed*: proc (editable: PEditable){.cdecl.}
-    do_insert_text*: proc (editable: PEditable, text: cstring, length: gint, 
-                           position: Pgint){.cdecl.}
-    do_delete_text*: proc (editable: PEditable, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    get_chars*: proc (editable: PEditable, start_pos: gint, end_pos: gint): cstring{.
-        cdecl.}
-    set_selection_bounds*: proc (editable: PEditable, start_pos: gint, 
-                                 end_pos: gint){.cdecl.}
-    get_selection_bounds*: proc (editable: PEditable, start_pos: Pgint, 
-                                 end_pos: Pgint): gboolean{.cdecl.}
-    set_position*: proc (editable: PEditable, position: gint){.cdecl.}
-    get_position*: proc (editable: PEditable): gint{.cdecl.}
-
-  PIMContext* = ptr TIMContext
-  TIMContext* = object of TGObject
-  PIMContextClass* = ptr TIMContextClass
-  TIMContextClass* = object of TObjectClass
-    preedit_start*: proc (context: PIMContext){.cdecl.}
-    preedit_end*: proc (context: PIMContext){.cdecl.}
-    preedit_changed*: proc (context: PIMContext){.cdecl.}
-    commit*: proc (context: PIMContext, str: cstring){.cdecl.}
-    retrieve_surrounding*: proc (context: PIMContext): gboolean{.cdecl.}
-    delete_surrounding*: proc (context: PIMContext, offset: gint, n_chars: gint): gboolean{.
-        cdecl.}
-    set_client_window*: proc (context: PIMContext, window: gdk2.PWindow){.cdecl.}
-    get_preedit_string*: proc (context: PIMContext, str: PPgchar, 
-                               attrs: var pango.PAttrList, cursor_pos: Pgint){.
-        cdecl.}
-    filter_keypress*: proc (context: PIMContext, event: gdk2.PEventKey): gboolean{.
-        cdecl.}
-    focus_in*: proc (context: PIMContext){.cdecl.}
-    focus_out*: proc (context: PIMContext){.cdecl.}
-    reset*: proc (context: PIMContext){.cdecl.}
-    set_cursor_location*: proc (context: PIMContext, area: gdk2.PRectangle){.cdecl.}
-    set_use_preedit*: proc (context: PIMContext, use_preedit: gboolean){.cdecl.}
-    set_surrounding*: proc (context: PIMContext, text: cstring, len: gint, 
-                            cursor_index: gint){.cdecl.}
-    get_surrounding*: proc (context: PIMContext, text: PPgchar, 
-                            cursor_index: Pgint): gboolean{.cdecl.}
-    reserved261: proc (){.cdecl.}
-    reserved262: proc (){.cdecl.}
-    reserved263: proc (){.cdecl.}
-    reserved264: proc (){.cdecl.}
-    reserved265: proc (){.cdecl.}
-    reserved266: proc (){.cdecl.}
-
-  PMenuShell* = ptr TMenuShell
-  TMenuShell* = object of TContainer
-    children*: PGList
-    active_menu_item*: PWidget
-    parent_menu_shell*: PWidget
-    button*: guint
-    activate_time*: guint32
-    MenuShell_flag0*: guint16
-
-  PMenuShellClass* = ptr TMenuShellClass
-  TMenuShellClass* = object of TContainerClass
-    MenuShellClass_flag0*: guint16
-    deactivate*: proc (menu_shell: PMenuShell){.cdecl.}
-    selection_done*: proc (menu_shell: PMenuShell){.cdecl.}
-    move_current*: proc (menu_shell: PMenuShell, direction: TMenuDirectionType){.
-        cdecl.}
-    activate_current*: proc (menu_shell: PMenuShell, force_hide: gboolean){.
-        cdecl.}
-    cancel*: proc (menu_shell: PMenuShell){.cdecl.}
-    select_item*: proc (menu_shell: PMenuShell, menu_item: PWidget){.cdecl.}
-    insert*: proc (menu_shell: PMenuShell, child: PWidget, position: gint){.
-        cdecl.}
-    reserved271: proc (){.cdecl.}
-    reserved272: proc (){.cdecl.}
-    reserved273: proc (){.cdecl.}
-    reserved274: proc (){.cdecl.}
-
-  TMenuPositionFunc* = proc (menu: PMenu, x: Pgint, y: Pgint, 
-                             push_in: Pgboolean, user_data: gpointer){.cdecl.}
-  TMenuDetachFunc* = proc (attach_widget: PWidget, menu: PMenu){.cdecl.}
-  TMenu* = object of TMenuShell
-    parent_menu_item*: PWidget
-    old_active_menu_item*: PWidget
-    accel_group*: PAccelGroup
-    accel_path*: cstring
-    position_func*: TMenuPositionFunc
-    position_func_data*: gpointer
-    toggle_size*: guint
-    toplevel*: PWidget
-    tearoff_window*: PWidget
-    tearoff_hbox*: PWidget
-    tearoff_scrollbar*: PWidget
-    tearoff_adjustment*: PAdjustment
-    view_window*: gdk2.PWindow
-    bin_window*: gdk2.PWindow
-    scroll_offset*: gint
-    saved_scroll_offset*: gint
-    scroll_step*: gint
-    timeout_id*: guint
-    navigation_region*: gdk2.PRegion
-    navigation_timeout*: guint
-    Menu_flag0*: guint16
-
-  PMenuClass* = ptr TMenuClass
-  TMenuClass* = object of TMenuShellClass
-    reserved281: proc (){.cdecl.}
-    reserved282: proc (){.cdecl.}
-    reserved283: proc (){.cdecl.}
-    reserved284: proc (){.cdecl.}
-
-  PEntry* = ptr TEntry
-  TEntry* = object of TWidget
-    text*: cstring
-    Entry_flag0*: guint16
-    text_length*: guint16
-    text_max_length*: guint16
-    text_area*: gdk2.PWindow
-    im_context*: PIMContext
-    popup_menu*: PWidget
-    current_pos*: gint
-    selection_bound*: gint
-    cached_layout*: pango.PLayout
-    flag1*: guint16
-    button*: guint
-    blink_timeout*: guint
-    recompute_idle*: guint
-    scroll_offset*: gint
-    ascent*: gint
-    descent*: gint
-    text_size*: guint16
-    n_bytes*: guint16
-    preedit_length*: guint16
-    preedit_cursor*: guint16
-    dnd_position*: gint
-    drag_start_x*: gint
-    drag_start_y*: gint
-    invisible_char*: gunichar
-    width_chars*: gint
-
-  PEntryClass* = ptr TEntryClass
-  TEntryClass* = object of TWidgetClass
-    populate_popup*: proc (entry: PEntry, menu: PMenu){.cdecl.}
-    activate*: proc (entry: PEntry){.cdecl.}
-    move_cursor*: proc (entry: PEntry, step: TMovementStep, count: gint, 
-                        extend_selection: gboolean){.cdecl.}
-    insert_at_cursor*: proc (entry: PEntry, str: cstring){.cdecl.}
-    delete_from_cursor*: proc (entry: PEntry, thetype: TDeleteType, count: gint){.
-        cdecl.}
-    cut_clipboard*: proc (entry: PEntry){.cdecl.}
-    copy_clipboard*: proc (entry: PEntry){.cdecl.}
-    paste_clipboard*: proc (entry: PEntry){.cdecl.}
-    toggle_overwrite*: proc (entry: PEntry){.cdecl.}
-    reserved291: proc (){.cdecl.}
-    reserved292: proc (){.cdecl.}
-    reserved293: proc (){.cdecl.}
-    reserved294: proc (){.cdecl.}
-
-  PEventBox* = ptr TEventBox
-  TEventBox* = object of TBin
-  PEventBoxClass* = ptr TEventBoxClass
-  TEventBoxClass* = object of TBinClass
-  PFileSelection* = ptr TFileSelection
-  TFileSelection* = object of TDialog
-    dir_list*: PWidget
-    file_list*: PWidget
-    selection_entry*: PWidget
-    selection_text*: PWidget
-    main_vbox*: PWidget
-    ok_button*: PWidget
-    cancel_button*: PWidget
-    help_button*: PWidget
-    history_pulldown*: PWidget
-    history_menu*: PWidget
-    history_list*: PGList
-    fileop_dialog*: PWidget
-    fileop_entry*: PWidget
-    fileop_file*: cstring
-    cmpl_state*: gpointer
-    fileop_c_dir*: PWidget
-    fileop_del_file*: PWidget
-    fileop_ren_file*: PWidget
-    button_area*: PWidget
-    FileSelection_action_area*: PWidget
-    selected_names*: PGPtrArray
-    last_selected*: cstring
-
-  PFileSelectionClass* = ptr TFileSelectionClass
-  TFileSelectionClass* = object of TDialogClass
-    reserved301: proc (){.cdecl.}
-    reserved302: proc (){.cdecl.}
-    reserved303: proc (){.cdecl.}
-    reserved304: proc (){.cdecl.}
-
-  PFixed* = ptr TFixed
-  TFixed* = object of TContainer
-    children*: PGList
-
-  PFixedClass* = ptr TFixedClass
-  TFixedClass* = object of TContainerClass
-  PFixedChild* = ptr TFixedChild
-  TFixedChild*{.final, pure.} = object 
-    widget*: PWidget
-    x*: gint
-    y*: gint
-
-  PFontSelection* = ptr TFontSelection
-  TFontSelection* = object of TVBox
-    font_entry*: PWidget
-    family_list*: PWidget
-    font_style_entry*: PWidget
-    face_list*: PWidget
-    size_entry*: PWidget
-    size_list*: PWidget
-    pixels_button*: PWidget
-    points_button*: PWidget
-    filter_button*: PWidget
-    preview_entry*: PWidget
-    family*: pango.PFontFamily
-    face*: pango.PFontFace
-    size*: gint
-    font*: gdk2.PFont
-
-  PFontSelectionClass* = ptr TFontSelectionClass
-  TFontSelectionClass* = object of TVBoxClass
-    reserved311: proc (){.cdecl.}
-    reserved312: proc (){.cdecl.}
-    reserved313: proc (){.cdecl.}
-    reserved314: proc (){.cdecl.}
-
-  PFontSelectionDialog* = ptr TFontSelectionDialog
-  TFontSelectionDialog* = object of TDialog
-    fontsel*: PWidget
-    main_vbox*: PWidget
-    FontSelectionDialog_action_area*: PWidget
-    ok_button*: PWidget
-    apply_button*: PWidget
-    cancel_button*: PWidget
-    dialog_width*: gint
-    auto_resize*: gboolean
-
-  PFontSelectionDialogClass* = ptr TFontSelectionDialogClass
-  TFontSelectionDialogClass* = object of TDialogClass
-    reserved321: proc (){.cdecl.}
-    reserved322: proc (){.cdecl.}
-    reserved323: proc (){.cdecl.}
-    reserved324: proc (){.cdecl.}
-
-  PGammaCurve* = ptr TGammaCurve
-  TGammaCurve* = object of TVBox
-    table*: PWidget
-    curve*: PWidget
-    button*: array[0..4, PWidget]
-    gamma*: gfloat
-    gamma_dialog*: PWidget
-    gamma_text*: PWidget
-
-  PGammaCurveClass* = ptr TGammaCurveClass
-  TGammaCurveClass* = object of TVBoxClass
-    reserved331: proc (){.cdecl.}
-    reserved332: proc (){.cdecl.}
-    reserved333: proc (){.cdecl.}
-    reserved334: proc (){.cdecl.}
-
-  PHandleBox* = ptr THandleBox
-  THandleBox* = object of TBin
-    bin_window*: gdk2.PWindow
-    float_window*: gdk2.PWindow
-    shadow_type*: TShadowType
-    HandleBox_flag0*: guint16
-    deskoff_x*: gint
-    deskoff_y*: gint
-    attach_allocation*: TAllocation
-    float_allocation*: TAllocation
-
-  PHandleBoxClass* = ptr THandleBoxClass
-  THandleBoxClass* = object of TBinClass
-    child_attached*: proc (handle_box: PHandleBox, child: PWidget){.cdecl.}
-    child_detached*: proc (handle_box: PHandleBox, child: PWidget){.cdecl.}
-    reserved341: proc (){.cdecl.}
-    reserved342: proc (){.cdecl.}
-    reserved343: proc (){.cdecl.}
-    reserved344: proc (){.cdecl.}
-
-  PPaned* = ptr TPaned
-  TPaned* = object of TContainer
-    child1*: PWidget
-    child2*: PWidget
-    handle*: gdk2.PWindow
-    xor_gc*: gdk2.PGC
-    cursor_type*: gdk2.TCursorType
-    handle_pos*: gdk2.TRectangle
-    child1_size*: gint
-    last_allocation*: gint
-    min_position*: gint
-    max_position*: gint
-    Paned_flag0*: guint16
-    last_child1_focus*: PWidget
-    last_child2_focus*: PWidget
-    saved_focus*: PWidget
-    drag_pos*: gint
-    original_position*: gint
-
-  PPanedClass* = ptr TPanedClass
-  TPanedClass* = object of TContainerClass
-    cycle_child_focus*: proc (paned: PPaned, reverse: gboolean): gboolean{.cdecl.}
-    toggle_handle_focus*: proc (paned: PPaned): gboolean{.cdecl.}
-    move_handle*: proc (paned: PPaned, scroll: TScrollType): gboolean{.cdecl.}
-    cycle_handle_focus*: proc (paned: PPaned, reverse: gboolean): gboolean{.
-        cdecl.}
-    accept_position*: proc (paned: PPaned): gboolean{.cdecl.}
-    cancel_position*: proc (paned: PPaned): gboolean{.cdecl.}
-    reserved351: proc (){.cdecl.}
-    reserved352: proc (){.cdecl.}
-    reserved353: proc (){.cdecl.}
-    reserved354: proc (){.cdecl.}
-
-  PHButtonBox* = ptr THButtonBox
-  THButtonBox* = object of TButtonBox
-  PHButtonBoxClass* = ptr THButtonBoxClass
-  THButtonBoxClass* = object of TButtonBoxClass
-  PHPaned* = ptr THPaned
-  THPaned* = object of TPaned
-  PHPanedClass* = ptr THPanedClass
-  THPanedClass* = object of TPanedClass
-  PRulerMetric* = ptr TRulerMetric
-  PRuler* = ptr TRuler
-  TRuler* = object of TWidget
-    backing_store*: gdk2.PPixmap
-    non_gr_exp_gc*: gdk2.PGC
-    metric*: PRulerMetric
-    xsrc*: gint
-    ysrc*: gint
-    slider_size*: gint
-    lower*: gdouble
-    upper*: gdouble
-    position*: gdouble
-    max_size*: gdouble
-
-  PRulerClass* = ptr TRulerClass
-  TRulerClass* = object of TWidgetClass
-    draw_ticks*: proc (ruler: PRuler){.cdecl.}
-    draw_pos*: proc (ruler: PRuler){.cdecl.}
-    reserved361: proc (){.cdecl.}
-    reserved362: proc (){.cdecl.}
-    reserved363: proc (){.cdecl.}
-    reserved364: proc (){.cdecl.}
-
-  TRulerMetric*{.final, pure.} = object 
-    metric_name*: cstring
-    abbrev*: cstring
-    pixels_per_unit*: gdouble
-    ruler_scale*: array[0..9, gdouble]
-    subdivide*: array[0..4, gint]
-
-  PHRuler* = ptr THRuler
-  THRuler* = object of TRuler
-  PHRulerClass* = ptr THRulerClass
-  THRulerClass* = object of TRulerClass
-  PRcContext* = pointer
-  PSettings* = ptr TSettings
-  TSettings* = object of TGObject
-    queued_settings*: PGData
-    property_values*: PGValue
-    rc_context*: PRcContext
-    screen*: gdk2.PScreen
-
-  PSettingsClass* = ptr TSettingsClass
-  TSettingsClass* = object of TGObjectClass
-  PSettingsValue* = ptr TSettingsValue
-  TSettingsValue*{.final, pure.} = object 
-    origin*: cstring
-    value*: TGValue
-
-  PRcFlags* = ptr TRcFlags
-  TRcFlags* = int32
-  PRcStyle* = ptr TRcStyle
-  TRcStyle* = object of TGObject
-    name*: cstring
-    bg_pixmap_name*: array[0..4, cstring]
-    font_desc*: pango.PFontDescription
-    color_flags*: array[0..4, TRcFlags]
-    fg*: array[0..4, gdk2.TColor]
-    bg*: array[0..4, gdk2.TColor]
-    text*: array[0..4, gdk2.TColor]
-    base*: array[0..4, gdk2.TColor]
-    xthickness*: gint
-    ythickness*: gint
-    rc_properties*: PGArray
-    rc_style_lists*: PGSList
-    icon_factories*: PGSList
-    RcStyle_flag0*: guint16
-
-  PRcStyleClass* = ptr TRcStyleClass
-  TRcStyleClass* = object of TGObjectClass
-    create_rc_style*: proc (rc_style: PRcStyle): PRcStyle{.cdecl.}
-    parse*: proc (rc_style: PRcStyle, settings: PSettings, scanner: PGScanner): guint{.
-        cdecl.}
-    merge*: proc (dest: PRcStyle, src: PRcStyle){.cdecl.}
-    create_style*: proc (rc_style: PRcStyle): PStyle{.cdecl.}
-    reserved371: proc (){.cdecl.}
-    reserved372: proc (){.cdecl.}
-    reserved373: proc (){.cdecl.}
-    reserved374: proc (){.cdecl.}
-
-  PRcTokenType* = ptr TRcTokenType
-  TRcTokenType* = enum 
-    RC_TOKEN_INVALID, RC_TOKEN_INCLUDE, RC_TOKEN_NORMAL, RC_TOKEN_ACTIVE, 
-    RC_TOKEN_PRELIGHT, RC_TOKEN_SELECTED, RC_TOKEN_INSENSITIVE, RC_TOKEN_FG, 
-    RC_TOKEN_BG, RC_TOKEN_TEXT, RC_TOKEN_BASE, RC_TOKEN_XTHICKNESS, 
-    RC_TOKEN_YTHICKNESS, RC_TOKEN_FONT, RC_TOKEN_FONTSET, RC_TOKEN_FONT_NAME, 
-    RC_TOKEN_BG_PIXMAP, RC_TOKEN_PIXMAP_PATH, RC_TOKEN_STYLE, RC_TOKEN_BINDING, 
-    RC_TOKEN_BIND, RC_TOKEN_WIDGET, RC_TOKEN_WIDGET_CLASS, RC_TOKEN_CLASS, 
-    RC_TOKEN_LOWEST, RC_TOKEN_GTK, RC_TOKEN_APPLICATION, RC_TOKEN_THEME, 
-    RC_TOKEN_RC, RC_TOKEN_HIGHEST, RC_TOKEN_ENGINE, RC_TOKEN_MODULE_PATH, 
-    RC_TOKEN_IM_MODULE_PATH, RC_TOKEN_IM_MODULE_FILE, RC_TOKEN_STOCK, 
-    RC_TOKEN_LTR, RC_TOKEN_RTL, RC_TOKEN_LAST
-  PRcProperty* = ptr TRcProperty
-  TRcProperty*{.final, pure.} = object 
-    type_name*: TGQuark
-    property_name*: TGQuark
-    origin*: cstring
-    value*: TGValue
-
-  PIconSource* = pointer
-  TRcPropertyParser* = proc (pspec: PGParamSpec, rc_string: PGString, 
-                             property_value: PGValue): gboolean{.cdecl.}
-  TStyle* = object of TGObject
-    fg*: array[0..4, gdk2.TColor]
-    bg*: array[0..4, gdk2.TColor]
-    light*: array[0..4, gdk2.TColor]
-    dark*: array[0..4, gdk2.TColor]
-    mid*: array[0..4, gdk2.TColor]
-    text*: array[0..4, gdk2.TColor]
-    base*: array[0..4, gdk2.TColor]
-    text_aa*: array[0..4, gdk2.TColor]
-    black*: gdk2.TColor
-    white*: gdk2.TColor
-    font_desc*: pango.PFontDescription
-    xthickness*: gint
-    ythickness*: gint
-    fg_gc*: array[0..4, gdk2.PGC]
-    bg_gc*: array[0..4, gdk2.PGC]
-    light_gc*: array[0..4, gdk2.PGC]
-    dark_gc*: array[0..4, gdk2.PGC]
-    mid_gc*: array[0..4, gdk2.PGC]
-    text_gc*: array[0..4, gdk2.PGC]
-    base_gc*: array[0..4, gdk2.PGC]
-    text_aa_gc*: array[0..4, gdk2.PGC]
-    black_gc*: gdk2.PGC
-    white_gc*: gdk2.PGC
-    bg_pixmap*: array[0..4, gdk2.PPixmap]
-    attach_count*: gint
-    depth*: gint
-    colormap*: gdk2.PColormap
-    private_font*: gdk2.PFont
-    private_font_desc*: pango.PFontDescription
-    rc_style*: PRcStyle
-    styles*: PGSList
-    property_cache*: PGArray
-    icon_factories*: PGSList
-
-  PStyleClass* = ptr TStyleClass
-  TStyleClass* = object of TGObjectClass
-    realize*: proc (style: PStyle){.cdecl.}
-    unrealize*: proc (style: PStyle){.cdecl.}
-    copy*: proc (style: PStyle, src: PStyle){.cdecl.}
-    clone*: proc (style: PStyle): PStyle{.cdecl.}
-    init_from_rc*: proc (style: PStyle, rc_style: PRcStyle){.cdecl.}
-    set_background*: proc (style: PStyle, window: gdk2.PWindow, 
-                           state_type: TStateType){.cdecl.}
-    render_icon*: proc (style: PStyle, source: PIconSource, 
-                        direction: TTextDirection, state: TStateType, 
-                        size: TIconSize, widget: PWidget, detail: cstring): gdk2pixbuf.PPixbuf{.
-        cdecl.}
-    draw_hline*: proc (style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, area: gdk2.PRectangle, 
-                       widget: PWidget, detail: cstring, x1: gint, x2: gint, 
-                       y: gint){.cdecl.}
-    draw_vline*: proc (style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, area: gdk2.PRectangle, 
-                       widget: PWidget, detail: cstring, y1: gint, y2: gint, 
-                       x: gint){.cdecl.}
-    draw_shadow*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, shadow_type: TShadowType, 
-                        area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                        x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_polygon*: proc (style: PStyle, window: gdk2.PWindow, 
-                         state_type: TStateType, shadow_type: TShadowType, 
-                         area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                         point: gdk2.PPoint, npoints: gint, fill: gboolean){.cdecl.}
-    draw_arrow*: proc (style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, shadow_type: TShadowType, 
-                       area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                       arrow_type: TArrowType, fill: gboolean, x: gint, y: gint, 
-                       width: gint, height: gint){.cdecl.}
-    draw_diamond*: proc (style: PStyle, window: gdk2.PWindow, 
-                         state_type: TStateType, shadow_type: TShadowType, 
-                         area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                         x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_string*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, area: gdk2.PRectangle, 
-                        widget: PWidget, detail: cstring, x: gint, y: gint, 
-                        `string`: cstring){.cdecl.}
-    draw_box*: proc (style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                     shadow_type: TShadowType, area: gdk2.PRectangle, 
-                     widget: PWidget, detail: cstring, x: gint, y: gint, 
-                     width: gint, height: gint){.cdecl.}
-    draw_flat_box*: proc (style: PStyle, window: gdk2.PWindow, 
-                          state_type: TStateType, shadow_type: TShadowType, 
-                          area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                          x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_check*: proc (style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, shadow_type: TShadowType, 
-                       area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                       x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_option*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, shadow_type: TShadowType, 
-                        area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                        x: gint, y: gint, width: gint, height: gint){.cdecl.}
-    draw_tab*: proc (style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                     shadow_type: TShadowType, area: gdk2.PRectangle, 
-                     widget: PWidget, detail: cstring, x: gint, y: gint, 
-                     width: gint, height: gint){.cdecl.}
-    draw_shadow_gap*: proc (style: PStyle, window: gdk2.PWindow, 
-                            state_type: TStateType, shadow_type: TShadowType, 
-                            area: gdk2.PRectangle, widget: PWidget, 
-                            detail: cstring, x: gint, y: gint, width: gint, 
-                            height: gint, gap_side: TPositionType, gap_x: gint, 
-                            gap_width: gint){.cdecl.}
-    draw_box_gap*: proc (style: PStyle, window: gdk2.PWindow, 
-                         state_type: TStateType, shadow_type: TShadowType, 
-                         area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                         x: gint, y: gint, width: gint, height: gint, 
-                         gap_side: TPositionType, gap_x: gint, gap_width: gint){.
-        cdecl.}
-    draw_extension*: proc (style: PStyle, window: gdk2.PWindow, 
-                           state_type: TStateType, shadow_type: TShadowType, 
-                           area: gdk2.PRectangle, widget: PWidget, 
-                           detail: cstring, x: gint, y: gint, width: gint, 
-                           height: gint, gap_side: TPositionType){.cdecl.}
-    draw_focus*: proc (style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, area: gdk2.PRectangle, 
-                       widget: PWidget, detail: cstring, x: gint, y: gint, 
-                       width: gint, height: gint){.cdecl.}
-    draw_slider*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, shadow_type: TShadowType, 
-                        area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                        x: gint, y: gint, width: gint, height: gint, 
-                        orientation: TOrientation){.cdecl.}
-    draw_handle*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, shadow_type: TShadowType, 
-                        area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                        x: gint, y: gint, width: gint, height: gint, 
-                        orientation: TOrientation){.cdecl.}
-    draw_expander*: proc (style: PStyle, window: gdk2.PWindow, 
-                          state_type: TStateType, area: gdk2.PRectangle, 
-                          widget: PWidget, detail: cstring, x: gint, y: gint, 
-                          expander_style: TExpanderStyle){.cdecl.}
-    draw_layout*: proc (style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, use_text: gboolean, 
-                        area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                        x: gint, y: gint, layout: pango.PLayout){.cdecl.}
-    draw_resize_grip*: proc (style: PStyle, window: gdk2.PWindow, 
-                             state_type: TStateType, area: gdk2.PRectangle, 
-                             widget: PWidget, detail: cstring, 
-                             edge: gdk2.TWindowEdge, x: gint, y: gint, 
-                             width: gint, height: gint){.cdecl.}
-    reserved381: proc (){.cdecl.}
-    reserved382: proc (){.cdecl.}
-    reserved383: proc (){.cdecl.}
-    reserved384: proc (){.cdecl.}
-    reserved385: proc (){.cdecl.}
-    reserved386: proc (){.cdecl.}
-    reserved387: proc (){.cdecl.}
-    reserved388: proc (){.cdecl.}
-    reserved389: proc (){.cdecl.}
-    reserved3810: proc (){.cdecl.}
-    reserved3811: proc (){.cdecl.}
-    reserved3812: proc (){.cdecl.}
-
-  PBorder* = ptr TBorder
-  TBorder*{.final, pure.} = object 
-    left*: gint
-    right*: gint
-    top*: gint
-    bottom*: gint
-
-  PRangeLayout* = pointer
-  PRangeStepTimer* = pointer
-  PRange* = ptr TRange
-  TRange* = object of TWidget
-    adjustment*: PAdjustment
-    update_policy*: TUpdateType
-    Range_flag0*: guint16
-    min_slider_size*: gint
-    orientation*: TOrientation
-    range_rect*: gdk2.TRectangle
-    slider_start*: gint
-    slider_end*: gint
-    round_digits*: gint
-    flag1*: guint16
-    layout*: PRangeLayout
-    timer*: PRangeStepTimer
-    slide_initial_slider_position*: gint
-    slide_initial_coordinate*: gint
-    update_timeout_id*: guint
-    event_window*: gdk2.PWindow
-
-  PRangeClass* = ptr TRangeClass
-  TRangeClass* = object of TWidgetClass
-    slider_detail*: cstring
-    stepper_detail*: cstring
-    value_changed*: proc (range: PRange){.cdecl.}
-    adjust_bounds*: proc (range: PRange, new_value: gdouble){.cdecl.}
-    move_slider*: proc (range: PRange, scroll: TScrollType){.cdecl.}
-    get_range_border*: proc (range: PRange, border: PBorder){.cdecl.}
-    reserved401: proc (){.cdecl.}
-    reserved402: proc (){.cdecl.}
-    reserved403: proc (){.cdecl.}
-    reserved404: proc (){.cdecl.}
-
-  PScale* = ptr TScale
-  TScale* = object of TRange
-    digits*: gint
-    Scale_flag0*: guint16
-
-  PScaleClass* = ptr TScaleClass
-  TScaleClass* = object of TRangeClass
-    format_value*: proc (scale: PScale, value: gdouble): cstring{.cdecl.}
-    draw_value*: proc (scale: PScale){.cdecl.}
-    reserved411: proc (){.cdecl.}
-    reserved412: proc (){.cdecl.}
-    reserved413: proc (){.cdecl.}
-    reserved414: proc (){.cdecl.}
-
-  PHScale* = ptr THScale
-  THScale* = object of TScale
-  PHScaleClass* = ptr THScaleClass
-  THScaleClass* = object of TScaleClass
-  PScrollbar* = ptr TScrollbar
-  TScrollbar* = object of TRange
-  PScrollbarClass* = ptr TScrollbarClass
-  TScrollbarClass* = object of TRangeClass
-    reserved421: proc (){.cdecl.}
-    reserved422: proc (){.cdecl.}
-    reserved423: proc (){.cdecl.}
-    reserved424: proc (){.cdecl.}
-
-  PHScrollbar* = ptr THScrollbar
-  THScrollbar* = object of TScrollbar
-  PHScrollbarClass* = ptr THScrollbarClass
-  THScrollbarClass* = object of TScrollbarClass
-  PSeparator* = ptr TSeparator
-  TSeparator* = object of TWidget
-  PSeparatorClass* = ptr TSeparatorClass
-  TSeparatorClass* = object of TWidgetClass
-  PHSeparator* = ptr THSeparator
-  THSeparator* = object of TSeparator
-  PHSeparatorClass* = ptr THSeparatorClass
-  THSeparatorClass* = object of TSeparatorClass
-  PIconFactory* = ptr TIconFactory
-  TIconFactory* = object of TGObject
-    icons*: PGHashTable
-
-  PIconFactoryClass* = ptr TIconFactoryClass
-  TIconFactoryClass* = object of TGObjectClass
-    reserved431: proc (){.cdecl.}
-    reserved432: proc (){.cdecl.}
-    reserved433: proc (){.cdecl.}
-    reserved434: proc (){.cdecl.}
-
-  PIconSet* = pointer
-  PImagePixmapData* = ptr TImagePixmapData
-  TImagePixmapData*{.final, pure.} = object 
-    pixmap*: gdk2.PPixmap
-
-  PImageImageData* = ptr TImageImageData
-  TImageImageData*{.final, pure.} = object 
-    image*: gdk2.PImage
-
-  PImagePixbufData* = ptr TImagePixbufData
-  TImagePixbufData*{.final, pure.} = object 
-    pixbuf*: gdk2pixbuf.PPixbuf
-
-  PImageStockData* = ptr TImageStockData
-  TImageStockData*{.final, pure.} = object 
-    stock_id*: cstring
-
-  PImageIconSetData* = ptr TImageIconSetData
-  TImageIconSetData*{.final, pure.} = object 
-    icon_set*: PIconSet
-
-  PImageAnimationData* = ptr TImageAnimationData
-  TImageAnimationData*{.final, pure.} = object 
-    anim*: gdk2pixbuf.PPixbufAnimation
-    iter*: gdk2pixbuf.PPixbufAnimationIter
-    frame_timeout*: guint
-
-  PImageType* = ptr TImageType
-  TImageType* = enum 
-    IMAGE_EMPTY, IMAGE_PIXMAP, IMAGE_IMAGE, IMAGE_PIXBUF, IMAGE_STOCK, 
-    IMAGE_ICON_SET, IMAGE_ANIMATION
-  PImage* = ptr TImage
-  TImage* = object of TMisc
-    storage_type*: TImageType
-    pixmap*: TImagePixmapData
-    mask*: gdk2.PBitmap
-    icon_size*: TIconSize
-
-  PImageClass* = ptr TImageClass
-  TImageClass* = object of TMiscClass
-    reserved441: proc (){.cdecl.}
-    reserved442: proc (){.cdecl.}
-    reserved443: proc (){.cdecl.}
-    reserved444: proc (){.cdecl.}
-
-  PImageMenuItem* = ptr TImageMenuItem
-  TImageMenuItem* = object of TMenuItem
-    image*: PWidget
-
-  PImageMenuItemClass* = ptr TImageMenuItemClass
-  TImageMenuItemClass* = object of TMenuItemClass
-  PIMContextSimple* = ptr TIMContextSimple
-  TIMContextSimple* = object of TIMContext
-    tables*: PGSList
-    compose_buffer*: array[0..(MAX_COMPOSE_LEN + 1) - 1, guint]
-    tentative_match*: gunichar
-    tentative_match_len*: gint
-    IMContextSimple_flag0*: guint16
-
-  PIMContextSimpleClass* = ptr TIMContextSimpleClass
-  TIMContextSimpleClass* = object of TIMContextClass
-  PIMMulticontext* = ptr TIMMulticontext
-  TIMMulticontext* = object of TIMContext
-    slave*: PIMContext
-    client_window*: gdk2.PWindow
-    context_id*: cstring
-
-  PIMMulticontextClass* = ptr TIMMulticontextClass
-  TIMMulticontextClass* = object of TIMContextClass
-    reserved451: proc (){.cdecl.}
-    reserved452: proc (){.cdecl.}
-    reserved453: proc (){.cdecl.}
-    reserved454: proc (){.cdecl.}
-
-  PInputDialog* = ptr TInputDialog
-  TInputDialog* = object of TDialog
-    axis_list*: PWidget
-    axis_listbox*: PWidget
-    mode_optionmenu*: PWidget
-    close_button*: PWidget
-    save_button*: PWidget
-    axis_items*: array[0..(gdk2.AXIS_LAST) - 1, PWidget]
-    current_device*: gdk2.PDevice
-    keys_list*: PWidget
-    keys_listbox*: PWidget
-
-  PInputDialogClass* = ptr TInputDialogClass
-  TInputDialogClass* = object of TDialogClass
-    enable_device*: proc (inputd: PInputDialog, device: gdk2.PDevice){.cdecl.}
-    disable_device*: proc (inputd: PInputDialog, device: gdk2.PDevice){.cdecl.}
-    reserved461: proc (){.cdecl.}
-    reserved462: proc (){.cdecl.}
-    reserved463: proc (){.cdecl.}
-    reserved464: proc (){.cdecl.}
-
-  PInvisible* = ptr TInvisible
-  TInvisible* = object of TWidget
-    has_user_ref_count*: gboolean
-    screen*: gdk2.PScreen
-
-  PInvisibleClass* = ptr TInvisibleClass
-  TInvisibleClass* = object of TWidgetClass
-    reserved701: proc (){.cdecl.}
-    reserved702: proc (){.cdecl.}
-    reserved703: proc (){.cdecl.}
-    reserved704: proc (){.cdecl.}
-
-  TPrintFunc* = proc (func_data: gpointer, str: cstring){.cdecl.}
-  PTranslateFunc* = ptr TTranslateFunc
-  TTranslateFunc* = gchar
-  TItemFactoryCallback* = proc (){.cdecl.}
-  TItemFactoryCallback1* = proc (callback_data: gpointer, 
-                                 callback_action: guint, widget: PWidget){.cdecl.}
-  PItemFactory* = ptr TItemFactory
-  TItemFactory* = object of TObject
-    path*: cstring
-    accel_group*: PAccelGroup
-    widget*: PWidget
-    items*: PGSList
-    translate_func*: TTranslateFunc
-    translate_data*: gpointer
-    translate_notify*: TDestroyNotify
-
-  PItemFactoryClass* = ptr TItemFactoryClass
-  TItemFactoryClass* = object of TObjectClass
-    item_ht*: PGHashTable
-    reserved471: proc (){.cdecl.}
-    reserved472: proc (){.cdecl.}
-    reserved473: proc (){.cdecl.}
-    reserved474: proc (){.cdecl.}
-
-  PItemFactoryEntry* = ptr TItemFactoryEntry
-  TItemFactoryEntry*{.final, pure.} = object 
-    path*: cstring
-    accelerator*: cstring
-    callback*: TItemFactoryCallback
-    callback_action*: guint
-    item_type*: cstring
-    extra_data*: gconstpointer
-
-  PItemFactoryItem* = ptr TItemFactoryItem
-  TItemFactoryItem*{.final, pure.} = object 
-    path*: cstring
-    widgets*: PGSList
-
-  PLayout* = ptr TLayout
-  TLayout* = object of TContainer
-    children*: PGList
-    width*: guint
-    height*: guint
-    hadjustment*: PAdjustment
-    vadjustment*: PAdjustment
-    bin_window*: gdk2.PWindow
-    visibility*: gdk2.TVisibilityState
-    scroll_x*: gint
-    scroll_y*: gint
-    freeze_count*: guint
-
-  PLayoutClass* = ptr TLayoutClass
-  TLayoutClass* = object of TContainerClass
-    set_scroll_adjustments*: proc (layout: PLayout, hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-    reserved481: proc (){.cdecl.}
-    reserved482: proc (){.cdecl.}
-    reserved483: proc (){.cdecl.}
-    reserved484: proc (){.cdecl.}
-
-  PList* = ptr TList
-  TList* = object of TContainer
-    children*: PGList
-    selection*: PGList
-    undo_selection*: PGList
-    undo_unselection*: PGList
-    last_focus_child*: PWidget
-    undo_focus_child*: PWidget
-    htimer*: guint
-    vtimer*: guint
-    anchor*: gint
-    drag_pos*: gint
-    anchor_state*: TStateType
-    List_flag0*: guint16
-
-  PListClass* = ptr TListClass
-  TListClass* = object of TContainerClass
-    selection_changed*: proc (list: PList){.cdecl.}
-    select_child*: proc (list: PList, child: PWidget){.cdecl.}
-    unselect_child*: proc (list: PList, child: PWidget){.cdecl.}
-
-  TTreeModelForeachFunc* = proc (model: PTreeModel, path: PTreePath, 
-                                 iter: PTreeIter, data: gpointer): gboolean{.
-      cdecl.}
-  PTreeModelFlags* = ptr TTreeModelFlags
-  TTreeModelFlags* = int32
-  TTreeIter*{.final, pure.} = object 
-    stamp*: gint
-    user_data*: gpointer
-    user_data2*: gpointer
-    user_data3*: gpointer
-
-  PTreeModelIface* = ptr TTreeModelIface
-  TTreeModelIface* = object of TGTypeInterface
-    row_changed*: proc (tree_model: PTreeModel, path: PTreePath, iter: PTreeIter){.
-        cdecl.}
-    row_inserted*: proc (tree_model: PTreeModel, path: PTreePath, 
-                         iter: PTreeIter){.cdecl.}
-    row_has_child_toggled*: proc (tree_model: PTreeModel, path: PTreePath, 
-                                  iter: PTreeIter){.cdecl.}
-    row_deleted*: proc (tree_model: PTreeModel, path: PTreePath){.cdecl.}
-    rows_reordered*: proc (tree_model: PTreeModel, path: PTreePath, 
-                           iter: PTreeIter, new_order: Pgint){.cdecl.}
-    get_flags*: proc (tree_model: PTreeModel): TTreeModelFlags{.cdecl.}
-    get_n_columns*: proc (tree_model: PTreeModel): gint{.cdecl.}
-    get_column_type*: proc (tree_model: PTreeModel, index: gint): GType{.cdecl.}
-    get_iter*: proc (tree_model: PTreeModel, iter: PTreeIter, path: PTreePath): gboolean{.
-        cdecl.}
-    get_path*: proc (tree_model: PTreeModel, iter: PTreeIter): PTreePath{.cdecl.}
-    get_value*: proc (tree_model: PTreeModel, iter: PTreeIter, column: gint, 
-                      value: PGValue){.cdecl.}
-    iter_next*: proc (tree_model: PTreeModel, iter: PTreeIter): gboolean{.cdecl.}
-    iter_children*: proc (tree_model: PTreeModel, iter: PTreeIter, 
-                          parent: PTreeIter): gboolean{.cdecl.}
-    iter_has_child*: proc (tree_model: PTreeModel, iter: PTreeIter): gboolean{.
-        cdecl.}
-    iter_n_children*: proc (tree_model: PTreeModel, iter: PTreeIter): gint{.
-        cdecl.}
-    iter_nth_child*: proc (tree_model: PTreeModel, iter: PTreeIter, 
-                           parent: PTreeIter, n: gint): gboolean{.cdecl.}
-    iter_parent*: proc (tree_model: PTreeModel, iter: PTreeIter, 
-                        child: PTreeIter): gboolean{.cdecl.}
-    ref_node*: proc (tree_model: PTreeModel, iter: PTreeIter){.cdecl.}
-    unref_node*: proc (tree_model: PTreeModel, iter: PTreeIter){.cdecl.}
-
-  PTreeSortable* = pointer
-  TTreeIterCompareFunc* = proc (model: PTreeModel, a: PTreeIter, b: PTreeIter, 
-                                user_data: gpointer): gint{.cdecl.}
-  PTreeSortableIface* = ptr TTreeSortableIface
-  TTreeSortableIface* = object of TGTypeInterface
-    sort_column_changed*: proc (sortable: PTreeSortable){.cdecl.}
-    get_sort_column_id*: proc (sortable: PTreeSortable, sort_column_id: Pgint, 
-                               order: PSortType): gboolean{.cdecl.}
-    set_sort_column_id*: proc (sortable: PTreeSortable, sort_column_id: gint, 
-                               order: TSortType){.cdecl.}
-    set_sort_func*: proc (sortable: PTreeSortable, sort_column_id: gint, 
-                          func: TTreeIterCompareFunc, data: gpointer, 
-                          destroy: TDestroyNotify){.cdecl.}
-    set_default_sort_func*: proc (sortable: PTreeSortable, 
-                                  func: TTreeIterCompareFunc, data: gpointer, 
-                                  destroy: TDestroyNotify){.cdecl.}
-    has_default_sort_func*: proc (sortable: PTreeSortable): gboolean{.cdecl.}
-
-  PTreeModelSort* = ptr TTreeModelSort
-  TTreeModelSort* = object of TGObject
-    root*: gpointer
-    stamp*: gint
-    child_flags*: guint
-    child_model*: PTreeModel
-    zero_ref_count*: gint
-    sort_list*: PGList
-    sort_column_id*: gint
-    order*: TSortType
-    default_sort_func*: TTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TDestroyNotify
-    changed_id*: guint
-    inserted_id*: guint
-    has_child_toggled_id*: guint
-    deleted_id*: guint
-    reordered_id*: guint
-
-  PTreeModelSortClass* = ptr TTreeModelSortClass
-  TTreeModelSortClass* = object of TGObjectClass
-    reserved491: proc (){.cdecl.}
-    reserved492: proc (){.cdecl.}
-    reserved493: proc (){.cdecl.}
-    reserved494: proc (){.cdecl.}
-
-  PListStore* = ptr TListStore
-  TListStore* = object of TGObject
-    stamp*: gint
-    root*: gpointer
-    tail*: gpointer
-    sort_list*: PGList
-    n_columns*: gint
-    sort_column_id*: gint
-    order*: TSortType
-    column_headers*: PGType
-    length*: gint
-    default_sort_func*: TTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TDestroyNotify
-    ListStore_flag0*: guint16
-
-  PListStoreClass* = ptr TListStoreClass
-  TListStoreClass* = object of TGObjectClass
-    reserved501: proc (){.cdecl.}
-    reserved502: proc (){.cdecl.}
-    reserved503: proc (){.cdecl.}
-    reserved504: proc (){.cdecl.}
-
-  TModuleInitFunc* = proc (argc: Pgint, argv: PPPgchar){.cdecl.}
-  TKeySnoopFunc* = proc (grab_widget: PWidget, event: gdk2.PEventKey, 
-                         func_data: gpointer): gint{.cdecl.}
-  PMenuBar* = ptr TMenuBar
-  TMenuBar* = object of TMenuShell
-  PMenuBarClass* = ptr TMenuBarClass
-  TMenuBarClass* = object of TMenuShellClass
-    reserved511: proc (){.cdecl.}
-    reserved512: proc (){.cdecl.}
-    reserved513: proc (){.cdecl.}
-    reserved514: proc (){.cdecl.}
-
-  PMessageType* = ptr TMessageType
-  TMessageType* = enum 
-    MESSAGE_INFO, MESSAGE_WARNING, MESSAGE_QUESTION, MESSAGE_ERROR
-  PButtonsType* = ptr TButtonsType
-  TButtonsType* = enum 
-    BUTTONS_NONE, BUTTONS_OK, BUTTONS_CLOSE, BUTTONS_CANCEL, BUTTONS_YES_NO, 
-    BUTTONS_OK_CANCEL
-  PMessageDialog* = ptr TMessageDialog
-  TMessageDialog* = object of TDialog
-    image*: PWidget
-    label*: PWidget
-
-  PMessageDialogClass* = ptr TMessageDialogClass
-  TMessageDialogClass* = object of TDialogClass
-    reserved521: proc (){.cdecl.}
-    reserved522: proc (){.cdecl.}
-    reserved523: proc (){.cdecl.}
-    reserved524: proc (){.cdecl.}
-
-  PNotebookPage* = pointer
-  PNotebookTab* = ptr TNotebookTab
-  TNotebookTab* = enum 
-    NOTEBOOK_TAB_FIRST, NOTEBOOK_TAB_LAST
-  PNotebook* = ptr TNotebook
-  TNotebook* = object of TContainer
-    cur_page*: PNotebookPage
-    children*: PGList
-    first_tab*: PGList
-    focus_tab*: PGList
-    menu*: PWidget
-    event_window*: gdk2.PWindow
-    timer*: guint32
-    tab_hborder*: guint16
-    tab_vborder*: guint16
-    Notebook_flag0*: guint16
-
-  PNotebookClass* = ptr TNotebookClass
-  TNotebookClass* = object of TContainerClass
-    switch_page*: proc (notebook: PNotebook, page: PNotebookPage, 
-                        page_num: guint){.cdecl.}
-    select_page*: proc (notebook: PNotebook, move_focus: gboolean): gboolean{.
-        cdecl.}
-    focus_tab*: proc (notebook: PNotebook, thetype: TNotebookTab): gboolean{.
-        cdecl.}
-    change_current_page*: proc (notebook: PNotebook, offset: gint){.cdecl.}
-    move_focus_out*: proc (notebook: PNotebook, direction: TDirectionType){.
-        cdecl.}
-    reserved531: proc (){.cdecl.}
-    reserved532: proc (){.cdecl.}
-    reserved533: proc (){.cdecl.}
-    reserved534: proc (){.cdecl.}
-
-  POldEditable* = ptr TOldEditable
-  TOldEditable* = object of TWidget
-    current_pos*: guint
-    selection_start_pos*: guint
-    selection_end_pos*: guint
-    OldEditable_flag0*: guint16
-    clipboard_text*: cstring
-
-  TTextFunction* = proc (editable: POldEditable, time: guint32){.cdecl.}
-  POldEditableClass* = ptr TOldEditableClass
-  TOldEditableClass* = object of TWidgetClass
-    activate*: proc (editable: POldEditable){.cdecl.}
-    set_editable*: proc (editable: POldEditable, is_editable: gboolean){.cdecl.}
-    move_cursor*: proc (editable: POldEditable, x: gint, y: gint){.cdecl.}
-    move_word*: proc (editable: POldEditable, n: gint){.cdecl.}
-    move_page*: proc (editable: POldEditable, x: gint, y: gint){.cdecl.}
-    move_to_row*: proc (editable: POldEditable, row: gint){.cdecl.}
-    move_to_column*: proc (editable: POldEditable, row: gint){.cdecl.}
-    kill_char*: proc (editable: POldEditable, direction: gint){.cdecl.}
-    kill_word*: proc (editable: POldEditable, direction: gint){.cdecl.}
-    kill_line*: proc (editable: POldEditable, direction: gint){.cdecl.}
-    cut_clipboard*: proc (editable: POldEditable){.cdecl.}
-    copy_clipboard*: proc (editable: POldEditable){.cdecl.}
-    paste_clipboard*: proc (editable: POldEditable){.cdecl.}
-    update_text*: proc (editable: POldEditable, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    get_chars*: proc (editable: POldEditable, start_pos: gint, end_pos: gint): cstring{.
-        cdecl.}
-    set_selection*: proc (editable: POldEditable, start_pos: gint, end_pos: gint){.
-        cdecl.}
-    set_position*: proc (editable: POldEditable, position: gint){.cdecl.}
-
-  POptionMenu* = ptr TOptionMenu
-  TOptionMenu* = object of TButton
-    menu*: PWidget
-    menu_item*: PWidget
-    width*: guint16
-    height*: guint16
-
-  POptionMenuClass* = ptr TOptionMenuClass
-  TOptionMenuClass* = object of TButtonClass
-    changed*: proc (option_menu: POptionMenu){.cdecl.}
-    reserved541: proc (){.cdecl.}
-    reserved542: proc (){.cdecl.}
-    reserved543: proc (){.cdecl.}
-    reserved544: proc (){.cdecl.}
-
-  PPixmap* = ptr TPixmap
-  TPixmap* = object of TMisc
-    pixmap*: gdk2.PPixmap
-    mask*: gdk2.PBitmap
-    pixmap_insensitive*: gdk2.PPixmap
-    Pixmap_flag0*: guint16
-
-  PPixmapClass* = ptr TPixmapClass
-  TPixmapClass* = object of TMiscClass
-  PPlug* = ptr TPlug
-  TPlug* = object of TWindow
-    socket_window*: gdk2.PWindow
-    modality_window*: PWidget
-    modality_group*: PWindowGroup
-    grabbed_keys*: PGHashTable
-    Plug_flag0*: guint16
-
-  PPlugClass* = ptr TPlugClass
-  TPlugClass* = object of TWindowClass
-    embedded*: proc (plug: PPlug){.cdecl.}
-    reserved551: proc (){.cdecl.}
-    reserved552: proc (){.cdecl.}
-    reserved553: proc (){.cdecl.}
-    reserved554: proc (){.cdecl.}
-
-  PPreview* = ptr TPreview
-  TPreview* = object of TWidget
-    buffer*: Pguchar
-    buffer_width*: guint16
-    buffer_height*: guint16
-    bpp*: guint16
-    rowstride*: guint16
-    dither*: gdk2.TRgbDither
-    Preview_flag0*: guint16
-
-  PPreviewInfo* = ptr TPreviewInfo
-  TPreviewInfo*{.final, pure.} = object 
-    lookup*: Pguchar
-    gamma*: gdouble
-
-  PDitherInfo* = ptr TDitherInfo
-  TDitherInfo*{.final, pure.} = object 
-    c*: array[0..3, guchar]
-
-  PPreviewClass* = ptr TPreviewClass
-  TPreviewClass* = object of TWidgetClass
-    info*: TPreviewInfo
-
-  PProgress* = ptr TProgress
-  TProgress* = object of TWidget
-    adjustment*: PAdjustment
-    offscreen_pixmap*: gdk2.PPixmap
-    format*: cstring
-    x_align*: gfloat
-    y_align*: gfloat
-    Progress_flag0*: guint16
-
-  PProgressClass* = ptr TProgressClass
-  TProgressClass* = object of TWidgetClass
-    paint*: proc (progress: PProgress){.cdecl.}
-    update*: proc (progress: PProgress){.cdecl.}
-    act_mode_enter*: proc (progress: PProgress){.cdecl.}
-    reserved561: proc (){.cdecl.}
-    reserved562: proc (){.cdecl.}
-    reserved563: proc (){.cdecl.}
-    reserved564: proc (){.cdecl.}
-
-  PProgressBarStyle* = ptr TProgressBarStyle
-  TProgressBarStyle* = enum 
-    PROGRESS_CONTINUOUS, PROGRESS_DISCRETE
-  PProgressBarOrientation* = ptr TProgressBarOrientation
-  TProgressBarOrientation* = enum 
-    PROGRESS_LEFT_TO_RIGHT, PROGRESS_RIGHT_TO_LEFT, PROGRESS_BOTTOM_TO_TOP, 
-    PROGRESS_TOP_TO_BOTTOM
-  PProgressBar* = ptr TProgressBar
-  TProgressBar* = object of TProgress
-    bar_style*: TProgressBarStyle
-    orientation*: TProgressBarOrientation
-    blocks*: guint
-    in_block*: gint
-    activity_pos*: gint
-    activity_step*: guint
-    activity_blocks*: guint
-    pulse_fraction*: gdouble
-    ProgressBar_flag0*: guint16
-
-  PProgressBarClass* = ptr TProgressBarClass
-  TProgressBarClass* = object of TProgressClass
-    reserved571: proc (){.cdecl.}
-    reserved572: proc (){.cdecl.}
-    reserved573: proc (){.cdecl.}
-    reserved574: proc (){.cdecl.}
-
-  PRadioButton* = ptr TRadioButton
-  TRadioButton* = object of TCheckButton
-    group*: PGSList
-
-  PRadioButtonClass* = ptr TRadioButtonClass
-  TRadioButtonClass* = object of TCheckButtonClass
-    reserved581: proc (){.cdecl.}
-    reserved582: proc (){.cdecl.}
-    reserved583: proc (){.cdecl.}
-    reserved584: proc (){.cdecl.}
-
-  PRadioMenuItem* = ptr TRadioMenuItem
-  TRadioMenuItem* = object of TCheckMenuItem
-    group*: PGSList
-
-  PRadioMenuItemClass* = ptr TRadioMenuItemClass
-  TRadioMenuItemClass* = object of TCheckMenuItemClass
-    reserved591: proc (){.cdecl.}
-    reserved592: proc (){.cdecl.}
-    reserved593: proc (){.cdecl.}
-    reserved594: proc (){.cdecl.}
-
-  PScrolledWindow* = ptr TScrolledWindow
-  TScrolledWindow* = object of TBin
-    hscrollbar*: PWidget
-    vscrollbar*: PWidget
-    ScrolledWindow_flag0*: guint16
-    shadow_type*: guint16
-
-  PScrolledWindowClass* = ptr TScrolledWindowClass
-  TScrolledWindowClass* = object of TBinClass
-    scrollbar_spacing*: gint
-    scroll_child*: proc (scrolled_window: PScrolledWindow, scroll: TScrollType, 
-                         horizontal: gboolean){.cdecl.}
-    move_focus_out*: proc (scrolled_window: PScrolledWindow, 
-                           direction: TDirectionType){.cdecl.}
-    reserved601: proc (){.cdecl.}
-    reserved602: proc (){.cdecl.}
-    reserved603: proc (){.cdecl.}
-    reserved604: proc (){.cdecl.}
-
-  TSelectionData*{.final, pure.} = object 
-    selection*: gdk2.TAtom
-    target*: gdk2.TAtom
-    thetype*: gdk2.TAtom
-    format*: gint
-    data*: Pguchar
-    length*: gint
-    display*: gdk2.PDisplay
-
-  PTargetEntry* = ptr TTargetEntry
-  TTargetEntry*{.final, pure.} = object 
-    target*: cstring
-    flags*: guint
-    info*: guint
-
-  PTargetList* = ptr TTargetList
-  TTargetList*{.final, pure.} = object 
-    list*: PGList
-    ref_count*: guint
-
-  PTargetPair* = ptr TTargetPair
-  TTargetPair*{.final, pure.} = object 
-    target*: gdk2.TAtom
-    flags*: guint
-    info*: guint
-
-  PSeparatorMenuItem* = ptr TSeparatorMenuItem
-  TSeparatorMenuItem* = object of TMenuItem
-  PSeparatorMenuItemClass* = ptr TSeparatorMenuItemClass
-  TSeparatorMenuItemClass* = object of TMenuItemClass
-  PSizeGroup* = ptr TSizeGroup
-  TSizeGroup* = object of TGObject
-    widgets*: PGSList
-    mode*: guint8
-    SizeGroup_flag0*: guint16
-    requisition*: TRequisition
-
-  PSizeGroupClass* = ptr TSizeGroupClass
-  TSizeGroupClass* = object of TGObjectClass
-    reserved611: proc (){.cdecl.}
-    reserved612: proc (){.cdecl.}
-    reserved613: proc (){.cdecl.}
-    reserved614: proc (){.cdecl.}
-
-  PSizeGroupMode* = ptr TSizeGroupMode
-  TSizeGroupMode* = enum 
-    SIZE_GROUP_NONE, SIZE_GROUP_HORIZONTAL, SIZE_GROUP_VERTICAL, SIZE_GROUP_BOTH
-  PSocket* = ptr TSocket
-  TSocket* = object of TContainer
-    request_width*: guint16
-    request_height*: guint16
-    current_width*: guint16
-    current_height*: guint16
-    plug_window*: gdk2.PWindow
-    plug_widget*: PWidget
-    xembed_version*: gshort
-    Socket_flag0*: guint16
-    accel_group*: PAccelGroup
-    toplevel*: PWidget
-
-  PSocketClass* = ptr TSocketClass
-  TSocketClass* = object of TContainerClass
-    plug_added*: proc (socket: PSocket){.cdecl.}
-    plug_removed*: proc (socket: PSocket): gboolean{.cdecl.}
-    reserved621: proc (){.cdecl.}
-    reserved622: proc (){.cdecl.}
-    reserved623: proc (){.cdecl.}
-    reserved624: proc (){.cdecl.}
-
-  PSpinButtonUpdatePolicy* = ptr TSpinButtonUpdatePolicy
-  TSpinButtonUpdatePolicy* = enum 
-    UPDATE_ALWAYS, UPDATE_IF_VALID
-  PSpinType* = ptr TSpinType
-  TSpinType* = enum 
-    SPIN_STEP_FORWARD, SPIN_STEP_BACKWARD, SPIN_PAGE_FORWARD, 
-    SPIN_PAGE_BACKWARD, SPIN_HOME, SPIN_END, SPIN_USER_DEFINED
-  PSpinButton* = ptr TSpinButton
-  TSpinButton* = object of TEntry
-    adjustment*: PAdjustment
-    panel*: gdk2.PWindow
-    timer*: guint32
-    climb_rate*: gdouble
-    timer_step*: gdouble
-    update_policy*: TSpinButtonUpdatePolicy
-    SpinButton_flag0*: int32
-
-  PSpinButtonClass* = ptr TSpinButtonClass
-  TSpinButtonClass* = object of TEntryClass
-    input*: proc (spin_button: PSpinButton, new_value: Pgdouble): gint{.cdecl.}
-    output*: proc (spin_button: PSpinButton): gint{.cdecl.}
-    value_changed*: proc (spin_button: PSpinButton){.cdecl.}
-    change_value*: proc (spin_button: PSpinButton, scroll: TScrollType){.cdecl.}
-    reserved631: proc (){.cdecl.}
-    reserved632: proc (){.cdecl.}
-    reserved633: proc (){.cdecl.}
-    reserved634: proc (){.cdecl.}
-
-  PStockItem* = ptr TStockItem
-  TStockItem*{.final, pure.} = object 
-    stock_id*: cstring
-    label*: cstring
-    modifier*: gdk2.TModifierType
-    keyval*: guint
-    translation_domain*: cstring
-
-  PStatusbar* = ptr TStatusbar
-  TStatusbar* = object of THBox
-    frame*: PWidget
-    `label`*: PWidget
-    messages*: PGSList
-    keys*: PGSList
-    seq_context_id*: guint
-    seq_message_id*: guint
-    grip_window*: gdk2.PWindow
-    Statusbar_flag0*: guint16
-
-  PStatusbarClass* = ptr TStatusbarClass
-  TStatusbarClass* = object of THBoxClass
-    messages_mem_chunk*: PGMemChunk
-    text_pushed*: proc (statusbar: PStatusbar, context_id: guint, text: cstring){.
-        cdecl.}
-    text_popped*: proc (statusbar: PStatusbar, context_id: guint, text: cstring){.
-        cdecl.}
-    reserved641: proc (){.cdecl.}
-    reserved642: proc (){.cdecl.}
-    reserved643: proc (){.cdecl.}
-    reserved644: proc (){.cdecl.}
-
-  PTableRowCol* = ptr TTableRowCol
-  PTable* = ptr TTable
-  TTable* = object of TContainer
-    children*: PGList
-    rows*: PTableRowCol
-    cols*: PTableRowCol
-    nrows*: guint16
-    ncols*: guint16
-    column_spacing*: guint16
-    row_spacing*: guint16
-    Table_flag0*: guint16
-
-  PTableClass* = ptr TTableClass
-  TTableClass* = object of TContainerClass
-  PTableChild* = ptr TTableChild
-  TTableChild*{.final, pure.} = object 
-    widget*: PWidget
-    left_attach*: guint16
-    right_attach*: guint16
-    top_attach*: guint16
-    bottom_attach*: guint16
-    xpadding*: guint16
-    ypadding*: guint16
-    TableChild_flag0*: guint16
-
-  TTableRowCol*{.final, pure.} = object 
-    requisition*: guint16
-    allocation*: guint16
-    spacing*: guint16
-    flag0*: guint16
-
-  PTearoffMenuItem* = ptr TTearoffMenuItem
-  TTearoffMenuItem* = object of TMenuItem
-    TearoffMenuItem_flag0*: guint16
-
-  PTearoffMenuItemClass* = ptr TTearoffMenuItemClass
-  TTearoffMenuItemClass* = object of TMenuItemClass
-    reserved651: proc (){.cdecl.}
-    reserved652: proc (){.cdecl.}
-    reserved653: proc (){.cdecl.}
-    reserved654: proc (){.cdecl.}
-
-  PTextFont* = pointer
-  PPropertyMark* = ptr TPropertyMark
-  TPropertyMark*{.final, pure.} = object 
-    `property`*: PGList
-    offset*: guint
-    index*: guint
-
-  PText* = ptr TText
-  TText* = object of TOldEditable
-    text_area*: gdk2.PWindow
-    hadj*: PAdjustment
-    vadj*: PAdjustment
-    gc*: gdk2.PGC
-    line_wrap_bitmap*: gdk2.PPixmap
-    line_arrow_bitmap*: gdk2.PPixmap
-    text*: Pguchar
-    text_len*: guint
-    gap_position*: guint
-    gap_size*: guint
-    text_end*: guint
-    line_start_cache*: PGList
-    first_line_start_index*: guint
-    first_cut_pixels*: guint
-    first_onscreen_hor_pixel*: guint
-    first_onscreen_ver_pixel*: guint
-    Text_flag0*: guint16
-    freeze_count*: guint
-    text_properties*: PGList
-    text_properties_end*: PGList
-    point*: TPropertyMark
-    scratch_buffer*: Pguchar
-    scratch_buffer_len*: guint
-    last_ver_value*: gint
-    cursor_pos_x*: gint
-    cursor_pos_y*: gint
-    cursor_mark*: TPropertyMark
-    cursor_char*: gdk2.TWChar
-    cursor_char_offset*: gchar
-    cursor_virtual_x*: gint
-    cursor_drawn_level*: gint
-    current_line*: PGList
-    tab_stops*: PGList
-    default_tab_width*: gint
-    current_font*: PTextFont
-    timer*: gint
-    button*: guint
-    bg_gc*: gdk2.PGC
-
-  PTextClass* = ptr TTextClass
-  TTextClass* = object of TOldEditableClass
-    set_scroll_adjustments*: proc (text: PText, hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-
-  PTextSearchFlags* = ptr TTextSearchFlags
-  TTextSearchFlags* = int32
-  PTextIter* = ptr TTextIter
-  TTextIter*{.final, pure.} = object 
-    dummy1*: gpointer
-    dummy2*: gpointer
-    dummy3*: gint
-    dummy4*: gint
-    dummy5*: gint
-    dummy6*: gint
-    dummy7*: gint
-    dummy8*: gint
-    dummy9*: gpointer
-    dummy10*: gpointer
-    dummy11*: gint
-    dummy12*: gint
-    dummy13*: gint
-    dummy14*: gpointer
-
-  TTextCharPredicate* = proc (ch: gunichar, user_data: gpointer): gboolean{.
-      cdecl.}
-  PTextTagClass* = ptr TTextTagClass
-  PTextAttributes* = ptr TTextAttributes
-  PTextTag* = ptr TTextTag
-  PPGtkTextTag* = ptr PTextTag
-  TTextTag* = object of TGObject
-    table*: PTextTagTable
-    name*: cstring
-    priority*: int32
-    values*: PTextAttributes
-    TextTag_flag0*: int32
-
-  TTextTagClass* = object of TGObjectClass
-    event*: proc (tag: PTextTag, event_object: PGObject, event: gdk2.PEvent, 
-                  iter: PTextIter): gboolean{.cdecl.}
-    reserved661: proc (){.cdecl.}
-    reserved662: proc (){.cdecl.}
-    reserved663: proc (){.cdecl.}
-    reserved664: proc (){.cdecl.}
-
-  PTextAppearance* = ptr TTextAppearance
-  TTextAppearance*{.final, pure.} = object 
-    bg_color*: gdk2.TColor
-    fg_color*: gdk2.TColor
-    bg_stipple*: gdk2.PBitmap
-    fg_stipple*: gdk2.PBitmap
-    rise*: gint
-    padding1*: gpointer
-    flag0*: guint16
-
-  TTextAttributes*{.final, pure.} = object 
-    refcount*: guint
-    appearance*: TTextAppearance
-    justification*: TJustification
-    direction*: TTextDirection
-    font*: pango.PFontDescription
-    font_scale*: gdouble
-    left_margin*: gint
-    indent*: gint
-    right_margin*: gint
-    pixels_above_lines*: gint
-    pixels_below_lines*: gint
-    pixels_inside_wrap*: gint
-    tabs*: pango.PTabArray
-    wrap_mode*: TWrapMode
-    language*: pango.PLanguage
-    padding1*: gpointer
-    flag0*: guint16
-
-  TTextTagTableForeach* = proc (tag: PTextTag, data: gpointer){.cdecl.}
-  TTextTagTable* = object of TGObject
-    hash*: PGHashTable
-    anonymous*: PGSList
-    anon_count*: gint
-    buffers*: PGSList
-
-  PTextTagTableClass* = ptr TTextTagTableClass
-  TTextTagTableClass* = object of TGObjectClass
-    tag_changed*: proc (table: PTextTagTable, tag: PTextTag, 
-                        size_changed: gboolean){.cdecl.}
-    tag_added*: proc (table: PTextTagTable, tag: PTextTag){.cdecl.}
-    tag_removed*: proc (table: PTextTagTable, tag: PTextTag){.cdecl.}
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PTextMark* = ptr TTextMark
-  TTextMark* = object of TGObject
-    segment*: gpointer
-
-  PTextMarkClass* = ptr TTextMarkClass
-  TTextMarkClass* = object of TGObjectClass
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PTextMarkBody* = ptr TTextMarkBody
-  TTextMarkBody*{.final, pure.} = object 
-    obj*: PTextMark
-    name*: cstring
-    tree*: PTextBTree
-    line*: PTextLine
-    flag0*: guint16
-
-  PTextChildAnchor* = ptr TTextChildAnchor
-  TTextChildAnchor* = object of TGObject
-    segment*: gpointer
-
-  PTextChildAnchorClass* = ptr TTextChildAnchorClass
-  TTextChildAnchorClass* = object of TGObjectClass
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PTextPixbuf* = ptr TTextPixbuf
-  TTextPixbuf*{.final, pure.} = object 
-    pixbuf*: gdk2pixbuf.PPixbuf
-
-  PTextChildBody* = ptr TTextChildBody
-  TTextChildBody*{.final, pure.} = object 
-    obj*: PTextChildAnchor
-    widgets*: PGSList
-    tree*: PTextBTree
-    line*: PTextLine
-
-  PTextLineSegment* = ptr TTextLineSegment
-  PTextLineSegmentClass* = ptr TTextLineSegmentClass
-  PTextTagInfo* = ptr TTextTagInfo
-  TTextTagInfo*{.final, pure.} = object 
-    tag*: PTextTag
-    tag_root*: PTextBTreeNode
-    toggle_count*: gint
-
-  PTextToggleBody* = ptr TTextToggleBody
-  TTextToggleBody*{.final, pure.} = object 
-    info*: PTextTagInfo
-    inNodeCounts*: gboolean
-
-  TTextLineSegment*{.final, pure.} = object 
-    `type`*: PTextLineSegmentClass
-    next*: PTextLineSegment
-    char_count*: int32
-    byte_count*: int32
-    body*: TTextChildBody
-
-  PTextSegSplitFunc* = ptr TTextSegSplitFunc
-  TTextSegSplitFunc* = TTextLineSegment
-  TTextSegDeleteFunc* = proc (seg: PTextLineSegment, line: PTextLine, 
-                              tree_gone: gboolean): gboolean{.cdecl.}
-  PTextSegCleanupFunc* = ptr TTextSegCleanupFunc
-  TTextSegCleanupFunc* = TTextLineSegment
-  TTextSegLineChangeFunc* = proc (seg: PTextLineSegment, line: PTextLine){.cdecl.}
-  TTextSegCheckFunc* = proc (seg: PTextLineSegment, line: PTextLine){.cdecl.}
-  TTextLineSegmentClass*{.final, pure.} = object 
-    name*: cstring
-    leftGravity*: gboolean
-    splitFunc*: TTextSegSplitFunc
-    deleteFunc*: TTextSegDeleteFunc
-    cleanupFunc*: TTextSegCleanupFunc
-    lineChangeFunc*: TTextSegLineChangeFunc
-    checkFunc*: TTextSegCheckFunc
-
-  PTextLineData* = ptr TTextLineData
-  TTextLineData*{.final, pure.} = object 
-    view_id*: gpointer
-    next*: PTextLineData
-    height*: gint
-    flag0*: int32
-
-  TTextLine*{.final, pure.} = object 
-    parent*: PTextBTreeNode
-    next*: PTextLine
-    segments*: PTextLineSegment
-    views*: PTextLineData
-
-  PTextLogAttrCache* = pointer
-  PTextBuffer* = ptr TTextBuffer
-  TTextBuffer* = object of TGObject
-    tag_table*: PTextTagTable
-    btree*: PTextBTree
-    clipboard_contents_buffers*: PGSList
-    selection_clipboards*: PGSList
-    log_attr_cache*: PTextLogAttrCache
-    user_action_count*: guint
-    TextBuffer_flag0*: guint16
-
-  PTextBufferClass* = ptr TTextBufferClass
-  TTextBufferClass* = object of TGObjectClass
-    insert_text*: proc (buffer: PTextBuffer, pos: PTextIter, text: cstring, 
-                        length: gint){.cdecl.}
-    insert_pixbuf*: proc (buffer: PTextBuffer, pos: PTextIter, 
-                          pixbuf: gdk2pixbuf.PPixbuf){.cdecl.}
-    insert_child_anchor*: proc (buffer: PTextBuffer, pos: PTextIter, 
-                                anchor: PTextChildAnchor){.cdecl.}
-    delete_range*: proc (buffer: PTextBuffer, start: PTextIter, 
-                         theEnd: PTextIter){.cdecl.}
-    changed*: proc (buffer: PTextBuffer){.cdecl.}
-    modified_changed*: proc (buffer: PTextBuffer){.cdecl.}
-    mark_set*: proc (buffer: PTextBuffer, location: PTextIter, mark: PTextMark){.
-        cdecl.}
-    mark_deleted*: proc (buffer: PTextBuffer, mark: PTextMark){.cdecl.}
-    apply_tag*: proc (buffer: PTextBuffer, tag: PTextTag, start_char: PTextIter, 
-                      end_char: PTextIter){.cdecl.}
-    remove_tag*: proc (buffer: PTextBuffer, tag: PTextTag, 
-                       start_char: PTextIter, end_char: PTextIter){.cdecl.}
-    begin_user_action*: proc (buffer: PTextBuffer){.cdecl.}
-    end_user_action*: proc (buffer: PTextBuffer){.cdecl.}
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-    reserved5: proc (){.cdecl.}
-    reserved6: proc (){.cdecl.}
-
-  PTextLineDisplay* = ptr TTextLineDisplay
-  PTextLayout* = ptr TTextLayout
-  TTextLayout* = object of TGObject
-    screen_width*: gint
-    width*: gint
-    height*: gint
-    buffer*: PTextBuffer
-    default_style*: PTextAttributes
-    ltr_context*: pango.PContext
-    rtl_context*: pango.PContext
-    one_style_cache*: PTextAttributes
-    one_display_cache*: PTextLineDisplay
-    wrap_loop_count*: gint
-    TextLayout_flag0*: guint16
-    preedit_string*: cstring
-    preedit_attrs*: pango.PAttrList
-    preedit_len*: gint
-    preedit_cursor*: gint
-
-  PTextLayoutClass* = ptr TTextLayoutClass
-  TTextLayoutClass* = object of TGObjectClass
-    invalidated*: proc (layout: PTextLayout){.cdecl.}
-    changed*: proc (layout: PTextLayout, y: gint, old_height: gint, 
-                    new_height: gint){.cdecl.}
-    wrap*: proc (layout: PTextLayout, line: PTextLine, line_data: PTextLineData): PTextLineData{.
-        cdecl.}
-    get_log_attrs*: proc (layout: PTextLayout, line: PTextLine, 
-                          attrs: var pango.PLogAttr, n_attrs: Pgint){.cdecl.}
-    invalidate*: proc (layout: PTextLayout, start: PTextIter, theEnd: PTextIter){.
-        cdecl.}
-    free_line_data*: proc (layout: PTextLayout, line: PTextLine, 
-                           line_data: PTextLineData){.cdecl.}
-    allocate_child*: proc (layout: PTextLayout, child: PWidget, x: gint, y: gint){.
-        cdecl.}
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PTextAttrAppearance* = ptr TTextAttrAppearance
-  TTextAttrAppearance*{.final, pure.} = object 
-    attr*: pango.TAttribute
-    appearance*: TTextAppearance
-
-  PTextCursorDisplay* = ptr TTextCursorDisplay
-  TTextCursorDisplay*{.final, pure.} = object 
-    x*: gint
-    y*: gint
-    height*: gint
-    flag0*: guint16
-
-  TTextLineDisplay*{.final, pure.} = object 
-    layout*: pango.PLayout
-    cursors*: PGSList
-    shaped_objects*: PGSList
-    direction*: TTextDirection
-    width*: gint
-    total_width*: gint
-    height*: gint
-    x_offset*: gint
-    left_margin*: gint
-    right_margin*: gint
-    top_margin*: gint
-    bottom_margin*: gint
-    insert_index*: gint
-    size_only*: gboolean
-    line*: PTextLine
-
-  PTextWindow* = pointer
-  PTextPendingScroll* = pointer
-  PTextWindowType* = ptr TTextWindowType
-  TTextWindowType* = enum 
-    TEXT_WINDOW_PRIVATE, TEXT_WINDOW_WIDGET, TEXT_WINDOW_TEXT, TEXT_WINDOW_LEFT, 
-    TEXT_WINDOW_RIGHT, TEXT_WINDOW_TOP, TEXT_WINDOW_BOTTOM
-  PTextView* = ptr TTextView
-  TTextView* = object of TContainer
-    layout*: PTextLayout
-    buffer*: PTextBuffer
-    selection_drag_handler*: guint
-    scroll_timeout*: guint
-    pixels_above_lines*: gint
-    pixels_below_lines*: gint
-    pixels_inside_wrap*: gint
-    wrap_mode*: TWrapMode
-    justify*: TJustification
-    left_margin*: gint
-    right_margin*: gint
-    indent*: gint
-    tabs*: pango.PTabArray
-    TextView_flag0*: guint16
-    text_window*: PTextWindow
-    left_window*: PTextWindow
-    right_window*: PTextWindow
-    top_window*: PTextWindow
-    bottom_window*: PTextWindow
-    hadjustment*: PAdjustment
-    vadjustment*: PAdjustment
-    xoffset*: gint
-    yoffset*: gint
-    width*: gint
-    height*: gint
-    virtual_cursor_x*: gint
-    virtual_cursor_y*: gint
-    first_para_mark*: PTextMark
-    first_para_pixels*: gint
-    dnd_mark*: PTextMark
-    blink_timeout*: guint
-    first_validate_idle*: guint
-    incremental_validate_idle*: guint
-    im_context*: PIMContext
-    popup_menu*: PWidget
-    drag_start_x*: gint
-    drag_start_y*: gint
-    children*: PGSList
-    pending_scroll*: PTextPendingScroll
-    pending_place_cursor_button*: gint
-
-  PTextViewClass* = ptr TTextViewClass
-  TTextViewClass* = object of TContainerClass
-    set_scroll_adjustments*: proc (text_view: PTextView, 
-                                   hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-    populate_popup*: proc (text_view: PTextView, menu: PMenu){.cdecl.}
-    move_cursor*: proc (text_view: PTextView, step: TMovementStep, count: gint, 
-                        extend_selection: gboolean){.cdecl.}
-    page_horizontally*: proc (text_view: PTextView, count: gint, 
-                              extend_selection: gboolean){.cdecl.}
-    set_anchor*: proc (text_view: PTextView){.cdecl.}
-    insert_at_cursor*: proc (text_view: PTextView, str: cstring){.cdecl.}
-    delete_from_cursor*: proc (text_view: PTextView, thetype: TDeleteType, 
-                               count: gint){.cdecl.}
-    cut_clipboard*: proc (text_view: PTextView){.cdecl.}
-    copy_clipboard*: proc (text_view: PTextView){.cdecl.}
-    paste_clipboard*: proc (text_view: PTextView){.cdecl.}
-    toggle_overwrite*: proc (text_view: PTextView){.cdecl.}
-    move_focus*: proc (text_view: PTextView, direction: TDirectionType){.cdecl.}
-    reserved711: proc (){.cdecl.}
-    reserved712: proc (){.cdecl.}
-    reserved713: proc (){.cdecl.}
-    reserved714: proc (){.cdecl.}
-    reserved715: proc (){.cdecl.}
-    reserved716: proc (){.cdecl.}
-    reserved717: proc (){.cdecl.}
-    reserved718: proc (){.cdecl.}
-
-  PTipsQuery* = ptr TTipsQuery
-  TTipsQuery* = object of TLabel
-    TipsQuery_flag0*: guint16
-    label_inactive*: cstring
-    label_no_tip*: cstring
-    caller*: PWidget
-    last_crossed*: PWidget
-    query_cursor*: gdk2.PCursor
-
-  PTipsQueryClass* = ptr TTipsQueryClass
-  TTipsQueryClass* = object of TLabelClass
-    start_query*: proc (tips_query: PTipsQuery){.cdecl.}
-    stop_query*: proc (tips_query: PTipsQuery){.cdecl.}
-    widget_entered*: proc (tips_query: PTipsQuery, widget: PWidget, 
-                           tip_text: cstring, tip_private: cstring){.cdecl.}
-    widget_selected*: proc (tips_query: PTipsQuery, widget: PWidget, 
-                            tip_text: cstring, tip_private: cstring, 
-                            event: gdk2.PEventButton): gint{.cdecl.}
-    reserved721: proc (){.cdecl.}
-    reserved722: proc (){.cdecl.}
-    reserved723: proc (){.cdecl.}
-    reserved724: proc (){.cdecl.}
-
-  PTooltips* = ptr TTooltips
-  PTooltipsData* = ptr TTooltipsData
-  TTooltipsData*{.final, pure.} = object 
-    tooltips*: PTooltips
-    widget*: PWidget
-    tip_text*: cstring
-    tip_private*: cstring
-
-  TTooltips* = object of TObject
-    tip_window*: PWidget
-    tip_label*: PWidget
-    active_tips_data*: PTooltipsData
-    tips_data_list*: PGList
-    Tooltips_flag0*: int32
-    flag1*: guint16
-    timer_tag*: gint
-    last_popdown*: TGTimeVal
-
-  PTooltipsClass* = ptr TTooltipsClass
-  TTooltipsClass* = object of TObjectClass
-    reserved1: proc (){.cdecl.}
-    reserved2: proc (){.cdecl.}
-    reserved3: proc (){.cdecl.}
-    reserved4: proc (){.cdecl.}
-
-  PToolbarChildType* = ptr TToolbarChildType
-  TToolbarChildType* = enum 
-    TOOLBAR_CHILD_SPACE, TOOLBAR_CHILD_BUTTON, TOOLBAR_CHILD_TOGGLEBUTTON, 
-    TOOLBAR_CHILD_RADIOBUTTON, TOOLBAR_CHILD_WIDGET
-  PToolbarSpaceStyle* = ptr TToolbarSpaceStyle
-  TToolbarSpaceStyle* = enum 
-    TOOLBAR_SPACE_EMPTY, TOOLBAR_SPACE_LINE
-  PToolbarChild* = ptr TToolbarChild
-  TToolbarChild*{.final, pure.} = object 
-    `type`*: TToolbarChildType
-    widget*: PWidget
-    icon*: PWidget
-    label*: PWidget
-
-  PToolbar* = ptr TToolbar
-  TToolbar* = object of TContainer
-    num_children*: gint
-    children*: PGList
-    orientation*: TOrientation
-    Toolbar_style*: TToolbarStyle
-    icon_size*: TIconSize
-    tooltips*: PTooltips
-    button_maxw*: gint
-    button_maxh*: gint
-    style_set_connection*: guint
-    icon_size_connection*: guint
-    Toolbar_flag0*: guint16
-
-  PToolbarClass* = ptr TToolbarClass
-  TToolbarClass* = object of TContainerClass
-    orientation_changed*: proc (toolbar: PToolbar, orientation: TOrientation){.
-        cdecl.}
-    style_changed*: proc (toolbar: PToolbar, style: TToolbarStyle){.cdecl.}
-    reserved731: proc (){.cdecl.}
-    reserved732: proc (){.cdecl.}
-    reserved733: proc (){.cdecl.}
-    reserved734: proc (){.cdecl.}
-
-  PTreeViewMode* = ptr TTreeViewMode
-  TTreeViewMode* = enum 
-    TREE_VIEW_LINE, TREE_VIEW_ITEM
-  PTree* = ptr TTree
-  TTree* = object of TContainer
-    children*: PGList
-    root_tree*: PTree
-    tree_owner*: PWidget
-    selection*: PGList
-    level*: guint
-    indent_value*: guint
-    current_indent*: guint
-    Tree_flag0*: guint16
-
-  PTreeClass* = ptr TTreeClass
-  TTreeClass* = object of TContainerClass
-    selection_changed*: proc (tree: PTree){.cdecl.}
-    select_child*: proc (tree: PTree, child: PWidget){.cdecl.}
-    unselect_child*: proc (tree: PTree, child: PWidget){.cdecl.}
-
-  PTreeDragSource* = pointer
-  PTreeDragDest* = pointer
-  PTreeDragSourceIface* = ptr TTreeDragSourceIface
-  TTreeDragSourceIface* = object of TGTypeInterface
-    row_draggable*: proc (drag_source: PTreeDragSource, path: PTreePath): gboolean{.
-        cdecl.}
-    drag_data_get*: proc (drag_source: PTreeDragSource, path: PTreePath, 
-                          selection_data: PSelectionData): gboolean{.cdecl.}
-    drag_data_delete*: proc (drag_source: PTreeDragSource, path: PTreePath): gboolean{.
-        cdecl.}
-
-  PTreeDragDestIface* = ptr TTreeDragDestIface
-  TTreeDragDestIface* = object of TGTypeInterface
-    drag_data_received*: proc (drag_dest: PTreeDragDest, dest: PTreePath, 
-                               selection_data: PSelectionData): gboolean{.cdecl.}
-    row_drop_possible*: proc (drag_dest: PTreeDragDest, dest_path: PTreePath, 
-                              selection_data: PSelectionData): gboolean{.cdecl.}
-
-  PTreeItem* = ptr TTreeItem
-  TTreeItem* = object of TItem
-    subtree*: PWidget
-    pixmaps_box*: PWidget
-    plus_pix_widget*: PWidget
-    minus_pix_widget*: PWidget
-    pixmaps*: PGList
-    TreeItem_flag0*: guint16
-
-  PTreeItemClass* = ptr TTreeItemClass
-  TTreeItemClass* = object of TItemClass
-    expand*: proc (tree_item: PTreeItem){.cdecl.}
-    collapse*: proc (tree_item: PTreeItem){.cdecl.}
-
-  PTreeSelection* = ptr TTreeSelection
-  TTreeSelectionFunc* = proc (selection: PTreeSelection, model: PTreeModel, 
-                              path: PTreePath, 
-                              path_currently_selected: gboolean, data: gpointer): gboolean{.
-      cdecl.}
-  TTreeSelectionForeachFunc* = proc (model: PTreeModel, path: PTreePath, 
-                                     iter: PTreeIter, data: gpointer){.cdecl.}
-  TTreeSelection* = object of TGObject
-    tree_view*: PTreeView
-    thetype*: TSelectionMode
-    user_func*: TTreeSelectionFunc
-    user_data*: gpointer
-    destroy*: TDestroyNotify
-
-  PTreeSelectionClass* = ptr TTreeSelectionClass
-  TTreeSelectionClass* = object of TGObjectClass
-    changed*: proc (selection: PTreeSelection){.cdecl.}
-    reserved741: proc (){.cdecl.}
-    reserved742: proc (){.cdecl.}
-    reserved743: proc (){.cdecl.}
-    reserved744: proc (){.cdecl.}
-
-  PTreeStore* = ptr TTreeStore
-  TTreeStore* = object of TGObject
-    stamp*: gint
-    root*: gpointer
-    last*: gpointer
-    n_columns*: gint
-    sort_column_id*: gint
-    sort_list*: PGList
-    order*: TSortType
-    column_headers*: PGType
-    default_sort_func*: TTreeIterCompareFunc
-    default_sort_data*: gpointer
-    default_sort_destroy*: TDestroyNotify
-    TreeStore_flag0*: guint16
-
-  PTreeStoreClass* = ptr TTreeStoreClass
-  TTreeStoreClass* = object of TGObjectClass
-    reserved751: proc (){.cdecl.}
-    reserved752: proc (){.cdecl.}
-    reserved753: proc (){.cdecl.}
-    reserved754: proc (){.cdecl.}
-
-  PTreeViewColumnSizing* = ptr TTreeViewColumnSizing
-  TTreeViewColumnSizing* = enum 
-    TREE_VIEW_COLUMN_GROW_ONLY, TREE_VIEW_COLUMN_AUTOSIZE, 
-    TREE_VIEW_COLUMN_FIXED
-  TTreeCellDataFunc* = proc (tree_column: PTreeViewColumn, cell: PCellRenderer, 
-                             tree_model: PTreeModel, iter: PTreeIter, 
-                             data: gpointer){.cdecl.}
-  TTreeViewColumn* = object of TObject
-    tree_view*: PWidget
-    button*: PWidget
-    child*: PWidget
-    arrow*: PWidget
-    alignment*: PWidget
-    window*: gdk2.PWindow
-    editable_widget*: PCellEditable
-    xalign*: gfloat
-    property_changed_signal*: guint
-    spacing*: gint
-    column_type*: TTreeViewColumnSizing
-    requested_width*: gint
-    button_request*: gint
-    resized_width*: gint
-    width*: gint
-    fixed_width*: gint
-    min_width*: gint
-    max_width*: gint
-    drag_x*: gint
-    drag_y*: gint
-    title*: cstring
-    cell_list*: PGList
-    sort_clicked_signal*: guint
-    sort_column_changed_signal*: guint
-    sort_column_id*: gint
-    sort_order*: TSortType
-    TreeViewColumn_flag0*: guint16
-
-  PTreeViewColumnClass* = ptr TTreeViewColumnClass
-  TTreeViewColumnClass* = object of TObjectClass
-    clicked*: proc (tree_column: PTreeViewColumn){.cdecl.}
-    reserved751: proc (){.cdecl.}
-    reserved752: proc (){.cdecl.}
-    reserved753: proc (){.cdecl.}
-    reserved754: proc (){.cdecl.}
-
-  PRBNodeColor* = ptr TRBNodeColor
-  TRBNodeColor* = int32
-  PRBTree* = ptr TRBTree
-  PRBNode* = ptr TRBNode
-  TRBTreeTraverseFunc* = proc (tree: PRBTree, node: PRBNode, data: gpointer){.
-      cdecl.}
-  TRBTree*{.final, pure.} = object 
-    root*: PRBNode
-    `nil`*: PRBNode
-    parent_tree*: PRBTree
-    parent_node*: PRBNode
-
-  TRBNode*{.final, pure.} = object 
-    flag0*: guint16
-    left*: PRBNode
-    right*: PRBNode
-    parent*: PRBNode
-    count*: gint
-    offset*: gint
-    children*: PRBTree
-
-  PTreeRowReference* = pointer
-  PTreeViewFlags* = ptr TTreeViewFlags
-  TTreeViewFlags* = int32
-  TTreeViewSearchDialogPositionFunc* = proc (tree_view: PTreeView, 
-      search_dialog: PWidget){.cdecl.}
-  PTreeViewColumnReorder* = ptr TTreeViewColumnReorder
-  TTreeViewColumnReorder*{.final, pure.} = object 
-    left_align*: gint
-    right_align*: gint
-    left_column*: PTreeViewColumn
-    right_column*: PTreeViewColumn
-
-  PTreeViewPrivate* = ptr TTreeViewPrivate
-  TTreeViewPrivate*{.final, pure.} = object 
-    model*: PTreeModel
-    flags*: guint
-    tree*: PRBTree
-    button_pressed_node*: PRBNode
-    button_pressed_tree*: PRBTree
-    children*: PGList
-    width*: gint
-    height*: gint
-    expander_size*: gint
-    hadjustment*: PAdjustment
-    vadjustment*: PAdjustment
-    bin_window*: gdk2.PWindow
-    header_window*: gdk2.PWindow
-    drag_window*: gdk2.PWindow
-    drag_highlight_window*: gdk2.PWindow
-    drag_column*: PTreeViewColumn
-    last_button_press*: PTreeRowReference
-    last_button_press_2*: PTreeRowReference
-    top_row*: PTreeRowReference
-    top_row_dy*: gint
-    dy*: gint
-    drag_column_x*: gint
-    expander_column*: PTreeViewColumn
-    edited_column*: PTreeViewColumn
-    presize_handler_timer*: guint
-    validate_rows_timer*: guint
-    scroll_sync_timer*: guint
-    focus_column*: PTreeViewColumn
-    anchor*: PTreeRowReference
-    cursor*: PTreeRowReference
-    drag_pos*: gint
-    x_drag*: gint
-    prelight_node*: PRBNode
-    prelight_tree*: PRBTree
-    expanded_collapsed_node*: PRBNode
-    expanded_collapsed_tree*: PRBTree
-    expand_collapse_timeout*: guint
-    selection*: PTreeSelection
-    n_columns*: gint
-    columns*: PGList
-    header_height*: gint
-    column_drop_func*: TTreeViewColumnDropFunc
-    column_drop_func_data*: gpointer
-    column_drop_func_data_destroy*: TDestroyNotify
-    column_drag_info*: PGList
-    cur_reorder*: PTreeViewColumnReorder
-    destroy_count_func*: TTreeDestroyCountFunc
-    destroy_count_data*: gpointer
-    destroy_count_destroy*: TDestroyNotify
-    scroll_timeout*: guint
-    drag_dest_row*: PTreeRowReference
-    drag_dest_pos*: TTreeViewDropPosition
-    open_dest_timeout*: guint
-    pressed_button*: gint
-    press_start_x*: gint
-    press_start_y*: gint
-    scroll_to_path*: PTreeRowReference
-    scroll_to_column*: PTreeViewColumn
-    scroll_to_row_align*: gfloat
-    scroll_to_col_align*: gfloat
-    flag0*: guint16
-    search_column*: gint
-    search_dialog_position_func*: TTreeViewSearchDialogPositionFunc
-    search_equal_func*: TTreeViewSearchEqualFunc
-    search_user_data*: gpointer
-    search_destroy*: TDestroyNotify
-
-  TTreeView* = object of TContainer
-    priv*: PTreeViewPrivate
-
-  PTreeViewClass* = ptr TTreeViewClass
-  TTreeViewClass* = object of TContainerClass
-    set_scroll_adjustments*: proc (tree_view: PTreeView, 
-                                   hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-    row_activated*: proc (tree_view: PTreeView, path: PTreePath, 
-                          column: PTreeViewColumn){.cdecl.}
-    test_expand_row*: proc (tree_view: PTreeView, iter: PTreeIter, 
-                            path: PTreePath): gboolean{.cdecl.}
-    test_collapse_row*: proc (tree_view: PTreeView, iter: PTreeIter, 
-                              path: PTreePath): gboolean{.cdecl.}
-    row_expanded*: proc (tree_view: PTreeView, iter: PTreeIter, path: PTreePath){.
-        cdecl.}
-    row_collapsed*: proc (tree_view: PTreeView, iter: PTreeIter, path: PTreePath){.
-        cdecl.}
-    columns_changed*: proc (tree_view: PTreeView){.cdecl.}
-    cursor_changed*: proc (tree_view: PTreeView){.cdecl.}
-    move_cursor*: proc (tree_view: PTreeView, step: TMovementStep, count: gint): gboolean{.
-        cdecl.}
-    select_all*: proc (tree_view: PTreeView){.cdecl.}
-    unselect_all*: proc (tree_view: PTreeView){.cdecl.}
-    select_cursor_row*: proc (tree_view: PTreeView, start_editing: gboolean){.
-        cdecl.}
-    toggle_cursor_row*: proc (tree_view: PTreeView){.cdecl.}
-    expand_collapse_cursor_row*: proc (tree_view: PTreeView, logical: gboolean, 
-                                       expand: gboolean, open_all: gboolean){.
-        cdecl.}
-    select_cursor_parent*: proc (tree_view: PTreeView){.cdecl.}
-    start_interactive_search*: proc (tree_view: PTreeView){.cdecl.}
-    reserved760: proc (){.cdecl.}
-    reserved761: proc (){.cdecl.}
-    reserved762: proc (){.cdecl.}
-    reserved763: proc (){.cdecl.}
-    reserved764: proc (){.cdecl.}
-
-  PVButtonBox* = ptr TVButtonBox
-  TVButtonBox* = object of TButtonBox
-  PVButtonBoxClass* = ptr TVButtonBoxClass
-  TVButtonBoxClass* = object of TButtonBoxClass
-  PViewport* = ptr TViewport
-  TViewport* = object of TBin
-    shadow_type*: TShadowType
-    view_window*: gdk2.PWindow
-    bin_window*: gdk2.PWindow
-    hadjustment*: PAdjustment
-    vadjustment*: PAdjustment
-
-  PViewportClass* = ptr TViewportClass
-  TViewportClass* = object of TBinClass
-    set_scroll_adjustments*: proc (viewport: PViewport, 
-                                   hadjustment: PAdjustment, 
-                                   vadjustment: PAdjustment){.cdecl.}
-
-  PVPaned* = ptr TVPaned
-  TVPaned* = object of TPaned
-  PVPanedClass* = ptr TVPanedClass
-  TVPanedClass* = object of TPanedClass
-  PVRuler* = ptr TVRuler
-  TVRuler* = object of TRuler
-  PVRulerClass* = ptr TVRulerClass
-  TVRulerClass* = object of TRulerClass
-  PVScale* = ptr TVScale
-  TVScale* = object of TScale
-  PVScaleClass* = ptr TVScaleClass
-  TVScaleClass* = object of TScaleClass
-  PVScrollbar* = ptr TVScrollbar
-  TVScrollbar* = object of TScrollbar
-  PVScrollbarClass* = ptr TVScrollbarClass
-  TVScrollbarClass* = object of TScrollbarClass
-  PVSeparator* = ptr TVSeparator
-  TVSeparator* = object of TSeparator
-  PVSeparatorClass* = ptr TVSeparatorClass
-  TVSeparatorClass* = object of TSeparatorClass
-
-const 
-  IN_DESTRUCTION* = 1 shl 0
-  FLOATING* = 1 shl 1
-  RESERVED_1* = 1 shl 2
-  RESERVED_2* = 1 shl 3
-  ARG_READABLE* = G_PARAM_READABLE
-  ARG_WRITABLE* = G_PARAM_WRITABLE
-  ARG_CONSTRUCT* = G_PARAM_CONSTRUCT
-  ARG_CONSTRUCT_ONLY* = G_PARAM_CONSTRUCT_ONLY
-  ARG_CHILD_ARG* = 1 shl 4
-
-proc TYPE_OBJECT*(): GType
-proc `OBJECT`*(anObject: pointer): PObject
-proc OBJECT_CLASS*(klass: pointer): PObjectClass
-proc IS_OBJECT*(anObject: pointer): bool
-proc IS_OBJECT_CLASS*(klass: pointer): bool
-proc OBJECT_GET_CLASS*(anObject: pointer): PObjectClass
-proc OBJECT_TYPE*(anObject: pointer): GType
-proc OBJECT_TYPE_NAME*(anObject: pointer): cstring
-proc OBJECT_FLAGS*(obj: pointer): guint32
-proc OBJECT_FLOATING*(obj: pointer): gboolean
-proc OBJECT_SET_FLAGS*(obj: pointer, flag: guint32)
-proc OBJECT_UNSET_FLAGS*(obj: pointer, flag: guint32)
-proc object_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_object_get_type".}
-proc object_new*(thetype: TType, first_property_name: cstring): PObject{.cdecl, 
-    varargs, dynlib: lib, importc: "gtk_object_new".}
-proc sink*(anObject: PObject){.cdecl, dynlib: lib, 
-                                      importc: "gtk_object_sink".}
-proc destroy*(anObject: PObject){.cdecl, dynlib: lib, 
-    importc: "gtk_object_destroy".}
-const 
-  TYPE_INVALID* = G_TYPE_INVALID
-  TYPE_NONE* = G_TYPE_NONE
-  TYPE_ENUM* = G_TYPE_ENUM
-  TYPE_FLAGS* = G_TYPE_FLAGS
-  TYPE_CHAR* = G_TYPE_CHAR
-  TYPE_UCHAR* = G_TYPE_UCHAR
-  TYPE_BOOL* = G_TYPE_BOOLEAN
-  TYPE_INT* = G_TYPE_INT
-  TYPE_UINT* = G_TYPE_UINT
-  TYPE_LONG* = G_TYPE_LONG
-  TYPE_ULONG* = G_TYPE_ULONG
-  TYPE_FLOAT* = G_TYPE_FLOAT
-  TYPE_DOUBLE* = G_TYPE_DOUBLE
-  TYPE_STRING* = G_TYPE_STRING
-  TYPE_BOXED* = G_TYPE_BOXED
-  TYPE_POINTER* = G_TYPE_POINTER
-
-proc TYPE_IDENTIFIER*(): GType
-proc identifier_get_type*(): GType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_identifier_get_type".}
-proc SIGNAL_FUNC*(f: pointer): TSignalFunc
-proc type_class*(thetype: TType): gpointer{.cdecl, dynlib: lib, 
-    importc: "gtk_type_class".}
-const 
-  TOPLEVEL* = 1 shl 4
-  NO_WINDOW* = 1 shl 5
-  constREALIZED* = 1 shl 6
-  MAPPED* = 1 shl 7
-  constVISIBLE* = 1 shl 8
-  SENSITIVE* = 1 shl 9
-  PARENT_SENSITIVE* = 1 shl 10
-  CAN_FOCUS* = 1 shl 11
-  constHAS_FOCUS* = 1 shl 12
-  CAN_DEFAULT* = 1 shl 13
-  HAS_DEFAULT* = 1 shl 14
-  HAS_GRAB* = 1 shl 15
-  RC_STYLE* = 1 shl 16
-  COMPOSITE_CHILD* = 1 shl 17
-  NO_REPARENT* = 1 shl 18
-  APP_PAINTABLE* = 1 shl 19
-  RECEIVES_DEFAULT* = 1 shl 20
-  DOUBLE_BUFFERED* = 1 shl 21
-
-const 
-  bm_TGtkWidgetAuxInfo_x_set* = 0x0001'i16
-  bp_TGtkWidgetAuxInfo_x_set* = 0'i16
-  bm_TGtkWidgetAuxInfo_y_set* = 0x0002'i16
-  bp_TGtkWidgetAuxInfo_y_set* = 1'i16
-
-proc TYPE_WIDGET*(): GType
-proc WIDGET*(widget: pointer): PWidget
-proc WIDGET_CLASS*(klass: pointer): PWidgetClass
-proc IS_WIDGET*(widget: pointer): bool
-proc IS_WIDGET_CLASS*(klass: pointer): bool
-proc WIDGET_GET_CLASS*(obj: pointer): PWidgetClass
-proc WIDGET_TYPE*(wid: pointer): GType
-proc WIDGET_STATE*(wid: pointer): int32
-proc WIDGET_SAVED_STATE*(wid: pointer): int32
-proc WIDGET_FLAGS*(wid: pointer): guint32
-proc WIDGET_TOPLEVEL*(wid: pointer): gboolean
-proc WIDGET_NO_WINDOW*(wid: pointer): gboolean
-proc WIDGET_REALIZED*(wid: pointer): gboolean
-proc WIDGET_MAPPED*(wid: pointer): gboolean
-proc WIDGET_VISIBLE*(wid: pointer): gboolean
-proc WIDGET_DRAWABLE*(wid: pointer): gboolean
-proc WIDGET_SENSITIVE*(wid: pointer): gboolean
-proc WIDGET_PARENT_SENSITIVE*(wid: pointer): gboolean
-proc WIDGET_IS_SENSITIVE*(wid: pointer): gboolean
-proc WIDGET_CAN_FOCUS*(wid: pointer): gboolean
-proc WIDGET_HAS_FOCUS*(wid: pointer): gboolean
-proc WIDGET_CAN_DEFAULT*(wid: pointer): gboolean
-proc WIDGET_HAS_DEFAULT*(wid: pointer): gboolean
-proc WIDGET_HAS_GRAB*(wid: pointer): gboolean
-proc WIDGET_RC_STYLE*(wid: pointer): gboolean
-proc WIDGET_COMPOSITE_CHILD*(wid: pointer): gboolean
-proc WIDGET_APP_PAINTABLE*(wid: pointer): gboolean
-proc WIDGET_RECEIVES_DEFAULT*(wid: pointer): gboolean
-proc WIDGET_DOUBLE_BUFFERED*(wid: pointer): gboolean
-proc SET_FLAGS*(wid: PWidget, flags: TWidgetFlags): TWidgetFlags
-proc UNSET_FLAGS*(wid: PWidget, flags: TWidgetFlags): TWidgetFlags
-proc TYPE_REQUISITION*(): GType
-proc x_set*(a: PWidgetAuxInfo): guint
-proc set_x_set*(a: PWidgetAuxInfo, x_set: guint)
-proc y_set*(a: PWidgetAuxInfo): guint
-proc set_y_set*(a: PWidgetAuxInfo, y_set: guint)
-proc widget_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_widget_get_type".}
-proc reference*(widget: PWidget): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_ref".}
-proc unref*(widget: PWidget){.cdecl, dynlib: lib, 
-                                     importc: "gtk_widget_unref".}
-proc destroy*(widget: PWidget){.cdecl, dynlib: lib, 
-                                       importc: "gtk_widget_destroy".}
-proc destroyed*(widget: PWidget, r: var PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_destroyed".}
-proc unparent*(widget: PWidget){.cdecl, dynlib: lib, 
-                                        importc: "gtk_widget_unparent".}
-proc show*(widget: PWidget){.cdecl, dynlib: lib, 
-                                    importc: "gtk_widget_show".}
-proc show_now*(widget: PWidget){.cdecl, dynlib: lib, 
-                                        importc: "gtk_widget_show_now".}
-proc hide*(widget: PWidget){.cdecl, dynlib: lib, 
-                                    importc: "gtk_widget_hide".}
-proc show_all*(widget: PWidget){.cdecl, dynlib: lib, 
-                                        importc: "gtk_widget_show_all".}
-proc hide_all*(widget: PWidget){.cdecl, dynlib: lib, 
-                                        importc: "gtk_widget_hide_all".}
-proc map*(widget: PWidget){.cdecl, dynlib: lib, importc: "gtk_widget_map".}
-proc unmap*(widget: PWidget){.cdecl, dynlib: lib, 
-                                     importc: "gtk_widget_unmap".}
-proc realize*(widget: PWidget){.cdecl, dynlib: lib, 
-                                       importc: "gtk_widget_realize".}
-proc unrealize*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_unrealize".}
-proc queue_draw*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_queue_draw".}
-proc queue_draw_area*(widget: PWidget, x: gint, y: gint, width: gint, 
-                             height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_queue_draw_area".}
-proc queue_resize*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_queue_resize".}
-proc size_request*(widget: PWidget, requisition: PRequisition){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_size_request".}
-proc size_allocate*(widget: PWidget, allocation: PAllocation){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_size_allocate".}
-proc get_child_requisition*(widget: PWidget, requisition: PRequisition){.
-    cdecl, dynlib: lib, importc: "gtk_widget_get_child_requisition".}
-proc add_accelerator*(widget: PWidget, accel_signal: cstring, 
-                             accel_group: PAccelGroup, accel_key: guint, 
-                             accel_mods: gdk2.TModifierType, 
-                             accel_flags: TAccelFlags){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_add_accelerator".}
-proc remove_accelerator*(widget: PWidget, accel_group: PAccelGroup, 
-                                accel_key: guint, accel_mods: gdk2.TModifierType): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_widget_remove_accelerator".}
-proc set_accel_path*(widget: PWidget, accel_path: cstring, 
-                            accel_group: PAccelGroup){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_accel_path".}
-proc get_accel_path*(widget: PWidget, locked: Pgboolean): cstring{.cdecl, 
-    dynlib: lib, importc: "_gtk_widget_get_accel_path".}
-proc list_accel_closures*(widget: PWidget): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_list_accel_closures".}
-proc mnemonic_activate*(widget: PWidget, group_cycling: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_widget_mnemonic_activate".}
-proc event*(widget: PWidget, event: gdk2.PEvent): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_event".}
-proc send_expose*(widget: PWidget, event: gdk2.PEvent): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_send_expose".}
-proc activate*(widget: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_activate".}
-proc set_scroll_adjustments*(widget: PWidget, hadjustment: PAdjustment, 
-                                    vadjustment: PAdjustment): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_scroll_adjustments".}
-proc reparent*(widget: PWidget, new_parent: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_reparent".}
-proc intersect*(widget: PWidget, area: gdk2.PRectangle, 
-                       intersection: gdk2.PRectangle): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_intersect".}
-proc region_intersect*(widget: PWidget, region: gdk2.PRegion): gdk2.PRegion{.
-    cdecl, dynlib: lib, importc: "gtk_widget_region_intersect".}
-proc freeze_child_notify*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_freeze_child_notify".}
-proc child_notify*(widget: PWidget, child_property: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_child_notify".}
-proc thaw_child_notify*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_thaw_child_notify".}
-proc is_focus*(widget: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_is_focus".}
-proc grab_focus*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_grab_focus".}
-proc grab_default*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_grab_default".}
-proc set_name*(widget: PWidget, name: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_name".}
-proc get_name*(widget: PWidget): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_name".}
-proc set_state*(widget: PWidget, state: TStateType){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_state".}
-proc set_sensitive*(widget: PWidget, sensitive: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_sensitive".}
-proc set_app_paintable*(widget: PWidget, app_paintable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_app_paintable".}
-proc set_double_buffered*(widget: PWidget, double_buffered: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_widget_set_double_buffered".}
-proc set_redraw_on_allocate*(widget: PWidget, 
-                                    redraw_on_allocate: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_redraw_on_allocate".}
-proc set_parent*(widget: PWidget, parent: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_parent".}
-proc set_parent_window*(widget: PWidget, parent_window: gdk2.PWindow){.
-    cdecl, dynlib: lib, importc: "gtk_widget_set_parent_window".}
-proc set_child_visible*(widget: PWidget, is_visible: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_child_visible".}
-proc get_child_visible*(widget: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_child_visible".}
-proc get_parent*(widget: PWidget): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_parent".}
-proc get_parent_window*(widget: PWidget): gdk2.PWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_parent_window".}
-proc child_focus*(widget: PWidget, direction: TDirectionType): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_widget_child_focus".}
-proc set_size_request*(widget: PWidget, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gtk_widget_set_size_request".}
-proc get_size_request*(widget: PWidget, width: Pgint, height: Pgint){.
-    cdecl, dynlib: lib, importc: "gtk_widget_get_size_request".}
-proc set_events*(widget: PWidget, events: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_events".}
-proc add_events*(widget: PWidget, events: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_add_events".}
-proc set_extension_events*(widget: PWidget, mode: gdk2.TExtensionMode){.
-    cdecl, dynlib: lib, importc: "gtk_widget_set_extension_events".}
-proc get_extension_events*(widget: PWidget): gdk2.TExtensionMode{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_get_extension_events".}
-proc get_toplevel*(widget: PWidget): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_toplevel".}
-proc get_ancestor*(widget: PWidget, widget_type: TType): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_get_ancestor".}
-proc get_colormap*(widget: PWidget): gdk2.PColormap{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_colormap".}
-proc get_visual*(widget: PWidget): gdk2.PVisual{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_visual".}
-proc get_screen*(widget: PWidget): gdk2.PScreen{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_screen".}
-proc has_screen*(widget: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_has_screen".}
-proc get_display*(widget: PWidget): gdk2.PDisplay{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_display".}
-proc get_root_window*(widget: PWidget): gdk2.PWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_root_window".}
-proc get_settings*(widget: PWidget): PSettings{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_settings".}
-proc get_clipboard*(widget: PWidget, selection: gdk2.TAtom): PClipboard{.
-    cdecl, dynlib: lib, importc: "gtk_widget_get_clipboard".}
-proc get_accessible*(widget: PWidget): atk.PObject{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_accessible".}
-proc set_colormap*(widget: PWidget, colormap: gdk2.PColormap){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_colormap".}
-proc get_events*(widget: PWidget): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_events".}
-proc get_pointer*(widget: PWidget, x: Pgint, y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_get_pointer".}
-proc is_ancestor*(widget: PWidget, ancestor: PWidget): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_is_ancestor".}
-proc translate_coordinates*(src_widget: PWidget, dest_widget: PWidget, 
-                                   src_x: gint, src_y: gint, dest_x: Pgint, 
-                                   dest_y: Pgint): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_translate_coordinates".}
-proc hide_on_delete*(widget: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_hide_on_delete".}
-proc set_style*(widget: PWidget, style: PStyle){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_style".}
-proc ensure_style*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_ensure_style".}
-proc get_style*(widget: PWidget): PStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_style".}
-proc modify_style*(widget: PWidget, style: PRcStyle){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_modify_style".}
-proc get_modifier_style*(widget: PWidget): PRcStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_modifier_style".}
-proc modify_fg*(widget: PWidget, state: TStateType, color: gdk2.PColor){.
-    cdecl, dynlib: lib, importc: "gtk_widget_modify_fg".}
-proc modify_bg*(widget: PWidget, state: TStateType, color: gdk2.PColor){.
-    cdecl, dynlib: lib, importc: "gtk_widget_modify_bg".}
-proc modify_text*(widget: PWidget, state: TStateType, color: gdk2.PColor){.
-    cdecl, dynlib: lib, importc: "gtk_widget_modify_text".}
-proc modify_base*(widget: PWidget, state: TStateType, color: gdk2.PColor){.
-    cdecl, dynlib: lib, importc: "gtk_widget_modify_base".}
-proc modify_font*(widget: PWidget, font_desc: pango.PFontDescription){.
-    cdecl, dynlib: lib, importc: "gtk_widget_modify_font".}
-proc create_pango_context*(widget: PWidget): pango.PContext{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_create_pango_context".}
-proc get_pango_context*(widget: PWidget): pango.PContext{.cdecl, 
-    dynlib: lib, importc: "gtk_widget_get_pango_context".}
-proc create_pango_layout*(widget: PWidget, text: cstring): pango.PLayout{.
-    cdecl, dynlib: lib, importc: "gtk_widget_create_pango_layout".}
-proc render_icon*(widget: PWidget, stock_id: cstring, size: TIconSize, 
-                         detail: cstring): gdk2pixbuf.PPixbuf{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_render_icon".}
-proc set_composite_name*(widget: PWidget, name: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_composite_name".}
-proc get_composite_name*(widget: PWidget): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_composite_name".}
-proc reset_rc_styles*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_reset_rc_styles".}
-proc widget_push_colormap*(cmap: gdk2.PColormap){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_push_colormap".}
-proc widget_push_composite_child*(){.cdecl, dynlib: lib, 
-                                     importc: "gtk_widget_push_composite_child".}
-proc widget_pop_composite_child*(){.cdecl, dynlib: lib, 
-                                    importc: "gtk_widget_pop_composite_child".}
-proc widget_pop_colormap*(){.cdecl, dynlib: lib, 
-                             importc: "gtk_widget_pop_colormap".}
-proc install_style_property*(klass: PWidgetClass, 
-    pspec: PGParamSpec){.cdecl, dynlib: lib, 
-                         importc: "gtk_widget_class_install_style_property".}
-proc install_style_property_parser*(klass: PWidgetClass, 
-    pspec: PGParamSpec, parser: TRcPropertyParser){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_class_install_style_property_parser".}
-proc find_style_property*(klass: PWidgetClass, 
-                                       property_name: cstring): PGParamSpec{.
-    cdecl, dynlib: lib, importc: "gtk_widget_class_find_style_property".}
-proc list_style_properties*(klass: PWidgetClass, 
-    n_properties: Pguint): PPGParamSpec{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_class_list_style_properties".}
-proc style_get_property*(widget: PWidget, property_name: cstring, 
-                                value: PGValue){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_style_get_property".}
-proc widget_set_default_colormap*(colormap: gdk2.PColormap){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_default_colormap".}
-proc widget_get_default_style*(): PStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_default_style".}
-proc set_direction*(widget: PWidget, dir: TTextDirection){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_set_direction".}
-proc get_direction*(widget: PWidget): TTextDirection{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_direction".}
-proc widget_set_default_direction*(dir: TTextDirection){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_set_default_direction".}
-proc widget_get_default_direction*(): TTextDirection{.cdecl, dynlib: lib, 
-    importc: "gtk_widget_get_default_direction".}
-proc shape_combine_mask*(widget: PWidget, shape_mask: gdk2.PBitmap, 
-                                offset_x: gint, offset_y: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_widget_shape_combine_mask".}
-proc reset_shapes*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_reset_shapes".}
-proc path*(widget: PWidget, path_length: Pguint, path: PPgchar, 
-                  path_reversed: PPgchar){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_path".}
-proc class_path*(widget: PWidget, path_length: Pguint, path: PPgchar, 
-                        path_reversed: PPgchar){.cdecl, dynlib: lib, 
-    importc: "gtk_widget_class_path".}
-proc requisition_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_requisition_get_type".}
-proc copy*(requisition: PRequisition): PRequisition{.cdecl, 
-    dynlib: lib, importc: "gtk_requisition_copy".}
-proc free*(requisition: PRequisition){.cdecl, dynlib: lib, 
-    importc: "gtk_requisition_free".}
-proc get_aux_info*(widget: PWidget, create: gboolean): PWidgetAuxInfo{.
-    cdecl, dynlib: lib, importc: "gtk_widget_get_aux_info".}
-proc propagate_hierarchy_changed*(widget: PWidget, 
-    previous_toplevel: PWidget){.cdecl, dynlib: lib, importc: "_gtk_widget_propagate_hierarchy_changed".}
-proc widget_peek_colormap*(): gdk2.PColormap{.cdecl, dynlib: lib, 
-    importc: "_gtk_widget_peek_colormap".}
-proc TYPE_MISC*(): GType
-proc MISC*(obj: pointer): PMisc
-proc MISC_CLASS*(klass: pointer): PMiscClass
-proc IS_MISC*(obj: pointer): bool
-proc IS_MISC_CLASS*(klass: pointer): bool
-proc MISC_GET_CLASS*(obj: pointer): PMiscClass
-proc misc_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_misc_get_type".}
-proc set_alignment*(misc: PMisc, xalign: gfloat, yalign: gfloat){.cdecl, 
-    dynlib: lib, importc: "gtk_misc_set_alignment".}
-proc get_alignment*(misc: PMisc, xalign, yalign: var Pgfloat){.cdecl, 
-    dynlib: lib, importc: "gtk_misc_get_alignment".}
-proc set_padding*(misc: PMisc, xpad: gint, ypad: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_misc_set_padding".}
-proc get_padding*(misc: PMisc, xpad, ypad: var Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_misc_get_padding".}
-const 
-  ACCEL_VISIBLE* = 1 shl 0
-  ACCEL_LOCKED* = 1 shl 1
-  ACCEL_MASK* = 0x00000007
-  bm_TGtkAccelKey_accel_flags* = 0xFFFF'i16
-  bp_TGtkAccelKey_accel_flags* = 0'i16
-
-proc TYPE_ACCEL_GROUP*(): GType
-proc ACCEL_GROUP*(anObject: pointer): PAccelGroup
-proc ACCEL_GROUP_CLASS*(klass: pointer): PAccelGroupClass
-proc IS_ACCEL_GROUP*(anObject: pointer): bool
-proc IS_ACCEL_GROUP_CLASS*(klass: pointer): bool
-proc ACCEL_GROUP_GET_CLASS*(obj: pointer): PAccelGroupClass
-proc accel_flags*(a: PAccelKey): guint
-proc set_accel_flags*(a: PAccelKey, `accel_flags`: guint)
-proc accel_group_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_accel_group_get_type".}
-proc accel_group_new*(): PAccelGroup{.cdecl, dynlib: lib, 
-                                      importc: "gtk_accel_group_new".}
-proc lock*(accel_group: PAccelGroup){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_group_lock".}
-proc unlock*(accel_group: PAccelGroup){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_group_unlock".}
-proc connect*(accel_group: PAccelGroup, accel_key: guint, 
-                          accel_mods: gdk2.TModifierType, 
-                          accel_flags: TAccelFlags, closure: PGClosure){.cdecl, 
-    dynlib: lib, importc: "gtk_accel_group_connect".}
-proc connect_by_path*(accel_group: PAccelGroup, accel_path: cstring, 
-                                  closure: PGClosure){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_group_connect_by_path".}
-proc disconnect*(accel_group: PAccelGroup, closure: PGClosure): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_accel_group_disconnect".}
-proc disconnect_key*(accel_group: PAccelGroup, accel_key: guint, 
-                                 accel_mods: gdk2.TModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_group_disconnect_key".}
-proc attach*(accel_group: PAccelGroup, anObject: PGObject){.cdecl, 
-    dynlib: lib, importc: "_gtk_accel_group_attach".}
-proc detach*(accel_group: PAccelGroup, anObject: PGObject){.cdecl, 
-    dynlib: lib, importc: "_gtk_accel_group_detach".}
-proc accel_groups_activate*(anObject: PGObject, accel_key: guint, 
-                            accel_mods: gdk2.TModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_groups_activate".}
-proc accel_groups_from_object*(anObject: PGObject): PGSList{.cdecl, dynlib: lib, 
-    importc: "gtk_accel_groups_from_object".}
-proc find*(accel_group: PAccelGroup, 
-                       find_func: Taccel_group_find_func, data: gpointer): PAccelKey{.
-    cdecl, dynlib: lib, importc: "gtk_accel_group_find".}
-proc accel_group_from_accel_closure*(closure: PGClosure): PAccelGroup{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_group_from_accel_closure".}
-proc accelerator_valid*(keyval: guint, modifiers: gdk2.TModifierType): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_accelerator_valid".}
-proc accelerator_parse*(accelerator: cstring, accelerator_key: Pguint, 
-                        accelerator_mods: gdk2.PModifierType){.cdecl, dynlib: lib, 
-    importc: "gtk_accelerator_parse".}
-proc accelerator_name*(accelerator_key: guint, 
-                       accelerator_mods: gdk2.TModifierType): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_accelerator_name".}
-proc accelerator_set_default_mod_mask*(default_mod_mask: gdk2.TModifierType){.
-    cdecl, dynlib: lib, importc: "gtk_accelerator_set_default_mod_mask".}
-proc accelerator_get_default_mod_mask*(): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_accelerator_get_default_mod_mask".}
-proc query*(accel_group: PAccelGroup, accel_key: guint, 
-                        accel_mods: gdk2.TModifierType, n_entries: Pguint): PAccelGroupEntry{.
-    cdecl, dynlib: lib, importc: "gtk_accel_group_query".}
-proc reconnect*(accel_group: PAccelGroup, accel_path_quark: TGQuark){.
-    cdecl, dynlib: lib, importc: "_gtk_accel_group_reconnect".}
-const 
-  bm_TGtkContainer_border_width* = 0x0000FFFF'i32
-  bp_TGtkContainer_border_width* = 0'i32
-  bm_TGtkContainer_need_resize* = 0x00010000'i32
-  bp_TGtkContainer_need_resize* = 16'i32
-  bm_TGtkContainer_resize_mode* = 0x00060000'i32
-  bp_TGtkContainer_resize_mode* = 17'i32
-  bm_TGtkContainer_reallocate_redraws* = 0x00080000'i32
-  bp_TGtkContainer_reallocate_redraws* = 19'i32
-  bm_TGtkContainer_has_focus_chain* = 0x00100000'i32
-  bp_TGtkContainer_has_focus_chain* = 20'i32
-
-proc TYPE_CONTAINER*(): GType
-proc CONTAINER*(obj: pointer): PContainer
-proc CONTAINER_CLASS*(klass: pointer): PContainerClass
-proc IS_CONTAINER*(obj: pointer): bool
-proc IS_CONTAINER_CLASS*(klass: pointer): bool
-proc CONTAINER_GET_CLASS*(obj: pointer): PContainerClass
-proc IS_RESIZE_CONTAINER*(widget: pointer): bool
-proc border_width*(a: PContainer): guint
-proc need_resize*(a: PContainer): guint
-proc set_need_resize*(a: PContainer, `need_resize`: guint)
-proc resize_mode*(a: PContainer): guint
-proc set_resize_mode*(a: PContainer, `resize_mode`: guint)
-proc reallocate_redraws*(a: PContainer): guint
-proc set_reallocate_redraws*(a: PContainer, `reallocate_redraws`: guint)
-proc has_focus_chain*(a: PContainer): guint
-proc set_has_focus_chain*(a: PContainer, `has_focus_chain`: guint)
-proc container_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_container_get_type".}
-proc set_border_width*(container: PContainer, border_width: guint){.
-    cdecl, dynlib: lib, importc: "gtk_container_set_border_width".}
-proc get_border_width*(container: PContainer): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_container_get_border_width".}
-proc add*(container: PContainer, widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_container_add".}
-proc remove*(container: PContainer, widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_container_remove".}
-proc set_resize_mode*(container: PContainer, resize_mode: TResizeMode){.
-    cdecl, dynlib: lib, importc: "gtk_container_set_resize_mode".}
-proc get_resize_mode*(container: PContainer): TResizeMode{.cdecl, 
-    dynlib: lib, importc: "gtk_container_get_resize_mode".}
-proc check_resize*(container: PContainer){.cdecl, dynlib: lib, 
-    importc: "gtk_container_check_resize".}
-proc foreach*(container: PContainer, callback: TCallback, 
-                        callback_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_container_foreach".}
-proc get_children*(container: PContainer): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_container_get_children".}
-proc propagate_expose*(container: PContainer, child: PWidget, 
-                                 event: gdk2.PEventExpose){.cdecl, dynlib: lib, 
-    importc: "gtk_container_propagate_expose".}
-proc set_focus_chain*(container: PContainer, focusable_widgets: PGList){.
-    cdecl, dynlib: lib, importc: "gtk_container_set_focus_chain".}
-proc get_focus_chain*(container: PContainer, s: var PGList): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_container_get_focus_chain".}
-proc unset_focus_chain*(container: PContainer){.cdecl, dynlib: lib, 
-    importc: "gtk_container_unset_focus_chain".}
-proc set_reallocate_redraws*(container: PContainer, 
-                                       needs_redraws: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_container_set_reallocate_redraws".}
-proc set_focus_child*(container: PContainer, child: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_container_set_focus_child".}
-proc set_focus_vadjustment*(container: PContainer, 
-                                      adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_container_set_focus_vadjustment".}
-proc get_focus_vadjustment*(container: PContainer): PAdjustment{.
-    cdecl, dynlib: lib, importc: "gtk_container_get_focus_vadjustment".}
-proc set_focus_hadjustment*(container: PContainer, 
-                                      adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_container_set_focus_hadjustment".}
-proc get_focus_hadjustment*(container: PContainer): PAdjustment{.
-    cdecl, dynlib: lib, importc: "gtk_container_get_focus_hadjustment".}
-proc resize_children*(container: PContainer){.cdecl, dynlib: lib, 
-    importc: "gtk_container_resize_children".}
-proc child_type*(container: PContainer): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_container_child_type".}
-proc install_child_property*(cclass: PContainerClass, 
-    property_id: guint, pspec: PGParamSpec){.cdecl, dynlib: lib, 
-    importc: "gtk_container_class_install_child_property".}
-proc container_class_find_child_property*(cclass: PGObjectClass, 
-    property_name: cstring): PGParamSpec{.cdecl, dynlib: lib, 
-    importc: "gtk_container_class_find_child_property".}
-proc container_class_list_child_properties*(cclass: PGObjectClass, 
-    n_properties: Pguint): PPGParamSpec{.cdecl, dynlib: lib, 
-    importc: "gtk_container_class_list_child_properties".}
-proc child_set_property*(container: PContainer, child: PWidget, 
-                                   property_name: cstring, value: PGValue){.
-    cdecl, dynlib: lib, importc: "gtk_container_child_set_property".}
-proc child_get_property*(container: PContainer, child: PWidget, 
-                                   property_name: cstring, value: PGValue){.
-    cdecl, dynlib: lib, importc: "gtk_container_child_get_property".}
-proc CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID*(anObject: pointer, 
-    property_id: guint, pspec: pointer)
-proc forall*(container: PContainer, callback: TCallback, 
-                       callback_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_container_forall".}
-proc queue_resize*(container: PContainer){.cdecl, dynlib: lib, 
-    importc: "_gtk_container_queue_resize".}
-proc clear_resize_widgets*(container: PContainer){.cdecl, dynlib: lib, 
-    importc: "_gtk_container_clear_resize_widgets".}
-proc child_composite_name*(container: PContainer, child: PWidget): cstring{.
-    cdecl, dynlib: lib, importc: "_gtk_container_child_composite_name".}
-proc dequeue_resize_handler*(container: PContainer){.cdecl, 
-    dynlib: lib, importc: "_gtk_container_dequeue_resize_handler".}
-proc focus_sort*(container: PContainer, children: PGList, 
-                           direction: TDirectionType, old_focus: PWidget): PGList{.
-    cdecl, dynlib: lib, importc: "_gtk_container_focus_sort".}
-proc TYPE_BIN*(): GType
-proc BIN*(obj: pointer): PBin
-proc BIN_CLASS*(klass: pointer): PBinClass
-proc IS_BIN*(obj: pointer): bool
-proc IS_BIN_CLASS*(klass: pointer): bool
-proc BIN_GET_CLASS*(obj: pointer): PBinClass
-proc bin_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_bin_get_type".}
-proc get_child*(bin: PBin): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_bin_get_child".}
-const 
-  bm_TGtkWindow_allow_shrink* = 0x00000001'i32
-  bp_TGtkWindow_allow_shrink* = 0'i32
-  bm_TGtkWindow_allow_grow* = 0x00000002'i32
-  bp_TGtkWindow_allow_grow* = 1'i32
-  bm_TGtkWindow_configure_notify_received* = 0x00000004'i32
-  bp_TGtkWindow_configure_notify_received* = 2'i32
-  bm_TGtkWindow_need_default_position* = 0x00000008'i32
-  bp_TGtkWindow_need_default_position* = 3'i32
-  bm_TGtkWindow_need_default_size* = 0x00000010'i32
-  bp_TGtkWindow_need_default_size* = 4'i32
-  bm_TGtkWindow_position* = 0x000000E0'i32
-  bp_TGtkWindow_position* = 5'i32
-  bm_TGtkWindow_type* = 0x00000F00'i32
-  bp_TGtkWindow_type* = 8'i32
-  bm_TGtkWindow_has_user_ref_count* = 0x00001000'i32
-  bp_TGtkWindow_has_user_ref_count* = 12'i32
-  bm_TGtkWindow_has_focus* = 0x00002000'i32
-  bp_TGtkWindow_has_focus* = 13'i32
-  bm_TGtkWindow_modal* = 0x00004000'i32
-  bp_TGtkWindow_modal* = 14'i32
-  bm_TGtkWindow_destroy_with_parent* = 0x00008000'i32
-  bp_TGtkWindow_destroy_with_parent* = 15'i32
-  bm_TGtkWindow_has_frame* = 0x00010000'i32
-  bp_TGtkWindow_has_frame* = 16'i32
-  bm_TGtkWindow_iconify_initially* = 0x00020000'i32
-  bp_TGtkWindow_iconify_initially* = 17'i32
-  bm_TGtkWindow_stick_initially* = 0x00040000'i32
-  bp_TGtkWindow_stick_initially* = 18'i32
-  bm_TGtkWindow_maximize_initially* = 0x00080000'i32
-  bp_TGtkWindow_maximize_initially* = 19'i32
-  bm_TGtkWindow_decorated* = 0x00100000'i32
-  bp_TGtkWindow_decorated* = 20'i32
-  bm_TGtkWindow_type_hint* = 0x00E00000'i32
-  bp_TGtkWindow_type_hint* = 21'i32
-  bm_TGtkWindow_gravity* = 0x1F000000'i32
-  bp_TGtkWindow_gravity* = 24'i32
-
-proc TYPE_WINDOW*(): GType
-proc WINDOW*(obj: pointer): PWindow
-proc WINDOW_CLASS*(klass: pointer): PWindowClass
-proc IS_WINDOW*(obj: pointer): bool
-proc IS_WINDOW_CLASS*(klass: pointer): bool
-proc WINDOW_GET_CLASS*(obj: pointer): PWindowClass
-proc allow_shrink*(a: gtk2.PWindow): guint
-proc set_allow_shrink*(a: gtk2.PWindow, `allow_shrink`: guint)
-proc allow_grow*(a: gtk2.PWindow): guint
-proc set_allow_grow*(a: gtk2.PWindow, `allow_grow`: guint)
-proc configure_notify_received*(a: gtk2.PWindow): guint
-proc set_configure_notify_received*(a: gtk2.PWindow, 
-                                    `configure_notify_received`: guint)
-proc need_default_position*(a: gtk2.PWindow): guint
-proc set_need_default_position*(a: gtk2.PWindow, `need_default_position`: guint)
-proc need_default_size*(a: gtk2.PWindow): guint
-proc set_need_default_size*(a: gtk2.PWindow, `need_default_size`: guint)
-proc position*(a: gtk2.PWindow): guint
-proc set_position*(a: gtk2.PWindow, `position`: guint)
-proc get_type*(a: gtk2.PWindow): guint
-proc set_type*(a: gtk2.PWindow, `type`: guint)
-proc has_user_ref_count*(a: gtk2.PWindow): guint
-proc set_has_user_ref_count*(a: gtk2.PWindow, `has_user_ref_count`: guint)
-proc has_focus*(a: gtk2.PWindow): guint
-proc set_has_focus*(a: gtk2.PWindow, `has_focus`: guint)
-proc modal*(a: gtk2.PWindow): guint
-proc set_modal*(a: gtk2.PWindow, `modal`: guint)
-proc destroy_with_parent*(a: gtk2.PWindow): guint
-proc set_destroy_with_parent*(a: gtk2.PWindow, `destroy_with_parent`: guint)
-proc has_frame*(a: gtk2.PWindow): guint
-proc set_has_frame*(a: gtk2.PWindow, `has_frame`: guint)
-proc iconify_initially*(a: gtk2.PWindow): guint
-proc set_iconify_initially*(a: gtk2.PWindow, `iconify_initially`: guint)
-proc stick_initially*(a: gtk2.PWindow): guint
-proc set_stick_initially*(a: gtk2.PWindow, `stick_initially`: guint)
-proc maximize_initially*(a: gtk2.PWindow): guint
-proc set_maximize_initially*(a: gtk2.PWindow, `maximize_initially`: guint)
-proc decorated*(a: gtk2.PWindow): guint
-proc set_decorated*(a: gtk2.PWindow, `decorated`: guint)
-proc type_hint*(a: gtk2.PWindow): guint
-proc set_type_hint*(a: gtk2.PWindow, `type_hint`: guint)
-proc gravity*(a: gtk2.PWindow): guint
-proc set_gravity*(a: gtk2.PWindow, `gravity`: guint)
-proc TYPE_WINDOW_GROUP*(): GType
-proc WINDOW_GROUP*(anObject: pointer): PWindowGroup
-proc WINDOW_GROUP_CLASS*(klass: pointer): PWindowGroupClass
-proc IS_WINDOW_GROUP*(anObject: pointer): bool
-proc IS_WINDOW_GROUP_CLASS*(klass: pointer): bool
-proc WINDOW_GROUP_GET_CLASS*(obj: pointer): PWindowGroupClass
-proc window_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_window_get_type".}
-proc window_new*(thetype: TWindowType): PWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_window_new".}
-proc set_title*(window: PWindow, title: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_title".}
-proc get_title*(window: PWindow): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_title".}
-proc set_wmclass*(window: PWindow, wmclass_name: cstring, 
-                         wmclass_class: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_wmclass".}
-proc set_role*(window: PWindow, role: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_role".}
-proc get_role*(window: PWindow): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_role".}
-proc add_accel_group*(window: PWindow, accel_group: PAccelGroup){.cdecl, 
-    dynlib: lib, importc: "gtk_window_add_accel_group".}
-proc remove_accel_group*(window: PWindow, accel_group: PAccelGroup){.
-    cdecl, dynlib: lib, importc: "gtk_window_remove_accel_group".}
-proc set_position*(window: PWindow, position: TWindowPosition){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_position".}
-proc activate_focus*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_activate_focus".}
-proc set_focus*(window: PWindow, focus: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_focus".}
-proc get_focus*(window: PWindow): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_focus".}
-proc set_default*(window: PWindow, default_widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_default".}
-proc activate_default*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_activate_default".}
-proc set_transient_for*(window: PWindow, parent: PWindow){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_transient_for".}
-proc get_transient_for*(window: PWindow): PWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_transient_for".}
-proc set_type_hint*(window: PWindow, hint: gdk2.TWindowTypeHint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_type_hint".}
-proc get_type_hint*(window: PWindow): gdk2.TWindowTypeHint{.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_type_hint".}
-proc set_destroy_with_parent*(window: PWindow, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_destroy_with_parent".}
-proc get_destroy_with_parent*(window: PWindow): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_destroy_with_parent".}
-proc set_resizable*(window: PWindow, resizable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_resizable".}
-proc get_resizable*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_resizable".}
-proc set_gravity*(window: PWindow, gravity: gdk2.TGravity){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_gravity".}
-proc get_gravity*(window: PWindow): gdk2.TGravity{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_gravity".}
-proc set_geometry_hints*(window: PWindow, geometry_widget: PWidget, 
-                                geometry: gdk2.PGeometry, 
-                                geom_mask: gdk2.TWindowHints){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_geometry_hints".}
-proc set_screen*(window: PWindow, screen: gdk2.PScreen){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_screen".}
-proc get_screen*(window: PWindow): gdk2.PScreen{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_screen".}
-proc set_has_frame*(window: PWindow, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_has_frame".}
-proc get_has_frame*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_has_frame".}
-proc set_frame_dimensions*(window: PWindow, left: gint, top: gint, 
-                                  right: gint, bottom: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_frame_dimensions".}
-proc get_frame_dimensions*(window: PWindow, left: Pgint, top: Pgint, 
-                                  right: Pgint, bottom: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_frame_dimensions".}
-proc set_decorated*(window: PWindow, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_window_set_decorated".}
-proc get_decorated*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_decorated".}
-proc set_icon_list*(window: PWindow, list: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_icon_list".}
-proc get_icon_list*(window: PWindow): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_icon_list".}
-proc set_icon*(window: PWindow, icon: gdk2pixbuf.PPixbuf){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_icon".}
-proc get_icon*(window: PWindow): gdk2pixbuf.PPixbuf{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_icon".}
-proc window_set_default_icon_list*(list: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_default_icon_list".}
-proc window_get_default_icon_list*(): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_default_icon_list".}
-proc set_modal*(window: PWindow, modal: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_modal".}
-proc get_modal*(window: PWindow): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_window_get_modal".}
-proc window_list_toplevels*(): PGList{.cdecl, dynlib: lib, 
-                                       importc: "gtk_window_list_toplevels".}
-proc add_mnemonic*(window: PWindow, keyval: guint, target: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_window_add_mnemonic".}
-proc remove_mnemonic*(window: PWindow, keyval: guint, target: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_window_remove_mnemonic".}
-proc mnemonic_activate*(window: PWindow, keyval: guint, 
-                               modifier: gdk2.TModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_window_mnemonic_activate".}
-proc set_mnemonic_modifier*(window: PWindow, modifier: gdk2.TModifierType){.
-    cdecl, dynlib: lib, importc: "gtk_window_set_mnemonic_modifier".}
-proc get_mnemonic_modifier*(window: PWindow): gdk2.TModifierType{.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_mnemonic_modifier".}
-proc present*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gtk_window_present".}
-proc iconify*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gtk_window_iconify".}
-proc deiconify*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gtk_window_deiconify".}
-proc stick*(window: PWindow){.cdecl, dynlib: lib, 
-                                     importc: "gtk_window_stick".}
-proc unstick*(window: PWindow){.cdecl, dynlib: lib, 
-                                       importc: "gtk_window_unstick".}
-proc maximize*(window: PWindow){.cdecl, dynlib: lib, 
-                                        importc: "gtk_window_maximize".}
-proc unmaximize*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gtk_window_unmaximize".}
-proc begin_resize_drag*(window: PWindow, edge: gdk2.TWindowEdge, 
-                               button: gint, root_x: gint, root_y: gint, 
-                               timestamp: guint32){.cdecl, dynlib: lib, 
-    importc: "gtk_window_begin_resize_drag".}
-proc begin_move_drag*(window: PWindow, button: gint, root_x: gint, 
-                             root_y: gint, timestamp: guint32){.cdecl, 
-    dynlib: lib, importc: "gtk_window_begin_move_drag".}
-proc set_default_size*(window: PWindow, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gtk_window_set_default_size".}
-proc get_default_size*(window: PWindow, width: Pgint, height: Pgint){.
-    cdecl, dynlib: lib, importc: "gtk_window_get_default_size".}
-proc resize*(window: PWindow, width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_resize".}
-proc get_size*(window: PWindow, width: Pgint, height: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_size".}
-proc move*(window: PWindow, x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_window_move".}
-proc get_position*(window: PWindow, root_x: Pgint, root_y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_get_position".}
-proc parse_geometry*(window: PWindow, geometry: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_window_parse_geometry".}
-proc reshow_with_initial_size*(window: PWindow){.cdecl, dynlib: lib, 
-    importc: "gtk_window_reshow_with_initial_size".}
-proc window_group_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_window_group_get_type".}
-proc window_group_new*(): PWindowGroup{.cdecl, dynlib: lib, 
-                                        importc: "gtk_window_group_new".}
-proc add_window*(window_group: PWindowGroup, window: PWindow){.
-    cdecl, dynlib: lib, importc: "gtk_window_group_add_window".}
-proc remove_window*(window_group: PWindowGroup, window: PWindow){.
-    cdecl, dynlib: lib, importc: "gtk_window_group_remove_window".}
-proc window_set_default_icon_name*(name: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_window_set_default_icon_name".}
-proc internal_set_focus*(window: PWindow, focus: PWidget){.cdecl, 
-    dynlib: lib, importc: "_gtk_window_internal_set_focus".}
-proc remove_embedded_xid*(window: PWindow, xid: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_window_remove_embedded_xid".}
-proc add_embedded_xid*(window: PWindow, xid: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_window_add_embedded_xid".}
-proc reposition*(window: PWindow, x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "_gtk_window_reposition".}
-proc constrain_size*(window: PWindow, width: gint, height: gint, 
-                            new_width: Pgint, new_height: Pgint){.cdecl, 
-    dynlib: lib, importc: "_gtk_window_constrain_size".}
-proc get_group*(window: PWindow): PWindowGroup{.cdecl, dynlib: lib, 
-    importc: "_gtk_window_get_group".}
-proc activate_key*(window: PWindow, event: gdk2.PEventKey): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_window_activate_key".}
-proc keys_foreach*(window: PWindow, func: TWindowKeysForeachFunc, 
-                          func_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "_gtk_window_keys_foreach".}
-proc query_nonaccels*(window: PWindow, accel_key: guint, 
-                             accel_mods: gdk2.TModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_window_query_nonaccels".}
-const 
-  bm_TGtkLabel_jtype* = 0x0003'i16
-  bp_TGtkLabel_jtype* = 0'i16
-  bm_TGtkLabel_wrap* = 0x0004'i16
-  bp_TGtkLabel_wrap* = 2'i16
-  bm_TGtkLabel_use_underline* = 0x0008'i16
-  bp_TGtkLabel_use_underline* = 3'i16
-  bm_TGtkLabel_use_markup* = 0x0010'i16
-  bp_TGtkLabel_use_markup* = 4'i16
-
-proc TYPE_LABEL*(): GType
-proc LABEL*(obj: pointer): PLabel
-proc LABEL_CLASS*(klass: pointer): PLabelClass
-proc IS_LABEL*(obj: pointer): bool
-proc IS_LABEL_CLASS*(klass: pointer): bool
-proc LABEL_GET_CLASS*(obj: pointer): PLabelClass
-proc jtype*(a: PLabel): guint
-proc set_jtype*(a: PLabel, `jtype`: guint)
-proc wrap*(a: PLabel): guint
-proc set_wrap*(a: PLabel, `wrap`: guint)
-proc use_underline*(a: PLabel): guint
-proc set_use_underline*(a: PLabel, `use_underline`: guint)
-proc use_markup*(a: PLabel): guint
-proc set_use_markup*(a: PLabel, `use_markup`: guint)
-proc label_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_label_get_type".}
-proc label_new*(str: cstring): PLabel{.cdecl, dynlib: lib, 
-                                       importc: "gtk_label_new".}
-proc label_new_with_mnemonic*(str: cstring): PLabel{.cdecl, dynlib: lib, 
-    importc: "gtk_label_new_with_mnemonic".}
-proc set_text*(`label`: PLabel, str: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_label_set_text".}
-proc get_text*(`label`: PLabel): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_text".}
-proc set_attributes*(`label`: PLabel, attrs: pango.PAttrList){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_attributes".}
-proc get_attributes*(`label`: PLabel): pango.PAttrList{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_attributes".}
-proc set_label*(`label`: PLabel, str: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_label_set_label".}
-proc get_label*(`label`: PLabel): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_label".}
-proc set_markup*(`label`: PLabel, str: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_label_set_markup".}
-proc set_use_markup*(`label`: PLabel, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_use_markup".}
-proc get_use_markup*(`label`: PLabel): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_use_markup".}
-proc set_use_underline*(`label`: PLabel, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_use_underline".}
-proc get_use_underline*(`label`: PLabel): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_use_underline".}
-proc set_markup_with_mnemonic*(`label`: PLabel, str: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_markup_with_mnemonic".}
-proc get_mnemonic_keyval*(`label`: PLabel): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_mnemonic_keyval".}
-proc set_mnemonic_widget*(`label`: PLabel, widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_mnemonic_widget".}
-proc get_mnemonic_widget*(`label`: PLabel): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_mnemonic_widget".}
-proc set_text_with_mnemonic*(`label`: PLabel, str: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_text_with_mnemonic".}
-proc set_justify*(`label`: PLabel, jtype: TJustification){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_justify".}
-proc get_justify*(`label`: PLabel): TJustification{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_justify".}
-proc set_pattern*(`label`: PLabel, pattern: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_label_set_pattern".}
-proc set_line_wrap*(`label`: PLabel, wrap: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_label_set_line_wrap".}
-proc get_line_wrap*(`label`: PLabel): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_line_wrap".}
-proc set_selectable*(`label`: PLabel, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_label_set_selectable".}
-proc get_selectable*(`label`: PLabel): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_selectable".}
-proc select_region*(`label`: PLabel, start_offset: gint, end_offset: gint){.
-    cdecl, dynlib: lib, importc: "gtk_label_select_region".}
-proc get_selection_bounds*(`label`: PLabel, start: Pgint, theEnd: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_label_get_selection_bounds".}
-proc get_layout*(`label`: PLabel): pango.PLayout{.cdecl, dynlib: lib, 
-    importc: "gtk_label_get_layout".}
-proc get_layout_offsets*(`label`: PLabel, x: Pgint, y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_label_get_layout_offsets".}
-const 
-  bm_TGtkAccelLabelClass_latin1_to_char* = 0x0001'i16
-  bp_TGtkAccelLabelClass_latin1_to_char* = 0'i16
-
-proc TYPE_ACCEL_LABEL*(): GType
-proc ACCEL_LABEL*(obj: pointer): PAccelLabel
-proc ACCEL_LABEL_CLASS*(klass: pointer): PAccelLabelClass
-proc IS_ACCEL_LABEL*(obj: pointer): bool
-proc IS_ACCEL_LABEL_CLASS*(klass: pointer): bool
-proc ACCEL_LABEL_GET_CLASS*(obj: pointer): PAccelLabelClass
-proc latin1_to_char*(a: PAccelLabelClass): guint
-proc set_latin1_to_char*(a: PAccelLabelClass, `latin1_to_char`: guint)
-proc accel_label_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_accel_label_get_type".}
-proc accel_label_new*(`string`: cstring): PAccelLabel{.cdecl, dynlib: lib, 
-    importc: "gtk_accel_label_new".}
-proc get_accel_widget*(accel_label: PAccelLabel): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_label_get_accel_widget".}
-proc get_accel_width*(accel_label: PAccelLabel): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_label_get_accel_width".}
-proc set_accel_widget*(accel_label: PAccelLabel, 
-                                   accel_widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_label_set_accel_widget".}
-proc set_accel_closure*(accel_label: PAccelLabel, 
-                                    accel_closure: PGClosure){.cdecl, 
-    dynlib: lib, importc: "gtk_accel_label_set_accel_closure".}
-proc refetch*(accel_label: PAccelLabel): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_accel_label_refetch".}
-proc accel_map_add_entry*(accel_path: cstring, accel_key: guint, 
-                          accel_mods: gdk2.TModifierType){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_map_add_entry".}
-proc accel_map_lookup_entry*(accel_path: cstring, key: PAccelKey): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_accel_map_lookup_entry".}
-proc accel_map_change_entry*(accel_path: cstring, accel_key: guint, 
-                             accel_mods: gdk2.TModifierType, replace: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_accel_map_change_entry".}
-proc accel_map_load*(file_name: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_map_load".}
-proc accel_map_save*(file_name: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_map_save".}
-proc accel_map_foreach*(data: gpointer, foreach_func: TAccelMapForeach){.cdecl, 
-    dynlib: lib, importc: "gtk_accel_map_foreach".}
-proc accel_map_load_fd*(fd: gint){.cdecl, dynlib: lib, 
-                                   importc: "gtk_accel_map_load_fd".}
-proc accel_map_load_scanner*(scanner: PGScanner){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_map_load_scanner".}
-proc accel_map_save_fd*(fd: gint){.cdecl, dynlib: lib, 
-                                   importc: "gtk_accel_map_save_fd".}
-proc accel_map_add_filter*(filter_pattern: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_accel_map_add_filter".}
-proc accel_map_foreach_unfiltered*(data: gpointer, 
-                                   foreach_func: TAccelMapForeach){.cdecl, 
-    dynlib: lib, importc: "gtk_accel_map_foreach_unfiltered".}
-proc accel_map_init*(){.cdecl, dynlib: lib, importc: "_gtk_accel_map_init".}
-proc accel_map_add_group*(accel_path: cstring, accel_group: PAccelGroup){.cdecl, 
-    dynlib: lib, importc: "_gtk_accel_map_add_group".}
-proc accel_map_remove_group*(accel_path: cstring, accel_group: PAccelGroup){.
-    cdecl, dynlib: lib, importc: "_gtk_accel_map_remove_group".}
-proc accel_path_is_valid*(accel_path: cstring): gboolean{.cdecl, dynlib: lib, 
-    importc: "_gtk_accel_path_is_valid".}
-proc TYPE_ACCESSIBLE*(): GType
-proc ACCESSIBLE*(obj: pointer): PAccessible
-proc ACCESSIBLE_CLASS*(klass: pointer): PAccessibleClass
-proc IS_ACCESSIBLE*(obj: pointer): bool
-proc IS_ACCESSIBLE_CLASS*(klass: pointer): bool
-proc ACCESSIBLE_GET_CLASS*(obj: pointer): PAccessibleClass
-proc accessible_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_accessible_get_type".}
-proc connect_widget_destroyed*(accessible: PAccessible){.cdecl, 
-    dynlib: lib, importc: "gtk_accessible_connect_widget_destroyed".}
-proc TYPE_ADJUSTMENT*(): GType
-proc ADJUSTMENT*(obj: pointer): PAdjustment
-proc ADJUSTMENT_CLASS*(klass: pointer): PAdjustmentClass
-proc IS_ADJUSTMENT*(obj: pointer): bool
-proc IS_ADJUSTMENT_CLASS*(klass: pointer): bool
-proc ADJUSTMENT_GET_CLASS*(obj: pointer): PAdjustmentClass
-proc adjustment_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_adjustment_get_type".}
-proc adjustment_new*(value: gdouble, lower: gdouble, upper: gdouble, 
-                     step_increment: gdouble, page_increment: gdouble, 
-                     page_size: gdouble): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_adjustment_new".}
-proc changed*(adjustment: PAdjustment){.cdecl, dynlib: lib, 
-    importc: "gtk_adjustment_changed".}
-proc value_changed*(adjustment: PAdjustment){.cdecl, dynlib: lib, 
-    importc: "gtk_adjustment_value_changed".}
-proc clamp_page*(adjustment: PAdjustment, lower: gdouble, 
-                            upper: gdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_adjustment_clamp_page".}
-proc get_value*(adjustment: PAdjustment): gdouble{.cdecl, 
-    dynlib: lib, importc: "gtk_adjustment_get_value".}
-proc set_value*(adjustment: PAdjustment, value: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_adjustment_set_value".}
-proc TYPE_ALIGNMENT*(): GType
-proc ALIGNMENT*(obj: pointer): PAlignment
-proc ALIGNMENT_CLASS*(klass: pointer): PAlignmentClass
-proc IS_ALIGNMENT*(obj: pointer): bool
-proc IS_ALIGNMENT_CLASS*(klass: pointer): bool
-proc ALIGNMENT_GET_CLASS*(obj: pointer): PAlignmentClass
-proc alignment_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_alignment_get_type".}
-proc alignment_new*(xalign: gfloat, yalign: gfloat, xscale: gfloat, 
-                    yscale: gfloat): PAlignment{.cdecl, dynlib: lib, 
-    importc: "gtk_alignment_new".}
-proc set*(alignment: PAlignment, xalign: gfloat, yalign: gfloat, 
-                    xscale: gfloat, yscale: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_alignment_set".}
-proc TYPE_FRAME*(): GType
-proc FRAME*(obj: pointer): PFrame
-proc FRAME_CLASS*(klass: pointer): PFrameClass
-proc IS_FRAME*(obj: pointer): bool
-proc IS_FRAME_CLASS*(klass: pointer): bool
-proc FRAME_GET_CLASS*(obj: pointer): PFrameClass
-proc frame_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_frame_get_type".}
-proc frame_new*(`label`: cstring): PFrame{.cdecl, dynlib: lib, 
-    importc: "gtk_frame_new".}
-proc set_label*(frame: PFrame, `label`: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_frame_set_label".}
-proc get_label*(frame: PFrame): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_frame_get_label".}
-proc set_label_widget*(frame: PFrame, label_widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_frame_set_label_widget".}
-proc get_label_widget*(frame: PFrame): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_frame_get_label_widget".}
-proc set_label_align*(frame: PFrame, xalign: gfloat, yalign: gfloat){.
-    cdecl, dynlib: lib, importc: "gtk_frame_set_label_align".}
-proc get_label_align*(frame: PFrame, xalign: Pgfloat, yalign: Pgfloat){.
-    cdecl, dynlib: lib, importc: "gtk_frame_get_label_align".}
-proc set_shadow_type*(frame: PFrame, thetype: TShadowType){.cdecl, 
-    dynlib: lib, importc: "gtk_frame_set_shadow_type".}
-proc get_shadow_type*(frame: PFrame): TShadowType{.cdecl, dynlib: lib, 
-    importc: "gtk_frame_get_shadow_type".}
-proc TYPE_ASPECT_FRAME*(): GType
-proc ASPECT_FRAME*(obj: pointer): PAspectFrame
-proc ASPECT_FRAME_CLASS*(klass: pointer): PAspectFrameClass
-proc IS_ASPECT_FRAME*(obj: pointer): bool
-proc IS_ASPECT_FRAME_CLASS*(klass: pointer): bool
-proc ASPECT_FRAME_GET_CLASS*(obj: pointer): PAspectFrameClass
-proc aspect_frame_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_aspect_frame_get_type".}
-proc aspect_frame_new*(`label`: cstring, xalign: gfloat, yalign: gfloat, 
-                       ratio: gfloat, obey_child: gboolean): PAspectFrame{.
-    cdecl, dynlib: lib, importc: "gtk_aspect_frame_new".}
-proc set*(aspect_frame: PAspectFrame, xalign: gfloat, 
-                       yalign: gfloat, ratio: gfloat, obey_child: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_aspect_frame_set".}
-proc TYPE_ARROW*(): GType
-proc ARROW*(obj: pointer): PArrow
-proc ARROW_CLASS*(klass: pointer): PArrowClass
-proc IS_ARROW*(obj: pointer): bool
-proc IS_ARROW_CLASS*(klass: pointer): bool
-proc ARROW_GET_CLASS*(obj: pointer): PArrowClass
-proc arrow_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_arrow_get_type".}
-proc arrow_new*(arrow_type: TArrowType, shadow_type: TShadowType): PArrow{.
-    cdecl, dynlib: lib, importc: "gtk_arrow_new".}
-proc set*(arrow: PArrow, arrow_type: TArrowType, shadow_type: TShadowType){.
-    cdecl, dynlib: lib, importc: "gtk_arrow_set".}
-const 
-  bm_TGtkBindingSet_parsed* = 0x0001'i16
-  bp_TGtkBindingSet_parsed* = 0'i16
-  bm_TGtkBindingEntry_destroyed* = 0x0001'i16
-  bp_TGtkBindingEntry_destroyed* = 0'i16
-  bm_TGtkBindingEntry_in_emission* = 0x0002'i16
-  bp_TGtkBindingEntry_in_emission* = 1'i16
-
-proc entry_add*(binding_set: PBindingSet, keyval: guint, 
-                        modifiers: gdk2.TModifierType)
-proc parsed*(a: PBindingSet): guint
-proc set_parsed*(a: PBindingSet, `parsed`: guint)
-proc destroyed*(a: PBindingEntry): guint
-proc set_destroyed*(a: PBindingEntry, `destroyed`: guint)
-proc in_emission*(a: PBindingEntry): guint
-proc set_in_emission*(a: PBindingEntry, `in_emission`: guint)
-proc binding_set_new*(set_name: cstring): PBindingSet{.cdecl, dynlib: lib, 
-    importc: "gtk_binding_set_new".}
-proc binding_set_by_class*(object_class: gpointer): PBindingSet{.cdecl, 
-    dynlib: lib, importc: "gtk_binding_set_by_class".}
-proc binding_set_find*(set_name: cstring): PBindingSet{.cdecl, dynlib: lib, 
-    importc: "gtk_binding_set_find".}
-proc bindings_activate*(anObject: PObject, keyval: guint, 
-                        modifiers: gdk2.TModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_bindings_activate".}
-proc activate*(binding_set: PBindingSet, keyval: guint, 
-                           modifiers: gdk2.TModifierType, anObject: PObject): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_binding_set_activate".}
-proc entry_clear*(binding_set: PBindingSet, keyval: guint, 
-                          modifiers: gdk2.TModifierType){.cdecl, dynlib: lib, 
-    importc: "gtk_binding_entry_clear".}
-proc add_path*(binding_set: PBindingSet, path_type: TPathType, 
-                           path_pattern: cstring, priority: TPathPriorityType){.
-    cdecl, dynlib: lib, importc: "gtk_binding_set_add_path".}
-proc entry_remove*(binding_set: PBindingSet, keyval: guint, 
-                           modifiers: gdk2.TModifierType){.cdecl, dynlib: lib, 
-    importc: "gtk_binding_entry_remove".}
-proc entry_add_signall*(binding_set: PBindingSet, keyval: guint, 
-                                modifiers: gdk2.TModifierType, 
-                                signal_name: cstring, binding_args: PGSList){.
-    cdecl, dynlib: lib, importc: "gtk_binding_entry_add_signall".}
-proc binding_parse_binding*(scanner: PGScanner): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_binding_parse_binding".}
-proc bindings_activate_event*(anObject: PObject, event: gdk2.PEventKey): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_bindings_activate_event".}
-proc binding_reset_parsed*(){.cdecl, dynlib: lib, 
-                              importc: "_gtk_binding_reset_parsed".}
-const 
-  bm_TGtkBox_homogeneous* = 0x0001'i16
-  bp_TGtkBox_homogeneous* = 0'i16
-  bm_TGtkBoxChild_expand* = 0x0001'i16
-  bp_TGtkBoxChild_expand* = 0'i16
-  bm_TGtkBoxChild_fill* = 0x0002'i16
-  bp_TGtkBoxChild_fill* = 1'i16
-  bm_TGtkBoxChild_pack* = 0x0004'i16
-  bp_TGtkBoxChild_pack* = 2'i16
-  bm_TGtkBoxChild_is_secondary* = 0x0008'i16
-  bp_TGtkBoxChild_is_secondary* = 3'i16
-
-proc TYPE_BOX*(): GType
-proc BOX*(obj: pointer): PBox
-proc BOX_CLASS*(klass: pointer): PBoxClass
-proc IS_BOX*(obj: pointer): bool
-proc IS_BOX_CLASS*(klass: pointer): bool
-proc BOX_GET_CLASS*(obj: pointer): PBoxClass
-proc homogeneous*(a: PBox): guint
-proc set_homogeneous*(a: PBox, `homogeneous`: guint)
-proc expand*(a: PBoxChild): guint
-proc set_expand*(a: PBoxChild, `expand`: guint)
-proc fill*(a: PBoxChild): guint
-proc set_fill*(a: PBoxChild, `fill`: guint)
-proc pack*(a: PBoxChild): guint
-proc set_pack*(a: PBoxChild, `pack`: guint)
-proc is_secondary*(a: PBoxChild): guint
-proc set_is_secondary*(a: PBoxChild, `is_secondary`: guint)
-proc box_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_box_get_type".}
-proc pack_start*(box: PBox, child: PWidget, expand: gboolean, 
-                     fill: gboolean, padding: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_box_pack_start".}
-proc pack_end*(box: PBox, child: PWidget, expand: gboolean, fill: gboolean, 
-                   padding: guint){.cdecl, dynlib: lib, 
-                                    importc: "gtk_box_pack_end".}
-proc pack_start_defaults*(box: PBox, widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_box_pack_start_defaults".}
-proc pack_end_defaults*(box: PBox, widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_box_pack_end_defaults".}
-proc set_homogeneous*(box: PBox, homogeneous: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_box_set_homogeneous".}
-proc get_homogeneous*(box: PBox): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_box_get_homogeneous".}
-proc set_spacing*(box: PBox, spacing: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_box_set_spacing".}
-proc get_spacing*(box: PBox): gint{.cdecl, dynlib: lib, 
-                                        importc: "gtk_box_get_spacing".}
-proc reorder_child*(box: PBox, child: PWidget, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_box_reorder_child".}
-proc query_child_packing*(box: PBox, child: PWidget, expand: Pgboolean, 
-                              fill: Pgboolean, padding: Pguint, 
-                              pack_type: PPackType){.cdecl, dynlib: lib, 
-    importc: "gtk_box_query_child_packing".}
-proc set_child_packing*(box: PBox, child: PWidget, expand: gboolean, 
-                            fill: gboolean, padding: guint, pack_type: TPackType){.
-    cdecl, dynlib: lib, importc: "gtk_box_set_child_packing".}
-const 
-  BUTTONBOX_DEFAULT* = - (1)
-
-proc TYPE_BUTTON_BOX*(): GType
-proc BUTTON_BOX*(obj: pointer): PButtonBox
-proc BUTTON_BOX_CLASS*(klass: pointer): PButtonBoxClass
-proc IS_BUTTON_BOX*(obj: pointer): bool
-proc IS_BUTTON_BOX_CLASS*(klass: pointer): bool
-proc BUTTON_BOX_GET_CLASS*(obj: pointer): PButtonBoxClass
-proc button_box_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_button_box_get_type".}
-proc get_layout*(widget: PButtonBox): TButtonBoxStyle{.cdecl, 
-    dynlib: lib, importc: "gtk_button_box_get_layout".}
-proc set_layout*(widget: PButtonBox, layout_style: TButtonBoxStyle){.
-    cdecl, dynlib: lib, importc: "gtk_button_box_set_layout".}
-proc set_child_secondary*(widget: PButtonBox, child: PWidget, 
-                                     is_secondary: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_button_box_set_child_secondary".}
-proc button_box_child_requisition*(widget: PWidget, nvis_children: var int32, 
-                                   nvis_secondaries: var int32, 
-                                   width: var int32, height: var int32){.cdecl, 
-    dynlib: lib, importc: "_gtk_button_box_child_requisition".}
-const 
-  bm_TGtkButton_constructed* = 0x0001'i16
-  bp_TGtkButton_constructed* = 0'i16
-  bm_TGtkButton_in_button* = 0x0002'i16
-  bp_TGtkButton_in_button* = 1'i16
-  bm_TGtkButton_button_down* = 0x0004'i16
-  bp_TGtkButton_button_down* = 2'i16
-  bm_TGtkButton_relief* = 0x0018'i16
-  bp_TGtkButton_relief* = 3'i16
-  bm_TGtkButton_use_underline* = 0x0020'i16
-  bp_TGtkButton_use_underline* = 5'i16
-  bm_TGtkButton_use_stock* = 0x0040'i16
-  bp_TGtkButton_use_stock* = 6'i16
-  bm_TGtkButton_depressed* = 0x0080'i16
-  bp_TGtkButton_depressed* = 7'i16
-  bm_TGtkButton_depress_on_activate* = 0x0100'i16
-  bp_TGtkButton_depress_on_activate* = 8'i16
-
-proc TYPE_BUTTON*(): GType
-proc BUTTON*(obj: pointer): PButton
-proc BUTTON_CLASS*(klass: pointer): PButtonClass
-proc IS_BUTTON*(obj: pointer): bool
-proc IS_BUTTON_CLASS*(klass: pointer): bool
-proc BUTTON_GET_CLASS*(obj: pointer): PButtonClass
-proc constructed*(a: PButton): guint
-proc set_constructed*(a: PButton, `constructed`: guint)
-proc in_button*(a: PButton): guint
-proc set_in_button*(a: PButton, `in_button`: guint)
-proc button_down*(a: PButton): guint
-proc set_button_down*(a: PButton, `button_down`: guint)
-proc relief*(a: PButton): guint
-proc use_underline*(a: PButton): guint
-proc set_use_underline*(a: PButton, `use_underline`: guint)
-proc use_stock*(a: PButton): guint
-proc set_use_stock*(a: PButton, `use_stock`: guint)
-proc depressed*(a: PButton): guint
-proc set_depressed*(a: PButton, `depressed`: guint)
-proc depress_on_activate*(a: PButton): guint
-proc set_depress_on_activate*(a: PButton, `depress_on_activate`: guint)
-proc button_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_button_get_type".}
-proc button_new*(): PButton{.cdecl, dynlib: lib, importc: "gtk_button_new".}
-proc button_new*(`label`: cstring): PButton{.cdecl, dynlib: lib, 
-    importc: "gtk_button_new_with_label".}
-proc button_new_from_stock*(stock_id: cstring): PButton{.cdecl, dynlib: lib, 
-    importc: "gtk_button_new_from_stock".}
-proc button_new_with_mnemonic*(`label`: cstring): PButton{.cdecl, dynlib: lib, 
-    importc: "gtk_button_new_with_mnemonic".}
-proc pressed*(button: PButton){.cdecl, dynlib: lib, 
-                                       importc: "gtk_button_pressed".}
-proc released*(button: PButton){.cdecl, dynlib: lib, 
-                                        importc: "gtk_button_released".}
-proc clicked*(button: PButton){.cdecl, dynlib: lib, 
-                                       importc: "gtk_button_clicked".}
-proc enter*(button: PButton){.cdecl, dynlib: lib, 
-                                     importc: "gtk_button_enter".}
-proc leave*(button: PButton){.cdecl, dynlib: lib, 
-                                     importc: "gtk_button_leave".}
-proc set_relief*(button: PButton, newstyle: TReliefStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_button_set_relief".}
-proc get_relief*(button: PButton): TReliefStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_button_get_relief".}
-proc set_label*(button: PButton, `label`: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_button_set_label".}
-proc get_label*(button: PButton): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_button_get_label".}
-proc set_use_underline*(button: PButton, use_underline: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_button_set_use_underline".}
-proc get_use_underline*(button: PButton): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_button_get_use_underline".}
-proc set_use_stock*(button: PButton, use_stock: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_button_set_use_stock".}
-proc get_use_stock*(button: PButton): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_button_get_use_stock".}
-proc set_depressed*(button: PButton, depressed: gboolean){.cdecl, 
-    dynlib: lib, importc: "_gtk_button_set_depressed".}
-proc paint*(button: PButton, area: gdk2.PRectangle, state_type: TStateType, 
-                   shadow_type: TShadowType, main_detail: cstring, 
-                   default_detail: cstring){.cdecl, dynlib: lib, 
-    importc: "_gtk_button_paint".}
-proc set_image*(button: PButton, image: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_button_set_image".}
-proc get_image*(button: PButton): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_button_get_image".}
-const 
-  CALENDAR_SHOW_HEADING* = 1 shl 0
-  CALENDAR_SHOW_DAY_NAMES* = 1 shl 1
-  CALENDAR_NO_MONTH_CHANGE* = 1 shl 2
-  CALENDAR_SHOW_WEEK_NUMBERS* = 1 shl 3
-  CALENDAR_WEEK_START_MONDAY* = 1 shl 4
-
-proc TYPE_CALENDAR*(): GType
-proc CALENDAR*(obj: pointer): PCalendar
-proc CALENDAR_CLASS*(klass: pointer): PCalendarClass
-proc IS_CALENDAR*(obj: pointer): bool
-proc IS_CALENDAR_CLASS*(klass: pointer): bool
-proc CALENDAR_GET_CLASS*(obj: pointer): PCalendarClass
-proc calendar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_calendar_get_type".}
-proc calendar_new*(): PCalendar{.cdecl, dynlib: lib, importc: "gtk_calendar_new".}
-proc select_month*(calendar: PCalendar, month: guint, year: guint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_calendar_select_month".}
-proc select_day*(calendar: PCalendar, day: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_calendar_select_day".}
-proc mark_day*(calendar: PCalendar, day: guint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_calendar_mark_day".}
-proc unmark_day*(calendar: PCalendar, day: guint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_calendar_unmark_day".}
-proc clear_marks*(calendar: PCalendar){.cdecl, dynlib: lib, 
-    importc: "gtk_calendar_clear_marks".}
-proc display_options*(calendar: PCalendar, 
-                               flags: TCalendarDisplayOptions){.cdecl, 
-    dynlib: lib, importc: "gtk_calendar_display_options".}
-proc get_date*(calendar: PCalendar, year: Pguint, month: Pguint, 
-                        day: Pguint){.cdecl, dynlib: lib, 
-                                      importc: "gtk_calendar_get_date".}
-proc freeze*(calendar: PCalendar){.cdecl, dynlib: lib, 
-    importc: "gtk_calendar_freeze".}
-proc thaw*(calendar: PCalendar){.cdecl, dynlib: lib, 
-    importc: "gtk_calendar_thaw".}
-proc TYPE_CELL_EDITABLE*(): GType
-proc CELL_EDITABLE*(obj: pointer): PCellEditable
-proc CELL_EDITABLE_CLASS*(obj: pointer): PCellEditableIface
-proc IS_CELL_EDITABLE*(obj: pointer): bool
-proc CELL_EDITABLE_GET_IFACE*(obj: pointer): PCellEditableIface
-proc cell_editable_get_type*(): GType{.cdecl, dynlib: lib, 
-                                       importc: "gtk_cell_editable_get_type".}
-proc start_editing*(cell_editable: PCellEditable, event: gdk2.PEvent){.
-    cdecl, dynlib: lib, importc: "gtk_cell_editable_start_editing".}
-proc editing_done*(cell_editable: PCellEditable){.cdecl, 
-    dynlib: lib, importc: "gtk_cell_editable_editing_done".}
-proc remove_widget*(cell_editable: PCellEditable){.cdecl, 
-    dynlib: lib, importc: "gtk_cell_editable_remove_widget".}
-const 
-  CELL_RENDERER_SELECTED* = 1 shl 0
-  CELL_RENDERER_PRELIT* = 1 shl 1
-  CELL_RENDERER_INSENSITIVE* = 1 shl 2
-  CELL_RENDERER_SORTED* = 1 shl 3
-
-const 
-  bm_TGtkCellRenderer_mode* = 0x0003'i16
-  bp_TGtkCellRenderer_mode* = 0'i16
-  bm_TGtkCellRenderer_visible* = 0x0004'i16
-  bp_TGtkCellRenderer_visible* = 2'i16
-  bm_TGtkCellRenderer_is_expander* = 0x0008'i16
-  bp_TGtkCellRenderer_is_expander* = 3'i16
-  bm_TGtkCellRenderer_is_expanded* = 0x0010'i16
-  bp_TGtkCellRenderer_is_expanded* = 4'i16
-  bm_TGtkCellRenderer_cell_background_set* = 0x0020'i16
-  bp_TGtkCellRenderer_cell_background_set* = 5'i16
-
-proc TYPE_CELL_RENDERER*(): GType
-proc CELL_RENDERER*(obj: pointer): PCellRenderer
-proc CELL_RENDERER_CLASS*(klass: pointer): PCellRendererClass
-proc IS_CELL_RENDERER*(obj: pointer): bool
-proc IS_CELL_RENDERER_CLASS*(klass: pointer): bool
-proc CELL_RENDERER_GET_CLASS*(obj: pointer): PCellRendererClass
-proc mode*(a: PCellRenderer): guint
-proc set_mode*(a: PCellRenderer, `mode`: guint)
-proc visible*(a: PCellRenderer): guint
-proc set_visible*(a: PCellRenderer, `visible`: guint)
-proc is_expander*(a: PCellRenderer): guint
-proc set_is_expander*(a: PCellRenderer, `is_expander`: guint)
-proc is_expanded*(a: PCellRenderer): guint
-proc set_is_expanded*(a: PCellRenderer, `is_expanded`: guint)
-proc cell_background_set*(a: PCellRenderer): guint
-proc set_cell_background_set*(a: PCellRenderer, `cell_background_set`: guint)
-proc cell_renderer_get_type*(): GType{.cdecl, dynlib: lib, 
-                                       importc: "gtk_cell_renderer_get_type".}
-proc get_size*(cell: PCellRenderer, widget: PWidget, 
-                             cell_area: gdk2.PRectangle, x_offset: Pgint, 
-                             y_offset: Pgint, width: Pgint, height: Pgint){.
-    cdecl, dynlib: lib, importc: "gtk_cell_renderer_get_size".}
-proc render*(cell: PCellRenderer, window: gdk2.PWindow, 
-                           widget: PWidget, background_area: gdk2.PRectangle, 
-                           cell_area: gdk2.PRectangle, expose_area: gdk2.PRectangle, 
-                           flags: TCellRendererState){.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_render".}
-proc activate*(cell: PCellRenderer, event: gdk2.PEvent, 
-                             widget: PWidget, path: cstring, 
-                             background_area: gdk2.PRectangle, 
-                             cell_area: gdk2.PRectangle, flags: TCellRendererState): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_cell_renderer_activate".}
-proc start_editing*(cell: PCellRenderer, event: gdk2.PEvent, 
-                                  widget: PWidget, path: cstring, 
-                                  background_area: gdk2.PRectangle, 
-                                  cell_area: gdk2.PRectangle, 
-                                  flags: TCellRendererState): PCellEditable{.
-    cdecl, dynlib: lib, importc: "gtk_cell_renderer_start_editing".}
-proc set_fixed_size*(cell: PCellRenderer, width: gint, 
-                                   height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_set_fixed_size".}
-proc get_fixed_size*(cell: PCellRenderer, width: Pgint, 
-                                   height: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_get_fixed_size".}
-const 
-  bm_TGtkCellRendererText_strikethrough* = 0x0001'i16
-  bp_TGtkCellRendererText_strikethrough* = 0'i16
-  bm_TGtkCellRendererText_editable* = 0x0002'i16
-  bp_TGtkCellRendererText_editable* = 1'i16
-  bm_TGtkCellRendererText_scale_set* = 0x0004'i16
-  bp_TGtkCellRendererText_scale_set* = 2'i16
-  bm_TGtkCellRendererText_foreground_set* = 0x0008'i16
-  bp_TGtkCellRendererText_foreground_set* = 3'i16
-  bm_TGtkCellRendererText_background_set* = 0x0010'i16
-  bp_TGtkCellRendererText_background_set* = 4'i16
-  bm_TGtkCellRendererText_underline_set* = 0x0020'i16
-  bp_TGtkCellRendererText_underline_set* = 5'i16
-  bm_TGtkCellRendererText_rise_set* = 0x0040'i16
-  bp_TGtkCellRendererText_rise_set* = 6'i16
-  bm_TGtkCellRendererText_strikethrough_set* = 0x0080'i16
-  bp_TGtkCellRendererText_strikethrough_set* = 7'i16
-  bm_TGtkCellRendererText_editable_set* = 0x0100'i16
-  bp_TGtkCellRendererText_editable_set* = 8'i16
-  bm_TGtkCellRendererText_calc_fixed_height* = 0x0200'i16
-  bp_TGtkCellRendererText_calc_fixed_height* = 9'i16
-
-proc TYPE_CELL_RENDERER_TEXT*(): GType
-proc CELL_RENDERER_TEXT*(obj: pointer): PCellRendererText
-proc CELL_RENDERER_TEXT_CLASS*(klass: pointer): PCellRendererTextClass
-proc IS_CELL_RENDERER_TEXT*(obj: pointer): bool
-proc IS_CELL_RENDERER_TEXT_CLASS*(klass: pointer): bool
-proc CELL_RENDERER_TEXT_GET_CLASS*(obj: pointer): PCellRendererTextClass
-proc strikethrough*(a: PCellRendererText): guint
-proc set_strikethrough*(a: PCellRendererText, `strikethrough`: guint)
-proc editable*(a: PCellRendererText): guint
-proc set_editable*(a: PCellRendererText, `editable`: guint)
-proc scale_set*(a: PCellRendererText): guint
-proc set_scale_set*(a: PCellRendererText, `scale_set`: guint)
-proc foreground_set*(a: PCellRendererText): guint
-proc set_foreground_set*(a: PCellRendererText, `foreground_set`: guint)
-proc background_set*(a: PCellRendererText): guint
-proc set_background_set*(a: PCellRendererText, `background_set`: guint)
-proc underline_set*(a: PCellRendererText): guint
-proc set_underline_set*(a: PCellRendererText, `underline_set`: guint)
-proc rise_set*(a: PCellRendererText): guint
-proc set_rise_set*(a: PCellRendererText, `rise_set`: guint)
-proc strikethrough_set*(a: PCellRendererText): guint
-proc set_strikethrough_set*(a: PCellRendererText, `strikethrough_set`: guint)
-proc editable_set*(a: PCellRendererText): guint
-proc set_editable_set*(a: PCellRendererText, `editable_set`: guint)
-proc calc_fixed_height*(a: PCellRendererText): guint
-proc set_calc_fixed_height*(a: PCellRendererText, `calc_fixed_height`: guint)
-proc cell_renderer_text_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_text_get_type".}
-proc cell_renderer_text_new*(): PCellRenderer{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_text_new".}
-proc text_set_fixed_height_from_font*(renderer: PCellRendererText, 
-    number_of_rows: gint){.cdecl, dynlib: lib, importc: "gtk_cell_renderer_text_set_fixed_height_from_font".}
-const 
-  bm_TGtkCellRendererToggle_active* = 0x0001'i16
-  bp_TGtkCellRendererToggle_active* = 0'i16
-  bm_TGtkCellRendererToggle_activatable* = 0x0002'i16
-  bp_TGtkCellRendererToggle_activatable* = 1'i16
-  bm_TGtkCellRendererToggle_radio* = 0x0004'i16
-  bp_TGtkCellRendererToggle_radio* = 2'i16
-
-proc TYPE_CELL_RENDERER_TOGGLE*(): GType
-proc CELL_RENDERER_TOGGLE*(obj: pointer): PCellRendererToggle
-proc CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): PCellRendererToggleClass
-proc IS_CELL_RENDERER_TOGGLE*(obj: pointer): bool
-proc IS_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): bool
-proc CELL_RENDERER_TOGGLE_GET_CLASS*(obj: pointer): PCellRendererToggleClass
-proc active*(a: PCellRendererToggle): guint
-proc set_active*(a: PCellRendererToggle, `active`: guint)
-proc activatable*(a: PCellRendererToggle): guint
-proc set_activatable*(a: PCellRendererToggle, `activatable`: guint)
-proc radio*(a: PCellRendererToggle): guint
-proc set_radio*(a: PCellRendererToggle, `radio`: guint)
-proc cell_renderer_toggle_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_toggle_get_type".}
-proc cell_renderer_toggle_new*(): PCellRenderer{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_toggle_new".}
-proc toggle_get_radio*(toggle: PCellRendererToggle): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_cell_renderer_toggle_get_radio".}
-proc toggle_set_radio*(toggle: PCellRendererToggle, 
-                                     radio: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_toggle_set_radio".}
-proc toggle_get_active*(toggle: PCellRendererToggle): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_cell_renderer_toggle_get_active".}
-proc toggle_set_active*(toggle: PCellRendererToggle, 
-                                      setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_toggle_set_active".}
-proc TYPE_CELL_RENDERER_PIXBUF*(): GType
-proc CELL_RENDERER_PIXBUF*(obj: pointer): PCellRendererPixbuf
-proc CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): PCellRendererPixbufClass
-proc IS_CELL_RENDERER_PIXBUF*(obj: pointer): bool
-proc IS_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): bool
-proc CELL_RENDERER_PIXBUF_GET_CLASS*(obj: pointer): PCellRendererPixbufClass
-proc cell_renderer_pixbuf_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_pixbuf_get_type".}
-proc cell_renderer_pixbuf_new*(): PCellRenderer{.cdecl, dynlib: lib, 
-    importc: "gtk_cell_renderer_pixbuf_new".}
-proc TYPE_ITEM*(): GType
-proc ITEM*(obj: pointer): PItem
-proc ITEM_CLASS*(klass: pointer): PItemClass
-proc IS_ITEM*(obj: pointer): bool
-proc IS_ITEM_CLASS*(klass: pointer): bool
-proc ITEM_GET_CLASS*(obj: pointer): PItemClass
-proc item_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_item_get_type".}
-proc select*(item: PItem){.cdecl, dynlib: lib, importc: "gtk_item_select".}
-proc deselect*(item: PItem){.cdecl, dynlib: lib, 
-                                  importc: "gtk_item_deselect".}
-proc toggle*(item: PItem){.cdecl, dynlib: lib, importc: "gtk_item_toggle".}
-const 
-  bm_TGtkMenuItem_show_submenu_indicator* = 0x0001'i16
-  bp_TGtkMenuItem_show_submenu_indicator* = 0'i16
-  bm_TGtkMenuItem_submenu_placement* = 0x0002'i16
-  bp_TGtkMenuItem_submenu_placement* = 1'i16
-  bm_TGtkMenuItem_submenu_direction* = 0x0004'i16
-  bp_TGtkMenuItem_submenu_direction* = 2'i16
-  bm_TGtkMenuItem_right_justify* = 0x0008'i16
-  bp_TGtkMenuItem_right_justify* = 3'i16
-  bm_TGtkMenuItem_timer_from_keypress* = 0x0010'i16
-  bp_TGtkMenuItem_timer_from_keypress* = 4'i16
-  bm_TGtkMenuItemClass_hide_on_activate* = 0x0001'i16
-  bp_TGtkMenuItemClass_hide_on_activate* = 0'i16
-
-proc TYPE_MENU_ITEM*(): GType
-proc MENU_ITEM*(obj: pointer): PMenuItem
-proc MENU_ITEM_CLASS*(klass: pointer): PMenuItemClass
-proc IS_MENU_ITEM*(obj: pointer): bool
-proc IS_MENU_ITEM_CLASS*(klass: pointer): bool
-proc MENU_ITEM_GET_CLASS*(obj: pointer): PMenuItemClass
-proc show_submenu_indicator*(a: PMenuItem): guint
-proc set_show_submenu_indicator*(a: PMenuItem, 
-                                 `show_submenu_indicator`: guint)
-proc submenu_placement*(a: PMenuItem): guint
-proc set_submenu_placement*(a: PMenuItem, `submenu_placement`: guint)
-proc submenu_direction*(a: PMenuItem): guint
-proc set_submenu_direction*(a: PMenuItem, `submenu_direction`: guint)
-proc right_justify*(a: PMenuItem): guint
-proc set_right_justify*(a: PMenuItem, `right_justify`: guint)
-proc timer_from_keypress*(a: PMenuItem): guint
-proc set_timer_from_keypress*(a: PMenuItem, `timer_from_keypress`: guint)
-proc hide_on_activate*(a: PMenuItemClass): guint
-proc set_hide_on_activate*(a: PMenuItemClass, `hide_on_activate`: guint)
-proc menu_item_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_menu_item_get_type".}
-proc menu_item_new*(): PMenuItem{.cdecl, dynlib: lib, 
-                                  importc: "gtk_menu_item_new".}
-proc menu_item_new*(`label`: cstring): PMenuItem{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_new_with_label".}
-proc menu_item_new_with_mnemonic*(`label`: cstring): PMenuItem{.cdecl, 
-    dynlib: lib, importc: "gtk_menu_item_new_with_mnemonic".}
-proc set_submenu*(menu_item: PMenuItem, submenu: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_item_set_submenu".}
-proc get_submenu*(menu_item: PMenuItem): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_get_submenu".}
-proc remove_submenu*(menu_item: PMenuItem){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_remove_submenu".}
-proc select*(menu_item: PMenuItem){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_select".}
-proc deselect*(menu_item: PMenuItem){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_deselect".}
-proc activate*(menu_item: PMenuItem){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_item_activate".}
-proc toggle_size_request*(menu_item: PMenuItem, requisition: Pgint){.
-    cdecl, dynlib: lib, importc: "gtk_menu_item_toggle_size_request".}
-proc toggle_size_allocate*(menu_item: PMenuItem, allocation: gint){.
-    cdecl, dynlib: lib, importc: "gtk_menu_item_toggle_size_allocate".}
-proc set_right_justified*(menu_item: PMenuItem, 
-                                    right_justified: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_item_set_right_justified".}
-proc get_right_justified*(menu_item: PMenuItem): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_menu_item_get_right_justified".}
-proc set_accel_path*(menu_item: PMenuItem, accel_path: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_menu_item_set_accel_path".}
-proc refresh_accel_path*(menu_item: PMenuItem, prefix: cstring, 
-                                   accel_group: PAccelGroup, 
-                                   group_changed: gboolean){.cdecl, dynlib: lib, 
-    importc: "_gtk_menu_item_refresh_accel_path".}
-proc menu_item_is_selectable*(menu_item: PWidget): gboolean{.cdecl, dynlib: lib, 
-    importc: "_gtk_menu_item_is_selectable".}
-const 
-  bm_TGtkToggleButton_active* = 0x0001'i16
-  bp_TGtkToggleButton_active* = 0'i16
-  bm_TGtkToggleButton_draw_indicator* = 0x0002'i16
-  bp_TGtkToggleButton_draw_indicator* = 1'i16
-  bm_TGtkToggleButton_inconsistent* = 0x0004'i16
-  bp_TGtkToggleButton_inconsistent* = 2'i16
-
-proc TYPE_TOGGLE_BUTTON*(): GType
-proc TOGGLE_BUTTON*(obj: pointer): PToggleButton
-proc TOGGLE_BUTTON_CLASS*(klass: pointer): PToggleButtonClass
-proc IS_TOGGLE_BUTTON*(obj: pointer): bool
-proc IS_TOGGLE_BUTTON_CLASS*(klass: pointer): bool
-proc TOGGLE_BUTTON_GET_CLASS*(obj: pointer): PToggleButtonClass
-proc active*(a: PToggleButton): guint
-proc set_active*(a: PToggleButton, `active`: guint)
-proc draw_indicator*(a: PToggleButton): guint
-proc set_draw_indicator*(a: PToggleButton, `draw_indicator`: guint)
-proc inconsistent*(a: PToggleButton): guint
-proc set_inconsistent*(a: PToggleButton, `inconsistent`: guint)
-proc toggle_button_get_type*(): TType{.cdecl, dynlib: lib, 
-                                       importc: "gtk_toggle_button_get_type".}
-proc toggle_button_new*(): PToggleButton{.cdecl, dynlib: lib, 
-    importc: "gtk_toggle_button_new".}
-proc toggle_button_new*(`label`: cstring): PToggleButton{.cdecl, 
-    dynlib: lib, importc: "gtk_toggle_button_new_with_label".}
-proc toggle_button_new_with_mnemonic*(`label`: cstring): PToggleButton{.cdecl, 
-    dynlib: lib, importc: "gtk_toggle_button_new_with_mnemonic".}
-proc set_mode*(toggle_button: PToggleButton, 
-                             draw_indicator: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_toggle_button_set_mode".}
-proc get_mode*(toggle_button: PToggleButton): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_toggle_button_get_mode".}
-proc set_active*(toggle_button: PToggleButton, is_active: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_toggle_button_set_active".}
-proc get_active*(toggle_button: PToggleButton): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_toggle_button_get_active".}
-proc toggled*(toggle_button: PToggleButton){.cdecl, dynlib: lib, 
-    importc: "gtk_toggle_button_toggled".}
-proc set_inconsistent*(toggle_button: PToggleButton, 
-                                     setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_toggle_button_set_inconsistent".}
-proc get_inconsistent*(toggle_button: PToggleButton): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_toggle_button_get_inconsistent".}
-proc TYPE_CHECK_BUTTON*(): GType
-proc CHECK_BUTTON*(obj: pointer): PCheckButton
-proc CHECK_BUTTON_CLASS*(klass: pointer): PCheckButtonClass
-proc IS_CHECK_BUTTON*(obj: pointer): bool
-proc IS_CHECK_BUTTON_CLASS*(klass: pointer): bool
-proc CHECK_BUTTON_GET_CLASS*(obj: pointer): PCheckButtonClass
-proc check_button_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_check_button_get_type".}
-proc check_button_new*(): PCheckButton{.cdecl, dynlib: lib, 
-                                        importc: "gtk_check_button_new".}
-proc check_button_new*(`label`: cstring): PCheckButton{.cdecl, 
-    dynlib: lib, importc: "gtk_check_button_new_with_label".}
-proc check_button_new_with_mnemonic*(`label`: cstring): PCheckButton{.cdecl, 
-    dynlib: lib, importc: "gtk_check_button_new_with_mnemonic".}
-proc get_props*(check_button: PCheckButton, indicator_size: Pgint, 
-                             indicator_spacing: Pgint){.cdecl, dynlib: lib, 
-    importc: "_gtk_check_button_get_props".}
-const 
-  bm_TGtkCheckMenuItem_active* = 0x0001'i16
-  bp_TGtkCheckMenuItem_active* = 0'i16
-  bm_TGtkCheckMenuItem_always_show_toggle* = 0x0002'i16
-  bp_TGtkCheckMenuItem_always_show_toggle* = 1'i16
-  bm_TGtkCheckMenuItem_inconsistent* = 0x0004'i16
-  bp_TGtkCheckMenuItem_inconsistent* = 2'i16
-
-proc TYPE_CHECK_MENU_ITEM*(): GType
-proc CHECK_MENU_ITEM*(obj: pointer): PCheckMenuItem
-proc CHECK_MENU_ITEM_CLASS*(klass: pointer): PCheckMenuItemClass
-proc IS_CHECK_MENU_ITEM*(obj: pointer): bool
-proc IS_CHECK_MENU_ITEM_CLASS*(klass: pointer): bool
-proc CHECK_MENU_ITEM_GET_CLASS*(obj: pointer): PCheckMenuItemClass
-proc active*(a: PCheckMenuItem): guint
-proc set_active*(a: PCheckMenuItem, `active`: guint)
-proc always_show_toggle*(a: PCheckMenuItem): guint
-proc set_always_show_toggle*(a: PCheckMenuItem, `always_show_toggle`: guint)
-proc inconsistent*(a: PCheckMenuItem): guint
-proc set_inconsistent*(a: PCheckMenuItem, `inconsistent`: guint)
-proc check_menu_item_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_check_menu_item_get_type".}
-proc check_menu_item_new*(): PCheckMenuItem{.cdecl, dynlib: lib, 
-                                      importc: "gtk_check_menu_item_new".}
-proc check_menu_item_new*(`label`: cstring): PCheckMenuItem{.cdecl, 
-    dynlib: lib, importc: "gtk_check_menu_item_new_with_label".}
-proc check_menu_item_new_with_mnemonic*(`label`: cstring): PCheckMenuItem{.cdecl, 
-    dynlib: lib, importc: "gtk_check_menu_item_new_with_mnemonic".}
-proc item_set_active*(check_menu_item: PCheckMenuItem, 
-                                 is_active: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_check_menu_item_set_active".}
-proc item_get_active*(check_menu_item: PCheckMenuItem): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_check_menu_item_get_active".}
-proc item_toggled*(check_menu_item: PCheckMenuItem){.cdecl, 
-    dynlib: lib, importc: "gtk_check_menu_item_toggled".}
-proc item_set_inconsistent*(check_menu_item: PCheckMenuItem, 
-                                       setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_check_menu_item_set_inconsistent".}
-proc item_get_inconsistent*(check_menu_item: PCheckMenuItem): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_check_menu_item_get_inconsistent".}
-proc clipboard_get_for_display*(display: gdk2.PDisplay, selection: gdk2.TAtom): PClipboard{.
-    cdecl, dynlib: lib, importc: "gtk_clipboard_get_for_display".}
-proc get_display*(clipboard: PClipboard): gdk2.PDisplay{.cdecl, 
-    dynlib: lib, importc: "gtk_clipboard_get_display".}
-proc set_with_data*(clipboard: PClipboard, targets: PTargetEntry, 
-                              n_targets: guint, get_func: TClipboardGetFunc, 
-                              clear_func: TClipboardClearFunc, 
-                              user_data: gpointer): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_clipboard_set_with_data".}
-proc set_with_owner*(clipboard: PClipboard, targets: PTargetEntry, 
-                               n_targets: guint, get_func: TClipboardGetFunc, 
-                               clear_func: TClipboardClearFunc, owner: PGObject): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_clipboard_set_with_owner".}
-proc get_owner*(clipboard: PClipboard): PGObject{.cdecl, dynlib: lib, 
-    importc: "gtk_clipboard_get_owner".}
-proc clear*(clipboard: PClipboard){.cdecl, dynlib: lib, 
-    importc: "gtk_clipboard_clear".}
-proc set_text*(clipboard: PClipboard, text: cstring, len: gint){.
-    cdecl, dynlib: lib, importc: "gtk_clipboard_set_text".}
-proc request_contents*(clipboard: PClipboard, target: gdk2.TAtom, 
-                                 callback: TClipboardReceivedFunc, 
-                                 user_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_clipboard_request_contents".}
-proc request_text*(clipboard: PClipboard, 
-                             callback: TClipboardTextReceivedFunc, 
-                             user_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_clipboard_request_text".}
-proc wait_for_contents*(clipboard: PClipboard, target: gdk2.TAtom): PSelectionData{.
-    cdecl, dynlib: lib, importc: "gtk_clipboard_wait_for_contents".}
-proc wait_for_text*(clipboard: PClipboard): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_clipboard_wait_for_text".}
-proc wait_is_text_available*(clipboard: PClipboard): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_clipboard_wait_is_text_available".}
-const 
-  CLIST_IN_DRAG* = 1 shl 0
-  CLIST_ROW_HEIGHT_SET* = 1 shl 1
-  CLIST_SHOW_TITLES* = 1 shl 2
-  CLIST_ADD_MODE* = 1 shl 4
-  CLIST_AUTO_SORT* = 1 shl 5
-  CLIST_AUTO_RESIZE_BLOCKED* = 1 shl 6
-  CLIST_REORDERABLE* = 1 shl 7
-  CLIST_USE_DRAG_ICONS* = 1 shl 8
-  CLIST_DRAW_DRAG_LINE* = 1 shl 9
-  CLIST_DRAW_DRAG_RECT* = 1 shl 10
-  BUTTON_IGNORED* = 0
-  BUTTON_SELECTS* = 1 shl 0
-  BUTTON_DRAGS* = 1 shl 1
-  BUTTON_EXPANDS* = 1 shl 2
-
-const 
-  bm_TGtkCListColumn_visible* = 0x0001'i16
-  bp_TGtkCListColumn_visible* = 0'i16
-  bm_TGtkCListColumn_width_set* = 0x0002'i16
-  bp_TGtkCListColumn_width_set* = 1'i16
-  bm_TGtkCListColumn_resizeable* = 0x0004'i16
-  bp_TGtkCListColumn_resizeable* = 2'i16
-  bm_TGtkCListColumn_auto_resize* = 0x0008'i16
-  bp_TGtkCListColumn_auto_resize* = 3'i16
-  bm_TGtkCListColumn_button_passive* = 0x0010'i16
-  bp_TGtkCListColumn_button_passive* = 4'i16
-  bm_TGtkCListRow_fg_set* = 0x0001'i16
-  bp_TGtkCListRow_fg_set* = 0'i16
-  bm_TGtkCListRow_bg_set* = 0x0002'i16
-  bp_TGtkCListRow_bg_set* = 1'i16
-  bm_TGtkCListRow_selectable* = 0x0004'i16
-  bp_TGtkCListRow_selectable* = 2'i16
-
-proc TYPE_CLIST*(): GType
-proc CLIST*(obj: pointer): PCList
-proc CLIST_CLASS*(klass: pointer): PCListClass
-proc IS_CLIST*(obj: pointer): bool
-proc IS_CLIST_CLASS*(klass: pointer): bool
-proc CLIST_GET_CLASS*(obj: pointer): PCListClass
-proc CLIST_FLAGS*(clist: pointer): guint16
-proc SET_FLAG*(clist: PCList, flag: guint16)
-proc UNSET_FLAG*(clist: PCList, flag: guint16)
-#proc GTK_CLIST_IN_DRAG_get*(clist: pointer): bool
-#proc GTK_CLIST_ROW_HEIGHT_SET_get*(clist: pointer): bool
-#proc GTK_CLIST_SHOW_TITLES_get*(clist: pointer): bool
-#proc GTK_CLIST_ADD_MODE_get*(clist: pointer): bool
-#proc GTK_CLIST_AUTO_SORT_get*(clist: pointer): bool
-#proc GTK_CLIST_AUTO_RESIZE_BLOCKED_get*(clist: pointer): bool
-#proc GTK_CLIST_REORDERABLE_get*(clist: pointer): bool
-#proc GTK_CLIST_USE_DRAG_ICONS_get*(clist: pointer): bool
-#proc GTK_CLIST_DRAW_DRAG_LINE_get*(clist: pointer): bool
-#proc GTK_CLIST_DRAW_DRAG_RECT_get*(clist: pointer): bool
-#proc GTK_CLIST_ROW_get*(glist: PGList): PGtkCListRow
-#proc GTK_CELL_TEXT_get*(cell: pointer): PGtkCellText
-#proc GTK_CELL_PIXMAP_get*(cell: pointer): PGtkCellPixmap
-#proc GTK_CELL_PIXTEXT_get*(cell: pointer): PGtkCellPixText
-#proc GTK_CELL_WIDGET_get*(cell: pointer): PGtkCellWidget
-
-proc visible*(a: PCListColumn): guint
-proc set_visible*(a: PCListColumn, `visible`: guint)
-proc width_set*(a: PCListColumn): guint
-proc set_width_set*(a: PCListColumn, `width_set`: guint)
-proc resizeable*(a: PCListColumn): guint
-proc set_resizeable*(a: PCListColumn, `resizeable`: guint)
-proc auto_resize*(a: PCListColumn): guint
-proc set_auto_resize*(a: PCListColumn, `auto_resize`: guint)
-proc button_passive*(a: PCListColumn): guint
-proc set_button_passive*(a: PCListColumn, `button_passive`: guint)
-proc fg_set*(a: PCListRow): guint
-proc set_fg_set*(a: PCListRow, `fg_set`: guint)
-proc bg_set*(a: PCListRow): guint
-proc set_bg_set*(a: PCListRow, `bg_set`: guint)
-proc selectable*(a: PCListRow): guint
-proc set_selectable*(a: PCListRow, `selectable`: guint)
-proc clist_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_clist_get_type".}
-proc clist_new*(columns: gint): PCList{.cdecl, dynlib: lib, 
-                                        importc: "gtk_clist_new".}
-proc set_hadjustment*(clist: PCList, adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_hadjustment".}
-proc set_vadjustment*(clist: PCList, adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_vadjustment".}
-proc get_hadjustment*(clist: PCList): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_clist_get_hadjustment".}
-proc get_vadjustment*(clist: PCList): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_clist_get_vadjustment".}
-proc set_shadow_type*(clist: PCList, thetype: TShadowType){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_shadow_type".}
-proc set_selection_mode*(clist: PCList, mode: TSelectionMode){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_selection_mode".}
-proc set_reorderable*(clist: PCList, reorderable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_reorderable".}
-proc set_use_drag_icons*(clist: PCList, use_icons: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_use_drag_icons".}
-proc set_button_actions*(clist: PCList, button: guint, 
-                               button_actions: guint8){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_button_actions".}
-proc freeze*(clist: PCList){.cdecl, dynlib: lib, 
-                                   importc: "gtk_clist_freeze".}
-proc thaw*(clist: PCList){.cdecl, dynlib: lib, importc: "gtk_clist_thaw".}
-proc column_titles_show*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_column_titles_show".}
-proc column_titles_hide*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_column_titles_hide".}
-proc column_title_active*(clist: PCList, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_column_title_active".}
-proc column_title_passive*(clist: PCList, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_column_title_passive".}
-proc column_titles_active*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_column_titles_active".}
-proc column_titles_passive*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_column_titles_passive".}
-proc set_column_title*(clist: PCList, column: gint, title: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_column_title".}
-proc get_column_title*(clist: PCList, column: gint): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_get_column_title".}
-proc set_column_widget*(clist: PCList, column: gint, widget: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_column_widget".}
-proc get_column_widget*(clist: PCList, column: gint): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_get_column_widget".}
-proc set_column_justification*(clist: PCList, column: gint, 
-                                     justification: TJustification){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_column_justification".}
-proc set_column_visibility*(clist: PCList, column: gint, visible: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_column_visibility".}
-proc set_column_resizeable*(clist: PCList, column: gint, 
-                                  resizeable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_column_resizeable".}
-proc set_column_auto_resize*(clist: PCList, column: gint, 
-                                   auto_resize: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_column_auto_resize".}
-proc columns_autosize*(clist: PCList): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_clist_columns_autosize".}
-proc optimal_column_width*(clist: PCList, column: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_optimal_column_width".}
-proc set_column_width*(clist: PCList, column: gint, width: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_column_width".}
-proc set_column_min_width*(clist: PCList, column: gint, min_width: gint){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_column_min_width".}
-proc set_column_max_width*(clist: PCList, column: gint, max_width: gint){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_column_max_width".}
-proc set_row_height*(clist: PCList, height: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_row_height".}
-proc moveto*(clist: PCList, row: gint, column: gint, row_align: gfloat, 
-                   col_align: gfloat){.cdecl, dynlib: lib, 
-                                       importc: "gtk_clist_moveto".}
-proc row_is_visible*(clist: PCList, row: gint): TVisibility{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_row_is_visible".}
-proc get_cell_type*(clist: PCList, row: gint, column: gint): TCellType{.
-    cdecl, dynlib: lib, importc: "gtk_clist_get_cell_type".}
-proc set_text*(clist: PCList, row: gint, column: gint, text: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_text".}
-proc get_text*(clist: PCList, row: gint, column: gint, text: PPgchar): gint{.
-    cdecl, dynlib: lib, importc: "gtk_clist_get_text".}
-proc set_pixmap*(clist: PCList, row: gint, column: gint, 
-                       pixmap: gdk2.PPixmap, mask: gdk2.PBitmap){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_pixmap".}
-proc get_pixmap*(clist: PCList, row: gint, column: gint, 
-                       pixmap: var gdk2.PPixmap, mask: var gdk2.PBitmap): gint{.
-    cdecl, dynlib: lib, importc: "gtk_clist_get_pixmap".}
-proc set_pixtext*(clist: PCList, row: gint, column: gint, text: cstring, 
-                        spacing: guint8, pixmap: gdk2.PPixmap, mask: gdk2.PBitmap){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_pixtext".}
-proc set_foreground*(clist: PCList, row: gint, color: gdk2.PColor){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_foreground".}
-proc set_background*(clist: PCList, row: gint, color: gdk2.PColor){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_background".}
-proc set_cell_style*(clist: PCList, row: gint, column: gint, style: PStyle){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_cell_style".}
-proc get_cell_style*(clist: PCList, row: gint, column: gint): PStyle{.
-    cdecl, dynlib: lib, importc: "gtk_clist_get_cell_style".}
-proc set_row_style*(clist: PCList, row: gint, style: PStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_row_style".}
-proc get_row_style*(clist: PCList, row: gint): PStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_clist_get_row_style".}
-proc set_shift*(clist: PCList, row: gint, column: gint, vertical: gint, 
-                      horizontal: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_shift".}
-proc set_selectable*(clist: PCList, row: gint, selectable: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_clist_set_selectable".}
-proc get_selectable*(clist: PCList, row: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_get_selectable".}
-proc remove*(clist: PCList, row: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_remove".}
-proc set_row_data*(clist: PCList, row: gint, data: gpointer){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_row_data".}
-proc set_row_data_full*(clist: PCList, row: gint, data: gpointer, 
-                              destroy: TDestroyNotify){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_row_data_full".}
-proc get_row_data*(clist: PCList, row: gint): gpointer{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_get_row_data".}
-proc find_row_from_data*(clist: PCList, data: gpointer): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_clist_find_row_from_data".}
-proc select_row*(clist: PCList, row: gint, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_select_row".}
-proc unselect_row*(clist: PCList, row: gint, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_unselect_row".}
-proc undo_selection*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_undo_selection".}
-proc clear*(clist: PCList){.cdecl, dynlib: lib, importc: "gtk_clist_clear".}
-proc get_selection_info*(clist: PCList, x: gint, y: gint, row: Pgint, 
-                               column: Pgint): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_clist_get_selection_info".}
-proc select_all*(clist: PCList){.cdecl, dynlib: lib, 
-                                       importc: "gtk_clist_select_all".}
-proc unselect_all*(clist: PCList){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_unselect_all".}
-proc swap_rows*(clist: PCList, row1: gint, row2: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_swap_rows".}
-proc row_move*(clist: PCList, source_row: gint, dest_row: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_row_move".}
-proc set_compare_func*(clist: PCList, cmp_func: TCListCompareFunc){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_compare_func".}
-proc set_sort_column*(clist: PCList, column: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_clist_set_sort_column".}
-proc set_sort_type*(clist: PCList, sort_type: TSortType){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_sort_type".}
-proc sort*(clist: PCList){.cdecl, dynlib: lib, importc: "gtk_clist_sort".}
-proc set_auto_sort*(clist: PCList, auto_sort: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_clist_set_auto_sort".}
-proc create_cell_layout*(clist: PCList, clist_row: PCListRow, column: gint): pango.PLayout{.
-    cdecl, dynlib: lib, importc: "_gtk_clist_create_cell_layout".}
-const 
-  DIALOG_MODAL* = cint(1 shl 0)
-  DIALOG_DESTROY_WITH_PARENT* = cint(1 shl 1)
-  DIALOG_NO_SEPARATOR* = cint(1 shl 2)
-  RESPONSE_NONE* = - cint(1)
-  RESPONSE_REJECT* = - cint(2)
-  RESPONSE_ACCEPT* = - cint(3)
-  RESPONSE_DELETE_EVENT* = - cint(4)
-  RESPONSE_OK* = - cint(5)
-  RESPONSE_CANCEL* = cint(-6)
-  RESPONSE_CLOSE* = - cint(7)
-  RESPONSE_YES* = - cint(8)
-  RESPONSE_NO* = - cint(9)
-  RESPONSE_APPLY* = - cint(10)
-  RESPONSE_HELP* = - cint(11)
-
-proc TYPE_DIALOG*(): GType
-proc DIALOG*(obj: pointer): PDialog
-proc DIALOG_CLASS*(klass: pointer): PDialogClass
-proc IS_DIALOG*(obj: pointer): bool
-proc IS_DIALOG_CLASS*(klass: pointer): bool
-proc DIALOG_GET_CLASS*(obj: pointer): PDialogClass
-proc dialog_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_dialog_get_type".}
-proc dialog_new*(): PDialog{.cdecl, dynlib: lib, importc: "gtk_dialog_new".}
-proc add_action_widget*(dialog: PDialog, child: PWidget, 
-                               response_id: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_dialog_add_action_widget".}
-proc add_button*(dialog: PDialog, button_text: cstring, response_id: gint): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_dialog_add_button".}
-proc set_response_sensitive*(dialog: PDialog, response_id: gint, 
-                                    setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_dialog_set_response_sensitive".}
-proc set_default_response*(dialog: PDialog, response_id: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_dialog_set_default_response".}
-proc set_has_separator*(dialog: PDialog, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_dialog_set_has_separator".}
-proc get_has_separator*(dialog: PDialog): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_dialog_get_has_separator".}
-proc response*(dialog: PDialog, response_id: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_dialog_response".}
-proc run*(dialog: PDialog): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_dialog_run".}
-proc show_about_dialog*(parent: PWindow, firstPropertyName: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_show_about_dialog", varargs.}
-proc TYPE_VBOX*(): GType
-proc VBOX*(obj: pointer): PVBox
-proc VBOX_CLASS*(klass: pointer): PVBoxClass
-proc IS_VBOX*(obj: pointer): bool
-proc IS_VBOX_CLASS*(klass: pointer): bool
-proc VBOX_GET_CLASS*(obj: pointer): PVBoxClass
-proc vbox_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_vbox_get_type".}
-proc vbox_new*(homogeneous: gboolean, spacing: gint): PVBox{.cdecl, dynlib: lib, 
-    importc: "gtk_vbox_new".}
-proc TYPE_COLOR_SELECTION*(): GType
-proc COLOR_SELECTION*(obj: pointer): PColorSelection
-proc COLOR_SELECTION_CLASS*(klass: pointer): PColorSelectionClass
-proc IS_COLOR_SELECTION*(obj: pointer): bool
-proc IS_COLOR_SELECTION_CLASS*(klass: pointer): bool
-proc COLOR_SELECTION_GET_CLASS*(obj: pointer): PColorSelectionClass
-proc color_selection_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_get_type".}
-proc color_selection_new*(): PColorSelection{.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_new".}
-proc get_has_opacity_control*(colorsel: PColorSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_color_selection_get_has_opacity_control".}
-proc set_has_opacity_control*(colorsel: PColorSelection, 
-    has_opacity: gboolean){.cdecl, dynlib: lib, importc: "gtk_color_selection_set_has_opacity_control".}
-proc get_has_palette*(colorsel: PColorSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_color_selection_get_has_palette".}
-proc set_has_palette*(colorsel: PColorSelection, 
-                                      has_palette: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_color_selection_set_has_palette".}
-proc set_current_color*(colorsel: PColorSelection, 
-                                        color: gdk2.PColor){.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_set_current_color".}
-proc set_current_alpha*(colorsel: PColorSelection, 
-                                        alpha: guint16){.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_set_current_alpha".}
-proc get_current_color*(colorsel: PColorSelection, 
-                                        color: gdk2.PColor){.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_get_current_color".}
-proc get_current_alpha*(colorsel: PColorSelection): guint16{.
-    cdecl, dynlib: lib, importc: "gtk_color_selection_get_current_alpha".}
-proc set_previous_color*(colorsel: PColorSelection, 
-    color: gdk2.PColor){.cdecl, dynlib: lib, 
-                       importc: "gtk_color_selection_set_previous_color".}
-proc set_previous_alpha*(colorsel: PColorSelection, 
-    alpha: guint16){.cdecl, dynlib: lib, 
-                     importc: "gtk_color_selection_set_previous_alpha".}
-proc get_previous_color*(colorsel: PColorSelection, 
-    color: gdk2.PColor){.cdecl, dynlib: lib, 
-                       importc: "gtk_color_selection_get_previous_color".}
-proc get_previous_alpha*(colorsel: PColorSelection): guint16{.
-    cdecl, dynlib: lib, importc: "gtk_color_selection_get_previous_alpha".}
-proc is_adjusting*(colorsel: PColorSelection): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_color_selection_is_adjusting".}
-proc color_selection_palette_from_string*(str: cstring, colors: var gdk2.PColor, 
-    n_colors: Pgint): gboolean{.cdecl, dynlib: lib, importc: "gtk_color_selection_palette_from_string".}
-proc color_selection_palette_to_string*(colors: gdk2.PColor, n_colors: gint): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_color_selection_palette_to_string".}
-proc color_selection_set_change_palette_with_screen_hook*(
-    func: TColorSelectionChangePaletteWithScreenFunc): TColorSelectionChangePaletteWithScreenFunc{.
-    cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_set_change_palette_with_screen_hook".}
-proc TYPE_COLOR_SELECTION_DIALOG*(): GType
-proc COLOR_SELECTION_DIALOG*(obj: pointer): PColorSelectionDialog
-proc COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): PColorSelectionDialogClass
-proc IS_COLOR_SELECTION_DIALOG*(obj: pointer): bool
-proc IS_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): bool
-proc COLOR_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PColorSelectionDialogClass
-proc color_selection_dialog_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_color_selection_dialog_get_type".}
-proc color_selection_dialog_new*(title: cstring): PColorSelectionDialog{.cdecl, 
-    dynlib: lib, importc: "gtk_color_selection_dialog_new".}
-proc TYPE_HBOX*(): GType
-proc HBOX*(obj: pointer): PHBox
-proc HBOX_CLASS*(klass: pointer): PHBoxClass
-proc IS_HBOX*(obj: pointer): bool
-proc IS_HBOX_CLASS*(klass: pointer): bool
-proc HBOX_GET_CLASS*(obj: pointer): PHBoxClass
-proc hbox_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_hbox_get_type".}
-proc hbox_new*(homogeneous: gboolean, spacing: gint): PHBox{.cdecl, dynlib: lib, 
-    importc: "gtk_hbox_new".}
-const 
-  bm_TGtkCombo_value_in_list* = 0x0001'i16
-  bp_TGtkCombo_value_in_list* = 0'i16
-  bm_TGtkCombo_ok_if_empty* = 0x0002'i16
-  bp_TGtkCombo_ok_if_empty* = 1'i16
-  bm_TGtkCombo_case_sensitive* = 0x0004'i16
-  bp_TGtkCombo_case_sensitive* = 2'i16
-  bm_TGtkCombo_use_arrows* = 0x0008'i16
-  bp_TGtkCombo_use_arrows* = 3'i16
-  bm_TGtkCombo_use_arrows_always* = 0x0010'i16
-  bp_TGtkCombo_use_arrows_always* = 4'i16
-
-proc TYPE_COMBO*(): GType
-proc COMBO*(obj: pointer): PCombo
-proc COMBO_CLASS*(klass: pointer): PComboClass
-proc IS_COMBO*(obj: pointer): bool
-proc IS_COMBO_CLASS*(klass: pointer): bool
-proc COMBO_GET_CLASS*(obj: pointer): PComboClass
-proc value_in_list*(a: PCombo): guint
-proc set_value_in_list*(a: PCombo, `value_in_list`: guint)
-proc ok_if_empty*(a: PCombo): guint
-proc set_ok_if_empty*(a: PCombo, `ok_if_empty`: guint)
-proc case_sensitive*(a: PCombo): guint
-proc set_case_sensitive*(a: PCombo, `case_sensitive`: guint)
-proc use_arrows*(a: PCombo): guint
-proc set_use_arrows*(a: PCombo, `use_arrows`: guint)
-proc use_arrows_always*(a: PCombo): guint
-proc set_use_arrows_always*(a: PCombo, `use_arrows_always`: guint)
-proc combo_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_combo_get_type".}
-proc combo_new*(): PCombo{.cdecl, dynlib: lib, importc: "gtk_combo_new".}
-proc set_value_in_list*(combo: PCombo, val: gboolean, 
-                              ok_if_empty: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_combo_set_value_in_list".}
-proc set_use_arrows*(combo: PCombo, val: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_combo_set_use_arrows".}
-proc set_use_arrows_always*(combo: PCombo, val: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_combo_set_use_arrows_always".}
-proc set_case_sensitive*(combo: PCombo, val: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_combo_set_case_sensitive".}
-proc set_item_string*(combo: PCombo, item: PItem, item_value: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_combo_set_item_string".}
-proc set_popdown_strings*(combo: PCombo, strings: PGList){.cdecl, 
-    dynlib: lib, importc: "gtk_combo_set_popdown_strings".}
-proc disable_activate*(combo: PCombo){.cdecl, dynlib: lib, 
-    importc: "gtk_combo_disable_activate".}
-const 
-  bm_TGtkCTree_line_style* = 0x0003'i16
-  bp_TGtkCTree_line_style* = 0'i16
-  bm_TGtkCTree_expander_style* = 0x000C'i16
-  bp_TGtkCTree_expander_style* = 2'i16
-  bm_TGtkCTree_show_stub* = 0x0010'i16
-  bp_TGtkCTree_show_stub* = 4'i16
-  bm_TGtkCTreeRow_is_leaf* = 0x0001'i16
-  bp_TGtkCTreeRow_is_leaf* = 0'i16
-  bm_TGtkCTreeRow_expanded* = 0x0002'i16
-  bp_TGtkCTreeRow_expanded* = 1'i16
-
-proc TYPE_CTREE*(): GType
-proc CTREE*(obj: pointer): PCTree
-proc CTREE_CLASS*(klass: pointer): PCTreeClass
-proc IS_CTREE*(obj: pointer): bool
-proc IS_CTREE_CLASS*(klass: pointer): bool
-proc CTREE_GET_CLASS*(obj: pointer): PCTreeClass
-proc CTREE_ROW*(node: TAddress): PCTreeRow
-proc CTREE_NODE*(node: TAddress): PCTreeNode
-proc CTREE_NODE_NEXT*(nnode: TAddress): PCTreeNode
-proc CTREE_NODE_PREV*(pnode: TAddress): PCTreeNode
-proc CTREE_FUNC*(fun: TAddress): TCTreeFunc
-proc TYPE_CTREE_NODE*(): GType
-proc line_style*(a: PCTree): guint
-proc set_line_style*(a: PCTree, `line_style`: guint)
-proc expander_style*(a: PCTree): guint
-proc set_expander_style*(a: PCTree, `expander_style`: guint)
-proc show_stub*(a: PCTree): guint
-proc set_show_stub*(a: PCTree, `show_stub`: guint)
-proc is_leaf*(a: PCTreeRow): guint
-proc set_is_leaf*(a: PCTreeRow, `is_leaf`: guint)
-proc expanded*(a: PCTreeRow): guint
-proc set_expanded*(a: PCTreeRow, `expanded`: guint)
-proc ctree_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_ctree_get_type".}
-proc ctree_new*(columns: gint, tree_column: gint): PCTree{.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_new".}
-proc insert_node*(ctree: PCTree, parent: PCTreeNode, sibling: PCTreeNode, 
-                        text: openarray[cstring], spacing: guint8, 
-                        pixmap_closed: gdk2.PPixmap, mask_closed: gdk2.PBitmap, 
-                        pixmap_opened: gdk2.PPixmap, mask_opened: gdk2.PBitmap, 
-                        is_leaf: gboolean, expanded: gboolean): PCTreeNode{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_insert_node".}
-proc remove_node*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_remove_node".}
-proc insert_gnode*(ctree: PCTree, parent: PCTreeNode, sibling: PCTreeNode, 
-                         gnode: PGNode, fun: TCTreeGNodeFunc, data: gpointer): PCTreeNode{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_insert_gnode".}
-proc export_to_gnode*(ctree: PCTree, parent: PGNode, sibling: PGNode, 
-                            node: PCTreeNode, fun: TCTreeGNodeFunc, 
-                            data: gpointer): PGNode{.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_export_to_gnode".}
-proc post_recursive*(ctree: PCTree, node: PCTreeNode, fun: TCTreeFunc, 
-                           data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_post_recursive".}
-proc post_recursive_to_depth*(ctree: PCTree, node: PCTreeNode, 
-                                    depth: gint, fun: TCTreeFunc, 
-                                    data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_post_recursive_to_depth".}
-proc pre_recursive*(ctree: PCTree, node: PCTreeNode, fun: TCTreeFunc, 
-                          data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_pre_recursive".}
-proc pre_recursive_to_depth*(ctree: PCTree, node: PCTreeNode, 
-                                   depth: gint, fun: TCTreeFunc, 
-                                   data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_pre_recursive_to_depth".}
-proc is_viewable*(ctree: PCTree, node: PCTreeNode): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_is_viewable".}
-proc last*(ctree: PCTree, node: PCTreeNode): PCTreeNode{.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_last".}
-proc find_node_ptr*(ctree: PCTree, ctree_row: PCTreeRow): PCTreeNode{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_find_node_ptr".}
-proc node_nth*(ctree: PCTree, row: guint): PCTreeNode{.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_nth".}
-proc find*(ctree: PCTree, node: PCTreeNode, child: PCTreeNode): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_find".}
-proc is_ancestor*(ctree: PCTree, node: PCTreeNode, child: PCTreeNode): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_is_ancestor".}
-proc find_by_row_data*(ctree: PCTree, node: PCTreeNode, data: gpointer): PCTreeNode{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_find_by_row_data".}
-proc find_all_by_row_data*(ctree: PCTree, node: PCTreeNode, 
-                                 data: gpointer): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_find_all_by_row_data".}
-proc find_by_row_data_custom*(ctree: PCTree, node: PCTreeNode, 
-                                    data: gpointer, fun: TGCompareFunc): PCTreeNode{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_find_by_row_data_custom".}
-proc find_all_by_row_data_custom*(ctree: PCTree, node: PCTreeNode, 
-                                        data: gpointer, fun: TGCompareFunc): PGList{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_find_all_by_row_data_custom".}
-proc is_hot_spot*(ctree: PCTree, x: gint, y: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_is_hot_spot".}
-proc move*(ctree: PCTree, node: PCTreeNode, new_parent: PCTreeNode, 
-                 new_sibling: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_move".}
-proc expand*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_expand".}
-proc expand_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_expand_recursive".}
-proc expand_to_depth*(ctree: PCTree, node: PCTreeNode, depth: gint){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_expand_to_depth".}
-proc collapse*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_collapse".}
-proc collapse_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_collapse_recursive".}
-proc collapse_to_depth*(ctree: PCTree, node: PCTreeNode, depth: gint){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_collapse_to_depth".}
-proc toggle_expansion*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_toggle_expansion".}
-proc toggle_expansion_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_toggle_expansion_recursive".}
-proc select*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_select".}
-proc select_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_select_recursive".}
-proc unselect*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_unselect".}
-proc unselect_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_unselect_recursive".}
-proc real_select_recursive*(ctree: PCTree, node: PCTreeNode, state: gint){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_real_select_recursive".}
-proc node_set_text*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                          text: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_text".}
-proc node_set_pixmap*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                            pixmap: gdk2.PPixmap, mask: gdk2.PBitmap){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_node_set_pixmap".}
-proc node_set_pixtext*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                             text: cstring, spacing: guint8, pixmap: gdk2.PPixmap, 
-                             mask: gdk2.PBitmap){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_pixtext".}
-proc set_node_info*(ctree: PCTree, node: PCTreeNode, text: cstring, 
-                          spacing: guint8, pixmap_closed: gdk2.PPixmap, 
-                          mask_closed: gdk2.PBitmap, pixmap_opened: gdk2.PPixmap, 
-                          mask_opened: gdk2.PBitmap, is_leaf: gboolean, 
-                          expanded: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_set_node_info".}
-proc node_set_shift*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                           vertical: gint, horizontal: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_node_set_shift".}
-proc node_set_selectable*(ctree: PCTree, node: PCTreeNode, 
-                                selectable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_selectable".}
-proc node_get_selectable*(ctree: PCTree, node: PCTreeNode): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_get_selectable".}
-proc node_get_cell_type*(ctree: PCTree, node: PCTreeNode, column: gint): TCellType{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_get_cell_type".}
-proc node_get_text*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                          text: PPgchar): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_get_text".}
-proc node_set_row_style*(ctree: PCTree, node: PCTreeNode, style: PStyle){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_set_row_style".}
-proc node_get_row_style*(ctree: PCTree, node: PCTreeNode): PStyle{.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_node_get_row_style".}
-proc node_set_cell_style*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                                style: PStyle){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_cell_style".}
-proc node_get_cell_style*(ctree: PCTree, node: PCTreeNode, column: gint): PStyle{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_get_cell_style".}
-proc node_set_foreground*(ctree: PCTree, node: PCTreeNode, 
-                                color: gdk2.PColor){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_foreground".}
-proc node_set_background*(ctree: PCTree, node: PCTreeNode, 
-                                color: gdk2.PColor){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_node_set_background".}
-proc node_set_row_data*(ctree: PCTree, node: PCTreeNode, data: gpointer){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_set_row_data".}
-proc node_set_row_data_full*(ctree: PCTree, node: PCTreeNode, 
-                                   data: gpointer, destroy: TDestroyNotify){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_set_row_data_full".}
-proc node_get_row_data*(ctree: PCTree, node: PCTreeNode): gpointer{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_get_row_data".}
-proc node_moveto*(ctree: PCTree, node: PCTreeNode, column: gint, 
-                        row_align: gfloat, col_align: gfloat){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_node_moveto".}
-proc node_is_visible*(ctree: PCTree, node: PCTreeNode): TVisibility{.
-    cdecl, dynlib: lib, importc: "gtk_ctree_node_is_visible".}
-proc set_indent*(ctree: PCTree, indent: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_set_indent".}
-proc set_spacing*(ctree: PCTree, spacing: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_set_spacing".}
-proc set_show_stub*(ctree: PCTree, show_stub: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_set_show_stub".}
-proc set_line_style*(ctree: PCTree, line_style: TCTreeLineStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_set_line_style".}
-proc set_expander_style*(ctree: PCTree, 
-                               expander_style: TCTreeExpanderStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_set_expander_style".}
-proc set_drag_compare_func*(ctree: PCTree, cmp_func: TCTreeCompareDragFunc){.
-    cdecl, dynlib: lib, importc: "gtk_ctree_set_drag_compare_func".}
-proc sort_node*(ctree: PCTree, node: PCTreeNode){.cdecl, dynlib: lib, 
-    importc: "gtk_ctree_sort_node".}
-proc sort_recursive*(ctree: PCTree, node: PCTreeNode){.cdecl, 
-    dynlib: lib, importc: "gtk_ctree_sort_recursive".}
-proc ctree_set_reorderable*(t: pointer, r: bool)
-proc ctree_node_get_type*(): GType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_ctree_node_get_type".}
-proc TYPE_DRAWING_AREA*(): GType
-proc DRAWING_AREA*(obj: pointer): PDrawingArea
-proc DRAWING_AREA_CLASS*(klass: pointer): PDrawingAreaClass
-proc IS_DRAWING_AREA*(obj: pointer): bool
-proc IS_DRAWING_AREA_CLASS*(klass: pointer): bool
-proc DRAWING_AREA_GET_CLASS*(obj: pointer): PDrawingAreaClass
-proc drawing_area_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_drawing_area_get_type".}
-proc drawing_area_new*(): PDrawingArea{.cdecl, dynlib: lib, 
-                                        importc: "gtk_drawing_area_new".}
-proc TYPE_CURVE*(): GType
-proc CURVE*(obj: pointer): PCurve
-proc CURVE_CLASS*(klass: pointer): PCurveClass
-proc IS_CURVE*(obj: pointer): bool
-proc IS_CURVE_CLASS*(klass: pointer): bool
-proc CURVE_GET_CLASS*(obj: pointer): PCurveClass
-proc curve_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_curve_get_type".}
-proc curve_new*(): PCurve{.cdecl, dynlib: lib, importc: "gtk_curve_new".}
-proc reset*(curve: PCurve){.cdecl, dynlib: lib, importc: "gtk_curve_reset".}
-proc set_gamma*(curve: PCurve, gamma: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_curve_set_gamma".}
-proc set_range*(curve: PCurve, min_x: gfloat, max_x: gfloat, 
-                      min_y: gfloat, max_y: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_curve_set_range".}
-proc set_curve_type*(curve: PCurve, thetype: TCurveType){.cdecl, 
-    dynlib: lib, importc: "gtk_curve_set_curve_type".}
-const 
-  DEST_DEFAULT_MOTION* = 1 shl 0
-  DEST_DEFAULT_HIGHLIGHT* = 1 shl 1
-  DEST_DEFAULT_DROP* = 1 shl 2
-  DEST_DEFAULT_ALL* = 0x00000007
-  TARGET_SAME_APP* = 1 shl 0
-  TARGET_SAME_WIDGET* = 1 shl 1
-
-proc drag_get_data*(widget: PWidget, context: gdk2.PDragContext, target: gdk2.TAtom, 
-                    time: guint32){.cdecl, dynlib: lib, 
-                                    importc: "gtk_drag_get_data".}
-proc drag_finish*(context: gdk2.PDragContext, success: gboolean, del: gboolean, 
-                  time: guint32){.cdecl, dynlib: lib, importc: "gtk_drag_finish".}
-proc drag_get_source_widget*(context: gdk2.PDragContext): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_drag_get_source_widget".}
-proc drag_highlight*(widget: PWidget){.cdecl, dynlib: lib, 
-                                       importc: "gtk_drag_highlight".}
-proc drag_unhighlight*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_unhighlight".}
-proc drag_dest_set*(widget: PWidget, flags: TDestDefaults, 
-                    targets: PTargetEntry, n_targets: gint, 
-                    actions: gdk2.TDragAction){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_dest_set".}
-proc drag_dest_set_proxy*(widget: PWidget, proxy_window: gdk2.PWindow, 
-                          protocol: gdk2.TDragProtocol, use_coordinates: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_drag_dest_set_proxy".}
-proc drag_dest_unset*(widget: PWidget){.cdecl, dynlib: lib, 
-                                        importc: "gtk_drag_dest_unset".}
-proc drag_dest_find_target*(widget: PWidget, context: gdk2.PDragContext, 
-                            target_list: PTargetList): gdk2.TAtom{.cdecl, 
-    dynlib: lib, importc: "gtk_drag_dest_find_target".}
-proc drag_dest_get_target_list*(widget: PWidget): PTargetList{.cdecl, 
-    dynlib: lib, importc: "gtk_drag_dest_get_target_list".}
-proc drag_dest_set_target_list*(widget: PWidget, target_list: PTargetList){.
-    cdecl, dynlib: lib, importc: "gtk_drag_dest_set_target_list".}
-proc drag_source_set*(widget: PWidget, start_button_mask: gdk2.TModifierType, 
-                      targets: PTargetEntry, n_targets: gint, 
-                      actions: gdk2.TDragAction){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_source_set".}
-proc drag_source_unset*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_source_unset".}
-proc drag_source_set_icon*(widget: PWidget, colormap: gdk2.PColormap, 
-                           pixmap: gdk2.PPixmap, mask: gdk2.PBitmap){.cdecl, 
-    dynlib: lib, importc: "gtk_drag_source_set_icon".}
-proc drag_source_set_icon_pixbuf*(widget: PWidget, pixbuf: gdk2pixbuf.PPixbuf){.cdecl, 
-    dynlib: lib, importc: "gtk_drag_source_set_icon_pixbuf".}
-proc drag_source_set_icon_stock*(widget: PWidget, stock_id: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_drag_source_set_icon_stock".}
-proc drag_begin*(widget: PWidget, targets: PTargetList, actions: gdk2.TDragAction, 
-                 button: gint, event: gdk2.PEvent): gdk2.PDragContext{.cdecl, 
-    dynlib: lib, importc: "gtk_drag_begin".}
-proc drag_set_icon_widget*(context: gdk2.PDragContext, widget: PWidget, 
-                           hot_x: gint, hot_y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_set_icon_widget".}
-proc drag_set_icon_pixmap*(context: gdk2.PDragContext, colormap: gdk2.PColormap, 
-                           pixmap: gdk2.PPixmap, mask: gdk2.PBitmap, hot_x: gint, 
-                           hot_y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_set_icon_pixmap".}
-proc drag_set_icon_pixbuf*(context: gdk2.PDragContext, pixbuf: gdk2pixbuf.PPixbuf, 
-                           hot_x: gint, hot_y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_set_icon_pixbuf".}
-proc drag_set_icon_stock*(context: gdk2.PDragContext, stock_id: cstring, 
-                          hot_x: gint, hot_y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_set_icon_stock".}
-proc drag_set_icon_default*(context: gdk2.PDragContext){.cdecl, dynlib: lib, 
-    importc: "gtk_drag_set_icon_default".}
-proc drag_check_threshold*(widget: PWidget, start_x: gint, start_y: gint, 
-                           current_x: gint, current_y: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_drag_check_threshold".}
-proc drag_source_handle_event*(widget: PWidget, event: gdk2.PEvent){.cdecl, 
-    dynlib: lib, importc: "_gtk_drag_source_handle_event".}
-proc drag_dest_handle_event*(toplevel: PWidget, event: gdk2.PEvent){.cdecl, 
-    dynlib: lib, importc: "_gtk_drag_dest_handle_event".}
-proc TYPE_EDITABLE*(): GType
-proc EDITABLE*(obj: pointer): PEditable
-proc EDITABLE_CLASS*(vtable: pointer): PEditableClass
-proc IS_EDITABLE*(obj: pointer): bool
-proc IS_EDITABLE_CLASS*(vtable: pointer): bool
-proc EDITABLE_GET_CLASS*(inst: pointer): PEditableClass
-proc editable_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_editable_get_type".}
-proc select_region*(editable: PEditable, start: gint, theEnd: gint){.
-    cdecl, dynlib: lib, importc: "gtk_editable_select_region".}
-proc get_selection_bounds*(editable: PEditable, start: Pgint, 
-                                    theEnd: Pgint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_editable_get_selection_bounds".}
-proc insert_text*(editable: PEditable, new_text: cstring, 
-                           new_text_length: gint, position: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_editable_insert_text".}
-proc delete_text*(editable: PEditable, start_pos: gint, end_pos: gint){.
-    cdecl, dynlib: lib, importc: "gtk_editable_delete_text".}
-proc get_chars*(editable: PEditable, start_pos: gint, end_pos: gint): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_editable_get_chars".}
-proc cut_clipboard*(editable: PEditable){.cdecl, dynlib: lib, 
-    importc: "gtk_editable_cut_clipboard".}
-proc copy_clipboard*(editable: PEditable){.cdecl, dynlib: lib, 
-    importc: "gtk_editable_copy_clipboard".}
-proc paste_clipboard*(editable: PEditable){.cdecl, dynlib: lib, 
-    importc: "gtk_editable_paste_clipboard".}
-proc delete_selection*(editable: PEditable){.cdecl, dynlib: lib, 
-    importc: "gtk_editable_delete_selection".}
-proc set_position*(editable: PEditable, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_editable_set_position".}
-proc get_position*(editable: PEditable): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_editable_get_position".}
-proc set_editable*(editable: PEditable, is_editable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_editable_set_editable".}
-proc get_editable*(editable: PEditable): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_editable_get_editable".}
-proc TYPE_IM_CONTEXT*(): GType
-proc IM_CONTEXT*(obj: pointer): PIMContext
-proc IM_CONTEXT_CLASS*(klass: pointer): PIMContextClass
-proc IS_IM_CONTEXT*(obj: pointer): bool
-proc IS_IM_CONTEXT_CLASS*(klass: pointer): bool
-proc IM_CONTEXT_GET_CLASS*(obj: pointer): PIMContextClass
-proc im_context_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_im_context_get_type".}
-proc set_client_window*(context: PIMContext, window: gdk2.PWindow){.
-    cdecl, dynlib: lib, importc: "gtk_im_context_set_client_window".}
-proc filter_keypress*(context: PIMContext, event: gdk2.PEventKey): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_im_context_filter_keypress".}
-proc focus_in*(context: PIMContext){.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_focus_in".}
-proc focus_out*(context: PIMContext){.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_focus_out".}
-proc reset*(context: PIMContext){.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_reset".}
-proc set_cursor_location*(context: PIMContext, area: gdk2.PRectangle){.
-    cdecl, dynlib: lib, importc: "gtk_im_context_set_cursor_location".}
-proc set_use_preedit*(context: PIMContext, use_preedit: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_im_context_set_use_preedit".}
-proc set_surrounding*(context: PIMContext, text: cstring, len: gint, 
-                                 cursor_index: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_set_surrounding".}
-proc get_surrounding*(context: PIMContext, text: PPgchar, 
-                                 cursor_index: Pgint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_im_context_get_surrounding".}
-proc delete_surrounding*(context: PIMContext, offset: gint, 
-                                    n_chars: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_im_context_delete_surrounding".}
-const 
-  bm_TGtkMenuShell_active* = 0x0001'i16
-  bp_TGtkMenuShell_active* = 0'i16
-  bm_TGtkMenuShell_have_grab* = 0x0002'i16
-  bp_TGtkMenuShell_have_grab* = 1'i16
-  bm_TGtkMenuShell_have_xgrab* = 0x0004'i16
-  bp_TGtkMenuShell_have_xgrab* = 2'i16
-  bm_TGtkMenuShell_ignore_leave* = 0x0008'i16
-  bp_TGtkMenuShell_ignore_leave* = 3'i16
-  bm_TGtkMenuShell_menu_flag* = 0x0010'i16
-  bp_TGtkMenuShell_menu_flag* = 4'i16
-  bm_TGtkMenuShell_ignore_enter* = 0x0020'i16
-  bp_TGtkMenuShell_ignore_enter* = 5'i16
-  bm_TGtkMenuShellClass_submenu_placement* = 0x0001'i16
-  bp_TGtkMenuShellClass_submenu_placement* = 0'i16
-
-proc TYPE_MENU_SHELL*(): GType
-proc MENU_SHELL*(obj: pointer): PMenuShell
-proc MENU_SHELL_CLASS*(klass: pointer): PMenuShellClass
-proc IS_MENU_SHELL*(obj: pointer): bool
-proc IS_MENU_SHELL_CLASS*(klass: pointer): bool
-proc MENU_SHELL_GET_CLASS*(obj: pointer): PMenuShellClass
-proc active*(a: PMenuShell): guint
-proc set_active*(a: PMenuShell, `active`: guint)
-proc have_grab*(a: PMenuShell): guint
-proc set_have_grab*(a: PMenuShell, `have_grab`: guint)
-proc have_xgrab*(a: PMenuShell): guint
-proc set_have_xgrab*(a: PMenuShell, `have_xgrab`: guint)
-proc ignore_leave*(a: PMenuShell): guint
-proc set_ignore_leave*(a: PMenuShell, `ignore_leave`: guint)
-proc menu_flag*(a: PMenuShell): guint
-proc set_menu_flag*(a: PMenuShell, `menu_flag`: guint)
-proc ignore_enter*(a: PMenuShell): guint
-proc set_ignore_enter*(a: PMenuShell, `ignore_enter`: guint)
-proc submenu_placement*(a: PMenuShellClass): guint
-proc set_submenu_placement*(a: PMenuShellClass, `submenu_placement`: guint)
-proc menu_shell_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_menu_shell_get_type".}
-proc append*(menu_shell: PMenuShell, child: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_shell_append".}
-proc prepend*(menu_shell: PMenuShell, child: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_shell_prepend".}
-proc insert*(menu_shell: PMenuShell, child: PWidget, position: gint){.
-    cdecl, dynlib: lib, importc: "gtk_menu_shell_insert".}
-proc deactivate*(menu_shell: PMenuShell){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_shell_deactivate".}
-proc select_item*(menu_shell: PMenuShell, menu_item: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_shell_select_item".}
-proc deselect*(menu_shell: PMenuShell){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_shell_deselect".}
-proc activate_item*(menu_shell: PMenuShell, menu_item: PWidget, 
-                               force_deactivate: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_shell_activate_item".}
-proc select_first*(menu_shell: PMenuShell){.cdecl, dynlib: lib, 
-    importc: "_gtk_menu_shell_select_first".}
-proc activate*(menu_shell: PMenuShell){.cdecl, dynlib: lib, 
-    importc: "_gtk_menu_shell_activate".}
-const 
-  bm_TGtkMenu_needs_destruction_ref_count* = 0x0001'i16
-  bp_TGtkMenu_needs_destruction_ref_count* = 0'i16
-  bm_TGtkMenu_torn_off* = 0x0002'i16
-  bp_TGtkMenu_torn_off* = 1'i16
-  bm_TGtkMenu_tearoff_active* = 0x0004'i16
-  bp_TGtkMenu_tearoff_active* = 2'i16
-  bm_TGtkMenu_scroll_fast* = 0x0008'i16
-  bp_TGtkMenu_scroll_fast* = 3'i16
-  bm_TGtkMenu_upper_arrow_visible* = 0x0010'i16
-  bp_TGtkMenu_upper_arrow_visible* = 4'i16
-  bm_TGtkMenu_lower_arrow_visible* = 0x0020'i16
-  bp_TGtkMenu_lower_arrow_visible* = 5'i16
-  bm_TGtkMenu_upper_arrow_prelight* = 0x0040'i16
-  bp_TGtkMenu_upper_arrow_prelight* = 6'i16
-  bm_TGtkMenu_lower_arrow_prelight* = 0x0080'i16
-  bp_TGtkMenu_lower_arrow_prelight* = 7'i16
-
-proc TYPE_MENU*(): GType
-proc MENU*(obj: pointer): PMenu
-proc MENU_CLASS*(klass: pointer): PMenuClass
-proc IS_MENU*(obj: pointer): bool
-proc IS_MENU_CLASS*(klass: pointer): bool
-proc MENU_GET_CLASS*(obj: pointer): PMenuClass
-proc needs_destruction_ref_count*(a: PMenu): guint
-proc set_needs_destruction_ref_count*(a: PMenu, 
-                                      `needs_destruction_ref_count`: guint)
-proc torn_off*(a: PMenu): guint
-proc set_torn_off*(a: PMenu, `torn_off`: guint)
-proc tearoff_active*(a: PMenu): guint
-proc set_tearoff_active*(a: PMenu, `tearoff_active`: guint)
-proc scroll_fast*(a: PMenu): guint
-proc set_scroll_fast*(a: PMenu, `scroll_fast`: guint)
-proc upper_arrow_visible*(a: PMenu): guint
-proc set_upper_arrow_visible*(a: PMenu, `upper_arrow_visible`: guint)
-proc lower_arrow_visible*(a: PMenu): guint
-proc set_lower_arrow_visible*(a: PMenu, `lower_arrow_visible`: guint)
-proc upper_arrow_prelight*(a: PMenu): guint
-proc set_upper_arrow_prelight*(a: PMenu, `upper_arrow_prelight`: guint)
-proc lower_arrow_prelight*(a: PMenu): guint
-proc set_lower_arrow_prelight*(a: PMenu, `lower_arrow_prelight`: guint)
-proc menu_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_menu_get_type".}
-proc menu_new*(): PMenu{.cdecl, dynlib: lib, importc: "gtk_menu_new".}
-proc popup*(menu: PMenu, parent_menu_shell: PWidget, 
-                 parent_menu_item: PWidget, fun: TMenuPositionFunc, 
-                 data: gpointer, button: guint, activate_time: guint32){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_popup".}
-proc reposition*(menu: PMenu){.cdecl, dynlib: lib, 
-                                    importc: "gtk_menu_reposition".}
-proc popdown*(menu: PMenu){.cdecl, dynlib: lib, importc: "gtk_menu_popdown".}
-proc get_active*(menu: PMenu): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_get_active".}
-proc set_active*(menu: PMenu, index: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_set_active".}
-proc set_accel_group*(menu: PMenu, accel_group: PAccelGroup){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_set_accel_group".}
-proc get_accel_group*(menu: PMenu): PAccelGroup{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_get_accel_group".}
-proc set_accel_path*(menu: PMenu, accel_path: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_set_accel_path".}
-proc attach_to_widget*(menu: PMenu, attach_widget: PWidget, 
-                            detacher: TMenuDetachFunc){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_attach_to_widget".}
-proc detach*(menu: PMenu){.cdecl, dynlib: lib, importc: "gtk_menu_detach".}
-proc get_attach_widget*(menu: PMenu): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_get_attach_widget".}
-proc set_tearoff_state*(menu: PMenu, torn_off: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_set_tearoff_state".}
-proc get_tearoff_state*(menu: PMenu): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_get_tearoff_state".}
-proc set_title*(menu: PMenu, title: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_set_title".}
-proc get_title*(menu: PMenu): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_menu_get_title".}
-proc reorder_child*(menu: PMenu, child: PWidget, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_menu_reorder_child".}
-proc set_screen*(menu: PMenu, screen: gdk2.PScreen){.cdecl, dynlib: lib, 
-    importc: "gtk_menu_set_screen".}
-const 
-  bm_TGtkEntry_editable* = 0x0001'i16
-  bp_TGtkEntry_editable* = 0'i16
-  bm_TGtkEntry_visible* = 0x0002'i16
-  bp_TGtkEntry_visible* = 1'i16
-  bm_TGtkEntry_overwrite_mode* = 0x0004'i16
-  bp_TGtkEntry_overwrite_mode* = 2'i16
-  bm_TGtkEntry_in_drag* = 0x0008'i16
-  bp_TGtkEntry_in_drag* = 3'i16
-  bm_TGtkEntry_cache_includes_preedit* = 0x0001'i16
-  bp_TGtkEntry_cache_includes_preedit* = 0'i16
-  bm_TGtkEntry_need_im_reset* = 0x0002'i16
-  bp_TGtkEntry_need_im_reset* = 1'i16
-  bm_TGtkEntry_has_frame* = 0x0004'i16
-  bp_TGtkEntry_has_frame* = 2'i16
-  bm_TGtkEntry_activates_default* = 0x0008'i16
-  bp_TGtkEntry_activates_default* = 3'i16
-  bm_TGtkEntry_cursor_visible* = 0x0010'i16
-  bp_TGtkEntry_cursor_visible* = 4'i16
-  bm_TGtkEntry_in_click* = 0x0020'i16
-  bp_TGtkEntry_in_click* = 5'i16
-  bm_TGtkEntry_is_cell_renderer* = 0x0040'i16
-  bp_TGtkEntry_is_cell_renderer* = 6'i16
-  bm_TGtkEntry_editing_canceled* = 0x0080'i16
-  bp_TGtkEntry_editing_canceled* = 7'i16
-  bm_TGtkEntry_mouse_cursor_obscured* = 0x0100'i16
-  bp_TGtkEntry_mouse_cursor_obscured* = 8'i16
-
-proc TYPE_ENTRY*(): GType
-proc ENTRY*(obj: pointer): PEntry
-proc ENTRY_CLASS*(klass: pointer): PEntryClass
-proc IS_ENTRY*(obj: pointer): bool
-proc IS_ENTRY_CLASS*(klass: pointer): bool
-proc ENTRY_GET_CLASS*(obj: pointer): PEntryClass
-proc editable*(a: PEntry): guint
-proc set_editable*(a: PEntry, `editable`: guint)
-proc visible*(a: PEntry): guint
-proc set_visible*(a: PEntry, `visible`: guint)
-proc overwrite_mode*(a: PEntry): guint
-proc set_overwrite_mode*(a: PEntry, `overwrite_mode`: guint)
-proc in_drag*(a: PEntry): guint
-proc set_in_drag*(a: PEntry, `in_drag`: guint)
-proc cache_includes_preedit*(a: PEntry): guint
-proc set_cache_includes_preedit*(a: PEntry, `cache_includes_preedit`: guint)
-proc need_im_reset*(a: PEntry): guint
-proc set_need_im_reset*(a: PEntry, `need_im_reset`: guint)
-proc has_frame*(a: PEntry): guint
-proc set_has_frame*(a: PEntry, `has_frame`: guint)
-proc activates_default*(a: PEntry): guint
-proc set_activates_default*(a: PEntry, `activates_default`: guint)
-proc cursor_visible*(a: PEntry): guint
-proc set_cursor_visible*(a: PEntry, `cursor_visible`: guint)
-proc in_click*(a: PEntry): guint
-proc set_in_click*(a: PEntry, `in_click`: guint)
-proc is_cell_renderer*(a: PEntry): guint
-proc set_is_cell_renderer*(a: PEntry, `is_cell_renderer`: guint)
-proc editing_canceled*(a: PEntry): guint
-proc set_editing_canceled*(a: PEntry, `editing_canceled`: guint)
-proc mouse_cursor_obscured*(a: PEntry): guint
-proc set_mouse_cursor_obscured*(a: PEntry, `mouse_cursor_obscured`: guint)
-proc entry_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_entry_get_type".}
-proc entry_new*(): PEntry{.cdecl, dynlib: lib, importc: "gtk_entry_new".}
-proc set_visibility*(entry: PEntry, visible: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_entry_set_visibility".}
-proc get_visibility*(entry: PEntry): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_visibility".}
-proc set_invisible_char*(entry: PEntry, ch: gunichar){.cdecl, dynlib: lib, 
-    importc: "gtk_entry_set_invisible_char".}
-proc get_invisible_char*(entry: PEntry): gunichar{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_invisible_char".}
-proc set_has_frame*(entry: PEntry, setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_entry_set_has_frame".}
-proc get_has_frame*(entry: PEntry): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_has_frame".}
-proc set_max_length*(entry: PEntry, max: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_entry_set_max_length".}
-proc get_max_length*(entry: PEntry): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_max_length".}
-proc set_activates_default*(entry: PEntry, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_entry_set_activates_default".}
-proc get_activates_default*(entry: PEntry): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_activates_default".}
-proc set_width_chars*(entry: PEntry, n_chars: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_entry_set_width_chars".}
-proc get_width_chars*(entry: PEntry): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_width_chars".}
-proc set_text*(entry: PEntry, text: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_entry_set_text".}
-proc get_text*(entry: PEntry): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_text".}
-proc get_layout*(entry: PEntry): pango.PLayout{.cdecl, dynlib: lib, 
-    importc: "gtk_entry_get_layout".}
-proc get_layout_offsets*(entry: PEntry, x: Pgint, y: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_entry_get_layout_offsets".}
-const 
-  ANCHOR_CENTER* = 0
-  ANCHOR_NORTH* = 1
-  ANCHOR_NORTH_WEST* = 2
-  ANCHOR_NORTH_EAST* = 3
-  ANCHOR_SOUTH* = 4
-  ANCHOR_SOUTH_WEST* = 5
-  ANCHOR_SOUTH_EAST* = 6
-  ANCHOR_WEST* = 7
-  ANCHOR_EAST* = 8
-  ANCHOR_N* = ANCHOR_NORTH
-  ANCHOR_NW* = ANCHOR_NORTH_WEST
-  ANCHOR_NE* = ANCHOR_NORTH_EAST
-  ANCHOR_S* = ANCHOR_SOUTH
-  ANCHOR_SW* = ANCHOR_SOUTH_WEST
-  ANCHOR_SE* = ANCHOR_SOUTH_EAST
-  ANCHOR_W* = ANCHOR_WEST
-  ANCHOR_E* = ANCHOR_EAST
-  ARROW_UP* = 0
-  ARROW_DOWN* = 1
-  ARROW_LEFT* = 2
-  ARROW_RIGHT* = 3
-  constEXPAND* = 1 shl 0
-  constSHRINK* = 1 shl 1
-  constFILL* = 1 shl 2
-  BUTTONBOX_DEFAULT_STYLE* = 0
-  BUTTONBOX_SPREAD* = 1
-  BUTTONBOX_EDGE* = 2
-  BUTTONBOX_START* = 3
-  BUTTONBOX_END* = 4
-  CURVE_TYPE_LINEAR* = 0
-  CURVE_TYPE_SPLINE* = 1
-  CURVE_TYPE_FREE* = 2
-  DELETE_CHARS* = 0
-  DELETE_WORD_ENDS* = 1
-  DELETE_WORDS* = 2
-  DELETE_DISPLAY_LINES* = 3
-  DELETE_DISPLAY_LINE_ENDS* = 4
-  DELETE_PARAGRAPH_ENDS* = 5
-  DELETE_PARAGRAPHS* = 6
-  DELETE_WHITESPACE* = 7
-  DIR_TAB_FORWARD* = 0
-  DIR_TAB_BACKWARD* = 1
-  DIR_UP* = 2
-  DIR_DOWN* = 3
-  DIR_LEFT* = 4
-  DIR_RIGHT* = 5
-  EXPANDER_COLLAPSED* = 0
-  EXPANDER_SEMI_COLLAPSED* = 1
-  EXPANDER_SEMI_EXPANDED* = 2
-  EXPANDER_EXPANDED* = 3
-  ICON_SIZE_INVALID* = 0
-  ICON_SIZE_MENU* = 1
-  ICON_SIZE_SMALL_TOOLBAR* = 2
-  ICON_SIZE_LARGE_TOOLBAR* = 3
-  ICON_SIZE_BUTTON* = 4
-  ICON_SIZE_DND* = 5
-  ICON_SIZE_DIALOG* = 6
-  TEXT_DIR_NONE* = 0
-  TEXT_DIR_LTR* = 1
-  TEXT_DIR_RTL* = 2
-  JUSTIFY_LEFT* = 0
-  JUSTIFY_RIGHT* = 1
-  JUSTIFY_CENTER* = 2
-  JUSTIFY_FILL* = 3
-  MENU_DIR_PARENT* = 0
-  MENU_DIR_CHILD* = 1
-  MENU_DIR_NEXT* = 2
-  MENU_DIR_PREV* = 3
-  PIXELS* = 0
-  INCHES* = 1
-  CENTIMETERS* = 2
-  MOVEMENT_LOGICAL_POSITIONS* = 0
-  MOVEMENT_VISUAL_POSITIONS* = 1
-  MOVEMENT_WORDS* = 2
-  MOVEMENT_DISPLAY_LINES* = 3
-  MOVEMENT_DISPLAY_LINE_ENDS* = 4
-  MOVEMENT_PARAGRAPHS* = 5
-  MOVEMENT_PARAGRAPH_ENDS* = 6
-  MOVEMENT_PAGES* = 7
-  MOVEMENT_BUFFER_ENDS* = 8
-  ORIENTATION_HORIZONTAL* = 0
-  ORIENTATION_VERTICAL* = 1
-  CORNER_TOP_LEFT* = 0
-  CORNER_BOTTOM_LEFT* = 1
-  CORNER_TOP_RIGHT* = 2
-  CORNER_BOTTOM_RIGHT* = 3
-  constPACK_START* = 0
-  constPACK_END* = 1
-  PATH_PRIO_LOWEST* = 0
-  PATH_PRIO_GTK* = 4
-  PATH_PRIO_APPLICATION* = 8
-  PATH_PRIO_THEME* = 10
-  PATH_PRIO_RC* = 12
-  PATH_PRIO_HIGHEST* = 15
-  PATH_WIDGET* = 0
-  PATH_WIDGET_CLASS* = 1
-  PATH_CLASS* = 2
-  POLICY_ALWAYS* = 0
-  POLICY_AUTOMATIC* = 1
-  POLICY_NEVER* = 2
-  POS_LEFT* = 0
-  POS_RIGHT* = 1
-  POS_TOP* = 2
-  POS_BOTTOM* = 3
-  PREVIEW_COLOR* = 0
-  PREVIEW_GRAYSCALE* = 1
-  RELIEF_NORMAL* = 0
-  RELIEF_HALF* = 1
-  RELIEF_NONE* = 2
-  RESIZE_PARENT* = 0
-  RESIZE_QUEUE* = 1
-  RESIZE_IMMEDIATE* = 2
-  SCROLL_NONE* = 0
-  SCROLL_JUMP* = 1
-  SCROLL_STEP_BACKWARD* = 2
-  SCROLL_STEP_FORWARD* = 3
-  SCROLL_PAGE_BACKWARD* = 4
-  SCROLL_PAGE_FORWARD* = 5
-  SCROLL_STEP_UP* = 6
-  SCROLL_STEP_DOWN* = 7
-  SCROLL_PAGE_UP* = 8
-  SCROLL_PAGE_DOWN* = 9
-  SCROLL_STEP_LEFT* = 10
-  SCROLL_STEP_RIGHT* = 11
-  SCROLL_PAGE_LEFT* = 12
-  SCROLL_PAGE_RIGHT* = 13
-  SCROLL_START* = 14
-  SCROLL_END* = 15
-  SELECTION_NONE* = 0
-  SELECTION_SINGLE* = 1
-  SELECTION_BROWSE* = 2
-  SELECTION_MULTIPLE* = 3
-  SELECTION_EXTENDED* = SELECTION_MULTIPLE
-  SHADOW_NONE* = 0
-  SHADOW_IN* = 1
-  SHADOW_OUT* = 2
-  SHADOW_ETCHED_IN* = 3
-  SHADOW_ETCHED_OUT* = 4
-  STATE_NORMAL* = 0
-  STATE_ACTIVE* = 1
-  STATE_PRELIGHT* = 2
-  STATE_SELECTED* = 3
-  STATE_INSENSITIVE* = 4
-  DIRECTION_LEFT* = 0
-  DIRECTION_RIGHT* = 1
-  TOP_BOTTOM* = 0
-  LEFT_RIGHT* = 1
-  TOOLBAR_ICONS* = 0
-  TOOLBAR_TEXT* = 1
-  TOOLBAR_BOTH* = 2
-  TOOLBAR_BOTH_HORIZ* = 3
-  UPDATE_CONTINUOUS* = 0
-  UPDATE_DISCONTINUOUS* = 1
-  UPDATE_DELAYED* = 2
-  VISIBILITY_NONE* = 0
-  VISIBILITY_PARTIAL* = 1
-  VISIBILITY_FULL* = 2
-  WIN_POS_NONE* = 0
-  WIN_POS_CENTER* = 1
-  WIN_POS_MOUSE* = 2
-  WIN_POS_CENTER_ALWAYS* = 3
-  WIN_POS_CENTER_ON_PARENT* = 4
-  WINDOW_TOPLEVEL* = 0
-  WINDOW_POPUP* = 1
-  WRAP_NONE* = 0
-  WRAP_CHAR* = 1
-  WRAP_WORD* = 2
-  SORT_ASCENDING* = 0
-  SORT_DESCENDING* = 1
-
-proc TYPE_EVENT_BOX*(): GType
-proc EVENT_BOX*(obj: pointer): PEventBox
-proc EVENT_BOX_CLASS*(klass: pointer): PEventBoxClass
-proc IS_EVENT_BOX*(obj: pointer): bool
-proc IS_EVENT_BOX_CLASS*(klass: pointer): bool
-proc EVENT_BOX_GET_CLASS*(obj: pointer): PEventBoxClass
-proc event_box_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_event_box_get_type".}
-proc event_box_new*(): PEventBox{.cdecl, dynlib: lib, 
-                                  importc: "gtk_event_box_new".}
-const 
-  FNM_PATHNAME* = 1 shl 0
-  FNM_NOESCAPE* = 1 shl 1
-  FNM_PERIOD* = 1 shl 2
-
-const 
-  FNM_FILE_NAME* = FNM_PATHNAME
-  FNM_LEADING_DIR* = 1 shl 3
-  FNM_CASEFOLD* = 1 shl 4
-
-const 
-  FNM_NOMATCH* = 1
-
-proc fnmatch*(`pattern`: char, `string`: char, `flags`: gint): gint{.cdecl, 
-    dynlib: lib, importc: "fnmatch".}
-proc TYPE_FILE_SELECTION*(): GType
-proc FILE_SELECTION*(obj: pointer): PFileSelection
-proc FILE_SELECTION_CLASS*(klass: pointer): PFileSelectionClass
-proc IS_FILE_SELECTION*(obj: pointer): bool
-proc IS_FILE_SELECTION_CLASS*(klass: pointer): bool
-proc FILE_SELECTION_GET_CLASS*(obj: pointer): PFileSelectionClass
-proc file_selection_get_type*(): TType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_file_selection_get_type".}
-proc file_selection_new*(title: cstring): PFileSelection{.cdecl, dynlib: lib, 
-    importc: "gtk_file_selection_new".}
-proc set_filename*(filesel: PFileSelection, filename: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_file_selection_set_filename".}
-proc get_filename*(filesel: PFileSelection): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_file_selection_get_filename".}
-proc complete*(filesel: PFileSelection, pattern: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_file_selection_complete".}
-proc show_fileop_buttons*(filesel: PFileSelection){.cdecl, 
-    dynlib: lib, importc: "gtk_file_selection_show_fileop_buttons".}
-proc hide_fileop_buttons*(filesel: PFileSelection){.cdecl, 
-    dynlib: lib, importc: "gtk_file_selection_hide_fileop_buttons".}
-proc get_selections*(filesel: PFileSelection): PPgchar{.cdecl, 
-    dynlib: lib, importc: "gtk_file_selection_get_selections".}
-proc set_select_multiple*(filesel: PFileSelection, 
-    select_multiple: gboolean){.cdecl, dynlib: lib, importc: "gtk_file_selection_set_select_multiple".}
-proc get_select_multiple*(filesel: PFileSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_selection_get_select_multiple".}
-proc TYPE_FIXED*(): GType
-proc FIXED*(obj: pointer): PFixed
-proc FIXED_CLASS*(klass: pointer): PFixedClass
-proc IS_FIXED*(obj: pointer): bool
-proc IS_FIXED_CLASS*(klass: pointer): bool
-proc FIXED_GET_CLASS*(obj: pointer): PFixedClass
-proc fixed_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_fixed_get_type".}
-proc fixed_new*(): PFixed{.cdecl, dynlib: lib, importc: "gtk_fixed_new".}
-proc put*(fixed: PFixed, widget: PWidget, x: gint, y: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_fixed_put".}
-proc move*(fixed: PFixed, widget: PWidget, x: gint, y: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_fixed_move".}
-proc set_has_window*(fixed: PFixed, has_window: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_fixed_set_has_window".}
-proc get_has_window*(fixed: PFixed): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_fixed_get_has_window".}
-proc TYPE_FONT_SELECTION*(): GType
-proc FONT_SELECTION*(obj: pointer): PFontSelection
-proc FONT_SELECTION_CLASS*(klass: pointer): PFontSelectionClass
-proc IS_FONT_SELECTION*(obj: pointer): bool
-proc IS_FONT_SELECTION_CLASS*(klass: pointer): bool
-proc FONT_SELECTION_GET_CLASS*(obj: pointer): PFontSelectionClass
-proc TYPE_FONT_SELECTION_DIALOG*(): GType
-proc FONT_SELECTION_DIALOG*(obj: pointer): PFontSelectionDialog
-proc FONT_SELECTION_DIALOG_CLASS*(klass: pointer): PFontSelectionDialogClass
-proc IS_FONT_SELECTION_DIALOG*(obj: pointer): bool
-proc IS_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): bool
-proc FONT_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PFontSelectionDialogClass
-proc font_selection_get_type*(): TType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_font_selection_get_type".}
-proc font_selection_new*(): PFontSelection{.cdecl, dynlib: lib, 
-    importc: "gtk_font_selection_new".}
-proc get_font_name*(fontsel: PFontSelection): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_font_selection_get_font_name".}
-proc set_font_name*(fontsel: PFontSelection, fontname: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_font_selection_set_font_name".}
-proc get_preview_text*(fontsel: PFontSelection): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_font_selection_get_preview_text".}
-proc set_preview_text*(fontsel: PFontSelection, text: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_font_selection_set_preview_text".}
-proc font_selection_dialog_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_font_selection_dialog_get_type".}
-proc font_selection_dialog_new*(title: cstring): PFontSelectionDialog{.cdecl, 
-    dynlib: lib, importc: "gtk_font_selection_dialog_new".}
-proc dialog_get_font_name*(fsd: PFontSelectionDialog): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_font_selection_dialog_get_font_name".}
-proc dialog_set_font_name*(fsd: PFontSelectionDialog, 
-    fontname: cstring): gboolean{.cdecl, dynlib: lib, importc: "gtk_font_selection_dialog_set_font_name".}
-proc dialog_get_preview_text*(fsd: PFontSelectionDialog): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_font_selection_dialog_get_preview_text".}
-proc dialog_set_preview_text*(fsd: PFontSelectionDialog, 
-    text: cstring){.cdecl, dynlib: lib, 
-                    importc: "gtk_font_selection_dialog_set_preview_text".}
-proc TYPE_GAMMA_CURVE*(): GType
-proc GAMMA_CURVE*(obj: pointer): PGammaCurve
-proc GAMMA_CURVE_CLASS*(klass: pointer): PGammaCurveClass
-proc IS_GAMMA_CURVE*(obj: pointer): bool
-proc IS_GAMMA_CURVE_CLASS*(klass: pointer): bool
-proc GAMMA_CURVE_GET_CLASS*(obj: pointer): PGammaCurveClass
-proc gamma_curve_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_gamma_curve_get_type".}
-proc gamma_curve_new*(): PGammaCurve{.cdecl, dynlib: lib, 
-                                      importc: "gtk_gamma_curve_new".}
-proc gc_get*(depth: gint, colormap: gdk2.PColormap, values: gdk2.PGCValues, 
-             values_mask: gdk2.TGCValuesMask): gdk2.PGC{.cdecl, dynlib: lib, 
-    importc: "gtk_gc_get".}
-proc gc_release*(gc: gdk2.PGC){.cdecl, dynlib: lib, importc: "gtk_gc_release".}
-const 
-  bm_TGtkHandleBox_handle_position* = 0x0003'i16
-  bp_TGtkHandleBox_handle_position* = 0'i16
-  bm_TGtkHandleBox_float_window_mapped* = 0x0004'i16
-  bp_TGtkHandleBox_float_window_mapped* = 2'i16
-  bm_TGtkHandleBox_child_detached* = 0x0008'i16
-  bp_TGtkHandleBox_child_detached* = 3'i16
-  bm_TGtkHandleBox_in_drag* = 0x0010'i16
-  bp_TGtkHandleBox_in_drag* = 4'i16
-  bm_TGtkHandleBox_shrink_on_detach* = 0x0020'i16
-  bp_TGtkHandleBox_shrink_on_detach* = 5'i16
-  bm_TGtkHandleBox_snap_edge* = 0x01C0'i16
-  bp_TGtkHandleBox_snap_edge* = 6'i16
-
-proc TYPE_HANDLE_BOX*(): GType
-proc HANDLE_BOX*(obj: pointer): PHandleBox
-proc HANDLE_BOX_CLASS*(klass: pointer): PHandleBoxClass
-proc IS_HANDLE_BOX*(obj: pointer): bool
-proc IS_HANDLE_BOX_CLASS*(klass: pointer): bool
-proc HANDLE_BOX_GET_CLASS*(obj: pointer): PHandleBoxClass
-proc handle_position*(a: PHandleBox): guint
-proc set_handle_position*(a: PHandleBox, `handle_position`: guint)
-proc float_window_mapped*(a: PHandleBox): guint
-proc set_float_window_mapped*(a: PHandleBox, `float_window_mapped`: guint)
-proc child_detached*(a: PHandleBox): guint
-proc set_child_detached*(a: PHandleBox, `child_detached`: guint)
-proc in_drag*(a: PHandleBox): guint
-proc set_in_drag*(a: PHandleBox, `in_drag`: guint)
-proc shrink_on_detach*(a: PHandleBox): guint
-proc set_shrink_on_detach*(a: PHandleBox, `shrink_on_detach`: guint)
-proc snap_edge*(a: PHandleBox): gint
-proc set_snap_edge*(a: PHandleBox, `snap_edge`: gint)
-proc handle_box_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_handle_box_get_type".}
-proc handle_box_new*(): PHandleBox{.cdecl, dynlib: lib, 
-                                    importc: "gtk_handle_box_new".}
-proc set_shadow_type*(handle_box: PHandleBox, thetype: TShadowType){.
-    cdecl, dynlib: lib, importc: "gtk_handle_box_set_shadow_type".}
-proc get_shadow_type*(handle_box: PHandleBox): TShadowType{.cdecl, 
-    dynlib: lib, importc: "gtk_handle_box_get_shadow_type".}
-proc set_handle_position*(handle_box: PHandleBox, 
-                                     position: TPositionType){.cdecl, 
-    dynlib: lib, importc: "gtk_handle_box_set_handle_position".}
-proc get_handle_position*(handle_box: PHandleBox): TPositionType{.
-    cdecl, dynlib: lib, importc: "gtk_handle_box_get_handle_position".}
-proc set_snap_edge*(handle_box: PHandleBox, edge: TPositionType){.
-    cdecl, dynlib: lib, importc: "gtk_handle_box_set_snap_edge".}
-proc get_snap_edge*(handle_box: PHandleBox): TPositionType{.cdecl, 
-    dynlib: lib, importc: "gtk_handle_box_get_snap_edge".}
-const 
-  bm_TGtkPaned_position_set* = 0x0001'i16
-  bp_TGtkPaned_position_set* = 0'i16
-  bm_TGtkPaned_in_drag* = 0x0002'i16
-  bp_TGtkPaned_in_drag* = 1'i16
-  bm_TGtkPaned_child1_shrink* = 0x0004'i16
-  bp_TGtkPaned_child1_shrink* = 2'i16
-  bm_TGtkPaned_child1_resize* = 0x0008'i16
-  bp_TGtkPaned_child1_resize* = 3'i16
-  bm_TGtkPaned_child2_shrink* = 0x0010'i16
-  bp_TGtkPaned_child2_shrink* = 4'i16
-  bm_TGtkPaned_child2_resize* = 0x0020'i16
-  bp_TGtkPaned_child2_resize* = 5'i16
-  bm_TGtkPaned_orientation* = 0x0040'i16
-  bp_TGtkPaned_orientation* = 6'i16
-  bm_TGtkPaned_in_recursion* = 0x0080'i16
-  bp_TGtkPaned_in_recursion* = 7'i16
-  bm_TGtkPaned_handle_prelit* = 0x0100'i16
-  bp_TGtkPaned_handle_prelit* = 8'i16
-
-proc TYPE_PANED*(): GType
-proc PANED*(obj: pointer): PPaned
-proc PANED_CLASS*(klass: pointer): PPanedClass
-proc IS_PANED*(obj: pointer): bool
-proc IS_PANED_CLASS*(klass: pointer): bool
-proc PANED_GET_CLASS*(obj: pointer): PPanedClass
-proc position_set*(a: PPaned): guint
-proc set_position_set*(a: PPaned, `position_set`: guint)
-proc in_drag*(a: PPaned): guint
-proc set_in_drag*(a: PPaned, `in_drag`: guint)
-proc child1_shrink*(a: PPaned): guint
-proc set_child1_shrink*(a: PPaned, `child1_shrink`: guint)
-proc child1_resize*(a: PPaned): guint
-proc set_child1_resize*(a: PPaned, `child1_resize`: guint)
-proc child2_shrink*(a: PPaned): guint
-proc set_child2_shrink*(a: PPaned, `child2_shrink`: guint)
-proc child2_resize*(a: PPaned): guint
-proc set_child2_resize*(a: PPaned, `child2_resize`: guint)
-proc orientation*(a: PPaned): guint
-proc set_orientation*(a: PPaned, `orientation`: guint)
-proc in_recursion*(a: PPaned): guint
-proc set_in_recursion*(a: PPaned, `in_recursion`: guint)
-proc handle_prelit*(a: PPaned): guint
-proc set_handle_prelit*(a: PPaned, `handle_prelit`: guint)
-proc paned_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_paned_get_type".}
-proc add1*(paned: PPaned, child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_paned_add1".}
-proc add2*(paned: PPaned, child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_paned_add2".}
-proc pack1*(paned: PPaned, child: PWidget, resize: gboolean, 
-                  shrink: gboolean){.cdecl, dynlib: lib, 
-                                     importc: "gtk_paned_pack1".}
-proc pack2*(paned: PPaned, child: PWidget, resize: gboolean, 
-                  shrink: gboolean){.cdecl, dynlib: lib, 
-                                     importc: "gtk_paned_pack2".}
-proc get_position*(paned: PPaned): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_paned_get_position".}
-proc set_position*(paned: PPaned, position: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paned_set_position".}
-proc compute_position*(paned: PPaned, allocation: gint, child1_req: gint, 
-                             child2_req: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paned_compute_position".}
-proc TYPE_HBUTTON_BOX*(): GType
-proc HBUTTON_BOX*(obj: pointer): PHButtonBox
-proc HBUTTON_BOX_CLASS*(klass: pointer): PHButtonBoxClass
-proc IS_HBUTTON_BOX*(obj: pointer): bool
-proc IS_HBUTTON_BOX_CLASS*(klass: pointer): bool
-proc HBUTTON_BOX_GET_CLASS*(obj: pointer): PHButtonBoxClass
-proc hbutton_box_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_hbutton_box_get_type".}
-proc hbutton_box_new*(): PHButtonBox{.cdecl, dynlib: lib, 
-                                      importc: "gtk_hbutton_box_new".}
-proc TYPE_HPANED*(): GType
-proc HPANED*(obj: pointer): PHPaned
-proc HPANED_CLASS*(klass: pointer): PHPanedClass
-proc IS_HPANED*(obj: pointer): bool
-proc IS_HPANED_CLASS*(klass: pointer): bool
-proc HPANED_GET_CLASS*(obj: pointer): PHPanedClass
-proc hpaned_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_hpaned_get_type".}
-proc hpaned_new*(): PHPaned{.cdecl, dynlib: lib, importc: "gtk_hpaned_new".}
-proc TYPE_RULER*(): GType
-proc RULER*(obj: pointer): PRuler
-proc RULER_CLASS*(klass: pointer): PRulerClass
-proc IS_RULER*(obj: pointer): bool
-proc IS_RULER_CLASS*(klass: pointer): bool
-proc RULER_GET_CLASS*(obj: pointer): PRulerClass
-proc ruler_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_ruler_get_type".}
-proc set_metric*(ruler: PRuler, metric: TMetricType){.cdecl, dynlib: lib, 
-    importc: "gtk_ruler_set_metric".}
-proc set_range*(ruler: PRuler, lower: gdouble, upper: gdouble, 
-                      position: gdouble, max_size: gdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_ruler_set_range".}
-proc draw_ticks*(ruler: PRuler){.cdecl, dynlib: lib, 
-                                       importc: "gtk_ruler_draw_ticks".}
-proc draw_pos*(ruler: PRuler){.cdecl, dynlib: lib, 
-                                     importc: "gtk_ruler_draw_pos".}
-proc get_metric*(ruler: PRuler): TMetricType{.cdecl, dynlib: lib, 
-    importc: "gtk_ruler_get_metric".}
-proc get_range*(ruler: PRuler, lower: Pgdouble, upper: Pgdouble, 
-                      position: Pgdouble, max_size: Pgdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_ruler_get_range".}
-proc TYPE_HRULER*(): GType
-proc HRULER*(obj: pointer): PHRuler
-proc HRULER_CLASS*(klass: pointer): PHRulerClass
-proc IS_HRULER*(obj: pointer): bool
-proc IS_HRULER_CLASS*(klass: pointer): bool
-proc HRULER_GET_CLASS*(obj: pointer): PHRulerClass
-proc hruler_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_hruler_get_type".}
-proc hruler_new*(): PHRuler{.cdecl, dynlib: lib, importc: "gtk_hruler_new".}
-proc TYPE_SETTINGS*(): GType
-proc SETTINGS*(obj: pointer): PSettings
-proc SETTINGS_CLASS*(klass: pointer): PSettingsClass
-proc IS_SETTINGS*(obj: pointer): bool
-proc IS_SETTINGS_CLASS*(klass: pointer): bool
-proc SETTINGS_GET_CLASS*(obj: pointer): PSettingsClass
-proc settings_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_settings_get_type".}
-proc settings_get_for_screen*(screen: gdk2.PScreen): PSettings{.cdecl, 
-    dynlib: lib, importc: "gtk_settings_get_for_screen".}
-proc settings_install_property*(pspec: PGParamSpec){.cdecl, dynlib: lib, 
-    importc: "gtk_settings_install_property".}
-proc settings_install_property_parser*(pspec: PGParamSpec, 
-                                       parser: TRcPropertyParser){.cdecl, 
-    dynlib: lib, importc: "gtk_settings_install_property_parser".}
-proc rc_property_parse_color*(pspec: PGParamSpec, gstring: PGString, 
-                              property_value: PGValue): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_property_parse_color".}
-proc rc_property_parse_enum*(pspec: PGParamSpec, gstring: PGString, 
-                             property_value: PGValue): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_property_parse_enum".}
-proc rc_property_parse_flags*(pspec: PGParamSpec, gstring: PGString, 
-                              property_value: PGValue): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_property_parse_flags".}
-proc rc_property_parse_requisition*(pspec: PGParamSpec, gstring: PGString, 
-                                    property_value: PGValue): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_property_parse_requisition".}
-proc rc_property_parse_border*(pspec: PGParamSpec, gstring: PGString, 
-                               property_value: PGValue): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_property_parse_border".}
-proc set_property_value*(settings: PSettings, name: cstring, 
-                                  svalue: PSettingsValue){.cdecl, dynlib: lib, 
-    importc: "gtk_settings_set_property_value".}
-proc set_string_property*(settings: PSettings, name: cstring, 
-                                   v_string: cstring, origin: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_settings_set_string_property".}
-proc set_long_property*(settings: PSettings, name: cstring, 
-                                 v_long: glong, origin: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_settings_set_long_property".}
-proc set_double_property*(settings: PSettings, name: cstring, 
-                                   v_double: gdouble, origin: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_settings_set_double_property".}
-proc settings_handle_event*(event: gdk2.PEventSetting){.cdecl, dynlib: lib, 
-    importc: "_gtk_settings_handle_event".}
-proc rc_property_parser_from_type*(thetype: GType): TRcPropertyParser{.cdecl, 
-    dynlib: lib, importc: "_gtk_rc_property_parser_from_type".}
-proc settings_parse_convert*(parser: TRcPropertyParser, src_value: PGValue, 
-                             pspec: PGParamSpec, dest_value: PGValue): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_settings_parse_convert".}
-const 
-  RC_FG* = 1 shl 0
-  RC_BG* = 1 shl 1
-  RC_TEXT* = 1 shl 2
-  RC_BASE* = 1 shl 3
-  bm_TGtkRcStyle_engine_specified* = 0x0001'i16
-  bp_TGtkRcStyle_engine_specified* = 0'i16
-
-proc TYPE_RC_STYLE*(): GType
-proc RC_STYLE_get*(anObject: pointer): PRcStyle
-proc RC_STYLE_CLASS*(klass: pointer): PRcStyleClass
-proc IS_RC_STYLE*(anObject: pointer): bool
-proc IS_RC_STYLE_CLASS*(klass: pointer): bool
-proc RC_STYLE_GET_CLASS*(obj: pointer): PRcStyleClass
-proc engine_specified*(a: PRcStyle): guint
-proc set_engine_specified*(a: PRcStyle, `engine_specified`: guint)
-proc rc_init*(){.cdecl, dynlib: lib, importc: "_gtk_rc_init".}
-proc rc_add_default_file*(filename: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_rc_add_default_file".}
-proc rc_set_default_files*(filenames: PPgchar){.cdecl, dynlib: lib, 
-    importc: "gtk_rc_set_default_files".}
-proc rc_get_default_files*(): PPgchar{.cdecl, dynlib: lib, 
-                                       importc: "gtk_rc_get_default_files".}
-proc rc_get_style*(widget: PWidget): PStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_rc_get_style".}
-proc rc_get_style_by_paths*(settings: PSettings, widget_path: cstring, 
-                            class_path: cstring, thetype: GType): PStyle{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_get_style_by_paths".}
-proc rc_reparse_all_for_settings*(settings: PSettings, force_load: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_rc_reparse_all_for_settings".}
-proc rc_find_pixmap_in_path*(settings: PSettings, scanner: PGScanner, 
-                             pixmap_file: cstring): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_rc_find_pixmap_in_path".}
-proc rc_parse*(filename: cstring){.cdecl, dynlib: lib, importc: "gtk_rc_parse".}
-proc rc_parse_string*(rc_string: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_rc_parse_string".}
-proc rc_reparse_all*(): gboolean{.cdecl, dynlib: lib, 
-                                  importc: "gtk_rc_reparse_all".}
-proc rc_style_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_rc_style_get_type".}
-proc rc_style_new*(): PRcStyle{.cdecl, dynlib: lib, importc: "gtk_rc_style_new".}
-proc copy*(orig: PRcStyle): PRcStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_rc_style_copy".}
-proc reference*(rc_style: PRcStyle){.cdecl, dynlib: lib, 
-                                        importc: "gtk_rc_style_ref".}
-proc unref*(rc_style: PRcStyle){.cdecl, dynlib: lib, 
-    importc: "gtk_rc_style_unref".}
-proc rc_find_module_in_path*(module_file: cstring): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_rc_find_module_in_path".}
-proc rc_get_theme_dir*(): cstring{.cdecl, dynlib: lib, 
-                                   importc: "gtk_rc_get_theme_dir".}
-proc rc_get_module_dir*(): cstring{.cdecl, dynlib: lib, 
-                                    importc: "gtk_rc_get_module_dir".}
-proc rc_get_im_module_path*(): cstring{.cdecl, dynlib: lib, 
-                                        importc: "gtk_rc_get_im_module_path".}
-proc rc_get_im_module_file*(): cstring{.cdecl, dynlib: lib, 
-                                        importc: "gtk_rc_get_im_module_file".}
-proc rc_scanner_new*(): PGScanner{.cdecl, dynlib: lib, 
-                                   importc: "gtk_rc_scanner_new".}
-proc rc_parse_color*(scanner: PGScanner, color: gdk2.PColor): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_parse_color".}
-proc rc_parse_state*(scanner: PGScanner, state: PStateType): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_rc_parse_state".}
-proc rc_parse_priority*(scanner: PGScanner, priority: PPathPriorityType): guint{.
-    cdecl, dynlib: lib, importc: "gtk_rc_parse_priority".}
-proc lookup_rc_property*(rc_style: PRcStyle, type_name: TGQuark, 
-                                  property_name: TGQuark): PRcProperty{.cdecl, 
-    dynlib: lib, importc: "_gtk_rc_style_lookup_rc_property".}
-proc rc_context_get_default_font_name*(settings: PSettings): cstring{.cdecl, 
-    dynlib: lib, importc: "_gtk_rc_context_get_default_font_name".}
-proc TYPE_STYLE*(): GType
-proc STYLE*(anObject: pointer): PStyle
-proc STYLE_CLASS*(klass: pointer): PStyleClass
-proc IS_STYLE*(anObject: pointer): bool
-proc IS_STYLE_CLASS*(klass: pointer): bool
-proc STYLE_GET_CLASS*(obj: pointer): PStyleClass
-proc TYPE_BORDER*(): GType
-proc STYLE_ATTACHED*(style: pointer): bool
-proc style_get_type*(): GType{.cdecl, dynlib: lib, importc: "gtk_style_get_type".}
-proc style_new*(): PStyle{.cdecl, dynlib: lib, importc: "gtk_style_new".}
-proc copy*(style: PStyle): PStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_style_copy".}
-proc attach*(style: PStyle, window: gdk2.PWindow): PStyle{.cdecl, 
-    dynlib: lib, importc: "gtk_style_attach".}
-proc detach*(style: PStyle){.cdecl, dynlib: lib, 
-                                   importc: "gtk_style_detach".}
-proc set_background*(style: PStyle, window: gdk2.PWindow, 
-                           state_type: TStateType){.cdecl, dynlib: lib, 
-    importc: "gtk_style_set_background".}
-proc apply_default_background*(style: PStyle, window: gdk2.PWindow, 
-                                     set_bg: gboolean, state_type: TStateType, 
-                                     area: gdk2.PRectangle, x: gint, y: gint, 
-                                     width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_style_apply_default_background".}
-proc lookup_icon_set*(style: PStyle, stock_id: cstring): PIconSet{.cdecl, 
-    dynlib: lib, importc: "gtk_style_lookup_icon_set".}
-proc render_icon*(style: PStyle, source: PIconSource, 
-                        direction: TTextDirection, state: TStateType, 
-                        size: TIconSize, widget: PWidget, detail: cstring): gdk2pixbuf.PPixbuf{.
-    cdecl, dynlib: lib, importc: "gtk_style_render_icon".}
-proc paint_hline*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                  area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                  x1: gint, x2: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_hline".}
-proc paint_vline*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                  area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                  y1: gint, y2: gint, x: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_vline".}
-proc paint_shadow*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                   shadow_type: TShadowType, area: gdk2.PRectangle, 
-                   widget: PWidget, detail: cstring, x: gint, y: gint, 
-                   width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_shadow".}
-proc paint_polygon*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                    shadow_type: TShadowType, area: gdk2.PRectangle, 
-                    widget: PWidget, detail: cstring, points: gdk2.PPoint, 
-                    npoints: gint, fill: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_polygon".}
-proc paint_arrow*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                  shadow_type: TShadowType, area: gdk2.PRectangle, 
-                  widget: PWidget, detail: cstring, arrow_type: TArrowType, 
-                  fill: gboolean, x: gint, y: gint, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gtk_paint_arrow".}
-proc paint_diamond*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                    shadow_type: TShadowType, area: gdk2.PRectangle, 
-                    widget: PWidget, detail: cstring, x: gint, y: gint, 
-                    width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_diamond".}
-proc paint_box*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                shadow_type: TShadowType, area: gdk2.PRectangle, widget: PWidget, 
-                detail: cstring, x: gint, y: gint, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gtk_paint_box".}
-proc paint_flat_box*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                     shadow_type: TShadowType, area: gdk2.PRectangle, 
-                     widget: PWidget, detail: cstring, x: gint, y: gint, 
-                     width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_flat_box".}
-proc paint_check*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                  shadow_type: TShadowType, area: gdk2.PRectangle, 
-                  widget: PWidget, detail: cstring, x: gint, y: gint, 
-                  width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_check".}
-proc paint_option*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                   shadow_type: TShadowType, area: gdk2.PRectangle, 
-                   widget: PWidget, detail: cstring, x: gint, y: gint, 
-                   width: gint, height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_option".}
-proc paint_tab*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                shadow_type: TShadowType, area: gdk2.PRectangle, widget: PWidget, 
-                detail: cstring, x: gint, y: gint, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "gtk_paint_tab".}
-proc paint_shadow_gap*(style: PStyle, window: gdk2.PWindow, 
-                       state_type: TStateType, shadow_type: TShadowType, 
-                       area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                       x: gint, y: gint, width: gint, height: gint, 
-                       gap_side: TPositionType, gap_x: gint, gap_width: gint){.
-    cdecl, dynlib: lib, importc: "gtk_paint_shadow_gap".}
-proc paint_box_gap*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                    shadow_type: TShadowType, area: gdk2.PRectangle, 
-                    widget: PWidget, detail: cstring, x: gint, y: gint, 
-                    width: gint, height: gint, gap_side: TPositionType, 
-                    gap_x: gint, gap_width: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_paint_box_gap".}
-proc paint_extension*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                      shadow_type: TShadowType, area: gdk2.PRectangle, 
-                      widget: PWidget, detail: cstring, x: gint, y: gint, 
-                      width: gint, height: gint, gap_side: TPositionType){.
-    cdecl, dynlib: lib, importc: "gtk_paint_extension".}
-proc paint_focus*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                  area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                  x: gint, y: gint, width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_paint_focus".}
-proc paint_slider*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                   shadow_type: TShadowType, area: gdk2.PRectangle, 
-                   widget: PWidget, detail: cstring, x: gint, y: gint, 
-                   width: gint, height: gint, orientation: TOrientation){.cdecl, 
-    dynlib: lib, importc: "gtk_paint_slider".}
-proc paint_handle*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                   shadow_type: TShadowType, area: gdk2.PRectangle, 
-                   widget: PWidget, detail: cstring, x: gint, y: gint, 
-                   width: gint, height: gint, orientation: TOrientation){.cdecl, 
-    dynlib: lib, importc: "gtk_paint_handle".}
-proc paint_expander*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                     area: gdk2.PRectangle, widget: PWidget, detail: cstring, 
-                     x: gint, y: gint, expander_style: TExpanderStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_paint_expander".}
-proc paint_layout*(style: PStyle, window: gdk2.PWindow, state_type: TStateType, 
-                   use_text: gboolean, area: gdk2.PRectangle, widget: PWidget, 
-                   detail: cstring, x: gint, y: gint, layout: pango.PLayout){.
-    cdecl, dynlib: lib, importc: "gtk_paint_layout".}
-proc paint_resize_grip*(style: PStyle, window: gdk2.PWindow, 
-                        state_type: TStateType, area: gdk2.PRectangle, 
-                        widget: PWidget, detail: cstring, edge: gdk2.TWindowEdge, 
-                        x: gint, y: gint, width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_paint_resize_grip".}
-proc border_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "gtk_border_get_type".}
-proc copy*(border: PBorder): PBorder{.cdecl, dynlib: lib, 
-    importc: "gtk_border_copy".}
-proc free*(border: PBorder){.cdecl, dynlib: lib, 
-                                    importc: "gtk_border_free".}
-proc peek_property_value*(style: PStyle, widget_type: GType, 
-                                pspec: PGParamSpec, parser: TRcPropertyParser): PGValue{.
-    cdecl, dynlib: lib, importc: "_gtk_style_peek_property_value".}
-proc get_insertion_cursor_gc*(widget: PWidget, is_primary: gboolean): gdk2.PGC{.
-    cdecl, dynlib: lib, importc: "_gtk_get_insertion_cursor_gc".}
-proc draw_insertion_cursor*(widget: PWidget, drawable: gdk2.PDrawable, gc: gdk2.PGC, 
-                            location: gdk2.PRectangle, direction: TTextDirection, 
-                            draw_arrow: gboolean){.cdecl, dynlib: lib, 
-    importc: "_gtk_draw_insertion_cursor".}
-const 
-  bm_TGtkRange_inverted* = 0x0001'i16
-  bp_TGtkRange_inverted* = 0'i16
-  bm_TGtkRange_flippable* = 0x0002'i16
-  bp_TGtkRange_flippable* = 1'i16
-  bm_TGtkRange_has_stepper_a* = 0x0004'i16
-  bp_TGtkRange_has_stepper_a* = 2'i16
-  bm_TGtkRange_has_stepper_b* = 0x0008'i16
-  bp_TGtkRange_has_stepper_b* = 3'i16
-  bm_TGtkRange_has_stepper_c* = 0x0010'i16
-  bp_TGtkRange_has_stepper_c* = 4'i16
-  bm_TGtkRange_has_stepper_d* = 0x0020'i16
-  bp_TGtkRange_has_stepper_d* = 5'i16
-  bm_TGtkRange_need_recalc* = 0x0040'i16
-  bp_TGtkRange_need_recalc* = 6'i16
-  bm_TGtkRange_slider_size_fixed* = 0x0080'i16
-  bp_TGtkRange_slider_size_fixed* = 7'i16
-  bm_TGtkRange_trough_click_forward* = 0x0001'i16
-  bp_TGtkRange_trough_click_forward* = 0'i16
-  bm_TGtkRange_update_pending* = 0x0002'i16
-  bp_TGtkRange_update_pending* = 1'i16
-
-proc TYPE_RANGE*(): GType
-proc RANGE*(obj: pointer): PRange
-proc RANGE_CLASS*(klass: pointer): PRangeClass
-proc IS_RANGE*(obj: pointer): bool
-proc IS_RANGE_CLASS*(klass: pointer): bool
-proc RANGE_GET_CLASS*(obj: pointer): PRangeClass
-proc inverted*(a: PRange): guint
-proc set_inverted*(a: PRange, `inverted`: guint)
-proc flippable*(a: PRange): guint
-proc set_flippable*(a: PRange, `flippable`: guint)
-proc has_stepper_a*(a: PRange): guint
-proc set_has_stepper_a*(a: PRange, `has_stepper_a`: guint)
-proc has_stepper_b*(a: PRange): guint
-proc set_has_stepper_b*(a: PRange, `has_stepper_b`: guint)
-proc has_stepper_c*(a: PRange): guint
-proc set_has_stepper_c*(a: PRange, `has_stepper_c`: guint)
-proc has_stepper_d*(a: PRange): guint
-proc set_has_stepper_d*(a: PRange, `has_stepper_d`: guint)
-proc need_recalc*(a: PRange): guint
-proc set_need_recalc*(a: PRange, `need_recalc`: guint)
-proc slider_size_fixed*(a: PRange): guint
-proc set_slider_size_fixed*(a: PRange, `slider_size_fixed`: guint)
-proc trough_click_forward*(a: PRange): guint
-proc set_trough_click_forward*(a: PRange, `trough_click_forward`: guint)
-proc update_pending*(a: PRange): guint
-proc set_update_pending*(a: PRange, `update_pending`: guint)
-proc range_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_range_get_type".}
-proc set_update_policy*(range: PRange, policy: TUpdateType){.cdecl, 
-    dynlib: lib, importc: "gtk_range_set_update_policy".}
-proc get_update_policy*(range: PRange): TUpdateType{.cdecl, dynlib: lib, 
-    importc: "gtk_range_get_update_policy".}
-proc set_adjustment*(range: PRange, adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_range_set_adjustment".}
-proc get_adjustment*(range: PRange): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_range_get_adjustment".}
-proc set_inverted*(range: PRange, setting: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_range_set_inverted".}
-proc get_inverted*(range: PRange): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_range_get_inverted".}
-proc set_increments*(range: PRange, step: gdouble, page: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_range_set_increments".}
-proc set_range*(range: PRange, min: gdouble, max: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_range_set_range".}
-proc set_value*(range: PRange, value: gdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_range_set_value".}
-proc get_value*(range: PRange): gdouble{.cdecl, dynlib: lib, 
-    importc: "gtk_range_get_value".}
-const 
-  bm_TGtkScale_draw_value* = 0x0001'i16
-  bp_TGtkScale_draw_value* = 0'i16
-  bm_TGtkScale_value_pos* = 0x0006'i16
-  bp_TGtkScale_value_pos* = 1'i16
-
-proc TYPE_SCALE*(): GType
-proc SCALE*(obj: pointer): PScale
-proc SCALE_CLASS*(klass: pointer): PScaleClass
-proc IS_SCALE*(obj: pointer): bool
-proc IS_SCALE_CLASS*(klass: pointer): bool
-proc SCALE_GET_CLASS*(obj: pointer): PScaleClass
-proc draw_value*(a: PScale): guint
-proc set_draw_value*(a: PScale, `draw_value`: guint)
-proc value_pos*(a: PScale): guint
-proc set_value_pos*(a: PScale, `value_pos`: guint)
-proc scale_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_scale_get_type".}
-proc set_digits*(scale: PScale, digits: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_scale_set_digits".}
-proc get_digits*(scale: PScale): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_scale_get_digits".}
-proc set_draw_value*(scale: PScale, draw_value: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_scale_set_draw_value".}
-proc get_draw_value*(scale: PScale): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_scale_get_draw_value".}
-proc set_value_pos*(scale: PScale, pos: TPositionType){.cdecl, 
-    dynlib: lib, importc: "gtk_scale_set_value_pos".}
-proc get_value_pos*(scale: PScale): TPositionType{.cdecl, dynlib: lib, 
-    importc: "gtk_scale_get_value_pos".}
-proc get_value_size*(scale: PScale, width: Pgint, height: Pgint){.cdecl, 
-    dynlib: lib, importc: "_gtk_scale_get_value_size".}
-proc format_value*(scale: PScale, value: gdouble): cstring{.cdecl, 
-    dynlib: lib, importc: "_gtk_scale_format_value".}
-proc TYPE_HSCALE*(): GType
-proc HSCALE*(obj: pointer): PHScale
-proc HSCALE_CLASS*(klass: pointer): PHScaleClass
-proc IS_HSCALE*(obj: pointer): bool
-proc IS_HSCALE_CLASS*(klass: pointer): bool
-proc HSCALE_GET_CLASS*(obj: pointer): PHScaleClass
-proc hscale_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_hscale_get_type".}
-proc hscale_new*(adjustment: PAdjustment): PHScale{.cdecl, dynlib: lib, 
-    importc: "gtk_hscale_new".}
-proc hscale_new*(min: gdouble, max: gdouble, step: gdouble): PHScale{.
-    cdecl, dynlib: lib, importc: "gtk_hscale_new_with_range".}
-proc TYPE_SCROLLBAR*(): GType
-proc SCROLLBAR*(obj: pointer): PScrollbar
-proc SCROLLBAR_CLASS*(klass: pointer): PScrollbarClass
-proc IS_SCROLLBAR*(obj: pointer): bool
-proc IS_SCROLLBAR_CLASS*(klass: pointer): bool
-proc SCROLLBAR_GET_CLASS*(obj: pointer): PScrollbarClass
-proc scrollbar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_scrollbar_get_type".}
-proc TYPE_HSCROLLBAR*(): GType
-proc HSCROLLBAR*(obj: pointer): PHScrollbar
-proc HSCROLLBAR_CLASS*(klass: pointer): PHScrollbarClass
-proc IS_HSCROLLBAR*(obj: pointer): bool
-proc IS_HSCROLLBAR_CLASS*(klass: pointer): bool
-proc HSCROLLBAR_GET_CLASS*(obj: pointer): PHScrollbarClass
-proc hscrollbar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_hscrollbar_get_type".}
-proc hscrollbar_new*(adjustment: PAdjustment): PHScrollbar{.cdecl, dynlib: lib, 
-    importc: "gtk_hscrollbar_new".}
-proc TYPE_SEPARATOR*(): GType
-proc SEPARATOR*(obj: pointer): PSeparator
-proc SEPARATOR_CLASS*(klass: pointer): PSeparatorClass
-proc IS_SEPARATOR*(obj: pointer): bool
-proc IS_SEPARATOR_CLASS*(klass: pointer): bool
-proc SEPARATOR_GET_CLASS*(obj: pointer): PSeparatorClass
-proc separator_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_separator_get_type".}
-proc TYPE_HSEPARATOR*(): GType
-proc HSEPARATOR*(obj: pointer): PHSeparator
-proc HSEPARATOR_CLASS*(klass: pointer): PHSeparatorClass
-proc IS_HSEPARATOR*(obj: pointer): bool
-proc IS_HSEPARATOR_CLASS*(klass: pointer): bool
-proc HSEPARATOR_GET_CLASS*(obj: pointer): PHSeparatorClass
-proc hseparator_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_hseparator_get_type".}
-proc hseparator_new*(): PHSeparator{.cdecl, dynlib: lib, 
-                                     importc: "gtk_hseparator_new".}
-proc TYPE_ICON_FACTORY*(): GType
-proc ICON_FACTORY*(anObject: pointer): PIconFactory
-proc ICON_FACTORY_CLASS*(klass: pointer): PIconFactoryClass
-proc IS_ICON_FACTORY*(anObject: pointer): bool
-proc IS_ICON_FACTORY_CLASS*(klass: pointer): bool
-proc ICON_FACTORY_GET_CLASS*(obj: pointer): PIconFactoryClass
-proc TYPE_ICON_SET*(): GType
-proc TYPE_ICON_SOURCE*(): GType
-proc icon_factory_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_icon_factory_get_type".}
-proc icon_factory_new*(): PIconFactory{.cdecl, dynlib: lib, 
-                                        importc: "gtk_icon_factory_new".}
-proc add*(factory: PIconFactory, stock_id: cstring, 
-                       icon_set: PIconSet){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_factory_add".}
-proc lookup*(factory: PIconFactory, stock_id: cstring): PIconSet{.
-    cdecl, dynlib: lib, importc: "gtk_icon_factory_lookup".}
-proc add_default*(factory: PIconFactory){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_factory_add_default".}
-proc remove_default*(factory: PIconFactory){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_factory_remove_default".}
-proc icon_factory_lookup_default*(stock_id: cstring): PIconSet{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_factory_lookup_default".}
-proc icon_size_lookup*(size: TIconSize, width: Pgint, height: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_icon_size_lookup".}
-proc icon_size_register*(name: cstring, width: gint, height: gint): TIconSize{.
-    cdecl, dynlib: lib, importc: "gtk_icon_size_register".}
-proc icon_size_register_alias*(alias: cstring, target: TIconSize){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_size_register_alias".}
-proc icon_size_from_name*(name: cstring): TIconSize{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_size_from_name".}
-proc icon_size_get_name*(size: TIconSize): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_size_get_name".}
-proc icon_set_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_icon_set_get_type".}
-proc icon_set_new*(): PIconSet{.cdecl, dynlib: lib, importc: "gtk_icon_set_new".}
-proc icon_set_new_from_pixbuf*(pixbuf: gdk2pixbuf.PPixbuf): PIconSet{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_set_new_from_pixbuf".}
-proc reference*(icon_set: PIconSet): PIconSet{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_set_ref".}
-proc unref*(icon_set: PIconSet){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_set_unref".}
-proc copy*(icon_set: PIconSet): PIconSet{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_set_copy".}
-proc render_icon*(icon_set: PIconSet, style: PStyle, 
-                           direction: TTextDirection, state: TStateType, 
-                           size: TIconSize, widget: PWidget, detail: cstring): gdk2pixbuf.PPixbuf{.
-    cdecl, dynlib: lib, importc: "gtk_icon_set_render_icon".}
-proc add_source*(icon_set: PIconSet, source: PIconSource){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_set_add_source".}
-proc get_sizes*(icon_set: PIconSet, sizes: PPGtkIconSize, 
-                         n_sizes: pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_set_get_sizes".}
-proc icon_source_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_icon_source_get_type".}
-proc icon_source_new*(): PIconSource{.cdecl, dynlib: lib, 
-                                      importc: "gtk_icon_source_new".}
-proc copy*(source: PIconSource): PIconSource{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_source_copy".}
-proc free*(source: PIconSource){.cdecl, dynlib: lib, 
-    importc: "gtk_icon_source_free".}
-proc set_filename*(source: PIconSource, filename: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_set_filename".}
-proc set_pixbuf*(source: PIconSource, pixbuf: gdk2pixbuf.PPixbuf){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_set_pixbuf".}
-proc get_filename*(source: PIconSource): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_filename".}
-proc get_pixbuf*(source: PIconSource): gdk2pixbuf.PPixbuf{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_pixbuf".}
-proc set_direction_wildcarded*(source: PIconSource, 
-    setting: gboolean){.cdecl, dynlib: lib, 
-                        importc: "gtk_icon_source_set_direction_wildcarded".}
-proc set_state_wildcarded*(source: PIconSource, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_icon_source_set_state_wildcarded".}
-proc set_size_wildcarded*(source: PIconSource, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_icon_source_set_size_wildcarded".}
-proc get_size_wildcarded*(source: PIconSource): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_size_wildcarded".}
-proc get_state_wildcarded*(source: PIconSource): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_state_wildcarded".}
-proc get_direction_wildcarded*(source: PIconSource): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_icon_source_get_direction_wildcarded".}
-proc set_direction*(source: PIconSource, direction: TTextDirection){.
-    cdecl, dynlib: lib, importc: "gtk_icon_source_set_direction".}
-proc set_state*(source: PIconSource, state: TStateType){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_set_state".}
-proc set_size*(source: PIconSource, size: TIconSize){.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_set_size".}
-proc get_direction*(source: PIconSource): TTextDirection{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_direction".}
-proc get_state*(source: PIconSource): TStateType{.cdecl, 
-    dynlib: lib, importc: "gtk_icon_source_get_state".}
-proc get_size*(source: PIconSource): TIconSize{.cdecl, dynlib: lib, 
-    importc: "gtk_icon_source_get_size".}
-proc icon_set_invalidate_caches*(){.cdecl, dynlib: lib, 
-                                    importc: "_gtk_icon_set_invalidate_caches".}
-proc icon_factory_list_ids*(): PGSList{.cdecl, dynlib: lib, 
-                                        importc: "_gtk_icon_factory_list_ids".}
-proc TYPE_IMAGE*(): GType
-proc IMAGE*(obj: pointer): PImage
-proc IMAGE_CLASS*(klass: pointer): PImageClass
-proc IS_IMAGE*(obj: pointer): bool
-proc IS_IMAGE_CLASS*(klass: pointer): bool
-proc IMAGE_GET_CLASS*(obj: pointer): PImageClass
-proc image_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_image_get_type".}
-proc image_new*(): PImage{.cdecl, dynlib: lib, importc: "gtk_image_new".}
-proc image_new_from_pixmap*(pixmap: gdk2.PPixmap, mask: gdk2.PBitmap): PImage{.
-    cdecl, dynlib: lib, importc: "gtk_image_new_from_pixmap".}
-proc image_new_from_image*(image: gdk2.PImage, mask: gdk2.PBitmap): PImage{.cdecl, 
-    dynlib: lib, importc: "gtk_image_new_from_image".}
-proc image_new_from_file*(filename: cstring): PImage{.cdecl, dynlib: lib, 
-    importc: "gtk_image_new_from_file".}
-proc image_new_from_pixbuf*(pixbuf: gdk2pixbuf.PPixbuf): PImage{.cdecl, dynlib: lib, 
-    importc: "gtk_image_new_from_pixbuf".}
-proc image_new_from_stock*(stock_id: cstring, size: TIconSize): PImage{.cdecl, 
-    dynlib: lib, importc: "gtk_image_new_from_stock".}
-proc image_new_from_icon_set*(icon_set: PIconSet, size: TIconSize): PImage{.
-    cdecl, dynlib: lib, importc: "gtk_image_new_from_icon_set".}
-proc image_new_from_animation*(animation: gdk2pixbuf.PPixbufAnimation): PImage{.cdecl, 
-    dynlib: lib, importc: "gtk_image_new_from_animation".}
-proc set_from_pixmap*(image: PImage, pixmap: gdk2.PPixmap, mask: gdk2.PBitmap){.
-    cdecl, dynlib: lib, importc: "gtk_image_set_from_pixmap".}
-proc set_from_image*(image: PImage, gdk_image: gdk2.PImage, mask: gdk2.PBitmap){.
-    cdecl, dynlib: lib, importc: "gtk_image_set_from_image".}
-proc set_from_file*(image: PImage, filename: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_image_set_from_file".}
-proc set_from_pixbuf*(image: PImage, pixbuf: gdk2pixbuf.PPixbuf){.cdecl, 
-    dynlib: lib, importc: "gtk_image_set_from_pixbuf".}
-proc set_from_stock*(image: PImage, stock_id: cstring, size: TIconSize){.
-    cdecl, dynlib: lib, importc: "gtk_image_set_from_stock".}
-proc set_from_icon_set*(image: PImage, icon_set: PIconSet, size: TIconSize){.
-    cdecl, dynlib: lib, importc: "gtk_image_set_from_icon_set".}
-proc set_from_animation*(image: PImage, animation: gdk2pixbuf.PPixbufAnimation){.
-    cdecl, dynlib: lib, importc: "gtk_image_set_from_animation".}
-proc get_storage_type*(image: PImage): TImageType{.cdecl, dynlib: lib, 
-    importc: "gtk_image_get_storage_type".}
-proc get_pixbuf*(image: PImage): gdk2pixbuf.PPixbuf{.cdecl, dynlib: lib, 
-    importc: "gtk_image_get_pixbuf".}
-proc get_stock*(image: PImage, stock_id: PPgchar, size: PIconSize){.cdecl, 
-    dynlib: lib, importc: "gtk_image_get_stock".}
-proc get_animation*(image: PImage): gdk2pixbuf.PPixbufAnimation{.cdecl, 
-    dynlib: lib, importc: "gtk_image_get_animation".}
-proc TYPE_IMAGE_MENU_ITEM*(): GType
-proc IMAGE_MENU_ITEM*(obj: pointer): PImageMenuItem
-proc IMAGE_MENU_ITEM_CLASS*(klass: pointer): PImageMenuItemClass
-proc IS_IMAGE_MENU_ITEM*(obj: pointer): bool
-proc IS_IMAGE_MENU_ITEM_CLASS*(klass: pointer): bool
-proc IMAGE_MENU_ITEM_GET_CLASS*(obj: pointer): PImageMenuItemClass
-proc image_menu_item_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_image_menu_item_get_type".}
-proc image_menu_item_new*(): PImageMenuItem{.cdecl, dynlib: lib, 
-    importc: "gtk_image_menu_item_new".}
-proc image_menu_item_new*(`label`: cstring): PImageMenuItem{.cdecl, 
-    dynlib: lib, importc: "gtk_image_menu_item_new_with_label".}
-proc image_menu_item_new_with_mnemonic*(`label`: cstring): PImageMenuItem{.
-    cdecl, dynlib: lib, importc: "gtk_image_menu_item_new_with_mnemonic".}
-proc image_menu_item_new_from_stock*(stock_id: cstring, accel_group: PAccelGroup): PImageMenuItem{.
-    cdecl, dynlib: lib, importc: "gtk_image_menu_item_new_from_stock".}
-proc item_set_image*(image_menu_item: PImageMenuItem, image: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_image_menu_item_set_image".}
-proc item_get_image*(image_menu_item: PImageMenuItem): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_image_menu_item_get_image".}
-const 
-  bm_TGtkIMContextSimple_in_hex_sequence* = 0x0001'i16
-  bp_TGtkIMContextSimple_in_hex_sequence* = 0'i16
-
-proc TYPE_IM_CONTEXT_SIMPLE*(): GType
-proc IM_CONTEXT_SIMPLE*(obj: pointer): PIMContextSimple
-proc IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): PIMContextSimpleClass
-proc IS_IM_CONTEXT_SIMPLE*(obj: pointer): bool
-proc IS_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): bool
-proc IM_CONTEXT_SIMPLE_GET_CLASS*(obj: pointer): PIMContextSimpleClass
-proc in_hex_sequence*(a: PIMContextSimple): guint
-proc set_in_hex_sequence*(a: PIMContextSimple, `in_hex_sequence`: guint)
-proc im_context_simple_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_simple_get_type".}
-proc im_context_simple_new*(): PIMContext{.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_simple_new".}
-proc simple_add_table*(context_simple: PIMContextSimple, 
-                                  data: Pguint16, max_seq_len: gint, 
-                                  n_seqs: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_im_context_simple_add_table".}
-proc TYPE_IM_MULTICONTEXT*(): GType
-proc IM_MULTICONTEXT*(obj: pointer): PIMMulticontext
-proc IM_MULTICONTEXT_CLASS*(klass: pointer): PIMMulticontextClass
-proc IS_IM_MULTICONTEXT*(obj: pointer): bool
-proc IS_IM_MULTICONTEXT_CLASS*(klass: pointer): bool
-proc IM_MULTICONTEXT_GET_CLASS*(obj: pointer): PIMMulticontextClass
-proc im_multicontext_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_im_multicontext_get_type".}
-proc im_multicontext_new*(): PIMContext{.cdecl, dynlib: lib, 
-    importc: "gtk_im_multicontext_new".}
-proc append_menuitems*(context: PIMMulticontext, 
-                                       menushell: PMenuShell){.cdecl, 
-    dynlib: lib, importc: "gtk_im_multicontext_append_menuitems".}
-proc TYPE_INPUT_DIALOG*(): GType
-proc INPUT_DIALOG*(obj: pointer): PInputDialog
-proc INPUT_DIALOG_CLASS*(klass: pointer): PInputDialogClass
-proc IS_INPUT_DIALOG*(obj: pointer): bool
-proc IS_INPUT_DIALOG_CLASS*(klass: pointer): bool
-proc INPUT_DIALOG_GET_CLASS*(obj: pointer): PInputDialogClass
-proc input_dialog_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_input_dialog_get_type".}
-proc input_dialog_new*(): PInputDialog{.cdecl, dynlib: lib, 
-                                        importc: "gtk_input_dialog_new".}
-proc TYPE_INVISIBLE*(): GType
-proc INVISIBLE*(obj: pointer): PInvisible
-proc INVISIBLE_CLASS*(klass: pointer): PInvisibleClass
-proc IS_INVISIBLE*(obj: pointer): bool
-proc IS_INVISIBLE_CLASS*(klass: pointer): bool
-proc INVISIBLE_GET_CLASS*(obj: pointer): PInvisibleClass
-proc invisible_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_invisible_get_type".}
-proc invisible_new*(): PInvisible{.cdecl, dynlib: lib, 
-                                   importc: "gtk_invisible_new".}
-proc invisible_new_for_screen*(screen: gdk2.PScreen): PInvisible{.cdecl, 
-    dynlib: lib, importc: "gtk_invisible_new_for_screen".}
-proc set_screen*(invisible: PInvisible, screen: gdk2.PScreen){.cdecl, 
-    dynlib: lib, importc: "gtk_invisible_set_screen".}
-proc get_screen*(invisible: PInvisible): gdk2.PScreen{.cdecl, 
-    dynlib: lib, importc: "gtk_invisible_get_screen".}
-proc TYPE_ITEM_FACTORY*(): GType
-proc ITEM_FACTORY*(anObject: pointer): PItemFactory
-proc ITEM_FACTORY_CLASS*(klass: pointer): PItemFactoryClass
-proc IS_ITEM_FACTORY*(anObject: pointer): bool
-proc IS_ITEM_FACTORY_CLASS*(klass: pointer): bool
-proc ITEM_FACTORY_GET_CLASS*(obj: pointer): PItemFactoryClass
-proc item_factory_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_item_factory_get_type".}
-proc item_factory_new*(container_type: TType, path: cstring, 
-                       accel_group: PAccelGroup): PItemFactory{.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_new".}
-proc construct*(ifactory: PItemFactory, container_type: TType, 
-                             path: cstring, accel_group: PAccelGroup){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_construct".}
-proc item_factory_add_foreign*(accel_widget: PWidget, full_path: cstring, 
-                               accel_group: PAccelGroup, keyval: guint, 
-                               modifiers: gdk2.TModifierType){.cdecl, dynlib: lib, 
-    importc: "gtk_item_factory_add_foreign".}
-proc item_factory_from_widget*(widget: PWidget): PItemFactory{.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_from_widget".}
-proc item_factory_path_from_widget*(widget: PWidget): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_path_from_widget".}
-proc get_item*(ifactory: PItemFactory, path: cstring): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_get_item".}
-proc get_widget*(ifactory: PItemFactory, path: cstring): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_get_widget".}
-proc get_widget_by_action*(ifactory: PItemFactory, action: guint): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_get_widget_by_action".}
-proc get_item_by_action*(ifactory: PItemFactory, action: guint): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_get_item_by_action".}
-proc create_item*(ifactory: PItemFactory, entry: PItemFactoryEntry, 
-                               callback_data: gpointer, callback_type: guint){.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_create_item".}
-proc create_items*(ifactory: PItemFactory, n_entries: guint, 
-                                entries: PItemFactoryEntry, 
-                                callback_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_item_factory_create_items".}
-proc delete_item*(ifactory: PItemFactory, path: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_delete_item".}
-proc delete_entry*(ifactory: PItemFactory, entry: PItemFactoryEntry){.
-    cdecl, dynlib: lib, importc: "gtk_item_factory_delete_entry".}
-proc delete_entries*(ifactory: PItemFactory, n_entries: guint, 
-                                  entries: PItemFactoryEntry){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_delete_entries".}
-proc popup*(ifactory: PItemFactory, x: guint, y: guint, 
-                         mouse_button: guint, time: guint32){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_popup".}
-proc popup*(ifactory: PItemFactory, popup_data: gpointer, 
-                                   destroy: TDestroyNotify, x: guint, y: guint, 
-                                   mouse_button: guint, time: guint32){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_popup_with_data".}
-proc popup_data*(ifactory: PItemFactory): gpointer{.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_popup_data".}
-proc item_factory_popup_data_from_widget*(widget: PWidget): gpointer{.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_popup_data_from_widget".}
-proc set_translate_func*(ifactory: PItemFactory, 
-                                      fun: TTranslateFunc, data: gpointer, 
-                                      notify: TDestroyNotify){.cdecl, 
-    dynlib: lib, importc: "gtk_item_factory_set_translate_func".}
-proc TYPE_LAYOUT*(): GType
-proc LAYOUT*(obj: pointer): PLayout
-proc LAYOUT_CLASS*(klass: pointer): PLayoutClass
-proc IS_LAYOUT*(obj: pointer): bool
-proc IS_LAYOUT_CLASS*(klass: pointer): bool
-proc LAYOUT_GET_CLASS*(obj: pointer): PLayoutClass
-proc layout_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_layout_get_type".}
-proc layout_new*(hadjustment: PAdjustment, vadjustment: PAdjustment): PLayout{.
-    cdecl, dynlib: lib, importc: "gtk_layout_new".}
-proc put*(layout: PLayout, child_widget: PWidget, x: gint, y: gint){.
-    cdecl, dynlib: lib, importc: "gtk_layout_put".}
-proc move*(layout: PLayout, child_widget: PWidget, x: gint, y: gint){.
-    cdecl, dynlib: lib, importc: "gtk_layout_move".}
-proc set_size*(layout: PLayout, width: guint, height: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_layout_set_size".}
-proc get_size*(layout: PLayout, width: Pguint, height: Pguint){.cdecl, 
-    dynlib: lib, importc: "gtk_layout_get_size".}
-proc get_hadjustment*(layout: PLayout): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_layout_get_hadjustment".}
-proc get_vadjustment*(layout: PLayout): PAdjustment{.cdecl, dynlib: lib, 
-    importc: "gtk_layout_get_vadjustment".}
-proc set_hadjustment*(layout: PLayout, adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_layout_set_hadjustment".}
-proc set_vadjustment*(layout: PLayout, adjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_layout_set_vadjustment".}
-const 
-  bm_TGtkList_selection_mode* = 0x0003'i16
-  bp_TGtkList_selection_mode* = 0'i16
-  bm_TGtkList_drag_selection* = 0x0004'i16
-  bp_TGtkList_drag_selection* = 2'i16
-  bm_TGtkList_add_mode* = 0x0008'i16
-  bp_TGtkList_add_mode* = 3'i16
-
-proc TYPE_LIST*(): GType
-proc LIST*(obj: pointer): PList
-proc LIST_CLASS*(klass: pointer): PListClass
-proc IS_LIST*(obj: pointer): bool
-proc IS_LIST_CLASS*(klass: pointer): bool
-proc LIST_GET_CLASS*(obj: pointer): PListClass
-proc selection_mode*(a: PList): guint
-proc set_selection_mode*(a: PList, `selection_mode`: guint)
-proc drag_selection*(a: PList): guint
-proc set_drag_selection*(a: PList, `drag_selection`: guint)
-proc add_mode*(a: PList): guint
-proc set_add_mode*(a: PList, `add_mode`: guint)
-proc list_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_list_get_type".}
-proc list_new*(): PList{.cdecl, dynlib: lib, importc: "gtk_list_new".}
-proc insert_items*(list: PList, items: PGList, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_list_insert_items".}
-proc append_items*(list: PList, items: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_append_items".}
-proc prepend_items*(list: PList, items: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_prepend_items".}
-proc remove_items*(list: PList, items: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_remove_items".}
-proc remove_items_no_unref*(list: PList, items: PGList){.cdecl, 
-    dynlib: lib, importc: "gtk_list_remove_items_no_unref".}
-proc clear_items*(list: PList, start: gint, theEnd: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_list_clear_items".}
-proc select_item*(list: PList, item: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_list_select_item".}
-proc unselect_item*(list: PList, item: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_list_unselect_item".}
-proc select_child*(list: PList, child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_list_select_child".}
-proc unselect_child*(list: PList, child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_list_unselect_child".}
-proc child_position*(list: PList, child: PWidget): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_list_child_position".}
-proc set_selection_mode*(list: PList, mode: TSelectionMode){.cdecl, 
-    dynlib: lib, importc: "gtk_list_set_selection_mode".}
-proc extend_selection*(list: PList, scroll_type: TScrollType, 
-                            position: gfloat, auto_start_selection: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_list_extend_selection".}
-proc start_selection*(list: PList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_start_selection".}
-proc end_selection*(list: PList){.cdecl, dynlib: lib, 
-                                       importc: "gtk_list_end_selection".}
-proc select_all*(list: PList){.cdecl, dynlib: lib, 
-                                    importc: "gtk_list_select_all".}
-proc unselect_all*(list: PList){.cdecl, dynlib: lib, 
-                                      importc: "gtk_list_unselect_all".}
-proc scroll_horizontal*(list: PList, scroll_type: TScrollType, 
-                             position: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_list_scroll_horizontal".}
-proc scroll_vertical*(list: PList, scroll_type: TScrollType, 
-                           position: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_list_scroll_vertical".}
-proc toggle_add_mode*(list: PList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_toggle_add_mode".}
-proc toggle_focus_row*(list: PList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_toggle_focus_row".}
-proc toggle_row*(list: PList, item: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_list_toggle_row".}
-proc undo_selection*(list: PList){.cdecl, dynlib: lib, 
-                                        importc: "gtk_list_undo_selection".}
-proc end_drag_selection*(list: PList){.cdecl, dynlib: lib, 
-    importc: "gtk_list_end_drag_selection".}
-const 
-  TREE_MODEL_ITERS_PERSIST* = 1 shl 0
-  TREE_MODEL_LIST_ONLY* = 1 shl 1
-
-proc TYPE_TREE_MODEL*(): GType
-proc TREE_MODEL*(obj: pointer): PTreeModel
-proc IS_TREE_MODEL*(obj: pointer): bool
-proc TREE_MODEL_GET_IFACE*(obj: pointer): PTreeModelIface
-proc TYPE_TREE_ITER*(): GType
-proc TYPE_TREE_PATH*(): GType
-proc tree_path_new*(): PTreePath{.cdecl, dynlib: lib, 
-                                  importc: "gtk_tree_path_new".}
-proc tree_path_new_from_string*(path: cstring): PTreePath{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_new_from_string".}
-proc to_string*(path: PTreePath): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_to_string".}
-proc tree_path_new_root*(): PTreePath
-proc tree_path_new_first*(): PTreePath{.cdecl, dynlib: lib, 
-                                        importc: "gtk_tree_path_new_first".}
-proc append_index*(path: PTreePath, index: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_append_index".}
-proc prepend_index*(path: PTreePath, index: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_prepend_index".}
-proc get_depth*(path: PTreePath): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_get_depth".}
-proc get_indices*(path: PTreePath): Pgint{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_get_indices".}
-proc free*(path: PTreePath){.cdecl, dynlib: lib, 
-                                       importc: "gtk_tree_path_free".}
-proc copy*(path: PTreePath): PTreePath{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_copy".}
-proc tree_path_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_tree_path_get_type".}
-proc compare*(a: PTreePath, b: PTreePath): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_compare".}
-proc next*(path: PTreePath){.cdecl, dynlib: lib, 
-                                       importc: "gtk_tree_path_next".}
-proc prev*(path: PTreePath): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_prev".}
-proc up*(path: PTreePath): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_path_up".}
-proc down*(path: PTreePath){.cdecl, dynlib: lib, 
-                                       importc: "gtk_tree_path_down".}
-proc is_ancestor*(path: PTreePath, descendant: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_path_is_ancestor".}
-proc is_descendant*(path: PTreePath, ancestor: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_path_is_descendant".}
-proc row_reference_new*(model: PTreeModel, path: PTreePath): PTreeRowReference{.
-    cdecl, dynlib: lib, importc: "gtk_tree_row_reference_new".}
-proc tree_row_reference_new_proxy*(proxy: PGObject, model: PTreeModel, 
-                                   path: PTreePath): PTreeRowReference{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_row_reference_new_proxy".}
-proc reference_get_path*(reference: PTreeRowReference): PTreePath{.
-    cdecl, dynlib: lib, importc: "gtk_tree_row_reference_get_path".}
-proc reference_valid*(reference: PTreeRowReference): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_row_reference_valid".}
-proc reference_free*(reference: PTreeRowReference){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_row_reference_free".}
-proc tree_row_reference_inserted*(proxy: PGObject, path: PTreePath){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_row_reference_inserted".}
-proc tree_row_reference_deleted*(proxy: PGObject, path: PTreePath){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_row_reference_deleted".}
-proc tree_row_reference_reordered*(proxy: PGObject, path: PTreePath, 
-                                   iter: PTreeIter, new_order: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_row_reference_reordered".}
-proc copy*(iter: PTreeIter): PTreeIter{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_iter_copy".}
-proc free*(iter: PTreeIter){.cdecl, dynlib: lib, 
-                                       importc: "gtk_tree_iter_free".}
-proc tree_iter_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_tree_iter_get_type".}
-proc tree_model_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_tree_model_get_type".}
-proc get_flags*(tree_model: PTreeModel): TTreeModelFlags{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_get_flags".}
-proc get_n_columns*(tree_model: PTreeModel): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_get_n_columns".}
-proc get_column_type*(tree_model: PTreeModel, index: gint): GType{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_get_column_type".}
-proc get_iter*(tree_model: PTreeModel, iter: PTreeIter, 
-                          path: PTreePath): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_get_iter".}
-proc get_iter_from_string*(tree_model: PTreeModel, iter: PTreeIter, 
-                                      path_string: cstring): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_get_iter_from_string".}
-proc get_iter_root*(tree_model: PTreeModel, iter: PTreeIter): gboolean
-proc get_iter_first*(tree_model: PTreeModel, iter: PTreeIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_get_iter_first".}
-proc get_path*(tree_model: PTreeModel, iter: PTreeIter): PTreePath{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_get_path".}
-proc get_value*(tree_model: PTreeModel, iter: PTreeIter, 
-                           column: gint, value: PGValue){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_get_value".}
-proc iter_next*(tree_model: PTreeModel, iter: PTreeIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_iter_next".}
-proc iter_children*(tree_model: PTreeModel, iter: PTreeIter, 
-                               parent: PTreeIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_iter_children".}
-proc iter_has_child*(tree_model: PTreeModel, iter: PTreeIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_iter_has_child".}
-proc iter_n_children*(tree_model: PTreeModel, iter: PTreeIter): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_iter_n_children".}
-proc iter_nth_child*(tree_model: PTreeModel, iter: PTreeIter, 
-                                parent: PTreeIter, n: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_iter_nth_child".}
-proc iter_parent*(tree_model: PTreeModel, iter: PTreeIter, 
-                             child: PTreeIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_iter_parent".}
-proc ref_node*(tree_model: PTreeModel, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_ref_node".}
-proc unref_node*(tree_model: PTreeModel, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_unref_node".}
-proc foreach*(model: PTreeModel, fun: TTreeModelForeachFunc, 
-                         user_data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_foreach".}
-proc row_changed*(tree_model: PTreeModel, path: PTreePath, 
-                             iter: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_row_changed".}
-proc row_inserted*(tree_model: PTreeModel, path: PTreePath, 
-                              iter: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_row_inserted".}
-proc row_has_child_toggled*(tree_model: PTreeModel, path: PTreePath, 
-                                       iter: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_row_has_child_toggled".}
-proc row_deleted*(tree_model: PTreeModel, path: PTreePath){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_row_deleted".}
-proc rows_reordered*(tree_model: PTreeModel, path: PTreePath, 
-                                iter: PTreeIter, new_order: Pgint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_rows_reordered".}
-const 
-  TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID* = - (1)
-
-proc TYPE_TREE_SORTABLE*(): GType
-proc TREE_SORTABLE*(obj: pointer): PTreeSortable
-proc TREE_SORTABLE_CLASS*(obj: pointer): PTreeSortableIface
-proc IS_TREE_SORTABLE*(obj: pointer): bool
-proc TREE_SORTABLE_GET_IFACE*(obj: pointer): PTreeSortableIface
-proc tree_sortable_get_type*(): GType{.cdecl, dynlib: lib, 
-                                       importc: "gtk_tree_sortable_get_type".}
-proc sort_column_changed*(sortable: PTreeSortable){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_sortable_sort_column_changed".}
-proc get_sort_column_id*(sortable: PTreeSortable, 
-                                       sort_column_id: Pgint, order: PSortType): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_sortable_get_sort_column_id".}
-proc set_sort_column_id*(sortable: PTreeSortable, 
-                                       sort_column_id: gint, order: TSortType){.
-    cdecl, dynlib: lib, importc: "gtk_tree_sortable_set_sort_column_id".}
-proc set_sort_func*(sortable: PTreeSortable, sort_column_id: gint, 
-                                  sort_func: TTreeIterCompareFunc, 
-                                  user_data: gpointer, destroy: TDestroyNotify){.
-    cdecl, dynlib: lib, importc: "gtk_tree_sortable_set_sort_func".}
-proc set_default_sort_func*(sortable: PTreeSortable, 
-    sort_func: TTreeIterCompareFunc, user_data: gpointer, 
-    destroy: TDestroyNotify){.cdecl, dynlib: lib, importc: "gtk_tree_sortable_set_default_sort_func".}
-proc has_default_sort_func*(sortable: PTreeSortable): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_sortable_has_default_sort_func".}
-proc TYPE_TREE_MODEL_SORT*(): GType
-proc TREE_MODEL_SORT*(obj: pointer): PTreeModelSort
-proc TREE_MODEL_SORT_CLASS*(klass: pointer): PTreeModelSortClass
-proc IS_TREE_MODEL_SORT*(obj: pointer): bool
-proc IS_TREE_MODEL_SORT_CLASS*(klass: pointer): bool
-proc TREE_MODEL_SORT_GET_CLASS*(obj: pointer): PTreeModelSortClass
-proc tree_model_sort_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_sort_get_type".}
-proc sort_new*(child_model: PTreeModel): PTreeModel{.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_sort_new_with_model".}
-proc sort_get_model*(tree_model: PTreeModelSort): PTreeModel{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_sort_get_model".}
-proc tree_model_sort_convert_child_path_to_path*(
-    tree_model_sort: PTreeModelSort, child_path: PTreePath): PTreePath{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_sort_convert_child_path_to_path".}
-proc tree_model_sort_convert_child_iter_to_iter*(
-    tree_model_sort: PTreeModelSort, sort_iter: PTreeIter, child_iter: PTreeIter){.
-    cdecl, dynlib: lib, 
-    importc: "gtk_tree_model_sort_convert_child_iter_to_iter".}
-proc tree_model_sort_convert_path_to_child_path*(
-    tree_model_sort: PTreeModelSort, sorted_path: PTreePath): PTreePath{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_sort_convert_path_to_child_path".}
-proc tree_model_sort_convert_iter_to_child_iter*(
-    tree_model_sort: PTreeModelSort, child_iter: PTreeIter, 
-    sorted_iter: PTreeIter){.cdecl, dynlib: lib, importc: "gtk_tree_model_sort_convert_iter_to_child_iter".}
-proc sort_reset_default_sort_func*(tree_model_sort: PTreeModelSort){.
-    cdecl, dynlib: lib, importc: "gtk_tree_model_sort_reset_default_sort_func".}
-proc sort_clear_cache*(tree_model_sort: PTreeModelSort){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_model_sort_clear_cache".}
-const 
-  bm_TGtkListStore_columns_dirty* = 0x0001'i16
-  bp_TGtkListStore_columns_dirty* = 0'i16
-
-proc TYPE_LIST_STORE*(): GType
-proc LIST_STORE*(obj: pointer): PListStore
-proc LIST_STORE_CLASS*(klass: pointer): PListStoreClass
-proc IS_LIST_STORE*(obj: pointer): bool
-proc IS_LIST_STORE_CLASS*(klass: pointer): bool
-proc LIST_STORE_GET_CLASS*(obj: pointer): PListStoreClass
-proc columns_dirty*(a: PListStore): guint
-proc set_columns_dirty*(a: PListStore, `columns_dirty`: guint)
-proc list_store_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_list_store_get_type".}
-proc list_store_newv*(n_columns: gint, types: PGType): PListStore{.cdecl, 
-    dynlib: lib, importc: "gtk_list_store_newv".}
-proc set_column_types*(list_store: PListStore, n_columns: gint, 
-                                  types: PGType){.cdecl, dynlib: lib, 
-    importc: "gtk_list_store_set_column_types".}
-proc set_value*(list_store: PListStore, iter: PTreeIter, 
-                           column: gint, value: PGValue){.cdecl, dynlib: lib, 
-    importc: "gtk_list_store_set_value".}
-proc remove*(list_store: PListStore, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_list_store_remove".}
-proc insert*(list_store: PListStore, iter: PTreeIter, position: gint){.
-    cdecl, dynlib: lib, importc: "gtk_list_store_insert".}
-proc insert_before*(list_store: PListStore, iter: PTreeIter, 
-                               sibling: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_list_store_insert_before".}
-proc insert_after*(list_store: PListStore, iter: PTreeIter, 
-                              sibling: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_list_store_insert_after".}
-proc prepend*(list_store: PListStore, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_list_store_prepend".}
-proc append*(list_store: PListStore, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_list_store_append".}
-proc clear*(list_store: PListStore){.cdecl, dynlib: lib, 
-    importc: "gtk_list_store_clear".}
-when false: 
-  const 
-    PRIORITY_RESIZE* = G_PRIORITY_HIGH_IDLE + 10
-proc check_version*(required_major: guint, required_minor: guint, 
-                    required_micro: guint): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_check_version".}
-proc disable_setlocale*(){.cdecl, dynlib: lib, importc: "gtk_disable_setlocale".}
-proc set_locale*(): cstring{.cdecl, dynlib: lib, importc: "gtk_set_locale".}
-proc get_default_language*(): pango.PLanguage{.cdecl, dynlib: lib, 
-    importc: "gtk_get_default_language".}
-proc events_pending*(): gint{.cdecl, dynlib: lib, importc: "gtk_events_pending".}
-proc main_do_event*(event: gdk2.PEvent){.cdecl, dynlib: lib, 
-                                       importc: "gtk_main_do_event".}
-proc main*(){.cdecl, dynlib: lib, importc: "gtk_main".}
-proc init*(argc, argv: pointer){.cdecl, dynlib: lib, importc: "gtk_init".}
-proc main_level*(): guint{.cdecl, dynlib: lib, importc: "gtk_main_level".}
-proc main_quit*(){.cdecl, dynlib: lib, importc: "gtk_main_quit".}
-proc main_iteration*(): gboolean{.cdecl, dynlib: lib, 
-                                  importc: "gtk_main_iteration".}
-proc main_iteration_do*(blocking: gboolean): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_main_iteration_do".}
-proc gtkTrue*(): gboolean{.cdecl, dynlib: lib, importc: "gtk_true".}
-proc gtkFalse*(): gboolean{.cdecl, dynlib: lib, importc: "gtk_false".}
-proc grab_add*(widget: PWidget){.cdecl, dynlib: lib, importc: "gtk_grab_add".}
-proc grab_get_current*(): PWidget{.cdecl, dynlib: lib, 
-                                   importc: "gtk_grab_get_current".}
-proc grab_remove*(widget: PWidget){.cdecl, dynlib: lib, 
-                                    importc: "gtk_grab_remove".}
-proc init_add*(`function`: TFunction, data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_init_add".}
-proc quit_add_destroy*(main_level: guint, anObject: PObject){.cdecl, 
-    dynlib: lib, importc: "gtk_quit_add_destroy".}
-proc quit_add*(main_level: guint, `function`: TFunction, data: gpointer): guint{.
-    cdecl, dynlib: lib, importc: "gtk_quit_add".}
-proc quit_add_full*(main_level: guint, `function`: TFunction, 
-                    marshal: TCallbackMarshal, data: gpointer, 
-                    destroy: TDestroyNotify): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_quit_add_full".}
-proc quit_remove*(quit_handler_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_quit_remove".}
-proc quit_remove_by_data*(data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_quit_remove_by_data".}
-proc timeout_add*(interval: guint32, `function`: TFunction, data: gpointer): guint{.
-    cdecl, dynlib: lib, importc: "gtk_timeout_add".}
-proc timeout_add_full*(interval: guint32, `function`: TFunction, 
-                       marshal: TCallbackMarshal, data: gpointer, 
-                       destroy: TDestroyNotify): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_timeout_add_full".}
-proc timeout_remove*(timeout_handler_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_timeout_remove".}
-proc idle_add*(`function`: TFunction, data: gpointer): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_idle_add".}
-proc idle_add_priority*(priority: gint, `function`: TFunction, data: gpointer): guint{.
-    cdecl, dynlib: lib, importc: "gtk_idle_add_priority".}
-proc idle_add_full*(priority: gint, `function`: TFunction, 
-                    marshal: TCallbackMarshal, data: gpointer, 
-                    destroy: TDestroyNotify): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_idle_add_full".}
-proc idle_remove*(idle_handler_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_idle_remove".}
-proc idle_remove_by_data*(data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_idle_remove_by_data".}
-proc input_add_full*(source: gint, condition: gdk2.TInputCondition, 
-                     `function`: gdk2.TInputFunction, marshal: TCallbackMarshal, 
-                     data: gpointer, destroy: TDestroyNotify): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_input_add_full".}
-proc input_remove*(input_handler_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_input_remove".}
-proc key_snooper_install*(snooper: TKeySnoopFunc, func_data: gpointer): guint{.
-    cdecl, dynlib: lib, importc: "gtk_key_snooper_install".}
-proc key_snooper_remove*(snooper_handler_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_key_snooper_remove".}
-proc get_current_event*(): gdk2.PEvent{.cdecl, dynlib: lib, 
-                                      importc: "gtk_get_current_event".}
-proc get_current_event_time*(): guint32{.cdecl, dynlib: lib, 
-    importc: "gtk_get_current_event_time".}
-proc get_current_event_state*(state: gdk2.PModifierType): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_get_current_event_state".}
-proc get_event_widget*(event: gdk2.PEvent): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_get_event_widget".}
-proc propagate_event*(widget: PWidget, event: gdk2.PEvent){.cdecl, dynlib: lib, 
-    importc: "gtk_propagate_event".}
-proc boolean_handled_accumulator*(ihint: PGSignalInvocationHint, 
-                                  return_accu: PGValue, handler_return: PGValue, 
-                                  dummy: gpointer): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_boolean_handled_accumulator".}
-proc find_module*(name: cstring, thetype: cstring): cstring{.cdecl, dynlib: lib, 
-    importc: "_gtk_find_module".}
-proc get_module_path*(thetype: cstring): PPgchar{.cdecl, dynlib: lib, 
-    importc: "_gtk_get_module_path".}
-proc TYPE_MENU_BAR*(): GType
-proc MENU_BAR*(obj: pointer): PMenuBar
-proc MENU_BAR_CLASS*(klass: pointer): PMenuBarClass
-proc IS_MENU_BAR*(obj: pointer): bool
-proc IS_MENU_BAR_CLASS*(klass: pointer): bool
-proc MENU_BAR_GET_CLASS*(obj: pointer): PMenuBarClass
-proc menu_bar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_menu_bar_get_type".}
-proc menu_bar_new*(): PMenuBar{.cdecl, dynlib: lib, importc: "gtk_menu_bar_new".}
-proc cycle_focus*(menubar: PMenuBar, dir: TDirectionType){.cdecl, 
-    dynlib: lib, importc: "_gtk_menu_bar_cycle_focus".}
-proc TYPE_MESSAGE_DIALOG*(): GType
-proc MESSAGE_DIALOG*(obj: pointer): PMessageDialog
-proc MESSAGE_DIALOG_CLASS*(klass: pointer): PMessageDialogClass
-proc IS_MESSAGE_DIALOG*(obj: pointer): bool
-proc IS_MESSAGE_DIALOG_CLASS*(klass: pointer): bool
-proc MESSAGE_DIALOG_GET_CLASS*(obj: pointer): PMessageDialogClass
-proc message_dialog_get_type*(): TType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_message_dialog_get_type".}
-const 
-  bm_TGtkNotebook_show_tabs* = 0x0001'i16
-  bp_TGtkNotebook_show_tabs* = 0'i16
-  bm_TGtkNotebook_homogeneous* = 0x0002'i16
-  bp_TGtkNotebook_homogeneous* = 1'i16
-  bm_TGtkNotebook_show_border* = 0x0004'i16
-  bp_TGtkNotebook_show_border* = 2'i16
-  bm_TGtkNotebook_tab_pos* = 0x0018'i16
-  bp_TGtkNotebook_tab_pos* = 3'i16
-  bm_TGtkNotebook_scrollable* = 0x0020'i16
-  bp_TGtkNotebook_scrollable* = 5'i16
-  bm_TGtkNotebook_in_child* = 0x00C0'i16
-  bp_TGtkNotebook_in_child* = 6'i16
-  bm_TGtkNotebook_click_child* = 0x0300'i16
-  bp_TGtkNotebook_click_child* = 8'i16
-  bm_TGtkNotebook_button* = 0x0C00'i16
-  bp_TGtkNotebook_button* = 10'i16
-  bm_TGtkNotebook_need_timer* = 0x1000'i16
-  bp_TGtkNotebook_need_timer* = 12'i16
-  bm_TGtkNotebook_child_has_focus* = 0x2000'i16
-  bp_TGtkNotebook_child_has_focus* = 13'i16
-  bm_TGtkNotebook_have_visible_child* = 0x4000'i16
-  bp_TGtkNotebook_have_visible_child* = 14'i16
-  bm_TGtkNotebook_focus_out* = 0x8000'i16
-  bp_TGtkNotebook_focus_out* = 15'i16
-
-proc TYPE_NOTEBOOK*(): GType
-proc NOTEBOOK*(obj: pointer): PNotebook
-proc NOTEBOOK_CLASS*(klass: pointer): PNotebookClass
-proc IS_NOTEBOOK*(obj: pointer): bool
-proc IS_NOTEBOOK_CLASS*(klass: pointer): bool
-proc NOTEBOOK_GET_CLASS*(obj: pointer): PNotebookClass
-proc show_tabs*(a: PNotebook): guint
-proc set_show_tabs*(a: PNotebook, `show_tabs`: guint)
-proc homogeneous*(a: PNotebook): guint
-proc set_homogeneous*(a: PNotebook, `homogeneous`: guint)
-proc show_border*(a: PNotebook): guint
-proc set_show_border*(a: PNotebook, `show_border`: guint)
-proc tab_pos*(a: PNotebook): guint
-proc scrollable*(a: PNotebook): guint
-proc set_scrollable*(a: PNotebook, `scrollable`: guint)
-proc in_child*(a: PNotebook): guint
-proc set_in_child*(a: PNotebook, `in_child`: guint)
-proc click_child*(a: PNotebook): guint
-proc set_click_child*(a: PNotebook, `click_child`: guint)
-proc button*(a: PNotebook): guint
-proc set_button*(a: PNotebook, `button`: guint)
-proc need_timer*(a: PNotebook): guint
-proc set_need_timer*(a: PNotebook, `need_timer`: guint)
-proc child_has_focus*(a: PNotebook): guint
-proc set_child_has_focus*(a: PNotebook, `child_has_focus`: guint)
-proc have_visible_child*(a: PNotebook): guint
-proc set_have_visible_child*(a: PNotebook, `have_visible_child`: guint)
-proc focus_out*(a: PNotebook): guint
-proc set_focus_out*(a: PNotebook, `focus_out`: guint)
-proc notebook_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_notebook_get_type".}
-proc notebook_new*(): PNotebook{.cdecl, dynlib: lib, importc: "gtk_notebook_new".}
-proc append_page*(notebook: PNotebook, child: PWidget, 
-                           tab_label: PWidget): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_append_page".}
-proc append_page_menu*(notebook: PNotebook, child: PWidget, 
-                                tab_label: PWidget, menu_label: PWidget): gint{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_append_page_menu".}
-proc prepend_page*(notebook: PNotebook, child: PWidget, 
-                            tab_label: PWidget): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_prepend_page".}
-proc prepend_page_menu*(notebook: PNotebook, child: PWidget, 
-                                 tab_label: PWidget, menu_label: PWidget): gint{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_prepend_page_menu".}
-proc insert_page*(notebook: PNotebook, child: PWidget, 
-                           tab_label: PWidget, position: gint): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_insert_page".}
-proc insert_page_menu*(notebook: PNotebook, child: PWidget, 
-                                tab_label: PWidget, menu_label: PWidget, 
-                                position: gint): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_insert_page_menu".}
-proc remove_page*(notebook: PNotebook, page_num: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_remove_page".}
-proc get_current_page*(notebook: PNotebook): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_get_current_page".}
-proc get_n_pages*(notebook: PNotebook): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_get_n_pages".}
-proc get_nth_page*(notebook: PNotebook, page_num: gint): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_get_nth_page".}
-proc page_num*(notebook: PNotebook, child: PWidget): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_page_num".}
-proc set_current_page*(notebook: PNotebook, page_num: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_set_current_page".}
-proc next_page*(notebook: PNotebook){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_next_page".}
-proc prev_page*(notebook: PNotebook){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_prev_page".}
-proc set_show_border*(notebook: PNotebook, show_border: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_notebook_set_show_border".}
-proc get_show_border*(notebook: PNotebook): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_get_show_border".}
-proc set_show_tabs*(notebook: PNotebook, show_tabs: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_set_show_tabs".}
-proc get_show_tabs*(notebook: PNotebook): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_get_show_tabs".}
-#proc set_tab_pos*(notebook: PNotebook, pos: TPositionType){.cdecl, 
-#    dynlib: lib, importc: "gtk_notebook_set_tab_pos".}
-proc get_tab_pos*(notebook: PNotebook): TPositionType{.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_get_tab_pos".}
-proc set_scrollable*(notebook: PNotebook, scrollable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_set_scrollable".}
-proc get_scrollable*(notebook: PNotebook): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_get_scrollable".}
-proc popup_enable*(notebook: PNotebook){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_popup_enable".}
-proc popup_disable*(notebook: PNotebook){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_popup_disable".}
-proc get_tab_label*(notebook: PNotebook, child: PWidget): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_get_tab_label".}
-proc set_tab_label*(notebook: PNotebook, child: PWidget, 
-                             tab_label: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_set_tab_label".}
-proc set_tab_label_text*(notebook: PNotebook, child: PWidget, 
-                                  tab_text: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_set_tab_label_text".}
-proc get_tab_label_text*(notebook: PNotebook, child: PWidget): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_get_tab_label_text".}
-proc get_menu_label*(notebook: PNotebook, child: PWidget): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_get_menu_label".}
-proc set_menu_label*(notebook: PNotebook, child: PWidget, 
-                              menu_label: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_set_menu_label".}
-proc set_menu_label_text*(notebook: PNotebook, child: PWidget, 
-                                   menu_text: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_set_menu_label_text".}
-proc get_menu_label_text*(notebook: PNotebook, child: PWidget): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_notebook_get_menu_label_text".}
-proc query_tab_label_packing*(notebook: PNotebook, child: PWidget, 
-                                       expand: Pgboolean, fill: Pgboolean, 
-                                       pack_type: PPackType){.cdecl, 
-    dynlib: lib, importc: "gtk_notebook_query_tab_label_packing".}
-proc set_tab_label_packing*(notebook: PNotebook, child: PWidget, 
-                                     expand: gboolean, fill: gboolean, 
-                                     pack_type: TPackType){.cdecl, dynlib: lib, 
-    importc: "gtk_notebook_set_tab_label_packing".}
-proc reorder_child*(notebook: PNotebook, child: PWidget, position: gint){.
-    cdecl, dynlib: lib, importc: "gtk_notebook_reorder_child".}
-const 
-  bm_TGtkOldEditable_has_selection* = 0x0001'i16
-  bp_TGtkOldEditable_has_selection* = 0'i16
-  bm_TGtkOldEditable_editable* = 0x0002'i16
-  bp_TGtkOldEditable_editable* = 1'i16
-  bm_TGtkOldEditable_visible* = 0x0004'i16
-  bp_TGtkOldEditable_visible* = 2'i16
-
-proc TYPE_OLD_EDITABLE*(): GType
-proc OLD_EDITABLE*(obj: pointer): POldEditable
-proc OLD_EDITABLE_CLASS*(klass: pointer): POldEditableClass
-proc IS_OLD_EDITABLE*(obj: pointer): bool
-proc IS_OLD_EDITABLE_CLASS*(klass: pointer): bool
-proc OLD_EDITABLE_GET_CLASS*(obj: pointer): POldEditableClass
-proc has_selection*(a: POldEditable): guint
-proc set_has_selection*(a: POldEditable, `has_selection`: guint)
-proc editable*(a: POldEditable): guint
-proc set_editable*(a: POldEditable, `editable`: guint)
-proc visible*(a: POldEditable): guint
-proc set_visible*(a: POldEditable, `visible`: guint)
-proc old_editable_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_old_editable_get_type".}
-proc claim_selection*(old_editable: POldEditable, claim: gboolean, 
-                                   time: guint32){.cdecl, dynlib: lib, 
-    importc: "gtk_old_editable_claim_selection".}
-proc changed*(old_editable: POldEditable){.cdecl, dynlib: lib, 
-    importc: "gtk_old_editable_changed".}
-proc TYPE_OPTION_MENU*(): GType
-proc OPTION_MENU*(obj: pointer): POptionMenu
-proc OPTION_MENU_CLASS*(klass: pointer): POptionMenuClass
-proc IS_OPTION_MENU*(obj: pointer): bool
-proc IS_OPTION_MENU_CLASS*(klass: pointer): bool
-proc OPTION_MENU_GET_CLASS*(obj: pointer): POptionMenuClass
-proc option_menu_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_option_menu_get_type".}
-proc option_menu_new*(): POptionMenu{.cdecl, dynlib: lib, 
-                                      importc: "gtk_option_menu_new".}
-proc get_menu*(option_menu: POptionMenu): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_option_menu_get_menu".}
-proc set_menu*(option_menu: POptionMenu, menu: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_option_menu_set_menu".}
-proc remove_menu*(option_menu: POptionMenu){.cdecl, dynlib: lib, 
-    importc: "gtk_option_menu_remove_menu".}
-proc get_history*(option_menu: POptionMenu): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_option_menu_get_history".}
-proc set_history*(option_menu: POptionMenu, index: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_option_menu_set_history".}
-const 
-  bm_TGtkPixmap_build_insensitive* = 0x0001'i16
-  bp_TGtkPixmap_build_insensitive* = 0'i16
-
-proc TYPE_PIXMAP*(): GType
-proc PIXMAP*(obj: pointer): PPixmap
-proc PIXMAP_CLASS*(klass: pointer): PPixmapClass
-proc IS_PIXMAP*(obj: pointer): bool
-proc IS_PIXMAP_CLASS*(klass: pointer): bool
-proc PIXMAP_GET_CLASS*(obj: pointer): PPixmapClass
-proc build_insensitive*(a: PPixmap): guint
-proc set_build_insensitive*(a: PPixmap, `build_insensitive`: guint)
-proc pixmap_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_pixmap_get_type".}
-proc pixmap_new*(pixmap: gdk2.PPixmap, mask: gdk2.PBitmap): PPixmap{.cdecl, 
-    dynlib: lib, importc: "gtk_pixmap_new".}
-proc set*(pixmap: PPixmap, val: gdk2.PPixmap, mask: gdk2.PBitmap){.cdecl, 
-    dynlib: lib, importc: "gtk_pixmap_set".}
-proc get*(pixmap: PPixmap, val: var gdk2.PPixmap, mask: var gdk2.PBitmap){.
-    cdecl, dynlib: lib, importc: "gtk_pixmap_get".}
-proc set_build_insensitive*(pixmap: PPixmap, build: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_pixmap_set_build_insensitive".}
-const 
-  bm_TGtkPlug_same_app* = 0x0001'i16
-  bp_TGtkPlug_same_app* = 0'i16
-
-proc TYPE_PLUG*(): GType
-proc PLUG*(obj: pointer): PPlug
-proc PLUG_CLASS*(klass: pointer): PPlugClass
-proc IS_PLUG*(obj: pointer): bool
-proc IS_PLUG_CLASS*(klass: pointer): bool
-proc PLUG_GET_CLASS*(obj: pointer): PPlugClass
-proc same_app*(a: PPlug): guint
-proc set_same_app*(a: PPlug, `same_app`: guint)
-proc plug_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_plug_get_type".}
-proc construct_for_display*(plug: PPlug, display: gdk2.PDisplay, 
-                                 socket_id: gdk2.TNativeWindow){.cdecl, 
-    dynlib: lib, importc: "gtk_plug_construct_for_display".}
-proc plug_new_for_display*(display: gdk2.PDisplay, socket_id: gdk2.TNativeWindow): PPlug{.
-    cdecl, dynlib: lib, importc: "gtk_plug_new_for_display".}
-proc get_id*(plug: PPlug): gdk2.TNativeWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_plug_get_id".}
-proc add_to_socket*(plug: PPlug, socket: PSocket){.cdecl, dynlib: lib, 
-    importc: "_gtk_plug_add_to_socket".}
-proc remove_from_socket*(plug: PPlug, socket: PSocket){.cdecl, dynlib: lib, 
-    importc: "_gtk_plug_remove_from_socket".}
-const 
-  bm_TGtkPreview_type* = 0x0001'i16
-  bp_TGtkPreview_type* = 0'i16
-  bm_TGtkPreview_expand* = 0x0002'i16
-  bp_TGtkPreview_expand* = 1'i16
-
-proc TYPE_PREVIEW*(): GType
-proc PREVIEW*(obj: pointer): PPreview
-proc PREVIEW_CLASS*(klass: pointer): PPreviewClass
-proc IS_PREVIEW*(obj: pointer): bool
-proc IS_PREVIEW_CLASS*(klass: pointer): bool
-proc PREVIEW_GET_CLASS*(obj: pointer): PPreviewClass
-proc get_type*(a: PPreview): guint
-proc set_type*(a: PPreview, `type`: guint)
-proc get_expand*(a: PPreview): guint
-proc set_expand*(a: PPreview, `expand`: guint)
-proc preview_get_type*(): TType{.cdecl, dynlib: lib, 
-                                 importc: "gtk_preview_get_type".}
-proc preview_uninit*(){.cdecl, dynlib: lib, importc: "gtk_preview_uninit".}
-proc preview_new*(thetype: TPreviewClass): PPreview{.cdecl, dynlib: lib, 
-    importc: "gtk_preview_new".}
-proc size*(preview: PPreview, width: gint, height: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_preview_size".}
-proc put*(preview: PPreview, window: gdk2.PWindow, gc: gdk2.PGC, srcx: gint, 
-                  srcy: gint, destx: gint, desty: gint, width: gint, 
-                  height: gint){.cdecl, dynlib: lib, importc: "gtk_preview_put".}
-proc draw_row*(preview: PPreview, data: Pguchar, x: gint, y: gint, 
-                       w: gint){.cdecl, dynlib: lib, 
-                                 importc: "gtk_preview_draw_row".}
-proc set_expand*(preview: PPreview, expand: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_preview_set_expand".}
-proc preview_set_gamma*(gamma: float64){.cdecl, dynlib: lib, 
-    importc: "gtk_preview_set_gamma".}
-proc preview_set_color_cube*(nred_shades: guint, ngreen_shades: guint, 
-                             nblue_shades: guint, ngray_shades: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_preview_set_color_cube".}
-proc preview_set_install_cmap*(install_cmap: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_preview_set_install_cmap".}
-proc preview_set_reserved*(nreserved: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_preview_set_reserved".}
-proc set_dither*(preview: PPreview, dither: gdk2.TRgbDither){.cdecl, 
-    dynlib: lib, importc: "gtk_preview_set_dither".}
-proc preview_get_info*(): PPreviewInfo{.cdecl, dynlib: lib, 
-                                        importc: "gtk_preview_get_info".}
-proc preview_reset*(){.cdecl, dynlib: lib, importc: "gtk_preview_reset".}
-const 
-  bm_TGtkProgress_show_text* = 0x0001'i16
-  bp_TGtkProgress_show_text* = 0'i16
-  bm_TGtkProgress_activity_mode* = 0x0002'i16
-  bp_TGtkProgress_activity_mode* = 1'i16
-  bm_TGtkProgress_use_text_format* = 0x0004'i16
-  bp_TGtkProgress_use_text_format* = 2'i16
-
-proc show_text*(a: PProgress): guint
-proc set_show_text*(a: PProgress, `show_text`: guint)
-proc activity_mode*(a: PProgress): guint
-proc set_activity_mode*(a: PProgress, `activity_mode`: guint)
-proc use_text_format*(a: PProgress): guint
-proc set_use_text_format*(a: PProgress, `use_text_format`: guint)
-const 
-  bm_TGtkProgressBar_activity_dir* = 0x0001'i16
-  bp_TGtkProgressBar_activity_dir* = 0'i16
-
-proc TYPE_PROGRESS_BAR*(): GType
-proc PROGRESS_BAR*(obj: pointer): PProgressBar
-proc PROGRESS_BAR_CLASS*(klass: pointer): PProgressBarClass
-proc IS_PROGRESS_BAR*(obj: pointer): bool
-proc IS_PROGRESS_BAR_CLASS*(klass: pointer): bool
-proc PROGRESS_BAR_GET_CLASS*(obj: pointer): PProgressBarClass
-proc activity_dir*(a: PProgressBar): guint
-proc set_activity_dir*(a: PProgressBar, `activity_dir`: guint)
-proc progress_bar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_progress_bar_get_type".}
-proc progress_bar_new*(): PProgressBar{.cdecl, dynlib: lib, 
-                                        importc: "gtk_progress_bar_new".}
-proc pulse*(pbar: PProgressBar){.cdecl, dynlib: lib, 
-    importc: "gtk_progress_bar_pulse".}
-proc set_text*(pbar: PProgressBar, text: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_set_text".}
-proc set_fraction*(pbar: PProgressBar, fraction: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_set_fraction".}
-proc set_pulse_step*(pbar: PProgressBar, fraction: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_set_pulse_step".}
-proc set_orientation*(pbar: PProgressBar, 
-                                   orientation: TProgressBarOrientation){.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_set_orientation".}
-proc get_text*(pbar: PProgressBar): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_progress_bar_get_text".}
-proc get_fraction*(pbar: PProgressBar): gdouble{.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_get_fraction".}
-proc get_pulse_step*(pbar: PProgressBar): gdouble{.cdecl, 
-    dynlib: lib, importc: "gtk_progress_bar_get_pulse_step".}
-proc get_orientation*(pbar: PProgressBar): TProgressBarOrientation{.
-    cdecl, dynlib: lib, importc: "gtk_progress_bar_get_orientation".}
-proc TYPE_RADIO_BUTTON*(): GType
-proc RADIO_BUTTON*(obj: pointer): PRadioButton
-proc RADIO_BUTTON_CLASS*(klass: pointer): PRadioButtonClass
-proc IS_RADIO_BUTTON*(obj: pointer): bool
-proc IS_RADIO_BUTTON_CLASS*(klass: pointer): bool
-proc RADIO_BUTTON_GET_CLASS*(obj: pointer): PRadioButtonClass
-proc radio_button_get_type*(): TType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_radio_button_get_type".}
-proc radio_button_new*(group: PGSList): PRadioButton{.cdecl, dynlib: lib, 
-    importc: "gtk_radio_button_new".}
-proc new_from_widget*(group: PRadioButton): PRadioButton{.cdecl, 
-    dynlib: lib, importc: "gtk_radio_button_new_from_widget".}
-proc radio_button_new*(group: PGSList, `label`: cstring): PRadioButton{.
-    cdecl, dynlib: lib, importc: "gtk_radio_button_new_with_label".}
-proc radio_button_new_with_label_from_widget*(group: PRadioButton, 
-    `label`: cstring): PRadioButton{.cdecl, dynlib: lib, importc: "gtk_radio_button_new_with_label_from_widget".}
-proc radio_button_new_with_mnemonic*(group: PGSList, `label`: cstring): PRadioButton{.
-    cdecl, dynlib: lib, importc: "gtk_radio_button_new_with_mnemonic".}
-proc radio_button_new_with_mnemonic_from_widget*(group: PRadioButton, 
-    `label`: cstring): PRadioButton{.cdecl, dynlib: lib, importc: "gtk_radio_button_new_with_mnemonic_from_widget".}
-proc get_group*(radio_button: PRadioButton): PGSList{.cdecl, 
-    dynlib: lib, importc: "gtk_radio_button_get_group".}
-proc set_group*(radio_button: PRadioButton, group: PGSList){.cdecl, 
-    dynlib: lib, importc: "gtk_radio_button_set_group".}
-proc TYPE_RADIO_MENU_ITEM*(): GType
-proc RADIO_MENU_ITEM*(obj: pointer): PRadioMenuItem
-proc RADIO_MENU_ITEM_CLASS*(klass: pointer): PRadioMenuItemClass
-proc IS_RADIO_MENU_ITEM*(obj: pointer): bool
-proc IS_RADIO_MENU_ITEM_CLASS*(klass: pointer): bool
-proc RADIO_MENU_ITEM_GET_CLASS*(obj: pointer): PRadioMenuItemClass
-proc radio_menu_item_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_radio_menu_item_get_type".}
-proc radio_menu_item_new*(group: PGSList): PRadioMenuItem{.cdecl, dynlib: lib, 
-    importc: "gtk_radio_menu_item_new".}
-proc radio_menu_item_new*(group: PGSList, `label`: cstring): PRadioMenuItem{.
-    cdecl, dynlib: lib, importc: "gtk_radio_menu_item_new_with_label".}
-proc radio_menu_item_new_with_mnemonic*(group: PGSList, `label`: cstring): PRadioMenuItem{.
-    cdecl, dynlib: lib, importc: "gtk_radio_menu_item_new_with_mnemonic".}
-proc item_get_group*(radio_menu_item: PRadioMenuItem): PGSList{.
-    cdecl, dynlib: lib, importc: "gtk_radio_menu_item_get_group".}
-proc item_set_group*(radio_menu_item: PRadioMenuItem, group: PGSList){.
-    cdecl, dynlib: lib, importc: "gtk_radio_menu_item_set_group".}
-const 
-  bm_TGtkScrolledWindow_hscrollbar_policy* = 0x0003'i16
-  bp_TGtkScrolledWindow_hscrollbar_policy* = 0'i16
-  bm_TGtkScrolledWindow_vscrollbar_policy* = 0x000C'i16
-  bp_TGtkScrolledWindow_vscrollbar_policy* = 2'i16
-  bm_TGtkScrolledWindow_hscrollbar_visible* = 0x0010'i16
-  bp_TGtkScrolledWindow_hscrollbar_visible* = 4'i16
-  bm_TGtkScrolledWindow_vscrollbar_visible* = 0x0020'i16
-  bp_TGtkScrolledWindow_vscrollbar_visible* = 5'i16
-  bm_TGtkScrolledWindow_window_placement* = 0x00C0'i16
-  bp_TGtkScrolledWindow_window_placement* = 6'i16
-  bm_TGtkScrolledWindow_focus_out* = 0x0100'i16
-  bp_TGtkScrolledWindow_focus_out* = 8'i16
-
-proc TYPE_SCROLLED_WINDOW*(): GType
-proc SCROLLED_WINDOW*(obj: pointer): PScrolledWindow
-proc SCROLLED_WINDOW_CLASS*(klass: pointer): PScrolledWindowClass
-proc IS_SCROLLED_WINDOW*(obj: pointer): bool
-proc IS_SCROLLED_WINDOW_CLASS*(klass: pointer): bool
-proc SCROLLED_WINDOW_GET_CLASS*(obj: pointer): PScrolledWindowClass
-proc hscrollbar_policy*(a: PScrolledWindow): guint
-proc set_hscrollbar_policy*(a: PScrolledWindow, `hscrollbar_policy`: guint)
-proc vscrollbar_policy*(a: PScrolledWindow): guint
-proc set_vscrollbar_policy*(a: PScrolledWindow, `vscrollbar_policy`: guint)
-proc hscrollbar_visible*(a: PScrolledWindow): guint
-proc set_hscrollbar_visible*(a: PScrolledWindow, `hscrollbar_visible`: guint)
-proc vscrollbar_visible*(a: PScrolledWindow): guint
-proc set_vscrollbar_visible*(a: PScrolledWindow, `vscrollbar_visible`: guint)
-proc window_placement*(a: PScrolledWindow): guint
-proc set_window_placement*(a: PScrolledWindow, `window_placement`: guint)
-proc focus_out*(a: PScrolledWindow): guint
-proc set_focus_out*(a: PScrolledWindow, `focus_out`: guint)
-proc scrolled_window_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_scrolled_window_get_type".}
-proc scrolled_window_new*(hadjustment: PAdjustment, vadjustment: PAdjustment): PScrolledWindow{.
-    cdecl, dynlib: lib, importc: "gtk_scrolled_window_new".}
-proc set_hadjustment*(scrolled_window: PScrolledWindow, 
-                                      hadjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_scrolled_window_set_hadjustment".}
-proc set_vadjustment*(scrolled_window: PScrolledWindow, 
-                                      hadjustment: PAdjustment){.cdecl, 
-    dynlib: lib, importc: "gtk_scrolled_window_set_vadjustment".}
-proc get_hadjustment*(scrolled_window: PScrolledWindow): PAdjustment{.
-    cdecl, dynlib: lib, importc: "gtk_scrolled_window_get_hadjustment".}
-proc get_vadjustment*(scrolled_window: PScrolledWindow): PAdjustment{.
-    cdecl, dynlib: lib, importc: "gtk_scrolled_window_get_vadjustment".}
-proc set_policy*(scrolled_window: PScrolledWindow, 
-                                 hscrollbar_policy: TPolicyType, 
-                                 vscrollbar_policy: TPolicyType){.cdecl, 
-    dynlib: lib, importc: "gtk_scrolled_window_set_policy".}
-proc get_policy*(scrolled_window: PScrolledWindow, 
-                                 hscrollbar_policy: PPolicyType, 
-                                 vscrollbar_policy: PPolicyType){.cdecl, 
-    dynlib: lib, importc: "gtk_scrolled_window_get_policy".}
-proc set_placement*(scrolled_window: PScrolledWindow, 
-                                    window_placement: TCornerType){.cdecl, 
-    dynlib: lib, importc: "gtk_scrolled_window_set_placement".}
-proc get_placement*(scrolled_window: PScrolledWindow): TCornerType{.
-    cdecl, dynlib: lib, importc: "gtk_scrolled_window_get_placement".}
-proc set_shadow_type*(scrolled_window: PScrolledWindow, 
-                                      thetype: TShadowType){.cdecl, dynlib: lib, 
-    importc: "gtk_scrolled_window_set_shadow_type".}
-proc get_shadow_type*(scrolled_window: PScrolledWindow): TShadowType{.
-    cdecl, dynlib: lib, importc: "gtk_scrolled_window_get_shadow_type".}
-proc add_with_viewport*(scrolled_window: PScrolledWindow, 
-                                        child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_scrolled_window_add_with_viewport".}
-proc TYPE_SELECTION_DATA*(): GType
-proc list_new*(targets: PTargetEntry, ntargets: guint): PTargetList{.
-    cdecl, dynlib: lib, importc: "gtk_target_list_new".}
-proc reference*(list: PTargetList){.cdecl, dynlib: lib, 
-    importc: "gtk_target_list_ref".}
-proc unref*(list: PTargetList){.cdecl, dynlib: lib, 
-    importc: "gtk_target_list_unref".}
-proc add*(list: PTargetList, target: gdk2.TAtom, flags: guint, 
-                      info: guint){.cdecl, dynlib: lib, 
-                                    importc: "gtk_target_list_add".}
-proc add_table*(list: PTargetList, targets: PTargetEntry, 
-                            ntargets: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_target_list_add_table".}
-proc remove*(list: PTargetList, target: gdk2.TAtom){.cdecl, 
-    dynlib: lib, importc: "gtk_target_list_remove".}
-proc find*(list: PTargetList, target: gdk2.TAtom, info: Pguint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_target_list_find".}
-proc selection_owner_set*(widget: PWidget, selection: gdk2.TAtom, time: guint32): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_owner_set".}
-proc selection_owner_set_for_display*(display: gdk2.PDisplay, widget: PWidget, 
-                                      selection: gdk2.TAtom, time: guint32): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_owner_set_for_display".}
-proc selection_add_target*(widget: PWidget, selection: gdk2.TAtom, 
-                           target: gdk2.TAtom, info: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_selection_add_target".}
-proc selection_add_targets*(widget: PWidget, selection: gdk2.TAtom, 
-                            targets: PTargetEntry, ntargets: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_selection_add_targets".}
-proc selection_clear_targets*(widget: PWidget, selection: gdk2.TAtom){.cdecl, 
-    dynlib: lib, importc: "gtk_selection_clear_targets".}
-proc selection_convert*(widget: PWidget, selection: gdk2.TAtom, target: gdk2.TAtom, 
-                        time: guint32): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_selection_convert".}
-proc set*(selection_data: PSelectionData, thetype: gdk2.TAtom, 
-                         format: gint, data: Pguchar, length: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_selection_data_set".}
-proc set_text*(selection_data: PSelectionData, str: cstring, 
-                              len: gint): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_selection_data_set_text".}
-proc get_text*(selection_data: PSelectionData): Pguchar{.cdecl, 
-    dynlib: lib, importc: "gtk_selection_data_get_text".}
-proc targets_include_text*(selection_data: PSelectionData): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_data_targets_include_text".}
-proc selection_remove_all*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_selection_remove_all".}
-proc selection_clear*(widget: PWidget, event: gdk2.PEventSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_clear".}
-proc selection_request*(widget: PWidget, event: gdk2.PEventSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_request".}
-proc selection_incr_event*(window: gdk2.PWindow, event: gdk2.PEventProperty): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_incr_event".}
-proc selection_notify*(widget: PWidget, event: gdk2.PEventSelection): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_notify".}
-proc selection_property_notify*(widget: PWidget, event: gdk2.PEventProperty): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_selection_property_notify".}
-proc selection_data_get_type*(): GType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_selection_data_get_type".}
-proc copy*(data: PSelectionData): PSelectionData{.cdecl, 
-    dynlib: lib, importc: "gtk_selection_data_copy".}
-proc free*(data: PSelectionData){.cdecl, dynlib: lib, 
-    importc: "gtk_selection_data_free".}
-proc TYPE_SEPARATOR_MENU_ITEM*(): GType
-proc SEPARATOR_MENU_ITEM*(obj: pointer): PSeparatorMenuItem
-proc SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): PSeparatorMenuItemClass
-proc IS_SEPARATOR_MENU_ITEM*(obj: pointer): bool
-proc IS_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): bool
-proc SEPARATOR_MENU_ITEM_GET_CLASS*(obj: pointer): PSeparatorMenuItemClass
-proc separator_menu_item_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "gtk_separator_menu_item_get_type".}
-proc separator_menu_item_new*(): PSeparatorMenuItem{.cdecl, dynlib: lib, 
-    importc: "gtk_separator_menu_item_new".}
-const 
-  bm_TGtkSizeGroup_have_width* = 0x0001'i16
-  bp_TGtkSizeGroup_have_width* = 0'i16
-  bm_TGtkSizeGroup_have_height* = 0x0002'i16
-  bp_TGtkSizeGroup_have_height* = 1'i16
-
-proc TYPE_SIZE_GROUP*(): GType
-proc SIZE_GROUP*(obj: pointer): PSizeGroup
-proc SIZE_GROUP_CLASS*(klass: pointer): PSizeGroupClass
-proc IS_SIZE_GROUP*(obj: pointer): bool
-proc IS_SIZE_GROUP_CLASS*(klass: pointer): bool
-proc SIZE_GROUP_GET_CLASS*(obj: pointer): PSizeGroupClass
-proc have_width*(a: PSizeGroup): guint
-proc set_have_width*(a: PSizeGroup, `have_width`: guint)
-proc have_height*(a: PSizeGroup): guint
-proc set_have_height*(a: PSizeGroup, `have_height`: guint)
-proc size_group_get_type*(): GType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_size_group_get_type".}
-proc size_group_new*(mode: TSizeGroupMode): PSizeGroup{.cdecl, dynlib: lib, 
-    importc: "gtk_size_group_new".}
-proc set_mode*(size_group: PSizeGroup, mode: TSizeGroupMode){.cdecl, 
-    dynlib: lib, importc: "gtk_size_group_set_mode".}
-proc get_mode*(size_group: PSizeGroup): TSizeGroupMode{.cdecl, 
-    dynlib: lib, importc: "gtk_size_group_get_mode".}
-proc add_widget*(size_group: PSizeGroup, widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_size_group_add_widget".}
-proc remove_widget*(size_group: PSizeGroup, widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_size_group_remove_widget".}
-proc size_group_get_child_requisition*(widget: PWidget, 
-                                       requisition: PRequisition){.cdecl, 
-    dynlib: lib, importc: "_gtk_size_group_get_child_requisition".}
-proc size_group_compute_requisition*(widget: PWidget, requisition: PRequisition){.
-    cdecl, dynlib: lib, importc: "_gtk_size_group_compute_requisition".}
-proc size_group_queue_resize*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "_gtk_size_group_queue_resize".}
-const 
-  bm_TGtkSocket_same_app* = 0x0001'i16
-  bp_TGtkSocket_same_app* = 0'i16
-  bm_TGtkSocket_focus_in* = 0x0002'i16
-  bp_TGtkSocket_focus_in* = 1'i16
-  bm_TGtkSocket_have_size* = 0x0004'i16
-  bp_TGtkSocket_have_size* = 2'i16
-  bm_TGtkSocket_need_map* = 0x0008'i16
-  bp_TGtkSocket_need_map* = 3'i16
-  bm_TGtkSocket_is_mapped* = 0x0010'i16
-  bp_TGtkSocket_is_mapped* = 4'i16
-
-proc TYPE_SOCKET*(): GType
-proc SOCKET*(obj: pointer): PSocket
-proc SOCKET_CLASS*(klass: pointer): PSocketClass
-proc IS_SOCKET*(obj: pointer): bool
-proc IS_SOCKET_CLASS*(klass: pointer): bool
-proc SOCKET_GET_CLASS*(obj: pointer): PSocketClass
-proc same_app*(a: PSocket): guint
-proc set_same_app*(a: PSocket, `same_app`: guint)
-proc focus_in*(a: PSocket): guint
-proc set_focus_in*(a: PSocket, `focus_in`: guint)
-proc have_size*(a: PSocket): guint
-proc set_have_size*(a: PSocket, `have_size`: guint)
-proc need_map*(a: PSocket): guint
-proc set_need_map*(a: PSocket, `need_map`: guint)
-proc is_mapped*(a: PSocket): guint
-proc set_is_mapped*(a: PSocket, `is_mapped`: guint)
-proc socket_new*(): PSocket{.cdecl, dynlib: lib, importc: "gtk_socket_new".}
-proc socket_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_socket_get_type".}
-proc add_id*(socket: PSocket, window_id: gdk2.TNativeWindow){.cdecl, 
-    dynlib: lib, importc: "gtk_socket_add_id".}
-proc get_id*(socket: PSocket): gdk2.TNativeWindow{.cdecl, dynlib: lib, 
-    importc: "gtk_socket_get_id".}
-const 
-  INPUT_ERROR* = - (1)
-  bm_TGtkSpinButton_in_child* = 0x00000003'i32
-  bp_TGtkSpinButton_in_child* = 0'i32
-  bm_TGtkSpinButton_click_child* = 0x0000000C'i32
-  bp_TGtkSpinButton_click_child* = 2'i32
-  bm_TGtkSpinButton_button* = 0x00000030'i32
-  bp_TGtkSpinButton_button* = 4'i32
-  bm_TGtkSpinButton_need_timer* = 0x00000040'i32
-  bp_TGtkSpinButton_need_timer* = 6'i32
-  bm_TGtkSpinButton_timer_calls* = 0x00000380'i32
-  bp_TGtkSpinButton_timer_calls* = 7'i32
-  bm_TGtkSpinButton_digits* = 0x000FFC00'i32
-  bp_TGtkSpinButton_digits* = 10'i32
-  bm_TGtkSpinButton_numeric* = 0x00100000'i32
-  bp_TGtkSpinButton_numeric* = 20'i32
-  bm_TGtkSpinButton_wrap* = 0x00200000'i32
-  bp_TGtkSpinButton_wrap* = 21'i32
-  bm_TGtkSpinButton_snap_to_ticks* = 0x00400000'i32
-  bp_TGtkSpinButton_snap_to_ticks* = 22'i32
-
-proc TYPE_SPIN_BUTTON*(): GType
-proc SPIN_BUTTON*(obj: pointer): PSpinButton
-proc SPIN_BUTTON_CLASS*(klass: pointer): PSpinButtonClass
-proc IS_SPIN_BUTTON*(obj: pointer): bool
-proc IS_SPIN_BUTTON_CLASS*(klass: pointer): bool
-proc SPIN_BUTTON_GET_CLASS*(obj: pointer): PSpinButtonClass
-proc in_child*(a: PSpinButton): guint
-proc set_in_child*(a: PSpinButton, `in_child`: guint)
-proc click_child*(a: PSpinButton): guint
-proc set_click_child*(a: PSpinButton, `click_child`: guint)
-proc button*(a: PSpinButton): guint
-proc set_button*(a: PSpinButton, `button`: guint)
-proc need_timer*(a: PSpinButton): guint
-proc set_need_timer*(a: PSpinButton, `need_timer`: guint)
-proc timer_calls*(a: PSpinButton): guint
-proc set_timer_calls*(a: PSpinButton, `timer_calls`: guint)
-proc digits*(a: PSpinButton): guint
-proc set_digits*(a: PSpinButton, `digits`: guint)
-proc numeric*(a: PSpinButton): guint
-proc set_numeric*(a: PSpinButton, `numeric`: guint)
-proc wrap*(a: PSpinButton): guint
-proc set_wrap*(a: PSpinButton, `wrap`: guint)
-proc snap_to_ticks*(a: PSpinButton): guint
-proc set_snap_to_ticks*(a: PSpinButton, `snap_to_ticks`: guint)
-proc spin_button_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_spin_button_get_type".}
-proc configure*(spin_button: PSpinButton, adjustment: PAdjustment, 
-                            climb_rate: gdouble, digits: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_configure".}
-proc spin_button_new*(adjustment: PAdjustment, climb_rate: gdouble, 
-                      digits: guint): PSpinButton{.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_new".}
-proc spin_button_new*(min: gdouble, max: gdouble, step: gdouble): PSpinButton{.
-    cdecl, dynlib: lib, importc: "gtk_spin_button_new_with_range".}
-proc set_adjustment*(spin_button: PSpinButton, 
-                                 adjustment: PAdjustment){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_set_adjustment".}
-proc get_adjustment*(spin_button: PSpinButton): PAdjustment{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_adjustment".}
-proc set_digits*(spin_button: PSpinButton, digits: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_set_digits".}
-proc get_digits*(spin_button: PSpinButton): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_digits".}
-proc set_increments*(spin_button: PSpinButton, step: gdouble, 
-                                 page: gdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_set_increments".}
-proc get_increments*(spin_button: PSpinButton, step: Pgdouble, 
-                                 page: Pgdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_get_increments".}
-proc set_range*(spin_button: PSpinButton, min: gdouble, max: gdouble){.
-    cdecl, dynlib: lib, importc: "gtk_spin_button_set_range".}
-proc get_range*(spin_button: PSpinButton, min: Pgdouble, 
-                            max: Pgdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_get_range".}
-proc get_value*(spin_button: PSpinButton): gdouble{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_value".}
-proc get_value_as_int*(spin_button: PSpinButton): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_value_as_int".}
-proc set_value*(spin_button: PSpinButton, value: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_set_value".}
-proc set_update_policy*(spin_button: PSpinButton, 
-                                    policy: TSpinButtonUpdatePolicy){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_set_update_policy".}
-proc get_update_policy*(spin_button: PSpinButton): TSpinButtonUpdatePolicy{.
-    cdecl, dynlib: lib, importc: "gtk_spin_button_get_update_policy".}
-proc set_numeric*(spin_button: PSpinButton, numeric: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_spin_button_set_numeric".}
-proc get_numeric*(spin_button: PSpinButton): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_numeric".}
-proc spin*(spin_button: PSpinButton, direction: TSpinType, 
-                       increment: gdouble){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_spin".}
-proc set_wrap*(spin_button: PSpinButton, wrap: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_set_wrap".}
-proc get_wrap*(spin_button: PSpinButton): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_wrap".}
-proc set_snap_to_ticks*(spin_button: PSpinButton, 
-                                    snap_to_ticks: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_set_snap_to_ticks".}
-proc get_snap_to_ticks*(spin_button: PSpinButton): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_spin_button_get_snap_to_ticks".}
-proc update*(spin_button: PSpinButton){.cdecl, dynlib: lib, 
-    importc: "gtk_spin_button_update".}
-const 
-  STOCK_DIALOG_INFO* = "gtk-dialog-info"
-  STOCK_DIALOG_WARNING* = "gtk-dialog-warning"
-  STOCK_DIALOG_ERROR* = "gtk-dialog-error"
-  STOCK_DIALOG_QUESTION* = "gtk-dialog-question"
-  STOCK_DND* = "gtk-dnd"
-  STOCK_DND_MULTIPLE* = "gtk-dnd-multiple"
-  STOCK_ABOUT* = "gtk-about"
-  STOCK_ADD_name* = "gtk-add"
-  STOCK_APPLY* = "gtk-apply"
-  STOCK_BOLD* = "gtk-bold"
-  STOCK_CANCEL* = "gtk-cancel"
-  STOCK_CDROM* = "gtk-cdrom"
-  STOCK_CLEAR* = "gtk-clear"
-  STOCK_CLOSE* = "gtk-close"
-  STOCK_COLOR_PICKER* = "gtk-color-picker"
-  STOCK_CONVERT* = "gtk-convert"
-  STOCK_CONNECT* = "gtk-connect"
-  STOCK_COPY* = "gtk-copy"
-  STOCK_CUT* = "gtk-cut"
-  STOCK_DELETE* = "gtk-delete"
-  STOCK_EDIT* = "gtk-edit"
-  STOCK_EXECUTE* = "gtk-execute"
-  STOCK_FIND* = "gtk-find"
-  STOCK_FIND_AND_REPLACE* = "gtk-find-and-replace"
-  STOCK_FLOPPY* = "gtk-floppy"
-  STOCK_GOTO_BOTTOM* = "gtk-goto-bottom"
-  STOCK_GOTO_FIRST* = "gtk-goto-first"
-  STOCK_GOTO_LAST* = "gtk-goto-last"
-  STOCK_GOTO_TOP* = "gtk-goto-top"
-  STOCK_GO_BACK* = "gtk-go-back"
-  STOCK_GO_DOWN* = "gtk-go-down"
-  STOCK_GO_FORWARD* = "gtk-go-forward"
-  STOCK_GO_UP* = "gtk-go-up"
-  STOCK_HELP* = "gtk-help"
-  STOCK_HOME* = "gtk-home"
-  STOCK_INDEX* = "gtk-index"
-  STOCK_ITALIC* = "gtk-italic"
-  STOCK_JUMP_TO* = "gtk-jump-to"
-  STOCK_JUSTIFY_CENTER* = "gtk-justify-center"
-  STOCK_JUSTIFY_FILL* = "gtk-justify-fill"
-  STOCK_JUSTIFY_LEFT* = "gtk-justify-left"
-  STOCK_JUSTIFY_RIGHT* = "gtk-justify-right"
-  STOCK_MEDIA_FORWARD* = "gtk-media-forward"
-  STOCK_MEDIA_NEXT* = "gtk-media-next"
-  STOCK_MEDIA_PAUSE* = "gtk-media-pause"
-  STOCK_MEDIA_PLAY* = "gtk-media-play"
-  STOCK_MEDIA_PREVIOUS* = "gtk-media-previous"
-  STOCK_MEDIA_RECORD* = "gtk-media-record"
-  STOCK_MEDIA_REWIND* = "gtk-media-rewind"
-  STOCK_MEDIA_STOP* = "gtk-media-stop"
-  STOCK_MISSING_IMAGE* = "gtk-missing-image"
-  STOCK_NEW* = "gtk-new"
-  STOCK_NO* = "gtk-no"
-  STOCK_OK* = "gtk-ok"
-  STOCK_OPEN* = "gtk-open"
-  STOCK_PASTE* = "gtk-paste"
-  STOCK_PREFERENCES* = "gtk-preferences"
-  STOCK_PRINT* = "gtk-print"
-  STOCK_PRINT_PREVIEW* = "gtk-print-preview"
-  STOCK_PROPERTIES* = "gtk-properties"
-  STOCK_QUIT* = "gtk-quit"
-  STOCK_REDO* = "gtk-redo"
-  STOCK_REFRESH* = "gtk-refresh"
-  STOCK_REMOVE* = "gtk-remove"
-  STOCK_REVERT_TO_SAVED* = "gtk-revert-to-saved"
-  STOCK_SAVE* = "gtk-save"
-  STOCK_SAVE_AS* = "gtk-save-as"
-  STOCK_SELECT_COLOR* = "gtk-select-color"
-  STOCK_SELECT_FONT* = "gtk-select-font"
-  STOCK_SORT_ASCENDING* = "gtk-sort-ascending"
-  STOCK_SORT_DESCENDING* = "gtk-sort-descending"
-  STOCK_SPELL_CHECK* = "gtk-spell-check"
-  STOCK_STOP* = "gtk-stop"
-  STOCK_STRIKETHROUGH* = "gtk-strikethrough"
-  STOCK_UNDELETE* = "gtk-undelete"
-  STOCK_UNDERLINE* = "gtk-underline"
-  STOCK_UNDO* = "gtk-undo"
-  STOCK_YES* = "gtk-yes"
-  STOCK_ZOOM_100* = "gtk-zoom-100"
-  STOCK_ZOOM_FIT* = "gtk-zoom-fit"
-  STOCK_ZOOM_IN* = "gtk-zoom-in"
-  STOCK_ZOOM_OUT* = "gtk-zoom-out"
-
-proc add*(items: PStockItem, n_items: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_stock_add".}
-proc add_static*(items: PStockItem, n_items: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_stock_add_static".}
-proc stock_lookup*(stock_id: cstring, item: PStockItem): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_stock_lookup".}
-proc stock_list_ids*(): PGSList{.cdecl, dynlib: lib, 
-                                 importc: "gtk_stock_list_ids".}
-proc copy*(item: PStockItem): PStockItem{.cdecl, dynlib: lib, 
-    importc: "gtk_stock_item_copy".}
-proc free*(item: PStockItem){.cdecl, dynlib: lib, 
-    importc: "gtk_stock_item_free".}
-proc TYPE_STATUSBAR*(): GType
-proc STATUSBAR*(obj: pointer): PStatusbar
-proc STATUSBAR_CLASS*(klass: pointer): PStatusbarClass
-proc IS_STATUSBAR*(obj: pointer): bool
-proc IS_STATUSBAR_CLASS*(klass: pointer): bool
-proc STATUSBAR_GET_CLASS*(obj: pointer): PStatusbarClass
-const 
-  bm_TGtkStatusbar_has_resize_grip* = 0x0001'i16
-  bp_TGtkStatusbar_has_resize_grip* = 0'i16
-
-proc has_resize_grip*(a: PStatusbar): guint
-proc set_has_resize_grip*(a: PStatusbar, `has_resize_grip`: guint)
-proc statusbar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_statusbar_get_type".}
-proc statusbar_new*(): PStatusbar{.cdecl, dynlib: lib, 
-                                   importc: "gtk_statusbar_new".}
-proc get_context_id*(statusbar: PStatusbar, 
-                               context_description: cstring): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_statusbar_get_context_id".}
-proc push*(statusbar: PStatusbar, context_id: guint, text: cstring): guint{.
-    cdecl, dynlib: lib, importc: "gtk_statusbar_push".}
-proc pop*(statusbar: PStatusbar, context_id: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_statusbar_pop".}
-proc remove*(statusbar: PStatusbar, context_id: guint, 
-                       message_id: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_statusbar_remove".}
-proc set_has_resize_grip*(statusbar: PStatusbar, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_statusbar_set_has_resize_grip".}
-proc get_has_resize_grip*(statusbar: PStatusbar): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_statusbar_get_has_resize_grip".}
-const 
-  bm_TGtkTable_homogeneous* = 0x0001'i16
-  bp_TGtkTable_homogeneous* = 0'i16
-  bm_TGtkTableChild_xexpand* = 0x0001'i16
-  bp_TGtkTableChild_xexpand* = 0'i16
-  bm_TGtkTableChild_yexpand* = 0x0002'i16
-  bp_TGtkTableChild_yexpand* = 1'i16
-  bm_TGtkTableChild_xshrink* = 0x0004'i16
-  bp_TGtkTableChild_xshrink* = 2'i16
-  bm_TGtkTableChild_yshrink* = 0x0008'i16
-  bp_TGtkTableChild_yshrink* = 3'i16
-  bm_TGtkTableChild_xfill* = 0x0010'i16
-  bp_TGtkTableChild_xfill* = 4'i16
-  bm_TGtkTableChild_yfill* = 0x0020'i16
-  bp_TGtkTableChild_yfill* = 5'i16
-  bm_TGtkTableRowCol_need_expand* = 0x0001'i16
-  bp_TGtkTableRowCol_need_expand* = 0'i16
-  bm_TGtkTableRowCol_need_shrink* = 0x0002'i16
-  bp_TGtkTableRowCol_need_shrink* = 1'i16
-  bm_TGtkTableRowCol_expand* = 0x0004'i16
-  bp_TGtkTableRowCol_expand* = 2'i16
-  bm_TGtkTableRowCol_shrink* = 0x0008'i16
-  bp_TGtkTableRowCol_shrink* = 3'i16
-  bm_TGtkTableRowCol_empty* = 0x0010'i16
-  bp_TGtkTableRowCol_empty* = 4'i16
-
-proc TYPE_TABLE*(): GType
-proc TABLE*(obj: pointer): PTable
-proc TABLE_CLASS*(klass: pointer): PTableClass
-proc IS_TABLE*(obj: pointer): bool
-proc IS_TABLE_CLASS*(klass: pointer): bool
-proc TABLE_GET_CLASS*(obj: pointer): PTableClass
-proc homogeneous*(a: PTable): guint
-proc set_homogeneous*(a: PTable, `homogeneous`: guint)
-proc xexpand*(a: PTableChild): guint
-proc set_xexpand*(a: PTableChild, `xexpand`: guint)
-proc yexpand*(a: PTableChild): guint
-proc set_yexpand*(a: PTableChild, `yexpand`: guint)
-proc xshrink*(a: PTableChild): guint
-proc set_xshrink*(a: PTableChild, `xshrink`: guint)
-proc yshrink*(a: PTableChild): guint
-proc set_yshrink*(a: PTableChild, `yshrink`: guint)
-proc xfill*(a: PTableChild): guint
-proc set_xfill*(a: PTableChild, `xfill`: guint)
-proc yfill*(a: PTableChild): guint
-proc set_yfill*(a: PTableChild, `yfill`: guint)
-proc need_expand*(a: PTableRowCol): guint
-proc set_need_expand*(a: PTableRowCol, `need_expand`: guint)
-proc need_shrink*(a: PTableRowCol): guint
-proc set_need_shrink*(a: PTableRowCol, `need_shrink`: guint)
-proc expand*(a: PTableRowCol): guint
-proc set_expand*(a: PTableRowCol, `expand`: guint)
-proc shrink*(a: PTableRowCol): guint
-proc set_shrink*(a: PTableRowCol, `shrink`: guint)
-proc empty*(a: PTableRowCol): guint
-proc set_empty*(a: PTableRowCol, `empty`: guint)
-proc table_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_table_get_type".}
-proc table_new*(rows: guint, columns: guint, homogeneous: gboolean): PTable{.
-    cdecl, dynlib: lib, importc: "gtk_table_new".}
-proc resize*(table: PTable, rows: guint, columns: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_table_resize".}
-proc attach*(table: PTable, child: PWidget, left_attach: guint, 
-                   right_attach: guint, top_attach: guint, bottom_attach: guint, 
-                   xoptions: TAttachOptions, yoptions: TAttachOptions, 
-                   xpadding: guint, ypadding: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_table_attach".}
-proc attach_defaults*(table: PTable, widget: PWidget, left_attach: guint, 
-                            right_attach: guint, top_attach: guint, 
-                            bottom_attach: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_table_attach_defaults".}
-proc set_row_spacing*(table: PTable, row: guint, spacing: guint){.cdecl, 
-    dynlib: lib, importc: "gtk_table_set_row_spacing".}
-proc get_row_spacing*(table: PTable, row: guint): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_table_get_row_spacing".}
-proc set_col_spacing*(table: PTable, column: guint, spacing: guint){.
-    cdecl, dynlib: lib, importc: "gtk_table_set_col_spacing".}
-proc get_col_spacing*(table: PTable, column: guint): guint{.cdecl, 
-    dynlib: lib, importc: "gtk_table_get_col_spacing".}
-proc set_row_spacings*(table: PTable, spacing: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_table_set_row_spacings".}
-proc get_default_row_spacing*(table: PTable): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_table_get_default_row_spacing".}
-proc set_col_spacings*(table: PTable, spacing: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_table_set_col_spacings".}
-proc get_default_col_spacing*(table: PTable): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_table_get_default_col_spacing".}
-proc set_homogeneous*(table: PTable, homogeneous: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_table_set_homogeneous".}
-proc get_homogeneous*(table: PTable): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_table_get_homogeneous".}
-const 
-  bm_TGtkTearoffMenuItem_torn_off* = 0x0001'i16
-  bp_TGtkTearoffMenuItem_torn_off* = 0'i16
-
-proc TYPE_TEAROFF_MENU_ITEM*(): GType
-proc TEAROFF_MENU_ITEM*(obj: pointer): PTearoffMenuItem
-proc TEAROFF_MENU_ITEM_CLASS*(klass: pointer): PTearoffMenuItemClass
-proc IS_TEAROFF_MENU_ITEM*(obj: pointer): bool
-proc IS_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): bool
-proc TEAROFF_MENU_ITEM_GET_CLASS*(obj: pointer): PTearoffMenuItemClass
-proc torn_off*(a: PTearoffMenuItem): guint
-proc set_torn_off*(a: PTearoffMenuItem, `torn_off`: guint)
-proc tearoff_menu_item_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_tearoff_menu_item_get_type".}
-proc tearoff_menu_item_new*(): PTearoffMenuItem{.cdecl, dynlib: lib, 
-    importc: "gtk_tearoff_menu_item_new".}
-const 
-  bm_TGtkText_line_wrap* = 0x0001'i16
-  bp_TGtkText_line_wrap* = 0'i16
-  bm_TGtkText_word_wrap* = 0x0002'i16
-  bp_TGtkText_word_wrap* = 1'i16
-  bm_TGtkText_use_wchar* = 0x0004'i16
-  bp_TGtkText_use_wchar* = 2'i16
-
-proc TYPE_TEXT*(): GType
-proc TEXT*(obj: pointer): PText
-proc TEXT_CLASS*(klass: pointer): PTextClass
-proc IS_TEXT*(obj: pointer): bool
-proc IS_TEXT_CLASS*(klass: pointer): bool
-proc TEXT_GET_CLASS*(obj: pointer): PTextClass
-proc line_wrap*(a: PText): guint
-proc set_line_wrap*(a: PText, `line_wrap`: guint)
-proc word_wrap*(a: PText): guint
-proc set_word_wrap*(a: PText, `word_wrap`: guint)
-proc use_wchar*(a: PText): gboolean
-proc set_use_wchar*(a: PText, `use_wchar`: gboolean)
-proc text_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_text_get_type".}
-proc text_new*(hadj: PAdjustment, vadj: PAdjustment): PText{.cdecl, dynlib: lib, 
-    importc: "gtk_text_new".}
-proc set_editable*(text: PText, editable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_text_set_editable".}
-proc set_word_wrap*(text: PText, word_wrap: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_text_set_word_wrap".}
-proc set_line_wrap*(text: PText, line_wrap: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_text_set_line_wrap".}
-proc set_adjustments*(text: PText, hadj: PAdjustment, vadj: PAdjustment){.
-    cdecl, dynlib: lib, importc: "gtk_text_set_adjustments".}
-proc set_point*(text: PText, index: guint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_set_point".}
-proc get_point*(text: PText): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_get_point".}
-proc get_length*(text: PText): guint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_get_length".}
-proc freeze*(text: PText){.cdecl, dynlib: lib, importc: "gtk_text_freeze".}
-proc thaw*(text: PText){.cdecl, dynlib: lib, importc: "gtk_text_thaw".}
-proc insert*(text: PText, font: gdk2.PFont, fore: gdk2.PColor, back: gdk2.PColor, 
-                  chars: cstring, length: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_insert".}
-proc backward_delete*(text: PText, nchars: guint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_backward_delete".}
-proc forward_delete*(text: PText, nchars: guint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_forward_delete".}
-proc INDEX_WCHAR*(t: PText, index: guint): guint32
-proc INDEX_UCHAR*(t: PText, index: guint): GUChar
-const 
-  TEXT_SEARCH_VISIBLE_ONLY* = 0
-  TEXT_SEARCH_TEXT_ONLY* = 1
-
-proc TYPE_TEXT_ITER*(): GType
-proc get_buffer*(iter: PTextIter): PTextBuffer{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_buffer".}
-proc copy*(iter: PTextIter): PTextIter{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_copy".}
-proc free*(iter: PTextIter){.cdecl, dynlib: lib, 
-                                       importc: "gtk_text_iter_free".}
-proc text_iter_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_text_iter_get_type".}
-proc get_offset*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_offset".}
-proc get_line*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_line".}
-proc get_line_offset*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_line_offset".}
-proc get_line_index*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_line_index".}
-proc get_visible_line_offset*(iter: PTextIter): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_visible_line_offset".}
-proc get_visible_line_index*(iter: PTextIter): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_visible_line_index".}
-proc get_char*(iter: PTextIter): gunichar{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_char".}
-proc get_slice*(start: PTextIter, theEnd: PTextIter): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_slice".}
-proc get_text*(start: PTextIter, theEnd: PTextIter): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_text".}
-proc get_visible_slice*(start: PTextIter, theEnd: PTextIter): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_get_visible_slice".}
-proc get_visible_text*(start: PTextIter, theEnd: PTextIter): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_get_visible_text".}
-proc get_pixbuf*(iter: PTextIter): gdk2pixbuf.PPixbuf{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_pixbuf".}
-proc get_marks*(iter: PTextIter): PGSList{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_marks".}
-proc get_child_anchor*(iter: PTextIter): PTextChildAnchor{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_child_anchor".}
-proc get_toggled_tags*(iter: PTextIter, toggled_on: gboolean): PGSList{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_get_toggled_tags".}
-proc begins_tag*(iter: PTextIter, tag: PTextTag): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_begins_tag".}
-proc ends_tag*(iter: PTextIter, tag: PTextTag): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_ends_tag".}
-proc toggles_tag*(iter: PTextIter, tag: PTextTag): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_toggles_tag".}
-proc has_tag*(iter: PTextIter, tag: PTextTag): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_has_tag".}
-proc get_tags*(iter: PTextIter): PGSList{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_tags".}
-proc editable*(iter: PTextIter, default_setting: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_editable".}
-proc can_insert*(iter: PTextIter, default_editability: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_can_insert".}
-proc starts_word*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_starts_word".}
-proc ends_word*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_ends_word".}
-proc inside_word*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_inside_word".}
-proc starts_sentence*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_starts_sentence".}
-proc ends_sentence*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_ends_sentence".}
-proc inside_sentence*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_inside_sentence".}
-proc starts_line*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_starts_line".}
-proc ends_line*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_ends_line".}
-proc is_cursor_position*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_is_cursor_position".}
-proc get_chars_in_line*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_chars_in_line".}
-proc get_bytes_in_line*(iter: PTextIter): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_get_bytes_in_line".}
-proc get_attributes*(iter: PTextIter, values: PTextAttributes): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_get_attributes".}
-proc get_language*(iter: PTextIter): pango.PLanguage{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_get_language".}
-proc is_end*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_is_end".}
-proc is_start*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_is_start".}
-proc forward_char*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_forward_char".}
-proc backward_char*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_backward_char".}
-proc forward_chars*(iter: PTextIter, count: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_forward_chars".}
-proc backward_chars*(iter: PTextIter, count: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_backward_chars".}
-proc forward_line*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_forward_line".}
-proc backward_line*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_backward_line".}
-proc forward_lines*(iter: PTextIter, count: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_forward_lines".}
-proc backward_lines*(iter: PTextIter, count: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_backward_lines".}
-proc forward_word_end*(iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_forward_word_end".}
-proc backward_word_start*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_backward_word_start".}
-proc forward_word_ends*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_word_ends".}
-proc backward_word_starts*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_word_starts".}
-proc forward_sentence_end*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_forward_sentence_end".}
-proc backward_sentence_start*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_backward_sentence_start".}
-proc forward_sentence_ends*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_sentence_ends".}
-proc backward_sentence_starts*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_sentence_starts".}
-proc forward_cursor_position*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_forward_cursor_position".}
-proc backward_cursor_position*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_backward_cursor_position".}
-proc forward_cursor_positions*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_cursor_positions".}
-proc backward_cursor_positions*(iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_cursor_positions".}
-proc set_offset*(iter: PTextIter, char_offset: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_set_offset".}
-proc set_line*(iter: PTextIter, line_number: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_set_line".}
-proc set_line_offset*(iter: PTextIter, char_on_line: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_set_line_offset".}
-proc set_line_index*(iter: PTextIter, byte_on_line: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_set_line_index".}
-proc forward_to_end*(iter: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_forward_to_end".}
-proc forward_to_line_end*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_forward_to_line_end".}
-proc set_visible_line_offset*(iter: PTextIter, char_on_line: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_set_visible_line_offset".}
-proc set_visible_line_index*(iter: PTextIter, byte_on_line: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_set_visible_line_index".}
-proc forward_to_tag_toggle*(iter: PTextIter, tag: PTextTag): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_to_tag_toggle".}
-proc backward_to_tag_toggle*(iter: PTextIter, tag: PTextTag): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_to_tag_toggle".}
-proc forward_find_char*(iter: PTextIter, pred: TTextCharPredicate, 
-                                  user_data: gpointer, limit: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_find_char".}
-proc backward_find_char*(iter: PTextIter, pred: TTextCharPredicate, 
-                                   user_data: gpointer, limit: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_find_char".}
-proc forward_search*(iter: PTextIter, str: cstring, 
-                               flags: TTextSearchFlags, match_start: PTextIter, 
-                               match_end: PTextIter, limit: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_forward_search".}
-proc backward_search*(iter: PTextIter, str: cstring, 
-                                flags: TTextSearchFlags, match_start: PTextIter, 
-                                match_end: PTextIter, limit: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_backward_search".}
-proc equal*(lhs: PTextIter, rhs: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_equal".}
-proc compare*(lhs: PTextIter, rhs: PTextIter): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_iter_compare".}
-proc in_range*(iter: PTextIter, start: PTextIter, theEnd: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_iter_in_range".}
-proc order*(first: PTextIter, second: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_iter_order".}
-proc TYPE_TEXT_TAG*(): GType
-proc TEXT_TAG*(obj: pointer): PTextTag
-proc TEXT_TAG_CLASS*(klass: pointer): PTextTagClass
-proc IS_TEXT_TAG*(obj: pointer): bool
-proc IS_TEXT_TAG_CLASS*(klass: pointer): bool
-proc TEXT_TAG_GET_CLASS*(obj: pointer): PTextTagClass
-proc TYPE_TEXT_ATTRIBUTES*(): GType
-proc text_tag_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_text_tag_get_type".}
-proc text_tag_new*(name: cstring): PTextTag{.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_new".}
-proc get_priority*(tag: PTextTag): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_get_priority".}
-proc set_priority*(tag: PTextTag, priority: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_set_priority".}
-proc event*(tag: PTextTag, event_object: PGObject, event: gdk2.PEvent, 
-                     iter: PTextIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_event".}
-proc text_attributes_new*(): PTextAttributes{.cdecl, dynlib: lib, 
-    importc: "gtk_text_attributes_new".}
-proc copy*(src: PTextAttributes): PTextAttributes{.cdecl, 
-    dynlib: lib, importc: "gtk_text_attributes_copy".}
-proc copy_values*(src: PTextAttributes, dest: PTextAttributes){.
-    cdecl, dynlib: lib, importc: "gtk_text_attributes_copy_values".}
-proc unref*(values: PTextAttributes){.cdecl, dynlib: lib, 
-    importc: "gtk_text_attributes_unref".}
-proc reference*(values: PTextAttributes){.cdecl, dynlib: lib, 
-    importc: "gtk_text_attributes_ref".}
-proc text_attributes_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "gtk_text_attributes_get_type".}
-const 
-  bm_TGtkTextTag_bg_color_set* = 0x00000001'i32
-  bp_TGtkTextTag_bg_color_set* = 0'i32
-  bm_TGtkTextTag_bg_stipple_set* = 0x00000002'i32
-  bp_TGtkTextTag_bg_stipple_set* = 1'i32
-  bm_TGtkTextTag_fg_color_set* = 0x00000004'i32
-  bp_TGtkTextTag_fg_color_set* = 2'i32
-  bm_TGtkTextTag_scale_set* = 0x00000008'i32
-  bp_TGtkTextTag_scale_set* = 3'i32
-  bm_TGtkTextTag_fg_stipple_set* = 0x00000010'i32
-  bp_TGtkTextTag_fg_stipple_set* = 4'i32
-  bm_TGtkTextTag_justification_set* = 0x00000020'i32
-  bp_TGtkTextTag_justification_set* = 5'i32
-  bm_TGtkTextTag_left_margin_set* = 0x00000040'i32
-  bp_TGtkTextTag_left_margin_set* = 6'i32
-  bm_TGtkTextTag_indent_set* = 0x00000080'i32
-  bp_TGtkTextTag_indent_set* = 7'i32
-  bm_TGtkTextTag_rise_set* = 0x00000100'i32
-  bp_TGtkTextTag_rise_set* = 8'i32
-  bm_TGtkTextTag_strikethrough_set* = 0x00000200'i32
-  bp_TGtkTextTag_strikethrough_set* = 9'i32
-  bm_TGtkTextTag_right_margin_set* = 0x00000400'i32
-  bp_TGtkTextTag_right_margin_set* = 10'i32
-  bm_TGtkTextTag_pixels_above_lines_set* = 0x00000800'i32
-  bp_TGtkTextTag_pixels_above_lines_set* = 11'i32
-  bm_TGtkTextTag_pixels_below_lines_set* = 0x00001000'i32
-  bp_TGtkTextTag_pixels_below_lines_set* = 12'i32
-  bm_TGtkTextTag_pixels_inside_wrap_set* = 0x00002000'i32
-  bp_TGtkTextTag_pixels_inside_wrap_set* = 13'i32
-  bm_TGtkTextTag_tabs_set* = 0x00004000'i32
-  bp_TGtkTextTag_tabs_set* = 14'i32
-  bm_TGtkTextTag_underline_set* = 0x00008000'i32
-  bp_TGtkTextTag_underline_set* = 15'i32
-  bm_TGtkTextTag_wrap_mode_set* = 0x00010000'i32
-  bp_TGtkTextTag_wrap_mode_set* = 16'i32
-  bm_TGtkTextTag_bg_full_height_set* = 0x00020000'i32
-  bp_TGtkTextTag_bg_full_height_set* = 17'i32
-  bm_TGtkTextTag_invisible_set* = 0x00040000'i32
-  bp_TGtkTextTag_invisible_set* = 18'i32
-  bm_TGtkTextTag_editable_set* = 0x00080000'i32
-  bp_TGtkTextTag_editable_set* = 19'i32
-  bm_TGtkTextTag_language_set* = 0x00100000'i32
-  bp_TGtkTextTag_language_set* = 20'i32
-  bm_TGtkTextTag_pad1* = 0x00200000'i32
-  bp_TGtkTextTag_pad1* = 21'i32
-  bm_TGtkTextTag_pad2* = 0x00400000'i32
-  bp_TGtkTextTag_pad2* = 22'i32
-  bm_TGtkTextTag_pad3* = 0x00800000'i32
-  bp_TGtkTextTag_pad3* = 23'i32
-
-proc bg_color_set*(a: PTextTag): guint
-proc set_bg_color_set*(a: PTextTag, `bg_color_set`: guint)
-proc bg_stipple_set*(a: PTextTag): guint
-proc set_bg_stipple_set*(a: PTextTag, `bg_stipple_set`: guint)
-proc fg_color_set*(a: PTextTag): guint
-proc set_fg_color_set*(a: PTextTag, `fg_color_set`: guint)
-proc scale_set*(a: PTextTag): guint
-proc set_scale_set*(a: PTextTag, `scale_set`: guint)
-proc fg_stipple_set*(a: PTextTag): guint
-proc set_fg_stipple_set*(a: PTextTag, `fg_stipple_set`: guint)
-proc justification_set*(a: PTextTag): guint
-proc set_justification_set*(a: PTextTag, `justification_set`: guint)
-proc left_margin_set*(a: PTextTag): guint
-proc set_left_margin_set*(a: PTextTag, `left_margin_set`: guint)
-proc indent_set*(a: PTextTag): guint
-proc set_indent_set*(a: PTextTag, `indent_set`: guint)
-proc rise_set*(a: PTextTag): guint
-proc set_rise_set*(a: PTextTag, `rise_set`: guint)
-proc strikethrough_set*(a: PTextTag): guint
-proc set_strikethrough_set*(a: PTextTag, `strikethrough_set`: guint)
-proc right_margin_set*(a: PTextTag): guint
-proc set_right_margin_set*(a: PTextTag, `right_margin_set`: guint)
-proc pixels_above_lines_set*(a: PTextTag): guint
-proc set_pixels_above_lines_set*(a: PTextTag, 
-                                 `pixels_above_lines_set`: guint)
-proc pixels_below_lines_set*(a: PTextTag): guint
-proc set_pixels_below_lines_set*(a: PTextTag, 
-                                 `pixels_below_lines_set`: guint)
-proc pixels_inside_wrap_set*(a: PTextTag): guint
-proc set_pixels_inside_wrap_set*(a: PTextTag, 
-                                 `pixels_inside_wrap_set`: guint)
-proc tabs_set*(a: PTextTag): guint
-proc set_tabs_set*(a: PTextTag, `tabs_set`: guint)
-proc underline_set*(a: PTextTag): guint
-proc set_underline_set*(a: PTextTag, `underline_set`: guint)
-proc wrap_mode_set*(a: PTextTag): guint
-proc set_wrap_mode_set*(a: PTextTag, `wrap_mode_set`: guint)
-proc bg_full_height_set*(a: PTextTag): guint
-proc set_bg_full_height_set*(a: PTextTag, `bg_full_height_set`: guint)
-proc invisible_set*(a: PTextTag): guint
-proc set_invisible_set*(a: PTextTag, `invisible_set`: guint)
-proc editable_set*(a: PTextTag): guint
-proc set_editable_set*(a: PTextTag, `editable_set`: guint)
-proc language_set*(a: PTextTag): guint
-proc set_language_set*(a: PTextTag, `language_set`: guint)
-proc pad1*(a: PTextTag): guint
-proc set_pad1*(a: PTextTag, `pad1`: guint)
-proc pad2*(a: PTextTag): guint
-proc set_pad2*(a: PTextTag, `pad2`: guint)
-proc pad3*(a: PTextTag): guint
-proc set_pad3*(a: PTextTag, `pad3`: guint)
-const 
-  bm_TGtkTextAppearance_underline* = 0x000F'i16
-  bp_TGtkTextAppearance_underline* = 0'i16
-  bm_TGtkTextAppearance_strikethrough* = 0x0010'i16
-  bp_TGtkTextAppearance_strikethrough* = 4'i16
-  bm_TGtkTextAppearance_draw_bg* = 0x0020'i16
-  bp_TGtkTextAppearance_draw_bg* = 5'i16
-  bm_TGtkTextAppearance_inside_selection* = 0x0040'i16
-  bp_TGtkTextAppearance_inside_selection* = 6'i16
-  bm_TGtkTextAppearance_is_text* = 0x0080'i16
-  bp_TGtkTextAppearance_is_text* = 7'i16
-  bm_TGtkTextAppearance_pad1* = 0x0100'i16
-  bp_TGtkTextAppearance_pad1* = 8'i16
-  bm_TGtkTextAppearance_pad2* = 0x0200'i16
-  bp_TGtkTextAppearance_pad2* = 9'i16
-  bm_TGtkTextAppearance_pad3* = 0x0400'i16
-  bp_TGtkTextAppearance_pad3* = 10'i16
-  bm_TGtkTextAppearance_pad4* = 0x0800'i16
-  bp_TGtkTextAppearance_pad4* = 11'i16
-
-proc underline*(a: PTextAppearance): guint
-proc set_underline*(a: PTextAppearance, `underline`: guint)
-proc strikethrough*(a: PTextAppearance): guint
-proc set_strikethrough*(a: PTextAppearance, `strikethrough`: guint)
-proc draw_bg*(a: PTextAppearance): guint
-proc set_draw_bg*(a: PTextAppearance, `draw_bg`: guint)
-proc inside_selection*(a: PTextAppearance): guint
-proc set_inside_selection*(a: PTextAppearance, `inside_selection`: guint)
-proc is_text*(a: PTextAppearance): guint
-proc set_is_text*(a: PTextAppearance, `is_text`: guint)
-proc pad1*(a: PTextAppearance): guint
-proc set_pad1*(a: PTextAppearance, `pad1`: guint)
-proc pad2*(a: PTextAppearance): guint
-proc set_pad2*(a: PTextAppearance, `pad2`: guint)
-proc pad3*(a: PTextAppearance): guint
-proc set_pad3*(a: PTextAppearance, `pad3`: guint)
-proc pad4*(a: PTextAppearance): guint
-proc set_pad4*(a: PTextAppearance, `pad4`: guint)
-const 
-  bm_TGtkTextAttributes_invisible* = 0x0001'i16
-  bp_TGtkTextAttributes_invisible* = 0'i16
-  bm_TGtkTextAttributes_bg_full_height* = 0x0002'i16
-  bp_TGtkTextAttributes_bg_full_height* = 1'i16
-  bm_TGtkTextAttributes_editable* = 0x0004'i16
-  bp_TGtkTextAttributes_editable* = 2'i16
-  bm_TGtkTextAttributes_realized* = 0x0008'i16
-  bp_TGtkTextAttributes_realized* = 3'i16
-  bm_TGtkTextAttributes_pad1* = 0x0010'i16
-  bp_TGtkTextAttributes_pad1* = 4'i16
-  bm_TGtkTextAttributes_pad2* = 0x0020'i16
-  bp_TGtkTextAttributes_pad2* = 5'i16
-  bm_TGtkTextAttributes_pad3* = 0x0040'i16
-  bp_TGtkTextAttributes_pad3* = 6'i16
-  bm_TGtkTextAttributes_pad4* = 0x0080'i16
-  bp_TGtkTextAttributes_pad4* = 7'i16
-
-proc invisible*(a: PTextAttributes): guint
-proc set_invisible*(a: PTextAttributes, `invisible`: guint)
-proc bg_full_height*(a: PTextAttributes): guint
-proc set_bg_full_height*(a: PTextAttributes, `bg_full_height`: guint)
-proc editable*(a: PTextAttributes): guint
-proc set_editable*(a: PTextAttributes, `editable`: guint)
-proc realized*(a: PTextAttributes): guint
-proc set_realized*(a: PTextAttributes, `realized`: guint)
-proc pad1*(a: PTextAttributes): guint
-proc set_pad1*(a: PTextAttributes, `pad1`: guint)
-proc pad2*(a: PTextAttributes): guint
-proc set_pad2*(a: PTextAttributes, `pad2`: guint)
-proc pad3*(a: PTextAttributes): guint
-proc set_pad3*(a: PTextAttributes, `pad3`: guint)
-proc pad4*(a: PTextAttributes): guint
-proc set_pad4*(a: PTextAttributes, `pad4`: guint)
-proc TYPE_TEXT_TAG_TABLE*(): GType
-proc TEXT_TAG_TABLE*(obj: pointer): PTextTagTable
-proc TEXT_TAG_TABLE_CLASS*(klass: pointer): PTextTagTableClass
-proc IS_TEXT_TAG_TABLE*(obj: pointer): bool
-proc IS_TEXT_TAG_TABLE_CLASS*(klass: pointer): bool
-proc TEXT_TAG_TABLE_GET_CLASS*(obj: pointer): PTextTagTableClass
-proc text_tag_table_get_type*(): GType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_text_tag_table_get_type".}
-proc text_tag_table_new*(): PTextTagTable{.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_table_new".}
-proc table_add*(table: PTextTagTable, tag: PTextTag){.cdecl, 
-    dynlib: lib, importc: "gtk_text_tag_table_add".}
-proc table_remove*(table: PTextTagTable, tag: PTextTag){.cdecl, 
-    dynlib: lib, importc: "gtk_text_tag_table_remove".}
-proc table_lookup*(table: PTextTagTable, name: cstring): PTextTag{.
-    cdecl, dynlib: lib, importc: "gtk_text_tag_table_lookup".}
-proc table_foreach*(table: PTextTagTable, fun: TTextTagTableForeach, 
-                             data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_table_foreach".}
-proc table_get_size*(table: PTextTagTable): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_tag_table_get_size".}
-proc table_add_buffer*(table: PTextTagTable, buffer: gpointer){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_tag_table_add_buffer".}
-proc table_remove_buffer*(table: PTextTagTable, buffer: gpointer){.
-    cdecl, dynlib: lib, importc: "_gtk_text_tag_table_remove_buffer".}
-proc TYPE_TEXT_MARK*(): GType
-proc TEXT_MARK*(anObject: pointer): PTextMark
-proc TEXT_MARK_CLASS*(klass: pointer): PTextMarkClass
-proc IS_TEXT_MARK*(anObject: pointer): bool
-proc IS_TEXT_MARK_CLASS*(klass: pointer): bool
-proc TEXT_MARK_GET_CLASS*(obj: pointer): PTextMarkClass
-proc text_mark_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_text_mark_get_type".}
-proc set_visible*(mark: PTextMark, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_text_mark_set_visible".}
-proc get_visible*(mark: PTextMark): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_mark_get_visible".}
-proc get_name*(mark: PTextMark): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_text_mark_get_name".}
-proc get_deleted*(mark: PTextMark): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_mark_get_deleted".}
-proc get_buffer*(mark: PTextMark): PTextBuffer{.cdecl, dynlib: lib, 
-    importc: "gtk_text_mark_get_buffer".}
-proc get_left_gravity*(mark: PTextMark): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_mark_get_left_gravity".}
-const 
-  bm_TGtkTextMarkBody_visible* = 0x0001'i16
-  bp_TGtkTextMarkBody_visible* = 0'i16
-  bm_TGtkTextMarkBody_not_deleteable* = 0x0002'i16
-  bp_TGtkTextMarkBody_not_deleteable* = 1'i16
-
-proc visible*(a: PTextMarkBody): guint
-proc set_visible*(a: PTextMarkBody, `visible`: guint)
-proc not_deleteable*(a: PTextMarkBody): guint
-proc set_not_deleteable*(a: PTextMarkBody, `not_deleteable`: guint)
-proc mark_segment_new*(tree: PTextBTree, left_gravity: gboolean, name: cstring): PTextLineSegment{.
-    cdecl, dynlib: lib, importc: "_gtk_mark_segment_new".}
-proc TYPE_TEXT_CHILD_ANCHOR*(): GType
-proc TEXT_CHILD_ANCHOR*(anObject: pointer): PTextChildAnchor
-proc TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): PTextChildAnchorClass
-proc IS_TEXT_CHILD_ANCHOR*(anObject: pointer): bool
-proc IS_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): bool
-proc TEXT_CHILD_ANCHOR_GET_CLASS*(obj: pointer): PTextChildAnchorClass
-proc text_child_anchor_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "gtk_text_child_anchor_get_type".}
-proc text_child_anchor_new*(): PTextChildAnchor{.cdecl, dynlib: lib, 
-    importc: "gtk_text_child_anchor_new".}
-proc anchor_get_widgets*(anchor: PTextChildAnchor): PGList{.cdecl, 
-    dynlib: lib, importc: "gtk_text_child_anchor_get_widgets".}
-proc anchor_get_deleted*(anchor: PTextChildAnchor): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_child_anchor_get_deleted".}
-proc pixbuf_segment_new*(pixbuf: gdk2pixbuf.PPixbuf): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_pixbuf_segment_new".}
-proc widget_segment_new*(anchor: PTextChildAnchor): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_widget_segment_new".}
-proc widget_segment_add*(widget_segment: PTextLineSegment, child: PWidget){.
-    cdecl, dynlib: lib, importc: "_gtk_widget_segment_add".}
-proc widget_segment_remove*(widget_segment: PTextLineSegment, child: PWidget){.
-    cdecl, dynlib: lib, importc: "_gtk_widget_segment_remove".}
-proc widget_segment_ref*(widget_segment: PTextLineSegment){.cdecl, dynlib: lib, 
-    importc: "_gtk_widget_segment_ref".}
-proc widget_segment_unref*(widget_segment: PTextLineSegment){.cdecl, 
-    dynlib: lib, importc: "_gtk_widget_segment_unref".}
-proc anchored_child_get_layout*(child: PWidget): PTextLayout{.cdecl, 
-    dynlib: lib, importc: "_gtk_anchored_child_get_layout".}
-proc line_segment_split*(iter: PTextIter): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "gtk_text_line_segment_split".}
-proc char_segment_new*(text: cstring, len: guint): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_char_segment_new".}
-proc char_segment_new_from_two_strings*(text1: cstring, len1: guint, 
-                                        text2: cstring, len2: guint): PTextLineSegment{.
-    cdecl, dynlib: lib, importc: "_gtk_char_segment_new_from_two_strings".}
-proc toggle_segment_new*(info: PTextTagInfo, StateOn: gboolean): PTextLineSegment{.
-    cdecl, dynlib: lib, importc: "_gtk_toggle_segment_new".}
-proc btree_new*(table: PTextTagTable, buffer: PTextBuffer): PTextBTree{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_new".}
-proc reference*(tree: PTextBTree){.cdecl, dynlib: lib, 
-                                   importc: "_gtk_text_btree_ref".}
-proc unref*(tree: PTextBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_unref".}
-proc get_buffer*(tree: PTextBTree): PTextBuffer{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_get_buffer".}
-proc get_chars_changed_stamp*(tree: PTextBTree): guint{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_chars_changed_stamp".}
-proc get_segments_changed_stamp*(tree: PTextBTree): guint{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_segments_changed_stamp".}
-proc segments_changed*(tree: PTextBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_segments_changed".}
-proc is_end*(tree: PTextBTree, line: PTextLine, 
-                        seg: PTextLineSegment, byte_index: int32, 
-                        char_offset: int32): gboolean{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_is_end".}
-proc btree_delete*(start: PTextIter, theEnd: PTextIter){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_delete".}
-proc btree_insert*(iter: PTextIter, text: cstring, len: gint){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_insert".}
-proc btree_insert_pixbuf*(iter: PTextIter, pixbuf: gdk2pixbuf.PPixbuf){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_insert_pixbuf".}
-proc btree_insert_child_anchor*(iter: PTextIter, anchor: PTextChildAnchor){.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_insert_child_anchor".}
-proc btree_unregister_child_anchor*(anchor: PTextChildAnchor){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_unregister_child_anchor".}
-proc find_line_by_y*(tree: PTextBTree, view_id: gpointer, 
-                                ypixel: gint, line_top_y: Pgint): PTextLine{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_find_line_by_y".}
-proc find_line_top*(tree: PTextBTree, line: PTextLine, 
-                               view_id: gpointer): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_find_line_top".}
-proc add_view*(tree: PTextBTree, layout: PTextLayout){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_add_view".}
-proc remove_view*(tree: PTextBTree, view_id: gpointer){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_remove_view".}
-proc invalidate_region*(tree: PTextBTree, start: PTextIter, 
-                                   theEnd: PTextIter){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_invalidate_region".}
-proc get_view_size*(tree: PTextBTree, view_id: gpointer, 
-                               width: Pgint, height: Pgint){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_get_view_size".}
-proc is_valid*(tree: PTextBTree, view_id: gpointer): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_is_valid".}
-proc validate*(tree: PTextBTree, view_id: gpointer, max_pixels: gint, 
-                          y: Pgint, old_height: Pgint, new_height: Pgint): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_validate".}
-proc validate_line*(tree: PTextBTree, line: PTextLine, 
-                               view_id: gpointer){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_validate_line".}
-proc btree_tag*(start: PTextIter, theEnd: PTextIter, tag: PTextTag, 
-                     apply: gboolean){.cdecl, dynlib: lib, 
-                                       importc: "_gtk_text_btree_tag".}
-proc get_line*(tree: PTextBTree, line_number: gint, 
-                          real_line_number: Pgint): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_line".}
-proc get_line_no_last*(tree: PTextBTree, line_number: gint, 
-                                  real_line_number: Pgint): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_line_no_last".}
-proc get_end_iter_line*(tree: PTextBTree): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_end_iter_line".}
-proc get_line_at_char*(tree: PTextBTree, char_index: gint, 
-                                  line_start_index: Pgint, 
-                                  real_char_index: Pgint): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_line_at_char".}
-proc btree_get_tags*(iter: PTextIter, num_tags: Pgint): PPGtkTextTag{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_get_tags".}
-proc btree_get_text*(start: PTextIter, theEnd: PTextIter, 
-                          include_hidden: gboolean, include_nonchars: gboolean): cstring{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_get_text".}
-proc line_count*(tree: PTextBTree): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_line_count".}
-proc char_count*(tree: PTextBTree): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_char_count".}
-proc btree_char_is_invisible*(iter: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_char_is_invisible".}
-proc get_iter_at_char*(tree: PTextBTree, iter: PTextIter, 
-                                  char_index: gint){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_get_iter_at_char".}
-proc get_iter_at_line_char*(tree: PTextBTree, iter: PTextIter, 
-                                       line_number: gint, char_index: gint){.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_get_iter_at_line_char".}
-proc get_iter_at_line_byte*(tree: PTextBTree, iter: PTextIter, 
-                                       line_number: gint, byte_index: gint){.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_get_iter_at_line_byte".}
-proc get_iter_from_string*(tree: PTextBTree, iter: PTextIter, 
-                                      `string`: cstring): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_iter_from_string".}
-proc get_iter_at_mark_name*(tree: PTextBTree, iter: PTextIter, 
-                                       mark_name: cstring): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_iter_at_mark_name".}
-proc get_iter_at_mark*(tree: PTextBTree, iter: PTextIter, 
-                                  mark: PTextMark){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_get_iter_at_mark".}
-proc get_end_iter*(tree: PTextBTree, iter: PTextIter){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_end_iter".}
-proc get_iter_at_line*(tree: PTextBTree, iter: PTextIter, 
-                                  line: PTextLine, byte_offset: gint){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_iter_at_line".}
-proc get_iter_at_first_toggle*(tree: PTextBTree, iter: PTextIter, 
-    tag: PTextTag): gboolean{.cdecl, dynlib: lib, importc: "_gtk_text_btree_get_iter_at_first_toggle".}
-proc get_iter_at_last_toggle*(tree: PTextBTree, iter: PTextIter, 
-    tag: PTextTag): gboolean{.cdecl, dynlib: lib, importc: "_gtk_text_btree_get_iter_at_last_toggle".}
-proc get_iter_at_child_anchor*(tree: PTextBTree, iter: PTextIter, 
-    anchor: PTextChildAnchor){.cdecl, dynlib: lib, importc: "_gtk_text_btree_get_iter_at_child_anchor".}
-proc set_mark*(tree: PTextBTree, existing_mark: PTextMark, 
-                          name: cstring, left_gravity: gboolean, 
-                          index: PTextIter, should_exist: gboolean): PTextMark{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_set_mark".}
-proc remove_mark_by_name*(tree: PTextBTree, name: cstring){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_remove_mark_by_name".}
-proc remove_mark*(tree: PTextBTree, segment: PTextMark){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_remove_mark".}
-proc get_selection_bounds*(tree: PTextBTree, start: PTextIter, 
-                                      theEnd: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_get_selection_bounds".}
-proc place_cursor*(tree: PTextBTree, `where`: PTextIter){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_place_cursor".}
-proc mark_is_insert*(tree: PTextBTree, segment: PTextMark): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_mark_is_insert".}
-proc mark_is_selection_bound*(tree: PTextBTree, segment: PTextMark): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_mark_is_selection_bound".}
-proc get_mark_by_name*(tree: PTextBTree, name: cstring): PTextMark{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_get_mark_by_name".}
-proc first_could_contain_tag*(tree: PTextBTree, tag: PTextTag): PTextLine{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_first_could_contain_tag".}
-proc last_could_contain_tag*(tree: PTextBTree, tag: PTextTag): PTextLine{.
-    cdecl, dynlib: lib, importc: "_gtk_text_btree_last_could_contain_tag".}
-const 
-  bm_TGtkTextLineData_width* = 0x00FFFFFF'i32
-  bp_TGtkTextLineData_width* = 0'i32
-  bm_TGtkTextLineData_valid* = 0xFF000000'i32
-  bp_TGtkTextLineData_valid* = 24'i32
-
-proc width*(a: PTextLineData): gint
-proc set_width*(a: PTextLineData, NewWidth: gint)
-proc valid*(a: PTextLineData): gint
-proc set_valid*(a: PTextLineData, `valid`: gint)
-proc get_number*(line: PTextLine): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_get_number".}
-proc char_has_tag*(line: PTextLine, tree: PTextBTree, 
-                             char_in_line: gint, tag: PTextTag): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_line_char_has_tag".}
-proc byte_has_tag*(line: PTextLine, tree: PTextBTree, 
-                             byte_in_line: gint, tag: PTextTag): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_line_byte_has_tag".}
-proc is_last*(line: PTextLine, tree: PTextBTree): gboolean{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_is_last".}
-proc contains_end_iter*(line: PTextLine, tree: PTextBTree): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_text_line_contains_end_iter".}
-proc next*(line: PTextLine): PTextLine{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_next".}
-proc next_excluding_last*(line: PTextLine): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_next_excluding_last".}
-proc previous*(line: PTextLine): PTextLine{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_previous".}
-proc add_data*(line: PTextLine, data: PTextLineData){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_add_data".}
-proc remove_data*(line: PTextLine, view_id: gpointer): gpointer{.
-    cdecl, dynlib: lib, importc: "_gtk_text_line_remove_data".}
-proc get_data*(line: PTextLine, view_id: gpointer): gpointer{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_get_data".}
-proc invalidate_wrap*(line: PTextLine, ld: PTextLineData){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_invalidate_wrap".}
-proc char_count*(line: PTextLine): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_char_count".}
-proc byte_count*(line: PTextLine): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_byte_count".}
-proc char_index*(line: PTextLine): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_text_line_char_index".}
-proc byte_to_segment*(line: PTextLine, byte_offset: gint, 
-                                seg_offset: Pgint): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_byte_to_segment".}
-proc char_to_segment*(line: PTextLine, char_offset: gint, 
-                                seg_offset: Pgint): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_char_to_segment".}
-proc byte_to_char_offsets*(line: PTextLine, byte_offset: gint, 
-                                     line_char_offset: Pgint, 
-                                     seg_char_offset: Pgint){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_byte_to_char_offsets".}
-proc char_to_byte_offsets*(line: PTextLine, char_offset: gint, 
-                                     line_byte_offset: Pgint, 
-                                     seg_byte_offset: Pgint){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_char_to_byte_offsets".}
-proc byte_to_any_segment*(line: PTextLine, byte_offset: gint, 
-                                    seg_offset: Pgint): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_byte_to_any_segment".}
-proc char_to_any_segment*(line: PTextLine, char_offset: gint, 
-                                    seg_offset: Pgint): PTextLineSegment{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_char_to_any_segment".}
-proc byte_to_char*(line: PTextLine, byte_offset: gint): gint{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_byte_to_char".}
-proc char_to_byte*(line: PTextLine, char_offset: gint): gint{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_char_to_byte".}
-proc next_could_contain_tag*(line: PTextLine, tree: PTextBTree, 
-                                       tag: PTextTag): PTextLine{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_line_next_could_contain_tag".}
-proc previous_could_contain_tag*(line: PTextLine, tree: PTextBTree, 
-    tag: PTextTag): PTextLine{.cdecl, dynlib: lib, importc: "_gtk_text_line_previous_could_contain_tag".}
-proc line_data_new*(layout: PTextLayout, line: PTextLine): PTextLineData{.
-    cdecl, dynlib: lib, importc: "_gtk_text_line_data_new".}
-proc check*(tree: PTextBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_check".}
-proc spew*(tree: PTextBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_btree_spew".}
-proc toggle_segment_check_func*(segPtr: PTextLineSegment, line: PTextLine){.
-    cdecl, dynlib: lib, importc: "_gtk_toggle_segment_check_func".}
-proc change_node_toggle_count*(node: PTextBTreeNode, info: PTextTagInfo, 
-                               delta: gint){.cdecl, dynlib: lib, 
-    importc: "_gtk_change_node_toggle_count".}
-proc release_mark_segment*(tree: PTextBTree, 
-                                      segment: PTextLineSegment){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_release_mark_segment".}
-proc notify_will_remove_tag*(tree: PTextBTree, tag: PTextTag){.cdecl, 
-    dynlib: lib, importc: "_gtk_text_btree_notify_will_remove_tag".}
-const 
-  bm_TGtkTextBuffer_modified* = 0x0001'i16
-  bp_TGtkTextBuffer_modified* = 0'i16
-
-proc TYPE_TEXT_BUFFER*(): GType
-proc TEXT_BUFFER*(obj: pointer): PTextBuffer
-proc TEXT_BUFFER_CLASS*(klass: pointer): PTextBufferClass
-proc IS_TEXT_BUFFER*(obj: pointer): bool
-proc IS_TEXT_BUFFER_CLASS*(klass: pointer): bool
-proc TEXT_BUFFER_GET_CLASS*(obj: pointer): PTextBufferClass
-proc modified*(a: PTextBuffer): guint
-proc set_modified*(a: PTextBuffer, `modified`: guint)
-proc text_buffer_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_text_buffer_get_type".}
-proc text_buffer_new*(table: PTextTagTable): PTextBuffer{.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_new".}
-proc get_line_count*(buffer: PTextBuffer): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_line_count".}
-proc get_char_count*(buffer: PTextBuffer): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_char_count".}
-proc get_tag_table*(buffer: PTextBuffer): PTextTagTable{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_tag_table".}
-proc set_text*(buffer: PTextBuffer, text: cstring, len: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_set_text".}
-proc insert*(buffer: PTextBuffer, iter: PTextIter, text: cstring, 
-                         len: gint){.cdecl, dynlib: lib, 
-                                     importc: "gtk_text_buffer_insert".}
-proc insert_at_cursor*(buffer: PTextBuffer, text: cstring, len: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_insert_at_cursor".}
-proc insert_interactive*(buffer: PTextBuffer, iter: PTextIter, 
-                                     text: cstring, len: gint, 
-                                     default_editable: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_insert_interactive".}
-proc insert_interactive_at_cursor*(buffer: PTextBuffer, 
-    text: cstring, len: gint, default_editable: gboolean): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_insert_interactive_at_cursor".}
-proc insert_range*(buffer: PTextBuffer, iter: PTextIter, 
-                               start: PTextIter, theEnd: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_insert_range".}
-proc insert_range_interactive*(buffer: PTextBuffer, iter: PTextIter, 
-    start: PTextIter, theEnd: PTextIter, default_editable: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_insert_range_interactive".}
-proc delete*(buffer: PTextBuffer, start: PTextIter, 
-                         theEnd: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_delete".}
-proc delete_interactive*(buffer: PTextBuffer, start_iter: PTextIter, 
-                                     end_iter: PTextIter, 
-                                     default_editable: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_delete_interactive".}
-proc get_text*(buffer: PTextBuffer, start: PTextIter, 
-                           theEnd: PTextIter, include_hidden_chars: gboolean): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_get_text".}
-proc get_slice*(buffer: PTextBuffer, start: PTextIter, 
-                            theEnd: PTextIter, include_hidden_chars: gboolean): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_get_slice".}
-proc insert_pixbuf*(buffer: PTextBuffer, iter: PTextIter, 
-                                pixbuf: gdk2pixbuf.PPixbuf){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_insert_pixbuf".}
-proc insert_child_anchor*(buffer: PTextBuffer, iter: PTextIter, 
-                                      anchor: PTextChildAnchor){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_insert_child_anchor".}
-proc create_child_anchor*(buffer: PTextBuffer, iter: PTextIter): PTextChildAnchor{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_create_child_anchor".}
-proc create_mark*(buffer: PTextBuffer, mark_name: cstring, 
-                              `where`: PTextIter, left_gravity: gboolean): PTextMark{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_create_mark".}
-proc move_mark*(buffer: PTextBuffer, mark: PTextMark, 
-                            `where`: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_move_mark".}
-proc delete_mark*(buffer: PTextBuffer, mark: PTextMark){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_delete_mark".}
-proc get_mark*(buffer: PTextBuffer, name: cstring): PTextMark{.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_get_mark".}
-proc move_mark_by_name*(buffer: PTextBuffer, name: cstring, 
-                                    `where`: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_move_mark_by_name".}
-proc delete_mark_by_name*(buffer: PTextBuffer, name: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_delete_mark_by_name".}
-proc get_insert*(buffer: PTextBuffer): PTextMark{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_insert".}
-proc get_selection_bound*(buffer: PTextBuffer): PTextMark{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_selection_bound".}
-proc place_cursor*(buffer: PTextBuffer, `where`: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_place_cursor".}
-proc apply_tag*(buffer: PTextBuffer, tag: PTextTag, 
-                            start: PTextIter, theEnd: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_apply_tag".}
-proc remove_tag*(buffer: PTextBuffer, tag: PTextTag, 
-                             start: PTextIter, theEnd: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_remove_tag".}
-proc apply_tag_by_name*(buffer: PTextBuffer, name: cstring, 
-                                    start: PTextIter, theEnd: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_apply_tag_by_name".}
-proc remove_tag_by_name*(buffer: PTextBuffer, name: cstring, 
-                                     start: PTextIter, theEnd: PTextIter){.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_remove_tag_by_name".}
-proc remove_all_tags*(buffer: PTextBuffer, start: PTextIter, 
-                                  theEnd: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_remove_all_tags".}
-proc get_iter_at_line_offset*(buffer: PTextBuffer, iter: PTextIter, 
-    line_number: gint, char_offset: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_iter_at_line_offset".}
-proc get_iter_at_line_index*(buffer: PTextBuffer, iter: PTextIter, 
-    line_number: gint, byte_index: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_iter_at_line_index".}
-proc get_iter_at_offset*(buffer: PTextBuffer, iter: PTextIter, 
-                                     char_offset: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_iter_at_offset".}
-proc get_iter_at_line*(buffer: PTextBuffer, iter: PTextIter, 
-                                   line_number: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_iter_at_line".}
-proc get_start_iter*(buffer: PTextBuffer, iter: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_start_iter".}
-proc get_end_iter*(buffer: PTextBuffer, iter: PTextIter){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_end_iter".}
-proc get_bounds*(buffer: PTextBuffer, start: PTextIter, 
-                             theEnd: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_bounds".}
-proc get_iter_at_mark*(buffer: PTextBuffer, iter: PTextIter, 
-                                   mark: PTextMark){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_get_iter_at_mark".}
-proc get_iter_at_child_anchor*(buffer: PTextBuffer, iter: PTextIter, 
-    anchor: PTextChildAnchor){.cdecl, dynlib: lib, importc: "gtk_text_buffer_get_iter_at_child_anchor".}
-proc get_modified*(buffer: PTextBuffer): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_modified".}
-proc set_modified*(buffer: PTextBuffer, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_set_modified".}
-proc add_selection_clipboard*(buffer: PTextBuffer, 
-    clipboard: PClipboard){.cdecl, dynlib: lib, 
-                            importc: "gtk_text_buffer_add_selection_clipboard".}
-proc remove_selection_clipboard*(buffer: PTextBuffer, 
-    clipboard: PClipboard){.cdecl, dynlib: lib, importc: "gtk_text_buffer_remove_selection_clipboard".}
-proc cut_clipboard*(buffer: PTextBuffer, clipboard: PClipboard, 
-                                default_editable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_cut_clipboard".}
-proc copy_clipboard*(buffer: PTextBuffer, clipboard: PClipboard){.
-    cdecl, dynlib: lib, importc: "gtk_text_buffer_copy_clipboard".}
-proc paste_clipboard*(buffer: PTextBuffer, clipboard: PClipboard, 
-                                  override_location: PTextIter, 
-                                  default_editable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_paste_clipboard".}
-proc get_selection_bounds*(buffer: PTextBuffer, start: PTextIter, 
-                                       theEnd: PTextIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_get_selection_bounds".}
-proc delete_selection*(buffer: PTextBuffer, interactive: gboolean, 
-                                   default_editable: gboolean): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_buffer_delete_selection".}
-proc begin_user_action*(buffer: PTextBuffer){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_begin_user_action".}
-proc end_user_action*(buffer: PTextBuffer){.cdecl, dynlib: lib, 
-    importc: "gtk_text_buffer_end_user_action".}
-proc spew*(buffer: PTextBuffer){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_buffer_spew".}
-proc get_btree*(buffer: PTextBuffer): PTextBTree{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_buffer_get_btree".}
-proc get_line_log_attrs*(buffer: PTextBuffer, 
-                                     anywhere_in_line: PTextIter, 
-                                     char_len: Pgint): pango.PLogAttr{.cdecl, 
-    dynlib: lib, importc: "_gtk_text_buffer_get_line_log_attrs".}
-proc notify_will_remove_tag*(buffer: PTextBuffer, tag: PTextTag){.
-    cdecl, dynlib: lib, importc: "_gtk_text_buffer_notify_will_remove_tag".}
-proc TYPE_TEXT_LAYOUT*(): GType
-proc TEXT_LAYOUT*(obj: pointer): PTextLayout
-proc TEXT_LAYOUT_CLASS*(klass: pointer): PTextLayoutClass
-proc IS_TEXT_LAYOUT*(obj: pointer): bool
-proc IS_TEXT_LAYOUT_CLASS*(klass: pointer): bool
-proc TEXT_LAYOUT_GET_CLASS*(obj: pointer): PTextLayoutClass
-const 
-  bm_TGtkTextLayout_cursor_visible* = 0x0001'i16
-  bp_TGtkTextLayout_cursor_visible* = 0'i16
-  bm_TGtkTextLayout_cursor_direction* = 0x0006'i16
-  bp_TGtkTextLayout_cursor_direction* = 1'i16
-
-proc cursor_visible*(a: PTextLayout): guint
-proc set_cursor_visible*(a: PTextLayout, `cursor_visible`: guint)
-proc cursor_direction*(a: PTextLayout): gint
-proc set_cursor_direction*(a: PTextLayout, `cursor_direction`: gint)
-const 
-  bm_TGtkTextCursorDisplay_is_strong* = 0x0001'i16
-  bp_TGtkTextCursorDisplay_is_strong* = 0'i16
-  bm_TGtkTextCursorDisplay_is_weak* = 0x0002'i16
-  bp_TGtkTextCursorDisplay_is_weak* = 1'i16
-
-proc is_strong*(a: PTextCursorDisplay): guint
-proc set_is_strong*(a: PTextCursorDisplay, `is_strong`: guint)
-proc is_weak*(a: PTextCursorDisplay): guint
-proc set_is_weak*(a: PTextCursorDisplay, `is_weak`: guint)
-proc text_layout_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_text_layout_get_type".}
-proc text_layout_new*(): PTextLayout{.cdecl, dynlib: lib, 
-                                      importc: "gtk_text_layout_new".}
-proc set_buffer*(layout: PTextLayout, buffer: PTextBuffer){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_set_buffer".}
-proc get_buffer*(layout: PTextLayout): PTextBuffer{.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_get_buffer".}
-proc set_default_style*(layout: PTextLayout, values: PTextAttributes){.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_set_default_style".}
-proc set_contexts*(layout: PTextLayout, ltr_context: pango.PContext, 
-                               rtl_context: pango.PContext){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_set_contexts".}
-proc set_cursor_direction*(layout: PTextLayout, 
-                                       direction: TTextDirection){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_set_cursor_direction".}
-proc default_style_changed*(layout: PTextLayout){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_default_style_changed".}
-proc set_screen_width*(layout: PTextLayout, width: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_set_screen_width".}
-proc set_preedit_string*(layout: PTextLayout, 
-                                     preedit_string: cstring, 
-                                     preedit_attrs: pango.PAttrList, 
-                                     cursor_pos: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_set_preedit_string".}
-proc set_cursor_visible*(layout: PTextLayout, 
-                                     cursor_visible: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_set_cursor_visible".}
-proc get_cursor_visible*(layout: PTextLayout): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_get_cursor_visible".}
-proc get_size*(layout: PTextLayout, width: Pgint, height: Pgint){.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_get_size".}
-proc get_lines*(layout: PTextLayout, top_y: gint, bottom_y: gint, 
-                            first_line_y: Pgint): PGSList{.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_get_lines".}
-proc wrap_loop_start*(layout: PTextLayout){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_wrap_loop_start".}
-proc wrap_loop_end*(layout: PTextLayout){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_wrap_loop_end".}
-proc get_line_display*(layout: PTextLayout, line: PTextLine, 
-                                   size_only: gboolean): PTextLineDisplay{.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_get_line_display".}
-proc free_line_display*(layout: PTextLayout, 
-                                    display: PTextLineDisplay){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_free_line_display".}
-proc get_line_at_y*(layout: PTextLayout, target_iter: PTextIter, 
-                                y: gint, line_top: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_get_line_at_y".}
-proc get_iter_at_pixel*(layout: PTextLayout, iter: PTextIter, 
-                                    x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_get_iter_at_pixel".}
-proc invalidate*(layout: PTextLayout, start: PTextIter, 
-                             theEnd: PTextIter){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_invalidate".}
-proc free_line_data*(layout: PTextLayout, line: PTextLine, 
-                                 line_data: PTextLineData){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_free_line_data".}
-proc is_valid*(layout: PTextLayout): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_is_valid".}
-proc validate_yrange*(layout: PTextLayout, anchor_line: PTextIter, 
-                                  y0: gint, y1: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_validate_yrange".}
-proc validate*(layout: PTextLayout, max_pixels: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_validate".}
-proc wrap*(layout: PTextLayout, line: PTextLine, 
-                       line_data: PTextLineData): PTextLineData{.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_wrap".}
-proc changed*(layout: PTextLayout, y: gint, old_height: gint, 
-                          new_height: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_changed".}
-proc get_iter_location*(layout: PTextLayout, iter: PTextIter, 
-                                    rect: gdk2.PRectangle){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_get_iter_location".}
-proc get_line_yrange*(layout: PTextLayout, iter: PTextIter, 
-                                  y: Pgint, height: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_get_line_yrange".}
-proc get_line_xrange*(layout: PTextLayout, iter: PTextIter, 
-                                  x: Pgint, width: Pgint){.cdecl, dynlib: lib, 
-    importc: "_gtk_text_layout_get_line_xrange".}
-proc get_cursor_locations*(layout: PTextLayout, iter: PTextIter, 
-                                       strong_pos: gdk2.PRectangle, 
-                                       weak_pos: gdk2.PRectangle){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_get_cursor_locations".}
-proc clamp_iter_to_vrange*(layout: PTextLayout, iter: PTextIter, 
-                                       top: gint, bottom: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_clamp_iter_to_vrange".}
-proc move_iter_to_line_end*(layout: PTextLayout, iter: PTextIter, 
-                                        direction: gint): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_move_iter_to_line_end".}
-proc move_iter_to_previous_line*(layout: PTextLayout, 
-    iter: PTextIter): gboolean{.cdecl, dynlib: lib, importc: "gtk_text_layout_move_iter_to_previous_line".}
-proc move_iter_to_next_line*(layout: PTextLayout, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_move_iter_to_next_line".}
-proc move_iter_to_x*(layout: PTextLayout, iter: PTextIter, x: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_move_iter_to_x".}
-proc move_iter_visually*(layout: PTextLayout, iter: PTextIter, 
-                                     count: gint): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_move_iter_visually".}
-proc iter_starts_line*(layout: PTextLayout, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_layout_iter_starts_line".}
-proc get_iter_at_line*(layout: PTextLayout, iter: PTextIter, 
-                                   line: PTextLine, byte_offset: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_layout_get_iter_at_line".}
-proc anchor_register_child*(anchor: PTextChildAnchor, child: PWidget, 
-                                       layout: PTextLayout){.cdecl, dynlib: lib, 
-    importc: "gtk_text_child_anchor_register_child".}
-proc anchor_unregister_child*(anchor: PTextChildAnchor, 
-    child: PWidget){.cdecl, dynlib: lib, 
-                     importc: "gtk_text_child_anchor_unregister_child".}
-proc anchor_queue_resize*(anchor: PTextChildAnchor, 
-                                     layout: PTextLayout){.cdecl, dynlib: lib, 
-    importc: "gtk_text_child_anchor_queue_resize".}
-proc text_anchored_child_set_layout*(child: PWidget, layout: PTextLayout){.
-    cdecl, dynlib: lib, importc: "gtk_text_anchored_child_set_layout".}
-proc spew*(layout: PTextLayout){.cdecl, dynlib: lib, 
-    importc: "gtk_text_layout_spew".}
-const                         # GTK_TEXT_VIEW_PRIORITY_VALIDATE* = GDK_PRIORITY_REDRAW + 5
-  bm_TGtkTextView_editable* = 0x0001'i16
-  bp_TGtkTextView_editable* = 0'i16
-  bm_TGtkTextView_overwrite_mode* = 0x0002'i16
-  bp_TGtkTextView_overwrite_mode* = 1'i16
-  bm_TGtkTextView_cursor_visible* = 0x0004'i16
-  bp_TGtkTextView_cursor_visible* = 2'i16
-  bm_TGtkTextView_need_im_reset* = 0x0008'i16
-  bp_TGtkTextView_need_im_reset* = 3'i16
-  bm_TGtkTextView_just_selected_element* = 0x0010'i16
-  bp_TGtkTextView_just_selected_element* = 4'i16
-  bm_TGtkTextView_disable_scroll_on_focus* = 0x0020'i16
-  bp_TGtkTextView_disable_scroll_on_focus* = 5'i16
-  bm_TGtkTextView_onscreen_validated* = 0x0040'i16
-  bp_TGtkTextView_onscreen_validated* = 6'i16
-  bm_TGtkTextView_mouse_cursor_obscured* = 0x0080'i16
-  bp_TGtkTextView_mouse_cursor_obscured* = 7'i16
-
-proc TYPE_TEXT_VIEW*(): GType
-proc TEXT_VIEW*(obj: pointer): PTextView
-proc TEXT_VIEW_CLASS*(klass: pointer): PTextViewClass
-proc IS_TEXT_VIEW*(obj: pointer): bool
-proc IS_TEXT_VIEW_CLASS*(klass: pointer): bool
-proc TEXT_VIEW_GET_CLASS*(obj: pointer): PTextViewClass
-proc editable*(a: PTextView): guint
-proc set_editable*(a: PTextView, `editable`: guint)
-proc overwrite_mode*(a: PTextView): guint
-proc set_overwrite_mode*(a: PTextView, `overwrite_mode`: guint)
-proc cursor_visible*(a: PTextView): guint
-proc set_cursor_visible*(a: PTextView, `cursor_visible`: guint)
-proc need_im_reset*(a: PTextView): guint
-proc set_need_im_reset*(a: PTextView, `need_im_reset`: guint)
-proc just_selected_element*(a: PTextView): guint
-proc set_just_selected_element*(a: PTextView, `just_selected_element`: guint)
-proc disable_scroll_on_focus*(a: PTextView): guint
-proc set_disable_scroll_on_focus*(a: PTextView, 
-                                  `disable_scroll_on_focus`: guint)
-proc onscreen_validated*(a: PTextView): guint
-proc set_onscreen_validated*(a: PTextView, `onscreen_validated`: guint)
-proc mouse_cursor_obscured*(a: PTextView): guint
-proc set_mouse_cursor_obscured*(a: PTextView, `mouse_cursor_obscured`: guint)
-proc text_view_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_text_view_get_type".}
-proc text_view_new*(): PTextView{.cdecl, dynlib: lib, 
-                                  importc: "gtk_text_view_new".}
-proc text_view_new*(buffer: PTextBuffer): PTextView{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_new_with_buffer".}
-proc set_buffer*(text_view: PTextView, buffer: PTextBuffer){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_buffer".}
-proc get_buffer*(text_view: PTextView): PTextBuffer{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_buffer".}
-proc scroll_to_iter*(text_view: PTextView, iter: PTextIter, 
-                               within_margin: gdouble, use_align: gboolean, 
-                               xalign: gdouble, yalign: gdouble): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_scroll_to_iter".}
-proc scroll_to_mark*(text_view: PTextView, mark: PTextMark, 
-                               within_margin: gdouble, use_align: gboolean, 
-                               xalign: gdouble, yalign: gdouble){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_scroll_to_mark".}
-proc scroll_mark_onscreen*(text_view: PTextView, mark: PTextMark){.
-    cdecl, dynlib: lib, importc: "gtk_text_view_scroll_mark_onscreen".}
-proc move_mark_onscreen*(text_view: PTextView, mark: PTextMark): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_move_mark_onscreen".}
-proc place_cursor_onscreen*(text_view: PTextView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_place_cursor_onscreen".}
-proc get_visible_rect*(text_view: PTextView, 
-                                 visible_rect: gdk2.PRectangle){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_visible_rect".}
-proc set_cursor_visible*(text_view: PTextView, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_text_view_set_cursor_visible".}
-proc get_cursor_visible*(text_view: PTextView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_cursor_visible".}
-proc get_iter_location*(text_view: PTextView, iter: PTextIter, 
-                                  location: gdk2.PRectangle){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_iter_location".}
-proc get_iter_at_location*(text_view: PTextView, iter: PTextIter, 
-                                     x: gint, y: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_iter_at_location".}
-proc get_line_yrange*(text_view: PTextView, iter: PTextIter, y: Pgint, 
-                                height: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_line_yrange".}
-proc get_line_at_y*(text_view: PTextView, target_iter: PTextIter, 
-                              y: gint, line_top: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_line_at_y".}
-proc buffer_to_window_coords*(text_view: PTextView, 
-                                        win: TTextWindowType, buffer_x: gint, 
-                                        buffer_y: gint, window_x: Pgint, 
-                                        window_y: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_buffer_to_window_coords".}
-proc window_to_buffer_coords*(text_view: PTextView, 
-                                        win: TTextWindowType, window_x: gint, 
-                                        window_y: gint, buffer_x: Pgint, 
-                                        buffer_y: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_window_to_buffer_coords".}
-proc get_window*(text_view: PTextView, win: TTextWindowType): gdk2.PWindow{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_get_window".}
-proc get_window_type*(text_view: PTextView, window: gdk2.PWindow): TTextWindowType{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_get_window_type".}
-proc set_border_window_size*(text_view: PTextView, 
-                                       thetype: TTextWindowType, size: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_view_set_border_window_size".}
-proc get_border_window_size*(text_view: PTextView, 
-                                       thetype: TTextWindowType): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_border_window_size".}
-proc forward_display_line*(text_view: PTextView, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_forward_display_line".}
-proc backward_display_line*(text_view: PTextView, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_backward_display_line".}
-proc forward_display_line_end*(text_view: PTextView, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_forward_display_line_end".}
-proc backward_display_line_start*(text_view: PTextView, 
-    iter: PTextIter): gboolean{.cdecl, dynlib: lib, importc: "gtk_text_view_backward_display_line_start".}
-proc starts_display_line*(text_view: PTextView, iter: PTextIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_starts_display_line".}
-proc move_visually*(text_view: PTextView, iter: PTextIter, count: gint): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_move_visually".}
-proc add_child_at_anchor*(text_view: PTextView, child: PWidget, 
-                                    anchor: PTextChildAnchor){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_add_child_at_anchor".}
-proc add_child_in_window*(text_view: PTextView, child: PWidget, 
-                                    which_window: TTextWindowType, xpos: gint, 
-                                    ypos: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_add_child_in_window".}
-proc move_child*(text_view: PTextView, child: PWidget, xpos: gint, 
-                           ypos: gint){.cdecl, dynlib: lib, 
-                                        importc: "gtk_text_view_move_child".}
-proc set_wrap_mode*(text_view: PTextView, wrap_mode: TWrapMode){.
-    cdecl, dynlib: lib, importc: "gtk_text_view_set_wrap_mode".}
-proc get_wrap_mode*(text_view: PTextView): TWrapMode{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_wrap_mode".}
-proc set_editable*(text_view: PTextView, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_editable".}
-proc get_editable*(text_view: PTextView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_editable".}
-proc set_pixels_above_lines*(text_view: PTextView, 
-                                       pixels_above_lines: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_pixels_above_lines".}
-proc get_pixels_above_lines*(text_view: PTextView): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_pixels_above_lines".}
-proc set_pixels_below_lines*(text_view: PTextView, 
-                                       pixels_below_lines: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_pixels_below_lines".}
-proc get_pixels_below_lines*(text_view: PTextView): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_pixels_below_lines".}
-proc set_pixels_inside_wrap*(text_view: PTextView, 
-                                       pixels_inside_wrap: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_pixels_inside_wrap".}
-proc get_pixels_inside_wrap*(text_view: PTextView): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_pixels_inside_wrap".}
-proc set_justification*(text_view: PTextView, 
-                                  justification: TJustification){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_justification".}
-proc get_justification*(text_view: PTextView): TJustification{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_justification".}
-proc set_left_margin*(text_view: PTextView, left_margin: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_left_margin".}
-proc get_left_margin*(text_view: PTextView): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_left_margin".}
-proc set_right_margin*(text_view: PTextView, right_margin: gint){.
-    cdecl, dynlib: lib, importc: "gtk_text_view_set_right_margin".}
-proc get_right_margin*(text_view: PTextView): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_right_margin".}
-proc set_indent*(text_view: PTextView, indent: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_indent".}
-proc get_indent*(text_view: PTextView): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_text_view_get_indent".}
-proc set_tabs*(text_view: PTextView, tabs: pango.PTabArray){.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_set_tabs".}
-proc get_tabs*(text_view: PTextView): pango.PTabArray{.cdecl, 
-    dynlib: lib, importc: "gtk_text_view_get_tabs".}
-proc get_default_attributes*(text_view: PTextView): PTextAttributes{.
-    cdecl, dynlib: lib, importc: "gtk_text_view_get_default_attributes".}
-const 
-  bm_TGtkTipsQuery_emit_always* = 0x0001'i16
-  bp_TGtkTipsQuery_emit_always* = 0'i16
-  bm_TGtkTipsQuery_in_query* = 0x0002'i16
-  bp_TGtkTipsQuery_in_query* = 1'i16
-
-proc TYPE_TIPS_QUERY*(): GType
-proc TIPS_QUERY*(obj: pointer): PTipsQuery
-proc TIPS_QUERY_CLASS*(klass: pointer): PTipsQueryClass
-proc IS_TIPS_QUERY*(obj: pointer): bool
-proc IS_TIPS_QUERY_CLASS*(klass: pointer): bool
-proc TIPS_QUERY_GET_CLASS*(obj: pointer): PTipsQueryClass
-proc emit_always*(a: PTipsQuery): guint
-proc set_emit_always*(a: PTipsQuery, `emit_always`: guint)
-proc in_query*(a: PTipsQuery): guint
-proc set_in_query*(a: PTipsQuery, `in_query`: guint)
-proc tips_query_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_tips_query_get_type".}
-proc tips_query_new*(): PTipsQuery{.cdecl, dynlib: lib, 
-                                    importc: "gtk_tips_query_new".}
-proc start_query*(tips_query: PTipsQuery){.cdecl, dynlib: lib, 
-    importc: "gtk_tips_query_start_query".}
-proc stop_query*(tips_query: PTipsQuery){.cdecl, dynlib: lib, 
-    importc: "gtk_tips_query_stop_query".}
-proc set_caller*(tips_query: PTipsQuery, caller: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_tips_query_set_caller".}
-proc set_labels*(tips_query: PTipsQuery, label_inactive: cstring, 
-                            label_no_tip: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_tips_query_set_labels".}
-const 
-  bm_TGtkTooltips_delay* = 0x3FFFFFFF'i32
-  bp_TGtkTooltips_delay* = 0'i32
-  bm_TGtkTooltips_enabled* = 0x40000000'i32
-  bp_TGtkTooltips_enabled* = 30'i32
-  bm_TGtkTooltips_have_grab* = 0x80000000'i32
-  bp_TGtkTooltips_have_grab* = 31'i32
-  bm_TGtkTooltips_use_sticky_delay* = 0x00000001'i32
-  bp_TGtkTooltips_use_sticky_delay* = 0'i32
-
-proc TYPE_TOOLTIPS*(): GType
-proc TOOLTIPS*(obj: pointer): PTooltips
-proc TOOLTIPS_CLASS*(klass: pointer): PTooltipsClass
-proc IS_TOOLTIPS*(obj: pointer): bool
-proc IS_TOOLTIPS_CLASS*(klass: pointer): bool
-proc TOOLTIPS_GET_CLASS*(obj: pointer): PTooltipsClass
-proc delay*(a: PTooltips): guint
-proc set_delay*(a: PTooltips, `delay`: guint)
-proc enabled*(a: PTooltips): guint
-proc set_enabled*(a: PTooltips, `enabled`: guint)
-proc have_grab*(a: PTooltips): guint
-proc set_have_grab*(a: PTooltips, `have_grab`: guint)
-proc use_sticky_delay*(a: PTooltips): guint
-proc set_use_sticky_delay*(a: PTooltips, `use_sticky_delay`: guint)
-proc tooltips_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_tooltips_get_type".}
-proc tooltips_new*(): PTooltips{.cdecl, dynlib: lib, importc: "gtk_tooltips_new".}
-proc enable*(tooltips: PTooltips){.cdecl, dynlib: lib, 
-    importc: "gtk_tooltips_enable".}
-proc disable*(tooltips: PTooltips){.cdecl, dynlib: lib, 
-    importc: "gtk_tooltips_disable".}
-proc set_tip*(tooltips: PTooltips, widget: PWidget, tip_text: cstring, 
-                       tip_private: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_tooltips_set_tip".}
-proc tooltips_data_get*(widget: PWidget): PTooltipsData{.cdecl, dynlib: lib, 
-    importc: "gtk_tooltips_data_get".}
-proc force_window*(tooltips: PTooltips){.cdecl, dynlib: lib, 
-    importc: "gtk_tooltips_force_window".}
-proc tooltips_toggle_keyboard_mode*(widget: PWidget){.cdecl, dynlib: lib, 
-    importc: "_gtk_tooltips_toggle_keyboard_mode".}
-const 
-  bm_TGtkToolbar_style_set* = 0x0001'i16
-  bp_TGtkToolbar_style_set* = 0'i16
-  bm_TGtkToolbar_icon_size_set* = 0x0002'i16
-  bp_TGtkToolbar_icon_size_set* = 1'i16
-
-proc TYPE_TOOLBAR*(): GType
-proc TOOLBAR*(obj: pointer): PToolbar
-proc TOOLBAR_CLASS*(klass: pointer): PToolbarClass
-proc IS_TOOLBAR*(obj: pointer): bool
-proc IS_TOOLBAR_CLASS*(klass: pointer): bool
-proc TOOLBAR_GET_CLASS*(obj: pointer): PToolbarClass
-proc style_set*(a: PToolbar): guint
-proc set_style_set*(a: PToolbar, `style_set`: guint)
-proc icon_size_set*(a: PToolbar): guint
-proc set_icon_size_set*(a: PToolbar, `icon_size_set`: guint)
-proc toolbar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                 importc: "gtk_toolbar_get_type".}
-proc toolbar_new*(): PToolbar{.cdecl, dynlib: lib, importc: "gtk_toolbar_new".}
-proc append_item*(toolbar: PToolbar, text: cstring, 
-                          tooltip_text: cstring, tooltip_private_text: cstring, 
-                          icon: PWidget, callback: TSignalFunc, 
-                          user_data: gpointer): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_append_item".}
-proc prepend_item*(toolbar: PToolbar, text: cstring, 
-                           tooltip_text: cstring, tooltip_private_text: cstring, 
-                           icon: PWidget, callback: TSignalFunc, 
-                           user_data: gpointer): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_prepend_item".}
-proc insert_item*(toolbar: PToolbar, text: cstring, 
-                          tooltip_text: cstring, tooltip_private_text: cstring, 
-                          icon: PWidget, callback: TSignalFunc, 
-                          user_data: gpointer, position: gint): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_insert_item".}
-proc insert_stock*(toolbar: PToolbar, stock_id: cstring, 
-                           tooltip_text: cstring, tooltip_private_text: cstring, 
-                           callback: TSignalFunc, user_data: gpointer, 
-                           position: gint): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_insert_stock".}
-proc append_space*(toolbar: PToolbar){.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_append_space".}
-proc prepend_space*(toolbar: PToolbar){.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_prepend_space".}
-proc insert_space*(toolbar: PToolbar, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_insert_space".}
-proc remove_space*(toolbar: PToolbar, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_remove_space".}
-proc append_element*(toolbar: PToolbar, thetype: TToolbarChildType, 
-                             widget: PWidget, text: cstring, 
-                             tooltip_text: cstring, 
-                             tooltip_private_text: cstring, icon: PWidget, 
-                             callback: TSignalFunc, user_data: gpointer): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_toolbar_append_element".}
-proc prepend_element*(toolbar: PToolbar, thetype: TToolbarChildType, 
-                              widget: PWidget, text: cstring, 
-                              tooltip_text: cstring, 
-                              tooltip_private_text: cstring, icon: PWidget, 
-                              callback: TSignalFunc, user_data: gpointer): PWidget{.
-    cdecl, dynlib: lib, importc: "gtk_toolbar_prepend_element".}
-proc insert_element*(toolbar: PToolbar, thetype: TToolbarChildType, 
-                             widget: PWidget, text: cstring, 
-                             tooltip_text: cstring, 
-                             tooltip_private_text: cstring, icon: PWidget, 
-                             callback: TSignalFunc, user_data: gpointer, 
-                             position: gint): PWidget{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_insert_element".}
-proc append_widget*(toolbar: PToolbar, widget: PWidget, 
-                            tooltip_text: cstring, tooltip_private_text: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_toolbar_append_widget".}
-proc prepend_widget*(toolbar: PToolbar, widget: PWidget, 
-                             tooltip_text: cstring, 
-                             tooltip_private_text: cstring){.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_prepend_widget".}
-proc insert_widget*(toolbar: PToolbar, widget: PWidget, 
-                            tooltip_text: cstring, 
-                            tooltip_private_text: cstring, position: gint){.
-    cdecl, dynlib: lib, importc: "gtk_toolbar_insert_widget".}
-proc set_orientation*(toolbar: PToolbar, orientation: TOrientation){.
-    cdecl, dynlib: lib, importc: "gtk_toolbar_set_orientation".}
-proc set_style*(toolbar: PToolbar, style: TToolbarStyle){.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_set_style".}
-proc set_icon_size*(toolbar: PToolbar, icon_size: TIconSize){.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_set_icon_size".}
-proc set_tooltips*(toolbar: PToolbar, enable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_set_tooltips".}
-proc unset_style*(toolbar: PToolbar){.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_unset_style".}
-proc unset_icon_size*(toolbar: PToolbar){.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_unset_icon_size".}
-proc get_orientation*(toolbar: PToolbar): TOrientation{.cdecl, 
-    dynlib: lib, importc: "gtk_toolbar_get_orientation".}
-proc get_style*(toolbar: PToolbar): TToolbarStyle{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_get_style".}
-proc get_icon_size*(toolbar: PToolbar): TIconSize{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_get_icon_size".}
-proc get_tooltips*(toolbar: PToolbar): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_toolbar_get_tooltips".}
-const 
-  bm_TGtkTree_selection_mode* = 0x0003'i16
-  bp_TGtkTree_selection_mode* = 0'i16
-  bm_TGtkTree_view_mode* = 0x0004'i16
-  bp_TGtkTree_view_mode* = 2'i16
-  bm_TGtkTree_view_line* = 0x0008'i16
-  bp_TGtkTree_view_line* = 3'i16
-
-proc TYPE_TREE*(): GType
-proc TREE*(obj: pointer): PTree
-proc TREE_CLASS*(klass: pointer): PTreeClass
-proc IS_TREE*(obj: pointer): bool
-proc IS_TREE_CLASS*(klass: pointer): bool
-proc TREE_GET_CLASS*(obj: pointer): PTreeClass
-proc IS_ROOT_TREE*(obj: pointer): bool
-proc TREE_ROOT_TREE*(obj: pointer): PTree
-proc TREE_SELECTION_OLD*(obj: pointer): PGList
-proc selection_mode*(a: PTree): guint
-proc set_selection_mode*(a: PTree, `selection_mode`: guint)
-proc view_mode*(a: PTree): guint
-proc set_view_mode*(a: PTree, `view_mode`: guint)
-proc view_line*(a: PTree): guint
-proc set_view_line*(a: PTree, `view_line`: guint)
-proc tree_get_type*(): TType{.cdecl, dynlib: lib, importc: "gtk_tree_get_type".}
-proc tree_new*(): PTree{.cdecl, dynlib: lib, importc: "gtk_tree_new".}
-proc append*(tree: PTree, tree_item: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_append".}
-proc prepend*(tree: PTree, tree_item: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_prepend".}
-proc insert*(tree: PTree, tree_item: PWidget, position: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_insert".}
-proc remove_items*(tree: PTree, items: PGList){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_remove_items".}
-proc clear_items*(tree: PTree, start: gint, theEnd: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_clear_items".}
-proc select_item*(tree: PTree, item: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_select_item".}
-proc unselect_item*(tree: PTree, item: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_unselect_item".}
-proc select_child*(tree: PTree, tree_item: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_select_child".}
-proc unselect_child*(tree: PTree, tree_item: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_unselect_child".}
-proc child_position*(tree: PTree, child: PWidget): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_child_position".}
-proc set_selection_mode*(tree: PTree, mode: TSelectionMode){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_set_selection_mode".}
-proc set_view_mode*(tree: PTree, mode: TTreeViewMode){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_set_view_mode".}
-proc set_view_lines*(tree: PTree, flag: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_set_view_lines".}
-proc remove_item*(tree: PTree, child: PWidget){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_remove_item".}
-proc TYPE_TREE_DRAG_SOURCE*(): GType
-proc TREE_DRAG_SOURCE*(obj: pointer): PTreeDragSource
-proc IS_TREE_DRAG_SOURCE*(obj: pointer): bool
-proc TREE_DRAG_SOURCE_GET_IFACE*(obj: pointer): PTreeDragSourceIface
-proc tree_drag_source_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_drag_source_get_type".}
-proc source_row_draggable*(drag_source: PTreeDragSource, 
-                                     path: PTreePath): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_drag_source_row_draggable".}
-proc source_drag_data_delete*(drag_source: PTreeDragSource, 
-                                        path: PTreePath): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_drag_source_drag_data_delete".}
-proc source_drag_data_get*(drag_source: PTreeDragSource, 
-                                     path: PTreePath, 
-                                     selection_data: PSelectionData): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_drag_source_drag_data_get".}
-proc TYPE_TREE_DRAG_DEST*(): GType
-proc TREE_DRAG_DEST*(obj: pointer): PTreeDragDest
-proc IS_TREE_DRAG_DEST*(obj: pointer): bool
-proc TREE_DRAG_DEST_GET_IFACE*(obj: pointer): PTreeDragDestIface
-proc tree_drag_dest_get_type*(): GType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_tree_drag_dest_get_type".}
-proc dest_drag_data_received*(drag_dest: PTreeDragDest, 
-                                        dest: PTreePath, 
-                                        selection_data: PSelectionData): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_drag_dest_drag_data_received".}
-proc dest_row_drop_possible*(drag_dest: PTreeDragDest, 
-                                       dest_path: PTreePath, 
-                                       selection_data: PSelectionData): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_drag_dest_row_drop_possible".}
-proc tree_set_row_drag_data*(selection_data: PSelectionData, 
-                             tree_model: PTreeModel, path: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_set_row_drag_data".}
-const 
-  bm_TGtkTreeItem_expanded* = 0x0001'i16
-  bp_TGtkTreeItem_expanded* = 0'i16
-
-proc TYPE_TREE_ITEM*(): GType
-proc TREE_ITEM*(obj: pointer): PTreeItem
-proc TREE_ITEM_CLASS*(klass: pointer): PTreeItemClass
-proc IS_TREE_ITEM*(obj: pointer): bool
-proc IS_TREE_ITEM_CLASS*(klass: pointer): bool
-proc TREE_ITEM_GET_CLASS*(obj: pointer): PTreeItemClass
-proc TREE_ITEM_SUBTREE*(obj: pointer): PWidget
-proc expanded*(a: PTreeItem): guint
-proc set_expanded*(a: PTreeItem, `expanded`: guint)
-proc tree_item_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_tree_item_get_type".}
-proc tree_item_new*(): PTreeItem{.cdecl, dynlib: lib, 
-                                  importc: "gtk_tree_item_new".}
-proc tree_item_new*(`label`: cstring): PTreeItem{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_new_with_label".}
-proc set_subtree*(tree_item: PTreeItem, subtree: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_item_set_subtree".}
-proc remove_subtree*(tree_item: PTreeItem){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_remove_subtree".}
-proc select*(tree_item: PTreeItem){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_select".}
-proc deselect*(tree_item: PTreeItem){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_deselect".}
-proc expand*(tree_item: PTreeItem){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_expand".}
-proc collapse*(tree_item: PTreeItem){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_item_collapse".}
-proc TYPE_TREE_SELECTION*(): GType
-proc TREE_SELECTION*(obj: pointer): PTreeSelection
-proc TREE_SELECTION_CLASS*(klass: pointer): PTreeSelectionClass
-proc IS_TREE_SELECTION*(obj: pointer): bool
-proc IS_TREE_SELECTION_CLASS*(klass: pointer): bool
-proc TREE_SELECTION_GET_CLASS*(obj: pointer): PTreeSelectionClass
-proc tree_selection_get_type*(): TType{.cdecl, dynlib: lib, 
-                                        importc: "gtk_tree_selection_get_type".}
-proc set_mode*(selection: PTreeSelection, thetype: TSelectionMode){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_set_mode".}
-proc get_mode*(selection: PTreeSelection): TSelectionMode{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_get_mode".}
-proc set_select_function*(selection: PTreeSelection, 
-    fun: TTreeSelectionFunc, data: gpointer, destroy: TDestroyNotify){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_set_select_function".}
-proc get_user_data*(selection: PTreeSelection): gpointer{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_get_user_data".}
-proc get_tree_view*(selection: PTreeSelection): PTreeView{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_get_tree_view".}
-proc get_selected*(selection: PTreeSelection, 
-                                  model: PPGtkTreeModel, iter: PTreeIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_get_selected".}
-proc get_selected_rows*(selection: PTreeSelection, 
-                                       model: PPGtkTreeModel): PGList{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_get_selected_rows".}
-proc selected_foreach*(selection: PTreeSelection, 
-                                      fun: TTreeSelectionForeachFunc, 
-                                      data: gpointer){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_selection_selected_foreach".}
-proc select_path*(selection: PTreeSelection, path: PTreePath){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_select_path".}
-proc unselect_path*(selection: PTreeSelection, path: PTreePath){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_unselect_path".}
-proc select_iter*(selection: PTreeSelection, iter: PTreeIter){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_select_iter".}
-proc unselect_iter*(selection: PTreeSelection, iter: PTreeIter){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_unselect_iter".}
-proc path_is_selected*(selection: PTreeSelection, path: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_path_is_selected".}
-proc iter_is_selected*(selection: PTreeSelection, iter: PTreeIter): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_iter_is_selected".}
-proc select_all*(selection: PTreeSelection){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_selection_select_all".}
-proc unselect_all*(selection: PTreeSelection){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_selection_unselect_all".}
-proc select_range*(selection: PTreeSelection, 
-                                  start_path: PTreePath, end_path: PTreePath){.
-    cdecl, dynlib: lib, importc: "gtk_tree_selection_select_range".}
-const 
-  bm_TGtkTreeStore_columns_dirty* = 0x0001'i16
-  bp_TGtkTreeStore_columns_dirty* = 0'i16
-
-proc TYPE_TREE_STORE*(): GType
-proc TREE_STORE*(obj: pointer): PTreeStore
-proc TREE_STORE_CLASS*(klass: pointer): PTreeStoreClass
-proc IS_TREE_STORE*(obj: pointer): bool
-proc IS_TREE_STORE_CLASS*(klass: pointer): bool
-proc TREE_STORE_GET_CLASS*(obj: pointer): PTreeStoreClass
-proc columns_dirty*(a: PTreeStore): guint
-proc set_columns_dirty*(a: PTreeStore, `columns_dirty`: guint)
-proc tree_store_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_tree_store_get_type".}
-proc tree_store_newv*(n_columns: gint, types: PGType): PTreeStore{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_store_newv".}
-proc set_column_types*(tree_store: PTreeStore, n_columns: gint, 
-                                  types: PGType){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_set_column_types".}
-proc set_value*(tree_store: PTreeStore, iter: PTreeIter, 
-                           column: gint, value: PGValue){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_set_value".}
-proc remove*(tree_store: PTreeStore, iter: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_store_remove".}
-proc insert*(tree_store: PTreeStore, iter: PTreeIter, 
-                        parent: PTreeIter, position: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_insert".}
-proc insert_before*(tree_store: PTreeStore, iter: PTreeIter, 
-                               parent: PTreeIter, sibling: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_store_insert_before".}
-proc insert_after*(tree_store: PTreeStore, iter: PTreeIter, 
-                              parent: PTreeIter, sibling: PTreeIter){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_store_insert_after".}
-proc prepend*(tree_store: PTreeStore, iter: PTreeIter, 
-                         parent: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_prepend".}
-proc append*(tree_store: PTreeStore, iter: PTreeIter, 
-                        parent: PTreeIter){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_append".}
-proc is_ancestor*(tree_store: PTreeStore, iter: PTreeIter, 
-                             descendant: PTreeIter): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_store_is_ancestor".}
-proc iter_depth*(tree_store: PTreeStore, iter: PTreeIter): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_store_iter_depth".}
-proc clear*(tree_store: PTreeStore){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_store_clear".}
-const 
-  bm_TGtkTreeViewColumn_visible* = 0x0001'i16
-  bp_TGtkTreeViewColumn_visible* = 0'i16
-  bm_TGtkTreeViewColumn_resizable* = 0x0002'i16
-  bp_TGtkTreeViewColumn_resizable* = 1'i16
-  bm_TGtkTreeViewColumn_clickable* = 0x0004'i16
-  bp_TGtkTreeViewColumn_clickable* = 2'i16
-  bm_TGtkTreeViewColumn_dirty* = 0x0008'i16
-  bp_TGtkTreeViewColumn_dirty* = 3'i16
-  bm_TGtkTreeViewColumn_show_sort_indicator* = 0x0010'i16
-  bp_TGtkTreeViewColumn_show_sort_indicator* = 4'i16
-  bm_TGtkTreeViewColumn_maybe_reordered* = 0x0020'i16
-  bp_TGtkTreeViewColumn_maybe_reordered* = 5'i16
-  bm_TGtkTreeViewColumn_reorderable* = 0x0040'i16
-  bp_TGtkTreeViewColumn_reorderable* = 6'i16
-  bm_TGtkTreeViewColumn_use_resized_width* = 0x0080'i16
-  bp_TGtkTreeViewColumn_use_resized_width* = 7'i16
-
-proc TYPE_TREE_VIEW_COLUMN*(): GType
-proc TREE_VIEW_COLUMN*(obj: pointer): PTreeViewColumn
-proc TREE_VIEW_COLUMN_CLASS*(klass: pointer): PTreeViewColumnClass
-proc IS_TREE_VIEW_COLUMN*(obj: pointer): bool
-proc IS_TREE_VIEW_COLUMN_CLASS*(klass: pointer): bool
-proc TREE_VIEW_COLUMN_GET_CLASS*(obj: pointer): PTreeViewColumnClass
-proc visible*(a: PTreeViewColumn): guint
-proc set_visible*(a: PTreeViewColumn, `visible`: guint)
-proc resizable*(a: PTreeViewColumn): guint
-proc set_resizable*(a: PTreeViewColumn, `resizable`: guint)
-proc clickable*(a: PTreeViewColumn): guint
-proc set_clickable*(a: PTreeViewColumn, `clickable`: guint)
-proc dirty*(a: PTreeViewColumn): guint
-proc set_dirty*(a: PTreeViewColumn, `dirty`: guint)
-proc show_sort_indicator*(a: PTreeViewColumn): guint
-proc set_show_sort_indicator*(a: PTreeViewColumn, 
-                              `show_sort_indicator`: guint)
-proc maybe_reordered*(a: PTreeViewColumn): guint
-proc set_maybe_reordered*(a: PTreeViewColumn, `maybe_reordered`: guint)
-proc reorderable*(a: PTreeViewColumn): guint
-proc set_reorderable*(a: PTreeViewColumn, `reorderable`: guint)
-proc use_resized_width*(a: PTreeViewColumn): guint
-proc set_use_resized_width*(a: PTreeViewColumn, `use_resized_width`: guint)
-proc tree_view_column_get_type*(): TType{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_get_type".}
-proc tree_view_column_new*(): PTreeViewColumn{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_new".}
-proc column_pack_start*(tree_column: PTreeViewColumn, 
-                                  cell: PCellRenderer, expand: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_pack_start".}
-proc column_pack_end*(tree_column: PTreeViewColumn, 
-                                cell: PCellRenderer, expand: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_pack_end".}
-proc column_clear*(tree_column: PTreeViewColumn){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_clear".}
-proc column_get_cell_renderers*(tree_column: PTreeViewColumn): PGList{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_cell_renderers".}
-proc column_add_attribute*(tree_column: PTreeViewColumn, 
-                                     cell_renderer: PCellRenderer, 
-                                     attribute: cstring, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_add_attribute".}
-proc column_set_cell_data_func*(tree_column: PTreeViewColumn, 
-    cell_renderer: PCellRenderer, fun: TTreeCellDataFunc, func_data: gpointer, 
-    destroy: TDestroyNotify){.cdecl, dynlib: lib, importc: "gtk_tree_view_column_set_cell_data_func".}
-proc column_clear_attributes*(tree_column: PTreeViewColumn, 
-                                        cell_renderer: PCellRenderer){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_clear_attributes".}
-proc column_set_spacing*(tree_column: PTreeViewColumn, spacing: gint){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_set_spacing".}
-proc column_get_spacing*(tree_column: PTreeViewColumn): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_spacing".}
-proc column_set_visible*(tree_column: PTreeViewColumn, 
-                                   visible: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_visible".}
-proc column_get_visible*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_visible".}
-proc column_set_resizable*(tree_column: PTreeViewColumn, 
-                                     resizable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_resizable".}
-proc column_get_resizable*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_resizable".}
-proc column_set_sizing*(tree_column: PTreeViewColumn, 
-                                  thetype: TTreeViewColumnSizing){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_set_sizing".}
-proc column_get_sizing*(tree_column: PTreeViewColumn): TTreeViewColumnSizing{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_sizing".}
-proc column_get_width*(tree_column: PTreeViewColumn): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_width".}
-proc column_get_fixed_width*(tree_column: PTreeViewColumn): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_fixed_width".}
-proc column_set_fixed_width*(tree_column: PTreeViewColumn, 
-                                       fixed_width: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_fixed_width".}
-proc column_set_min_width*(tree_column: PTreeViewColumn, 
-                                     min_width: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_min_width".}
-proc column_get_min_width*(tree_column: PTreeViewColumn): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_min_width".}
-proc column_set_max_width*(tree_column: PTreeViewColumn, 
-                                     max_width: gint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_max_width".}
-proc column_get_max_width*(tree_column: PTreeViewColumn): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_max_width".}
-proc column_clicked*(tree_column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_clicked".}
-proc column_set_title*(tree_column: PTreeViewColumn, title: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_set_title".}
-proc column_get_title*(tree_column: PTreeViewColumn): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_title".}
-proc column_set_clickable*(tree_column: PTreeViewColumn, 
-                                     clickable: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_clickable".}
-proc column_get_clickable*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_clickable".}
-proc column_set_widget*(tree_column: PTreeViewColumn, widget: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_set_widget".}
-proc column_get_widget*(tree_column: PTreeViewColumn): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_get_widget".}
-proc column_set_alignment*(tree_column: PTreeViewColumn, 
-                                     xalign: gfloat){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_alignment".}
-proc column_get_alignment*(tree_column: PTreeViewColumn): gfloat{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_alignment".}
-proc column_set_reorderable*(tree_column: PTreeViewColumn, 
-                                       reorderable: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_column_set_reorderable".}
-proc column_get_reorderable*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_reorderable".}
-proc column_set_sort_column_id*(tree_column: PTreeViewColumn, 
-    sort_column_id: gint){.cdecl, dynlib: lib, 
-                           importc: "gtk_tree_view_column_set_sort_column_id".}
-proc column_get_sort_column_id*(tree_column: PTreeViewColumn): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_sort_column_id".}
-proc column_set_sort_indicator*(tree_column: PTreeViewColumn, 
-    setting: gboolean){.cdecl, dynlib: lib, 
-                        importc: "gtk_tree_view_column_set_sort_indicator".}
-proc column_get_sort_indicator*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_sort_indicator".}
-proc column_set_sort_order*(tree_column: PTreeViewColumn, 
-                                      order: TSortType){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_set_sort_order".}
-proc column_get_sort_order*(tree_column: PTreeViewColumn): TSortType{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_sort_order".}
-proc column_cell_set_cell_data*(tree_column: PTreeViewColumn, 
-    tree_model: PTreeModel, iter: PTreeIter, is_expander: gboolean, 
-    is_expanded: gboolean){.cdecl, dynlib: lib, 
-                            importc: "gtk_tree_view_column_cell_set_cell_data".}
-proc column_cell_get_size*(tree_column: PTreeViewColumn, 
-                                     cell_area: gdk2.PRectangle, x_offset: Pgint, 
-                                     y_offset: Pgint, width: Pgint, 
-                                     height: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_cell_get_size".}
-proc column_cell_is_visible*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_cell_is_visible".}
-proc column_focus_cell*(tree_column: PTreeViewColumn, 
-                                  cell: PCellRenderer){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_column_focus_cell".}
-proc column_set_expand*(tree_column: PTreeViewColumn, Expand: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_set_expand".}
-proc column_get_expand*(tree_column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_column_get_expand".}
-const 
-  RBNODE_BLACK* = 1 shl 0
-  RBNODE_RED* = 1 shl 1
-  RBNODE_IS_PARENT* = 1 shl 2
-  RBNODE_IS_SELECTED* = 1 shl 3
-  RBNODE_IS_PRELIT* = 1 shl 4
-  RBNODE_IS_SEMI_COLLAPSED* = 1 shl 5
-  RBNODE_IS_SEMI_EXPANDED* = 1 shl 6
-  RBNODE_INVALID* = 1 shl 7
-  RBNODE_COLUMN_INVALID* = 1 shl 8
-  RBNODE_DESCENDANTS_INVALID* = 1 shl 9
-  RBNODE_NON_COLORS* = RBNODE_IS_PARENT or RBNODE_IS_SELECTED or
-      RBNODE_IS_PRELIT or RBNODE_IS_SEMI_COLLAPSED or RBNODE_IS_SEMI_EXPANDED or
-      RBNODE_INVALID or RBNODE_COLUMN_INVALID or RBNODE_DESCENDANTS_INVALID
-
-const 
-  bm_TGtkRBNode_flags* = 0x3FFF'i16
-  bp_TGtkRBNode_flags* = 0'i16
-  bm_TGtkRBNode_parity* = 0x4000'i16
-  bp_TGtkRBNode_parity* = 14'i16
-
-proc flags*(a: PRBNode): guint
-proc set_flags*(a: PRBNode, `flags`: guint)
-proc parity*(a: PRBNode): guint
-proc set_parity*(a: PRBNode, `parity`: guint)
-proc GET_COLOR*(node: PRBNode): guint
-proc SET_COLOR*(node: PRBNode, color: guint)
-proc GET_HEIGHT*(node: PRBNode): gint
-proc SET_FLAG*(node: PRBNode, flag: guint16)
-proc UNSET_FLAG*(node: PRBNode, flag: guint16)
-proc FLAG_SET*(node: PRBNode, flag: guint): bool
-proc rbtree_push_allocator*(allocator: PGAllocator){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_push_allocator".}
-proc rbtree_pop_allocator*(){.cdecl, dynlib: lib, 
-                              importc: "_gtk_rbtree_pop_allocator".}
-proc rbtree_new*(): PRBTree{.cdecl, dynlib: lib, importc: "_gtk_rbtree_new".}
-proc free*(tree: PRBTree){.cdecl, dynlib: lib, 
-                                  importc: "_gtk_rbtree_free".}
-proc remove*(tree: PRBTree){.cdecl, dynlib: lib, 
-                                    importc: "_gtk_rbtree_remove".}
-proc destroy*(tree: PRBTree){.cdecl, dynlib: lib, 
-                                     importc: "_gtk_rbtree_destroy".}
-proc insert_before*(tree: PRBTree, node: PRBNode, height: gint, 
-                           valid: gboolean): PRBNode{.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_insert_before".}
-proc insert_after*(tree: PRBTree, node: PRBNode, height: gint, 
-                          valid: gboolean): PRBNode{.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_insert_after".}
-proc remove_node*(tree: PRBTree, node: PRBNode){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_remove_node".}
-proc reorder*(tree: PRBTree, new_order: Pgint, length: gint){.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_reorder".}
-proc find_count*(tree: PRBTree, count: gint): PRBNode{.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_find_count".}
-proc node_set_height*(tree: PRBTree, node: PRBNode, height: gint){.
-    cdecl, dynlib: lib, importc: "_gtk_rbtree_node_set_height".}
-proc node_mark_invalid*(tree: PRBTree, node: PRBNode){.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_node_mark_invalid".}
-proc node_mark_valid*(tree: PRBTree, node: PRBNode){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_node_mark_valid".}
-proc column_invalid*(tree: PRBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_column_invalid".}
-proc mark_invalid*(tree: PRBTree){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_mark_invalid".}
-proc set_fixed_height*(tree: PRBTree, height: gint){.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_set_fixed_height".}
-proc node_find_offset*(tree: PRBTree, node: PRBNode): gint{.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_node_find_offset".}
-proc node_find_parity*(tree: PRBTree, node: PRBNode): gint{.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_node_find_parity".}
-proc traverse*(tree: PRBTree, node: PRBNode, order: TGTraverseType, 
-                      fun: TRBTreeTraverseFunc, data: gpointer){.cdecl, 
-    dynlib: lib, importc: "_gtk_rbtree_traverse".}
-proc next*(tree: PRBTree, node: PRBNode): PRBNode{.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_next".}
-proc prev*(tree: PRBTree, node: PRBNode): PRBNode{.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_prev".}
-proc get_depth*(tree: PRBTree): gint{.cdecl, dynlib: lib, 
-    importc: "_gtk_rbtree_get_depth".}
-const 
-  TREE_VIEW_DRAG_WIDTH* = 6
-  TREE_VIEW_IS_LIST* = 1 shl 0
-  TREE_VIEW_SHOW_EXPANDERS* = 1 shl 1
-  TREE_VIEW_IN_COLUMN_RESIZE* = 1 shl 2
-  TREE_VIEW_ARROW_PRELIT* = 1 shl 3
-  TREE_VIEW_HEADERS_VISIBLE* = 1 shl 4
-  TREE_VIEW_DRAW_KEYFOCUS* = 1 shl 5
-  TREE_VIEW_MODEL_SETUP* = 1 shl 6
-  TREE_VIEW_IN_COLUMN_DRAG* = 1 shl 7
-  DRAG_COLUMN_WINDOW_STATE_UNSET* = 0
-  DRAG_COLUMN_WINDOW_STATE_ORIGINAL* = 1
-  DRAG_COLUMN_WINDOW_STATE_ARROW* = 2
-  DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT* = 3
-  DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT* = 4
-
-proc SET_FLAG*(tree_view: PTreeView, flag: guint)
-proc UNSET_FLAG*(tree_view: PTreeView, flag: guint)
-proc FLAG_SET*(tree_view: PTreeView, flag: guint): bool
-proc HEADER_HEIGHT*(tree_view: PTreeView): int32
-proc COLUMN_REQUESTED_WIDTH*(column: PTreeViewColumn): int32
-proc DRAW_EXPANDERS*(tree_view: PTreeView): bool
-proc COLUMN_DRAG_DEAD_MULTIPLIER*(tree_view: PTreeView): int32
-const 
-  bm_TGtkTreeViewPrivate_scroll_to_use_align* = 0x0001'i16
-  bp_TGtkTreeViewPrivate_scroll_to_use_align* = 0'i16
-  bm_TGtkTreeViewPrivate_fixed_height_check* = 0x0002'i16
-  bp_TGtkTreeViewPrivate_fixed_height_check* = 1'i16
-  bm_TGtkTreeViewPrivate_reorderable* = 0x0004'i16
-  bp_TGtkTreeViewPrivate_reorderable* = 2'i16
-  bm_TGtkTreeViewPrivate_header_has_focus* = 0x0008'i16
-  bp_TGtkTreeViewPrivate_header_has_focus* = 3'i16
-  bm_TGtkTreeViewPrivate_drag_column_window_state* = 0x0070'i16
-  bp_TGtkTreeViewPrivate_drag_column_window_state* = 4'i16
-  bm_TGtkTreeViewPrivate_has_rules* = 0x0080'i16
-  bp_TGtkTreeViewPrivate_has_rules* = 7'i16
-  bm_TGtkTreeViewPrivate_mark_rows_col_dirty* = 0x0100'i16
-  bp_TGtkTreeViewPrivate_mark_rows_col_dirty* = 8'i16
-  bm_TGtkTreeViewPrivate_enable_search* = 0x0200'i16
-  bp_TGtkTreeViewPrivate_enable_search* = 9'i16
-  bm_TGtkTreeViewPrivate_disable_popdown* = 0x0400'i16
-  bp_TGtkTreeViewPrivate_disable_popdown* = 10'i16
-
-proc scroll_to_use_align*(a: PTreeViewPrivate): guint
-proc set_scroll_to_use_align*(a: PTreeViewPrivate, 
-                              `scroll_to_use_align`: guint)
-proc fixed_height_check*(a: PTreeViewPrivate): guint
-proc set_fixed_height_check*(a: PTreeViewPrivate, 
-                             `fixed_height_check`: guint)
-proc reorderable*(a: PTreeViewPrivate): guint
-proc set_reorderable*(a: PTreeViewPrivate, `reorderable`: guint)
-proc header_has_focus*(a: PTreeViewPrivate): guint
-proc set_header_has_focus*(a: PTreeViewPrivate, `header_has_focus`: guint)
-proc drag_column_window_state*(a: PTreeViewPrivate): guint
-proc set_drag_column_window_state*(a: PTreeViewPrivate, 
-                                   `drag_column_window_state`: guint)
-proc has_rules*(a: PTreeViewPrivate): guint
-proc set_has_rules*(a: PTreeViewPrivate, `has_rules`: guint)
-proc mark_rows_col_dirty*(a: PTreeViewPrivate): guint
-proc set_mark_rows_col_dirty*(a: PTreeViewPrivate, 
-                              `mark_rows_col_dirty`: guint)
-proc enable_search*(a: PTreeViewPrivate): guint
-proc set_enable_search*(a: PTreeViewPrivate, `enable_search`: guint)
-proc disable_popdown*(a: PTreeViewPrivate): guint
-proc set_disable_popdown*(a: PTreeViewPrivate, `disable_popdown`: guint)
-proc internal_select_node*(selection: PTreeSelection, 
-    node: PRBNode, tree: PRBTree, path: PTreePath, state: gdk2.TModifierType, 
-    override_browse_mode: gboolean){.cdecl, dynlib: lib, importc: "_gtk_tree_selection_internal_select_node".}
-proc find_node*(tree_view: PTreeView, path: PTreePath, 
-                          tree: var PRBTree, node: var PRBNode): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_find_node".}
-proc find_path*(tree_view: PTreeView, tree: PRBTree, node: PRBNode): PTreePath{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_find_path".}
-proc child_move_resize*(tree_view: PTreeView, widget: PWidget, 
-                                  x: gint, y: gint, width: gint, height: gint){.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_child_move_resize".}
-proc queue_draw_node*(tree_view: PTreeView, tree: PRBTree, 
-                                node: PRBNode, clip_rect: gdk2.PRectangle){.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_queue_draw_node".}
-proc column_realize_button*(column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_realize_button".}
-proc column_unrealize_button*(column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_unrealize_button".}
-proc column_set_tree_view*(column: PTreeViewColumn, 
-                                     tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "_gtk_tree_view_column_set_tree_view".}
-proc column_unset_tree_view*(column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_unset_tree_view".}
-proc column_set_width*(column: PTreeViewColumn, width: gint){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_set_width".}
-proc column_start_drag*(tree_view: PTreeView, column: PTreeViewColumn){.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_start_drag".}
-proc column_start_editing*(tree_column: PTreeViewColumn, 
-                                     editable_widget: PCellEditable){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_start_editing".}
-proc column_stop_editing*(tree_column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_stop_editing".}
-proc install_mark_rows_col_dirty*(tree_view: PTreeView){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_install_mark_rows_col_dirty".}
-proc DOgtk_tree_view_column_autosize*(tree_view: PTreeView, 
-                                      column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_autosize".}
-proc column_has_editable_cell*(column: PTreeViewColumn): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_has_editable_cell".}
-proc column_get_edited_cell*(column: PTreeViewColumn): PCellRenderer{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_get_edited_cell".}
-proc column_count_special_cells*(column: PTreeViewColumn): gint{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_count_special_cells".}
-proc column_get_cell_at_pos*(column: PTreeViewColumn, x: gint): PCellRenderer{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_get_cell_at_pos".}
-proc tree_selection_new*(): PTreeSelection{.cdecl, dynlib: lib, 
-    importc: "_gtk_tree_selection_new".}
-proc selection_new*(tree_view: PTreeView): PTreeSelection{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_selection_new_with_tree_view".}
-proc set_tree_view*(selection: PTreeSelection, 
-                                   tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "_gtk_tree_selection_set_tree_view".}
-proc column_cell_render*(tree_column: PTreeViewColumn, 
-                                   window: gdk2.PWindow, 
-                                   background_area: gdk2.PRectangle, 
-                                   cell_area: gdk2.PRectangle, 
-                                   expose_area: gdk2.PRectangle, flags: guint){.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_cell_render".}
-proc column_cell_focus*(tree_column: PTreeViewColumn, direction: gint, 
-                                  left: gboolean, right: gboolean): gboolean{.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_cell_focus".}
-proc column_cell_draw_focus*(tree_column: PTreeViewColumn, 
-                                       window: gdk2.PWindow, 
-                                       background_area: gdk2.PRectangle, 
-                                       cell_area: gdk2.PRectangle, 
-                                       expose_area: gdk2.PRectangle, flags: guint){.
-    cdecl, dynlib: lib, importc: "_gtk_tree_view_column_cell_draw_focus".}
-proc column_cell_set_dirty*(tree_column: PTreeViewColumn, 
-                                      install_handler: gboolean){.cdecl, 
-    dynlib: lib, importc: "_gtk_tree_view_column_cell_set_dirty".}
-proc column_get_neighbor_sizes*(column: PTreeViewColumn, 
-    cell: PCellRenderer, left: Pgint, right: Pgint){.cdecl, dynlib: lib, 
-    importc: "_gtk_tree_view_column_get_neighbor_sizes".}
-proc TYPE_TREE_VIEW*(): GType
-proc TREE_VIEW*(obj: pointer): PTreeView
-proc TREE_VIEW_CLASS*(klass: pointer): PTreeViewClass
-proc IS_TREE_VIEW*(obj: pointer): bool
-proc IS_TREE_VIEW_CLASS*(klass: pointer): bool
-proc TREE_VIEW_GET_CLASS*(obj: pointer): PTreeViewClass
-proc tree_view_get_type*(): TType{.cdecl, dynlib: lib, 
-                                   importc: "gtk_tree_view_get_type".}
-proc tree_view_new*(): PTreeView{.cdecl, dynlib: lib, 
-                                  importc: "gtk_tree_view_new".}
-proc tree_view_new*(model: PTreeModel): PTreeView{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_new_with_model".}
-proc get_model*(tree_view: PTreeView): PTreeModel{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_get_model".}
-proc set_model*(tree_view: PTreeView, model: PTreeModel){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_model".}
-proc get_selection*(tree_view: PTreeView): PTreeSelection{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_selection".}
-proc get_hadjustment*(tree_view: PTreeView): PAdjustment{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_hadjustment".}
-proc set_hadjustment*(tree_view: PTreeView, adjustment: PAdjustment){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_hadjustment".}
-proc get_vadjustment*(tree_view: PTreeView): PAdjustment{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_vadjustment".}
-proc set_vadjustment*(tree_view: PTreeView, adjustment: PAdjustment){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_vadjustment".}
-proc get_headers_visible*(tree_view: PTreeView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_headers_visible".}
-proc set_headers_visible*(tree_view: PTreeView, 
-                                    headers_visible: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_headers_visible".}
-proc columns_autosize*(tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_columns_autosize".}
-proc set_headers_clickable*(tree_view: PTreeView, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_headers_clickable".}
-proc set_rules_hint*(tree_view: PTreeView, setting: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_rules_hint".}
-proc get_rules_hint*(tree_view: PTreeView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_rules_hint".}
-proc append_column*(tree_view: PTreeView, column: PTreeViewColumn): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_append_column".}
-proc remove_column*(tree_view: PTreeView, column: PTreeViewColumn): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_remove_column".}
-proc insert_column*(tree_view: PTreeView, column: PTreeViewColumn, 
-                              position: gint): gint{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_insert_column".}
-proc insert_column_with_data_func*(tree_view: PTreeView, 
-    position: gint, title: cstring, cell: PCellRenderer, 
-    fun: TTreeCellDataFunc, data: gpointer, dnotify: TGDestroyNotify): gint{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_insert_column_with_data_func".}
-proc get_column*(tree_view: PTreeView, n: gint): PTreeViewColumn{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_get_column".}
-proc get_columns*(tree_view: PTreeView): PGList{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_get_columns".}
-proc move_column_after*(tree_view: PTreeView, column: PTreeViewColumn, 
-                                  base_column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_move_column_after".}
-proc set_expander_column*(tree_view: PTreeView, 
-                                    column: PTreeViewColumn){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_expander_column".}
-proc get_expander_column*(tree_view: PTreeView): PTreeViewColumn{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_get_expander_column".}
-proc set_column_drag_function*(tree_view: PTreeView, 
-    fun: TTreeViewColumnDropFunc, user_data: gpointer, destroy: TDestroyNotify){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_column_drag_function".}
-proc scroll_to_point*(tree_view: PTreeView, tree_x: gint, tree_y: gint){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_scroll_to_point".}
-proc scroll_to_cell*(tree_view: PTreeView, path: PTreePath, 
-                               column: PTreeViewColumn, use_align: gboolean, 
-                               row_align: gfloat, col_align: gfloat){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_scroll_to_cell".}
-proc row_activated*(tree_view: PTreeView, path: PTreePath, 
-                              column: PTreeViewColumn){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_row_activated".}
-proc expand_all*(tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_expand_all".}
-proc collapse_all*(tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_collapse_all".}
-proc expand_row*(tree_view: PTreeView, path: PTreePath, 
-                           open_all: gboolean): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_expand_row".}
-proc collapse_row*(tree_view: PTreeView, path: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_collapse_row".}
-proc map_expanded_rows*(tree_view: PTreeView, 
-                                  fun: TTreeViewMappingFunc, data: gpointer){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_map_expanded_rows".}
-proc row_expanded*(tree_view: PTreeView, path: PTreePath): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_row_expanded".}
-proc set_reorderable*(tree_view: PTreeView, reorderable: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_reorderable".}
-proc get_reorderable*(tree_view: PTreeView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_reorderable".}
-proc set_cursor*(tree_view: PTreeView, path: PTreePath, 
-                           focus_column: PTreeViewColumn, 
-                           start_editing: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_set_cursor".}
-proc set_cursor_on_cell*(tree_view: PTreeView, path: PTreePath, 
-                                   focus_column: PTreeViewColumn, 
-                                   focus_cell: PCellRenderer, 
-                                   start_editing: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_set_cursor_on_cell".}
-proc get_bin_window*(tree_view: PTreeView): gdk2.PWindow{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_bin_window".}
-proc get_cell_area*(tree_view: PTreeView, path: PTreePath, 
-                              column: PTreeViewColumn, rect: gdk2.PRectangle){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_get_cell_area".}
-proc get_background_area*(tree_view: PTreeView, path: PTreePath, 
-                                    column: PTreeViewColumn, rect: gdk2.PRectangle){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_get_background_area".}
-proc get_visible_rect*(tree_view: PTreeView, 
-                                 visible_rect: gdk2.PRectangle){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_visible_rect".}
-proc widget_to_tree_coords*(tree_view: PTreeView, wx: gint, wy: gint, 
-                                      tx: Pgint, ty: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_widget_to_tree_coords".}
-proc tree_to_widget_coords*(tree_view: PTreeView, tx: gint, ty: gint, 
-                                      wx: Pgint, wy: Pgint){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_tree_to_widget_coords".}
-proc enable_model_drag_source*(tree_view: PTreeView, 
-    start_button_mask: gdk2.TModifierType, targets: PTargetEntry, n_targets: gint, 
-    actions: gdk2.TDragAction){.cdecl, dynlib: lib, 
-                              importc: "gtk_tree_view_enable_model_drag_source".}
-proc enable_model_drag_dest*(tree_view: PTreeView, 
-                                       targets: PTargetEntry, n_targets: gint, 
-                                       actions: gdk2.TDragAction){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_enable_model_drag_dest".}
-proc unset_rows_drag_source*(tree_view: PTreeView){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_unset_rows_drag_source".}
-proc unset_rows_drag_dest*(tree_view: PTreeView){.cdecl, dynlib: lib, 
-    importc: "gtk_tree_view_unset_rows_drag_dest".}
-proc set_drag_dest_row*(tree_view: PTreeView, path: PTreePath, 
-                                  pos: TTreeViewDropPosition){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_drag_dest_row".}
-proc create_row_drag_icon*(tree_view: PTreeView, path: PTreePath): gdk2.PPixmap{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_create_row_drag_icon".}
-proc set_enable_search*(tree_view: PTreeView, enable_search: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_enable_search".}
-proc get_enable_search*(tree_view: PTreeView): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_enable_search".}
-proc get_search_column*(tree_view: PTreeView): gint{.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_get_search_column".}
-proc set_search_column*(tree_view: PTreeView, column: gint){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_search_column".}
-proc get_search_equal_func*(tree_view: PTreeView): TTreeViewSearchEqualFunc{.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_get_search_equal_func".}
-proc set_search_equal_func*(tree_view: PTreeView, search_equal_func: TTreeViewSearchEqualFunc, 
-                                      search_user_data: gpointer, 
-                                      search_destroy: TDestroyNotify){.cdecl, 
-    dynlib: lib, importc: "gtk_tree_view_set_search_equal_func".}
-proc set_destroy_count_func*(tree_view: PTreeView, 
-                                       fun: TTreeDestroyCountFunc, 
-                                       data: gpointer, destroy: TDestroyNotify){.
-    cdecl, dynlib: lib, importc: "gtk_tree_view_set_destroy_count_func".}
-proc TYPE_VBUTTON_BOX*(): GType
-proc VBUTTON_BOX*(obj: pointer): PVButtonBox
-proc VBUTTON_BOX_CLASS*(klass: pointer): PVButtonBoxClass
-proc IS_VBUTTON_BOX*(obj: pointer): bool
-proc IS_VBUTTON_BOX_CLASS*(klass: pointer): bool
-proc VBUTTON_BOX_GET_CLASS*(obj: pointer): PVButtonBoxClass
-proc vbutton_box_get_type*(): TType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_vbutton_box_get_type".}
-proc vbutton_box_new*(): PVButtonBox{.cdecl, dynlib: lib, 
-                                      importc: "gtk_vbutton_box_new".}
-proc TYPE_VIEWPORT*(): GType
-proc VIEWPORT*(obj: pointer): PViewport
-proc VIEWPORT_CLASS*(klass: pointer): PViewportClass
-proc IS_VIEWPORT*(obj: pointer): bool
-proc IS_VIEWPORT_CLASS*(klass: pointer): bool
-proc VIEWPORT_GET_CLASS*(obj: pointer): PViewportClass
-proc viewport_get_type*(): TType{.cdecl, dynlib: lib, 
-                                  importc: "gtk_viewport_get_type".}
-proc viewport_new*(hadjustment: PAdjustment, vadjustment: PAdjustment): PViewport{.
-    cdecl, dynlib: lib, importc: "gtk_viewport_new".}
-proc get_hadjustment*(viewport: PViewport): PAdjustment{.cdecl, 
-    dynlib: lib, importc: "gtk_viewport_get_hadjustment".}
-proc get_vadjustment*(viewport: PViewport): PAdjustment{.cdecl, 
-    dynlib: lib, importc: "gtk_viewport_get_vadjustment".}
-proc set_hadjustment*(viewport: PViewport, adjustment: PAdjustment){.
-    cdecl, dynlib: lib, importc: "gtk_viewport_set_hadjustment".}
-proc set_vadjustment*(viewport: PViewport, adjustment: PAdjustment){.
-    cdecl, dynlib: lib, importc: "gtk_viewport_set_vadjustment".}
-proc set_shadow_type*(viewport: PViewport, thetype: TShadowType){.
-    cdecl, dynlib: lib, importc: "gtk_viewport_set_shadow_type".}
-proc get_shadow_type*(viewport: PViewport): TShadowType{.cdecl, 
-    dynlib: lib, importc: "gtk_viewport_get_shadow_type".}
-proc TYPE_VPANED*(): GType
-proc VPANED*(obj: pointer): PVPaned
-proc VPANED_CLASS*(klass: pointer): PVPanedClass
-proc IS_VPANED*(obj: pointer): bool
-proc IS_VPANED_CLASS*(klass: pointer): bool
-proc VPANED_GET_CLASS*(obj: pointer): PVPanedClass
-proc vpaned_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_vpaned_get_type".}
-proc vpaned_new*(): PVPaned{.cdecl, dynlib: lib, importc: "gtk_vpaned_new".}
-proc TYPE_VRULER*(): GType
-proc VRULER*(obj: pointer): PVRuler
-proc VRULER_CLASS*(klass: pointer): PVRulerClass
-proc IS_VRULER*(obj: pointer): bool
-proc IS_VRULER_CLASS*(klass: pointer): bool
-proc VRULER_GET_CLASS*(obj: pointer): PVRulerClass
-proc vruler_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_vruler_get_type".}
-proc vruler_new*(): PVRuler{.cdecl, dynlib: lib, importc: "gtk_vruler_new".}
-proc TYPE_VSCALE*(): GType
-proc VSCALE*(obj: pointer): PVScale
-proc VSCALE_CLASS*(klass: pointer): PVScaleClass
-proc IS_VSCALE*(obj: pointer): bool
-proc IS_VSCALE_CLASS*(klass: pointer): bool
-proc VSCALE_GET_CLASS*(obj: pointer): PVScaleClass
-proc vscale_get_type*(): TType{.cdecl, dynlib: lib, 
-                                importc: "gtk_vscale_get_type".}
-proc vscale_new*(adjustment: PAdjustment): PVScale{.cdecl, dynlib: lib, 
-    importc: "gtk_vscale_new".}
-proc vscale_new*(min: gdouble, max: gdouble, step: gdouble): PVScale{.
-    cdecl, dynlib: lib, importc: "gtk_vscale_new_with_range".}
-proc TYPE_VSCROLLBAR*(): GType
-proc VSCROLLBAR*(obj: pointer): PVScrollbar
-proc VSCROLLBAR_CLASS*(klass: pointer): PVScrollbarClass
-proc IS_VSCROLLBAR*(obj: pointer): bool
-proc IS_VSCROLLBAR_CLASS*(klass: pointer): bool
-proc VSCROLLBAR_GET_CLASS*(obj: pointer): PVScrollbarClass
-proc vscrollbar_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_vscrollbar_get_type".}
-proc vscrollbar_new*(adjustment: PAdjustment): PVScrollbar{.cdecl, dynlib: lib, 
-    importc: "gtk_vscrollbar_new".}
-proc TYPE_VSEPARATOR*(): GType
-proc VSEPARATOR*(obj: pointer): PVSeparator
-proc VSEPARATOR_CLASS*(klass: pointer): PVSeparatorClass
-proc IS_VSEPARATOR*(obj: pointer): bool
-proc IS_VSEPARATOR_CLASS*(klass: pointer): bool
-proc VSEPARATOR_GET_CLASS*(obj: pointer): PVSeparatorClass
-proc vseparator_get_type*(): TType{.cdecl, dynlib: lib, 
-                                    importc: "gtk_vseparator_get_type".}
-proc vseparator_new*(): PVSeparator{.cdecl, dynlib: lib, 
-                                     importc: "gtk_vseparator_new".}
-proc TYPE_OBJECT*(): GType = 
-  result = gtk2.object_get_type()
-
-proc CHECK_CAST*(instance: Pointer, g_type: GType): PGTypeInstance = 
-  result = G_TYPE_CHECK_INSTANCE_CAST(instance, g_type)
-
-proc CHECK_CLASS_CAST*(g_class: pointer, g_type: GType): Pointer = 
-  result = G_TYPE_CHECK_CLASS_CAST(g_class, g_type)
-
-proc CHECK_GET_CLASS*(instance: Pointer, g_type: GType): PGTypeClass = 
-  result = G_TYPE_INSTANCE_GET_CLASS(instance, g_type)
-
-proc CHECK_TYPE*(instance: Pointer, g_type: GType): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type)
-
-proc CHECK_CLASS_TYPE*(g_class: pointer, g_type: GType): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(g_class, g_type)
-
-proc `OBJECT`*(anObject: pointer): PObject = 
-  result = cast[PObject](CHECK_CAST(anObject, gtk2.TYPE_OBJECT()))
-
-proc OBJECT_CLASS*(klass: pointer): PObjectClass = 
-  result = cast[PObjectClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_OBJECT()))
-
-proc IS_OBJECT*(anObject: pointer): bool = 
-  result = CHECK_TYPE(anObject, gtk2.TYPE_OBJECT())
-
-proc IS_OBJECT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_OBJECT())
-
-proc OBJECT_GET_CLASS*(anObject: pointer): PObjectClass = 
-  result = cast[PObjectClass](CHECK_GET_CLASS(anObject, gtk2.TYPE_OBJECT()))
-
-proc OBJECT_TYPE*(anObject: pointer): GType = 
-  result = G_TYPE_FROM_INSTANCE(anObject)
-
-proc OBJECT_TYPE_NAME*(anObject: pointer): cstring = 
-  result = g_type_name(OBJECT_TYPE(anObject))
-
-proc OBJECT_FLAGS*(obj: pointer): guint32 = 
-  result = (gtk2.`OBJECT`(obj)).flags
-
-proc OBJECT_FLOATING*(obj: pointer): gboolean = 
-  result = ((OBJECT_FLAGS(obj)) and cint(FLOATING)) != 0'i32
-
-proc OBJECT_SET_FLAGS*(obj: pointer, flag: guint32) = 
-  gtk2.`OBJECT`(obj).flags = gtk2.`OBJECT`(obj).flags or flag
-
-proc OBJECT_UNSET_FLAGS*(obj: pointer, flag: guint32) = 
-  gtk2.`OBJECT`(obj).flags = gtk2.`OBJECT`(obj).flags and not (flag)
-
-proc object_data_try_key*(`string`: cstring): TGQuark = 
-  result = g_quark_try_string(`string`)
-
-proc object_data_force_id*(`string`: cstring): TGQuark = 
-  result = g_quark_from_string(`string`)
-
-proc CLASS_NAME*(`class`: pointer): cstring = 
-  result = g_type_name(G_TYPE_FROM_CLASS(`class`))
-
-proc CLASS_TYPE*(`class`: pointer): GType = 
-  result = G_TYPE_FROM_CLASS(`class`)
-
-proc TYPE_IS_OBJECT*(thetype: GType): gboolean = 
-  result = g_type_is_a(thetype, gtk2.TYPE_OBJECT())
-
-proc TYPE_IDENTIFIER*(): GType = 
-  result = identifier_get_type()
-
-proc SIGNAL_FUNC*(f: pointer): TSignalFunc = 
-  result = cast[TSignalFunc](f)
-
-proc type_name*(thetype: GType): cstring = 
-  result = g_type_name(thetype)
-
-proc type_from_name*(name: cstring): GType = 
-  result = g_type_from_name(name)
-
-proc type_parent*(thetype: GType): GType = 
-  result = g_type_parent(thetype)
-
-proc type_is_a*(thetype, is_a_type: GType): gboolean = 
-  result = g_type_is_a(thetype, is_a_type)
-
-proc FUNDAMENTAL_TYPE*(thetype: GType): GType = 
-  result = G_TYPE_FUNDAMENTAL(thetype)
-
-proc VALUE_CHAR*(a: TArg): gchar = 
-  var a = a
-  Result = cast[ptr gchar](addr(a.d))^ 
-
-proc VALUE_UCHAR*(a: TArg): guchar = 
-  var a = a
-  Result = cast[ptr guchar](addr(a.d))^ 
-
-proc VALUE_BOOL*(a: TArg): gboolean = 
-  var a = a
-  Result = cast[ptr gboolean](addr(a.d))^ 
-
-proc VALUE_INT*(a: TArg): gint = 
-  var a = a
-  Result = cast[ptr gint](addr(a.d))^ 
-
-proc VALUE_UINT*(a: TArg): guint = 
-  var a = a
-  Result = cast[ptr guint](addr(a.d))^ 
-
-proc VALUE_LONG*(a: TArg): glong = 
-  var a = a
-  Result = cast[ptr glong](addr(a.d))^ 
-
-proc VALUE_ULONG*(a: TArg): gulong = 
-  var a = a
-  Result = cast[ptr gulong](addr(a.d))^ 
-
-proc VALUE_FLOAT*(a: TArg): gfloat = 
-  var a = a
-  Result = cast[ptr gfloat](addr(a.d))^ 
-
-proc VALUE_DOUBLE*(a: TArg): gdouble = 
-  var a = a
-  Result = cast[ptr gdouble](addr(a.d))^ 
-
-proc VALUE_STRING*(a: TArg): cstring = 
-  var a = a
-  Result = cast[ptr cstring](addr(a.d))^ 
-
-proc VALUE_ENUM*(a: TArg): gint = 
-  var a = a
-  Result = cast[ptr gint](addr(a.d))^ 
-
-proc VALUE_FLAGS*(a: TArg): guint = 
-  var a = a
-  Result = cast[ptr guint](addr(a.d))^ 
-
-proc VALUE_BOXED*(a: TArg): gpointer = 
-  var a = a
-  Result = cast[ptr gpointer](addr(a.d))^ 
-
-proc VALUE_OBJECT*(a: TArg): PObject = 
-  var a = a
-  Result = cast[ptr PObject](addr(a.d))^ 
-
-proc VALUE_POINTER*(a: TArg): GPointer = 
-  var a = a
-  Result = cast[ptr gpointer](addr(a.d))^ 
-
-proc VALUE_SIGNAL*(a: TArg): TArgSignalData = 
-  var a = a
-  Result = cast[ptr TArgSignalData](addr(a.d))^ 
-
-proc RETLOC_CHAR*(a: TArg): cstring = 
-  var a = a
-  Result = cast[ptr cstring](addr(a.d))^ 
-
-proc RETLOC_UCHAR*(a: TArg): Pguchar = 
-  var a = a
-  Result = cast[ptr pguchar](addr(a.d))^ 
-
-proc RETLOC_BOOL*(a: TArg): Pgboolean = 
-  var a = a
-  Result = cast[ptr pgboolean](addr(a.d))^ 
-
-proc RETLOC_INT*(a: TArg): Pgint = 
-  var a = a
-  Result = cast[ptr pgint](addr(a.d))^ 
-
-proc RETLOC_UINT*(a: TArg): Pguint = 
-  var a = a
-  Result = cast[ptr pguint](addr(a.d))^ 
-
-proc RETLOC_LONG*(a: TArg): Pglong = 
-  var a = a
-  Result = cast[ptr pglong](addr(a.d))^ 
-
-proc RETLOC_ULONG*(a: TArg): Pgulong = 
-  var a = a
-  Result = cast[ptr pgulong](addr(a.d))^ 
-
-proc RETLOC_FLOAT*(a: TArg): Pgfloat = 
-  var a = a
-  Result = cast[ptr pgfloat](addr(a.d))^ 
-
-proc RETLOC_DOUBLE*(a: TArg): Pgdouble = 
-  var a = a
-  Result = cast[ptr pgdouble](addr(a.d))^ 
-
-proc RETLOC_STRING*(a: TArg): Ppgchar = 
-  var a = a
-  Result = cast[ptr Ppgchar](addr(a.d))^ 
-
-proc RETLOC_ENUM*(a: TArg): Pgint = 
-  var a = a
-  Result = cast[ptr Pgint](addr(a.d))^ 
-
-proc RETLOC_FLAGS*(a: TArg): Pguint = 
-  var a = a
-  Result = cast[ptr pguint](addr(a.d))^ 
-
-proc RETLOC_BOXED*(a: TArg): Pgpointer = 
-  var a = a
-  Result = cast[ptr pgpointer](addr(a.d))^ 
-
-proc RETLOC_OBJECT*(a: TArg): PPGtkObject = 
-  var a = a
-  Result = cast[ptr ppgtkobject](addr(a.d))^ 
-
-proc RETLOC_POINTER*(a: TArg): Pgpointer = 
-  var a = a
-  Result = cast[ptr pgpointer](addr(a.d))^ 
-
-proc TYPE_WIDGET*(): GType = 
-  result = widget_get_type()
-
-proc WIDGET*(widget: pointer): PWidget = 
-  result = cast[PWidget](CHECK_CAST(widget, TYPE_WIDGET()))
-
-proc WIDGET_CLASS*(klass: pointer): PWidgetClass = 
-  result = cast[PWidgetClass](CHECK_CLASS_CAST(klass, TYPE_WIDGET()))
-
-proc IS_WIDGET*(widget: pointer): bool = 
-  result = CHECK_TYPE(widget, TYPE_WIDGET())
-
-proc IS_WIDGET_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_WIDGET())
-
-proc WIDGET_GET_CLASS*(obj: pointer): PWidgetClass = 
-  result = cast[PWidgetClass](CHECK_GET_CLASS(obj, TYPE_WIDGET()))
-
-proc WIDGET_TYPE*(wid: pointer): GType = 
-  result = OBJECT_TYPE(wid)
-
-proc WIDGET_STATE*(wid: pointer): int32 = 
-  result = (WIDGET(wid)).state
-
-proc WIDGET_SAVED_STATE*(wid: pointer): int32 = 
-  result = (WIDGET(wid)).saved_state
-
-proc WIDGET_FLAGS*(wid: pointer): guint32 = 
-  result = OBJECT_FLAGS(wid)
-
-proc WIDGET_TOPLEVEL*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(TOPLEVEL)) != 0'i32
-
-proc WIDGET_NO_WINDOW*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(NO_WINDOW)) != 0'i32
-
-proc WIDGET_REALIZED*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(constREALIZED)) != 0'i32
-
-proc WIDGET_MAPPED*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(MAPPED)) != 0'i32
-
-proc WIDGET_VISIBLE*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(constVISIBLE)) != 0'i32
-
-proc WIDGET_DRAWABLE*(wid: pointer): gboolean = 
-  result = (WIDGET_VISIBLE(wid)) and (WIDGET_MAPPED(wid))
-
-proc WIDGET_SENSITIVE*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(SENSITIVE)) != 0'i32
-
-proc WIDGET_PARENT_SENSITIVE*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(PARENT_SENSITIVE)) != 0'i32
-
-proc WIDGET_IS_SENSITIVE*(wid: pointer): gboolean = 
-  result = (WIDGET_SENSITIVE(wid)) and (WIDGET_PARENT_SENSITIVE(wid))
-
-proc WIDGET_CAN_FOCUS*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(CAN_FOCUS)) != 0'i32
-
-proc WIDGET_HAS_FOCUS*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(constHAS_FOCUS)) != 0'i32
-
-proc WIDGET_CAN_DEFAULT*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(CAN_DEFAULT)) != 0'i32
-
-proc WIDGET_HAS_DEFAULT*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(HAS_DEFAULT)) != 0'i32
-
-proc WIDGET_HAS_GRAB*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(HAS_GRAB)) != 0'i32
-
-proc WIDGET_RC_STYLE*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(RC_STYLE)) != 0'i32
-
-proc WIDGET_COMPOSITE_CHILD*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(COMPOSITE_CHILD)) != 0'i32
-
-proc WIDGET_APP_PAINTABLE*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(APP_PAINTABLE)) != 0'i32
-
-proc WIDGET_RECEIVES_DEFAULT*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(RECEIVES_DEFAULT)) != 0'i32
-
-proc WIDGET_DOUBLE_BUFFERED*(wid: pointer): gboolean = 
-  result = ((WIDGET_FLAGS(wid)) and cint(DOUBLE_BUFFERED)) != 0'i32
-
-proc TYPE_REQUISITION*(): GType = 
-  result = requisition_get_type()
-
-proc x_set*(a: PWidgetAuxInfo): guint = 
-  result = (a.flag0 and bm_TGtkWidgetAuxInfo_x_set) shr
-      bp_TGtkWidgetAuxInfo_x_set
-
-proc set_x_set*(a: PWidgetAuxInfo, `x_set`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`x_set` shl bp_TGtkWidgetAuxInfo_x_set) and
-      bm_TGtkWidgetAuxInfo_x_set)
-
-proc y_set*(a: PWidgetAuxInfo): guint = 
-  result = (a.flag0 and bm_TGtkWidgetAuxInfo_y_set) shr
-      bp_TGtkWidgetAuxInfo_y_set
-
-proc set_y_set*(a: PWidgetAuxInfo, `y_set`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`y_set` shl bp_TGtkWidgetAuxInfo_y_set) and
-      bm_TGtkWidgetAuxInfo_y_set)
-
-proc widget_set_visual*(widget, visual: pointer) = 
-  if (Widget != nil) and (visual != nil): nil
-  
-proc widget_push_visual*(visual: pointer) = 
-  if (visual != nil): nil
-  
-proc widget_pop_visual*() = 
-  nil
-
-proc widget_set_default_visual*(visual: pointer) = 
-  if (visual != nil): nil
-  
-proc widget_set_rc_style*(widget: pointer) = 
-  set_style(cast[PWidget](widget), nil)
-
-proc widget_restore_default_style*(widget: pointer) = 
-  set_style(cast[PWidget](widget), nil)
-
-proc SET_FLAGS*(wid: PWidget, flags: TWidgetFlags): TWidgetFlags = 
-  cast[pObject](wid).flags = cast[pObject](wid).flags or (flags)
-  result = cast[pObject](wid).flags
-
-proc UNSET_FLAGS*(wid: PWidget, flags: TWidgetFlags): TWidgetFlags = 
-  cast[pObject](wid).flags = cast[pObject](wid).flags and (not (flags))
-  result = cast[pObject](wid).flags
-
-proc TYPE_MISC*(): GType = 
-  result = misc_get_type()
-
-proc MISC*(obj: pointer): PMisc = 
-  result = cast[PMisc](CHECK_CAST(obj, TYPE_MISC()))
-
-proc MISC_CLASS*(klass: pointer): PMiscClass = 
-  result = cast[PMiscClass](CHECK_CLASS_CAST(klass, TYPE_MISC()))
-
-proc IS_MISC*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MISC())
-
-proc IS_MISC_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MISC())
-
-proc MISC_GET_CLASS*(obj: pointer): PMiscClass = 
-  result = cast[PMiscClass](CHECK_GET_CLASS(obj, TYPE_MISC()))
-
-proc TYPE_ACCEL_GROUP*(): GType = 
-  result = accel_group_get_type()
-
-proc ACCEL_GROUP*(anObject: pointer): PAccelGroup = 
-  result = cast[PAccelGroup](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_ACCEL_GROUP()))
-
-proc ACCEL_GROUP_CLASS*(klass: pointer): PAccelGroupClass = 
-  result = cast[PAccelGroupClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_ACCEL_GROUP()))
-
-proc IS_ACCEL_GROUP*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_ACCEL_GROUP())
-
-proc IS_ACCEL_GROUP_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_ACCEL_GROUP())
-
-proc ACCEL_GROUP_GET_CLASS*(obj: pointer): PAccelGroupClass = 
-  result = cast[PAccelGroupClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_ACCEL_GROUP()))
-
-proc accel_flags*(a: PAccelKey): guint = 
-  result = (a.flag0 and bm_TGtkAccelKey_accel_flags) shr
-      bp_TGtkAccelKey_accel_flags
-
-proc set_accel_flags*(a: PAccelKey, `accel_flags`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`accel_flags` shl bp_TGtkAccelKey_accel_flags) and
-      bm_TGtkAccelKey_accel_flags)
-
-proc reference*(AccelGroup: PAccelGroup) = 
-  discard g_object_ref(AccelGroup)
-
-proc unref*(AccelGroup: PAccelGroup) = 
-  g_object_unref(AccelGroup)
-
-proc TYPE_CONTAINER*(): GType = 
-  result = container_get_type()
-
-proc CONTAINER*(obj: pointer): PContainer = 
-  result = cast[PContainer](CHECK_CAST(obj, TYPE_CONTAINER()))
-
-proc CONTAINER_CLASS*(klass: pointer): PContainerClass = 
-  result = cast[PContainerClass](CHECK_CLASS_CAST(klass, TYPE_CONTAINER()))
-
-proc IS_CONTAINER*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CONTAINER())
-
-proc IS_CONTAINER_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CONTAINER())
-
-proc CONTAINER_GET_CLASS*(obj: pointer): PContainerClass = 
-  result = cast[PContainerClass](CHECK_GET_CLASS(obj, TYPE_CONTAINER()))
-
-proc IS_RESIZE_CONTAINER*(widget: pointer): bool = 
-  result = (IS_CONTAINER(widget)) and
-      ((resize_mode(cast[PContainer](widget))) != cint(RESIZE_PARENT))
-
-proc border_width*(a: PContainer): guint = 
-  result = (a.Container_flag0 and bm_TGtkContainer_border_width) shr
-      bp_TGtkContainer_border_width
-
-proc need_resize*(a: PContainer): guint = 
-  result = (a.Container_flag0 and bm_TGtkContainer_need_resize) shr
-      bp_TGtkContainer_need_resize
-
-proc set_need_resize*(a: PContainer, `need_resize`: guint) = 
-  a.Container_flag0 = a.Container_flag0 or
-      ((`need_resize` shl bp_TGtkContainer_need_resize) and
-      bm_TGtkContainer_need_resize)
-
-proc resize_mode*(a: PContainer): guint = 
-  result = (a.Container_flag0 and bm_TGtkContainer_resize_mode) shr
-      bp_TGtkContainer_resize_mode
-
-proc set_resize_mode*(a: PContainer, `resize_mode`: guint) = 
-  a.Containerflag0 = a.Containerflag0 or
-      ((`resize_mode` shl bp_TGtkContainer_resize_mode) and
-      bm_TGtkContainer_resize_mode)
-
-proc reallocate_redraws*(a: PContainer): guint = 
-  result = (a.Containerflag0 and bm_TGtkContainer_reallocate_redraws) shr
-      bp_TGtkContainer_reallocate_redraws
-
-proc set_reallocate_redraws*(a: PContainer, `reallocate_redraws`: guint) = 
-  a.Containerflag0 = a.Containerflag0 or
-      ((`reallocate_redraws` shl bp_TGtkContainer_reallocate_redraws) and
-      bm_TGtkContainer_reallocate_redraws)
-
-proc has_focus_chain*(a: PContainer): guint = 
-  result = (a.Containerflag0 and bm_TGtkContainer_has_focus_chain) shr
-      bp_TGtkContainer_has_focus_chain
-
-proc set_has_focus_chain*(a: PContainer, `has_focus_chain`: guint) = 
-  a.Containerflag0 = a.Containerflag0 or
-      ((`has_focus_chain` shl bp_TGtkContainer_has_focus_chain) and
-      bm_TGtkContainer_has_focus_chain)
-
-proc CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID*(anObject: pointer, 
-    property_id: guint, pspec: pointer) = 
-  write(stdout, "WARNING: invalid child property id\x0A")
-
-proc TYPE_BIN*(): GType = 
-  result = bin_get_type()
-
-proc BIN*(obj: pointer): PBin = 
-  result = cast[PBin](CHECK_CAST(obj, TYPE_BIN()))
-
-proc BIN_CLASS*(klass: pointer): PBinClass = 
-  result = cast[PBinClass](CHECK_CLASS_CAST(klass, TYPE_BIN()))
-
-proc IS_BIN*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_BIN())
-
-proc IS_BIN_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_BIN())
-
-proc BIN_GET_CLASS*(obj: pointer): PBinClass = 
-  result = cast[PBinClass](CHECK_GET_CLASS(obj, TYPE_BIN()))
-
-proc TYPE_WINDOW*(): GType = 
-  result = window_get_type()
-
-proc WINDOW*(obj: pointer): PWindow = 
-  result = cast[PWindow](CHECK_CAST(obj, gtk2.TYPE_WINDOW()))
-
-proc WINDOW_CLASS*(klass: pointer): PWindowClass = 
-  result = cast[PWindowClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_WINDOW()))
-
-proc IS_WINDOW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_WINDOW())
-
-proc IS_WINDOW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_WINDOW())
-
-proc WINDOW_GET_CLASS*(obj: pointer): PWindowClass = 
-  result = cast[PWindowClass](CHECK_GET_CLASS(obj, gtk2.TYPE_WINDOW()))
-
-proc allow_shrink*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_allow_shrink) shr
-      bp_TGtkWindow_allow_shrink
-
-proc set_allow_shrink*(a: gtk2.PWindow, `allow_shrink`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`allow_shrink` shl bp_TGtkWindow_allow_shrink) and
-      bm_TGtkWindow_allow_shrink)
-
-proc allow_grow*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_allow_grow) shr
-      bp_TGtkWindow_allow_grow
-
-proc set_allow_grow*(a: gtk2.PWindow, `allow_grow`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`allow_grow` shl bp_TGtkWindow_allow_grow) and
-      bm_TGtkWindow_allow_grow)
-
-proc configure_notify_received*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_configure_notify_received) shr
-      bp_TGtkWindow_configure_notify_received
-
-proc set_configure_notify_received*(a: gtk2.PWindow, 
-                                    `configure_notify_received`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`configure_notify_received` shl
-      bp_TGtkWindow_configure_notify_received) and
-      bm_TGtkWindow_configure_notify_received)
-
-proc need_default_position*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_need_default_position) shr
-      bp_TGtkWindow_need_default_position
-
-proc set_need_default_position*(a: gtk2.PWindow, `need_default_position`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`need_default_position` shl bp_TGtkWindow_need_default_position) and
-      bm_TGtkWindow_need_default_position)
-
-proc need_default_size*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_need_default_size) shr
-      bp_TGtkWindow_need_default_size
-
-proc set_need_default_size*(a: gtk2.PWindow, `need_default_size`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`need_default_size` shl bp_TGtkWindow_need_default_size) and
-      bm_TGtkWindow_need_default_size)
-
-proc position*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_position) shr
-      bp_TGtkWindow_position
-
-proc set_position*(a: gtk2.PWindow, `position`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`position` shl bp_TGtkWindow_position) and bm_TGtkWindow_position)
-
-proc get_type*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_type) shr bp_TGtkWindow_type
-
-proc set_type*(a: gtk2.PWindow, `type`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`type` shl bp_TGtkWindow_type) and bm_TGtkWindow_type)
-
-proc has_user_ref_count*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_has_user_ref_count) shr
-      bp_TGtkWindow_has_user_ref_count
-
-proc set_has_user_ref_count*(a: gtk2.PWindow, `has_user_ref_count`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`has_user_ref_count` shl bp_TGtkWindow_has_user_ref_count) and
-      bm_TGtkWindow_has_user_ref_count)
-
-proc has_focus*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_has_focus) shr
-      bp_TGtkWindow_has_focus
-
-proc set_has_focus*(a: gtk2.PWindow, `has_focus`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`has_focus` shl bp_TGtkWindow_has_focus) and bm_TGtkWindow_has_focus)
-
-proc modal*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_modal) shr bp_TGtkWindow_modal
-
-proc set_modal*(a: gtk2.PWindow, `modal`: guint) = 
-  a.Window_flag0 = a.Window_flag0 or
-      ((`modal` shl bp_TGtkWindow_modal) and bm_TGtkWindow_modal)
-
-proc destroy_with_parent*(a: gtk2.PWindow): guint = 
-  result = (a.Window_flag0 and bm_TGtkWindow_destroy_with_parent) shr
-      bp_TGtkWindow_destroy_with_parent
-
-proc set_destroy_with_parent*(a: gtk2.PWindow, `destroy_with_parent`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`destroy_with_parent` shl bp_TGtkWindow_destroy_with_parent) and
-      bm_TGtkWindow_destroy_with_parent)
-
-proc has_frame*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_has_frame) shr
-      bp_TGtkWindow_has_frame
-
-proc set_has_frame*(a: gtk2.PWindow, `has_frame`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`has_frame` shl bp_TGtkWindow_has_frame) and bm_TGtkWindow_has_frame)
-
-proc iconify_initially*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_iconify_initially) shr
-      bp_TGtkWindow_iconify_initially
-
-proc set_iconify_initially*(a: gtk2.PWindow, `iconify_initially`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`iconify_initially` shl bp_TGtkWindow_iconify_initially) and
-      bm_TGtkWindow_iconify_initially)
-
-proc stick_initially*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_stick_initially) shr
-      bp_TGtkWindow_stick_initially
-
-proc set_stick_initially*(a: gtk2.PWindow, `stick_initially`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`stick_initially` shl bp_TGtkWindow_stick_initially) and
-      bm_TGtkWindow_stick_initially)
-
-proc maximize_initially*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_maximize_initially) shr
-      bp_TGtkWindow_maximize_initially
-
-proc set_maximize_initially*(a: gtk2.PWindow, `maximize_initially`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`maximize_initially` shl bp_TGtkWindow_maximize_initially) and
-      bm_TGtkWindow_maximize_initially)
-
-proc decorated*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_decorated) shr
-      bp_TGtkWindow_decorated
-
-proc set_decorated*(a: gtk2.PWindow, `decorated`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`decorated` shl bp_TGtkWindow_decorated) and bm_TGtkWindow_decorated)
-
-proc type_hint*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_type_hint) shr
-      bp_TGtkWindow_type_hint
-
-proc set_type_hint*(a: gtk2.PWindow, `type_hint`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`type_hint` shl bp_TGtkWindow_type_hint) and bm_TGtkWindow_type_hint)
-
-proc gravity*(a: gtk2.PWindow): guint = 
-  result = (a.Windowflag0 and bm_TGtkWindow_gravity) shr
-      bp_TGtkWindow_gravity
-
-proc set_gravity*(a: gtk2.PWindow, `gravity`: guint) = 
-  a.Windowflag0 = a.Windowflag0 or
-      ((`gravity` shl bp_TGtkWindow_gravity) and bm_TGtkWindow_gravity)
-
-proc TYPE_WINDOW_GROUP*(): GType = 
-  result = window_group_get_type()
-
-proc WINDOW_GROUP*(anObject: pointer): PWindowGroup = 
-  result = cast[PWindowGroup](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_WINDOW_GROUP()))
-
-proc WINDOW_GROUP_CLASS*(klass: pointer): PWindowGroupClass = 
-  result = cast[PWindowGroupClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_WINDOW_GROUP()))
-
-proc IS_WINDOW_GROUP*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_WINDOW_GROUP())
-
-proc IS_WINDOW_GROUP_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_WINDOW_GROUP())
-
-proc WINDOW_GROUP_GET_CLASS*(obj: pointer): PWindowGroupClass = 
-  result = cast[PWindowGroupClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_WINDOW_GROUP()))
-
-proc TYPE_LABEL*(): GType = 
-  result = label_get_type()
-
-proc LABEL*(obj: pointer): PLabel = 
-  result = cast[PLabel](CHECK_CAST(obj, TYPE_LABEL()))
-
-proc LABEL_CLASS*(klass: pointer): PLabelClass = 
-  result = cast[PLabelClass](CHECK_CLASS_CAST(klass, TYPE_LABEL()))
-
-proc IS_LABEL*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_LABEL())
-
-proc IS_LABEL_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_LABEL())
-
-proc LABEL_GET_CLASS*(obj: pointer): PLabelClass = 
-  result = cast[PLabelClass](CHECK_GET_CLASS(obj, TYPE_LABEL()))
-
-proc jtype*(a: PLabel): guint = 
-  result = (a.Labelflag0 and bm_TGtkLabel_jtype) shr bp_TGtkLabel_jtype
-
-proc set_jtype*(a: PLabel, `jtype`: guint) = 
-  a.Labelflag0 = a.Labelflag0 or
-      (int16(`jtype` shl bp_TGtkLabel_jtype) and bm_TGtkLabel_jtype)
-
-proc wrap*(a: PLabel): guint = 
-  result = (a.Labelflag0 and bm_TGtkLabel_wrap) shr bp_TGtkLabel_wrap
-
-proc set_wrap*(a: PLabel, `wrap`: guint) = 
-  a.Labelflag0 = a.Labelflag0 or
-      (int16(`wrap` shl bp_TGtkLabel_wrap) and bm_TGtkLabel_wrap)
-
-proc use_underline*(a: PLabel): guint = 
-  result = (a.Labelflag0 and bm_TGtkLabel_use_underline) shr
-      bp_TGtkLabel_use_underline
-
-proc set_use_underline*(a: PLabel, `use_underline`: guint) = 
-  a.Labelflag0 = a.Labelflag0 or
-      (int16(`use_underline` shl bp_TGtkLabel_use_underline) and
-      bm_TGtkLabel_use_underline)
-
-proc use_markup*(a: PLabel): guint = 
-  result = (a.Labelflag0 and bm_TGtkLabel_use_markup) shr
-      bp_TGtkLabel_use_markup
-
-proc set_use_markup*(a: PLabel, `use_markup`: guint) = 
-  a.Labelflag0 = a.Labelflag0 or
-      (int16(`use_markup` shl bp_TGtkLabel_use_markup) and
-      bm_TGtkLabel_use_markup)
-
-proc TYPE_ACCEL_LABEL*(): GType = 
-  result = accel_label_get_type()
-
-proc ACCEL_LABEL*(obj: pointer): PAccelLabel = 
-  result = cast[PAccelLabel](CHECK_CAST(obj, TYPE_ACCEL_LABEL()))
-
-proc ACCEL_LABEL_CLASS*(klass: pointer): PAccelLabelClass = 
-  result = cast[PAccelLabelClass](CHECK_CLASS_CAST(klass, TYPE_ACCEL_LABEL()))
-
-proc IS_ACCEL_LABEL*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ACCEL_LABEL())
-
-proc IS_ACCEL_LABEL_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ACCEL_LABEL())
-
-proc ACCEL_LABEL_GET_CLASS*(obj: pointer): PAccelLabelClass = 
-  result = cast[PAccelLabelClass](CHECK_GET_CLASS(obj, TYPE_ACCEL_LABEL()))
-
-proc latin1_to_char*(a: PAccelLabelClass): guint = 
-  result = (a.AccelLabelClassflag0 and bm_TGtkAccelLabelClass_latin1_to_char) shr
-      bp_TGtkAccelLabelClass_latin1_to_char
-
-proc set_latin1_to_char*(a: PAccelLabelClass, `latin1_to_char`: guint) = 
-  a.AccelLabelClassflag0 = a.AccelLabelClassflag0 or
-      (int16(`latin1_to_char` shl bp_TGtkAccelLabelClass_latin1_to_char) and
-      bm_TGtkAccelLabelClass_latin1_to_char)
-
-proc accelerator_width*(accel_label: PAccelLabel): guint = 
-  result = get_accel_width(accel_label)
-
-proc TYPE_ACCESSIBLE*(): GType = 
-  result = accessible_get_type()
-
-proc ACCESSIBLE*(obj: pointer): PAccessible = 
-  result = cast[PAccessible](CHECK_CAST(obj, TYPE_ACCESSIBLE()))
-
-proc ACCESSIBLE_CLASS*(klass: pointer): PAccessibleClass = 
-  result = cast[PAccessibleClass](CHECK_CLASS_CAST(klass, TYPE_ACCESSIBLE()))
-
-proc IS_ACCESSIBLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ACCESSIBLE())
-
-proc IS_ACCESSIBLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ACCESSIBLE())
-
-proc ACCESSIBLE_GET_CLASS*(obj: pointer): PAccessibleClass = 
-  result = cast[PAccessibleClass](CHECK_GET_CLASS(obj, TYPE_ACCESSIBLE()))
-
-proc TYPE_ADJUSTMENT*(): GType = 
-  result = adjustment_get_type()
-
-proc ADJUSTMENT*(obj: pointer): PAdjustment = 
-  result = cast[PAdjustment](CHECK_CAST(obj, TYPE_ADJUSTMENT()))
-
-proc ADJUSTMENT_CLASS*(klass: pointer): PAdjustmentClass = 
-  result = cast[PAdjustmentClass](CHECK_CLASS_CAST(klass, TYPE_ADJUSTMENT()))
-
-proc IS_ADJUSTMENT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ADJUSTMENT())
-
-proc IS_ADJUSTMENT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ADJUSTMENT())
-
-proc ADJUSTMENT_GET_CLASS*(obj: pointer): PAdjustmentClass = 
-  result = cast[PAdjustmentClass](CHECK_GET_CLASS(obj, TYPE_ADJUSTMENT()))
-
-proc TYPE_ALIGNMENT*(): GType = 
-  result = alignment_get_type()
-
-proc ALIGNMENT*(obj: pointer): PAlignment = 
-  result = cast[PAlignment](CHECK_CAST(obj, TYPE_ALIGNMENT()))
-
-proc ALIGNMENT_CLASS*(klass: pointer): PAlignmentClass = 
-  result = cast[PAlignmentClass](CHECK_CLASS_CAST(klass, TYPE_ALIGNMENT()))
-
-proc IS_ALIGNMENT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ALIGNMENT())
-
-proc IS_ALIGNMENT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ALIGNMENT())
-
-proc ALIGNMENT_GET_CLASS*(obj: pointer): PAlignmentClass = 
-  result = cast[PAlignmentClass](CHECK_GET_CLASS(obj, TYPE_ALIGNMENT()))
-
-proc TYPE_FRAME*(): GType = 
-  result = frame_get_type()
-
-proc FRAME*(obj: pointer): PFrame = 
-  result = cast[PFrame](CHECK_CAST(obj, TYPE_FRAME()))
-
-proc FRAME_CLASS*(klass: pointer): PFrameClass = 
-  result = cast[PFrameClass](CHECK_CLASS_CAST(klass, TYPE_FRAME()))
-
-proc IS_FRAME*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_FRAME())
-
-proc IS_FRAME_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_FRAME())
-
-proc FRAME_GET_CLASS*(obj: pointer): PFrameClass = 
-  result = cast[PFrameClass](CHECK_GET_CLASS(obj, TYPE_FRAME()))
-
-proc TYPE_ASPECT_FRAME*(): GType = 
-  result = aspect_frame_get_type()
-
-proc ASPECT_FRAME*(obj: pointer): PAspectFrame = 
-  result = cast[PAspectFrame](CHECK_CAST(obj, TYPE_ASPECT_FRAME()))
-
-proc ASPECT_FRAME_CLASS*(klass: pointer): PAspectFrameClass = 
-  result = cast[PAspectFrameClass](CHECK_CLASS_CAST(klass, TYPE_ASPECT_FRAME()))
-
-proc IS_ASPECT_FRAME*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ASPECT_FRAME())
-
-proc IS_ASPECT_FRAME_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ASPECT_FRAME())
-
-proc ASPECT_FRAME_GET_CLASS*(obj: pointer): PAspectFrameClass = 
-  result = cast[PAspectFrameClass](CHECK_GET_CLASS(obj, TYPE_ASPECT_FRAME()))
-
-proc TYPE_ARROW*(): GType = 
-  result = arrow_get_type()
-
-proc ARROW*(obj: pointer): PArrow = 
-  result = cast[PArrow](CHECK_CAST(obj, TYPE_ARROW()))
-
-proc ARROW_CLASS*(klass: pointer): PArrowClass = 
-  result = cast[PArrowClass](CHECK_CLASS_CAST(klass, TYPE_ARROW()))
-
-proc IS_ARROW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ARROW())
-
-proc IS_ARROW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ARROW())
-
-proc ARROW_GET_CLASS*(obj: pointer): PArrowClass = 
-  result = cast[PArrowClass](CHECK_GET_CLASS(obj, TYPE_ARROW()))
-
-proc parsed*(a: PBindingSet): guint = 
-  result = (a.flag0 and bm_TGtkBindingSet_parsed) shr
-      bp_TGtkBindingSet_parsed
-
-proc set_parsed*(a: PBindingSet, `parsed`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`parsed` shl bp_TGtkBindingSet_parsed) and
-      bm_TGtkBindingSet_parsed)
-
-proc destroyed*(a: PBindingEntry): guint = 
-  result = (a.flag0 and bm_TGtkBindingEntry_destroyed) shr
-      bp_TGtkBindingEntry_destroyed
-
-proc set_destroyed*(a: PBindingEntry, `destroyed`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`destroyed` shl bp_TGtkBindingEntry_destroyed) and
-      bm_TGtkBindingEntry_destroyed)
-
-proc in_emission*(a: PBindingEntry): guint = 
-  result = (a.flag0 and bm_TGtkBindingEntry_in_emission) shr
-      bp_TGtkBindingEntry_in_emission
-
-proc set_in_emission*(a: PBindingEntry, `in_emission`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`in_emission` shl bp_TGtkBindingEntry_in_emission) and
-      bm_TGtkBindingEntry_in_emission)
-
-proc entry_add*(binding_set: PBindingSet, keyval: guint, 
-                        modifiers: gdk2.TModifierType) = 
-  entry_clear(binding_set, keyval, modifiers)
-
-proc TYPE_BOX*(): GType = 
-  result = box_get_type()
-
-proc BOX*(obj: pointer): PBox = 
-  result = cast[PBox](CHECK_CAST(obj, TYPE_BOX()))
-
-proc BOX_CLASS*(klass: pointer): PBoxClass = 
-  result = cast[PBoxClass](CHECK_CLASS_CAST(klass, TYPE_BOX()))
-
-proc IS_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_BOX())
-
-proc IS_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_BOX())
-
-proc BOX_GET_CLASS*(obj: pointer): PBoxClass = 
-  result = cast[PBoxClass](CHECK_GET_CLASS(obj, TYPE_BOX()))
-
-proc homogeneous*(a: PBox): guint = 
-  result = (a.Boxflag0 and bm_TGtkBox_homogeneous) shr bp_TGtkBox_homogeneous
-
-proc set_homogeneous*(a: PBox, `homogeneous`: guint) = 
-  a.Boxflag0 = a.Boxflag0 or
-      (int16(`homogeneous` shl bp_TGtkBox_homogeneous) and
-      bm_TGtkBox_homogeneous)
-
-proc expand*(a: PBoxChild): guint = 
-  result = (a.flag0 and bm_TGtkBoxChild_expand) shr bp_TGtkBoxChild_expand
-
-proc set_expand*(a: PBoxChild, `expand`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`expand` shl bp_TGtkBoxChild_expand) and bm_TGtkBoxChild_expand)
-
-proc fill*(a: PBoxChild): guint = 
-  result = (a.flag0 and bm_TGtkBoxChild_fill) shr bp_TGtkBoxChild_fill
-
-proc set_fill*(a: PBoxChild, `fill`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`fill` shl bp_TGtkBoxChild_fill) and bm_TGtkBoxChild_fill)
-
-proc pack*(a: PBoxChild): guint = 
-  result = (a.flag0 and bm_TGtkBoxChild_pack) shr bp_TGtkBoxChild_pack
-
-proc set_pack*(a: PBoxChild, `pack`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pack` shl bp_TGtkBoxChild_pack) and bm_TGtkBoxChild_pack)
-
-proc is_secondary*(a: PBoxChild): guint = 
-  result = (a.flag0 and bm_TGtkBoxChild_is_secondary) shr
-      bp_TGtkBoxChild_is_secondary
-
-proc set_is_secondary*(a: PBoxChild, `is_secondary`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_secondary` shl bp_TGtkBoxChild_is_secondary) and
-      bm_TGtkBoxChild_is_secondary)
-
-proc TYPE_BUTTON_BOX*(): GType = 
-  result = button_box_get_type()
-
-proc BUTTON_BOX*(obj: pointer): PButtonBox = 
-  result = cast[PButtonBox](CHECK_CAST(obj, TYPE_BUTTON_BOX()))
-
-proc BUTTON_BOX_CLASS*(klass: pointer): PButtonBoxClass = 
-  result = cast[PButtonBoxClass](CHECK_CLASS_CAST(klass, TYPE_BUTTON_BOX()))
-
-proc IS_BUTTON_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_BUTTON_BOX())
-
-proc IS_BUTTON_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_BUTTON_BOX())
-
-proc BUTTON_BOX_GET_CLASS*(obj: pointer): PButtonBoxClass = 
-  result = cast[PButtonBoxClass](CHECK_GET_CLASS(obj, TYPE_BUTTON_BOX()))
-
-proc button_box_set_spacing*(b: pointer, s: gint) = 
-  set_spacing(BOX(b), s)
-
-proc button_box_get_spacing*(b: pointer): gint = 
-  result = get_spacing(BOX(b))
-
-proc TYPE_BUTTON*(): GType = 
-  result = button_get_type()
-
-proc BUTTON*(obj: pointer): PButton = 
-  result = cast[PButton](CHECK_CAST(obj, TYPE_BUTTON()))
-
-proc BUTTON_CLASS*(klass: pointer): PButtonClass = 
-  result = cast[PButtonClass](CHECK_CLASS_CAST(klass, TYPE_BUTTON()))
-
-proc IS_BUTTON*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_BUTTON())
-
-proc IS_BUTTON_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_BUTTON())
-
-proc BUTTON_GET_CLASS*(obj: pointer): PButtonClass = 
-  result = cast[PButtonClass](CHECK_GET_CLASS(obj, TYPE_BUTTON()))
-
-proc constructed*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_constructed) shr
-      bp_TGtkButton_constructed
-
-proc set_constructed*(a: PButton, `constructed`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`constructed` shl bp_TGtkButton_constructed) and
-      bm_TGtkButton_constructed)
-
-proc in_button*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_in_button) shr
-      bp_TGtkButton_in_button
-
-proc set_in_button*(a: PButton, `in_button`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`in_button` shl bp_TGtkButton_in_button) and
-      bm_TGtkButton_in_button)
-
-proc button_down*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_button_down) shr
-      bp_TGtkButton_button_down
-
-proc set_button_down*(a: PButton, `button_down`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`button_down` shl bp_TGtkButton_button_down) and
-      bm_TGtkButton_button_down)
-
-proc relief*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_relief) shr bp_TGtkButton_relief
-
-proc use_underline*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_use_underline) shr
-      bp_TGtkButton_use_underline
-
-proc set_use_underline*(a: PButton, `use_underline`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`use_underline` shl bp_TGtkButton_use_underline) and
-      bm_TGtkButton_use_underline)
-
-proc use_stock*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_use_stock) shr
-      bp_TGtkButton_use_stock
-
-proc set_use_stock*(a: PButton, `use_stock`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`use_stock` shl bp_TGtkButton_use_stock) and
-      bm_TGtkButton_use_stock)
-
-proc depressed*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_depressed) shr
-      bp_TGtkButton_depressed
-
-proc set_depressed*(a: PButton, `depressed`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`depressed` shl bp_TGtkButton_depressed) and
-      bm_TGtkButton_depressed)
-
-proc depress_on_activate*(a: PButton): guint = 
-  result = (a.Buttonflag0 and bm_TGtkButton_depress_on_activate) shr
-      bp_TGtkButton_depress_on_activate
-
-proc set_depress_on_activate*(a: PButton, `depress_on_activate`: guint) = 
-  a.Buttonflag0 = a.Buttonflag0 or
-      (int16(`depress_on_activate` shl bp_TGtkButton_depress_on_activate) and
-      bm_TGtkButton_depress_on_activate)
-
-proc TYPE_CALENDAR*(): GType = 
-  result = calendar_get_type()
-
-proc CALENDAR*(obj: pointer): PCalendar = 
-  result = cast[PCalendar](CHECK_CAST(obj, TYPE_CALENDAR()))
-
-proc CALENDAR_CLASS*(klass: pointer): PCalendarClass = 
-  result = cast[PCalendarClass](CHECK_CLASS_CAST(klass, TYPE_CALENDAR()))
-
-proc IS_CALENDAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CALENDAR())
-
-proc IS_CALENDAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CALENDAR())
-
-proc CALENDAR_GET_CLASS*(obj: pointer): PCalendarClass = 
-  result = cast[PCalendarClass](CHECK_GET_CLASS(obj, TYPE_CALENDAR()))
-
-proc TYPE_CELL_EDITABLE*(): GType = 
-  result = cell_editable_get_type()
-
-proc CELL_EDITABLE*(obj: pointer): PCellEditable = 
-  result = cast[PCellEditable](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_CELL_EDITABLE()))
-
-proc CELL_EDITABLE_CLASS*(obj: pointer): PCellEditableIface = 
-  result = cast[PCellEditableIface](G_TYPE_CHECK_CLASS_CAST(obj, 
-      TYPE_CELL_EDITABLE()))
-
-proc IS_CELL_EDITABLE*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_CELL_EDITABLE())
-
-proc CELL_EDITABLE_GET_IFACE*(obj: pointer): PCellEditableIface = 
-  result = cast[PCellEditableIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, 
-      TYPE_CELL_EDITABLE()))
-
-proc TYPE_CELL_RENDERER*(): GType = 
-  result = cell_renderer_get_type()
-
-proc CELL_RENDERER*(obj: pointer): PCellRenderer = 
-  result = cast[PCellRenderer](CHECK_CAST(obj, TYPE_CELL_RENDERER()))
-
-proc CELL_RENDERER_CLASS*(klass: pointer): PCellRendererClass = 
-  result = cast[PCellRendererClass](CHECK_CLASS_CAST(klass, TYPE_CELL_RENDERER()))
-
-proc IS_CELL_RENDERER*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CELL_RENDERER())
-
-proc IS_CELL_RENDERER_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CELL_RENDERER())
-
-proc CELL_RENDERER_GET_CLASS*(obj: pointer): PCellRendererClass = 
-  result = cast[PCellRendererClass](CHECK_GET_CLASS(obj, TYPE_CELL_RENDERER()))
-
-proc mode*(a: PCellRenderer): guint = 
-  result = (a.CellRendererflag0 and bm_TGtkCellRenderer_mode) shr
-      bp_TGtkCellRenderer_mode
-
-proc set_mode*(a: PCellRenderer, `mode`: guint) = 
-  a.CellRendererflag0 = a.CellRendererflag0 or
-      (int16(`mode` shl bp_TGtkCellRenderer_mode) and
-      bm_TGtkCellRenderer_mode)
-
-proc visible*(a: PCellRenderer): guint = 
-  result = (a.CellRendererflag0 and bm_TGtkCellRenderer_visible) shr
-      bp_TGtkCellRenderer_visible
-
-proc set_visible*(a: PCellRenderer, `visible`: guint) = 
-  a.CellRendererflag0 = a.CellRendererflag0 or
-      (int16(`visible` shl bp_TGtkCellRenderer_visible) and
-      bm_TGtkCellRenderer_visible)
-
-proc is_expander*(a: PCellRenderer): guint = 
-  result = (a.CellRendererflag0 and bm_TGtkCellRenderer_is_expander) shr
-      bp_TGtkCellRenderer_is_expander
-
-proc set_is_expander*(a: PCellRenderer, `is_expander`: guint) = 
-  a.CellRendererflag0 = a.CellRendererflag0 or
-      (int16(`is_expander` shl bp_TGtkCellRenderer_is_expander) and
-      bm_TGtkCellRenderer_is_expander)
-
-proc is_expanded*(a: PCellRenderer): guint = 
-  result = (a.CellRendererflag0 and bm_TGtkCellRenderer_is_expanded) shr
-      bp_TGtkCellRenderer_is_expanded
-
-proc set_is_expanded*(a: PCellRenderer, `is_expanded`: guint) = 
-  a.CellRendererflag0 = a.CellRendererflag0 or
-      (int16(`is_expanded` shl bp_TGtkCellRenderer_is_expanded) and
-      bm_TGtkCellRenderer_is_expanded)
-
-proc cell_background_set*(a: PCellRenderer): guint = 
-  result = (a.CellRendererflag0 and bm_TGtkCellRenderer_cell_background_set) shr
-      bp_TGtkCellRenderer_cell_background_set
-
-proc set_cell_background_set*(a: PCellRenderer, `cell_background_set`: guint) = 
-  a.CellRendererflag0 = a.CellRendererflag0 or
-      (int16(`cell_background_set` shl
-      bp_TGtkCellRenderer_cell_background_set) and
-      bm_TGtkCellRenderer_cell_background_set)
-
-proc TYPE_CELL_RENDERER_TEXT*(): GType = 
-  result = cell_renderer_text_get_type()
-
-proc CELL_RENDERER_TEXT*(obj: pointer): PCellRendererText = 
-  result = cast[PCellRendererText](CHECK_CAST(obj, TYPE_CELL_RENDERER_TEXT()))
-
-proc CELL_RENDERER_TEXT_CLASS*(klass: pointer): PCellRendererTextClass = 
-  result = cast[PCellRendererTextClass](CHECK_CLASS_CAST(klass, 
-      TYPE_CELL_RENDERER_TEXT()))
-
-proc IS_CELL_RENDERER_TEXT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CELL_RENDERER_TEXT())
-
-proc IS_CELL_RENDERER_TEXT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CELL_RENDERER_TEXT())
-
-proc CELL_RENDERER_TEXT_GET_CLASS*(obj: pointer): PCellRendererTextClass = 
-  result = cast[PCellRendererTextClass](CHECK_GET_CLASS(obj, 
-      TYPE_CELL_RENDERER_TEXT()))
-
-proc strikethrough*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_strikethrough) shr
-      bp_TGtkCellRendererText_strikethrough
-
-proc set_strikethrough*(a: PCellRendererText, `strikethrough`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`strikethrough` shl bp_TGtkCellRendererText_strikethrough) and
-      bm_TGtkCellRendererText_strikethrough)
-
-proc editable*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_editable) shr
-      bp_TGtkCellRendererText_editable
-
-proc set_editable*(a: PCellRendererText, `editable`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`editable` shl bp_TGtkCellRendererText_editable) and
-      bm_TGtkCellRendererText_editable)
-
-proc scale_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_scale_set) shr
-      bp_TGtkCellRendererText_scale_set
-
-proc set_scale_set*(a: PCellRendererText, `scale_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`scale_set` shl bp_TGtkCellRendererText_scale_set) and
-      bm_TGtkCellRendererText_scale_set)
-
-proc foreground_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and
-      bm_TGtkCellRendererText_foreground_set) shr
-      bp_TGtkCellRendererText_foreground_set
-
-proc set_foreground_set*(a: PCellRendererText, `foreground_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`foreground_set` shl bp_TGtkCellRendererText_foreground_set) and
-      bm_TGtkCellRendererText_foreground_set)
-
-proc background_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and
-      bm_TGtkCellRendererText_background_set) shr
-      bp_TGtkCellRendererText_background_set
-
-proc set_background_set*(a: PCellRendererText, `background_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`background_set` shl bp_TGtkCellRendererText_background_set) and
-      bm_TGtkCellRendererText_background_set)
-
-proc underline_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_underline_set) shr
-      bp_TGtkCellRendererText_underline_set
-
-proc set_underline_set*(a: PCellRendererText, `underline_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`underline_set` shl bp_TGtkCellRendererText_underline_set) and
-      bm_TGtkCellRendererText_underline_set)
-
-proc rise_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_rise_set) shr
-      bp_TGtkCellRendererText_rise_set
-
-proc set_rise_set*(a: PCellRendererText, `rise_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`rise_set` shl bp_TGtkCellRendererText_rise_set) and
-      bm_TGtkCellRendererText_rise_set)
-
-proc strikethrough_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and
-      bm_TGtkCellRendererText_strikethrough_set) shr
-      bp_TGtkCellRendererText_strikethrough_set
-
-proc set_strikethrough_set*(a: PCellRendererText, `strikethrough_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`strikethrough_set` shl
-      bp_TGtkCellRendererText_strikethrough_set) and
-      bm_TGtkCellRendererText_strikethrough_set)
-
-proc editable_set*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and bm_TGtkCellRendererText_editable_set) shr
-      bp_TGtkCellRendererText_editable_set
-
-proc set_editable_set*(a: PCellRendererText, `editable_set`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`editable_set` shl bp_TGtkCellRendererText_editable_set) and
-      bm_TGtkCellRendererText_editable_set)
-
-proc calc_fixed_height*(a: PCellRendererText): guint = 
-  result = (a.CellRendererTextflag0 and
-      bm_TGtkCellRendererText_calc_fixed_height) shr
-      bp_TGtkCellRendererText_calc_fixed_height
-
-proc set_calc_fixed_height*(a: PCellRendererText, `calc_fixed_height`: guint) = 
-  a.CellRendererTextflag0 = a.CellRendererTextflag0 or
-      (int16(`calc_fixed_height` shl
-      bp_TGtkCellRendererText_calc_fixed_height) and
-      bm_TGtkCellRendererText_calc_fixed_height)
-
-proc TYPE_CELL_RENDERER_TOGGLE*(): GType = 
-  result = cell_renderer_toggle_get_type()
-
-proc CELL_RENDERER_TOGGLE*(obj: pointer): PCellRendererToggle = 
-  result = cast[PCellRendererToggle](CHECK_CAST(obj, TYPE_CELL_RENDERER_TOGGLE()))
-
-proc CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): PCellRendererToggleClass = 
-  result = cast[PCellRendererToggleClass](CHECK_CLASS_CAST(klass, 
-      TYPE_CELL_RENDERER_TOGGLE()))
-
-proc IS_CELL_RENDERER_TOGGLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CELL_RENDERER_TOGGLE())
-
-proc IS_CELL_RENDERER_TOGGLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CELL_RENDERER_TOGGLE())
-
-proc CELL_RENDERER_TOGGLE_GET_CLASS*(obj: pointer): PCellRendererToggleClass = 
-  result = cast[PCellRendererToggleClass](CHECK_GET_CLASS(obj, 
-      TYPE_CELL_RENDERER_TOGGLE()))
-
-proc active*(a: PCellRendererToggle): guint = 
-  result = (a.CellRendererToggleflag0 and bm_TGtkCellRendererToggle_active) shr
-      bp_TGtkCellRendererToggle_active
-
-proc set_active*(a: PCellRendererToggle, `active`: guint) = 
-  a.CellRendererToggleflag0 = a.CellRendererToggleflag0 or
-      (int16(`active` shl bp_TGtkCellRendererToggle_active) and
-      bm_TGtkCellRendererToggle_active)
-
-proc activatable*(a: PCellRendererToggle): guint = 
-  result = (a.CellRendererToggleflag0 and
-      bm_TGtkCellRendererToggle_activatable) shr
-      bp_TGtkCellRendererToggle_activatable
-
-proc set_activatable*(a: PCellRendererToggle, `activatable`: guint) = 
-  a.CellRendererToggleflag0 = a.CellRendererToggleflag0 or
-      (int16(`activatable` shl bp_TGtkCellRendererToggle_activatable) and
-      bm_TGtkCellRendererToggle_activatable)
-
-proc radio*(a: PCellRendererToggle): guint = 
-  result = (a.CellRendererToggleflag0 and bm_TGtkCellRendererToggle_radio) shr
-      bp_TGtkCellRendererToggle_radio
-
-proc set_radio*(a: PCellRendererToggle, `radio`: guint) = 
-  a.CellRendererToggleflag0 = a.CellRendererToggleflag0 or
-      (int16(`radio` shl bp_TGtkCellRendererToggle_radio) and
-      bm_TGtkCellRendererToggle_radio)
-
-proc TYPE_CELL_RENDERER_PIXBUF*(): GType = 
-  result = cell_renderer_pixbuf_get_type()
-
-proc CELL_RENDERER_PIXBUF*(obj: pointer): PCellRendererPixbuf = 
-  result = cast[PCellRendererPixbuf](CHECK_CAST(obj, TYPE_CELL_RENDERER_PIXBUF()))
-
-proc CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): PCellRendererPixbufClass = 
-  result = cast[PCellRendererPixbufClass](CHECK_CLASS_CAST(klass, 
-      TYPE_CELL_RENDERER_PIXBUF()))
-
-proc IS_CELL_RENDERER_PIXBUF*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CELL_RENDERER_PIXBUF())
-
-proc IS_CELL_RENDERER_PIXBUF_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CELL_RENDERER_PIXBUF())
-
-proc CELL_RENDERER_PIXBUF_GET_CLASS*(obj: pointer): PCellRendererPixbufClass = 
-  result = cast[PCellRendererPixbufClass](CHECK_GET_CLASS(obj, 
-      TYPE_CELL_RENDERER_PIXBUF()))
-
-proc TYPE_ITEM*(): GType = 
-  result = item_get_type()
-
-proc ITEM*(obj: pointer): PItem = 
-  result = cast[PItem](CHECK_CAST(obj, TYPE_ITEM()))
-
-proc ITEM_CLASS*(klass: pointer): PItemClass = 
-  result = cast[PItemClass](CHECK_CLASS_CAST(klass, TYPE_ITEM()))
-
-proc IS_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ITEM())
-
-proc IS_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ITEM())
-
-proc ITEM_GET_CLASS*(obj: pointer): PItemClass = 
-  result = cast[PItemClass](CHECK_GET_CLASS(obj, TYPE_ITEM()))
-
-proc TYPE_MENU_ITEM*(): GType = 
-  result = menu_item_get_type()
-
-proc MENU_ITEM*(obj: pointer): PMenuItem = 
-  result = cast[PMenuItem](CHECK_CAST(obj, TYPE_MENU_ITEM()))
-
-proc MENU_ITEM_CLASS*(klass: pointer): PMenuItemClass = 
-  result = cast[PMenuItemClass](CHECK_CLASS_CAST(klass, TYPE_MENU_ITEM()))
-
-proc IS_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MENU_ITEM())
-
-proc IS_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MENU_ITEM())
-
-proc MENU_ITEM_GET_CLASS*(obj: pointer): PMenuItemClass = 
-  result = cast[PMenuItemClass](CHECK_GET_CLASS(obj, TYPE_MENU_ITEM()))
-
-proc show_submenu_indicator*(a: PMenuItem): guint = 
-  result = (a.MenuItemflag0 and bm_TGtkMenuItem_show_submenu_indicator) shr
-      bp_TGtkMenuItem_show_submenu_indicator
-
-proc set_show_submenu_indicator*(a: PMenuItem, 
-                                 `show_submenu_indicator`: guint) = 
-  a.MenuItemflag0 = a.MenuItemflag0 or
-      (int16(`show_submenu_indicator` shl
-      bp_TGtkMenuItem_show_submenu_indicator) and
-      bm_TGtkMenuItem_show_submenu_indicator)
-
-proc submenu_placement*(a: PMenuItem): guint = 
-  result = (a.MenuItemflag0 and bm_TGtkMenuItem_submenu_placement) shr
-      bp_TGtkMenuItem_submenu_placement
-
-proc set_submenu_placement*(a: PMenuItem, `submenu_placement`: guint) = 
-  a.MenuItemflag0 = a.MenuItemflag0 or
-      (int16(`submenu_placement` shl bp_TGtkMenuItem_submenu_placement) and
-      bm_TGtkMenuItem_submenu_placement)
-
-proc submenu_direction*(a: PMenuItem): guint = 
-  result = (a.MenuItemflag0 and bm_TGtkMenuItem_submenu_direction) shr
-      bp_TGtkMenuItem_submenu_direction
-
-proc set_submenu_direction*(a: PMenuItem, `submenu_direction`: guint) = 
-  a.MenuItemflag0 = a.MenuItemflag0 or
-      (int16(`submenu_direction` shl bp_TGtkMenuItem_submenu_direction) and
-      bm_TGtkMenuItem_submenu_direction)
-
-proc right_justify*(a: PMenuItem): guint = 
-  result = (a.MenuItemflag0 and bm_TGtkMenuItem_right_justify) shr
-      bp_TGtkMenuItem_right_justify
-
-proc set_right_justify*(a: PMenuItem, `right_justify`: guint) = 
-  a.MenuItemflag0 = a.MenuItemflag0 or
-      (int16(`right_justify` shl bp_TGtkMenuItem_right_justify) and
-      bm_TGtkMenuItem_right_justify)
-
-proc timer_from_keypress*(a: PMenuItem): guint = 
-  result = (a.MenuItemflag0 and bm_TGtkMenuItem_timer_from_keypress) shr
-      bp_TGtkMenuItem_timer_from_keypress
-
-proc set_timer_from_keypress*(a: PMenuItem, `timer_from_keypress`: guint) = 
-  a.MenuItemflag0 = a.MenuItemflag0 or
-      (int16(`timer_from_keypress` shl bp_TGtkMenuItem_timer_from_keypress) and
-      bm_TGtkMenuItem_timer_from_keypress)
-
-proc hide_on_activate*(a: PMenuItemClass): guint = 
-  result = (a.MenuItemClassflag0 and bm_TGtkMenuItemClass_hide_on_activate) shr
-      bp_TGtkMenuItemClass_hide_on_activate
-
-proc set_hide_on_activate*(a: PMenuItemClass, `hide_on_activate`: guint) = 
-  a.MenuItemClassflag0 = a.MenuItemClassflag0 or
-      (int16(`hide_on_activate` shl bp_TGtkMenuItemClass_hide_on_activate) and
-      bm_TGtkMenuItemClass_hide_on_activate)
-
-proc right_justify*(menu_item: PMenuItem) = 
-  set_right_justified(menu_item, system.true)
-
-proc TYPE_TOGGLE_BUTTON*(): GType = 
-  result = toggle_button_get_type()
-
-proc TOGGLE_BUTTON*(obj: pointer): PToggleButton = 
-  result = cast[PToggleButton](CHECK_CAST(obj, TYPE_TOGGLE_BUTTON()))
-
-proc TOGGLE_BUTTON_CLASS*(klass: pointer): PToggleButtonClass = 
-  result = cast[PToggleButtonClass](CHECK_CLASS_CAST(klass, TYPE_TOGGLE_BUTTON()))
-
-proc IS_TOGGLE_BUTTON*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TOGGLE_BUTTON())
-
-proc IS_TOGGLE_BUTTON_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TOGGLE_BUTTON())
-
-proc TOGGLE_BUTTON_GET_CLASS*(obj: pointer): PToggleButtonClass = 
-  result = cast[PToggleButtonClass](CHECK_GET_CLASS(obj, TYPE_TOGGLE_BUTTON()))
-
-proc active*(a: PToggleButton): guint = 
-  result = (a.ToggleButtonflag0 and bm_TGtkToggleButton_active) shr
-      bp_TGtkToggleButton_active
-
-proc set_active*(a: PToggleButton, `active`: guint) = 
-  a.ToggleButtonflag0 = a.ToggleButtonflag0 or
-      (int16(`active` shl bp_TGtkToggleButton_active) and
-      bm_TGtkToggleButton_active)
-
-proc draw_indicator*(a: PToggleButton): guint = 
-  result = (a.ToggleButtonflag0 and bm_TGtkToggleButton_draw_indicator) shr
-      bp_TGtkToggleButton_draw_indicator
-
-proc set_draw_indicator*(a: PToggleButton, `draw_indicator`: guint) = 
-  a.ToggleButtonflag0 = a.ToggleButtonflag0 or
-      (int16(`draw_indicator` shl bp_TGtkToggleButton_draw_indicator) and
-      bm_TGtkToggleButton_draw_indicator)
-
-proc inconsistent*(a: PToggleButton): guint = 
-  result = (a.ToggleButtonflag0 and bm_TGtkToggleButton_inconsistent) shr
-      bp_TGtkToggleButton_inconsistent
-
-proc set_inconsistent*(a: PToggleButton, `inconsistent`: guint) = 
-  a.ToggleButtonflag0 = a.ToggleButtonflag0 or
-      (int16(`inconsistent` shl bp_TGtkToggleButton_inconsistent) and
-      bm_TGtkToggleButton_inconsistent)
-
-proc TYPE_CHECK_BUTTON*(): GType = 
-  result = check_button_get_type()
-
-proc CHECK_BUTTON*(obj: pointer): PCheckButton = 
-  result = cast[PCheckButton](CHECK_CAST(obj, TYPE_CHECK_BUTTON()))
-
-proc CHECK_BUTTON_CLASS*(klass: pointer): PCheckButtonClass = 
-  result = cast[PCheckButtonClass](CHECK_CLASS_CAST(klass, TYPE_CHECK_BUTTON()))
-
-proc IS_CHECK_BUTTON*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CHECK_BUTTON())
-
-proc IS_CHECK_BUTTON_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CHECK_BUTTON())
-
-proc CHECK_BUTTON_GET_CLASS*(obj: pointer): PCheckButtonClass = 
-  result = cast[PCheckButtonClass](CHECK_GET_CLASS(obj, TYPE_CHECK_BUTTON()))
-
-proc TYPE_CHECK_MENU_ITEM*(): GType = 
-  result = check_menu_item_get_type()
-
-proc CHECK_MENU_ITEM*(obj: pointer): PCheckMenuItem = 
-  result = cast[PCheckMenuItem](CHECK_CAST(obj, TYPE_CHECK_MENU_ITEM()))
-
-proc CHECK_MENU_ITEM_CLASS*(klass: pointer): PCheckMenuItemClass = 
-  result = cast[PCheckMenuItemClass](CHECK_CLASS_CAST(klass, 
-      TYPE_CHECK_MENU_ITEM()))
-
-proc IS_CHECK_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CHECK_MENU_ITEM())
-
-proc IS_CHECK_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CHECK_MENU_ITEM())
-
-proc CHECK_MENU_ITEM_GET_CLASS*(obj: pointer): PCheckMenuItemClass = 
-  result = cast[PCheckMenuItemClass](CHECK_GET_CLASS(obj, TYPE_CHECK_MENU_ITEM()))
-
-proc active*(a: PCheckMenuItem): guint = 
-  result = (a.CheckMenuItemflag0 and bm_TGtkCheckMenuItem_active) shr
-      bp_TGtkCheckMenuItem_active
-
-proc set_active*(a: PCheckMenuItem, `active`: guint) = 
-  a.CheckMenuItemflag0 = a.CheckMenuItemflag0 or
-      (int16(`active` shl bp_TGtkCheckMenuItem_active) and
-      bm_TGtkCheckMenuItem_active)
-
-proc always_show_toggle*(a: PCheckMenuItem): guint = 
-  result = (a.CheckMenuItemflag0 and bm_TGtkCheckMenuItem_always_show_toggle) shr
-      bp_TGtkCheckMenuItem_always_show_toggle
-
-proc set_always_show_toggle*(a: PCheckMenuItem, `always_show_toggle`: guint) = 
-  a.CheckMenuItemflag0 = a.CheckMenuItemflag0 or
-      (int16(`always_show_toggle` shl bp_TGtkCheckMenuItem_always_show_toggle) and
-      bm_TGtkCheckMenuItem_always_show_toggle)
-
-proc inconsistent*(a: PCheckMenuItem): guint = 
-  result = (a.CheckMenuItemflag0 and bm_TGtkCheckMenuItem_inconsistent) shr
-      bp_TGtkCheckMenuItem_inconsistent
-
-proc set_inconsistent*(a: PCheckMenuItem, `inconsistent`: guint) = 
-  a.CheckMenuItemflag0 = a.CheckMenuItemflag0 or
-      (int16(`inconsistent` shl bp_TGtkCheckMenuItem_inconsistent) and
-      bm_TGtkCheckMenuItem_inconsistent)
-
-proc TYPE_CLIST*(): GType = 
-  result = clist_get_type()
-
-proc CLIST*(obj: pointer): PCList = 
-  result = cast[PCList](CHECK_CAST(obj, TYPE_CLIST()))
-
-proc CLIST_CLASS*(klass: pointer): PCListClass = 
-  result = cast[PCListClass](CHECK_CLASS_CAST(klass, TYPE_CLIST()))
-
-proc IS_CLIST*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CLIST())
-
-proc IS_CLIST_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CLIST())
-
-proc CLIST_GET_CLASS*(obj: pointer): PCListClass = 
-  result = cast[PCListClass](CHECK_GET_CLASS(obj, TYPE_CLIST()))
-
-proc CLIST_FLAGS*(clist: pointer): guint16 = 
-  result = toU16(CLIST(clist).flags)
-
-proc SET_FLAG*(clist: PCList, flag: guint16) = 
-  clist.flags = CLIST(clist).flags or (flag)
-
-proc UNSET_FLAG*(clist: PCList, flag: guint16) = 
-  clist.flags = CLIST(clist).flags and not (flag)
-
-proc CLIST_IN_DRAG_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_IN_DRAG)) != 0'i32
-
-proc CLIST_ROW_HEIGHT_SET_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_ROW_HEIGHT_SET)) != 0'i32
-
-proc CLIST_SHOW_TITLES_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_SHOW_TITLES)) != 0'i32
-
-proc CLIST_ADD_MODE_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_ADD_MODE)) != 0'i32
-
-proc CLIST_AUTO_SORT_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_AUTO_SORT)) != 0'i32
-
-proc CLIST_AUTO_RESIZE_BLOCKED_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_AUTO_RESIZE_BLOCKED)) != 0'i32
-
-proc CLIST_REORDERABLE_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_REORDERABLE)) != 0'i32
-
-proc CLIST_USE_DRAG_ICONS_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_USE_DRAG_ICONS)) != 0'i32
-
-proc CLIST_DRAW_DRAG_LINE_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_DRAW_DRAG_LINE)) != 0'i32
-
-proc CLIST_DRAW_DRAG_RECT_get*(clist: pointer): bool = 
-  result = ((CLIST_FLAGS(clist)) and cint(CLIST_DRAW_DRAG_RECT)) != 0'i32
-
-proc CLIST_ROW_get*(glist: PGList): PCListRow = 
-  result = cast[PCListRow](glist.data)
-
-when false: 
-  proc CELL_TEXT_get*(cell: pointer): PCellText = 
-    result = cast[PCellText](addr((cell)))
-
-  proc CELL_PIXMAP_get*(cell: pointer): PCellPixmap = 
-    result = cast[PCellPixmap](addr((cell)))
-
-  proc CELL_PIXTEXT_get*(cell: pointer): PCellPixText = 
-    result = cast[PCellPixText](addr((cell)))
-
-  proc CELL_WIDGET_get*(cell: pointer): PCellWidget = 
-    result = cast[PCellWidget](addr((cell)))
-
-proc visible*(a: PCListColumn): guint = 
-  result = (a.flag0 and bm_TGtkCListColumn_visible) shr
-      bp_TGtkCListColumn_visible
-
-proc set_visible*(a: PCListColumn, `visible`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`visible` shl bp_TGtkCListColumn_visible) and
-      bm_TGtkCListColumn_visible)
-
-proc width_set*(a: PCListColumn): guint = 
-  result = (a.flag0 and bm_TGtkCListColumn_width_set) shr
-      bp_TGtkCListColumn_width_set
-
-proc set_width_set*(a: PCListColumn, `width_set`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`width_set` shl bp_TGtkCListColumn_width_set) and
-      bm_TGtkCListColumn_width_set)
-
-proc resizeable*(a: PCListColumn): guint = 
-  result = (a.flag0 and bm_TGtkCListColumn_resizeable) shr
-      bp_TGtkCListColumn_resizeable
-
-proc set_resizeable*(a: PCListColumn, `resizeable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`resizeable` shl bp_TGtkCListColumn_resizeable) and
-      bm_TGtkCListColumn_resizeable)
-
-proc auto_resize*(a: PCListColumn): guint = 
-  result = (a.flag0 and bm_TGtkCListColumn_auto_resize) shr
-      bp_TGtkCListColumn_auto_resize
-
-proc set_auto_resize*(a: PCListColumn, `auto_resize`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`auto_resize` shl bp_TGtkCListColumn_auto_resize) and
-      bm_TGtkCListColumn_auto_resize)
-
-proc button_passive*(a: PCListColumn): guint = 
-  result = (a.flag0 and bm_TGtkCListColumn_button_passive) shr
-      bp_TGtkCListColumn_button_passive
-
-proc set_button_passive*(a: PCListColumn, `button_passive`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`button_passive` shl bp_TGtkCListColumn_button_passive) and
-      bm_TGtkCListColumn_button_passive)
-
-proc fg_set*(a: PCListRow): guint = 
-  result = (a.flag0 and bm_TGtkCListRow_fg_set) shr bp_TGtkCListRow_fg_set
-
-proc set_fg_set*(a: PCListRow, `fg_set`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`fg_set` shl bp_TGtkCListRow_fg_set) and bm_TGtkCListRow_fg_set)
-
-proc bg_set*(a: PCListRow): guint = 
-  result = (a.flag0 and bm_TGtkCListRow_bg_set) shr bp_TGtkCListRow_bg_set
-
-proc set_bg_set*(a: PCListRow, `bg_set`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`bg_set` shl bp_TGtkCListRow_bg_set) and bm_TGtkCListRow_bg_set)
-
-proc selectable*(a: PCListRow): guint = 
-  result = (a.flag0 and bm_TGtkCListRow_selectable) shr
-      bp_TGtkCListRow_selectable
-
-proc set_selectable*(a: PCListRow, `selectable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`selectable` shl bp_TGtkCListRow_selectable) and
-      bm_TGtkCListRow_selectable)
-
-proc TYPE_DIALOG*(): GType = 
-  result = dialog_get_type()
-
-proc DIALOG*(obj: pointer): PDialog = 
-  result = cast[PDialog](CHECK_CAST(obj, TYPE_DIALOG()))
-
-proc DIALOG_CLASS*(klass: pointer): PDialogClass = 
-  result = cast[PDialogClass](CHECK_CLASS_CAST(klass, TYPE_DIALOG()))
-
-proc IS_DIALOG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_DIALOG())
-
-proc IS_DIALOG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_DIALOG())
-
-proc DIALOG_GET_CLASS*(obj: pointer): PDialogClass = 
-  result = cast[PDialogClass](CHECK_GET_CLASS(obj, TYPE_DIALOG()))
-
-proc TYPE_VBOX*(): GType = 
-  result = vbox_get_type()
-
-proc VBOX*(obj: pointer): PVBox = 
-  result = cast[PVBox](CHECK_CAST(obj, TYPE_VBOX()))
-
-proc VBOX_CLASS*(klass: pointer): PVBoxClass = 
-  result = cast[PVBoxClass](CHECK_CLASS_CAST(klass, TYPE_VBOX()))
-
-proc IS_VBOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VBOX())
-
-proc IS_VBOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VBOX())
-
-proc VBOX_GET_CLASS*(obj: pointer): PVBoxClass = 
-  result = cast[PVBoxClass](CHECK_GET_CLASS(obj, TYPE_VBOX()))
-
-proc TYPE_COLOR_SELECTION*(): GType = 
-  result = color_selection_get_type()
-
-proc COLOR_SELECTION*(obj: pointer): PColorSelection = 
-  result = cast[PColorSelection](CHECK_CAST(obj, TYPE_COLOR_SELECTION()))
-
-proc COLOR_SELECTION_CLASS*(klass: pointer): PColorSelectionClass = 
-  result = cast[PColorSelectionClass](CHECK_CLASS_CAST(klass, 
-      TYPE_COLOR_SELECTION()))
-
-proc IS_COLOR_SELECTION*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_COLOR_SELECTION())
-
-proc IS_COLOR_SELECTION_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_COLOR_SELECTION())
-
-proc COLOR_SELECTION_GET_CLASS*(obj: pointer): PColorSelectionClass = 
-  result = cast[PColorSelectionClass](CHECK_GET_CLASS(obj, 
-      TYPE_COLOR_SELECTION()))
-
-proc TYPE_COLOR_SELECTION_DIALOG*(): GType = 
-  result = color_selection_dialog_get_type()
-
-proc COLOR_SELECTION_DIALOG*(obj: pointer): PColorSelectionDialog = 
-  result = cast[PColorSelectionDialog](CHECK_CAST(obj, 
-      TYPE_COLOR_SELECTION_DIALOG()))
-
-proc COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): PColorSelectionDialogClass = 
-  result = cast[PColorSelectionDialogClass](CHECK_CLASS_CAST(klass, 
-      TYPE_COLOR_SELECTION_DIALOG()))
-
-proc IS_COLOR_SELECTION_DIALOG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_COLOR_SELECTION_DIALOG())
-
-proc IS_COLOR_SELECTION_DIALOG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_COLOR_SELECTION_DIALOG())
-
-proc COLOR_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PColorSelectionDialogClass = 
-  result = cast[PColorSelectionDialogClass](CHECK_GET_CLASS(obj, 
-      TYPE_COLOR_SELECTION_DIALOG()))
-
-proc TYPE_HBOX*(): GType = 
-  result = hbox_get_type()
-
-proc HBOX*(obj: pointer): PHBox = 
-  result = cast[PHBox](CHECK_CAST(obj, TYPE_HBOX()))
-
-proc HBOX_CLASS*(klass: pointer): PHBoxClass = 
-  result = cast[PHBoxClass](CHECK_CLASS_CAST(klass, TYPE_HBOX()))
-
-proc IS_HBOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HBOX())
-
-proc IS_HBOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HBOX())
-
-proc HBOX_GET_CLASS*(obj: pointer): PHBoxClass = 
-  result = cast[PHBoxClass](CHECK_GET_CLASS(obj, TYPE_HBOX()))
-
-proc TYPE_COMBO*(): GType = 
-  result = combo_get_type()
-
-proc COMBO*(obj: pointer): PCombo = 
-  result = cast[PCombo](CHECK_CAST(obj, TYPE_COMBO()))
-
-proc COMBO_CLASS*(klass: pointer): PComboClass = 
-  result = cast[PComboClass](CHECK_CLASS_CAST(klass, TYPE_COMBO()))
-
-proc IS_COMBO*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_COMBO())
-
-proc IS_COMBO_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_COMBO())
-
-proc COMBO_GET_CLASS*(obj: pointer): PComboClass = 
-  result = cast[PComboClass](CHECK_GET_CLASS(obj, TYPE_COMBO()))
-
-proc value_in_list*(a: PCombo): guint = 
-  result = (a.Comboflag0 and bm_TGtkCombo_value_in_list) shr
-      bp_TGtkCombo_value_in_list
-
-proc set_value_in_list*(a: PCombo, `value_in_list`: guint) = 
-  a.Comboflag0 = a.Comboflag0 or
-      (int16(`value_in_list` shl bp_TGtkCombo_value_in_list) and
-      bm_TGtkCombo_value_in_list)
-
-proc ok_if_empty*(a: PCombo): guint = 
-  result = (a.Comboflag0 and bm_TGtkCombo_ok_if_empty) shr
-      bp_TGtkCombo_ok_if_empty
-
-proc set_ok_if_empty*(a: PCombo, `ok_if_empty`: guint) = 
-  a.Comboflag0 = a.Comboflag0 or
-      (int16(`ok_if_empty` shl bp_TGtkCombo_ok_if_empty) and
-      bm_TGtkCombo_ok_if_empty)
-
-proc case_sensitive*(a: PCombo): guint = 
-  result = (a.Comboflag0 and bm_TGtkCombo_case_sensitive) shr
-      bp_TGtkCombo_case_sensitive
-
-proc set_case_sensitive*(a: PCombo, `case_sensitive`: guint) = 
-  a.Comboflag0 = a.Comboflag0 or
-      (int16(`case_sensitive` shl bp_TGtkCombo_case_sensitive) and
-      bm_TGtkCombo_case_sensitive)
-
-proc use_arrows*(a: PCombo): guint = 
-  result = (a.Comboflag0 and bm_TGtkCombo_use_arrows) shr
-      bp_TGtkCombo_use_arrows
-
-proc set_use_arrows*(a: PCombo, `use_arrows`: guint) = 
-  a.Comboflag0 = a.Comboflag0 or
-      (int16(`use_arrows` shl bp_TGtkCombo_use_arrows) and
-      bm_TGtkCombo_use_arrows)
-
-proc use_arrows_always*(a: PCombo): guint = 
-  result = (a.Comboflag0 and bm_TGtkCombo_use_arrows_always) shr
-      bp_TGtkCombo_use_arrows_always
-
-proc set_use_arrows_always*(a: PCombo, `use_arrows_always`: guint) = 
-  a.Comboflag0 = a.Comboflag0 or
-      (int16(`use_arrows_always` shl bp_TGtkCombo_use_arrows_always) and
-      bm_TGtkCombo_use_arrows_always)
-
-proc TYPE_CTREE*(): GType = 
-  result = ctree_get_type()
-
-proc CTREE*(obj: pointer): PCTree = 
-  result = cast[PCTree](CHECK_CAST(obj, TYPE_CTREE()))
-
-proc CTREE_CLASS*(klass: pointer): PCTreeClass = 
-  result = cast[PCTreeClass](CHECK_CLASS_CAST(klass, TYPE_CTREE()))
-
-proc IS_CTREE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CTREE())
-
-proc IS_CTREE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CTREE())
-
-proc CTREE_GET_CLASS*(obj: pointer): PCTreeClass = 
-  result = cast[PCTreeClass](CHECK_GET_CLASS(obj, TYPE_CTREE()))
-
-proc CTREE_ROW*(node: TAddress): PCTreeRow = 
-  result = cast[PCTreeRow]((cast[PGList](node)).data)
-
-proc CTREE_NODE*(node: TAddress): PCTreeNode = 
-  result = cast[PCTreeNode](node)
-
-proc CTREE_NODE_NEXT*(nnode: TAddress): PCTreeNode = 
-  result = cast[PCTreeNode]((cast[PGList](nnode)).next)
-
-proc CTREE_NODE_PREV*(pnode: TAddress): PCTreeNode = 
-  result = cast[PCTreeNode]((cast[PGList](pnode)).prev)
-
-proc CTREE_FUNC*(fun: TAddress): TCTreeFunc = 
-  result = cast[TCTreeFunc](fun)
-
-proc TYPE_CTREE_NODE*(): GType = 
-  result = ctree_node_get_type()
-
-proc line_style*(a: PCTree): guint = 
-  result = (a.CTreeflag0 and bm_TGtkCTree_line_style) shr
-      bp_TGtkCTree_line_style
-
-proc set_line_style*(a: PCTree, `line_style`: guint) = 
-  a.CTreeflag0 = a.CTreeflag0 or
-      (int16(`line_style` shl bp_TGtkCTree_line_style) and
-      bm_TGtkCTree_line_style)
-
-proc expander_style*(a: PCTree): guint = 
-  result = (a.CTreeflag0 and bm_TGtkCTree_expander_style) shr
-      bp_TGtkCTree_expander_style
-
-proc set_expander_style*(a: PCTree, `expander_style`: guint) = 
-  a.CTreeflag0 = a.CTreeflag0 or
-      (int16(`expander_style` shl bp_TGtkCTree_expander_style) and
-      bm_TGtkCTree_expander_style)
-
-proc show_stub*(a: PCTree): guint = 
-  result = (a.CTreeflag0 and bm_TGtkCTree_show_stub) shr
-      bp_TGtkCTree_show_stub
-
-proc set_show_stub*(a: PCTree, `show_stub`: guint) = 
-  a.CTreeflag0 = a.CTreeflag0 or
-      (int16(`show_stub` shl bp_TGtkCTree_show_stub) and
-      bm_TGtkCTree_show_stub)
-
-proc is_leaf*(a: PCTreeRow): guint = 
-  result = (a.CTreeRow_flag0 and bm_TGtkCTreeRow_is_leaf) shr
-      bp_TGtkCTreeRow_is_leaf
-
-proc set_is_leaf*(a: PCTreeRow, `is_leaf`: guint) = 
-  a.CTreeRow_flag0 = a.CTreeRow_flag0 or
-      (int16(`is_leaf` shl bp_TGtkCTreeRow_is_leaf) and
-      bm_TGtkCTreeRow_is_leaf)
-
-proc expanded*(a: PCTreeRow): guint = 
-  result = (a.CTreeRow_flag0 and bm_TGtkCTreeRow_expanded) shr
-      bp_TGtkCTreeRow_expanded
-
-proc set_expanded*(a: PCTreeRow, `expanded`: guint) = 
-  a.CTreeRow_flag0 = a.CTreeRowflag0 or
-      (int16(`expanded` shl bp_TGtkCTreeRow_expanded) and
-      bm_TGtkCTreeRow_expanded)
-
-proc ctree_set_reorderable*(t: pointer, r: bool) = 
-  set_reorderable(cast[PCList](t), r)
-
-proc TYPE_DRAWING_AREA*(): GType = 
-  result = drawing_area_get_type()
-
-proc DRAWING_AREA*(obj: pointer): PDrawingArea = 
-  result = cast[PDrawingArea](CHECK_CAST(obj, TYPE_DRAWING_AREA()))
-
-proc DRAWING_AREA_CLASS*(klass: pointer): PDrawingAreaClass = 
-  result = cast[PDrawingAreaClass](CHECK_CLASS_CAST(klass, TYPE_DRAWING_AREA()))
-
-proc IS_DRAWING_AREA*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_DRAWING_AREA())
-
-proc IS_DRAWING_AREA_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_DRAWING_AREA())
-
-proc DRAWING_AREA_GET_CLASS*(obj: pointer): PDrawingAreaClass = 
-  result = cast[PDrawingAreaClass](CHECK_GET_CLASS(obj, TYPE_DRAWING_AREA()))
-
-proc TYPE_CURVE*(): GType = 
-  result = curve_get_type()
-
-proc CURVE*(obj: pointer): PCurve = 
-  result = cast[PCurve](CHECK_CAST(obj, TYPE_CURVE()))
-
-proc CURVE_CLASS*(klass: pointer): PCurveClass = 
-  result = cast[PCurveClass](CHECK_CLASS_CAST(klass, TYPE_CURVE()))
-
-proc IS_CURVE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_CURVE())
-
-proc IS_CURVE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_CURVE())
-
-proc CURVE_GET_CLASS*(obj: pointer): PCurveClass = 
-  result = cast[PCurveClass](CHECK_GET_CLASS(obj, TYPE_CURVE()))
-
-proc TYPE_EDITABLE*(): GType = 
-  result = editable_get_type()
-
-proc EDITABLE*(obj: pointer): PEditable = 
-  result = cast[PEditable](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_EDITABLE()))
-
-proc EDITABLE_CLASS*(vtable: pointer): PEditableClass = 
-  result = cast[PEditableClass](G_TYPE_CHECK_CLASS_CAST(vtable, TYPE_EDITABLE()))
-
-proc IS_EDITABLE*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_EDITABLE())
-
-proc IS_EDITABLE_CLASS*(vtable: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(vtable, TYPE_EDITABLE())
-
-proc EDITABLE_GET_CLASS*(inst: pointer): PEditableClass = 
-  result = cast[PEditableClass](G_TYPE_INSTANCE_GET_INTERFACE(inst, 
-      TYPE_EDITABLE()))
-
-proc TYPE_IM_CONTEXT*(): GType = 
-  result = im_context_get_type()
-
-proc IM_CONTEXT*(obj: pointer): PIMContext = 
-  result = cast[PIMContext](CHECK_CAST(obj, TYPE_IM_CONTEXT()))
-
-proc IM_CONTEXT_CLASS*(klass: pointer): PIMContextClass = 
-  result = cast[PIMContextClass](CHECK_CLASS_CAST(klass, TYPE_IM_CONTEXT()))
-
-proc IS_IM_CONTEXT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_IM_CONTEXT())
-
-proc IS_IM_CONTEXT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_IM_CONTEXT())
-
-proc IM_CONTEXT_GET_CLASS*(obj: pointer): PIMContextClass = 
-  result = cast[PIMContextClass](CHECK_GET_CLASS(obj, TYPE_IM_CONTEXT()))
-
-proc TYPE_MENU_SHELL*(): GType = 
-  result = menu_shell_get_type()
-
-proc MENU_SHELL*(obj: pointer): PMenuShell = 
-  result = cast[PMenuShell](CHECK_CAST(obj, TYPE_MENU_SHELL()))
-
-proc MENU_SHELL_CLASS*(klass: pointer): PMenuShellClass = 
-  result = cast[PMenuShellClass](CHECK_CLASS_CAST(klass, TYPE_MENU_SHELL()))
-
-proc IS_MENU_SHELL*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MENU_SHELL())
-
-proc IS_MENU_SHELL_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MENU_SHELL())
-
-proc MENU_SHELL_GET_CLASS*(obj: pointer): PMenuShellClass = 
-  result = cast[PMenuShellClass](CHECK_GET_CLASS(obj, TYPE_MENU_SHELL()))
-
-proc active*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_active) shr
-      bp_TGtkMenuShell_active
-
-proc set_active*(a: PMenuShell, `active`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`active` shl bp_TGtkMenuShell_active) and
-      bm_TGtkMenuShell_active)
-
-proc have_grab*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_have_grab) shr
-      bp_TGtkMenuShell_have_grab
-
-proc set_have_grab*(a: PMenuShell, `have_grab`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`have_grab` shl bp_TGtkMenuShell_have_grab) and
-      bm_TGtkMenuShell_have_grab)
-
-proc have_xgrab*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_have_xgrab) shr
-      bp_TGtkMenuShell_have_xgrab
-
-proc set_have_xgrab*(a: PMenuShell, `have_xgrab`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`have_xgrab` shl bp_TGtkMenuShell_have_xgrab) and
-      bm_TGtkMenuShell_have_xgrab)
-
-proc ignore_leave*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_ignore_leave) shr
-      bp_TGtkMenuShell_ignore_leave
-
-proc set_ignore_leave*(a: PMenuShell, `ignore_leave`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`ignore_leave` shl bp_TGtkMenuShell_ignore_leave) and
-      bm_TGtkMenuShell_ignore_leave)
-
-proc menu_flag*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_menu_flag) shr
-      bp_TGtkMenuShell_menu_flag
-
-proc set_menu_flag*(a: PMenuShell, `menu_flag`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`menu_flag` shl bp_TGtkMenuShell_menu_flag) and
-      bm_TGtkMenuShell_menu_flag)
-
-proc ignore_enter*(a: PMenuShell): guint = 
-  result = (a.MenuShellflag0 and bm_TGtkMenuShell_ignore_enter) shr
-      bp_TGtkMenuShell_ignore_enter
-
-proc set_ignore_enter*(a: PMenuShell, `ignore_enter`: guint) = 
-  a.MenuShellflag0 = a.MenuShellflag0 or
-      (int16(`ignore_enter` shl bp_TGtkMenuShell_ignore_enter) and
-      bm_TGtkMenuShell_ignore_enter)
-
-proc submenu_placement*(a: PMenuShellClass): guint = 
-  result = (a.MenuShellClassflag0 and bm_TGtkMenuShellClass_submenu_placement) shr
-      bp_TGtkMenuShellClass_submenu_placement
-
-proc set_submenu_placement*(a: PMenuShellClass, `submenu_placement`: guint) = 
-  a.MenuShellClassflag0 = a.MenuShellClassflag0 or
-      (int16(`submenu_placement` shl bp_TGtkMenuShellClass_submenu_placement) and
-      bm_TGtkMenuShellClass_submenu_placement)
-
-proc TYPE_MENU*(): GType = 
-  result = menu_get_type()
-
-proc MENU*(obj: pointer): PMenu = 
-  result = cast[PMenu](CHECK_CAST(obj, TYPE_MENU()))
-
-proc MENU_CLASS*(klass: pointer): PMenuClass = 
-  result = cast[PMenuClass](CHECK_CLASS_CAST(klass, TYPE_MENU()))
-
-proc IS_MENU*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MENU())
-
-proc IS_MENU_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MENU())
-
-proc MENU_GET_CLASS*(obj: pointer): PMenuClass = 
-  result = cast[PMenuClass](CHECK_GET_CLASS(obj, TYPE_MENU()))
-
-proc needs_destruction_ref_count*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_needs_destruction_ref_count) shr
-      bp_TGtkMenu_needs_destruction_ref_count
-
-proc set_needs_destruction_ref_count*(a: PMenu, 
-                                      `needs_destruction_ref_count`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`needs_destruction_ref_count` shl
-      bp_TGtkMenu_needs_destruction_ref_count) and
-      bm_TGtkMenu_needs_destruction_ref_count)
-
-proc torn_off*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_torn_off) shr bp_TGtkMenu_torn_off
-
-proc set_torn_off*(a: PMenu, `torn_off`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`torn_off` shl bp_TGtkMenu_torn_off) and bm_TGtkMenu_torn_off)
-
-proc tearoff_active*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_tearoff_active) shr
-      bp_TGtkMenu_tearoff_active
-
-proc set_tearoff_active*(a: PMenu, `tearoff_active`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`tearoff_active` shl bp_TGtkMenu_tearoff_active) and
-      bm_TGtkMenu_tearoff_active)
-
-proc scroll_fast*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_scroll_fast) shr
-      bp_TGtkMenu_scroll_fast
-
-proc set_scroll_fast*(a: PMenu, `scroll_fast`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`scroll_fast` shl bp_TGtkMenu_scroll_fast) and
-      bm_TGtkMenu_scroll_fast)
-
-proc upper_arrow_visible*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_upper_arrow_visible) shr
-      bp_TGtkMenu_upper_arrow_visible
-
-proc set_upper_arrow_visible*(a: PMenu, `upper_arrow_visible`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`upper_arrow_visible` shl bp_TGtkMenu_upper_arrow_visible) and
-      bm_TGtkMenu_upper_arrow_visible)
-
-proc lower_arrow_visible*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_lower_arrow_visible) shr
-      bp_TGtkMenu_lower_arrow_visible
-
-proc set_lower_arrow_visible*(a: PMenu, `lower_arrow_visible`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`lower_arrow_visible` shl bp_TGtkMenu_lower_arrow_visible) and
-      bm_TGtkMenu_lower_arrow_visible)
-
-proc upper_arrow_prelight*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_upper_arrow_prelight) shr
-      bp_TGtkMenu_upper_arrow_prelight
-
-proc set_upper_arrow_prelight*(a: PMenu, `upper_arrow_prelight`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`upper_arrow_prelight` shl bp_TGtkMenu_upper_arrow_prelight) and
-      bm_TGtkMenu_upper_arrow_prelight)
-
-proc lower_arrow_prelight*(a: PMenu): guint = 
-  result = (a.Menuflag0 and bm_TGtkMenu_lower_arrow_prelight) shr
-      bp_TGtkMenu_lower_arrow_prelight
-
-proc set_lower_arrow_prelight*(a: PMenu, `lower_arrow_prelight`: guint) = 
-  a.Menuflag0 = a.Menuflag0 or
-      (int16(`lower_arrow_prelight` shl bp_TGtkMenu_lower_arrow_prelight) and
-      bm_TGtkMenu_lower_arrow_prelight)
-
-proc menu_append*(menu, child: PWidget) = 
-  append(cast[PMenuShell](menu), child)
-
-proc menu_prepend*(menu, child: PWidget) = 
-  prepend(cast[PMenuShell](menu), child)
-
-proc menu_insert*(menu, child: PWidget, pos: gint) = 
-  insert(cast[PMenuShell](menu), child, pos)
-
-proc TYPE_ENTRY*(): GType = 
-  result = entry_get_type()
-
-proc ENTRY*(obj: pointer): PEntry = 
-  result = cast[PEntry](CHECK_CAST(obj, TYPE_ENTRY()))
-
-proc ENTRY_CLASS*(klass: pointer): PEntryClass = 
-  result = cast[PEntryClass](CHECK_CLASS_CAST(klass, TYPE_ENTRY()))
-
-proc IS_ENTRY*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_ENTRY())
-
-proc IS_ENTRY_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ENTRY())
-
-proc ENTRY_GET_CLASS*(obj: pointer): PEntryClass = 
-  result = cast[PEntryClass](CHECK_GET_CLASS(obj, TYPE_ENTRY()))
-
-proc editable*(a: PEntry): guint = 
-  result = (a.Entryflag0 and bm_TGtkEntry_editable) shr bp_TGtkEntry_editable
-
-proc set_editable*(a: PEntry, `editable`: guint) = 
-  a.Entryflag0 = a.Entryflag0 or
-      (int16(`editable` shl bp_TGtkEntry_editable) and bm_TGtkEntry_editable)
-
-proc visible*(a: PEntry): guint = 
-  result = (a.Entryflag0 and bm_TGtkEntry_visible) shr bp_TGtkEntry_visible
-
-proc set_visible*(a: PEntry, `visible`: guint) = 
-  a.Entryflag0 = a.Entryflag0 or
-      (int16(`visible` shl bp_TGtkEntry_visible) and bm_TGtkEntry_visible)
-
-proc overwrite_mode*(a: PEntry): guint = 
-  result = (a.Entryflag0 and bm_TGtkEntry_overwrite_mode) shr
-      bp_TGtkEntry_overwrite_mode
-
-proc set_overwrite_mode*(a: PEntry, `overwrite_mode`: guint) = 
-  a.Entryflag0 = a.Entryflag0 or
-      (int16(`overwrite_mode` shl bp_TGtkEntry_overwrite_mode) and
-      bm_TGtkEntry_overwrite_mode)
-
-proc in_drag*(a: PEntry): guint = 
-  result = (a.Entryflag0 and bm_TGtkEntry_in_drag) shr bp_TGtkEntry_in_drag
-
-proc set_in_drag*(a: PEntry, `in_drag`: guint) = 
-  a.Entryflag0 = a.Entryflag0 or
-      (int16(`in_drag` shl bp_TGtkEntry_in_drag) and bm_TGtkEntry_in_drag)
-
-proc cache_includes_preedit*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_cache_includes_preedit) shr
-      bp_TGtkEntry_cache_includes_preedit
-
-proc set_cache_includes_preedit*(a: PEntry, `cache_includes_preedit`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`cache_includes_preedit` shl bp_TGtkEntry_cache_includes_preedit) and
-      bm_TGtkEntry_cache_includes_preedit)
-
-proc need_im_reset*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_need_im_reset) shr
-      bp_TGtkEntry_need_im_reset
-
-proc set_need_im_reset*(a: PEntry, `need_im_reset`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`need_im_reset` shl bp_TGtkEntry_need_im_reset) and
-      bm_TGtkEntry_need_im_reset)
-
-proc has_frame*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_has_frame) shr bp_TGtkEntry_has_frame
-
-proc set_has_frame*(a: PEntry, `has_frame`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`has_frame` shl bp_TGtkEntry_has_frame) and
-      bm_TGtkEntry_has_frame)
-
-proc activates_default*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_activates_default) shr
-      bp_TGtkEntry_activates_default
-
-proc set_activates_default*(a: PEntry, `activates_default`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`activates_default` shl bp_TGtkEntry_activates_default) and
-      bm_TGtkEntry_activates_default)
-
-proc cursor_visible*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_cursor_visible) shr
-      bp_TGtkEntry_cursor_visible
-
-proc set_cursor_visible*(a: PEntry, `cursor_visible`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`cursor_visible` shl bp_TGtkEntry_cursor_visible) and
-      bm_TGtkEntry_cursor_visible)
-
-proc in_click*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_in_click) shr bp_TGtkEntry_in_click
-
-proc set_in_click*(a: PEntry, `in_click`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`in_click` shl bp_TGtkEntry_in_click) and bm_TGtkEntry_in_click)
-
-proc is_cell_renderer*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_is_cell_renderer) shr
-      bp_TGtkEntry_is_cell_renderer
-
-proc set_is_cell_renderer*(a: PEntry, `is_cell_renderer`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`is_cell_renderer` shl bp_TGtkEntry_is_cell_renderer) and
-      bm_TGtkEntry_is_cell_renderer)
-
-proc editing_canceled*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_editing_canceled) shr
-      bp_TGtkEntry_editing_canceled
-
-proc set_editing_canceled*(a: PEntry, `editing_canceled`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`editing_canceled` shl bp_TGtkEntry_editing_canceled) and
-      bm_TGtkEntry_editing_canceled)
-
-proc mouse_cursor_obscured*(a: PEntry): guint = 
-  result = (a.flag1 and bm_TGtkEntry_mouse_cursor_obscured) shr
-      bp_TGtkEntry_mouse_cursor_obscured
-
-proc set_mouse_cursor_obscured*(a: PEntry, `mouse_cursor_obscured`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`mouse_cursor_obscured` shl bp_TGtkEntry_mouse_cursor_obscured) and
-      bm_TGtkEntry_mouse_cursor_obscured)
-
-proc TYPE_EVENT_BOX*(): GType = 
-  result = event_box_get_type()
-
-proc EVENT_BOX*(obj: pointer): PEventBox = 
-  result = cast[PEventBox](CHECK_CAST(obj, TYPE_EVENT_BOX()))
-
-proc EVENT_BOX_CLASS*(klass: pointer): PEventBoxClass = 
-  result = cast[PEventBoxClass](CHECK_CLASS_CAST(klass, TYPE_EVENT_BOX()))
-
-proc IS_EVENT_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_EVENT_BOX())
-
-proc IS_EVENT_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_EVENT_BOX())
-
-proc EVENT_BOX_GET_CLASS*(obj: pointer): PEventBoxClass = 
-  result = cast[PEventBoxClass](CHECK_GET_CLASS(obj, TYPE_EVENT_BOX()))
-
-proc TYPE_FILE_SELECTION*(): GType = 
-  result = file_selection_get_type()
-
-proc FILE_SELECTION*(obj: pointer): PFileSelection = 
-  result = cast[PFileSelection](CHECK_CAST(obj, TYPE_FILE_SELECTION()))
-
-proc FILE_SELECTION_CLASS*(klass: pointer): PFileSelectionClass = 
-  result = cast[PFileSelectionClass](CHECK_CLASS_CAST(klass, 
-      TYPE_FILE_SELECTION()))
-
-proc IS_FILE_SELECTION*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_FILE_SELECTION())
-
-proc IS_FILE_SELECTION_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_FILE_SELECTION())
-
-proc FILE_SELECTION_GET_CLASS*(obj: pointer): PFileSelectionClass = 
-  result = cast[PFileSelectionClass](CHECK_GET_CLASS(obj, TYPE_FILE_SELECTION()))
-
-proc TYPE_FIXED*(): GType = 
-  result = fixed_get_type()
-
-proc FIXED*(obj: pointer): PFixed = 
-  result = cast[PFixed](CHECK_CAST(obj, TYPE_FIXED()))
-
-proc FIXED_CLASS*(klass: pointer): PFixedClass = 
-  result = cast[PFixedClass](CHECK_CLASS_CAST(klass, TYPE_FIXED()))
-
-proc IS_FIXED*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_FIXED())
-
-proc IS_FIXED_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_FIXED())
-
-proc FIXED_GET_CLASS*(obj: pointer): PFixedClass = 
-  result = cast[PFixedClass](CHECK_GET_CLASS(obj, TYPE_FIXED()))
-
-proc TYPE_FONT_SELECTION*(): GType = 
-  result = font_selection_get_type()
-
-proc FONT_SELECTION*(obj: pointer): PFontSelection = 
-  result = cast[PFontSelection](CHECK_CAST(obj, TYPE_FONT_SELECTION()))
-
-proc FONT_SELECTION_CLASS*(klass: pointer): PFontSelectionClass = 
-  result = cast[PFontSelectionClass](CHECK_CLASS_CAST(klass, 
-      TYPE_FONT_SELECTION()))
-
-proc IS_FONT_SELECTION*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_FONT_SELECTION())
-
-proc IS_FONT_SELECTION_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_FONT_SELECTION())
-
-proc FONT_SELECTION_GET_CLASS*(obj: pointer): PFontSelectionClass = 
-  result = cast[PFontSelectionClass](CHECK_GET_CLASS(obj, TYPE_FONT_SELECTION()))
-
-proc TYPE_FONT_SELECTION_DIALOG*(): GType = 
-  result = font_selection_dialog_get_type()
-
-proc FONT_SELECTION_DIALOG*(obj: pointer): PFontSelectionDialog = 
-  result = cast[PFontSelectionDialog](CHECK_CAST(obj, 
-      TYPE_FONT_SELECTION_DIALOG()))
-
-proc FONT_SELECTION_DIALOG_CLASS*(klass: pointer): PFontSelectionDialogClass = 
-  result = cast[PFontSelectionDialogClass](CHECK_CLASS_CAST(klass, 
-      TYPE_FONT_SELECTION_DIALOG()))
-
-proc IS_FONT_SELECTION_DIALOG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_FONT_SELECTION_DIALOG())
-
-proc IS_FONT_SELECTION_DIALOG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_FONT_SELECTION_DIALOG())
-
-proc FONT_SELECTION_DIALOG_GET_CLASS*(obj: pointer): PFontSelectionDialogClass = 
-  result = cast[PFontSelectionDialogClass](CHECK_GET_CLASS(obj, 
-      TYPE_FONT_SELECTION_DIALOG()))
-
-proc TYPE_GAMMA_CURVE*(): GType = 
-  result = gamma_curve_get_type()
-
-proc GAMMA_CURVE*(obj: pointer): PGammaCurve = 
-  result = cast[PGammaCurve](CHECK_CAST(obj, TYPE_GAMMA_CURVE()))
-
-proc GAMMA_CURVE_CLASS*(klass: pointer): PGammaCurveClass = 
-  result = cast[PGammaCurveClass](CHECK_CLASS_CAST(klass, TYPE_GAMMA_CURVE()))
-
-proc IS_GAMMA_CURVE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_GAMMA_CURVE())
-
-proc IS_GAMMA_CURVE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_GAMMA_CURVE())
-
-proc GAMMA_CURVE_GET_CLASS*(obj: pointer): PGammaCurveClass = 
-  result = cast[PGammaCurveClass](CHECK_GET_CLASS(obj, TYPE_GAMMA_CURVE()))
-
-proc TYPE_HANDLE_BOX*(): GType = 
-  result = handle_box_get_type()
-
-proc HANDLE_BOX*(obj: pointer): PHandleBox = 
-  result = cast[PHandleBox](CHECK_CAST(obj, TYPE_HANDLE_BOX()))
-
-proc HANDLE_BOX_CLASS*(klass: pointer): PHandleBoxClass = 
-  result = cast[PHandleBoxClass](CHECK_CLASS_CAST(klass, TYPE_HANDLE_BOX()))
-
-proc IS_HANDLE_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HANDLE_BOX())
-
-proc IS_HANDLE_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HANDLE_BOX())
-
-proc HANDLE_BOX_GET_CLASS*(obj: pointer): PHandleBoxClass = 
-  result = cast[PHandleBoxClass](CHECK_GET_CLASS(obj, TYPE_HANDLE_BOX()))
-
-proc handle_position*(a: PHandleBox): guint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_handle_position) shr
-      bp_TGtkHandleBox_handle_position
-
-proc set_handle_position*(a: PHandleBox, `handle_position`: guint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`handle_position` shl bp_TGtkHandleBox_handle_position) and
-      bm_TGtkHandleBox_handle_position)
-
-proc float_window_mapped*(a: PHandleBox): guint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_float_window_mapped) shr
-      bp_TGtkHandleBox_float_window_mapped
-
-proc set_float_window_mapped*(a: PHandleBox, `float_window_mapped`: guint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`float_window_mapped` shl bp_TGtkHandleBox_float_window_mapped) and
-      bm_TGtkHandleBox_float_window_mapped)
-
-proc child_detached*(a: PHandleBox): guint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_child_detached) shr
-      bp_TGtkHandleBox_child_detached
-
-proc set_child_detached*(a: PHandleBox, `child_detached`: guint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`child_detached` shl bp_TGtkHandleBox_child_detached) and
-      bm_TGtkHandleBox_child_detached)
-
-proc in_drag*(a: PHandleBox): guint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_in_drag) shr
-      bp_TGtkHandleBox_in_drag
-
-proc set_in_drag*(a: PHandleBox, `in_drag`: guint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`in_drag` shl bp_TGtkHandleBox_in_drag) and
-      bm_TGtkHandleBox_in_drag)
-
-proc shrink_on_detach*(a: PHandleBox): guint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_shrink_on_detach) shr
-      bp_TGtkHandleBox_shrink_on_detach
-
-proc set_shrink_on_detach*(a: PHandleBox, `shrink_on_detach`: guint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`shrink_on_detach` shl bp_TGtkHandleBox_shrink_on_detach) and
-      bm_TGtkHandleBox_shrink_on_detach)
-
-proc snap_edge*(a: PHandleBox): gint = 
-  result = (a.HandleBoxflag0 and bm_TGtkHandleBox_snap_edge) shr
-      bp_TGtkHandleBox_snap_edge
-
-proc set_snap_edge*(a: PHandleBox, `snap_edge`: gint) = 
-  a.HandleBoxflag0 = a.HandleBoxflag0 or
-      (int16(`snap_edge` shl bp_TGtkHandleBox_snap_edge) and
-      bm_TGtkHandleBox_snap_edge)
-
-proc TYPE_PANED*(): GType = 
-  result = paned_get_type()
-
-proc PANED*(obj: pointer): PPaned = 
-  result = cast[PPaned](CHECK_CAST(obj, TYPE_PANED()))
-
-proc PANED_CLASS*(klass: pointer): PPanedClass = 
-  result = cast[PPanedClass](CHECK_CLASS_CAST(klass, TYPE_PANED()))
-
-proc IS_PANED*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_PANED())
-
-proc IS_PANED_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_PANED())
-
-proc PANED_GET_CLASS*(obj: pointer): PPanedClass = 
-  result = cast[PPanedClass](CHECK_GET_CLASS(obj, TYPE_PANED()))
-
-proc position_set*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_position_set) shr
-      bp_TGtkPaned_position_set
-
-proc set_position_set*(a: PPaned, `position_set`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`position_set` shl bp_TGtkPaned_position_set) and
-      bm_TGtkPaned_position_set)
-
-proc in_drag*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_in_drag) shr bp_TGtkPaned_in_drag
-
-proc set_in_drag*(a: PPaned, `in_drag`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`in_drag` shl bp_TGtkPaned_in_drag) and bm_TGtkPaned_in_drag)
-
-proc child1_shrink*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_child1_shrink) shr
-      bp_TGtkPaned_child1_shrink
-
-proc set_child1_shrink*(a: PPaned, `child1_shrink`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`child1_shrink` shl bp_TGtkPaned_child1_shrink) and
-      bm_TGtkPaned_child1_shrink)
-
-proc child1_resize*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_child1_resize) shr
-      bp_TGtkPaned_child1_resize
-
-proc set_child1_resize*(a: PPaned, `child1_resize`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`child1_resize` shl bp_TGtkPaned_child1_resize) and
-      bm_TGtkPaned_child1_resize)
-
-proc child2_shrink*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_child2_shrink) shr
-      bp_TGtkPaned_child2_shrink
-
-proc set_child2_shrink*(a: PPaned, `child2_shrink`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`child2_shrink` shl bp_TGtkPaned_child2_shrink) and
-      bm_TGtkPaned_child2_shrink)
-
-proc child2_resize*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_child2_resize) shr
-      bp_TGtkPaned_child2_resize
-
-proc set_child2_resize*(a: PPaned, `child2_resize`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`child2_resize` shl bp_TGtkPaned_child2_resize) and
-      bm_TGtkPaned_child2_resize)
-
-proc orientation*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_orientation) shr
-      bp_TGtkPaned_orientation
-
-proc set_orientation*(a: PPaned, `orientation`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`orientation` shl bp_TGtkPaned_orientation) and
-      bm_TGtkPaned_orientation)
-
-proc in_recursion*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_in_recursion) shr
-      bp_TGtkPaned_in_recursion
-
-proc set_in_recursion*(a: PPaned, `in_recursion`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`in_recursion` shl bp_TGtkPaned_in_recursion) and
-      bm_TGtkPaned_in_recursion)
-
-proc handle_prelit*(a: PPaned): guint = 
-  result = (a.Panedflag0 and bm_TGtkPaned_handle_prelit) shr
-      bp_TGtkPaned_handle_prelit
-
-proc set_handle_prelit*(a: PPaned, `handle_prelit`: guint) = 
-  a.Panedflag0 = a.Panedflag0 or
-      (int16(`handle_prelit` shl bp_TGtkPaned_handle_prelit) and
-      bm_TGtkPaned_handle_prelit)
-
-proc paned_gutter_size*(p: pointer, s: gint) = 
-  if (p != nil) and (s != 0'i32): nil
-  
-proc paned_set_gutter_size*(p: pointer, s: gint) = 
-  if (p != nil) and (s != 0'i32): nil
-  
-proc TYPE_HBUTTON_BOX*(): GType = 
-  result = hbutton_box_get_type()
-
-proc HBUTTON_BOX*(obj: pointer): PHButtonBox = 
-  result = cast[PHButtonBox](CHECK_CAST(obj, TYPE_HBUTTON_BOX()))
-
-proc HBUTTON_BOX_CLASS*(klass: pointer): PHButtonBoxClass = 
-  result = cast[PHButtonBoxClass](CHECK_CLASS_CAST(klass, TYPE_HBUTTON_BOX()))
-
-proc IS_HBUTTON_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HBUTTON_BOX())
-
-proc IS_HBUTTON_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HBUTTON_BOX())
-
-proc HBUTTON_BOX_GET_CLASS*(obj: pointer): PHButtonBoxClass = 
-  result = cast[PHButtonBoxClass](CHECK_GET_CLASS(obj, TYPE_HBUTTON_BOX()))
-
-proc TYPE_HPANED*(): GType = 
-  result = hpaned_get_type()
-
-proc HPANED*(obj: pointer): PHPaned = 
-  result = cast[PHPaned](CHECK_CAST(obj, TYPE_HPANED()))
-
-proc HPANED_CLASS*(klass: pointer): PHPanedClass = 
-  result = cast[PHPanedClass](CHECK_CLASS_CAST(klass, TYPE_HPANED()))
-
-proc IS_HPANED*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HPANED())
-
-proc IS_HPANED_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HPANED())
-
-proc HPANED_GET_CLASS*(obj: pointer): PHPanedClass = 
-  result = cast[PHPanedClass](CHECK_GET_CLASS(obj, TYPE_HPANED()))
-
-proc TYPE_RULER*(): GType = 
-  result = ruler_get_type()
-
-proc RULER*(obj: pointer): PRuler = 
-  result = cast[PRuler](CHECK_CAST(obj, TYPE_RULER()))
-
-proc RULER_CLASS*(klass: pointer): PRulerClass = 
-  result = cast[PRulerClass](CHECK_CLASS_CAST(klass, TYPE_RULER()))
-
-proc IS_RULER*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_RULER())
-
-proc IS_RULER_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_RULER())
-
-proc RULER_GET_CLASS*(obj: pointer): PRulerClass = 
-  result = cast[PRulerClass](CHECK_GET_CLASS(obj, TYPE_RULER()))
-
-proc TYPE_HRULER*(): GType = 
-  result = hruler_get_type()
-
-proc HRULER*(obj: pointer): PHRuler = 
-  result = cast[PHRuler](CHECK_CAST(obj, TYPE_HRULER()))
-
-proc HRULER_CLASS*(klass: pointer): PHRulerClass = 
-  result = cast[PHRulerClass](CHECK_CLASS_CAST(klass, TYPE_HRULER()))
-
-proc IS_HRULER*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HRULER())
-
-proc IS_HRULER_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HRULER())
-
-proc HRULER_GET_CLASS*(obj: pointer): PHRulerClass = 
-  result = cast[PHRulerClass](CHECK_GET_CLASS(obj, TYPE_HRULER()))
-
-proc TYPE_SETTINGS*(): GType = 
-  result = settings_get_type()
-
-proc SETTINGS*(obj: pointer): PSettings = 
-  result = cast[PSettings](CHECK_CAST(obj, TYPE_SETTINGS()))
-
-proc SETTINGS_CLASS*(klass: pointer): PSettingsClass = 
-  result = cast[PSettingsClass](CHECK_CLASS_CAST(klass, TYPE_SETTINGS()))
-
-proc IS_SETTINGS*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SETTINGS())
-
-proc IS_SETTINGS_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SETTINGS())
-
-proc SETTINGS_GET_CLASS*(obj: pointer): PSettingsClass = 
-  result = cast[PSettingsClass](CHECK_GET_CLASS(obj, TYPE_SETTINGS()))
-
-proc TYPE_RC_STYLE*(): GType = 
-  result = rc_style_get_type()
-
-proc RC_STYLE_get*(anObject: pointer): PRcStyle = 
-  result = cast[PRcStyle](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_RC_STYLE()))
-
-proc RC_STYLE_CLASS*(klass: pointer): PRcStyleClass = 
-  result = cast[PRcStyleClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_RC_STYLE()))
-
-proc IS_RC_STYLE*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_RC_STYLE())
-
-proc IS_RC_STYLE_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_RC_STYLE())
-
-proc RC_STYLE_GET_CLASS*(obj: pointer): PRcStyleClass = 
-  result = cast[PRcStyleClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_RC_STYLE()))
-
-proc engine_specified*(a: PRcStyle): guint = 
-  result = (a.RcStyleflag0 and bm_TGtkRcStyle_engine_specified) shr
-      bp_TGtkRcStyle_engine_specified
-
-proc set_engine_specified*(a: PRcStyle, `engine_specified`: guint) = 
-  a.RcStyleflag0 = a.RcStyleflag0 or
-      (int16(`engine_specified` shl bp_TGtkRcStyle_engine_specified) and
-      bm_TGtkRcStyle_engine_specified)
-
-proc TYPE_STYLE*(): GType = 
-  result = style_get_type()
-
-proc STYLE*(anObject: pointer): PStyle = 
-  result = cast[PStyle](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_STYLE()))
-
-proc STYLE_CLASS*(klass: pointer): PStyleClass = 
-  result = cast[PStyleClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_STYLE()))
-
-proc IS_STYLE*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_STYLE())
-
-proc IS_STYLE_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_STYLE())
-
-proc STYLE_GET_CLASS*(obj: pointer): PStyleClass = 
-  result = cast[PStyleClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_STYLE()))
-
-proc TYPE_BORDER*(): GType = 
-  result = border_get_type()
-
-proc STYLE_ATTACHED*(style: pointer): bool = 
-  result = ((STYLE(style)).attach_count) > 0'i32
-
-proc apply_default_pixmap*(style: PStyle, window: gdk2.PWindow, 
-                                 state_type: TStateType, area: gdk2.PRectangle, 
-                                 x: gint, y: gint, width: gint, height: gint) = 
-  apply_default_background(style, window, true, state_type, area, x, y, 
-                           width, height)
-
-proc TYPE_RANGE*(): GType = 
-  result = range_get_type()
-
-proc RANGE*(obj: pointer): PRange = 
-  result = cast[PRange](CHECK_CAST(obj, TYPE_RANGE()))
-
-proc RANGE_CLASS*(klass: pointer): PRangeClass = 
-  result = cast[PRangeClass](CHECK_CLASS_CAST(klass, TYPE_RANGE()))
-
-proc IS_RANGE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_RANGE())
-
-proc IS_RANGE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_RANGE())
-
-proc RANGE_GET_CLASS*(obj: pointer): PRangeClass = 
-  result = cast[PRangeClass](CHECK_GET_CLASS(obj, TYPE_RANGE()))
-
-proc inverted*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_inverted) shr bp_TGtkRange_inverted
-
-proc set_inverted*(a: PRange, `inverted`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`inverted` shl bp_TGtkRange_inverted) and bm_TGtkRange_inverted)
-
-proc flippable*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_flippable) shr
-      bp_TGtkRange_flippable
-
-proc set_flippable*(a: PRange, `flippable`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`flippable` shl bp_TGtkRange_flippable) and
-      bm_TGtkRange_flippable)
-
-proc has_stepper_a*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_has_stepper_a) shr
-      bp_TGtkRange_has_stepper_a
-
-proc set_has_stepper_a*(a: PRange, `has_stepper_a`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`has_stepper_a` shl bp_TGtkRange_has_stepper_a) and
-      bm_TGtkRange_has_stepper_a)
-
-proc has_stepper_b*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_has_stepper_b) shr
-      bp_TGtkRange_has_stepper_b
-
-proc set_has_stepper_b*(a: PRange, `has_stepper_b`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`has_stepper_b` shl bp_TGtkRange_has_stepper_b) and
-      bm_TGtkRange_has_stepper_b)
-
-proc has_stepper_c*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_has_stepper_c) shr
-      bp_TGtkRange_has_stepper_c
-
-proc set_has_stepper_c*(a: PRange, `has_stepper_c`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`has_stepper_c` shl bp_TGtkRange_has_stepper_c) and
-      bm_TGtkRange_has_stepper_c)
-
-proc has_stepper_d*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_has_stepper_d) shr
-      bp_TGtkRange_has_stepper_d
-
-proc set_has_stepper_d*(a: PRange, `has_stepper_d`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`has_stepper_d` shl bp_TGtkRange_has_stepper_d) and
-      bm_TGtkRange_has_stepper_d)
-
-proc need_recalc*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_need_recalc) shr
-      bp_TGtkRange_need_recalc
-
-proc set_need_recalc*(a: PRange, `need_recalc`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`need_recalc` shl bp_TGtkRange_need_recalc) and
-      bm_TGtkRange_need_recalc)
-
-proc slider_size_fixed*(a: PRange): guint = 
-  result = (a.Rangeflag0 and bm_TGtkRange_slider_size_fixed) shr
-      bp_TGtkRange_slider_size_fixed
-
-proc set_slider_size_fixed*(a: PRange, `slider_size_fixed`: guint) = 
-  a.Rangeflag0 = a.Rangeflag0 or
-      (int16(`slider_size_fixed` shl bp_TGtkRange_slider_size_fixed) and
-      bm_TGtkRange_slider_size_fixed)
-
-proc trough_click_forward*(a: PRange): guint = 
-  result = (a.flag1 and bm_TGtkRange_trough_click_forward) shr
-      bp_TGtkRange_trough_click_forward
-
-proc set_trough_click_forward*(a: PRange, `trough_click_forward`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`trough_click_forward` shl bp_TGtkRange_trough_click_forward) and
-      bm_TGtkRange_trough_click_forward)
-
-proc update_pending*(a: PRange): guint = 
-  result = (a.flag1 and bm_TGtkRange_update_pending) shr
-      bp_TGtkRange_update_pending
-
-proc set_update_pending*(a: PRange, `update_pending`: guint) = 
-  a.flag1 = a.flag1 or
-      (int16(`update_pending` shl bp_TGtkRange_update_pending) and
-      bm_TGtkRange_update_pending)
-
-proc TYPE_SCALE*(): GType = 
-  result = scale_get_type()
-
-proc SCALE*(obj: pointer): PScale = 
-  result = cast[PScale](CHECK_CAST(obj, TYPE_SCALE()))
-
-proc SCALE_CLASS*(klass: pointer): PScaleClass = 
-  result = cast[PScaleClass](CHECK_CLASS_CAST(klass, TYPE_SCALE()))
-
-proc IS_SCALE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SCALE())
-
-proc IS_SCALE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SCALE())
-
-proc SCALE_GET_CLASS*(obj: pointer): PScaleClass = 
-  result = cast[PScaleClass](CHECK_GET_CLASS(obj, TYPE_SCALE()))
-
-proc draw_value*(a: PScale): guint = 
-  result = (a.Scaleflag0 and bm_TGtkScale_draw_value) shr
-      bp_TGtkScale_draw_value
-
-proc set_draw_value*(a: PScale, `draw_value`: guint) = 
-  a.Scaleflag0 = a.Scaleflag0 or
-      (int16(`draw_value` shl bp_TGtkScale_draw_value) and
-      bm_TGtkScale_draw_value)
-
-proc value_pos*(a: PScale): guint = 
-  result = (a.Scaleflag0 and bm_TGtkScale_value_pos) shr
-      bp_TGtkScale_value_pos
-
-proc set_value_pos*(a: PScale, `value_pos`: guint) = 
-  a.Scaleflag0 = a.Scaleflag0 or
-      (int16(`value_pos` shl bp_TGtkScale_value_pos) and
-      bm_TGtkScale_value_pos)
-
-proc TYPE_HSCALE*(): GType = 
-  result = hscale_get_type()
-
-proc HSCALE*(obj: pointer): PHScale = 
-  result = cast[PHScale](CHECK_CAST(obj, TYPE_HSCALE()))
-
-proc HSCALE_CLASS*(klass: pointer): PHScaleClass = 
-  result = cast[PHScaleClass](CHECK_CLASS_CAST(klass, TYPE_HSCALE()))
-
-proc IS_HSCALE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HSCALE())
-
-proc IS_HSCALE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HSCALE())
-
-proc HSCALE_GET_CLASS*(obj: pointer): PHScaleClass = 
-  result = cast[PHScaleClass](CHECK_GET_CLASS(obj, TYPE_HSCALE()))
-
-proc TYPE_SCROLLBAR*(): GType = 
-  result = scrollbar_get_type()
-
-proc SCROLLBAR*(obj: pointer): PScrollbar = 
-  result = cast[PScrollbar](CHECK_CAST(obj, TYPE_SCROLLBAR()))
-
-proc SCROLLBAR_CLASS*(klass: pointer): PScrollbarClass = 
-  result = cast[PScrollbarClass](CHECK_CLASS_CAST(klass, TYPE_SCROLLBAR()))
-
-proc IS_SCROLLBAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SCROLLBAR())
-
-proc IS_SCROLLBAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SCROLLBAR())
-
-proc SCROLLBAR_GET_CLASS*(obj: pointer): PScrollbarClass = 
-  result = cast[PScrollbarClass](CHECK_GET_CLASS(obj, TYPE_SCROLLBAR()))
-
-proc TYPE_HSCROLLBAR*(): GType = 
-  result = hscrollbar_get_type()
-
-proc HSCROLLBAR*(obj: pointer): PHScrollbar = 
-  result = cast[PHScrollbar](CHECK_CAST(obj, TYPE_HSCROLLBAR()))
-
-proc HSCROLLBAR_CLASS*(klass: pointer): PHScrollbarClass = 
-  result = cast[PHScrollbarClass](CHECK_CLASS_CAST(klass, TYPE_HSCROLLBAR()))
-
-proc IS_HSCROLLBAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HSCROLLBAR())
-
-proc IS_HSCROLLBAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HSCROLLBAR())
-
-proc HSCROLLBAR_GET_CLASS*(obj: pointer): PHScrollbarClass = 
-  result = cast[PHScrollbarClass](CHECK_GET_CLASS(obj, TYPE_HSCROLLBAR()))
-
-proc TYPE_SEPARATOR*(): GType = 
-  result = separator_get_type()
-
-proc SEPARATOR*(obj: pointer): PSeparator = 
-  result = cast[PSeparator](CHECK_CAST(obj, TYPE_SEPARATOR()))
-
-proc SEPARATOR_CLASS*(klass: pointer): PSeparatorClass = 
-  result = cast[PSeparatorClass](CHECK_CLASS_CAST(klass, TYPE_SEPARATOR()))
-
-proc IS_SEPARATOR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SEPARATOR())
-
-proc IS_SEPARATOR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SEPARATOR())
-
-proc SEPARATOR_GET_CLASS*(obj: pointer): PSeparatorClass = 
-  result = cast[PSeparatorClass](CHECK_GET_CLASS(obj, TYPE_SEPARATOR()))
-
-proc TYPE_HSEPARATOR*(): GType = 
-  result = hseparator_get_type()
-
-proc HSEPARATOR*(obj: pointer): PHSeparator = 
-  result = cast[PHSeparator](CHECK_CAST(obj, TYPE_HSEPARATOR()))
-
-proc HSEPARATOR_CLASS*(klass: pointer): PHSeparatorClass = 
-  result = cast[PHSeparatorClass](CHECK_CLASS_CAST(klass, TYPE_HSEPARATOR()))
-
-proc IS_HSEPARATOR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_HSEPARATOR())
-
-proc IS_HSEPARATOR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_HSEPARATOR())
-
-proc HSEPARATOR_GET_CLASS*(obj: pointer): PHSeparatorClass = 
-  result = cast[PHSeparatorClass](CHECK_GET_CLASS(obj, TYPE_HSEPARATOR()))
-
-proc TYPE_ICON_FACTORY*(): GType = 
-  result = icon_factory_get_type()
-
-proc ICON_FACTORY*(anObject: pointer): PIconFactory = 
-  result = cast[PIconFactory](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_ICON_FACTORY()))
-
-proc ICON_FACTORY_CLASS*(klass: pointer): PIconFactoryClass = 
-  result = cast[PIconFactoryClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_ICON_FACTORY()))
-
-proc IS_ICON_FACTORY*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_ICON_FACTORY())
-
-proc IS_ICON_FACTORY_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_ICON_FACTORY())
-
-proc ICON_FACTORY_GET_CLASS*(obj: pointer): PIconFactoryClass = 
-  result = cast[PIconFactoryClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_ICON_FACTORY()))
-
-proc TYPE_ICON_SET*(): GType = 
-  result = icon_set_get_type()
-
-proc TYPE_ICON_SOURCE*(): GType = 
-  result = icon_source_get_type()
-
-proc TYPE_IMAGE*(): GType = 
-  result = gtk2.image_get_type()
-
-proc IMAGE*(obj: pointer): PImage = 
-  result = cast[PImage](CHECK_CAST(obj, gtk2.TYPE_IMAGE()))
-
-proc IMAGE_CLASS*(klass: pointer): PImageClass = 
-  result = cast[PImageClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_IMAGE()))
-
-proc IS_IMAGE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_IMAGE())
-
-proc IS_IMAGE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_IMAGE())
-
-proc IMAGE_GET_CLASS*(obj: pointer): PImageClass = 
-  result = cast[PImageClass](CHECK_GET_CLASS(obj, gtk2.TYPE_IMAGE()))
-
-proc TYPE_IMAGE_MENU_ITEM*(): GType = 
-  result = image_menu_item_get_type()
-
-proc IMAGE_MENU_ITEM*(obj: pointer): PImageMenuItem = 
-  result = cast[PImageMenuItem](CHECK_CAST(obj, TYPE_IMAGE_MENU_ITEM()))
-
-proc IMAGE_MENU_ITEM_CLASS*(klass: pointer): PImageMenuItemClass = 
-  result = cast[PImageMenuItemClass](CHECK_CLASS_CAST(klass, 
-      TYPE_IMAGE_MENU_ITEM()))
-
-proc IS_IMAGE_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_IMAGE_MENU_ITEM())
-
-proc IS_IMAGE_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_IMAGE_MENU_ITEM())
-
-proc IMAGE_MENU_ITEM_GET_CLASS*(obj: pointer): PImageMenuItemClass = 
-  result = cast[PImageMenuItemClass](CHECK_GET_CLASS(obj, TYPE_IMAGE_MENU_ITEM()))
-
-proc TYPE_IM_CONTEXT_SIMPLE*(): GType = 
-  result = im_context_simple_get_type()
-
-proc IM_CONTEXT_SIMPLE*(obj: pointer): PIMContextSimple = 
-  result = cast[PIMContextSimple](CHECK_CAST(obj, TYPE_IM_CONTEXT_SIMPLE()))
-
-proc IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): PIMContextSimpleClass = 
-  result = cast[PIMContextSimpleClass](CHECK_CLASS_CAST(klass, 
-      TYPE_IM_CONTEXT_SIMPLE()))
-
-proc IS_IM_CONTEXT_SIMPLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_IM_CONTEXT_SIMPLE())
-
-proc IS_IM_CONTEXT_SIMPLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_IM_CONTEXT_SIMPLE())
-
-proc IM_CONTEXT_SIMPLE_GET_CLASS*(obj: pointer): PIMContextSimpleClass = 
-  result = cast[PIMContextSimpleClass](CHECK_GET_CLASS(obj, 
-      TYPE_IM_CONTEXT_SIMPLE()))
-
-proc in_hex_sequence*(a: PIMContextSimple): guint = 
-  result = (a.IMContextSimpleflag0 and bm_TGtkIMContextSimple_in_hex_sequence) shr
-      bp_TGtkIMContextSimple_in_hex_sequence
-
-proc set_in_hex_sequence*(a: PIMContextSimple, `in_hex_sequence`: guint) = 
-  a.IMContextSimpleflag0 = a.IMContextSimpleflag0 or
-      (int16(`in_hex_sequence` shl bp_TGtkIMContextSimple_in_hex_sequence) and
-      bm_TGtkIMContextSimple_in_hex_sequence)
-
-proc TYPE_IM_MULTICONTEXT*(): GType = 
-  result = im_multicontext_get_type()
-
-proc IM_MULTICONTEXT*(obj: pointer): PIMMulticontext = 
-  result = cast[PIMMulticontext](CHECK_CAST(obj, TYPE_IM_MULTICONTEXT()))
-
-proc IM_MULTICONTEXT_CLASS*(klass: pointer): PIMMulticontextClass = 
-  result = cast[PIMMulticontextClass](CHECK_CLASS_CAST(klass, 
-      TYPE_IM_MULTICONTEXT()))
-
-proc IS_IM_MULTICONTEXT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_IM_MULTICONTEXT())
-
-proc IS_IM_MULTICONTEXT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_IM_MULTICONTEXT())
-
-proc IM_MULTICONTEXT_GET_CLASS*(obj: pointer): PIMMulticontextClass = 
-  result = cast[PIMMulticontextClass](CHECK_GET_CLASS(obj, 
-      TYPE_IM_MULTICONTEXT()))
-
-proc TYPE_INPUT_DIALOG*(): GType = 
-  result = input_dialog_get_type()
-
-proc INPUT_DIALOG*(obj: pointer): PInputDialog = 
-  result = cast[PInputDialog](CHECK_CAST(obj, TYPE_INPUT_DIALOG()))
-
-proc INPUT_DIALOG_CLASS*(klass: pointer): PInputDialogClass = 
-  result = cast[PInputDialogClass](CHECK_CLASS_CAST(klass, TYPE_INPUT_DIALOG()))
-
-proc IS_INPUT_DIALOG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_INPUT_DIALOG())
-
-proc IS_INPUT_DIALOG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_INPUT_DIALOG())
-
-proc INPUT_DIALOG_GET_CLASS*(obj: pointer): PInputDialogClass = 
-  result = cast[PInputDialogClass](CHECK_GET_CLASS(obj, TYPE_INPUT_DIALOG()))
-
-proc TYPE_INVISIBLE*(): GType = 
-  result = invisible_get_type()
-
-proc INVISIBLE*(obj: pointer): PInvisible = 
-  result = cast[PInvisible](CHECK_CAST(obj, TYPE_INVISIBLE()))
-
-proc INVISIBLE_CLASS*(klass: pointer): PInvisibleClass = 
-  result = cast[PInvisibleClass](CHECK_CLASS_CAST(klass, TYPE_INVISIBLE()))
-
-proc IS_INVISIBLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_INVISIBLE())
-
-proc IS_INVISIBLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_INVISIBLE())
-
-proc INVISIBLE_GET_CLASS*(obj: pointer): PInvisibleClass = 
-  result = cast[PInvisibleClass](CHECK_GET_CLASS(obj, TYPE_INVISIBLE()))
-
-proc TYPE_ITEM_FACTORY*(): GType = 
-  result = item_factory_get_type()
-
-proc ITEM_FACTORY*(anObject: pointer): PItemFactory = 
-  result = cast[PItemFactory](CHECK_CAST(anObject, TYPE_ITEM_FACTORY()))
-
-proc ITEM_FACTORY_CLASS*(klass: pointer): PItemFactoryClass = 
-  result = cast[PItemFactoryClass](CHECK_CLASS_CAST(klass, TYPE_ITEM_FACTORY()))
-
-proc IS_ITEM_FACTORY*(anObject: pointer): bool = 
-  result = CHECK_TYPE(anObject, TYPE_ITEM_FACTORY())
-
-proc IS_ITEM_FACTORY_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_ITEM_FACTORY())
-
-proc ITEM_FACTORY_GET_CLASS*(obj: pointer): PItemFactoryClass = 
-  result = cast[PItemFactoryClass](CHECK_GET_CLASS(obj, TYPE_ITEM_FACTORY()))
-
-proc TYPE_LAYOUT*(): GType = 
-  result = gtk2.layout_get_type()
-
-proc LAYOUT*(obj: pointer): PLayout = 
-  result = cast[PLayout](CHECK_CAST(obj, gtk2.TYPE_LAYOUT()))
-
-proc LAYOUT_CLASS*(klass: pointer): PLayoutClass = 
-  result = cast[PLayoutClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_LAYOUT()))
-
-proc IS_LAYOUT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_LAYOUT())
-
-proc IS_LAYOUT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_LAYOUT())
-
-proc LAYOUT_GET_CLASS*(obj: pointer): PLayoutClass = 
-  result = cast[PLayoutClass](CHECK_GET_CLASS(obj, gtk2.TYPE_LAYOUT()))
-
-proc TYPE_LIST*(): GType = 
-  result = list_get_type()
-
-proc LIST*(obj: pointer): PList = 
-  result = cast[PList](CHECK_CAST(obj, TYPE_LIST()))
-
-proc LIST_CLASS*(klass: pointer): PListClass = 
-  result = cast[PListClass](CHECK_CLASS_CAST(klass, TYPE_LIST()))
-
-proc IS_LIST*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_LIST())
-
-proc IS_LIST_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_LIST())
-
-proc LIST_GET_CLASS*(obj: pointer): PListClass = 
-  result = cast[PListClass](CHECK_GET_CLASS(obj, TYPE_LIST()))
-
-proc selection_mode*(a: PList): guint = 
-  result = (a.Listflag0 and bm_TGtkList_selection_mode) shr
-      bp_TGtkList_selection_mode
-
-proc set_selection_mode*(a: PList, `selection_mode`: guint) = 
-  a.Listflag0 = a.Listflag0 or
-      (int16(`selection_mode` shl bp_TGtkList_selection_mode) and
-      bm_TGtkList_selection_mode)
-
-proc drag_selection*(a: PList): guint = 
-  result = (a.Listflag0 and bm_TGtkList_drag_selection) shr
-      bp_TGtkList_drag_selection
-
-proc set_drag_selection*(a: PList, `drag_selection`: guint) = 
-  a.Listflag0 = a.Listflag0 or
-      (int16(`drag_selection` shl bp_TGtkList_drag_selection) and
-      bm_TGtkList_drag_selection)
-
-proc add_mode*(a: PList): guint = 
-  result = (a.Listflag0 and bm_TGtkList_add_mode) shr bp_TGtkList_add_mode
-
-proc set_add_mode*(a: PList, `add_mode`: guint) = 
-  a.Listflag0 = a.Listflag0 or
-      (int16(`add_mode` shl bp_TGtkList_add_mode) and bm_TGtkList_add_mode)
-
-proc list_item_get_type(): GType{.importc: "gtk_list_item_get_type", cdecl, 
-                                  dynlib: lib.}
-proc TYPE_LIST_ITEM*(): GType = 
-  result = list_item_get_type()
-
-type 
-  TListItem = object of TItem
-  TListItemClass = object of TItemClass
-  PListItem = ptr TListItem
-  PListItemClass = ptr TListItemClass
-
-proc LIST_ITEM*(obj: pointer): PListItem = 
-  result = cast[PListItem](CHECK_CAST(obj, TYPE_LIST_ITEM()))
-
-proc LIST_ITEM_CLASS*(klass: pointer): PListItemClass = 
-  result = cast[PListItemClass](CHECK_CLASS_CAST(klass, TYPE_LIST_ITEM()))
-
-proc IS_LIST_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_LIST_ITEM())
-
-proc IS_LIST_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_LIST_ITEM())
-
-proc LIST_ITEM_GET_CLASS*(obj: pointer): PListItemClass = 
-  #proc gtk_tree_model_get_type(): GType {.importc, cdecl, dynlib: gtklib.}
-  result = cast[PListItemClass](CHECK_GET_CLASS(obj, TYPE_LIST_ITEM()))
-
-proc TYPE_TREE_MODEL*(): GType = 
-  result = tree_model_get_type()
-
-proc TREE_MODEL*(obj: pointer): PTreeModel = 
-  result = cast[PTreeModel](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_TREE_MODEL()))
-
-proc IS_TREE_MODEL*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TREE_MODEL())
-
-proc TREE_MODEL_GET_IFACE*(obj: pointer): PTreeModelIface = 
-  result = cast[PTreeModelIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, 
-      TYPE_TREE_MODEL()))
-
-proc TYPE_TREE_ITER*(): GType = 
-  result = tree_iter_get_type()
-
-proc TYPE_TREE_PATH*(): GType = 
-  result = tree_path_get_type()
-
-proc tree_path_new_root*(): PTreePath = 
-  result = tree_path_new_first()
-
-proc get_iter_root*(tree_model: PTreeModel, iter: PTreeIter): gboolean = 
-  result = get_iter_first(tree_model, iter)
-
-proc TYPE_TREE_SORTABLE*(): GType = 
-  result = tree_sortable_get_type()
-
-proc TREE_SORTABLE*(obj: pointer): PTreeSortable = 
-  result = cast[PTreeSortable](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_TREE_SORTABLE()))
-
-proc TREE_SORTABLE_CLASS*(obj: pointer): PTreeSortableIface = 
-  result = cast[PTreeSortableIface](G_TYPE_CHECK_CLASS_CAST(obj, 
-      TYPE_TREE_SORTABLE()))
-
-proc IS_TREE_SORTABLE*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TREE_SORTABLE())
-
-proc TREE_SORTABLE_GET_IFACE*(obj: pointer): PTreeSortableIface = 
-  result = cast[PTreeSortableIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, 
-      TYPE_TREE_SORTABLE()))
-
-proc TYPE_TREE_MODEL_SORT*(): GType = 
-  result = tree_model_sort_get_type()
-
-proc TREE_MODEL_SORT*(obj: pointer): PTreeModelSort = 
-  result = cast[PTreeModelSort](CHECK_CAST(obj, TYPE_TREE_MODEL_SORT()))
-
-proc TREE_MODEL_SORT_CLASS*(klass: pointer): PTreeModelSortClass = 
-  result = cast[PTreeModelSortClass](CHECK_CLASS_CAST(klass, 
-      TYPE_TREE_MODEL_SORT()))
-
-proc IS_TREE_MODEL_SORT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_MODEL_SORT())
-
-proc IS_TREE_MODEL_SORT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_MODEL_SORT())
-
-proc TREE_MODEL_SORT_GET_CLASS*(obj: pointer): PTreeModelSortClass = 
-  result = cast[PTreeModelSortClass](CHECK_GET_CLASS(obj, TYPE_TREE_MODEL_SORT()))
-
-proc TYPE_LIST_STORE*(): GType = 
-  result = list_store_get_type()
-
-proc LIST_STORE*(obj: pointer): PListStore = 
-  result = cast[PListStore](CHECK_CAST(obj, TYPE_LIST_STORE()))
-
-proc LIST_STORE_CLASS*(klass: pointer): PListStoreClass = 
-  result = cast[PListStoreClass](CHECK_CLASS_CAST(klass, TYPE_LIST_STORE()))
-
-proc IS_LIST_STORE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_LIST_STORE())
-
-proc IS_LIST_STORE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_LIST_STORE())
-
-proc LIST_STORE_GET_CLASS*(obj: pointer): PListStoreClass = 
-  result = cast[PListStoreClass](CHECK_GET_CLASS(obj, TYPE_LIST_STORE()))
-
-proc columns_dirty*(a: PListStore): guint = 
-  result = (a.ListStoreflag0 and bm_TGtkListStore_columns_dirty) shr
-      bp_TGtkListStore_columns_dirty
-
-proc set_columns_dirty*(a: PListStore, `columns_dirty`: guint) = 
-  a.ListStoreflag0 = a.ListStoreflag0 or
-      (int16(`columns_dirty` shl bp_TGtkListStore_columns_dirty) and
-      bm_TGtkListStore_columns_dirty)
-
-proc TYPE_MENU_BAR*(): GType = 
-  result = menu_bar_get_type()
-
-proc MENU_BAR*(obj: pointer): PMenuBar = 
-  result = cast[PMenuBar](CHECK_CAST(obj, TYPE_MENU_BAR()))
-
-proc MENU_BAR_CLASS*(klass: pointer): PMenuBarClass = 
-  result = cast[PMenuBarClass](CHECK_CLASS_CAST(klass, TYPE_MENU_BAR()))
-
-proc IS_MENU_BAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MENU_BAR())
-
-proc IS_MENU_BAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MENU_BAR())
-
-proc MENU_BAR_GET_CLASS*(obj: pointer): PMenuBarClass = 
-  result = cast[PMenuBarClass](CHECK_GET_CLASS(obj, TYPE_MENU_BAR()))
-
-proc menu_bar_append*(menu, child: PWidget) = 
-  append(cast[PMenuShell](menu), child)
-
-proc menu_bar_prepend*(menu, child: PWidget) = 
-  prepend(cast[PMenuShell](menu), child)
-
-proc menu_bar_insert*(menu, child: PWidget, pos: gint) = 
-  insert(cast[PMenuShell](menu), child, pos)
-
-proc TYPE_MESSAGE_DIALOG*(): GType = 
-  result = message_dialog_get_type()
-
-proc MESSAGE_DIALOG*(obj: pointer): PMessageDialog = 
-  result = cast[PMessageDialog](CHECK_CAST(obj, TYPE_MESSAGE_DIALOG()))
-
-proc MESSAGE_DIALOG_CLASS*(klass: pointer): PMessageDialogClass = 
-  result = cast[PMessageDialogClass](CHECK_CLASS_CAST(klass, 
-      TYPE_MESSAGE_DIALOG()))
-
-proc IS_MESSAGE_DIALOG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_MESSAGE_DIALOG())
-
-proc IS_MESSAGE_DIALOG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_MESSAGE_DIALOG())
-
-proc MESSAGE_DIALOG_GET_CLASS*(obj: pointer): PMessageDialogClass = 
-  result = cast[PMessageDialogClass](CHECK_GET_CLASS(obj, TYPE_MESSAGE_DIALOG()))
-
-proc TYPE_NOTEBOOK*(): GType = 
-  result = notebook_get_type()
-
-proc NOTEBOOK*(obj: pointer): PNotebook = 
-  result = cast[PNotebook](CHECK_CAST(obj, TYPE_NOTEBOOK()))
-
-proc NOTEBOOK_CLASS*(klass: pointer): PNotebookClass = 
-  result = cast[PNotebookClass](CHECK_CLASS_CAST(klass, TYPE_NOTEBOOK()))
-
-proc IS_NOTEBOOK*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_NOTEBOOK())
-
-proc IS_NOTEBOOK_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_NOTEBOOK())
-
-proc NOTEBOOK_GET_CLASS*(obj: pointer): PNotebookClass = 
-  result = cast[PNotebookClass](CHECK_GET_CLASS(obj, TYPE_NOTEBOOK()))
-
-proc show_tabs*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_show_tabs) shr
-      bp_TGtkNotebook_show_tabs
-
-proc set_show_tabs*(a: PNotebook, `show_tabs`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`show_tabs` shl bp_TGtkNotebook_show_tabs) and
-      bm_TGtkNotebook_show_tabs)
-
-proc homogeneous*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_homogeneous) shr
-      bp_TGtkNotebook_homogeneous
-
-proc set_homogeneous*(a: PNotebook, `homogeneous`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`homogeneous` shl bp_TGtkNotebook_homogeneous) and
-      bm_TGtkNotebook_homogeneous)
-
-proc show_border*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_show_border) shr
-      bp_TGtkNotebook_show_border
-
-proc set_show_border*(a: PNotebook, `show_border`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`show_border` shl bp_TGtkNotebook_show_border) and
-      bm_TGtkNotebook_show_border)
-
-proc tab_pos*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_tab_pos) shr
-      bp_TGtkNotebook_tab_pos
-
-proc set_tab_pos*(a: PNotebook, `tab_pos`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`tab_pos` shl bp_TGtkNotebook_tab_pos) and
-      bm_TGtkNotebook_tab_pos)
-
-proc scrollable*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_scrollable) shr
-      bp_TGtkNotebook_scrollable
-
-proc set_scrollable*(a: PNotebook, `scrollable`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`scrollable` shl bp_TGtkNotebook_scrollable) and
-      bm_TGtkNotebook_scrollable)
-
-proc in_child*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_in_child) shr
-      bp_TGtkNotebook_in_child
-
-proc set_in_child*(a: PNotebook, `in_child`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`in_child` shl bp_TGtkNotebook_in_child) and
-      bm_TGtkNotebook_in_child)
-
-proc click_child*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_click_child) shr
-      bp_TGtkNotebook_click_child
-
-proc set_click_child*(a: PNotebook, `click_child`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`click_child` shl bp_TGtkNotebook_click_child) and
-      bm_TGtkNotebook_click_child)
-
-proc button*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_button) shr
-      bp_TGtkNotebook_button
-
-proc set_button*(a: PNotebook, `button`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`button` shl bp_TGtkNotebook_button) and bm_TGtkNotebook_button)
-
-proc need_timer*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_need_timer) shr
-      bp_TGtkNotebook_need_timer
-
-proc set_need_timer*(a: PNotebook, `need_timer`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`need_timer` shl bp_TGtkNotebook_need_timer) and
-      bm_TGtkNotebook_need_timer)
-
-proc child_has_focus*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_child_has_focus) shr
-      bp_TGtkNotebook_child_has_focus
-
-proc set_child_has_focus*(a: PNotebook, `child_has_focus`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`child_has_focus` shl bp_TGtkNotebook_child_has_focus) and
-      bm_TGtkNotebook_child_has_focus)
-
-proc have_visible_child*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_have_visible_child) shr
-      bp_TGtkNotebook_have_visible_child
-
-proc set_have_visible_child*(a: PNotebook, `have_visible_child`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`have_visible_child` shl bp_TGtkNotebook_have_visible_child) and
-      bm_TGtkNotebook_have_visible_child)
-
-proc focus_out*(a: PNotebook): guint = 
-  result = (a.Notebookflag0 and bm_TGtkNotebook_focus_out) shr
-      bp_TGtkNotebook_focus_out
-
-proc set_focus_out*(a: PNotebook, `focus_out`: guint) = 
-  a.Notebookflag0 = a.Notebookflag0 or
-      (int16(`focus_out` shl bp_TGtkNotebook_focus_out) and
-      bm_TGtkNotebook_focus_out)
-
-proc TYPE_OLD_EDITABLE*(): GType = 
-  result = old_editable_get_type()
-
-proc OLD_EDITABLE*(obj: pointer): POldEditable = 
-  result = cast[POldEditable](CHECK_CAST(obj, TYPE_OLD_EDITABLE()))
-
-proc OLD_EDITABLE_CLASS*(klass: pointer): POldEditableClass = 
-  result = cast[POldEditableClass](CHECK_CLASS_CAST(klass, TYPE_OLD_EDITABLE()))
-
-proc IS_OLD_EDITABLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_OLD_EDITABLE())
-
-proc IS_OLD_EDITABLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_OLD_EDITABLE())
-
-proc OLD_EDITABLE_GET_CLASS*(obj: pointer): POldEditableClass = 
-  result = cast[POldEditableClass](CHECK_GET_CLASS(obj, TYPE_OLD_EDITABLE()))
-
-proc has_selection*(a: POldEditable): guint = 
-  result = (a.OldEditableflag0 and bm_TGtkOldEditable_has_selection) shr
-      bp_TGtkOldEditable_has_selection
-
-proc set_has_selection*(a: POldEditable, `has_selection`: guint) = 
-  a.OldEditableflag0 = a.OldEditableflag0 or
-      (int16(`has_selection` shl bp_TGtkOldEditable_has_selection) and
-      bm_TGtkOldEditable_has_selection)
-
-proc editable*(a: POldEditable): guint = 
-  result = (a.OldEditableflag0 and bm_TGtkOldEditable_editable) shr
-      bp_TGtkOldEditable_editable
-
-proc set_editable*(a: POldEditable, `editable`: guint) = 
-  a.OldEditableflag0 = a.OldEditableflag0 or
-      (int16(`editable` shl bp_TGtkOldEditable_editable) and
-      bm_TGtkOldEditable_editable)
-
-proc visible*(a: POldEditable): guint = 
-  result = (a.OldEditableflag0 and bm_TGtkOldEditable_visible) shr
-      bp_TGtkOldEditable_visible
-
-proc set_visible*(a: POldEditable, `visible`: guint) = 
-  a.OldEditableflag0 = a.OldEditableflag0 or
-      (int16(`visible` shl bp_TGtkOldEditable_visible) and
-      bm_TGtkOldEditable_visible)
-
-proc TYPE_OPTION_MENU*(): GType = 
-  result = option_menu_get_type()
-
-proc OPTION_MENU*(obj: pointer): POptionMenu = 
-  result = cast[POptionMenu](CHECK_CAST(obj, TYPE_OPTION_MENU()))
-
-proc OPTION_MENU_CLASS*(klass: pointer): POptionMenuClass = 
-  result = cast[POptionMenuClass](CHECK_CLASS_CAST(klass, TYPE_OPTION_MENU()))
-
-proc IS_OPTION_MENU*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_OPTION_MENU())
-
-proc IS_OPTION_MENU_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_OPTION_MENU())
-
-proc OPTION_MENU_GET_CLASS*(obj: pointer): POptionMenuClass = 
-  result = cast[POptionMenuClass](CHECK_GET_CLASS(obj, TYPE_OPTION_MENU()))
-
-proc TYPE_PIXMAP*(): GType = 
-  result = gtk2.pixmap_get_type()
-
-proc PIXMAP*(obj: pointer): PPixmap = 
-  result = cast[PPixmap](CHECK_CAST(obj, gtk2.TYPE_PIXMAP()))
-
-proc PIXMAP_CLASS*(klass: pointer): PPixmapClass = 
-  result = cast[PPixmapClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_PIXMAP()))
-
-proc IS_PIXMAP*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_PIXMAP())
-
-proc IS_PIXMAP_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_PIXMAP())
-
-proc PIXMAP_GET_CLASS*(obj: pointer): PPixmapClass = 
-  result = cast[PPixmapClass](CHECK_GET_CLASS(obj, gtk2.TYPE_PIXMAP()))
-
-proc build_insensitive*(a: PPixmap): guint = 
-  result = (a.Pixmapflag0 and bm_TGtkPixmap_build_insensitive) shr
-      bp_TGtkPixmap_build_insensitive
-
-proc set_build_insensitive*(a: PPixmap, `build_insensitive`: guint) = 
-  a.Pixmapflag0 = a.Pixmapflag0 or
-      (int16(`build_insensitive` shl bp_TGtkPixmap_build_insensitive) and
-      bm_TGtkPixmap_build_insensitive)
-
-proc TYPE_PLUG*(): GType = 
-  result = plug_get_type()
-
-proc PLUG*(obj: pointer): PPlug = 
-  result = cast[PPlug](CHECK_CAST(obj, TYPE_PLUG()))
-
-proc PLUG_CLASS*(klass: pointer): PPlugClass = 
-  result = cast[PPlugClass](CHECK_CLASS_CAST(klass, TYPE_PLUG()))
-
-proc IS_PLUG*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_PLUG())
-
-proc IS_PLUG_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_PLUG())
-
-proc PLUG_GET_CLASS*(obj: pointer): PPlugClass = 
-  result = cast[PPlugClass](CHECK_GET_CLASS(obj, TYPE_PLUG()))
-
-proc same_app*(a: PPlug): guint = 
-  result = (a.Plugflag0 and bm_TGtkPlug_same_app) shr bp_TGtkPlug_same_app
-
-proc set_same_app*(a: PPlug, `same_app`: guint) = 
-  a.Plugflag0 = a.Plugflag0 or
-      (int16(`same_app` shl bp_TGtkPlug_same_app) and bm_TGtkPlug_same_app)
-
-proc TYPE_PREVIEW*(): GType = 
-  result = preview_get_type()
-
-proc PREVIEW*(obj: pointer): PPreview = 
-  result = cast[PPreview](CHECK_CAST(obj, TYPE_PREVIEW()))
-
-proc PREVIEW_CLASS*(klass: pointer): PPreviewClass = 
-  result = cast[PPreviewClass](CHECK_CLASS_CAST(klass, TYPE_PREVIEW()))
-
-proc IS_PREVIEW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_PREVIEW())
-
-proc IS_PREVIEW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_PREVIEW())
-
-proc PREVIEW_GET_CLASS*(obj: pointer): PPreviewClass = 
-  result = cast[PPreviewClass](CHECK_GET_CLASS(obj, TYPE_PREVIEW()))
-
-proc get_type*(a: PPreview): guint = 
-  result = (a.Previewflag0 and bm_TGtkPreview_type) shr bp_TGtkPreview_type
-
-proc set_type*(a: PPreview, `type`: guint) = 
-  a.Previewflag0 = a.Previewflag0 or
-      (int16(`type` shl bp_TGtkPreview_type) and bm_TGtkPreview_type)
-
-proc get_expand*(a: PPreview): guint = 
-  result = (a.Previewflag0 and bm_TGtkPreview_expand) shr
-      bp_TGtkPreview_expand
-
-proc set_expand*(a: PPreview, `expand`: guint) = 
-  a.Previewflag0 = a.Previewflag0 or
-      (int16(`expand` shl bp_TGtkPreview_expand) and bm_TGtkPreview_expand)
-
-proc progress_get_type(): GType{.importc: "gtk_progress_get_type", cdecl, 
-                                 dynlib: lib.}
-proc TYPE_PROGRESS*(): GType = 
-  result = progress_get_type()
-
-proc PROGRESS*(obj: pointer): PProgress = 
-  result = cast[PProgress](CHECK_CAST(obj, TYPE_PROGRESS()))
-
-proc PROGRESS_CLASS*(klass: pointer): PProgressClass = 
-  result = cast[PProgressClass](CHECK_CLASS_CAST(klass, TYPE_PROGRESS()))
-
-proc IS_PROGRESS*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_PROGRESS())
-
-proc IS_PROGRESS_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_PROGRESS())
-
-proc PROGRESS_GET_CLASS*(obj: pointer): PProgressClass = 
-  result = cast[PProgressClass](CHECK_GET_CLASS(obj, TYPE_PROGRESS()))
-
-proc show_text*(a: PProgress): guint = 
-  result = (a.Progressflag0 and bm_TGtkProgress_show_text) shr
-      bp_TGtkProgress_show_text
-
-proc set_show_text*(a: PProgress, `show_text`: guint) = 
-  a.Progressflag0 = a.Progressflag0 or
-      (int16(`show_text` shl bp_TGtkProgress_show_text) and
-      bm_TGtkProgress_show_text)
-
-proc activity_mode*(a: PProgress): guint = 
-  result = (a.Progressflag0 and bm_TGtkProgress_activity_mode) shr
-      bp_TGtkProgress_activity_mode
-
-proc set_activity_mode*(a: PProgress, `activity_mode`: guint) = 
-  a.Progressflag0 = a.Progressflag0 or
-      (int16(`activity_mode` shl bp_TGtkProgress_activity_mode) and
-      bm_TGtkProgress_activity_mode)
-
-proc use_text_format*(a: PProgress): guint = 
-  result = (a.Progressflag0 and bm_TGtkProgress_use_text_format) shr
-      bp_TGtkProgress_use_text_format
-
-proc set_use_text_format*(a: PProgress, `use_text_format`: guint) = 
-  a.Progressflag0 = a.Progressflag0 or
-      (int16(`use_text_format` shl bp_TGtkProgress_use_text_format) and
-      bm_TGtkProgress_use_text_format)
-
-proc TYPE_PROGRESS_BAR*(): GType = 
-  result = progress_bar_get_type()
-
-proc PROGRESS_BAR*(obj: pointer): PProgressBar = 
-  result = cast[PProgressBar](CHECK_CAST(obj, TYPE_PROGRESS_BAR()))
-
-proc PROGRESS_BAR_CLASS*(klass: pointer): PProgressBarClass = 
-  result = cast[PProgressBarClass](CHECK_CLASS_CAST(klass, TYPE_PROGRESS_BAR()))
-
-proc IS_PROGRESS_BAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_PROGRESS_BAR())
-
-proc IS_PROGRESS_BAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_PROGRESS_BAR())
-
-proc PROGRESS_BAR_GET_CLASS*(obj: pointer): PProgressBarClass = 
-  result = cast[PProgressBarClass](CHECK_GET_CLASS(obj, TYPE_PROGRESS_BAR()))
-
-proc activity_dir*(a: PProgressBar): guint = 
-  result = (a.ProgressBarflag0 and bm_TGtkProgressBar_activity_dir) shr
-      bp_TGtkProgressBar_activity_dir
-
-proc set_activity_dir*(a: PProgressBar, `activity_dir`: guint) = 
-  a.ProgressBarflag0 = a.ProgressBarflag0 or
-      (int16(`activity_dir` shl bp_TGtkProgressBar_activity_dir) and
-      bm_TGtkProgressBar_activity_dir)
-
-proc TYPE_RADIO_BUTTON*(): GType = 
-  result = radio_button_get_type()
-
-proc RADIO_BUTTON*(obj: pointer): PRadioButton = 
-  result = cast[PRadioButton](CHECK_CAST(obj, TYPE_RADIO_BUTTON()))
-
-proc RADIO_BUTTON_CLASS*(klass: pointer): PRadioButtonClass = 
-  result = cast[PRadioButtonClass](CHECK_CLASS_CAST(klass, TYPE_RADIO_BUTTON()))
-
-proc IS_RADIO_BUTTON*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_RADIO_BUTTON())
-
-proc IS_RADIO_BUTTON_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_RADIO_BUTTON())
-
-proc RADIO_BUTTON_GET_CLASS*(obj: pointer): PRadioButtonClass = 
-  result = cast[PRadioButtonClass](CHECK_GET_CLASS(obj, TYPE_RADIO_BUTTON()))
-
-proc TYPE_RADIO_MENU_ITEM*(): GType = 
-  result = radio_menu_item_get_type()
-
-proc RADIO_MENU_ITEM*(obj: pointer): PRadioMenuItem = 
-  result = cast[PRadioMenuItem](CHECK_CAST(obj, TYPE_RADIO_MENU_ITEM()))
-
-proc RADIO_MENU_ITEM_CLASS*(klass: pointer): PRadioMenuItemClass = 
-  result = cast[PRadioMenuItemClass](CHECK_CLASS_CAST(klass, 
-      TYPE_RADIO_MENU_ITEM()))
-
-proc IS_RADIO_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_RADIO_MENU_ITEM())
-
-proc IS_RADIO_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_RADIO_MENU_ITEM())
-
-proc RADIO_MENU_ITEM_GET_CLASS*(obj: pointer): PRadioMenuItemClass = 
-  result = cast[PRadioMenuItemClass](CHECK_GET_CLASS(obj, TYPE_RADIO_MENU_ITEM()))
-
-proc TYPE_SCROLLED_WINDOW*(): GType = 
-  result = scrolled_window_get_type()
-
-proc SCROLLED_WINDOW*(obj: pointer): PScrolledWindow = 
-  result = cast[PScrolledWindow](CHECK_CAST(obj, TYPE_SCROLLED_WINDOW()))
-
-proc SCROLLED_WINDOW_CLASS*(klass: pointer): PScrolledWindowClass = 
-  result = cast[PScrolledWindowClass](CHECK_CLASS_CAST(klass, 
-      TYPE_SCROLLED_WINDOW()))
-
-proc IS_SCROLLED_WINDOW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SCROLLED_WINDOW())
-
-proc IS_SCROLLED_WINDOW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SCROLLED_WINDOW())
-
-proc SCROLLED_WINDOW_GET_CLASS*(obj: pointer): PScrolledWindowClass = 
-  result = cast[PScrolledWindowClass](CHECK_GET_CLASS(obj, 
-      TYPE_SCROLLED_WINDOW()))
-
-proc hscrollbar_policy*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and bm_TGtkScrolledWindow_hscrollbar_policy) shr
-      bp_TGtkScrolledWindow_hscrollbar_policy
-
-proc set_hscrollbar_policy*(a: PScrolledWindow, `hscrollbar_policy`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      (int16(`hscrollbar_policy` shl bp_TGtkScrolledWindow_hscrollbar_policy) and
-      bm_TGtkScrolledWindow_hscrollbar_policy)
-
-proc vscrollbar_policy*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and bm_TGtkScrolledWindow_vscrollbar_policy) shr
-      bp_TGtkScrolledWindow_vscrollbar_policy
-
-proc set_vscrollbar_policy*(a: PScrolledWindow, `vscrollbar_policy`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      (int16(`vscrollbar_policy` shl bp_TGtkScrolledWindow_vscrollbar_policy) and
-      bm_TGtkScrolledWindow_vscrollbar_policy)
-
-proc hscrollbar_visible*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and
-      bm_TGtkScrolledWindow_hscrollbar_visible) shr
-      bp_TGtkScrolledWindow_hscrollbar_visible
-
-proc set_hscrollbar_visible*(a: PScrolledWindow, `hscrollbar_visible`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      (int16(`hscrollbar_visible` shl
-      bp_TGtkScrolledWindow_hscrollbar_visible) and
-      bm_TGtkScrolledWindow_hscrollbar_visible)
-
-proc vscrollbar_visible*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and
-      bm_TGtkScrolledWindow_vscrollbar_visible) shr
-      bp_TGtkScrolledWindow_vscrollbar_visible
-
-proc set_vscrollbar_visible*(a: PScrolledWindow, `vscrollbar_visible`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      int16((`vscrollbar_visible` shl
-      bp_TGtkScrolledWindow_vscrollbar_visible) and
-      bm_TGtkScrolledWindow_vscrollbar_visible)
-
-proc window_placement*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and bm_TGtkScrolledWindow_window_placement) shr
-      bp_TGtkScrolledWindow_window_placement
-
-proc set_window_placement*(a: PScrolledWindow, `window_placement`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      (int16(`window_placement` shl bp_TGtkScrolledWindow_window_placement) and
-      bm_TGtkScrolledWindow_window_placement)
-
-proc focus_out*(a: PScrolledWindow): guint = 
-  result = (a.ScrolledWindowflag0 and bm_TGtkScrolledWindow_focus_out) shr
-      bp_TGtkScrolledWindow_focus_out
-
-proc set_focus_out*(a: PScrolledWindow, `focus_out`: guint) = 
-  a.ScrolledWindowflag0 = a.ScrolledWindowflag0 or
-      (int16(`focus_out` shl bp_TGtkScrolledWindow_focus_out) and
-      bm_TGtkScrolledWindow_focus_out)
-
-proc TYPE_SELECTION_DATA*(): GType = 
-  result = selection_data_get_type()
-
-proc TYPE_SEPARATOR_MENU_ITEM*(): GType = 
-  result = separator_menu_item_get_type()
-
-proc SEPARATOR_MENU_ITEM*(obj: pointer): PSeparatorMenuItem = 
-  result = cast[PSeparatorMenuItem](CHECK_CAST(obj, TYPE_SEPARATOR_MENU_ITEM()))
-
-proc SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): PSeparatorMenuItemClass = 
-  result = cast[PSeparatorMenuItemClass](CHECK_CLASS_CAST(klass, 
-      TYPE_SEPARATOR_MENU_ITEM()))
-
-proc IS_SEPARATOR_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SEPARATOR_MENU_ITEM())
-
-proc IS_SEPARATOR_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SEPARATOR_MENU_ITEM())
-
-proc SEPARATOR_MENU_ITEM_GET_CLASS*(obj: pointer): PSeparatorMenuItemClass = 
-  result = cast[PSeparatorMenuItemClass](CHECK_GET_CLASS(obj, 
-      TYPE_SEPARATOR_MENU_ITEM()))
-
-proc signal_lookup*(name: cstring, object_type: GType): guint = 
-  result = g_signal_lookup(name, object_type)
-
-proc signal_name*(signal_id: guint): cstring = 
-  result = g_signal_name(signal_id)
-
-proc signal_emit_stop*(instance: gpointer, signal_id: guint, detail: TGQuark) = 
-  if detail != 0'i32: g_signal_stop_emission(instance, signal_id, 0)
-  
-proc signal_connect_full*(anObject: PObject, name: cstring, fun: TSignalFunc, 
-                          unknown1: pointer, func_data: gpointer, 
-                          unknown2: pointer, unknown3, unknown4: int): gulong{.
-    importc: "gtk_signal_connect_full", cdecl, dynlib: lib.}
-proc signal_compat_matched*(anObject: PObject, fun: TSignalFunc, 
-                            data: gpointer, m: TGSignalMatchType, u: int){.
-    importc: "gtk_signal_compat_matched", cdecl, dynlib: lib.}
-proc signal_connect*(anObject: PObject, name: cstring, fun: TSignalFunc, 
-                     func_data: gpointer): gulong = 
-  result = signal_connect_full(anObject, name, fun, nil, func_data, nil, 0, 0)
-
-proc signal_connect_after*(anObject: PObject, name: cstring, fun: TSignalFunc, 
-                           func_data: gpointer): gulong = 
-  result = signal_connect_full(anObject, name, fun, nil, func_data, nil, 0, 1)
-
-proc signal_connect_object*(anObject: PObject, name: cstring, 
-                            fun: TSignalFunc, slot_object: gpointer): gulong = 
-  result = signal_connect_full(anObject, name, fun, nil, slot_object, nil, 1, 
-                               0)
-
-proc signal_connect_object_after*(anObject: PObject, name: cstring, 
-                                  fun: TSignalFunc, slot_object: gpointer): gulong = 
-  result = signal_connect_full(anObject, name, fun, nil, slot_object, nil, 1, 
-                               1)
-
-proc signal_disconnect*(anObject: gpointer, handler_id: gulong) = 
-  g_signal_handler_disconnect(anObject, handler_id)
-
-proc signal_handler_block*(anObject: gpointer, handler_id: gulong) = 
-  g_signal_handler_block(anObject, handler_id)
-
-proc signal_handler_unblock*(anObject: gpointer, handler_id: gulong) = 
-  g_signal_handler_unblock(anObject, handler_id)
-
-proc signal_disconnect_by_data*(anObject: PObject, data: gpointer) = 
-  signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 0)
-
-proc signal_disconnect_by_func*(anObject: PObject, fun: TSignalFunc, 
-                                data: gpointer) = 
-  signal_compat_matched(anObject, fun, data, cast[TGSignalMatchType](G_SIGNAL_MATCH_FUNC or
-      G_SIGNAL_MATCH_DATA), 0)
-
-proc signal_handler_block_by_func*(anObject: PObject, fun: TSignalFunc, 
-                                   data: gpointer) = 
-  signal_compat_matched(anObject, fun, data, TGSignalMatchType(
-      G_SIGNAL_MATCH_FUNC or G_SIGNAL_MATCH_DATA), 0)
-
-proc signal_handler_block_by_data*(anObject: PObject, data: gpointer) = 
-  signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 1)
-
-proc signal_handler_unblock_by_func*(anObject: PObject, fun: TSignalFunc, 
-                                     data: gpointer) = 
-  signal_compat_matched(anObject, fun, data, cast[TGSignalMatchType](G_SIGNAL_MATCH_FUNC or
-      G_SIGNAL_MATCH_DATA), 0)
-
-proc signal_handler_unblock_by_data*(anObject: PObject, data: gpointer) = 
-  signal_compat_matched(anObject, nil, data, G_SIGNAL_MATCH_DATA, 2)
-
-proc signal_handler_pending*(anObject: PObject, signal_id: guint, 
-                             may_be_blocked: gboolean): gboolean = 
-  Result = g_signal_has_handler_pending(anObject, signal_id, 0, may_be_blocked)
-
-proc signal_handler_pending_by_func*(anObject: PObject, signal_id: guint, 
-                                     may_be_blocked: gboolean, 
-                                     fun: TSignalFunc, 
-                                     data: gpointer): gboolean = 
-  var T: TGSignalMatchType
-  t = cast[TGSignalMatchType](G_SIGNAL_MATCH_ID or G_SIGNAL_MATCH_FUNC or
-      G_SIGNAL_MATCH_DATA)
-  if not may_be_blocked: 
-    t = t or cast[TGSignalMatchType](G_SIGNAL_MATCH_UNBLOCKED)
-  Result = g_signal_handler_find(anObject, t, signal_id, 0, nil, fun, data) !=
-      0
-
-proc TYPE_SIZE_GROUP*(): GType = 
-  result = size_group_get_type()
-
-proc SIZE_GROUP*(obj: pointer): PSizeGroup = 
-  result = cast[PSizeGroup](CHECK_CAST(obj, TYPE_SIZE_GROUP()))
-
-proc SIZE_GROUP_CLASS*(klass: pointer): PSizeGroupClass = 
-  result = cast[PSizeGroupClass](CHECK_CLASS_CAST(klass, TYPE_SIZE_GROUP()))
-
-proc IS_SIZE_GROUP*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SIZE_GROUP())
-
-proc IS_SIZE_GROUP_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SIZE_GROUP())
-
-proc SIZE_GROUP_GET_CLASS*(obj: pointer): PSizeGroupClass = 
-  result = cast[PSizeGroupClass](CHECK_GET_CLASS(obj, TYPE_SIZE_GROUP()))
-
-proc have_width*(a: PSizeGroup): guint = 
-  result = (a.SizeGroupflag0 and bm_TGtkSizeGroup_have_width) shr
-      bp_TGtkSizeGroup_have_width
-
-proc set_have_width*(a: PSizeGroup, `have_width`: guint) = 
-  a.SizeGroupflag0 = a.SizeGroupflag0 or
-      (int16(`have_width` shl bp_TGtkSizeGroup_have_width) and
-      bm_TGtkSizeGroup_have_width)
-
-proc have_height*(a: PSizeGroup): guint = 
-  result = (a.SizeGroupflag0 and bm_TGtkSizeGroup_have_height) shr
-      bp_TGtkSizeGroup_have_height
-
-proc set_have_height*(a: PSizeGroup, `have_height`: guint) = 
-  a.SizeGroupflag0 = a.SizeGroupflag0 or
-      (int16(`have_height` shl bp_TGtkSizeGroup_have_height) and
-      bm_TGtkSizeGroup_have_height)
-
-proc TYPE_SOCKET*(): GType = 
-  result = socket_get_type()
-
-proc SOCKET*(obj: pointer): PSocket = 
-  result = cast[PSocket](CHECK_CAST(obj, TYPE_SOCKET()))
-
-proc SOCKET_CLASS*(klass: pointer): PSocketClass = 
-  result = cast[PSocketClass](CHECK_CLASS_CAST(klass, TYPE_SOCKET()))
-
-proc IS_SOCKET*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SOCKET())
-
-proc IS_SOCKET_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SOCKET())
-
-proc SOCKET_GET_CLASS*(obj: pointer): PSocketClass = 
-  result = cast[PSocketClass](CHECK_GET_CLASS(obj, TYPE_SOCKET()))
-
-proc same_app*(a: PSocket): guint = 
-  result = (a.Socketflag0 and bm_TGtkSocket_same_app) shr
-      bp_TGtkSocket_same_app
-
-proc set_same_app*(a: PSocket, `same_app`: guint) = 
-  a.Socketflag0 = a.Socketflag0 or
-      (int16(`same_app` shl bp_TGtkSocket_same_app) and
-      bm_TGtkSocket_same_app)
-
-proc focus_in*(a: PSocket): guint = 
-  result = (a.Socketflag0 and bm_TGtkSocket_focus_in) shr
-      bp_TGtkSocket_focus_in
-
-proc set_focus_in*(a: PSocket, `focus_in`: guint) = 
-  a.Socketflag0 = a.Socketflag0 or
-      (int16(`focus_in` shl bp_TGtkSocket_focus_in) and
-      bm_TGtkSocket_focus_in)
-
-proc have_size*(a: PSocket): guint = 
-  result = (a.Socketflag0 and bm_TGtkSocket_have_size) shr
-      bp_TGtkSocket_have_size
-
-proc set_have_size*(a: PSocket, `have_size`: guint) = 
-  a.Socketflag0 = a.Socketflag0 or
-      (int16(`have_size` shl bp_TGtkSocket_have_size) and
-      bm_TGtkSocket_have_size)
-
-proc need_map*(a: PSocket): guint = 
-  result = (a.Socketflag0 and bm_TGtkSocket_need_map) shr
-      bp_TGtkSocket_need_map
-
-proc set_need_map*(a: PSocket, `need_map`: guint) = 
-  a.Socketflag0 = a.Socketflag0 or
-      (int16(`need_map` shl bp_TGtkSocket_need_map) and
-      bm_TGtkSocket_need_map)
-
-proc is_mapped*(a: PSocket): guint = 
-  result = (a.Socketflag0 and bm_TGtkSocket_is_mapped) shr
-      bp_TGtkSocket_is_mapped
-
-proc set_is_mapped*(a: PSocket, `is_mapped`: guint) = 
-  a.Socketflag0 = a.Socketflag0 or
-      (int16(`is_mapped` shl bp_TGtkSocket_is_mapped) and
-      bm_TGtkSocket_is_mapped)
-
-proc TYPE_SPIN_BUTTON*(): GType = 
-  result = spin_button_get_type()
-
-proc SPIN_BUTTON*(obj: pointer): PSpinButton = 
-  result = cast[PSpinButton](CHECK_CAST(obj, TYPE_SPIN_BUTTON()))
-
-proc SPIN_BUTTON_CLASS*(klass: pointer): PSpinButtonClass = 
-  result = cast[PSpinButtonClass](CHECK_CLASS_CAST(klass, TYPE_SPIN_BUTTON()))
-
-proc IS_SPIN_BUTTON*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_SPIN_BUTTON())
-
-proc IS_SPIN_BUTTON_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_SPIN_BUTTON())
-
-proc SPIN_BUTTON_GET_CLASS*(obj: pointer): PSpinButtonClass = 
-  result = cast[PSpinButtonClass](CHECK_GET_CLASS(obj, TYPE_SPIN_BUTTON()))
-
-proc in_child*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_in_child) shr
-      bp_TGtkSpinButton_in_child
-
-proc set_in_child*(a: PSpinButton, `in_child`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`in_child` shl bp_TGtkSpinButton_in_child) and
-      bm_TGtkSpinButton_in_child)
-
-proc click_child*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_click_child) shr
-      bp_TGtkSpinButton_click_child
-
-proc set_click_child*(a: PSpinButton, `click_child`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`click_child` shl bp_TGtkSpinButton_click_child) and
-      bm_TGtkSpinButton_click_child)
-
-proc button*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_button) shr
-      bp_TGtkSpinButton_button
-
-proc set_button*(a: PSpinButton, `button`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`button` shl bp_TGtkSpinButton_button) and bm_TGtkSpinButton_button)
-
-proc need_timer*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_need_timer) shr
-      bp_TGtkSpinButton_need_timer
-
-proc set_need_timer*(a: PSpinButton, `need_timer`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`need_timer` shl bp_TGtkSpinButton_need_timer) and
-      bm_TGtkSpinButton_need_timer)
-
-proc timer_calls*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_timer_calls) shr
-      bp_TGtkSpinButton_timer_calls
-
-proc set_timer_calls*(a: PSpinButton, `timer_calls`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`timer_calls` shl bp_TGtkSpinButton_timer_calls) and
-      bm_TGtkSpinButton_timer_calls)
-
-proc digits*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_digits) shr
-      bp_TGtkSpinButton_digits
-
-proc set_digits*(a: PSpinButton, `digits`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`digits` shl bp_TGtkSpinButton_digits) and bm_TGtkSpinButton_digits)
-
-proc numeric*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_numeric) shr
-      bp_TGtkSpinButton_numeric
-
-proc set_numeric*(a: PSpinButton, `numeric`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`numeric` shl bp_TGtkSpinButton_numeric) and
-      bm_TGtkSpinButton_numeric)
-
-proc wrap*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_wrap) shr
-      bp_TGtkSpinButton_wrap
-
-proc set_wrap*(a: PSpinButton, `wrap`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`wrap` shl bp_TGtkSpinButton_wrap) and bm_TGtkSpinButton_wrap)
-
-proc snap_to_ticks*(a: PSpinButton): guint = 
-  result = (a.SpinButtonflag0 and bm_TGtkSpinButton_snap_to_ticks) shr
-      bp_TGtkSpinButton_snap_to_ticks
-
-proc set_snap_to_ticks*(a: PSpinButton, `snap_to_ticks`: guint) = 
-  a.SpinButtonflag0 = a.SpinButtonflag0 or
-      ((`snap_to_ticks` shl bp_TGtkSpinButton_snap_to_ticks) and
-      bm_TGtkSpinButton_snap_to_ticks)
-
-proc TYPE_STATUSBAR*(): GType = 
-  result = statusbar_get_type()
-
-proc STATUSBAR*(obj: pointer): PStatusbar = 
-  result = cast[PStatusbar](CHECK_CAST(obj, TYPE_STATUSBAR()))
-
-proc STATUSBAR_CLASS*(klass: pointer): PStatusbarClass = 
-  result = cast[PStatusbarClass](CHECK_CLASS_CAST(klass, TYPE_STATUSBAR()))
-
-proc IS_STATUSBAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_STATUSBAR())
-
-proc IS_STATUSBAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_STATUSBAR())
-
-proc STATUSBAR_GET_CLASS*(obj: pointer): PStatusbarClass = 
-  result = cast[PStatusbarClass](CHECK_GET_CLASS(obj, TYPE_STATUSBAR()))
-
-proc has_resize_grip*(a: PStatusbar): guint = 
-  result = (a.Statusbarflag0 and bm_TGtkStatusbar_has_resize_grip) shr
-      bp_TGtkStatusbar_has_resize_grip
-
-proc set_has_resize_grip*(a: PStatusbar, `has_resize_grip`: guint) = 
-  a.Statusbarflag0 = a.Statusbarflag0 or
-      (int16(`has_resize_grip` shl bp_TGtkStatusbar_has_resize_grip) and
-      bm_TGtkStatusbar_has_resize_grip)
-
-proc TYPE_TABLE*(): GType = 
-  result = gtk2.table_get_type()
-
-proc TABLE*(obj: pointer): PTable = 
-  result = cast[PTable](CHECK_CAST(obj, gtk2.TYPE_TABLE()))
-
-proc TABLE_CLASS*(klass: pointer): PTableClass = 
-  result = cast[PTableClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_TABLE()))
-
-proc IS_TABLE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_TABLE())
-
-proc IS_TABLE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_TABLE())
-
-proc TABLE_GET_CLASS*(obj: pointer): PTableClass = 
-  result = cast[PTableClass](CHECK_GET_CLASS(obj, gtk2.TYPE_TABLE()))
-
-proc homogeneous*(a: PTable): guint = 
-  result = (a.Tableflag0 and bm_TGtkTable_homogeneous) shr
-      bp_TGtkTable_homogeneous
-
-proc set_homogeneous*(a: PTable, `homogeneous`: guint) = 
-  a.Tableflag0 = a.Tableflag0 or
-      (int16(`homogeneous` shl bp_TGtkTable_homogeneous) and
-      bm_TGtkTable_homogeneous)
-
-proc xexpand*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_xexpand) shr
-      bp_TGtkTableChild_xexpand
-
-proc set_xexpand*(a: PTableChild, `xexpand`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`xexpand` shl bp_TGtkTableChild_xexpand) and
-      bm_TGtkTableChild_xexpand)
-
-proc yexpand*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_yexpand) shr
-      bp_TGtkTableChild_yexpand
-
-proc set_yexpand*(a: PTableChild, `yexpand`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`yexpand` shl bp_TGtkTableChild_yexpand) and
-      bm_TGtkTableChild_yexpand)
-
-proc xshrink*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_xshrink) shr
-      bp_TGtkTableChild_xshrink
-
-proc set_xshrink*(a: PTableChild, `xshrink`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`xshrink` shl bp_TGtkTableChild_xshrink) and
-      bm_TGtkTableChild_xshrink)
-
-proc yshrink*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_yshrink) shr
-      bp_TGtkTableChild_yshrink
-
-proc set_yshrink*(a: PTableChild, `yshrink`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`yshrink` shl bp_TGtkTableChild_yshrink) and
-      bm_TGtkTableChild_yshrink)
-
-proc xfill*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_xfill) shr
-      bp_TGtkTableChild_xfill
-
-proc set_xfill*(a: PTableChild, `xfill`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`xfill` shl bp_TGtkTableChild_xfill) and bm_TGtkTableChild_xfill)
-
-proc yfill*(a: PTableChild): guint = 
-  result = (a.TableChildflag0 and bm_TGtkTableChild_yfill) shr
-      bp_TGtkTableChild_yfill
-
-proc set_yfill*(a: PTableChild, `yfill`: guint) = 
-  a.TableChildflag0 = a.TableChildflag0 or
-      (int16(`yfill` shl bp_TGtkTableChild_yfill) and bm_TGtkTableChild_yfill)
-
-proc need_expand*(a: PTableRowCol): guint = 
-  result = (a.flag0 and bm_TGtkTableRowCol_need_expand) shr
-      bp_TGtkTableRowCol_need_expand
-
-proc set_need_expand*(a: PTableRowCol, `need_expand`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`need_expand` shl bp_TGtkTableRowCol_need_expand) and
-      bm_TGtkTableRowCol_need_expand)
-
-proc need_shrink*(a: PTableRowCol): guint = 
-  result = (a.flag0 and bm_TGtkTableRowCol_need_shrink) shr
-      bp_TGtkTableRowCol_need_shrink
-
-proc set_need_shrink*(a: PTableRowCol, `need_shrink`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`need_shrink` shl bp_TGtkTableRowCol_need_shrink) and
-      bm_TGtkTableRowCol_need_shrink)
-
-proc expand*(a: PTableRowCol): guint = 
-  result = (a.flag0 and bm_TGtkTableRowCol_expand) shr
-      bp_TGtkTableRowCol_expand
-
-proc set_expand*(a: PTableRowCol, `expand`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`expand` shl bp_TGtkTableRowCol_expand) and
-      bm_TGtkTableRowCol_expand)
-
-proc shrink*(a: PTableRowCol): guint = 
-  result = (a.flag0 and bm_TGtkTableRowCol_shrink) shr
-      bp_TGtkTableRowCol_shrink
-
-proc set_shrink*(a: PTableRowCol, `shrink`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`shrink` shl bp_TGtkTableRowCol_shrink) and
-      bm_TGtkTableRowCol_shrink)
-
-proc empty*(a: PTableRowCol): guint = 
-  result = (a.flag0 and bm_TGtkTableRowCol_empty) shr
-      bp_TGtkTableRowCol_empty
-
-proc set_empty*(a: PTableRowCol, `empty`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`empty` shl bp_TGtkTableRowCol_empty) and
-      bm_TGtkTableRowCol_empty)
-
-proc TYPE_TEAROFF_MENU_ITEM*(): GType = 
-  result = tearoff_menu_item_get_type()
-
-proc TEAROFF_MENU_ITEM*(obj: pointer): PTearoffMenuItem = 
-  result = cast[PTearoffMenuItem](CHECK_CAST(obj, TYPE_TEAROFF_MENU_ITEM()))
-
-proc TEAROFF_MENU_ITEM_CLASS*(klass: pointer): PTearoffMenuItemClass = 
-  result = cast[PTearoffMenuItemClass](CHECK_CLASS_CAST(klass, 
-      TYPE_TEAROFF_MENU_ITEM()))
-
-proc IS_TEAROFF_MENU_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TEAROFF_MENU_ITEM())
-
-proc IS_TEAROFF_MENU_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TEAROFF_MENU_ITEM())
-
-proc TEAROFF_MENU_ITEM_GET_CLASS*(obj: pointer): PTearoffMenuItemClass = 
-  result = cast[PTearoffMenuItemClass](CHECK_GET_CLASS(obj, 
-      TYPE_TEAROFF_MENU_ITEM()))
-
-proc torn_off*(a: PTearoffMenuItem): guint = 
-  result = (a.TearoffMenuItemflag0 and bm_TGtkTearoffMenuItem_torn_off) shr
-      bp_TGtkTearoffMenuItem_torn_off
-
-proc set_torn_off*(a: PTearoffMenuItem, `torn_off`: guint) = 
-  a.TearoffMenuItemflag0 = a.TearoffMenuItemflag0 or
-      (int16(`torn_off` shl bp_TGtkTearoffMenuItem_torn_off) and
-      bm_TGtkTearoffMenuItem_torn_off)
-
-proc TYPE_TEXT*(): GType = 
-  result = gtk2.text_get_type()
-
-proc TEXT*(obj: pointer): PText = 
-  result = cast[PText](CHECK_CAST(obj, gtk2.TYPE_TEXT()))
-
-proc TEXT_CLASS*(klass: pointer): PTextClass = 
-  result = cast[PTextClass](CHECK_CLASS_CAST(klass, gtk2.TYPE_TEXT()))
-
-proc IS_TEXT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, gtk2.TYPE_TEXT())
-
-proc IS_TEXT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, gtk2.TYPE_TEXT())
-
-proc TEXT_GET_CLASS*(obj: pointer): PTextClass = 
-  result = cast[PTextClass](CHECK_GET_CLASS(obj, gtk2.TYPE_TEXT()))
-
-proc line_wrap*(a: PText): guint = 
-  result = (a.Textflag0 and bm_TGtkText_line_wrap) shr bp_TGtkText_line_wrap
-
-proc set_line_wrap*(a: PText, `line_wrap`: guint) = 
-  a.Textflag0 = a.Textflag0 or
-      (int16(`line_wrap` shl bp_TGtkText_line_wrap) and bm_TGtkText_line_wrap)
-
-proc word_wrap*(a: PText): guint = 
-  result = (a.Textflag0 and bm_TGtkText_word_wrap) shr bp_TGtkText_word_wrap
-
-proc set_word_wrap*(a: PText, `word_wrap`: guint) = 
-  a.Textflag0 = a.Textflag0 or
-      (int16(`word_wrap` shl bp_TGtkText_word_wrap) and bm_TGtkText_word_wrap)
-
-proc use_wchar*(a: PText): gboolean = 
-  result = ((a.Textflag0 and bm_TGtkText_use_wchar) shr bp_TGtkText_use_wchar) >
-      0'i16
-
-proc set_use_wchar*(a: PText, `use_wchar`: gboolean) = 
-  if `use_wchar`: 
-    a.Textflag0 = a.Textflag0 or bm_TGtkText_use_wchar
-  else: 
-    a.Textflag0 = a.Textflag0 and not bm_TGtkText_use_wchar
-
-proc INDEX_WCHAR*(t: PText, index: guint): guint32 = 
-  nil
-
-proc INDEX_UCHAR*(t: PText, index: guint): GUChar = 
-  nil
-
-proc TYPE_TEXT_ITER*(): GType = 
-  result = text_iter_get_type()
-
-proc TYPE_TEXT_TAG*(): GType = 
-  result = text_tag_get_type()
-
-proc TEXT_TAG*(obj: pointer): PTextTag = 
-  result = cast[PTextTag](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_TEXT_TAG()))
-
-proc TEXT_TAG_CLASS*(klass: pointer): PTextTagClass = 
-  result = cast[PTextTagClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_TEXT_TAG()))
-
-proc IS_TEXT_TAG*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TEXT_TAG())
-
-proc IS_TEXT_TAG_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_TAG())
-
-proc TEXT_TAG_GET_CLASS*(obj: pointer): PTextTagClass = 
-  result = cast[PTextTagClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_TEXT_TAG()))
-
-proc TYPE_TEXT_ATTRIBUTES*(): GType = 
-  result = text_attributes_get_type()
-
-proc bg_color_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_bg_color_set) shr
-      bp_TGtkTextTag_bg_color_set
-
-proc set_bg_color_set*(a: PTextTag, `bg_color_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`bg_color_set` shl bp_TGtkTextTag_bg_color_set) and
-      bm_TGtkTextTag_bg_color_set)
-
-proc bg_stipple_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_bg_stipple_set) shr
-      bp_TGtkTextTag_bg_stipple_set
-
-proc set_bg_stipple_set*(a: PTextTag, `bg_stipple_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`bg_stipple_set` shl bp_TGtkTextTag_bg_stipple_set) and
-      bm_TGtkTextTag_bg_stipple_set)
-
-proc fg_color_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_fg_color_set) shr
-      bp_TGtkTextTag_fg_color_set
-
-proc set_fg_color_set*(a: PTextTag, `fg_color_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`fg_color_set` shl bp_TGtkTextTag_fg_color_set) and
-      bm_TGtkTextTag_fg_color_set)
-
-proc scale_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_scale_set) shr
-      bp_TGtkTextTag_scale_set
-
-proc set_scale_set*(a: PTextTag, `scale_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`scale_set` shl bp_TGtkTextTag_scale_set) and
-      bm_TGtkTextTag_scale_set)
-
-proc fg_stipple_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_fg_stipple_set) shr
-      bp_TGtkTextTag_fg_stipple_set
-
-proc set_fg_stipple_set*(a: PTextTag, `fg_stipple_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`fg_stipple_set` shl bp_TGtkTextTag_fg_stipple_set) and
-      bm_TGtkTextTag_fg_stipple_set)
-
-proc justification_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_justification_set) shr
-      bp_TGtkTextTag_justification_set
-
-proc set_justification_set*(a: PTextTag, `justification_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`justification_set` shl bp_TGtkTextTag_justification_set) and
-      bm_TGtkTextTag_justification_set)
-
-proc left_margin_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_left_margin_set) shr
-      bp_TGtkTextTag_left_margin_set
-
-proc set_left_margin_set*(a: PTextTag, `left_margin_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`left_margin_set` shl bp_TGtkTextTag_left_margin_set) and
-      bm_TGtkTextTag_left_margin_set)
-
-proc indent_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_indent_set) shr
-      bp_TGtkTextTag_indent_set
-
-proc set_indent_set*(a: PTextTag, `indent_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`indent_set` shl bp_TGtkTextTag_indent_set) and
-      bm_TGtkTextTag_indent_set)
-
-proc rise_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_rise_set) shr
-      bp_TGtkTextTag_rise_set
-
-proc set_rise_set*(a: PTextTag, `rise_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`rise_set` shl bp_TGtkTextTag_rise_set) and bm_TGtkTextTag_rise_set)
-
-proc strikethrough_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_strikethrough_set) shr
-      bp_TGtkTextTag_strikethrough_set
-
-proc set_strikethrough_set*(a: PTextTag, `strikethrough_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`strikethrough_set` shl bp_TGtkTextTag_strikethrough_set) and
-      bm_TGtkTextTag_strikethrough_set)
-
-proc right_margin_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_right_margin_set) shr
-      bp_TGtkTextTag_right_margin_set
-
-proc set_right_margin_set*(a: PTextTag, `right_margin_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`right_margin_set` shl bp_TGtkTextTag_right_margin_set) and
-      bm_TGtkTextTag_right_margin_set)
-
-proc pixels_above_lines_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pixels_above_lines_set) shr
-      bp_TGtkTextTag_pixels_above_lines_set
-
-proc set_pixels_above_lines_set*(a: PTextTag, 
-                                 `pixels_above_lines_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pixels_above_lines_set` shl bp_TGtkTextTag_pixels_above_lines_set) and
-      bm_TGtkTextTag_pixels_above_lines_set)
-
-proc pixels_below_lines_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pixels_below_lines_set) shr
-      bp_TGtkTextTag_pixels_below_lines_set
-
-proc set_pixels_below_lines_set*(a: PTextTag, 
-                                 `pixels_below_lines_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pixels_below_lines_set` shl bp_TGtkTextTag_pixels_below_lines_set) and
-      bm_TGtkTextTag_pixels_below_lines_set)
-
-proc pixels_inside_wrap_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pixels_inside_wrap_set) shr
-      bp_TGtkTextTag_pixels_inside_wrap_set
-
-proc set_pixels_inside_wrap_set*(a: PTextTag, 
-                                 `pixels_inside_wrap_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pixels_inside_wrap_set` shl bp_TGtkTextTag_pixels_inside_wrap_set) and
-      bm_TGtkTextTag_pixels_inside_wrap_set)
-
-proc tabs_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_tabs_set) shr
-      bp_TGtkTextTag_tabs_set
-
-proc set_tabs_set*(a: PTextTag, `tabs_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`tabs_set` shl bp_TGtkTextTag_tabs_set) and bm_TGtkTextTag_tabs_set)
-
-proc underline_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_underline_set) shr
-      bp_TGtkTextTag_underline_set
-
-proc set_underline_set*(a: PTextTag, `underline_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`underline_set` shl bp_TGtkTextTag_underline_set) and
-      bm_TGtkTextTag_underline_set)
-
-proc wrap_mode_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_wrap_mode_set) shr
-      bp_TGtkTextTag_wrap_mode_set
-
-proc set_wrap_mode_set*(a: PTextTag, `wrap_mode_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`wrap_mode_set` shl bp_TGtkTextTag_wrap_mode_set) and
-      bm_TGtkTextTag_wrap_mode_set)
-
-proc bg_full_height_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_bg_full_height_set) shr
-      bp_TGtkTextTag_bg_full_height_set
-
-proc set_bg_full_height_set*(a: PTextTag, `bg_full_height_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`bg_full_height_set` shl bp_TGtkTextTag_bg_full_height_set) and
-      bm_TGtkTextTag_bg_full_height_set)
-
-proc invisible_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_invisible_set) shr
-      bp_TGtkTextTag_invisible_set
-
-proc set_invisible_set*(a: PTextTag, `invisible_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`invisible_set` shl bp_TGtkTextTag_invisible_set) and
-      bm_TGtkTextTag_invisible_set)
-
-proc editable_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_editable_set) shr
-      bp_TGtkTextTag_editable_set
-
-proc set_editable_set*(a: PTextTag, `editable_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`editable_set` shl bp_TGtkTextTag_editable_set) and
-      bm_TGtkTextTag_editable_set)
-
-proc language_set*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_language_set) shr
-      bp_TGtkTextTag_language_set
-
-proc set_language_set*(a: PTextTag, `language_set`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`language_set` shl bp_TGtkTextTag_language_set) and
-      bm_TGtkTextTag_language_set)
-
-proc pad1*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pad1) shr bp_TGtkTextTag_pad1
-
-proc set_pad1*(a: PTextTag, `pad1`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pad1` shl bp_TGtkTextTag_pad1) and bm_TGtkTextTag_pad1)
-
-proc pad2*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pad2) shr bp_TGtkTextTag_pad2
-
-proc set_pad2*(a: PTextTag, `pad2`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pad2` shl bp_TGtkTextTag_pad2) and bm_TGtkTextTag_pad2)
-
-proc pad3*(a: PTextTag): guint = 
-  result = (a.TextTagflag0 and bm_TGtkTextTag_pad3) shr bp_TGtkTextTag_pad3
-
-proc set_pad3*(a: PTextTag, `pad3`: guint) = 
-  a.TextTagflag0 = a.TextTagflag0 or
-      ((`pad3` shl bp_TGtkTextTag_pad3) and bm_TGtkTextTag_pad3)
-
-proc underline*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_underline) shr
-      bp_TGtkTextAppearance_underline
-
-proc set_underline*(a: PTextAppearance, `underline`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`underline` shl bp_TGtkTextAppearance_underline) and
-      bm_TGtkTextAppearance_underline)
-
-proc strikethrough*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_strikethrough) shr
-      bp_TGtkTextAppearance_strikethrough
-
-proc set_strikethrough*(a: PTextAppearance, `strikethrough`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`strikethrough` shl bp_TGtkTextAppearance_strikethrough) and
-      bm_TGtkTextAppearance_strikethrough)
-
-proc draw_bg*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_draw_bg) shr
-      bp_TGtkTextAppearance_draw_bg
-
-proc set_draw_bg*(a: PTextAppearance, `draw_bg`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`draw_bg` shl bp_TGtkTextAppearance_draw_bg) and
-      bm_TGtkTextAppearance_draw_bg)
-
-proc inside_selection*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_inside_selection) shr
-      bp_TGtkTextAppearance_inside_selection
-
-proc set_inside_selection*(a: PTextAppearance, `inside_selection`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`inside_selection` shl bp_TGtkTextAppearance_inside_selection) and
-      bm_TGtkTextAppearance_inside_selection)
-
-proc is_text*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_is_text) shr
-      bp_TGtkTextAppearance_is_text
-
-proc set_is_text*(a: PTextAppearance, `is_text`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_text` shl bp_TGtkTextAppearance_is_text) and
-      bm_TGtkTextAppearance_is_text)
-
-proc pad1*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_pad1) shr
-      bp_TGtkTextAppearance_pad1
-
-proc set_pad1*(a: PTextAppearance, `pad1`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad1` shl bp_TGtkTextAppearance_pad1) and
-      bm_TGtkTextAppearance_pad1)
-
-proc pad2*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_pad2) shr
-      bp_TGtkTextAppearance_pad2
-
-proc set_pad2*(a: PTextAppearance, `pad2`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad2` shl bp_TGtkTextAppearance_pad2) and
-      bm_TGtkTextAppearance_pad2)
-
-proc pad3*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_pad3) shr
-      bp_TGtkTextAppearance_pad3
-
-proc set_pad3*(a: PTextAppearance, `pad3`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad3` shl bp_TGtkTextAppearance_pad3) and
-      bm_TGtkTextAppearance_pad3)
-
-proc pad4*(a: PTextAppearance): guint = 
-  result = (a.flag0 and bm_TGtkTextAppearance_pad4) shr
-      bp_TGtkTextAppearance_pad4
-
-proc set_pad4*(a: PTextAppearance, `pad4`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad4` shl bp_TGtkTextAppearance_pad4) and
-      bm_TGtkTextAppearance_pad4)
-
-proc invisible*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_invisible) shr
-      bp_TGtkTextAttributes_invisible
-
-proc set_invisible*(a: PTextAttributes, `invisible`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`invisible` shl bp_TGtkTextAttributes_invisible) and
-      bm_TGtkTextAttributes_invisible)
-
-proc bg_full_height*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_bg_full_height) shr
-      bp_TGtkTextAttributes_bg_full_height
-
-proc set_bg_full_height*(a: PTextAttributes, `bg_full_height`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`bg_full_height` shl bp_TGtkTextAttributes_bg_full_height) and
-      bm_TGtkTextAttributes_bg_full_height)
-
-proc editable*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_editable) shr
-      bp_TGtkTextAttributes_editable
-
-proc set_editable*(a: PTextAttributes, `editable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`editable` shl bp_TGtkTextAttributes_editable) and
-      bm_TGtkTextAttributes_editable)
-
-proc realized*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_realized) shr
-      bp_TGtkTextAttributes_realized
-
-proc set_realized*(a: PTextAttributes, `realized`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`realized` shl bp_TGtkTextAttributes_realized) and
-      bm_TGtkTextAttributes_realized)
-
-proc pad1*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_pad1) shr
-      bp_TGtkTextAttributes_pad1
-
-proc set_pad1*(a: PTextAttributes, `pad1`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad1` shl bp_TGtkTextAttributes_pad1) and
-      bm_TGtkTextAttributes_pad1)
-
-proc pad2*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_pad2) shr
-      bp_TGtkTextAttributes_pad2
-
-proc set_pad2*(a: PTextAttributes, `pad2`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad2` shl bp_TGtkTextAttributes_pad2) and
-      bm_TGtkTextAttributes_pad2)
-
-proc pad3*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_pad3) shr
-      bp_TGtkTextAttributes_pad3
-
-proc set_pad3*(a: PTextAttributes, `pad3`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad3` shl bp_TGtkTextAttributes_pad3) and
-      bm_TGtkTextAttributes_pad3)
-
-proc pad4*(a: PTextAttributes): guint = 
-  result = (a.flag0 and bm_TGtkTextAttributes_pad4) shr
-      bp_TGtkTextAttributes_pad4
-
-proc set_pad4*(a: PTextAttributes, `pad4`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`pad4` shl bp_TGtkTextAttributes_pad4) and
-      bm_TGtkTextAttributes_pad4)
-
-proc TYPE_TEXT_TAG_TABLE*(): GType = 
-  result = text_tag_table_get_type()
-
-proc TEXT_TAG_TABLE*(obj: pointer): PTextTagTable = 
-  result = cast[PTextTagTable](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_TEXT_TAG_TABLE()))
-
-proc TEXT_TAG_TABLE_CLASS*(klass: pointer): PTextTagTableClass = 
-  result = cast[PTextTagTableClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_TEXT_TAG_TABLE()))
-
-proc IS_TEXT_TAG_TABLE*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TEXT_TAG_TABLE())
-
-proc IS_TEXT_TAG_TABLE_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_TAG_TABLE())
-
-proc TEXT_TAG_TABLE_GET_CLASS*(obj: pointer): PTextTagTableClass = 
-  result = cast[PTextTagTableClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_TEXT_TAG_TABLE()))
-
-proc TYPE_TEXT_MARK*(): GType = 
-  result = text_mark_get_type()
-
-proc TEXT_MARK*(anObject: pointer): PTextMark = 
-  result = cast[PTextMark](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_TEXT_MARK()))
-
-proc TEXT_MARK_CLASS*(klass: pointer): PTextMarkClass = 
-  result = cast[PTextMarkClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_TEXT_MARK()))
-
-proc IS_TEXT_MARK*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_TEXT_MARK())
-
-proc IS_TEXT_MARK_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_MARK())
-
-proc TEXT_MARK_GET_CLASS*(obj: pointer): PTextMarkClass = 
-  result = cast[PTextMarkClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_TEXT_MARK()))
-
-proc visible*(a: PTextMarkBody): guint = 
-  result = (a.flag0 and bm_TGtkTextMarkBody_visible) shr
-      bp_TGtkTextMarkBody_visible
-
-proc set_visible*(a: PTextMarkBody, `visible`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`visible` shl bp_TGtkTextMarkBody_visible) and
-      bm_TGtkTextMarkBody_visible)
-
-proc not_deleteable*(a: PTextMarkBody): guint = 
-  result = (a.flag0 and bm_TGtkTextMarkBody_not_deleteable) shr
-      bp_TGtkTextMarkBody_not_deleteable
-
-proc set_not_deleteable*(a: PTextMarkBody, `not_deleteable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`not_deleteable` shl bp_TGtkTextMarkBody_not_deleteable) and
-      bm_TGtkTextMarkBody_not_deleteable)
-
-proc TYPE_TEXT_CHILD_ANCHOR*(): GType = 
-  result = text_child_anchor_get_type()
-
-proc TEXT_CHILD_ANCHOR*(anObject: pointer): PTextChildAnchor = 
-  result = cast[PTextChildAnchor](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_TEXT_CHILD_ANCHOR()))
-
-proc TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): PTextChildAnchorClass = 
-  result = cast[PTextChildAnchorClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_TEXT_CHILD_ANCHOR()))
-
-proc IS_TEXT_CHILD_ANCHOR*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_TEXT_CHILD_ANCHOR())
-
-proc IS_TEXT_CHILD_ANCHOR_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_CHILD_ANCHOR())
-
-proc TEXT_CHILD_ANCHOR_GET_CLASS*(obj: pointer): PTextChildAnchorClass = 
-  result = cast[PTextChildAnchorClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_TEXT_CHILD_ANCHOR()))
-
-proc width*(a: PTextLineData): gint = 
-  result = a.flag0 and bm_TGtkTextLineData_width
-
-proc set_width*(a: PTextLineData, NewWidth: gint) = 
-  a.flag0 = (bm_TGtkTextLineData_width and NewWidth) or a.flag0
-
-proc valid*(a: PTextLineData): gint = 
-  result = (a.flag0 and bm_TGtkTextLineData_valid) shr
-      bp_TGtkTextLineData_valid
-
-proc set_valid*(a: PTextLineData, `valid`: gint) = 
-  a.flag0 = a.flag0 or
-      ((`valid` shl bp_TGtkTextLineData_valid) and bm_TGtkTextLineData_valid)
-
-proc TYPE_TEXT_BUFFER*(): GType = 
-  result = text_buffer_get_type()
-
-proc TEXT_BUFFER*(obj: pointer): PTextBuffer = 
-  result = cast[PTextBuffer](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_TEXT_BUFFER()))
-
-proc TEXT_BUFFER_CLASS*(klass: pointer): PTextBufferClass = 
-  result = cast[PTextBufferClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_TEXT_BUFFER()))
-
-proc IS_TEXT_BUFFER*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TEXT_BUFFER())
-
-proc IS_TEXT_BUFFER_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_BUFFER())
-
-proc TEXT_BUFFER_GET_CLASS*(obj: pointer): PTextBufferClass = 
-  result = cast[PTextBufferClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_TEXT_BUFFER()))
-
-proc modified*(a: PTextBuffer): guint = 
-  result = (a.TextBufferflag0 and bm_TGtkTextBuffer_modified) shr
-      bp_TGtkTextBuffer_modified
-
-proc set_modified*(a: PTextBuffer, `modified`: guint) = 
-  a.TextBufferflag0 = a.TextBufferflag0 or
-      (int16(`modified` shl bp_TGtkTextBuffer_modified) and
-      bm_TGtkTextBuffer_modified)
-
-proc TYPE_TEXT_LAYOUT*(): GType = 
-  result = text_layout_get_type()
-
-proc TEXT_LAYOUT*(obj: pointer): PTextLayout = 
-  result = cast[PTextLayout](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_TEXT_LAYOUT()))
-
-proc TEXT_LAYOUT_CLASS*(klass: pointer): PTextLayoutClass = 
-  result = cast[PTextLayoutClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_TEXT_LAYOUT()))
-
-proc IS_TEXT_LAYOUT*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TEXT_LAYOUT())
-
-proc IS_TEXT_LAYOUT_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_TEXT_LAYOUT())
-
-proc TEXT_LAYOUT_GET_CLASS*(obj: pointer): PTextLayoutClass = 
-  result = cast[PTextLayoutClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_TEXT_LAYOUT()))
-
-proc cursor_visible*(a: PTextLayout): guint = 
-  result = (a.TextLayoutflag0 and bm_TGtkTextLayout_cursor_visible) shr
-      bp_TGtkTextLayout_cursor_visible
-
-proc set_cursor_visible*(a: PTextLayout, `cursor_visible`: guint) = 
-  a.TextLayoutflag0 = a.TextLayoutflag0 or
-      (int16(`cursor_visible` shl bp_TGtkTextLayout_cursor_visible) and
-      bm_TGtkTextLayout_cursor_visible)
-
-proc cursor_direction*(a: PTextLayout): gint = 
-  result = (a.TextLayoutflag0 and bm_TGtkTextLayout_cursor_direction) shr
-      bp_TGtkTextLayout_cursor_direction
-
-proc set_cursor_direction*(a: PTextLayout, `cursor_direction`: gint) = 
-  a.TextLayoutflag0 = a.TextLayoutflag0 or
-      (int16(`cursor_direction` shl bp_TGtkTextLayout_cursor_direction) and
-      bm_TGtkTextLayout_cursor_direction)
-
-proc is_strong*(a: PTextCursorDisplay): guint = 
-  result = (a.flag0 and bm_TGtkTextCursorDisplay_is_strong) shr
-      bp_TGtkTextCursorDisplay_is_strong
-
-proc set_is_strong*(a: PTextCursorDisplay, `is_strong`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_strong` shl bp_TGtkTextCursorDisplay_is_strong) and
-      bm_TGtkTextCursorDisplay_is_strong)
-
-proc is_weak*(a: PTextCursorDisplay): guint = 
-  result = (a.flag0 and bm_TGtkTextCursorDisplay_is_weak) shr
-      bp_TGtkTextCursorDisplay_is_weak
-
-proc set_is_weak*(a: PTextCursorDisplay, `is_weak`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_weak` shl bp_TGtkTextCursorDisplay_is_weak) and
-      bm_TGtkTextCursorDisplay_is_weak)
-
-proc TYPE_TEXT_VIEW*(): GType = 
-  result = text_view_get_type()
-
-proc TEXT_VIEW*(obj: pointer): PTextView = 
-  result = cast[PTextView](CHECK_CAST(obj, TYPE_TEXT_VIEW()))
-
-proc TEXT_VIEW_CLASS*(klass: pointer): PTextViewClass = 
-  result = cast[PTextViewClass](CHECK_CLASS_CAST(klass, TYPE_TEXT_VIEW()))
-
-proc IS_TEXT_VIEW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TEXT_VIEW())
-
-proc IS_TEXT_VIEW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TEXT_VIEW())
-
-proc TEXT_VIEW_GET_CLASS*(obj: pointer): PTextViewClass = 
-  result = cast[PTextViewClass](CHECK_GET_CLASS(obj, TYPE_TEXT_VIEW()))
-
-proc editable*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_editable) shr
-      bp_TGtkTextView_editable
-
-proc set_editable*(a: PTextView, `editable`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`editable` shl bp_TGtkTextView_editable) and
-      bm_TGtkTextView_editable)
-
-proc overwrite_mode*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_overwrite_mode) shr
-      bp_TGtkTextView_overwrite_mode
-
-proc set_overwrite_mode*(a: PTextView, `overwrite_mode`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`overwrite_mode` shl bp_TGtkTextView_overwrite_mode) and
-      bm_TGtkTextView_overwrite_mode)
-
-proc cursor_visible*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_cursor_visible) shr
-      bp_TGtkTextView_cursor_visible
-
-proc set_cursor_visible*(a: PTextView, `cursor_visible`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`cursor_visible` shl bp_TGtkTextView_cursor_visible) and
-      bm_TGtkTextView_cursor_visible)
-
-proc need_im_reset*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_need_im_reset) shr
-      bp_TGtkTextView_need_im_reset
-
-proc set_need_im_reset*(a: PTextView, `need_im_reset`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`need_im_reset` shl bp_TGtkTextView_need_im_reset) and
-      bm_TGtkTextView_need_im_reset)
-
-proc just_selected_element*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_just_selected_element) shr
-      bp_TGtkTextView_just_selected_element
-
-proc set_just_selected_element*(a: PTextView, `just_selected_element`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`just_selected_element` shl
-      bp_TGtkTextView_just_selected_element) and
-      bm_TGtkTextView_just_selected_element)
-
-proc disable_scroll_on_focus*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_disable_scroll_on_focus) shr
-      bp_TGtkTextView_disable_scroll_on_focus
-
-proc set_disable_scroll_on_focus*(a: PTextView, 
-                                  `disable_scroll_on_focus`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`disable_scroll_on_focus` shl
-      bp_TGtkTextView_disable_scroll_on_focus) and
-      bm_TGtkTextView_disable_scroll_on_focus)
-
-proc onscreen_validated*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_onscreen_validated) shr
-      bp_TGtkTextView_onscreen_validated
-
-proc set_onscreen_validated*(a: PTextView, `onscreen_validated`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`onscreen_validated` shl bp_TGtkTextView_onscreen_validated) and
-      bm_TGtkTextView_onscreen_validated)
-
-proc mouse_cursor_obscured*(a: PTextView): guint = 
-  result = (a.TextViewflag0 and bm_TGtkTextView_mouse_cursor_obscured) shr
-      bp_TGtkTextView_mouse_cursor_obscured
-
-proc set_mouse_cursor_obscured*(a: PTextView, `mouse_cursor_obscured`: guint) = 
-  a.TextViewflag0 = a.TextViewflag0 or
-      (int16(`mouse_cursor_obscured` shl
-      bp_TGtkTextView_mouse_cursor_obscured) and
-      bm_TGtkTextView_mouse_cursor_obscured)
-
-proc TYPE_TIPS_QUERY*(): GType = 
-  result = tips_query_get_type()
-
-proc TIPS_QUERY*(obj: pointer): PTipsQuery = 
-  result = cast[PTipsQuery](CHECK_CAST(obj, TYPE_TIPS_QUERY()))
-
-proc TIPS_QUERY_CLASS*(klass: pointer): PTipsQueryClass = 
-  result = cast[PTipsQueryClass](CHECK_CLASS_CAST(klass, TYPE_TIPS_QUERY()))
-
-proc IS_TIPS_QUERY*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TIPS_QUERY())
-
-proc IS_TIPS_QUERY_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TIPS_QUERY())
-
-proc TIPS_QUERY_GET_CLASS*(obj: pointer): PTipsQueryClass = 
-  result = cast[PTipsQueryClass](CHECK_GET_CLASS(obj, TYPE_TIPS_QUERY()))
-
-proc emit_always*(a: PTipsQuery): guint = 
-  result = (a.TipsQueryflag0 and bm_TGtkTipsQuery_emit_always) shr
-      bp_TGtkTipsQuery_emit_always
-
-proc set_emit_always*(a: PTipsQuery, `emit_always`: guint) = 
-  a.TipsQueryflag0 = a.TipsQueryflag0 or
-      (int16(`emit_always` shl bp_TGtkTipsQuery_emit_always) and
-      bm_TGtkTipsQuery_emit_always)
-
-proc in_query*(a: PTipsQuery): guint = 
-  result = (a.TipsQueryflag0 and bm_TGtkTipsQuery_in_query) shr
-      bp_TGtkTipsQuery_in_query
-
-proc set_in_query*(a: PTipsQuery, `in_query`: guint) = 
-  a.TipsQueryflag0 = a.TipsQueryflag0 or
-      (int16(`in_query` shl bp_TGtkTipsQuery_in_query) and
-      bm_TGtkTipsQuery_in_query)
-
-proc TYPE_TOOLTIPS*(): GType = 
-  result = tooltips_get_type()
-
-proc TOOLTIPS*(obj: pointer): PTooltips = 
-  result = cast[PTooltips](CHECK_CAST(obj, TYPE_TOOLTIPS()))
-
-proc TOOLTIPS_CLASS*(klass: pointer): PTooltipsClass = 
-  result = cast[PTooltipsClass](CHECK_CLASS_CAST(klass, TYPE_TOOLTIPS()))
-
-proc IS_TOOLTIPS*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TOOLTIPS())
-
-proc IS_TOOLTIPS_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TOOLTIPS())
-
-proc TOOLTIPS_GET_CLASS*(obj: pointer): PTooltipsClass = 
-  result = cast[PTooltipsClass](CHECK_GET_CLASS(obj, TYPE_TOOLTIPS()))
-
-proc delay*(a: PTooltips): guint = 
-  result = (a.Tooltipsflag0 and bm_TGtkTooltips_delay) shr
-      bp_TGtkTooltips_delay
-
-proc set_delay*(a: PTooltips, `delay`: guint) = 
-  a.Tooltipsflag0 = a.Tooltipsflag0 or
-      ((`delay` shl bp_TGtkTooltips_delay) and bm_TGtkTooltips_delay)
-
-proc enabled*(a: PTooltips): guint = 
-  result = (a.Tooltipsflag0 and bm_TGtkTooltips_enabled) shr
-      bp_TGtkTooltips_enabled
-
-proc set_enabled*(a: PTooltips, `enabled`: guint) = 
-  a.Tooltipsflag0 = a.Tooltipsflag0 or
-      ((`enabled` shl bp_TGtkTooltips_enabled) and bm_TGtkTooltips_enabled)
-
-proc have_grab*(a: PTooltips): guint = 
-  result = (a.Tooltipsflag0 and bm_TGtkTooltips_have_grab) shr
-      bp_TGtkTooltips_have_grab
-
-proc set_have_grab*(a: PTooltips, `have_grab`: guint) = 
-  a.Tooltipsflag0 = a.Tooltipsflag0 or
-      ((`have_grab` shl bp_TGtkTooltips_have_grab) and
-      bm_TGtkTooltips_have_grab)
-
-proc use_sticky_delay*(a: PTooltips): guint = 
-  result = (a.Tooltipsflag0 and bm_TGtkTooltips_use_sticky_delay) shr
-      bp_TGtkTooltips_use_sticky_delay
-
-proc set_use_sticky_delay*(a: PTooltips, `use_sticky_delay`: guint) = 
-  a.Tooltipsflag0 = a.Tooltipsflag0 or
-      ((`use_sticky_delay` shl bp_TGtkTooltips_use_sticky_delay) and
-      bm_TGtkTooltips_use_sticky_delay)
-
-proc TYPE_TOOLBAR*(): GType = 
-  result = toolbar_get_type()
-
-proc TOOLBAR*(obj: pointer): PToolbar = 
-  result = cast[PToolbar](CHECK_CAST(obj, TYPE_TOOLBAR()))
-
-proc TOOLBAR_CLASS*(klass: pointer): PToolbarClass = 
-  result = cast[PToolbarClass](CHECK_CLASS_CAST(klass, TYPE_TOOLBAR()))
-
-proc IS_TOOLBAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TOOLBAR())
-
-proc IS_TOOLBAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TOOLBAR())
-
-proc TOOLBAR_GET_CLASS*(obj: pointer): PToolbarClass = 
-  result = cast[PToolbarClass](CHECK_GET_CLASS(obj, TYPE_TOOLBAR()))
-
-proc style_set*(a: PToolbar): guint = 
-  result = (a.Toolbarflag0 and bm_TGtkToolbar_style_set) shr
-      bp_TGtkToolbar_style_set
-
-proc set_style_set*(a: PToolbar, `style_set`: guint) = 
-  a.Toolbarflag0 = a.Toolbarflag0 or
-      (int16(`style_set` shl bp_TGtkToolbar_style_set) and
-      bm_TGtkToolbar_style_set)
-
-proc icon_size_set*(a: PToolbar): guint = 
-  result = (a.Toolbarflag0 and bm_TGtkToolbar_icon_size_set) shr
-      bp_TGtkToolbar_icon_size_set
-
-proc set_icon_size_set*(a: PToolbar, `icon_size_set`: guint) = 
-  a.Toolbarflag0 = a.Toolbarflag0 or
-      (int16(`icon_size_set` shl bp_TGtkToolbar_icon_size_set) and
-      bm_TGtkToolbar_icon_size_set)
-
-proc TYPE_TREE*(): GType = 
-  result = tree_get_type()
-
-proc TREE*(obj: pointer): PTree = 
-  result = cast[PTree](CHECK_CAST(obj, TYPE_TREE()))
-
-proc TREE_CLASS*(klass: pointer): PTreeClass = 
-  result = cast[PTreeClass](CHECK_CLASS_CAST(klass, TYPE_TREE()))
-
-proc IS_TREE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE())
-
-proc IS_TREE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE())
-
-proc TREE_GET_CLASS*(obj: pointer): PTreeClass = 
-  result = cast[PTreeClass](CHECK_GET_CLASS(obj, TYPE_TREE()))
-
-proc IS_ROOT_TREE*(obj: pointer): bool = 
-  result = (cast[PObject]((TREE(obj)).root_tree)) == (cast[PObject](obj))
-
-proc TREE_ROOT_TREE*(obj: pointer): PTree = 
-  result = TREE(obj).root_tree
-
-proc TREE_SELECTION_OLD*(obj: pointer): PGList = 
-  result = (TREE_ROOT_TREE(obj)).selection
-
-proc selection_mode*(a: PTree): guint = 
-  result = (a.Treeflag0 and bm_TGtkTree_selection_mode) shr
-      bp_TGtkTree_selection_mode
-
-proc set_selection_mode*(a: PTree, `selection_mode`: guint) = 
-  a.Treeflag0 = a.Treeflag0 or
-      (int16(`selection_mode` shl bp_TGtkTree_selection_mode) and
-      bm_TGtkTree_selection_mode)
-
-proc view_mode*(a: PTree): guint = 
-  result = (a.Treeflag0 and bm_TGtkTree_view_mode) shr bp_TGtkTree_view_mode
-
-proc set_view_mode*(a: PTree, `view_mode`: guint) = 
-  a.Treeflag0 = a.Treeflag0 or
-      (int16(`view_mode` shl bp_TGtkTree_view_mode) and bm_TGtkTree_view_mode)
-
-proc view_line*(a: PTree): guint = 
-  result = (a.Treeflag0 and bm_TGtkTree_view_line) shr bp_TGtkTree_view_line
-
-proc set_view_line*(a: PTree, `view_line`: guint) = 
-  a.Treeflag0 = a.Treeflag0 or
-      (int16(`view_line` shl bp_TGtkTree_view_line) and bm_TGtkTree_view_line)
-
-proc TYPE_TREE_DRAG_SOURCE*(): GType = 
-  result = tree_drag_source_get_type()
-
-proc TREE_DRAG_SOURCE*(obj: pointer): PTreeDragSource = 
-  result = cast[PTreeDragSource](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_TREE_DRAG_SOURCE()))
-
-proc IS_TREE_DRAG_SOURCE*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TREE_DRAG_SOURCE())
-
-proc TREE_DRAG_SOURCE_GET_IFACE*(obj: pointer): PTreeDragSourceIface = 
-  result = cast[PTreeDragSourceIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, 
-      TYPE_TREE_DRAG_SOURCE()))
-
-proc TYPE_TREE_DRAG_DEST*(): GType = 
-  result = tree_drag_dest_get_type()
-
-proc TREE_DRAG_DEST*(obj: pointer): PTreeDragDest = 
-  result = cast[PTreeDragDest](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_TREE_DRAG_DEST()))
-
-proc IS_TREE_DRAG_DEST*(obj: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_TREE_DRAG_DEST())
-
-proc TREE_DRAG_DEST_GET_IFACE*(obj: pointer): PTreeDragDestIface = 
-  result = cast[PTreeDragDestIface](G_TYPE_INSTANCE_GET_INTERFACE(obj, 
-      TYPE_TREE_DRAG_DEST()))
-
-proc TYPE_TREE_ITEM*(): GType = 
-  result = tree_item_get_type()
-
-proc TREE_ITEM*(obj: pointer): PTreeItem = 
-  result = cast[PTreeItem](CHECK_CAST(obj, TYPE_TREE_ITEM()))
-
-proc TREE_ITEM_CLASS*(klass: pointer): PTreeItemClass = 
-  result = cast[PTreeItemClass](CHECK_CLASS_CAST(klass, TYPE_TREE_ITEM()))
-
-proc IS_TREE_ITEM*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_ITEM())
-
-proc IS_TREE_ITEM_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_ITEM())
-
-proc TREE_ITEM_GET_CLASS*(obj: pointer): PTreeItemClass = 
-  result = cast[PTreeItemClass](CHECK_GET_CLASS(obj, TYPE_TREE_ITEM()))
-
-proc TREE_ITEM_SUBTREE*(obj: pointer): PWidget = 
-  result = (TREE_ITEM(obj)).subtree
-
-proc expanded*(a: PTreeItem): guint = 
-  result = (a.TreeItemflag0 and bm_TGtkTreeItem_expanded) shr
-      bp_TGtkTreeItem_expanded
-
-proc set_expanded*(a: PTreeItem, `expanded`: guint) = 
-  a.TreeItemflag0 = a.TreeItemflag0 or
-      (int16(`expanded` shl bp_TGtkTreeItem_expanded) and
-      bm_TGtkTreeItem_expanded)
-
-proc TYPE_TREE_SELECTION*(): GType = 
-  result = tree_selection_get_type()
-
-proc TREE_SELECTION*(obj: pointer): PTreeSelection = 
-  result = cast[PTreeSelection](CHECK_CAST(obj, TYPE_TREE_SELECTION()))
-
-proc TREE_SELECTION_CLASS*(klass: pointer): PTreeSelectionClass = 
-  result = cast[PTreeSelectionClass](CHECK_CLASS_CAST(klass, 
-      TYPE_TREE_SELECTION()))
-
-proc IS_TREE_SELECTION*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_SELECTION())
-
-proc IS_TREE_SELECTION_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_SELECTION())
-
-proc TREE_SELECTION_GET_CLASS*(obj: pointer): PTreeSelectionClass = 
-  result = cast[PTreeSelectionClass](CHECK_GET_CLASS(obj, TYPE_TREE_SELECTION()))
-
-proc TYPE_TREE_STORE*(): GType = 
-  result = tree_store_get_type()
-
-proc TREE_STORE*(obj: pointer): PTreeStore = 
-  result = cast[PTreeStore](CHECK_CAST(obj, TYPE_TREE_STORE()))
-
-proc TREE_STORE_CLASS*(klass: pointer): PTreeStoreClass = 
-  result = cast[PTreeStoreClass](CHECK_CLASS_CAST(klass, TYPE_TREE_STORE()))
-
-proc IS_TREE_STORE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_STORE())
-
-proc IS_TREE_STORE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_STORE())
-
-proc TREE_STORE_GET_CLASS*(obj: pointer): PTreeStoreClass = 
-  result = cast[PTreeStoreClass](CHECK_GET_CLASS(obj, TYPE_TREE_STORE()))
-
-proc columns_dirty*(a: PTreeStore): guint = 
-  result = (a.TreeStoreflag0 and bm_TGtkTreeStore_columns_dirty) shr
-      bp_TGtkTreeStore_columns_dirty
-
-proc set_columns_dirty*(a: PTreeStore, `columns_dirty`: guint) = 
-  a.TreeStoreflag0 = a.TreeStoreflag0 or
-      (int16(`columns_dirty` shl bp_TGtkTreeStore_columns_dirty) and
-      bm_TGtkTreeStore_columns_dirty)
-
-proc TYPE_TREE_VIEW_COLUMN*(): GType = 
-  result = tree_view_column_get_type()
-
-proc TREE_VIEW_COLUMN*(obj: pointer): PTreeViewColumn = 
-  result = cast[PTreeViewColumn](CHECK_CAST(obj, TYPE_TREE_VIEW_COLUMN()))
-
-proc TREE_VIEW_COLUMN_CLASS*(klass: pointer): PTreeViewColumnClass = 
-  result = cast[PTreeViewColumnClass](CHECK_CLASS_CAST(klass, 
-      TYPE_TREE_VIEW_COLUMN()))
-
-proc IS_TREE_VIEW_COLUMN*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_VIEW_COLUMN())
-
-proc IS_TREE_VIEW_COLUMN_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_VIEW_COLUMN())
-
-proc TREE_VIEW_COLUMN_GET_CLASS*(obj: pointer): PTreeViewColumnClass = 
-  result = cast[PTreeViewColumnClass](CHECK_GET_CLASS(obj, 
-      TYPE_TREE_VIEW_COLUMN()))
-
-proc visible*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_visible) shr
-      bp_TGtkTreeViewColumn_visible
-
-proc set_visible*(a: PTreeViewColumn, `visible`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`visible` shl bp_TGtkTreeViewColumn_visible) and
-      bm_TGtkTreeViewColumn_visible)
-
-proc resizable*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_resizable) shr
-      bp_TGtkTreeViewColumn_resizable
-
-proc set_resizable*(a: PTreeViewColumn, `resizable`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`resizable` shl bp_TGtkTreeViewColumn_resizable) and
-      bm_TGtkTreeViewColumn_resizable)
-
-proc clickable*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_clickable) shr
-      bp_TGtkTreeViewColumn_clickable
-
-proc set_clickable*(a: PTreeViewColumn, `clickable`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`clickable` shl bp_TGtkTreeViewColumn_clickable) and
-      bm_TGtkTreeViewColumn_clickable)
-
-proc dirty*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_dirty) shr
-      bp_TGtkTreeViewColumn_dirty
-
-proc set_dirty*(a: PTreeViewColumn, `dirty`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`dirty` shl bp_TGtkTreeViewColumn_dirty) and
-      bm_TGtkTreeViewColumn_dirty)
-
-proc show_sort_indicator*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and
-      bm_TGtkTreeViewColumn_show_sort_indicator) shr
-      bp_TGtkTreeViewColumn_show_sort_indicator
-
-proc set_show_sort_indicator*(a: PTreeViewColumn, 
-                              `show_sort_indicator`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`show_sort_indicator` shl
-      bp_TGtkTreeViewColumn_show_sort_indicator) and
-      bm_TGtkTreeViewColumn_show_sort_indicator)
-
-proc maybe_reordered*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_maybe_reordered) shr
-      bp_TGtkTreeViewColumn_maybe_reordered
-
-proc set_maybe_reordered*(a: PTreeViewColumn, `maybe_reordered`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`maybe_reordered` shl bp_TGtkTreeViewColumn_maybe_reordered) and
-      bm_TGtkTreeViewColumn_maybe_reordered)
-
-proc reorderable*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_reorderable) shr
-      bp_TGtkTreeViewColumn_reorderable
-
-proc set_reorderable*(a: PTreeViewColumn, `reorderable`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`reorderable` shl bp_TGtkTreeViewColumn_reorderable) and
-      bm_TGtkTreeViewColumn_reorderable)
-
-proc use_resized_width*(a: PTreeViewColumn): guint = 
-  result = (a.TreeViewColumnflag0 and bm_TGtkTreeViewColumn_use_resized_width) shr
-      bp_TGtkTreeViewColumn_use_resized_width
-
-proc set_use_resized_width*(a: PTreeViewColumn, `use_resized_width`: guint) = 
-  a.TreeViewColumnflag0 = a.TreeViewColumnflag0 or
-      (int16(`use_resized_width` shl bp_TGtkTreeViewColumn_use_resized_width) and
-      bm_TGtkTreeViewColumn_use_resized_width)
-
-proc flags*(a: PRBNode): guint = 
-  result = (a.flag0 and bm_TGtkRBNode_flags) shr bp_TGtkRBNode_flags
-
-proc set_flags*(a: PRBNode, `flags`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`flags` shl bp_TGtkRBNode_flags) and bm_TGtkRBNode_flags)
-
-proc parity*(a: PRBNode): guint = 
-  result = (a.flag0 and bm_TGtkRBNode_parity) shr bp_TGtkRBNode_parity
-
-proc set_parity*(a: PRBNode, `parity`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`parity` shl bp_TGtkRBNode_parity) and bm_TGtkRBNode_parity)
-
-proc GET_COLOR*(node: PRBNode): guint = 
-  if node == nil: 
-    Result = RBNODE_BLACK
-  elif (int(flags(node)) and RBNODE_RED) == RBNODE_RED: 
-    Result = RBNODE_RED
-  else: 
-    Result = RBNODE_BLACK
-
-proc SET_COLOR*(node: PRBNode, color: guint) = 
-  if node == nil: 
-    return 
-  if ((flags(node) and (color)) != color): 
-    set_flags(node, flags(node) xor cint(RBNODE_RED or RBNODE_BLACK))
-
-proc GET_HEIGHT*(node: PRBNode): gint = 
-  var if_local1: gint
-  if node.children != nil: 
-    if_local1 = node.children.root.offset
-  else: 
-    if_local1 = 0
-  result = node.offset -
-      ((node.left.offset) + node.right.offset + if_local1)
-
-proc FLAG_SET*(node: PRBNode, flag: guint): bool = 
-  result = (node != nil) and ((flags(node) and (flag)) == flag)
-
-proc SET_FLAG*(node: PRBNode, flag: guint16) = 
-  set_flags(node, (flag) or flags(node))
-
-proc UNSET_FLAG*(node: PRBNode, flag: guint16) = 
-  set_flags(node, (not (flag)) and flags(node))
-
-proc FLAG_SET*(tree_view: PTreeView, flag: guint): bool = 
-  result = ((tree_view.priv.flags) and (flag)) == flag
-
-proc HEADER_HEIGHT*(tree_view: PTreeView): int32 = 
-  var if_local1: int32
-  if FLAG_SET(tree_view, TREE_VIEW_HEADERS_VISIBLE): 
-    if_local1 = tree_view.priv.header_height
-  else: 
-    if_local1 = 0
-  result = if_local1
-
-proc COLUMN_REQUESTED_WIDTH*(column: PTreeViewColumn): int32 = 
-  var MinWidth, MaxWidth: int
-  if column.min_width != - 1'i32: 
-    MinWidth = column.min_width
-  else: 
-    MinWidth = column.requested_width
-  if column.max_width != - 1'i32: 
-    MaxWidth = column.max_width
-  else: 
-    MaxWidth = column.requested_width
-  result = CLAMP(column.requested_width, MinWidth, MaxWidth)
-
-proc DRAW_EXPANDERS*(tree_view: PTreeView): bool = 
-  result = (not (FLAG_SET(tree_view, TREE_VIEW_IS_LIST))) and
-      (FLAG_SET(tree_view, TREE_VIEW_SHOW_EXPANDERS))
-
-proc COLUMN_DRAG_DEAD_MULTIPLIER*(tree_view: PTreeView): int32 = 
-  result = 10'i32 * (HEADER_HEIGHT(tree_view))
-
-proc scroll_to_use_align*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_scroll_to_use_align) shr
-      bp_TGtkTreeViewPrivate_scroll_to_use_align
-
-proc set_scroll_to_use_align*(a: PTreeViewPrivate, 
-                              `scroll_to_use_align`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`scroll_to_use_align` shl
-      bp_TGtkTreeViewPrivate_scroll_to_use_align) and
-      bm_TGtkTreeViewPrivate_scroll_to_use_align)
-
-proc fixed_height_check*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_fixed_height_check) shr
-      bp_TGtkTreeViewPrivate_fixed_height_check
-
-proc set_fixed_height_check*(a: PTreeViewPrivate, 
-                             `fixed_height_check`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`fixed_height_check` shl
-      bp_TGtkTreeViewPrivate_fixed_height_check) and
-      bm_TGtkTreeViewPrivate_fixed_height_check)
-
-proc reorderable*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_reorderable) shr
-      bp_TGtkTreeViewPrivate_reorderable
-
-proc set_reorderable*(a: PTreeViewPrivate, `reorderable`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`reorderable` shl bp_TGtkTreeViewPrivate_reorderable) and
-      bm_TGtkTreeViewPrivate_reorderable)
-
-proc header_has_focus*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_header_has_focus) shr
-      bp_TGtkTreeViewPrivate_header_has_focus
-
-proc set_header_has_focus*(a: PTreeViewPrivate, `header_has_focus`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`header_has_focus` shl bp_TGtkTreeViewPrivate_header_has_focus) and
-      bm_TGtkTreeViewPrivate_header_has_focus)
-
-proc drag_column_window_state*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_drag_column_window_state) shr
-      bp_TGtkTreeViewPrivate_drag_column_window_state
-
-proc set_drag_column_window_state*(a: PTreeViewPrivate, 
-                                   `drag_column_window_state`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`drag_column_window_state` shl
-      bp_TGtkTreeViewPrivate_drag_column_window_state) and
-      bm_TGtkTreeViewPrivate_drag_column_window_state)
-
-proc has_rules*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_has_rules) shr
-      bp_TGtkTreeViewPrivate_has_rules
-
-proc set_has_rules*(a: PTreeViewPrivate, `has_rules`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`has_rules` shl bp_TGtkTreeViewPrivate_has_rules) and
-      bm_TGtkTreeViewPrivate_has_rules)
-
-proc mark_rows_col_dirty*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_mark_rows_col_dirty) shr
-      bp_TGtkTreeViewPrivate_mark_rows_col_dirty
-
-proc set_mark_rows_col_dirty*(a: PTreeViewPrivate, 
-                              `mark_rows_col_dirty`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`mark_rows_col_dirty` shl
-      bp_TGtkTreeViewPrivate_mark_rows_col_dirty) and
-      bm_TGtkTreeViewPrivate_mark_rows_col_dirty)
-
-proc enable_search*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_enable_search) shr
-      bp_TGtkTreeViewPrivate_enable_search
-
-proc set_enable_search*(a: PTreeViewPrivate, `enable_search`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`enable_search` shl bp_TGtkTreeViewPrivate_enable_search) and
-      bm_TGtkTreeViewPrivate_enable_search)
-
-proc disable_popdown*(a: PTreeViewPrivate): guint = 
-  result = (a.flag0 and bm_TGtkTreeViewPrivate_disable_popdown) shr
-      bp_TGtkTreeViewPrivate_disable_popdown
-
-proc set_disable_popdown*(a: PTreeViewPrivate, `disable_popdown`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`disable_popdown` shl bp_TGtkTreeViewPrivate_disable_popdown) and
-      bm_TGtkTreeViewPrivate_disable_popdown)
-
-proc SET_FLAG*(tree_view: PTreeView, flag: guint) = 
-  tree_view.priv.flags = tree_view.priv.flags or (flag)
-
-proc UNSET_FLAG*(tree_view: PTreeView, flag: guint) = 
-  tree_view.priv.flags = tree_view.priv.flags and not (flag)
-
-proc TYPE_TREE_VIEW*(): GType = 
-  result = tree_view_get_type()
-
-proc TREE_VIEW*(obj: pointer): PTreeView = 
-  result = cast[PTreeView](CHECK_CAST(obj, TYPE_TREE_VIEW()))
-
-proc TREE_VIEW_CLASS*(klass: pointer): PTreeViewClass = 
-  result = cast[PTreeViewClass](CHECK_CLASS_CAST(klass, TYPE_TREE_VIEW()))
-
-proc IS_TREE_VIEW*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_TREE_VIEW())
-
-proc IS_TREE_VIEW_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_TREE_VIEW())
-
-proc TREE_VIEW_GET_CLASS*(obj: pointer): PTreeViewClass = 
-  result = cast[PTreeViewClass](CHECK_GET_CLASS(obj, TYPE_TREE_VIEW()))
-
-proc TYPE_VBUTTON_BOX*(): GType = 
-  result = vbutton_box_get_type()
-
-proc VBUTTON_BOX*(obj: pointer): PVButtonBox = 
-  result = cast[PVButtonBox](CHECK_CAST(obj, TYPE_VBUTTON_BOX()))
-
-proc VBUTTON_BOX_CLASS*(klass: pointer): PVButtonBoxClass = 
-  result = cast[PVButtonBoxClass](CHECK_CLASS_CAST(klass, TYPE_VBUTTON_BOX()))
-
-proc IS_VBUTTON_BOX*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VBUTTON_BOX())
-
-proc IS_VBUTTON_BOX_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VBUTTON_BOX())
-
-proc VBUTTON_BOX_GET_CLASS*(obj: pointer): PVButtonBoxClass = 
-  result = cast[PVButtonBoxClass](CHECK_GET_CLASS(obj, TYPE_VBUTTON_BOX()))
-
-proc TYPE_VIEWPORT*(): GType = 
-  result = viewport_get_type()
-
-proc VIEWPORT*(obj: pointer): PViewport = 
-  result = cast[PViewport](CHECK_CAST(obj, TYPE_VIEWPORT()))
-
-proc VIEWPORT_CLASS*(klass: pointer): PViewportClass = 
-  result = cast[PViewportClass](CHECK_CLASS_CAST(klass, TYPE_VIEWPORT()))
-
-proc IS_VIEWPORT*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VIEWPORT())
-
-proc IS_VIEWPORT_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VIEWPORT())
-
-proc VIEWPORT_GET_CLASS*(obj: pointer): PViewportClass = 
-  result = cast[PViewportClass](CHECK_GET_CLASS(obj, TYPE_VIEWPORT()))
-
-proc TYPE_VPANED*(): GType = 
-  result = vpaned_get_type()
-
-proc VPANED*(obj: pointer): PVPaned = 
-  result = cast[PVPaned](CHECK_CAST(obj, TYPE_VPANED()))
-
-proc VPANED_CLASS*(klass: pointer): PVPanedClass = 
-  result = cast[PVPanedClass](CHECK_CLASS_CAST(klass, TYPE_VPANED()))
-
-proc IS_VPANED*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VPANED())
-
-proc IS_VPANED_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VPANED())
-
-proc VPANED_GET_CLASS*(obj: pointer): PVPanedClass = 
-  result = cast[PVPanedClass](CHECK_GET_CLASS(obj, TYPE_VPANED()))
-
-proc TYPE_VRULER*(): GType = 
-  result = vruler_get_type()
-
-proc VRULER*(obj: pointer): PVRuler = 
-  result = cast[PVRuler](CHECK_CAST(obj, TYPE_VRULER()))
-
-proc VRULER_CLASS*(klass: pointer): PVRulerClass = 
-  result = cast[PVRulerClass](CHECK_CLASS_CAST(klass, TYPE_VRULER()))
-
-proc IS_VRULER*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VRULER())
-
-proc IS_VRULER_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VRULER())
-
-proc VRULER_GET_CLASS*(obj: pointer): PVRulerClass = 
-  result = cast[PVRulerClass](CHECK_GET_CLASS(obj, TYPE_VRULER()))
-
-proc TYPE_VSCALE*(): GType = 
-  result = vscale_get_type()
-
-proc VSCALE*(obj: pointer): PVScale = 
-  result = cast[PVScale](CHECK_CAST(obj, TYPE_VSCALE()))
-
-proc VSCALE_CLASS*(klass: pointer): PVScaleClass = 
-  result = cast[PVScaleClass](CHECK_CLASS_CAST(klass, TYPE_VSCALE()))
-
-proc IS_VSCALE*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VSCALE())
-
-proc IS_VSCALE_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VSCALE())
-
-proc VSCALE_GET_CLASS*(obj: pointer): PVScaleClass = 
-  result = cast[PVScaleClass](CHECK_GET_CLASS(obj, TYPE_VSCALE()))
-
-proc TYPE_VSCROLLBAR*(): GType = 
-  result = vscrollbar_get_type()
-
-proc VSCROLLBAR*(obj: pointer): PVScrollbar = 
-  result = cast[PVScrollbar](CHECK_CAST(obj, TYPE_VSCROLLBAR()))
-
-proc VSCROLLBAR_CLASS*(klass: pointer): PVScrollbarClass = 
-  result = cast[PVScrollbarClass](CHECK_CLASS_CAST(klass, TYPE_VSCROLLBAR()))
-
-proc IS_VSCROLLBAR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VSCROLLBAR())
-
-proc IS_VSCROLLBAR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VSCROLLBAR())
-
-proc VSCROLLBAR_GET_CLASS*(obj: pointer): PVScrollbarClass = 
-  result = cast[PVScrollbarClass](CHECK_GET_CLASS(obj, TYPE_VSCROLLBAR()))
-
-proc TYPE_VSEPARATOR*(): GType = 
-  result = vseparator_get_type()
-
-proc VSEPARATOR*(obj: pointer): PVSeparator = 
-  result = cast[PVSeparator](CHECK_CAST(obj, TYPE_VSEPARATOR()))
-
-proc VSEPARATOR_CLASS*(klass: pointer): PVSeparatorClass = 
-  result = cast[PVSeparatorClass](CHECK_CLASS_CAST(klass, TYPE_VSEPARATOR()))
-
-proc IS_VSEPARATOR*(obj: pointer): bool = 
-  result = CHECK_TYPE(obj, TYPE_VSEPARATOR())
-
-proc IS_VSEPARATOR_CLASS*(klass: pointer): bool = 
-  result = CHECK_CLASS_TYPE(klass, TYPE_VSEPARATOR())
-
-proc VSEPARATOR_GET_CLASS*(obj: pointer): PVSeparatorClass = 
-  # these were missing:
-  result = cast[PVSeparatorClass](CHECK_GET_CLASS(obj, TYPE_VSEPARATOR()))
-
-type 
-  Tcelllayout {.pure, final.} = object
-
-  PCellLayout* = tcelllayout
-  PPGtkCellLayout* = ptr PCellLayout
-  PSignalRunType* = ptr TSignalRunType
-  TSignalRunType* = int32
-  PFileChooserAction* = ptr TFileChooserAction
-  TFileChooserAction* = enum 
-    FILE_CHOOSER_ACTION_OPEN, FILE_CHOOSER_ACTION_SAVE, 
-    FILE_CHOOSER_ACTION_SELECT_FOLDER, FILE_CHOOSER_ACTION_CREATE_FOLDER
-  PFileChooserError* = ptr TFileChooserError
-  TFileChooserError* = enum 
-    FILE_CHOOSER_ERROR_NONEXISTENT, FILE_CHOOSER_ERROR_BAD_FILENAME
-
-  TFileChooser = object of TDialog
-  PFileChooser* = ptr TFileChooser
-  PPFileChooser* = ptr PFileChooser
-
-
-const 
-  ARG_READWRITE* = ARG_READABLE or ARG_WRITABLE
-
-proc entry_add_signal*(binding_set: PBindingSet, keyval: guint, 
-                               modifiers: gdk2.TModifierType, 
-                               signal_name: cstring, n_args: guint){.varargs, 
-    importc: "gtk_binding_entry_add_signal", cdecl, dynlib: lib.}
-proc clist_new_with_titles*(columns: gint): PCList{.varargs, cdecl, 
-    importc: "gtk_clist_new_with_titles", dynlib: lib.}
-proc prepend*(clist: PCList): gint{.importc: "gtk_clist_prepend", varargs, 
-    cdecl, dynlib: lib.}
-proc append*(clist: PCList): gint{.importc: "gtk_clist_append", varargs, 
-    cdecl, dynlib: lib.}
-proc insert*(clist: PCList, row: gint): gint{.varargs, cdecl, 
-    importc: "gtk_clist_insert", dynlib: lib.}
-proc set_attributes*(cell_layout: PCellLayout, cell: PCellRenderer){.
-    cdecl, varargs, importc: "gtk_cell_layout_set_attributes", dynlib: lib, 
-    importc: "gtk_cell_layout_set_attributes".}
-proc add_with_properties*(container: PContainer, widget: PWidget, 
-                                    first_prop_name: cstring){.varargs, 
-    importc: "gtk_container_add_with_properties", cdecl, dynlib: lib.}
-proc child_set*(container: PContainer, child: PWidget, 
-                          first_prop_name: cstring){.varargs, cdecl, 
-    importc: "gtk_container_child_set", dynlib: lib.}
-proc child_get*(container: PContainer, child: PWidget, 
-                          first_prop_name: cstring){.varargs, cdecl, 
-    importc: "gtk_container_child_get", dynlib: lib.}
-proc child_set_valist*(container: PContainer, child: PWidget, 
-                                 first_property_name: cstring){.varargs, 
-    importc: "gtk_container_child_set_valist", cdecl, dynlib: lib.}
-proc child_get_valist*(container: PContainer, child: PWidget, 
-                                 first_property_name: cstring){.varargs, 
-    importc: "gtk_container_child_get_valist", cdecl, dynlib: lib.}
-proc ctree_new_with_titles*(columns: gint, tree_column: gint): PCTree{.
-    importc: "gtk_ctree_new_with_titles", varargs, cdecl, dynlib: lib.}
-proc get_vector*(curve: PCurve, veclen: int32){.varargs, cdecl, 
-    importc: "gtk_curve_get_vector", dynlib: lib.}
-proc set_vector*(curve: PCurve, veclen: int32){.varargs, cdecl, 
-    importc: "gtk_curve_set_vector", dynlib: lib.}
-proc add_buttons*(dialog: PDialog, first_button_text: cstring){.varargs, 
-    cdecl, importc: "gtk_dialog_add_buttons", dynlib: lib.}
-proc dialog_new_with_buttons*(title: cstring, parent: PWindow, 
-                              flags: TDialogFlags, first_button_text: cstring): PDialog{.
-    varargs, cdecl, importc: "gtk_dialog_new_with_buttons", dynlib: lib.}
-proc list_store_new*(n_columns: gint): PListStore{.varargs, cdecl, 
-    importc: "gtk_list_store_new", dynlib: lib.}
-proc set*(list_store: PListStore, iter: PTreeIter){.varargs, cdecl, 
-    importc: "gtk_list_store_set", dynlib: lib.}
-proc set_valist*(list_store: PListStore, iter: PTreeIter){.varargs, 
-    cdecl, importc: "gtk_list_store_set_valist", dynlib: lib.}
-proc message_dialog_new*(parent: PWindow, flags: TDialogFlags, 
-                         thetype: TMessageType, buttons: TButtonsType, 
-                         message_format: cstring): PMessageDialog{.varargs, 
-    cdecl, importc: "gtk_message_dialog_new", dynlib: lib.}
-proc signal_new*(name: cstring, signal_flags: TSignalRunType, 
-                 object_type: TType, function_offset: guint, 
-                 marshaller: TSignalMarshaller, return_val: TType, n_args: guint): guint{.
-    varargs, importc: "gtk_signal_new", cdecl, dynlib: lib.}
-proc signal_emit*(anObject: PObject, signal_id: guint){.varargs, cdecl, 
-    importc: "gtk_signal_emit", dynlib: lib.}
-proc signal_emit_by_name*(anObject: PObject, name: cstring){.varargs, cdecl, 
-    importc: "gtk_signal_emit_by_name", dynlib: lib.}
-proc insert_with_tags*(buffer: PTextBuffer, iter: PTextIter, 
-                                   text: cstring, length: gint, 
-                                   first_tag: PTextTag){.varargs, 
-    importc: "gtk_text_buffer_insert_with_tags", cdecl, dynlib: lib.}
-proc insert_with_tags_by_name*(buffer: PTextBuffer, iter: PTextIter, 
-    text: cstring, length: gint, first_tag_name: cstring){.varargs, 
-    importc: "gtk_text_buffer_insert_with_tags_by_name", cdecl, dynlib: lib.}
-proc create_tag*(buffer: PTextBuffer, tag_name: cstring, 
-                             first_property_name: cstring): PTextTag{.varargs, 
-    importc: "gtk_text_buffer_create_tag", cdecl, dynlib: lib.}
-proc get*(tree_model: PTreeModel, iter: PTreeIter){.varargs, 
-    importc: "gtk_tree_model_get", cdecl, dynlib: lib.}
-proc get_valist*(tree_model: PTreeModel, iter: PTreeIter){.varargs, 
-    importc: "gtk_tree_model_get_valist", cdecl, dynlib: lib.}
-proc tree_store_new*(n_columns: gint): PTreeStore{.varargs, cdecl, 
-    importc: "gtk_tree_store_new", dynlib: lib.}
-proc set*(tree_store: PTreeStore, iter: PTreeIter){.varargs, cdecl, 
-    importc: "gtk_tree_store_set", dynlib: lib.}
-proc set_valist*(tree_store: PTreeStore, iter: PTreeIter){.varargs, 
-    cdecl, importc: "gtk_tree_store_set_valist", dynlib: lib.}
-proc iter_is_valid*(tree_store: PTreeStore, iter: PTreeIter): gboolean{.
-    cdecl, importc: "gtk_tree_store_iter_is_valid", dynlib: lib.}
-proc reorder*(tree_store: PTreeStore, parent: PTreeIter, 
-                         new_order: pgint){.cdecl, 
-    importc: "gtk_tree_store_reorder", dynlib: lib.}
-proc swap*(tree_store: PTreeStore, a: PTreeIter, b: PTreeIter){.
-    cdecl, importc: "gtk_tree_store_swap", dynlib: lib.}
-proc move_before*(tree_store: PTreeStore, iter: PTreeIter, 
-                             position: PTreeIter){.cdecl, 
-    importc: "gtk_tree_store_move_before", dynlib: lib.}
-proc move_after*(tree_store: PTreeStore, iter: PTreeIter, 
-                            position: PTreeIter){.cdecl, 
-    importc: "gtk_tree_store_move_after", dynlib: lib.}
-proc insert_column_with_attributes*(tree_view: PTreeView, 
-    position: gint, title: cstring, cell: PCellRenderer): gint{.varargs, 
-    importc: "gtk_tree_view_insert_column_with_attributes", cdecl, dynlib: lib.}
-proc tree_view_column_new_with_attributes*(title: cstring, cell: PCellRenderer): PTreeViewColumn{.
-    importc: "gtk_tree_view_column_new_with_attributes", varargs, cdecl, 
-    dynlib: lib.}
-proc column_set_attributes*(tree_column: PTreeViewColumn, 
-                                      cell_renderer: PCellRenderer){.
-    importc: "gtk_tree_view_column_set_attributes", varargs, cdecl, dynlib: lib.}
-proc widget_new*(thetype: TType, first_property_name: cstring): PWidget{.
-    importc: "gtk_widget_new", varargs, cdecl, dynlib: lib.}
-proc set*(widget: PWidget, first_property_name: cstring){.varargs, 
-    importc: "gtk_widget_set", cdecl, dynlib: lib.}
-proc queue_clear*(widget: PWidget){.importc: "gtk_widget_queue_clear", 
-    cdecl, dynlib: lib.}
-proc queue_clear_area*(widget: PWidget, x: gint, y: gint, width: gint, 
-                              height: gint){.cdecl, 
-    importc: "gtk_widget_queue_clear_area", dynlib: lib.}
-proc draw*(widget: PWidget, area: gdk2.PRectangle){.cdecl, 
-    importc: "gtk_widget_draw", dynlib: lib.}
-proc style_get_valist*(widget: PWidget, first_property_name: cstring){.
-    varargs, cdecl, importc: "gtk_widget_style_get_valist", dynlib: lib.}
-proc style_get*(widget: PWidget, first_property_name: cstring){.varargs, 
-    cdecl, importc: "gtk_widget_style_get", dynlib: lib.}
-proc file_chooser_dialog_new*(title: cstring, parent: PWindow, 
-                              action: TFileChooserAction, 
-                              first_button_text: cstring): PFileChooser{.cdecl, 
-    varargs, dynlib: lib, importc: "gtk_file_chooser_dialog_new".}
-        
-proc file_chooser_dialog_new_with_backend*(title: cstring, parent: PWindow, 
-    action: TFileChooserAction, backend: cstring, first_button_text: cstring): PFileChooser{.
-    varargs, cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_dialog_new_with_backend".}
-proc reference*(anObject: PObject): PObject{.cdecl, importc: "gtk_object_ref", 
-    dynlib: lib.}
-proc unref*(anObject: PObject){.cdecl, importc: "gtk_object_unref", 
-                                       dynlib: lib.}
-proc weakref*(anObject: PObject, notify: TDestroyNotify, data: gpointer){.
-    cdecl, importc: "gtk_object_weakref", dynlib: lib.}
-proc weakunref*(anObject: PObject, notify: TDestroyNotify, data: gpointer){.
-    cdecl, importc: "gtk_object_weakunref", dynlib: lib.}
-proc set_data*(anObject: PObject, key: cstring, data: gpointer){.cdecl, 
-    importc: "gtk_object_set_data", dynlib: lib.}
-proc set_data_full*(anObject: PObject, key: cstring, data: gpointer, 
-                           destroy: TDestroyNotify){.
-    importc: "gtk_object_set_data_full", cdecl, dynlib: lib.}
-proc remove_data*(anObject: PObject, key: cstring){.cdecl, 
-    importc: "gtk_object_remove_data", dynlib: lib.}
-proc get_data*(anObject: PObject, key: cstring): gpointer{.cdecl, 
-    importc: "gtk_object_get_data", dynlib: lib.}
-proc remove_no_notify*(anObject: PObject, key: cstring){.cdecl, 
-    importc: "gtk_object_remove_no_notify", dynlib: lib.}
-proc set_user_data*(anObject: PObject, data: gpointer){.cdecl, 
-    importc: "gtk_object_set_user_data", dynlib: lib.}
-proc get_user_data*(anObject: PObject): gpointer{.cdecl, 
-    importc: "gtk_object_get_user_data", dynlib: lib.}
-proc set_data_by_id*(anObject: PObject, data_id: TGQuark, data: gpointer){.
-    cdecl, importc: "gtk_object_set_data_by_id", dynlib: lib.}
-proc set_data_by_id_full*(anObject: PObject, data_id: TGQuark, 
-                                 data: gpointer, destroy: TDestroyNotify){.
-    cdecl, importc: "gtk_object_set_data_by_id_full", dynlib: lib.}
-proc get_data_by_id*(anObject: PObject, data_id: TGQuark): gpointer{.
-    cdecl, importc: "gtk_object_get_data_by_id", dynlib: lib.}
-proc remove_data_by_id*(anObject: PObject, data_id: TGQuark){.cdecl, 
-    importc: "gtk_object_remove_data_by_id", dynlib: lib.}
-proc remove_no_notify_by_id*(anObject: PObject, key_id: TGQuark){.cdecl, 
-    importc: "gtk_object_remove_no_notify_by_id", dynlib: lib.}
-proc object_data_try_key*(str: cstring): TGQuark{.cdecl, 
-    importc: "gtk_object_data_try_key", dynlib: lib.}
-proc object_data_force_id*(str: cstring): TGQuark{.cdecl, 
-    importc: "gtk_object_data_force_id", dynlib: lib.}
-proc get*(anObject: PObject, first_property_name: cstring){.cdecl, 
-    importc: "gtk_object_get", varargs, dynlib: lib.}
-proc set*(anObject: PObject, first_property_name: cstring){.cdecl, 
-    importc: "gtk_object_set", varargs, dynlib: lib.}
-proc object_add_arg_type*(arg_name: cstring, arg_type: TType, arg_flags: guint, 
-                          arg_id: guint){.cdecl, 
-    importc: "gtk_object_add_arg_type", dynlib: lib.}
-
-type 
-  TFileFilter {.pure, final.} = object
-  PFileFilter* = ptr TFileFilter
-  PPGtkFileFilter* = ptr PFileFilter
-  PFileFilterFlags* = ptr TFileFilterFlags
-  TFileFilterFlags* = enum 
-    FILE_FILTER_FILENAME = 1 shl 0, FILE_FILTER_URI = 1 shl 1, 
-    FILE_FILTER_DISPLAY_NAME = 1 shl 2, FILE_FILTER_MIME_TYPE = 1 shl 3
-  PFileFilterInfo* = ptr TFileFilterInfo
-  TFileFilterInfo*{.final, pure.} = object 
-    contains*: TFileFilterFlags
-    filename*: cstring
-    uri*: cstring
-    display_name*: cstring
-    mime_type*: cstring
-
-  TFileFilterFunc* = proc (filter_info: PFileFilterInfo, data: gpointer): gboolean{.
-      cdecl.}
-
-proc TYPE_FILE_FILTER*(): GType
-proc FILE_FILTER*(obj: pointer): PFileFilter
-proc IS_FILE_FILTER*(obj: pointer): gboolean
-proc file_filter_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "gtk_file_filter_get_type".}
-proc file_filter_new*(): PFileFilter{.cdecl, dynlib: lib, 
-                                      importc: "gtk_file_filter_new".}
-proc set_name*(filter: PFileFilter, name: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_file_filter_set_name".}
-proc get_name*(filter: PFileFilter): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_file_filter_get_name".}
-proc add_mime_type*(filter: PFileFilter, mime_type: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_file_filter_add_mime_type".}
-proc add_pattern*(filter: PFileFilter, pattern: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_file_filter_add_pattern".}
-proc add_custom*(filter: PFileFilter, needed: TFileFilterFlags, 
-                             func: TFileFilterFunc, data: gpointer, 
-                             notify: TGDestroyNotify){.cdecl, dynlib: lib, 
-    importc: "gtk_file_filter_add_custom".}
-proc get_needed*(filter: PFileFilter): TFileFilterFlags{.cdecl, 
-    dynlib: lib, importc: "gtk_file_filter_get_needed".}
-proc filter*(filter: PFileFilter, filter_info: PFileFilterInfo): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_filter_filter".}
-proc TYPE_FILE_FILTER(): GType = 
-  result = file_filter_get_type()
-
-proc FILE_FILTER(obj: pointer): PFileFilter = 
-  result = cast[PFileFilter](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_FILE_FILTER()))
-
-proc IS_FILE_FILTER(obj: pointer): gboolean = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_FILE_FILTER())
-
-proc file_chooser_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "gtk_file_chooser_get_type".}
-proc file_chooser_error_quark*(): TGQuark{.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_error_quark".}
-proc TYPE_FILE_CHOOSER*(): GType = 
-  result = file_chooser_get_type()
-
-proc FILE_CHOOSER*(obj: pointer): PFileChooser = 
-  result = cast[PFileChooser](G_TYPE_CHECK_INSTANCE_CAST(obj, 
-      TYPE_FILE_CHOOSER()))
-
-proc IS_FILE_CHOOSER*(obj: pointer): gboolean = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_FILE_CHOOSER())
-
-proc set_action*(chooser: PFileChooser, action: TFileChooserAction){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_action".}
-proc get_action*(chooser: PFileChooser): TFileChooserAction{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_action".}
-proc set_local_only*(chooser: PFileChooser, local_only: gboolean){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_local_only".}
-proc get_local_only*(chooser: PFileChooser): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_local_only".}
-proc set_select_multiple*(chooser: PFileChooser, 
-                                       select_multiple: gboolean){.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_set_select_multiple".}
-proc get_select_multiple*(chooser: PFileChooser): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_select_multiple".}
-proc set_current_name*(chooser: PFileChooser, name: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_current_name".}
-proc get_filename*(chooser: PFileChooser): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_filename".}
-proc set_filename*(chooser: PFileChooser, filename: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_filename".}
-proc select_filename*(chooser: PFileChooser, filename: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_select_filename".}
-proc unselect_filename*(chooser: PFileChooser, filename: cstring){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_unselect_filename".}
-proc select_all*(chooser: PFileChooser){.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_select_all".}
-proc unselect_all*(chooser: PFileChooser){.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_unselect_all".}
-proc get_filenames*(chooser: PFileChooser): PGSList{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_filenames".}
-proc set_current_folder*(chooser: PFileChooser, filename: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_current_folder".}
-proc get_current_folder*(chooser: PFileChooser): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_current_folder".}
-proc get_uri*(chooser: PFileChooser): cstring{.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_get_uri".}
-proc set_uri*(chooser: PFileChooser, uri: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_uri".}
-proc select_uri*(chooser: PFileChooser, uri: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_select_uri".}
-proc unselect_uri*(chooser: PFileChooser, uri: cstring){.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_unselect_uri".}
-proc get_uris*(chooser: PFileChooser): PGSList{.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_get_uris".}
-proc set_current_folder_uri*(chooser: PFileChooser, uri: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_current_folder_uri".}
-proc get_current_folder_uri*(chooser: PFileChooser): cstring{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_get_current_folder_uri".}
-proc set_preview_widget*(chooser: PFileChooser, 
-                                      preview_widget: PWidget){.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_set_preview_widget".}
-proc get_preview_widget*(chooser: PFileChooser): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_preview_widget".}
-proc set_preview_widget_active*(chooser: PFileChooser, 
-    active: gboolean){.cdecl, dynlib: lib, 
-                       importc: "gtk_file_chooser_set_preview_widget_active".}
-proc get_preview_widget_active*(chooser: PFileChooser): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_get_preview_widget_active".}
-proc set_use_preview_label*(chooser: PFileChooser, 
-    use_label: gboolean){.cdecl, dynlib: lib, 
-                          importc: "gtk_file_chooser_set_use_preview_label".}
-proc get_use_preview_label*(chooser: PFileChooser): gboolean{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_get_use_preview_label".}
-proc get_preview_filename*(chooser: PFileChooser): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_preview_filename".}
-proc get_preview_uri*(chooser: PFileChooser): cstring{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_preview_uri".}
-proc set_extra_widget*(chooser: PFileChooser, extra_widget: PWidget){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_extra_widget".}
-proc get_extra_widget*(chooser: PFileChooser): PWidget{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_extra_widget".}
-proc add_filter*(chooser: PFileChooser, filter: PFileFilter){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_add_filter".}
-proc remove_filter*(chooser: PFileChooser, filter: PFileFilter){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_remove_filter".}
-proc list_filters*(chooser: PFileChooser): PGSList{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_list_filters".}
-proc set_filter*(chooser: PFileChooser, filter: PFileFilter){.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_set_filter".}
-proc get_filter*(chooser: PFileChooser): PFileFilter{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_get_filter".}
-proc add_shortcut_folder*(chooser: PFileChooser, folder: cstring, 
-                                       error: pointer): gboolean{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_add_shortcut_folder".}
-proc remove_shortcut_folder*(chooser: PFileChooser, 
-    folder: cstring, error: pointer): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_remove_shortcut_folder".}
-proc list_shortcut_folders*(chooser: PFileChooser): PGSList{.cdecl, 
-    dynlib: lib, importc: "gtk_file_chooser_list_shortcut_folders".}
-proc add_shortcut_folder_uri*(chooser: PFileChooser, uri: cstring, 
-    error: pointer): gboolean{.cdecl, dynlib: lib, importc: "gtk_file_chooser_add_shortcut_folder_uri".}
-proc remove_shortcut_folder_uri*(chooser: PFileChooser, 
-    uri: cstring, error: pointer): gboolean{.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_remove_shortcut_folder_uri".}
-proc list_shortcut_folder_uris*(chooser: PFileChooser): PGSList{.
-    cdecl, dynlib: lib, importc: "gtk_file_chooser_list_shortcut_folder_uris".}
-proc set_do_overwrite_confirmation*(chooser: PFileChooser, 
-    do_overwrite_confirmation: gboolean){.cdecl, dynlib: lib, 
-    importc: "gtk_file_chooser_set_do_overwrite_confirmation".}
-
-proc nimrod_init*() = 
-  var 
-    cmdLine{.importc: "cmdLine".}: array[0..255, cstring]
-    cmdCount{.importc: "cmdCount".}: cint
-  init(addr(cmdLine), addr(cmdCount))
diff --git a/lib/wrappers/gtk/libglade2.nim b/lib/wrappers/gtk/libglade2.nim
deleted file mode 100755
index 844f055a0..000000000
--- a/lib/wrappers/gtk/libglade2.nim
+++ /dev/null
@@ -1,108 +0,0 @@
-{.deadCodeElim: on.}
-import 
-  glib2, gtk2
-
-when defined(win32): 
-  const 
-    LibGladeLib = "libglade-2.0-0.dll"
-else: 
-  const 
-    LibGladeLib = "libglade-2.0.so"
-type 
-  PLongint* = ptr int32
-  PSmallInt* = ptr int16
-  PByte* = ptr int8
-  PWord* = ptr int16
-  PDWord* = ptr int32
-  PDouble* = ptr float64
-
-proc init*(){.cdecl, dynlib: LibGladeLib, importc: "glade_init".}
-proc require*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib, 
-                                    importc: "glade_require".}
-proc provide*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib, 
-                                    importc: "glade_provide".}
-type 
-  PXMLPrivate* = pointer
-  PXML* = ptr TXML
-  TXML* = object of TGObject
-    filename*: cstring
-    priv*: PXMLPrivate
-
-  PXMLClass* = ptr TXMLClass
-  TXMLClass* = object of TGObjectClass
-  TXMLConnectFunc* = proc (handler_name: cstring, anObject: PGObject, 
-                           signal_name: cstring, signal_data: cstring, 
-                           connect_object: PGObject, after: gboolean, 
-                           user_data: gpointer){.cdecl.}
-
-proc TYPE_XML*(): GType
-proc XML*(obj: pointer): PXML
-proc XML_CLASS*(klass: pointer): PXMLClass
-proc IS_XML*(obj: pointer): gboolean
-proc IS_XML_CLASS*(klass: pointer): gboolean
-proc XML_GET_CLASS*(obj: pointer): PXMLClass
-proc xml_get_type*(): GType{.cdecl, dynlib: LibGladeLib, 
-                             importc: "glade_xml_get_type".}
-proc xml_new*(fname: cstring, root: cstring, domain: cstring): PXML{.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_new".}
-proc xml_new_from_buffer*(buffer: cstring, size: int32, root: cstring, 
-                          domain: cstring): PXML{.cdecl, dynlib: LibGladeLib, 
-    importc: "glade_xml_new_from_buffer".}
-proc construct*(self: PXML, fname: cstring, root: cstring, domain: cstring): gboolean{.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_construct".}
-proc signal_connect*(self: PXML, handlername: cstring, func: TGCallback){.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_signal_connect".}
-proc signal_connect_data*(self: PXML, handlername: cstring, 
-                              func: TGCallback, user_data: gpointer){.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_signal_connect_data".}
-proc signal_autoconnect*(self: PXML){.cdecl, dynlib: LibGladeLib, 
-    importc: "glade_xml_signal_autoconnect".}
-proc signal_connect_full*(self: PXML, handler_name: cstring, 
-                              func: TXMLConnectFunc, user_data: gpointer){.
-    cdecl, dynlib: LibGladeLib, importc: "glade_xml_signal_connect_full".}
-proc signal_autoconnect_full*(self: PXML, func: TXMLConnectFunc, 
-                                  user_data: gpointer){.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_signal_autoconnect_full".}
-proc get_widget*(self: PXML, name: cstring): gtk2.PWidget{.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_get_widget".}
-proc get_widget_prefix*(self: PXML, name: cstring): PGList{.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_get_widget_prefix".}
-proc relative_file*(self: PXML, filename: cstring): cstring{.cdecl, 
-    dynlib: LibGladeLib, importc: "glade_xml_relative_file".}
-proc get_widget_name*(widget: gtk2.PWidget): cstring{.cdecl, dynlib: LibGladeLib, 
-    importc: "glade_get_widget_name".}
-proc get_widget_tree*(widget: gtk2.PWidget): PXML{.cdecl, dynlib: LibGladeLib, 
-    importc: "glade_get_widget_tree".}
-type 
-  PXMLCustomWidgetHandler* = ptr TXMLCustomWidgetHandler
-  TXMLCustomWidgetHandler* = gtk2.TWidget
-
-proc set_custom_handler*(handler: TXMLCustomWidgetHandler, user_data: gpointer){.
-    cdecl, dynlib: LibGladeLib, importc: "glade_set_custom_handler".}
-proc gnome_init*() = 
-  init()
-
-proc bonobo_init*() = 
-  init()
-
-proc xml_new_from_memory*(buffer: cstring, size: int32, root: cstring, 
-                          domain: cstring): PXML = 
-  result = xml_new_from_buffer(buffer, size, root, domain)
-
-proc TYPE_XML*(): GType = 
-  result = xml_get_type()
-
-proc XML*(obj: pointer): PXML = 
-  result = cast[PXML](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_XML()))
-
-proc XML_CLASS*(klass: pointer): PXMLClass = 
-  result = cast[PXMLClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_XML()))
-
-proc IS_XML*(obj: pointer): gboolean = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_XML())
-
-proc IS_XML_CLASS*(klass: pointer): gboolean = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_XML())
-
-proc XML_GET_CLASS*(obj: pointer): PXMLClass = 
-  result = cast[PXMLClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_XML()))
diff --git a/lib/wrappers/gtk/pango.nim b/lib/wrappers/gtk/pango.nim
deleted file mode 100755
index facdffb38..000000000
--- a/lib/wrappers/gtk/pango.nim
+++ /dev/null
@@ -1,1157 +0,0 @@
-{.deadCodeElim: on.}
-import 
-  glib2
-
-when defined(win32): 
-  const 
-    lib* = "libpango-1.0-0.dll"
-else: 
-  const 
-    lib* = "libpango-1.0.so.0"
-type 
-  TFont* {.pure, final.} = object
-  PFont* = ptr TFont
-  TFontFamily* {.pure, final.} = object
-  PFontFamily* = ptr TFontFamily
-  TFontSet* {.pure, final.} = object
-  PFontset* = ptr TFontset
-  TFontMetrics* {.pure, final.} = object
-  PFontMetrics* = ptr TFontMetrics
-  TFontFace* {.pure, final.} = object
-  PFontFace* = ptr TFontFace
-  TFontMap* {.pure, final.} = object
-  PFontMap* = ptr TFontMap
-  TFontsetClass {.pure, final.} = object
-  PFontsetClass* = ptr TFontSetClass
-  TFontFamilyClass* {.pure, final.} = object
-  PFontFamilyClass* = ptr TFontFamilyClass
-  TFontFaceClass* {.pure, final.} = object
-  PFontFaceClass* = ptr TFontFaceClass
-  TFontClass* {.pure, final.} = object
-  PFontClass* = ptr TFontClass
-  TFontMapClass* {.pure, final.} = object
-  PFontMapClass* = ptr TFontMapClass
-  PFontDescription* = ptr TFontDescription
-  TFontDescription* {.pure, final.} = object
-  PAttrList* = ptr TAttrList
-  TAttrList* {.pure, final.} = object
-  PAttrIterator* = ptr TAttrIterator
-  TAttrIterator* {.pure, final.} = object
-  PLayout* = ptr TLayout
-  TLayout* {.pure, final.} = object
-  PLayoutClass* = ptr TLayoutClass
-  TLayoutClass* {.pure, final.} = object
-  PLayoutIter* = ptr TLayoutIter
-  TLayoutIter* {.pure, final.} = object
-  PContext* = ptr TContext
-  TContext* {.pure, final.} = object
-  PContextClass* = ptr TContextClass
-  TContextClass* {.pure, final.} = object
-  PFontsetSimple* = ptr TFontsetSimple
-  TFontsetSimple* {.pure, final.} = object
-  PTabArray* = ptr TTabArray
-  TTabArray* {.pure, final.} = object
-  PGlyphString* = ptr TGlyphString
-  PAnalysis* = ptr TAnalysis
-  PItem* = ptr TItem
-  PLanguage* = ptr TLanguage
-  TLanguage* {.pure, final.} = object
-  PGlyph* = ptr TGlyph
-  TGlyph* = guint32
-  PRectangle* = ptr TRectangle
-  TRectangle*{.final, pure.} = object 
-    x*: int32
-    y*: int32
-    width*: int32
-    height*: int32
-
-  PDirection* = ptr TDirection
-  TDirection* = enum 
-    DIRECTION_LTR, DIRECTION_RTL, DIRECTION_TTB_LTR, DIRECTION_TTB_RTL
-  PColor* = ptr TColor
-  TColor*{.final, pure.} = object 
-    red*: guint16
-    green*: guint16
-    blue*: guint16
-
-  PAttrType* = ptr TAttrType
-  TAttrType* = int32
-  PUnderline* = ptr TUnderline
-  TUnderline* = int32
-  PAttribute* = ptr TAttribute
-  PAttrClass* = ptr TAttrClass
-  TAttribute*{.final, pure.} = object 
-    klass*: PAttrClass
-    start_index*: int
-    end_index*: int
-
-  TAttrClass*{.final, pure.} = object 
-    `type`*: TAttrType
-    copy*: proc (attr: PAttribute): PAttribute{.cdecl.}
-    destroy*: proc (attr: PAttribute){.cdecl.}
-    equal*: proc (attr1: PAttribute, attr2: PAttribute): gboolean{.cdecl.}
-
-  PAttrString* = ptr TAttrString
-  TAttrString*{.final, pure.} = object 
-    attr*: TAttribute
-    value*: cstring
-
-  PAttrLanguage* = ptr TAttrLanguage
-  TAttrLanguage*{.final, pure.} = object 
-    attr*: TAttribute
-    value*: PLanguage
-
-  PAttrInt* = ptr TAttrInt
-  TAttrInt*{.final, pure.} = object 
-    attr*: TAttribute
-    value*: int32
-
-  PAttrFloat* = ptr TAttrFloat
-  TAttrFloat*{.final, pure.} = object 
-    attr*: TAttribute
-    value*: gdouble
-
-  PAttrColor* = ptr TAttrColor
-  TAttrColor*{.final, pure.} = object 
-    attr*: TAttribute
-    color*: TColor
-
-  PAttrShape* = ptr TAttrShape
-  TAttrShape*{.final, pure.} = object 
-    attr*: TAttribute
-    ink_rect*: TRectangle
-    logical_rect*: TRectangle
-
-  PAttrFontDesc* = ptr TAttrFontDesc
-  TAttrFontDesc*{.final, pure.} = object 
-    attr*: TAttribute
-    desc*: PFontDescription
-
-  PLogAttr* = ptr TLogAttr
-  TLogAttr*{.final, pure.} = object 
-    flag0*: guint16
-
-  PCoverageLevel* = ptr TCoverageLevel
-  TCoverageLevel* = enum 
-    COVERAGE_NONE, COVERAGE_FALLBACK, COVERAGE_APPROXIMATE, COVERAGE_EXACT
-  PBlockInfo* = ptr TBlockInfo
-  TBlockInfo*{.final, pure.} = object 
-    data*: Pguchar
-    level*: TCoverageLevel
-
-  PCoverage* = ptr TCoverage
-  TCoverage*{.final, pure.} = object 
-    ref_count*: int
-    n_blocks*: int32
-    data_size*: int32
-    blocks*: PBlockInfo
-
-  PEngineRange* = ptr TEngineRange
-  TEngineRange*{.final, pure.} = object 
-    start*: int32
-    theEnd*: int32
-    langs*: cstring
-
-  PEngineInfo* = ptr TEngineInfo
-  TEngineInfo*{.final, pure.} = object 
-    id*: cstring
-    engine_type*: cstring
-    render_type*: cstring
-    ranges*: PEngineRange
-    n_ranges*: gint
-
-  PEngine* = ptr TEngine
-  TEngine*{.final, pure.} = object 
-    id*: cstring
-    `type`*: cstring
-    length*: gint
-
-  TEngineLangScriptBreak* = proc (text: cstring, len: int32, 
-                                  analysis: PAnalysis, attrs: PLogAttr, 
-                                  attrs_len: int32){.cdecl.}
-  PEngineLang* = ptr TEngineLang
-  TEngineLang*{.final, pure.} = object 
-    engine*: TEngine
-    script_break*: TEngineLangScriptBreak
-
-  TEngineShapeScript* = proc (font: PFont, text: cstring, length: int32, 
-                              analysis: PAnalysis, glyphs: PGlyphString){.cdecl.}
-  TEngineShapeGetCoverage* = proc (font: PFont, language: PLanguage): PCoverage{.
-      cdecl.}
-  PEngineShape* = ptr TEngineShape
-  TEngineShape*{.final, pure.} = object 
-    engine*: TEngine
-    script_shape*: TEngineShapeScript
-    get_coverage*: TEngineShapeGetCoverage
-
-  PStyle* = ptr TStyle
-  TStyle* = gint
-  PVariant* = ptr TVariant
-  TVariant* = gint
-  PWeight* = ptr TWeight
-  TWeight* = gint
-  PStretch* = ptr TStretch
-  TStretch* = gint
-  PFontMask* = ptr TFontMask
-  TFontMask* = int32
-  PGlyphUnit* = ptr TGlyphUnit
-  TGlyphUnit* = gint32
-  PGlyphGeometry* = ptr TGlyphGeometry
-  TGlyphGeometry*{.final, pure.} = object 
-    width*: TGlyphUnit
-    x_offset*: TGlyphUnit
-    y_offset*: TGlyphUnit
-
-  PGlyphVisAttr* = ptr TGlyphVisAttr
-  TGlyphVisAttr*{.final, pure.} = object 
-    flag0*: int16
-
-  PGlyphInfo* = ptr TGlyphInfo
-  TGlyphInfo*{.final, pure.} = object 
-    glyph*: TGlyph
-    geometry*: TGlyphGeometry
-    attr*: TGlyphVisAttr
-
-  TGlyphString*{.final, pure.} = object 
-    num_glyphs*: gint
-    glyphs*: PGlyphInfo
-    log_clusters*: Pgint
-    space*: gint
-
-  TAnalysis*{.final, pure.} = object 
-    shape_engine*: PEngineShape
-    lang_engine*: PEngineLang
-    font*: PFont
-    level*: guint8
-    language*: PLanguage
-    extra_attrs*: PGSList
-
-  TItem*{.final, pure.} = object 
-    offset*: gint
-    length*: gint
-    num_chars*: gint
-    analysis*: TAnalysis
-
-  PAlignment* = ptr TAlignment
-  TAlignment* = enum 
-    ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT
-  PWrapMode* = ptr TWrapMode
-  TWrapMode* = enum 
-    WRAP_WORD, WRAP_CHAR
-  PLayoutLine* = ptr TLayoutLine
-  TLayoutLine*{.final, pure.} = object 
-    layout*: PLayout
-    start_index*: gint
-    length*: gint
-    runs*: PGSList
-
-  PLayoutRun* = ptr TLayoutRun
-  TLayoutRun*{.final, pure.} = object 
-    item*: PItem
-    glyphs*: PGlyphString
-
-  PTabAlign* = ptr TTabAlign
-  TTabAlign* = enum 
-    TAB_LEFT
-
-const 
-  SCALE* = 1024
-
-proc PIXELS*(d: int): int
-proc ASCENT*(rect: TRectangle): int32
-proc DESCENT*(rect: TRectangle): int32
-proc LBEARING*(rect: TRectangle): int32
-proc RBEARING*(rect: TRectangle): int32
-proc TYPE_LANGUAGE*(): GType
-proc language_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "pango_language_get_type".}
-proc language_from_string*(language: cstring): PLanguage{.cdecl, dynlib: lib, 
-    importc: "pango_language_from_string".}
-proc to_string*(language: PLanguage): cstring
-proc matches*(language: PLanguage, range_list: cstring): gboolean{.
-    cdecl, dynlib: lib, importc: "pango_language_matches".}
-const 
-  ATTR_INVALID* = 0
-  ATTR_LANGUAGE* = 1
-  ATTR_FAMILY* = 2
-  ATTR_STYLE* = 3
-  ATTR_WEIGHT* = 4
-  ATTR_VARIANT* = 5
-  ATTR_STRETCH* = 6
-  ATTR_SIZE* = 7
-  ATTR_FONT_DESC* = 8
-  ATTR_FOREGROUND* = 9
-  ATTR_BACKGROUND* = 10
-  ATTR_UNDERLINE* = 11
-  ATTR_STRIKETHROUGH* = 12
-  ATTR_RISE* = 13
-  ATTR_SHAPE* = 14
-  ATTR_SCALE* = 15
-  UNDERLINE_NONE* = 0
-  UNDERLINE_SINGLE* = 1
-  UNDERLINE_DOUBLE* = 2
-  UNDERLINE_LOW* = 3
-
-proc TYPE_COLOR*(): GType
-proc color_get_type*(): GType{.cdecl, dynlib: lib, 
-                               importc: "pango_color_get_type".}
-proc copy*(src: PColor): PColor{.cdecl, dynlib: lib, 
-                                       importc: "pango_color_copy".}
-proc free*(color: PColor){.cdecl, dynlib: lib, importc: "pango_color_free".}
-proc parse*(color: PColor, spec: cstring): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_color_parse".}
-proc TYPE_ATTR_LIST*(): GType
-proc attr_type_register*(name: cstring): TAttrType{.cdecl, dynlib: lib, 
-    importc: "pango_attr_type_register".}
-proc copy*(attr: PAttribute): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attribute_copy".}
-proc destroy*(attr: PAttribute){.cdecl, dynlib: lib, 
-    importc: "pango_attribute_destroy".}
-proc equal*(attr1: PAttribute, attr2: PAttribute): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_attribute_equal".}
-proc attr_language_new*(language: PLanguage): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_language_new".}
-proc attr_family_new*(family: cstring): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_family_new".}
-proc attr_foreground_new*(red: guint16, green: guint16, blue: guint16): PAttribute{.
-    cdecl, dynlib: lib, importc: "pango_attr_foreground_new".}
-proc attr_background_new*(red: guint16, green: guint16, blue: guint16): PAttribute{.
-    cdecl, dynlib: lib, importc: "pango_attr_background_new".}
-proc attr_size_new*(size: int32): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_size_new".}
-proc attr_style_new*(style: TStyle): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_style_new".}
-proc attr_weight_new*(weight: TWeight): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_weight_new".}
-proc attr_variant_new*(variant: TVariant): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_variant_new".}
-proc attr_stretch_new*(stretch: TStretch): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_stretch_new".}
-proc attr_font_desc_new*(desc: PFontDescription): PAttribute{.cdecl, 
-    dynlib: lib, importc: "pango_attr_font_desc_new".}
-proc attr_underline_new*(underline: TUnderline): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_underline_new".}
-proc attr_strikethrough_new*(strikethrough: gboolean): PAttribute{.cdecl, 
-    dynlib: lib, importc: "pango_attr_strikethrough_new".}
-proc attr_rise_new*(rise: int32): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_rise_new".}
-proc attr_shape_new*(ink_rect: PRectangle, logical_rect: PRectangle): PAttribute{.
-    cdecl, dynlib: lib, importc: "pango_attr_shape_new".}
-proc attr_scale_new*(scale_factor: gdouble): PAttribute{.cdecl, dynlib: lib, 
-    importc: "pango_attr_scale_new".}
-proc attr_list_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "pango_attr_list_get_type".}
-proc attr_list_new*(): PAttrList{.cdecl, dynlib: lib, 
-                                  importc: "pango_attr_list_new".}
-proc reference*(list: PAttrList){.cdecl, dynlib: lib, 
-                                      importc: "pango_attr_list_ref".}
-proc unref*(list: PAttrList){.cdecl, dynlib: lib, 
-                                        importc: "pango_attr_list_unref".}
-proc copy*(list: PAttrList): PAttrList{.cdecl, dynlib: lib, 
-    importc: "pango_attr_list_copy".}
-proc insert*(list: PAttrList, attr: PAttribute){.cdecl, dynlib: lib, 
-    importc: "pango_attr_list_insert".}
-proc insert_before*(list: PAttrList, attr: PAttribute){.cdecl, 
-    dynlib: lib, importc: "pango_attr_list_insert_before".}
-proc change*(list: PAttrList, attr: PAttribute){.cdecl, dynlib: lib, 
-    importc: "pango_attr_list_change".}
-proc splice*(list: PAttrList, other: PAttrList, pos: gint, len: gint){.
-    cdecl, dynlib: lib, importc: "pango_attr_list_splice".}
-proc get_iterator*(list: PAttrList): PAttrIterator{.cdecl, 
-    dynlib: lib, importc: "pango_attr_list_get_iterator".}
-proc attr_iterator_range*(`iterator`: PAttrIterator, start: Pgint, theEnd: Pgint){.
-    cdecl, dynlib: lib, importc: "pango_attr_iterator_range".}
-proc attr_iterator_next*(`iterator`: PAttrIterator): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_attr_iterator_next".}
-proc attr_iterator_copy*(`iterator`: PAttrIterator): PAttrIterator{.cdecl, 
-    dynlib: lib, importc: "pango_attr_iterator_copy".}
-proc attr_iterator_destroy*(`iterator`: PAttrIterator){.cdecl, dynlib: lib, 
-    importc: "pango_attr_iterator_destroy".}
-proc attr_iterator_get*(`iterator`: PAttrIterator, `type`: TAttrType): PAttribute{.
-    cdecl, dynlib: lib, importc: "pango_attr_iterator_get".}
-proc attr_iterator_get_font*(`iterator`: PAttrIterator, desc: PFontDescription, 
-                             language: var PLanguage, extra_attrs: PPGSList){.
-    cdecl, dynlib: lib, importc: "pango_attr_iterator_get_font".}
-proc parse_markup*(markup_text: cstring, length: int32, accel_marker: gunichar, 
-                   attr_list: var PAttrList, text: PPchar, 
-                   accel_char: Pgunichar, error: pointer): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_parse_markup".}
-const 
-  bm_TPangoLogAttr_is_line_break* = 0x0001'i16
-  bp_TPangoLogAttr_is_line_break* = 0'i16
-  bm_TPangoLogAttr_is_mandatory_break* = 0x0002'i16
-  bp_TPangoLogAttr_is_mandatory_break* = 1'i16
-  bm_TPangoLogAttr_is_char_break* = 0x0004'i16
-  bp_TPangoLogAttr_is_char_break* = 2'i16
-  bm_TPangoLogAttr_is_white* = 0x0008'i16
-  bp_TPangoLogAttr_is_white* = 3'i16
-  bm_TPangoLogAttr_is_cursor_position* = 0x0010'i16
-  bp_TPangoLogAttr_is_cursor_position* = 4'i16
-  bm_TPangoLogAttr_is_word_start* = 0x0020'i16
-  bp_TPangoLogAttr_is_word_start* = 5'i16
-  bm_TPangoLogAttr_is_word_end* = 0x0040'i16
-  bp_TPangoLogAttr_is_word_end* = 6'i16
-  bm_TPangoLogAttr_is_sentence_boundary* = 0x0080'i16
-  bp_TPangoLogAttr_is_sentence_boundary* = 7'i16
-  bm_TPangoLogAttr_is_sentence_start* = 0x0100'i16
-  bp_TPangoLogAttr_is_sentence_start* = 8'i16
-  bm_TPangoLogAttr_is_sentence_end* = 0x0200'i16
-  bp_TPangoLogAttr_is_sentence_end* = 9'i16
-
-proc is_line_break*(a: PLogAttr): guint
-proc set_is_line_break*(a: PLogAttr, `is_line_break`: guint)
-proc is_mandatory_break*(a: PLogAttr): guint
-proc set_is_mandatory_break*(a: PLogAttr, `is_mandatory_break`: guint)
-proc is_char_break*(a: PLogAttr): guint
-proc set_is_char_break*(a: PLogAttr, `is_char_break`: guint)
-proc is_white*(a: PLogAttr): guint
-proc set_is_white*(a: PLogAttr, `is_white`: guint)
-proc is_cursor_position*(a: PLogAttr): guint
-proc set_is_cursor_position*(a: PLogAttr, `is_cursor_position`: guint)
-proc is_word_start*(a: PLogAttr): guint
-proc set_is_word_start*(a: PLogAttr, `is_word_start`: guint)
-proc is_word_end*(a: PLogAttr): guint
-proc set_is_word_end*(a: PLogAttr, `is_word_end`: guint)
-proc is_sentence_boundary*(a: PLogAttr): guint
-proc set_is_sentence_boundary*(a: PLogAttr, `is_sentence_boundary`: guint)
-proc is_sentence_start*(a: PLogAttr): guint
-proc set_is_sentence_start*(a: PLogAttr, `is_sentence_start`: guint)
-proc is_sentence_end*(a: PLogAttr): guint
-proc set_is_sentence_end*(a: PLogAttr, `is_sentence_end`: guint)
-proc `break`*(text: cstring, length: int32, analysis: PAnalysis, attrs: PLogAttr, 
-            attrs_len: int32){.cdecl, dynlib: lib, importc: "pango_break".}
-proc find_paragraph_boundary*(text: cstring, length: gint, 
-                              paragraph_delimiter_index: Pgint, 
-                              next_paragraph_start: Pgint){.cdecl, dynlib: lib, 
-    importc: "pango_find_paragraph_boundary".}
-proc get_log_attrs*(text: cstring, length: int32, level: int32, 
-                    language: PLanguage, log_attrs: PLogAttr, attrs_len: int32){.
-    cdecl, dynlib: lib, importc: "pango_get_log_attrs".}
-proc TYPE_CONTEXT*(): GType
-proc CONTEXT*(anObject: pointer): PContext
-proc CONTEXT_CLASS*(klass: pointer): PContextClass
-proc IS_CONTEXT*(anObject: pointer): bool
-proc IS_CONTEXT_CLASS*(klass: pointer): bool
-proc GET_CLASS*(obj: PContext): PContextClass
-proc context_get_type*(): GType{.cdecl, dynlib: lib, 
-                                 importc: "pango_context_get_type".}
-proc list_families*(context: PContext, 
-                            families: openarray[ptr PFontFamily]){.cdecl, 
-    dynlib: lib, importc: "pango_context_list_families".}
-proc load_font*(context: PContext, desc: PFontDescription): PFont{.
-    cdecl, dynlib: lib, importc: "pango_context_load_font".}
-proc load_fontset*(context: PContext, desc: PFontDescription, 
-                           language: PLanguage): PFontset{.cdecl, dynlib: lib, 
-    importc: "pango_context_load_fontset".}
-proc get_metrics*(context: PContext, desc: PFontDescription, 
-                          language: PLanguage): PFontMetrics{.cdecl, 
-    dynlib: lib, importc: "pango_context_get_metrics".}
-proc set_font_description*(context: PContext, desc: PFontDescription){.
-    cdecl, dynlib: lib, importc: "pango_context_set_font_description".}
-proc get_font_description*(context: PContext): PFontDescription{.cdecl, 
-    dynlib: lib, importc: "pango_context_get_font_description".}
-proc get_language*(context: PContext): PLanguage{.cdecl, dynlib: lib, 
-    importc: "pango_context_get_language".}
-proc set_language*(context: PContext, language: PLanguage){.cdecl, 
-    dynlib: lib, importc: "pango_context_set_language".}
-proc set_base_dir*(context: PContext, direction: TDirection){.cdecl, 
-    dynlib: lib, importc: "pango_context_set_base_dir".}
-proc get_base_dir*(context: PContext): TDirection{.cdecl, dynlib: lib, 
-    importc: "pango_context_get_base_dir".}
-proc itemize*(context: PContext, text: cstring, start_index: int32, 
-              length: int32, attrs: PAttrList, cached_iter: PAttrIterator): PGList{.
-    cdecl, dynlib: lib, importc: "pango_itemize".}
-proc coverage_new*(): PCoverage{.cdecl, dynlib: lib, 
-                                 importc: "pango_coverage_new".}
-proc reference*(coverage: PCoverage): PCoverage{.cdecl, dynlib: lib, 
-    importc: "pango_coverage_ref".}
-proc unref*(coverage: PCoverage){.cdecl, dynlib: lib, 
-    importc: "pango_coverage_unref".}
-proc copy*(coverage: PCoverage): PCoverage{.cdecl, dynlib: lib, 
-    importc: "pango_coverage_copy".}
-proc get*(coverage: PCoverage, index: int32): TCoverageLevel{.cdecl, 
-    dynlib: lib, importc: "pango_coverage_get".}
-proc set*(coverage: PCoverage, index: int32, level: TCoverageLevel){.
-    cdecl, dynlib: lib, importc: "pango_coverage_set".}
-proc max*(coverage: PCoverage, other: PCoverage){.cdecl, dynlib: lib, 
-    importc: "pango_coverage_max".}
-proc to_bytes*(coverage: PCoverage, bytes: PPguchar, n_bytes: var int32){.
-    cdecl, dynlib: lib, importc: "pango_coverage_to_bytes".}
-proc coverage_from_bytes*(bytes: Pguchar, n_bytes: int32): PCoverage{.cdecl, 
-    dynlib: lib, importc: "pango_coverage_from_bytes".}
-proc TYPE_FONTSET*(): GType
-proc FONTSET*(anObject: pointer): PFontset
-proc IS_FONTSET*(anObject: pointer): bool
-proc fontset_get_type*(): GType{.cdecl, dynlib: lib, 
-                                 importc: "pango_fontset_get_type".}
-proc get_font*(fontset: PFontset, wc: guint): PFont{.cdecl, dynlib: lib, 
-    importc: "pango_fontset_get_font".}
-proc get_metrics*(fontset: PFontset): PFontMetrics{.cdecl, dynlib: lib, 
-    importc: "pango_fontset_get_metrics".}
-const 
-  STYLE_NORMAL* = 0
-  STYLE_OBLIQUE* = 1
-  STYLE_ITALIC* = 2
-  VARIANT_NORMAL* = 0
-  VARIANT_SMALL_CAPS* = 1
-  WEIGHT_ULTRALIGHT* = 200
-  WEIGHT_LIGHT* = 300
-  WEIGHT_NORMAL* = 400
-  WEIGHT_BOLD* = 700
-  WEIGHT_ULTRABOLD* = 800
-  WEIGHT_HEAVY* = 900
-  STRETCH_ULTRA_CONDENSED* = 0
-  STRETCH_EXTRA_CONDENSED* = 1
-  STRETCH_CONDENSED* = 2
-  STRETCH_SEMI_CONDENSED* = 3
-  STRETCH_NORMAL* = 4
-  STRETCH_SEMI_EXPANDED* = 5
-  STRETCH_EXPANDED* = 6
-  STRETCH_EXTRA_EXPANDED* = 7
-  STRETCH_ULTRA_EXPANDED* = 8
-  FONT_MASK_FAMILY* = 1 shl 0
-  FONT_MASK_STYLE* = 1 shl 1
-  FONT_MASK_VARIANT* = 1 shl 2
-  FONT_MASK_WEIGHT* = 1 shl 3
-  FONT_MASK_STRETCH* = 1 shl 4
-  FONT_MASK_SIZE* = 1 shl 5
-  SCALE_XX_SMALL* = 0.578704
-  SCALE_X_SMALL* = 0.644444
-  SCALE_SMALL* = 0.833333
-  SCALE_MEDIUM* = 1.00000
-  SCALE_LARGE* = 1.20000
-  SCALE_X_LARGE* = 1.44000
-  SCALE_XX_LARGE* = 1.72800
-
-proc TYPE_FONT_DESCRIPTION*(): GType
-proc font_description_get_type*(): GType{.cdecl, dynlib: lib, 
-    importc: "pango_font_description_get_type".}
-proc font_description_new*(): PFontDescription{.cdecl, dynlib: lib, 
-    importc: "pango_font_description_new".}
-proc copy*(desc: PFontDescription): PFontDescription{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_copy".}
-proc copy_static*(desc: PFontDescription): PFontDescription{.
-    cdecl, dynlib: lib, importc: "pango_font_description_copy_static".}
-proc hash*(desc: PFontDescription): guint{.cdecl, dynlib: lib, 
-    importc: "pango_font_description_hash".}
-proc equal*(desc1: PFontDescription, desc2: PFontDescription): gboolean{.
-    cdecl, dynlib: lib, importc: "pango_font_description_equal".}
-proc free*(desc: PFontDescription){.cdecl, dynlib: lib, 
-    importc: "pango_font_description_free".}
-proc font_descriptions_free*(descs: var PFontDescription, n_descs: int32){.
-    cdecl, dynlib: lib, importc: "pango_font_descriptions_free".}
-proc set_family*(desc: PFontDescription, family: cstring){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_family".}
-proc set_family_static*(desc: PFontDescription, family: cstring){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_family_static".}
-proc get_family*(desc: PFontDescription): cstring{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_family".}
-proc set_style*(desc: PFontDescription, style: TStyle){.cdecl, 
-    dynlib: lib, importc: "pango_font_description_set_style".}
-proc get_style*(desc: PFontDescription): TStyle{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_style".}
-proc set_variant*(desc: PFontDescription, variant: TVariant){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_variant".}
-proc get_variant*(desc: PFontDescription): TVariant{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_variant".}
-proc set_weight*(desc: PFontDescription, weight: TWeight){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_weight".}
-proc get_weight*(desc: PFontDescription): TWeight{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_weight".}
-proc set_stretch*(desc: PFontDescription, stretch: TStretch){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_stretch".}
-proc get_stretch*(desc: PFontDescription): TStretch{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_stretch".}
-proc set_size*(desc: PFontDescription, size: gint){.cdecl, 
-    dynlib: lib, importc: "pango_font_description_set_size".}
-proc get_size*(desc: PFontDescription): gint{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_size".}
-proc set_absolute_size*(desc: PFontDescription, size: float64){.
-    cdecl, dynlib: lib, importc: "pango_font_description_set_absolute_size".}
-proc get_size_is_absolute*(desc: PFontDescription, 
-    size: float64): gboolean{.cdecl, dynlib: lib, importc: "pango_font_description_get_size_is_absolute".}
-proc get_set_fields*(desc: PFontDescription): TFontMask{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_get_set_fields".}
-proc unset_fields*(desc: PFontDescription, to_unset: TFontMask){.
-    cdecl, dynlib: lib, importc: "pango_font_description_unset_fields".}
-proc merge*(desc: PFontDescription, 
-                             desc_to_merge: PFontDescription, 
-                             replace_existing: gboolean){.cdecl, dynlib: lib, 
-    importc: "pango_font_description_merge".}
-proc merge_static*(desc: PFontDescription, 
-                                    desc_to_merge: PFontDescription, 
-                                    replace_existing: gboolean){.cdecl, 
-    dynlib: lib, importc: "pango_font_description_merge_static".}
-proc better_match*(desc: PFontDescription, 
-                                    old_match: PFontDescription, 
-                                    new_match: PFontDescription): gboolean{.
-    cdecl, dynlib: lib, importc: "pango_font_description_better_match".}
-proc font_description_from_string*(str: cstring): PFontDescription{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_from_string".}
-proc to_string*(desc: PFontDescription): cstring{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_to_string".}
-proc to_filename*(desc: PFontDescription): cstring{.cdecl, 
-    dynlib: lib, importc: "pango_font_description_to_filename".}
-proc TYPE_FONT_METRICS*(): GType
-proc font_metrics_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "pango_font_metrics_get_type".}
-proc reference*(metrics: PFontMetrics): PFontMetrics{.cdecl, dynlib: lib, 
-    importc: "pango_font_metrics_ref".}
-proc unref*(metrics: PFontMetrics){.cdecl, dynlib: lib, 
-    importc: "pango_font_metrics_unref".}
-proc get_ascent*(metrics: PFontMetrics): int32{.cdecl, dynlib: lib, 
-    importc: "pango_font_metrics_get_ascent".}
-proc get_descent*(metrics: PFontMetrics): int32{.cdecl, 
-    dynlib: lib, importc: "pango_font_metrics_get_descent".}
-proc get_approximate_char_width*(metrics: PFontMetrics): int32{.
-    cdecl, dynlib: lib, importc: "pango_font_metrics_get_approximate_char_width".}
-proc get_approximate_digit_width*(metrics: PFontMetrics): int32{.
-    cdecl, dynlib: lib, 
-    importc: "pango_font_metrics_get_approximate_digit_width".}
-proc TYPE_FONT_FAMILY*(): GType
-proc FONT_FAMILY*(anObject: Pointer): PFontFamily
-proc IS_FONT_FAMILY*(anObject: Pointer): bool
-proc font_family_get_type*(): GType{.cdecl, dynlib: lib, 
-                                     importc: "pango_font_family_get_type".}
-proc list_faces*(family: PFontFamily, 
-                             faces: var openarray[ptr PFontFace]){.cdecl, 
-    dynlib: lib, importc: "pango_font_family_list_faces".}
-proc get_name*(family: PFontFamily): cstring{.cdecl, dynlib: lib, 
-    importc: "pango_font_family_get_name".}
-proc TYPE_FONT_FACE*(): GType
-proc FONT_FACE*(anObject: pointer): PFontFace
-proc IS_FONT_FACE*(anObject: pointer): bool
-proc font_face_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "pango_font_face_get_type".}
-proc describe*(face: PFontFace): PFontDescription{.cdecl, dynlib: lib, 
-    importc: "pango_font_face_describe".}
-proc get_face_name*(face: PFontFace): cstring{.cdecl, dynlib: lib, 
-    importc: "pango_font_face_get_face_name".}
-proc TYPE_FONT*(): GType
-proc FONT*(anObject: pointer): PFont
-proc IS_FONT*(anObject: pointer): bool
-proc font_get_type*(): GType{.cdecl, dynlib: lib, importc: "pango_font_get_type".}
-proc describe*(font: PFont): PFontDescription{.cdecl, dynlib: lib, 
-    importc: "pango_font_describe".}
-proc get_coverage*(font: PFont, language: PLanguage): PCoverage{.cdecl, 
-    dynlib: lib, importc: "pango_font_get_coverage".}
-proc find_shaper*(font: PFont, language: PLanguage, ch: guint32): PEngineShape{.
-    cdecl, dynlib: lib, importc: "pango_font_find_shaper".}
-proc get_metrics*(font: PFont, language: PLanguage): PFontMetrics{.cdecl, 
-    dynlib: lib, importc: "pango_font_get_metrics".}
-proc get_glyph_extents*(font: PFont, glyph: TGlyph, ink_rect: PRectangle, 
-                             logical_rect: PRectangle){.cdecl, dynlib: lib, 
-    importc: "pango_font_get_glyph_extents".}
-proc TYPE_FONT_MAP*(): GType
-proc FONT_MAP*(anObject: pointer): PFontMap
-proc IS_FONT_MAP*(anObject: pointer): bool
-proc font_map_get_type*(): GType{.cdecl, dynlib: lib, 
-                                  importc: "pango_font_map_get_type".}
-proc load_font*(fontmap: PFontMap, context: PContext, 
-                         desc: PFontDescription): PFont{.cdecl, dynlib: lib, 
-    importc: "pango_font_map_load_font".}
-proc load_fontset*(fontmap: PFontMap, context: PContext, 
-                            desc: PFontDescription, language: PLanguage): PFontset{.
-    cdecl, dynlib: lib, importc: "pango_font_map_load_fontset".}
-proc list_families*(fontmap: PFontMap, 
-                             families: var openarray[ptr PFontFamily]){.cdecl, 
-    dynlib: lib, importc: "pango_font_map_list_families".}
-const 
-  bm_TPangoGlyphVisAttr_is_cluster_start* = 0x0001'i16
-  bp_TPangoGlyphVisAttr_is_cluster_start* = 0'i16
-
-proc is_cluster_start*(a: PGlyphVisAttr): guint
-proc set_is_cluster_start*(a: PGlyphVisAttr, `is_cluster_start`: guint)
-proc TYPE_GLYPH_STRING*(): GType
-proc glyph_string_new*(): PGlyphString{.cdecl, dynlib: lib, 
-                                        importc: "pango_glyph_string_new".}
-proc glyph_string_set_size*(`string`: PGlyphString, new_len: gint){.cdecl, 
-    dynlib: lib, importc: "pango_glyph_string_set_size".}
-proc glyph_string_get_type*(): GType{.cdecl, dynlib: lib, 
-                                      importc: "pango_glyph_string_get_type".}
-proc glyph_string_copy*(`string`: PGlyphString): PGlyphString{.cdecl, 
-    dynlib: lib, importc: "pango_glyph_string_copy".}
-proc glyph_string_free*(`string`: PGlyphString){.cdecl, dynlib: lib, 
-    importc: "pango_glyph_string_free".}
-proc extents*(glyphs: PGlyphString, font: PFont, 
-                           ink_rect: PRectangle, logical_rect: PRectangle){.
-    cdecl, dynlib: lib, importc: "pango_glyph_string_extents".}
-proc extents_range*(glyphs: PGlyphString, start: int32, 
-                                 theEnd: int32, font: PFont, 
-                                 ink_rect: PRectangle, logical_rect: PRectangle){.
-    cdecl, dynlib: lib, importc: "pango_glyph_string_extents_range".}
-proc get_logical_widths*(glyphs: PGlyphString, text: cstring, 
-                                      length: int32, embedding_level: int32, 
-                                      logical_widths: var int32){.cdecl, 
-    dynlib: lib, importc: "pango_glyph_string_get_logical_widths".}
-proc index_to_x*(glyphs: PGlyphString, text: cstring, 
-                              length: int32, analysis: PAnalysis, index: int32, 
-                              trailing: gboolean, x_pos: var int32){.cdecl, 
-    dynlib: lib, importc: "pango_glyph_string_index_to_x".}
-proc x_to_index*(glyphs: PGlyphString, text: cstring, 
-                              length: int32, analysis: PAnalysis, x_pos: int32, 
-                              index, trailing: var int32){.cdecl, dynlib: lib, 
-    importc: "pango_glyph_string_x_to_index".}
-proc shape*(text: cstring, length: gint, analysis: PAnalysis, 
-            glyphs: PGlyphString){.cdecl, dynlib: lib, importc: "pango_shape".}
-proc reorder_items*(logical_items: PGList): PGList{.cdecl, dynlib: lib, 
-    importc: "pango_reorder_items".}
-proc item_new*(): PItem{.cdecl, dynlib: lib, importc: "pango_item_new".}
-proc copy*(item: PItem): PItem{.cdecl, dynlib: lib, 
-                                     importc: "pango_item_copy".}
-proc free*(item: PItem){.cdecl, dynlib: lib, importc: "pango_item_free".}
-proc split*(orig: PItem, split_index: int32, split_offset: int32): PItem{.
-    cdecl, dynlib: lib, importc: "pango_item_split".}
-proc TYPE_LAYOUT*(): GType
-proc LAYOUT*(anObject: pointer): PLayout
-proc LAYOUT_CLASS*(klass: pointer): PLayoutClass
-proc IS_LAYOUT*(anObject: pointer): bool
-proc IS_LAYOUT_CLASS*(klass: pointer): bool
-proc GET_CLASS*(obj: PLayout): PLayoutClass
-proc layout_get_type*(): GType{.cdecl, dynlib: lib, 
-                                importc: "pango_layout_get_type".}
-proc layout_new*(context: PContext): PLayout{.cdecl, dynlib: lib, 
-    importc: "pango_layout_new".}
-proc copy*(src: PLayout): PLayout{.cdecl, dynlib: lib, 
-    importc: "pango_layout_copy".}
-proc get_context*(layout: PLayout): PContext{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_context".}
-proc set_attributes*(layout: PLayout, attrs: PAttrList){.cdecl, 
-    dynlib: lib, importc: "pango_layout_set_attributes".}
-proc get_attributes*(layout: PLayout): PAttrList{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_attributes".}
-proc set_text*(layout: PLayout, text: cstring, length: int32){.cdecl, 
-    dynlib: lib, importc: "pango_layout_set_text".}
-proc get_text*(layout: PLayout): cstring{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_text".}
-proc set_markup*(layout: PLayout, markup: cstring, length: int32){.cdecl, 
-    dynlib: lib, importc: "pango_layout_set_markup".}
-proc set_markup*(layout: PLayout, markup: cstring, 
-                                   length: int32, accel_marker: gunichar, 
-                                   accel_char: Pgunichar){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_markup_with_accel".}
-proc set_font_description*(layout: PLayout, desc: PFontDescription){.
-    cdecl, dynlib: lib, importc: "pango_layout_set_font_description".}
-proc set_width*(layout: PLayout, width: int32){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_width".}
-proc get_width*(layout: PLayout): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_width".}
-proc set_wrap*(layout: PLayout, wrap: TWrapMode){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_wrap".}
-proc get_wrap*(layout: PLayout): TWrapMode{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_wrap".}
-proc set_indent*(layout: PLayout, indent: int32){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_indent".}
-proc get_indent*(layout: PLayout): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_indent".}
-proc set_spacing*(layout: PLayout, spacing: int32){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_spacing".}
-proc get_spacing*(layout: PLayout): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_spacing".}
-proc set_justify*(layout: PLayout, justify: gboolean){.cdecl, 
-    dynlib: lib, importc: "pango_layout_set_justify".}
-proc get_justify*(layout: PLayout): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_justify".}
-proc set_alignment*(layout: PLayout, alignment: TAlignment){.cdecl, 
-    dynlib: lib, importc: "pango_layout_set_alignment".}
-proc get_alignment*(layout: PLayout): TAlignment{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_alignment".}
-proc set_tabs*(layout: PLayout, tabs: PTabArray){.cdecl, dynlib: lib, 
-    importc: "pango_layout_set_tabs".}
-proc get_tabs*(layout: PLayout): PTabArray{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_tabs".}
-proc set_single_paragraph_mode*(layout: PLayout, setting: gboolean){.
-    cdecl, dynlib: lib, importc: "pango_layout_set_single_paragraph_mode".}
-proc get_single_paragraph_mode*(layout: PLayout): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_layout_get_single_paragraph_mode".}
-proc context_changed*(layout: PLayout){.cdecl, dynlib: lib, 
-    importc: "pango_layout_context_changed".}
-proc get_log_attrs*(layout: PLayout, attrs: var PLogAttr, n_attrs: Pgint){.
-    cdecl, dynlib: lib, importc: "pango_layout_get_log_attrs".}
-proc index_to_pos*(layout: PLayout, index: int32, pos: PRectangle){.
-    cdecl, dynlib: lib, importc: "pango_layout_index_to_pos".}
-proc get_cursor_pos*(layout: PLayout, index: int32, 
-                            strong_pos: PRectangle, weak_pos: PRectangle){.
-    cdecl, dynlib: lib, importc: "pango_layout_get_cursor_pos".}
-proc move_cursor_visually*(layout: PLayout, strong: gboolean, 
-                                  old_index: int32, old_trailing: int32, 
-                                  direction: int32, 
-                                  new_index, new_trailing: var int32){.cdecl, 
-    dynlib: lib, importc: "pango_layout_move_cursor_visually".}
-proc xy_to_index*(layout: PLayout, x: int32, y: int32, 
-                         index, trailing: var int32): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_layout_xy_to_index".}
-proc get_extents*(layout: PLayout, ink_rect: PRectangle, 
-                         logical_rect: PRectangle){.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_extents".}
-proc get_pixel_extents*(layout: PLayout, ink_rect: PRectangle, 
-                               logical_rect: PRectangle){.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_pixel_extents".}
-proc get_size*(layout: PLayout, width: var int32, height: var int32){.
-    cdecl, dynlib: lib, importc: "pango_layout_get_size".}
-proc get_pixel_size*(layout: PLayout, width: var int32, height: var int32){.
-    cdecl, dynlib: lib, importc: "pango_layout_get_pixel_size".}
-proc get_line_count*(layout: PLayout): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_line_count".}
-proc get_line*(layout: PLayout, line: int32): PLayoutLine{.cdecl, 
-    dynlib: lib, importc: "pango_layout_get_line".}
-proc get_lines*(layout: PLayout): PGSList{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_lines".}
-proc reference*(line: PLayoutLine){.cdecl, dynlib: lib, 
-    importc: "pango_layout_line_ref".}
-proc unref*(line: PLayoutLine){.cdecl, dynlib: lib, 
-    importc: "pango_layout_line_unref".}
-proc x_to_index*(line: PLayoutLine, x_pos: int32, index: var int32, 
-                             trailing: var int32): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_line_x_to_index".}
-proc index_to_x*(line: PLayoutLine, index: int32, 
-                             trailing: gboolean, x_pos: var int32){.cdecl, 
-    dynlib: lib, importc: "pango_layout_line_index_to_x".}
-proc get_extents*(line: PLayoutLine, ink_rect: PRectangle, 
-                              logical_rect: PRectangle){.cdecl, dynlib: lib, 
-    importc: "pango_layout_line_get_extents".}
-proc get_pixel_extents*(layout_line: PLayoutLine, 
-                                    ink_rect: PRectangle, 
-                                    logical_rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "pango_layout_line_get_pixel_extents".}
-proc get_iter*(layout: PLayout): PLayoutIter{.cdecl, dynlib: lib, 
-    importc: "pango_layout_get_iter".}
-proc free*(iter: PLayoutIter){.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_free".}
-proc get_index*(iter: PLayoutIter): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_index".}
-proc get_run*(iter: PLayoutIter): PLayoutRun{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_run".}
-proc get_line*(iter: PLayoutIter): PLayoutLine{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_line".}
-proc at_last_line*(iter: PLayoutIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_at_last_line".}
-proc next_char*(iter: PLayoutIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_next_char".}
-proc next_cluster*(iter: PLayoutIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_next_cluster".}
-proc next_run*(iter: PLayoutIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_next_run".}
-proc next_line*(iter: PLayoutIter): gboolean{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_next_line".}
-proc get_char_extents*(iter: PLayoutIter, logical_rect: PRectangle){.
-    cdecl, dynlib: lib, importc: "pango_layout_iter_get_char_extents".}
-proc get_cluster_extents*(iter: PLayoutIter, ink_rect: PRectangle, 
-                                      logical_rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "pango_layout_iter_get_cluster_extents".}
-proc get_run_extents*(iter: PLayoutIter, ink_rect: PRectangle, 
-                                  logical_rect: PRectangle){.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_run_extents".}
-proc get_line_extents*(iter: PLayoutIter, ink_rect: PRectangle, 
-                                   logical_rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "pango_layout_iter_get_line_extents".}
-proc get_line_yrange*(iter: PLayoutIter, y0: var int32, 
-                                  y1: var int32){.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_line_yrange".}
-proc get_layout_extents*(iter: PLayoutIter, ink_rect: PRectangle, 
-                                     logical_rect: PRectangle){.cdecl, 
-    dynlib: lib, importc: "pango_layout_iter_get_layout_extents".}
-proc get_baseline*(iter: PLayoutIter): int32{.cdecl, dynlib: lib, 
-    importc: "pango_layout_iter_get_baseline".}
-proc TYPE_TAB_ARRAY*(): GType
-proc tab_array_new*(initial_size: gint, positions_in_pixels: gboolean): PTabArray{.
-    cdecl, dynlib: lib, importc: "pango_tab_array_new".}
-proc tab_array_get_type*(): GType{.cdecl, dynlib: lib, 
-                                   importc: "pango_tab_array_get_type".}
-proc copy*(src: PTabArray): PTabArray{.cdecl, dynlib: lib, 
-    importc: "pango_tab_array_copy".}
-proc free*(tab_array: PTabArray){.cdecl, dynlib: lib, 
-    importc: "pango_tab_array_free".}
-proc get_size*(tab_array: PTabArray): gint{.cdecl, dynlib: lib, 
-    importc: "pango_tab_array_get_size".}
-proc resize*(tab_array: PTabArray, new_size: gint){.cdecl, 
-    dynlib: lib, importc: "pango_tab_array_resize".}
-proc set_tab*(tab_array: PTabArray, tab_index: gint, 
-                        alignment: TTabAlign, location: gint){.cdecl, 
-    dynlib: lib, importc: "pango_tab_array_set_tab".}
-proc get_tab*(tab_array: PTabArray, tab_index: gint, 
-                        alignment: PTabAlign, location: Pgint){.cdecl, 
-    dynlib: lib, importc: "pango_tab_array_get_tab".}
-proc get_positions_in_pixels*(tab_array: PTabArray): gboolean{.cdecl, 
-    dynlib: lib, importc: "pango_tab_array_get_positions_in_pixels".}
-proc ASCENT*(rect: TRectangle): int32 = 
-  result = - int(rect.y)
-
-proc DESCENT*(rect: TRectangle): int32 = 
-  result = int(rect.y) + int(rect.height)
-
-proc LBEARING*(rect: TRectangle): int32 = 
-  result = rect.x
-
-proc RBEARING*(rect: TRectangle): int32 = 
-  result = (rect.x) + (rect.width)
-
-proc TYPE_LANGUAGE*(): GType = 
-  result = language_get_type()
-
-proc to_string*(language: PLanguage): cstring = 
-  result = cast[cstring](language)
-
-proc PIXELS*(d: int): int = 
-  if d >= 0: 
-    result = (d + (SCALE div 2)) div SCALE
-  else: 
-    result = (d - (SCALE div 2)) div SCALE
-
-proc TYPE_COLOR*(): GType = 
-  result = color_get_type()
-
-proc TYPE_ATTR_LIST*(): GType = 
-  result = attr_list_get_type()
-
-proc is_line_break*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_line_break) shr
-      bp_TPangoLogAttr_is_line_break
-
-proc set_is_line_break*(a: PLogAttr, `is_line_break`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_line_break` shl bp_TPangoLogAttr_is_line_break) and
-      bm_TPangoLogAttr_is_line_break)
-
-proc is_mandatory_break*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_mandatory_break) shr
-      bp_TPangoLogAttr_is_mandatory_break
-
-proc set_is_mandatory_break*(a: PLogAttr, `is_mandatory_break`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_mandatory_break` shl bp_TPangoLogAttr_is_mandatory_break) and
-      bm_TPangoLogAttr_is_mandatory_break)
-
-proc is_char_break*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_char_break) shr
-      bp_TPangoLogAttr_is_char_break
-
-proc set_is_char_break*(a: PLogAttr, `is_char_break`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_char_break` shl bp_TPangoLogAttr_is_char_break) and
-      bm_TPangoLogAttr_is_char_break)
-
-proc is_white*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_white) shr
-      bp_TPangoLogAttr_is_white
-
-proc set_is_white*(a: PLogAttr, `is_white`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_white` shl bp_TPangoLogAttr_is_white) and
-      bm_TPangoLogAttr_is_white)
-
-proc is_cursor_position*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_cursor_position) shr
-      bp_TPangoLogAttr_is_cursor_position
-
-proc set_is_cursor_position*(a: PLogAttr, `is_cursor_position`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_cursor_position` shl bp_TPangoLogAttr_is_cursor_position) and
-      bm_TPangoLogAttr_is_cursor_position)
-
-proc is_word_start*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_word_start) shr
-      bp_TPangoLogAttr_is_word_start
-
-proc set_is_word_start*(a: PLogAttr, `is_word_start`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_word_start` shl bp_TPangoLogAttr_is_word_start) and
-      bm_TPangoLogAttr_is_word_start)
-
-proc is_word_end*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_word_end) shr
-      bp_TPangoLogAttr_is_word_end
-
-proc set_is_word_end*(a: PLogAttr, `is_word_end`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_word_end` shl bp_TPangoLogAttr_is_word_end) and
-      bm_TPangoLogAttr_is_word_end)
-
-proc is_sentence_boundary*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_boundary) shr
-      bp_TPangoLogAttr_is_sentence_boundary
-
-proc set_is_sentence_boundary*(a: PLogAttr, `is_sentence_boundary`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_boundary` shl bp_TPangoLogAttr_is_sentence_boundary) and
-      bm_TPangoLogAttr_is_sentence_boundary)
-
-proc is_sentence_start*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_start) shr
-      bp_TPangoLogAttr_is_sentence_start
-
-proc set_is_sentence_start*(a: PLogAttr, `is_sentence_start`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_start` shl bp_TPangoLogAttr_is_sentence_start) and
-      bm_TPangoLogAttr_is_sentence_start)
-
-proc is_sentence_end*(a: PLogAttr): guint = 
-  result = (a.flag0 and bm_TPangoLogAttr_is_sentence_end) shr
-      bp_TPangoLogAttr_is_sentence_end
-
-proc set_is_sentence_end*(a: PLogAttr, `is_sentence_end`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_sentence_end` shl bp_TPangoLogAttr_is_sentence_end) and
-      bm_TPangoLogAttr_is_sentence_end)
-
-proc TYPE_CONTEXT*(): GType = 
-  result = context_get_type()
-
-proc CONTEXT*(anObject: pointer): PContext = 
-  result = cast[PContext](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_CONTEXT()))
-
-proc CONTEXT_CLASS*(klass: pointer): PContextClass = 
-  result = cast[PContextClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_CONTEXT()))
-
-proc IS_CONTEXT*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_CONTEXT())
-
-proc IS_CONTEXT_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_CONTEXT())
-
-proc GET_CLASS*(obj: PContext): PContextClass = 
-  result = cast[PContextClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_CONTEXT()))
-
-proc TYPE_FONTSET*(): GType = 
-  result = fontset_get_type()
-
-proc FONTSET*(anObject: pointer): PFontset = 
-  result = cast[PFontset](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_FONTSET()))
-
-proc IS_FONTSET*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONTSET())
-
-proc FONTSET_CLASS*(klass: pointer): PFontsetClass = 
-  result = cast[PFontsetClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_FONTSET()))
-
-proc IS_FONTSET_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_FONTSET())
-
-proc GET_CLASS*(obj: PFontset): PFontsetClass = 
-  result = cast[PFontsetClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_FONTSET()))
-
-proc fontset_simple_get_type(): GType{.importc: "pango_fontset_simple_get_type", 
-                                       cdecl, dynlib: lib.}
-proc TYPE_FONTSET_SIMPLE*(): GType = 
-  result = fontset_simple_get_type()
-
-proc FONTSET_SIMPLE*(anObject: pointer): PFontsetSimple = 
-  result = cast[PFontsetSimple](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_FONTSET_SIMPLE()))
-
-proc IS_FONTSET_SIMPLE*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONTSET_SIMPLE())
-
-proc TYPE_FONT_DESCRIPTION*(): GType = 
-  result = font_description_get_type()
-
-proc TYPE_FONT_METRICS*(): GType = 
-  result = font_metrics_get_type()
-
-proc TYPE_FONT_FAMILY*(): GType = 
-  result = font_family_get_type()
-
-proc FONT_FAMILY*(anObject: pointer): PFontFamily = 
-  result = cast[PFontFamily](G_TYPE_CHECK_INSTANCE_CAST(anObject, 
-      TYPE_FONT_FAMILY()))
-
-proc IS_FONT_FAMILY*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONT_FAMILY())
-
-proc FONT_FAMILY_CLASS*(klass: Pointer): PFontFamilyClass = 
-  result = cast[PFontFamilyClass](G_TYPE_CHECK_CLASS_CAST(klass, 
-      TYPE_FONT_FAMILY()))
-
-proc IS_FONT_FAMILY_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_FONT_FAMILY())
-
-proc GET_CLASS*(obj: PFontFamily): PFontFamilyClass = 
-  result = cast[PFontFamilyClass](G_TYPE_INSTANCE_GET_CLASS(obj, 
-      TYPE_FONT_FAMILY()))
-
-proc TYPE_FONT_FACE*(): GType = 
-  result = font_face_get_type()
-
-proc FONT_FACE*(anObject: Pointer): PFontFace = 
-  result = cast[PFontFace](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_FONT_FACE()))
-
-proc IS_FONT_FACE*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONT_FACE())
-
-proc FONT_FACE_CLASS*(klass: Pointer): PFontFaceClass = 
-  result = cast[PFontFaceClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_FONT_FACE()))
-
-proc IS_FONT_FACE_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_FONT_FACE())
-
-proc FONT_FACE_GET_CLASS*(obj: Pointer): PFontFaceClass = 
-  result = cast[PFontFaceClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_FONT_FACE()))
-
-proc TYPE_FONT*(): GType = 
-  result = font_get_type()
-
-proc FONT*(anObject: Pointer): PFont = 
-  result = cast[PFont](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_FONT()))
-
-proc IS_FONT*(anObject: Pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONT())
-
-proc FONT_CLASS*(klass: Pointer): PFontClass = 
-  result = cast[PFontClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_FONT()))
-
-proc IS_FONT_CLASS*(klass: Pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_FONT())
-
-proc GET_CLASS*(obj: PFont): PFontClass = 
-  result = cast[PFontClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_FONT()))
-
-proc TYPE_FONT_MAP*(): GType = 
-  result = font_map_get_type()
-
-proc FONT_MAP*(anObject: pointer): PFontmap = 
-  result = cast[PFontmap](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_FONT_MAP()))
-
-proc IS_FONT_MAP*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_FONT_MAP())
-
-proc FONT_MAP_CLASS*(klass: pointer): PFontMapClass = 
-  result = cast[PFontMapClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_FONT_MAP()))
-
-proc IS_FONT_MAP_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_FONT_MAP())
-
-proc GET_CLASS*(obj: PFontMap): PFontMapClass = 
-  result = cast[PFontMapClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_FONT_MAP()))
-
-proc is_cluster_start*(a: PGlyphVisAttr): guint = 
-  result = (a.flag0 and bm_TPangoGlyphVisAttr_is_cluster_start) shr
-      bp_TPangoGlyphVisAttr_is_cluster_start
-
-proc set_is_cluster_start*(a: PGlyphVisAttr, `is_cluster_start`: guint) = 
-  a.flag0 = a.flag0 or
-      (int16(`is_cluster_start` shl bp_TPangoGlyphVisAttr_is_cluster_start) and
-      bm_TPangoGlyphVisAttr_is_cluster_start)
-
-proc TYPE_GLYPH_STRING*(): GType = 
-  result = glyph_string_get_type()
-
-proc TYPE_LAYOUT*(): GType = 
-  result = layout_get_type()
-
-proc LAYOUT*(anObject: pointer): PLayout = 
-  result = cast[PLayout](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_LAYOUT()))
-
-proc LAYOUT_CLASS*(klass: pointer): PLayoutClass = 
-  result = cast[PLayoutClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_LAYOUT()))
-
-proc IS_LAYOUT*(anObject: pointer): bool = 
-  result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_LAYOUT())
-
-proc IS_LAYOUT_CLASS*(klass: pointer): bool = 
-  result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_LAYOUT())
-
-proc GET_CLASS*(obj: PLayout): PLayoutClass = 
-  result = cast[PLayoutClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_LAYOUT()))
-
-proc TYPE_TAB_ARRAY*(): GType = 
-  result = tab_array_get_type()
diff --git a/lib/wrappers/iup.nim b/lib/wrappers/iup.nim
deleted file mode 100755
index c37d31047..000000000
--- a/lib/wrappers/iup.nim
+++ /dev/null
@@ -1,945 +0,0 @@
-#
-#    Binding for the IUP GUI toolkit
-#       (c) 2010 Andreas Rumpf 
-#    C header files translated by hand
-#    Licence of IUP follows:
-
-
-# ****************************************************************************
-# Copyright (C) 1994-2009 Tecgraf, PUC-Rio.
-# 
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-# ****************************************************************************
-
-{.deadCodeElim: on.}
-
-when defined(windows): 
-  const dllname = "iup(30|27|26|25|24).dll"
-elif defined(macosx):
-  const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).dylib"
-else: 
-  const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).so.1"
-
-const
-  IUP_NAME* = "IUP - Portable User Interface"
-  IUP_COPYRIGHT* = "Copyright (C) 1994-2009 Tecgraf, PUC-Rio."
-  IUP_DESCRIPTION* = "Portable toolkit for building graphical user interfaces."
-  constIUP_VERSION* = "3.0"
-  constIUP_VERSION_NUMBER* = 300000
-  constIUP_VERSION_DATE* = "2009/07/18"
-
-type
-  Ihandle {.pure.} = object
-  PIhandle* = ptr Ihandle
-
-  Icallback* = proc (arg: PIhandle): cint {.cdecl.}
-
-#                      pre-definided dialogs
-proc FileDlg*: PIhandle {.importc: "IupFileDlg", dynlib: dllname, cdecl.}
-proc MessageDlg*: PIhandle {.importc: "IupMessageDlg", dynlib: dllname, cdecl.}
-proc ColorDlg*: PIhandle {.importc: "IupColorDlg", dynlib: dllname, cdecl.}
-proc FontDlg*: PIhandle {.importc: "IupFontDlg", dynlib: dllname, cdecl.}
-
-proc GetFile*(arq: cstring): cint {.
-  importc: "IupGetFile", dynlib: dllname, cdecl.}
-proc Message*(title, msg: cstring) {.
-  importc: "IupMessage", dynlib: dllname, cdecl.}
-proc Messagef*(title, format: cstring) {.
-  importc: "IupMessagef", dynlib: dllname, cdecl, varargs.}
-proc Alarm*(title, msg, b1, b2, b3: cstring): cint {.
-  importc: "IupAlarm", dynlib: dllname, cdecl.}
-proc Scanf*(format: cstring): cint {.
-  importc: "IupScanf", dynlib: dllname, cdecl, varargs.}
-proc ListDialog*(theType: cint, title: cstring, size: cint, 
-                 list: cstringArray, op, max_col, max_lin: cint, 
-                 marks: ptr cint): cint {.
-                 importc: "IupListDialog", dynlib: dllname, cdecl.}
-proc GetText*(title, text: cstring): cint {.
-  importc: "IupGetText", dynlib: dllname, cdecl.}
-proc GetColor*(x, y: cint, r, g, b: var byte): cint {.
-  importc: "IupGetColor", dynlib: dllname, cdecl.}
-
-type
-  Iparamcb* = proc (dialog: PIhandle, param_index: cint, 
-                    user_data: pointer): cint {.cdecl.}
-
-proc GetParam*(title: cstring, action: Iparamcb, user_data: pointer, 
-               format: cstring): cint {.
-               importc: "IupGetParam", cdecl, varargs, dynlib: dllname.}
-proc GetParamv*(title: cstring, action: Iparamcb, user_data: pointer, 
-                format: cstring, param_count, param_extra: cint, 
-                param_data: pointer): cint {.
-                importc: "IupGetParamv", cdecl, dynlib: dllname.}
-
-
-#                      Functions
-
-proc Open*(argc: ptr cint, argv: ptr cstringArray): cint {.
-  importc: "IupOpen", cdecl, dynlib: dllname.}
-proc Close*() {.importc: "IupClose", cdecl, dynlib: dllname.}
-proc ImageLibOpen*() {.importc: "IupImageLibOpen", cdecl, dynlib: dllname.}
-
-proc MainLoop*(): cint {.importc: "IupMainLoop", cdecl, dynlib: dllname.}
-proc LoopStep*(): cint {.importc: "IupLoopStep", cdecl, dynlib: dllname.}
-proc MainLoopLevel*(): cint {.importc: "IupMainLoopLevel", cdecl, dynlib: dllname.}
-proc Flush*() {.importc: "IupFlush", cdecl, dynlib: dllname.}
-proc ExitLoop*() {.importc: "IupExitLoop", cdecl, dynlib: dllname.}
-
-proc Update*(ih: PIhandle) {.importc: "IupUpdate", cdecl, dynlib: dllname.}
-proc UpdateChildren*(ih: PIhandle) {.importc: "IupUpdateChildren", cdecl, dynlib: dllname.}
-proc Redraw*(ih: PIhandle, children: cint) {.importc: "IupRedraw", cdecl, dynlib: dllname.}
-proc Refresh*(ih: PIhandle) {.importc: "IupRefresh", cdecl, dynlib: dllname.}
-
-proc MapFont*(iupfont: cstring): cstring {.importc: "IupMapFont", cdecl, dynlib: dllname.}
-proc UnMapFont*(driverfont: cstring): cstring {.importc: "IupUnMapFont", cdecl, dynlib: dllname.}
-proc Help*(url: cstring): cint {.importc: "IupHelp", cdecl, dynlib: dllname.}
-proc Load*(filename: cstring): cstring {.importc: "IupLoad", cdecl, dynlib: dllname.}
-
-proc IupVersion*(): cstring {.importc: "IupVersion", cdecl, dynlib: dllname.}
-proc IupVersionDate*(): cstring {.importc: "IupVersionDate", cdecl, dynlib: dllname.}
-proc IupVersionNumber*(): cint {.importc: "IupVersionNumber", cdecl, dynlib: dllname.}
-proc SetLanguage*(lng: cstring) {.importc: "IupSetLanguage", cdecl, dynlib: dllname.}
-proc GetLanguage*(): cstring {.importc: "IupGetLanguage", cdecl, dynlib: dllname.}
-
-proc Destroy*(ih: PIhandle) {.importc: "IupDestroy", cdecl, dynlib: dllname.}
-proc Detach*(child: PIhandle) {.importc: "IupDetach", cdecl, dynlib: dllname.}
-proc Append*(ih, child: PIhandle): PIhandle {.
-  importc: "IupAppend", cdecl, dynlib: dllname.}
-proc Insert*(ih, ref_child, child: PIhandle): PIhandle {.
-  importc: "IupInsert", cdecl, dynlib: dllname.}
-proc GetChild*(ih: PIhandle, pos: cint): PIhandle {.
-  importc: "IupGetChild", cdecl, dynlib: dllname.}
-proc GetChildPos*(ih, child: PIhandle): cint {.
-  importc: "IupGetChildPos", cdecl, dynlib: dllname.}
-proc GetChildCount*(ih: PIhandle): cint {.
-  importc: "IupGetChildCount", cdecl, dynlib: dllname.}
-proc GetNextChild*(ih, child: PIhandle): PIhandle {.
-  importc: "IupGetNextChild", cdecl, dynlib: dllname.}
-proc GetBrother*(ih: PIhandle): PIhandle {.
-  importc: "IupGetBrother", cdecl, dynlib: dllname.}
-proc GetParent*(ih: PIhandle): PIhandle {.
-  importc: "IupGetParent", cdecl, dynlib: dllname.}
-proc GetDialog*(ih: PIhandle): PIhandle {.
-  importc: "IupGetDialog", cdecl, dynlib: dllname.}
-proc GetDialogChild*(ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupGetDialogChild", cdecl, dynlib: dllname.}
-proc Reparent*(ih, new_parent: PIhandle): cint {.
-  importc: "IupReparent", cdecl, dynlib: dllname.}
-
-proc Popup*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupPopup", cdecl, dynlib: dllname.}
-proc Show*(ih: PIhandle): cint {.
-  importc: "IupShow", cdecl, dynlib: dllname.}
-proc ShowXY*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupShowXY", cdecl, dynlib: dllname.}
-proc Hide*(ih: PIhandle): cint {.
-  importc: "IupHide", cdecl, dynlib: dllname.}
-proc Map*(ih: PIhandle): cint {.
-  importc: "IupMap", cdecl, dynlib: dllname.}
-proc Unmap*(ih: PIhandle) {.
-  importc: "IupUnmap", cdecl, dynlib: dllname.}
-
-proc SetAttribute*(ih: PIhandle, name, value: cstring) {.
-  importc: "IupSetAttribute", cdecl, dynlib: dllname.}
-proc StoreAttribute*(ih: PIhandle, name, value: cstring) {.
-  importc: "IupStoreAttribute", cdecl, dynlib: dllname.}
-proc SetAttributes*(ih: PIhandle, str: cstring): PIhandle {.
-  importc: "IupSetAttributes", cdecl, dynlib: dllname.}
-proc GetAttribute*(ih: PIhandle, name: cstring): cstring {.
-  importc: "IupGetAttribute", cdecl, dynlib: dllname.}
-proc GetAttributes*(ih: PIhandle): cstring {.
-  importc: "IupGetAttributes", cdecl, dynlib: dllname.}
-proc GetInt*(ih: PIhandle, name: cstring): cint {.
-  importc: "IupGetInt", cdecl, dynlib: dllname.}
-proc GetInt2*(ih: PIhandle, name: cstring): cint {.
-  importc: "IupGetInt2", cdecl, dynlib: dllname.}
-proc GetIntInt*(ih: PIhandle, name: cstring, i1, i2: var cint): cint {.
-  importc: "IupGetIntInt", cdecl, dynlib: dllname.}
-proc GetFloat*(ih: PIhandle, name: cstring): cfloat {.
-  importc: "IupGetFloat", cdecl, dynlib: dllname.}
-proc SetfAttribute*(ih: PIhandle, name, format: cstring) {.
-  importc: "IupSetfAttribute", cdecl, dynlib: dllname, varargs.}
-proc GetAllAttributes*(ih: PIhandle, names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllAttributes", cdecl, dynlib: dllname.}
-proc SetAtt*(handle_name: cstring, ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupSetAtt", cdecl, dynlib: dllname, varargs.}
-
-proc SetGlobal*(name, value: cstring) {.
-  importc: "IupSetGlobal", cdecl, dynlib: dllname.}
-proc StoreGlobal*(name, value: cstring) {.
-  importc: "IupStoreGlobal", cdecl, dynlib: dllname.}
-proc GetGlobal*(name: cstring): cstring {.
-  importc: "IupGetGlobal", cdecl, dynlib: dllname.}
-
-proc SetFocus*(ih: PIhandle): PIhandle {.
-  importc: "IupSetFocus", cdecl, dynlib: dllname.}
-proc GetFocus*(): PIhandle {.
-  importc: "IupGetFocus", cdecl, dynlib: dllname.}
-proc PreviousField*(ih: PIhandle): PIhandle {.
-  importc: "IupPreviousField", cdecl, dynlib: dllname.}
-proc NextField*(ih: PIhandle): PIhandle {.
-  importc: "IupNextField", cdecl, dynlib: dllname.}
-
-proc GetCallback*(ih: PIhandle, name: cstring): Icallback {.
-  importc: "IupGetCallback", cdecl, dynlib: dllname.}
-proc SetCallback*(ih: PIhandle, name: cstring, func: Icallback): Icallback {.
-  importc: "IupSetCallback", cdecl, dynlib: dllname.}
-proc SetCallbacks*(ih: PIhandle, name: cstring, func: Icallback): PIhandle {.
-  importc: "IupSetCallbacks", cdecl, dynlib: dllname, varargs.}
-
-proc GetFunction*(name: cstring): Icallback {.
-  importc: "IupGetFunction", cdecl, dynlib: dllname.}
-proc SetFunction*(name: cstring, func: Icallback): Icallback {.
-  importc: "IupSetFunction", cdecl, dynlib: dllname.}
-proc GetActionName*(): cstring {.
-  importc: "IupGetActionName", cdecl, dynlib: dllname.}
-
-proc GetHandle*(name: cstring): PIhandle {.
-  importc: "IupGetHandle", cdecl, dynlib: dllname.}
-proc SetHandle*(name: cstring, ih: PIhandle): PIhandle {.
-  importc: "IupSetHandle", cdecl, dynlib: dllname.}
-proc GetAllNames*(names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllNames", cdecl, dynlib: dllname.}
-proc GetAllDialogs*(names: cstringArray, n: cint): cint {.
-  importc: "IupGetAllDialogs", cdecl, dynlib: dllname.}
-proc GetName*(ih: PIhandle): cstring {.
-  importc: "IupGetName", cdecl, dynlib: dllname.}
-
-proc SetAttributeHandle*(ih: PIhandle, name: cstring, ih_named: PIhandle) {.
-  importc: "IupSetAttributeHandle", cdecl, dynlib: dllname.}
-proc GetAttributeHandle*(ih: PIhandle, name: cstring): PIhandle {.
-  importc: "IupGetAttributeHandle", cdecl, dynlib: dllname.}
-
-proc GetClassName*(ih: PIhandle): cstring {.
-  importc: "IupGetClassName", cdecl, dynlib: dllname.}
-proc GetClassType*(ih: PIhandle): cstring {.
-  importc: "IupGetClassType", cdecl, dynlib: dllname.}
-proc GetClassAttributes*(classname: cstring, names: cstringArray, 
-                         n: cint): cint {.
-  importc: "IupGetClassAttributes", cdecl, dynlib: dllname.}
-proc SaveClassAttributes*(ih: PIhandle) {.
-  importc: "IupSaveClassAttributes", cdecl, dynlib: dllname.}
-proc SetClassDefaultAttribute*(classname, name, value: cstring) {.
-  importc: "IupSetClassDefaultAttribute", cdecl, dynlib: dllname.}
-
-proc Create*(classname: cstring): PIhandle {.
-  importc: "IupCreate", cdecl, dynlib: dllname.}
-proc Createv*(classname: cstring, params: pointer): PIhandle {.
-  importc: "IupCreatev", cdecl, dynlib: dllname.}
-proc Createp*(classname: cstring, first: pointer): PIhandle {.
-  importc: "IupCreatep", cdecl, dynlib: dllname, varargs.}
-
-proc Fill*(): PIhandle {.importc: "IupFill", cdecl, dynlib: dllname.}
-proc Radio*(child: PIhandle): PIhandle {.
-  importc: "IupRadio", cdecl, dynlib: dllname.}
-proc Vbox*(child: PIhandle): PIhandle {.
-  importc: "IupVbox", cdecl, dynlib: dllname, varargs.}
-proc Vboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupVboxv", cdecl, dynlib: dllname.}
-proc Zbox*(child: PIhandle): PIhandle {.
-  importc: "IupZbox", cdecl, dynlib: dllname, varargs.}
-proc Zboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupZboxv", cdecl, dynlib: dllname.}
-proc Hbox*(child: PIhandle): PIhandle {.
-  importc: "IupHbox", cdecl, dynlib: dllname, varargs.}
-proc Hboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupHboxv", cdecl, dynlib: dllname.}
-
-proc Normalizer*(ih_first: PIhandle): PIhandle {.
-  importc: "IupNormalizer", cdecl, dynlib: dllname, varargs.}
-proc Normalizerv*(ih_list: ptr PIhandle): PIhandle {.
-  importc: "IupNormalizerv", cdecl, dynlib: dllname.}
-
-proc Cbox*(child: PIhandle): PIhandle {.
-  importc: "IupCbox", cdecl, dynlib: dllname, varargs.}
-proc Cboxv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupCboxv", cdecl, dynlib: dllname.}
-proc Sbox*(child: PIhandle): PIhandle {.
-  importc: "IupSbox", cdecl, dynlib: dllname.}
-
-proc Frame*(child: PIhandle): PIhandle {.
-  importc: "IupFrame", cdecl, dynlib: dllname.}
-
-proc Image*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImage", cdecl, dynlib: dllname.}
-proc ImageRGB*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImageRGB", cdecl, dynlib: dllname.}
-proc ImageRGBA*(width, height: cint, pixmap: pointer): PIhandle {.
-  importc: "IupImageRGBA", cdecl, dynlib: dllname.}
-
-proc Item*(title, action: cstring): PIhandle {.
-  importc: "IupItem", cdecl, dynlib: dllname.}
-proc Submenu*(title: cstring, child: PIhandle): PIhandle {.
-  importc: "IupSubmenu", cdecl, dynlib: dllname.}
-proc Separator*(): PIhandle {.
-  importc: "IupSeparator", cdecl, dynlib: dllname.}
-proc Menu*(child: PIhandle): PIhandle {.
-  importc: "IupMenu", cdecl, dynlib: dllname, varargs.}
-proc Menuv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupMenuv", cdecl, dynlib: dllname.}
-
-proc Button*(title, action: cstring): PIhandle {.
-  importc: "IupButton", cdecl, dynlib: dllname.}
-proc Canvas*(action: cstring): PIhandle {.
-  importc: "IupCanvas", cdecl, dynlib: dllname.}
-proc Dialog*(child: PIhandle): PIhandle {.
-  importc: "IupDialog", cdecl, dynlib: dllname.}
-proc User*(): PIhandle {.
-  importc: "IupUser", cdecl, dynlib: dllname.}
-proc Label*(title: cstring): PIhandle {.
-  importc: "IupLabel", cdecl, dynlib: dllname.}
-proc List*(action: cstring): PIhandle {.
-  importc: "IupList", cdecl, dynlib: dllname.}
-proc Text*(action: cstring): PIhandle {.
-  importc: "IupText", cdecl, dynlib: dllname.}
-proc MultiLine*(action: cstring): PIhandle {.
-  importc: "IupMultiLine", cdecl, dynlib: dllname.}
-proc Toggle*(title, action: cstring): PIhandle {.
-  importc: "IupToggle", cdecl, dynlib: dllname.}
-proc Timer*(): PIhandle {.
-  importc: "IupTimer", cdecl, dynlib: dllname.}
-proc ProgressBar*(): PIhandle {.
-  importc: "IupProgressBar", cdecl, dynlib: dllname.}
-proc Val*(theType: cstring): PIhandle {.
-  importc: "IupVal", cdecl, dynlib: dllname.}
-proc Tabs*(child: PIhandle): PIhandle {.
-  importc: "IupTabs", cdecl, dynlib: dllname, varargs.}
-proc Tabsv*(children: ptr PIhandle): PIhandle {.
-  importc: "IupTabsv", cdecl, dynlib: dllname.}
-proc Tree*(): PIhandle {.importc: "IupTree", cdecl, dynlib: dllname.}
-
-proc Spin*(): PIhandle {.importc: "IupSpin", cdecl, dynlib: dllname.}
-proc Spinbox*(child: PIhandle): PIhandle {.
-  importc: "IupSpinbox", cdecl, dynlib: dllname.}
-
-# IupText utilities
-proc TextConvertLinColToPos*(ih: PIhandle, lin, col: cint, pos: var cint) {.
-  importc: "IupTextConvertLinColToPos", cdecl, dynlib: dllname.}
-proc TextConvertPosToLinCol*(ih: PIhandle, pos: cint, lin, col: var cint) {.
-  importc: "IupTextConvertPosToLinCol", cdecl, dynlib: dllname.}
-
-proc ConvertXYToPos*(ih: PIhandle, x, y: cint): cint {.
-  importc: "IupConvertXYToPos", cdecl, dynlib: dllname.}
-
-# IupTree utilities
-proc TreeSetUserId*(ih: PIhandle, id: cint, userid: pointer): cint {.
-  importc: "IupTreeSetUserId", cdecl, dynlib: dllname.}
-proc TreeGetUserId*(ih: PIhandle, id: cint): pointer {.
-  importc: "IupTreeGetUserId", cdecl, dynlib: dllname.}
-proc TreeGetId*(ih: PIhandle, userid: pointer): cint {.
-  importc: "IupTreeGetId", cdecl, dynlib: dllname.}
-
-proc TreeSetAttribute*(ih: PIhandle, name: cstring, id: cint, value: cstring) {.
-  importc: "IupTreeSetAttribute", cdecl, dynlib: dllname.}
-proc TreeStoreAttribute*(ih: PIhandle, name: cstring, id: cint, value: cstring) {.
-  importc: "IupTreeStoreAttribute", cdecl, dynlib: dllname.}
-proc TreeGetAttribute*(ih: PIhandle, name: cstring, id: cint): cstring {.
-  importc: "IupTreeGetAttribute", cdecl, dynlib: dllname.}
-proc TreeGetInt*(ih: PIhandle, name: cstring, id: cint): cint {.
-  importc: "IupTreeGetInt", cdecl, dynlib: dllname.}
-proc TreeGetFloat*(ih: PIhandle, name: cstring, id: cint): cfloat {.
-  importc: "IupTreeGetFloat", cdecl, dynlib: dllname.}
-proc TreeSetfAttribute*(ih: PIhandle, name: cstring, id: cint, format: cstring) {.
-  importc: "IupTreeSetfAttribute", cdecl, dynlib: dllname, varargs.}
-
-
-#                   Common Return Values
-const
-  IUP_ERROR* = cint(1)
-  IUP_NOERROR* = cint(0)
-  IUP_OPENED* = cint(-1)
-  IUP_INVALID* = cint(-1)
-
-  # Callback Return Values
-  IUP_IGNORE* = cint(-1)
-  IUP_DEFAULT* = cint(-2)
-  IUP_CLOSE* = cint(-3)
-  IUP_CONTINUE* = cint(-4)
-
-  # IupPopup and IupShowXY Parameter Values
-  IUP_CENTER* = cint(0xFFFF) 
-  IUP_LEFT* = cint(0xFFFE) 
-  IUP_RIGHT* = cint(0xFFFD) 
-  IUP_MOUSEPOS* = cint(0xFFFC) 
-  IUP_CURRENT* = cint(0xFFFB) 
-  IUP_CENTERPARENT* = cint(0xFFFA) 
-  IUP_TOP* = IUP_LEFT
-  IUP_BOTTOM* = IUP_RIGHT
-
-  # SHOW_CB Callback Values
-  IUP_SHOW* = cint(0)
-  IUP_RESTORE* = cint(1)
-  IUP_MINIMIZE* = cint(2)
-  IUP_MAXIMIZE* = cint(3)
-  IUP_HIDE* = cint(4)
-
-  # SCROLL_CB Callback Values
-  IUP_SBUP* = cint(0)
-  IUP_SBDN* = cint(1)
-  IUP_SBPGUP* = cint(2)   
-  IUP_SBPGDN* = cint(3)
-  IUP_SBPOSV* = cint(4)
-  IUP_SBDRAGV* = cint(5) 
-  IUP_SBLEFT* = cint(6)
-  IUP_SBRIGHT* = cint(7)
-  IUP_SBPGLEFT* = cint(8)
-  IUP_SBPGRIGHT* = cint(9)
-  IUP_SBPOSH* = cint(10)
-  IUP_SBDRAGH* = cint(11)
-
-  # Mouse Button Values and Macros
-  IUP_BUTTON1* = cint(ord('1'))
-  IUP_BUTTON2* = cint(ord('2'))
-  IUP_BUTTON3* = cint(ord('3'))
-  IUP_BUTTON4* = cint(ord('4'))
-  IUP_BUTTON5* = cint(ord('5'))
-
-proc isShift*(s: cstring): bool = return s[0] == 'S'
-proc isControl*(s: cstring): bool = return s[1] == 'C'
-proc isButton1*(s: cstring): bool = return s[2] == '1'
-proc isButton2*(s: cstring): bool = return s[3] == '2'
-proc isbutton3*(s: cstring): bool = return s[4] == '3'
-proc isDouble*(s: cstring): bool = return s[5] == 'D'
-proc isAlt*(s: cstring): bool = return s[6] == 'A'
-proc isSys*(s: cstring): bool = return s[7] == 'Y'
-proc isButton4*(s: cstring): bool = return s[8] == '4'
-proc isButton5*(s: cstring): bool = return s[9] == '5'
-
-# Pre-Defined Masks
-const
-  IUP_MASK_FLOAT* = "[+/-]?(/d+/.?/d*|/./d+)"
-  IUP_MASK_UFLOAT* = "(/d+/.?/d*|/./d+)"
-  IUP_MASK_EFLOAT* = "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
-  IUP_MASK_INT* = "[+/-]?/d+"
-  IUP_MASK_UINT* = "/d+"
-  
-# from 32 to 126, all character sets are equal,

-# the key code i the same as the character code.

-const

-  K_SP* = cint(ord(' '))

-  K_exclam* = cint(ord('!'))   

-  K_quotedbl* = cint(ord('\"'))

-  K_numbersign* = cint(ord('#'))

-  K_dollar* = cint(ord('$'))

-  K_percent* = cint(ord('%'))

-  K_ampersand* = cint(ord('&'))

-  K_apostrophe* = cint(ord('\''))

-  K_parentleft* = cint(ord('('))

-  K_parentright* = cint(ord(')'))

-  K_asterisk* = cint(ord('*'))

-  K_plus* = cint(ord('+'))

-  K_comma* = cint(ord(','))

-  K_minus* = cint(ord('-'))

-  K_period* = cint(ord('.'))

-  K_slash* = cint(ord('/'))

-  K_0* = cint(ord('0'))

-  K_1* = cint(ord('1'))

-  K_2* = cint(ord('2'))

-  K_3* = cint(ord('3'))

-  K_4* = cint(ord('4'))

-  K_5* = cint(ord('5'))

-  K_6* = cint(ord('6'))

-  K_7* = cint(ord('7'))

-  K_8* = cint(ord('8'))

-  K_9* = cint(ord('9'))

-  K_colon* = cint(ord(':'))

-  K_semicolon* = cint(ord(';'))

-  K_less* = cint(ord('<'))

-  K_equal* = cint(ord('='))

-  K_greater* = cint(ord('>'))   

-  K_question* = cint(ord('?'))   

-  K_at* = cint(ord('@'))   

-  K_upperA* = cint(ord('A'))   

-  K_upperB* = cint(ord('B'))   

-  K_upperC* = cint(ord('C'))   

-  K_upperD* = cint(ord('D'))   

-  K_upperE* = cint(ord('E'))   

-  K_upperF* = cint(ord('F'))   

-  K_upperG* = cint(ord('G'))   

-  K_upperH* = cint(ord('H'))   

-  K_upperI* = cint(ord('I'))   

-  K_upperJ* = cint(ord('J'))   

-  K_upperK* = cint(ord('K'))   

-  K_upperL* = cint(ord('L'))   

-  K_upperM* = cint(ord('M'))   

-  K_upperN* = cint(ord('N'))   

-  K_upperO* = cint(ord('O'))   

-  K_upperP* = cint(ord('P'))   

-  K_upperQ* = cint(ord('Q'))  

-  K_upperR* = cint(ord('R'))  

-  K_upperS* = cint(ord('S'))  

-  K_upperT* = cint(ord('T'))  

-  K_upperU* = cint(ord('U'))  

-  K_upperV* = cint(ord('V')) 

-  K_upperW* = cint(ord('W')) 

-  K_upperX* = cint(ord('X'))  

-  K_upperY* = cint(ord('Y'))  

-  K_upperZ* = cint(ord('Z'))  

-  K_bracketleft* = cint(ord('[')) 

-  K_backslash* = cint(ord('\\'))  

-  K_bracketright* = cint(ord(']'))  

-  K_circum* = cint(ord('^'))   

-  K_underscore* = cint(ord('_'))   

-  K_grave* = cint(ord('`'))   

-  K_lowera* = cint(ord('a'))  

-  K_lowerb* = cint(ord('b'))   

-  K_lowerc* = cint(ord('c')) 

-  K_lowerd* = cint(ord('d'))   

-  K_lowere* = cint(ord('e'))   

-  K_lowerf* = cint(ord('f'))  

-  K_lowerg* = cint(ord('g'))

-  K_lowerh* = cint(ord('h')) 

-  K_loweri* = cint(ord('i')) 

-  K_lowerj* = cint(ord('j')) 

-  K_lowerk* = cint(ord('k'))

-  K_lowerl* = cint(ord('l'))

-  K_lowerm* = cint(ord('m'))

-  K_lowern* = cint(ord('n'))

-  K_lowero* = cint(ord('o'))

-  K_lowerp* = cint(ord('p'))

-  K_lowerq* = cint(ord('q'))

-  K_lowerr* = cint(ord('r'))

-  K_lowers* = cint(ord('s'))

-  K_lowert* = cint(ord('t'))

-  K_loweru* = cint(ord('u'))

-  K_lowerv* = cint(ord('v'))

-  K_lowerw* = cint(ord('w'))

-  K_lowerx* = cint(ord('x'))

-  K_lowery* = cint(ord('y'))

-  K_lowerz* = cint(ord('z'))

-  K_braceleft* = cint(ord('{'))

-  K_bar* = cint(ord('|'))

-  K_braceright* = cint(ord('}'))

-  K_tilde* = cint(ord('~'))

-

-proc isPrint*(c: cint): bool = return c > 31 and c < 127

-

-# also define the escape sequences that have keys associated

-const

-  K_BS* = cint(ord('\b'))

-  K_TAB* = cint(ord('\t'))

-  K_LF* = cint(10)

-  K_CR* = cint(13)

-

-# IUP Extended Key Codes, range start at 128

-# Modifiers use 256 interval

-# These key code definitions are specific to IUP

-

-proc isXkey*(c: cint): bool = return c > 128

-proc isShiftXkey*(c: cint): bool = return c > 256 and c < 512

-proc isCtrlXkey*(c: cint): bool = return c > 512 and c < 768

-proc isAltXkey*(c: cint): bool = return c > 768 and c < 1024

-proc isSysXkey*(c: cint): bool = return c > 1024 and c < 1280

-

-proc IUPxCODE*(c: cint): cint = return c + cint(128) # Normal (must be above 128)

-proc IUPsxCODE*(c: cint): cint = 
-  return c + cint(256)
-  # Shift (must have range to include the standard keys and the normal 
-  # extended keys, so must be above 256
-
-proc IUPcxCODE*(c: cint): cint = return c + cint(512) # Ctrl

-proc IUPmxCODE*(c: cint): cint = return c + cint(768) # Alt

-proc IUPyxCODE*(c: cint): cint = return c + cint(1024) # Sys (Win or Apple) 

-
-const

-  IUP_NUMMAXCODES* = 1280 ## 5*256=1280  Normal+Shift+Ctrl+Alt+Sys

-

-  K_HOME* = IUPxCODE(1)                

-  K_UP* = IUPxCODE(2)

-  K_PGUP* = IUPxCODE(3)

-  K_LEFT* = IUPxCODE(4)

-  K_MIDDLE* = IUPxCODE(5)

-  K_RIGHT* = IUPxCODE(6)

-  K_END* = IUPxCODE(7)

-  K_DOWN* = IUPxCODE(8)

-  K_PGDN* = IUPxCODE(9)

-  K_INS* = IUPxCODE(10)    

-  K_DEL* = IUPxCODE(11)    

-  K_PAUSE* = IUPxCODE(12)

-  K_ESC* = IUPxCODE(13)

-  K_ccedilla* = IUPxCODE(14)

-  K_F1* = IUPxCODE(15)

-  K_F2* = IUPxCODE(16)

-  K_F3* = IUPxCODE(17)

-  K_F4* = IUPxCODE(18)

-  K_F5* = IUPxCODE(19)

-  K_F6* = IUPxCODE(20)

-  K_F7* = IUPxCODE(21)

-  K_F8* = IUPxCODE(22)

-  K_F9* = IUPxCODE(23)

-  K_F10* = IUPxCODE(24)

-  K_F11* = IUPxCODE(25)

-  K_F12* = IUPxCODE(26)

-  K_Print* = IUPxCODE(27)

-  K_Menu* = IUPxCODE(28)

-

-  K_acute* = IUPxCODE(29) # no Shift/Ctrl/Alt

-

-  K_sHOME* = IUPsxCODE(K_HOME)

-  K_sUP* = IUPsxCODE(K_UP)

-  K_sPGUP* = IUPsxCODE(K_PGUP)

-  K_sLEFT* = IUPsxCODE(K_LEFT)

-  K_sMIDDLE* = IUPsxCODE(K_MIDDLE)

-  K_sRIGHT* = IUPsxCODE(K_RIGHT)

-  K_sEND* = IUPsxCODE(K_END)

-  K_sDOWN* = IUPsxCODE(K_DOWN)

-  K_sPGDN* = IUPsxCODE(K_PGDN)

-  K_sINS* = IUPsxCODE(K_INS)

-  K_sDEL* = IUPsxCODE(K_DEL)

-  K_sSP* = IUPsxCODE(K_SP)

-  K_sTAB* = IUPsxCODE(K_TAB)

-  K_sCR* = IUPsxCODE(K_CR)

-  K_sBS* = IUPsxCODE(K_BS)

-  K_sPAUSE* = IUPsxCODE(K_PAUSE)

-  K_sESC* = IUPsxCODE(K_ESC)

-  K_sCcedilla* = IUPsxCODE(K_ccedilla)

-  K_sF1* = IUPsxCODE(K_F1)

-  K_sF2* = IUPsxCODE(K_F2)

-  K_sF3* = IUPsxCODE(K_F3)

-  K_sF4* = IUPsxCODE(K_F4)

-  K_sF5* = IUPsxCODE(K_F5)

-  K_sF6* = IUPsxCODE(K_F6)

-  K_sF7* = IUPsxCODE(K_F7)

-  K_sF8* = IUPsxCODE(K_F8)

-  K_sF9* = IUPsxCODE(K_F9)

-  K_sF10* = IUPsxCODE(K_F10)

-  K_sF11* = IUPsxCODE(K_F11)

-  K_sF12* = IUPsxCODE(K_F12)

-  K_sPrint* = IUPsxCODE(K_Print)

-  K_sMenu* = IUPsxCODE(K_Menu)

-

-  K_cHOME* = IUPcxCODE(K_HOME)

-  K_cUP* = IUPcxCODE(K_UP)

-  K_cPGUP* = IUPcxCODE(K_PGUP)

-  K_cLEFT* = IUPcxCODE(K_LEFT)

-  K_cMIDDLE* = IUPcxCODE(K_MIDDLE)

-  K_cRIGHT* = IUPcxCODE(K_RIGHT)

-  K_cEND* = IUPcxCODE(K_END)

-  K_cDOWN* = IUPcxCODE(K_DOWN)

-  K_cPGDN* = IUPcxCODE(K_PGDN)

-  K_cINS* = IUPcxCODE(K_INS)

-  K_cDEL* = IUPcxCODE(K_DEL)

-  K_cSP* = IUPcxCODE(K_SP)

-  K_cTAB* = IUPcxCODE(K_TAB)

-  K_cCR* = IUPcxCODE(K_CR)

-  K_cBS* = IUPcxCODE(K_BS)

-  K_cPAUSE* = IUPcxCODE(K_PAUSE)

-  K_cESC* = IUPcxCODE(K_ESC)

-  K_cCcedilla* = IUPcxCODE(K_ccedilla)

-  K_cF1* = IUPcxCODE(K_F1)

-  K_cF2* = IUPcxCODE(K_F2)

-  K_cF3* = IUPcxCODE(K_F3)

-  K_cF4* = IUPcxCODE(K_F4)

-  K_cF5* = IUPcxCODE(K_F5)

-  K_cF6* = IUPcxCODE(K_F6)

-  K_cF7* = IUPcxCODE(K_F7)

-  K_cF8* = IUPcxCODE(K_F8)

-  K_cF9* = IUPcxCODE(K_F9)

-  K_cF10* = IUPcxCODE(K_F10)

-  K_cF11* = IUPcxCODE(K_F11)

-  K_cF12* = IUPcxCODE(K_F12)

-  K_cPrint* = IUPcxCODE(K_Print)

-  K_cMenu* = IUPcxCODE(K_Menu)

-

-  K_mHOME* = IUPmxCODE(K_HOME)

-  K_mUP* = IUPmxCODE(K_UP)

-  K_mPGUP* = IUPmxCODE(K_PGUP)

-  K_mLEFT* = IUPmxCODE(K_LEFT)

-  K_mMIDDLE* = IUPmxCODE(K_MIDDLE)

-  K_mRIGHT* = IUPmxCODE(K_RIGHT)

-  K_mEND* = IUPmxCODE(K_END)

-  K_mDOWN* = IUPmxCODE(K_DOWN)

-  K_mPGDN* = IUPmxCODE(K_PGDN)

-  K_mINS* = IUPmxCODE(K_INS)

-  K_mDEL* = IUPmxCODE(K_DEL)

-  K_mSP* = IUPmxCODE(K_SP)

-  K_mTAB* = IUPmxCODE(K_TAB)

-  K_mCR* = IUPmxCODE(K_CR)

-  K_mBS* = IUPmxCODE(K_BS)

-  K_mPAUSE* = IUPmxCODE(K_PAUSE)

-  K_mESC* = IUPmxCODE(K_ESC)

-  K_mCcedilla* = IUPmxCODE(K_ccedilla)

-  K_mF1* = IUPmxCODE(K_F1)

-  K_mF2* = IUPmxCODE(K_F2)

-  K_mF3* = IUPmxCODE(K_F3)

-  K_mF4* = IUPmxCODE(K_F4)

-  K_mF5* = IUPmxCODE(K_F5)

-  K_mF6* = IUPmxCODE(K_F6)

-  K_mF7* = IUPmxCODE(K_F7)

-  K_mF8* = IUPmxCODE(K_F8)

-  K_mF9* = IUPmxCODE(K_F9)

-  K_mF10* = IUPmxCODE(K_F10)

-  K_mF11* = IUPmxCODE(K_F11)

-  K_mF12* = IUPmxCODE(K_F12)

-  K_mPrint* = IUPmxCODE(K_Print)

-  K_mMenu* = IUPmxCODE(K_Menu)

-

-  K_yHOME* = IUPyxCODE(K_HOME)

-  K_yUP* = IUPyxCODE(K_UP)

-  K_yPGUP* = IUPyxCODE(K_PGUP)

-  K_yLEFT* = IUPyxCODE(K_LEFT)

-  K_yMIDDLE* = IUPyxCODE(K_MIDDLE)

-  K_yRIGHT* = IUPyxCODE(K_RIGHT)

-  K_yEND* = IUPyxCODE(K_END)

-  K_yDOWN* = IUPyxCODE(K_DOWN)

-  K_yPGDN* = IUPyxCODE(K_PGDN)

-  K_yINS* = IUPyxCODE(K_INS)

-  K_yDEL* = IUPyxCODE(K_DEL)

-  K_ySP* = IUPyxCODE(K_SP)

-  K_yTAB* = IUPyxCODE(K_TAB)

-  K_yCR* = IUPyxCODE(K_CR)

-  K_yBS* = IUPyxCODE(K_BS)

-  K_yPAUSE* = IUPyxCODE(K_PAUSE)

-  K_yESC* = IUPyxCODE(K_ESC)

-  K_yCcedilla* = IUPyxCODE(K_ccedilla)

-  K_yF1* = IUPyxCODE(K_F1)

-  K_yF2* = IUPyxCODE(K_F2)

-  K_yF3* = IUPyxCODE(K_F3)

-  K_yF4* = IUPyxCODE(K_F4)

-  K_yF5* = IUPyxCODE(K_F5)

-  K_yF6* = IUPyxCODE(K_F6)

-  K_yF7* = IUPyxCODE(K_F7)

-  K_yF8* = IUPyxCODE(K_F8)

-  K_yF9* = IUPyxCODE(K_F9)

-  K_yF10* = IUPyxCODE(K_F10)

-  K_yF11* = IUPyxCODE(K_F11)

-  K_yF12* = IUPyxCODE(K_F12)

-  K_yPrint* = IUPyxCODE(K_Print)

-  K_yMenu* = IUPyxCODE(K_Menu)

-

-  K_sPlus* = IUPsxCODE(K_plus)   

-  K_sComma* = IUPsxCODE(K_comma)   

-  K_sMinus* = IUPsxCODE(K_minus)   

-  K_sPeriod* = IUPsxCODE(K_period)   

-  K_sSlash* = IUPsxCODE(K_slash)   

-  K_sAsterisk* = IUPsxCODE(K_asterisk)

-                        

-  K_cupperA* = IUPcxCODE(K_upperA)

-  K_cupperB* = IUPcxCODE(K_upperB)

-  K_cupperC* = IUPcxCODE(K_upperC)

-  K_cupperD* = IUPcxCODE(K_upperD)

-  K_cupperE* = IUPcxCODE(K_upperE)

-  K_cupperF* = IUPcxCODE(K_upperF)

-  K_cupperG* = IUPcxCODE(K_upperG)

-  K_cupperH* = IUPcxCODE(K_upperH)

-  K_cupperI* = IUPcxCODE(K_upperI)

-  K_cupperJ* = IUPcxCODE(K_upperJ)

-  K_cupperK* = IUPcxCODE(K_upperK)

-  K_cupperL* = IUPcxCODE(K_upperL)

-  K_cupperM* = IUPcxCODE(K_upperM)

-  K_cupperN* = IUPcxCODE(K_upperN)

-  K_cupperO* = IUPcxCODE(K_upperO)

-  K_cupperP* = IUPcxCODE(K_upperP)

-  K_cupperQ* = IUPcxCODE(K_upperQ)

-  K_cupperR* = IUPcxCODE(K_upperR)

-  K_cupperS* = IUPcxCODE(K_upperS)

-  K_cupperT* = IUPcxCODE(K_upperT)

-  K_cupperU* = IUPcxCODE(K_upperU)

-  K_cupperV* = IUPcxCODE(K_upperV)

-  K_cupperW* = IUPcxCODE(K_upperW)

-  K_cupperX* = IUPcxCODE(K_upperX)

-  K_cupperY* = IUPcxCODE(K_upperY)

-  K_cupperZ* = IUPcxCODE(K_upperZ)

-  K_c1* = IUPcxCODE(K_1)

-  K_c2* = IUPcxCODE(K_2)

-  K_c3* = IUPcxCODE(K_3)

-  K_c4* = IUPcxCODE(K_4)

-  K_c5* = IUPcxCODE(K_5)

-  K_c6* = IUPcxCODE(K_6)

-  K_c7* = IUPcxCODE(K_7)        

-  K_c8* = IUPcxCODE(K_8)         

-  K_c9* = IUPcxCODE(K_9)

-  K_c0* = IUPcxCODE(K_0)

-  K_cPlus* = IUPcxCODE(K_plus)   

-  K_cComma* = IUPcxCODE(K_comma)   

-  K_cMinus* = IUPcxCODE(K_minus)   

-  K_cPeriod* = IUPcxCODE(K_period)   

-  K_cSlash* = IUPcxCODE(K_slash)   

-  K_cSemicolon* = IUPcxCODE(K_semicolon) 

-  K_cEqual* = IUPcxCODE(K_equal)

-  K_cBracketleft* = IUPcxCODE(K_bracketleft)

-  K_cBracketright* = IUPcxCODE(K_bracketright)

-  K_cBackslash* = IUPcxCODE(K_backslash)

-  K_cAsterisk* = IUPcxCODE(K_asterisk)

-

-  K_mupperA* = IUPmxCODE(K_upperA)

-  K_mupperB* = IUPmxCODE(K_upperB)

-  K_mupperC* = IUPmxCODE(K_upperC)

-  K_mupperD* = IUPmxCODE(K_upperD)

-  K_mupperE* = IUPmxCODE(K_upperE)

-  K_mupperF* = IUPmxCODE(K_upperF)

-  K_mupperG* = IUPmxCODE(K_upperG)

-  K_mupperH* = IUPmxCODE(K_upperH)

-  K_mupperI* = IUPmxCODE(K_upperI)

-  K_mupperJ* = IUPmxCODE(K_upperJ)

-  K_mupperK* = IUPmxCODE(K_upperK)

-  K_mupperL* = IUPmxCODE(K_upperL)

-  K_mupperM* = IUPmxCODE(K_upperM)

-  K_mupperN* = IUPmxCODE(K_upperN)

-  K_mupperO* = IUPmxCODE(K_upperO)

-  K_mupperP* = IUPmxCODE(K_upperP)

-  K_mupperQ* = IUPmxCODE(K_upperQ)

-  K_mupperR* = IUPmxCODE(K_upperR)

-  K_mupperS* = IUPmxCODE(K_upperS)

-  K_mupperT* = IUPmxCODE(K_upperT)

-  K_mupperU* = IUPmxCODE(K_upperU)

-  K_mupperV* = IUPmxCODE(K_upperV)

-  K_mupperW* = IUPmxCODE(K_upperW)

-  K_mupperX* = IUPmxCODE(K_upperX)

-  K_mupperY* = IUPmxCODE(K_upperY)

-  K_mupperZ* = IUPmxCODE(K_upperZ)

-  K_m1* = IUPmxCODE(K_1)

-  K_m2* = IUPmxCODE(K_2)

-  K_m3* = IUPmxCODE(K_3)

-  K_m4* = IUPmxCODE(K_4)

-  K_m5* = IUPmxCODE(K_5)

-  K_m6* = IUPmxCODE(K_6)

-  K_m7* = IUPmxCODE(K_7)        

-  K_m8* = IUPmxCODE(K_8)         

-  K_m9* = IUPmxCODE(K_9)

-  K_m0* = IUPmxCODE(K_0)

-  K_mPlus* = IUPmxCODE(K_plus)   

-  K_mComma* = IUPmxCODE(K_comma)   

-  K_mMinus* = IUPmxCODE(K_minus)   

-  K_mPeriod* = IUPmxCODE(K_period)   

-  K_mSlash* = IUPmxCODE(K_slash)   

-  K_mSemicolon* = IUPmxCODE(K_semicolon) 

-  K_mEqual* = IUPmxCODE(K_equal)

-  K_mBracketleft* = IUPmxCODE(K_bracketleft)

-  K_mBracketright* = IUPmxCODE(K_bracketright)

-  K_mBackslash* = IUPmxCODE(K_backslash)

-  K_mAsterisk* = IUPmxCODE(K_asterisk)

-

-  K_yA* = IUPyxCODE(K_upperA)

-  K_yB* = IUPyxCODE(K_upperB)

-  K_yC* = IUPyxCODE(K_upperC)

-  K_yD* = IUPyxCODE(K_upperD)

-  K_yE* = IUPyxCODE(K_upperE)

-  K_yF* = IUPyxCODE(K_upperF)

-  K_yG* = IUPyxCODE(K_upperG)

-  K_yH* = IUPyxCODE(K_upperH)

-  K_yI* = IUPyxCODE(K_upperI)

-  K_yJ* = IUPyxCODE(K_upperJ)

-  K_yK* = IUPyxCODE(K_upperK)

-  K_yL* = IUPyxCODE(K_upperL)

-  K_yM* = IUPyxCODE(K_upperM)

-  K_yN* = IUPyxCODE(K_upperN)

-  K_yO* = IUPyxCODE(K_upperO)

-  K_yP* = IUPyxCODE(K_upperP)

-  K_yQ* = IUPyxCODE(K_upperQ)

-  K_yR* = IUPyxCODE(K_upperR)

-  K_yS* = IUPyxCODE(K_upperS)

-  K_yT* = IUPyxCODE(K_upperT)

-  K_yU* = IUPyxCODE(K_upperU)

-  K_yV* = IUPyxCODE(K_upperV)

-  K_yW* = IUPyxCODE(K_upperW)

-  K_yX* = IUPyxCODE(K_upperX)

-  K_yY* = IUPyxCODE(K_upperY)

-  K_yZ* = IUPyxCODE(K_upperZ)

-  K_y1* = IUPyxCODE(K_1)

-  K_y2* = IUPyxCODE(K_2)

-  K_y3* = IUPyxCODE(K_3)

-  K_y4* = IUPyxCODE(K_4)

-  K_y5* = IUPyxCODE(K_5)

-  K_y6* = IUPyxCODE(K_6)

-  K_y7* = IUPyxCODE(K_7)        

-  K_y8* = IUPyxCODE(K_8)         

-  K_y9* = IUPyxCODE(K_9)

-  K_y0* = IUPyxCODE(K_0)

-  K_yPlus* = IUPyxCODE(K_plus)

-  K_yComma* = IUPyxCODE(K_comma)

-  K_yMinus* = IUPyxCODE(K_minus)   

-  K_yPeriod* = IUPyxCODE(K_period)   

-  K_ySlash* = IUPyxCODE(K_slash)   

-  K_ySemicolon* = IUPyxCODE(K_semicolon) 

-  K_yEqual* = IUPyxCODE(K_equal)

-  K_yBracketleft* = IUPyxCODE(K_bracketleft)

-  K_yBracketright* = IUPyxCODE(K_bracketright)

-  K_yBackslash* = IUPyxCODE(K_backslash)

-  K_yAsterisk* = IUPyxCODE(K_asterisk)

-
-proc ControlsOpen*(): cint {.cdecl, importc: "IupControlsOpen", dynlib: dllname.}

-proc ControlsClose*() {.cdecl, importc: "IupControlsClose", dynlib: dllname.}

-

-proc OldValOpen*() {.cdecl, importc: "IupOldValOpen", dynlib: dllname.}

-proc OldTabsOpen*() {.cdecl, importc: "IupOldTabsOpen", dynlib: dllname.}

-

-proc Colorbar*(): PIhandle {.cdecl, importc: "IupColorbar", dynlib: dllname.}

-proc Cells*(): PIhandle {.cdecl, importc: "IupCells", dynlib: dllname.}

-proc ColorBrowser*(): PIhandle {.cdecl, importc: "IupColorBrowser", dynlib: dllname.}

-proc Gauge*(): PIhandle {.cdecl, importc: "IupGauge", dynlib: dllname.}

-proc Dial*(theType: cstring): PIhandle {.cdecl, importc: "IupDial", dynlib: dllname.}

-proc Matrix*(action: cstring): PIhandle {.cdecl, importc: "IupMatrix", dynlib: dllname.}

-

-# IupMatrix utilities

-proc MatSetAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                      value: cstring) {.
-                      cdecl, importc: "IupMatSetAttribute", dynlib: dllname.}

-proc MatStoreAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                        value: cstring) {.cdecl, 
-                        importc: "IupMatStoreAttribute", dynlib: dllname.}

-proc MatGetAttribute*(ih: PIhandle, name: cstring, lin, col: cint): cstring {.
-  cdecl, importc: "IupMatGetAttribute", dynlib: dllname.}

-proc MatGetInt*(ih: PIhandle, name: cstring, lin, col: cint): cint {.
-  cdecl, importc: "IupMatGetInt", dynlib: dllname.}

-proc MatGetFloat*(ih: PIhandle, name: cstring, lin, col: cint): cfloat {.
-  cdecl, importc: "IupMatGetFloat", dynlib: dllname.}

-proc MatSetfAttribute*(ih: PIhandle, name: cstring, lin, col: cint, 
-                       format: cstring) {.cdecl, 
-                       importc: "IupMatSetfAttribute", 
-                       dynlib: dllname, varargs.}

-

-# Used by IupColorbar

-const
-  IUP_PRIMARY* = -1

-  IUP_SECONDARY* = -2

-

-# Initialize PPlot widget class

-proc PPlotOpen*() {.cdecl, importc: "IupPPlotOpen", dynlib: dllname.}

-

-# Create an PPlot widget instance

-proc PPlot*: PIhandle {.cdecl, importc: "IupPPlot", dynlib: dllname.}

-

-# Add dataset to plot

-proc PPlotBegin*(ih: PIhandle, strXdata: cint) {.
-  cdecl, importc: "IupPPlotBegin", dynlib: dllname.}

-proc PPlotAdd*(ih: PIhandle, x, y: cfloat) {.
-  cdecl, importc: "IupPPlotAdd", dynlib: dllname.}

-proc PPlotAddStr*(ih: PIhandle, x: cstring, y: cfloat) {.
-  cdecl, importc: "IupPPlotAddStr", dynlib: dllname.}

-proc PPlotEnd*(ih: PIhandle): cint {.
-  cdecl, importc: "IupPPlotEnd", dynlib: dllname.}

-

-proc PPlotInsertStr*(ih: PIhandle, index, sample_index: cint, x: cstring, 
-                     y: cfloat) {.cdecl, importc: "IupPPlotInsertStr", 
-                     dynlib: dllname.}

-proc PPlotInsert*(ih: PIhandle, index, sample_index: cint, 
-                  x, y: cfloat) {.
-                  cdecl, importc: "IupPPlotInsert", dynlib: dllname.}

-

-# convert from plot coordinates to pixels

-proc PPlotTransform*(ih: PIhandle, x, y: cfloat, ix, iy: var cint) {.
-  cdecl, importc: "IupPPlotTransform", dynlib: dllname.}

-

-# Plot on the given device. Uses a "cdCanvas*".

-proc PPlotPaintTo*(ih: PIhandle, cnv: pointer) {.
-  cdecl, importc: "IupPPlotPaintTo", dynlib: dllname.}

-

-
diff --git a/lib/wrappers/linenoise/LICENSE.txt b/lib/wrappers/linenoise/LICENSE.txt
new file mode 100644
index 000000000..18e814865
--- /dev/null
+++ b/lib/wrappers/linenoise/LICENSE.txt
@@ -0,0 +1,25 @@
+Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
+Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/lib/wrappers/linenoise/README.markdown b/lib/wrappers/linenoise/README.markdown
new file mode 100644
index 000000000..c845673cd
--- /dev/null
+++ b/lib/wrappers/linenoise/README.markdown
@@ -0,0 +1,52 @@
+# Linenoise
+
+A minimal, zero-config, BSD licensed, readline replacement used in Redis,
+MongoDB, and Android.
+
+* Single and multi line editing mode with the usual key bindings implemented.
+* History handling.
+* Completion.
+* About 1,100 lines of BSD license source code.
+* Only uses a subset of VT100 escapes (ANSI.SYS compatible).
+
+## Can a line editing library be 20k lines of code?
+
+Line editing with some support for history is a really important feature for command line utilities. Instead of retyping almost the same stuff again and again it's just much better to hit the up arrow and edit on syntax errors, or in order to try a slightly different command. But apparently code dealing with terminals is some sort of Black Magic: readline is 30k lines of code, libedit 20k. Is it reasonable to link small utilities to huge libraries just to get a minimal support for line editing?
+
+So what usually happens is either:
+
+ * Large programs with configure scripts disabling line editing if readline is not present in the system, or not supporting it at all since readline is GPL licensed and libedit (the BSD clone) is not as known and available as readline is (Real world example of this problem: Tclsh).
+ * Smaller programs not using a configure script not supporting line editing at all (A problem we had with Redis-cli for instance).
+ 
+The result is a pollution of binaries without line editing support.
+
+So I spent more or less two hours doing a reality check resulting in this little library: is it *really* needed for a line editing library to be 20k lines of code? Apparently not, it is possibe to get a very small, zero configuration, trivial to embed library, that solves the problem. Smaller programs will just include this, supporing line editing out of the box. Larger programs may use this little library or just checking with configure if readline/libedit is available and resorting to linenoise if not.
+
+## Terminals, in 2010.
+
+Apparently almost every terminal you can happen to use today has some kind of support for basic VT100 escape sequences. So I tried to write a lib using just very basic VT100 features. The resulting library appears to work everywhere I tried to use it, and now can work even on ANSI.SYS compatible terminals, since no
+VT220 specific sequences are used anymore.
+
+The library is currently about 1100 lines of code. In order to use it in your project just look at the *example.c* file in the source distribution, it is trivial. Linenoise is BSD code, so you can use both in free software and commercial software.
+
+## Tested with...
+
+ * Linux text only console ($TERM = linux)
+ * Linux KDE terminal application ($TERM = xterm)
+ * Linux xterm ($TERM = xterm)
+ * Linux Buildroot ($TERM = vt100)
+ * Mac OS X iTerm ($TERM = xterm)
+ * Mac OS X default Terminal.app ($TERM = xterm)
+ * OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen)
+ * IBM AIX 6.1
+ * FreeBSD xterm ($TERM = xterm)
+ * ANSI.SYS
+
+Please test it everywhere you can and report back!
+
+## Let's push this forward!
+
+Patches should be provided in the respect of linenoise sensibility for small
+easy to understand code.
+
+Send feedbacks to antirez at gmail
diff --git a/lib/wrappers/linenoise/linenoise.c b/lib/wrappers/linenoise/linenoise.c
new file mode 100644
index 000000000..be792b96b
--- /dev/null
+++ b/lib/wrappers/linenoise/linenoise.c
@@ -0,0 +1,1207 @@
+/* linenoise.c -- guerrilla line editing library against the idea that a
+ * line editing lib needs to be 20,000 lines of C code.
+ *
+ * You can find the latest source code at:
+ *
+ *   http://github.com/antirez/linenoise
+ *
+ * Does a number of crazy assumptions that happen to be true in 99.9999% of
+ * the 2010 UNIX computers around.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Copyright (c) 2010-2016, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *  *  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *  *  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * References:
+ * - http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+ * - http://www.3waylabs.com/nw/WWW/products/wizcon/vt220.html
+ *
+ * Todo list:
+ * - Filter bogus Ctrl+<char> combinations.
+ * - Win32 support
+ *
+ * Bloat:
+ * - History search like Ctrl+r in readline?
+ *
+ * List of escape sequences used by this program, we do everything just
+ * with three sequences. In order to be so cheap we may have some
+ * flickering effect with some slow terminal, but the lesser sequences
+ * the more compatible.
+ *
+ * EL (Erase Line)
+ *    Sequence: ESC [ n K
+ *    Effect: if n is 0 or missing, clear from cursor to end of line
+ *    Effect: if n is 1, clear from beginning of line to cursor
+ *    Effect: if n is 2, clear entire line
+ *
+ * CUF (CUrsor Forward)
+ *    Sequence: ESC [ n C
+ *    Effect: moves cursor forward n chars
+ *
+ * CUB (CUrsor Backward)
+ *    Sequence: ESC [ n D
+ *    Effect: moves cursor backward n chars
+ *
+ * The following is used to get the terminal width if getting
+ * the width with the TIOCGWINSZ ioctl fails
+ *
+ * DSR (Device Status Report)
+ *    Sequence: ESC [ 6 n
+ *    Effect: reports the current cusor position as ESC [ n ; m R
+ *            where n is the row and m is the column
+ *
+ * When multi line mode is enabled, we also use an additional escape
+ * sequence. However multi line editing is disabled by default.
+ *
+ * CUU (Cursor Up)
+ *    Sequence: ESC [ n A
+ *    Effect: moves cursor up of n chars.
+ *
+ * CUD (Cursor Down)
+ *    Sequence: ESC [ n B
+ *    Effect: moves cursor down of n chars.
+ *
+ * When linenoiseClearScreen() is called, two additional escape sequences
+ * are used in order to clear the screen and position the cursor at home
+ * position.
+ *
+ * CUP (Cursor position)
+ *    Sequence: ESC [ H
+ *    Effect: moves the cursor to upper left corner
+ *
+ * ED (Erase display)
+ *    Sequence: ESC [ 2 J
+ *    Effect: clear the whole screen
+ *
+ */
+
+#include <termios.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include "linenoise.h"
+
+#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
+#define LINENOISE_MAX_LINE 4096
+static char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
+static linenoiseCompletionCallback *completionCallback = NULL;
+static linenoiseHintsCallback *hintsCallback = NULL;
+static linenoiseFreeHintsCallback *freeHintsCallback = NULL;
+
+static struct termios orig_termios; /* In order to restore at exit.*/
+static int rawmode = 0; /* For atexit() function to check if restore is needed*/
+static int mlmode = 0;  /* Multi line mode. Default is single line. */
+static int atexit_registered = 0; /* Register atexit just 1 time. */
+static int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN;
+static int history_len = 0;
+static char **history = NULL;
+
+/* The linenoiseState structure represents the state during line editing.
+ * We pass this state to functions implementing specific editing
+ * functionalities. */
+struct linenoiseState {
+    int ifd;            /* Terminal stdin file descriptor. */
+    int ofd;            /* Terminal stdout file descriptor. */
+    char *buf;          /* Edited line buffer. */
+    size_t buflen;      /* Edited line buffer size. */
+    const char *prompt; /* Prompt to display. */
+    size_t plen;        /* Prompt length. */
+    size_t pos;         /* Current cursor position. */
+    size_t oldpos;      /* Previous refresh cursor position. */
+    size_t len;         /* Current edited line length. */
+    size_t cols;        /* Number of columns in terminal. */
+    size_t maxrows;     /* Maximum num of rows used so far (multiline mode) */
+    int history_index;  /* The history index we are currently editing. */
+};
+
+enum KEY_ACTION{
+	KEY_NULL = 0,	    /* NULL */
+	CTRL_A = 1,         /* Ctrl+a */
+	CTRL_B = 2,         /* Ctrl-b */
+	CTRL_C = 3,         /* Ctrl-c */
+	CTRL_D = 4,         /* Ctrl-d */
+	CTRL_E = 5,         /* Ctrl-e */
+	CTRL_F = 6,         /* Ctrl-f */
+	CTRL_H = 8,         /* Ctrl-h */
+	TAB = 9,            /* Tab */
+	CTRL_K = 11,        /* Ctrl+k */
+	CTRL_L = 12,        /* Ctrl+l */
+	ENTER = 13,         /* Enter */
+	CTRL_N = 14,        /* Ctrl-n */
+	CTRL_P = 16,        /* Ctrl-p */
+	CTRL_T = 20,        /* Ctrl-t */
+	CTRL_U = 21,        /* Ctrl+u */
+	CTRL_W = 23,        /* Ctrl+w */
+	ESC = 27,           /* Escape */
+	BACKSPACE =  127    /* Backspace */
+};
+
+static void linenoiseAtExit(void);
+int linenoiseHistoryAdd(const char *line);
+static void refreshLine(struct linenoiseState *l);
+
+/* Debugging macro. */
+#if 0
+FILE *lndebug_fp = NULL;
+#define lndebug(...) \
+    do { \
+        if (lndebug_fp == NULL) { \
+            lndebug_fp = fopen("/tmp/lndebug.txt","a"); \
+            fprintf(lndebug_fp, \
+            "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \
+            (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \
+            (int)l->maxrows,old_rows); \
+        } \
+        fprintf(lndebug_fp, ", " __VA_ARGS__); \
+        fflush(lndebug_fp); \
+    } while (0)
+#else
+#define lndebug(fmt, ...)
+#endif
+
+/* ======================= Low level terminal handling ====================== */
+
+/* Set if to use or not the multi line mode. */
+void linenoiseSetMultiLine(int ml) {
+    mlmode = ml;
+}
+
+/* Return true if the terminal name is in the list of terminals we know are
+ * not able to understand basic escape sequences. */
+static int isUnsupportedTerm(void) {
+    char *term = getenv("TERM");
+    int j;
+
+    if (term == NULL) return 0;
+    for (j = 0; unsupported_term[j]; j++)
+        if (!strcasecmp(term,unsupported_term[j])) return 1;
+    return 0;
+}
+
+/* Raw mode: 1960 magic shit. */
+static int enableRawMode(int fd) {
+    struct termios raw;
+
+    if (!isatty(STDIN_FILENO)) goto fatal;
+    if (!atexit_registered) {
+        atexit(linenoiseAtExit);
+        atexit_registered = 1;
+    }
+    if (tcgetattr(fd,&orig_termios) == -1) goto fatal;
+
+    raw = orig_termios;  /* modify the original mode */
+    /* input modes: no break, no CR to NL, no parity check, no strip char,
+     * no start/stop output control. */
+    raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+    /* output modes - disable post processing */
+    raw.c_oflag &= ~(OPOST);
+    /* control modes - set 8 bit chars */
+    raw.c_cflag |= (CS8);
+    /* local modes - choing off, canonical off, no extended functions,
+     * no signal chars (^Z,^C) */
+    raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
+    /* control chars - set return condition: min number of bytes and timer.
+     * We want read to return every single byte, without timeout. */
+    raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */
+
+    /* put terminal in raw mode after flushing */
+    if (tcsetattr(fd,TCSAFLUSH,&raw) < 0) goto fatal;
+    rawmode = 1;
+    return 0;
+
+fatal:
+    errno = ENOTTY;
+    return -1;
+}
+
+static void disableRawMode(int fd) {
+    /* Don't even check the return value as it's too late. */
+    if (rawmode && tcsetattr(fd,TCSAFLUSH,&orig_termios) != -1)
+        rawmode = 0;
+}
+
+/* Use the ESC [6n escape sequence to query the horizontal cursor position
+ * and return it. On error -1 is returned, on success the position of the
+ * cursor. */
+static int getCursorPosition(int ifd, int ofd) {
+    char buf[32];
+    int cols, rows;
+    unsigned int i = 0;
+
+    /* Report cursor location */
+    if (write(ofd, "\x1b[6n", 4) != 4) return -1;
+
+    /* Read the response: ESC [ rows ; cols R */
+    while (i < sizeof(buf)-1) {
+        if (read(ifd,buf+i,1) != 1) break;
+        if (buf[i] == 'R') break;
+        i++;
+    }
+    buf[i] = '\0';
+
+    /* Parse it. */
+    if (buf[0] != ESC || buf[1] != '[') return -1;
+    if (sscanf(buf+2,"%d;%d",&rows,&cols) != 2) return -1;
+    return cols;
+}
+
+/* Try to get the number of columns in the current terminal, or assume 80
+ * if it fails. */
+static int getColumns(int ifd, int ofd) {
+    struct winsize ws;
+
+    if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
+        /* ioctl() failed. Try to query the terminal itself. */
+        int start, cols;
+
+        /* Get the initial position so we can restore it later. */
+        start = getCursorPosition(ifd,ofd);
+        if (start == -1) goto failed;
+
+        /* Go to right margin and get position. */
+        if (write(ofd,"\x1b[999C",6) != 6) goto failed;
+        cols = getCursorPosition(ifd,ofd);
+        if (cols == -1) goto failed;
+
+        /* Restore position. */
+        if (cols > start) {
+            char seq[32];
+            snprintf(seq,32,"\x1b[%dD",cols-start);
+            if (write(ofd,seq,strlen(seq)) == -1) {
+                /* Can't recover... */
+            }
+        }
+        return cols;
+    } else {
+        return ws.ws_col;
+    }
+
+failed:
+    return 80;
+}
+
+/* Clear the screen. Used to handle ctrl+l */
+void linenoiseClearScreen(void) {
+    if (write(STDOUT_FILENO,"\x1b[H\x1b[2J",7) <= 0) {
+        /* nothing to do, just to avoid warning. */
+    }
+}
+
+/* Beep, used for completion when there is nothing to complete or when all
+ * the choices were already shown. */
+static void linenoiseBeep(void) {
+    fprintf(stderr, "\x7");
+    fflush(stderr);
+}
+
+/* ============================== Completion ================================ */
+
+/* Free a list of completion option populated by linenoiseAddCompletion(). */
+static void freeCompletions(linenoiseCompletions *lc) {
+    size_t i;
+    for (i = 0; i < lc->len; i++)
+        free(lc->cvec[i]);
+    if (lc->cvec != NULL)
+        free(lc->cvec);
+}
+
+/* This is an helper function for linenoiseEdit() and is called when the
+ * user types the <tab> key in order to complete the string currently in the
+ * input.
+ *
+ * The state of the editing is encapsulated into the pointed linenoiseState
+ * structure as described in the structure definition. */
+static int completeLine(struct linenoiseState *ls) {
+    linenoiseCompletions lc = { 0, NULL };
+    int nread, nwritten;
+    char c = 0;
+
+    completionCallback(ls->buf,&lc);
+    if (lc.len == 0) {
+        linenoiseBeep();
+    } else {
+        size_t stop = 0, i = 0;
+
+        while(!stop) {
+            /* Show completion or original buffer */
+            if (i < lc.len) {
+                struct linenoiseState saved = *ls;
+
+                ls->len = ls->pos = strlen(lc.cvec[i]);
+                ls->buf = lc.cvec[i];
+                refreshLine(ls);
+                ls->len = saved.len;
+                ls->pos = saved.pos;
+                ls->buf = saved.buf;
+            } else {
+                refreshLine(ls);
+            }
+
+            nread = read(ls->ifd,&c,1);
+            if (nread <= 0) {
+                freeCompletions(&lc);
+                return -1;
+            }
+
+            switch(c) {
+                case 9: /* tab */
+                    i = (i+1) % (lc.len+1);
+                    if (i == lc.len) linenoiseBeep();
+                    break;
+                case 27: /* escape */
+                    /* Re-show original buffer */
+                    if (i < lc.len) refreshLine(ls);
+                    stop = 1;
+                    break;
+                default:
+                    /* Update buffer and return */
+                    if (i < lc.len) {
+                        nwritten = snprintf(ls->buf,ls->buflen,"%s",lc.cvec[i]);
+                        ls->len = ls->pos = nwritten;
+                    }
+                    stop = 1;
+                    break;
+            }
+        }
+    }
+
+    freeCompletions(&lc);
+    return c; /* Return last read character */
+}
+
+/* Register a callback function to be called for tab-completion. */
+void linenoiseSetCompletionCallback(linenoiseCompletionCallback *fn) {
+    completionCallback = fn;
+}
+
+/* Register a hits function to be called to show hits to the user at the
+ * right of the prompt. */
+void linenoiseSetHintsCallback(linenoiseHintsCallback *fn) {
+    hintsCallback = fn;
+}
+
+/* Register a function to free the hints returned by the hints callback
+ * registered with linenoiseSetHintsCallback(). */
+void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *fn) {
+    freeHintsCallback = fn;
+}
+
+/* This function is used by the callback function registered by the user
+ * in order to add completion options given the input string when the
+ * user typed <tab>. See the example.c source code for a very easy to
+ * understand example. */
+void linenoiseAddCompletion(linenoiseCompletions *lc, const char *str) {
+    size_t len = strlen(str);
+    char *copy, **cvec;
+
+    copy = malloc(len+1);
+    if (copy == NULL) return;
+    memcpy(copy,str,len+1);
+    cvec = realloc(lc->cvec,sizeof(char*)*(lc->len+1));
+    if (cvec == NULL) {
+        free(copy);
+        return;
+    }
+    lc->cvec = cvec;
+    lc->cvec[lc->len++] = copy;
+}
+
+/* =========================== Line editing ================================= */
+
+/* We define a very simple "append buffer" structure, that is an heap
+ * allocated string where we can append to. This is useful in order to
+ * write all the escape sequences in a buffer and flush them to the standard
+ * output in a single call, to avoid flickering effects. */
+struct abuf {
+    char *b;
+    int len;
+};
+
+static void abInit(struct abuf *ab) {
+    ab->b = NULL;
+    ab->len = 0;
+}
+
+static void abAppend(struct abuf *ab, const char *s, int len) {
+    char *new = realloc(ab->b,ab->len+len);
+
+    if (new == NULL) return;
+    memcpy(new+ab->len,s,len);
+    ab->b = new;
+    ab->len += len;
+}
+
+static void abFree(struct abuf *ab) {
+    free(ab->b);
+}
+
+/* Helper of refreshSingleLine() and refreshMultiLine() to show hints
+ * to the right of the prompt. */
+void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
+    char seq[64];
+    if (hintsCallback && plen+l->len < l->cols) {
+        int color = -1, bold = 0;
+        char *hint = hintsCallback(l->buf,&color,&bold);
+        if (hint) {
+            int hintlen = strlen(hint);
+            int hintmaxlen = l->cols-(plen+l->len);
+            if (hintlen > hintmaxlen) hintlen = hintmaxlen;
+            if (bold == 1 && color == -1) color = 37;
+            if (color != -1 || bold != 0)
+                snprintf(seq,64,"\033[%d;%d;49m",bold,color);
+            abAppend(ab,seq,strlen(seq));
+            abAppend(ab,hint,hintlen);
+            if (color != -1 || bold != 0)
+                abAppend(ab,"\033[0m",4);
+            /* Call the function to free the hint returned. */
+            if (freeHintsCallback) freeHintsCallback(hint);
+        }
+    }
+}
+
+/* Single line low level line refresh.
+ *
+ * Rewrite the currently edited line accordingly to the buffer content,
+ * cursor position, and number of columns of the terminal. */
+static void refreshSingleLine(struct linenoiseState *l) {
+    char seq[64];
+    size_t plen = strlen(l->prompt);
+    int fd = l->ofd;
+    char *buf = l->buf;
+    size_t len = l->len;
+    size_t pos = l->pos;
+    struct abuf ab;
+
+    while((plen+pos) >= l->cols) {
+        buf++;
+        len--;
+        pos--;
+    }
+    while (plen+len > l->cols) {
+        len--;
+    }
+
+    abInit(&ab);
+    /* Cursor to left edge */
+    snprintf(seq,64,"\r");
+    abAppend(&ab,seq,strlen(seq));
+    /* Write the prompt and the current buffer content */
+    abAppend(&ab,l->prompt,strlen(l->prompt));
+    abAppend(&ab,buf,len);
+    /* Show hits if any. */
+    refreshShowHints(&ab,l,plen);
+    /* Erase to right */
+    snprintf(seq,64,"\x1b[0K");
+    abAppend(&ab,seq,strlen(seq));
+    /* Move cursor to original position. */
+    snprintf(seq,64,"\r\x1b[%dC", (int)(pos+plen));
+    abAppend(&ab,seq,strlen(seq));
+    if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */
+    abFree(&ab);
+}
+
+/* Multi line low level line refresh.
+ *
+ * Rewrite the currently edited line accordingly to the buffer content,
+ * cursor position, and number of columns of the terminal. */
+static void refreshMultiLine(struct linenoiseState *l) {
+    char seq[64];
+    int plen = strlen(l->prompt);
+    int rows = (plen+l->len+l->cols-1)/l->cols; /* rows used by current buf. */
+    int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */
+    int rpos2; /* rpos after refresh. */
+    int col; /* colum position, zero-based. */
+    int old_rows = l->maxrows;
+    int fd = l->ofd, j;
+    struct abuf ab;
+
+    /* Update maxrows if needed. */
+    if (rows > (int)l->maxrows) l->maxrows = rows;
+
+    /* First step: clear all the lines used before. To do so start by
+     * going to the last row. */
+    abInit(&ab);
+    if (old_rows-rpos > 0) {
+        lndebug("go down %d", old_rows-rpos);
+        snprintf(seq,64,"\x1b[%dB", old_rows-rpos);
+        abAppend(&ab,seq,strlen(seq));
+    }
+
+    /* Now for every row clear it, go up. */
+    for (j = 0; j < old_rows-1; j++) {
+        lndebug("clear+up");
+        snprintf(seq,64,"\r\x1b[0K\x1b[1A");
+        abAppend(&ab,seq,strlen(seq));
+    }
+
+    /* Clean the top line. */
+    lndebug("clear");
+    snprintf(seq,64,"\r\x1b[0K");
+    abAppend(&ab,seq,strlen(seq));
+
+    /* Write the prompt and the current buffer content */
+    abAppend(&ab,l->prompt,strlen(l->prompt));
+    abAppend(&ab,l->buf,l->len);
+
+    /* Show hits if any. */
+    refreshShowHints(&ab,l,plen);
+
+    /* If we are at the very end of the screen with our prompt, we need to
+     * emit a newline and move the prompt to the first column. */
+    if (l->pos &&
+        l->pos == l->len &&
+        (l->pos+plen) % l->cols == 0)
+    {
+        lndebug("<newline>");
+        abAppend(&ab,"\n",1);
+        snprintf(seq,64,"\r");
+        abAppend(&ab,seq,strlen(seq));
+        rows++;
+        if (rows > (int)l->maxrows) l->maxrows = rows;
+    }
+
+    /* Move cursor to right position. */
+    rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */
+    lndebug("rpos2 %d", rpos2);
+
+    /* Go up till we reach the expected position. */
+    if (rows-rpos2 > 0) {
+        lndebug("go-up %d", rows-rpos2);
+        snprintf(seq,64,"\x1b[%dA", rows-rpos2);
+        abAppend(&ab,seq,strlen(seq));
+    }
+
+    /* Set column. */
+    col = (plen+(int)l->pos) % (int)l->cols;
+    lndebug("set col %d", 1+col);
+    if (col)
+        snprintf(seq,64,"\r\x1b[%dC", col);
+    else
+        snprintf(seq,64,"\r");
+    abAppend(&ab,seq,strlen(seq));
+
+    lndebug("\n");
+    l->oldpos = l->pos;
+
+    if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */
+    abFree(&ab);
+}
+
+/* Calls the two low level functions refreshSingleLine() or
+ * refreshMultiLine() according to the selected mode. */
+static void refreshLine(struct linenoiseState *l) {
+    if (mlmode)
+        refreshMultiLine(l);
+    else
+        refreshSingleLine(l);
+}
+
+/* Insert the character 'c' at cursor current position.
+ *
+ * On error writing to the terminal -1 is returned, otherwise 0. */
+int linenoiseEditInsert(struct linenoiseState *l, char c) {
+    if (l->len < l->buflen) {
+        if (l->len == l->pos) {
+            l->buf[l->pos] = c;
+            l->pos++;
+            l->len++;
+            l->buf[l->len] = '\0';
+            if ((!mlmode && l->plen+l->len < l->cols && !hintsCallback)) {
+                /* Avoid a full update of the line in the
+                 * trivial case. */
+                if (write(l->ofd,&c,1) == -1) return -1;
+            } else {
+                refreshLine(l);
+            }
+        } else {
+            memmove(l->buf+l->pos+1,l->buf+l->pos,l->len-l->pos);
+            l->buf[l->pos] = c;
+            l->len++;
+            l->pos++;
+            l->buf[l->len] = '\0';
+            refreshLine(l);
+        }
+    }
+    return 0;
+}
+
+/* Move cursor on the left. */
+void linenoiseEditMoveLeft(struct linenoiseState *l) {
+    if (l->pos > 0) {
+        l->pos--;
+        refreshLine(l);
+    }
+}
+
+/* Move cursor on the right. */
+void linenoiseEditMoveRight(struct linenoiseState *l) {
+    if (l->pos != l->len) {
+        l->pos++;
+        refreshLine(l);
+    }
+}
+
+/* Move cursor to the start of the line. */
+void linenoiseEditMoveHome(struct linenoiseState *l) {
+    if (l->pos != 0) {
+        l->pos = 0;
+        refreshLine(l);
+    }
+}
+
+/* Move cursor to the end of the line. */
+void linenoiseEditMoveEnd(struct linenoiseState *l) {
+    if (l->pos != l->len) {
+        l->pos = l->len;
+        refreshLine(l);
+    }
+}
+
+/* Substitute the currently edited line with the next or previous history
+ * entry as specified by 'dir'. */
+#define LINENOISE_HISTORY_NEXT 0
+#define LINENOISE_HISTORY_PREV 1
+void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
+    if (history_len > 1) {
+        /* Update the current history entry before to
+         * overwrite it with the next one. */
+        free(history[history_len - 1 - l->history_index]);
+        history[history_len - 1 - l->history_index] = strdup(l->buf);
+        /* Show the new entry */
+        l->history_index += (dir == LINENOISE_HISTORY_PREV) ? 1 : -1;
+        if (l->history_index < 0) {
+            l->history_index = 0;
+            return;
+        } else if (l->history_index >= history_len) {
+            l->history_index = history_len-1;
+            return;
+        }
+        strncpy(l->buf,history[history_len - 1 - l->history_index],l->buflen);
+        l->buf[l->buflen-1] = '\0';
+        l->len = l->pos = strlen(l->buf);
+        refreshLine(l);
+    }
+}
+
+/* Delete the character at the right of the cursor without altering the cursor
+ * position. Basically this is what happens with the "Delete" keyboard key. */
+void linenoiseEditDelete(struct linenoiseState *l) {
+    if (l->len > 0 && l->pos < l->len) {
+        memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1);
+        l->len--;
+        l->buf[l->len] = '\0';
+        refreshLine(l);
+    }
+}
+
+/* Backspace implementation. */
+void linenoiseEditBackspace(struct linenoiseState *l) {
+    if (l->pos > 0 && l->len > 0) {
+        memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos);
+        l->pos--;
+        l->len--;
+        l->buf[l->len] = '\0';
+        refreshLine(l);
+    }
+}
+
+/* Delete the previosu word, maintaining the cursor at the start of the
+ * current word. */
+void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
+    size_t old_pos = l->pos;
+    size_t diff;
+
+    while (l->pos > 0 && l->buf[l->pos-1] == ' ')
+        l->pos--;
+    while (l->pos > 0 && l->buf[l->pos-1] != ' ')
+        l->pos--;
+    diff = old_pos - l->pos;
+    memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1);
+    l->len -= diff;
+    refreshLine(l);
+}
+
+/* This function is the core of the line editing capability of linenoise.
+ * It expects 'fd' to be already in "raw mode" so that every key pressed
+ * will be returned ASAP to read().
+ *
+ * The resulting string is put into 'buf' when the user type enter, or
+ * when ctrl+d is typed.
+ *
+ * The function returns the length of the current buffer. */
+static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt, linenoiseData* data)
+{
+    struct linenoiseState l;
+
+    /* Populate the linenoise state that we pass to functions implementing
+     * specific editing functionalities. */
+    l.ifd = stdin_fd;
+    l.ofd = stdout_fd;
+    l.buf = buf;
+    l.buflen = buflen;
+    l.prompt = prompt;
+    l.plen = strlen(prompt);
+    l.oldpos = l.pos = 0;
+    l.len = 0;
+    l.cols = getColumns(stdin_fd, stdout_fd);
+    l.maxrows = 0;
+    l.history_index = 0;
+
+    /* Buffer starts empty. */
+    l.buf[0] = '\0';
+    l.buflen--; /* Make sure there is always space for the nulterm */
+
+    /* The latest history entry is always our current buffer, that
+     * initially is just an empty string. */
+    linenoiseHistoryAdd("");
+
+    if (write(l.ofd,prompt,l.plen) == -1) return -1;
+    while(1) {
+        char c;
+        int nread;
+        char seq[3];
+
+        nread = read(l.ifd,&c,1);
+        if (nread <= 0) return l.len;
+
+        /* Only autocomplete when the callback is set. It returns < 0 when
+         * there was an error reading from fd. Otherwise it will return the
+         * character that should be handled next. */
+        if (c == 9 && completionCallback != NULL) {
+            c = completeLine(&l);
+            /* Return on errors */
+            if (c < 0) return l.len;
+            /* Read next character when 0 */
+            if (c == 0) continue;
+        }
+
+        switch(c) {
+        case ENTER:    /* enter */
+            history_len--;
+            free(history[history_len]);
+            if (mlmode) linenoiseEditMoveEnd(&l);
+            if (hintsCallback) {
+                /* Force a refresh without hints to leave the previous
+                 * line as the user typed it after a newline. */
+                linenoiseHintsCallback *hc = hintsCallback;
+                hintsCallback = NULL;
+                refreshLine(&l);
+                hintsCallback = hc;
+            }
+            return (int)l.len;
+        case CTRL_C:     /* ctrl-c */
+            errno = EAGAIN;
+            data->status = linenoiseStatus_ctrl_C;
+            return -1;
+        case BACKSPACE:   /* backspace */
+        case 8:     /* ctrl-h */
+            linenoiseEditBackspace(&l);
+            break;
+        case CTRL_D:     /* ctrl-d, remove char at right of cursor, or if the
+                            line is empty, act as end-of-file. */
+            if (l.len > 0) {
+                linenoiseEditDelete(&l);
+            } else {
+                history_len--;
+                free(history[history_len]);
+                data->status = linenoiseStatus_ctrl_D;
+                return -1;
+            }
+            break;
+        case CTRL_T:    /* ctrl-t, swaps current character with previous. */
+            if (l.pos > 0 && l.pos < l.len) {
+                int aux = buf[l.pos-1];
+                buf[l.pos-1] = buf[l.pos];
+                buf[l.pos] = aux;
+                if (l.pos != l.len-1) l.pos++;
+                refreshLine(&l);
+            }
+            break;
+        case CTRL_B:     /* ctrl-b */
+            linenoiseEditMoveLeft(&l);
+            break;
+        case CTRL_F:     /* ctrl-f */
+            linenoiseEditMoveRight(&l);
+            break;
+        case CTRL_P:    /* ctrl-p */
+            linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_PREV);
+            break;
+        case CTRL_N:    /* ctrl-n */
+            linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_NEXT);
+            break;
+        case ESC:    /* escape sequence */
+            /* Read the next two bytes representing the escape sequence.
+             * Use two calls to handle slow terminals returning the two
+             * chars at different times. */
+            if (read(l.ifd,seq,1) == -1) break;
+            if (read(l.ifd,seq+1,1) == -1) break;
+
+            /* ESC [ sequences. */
+            if (seq[0] == '[') {
+                if (seq[1] >= '0' && seq[1] <= '9') {
+                    /* Extended escape, read additional byte. */
+                    if (read(l.ifd,seq+2,1) == -1) break;
+                    if (seq[2] == '~') {
+                        switch(seq[1]) {
+                        case '3': /* Delete key. */
+                            linenoiseEditDelete(&l);
+                            break;
+                        }
+                    }
+                } else {
+                    switch(seq[1]) {
+                    case 'A': /* Up */
+                        linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_PREV);
+                        break;
+                    case 'B': /* Down */
+                        linenoiseEditHistoryNext(&l, LINENOISE_HISTORY_NEXT);
+                        break;
+                    case 'C': /* Right */
+                        linenoiseEditMoveRight(&l);
+                        break;
+                    case 'D': /* Left */
+                        linenoiseEditMoveLeft(&l);
+                        break;
+                    case 'H': /* Home */
+                        linenoiseEditMoveHome(&l);
+                        break;
+                    case 'F': /* End*/
+                        linenoiseEditMoveEnd(&l);
+                        break;
+                    }
+                }
+            }
+
+            /* ESC O sequences. */
+            else if (seq[0] == 'O') {
+                switch(seq[1]) {
+                case 'H': /* Home */
+                    linenoiseEditMoveHome(&l);
+                    break;
+                case 'F': /* End*/
+                    linenoiseEditMoveEnd(&l);
+                    break;
+                }
+            }
+            break;
+        default:
+            if (linenoiseEditInsert(&l,c)) return -1;
+            break;
+        case CTRL_U: /* Ctrl+u, delete the whole line. */
+            buf[0] = '\0';
+            l.pos = l.len = 0;
+            refreshLine(&l);
+            break;
+        case CTRL_K: /* Ctrl+k, delete from current to end of line. */
+            buf[l.pos] = '\0';
+            l.len = l.pos;
+            refreshLine(&l);
+            break;
+        case CTRL_A: /* Ctrl+a, go to the start of the line */
+            linenoiseEditMoveHome(&l);
+            break;
+        case CTRL_E: /* ctrl+e, go to the end of the line */
+            linenoiseEditMoveEnd(&l);
+            break;
+        case CTRL_L: /* ctrl+l, clear screen */
+            linenoiseClearScreen();
+            refreshLine(&l);
+            break;
+        case CTRL_W: /* ctrl+w, delete previous word */
+            linenoiseEditDeletePrevWord(&l);
+            break;
+        }
+    }
+    return l.len;
+}
+
+/* This special mode is used by linenoise in order to print scan codes
+ * on screen for debugging / development purposes. It is implemented
+ * by the linenoise_example program using the --keycodes option. */
+void linenoisePrintKeyCodes(void) {
+    char quit[4];
+
+    printf("Linenoise key codes debugging mode.\n"
+            "Press keys to see scan codes. Type 'quit' at any time to exit.\n");
+    if (enableRawMode(STDIN_FILENO) == -1) return;
+    memset(quit,' ',4);
+    while(1) {
+        char c;
+        int nread;
+
+        nread = read(STDIN_FILENO,&c,1);
+        if (nread <= 0) continue;
+        memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
+        quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
+        if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
+
+        printf("'%c' %02x (%d) (type quit to exit)\n",
+            isprint(c) ? c : '?', (int)c, (int)c);
+        printf("\r"); /* Go left edge manually, we are in raw mode. */
+        fflush(stdout);
+    }
+    disableRawMode(STDIN_FILENO);
+}
+
+/* This function calls the line editing function linenoiseEdit() using
+ * the STDIN file descriptor set in raw mode. */
+static int linenoiseRaw(char *buf, size_t buflen, const char *prompt, linenoiseData* data) {
+    int count;
+
+    if (buflen == 0) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    if (enableRawMode(STDIN_FILENO) == -1) return -1;
+    count = linenoiseEdit(STDIN_FILENO, STDOUT_FILENO, buf, buflen, prompt, data);
+    disableRawMode(STDIN_FILENO);
+    printf("\n");
+    return count;
+}
+
+/* This function is called when linenoise() is called with the standard
+ * input file descriptor not attached to a TTY. So for example when the
+ * program using linenoise is called in pipe or with a file redirected
+ * to its standard input. In this case, we want to be able to return the
+ * line regardless of its length (by default we are limited to 4k). */
+static char *linenoiseNoTTY(void) {
+    char *line = NULL;
+    size_t len = 0, maxlen = 0;
+
+    while(1) {
+        if (len == maxlen) {
+            if (maxlen == 0) maxlen = 16;
+            maxlen *= 2;
+            char *oldval = line;
+            line = realloc(line,maxlen);
+            if (line == NULL) {
+                if (oldval) free(oldval);
+                return NULL;
+            }
+        }
+        int c = fgetc(stdin);
+        if (c == EOF || c == '\n') {
+            if (c == EOF && len == 0) {
+                free(line);
+                return NULL;
+            } else {
+                line[len] = '\0';
+                return line;
+            }
+        } else {
+            line[len] = c;
+            len++;
+        }
+    }
+}
+
+/* The high level function that is the main API of the linenoise library.
+ * This function checks if the terminal has basic capabilities, just checking
+ * for a blacklist of stupid terminals, and later either calls the line
+ * editing function or uses dummy fgets() so that you will be able to type
+ * something even in the most desperate of the conditions. */
+char *linenoiseExtra(const char *prompt, linenoiseData* data) {
+    char buf[LINENOISE_MAX_LINE];
+    int count;
+
+    if (!isatty(STDIN_FILENO)) {
+        /* Not a tty: read from file / pipe. In this mode we don't want any
+         * limit to the line size, so we call a function to handle that. */
+        return linenoiseNoTTY();
+    } else if (isUnsupportedTerm()) {
+        size_t len;
+
+        printf("%s",prompt);
+        fflush(stdout);
+        if (fgets(buf,LINENOISE_MAX_LINE,stdin) == NULL) return NULL;
+        len = strlen(buf);
+        while(len && (buf[len-1] == '\n' || buf[len-1] == '\r')) {
+            len--;
+            buf[len] = '\0';
+        }
+        return strdup(buf);
+    } else {
+        count = linenoiseRaw(buf,LINENOISE_MAX_LINE,prompt, data);
+        if (count == -1) return NULL;
+        return strdup(buf);
+    }
+}
+
+char *linenoise(const char *prompt) {
+  linenoiseData data;
+  data.status = linenoiseStatus_ctrl_unknown;
+  return linenoiseExtra(prompt, &data);
+}
+
+/* This is just a wrapper the user may want to call in order to make sure
+ * the linenoise returned buffer is freed with the same allocator it was
+ * created with. Useful when the main program is using an alternative
+ * allocator. */
+void linenoiseFree(void *ptr) {
+    free(ptr);
+}
+
+/* ================================ History ================================= */
+
+/* Free the history, but does not reset it. Only used when we have to
+ * exit() to avoid memory leaks are reported by valgrind & co. */
+static void freeHistory(void) {
+    if (history) {
+        int j;
+
+        for (j = 0; j < history_len; j++)
+            free(history[j]);
+        free(history);
+    }
+}
+
+/* At exit we'll try to fix the terminal to the initial conditions. */
+static void linenoiseAtExit(void) {
+    disableRawMode(STDIN_FILENO);
+    freeHistory();
+}
+
+/* This is the API call to add a new entry in the linenoise history.
+ * It uses a fixed array of char pointers that are shifted (memmoved)
+ * when the history max length is reached in order to remove the older
+ * entry and make room for the new one, so it is not exactly suitable for huge
+ * histories, but will work well for a few hundred of entries.
+ *
+ * Using a circular buffer is smarter, but a bit more complex to handle. */
+int linenoiseHistoryAdd(const char *line) {
+    char *linecopy;
+
+    if (history_max_len == 0) return 0;
+
+    /* Initialization on first call. */
+    if (history == NULL) {
+        history = malloc(sizeof(char*)*history_max_len);
+        if (history == NULL) return 0;
+        memset(history,0,(sizeof(char*)*history_max_len));
+    }
+
+    /* Don't add duplicated lines. */
+    if (history_len && !strcmp(history[history_len-1], line)) return 0;
+
+    /* Add an heap allocated copy of the line in the history.
+     * If we reached the max length, remove the older line. */
+    linecopy = strdup(line);
+    if (!linecopy) return 0;
+    if (history_len == history_max_len) {
+        free(history[0]);
+        memmove(history,history+1,sizeof(char*)*(history_max_len-1));
+        history_len--;
+    }
+    history[history_len] = linecopy;
+    history_len++;
+    return 1;
+}
+
+/* Set the maximum length for the history. This function can be called even
+ * if there is already some history, the function will make sure to retain
+ * just the latest 'len' elements if the new history length value is smaller
+ * than the amount of items already inside the history. */
+int linenoiseHistorySetMaxLen(int len) {
+    char **new;
+
+    if (len < 1) return 0;
+    if (history) {
+        int tocopy = history_len;
+
+        new = malloc(sizeof(char*)*len);
+        if (new == NULL) return 0;
+
+        /* If we can't copy everything, free the elements we'll not use. */
+        if (len < tocopy) {
+            int j;
+
+            for (j = 0; j < tocopy-len; j++) free(history[j]);
+            tocopy = len;
+        }
+        memset(new,0,sizeof(char*)*len);
+        memcpy(new,history+(history_len-tocopy), sizeof(char*)*tocopy);
+        free(history);
+        history = new;
+    }
+    history_max_len = len;
+    if (history_len > history_max_len)
+        history_len = history_max_len;
+    return 1;
+}
+
+/* Save the history in the specified file. On success 0 is returned
+ * otherwise -1 is returned. */
+int linenoiseHistorySave(const char *filename) {
+    mode_t old_umask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
+    FILE *fp;
+    int j;
+
+    fp = fopen(filename,"w");
+    umask(old_umask);
+    if (fp == NULL) return -1;
+    chmod(filename,S_IRUSR|S_IWUSR);
+    for (j = 0; j < history_len; j++)
+        fprintf(fp,"%s\n",history[j]);
+    fclose(fp);
+    return 0;
+}
+
+/* Load the history from the specified file. If the file does not exist
+ * zero is returned and no operation is performed.
+ *
+ * If the file exists and the operation succeeded 0 is returned, otherwise
+ * on error -1 is returned. */
+int linenoiseHistoryLoad(const char *filename) {
+    FILE *fp = fopen(filename,"r");
+    char buf[LINENOISE_MAX_LINE];
+
+    if (fp == NULL) return -1;
+
+    while (fgets(buf,LINENOISE_MAX_LINE,fp) != NULL) {
+        char *p;
+
+        p = strchr(buf,'\r');
+        if (!p) p = strchr(buf,'\n');
+        if (p) *p = '\0';
+        linenoiseHistoryAdd(buf);
+    }
+    fclose(fp);
+    return 0;
+}
diff --git a/lib/wrappers/linenoise/linenoise.h b/lib/wrappers/linenoise/linenoise.h
new file mode 100644
index 000000000..aa86ccb78
--- /dev/null
+++ b/lib/wrappers/linenoise/linenoise.h
@@ -0,0 +1,84 @@
+/* linenoise.h -- VERSION 1.0
+ *
+ * Guerrilla line editing library against the idea that a line editing lib
+ * needs to be 20,000 lines of C code.
+ *
+ * See linenoise.c for more information.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *  *  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *  *  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LINENOISE_H
+#define __LINENOISE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct linenoiseCompletions {
+  size_t len;
+  char **cvec;
+} linenoiseCompletions;
+
+typedef enum linenoiseStatus {
+  linenoiseStatus_ctrl_unknown,
+  linenoiseStatus_ctrl_C,
+  linenoiseStatus_ctrl_D
+} linenoiseStatus;
+
+typedef struct linenoiseData {
+  linenoiseStatus status;
+} linenoiseData;
+
+typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
+typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
+typedef void(linenoiseFreeHintsCallback)(void *);
+void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
+void linenoiseSetHintsCallback(linenoiseHintsCallback *);
+void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
+void linenoiseAddCompletion(linenoiseCompletions *, const char *);
+
+char *linenoise(const char *prompt);
+char *linenoiseExtra(const char *prompt, linenoiseData* data);
+void linenoiseFree(void *ptr);
+int linenoiseHistoryAdd(const char *line);
+int linenoiseHistorySetMaxLen(int len);
+int linenoiseHistorySave(const char *filename);
+int linenoiseHistoryLoad(const char *filename);
+void linenoiseClearScreen(void);
+void linenoiseSetMultiLine(int ml);
+void linenoisePrintKeyCodes(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LINENOISE_H */
diff --git a/lib/wrappers/linenoise/linenoise.nim b/lib/wrappers/linenoise/linenoise.nim
new file mode 100644
index 000000000..186b3b252
--- /dev/null
+++ b/lib/wrappers/linenoise/linenoise.nim
@@ -0,0 +1,72 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+type
+  Completions* = object
+    len*: csize_t
+    cvec*: cstringArray
+
+  CompletionCallback* = proc (a2: cstring; a3: ptr Completions) {.cdecl.}
+
+{.compile: "linenoise.c".}
+
+proc setCompletionCallback*(a2: CompletionCallback) {.
+    importc: "linenoiseSetCompletionCallback".}
+proc addCompletion*(a2: ptr Completions; a3: cstring) {.
+    importc: "linenoiseAddCompletion".}
+proc readLine*(prompt: cstring): cstring {.importc: "linenoise".}
+proc historyAdd*(line: cstring): cint {.importc: "linenoiseHistoryAdd",
+                                        discardable.}
+proc historySetMaxLen*(len: cint): cint {.importc: "linenoiseHistorySetMaxLen".}
+proc historySave*(filename: cstring): cint {.importc: "linenoiseHistorySave".}
+proc historyLoad*(filename: cstring): cint {.importc: "linenoiseHistoryLoad".}
+proc clearScreen*() {.importc: "linenoiseClearScreen".}
+proc setMultiLine*(ml: cint) {.importc: "linenoiseSetMultiLine".}
+proc printKeyCodes*() {.importc: "linenoisePrintKeyCodes".}
+
+proc free*(s: cstring) {.importc: "free", header: "<stdlib.h>".}
+
+when defined(nimExperimentalLinenoiseExtra) and not defined(windows):
+  # C interface
+  type LinenoiseStatus = enum
+    linenoiseStatus_ctrl_unknown
+    linenoiseStatus_ctrl_C
+    linenoiseStatus_ctrl_D
+
+  type LinenoiseData* = object
+    status: LinenoiseStatus
+
+  proc linenoiseExtra(prompt: cstring, data: ptr LinenoiseData): cstring {.importc.}
+
+  # stable nim interface
+  type Status* = enum
+    lnCtrlUnkown
+    lnCtrlC
+    lnCtrlD
+
+  type ReadLineResult* = object
+    line*: string
+    status*: Status
+
+  proc readLineStatus*(prompt: string, result: var ReadLineResult) =
+    ## line editing API that allows returning the line entered and an indicator
+    ## of which control key was entered, allowing user to distinguish between
+    ## for example ctrl-C vs ctrl-D.
+    runnableExamples("-d:nimExperimentalLinenoiseExtra -r:off"):
+      var ret: ReadLineResult
+      while true:
+        readLineStatus("name: ", ret) # ctrl-D will exit, ctrl-C will go to next prompt
+        if ret.line.len > 0: echo ret.line
+        if ret.status == lnCtrlD: break
+      echo "exiting"
+    var data: LinenoiseData
+    let buf = linenoiseExtra(prompt, data.addr)
+    result.line = $buf
+    free(buf)
+    result.status = data.status.ord.Status
diff --git a/lib/wrappers/odbcsql.nim b/lib/wrappers/odbcsql.nim
deleted file mode 100755
index 77719e85f..000000000
--- a/lib/wrappers/odbcsql.nim
+++ /dev/null
@@ -1,788 +0,0 @@
-
-{.deadCodeElim: on.}
-
-when not defined(ODBCVER):
-  const
-    ODBCVER = 0x0351 ## define ODBC version 3.51 by default
-
-when defined(windows):
-  {.push callconv: stdcall.}
-  const odbclib = "odbc32.dll"
-else:
-  {.push callconv: cdecl.}
-  const odbclib = "libodbc.so"
-
-# DATA TYPES CORRESPONDENCE
-#   BDE fields  ODBC types
-#   ----------  ------------------
-#   ftBlob      SQL_BINARY
-#   ftBoolean   SQL_BIT
-#   ftDate      SQL_TYPE_DATE
-#   ftTime      SQL_TYPE_TIME
-#   ftDateTime  SQL_TYPE_TIMESTAMP
-#   ftInteger   SQL_INTEGER
-#   ftSmallint  SQL_SMALLINT
-#   ftFloat     SQL_DOUBLE
-#   ftString    SQL_CHAR
-#   ftMemo      SQL_BINARY // SQL_VARCHAR
-#
-
-type 
-  TSqlChar* = char
-  TSqlSmallInt* = int16
-  TSqlUSmallInt* = int16
-  TSqlHandle* = pointer
-  TSqlHEnv* = TSqlHandle
-  TSqlHDBC* = TSqlHandle
-  TSqlHStmt* = TSqlHandle
-  TSqlHDesc* = TSqlHandle
-  TSqlInteger* = int
-  TSqlUInteger* = int
-  TSqlPointer* = pointer
-  TSqlReal* = cfloat
-  TSqlDouble* = cdouble
-  TSqlFloat* = cdouble
-  TSqlHWND* = pointer
-  PSQLCHAR* = cstring
-  PSQLINTEGER* = ptr TSqlInteger
-  PSQLUINTEGER* = ptr TSqlUInteger
-  PSQLSMALLINT* = ptr TSqlSmallInt
-  PSQLUSMALLINT* = ptr TSqlUSmallInt
-  PSQLREAL* = ptr TSqlReal
-  PSQLDOUBLE* = ptr TSqlDouble
-  PSQLFLOAT* = ptr TSqlFloat
-  PSQLHANDLE* = ptr TSqlHandle
-
-const                         # SQL data type codes 
-  SQL_UNKNOWN_TYPE* = 0
-  SQL_LONGVARCHAR* = (- 1)
-  SQL_BINARY* = (- 2)
-  SQL_VARBINARY* = (- 3)
-  SQL_LONGVARBINARY* = (- 4)
-  SQL_BIGINT* = (- 5)
-  SQL_TINYINT* = (- 6)
-  SQL_BIT* = (- 7)
-  SQL_WCHAR* = (- 8)
-  SQL_WVARCHAR* = (- 9)
-  SQL_WLONGVARCHAR* = (- 10)
-  SQL_CHAR* = 1
-  SQL_NUMERIC* = 2
-  SQL_DECIMAL* = 3
-  SQL_INTEGER* = 4
-  SQL_SMALLINT* = 5
-  SQL_FLOAT* = 6
-  SQL_REAL* = 7
-  SQL_DOUBLE* = 8
-  SQL_DATETIME* = 9
-  SQL_VARCHAR* = 12
-  SQL_TYPE_DATE* = 91
-  SQL_TYPE_TIME* = 92
-  SQL_TYPE_TIMESTAMP* = 93
-  SQL_DATE* = 9
-  SQL_TIME* = 10
-  SQL_TIMESTAMP* = 11
-  SQL_INTERVAL* = 10
-  SQL_GUID* = - 11            # interval codes
-
-when ODBCVER >= 0x0300: 
-  const 
-    SQL_CODE_YEAR* = 1
-    SQL_CODE_MONTH* = 2
-    SQL_CODE_DAY* = 3
-    SQL_CODE_HOUR* = 4
-    SQL_CODE_MINUTE* = 5
-    SQL_CODE_SECOND* = 6
-    SQL_CODE_YEAR_TO_MONTH* = 7
-    SQL_CODE_DAY_TO_HOUR* = 8
-    SQL_CODE_DAY_TO_MINUTE* = 9
-    SQL_CODE_DAY_TO_SECOND* = 10
-    SQL_CODE_HOUR_TO_MINUTE* = 11
-    SQL_CODE_HOUR_TO_SECOND* = 12
-    SQL_CODE_MINUTE_TO_SECOND* = 13
-    SQL_INTERVAL_YEAR* = 100 + SQL_CODE_YEAR
-    SQL_INTERVAL_MONTH* = 100 + SQL_CODE_MONTH
-    SQL_INTERVAL_DAY* = 100 + SQL_CODE_DAY
-    SQL_INTERVAL_HOUR* = 100 + SQL_CODE_HOUR
-    SQL_INTERVAL_MINUTE* = 100 + SQL_CODE_MINUTE
-    SQL_INTERVAL_SECOND* = 100 + SQL_CODE_SECOND
-    SQL_INTERVAL_YEAR_TO_MONTH* = 100 + SQL_CODE_YEAR_TO_MONTH
-    SQL_INTERVAL_DAY_TO_HOUR* = 100 + SQL_CODE_DAY_TO_HOUR
-    SQL_INTERVAL_DAY_TO_MINUTE* = 100 + SQL_CODE_DAY_TO_MINUTE
-    SQL_INTERVAL_DAY_TO_SECOND* = 100 + SQL_CODE_DAY_TO_SECOND
-    SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
-    SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
-    SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
-else: 
-  const 
-    SQL_INTERVAL_YEAR* = - 80
-    SQL_INTERVAL_MONTH* = - 81
-    SQL_INTERVAL_YEAR_TO_MONTH* = - 82
-    SQL_INTERVAL_DAY* = - 83
-    SQL_INTERVAL_HOUR* = - 84
-    SQL_INTERVAL_MINUTE* = - 85
-    SQL_INTERVAL_SECOND* = - 86
-    SQL_INTERVAL_DAY_TO_HOUR* = - 87
-    SQL_INTERVAL_DAY_TO_MINUTE* = - 88
-    SQL_INTERVAL_DAY_TO_SECOND* = - 89
-    SQL_INTERVAL_HOUR_TO_MINUTE* = - 90
-    SQL_INTERVAL_HOUR_TO_SECOND* = - 91
-    SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
-
-
-when ODBCVER < 0x0300: 
-  const 
-    SQL_UNICODE* = - 95
-    SQL_UNICODE_VARCHAR* = - 96
-    SQL_UNICODE_LONGVARCHAR* = - 97
-    SQL_UNICODE_CHAR* = SQL_UNICODE
-else: 
-  # The previous definitions for SQL_UNICODE_ are historical and obsolete 
-  const 
-    SQL_UNICODE* = SQL_WCHAR
-    SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
-    SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
-    SQL_UNICODE_CHAR* = SQL_WCHAR
-const                         # C datatype to SQL datatype mapping 
-  SQL_C_CHAR* = SQL_CHAR
-  SQL_C_LONG* = SQL_INTEGER
-  SQL_C_SHORT* = SQL_SMALLINT
-  SQL_C_FLOAT* = SQL_REAL
-  SQL_C_DOUBLE* = SQL_DOUBLE
-  SQL_C_NUMERIC* = SQL_NUMERIC
-  SQL_C_DEFAULT* = 99
-  SQL_SIGNED_OFFSET* = - 20
-  SQL_UNSIGNED_OFFSET* = - 22
-  SQL_C_DATE* = SQL_DATE
-  SQL_C_TIME* = SQL_TIME
-  SQL_C_TIMESTAMP* = SQL_TIMESTAMP
-  SQL_C_TYPE_DATE* = SQL_TYPE_DATE
-  SQL_C_TYPE_TIME* = SQL_TYPE_TIME
-  SQL_C_TYPE_TIMESTAMP* = SQL_TYPE_TIMESTAMP
-  SQL_C_INTERVAL_YEAR* = SQL_INTERVAL_YEAR
-  SQL_C_INTERVAL_MONTH* = SQL_INTERVAL_MONTH
-  SQL_C_INTERVAL_DAY* = SQL_INTERVAL_DAY
-  SQL_C_INTERVAL_HOUR* = SQL_INTERVAL_HOUR
-  SQL_C_INTERVAL_MINUTE* = SQL_INTERVAL_MINUTE
-  SQL_C_INTERVAL_SECOND* = SQL_INTERVAL_SECOND
-  SQL_C_INTERVAL_YEAR_TO_MONTH* = SQL_INTERVAL_YEAR_TO_MONTH
-  SQL_C_INTERVAL_DAY_TO_HOUR* = SQL_INTERVAL_DAY_TO_HOUR
-  SQL_C_INTERVAL_DAY_TO_MINUTE* = SQL_INTERVAL_DAY_TO_MINUTE
-  SQL_C_INTERVAL_DAY_TO_SECOND* = SQL_INTERVAL_DAY_TO_SECOND
-  SQL_C_INTERVAL_HOUR_TO_MINUTE* = SQL_INTERVAL_HOUR_TO_MINUTE
-  SQL_C_INTERVAL_HOUR_TO_SECOND* = SQL_INTERVAL_HOUR_TO_SECOND
-  SQL_C_INTERVAL_MINUTE_TO_SECOND* = SQL_INTERVAL_MINUTE_TO_SECOND
-  SQL_C_BINARY* = SQL_BINARY
-  SQL_C_BIT* = SQL_BIT
-  SQL_C_SBIGINT* = SQL_BIGINT + SQL_SIGNED_OFFSET # SIGNED BIGINT
-  SQL_C_UBIGINT* = SQL_BIGINT + SQL_UNSIGNED_OFFSET # UNSIGNED BIGINT
-  SQL_C_TINYINT* = SQL_TINYINT
-  SQL_C_SLONG* = SQL_C_LONG + SQL_SIGNED_OFFSET # SIGNED INTEGER
-  SQL_C_SSHORT* = SQL_C_SHORT + SQL_SIGNED_OFFSET # SIGNED SMALLINT
-  SQL_C_STINYINT* = SQL_TINYINT + SQL_SIGNED_OFFSET # SIGNED TINYINT
-  SQL_C_ULONG* = SQL_C_LONG + SQL_UNSIGNED_OFFSET # UNSIGNED INTEGER
-  SQL_C_USHORT* = SQL_C_SHORT + SQL_UNSIGNED_OFFSET # UNSIGNED SMALLINT
-  SQL_C_UTINYINT* = SQL_TINYINT + SQL_UNSIGNED_OFFSET # UNSIGNED TINYINT
-  SQL_C_BOOKMARK* = SQL_C_ULONG # BOOKMARK
-  SQL_C_GUID* = SQL_GUID
-  SQL_TYPE_NULL* = 0
-
-when ODBCVER < 0x0300: 
-  const 
-    SQL_TYPE_MIN* = SQL_BIT
-    SQL_TYPE_MAX* = SQL_VARCHAR
-
-const 
-  SQL_C_VARBOOKMARK* = SQL_C_BINARY
-  SQL_API_SQLDESCRIBEPARAM* = 58
-  SQL_NO_TOTAL* = - 4
-
-type 
-  SQL_DATE_STRUCT* {.final, pure.} = object 
-    Year*: TSqlSmallInt
-    Month*: TSqlUSmallInt
-    Day*: TSqlUSmallInt
-
-  PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
-  SQL_TIME_STRUCT* {.final, pure.} = object 
-    Hour*: TSqlUSmallInt
-    Minute*: TSqlUSmallInt
-    Second*: TSqlUSmallInt
-
-  PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
-  SQL_TIMESTAMP_STRUCT* {.final, pure.} = object 
-    Year*: TSqlUSmallInt
-    Month*: TSqlUSmallInt
-    Day*: TSqlUSmallInt
-    Hour*: TSqlUSmallInt
-    Minute*: TSqlUSmallInt
-    Second*: TSqlUSmallInt
-    Fraction*: TSqlUInteger
-
-  PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
-
-const 
-  SQL_NAME_LEN* = 128
-  SQL_OV_ODBC3* = 3
-  SQL_OV_ODBC2* = 2
-  SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect 
-  SQL_DRIVER_NOPROMPT* = 0
-  SQL_DRIVER_COMPLETE* = 1
-  SQL_DRIVER_PROMPT* = 2
-  SQL_DRIVER_COMPLETE_REQUIRED* = 3 
-  SQL_IS_POINTER* = (- 4)  # whether an attribute is a pointer or not 
-  SQL_IS_UINTEGER* = (- 5)
-  SQL_IS_INTEGER* = (- 6)
-  SQL_IS_USMALLINT* = (- 7)
-  SQL_IS_SMALLINT* = (- 8)    # SQLExtendedFetch "fFetchType" values 
-  SQL_FETCH_BOOKMARK* = 8
-  SQL_SCROLL_OPTIONS* = 44    # SQL_USE_BOOKMARKS options 
-  SQL_UB_OFF* = 0
-  SQL_UB_ON* = 1
-  SQL_UB_DEFAULT* = SQL_UB_OFF
-  SQL_UB_FIXED* = SQL_UB_ON
-  SQL_UB_VARIABLE* = 2        # SQL_SCROLL_OPTIONS masks 
-  SQL_SO_FORWARD_ONLY* = 0x00000001
-  SQL_SO_KEYSET_DRIVEN* = 0x00000002
-  SQL_SO_DYNAMIC* = 0x00000004
-  SQL_SO_MIXED* = 0x00000008
-  SQL_SO_STATIC* = 0x00000010
-  SQL_BOOKMARK_PERSISTENCE* = 82
-  SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values 
-  SQL_BP_CLOSE* = 0x00000001
-  SQL_BP_DELETE* = 0x00000002
-  SQL_BP_DROP* = 0x00000004
-  SQL_BP_TRANSACTION* = 0x00000008
-  SQL_BP_UPDATE* = 0x00000010
-  SQL_BP_OTHER_HSTMT* = 0x00000020
-  SQL_BP_SCROLL* = 0x00000040
-  SQL_DYNAMIC_CURSOR_ATTRIBUTES1* = 144
-  SQL_DYNAMIC_CURSOR_ATTRIBUTES2* = 145
-  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1* = 146
-  SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2* = 147
-  SQL_INDEX_KEYWORDS* = 148
-  SQL_INFO_SCHEMA_VIEWS* = 149
-  SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
-  SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
-  SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
-  SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's 
-  SQL_CA1_NEXT* = 1
-  SQL_CA1_ABSOLUTE* = 2
-  SQL_CA1_RELATIVE* = 4
-  SQL_CA1_BOOKMARK* = 8       # supported SQLSetPos LockType's 
-  SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
-  SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
-  SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations 
-  SQL_CA1_POS_POSITION* = 0x00000200
-  SQL_CA1_POS_UPDATE* = 0x00000400
-  SQL_CA1_POS_DELETE* = 0x00000800
-  SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes 
-  SQL_CA1_POSITIONED_UPDATE* = 0x00002000
-  SQL_CA1_POSITIONED_DELETE* = 0x00004000
-  SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations 
-  SQL_CA1_BULK_ADD* = 0x00010000
-  SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
-  SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
-  SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY 
-  SQL_CA2_READ_ONLY_CONCURRENCY* = 1
-  SQL_CA2_LOCK_CONCURRENCY* = 2
-  SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
-  SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates 
-  SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
-  SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
-  SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 #  semantics of SQL_ATTR_MAX_ROWS 
-  SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
-  SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
-  SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
-  SQL_CA2_MAX_ROWS_UPDATE* = 0x00000400
-  SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
-  SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
-      SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
-      SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of 
-                                                           # SQL_DIAG_CURSOR_ROW_COUNT 
-  SQL_CA2_CRC_EXACT* = 0x00001000
-  SQL_CA2_CRC_APPROXIMATE* = 0x00002000 #  the kinds of positioned statements that can be simulated 
-  SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
-  SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
-  SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 #  Operations in SQLBulkOperations 
-  SQL_ADD* = 4
-  SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
-  SQL_UPDATE_BY_BOOKMARK* = 5
-  SQL_DELETE_BY_BOOKMARK* = 6
-  SQL_FETCH_BY_BOOKMARK* = 7  # Operations in SQLSetPos 
-  SQL_POSITION* = 0
-  SQL_REFRESH* = 1
-  SQL_UPDATE* = 2
-  SQL_DELETE* = 3             # Lock options in SQLSetPos 
-  SQL_LOCK_NO_CHANGE* = 0
-  SQL_LOCK_EXCLUSIVE* = 1
-  SQL_LOCK_UNLOCK* = 2        # SQLExtendedFetch "rgfRowStatus" element values 
-  SQL_ROW_SUCCESS* = 0
-  SQL_ROW_DELETED* = 1
-  SQL_ROW_UPDATED* = 2
-  SQL_ROW_NOROW* = 3
-  SQL_ROW_ADDED* = 4
-  SQL_ROW_ERROR* = 5
-  SQL_ROW_SUCCESS_WITH_INFO* = 6
-  SQL_ROW_PROCEED* = 0
-  SQL_ROW_IGNORE* = 1
-  SQL_MAX_DSN_LENGTH* = 32    # maximum data source name size 
-  SQL_MAX_OPTION_STRING_LENGTH* = 256
-  SQL_ODBC_CURSORS* = 110
-  SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options 
-  SQL_CUR_USE_IF_NEEDED* = 0
-  SQL_CUR_USE_ODBC* = 1
-  SQL_CUR_USE_DRIVER* = 2
-  SQL_CUR_DEFAULT* = SQL_CUR_USE_DRIVER
-  SQL_PARAM_TYPE_UNKNOWN* = 0
-  SQL_PARAM_INPUT* = 1
-  SQL_PARAM_INPUT_OUTPUT* = 2
-  SQL_RESULT_COL* = 3
-  SQL_PARAM_OUTPUT* = 4
-  SQL_RETURN_VALUE* = 5       # special length/indicator values 
-  SQL_NULL_DATA* = (- 1)
-  SQL_DATA_AT_EXEC* = (- 2)
-  SQL_SUCCESS* = 0
-  SQL_SUCCESS_WITH_INFO* = 1
-  SQL_NO_DATA* = 100
-  SQL_ERROR* = (- 1)
-  SQL_INVALID_HANDLE* = (- 2)
-  SQL_STILL_EXECUTING* = 2
-  SQL_NEED_DATA* = 99         # flags for null-terminated string 
-  SQL_NTS* = (- 3)            # maximum message length 
-  SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants 
-  SQL_DATE_LEN* = 10
-  SQL_TIME_LEN* = 8           # add P+1 if precision is nonzero 
-  SQL_TIMESTAMP_LEN* = 19     # add P+1 if precision is nonzero 
-                              # handle type identifiers 
-  SQL_HANDLE_ENV* = 1
-  SQL_HANDLE_DBC* = 2
-  SQL_HANDLE_STMT* = 3
-  SQL_HANDLE_DESC* = 4        # environment attribute 
-  SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes 
-  SQL_ATTR_AUTO_IPD* = 10001
-  SQL_ATTR_METADATA_ID* = 10014 # statement attributes 
-  SQL_ATTR_APP_ROW_DESC* = 10010
-  SQL_ATTR_APP_PARAM_DESC* = 10011
-  SQL_ATTR_IMP_ROW_DESC* = 10012
-  SQL_ATTR_IMP_PARAM_DESC* = 10013
-  SQL_ATTR_CURSOR_SCROLLABLE* = (- 1)
-  SQL_ATTR_CURSOR_SENSITIVITY* = (- 2)
-  SQL_QUERY_TIMEOUT* = 0
-  SQL_MAX_ROWS* = 1
-  SQL_NOSCAN* = 2
-  SQL_MAX_LENGTH* = 3
-  SQL_ASYNC_ENABLE* = 4       # same as SQL_ATTR_ASYNC_ENABLE */
-  SQL_BIND_TYPE* = 5
-  SQL_CURSOR_TYPE* = 6
-  SQL_CONCURRENCY* = 7
-  SQL_KEYSET_SIZE* = 8
-  SQL_ROWSET_SIZE* = 9
-  SQL_SIMULATE_CURSOR* = 10
-  SQL_RETRIEVE_DATA* = 11
-  SQL_USE_BOOKMARKS* = 12
-  SQL_GET_BOOKMARK* = 13      #      GetStmtOption Only */
-  SQL_ROW_NUMBER* = 14        #      GetStmtOption Only */
-  SQL_ATTR_CURSOR_TYPE* = SQL_CURSOR_TYPE
-  SQL_ATTR_CONCURRENCY* = SQL_CONCURRENCY
-  SQL_ATTR_FETCH_BOOKMARK_PTR* = 16
-  SQL_ATTR_ROW_STATUS_PTR* = 25
-  SQL_ATTR_ROWS_FETCHED_PTR* = 26
-  SQL_AUTOCOMMIT* = 102
-  SQL_ATTR_AUTOCOMMIT* = SQL_AUTOCOMMIT
-  SQL_ATTR_ROW_NUMBER* = SQL_ROW_NUMBER
-  SQL_TXN_ISOLATION* = 108
-  SQL_ATTR_TXN_ISOLATION* = SQL_TXN_ISOLATION
-  SQL_ATTR_MAX_ROWS* = SQL_MAX_ROWS
-  SQL_ATTR_USE_BOOKMARKS* = SQL_USE_BOOKMARKS #* connection attributes */
-  SQL_ACCESS_MODE* = 101      #  SQL_AUTOCOMMIT              =102;
-  SQL_LOGIN_TIMEOUT* = 103
-  SQL_OPT_TRACE* = 104
-  SQL_OPT_TRACEFILE* = 105
-  SQL_TRANSLATE_DLL* = 106
-  SQL_TRANSLATE_OPTION* = 107 #  SQL_TXN_ISOLATION           =108;
-  SQL_CURRENT_QUALIFIER* = 109 #  SQL_ODBC_CURSORS            =110;
-  SQL_QUIET_MODE* = 111
-  SQL_PACKET_SIZE* = 112      #* connection attributes with new names */
-  SQL_ATTR_ACCESS_MODE* = SQL_ACCESS_MODE #  SQL_ATTR_AUTOCOMMIT                       =SQL_AUTOCOMMIT;
-  SQL_ATTR_CONNECTION_DEAD* = 1209 #* GetConnectAttr only */
-  SQL_ATTR_CONNECTION_TIMEOUT* = 113
-  SQL_ATTR_CURRENT_CATALOG* = SQL_CURRENT_QUALIFIER
-  SQL_ATTR_DISCONNECT_BEHAVIOR* = 114
-  SQL_ATTR_ENLIST_IN_DTC* = 1207
-  SQL_ATTR_ENLIST_IN_XA* = 1208
-  SQL_ATTR_LOGIN_TIMEOUT* = SQL_LOGIN_TIMEOUT #  SQL_ATTR_ODBC_CURSORS             =SQL_ODBC_CURSORS;
-  SQL_ATTR_PACKET_SIZE* = SQL_PACKET_SIZE
-  SQL_ATTR_QUIET_MODE* = SQL_QUIET_MODE
-  SQL_ATTR_TRACE* = SQL_OPT_TRACE
-  SQL_ATTR_TRACEFILE* = SQL_OPT_TRACEFILE
-  SQL_ATTR_TRANSLATE_LIB* = SQL_TRANSLATE_DLL
-  SQL_ATTR_TRANSLATE_OPTION* = SQL_TRANSLATE_OPTION #  SQL_ATTR_TXN_ISOLATION                  =SQL_TXN_ISOLATION;
-                                                    #* SQL_ACCESS_MODE options */
-  SQL_MODE_READ_WRITE* = 0
-  SQL_MODE_READ_ONLY* = 1
-  SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
-  SQL_AUTOCOMMIT_OFF* = 0
-  SQL_AUTOCOMMIT_ON* = 1
-  SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values 
-  SQL_NONSCROLLABLE* = 0
-  SQL_SCROLLABLE* = 1         # SQL_CURSOR_TYPE options 
-  SQL_CURSOR_FORWARD_ONLY* = 0
-  SQL_CURSOR_KEYSET_DRIVEN* = 1
-  SQL_CURSOR_DYNAMIC* = 2
-  SQL_CURSOR_STATIC* = 3
-  SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value 
-                                                     # SQL_CONCURRENCY options 
-  SQL_CONCUR_READ_ONLY* = 1
-  SQL_CONCUR_LOCK* = 2
-  SQL_CONCUR_ROWVER* = 3
-  SQL_CONCUR_VALUES* = 4
-  SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value 
-                                             # identifiers of fields in the SQL descriptor 
-  SQL_DESC_COUNT* = 1001
-  SQL_DESC_TYPE* = 1002
-  SQL_DESC_LENGTH* = 1003
-  SQL_DESC_OCTET_LENGTH_PTR* = 1004
-  SQL_DESC_PRECISION* = 1005
-  SQL_DESC_SCALE* = 1006
-  SQL_DESC_DATETIME_INTERVAL_CODE* = 1007
-  SQL_DESC_NULLABLE* = 1008
-  SQL_DESC_INDICATOR_PTR* = 1009
-  SQL_DESC_DATA_PTR* = 1010
-  SQL_DESC_NAME* = 1011
-  SQL_DESC_UNNAMED* = 1012
-  SQL_DESC_OCTET_LENGTH* = 1013
-  SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area 
-  SQL_DIAG_RETURNCODE* = 1
-  SQL_DIAG_NUMBER* = 2
-  SQL_DIAG_ROW_COUNT* = 3
-  SQL_DIAG_SQLSTATE* = 4
-  SQL_DIAG_NATIVE* = 5
-  SQL_DIAG_MESSAGE_TEXT* = 6
-  SQL_DIAG_DYNAMIC_FUNCTION* = 7
-  SQL_DIAG_CLASS_ORIGIN* = 8
-  SQL_DIAG_SUBCLASS_ORIGIN* = 9
-  SQL_DIAG_CONNECTION_NAME* = 10
-  SQL_DIAG_SERVER_NAME* = 11
-  SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes 
-  SQL_DIAG_ALTER_TABLE* = 4
-  SQL_DIAG_CREATE_INDEX* = (- 1)
-  SQL_DIAG_CREATE_TABLE* = 77
-  SQL_DIAG_CREATE_VIEW* = 84
-  SQL_DIAG_DELETE_WHERE* = 19
-  SQL_DIAG_DROP_INDEX* = (- 2)
-  SQL_DIAG_DROP_TABLE* = 32
-  SQL_DIAG_DROP_VIEW* = 36
-  SQL_DIAG_DYNAMIC_DELETE_CURSOR* = 38
-  SQL_DIAG_DYNAMIC_UPDATE_CURSOR* = 81
-  SQL_DIAG_GRANT* = 48
-  SQL_DIAG_INSERT* = 50
-  SQL_DIAG_REVOKE* = 59
-  SQL_DIAG_SELECT_CURSOR* = 85
-  SQL_DIAG_UNKNOWN_STATEMENT* = 0
-  SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity 
-  SQL_UNSPECIFIED* = 0
-  SQL_INSENSITIVE* = 1
-  SQL_SENSITIVE* = 2          # GetTypeInfo() request for all data types 
-  SQL_ALL_TYPES* = 0          # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() 
-  SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
-                    #    specifies the data type 
-  SQL_ARD_TYPE* = (- 99)      # SQL date/time type subcodes 
-  SQL_CODE_DATE* = 1
-  SQL_CODE_TIME* = 2
-  SQL_CODE_TIMESTAMP* = 3     # CLI option values 
-  SQL_FALSE* = 0
-  SQL_TRUE* = 1               # values of NULLABLE field in descriptor 
-  SQL_NO_NULLS* = 0
-  SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
-                    # not known whether or not a data type supports null values. 
-  SQL_NULLABLE_UNKNOWN* = 2 
-  SQL_CLOSE* = 0
-  SQL_DROP* = 1
-  SQL_UNBIND* = 2
-  SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
-                        #   and in SQLDataSources() 
-  SQL_FETCH_NEXT* = 1
-  SQL_FETCH_FIRST* = 2
-  SQL_FETCH_FIRST_USER* = 31
-  SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll() 
-  SQL_FETCH_LAST* = 3
-  SQL_FETCH_PRIOR* = 4
-  SQL_FETCH_ABSOLUTE* = 5
-  SQL_FETCH_RELATIVE* = 6   
-  SQL_NULL_HENV* = TSqlHEnv(nil)
-  SQL_NULL_HDBC* = TSqlHDBC(nil)
-  SQL_NULL_HSTMT* = TSqlHStmt(nil)
-  SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */
-  SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */
-  SQL_SCOPE_CURROW* = 0
-  SQL_SCOPE_TRANSACTION* = 1
-  SQL_SCOPE_SESSION* = 2      #* Column types and scopes in SQLSpecialColumns.  */
-  SQL_BEST_ROWID* = 1
-  SQL_ROWVER* = 2             
-  SQL_ROW_IDENTIFIER* = 1     #* Reserved values for UNIQUE argument of SQLStatistics() */
-  SQL_INDEX_UNIQUE* = 0
-  SQL_INDEX_ALL* = 1          #* Reserved values for RESERVED argument of SQLStatistics() */
-  SQL_QUICK* = 0
-  SQL_ENSURE* = 1             #* Values that may appear in the result set of SQLStatistics() */
-  SQL_TABLE_STAT* = 0
-  SQL_INDEX_CLUSTERED* = 1
-  SQL_INDEX_HASHED* = 2
-  SQL_INDEX_OTHER* = 3 
-  SQL_SCROLL_CONCURRENCY* = 43
-  SQL_TXN_CAPABLE* = 46
-  SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
-  SQL_USER_NAME* = 47
-  SQL_TXN_ISOLATION_OPTION* = 72
-  SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION 
-  SQL_OJ_CAPABILITIES* = 115
-  SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
-  SQL_XOPEN_CLI_YEAR* = 10000
-  SQL_CURSOR_SENSITIVITY* = 10001
-  SQL_DESCRIBE_PARAMETER* = 10002
-  SQL_CATALOG_NAME* = 10003
-  SQL_COLLATION_SEQ* = 10004
-  SQL_MAX_IDENTIFIER_LEN* = 10005
-  SQL_MAXIMUM_IDENTIFIER_LENGTH* = SQL_MAX_IDENTIFIER_LEN
-  SQL_SCCO_READ_ONLY* = 1
-  SQL_SCCO_LOCK* = 2
-  SQL_SCCO_OPT_ROWVER* = 4
-  SQL_SCCO_OPT_VALUES* = 8    #* SQL_TXN_CAPABLE values */
-  SQL_TC_NONE* = 0
-  SQL_TC_DML* = 1
-  SQL_TC_ALL* = 2
-  SQL_TC_DDL_COMMIT* = 3
-  SQL_TC_DDL_IGNORE* = 4      #* SQL_TXN_ISOLATION_OPTION bitmasks */
-  SQL_TXN_READ_UNCOMMITTED* = 1
-  SQL_TRANSACTION_READ_UNCOMMITTED* = SQL_TXN_READ_UNCOMMITTED
-  SQL_TXN_READ_COMMITTED* = 2
-  SQL_TRANSACTION_READ_COMMITTED* = SQL_TXN_READ_COMMITTED
-  SQL_TXN_REPEATABLE_READ* = 4
-  SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
-  SQL_TXN_SERIALIZABLE* = 8
-  SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE 
-  SQL_SS_ADDITIONS* = 1
-  SQL_SS_DELETIONS* = 2
-  SQL_SS_UPDATES* = 4         # SQLColAttributes defines 
-  SQL_COLUMN_COUNT* = 0
-  SQL_COLUMN_NAME* = 1
-  SQL_COLUMN_TYPE* = 2
-  SQL_COLUMN_LENGTH* = 3
-  SQL_COLUMN_PRECISION* = 4
-  SQL_COLUMN_SCALE* = 5
-  SQL_COLUMN_DISPLAY_SIZE* = 6
-  SQL_COLUMN_NULLABLE* = 7
-  SQL_COLUMN_UNSIGNED* = 8
-  SQL_COLUMN_MONEY* = 9
-  SQL_COLUMN_UPDATABLE* = 10
-  SQL_COLUMN_AUTO_INCREMENT* = 11
-  SQL_COLUMN_CASE_SENSITIVE* = 12
-  SQL_COLUMN_SEARCHABLE* = 13
-  SQL_COLUMN_TYPE_NAME* = 14
-  SQL_COLUMN_TABLE_NAME* = 15
-  SQL_COLUMN_OWNER_NAME* = 16
-  SQL_COLUMN_QUALIFIER_NAME* = 17
-  SQL_COLUMN_LABEL* = 18
-  SQL_COLATT_OPT_MAX* = SQL_COLUMN_LABEL
-  SQL_COLUMN_DRIVER_START* = 1000
-  SQL_DESC_ARRAY_SIZE* = 20
-  SQL_DESC_ARRAY_STATUS_PTR* = 21
-  SQL_DESC_AUTO_UNIQUE_VALUE* = SQL_COLUMN_AUTO_INCREMENT
-  SQL_DESC_BASE_COLUMN_NAME* = 22
-  SQL_DESC_BASE_TABLE_NAME* = 23
-  SQL_DESC_BIND_OFFSET_PTR* = 24
-  SQL_DESC_BIND_TYPE* = 25
-  SQL_DESC_CASE_SENSITIVE* = SQL_COLUMN_CASE_SENSITIVE
-  SQL_DESC_CATALOG_NAME* = SQL_COLUMN_QUALIFIER_NAME
-  SQL_DESC_CONCISE_TYPE* = SQL_COLUMN_TYPE
-  SQL_DESC_DATETIME_INTERVAL_PRECISION* = 26
-  SQL_DESC_DISPLAY_SIZE* = SQL_COLUMN_DISPLAY_SIZE
-  SQL_DESC_FIXED_PREC_SCALE* = SQL_COLUMN_MONEY
-  SQL_DESC_LABEL* = SQL_COLUMN_LABEL
-  SQL_DESC_LITERAL_PREFIX* = 27
-  SQL_DESC_LITERAL_SUFFIX* = 28
-  SQL_DESC_LOCAL_TYPE_NAME* = 29
-  SQL_DESC_MAXIMUM_SCALE* = 30
-  SQL_DESC_MINIMUM_SCALE* = 31
-  SQL_DESC_NUM_PREC_RADIX* = 32
-  SQL_DESC_PARAMETER_TYPE* = 33
-  SQL_DESC_ROWS_PROCESSED_PTR* = 34
-  SQL_DESC_SCHEMA_NAME* = SQL_COLUMN_OWNER_NAME
-  SQL_DESC_SEARCHABLE* = SQL_COLUMN_SEARCHABLE
-  SQL_DESC_TYPE_NAME* = SQL_COLUMN_TYPE_NAME
-  SQL_DESC_TABLE_NAME* = SQL_COLUMN_TABLE_NAME
-  SQL_DESC_UNSIGNED* = SQL_COLUMN_UNSIGNED
-  SQL_DESC_UPDATABLE* = SQL_COLUMN_UPDATABLE #* SQLEndTran() options */
-  SQL_COMMIT* = 0
-  SQL_ROLLBACK* = 1
-  SQL_ATTR_ROW_ARRAY_SIZE* = 27 #* SQLConfigDataSource() options */
-  ODBC_ADD_DSN* = 1
-  ODBC_CONFIG_DSN* = 2
-  ODBC_REMOVE_DSN* = 3
-  ODBC_ADD_SYS_DSN* = 4
-  ODBC_CONFIG_SYS_DSN* = 5
-  ODBC_REMOVE_SYS_DSN* = 6
-
-proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle, 
-                     OutputHandlePtr: var TSqlHandle): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, 
-                    Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, 
-                    Value: TSqlPointer, BufferLength: TSqlInteger, 
-                    StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: TSqlHandle): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                    RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR, 
-                    NativeError: var TSqlInteger, MessageText: PSQLCHAR, 
-                    BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                      RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, 
-                      DiagInfoPtr: TSqlPointer, BufferLength: TSqlSmallInt, 
-                      StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLConnect*(ConnectionHandle: TSqlHDBC, ServerName: PSQLCHAR, 
-                 NameLength1: TSqlSmallInt, UserName: PSQLCHAR, 
-                 NameLength2: TSqlSmallInt, Authentication: PSQLCHAR, 
-                 NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDisconnect*(ConnectionHandle: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring, 
-                       szCLen: TSqlSmallInt, szCsout: cstring, 
-                       cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, 
-                       f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR, 
-                       cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, 
-                       cbConnStrOutMax: TSqlSmallInt, 
-                       cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, 
-                    TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, 
-                 TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLDescribeCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                     ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                     NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, 
-                     ColumnSize: var TSqlUInteger, 
-                     DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLFetchScroll*(StatementHandle: TSqlHStmt, FetchOrientation: TSqlSmallInt, 
-                     FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt, 
-                       irow: TSqlInteger, pcrow: PSQLUINTEGER, 
-                       rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLGetData*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: TSqlPointer, 
-                 BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, 
-                     Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, 
-                     Value: TSqlPointer, BufferLength: TSqlInteger, 
-                     StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLGetInfo*(ConnectionHandle: TSqlHDBC, InfoType: TSqlUSmallInt, 
-                 InfoValue: TSqlPointer, BufferLength: TSqlSmallInt, 
-                 StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLBulkOperations*(StatementHandle: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer, 
-                 StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                 TargetType: TSqlSmallInt, TargetValue: TSqlPointer, 
-                 BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt, 
-                fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, 
-                     ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                     NameLength1: PSQLSMALLINT, Description: PSQLCHAR, 
-                     BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, 
-                 DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt, 
-                 DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR, 
-                 BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetConnectAttr*(ConnectionHandle: TSqlHDBC, Attribute: TSqlInteger, 
-                        Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, 
-                       BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, 
-                       NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt, 
-                       fParamType: TSqlSmallInt, fCType: TSqlSmallInt, 
-                       fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger, 
-                       ibScale: TSqlSmallInt, rgbValue: TSqlPointer, 
-                       cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLFreeStmt*(StatementHandle: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, 
-                      FieldIdentifier: TSqlUSmallInt, 
-                      CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, 
-                      StringLength: PSQLSMALLINT, 
-                      NumericAttribute: TSqlPointer): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: TSqlHandle, 
-                 CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLTables*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                cbTableName: TSqlSmallInt, szTableType: PSQLCHAR, 
-                cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLColumns*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                 cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                 cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                 cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR, 
-                 cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
-proc SQLSpecialColumns*(StatementHandle: TSqlHStmt, IdentifierType: TSqlUSmallInt, 
-                        CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, 
-                        SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, 
-                        TableName: PSQLCHAR, NameLength3: TSqlSmallInt, 
-                        Scope: TSqlUSmallInt, 
-                        Nullable: TSqlUSmallInt): TSqlSmallInt{.
-    dynlib: odbclib, importc.}
-proc SQLProcedures*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, 
-                    cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, 
-                    cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, 
-                    cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLPrimaryKeys*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                     NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                     NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                     NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLProcedureColumns*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                          NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                          NameLength2: TSqlSmallInt, ProcName: PSQLCHAR, 
-                          NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR, 
-                          NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, 
-    importc.}
-proc SQLStatistics*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, 
-                    NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, 
-                    NameLength2: TSqlSmallInt, TableName: PSQLCHAR, 
-                    NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt, 
-                    Reserved: TSqlUSmallInt): TSqlSmallInt {.
-                    dynlib: odbclib, importc.}
-
-{.pop.}
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
new file mode 100644
index 000000000..9921b7ffd
--- /dev/null
+++ b/lib/wrappers/openssl.nim
@@ -0,0 +1,909 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+## OpenSSL wrapper. Supports OpenSSL >= 1.1.0 dynamically (as default) or statically linked
+## using `--dynlibOverride:ssl`.
+##
+## `-d:sslVersion=1.2.3` can be used to force an SSL version.
+## This version must be included in the library name.
+## `-d:useOpenssl3` may be set for OpenSSL 3 instead.
+##
+## There is also limited support for OpenSSL 1.0.x which may require `-d:openssl10`.
+##
+## Build and test examples:
+##
+##   ```cmd
+##   ./bin/nim c -d:ssl -p:. -r tests/stdlib/tssl.nim
+##   ./bin/nim c -d:ssl --threads:on -p:. -r tests/stdlib/thttpclient_ssl.nim
+##   ./bin/nim c -d:ssl -p:. -r tests/untestable/tssl.nim
+##   ./bin/nim c -d:ssl -p:. --dynlibOverride:ssl --passl:-lcrypto --passl:-lssl -r tests/untestable/tssl.nim
+##   ./bin/nim r --putenv:NIM_TESTAMENT_REMOTE_NETWORKING:1 -d:ssl -p:testament/lib --threads:on tests/untestable/thttpclient_ssl_remotenetwork.nim
+##   ```
+
+# https://www.feistyduck.com/library/openssl-cookbook/online/ch-testing-with-openssl.html
+#
+from std/strutils import startsWith
+
+when defined(nimPreviewSlimSystem):
+  import std/syncio
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+const useWinVersion = defined(windows) or defined(nimdoc)
+
+# To force openSSL version use -d:sslVersion=1.2.3
+# See: #10281, #10230
+# General issue:
+# Other dynamic libraries (like libpg) load different openSSL version then what nim loads.
+# Having two different openSSL loaded version causes a crash.
+# Use this compile time define to force the openSSL version that your other dynamic libraries want.
+const sslVersion {.strdefine.}: string = ""
+const useOpenssl3* {.booldefine.} = sslVersion.startsWith('3')
+when sslVersion != "":
+  when defined(macosx):
+    const
+      DLLSSLName* = "libssl." & sslVersion & ".dylib"
+      DLLUtilName* = "libcrypto." & sslVersion & ".dylib"
+    from std/posix import SocketHandle
+  elif defined(windows):
+    const
+      DLLSSLName* = "libssl-" & sslVersion & ".dll"
+      DLLUtilName* =  "libcrypto-" & sslVersion & ".dll"
+    from std/winlean import SocketHandle
+  else:
+    const
+      DLLSSLName* = "libssl.so." & sslVersion
+      DLLUtilName* = "libcrypto.so." & sslVersion
+    from std/posix import SocketHandle
+
+elif useWinVersion:
+  when defined(openssl10) or defined(nimOldDlls):
+    when defined(cpu64):
+      const
+        DLLSSLName* = "(ssleay32|ssleay64).dll"
+        DLLUtilName* = "(libeay32|libeay64).dll"
+    else:
+      const
+        DLLSSLName* = "ssleay32.dll"
+        DLLUtilName* = "libeay32.dll"
+  elif defined(cpu64):
+    const
+      DLLSSLName* = "(libssl-1_1-x64|ssleay64|libssl64).dll"
+      DLLUtilName* = "(libcrypto-1_1-x64|libeay64).dll"
+  else:
+    const
+      DLLSSLName* = "(libssl-1_1|ssleay32|libssl32).dll"
+      DLLUtilName* = "(libcrypto-1_1|libeay32).dll"
+
+  from std/winlean import SocketHandle
+else:
+  # same list of versions but ordered differently?
+  when defined(osx):
+    const versions = "(.3|.1.1|.38|.39|.41|.43|.44|.45|.46|.47|.48|.10|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|)"
+  else:
+    const versions = "(.3|.1.1|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|.48|.47|.46|.45|.44|.43|.41|.39|.38|.10|)"
+
+  when defined(macosx):
+    const
+      DLLSSLName* = "libssl" & versions & ".dylib"
+      DLLUtilName* = "libcrypto" & versions & ".dylib"
+  elif defined(genode):
+    const
+      DLLSSLName* = "libssl.lib.so"
+      DLLUtilName* = "libcrypto.lib.so"
+  else:
+    const
+      DLLSSLName* = "libssl.so" & versions
+      DLLUtilName* = "libcrypto.so" & versions
+  from std/posix import SocketHandle
+
+import std/dynlib
+
+{.pragma: lcrypto, cdecl, dynlib: DLLUtilName, importc.}
+{.pragma: lssl, cdecl, dynlib: DLLSSLName, importc.}
+
+type
+  SslStruct {.final, pure.} = object
+  SslPtr* = ptr SslStruct
+  PSslPtr* = ptr SslPtr
+  SslCtx* = SslPtr
+  PSSL_METHOD* = SslPtr
+  PSTACK* = SslPtr
+  PX509* = SslPtr
+  PX509_NAME* = SslPtr
+  PBIO_METHOD* = SslPtr
+  BIO* = SslPtr
+  EVP_PKEY* = SslPtr
+  PRSA* = SslPtr
+  PASN1_UTCTIME* = SslPtr
+  PASN1_cInt* = SslPtr
+  PPasswdCb* = SslPtr
+  EVP_MD* = SslPtr
+  EVP_MD_CTX* = SslPtr
+  EVP_PKEY_CTX* = SslPtr
+  ENGINE* = SslPtr
+  PFunction* = proc () {.cdecl.}
+  DES_cblock* = array[0..7, int8]
+  PDES_cblock* = ptr DES_cblock
+  des_ks_struct*{.final.} = object
+    ks*: DES_cblock
+    weak_key*: cint
+
+  des_key_schedule* = array[1..16, des_ks_struct]
+
+  pem_password_cb* = proc(buf: cstring, size, rwflag: cint, userdata: pointer): cint {.cdecl.}
+
+  PaddingType* = enum
+    RSA_PKCS1_PADDING = 1.cint,
+    RSA_SSLV23_PADDING = 2.cint,
+    RSA_NO_PADDING = 3.cint,
+    RSA_PKCS1_OAEP_PADDING = 4.cint,
+    RSA_X931_PADDING = 5.cint,
+    RSA_PKCS1_PSS_PADDING = 6.cint
+
+
+const
+  SSL_SENT_SHUTDOWN* = 1
+  SSL_RECEIVED_SHUTDOWN* = 2
+  EVP_MAX_MD_SIZE* = 16 + 20
+  SSL_ERROR_NONE* = 0
+  SSL_ERROR_SSL* = 1
+  SSL_ERROR_WANT_READ* = 2
+  SSL_ERROR_WANT_WRITE* = 3
+  SSL_ERROR_WANT_X509_LOOKUP* = 4
+  SSL_ERROR_SYSCALL* = 5      #look at error stack/return value/errno
+  SSL_ERROR_ZERO_RETURN* = 6
+  SSL_ERROR_WANT_CONNECT* = 7
+  SSL_ERROR_WANT_ACCEPT* = 8
+  SSL_CTRL_NEED_TMP_RSA* = 1
+  SSL_CTRL_SET_TMP_RSA* = 2
+  SSL_CTRL_SET_TMP_DH* = 3
+  SSL_CTRL_SET_TMP_ECDH* = 4
+  SSL_CTRL_SET_TMP_RSA_CB* = 5
+  SSL_CTRL_SET_TMP_DH_CB* = 6
+  SSL_CTRL_SET_TMP_ECDH_CB* = 7
+  SSL_CTRL_GET_SESSION_REUSED* = 8
+  SSL_CTRL_GET_CLIENT_CERT_REQUEST* = 9
+  SSL_CTRL_GET_NUM_RENEGOTIATIONS* = 10
+  SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS* = 11
+  SSL_CTRL_GET_TOTAL_RENEGOTIATIONS* = 12
+  SSL_CTRL_GET_FLAGS* = 13
+  SSL_CTRL_EXTRA_CHAIN_CERT* = 14
+  SSL_CTRL_SET_MSG_CALLBACK* = 15
+  SSL_CTRL_SET_MSG_CALLBACK_ARG* = 16 # only applies to datagram connections
+  SSL_CTRL_SET_MTU* = 17      # Stats
+  SSL_CTRL_SESS_NUMBER* = 20
+  SSL_CTRL_SESS_CONNECT* = 21
+  SSL_CTRL_SESS_CONNECT_GOOD* = 22
+  SSL_CTRL_SESS_CONNECT_RENEGOTIATE* = 23
+  SSL_CTRL_SESS_ACCEPT* = 24
+  SSL_CTRL_SESS_ACCEPT_GOOD* = 25
+  SSL_CTRL_SESS_ACCEPT_RENEGOTIATE* = 26
+  SSL_CTRL_SESS_HIT* = 27
+  SSL_CTRL_SESS_CB_HIT* = 28
+  SSL_CTRL_SESS_MISSES* = 29
+  SSL_CTRL_SESS_TIMEOUTS* = 30
+  SSL_CTRL_SESS_CACHE_FULL* = 31
+  SSL_CTRL_OPTIONS* = 32
+  SSL_CTRL_MODE* = 33
+  SSL_CTRL_GET_READ_AHEAD* = 40
+  SSL_CTRL_SET_READ_AHEAD* = 41
+  SSL_CTRL_SET_SESS_CACHE_SIZE* = 42
+  SSL_CTRL_GET_SESS_CACHE_SIZE* = 43
+  SSL_CTRL_SET_SESS_CACHE_MODE* = 44
+  SSL_CTRL_GET_SESS_CACHE_MODE* = 45
+  SSL_CTRL_GET_MAX_CERT_LIST* = 50
+  SSL_CTRL_SET_MAX_CERT_LIST* = 51 #* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
+                                   # * when just a single record has been written): *
+  SSL_CTRL_SET_TLSEXT_SERVERNAME_CB = 53
+  SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG = 54
+  SSL_CTRL_SET_TLSEXT_HOSTNAME = 55
+  SSL_CTRL_SET_ECDH_AUTO* = 94
+  TLSEXT_NAMETYPE_host_name* = 0
+  SSL_TLSEXT_ERR_OK* = 0
+  SSL_TLSEXT_ERR_ALERT_WARNING* = 1
+  SSL_TLSEXT_ERR_ALERT_FATAL* = 2
+  SSL_TLSEXT_ERR_NOACK* = 3
+  SSL_MODE_ENABLE_PARTIAL_WRITE* = 1 #* Make it possible to retry SSL_write() with changed buffer location
+                                     # * (buffer contents must stay the same!); this is not the default to avoid
+                                     # * the misconception that non-blocking SSL_write() behaves like
+                                     # * non-blocking write(): *
+  SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER* = 2 #* Never bother the application with retries if the transport
+                                           # * is blocking: *
+  SSL_MODE_AUTO_RETRY* = 4    #* Don't attempt to automatically build certificate chain *
+  SSL_MODE_NO_AUTO_CHAIN* = 8
+  SSL_OP_NO_SSLv2* = 0x01000000
+  SSL_OP_NO_SSLv3* = 0x02000000
+  SSL_OP_NO_TLSv1* = 0x04000000
+  SSL_OP_NO_TLSv1_1* = 0x08000000
+  SSL_OP_ALL* = 0x000FFFFF
+  SSL_VERIFY_NONE* = 0x00000000
+  SSL_VERIFY_PEER* = 0x00000001
+  SSL_ST_CONNECT* = 0x1000
+  SSL_ST_ACCEPT* = 0x2000
+  SSL_ST_INIT* = SSL_ST_CONNECT or SSL_ST_ACCEPT
+  OPENSSL_DES_DECRYPT* = 0
+  OPENSSL_DES_ENCRYPT* = 1
+  X509_V_OK* = 0
+  X509_V_ILLEGAL* = 1
+  X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT* = 2
+  X509_V_ERR_UNABLE_TO_GET_CRL* = 3
+  X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE* = 4
+  X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE* = 5
+  X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY* = 6
+  X509_V_ERR_CERT_SIGNATURE_FAILURE* = 7
+  X509_V_ERR_CRL_SIGNATURE_FAILURE* = 8
+  X509_V_ERR_CERT_NOT_YET_VALID* = 9
+  X509_V_ERR_CERT_HAS_EXPIRED* = 10
+  X509_V_ERR_CRL_NOT_YET_VALID* = 11
+  X509_V_ERR_CRL_HAS_EXPIRED* = 12
+  X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD* = 13
+  X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD* = 14
+  X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD* = 15
+  X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD* = 16
+  X509_V_ERR_OUT_OF_MEM* = 17
+  X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT* = 18
+  X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN* = 19
+  X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY* = 20
+  X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE* = 21
+  X509_V_ERR_CERT_CHAIN_TOO_LONG* = 22
+  X509_V_ERR_CERT_REVOKED* = 23
+  X509_V_ERR_INVALID_CA* = 24
+  X509_V_ERR_PATH_LENGTH_EXCEEDED* = 25
+  X509_V_ERR_INVALID_PURPOSE* = 26
+  X509_V_ERR_CERT_UNTRUSTED* = 27
+  X509_V_ERR_CERT_REJECTED* = 28 #These are 'informational' when looking for issuer cert
+  X509_V_ERR_SUBJECT_ISSUER_MISMATCH* = 29
+  X509_V_ERR_AKID_SKID_MISMATCH* = 30
+  X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH* = 31
+  X509_V_ERR_KEYUSAGE_NO_CERTSIGN* = 32
+  X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER* = 33
+  X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION* = 34 #The application is not happy
+  X509_V_ERR_APPLICATION_VERIFICATION* = 50
+  SSL_FILETYPE_ASN1* = 2
+  SSL_FILETYPE_PEM* = 1
+  EVP_PKEY_RSA* = 6           # libssl.dll
+
+  BIO_C_SET_CONNECT = 100
+  BIO_C_DO_STATE_MACHINE = 101
+  BIO_C_GET_SSL = 110
+
+proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
+
+# TLS_method(), TLS_server_method(), TLS_client_method() are introduced in 1.1.0
+# and support SSLv3, TLSv1, TLSv1.1 and TLSv1.2
+# SSLv23_method(), SSLv23_server_method(), SSLv23_client_method() are removed in 1.1.0
+
+const useStaticLink = compileOption("dynlibOverride", "ssl") or defined(noOpenSSLHacks)
+
+when useStaticLink:
+  # Static linking
+
+  when defined(openssl10):
+    proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
+    proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSLeay(): culong {.cdecl, dynlib: DLLUtilName, importc.}
+
+    proc getOpenSSLVersion*(): culong =
+      SSLeay()
+
+    proc ERR_load_BIO_strings*() {.cdecl, dynlib: DLLUtilName, importc.}
+  else:
+    proc OPENSSL_init_ssl*(opts: uint64, settings: uint8): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
+    proc SSL_library_init*(): cint {.discardable.} =
+      ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0
+      return OPENSSL_init_ssl(0.uint64, 0.uint8)
+
+    proc TLS_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSLv23_method*(): PSSL_METHOD =
+      TLS_method()
+
+    proc OpenSSL_version_num(): culong {.cdecl, dynlib: DLLUtilName, importc.}
+
+    proc getOpenSSLVersion*(): culong =
+      ## Return OpenSSL version as unsigned long
+      OpenSSL_version_num()
+
+    proc SSL_load_error_strings*() =
+      ## Removed from OpenSSL 1.1.0
+      # This proc prevents breaking existing code calling SslLoadErrorStrings
+      # Static linking against OpenSSL < 1.1.0 is not supported
+      discard
+
+    proc ERR_load_BIO_strings*() =
+      discard
+
+  when defined(libressl) or defined(openssl10):
+    proc SSL_state(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSL_in_init*(ssl: SslPtr): cint {.inline.} =
+      SSL_state(ssl) and SSL_ST_INIT
+  else:
+    proc SSL_in_init*(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSL_CTX_set_ciphersuites*(ctx: SslCtx, str: cstring): cint {.cdecl, dynlib: DLLSSLName, importc.}
+
+  template OpenSSL_add_all_algorithms*() = discard
+
+  proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+  proc SSLv2_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+  proc SSLv3_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
+  proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, dynlib: DLLUtilName, importc.}
+
+else:
+  # Here we're trying to stay compatible between openssl versions. Some
+  # symbols are loaded dynamically and we don't use them if not found.
+  proc thisModule(): LibHandle {.inline.} =
+    var thisMod {.global.}: LibHandle
+    if thisMod.isNil: thisMod = loadLib()
+
+    result = thisMod
+
+  proc sslModule(): LibHandle {.inline, raises: [LibraryError], tags:[RootEffect].} =
+    var sslMod {.global.}: LibHandle
+    try:
+      if sslMod.isNil: sslMod = loadLibPattern(DLLSSLName)
+    except:
+      raise newException(LibraryError, "Could not load SSL using " & DLLSSLName)
+
+    result = sslMod
+
+  proc utilModule(): LibHandle {.inline.} =
+    var utilMod {.global.}: LibHandle
+    if utilMod.isNil: utilMod = loadLibPattern(DLLUtilName)
+
+    result = utilMod
+
+  proc symNullable(dll: LibHandle, name: string, alternativeName = ""): pointer =
+    # Load from DLL.
+    if not dll.isNil:
+      result = symAddr(dll, name)
+      if result.isNil and alternativeName.len > 0:
+        result = symAddr(dll, alternativeName)
+
+    # Attempt to load from current exe.
+    if result.isNil:
+      let thisDynlib = thisModule()
+      if thisDynlib.isNil: return nil
+      result = symAddr(thisDynlib, name)
+      if result.isNil and alternativeName.len > 0:
+        result = symAddr(thisDynlib, alternativeName)
+
+  proc sslSymNullable(name: string, alternativeName = ""): pointer {.raises: [LibraryError], tags:[RootEffect].} =
+    sslModule().symNullable(name, alternativeName)
+
+  proc sslSymThrows(name: string, alternativeName = ""): pointer {.raises: [LibraryError].} =
+    result = sslSymNullable(name, alternativeName)
+    if result.isNil: raiseInvalidLibrary(name)
+
+  proc utilSymNullable(name: string, alternativeName = ""): pointer =
+    utilModule().symNullable(name, alternativeName)
+
+  proc loadPSSLMethod(method1, method2: string): PSSL_METHOD {.raises: [LibraryError], tags:[RootEffect].} =
+    ## Load <method1> from OpenSSL if available, otherwise <method2>
+    ##
+    let methodSym = sslSymNullable(method1, method2)
+    if methodSym.isNil:
+      raise newException(LibraryError, "Could not load " & method1 & " nor " & method2)
+
+    let method2Proc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe, raises: [].}](methodSym)
+    return method2Proc()
+
+  proc CRYPTO_set_mem_functions(a,b,c: pointer) =
+    let theProc = cast[proc(a,b,c: pointer) {.cdecl.}](utilModule().symNullable("CRYPTO_set_mem_functions"))
+    if not theProc.isNil: theProc(a, b, c)
+
+  proc SSL_library_init*(): cint {.discardable.} =
+    ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 otherwise
+    ## SSL_library_init
+    let newInitSym = sslSymNullable("OPENSSL_init_ssl")
+    if not newInitSym.isNil:
+      let newInitProc =
+        cast[proc(opts: uint64, settings: uint8): cint {.cdecl.}](newInitSym)
+      return newInitProc(0, 0)
+    let olderProc = cast[proc(): cint {.cdecl.}](sslSymThrows("SSL_library_init"))
+    if not olderProc.isNil: result = olderProc()
+
+  proc SSL_load_error_strings*() =
+    # TODO: Are we ignoring this on purpose? SSL GitHub CI fails otherwise.
+    let theProc = cast[proc() {.cdecl.}](sslSymNullable("SSL_load_error_strings"))
+    if not theProc.isNil: theProc()
+
+  proc ERR_load_BIO_strings*() =
+    let theProc = cast[proc() {.cdecl.}](utilModule().symNullable("ERR_load_BIO_strings"))
+    if not theProc.isNil: theProc()
+
+  proc SSLv23_client_method*(): PSSL_METHOD =
+    loadPSSLMethod("SSLv23_client_method", "TLS_client_method")
+
+  proc SSLv23_method*(): PSSL_METHOD =
+    loadPSSLMethod("SSLv23_method", "TLS_method")
+
+  proc SSLv2_method*(): PSSL_METHOD =
+    loadPSSLMethod("SSLv2_method", "TLS_method")
+
+  proc SSLv3_method*(): PSSL_METHOD =
+    loadPSSLMethod("SSLv3_method", "TLS_method")
+
+  proc TLS_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_method", "SSLv23_method")
+
+  proc TLS_client_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_client_method", "SSLv23_client_method")
+
+  proc TLS_server_method*(): PSSL_METHOD =
+    loadPSSLMethod("TLS_server_method", "SSLv23_server_method")
+
+  proc OpenSSL_add_all_algorithms*() =
+    # TODO: Are we ignoring this on purpose? SSL GitHub CI fails otherwise.
+    let theProc = cast[proc() {.cdecl.}](sslSymNullable("OPENSSL_add_all_algorithms_conf"))
+    if not theProc.isNil: theProc()
+
+  proc getOpenSSLVersion*(): culong =
+    ## Return OpenSSL version as unsigned long or 0 if not available
+    let theProc = cast[proc(): culong {.cdecl, gcsafe.}](utilSymNullable("OpenSSL_version_num", "SSLeay"))
+    result =
+      if theProc.isNil: 0.culong
+      else: theProc()
+
+  proc SSL_in_init*(ssl: SslPtr): cint =
+    # A compatibility wrapper for `SSL_in_init()` for OpenSSL 1.0, 1.1 and LibreSSL
+    const MainProc = "SSL_in_init"
+    let
+      theProc {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl, gcsafe.}](sslSymNullable(MainProc))
+      # Fallback
+      sslState {.global.} = cast[proc(ssl: SslPtr): cint {.cdecl, gcsafe.}](sslSymNullable("SSL_state"))
+
+    if not theProc.isNil:
+      result = theProc(ssl)
+    elif not sslState.isNil:
+      result = sslState(ssl) and SSL_ST_INIT
+    else:
+      raiseInvalidLibrary MainProc
+
+  proc SSL_CTX_set_ciphersuites*(ctx: SslCtx, str: cstring): cint =
+    var theProc {.global.}: proc(ctx: SslCtx, str: cstring): cint {.cdecl, gcsafe.}
+    if theProc.isNil:
+      theProc = cast[typeof(theProc)](sslSymThrows("SSL_CTX_set_ciphersuites"))
+    result = theProc(ctx, str)
+
+proc SSL_new*(context: SslCtx): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_free*(ssl: SslPtr){.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get_SSL_CTX*(ssl: SslPtr): SslCtx {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_set_SSL_CTX*(ssl: SslPtr, ctx: SslCtx): SslCtx {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_session_id_context*(context: SslCtx, sid_ctx: string, sid_ctx_len: int){.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get0_verified_chain*(ssl: SslPtr): PSTACK {.cdecl, dynlib: DLLSSLName,
+    importc.}
+proc SSL_CTX_new*(meth: PSSL_METHOD): SslCtx{.cdecl,
+    dynlib: DLLSSLName, importc.}
+proc SSL_CTX_load_verify_locations*(ctx: SslCtx, CAfile: cstring,
+    CApath: cstring): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_free*(arg0: SslCtx){.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_verify*(s: SslCtx, mode: int, cb: proc (a: int, b: pointer): int {.cdecl.}){.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get_verify_result*(ssl: SslPtr): int{.cdecl,
+    dynlib: DLLSSLName, importc.}
+
+proc SSL_CTX_set_cipher_list*(s: SslCtx, ciphers: cstring): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_use_certificate_file*(ctx: SslCtx, filename: cstring, typ: cint): cint{.
+    stdcall, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_use_certificate_chain_file*(ctx: SslCtx, filename: cstring): cint{.
+    stdcall, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_use_PrivateKey_file*(ctx: SslCtx,
+    filename: cstring, typ: cint): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_check_private_key*(ctx: SslCtx): cint{.cdecl, dynlib: DLLSSLName,
+    importc.}
+
+proc SSL_CTX_get_ex_new_index*(argl: clong, argp: pointer, new_func: pointer, dup_func: pointer, free_func: pointer): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_ex_data*(ssl: SslCtx, idx: cint, arg: pointer): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_get_ex_data*(ssl: SslCtx, idx: cint): pointer {.cdecl, dynlib: DLLSSLName, importc.}
+
+proc SSL_set_fd*(ssl: SslPtr, fd: SocketHandle): cint{.cdecl, dynlib: DLLSSLName, importc.}
+
+proc SSL_shutdown*(ssl: SslPtr): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_set_shutdown*(ssl: SslPtr, mode: cint) {.cdecl, dynlib: DLLSSLName, importc: "SSL_set_shutdown".}
+proc SSL_get_shutdown*(ssl: SslPtr): cint {.cdecl, dynlib: DLLSSLName, importc: "SSL_get_shutdown".}
+proc SSL_connect*(ssl: SslPtr): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_read*(ssl: SslPtr, buf: pointer, num: int): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_write*(ssl: SslPtr, buf: cstring, num: int): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get_error*(s: SslPtr, ret_code: cint): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_accept*(ssl: SslPtr): cint{.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_pending*(ssl: SslPtr): cint{.cdecl, dynlib: DLLSSLName, importc.}
+
+proc BIO_new_mem_buf*(data: pointer, len: cint): BIO{.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc BIO_new_ssl_connect*(ctx: SslCtx): BIO{.cdecl,
+    dynlib: DLLSSLName, importc.}
+proc BIO_ctrl*(bio: BIO, cmd: cint, larg: int, arg: cstring): int{.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc BIO_get_ssl*(bio: BIO, ssl: ptr SslPtr): int =
+  return BIO_ctrl(bio, BIO_C_GET_SSL, 0, cast[cstring](ssl))
+proc BIO_set_conn_hostname*(bio: BIO, name: cstring): int =
+  return BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, name)
+proc BIO_do_handshake*(bio: BIO): int =
+  return BIO_ctrl(bio, BIO_C_DO_STATE_MACHINE, 0, nil)
+proc BIO_do_connect*(bio: BIO): int =
+  return BIO_do_handshake(bio)
+
+proc BIO_read*(b: BIO, data: cstring, length: cint): cint{.cdecl, dynlib: DLLUtilName, importc.}
+proc BIO_write*(b: BIO, data: cstring, length: cint): cint{.cdecl, dynlib: DLLUtilName, importc.}
+
+proc BIO_free*(b: BIO): cint{.cdecl, dynlib: DLLUtilName, importc.}
+
+proc ERR_print_errors_fp*(fp: File){.cdecl, dynlib: DLLUtilName, importc.}
+
+proc ERR_error_string*(e: culong, buf: cstring): cstring{.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc ERR_get_error*(): culong{.cdecl, dynlib: DLLUtilName, importc.}
+proc ERR_peek_last_error*(): culong{.cdecl, dynlib: DLLUtilName, importc.}
+
+proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLUtilName, importc.}
+
+proc OPENSSL_sk_num*(stack: PSTACK): int {.cdecl, dynlib: DLLSSLName, importc.}
+
+proc OPENSSL_sk_value*(stack: PSTACK, index: int): pointer {.cdecl,
+    dynlib: DLLSSLName, importc.}
+
+proc d2i_X509*(px: ptr PX509, i: ptr ptr uint8, len: cint): PX509 {.cdecl,
+    dynlib: DLLUtilName, importc.}
+
+proc i2d_X509*(cert: PX509; o: ptr ptr uint8): cint {.cdecl,
+    dynlib: DLLUtilName, importc.}
+
+proc d2i_X509*(b: string): PX509 =
+  ## decode DER/BER bytestring into X.509 certificate struct
+  var bb = b.cstring
+  let i = cast[ptr ptr uint8](addr bb)
+  let ret = d2i_X509(addr result, i, b.len.cint)
+  if ret.isNil:
+    raise newException(Exception, "X.509 certificate decoding failed")
+
+proc i2d_X509*(cert: PX509): string =
+  ## encode `cert` to DER string
+  let encoded_length = i2d_X509(cert, nil)
+  result = newString(encoded_length)
+  var q = result.cstring
+  let o = cast[ptr ptr uint8](addr q)
+  let length = i2d_X509(cert, o)
+  if length.int <= 0:
+    raise newException(Exception, "X.509 certificate encoding failed")
+
+const
+  useNimsAlloc = not defined(nimNoAllocForSSL) and not defined(gcDestructors)
+
+when not useWinVersion and not defined(macosx) and not defined(android) and useNimsAlloc:
+  proc allocWrapper(size: int): pointer {.cdecl.} = allocShared(size)
+  proc reallocWrapper(p: pointer; newSize: int): pointer {.cdecl.} =
+    if p == nil:
+      if newSize > 0: result = allocShared(newSize)
+    elif newSize == 0: deallocShared(p)
+    else: result = reallocShared(p, newSize)
+  proc deallocWrapper(p: pointer) {.cdecl.} =
+    if p != nil: deallocShared(p)
+
+  proc CRYPTO_malloc_init*() =
+    CRYPTO_set_mem_functions(cast[pointer](allocWrapper), cast[pointer](reallocWrapper), cast[pointer](deallocWrapper))
+else:
+  proc CRYPTO_malloc_init*() =
+    discard
+
+proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cint, larg: clong, parg: pointer): clong{.
+  cdecl, dynlib: DLLSSLName, importc.}
+
+proc SSL_CTX_callback_ctrl(ctx: SslCtx, typ: cint, fp: PFunction): int{.
+  cdecl, dynlib: DLLSSLName, importc.}
+
+proc SSLCTXSetMode*(ctx: SslCtx, mode: int): int =
+  result = SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, clong mode, nil)
+
+proc SSL_ctrl*(ssl: SslPtr, cmd: cint, larg: int, parg: pointer): int{.
+  cdecl, dynlib: DLLSSLName, importc.}
+
+proc SSL_set_tlsext_host_name*(ssl: SslPtr, name: cstring): int =
+  ## Set the SNI server name extension to be used in a client hello.
+  ## Returns 1 if SNI was set, 0 if current SSL configuration doesn't support SNI.
+  result = SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name)
+
+proc SSL_get_servername*(ssl: SslPtr, typ: cint = TLSEXT_NAMETYPE_host_name): cstring {.cdecl, dynlib: DLLSSLName, importc.}
+  ## Retrieve the server name requested in the client hello. This can be used
+  ## in the callback set in `SSL_CTX_set_tlsext_servername_callback` to
+  ## implement virtual hosting. May return `nil`.
+
+proc SSL_CTX_set_tlsext_servername_callback*(ctx: SslCtx, cb: proc(ssl: SslPtr, cb_id: int, arg: pointer): int {.cdecl.}): int =
+  ## Set the callback to be used on listening SSL connections when the client hello is received.
+  ##
+  ## The callback should return one of:
+  ## * SSL_TLSEXT_ERR_OK
+  ## * SSL_TLSEXT_ERR_ALERT_WARNING
+  ## * SSL_TLSEXT_ERR_ALERT_FATAL
+  ## * SSL_TLSEXT_ERR_NOACK
+  result = SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, cast[PFunction](cb))
+
+proc SSL_CTX_set_tlsext_servername_arg*(ctx: SslCtx, arg: pointer): int =
+  ## Set the pointer to be used in the callback registered to `SSL_CTX_set_tlsext_servername_callback`.
+  result = SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, arg)
+
+type
+  PskClientCallback* = proc (ssl: SslPtr;
+    hint: cstring; identity: cstring; max_identity_len: cuint; psk: ptr uint8;
+    max_psk_len: cuint): cuint {.cdecl.}
+
+  PskServerCallback* = proc (ssl: SslPtr;
+    identity: cstring; psk: ptr uint8; max_psk_len: cint): cuint {.cdecl.}
+
+proc SSL_CTX_set_psk_client_callback*(ctx: SslCtx; callback: PskClientCallback) {.cdecl, dynlib: DLLSSLName, importc.}
+  ## Set callback called when OpenSSL needs PSK (for client).
+
+proc SSL_CTX_set_psk_server_callback*(ctx: SslCtx; callback: PskServerCallback) {.cdecl, dynlib: DLLSSLName, importc.}
+  ## Set callback called when OpenSSL needs PSK (for server).
+
+proc SSL_CTX_use_psk_identity_hint*(ctx: SslCtx; hint: cstring): cint {.cdecl, dynlib: DLLSSLName, importc.}
+  ## Set PSK identity hint to use.
+
+proc SSL_get_psk_identity*(ssl: SslPtr): cstring {.cdecl, dynlib: DLLSSLName, importc.}
+  ## Get PSK identity.
+
+proc SSL_CTX_set_ecdh_auto*(ctx: SslCtx, onoff: cint): cint {.inline.} =
+  ## Set automatic curve selection.
+  ##
+  ## On OpenSSL >= 1.1.0 this is on by default and cannot be disabled.
+  if getOpenSSLVersion() < 0x010100000 or getOpenSSLVersion() == 0x020000000:
+    result = cint SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff, nil)
+  else:
+    result = 1
+
+proc bioNew*(b: PBIO_METHOD): BIO{.cdecl, dynlib: DLLUtilName, importc: "BIO_new".}
+proc bioFreeAll*(b: BIO){.cdecl, dynlib: DLLUtilName, importc: "BIO_free_all".}
+proc bioSMem*(): PBIO_METHOD{.cdecl, dynlib: DLLUtilName, importc: "BIO_s_mem".}
+proc bioCtrlPending*(b: BIO): cint{.cdecl, dynlib: DLLUtilName, importc: "BIO_ctrl_pending".}
+proc bioRead*(b: BIO, Buf: cstring, length: cint): cint{.cdecl,
+    dynlib: DLLUtilName, importc: "BIO_read".}
+proc bioWrite*(b: BIO, Buf: cstring, length: cint): cint{.cdecl,
+    dynlib: DLLUtilName, importc: "BIO_write".}
+
+proc sslSetConnectState*(s: SslPtr) {.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_set_connect_state".}
+proc sslSetAcceptState*(s: SslPtr) {.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_set_accept_state".}
+
+proc sslRead*(ssl: SslPtr, buf: cstring, num: cint): cint{.cdecl,
+      dynlib: DLLSSLName, importc: "SSL_read".}
+proc sslPeek*(ssl: SslPtr, buf: cstring, num: cint): cint{.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_peek".}
+proc sslWrite*(ssl: SslPtr, buf: cstring, num: cint): cint{.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_write".}
+
+proc sslSetBio*(ssl: SslPtr, rbio, wbio: BIO) {.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_set_bio".}
+
+proc sslDoHandshake*(ssl: SslPtr): cint {.cdecl,
+    dynlib: DLLSSLName, importc: "SSL_do_handshake".}
+
+
+proc ErrClearError*(){.cdecl, dynlib: DLLUtilName, importc: "ERR_clear_error".}
+proc ErrFreeStrings*(){.cdecl, dynlib: DLLUtilName, importc: "ERR_free_strings".}
+proc ErrRemoveState*(pid: cint){.cdecl, dynlib: DLLUtilName, importc: "ERR_remove_state".}
+
+proc PEM_read_bio_RSA_PUBKEY*(bp: BIO, x: ptr PRSA, pw: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc PEM_read_RSA_PUBKEY*(fp: pointer; x: ptr PRSA; cb: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_verify*(kind: cint, origMsg: pointer, origMsgLen: cuint, signature: pointer,
+    signatureLen: cuint, rsa: PRSA): cint {.cdecl, dynlib: DLLUtilName, importc.}
+proc PEM_read_RSAPrivateKey*(fp: pointer; x: ptr PRSA; cb: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc PEM_read_RSAPublicKey*(fp: pointer; x: ptr PRSA; cb: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc PEM_read_bio_RSAPublicKey*(bp: BIO, x: ptr PRSA, cb: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc PEM_read_bio_RSAPrivateKey*(bp: BIO, x: ptr PRSA, cb: pem_password_cb, u: pointer): PRSA {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_private_encrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_public_encrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_private_decrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_public_decrypt*(flen: cint, fr: ptr uint8, to: ptr uint8, rsa: PRSA, padding: PaddingType): cint {.cdecl,
+    dynlib: DLLUtilName, importc.}
+proc RSA_free*(rsa: PRSA) {.cdecl, dynlib: DLLUtilName, importc.}
+proc RSA_size*(rsa: PRSA): cint {.cdecl, dynlib: DLLUtilName, importc.}
+
+# sha types
+proc EVP_md_null*(): EVP_MD   {.lcrypto.}
+proc EVP_md2*(): EVP_MD       {.lcrypto.}
+proc EVP_md4*(): EVP_MD       {.lcrypto.}
+proc EVP_md5*(): EVP_MD       {.lcrypto.}
+proc EVP_sha*(): EVP_MD       {.lcrypto.}
+proc EVP_sha1*(): EVP_MD      {.lcrypto.}
+proc EVP_dss*(): EVP_MD       {.lcrypto.}
+proc EVP_dss1*(): EVP_MD      {.lcrypto.}
+proc EVP_ecdsa*(): EVP_MD     {.lcrypto.}
+proc EVP_sha224*(): EVP_MD    {.lcrypto.}
+proc EVP_sha256*(): EVP_MD    {.lcrypto.}
+proc EVP_sha384*(): EVP_MD    {.lcrypto.}
+proc EVP_sha512*(): EVP_MD    {.lcrypto.}
+proc EVP_mdc2*(): EVP_MD      {.lcrypto.}
+proc EVP_ripemd160*(): EVP_MD {.lcrypto.}
+proc EVP_whirlpool*(): EVP_MD {.lcrypto.}
+proc EVP_MD_size*(md: EVP_MD): cint {.lcrypto.}
+
+# hmac functions
+proc HMAC*(evp_md: EVP_MD; key: pointer; key_len: cint; d: cstring; n: csize_t; md: cstring; md_len: ptr cuint): cstring {.lcrypto.}
+
+# RSA key functions
+proc PEM_read_bio_PrivateKey*(bp: BIO, x: ptr EVP_PKEY, cb: pointer, u: pointer): EVP_PKEY {.lcrypto.}
+proc EVP_PKEY_free*(p: EVP_PKEY)  {.lcrypto.}
+proc EVP_DigestSignInit*(ctx: EVP_MD_CTX, pctx: ptr EVP_PKEY_CTX, typ: EVP_MD, e: ENGINE, pkey: EVP_PKEY): cint {.lcrypto.}
+proc EVP_DigestInit_ex*(ctx: EVP_MD_CTX, typ: EVP_MD, engine: SslPtr = nil): cint {.lcrypto.}
+proc EVP_DigestUpdate*(ctx: EVP_MD_CTX, data: pointer, len: cuint): cint {.lcrypto.}
+proc EVP_DigestFinal_ex*(ctx: EVP_MD_CTX, buffer: pointer, size: ptr cuint): cint {.lcrypto.}
+proc EVP_DigestSignFinal*(ctx: EVP_MD_CTX, data: pointer, len: ptr csize_t): cint {.lcrypto.}
+proc EVP_PKEY_CTX_new*(pkey: EVP_PKEY, e: ENGINE): EVP_PKEY_CTX {.lcrypto.}
+proc EVP_PKEY_CTX_free*(pkeyCtx: EVP_PKEY_CTX) {.lcrypto.}
+proc EVP_PKEY_sign_init*(c: EVP_PKEY_CTX): cint {.lcrypto.}
+
+when defined(macosx) or defined(windows):
+  proc EVP_MD_CTX_create*(): EVP_MD_CTX {.lcrypto.}
+  proc EVP_MD_CTX_destroy*(ctx: EVP_MD_CTX) {.lcrypto.}
+  proc EVP_MD_CTX_cleanup*(ctx: EVP_MD_CTX): cint {.lcrypto.}
+else:
+  # some times you will need this instead:
+  proc EVP_MD_CTX_create*(): EVP_MD_CTX {.cdecl, importc: "EVP_MD_CTX_new", dynlib: DLLUtilName.}
+  proc EVP_MD_CTX_destroy*(ctx: EVP_MD_CTX) {.cdecl, importc: "EVP_MD_CTX_free", dynlib: DLLUtilName.}
+  proc EVP_MD_CTX_cleanup*(ctx: EVP_MD_CTX): cint {.cdecl, importc: "EVP_MD_CTX_cleanup", dynlib: DLLUtilName.}
+
+# <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
+
+{.push callconv:cdecl, dynlib:DLLUtilName.}
+proc md5_Init*(c: var MD5_CTX): cint{.importc: "MD5_Init".}
+proc md5_Update*(c: var MD5_CTX; data: pointer; len: csize_t): cint{.importc: "MD5_Update".}
+proc md5_Final*(md: cstring; c: var MD5_CTX): cint{.importc: "MD5_Final".}
+proc md5*(d: ptr uint8; n: csize_t; md: ptr uint8): ptr uint8{.importc: "MD5".}
+proc md5_Transform*(c: var MD5_CTX; b: ptr uint8){.importc: "MD5_Transform".}
+{.pop.}
+
+from std/strutils import toHex, toLowerAscii
+
+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).toLowerAscii
+
+proc md5_File*(file: string): string {.raises: [IOError,Exception].} =
+  ## 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); bytes > 0):
+    discard md5_Update(ctx, buf[0].addr, cast[csize_t](bytes))
+
+  discard md5_Final(cast[cstring](buf[0].addr), ctx)
+  f.close
+
+  result = hexStr(cast[cstring](addr buf))
+
+proc md5_Str*(str: string): string =
+  ## 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, cast[csize_t](L))
+    i += L
+
+  discard md5_Final(cast[cstring](addr res), ctx)
+  result = hexStr(cast[cstring](addr res))
+
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+
+# Certificate validation
+# On old openSSL version some of these symbols are not available
+when not defined(nimDisableCertificateValidation) and not defined(windows):
+
+  # SSL_get_peer_certificate removed in 3.0
+  # SSL_get1_peer_certificate added in 3.0
+  when useOpenssl3:
+    proc SSL_get1_peer_certificate*(ssl: SslCtx): PX509 {.cdecl, dynlib: DLLSSLName, importc.}
+    proc SSL_get_peer_certificate*(ssl: SslCtx): PX509 =
+      SSL_get1_peer_certificate(ssl)
+  elif useStaticLink:
+    proc SSL_get_peer_certificate*(ssl: SslCtx): PX509 {.cdecl, dynlib: DLLSSLName, importc.}
+  else:
+    proc SSL_get_peer_certificate*(ssl: SslCtx): PX509 =
+      let methodSym = sslSymNullable("SSL_get_peer_certificate", "SSL_get1_peer_certificate")
+      if methodSym.isNil:
+        raise newException(LibraryError, "Could not load SSL_get_peer_certificate or SSL_get1_peer_certificate")
+      let method2Proc = cast[proc(ssl: SslCtx): PX509 {.cdecl, gcsafe, raises: [].}](methodSym)
+      return method2Proc(ssl)
+
+  proc X509_get_subject_name*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLSSLName, importc.}
+
+  proc X509_get_issuer_name*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName, importc.}
+
+  proc X509_NAME_oneline*(a: PX509_NAME, buf: cstring, size: cint): cstring {.
+    cdecl, dynlib:DLLSSLName, importc.}
+
+  proc X509_NAME_get_text_by_NID*(subject:cstring, NID: cint, buf: cstring, size: cint): cint{.
+    cdecl, dynlib:DLLSSLName, importc.}
+
+  proc X509_check_host*(cert: PX509, name: cstring, namelen: cint, flags:cuint, peername: cstring): cint {.cdecl, dynlib: DLLSSLName, importc.}
+
+  proc X509_free*(cert: PX509) {.cdecl, dynlib: DLLSSLName, importc.}
+
+  # Certificates store
+
+  type PX509_STORE* = SslPtr
+  type PX509_OBJECT* = SslPtr
+
+  {.push callconv:cdecl, dynlib:DLLUtilName, importc.}
+
+  proc X509_OBJECT_new*(): PX509_OBJECT
+  proc X509_OBJECT_free*(a: PX509_OBJECT)
+
+  proc X509_STORE_new*(): PX509_STORE
+  proc X509_STORE_free*(v: PX509_STORE)
+  proc X509_STORE_lock*(ctx: PX509_STORE): cint
+  proc X509_STORE_unlock*(ctx: PX509_STORE): cint
+  proc X509_STORE_up_ref*(v: PX509_STORE): cint
+  proc X509_STORE_set_flags*(ctx: PX509_STORE; flags: culong): cint
+  proc X509_STORE_set_purpose*(ctx: PX509_STORE; purpose: cint): cint
+  proc X509_STORE_set_trust*(ctx: PX509_STORE; trust: cint): cint
+  proc X509_STORE_add_cert*(ctx: PX509_STORE; x: PX509): cint
+
+  {.pop.}
+
+  when isMainModule:
+    when defined(nimPreviewSlimSystem):
+      import std/assertions
+    # A simple certificate test
+    let certbytes = readFile("certificate.der")
+    let cert = d2i_X509(certbytes)
+    let encoded = cert.i2d_X509()
+    assert encoded == certbytes
+
+# Application Layer Protocol Negociation extension (TLS-ALPN, RFC7301)
+# Available in at least OpenSSL 1.1.1 and later, not sure if earlier
+# --Iced Quinn
+
+proc SSL_CTX_set_alpn_protos*(ctx: SslCtx; protos: cstring; protos_len: cuint): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_set_alpn_protos*(ssl: SslPtr; protos: cstring; protos_len: cuint): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_alpn_select_cb*(ctx: SslCtx; cb: proc(ssl: SslPtr; out_proto: ptr cstring; outlen: cstring; in_proto: cstring; inlen: cuint; arg: pointer): cint {.cdecl.}; arg: pointer): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get0_alpn_selected*(ssl: SslPtr; data: ptr cstring; len: ptr cuint) {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_next_protos_advertised_cb*(ctx: SslCtx; cb: proc(ssl: SslPtr; out_proto: ptr cstring; outlen: ptr cuint; arg: pointer): cint {.cdecl.}; arg: pointer) {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_CTX_set_next_proto_select_cb*(ctx: SslCtx; cb: proc(s: SslPtr; out_proto: cstring; outlen: cstring; in_proto: cstring; inlen: cuint; arg: pointer): cint {.cdecl.}; arg: pointer) {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_select_next_proto*(out_proto: ptr cstring; outlen: cstring; server: cstring; server_len: cuint; client: cstring; client_len: cuint): cint {.cdecl, dynlib: DLLSSLName, importc.}
+proc SSL_get0_next_proto_negotiated*(s: SslPtr; data: ptr cstring; len: ptr cuint) {.cdecl, dynlib: DLLSSLName, importc.}
+
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
new file mode 100644
index 000000000..9144f6784
--- /dev/null
+++ b/lib/wrappers/pcre.nim
@@ -0,0 +1,473 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# The current PCRE version information.
+
+const
+  PCRE_MAJOR* = 8
+  PCRE_MINOR* = 36
+  PCRE_PRERELEASE* = true
+  PCRE_DATE* = "2014-09-26"
+
+# When an application links to a PCRE DLL in Windows, the symbols that are
+# imported have to be identified as such. When building PCRE, the appropriate
+# export setting is defined in pcre_internal.h, which includes this file. So we
+# don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL.
+
+# By default, we use the standard "extern" declarations.
+
+# Allow for C++ users
+
+# Public options. Some are compile-time only, some are run-time only, and some
+# are both. Most of the compile-time options are saved with the compiled regex
+# so that they can be inspected during studying (and therefore JIT compiling).
+# Note that pcre_study() has its own set of options. Originally, all the options
+# defined here used distinct bits. However, almost all the bits in a 32-bit word
+# are now used, so in order to conserve them, option bits that were previously
+# only recognized at matching time (i.e. by pcre_exec() or pcre_dfa_exec()) may
+# also be used for compile-time options that affect only compiling and are not
+# relevant for studying or JIT compiling.
+#
+# Some options for pcre_compile() change its behaviour but do not affect the
+# behaviour of the execution functions. Other options are passed through to the
+# execution functions and affect their behaviour, with or without affecting the
+# behaviour of pcre_compile().
+#
+# Options that can be passed to pcre_compile() are tagged Cx below, with these
+# variants:
+#
+# C1   Affects compile only
+# C2   Does not affect compile; affects exec, dfa_exec
+# C3   Affects compile, exec, dfa_exec
+# C4   Affects compile, exec, dfa_exec, study
+# C5   Affects compile, exec, study
+#
+# Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged
+# with E and D, respectively. They take precedence over C3, C4, and C5 settings
+# passed from pcre_compile(). Those that are compatible with JIT execution are
+# flagged with J.
+
+const
+  CASELESS*          = 0x00000001  # C1
+  MULTILINE*         = 0x00000002  # C1
+  DOTALL*            = 0x00000004  # C1
+  EXTENDED*          = 0x00000008  # C1
+  ANCHORED*          = 0x00000010  # C4 E D
+  DOLLAR_ENDONLY*    = 0x00000020  # C2
+  EXTRA*             = 0x00000040  # C1
+  NOTBOL*            = 0x00000080  #    E D J
+  NOTEOL*            = 0x00000100  #    E D J
+  UNGREEDY*          = 0x00000200  # C1
+  NOTEMPTY*          = 0x00000400  #    E D J
+  UTF8*              = 0x00000800  # C4        )
+  UTF16*             = 0x00000800  # C4        ) Synonyms
+  UTF32*             = 0x00000800  # C4        )
+  NO_AUTO_CAPTURE*   = 0x00001000  # C1
+  NO_UTF8_CHECK*     = 0x00002000  # C1 E D J  )
+  NO_UTF16_CHECK*    = 0x00002000  # C1 E D J  ) Synonyms
+  NO_UTF32_CHECK*    = 0x00002000  # C1 E D J  )
+  AUTO_CALLOUT*      = 0x00004000  # C1
+  PARTIAL_SOFT*      = 0x00008000  #    E D J  ) Synonyms
+  PARTIAL*           = 0x00008000  #    E D J  )
+
+# This pair use the same bit.
+const
+  NEVER_UTF*         = 0x00010000  # C1        ) Overlaid
+  DFA_SHORTEST*      = 0x00010000  #      D    ) Overlaid
+
+# This pair use the same bit.
+const
+  NO_AUTO_POSSESS*   = 0x00020000  # C1        ) Overlaid
+  DFA_RESTART*       = 0x00020000  #      D    ) Overlaid
+
+const
+  FIRSTLINE*         = 0x00040000  # C3
+  DUPNAMES*          = 0x00080000  # C1
+  NEWLINE_CR*        = 0x00100000  # C3 E D
+  NEWLINE_LF*        = 0x00200000  # C3 E D
+  NEWLINE_CRLF*      = 0x00300000  # C3 E D
+  NEWLINE_ANY*       = 0x00400000  # C3 E D
+  NEWLINE_ANYCRLF*   = 0x00500000  # C3 E D
+  BSR_ANYCRLF*       = 0x00800000  # C3 E D
+  BSR_UNICODE*       = 0x01000000  # C3 E D
+  JAVASCRIPT_COMPAT* = 0x02000000  # C5
+  NO_START_OPTIMIZE* = 0x04000000  # C2 E D    ) Synonyms
+  NO_START_OPTIMISE* = 0x04000000  # C2 E D    )
+  PARTIAL_HARD*      = 0x08000000  #    E D J
+  NOTEMPTY_ATSTART*  = 0x10000000  #    E D J
+  UCP*               = 0x20000000  # C3
+
+# Exec-time and get/set-time error codes
+const
+  ERROR_NOMATCH*          =  -1
+  ERROR_NULL*             =  -2
+  ERROR_BADOPTION*        =  -3
+  ERROR_BADMAGIC*         =  -4
+  ERROR_UNKNOWN_OPCODE*   =  -5
+  ERROR_UNKNOWN_NODE*     =  -5 ## For backward compatibility
+  ERROR_NOMEMORY*         =  -6
+  ERROR_NOSUBSTRING*      =  -7
+  ERROR_MATCHLIMIT*       =  -8
+  ERROR_CALLOUT*          =  -9 ## Never used by PCRE itself
+  ERROR_BADUTF8*          = -10 ## Same for 8/16/32
+  ERROR_BADUTF16*         = -10 ## Same for 8/16/32
+  ERROR_BADUTF32*         = -10 ## Same for 8/16/32
+  ERROR_BADUTF8_OFFSET*   = -11 ## Same for 8/16
+  ERROR_BADUTF16_OFFSET*  = -11 ## Same for 8/16
+  ERROR_PARTIAL*          = -12
+  ERROR_BADPARTIAL*       = -13
+  ERROR_INTERNAL*         = -14
+  ERROR_BADCOUNT*         = -15
+  ERROR_DFA_UITEM*        = -16
+  ERROR_DFA_UCOND*        = -17
+  ERROR_DFA_UMLIMIT*      = -18
+  ERROR_DFA_WSSIZE*       = -19
+  ERROR_DFA_RECURSE*      = -20
+  ERROR_RECURSIONLIMIT*   = -21
+  ERROR_NULLWSLIMIT*      = -22 ## No longer actually used
+  ERROR_BADNEWLINE*       = -23
+  ERROR_BADOFFSET*        = -24
+  ERROR_SHORTUTF8*        = -25
+  ERROR_SHORTUTF16*       = -25 ## Same for 8/16
+  ERROR_RECURSELOOP*      = -26
+  ERROR_JIT_STACKLIMIT*   = -27
+  ERROR_BADMODE*          = -28
+  ERROR_BADENDIANNESS*    = -29
+  ERROR_DFA_BADRESTART*   = -30
+  ERROR_JIT_BADOPTION*    = -31
+  ERROR_BADLENGTH*        = -32
+  ERROR_UNSET*            = -33
+
+# Specific error codes for UTF-8 validity checks
+const
+  UTF8_ERR0*  =  0
+  UTF8_ERR1*  =  1
+  UTF8_ERR2*  =  2
+  UTF8_ERR3*  =  3
+  UTF8_ERR4*  =  4
+  UTF8_ERR5*  =  5
+  UTF8_ERR6*  =  6
+  UTF8_ERR7*  =  7
+  UTF8_ERR8*  =  8
+  UTF8_ERR9*  =  9
+  UTF8_ERR10* = 10
+  UTF8_ERR11* = 11
+  UTF8_ERR12* = 12
+  UTF8_ERR13* = 13
+  UTF8_ERR14* = 14
+  UTF8_ERR15* = 15
+  UTF8_ERR16* = 16
+  UTF8_ERR17* = 17
+  UTF8_ERR18* = 18
+  UTF8_ERR19* = 19
+  UTF8_ERR20* = 20
+  UTF8_ERR21* = 21
+  UTF8_ERR22* = 22 # Unused (was non-character)
+
+# Specific error codes for UTF-16 validity checks
+const
+  UTF16_ERR0* = 0
+  UTF16_ERR1* = 1
+  UTF16_ERR2* = 2
+  UTF16_ERR3* = 3
+  UTF16_ERR4* = 4 # Unused (was non-character)
+
+# Specific error codes for UTF-32 validity checks
+const
+  UTF32_ERR0* = 0
+  UTF32_ERR1* = 1
+  UTF32_ERR2* = 2 # Unused (was non-character)
+  UTF32_ERR3* = 3
+
+# Request types for pcre_fullinfo()
+const
+  INFO_OPTIONS*             =  0
+  INFO_SIZE*                =  1
+  INFO_CAPTURECOUNT*        =  2
+  INFO_BACKREFMAX*          =  3
+  INFO_FIRSTBYTE*           =  4
+  INFO_FIRSTCHAR*           =  4 ## For backwards compatibility
+  INFO_FIRSTTABLE*          =  5
+  INFO_LASTLITERAL*         =  6
+  INFO_NAMEENTRYSIZE*       =  7
+  INFO_NAMECOUNT*           =  8
+  INFO_NAMETABLE*           =  9
+  INFO_STUDYSIZE*           = 10
+  INFO_DEFAULT_TABLES*      = 11
+  INFO_OKPARTIAL*           = 12
+  INFO_JCHANGED*            = 13
+  INFO_HASCRORLF*           = 14
+  INFO_MINLENGTH*           = 15
+  INFO_JIT*                 = 16
+  INFO_JITSIZE*             = 17
+  INFO_MAXLOOKBEHIND*       = 18
+  INFO_FIRSTCHARACTER*      = 19
+  INFO_FIRSTCHARACTERFLAGS* = 20
+  INFO_REQUIREDCHAR*        = 21
+  INFO_REQUIREDCHARFLAGS*   = 22
+  INFO_MATCHLIMIT*          = 23
+  INFO_RECURSIONLIMIT*      = 24
+  INFO_MATCH_EMPTY*         = 25
+
+# Request types for pcre_config(). Do not re-arrange, in order to remain
+# compatible.
+const
+  CONFIG_UTF8*                   =  0
+  CONFIG_NEWLINE*                =  1
+  CONFIG_LINK_SIZE*              =  2
+  CONFIG_POSIX_MALLOC_THRESHOLD* =  3
+  CONFIG_MATCH_LIMIT*            =  4
+  CONFIG_STACKRECURSE*           =  5
+  CONFIG_UNICODE_PROPERTIES*     =  6
+  CONFIG_MATCH_LIMIT_RECURSION*  =  7
+  CONFIG_BSR*                    =  8
+  CONFIG_JIT*                    =  9
+  CONFIG_UTF16*                  = 10
+  CONFIG_JITTARGET*              = 11
+  CONFIG_UTF32*                  = 12
+  CONFIG_PARENS_LIMIT*           = 13
+
+# Request types for pcre_study(). Do not re-arrange, in order to remain
+# compatible.
+const
+  STUDY_JIT_COMPILE*              = 0x0001
+  STUDY_JIT_PARTIAL_SOFT_COMPILE* = 0x0002
+  STUDY_JIT_PARTIAL_HARD_COMPILE* = 0x0004
+  STUDY_EXTRA_NEEDED*             = 0x0008
+
+# Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine
+# these bits, just add new ones on the end, in order to remain compatible.
+const
+  EXTRA_STUDY_DATA*            = 0x0001
+  EXTRA_MATCH_LIMIT*           = 0x0002
+  EXTRA_CALLOUT_DATA*          = 0x0004
+  EXTRA_TABLES*                = 0x0008
+  EXTRA_MATCH_LIMIT_RECURSION* = 0x0010
+  EXTRA_MARK*                  = 0x0020
+  EXTRA_EXECUTABLE_JIT*        = 0x0040
+
+# Types
+type
+  Pcre* = object
+  Pcre16* = object
+  Pcre32* = object
+  JitStack* = object
+  JitStack16* = object
+  JitStack32* = object
+
+when defined(nimHasStyleChecks):
+  {.push styleChecks: off.}
+
+# The structure for passing additional data to pcre_exec(). This is defined in
+# such as way as to be extensible. Always add new fields at the end, in order
+# to remain compatible.
+type
+  ExtraData* = object
+    flags*: clong                  ## Bits for which fields are set
+    study_data*: pointer           ## Opaque data from pcre_study()
+    match_limit*: clong            ## Maximum number of calls to match()
+    callout_data*: pointer         ## Data passed back in callouts
+    tables*: pointer               ## Pointer to character tables
+    match_limit_recursion*: clong  ## Max recursive calls to match()
+    mark*: pointer                 ## For passing back a mark pointer
+    executable_jit*: pointer       ## Contains a pointer to a compiled jit code
+
+# The structure for passing out data via the pcre_callout_function. We use a
+# structure so that new fields can be added on the end in future versions,
+# without changing the API of the function, thereby allowing old clients to
+# work without modification.
+type
+  CalloutBlock* = object
+    version*         : cint       ## Identifies version of block
+    # ------------------------ Version 0 -------------------------------
+    callout_number*  : cint       ## Number compiled into pattern
+    offset_vector*   : ptr cint   ## The offset vector
+    subject*         : cstring    ## The subject being matched
+    subject_length*  : cint       ## The length of the subject
+    start_match*     : cint       ## Offset to start of this match attempt
+    current_position*: cint       ## Where we currently are in the subject
+    capture_top*     : cint       ## Max current capture
+    capture_last*    : cint       ## Most recently closed capture
+    callout_data*    : pointer    ## Data passed in with the call
+    # ------------------- Added for Version 1 --------------------------
+    pattern_position*: cint       ## Offset to next item in the pattern
+    next_item_length*: cint       ## Length of next item in the pattern
+    # ------------------- Added for Version 2 --------------------------
+    mark*            : pointer    ## Pointer to current mark or NULL
+    # ------------------------------------------------------------------
+
+when defined(nimHasStyleChecks):
+  {.pop.}
+
+# User defined callback which provides a stack just before the match starts.
+type
+  JitCallback* = proc (a: pointer): ptr JitStack {.cdecl.}
+
+
+when not defined(usePcreHeader):
+  when hostOS == "windows":
+    when defined(nimOldDlls):
+      const pcreDll = "pcre.dll"
+    elif defined(cpu64):
+      const pcreDll = "pcre64.dll"
+    else:
+      const pcreDll = "pcre32.dll"
+  elif hostOS == "macosx":
+    const pcreDll = "libpcre(.3|.1|).dylib"
+  else:
+    const pcreDll = "libpcre.so(.3|.1|)"
+  {.push dynlib: pcreDll.}
+else:
+  {.push header: "<pcre.h>".}
+
+{.push cdecl, importc: "pcre_$1".}
+
+# Exported PCRE functions
+
+proc compile*(pattern: cstring,
+              options: cint,
+              errptr: ptr cstring,
+              erroffset: ptr cint,
+              tableptr: pointer): ptr Pcre
+
+proc compile2*(pattern: cstring,
+               options: cint,
+               errorcodeptr: ptr cint,
+               errptr: ptr cstring,
+               erroffset: ptr cint,
+               tableptr: pointer): ptr Pcre
+
+proc config*(what: cint,
+             where: pointer): cint
+
+proc copy_named_substring*(code: ptr Pcre,
+                           subject: cstring,
+                           ovector: ptr cint,
+                           stringcount: cint,
+                           stringname: cstring,
+                           buffer: cstring,
+                           buffersize: cint): cint
+
+proc copy_substring*(subject: cstring,
+                     ovector: ptr cint,
+                     stringcount: cint,
+                     stringnumber: cint,
+                     buffer: cstring,
+                     buffersize: cint): cint
+
+proc dfa_exec*(code: ptr Pcre,
+               extra: ptr ExtraData,
+               subject: cstring,
+               length: cint,
+               startoffset: cint,
+               options: cint,
+               ovector: ptr cint,
+               ovecsize: cint,
+               workspace: ptr cint,
+               wscount: cint): cint
+
+proc exec*(code: ptr Pcre,
+           extra: ptr ExtraData,
+           subject: cstring,
+           length: cint,
+           startoffset: cint,
+           options: cint,
+           ovector: ptr cint,
+           ovecsize: cint): cint
+
+proc jit_exec*(code: ptr Pcre,
+               extra: ptr ExtraData,
+               subject: cstring,
+               length: cint,
+               startoffset: cint,
+               options: cint,
+               ovector: ptr cint,
+               ovecsize: cint,
+               jstack: ptr JitStack): cint
+
+proc free_substring*(stringptr: cstring)
+
+proc free_substring_list*(stringptr: cstringArray)
+
+proc fullinfo*(code: ptr Pcre,
+               extra: ptr ExtraData,
+               what: cint,
+               where: pointer): cint
+
+proc get_named_substring*(code: ptr Pcre,
+                          subject: cstring,
+                          ovector: ptr cint,
+                          stringcount: cint,
+                          stringname: cstring,
+                          stringptr: cstringArray): cint
+
+proc get_stringnumber*(code: ptr Pcre,
+                       name: cstring): cint
+
+proc get_stringtable_entries*(code: ptr Pcre,
+                              name: cstring,
+                              first: cstringArray,
+                              last: cstringArray): cint
+
+proc get_substring*(subject: cstring,
+                    ovector: ptr cint,
+                    stringcount: cint,
+                    stringnumber: cint,
+                    stringptr: cstringArray): cint
+
+proc get_substring_list*(subject: cstring,
+                         ovector: ptr cint,
+                         stringcount: cint,
+                         listptr: ptr cstringArray): cint
+
+proc maketables*(): pointer
+
+proc refcount*(code: ptr Pcre,
+               adjust: cint): cint
+
+proc study*(code: ptr Pcre,
+            options: cint,
+            errptr: ptr cstring): ptr ExtraData
+
+proc free_study*(extra: ptr ExtraData)
+
+proc version*(): cstring
+
+# Utility functions for byte order swaps.
+
+proc pattern_to_host_byte_order*(code: ptr Pcre,
+                                 extra: ptr ExtraData,
+                                 tables: pointer): cint
+
+# JIT compiler related functions.
+
+proc jit_stack_alloc*(startsize: cint,
+                      maxsize: cint): ptr JitStack
+
+proc jit_stack_free*(stack: ptr JitStack)
+
+proc assign_jit_stack*(extra: ptr ExtraData,
+                       callback: JitCallback,
+                       data: pointer)
+
+proc jit_free_unused_memory*()
+
+
+# There was an odd function with `var cstring` instead of `ptr`
+proc study*(code: ptr Pcre,
+            options: cint,
+            errptr: var cstring): ptr ExtraData {.deprecated.}
+
+{.pop.}
+{.pop.}
+
+
+type
+  PPcre* {.deprecated.} = ptr Pcre
+  PJitStack* {.deprecated.} = ptr JitStack
diff --git a/lib/wrappers/pcre/pcre.nim b/lib/wrappers/pcre/pcre.nim
deleted file mode 100755
index f2622d190..000000000
--- a/lib/wrappers/pcre/pcre.nim
+++ /dev/null
@@ -1,259 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-{.compile: "pcre_all.c".}
-type 
-  Pbyte = ptr byte
-  PPchar = ptr cstring
-  Pint = ptr cint
-  PPcre* = ptr Tpcre
-  Pcallout_block* = ptr tcallout_block
-  Pextra* = ptr Textra
-  Tpcre {.final, pure.} = object 
-  # The structure for passing additional data to pcre_exec(). This is defined
-  # in such as way as to be extensible.
-  # Bits for which fields are set
-  # Opaque data from pcre_study()
-  # Maximum number of calls to match()
-  # Data passed back in callouts
-  # Const before type ignored
-  # Pointer to character tables
-  Textra*{.final, pure.} = object  # The structure for passing out data via the pcre_callout_function. We use a
-                                   # structure so that new fields can be added on the end in future versions,
-                                   # without changing the API of the function, thereby allowing old clients to
-                                   # work without modification.
-                                   # Identifies version of block
-                                   # ------------------------ Version 0 -------------------------------
-                                   # Number compiled into pattern
-                                   # The offset vector
-                                   # Const before type ignored
-                                   # The subject being matched
-                                   # The length of the subject
-                                   # Offset to start of this match attempt
-                                   # Where we currently are in the subject
-                                   # Max current capture
-                                   # Most recently closed capture
-                                   # Data passed in with the call
-                                   # ------------------- Added for Version 1 --------------------------
-                                   # Offset to next item in the pattern
-                                   # Length of next item in the pattern
-                                   # 
-                                   # ------------------------------------------------------------------
-    flags: cint
-    study_data: pointer
-    match_limit: cint
-    callout_data: pointer
-    tables: ptr byte
-
-  Tcallout_block*{.final, pure.} = object 
-    version: cint
-    callout_number: cint
-    offset_vector: ptr cint
-    subject: ptr char
-    subject_length: cint
-    start_match: cint
-    current_position: cint
-    capture_top: cint
-    capture_last: cint
-    callout_data: pointer
-    pattern_position: cint
-    next_item_length: cint
-
-
-#************************************************
-#*       Perl-Compatible Regular Expressions    *
-#************************************************
-#
-#   Modified by Andreas Rumpf for h2pas.
-
-# In its original form, this is the .in file that is transformed by
-# "configure" into pcre.h.
-#
-#           Copyright (c) 1997-2005 University of Cambridge
-#
-# -----------------------------------------------------------------------------
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-#    * Redistributions of source code must retain the above copyright notice,
-#      this list of conditions and the following disclaimer.
-#
-#    * Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#    * Neither the name of the University of Cambridge nor the names of its
-#      contributors may be used to endorse or promote products derived from
-#      this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-# -----------------------------------------------------------------------------
-
-# The file pcre.h is build by "configure". Do not edit it; instead
-# make changes to pcre.in.
-
-const 
-  PCRE_MAJOR* = 6
-  PCRE_MINOR* = 3
-  PCRE_DATE* = "2005/11/29"
-  # Options
-  PCRE_CASELESS* = 0x00000001
-  PCRE_MULTILINE* = 0x00000002
-  PCRE_DOTALL* = 0x00000004
-  PCRE_EXTENDED* = 0x00000008
-  PCRE_ANCHORED* = 0x00000010
-  PCRE_DOLLAR_ENDONLY* = 0x00000020
-  PCRE_EXTRA* = 0x00000040
-  PCRE_NOTBOL* = 0x00000080
-  PCRE_NOTEOL* = 0x00000100
-  PCRE_UNGREEDY* = 0x00000200
-  PCRE_NOTEMPTY* = 0x00000400
-  PCRE_UTF8* = 0x00000800
-  PCRE_NO_AUTO_CAPTURE* = 0x00001000
-  PCRE_NO_UTF8_CHECK* = 0x00002000
-  PCRE_AUTO_CALLOUT* = 0x00004000
-  PCRE_PARTIAL* = 0x00008000
-  PCRE_DFA_SHORTEST* = 0x00010000
-  PCRE_DFA_RESTART* = 0x00020000
-  PCRE_FIRSTLINE* = 0x00040000
-  # Exec-time and get/set-time error codes
-  PCRE_ERROR_NOMATCH* = - (1)
-  PCRE_ERROR_NULL* = - (2)
-  PCRE_ERROR_BADOPTION* = - (3)
-  PCRE_ERROR_BADMAGIC* = - (4)
-  PCRE_ERROR_UNKNOWN_NODE* = - (5)
-  PCRE_ERROR_NOMEMORY* = - (6)
-  PCRE_ERROR_NOSUBSTRING* = - (7)
-  PCRE_ERROR_MATCHLIMIT* = - (8)
-  # Never used by PCRE itself
-  PCRE_ERROR_CALLOUT* = - (9)
-  PCRE_ERROR_BADUTF8* = - (10)
-  PCRE_ERROR_BADUTF8_OFFSET* = - (11)
-  PCRE_ERROR_PARTIAL* = - (12)
-  PCRE_ERROR_BADPARTIAL* = - (13)
-  PCRE_ERROR_INTERNAL* = - (14)
-  PCRE_ERROR_BADCOUNT* = - (15)
-  PCRE_ERROR_DFA_UITEM* = - (16)
-  PCRE_ERROR_DFA_UCOND* = - (17)
-  PCRE_ERROR_DFA_UMLIMIT* = - (18)
-  PCRE_ERROR_DFA_WSSIZE* = - (19)
-  PCRE_ERROR_DFA_RECURSE* = - (20)
-  # Request types for pcre_fullinfo()
-  PCRE_INFO_OPTIONS* = 0
-  PCRE_INFO_SIZE* = 1
-  PCRE_INFO_CAPTURECOUNT* = 2
-  PCRE_INFO_BACKREFMAX* = 3
-  PCRE_INFO_FIRSTBYTE* = 4
-  # For backwards compatibility
-  PCRE_INFO_FIRSTCHAR* = 4
-  PCRE_INFO_FIRSTTABLE* = 5
-  PCRE_INFO_LASTLITERAL* = 6
-  PCRE_INFO_NAMEENTRYSIZE* = 7
-  PCRE_INFO_NAMECOUNT* = 8
-  PCRE_INFO_NAMETABLE* = 9
-  PCRE_INFO_STUDYSIZE* = 10
-  PCRE_INFO_DEFAULT_TABLES* = 11
-  # Request types for pcre_config()
-  PCRE_CONFIG_UTF8* = 0
-  PCRE_CONFIG_NEWLINE* = 1
-  PCRE_CONFIG_LINK_SIZE* = 2
-  PCRE_CONFIG_POSIX_MALLOC_THRESHOLD* = 3
-  PCRE_CONFIG_MATCH_LIMIT* = 4
-  PCRE_CONFIG_STACKRECURSE* = 5
-  PCRE_CONFIG_UNICODE_PROPERTIES* = 6
-  # Bit flags for the pcre_extra structure
-  PCRE_EXTRA_STUDY_DATA* = 0x00000001
-  PCRE_EXTRA_MATCH_LIMIT* = 0x00000002
-  PCRE_EXTRA_CALLOUT_DATA* = 0x00000004
-  PCRE_EXTRA_TABLES* = 0x00000008
-
-# Exported PCRE functions
-
-proc pcre_compile*(para1: cstring, para2: cint, para3: ptr cstring, 
-                   para4: ptr int, para5: Pbyte): PPcre{.importc: "pcre_compile", 
-    noconv.}
-proc pcre_compile2*(para1: cstring, para2: cint, para3: Pint, para4: PPchar, 
-                    para5: ptr int, para6: Pbyte): PPcre{.importc: "pcre_compile2", 
-    noconv.}
-proc pcre_config*(para1: cint, para2: pointer): cint{.importc: "pcre_config", 
-    noconv.}
-proc pcre_copy_named_substring*(para1: PPcre, para2: cstring, para3: Pint, 
-                                para4: cint, para5: cstring, para6: cstring, 
-                                para7: cint): cint{.
-    importc: "pcre_copy_named_substring", noconv.}
-proc pcre_copy_substring*(para1: cstring, para2: Pint, para3: cint, para4: cint, 
-                          para5: cstring, para6: cint): cint{.
-    importc: "pcre_copy_substring", noconv.}
-proc pcre_dfa_exec*(para1: PPcre, para2: Pextra, para3: cstring, para4: cint, 
-                    para5: cint, para6: cint, para7: Pint, para8: cint, 
-                    para9: Pint, para10: cint): cint{.importc: "pcre_dfa_exec", 
-    noconv.}
-proc pcre_exec*(para1: PPcre, para2: Pextra, para3: cstring, para4: cint, 
-                para5: cint, para6: cint, para7: Pint, para8: cint): cint{.
-    importc: "pcre_exec", noconv.}
-proc pcre_free_substring*(para1: cstring){.importc: "pcre_free_substring", 
-    noconv.}
-proc pcre_free_substring_list*(para1: PPchar){.
-    importc: "pcre_free_substring_list", noconv.}
-proc pcre_fullinfo*(para1: PPcre, para2: Pextra, para3: cint, para4: pointer): cint{.
-    importc: "pcre_fullinfo", noconv.}
-proc pcre_get_named_substring*(para1: PPcre, para2: cstring, para3: Pint, 
-                               para4: cint, para5: cstring, para6: PPchar): cint{.
-    importc: "pcre_get_named_substring", noconv.}
-proc pcre_get_stringnumber*(para1: PPcre, para2: cstring): cint{.
-    importc: "pcre_get_stringnumber", noconv.}
-proc pcre_get_substring*(para1: cstring, para2: Pint, para3: cint, para4: cint, 
-                         para5: PPchar): cint{.importc: "pcre_get_substring", 
-    noconv.}
-proc pcre_get_substring_list*(para1: cstring, para2: Pint, para3: cint, 
-                              para4: ptr PPchar): cint{.
-    importc: "pcre_get_substring_list", noconv.}
-proc pcre_info*(para1: PPcre, para2: Pint, para3: Pint): cint{.importc: "pcre_info", 
-    noconv.}
-proc pcre_maketables*(): ptr byte{.importc: "pcre_maketables", noconv.}
-proc pcre_refcount*(para1: PPcre, para2: cint): cint{.importc: "pcre_refcount", 
-    noconv.}
-proc pcre_study*(para1: PPcre, para2: cint, para3: ptr CString): Pextra{.
-    importc: "pcre_study", noconv.}
-proc pcre_version*(): CString{.importc: "pcre_version", noconv.}
-# Indirection for store get and free functions. These can be set to
-# alternative malloc/free functions if required. Special ones are used in the
-# non-recursive case for "frames". There is also an optional callout function
-# that is triggered by the (?) regex item.
-#
-
-# we use Nimrod's memory manager (but not GC!) for these functions:
-
-type 
-  TMalloc = proc (para1: int): pointer{.noconv.}
-  TFree = proc (para1: pointer){.noconv.}
-
-var 
-  pcre_malloc{.importc: "pcre_malloc".}: TMalloc
-  pcre_free{.importc: "pcre_free".}: TFree
-  pcre_stack_malloc{.importc: "pcre_stack_malloc".}: TMalloc
-  pcre_stack_free{.importc: "pcre_stack_free".}: TFree
-  pcre_callout{.importc: "pcre_callout".}: proc (para1: Pcallout_block): cint{.
-      noconv.}
-
-pcre_malloc = cast[TMalloc](system.alloc)
-pcre_free = cast[TFree](system.dealloc)
-pcre_stack_malloc = cast[TMalloc](system.alloc)
-pcre_stack_free = cast[TFree](system.dealloc)
-pcre_callout = nil
diff --git a/lib/wrappers/pcre/pcre_all.c b/lib/wrappers/pcre/pcre_all.c
deleted file mode 100755
index bcda06e50..000000000
--- a/lib/wrappers/pcre/pcre_all.c
+++ /dev/null
@@ -1,30072 +0,0 @@
-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* This file is automatically written by the dftables auxiliary

-program. If you edit it by hand, you might like to edit the Makefile to

-prevent its ever being regenerated.

-

-This file contains the default tables for characters with codes less than

-128 (ASCII characters). These tables are used when no external tables are

-passed to PCRE. */

-

-const unsigned char _pcre_default_tables[] = {

-

-/* This table is a lower casing table. */

-

-    0,  1,  2,  3,  4,  5,  6,  7,

-    8,  9, 10, 11, 12, 13, 14, 15,

-   16, 17, 18, 19, 20, 21, 22, 23,

-   24, 25, 26, 27, 28, 29, 30, 31,

-   32, 33, 34, 35, 36, 37, 38, 39,

-   40, 41, 42, 43, 44, 45, 46, 47,

-   48, 49, 50, 51, 52, 53, 54, 55,

-   56, 57, 58, 59, 60, 61, 62, 63,

-   64, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122, 91, 92, 93, 94, 95,

-   96, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122,123,124,125,126,127,

-  128,129,130,131,132,133,134,135,

-  136,137,138,139,140,141,142,143,

-  144,145,146,147,148,149,150,151,

-  152,153,154,155,156,157,158,159,

-  160,161,162,163,164,165,166,167,

-  168,169,170,171,172,173,174,175,

-  176,177,178,179,180,181,182,183,

-  184,185,186,187,188,189,190,191,

-  192,193,194,195,196,197,198,199,

-  200,201,202,203,204,205,206,207,

-  208,209,210,211,212,213,214,215,

-  216,217,218,219,220,221,222,223,

-  224,225,226,227,228,229,230,231,

-  232,233,234,235,236,237,238,239,

-  240,241,242,243,244,245,246,247,

-  248,249,250,251,252,253,254,255,

-

-/* This table is a case flipping table. */

-

-    0,  1,  2,  3,  4,  5,  6,  7,

-    8,  9, 10, 11, 12, 13, 14, 15,

-   16, 17, 18, 19, 20, 21, 22, 23,

-   24, 25, 26, 27, 28, 29, 30, 31,

-   32, 33, 34, 35, 36, 37, 38, 39,

-   40, 41, 42, 43, 44, 45, 46, 47,

-   48, 49, 50, 51, 52, 53, 54, 55,

-   56, 57, 58, 59, 60, 61, 62, 63,

-   64, 97, 98, 99,100,101,102,103,

-  104,105,106,107,108,109,110,111,

-  112,113,114,115,116,117,118,119,

-  120,121,122, 91, 92, 93, 94, 95,

-   96, 65, 66, 67, 68, 69, 70, 71,

-   72, 73, 74, 75, 76, 77, 78, 79,

-   80, 81, 82, 83, 84, 85, 86, 87,

-   88, 89, 90,123,124,125,126,127,

-  128,129,130,131,132,133,134,135,

-  136,137,138,139,140,141,142,143,

-  144,145,146,147,148,149,150,151,

-  152,153,154,155,156,157,158,159,

-  160,161,162,163,164,165,166,167,

-  168,169,170,171,172,173,174,175,

-  176,177,178,179,180,181,182,183,

-  184,185,186,187,188,189,190,191,

-  192,193,194,195,196,197,198,199,

-  200,201,202,203,204,205,206,207,

-  208,209,210,211,212,213,214,215,

-  216,217,218,219,220,221,222,223,

-  224,225,226,227,228,229,230,231,

-  232,233,234,235,236,237,238,239,

-  240,241,242,243,244,245,246,247,

-  248,249,250,251,252,253,254,255,

-

-/* This table contains bit maps for various character classes.

-Each map is 32 bytes long and the bits run from the least

-significant end of each byte. The classes that have their own

-maps are: space, xdigit, digit, upper, lower, word, graph

-print, punct, and cntrl. Other classes are built from combinations. */

-

-  0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,

-  0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,

-  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,

-  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,

-  0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-  0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

-

-/* This table identifies various classes of character by individual bits:

-  0x01   white space character

-  0x02   letter

-  0x04   decimal digit

-  0x08   hexadecimal digit

-  0x10   alphanumeric or '_'

-  0x80   regular expression metacharacter or binary zero

-*/

-

-  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */

-  0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /*    - '  */

-  0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /*  ( - /  */

-  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */

-  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /*  8 - ?  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  @ - G  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  H - O  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  P - W  */

-  0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /*  X - _  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  ` - g  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  h - o  */

-  0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  p - w  */

-  0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /*  x -127 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */

-

-/* End of chartables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_compile(), along with

-supporting internal functions that are not used by other modules. */

-

-

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-/* This header contains definitions that are shared between the different

-modules, but which are not relevant to the exported API. This includes some

-functions whose names all begin with "_pcre_". */

-

-

-/* Define DEBUG to get debugging output on stdout. */

-

-/****

-#define DEBUG

-****/

-

-/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef

-inline, and there are *still* stupid compilers about that don't like indented

-pre-processor statements, or at least there were when I first wrote this. After

-all, it had only been about 10 years then... */

-

-#ifdef DEBUG

-#define DPRINTF(p) printf p

-#else

-#define DPRINTF(p) /*nothing*/

-#endif

-

-

-/* Get the definitions provided by running "configure" */

-

-

-/* On Unix systems config.in is converted by configure into config.h. PCRE is

-written in Standard C, but there are a few non-standard things it can cope

-with, allowing it to run on SunOS4 and other "close to standard" systems.

-

-On a non-Unix system you should just copy this file into config.h, and set up

-the macros the way you need them. You should normally change the definitions of

-HAVE_STRERROR and HAVE_MEMMOVE to 1. Unfortunately, because of the way autoconf

-works, these cannot be made the defaults. If your system has bcopy() and not

-memmove(), change the definition of HAVE_BCOPY instead of HAVE_MEMMOVE. If your

-system has neither bcopy() nor memmove(), leave them both as 0; an emulation

-function will be used. */

-

-/* If you are compiling for a system that uses EBCDIC instead of ASCII

-character codes, define this macro as 1. On systems that can use "configure",

-this can be done via --enable-ebcdic. */

-

-#ifndef EBCDIC

-#define EBCDIC 0

-#endif

-

-/* If you are compiling for a system that needs some magic to be inserted

-before the definition of an exported function, define this macro to contain the

-relevant magic. It apears at the start of every exported function. */

-

-#define EXPORT

-

-/* Define to empty if the "const" keyword does not work. */

-

-#undef const

-

-/* Define to "unsigned" if <stddef.h> doesn't define size_t. */

-

-#undef size_t

-

-/* The following two definitions are mainly for the benefit of SunOS4, which

-doesn't have the strerror() or memmove() functions that should be present in

-all Standard C libraries. The macros HAVE_STRERROR and HAVE_MEMMOVE should

-normally be defined with the value 1 for other systems, but unfortunately we

-can't make this the default because "configure" files generated by autoconf

-will only change 0 to 1; they won't change 1 to 0 if the functions are not

-found. */

-

-#define HAVE_STRERROR 1

-#define HAVE_MEMMOVE  1

-

-/* There are some non-Unix systems that don't even have bcopy(). If this macro

-is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of

-HAVE_BCOPY is not relevant. */

-

-#define HAVE_BCOPY    0

-

-/* The value of NEWLINE determines the newline character. The default is to

-leave it up to the compiler, but some sites want to force a particular value.

-On Unix systems, "configure" can be used to override this default. */

-

-#ifndef NEWLINE

-#define NEWLINE '\n'

-#endif

-

-/* The value of LINK_SIZE determines the number of bytes used to store

-links as offsets within the compiled regex. The default is 2, which allows for

-compiled patterns up to 64K long. This covers the vast majority of cases.

-However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for

-longer patterns in extreme cases. On Unix systems, "configure" can be used to

-override this default. */

-

-#ifndef LINK_SIZE

-#define LINK_SIZE   2

-#endif

-

-/* The value of MATCH_LIMIT determines the default number of times the match()

-function can be called during a single execution of pcre_exec(). (There is a

-runtime method of setting a different limit.) The limit exists in order to

-catch runaway regular expressions that take for ever to determine that they do

-not match. The default is set very large so that it does not accidentally catch

-legitimate cases. On Unix systems, "configure" can be used to override this

-default default. */

-

-#ifndef MATCH_LIMIT

-#define MATCH_LIMIT 10000000

-#endif

-

-/* When calling PCRE via the POSIX interface, additional working storage is

-required for holding the pointers to capturing substrings because PCRE requires

-three integers per substring, whereas the POSIX interface provides only two. If

-the number of expected substrings is small, the wrapper function uses space on

-the stack, because this is faster than using malloc() for each call. The

-threshold above which the stack is no longer use is defined by POSIX_MALLOC_

-THRESHOLD. On Unix systems, "configure" can be used to override this default.

-*/

-

-#ifndef POSIX_MALLOC_THRESHOLD

-#define POSIX_MALLOC_THRESHOLD 10

-#endif

-

-/* PCRE uses recursive function calls to handle backtracking while matching.

-This can sometimes be a problem on systems that have stacks of limited size.

-Define NO_RECURSE to get a version that doesn't use recursion in the match()

-function; instead it creates its own stack by steam using pcre_recurse_malloc

-to get memory. For more detail, see comments and other stuff just above the

-match() function. On Unix systems, "configure" can be used to set this in the

-Makefile (use --disable-stack-for-recursion). */

-

-/* #define NO_RECURSE */

-

-/* End */

-

-/* Standard C headers plus the external interface definition. The only time

-setjmp and stdarg are used is when NO_RECURSE is set. */

-

-#include <ctype.h>

-#include <limits.h>

-#include <setjmp.h>

-#include <stdarg.h>

-#include <stddef.h>

-#include <stdio.h>

-#include <stdlib.h>

-#include <string.h>

-

-#ifndef PCRE_SPY

-#define PCRE_DEFINITION       /* Win32 __declspec(export) trigger for .dll */

-#endif

-

-/* We need to have types that specify unsigned 16-bit and 32-bit integers. We

-cannot determine these outside the compilation (e.g. by running a program as

-part of "configure") because PCRE is often cross-compiled for use on other

-systems. Instead we make use of the maximum sizes that are available at

-preprocessor time in standard C environments. */

-

-#if USHRT_MAX == 65535

-  typedef unsigned short pcre_uint16;

-#elif UINT_MAX == 65535

-  typedef unsigned int pcre_uint16;

-#else

-  #error Cannot determine a type for 16-bit unsigned integers

-#endif

-

-#if UINT_MAX == 4294967295

-  typedef unsigned int pcre_uint32;

-#elif ULONG_MAX == 4294967295

-  typedef unsigned long int pcre_uint32;

-#else

-  #error Cannot determine a type for 32-bit unsigned integers

-#endif

-

-/* All character handling must be done as unsigned characters. Otherwise there

-are problems with top-bit-set characters and functions such as isspace().

-However, we leave the interface to the outside world as char *, because that

-should make things easier for callers. We define a short type for unsigned char

-to save lots of typing. I tried "uchar", but it causes problems on Digital

-Unix, where it is defined in sys/types, so use "uschar" instead. */

-

-typedef unsigned char uschar;

-

-/* Include the public PCRE header */

-

-/*************************************************

-*       Perl-Compatible Regular Expressions      *

-*************************************************/

-

-/* In its original form, this is the .in file that is transformed by

-"configure" into pcre.h.

-

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-#ifndef _PCRE_H

-#define _PCRE_H

-

-/* The file pcre.h is build by "configure". Do not edit it; instead

-make changes to pcre.in. */

-

-#define PCRE_MAJOR          6

-#define PCRE_MINOR          3

-#define PCRE_DATE           "2005/11/29"

-

-/* For other operating systems, we use the standard "extern". */

-

-#ifndef PCRE_DATA_SCOPE

-#  ifdef __cplusplus

-#    define PCRE_DATA_SCOPE     extern "C"

-#  else

-#    define PCRE_DATA_SCOPE     extern

-#  endif

-#endif

-

-/* Have to include stdlib.h in order to ensure that size_t is defined;

-it is needed here for malloc. */

-

-#include <stdlib.h>

-

-/* Allow for C++ users */

-

-#ifdef __cplusplus

-extern "C" {

-#endif

-

-/* Options */

-

-#define PCRE_CASELESS           0x00000001

-#define PCRE_MULTILINE          0x00000002

-#define PCRE_DOTALL             0x00000004

-#define PCRE_EXTENDED           0x00000008

-#define PCRE_ANCHORED           0x00000010

-#define PCRE_DOLLAR_ENDONLY     0x00000020

-#define PCRE_EXTRA              0x00000040

-#define PCRE_NOTBOL             0x00000080

-#define PCRE_NOTEOL             0x00000100

-#define PCRE_UNGREEDY           0x00000200

-#define PCRE_NOTEMPTY           0x00000400

-#define PCRE_UTF8               0x00000800

-#define PCRE_NO_AUTO_CAPTURE    0x00001000

-#define PCRE_NO_UTF8_CHECK      0x00002000

-#define PCRE_AUTO_CALLOUT       0x00004000

-#define PCRE_PARTIAL            0x00008000

-#define PCRE_DFA_SHORTEST       0x00010000

-#define PCRE_DFA_RESTART        0x00020000

-#define PCRE_FIRSTLINE          0x00040000

-

-/* Exec-time and get/set-time error codes */

-

-#define PCRE_ERROR_NOMATCH         (-1)

-#define PCRE_ERROR_NULL            (-2)

-#define PCRE_ERROR_BADOPTION       (-3)

-#define PCRE_ERROR_BADMAGIC        (-4)

-#define PCRE_ERROR_UNKNOWN_NODE    (-5)

-#define PCRE_ERROR_NOMEMORY        (-6)

-#define PCRE_ERROR_NOSUBSTRING     (-7)

-#define PCRE_ERROR_MATCHLIMIT      (-8)

-#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */

-#define PCRE_ERROR_BADUTF8        (-10)

-#define PCRE_ERROR_BADUTF8_OFFSET (-11)

-#define PCRE_ERROR_PARTIAL        (-12)

-#define PCRE_ERROR_BADPARTIAL     (-13)

-#define PCRE_ERROR_INTERNAL       (-14)

-#define PCRE_ERROR_BADCOUNT       (-15)

-#define PCRE_ERROR_DFA_UITEM      (-16)

-#define PCRE_ERROR_DFA_UCOND      (-17)

-#define PCRE_ERROR_DFA_UMLIMIT    (-18)

-#define PCRE_ERROR_DFA_WSSIZE     (-19)

-#define PCRE_ERROR_DFA_RECURSE    (-20)

-

-/* Request types for pcre_fullinfo() */

-

-#define PCRE_INFO_OPTIONS            0

-#define PCRE_INFO_SIZE               1

-#define PCRE_INFO_CAPTURECOUNT       2

-#define PCRE_INFO_BACKREFMAX         3

-#define PCRE_INFO_FIRSTBYTE          4

-#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */

-#define PCRE_INFO_FIRSTTABLE         5

-#define PCRE_INFO_LASTLITERAL        6

-#define PCRE_INFO_NAMEENTRYSIZE      7

-#define PCRE_INFO_NAMECOUNT          8

-#define PCRE_INFO_NAMETABLE          9

-#define PCRE_INFO_STUDYSIZE         10

-#define PCRE_INFO_DEFAULT_TABLES    11

-

-/* Request types for pcre_config() */

-

-#define PCRE_CONFIG_UTF8                    0

-#define PCRE_CONFIG_NEWLINE                 1

-#define PCRE_CONFIG_LINK_SIZE               2

-#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3

-#define PCRE_CONFIG_MATCH_LIMIT             4

-#define PCRE_CONFIG_STACKRECURSE            5

-#define PCRE_CONFIG_UNICODE_PROPERTIES      6

-

-/* Bit flags for the pcre_extra structure */

-

-#define PCRE_EXTRA_STUDY_DATA          0x0001

-#define PCRE_EXTRA_MATCH_LIMIT         0x0002

-#define PCRE_EXTRA_CALLOUT_DATA        0x0004

-#define PCRE_EXTRA_TABLES              0x0008

-

-/* Types */

-

-struct real_pcre;                 /* declaration; the definition is private  */

-typedef struct real_pcre pcre;

-

-/* The structure for passing additional data to pcre_exec(). This is defined in

-such as way as to be extensible. Always add new fields at the end, in order to

-remain compatible. */

-

-typedef struct pcre_extra {

-  unsigned long int flags;        /* Bits for which fields are set */

-  void *study_data;               /* Opaque data from pcre_study() */

-  unsigned long int match_limit;  /* Maximum number of calls to match() */

-  void *callout_data;             /* Data passed back in callouts */

-  const unsigned char *tables;    /* Pointer to character tables */

-} pcre_extra;

-

-/* The structure for passing out data via the pcre_callout_function. We use a

-structure so that new fields can be added on the end in future versions,

-without changing the API of the function, thereby allowing old clients to work

-without modification. */

-

-typedef struct pcre_callout_block {

-  int          version;           /* Identifies version of block */

-  /* ------------------------ Version 0 ------------------------------- */

-  int          callout_number;    /* Number compiled into pattern */

-  int         *offset_vector;     /* The offset vector */

-  const char  *subject;           /* The subject being matched */

-  int          subject_length;    /* The length of the subject */

-  int          start_match;       /* Offset to start of this match attempt */

-  int          current_position;  /* Where we currently are in the subject */

-  int          capture_top;       /* Max current capture */

-  int          capture_last;      /* Most recently closed capture */

-  void        *callout_data;      /* Data passed in with the call */

-  /* ------------------- Added for Version 1 -------------------------- */

-  int          pattern_position;  /* Offset to next item in the pattern */

-  int          next_item_length;  /* Length of next item in the pattern */

-  /* ------------------------------------------------------------------ */

-} pcre_callout_block;

-

-/* Indirection for store get and free functions. These can be set to

-alternative malloc/free functions if required. Special ones are used in the

-non-recursive case for "frames". There is also an optional callout function

-that is triggered by the (?) regex item. For Virtual Pascal, these definitions

-have to take another form. */

-

-#ifndef VPCOMPAT

-PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);

-PCRE_DATA_SCOPE void  (*pcre_free)(void *);

-PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);

-PCRE_DATA_SCOPE void  (*pcre_stack_free)(void *);

-PCRE_DATA_SCOPE int   (*pcre_callout)(pcre_callout_block *);

-#else   /* VPCOMPAT */

-PCRE_DATA_SCOPE void *pcre_malloc(size_t);

-PCRE_DATA_SCOPE void  pcre_free(void *);

-PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t);

-PCRE_DATA_SCOPE void  pcre_stack_free(void *);

-PCRE_DATA_SCOPE int   pcre_callout(pcre_callout_block *);

-#endif  /* VPCOMPAT */

-

-/* Exported PCRE functions */

-

-PCRE_DATA_SCOPE pcre *pcre_compile(const char *, int, const char **, int *,

-                  const unsigned char *);

-PCRE_DATA_SCOPE pcre *pcre_compile2(const char *, int, int *, const char **,

-                  int *, const unsigned char *);

-PCRE_DATA_SCOPE int  pcre_config(int, void *);

-PCRE_DATA_SCOPE int  pcre_copy_named_substring(const pcre *, const char *,

-                  int *, int, const char *, char *, int);

-PCRE_DATA_SCOPE int  pcre_copy_substring(const char *, int *, int, int, char *,

-                  int);

-PCRE_DATA_SCOPE int  pcre_dfa_exec(const pcre *, const pcre_extra *,

-                  const char *, int, int, int, int *, int , int *, int);

-PCRE_DATA_SCOPE int  pcre_exec(const pcre *, const pcre_extra *, const char *,

-                   int, int, int, int *, int);

-PCRE_DATA_SCOPE void pcre_free_substring(const char *);

-PCRE_DATA_SCOPE void pcre_free_substring_list(const char **);

-PCRE_DATA_SCOPE int  pcre_fullinfo(const pcre *, const pcre_extra *, int,

-                  void *);

-PCRE_DATA_SCOPE int  pcre_get_named_substring(const pcre *, const char *,

-                  int *, int, const char *, const char **);

-PCRE_DATA_SCOPE int  pcre_get_stringnumber(const pcre *, const char *);

-PCRE_DATA_SCOPE int  pcre_get_substring(const char *, int *, int, int,

-                  const char **);

-PCRE_DATA_SCOPE int  pcre_get_substring_list(const char *, int *, int,

-                  const char ***);

-PCRE_DATA_SCOPE int  pcre_info(const pcre *, int *, int *);

-PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void);

-PCRE_DATA_SCOPE int  pcre_refcount(pcre *, int);

-PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **);

-PCRE_DATA_SCOPE const char *pcre_version(void);

-

-#ifdef __cplusplus

-}  /* extern "C" */

-#endif

-

-#endif /* End of pcre.h */

-

-/* Include the (copy of) the public ucp header, changing the external name into

-a private one. This does no harm, even if we aren't compiling UCP support. */

-

-#define ucp_findchar _pcre_ucp_findchar

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-

-#ifndef _UCP_H

-#define _UCP_H

-

-/* These are the character categories that are returned by ucp_findchar */

-

-enum {

-  ucp_C,     /* Other */

-  ucp_L,     /* Letter */

-  ucp_M,     /* Mark */

-  ucp_N,     /* Number */

-  ucp_P,     /* Punctuation */

-  ucp_S,     /* Symbol */

-  ucp_Z      /* Separator */

-};

-

-/* These are the detailed character types that are returned by ucp_findchar */

-

-enum {

-  ucp_Cc,    /* Control */

-  ucp_Cf,    /* Format */

-  ucp_Cn,    /* Unassigned */

-  ucp_Co,    /* Private use */

-  ucp_Cs,    /* Surrogate */

-  ucp_Ll,    /* Lower case letter */

-  ucp_Lm,    /* Modifier letter */

-  ucp_Lo,    /* Other letter */

-  ucp_Lt,    /* Title case letter */

-  ucp_Lu,    /* Upper case letter */

-  ucp_Mc,    /* Spacing mark */

-  ucp_Me,    /* Enclosing mark */

-  ucp_Mn,    /* Non-spacing mark */

-  ucp_Nd,    /* Decimal number */

-  ucp_Nl,    /* Letter number */

-  ucp_No,    /* Other number */

-  ucp_Pc,    /* Connector punctuation */

-  ucp_Pd,    /* Dash punctuation */

-  ucp_Pe,    /* Close punctuation */

-  ucp_Pf,    /* Final punctuation */

-  ucp_Pi,    /* Initial punctuation */

-  ucp_Po,    /* Other punctuation */

-  ucp_Ps,    /* Open punctuation */

-  ucp_Sc,    /* Currency symbol */

-  ucp_Sk,    /* Modifier symbol */

-  ucp_Sm,    /* Mathematical symbol */

-  ucp_So,    /* Other symbol */

-  ucp_Zl,    /* Line separator */

-  ucp_Zp,    /* Paragraph separator */

-  ucp_Zs     /* Space separator */

-};

-

-extern int ucp_findchar(const int, int *, int *);

-

-#endif

-

-/* End of ucp.h */

-

-/* When compiling for use with the Virtual Pascal compiler, these functions

-need to have their names changed. PCRE must be compiled with the -DVPCOMPAT

-option on the command line. */

-

-#ifdef VPCOMPAT

-#define strncmp(s1,s2,m) _strncmp(s1,s2,m)

-#define memcpy(d,s,n)    _memcpy(d,s,n)

-#define memmove(d,s,n)   _memmove(d,s,n)

-#define memset(s,c,n)    _memset(s,c,n)

-#else  /* VPCOMPAT */

-

-/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),

-define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY

-is set. Otherwise, include an emulating function for those systems that have

-neither (there some non-Unix environments where this is the case). This assumes

-that all calls to memmove are moving strings upwards in store, which is the

-case in PCRE. */

-

-#if ! HAVE_MEMMOVE

-#undef  memmove        /* some systems may have a macro */

-#if HAVE_BCOPY

-#define memmove(a, b, c) bcopy(b, a, c)

-#else  /* HAVE_BCOPY */

-void *

-pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)

-{

-int i;

-dest += n;

-src += n;

-for (i = 0; i < n; ++i) *(--dest) =  *(--src);

-}

-#define memmove(a, b, c) pcre_memmove(a, b, c)

-#endif   /* not HAVE_BCOPY */

-#endif   /* not HAVE_MEMMOVE */

-#endif   /* not VPCOMPAT */

-

-

-/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored

-in big-endian order) by default. These are used, for example, to link from the

-start of a subpattern to its alternatives and its end. The use of 2 bytes per

-offset limits the size of the compiled regex to around 64K, which is big enough

-for almost everybody. However, I received a request for an even bigger limit.

-For this reason, and also to make the code easier to maintain, the storing and

-loading of offsets from the byte string is now handled by the macros that are

-defined here.

-

-The macros are controlled by the value of LINK_SIZE. This defaults to 2 in

-the config.h file, but can be overridden by using -D on the command line. This

-is automated on Unix systems via the "configure" command. */

-

-#if LINK_SIZE == 2

-

-#define PUT(a,n,d)   \

-  (a[n] = (d) >> 8), \

-  (a[(n)+1] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 8) | (a)[(n)+1])

-

-#define MAX_PATTERN_SIZE (1 << 16)

-

-

-#elif LINK_SIZE == 3

-

-#define PUT(a,n,d)       \

-  (a[n] = (d) >> 16),    \

-  (a[(n)+1] = (d) >> 8), \

-  (a[(n)+2] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])

-

-#define MAX_PATTERN_SIZE (1 << 24)

-

-

-#elif LINK_SIZE == 4

-

-#define PUT(a,n,d)        \

-  (a[n] = (d) >> 24),     \

-  (a[(n)+1] = (d) >> 16), \

-  (a[(n)+2] = (d) >> 8),  \

-  (a[(n)+3] = (d) & 255)

-

-#define GET(a,n) \

-  (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])

-

-#define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */

-

-

-#else

-#error LINK_SIZE must be either 2, 3, or 4

-#endif

-

-

-/* Convenience macro defined in terms of the others */

-

-#define PUTINC(a,n,d)   PUT(a,n,d), a += LINK_SIZE

-

-

-/* PCRE uses some other 2-byte quantities that do not change when the size of

-offsets changes. There are used for repeat counts and for other things such as

-capturing parenthesis numbers in back references. */

-

-#define PUT2(a,n,d)   \

-  a[n] = (d) >> 8; \

-  a[(n)+1] = (d) & 255

-

-#define GET2(a,n) \

-  (((a)[n] << 8) | (a)[(n)+1])

-

-#define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2

-

-

-/* When UTF-8 encoding is being used, a character is no longer just a single

-byte. The macros for character handling generate simple sequences when used in

-byte-mode, and more complicated ones for UTF-8 characters. */

-

-#ifndef SUPPORT_UTF8

-#define GETCHAR(c, eptr) c = *eptr;

-#define GETCHARTEST(c, eptr) c = *eptr;

-#define GETCHARINC(c, eptr) c = *eptr++;

-#define GETCHARINCTEST(c, eptr) c = *eptr++;

-#define GETCHARLEN(c, eptr, len) c = *eptr;

-#define BACKCHAR(eptr)

-

-#else   /* SUPPORT_UTF8 */

-

-/* Get the next UTF-8 character, not advancing the pointer. This is called when

-we know we are in UTF-8 mode. */

-

-#define GETCHAR(c, eptr) \

-  c = *eptr; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the

-pointer. */

-

-#define GETCHARTEST(c, eptr) \

-  c = *eptr; \

-  if (utf8 && (c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, advancing the pointer. This is called when we

-know we are in UTF-8 mode. */

-

-#define GETCHARINC(c, eptr) \

-  c = *eptr++; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    while (gcaa-- > 0) \

-      { \

-      gcss -= 6; \

-      c |= (*eptr++ & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next character, testing for UTF-8 mode, and advancing the pointer */

-

-#define GETCHARINCTEST(c, eptr) \

-  c = *eptr++; \

-  if (utf8 && (c & 0xc0) == 0xc0) \

-    { \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    while (gcaa-- > 0) \

-      { \

-      gcss -= 6; \

-      c |= (*eptr++ & 0x3f) << gcss; \

-      } \

-    }

-

-/* Get the next UTF-8 character, not advancing the pointer, incrementing length

-if there are extra bytes. This is called when we know we are in UTF-8 mode. */

-

-#define GETCHARLEN(c, eptr, len) \

-  c = *eptr; \

-  if ((c & 0xc0) == 0xc0) \

-    { \

-    int gcii; \

-    int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \

-    int gcss = 6*gcaa; \

-    c = (c & _pcre_utf8_table3[gcaa]) << gcss; \

-    for (gcii = 1; gcii <= gcaa; gcii++) \

-      { \

-      gcss -= 6; \

-      c |= (eptr[gcii] & 0x3f) << gcss; \

-      } \

-    len += gcaa; \

-    }

-

-/* If the pointer is not at the start of a character, move it back until

-it is. Called only in UTF-8 mode. */

-

-#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--;

-

-#endif

-

-

-/* In case there is no definition of offsetof() provided - though any proper

-Standard C system should have one. */

-

-#ifndef offsetof

-#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))

-#endif

-

-

-/* These are the public options that can change during matching. */

-

-#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)

-

-/* Private options flags start at the most significant end of the four bytes,

-but skip the top bit so we can use ints for convenience without getting tangled

-with negative values. The public options defined in pcre.h start at the least

-significant end. Make sure they don't overlap! */

-

-#define PCRE_FIRSTSET      0x40000000  /* first_byte is set */

-#define PCRE_REQCHSET      0x20000000  /* req_byte is set */

-#define PCRE_STARTLINE     0x10000000  /* start after \n for multiline */

-#define PCRE_ICHANGED      0x08000000  /* i option changes within regex */

-#define PCRE_NOPARTIAL     0x04000000  /* can't use partial with this regex */

-

-/* Options for the "extra" block produced by pcre_study(). */

-

-#define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */

-

-/* Masks for identifying the public options that are permitted at compile

-time, run time, or study time, respectively. */

-

-#define PUBLIC_OPTIONS \

-  (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \

-   PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \

-   PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE)

-

-#define PUBLIC_EXEC_OPTIONS \

-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \

-   PCRE_PARTIAL)

-

-#define PUBLIC_DFA_EXEC_OPTIONS \

-  (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \

-   PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART)

-

-#define PUBLIC_STUDY_OPTIONS 0   /* None defined */

-

-/* Magic number to provide a small check against being handed junk. Also used

-to detect whether a pattern was compiled on a host of different endianness. */

-

-#define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */

-

-/* Negative values for the firstchar and reqchar variables */

-

-#define REQ_UNSET (-2)

-#define REQ_NONE  (-1)

-

-/* The maximum remaining length of subject we are prepared to search for a

-req_byte match. */

-

-#define REQ_BYTE_MAX 1000

-

-/* Flags added to firstbyte or reqbyte; a "non-literal" item is either a

-variable-length repeat, or a anything other than literal characters. */

-

-#define REQ_CASELESS 0x0100    /* indicates caselessness */

-#define REQ_VARY     0x0200    /* reqbyte followed non-literal item */

-

-/* Miscellaneous definitions */

-

-typedef int BOOL;

-

-#define FALSE   0

-#define TRUE    1

-

-/* Escape items that are just an encoding of a particular data value. Note that

-ESC_n is defined as yet another macro, which is set in config.h to either \n

-(the default) or \r (which some people want). */

-

-#ifndef ESC_e

-#define ESC_e 27

-#endif

-

-#ifndef ESC_f

-#define ESC_f '\f'

-#endif

-

-#ifndef ESC_n

-#define ESC_n NEWLINE

-#endif

-

-#ifndef ESC_r

-#define ESC_r '\r'

-#endif

-

-/* We can't officially use ESC_t because it is a POSIX reserved identifier

-(presumably because of all the others like size_t). */

-

-#ifndef ESC_tee

-#define ESC_tee '\t'

-#endif

-

-/* These are escaped items that aren't just an encoding of a particular data

-value such as \n. They must have non-zero values, as check_escape() returns

-their negation. Also, they must appear in the same order as in the opcode

-definitions below, up to ESC_z. There's a dummy for OP_ANY because it

-corresponds to "." rather than an escape sequence. The final one must be

-ESC_REF as subsequent values are used for \1, \2, \3, etc. There is are two

-tests in the code for an escape greater than ESC_b and less than ESC_Z to

-detect the types that may be repeated. These are the types that consume

-characters. If any new escapes are put in between that don't consume a

-character, that code will have to change. */

-

-enum { ESC_A = 1, ESC_G, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W,

-       ESC_w, ESC_dum1, ESC_C, ESC_P, ESC_p, ESC_X, ESC_Z, ESC_z, ESC_E,

-       ESC_Q, ESC_REF };

-

-/* Flag bits and data types for the extended class (OP_XCLASS) for classes that

-contain UTF-8 characters with values greater than 255. */

-

-#define XCL_NOT    0x01    /* Flag: this is a negative class */

-#define XCL_MAP    0x02    /* Flag: a 32-byte map is present */

-

-#define XCL_END       0    /* Marks end of individual items */

-#define XCL_SINGLE    1    /* Single item (one multibyte char) follows */

-#define XCL_RANGE     2    /* A range (two multibyte chars) follows */

-#define XCL_PROP      3    /* Unicode property (one property code) follows */

-#define XCL_NOTPROP   4    /* Unicode inverted property (ditto) */

-

-

-/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets

-that extract substrings. Starting from 1 (i.e. after OP_END), the values up to

-OP_EOD must correspond in order to the list of escapes immediately above.

-Note that whenever this list is updated, the two macro definitions that follow

-must also be updated to match. */

-

-enum {

-  OP_END,            /* 0 End of pattern */

-

-  /* Values corresponding to backslashed metacharacters */

-

-  OP_SOD,            /* 1 Start of data: \A */

-  OP_SOM,            /* 2 Start of match (subject + offset): \G */

-  OP_NOT_WORD_BOUNDARY,  /*  3 \B */

-  OP_WORD_BOUNDARY,      /*  4 \b */

-  OP_NOT_DIGIT,          /*  5 \D */

-  OP_DIGIT,              /*  6 \d */

-  OP_NOT_WHITESPACE,     /*  7 \S */

-  OP_WHITESPACE,         /*  8 \s */

-  OP_NOT_WORDCHAR,       /*  9 \W */

-  OP_WORDCHAR,           /* 10 \w */

-  OP_ANY,            /* 11 Match any character */

-  OP_ANYBYTE,        /* 12 Match any byte (\C); different to OP_ANY for UTF-8 */

-  OP_NOTPROP,        /* 13 \P (not Unicode property) */

-  OP_PROP,           /* 14 \p (Unicode property) */

-  OP_EXTUNI,         /* 15 \X (extended Unicode sequence */

-  OP_EODN,           /* 16 End of data or \n at end of data: \Z. */

-  OP_EOD,            /* 17 End of data: \z */

-

-  OP_OPT,            /* 18 Set runtime options */

-  OP_CIRC,           /* 19 Start of line - varies with multiline switch */

-  OP_DOLL,           /* 20 End of line - varies with multiline switch */

-  OP_CHAR,           /* 21 Match one character, casefully */

-  OP_CHARNC,         /* 22 Match one character, caselessly */

-  OP_NOT,            /* 23 Match anything but the following char */

-

-  OP_STAR,           /* 24 The maximizing and minimizing versions of */

-  OP_MINSTAR,        /* 25 all these opcodes must come in pairs, with */

-  OP_PLUS,           /* 26 the minimizing one second. */

-  OP_MINPLUS,        /* 27 This first set applies to single characters */

-  OP_QUERY,          /* 28 */

-  OP_MINQUERY,       /* 29 */

-  OP_UPTO,           /* 30 From 0 to n matches */

-  OP_MINUPTO,        /* 31 */

-  OP_EXACT,          /* 32 Exactly n matches */

-

-  OP_NOTSTAR,        /* 33 The maximizing and minimizing versions of */

-  OP_NOTMINSTAR,     /* 34 all these opcodes must come in pairs, with */

-  OP_NOTPLUS,        /* 35 the minimizing one second. */

-  OP_NOTMINPLUS,     /* 36 This set applies to "not" single characters */

-  OP_NOTQUERY,       /* 37 */

-  OP_NOTMINQUERY,    /* 38 */

-  OP_NOTUPTO,        /* 39 From 0 to n matches */

-  OP_NOTMINUPTO,     /* 40 */

-  OP_NOTEXACT,       /* 41 Exactly n matches */

-

-  OP_TYPESTAR,       /* 42 The maximizing and minimizing versions of */

-  OP_TYPEMINSTAR,    /* 43 all these opcodes must come in pairs, with */

-  OP_TYPEPLUS,       /* 44 the minimizing one second. These codes must */

-  OP_TYPEMINPLUS,    /* 45 be in exactly the same order as those above. */

-  OP_TYPEQUERY,      /* 46 This set applies to character types such as \d */

-  OP_TYPEMINQUERY,   /* 47 */

-  OP_TYPEUPTO,       /* 48 From 0 to n matches */

-  OP_TYPEMINUPTO,    /* 49 */

-  OP_TYPEEXACT,      /* 50 Exactly n matches */

-

-  OP_CRSTAR,         /* 51 The maximizing and minimizing versions of */

-  OP_CRMINSTAR,      /* 52 all these opcodes must come in pairs, with */

-  OP_CRPLUS,         /* 53 the minimizing one second. These codes must */

-  OP_CRMINPLUS,      /* 54 be in exactly the same order as those above. */

-  OP_CRQUERY,        /* 55 These are for character classes and back refs */

-  OP_CRMINQUERY,     /* 56 */

-  OP_CRRANGE,        /* 57 These are different to the three sets above. */

-  OP_CRMINRANGE,     /* 58 */

-

-  OP_CLASS,          /* 59 Match a character class, chars < 256 only */

-  OP_NCLASS,         /* 60 Same, but the bitmap was created from a negative

-                           class - the difference is relevant only when a UTF-8

-                           character > 255 is encountered. */

-

-  OP_XCLASS,         /* 61 Extended class for handling UTF-8 chars within the

-                           class. This does both positive and negative. */

-

-  OP_REF,            /* 62 Match a back reference */

-  OP_RECURSE,        /* 63 Match a numbered subpattern (possibly recursive) */

-  OP_CALLOUT,        /* 64 Call out to external function if provided */

-

-  OP_ALT,            /* 65 Start of alternation */

-  OP_KET,            /* 66 End of group that doesn't have an unbounded repeat */

-  OP_KETRMAX,        /* 67 These two must remain together and in this */

-  OP_KETRMIN,        /* 68 order. They are for groups the repeat for ever. */

-

-  /* The assertions must come before ONCE and COND */

-

-  OP_ASSERT,         /* 69 Positive lookahead */

-  OP_ASSERT_NOT,     /* 70 Negative lookahead */

-  OP_ASSERTBACK,     /* 71 Positive lookbehind */

-  OP_ASSERTBACK_NOT, /* 72 Negative lookbehind */

-  OP_REVERSE,        /* 73 Move pointer back - used in lookbehind assertions */

-

-  /* ONCE and COND must come after the assertions, with ONCE first, as there's

-  a test for >= ONCE for a subpattern that isn't an assertion. */

-

-  OP_ONCE,           /* 74 Once matched, don't back up into the subpattern */

-  OP_COND,           /* 75 Conditional group */

-  OP_CREF,           /* 76 Used to hold an extraction string number (cond ref) */

-

-  OP_BRAZERO,        /* 77 These two must remain together and in this */

-  OP_BRAMINZERO,     /* 78 order. */

-

-  OP_BRANUMBER,      /* 79 Used for extracting brackets whose number is greater

-                           than can fit into an opcode. */

-

-  OP_BRA             /* 80 This and greater values are used for brackets that

-                           extract substrings up to EXTRACT_BASIC_MAX. After

-                           that, use is made of OP_BRANUMBER. */

-};

-

-/* WARNING WARNING WARNING: There is an implicit assumption in pcre.c and

-study.c that all opcodes are less than 128 in value. This makes handling UTF-8

-character sequences easier. */

-

-/* The highest extraction number before we have to start using additional

-bytes. (Originally PCRE didn't have support for extraction counts highter than

-this number.) The value is limited by the number of opcodes left after OP_BRA,

-i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional

-opcodes. */

-

-#define EXTRACT_BASIC_MAX  100

-

-

-/* This macro defines textual names for all the opcodes. These are used only

-for debugging. The macro is referenced only in pcre_printint.c. */

-

-#define OP_NAME_LIST \

-  "End", "\\A", "\\G", "\\B", "\\b", "\\D", "\\d",                \

-  "\\S", "\\s", "\\W", "\\w", "Any", "Anybyte",                   \

-  "notprop", "prop", "extuni",                                    \

-  "\\Z", "\\z",                                                   \

-  "Opt", "^", "$", "char", "charnc", "not",                       \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \

-  "*", "*?", "+", "+?", "?", "??", "{", "{",                      \

-  "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \

-  "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \

-  "AssertB", "AssertB not", "Reverse", "Once", "Cond", "Cond ref",\

-  "Brazero", "Braminzero", "Branumber", "Bra"

-

-

-/* This macro defines the length of fixed length operations in the compiled

-regex. The lengths are used when searching for specific things, and also in the

-debugging printing of a compiled regex. We use a macro so that it can be

-defined close to the definitions of the opcodes themselves.

-

-As things have been extended, some of these are no longer fixed lenths, but are

-minima instead. For example, the length of a single-character repeat may vary

-in UTF-8 mode. The code that uses this table must know about such things. */

-

-#define OP_LENGTHS \

-  1,                             /* End                                    */ \

-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* \A, \G, \B, \B, \D, \d, \S, \s, \W, \w */ \

-  1, 1,                          /* Any, Anybyte                           */ \

-  2, 2, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \

-  1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \

-  2,                             /* Char  - the minimum length             */ \

-  2,                             /* Charnc  - the minimum length           */ \

-  2,                             /* not                                    */ \

-  /* Positive single-char repeats                            ** These are  */ \

-  2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??      ** minima in  */ \

-  4, 4, 4,                       /* upto, minupto, exact     ** UTF-8 mode */ \

-  /* Negative single-char repeats - only for chars < 256                   */ \

-  2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \

-  4, 4, 4,                       /* NOT upto, minupto, exact               */ \

-  /* Positive type repeats                                                 */ \

-  2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \

-  4, 4, 4,                       /* Type upto, minupto, exact              */ \

-  /* Character class & ref repeats                                         */ \

-  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \

-  5, 5,                          /* CRRANGE, CRMINRANGE                    */ \

- 33,                             /* CLASS                                  */ \

- 33,                             /* NCLASS                                 */ \

-  0,                             /* XCLASS - variable length               */ \

-  3,                             /* REF                                    */ \

-  1+LINK_SIZE,                   /* RECURSE                                */ \

-  2+2*LINK_SIZE,                 /* CALLOUT                                */ \

-  1+LINK_SIZE,                   /* Alt                                    */ \

-  1+LINK_SIZE,                   /* Ket                                    */ \

-  1+LINK_SIZE,                   /* KetRmax                                */ \

-  1+LINK_SIZE,                   /* KetRmin                                */ \

-  1+LINK_SIZE,                   /* Assert                                 */ \

-  1+LINK_SIZE,                   /* Assert not                             */ \

-  1+LINK_SIZE,                   /* Assert behind                          */ \

-  1+LINK_SIZE,                   /* Assert behind not                      */ \

-  1+LINK_SIZE,                   /* Reverse                                */ \

-  1+LINK_SIZE,                   /* Once                                   */ \

-  1+LINK_SIZE,                   /* COND                                   */ \

-  3,                             /* CREF                                   */ \

-  1, 1,                          /* BRAZERO, BRAMINZERO                    */ \

-  3,                             /* BRANUMBER                              */ \

-  1+LINK_SIZE                    /* BRA                                    */ \

-

-

-/* A magic value for OP_CREF to indicate the "in recursion" condition. */

-

-#define CREF_RECURSE  0xffff

-

-/* Error code numbers. They are given names so that they can more easily be

-tracked. */

-

-enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,

-       ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,

-       ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,

-       ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,

-       ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47 };

-

-/* The real format of the start of the pcre block; the index of names and the

-code vector run on as long as necessary after the end. We store an explicit

-offset to the name table so that if a regex is compiled on one host, saved, and

-then run on another where the size of pointers is different, all might still

-be well. For the case of compiled-on-4 and run-on-8, we include an extra

-pointer that is always NULL. For future-proofing, a few dummy fields were

-originally included - even though you can never get this planning right - but

-there is only one left now.

-

-NOTE NOTE NOTE:

-Because people can now save and re-use compiled patterns, any additions to this

-structure should be made at the end, and something earlier (e.g. a new

-flag in the options or one of the dummy fields) should indicate that the new

-fields are present. Currently PCRE always sets the dummy fields to zero.

-NOTE NOTE NOTE:

-*/

-

-typedef struct real_pcre {

-  pcre_uint32 magic_number;

-  pcre_uint32 size;               /* Total that was malloced */

-  pcre_uint32 options;

-  pcre_uint32 dummy1;             /* For future use, maybe */

-

-  pcre_uint16 top_bracket;

-  pcre_uint16 top_backref;

-  pcre_uint16 first_byte;

-  pcre_uint16 req_byte;

-  pcre_uint16 name_table_offset;  /* Offset to name table that follows */

-  pcre_uint16 name_entry_size;    /* Size of any name items */

-  pcre_uint16 name_count;         /* Number of name items */

-  pcre_uint16 ref_count;          /* Reference count */

-

-  const unsigned char *tables;    /* Pointer to tables or NULL for std */

-  const unsigned char *nullpad;   /* NULL padding */

-} real_pcre;

-

-/* The format of the block used to store data from pcre_study(). The same

-remark (see NOTE above) about extending this structure applies. */

-

-typedef struct pcre_study_data {

-  pcre_uint32 size;               /* Total that was malloced */

-  pcre_uint32 options;

-  uschar start_bits[32];

-} pcre_study_data;

-

-/* Structure for passing "static" information around between the functions

-doing the compiling, so that they are thread-safe. */

-

-typedef struct compile_data {

-  const uschar *lcc;            /* Points to lower casing table */

-  const uschar *fcc;            /* Points to case-flipping table */

-  const uschar *cbits;          /* Points to character type table */

-  const uschar *ctypes;         /* Points to table of type maps */

-  const uschar *start_code;     /* The start of the compiled code */

-  const uschar *start_pattern;  /* The start of the pattern */

-  uschar *name_table;           /* The name/number table */

-  int  names_found;             /* Number of entries so far */

-  int  name_entry_size;         /* Size of each entry */

-  int  top_backref;             /* Maximum back reference */

-  unsigned int backref_map;     /* Bitmap of low back refs */

-  int  req_varyopt;             /* "After variable item" flag for reqbyte */

-  BOOL nopartial;               /* Set TRUE if partial won't work */

-} compile_data;

-

-/* Structure for maintaining a chain of pointers to the currently incomplete

-branches, for testing for left recursion. */

-

-typedef struct branch_chain {

-  struct branch_chain *outer;

-  uschar *current;

-} branch_chain;

-

-/* Structure for items in a linked list that represents an explicit recursive

-call within the pattern. */

-

-typedef struct recursion_info {

-  struct recursion_info *prevrec; /* Previous recursion record (or NULL) */

-  int group_num;                /* Number of group that was called */

-  const uschar *after_call;     /* "Return value": points after the call in the expr */

-  const uschar *save_start;     /* Old value of md->start_match */

-  int *offset_save;             /* Pointer to start of saved offsets */

-  int saved_max;                /* Number of saved offsets */

-} recursion_info;

-

-/* When compiling in a mode that doesn't use recursive calls to match(),

-a structure is used to remember local variables on the heap. It is defined in

-pcre.c, close to the match() function, so that it is easy to keep it in step

-with any changes of local variable. However, the pointer to the current frame

-must be saved in some "static" place over a longjmp(). We declare the

-structure here so that we can put a pointer in the match_data structure.

-NOTE: This isn't used for a "normal" compilation of pcre. */

-

-struct heapframe;

-

-/* Structure for passing "static" information around between the functions

-doing traditional NFA matching, so that they are thread-safe. */

-

-typedef struct match_data {

-  unsigned long int match_call_count; /* As it says */

-  unsigned long int match_limit;/* As it says */

-  int   *offset_vector;         /* Offset vector */

-  int    offset_end;            /* One past the end */

-  int    offset_max;            /* The maximum usable for return data */

-  const uschar *lcc;            /* Points to lower casing table */

-  const uschar *ctypes;         /* Points to table of type maps */

-  BOOL   offset_overflow;       /* Set if too many extractions */

-  BOOL   notbol;                /* NOTBOL flag */

-  BOOL   noteol;                /* NOTEOL flag */

-  BOOL   utf8;                  /* UTF8 flag */

-  BOOL   endonly;               /* Dollar not before final \n */

-  BOOL   notempty;              /* Empty string match not wanted */

-  BOOL   partial;               /* PARTIAL flag */

-  BOOL   hitend;                /* Hit the end of the subject at some point */

-  const uschar *start_code;     /* For use when recursing */

-  const uschar *start_subject;  /* Start of the subject string */

-  const uschar *end_subject;    /* End of the subject string */

-  const uschar *start_match;    /* Start of this match attempt */

-  const uschar *end_match_ptr;  /* Subject position at end match */

-  int    end_offset_top;        /* Highwater mark at end of match */

-  int    capture_last;          /* Most recent capture number */

-  int    start_offset;          /* The start offset value */

-  recursion_info *recursive;    /* Linked list of recursion data */

-  void  *callout_data;          /* To pass back to callouts */

-  struct heapframe *thisframe;  /* Used only when compiling for no recursion */

-} match_data;

-

-/* A similar structure is used for the same purpose by the DFA matching

-functions. */

-

-typedef struct dfa_match_data {

-  const uschar *start_code;     /* Start of the compiled pattern */

-  const uschar *start_subject;  /* Start of the subject string */

-  const uschar *end_subject;    /* End of subject string */

-  const uschar *tables;         /* Character tables */

-  int   moptions;               /* Match options */

-  int   poptions;               /* Pattern options */

-  void  *callout_data;          /* To pass back to callouts */

-} dfa_match_data;

-

-/* Bit definitions for entries in the pcre_ctypes table. */

-

-#define ctype_space   0x01

-#define ctype_letter  0x02

-#define ctype_digit   0x04

-#define ctype_xdigit  0x08

-#define ctype_word    0x10   /* alphameric or '_' */

-#define ctype_meta    0x80   /* regexp meta char or zero (end pattern) */

-

-/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set

-of bits for a class map. Some classes are built by combining these tables. */

-

-#define cbit_space     0      /* [:space:] or \s */

-#define cbit_xdigit   32      /* [:xdigit:] */

-#define cbit_digit    64      /* [:digit:] or \d */

-#define cbit_upper    96      /* [:upper:] */

-#define cbit_lower   128      /* [:lower:] */

-#define cbit_word    160      /* [:word:] or \w */

-#define cbit_graph   192      /* [:graph:] */

-#define cbit_print   224      /* [:print:] */

-#define cbit_punct   256      /* [:punct:] */

-#define cbit_cntrl   288      /* [:cntrl:] */

-#define cbit_length  320      /* Length of the cbits table */

-

-/* Offsets of the various tables from the base tables pointer, and

-total length. */

-

-#define lcc_offset      0

-#define fcc_offset    256

-#define cbits_offset  512

-#define ctypes_offset (cbits_offset + cbit_length)

-#define tables_length (ctypes_offset + 256)

-

-/* Layout of the UCP type table that translates property names into codes for

-ucp_findchar(). */

-

-typedef struct {

-  const char *name;

-  int value;

-} ucp_type_table;

-

-

-/* Internal shared data tables. These are tables that are used by more than one

-of the exported public functions. They have to be "external" in the C sense,

-but are not part of the PCRE public API. The data for these tables is in the

-pcre_tables.c module. */

-

-extern const int    _pcre_utf8_table1[];

-extern const int    _pcre_utf8_table2[];

-extern const int    _pcre_utf8_table3[];

-extern const uschar _pcre_utf8_table4[];

-

-extern const int    _pcre_utf8_table1_size;

-

-extern const ucp_type_table _pcre_utt[];

-extern const int _pcre_utt_size;

-

-extern const uschar _pcre_default_tables[];

-

-extern const uschar _pcre_OP_lengths[];

-

-

-/* Internal shared functions. These are functions that are used by more than

-one of the exported public functions. They have to be "external" in the C

-sense, but are not part of the PCRE public API. */

-

-extern int         _pcre_ord2utf8(int, uschar *);

-extern void        _pcre_printint(pcre *, FILE *);

-extern real_pcre * _pcre_try_flipped(const real_pcre *, real_pcre *,

-                     const pcre_study_data *, pcre_study_data *);

-extern int         _pcre_ucp_findchar(const int, int *, int *);

-extern int         _pcre_valid_utf8(const uschar *, int);

-extern BOOL        _pcre_xclass(int, const uschar *);

-

-/* End of pcre_internal.h */

-

-

-/*************************************************

-*      Code parameters and static tables         *

-*************************************************/

-

-/* Maximum number of items on the nested bracket stacks at compile time. This

-applies to the nesting of all kinds of parentheses. It does not limit

-un-nested, non-capturing parentheses. This number can be made bigger if

-necessary - it is used to dimension one int and one unsigned char vector at

-compile time. */

-

-#define BRASTACK_SIZE 200

-

-

-/* Table for handling escaped characters in the range '0'-'z'. Positive returns

-are simple data values; negative values are for special things like \d and so

-on. Zero means further processing is needed (for things like \x), or the escape

-is invalid. */

-

-#if !EBCDIC   /* This is the "normal" table for ASCII systems */

-static const short int escapes[] = {

-     0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */

-     0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */

-   '@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E,      0, -ESC_G,   /* @ - G */

-     0,      0,      0,      0,      0,      0,      0,      0,   /* H - O */

--ESC_P, -ESC_Q,      0, -ESC_S,      0,      0,      0, -ESC_W,   /* P - W */

--ESC_X,      0, -ESC_Z,    '[',   '\\',    ']',    '^',    '_',   /* X - _ */

-   '`',      7, -ESC_b,      0, -ESC_d,  ESC_e,  ESC_f,      0,   /* ` - g */

-     0,      0,      0,      0,      0,      0,  ESC_n,      0,   /* h - o */

--ESC_p,      0,  ESC_r, -ESC_s,  ESC_tee,    0,      0, -ESC_w,   /* p - w */

-     0,      0, -ESC_z                                            /* x - z */

-};

-

-#else         /* This is the "abnormal" table for EBCDIC systems */

-static const short int escapes[] = {

-/*  48 */     0,     0,      0,     '.',    '<',   '(',    '+',    '|',

-/*  50 */   '&',     0,      0,       0,      0,     0,      0,      0,

-/*  58 */     0,     0,    '!',     '$',    '*',   ')',    ';',    '~',

-/*  60 */   '-',   '/',      0,       0,      0,     0,      0,      0,

-/*  68 */     0,     0,    '|',     ',',    '%',   '_',    '>',    '?',

-/*  70 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  78 */     0,   '`',    ':',     '#',    '@',  '\'',    '=',    '"',

-/*  80 */     0,     7, -ESC_b,       0, -ESC_d, ESC_e,  ESC_f,      0,

-/*  88 */     0,     0,      0,     '{',      0,     0,      0,      0,

-/*  90 */     0,     0,      0,     'l',      0, ESC_n,      0, -ESC_p,

-/*  98 */     0, ESC_r,      0,     '}',      0,     0,      0,      0,

-/*  A0 */     0,   '~', -ESC_s, ESC_tee,      0,     0, -ESC_w,      0,

-/*  A8 */     0,-ESC_z,      0,       0,      0,   '[',      0,      0,

-/*  B0 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  B8 */     0,     0,      0,       0,      0,   ']',    '=',    '-',

-/*  C0 */   '{',-ESC_A, -ESC_B,  -ESC_C, -ESC_D,-ESC_E,      0, -ESC_G,

-/*  C8 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  D0 */   '}',     0,      0,       0,      0,     0,      0, -ESC_P,

-/*  D8 */-ESC_Q,     0,      0,       0,      0,     0,      0,      0,

-/*  E0 */  '\\',     0, -ESC_S,       0,      0,     0, -ESC_W, -ESC_X,

-/*  E8 */     0,-ESC_Z,      0,       0,      0,     0,      0,      0,

-/*  F0 */     0,     0,      0,       0,      0,     0,      0,      0,

-/*  F8 */     0,     0,      0,       0,      0,     0,      0,      0

-};

-#endif

-

-

-/* Tables of names of POSIX character classes and their lengths. The list is

-terminated by a zero length entry. The first three must be alpha, upper, lower,

-as this is assumed for handling case independence. */

-

-static const char *const posix_names[] = {

-  "alpha", "lower", "upper",

-  "alnum", "ascii", "blank", "cntrl", "digit", "graph",

-  "print", "punct", "space", "word",  "xdigit" };

-

-static const uschar posix_name_lengths[] = {

-  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };

-

-/* Table of class bit maps for each POSIX class; up to three may be combined

-to form the class. The table for [:blank:] is dynamically modified to remove

-the vertical space characters. */

-

-static const int posix_class_maps[] = {

-  cbit_lower, cbit_upper, -1,             /* alpha */

-  cbit_lower, -1,         -1,             /* lower */

-  cbit_upper, -1,         -1,             /* upper */

-  cbit_digit, cbit_lower, cbit_upper,     /* alnum */

-  cbit_print, cbit_cntrl, -1,             /* ascii */

-  cbit_space, -1,         -1,             /* blank - a GNU extension */

-  cbit_cntrl, -1,         -1,             /* cntrl */

-  cbit_digit, -1,         -1,             /* digit */

-  cbit_graph, -1,         -1,             /* graph */

-  cbit_print, -1,         -1,             /* print */

-  cbit_punct, -1,         -1,             /* punct */

-  cbit_space, -1,         -1,             /* space */

-  cbit_word,  -1,         -1,             /* word - a Perl extension */

-  cbit_xdigit,-1,         -1              /* xdigit */

-};

-

-

-/* The texts of compile-time error messages. These are "char *" because they

-are passed to the outside world. */

-

-static const char *error_texts[] = {

-  "no error",

-  "\\ at end of pattern",

-  "\\c at end of pattern",

-  "unrecognized character follows \\",

-  "numbers out of order in {} quantifier",

-  /* 5 */

-  "number too big in {} quantifier",

-  "missing terminating ] for character class",

-  "invalid escape sequence in character class",

-  "range out of order in character class",

-  "nothing to repeat",

-  /* 10 */

-  "operand of unlimited repeat could match the empty string",

-  "internal error: unexpected repeat",

-  "unrecognized character after (?",

-  "POSIX named classes are supported only within a class",

-  "missing )",

-  /* 15 */

-  "reference to non-existent subpattern",

-  "erroffset passed as NULL",

-  "unknown option bit(s) set",

-  "missing ) after comment",

-  "parentheses nested too deeply",

-  /* 20 */

-  "regular expression too large",

-  "failed to get memory",

-  "unmatched parentheses",

-  "internal error: code overflow",

-  "unrecognized character after (?<",

-  /* 25 */

-  "lookbehind assertion is not fixed length",

-  "malformed number after (?(",

-  "conditional group contains more than two branches",

-  "assertion expected after (?(",

-  "(?R or (?digits must be followed by )",

-  /* 30 */

-  "unknown POSIX class name",

-  "POSIX collating elements are not supported",

-  "this version of PCRE is not compiled with PCRE_UTF8 support",

-  "spare error",

-  "character value in \\x{...} sequence is too large",

-  /* 35 */

-  "invalid condition (?(0)",

-  "\\C not allowed in lookbehind assertion",

-  "PCRE does not support \\L, \\l, \\N, \\U, or \\u",

-  "number after (?C is > 255",

-  "closing ) for (?C expected",

-  /* 40 */

-  "recursive call could loop indefinitely",

-  "unrecognized character after (?P",

-  "syntax error after (?P",

-  "two named groups have the same name",

-  "invalid UTF-8 string",

-  /* 45 */

-  "support for \\P, \\p, and \\X has not been compiled",

-  "malformed \\P or \\p sequence",

-  "unknown property name after \\P or \\p"

-};

-

-

-/* Table to identify digits and hex digits. This is used when compiling

-patterns. Note that the tables in chartables are dependent on the locale, and

-may mark arbitrary characters as digits - but the PCRE compiling code expects

-to handle only 0-9, a-z, and A-Z as digits when compiling. That is why we have

-a private table here. It costs 256 bytes, but it is a lot faster than doing

-character value tests (at least in some simple cases I timed), and in some

-applications one wants PCRE to compile efficiently as well as match

-efficiently.

-

-For convenience, we use the same bit definitions as in chartables:

-

-  0x04   decimal digit

-  0x08   hexadecimal digit

-

-Then we can use ctype_digit and ctype_xdigit in the code. */

-

-#if !EBCDIC    /* This is the "normal" case, for ASCII systems */

-static const unsigned char digitab[] =

-  {

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - '  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ( - /  */

-  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  */

-  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /*  8 - ?  */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  @ - G  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H - O  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  P - W  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  X - _  */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  ` - g  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h - o  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  p - w  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  x -127 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */

-

-#else          /* This is the "abnormal" case, for EBCDIC systems */

-static const unsigned char digitab[] =

-  {

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   0-  7  0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*   8- 15    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  16- 23 10 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  32- 39 20 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 30 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 40 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  72- |     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 50 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  88- ¬     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 60 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ?     */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "     */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* 128- g  80 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144- p  90 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160- x  A0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 B0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191    */

-  0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /*  { - G  C0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  } - P  D0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223    */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  \ - X  E0 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239    */

-  0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /*  0 - 7  F0 */

-  0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255    */

-

-static const unsigned char ebcdic_chartab[] = { /* chartable partial dup */

-  0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*   0-  7 */

-  0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, /*   8- 15 */

-  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  16- 23 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  24- 31 */

-  0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /*  32- 39 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  40- 47 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  48- 55 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  56- 63 */

-  0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*    - 71 */

-  0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /*  72- |  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  & - 87 */

-  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /*  88- ¬  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  - -103 */

-  0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ?  */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */

-  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- "  */

-  0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* 128- g  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  h -143 */

-  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* 144- p  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  q -159 */

-  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* 160- x  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  y -175 */

-  0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*  ^ -183 */

-  0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 184-191 */

-  0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /*  { - G  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  H -207 */

-  0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /*  } - P  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Q -223 */

-  0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /*  \ - X  */

-  0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /*  Y -239 */

-  0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /*  0 - 7  */

-  0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/*  8 -255 */

-#endif

-

-

-/* Definition to allow mutual recursion */

-

-static BOOL

-  compile_regex(int, int, int *, uschar **, const uschar **, int *, BOOL, int,

-    int *, int *, branch_chain *, compile_data *);

-

-

-

-/*************************************************

-*            Handle escapes                      *

-*************************************************/

-

-/* This function is called when a \ has been encountered. It either returns a

-positive value for a simple escape such as \n, or a negative value which

-encodes one of the more complicated things such as \d. When UTF-8 is enabled,

-a positive value greater than 255 may be returned. On entry, ptr is pointing at

-the \. On exit, it is on the final character of the escape sequence.

-

-Arguments:

-  ptrptr         points to the pattern position pointer

-  errorcodeptr   points to the errorcode variable

-  bracount       number of previous extracting brackets

-  options        the options bits

-  isclass        TRUE if inside a character class

-

-Returns:         zero or positive => a data character

-                 negative => a special escape sequence

-                 on error, errorptr is set

-*/

-

-static int

-check_escape(const uschar **ptrptr, int *errorcodeptr, int bracount,

-  int options, BOOL isclass)

-{

-const uschar *ptr = *ptrptr;

-int c, i;

-

-/* If backslash is at the end of the pattern, it's an error. */

-

-c = *(++ptr);

-if (c == 0) *errorcodeptr = ERR1;

-

-/* Non-alphamerics are literals. For digits or letters, do an initial lookup in

-a table. A non-zero result is something that can be returned immediately.

-Otherwise further processing may be required. */

-

-#if !EBCDIC    /* ASCII coding */

-else if (c < '0' || c > 'z') {}                           /* Not alphameric */

-else if ((i = escapes[c - '0']) != 0) c = i;

-

-#else          /* EBCDIC coding */

-else if (c < 'a' || (ebcdic_chartab[c] & 0x0E) == 0) {}   /* Not alphameric */

-else if ((i = escapes[c - 0x48]) != 0)  c = i;

-#endif

-

-/* Escapes that need further processing, or are illegal. */

-

-else

-  {

-  const uschar *oldptr;

-  switch (c)

-    {

-    /* A number of Perl escapes are not handled by PCRE. We give an explicit

-    error. */

-

-    case 'l':

-    case 'L':

-    case 'N':

-    case 'u':

-    case 'U':

-    *errorcodeptr = ERR37;

-    break;

-

-    /* The handling of escape sequences consisting of a string of digits

-    starting with one that is not zero is not straightforward. By experiment,

-    the way Perl works seems to be as follows:

-

-    Outside a character class, the digits are read as a decimal number. If the

-    number is less than 10, or if there are that many previous extracting

-    left brackets, then it is a back reference. Otherwise, up to three octal

-    digits are read to form an escaped byte. Thus \123 is likely to be octal

-    123 (cf \0123, which is octal 012 followed by the literal 3). If the octal

-    value is greater than 377, the least significant 8 bits are taken. Inside a

-    character class, \ followed by a digit is always an octal number. */

-

-    case '1': case '2': case '3': case '4': case '5':

-    case '6': case '7': case '8': case '9':

-

-    if (!isclass)

-      {

-      oldptr = ptr;

-      c -= '0';

-      while ((digitab[ptr[1]] & ctype_digit) != 0)

-        c = c * 10 + *(++ptr) - '0';

-      if (c < 10 || c <= bracount)

-        {

-        c = -(ESC_REF + c);

-        break;

-        }

-      ptr = oldptr;      /* Put the pointer back and fall through */

-      }

-

-    /* Handle an octal number following \. If the first digit is 8 or 9, Perl

-    generates a binary zero byte and treats the digit as a following literal.

-    Thus we have to pull back the pointer by one. */

-

-    if ((c = *ptr) >= '8')

-      {

-      ptr--;

-      c = 0;

-      break;

-      }

-

-    /* \0 always starts an octal number, but we may drop through to here with a

-    larger first octal digit. */

-

-    case '0':

-    c -= '0';

-    while(i++ < 2 && ptr[1] >= '0' && ptr[1] <= '7')

-        c = c * 8 + *(++ptr) - '0';

-    c &= 255;     /* Take least significant 8 bits */

-    break;

-

-    /* \x is complicated when UTF-8 is enabled. \x{ddd} is a character number

-    which can be greater than 0xff, but only if the ddd are hex digits. */

-

-    case 'x':

-#ifdef SUPPORT_UTF8

-    if (ptr[1] == '{' && (options & PCRE_UTF8) != 0)

-      {

-      const uschar *pt = ptr + 2;

-      register int count = 0;

-      c = 0;

-      while ((digitab[*pt] & ctype_xdigit) != 0)

-        {

-        int cc = *pt++;

-        count++;

-#if !EBCDIC    /* ASCII coding */

-        if (cc >= 'a') cc -= 32;               /* Convert to upper case */

-        c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));

-#else          /* EBCDIC coding */

-        if (cc >= 'a' && cc <= 'z') cc += 64;  /* Convert to upper case */

-        c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));

-#endif

-        }

-      if (*pt == '}')

-        {

-        if (c < 0 || count > 8) *errorcodeptr = ERR34;

-        ptr = pt;

-        break;

-        }

-      /* If the sequence of hex digits does not end with '}', then we don't

-      recognize this construct; fall through to the normal \x handling. */

-      }

-#endif

-

-    /* Read just a single hex char */

-

-    c = 0;

-    while (i++ < 2 && (digitab[ptr[1]] & ctype_xdigit) != 0)

-      {

-      int cc;                               /* Some compilers don't like ++ */

-      cc = *(++ptr);                        /* in initializers */

-#if !EBCDIC    /* ASCII coding */

-      if (cc >= 'a') cc -= 32;              /* Convert to upper case */

-      c = c * 16 + cc - ((cc < 'A')? '0' : ('A' - 10));

-#else          /* EBCDIC coding */

-      if (cc <= 'z') cc += 64;              /* Convert to upper case */

-      c = c * 16 + cc - ((cc >= '0')? '0' : ('A' - 10));

-#endif

-      }

-    break;

-

-    /* Other special escapes not starting with a digit are straightforward */

-

-    case 'c':

-    c = *(++ptr);

-    if (c == 0)

-      {

-      *errorcodeptr = ERR2;

-      return 0;

-      }

-

-    /* A letter is upper-cased; then the 0x40 bit is flipped. This coding

-    is ASCII-specific, but then the whole concept of \cx is ASCII-specific.

-    (However, an EBCDIC equivalent has now been added.) */

-

-#if !EBCDIC    /* ASCII coding */

-    if (c >= 'a' && c <= 'z') c -= 32;

-    c ^= 0x40;

-#else          /* EBCDIC coding */

-    if (c >= 'a' && c <= 'z') c += 64;

-    c ^= 0xC0;

-#endif

-    break;

-

-    /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any

-    other alphameric following \ is an error if PCRE_EXTRA was set; otherwise,

-    for Perl compatibility, it is a literal. This code looks a bit odd, but

-    there used to be some cases other than the default, and there may be again

-    in future, so I haven't "optimized" it. */

-

-    default:

-    if ((options & PCRE_EXTRA) != 0) switch(c)

-      {

-      default:

-      *errorcodeptr = ERR3;

-      break;

-      }

-    break;

-    }

-  }

-

-*ptrptr = ptr;

-return c;

-}

-

-

-

-#ifdef SUPPORT_UCP

-/*************************************************

-*               Handle \P and \p                 *

-*************************************************/

-

-/* This function is called after \P or \p has been encountered, provided that

-PCRE is compiled with support for Unicode properties. On entry, ptrptr is

-pointing at the P or p. On exit, it is pointing at the final character of the

-escape sequence.

-

-Argument:

-  ptrptr         points to the pattern position pointer

-  negptr         points to a boolean that is set TRUE for negation else FALSE

-  errorcodeptr   points to the error code variable

-

-Returns:     value from ucp_type_table, or -1 for an invalid type

-*/

-

-static int

-get_ucp(const uschar **ptrptr, BOOL *negptr, int *errorcodeptr)

-{

-int c, i, bot, top;

-const uschar *ptr = *ptrptr;

-char name[4];

-

-c = *(++ptr);

-if (c == 0) goto ERROR_RETURN;

-

-*negptr = FALSE;

-

-/* \P or \p can be followed by a one- or two-character name in {}, optionally

-preceded by ^ for negation. */

-

-if (c == '{')

-  {

-  if (ptr[1] == '^')

-    {

-    *negptr = TRUE;

-    ptr++;

-    }

-  for (i = 0; i <= 2; i++)

-    {

-    c = *(++ptr);

-    if (c == 0) goto ERROR_RETURN;

-    if (c == '}') break;

-    name[i] = c;

-    }

-  if (c !='}')   /* Try to distinguish error cases */

-    {

-    while (*(++ptr) != 0 && *ptr != '}');

-    if (*ptr == '}') goto UNKNOWN_RETURN; else goto ERROR_RETURN;

-    }

-  name[i] = 0;

-  }

-

-/* Otherwise there is just one following character */

-

-else

-  {

-  name[0] = c;

-  name[1] = 0;

-  }

-

-*ptrptr = ptr;

-

-/* Search for a recognized property name using binary chop */

-

-bot = 0;

-top = _pcre_utt_size;

-

-while (bot < top)

-  {

-  i = (bot + top)/2;

-  c = strcmp(name, _pcre_utt[i].name);

-  if (c == 0) return _pcre_utt[i].value;

-  if (c > 0) bot = i + 1; else top = i;

-  }

-

-UNKNOWN_RETURN:

-*errorcodeptr = ERR47;

-*ptrptr = ptr;

-return -1;

-

-ERROR_RETURN:

-*errorcodeptr = ERR46;

-*ptrptr = ptr;

-return -1;

-}

-#endif

-

-

-

-

-/*************************************************

-*            Check for counted repeat            *

-*************************************************/

-

-/* This function is called when a '{' is encountered in a place where it might

-start a quantifier. It looks ahead to see if it really is a quantifier or not.

-It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}

-where the ddds are digits.

-

-Arguments:

-  p         pointer to the first char after '{'

-

-Returns:    TRUE or FALSE

-*/

-

-static BOOL

-is_counted_repeat(const uschar *p)

-{

-if ((digitab[*p++] & ctype_digit) == 0) return FALSE;

-while ((digitab[*p] & ctype_digit) != 0) p++;

-if (*p == '}') return TRUE;

-

-if (*p++ != ',') return FALSE;

-if (*p == '}') return TRUE;

-

-if ((digitab[*p++] & ctype_digit) == 0) return FALSE;

-while ((digitab[*p] & ctype_digit) != 0) p++;

-

-return (*p == '}');

-}

-

-

-

-/*************************************************

-*         Read repeat counts                     *

-*************************************************/

-

-/* Read an item of the form {n,m} and return the values. This is called only

-after is_counted_repeat() has confirmed that a repeat-count quantifier exists,

-so the syntax is guaranteed to be correct, but we need to check the values.

-

-Arguments:

-  p              pointer to first char after '{'

-  minp           pointer to int for min

-  maxp           pointer to int for max

-                 returned as -1 if no max

-  errorcodeptr   points to error code variable

-

-Returns:         pointer to '}' on success;

-                 current ptr on error, with errorcodeptr set non-zero

-*/

-

-static const uschar *

-read_repeat_counts(const uschar *p, int *minp, int *maxp, int *errorcodeptr)

-{

-int min = 0;

-int max = -1;

-

-/* Read the minimum value and do a paranoid check: a negative value indicates

-an integer overflow. */

-

-while ((digitab[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';

-if (min < 0 || min > 65535)

-  {

-  *errorcodeptr = ERR5;

-  return p;

-  }

-

-/* Read the maximum value if there is one, and again do a paranoid on its size.

-Also, max must not be less than min. */

-

-if (*p == '}') max = min; else

-  {

-  if (*(++p) != '}')

-    {

-    max = 0;

-    while((digitab[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';

-    if (max < 0 || max > 65535)

-      {

-      *errorcodeptr = ERR5;

-      return p;

-      }

-    if (max < min)

-      {

-      *errorcodeptr = ERR4;

-      return p;

-      }

-    }

-  }

-

-/* Fill in the required variables, and pass back the pointer to the terminating

-'}'. */

-

-*minp = min;

-*maxp = max;

-return p;

-}

-

-

-

-/*************************************************

-*      Find first significant op code            *

-*************************************************/

-

-/* This is called by several functions that scan a compiled expression looking

-for a fixed first character, or an anchoring op code etc. It skips over things

-that do not influence this. For some calls, a change of option is important.

-For some calls, it makes sense to skip negative forward and all backward

-assertions, and also the \b assertion; for others it does not.

-

-Arguments:

-  code         pointer to the start of the group

-  options      pointer to external options

-  optbit       the option bit whose changing is significant, or

-                 zero if none are

-  skipassert   TRUE if certain assertions are to be skipped

-

-Returns:       pointer to the first significant opcode

-*/

-

-static const uschar*

-first_significant_code(const uschar *code, int *options, int optbit,

-  BOOL skipassert)

-{

-for (;;)

-  {

-  switch ((int)*code)

-    {

-    case OP_OPT:

-    if (optbit > 0 && ((int)code[1] & optbit) != (*options & optbit))

-      *options = (int)code[1];

-    code += 2;

-    break;

-

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    if (!skipassert) return code;

-    do code += GET(code, 1); while (*code == OP_ALT);

-    code += _pcre_OP_lengths[*code];

-    break;

-

-    case OP_WORD_BOUNDARY:

-    case OP_NOT_WORD_BOUNDARY:

-    if (!skipassert) return code;

-    /* Fall through */

-

-    case OP_CALLOUT:

-    case OP_CREF:

-    case OP_BRANUMBER:

-    code += _pcre_OP_lengths[*code];

-    break;

-

-    default:

-    return code;

-    }

-  }

-/* Control never reaches here */

-}

-

-

-

-

-/*************************************************

-*        Find the fixed length of a pattern      *

-*************************************************/

-

-/* Scan a pattern and compute the fixed length of subject that will match it,

-if the length is fixed. This is needed for dealing with backward assertions.

-In UTF8 mode, the result is in characters rather than bytes.

-

-Arguments:

-  code     points to the start of the pattern (the bracket)

-  options  the compiling options

-

-Returns:   the fixed length, or -1 if there is no fixed length,

-             or -2 if \C was encountered

-*/

-

-static int

-find_fixedlength(uschar *code, int options)

-{

-int length = -1;

-

-register int branchlength = 0;

-register uschar *cc = code + 1 + LINK_SIZE;

-

-/* Scan along the opcodes for this branch. If we get to the end of the

-branch, check the length against that of the other branches. */

-

-for (;;)

-  {

-  int d;

-  register int op = *cc;

-  if (op >= OP_BRA) op = OP_BRA;

-

-  switch (op)

-    {

-    case OP_BRA:

-    case OP_ONCE:

-    case OP_COND:

-    d = find_fixedlength(cc, options);

-    if (d < 0) return d;

-    branchlength += d;

-    do cc += GET(cc, 1); while (*cc == OP_ALT);

-    cc += 1 + LINK_SIZE;

-    break;

-

-    /* Reached end of a branch; if it's a ket it is the end of a nested

-    call. If it's ALT it is an alternation in a nested call. If it is

-    END it's the end of the outer call. All can be handled by the same code. */

-

-    case OP_ALT:

-    case OP_KET:

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_END:

-    if (length < 0) length = branchlength;

-      else if (length != branchlength) return -1;

-    if (*cc != OP_ALT) return length;

-    cc += 1 + LINK_SIZE;

-    branchlength = 0;

-    break;

-

-    /* Skip over assertive subpatterns */

-

-    case OP_ASSERT:

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    do cc += GET(cc, 1); while (*cc == OP_ALT);

-    /* Fall through */

-

-    /* Skip over things that don't match chars */

-

-    case OP_REVERSE:

-    case OP_BRANUMBER:

-    case OP_CREF:

-    case OP_OPT:

-    case OP_CALLOUT:

-    case OP_SOD:

-    case OP_SOM:

-    case OP_EOD:

-    case OP_EODN:

-    case OP_CIRC:

-    case OP_DOLL:

-    case OP_NOT_WORD_BOUNDARY:

-    case OP_WORD_BOUNDARY:

-    cc += _pcre_OP_lengths[*cc];

-    break;

-

-    /* Handle literal characters */

-

-    case OP_CHAR:

-    case OP_CHARNC:

-    branchlength++;

-    cc += 2;

-#ifdef SUPPORT_UTF8

-    if ((options & PCRE_UTF8) != 0)

-      {

-      while ((*cc & 0xc0) == 0x80) cc++;

-      }

-#endif

-    break;

-

-    /* Handle exact repetitions. The count is already in characters, but we

-    need to skip over a multibyte character in UTF8 mode.  */

-

-    case OP_EXACT:

-    branchlength += GET2(cc,1);

-    cc += 4;

-#ifdef SUPPORT_UTF8

-    if ((options & PCRE_UTF8) != 0)

-      {

-      while((*cc & 0x80) == 0x80) cc++;

-      }

-#endif

-    break;

-

-    case OP_TYPEEXACT:

-    branchlength += GET2(cc,1);

-    cc += 4;

-    break;

-

-    /* Handle single-char matchers */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    cc++;

-    /* Fall through */

-

-    case OP_NOT_DIGIT:

-    case OP_DIGIT:

-    case OP_NOT_WHITESPACE:

-    case OP_WHITESPACE:

-    case OP_NOT_WORDCHAR:

-    case OP_WORDCHAR:

-    case OP_ANY:

-    branchlength++;

-    cc++;

-    break;

-

-    /* The single-byte matcher isn't allowed */

-

-    case OP_ANYBYTE:

-    return -2;

-

-    /* Check a class for variable quantification */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-    cc += GET(cc, 1) - 33;

-    /* Fall through */

-#endif

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    cc += 33;

-

-    switch (*cc)

-      {

-      case OP_CRSTAR:

-      case OP_CRMINSTAR:

-      case OP_CRQUERY:

-      case OP_CRMINQUERY:

-      return -1;

-

-      case OP_CRRANGE:

-      case OP_CRMINRANGE:

-      if (GET2(cc,1) != GET2(cc,3)) return -1;

-      branchlength += GET2(cc,1);

-      cc += 5;

-      break;

-

-      default:

-      branchlength++;

-      }

-    break;

-

-    /* Anything else is variable length */

-

-    default:

-    return -1;

-    }

-  }

-/* Control never gets here */

-}

-

-

-

-

-/*************************************************

-*    Scan compiled regex for numbered bracket    *

-*************************************************/

-

-/* This little function scans through a compiled pattern until it finds a

-capturing bracket with the given number.

-

-Arguments:

-  code        points to start of expression

-  utf8        TRUE in UTF-8 mode

-  number      the required bracket number

-

-Returns:      pointer to the opcode for the bracket, or NULL if not found

-*/

-

-static const uschar *

-find_bracket(const uschar *code, BOOL utf8, int number)

-{

-#ifndef SUPPORT_UTF8

-utf8 = utf8;               /* Stop pedantic compilers complaining */

-#endif

-

-for (;;)

-  {

-  register int c = *code;

-  if (c == OP_END) return NULL;

-  else if (c > OP_BRA)

-    {

-    int n = c - OP_BRA;

-    if (n > EXTRACT_BASIC_MAX) n = GET2(code, 2+LINK_SIZE);

-    if (n == number) return (uschar *)code;

-    code += _pcre_OP_lengths[OP_BRA];

-    }

-  else

-    {

-    code += _pcre_OP_lengths[c];

-

-#ifdef SUPPORT_UTF8

-

-    /* In UTF-8 mode, opcodes that are followed by a character may be followed

-    by a multi-byte character. The length in the table is a minimum, so we have

-    to scan along to skip the extra bytes. All opcodes are less than 128, so we

-    can use relatively efficient code. */

-

-    if (utf8) switch(c)

-      {

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      while ((*code & 0xc0) == 0x80) code++;

-      break;

-

-      /* XCLASS is used for classes that cannot be represented just by a bit

-      map. This includes negated single high-valued characters. The length in

-      the table is zero; the actual length is stored in the compiled code. */

-

-      case OP_XCLASS:

-      code += GET(code, 1) + 1;

-      break;

-      }

-#endif

-    }

-  }

-}

-

-

-

-/*************************************************

-*   Scan compiled regex for recursion reference  *

-*************************************************/

-

-/* This little function scans through a compiled pattern until it finds an

-instance of OP_RECURSE.

-

-Arguments:

-  code        points to start of expression

-  utf8        TRUE in UTF-8 mode

-

-Returns:      pointer to the opcode for OP_RECURSE, or NULL if not found

-*/

-

-static const uschar *

-find_recurse(const uschar *code, BOOL utf8)

-{

-#ifndef SUPPORT_UTF8

-utf8 = utf8;               /* Stop pedantic compilers complaining */

-#endif

-

-for (;;)

-  {

-  register int c = *code;

-  if (c == OP_END) return NULL;

-  else if (c == OP_RECURSE) return code;

-  else if (c > OP_BRA)

-    {

-    code += _pcre_OP_lengths[OP_BRA];

-    }

-  else

-    {

-    code += _pcre_OP_lengths[c];

-

-#ifdef SUPPORT_UTF8

-

-    /* In UTF-8 mode, opcodes that are followed by a character may be followed

-    by a multi-byte character. The length in the table is a minimum, so we have

-    to scan along to skip the extra bytes. All opcodes are less than 128, so we

-    can use relatively efficient code. */

-

-    if (utf8) switch(c)

-      {

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      while ((*code & 0xc0) == 0x80) code++;

-      break;

-

-      /* XCLASS is used for classes that cannot be represented just by a bit

-      map. This includes negated single high-valued characters. The length in

-      the table is zero; the actual length is stored in the compiled code. */

-

-      case OP_XCLASS:

-      code += GET(code, 1) + 1;

-      break;

-      }

-#endif

-    }

-  }

-}

-

-

-

-/*************************************************

-*    Scan compiled branch for non-emptiness      *

-*************************************************/

-

-/* This function scans through a branch of a compiled pattern to see whether it

-can match the empty string or not. It is called only from could_be_empty()

-below. Note that first_significant_code() skips over assertions. If we hit an

-unclosed bracket, we return "empty" - this means we've struck an inner bracket

-whose current branch will already have been scanned.

-

-Arguments:

-  code        points to start of search

-  endcode     points to where to stop

-  utf8        TRUE if in UTF8 mode

-

-Returns:      TRUE if what is matched could be empty

-*/

-

-static BOOL

-could_be_empty_branch(const uschar *code, const uschar *endcode, BOOL utf8)

-{

-register int c;

-for (code = first_significant_code(code + 1 + LINK_SIZE, NULL, 0, TRUE);

-     code < endcode;

-     code = first_significant_code(code + _pcre_OP_lengths[c], NULL, 0, TRUE))

-  {

-  const uschar *ccode;

-

-  c = *code;

-

-  if (c >= OP_BRA)

-    {

-    BOOL empty_branch;

-    if (GET(code, 1) == 0) return TRUE;    /* Hit unclosed bracket */

-

-    /* Scan a closed bracket */

-

-    empty_branch = FALSE;

-    do

-      {

-      if (!empty_branch && could_be_empty_branch(code, endcode, utf8))

-        empty_branch = TRUE;

-      code += GET(code, 1);

-      }

-    while (*code == OP_ALT);

-    if (!empty_branch) return FALSE;   /* All branches are non-empty */

-    code += 1 + LINK_SIZE;

-    c = *code;

-    }

-

-  else switch (c)

-    {

-    /* Check for quantifiers after a class */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-    ccode = code + GET(code, 1);

-    goto CHECK_CLASS_REPEAT;

-#endif

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    ccode = code + 33;

-

-#ifdef SUPPORT_UTF8

-    CHECK_CLASS_REPEAT:

-#endif

-

-    switch (*ccode)

-      {

-      case OP_CRSTAR:            /* These could be empty; continue */

-      case OP_CRMINSTAR:

-      case OP_CRQUERY:

-      case OP_CRMINQUERY:

-      break;

-

-      default:                   /* Non-repeat => class must match */

-      case OP_CRPLUS:            /* These repeats aren't empty */

-      case OP_CRMINPLUS:

-      return FALSE;

-

-      case OP_CRRANGE:

-      case OP_CRMINRANGE:

-      if (GET2(ccode, 1) > 0) return FALSE;  /* Minimum > 0 */

-      break;

-      }

-    break;

-

-    /* Opcodes that must match a character */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    case OP_EXTUNI:

-    case OP_NOT_DIGIT:

-    case OP_DIGIT:

-    case OP_NOT_WHITESPACE:

-    case OP_WHITESPACE:

-    case OP_NOT_WORDCHAR:

-    case OP_WORDCHAR:

-    case OP_ANY:

-    case OP_ANYBYTE:

-    case OP_CHAR:

-    case OP_CHARNC:

-    case OP_NOT:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_EXACT:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTEXACT:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEEXACT:

-    return FALSE;

-

-    /* End of branch */

-

-    case OP_KET:

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_ALT:

-    return TRUE;

-

-    /* In UTF-8 mode, STAR, MINSTAR, QUERY, MINQUERY, UPTO, and MINUPTO  may be

-    followed by a multibyte character */

-

-#ifdef SUPPORT_UTF8

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    case OP_UPTO:

-    case OP_MINUPTO:

-    if (utf8) while ((code[2] & 0xc0) == 0x80) code++;

-    break;

-#endif

-    }

-  }

-

-return TRUE;

-}

-

-

-

-/*************************************************

-*    Scan compiled regex for non-emptiness       *

-*************************************************/

-

-/* This function is called to check for left recursive calls. We want to check

-the current branch of the current pattern to see if it could match the empty

-string. If it could, we must look outwards for branches at other levels,

-stopping when we pass beyond the bracket which is the subject of the recursion.

-

-Arguments:

-  code        points to start of the recursion

-  endcode     points to where to stop (current RECURSE item)

-  bcptr       points to the chain of current (unclosed) branch starts

-  utf8        TRUE if in UTF-8 mode

-

-Returns:      TRUE if what is matched could be empty

-*/

-

-static BOOL

-could_be_empty(const uschar *code, const uschar *endcode, branch_chain *bcptr,

-  BOOL utf8)

-{

-while (bcptr != NULL && bcptr->current >= code)

-  {

-  if (!could_be_empty_branch(bcptr->current, endcode, utf8)) return FALSE;

-  bcptr = bcptr->outer;

-  }

-return TRUE;

-}

-

-

-

-/*************************************************

-*           Check for POSIX class syntax         *

-*************************************************/

-

-/* This function is called when the sequence "[:" or "[." or "[=" is

-encountered in a character class. It checks whether this is followed by an

-optional ^ and then a sequence of letters, terminated by a matching ":]" or

-".]" or "=]".

-

-Argument:

-  ptr      pointer to the initial [

-  endptr   where to return the end pointer

-  cd       pointer to compile data

-

-Returns:   TRUE or FALSE

-*/

-

-static BOOL

-check_posix_syntax(const uschar *ptr, const uschar **endptr, compile_data *cd)

-{

-int terminator;          /* Don't combine these lines; the Solaris cc */

-terminator = *(++ptr);   /* compiler warns about "non-constant" initializer. */

-if (*(++ptr) == '^') ptr++;

-while ((cd->ctypes[*ptr] & ctype_letter) != 0) ptr++;

-if (*ptr == terminator && ptr[1] == ']')

-  {

-  *endptr = ptr;

-  return TRUE;

-  }

-return FALSE;

-}

-

-

-

-

-/*************************************************

-*          Check POSIX class name                *

-*************************************************/

-

-/* This function is called to check the name given in a POSIX-style class entry

-such as [:alnum:].

-

-Arguments:

-  ptr        points to the first letter

-  len        the length of the name

-

-Returns:     a value representing the name, or -1 if unknown

-*/

-

-static int

-check_posix_name(const uschar *ptr, int len)

-{

-register int yield = 0;

-while (posix_name_lengths[yield] != 0)

-  {

-  if (len == posix_name_lengths[yield] &&

-    strncmp((const char *)ptr, posix_names[yield], len) == 0) return yield;

-  yield++;

-  }

-return -1;

-}

-

-

-/*************************************************

-*    Adjust OP_RECURSE items in repeated group   *

-*************************************************/

-

-/* OP_RECURSE items contain an offset from the start of the regex to the group

-that is referenced. This means that groups can be replicated for fixed

-repetition simply by copying (because the recursion is allowed to refer to

-earlier groups that are outside the current group). However, when a group is

-optional (i.e. the minimum quantifier is zero), OP_BRAZERO is inserted before

-it, after it has been compiled. This means that any OP_RECURSE items within it

-that refer to the group itself or any contained groups have to have their

-offsets adjusted. That is the job of this function. Before it is called, the

-partially compiled regex must be temporarily terminated with OP_END.

-

-Arguments:

-  group      points to the start of the group

-  adjust     the amount by which the group is to be moved

-  utf8       TRUE in UTF-8 mode

-  cd         contains pointers to tables etc.

-

-Returns:     nothing

-*/

-

-static void

-adjust_recurse(uschar *group, int adjust, BOOL utf8, compile_data *cd)

-{

-uschar *ptr = group;

-while ((ptr = (uschar *)find_recurse(ptr, utf8)) != NULL)

-  {

-  int offset = GET(ptr, 1);

-  if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);

-  ptr += 1 + LINK_SIZE;

-  }

-}

-

-

-

-/*************************************************

-*        Insert an automatic callout point       *

-*************************************************/

-

-/* This function is called when the PCRE_AUTO_CALLOUT option is set, to insert

-callout points before each pattern item.

-

-Arguments:

-  code           current code pointer

-  ptr            current pattern pointer

-  cd             pointers to tables etc

-

-Returns:         new code pointer

-*/

-

-static uschar *

-auto_callout(uschar *code, const uschar *ptr, compile_data *cd)

-{

-*code++ = OP_CALLOUT;

-*code++ = 255;

-PUT(code, 0, ptr - cd->start_pattern);  /* Pattern offset */

-PUT(code, LINK_SIZE, 0);                /* Default length */

-return code + 2*LINK_SIZE;

-}

-

-

-

-/*************************************************

-*         Complete a callout item                *

-*************************************************/

-

-/* A callout item contains the length of the next item in the pattern, which

-we can't fill in till after we have reached the relevant point. This is used

-for both automatic and manual callouts.

-

-Arguments:

-  previous_callout   points to previous callout item

-  ptr                current pattern pointer

-  cd                 pointers to tables etc

-

-Returns:             nothing

-*/

-

-static void

-complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd)

-{

-int length = ptr - cd->start_pattern - GET(previous_callout, 2);

-PUT(previous_callout, 2 + LINK_SIZE, length);

-}

-

-

-

-#ifdef SUPPORT_UCP

-/*************************************************

-*           Get othercase range                  *

-*************************************************/

-

-/* This function is passed the start and end of a class range, in UTF-8 mode

-with UCP support. It searches up the characters, looking for internal ranges of

-characters in the "other" case. Each call returns the next one, updating the

-start address.

-

-Arguments:

-  cptr        points to starting character value; updated

-  d           end value

-  ocptr       where to put start of othercase range

-  odptr       where to put end of othercase range

-

-Yield:        TRUE when range returned; FALSE when no more

-*/

-

-static BOOL

-get_othercase_range(int *cptr, int d, int *ocptr, int *odptr)

-{

-int c, chartype, othercase, next;

-

-for (c = *cptr; c <= d; c++)

-  {

-  if (_pcre_ucp_findchar(c, &chartype, &othercase) == ucp_L && othercase != 0)

-    break;

-  }

-

-if (c > d) return FALSE;

-

-*ocptr = othercase;

-next = othercase + 1;

-

-for (++c; c <= d; c++)

-  {

-  if (_pcre_ucp_findchar(c, &chartype, &othercase) != ucp_L ||

-        othercase != next)

-    break;

-  next++;

-  }

-

-*odptr = next - 1;

-*cptr = c;

-

-return TRUE;

-}

-#endif  /* SUPPORT_UCP */

-

-

-/*************************************************

-*           Compile one branch                   *

-*************************************************/

-

-/* Scan the pattern, compiling it into the code vector. If the options are

-changed during the branch, the pointer is used to change the external options

-bits.

-

-Arguments:

-  optionsptr     pointer to the option bits

-  brackets       points to number of extracting brackets used

-  codeptr        points to the pointer to the current code point

-  ptrptr         points to the current pattern pointer

-  errorcodeptr   points to error code variable

-  firstbyteptr   set to initial literal character, or < 0 (REQ_UNSET, REQ_NONE)

-  reqbyteptr     set to the last literal character required, else < 0

-  bcptr          points to current branch chain

-  cd             contains pointers to tables etc.

-

-Returns:         TRUE on success

-                 FALSE, with *errorcodeptr set non-zero on error

-*/

-

-static BOOL

-compile_branch(int *optionsptr, int *brackets, uschar **codeptr,

-  const uschar **ptrptr, int *errorcodeptr, int *firstbyteptr,

-  int *reqbyteptr, branch_chain *bcptr, compile_data *cd)

-{

-int repeat_type, op_type;

-int repeat_min = 0, repeat_max = 0;      /* To please picky compilers */

-int bravalue = 0;

-int greedy_default, greedy_non_default;

-int firstbyte, reqbyte;

-int zeroreqbyte, zerofirstbyte;

-int req_caseopt, reqvary, tempreqvary;

-int condcount = 0;

-int options = *optionsptr;

-int after_manual_callout = 0;

-register int c;

-register uschar *code = *codeptr;

-uschar *tempcode;

-BOOL inescq = FALSE;

-BOOL groupsetfirstbyte = FALSE;

-const uschar *ptr = *ptrptr;

-const uschar *tempptr;

-uschar *previous = NULL;

-uschar *previous_callout = NULL;

-uschar classbits[32];

-

-#ifdef SUPPORT_UTF8

-BOOL class_utf8;

-BOOL utf8 = (options & PCRE_UTF8) != 0;

-uschar *class_utf8data;

-uschar utf8_char[6];

-#else

-BOOL utf8 = FALSE;

-#endif

-

-/* Set up the default and non-default settings for greediness */

-

-greedy_default = ((options & PCRE_UNGREEDY) != 0);

-greedy_non_default = greedy_default ^ 1;

-

-/* Initialize no first byte, no required byte. REQ_UNSET means "no char

-matching encountered yet". It gets changed to REQ_NONE if we hit something that

-matches a non-fixed char first char; reqbyte just remains unset if we never

-find one.

-

-When we hit a repeat whose minimum is zero, we may have to adjust these values

-to take the zero repeat into account. This is implemented by setting them to

-zerofirstbyte and zeroreqbyte when such a repeat is encountered. The individual

-item types that can be repeated set these backoff variables appropriately. */

-

-firstbyte = reqbyte = zerofirstbyte = zeroreqbyte = REQ_UNSET;

-

-/* The variable req_caseopt contains either the REQ_CASELESS value or zero,

-according to the current setting of the caseless flag. REQ_CASELESS is a bit

-value > 255. It is added into the firstbyte or reqbyte variables to record the

-case status of the value. This is used only for ASCII characters. */

-

-req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;

-

-/* Switch on next character until the end of the branch */

-

-for (;; ptr++)

-  {

-  BOOL negate_class;

-  BOOL possessive_quantifier;

-  BOOL is_quantifier;

-  int class_charcount;

-  int class_lastchar;

-  int newoptions;

-  int recno;

-  int skipbytes;

-  int subreqbyte;

-  int subfirstbyte;

-  int mclength;

-  uschar mcbuffer[8];

-

-  /* Next byte in the pattern */

-

-  c = *ptr;

-

-  /* If in \Q...\E, check for the end; if not, we have a literal */

-

-  if (inescq && c != 0)

-    {

-    if (c == '\\' && ptr[1] == 'E')

-      {

-      inescq = FALSE;

-      ptr++;

-      continue;

-      }

-    else

-      {

-      if (previous_callout != NULL)

-        {

-        complete_callout(previous_callout, ptr, cd);

-        previous_callout = NULL;

-        }

-      if ((options & PCRE_AUTO_CALLOUT) != 0)

-        {

-        previous_callout = code;

-        code = auto_callout(code, ptr, cd);

-        }

-      goto NORMAL_CHAR;

-      }

-    }

-

-  /* Fill in length of a previous callout, except when the next thing is

-  a quantifier. */

-

-  is_quantifier = c == '*' || c == '+' || c == '?' ||

-    (c == '{' && is_counted_repeat(ptr+1));

-

-  if (!is_quantifier && previous_callout != NULL &&

-       after_manual_callout-- <= 0)

-    {

-    complete_callout(previous_callout, ptr, cd);

-    previous_callout = NULL;

-    }

-

-  /* In extended mode, skip white space and comments */

-

-  if ((options & PCRE_EXTENDED) != 0)

-    {

-    if ((cd->ctypes[c] & ctype_space) != 0) continue;

-    if (c == '#')

-      {

-      /* The space before the ; is to avoid a warning on a silly compiler

-      on the Macintosh. */

-      while ((c = *(++ptr)) != 0 && c != NEWLINE) ;

-      if (c != 0) continue;   /* Else fall through to handle end of string */

-      }

-    }

-

-  /* No auto callout for quantifiers. */

-

-  if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier)

-    {

-    previous_callout = code;

-    code = auto_callout(code, ptr, cd);

-    }

-

-  switch(c)

-    {

-    /* The branch terminates at end of string, |, or ). */

-

-    case 0:

-    case '|':

-    case ')':

-    *firstbyteptr = firstbyte;

-    *reqbyteptr = reqbyte;

-    *codeptr = code;

-    *ptrptr = ptr;

-    return TRUE;

-

-    /* Handle single-character metacharacters. In multiline mode, ^ disables

-    the setting of any following char as a first character. */

-

-    case '^':

-    if ((options & PCRE_MULTILINE) != 0)

-      {

-      if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-      }

-    previous = NULL;

-    *code++ = OP_CIRC;

-    break;

-

-    case '$':

-    previous = NULL;

-    *code++ = OP_DOLL;

-    break;

-

-    /* There can never be a first char if '.' is first, whatever happens about

-    repeats. The value of reqbyte doesn't change either. */

-

-    case '.':

-    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-    zerofirstbyte = firstbyte;

-    zeroreqbyte = reqbyte;

-    previous = code;

-    *code++ = OP_ANY;

-    break;

-

-    /* Character classes. If the included characters are all < 255 in value, we

-    build a 32-byte bitmap of the permitted characters, except in the special

-    case where there is only one such character. For negated classes, we build

-    the map as usual, then invert it at the end. However, we use a different

-    opcode so that data characters > 255 can be handled correctly.

-

-    If the class contains characters outside the 0-255 range, a different

-    opcode is compiled. It may optionally have a bit map for characters < 256,

-    but those above are are explicitly listed afterwards. A flag byte tells

-    whether the bitmap is present, and whether this is a negated class or not.

-    */

-

-    case '[':

-    previous = code;

-

-    /* PCRE supports POSIX class stuff inside a class. Perl gives an error if

-    they are encountered at the top level, so we'll do that too. */

-

-    if ((ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&

-        check_posix_syntax(ptr, &tempptr, cd))

-      {

-      *errorcodeptr = (ptr[1] == ':')? ERR13 : ERR31;

-      goto FAILED;

-      }

-

-    /* If the first character is '^', set the negation flag and skip it. */

-

-    if ((c = *(++ptr)) == '^')

-      {

-      negate_class = TRUE;

-      c = *(++ptr);

-      }

-    else

-      {

-      negate_class = FALSE;

-      }

-

-    /* Keep a count of chars with values < 256 so that we can optimize the case

-    of just a single character (as long as it's < 256). For higher valued UTF-8

-    characters, we don't yet do any optimization. */

-

-    class_charcount = 0;

-    class_lastchar = -1;

-

-#ifdef SUPPORT_UTF8

-    class_utf8 = FALSE;                       /* No chars >= 256 */

-    class_utf8data = code + LINK_SIZE + 34;   /* For UTF-8 items */

-#endif

-

-    /* Initialize the 32-char bit map to all zeros. We have to build the

-    map in a temporary bit of store, in case the class contains only 1

-    character (< 256), because in that case the compiled code doesn't use the

-    bit map. */

-

-    memset(classbits, 0, 32 * sizeof(uschar));

-

-    /* Process characters until ] is reached. By writing this as a "do" it

-    means that an initial ] is taken as a data character. The first pass

-    through the regex checked the overall syntax, so we don't need to be very

-    strict here. At the start of the loop, c contains the first byte of the

-    character. */

-

-    do

-      {

-#ifdef SUPPORT_UTF8

-      if (utf8 && c > 127)

-        {                           /* Braces are required because the */

-        GETCHARLEN(c, ptr, ptr);    /* macro generates multiple statements */

-        }

-#endif

-

-      /* Inside \Q...\E everything is literal except \E */

-

-      if (inescq)

-        {

-        if (c == '\\' && ptr[1] == 'E')

-          {

-          inescq = FALSE;

-          ptr++;

-          continue;

-          }

-        else goto LONE_SINGLE_CHARACTER;

-        }

-

-      /* Handle POSIX class names. Perl allows a negation extension of the

-      form [:^name:]. A square bracket that doesn't match the syntax is

-      treated as a literal. We also recognize the POSIX constructions

-      [.ch.] and [=ch=] ("collating elements") and fault them, as Perl

-      5.6 and 5.8 do. */

-

-      if (c == '[' &&

-          (ptr[1] == ':' || ptr[1] == '.' || ptr[1] == '=') &&

-          check_posix_syntax(ptr, &tempptr, cd))

-        {

-        BOOL local_negate = FALSE;

-        int posix_class, i;

-        register const uschar *cbits = cd->cbits;

-

-        if (ptr[1] != ':')

-          {

-          *errorcodeptr = ERR31;

-          goto FAILED;

-          }

-

-        ptr += 2;

-        if (*ptr == '^')

-          {

-          local_negate = TRUE;

-          ptr++;

-          }

-

-        posix_class = check_posix_name(ptr, tempptr - ptr);

-        if (posix_class < 0)

-          {

-          *errorcodeptr = ERR30;

-          goto FAILED;

-          }

-

-        /* If matching is caseless, upper and lower are converted to

-        alpha. This relies on the fact that the class table starts with

-        alpha, lower, upper as the first 3 entries. */

-

-        if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)

-          posix_class = 0;

-

-        /* Or into the map we are building up to 3 of the static class

-        tables, or their negations. The [:blank:] class sets up the same

-        chars as the [:space:] class (all white space). We remove the vertical

-        white space chars afterwards. */

-

-        posix_class *= 3;

-        for (i = 0; i < 3; i++)

-          {

-          BOOL blankclass = strncmp((char *)ptr, "blank", 5) == 0;

-          int taboffset = posix_class_maps[posix_class + i];

-          if (taboffset < 0) break;

-          if (local_negate)

-            {

-            if (i == 0)

-              for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+taboffset];

-            else

-              for (c = 0; c < 32; c++) classbits[c] &= ~cbits[c+taboffset];

-            if (blankclass) classbits[1] |= 0x3c;

-            }

-          else

-            {

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+taboffset];

-            if (blankclass) classbits[1] &= ~0x3c;

-            }

-          }

-

-        ptr = tempptr + 1;

-        class_charcount = 10;  /* Set > 1; assumes more than 1 per class */

-        continue;    /* End of POSIX syntax handling */

-        }

-

-      /* Backslash may introduce a single character, or it may introduce one

-      of the specials, which just set a flag. Escaped items are checked for

-      validity in the pre-compiling pass. The sequence \b is a special case.

-      Inside a class (and only there) it is treated as backspace. Elsewhere

-      it marks a word boundary. Other escapes have preset maps ready to

-      or into the one we are building. We assume they have more than one

-      character in them, so set class_charcount bigger than one. */

-

-      if (c == '\\')

-        {

-        c = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);

-

-        if (-c == ESC_b) c = '\b';       /* \b is backslash in a class */

-        else if (-c == ESC_X) c = 'X';   /* \X is literal X in a class */

-        else if (-c == ESC_Q)            /* Handle start of quoted string */

-          {

-          if (ptr[1] == '\\' && ptr[2] == 'E')

-            {

-            ptr += 2; /* avoid empty string */

-            }

-          else inescq = TRUE;

-          continue;

-          }

-

-        if (c < 0)

-          {

-          register const uschar *cbits = cd->cbits;

-          class_charcount += 2;     /* Greater than 1 is what matters */

-          switch (-c)

-            {

-            case ESC_d:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit];

-            continue;

-

-            case ESC_D:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_digit];

-            continue;

-

-            case ESC_w:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_word];

-            continue;

-

-            case ESC_W:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];

-            continue;

-

-            case ESC_s:

-            for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_space];

-            classbits[1] &= ~0x08;   /* Perl 5.004 onwards omits VT from \s */

-            continue;

-

-            case ESC_S:

-            for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];

-            classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */

-            continue;

-

-#ifdef SUPPORT_UCP

-            case ESC_p:

-            case ESC_P:

-              {

-              BOOL negated;

-              int property = get_ucp(&ptr, &negated, errorcodeptr);

-              if (property < 0) goto FAILED;

-              class_utf8 = TRUE;

-              *class_utf8data++ = ((-c == ESC_p) != negated)?

-                XCL_PROP : XCL_NOTPROP;

-              *class_utf8data++ = property;

-              class_charcount -= 2;   /* Not a < 256 character */

-              }

-            continue;

-#endif

-

-            /* Unrecognized escapes are faulted if PCRE is running in its

-            strict mode. By default, for compatibility with Perl, they are

-            treated as literals. */

-

-            default:

-            if ((options & PCRE_EXTRA) != 0)

-              {

-              *errorcodeptr = ERR7;

-              goto FAILED;

-              }

-            c = *ptr;              /* The final character */

-            class_charcount -= 2;  /* Undo the default count from above */

-            }

-          }

-

-        /* Fall through if we have a single character (c >= 0). This may be

-        > 256 in UTF-8 mode. */

-

-        }   /* End of backslash handling */

-

-      /* A single character may be followed by '-' to form a range. However,

-      Perl does not permit ']' to be the end of the range. A '-' character

-      here is treated as a literal. */

-

-      if (ptr[1] == '-' && ptr[2] != ']')

-        {

-        int d;

-        ptr += 2;

-

-#ifdef SUPPORT_UTF8

-        if (utf8)

-          {                           /* Braces are required because the */

-          GETCHARLEN(d, ptr, ptr);    /* macro generates multiple statements */

-          }

-        else

-#endif

-        d = *ptr;  /* Not UTF-8 mode */

-

-        /* The second part of a range can be a single-character escape, but

-        not any of the other escapes. Perl 5.6 treats a hyphen as a literal

-        in such circumstances. */

-

-        if (d == '\\')

-          {

-          const uschar *oldptr = ptr;

-          d = check_escape(&ptr, errorcodeptr, *brackets, options, TRUE);

-

-          /* \b is backslash; \X is literal X; any other special means the '-'

-          was literal */

-

-          if (d < 0)

-            {

-            if (d == -ESC_b) d = '\b';

-            else if (d == -ESC_X) d = 'X'; else

-              {

-              ptr = oldptr - 2;

-              goto LONE_SINGLE_CHARACTER;  /* A few lines below */

-              }

-            }

-          }

-

-        /* The check that the two values are in the correct order happens in

-        the pre-pass. Optimize one-character ranges */

-

-        if (d == c) goto LONE_SINGLE_CHARACTER;  /* A few lines below */

-

-        /* In UTF-8 mode, if the upper limit is > 255, or > 127 for caseless

-        matching, we have to use an XCLASS with extra data items. Caseless

-        matching for characters > 127 is available only if UCP support is

-        available. */

-

-#ifdef SUPPORT_UTF8

-        if (utf8 && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))

-          {

-          class_utf8 = TRUE;

-

-          /* With UCP support, we can find the other case equivalents of

-          the relevant characters. There may be several ranges. Optimize how

-          they fit with the basic range. */

-

-#ifdef SUPPORT_UCP

-          if ((options & PCRE_CASELESS) != 0)

-            {

-            int occ, ocd;

-            int cc = c;

-            int origd = d;

-            while (get_othercase_range(&cc, origd, &occ, &ocd))

-              {

-              if (occ >= c && ocd <= d) continue;  /* Skip embedded ranges */

-

-              if (occ < c  && ocd >= c - 1)        /* Extend the basic range */

-                {                                  /* if there is overlap,   */

-                c = occ;                           /* noting that if occ < c */

-                continue;                          /* we can't have ocd > d  */

-                }                                  /* because a subrange is  */

-              if (ocd > d && occ <= d + 1)         /* always shorter than    */

-                {                                  /* the basic range.       */

-                d = ocd;

-                continue;

-                }

-

-              if (occ == ocd)

-                {

-                *class_utf8data++ = XCL_SINGLE;

-                }

-              else

-                {

-                *class_utf8data++ = XCL_RANGE;

-                class_utf8data += _pcre_ord2utf8(occ, class_utf8data);

-                }

-              class_utf8data += _pcre_ord2utf8(ocd, class_utf8data);

-              }

-            }

-#endif  /* SUPPORT_UCP */

-

-          /* Now record the original range, possibly modified for UCP caseless

-          overlapping ranges. */

-

-          *class_utf8data++ = XCL_RANGE;

-          class_utf8data += _pcre_ord2utf8(c, class_utf8data);

-          class_utf8data += _pcre_ord2utf8(d, class_utf8data);

-

-          /* With UCP support, we are done. Without UCP support, there is no

-          caseless matching for UTF-8 characters > 127; we can use the bit map

-          for the smaller ones. */

-

-#ifdef SUPPORT_UCP

-          continue;    /* With next character in the class */

-#else

-          if ((options & PCRE_CASELESS) == 0 || c > 127) continue;

-

-          /* Adjust upper limit and fall through to set up the map */

-

-          d = 127;

-

-#endif  /* SUPPORT_UCP */

-          }

-#endif  /* SUPPORT_UTF8 */

-

-        /* We use the bit map for all cases when not in UTF-8 mode; else

-        ranges that lie entirely within 0-127 when there is UCP support; else

-        for partial ranges without UCP support. */

-

-        for (; c <= d; c++)

-          {

-          classbits[c/8] |= (1 << (c&7));

-          if ((options & PCRE_CASELESS) != 0)

-            {

-            int uc = cd->fcc[c];           /* flip case */

-            classbits[uc/8] |= (1 << (uc&7));

-            }

-          class_charcount++;                /* in case a one-char range */

-          class_lastchar = c;

-          }

-

-        continue;   /* Go get the next char in the class */

-        }

-

-      /* Handle a lone single character - we can get here for a normal

-      non-escape char, or after \ that introduces a single character or for an

-      apparent range that isn't. */

-

-      LONE_SINGLE_CHARACTER:

-

-      /* Handle a character that cannot go in the bit map */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))

-        {

-        class_utf8 = TRUE;

-        *class_utf8data++ = XCL_SINGLE;

-        class_utf8data += _pcre_ord2utf8(c, class_utf8data);

-

-#ifdef SUPPORT_UCP

-        if ((options & PCRE_CASELESS) != 0)

-          {

-          int chartype;

-          int othercase;

-          if (_pcre_ucp_findchar(c, &chartype, &othercase) >= 0 &&

-               othercase > 0)

-            {

-            *class_utf8data++ = XCL_SINGLE;

-            class_utf8data += _pcre_ord2utf8(othercase, class_utf8data);

-            }

-          }

-#endif  /* SUPPORT_UCP */

-

-        }

-      else

-#endif  /* SUPPORT_UTF8 */

-

-      /* Handle a single-byte character */

-        {

-        classbits[c/8] |= (1 << (c&7));

-        if ((options & PCRE_CASELESS) != 0)

-          {

-          c = cd->fcc[c];   /* flip case */

-          classbits[c/8] |= (1 << (c&7));

-          }

-        class_charcount++;

-        class_lastchar = c;

-        }

-      }

-

-    /* Loop until ']' reached; the check for end of string happens inside the

-    loop. This "while" is the end of the "do" above. */

-

-    while ((c = *(++ptr)) != ']' || inescq);

-

-    /* If class_charcount is 1, we saw precisely one character whose value is

-    less than 256. In non-UTF-8 mode we can always optimize. In UTF-8 mode, we

-    can optimize the negative case only if there were no characters >= 128

-    because OP_NOT and the related opcodes like OP_NOTSTAR operate on

-    single-bytes only. This is an historical hangover. Maybe one day we can

-    tidy these opcodes to handle multi-byte characters.

-

-    The optimization throws away the bit map. We turn the item into a

-    1-character OP_CHAR[NC] if it's positive, or OP_NOT if it's negative. Note

-    that OP_NOT does not support multibyte characters. In the positive case, it

-    can cause firstbyte to be set. Otherwise, there can be no first char if

-    this item is first, whatever repeat count may follow. In the case of

-    reqbyte, save the previous value for reinstating. */

-

-#ifdef SUPPORT_UTF8

-    if (class_charcount == 1 &&

-          (!utf8 ||

-          (!class_utf8 && (!negate_class || class_lastchar < 128))))

-

-#else

-    if (class_charcount == 1)

-#endif

-      {

-      zeroreqbyte = reqbyte;

-

-      /* The OP_NOT opcode works on one-byte characters only. */

-

-      if (negate_class)

-        {

-        if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-        zerofirstbyte = firstbyte;

-        *code++ = OP_NOT;

-        *code++ = class_lastchar;

-        break;

-        }

-

-      /* For a single, positive character, get the value into mcbuffer, and

-      then we can handle this with the normal one-character code. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && class_lastchar > 127)

-        mclength = _pcre_ord2utf8(class_lastchar, mcbuffer);

-      else

-#endif

-        {

-        mcbuffer[0] = class_lastchar;

-        mclength = 1;

-        }

-      goto ONE_CHAR;

-      }       /* End of 1-char optimization */

-

-    /* The general case - not the one-char optimization. If this is the first

-    thing in the branch, there can be no first char setting, whatever the

-    repeat count. Any reqbyte setting must remain unchanged after any kind of

-    repeat. */

-

-    if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE;

-    zerofirstbyte = firstbyte;

-    zeroreqbyte = reqbyte;

-

-    /* If there are characters with values > 255, we have to compile an

-    extended class, with its own opcode. If there are no characters < 256,

-    we can omit the bitmap. */

-

-#ifdef SUPPORT_UTF8

-    if (class_utf8)

-      {

-      *class_utf8data++ = XCL_END;    /* Marks the end of extra data */

-      *code++ = OP_XCLASS;

-      code += LINK_SIZE;

-      *code = negate_class? XCL_NOT : 0;

-

-      /* If the map is required, install it, and move on to the end of

-      the extra data */

-

-      if (class_charcount > 0)

-        {

-        *code++ |= XCL_MAP;

-        memcpy(code, classbits, 32);

-        code = class_utf8data;

-        }

-

-      /* If the map is not required, slide down the extra data. */

-

-      else

-        {

-        int len = class_utf8data - (code + 33);

-        memmove(code + 1, code + 33, len);

-        code += len + 1;

-        }

-

-      /* Now fill in the complete length of the item */

-

-      PUT(previous, 1, code - previous);

-      break;   /* End of class handling */

-      }

-#endif

-

-    /* If there are no characters > 255, negate the 32-byte map if necessary,

-    and copy it into the code vector. If this is the first thing in the branch,

-    there can be no first char setting, whatever the repeat count. Any reqbyte

-    setting must remain unchanged after any kind of repeat. */

-

-    if (negate_class)

-      {

-      *code++ = OP_NCLASS;

-      for (c = 0; c < 32; c++) code[c] = ~classbits[c];

-      }

-    else

-      {

-      *code++ = OP_CLASS;

-      memcpy(code, classbits, 32);

-      }

-    code += 32;

-    break;

-

-    /* Various kinds of repeat; '{' is not necessarily a quantifier, but this

-    has been tested above. */

-

-    case '{':

-    if (!is_quantifier) goto NORMAL_CHAR;

-    ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);

-    if (*errorcodeptr != 0) goto FAILED;

-    goto REPEAT;

-

-    case '*':

-    repeat_min = 0;

-    repeat_max = -1;

-    goto REPEAT;

-

-    case '+':

-    repeat_min = 1;

-    repeat_max = -1;

-    goto REPEAT;

-

-    case '?':

-    repeat_min = 0;

-    repeat_max = 1;

-

-    REPEAT:

-    if (previous == NULL)

-      {

-      *errorcodeptr = ERR9;

-      goto FAILED;

-      }

-

-    if (repeat_min == 0)

-      {

-      firstbyte = zerofirstbyte;    /* Adjust for zero repeat */

-      reqbyte = zeroreqbyte;        /* Ditto */

-      }

-

-    /* Remember whether this is a variable length repeat */

-

-    reqvary = (repeat_min == repeat_max)? 0 : REQ_VARY;

-

-    op_type = 0;                    /* Default single-char op codes */

-    possessive_quantifier = FALSE;  /* Default not possessive quantifier */

-

-    /* Save start of previous item, in case we have to move it up to make space

-    for an inserted OP_ONCE for the additional '+' extension. */

-

-    tempcode = previous;

-

-    /* If the next character is '+', we have a possessive quantifier. This

-    implies greediness, whatever the setting of the PCRE_UNGREEDY option.

-    If the next character is '?' this is a minimizing repeat, by default,

-    but if PCRE_UNGREEDY is set, it works the other way round. We change the

-    repeat type to the non-default. */

-

-    if (ptr[1] == '+')

-      {

-      repeat_type = 0;                  /* Force greedy */

-      possessive_quantifier = TRUE;

-      ptr++;

-      }

-    else if (ptr[1] == '?')

-      {

-      repeat_type = greedy_non_default;

-      ptr++;

-      }

-    else repeat_type = greedy_default;

-

-    /* If previous was a recursion, we need to wrap it inside brackets so that

-    it can be replicated if necessary. */

-

-    if (*previous == OP_RECURSE)

-      {

-      memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);

-      code += 1 + LINK_SIZE;

-      *previous = OP_BRA;

-      PUT(previous, 1, code - previous);

-      *code = OP_KET;

-      PUT(code, 1, code - previous);

-      code += 1 + LINK_SIZE;

-      }

-

-    /* If previous was a character match, abolish the item and generate a

-    repeat item instead. If a char item has a minumum of more than one, ensure

-    that it is set in reqbyte - it might not be if a sequence such as x{3} is

-    the first thing in a branch because the x will have gone into firstbyte

-    instead.  */

-

-    if (*previous == OP_CHAR || *previous == OP_CHARNC)

-      {

-      /* Deal with UTF-8 characters that take up more than one byte. It's

-      easier to write this out separately than try to macrify it. Use c to

-      hold the length of the character in bytes, plus 0x80 to flag that it's a

-      length rather than a small character. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && (code[-1] & 0x80) != 0)

-        {

-        uschar *lastchar = code - 1;

-        while((*lastchar & 0xc0) == 0x80) lastchar--;

-        c = code - lastchar;            /* Length of UTF-8 character */

-        memcpy(utf8_char, lastchar, c); /* Save the char */

-        c |= 0x80;                      /* Flag c as a length */

-        }

-      else

-#endif

-

-      /* Handle the case of a single byte - either with no UTF8 support, or

-      with UTF-8 disabled, or for a UTF-8 character < 128. */

-

-        {

-        c = code[-1];

-        if (repeat_min > 1) reqbyte = c | req_caseopt | cd->req_varyopt;

-        }

-

-      goto OUTPUT_SINGLE_REPEAT;   /* Code shared with single character types */

-      }

-

-    /* If previous was a single negated character ([^a] or similar), we use

-    one of the special opcodes, replacing it. The code is shared with single-

-    character repeats by setting opt_type to add a suitable offset into

-    repeat_type. OP_NOT is currently used only for single-byte chars. */

-

-    else if (*previous == OP_NOT)

-      {

-      op_type = OP_NOTSTAR - OP_STAR;  /* Use "not" opcodes */

-      c = previous[1];

-      goto OUTPUT_SINGLE_REPEAT;

-      }

-

-    /* If previous was a character type match (\d or similar), abolish it and

-    create a suitable repeat item. The code is shared with single-character

-    repeats by setting op_type to add a suitable offset into repeat_type. Note

-    the the Unicode property types will be present only when SUPPORT_UCP is

-    defined, but we don't wrap the little bits of code here because it just

-    makes it horribly messy. */

-

-    else if (*previous < OP_EODN)

-      {

-      uschar *oldcode;

-      int prop_type;

-      op_type = OP_TYPESTAR - OP_STAR;  /* Use type opcodes */

-      c = *previous;

-

-      OUTPUT_SINGLE_REPEAT:

-      prop_type = (*previous == OP_PROP || *previous == OP_NOTPROP)?

-        previous[1] : -1;

-

-      oldcode = code;

-      code = previous;                  /* Usually overwrite previous item */

-

-      /* If the maximum is zero then the minimum must also be zero; Perl allows

-      this case, so we do too - by simply omitting the item altogether. */

-

-      if (repeat_max == 0) goto END_REPEAT;

-

-      /* All real repeats make it impossible to handle partial matching (maybe

-      one day we will be able to remove this restriction). */

-

-      if (repeat_max != 1) cd->nopartial = TRUE;

-

-      /* Combine the op_type with the repeat_type */

-

-      repeat_type += op_type;

-

-      /* A minimum of zero is handled either as the special case * or ?, or as

-      an UPTO, with the maximum given. */

-

-      if (repeat_min == 0)

-        {

-        if (repeat_max == -1) *code++ = OP_STAR + repeat_type;

-          else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type;

-        else

-          {

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max);

-          }

-        }

-

-      /* A repeat minimum of 1 is optimized into some special cases. If the

-      maximum is unlimited, we use OP_PLUS. Otherwise, the original item it

-      left in place and, if the maximum is greater than 1, we use OP_UPTO with

-      one less than the maximum. */

-

-      else if (repeat_min == 1)

-        {

-        if (repeat_max == -1)

-          *code++ = OP_PLUS + repeat_type;

-        else

-          {

-          code = oldcode;                 /* leave previous item in place */

-          if (repeat_max == 1) goto END_REPEAT;

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max - 1);

-          }

-        }

-

-      /* The case {n,n} is just an EXACT, while the general case {n,m} is

-      handled as an EXACT followed by an UPTO. */

-

-      else

-        {

-        *code++ = OP_EXACT + op_type;  /* NB EXACT doesn't have repeat_type */

-        PUT2INC(code, 0, repeat_min);

-

-        /* If the maximum is unlimited, insert an OP_STAR. Before doing so,

-        we have to insert the character for the previous code. For a repeated

-        Unicode property match, there is an extra byte that defines the

-        required property. In UTF-8 mode, long characters have their length in

-        c, with the 0x80 bit as a flag. */

-

-        if (repeat_max < 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-            memcpy(code, utf8_char, c & 7);

-            code += c & 7;

-            }

-          else

-#endif

-            {

-            *code++ = c;

-            if (prop_type >= 0) *code++ = prop_type;

-            }

-          *code++ = OP_STAR + repeat_type;

-          }

-

-        /* Else insert an UPTO if the max is greater than the min, again

-        preceded by the character, for the previously inserted code. */

-

-        else if (repeat_max != repeat_min)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-            memcpy(code, utf8_char, c & 7);

-            code += c & 7;

-            }

-          else

-#endif

-          *code++ = c;

-          if (prop_type >= 0) *code++ = prop_type;

-          repeat_max -= repeat_min;

-          *code++ = OP_UPTO + repeat_type;

-          PUT2INC(code, 0, repeat_max);

-          }

-        }

-

-      /* The character or character type itself comes last in all cases. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && c >= 128)

-        {

-        memcpy(code, utf8_char, c & 7);

-        code += c & 7;

-        }

-      else

-#endif

-      *code++ = c;

-

-      /* For a repeated Unicode property match, there is an extra byte that

-      defines the required property. */

-

-#ifdef SUPPORT_UCP

-      if (prop_type >= 0) *code++ = prop_type;

-#endif

-      }

-

-    /* If previous was a character class or a back reference, we put the repeat

-    stuff after it, but just skip the item if the repeat was {0,0}. */

-

-    else if (*previous == OP_CLASS ||

-             *previous == OP_NCLASS ||

-#ifdef SUPPORT_UTF8

-             *previous == OP_XCLASS ||

-#endif

-             *previous == OP_REF)

-      {

-      if (repeat_max == 0)

-        {

-        code = previous;

-        goto END_REPEAT;

-        }

-

-      /* All real repeats make it impossible to handle partial matching (maybe

-      one day we will be able to remove this restriction). */

-

-      if (repeat_max != 1) cd->nopartial = TRUE;

-

-      if (repeat_min == 0 && repeat_max == -1)

-        *code++ = OP_CRSTAR + repeat_type;

-      else if (repeat_min == 1 && repeat_max == -1)

-        *code++ = OP_CRPLUS + repeat_type;

-      else if (repeat_min == 0 && repeat_max == 1)

-        *code++ = OP_CRQUERY + repeat_type;

-      else

-        {

-        *code++ = OP_CRRANGE + repeat_type;

-        PUT2INC(code, 0, repeat_min);

-        if (repeat_max == -1) repeat_max = 0;  /* 2-byte encoding for max */

-        PUT2INC(code, 0, repeat_max);

-        }

-      }

-

-    /* If previous was a bracket group, we may have to replicate it in certain

-    cases. */

-

-    else if (*previous >= OP_BRA || *previous == OP_ONCE ||

-             *previous == OP_COND)

-      {

-      register int i;

-      int ketoffset = 0;

-      int len = code - previous;

-      uschar *bralink = NULL;

-

-      /* If the maximum repeat count is unlimited, find the end of the bracket

-      by scanning through from the start, and compute the offset back to it

-      from the current code pointer. There may be an OP_OPT setting following

-      the final KET, so we can't find the end just by going back from the code

-      pointer. */

-

-      if (repeat_max == -1)

-        {

-        register uschar *ket = previous;

-        do ket += GET(ket, 1); while (*ket != OP_KET);

-        ketoffset = code - ket;

-        }

-

-      /* The case of a zero minimum is special because of the need to stick

-      OP_BRAZERO in front of it, and because the group appears once in the

-      data, whereas in other cases it appears the minimum number of times. For

-      this reason, it is simplest to treat this case separately, as otherwise

-      the code gets far too messy. There are several special subcases when the

-      minimum is zero. */

-

-      if (repeat_min == 0)

-        {

-        /* If the maximum is also zero, we just omit the group from the output

-        altogether. */

-

-        if (repeat_max == 0)

-          {

-          code = previous;

-          goto END_REPEAT;

-          }

-

-        /* If the maximum is 1 or unlimited, we just have to stick in the

-        BRAZERO and do no more at this point. However, we do need to adjust

-        any OP_RECURSE calls inside the group that refer to the group itself or

-        any internal group, because the offset is from the start of the whole

-        regex. Temporarily terminate the pattern while doing this. */

-

-        if (repeat_max <= 1)

-          {

-          *code = OP_END;

-          adjust_recurse(previous, 1, utf8, cd);

-          memmove(previous+1, previous, len);

-          code++;

-          *previous++ = OP_BRAZERO + repeat_type;

-          }

-

-        /* If the maximum is greater than 1 and limited, we have to replicate

-        in a nested fashion, sticking OP_BRAZERO before each set of brackets.

-        The first one has to be handled carefully because it's the original

-        copy, which has to be moved up. The remainder can be handled by code

-        that is common with the non-zero minimum case below. We have to

-        adjust the value or repeat_max, since one less copy is required. Once

-        again, we may have to adjust any OP_RECURSE calls inside the group. */

-

-        else

-          {

-          int offset;

-          *code = OP_END;

-          adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd);

-          memmove(previous + 2 + LINK_SIZE, previous, len);

-          code += 2 + LINK_SIZE;

-          *previous++ = OP_BRAZERO + repeat_type;

-          *previous++ = OP_BRA;

-

-          /* We chain together the bracket offset fields that have to be

-          filled in later when the ends of the brackets are reached. */

-

-          offset = (bralink == NULL)? 0 : previous - bralink;

-          bralink = previous;

-          PUTINC(previous, 0, offset);

-          }

-

-        repeat_max--;

-        }

-

-      /* If the minimum is greater than zero, replicate the group as many

-      times as necessary, and adjust the maximum to the number of subsequent

-      copies that we need. If we set a first char from the group, and didn't

-      set a required char, copy the latter from the former. */

-

-      else

-        {

-        if (repeat_min > 1)

-          {

-          if (groupsetfirstbyte && reqbyte < 0) reqbyte = firstbyte;

-          for (i = 1; i < repeat_min; i++)

-            {

-            memcpy(code, previous, len);

-            code += len;

-            }

-          }

-        if (repeat_max > 0) repeat_max -= repeat_min;

-        }

-

-      /* This code is common to both the zero and non-zero minimum cases. If

-      the maximum is limited, it replicates the group in a nested fashion,

-      remembering the bracket starts on a stack. In the case of a zero minimum,

-      the first one was set up above. In all cases the repeat_max now specifies

-      the number of additional copies needed. */

-

-      if (repeat_max >= 0)

-        {

-        for (i = repeat_max - 1; i >= 0; i--)

-          {

-          *code++ = OP_BRAZERO + repeat_type;

-

-          /* All but the final copy start a new nesting, maintaining the

-          chain of brackets outstanding. */

-

-          if (i != 0)

-            {

-            int offset;

-            *code++ = OP_BRA;

-            offset = (bralink == NULL)? 0 : code - bralink;

-            bralink = code;

-            PUTINC(code, 0, offset);

-            }

-

-          memcpy(code, previous, len);

-          code += len;

-          }

-

-        /* Now chain through the pending brackets, and fill in their length

-        fields (which are holding the chain links pro tem). */

-

-        while (bralink != NULL)

-          {

-          int oldlinkoffset;

-          int offset = code - bralink + 1;

-          uschar *bra = code - offset;

-          oldlinkoffset = GET(bra, 1);

-          bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;

-          *code++ = OP_KET;

-          PUTINC(code, 0, offset);

-          PUT(bra, 1, offset);

-          }

-        }

-

-      /* If the maximum is unlimited, set a repeater in the final copy. We

-      can't just offset backwards from the current code point, because we

-      don't know if there's been an options resetting after the ket. The

-      correct offset was computed above. */

-

-      else code[-ketoffset] = OP_KETRMAX + repeat_type;

-      }

-

-    /* Else there's some kind of shambles */

-

-    else

-      {

-      *errorcodeptr = ERR11;

-      goto FAILED;

-      }

-

-    /* If the character following a repeat is '+', we wrap the entire repeated

-    item inside OP_ONCE brackets. This is just syntactic sugar, taken from

-    Sun's Java package. The repeated item starts at tempcode, not at previous,

-    which might be the first part of a string whose (former) last char we

-    repeated. However, we don't support '+' after a greediness '?'. */

-

-    if (possessive_quantifier)

-      {

-      int len = code - tempcode;

-      memmove(tempcode + 1+LINK_SIZE, tempcode, len);

-      code += 1 + LINK_SIZE;

-      len += 1 + LINK_SIZE;

-      tempcode[0] = OP_ONCE;

-      *code++ = OP_KET;

-      PUTINC(code, 0, len);

-      PUT(tempcode, 1, len);

-      }

-

-    /* In all case we no longer have a previous item. We also set the

-    "follows varying string" flag for subsequently encountered reqbytes if

-    it isn't already set and we have just passed a varying length item. */

-

-    END_REPEAT:

-    previous = NULL;

-    cd->req_varyopt |= reqvary;

-    break;

-

-

-    /* Start of nested bracket sub-expression, or comment or lookahead or

-    lookbehind or option setting or condition. First deal with special things

-    that can come after a bracket; all are introduced by ?, and the appearance

-    of any of them means that this is not a referencing group. They were

-    checked for validity in the first pass over the string, so we don't have to

-    check for syntax errors here.  */

-

-    case '(':

-    newoptions = options;

-    skipbytes = 0;

-

-    if (*(++ptr) == '?')

-      {

-      int set, unset;

-      int *optset;

-

-      switch (*(++ptr))

-        {

-        case '#':                 /* Comment; skip to ket */

-        ptr++;

-        while (*ptr != ')') ptr++;

-        continue;

-

-        case ':':                 /* Non-extracting bracket */

-        bravalue = OP_BRA;

-        ptr++;

-        break;

-

-        case '(':

-        bravalue = OP_COND;       /* Conditional group */

-

-        /* Condition to test for recursion */

-

-        if (ptr[1] == 'R')

-          {

-          code[1+LINK_SIZE] = OP_CREF;

-          PUT2(code, 2+LINK_SIZE, CREF_RECURSE);

-          skipbytes = 3;

-          ptr += 3;

-          }

-

-        /* Condition to test for a numbered subpattern match. We know that

-        if a digit follows ( then there will just be digits until ) because

-        the syntax was checked in the first pass. */

-

-        else if ((digitab[ptr[1]] && ctype_digit) != 0)

-          {

-          int condref;                 /* Don't amalgamate; some compilers */

-          condref = *(++ptr) - '0';    /* grumble at autoincrement in declaration */

-          while (*(++ptr) != ')') condref = condref*10 + *ptr - '0';

-          if (condref == 0)

-            {

-            *errorcodeptr = ERR35;

-            goto FAILED;

-            }

-          ptr++;

-          code[1+LINK_SIZE] = OP_CREF;

-          PUT2(code, 2+LINK_SIZE, condref);

-          skipbytes = 3;

-          }

-        /* For conditions that are assertions, we just fall through, having

-        set bravalue above. */

-        break;

-

-        case '=':                 /* Positive lookahead */

-        bravalue = OP_ASSERT;

-        ptr++;

-        break;

-

-        case '!':                 /* Negative lookahead */

-        bravalue = OP_ASSERT_NOT;

-        ptr++;

-        break;

-

-        case '<':                 /* Lookbehinds */

-        switch (*(++ptr))

-          {

-          case '=':               /* Positive lookbehind */

-          bravalue = OP_ASSERTBACK;

-          ptr++;

-          break;

-

-          case '!':               /* Negative lookbehind */

-          bravalue = OP_ASSERTBACK_NOT;

-          ptr++;

-          break;

-          }

-        break;

-

-        case '>':                 /* One-time brackets */

-        bravalue = OP_ONCE;

-        ptr++;

-        break;

-

-        case 'C':                 /* Callout - may be followed by digits; */

-        previous_callout = code;  /* Save for later completion */

-        after_manual_callout = 1; /* Skip one item before completing */

-        *code++ = OP_CALLOUT;     /* Already checked that the terminating */

-          {                       /* closing parenthesis is present. */

-          int n = 0;

-          while ((digitab[*(++ptr)] & ctype_digit) != 0)

-            n = n * 10 + *ptr - '0';

-          if (n > 255)

-            {

-            *errorcodeptr = ERR38;

-            goto FAILED;

-            }

-          *code++ = n;

-          PUT(code, 0, ptr - cd->start_pattern + 1);  /* Pattern offset */

-          PUT(code, LINK_SIZE, 0);                    /* Default length */

-          code += 2 * LINK_SIZE;

-          }

-        previous = NULL;

-        continue;

-

-        case 'P':                 /* Named subpattern handling */

-        if (*(++ptr) == '<')      /* Definition */

-          {

-          int i, namelen;

-          uschar *slot = cd->name_table;

-          const uschar *name;     /* Don't amalgamate; some compilers */

-          name = ++ptr;           /* grumble at autoincrement in declaration */

-

-          while (*ptr++ != '>');

-          namelen = ptr - name - 1;

-

-          for (i = 0; i < cd->names_found; i++)

-            {

-            int crc = memcmp(name, slot+2, namelen);

-            if (crc == 0)

-              {

-              if (slot[2+namelen] == 0)

-                {

-                *errorcodeptr = ERR43;

-                goto FAILED;

-                }

-              crc = -1;             /* Current name is substring */

-              }

-            if (crc < 0)

-              {

-              memmove(slot + cd->name_entry_size, slot,

-                (cd->names_found - i) * cd->name_entry_size);

-              break;

-              }

-            slot += cd->name_entry_size;

-            }

-

-          PUT2(slot, 0, *brackets + 1);

-          memcpy(slot + 2, name, namelen);

-          slot[2+namelen] = 0;

-          cd->names_found++;

-          goto NUMBERED_GROUP;

-          }

-

-        if (*ptr == '=' || *ptr == '>')  /* Reference or recursion */

-          {

-          int i, namelen;

-          int type = *ptr++;

-          const uschar *name = ptr;

-          uschar *slot = cd->name_table;

-

-          while (*ptr != ')') ptr++;

-          namelen = ptr - name;

-

-          for (i = 0; i < cd->names_found; i++)

-            {

-            if (strncmp((char *)name, (char *)slot+2, namelen) == 0) break;

-            slot += cd->name_entry_size;

-            }

-          if (i >= cd->names_found)

-            {

-            *errorcodeptr = ERR15;

-            goto FAILED;

-            }

-

-          recno = GET2(slot, 0);

-

-          if (type == '>') goto HANDLE_RECURSION;  /* A few lines below */

-

-          /* Back reference */

-

-          previous = code;

-          *code++ = OP_REF;

-          PUT2INC(code, 0, recno);

-          cd->backref_map |= (recno < 32)? (1 << recno) : 1;

-          if (recno > cd->top_backref) cd->top_backref = recno;

-          continue;

-          }

-

-        /* Should never happen */

-        break;

-

-        case 'R':                 /* Pattern recursion */

-        ptr++;                    /* Same as (?0)      */

-        /* Fall through */

-

-        /* Recursion or "subroutine" call */

-

-        case '0': case '1': case '2': case '3': case '4':

-        case '5': case '6': case '7': case '8': case '9':

-          {

-          const uschar *called;

-          recno = 0;

-          while((digitab[*ptr] & ctype_digit) != 0)

-            recno = recno * 10 + *ptr++ - '0';

-

-          /* Come here from code above that handles a named recursion */

-

-          HANDLE_RECURSION:

-

-          previous = code;

-

-          /* Find the bracket that is being referenced. Temporarily end the

-          regex in case it doesn't exist. */

-

-          *code = OP_END;

-          called = (recno == 0)?

-            cd->start_code : find_bracket(cd->start_code, utf8, recno);

-

-          if (called == NULL)

-            {

-            *errorcodeptr = ERR15;

-            goto FAILED;

-            }

-

-          /* If the subpattern is still open, this is a recursive call. We

-          check to see if this is a left recursion that could loop for ever,

-          and diagnose that case. */

-

-          if (GET(called, 1) == 0 && could_be_empty(called, code, bcptr, utf8))

-            {

-            *errorcodeptr = ERR40;

-            goto FAILED;

-            }

-

-          /* Insert the recursion/subroutine item */

-

-          *code = OP_RECURSE;

-          PUT(code, 1, called - cd->start_code);

-          code += 1 + LINK_SIZE;

-          }

-        continue;

-

-        /* Character after (? not specially recognized */

-

-        default:                  /* Option setting */

-        set = unset = 0;

-        optset = &set;

-

-        while (*ptr != ')' && *ptr != ':')

-          {

-          switch (*ptr++)

-            {

-            case '-': optset = &unset; break;

-

-            case 'i': *optset |= PCRE_CASELESS; break;

-            case 'm': *optset |= PCRE_MULTILINE; break;

-            case 's': *optset |= PCRE_DOTALL; break;

-            case 'x': *optset |= PCRE_EXTENDED; break;

-            case 'U': *optset |= PCRE_UNGREEDY; break;

-            case 'X': *optset |= PCRE_EXTRA; break;

-            }

-          }

-

-        /* Set up the changed option bits, but don't change anything yet. */

-

-        newoptions = (options | set) & (~unset);

-

-        /* If the options ended with ')' this is not the start of a nested

-        group with option changes, so the options change at this level. Compile

-        code to change the ims options if this setting actually changes any of

-        them. We also pass the new setting back so that it can be put at the

-        start of any following branches, and when this group ends (if we are in

-        a group), a resetting item can be compiled.

-

-        Note that if this item is right at the start of the pattern, the

-        options will have been abstracted and made global, so there will be no

-        change to compile. */

-

-        if (*ptr == ')')

-          {

-          if ((options & PCRE_IMS) != (newoptions & PCRE_IMS))

-            {

-            *code++ = OP_OPT;

-            *code++ = newoptions & PCRE_IMS;

-            }

-

-          /* Change options at this level, and pass them back for use

-          in subsequent branches. Reset the greedy defaults and the case

-          value for firstbyte and reqbyte. */

-

-          *optionsptr = options = newoptions;

-          greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);

-          greedy_non_default = greedy_default ^ 1;

-          req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS : 0;

-

-          previous = NULL;       /* This item can't be repeated */

-          continue;              /* It is complete */

-          }

-

-        /* If the options ended with ':' we are heading into a nested group

-        with possible change of options. Such groups are non-capturing and are

-        not assertions of any kind. All we need to do is skip over the ':';

-        the newoptions value is handled below. */

-

-        bravalue = OP_BRA;

-        ptr++;

-        }

-      }

-

-    /* If PCRE_NO_AUTO_CAPTURE is set, all unadorned brackets become

-    non-capturing and behave like (?:...) brackets */

-

-    else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)

-      {

-      bravalue = OP_BRA;

-      }

-

-    /* Else we have a referencing group; adjust the opcode. If the bracket

-    number is greater than EXTRACT_BASIC_MAX, we set the opcode one higher, and

-    arrange for the true number to follow later, in an OP_BRANUMBER item. */

-

-    else

-      {

-      NUMBERED_GROUP:

-      if (++(*brackets) > EXTRACT_BASIC_MAX)

-        {

-        bravalue = OP_BRA + EXTRACT_BASIC_MAX + 1;

-        code[1+LINK_SIZE] = OP_BRANUMBER;

-        PUT2(code, 2+LINK_SIZE, *brackets);

-        skipbytes = 3;

-        }

-      else bravalue = OP_BRA + *brackets;

-      }

-

-    /* Process nested bracketed re. Assertions may not be repeated, but other

-    kinds can be. We copy code into a non-register variable in order to be able

-    to pass its address because some compilers complain otherwise. Pass in a

-    new setting for the ims options if they have changed. */

-

-    previous = (bravalue >= OP_ONCE)? code : NULL;

-    *code = bravalue;

-    tempcode = code;

-    tempreqvary = cd->req_varyopt;     /* Save value before bracket */

-

-    if (!compile_regex(

-         newoptions,                   /* The complete new option state */

-         options & PCRE_IMS,           /* The previous ims option state */

-         brackets,                     /* Extracting bracket count */

-         &tempcode,                    /* Where to put code (updated) */

-         &ptr,                         /* Input pointer (updated) */

-         errorcodeptr,                 /* Where to put an error message */

-         (bravalue == OP_ASSERTBACK ||

-          bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */

-         skipbytes,                    /* Skip over OP_COND/OP_BRANUMBER */

-         &subfirstbyte,                /* For possible first char */

-         &subreqbyte,                  /* For possible last char */

-         bcptr,                        /* Current branch chain */

-         cd))                          /* Tables block */

-      goto FAILED;

-

-    /* At the end of compiling, code is still pointing to the start of the

-    group, while tempcode has been updated to point past the end of the group

-    and any option resetting that may follow it. The pattern pointer (ptr)

-    is on the bracket. */

-

-    /* If this is a conditional bracket, check that there are no more than

-    two branches in the group. */

-

-    else if (bravalue == OP_COND)

-      {

-      uschar *tc = code;

-      condcount = 0;

-

-      do {

-         condcount++;

-         tc += GET(tc,1);

-         }

-      while (*tc != OP_KET);

-

-      if (condcount > 2)

-        {

-        *errorcodeptr = ERR27;

-        goto FAILED;

-        }

-

-      /* If there is just one branch, we must not make use of its firstbyte or

-      reqbyte, because this is equivalent to an empty second branch. */

-

-      if (condcount == 1) subfirstbyte = subreqbyte = REQ_NONE;

-      }

-

-    /* Handle updating of the required and first characters. Update for normal

-    brackets of all kinds, and conditions with two branches (see code above).

-    If the bracket is followed by a quantifier with zero repeat, we have to

-    back off. Hence the definition of zeroreqbyte and zerofirstbyte outside the

-    main loop so that they can be accessed for the back off. */

-

-    zeroreqbyte = reqbyte;

-    zerofirstbyte = firstbyte;

-    groupsetfirstbyte = FALSE;

-

-    if (bravalue >= OP_BRA || bravalue == OP_ONCE || bravalue == OP_COND)

-      {

-      /* If we have not yet set a firstbyte in this branch, take it from the

-      subpattern, remembering that it was set here so that a repeat of more

-      than one can replicate it as reqbyte if necessary. If the subpattern has

-      no firstbyte, set "none" for the whole branch. In both cases, a zero

-      repeat forces firstbyte to "none". */

-

-      if (firstbyte == REQ_UNSET)

-        {

-        if (subfirstbyte >= 0)

-          {

-          firstbyte = subfirstbyte;

-          groupsetfirstbyte = TRUE;

-          }

-        else firstbyte = REQ_NONE;

-        zerofirstbyte = REQ_NONE;

-        }

-

-      /* If firstbyte was previously set, convert the subpattern's firstbyte

-      into reqbyte if there wasn't one, using the vary flag that was in

-      existence beforehand. */

-

-      else if (subfirstbyte >= 0 && subreqbyte < 0)

-        subreqbyte = subfirstbyte | tempreqvary;

-

-      /* If the subpattern set a required byte (or set a first byte that isn't

-      really the first byte - see above), set it. */

-

-      if (subreqbyte >= 0) reqbyte = subreqbyte;

-      }

-

-    /* For a forward assertion, we take the reqbyte, if set. This can be

-    helpful if the pattern that follows the assertion doesn't set a different

-    char. For example, it's useful for /(?=abcde).+/. We can't set firstbyte

-    for an assertion, however because it leads to incorrect effect for patterns

-    such as /(?=a)a.+/ when the "real" "a" would then become a reqbyte instead

-    of a firstbyte. This is overcome by a scan at the end if there's no

-    firstbyte, looking for an asserted first char. */

-

-    else if (bravalue == OP_ASSERT && subreqbyte >= 0) reqbyte = subreqbyte;

-

-    /* Now update the main code pointer to the end of the group. */

-

-    code = tempcode;

-

-    /* Error if hit end of pattern */

-

-    if (*ptr != ')')

-      {

-      *errorcodeptr = ERR14;

-      goto FAILED;

-      }

-    break;

-

-    /* Check \ for being a real metacharacter; if not, fall through and handle

-    it as a data character at the start of a string. Escape items are checked

-    for validity in the pre-compiling pass. */

-

-    case '\\':

-    tempptr = ptr;

-    c = check_escape(&ptr, errorcodeptr, *brackets, options, FALSE);

-

-    /* Handle metacharacters introduced by \. For ones like \d, the ESC_ values

-    are arranged to be the negation of the corresponding OP_values. For the

-    back references, the values are ESC_REF plus the reference number. Only

-    back references and those types that consume a character may be repeated.

-    We can test for values between ESC_b and ESC_Z for the latter; this may

-    have to change if any new ones are ever created. */

-

-    if (c < 0)

-      {

-      if (-c == ESC_Q)            /* Handle start of quoted string */

-        {

-        if (ptr[1] == '\\' && ptr[2] == 'E') ptr += 2; /* avoid empty string */

-          else inescq = TRUE;

-        continue;

-        }

-

-      /* For metasequences that actually match a character, we disable the

-      setting of a first character if it hasn't already been set. */

-

-      if (firstbyte == REQ_UNSET && -c > ESC_b && -c < ESC_Z)

-        firstbyte = REQ_NONE;

-

-      /* Set values to reset to if this is followed by a zero repeat. */

-

-      zerofirstbyte = firstbyte;

-      zeroreqbyte = reqbyte;

-

-      /* Back references are handled specially */

-

-      if (-c >= ESC_REF)

-        {

-        int number = -c - ESC_REF;

-        previous = code;

-        *code++ = OP_REF;

-        PUT2INC(code, 0, number);

-        }

-

-      /* So are Unicode property matches, if supported. We know that get_ucp

-      won't fail because it was tested in the pre-pass. */

-

-#ifdef SUPPORT_UCP

-      else if (-c == ESC_P || -c == ESC_p)

-        {

-        BOOL negated;

-        int value = get_ucp(&ptr, &negated, errorcodeptr);

-        previous = code;

-        *code++ = ((-c == ESC_p) != negated)? OP_PROP : OP_NOTPROP;

-        *code++ = value;

-        }

-#endif

-

-      /* For the rest, we can obtain the OP value by negating the escape

-      value */

-

-      else

-        {

-        previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;

-        *code++ = -c;

-        }

-      continue;

-      }

-

-    /* We have a data character whose value is in c. In UTF-8 mode it may have

-    a value > 127. We set its representation in the length/buffer, and then

-    handle it as a data character. */

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && c > 127)

-      mclength = _pcre_ord2utf8(c, mcbuffer);

-    else

-#endif

-

-     {

-     mcbuffer[0] = c;

-     mclength = 1;

-     }

-

-    goto ONE_CHAR;

-

-    /* Handle a literal character. It is guaranteed not to be whitespace or #

-    when the extended flag is set. If we are in UTF-8 mode, it may be a

-    multi-byte literal character. */

-

-    default:

-    NORMAL_CHAR:

-    mclength = 1;

-    mcbuffer[0] = c;

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && (c & 0xc0) == 0xc0)

-      {

-      while ((ptr[1] & 0xc0) == 0x80)

-        mcbuffer[mclength++] = *(++ptr);

-      }

-#endif

-

-    /* At this point we have the character's bytes in mcbuffer, and the length

-    in mclength. When not in UTF-8 mode, the length is always 1. */

-

-    ONE_CHAR:

-    previous = code;

-    *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARNC : OP_CHAR;

-    for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];

-

-    /* Set the first and required bytes appropriately. If no previous first

-    byte, set it from this character, but revert to none on a zero repeat.

-    Otherwise, leave the firstbyte value alone, and don't change it on a zero

-    repeat. */

-

-    if (firstbyte == REQ_UNSET)

-      {

-      zerofirstbyte = REQ_NONE;

-      zeroreqbyte = reqbyte;

-

-      /* If the character is more than one byte long, we can set firstbyte

-      only if it is not to be matched caselessly. */

-

-      if (mclength == 1 || req_caseopt == 0)

-        {

-        firstbyte = mcbuffer[0] | req_caseopt;

-        if (mclength != 1) reqbyte = code[-1] | cd->req_varyopt;

-        }

-      else firstbyte = reqbyte = REQ_NONE;

-      }

-

-    /* firstbyte was previously set; we can set reqbyte only the length is

-    1 or the matching is caseful. */

-

-    else

-      {

-      zerofirstbyte = firstbyte;

-      zeroreqbyte = reqbyte;

-      if (mclength == 1 || req_caseopt == 0)

-        reqbyte = code[-1] | req_caseopt | cd->req_varyopt;

-      }

-

-    break;            /* End of literal character handling */

-    }

-  }                   /* end of big loop */

-

-/* Control never reaches here by falling through, only by a goto for all the

-error states. Pass back the position in the pattern so that it can be displayed

-to the user for diagnosing the error. */

-

-FAILED:

-*ptrptr = ptr;

-return FALSE;

-}

-

-

-

-

-/*************************************************

-*     Compile sequence of alternatives           *

-*************************************************/

-

-/* On entry, ptr is pointing past the bracket character, but on return

-it points to the closing bracket, or vertical bar, or end of string.

-The code variable is pointing at the byte into which the BRA operator has been

-stored. If the ims options are changed at the start (for a (?ims: group) or

-during any branch, we need to insert an OP_OPT item at the start of every

-following branch to ensure they get set correctly at run time, and also pass

-the new options into every subsequent branch compile.

-

-Argument:

-  options        option bits, including any changes for this subpattern

-  oldims         previous settings of ims option bits

-  brackets       -> int containing the number of extracting brackets used

-  codeptr        -> the address of the current code pointer

-  ptrptr         -> the address of the current pattern pointer

-  errorcodeptr   -> pointer to error code variable

-  lookbehind     TRUE if this is a lookbehind assertion

-  skipbytes      skip this many bytes at start (for OP_COND, OP_BRANUMBER)

-  firstbyteptr   place to put the first required character, or a negative number

-  reqbyteptr     place to put the last required character, or a negative number

-  bcptr          pointer to the chain of currently open branches

-  cd             points to the data block with tables pointers etc.

-

-Returns:      TRUE on success

-*/

-

-static BOOL

-compile_regex(int options, int oldims, int *brackets, uschar **codeptr,

-  const uschar **ptrptr, int *errorcodeptr, BOOL lookbehind, int skipbytes,

-  int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd)

-{

-const uschar *ptr = *ptrptr;

-uschar *code = *codeptr;

-uschar *last_branch = code;

-uschar *start_bracket = code;

-uschar *reverse_count = NULL;

-int firstbyte, reqbyte;

-int branchfirstbyte, branchreqbyte;

-branch_chain bc;

-

-bc.outer = bcptr;

-bc.current = code;

-

-firstbyte = reqbyte = REQ_UNSET;

-

-/* Offset is set zero to mark that this bracket is still open */

-

-PUT(code, 1, 0);

-code += 1 + LINK_SIZE + skipbytes;

-

-/* Loop for each alternative branch */

-

-for (;;)

-  {

-  /* Handle a change of ims options at the start of the branch */

-

-  if ((options & PCRE_IMS) != oldims)

-    {

-    *code++ = OP_OPT;

-    *code++ = options & PCRE_IMS;

-    }

-

-  /* Set up dummy OP_REVERSE if lookbehind assertion */

-

-  if (lookbehind)

-    {

-    *code++ = OP_REVERSE;

-    reverse_count = code;

-    PUTINC(code, 0, 0);

-    }

-

-  /* Now compile the branch */

-

-  if (!compile_branch(&options, brackets, &code, &ptr, errorcodeptr,

-        &branchfirstbyte, &branchreqbyte, &bc, cd))

-    {

-    *ptrptr = ptr;

-    return FALSE;

-    }

-

-  /* If this is the first branch, the firstbyte and reqbyte values for the

-  branch become the values for the regex. */

-

-  if (*last_branch != OP_ALT)

-    {

-    firstbyte = branchfirstbyte;

-    reqbyte = branchreqbyte;

-    }

-

-  /* If this is not the first branch, the first char and reqbyte have to

-  match the values from all the previous branches, except that if the previous

-  value for reqbyte didn't have REQ_VARY set, it can still match, and we set

-  REQ_VARY for the regex. */

-

-  else

-    {

-    /* If we previously had a firstbyte, but it doesn't match the new branch,

-    we have to abandon the firstbyte for the regex, but if there was previously

-    no reqbyte, it takes on the value of the old firstbyte. */

-

-    if (firstbyte >= 0 && firstbyte != branchfirstbyte)

-      {

-      if (reqbyte < 0) reqbyte = firstbyte;

-      firstbyte = REQ_NONE;

-      }

-

-    /* If we (now or from before) have no firstbyte, a firstbyte from the

-    branch becomes a reqbyte if there isn't a branch reqbyte. */

-

-    if (firstbyte < 0 && branchfirstbyte >= 0 && branchreqbyte < 0)

-        branchreqbyte = branchfirstbyte;

-

-    /* Now ensure that the reqbytes match */

-

-    if ((reqbyte & ~REQ_VARY) != (branchreqbyte & ~REQ_VARY))

-      reqbyte = REQ_NONE;

-    else reqbyte |= branchreqbyte;   /* To "or" REQ_VARY */

-    }

-

-  /* If lookbehind, check that this branch matches a fixed-length string,

-  and put the length into the OP_REVERSE item. Temporarily mark the end of

-  the branch with OP_END. */

-

-  if (lookbehind)

-    {

-    int length;

-    *code = OP_END;

-    length = find_fixedlength(last_branch, options);

-    DPRINTF(("fixed length = %d\n", length));

-    if (length < 0)

-      {

-      *errorcodeptr = (length == -2)? ERR36 : ERR25;

-      *ptrptr = ptr;

-      return FALSE;

-      }

-    PUT(reverse_count, 0, length);

-    }

-

-  /* Reached end of expression, either ')' or end of pattern. Go back through

-  the alternative branches and reverse the chain of offsets, with the field in

-  the BRA item now becoming an offset to the first alternative. If there are

-  no alternatives, it points to the end of the group. The length in the

-  terminating ket is always the length of the whole bracketed item. If any of

-  the ims options were changed inside the group, compile a resetting op-code

-  following, except at the very end of the pattern. Return leaving the pointer

-  at the terminating char. */

-

-  if (*ptr != '|')

-    {

-    int length = code - last_branch;

-    do

-      {

-      int prev_length = GET(last_branch, 1);

-      PUT(last_branch, 1, length);

-      length = prev_length;

-      last_branch -= length;

-      }

-    while (length > 0);

-

-    /* Fill in the ket */

-

-    *code = OP_KET;

-    PUT(code, 1, code - start_bracket);

-    code += 1 + LINK_SIZE;

-

-    /* Resetting option if needed */

-

-    if ((options & PCRE_IMS) != oldims && *ptr == ')')

-      {

-      *code++ = OP_OPT;

-      *code++ = oldims;

-      }

-

-    /* Set values to pass back */

-

-    *codeptr = code;

-    *ptrptr = ptr;

-    *firstbyteptr = firstbyte;

-    *reqbyteptr = reqbyte;

-    return TRUE;

-    }

-

-  /* Another branch follows; insert an "or" node. Its length field points back

-  to the previous branch while the bracket remains open. At the end the chain

-  is reversed. It's done like this so that the start of the bracket has a

-  zero offset until it is closed, making it possible to detect recursion. */

-

-  *code = OP_ALT;

-  PUT(code, 1, code - last_branch);

-  bc.current = last_branch = code;

-  code += 1 + LINK_SIZE;

-  ptr++;

-  }

-/* Control never reaches here */

-}

-

-

-

-

-/*************************************************

-*          Check for anchored expression         *

-*************************************************/

-

-/* Try to find out if this is an anchored regular expression. Consider each

-alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket

-all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then

-it's anchored. However, if this is a multiline pattern, then only OP_SOD

-counts, since OP_CIRC can match in the middle.

-

-We can also consider a regex to be anchored if OP_SOM starts all its branches.

-This is the code for \G, which means "match at start of match position, taking

-into account the match offset".

-

-A branch is also implicitly anchored if it starts with .* and DOTALL is set,

-because that will try the rest of the pattern at all possible matching points,

-so there is no point trying again.... er ....

-

-.... except when the .* appears inside capturing parentheses, and there is a

-subsequent back reference to those parentheses. We haven't enough information

-to catch that case precisely.

-

-At first, the best we could do was to detect when .* was in capturing brackets

-and the highest back reference was greater than or equal to that level.

-However, by keeping a bitmap of the first 31 back references, we can catch some

-of the more common cases more precisely.

-

-Arguments:

-  code           points to start of expression (the bracket)

-  options        points to the options setting

-  bracket_map    a bitmap of which brackets we are inside while testing; this

-                  handles up to substring 31; after that we just have to take

-                  the less precise approach

-  backref_map    the back reference bitmap

-

-Returns:     TRUE or FALSE

-*/

-

-static BOOL

-is_anchored(register const uschar *code, int *options, unsigned int bracket_map,

-  unsigned int backref_map)

-{

-do {

-   const uschar *scode =

-     first_significant_code(code + 1+LINK_SIZE, options, PCRE_MULTILINE, FALSE);

-   register int op = *scode;

-

-   /* Capturing brackets */

-

-   if (op > OP_BRA)

-     {

-     int new_map;

-     op -= OP_BRA;

-     if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);

-     new_map = bracket_map | ((op < 32)? (1 << op) : 1);

-     if (!is_anchored(scode, options, new_map, backref_map)) return FALSE;

-     }

-

-   /* Other brackets */

-

-   else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)

-     {

-     if (!is_anchored(scode, options, bracket_map, backref_map)) return FALSE;

-     }

-

-   /* .* is not anchored unless DOTALL is set and it isn't in brackets that

-   are or may be referenced. */

-

-   else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR) &&

-            (*options & PCRE_DOTALL) != 0)

-     {

-     if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;

-     }

-

-   /* Check for explicit anchoring */

-

-   else if (op != OP_SOD && op != OP_SOM &&

-           ((*options & PCRE_MULTILINE) != 0 || op != OP_CIRC))

-     return FALSE;

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);   /* Loop for each alternative */

-return TRUE;

-}

-

-

-

-/*************************************************

-*         Check for starting with ^ or .*        *

-*************************************************/

-

-/* This is called to find out if every branch starts with ^ or .* so that

-"first char" processing can be done to speed things up in multiline

-matching and for non-DOTALL patterns that start with .* (which must start at

-the beginning or after \n). As in the case of is_anchored() (see above), we

-have to take account of back references to capturing brackets that contain .*

-because in that case we can't make the assumption.

-

-Arguments:

-  code           points to start of expression (the bracket)

-  bracket_map    a bitmap of which brackets we are inside while testing; this

-                  handles up to substring 31; after that we just have to take

-                  the less precise approach

-  backref_map    the back reference bitmap

-

-Returns:         TRUE or FALSE

-*/

-

-static BOOL

-is_startline(const uschar *code, unsigned int bracket_map,

-  unsigned int backref_map)

-{

-do {

-   const uschar *scode = first_significant_code(code + 1+LINK_SIZE, NULL, 0,

-     FALSE);

-   register int op = *scode;

-

-   /* Capturing brackets */

-

-   if (op > OP_BRA)

-     {

-     int new_map;

-     op -= OP_BRA;

-     if (op > EXTRACT_BASIC_MAX) op = GET2(scode, 2+LINK_SIZE);

-     new_map = bracket_map | ((op < 32)? (1 << op) : 1);

-     if (!is_startline(scode, new_map, backref_map)) return FALSE;

-     }

-

-   /* Other brackets */

-

-   else if (op == OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND)

-     { if (!is_startline(scode, bracket_map, backref_map)) return FALSE; }

-

-   /* .* means "start at start or after \n" if it isn't in brackets that

-   may be referenced. */

-

-   else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR)

-     {

-     if (scode[1] != OP_ANY || (bracket_map & backref_map) != 0) return FALSE;

-     }

-

-   /* Check for explicit circumflex */

-

-   else if (op != OP_CIRC) return FALSE;

-

-   /* Move on to the next alternative */

-

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);  /* Loop for each alternative */

-return TRUE;

-}

-

-

-

-/*************************************************

-*       Check for asserted fixed first char      *

-*************************************************/

-

-/* During compilation, the "first char" settings from forward assertions are

-discarded, because they can cause conflicts with actual literals that follow.

-However, if we end up without a first char setting for an unanchored pattern,

-it is worth scanning the regex to see if there is an initial asserted first

-char. If all branches start with the same asserted char, or with a bracket all

-of whose alternatives start with the same asserted char (recurse ad lib), then

-we return that char, otherwise -1.

-

-Arguments:

-  code       points to start of expression (the bracket)

-  options    pointer to the options (used to check casing changes)

-  inassert   TRUE if in an assertion

-

-Returns:     -1 or the fixed first char

-*/

-

-static int

-find_firstassertedchar(const uschar *code, int *options, BOOL inassert)

-{

-register int c = -1;

-do {

-   int d;

-   const uschar *scode =

-     first_significant_code(code + 1+LINK_SIZE, options, PCRE_CASELESS, TRUE);

-   register int op = *scode;

-

-   if (op >= OP_BRA) op = OP_BRA;

-

-   switch(op)

-     {

-     default:

-     return -1;

-

-     case OP_BRA:

-     case OP_ASSERT:

-     case OP_ONCE:

-     case OP_COND:

-     if ((d = find_firstassertedchar(scode, options, op == OP_ASSERT)) < 0)

-       return -1;

-     if (c < 0) c = d; else if (c != d) return -1;

-     break;

-

-     case OP_EXACT:       /* Fall through */

-     scode += 2;

-

-     case OP_CHAR:

-     case OP_CHARNC:

-     case OP_PLUS:

-     case OP_MINPLUS:

-     if (!inassert) return -1;

-     if (c < 0)

-       {

-       c = scode[1];

-       if ((*options & PCRE_CASELESS) != 0) c |= REQ_CASELESS;

-       }

-     else if (c != scode[1]) return -1;

-     break;

-     }

-

-   code += GET(code, 1);

-   }

-while (*code == OP_ALT);

-return c;

-}

-

-

-

-/*************************************************

-*        Compile a Regular Expression            *

-*************************************************/

-

-/* This function takes a string and returns a pointer to a block of store

-holding a compiled version of the expression. The original API for this

-function had no error code return variable; it is retained for backwards

-compatibility. The new function is given a new name.

-

-Arguments:

-  pattern       the regular expression

-  options       various option bits

-  errorcodeptr  pointer to error code variable (pcre_compile2() only)

-                  can be NULL if you don't want a code value

-  errorptr      pointer to pointer to error text

-  erroroffset   ptr offset in pattern where error was detected

-  tables        pointer to character tables or NULL

-

-Returns:        pointer to compiled data block, or NULL on error,

-                with errorptr and erroroffset set

-*/

-

-EXPORT pcre *

-pcre_compile(const char *pattern, int options, const char **errorptr,

-  int *erroroffset, const unsigned char *tables)

-{

-return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);

-}

-

-

-EXPORT pcre *

-pcre_compile2(const char *pattern, int options, int *errorcodeptr,

-  const char **errorptr, int *erroroffset, const unsigned char *tables)

-{

-real_pcre *re;

-int length = 1 + LINK_SIZE;      /* For initial BRA plus length */

-int c, firstbyte, reqbyte;

-int bracount = 0;

-int branch_extra = 0;

-int branch_newextra;

-int item_count = -1;

-int name_count = 0;

-int max_name_size = 0;

-int lastitemlength = 0;

-int errorcode = 0;

-#ifdef SUPPORT_UTF8

-BOOL utf8;

-BOOL class_utf8;

-#endif

-BOOL inescq = FALSE;

-BOOL capturing;

-unsigned int brastackptr = 0;

-size_t size;

-uschar *code;

-const uschar *codestart;

-const uschar *ptr;

-compile_data compile_block;

-int brastack[BRASTACK_SIZE];

-uschar bralenstack[BRASTACK_SIZE];

-

-/* We can't pass back an error message if errorptr is NULL; I guess the best we

-can do is just return NULL, but we can set a code value if there is a code

-pointer. */

-

-if (errorptr == NULL)

-  {

-  if (errorcodeptr != NULL) *errorcodeptr = 99;

-  return NULL;

-  }

-

-*errorptr = NULL;

-if (errorcodeptr != NULL) *errorcodeptr = ERR0;

-

-/* However, we can give a message for this error */

-

-if (erroroffset == NULL)

-  {

-  errorcode = ERR16;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-*erroroffset = 0;

-

-/* Can't support UTF8 unless PCRE has been compiled to include the code. */

-

-#ifdef SUPPORT_UTF8

-utf8 = (options & PCRE_UTF8) != 0;

-if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0 &&

-     (*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0)

-  {

-  errorcode = ERR44;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-#else

-if ((options & PCRE_UTF8) != 0)

-  {

-  errorcode = ERR32;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-#endif

-

-if ((options & ~PUBLIC_OPTIONS) != 0)

-  {

-  errorcode = ERR17;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Set up pointers to the individual character tables */

-

-if (tables == NULL) tables = _pcre_default_tables;

-compile_block.lcc = tables + lcc_offset;

-compile_block.fcc = tables + fcc_offset;

-compile_block.cbits = tables + cbits_offset;

-compile_block.ctypes = tables + ctypes_offset;

-

-/* Maximum back reference and backref bitmap. This is updated for numeric

-references during the first pass, but for named references during the actual

-compile pass. The bitmap records up to 31 back references to help in deciding

-whether (.*) can be treated as anchored or not. */

-

-compile_block.top_backref = 0;

-compile_block.backref_map = 0;

-

-/* Reflect pattern for debugging output */

-

-DPRINTF(("------------------------------------------------------------------\n"));

-DPRINTF(("%s\n", pattern));

-

-/* The first thing to do is to make a pass over the pattern to compute the

-amount of store required to hold the compiled code. This does not have to be

-perfect as long as errors are overestimates. At the same time we can detect any

-flag settings right at the start, and extract them. Make an attempt to correct

-for any counted white space if an "extended" flag setting appears late in the

-pattern. We can't be so clever for #-comments. */

-

-ptr = (const uschar *)(pattern - 1);

-while ((c = *(++ptr)) != 0)

-  {

-  int min, max;

-  int class_optcount;

-  int bracket_length;

-  int duplength;

-

-  /* If we are inside a \Q...\E sequence, all chars are literal */

-

-  if (inescq)

-    {

-    if ((options & PCRE_AUTO_CALLOUT) != 0) length += 2 + 2*LINK_SIZE;

-    goto NORMAL_CHAR;

-    }

-

-  /* Otherwise, first check for ignored whitespace and comments */

-

-  if ((options & PCRE_EXTENDED) != 0)

-    {

-    if ((compile_block.ctypes[c] & ctype_space) != 0) continue;

-    if (c == '#')

-      {

-      /* The space before the ; is to avoid a warning on a silly compiler

-      on the Macintosh. */

-      while ((c = *(++ptr)) != 0 && c != NEWLINE) ;

-      if (c == 0) break;

-      continue;

-      }

-    }

-

-  item_count++;    /* Is zero for the first non-comment item */

-

-  /* Allow space for auto callout before every item except quantifiers. */

-

-  if ((options & PCRE_AUTO_CALLOUT) != 0 &&

-       c != '*' && c != '+' && c != '?' &&

-       (c != '{' || !is_counted_repeat(ptr + 1)))

-    length += 2 + 2*LINK_SIZE;

-

-  switch(c)

-    {

-    /* A backslashed item may be an escaped data character or it may be a

-    character type. */

-

-    case '\\':

-    c = check_escape(&ptr, &errorcode, bracount, options, FALSE);

-    if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-    lastitemlength = 1;     /* Default length of last item for repeats */

-

-    if (c >= 0)             /* Data character */

-      {

-      length += 2;          /* For a one-byte character */

-

-#ifdef SUPPORT_UTF8

-      if (utf8 && c > 127)

-        {

-        int i;

-        for (i = 0; i < _pcre_utf8_table1_size; i++)

-          if (c <= _pcre_utf8_table1[i]) break;

-        length += i;

-        lastitemlength += i;

-        }

-#endif

-

-      continue;

-      }

-

-    /* If \Q, enter "literal" mode */

-

-    if (-c == ESC_Q)

-      {

-      inescq = TRUE;

-      continue;

-      }

-

-    /* \X is supported only if Unicode property support is compiled */

-

-#ifndef SUPPORT_UCP

-    if (-c == ESC_X)

-      {

-      errorcode = ERR45;

-      goto PCRE_ERROR_RETURN;

-      }

-#endif

-

-    /* \P and \p are for Unicode properties, but only when the support has

-    been compiled. Each item needs 2 bytes. */

-

-    else if (-c == ESC_P || -c == ESC_p)

-      {

-#ifdef SUPPORT_UCP

-      BOOL negated;

-      length += 2;

-      lastitemlength = 2;

-      if (get_ucp(&ptr, &negated, &errorcode) < 0) goto PCRE_ERROR_RETURN;

-      continue;

-#else

-      errorcode = ERR45;

-      goto PCRE_ERROR_RETURN;

-#endif

-      }

-

-    /* Other escapes need one byte */

-

-    length++;

-

-    /* A back reference needs an additional 2 bytes, plus either one or 5

-    bytes for a repeat. We also need to keep the value of the highest

-    back reference. */

-

-    if (c <= -ESC_REF)

-      {

-      int refnum = -c - ESC_REF;

-      compile_block.backref_map |= (refnum < 32)? (1 << refnum) : 1;

-      if (refnum > compile_block.top_backref)

-        compile_block.top_backref = refnum;

-      length += 2;   /* For single back reference */

-      if (ptr[1] == '{' && is_counted_repeat(ptr+2))

-        {

-        ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-        if ((min == 0 && (max == 1 || max == -1)) ||

-          (min == 1 && max == -1))

-            length++;

-        else length += 5;

-        if (ptr[1] == '?') ptr++;

-        }

-      }

-    continue;

-

-    case '^':     /* Single-byte metacharacters */

-    case '.':

-    case '$':

-    length++;

-    lastitemlength = 1;

-    continue;

-

-    case '*':            /* These repeats won't be after brackets; */

-    case '+':            /* those are handled separately */

-    case '?':

-    length++;

-    goto POSESSIVE;      /* A few lines below */

-

-    /* This covers the cases of braced repeats after a single char, metachar,

-    class, or back reference. */

-

-    case '{':

-    if (!is_counted_repeat(ptr+1)) goto NORMAL_CHAR;

-    ptr = read_repeat_counts(ptr+1, &min, &max, &errorcode);

-    if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-    /* These special cases just insert one extra opcode */

-

-    if ((min == 0 && (max == 1 || max == -1)) ||

-      (min == 1 && max == -1))

-        length++;

-

-    /* These cases might insert additional copies of a preceding character. */

-

-    else

-      {

-      if (min != 1)

-        {

-        length -= lastitemlength;   /* Uncount the original char or metachar */

-        if (min > 0) length += 3 + lastitemlength;

-        }

-      length += lastitemlength + ((max > 0)? 3 : 1);

-      }

-

-    if (ptr[1] == '?') ptr++;      /* Needs no extra length */

-

-    POSESSIVE:                     /* Test for possessive quantifier */

-    if (ptr[1] == '+')

-      {

-      ptr++;

-      length += 2 + 2*LINK_SIZE;   /* Allow for atomic brackets */

-      }

-    continue;

-

-    /* An alternation contains an offset to the next branch or ket. If any ims

-    options changed in the previous branch(es), and/or if we are in a

-    lookbehind assertion, extra space will be needed at the start of the

-    branch. This is handled by branch_extra. */

-

-    case '|':

-    length += 1 + LINK_SIZE + branch_extra;

-    continue;

-

-    /* A character class uses 33 characters provided that all the character

-    values are less than 256. Otherwise, it uses a bit map for low valued

-    characters, and individual items for others. Don't worry about character

-    types that aren't allowed in classes - they'll get picked up during the

-    compile. A character class that contains only one single-byte character

-    uses 2 or 3 bytes, depending on whether it is negated or not. Notice this

-    where we can. (In UTF-8 mode we can do this only for chars < 128.) */

-

-    case '[':

-    if (*(++ptr) == '^')

-      {

-      class_optcount = 10;  /* Greater than one */

-      ptr++;

-      }

-    else class_optcount = 0;

-

-#ifdef SUPPORT_UTF8

-    class_utf8 = FALSE;

-#endif

-

-    /* Written as a "do" so that an initial ']' is taken as data */

-

-    if (*ptr != 0) do

-      {

-      /* Inside \Q...\E everything is literal except \E */

-

-      if (inescq)

-        {

-        if (*ptr != '\\' || ptr[1] != 'E') goto GET_ONE_CHARACTER;

-        inescq = FALSE;

-        ptr += 1;

-        continue;

-        }

-

-      /* Outside \Q...\E, check for escapes */

-

-      if (*ptr == '\\')

-        {

-        c = check_escape(&ptr, &errorcode, bracount, options, TRUE);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-

-        /* \b is backspace inside a class; \X is literal */

-

-        if (-c == ESC_b) c = '\b';

-        else if (-c == ESC_X) c = 'X';

-

-        /* \Q enters quoting mode */

-

-        else if (-c == ESC_Q)

-          {

-          inescq = TRUE;

-          continue;

-          }

-

-        /* Handle escapes that turn into characters */

-

-        if (c >= 0) goto NON_SPECIAL_CHARACTER;

-

-        /* Escapes that are meta-things. The normal ones just affect the

-        bit map, but Unicode properties require an XCLASS extended item. */

-

-        else

-          {

-          class_optcount = 10;         /* \d, \s etc; make sure > 1 */

-#ifdef SUPPORT_UTF8

-          if (-c == ESC_p || -c == ESC_P)

-            {

-            if (!class_utf8)

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-            length += 2;

-            }

-#endif

-          }

-        }

-

-      /* Check the syntax for POSIX stuff. The bits we actually handle are

-      checked during the real compile phase. */

-

-      else if (*ptr == '[' && check_posix_syntax(ptr, &ptr, &compile_block))

-        {

-        ptr++;

-        class_optcount = 10;    /* Make sure > 1 */

-        }

-

-      /* Anything else increments the possible optimization count. We have to

-      detect ranges here so that we can compute the number of extra ranges for

-      caseless wide characters when UCP support is available. If there are wide

-      characters, we are going to have to use an XCLASS, even for single

-      characters. */

-

-      else

-        {

-        int d;

-

-        GET_ONE_CHARACTER:

-

-#ifdef SUPPORT_UTF8

-        if (utf8)

-          {

-          int extra = 0;

-          GETCHARLEN(c, ptr, extra);

-          ptr += extra;

-          }

-        else c = *ptr;

-#else

-        c = *ptr;

-#endif

-

-        /* Come here from handling \ above when it escapes to a char value */

-

-        NON_SPECIAL_CHARACTER:

-        class_optcount++;

-

-        d = -1;

-        if (ptr[1] == '-')

-          {

-          uschar const *hyptr = ptr++;

-          if (ptr[1] == '\\')

-            {

-            ptr++;

-            d = check_escape(&ptr, &errorcode, bracount, options, TRUE);

-            if (errorcode != 0) goto PCRE_ERROR_RETURN;

-            if (-d == ESC_b) d = '\b';        /* backspace */

-            else if (-d == ESC_X) d = 'X';    /* literal X in a class */

-            }

-          else if (ptr[1] != 0 && ptr[1] != ']')

-            {

-            ptr++;

-#ifdef SUPPORT_UTF8

-            if (utf8)

-              {

-              int extra = 0;

-              GETCHARLEN(d, ptr, extra);

-              ptr += extra;

-              }

-            else

-#endif

-            d = *ptr;

-            }

-          if (d < 0) ptr = hyptr;      /* go back to hyphen as data */

-          }

-

-        /* If d >= 0 we have a range. In UTF-8 mode, if the end is > 255, or >

-        127 for caseless matching, we will need to use an XCLASS. */

-

-        if (d >= 0)

-          {

-          class_optcount = 10;     /* Ensure > 1 */

-          if (d < c)

-            {

-            errorcode = ERR8;

-            goto PCRE_ERROR_RETURN;

-            }

-

-#ifdef SUPPORT_UTF8

-          if (utf8 && (d > 255 || ((options & PCRE_CASELESS) != 0 && d > 127)))

-            {

-            uschar buffer[6];

-            if (!class_utf8)         /* Allow for XCLASS overhead */

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-

-#ifdef SUPPORT_UCP

-            /* If we have UCP support, find out how many extra ranges are

-            needed to map the other case of characters within this range. We

-            have to mimic the range optimization here, because extending the

-            range upwards might push d over a boundary that makes is use

-            another byte in the UTF-8 representation. */

-

-            if ((options & PCRE_CASELESS) != 0)

-              {

-              int occ, ocd;

-              int cc = c;

-              int origd = d;

-              while (get_othercase_range(&cc, origd, &occ, &ocd))

-                {

-                if (occ >= c && ocd <= d) continue;   /* Skip embedded */

-

-                if (occ < c  && ocd >= c - 1)  /* Extend the basic range */

-                  {                            /* if there is overlap,   */

-                  c = occ;                     /* noting that if occ < c */

-                  continue;                    /* we can't have ocd > d  */

-                  }                            /* because a subrange is  */

-                if (ocd > d && occ <= d + 1)   /* always shorter than    */

-                  {                            /* the basic range.       */

-                  d = ocd;

-                  continue;

-                  }

-

-                /* An extra item is needed */

-

-                length += 1 + _pcre_ord2utf8(occ, buffer) +

-                  ((occ == ocd)? 0 : _pcre_ord2utf8(ocd, buffer));

-                }

-              }

-#endif  /* SUPPORT_UCP */

-

-            /* The length of the (possibly extended) range */

-

-            length += 1 + _pcre_ord2utf8(c, buffer) + _pcre_ord2utf8(d, buffer);

-            }

-#endif  /* SUPPORT_UTF8 */

-

-          }

-

-        /* We have a single character. There is nothing to be done unless we

-        are in UTF-8 mode. If the char is > 255, or 127 when caseless, we must

-        allow for an XCL_SINGLE item, doubled for caselessness if there is UCP

-        support. */

-

-        else

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && (c > 255 || ((options & PCRE_CASELESS) != 0 && c > 127)))

-            {

-            uschar buffer[6];

-            class_optcount = 10;     /* Ensure > 1 */

-            if (!class_utf8)         /* Allow for XCLASS overhead */

-              {

-              class_utf8 = TRUE;

-              length += LINK_SIZE + 2;

-              }

-#ifdef SUPPORT_UCP

-            length += (((options & PCRE_CASELESS) != 0)? 2 : 1) *

-              (1 + _pcre_ord2utf8(c, buffer));

-#else   /* SUPPORT_UCP */

-            length += 1 + _pcre_ord2utf8(c, buffer);

-#endif  /* SUPPORT_UCP */

-            }

-#endif  /* SUPPORT_UTF8 */

-          }

-        }

-      }

-    while (*(++ptr) != 0 && (inescq || *ptr != ']')); /* Concludes "do" above */

-

-    if (*ptr == 0)                          /* Missing terminating ']' */

-      {

-      errorcode = ERR6;

-      goto PCRE_ERROR_RETURN;

-      }

-

-    /* We can optimize when there was only one optimizable character. Repeats

-    for positive and negated single one-byte chars are handled by the general

-    code. Here, we handle repeats for the class opcodes. */

-

-    if (class_optcount == 1) length += 3; else

-      {

-      length += 33;

-

-      /* A repeat needs either 1 or 5 bytes. If it is a possessive quantifier,

-      we also need extra for wrapping the whole thing in a sub-pattern. */

-

-      if (*ptr != 0 && ptr[1] == '{' && is_counted_repeat(ptr+2))

-        {

-        ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-        if (errorcode != 0) goto PCRE_ERROR_RETURN;

-        if ((min == 0 && (max == 1 || max == -1)) ||

-          (min == 1 && max == -1))

-            length++;

-        else length += 5;

-        if (ptr[1] == '+')

-          {

-          ptr++;

-          length += 2 + 2*LINK_SIZE;

-          }

-        else if (ptr[1] == '?') ptr++;

-        }

-      }

-    continue;

-

-    /* Brackets may be genuine groups or special things */

-

-    case '(':

-    branch_newextra = 0;

-    bracket_length = 1 + LINK_SIZE;

-    capturing = FALSE;

-

-    /* Handle special forms of bracket, which all start (? */

-

-    if (ptr[1] == '?')

-      {

-      int set, unset;

-      int *optset;

-

-      switch (c = ptr[2])

-        {

-        /* Skip over comments entirely */

-        case '#':

-        ptr += 3;

-        while (*ptr != 0 && *ptr != ')') ptr++;

-        if (*ptr == 0)

-          {

-          errorcode = ERR18;

-          goto PCRE_ERROR_RETURN;

-          }

-        continue;

-

-        /* Non-referencing groups and lookaheads just move the pointer on, and

-        then behave like a non-special bracket, except that they don't increment

-        the count of extracting brackets. Ditto for the "once only" bracket,

-        which is in Perl from version 5.005. */

-

-        case ':':

-        case '=':

-        case '!':

-        case '>':

-        ptr += 2;

-        break;

-

-        /* (?R) specifies a recursive call to the regex, which is an extension

-        to provide the facility which can be obtained by (?p{perl-code}) in

-        Perl 5.6. In Perl 5.8 this has become (??{perl-code}).

-

-        From PCRE 4.00, items such as (?3) specify subroutine-like "calls" to

-        the appropriate numbered brackets. This includes both recursive and

-        non-recursive calls. (?R) is now synonymous with (?0). */

-

-        case 'R':

-        ptr++;

-

-        case '0': case '1': case '2': case '3': case '4':

-        case '5': case '6': case '7': case '8': case '9':

-        ptr += 2;

-        if (c != 'R')

-          while ((digitab[*(++ptr)] & ctype_digit) != 0);

-        if (*ptr != ')')

-          {

-          errorcode = ERR29;

-          goto PCRE_ERROR_RETURN;

-          }

-        length += 1 + LINK_SIZE;

-

-        /* If this item is quantified, it will get wrapped inside brackets so

-        as to use the code for quantified brackets. We jump down and use the

-        code that handles this for real brackets. */

-

-        if (ptr[1] == '+' || ptr[1] == '*' || ptr[1] == '?' || ptr[1] == '{')

-          {

-          length += 2 + 2 * LINK_SIZE;       /* to make bracketed */

-          duplength = 5 + 3 * LINK_SIZE;

-          goto HANDLE_QUANTIFIED_BRACKETS;

-          }

-        continue;

-

-        /* (?C) is an extension which provides "callout" - to provide a bit of

-        the functionality of the Perl (?{...}) feature. An optional number may

-        follow (default is zero). */

-

-        case 'C':

-        ptr += 2;

-        while ((digitab[*(++ptr)] & ctype_digit) != 0);

-        if (*ptr != ')')

-          {

-          errorcode = ERR39;

-          goto PCRE_ERROR_RETURN;

-          }

-        length += 2 + 2*LINK_SIZE;

-        continue;

-

-        /* Named subpatterns are an extension copied from Python */

-

-        case 'P':

-        ptr += 3;

-

-        /* Handle the definition of a named subpattern */

-

-        if (*ptr == '<')

-          {

-          const uschar *p;    /* Don't amalgamate; some compilers */

-          p = ++ptr;          /* grumble at autoincrement in declaration */

-          while ((compile_block.ctypes[*ptr] & ctype_word) != 0) ptr++;

-          if (*ptr != '>')

-            {

-            errorcode = ERR42;

-            goto PCRE_ERROR_RETURN;

-            }

-          name_count++;

-          if (ptr - p > max_name_size) max_name_size = (ptr - p);

-          capturing = TRUE;   /* Named parentheses are always capturing */

-          break;

-          }

-

-        /* Handle back references and recursive calls to named subpatterns */

-

-        if (*ptr == '=' || *ptr == '>')

-          {

-          while ((compile_block.ctypes[*(++ptr)] & ctype_word) != 0);

-          if (*ptr != ')')

-            {

-            errorcode = ERR42;

-            goto PCRE_ERROR_RETURN;

-            }

-          break;

-          }

-

-        /* Unknown character after (?P */

-

-        errorcode = ERR41;

-        goto PCRE_ERROR_RETURN;

-

-        /* Lookbehinds are in Perl from version 5.005 */

-

-        case '<':

-        ptr += 3;

-        if (*ptr == '=' || *ptr == '!')

-          {

-          branch_newextra = 1 + LINK_SIZE;

-          length += 1 + LINK_SIZE;         /* For the first branch */

-          break;

-          }

-        errorcode = ERR24;

-        goto PCRE_ERROR_RETURN;

-

-        /* Conditionals are in Perl from version 5.005. The bracket must either

-        be followed by a number (for bracket reference) or by an assertion

-        group, or (a PCRE extension) by 'R' for a recursion test. */

-

-        case '(':

-        if (ptr[3] == 'R' && ptr[4] == ')')

-          {

-          ptr += 4;

-          length += 3;

-          }

-        else if ((digitab[ptr[3]] & ctype_digit) != 0)

-          {

-          ptr += 4;

-          length += 3;

-          while ((digitab[*ptr] & ctype_digit) != 0) ptr++;

-          if (*ptr != ')')

-            {

-            errorcode = ERR26;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-        else   /* An assertion must follow */

-          {

-          ptr++;   /* Can treat like ':' as far as spacing is concerned */

-          if (ptr[2] != '?' ||

-             (ptr[3] != '=' && ptr[3] != '!' && ptr[3] != '<') )

-            {

-            ptr += 2;    /* To get right offset in message */

-            errorcode = ERR28;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-        break;

-

-        /* Else loop checking valid options until ) is met. Anything else is an

-        error. If we are without any brackets, i.e. at top level, the settings

-        act as if specified in the options, so massage the options immediately.

-        This is for backward compatibility with Perl 5.004. */

-

-        default:

-        set = unset = 0;

-        optset = &set;

-        ptr += 2;

-

-        for (;; ptr++)

-          {

-          c = *ptr;

-          switch (c)

-            {

-            case 'i':

-            *optset |= PCRE_CASELESS;

-            continue;

-

-            case 'm':

-            *optset |= PCRE_MULTILINE;

-            continue;

-

-            case 's':

-            *optset |= PCRE_DOTALL;

-            continue;

-

-            case 'x':

-            *optset |= PCRE_EXTENDED;

-            continue;

-

-            case 'X':

-            *optset |= PCRE_EXTRA;

-            continue;

-

-            case 'U':

-            *optset |= PCRE_UNGREEDY;

-            continue;

-

-            case '-':

-            optset = &unset;

-            continue;

-

-            /* A termination by ')' indicates an options-setting-only item; if

-            this is at the very start of the pattern (indicated by item_count

-            being zero), we use it to set the global options. This is helpful

-            when analyzing the pattern for first characters, etc. Otherwise

-            nothing is done here and it is handled during the compiling

-            process.

-

-            We allow for more than one options setting at the start. If such

-            settings do not change the existing options, nothing is compiled.

-            However, we must leave space just in case something is compiled.

-            This can happen for pathological sequences such as (?i)(?-i)

-            because the global options will end up with -i set. The space is

-            small and not significant. (Before I did this there was a reported

-            bug with (?i)(?-i) in a machine-generated pattern.)

-

-            [Historical note: Up to Perl 5.8, options settings at top level

-            were always global settings, wherever they appeared in the pattern.

-            That is, they were equivalent to an external setting. From 5.8

-            onwards, they apply only to what follows (which is what you might

-            expect).] */

-

-            case ')':

-            if (item_count == 0)

-              {

-              options = (options | set) & (~unset);

-              set = unset = 0;     /* To save length */

-              item_count--;        /* To allow for several */

-              length += 2;

-              }

-

-            /* Fall through */

-

-            /* A termination by ':' indicates the start of a nested group with

-            the given options set. This is again handled at compile time, but

-            we must allow for compiled space if any of the ims options are

-            set. We also have to allow for resetting space at the end of

-            the group, which is why 4 is added to the length and not just 2.

-            If there are several changes of options within the same group, this

-            will lead to an over-estimate on the length, but this shouldn't

-            matter very much. We also have to allow for resetting options at

-            the start of any alternations, which we do by setting

-            branch_newextra to 2. Finally, we record whether the case-dependent

-            flag ever changes within the regex. This is used by the "required

-            character" code. */

-

-            case ':':

-            if (((set|unset) & PCRE_IMS) != 0)

-              {

-              length += 4;

-              branch_newextra = 2;

-              if (((set|unset) & PCRE_CASELESS) != 0) options |= PCRE_ICHANGED;

-              }

-            goto END_OPTIONS;

-

-            /* Unrecognized option character */

-

-            default:

-            errorcode = ERR12;

-            goto PCRE_ERROR_RETURN;

-            }

-          }

-

-        /* If we hit a closing bracket, that's it - this is a freestanding

-        option-setting. We need to ensure that branch_extra is updated if

-        necessary. The only values branch_newextra can have here are 0 or 2.

-        If the value is 2, then branch_extra must either be 2 or 5, depending

-        on whether this is a lookbehind group or not. */

-

-        END_OPTIONS:

-        if (c == ')')

-          {

-          if (branch_newextra == 2 &&

-              (branch_extra == 0 || branch_extra == 1+LINK_SIZE))

-            branch_extra += branch_newextra;

-          continue;

-          }

-

-        /* If options were terminated by ':' control comes here. This is a

-        non-capturing group with an options change. There is nothing more that

-        needs to be done because "capturing" is already set FALSE by default;

-        we can just fall through. */

-

-        }

-      }

-

-    /* Ordinary parentheses, not followed by '?', are capturing unless

-    PCRE_NO_AUTO_CAPTURE is set. */

-

-    else capturing = (options & PCRE_NO_AUTO_CAPTURE) == 0;

-

-    /* Capturing brackets must be counted so we can process escapes in a

-    Perlish way. If the number exceeds EXTRACT_BASIC_MAX we are going to need

-    an additional 3 bytes of memory per capturing bracket. */

-

-    if (capturing)

-      {

-      bracount++;

-      if (bracount > EXTRACT_BASIC_MAX) bracket_length += 3;

-      }

-

-    /* Save length for computing whole length at end if there's a repeat that

-    requires duplication of the group. Also save the current value of

-    branch_extra, and start the new group with the new value. If non-zero, this

-    will either be 2 for a (?imsx: group, or 3 for a lookbehind assertion. */

-

-    if (brastackptr >= sizeof(brastack)/sizeof(int))

-      {

-      errorcode = ERR19;

-      goto PCRE_ERROR_RETURN;

-      }

-

-    bralenstack[brastackptr] = branch_extra;

-    branch_extra = branch_newextra;

-

-    brastack[brastackptr++] = length;

-    length += bracket_length;

-    continue;

-

-    /* Handle ket. Look for subsequent max/min; for certain sets of values we

-    have to replicate this bracket up to that many times. If brastackptr is

-    0 this is an unmatched bracket which will generate an error, but take care

-    not to try to access brastack[-1] when computing the length and restoring

-    the branch_extra value. */

-

-    case ')':

-    length += 1 + LINK_SIZE;

-    if (brastackptr > 0)

-      {

-      duplength = length - brastack[--brastackptr];

-      branch_extra = bralenstack[brastackptr];

-      }

-    else duplength = 0;

-

-    /* The following code is also used when a recursion such as (?3) is

-    followed by a quantifier, because in that case, it has to be wrapped inside

-    brackets so that the quantifier works. The value of duplength must be

-    set before arrival. */

-

-    HANDLE_QUANTIFIED_BRACKETS:

-

-    /* Leave ptr at the final char; for read_repeat_counts this happens

-    automatically; for the others we need an increment. */

-

-    if ((c = ptr[1]) == '{' && is_counted_repeat(ptr+2))

-      {

-      ptr = read_repeat_counts(ptr+2, &min, &max, &errorcode);

-      if (errorcode != 0) goto PCRE_ERROR_RETURN;

-      }

-    else if (c == '*') { min = 0; max = -1; ptr++; }

-    else if (c == '+') { min = 1; max = -1; ptr++; }

-    else if (c == '?') { min = 0; max = 1;  ptr++; }

-    else { min = 1; max = 1; }

-

-    /* If the minimum is zero, we have to allow for an OP_BRAZERO before the

-    group, and if the maximum is greater than zero, we have to replicate

-    maxval-1 times; each replication acquires an OP_BRAZERO plus a nesting

-    bracket set. */

-

-    if (min == 0)

-      {

-      length++;

-      if (max > 0) length += (max - 1) * (duplength + 3 + 2*LINK_SIZE);

-      }

-

-    /* When the minimum is greater than zero, we have to replicate up to

-    minval-1 times, with no additions required in the copies. Then, if there

-    is a limited maximum we have to replicate up to maxval-1 times allowing

-    for a BRAZERO item before each optional copy and nesting brackets for all

-    but one of the optional copies. */

-

-    else

-      {

-      length += (min - 1) * duplength;

-      if (max > min)   /* Need this test as max=-1 means no limit */

-        length += (max - min) * (duplength + 3 + 2*LINK_SIZE)

-          - (2 + 2*LINK_SIZE);

-      }

-

-    /* Allow space for once brackets for "possessive quantifier" */

-

-    if (ptr[1] == '+')

-      {

-      ptr++;

-      length += 2 + 2*LINK_SIZE;

-      }

-    continue;

-

-    /* Non-special character. It won't be space or # in extended mode, so it is

-    always a genuine character. If we are in a \Q...\E sequence, check for the

-    end; if not, we have a literal. */

-

-    default:

-    NORMAL_CHAR:

-

-    if (inescq && c == '\\' && ptr[1] == 'E')

-      {

-      inescq = FALSE;

-      ptr++;

-      continue;

-      }

-

-    length += 2;          /* For a one-byte character */

-    lastitemlength = 1;   /* Default length of last item for repeats */

-

-    /* In UTF-8 mode, check for additional bytes. */

-

-#ifdef SUPPORT_UTF8

-    if (utf8 && (c & 0xc0) == 0xc0)

-      {

-      while ((ptr[1] & 0xc0) == 0x80)         /* Can't flow over the end */

-        {                                     /* because the end is marked */

-        lastitemlength++;                     /* by a zero byte. */

-        length++;

-        ptr++;

-        }

-      }

-#endif

-

-    continue;

-    }

-  }

-

-length += 2 + LINK_SIZE;    /* For final KET and END */

-

-if ((options & PCRE_AUTO_CALLOUT) != 0)

-  length += 2 + 2*LINK_SIZE;  /* For final callout */

-

-if (length > MAX_PATTERN_SIZE)

-  {

-  errorcode = ERR20;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Compute the size of data block needed and get it, either from malloc or

-externally provided function. */

-

-size = length + sizeof(real_pcre) + name_count * (max_name_size + 3);

-re = (real_pcre *)(pcre_malloc)(size);

-

-if (re == NULL)

-  {

-  errorcode = ERR21;

-  goto PCRE_EARLY_ERROR_RETURN;

-  }

-

-/* Put in the magic number, and save the sizes, options, and character table

-pointer. NULL is used for the default character tables. The nullpad field is at

-the end; it's there to help in the case when a regex compiled on a system with

-4-byte pointers is run on another with 8-byte pointers. */

-

-re->magic_number = MAGIC_NUMBER;

-re->size = size;

-re->options = options;

-re->dummy1 = 0;

-re->name_table_offset = sizeof(real_pcre);

-re->name_entry_size = max_name_size + 3;

-re->name_count = name_count;

-re->ref_count = 0;

-re->tables = (tables == _pcre_default_tables)? NULL : tables;

-re->nullpad = NULL;

-

-/* The starting points of the name/number translation table and of the code are

-passed around in the compile data block. */

-

-compile_block.names_found = 0;

-compile_block.name_entry_size = max_name_size + 3;

-compile_block.name_table = (uschar *)re + re->name_table_offset;

-codestart = compile_block.name_table + re->name_entry_size * re->name_count;

-compile_block.start_code = codestart;

-compile_block.start_pattern = (const uschar *)pattern;

-compile_block.req_varyopt = 0;

-compile_block.nopartial = FALSE;

-

-/* Set up a starting, non-extracting bracket, then compile the expression. On

-error, errorcode will be set non-zero, so we don't need to look at the result

-of the function here. */

-

-ptr = (const uschar *)pattern;

-code = (uschar *)codestart;

-*code = OP_BRA;

-bracount = 0;

-(void)compile_regex(options, options & PCRE_IMS, &bracount, &code, &ptr,

-  &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, &compile_block);

-re->top_bracket = bracount;

-re->top_backref = compile_block.top_backref;

-

-if (compile_block.nopartial) re->options |= PCRE_NOPARTIAL;

-

-/* If not reached end of pattern on success, there's an excess bracket. */

-

-if (errorcode == 0 && *ptr != 0) errorcode = ERR22;

-

-/* Fill in the terminating state and check for disastrous overflow, but

-if debugging, leave the test till after things are printed out. */

-

-*code++ = OP_END;

-

-#ifndef DEBUG

-if (code - codestart > length) errorcode = ERR23;

-#endif

-

-/* Give an error if there's back reference to a non-existent capturing

-subpattern. */

-

-if (re->top_backref > re->top_bracket) errorcode = ERR15;

-

-/* Failed to compile, or error while post-processing */

-

-if (errorcode != 0)

-  {

-  (pcre_free)(re);

-  PCRE_ERROR_RETURN:

-  *erroroffset = ptr - (const uschar *)pattern;

-  PCRE_EARLY_ERROR_RETURN:

-  *errorptr = error_texts[errorcode];

-  if (errorcodeptr != NULL) *errorcodeptr = errorcode;

-  return NULL;

-  }

-

-/* If the anchored option was not passed, set the flag if we can determine that

-the pattern is anchored by virtue of ^ characters or \A or anything else (such

-as starting with .* when DOTALL is set).

-

-Otherwise, if we know what the first character has to be, save it, because that

-speeds up unanchored matches no end. If not, see if we can set the

-PCRE_STARTLINE flag. This is helpful for multiline matches when all branches

-start with ^. and also when all branches start with .* for non-DOTALL matches.

-*/

-

-if ((options & PCRE_ANCHORED) == 0)

-  {

-  int temp_options = options;

-  if (is_anchored(codestart, &temp_options, 0, compile_block.backref_map))

-    re->options |= PCRE_ANCHORED;

-  else

-    {

-    if (firstbyte < 0)

-      firstbyte = find_firstassertedchar(codestart, &temp_options, FALSE);

-    if (firstbyte >= 0)   /* Remove caseless flag for non-caseable chars */

-      {

-      int ch = firstbyte & 255;

-      re->first_byte = ((firstbyte & REQ_CASELESS) != 0 &&

-         compile_block.fcc[ch] == ch)? ch : firstbyte;

-      re->options |= PCRE_FIRSTSET;

-      }

-    else if (is_startline(codestart, 0, compile_block.backref_map))

-      re->options |= PCRE_STARTLINE;

-    }

-  }

-

-/* For an anchored pattern, we use the "required byte" only if it follows a

-variable length item in the regex. Remove the caseless flag for non-caseable

-bytes. */

-

-if (reqbyte >= 0 &&

-     ((re->options & PCRE_ANCHORED) == 0 || (reqbyte & REQ_VARY) != 0))

-  {

-  int ch = reqbyte & 255;

-  re->req_byte = ((reqbyte & REQ_CASELESS) != 0 &&

-    compile_block.fcc[ch] == ch)? (reqbyte & ~REQ_CASELESS) : reqbyte;

-  re->options |= PCRE_REQCHSET;

-  }

-

-/* Print out the compiled data for debugging */

-

-#ifdef DEBUG

-

-printf("Length = %d top_bracket = %d top_backref = %d\n",

-  length, re->top_bracket, re->top_backref);

-

-if (re->options != 0)

-  {

-  printf("%s%s%s%s%s%s%s%s%s%s\n",

-    ((re->options & PCRE_NOPARTIAL) != 0)? "nopartial " : "",

-    ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",

-    ((re->options & PCRE_CASELESS) != 0)? "caseless " : "",

-    ((re->options & PCRE_ICHANGED) != 0)? "case state changed " : "",

-    ((re->options & PCRE_EXTENDED) != 0)? "extended " : "",

-    ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",

-    ((re->options & PCRE_DOTALL) != 0)? "dotall " : "",

-    ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",

-    ((re->options & PCRE_EXTRA) != 0)? "extra " : "",

-    ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : "");

-  }

-

-if ((re->options & PCRE_FIRSTSET) != 0)

-  {

-  int ch = re->first_byte & 255;

-  const char *caseless = ((re->first_byte & REQ_CASELESS) == 0)? "" : " (caseless)";

-  if (isprint(ch)) printf("First char = %c%s\n", ch, caseless);

-    else printf("First char = \\x%02x%s\n", ch, caseless);

-  }

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  int ch = re->req_byte & 255;

-  const char *caseless = ((re->req_byte & REQ_CASELESS) == 0)? "" : " (caseless)";

-  if (isprint(ch)) printf("Req char = %c%s\n", ch, caseless);

-    else printf("Req char = \\x%02x%s\n", ch, caseless);

-  }

-

-_pcre_printint(re, stdout);

-

-/* This check is done here in the debugging case so that the code that

-was compiled can be seen. */

-

-if (code - codestart > length)

-  {

-  (pcre_free)(re);

-  *errorptr = error_texts[ERR23];

-  *erroroffset = ptr - (uschar *)pattern;

-  if (errorcodeptr != NULL) *errorcodeptr = ERR23;

-  return NULL;

-  }

-#endif

-

-return (pcre *)re;

-}

-

-/* End of pcre_compile.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_config(). */

-

-

-

-

-/*************************************************

-* Return info about what features are configured *

-*************************************************/

-

-/* This function has an extensible interface so that additional items can be

-added compatibly.

-

-Arguments:

-  what             what information is required

-  where            where to put the information

-

-Returns:           0 if data returned, negative on error

-*/

-

-EXPORT int

-pcre_config(int what, void *where)

-{

-switch (what)

-  {

-  case PCRE_CONFIG_UTF8:

-#ifdef SUPPORT_UTF8

-  *((int *)where) = 1;

-#else

-  *((int *)where) = 0;

-#endif

-  break;

-

-  case PCRE_CONFIG_UNICODE_PROPERTIES:

-#ifdef SUPPORT_UCP

-  *((int *)where) = 1;

-#else

-  *((int *)where) = 0;

-#endif

-  break;

-

-  case PCRE_CONFIG_NEWLINE:

-  *((int *)where) = NEWLINE;

-  break;

-

-  case PCRE_CONFIG_LINK_SIZE:

-  *((int *)where) = LINK_SIZE;

-  break;

-

-  case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:

-  *((int *)where) = POSIX_MALLOC_THRESHOLD;

-  break;

-

-  case PCRE_CONFIG_MATCH_LIMIT:

-  *((unsigned int *)where) = MATCH_LIMIT;

-  break;

-

-  case PCRE_CONFIG_STACKRECURSE:

-#ifdef NO_RECURSE

-  *((int *)where) = 0;

-#else

-  *((int *)where) = 1;

-#endif

-  break;

-

-  default: return PCRE_ERROR_BADOPTION;

-  }

-

-return 0;

-}

-

-/* End of pcre_config.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_dfa_exec(), which is an

-alternative matching function that uses a DFA algorithm. This is NOT Perl-

-compatible, but it has advantages in certain applications. */

-

-

-

-

-/* For use to indent debugging output */

-

-#define SP "                   "

-

-

-

-/*************************************************

-*      Code parameters and static tables         *

-*************************************************/

-

-/* These are offsets that are used to turn the OP_TYPESTAR and friends opcodes

-into others, under special conditions. A gap of 10 between the blocks should be

-enough. */

-

-#define OP_PROP_EXTRA    (EXTRACT_BASIC_MAX+1)

-#define OP_EXTUNI_EXTRA  (EXTRACT_BASIC_MAX+11)

-

-

-/* This table identifies those opcodes that are followed immediately by a

-character that is to be tested in some way. This makes is possible to

-centralize the loading of these characters. In the case of Type * etc, the

-"character" is the opcode for \D, \d, \S, \s, \W, or \w, which will always be a

-small value. */

-

-static uschar coptable[] = {

-  0,                             /* End                                    */

-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* \A, \G, \B, \b, \D, \d, \S, \s, \W, \w */

-  0, 0,                          /* Any, Anybyte                           */

-  0, 0, 0,                       /* NOTPROP, PROP, EXTUNI                  */

-  0, 0, 0, 0, 0,                 /* \Z, \z, Opt, ^, $                      */

-  1,                             /* Char                                   */

-  1,                             /* Charnc                                 */

-  1,                             /* not                                    */

-  /* Positive single-char repeats                                          */

-  1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */

-  3, 3, 3,                       /* upto, minupto, exact                   */

-  /* Negative single-char repeats - only for chars < 256                   */

-  1, 1, 1, 1, 1, 1,              /* NOT *, *?, +, +?, ?, ??                */

-  3, 3, 3,                       /* NOT upto, minupto, exact               */

-  /* Positive type repeats                                                 */

-  1, 1, 1, 1, 1, 1,              /* Type *, *?, +, +?, ?, ??               */

-  3, 3, 3,                       /* Type upto, minupto, exact              */

-  /* Character class & ref repeats                                         */

-  0, 0, 0, 0, 0, 0,              /* *, *?, +, +?, ?, ??                    */

-  0, 0,                          /* CRRANGE, CRMINRANGE                    */

-  0,                             /* CLASS                                  */

-  0,                             /* NCLASS                                 */

-  0,                             /* XCLASS - variable length               */

-  0,                             /* REF                                    */

-  0,                             /* RECURSE                                */

-  0,                             /* CALLOUT                                */

-  0,                             /* Alt                                    */

-  0,                             /* Ket                                    */

-  0,                             /* KetRmax                                */

-  0,                             /* KetRmin                                */

-  0,                             /* Assert                                 */

-  0,                             /* Assert not                             */

-  0,                             /* Assert behind                          */

-  0,                             /* Assert behind not                      */

-  0,                             /* Reverse                                */

-  0,                             /* Once                                   */

-  0,                             /* COND                                   */

-  0,                             /* CREF                                   */

-  0, 0,                          /* BRAZERO, BRAMINZERO                    */

-  0,                             /* BRANUMBER                              */

-  0                              /* BRA                                    */

-};

-

-/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,

-and \w */

-

-static uschar toptable1[] = {

-  0, 0, 0, 0, 0,

-  ctype_digit, ctype_digit,

-  ctype_space, ctype_space,

-  ctype_word,  ctype_word,

-  0                               /* OP_ANY */

-};

-

-static uschar toptable2[] = {

-  0, 0, 0, 0, 0,

-  ctype_digit, 0,

-  ctype_space, 0,

-  ctype_word,  0,

-  1                               /* OP_ANY */

-};

-

-

-/* Structure for holding data about a particular state, which is in effect the

-current data for an active path through the match tree. It must consist

-entirely of ints because the working vector we are passed, and which we put

-these structures in, is a vector of ints. */

-

-typedef struct stateblock {

-  int offset;                     /* Offset to opcode */

-  int count;                      /* Count for repeats */

-  int ims;                        /* ims flag bits */

-  int data;                       /* Some use extra data */

-} stateblock;

-

-#define INTS_PER_STATEBLOCK  (sizeof(stateblock)/sizeof(int))

-

-

-#ifdef DEBUG

-/*************************************************

-*             Print character string             *

-*************************************************/

-

-/* Character string printing function for debugging.

-

-Arguments:

-  p            points to string

-  length       number of bytes

-  f            where to print

-

-Returns:       nothing

-*/

-

-static void

-pchars(unsigned char *p, int length, FILE *f)

-{

-int c;

-while (length-- > 0)

-  {

-  if (isprint(c = *(p++)))

-    fprintf(f, "%c", c);

-  else

-    fprintf(f, "\\x%02x", c);

-  }

-}

-#endif

-

-

-

-/*************************************************

-*    Execute a Regular Expression - DFA engine   *

-*************************************************/

-

-/* This internal function applies a compiled pattern to a subject string,

-starting at a given point, using a DFA engine. This function is called from the

-external one, possibly multiple times if the pattern is not anchored. The

-function calls itself recursively for some kinds of subpattern.

-

-Arguments:

-  md                the match_data block with fixed information

-  this_start_code   the opening bracket of this subexpression's code

-  current_subject   where we currently are in the subject string

-  start_offset      start offset in the subject string

-  offsets           vector to contain the matching string offsets

-  offsetcount       size of same

-  workspace         vector of workspace

-  wscount           size of same

-  ims               the current ims flags

-  rlevel            function call recursion level

-  recursing         regex recursive call level

-

-Returns:            > 0 =>

-                    = 0 =>

-                     -1 => failed to match

-                   < -1 => some kind of unexpected problem

-

-The following macros are used for adding states to the two state vectors (one

-for the current character, one for the following character). */

-

-#define ADD_ACTIVE(x,y) \

-  if (active_count++ < wscount) \

-    { \

-    next_active_state->offset = (x); \

-    next_active_state->count  = (y); \

-    next_active_state->ims    = ims; \

-    next_active_state++; \

-    DPRINTF(("%.*sADD_ACTIVE(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_ACTIVE_DATA(x,y,z) \

-  if (active_count++ < wscount) \

-    { \

-    next_active_state->offset = (x); \

-    next_active_state->count  = (y); \

-    next_active_state->ims    = ims; \

-    next_active_state->data   = (z); \

-    next_active_state++; \

-    DPRINTF(("%.*sADD_ACTIVE_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_NEW(x,y) \

-  if (new_count++ < wscount) \

-    { \

-    next_new_state->offset = (x); \

-    next_new_state->count  = (y); \

-    next_new_state->ims    = ims; \

-    next_new_state++; \

-    DPRINTF(("%.*sADD_NEW(%d,%d)\n", rlevel*2-2, SP, (x), (y))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-#define ADD_NEW_DATA(x,y,z) \

-  if (new_count++ < wscount) \

-    { \

-    next_new_state->offset = (x); \

-    next_new_state->count  = (y); \

-    next_new_state->ims    = ims; \

-    next_new_state->data   = (z); \

-    next_new_state++; \

-    DPRINTF(("%.*sADD_NEW_DATA(%d,%d,%d)\n", rlevel*2-2, SP, (x), (y), (z))); \

-    } \

-  else return PCRE_ERROR_DFA_WSSIZE

-

-/* And now, here is the code */

-

-static int

-internal_dfa_exec(

-  dfa_match_data *md,

-  const uschar *this_start_code,

-  const uschar *current_subject,

-  int start_offset,

-  int *offsets,

-  int offsetcount,

-  int *workspace,

-  int wscount,

-  int ims,

-  int  rlevel,

-  int  recursing)

-{

-stateblock *active_states, *new_states, *temp_states;

-stateblock *next_active_state, *next_new_state;

-

-const uschar *ctypes, *lcc, *fcc;

-const uschar *ptr;

-const uschar *end_code;

-

-int active_count, new_count, match_count;

-

-/* Some fields in the md block are frequently referenced, so we load them into

-independent variables in the hope that this will perform better. */

-

-const uschar *start_subject = md->start_subject;

-const uschar *end_subject = md->end_subject;

-const uschar *start_code = md->start_code;

-

-BOOL utf8 = (md->poptions & PCRE_UTF8) != 0;

-

-rlevel++;

-offsetcount &= (-2);

-

-wscount -= 2;

-wscount = (wscount - (wscount % (INTS_PER_STATEBLOCK * 2))) /

-          (2 * INTS_PER_STATEBLOCK);

-

-DPRINTF(("\n%.*s---------------------\n"

-  "%.*sCall to internal_dfa_exec f=%d r=%d\n",

-  rlevel*2-2, SP, rlevel*2-2, SP, rlevel, recursing));

-

-ctypes = md->tables + ctypes_offset;

-lcc = md->tables + lcc_offset;

-fcc = md->tables + fcc_offset;

-

-match_count = PCRE_ERROR_NOMATCH;   /* A negative number */

-

-active_states = (stateblock *)(workspace + 2);

-next_new_state = new_states = active_states + wscount;

-new_count = 0;

-

-/* The first thing in any (sub) pattern is a bracket of some sort. Push all

-the alternative states onto the list, and find out where the end is. This

-makes is possible to use this function recursively, when we want to stop at a

-matching internal ket rather than at the end.

-

-If the first opcode in the first alternative is OP_REVERSE, we are dealing with

-a backward assertion. In that case, we have to find out the maximum amount to

-move back, and set up each alternative appropriately. */

-

-if (this_start_code[1+LINK_SIZE] == OP_REVERSE)

-  {

-  int max_back = 0;

-  int gone_back;

-

-  end_code = this_start_code;

-  do

-    {

-    int back = GET(end_code, 2+LINK_SIZE);

-    if (back > max_back) max_back = back;

-    end_code += GET(end_code, 1);

-    }

-  while (*end_code == OP_ALT);

-

-  /* If we can't go back the amount required for the longest lookbehind

-  pattern, go back as far as we can; some alternatives may still be viable. */

-

-#ifdef SUPPORT_UTF8

-  /* In character mode we have to step back character by character */

-

-  if (utf8)

-    {

-    for (gone_back = 0; gone_back < max_back; gone_back++)

-      {

-      if (current_subject <= start_subject) break;

-      current_subject--;

-      while (current_subject > start_subject &&

-             (*current_subject & 0xc0) == 0x80)

-        current_subject--;

-      }

-    }

-  else

-#endif

-

-  /* In byte-mode we can do this quickly. */

-

-    {

-    gone_back = (current_subject - max_back < start_subject)?

-      current_subject - start_subject : max_back;

-    current_subject -= gone_back;

-    }

-

-  /* Now we can process the individual branches. */

-

-  end_code = this_start_code;

-  do

-    {

-    int back = GET(end_code, 2+LINK_SIZE);

-    if (back <= gone_back)

-      {

-      int bstate = end_code - start_code + 2 + 2*LINK_SIZE;

-      ADD_NEW_DATA(-bstate, 0, gone_back - back);

-      }

-    end_code += GET(end_code, 1);

-    }

-  while (*end_code == OP_ALT);

- }

-

-/* This is the code for a "normal" subpattern (not a backward assertion). The

-start of a whole pattern is always one of these. If we are at the top level,

-we may be asked to restart matching from the same point that we reached for a

-previous partial match. We still have to scan through the top-level branches to

-find the end state. */

-

-else

-  {

-  end_code = this_start_code;

-

-  /* Restarting */

-

-  if (rlevel == 1 && (md->moptions & PCRE_DFA_RESTART) != 0)

-    {

-    do { end_code += GET(end_code, 1); } while (*end_code == OP_ALT);

-    new_count = workspace[1];

-    if (!workspace[0])

-      memcpy(new_states, active_states, new_count * sizeof(stateblock));

-    }

-

-  /* Not restarting */

-

-  else

-    {

-    do

-      {

-      ADD_NEW(end_code - start_code + 1 + LINK_SIZE, 0);

-      end_code += GET(end_code, 1);

-      }

-    while (*end_code == OP_ALT);

-    }

-  }

-

-workspace[0] = 0;    /* Bit indicating which vector is current */

-

-DPRINTF(("%.*sEnd state = %d\n", rlevel*2-2, SP, end_code - start_code));

-

-/* Loop for scanning the subject */

-

-ptr = current_subject;

-for (;;)

-  {

-  int i, j;

-  int c, d, clen, dlen;

-

-  /* Make the new state list into the active state list and empty the

-  new state list. */

-

-  temp_states = active_states;

-  active_states = new_states;

-  new_states = temp_states;

-  active_count = new_count;

-  new_count = 0;

-

-  workspace[0] ^= 1;              /* Remember for the restarting feature */

-  workspace[1] = active_count;

-

-#ifdef DEBUG

-  printf("%.*sNext character: rest of subject = \"", rlevel*2-2, SP);

-  pchars((uschar *)ptr, strlen((char *)ptr), stdout);

-  printf("\"\n");

-

-  printf("%.*sActive states: ", rlevel*2-2, SP);

-  for (i = 0; i < active_count; i++)

-    printf("%d/%d ", active_states[i].offset, active_states[i].count);

-  printf("\n");

-#endif

-

-  /* Set the pointers for adding new states */

-

-  next_active_state = active_states + active_count;

-  next_new_state = new_states;

-

-  /* Load the current character from the subject outside the loop, as many

-  different states may want to look at it, and we assume that at least one

-  will. */

-

-  if (ptr < end_subject)

-    {

-    clen = 1;

-#ifdef SUPPORT_UTF8

-    if (utf8) { GETCHARLEN(c, ptr, clen); } else

-#endif  /* SUPPORT_UTF8 */

-    c = *ptr;

-    }

-  else

-    {

-    clen = 0;    /* At end subject */

-    c = -1;

-    }

-

-  /* Scan up the active states and act on each one. The result of an action

-  may be to add more states to the currently active list (e.g. on hitting a

-  parenthesis) or it may be to put states on the new list, for considering

-  when we move the character pointer on. */

-

-  for (i = 0; i < active_count; i++)

-    {

-    stateblock *current_state = active_states + i;

-    const uschar *code;

-    int state_offset = current_state->offset;

-    int count, codevalue;

-    int chartype, othercase;

-

-#ifdef DEBUG

-    printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);

-    if (c < 0) printf("-1\n");

-      else if (c > 32 && c < 127) printf("'%c'\n", c);

-        else printf("0x%02x\n", c);

-#endif

-

-    /* This variable is referred to implicity in the ADD_xxx macros. */

-

-    ims = current_state->ims;

-

-    /* A negative offset is a special case meaning "hold off going to this

-    (negated) state until the number of characters in the data field have

-    been skipped". */

-

-    if (state_offset < 0)

-      {

-      if (current_state->data > 0)

-        {

-        DPRINTF(("%.*sSkipping this character\n", rlevel*2-2, SP));

-        ADD_NEW_DATA(state_offset, current_state->count,

-          current_state->data - 1);

-        continue;

-        }

-      else

-        {

-        current_state->offset = state_offset = -state_offset;

-        }

-      }

-

-    /* Check for a duplicate state with the same count, and skip if found. */

-

-    for (j = 0; j < i; j++)

-      {

-      if (active_states[j].offset == state_offset &&

-          active_states[j].count == current_state->count)

-        {

-        DPRINTF(("%.*sDuplicate state: skipped\n", rlevel*2-2, SP));

-        goto NEXT_ACTIVE_STATE;

-        }

-      }

-

-    /* The state offset is the offset to the opcode */

-

-    code = start_code + state_offset;

-    codevalue = *code;

-    if (codevalue >= OP_BRA) codevalue = OP_BRA; /* All brackets are equal */

-

-    /* If this opcode is followed by an inline character, load it. It is

-    tempting to test for the presence of a subject character here, but that

-    is wrong, because sometimes zero repetitions of the subject are

-    permitted.

-

-    We also use this mechanism for opcodes such as OP_TYPEPLUS that take an

-    argument that is not a data character - but is always one byte long.

-    Unfortunately, we have to take special action to deal with  \P, \p, and

-    \X in this case. To keep the other cases fast, convert these ones to new

-    opcodes. */

-

-    if (coptable[codevalue] > 0)

-      {

-      dlen = 1;

-#ifdef SUPPORT_UTF8

-      if (utf8) { GETCHARLEN(d, (code + coptable[codevalue]), dlen); } else

-#endif  /* SUPPORT_UTF8 */

-      d = code[coptable[codevalue]];

-      if (codevalue >= OP_TYPESTAR)

-        {

-        if (d == OP_ANYBYTE) return PCRE_ERROR_DFA_UITEM;

-        if (d >= OP_NOTPROP)

-          codevalue += (d == OP_EXTUNI)? OP_EXTUNI_EXTRA : OP_PROP_EXTRA;

-        }

-      }

-    else

-      {

-      dlen = 0;         /* Not strictly necessary, but compilers moan */

-      d = -1;           /* if these variables are not set. */

-      }

-

-

-    /* Now process the individual opcodes */

-

-    switch (codevalue)

-      {

-

-/* ========================================================================== */

-      /* Reached a closing bracket. If not at the end of the pattern, carry

-      on with the next opcode. Otherwise, unless we have an empty string and

-      PCRE_NOTEMPTY is set, save the match data, shifting up all previous

-      matches so we always have the longest first. */

-

-      case OP_KET:

-      case OP_KETRMIN:

-      case OP_KETRMAX:

-      if (code != end_code)

-        {

-        ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);

-        if (codevalue != OP_KET)

-          {

-          ADD_ACTIVE(state_offset - GET(code, 1), 0);

-          }

-        }

-      else if (ptr > current_subject || (md->moptions & PCRE_NOTEMPTY) == 0)

-        {

-        if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0;

-          else if (match_count > 0 && ++match_count * 2 >= offsetcount)

-            match_count = 0;

-        count = ((match_count == 0)? offsetcount : match_count * 2) - 2;

-        if (count > 0) memmove(offsets + 2, offsets, count * sizeof(int));

-        if (offsetcount >= 2)

-          {

-          offsets[0] = current_subject - start_subject;

-          offsets[1] = ptr - start_subject;

-          DPRINTF(("%.*sSet matched string = \"%.*s\"\n", rlevel*2-2, SP,

-            offsets[1] - offsets[0], current_subject));

-          }

-        if ((md->moptions & PCRE_DFA_SHORTEST) != 0)

-          {

-          DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"

-            "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel,

-            match_count, rlevel*2-2, SP));

-          return match_count;

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These opcodes add to the current list of states without looking

-      at the current character. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_ALT:

-      do { code += GET(code, 1); } while (*code == OP_ALT);

-      ADD_ACTIVE(code - start_code, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRA:

-      do

-        {

-        ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);

-        code += GET(code, 1);

-        }

-      while (*code == OP_ALT);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRAZERO:

-      case OP_BRAMINZERO:

-      ADD_ACTIVE(state_offset + 1, 0);

-      code += 1 + GET(code, 2);

-      while (*code == OP_ALT) code += GET(code, 1);

-      ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_BRANUMBER:

-      ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_CIRC:

-      if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||

-          ((ims & PCRE_MULTILINE) != 0 && ptr[-1] == NEWLINE))

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EOD:

-      if (ptr >= end_subject) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_OPT:

-      ims = code[1];

-      ADD_ACTIVE(state_offset + 2, 0);

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_SOD:

-      if (ptr == start_subject) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_SOM:

-      if (ptr == start_subject + start_offset) { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-

-/* ========================================================================== */

-      /* These opcodes inspect the next subject character, and sometimes

-      the previous one as well, but do not have an argument. The variable

-      clen contains the length of the current character and is zero if we are

-      at the end of the subject. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_ANY:

-      if (clen > 0 && (c != NEWLINE || (ims & PCRE_DOTALL) != 0))

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EODN:

-      if (clen == 0 || (c == NEWLINE && ptr + 1 == end_subject))

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_DOLL:

-      if ((md->moptions & PCRE_NOTEOL) == 0)

-        {

-        if (clen == 0 || (c == NEWLINE && (ptr + 1 == end_subject ||

-                                (ims & PCRE_MULTILINE) != 0)))

-          { ADD_ACTIVE(state_offset + 1, 0); }

-        }

-      else if (c == NEWLINE && (ims & PCRE_MULTILINE) != 0)

-        { ADD_ACTIVE(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-

-      case OP_DIGIT:

-      case OP_WHITESPACE:

-      case OP_WORDCHAR:

-      if (clen > 0 && c < 256 &&

-            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0)

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_NOT_DIGIT:

-      case OP_NOT_WHITESPACE:

-      case OP_NOT_WORDCHAR:

-      if (clen > 0 && (c >= 256 ||

-            ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0))

-        { ADD_NEW(state_offset + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_WORD_BOUNDARY:

-      case OP_NOT_WORD_BOUNDARY:

-        {

-        int left_word, right_word;

-

-        if (ptr > start_subject)

-          {

-          const uschar *temp = ptr - 1;

-#ifdef SUPPORT_UTF8

-          if (utf8) BACKCHAR(temp);

-#endif

-          GETCHARTEST(d, temp);

-          left_word = d < 256 && (ctypes[d] & ctype_word) != 0;

-          }

-        else left_word = 0;

-

-        if (clen > 0) right_word = c < 256 && (ctypes[c] & ctype_word) != 0;

-          else right_word = 0;

-

-        if ((left_word == right_word) == (codevalue == OP_NOT_WORD_BOUNDARY))

-          { ADD_ACTIVE(state_offset + 1, 0); }

-        }

-      break;

-

-

-#ifdef SUPPORT_UCP

-

-      /*-----------------------------------------------------------------*/

-      /* Check the next character by Unicode property. We will get here only

-      if the support is in the binary; otherwise a compile-time error occurs.

-      */

-

-      case OP_PROP:

-      case OP_NOTPROP:

-      if (clen > 0)

-        {

-        int rqdtype, category;

-        category = ucp_findchar(c, &chartype, &othercase);

-        rqdtype = code[1];

-        if (rqdtype >= 128)

-          {

-          if ((rqdtype - 128 == category) == (codevalue == OP_PROP))

-            { ADD_NEW(state_offset + 2, 0); }

-          }

-        else

-          {

-          if ((rqdtype == chartype) == (codevalue == OP_PROP))

-            { ADD_NEW(state_offset + 2, 0); }

-          }

-        }

-      break;

-#endif

-

-

-

-/* ========================================================================== */

-      /* These opcodes likewise inspect the subject character, but have an

-      argument that is not a data character. It is one of these opcodes:

-      OP_ANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, OP_WORDCHAR,

-      OP_NOT_WORDCHAR. The value is loaded into d. */

-

-      case OP_TYPEPLUS:

-      case OP_TYPEMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          count++;

-          ADD_NEW(state_offset, count);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPEQUERY:

-      case OP_TYPEMINQUERY:

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          ADD_NEW(state_offset + 2, 0);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPESTAR:

-      case OP_TYPEMINSTAR:

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          ADD_NEW(state_offset, 0);

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_TYPEEXACT:

-      case OP_TYPEUPTO:

-      case OP_TYPEMINUPTO:

-      if (codevalue != OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 4, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||

-            (c < 256 &&

-              (d != OP_ANY || c != '\n' || (ims & PCRE_DOTALL) != 0) &&

-              ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + 4, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These are virtual opcodes that are used when something like

-      OP_TYPEPLUS has OP_PROP, OP_NOTPROP, or OP_EXTUNI as its argument. It

-      keeps the code above fast for the other cases. The argument is in the

-      d variable. */

-

-      case OP_PROP_EXTRA + OP_TYPEPLUS:

-      case OP_PROP_EXTRA + OP_TYPEMINPLUS:

-      count = current_state->count;           /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 3, 0); }

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[2];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          { count++; ADD_NEW(state_offset, count); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEPLUS:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); }

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        count++;

-        ADD_NEW_DATA(-state_offset, count, ncount);

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PROP_EXTRA + OP_TYPEQUERY:

-      case OP_PROP_EXTRA + OP_TYPEMINQUERY:

-      count = 3;

-      goto QS1;

-

-      case OP_PROP_EXTRA + OP_TYPESTAR:

-      case OP_PROP_EXTRA + OP_TYPEMINSTAR:

-      count = 0;

-

-      QS1:

-

-      ADD_ACTIVE(state_offset + 3, 0);

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[2];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          { ADD_NEW(state_offset + count, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEQUERY:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINQUERY:

-      count = 2;

-      goto QS2;

-

-      case OP_EXTUNI_EXTRA + OP_TYPESTAR:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINSTAR:

-      count = 0;

-

-      QS2:

-

-      ADD_ACTIVE(state_offset + 2, 0);

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        ADD_NEW_DATA(-(state_offset + count), 0, ncount);

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PROP_EXTRA + OP_TYPEEXACT:

-      case OP_PROP_EXTRA + OP_TYPEUPTO:

-      case OP_PROP_EXTRA + OP_TYPEMINUPTO:

-      if (codevalue != OP_PROP_EXTRA + OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 5, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        int category = ucp_findchar(c, &chartype, &othercase);

-        int rqdtype = code[4];

-        if ((d == OP_PROP) ==

-            (rqdtype == ((rqdtype >= 128)? (category + 128) : chartype)))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + 5, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXTUNI_EXTRA + OP_TYPEEXACT:

-      case OP_EXTUNI_EXTRA + OP_TYPEUPTO:

-      case OP_EXTUNI_EXTRA + OP_TYPEMINUPTO:

-      if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT)

-        { ADD_ACTIVE(state_offset + 4, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nd;

-          int ndlen = 1;

-          GETCHARLEN(nd, nptr, ndlen);

-          if (ucp_findchar(nd, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += ndlen;

-          }

-        if (++count >= GET2(code, 1))

-          { ADD_NEW_DATA(-(state_offset + 4), 0, ncount); }

-        else

-          { ADD_NEW_DATA(-state_offset, count, ncount); }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These opcodes are followed by a character that is usually compared

-      to the current subject character; it is loaded into d. We still get

-      here even if there is no subject character, because in some cases zero

-      repetitions are permitted. */

-

-      /*-----------------------------------------------------------------*/

-      case OP_CHAR:

-      if (clen > 0 && c == d) { ADD_NEW(state_offset + dlen + 1, 0); }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_CHARNC:

-      if (clen == 0) break;

-

-#ifdef SUPPORT_UTF8

-      if (utf8)

-        {

-        if (c == d) { ADD_NEW(state_offset + dlen + 1, 0); } else

-          {

-          if (c < 128) othercase = fcc[c]; else

-

-          /* If we have Unicode property support, we can use it to test the

-          other case of the character, if there is one. The result of

-          ucp_findchar() is < 0 if the char isn't found, and othercase is

-          returned as zero if there isn't another case. */

-

-#ifdef SUPPORT_UCP

-          if (ucp_findchar(c, &chartype, &othercase) < 0)

-#endif

-            othercase = -1;

-

-          if (d == othercase) { ADD_NEW(state_offset + dlen + 1, 0); }

-          }

-        }

-      else

-#endif  /* SUPPORT_UTF8 */

-

-      /* Non-UTF-8 mode */

-        {

-        if (lcc[c] == lcc[d]) { ADD_NEW(state_offset + 2, 0); }

-        }

-      break;

-

-

-#ifdef SUPPORT_UCP

-      /*-----------------------------------------------------------------*/

-      /* This is a tricky one because it can match more than one character.

-      Find out how many characters to skip, and then set up a negative state

-      to wait for them to pass before continuing. */

-

-      case OP_EXTUNI:

-      if (clen > 0 && ucp_findchar(c, &chartype, &othercase) != ucp_M)

-        {

-        const uschar *nptr = ptr + clen;

-        int ncount = 0;

-        while (nptr < end_subject)

-          {

-          int nclen = 1;

-          GETCHARLEN(c, nptr, nclen);

-          if (ucp_findchar(c, &chartype, &othercase) != ucp_M) break;

-          ncount++;

-          nptr += nclen;

-          }

-        ADD_NEW_DATA(-(state_offset + 1), 0, ncount);

-        }

-      break;

-#endif

-

-      /*-----------------------------------------------------------------*/

-      /* Match a negated single character. This is only used for one-byte

-      characters, that is, we know that d < 256. The character we are

-      checking (c) can be multibyte. */

-

-      case OP_NOT:

-      if (clen > 0)

-        {

-        int otherd = ((ims & PCRE_CASELESS) != 0)? fcc[d] : d;

-        if (c != d && c != otherd) { ADD_NEW(state_offset + dlen + 1, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_PLUS:

-      case OP_MINPLUS:

-      case OP_NOTPLUS:

-      case OP_NOTMINPLUS:

-      count = current_state->count;  /* Already matched */

-      if (count > 0) { ADD_ACTIVE(state_offset + dlen + 1, 0); }

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims & PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(d, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { count++; ADD_NEW(state_offset, count); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_QUERY:

-      case OP_MINQUERY:

-      case OP_NOTQUERY:

-      case OP_NOTMINQUERY:

-      ADD_ACTIVE(state_offset + dlen + 1, 0);

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims && PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(c, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { ADD_NEW(state_offset + dlen + 1, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_NOTSTAR:

-      case OP_NOTMINSTAR:

-      ADD_ACTIVE(state_offset + dlen + 1, 0);

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims && PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(c, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          { ADD_NEW(state_offset, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_EXACT:

-      case OP_UPTO:

-      case OP_MINUPTO:

-      case OP_NOTEXACT:

-      case OP_NOTUPTO:

-      case OP_NOTMINUPTO:

-      if (codevalue != OP_EXACT && codevalue != OP_NOTEXACT)

-        { ADD_ACTIVE(state_offset + dlen + 3, 0); }

-      count = current_state->count;  /* Number already matched */

-      if (clen > 0)

-        {

-        int otherd = -1;

-        if ((ims & PCRE_CASELESS) != 0)

-          {

-#ifdef SUPPORT_UTF8

-          if (utf8 && c >= 128)

-            {

-#ifdef SUPPORT_UCP

-            if (ucp_findchar(d, &chartype, &otherd) < 0) otherd = -1;

-#endif  /* SUPPORT_UCP */

-            }

-          else

-#endif  /* SUPPORT_UTF8 */

-          otherd = fcc[d];

-          }

-        if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR))

-          {

-          if (++count >= GET2(code, 1))

-            { ADD_NEW(state_offset + dlen + 3, 0); }

-          else

-            { ADD_NEW(state_offset, count); }

-          }

-        }

-      break;

-

-

-/* ========================================================================== */

-      /* These are the class-handling opcodes */

-

-      case OP_CLASS:

-      case OP_NCLASS:

-      case OP_XCLASS:

-        {

-        BOOL isinclass = FALSE;

-        int next_state_offset;

-        const uschar *ecode;

-

-        /* For a simple class, there is always just a 32-byte table, and we

-        can set isinclass from it. */

-

-        if (codevalue != OP_XCLASS)

-          {

-          ecode = code + 33;

-          if (clen > 0)

-            {

-            isinclass = (c > 255)? (codevalue == OP_NCLASS) :

-              ((code[1 + c/8] & (1 << (c&7))) != 0);

-            }

-          }

-

-        /* An extended class may have a table or a list of single characters,

-        ranges, or both, and it may be positive or negative. There's a

-        function that sorts all this out. */

-

-        else

-         {

-         ecode = code + GET(code, 1);

-         if (clen > 0) isinclass = _pcre_xclass(c, code + 1 + LINK_SIZE);

-         }

-

-        /* At this point, isinclass is set for all kinds of class, and ecode

-        points to the byte after the end of the class. If there is a

-        quantifier, this is where it will be. */

-

-        next_state_offset = ecode - start_code;

-

-        switch (*ecode)

-          {

-          case OP_CRSTAR:

-          case OP_CRMINSTAR:

-          ADD_ACTIVE(next_state_offset + 1, 0);

-          if (isinclass) { ADD_NEW(state_offset, 0); }

-          break;

-

-          case OP_CRPLUS:

-          case OP_CRMINPLUS:

-          count = current_state->count;  /* Already matched */

-          if (count > 0) { ADD_ACTIVE(next_state_offset + 1, 0); }

-          if (isinclass) { count++; ADD_NEW(state_offset, count); }

-          break;

-

-          case OP_CRQUERY:

-          case OP_CRMINQUERY:

-          ADD_ACTIVE(next_state_offset + 1, 0);

-          if (isinclass) { ADD_NEW(next_state_offset + 1, 0); }

-          break;

-

-          case OP_CRRANGE:

-          case OP_CRMINRANGE:

-          count = current_state->count;  /* Already matched */

-          if (count >= GET2(ecode, 1))

-            { ADD_ACTIVE(next_state_offset + 5, 0); }

-          if (isinclass)

-            {

-            if (++count >= GET2(ecode, 3))

-              { ADD_NEW(next_state_offset + 5, 0); }

-            else

-              { ADD_NEW(state_offset, count); }

-            }

-          break;

-

-          default:

-          if (isinclass) { ADD_NEW(next_state_offset, 0); }

-          break;

-          }

-        }

-      break;

-

-/* ========================================================================== */

-      /* These are the opcodes for fancy brackets of various kinds. We have

-      to use recursion in order to handle them. */

-

-      case OP_ASSERT:

-      case OP_ASSERT_NOT:

-      case OP_ASSERTBACK:

-      case OP_ASSERTBACK_NOT:

-        {

-        int rc;

-        int local_offsets[2];

-        int local_workspace[1000];

-        const uschar *endasscode = code + GET(code, 1);

-

-        while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);

-

-        rc = internal_dfa_exec(

-          md,                                   /* static match data */

-          code,                                 /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing);                           /* pass on regex recursion */

-

-        if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK))

-            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_COND:

-        {

-        int local_offsets[1000];

-        int local_workspace[1000];

-        int condcode = code[LINK_SIZE+1];

-

-        /* The only supported version of OP_CREF is for the value 0xffff, which

-        means "test if in a recursion". */

-

-        if (condcode == OP_CREF)

-          {

-          int value = GET2(code, LINK_SIZE+2);

-          if (value != 0xffff) return PCRE_ERROR_DFA_UCOND;

-          if (recursing > 0) { ADD_ACTIVE(state_offset + LINK_SIZE + 4, 0); }

-            else { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }

-          }

-

-        /* Otherwise, the condition is an assertion */

-

-        else

-          {

-          int rc;

-          const uschar *asscode = code + LINK_SIZE + 1;

-          const uschar *endasscode = asscode + GET(asscode, 1);

-

-          while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1);

-

-          rc = internal_dfa_exec(

-            md,                                   /* fixed match data */

-            asscode,                              /* this subexpression's code */

-            ptr,                                  /* where we currently are */

-            ptr - start_subject,                  /* start offset */

-            local_offsets,                        /* offset vector */

-            sizeof(local_offsets)/sizeof(int),    /* size of same */

-            local_workspace,                      /* workspace vector */

-            sizeof(local_workspace)/sizeof(int),  /* size of same */

-            ims,                                  /* the current ims flags */

-            rlevel,                               /* function recursion level */

-            recursing);                           /* pass on regex recursion */

-

-          if ((rc >= 0) ==

-                (condcode == OP_ASSERT || condcode == OP_ASSERTBACK))

-            { ADD_ACTIVE(endasscode + LINK_SIZE + 1 - start_code, 0); }

-          else

-            { ADD_ACTIVE(state_offset + GET(code, 1) + LINK_SIZE + 1, 0); }

-          }

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_RECURSE:

-        {

-        int local_offsets[1000];

-        int local_workspace[1000];

-        int rc;

-

-        DPRINTF(("%.*sStarting regex recursion %d\n", rlevel*2-2, SP,

-          recursing + 1));

-

-        rc = internal_dfa_exec(

-          md,                                   /* fixed match data */

-          start_code + GET(code, 1),            /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing + 1);                       /* regex recurse level */

-

-        DPRINTF(("%.*sReturn from regex recursion %d: rc=%d\n", rlevel*2-2, SP,

-          recursing + 1, rc));

-

-        /* Ran out of internal offsets */

-

-        if (rc == 0) return PCRE_ERROR_DFA_RECURSE;

-

-        /* For each successful matched substring, set up the next state with a

-        count of characters to skip before trying it. Note that the count is in

-        characters, not bytes. */

-

-        if (rc > 0)

-          {

-          for (rc = rc*2 - 2; rc >= 0; rc -= 2)

-            {

-            const uschar *p = start_subject + local_offsets[rc];

-            const uschar *pp = start_subject + local_offsets[rc+1];

-            int charcount = local_offsets[rc+1] - local_offsets[rc];

-            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;

-            if (charcount > 0)

-              {

-              ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, (charcount - 1));

-              }

-            else

-              {

-              ADD_ACTIVE(state_offset + LINK_SIZE + 1, 0);

-              }

-            }

-          }

-        else if (rc != PCRE_ERROR_NOMATCH) return rc;

-        }

-      break;

-

-      /*-----------------------------------------------------------------*/

-      case OP_ONCE:

-        {

-        const uschar *endcode;

-        int local_offsets[2];

-        int local_workspace[1000];

-

-        int rc = internal_dfa_exec(

-          md,                                   /* fixed match data */

-          code,                                 /* this subexpression's code */

-          ptr,                                  /* where we currently are */

-          ptr - start_subject,                  /* start offset */

-          local_offsets,                        /* offset vector */

-          sizeof(local_offsets)/sizeof(int),    /* size of same */

-          local_workspace,                      /* workspace vector */

-          sizeof(local_workspace)/sizeof(int),  /* size of same */

-          ims,                                  /* the current ims flags */

-          rlevel,                               /* function recursion level */

-          recursing);                           /* pass on regex recursion */

-

-        if (rc >= 0)

-          {

-          const uschar *end_subpattern = code;

-          int charcount = local_offsets[1] - local_offsets[0];

-          int next_state_offset, repeat_state_offset;

-          BOOL is_repeated;

-

-          do { end_subpattern += GET(end_subpattern, 1); }

-            while (*end_subpattern == OP_ALT);

-          next_state_offset = end_subpattern - start_code + LINK_SIZE + 1;

-

-          /* If the end of this subpattern is KETRMAX or KETRMIN, we must

-          arrange for the repeat state also to be added to the relevant list.

-          Calculate the offset, or set -1 for no repeat. */

-

-          repeat_state_offset = (*end_subpattern == OP_KETRMAX ||

-                                 *end_subpattern == OP_KETRMIN)?

-            end_subpattern - start_code - GET(end_subpattern, 1) : -1;

-

-          /* If we have matched an empty string, add the next state at the

-          current character pointer. This is important so that the duplicate

-          checking kicks in, which is what breaks infinite loops that match an

-          empty string. */

-

-          if (charcount == 0)

-            {

-            ADD_ACTIVE(next_state_offset, 0);

-            }

-

-          /* Optimization: if there are no more active states, and there

-          are no new states yet set up, then skip over the subject string

-          right here, to save looping. Otherwise, set up the new state to swing

-          into action when the end of the substring is reached. */

-

-          else if (i + 1 >= active_count && new_count == 0)

-            {

-            ptr += charcount;

-            clen = 0;

-            ADD_NEW(next_state_offset, 0);

-

-            /* If we are adding a repeat state at the new character position,

-            we must fudge things so that it is the only current state.

-            Otherwise, it might be a duplicate of one we processed before, and

-            that would cause it to be skipped. */

-

-            if (repeat_state_offset >= 0)

-              {

-              next_active_state = active_states;

-              active_count = 0;

-              i = -1;

-              ADD_ACTIVE(repeat_state_offset, 0);

-              }

-            }

-          else

-            {

-            const uschar *p = start_subject + local_offsets[0];

-            const uschar *pp = start_subject + local_offsets[1];

-            while (p < pp) if ((*p++ & 0xc0) == 0x80) charcount--;

-            ADD_NEW_DATA(-next_state_offset, 0, (charcount - 1));

-            if (repeat_state_offset >= 0)

-              { ADD_NEW_DATA(-repeat_state_offset, 0, (charcount - 1)); }

-            }

-

-          }

-        else if (rc != PCRE_ERROR_NOMATCH) return rc;

-        }

-      break;

-

-

-/* ========================================================================== */

-      /* Handle callouts */

-

-      case OP_CALLOUT:

-      if (pcre_callout != NULL)

-        {

-        int rrc;

-        pcre_callout_block cb;

-        cb.version          = 1;   /* Version 1 of the callout block */

-        cb.callout_number   = code[1];

-        cb.offset_vector    = offsets;

-        cb.subject          = (char *)start_subject;

-        cb.subject_length   = end_subject - start_subject;

-        cb.start_match      = current_subject - start_subject;

-        cb.current_position = ptr - start_subject;

-        cb.pattern_position = GET(code, 2);

-        cb.next_item_length = GET(code, 2 + LINK_SIZE);

-        cb.capture_top      = 1;

-        cb.capture_last     = -1;

-        cb.callout_data     = md->callout_data;

-        if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */

-        if (rrc == 0) { ADD_ACTIVE(state_offset + 2 + 2*LINK_SIZE, 0); }

-        }

-      break;

-

-

-/* ========================================================================== */

-      default:        /* Unsupported opcode */

-      return PCRE_ERROR_DFA_UITEM;

-      }

-

-    NEXT_ACTIVE_STATE: continue;

-

-    }      /* End of loop scanning active states */

-

-  /* We have finished the processing at the current subject character. If no

-  new states have been set for the next character, we have found all the

-  matches that we are going to find. If we are at the top level and partial

-  matching has been requested, check for appropriate conditions. */

-

-  if (new_count <= 0)

-    {

-    if (match_count < 0 &&                     /* No matches found */

-        rlevel == 1 &&                         /* Top level match function */

-        (md->moptions & PCRE_PARTIAL) != 0 &&  /* Want partial matching */

-        ptr >= end_subject &&                  /* Reached end of subject */

-        ptr > current_subject)                 /* Matched non-empty string */

-      {

-      if (offsetcount >= 2)

-        {

-        offsets[0] = current_subject - start_subject;

-        offsets[1] = end_subject - start_subject;

-        }

-      match_count = PCRE_ERROR_PARTIAL;

-      }

-

-    DPRINTF(("%.*sEnd of internal_dfa_exec %d: returning %d\n"

-      "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel, match_count,

-      rlevel*2-2, SP));

-    return match_count;

-    }

-

-  /* One or more states are active for the next character. */

-

-  ptr += clen;    /* Advance to next subject character */

-  }               /* Loop to move along the subject string */

-

-/* Control never gets here, but we must keep the compiler happy. */

-

-DPRINTF(("%.*s+++ Unexpected end of internal_dfa_exec %d +++\n"

-  "%.*s---------------------\n\n", rlevel*2-2, SP, rlevel, rlevel*2-2, SP));

-return PCRE_ERROR_NOMATCH;

-}

-

-

-

-

-/*************************************************

-*    Execute a Regular Expression - DFA engine   *

-*************************************************/

-

-/* This external function applies a compiled re to a subject string using a DFA

-engine. This function calls the internal function multiple times if the pattern

-is not anchored.

-

-Arguments:

-  argument_re     points to the compiled expression

-  extra_data      points to extra data or is NULL (not currently used)

-  subject         points to the subject string

-  length          length of subject string (may contain binary zeros)

-  start_offset    where to start in the subject string

-  options         option bits

-  offsets         vector of match offsets

-  offsetcount     size of same

-  workspace       workspace vector

-  wscount         size of same

-

-Returns:          > 0 => number of match offset pairs placed in offsets

-                  = 0 => offsets overflowed; longest matches are present

-                   -1 => failed to match

-                 < -1 => some kind of unexpected problem

-*/

-

-EXPORT int

-pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,

-  const char *subject, int length, int start_offset, int options, int *offsets,

-  int offsetcount, int *workspace, int wscount)

-{

-real_pcre *re = (real_pcre *)argument_re;

-dfa_match_data match_block;

-BOOL utf8, anchored, startline, firstline;

-const uschar *current_subject, *end_subject, *lcc;

-

-pcre_study_data internal_study;

-const pcre_study_data *study = NULL;

-real_pcre internal_re;

-

-const uschar *req_byte_ptr;

-const uschar *start_bits = NULL;

-BOOL first_byte_caseless = FALSE;

-BOOL req_byte_caseless = FALSE;

-int first_byte = -1;

-int req_byte = -1;

-int req_byte2 = -1;

-

-/* Plausibility checks */

-

-if ((options & ~PUBLIC_DFA_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;

-if (re == NULL || subject == NULL || workspace == NULL ||

-   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;

-if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;

-if (wscount < 20) return PCRE_ERROR_DFA_WSSIZE;

-

-/* We need to find the pointer to any study data before we test for byte

-flipping, so we scan the extra_data block first. This may set two fields in the

-match block, so we must initialize them beforehand. However, the other fields

-in the match block must not be set until after the byte flipping. */

-

-match_block.tables = re->tables;

-match_block.callout_data = NULL;

-

-if (extra_data != NULL)

-  {

-  unsigned int flags = extra_data->flags;

-  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)

-    study = (const pcre_study_data *)extra_data->study_data;

-  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0) return PCRE_ERROR_DFA_UMLIMIT;

-  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)

-    match_block.callout_data = extra_data->callout_data;

-  if ((flags & PCRE_EXTRA_TABLES) != 0)

-    match_block.tables = extra_data->tables;

-  }

-

-/* Check that the first field in the block is the magic number. If it is not,

-test for a regex that was compiled on a host of opposite endianness. If this is

-the case, flipped values are put in internal_re and internal_study if there was

-study data too. */

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-/* Set some local values */

-

-current_subject = (const unsigned char *)subject + start_offset;

-end_subject = (const unsigned char *)subject + length;

-req_byte_ptr = current_subject - 1;

-

-utf8 = (re->options & PCRE_UTF8) != 0;

-anchored = (options & PCRE_ANCHORED) != 0 || (re->options & PCRE_ANCHORED) != 0;

-

-/* The remaining fixed data for passing around. */

-

-match_block.start_code = (const uschar *)argument_re +

-    re->name_table_offset + re->name_count * re->name_entry_size;

-match_block.start_subject = (const unsigned char *)subject;

-match_block.end_subject = end_subject;

-match_block.moptions = options;

-match_block.poptions = re->options;

-

-/* Check a UTF-8 string if required. Unfortunately there's no way of passing

-back the character offset. */

-

-#ifdef SUPPORT_UTF8

-if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)

-  {

-  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)

-    return PCRE_ERROR_BADUTF8;

-  if (start_offset > 0 && start_offset < length)

-    {

-    int tb = ((uschar *)subject)[start_offset];

-    if (tb > 127)

-      {

-      tb &= 0xc0;

-      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;

-      }

-    }

-  }

-#endif

-

-/* If the exec call supplied NULL for tables, use the inbuilt ones. This

-is a feature that makes it possible to save compiled regex and re-use them

-in other programs later. */

-

-if (match_block.tables == NULL) match_block.tables = _pcre_default_tables;

-

-/* The lower casing table and the "must be at the start of a line" flag are

-used in a loop when finding where to start. */

-

-lcc = match_block.tables + lcc_offset;

-startline = (re->options & PCRE_STARTLINE) != 0;

-firstline = (re->options & PCRE_FIRSTLINE) != 0;

-

-/* Set up the first character to match, if available. The first_byte value is

-never set for an anchored regular expression, but the anchoring may be forced

-at run time, so we have to test for anchoring. The first char may be unset for

-an unanchored pattern, of course. If there's no first char and the pattern was

-studied, there may be a bitmap of possible first characters. */

-

-if (!anchored)

-  {

-  if ((re->options & PCRE_FIRSTSET) != 0)

-    {

-    first_byte = re->first_byte & 255;

-    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)

-      first_byte = lcc[first_byte];

-    }

-  else

-    {

-    if (startline && study != NULL &&

-         (study->options & PCRE_STUDY_MAPPED) != 0)

-      start_bits = study->start_bits;

-    }

-  }

-

-/* For anchored or unanchored matches, there may be a "last known required

-character" set. */

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  req_byte = re->req_byte & 255;

-  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;

-  req_byte2 = (match_block.tables + fcc_offset)[req_byte];  /* case flipped */

-  }

-

-/* Call the main matching function, looping for a non-anchored regex after a

-failed match. Unless restarting, optimize by moving to the first match

-character if possible, when not anchored. Then unless wanting a partial match,

-check for a required later character. */

-

-for (;;)

-  {

-  int rc;

-

-  if ((options & PCRE_DFA_RESTART) == 0)

-    {

-    const uschar *save_end_subject = end_subject;

-

-    /* Advance to a unique first char if possible. If firstline is TRUE, the

-    start of the match is constrained to the first line of a multiline string.

-    Implement this by temporarily adjusting end_subject so that we stop scanning

-    at a newline. If the match fails at the newline, later code breaks this loop.

-    */

-

-    if (firstline)

-      {

-      const uschar *t = current_subject;

-      while (t < save_end_subject && *t != '\n') t++;

-      end_subject = t;

-      }

-

-    if (first_byte >= 0)

-      {

-      if (first_byte_caseless)

-        while (current_subject < end_subject &&

-               lcc[*current_subject] != first_byte)

-          current_subject++;

-      else

-        while (current_subject < end_subject && *current_subject != first_byte)

-          current_subject++;

-      }

-

-    /* Or to just after \n for a multiline match if possible */

-

-    else if (startline)

-      {

-      if (current_subject > match_block.start_subject + start_offset)

-        {

-        while (current_subject < end_subject && current_subject[-1] != NEWLINE)

-          current_subject++;

-        }

-      }

-

-    /* Or to a non-unique first char after study */

-

-    else if (start_bits != NULL)

-      {

-      while (current_subject < end_subject)

-        {

-        register unsigned int c = *current_subject;

-        if ((start_bits[c/8] & (1 << (c&7))) == 0) current_subject++;

-          else break;

-        }

-      }

-

-    /* Restore fudged end_subject */

-

-    end_subject = save_end_subject;

-    }

-

-  /* If req_byte is set, we know that that character must appear in the subject

-  for the match to succeed. If the first character is set, req_byte must be

-  later in the subject; otherwise the test starts at the match point. This

-  optimization can save a huge amount of work in patterns with nested unlimited

-  repeats that aren't going to match. Writing separate code for cased/caseless

-  versions makes it go faster, as does using an autoincrement and backing off

-  on a match.

-

-  HOWEVER: when the subject string is very, very long, searching to its end can

-  take a long time, and give bad performance on quite ordinary patterns. This

-  showed up when somebody was matching /^C/ on a 32-megabyte string... so we

-  don't do this when the string is sufficiently long.

-

-  ALSO: this processing is disabled when partial matching is requested.

-  */

-

-  if (req_byte >= 0 &&

-      end_subject - current_subject < REQ_BYTE_MAX &&

-      (options & PCRE_PARTIAL) == 0)

-    {

-    register const uschar *p = current_subject + ((first_byte >= 0)? 1 : 0);

-

-    /* We don't need to repeat the search if we haven't yet reached the

-    place we found it at last time. */

-

-    if (p > req_byte_ptr)

-      {

-      if (req_byte_caseless)

-        {

-        while (p < end_subject)

-          {

-          register int pp = *p++;

-          if (pp == req_byte || pp == req_byte2) { p--; break; }

-          }

-        }

-      else

-        {

-        while (p < end_subject)

-          {

-          if (*p++ == req_byte) { p--; break; }

-          }

-        }

-

-      /* If we can't find the required character, break the matching loop,

-      which will cause a return or PCRE_ERROR_NOMATCH. */

-

-      if (p >= end_subject) break;

-

-      /* If we have found the required character, save the point where we

-      found it, so that we don't search again next time round the loop if

-      the start hasn't passed this character yet. */

-

-      req_byte_ptr = p;

-      }

-    }

-

-  /* OK, now we can do the business */

-

-  rc = internal_dfa_exec(

-    &match_block,                              /* fixed match data */

-    match_block.start_code,                    /* this subexpression's code */

-    current_subject,                           /* where we currently are */

-    start_offset,                              /* start offset in subject */

-    offsets,                                   /* offset vector */

-    offsetcount,                               /* size of same */

-    workspace,                                 /* workspace vector */

-    wscount,                                   /* size of same */

-    re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL), /* ims flags */

-    0,                                         /* function recurse level */

-    0);                                        /* regex recurse level */

-

-  /* Anything other than "no match" means we are done, always; otherwise, carry

-  on only if not anchored. */

-

-  if (rc != PCRE_ERROR_NOMATCH || anchored) return rc;

-

-  /* Advance to the next subject character unless we are at the end of a line

-  and firstline is set. */

-

-  if (firstline && *current_subject == NEWLINE) break;

-  current_subject++;

-

-#ifdef SUPPORT_UTF8

-  if (utf8)

-    {

-    while (current_subject < end_subject && (*current_subject & 0xc0) == 0x80)

-      current_subject++;

-    }

-#endif

-

-  if (current_subject > end_subject) break;

-  }

-

-return PCRE_ERROR_NOMATCH;

-}

-

-/* End of pcre_dfa_exec.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains pcre_exec(), the externally visible function that does

-pattern matching using an NFA algorithm, trying to mimic Perl as closely as

-possible. There are also some static supporting functions. */

-

-

-

-

-/* Structure for building a chain of data that actually lives on the

-stack, for holding the values of the subject pointer at the start of each

-subpattern, so as to detect when an empty string has been matched by a

-subpattern - to break infinite loops. When NO_RECURSE is set, these blocks

-are on the heap, not on the stack. */

-

-typedef struct eptrblock {

-  struct eptrblock *epb_prev;

-  const uschar *epb_saved_eptr;

-} eptrblock;

-

-/* Flag bits for the match() function */

-

-#define match_condassert   0x01    /* Called to check a condition assertion */

-#define match_isgroup      0x02    /* Set if start of bracketed group */

-

-/* Non-error returns from the match() function. Error returns are externally

-defined PCRE_ERROR_xxx codes, which are all negative. */

-

-#define MATCH_MATCH        1

-#define MATCH_NOMATCH      0

-

-/* Maximum number of ints of offset to save on the stack for recursive calls.

-If the offset vector is bigger, malloc is used. This should be a multiple of 3,

-because the offset vector is always a multiple of 3 long. */

-

-#define REC_STACK_SAVE_MAX 30

-

-/* Min and max values for the common repeats; for the maxima, 0 => infinity */

-

-static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };

-static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };

-

-

-

-#ifdef DEBUG

-/*************************************************

-*        Debugging function to print chars       *

-*************************************************/

-

-/* Print a sequence of chars in printable format, stopping at the end of the

-subject if the requested.

-

-Arguments:

-  p           points to characters

-  length      number to print

-  is_subject  TRUE if printing from within md->start_subject

-  md          pointer to matching data block, if is_subject is TRUE

-

-Returns:     nothing

-*/

-

-static void

-pchars(const uschar *p, int length, BOOL is_subject, match_data *md)

-{

-int c;

-if (is_subject && length > md->end_subject - p) length = md->end_subject - p;

-while (length-- > 0)

-  if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);

-}

-#endif

-

-

-

-/*************************************************

-*          Match a back-reference                *

-*************************************************/

-

-/* If a back reference hasn't been set, the length that is passed is greater

-than the number of characters left in the string, so the match fails.

-

-Arguments:

-  offset      index into the offset vector

-  eptr        points into the subject

-  length      length to be matched

-  md          points to match data block

-  ims         the ims flags

-

-Returns:      TRUE if matched

-*/

-

-static BOOL

-match_ref(int offset, register const uschar *eptr, int length, match_data *md,

-  unsigned long int ims)

-{

-const uschar *p = md->start_subject + md->offset_vector[offset];

-

-#ifdef DEBUG

-if (eptr >= md->end_subject)

-  printf("matching subject <null>");

-else

-  {

-  printf("matching subject ");

-  pchars(eptr, length, TRUE, md);

-  }

-printf(" against backref ");

-pchars(p, length, FALSE, md);

-printf("\n");

-#endif

-

-/* Always fail if not enough characters left */

-

-if (length > md->end_subject - eptr) return FALSE;

-

-/* Separate the caselesss case for speed */

-

-if ((ims & PCRE_CASELESS) != 0)

-  {

-  while (length-- > 0)

-    if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE;

-  }

-else

-  { while (length-- > 0) if (*p++ != *eptr++) return FALSE; }

-

-return TRUE;

-}

-

-

-

-/***************************************************************************

-****************************************************************************

-                   RECURSION IN THE match() FUNCTION

-

-The match() function is highly recursive. Some regular expressions can cause

-it to recurse thousands of times. I was writing for Unix, so I just let it

-call itself recursively. This uses the stack for saving everything that has

-to be saved for a recursive call. On Unix, the stack can be large, and this

-works fine.

-

-It turns out that on non-Unix systems there are problems with programs that

-use a lot of stack. (This despite the fact that every last chip has oodles

-of memory these days, and techniques for extending the stack have been known

-for decades.) So....

-

-There is a fudge, triggered by defining NO_RECURSE, which avoids recursive

-calls by keeping local variables that need to be preserved in blocks of memory

-obtained from malloc instead instead of on the stack. Macros are used to

-achieve this so that the actual code doesn't look very different to what it

-always used to.

-****************************************************************************

-***************************************************************************/

-

-

-/* These versions of the macros use the stack, as normal */

-

-#ifndef NO_RECURSE

-#define REGISTER register

-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) rx = match(ra,rb,rc,rd,re,rf,rg)

-#define RRETURN(ra) return ra

-#else

-

-

-/* These versions of the macros manage a private stack on the heap. Note

-that the rd argument of RMATCH isn't actually used. It's the md argument of

-match(), which never changes. */

-

-#define REGISTER

-

-#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg)\

-  {\

-  heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\

-  if (setjmp(frame->Xwhere) == 0)\

-    {\

-    newframe->Xeptr = ra;\

-    newframe->Xecode = rb;\

-    newframe->Xoffset_top = rc;\

-    newframe->Xims = re;\

-    newframe->Xeptrb = rf;\

-    newframe->Xflags = rg;\

-    newframe->Xprevframe = frame;\

-    frame = newframe;\

-    DPRINTF(("restarting from line %d\n", __LINE__));\

-    goto HEAP_RECURSE;\

-    }\

-  else\

-    {\

-    DPRINTF(("longjumped back to line %d\n", __LINE__));\

-    frame = md->thisframe;\

-    rx = frame->Xresult;\

-    }\

-  }

-

-#define RRETURN(ra)\

-  {\

-  heapframe *newframe = frame;\

-  frame = newframe->Xprevframe;\

-  (pcre_stack_free)(newframe);\

-  if (frame != NULL)\

-    {\

-    frame->Xresult = ra;\

-    md->thisframe = frame;\

-    longjmp(frame->Xwhere, 1);\

-    }\

-  return ra;\

-  }

-

-

-/* Structure for remembering the local variables in a private frame */

-

-typedef struct heapframe {

-  struct heapframe *Xprevframe;

-

-  /* Function arguments that may change */

-

-  const uschar *Xeptr;

-  const uschar *Xecode;

-  int Xoffset_top;

-  long int Xims;

-  eptrblock *Xeptrb;

-  int Xflags;

-

-  /* Function local variables */

-

-  const uschar *Xcallpat;

-  const uschar *Xcharptr;

-  const uschar *Xdata;

-  const uschar *Xnext;

-  const uschar *Xpp;

-  const uschar *Xprev;

-  const uschar *Xsaved_eptr;

-

-  recursion_info Xnew_recursive;

-

-  BOOL Xcur_is_word;

-  BOOL Xcondition;

-  BOOL Xminimize;

-  BOOL Xprev_is_word;

-

-  unsigned long int Xoriginal_ims;

-

-#ifdef SUPPORT_UCP

-  int Xprop_type;

-  int Xprop_fail_result;

-  int Xprop_category;

-  int Xprop_chartype;

-  int Xprop_othercase;

-  int Xprop_test_against;

-  int *Xprop_test_variable;

-#endif

-

-  int Xctype;

-  int Xfc;

-  int Xfi;

-  int Xlength;

-  int Xmax;

-  int Xmin;

-  int Xnumber;

-  int Xoffset;

-  int Xop;

-  int Xsave_capture_last;

-  int Xsave_offset1, Xsave_offset2, Xsave_offset3;

-  int Xstacksave[REC_STACK_SAVE_MAX];

-

-  eptrblock Xnewptrb;

-

-  /* Place to pass back result, and where to jump back to */

-

-  int  Xresult;

-  jmp_buf Xwhere;

-

-} heapframe;

-

-#endif

-

-

-/***************************************************************************

-***************************************************************************/

-

-

-

-/*************************************************

-*         Match from current position            *

-*************************************************/

-

-/* On entry ecode points to the first opcode, and eptr to the first character

-in the subject string, while eptrb holds the value of eptr at the start of the

-last bracketed group - used for breaking infinite loops matching zero-length

-strings. This function is called recursively in many circumstances. Whenever it

-returns a negative (error) response, the outer incarnation must also return the

-same response.

-

-Performance note: It might be tempting to extract commonly used fields from the

-md structure (e.g. utf8, end_subject) into individual variables to improve

-performance. Tests using gcc on a SPARC disproved this; in the first case, it

-made performance worse.

-

-Arguments:

-   eptr        pointer in subject

-   ecode       position in code

-   offset_top  current top pointer

-   md          pointer to "static" info for the match

-   ims         current /i, /m, and /s options

-   eptrb       pointer to chain of blocks containing eptr at start of

-                 brackets - for testing for empty matches

-   flags       can contain

-                 match_condassert - this is an assertion condition

-                 match_isgroup - this is the start of a bracketed group

-

-Returns:       MATCH_MATCH if matched            )  these values are >= 0

-               MATCH_NOMATCH if failed to match  )

-               a negative PCRE_ERROR_xxx value if aborted by an error condition

-                 (e.g. stopped by recursion limit)

-*/

-

-static int

-match(REGISTER const uschar *eptr, REGISTER const uschar *ecode,

-  int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,

-  int flags)

-{

-/* These variables do not need to be preserved over recursion in this function,

-so they can be ordinary variables in all cases. Mark them with "register"

-because they are used a lot in loops. */

-

-register int  rrc;    /* Returns from recursive calls */

-register int  i;      /* Used for loops not involving calls to RMATCH() */

-register int  c;      /* Character values not kept over RMATCH() calls */

-register BOOL utf8;   /* Local copy of UTF-8 flag for speed */

-

-/* When recursion is not being used, all "local" variables that have to be

-preserved over calls to RMATCH() are part of a "frame" which is obtained from

-heap storage. Set up the top-level frame here; others are obtained from the

-heap whenever RMATCH() does a "recursion". See the macro definitions above. */

-

-#ifdef NO_RECURSE

-heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));

-frame->Xprevframe = NULL;            /* Marks the top level */

-

-/* Copy in the original argument variables */

-

-frame->Xeptr = eptr;

-frame->Xecode = ecode;

-frame->Xoffset_top = offset_top;

-frame->Xims = ims;

-frame->Xeptrb = eptrb;

-frame->Xflags = flags;

-

-/* This is where control jumps back to to effect "recursion" */

-

-HEAP_RECURSE:

-

-/* Macros make the argument variables come from the current frame */

-

-#define eptr               frame->Xeptr

-#define ecode              frame->Xecode

-#define offset_top         frame->Xoffset_top

-#define ims                frame->Xims

-#define eptrb              frame->Xeptrb

-#define flags              frame->Xflags

-

-/* Ditto for the local variables */

-

-#ifdef SUPPORT_UTF8

-#define charptr            frame->Xcharptr

-#endif

-#define callpat            frame->Xcallpat

-#define data               frame->Xdata

-#define next               frame->Xnext

-#define pp                 frame->Xpp

-#define prev               frame->Xprev

-#define saved_eptr         frame->Xsaved_eptr

-

-#define new_recursive      frame->Xnew_recursive

-

-#define cur_is_word        frame->Xcur_is_word

-#define condition          frame->Xcondition

-#define minimize           frame->Xminimize

-#define prev_is_word       frame->Xprev_is_word

-

-#define original_ims       frame->Xoriginal_ims

-

-#ifdef SUPPORT_UCP

-#define prop_type          frame->Xprop_type

-#define prop_fail_result   frame->Xprop_fail_result

-#define prop_category      frame->Xprop_category

-#define prop_chartype      frame->Xprop_chartype

-#define prop_othercase     frame->Xprop_othercase

-#define prop_test_against  frame->Xprop_test_against

-#define prop_test_variable frame->Xprop_test_variable

-#endif

-

-#define ctype              frame->Xctype

-#define fc                 frame->Xfc

-#define fi                 frame->Xfi

-#define length             frame->Xlength

-#define max                frame->Xmax

-#define min                frame->Xmin

-#define number             frame->Xnumber

-#define offset             frame->Xoffset

-#define op                 frame->Xop

-#define save_capture_last  frame->Xsave_capture_last

-#define save_offset1       frame->Xsave_offset1

-#define save_offset2       frame->Xsave_offset2

-#define save_offset3       frame->Xsave_offset3

-#define stacksave          frame->Xstacksave

-

-#define newptrb            frame->Xnewptrb

-

-/* When recursion is being used, local variables are allocated on the stack and

-get preserved during recursion in the normal way. In this environment, fi and

-i, and fc and c, can be the same variables. */

-

-#else

-#define fi i

-#define fc c

-

-

-#ifdef SUPPORT_UTF8                /* Many of these variables are used ony */

-const uschar *charptr;             /* small blocks of the code. My normal  */

-#endif                             /* style of coding would have declared  */

-const uschar *callpat;             /* them within each of those blocks.    */

-const uschar *data;                /* However, in order to accommodate the */

-const uschar *next;                /* version of this code that uses an    */

-const uschar *pp;                  /* external "stack" implemented on the  */

-const uschar *prev;                /* heap, it is easier to declare them   */

-const uschar *saved_eptr;          /* all here, so the declarations can    */

-                                   /* be cut out in a block. The only      */

-recursion_info new_recursive;      /* declarations within blocks below are */

-                                   /* for variables that do not have to    */

-BOOL cur_is_word;                  /* be preserved over a recursive call   */

-BOOL condition;                    /* to RMATCH().                         */

-BOOL minimize;

-BOOL prev_is_word;

-

-unsigned long int original_ims;

-

-#ifdef SUPPORT_UCP

-int prop_type;

-int prop_fail_result;

-int prop_category;

-int prop_chartype;

-int prop_othercase;

-int prop_test_against;

-int *prop_test_variable;

-#endif

-

-int ctype;

-int length;

-int max;

-int min;

-int number;

-int offset;

-int op;

-int save_capture_last;

-int save_offset1, save_offset2, save_offset3;

-int stacksave[REC_STACK_SAVE_MAX];

-

-eptrblock newptrb;

-#endif

-

-/* These statements are here to stop the compiler complaining about unitialized

-variables. */

-

-#ifdef SUPPORT_UCP

-prop_fail_result = 0;

-prop_test_against = 0;

-prop_test_variable = NULL;

-#endif

-

-/* OK, now we can get on with the real code of the function. Recursion is

-specified by the macros RMATCH and RRETURN. When NO_RECURSE is *not* defined,

-these just turn into a recursive call to match() and a "return", respectively.

-However, RMATCH isn't like a function call because it's quite a complicated

-macro. It has to be used in one particular way. This shouldn't, however, impact

-performance when true recursion is being used. */

-

-if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);

-

-original_ims = ims;    /* Save for resetting on ')' */

-utf8 = md->utf8;       /* Local copy of the flag */

-

-/* At the start of a bracketed group, add the current subject pointer to the

-stack of such pointers, to be re-instated at the end of the group when we hit

-the closing ket. When match() is called in other circumstances, we don't add to

-this stack. */

-

-if ((flags & match_isgroup) != 0)

-  {

-  newptrb.epb_prev = eptrb;

-  newptrb.epb_saved_eptr = eptr;

-  eptrb = &newptrb;

-  }

-

-/* Now start processing the operations. */

-

-for (;;)

-  {

-  op = *ecode;

-  minimize = FALSE;

-

-  /* For partial matching, remember if we ever hit the end of the subject after

-  matching at least one subject character. */

-

-  if (md->partial &&

-      eptr >= md->end_subject &&

-      eptr > md->start_match)

-    md->hitend = TRUE;

-

-  /* Opening capturing bracket. If there is space in the offset vector, save

-  the current subject position in the working slot at the top of the vector. We

-  mustn't change the current values of the data slot, because they may be set

-  from a previous iteration of this group, and be referred to by a reference

-  inside the group.

-

-  If the bracket fails to match, we need to restore this value and also the

-  values of the final offsets, in case they were set by a previous iteration of

-  the same bracket.

-

-  If there isn't enough space in the offset vector, treat this as if it were a

-  non-capturing bracket. Don't worry about setting the flag for the error case

-  here; that is handled in the code for KET. */

-

-  if (op > OP_BRA)

-    {

-    number = op - OP_BRA;

-

-    /* For extended extraction brackets (large number), we have to fish out the

-    number from a dummy opcode at the start. */

-

-    if (number > EXTRACT_BASIC_MAX)

-      number = GET2(ecode, 2+LINK_SIZE);

-    offset = number << 1;

-

-#ifdef DEBUG

-    printf("start bracket %d subject=", number);

-    pchars(eptr, 16, TRUE, md);

-    printf("\n");

-#endif

-

-    if (offset < md->offset_max)

-      {

-      save_offset1 = md->offset_vector[offset];

-      save_offset2 = md->offset_vector[offset+1];

-      save_offset3 = md->offset_vector[md->offset_end - number];

-      save_capture_last = md->capture_last;

-

-      DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));

-      md->offset_vector[md->offset_end - number] = eptr - md->start_subject;

-

-      do

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-          match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        md->capture_last = save_capture_last;

-        ecode += GET(ecode, 1);

-        }

-      while (*ecode == OP_ALT);

-

-      DPRINTF(("bracket %d failed\n", number));

-

-      md->offset_vector[offset] = save_offset1;

-      md->offset_vector[offset+1] = save_offset2;

-      md->offset_vector[md->offset_end - number] = save_offset3;

-

-      RRETURN(MATCH_NOMATCH);

-      }

-

-    /* Insufficient room for saving captured contents */

-

-    else op = OP_BRA;

-    }

-

-  /* Other types of node can be handled by a switch */

-

-  switch(op)

-    {

-    case OP_BRA:     /* Non-capturing bracket: optimized */

-    DPRINTF(("start bracket 0\n"));

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode, 1);

-      }

-    while (*ecode == OP_ALT);

-    DPRINTF(("bracket 0 failed\n"));

-    RRETURN(MATCH_NOMATCH);

-

-    /* Conditional group: compilation checked that there are no more than

-    two branches. If the condition is false, skipping the first branch takes us

-    past the end if there is only one branch, but that's OK because that is

-    exactly what going to the ket would do. */

-

-    case OP_COND:

-    if (ecode[LINK_SIZE+1] == OP_CREF) /* Condition extract or recurse test */

-      {

-      offset = GET2(ecode, LINK_SIZE+2) << 1;  /* Doubled ref number */

-      condition = (offset == CREF_RECURSE * 2)?

-        (md->recursive != NULL) :

-        (offset < offset_top && md->offset_vector[offset] >= 0);

-      RMATCH(rrc, eptr, ecode + (condition?

-        (LINK_SIZE + 4) : (LINK_SIZE + 1 + GET(ecode, 1))),

-        offset_top, md, ims, eptrb, match_isgroup);

-      RRETURN(rrc);

-      }

-

-    /* The condition is an assertion. Call match() to evaluate it - setting

-    the final argument TRUE causes it to stop at the end of an assertion. */

-

-    else

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-          match_condassert | match_isgroup);

-      if (rrc == MATCH_MATCH)

-        {

-        ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE+2);

-        while (*ecode == OP_ALT) ecode += GET(ecode, 1);

-        }

-      else if (rrc != MATCH_NOMATCH)

-        {

-        RRETURN(rrc);         /* Need braces because of following else */

-        }

-      else ecode += GET(ecode, 1);

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      RRETURN(rrc);

-      }

-    /* Control never reaches here */

-

-    /* Skip over conditional reference or large extraction number data if

-    encountered. */

-

-    case OP_CREF:

-    case OP_BRANUMBER:

-    ecode += 3;

-    break;

-

-    /* End of the pattern. If we are in a recursion, we should restore the

-    offsets appropriately and continue from after the call. */

-

-    case OP_END:

-    if (md->recursive != NULL && md->recursive->group_num == 0)

-      {

-      recursion_info *rec = md->recursive;

-      DPRINTF(("Hit the end in a (?0) recursion\n"));

-      md->recursive = rec->prevrec;

-      memmove(md->offset_vector, rec->offset_save,

-        rec->saved_max * sizeof(int));

-      md->start_match = rec->save_start;

-      ims = original_ims;

-      ecode = rec->after_call;

-      break;

-      }

-

-    /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty

-    string - backtracking will then try other alternatives, if any. */

-

-    if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH);

-    md->end_match_ptr = eptr;          /* Record where we ended */

-    md->end_offset_top = offset_top;   /* and how many extracts were taken */

-    RRETURN(MATCH_MATCH);

-

-    /* Change option settings */

-

-    case OP_OPT:

-    ims = ecode[1];

-    ecode += 2;

-    DPRINTF(("ims set to %02lx\n", ims));

-    break;

-

-    /* Assertion brackets. Check the alternative branches in turn - the

-    matching won't pass the KET for an assertion. If any one branch matches,

-    the assertion is true. Lookbehind assertions have an OP_REVERSE item at the

-    start of each branch to move the current point backwards, so the code at

-    this level is identical to the lookahead case. */

-

-    case OP_ASSERT:

-    case OP_ASSERTBACK:

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-        match_isgroup);

-      if (rrc == MATCH_MATCH) break;

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode, 1);

-      }

-    while (*ecode == OP_ALT);

-    if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);

-

-    /* If checking an assertion for a condition, return MATCH_MATCH. */

-

-    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);

-

-    /* Continue from after the assertion, updating the offsets high water

-    mark, since extracts may have been taken during the assertion. */

-

-    do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-    ecode += 1 + LINK_SIZE;

-    offset_top = md->end_offset_top;

-    continue;

-

-    /* Negative assertion: all branches must fail to match */

-

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK_NOT:

-    do

-      {

-      RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,

-        match_isgroup);

-      if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode += GET(ecode,1);

-      }

-    while (*ecode == OP_ALT);

-

-    if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH);

-

-    ecode += 1 + LINK_SIZE;

-    continue;

-

-    /* Move the subject pointer back. This occurs only at the start of

-    each branch of a lookbehind assertion. If we are too close to the start to

-    move back, this match function fails. When working with UTF-8 we move

-    back a number of characters, not bytes. */

-

-    case OP_REVERSE:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      c = GET(ecode,1);

-      for (i = 0; i < c; i++)

-        {

-        eptr--;

-        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);

-        BACKCHAR(eptr)

-        }

-      }

-    else

-#endif

-

-    /* No UTF-8 support, or not in UTF-8 mode: count is byte count */

-

-      {

-      eptr -= GET(ecode,1);

-      if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);

-      }

-

-    /* Skip to next op code */

-

-    ecode += 1 + LINK_SIZE;

-    break;

-

-    /* The callout item calls an external function, if one is provided, passing

-    details of the match so far. This is mainly for debugging, though the

-    function is able to force a failure. */

-

-    case OP_CALLOUT:

-    if (pcre_callout != NULL)

-      {

-      pcre_callout_block cb;

-      cb.version          = 1;   /* Version 1 of the callout block */

-      cb.callout_number   = ecode[1];

-      cb.offset_vector    = md->offset_vector;

-      cb.subject          = (const char *)md->start_subject;

-      cb.subject_length   = md->end_subject - md->start_subject;

-      cb.start_match      = md->start_match - md->start_subject;

-      cb.current_position = eptr - md->start_subject;

-      cb.pattern_position = GET(ecode, 2);

-      cb.next_item_length = GET(ecode, 2 + LINK_SIZE);

-      cb.capture_top      = offset_top/2;

-      cb.capture_last     = md->capture_last;

-      cb.callout_data     = md->callout_data;

-      if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);

-      if (rrc < 0) RRETURN(rrc);

-      }

-    ecode += 2 + 2*LINK_SIZE;

-    break;

-

-    /* Recursion either matches the current regex, or some subexpression. The

-    offset data is the offset to the starting bracket from the start of the

-    whole pattern. (This is so that it works from duplicated subpatterns.)

-

-    If there are any capturing brackets started but not finished, we have to

-    save their starting points and reinstate them after the recursion. However,

-    we don't know how many such there are (offset_top records the completed

-    total) so we just have to save all the potential data. There may be up to

-    65535 such values, which is too large to put on the stack, but using malloc

-    for small numbers seems expensive. As a compromise, the stack is used when

-    there are no more than REC_STACK_SAVE_MAX values to store; otherwise malloc

-    is used. A problem is what to do if the malloc fails ... there is no way of

-    returning to the top level with an error. Save the top REC_STACK_SAVE_MAX

-    values on the stack, and accept that the rest may be wrong.

-

-    There are also other values that have to be saved. We use a chained

-    sequence of blocks that actually live on the stack. Thanks to Robin Houston

-    for the original version of this logic. */

-

-    case OP_RECURSE:

-      {

-      callpat = md->start_code + GET(ecode, 1);

-      new_recursive.group_num = *callpat - OP_BRA;

-

-      /* For extended extraction brackets (large number), we have to fish out

-      the number from a dummy opcode at the start. */

-

-      if (new_recursive.group_num > EXTRACT_BASIC_MAX)

-        new_recursive.group_num = GET2(callpat, 2+LINK_SIZE);

-

-      /* Add to "recursing stack" */

-

-      new_recursive.prevrec = md->recursive;

-      md->recursive = &new_recursive;

-

-      /* Find where to continue from afterwards */

-

-      ecode += 1 + LINK_SIZE;

-      new_recursive.after_call = ecode;

-

-      /* Now save the offset data. */

-

-      new_recursive.saved_max = md->offset_end;

-      if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)

-        new_recursive.offset_save = stacksave;

-      else

-        {

-        new_recursive.offset_save =

-          (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));

-        if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);

-        }

-

-      memcpy(new_recursive.offset_save, md->offset_vector,

-            new_recursive.saved_max * sizeof(int));

-      new_recursive.save_start = md->start_match;

-      md->start_match = eptr;

-

-      /* OK, now we can do the recursion. For each top-level alternative we

-      restore the offset and recursion data. */

-

-      DPRINTF(("Recursing into group %d\n", new_recursive.group_num));

-      do

-        {

-        RMATCH(rrc, eptr, callpat + 1 + LINK_SIZE, offset_top, md, ims,

-            eptrb, match_isgroup);

-        if (rrc == MATCH_MATCH)

-          {

-          md->recursive = new_recursive.prevrec;

-          if (new_recursive.offset_save != stacksave)

-            (pcre_free)(new_recursive.offset_save);

-          RRETURN(MATCH_MATCH);

-          }

-        else if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-

-        md->recursive = &new_recursive;

-        memcpy(md->offset_vector, new_recursive.offset_save,

-            new_recursive.saved_max * sizeof(int));

-        callpat += GET(callpat, 1);

-        }

-      while (*callpat == OP_ALT);

-

-      DPRINTF(("Recursion didn't match\n"));

-      md->recursive = new_recursive.prevrec;

-      if (new_recursive.offset_save != stacksave)

-        (pcre_free)(new_recursive.offset_save);

-      RRETURN(MATCH_NOMATCH);

-      }

-    /* Control never reaches here */

-

-    /* "Once" brackets are like assertion brackets except that after a match,

-    the point in the subject string is not moved back. Thus there can never be

-    a move back into the brackets. Friedl calls these "atomic" subpatterns.

-    Check the alternative branches in turn - the matching won't pass the KET

-    for this kind of subpattern. If any one branch matches, we carry on as at

-    the end of a normal bracket, leaving the subject pointer. */

-

-    case OP_ONCE:

-      {

-      prev = ecode;

-      saved_eptr = eptr;

-

-      do

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims,

-          eptrb, match_isgroup);

-        if (rrc == MATCH_MATCH) break;

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        ecode += GET(ecode,1);

-        }

-      while (*ecode == OP_ALT);

-

-      /* If hit the end of the group (which could be repeated), fail */

-

-      if (*ecode != OP_ONCE && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);

-

-      /* Continue as from after the assertion, updating the offsets high water

-      mark, since extracts may have been taken. */

-

-      do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-

-      offset_top = md->end_offset_top;

-      eptr = md->end_match_ptr;

-

-      /* For a non-repeating ket, just continue at this level. This also

-      happens for a repeating ket if no characters were matched in the group.

-      This is the forcible breaking of infinite loops as implemented in Perl

-      5.005. If there is an options reset, it will get obeyed in the normal

-      course of events. */

-

-      if (*ecode == OP_KET || eptr == saved_eptr)

-        {

-        ecode += 1+LINK_SIZE;

-        break;

-        }

-

-      /* The repeating kets try the rest of the pattern or restart from the

-      preceding bracket, in the appropriate order. We need to reset any options

-      that changed within the bracket before re-running it, so check the next

-      opcode. */

-

-      if (ecode[1+LINK_SIZE] == OP_OPT)

-        {

-        ims = (ims & ~PCRE_IMS) | ecode[4];

-        DPRINTF(("ims set to %02lx at group repeat\n", ims));

-        }

-

-      if (*ecode == OP_KETRMIN)

-        {

-        RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      else  /* OP_KETRMAX */

-        {

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      }

-    RRETURN(MATCH_NOMATCH);

-

-    /* An alternation is the end of a branch; scan along to find the end of the

-    bracketed group and go to there. */

-

-    case OP_ALT:

-    do ecode += GET(ecode,1); while (*ecode == OP_ALT);

-    break;

-

-    /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating

-    that it may occur zero times. It may repeat infinitely, or not at all -

-    i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper

-    repeat limits are compiled as a number of copies, with the optional ones

-    preceded by BRAZERO or BRAMINZERO. */

-

-    case OP_BRAZERO:

-      {

-      next = ecode+1;

-      RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      do next += GET(next,1); while (*next == OP_ALT);

-      ecode = next + 1+LINK_SIZE;

-      }

-    break;

-

-    case OP_BRAMINZERO:

-      {

-      next = ecode+1;

-      do next += GET(next,1); while (*next == OP_ALT);

-      RMATCH(rrc, eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb,

-        match_isgroup);

-      if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-      ecode++;

-      }

-    break;

-

-    /* End of a group, repeated or non-repeating. If we are at the end of

-    an assertion "group", stop matching and return MATCH_MATCH, but record the

-    current high water mark for use by positive assertions. Do this also

-    for the "once" (not-backup up) groups. */

-

-    case OP_KET:

-    case OP_KETRMIN:

-    case OP_KETRMAX:

-      {

-      prev = ecode - GET(ecode, 1);

-      saved_eptr = eptrb->epb_saved_eptr;

-

-      /* Back up the stack of bracket start pointers. */

-

-      eptrb = eptrb->epb_prev;

-

-      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||

-          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||

-          *prev == OP_ONCE)

-        {

-        md->end_match_ptr = eptr;      /* For ONCE */

-        md->end_offset_top = offset_top;

-        RRETURN(MATCH_MATCH);

-        }

-

-      /* In all other cases except a conditional group we have to check the

-      group number back at the start and if necessary complete handling an

-      extraction by setting the offsets and bumping the high water mark. */

-

-      if (*prev != OP_COND)

-        {

-        number = *prev - OP_BRA;

-

-        /* For extended extraction brackets (large number), we have to fish out

-        the number from a dummy opcode at the start. */

-

-        if (number > EXTRACT_BASIC_MAX) number = GET2(prev, 2+LINK_SIZE);

-        offset = number << 1;

-

-#ifdef DEBUG

-        printf("end bracket %d", number);

-        printf("\n");

-#endif

-

-        /* Test for a numbered group. This includes groups called as a result

-        of recursion. Note that whole-pattern recursion is coded as a recurse

-        into group 0, so it won't be picked up here. Instead, we catch it when

-        the OP_END is reached. */

-

-        if (number > 0)

-          {

-          md->capture_last = number;

-          if (offset >= md->offset_max) md->offset_overflow = TRUE; else

-            {

-            md->offset_vector[offset] =

-              md->offset_vector[md->offset_end - number];

-            md->offset_vector[offset+1] = eptr - md->start_subject;

-            if (offset_top <= offset) offset_top = offset + 2;

-            }

-

-          /* Handle a recursively called group. Restore the offsets

-          appropriately and continue from after the call. */

-

-          if (md->recursive != NULL && md->recursive->group_num == number)

-            {

-            recursion_info *rec = md->recursive;

-            DPRINTF(("Recursion (%d) succeeded - continuing\n", number));

-            md->recursive = rec->prevrec;

-            md->start_match = rec->save_start;

-            memcpy(md->offset_vector, rec->offset_save,

-              rec->saved_max * sizeof(int));

-            ecode = rec->after_call;

-            ims = original_ims;

-            break;

-            }

-          }

-        }

-

-      /* Reset the value of the ims flags, in case they got changed during

-      the group. */

-

-      ims = original_ims;

-      DPRINTF(("ims reset to %02lx\n", ims));

-

-      /* For a non-repeating ket, just continue at this level. This also

-      happens for a repeating ket if no characters were matched in the group.

-      This is the forcible breaking of infinite loops as implemented in Perl

-      5.005. If there is an options reset, it will get obeyed in the normal

-      course of events. */

-

-      if (*ecode == OP_KET || eptr == saved_eptr)

-        {

-        ecode += 1 + LINK_SIZE;

-        break;

-        }

-

-      /* The repeating kets try the rest of the pattern or restart from the

-      preceding bracket, in the appropriate order. */

-

-      if (*ecode == OP_KETRMIN)

-        {

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      else  /* OP_KETRMAX */

-        {

-        RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_isgroup);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0);

-        if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-        }

-      }

-

-    RRETURN(MATCH_NOMATCH);

-

-    /* Start of subject unless notbol, or after internal newline if multiline */

-

-    case OP_CIRC:

-    if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);

-    if ((ims & PCRE_MULTILINE) != 0)

-      {

-      if (eptr != md->start_subject && eptr[-1] != NEWLINE)

-        RRETURN(MATCH_NOMATCH);

-      ecode++;

-      break;

-      }

-    /* ... else fall through */

-

-    /* Start of subject assertion */

-

-    case OP_SOD:

-    if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Start of match assertion */

-

-    case OP_SOM:

-    if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Assert before internal newline if multiline, or before a terminating

-    newline unless endonly is set, else end of subject unless noteol is set. */

-

-    case OP_DOLL:

-    if ((ims & PCRE_MULTILINE) != 0)

-      {

-      if (eptr < md->end_subject)

-        { if (*eptr != NEWLINE) RRETURN(MATCH_NOMATCH); }

-      else

-        { if (md->noteol) RRETURN(MATCH_NOMATCH); }

-      ecode++;

-      break;

-      }

-    else

-      {

-      if (md->noteol) RRETURN(MATCH_NOMATCH);

-      if (!md->endonly)

-        {

-        if (eptr < md->end_subject - 1 ||

-           (eptr == md->end_subject - 1 && *eptr != NEWLINE))

-          RRETURN(MATCH_NOMATCH);

-        ecode++;

-        break;

-        }

-      }

-    /* ... else fall through */

-

-    /* End of subject assertion (\z) */

-

-    case OP_EOD:

-    if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* End of subject or ending \n assertion (\Z) */

-

-    case OP_EODN:

-    if (eptr < md->end_subject - 1 ||

-       (eptr == md->end_subject - 1 && *eptr != NEWLINE)) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    /* Word boundary assertions */

-

-    case OP_NOT_WORD_BOUNDARY:

-    case OP_WORD_BOUNDARY:

-      {

-

-      /* Find out if the previous and current characters are "word" characters.

-      It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to

-      be "non-word" characters. */

-

-#ifdef SUPPORT_UTF8

-      if (utf8)

-        {

-        if (eptr == md->start_subject) prev_is_word = FALSE; else

-          {

-          const uschar *lastptr = eptr - 1;

-          while((*lastptr & 0xc0) == 0x80) lastptr--;

-          GETCHAR(c, lastptr);

-          prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;

-          }

-        if (eptr >= md->end_subject) cur_is_word = FALSE; else

-          {

-          GETCHAR(c, eptr);

-          cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;

-          }

-        }

-      else

-#endif

-

-      /* More streamlined when not in UTF-8 mode */

-

-        {

-        prev_is_word = (eptr != md->start_subject) &&

-          ((md->ctypes[eptr[-1]] & ctype_word) != 0);

-        cur_is_word = (eptr < md->end_subject) &&

-          ((md->ctypes[*eptr] & ctype_word) != 0);

-        }

-

-      /* Now see if the situation is what we want */

-

-      if ((*ecode++ == OP_WORD_BOUNDARY)?

-           cur_is_word == prev_is_word : cur_is_word != prev_is_word)

-        RRETURN(MATCH_NOMATCH);

-      }

-    break;

-

-    /* Match a single character type; inline for speed */

-

-    case OP_ANY:

-    if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == NEWLINE)

-      RRETURN(MATCH_NOMATCH);

-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-#endif

-    ecode++;

-    break;

-

-    /* Match a single byte, even in UTF-8 mode. This opcode really does match

-    any byte, even newline, independent of the setting of PCRE_DOTALL. */

-

-    case OP_ANYBYTE:

-    if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_DIGIT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_digit) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_DIGIT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_digit) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_WHITESPACE:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_space) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_WHITESPACE:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_space) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_NOT_WORDCHAR:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c < 256 &&

-#endif

-       (md->ctypes[c] & ctype_word) != 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-    case OP_WORDCHAR:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-    if (

-#ifdef SUPPORT_UTF8

-       c >= 256 ||

-#endif

-       (md->ctypes[c] & ctype_word) == 0

-       )

-      RRETURN(MATCH_NOMATCH);

-    ecode++;

-    break;

-

-#ifdef SUPPORT_UCP

-    /* Check the next character by Unicode property. We will get here only

-    if the support is in the binary; otherwise a compile-time error occurs. */

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-      {

-      int chartype, rqdtype;

-      int othercase;

-      int category = ucp_findchar(c, &chartype, &othercase);

-

-      rqdtype = *(++ecode);

-      ecode++;

-

-      if (rqdtype >= 128)

-        {

-        if ((rqdtype - 128 != category) == (op == OP_PROP))

-          RRETURN(MATCH_NOMATCH);

-        }

-      else

-        {

-        if ((rqdtype != chartype) == (op == OP_PROP))

-          RRETURN(MATCH_NOMATCH);

-        }

-      }

-    break;

-

-    /* Match an extended Unicode sequence. We will get here only if the support

-    is in the binary; otherwise a compile-time error occurs. */

-

-    case OP_EXTUNI:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    GETCHARINCTEST(c, eptr);

-      {

-      int chartype;

-      int othercase;

-      int category = ucp_findchar(c, &chartype, &othercase);

-      if (category == ucp_M) RRETURN(MATCH_NOMATCH);

-      while (eptr < md->end_subject)

-        {

-        int len = 1;

-        if (!utf8) c = *eptr; else

-          {

-          GETCHARLEN(c, eptr, len);

-          }

-        category = ucp_findchar(c, &chartype, &othercase);

-        if (category != ucp_M) break;

-        eptr += len;

-        }

-      }

-    ecode++;

-    break;

-#endif

-

-

-    /* Match a back reference, possibly repeatedly. Look past the end of the

-    item to see if there is repeat information following. The code is similar

-    to that for character classes, but repeated for efficiency. Then obey

-    similar code to character type repeats - written out again for speed.

-    However, if the referenced string is the empty string, always treat

-    it as matched, any number of times (otherwise there could be infinite

-    loops). */

-

-    case OP_REF:

-      {

-      offset = GET2(ecode, 1) << 1;               /* Doubled ref number */

-      ecode += 3;                                 /* Advance past item */

-

-      /* If the reference is unset, set the length to be longer than the amount

-      of subject left; this ensures that every attempt at a match fails. We

-      can't just fail here, because of the possibility of quantifiers with zero

-      minima. */

-

-      length = (offset >= offset_top || md->offset_vector[offset] < 0)?

-        md->end_subject - eptr + 1 :

-        md->offset_vector[offset+1] - md->offset_vector[offset];

-

-      /* Set up for repetition, or handle the non-repeated case */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);

-        eptr += length;

-        continue;              /* With the main loop */

-        }

-

-      /* If the length of the reference is zero, just continue with the

-      main loop. */

-

-      if (length == 0) continue;

-

-      /* First, ensure the minimum number of matches are present. We get back

-      the length of the reference string explicitly rather than passing the

-      address of eptr, so that eptr can be a register variable. */

-

-      for (i = 1; i <= min; i++)

-        {

-        if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH);

-        eptr += length;

-        }

-

-      /* If min = max, continue at the same level without recursion.

-      They are not both allowed to be zero. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep trying and advancing the pointer */

-

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || !match_ref(offset, eptr, length, md, ims))

-            RRETURN(MATCH_NOMATCH);

-          eptr += length;

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest string and work backwards */

-

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (!match_ref(offset, eptr, length, md, ims)) break;

-          eptr += length;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          eptr -= length;

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-

-

-    /* Match a bit-mapped character class, possibly repeatedly. This op code is

-    used when all the characters in the class have values in the range 0-255,

-    and either the matching is caseful, or the characters are in the range

-    0-127 when UTF-8 processing is enabled. The only difference between

-    OP_CLASS and OP_NCLASS occurs when a data character outside the range is

-    encountered.

-

-    First, look past the end of the item to see if there is repeat information

-    following. Then obey similar code to character type repeats - written out

-    again for speed. */

-

-    case OP_NCLASS:

-    case OP_CLASS:

-      {

-      data = ecode + 1;                /* Save for matching */

-      ecode += 33;                     /* Advance past the item */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        min = max = 1;

-        break;

-        }

-

-      /* First, ensure the minimum number of matches are present. */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (c > 255)

-            {

-            if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);

-            }

-          else

-            {

-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-            }

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          c = *eptr++;

-          if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* If max == min we can continue with the main loop without the

-      need to recurse. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep testing the rest of the expression and advancing

-      the pointer while it matches the class. */

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            GETCHARINC(c, eptr);

-            if (c > 255)

-              {

-              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);

-              }

-            else

-              {

-              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-              }

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            c = *eptr++;

-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest possible run, then work backwards. */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c > 255)

-              {

-              if (op == OP_CLASS) break;

-              }

-            else

-              {

-              if ((data[c/8] & (1 << (c&7))) == 0) break;

-              }

-            eptr += len;

-            }

-          for (;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-          /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject) break;

-            c = *eptr;

-            if ((data[c/8] & (1 << (c&7))) == 0) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            eptr--;

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-

-    /* Match an extended character class. This opcode is encountered only

-    in UTF-8 mode, because that's the only time it is compiled. */

-

-#ifdef SUPPORT_UTF8

-    case OP_XCLASS:

-      {

-      data = ecode + 1 + LINK_SIZE;                /* Save for matching */

-      ecode += GET(ecode, 1);                      /* Advance past the item */

-

-      switch (*ecode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        c = *ecode++ - OP_CRSTAR;

-        minimize = (c & 1) != 0;

-        min = rep_min[c];                 /* Pick up values from tables; */

-        max = rep_max[c];                 /* zero for max => infinity */

-        if (max == 0) max = INT_MAX;

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        minimize = (*ecode == OP_CRMINRANGE);

-        min = GET2(ecode, 1);

-        max = GET2(ecode, 3);

-        if (max == 0) max = INT_MAX;

-        ecode += 5;

-        break;

-

-        default:               /* No repeat follows */

-        min = max = 1;

-        break;

-        }

-

-      /* First, ensure the minimum number of matches are present. */

-

-      for (i = 1; i <= min; i++)

-        {

-        if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-        GETCHARINC(c, eptr);

-        if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);

-        }

-

-      /* If max == min we can continue with the main loop without the

-      need to recurse. */

-

-      if (min == max) continue;

-

-      /* If minimizing, keep testing the rest of the expression and advancing

-      the pointer while it matches the class. */

-

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-

-      /* If maximizing, find the longest possible run, then work backwards. */

-

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          int len = 1;

-          if (eptr >= md->end_subject) break;

-          GETCHARLEN(c, eptr, len);

-          if (!_pcre_xclass(c, data)) break;

-          eptr += len;

-          }

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr)

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-

-      /* Control never gets here */

-      }

-#endif    /* End of XCLASS */

-

-    /* Match a single character, casefully */

-

-    case OP_CHAR:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      ecode++;

-      GETCHARLEN(fc, ecode, length);

-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);

-      }

-    else

-#endif

-

-    /* Non-UTF-8 mode */

-      {

-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);

-      if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);

-      ecode += 2;

-      }

-    break;

-

-    /* Match a single character, caselessly */

-

-    case OP_CHARNC:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      ecode++;

-      GETCHARLEN(fc, ecode, length);

-

-      if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-

-      /* If the pattern character's value is < 128, we have only one byte, and

-      can use the fast lookup table. */

-

-      if (fc < 128)

-        {

-        if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-        }

-

-      /* Otherwise we must pick up the subject character */

-

-      else

-        {

-        int dc;

-        GETCHARINC(dc, eptr);

-        ecode += length;

-

-        /* If we have Unicode property support, we can use it to test the other

-        case of the character, if there is one. The result of ucp_findchar() is

-        < 0 if the char isn't found, and othercase is returned as zero if there

-        isn't one. */

-

-        if (fc != dc)

-          {

-#ifdef SUPPORT_UCP

-          int chartype;

-          int othercase;

-          if (ucp_findchar(fc, &chartype, &othercase) < 0 || dc != othercase)

-#endif

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-      }

-    else

-#endif   /* SUPPORT_UTF8 */

-

-    /* Non-UTF-8 mode */

-      {

-      if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH);

-      if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-      ecode += 2;

-      }

-    break;

-

-    /* Match a single character repeatedly; different opcodes share code. */

-

-    case OP_EXACT:

-    min = max = GET2(ecode, 1);

-    ecode += 3;

-    goto REPEATCHAR;

-

-    case OP_UPTO:

-    case OP_MINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_MINUPTO;

-    ecode += 3;

-    goto REPEATCHAR;

-

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    c = *ecode++ - OP_STAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single-character matches. We can give

-    up quickly if there are fewer than the minimum number of characters left in

-    the subject. */

-

-    REPEATCHAR:

-#ifdef SUPPORT_UTF8

-    if (utf8)

-      {

-      length = 1;

-      charptr = ecode;

-      GETCHARLEN(fc, ecode, length);

-      if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      ecode += length;

-

-      /* Handle multibyte character matching specially here. There is

-      support for caseless matching if UCP support is present. */

-

-      if (length > 1)

-        {

-        int oclength = 0;

-        uschar occhars[8];

-

-#ifdef SUPPORT_UCP

-        int othercase;

-        int chartype;

-        if ((ims & PCRE_CASELESS) != 0 &&

-             ucp_findchar(fc, &chartype, &othercase) >= 0 &&

-             othercase > 0)

-          oclength = _pcre_ord2utf8(othercase, occhars);

-#endif  /* SUPPORT_UCP */

-

-        for (i = 1; i <= min; i++)

-          {

-          if (memcmp(eptr, charptr, length) == 0) eptr += length;

-          /* Need braces because of following else */

-          else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }

-          else

-            {

-            if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);

-            eptr += oclength;

-            }

-          }

-

-        if (min == max) continue;

-

-        if (minimize)

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-            if (memcmp(eptr, charptr, length) == 0) eptr += length;

-            /* Need braces because of following else */

-            else if (oclength == 0) { RRETURN(MATCH_NOMATCH); }

-            else

-              {

-              if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH);

-              eptr += oclength;

-              }

-            }

-          /* Control never gets here */

-          }

-        else

-          {

-          pp = eptr;

-          for (i = min; i < max; i++)

-            {

-            if (eptr > md->end_subject - length) break;

-            if (memcmp(eptr, charptr, length) == 0) eptr += length;

-            else if (oclength == 0) break;

-            else

-              {

-              if (memcmp(eptr, occhars, oclength) != 0) break;

-              eptr += oclength;

-              }

-            }

-          while (eptr >= pp)

-           {

-           RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-           if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-           eptr -= length;

-           }

-          RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-

-      /* If the length of a UTF-8 character is 1, we fall through here, and

-      obey the code as for non-UTF-8 characters below, though in this case the

-      value of fc will always be < 128. */

-      }

-    else

-#endif  /* SUPPORT_UTF8 */

-

-    /* When not in UTF-8 mode, load a single-byte character. */

-      {

-      if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-      fc = *ecode++;

-      }

-

-    /* The value of fc at this point is always less than 256, though we may or

-    may not be in UTF-8 mode. The code is duplicated for the caseless and

-    caseful cases, for speed, since matching characters is likely to be quite

-    common. First, ensure the minimum number of matches are present. If min =

-    max, continue at the same level without recursing. Otherwise, if

-    minimizing, keep trying the rest of the expression and advancing one

-    matching character if failing, up to the maximum. Alternatively, if

-    maximizing, find the maximum number of characters and work backwards. */

-

-    DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,

-      max, eptr));

-

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-      fc = md->lcc[fc];

-      for (i = 1; i <= min; i++)

-        if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-      if (min == max) continue;

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject ||

-              fc != md->lcc[*eptr++])

-            RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break;

-          eptr++;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      /* Control never gets here */

-      }

-

-    /* Caseful comparisons (includes all multi-byte characters) */

-

-    else

-      {

-      for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH);

-      if (min == max) continue;

-      if (minimize)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject || fc != *eptr++)

-            RRETURN(MATCH_NOMATCH);

-          }

-        /* Control never gets here */

-        }

-      else

-        {

-        pp = eptr;

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject || fc != *eptr) break;

-          eptr++;

-          }

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-    /* Match a negated single one-byte character. The character we are

-    checking can be multibyte. */

-

-    case OP_NOT:

-    if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-    ecode++;

-    GETCHARINCTEST(c, eptr);

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-#ifdef SUPPORT_UTF8

-      if (c < 256)

-#endif

-      c = md->lcc[c];

-      if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);

-      }

-    else

-      {

-      if (*ecode++ == c) RRETURN(MATCH_NOMATCH);

-      }

-    break;

-

-    /* Match a negated single one-byte character repeatedly. This is almost a

-    repeat of the code for a repeated single character, but I haven't found a

-    nice way of commoning these up that doesn't require a test of the

-    positive/negative option for each character match. Maybe that wouldn't add

-    very much to the time taken, but character matching *is* what this is all

-    about... */

-

-    case OP_NOTEXACT:

-    min = max = GET2(ecode, 1);

-    ecode += 3;

-    goto REPEATNOTCHAR;

-

-    case OP_NOTUPTO:

-    case OP_NOTMINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_NOTMINUPTO;

-    ecode += 3;

-    goto REPEATNOTCHAR;

-

-    case OP_NOTSTAR:

-    case OP_NOTMINSTAR:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTQUERY:

-    case OP_NOTMINQUERY:

-    c = *ecode++ - OP_NOTSTAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single-byte matches. We can give up quickly

-    if there are fewer than the minimum number of bytes left in the

-    subject. */

-

-    REPEATNOTCHAR:

-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-    fc = *ecode++;

-

-    /* The code is duplicated for the caseless and caseful cases, for speed,

-    since matching characters is likely to be quite common. First, ensure the

-    minimum number of matches are present. If min = max, continue at the same

-    level without recursing. Otherwise, if minimizing, keep trying the rest of

-    the expression and advancing one matching character if failing, up to the

-    maximum. Alternatively, if maximizing, find the maximum number of

-    characters and work backwards. */

-

-    DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,

-      max, eptr));

-

-    if ((ims & PCRE_CASELESS) != 0)

-      {

-      fc = md->lcc[fc];

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        register int d;

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(d, eptr);

-          if (d < 256) d = md->lcc[d];

-          if (fc == d) RRETURN(MATCH_NOMATCH);

-          }

-        }

-      else

-#endif

-

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);

-        }

-

-      if (min == max) continue;

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            GETCHARINC(d, eptr);

-            if (d < 256) d = md->lcc[d];

-            if (fi >= max || eptr >= md->end_subject || fc == d)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++])

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* Maximize case */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(d, eptr, len);

-            if (d < 256) d = md->lcc[d];

-            if (fc == d) break;

-            eptr += len;

-            }

-          for(;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            eptr--;

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      /* Control never gets here */

-      }

-

-    /* Caseful comparisons */

-

-    else

-      {

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        register int d;

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(d, eptr);

-          if (fc == d) RRETURN(MATCH_NOMATCH);

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (i = 1; i <= min; i++)

-          if (fc == *eptr++) RRETURN(MATCH_NOMATCH);

-        }

-

-      if (min == max) continue;

-

-      if (minimize)

-        {

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            GETCHARINC(d, eptr);

-            if (fi >= max || eptr >= md->end_subject || fc == d)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (fi = min;; fi++)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (fi >= max || eptr >= md->end_subject || fc == *eptr++)

-              RRETURN(MATCH_NOMATCH);

-            }

-          }

-        /* Control never gets here */

-        }

-

-      /* Maximize case */

-

-      else

-        {

-        pp = eptr;

-

-#ifdef SUPPORT_UTF8

-        /* UTF-8 mode */

-        if (utf8)

-          {

-          register int d;

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(d, eptr, len);

-            if (fc == d) break;

-            eptr += len;

-            }

-          for(;;)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            if (eptr-- == pp) break;        /* Stop if tried at original pos */

-            BACKCHAR(eptr);

-            }

-          }

-        else

-#endif

-        /* Not UTF-8 mode */

-          {

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || fc == *eptr) break;

-            eptr++;

-            }

-          while (eptr >= pp)

-            {

-            RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-            if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-            eptr--;

-            }

-          }

-

-        RRETURN(MATCH_NOMATCH);

-        }

-      }

-    /* Control never gets here */

-

-    /* Match a single character type repeatedly; several different opcodes

-    share code. This is very similar to the code for single characters, but we

-    repeat it in the interests of efficiency. */

-

-    case OP_TYPEEXACT:

-    min = max = GET2(ecode, 1);

-    minimize = TRUE;

-    ecode += 3;

-    goto REPEATTYPE;

-

-    case OP_TYPEUPTO:

-    case OP_TYPEMINUPTO:

-    min = 0;

-    max = GET2(ecode, 1);

-    minimize = *ecode == OP_TYPEMINUPTO;

-    ecode += 3;

-    goto REPEATTYPE;

-

-    case OP_TYPESTAR:

-    case OP_TYPEMINSTAR:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEQUERY:

-    case OP_TYPEMINQUERY:

-    c = *ecode++ - OP_TYPESTAR;

-    minimize = (c & 1) != 0;

-    min = rep_min[c];                 /* Pick up values from tables; */

-    max = rep_max[c];                 /* zero for max => infinity */

-    if (max == 0) max = INT_MAX;

-

-    /* Common code for all repeated single character type matches. Note that

-    in UTF-8 mode, '.' matches a character of any length, but for the other

-    character types, the valid characters are all one-byte long. */

-

-    REPEATTYPE:

-    ctype = *ecode++;      /* Code for the character type */

-

-#ifdef SUPPORT_UCP

-    if (ctype == OP_PROP || ctype == OP_NOTPROP)

-      {

-      prop_fail_result = ctype == OP_NOTPROP;

-      prop_type = *ecode++;

-      if (prop_type >= 128)

-        {

-        prop_test_against = prop_type - 128;

-        prop_test_variable = &prop_category;

-        }

-      else

-        {

-        prop_test_against = prop_type;

-        prop_test_variable = &prop_chartype;

-        }

-      }

-    else prop_type = -1;

-#endif

-

-    /* First, ensure the minimum number of matches are present. Use inline

-    code for maximizing the speed, and do the type test once at the start

-    (i.e. keep it out of the loop). Also we can test that there are at least

-    the minimum number of bytes before we start. This isn't as effective in

-    UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that

-    is tidier. Also separate the UCP code, which can be the same for both UTF-8

-    and single-bytes. */

-

-    if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);

-    if (min > 0)

-      {

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINC(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (i = 1; i <= min; i++)

-          {

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-        }

-

-      else

-#endif     /* SUPPORT_UCP */

-

-/* Handle all other cases when the coding is UTF-8 */

-

-#ifdef SUPPORT_UTF8

-      if (utf8) switch(ctype)

-        {

-        case OP_ANY:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr++ == NEWLINE && (ims & PCRE_DOTALL) == 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_ANYBYTE:

-        eptr += min;

-        break;

-

-        case OP_NOT_DIGIT:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)

-            RRETURN(MATCH_NOMATCH);

-          }

-        break;

-

-        case OP_DIGIT:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0))

-            RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-          }

-        break;

-

-        case OP_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          {

-          if (eptr >= md->end_subject ||

-             *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)

-            RRETURN(MATCH_NOMATCH);

-          /* No need to skip more bytes - we know it's a 1-byte character */

-          }

-        break;

-

-        default:

-        RRETURN(PCRE_ERROR_INTERNAL);

-        }  /* End switch(ctype) */

-

-      else

-#endif     /* SUPPORT_UTF8 */

-

-      /* Code for the non-UTF-8 case for minimum matching of operators other

-      than OP_PROP and OP_NOTPROP. */

-

-      switch(ctype)

-        {

-        case OP_ANY:

-        if ((ims & PCRE_DOTALL) == 0)

-          {

-          for (i = 1; i <= min; i++)

-            if (*eptr++ == NEWLINE) RRETURN(MATCH_NOMATCH);

-          }

-        else eptr += min;

-        break;

-

-        case OP_ANYBYTE:

-        eptr += min;

-        break;

-

-        case OP_NOT_DIGIT:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_DIGIT:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_WHITESPACE:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_word) != 0)

-            RRETURN(MATCH_NOMATCH);

-        break;

-

-        case OP_WORDCHAR:

-        for (i = 1; i <= min; i++)

-          if ((md->ctypes[*eptr++] & ctype_word) == 0)

-            RRETURN(MATCH_NOMATCH);

-        break;

-

-        default:

-        RRETURN(PCRE_ERROR_INTERNAL);

-        }

-      }

-

-    /* If min = max, continue at the same level without recursing */

-

-    if (min == max) continue;

-

-    /* If minimizing, we have to test the rest of the pattern before each

-    subsequent match. Again, separate the UTF-8 case for speed, and also

-    separate the UCP cases. */

-

-    if (minimize)

-      {

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINC(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            RRETURN(MATCH_NOMATCH);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-        }

-

-      else

-#endif     /* SUPPORT_UCP */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-      if (utf8)

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-

-          GETCHARINC(c, eptr);

-          switch(ctype)

-            {

-            case OP_ANY:

-            if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_ANYBYTE:

-            break;

-

-            case OP_NOT_DIGIT:

-            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_DIGIT:

-            if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WHITESPACE:

-            if (c < 256 && (md->ctypes[c] & ctype_space) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WHITESPACE:

-            if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WORDCHAR:

-            if (c < 256 && (md->ctypes[c] & ctype_word) != 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WORDCHAR:

-            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)

-              RRETURN(MATCH_NOMATCH);

-            break;

-

-            default:

-            RRETURN(PCRE_ERROR_INTERNAL);

-            }

-          }

-        }

-      else

-#endif

-      /* Not UTF-8 mode */

-        {

-        for (fi = min;; fi++)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH);

-          c = *eptr++;

-          switch(ctype)

-            {

-            case OP_ANY:

-            if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_ANYBYTE:

-            break;

-

-            case OP_NOT_DIGIT:

-            if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_DIGIT:

-            if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WHITESPACE:

-            if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WHITESPACE:

-            if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_NOT_WORDCHAR:

-            if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            case OP_WORDCHAR:

-            if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);

-            break;

-

-            default:

-            RRETURN(PCRE_ERROR_INTERNAL);

-            }

-          }

-        }

-      /* Control never gets here */

-      }

-

-    /* If maximizing it is worth using inline code for speed, doing the type

-    test once at the start (i.e. keep it out of the loop). Again, keep the

-    UTF-8 and UCP stuff separate. */

-

-    else

-      {

-      pp = eptr;  /* Remember where we started */

-

-#ifdef SUPPORT_UCP

-      if (prop_type > 0)

-        {

-        for (i = min; i < max; i++)

-          {

-          int len = 1;

-          if (eptr >= md->end_subject) break;

-          GETCHARLEN(c, eptr, len);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if ((*prop_test_variable == prop_test_against) == prop_fail_result)

-            break;

-          eptr+= len;

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr);

-          }

-        }

-

-      /* Match extended Unicode sequences. We will get here only if the

-      support is in the binary; otherwise a compile-time error occurs. */

-

-      else if (ctype == OP_EXTUNI)

-        {

-        for (i = min; i < max; i++)

-          {

-          if (eptr >= md->end_subject) break;

-          GETCHARINCTEST(c, eptr);

-          prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-          if (prop_category == ucp_M) break;

-          while (eptr < md->end_subject)

-            {

-            int len = 1;

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr += len;

-            }

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          for (;;)                        /* Move back over one extended */

-            {

-            int len = 1;

-            BACKCHAR(eptr);

-            if (!utf8) c = *eptr; else

-              {

-              GETCHARLEN(c, eptr, len);

-              }

-            prop_category = ucp_findchar(c, &prop_chartype, &prop_othercase);

-            if (prop_category != ucp_M) break;

-            eptr--;

-            }

-          }

-        }

-

-      else

-#endif   /* SUPPORT_UCP */

-

-#ifdef SUPPORT_UTF8

-      /* UTF-8 mode */

-

-      if (utf8)

-        {

-        switch(ctype)

-          {

-          case OP_ANY:

-

-          /* Special code is required for UTF8, but when the maximum is unlimited

-          we don't need it, so we repeat the non-UTF8 code. This is probably

-          worth it, because .* is quite a common idiom. */

-

-          if (max < INT_MAX)

-            {

-            if ((ims & PCRE_DOTALL) == 0)

-              {

-              for (i = min; i < max; i++)

-                {

-                if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-                eptr++;

-                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-                }

-              }

-            else

-              {

-              for (i = min; i < max; i++)

-                {

-                eptr++;

-                while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;

-                }

-              }

-            }

-

-          /* Handle unlimited UTF-8 repeat */

-

-          else

-            {

-            if ((ims & PCRE_DOTALL) == 0)

-              {

-              for (i = min; i < max; i++)

-                {

-                if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-                eptr++;

-                }

-              break;

-              }

-            else

-              {

-              c = max - min;

-              if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-              eptr += c;

-              }

-            }

-          break;

-

-          /* The byte case is the same as non-UTF8 */

-

-          case OP_ANYBYTE:

-          c = max - min;

-          if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-          eptr += c;

-          break;

-

-          case OP_NOT_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_NOT_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_NOT_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;

-            eptr+= len;

-            }

-          break;

-

-          case OP_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            int len = 1;

-            if (eptr >= md->end_subject) break;

-            GETCHARLEN(c, eptr, len);

-            if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;

-            eptr+= len;

-            }

-          break;

-

-          default:

-          RRETURN(PCRE_ERROR_INTERNAL);

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        for(;;)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          if (eptr-- == pp) break;        /* Stop if tried at original pos */

-          BACKCHAR(eptr);

-          }

-        }

-      else

-#endif

-

-      /* Not UTF-8 mode */

-        {

-        switch(ctype)

-          {

-          case OP_ANY:

-          if ((ims & PCRE_DOTALL) == 0)

-            {

-            for (i = min; i < max; i++)

-              {

-              if (eptr >= md->end_subject || *eptr == NEWLINE) break;

-              eptr++;

-              }

-            break;

-            }

-          /* For DOTALL case, fall through and treat as \C */

-

-          case OP_ANYBYTE:

-          c = max - min;

-          if (c > md->end_subject - eptr) c = md->end_subject - eptr;

-          eptr += c;

-          break;

-

-          case OP_NOT_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_DIGIT:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_NOT_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_WHITESPACE:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_NOT_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          case OP_WORDCHAR:

-          for (i = min; i < max; i++)

-            {

-            if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)

-              break;

-            eptr++;

-            }

-          break;

-

-          default:

-          RRETURN(PCRE_ERROR_INTERNAL);

-          }

-

-        /* eptr is now past the end of the maximum run */

-

-        while (eptr >= pp)

-          {

-          RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0);

-          eptr--;

-          if (rrc != MATCH_NOMATCH) RRETURN(rrc);

-          }

-        }

-

-      /* Get here if we can't make it match with any permitted repetitions */

-

-      RRETURN(MATCH_NOMATCH);

-      }

-    /* Control never gets here */

-

-    /* There's been some horrible disaster. Since all codes > OP_BRA are

-    for capturing brackets, and there shouldn't be any gaps between 0 and

-    OP_BRA, arrival here can only mean there is something seriously wrong

-    in the code above or the OP_xxx definitions. */

-

-    default:

-    DPRINTF(("Unknown opcode %d\n", *ecode));

-    RRETURN(PCRE_ERROR_UNKNOWN_NODE);

-    }

-

-  /* Do not stick any code in here without much thought; it is assumed

-  that "continue" in the code above comes out to here to repeat the main

-  loop. */

-

-  }             /* End of main loop */

-/* Control never reaches here */

-}

-

-

-/***************************************************************************

-****************************************************************************

-                   RECURSION IN THE match() FUNCTION

-

-Undefine all the macros that were defined above to handle this. */

-

-#ifdef NO_RECURSE

-#undef eptr

-#undef ecode

-#undef offset_top

-#undef ims

-#undef eptrb

-#undef flags

-

-#undef callpat

-#undef charptr

-#undef data

-#undef next

-#undef pp

-#undef prev

-#undef saved_eptr

-

-#undef new_recursive

-

-#undef cur_is_word

-#undef condition

-#undef minimize

-#undef prev_is_word

-

-#undef original_ims

-

-#undef ctype

-#undef length

-#undef max

-#undef min

-#undef number

-#undef offset

-#undef op

-#undef save_capture_last

-#undef save_offset1

-#undef save_offset2

-#undef save_offset3

-#undef stacksave

-

-#undef newptrb

-

-#endif

-

-/* These two are defined as macros in both cases */

-

-#undef fc

-#undef fi

-

-/***************************************************************************

-***************************************************************************/

-

-

-

-/*************************************************

-*         Execute a Regular Expression           *

-*************************************************/

-

-/* This function applies a compiled re to a subject string and picks out

-portions of the string if it matches. Two elements in the vector are set for

-each substring: the offsets to the start and end of the substring.

-

-Arguments:

-  argument_re     points to the compiled expression

-  extra_data      points to extra data or is NULL

-  subject         points to the subject string

-  length          length of subject string (may contain binary zeros)

-  start_offset    where to start in the subject string

-  options         option bits

-  offsets         points to a vector of ints to be filled in with offsets

-  offsetcount     the number of elements in the vector

-

-Returns:          > 0 => success; value is the number of elements filled in

-                  = 0 => success, but offsets is not big enough

-                   -1 => failed to match

-                 < -1 => some kind of unexpected problem

-*/

-

-EXPORT int

-pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,

-  const char *subject, int length, int start_offset, int options, int *offsets,

-  int offsetcount)

-{

-int rc, resetcount, ocount;

-int first_byte = -1;

-int req_byte = -1;

-int req_byte2 = -1;

-unsigned long int ims = 0;

-BOOL using_temporary_offsets = FALSE;

-BOOL anchored;

-BOOL startline;

-BOOL firstline;

-BOOL first_byte_caseless = FALSE;

-BOOL req_byte_caseless = FALSE;

-match_data match_block;

-const uschar *tables;

-const uschar *start_bits = NULL;

-const uschar *start_match = (const uschar *)subject + start_offset;

-const uschar *end_subject;

-const uschar *req_byte_ptr = start_match - 1;

-

-pcre_study_data internal_study;

-const pcre_study_data *study;

-

-real_pcre internal_re;

-const real_pcre *external_re = (const real_pcre *)argument_re;

-const real_pcre *re = external_re;

-

-/* Plausibility checks */

-

-if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;

-if (re == NULL || subject == NULL ||

-   (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;

-if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;

-

-/* Fish out the optional data from the extra_data structure, first setting

-the default values. */

-

-study = NULL;

-match_block.match_limit = MATCH_LIMIT;

-match_block.callout_data = NULL;

-

-/* The table pointer is always in native byte order. */

-

-tables = external_re->tables;

-

-if (extra_data != NULL)

-  {

-  register unsigned int flags = extra_data->flags;

-  if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)

-    study = (const pcre_study_data *)extra_data->study_data;

-  if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0)

-    match_block.match_limit = extra_data->match_limit;

-  if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)

-    match_block.callout_data = extra_data->callout_data;

-  if ((flags & PCRE_EXTRA_TABLES) != 0) tables = extra_data->tables;

-  }

-

-/* If the exec call supplied NULL for tables, use the inbuilt ones. This

-is a feature that makes it possible to save compiled regex and re-use them

-in other programs later. */

-

-if (tables == NULL) tables = _pcre_default_tables;

-

-/* Check that the first field in the block is the magic number. If it is not,

-test for a regex that was compiled on a host of opposite endianness. If this is

-the case, flipped values are put in internal_re and internal_study if there was

-study data too. */

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-/* Set up other data */

-

-anchored = ((re->options | options) & PCRE_ANCHORED) != 0;

-startline = (re->options & PCRE_STARTLINE) != 0;

-firstline = (re->options & PCRE_FIRSTLINE) != 0;

-

-/* The code starts after the real_pcre block and the capture name table. */

-

-match_block.start_code = (const uschar *)external_re + re->name_table_offset +

-  re->name_count * re->name_entry_size;

-

-match_block.start_subject = (const uschar *)subject;

-match_block.start_offset = start_offset;

-match_block.end_subject = match_block.start_subject + length;

-end_subject = match_block.end_subject;

-

-match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;

-match_block.utf8 = (re->options & PCRE_UTF8) != 0;

-

-match_block.notbol = (options & PCRE_NOTBOL) != 0;

-match_block.noteol = (options & PCRE_NOTEOL) != 0;

-match_block.notempty = (options & PCRE_NOTEMPTY) != 0;

-match_block.partial = (options & PCRE_PARTIAL) != 0;

-match_block.hitend = FALSE;

-

-match_block.recursive = NULL;                   /* No recursion at top level */

-

-match_block.lcc = tables + lcc_offset;

-match_block.ctypes = tables + ctypes_offset;

-

-/* Partial matching is supported only for a restricted set of regexes at the

-moment. */

-

-if (match_block.partial && (re->options & PCRE_NOPARTIAL) != 0)

-  return PCRE_ERROR_BADPARTIAL;

-

-/* Check a UTF-8 string if required. Unfortunately there's no way of passing

-back the character offset. */

-

-#ifdef SUPPORT_UTF8

-if (match_block.utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)

-  {

-  if (_pcre_valid_utf8((uschar *)subject, length) >= 0)

-    return PCRE_ERROR_BADUTF8;

-  if (start_offset > 0 && start_offset < length)

-    {

-    int tb = ((uschar *)subject)[start_offset];

-    if (tb > 127)

-      {

-      tb &= 0xc0;

-      if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;

-      }

-    }

-  }

-#endif

-

-/* The ims options can vary during the matching as a result of the presence

-of (?ims) items in the pattern. They are kept in a local variable so that

-restoring at the exit of a group is easy. */

-

-ims = re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);

-

-/* If the expression has got more back references than the offsets supplied can

-hold, we get a temporary chunk of working store to use during the matching.

-Otherwise, we can use the vector supplied, rounding down its size to a multiple

-of 3. */

-

-ocount = offsetcount - (offsetcount % 3);

-

-if (re->top_backref > 0 && re->top_backref >= ocount/3)

-  {

-  ocount = re->top_backref * 3 + 3;

-  match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));

-  if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;

-  using_temporary_offsets = TRUE;

-  DPRINTF(("Got memory to hold back references\n"));

-  }

-else match_block.offset_vector = offsets;

-

-match_block.offset_end = ocount;

-match_block.offset_max = (2*ocount)/3;

-match_block.offset_overflow = FALSE;

-match_block.capture_last = -1;

-

-/* Compute the minimum number of offsets that we need to reset each time. Doing

-this makes a huge difference to execution time when there aren't many brackets

-in the pattern. */

-

-resetcount = 2 + re->top_bracket * 2;

-if (resetcount > offsetcount) resetcount = ocount;

-

-/* Reset the working variable associated with each extraction. These should

-never be used unless previously set, but they get saved and restored, and so we

-initialize them to avoid reading uninitialized locations. */

-

-if (match_block.offset_vector != NULL)

-  {

-  register int *iptr = match_block.offset_vector + ocount;

-  register int *iend = iptr - resetcount/2 + 1;

-  while (--iptr >= iend) *iptr = -1;

-  }

-

-/* Set up the first character to match, if available. The first_byte value is

-never set for an anchored regular expression, but the anchoring may be forced

-at run time, so we have to test for anchoring. The first char may be unset for

-an unanchored pattern, of course. If there's no first char and the pattern was

-studied, there may be a bitmap of possible first characters. */

-

-if (!anchored)

-  {

-  if ((re->options & PCRE_FIRSTSET) != 0)

-    {

-    first_byte = re->first_byte & 255;

-    if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE)

-      first_byte = match_block.lcc[first_byte];

-    }

-  else

-    if (!startline && study != NULL &&

-      (study->options & PCRE_STUDY_MAPPED) != 0)

-        start_bits = study->start_bits;

-  }

-

-/* For anchored or unanchored matches, there may be a "last known required

-character" set. */

-

-if ((re->options & PCRE_REQCHSET) != 0)

-  {

-  req_byte = re->req_byte & 255;

-  req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0;

-  req_byte2 = (tables + fcc_offset)[req_byte];  /* case flipped */

-  }

-

-/* Loop for handling unanchored repeated matching attempts; for anchored regexs

-the loop runs just once. */

-

-do

-  {

-  const uschar *save_end_subject = end_subject;

-

-  /* Reset the maximum number of extractions we might see. */

-

-  if (match_block.offset_vector != NULL)

-    {

-    register int *iptr = match_block.offset_vector;

-    register int *iend = iptr + resetcount;

-    while (iptr < iend) *iptr++ = -1;

-    }

-

-  /* Advance to a unique first char if possible. If firstline is TRUE, the

-  start of the match is constrained to the first line of a multiline string.

-  Implement this by temporarily adjusting end_subject so that we stop scanning

-  at a newline. If the match fails at the newline, later code breaks this loop.

-  */

-

-  if (firstline)

-    {

-    const uschar *t = start_match;

-    while (t < save_end_subject && *t != '\n') t++;

-    end_subject = t;

-    }

-

-  /* Now test for a unique first byte */

-

-  if (first_byte >= 0)

-    {

-    if (first_byte_caseless)

-      while (start_match < end_subject &&

-             match_block.lcc[*start_match] != first_byte)

-        start_match++;

-    else

-      while (start_match < end_subject && *start_match != first_byte)

-        start_match++;

-    }

-

-  /* Or to just after \n for a multiline match if possible */

-

-  else if (startline)

-    {

-    if (start_match > match_block.start_subject + start_offset)

-      {

-      while (start_match < end_subject && start_match[-1] != NEWLINE)

-        start_match++;

-      }

-    }

-

-  /* Or to a non-unique first char after study */

-

-  else if (start_bits != NULL)

-    {

-    while (start_match < end_subject)

-      {

-      register unsigned int c = *start_match;

-      if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break;

-      }

-    }

-

-  /* Restore fudged end_subject */

-

-  end_subject = save_end_subject;

-

-#ifdef DEBUG  /* Sigh. Some compilers never learn. */

-  printf(">>>> Match against: ");

-  pchars(start_match, end_subject - start_match, TRUE, &match_block);

-  printf("\n");

-#endif

-

-  /* If req_byte is set, we know that that character must appear in the subject

-  for the match to succeed. If the first character is set, req_byte must be

-  later in the subject; otherwise the test starts at the match point. This

-  optimization can save a huge amount of backtracking in patterns with nested

-  unlimited repeats that aren't going to match. Writing separate code for

-  cased/caseless versions makes it go faster, as does using an autoincrement

-  and backing off on a match.

-

-  HOWEVER: when the subject string is very, very long, searching to its end can

-  take a long time, and give bad performance on quite ordinary patterns. This

-  showed up when somebody was matching /^C/ on a 32-megabyte string... so we

-  don't do this when the string is sufficiently long.

-

-  ALSO: this processing is disabled when partial matching is requested.

-  */

-

-  if (req_byte >= 0 &&

-      end_subject - start_match < REQ_BYTE_MAX &&

-      !match_block.partial)

-    {

-    register const uschar *p = start_match + ((first_byte >= 0)? 1 : 0);

-

-    /* We don't need to repeat the search if we haven't yet reached the

-    place we found it at last time. */

-

-    if (p > req_byte_ptr)

-      {

-      if (req_byte_caseless)

-        {

-        while (p < end_subject)

-          {

-          register int pp = *p++;

-          if (pp == req_byte || pp == req_byte2) { p--; break; }

-          }

-        }

-      else

-        {

-        while (p < end_subject)

-          {

-          if (*p++ == req_byte) { p--; break; }

-          }

-        }

-

-      /* If we can't find the required character, break the matching loop */

-

-      if (p >= end_subject) break;

-

-      /* If we have found the required character, save the point where we

-      found it, so that we don't search again next time round the loop if

-      the start hasn't passed this character yet. */

-

-      req_byte_ptr = p;

-      }

-    }

-

-  /* When a match occurs, substrings will be set for all internal extractions;

-  we just need to set up the whole thing as substring 0 before returning. If

-  there were too many extractions, set the return code to zero. In the case

-  where we had to get some local store to hold offsets for backreferences, copy

-  those back references that we can. In this case there need not be overflow

-  if certain parts of the pattern were not used. */

-

-  match_block.start_match = start_match;

-  match_block.match_call_count = 0;

-

-  rc = match(start_match, match_block.start_code, 2, &match_block, ims, NULL,

-    match_isgroup);

-

-  /* When the result is no match, if the subject's first character was a

-  newline and the PCRE_FIRSTLINE option is set, break (which will return

-  PCRE_ERROR_NOMATCH). The option requests that a match occur before the first

-  newline in the subject. Otherwise, advance the pointer to the next character

-  and continue - but the continuation will actually happen only when the

-  pattern is not anchored. */

-

-  if (rc == MATCH_NOMATCH)

-    {

-    if (firstline && *start_match == NEWLINE) break;

-    start_match++;

-#ifdef SUPPORT_UTF8

-    if (match_block.utf8)

-      while(start_match < end_subject && (*start_match & 0xc0) == 0x80)

-        start_match++;

-#endif

-    continue;

-    }

-

-  if (rc != MATCH_MATCH)

-    {

-    DPRINTF((">>>> error: returning %d\n", rc));

-    return rc;

-    }

-

-  /* We have a match! Copy the offset information from temporary store if

-  necessary */

-

-  if (using_temporary_offsets)

-    {

-    if (offsetcount >= 4)

-      {

-      memcpy(offsets + 2, match_block.offset_vector + 2,

-        (offsetcount - 2) * sizeof(int));

-      DPRINTF(("Copied offsets from temporary memory\n"));

-      }

-    if (match_block.end_offset_top > offsetcount)

-      match_block.offset_overflow = TRUE;

-

-    DPRINTF(("Freeing temporary memory\n"));

-    (pcre_free)(match_block.offset_vector);

-    }

-

-  rc = match_block.offset_overflow? 0 : match_block.end_offset_top/2;

-

-  if (offsetcount < 2) rc = 0; else

-    {

-    offsets[0] = start_match - match_block.start_subject;

-    offsets[1] = match_block.end_match_ptr - match_block.start_subject;

-    }

-

-  DPRINTF((">>>> returning %d\n", rc));

-  return rc;

-  }

-

-/* This "while" is the end of the "do" above */

-

-while (!anchored && start_match <= end_subject);

-

-if (using_temporary_offsets)

-  {

-  DPRINTF(("Freeing temporary memory\n"));

-  (pcre_free)(match_block.offset_vector);

-  }

-

-if (match_block.partial && match_block.hitend)

-  {

-  DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));

-  return PCRE_ERROR_PARTIAL;

-  }

-else

-  {

-  DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));

-  return PCRE_ERROR_NOMATCH;

-  }

-}

-

-/* End of pcre_exec.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/*PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_fullinfo(), which returns

-information about a compiled pattern. */

-

-

-

-

-/*************************************************

-*        Return info about compiled pattern      *

-*************************************************/

-

-/* This is a newer "info" function which has an extensible interface so

-that additional items can be added compatibly.

-

-Arguments:

-  argument_re      points to compiled code

-  extra_data       points extra data, or NULL

-  what             what information is required

-  where            where to put the information

-

-Returns:           0 if data returned, negative on error

-*/

-

-EXPORT int

-pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,

-  void *where)

-{

-real_pcre internal_re;

-pcre_study_data internal_study;

-const real_pcre *re = (const real_pcre *)argument_re;

-const pcre_study_data *study = NULL;

-

-if (re == NULL || where == NULL) return PCRE_ERROR_NULL;

-

-if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)

-  study = (const pcre_study_data *)extra_data->study_data;

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, study, &internal_study);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  if (study != NULL) study = &internal_study;

-  }

-

-switch (what)

-  {

-  case PCRE_INFO_OPTIONS:

-  *((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;

-  break;

-

-  case PCRE_INFO_SIZE:

-  *((size_t *)where) = re->size;

-  break;

-

-  case PCRE_INFO_STUDYSIZE:

-  *((size_t *)where) = (study == NULL)? 0 : study->size;

-  break;

-

-  case PCRE_INFO_CAPTURECOUNT:

-  *((int *)where) = re->top_bracket;

-  break;

-

-  case PCRE_INFO_BACKREFMAX:

-  *((int *)where) = re->top_backref;

-  break;

-

-  case PCRE_INFO_FIRSTBYTE:

-  *((int *)where) =

-    ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :

-    ((re->options & PCRE_STARTLINE) != 0)? -1 : -2;

-  break;

-

-  /* Make sure we pass back the pointer to the bit vector in the external

-  block, not the internal copy (with flipped integer fields). */

-

-  case PCRE_INFO_FIRSTTABLE:

-  *((const uschar **)where) =

-    (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?

-      ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;

-  break;

-

-  case PCRE_INFO_LASTLITERAL:

-  *((int *)where) =

-    ((re->options & PCRE_REQCHSET) != 0)? re->req_byte : -1;

-  break;

-

-  case PCRE_INFO_NAMEENTRYSIZE:

-  *((int *)where) = re->name_entry_size;

-  break;

-

-  case PCRE_INFO_NAMECOUNT:

-  *((int *)where) = re->name_count;

-  break;

-

-  case PCRE_INFO_NAMETABLE:

-  *((const uschar **)where) = (const uschar *)re + re->name_table_offset;

-  break;

-

-  case PCRE_INFO_DEFAULT_TABLES:

-  *((const uschar **)where) = (const uschar *)(_pcre_default_tables);

-  break;

-

-  default: return PCRE_ERROR_BADOPTION;

-  }

-

-return 0;

-}

-

-/* End of pcre_fullinfo.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains some convenience functions for extracting substrings

-from the subject string after a regex match has succeeded. The original idea

-for these functions came from Scott Wimer. */

-

-

-

-

-/*************************************************

-*           Find number for named string         *

-*************************************************/

-

-/* This function is used by the two extraction functions below, as well

-as being generally available.

-

-Arguments:

-  code        the compiled regex

-  stringname  the name whose number is required

-

-Returns:      the number of the named parentheses, or a negative number

-                (PCRE_ERROR_NOSUBSTRING) if not found

-*/

-

-int

-pcre_get_stringnumber(const pcre *code, const char *stringname)

-{

-int rc;

-int entrysize;

-int top, bot;

-uschar *nametable;

-

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)

-  return rc;

-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;

-

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)

-  return rc;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)

-  return rc;

-

-bot = 0;

-while (top > bot)

-  {

-  int mid = (top + bot) / 2;

-  uschar *entry = nametable + entrysize*mid;

-  int c = strcmp(stringname, (char *)(entry + 2));

-  if (c == 0) return (entry[0] << 8) + entry[1];

-  if (c > 0) bot = mid + 1; else top = mid;

-  }

-

-return PCRE_ERROR_NOSUBSTRING;

-}

-

-

-

-/*************************************************

-*      Copy captured string to given buffer      *

-*************************************************/

-

-/* This function copies a single captured substring into a given buffer.

-Note that we use memcpy() rather than strncpy() in case there are binary zeros

-in the string.

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringnumber   the number of the required substring

-  buffer         where to put the substring

-  size           the size of the buffer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) buffer too small

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_copy_substring(const char *subject, int *ovector, int stringcount,

-  int stringnumber, char *buffer, int size)

-{

-int yield;

-if (stringnumber < 0 || stringnumber >= stringcount)

-  return PCRE_ERROR_NOSUBSTRING;

-stringnumber *= 2;

-yield = ovector[stringnumber+1] - ovector[stringnumber];

-if (size < yield + 1) return PCRE_ERROR_NOMEMORY;

-memcpy(buffer, subject + ovector[stringnumber], yield);

-buffer[yield] = 0;

-return yield;

-}

-

-

-

-/*************************************************

-*   Copy named captured string to given buffer   *

-*************************************************/

-

-/* This function copies a single captured substring into a given buffer,

-identifying it by name.

-

-Arguments:

-  code           the compiled regex

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringname     the name of the required substring

-  buffer         where to put the substring

-  size           the size of the buffer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) buffer too small

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,

-  int stringcount, const char *stringname, char *buffer, int size)

-{

-int n = pcre_get_stringnumber(code, stringname);

-if (n <= 0) return n;

-return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);

-}

-

-

-

-/*************************************************

-*      Copy all captured strings to new store    *

-*************************************************/

-

-/* This function gets one chunk of store and builds a list of pointers and all

-of the captured substrings in it. A NULL pointer is put on the end of the list.

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  listptr        set to point to the list of pointers

-

-Returns:         if successful: 0

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) failed to get store

-*/

-

-int

-pcre_get_substring_list(const char *subject, int *ovector, int stringcount,

-  const char ***listptr)

-{

-int i;

-int size = sizeof(char *);

-int double_count = stringcount * 2;

-char **stringlist;

-char *p;

-

-for (i = 0; i < double_count; i += 2)

-  size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;

-

-stringlist = (char **)(pcre_malloc)(size);

-if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;

-

-*listptr = (const char **)stringlist;

-p = (char *)(stringlist + stringcount + 1);

-

-for (i = 0; i < double_count; i += 2)

-  {

-  int len = ovector[i+1] - ovector[i];

-  memcpy(p, subject + ovector[i], len);

-  *stringlist++ = p;

-  p += len;

-  *p++ = 0;

-  }

-

-*stringlist = NULL;

-return 0;

-}

-

-

-

-/*************************************************

-*   Free store obtained by get_substring_list    *

-*************************************************/

-

-/* This function exists for the benefit of people calling PCRE from non-C

-programs that can call its functions, but not free() or (pcre_free)() directly.

-

-Argument:   the result of a previous pcre_get_substring_list()

-Returns:    nothing

-*/

-

-void

-pcre_free_substring_list(const char **pointer)

-{

-(pcre_free)((void *)pointer);

-}

-

-

-

-/*************************************************

-*      Copy captured string to new store         *

-*************************************************/

-

-/* This function copies a single captured substring into a piece of new

-store

-

-Arguments:

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringnumber   the number of the required substring

-  stringptr      where to put a pointer to the substring

-

-Returns:         if successful:

-                   the length of the string, not including the zero that

-                   is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) failed to get store

-                   PCRE_ERROR_NOSUBSTRING (-7) substring not present

-*/

-

-int

-pcre_get_substring(const char *subject, int *ovector, int stringcount,

-  int stringnumber, const char **stringptr)

-{

-int yield;

-char *substring;

-if (stringnumber < 0 || stringnumber >= stringcount)

-  return PCRE_ERROR_NOSUBSTRING;

-stringnumber *= 2;

-yield = ovector[stringnumber+1] - ovector[stringnumber];

-substring = (char *)(pcre_malloc)(yield + 1);

-if (substring == NULL) return PCRE_ERROR_NOMEMORY;

-memcpy(substring, subject + ovector[stringnumber], yield);

-substring[yield] = 0;

-*stringptr = substring;

-return yield;

-}

-

-

-

-/*************************************************

-*   Copy named captured string to new store      *

-*************************************************/

-

-/* This function copies a single captured substring, identified by name, into

-new store.

-

-Arguments:

-  code           the compiled regex

-  subject        the subject string that was matched

-  ovector        pointer to the offsets table

-  stringcount    the number of substrings that were captured

-                   (i.e. the yield of the pcre_exec call, unless

-                   that was zero, in which case it should be 1/3

-                   of the offset table size)

-  stringname     the name of the required substring

-  stringptr      where to put the pointer

-

-Returns:         if successful:

-                   the length of the copied string, not including the zero

-                   that is put on the end; can be zero

-                 if not successful:

-                   PCRE_ERROR_NOMEMORY (-6) couldn't get memory

-                   PCRE_ERROR_NOSUBSTRING (-7) no such captured substring

-*/

-

-int

-pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,

-  int stringcount, const char *stringname, const char **stringptr)

-{

-int n = pcre_get_stringnumber(code, stringname);

-if (n <= 0) return n;

-return pcre_get_substring(subject, ovector, stringcount, n, stringptr);

-}

-

-

-

-

-/*************************************************

-*       Free store obtained by get_substring     *

-*************************************************/

-

-/* This function exists for the benefit of people calling PCRE from non-C

-programs that can call its functions, but not free() or (pcre_free)() directly.

-

-Argument:   the result of a previous pcre_get_substring()

-Returns:    nothing

-*/

-

-void

-pcre_free_substring(const char *pointer)

-{

-(pcre_free)((void *)pointer);

-}

-

-/* End of pcre_get.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains global variables that are exported by the PCRE library.

-PCRE is thread-clean and doesn't use any global variables in the normal sense.

-However, it calls memory allocation and freeing functions via the four

-indirections below, and it can optionally do callouts, using the fifth

-indirection. These values can be changed by the caller, but are shared between

-all threads. However, when compiling for Virtual Pascal, things are done

-differently, and global variables are not used (see pcre.in). */

-

-

-

-

-#ifndef VPCOMPAT

-#ifdef __cplusplus

-extern "C" void *(*pcre_malloc)(size_t) = malloc;

-extern "C" void  (*pcre_free)(void *) = free;

-extern "C" void *(*pcre_stack_malloc)(size_t) = malloc;

-extern "C" void  (*pcre_stack_free)(void *) = free;

-extern "C" int   (*pcre_callout)(pcre_callout_block *) = NULL;

-#else

-void *(*pcre_malloc)(size_t) = malloc;

-void  (*pcre_free)(void *) = free;

-void *(*pcre_stack_malloc)(size_t) = malloc;

-void  (*pcre_stack_free)(void *) = free;

-int   (*pcre_callout)(pcre_callout_block *) = NULL;

-#endif

-#endif

-

-/* End of pcre_globals.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_info(), which gives some

-information about a compiled pattern. However, use of this function is now

-deprecated, as it has been superseded by pcre_fullinfo(). */

-

-

-

-

-/*************************************************

-* (Obsolete) Return info about compiled pattern  *

-*************************************************/

-

-/* This is the original "info" function. It picks potentially useful data out

-of the private structure, but its interface was too rigid. It remains for

-backwards compatibility. The public options are passed back in an int - though

-the re->options field has been expanded to a long int, all the public options

-at the low end of it, and so even on 16-bit systems this will still be OK.

-Therefore, I haven't changed the API for pcre_info().

-

-Arguments:

-  argument_re   points to compiled code

-  optptr        where to pass back the options

-  first_byte    where to pass back the first character,

-                or -1 if multiline and all branches start ^,

-                or -2 otherwise

-

-Returns:        number of capturing subpatterns

-                or negative values on error

-*/

-

-EXPORT int

-pcre_info(const pcre *argument_re, int *optptr, int *first_byte)

-{

-real_pcre internal_re;

-const real_pcre *re = (const real_pcre *)argument_re;

-if (re == NULL) return PCRE_ERROR_NULL;

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  re = _pcre_try_flipped(re, &internal_re, NULL, NULL);

-  if (re == NULL) return PCRE_ERROR_BADMAGIC;

-  }

-if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);

-if (first_byte != NULL)

-  *first_byte = ((re->options & PCRE_FIRSTSET) != 0)? re->first_byte :

-     ((re->options & PCRE_STARTLINE) != 0)? -1 : -2;

-return re->top_bracket;

-}

-

-/* End of pcre_info.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_maketables(), which builds

-character tables for PCRE in the current locale. The file is compiled on its

-own as part of the PCRE library. However, it is also included in the

-compilation of dftables.c, in which case the macro DFTABLES is defined. */

-

-

-#ifndef DFTABLES

-#endif

-

-

-/*************************************************

-*           Create PCRE character tables         *

-*************************************************/

-

-/* This function builds a set of character tables for use by PCRE and returns

-a pointer to them. They are build using the ctype functions, and consequently

-their contents will depend upon the current locale setting. When compiled as

-part of the library, the store is obtained via pcre_malloc(), but when compiled

-inside dftables, use malloc().

-

-Arguments:   none

-Returns:     pointer to the contiguous block of data

-*/

-

-const unsigned char *

-pcre_maketables(void)

-{

-unsigned char *yield, *p;

-int i;

-

-#ifndef DFTABLES

-yield = (unsigned char*)(pcre_malloc)(tables_length);

-#else

-yield = (unsigned char*)malloc(tables_length);

-#endif

-

-if (yield == NULL) return NULL;

-p = yield;

-

-/* First comes the lower casing table */

-

-for (i = 0; i < 256; i++) *p++ = tolower(i);

-

-/* Next the case-flipping table */

-

-for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);

-

-/* Then the character class tables. Don't try to be clever and save effort

-on exclusive ones - in some locales things may be different. Note that the

-table for "space" includes everything "isspace" gives, including VT in the

-default locale. This makes it work for the POSIX class [:space:]. */

-

-memset(p, 0, cbit_length);

-for (i = 0; i < 256; i++)

-  {

-  if (isdigit(i))

-    {

-    p[cbit_digit  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (isupper(i))

-    {

-    p[cbit_upper  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (islower(i))

-    {

-    p[cbit_lower  + i/8] |= 1 << (i&7);

-    p[cbit_word   + i/8] |= 1 << (i&7);

-    }

-  if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);

-  if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);

-  if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);

-  if (isgraph(i)) p[cbit_graph  + i/8] |= 1 << (i&7);

-  if (isprint(i)) p[cbit_print  + i/8] |= 1 << (i&7);

-  if (ispunct(i)) p[cbit_punct  + i/8] |= 1 << (i&7);

-  if (iscntrl(i)) p[cbit_cntrl  + i/8] |= 1 << (i&7);

-  }

-p += cbit_length;

-

-/* Finally, the character type table. In this, we exclude VT from the white

-space chars, because Perl doesn't recognize it as such for \s and for comments

-within regexes. */

-

-for (i = 0; i < 256; i++)

-  {

-  int x = 0;

-  if (i != 0x0b && isspace(i)) x += ctype_space;

-  if (isalpha(i)) x += ctype_letter;

-  if (isdigit(i)) x += ctype_digit;

-  if (isxdigit(i)) x += ctype_xdigit;

-  if (isalnum(i) || i == '_') x += ctype_word;

-

-  /* Note: strchr includes the terminating zero in the characters it considers.

-  In this instance, that is ok because we want binary zero to be flagged as a

-  meta-character, which in this sense is any character that terminates a run

-  of data characters. */

-

-  if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta; *p++ = x; }

-

-return yield;

-}

-

-/* End of pcre_maketables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This file contains a private PCRE function that converts an ordinal

-character value into a UTF8 string. */

-

-

-

-

-/*************************************************

-*       Convert character value to UTF-8         *

-*************************************************/

-

-/* This function takes an integer value in the range 0 - 0x7fffffff

-and encodes it as a UTF-8 character in 0 to 6 bytes.

-

-Arguments:

-  cvalue     the character value

-  buffer     pointer to buffer for result - at least 6 bytes long

-

-Returns:     number of characters placed in the buffer

-*/

-

-EXPORT int

-_pcre_ord2utf8(int cvalue, uschar *buffer)

-{

-register int i, j;

-for (i = 0; i < _pcre_utf8_table1_size; i++)

-  if (cvalue <= _pcre_utf8_table1[i]) break;

-buffer += i;

-for (j = i; j > 0; j--)

- {

- *buffer-- = 0x80 | (cvalue & 0x3f);

- cvalue >>= 6;

- }

-*buffer = _pcre_utf8_table2[i] | cvalue;

-return i + 1;

-}

-

-/* End of pcre_ord2utf8.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an PCRE private debugging function for printing out the

-internal form of a compiled regular expression, along with some supporting

-local functions. */

-

-

-

-

-static const char *OP_names[] = { OP_NAME_LIST };

-

-

-/*************************************************

-*       Print single- or multi-byte character    *

-*************************************************/

-

-static int

-print_char(FILE *f, uschar *ptr, BOOL utf8)

-{

-int c = *ptr;

-

-if (!utf8 || (c & 0xc0) != 0xc0)

-  {

-  if (isprint(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);

-  return 0;

-  }

-else

-  {

-  int i;

-  int a = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */

-  int s = 6*a;

-  c = (c & _pcre_utf8_table3[a]) << s;

-  for (i = 1; i <= a; i++)

-    {

-    /* This is a check for malformed UTF-8; it should only occur if the sanity

-    check has been turned off. Rather than swallow random bytes, just stop if

-    we hit a bad one. Print it with \X instead of \x as an indication. */

-

-    if ((ptr[i] & 0xc0) != 0x80)

-      {

-      fprintf(f, "\\X{%x}", c);

-      return i - 1;

-      }

-

-    /* The byte is OK */

-

-    s -= 6;

-    c |= (ptr[i] & 0x3f) << s;

-    }

-  if (c < 128) fprintf(f, "\\x%02x", c); else fprintf(f, "\\x{%x}", c);

-  return a;

-  }

-}

-

-

-

-/*************************************************

-*          Find Unicode property name            *

-*************************************************/

-

-static const char *

-get_ucpname(int property)

-{

-#ifdef SUPPORT_UCP

-int i;

-for (i = _pcre_utt_size; i >= 0; i--)

-  {

-  if (property == _pcre_utt[i].value) break;

-  }

-return (i >= 0)? _pcre_utt[i].name : "??";

-#else

-return "??";

-#endif

-}

-

-

-

-/*************************************************

-*         Print compiled regex                   *

-*************************************************/

-

-/* Make this function work for a regex with integers either byte order.

-However, we assume that what we are passed is a compiled regex. */

-

-EXPORT void

-_pcre_printint(pcre *external_re, FILE *f)

-{

-real_pcre *re = (real_pcre *)external_re;

-uschar *codestart, *code;

-BOOL utf8;

-

-unsigned int options = re->options;

-int offset = re->name_table_offset;

-int count = re->name_count;

-int size = re->name_entry_size;

-

-if (re->magic_number != MAGIC_NUMBER)

-  {

-  offset = ((offset << 8) & 0xff00) | ((offset >> 8) & 0xff);

-  count = ((count << 8) & 0xff00) | ((count >> 8) & 0xff);

-  size = ((size << 8) & 0xff00) | ((size >> 8) & 0xff);

-  options = ((options << 24) & 0xff000000) |

-            ((options <<  8) & 0x00ff0000) |

-            ((options >>  8) & 0x0000ff00) |

-            ((options >> 24) & 0x000000ff);

-  }

-

-code = codestart = (uschar *)re + offset + count * size;

-utf8 = (options & PCRE_UTF8) != 0;

-

-for(;;)

-  {

-  uschar *ccode;

-  int c;

-  int extra = 0;

-

-  fprintf(f, "%3d ", (int)(code - codestart));

-

-  if (*code >= OP_BRA)

-    {

-    if (*code - OP_BRA > EXTRACT_BASIC_MAX)

-      fprintf(f, "%3d Bra extra\n", GET(code, 1));

-    else

-      fprintf(f, "%3d Bra %d\n", GET(code, 1), *code - OP_BRA);

-    code += _pcre_OP_lengths[OP_BRA];

-    continue;

-    }

-

-  switch(*code)

-    {

-    case OP_END:

-    fprintf(f, "    %s\n", OP_names[*code]);

-    fprintf(f, "------------------------------------------------------------------\n");

-    return;

-

-    case OP_OPT:

-    fprintf(f, " %.2x %s", code[1], OP_names[*code]);

-    break;

-

-    case OP_CHAR:

-      {

-      fprintf(f, "    ");

-      do

-        {

-        code++;

-        code += 1 + print_char(f, code, utf8);

-        }

-      while (*code == OP_CHAR);

-      fprintf(f, "\n");

-      continue;

-      }

-    break;

-

-    case OP_CHARNC:

-      {

-      fprintf(f, " NC ");

-      do

-        {

-        code++;

-        code += 1 + print_char(f, code, utf8);

-        }

-      while (*code == OP_CHARNC);

-      fprintf(f, "\n");

-      continue;

-      }

-    break;

-

-    case OP_KETRMAX:

-    case OP_KETRMIN:

-    case OP_ALT:

-    case OP_KET:

-    case OP_ASSERT:

-    case OP_ASSERT_NOT:

-    case OP_ASSERTBACK:

-    case OP_ASSERTBACK_NOT:

-    case OP_ONCE:

-    case OP_COND:

-    case OP_REVERSE:

-    fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);

-    break;

-

-    case OP_BRANUMBER:

-    printf("%3d %s", GET2(code, 1), OP_names[*code]);

-    break;

-

-    case OP_CREF:

-    if (GET2(code, 1) == CREF_RECURSE)

-      fprintf(f, "    Cond recurse");

-    else

-      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);

-    break;

-

-    case OP_STAR:

-    case OP_MINSTAR:

-    case OP_PLUS:

-    case OP_MINPLUS:

-    case OP_QUERY:

-    case OP_MINQUERY:

-    case OP_TYPESTAR:

-    case OP_TYPEMINSTAR:

-    case OP_TYPEPLUS:

-    case OP_TYPEMINPLUS:

-    case OP_TYPEQUERY:

-    case OP_TYPEMINQUERY:

-    fprintf(f, "    ");

-    if (*code >= OP_TYPESTAR)

-      {

-      fprintf(f, "%s", OP_names[code[1]]);

-      if (code[1] == OP_PROP || code[1] == OP_NOTPROP)

-        {

-        fprintf(f, " %s ", get_ucpname(code[2]));

-        extra = 1;

-        }

-      }

-    else extra = print_char(f, code+1, utf8);

-    fprintf(f, "%s", OP_names[*code]);

-    break;

-

-    case OP_EXACT:

-    case OP_UPTO:

-    case OP_MINUPTO:

-    fprintf(f, "    ");

-    extra = print_char(f, code+3, utf8);

-    fprintf(f, "{");

-    if (*code != OP_EXACT) fprintf(f, ",");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_MINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_TYPEEXACT:

-    case OP_TYPEUPTO:

-    case OP_TYPEMINUPTO:

-    fprintf(f, "    %s", OP_names[code[3]]);

-    if (code[3] == OP_PROP || code[3] == OP_NOTPROP)

-      {

-      fprintf(f, " %s ", get_ucpname(code[4]));

-      extra = 1;

-      }

-    fprintf(f, "{");

-    if (*code != OP_TYPEEXACT) fprintf(f, "0,");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_TYPEMINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_NOT:

-    if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);

-      else fprintf(f, "    [^\\x%02x]", c);

-    break;

-

-    case OP_NOTSTAR:

-    case OP_NOTMINSTAR:

-    case OP_NOTPLUS:

-    case OP_NOTMINPLUS:

-    case OP_NOTQUERY:

-    case OP_NOTMINQUERY:

-    if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);

-      else fprintf(f, "    [^\\x%02x]", c);

-    fprintf(f, "%s", OP_names[*code]);

-    break;

-

-    case OP_NOTEXACT:

-    case OP_NOTUPTO:

-    case OP_NOTMINUPTO:

-    if (isprint(c = code[3])) fprintf(f, "    [^%c]{", c);

-      else fprintf(f, "    [^\\x%02x]{", c);

-    if (*code != OP_NOTEXACT) fprintf(f, "0,");

-    fprintf(f, "%d}", GET2(code,1));

-    if (*code == OP_NOTMINUPTO) fprintf(f, "?");

-    break;

-

-    case OP_RECURSE:

-    fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);

-    break;

-

-    case OP_REF:

-    fprintf(f, "    \\%d", GET2(code,1));

-    ccode = code + _pcre_OP_lengths[*code];

-    goto CLASS_REF_REPEAT;

-

-    case OP_CALLOUT:

-    fprintf(f, "    %s %d %d %d", OP_names[*code], code[1], GET(code,2),

-      GET(code, 2 + LINK_SIZE));

-    break;

-

-    case OP_PROP:

-    case OP_NOTPROP:

-    fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1]));

-    break;

-

-    /* OP_XCLASS can only occur in UTF-8 mode. However, there's no harm in

-    having this code always here, and it makes it less messy without all those

-    #ifdefs. */

-

-    case OP_CLASS:

-    case OP_NCLASS:

-    case OP_XCLASS:

-      {

-      int i, min, max;

-      BOOL printmap;

-

-      fprintf(f, "    [");

-

-      if (*code == OP_XCLASS)

-        {

-        extra = GET(code, 1);

-        ccode = code + LINK_SIZE + 1;

-        printmap = (*ccode & XCL_MAP) != 0;

-        if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");

-        }

-      else

-        {

-        printmap = TRUE;

-        ccode = code + 1;

-        }

-

-      /* Print a bit map */

-

-      if (printmap)

-        {

-        for (i = 0; i < 256; i++)

-          {

-          if ((ccode[i/8] & (1 << (i&7))) != 0)

-            {

-            int j;

-            for (j = i+1; j < 256; j++)

-              if ((ccode[j/8] & (1 << (j&7))) == 0) break;

-            if (i == '-' || i == ']') fprintf(f, "\\");

-            if (isprint(i)) fprintf(f, "%c", i); else fprintf(f, "\\x%02x", i);

-            if (--j > i)

-              {

-              if (j != i + 1) fprintf(f, "-");

-              if (j == '-' || j == ']') fprintf(f, "\\");

-              if (isprint(j)) fprintf(f, "%c", j); else fprintf(f, "\\x%02x", j);

-              }

-            i = j;

-            }

-          }

-        ccode += 32;

-        }

-

-      /* For an XCLASS there is always some additional data */

-

-      if (*code == OP_XCLASS)

-        {

-        int ch;

-        while ((ch = *ccode++) != XCL_END)

-          {

-          if (ch == XCL_PROP)

-            {

-            fprintf(f, "\\p{%s}", get_ucpname(*ccode++));

-            }

-          else if (ch == XCL_NOTPROP)

-            {

-            fprintf(f, "\\P{%s}", get_ucpname(*ccode++));

-            }

-          else

-            {

-            ccode += 1 + print_char(f, ccode, TRUE);

-            if (ch == XCL_RANGE)

-              {

-              fprintf(f, "-");

-              ccode += 1 + print_char(f, ccode, TRUE);

-              }

-            }

-          }

-        }

-

-      /* Indicate a non-UTF8 class which was created by negation */

-

-      fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");

-

-      /* Handle repeats after a class or a back reference */

-

-      CLASS_REF_REPEAT:

-      switch(*ccode)

-        {

-        case OP_CRSTAR:

-        case OP_CRMINSTAR:

-        case OP_CRPLUS:

-        case OP_CRMINPLUS:

-        case OP_CRQUERY:

-        case OP_CRMINQUERY:

-        fprintf(f, "%s", OP_names[*ccode]);

-        extra += _pcre_OP_lengths[*ccode];

-        break;

-

-        case OP_CRRANGE:

-        case OP_CRMINRANGE:

-        min = GET2(ccode,1);

-        max = GET2(ccode,3);

-        if (max == 0) fprintf(f, "{%d,}", min);

-        else fprintf(f, "{%d,%d}", min, max);

-        if (*ccode == OP_CRMINRANGE) fprintf(f, "?");

-        extra += _pcre_OP_lengths[*ccode];

-        break;

-        }

-      }

-    break;

-

-    /* Anything else is just an item with no data*/

-

-    default:

-    fprintf(f, "    %s", OP_names[*code]);

-    break;

-    }

-

-  code += _pcre_OP_lengths[*code] + extra;

-  fprintf(f, "\n");

-  }

-}

-

-/* End of pcre_printint.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_refcount(), which is an

-auxiliary function that can be used to maintain a reference count in a compiled

-pattern data block. This might be helpful in applications where the block is

-shared by different users. */

-

-

-

-/*************************************************

-*           Maintain reference count             *

-*************************************************/

-

-/* The reference count is a 16-bit field, initialized to zero. It is not

-possible to transfer a non-zero count from one host to a different host that

-has a different byte order - though I can't see why anyone in their right mind

-would ever want to do that!

-

-Arguments:

-  argument_re   points to compiled code

-  adjust        value to add to the count

-

-Returns:        the (possibly updated) count value (a non-negative number), or

-                a negative error number

-*/

-

-EXPORT int

-pcre_refcount(pcre *argument_re, int adjust)

-{

-real_pcre *re = (real_pcre *)argument_re;

-if (re == NULL) return PCRE_ERROR_NULL;

-re->ref_count = (-adjust > re->ref_count)? 0 :

-                (adjust + re->ref_count > 65535)? 65535 :

-                re->ref_count + adjust;

-return re->ref_count;

-}

-

-/* End of pcre_refcount.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_study(), along with local

-supporting functions. */

-

-

-

-

-/*************************************************

-*      Set a bit and maybe its alternate case    *

-*************************************************/

-

-/* Given a character, set its bit in the table, and also the bit for the other

-version of a letter if we are caseless.

-

-Arguments:

-  start_bits    points to the bit map

-  c             is the character

-  caseless      the caseless flag

-  cd            the block with char table pointers

-

-Returns:        nothing

-*/

-

-static void

-set_bit(uschar *start_bits, unsigned int c, BOOL caseless, compile_data *cd)

-{

-start_bits[c/8] |= (1 << (c&7));

-if (caseless && (cd->ctypes[c] & ctype_letter) != 0)

-  start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));

-}

-

-

-

-/*************************************************

-*          Create bitmap of starting chars       *

-*************************************************/

-

-/* This function scans a compiled unanchored expression and attempts to build a

-bitmap of the set of initial characters. If it can't, it returns FALSE. As time

-goes by, we may be able to get more clever at doing this.

-

-Arguments:

-  code         points to an expression

-  start_bits   points to a 32-byte table, initialized to 0

-  caseless     the current state of the caseless flag

-  utf8         TRUE if in UTF-8 mode

-  cd           the block with char table pointers

-

-Returns:       TRUE if table built, FALSE otherwise

-*/

-

-static BOOL

-set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,

-  BOOL utf8, compile_data *cd)

-{

-register int c;

-

-/* This next statement and the later reference to dummy are here in order to

-trick the optimizer of the IBM C compiler for OS/2 into generating correct

-code. Apparently IBM isn't going to fix the problem, and we would rather not

-disable optimization (in this module it actually makes a big difference, and

-the pcre module can use all the optimization it can get). */

-

-volatile int dummy;

-

-do

-  {

-  const uschar *tcode = code + 1 + LINK_SIZE;

-  BOOL try_next = TRUE;

-

-  while (try_next)

-    {

-    /* If a branch starts with a bracket or a positive lookahead assertion,

-    recurse to set bits from within them. That's all for this branch. */

-

-    if ((int)*tcode >= OP_BRA || *tcode == OP_ASSERT)

-      {

-      if (!set_start_bits(tcode, start_bits, caseless, utf8, cd))

-        return FALSE;

-      try_next = FALSE;

-      }

-

-    else switch(*tcode)

-      {

-      default:

-      return FALSE;

-

-      /* Skip over callout */

-

-      case OP_CALLOUT:

-      tcode += 2 + 2*LINK_SIZE;

-      break;

-

-      /* Skip over extended extraction bracket number */

-

-      case OP_BRANUMBER:

-      tcode += 3;

-      break;

-

-      /* Skip over lookbehind and negative lookahead assertions */

-

-      case OP_ASSERT_NOT:

-      case OP_ASSERTBACK:

-      case OP_ASSERTBACK_NOT:

-      do tcode += GET(tcode, 1); while (*tcode == OP_ALT);

-      tcode += 1+LINK_SIZE;

-      break;

-

-      /* Skip over an option setting, changing the caseless flag */

-

-      case OP_OPT:

-      caseless = (tcode[1] & PCRE_CASELESS) != 0;

-      tcode += 2;

-      break;

-

-      /* BRAZERO does the bracket, but carries on. */

-

-      case OP_BRAZERO:

-      case OP_BRAMINZERO:

-      if (!set_start_bits(++tcode, start_bits, caseless, utf8, cd))

-        return FALSE;

-      dummy = 1;

-      do tcode += GET(tcode,1); while (*tcode == OP_ALT);

-      tcode += 1+LINK_SIZE;

-      break;

-

-      /* Single-char * or ? sets the bit and tries the next item */

-

-      case OP_STAR:

-      case OP_MINSTAR:

-      case OP_QUERY:

-      case OP_MINQUERY:

-      set_bit(start_bits, tcode[1], caseless, cd);

-      tcode += 2;

-#ifdef SUPPORT_UTF8

-      if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;

-#endif

-      break;

-

-      /* Single-char upto sets the bit and tries the next */

-

-      case OP_UPTO:

-      case OP_MINUPTO:

-      set_bit(start_bits, tcode[3], caseless, cd);

-      tcode += 4;

-#ifdef SUPPORT_UTF8

-      if (utf8) while ((*tcode & 0xc0) == 0x80) tcode++;

-#endif

-      break;

-

-      /* At least one single char sets the bit and stops */

-

-      case OP_EXACT:       /* Fall through */

-      tcode += 2;

-

-      case OP_CHAR:

-      case OP_CHARNC:

-      case OP_PLUS:

-      case OP_MINPLUS:

-      set_bit(start_bits, tcode[1], caseless, cd);

-      try_next = FALSE;

-      break;

-

-      /* Single character type sets the bits and stops */

-

-      case OP_NOT_DIGIT:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_digit];

-      try_next = FALSE;

-      break;

-

-      case OP_DIGIT:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_digit];

-      try_next = FALSE;

-      break;

-

-      case OP_NOT_WHITESPACE:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_space];

-      try_next = FALSE;

-      break;

-

-      case OP_WHITESPACE:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_space];

-      try_next = FALSE;

-      break;

-

-      case OP_NOT_WORDCHAR:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= ~cd->cbits[c+cbit_word];

-      try_next = FALSE;

-      break;

-

-      case OP_WORDCHAR:

-      for (c = 0; c < 32; c++)

-        start_bits[c] |= cd->cbits[c+cbit_word];

-      try_next = FALSE;

-      break;

-

-      /* One or more character type fudges the pointer and restarts, knowing

-      it will hit a single character type and stop there. */

-

-      case OP_TYPEPLUS:

-      case OP_TYPEMINPLUS:

-      tcode++;

-      break;

-

-      case OP_TYPEEXACT:

-      tcode += 3;

-      break;

-

-      /* Zero or more repeats of character types set the bits and then

-      try again. */

-

-      case OP_TYPEUPTO:

-      case OP_TYPEMINUPTO:

-      tcode += 2;               /* Fall through */

-

-      case OP_TYPESTAR:

-      case OP_TYPEMINSTAR:

-      case OP_TYPEQUERY:

-      case OP_TYPEMINQUERY:

-      switch(tcode[1])

-        {

-        case OP_ANY:

-        return FALSE;

-

-        case OP_NOT_DIGIT:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_digit];

-        break;

-

-        case OP_DIGIT:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_digit];

-        break;

-

-        case OP_NOT_WHITESPACE:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_space];

-        break;

-

-        case OP_WHITESPACE:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_space];

-        break;

-

-        case OP_NOT_WORDCHAR:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= ~cd->cbits[c+cbit_word];

-        break;

-

-        case OP_WORDCHAR:

-        for (c = 0; c < 32; c++)

-          start_bits[c] |= cd->cbits[c+cbit_word];

-        break;

-        }

-

-      tcode += 2;

-      break;

-

-      /* Character class where all the information is in a bit map: set the

-      bits and either carry on or not, according to the repeat count. If it was

-      a negative class, and we are operating with UTF-8 characters, any byte

-      with a value >= 0xc4 is a potentially valid starter because it starts a

-      character with a value > 255. */

-

-      case OP_NCLASS:

-      if (utf8)

-        {

-        start_bits[24] |= 0xf0;              /* Bits for 0xc4 - 0xc8 */

-        memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */

-        }

-      /* Fall through */

-

-      case OP_CLASS:

-        {

-        tcode++;

-

-        /* In UTF-8 mode, the bits in a bit map correspond to character

-        values, not to byte values. However, the bit map we are constructing is

-        for byte values. So we have to do a conversion for characters whose

-        value is > 127. In fact, there are only two possible starting bytes for

-        characters in the range 128 - 255. */

-

-        if (utf8)

-          {

-          for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];

-          for (c = 128; c < 256; c++)

-            {

-            if ((tcode[c/8] && (1 << (c&7))) != 0)

-              {

-              int d = (c >> 6) | 0xc0;            /* Set bit for this starter */

-              start_bits[d/8] |= (1 << (d&7));    /* and then skip on to the */

-              c = (c & 0xc0) + 0x40 - 1;          /* next relevant character. */

-              }

-            }

-          }

-

-        /* In non-UTF-8 mode, the two bit maps are completely compatible. */

-

-        else

-          {

-          for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];

-          }

-

-        /* Advance past the bit map, and act on what follows */

-

-        tcode += 32;

-        switch (*tcode)

-          {

-          case OP_CRSTAR:

-          case OP_CRMINSTAR:

-          case OP_CRQUERY:

-          case OP_CRMINQUERY:

-          tcode++;

-          break;

-

-          case OP_CRRANGE:

-          case OP_CRMINRANGE:

-          if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;

-            else try_next = FALSE;

-          break;

-

-          default:

-          try_next = FALSE;

-          break;

-          }

-        }

-      break; /* End of bitmap class handling */

-

-      }      /* End of switch */

-    }        /* End of try_next loop */

-

-  code += GET(code, 1);   /* Advance to next branch */

-  }

-while (*code == OP_ALT);

-return TRUE;

-}

-

-

-

-/*************************************************

-*          Study a compiled expression           *

-*************************************************/

-

-/* This function is handed a compiled expression that it must study to produce

-information that will speed up the matching. It returns a pcre_extra block

-which then gets handed back to pcre_exec().

-

-Arguments:

-  re        points to the compiled expression

-  options   contains option bits

-  errorptr  points to where to place error messages;

-            set NULL unless error

-

-Returns:    pointer to a pcre_extra block, with study_data filled in and the

-              appropriate flag set;

-            NULL on error or if no optimization possible

-*/

-

-EXPORT pcre_extra *

-pcre_study(const pcre *external_re, int options, const char **errorptr)

-{

-uschar start_bits[32];

-pcre_extra *extra;

-pcre_study_data *study;

-const uschar *tables;

-const real_pcre *re = (const real_pcre *)external_re;

-uschar *code = (uschar *)re + re->name_table_offset +

-  (re->name_count * re->name_entry_size);

-compile_data compile_block;

-

-*errorptr = NULL;

-

-if (re == NULL || re->magic_number != MAGIC_NUMBER)

-  {

-  *errorptr = "argument is not a compiled regular expression";

-  return NULL;

-  }

-

-if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)

-  {

-  *errorptr = "unknown or incorrect option bit(s) set";

-  return NULL;

-  }

-

-/* For an anchored pattern, or an unanchored pattern that has a first char, or

-a multiline pattern that matches only at "line starts", no further processing

-at present. */

-

-if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)

-  return NULL;

-

-/* Set the character tables in the block that is passed around */

-

-tables = re->tables;

-if (tables == NULL)

-  (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,

-  (void *)(&tables));

-

-compile_block.lcc = tables + lcc_offset;

-compile_block.fcc = tables + fcc_offset;

-compile_block.cbits = tables + cbits_offset;

-compile_block.ctypes = tables + ctypes_offset;

-

-/* See if we can find a fixed set of initial characters for the pattern. */

-

-memset(start_bits, 0, 32 * sizeof(uschar));

-if (!set_start_bits(code, start_bits, (re->options & PCRE_CASELESS) != 0,

-  (re->options & PCRE_UTF8) != 0, &compile_block)) return NULL;

-

-/* Get a pcre_extra block and a pcre_study_data block. The study data is put in

-the latter, which is pointed to by the former, which may also get additional

-data set later by the calling program. At the moment, the size of

-pcre_study_data is fixed. We nevertheless save it in a field for returning via

-the pcre_fullinfo() function so that if it becomes variable in the future, we

-don't have to change that code. */

-

-extra = (pcre_extra *)(pcre_malloc)

-  (sizeof(pcre_extra) + sizeof(pcre_study_data));

-

-if (extra == NULL)

-  {

-  *errorptr = "failed to get memory";

-  return NULL;

-  }

-

-study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));

-extra->flags = PCRE_EXTRA_STUDY_DATA;

-extra->study_data = study;

-

-study->size = sizeof(pcre_study_data);

-study->options = PCRE_STUDY_MAPPED;

-memcpy(study->start_bits, start_bits, sizeof(start_bits));

-

-return extra;

-}

-

-/* End of pcre_study.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains some fixed tables that are used by more than one of the

-PCRE code modules. */

-

-

-

-

-/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that

-the definition is next to the definition of the opcodes in internal.h. */

-

-const uschar _pcre_OP_lengths[] = { OP_LENGTHS };

-

-

-

-/*************************************************

-*           Tables for UTF-8 support             *

-*************************************************/

-

-/* These are the breakpoints for different numbers of bytes in a UTF-8

-character. */

-

-const int _pcre_utf8_table1[] =

-  { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};

-

-const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1)/sizeof(int);

-

-/* These are the indicator bits and the mask for the data bits to set in the

-first byte of a character, indexed by the number of additional bytes. */

-

-const int _pcre_utf8_table2[] = { 0,    0xc0, 0xe0, 0xf0, 0xf8, 0xfc};

-const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};

-

-/* Table of the number of extra characters, indexed by the first character

-masked with 0x3f. The highest number for a valid UTF-8 character is in fact

-0x3d. */

-

-const uschar _pcre_utf8_table4[] = {

-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

-  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,

-  3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };

-

-/* This table translates Unicode property names into code values for the

-ucp_findchar() function. It is used by pcretest as well as by the library

-functions. */

-

-const ucp_type_table _pcre_utt[] = {

-  { "C",  128 + ucp_C },

-  { "Cc", ucp_Cc },

-  { "Cf", ucp_Cf },

-  { "Cn", ucp_Cn },

-  { "Co", ucp_Co },

-  { "Cs", ucp_Cs },

-  { "L",  128 + ucp_L },

-  { "Ll", ucp_Ll },

-  { "Lm", ucp_Lm },

-  { "Lo", ucp_Lo },

-  { "Lt", ucp_Lt },

-  { "Lu", ucp_Lu },

-  { "M",  128 + ucp_M },

-  { "Mc", ucp_Mc },

-  { "Me", ucp_Me },

-  { "Mn", ucp_Mn },

-  { "N",  128 + ucp_N },

-  { "Nd", ucp_Nd },

-  { "Nl", ucp_Nl },

-  { "No", ucp_No },

-  { "P",  128 + ucp_P },

-  { "Pc", ucp_Pc },

-  { "Pd", ucp_Pd },

-  { "Pe", ucp_Pe },

-  { "Pf", ucp_Pf },

-  { "Pi", ucp_Pi },

-  { "Po", ucp_Po },

-  { "Ps", ucp_Ps },

-  { "S",  128 + ucp_S },

-  { "Sc", ucp_Sc },

-  { "Sk", ucp_Sk },

-  { "Sm", ucp_Sm },

-  { "So", ucp_So },

-  { "Z",  128 + ucp_Z },

-  { "Zl", ucp_Zl },

-  { "Zp", ucp_Zp },

-  { "Zs", ucp_Zs }

-};

-

-const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);

-

-/* End of pcre_tables.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function that tests a compiled pattern to

-see if it was compiled with the opposite endianness. If so, it uses an

-auxiliary local function to flip the appropriate bytes. */

-

-

-

-

-/*************************************************

-*         Flip bytes in an integer               *

-*************************************************/

-

-/* This function is called when the magic number in a regex doesn't match, in

-order to flip its bytes to see if we are dealing with a pattern that was

-compiled on a host of different endianness. If so, this function is used to

-flip other byte values.

-

-Arguments:

-  value        the number to flip

-  n            the number of bytes to flip (assumed to be 2 or 4)

-

-Returns:       the flipped value

-*/

-

-static long int

-byteflip(long int value, int n)

-{

-if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);

-return ((value & 0x000000ff) << 24) |

-       ((value & 0x0000ff00) <<  8) |

-       ((value & 0x00ff0000) >>  8) |

-       ((value & 0xff000000) >> 24);

-}

-

-

-

-/*************************************************

-*       Test for a byte-flipped compiled regex   *

-*************************************************/

-

-/* This function is called from pcre_exec(), pcre_dfa_exec(), and also from

-pcre_fullinfo(). Its job is to test whether the regex is byte-flipped - that

-is, it was compiled on a system of opposite endianness. The function is called

-only when the native MAGIC_NUMBER test fails. If the regex is indeed flipped,

-we flip all the relevant values into a different data block, and return it.

-

-Arguments:

-  re               points to the regex

-  study            points to study data, or NULL

-  internal_re      points to a new regex block

-  internal_study   points to a new study block

-

-Returns:           the new block if is is indeed a byte-flipped regex

-                   NULL if it is not

-*/

-

-EXPORT real_pcre *

-_pcre_try_flipped(const real_pcre *re, real_pcre *internal_re,

-  const pcre_study_data *study, pcre_study_data *internal_study)

-{

-if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)

-  return NULL;

-

-*internal_re = *re;           /* To copy other fields */

-internal_re->size = byteflip(re->size, sizeof(re->size));

-internal_re->options = byteflip(re->options, sizeof(re->options));

-internal_re->top_bracket =

-  (pcre_uint16)byteflip(re->top_bracket, sizeof(re->top_bracket));

-internal_re->top_backref =

-  (pcre_uint16)byteflip(re->top_backref, sizeof(re->top_backref));

-internal_re->first_byte =

-  (pcre_uint16)byteflip(re->first_byte, sizeof(re->first_byte));

-internal_re->req_byte =

-  (pcre_uint16)byteflip(re->req_byte, sizeof(re->req_byte));

-internal_re->name_table_offset =

-  (pcre_uint16)byteflip(re->name_table_offset, sizeof(re->name_table_offset));

-internal_re->name_entry_size =

-  (pcre_uint16)byteflip(re->name_entry_size, sizeof(re->name_entry_size));

-internal_re->name_count =

-  (pcre_uint16)byteflip(re->name_count, sizeof(re->name_count));

-

-if (study != NULL)

-  {

-  *internal_study = *study;   /* To copy other fields */

-  internal_study->size = byteflip(study->size, sizeof(study->size));

-  internal_study->options = byteflip(study->options, sizeof(study->options));

-  }

-

-return internal_re;

-}

-

-/* End of pcre_tryflipped.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module compiles code for supporting the use of Unicode character

-properties. We use the (embryonic at the time of writing) UCP library, by

-including some of its files, copies of which have been put in the PCRE

-distribution. There is a macro in pcre_internal.h that changes the name

-ucp_findchar into _pcre_ucp_findchar. */

-

-

-

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-/* Copyright (c) University of Cambridge 2004 */

-

-/* This little library provides a fast way of obtaining the basic Unicode

-properties of a character, using a compact binary tree that occupies less than

-100K bytes.

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/*************************************************

-*     libucp - Unicode Property Table handler    *

-*************************************************/

-

-/* Internal header file defining the layout of compact nodes in the tree. */

-

-typedef struct cnode {

-  unsigned short int f0;

-  unsigned short int f1;

-  unsigned short int f2;

-} cnode;

-

-/* Things for the f0 field */

-

-#define f0_leftexists   0x8000    /* Left child exists */

-#define f0_typemask     0x3f00    /* Type bits */

-#define f0_typeshift         8    /* Type shift */

-#define f0_chhmask      0x00ff    /* Character high bits */

-

-/* Things for the f2 field */

-

-#define f2_rightmask    0xf000    /* Mask for right offset bits */

-#define f2_rightshift       12    /* Shift for right offset */

-#define f2_casemask     0x0fff    /* Mask for case offset */

-

-/* The tree consists of a vector of structures of type cnode, with the root

-node as the first element. The three short ints (16-bits) are used as follows:

-

-(f0) (1) The 0x8000 bit of f0 is set if a left child exists. The child's node

-         is the next node in the vector.

-     (2) The 0x4000 bits of f0 is spare.

-     (3) The 0x3f00 bits of f0 contain the character type; this is a number

-         defined by the enumeration in ucp.h (e.g. ucp_Lu).

-     (4) The bottom 8 bits of f0 contain the most significant byte of the

-         character's 24-bit codepoint.

-

-(f1) (1) The f1 field contains the two least significant bytes of the

-         codepoint.

-

-(f2) (1) The 0xf000 bits of f2 contain zero if there is no right child of this

-         node. Otherwise, they contain one plus the exponent of the power of

-         two of the offset to the right node (e.g. a value of 3 means 8). The

-         units of the offset are node items.

-

-     (2) The 0x0fff bits of f2 contain the signed offset from this character to

-         its alternate cased value. They are zero if there is no such

-         character.

-

-

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

-||.|.| type (6) | ms char (8) ||  ls char (16)  ||....|  case offset (12)  ||

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

-  | |                                              |

-  | |-> spare                                      |

-  |                                        exponent of right

-  |-> left child exists                       child offset

-

-

-The upper/lower casing information is set only for characters that come in

-pairs. There are (at present) four non-one-to-one mappings in the Unicode data.

-These are ignored. They are:

-

-  1FBE Greek Prosgegrammeni (lower, with upper -> capital iota)

-  2126 Ohm

-  212A Kelvin

-  212B Angstrom

-

-Certainly for the last three, having an alternate case would seem to be a

-mistake. I don't know any Greek, so cannot comment on the first one.

-

-

-When searching the tree, proceed as follows:

-

-(1) Start at the first node.

-

-(2) Extract the character value from f1 and the bottom 8 bits of f0;

-

-(3) Compare with the character being sought. If equal, we are done.

-

-(4) If the test character is smaller, inspect the f0_leftexists flag. If it is

-    not set, the character is not in the tree. If it is set, move to the next

-    node, and go to (2).

-

-(5) If the test character is bigger, extract the f2_rightmask bits from f2, and

-    shift them right by f2_rightshift. If the result is zero, the character is

-    not in the tree. Otherwise, calculate the number of nodes to skip by

-    shifting the value 1 left by this number minus one. Go to (2).

-*/

-

-

-/* End of internal.h */

-/* This source module is automatically generated from the Unicode

-property table. See internal.h for a description of the layout. */

-

-static cnode ucp_table[] = {

-  { 0x9a00, 0x2f1f, 0xe000 },

-  { 0x8700, 0x1558, 0xd000 },

-  { 0x8700, 0x0a99, 0xc000 },

-  { 0x8500, 0x0435, 0xbfe0 },

-  { 0x8500, 0x01ff, 0xafff },

-  { 0x8500, 0x00ff, 0x9079 },

-  { 0x8000, 0x007f, 0x8000 },

-  { 0x9500, 0x003f, 0x7000 },

-  { 0x8000, 0x001f, 0x6000 },

-  { 0x8000, 0x000f, 0x5000 },

-  { 0x8000, 0x0007, 0x4000 },

-  { 0x8000, 0x0003, 0x3000 },

-  { 0x8000, 0x0001, 0x2000 },

-  { 0x0000, 0x0000, 0x0000 },

-  { 0x0000, 0x0002, 0x0000 },

-  { 0x8000, 0x0005, 0x2000 },

-  { 0x0000, 0x0004, 0x0000 },

-  { 0x0000, 0x0006, 0x0000 },

-  { 0x8000, 0x000b, 0x3000 },

-  { 0x8000, 0x0009, 0x2000 },

-  { 0x0000, 0x0008, 0x0000 },

-  { 0x0000, 0x000a, 0x0000 },

-  { 0x8000, 0x000d, 0x2000 },

-  { 0x0000, 0x000c, 0x0000 },

-  { 0x0000, 0x000e, 0x0000 },

-  { 0x8000, 0x0017, 0x4000 },

-  { 0x8000, 0x0013, 0x3000 },

-  { 0x8000, 0x0011, 0x2000 },

-  { 0x0000, 0x0010, 0x0000 },

-  { 0x0000, 0x0012, 0x0000 },

-  { 0x8000, 0x0015, 0x2000 },

-  { 0x0000, 0x0014, 0x0000 },

-  { 0x0000, 0x0016, 0x0000 },

-  { 0x8000, 0x001b, 0x3000 },

-  { 0x8000, 0x0019, 0x2000 },

-  { 0x0000, 0x0018, 0x0000 },

-  { 0x0000, 0x001a, 0x0000 },

-  { 0x8000, 0x001d, 0x2000 },

-  { 0x0000, 0x001c, 0x0000 },

-  { 0x0000, 0x001e, 0x0000 },

-  { 0x9500, 0x002f, 0x5000 },

-  { 0x9500, 0x0027, 0x4000 },

-  { 0x9500, 0x0023, 0x3000 },

-  { 0x9500, 0x0021, 0x2000 },

-  { 0x1d00, 0x0020, 0x0000 },

-  { 0x1500, 0x0022, 0x0000 },

-  { 0x9500, 0x0025, 0x2000 },

-  { 0x1700, 0x0024, 0x0000 },

-  { 0x1500, 0x0026, 0x0000 },

-  { 0x9900, 0x002b, 0x3000 },

-  { 0x9200, 0x0029, 0x2000 },

-  { 0x1600, 0x0028, 0x0000 },

-  { 0x1500, 0x002a, 0x0000 },

-  { 0x9100, 0x002d, 0x2000 },

-  { 0x1500, 0x002c, 0x0000 },

-  { 0x1500, 0x002e, 0x0000 },

-  { 0x8d00, 0x0037, 0x4000 },

-  { 0x8d00, 0x0033, 0x3000 },

-  { 0x8d00, 0x0031, 0x2000 },

-  { 0x0d00, 0x0030, 0x0000 },

-  { 0x0d00, 0x0032, 0x0000 },

-  { 0x8d00, 0x0035, 0x2000 },

-  { 0x0d00, 0x0034, 0x0000 },

-  { 0x0d00, 0x0036, 0x0000 },

-  { 0x9500, 0x003b, 0x3000 },

-  { 0x8d00, 0x0039, 0x2000 },

-  { 0x0d00, 0x0038, 0x0000 },

-  { 0x1500, 0x003a, 0x0000 },

-  { 0x9900, 0x003d, 0x2000 },

-  { 0x1900, 0x003c, 0x0000 },

-  { 0x1900, 0x003e, 0x0000 },

-  { 0x9000, 0x005f, 0x6000 },

-  { 0x8900, 0x004f, 0x5020 },

-  { 0x8900, 0x0047, 0x4020 },

-  { 0x8900, 0x0043, 0x3020 },

-  { 0x8900, 0x0041, 0x2020 },

-  { 0x1500, 0x0040, 0x0000 },

-  { 0x0900, 0x0042, 0x0020 },

-  { 0x8900, 0x0045, 0x2020 },

-  { 0x0900, 0x0044, 0x0020 },

-  { 0x0900, 0x0046, 0x0020 },

-  { 0x8900, 0x004b, 0x3020 },

-  { 0x8900, 0x0049, 0x2020 },

-  { 0x0900, 0x0048, 0x0020 },

-  { 0x0900, 0x004a, 0x0020 },

-  { 0x8900, 0x004d, 0x2020 },

-  { 0x0900, 0x004c, 0x0020 },

-  { 0x0900, 0x004e, 0x0020 },

-  { 0x8900, 0x0057, 0x4020 },

-  { 0x8900, 0x0053, 0x3020 },

-  { 0x8900, 0x0051, 0x2020 },

-  { 0x0900, 0x0050, 0x0020 },

-  { 0x0900, 0x0052, 0x0020 },

-  { 0x8900, 0x0055, 0x2020 },

-  { 0x0900, 0x0054, 0x0020 },

-  { 0x0900, 0x0056, 0x0020 },

-  { 0x9600, 0x005b, 0x3000 },

-  { 0x8900, 0x0059, 0x2020 },

-  { 0x0900, 0x0058, 0x0020 },

-  { 0x0900, 0x005a, 0x0020 },

-  { 0x9200, 0x005d, 0x2000 },

-  { 0x1500, 0x005c, 0x0000 },

-  { 0x1800, 0x005e, 0x0000 },

-  { 0x8500, 0x006f, 0x5fe0 },

-  { 0x8500, 0x0067, 0x4fe0 },

-  { 0x8500, 0x0063, 0x3fe0 },

-  { 0x8500, 0x0061, 0x2fe0 },

-  { 0x1800, 0x0060, 0x0000 },

-  { 0x0500, 0x0062, 0x0fe0 },

-  { 0x8500, 0x0065, 0x2fe0 },

-  { 0x0500, 0x0064, 0x0fe0 },

-  { 0x0500, 0x0066, 0x0fe0 },

-  { 0x8500, 0x006b, 0x3fe0 },

-  { 0x8500, 0x0069, 0x2fe0 },

-  { 0x0500, 0x0068, 0x0fe0 },

-  { 0x0500, 0x006a, 0x0fe0 },

-  { 0x8500, 0x006d, 0x2fe0 },

-  { 0x0500, 0x006c, 0x0fe0 },

-  { 0x0500, 0x006e, 0x0fe0 },

-  { 0x8500, 0x0077, 0x4fe0 },

-  { 0x8500, 0x0073, 0x3fe0 },

-  { 0x8500, 0x0071, 0x2fe0 },

-  { 0x0500, 0x0070, 0x0fe0 },

-  { 0x0500, 0x0072, 0x0fe0 },

-  { 0x8500, 0x0075, 0x2fe0 },

-  { 0x0500, 0x0074, 0x0fe0 },

-  { 0x0500, 0x0076, 0x0fe0 },

-  { 0x9600, 0x007b, 0x3000 },

-  { 0x8500, 0x0079, 0x2fe0 },

-  { 0x0500, 0x0078, 0x0fe0 },

-  { 0x0500, 0x007a, 0x0fe0 },

-  { 0x9200, 0x007d, 0x2000 },

-  { 0x1900, 0x007c, 0x0000 },

-  { 0x1900, 0x007e, 0x0000 },

-  { 0x9500, 0x00bf, 0x7000 },

-  { 0x8000, 0x009f, 0x6000 },

-  { 0x8000, 0x008f, 0x5000 },

-  { 0x8000, 0x0087, 0x4000 },

-  { 0x8000, 0x0083, 0x3000 },

-  { 0x8000, 0x0081, 0x2000 },

-  { 0x0000, 0x0080, 0x0000 },

-  { 0x0000, 0x0082, 0x0000 },

-  { 0x8000, 0x0085, 0x2000 },

-  { 0x0000, 0x0084, 0x0000 },

-  { 0x0000, 0x0086, 0x0000 },

-  { 0x8000, 0x008b, 0x3000 },

-  { 0x8000, 0x0089, 0x2000 },

-  { 0x0000, 0x0088, 0x0000 },

-  { 0x0000, 0x008a, 0x0000 },

-  { 0x8000, 0x008d, 0x2000 },

-  { 0x0000, 0x008c, 0x0000 },

-  { 0x0000, 0x008e, 0x0000 },

-  { 0x8000, 0x0097, 0x4000 },

-  { 0x8000, 0x0093, 0x3000 },

-  { 0x8000, 0x0091, 0x2000 },

-  { 0x0000, 0x0090, 0x0000 },

-  { 0x0000, 0x0092, 0x0000 },

-  { 0x8000, 0x0095, 0x2000 },

-  { 0x0000, 0x0094, 0x0000 },

-  { 0x0000, 0x0096, 0x0000 },

-  { 0x8000, 0x009b, 0x3000 },

-  { 0x8000, 0x0099, 0x2000 },

-  { 0x0000, 0x0098, 0x0000 },

-  { 0x0000, 0x009a, 0x0000 },

-  { 0x8000, 0x009d, 0x2000 },

-  { 0x0000, 0x009c, 0x0000 },

-  { 0x0000, 0x009e, 0x0000 },

-  { 0x9800, 0x00af, 0x5000 },

-  { 0x9a00, 0x00a7, 0x4000 },

-  { 0x9700, 0x00a3, 0x3000 },

-  { 0x9500, 0x00a1, 0x2000 },

-  { 0x1d00, 0x00a0, 0x0000 },

-  { 0x1700, 0x00a2, 0x0000 },

-  { 0x9700, 0x00a5, 0x2000 },

-  { 0x1700, 0x00a4, 0x0000 },

-  { 0x1a00, 0x00a6, 0x0000 },

-  { 0x9400, 0x00ab, 0x3000 },

-  { 0x9a00, 0x00a9, 0x2000 },

-  { 0x1800, 0x00a8, 0x0000 },

-  { 0x0500, 0x00aa, 0x0000 },

-  { 0x8100, 0x00ad, 0x2000 },

-  { 0x1900, 0x00ac, 0x0000 },

-  { 0x1a00, 0x00ae, 0x0000 },

-  { 0x9500, 0x00b7, 0x4000 },

-  { 0x8f00, 0x00b3, 0x3000 },

-  { 0x9900, 0x00b1, 0x2000 },

-  { 0x1a00, 0x00b0, 0x0000 },

-  { 0x0f00, 0x00b2, 0x0000 },

-  { 0x8500, 0x00b5, 0x22e7 },

-  { 0x1800, 0x00b4, 0x0000 },

-  { 0x1a00, 0x00b6, 0x0000 },

-  { 0x9300, 0x00bb, 0x3000 },

-  { 0x8f00, 0x00b9, 0x2000 },

-  { 0x1800, 0x00b8, 0x0000 },

-  { 0x0500, 0x00ba, 0x0000 },

-  { 0x8f00, 0x00bd, 0x2000 },

-  { 0x0f00, 0x00bc, 0x0000 },

-  { 0x0f00, 0x00be, 0x0000 },

-  { 0x8500, 0x00df, 0x6000 },

-  { 0x8900, 0x00cf, 0x5020 },

-  { 0x8900, 0x00c7, 0x4020 },

-  { 0x8900, 0x00c3, 0x3020 },

-  { 0x8900, 0x00c1, 0x2020 },

-  { 0x0900, 0x00c0, 0x0020 },

-  { 0x0900, 0x00c2, 0x0020 },

-  { 0x8900, 0x00c5, 0x2020 },

-  { 0x0900, 0x00c4, 0x0020 },

-  { 0x0900, 0x00c6, 0x0020 },

-  { 0x8900, 0x00cb, 0x3020 },

-  { 0x8900, 0x00c9, 0x2020 },

-  { 0x0900, 0x00c8, 0x0020 },

-  { 0x0900, 0x00ca, 0x0020 },

-  { 0x8900, 0x00cd, 0x2020 },

-  { 0x0900, 0x00cc, 0x0020 },

-  { 0x0900, 0x00ce, 0x0020 },

-  { 0x9900, 0x00d7, 0x4000 },

-  { 0x8900, 0x00d3, 0x3020 },

-  { 0x8900, 0x00d1, 0x2020 },

-  { 0x0900, 0x00d0, 0x0020 },

-  { 0x0900, 0x00d2, 0x0020 },

-  { 0x8900, 0x00d5, 0x2020 },

-  { 0x0900, 0x00d4, 0x0020 },

-  { 0x0900, 0x00d6, 0x0020 },

-  { 0x8900, 0x00db, 0x3020 },

-  { 0x8900, 0x00d9, 0x2020 },

-  { 0x0900, 0x00d8, 0x0020 },

-  { 0x0900, 0x00da, 0x0020 },

-  { 0x8900, 0x00dd, 0x2020 },

-  { 0x0900, 0x00dc, 0x0020 },

-  { 0x0900, 0x00de, 0x0020 },

-  { 0x8500, 0x00ef, 0x5fe0 },

-  { 0x8500, 0x00e7, 0x4fe0 },

-  { 0x8500, 0x00e3, 0x3fe0 },

-  { 0x8500, 0x00e1, 0x2fe0 },

-  { 0x0500, 0x00e0, 0x0fe0 },

-  { 0x0500, 0x00e2, 0x0fe0 },

-  { 0x8500, 0x00e5, 0x2fe0 },

-  { 0x0500, 0x00e4, 0x0fe0 },

-  { 0x0500, 0x00e6, 0x0fe0 },

-  { 0x8500, 0x00eb, 0x3fe0 },

-  { 0x8500, 0x00e9, 0x2fe0 },

-  { 0x0500, 0x00e8, 0x0fe0 },

-  { 0x0500, 0x00ea, 0x0fe0 },

-  { 0x8500, 0x00ed, 0x2fe0 },

-  { 0x0500, 0x00ec, 0x0fe0 },

-  { 0x0500, 0x00ee, 0x0fe0 },

-  { 0x9900, 0x00f7, 0x4000 },

-  { 0x8500, 0x00f3, 0x3fe0 },

-  { 0x8500, 0x00f1, 0x2fe0 },

-  { 0x0500, 0x00f0, 0x0fe0 },

-  { 0x0500, 0x00f2, 0x0fe0 },

-  { 0x8500, 0x00f5, 0x2fe0 },

-  { 0x0500, 0x00f4, 0x0fe0 },

-  { 0x0500, 0x00f6, 0x0fe0 },

-  { 0x8500, 0x00fb, 0x3fe0 },

-  { 0x8500, 0x00f9, 0x2fe0 },

-  { 0x0500, 0x00f8, 0x0fe0 },

-  { 0x0500, 0x00fa, 0x0fe0 },

-  { 0x8500, 0x00fd, 0x2fe0 },

-  { 0x0500, 0x00fc, 0x0fe0 },

-  { 0x0500, 0x00fe, 0x0fe0 },

-  { 0x8500, 0x017f, 0x8ed4 },

-  { 0x8900, 0x013f, 0x7001 },

-  { 0x8500, 0x011f, 0x6fff },

-  { 0x8500, 0x010f, 0x5fff },

-  { 0x8500, 0x0107, 0x4fff },

-  { 0x8500, 0x0103, 0x3fff },

-  { 0x8500, 0x0101, 0x2fff },

-  { 0x0900, 0x0100, 0x0001 },

-  { 0x0900, 0x0102, 0x0001 },

-  { 0x8500, 0x0105, 0x2fff },

-  { 0x0900, 0x0104, 0x0001 },

-  { 0x0900, 0x0106, 0x0001 },

-  { 0x8500, 0x010b, 0x3fff },

-  { 0x8500, 0x0109, 0x2fff },

-  { 0x0900, 0x0108, 0x0001 },

-  { 0x0900, 0x010a, 0x0001 },

-  { 0x8500, 0x010d, 0x2fff },

-  { 0x0900, 0x010c, 0x0001 },

-  { 0x0900, 0x010e, 0x0001 },

-  { 0x8500, 0x0117, 0x4fff },

-  { 0x8500, 0x0113, 0x3fff },

-  { 0x8500, 0x0111, 0x2fff },

-  { 0x0900, 0x0110, 0x0001 },

-  { 0x0900, 0x0112, 0x0001 },

-  { 0x8500, 0x0115, 0x2fff },

-  { 0x0900, 0x0114, 0x0001 },

-  { 0x0900, 0x0116, 0x0001 },

-  { 0x8500, 0x011b, 0x3fff },

-  { 0x8500, 0x0119, 0x2fff },

-  { 0x0900, 0x0118, 0x0001 },

-  { 0x0900, 0x011a, 0x0001 },

-  { 0x8500, 0x011d, 0x2fff },

-  { 0x0900, 0x011c, 0x0001 },

-  { 0x0900, 0x011e, 0x0001 },

-  { 0x8500, 0x012f, 0x5fff },

-  { 0x8500, 0x0127, 0x4fff },

-  { 0x8500, 0x0123, 0x3fff },

-  { 0x8500, 0x0121, 0x2fff },

-  { 0x0900, 0x0120, 0x0001 },

-  { 0x0900, 0x0122, 0x0001 },

-  { 0x8500, 0x0125, 0x2fff },

-  { 0x0900, 0x0124, 0x0001 },

-  { 0x0900, 0x0126, 0x0001 },

-  { 0x8500, 0x012b, 0x3fff },

-  { 0x8500, 0x0129, 0x2fff },

-  { 0x0900, 0x0128, 0x0001 },

-  { 0x0900, 0x012a, 0x0001 },

-  { 0x8500, 0x012d, 0x2fff },

-  { 0x0900, 0x012c, 0x0001 },

-  { 0x0900, 0x012e, 0x0001 },

-  { 0x8500, 0x0137, 0x4fff },

-  { 0x8500, 0x0133, 0x3fff },

-  { 0x8500, 0x0131, 0x2f18 },

-  { 0x0900, 0x0130, 0x0f39 },

-  { 0x0900, 0x0132, 0x0001 },

-  { 0x8500, 0x0135, 0x2fff },

-  { 0x0900, 0x0134, 0x0001 },

-  { 0x0900, 0x0136, 0x0001 },

-  { 0x8900, 0x013b, 0x3001 },

-  { 0x8900, 0x0139, 0x2001 },

-  { 0x0500, 0x0138, 0x0000 },

-  { 0x0500, 0x013a, 0x0fff },

-  { 0x8900, 0x013d, 0x2001 },

-  { 0x0500, 0x013c, 0x0fff },

-  { 0x0500, 0x013e, 0x0fff },

-  { 0x8500, 0x015f, 0x6fff },

-  { 0x8500, 0x014f, 0x5fff },

-  { 0x8900, 0x0147, 0x4001 },

-  { 0x8900, 0x0143, 0x3001 },

-  { 0x8900, 0x0141, 0x2001 },

-  { 0x0500, 0x0140, 0x0fff },

-  { 0x0500, 0x0142, 0x0fff },

-  { 0x8900, 0x0145, 0x2001 },

-  { 0x0500, 0x0144, 0x0fff },

-  { 0x0500, 0x0146, 0x0fff },

-  { 0x8500, 0x014b, 0x3fff },

-  { 0x8500, 0x0149, 0x2000 },

-  { 0x0500, 0x0148, 0x0fff },

-  { 0x0900, 0x014a, 0x0001 },

-  { 0x8500, 0x014d, 0x2fff },

-  { 0x0900, 0x014c, 0x0001 },

-  { 0x0900, 0x014e, 0x0001 },

-  { 0x8500, 0x0157, 0x4fff },

-  { 0x8500, 0x0153, 0x3fff },

-  { 0x8500, 0x0151, 0x2fff },

-  { 0x0900, 0x0150, 0x0001 },

-  { 0x0900, 0x0152, 0x0001 },

-  { 0x8500, 0x0155, 0x2fff },

-  { 0x0900, 0x0154, 0x0001 },

-  { 0x0900, 0x0156, 0x0001 },

-  { 0x8500, 0x015b, 0x3fff },

-  { 0x8500, 0x0159, 0x2fff },

-  { 0x0900, 0x0158, 0x0001 },

-  { 0x0900, 0x015a, 0x0001 },

-  { 0x8500, 0x015d, 0x2fff },

-  { 0x0900, 0x015c, 0x0001 },

-  { 0x0900, 0x015e, 0x0001 },

-  { 0x8500, 0x016f, 0x5fff },

-  { 0x8500, 0x0167, 0x4fff },

-  { 0x8500, 0x0163, 0x3fff },

-  { 0x8500, 0x0161, 0x2fff },

-  { 0x0900, 0x0160, 0x0001 },

-  { 0x0900, 0x0162, 0x0001 },

-  { 0x8500, 0x0165, 0x2fff },

-  { 0x0900, 0x0164, 0x0001 },

-  { 0x0900, 0x0166, 0x0001 },

-  { 0x8500, 0x016b, 0x3fff },

-  { 0x8500, 0x0169, 0x2fff },

-  { 0x0900, 0x0168, 0x0001 },

-  { 0x0900, 0x016a, 0x0001 },

-  { 0x8500, 0x016d, 0x2fff },

-  { 0x0900, 0x016c, 0x0001 },

-  { 0x0900, 0x016e, 0x0001 },

-  { 0x8500, 0x0177, 0x4fff },

-  { 0x8500, 0x0173, 0x3fff },

-  { 0x8500, 0x0171, 0x2fff },

-  { 0x0900, 0x0170, 0x0001 },

-  { 0x0900, 0x0172, 0x0001 },

-  { 0x8500, 0x0175, 0x2fff },

-  { 0x0900, 0x0174, 0x0001 },

-  { 0x0900, 0x0176, 0x0001 },

-  { 0x8900, 0x017b, 0x3001 },

-  { 0x8900, 0x0179, 0x2001 },

-  { 0x0900, 0x0178, 0x0f87 },

-  { 0x0500, 0x017a, 0x0fff },

-  { 0x8900, 0x017d, 0x2001 },

-  { 0x0500, 0x017c, 0x0fff },

-  { 0x0500, 0x017e, 0x0fff },

-  { 0x8500, 0x01bf, 0x7038 },

-  { 0x8900, 0x019f, 0x60d6 },

-  { 0x8900, 0x018f, 0x50ca },

-  { 0x8900, 0x0187, 0x4001 },

-  { 0x8500, 0x0183, 0x3fff },

-  { 0x8900, 0x0181, 0x20d2 },

-  { 0x0500, 0x0180, 0x0000 },

-  { 0x0900, 0x0182, 0x0001 },

-  { 0x8500, 0x0185, 0x2fff },

-  { 0x0900, 0x0184, 0x0001 },

-  { 0x0900, 0x0186, 0x00ce },

-  { 0x8900, 0x018b, 0x3001 },

-  { 0x8900, 0x0189, 0x20cd },

-  { 0x0500, 0x0188, 0x0fff },

-  { 0x0900, 0x018a, 0x00cd },

-  { 0x8500, 0x018d, 0x2000 },

-  { 0x0500, 0x018c, 0x0fff },

-  { 0x0900, 0x018e, 0x004f },

-  { 0x8900, 0x0197, 0x40d1 },

-  { 0x8900, 0x0193, 0x30cd },

-  { 0x8900, 0x0191, 0x2001 },

-  { 0x0900, 0x0190, 0x00cb },

-  { 0x0500, 0x0192, 0x0fff },

-  { 0x8500, 0x0195, 0x2061 },

-  { 0x0900, 0x0194, 0x00cf },

-  { 0x0900, 0x0196, 0x00d3 },

-  { 0x8500, 0x019b, 0x3000 },

-  { 0x8500, 0x0199, 0x2fff },

-  { 0x0900, 0x0198, 0x0001 },

-  { 0x0500, 0x019a, 0x0000 },

-  { 0x8900, 0x019d, 0x20d5 },

-  { 0x0900, 0x019c, 0x00d3 },

-  { 0x0500, 0x019e, 0x0082 },

-  { 0x8900, 0x01af, 0x5001 },

-  { 0x8900, 0x01a7, 0x4001 },

-  { 0x8500, 0x01a3, 0x3fff },

-  { 0x8500, 0x01a1, 0x2fff },

-  { 0x0900, 0x01a0, 0x0001 },

-  { 0x0900, 0x01a2, 0x0001 },

-  { 0x8500, 0x01a5, 0x2fff },

-  { 0x0900, 0x01a4, 0x0001 },

-  { 0x0900, 0x01a6, 0x00da },

-  { 0x8500, 0x01ab, 0x3000 },

-  { 0x8900, 0x01a9, 0x20da },

-  { 0x0500, 0x01a8, 0x0fff },

-  { 0x0500, 0x01aa, 0x0000 },

-  { 0x8500, 0x01ad, 0x2fff },

-  { 0x0900, 0x01ac, 0x0001 },

-  { 0x0900, 0x01ae, 0x00da },

-  { 0x8900, 0x01b7, 0x40db },

-  { 0x8900, 0x01b3, 0x3001 },

-  { 0x8900, 0x01b1, 0x20d9 },

-  { 0x0500, 0x01b0, 0x0fff },

-  { 0x0900, 0x01b2, 0x00d9 },

-  { 0x8900, 0x01b5, 0x2001 },

-  { 0x0500, 0x01b4, 0x0fff },

-  { 0x0500, 0x01b6, 0x0fff },

-  { 0x8700, 0x01bb, 0x3000 },

-  { 0x8500, 0x01b9, 0x2fff },

-  { 0x0900, 0x01b8, 0x0001 },

-  { 0x0500, 0x01ba, 0x0000 },

-  { 0x8500, 0x01bd, 0x2fff },

-  { 0x0900, 0x01bc, 0x0001 },

-  { 0x0500, 0x01be, 0x0000 },

-  { 0x8500, 0x01df, 0x6fff },

-  { 0x8900, 0x01cf, 0x5001 },

-  { 0x8900, 0x01c7, 0x4002 },

-  { 0x8700, 0x01c3, 0x3000 },

-  { 0x8700, 0x01c1, 0x2000 },

-  { 0x0700, 0x01c0, 0x0000 },

-  { 0x0700, 0x01c2, 0x0000 },

-  { 0x8800, 0x01c5, 0x2000 },

-  { 0x0900, 0x01c4, 0x0002 },

-  { 0x0500, 0x01c6, 0x0ffe },

-  { 0x8800, 0x01cb, 0x3000 },

-  { 0x8500, 0x01c9, 0x2ffe },

-  { 0x0800, 0x01c8, 0x0000 },

-  { 0x0900, 0x01ca, 0x0002 },

-  { 0x8900, 0x01cd, 0x2001 },

-  { 0x0500, 0x01cc, 0x0ffe },

-  { 0x0500, 0x01ce, 0x0fff },

-  { 0x8900, 0x01d7, 0x4001 },

-  { 0x8900, 0x01d3, 0x3001 },

-  { 0x8900, 0x01d1, 0x2001 },

-  { 0x0500, 0x01d0, 0x0fff },

-  { 0x0500, 0x01d2, 0x0fff },

-  { 0x8900, 0x01d5, 0x2001 },

-  { 0x0500, 0x01d4, 0x0fff },

-  { 0x0500, 0x01d6, 0x0fff },

-  { 0x8900, 0x01db, 0x3001 },

-  { 0x8900, 0x01d9, 0x2001 },

-  { 0x0500, 0x01d8, 0x0fff },

-  { 0x0500, 0x01da, 0x0fff },

-  { 0x8500, 0x01dd, 0x2fb1 },

-  { 0x0500, 0x01dc, 0x0fff },

-  { 0x0900, 0x01de, 0x0001 },

-  { 0x8500, 0x01ef, 0x5fff },

-  { 0x8500, 0x01e7, 0x4fff },

-  { 0x8500, 0x01e3, 0x3fff },

-  { 0x8500, 0x01e1, 0x2fff },

-  { 0x0900, 0x01e0, 0x0001 },

-  { 0x0900, 0x01e2, 0x0001 },

-  { 0x8500, 0x01e5, 0x2fff },

-  { 0x0900, 0x01e4, 0x0001 },

-  { 0x0900, 0x01e6, 0x0001 },

-  { 0x8500, 0x01eb, 0x3fff },

-  { 0x8500, 0x01e9, 0x2fff },

-  { 0x0900, 0x01e8, 0x0001 },

-  { 0x0900, 0x01ea, 0x0001 },

-  { 0x8500, 0x01ed, 0x2fff },

-  { 0x0900, 0x01ec, 0x0001 },

-  { 0x0900, 0x01ee, 0x0001 },

-  { 0x8900, 0x01f7, 0x4fc8 },

-  { 0x8500, 0x01f3, 0x3ffe },

-  { 0x8900, 0x01f1, 0x2002 },

-  { 0x0500, 0x01f0, 0x0000 },

-  { 0x0800, 0x01f2, 0x0000 },

-  { 0x8500, 0x01f5, 0x2fff },

-  { 0x0900, 0x01f4, 0x0001 },

-  { 0x0900, 0x01f6, 0x0f9f },

-  { 0x8500, 0x01fb, 0x3fff },

-  { 0x8500, 0x01f9, 0x2fff },

-  { 0x0900, 0x01f8, 0x0001 },

-  { 0x0900, 0x01fa, 0x0001 },

-  { 0x8500, 0x01fd, 0x2fff },

-  { 0x0900, 0x01fc, 0x0001 },

-  { 0x0900, 0x01fe, 0x0001 },

-  { 0x8c00, 0x0318, 0x9000 },

-  { 0x8500, 0x0298, 0x8000 },

-  { 0x8500, 0x0258, 0x7000 },

-  { 0x8500, 0x021f, 0x6fff },

-  { 0x8500, 0x020f, 0x5fff },

-  { 0x8500, 0x0207, 0x4fff },

-  { 0x8500, 0x0203, 0x3fff },

-  { 0x8500, 0x0201, 0x2fff },

-  { 0x0900, 0x0200, 0x0001 },

-  { 0x0900, 0x0202, 0x0001 },

-  { 0x8500, 0x0205, 0x2fff },

-  { 0x0900, 0x0204, 0x0001 },

-  { 0x0900, 0x0206, 0x0001 },

-  { 0x8500, 0x020b, 0x3fff },

-  { 0x8500, 0x0209, 0x2fff },

-  { 0x0900, 0x0208, 0x0001 },

-  { 0x0900, 0x020a, 0x0001 },

-  { 0x8500, 0x020d, 0x2fff },

-  { 0x0900, 0x020c, 0x0001 },

-  { 0x0900, 0x020e, 0x0001 },

-  { 0x8500, 0x0217, 0x4fff },

-  { 0x8500, 0x0213, 0x3fff },

-  { 0x8500, 0x0211, 0x2fff },

-  { 0x0900, 0x0210, 0x0001 },

-  { 0x0900, 0x0212, 0x0001 },

-  { 0x8500, 0x0215, 0x2fff },

-  { 0x0900, 0x0214, 0x0001 },

-  { 0x0900, 0x0216, 0x0001 },

-  { 0x8500, 0x021b, 0x3fff },

-  { 0x8500, 0x0219, 0x2fff },

-  { 0x0900, 0x0218, 0x0001 },

-  { 0x0900, 0x021a, 0x0001 },

-  { 0x8500, 0x021d, 0x2fff },

-  { 0x0900, 0x021c, 0x0001 },

-  { 0x0900, 0x021e, 0x0001 },

-  { 0x8500, 0x022f, 0x5fff },

-  { 0x8500, 0x0227, 0x4fff },

-  { 0x8500, 0x0223, 0x3fff },

-  { 0x8500, 0x0221, 0x2000 },

-  { 0x0900, 0x0220, 0x0f7e },

-  { 0x0900, 0x0222, 0x0001 },

-  { 0x8500, 0x0225, 0x2fff },

-  { 0x0900, 0x0224, 0x0001 },

-  { 0x0900, 0x0226, 0x0001 },

-  { 0x8500, 0x022b, 0x3fff },

-  { 0x8500, 0x0229, 0x2fff },

-  { 0x0900, 0x0228, 0x0001 },

-  { 0x0900, 0x022a, 0x0001 },

-  { 0x8500, 0x022d, 0x2fff },

-  { 0x0900, 0x022c, 0x0001 },

-  { 0x0900, 0x022e, 0x0001 },

-  { 0x8500, 0x0250, 0x4000 },

-  { 0x8500, 0x0233, 0x3fff },

-  { 0x8500, 0x0231, 0x2fff },

-  { 0x0900, 0x0230, 0x0001 },

-  { 0x0900, 0x0232, 0x0001 },

-  { 0x8500, 0x0235, 0x2000 },

-  { 0x0500, 0x0234, 0x0000 },

-  { 0x0500, 0x0236, 0x0000 },

-  { 0x8500, 0x0254, 0x3f32 },

-  { 0x8500, 0x0252, 0x2000 },

-  { 0x0500, 0x0251, 0x0000 },

-  { 0x0500, 0x0253, 0x0f2e },

-  { 0x8500, 0x0256, 0x2f33 },

-  { 0x0500, 0x0255, 0x0000 },

-  { 0x0500, 0x0257, 0x0f33 },

-  { 0x8500, 0x0278, 0x6000 },

-  { 0x8500, 0x0268, 0x5f2f },

-  { 0x8500, 0x0260, 0x4f33 },

-  { 0x8500, 0x025c, 0x3000 },

-  { 0x8500, 0x025a, 0x2000 },

-  { 0x0500, 0x0259, 0x0f36 },

-  { 0x0500, 0x025b, 0x0f35 },

-  { 0x8500, 0x025e, 0x2000 },

-  { 0x0500, 0x025d, 0x0000 },

-  { 0x0500, 0x025f, 0x0000 },

-  { 0x8500, 0x0264, 0x3000 },

-  { 0x8500, 0x0262, 0x2000 },

-  { 0x0500, 0x0261, 0x0000 },

-  { 0x0500, 0x0263, 0x0f31 },

-  { 0x8500, 0x0266, 0x2000 },

-  { 0x0500, 0x0265, 0x0000 },

-  { 0x0500, 0x0267, 0x0000 },

-  { 0x8500, 0x0270, 0x4000 },

-  { 0x8500, 0x026c, 0x3000 },

-  { 0x8500, 0x026a, 0x2000 },

-  { 0x0500, 0x0269, 0x0f2d },

-  { 0x0500, 0x026b, 0x0000 },

-  { 0x8500, 0x026e, 0x2000 },

-  { 0x0500, 0x026d, 0x0000 },

-  { 0x0500, 0x026f, 0x0f2d },

-  { 0x8500, 0x0274, 0x3000 },

-  { 0x8500, 0x0272, 0x2f2b },

-  { 0x0500, 0x0271, 0x0000 },

-  { 0x0500, 0x0273, 0x0000 },

-  { 0x8500, 0x0276, 0x2000 },

-  { 0x0500, 0x0275, 0x0f2a },

-  { 0x0500, 0x0277, 0x0000 },

-  { 0x8500, 0x0288, 0x5f26 },

-  { 0x8500, 0x0280, 0x4f26 },

-  { 0x8500, 0x027c, 0x3000 },

-  { 0x8500, 0x027a, 0x2000 },

-  { 0x0500, 0x0279, 0x0000 },

-  { 0x0500, 0x027b, 0x0000 },

-  { 0x8500, 0x027e, 0x2000 },

-  { 0x0500, 0x027d, 0x0000 },

-  { 0x0500, 0x027f, 0x0000 },

-  { 0x8500, 0x0284, 0x3000 },

-  { 0x8500, 0x0282, 0x2000 },

-  { 0x0500, 0x0281, 0x0000 },

-  { 0x0500, 0x0283, 0x0f26 },

-  { 0x8500, 0x0286, 0x2000 },

-  { 0x0500, 0x0285, 0x0000 },

-  { 0x0500, 0x0287, 0x0000 },

-  { 0x8500, 0x0290, 0x4000 },

-  { 0x8500, 0x028c, 0x3000 },

-  { 0x8500, 0x028a, 0x2f27 },

-  { 0x0500, 0x0289, 0x0000 },

-  { 0x0500, 0x028b, 0x0f27 },

-  { 0x8500, 0x028e, 0x2000 },

-  { 0x0500, 0x028d, 0x0000 },

-  { 0x0500, 0x028f, 0x0000 },

-  { 0x8500, 0x0294, 0x3000 },

-  { 0x8500, 0x0292, 0x2f25 },

-  { 0x0500, 0x0291, 0x0000 },

-  { 0x0500, 0x0293, 0x0000 },

-  { 0x8500, 0x0296, 0x2000 },

-  { 0x0500, 0x0295, 0x0000 },

-  { 0x0500, 0x0297, 0x0000 },

-  { 0x9800, 0x02d8, 0x7000 },

-  { 0x8600, 0x02b8, 0x6000 },

-  { 0x8500, 0x02a8, 0x5000 },

-  { 0x8500, 0x02a0, 0x4000 },

-  { 0x8500, 0x029c, 0x3000 },

-  { 0x8500, 0x029a, 0x2000 },

-  { 0x0500, 0x0299, 0x0000 },

-  { 0x0500, 0x029b, 0x0000 },

-  { 0x8500, 0x029e, 0x2000 },

-  { 0x0500, 0x029d, 0x0000 },

-  { 0x0500, 0x029f, 0x0000 },

-  { 0x8500, 0x02a4, 0x3000 },

-  { 0x8500, 0x02a2, 0x2000 },

-  { 0x0500, 0x02a1, 0x0000 },

-  { 0x0500, 0x02a3, 0x0000 },

-  { 0x8500, 0x02a6, 0x2000 },

-  { 0x0500, 0x02a5, 0x0000 },

-  { 0x0500, 0x02a7, 0x0000 },

-  { 0x8600, 0x02b0, 0x4000 },

-  { 0x8500, 0x02ac, 0x3000 },

-  { 0x8500, 0x02aa, 0x2000 },

-  { 0x0500, 0x02a9, 0x0000 },

-  { 0x0500, 0x02ab, 0x0000 },

-  { 0x8500, 0x02ae, 0x2000 },

-  { 0x0500, 0x02ad, 0x0000 },

-  { 0x0500, 0x02af, 0x0000 },

-  { 0x8600, 0x02b4, 0x3000 },

-  { 0x8600, 0x02b2, 0x2000 },

-  { 0x0600, 0x02b1, 0x0000 },

-  { 0x0600, 0x02b3, 0x0000 },

-  { 0x8600, 0x02b6, 0x2000 },

-  { 0x0600, 0x02b5, 0x0000 },

-  { 0x0600, 0x02b7, 0x0000 },

-  { 0x8600, 0x02c8, 0x5000 },

-  { 0x8600, 0x02c0, 0x4000 },

-  { 0x8600, 0x02bc, 0x3000 },

-  { 0x8600, 0x02ba, 0x2000 },

-  { 0x0600, 0x02b9, 0x0000 },

-  { 0x0600, 0x02bb, 0x0000 },

-  { 0x8600, 0x02be, 0x2000 },

-  { 0x0600, 0x02bd, 0x0000 },

-  { 0x0600, 0x02bf, 0x0000 },

-  { 0x9800, 0x02c4, 0x3000 },

-  { 0x9800, 0x02c2, 0x2000 },

-  { 0x0600, 0x02c1, 0x0000 },

-  { 0x1800, 0x02c3, 0x0000 },

-  { 0x8600, 0x02c6, 0x2000 },

-  { 0x1800, 0x02c5, 0x0000 },

-  { 0x0600, 0x02c7, 0x0000 },

-  { 0x8600, 0x02d0, 0x4000 },

-  { 0x8600, 0x02cc, 0x3000 },

-  { 0x8600, 0x02ca, 0x2000 },

-  { 0x0600, 0x02c9, 0x0000 },

-  { 0x0600, 0x02cb, 0x0000 },

-  { 0x8600, 0x02ce, 0x2000 },

-  { 0x0600, 0x02cd, 0x0000 },

-  { 0x0600, 0x02cf, 0x0000 },

-  { 0x9800, 0x02d4, 0x3000 },

-  { 0x9800, 0x02d2, 0x2000 },

-  { 0x0600, 0x02d1, 0x0000 },

-  { 0x1800, 0x02d3, 0x0000 },

-  { 0x9800, 0x02d6, 0x2000 },

-  { 0x1800, 0x02d5, 0x0000 },

-  { 0x1800, 0x02d7, 0x0000 },

-  { 0x9800, 0x02f8, 0x6000 },

-  { 0x9800, 0x02e8, 0x5000 },

-  { 0x8600, 0x02e0, 0x4000 },

-  { 0x9800, 0x02dc, 0x3000 },

-  { 0x9800, 0x02da, 0x2000 },

-  { 0x1800, 0x02d9, 0x0000 },

-  { 0x1800, 0x02db, 0x0000 },

-  { 0x9800, 0x02de, 0x2000 },

-  { 0x1800, 0x02dd, 0x0000 },

-  { 0x1800, 0x02df, 0x0000 },

-  { 0x8600, 0x02e4, 0x3000 },

-  { 0x8600, 0x02e2, 0x2000 },

-  { 0x0600, 0x02e1, 0x0000 },

-  { 0x0600, 0x02e3, 0x0000 },

-  { 0x9800, 0x02e6, 0x2000 },

-  { 0x1800, 0x02e5, 0x0000 },

-  { 0x1800, 0x02e7, 0x0000 },

-  { 0x9800, 0x02f0, 0x4000 },

-  { 0x9800, 0x02ec, 0x3000 },

-  { 0x9800, 0x02ea, 0x2000 },

-  { 0x1800, 0x02e9, 0x0000 },

-  { 0x1800, 0x02eb, 0x0000 },

-  { 0x8600, 0x02ee, 0x2000 },

-  { 0x1800, 0x02ed, 0x0000 },

-  { 0x1800, 0x02ef, 0x0000 },

-  { 0x9800, 0x02f4, 0x3000 },

-  { 0x9800, 0x02f2, 0x2000 },

-  { 0x1800, 0x02f1, 0x0000 },

-  { 0x1800, 0x02f3, 0x0000 },

-  { 0x9800, 0x02f6, 0x2000 },

-  { 0x1800, 0x02f5, 0x0000 },

-  { 0x1800, 0x02f7, 0x0000 },

-  { 0x8c00, 0x0308, 0x5000 },

-  { 0x8c00, 0x0300, 0x4000 },

-  { 0x9800, 0x02fc, 0x3000 },

-  { 0x9800, 0x02fa, 0x2000 },

-  { 0x1800, 0x02f9, 0x0000 },

-  { 0x1800, 0x02fb, 0x0000 },

-  { 0x9800, 0x02fe, 0x2000 },

-  { 0x1800, 0x02fd, 0x0000 },

-  { 0x1800, 0x02ff, 0x0000 },

-  { 0x8c00, 0x0304, 0x3000 },

-  { 0x8c00, 0x0302, 0x2000 },

-  { 0x0c00, 0x0301, 0x0000 },

-  { 0x0c00, 0x0303, 0x0000 },

-  { 0x8c00, 0x0306, 0x2000 },

-  { 0x0c00, 0x0305, 0x0000 },

-  { 0x0c00, 0x0307, 0x0000 },

-  { 0x8c00, 0x0310, 0x4000 },

-  { 0x8c00, 0x030c, 0x3000 },

-  { 0x8c00, 0x030a, 0x2000 },

-  { 0x0c00, 0x0309, 0x0000 },

-  { 0x0c00, 0x030b, 0x0000 },

-  { 0x8c00, 0x030e, 0x2000 },

-  { 0x0c00, 0x030d, 0x0000 },

-  { 0x0c00, 0x030f, 0x0000 },

-  { 0x8c00, 0x0314, 0x3000 },

-  { 0x8c00, 0x0312, 0x2000 },

-  { 0x0c00, 0x0311, 0x0000 },

-  { 0x0c00, 0x0313, 0x0000 },

-  { 0x8c00, 0x0316, 0x2000 },

-  { 0x0c00, 0x0315, 0x0000 },

-  { 0x0c00, 0x0317, 0x0000 },

-  { 0x8500, 0x03b0, 0x8000 },

-  { 0x8c00, 0x035d, 0x7000 },

-  { 0x8c00, 0x0338, 0x6000 },

-  { 0x8c00, 0x0328, 0x5000 },

-  { 0x8c00, 0x0320, 0x4000 },

-  { 0x8c00, 0x031c, 0x3000 },

-  { 0x8c00, 0x031a, 0x2000 },

-  { 0x0c00, 0x0319, 0x0000 },

-  { 0x0c00, 0x031b, 0x0000 },

-  { 0x8c00, 0x031e, 0x2000 },

-  { 0x0c00, 0x031d, 0x0000 },

-  { 0x0c00, 0x031f, 0x0000 },

-  { 0x8c00, 0x0324, 0x3000 },

-  { 0x8c00, 0x0322, 0x2000 },

-  { 0x0c00, 0x0321, 0x0000 },

-  { 0x0c00, 0x0323, 0x0000 },

-  { 0x8c00, 0x0326, 0x2000 },

-  { 0x0c00, 0x0325, 0x0000 },

-  { 0x0c00, 0x0327, 0x0000 },

-  { 0x8c00, 0x0330, 0x4000 },

-  { 0x8c00, 0x032c, 0x3000 },

-  { 0x8c00, 0x032a, 0x2000 },

-  { 0x0c00, 0x0329, 0x0000 },

-  { 0x0c00, 0x032b, 0x0000 },

-  { 0x8c00, 0x032e, 0x2000 },

-  { 0x0c00, 0x032d, 0x0000 },

-  { 0x0c00, 0x032f, 0x0000 },

-  { 0x8c00, 0x0334, 0x3000 },

-  { 0x8c00, 0x0332, 0x2000 },

-  { 0x0c00, 0x0331, 0x0000 },

-  { 0x0c00, 0x0333, 0x0000 },

-  { 0x8c00, 0x0336, 0x2000 },

-  { 0x0c00, 0x0335, 0x0000 },

-  { 0x0c00, 0x0337, 0x0000 },

-  { 0x8c00, 0x0348, 0x5000 },

-  { 0x8c00, 0x0340, 0x4000 },

-  { 0x8c00, 0x033c, 0x3000 },

-  { 0x8c00, 0x033a, 0x2000 },

-  { 0x0c00, 0x0339, 0x0000 },

-  { 0x0c00, 0x033b, 0x0000 },

-  { 0x8c00, 0x033e, 0x2000 },

-  { 0x0c00, 0x033d, 0x0000 },

-  { 0x0c00, 0x033f, 0x0000 },

-  { 0x8c00, 0x0344, 0x3000 },

-  { 0x8c00, 0x0342, 0x2000 },

-  { 0x0c00, 0x0341, 0x0000 },

-  { 0x0c00, 0x0343, 0x0000 },

-  { 0x8c00, 0x0346, 0x2000 },

-  { 0x0c00, 0x0345, 0x0000 },

-  { 0x0c00, 0x0347, 0x0000 },

-  { 0x8c00, 0x0350, 0x4000 },

-  { 0x8c00, 0x034c, 0x3000 },

-  { 0x8c00, 0x034a, 0x2000 },

-  { 0x0c00, 0x0349, 0x0000 },

-  { 0x0c00, 0x034b, 0x0000 },

-  { 0x8c00, 0x034e, 0x2000 },

-  { 0x0c00, 0x034d, 0x0000 },

-  { 0x0c00, 0x034f, 0x0000 },

-  { 0x8c00, 0x0354, 0x3000 },

-  { 0x8c00, 0x0352, 0x2000 },

-  { 0x0c00, 0x0351, 0x0000 },

-  { 0x0c00, 0x0353, 0x0000 },

-  { 0x8c00, 0x0356, 0x2000 },

-  { 0x0c00, 0x0355, 0x0000 },

-  { 0x0c00, 0x0357, 0x0000 },

-  { 0x8900, 0x038f, 0x603f },

-  { 0x8c00, 0x036d, 0x5000 },

-  { 0x8c00, 0x0365, 0x4000 },

-  { 0x8c00, 0x0361, 0x3000 },

-  { 0x8c00, 0x035f, 0x2000 },

-  { 0x0c00, 0x035e, 0x0000 },

-  { 0x0c00, 0x0360, 0x0000 },

-  { 0x8c00, 0x0363, 0x2000 },

-  { 0x0c00, 0x0362, 0x0000 },

-  { 0x0c00, 0x0364, 0x0000 },

-  { 0x8c00, 0x0369, 0x3000 },

-  { 0x8c00, 0x0367, 0x2000 },

-  { 0x0c00, 0x0366, 0x0000 },

-  { 0x0c00, 0x0368, 0x0000 },

-  { 0x8c00, 0x036b, 0x2000 },

-  { 0x0c00, 0x036a, 0x0000 },

-  { 0x0c00, 0x036c, 0x0000 },

-  { 0x9800, 0x0385, 0x4000 },

-  { 0x9800, 0x0375, 0x3000 },

-  { 0x8c00, 0x036f, 0x2000 },

-  { 0x0c00, 0x036e, 0x0000 },

-  { 0x1800, 0x0374, 0x0000 },

-  { 0x9500, 0x037e, 0x2000 },

-  { 0x0600, 0x037a, 0x0000 },

-  { 0x1800, 0x0384, 0x0000 },

-  { 0x8900, 0x0389, 0x3025 },

-  { 0x9500, 0x0387, 0x2000 },

-  { 0x0900, 0x0386, 0x0026 },

-  { 0x0900, 0x0388, 0x0025 },

-  { 0x8900, 0x038c, 0x2040 },

-  { 0x0900, 0x038a, 0x0025 },

-  { 0x0900, 0x038e, 0x003f },

-  { 0x8900, 0x039f, 0x5020 },

-  { 0x8900, 0x0397, 0x4020 },

-  { 0x8900, 0x0393, 0x3020 },

-  { 0x8900, 0x0391, 0x2020 },

-  { 0x0500, 0x0390, 0x0000 },

-  { 0x0900, 0x0392, 0x0020 },

-  { 0x8900, 0x0395, 0x2020 },

-  { 0x0900, 0x0394, 0x0020 },

-  { 0x0900, 0x0396, 0x0020 },

-  { 0x8900, 0x039b, 0x3020 },

-  { 0x8900, 0x0399, 0x2020 },

-  { 0x0900, 0x0398, 0x0020 },

-  { 0x0900, 0x039a, 0x0020 },

-  { 0x8900, 0x039d, 0x2020 },

-  { 0x0900, 0x039c, 0x0020 },

-  { 0x0900, 0x039e, 0x0020 },

-  { 0x8900, 0x03a8, 0x4020 },

-  { 0x8900, 0x03a4, 0x3020 },

-  { 0x8900, 0x03a1, 0x2020 },

-  { 0x0900, 0x03a0, 0x0020 },

-  { 0x0900, 0x03a3, 0x0020 },

-  { 0x8900, 0x03a6, 0x2020 },

-  { 0x0900, 0x03a5, 0x0020 },

-  { 0x0900, 0x03a7, 0x0020 },

-  { 0x8500, 0x03ac, 0x3fda },

-  { 0x8900, 0x03aa, 0x2020 },

-  { 0x0900, 0x03a9, 0x0020 },

-  { 0x0900, 0x03ab, 0x0020 },

-  { 0x8500, 0x03ae, 0x2fdb },

-  { 0x0500, 0x03ad, 0x0fdb },

-  { 0x0500, 0x03af, 0x0fdb },

-  { 0x8500, 0x03f1, 0x7fb0 },

-  { 0x8500, 0x03d1, 0x6fc7 },

-  { 0x8500, 0x03c0, 0x5fe0 },

-  { 0x8500, 0x03b8, 0x4fe0 },

-  { 0x8500, 0x03b4, 0x3fe0 },

-  { 0x8500, 0x03b2, 0x2fe0 },

-  { 0x0500, 0x03b1, 0x0fe0 },

-  { 0x0500, 0x03b3, 0x0fe0 },

-  { 0x8500, 0x03b6, 0x2fe0 },

-  { 0x0500, 0x03b5, 0x0fe0 },

-  { 0x0500, 0x03b7, 0x0fe0 },

-  { 0x8500, 0x03bc, 0x3fe0 },

-  { 0x8500, 0x03ba, 0x2fe0 },

-  { 0x0500, 0x03b9, 0x0fe0 },

-  { 0x0500, 0x03bb, 0x0fe0 },

-  { 0x8500, 0x03be, 0x2fe0 },

-  { 0x0500, 0x03bd, 0x0fe0 },

-  { 0x0500, 0x03bf, 0x0fe0 },

-  { 0x8500, 0x03c8, 0x4fe0 },

-  { 0x8500, 0x03c4, 0x3fe0 },

-  { 0x8500, 0x03c2, 0x2fe1 },

-  { 0x0500, 0x03c1, 0x0fe0 },

-  { 0x0500, 0x03c3, 0x0fe0 },

-  { 0x8500, 0x03c6, 0x2fe0 },

-  { 0x0500, 0x03c5, 0x0fe0 },

-  { 0x0500, 0x03c7, 0x0fe0 },

-  { 0x8500, 0x03cc, 0x3fc0 },

-  { 0x8500, 0x03ca, 0x2fe0 },

-  { 0x0500, 0x03c9, 0x0fe0 },

-  { 0x0500, 0x03cb, 0x0fe0 },

-  { 0x8500, 0x03ce, 0x2fc1 },

-  { 0x0500, 0x03cd, 0x0fc1 },

-  { 0x0500, 0x03d0, 0x0fc2 },

-  { 0x8500, 0x03e1, 0x5fff },

-  { 0x8500, 0x03d9, 0x4fff },

-  { 0x8500, 0x03d5, 0x3fd1 },

-  { 0x8900, 0x03d3, 0x2000 },

-  { 0x0900, 0x03d2, 0x0000 },

-  { 0x0900, 0x03d4, 0x0000 },

-  { 0x8500, 0x03d7, 0x2000 },

-  { 0x0500, 0x03d6, 0x0fca },

-  { 0x0900, 0x03d8, 0x0001 },

-  { 0x8500, 0x03dd, 0x3fff },

-  { 0x8500, 0x03db, 0x2fff },

-  { 0x0900, 0x03da, 0x0001 },

-  { 0x0900, 0x03dc, 0x0001 },

-  { 0x8500, 0x03df, 0x2fff },

-  { 0x0900, 0x03de, 0x0001 },

-  { 0x0900, 0x03e0, 0x0001 },

-  { 0x8500, 0x03e9, 0x4fff },

-  { 0x8500, 0x03e5, 0x3fff },

-  { 0x8500, 0x03e3, 0x2fff },

-  { 0x0900, 0x03e2, 0x0001 },

-  { 0x0900, 0x03e4, 0x0001 },

-  { 0x8500, 0x03e7, 0x2fff },

-  { 0x0900, 0x03e6, 0x0001 },

-  { 0x0900, 0x03e8, 0x0001 },

-  { 0x8500, 0x03ed, 0x3fff },

-  { 0x8500, 0x03eb, 0x2fff },

-  { 0x0900, 0x03ea, 0x0001 },

-  { 0x0900, 0x03ec, 0x0001 },

-  { 0x8500, 0x03ef, 0x2fff },

-  { 0x0900, 0x03ee, 0x0001 },

-  { 0x0500, 0x03f0, 0x0faa },

-  { 0x8900, 0x0415, 0x6020 },

-  { 0x8900, 0x0405, 0x5050 },

-  { 0x8900, 0x03f9, 0x4ff9 },

-  { 0x8500, 0x03f5, 0x3fa0 },

-  { 0x8500, 0x03f3, 0x2000 },

-  { 0x0500, 0x03f2, 0x0007 },

-  { 0x0900, 0x03f4, 0x0fc4 },

-  { 0x8900, 0x03f7, 0x2001 },

-  { 0x1900, 0x03f6, 0x0000 },

-  { 0x0500, 0x03f8, 0x0fff },

-  { 0x8900, 0x0401, 0x3050 },

-  { 0x8500, 0x03fb, 0x2fff },

-  { 0x0900, 0x03fa, 0x0001 },

-  { 0x0900, 0x0400, 0x0050 },

-  { 0x8900, 0x0403, 0x2050 },

-  { 0x0900, 0x0402, 0x0050 },

-  { 0x0900, 0x0404, 0x0050 },

-  { 0x8900, 0x040d, 0x4050 },

-  { 0x8900, 0x0409, 0x3050 },

-  { 0x8900, 0x0407, 0x2050 },

-  { 0x0900, 0x0406, 0x0050 },

-  { 0x0900, 0x0408, 0x0050 },

-  { 0x8900, 0x040b, 0x2050 },

-  { 0x0900, 0x040a, 0x0050 },

-  { 0x0900, 0x040c, 0x0050 },

-  { 0x8900, 0x0411, 0x3020 },

-  { 0x8900, 0x040f, 0x2050 },

-  { 0x0900, 0x040e, 0x0050 },

-  { 0x0900, 0x0410, 0x0020 },

-  { 0x8900, 0x0413, 0x2020 },

-  { 0x0900, 0x0412, 0x0020 },

-  { 0x0900, 0x0414, 0x0020 },

-  { 0x8900, 0x0425, 0x5020 },

-  { 0x8900, 0x041d, 0x4020 },

-  { 0x8900, 0x0419, 0x3020 },

-  { 0x8900, 0x0417, 0x2020 },

-  { 0x0900, 0x0416, 0x0020 },

-  { 0x0900, 0x0418, 0x0020 },

-  { 0x8900, 0x041b, 0x2020 },

-  { 0x0900, 0x041a, 0x0020 },

-  { 0x0900, 0x041c, 0x0020 },

-  { 0x8900, 0x0421, 0x3020 },

-  { 0x8900, 0x041f, 0x2020 },

-  { 0x0900, 0x041e, 0x0020 },

-  { 0x0900, 0x0420, 0x0020 },

-  { 0x8900, 0x0423, 0x2020 },

-  { 0x0900, 0x0422, 0x0020 },

-  { 0x0900, 0x0424, 0x0020 },

-  { 0x8900, 0x042d, 0x4020 },

-  { 0x8900, 0x0429, 0x3020 },

-  { 0x8900, 0x0427, 0x2020 },

-  { 0x0900, 0x0426, 0x0020 },

-  { 0x0900, 0x0428, 0x0020 },

-  { 0x8900, 0x042b, 0x2020 },

-  { 0x0900, 0x042a, 0x0020 },

-  { 0x0900, 0x042c, 0x0020 },

-  { 0x8500, 0x0431, 0x3fe0 },

-  { 0x8900, 0x042f, 0x2020 },

-  { 0x0900, 0x042e, 0x0020 },

-  { 0x0500, 0x0430, 0x0fe0 },

-  { 0x8500, 0x0433, 0x2fe0 },

-  { 0x0500, 0x0432, 0x0fe0 },

-  { 0x0500, 0x0434, 0x0fe0 },

-  { 0x8700, 0x06a4, 0xa000 },

-  { 0x8500, 0x0563, 0x9fd0 },

-  { 0x8900, 0x04b6, 0x8001 },

-  { 0x8500, 0x0475, 0x7fff },

-  { 0x8500, 0x0455, 0x6fb0 },

-  { 0x8500, 0x0445, 0x5fe0 },

-  { 0x8500, 0x043d, 0x4fe0 },

-  { 0x8500, 0x0439, 0x3fe0 },

-  { 0x8500, 0x0437, 0x2fe0 },

-  { 0x0500, 0x0436, 0x0fe0 },

-  { 0x0500, 0x0438, 0x0fe0 },

-  { 0x8500, 0x043b, 0x2fe0 },

-  { 0x0500, 0x043a, 0x0fe0 },

-  { 0x0500, 0x043c, 0x0fe0 },

-  { 0x8500, 0x0441, 0x3fe0 },

-  { 0x8500, 0x043f, 0x2fe0 },

-  { 0x0500, 0x043e, 0x0fe0 },

-  { 0x0500, 0x0440, 0x0fe0 },

-  { 0x8500, 0x0443, 0x2fe0 },

-  { 0x0500, 0x0442, 0x0fe0 },

-  { 0x0500, 0x0444, 0x0fe0 },

-  { 0x8500, 0x044d, 0x4fe0 },

-  { 0x8500, 0x0449, 0x3fe0 },

-  { 0x8500, 0x0447, 0x2fe0 },

-  { 0x0500, 0x0446, 0x0fe0 },

-  { 0x0500, 0x0448, 0x0fe0 },

-  { 0x8500, 0x044b, 0x2fe0 },

-  { 0x0500, 0x044a, 0x0fe0 },

-  { 0x0500, 0x044c, 0x0fe0 },

-  { 0x8500, 0x0451, 0x3fb0 },

-  { 0x8500, 0x044f, 0x2fe0 },

-  { 0x0500, 0x044e, 0x0fe0 },

-  { 0x0500, 0x0450, 0x0fb0 },

-  { 0x8500, 0x0453, 0x2fb0 },

-  { 0x0500, 0x0452, 0x0fb0 },

-  { 0x0500, 0x0454, 0x0fb0 },

-  { 0x8500, 0x0465, 0x5fff },

-  { 0x8500, 0x045d, 0x4fb0 },

-  { 0x8500, 0x0459, 0x3fb0 },

-  { 0x8500, 0x0457, 0x2fb0 },

-  { 0x0500, 0x0456, 0x0fb0 },

-  { 0x0500, 0x0458, 0x0fb0 },

-  { 0x8500, 0x045b, 0x2fb0 },

-  { 0x0500, 0x045a, 0x0fb0 },

-  { 0x0500, 0x045c, 0x0fb0 },

-  { 0x8500, 0x0461, 0x3fff },

-  { 0x8500, 0x045f, 0x2fb0 },

-  { 0x0500, 0x045e, 0x0fb0 },

-  { 0x0900, 0x0460, 0x0001 },

-  { 0x8500, 0x0463, 0x2fff },

-  { 0x0900, 0x0462, 0x0001 },

-  { 0x0900, 0x0464, 0x0001 },

-  { 0x8500, 0x046d, 0x4fff },

-  { 0x8500, 0x0469, 0x3fff },

-  { 0x8500, 0x0467, 0x2fff },

-  { 0x0900, 0x0466, 0x0001 },

-  { 0x0900, 0x0468, 0x0001 },

-  { 0x8500, 0x046b, 0x2fff },

-  { 0x0900, 0x046a, 0x0001 },

-  { 0x0900, 0x046c, 0x0001 },

-  { 0x8500, 0x0471, 0x3fff },

-  { 0x8500, 0x046f, 0x2fff },

-  { 0x0900, 0x046e, 0x0001 },

-  { 0x0900, 0x0470, 0x0001 },

-  { 0x8500, 0x0473, 0x2fff },

-  { 0x0900, 0x0472, 0x0001 },

-  { 0x0900, 0x0474, 0x0001 },

-  { 0x8900, 0x0496, 0x6001 },

-  { 0x8c00, 0x0485, 0x5000 },

-  { 0x8500, 0x047d, 0x4fff },

-  { 0x8500, 0x0479, 0x3fff },

-  { 0x8500, 0x0477, 0x2fff },

-  { 0x0900, 0x0476, 0x0001 },

-  { 0x0900, 0x0478, 0x0001 },

-  { 0x8500, 0x047b, 0x2fff },

-  { 0x0900, 0x047a, 0x0001 },

-  { 0x0900, 0x047c, 0x0001 },

-  { 0x8500, 0x0481, 0x3fff },

-  { 0x8500, 0x047f, 0x2fff },

-  { 0x0900, 0x047e, 0x0001 },

-  { 0x0900, 0x0480, 0x0001 },

-  { 0x8c00, 0x0483, 0x2000 },

-  { 0x1a00, 0x0482, 0x0000 },

-  { 0x0c00, 0x0484, 0x0000 },

-  { 0x8900, 0x048e, 0x4001 },

-  { 0x8900, 0x048a, 0x3001 },

-  { 0x8b00, 0x0488, 0x2000 },

-  { 0x0c00, 0x0486, 0x0000 },

-  { 0x0b00, 0x0489, 0x0000 },

-  { 0x8900, 0x048c, 0x2001 },

-  { 0x0500, 0x048b, 0x0fff },

-  { 0x0500, 0x048d, 0x0fff },

-  { 0x8900, 0x0492, 0x3001 },

-  { 0x8900, 0x0490, 0x2001 },

-  { 0x0500, 0x048f, 0x0fff },

-  { 0x0500, 0x0491, 0x0fff },

-  { 0x8900, 0x0494, 0x2001 },

-  { 0x0500, 0x0493, 0x0fff },

-  { 0x0500, 0x0495, 0x0fff },

-  { 0x8900, 0x04a6, 0x5001 },

-  { 0x8900, 0x049e, 0x4001 },

-  { 0x8900, 0x049a, 0x3001 },

-  { 0x8900, 0x0498, 0x2001 },

-  { 0x0500, 0x0497, 0x0fff },

-  { 0x0500, 0x0499, 0x0fff },

-  { 0x8900, 0x049c, 0x2001 },

-  { 0x0500, 0x049b, 0x0fff },

-  { 0x0500, 0x049d, 0x0fff },

-  { 0x8900, 0x04a2, 0x3001 },

-  { 0x8900, 0x04a0, 0x2001 },

-  { 0x0500, 0x049f, 0x0fff },

-  { 0x0500, 0x04a1, 0x0fff },

-  { 0x8900, 0x04a4, 0x2001 },

-  { 0x0500, 0x04a3, 0x0fff },

-  { 0x0500, 0x04a5, 0x0fff },

-  { 0x8900, 0x04ae, 0x4001 },

-  { 0x8900, 0x04aa, 0x3001 },

-  { 0x8900, 0x04a8, 0x2001 },

-  { 0x0500, 0x04a7, 0x0fff },

-  { 0x0500, 0x04a9, 0x0fff },

-  { 0x8900, 0x04ac, 0x2001 },

-  { 0x0500, 0x04ab, 0x0fff },

-  { 0x0500, 0x04ad, 0x0fff },

-  { 0x8900, 0x04b2, 0x3001 },

-  { 0x8900, 0x04b0, 0x2001 },

-  { 0x0500, 0x04af, 0x0fff },

-  { 0x0500, 0x04b1, 0x0fff },

-  { 0x8900, 0x04b4, 0x2001 },

-  { 0x0500, 0x04b3, 0x0fff },

-  { 0x0500, 0x04b5, 0x0fff },

-  { 0x8500, 0x04f9, 0x7fff },

-  { 0x8500, 0x04d7, 0x6fff },

-  { 0x8500, 0x04c6, 0x5fff },

-  { 0x8900, 0x04be, 0x4001 },

-  { 0x8900, 0x04ba, 0x3001 },

-  { 0x8900, 0x04b8, 0x2001 },

-  { 0x0500, 0x04b7, 0x0fff },

-  { 0x0500, 0x04b9, 0x0fff },

-  { 0x8900, 0x04bc, 0x2001 },

-  { 0x0500, 0x04bb, 0x0fff },

-  { 0x0500, 0x04bd, 0x0fff },

-  { 0x8500, 0x04c2, 0x3fff },

-  { 0x8900, 0x04c0, 0x2000 },

-  { 0x0500, 0x04bf, 0x0fff },

-  { 0x0900, 0x04c1, 0x0001 },

-  { 0x8500, 0x04c4, 0x2fff },

-  { 0x0900, 0x04c3, 0x0001 },

-  { 0x0900, 0x04c5, 0x0001 },

-  { 0x8500, 0x04ce, 0x4fff },

-  { 0x8500, 0x04ca, 0x3fff },

-  { 0x8500, 0x04c8, 0x2fff },

-  { 0x0900, 0x04c7, 0x0001 },

-  { 0x0900, 0x04c9, 0x0001 },

-  { 0x8500, 0x04cc, 0x2fff },

-  { 0x0900, 0x04cb, 0x0001 },

-  { 0x0900, 0x04cd, 0x0001 },

-  { 0x8500, 0x04d3, 0x3fff },

-  { 0x8500, 0x04d1, 0x2fff },

-  { 0x0900, 0x04d0, 0x0001 },

-  { 0x0900, 0x04d2, 0x0001 },

-  { 0x8500, 0x04d5, 0x2fff },

-  { 0x0900, 0x04d4, 0x0001 },

-  { 0x0900, 0x04d6, 0x0001 },

-  { 0x8500, 0x04e7, 0x5fff },

-  { 0x8500, 0x04df, 0x4fff },

-  { 0x8500, 0x04db, 0x3fff },

-  { 0x8500, 0x04d9, 0x2fff },

-  { 0x0900, 0x04d8, 0x0001 },

-  { 0x0900, 0x04da, 0x0001 },

-  { 0x8500, 0x04dd, 0x2fff },

-  { 0x0900, 0x04dc, 0x0001 },

-  { 0x0900, 0x04de, 0x0001 },

-  { 0x8500, 0x04e3, 0x3fff },

-  { 0x8500, 0x04e1, 0x2fff },

-  { 0x0900, 0x04e0, 0x0001 },

-  { 0x0900, 0x04e2, 0x0001 },

-  { 0x8500, 0x04e5, 0x2fff },

-  { 0x0900, 0x04e4, 0x0001 },

-  { 0x0900, 0x04e6, 0x0001 },

-  { 0x8500, 0x04ef, 0x4fff },

-  { 0x8500, 0x04eb, 0x3fff },

-  { 0x8500, 0x04e9, 0x2fff },

-  { 0x0900, 0x04e8, 0x0001 },

-  { 0x0900, 0x04ea, 0x0001 },

-  { 0x8500, 0x04ed, 0x2fff },

-  { 0x0900, 0x04ec, 0x0001 },

-  { 0x0900, 0x04ee, 0x0001 },

-  { 0x8500, 0x04f3, 0x3fff },

-  { 0x8500, 0x04f1, 0x2fff },

-  { 0x0900, 0x04f0, 0x0001 },

-  { 0x0900, 0x04f2, 0x0001 },

-  { 0x8500, 0x04f5, 0x2fff },

-  { 0x0900, 0x04f4, 0x0001 },

-  { 0x0900, 0x04f8, 0x0001 },

-  { 0x8900, 0x0540, 0x6030 },

-  { 0x8500, 0x050f, 0x5fff },

-  { 0x8500, 0x0507, 0x4fff },

-  { 0x8500, 0x0503, 0x3fff },

-  { 0x8500, 0x0501, 0x2fff },

-  { 0x0900, 0x0500, 0x0001 },

-  { 0x0900, 0x0502, 0x0001 },

-  { 0x8500, 0x0505, 0x2fff },

-  { 0x0900, 0x0504, 0x0001 },

-  { 0x0900, 0x0506, 0x0001 },

-  { 0x8500, 0x050b, 0x3fff },

-  { 0x8500, 0x0509, 0x2fff },

-  { 0x0900, 0x0508, 0x0001 },

-  { 0x0900, 0x050a, 0x0001 },

-  { 0x8500, 0x050d, 0x2fff },

-  { 0x0900, 0x050c, 0x0001 },

-  { 0x0900, 0x050e, 0x0001 },

-  { 0x8900, 0x0538, 0x4030 },

-  { 0x8900, 0x0534, 0x3030 },

-  { 0x8900, 0x0532, 0x2030 },

-  { 0x0900, 0x0531, 0x0030 },

-  { 0x0900, 0x0533, 0x0030 },

-  { 0x8900, 0x0536, 0x2030 },

-  { 0x0900, 0x0535, 0x0030 },

-  { 0x0900, 0x0537, 0x0030 },

-  { 0x8900, 0x053c, 0x3030 },

-  { 0x8900, 0x053a, 0x2030 },

-  { 0x0900, 0x0539, 0x0030 },

-  { 0x0900, 0x053b, 0x0030 },

-  { 0x8900, 0x053e, 0x2030 },

-  { 0x0900, 0x053d, 0x0030 },

-  { 0x0900, 0x053f, 0x0030 },

-  { 0x8900, 0x0550, 0x5030 },

-  { 0x8900, 0x0548, 0x4030 },

-  { 0x8900, 0x0544, 0x3030 },

-  { 0x8900, 0x0542, 0x2030 },

-  { 0x0900, 0x0541, 0x0030 },

-  { 0x0900, 0x0543, 0x0030 },

-  { 0x8900, 0x0546, 0x2030 },

-  { 0x0900, 0x0545, 0x0030 },

-  { 0x0900, 0x0547, 0x0030 },

-  { 0x8900, 0x054c, 0x3030 },

-  { 0x8900, 0x054a, 0x2030 },

-  { 0x0900, 0x0549, 0x0030 },

-  { 0x0900, 0x054b, 0x0030 },

-  { 0x8900, 0x054e, 0x2030 },

-  { 0x0900, 0x054d, 0x0030 },

-  { 0x0900, 0x054f, 0x0030 },

-  { 0x9500, 0x055a, 0x4000 },

-  { 0x8900, 0x0554, 0x3030 },

-  { 0x8900, 0x0552, 0x2030 },

-  { 0x0900, 0x0551, 0x0030 },

-  { 0x0900, 0x0553, 0x0030 },

-  { 0x8900, 0x0556, 0x2030 },

-  { 0x0900, 0x0555, 0x0030 },

-  { 0x0600, 0x0559, 0x0000 },

-  { 0x9500, 0x055e, 0x3000 },

-  { 0x9500, 0x055c, 0x2000 },

-  { 0x1500, 0x055b, 0x0000 },

-  { 0x1500, 0x055d, 0x0000 },

-  { 0x8500, 0x0561, 0x2fd0 },

-  { 0x1500, 0x055f, 0x0000 },

-  { 0x0500, 0x0562, 0x0fd0 },

-  { 0x9a00, 0x060f, 0x8000 },

-  { 0x8c00, 0x05ab, 0x7000 },

-  { 0x8500, 0x0583, 0x6fd0 },

-  { 0x8500, 0x0573, 0x5fd0 },

-  { 0x8500, 0x056b, 0x4fd0 },

-  { 0x8500, 0x0567, 0x3fd0 },

-  { 0x8500, 0x0565, 0x2fd0 },

-  { 0x0500, 0x0564, 0x0fd0 },

-  { 0x0500, 0x0566, 0x0fd0 },

-  { 0x8500, 0x0569, 0x2fd0 },

-  { 0x0500, 0x0568, 0x0fd0 },

-  { 0x0500, 0x056a, 0x0fd0 },

-  { 0x8500, 0x056f, 0x3fd0 },

-  { 0x8500, 0x056d, 0x2fd0 },

-  { 0x0500, 0x056c, 0x0fd0 },

-  { 0x0500, 0x056e, 0x0fd0 },

-  { 0x8500, 0x0571, 0x2fd0 },

-  { 0x0500, 0x0570, 0x0fd0 },

-  { 0x0500, 0x0572, 0x0fd0 },

-  { 0x8500, 0x057b, 0x4fd0 },

-  { 0x8500, 0x0577, 0x3fd0 },

-  { 0x8500, 0x0575, 0x2fd0 },

-  { 0x0500, 0x0574, 0x0fd0 },

-  { 0x0500, 0x0576, 0x0fd0 },

-  { 0x8500, 0x0579, 0x2fd0 },

-  { 0x0500, 0x0578, 0x0fd0 },

-  { 0x0500, 0x057a, 0x0fd0 },

-  { 0x8500, 0x057f, 0x3fd0 },

-  { 0x8500, 0x057d, 0x2fd0 },

-  { 0x0500, 0x057c, 0x0fd0 },

-  { 0x0500, 0x057e, 0x0fd0 },

-  { 0x8500, 0x0581, 0x2fd0 },

-  { 0x0500, 0x0580, 0x0fd0 },

-  { 0x0500, 0x0582, 0x0fd0 },

-  { 0x8c00, 0x059a, 0x5000 },

-  { 0x8c00, 0x0592, 0x4000 },

-  { 0x8500, 0x0587, 0x3000 },

-  { 0x8500, 0x0585, 0x2fd0 },

-  { 0x0500, 0x0584, 0x0fd0 },

-  { 0x0500, 0x0586, 0x0fd0 },

-  { 0x9100, 0x058a, 0x2000 },

-  { 0x1500, 0x0589, 0x0000 },

-  { 0x0c00, 0x0591, 0x0000 },

-  { 0x8c00, 0x0596, 0x3000 },

-  { 0x8c00, 0x0594, 0x2000 },

-  { 0x0c00, 0x0593, 0x0000 },

-  { 0x0c00, 0x0595, 0x0000 },

-  { 0x8c00, 0x0598, 0x2000 },

-  { 0x0c00, 0x0597, 0x0000 },

-  { 0x0c00, 0x0599, 0x0000 },

-  { 0x8c00, 0x05a3, 0x4000 },

-  { 0x8c00, 0x059e, 0x3000 },

-  { 0x8c00, 0x059c, 0x2000 },

-  { 0x0c00, 0x059b, 0x0000 },

-  { 0x0c00, 0x059d, 0x0000 },

-  { 0x8c00, 0x05a0, 0x2000 },

-  { 0x0c00, 0x059f, 0x0000 },

-  { 0x0c00, 0x05a1, 0x0000 },

-  { 0x8c00, 0x05a7, 0x3000 },

-  { 0x8c00, 0x05a5, 0x2000 },

-  { 0x0c00, 0x05a4, 0x0000 },

-  { 0x0c00, 0x05a6, 0x0000 },

-  { 0x8c00, 0x05a9, 0x2000 },

-  { 0x0c00, 0x05a8, 0x0000 },

-  { 0x0c00, 0x05aa, 0x0000 },

-  { 0x8700, 0x05d7, 0x6000 },

-  { 0x8c00, 0x05bc, 0x5000 },

-  { 0x8c00, 0x05b3, 0x4000 },

-  { 0x8c00, 0x05af, 0x3000 },

-  { 0x8c00, 0x05ad, 0x2000 },

-  { 0x0c00, 0x05ac, 0x0000 },

-  { 0x0c00, 0x05ae, 0x0000 },

-  { 0x8c00, 0x05b1, 0x2000 },

-  { 0x0c00, 0x05b0, 0x0000 },

-  { 0x0c00, 0x05b2, 0x0000 },

-  { 0x8c00, 0x05b7, 0x3000 },

-  { 0x8c00, 0x05b5, 0x2000 },

-  { 0x0c00, 0x05b4, 0x0000 },

-  { 0x0c00, 0x05b6, 0x0000 },

-  { 0x8c00, 0x05b9, 0x2000 },

-  { 0x0c00, 0x05b8, 0x0000 },

-  { 0x0c00, 0x05bb, 0x0000 },

-  { 0x8c00, 0x05c4, 0x4000 },

-  { 0x9500, 0x05c0, 0x3000 },

-  { 0x9500, 0x05be, 0x2000 },

-  { 0x0c00, 0x05bd, 0x0000 },

-  { 0x0c00, 0x05bf, 0x0000 },

-  { 0x8c00, 0x05c2, 0x2000 },

-  { 0x0c00, 0x05c1, 0x0000 },

-  { 0x1500, 0x05c3, 0x0000 },

-  { 0x8700, 0x05d3, 0x3000 },

-  { 0x8700, 0x05d1, 0x2000 },

-  { 0x0700, 0x05d0, 0x0000 },

-  { 0x0700, 0x05d2, 0x0000 },

-  { 0x8700, 0x05d5, 0x2000 },

-  { 0x0700, 0x05d4, 0x0000 },

-  { 0x0700, 0x05d6, 0x0000 },

-  { 0x8700, 0x05e7, 0x5000 },

-  { 0x8700, 0x05df, 0x4000 },

-  { 0x8700, 0x05db, 0x3000 },

-  { 0x8700, 0x05d9, 0x2000 },

-  { 0x0700, 0x05d8, 0x0000 },

-  { 0x0700, 0x05da, 0x0000 },

-  { 0x8700, 0x05dd, 0x2000 },

-  { 0x0700, 0x05dc, 0x0000 },

-  { 0x0700, 0x05de, 0x0000 },

-  { 0x8700, 0x05e3, 0x3000 },

-  { 0x8700, 0x05e1, 0x2000 },

-  { 0x0700, 0x05e0, 0x0000 },

-  { 0x0700, 0x05e2, 0x0000 },

-  { 0x8700, 0x05e5, 0x2000 },

-  { 0x0700, 0x05e4, 0x0000 },

-  { 0x0700, 0x05e6, 0x0000 },

-  { 0x9500, 0x05f4, 0x4000 },

-  { 0x8700, 0x05f0, 0x3000 },

-  { 0x8700, 0x05e9, 0x2000 },

-  { 0x0700, 0x05e8, 0x0000 },

-  { 0x0700, 0x05ea, 0x0000 },

-  { 0x8700, 0x05f2, 0x2000 },

-  { 0x0700, 0x05f1, 0x0000 },

-  { 0x1500, 0x05f3, 0x0000 },

-  { 0x8100, 0x0603, 0x3000 },

-  { 0x8100, 0x0601, 0x2000 },

-  { 0x0100, 0x0600, 0x0000 },

-  { 0x0100, 0x0602, 0x0000 },

-  { 0x9500, 0x060d, 0x2000 },

-  { 0x1500, 0x060c, 0x0000 },

-  { 0x1a00, 0x060e, 0x0000 },

-  { 0x8d00, 0x0664, 0x7000 },

-  { 0x8700, 0x0638, 0x6000 },

-  { 0x8700, 0x0628, 0x5000 },

-  { 0x9500, 0x061f, 0x4000 },

-  { 0x8c00, 0x0613, 0x3000 },

-  { 0x8c00, 0x0611, 0x2000 },

-  { 0x0c00, 0x0610, 0x0000 },

-  { 0x0c00, 0x0612, 0x0000 },

-  { 0x8c00, 0x0615, 0x2000 },

-  { 0x0c00, 0x0614, 0x0000 },

-  { 0x1500, 0x061b, 0x0000 },

-  { 0x8700, 0x0624, 0x3000 },

-  { 0x8700, 0x0622, 0x2000 },

-  { 0x0700, 0x0621, 0x0000 },

-  { 0x0700, 0x0623, 0x0000 },

-  { 0x8700, 0x0626, 0x2000 },

-  { 0x0700, 0x0625, 0x0000 },

-  { 0x0700, 0x0627, 0x0000 },

-  { 0x8700, 0x0630, 0x4000 },

-  { 0x8700, 0x062c, 0x3000 },

-  { 0x8700, 0x062a, 0x2000 },

-  { 0x0700, 0x0629, 0x0000 },

-  { 0x0700, 0x062b, 0x0000 },

-  { 0x8700, 0x062e, 0x2000 },

-  { 0x0700, 0x062d, 0x0000 },

-  { 0x0700, 0x062f, 0x0000 },

-  { 0x8700, 0x0634, 0x3000 },

-  { 0x8700, 0x0632, 0x2000 },

-  { 0x0700, 0x0631, 0x0000 },

-  { 0x0700, 0x0633, 0x0000 },

-  { 0x8700, 0x0636, 0x2000 },

-  { 0x0700, 0x0635, 0x0000 },

-  { 0x0700, 0x0637, 0x0000 },

-  { 0x8c00, 0x064d, 0x5000 },

-  { 0x8700, 0x0645, 0x4000 },

-  { 0x8700, 0x0641, 0x3000 },

-  { 0x8700, 0x063a, 0x2000 },

-  { 0x0700, 0x0639, 0x0000 },

-  { 0x0600, 0x0640, 0x0000 },

-  { 0x8700, 0x0643, 0x2000 },

-  { 0x0700, 0x0642, 0x0000 },

-  { 0x0700, 0x0644, 0x0000 },

-  { 0x8700, 0x0649, 0x3000 },

-  { 0x8700, 0x0647, 0x2000 },

-  { 0x0700, 0x0646, 0x0000 },

-  { 0x0700, 0x0648, 0x0000 },

-  { 0x8c00, 0x064b, 0x2000 },

-  { 0x0700, 0x064a, 0x0000 },

-  { 0x0c00, 0x064c, 0x0000 },

-  { 0x8c00, 0x0655, 0x4000 },

-  { 0x8c00, 0x0651, 0x3000 },

-  { 0x8c00, 0x064f, 0x2000 },

-  { 0x0c00, 0x064e, 0x0000 },

-  { 0x0c00, 0x0650, 0x0000 },

-  { 0x8c00, 0x0653, 0x2000 },

-  { 0x0c00, 0x0652, 0x0000 },

-  { 0x0c00, 0x0654, 0x0000 },

-  { 0x8d00, 0x0660, 0x3000 },

-  { 0x8c00, 0x0657, 0x2000 },

-  { 0x0c00, 0x0656, 0x0000 },

-  { 0x0c00, 0x0658, 0x0000 },

-  { 0x8d00, 0x0662, 0x2000 },

-  { 0x0d00, 0x0661, 0x0000 },

-  { 0x0d00, 0x0663, 0x0000 },

-  { 0x8700, 0x0684, 0x6000 },

-  { 0x8700, 0x0674, 0x5000 },

-  { 0x9500, 0x066c, 0x4000 },

-  { 0x8d00, 0x0668, 0x3000 },

-  { 0x8d00, 0x0666, 0x2000 },

-  { 0x0d00, 0x0665, 0x0000 },

-  { 0x0d00, 0x0667, 0x0000 },

-  { 0x9500, 0x066a, 0x2000 },

-  { 0x0d00, 0x0669, 0x0000 },

-  { 0x1500, 0x066b, 0x0000 },

-  { 0x8c00, 0x0670, 0x3000 },

-  { 0x8700, 0x066e, 0x2000 },

-  { 0x1500, 0x066d, 0x0000 },

-  { 0x0700, 0x066f, 0x0000 },

-  { 0x8700, 0x0672, 0x2000 },

-  { 0x0700, 0x0671, 0x0000 },

-  { 0x0700, 0x0673, 0x0000 },

-  { 0x8700, 0x067c, 0x4000 },

-  { 0x8700, 0x0678, 0x3000 },

-  { 0x8700, 0x0676, 0x2000 },

-  { 0x0700, 0x0675, 0x0000 },

-  { 0x0700, 0x0677, 0x0000 },

-  { 0x8700, 0x067a, 0x2000 },

-  { 0x0700, 0x0679, 0x0000 },

-  { 0x0700, 0x067b, 0x0000 },

-  { 0x8700, 0x0680, 0x3000 },

-  { 0x8700, 0x067e, 0x2000 },

-  { 0x0700, 0x067d, 0x0000 },

-  { 0x0700, 0x067f, 0x0000 },

-  { 0x8700, 0x0682, 0x2000 },

-  { 0x0700, 0x0681, 0x0000 },

-  { 0x0700, 0x0683, 0x0000 },

-  { 0x8700, 0x0694, 0x5000 },

-  { 0x8700, 0x068c, 0x4000 },

-  { 0x8700, 0x0688, 0x3000 },

-  { 0x8700, 0x0686, 0x2000 },

-  { 0x0700, 0x0685, 0x0000 },

-  { 0x0700, 0x0687, 0x0000 },

-  { 0x8700, 0x068a, 0x2000 },

-  { 0x0700, 0x0689, 0x0000 },

-  { 0x0700, 0x068b, 0x0000 },

-  { 0x8700, 0x0690, 0x3000 },

-  { 0x8700, 0x068e, 0x2000 },

-  { 0x0700, 0x068d, 0x0000 },

-  { 0x0700, 0x068f, 0x0000 },

-  { 0x8700, 0x0692, 0x2000 },

-  { 0x0700, 0x0691, 0x0000 },

-  { 0x0700, 0x0693, 0x0000 },

-  { 0x8700, 0x069c, 0x4000 },

-  { 0x8700, 0x0698, 0x3000 },

-  { 0x8700, 0x0696, 0x2000 },

-  { 0x0700, 0x0695, 0x0000 },

-  { 0x0700, 0x0697, 0x0000 },

-  { 0x8700, 0x069a, 0x2000 },

-  { 0x0700, 0x0699, 0x0000 },

-  { 0x0700, 0x069b, 0x0000 },

-  { 0x8700, 0x06a0, 0x3000 },

-  { 0x8700, 0x069e, 0x2000 },

-  { 0x0700, 0x069d, 0x0000 },

-  { 0x0700, 0x069f, 0x0000 },

-  { 0x8700, 0x06a2, 0x2000 },

-  { 0x0700, 0x06a1, 0x0000 },

-  { 0x0700, 0x06a3, 0x0000 },

-  { 0x8700, 0x0926, 0x9000 },

-  { 0x8700, 0x0725, 0x8000 },

-  { 0x8c00, 0x06e4, 0x7000 },

-  { 0x8700, 0x06c4, 0x6000 },

-  { 0x8700, 0x06b4, 0x5000 },

-  { 0x8700, 0x06ac, 0x4000 },

-  { 0x8700, 0x06a8, 0x3000 },

-  { 0x8700, 0x06a6, 0x2000 },

-  { 0x0700, 0x06a5, 0x0000 },

-  { 0x0700, 0x06a7, 0x0000 },

-  { 0x8700, 0x06aa, 0x2000 },

-  { 0x0700, 0x06a9, 0x0000 },

-  { 0x0700, 0x06ab, 0x0000 },

-  { 0x8700, 0x06b0, 0x3000 },

-  { 0x8700, 0x06ae, 0x2000 },

-  { 0x0700, 0x06ad, 0x0000 },

-  { 0x0700, 0x06af, 0x0000 },

-  { 0x8700, 0x06b2, 0x2000 },

-  { 0x0700, 0x06b1, 0x0000 },

-  { 0x0700, 0x06b3, 0x0000 },

-  { 0x8700, 0x06bc, 0x4000 },

-  { 0x8700, 0x06b8, 0x3000 },

-  { 0x8700, 0x06b6, 0x2000 },

-  { 0x0700, 0x06b5, 0x0000 },

-  { 0x0700, 0x06b7, 0x0000 },

-  { 0x8700, 0x06ba, 0x2000 },

-  { 0x0700, 0x06b9, 0x0000 },

-  { 0x0700, 0x06bb, 0x0000 },

-  { 0x8700, 0x06c0, 0x3000 },

-  { 0x8700, 0x06be, 0x2000 },

-  { 0x0700, 0x06bd, 0x0000 },

-  { 0x0700, 0x06bf, 0x0000 },

-  { 0x8700, 0x06c2, 0x2000 },

-  { 0x0700, 0x06c1, 0x0000 },

-  { 0x0700, 0x06c3, 0x0000 },

-  { 0x9500, 0x06d4, 0x5000 },

-  { 0x8700, 0x06cc, 0x4000 },

-  { 0x8700, 0x06c8, 0x3000 },

-  { 0x8700, 0x06c6, 0x2000 },

-  { 0x0700, 0x06c5, 0x0000 },

-  { 0x0700, 0x06c7, 0x0000 },

-  { 0x8700, 0x06ca, 0x2000 },

-  { 0x0700, 0x06c9, 0x0000 },

-  { 0x0700, 0x06cb, 0x0000 },

-  { 0x8700, 0x06d0, 0x3000 },

-  { 0x8700, 0x06ce, 0x2000 },

-  { 0x0700, 0x06cd, 0x0000 },

-  { 0x0700, 0x06cf, 0x0000 },

-  { 0x8700, 0x06d2, 0x2000 },

-  { 0x0700, 0x06d1, 0x0000 },

-  { 0x0700, 0x06d3, 0x0000 },

-  { 0x8c00, 0x06dc, 0x4000 },

-  { 0x8c00, 0x06d8, 0x3000 },

-  { 0x8c00, 0x06d6, 0x2000 },

-  { 0x0700, 0x06d5, 0x0000 },

-  { 0x0c00, 0x06d7, 0x0000 },

-  { 0x8c00, 0x06da, 0x2000 },

-  { 0x0c00, 0x06d9, 0x0000 },

-  { 0x0c00, 0x06db, 0x0000 },

-  { 0x8c00, 0x06e0, 0x3000 },

-  { 0x8b00, 0x06de, 0x2000 },

-  { 0x0100, 0x06dd, 0x0000 },

-  { 0x0c00, 0x06df, 0x0000 },

-  { 0x8c00, 0x06e2, 0x2000 },

-  { 0x0c00, 0x06e1, 0x0000 },

-  { 0x0c00, 0x06e3, 0x0000 },

-  { 0x9500, 0x0704, 0x6000 },

-  { 0x8d00, 0x06f4, 0x5000 },

-  { 0x8c00, 0x06ec, 0x4000 },

-  { 0x8c00, 0x06e8, 0x3000 },

-  { 0x8600, 0x06e6, 0x2000 },

-  { 0x0600, 0x06e5, 0x0000 },

-  { 0x0c00, 0x06e7, 0x0000 },

-  { 0x8c00, 0x06ea, 0x2000 },

-  { 0x1a00, 0x06e9, 0x0000 },

-  { 0x0c00, 0x06eb, 0x0000 },

-  { 0x8d00, 0x06f0, 0x3000 },

-  { 0x8700, 0x06ee, 0x2000 },

-  { 0x0c00, 0x06ed, 0x0000 },

-  { 0x0700, 0x06ef, 0x0000 },

-  { 0x8d00, 0x06f2, 0x2000 },

-  { 0x0d00, 0x06f1, 0x0000 },

-  { 0x0d00, 0x06f3, 0x0000 },

-  { 0x8700, 0x06fc, 0x4000 },

-  { 0x8d00, 0x06f8, 0x3000 },

-  { 0x8d00, 0x06f6, 0x2000 },

-  { 0x0d00, 0x06f5, 0x0000 },

-  { 0x0d00, 0x06f7, 0x0000 },

-  { 0x8700, 0x06fa, 0x2000 },

-  { 0x0d00, 0x06f9, 0x0000 },

-  { 0x0700, 0x06fb, 0x0000 },

-  { 0x9500, 0x0700, 0x3000 },

-  { 0x9a00, 0x06fe, 0x2000 },

-  { 0x1a00, 0x06fd, 0x0000 },

-  { 0x0700, 0x06ff, 0x0000 },

-  { 0x9500, 0x0702, 0x2000 },

-  { 0x1500, 0x0701, 0x0000 },

-  { 0x1500, 0x0703, 0x0000 },

-  { 0x8700, 0x0715, 0x5000 },

-  { 0x9500, 0x070c, 0x4000 },

-  { 0x9500, 0x0708, 0x3000 },

-  { 0x9500, 0x0706, 0x2000 },

-  { 0x1500, 0x0705, 0x0000 },

-  { 0x1500, 0x0707, 0x0000 },

-  { 0x9500, 0x070a, 0x2000 },

-  { 0x1500, 0x0709, 0x0000 },

-  { 0x1500, 0x070b, 0x0000 },

-  { 0x8c00, 0x0711, 0x3000 },

-  { 0x8100, 0x070f, 0x2000 },

-  { 0x1500, 0x070d, 0x0000 },

-  { 0x0700, 0x0710, 0x0000 },

-  { 0x8700, 0x0713, 0x2000 },

-  { 0x0700, 0x0712, 0x0000 },

-  { 0x0700, 0x0714, 0x0000 },

-  { 0x8700, 0x071d, 0x4000 },

-  { 0x8700, 0x0719, 0x3000 },

-  { 0x8700, 0x0717, 0x2000 },

-  { 0x0700, 0x0716, 0x0000 },

-  { 0x0700, 0x0718, 0x0000 },

-  { 0x8700, 0x071b, 0x2000 },

-  { 0x0700, 0x071a, 0x0000 },

-  { 0x0700, 0x071c, 0x0000 },

-  { 0x8700, 0x0721, 0x3000 },

-  { 0x8700, 0x071f, 0x2000 },

-  { 0x0700, 0x071e, 0x0000 },

-  { 0x0700, 0x0720, 0x0000 },

-  { 0x8700, 0x0723, 0x2000 },

-  { 0x0700, 0x0722, 0x0000 },

-  { 0x0700, 0x0724, 0x0000 },

-  { 0x8700, 0x0797, 0x7000 },

-  { 0x8c00, 0x0745, 0x6000 },

-  { 0x8c00, 0x0735, 0x5000 },

-  { 0x8700, 0x072d, 0x4000 },

-  { 0x8700, 0x0729, 0x3000 },

-  { 0x8700, 0x0727, 0x2000 },

-  { 0x0700, 0x0726, 0x0000 },

-  { 0x0700, 0x0728, 0x0000 },

-  { 0x8700, 0x072b, 0x2000 },

-  { 0x0700, 0x072a, 0x0000 },

-  { 0x0700, 0x072c, 0x0000 },

-  { 0x8c00, 0x0731, 0x3000 },

-  { 0x8700, 0x072f, 0x2000 },

-  { 0x0700, 0x072e, 0x0000 },

-  { 0x0c00, 0x0730, 0x0000 },

-  { 0x8c00, 0x0733, 0x2000 },

-  { 0x0c00, 0x0732, 0x0000 },

-  { 0x0c00, 0x0734, 0x0000 },

-  { 0x8c00, 0x073d, 0x4000 },

-  { 0x8c00, 0x0739, 0x3000 },

-  { 0x8c00, 0x0737, 0x2000 },

-  { 0x0c00, 0x0736, 0x0000 },

-  { 0x0c00, 0x0738, 0x0000 },

-  { 0x8c00, 0x073b, 0x2000 },

-  { 0x0c00, 0x073a, 0x0000 },

-  { 0x0c00, 0x073c, 0x0000 },

-  { 0x8c00, 0x0741, 0x3000 },

-  { 0x8c00, 0x073f, 0x2000 },

-  { 0x0c00, 0x073e, 0x0000 },

-  { 0x0c00, 0x0740, 0x0000 },

-  { 0x8c00, 0x0743, 0x2000 },

-  { 0x0c00, 0x0742, 0x0000 },

-  { 0x0c00, 0x0744, 0x0000 },

-  { 0x8700, 0x0787, 0x5000 },

-  { 0x8700, 0x074f, 0x4000 },

-  { 0x8c00, 0x0749, 0x3000 },

-  { 0x8c00, 0x0747, 0x2000 },

-  { 0x0c00, 0x0746, 0x0000 },

-  { 0x0c00, 0x0748, 0x0000 },

-  { 0x8700, 0x074d, 0x2000 },

-  { 0x0c00, 0x074a, 0x0000 },

-  { 0x0700, 0x074e, 0x0000 },

-  { 0x8700, 0x0783, 0x3000 },

-  { 0x8700, 0x0781, 0x2000 },

-  { 0x0700, 0x0780, 0x0000 },

-  { 0x0700, 0x0782, 0x0000 },

-  { 0x8700, 0x0785, 0x2000 },

-  { 0x0700, 0x0784, 0x0000 },

-  { 0x0700, 0x0786, 0x0000 },

-  { 0x8700, 0x078f, 0x4000 },

-  { 0x8700, 0x078b, 0x3000 },

-  { 0x8700, 0x0789, 0x2000 },

-  { 0x0700, 0x0788, 0x0000 },

-  { 0x0700, 0x078a, 0x0000 },

-  { 0x8700, 0x078d, 0x2000 },

-  { 0x0700, 0x078c, 0x0000 },

-  { 0x0700, 0x078e, 0x0000 },

-  { 0x8700, 0x0793, 0x3000 },

-  { 0x8700, 0x0791, 0x2000 },

-  { 0x0700, 0x0790, 0x0000 },

-  { 0x0700, 0x0792, 0x0000 },

-  { 0x8700, 0x0795, 0x2000 },

-  { 0x0700, 0x0794, 0x0000 },

-  { 0x0700, 0x0796, 0x0000 },

-  { 0x8700, 0x0906, 0x6000 },

-  { 0x8c00, 0x07a7, 0x5000 },

-  { 0x8700, 0x079f, 0x4000 },

-  { 0x8700, 0x079b, 0x3000 },

-  { 0x8700, 0x0799, 0x2000 },

-  { 0x0700, 0x0798, 0x0000 },

-  { 0x0700, 0x079a, 0x0000 },

-  { 0x8700, 0x079d, 0x2000 },

-  { 0x0700, 0x079c, 0x0000 },

-  { 0x0700, 0x079e, 0x0000 },

-  { 0x8700, 0x07a3, 0x3000 },

-  { 0x8700, 0x07a1, 0x2000 },

-  { 0x0700, 0x07a0, 0x0000 },

-  { 0x0700, 0x07a2, 0x0000 },

-  { 0x8700, 0x07a5, 0x2000 },

-  { 0x0700, 0x07a4, 0x0000 },

-  { 0x0c00, 0x07a6, 0x0000 },

-  { 0x8c00, 0x07af, 0x4000 },

-  { 0x8c00, 0x07ab, 0x3000 },

-  { 0x8c00, 0x07a9, 0x2000 },

-  { 0x0c00, 0x07a8, 0x0000 },

-  { 0x0c00, 0x07aa, 0x0000 },

-  { 0x8c00, 0x07ad, 0x2000 },

-  { 0x0c00, 0x07ac, 0x0000 },

-  { 0x0c00, 0x07ae, 0x0000 },

-  { 0x8c00, 0x0902, 0x3000 },

-  { 0x8700, 0x07b1, 0x2000 },

-  { 0x0c00, 0x07b0, 0x0000 },

-  { 0x0c00, 0x0901, 0x0000 },

-  { 0x8700, 0x0904, 0x2000 },

-  { 0x0a00, 0x0903, 0x0000 },

-  { 0x0700, 0x0905, 0x0000 },

-  { 0x8700, 0x0916, 0x5000 },

-  { 0x8700, 0x090e, 0x4000 },

-  { 0x8700, 0x090a, 0x3000 },

-  { 0x8700, 0x0908, 0x2000 },

-  { 0x0700, 0x0907, 0x0000 },

-  { 0x0700, 0x0909, 0x0000 },

-  { 0x8700, 0x090c, 0x2000 },

-  { 0x0700, 0x090b, 0x0000 },

-  { 0x0700, 0x090d, 0x0000 },

-  { 0x8700, 0x0912, 0x3000 },

-  { 0x8700, 0x0910, 0x2000 },

-  { 0x0700, 0x090f, 0x0000 },

-  { 0x0700, 0x0911, 0x0000 },

-  { 0x8700, 0x0914, 0x2000 },

-  { 0x0700, 0x0913, 0x0000 },

-  { 0x0700, 0x0915, 0x0000 },

-  { 0x8700, 0x091e, 0x4000 },

-  { 0x8700, 0x091a, 0x3000 },

-  { 0x8700, 0x0918, 0x2000 },

-  { 0x0700, 0x0917, 0x0000 },

-  { 0x0700, 0x0919, 0x0000 },

-  { 0x8700, 0x091c, 0x2000 },

-  { 0x0700, 0x091b, 0x0000 },

-  { 0x0700, 0x091d, 0x0000 },

-  { 0x8700, 0x0922, 0x3000 },

-  { 0x8700, 0x0920, 0x2000 },

-  { 0x0700, 0x091f, 0x0000 },

-  { 0x0700, 0x0921, 0x0000 },

-  { 0x8700, 0x0924, 0x2000 },

-  { 0x0700, 0x0923, 0x0000 },

-  { 0x0700, 0x0925, 0x0000 },

-  { 0x8c00, 0x09cd, 0x8000 },

-  { 0x8d00, 0x096d, 0x7000 },

-  { 0x8c00, 0x0948, 0x6000 },

-  { 0x8700, 0x0936, 0x5000 },

-  { 0x8700, 0x092e, 0x4000 },

-  { 0x8700, 0x092a, 0x3000 },

-  { 0x8700, 0x0928, 0x2000 },

-  { 0x0700, 0x0927, 0x0000 },

-  { 0x0700, 0x0929, 0x0000 },

-  { 0x8700, 0x092c, 0x2000 },

-  { 0x0700, 0x092b, 0x0000 },

-  { 0x0700, 0x092d, 0x0000 },

-  { 0x8700, 0x0932, 0x3000 },

-  { 0x8700, 0x0930, 0x2000 },

-  { 0x0700, 0x092f, 0x0000 },

-  { 0x0700, 0x0931, 0x0000 },

-  { 0x8700, 0x0934, 0x2000 },

-  { 0x0700, 0x0933, 0x0000 },

-  { 0x0700, 0x0935, 0x0000 },

-  { 0x8a00, 0x0940, 0x4000 },

-  { 0x8c00, 0x093c, 0x3000 },

-  { 0x8700, 0x0938, 0x2000 },

-  { 0x0700, 0x0937, 0x0000 },

-  { 0x0700, 0x0939, 0x0000 },

-  { 0x8a00, 0x093e, 0x2000 },

-  { 0x0700, 0x093d, 0x0000 },

-  { 0x0a00, 0x093f, 0x0000 },

-  { 0x8c00, 0x0944, 0x3000 },

-  { 0x8c00, 0x0942, 0x2000 },

-  { 0x0c00, 0x0941, 0x0000 },

-  { 0x0c00, 0x0943, 0x0000 },

-  { 0x8c00, 0x0946, 0x2000 },

-  { 0x0c00, 0x0945, 0x0000 },

-  { 0x0c00, 0x0947, 0x0000 },

-  { 0x8700, 0x095d, 0x5000 },

-  { 0x8c00, 0x0952, 0x4000 },

-  { 0x8a00, 0x094c, 0x3000 },

-  { 0x8a00, 0x094a, 0x2000 },

-  { 0x0a00, 0x0949, 0x0000 },

-  { 0x0a00, 0x094b, 0x0000 },

-  { 0x8700, 0x0950, 0x2000 },

-  { 0x0c00, 0x094d, 0x0000 },

-  { 0x0c00, 0x0951, 0x0000 },

-  { 0x8700, 0x0959, 0x3000 },

-  { 0x8c00, 0x0954, 0x2000 },

-  { 0x0c00, 0x0953, 0x0000 },

-  { 0x0700, 0x0958, 0x0000 },

-  { 0x8700, 0x095b, 0x2000 },

-  { 0x0700, 0x095a, 0x0000 },

-  { 0x0700, 0x095c, 0x0000 },

-  { 0x9500, 0x0965, 0x4000 },

-  { 0x8700, 0x0961, 0x3000 },

-  { 0x8700, 0x095f, 0x2000 },

-  { 0x0700, 0x095e, 0x0000 },

-  { 0x0700, 0x0960, 0x0000 },

-  { 0x8c00, 0x0963, 0x2000 },

-  { 0x0c00, 0x0962, 0x0000 },

-  { 0x1500, 0x0964, 0x0000 },

-  { 0x8d00, 0x0969, 0x3000 },

-  { 0x8d00, 0x0967, 0x2000 },

-  { 0x0d00, 0x0966, 0x0000 },

-  { 0x0d00, 0x0968, 0x0000 },

-  { 0x8d00, 0x096b, 0x2000 },

-  { 0x0d00, 0x096a, 0x0000 },

-  { 0x0d00, 0x096c, 0x0000 },

-  { 0x8700, 0x09a2, 0x6000 },

-  { 0x8700, 0x0990, 0x5000 },

-  { 0x8700, 0x0986, 0x4000 },

-  { 0x8c00, 0x0981, 0x3000 },

-  { 0x8d00, 0x096f, 0x2000 },

-  { 0x0d00, 0x096e, 0x0000 },

-  { 0x1500, 0x0970, 0x0000 },

-  { 0x8a00, 0x0983, 0x2000 },

-  { 0x0a00, 0x0982, 0x0000 },

-  { 0x0700, 0x0985, 0x0000 },

-  { 0x8700, 0x098a, 0x3000 },

-  { 0x8700, 0x0988, 0x2000 },

-  { 0x0700, 0x0987, 0x0000 },

-  { 0x0700, 0x0989, 0x0000 },

-  { 0x8700, 0x098c, 0x2000 },

-  { 0x0700, 0x098b, 0x0000 },

-  { 0x0700, 0x098f, 0x0000 },

-  { 0x8700, 0x099a, 0x4000 },

-  { 0x8700, 0x0996, 0x3000 },

-  { 0x8700, 0x0994, 0x2000 },

-  { 0x0700, 0x0993, 0x0000 },

-  { 0x0700, 0x0995, 0x0000 },

-  { 0x8700, 0x0998, 0x2000 },

-  { 0x0700, 0x0997, 0x0000 },

-  { 0x0700, 0x0999, 0x0000 },

-  { 0x8700, 0x099e, 0x3000 },

-  { 0x8700, 0x099c, 0x2000 },

-  { 0x0700, 0x099b, 0x0000 },

-  { 0x0700, 0x099d, 0x0000 },

-  { 0x8700, 0x09a0, 0x2000 },

-  { 0x0700, 0x099f, 0x0000 },

-  { 0x0700, 0x09a1, 0x0000 },

-  { 0x8700, 0x09b7, 0x5000 },

-  { 0x8700, 0x09ab, 0x4000 },

-  { 0x8700, 0x09a6, 0x3000 },

-  { 0x8700, 0x09a4, 0x2000 },

-  { 0x0700, 0x09a3, 0x0000 },

-  { 0x0700, 0x09a5, 0x0000 },

-  { 0x8700, 0x09a8, 0x2000 },

-  { 0x0700, 0x09a7, 0x0000 },

-  { 0x0700, 0x09aa, 0x0000 },

-  { 0x8700, 0x09af, 0x3000 },

-  { 0x8700, 0x09ad, 0x2000 },

-  { 0x0700, 0x09ac, 0x0000 },

-  { 0x0700, 0x09ae, 0x0000 },

-  { 0x8700, 0x09b2, 0x2000 },

-  { 0x0700, 0x09b0, 0x0000 },

-  { 0x0700, 0x09b6, 0x0000 },

-  { 0x8c00, 0x09c1, 0x4000 },

-  { 0x8700, 0x09bd, 0x3000 },

-  { 0x8700, 0x09b9, 0x2000 },

-  { 0x0700, 0x09b8, 0x0000 },

-  { 0x0c00, 0x09bc, 0x0000 },

-  { 0x8a00, 0x09bf, 0x2000 },

-  { 0x0a00, 0x09be, 0x0000 },

-  { 0x0a00, 0x09c0, 0x0000 },

-  { 0x8a00, 0x09c7, 0x3000 },

-  { 0x8c00, 0x09c3, 0x2000 },

-  { 0x0c00, 0x09c2, 0x0000 },

-  { 0x0c00, 0x09c4, 0x0000 },

-  { 0x8a00, 0x09cb, 0x2000 },

-  { 0x0a00, 0x09c8, 0x0000 },

-  { 0x0a00, 0x09cc, 0x0000 },

-  { 0x8700, 0x0a2b, 0x7000 },

-  { 0x8a00, 0x0a03, 0x6000 },

-  { 0x8d00, 0x09ed, 0x5000 },

-  { 0x8c00, 0x09e3, 0x4000 },

-  { 0x8700, 0x09df, 0x3000 },

-  { 0x8700, 0x09dc, 0x2000 },

-  { 0x0a00, 0x09d7, 0x0000 },

-  { 0x0700, 0x09dd, 0x0000 },

-  { 0x8700, 0x09e1, 0x2000 },

-  { 0x0700, 0x09e0, 0x0000 },

-  { 0x0c00, 0x09e2, 0x0000 },

-  { 0x8d00, 0x09e9, 0x3000 },

-  { 0x8d00, 0x09e7, 0x2000 },

-  { 0x0d00, 0x09e6, 0x0000 },

-  { 0x0d00, 0x09e8, 0x0000 },

-  { 0x8d00, 0x09eb, 0x2000 },

-  { 0x0d00, 0x09ea, 0x0000 },

-  { 0x0d00, 0x09ec, 0x0000 },

-  { 0x8f00, 0x09f5, 0x4000 },

-  { 0x8700, 0x09f1, 0x3000 },

-  { 0x8d00, 0x09ef, 0x2000 },

-  { 0x0d00, 0x09ee, 0x0000 },

-  { 0x0700, 0x09f0, 0x0000 },

-  { 0x9700, 0x09f3, 0x2000 },

-  { 0x1700, 0x09f2, 0x0000 },

-  { 0x0f00, 0x09f4, 0x0000 },

-  { 0x8f00, 0x09f9, 0x3000 },

-  { 0x8f00, 0x09f7, 0x2000 },

-  { 0x0f00, 0x09f6, 0x0000 },

-  { 0x0f00, 0x09f8, 0x0000 },

-  { 0x8c00, 0x0a01, 0x2000 },

-  { 0x1a00, 0x09fa, 0x0000 },

-  { 0x0c00, 0x0a02, 0x0000 },

-  { 0x8700, 0x0a1a, 0x5000 },

-  { 0x8700, 0x0a10, 0x4000 },

-  { 0x8700, 0x0a08, 0x3000 },

-  { 0x8700, 0x0a06, 0x2000 },

-  { 0x0700, 0x0a05, 0x0000 },

-  { 0x0700, 0x0a07, 0x0000 },

-  { 0x8700, 0x0a0a, 0x2000 },

-  { 0x0700, 0x0a09, 0x0000 },

-  { 0x0700, 0x0a0f, 0x0000 },

-  { 0x8700, 0x0a16, 0x3000 },

-  { 0x8700, 0x0a14, 0x2000 },

-  { 0x0700, 0x0a13, 0x0000 },

-  { 0x0700, 0x0a15, 0x0000 },

-  { 0x8700, 0x0a18, 0x2000 },

-  { 0x0700, 0x0a17, 0x0000 },

-  { 0x0700, 0x0a19, 0x0000 },

-  { 0x8700, 0x0a22, 0x4000 },

-  { 0x8700, 0x0a1e, 0x3000 },

-  { 0x8700, 0x0a1c, 0x2000 },

-  { 0x0700, 0x0a1b, 0x0000 },

-  { 0x0700, 0x0a1d, 0x0000 },

-  { 0x8700, 0x0a20, 0x2000 },

-  { 0x0700, 0x0a1f, 0x0000 },

-  { 0x0700, 0x0a21, 0x0000 },

-  { 0x8700, 0x0a26, 0x3000 },

-  { 0x8700, 0x0a24, 0x2000 },

-  { 0x0700, 0x0a23, 0x0000 },

-  { 0x0700, 0x0a25, 0x0000 },

-  { 0x8700, 0x0a28, 0x2000 },

-  { 0x0700, 0x0a27, 0x0000 },

-  { 0x0700, 0x0a2a, 0x0000 },

-  { 0x8d00, 0x0a6a, 0x6000 },

-  { 0x8c00, 0x0a41, 0x5000 },

-  { 0x8700, 0x0a35, 0x4000 },

-  { 0x8700, 0x0a2f, 0x3000 },

-  { 0x8700, 0x0a2d, 0x2000 },

-  { 0x0700, 0x0a2c, 0x0000 },

-  { 0x0700, 0x0a2e, 0x0000 },

-  { 0x8700, 0x0a32, 0x2000 },

-  { 0x0700, 0x0a30, 0x0000 },

-  { 0x0700, 0x0a33, 0x0000 },

-  { 0x8c00, 0x0a3c, 0x3000 },

-  { 0x8700, 0x0a38, 0x2000 },

-  { 0x0700, 0x0a36, 0x0000 },

-  { 0x0700, 0x0a39, 0x0000 },

-  { 0x8a00, 0x0a3f, 0x2000 },

-  { 0x0a00, 0x0a3e, 0x0000 },

-  { 0x0a00, 0x0a40, 0x0000 },

-  { 0x8700, 0x0a5a, 0x4000 },

-  { 0x8c00, 0x0a4b, 0x3000 },

-  { 0x8c00, 0x0a47, 0x2000 },

-  { 0x0c00, 0x0a42, 0x0000 },

-  { 0x0c00, 0x0a48, 0x0000 },

-  { 0x8c00, 0x0a4d, 0x2000 },

-  { 0x0c00, 0x0a4c, 0x0000 },

-  { 0x0700, 0x0a59, 0x0000 },

-  { 0x8d00, 0x0a66, 0x3000 },

-  { 0x8700, 0x0a5c, 0x2000 },

-  { 0x0700, 0x0a5b, 0x0000 },

-  { 0x0700, 0x0a5e, 0x0000 },

-  { 0x8d00, 0x0a68, 0x2000 },

-  { 0x0d00, 0x0a67, 0x0000 },

-  { 0x0d00, 0x0a69, 0x0000 },

-  { 0x8700, 0x0a87, 0x5000 },

-  { 0x8700, 0x0a72, 0x4000 },

-  { 0x8d00, 0x0a6e, 0x3000 },

-  { 0x8d00, 0x0a6c, 0x2000 },

-  { 0x0d00, 0x0a6b, 0x0000 },

-  { 0x0d00, 0x0a6d, 0x0000 },

-  { 0x8c00, 0x0a70, 0x2000 },

-  { 0x0d00, 0x0a6f, 0x0000 },

-  { 0x0c00, 0x0a71, 0x0000 },

-  { 0x8c00, 0x0a82, 0x3000 },

-  { 0x8700, 0x0a74, 0x2000 },

-  { 0x0700, 0x0a73, 0x0000 },

-  { 0x0c00, 0x0a81, 0x0000 },

-  { 0x8700, 0x0a85, 0x2000 },

-  { 0x0a00, 0x0a83, 0x0000 },

-  { 0x0700, 0x0a86, 0x0000 },

-  { 0x8700, 0x0a90, 0x4000 },

-  { 0x8700, 0x0a8b, 0x3000 },

-  { 0x8700, 0x0a89, 0x2000 },

-  { 0x0700, 0x0a88, 0x0000 },

-  { 0x0700, 0x0a8a, 0x0000 },

-  { 0x8700, 0x0a8d, 0x2000 },

-  { 0x0700, 0x0a8c, 0x0000 },

-  { 0x0700, 0x0a8f, 0x0000 },

-  { 0x8700, 0x0a95, 0x3000 },

-  { 0x8700, 0x0a93, 0x2000 },

-  { 0x0700, 0x0a91, 0x0000 },

-  { 0x0700, 0x0a94, 0x0000 },

-  { 0x8700, 0x0a97, 0x2000 },

-  { 0x0700, 0x0a96, 0x0000 },

-  { 0x0700, 0x0a98, 0x0000 },

-  { 0x8700, 0x10ef, 0xb000 },

-  { 0x8700, 0x0dc6, 0xa000 },

-  { 0x8700, 0x0c31, 0x9000 },

-  { 0x8700, 0x0b5f, 0x8000 },

-  { 0x8a00, 0x0b03, 0x7000 },

-  { 0x8a00, 0x0abe, 0x6000 },

-  { 0x8700, 0x0aaa, 0x5000 },

-  { 0x8700, 0x0aa1, 0x4000 },

-  { 0x8700, 0x0a9d, 0x3000 },

-  { 0x8700, 0x0a9b, 0x2000 },

-  { 0x0700, 0x0a9a, 0x0000 },

-  { 0x0700, 0x0a9c, 0x0000 },

-  { 0x8700, 0x0a9f, 0x2000 },

-  { 0x0700, 0x0a9e, 0x0000 },

-  { 0x0700, 0x0aa0, 0x0000 },

-  { 0x8700, 0x0aa5, 0x3000 },

-  { 0x8700, 0x0aa3, 0x2000 },

-  { 0x0700, 0x0aa2, 0x0000 },

-  { 0x0700, 0x0aa4, 0x0000 },

-  { 0x8700, 0x0aa7, 0x2000 },

-  { 0x0700, 0x0aa6, 0x0000 },

-  { 0x0700, 0x0aa8, 0x0000 },

-  { 0x8700, 0x0ab3, 0x4000 },

-  { 0x8700, 0x0aae, 0x3000 },

-  { 0x8700, 0x0aac, 0x2000 },

-  { 0x0700, 0x0aab, 0x0000 },

-  { 0x0700, 0x0aad, 0x0000 },

-  { 0x8700, 0x0ab0, 0x2000 },

-  { 0x0700, 0x0aaf, 0x0000 },

-  { 0x0700, 0x0ab2, 0x0000 },

-  { 0x8700, 0x0ab8, 0x3000 },

-  { 0x8700, 0x0ab6, 0x2000 },

-  { 0x0700, 0x0ab5, 0x0000 },

-  { 0x0700, 0x0ab7, 0x0000 },

-  { 0x8c00, 0x0abc, 0x2000 },

-  { 0x0700, 0x0ab9, 0x0000 },

-  { 0x0700, 0x0abd, 0x0000 },

-  { 0x8700, 0x0ae1, 0x5000 },

-  { 0x8c00, 0x0ac7, 0x4000 },

-  { 0x8c00, 0x0ac2, 0x3000 },

-  { 0x8a00, 0x0ac0, 0x2000 },

-  { 0x0a00, 0x0abf, 0x0000 },

-  { 0x0c00, 0x0ac1, 0x0000 },

-  { 0x8c00, 0x0ac4, 0x2000 },

-  { 0x0c00, 0x0ac3, 0x0000 },

-  { 0x0c00, 0x0ac5, 0x0000 },

-  { 0x8a00, 0x0acc, 0x3000 },

-  { 0x8a00, 0x0ac9, 0x2000 },

-  { 0x0c00, 0x0ac8, 0x0000 },

-  { 0x0a00, 0x0acb, 0x0000 },

-  { 0x8700, 0x0ad0, 0x2000 },

-  { 0x0c00, 0x0acd, 0x0000 },

-  { 0x0700, 0x0ae0, 0x0000 },

-  { 0x8d00, 0x0aeb, 0x4000 },

-  { 0x8d00, 0x0ae7, 0x3000 },

-  { 0x8c00, 0x0ae3, 0x2000 },

-  { 0x0c00, 0x0ae2, 0x0000 },

-  { 0x0d00, 0x0ae6, 0x0000 },

-  { 0x8d00, 0x0ae9, 0x2000 },

-  { 0x0d00, 0x0ae8, 0x0000 },

-  { 0x0d00, 0x0aea, 0x0000 },

-  { 0x8d00, 0x0aef, 0x3000 },

-  { 0x8d00, 0x0aed, 0x2000 },

-  { 0x0d00, 0x0aec, 0x0000 },

-  { 0x0d00, 0x0aee, 0x0000 },

-  { 0x8c00, 0x0b01, 0x2000 },

-  { 0x1700, 0x0af1, 0x0000 },

-  { 0x0a00, 0x0b02, 0x0000 },

-  { 0x8700, 0x0b28, 0x6000 },

-  { 0x8700, 0x0b18, 0x5000 },

-  { 0x8700, 0x0b0c, 0x4000 },

-  { 0x8700, 0x0b08, 0x3000 },

-  { 0x8700, 0x0b06, 0x2000 },

-  { 0x0700, 0x0b05, 0x0000 },

-  { 0x0700, 0x0b07, 0x0000 },

-  { 0x8700, 0x0b0a, 0x2000 },

-  { 0x0700, 0x0b09, 0x0000 },

-  { 0x0700, 0x0b0b, 0x0000 },

-  { 0x8700, 0x0b14, 0x3000 },

-  { 0x8700, 0x0b10, 0x2000 },

-  { 0x0700, 0x0b0f, 0x0000 },

-  { 0x0700, 0x0b13, 0x0000 },

-  { 0x8700, 0x0b16, 0x2000 },

-  { 0x0700, 0x0b15, 0x0000 },

-  { 0x0700, 0x0b17, 0x0000 },

-  { 0x8700, 0x0b20, 0x4000 },

-  { 0x8700, 0x0b1c, 0x3000 },

-  { 0x8700, 0x0b1a, 0x2000 },

-  { 0x0700, 0x0b19, 0x0000 },

-  { 0x0700, 0x0b1b, 0x0000 },

-  { 0x8700, 0x0b1e, 0x2000 },

-  { 0x0700, 0x0b1d, 0x0000 },

-  { 0x0700, 0x0b1f, 0x0000 },

-  { 0x8700, 0x0b24, 0x3000 },

-  { 0x8700, 0x0b22, 0x2000 },

-  { 0x0700, 0x0b21, 0x0000 },

-  { 0x0700, 0x0b23, 0x0000 },

-  { 0x8700, 0x0b26, 0x2000 },

-  { 0x0700, 0x0b25, 0x0000 },

-  { 0x0700, 0x0b27, 0x0000 },

-  { 0x8700, 0x0b3d, 0x5000 },

-  { 0x8700, 0x0b32, 0x4000 },

-  { 0x8700, 0x0b2d, 0x3000 },

-  { 0x8700, 0x0b2b, 0x2000 },

-  { 0x0700, 0x0b2a, 0x0000 },

-  { 0x0700, 0x0b2c, 0x0000 },

-  { 0x8700, 0x0b2f, 0x2000 },

-  { 0x0700, 0x0b2e, 0x0000 },

-  { 0x0700, 0x0b30, 0x0000 },

-  { 0x8700, 0x0b37, 0x3000 },

-  { 0x8700, 0x0b35, 0x2000 },

-  { 0x0700, 0x0b33, 0x0000 },

-  { 0x0700, 0x0b36, 0x0000 },

-  { 0x8700, 0x0b39, 0x2000 },

-  { 0x0700, 0x0b38, 0x0000 },

-  { 0x0c00, 0x0b3c, 0x0000 },

-  { 0x8a00, 0x0b48, 0x4000 },

-  { 0x8c00, 0x0b41, 0x3000 },

-  { 0x8c00, 0x0b3f, 0x2000 },

-  { 0x0a00, 0x0b3e, 0x0000 },

-  { 0x0a00, 0x0b40, 0x0000 },

-  { 0x8c00, 0x0b43, 0x2000 },

-  { 0x0c00, 0x0b42, 0x0000 },

-  { 0x0a00, 0x0b47, 0x0000 },

-  { 0x8c00, 0x0b56, 0x3000 },

-  { 0x8a00, 0x0b4c, 0x2000 },

-  { 0x0a00, 0x0b4b, 0x0000 },

-  { 0x0c00, 0x0b4d, 0x0000 },

-  { 0x8700, 0x0b5c, 0x2000 },

-  { 0x0a00, 0x0b57, 0x0000 },

-  { 0x0700, 0x0b5d, 0x0000 },

-  { 0x8d00, 0x0be7, 0x7000 },

-  { 0x8700, 0x0b9c, 0x6000 },

-  { 0x8700, 0x0b83, 0x5000 },

-  { 0x8d00, 0x0b6b, 0x4000 },

-  { 0x8d00, 0x0b67, 0x3000 },

-  { 0x8700, 0x0b61, 0x2000 },

-  { 0x0700, 0x0b60, 0x0000 },

-  { 0x0d00, 0x0b66, 0x0000 },

-  { 0x8d00, 0x0b69, 0x2000 },

-  { 0x0d00, 0x0b68, 0x0000 },

-  { 0x0d00, 0x0b6a, 0x0000 },

-  { 0x8d00, 0x0b6f, 0x3000 },

-  { 0x8d00, 0x0b6d, 0x2000 },

-  { 0x0d00, 0x0b6c, 0x0000 },

-  { 0x0d00, 0x0b6e, 0x0000 },

-  { 0x8700, 0x0b71, 0x2000 },

-  { 0x1a00, 0x0b70, 0x0000 },

-  { 0x0c00, 0x0b82, 0x0000 },

-  { 0x8700, 0x0b8f, 0x4000 },

-  { 0x8700, 0x0b88, 0x3000 },

-  { 0x8700, 0x0b86, 0x2000 },

-  { 0x0700, 0x0b85, 0x0000 },

-  { 0x0700, 0x0b87, 0x0000 },

-  { 0x8700, 0x0b8a, 0x2000 },

-  { 0x0700, 0x0b89, 0x0000 },

-  { 0x0700, 0x0b8e, 0x0000 },

-  { 0x8700, 0x0b94, 0x3000 },

-  { 0x8700, 0x0b92, 0x2000 },

-  { 0x0700, 0x0b90, 0x0000 },

-  { 0x0700, 0x0b93, 0x0000 },

-  { 0x8700, 0x0b99, 0x2000 },

-  { 0x0700, 0x0b95, 0x0000 },

-  { 0x0700, 0x0b9a, 0x0000 },

-  { 0x8700, 0x0bb7, 0x5000 },

-  { 0x8700, 0x0bae, 0x4000 },

-  { 0x8700, 0x0ba4, 0x3000 },

-  { 0x8700, 0x0b9f, 0x2000 },

-  { 0x0700, 0x0b9e, 0x0000 },

-  { 0x0700, 0x0ba3, 0x0000 },

-  { 0x8700, 0x0ba9, 0x2000 },

-  { 0x0700, 0x0ba8, 0x0000 },

-  { 0x0700, 0x0baa, 0x0000 },

-  { 0x8700, 0x0bb2, 0x3000 },

-  { 0x8700, 0x0bb0, 0x2000 },

-  { 0x0700, 0x0baf, 0x0000 },

-  { 0x0700, 0x0bb1, 0x0000 },

-  { 0x8700, 0x0bb4, 0x2000 },

-  { 0x0700, 0x0bb3, 0x0000 },

-  { 0x0700, 0x0bb5, 0x0000 },

-  { 0x8a00, 0x0bc6, 0x4000 },

-  { 0x8a00, 0x0bbf, 0x3000 },

-  { 0x8700, 0x0bb9, 0x2000 },

-  { 0x0700, 0x0bb8, 0x0000 },

-  { 0x0a00, 0x0bbe, 0x0000 },

-  { 0x8a00, 0x0bc1, 0x2000 },

-  { 0x0c00, 0x0bc0, 0x0000 },

-  { 0x0a00, 0x0bc2, 0x0000 },

-  { 0x8a00, 0x0bcb, 0x3000 },

-  { 0x8a00, 0x0bc8, 0x2000 },

-  { 0x0a00, 0x0bc7, 0x0000 },

-  { 0x0a00, 0x0bca, 0x0000 },

-  { 0x8c00, 0x0bcd, 0x2000 },

-  { 0x0a00, 0x0bcc, 0x0000 },

-  { 0x0a00, 0x0bd7, 0x0000 },

-  { 0x8700, 0x0c0f, 0x6000 },

-  { 0x9a00, 0x0bf7, 0x5000 },

-  { 0x8d00, 0x0bef, 0x4000 },

-  { 0x8d00, 0x0beb, 0x3000 },

-  { 0x8d00, 0x0be9, 0x2000 },

-  { 0x0d00, 0x0be8, 0x0000 },

-  { 0x0d00, 0x0bea, 0x0000 },

-  { 0x8d00, 0x0bed, 0x2000 },

-  { 0x0d00, 0x0bec, 0x0000 },

-  { 0x0d00, 0x0bee, 0x0000 },

-  { 0x9a00, 0x0bf3, 0x3000 },

-  { 0x8f00, 0x0bf1, 0x2000 },

-  { 0x0f00, 0x0bf0, 0x0000 },

-  { 0x0f00, 0x0bf2, 0x0000 },

-  { 0x9a00, 0x0bf5, 0x2000 },

-  { 0x1a00, 0x0bf4, 0x0000 },

-  { 0x1a00, 0x0bf6, 0x0000 },

-  { 0x8700, 0x0c06, 0x4000 },

-  { 0x8a00, 0x0c01, 0x3000 },

-  { 0x9700, 0x0bf9, 0x2000 },

-  { 0x1a00, 0x0bf8, 0x0000 },

-  { 0x1a00, 0x0bfa, 0x0000 },

-  { 0x8a00, 0x0c03, 0x2000 },

-  { 0x0a00, 0x0c02, 0x0000 },

-  { 0x0700, 0x0c05, 0x0000 },

-  { 0x8700, 0x0c0a, 0x3000 },

-  { 0x8700, 0x0c08, 0x2000 },

-  { 0x0700, 0x0c07, 0x0000 },

-  { 0x0700, 0x0c09, 0x0000 },

-  { 0x8700, 0x0c0c, 0x2000 },

-  { 0x0700, 0x0c0b, 0x0000 },

-  { 0x0700, 0x0c0e, 0x0000 },

-  { 0x8700, 0x0c20, 0x5000 },

-  { 0x8700, 0x0c18, 0x4000 },

-  { 0x8700, 0x0c14, 0x3000 },

-  { 0x8700, 0x0c12, 0x2000 },

-  { 0x0700, 0x0c10, 0x0000 },

-  { 0x0700, 0x0c13, 0x0000 },

-  { 0x8700, 0x0c16, 0x2000 },

-  { 0x0700, 0x0c15, 0x0000 },

-  { 0x0700, 0x0c17, 0x0000 },

-  { 0x8700, 0x0c1c, 0x3000 },

-  { 0x8700, 0x0c1a, 0x2000 },

-  { 0x0700, 0x0c19, 0x0000 },

-  { 0x0700, 0x0c1b, 0x0000 },

-  { 0x8700, 0x0c1e, 0x2000 },

-  { 0x0700, 0x0c1d, 0x0000 },

-  { 0x0700, 0x0c1f, 0x0000 },

-  { 0x8700, 0x0c28, 0x4000 },

-  { 0x8700, 0x0c24, 0x3000 },

-  { 0x8700, 0x0c22, 0x2000 },

-  { 0x0700, 0x0c21, 0x0000 },

-  { 0x0700, 0x0c23, 0x0000 },

-  { 0x8700, 0x0c26, 0x2000 },

-  { 0x0700, 0x0c25, 0x0000 },

-  { 0x0700, 0x0c27, 0x0000 },

-  { 0x8700, 0x0c2d, 0x3000 },

-  { 0x8700, 0x0c2b, 0x2000 },

-  { 0x0700, 0x0c2a, 0x0000 },

-  { 0x0700, 0x0c2c, 0x0000 },

-  { 0x8700, 0x0c2f, 0x2000 },

-  { 0x0700, 0x0c2e, 0x0000 },

-  { 0x0700, 0x0c30, 0x0000 },

-  { 0x8700, 0x0d0e, 0x8000 },

-  { 0x8700, 0x0ca1, 0x7000 },

-  { 0x8d00, 0x0c6c, 0x6000 },

-  { 0x8c00, 0x0c47, 0x5000 },

-  { 0x8c00, 0x0c3e, 0x4000 },

-  { 0x8700, 0x0c36, 0x3000 },

-  { 0x8700, 0x0c33, 0x2000 },

-  { 0x0700, 0x0c32, 0x0000 },

-  { 0x0700, 0x0c35, 0x0000 },

-  { 0x8700, 0x0c38, 0x2000 },

-  { 0x0700, 0x0c37, 0x0000 },

-  { 0x0700, 0x0c39, 0x0000 },

-  { 0x8a00, 0x0c42, 0x3000 },

-  { 0x8c00, 0x0c40, 0x2000 },

-  { 0x0c00, 0x0c3f, 0x0000 },

-  { 0x0a00, 0x0c41, 0x0000 },

-  { 0x8a00, 0x0c44, 0x2000 },

-  { 0x0a00, 0x0c43, 0x0000 },

-  { 0x0c00, 0x0c46, 0x0000 },

-  { 0x8700, 0x0c60, 0x4000 },

-  { 0x8c00, 0x0c4c, 0x3000 },

-  { 0x8c00, 0x0c4a, 0x2000 },

-  { 0x0c00, 0x0c48, 0x0000 },

-  { 0x0c00, 0x0c4b, 0x0000 },

-  { 0x8c00, 0x0c55, 0x2000 },

-  { 0x0c00, 0x0c4d, 0x0000 },

-  { 0x0c00, 0x0c56, 0x0000 },

-  { 0x8d00, 0x0c68, 0x3000 },

-  { 0x8d00, 0x0c66, 0x2000 },

-  { 0x0700, 0x0c61, 0x0000 },

-  { 0x0d00, 0x0c67, 0x0000 },

-  { 0x8d00, 0x0c6a, 0x2000 },

-  { 0x0d00, 0x0c69, 0x0000 },

-  { 0x0d00, 0x0c6b, 0x0000 },

-  { 0x8700, 0x0c90, 0x5000 },

-  { 0x8700, 0x0c87, 0x4000 },

-  { 0x8a00, 0x0c82, 0x3000 },

-  { 0x8d00, 0x0c6e, 0x2000 },

-  { 0x0d00, 0x0c6d, 0x0000 },

-  { 0x0d00, 0x0c6f, 0x0000 },

-  { 0x8700, 0x0c85, 0x2000 },

-  { 0x0a00, 0x0c83, 0x0000 },

-  { 0x0700, 0x0c86, 0x0000 },

-  { 0x8700, 0x0c8b, 0x3000 },

-  { 0x8700, 0x0c89, 0x2000 },

-  { 0x0700, 0x0c88, 0x0000 },

-  { 0x0700, 0x0c8a, 0x0000 },

-  { 0x8700, 0x0c8e, 0x2000 },

-  { 0x0700, 0x0c8c, 0x0000 },

-  { 0x0700, 0x0c8f, 0x0000 },

-  { 0x8700, 0x0c99, 0x4000 },

-  { 0x8700, 0x0c95, 0x3000 },

-  { 0x8700, 0x0c93, 0x2000 },

-  { 0x0700, 0x0c92, 0x0000 },

-  { 0x0700, 0x0c94, 0x0000 },

-  { 0x8700, 0x0c97, 0x2000 },

-  { 0x0700, 0x0c96, 0x0000 },

-  { 0x0700, 0x0c98, 0x0000 },

-  { 0x8700, 0x0c9d, 0x3000 },

-  { 0x8700, 0x0c9b, 0x2000 },

-  { 0x0700, 0x0c9a, 0x0000 },

-  { 0x0700, 0x0c9c, 0x0000 },

-  { 0x8700, 0x0c9f, 0x2000 },

-  { 0x0700, 0x0c9e, 0x0000 },

-  { 0x0700, 0x0ca0, 0x0000 },

-  { 0x8c00, 0x0cc6, 0x6000 },

-  { 0x8700, 0x0cb2, 0x5000 },

-  { 0x8700, 0x0caa, 0x4000 },

-  { 0x8700, 0x0ca5, 0x3000 },

-  { 0x8700, 0x0ca3, 0x2000 },

-  { 0x0700, 0x0ca2, 0x0000 },

-  { 0x0700, 0x0ca4, 0x0000 },

-  { 0x8700, 0x0ca7, 0x2000 },

-  { 0x0700, 0x0ca6, 0x0000 },

-  { 0x0700, 0x0ca8, 0x0000 },

-  { 0x8700, 0x0cae, 0x3000 },

-  { 0x8700, 0x0cac, 0x2000 },

-  { 0x0700, 0x0cab, 0x0000 },

-  { 0x0700, 0x0cad, 0x0000 },

-  { 0x8700, 0x0cb0, 0x2000 },

-  { 0x0700, 0x0caf, 0x0000 },

-  { 0x0700, 0x0cb1, 0x0000 },

-  { 0x8700, 0x0cbd, 0x4000 },

-  { 0x8700, 0x0cb7, 0x3000 },

-  { 0x8700, 0x0cb5, 0x2000 },

-  { 0x0700, 0x0cb3, 0x0000 },

-  { 0x0700, 0x0cb6, 0x0000 },

-  { 0x8700, 0x0cb9, 0x2000 },

-  { 0x0700, 0x0cb8, 0x0000 },

-  { 0x0c00, 0x0cbc, 0x0000 },

-  { 0x8a00, 0x0cc1, 0x3000 },

-  { 0x8c00, 0x0cbf, 0x2000 },

-  { 0x0a00, 0x0cbe, 0x0000 },

-  { 0x0a00, 0x0cc0, 0x0000 },

-  { 0x8a00, 0x0cc3, 0x2000 },

-  { 0x0a00, 0x0cc2, 0x0000 },

-  { 0x0a00, 0x0cc4, 0x0000 },

-  { 0x8d00, 0x0cea, 0x5000 },

-  { 0x8a00, 0x0cd6, 0x4000 },

-  { 0x8a00, 0x0ccb, 0x3000 },

-  { 0x8a00, 0x0cc8, 0x2000 },

-  { 0x0a00, 0x0cc7, 0x0000 },

-  { 0x0a00, 0x0cca, 0x0000 },

-  { 0x8c00, 0x0ccd, 0x2000 },

-  { 0x0c00, 0x0ccc, 0x0000 },

-  { 0x0a00, 0x0cd5, 0x0000 },

-  { 0x8d00, 0x0ce6, 0x3000 },

-  { 0x8700, 0x0ce0, 0x2000 },

-  { 0x0700, 0x0cde, 0x0000 },

-  { 0x0700, 0x0ce1, 0x0000 },

-  { 0x8d00, 0x0ce8, 0x2000 },

-  { 0x0d00, 0x0ce7, 0x0000 },

-  { 0x0d00, 0x0ce9, 0x0000 },

-  { 0x8700, 0x0d05, 0x4000 },

-  { 0x8d00, 0x0cee, 0x3000 },

-  { 0x8d00, 0x0cec, 0x2000 },

-  { 0x0d00, 0x0ceb, 0x0000 },

-  { 0x0d00, 0x0ced, 0x0000 },

-  { 0x8a00, 0x0d02, 0x2000 },

-  { 0x0d00, 0x0cef, 0x0000 },

-  { 0x0a00, 0x0d03, 0x0000 },

-  { 0x8700, 0x0d09, 0x3000 },

-  { 0x8700, 0x0d07, 0x2000 },

-  { 0x0700, 0x0d06, 0x0000 },

-  { 0x0700, 0x0d08, 0x0000 },

-  { 0x8700, 0x0d0b, 0x2000 },

-  { 0x0700, 0x0d0a, 0x0000 },

-  { 0x0700, 0x0d0c, 0x0000 },

-  { 0x8d00, 0x0d6c, 0x7000 },

-  { 0x8700, 0x0d30, 0x6000 },

-  { 0x8700, 0x0d1f, 0x5000 },

-  { 0x8700, 0x0d17, 0x4000 },

-  { 0x8700, 0x0d13, 0x3000 },

-  { 0x8700, 0x0d10, 0x2000 },

-  { 0x0700, 0x0d0f, 0x0000 },

-  { 0x0700, 0x0d12, 0x0000 },

-  { 0x8700, 0x0d15, 0x2000 },

-  { 0x0700, 0x0d14, 0x0000 },

-  { 0x0700, 0x0d16, 0x0000 },

-  { 0x8700, 0x0d1b, 0x3000 },

-  { 0x8700, 0x0d19, 0x2000 },

-  { 0x0700, 0x0d18, 0x0000 },

-  { 0x0700, 0x0d1a, 0x0000 },

-  { 0x8700, 0x0d1d, 0x2000 },

-  { 0x0700, 0x0d1c, 0x0000 },

-  { 0x0700, 0x0d1e, 0x0000 },

-  { 0x8700, 0x0d27, 0x4000 },

-  { 0x8700, 0x0d23, 0x3000 },

-  { 0x8700, 0x0d21, 0x2000 },

-  { 0x0700, 0x0d20, 0x0000 },

-  { 0x0700, 0x0d22, 0x0000 },

-  { 0x8700, 0x0d25, 0x2000 },

-  { 0x0700, 0x0d24, 0x0000 },

-  { 0x0700, 0x0d26, 0x0000 },

-  { 0x8700, 0x0d2c, 0x3000 },

-  { 0x8700, 0x0d2a, 0x2000 },

-  { 0x0700, 0x0d28, 0x0000 },

-  { 0x0700, 0x0d2b, 0x0000 },

-  { 0x8700, 0x0d2e, 0x2000 },

-  { 0x0700, 0x0d2d, 0x0000 },

-  { 0x0700, 0x0d2f, 0x0000 },

-  { 0x8a00, 0x0d46, 0x5000 },

-  { 0x8700, 0x0d38, 0x4000 },

-  { 0x8700, 0x0d34, 0x3000 },

-  { 0x8700, 0x0d32, 0x2000 },

-  { 0x0700, 0x0d31, 0x0000 },

-  { 0x0700, 0x0d33, 0x0000 },

-  { 0x8700, 0x0d36, 0x2000 },

-  { 0x0700, 0x0d35, 0x0000 },

-  { 0x0700, 0x0d37, 0x0000 },

-  { 0x8a00, 0x0d40, 0x3000 },

-  { 0x8a00, 0x0d3e, 0x2000 },

-  { 0x0700, 0x0d39, 0x0000 },

-  { 0x0a00, 0x0d3f, 0x0000 },

-  { 0x8c00, 0x0d42, 0x2000 },

-  { 0x0c00, 0x0d41, 0x0000 },

-  { 0x0c00, 0x0d43, 0x0000 },

-  { 0x8700, 0x0d60, 0x4000 },

-  { 0x8a00, 0x0d4b, 0x3000 },

-  { 0x8a00, 0x0d48, 0x2000 },

-  { 0x0a00, 0x0d47, 0x0000 },

-  { 0x0a00, 0x0d4a, 0x0000 },

-  { 0x8c00, 0x0d4d, 0x2000 },

-  { 0x0a00, 0x0d4c, 0x0000 },

-  { 0x0a00, 0x0d57, 0x0000 },

-  { 0x8d00, 0x0d68, 0x3000 },

-  { 0x8d00, 0x0d66, 0x2000 },

-  { 0x0700, 0x0d61, 0x0000 },

-  { 0x0d00, 0x0d67, 0x0000 },

-  { 0x8d00, 0x0d6a, 0x2000 },

-  { 0x0d00, 0x0d69, 0x0000 },

-  { 0x0d00, 0x0d6b, 0x0000 },

-  { 0x8700, 0x0da2, 0x6000 },

-  { 0x8700, 0x0d8f, 0x5000 },

-  { 0x8700, 0x0d87, 0x4000 },

-  { 0x8a00, 0x0d82, 0x3000 },

-  { 0x8d00, 0x0d6e, 0x2000 },

-  { 0x0d00, 0x0d6d, 0x0000 },

-  { 0x0d00, 0x0d6f, 0x0000 },

-  { 0x8700, 0x0d85, 0x2000 },

-  { 0x0a00, 0x0d83, 0x0000 },

-  { 0x0700, 0x0d86, 0x0000 },

-  { 0x8700, 0x0d8b, 0x3000 },

-  { 0x8700, 0x0d89, 0x2000 },

-  { 0x0700, 0x0d88, 0x0000 },

-  { 0x0700, 0x0d8a, 0x0000 },

-  { 0x8700, 0x0d8d, 0x2000 },

-  { 0x0700, 0x0d8c, 0x0000 },

-  { 0x0700, 0x0d8e, 0x0000 },

-  { 0x8700, 0x0d9a, 0x4000 },

-  { 0x8700, 0x0d93, 0x3000 },

-  { 0x8700, 0x0d91, 0x2000 },

-  { 0x0700, 0x0d90, 0x0000 },

-  { 0x0700, 0x0d92, 0x0000 },

-  { 0x8700, 0x0d95, 0x2000 },

-  { 0x0700, 0x0d94, 0x0000 },

-  { 0x0700, 0x0d96, 0x0000 },

-  { 0x8700, 0x0d9e, 0x3000 },

-  { 0x8700, 0x0d9c, 0x2000 },

-  { 0x0700, 0x0d9b, 0x0000 },

-  { 0x0700, 0x0d9d, 0x0000 },

-  { 0x8700, 0x0da0, 0x2000 },

-  { 0x0700, 0x0d9f, 0x0000 },

-  { 0x0700, 0x0da1, 0x0000 },

-  { 0x8700, 0x0db3, 0x5000 },

-  { 0x8700, 0x0daa, 0x4000 },

-  { 0x8700, 0x0da6, 0x3000 },

-  { 0x8700, 0x0da4, 0x2000 },

-  { 0x0700, 0x0da3, 0x0000 },

-  { 0x0700, 0x0da5, 0x0000 },

-  { 0x8700, 0x0da8, 0x2000 },

-  { 0x0700, 0x0da7, 0x0000 },

-  { 0x0700, 0x0da9, 0x0000 },

-  { 0x8700, 0x0dae, 0x3000 },

-  { 0x8700, 0x0dac, 0x2000 },

-  { 0x0700, 0x0dab, 0x0000 },

-  { 0x0700, 0x0dad, 0x0000 },

-  { 0x8700, 0x0db0, 0x2000 },

-  { 0x0700, 0x0daf, 0x0000 },

-  { 0x0700, 0x0db1, 0x0000 },

-  { 0x8700, 0x0dbb, 0x4000 },

-  { 0x8700, 0x0db7, 0x3000 },

-  { 0x8700, 0x0db5, 0x2000 },

-  { 0x0700, 0x0db4, 0x0000 },

-  { 0x0700, 0x0db6, 0x0000 },

-  { 0x8700, 0x0db9, 0x2000 },

-  { 0x0700, 0x0db8, 0x0000 },

-  { 0x0700, 0x0dba, 0x0000 },

-  { 0x8700, 0x0dc2, 0x3000 },

-  { 0x8700, 0x0dc0, 0x2000 },

-  { 0x0700, 0x0dbd, 0x0000 },

-  { 0x0700, 0x0dc1, 0x0000 },

-  { 0x8700, 0x0dc4, 0x2000 },

-  { 0x0700, 0x0dc3, 0x0000 },

-  { 0x0700, 0x0dc5, 0x0000 },

-  { 0x8700, 0x0f55, 0x9000 },

-  { 0x8700, 0x0ea5, 0x8000 },

-  { 0x8700, 0x0e2d, 0x7000 },

-  { 0x8700, 0x0e0d, 0x6000 },

-  { 0x8a00, 0x0ddf, 0x5000 },

-  { 0x8c00, 0x0dd6, 0x4000 },

-  { 0x8a00, 0x0dd1, 0x3000 },

-  { 0x8a00, 0x0dcf, 0x2000 },

-  { 0x0c00, 0x0dca, 0x0000 },

-  { 0x0a00, 0x0dd0, 0x0000 },

-  { 0x8c00, 0x0dd3, 0x2000 },

-  { 0x0c00, 0x0dd2, 0x0000 },

-  { 0x0c00, 0x0dd4, 0x0000 },

-  { 0x8a00, 0x0ddb, 0x3000 },

-  { 0x8a00, 0x0dd9, 0x2000 },

-  { 0x0a00, 0x0dd8, 0x0000 },

-  { 0x0a00, 0x0dda, 0x0000 },

-  { 0x8a00, 0x0ddd, 0x2000 },

-  { 0x0a00, 0x0ddc, 0x0000 },

-  { 0x0a00, 0x0dde, 0x0000 },

-  { 0x8700, 0x0e05, 0x4000 },

-  { 0x8700, 0x0e01, 0x3000 },

-  { 0x8a00, 0x0df3, 0x2000 },

-  { 0x0a00, 0x0df2, 0x0000 },

-  { 0x1500, 0x0df4, 0x0000 },

-  { 0x8700, 0x0e03, 0x2000 },

-  { 0x0700, 0x0e02, 0x0000 },

-  { 0x0700, 0x0e04, 0x0000 },

-  { 0x8700, 0x0e09, 0x3000 },

-  { 0x8700, 0x0e07, 0x2000 },

-  { 0x0700, 0x0e06, 0x0000 },

-  { 0x0700, 0x0e08, 0x0000 },

-  { 0x8700, 0x0e0b, 0x2000 },

-  { 0x0700, 0x0e0a, 0x0000 },

-  { 0x0700, 0x0e0c, 0x0000 },

-  { 0x8700, 0x0e1d, 0x5000 },

-  { 0x8700, 0x0e15, 0x4000 },

-  { 0x8700, 0x0e11, 0x3000 },

-  { 0x8700, 0x0e0f, 0x2000 },

-  { 0x0700, 0x0e0e, 0x0000 },

-  { 0x0700, 0x0e10, 0x0000 },

-  { 0x8700, 0x0e13, 0x2000 },

-  { 0x0700, 0x0e12, 0x0000 },

-  { 0x0700, 0x0e14, 0x0000 },

-  { 0x8700, 0x0e19, 0x3000 },

-  { 0x8700, 0x0e17, 0x2000 },

-  { 0x0700, 0x0e16, 0x0000 },

-  { 0x0700, 0x0e18, 0x0000 },

-  { 0x8700, 0x0e1b, 0x2000 },

-  { 0x0700, 0x0e1a, 0x0000 },

-  { 0x0700, 0x0e1c, 0x0000 },

-  { 0x8700, 0x0e25, 0x4000 },

-  { 0x8700, 0x0e21, 0x3000 },

-  { 0x8700, 0x0e1f, 0x2000 },

-  { 0x0700, 0x0e1e, 0x0000 },

-  { 0x0700, 0x0e20, 0x0000 },

-  { 0x8700, 0x0e23, 0x2000 },

-  { 0x0700, 0x0e22, 0x0000 },

-  { 0x0700, 0x0e24, 0x0000 },

-  { 0x8700, 0x0e29, 0x3000 },

-  { 0x8700, 0x0e27, 0x2000 },

-  { 0x0700, 0x0e26, 0x0000 },

-  { 0x0700, 0x0e28, 0x0000 },

-  { 0x8700, 0x0e2b, 0x2000 },

-  { 0x0700, 0x0e2a, 0x0000 },

-  { 0x0700, 0x0e2c, 0x0000 },

-  { 0x8d00, 0x0e51, 0x6000 },

-  { 0x8700, 0x0e41, 0x5000 },

-  { 0x8c00, 0x0e35, 0x4000 },

-  { 0x8c00, 0x0e31, 0x3000 },

-  { 0x8700, 0x0e2f, 0x2000 },

-  { 0x0700, 0x0e2e, 0x0000 },

-  { 0x0700, 0x0e30, 0x0000 },

-  { 0x8700, 0x0e33, 0x2000 },

-  { 0x0700, 0x0e32, 0x0000 },

-  { 0x0c00, 0x0e34, 0x0000 },

-  { 0x8c00, 0x0e39, 0x3000 },

-  { 0x8c00, 0x0e37, 0x2000 },

-  { 0x0c00, 0x0e36, 0x0000 },

-  { 0x0c00, 0x0e38, 0x0000 },

-  { 0x9700, 0x0e3f, 0x2000 },

-  { 0x0c00, 0x0e3a, 0x0000 },

-  { 0x0700, 0x0e40, 0x0000 },

-  { 0x8c00, 0x0e49, 0x4000 },

-  { 0x8700, 0x0e45, 0x3000 },

-  { 0x8700, 0x0e43, 0x2000 },

-  { 0x0700, 0x0e42, 0x0000 },

-  { 0x0700, 0x0e44, 0x0000 },

-  { 0x8c00, 0x0e47, 0x2000 },

-  { 0x0600, 0x0e46, 0x0000 },

-  { 0x0c00, 0x0e48, 0x0000 },

-  { 0x8c00, 0x0e4d, 0x3000 },

-  { 0x8c00, 0x0e4b, 0x2000 },

-  { 0x0c00, 0x0e4a, 0x0000 },

-  { 0x0c00, 0x0e4c, 0x0000 },

-  { 0x9500, 0x0e4f, 0x2000 },

-  { 0x0c00, 0x0e4e, 0x0000 },

-  { 0x0d00, 0x0e50, 0x0000 },

-  { 0x8700, 0x0e8a, 0x5000 },

-  { 0x8d00, 0x0e59, 0x4000 },

-  { 0x8d00, 0x0e55, 0x3000 },

-  { 0x8d00, 0x0e53, 0x2000 },

-  { 0x0d00, 0x0e52, 0x0000 },

-  { 0x0d00, 0x0e54, 0x0000 },

-  { 0x8d00, 0x0e57, 0x2000 },

-  { 0x0d00, 0x0e56, 0x0000 },

-  { 0x0d00, 0x0e58, 0x0000 },

-  { 0x8700, 0x0e82, 0x3000 },

-  { 0x9500, 0x0e5b, 0x2000 },

-  { 0x1500, 0x0e5a, 0x0000 },

-  { 0x0700, 0x0e81, 0x0000 },

-  { 0x8700, 0x0e87, 0x2000 },

-  { 0x0700, 0x0e84, 0x0000 },

-  { 0x0700, 0x0e88, 0x0000 },

-  { 0x8700, 0x0e9b, 0x4000 },

-  { 0x8700, 0x0e96, 0x3000 },

-  { 0x8700, 0x0e94, 0x2000 },

-  { 0x0700, 0x0e8d, 0x0000 },

-  { 0x0700, 0x0e95, 0x0000 },

-  { 0x8700, 0x0e99, 0x2000 },

-  { 0x0700, 0x0e97, 0x0000 },

-  { 0x0700, 0x0e9a, 0x0000 },

-  { 0x8700, 0x0e9f, 0x3000 },

-  { 0x8700, 0x0e9d, 0x2000 },

-  { 0x0700, 0x0e9c, 0x0000 },

-  { 0x0700, 0x0e9e, 0x0000 },

-  { 0x8700, 0x0ea2, 0x2000 },

-  { 0x0700, 0x0ea1, 0x0000 },

-  { 0x0700, 0x0ea3, 0x0000 },

-  { 0x9a00, 0x0f14, 0x7000 },

-  { 0x8d00, 0x0ed0, 0x6000 },

-  { 0x8c00, 0x0eb9, 0x5000 },

-  { 0x8c00, 0x0eb1, 0x4000 },

-  { 0x8700, 0x0ead, 0x3000 },

-  { 0x8700, 0x0eaa, 0x2000 },

-  { 0x0700, 0x0ea7, 0x0000 },

-  { 0x0700, 0x0eab, 0x0000 },

-  { 0x8700, 0x0eaf, 0x2000 },

-  { 0x0700, 0x0eae, 0x0000 },

-  { 0x0700, 0x0eb0, 0x0000 },

-  { 0x8c00, 0x0eb5, 0x3000 },

-  { 0x8700, 0x0eb3, 0x2000 },

-  { 0x0700, 0x0eb2, 0x0000 },

-  { 0x0c00, 0x0eb4, 0x0000 },

-  { 0x8c00, 0x0eb7, 0x2000 },

-  { 0x0c00, 0x0eb6, 0x0000 },

-  { 0x0c00, 0x0eb8, 0x0000 },

-  { 0x8700, 0x0ec4, 0x4000 },

-  { 0x8700, 0x0ec0, 0x3000 },

-  { 0x8c00, 0x0ebc, 0x2000 },

-  { 0x0c00, 0x0ebb, 0x0000 },

-  { 0x0700, 0x0ebd, 0x0000 },

-  { 0x8700, 0x0ec2, 0x2000 },

-  { 0x0700, 0x0ec1, 0x0000 },

-  { 0x0700, 0x0ec3, 0x0000 },

-  { 0x8c00, 0x0eca, 0x3000 },

-  { 0x8c00, 0x0ec8, 0x2000 },

-  { 0x0600, 0x0ec6, 0x0000 },

-  { 0x0c00, 0x0ec9, 0x0000 },

-  { 0x8c00, 0x0ecc, 0x2000 },

-  { 0x0c00, 0x0ecb, 0x0000 },

-  { 0x0c00, 0x0ecd, 0x0000 },

-  { 0x9500, 0x0f04, 0x5000 },

-  { 0x8d00, 0x0ed8, 0x4000 },

-  { 0x8d00, 0x0ed4, 0x3000 },

-  { 0x8d00, 0x0ed2, 0x2000 },

-  { 0x0d00, 0x0ed1, 0x0000 },

-  { 0x0d00, 0x0ed3, 0x0000 },

-  { 0x8d00, 0x0ed6, 0x2000 },

-  { 0x0d00, 0x0ed5, 0x0000 },

-  { 0x0d00, 0x0ed7, 0x0000 },

-  { 0x8700, 0x0f00, 0x3000 },

-  { 0x8700, 0x0edc, 0x2000 },

-  { 0x0d00, 0x0ed9, 0x0000 },

-  { 0x0700, 0x0edd, 0x0000 },

-  { 0x9a00, 0x0f02, 0x2000 },

-  { 0x1a00, 0x0f01, 0x0000 },

-  { 0x1a00, 0x0f03, 0x0000 },

-  { 0x9500, 0x0f0c, 0x4000 },

-  { 0x9500, 0x0f08, 0x3000 },

-  { 0x9500, 0x0f06, 0x2000 },

-  { 0x1500, 0x0f05, 0x0000 },

-  { 0x1500, 0x0f07, 0x0000 },

-  { 0x9500, 0x0f0a, 0x2000 },

-  { 0x1500, 0x0f09, 0x0000 },

-  { 0x1500, 0x0f0b, 0x0000 },

-  { 0x9500, 0x0f10, 0x3000 },

-  { 0x9500, 0x0f0e, 0x2000 },

-  { 0x1500, 0x0f0d, 0x0000 },

-  { 0x1500, 0x0f0f, 0x0000 },

-  { 0x9500, 0x0f12, 0x2000 },

-  { 0x1500, 0x0f11, 0x0000 },

-  { 0x1a00, 0x0f13, 0x0000 },

-  { 0x9a00, 0x0f34, 0x6000 },

-  { 0x8d00, 0x0f24, 0x5000 },

-  { 0x9a00, 0x0f1c, 0x4000 },

-  { 0x8c00, 0x0f18, 0x3000 },

-  { 0x9a00, 0x0f16, 0x2000 },

-  { 0x1a00, 0x0f15, 0x0000 },

-  { 0x1a00, 0x0f17, 0x0000 },

-  { 0x9a00, 0x0f1a, 0x2000 },

-  { 0x0c00, 0x0f19, 0x0000 },

-  { 0x1a00, 0x0f1b, 0x0000 },

-  { 0x8d00, 0x0f20, 0x3000 },

-  { 0x9a00, 0x0f1e, 0x2000 },

-  { 0x1a00, 0x0f1d, 0x0000 },

-  { 0x1a00, 0x0f1f, 0x0000 },

-  { 0x8d00, 0x0f22, 0x2000 },

-  { 0x0d00, 0x0f21, 0x0000 },

-  { 0x0d00, 0x0f23, 0x0000 },

-  { 0x8f00, 0x0f2c, 0x4000 },

-  { 0x8d00, 0x0f28, 0x3000 },

-  { 0x8d00, 0x0f26, 0x2000 },

-  { 0x0d00, 0x0f25, 0x0000 },

-  { 0x0d00, 0x0f27, 0x0000 },

-  { 0x8f00, 0x0f2a, 0x2000 },

-  { 0x0d00, 0x0f29, 0x0000 },

-  { 0x0f00, 0x0f2b, 0x0000 },

-  { 0x8f00, 0x0f30, 0x3000 },

-  { 0x8f00, 0x0f2e, 0x2000 },

-  { 0x0f00, 0x0f2d, 0x0000 },

-  { 0x0f00, 0x0f2f, 0x0000 },

-  { 0x8f00, 0x0f32, 0x2000 },

-  { 0x0f00, 0x0f31, 0x0000 },

-  { 0x0f00, 0x0f33, 0x0000 },

-  { 0x8700, 0x0f44, 0x5000 },

-  { 0x9600, 0x0f3c, 0x4000 },

-  { 0x9a00, 0x0f38, 0x3000 },

-  { 0x9a00, 0x0f36, 0x2000 },

-  { 0x0c00, 0x0f35, 0x0000 },

-  { 0x0c00, 0x0f37, 0x0000 },

-  { 0x9600, 0x0f3a, 0x2000 },

-  { 0x0c00, 0x0f39, 0x0000 },

-  { 0x1200, 0x0f3b, 0x0000 },

-  { 0x8700, 0x0f40, 0x3000 },

-  { 0x8a00, 0x0f3e, 0x2000 },

-  { 0x1200, 0x0f3d, 0x0000 },

-  { 0x0a00, 0x0f3f, 0x0000 },

-  { 0x8700, 0x0f42, 0x2000 },

-  { 0x0700, 0x0f41, 0x0000 },

-  { 0x0700, 0x0f43, 0x0000 },

-  { 0x8700, 0x0f4d, 0x4000 },

-  { 0x8700, 0x0f49, 0x3000 },

-  { 0x8700, 0x0f46, 0x2000 },

-  { 0x0700, 0x0f45, 0x0000 },

-  { 0x0700, 0x0f47, 0x0000 },

-  { 0x8700, 0x0f4b, 0x2000 },

-  { 0x0700, 0x0f4a, 0x0000 },

-  { 0x0700, 0x0f4c, 0x0000 },

-  { 0x8700, 0x0f51, 0x3000 },

-  { 0x8700, 0x0f4f, 0x2000 },

-  { 0x0700, 0x0f4e, 0x0000 },

-  { 0x0700, 0x0f50, 0x0000 },

-  { 0x8700, 0x0f53, 0x2000 },

-  { 0x0700, 0x0f52, 0x0000 },

-  { 0x0700, 0x0f54, 0x0000 },

-  { 0x8700, 0x1013, 0x8000 },

-  { 0x8c00, 0x0fa0, 0x7000 },

-  { 0x8c00, 0x0f7b, 0x6000 },

-  { 0x8700, 0x0f65, 0x5000 },

-  { 0x8700, 0x0f5d, 0x4000 },

-  { 0x8700, 0x0f59, 0x3000 },

-  { 0x8700, 0x0f57, 0x2000 },

-  { 0x0700, 0x0f56, 0x0000 },

-  { 0x0700, 0x0f58, 0x0000 },

-  { 0x8700, 0x0f5b, 0x2000 },

-  { 0x0700, 0x0f5a, 0x0000 },

-  { 0x0700, 0x0f5c, 0x0000 },

-  { 0x8700, 0x0f61, 0x3000 },

-  { 0x8700, 0x0f5f, 0x2000 },

-  { 0x0700, 0x0f5e, 0x0000 },

-  { 0x0700, 0x0f60, 0x0000 },

-  { 0x8700, 0x0f63, 0x2000 },

-  { 0x0700, 0x0f62, 0x0000 },

-  { 0x0700, 0x0f64, 0x0000 },

-  { 0x8c00, 0x0f73, 0x4000 },

-  { 0x8700, 0x0f69, 0x3000 },

-  { 0x8700, 0x0f67, 0x2000 },

-  { 0x0700, 0x0f66, 0x0000 },

-  { 0x0700, 0x0f68, 0x0000 },

-  { 0x8c00, 0x0f71, 0x2000 },

-  { 0x0700, 0x0f6a, 0x0000 },

-  { 0x0c00, 0x0f72, 0x0000 },

-  { 0x8c00, 0x0f77, 0x3000 },

-  { 0x8c00, 0x0f75, 0x2000 },

-  { 0x0c00, 0x0f74, 0x0000 },

-  { 0x0c00, 0x0f76, 0x0000 },

-  { 0x8c00, 0x0f79, 0x2000 },

-  { 0x0c00, 0x0f78, 0x0000 },

-  { 0x0c00, 0x0f7a, 0x0000 },

-  { 0x8700, 0x0f8b, 0x5000 },

-  { 0x8c00, 0x0f83, 0x4000 },

-  { 0x8a00, 0x0f7f, 0x3000 },

-  { 0x8c00, 0x0f7d, 0x2000 },

-  { 0x0c00, 0x0f7c, 0x0000 },

-  { 0x0c00, 0x0f7e, 0x0000 },

-  { 0x8c00, 0x0f81, 0x2000 },

-  { 0x0c00, 0x0f80, 0x0000 },

-  { 0x0c00, 0x0f82, 0x0000 },

-  { 0x8c00, 0x0f87, 0x3000 },

-  { 0x9500, 0x0f85, 0x2000 },

-  { 0x0c00, 0x0f84, 0x0000 },

-  { 0x0c00, 0x0f86, 0x0000 },

-  { 0x8700, 0x0f89, 0x2000 },

-  { 0x0700, 0x0f88, 0x0000 },

-  { 0x0700, 0x0f8a, 0x0000 },

-  { 0x8c00, 0x0f97, 0x4000 },

-  { 0x8c00, 0x0f93, 0x3000 },

-  { 0x8c00, 0x0f91, 0x2000 },

-  { 0x0c00, 0x0f90, 0x0000 },

-  { 0x0c00, 0x0f92, 0x0000 },

-  { 0x8c00, 0x0f95, 0x2000 },

-  { 0x0c00, 0x0f94, 0x0000 },

-  { 0x0c00, 0x0f96, 0x0000 },

-  { 0x8c00, 0x0f9c, 0x3000 },

-  { 0x8c00, 0x0f9a, 0x2000 },

-  { 0x0c00, 0x0f99, 0x0000 },

-  { 0x0c00, 0x0f9b, 0x0000 },

-  { 0x8c00, 0x0f9e, 0x2000 },

-  { 0x0c00, 0x0f9d, 0x0000 },

-  { 0x0c00, 0x0f9f, 0x0000 },

-  { 0x9a00, 0x0fc1, 0x6000 },

-  { 0x8c00, 0x0fb0, 0x5000 },

-  { 0x8c00, 0x0fa8, 0x4000 },

-  { 0x8c00, 0x0fa4, 0x3000 },

-  { 0x8c00, 0x0fa2, 0x2000 },

-  { 0x0c00, 0x0fa1, 0x0000 },

-  { 0x0c00, 0x0fa3, 0x0000 },

-  { 0x8c00, 0x0fa6, 0x2000 },

-  { 0x0c00, 0x0fa5, 0x0000 },

-  { 0x0c00, 0x0fa7, 0x0000 },

-  { 0x8c00, 0x0fac, 0x3000 },

-  { 0x8c00, 0x0faa, 0x2000 },

-  { 0x0c00, 0x0fa9, 0x0000 },

-  { 0x0c00, 0x0fab, 0x0000 },

-  { 0x8c00, 0x0fae, 0x2000 },

-  { 0x0c00, 0x0fad, 0x0000 },

-  { 0x0c00, 0x0faf, 0x0000 },

-  { 0x8c00, 0x0fb8, 0x4000 },

-  { 0x8c00, 0x0fb4, 0x3000 },

-  { 0x8c00, 0x0fb2, 0x2000 },

-  { 0x0c00, 0x0fb1, 0x0000 },

-  { 0x0c00, 0x0fb3, 0x0000 },

-  { 0x8c00, 0x0fb6, 0x2000 },

-  { 0x0c00, 0x0fb5, 0x0000 },

-  { 0x0c00, 0x0fb7, 0x0000 },

-  { 0x8c00, 0x0fbc, 0x3000 },

-  { 0x8c00, 0x0fba, 0x2000 },

-  { 0x0c00, 0x0fb9, 0x0000 },

-  { 0x0c00, 0x0fbb, 0x0000 },

-  { 0x9a00, 0x0fbf, 0x2000 },

-  { 0x1a00, 0x0fbe, 0x0000 },

-  { 0x1a00, 0x0fc0, 0x0000 },

-  { 0x8700, 0x1003, 0x5000 },

-  { 0x9a00, 0x0fc9, 0x4000 },

-  { 0x9a00, 0x0fc5, 0x3000 },

-  { 0x9a00, 0x0fc3, 0x2000 },

-  { 0x1a00, 0x0fc2, 0x0000 },

-  { 0x1a00, 0x0fc4, 0x0000 },

-  { 0x9a00, 0x0fc7, 0x2000 },

-  { 0x0c00, 0x0fc6, 0x0000 },

-  { 0x1a00, 0x0fc8, 0x0000 },

-  { 0x9a00, 0x0fcf, 0x3000 },

-  { 0x9a00, 0x0fcb, 0x2000 },

-  { 0x1a00, 0x0fca, 0x0000 },

-  { 0x1a00, 0x0fcc, 0x0000 },

-  { 0x8700, 0x1001, 0x2000 },

-  { 0x0700, 0x1000, 0x0000 },

-  { 0x0700, 0x1002, 0x0000 },

-  { 0x8700, 0x100b, 0x4000 },

-  { 0x8700, 0x1007, 0x3000 },

-  { 0x8700, 0x1005, 0x2000 },

-  { 0x0700, 0x1004, 0x0000 },

-  { 0x0700, 0x1006, 0x0000 },

-  { 0x8700, 0x1009, 0x2000 },

-  { 0x0700, 0x1008, 0x0000 },

-  { 0x0700, 0x100a, 0x0000 },

-  { 0x8700, 0x100f, 0x3000 },

-  { 0x8700, 0x100d, 0x2000 },

-  { 0x0700, 0x100c, 0x0000 },

-  { 0x0700, 0x100e, 0x0000 },

-  { 0x8700, 0x1011, 0x2000 },

-  { 0x0700, 0x1010, 0x0000 },

-  { 0x0700, 0x1012, 0x0000 },

-  { 0x8900, 0x10a5, 0x7000 },

-  { 0x8c00, 0x1039, 0x6000 },

-  { 0x8700, 0x1024, 0x5000 },

-  { 0x8700, 0x101b, 0x4000 },

-  { 0x8700, 0x1017, 0x3000 },

-  { 0x8700, 0x1015, 0x2000 },

-  { 0x0700, 0x1014, 0x0000 },

-  { 0x0700, 0x1016, 0x0000 },

-  { 0x8700, 0x1019, 0x2000 },

-  { 0x0700, 0x1018, 0x0000 },

-  { 0x0700, 0x101a, 0x0000 },

-  { 0x8700, 0x101f, 0x3000 },

-  { 0x8700, 0x101d, 0x2000 },

-  { 0x0700, 0x101c, 0x0000 },

-  { 0x0700, 0x101e, 0x0000 },

-  { 0x8700, 0x1021, 0x2000 },

-  { 0x0700, 0x1020, 0x0000 },

-  { 0x0700, 0x1023, 0x0000 },

-  { 0x8c00, 0x102e, 0x4000 },

-  { 0x8700, 0x1029, 0x3000 },

-  { 0x8700, 0x1026, 0x2000 },

-  { 0x0700, 0x1025, 0x0000 },

-  { 0x0700, 0x1027, 0x0000 },

-  { 0x8a00, 0x102c, 0x2000 },

-  { 0x0700, 0x102a, 0x0000 },

-  { 0x0c00, 0x102d, 0x0000 },

-  { 0x8c00, 0x1032, 0x3000 },

-  { 0x8c00, 0x1030, 0x2000 },

-  { 0x0c00, 0x102f, 0x0000 },

-  { 0x0a00, 0x1031, 0x0000 },

-  { 0x8c00, 0x1037, 0x2000 },

-  { 0x0c00, 0x1036, 0x0000 },

-  { 0x0a00, 0x1038, 0x0000 },

-  { 0x9500, 0x104f, 0x5000 },

-  { 0x8d00, 0x1047, 0x4000 },

-  { 0x8d00, 0x1043, 0x3000 },

-  { 0x8d00, 0x1041, 0x2000 },

-  { 0x0d00, 0x1040, 0x0000 },

-  { 0x0d00, 0x1042, 0x0000 },

-  { 0x8d00, 0x1045, 0x2000 },

-  { 0x0d00, 0x1044, 0x0000 },

-  { 0x0d00, 0x1046, 0x0000 },

-  { 0x9500, 0x104b, 0x3000 },

-  { 0x8d00, 0x1049, 0x2000 },

-  { 0x0d00, 0x1048, 0x0000 },

-  { 0x1500, 0x104a, 0x0000 },

-  { 0x9500, 0x104d, 0x2000 },

-  { 0x1500, 0x104c, 0x0000 },

-  { 0x1500, 0x104e, 0x0000 },

-  { 0x8a00, 0x1057, 0x4000 },

-  { 0x8700, 0x1053, 0x3000 },

-  { 0x8700, 0x1051, 0x2000 },

-  { 0x0700, 0x1050, 0x0000 },

-  { 0x0700, 0x1052, 0x0000 },

-  { 0x8700, 0x1055, 0x2000 },

-  { 0x0700, 0x1054, 0x0000 },

-  { 0x0a00, 0x1056, 0x0000 },

-  { 0x8900, 0x10a1, 0x3000 },

-  { 0x8c00, 0x1059, 0x2000 },

-  { 0x0c00, 0x1058, 0x0000 },

-  { 0x0900, 0x10a0, 0x0000 },

-  { 0x8900, 0x10a3, 0x2000 },

-  { 0x0900, 0x10a2, 0x0000 },

-  { 0x0900, 0x10a4, 0x0000 },

-  { 0x8900, 0x10c5, 0x6000 },

-  { 0x8900, 0x10b5, 0x5000 },

-  { 0x8900, 0x10ad, 0x4000 },

-  { 0x8900, 0x10a9, 0x3000 },

-  { 0x8900, 0x10a7, 0x2000 },

-  { 0x0900, 0x10a6, 0x0000 },

-  { 0x0900, 0x10a8, 0x0000 },

-  { 0x8900, 0x10ab, 0x2000 },

-  { 0x0900, 0x10aa, 0x0000 },

-  { 0x0900, 0x10ac, 0x0000 },

-  { 0x8900, 0x10b1, 0x3000 },

-  { 0x8900, 0x10af, 0x2000 },

-  { 0x0900, 0x10ae, 0x0000 },

-  { 0x0900, 0x10b0, 0x0000 },

-  { 0x8900, 0x10b3, 0x2000 },

-  { 0x0900, 0x10b2, 0x0000 },

-  { 0x0900, 0x10b4, 0x0000 },

-  { 0x8900, 0x10bd, 0x4000 },

-  { 0x8900, 0x10b9, 0x3000 },

-  { 0x8900, 0x10b7, 0x2000 },

-  { 0x0900, 0x10b6, 0x0000 },

-  { 0x0900, 0x10b8, 0x0000 },

-  { 0x8900, 0x10bb, 0x2000 },

-  { 0x0900, 0x10ba, 0x0000 },

-  { 0x0900, 0x10bc, 0x0000 },

-  { 0x8900, 0x10c1, 0x3000 },

-  { 0x8900, 0x10bf, 0x2000 },

-  { 0x0900, 0x10be, 0x0000 },

-  { 0x0900, 0x10c0, 0x0000 },

-  { 0x8900, 0x10c3, 0x2000 },

-  { 0x0900, 0x10c2, 0x0000 },

-  { 0x0900, 0x10c4, 0x0000 },

-  { 0x8700, 0x10df, 0x5000 },

-  { 0x8700, 0x10d7, 0x4000 },

-  { 0x8700, 0x10d3, 0x3000 },

-  { 0x8700, 0x10d1, 0x2000 },

-  { 0x0700, 0x10d0, 0x0000 },

-  { 0x0700, 0x10d2, 0x0000 },

-  { 0x8700, 0x10d5, 0x2000 },

-  { 0x0700, 0x10d4, 0x0000 },

-  { 0x0700, 0x10d6, 0x0000 },

-  { 0x8700, 0x10db, 0x3000 },

-  { 0x8700, 0x10d9, 0x2000 },

-  { 0x0700, 0x10d8, 0x0000 },

-  { 0x0700, 0x10da, 0x0000 },

-  { 0x8700, 0x10dd, 0x2000 },

-  { 0x0700, 0x10dc, 0x0000 },

-  { 0x0700, 0x10de, 0x0000 },

-  { 0x8700, 0x10e7, 0x4000 },

-  { 0x8700, 0x10e3, 0x3000 },

-  { 0x8700, 0x10e1, 0x2000 },

-  { 0x0700, 0x10e0, 0x0000 },

-  { 0x0700, 0x10e2, 0x0000 },

-  { 0x8700, 0x10e5, 0x2000 },

-  { 0x0700, 0x10e4, 0x0000 },

-  { 0x0700, 0x10e6, 0x0000 },

-  { 0x8700, 0x10eb, 0x3000 },

-  { 0x8700, 0x10e9, 0x2000 },

-  { 0x0700, 0x10e8, 0x0000 },

-  { 0x0700, 0x10ea, 0x0000 },

-  { 0x8700, 0x10ed, 0x2000 },

-  { 0x0700, 0x10ec, 0x0000 },

-  { 0x0700, 0x10ee, 0x0000 },

-  { 0x8700, 0x1322, 0xa000 },

-  { 0x8700, 0x1205, 0x9000 },

-  { 0x8700, 0x117a, 0x8000 },

-  { 0x8700, 0x1135, 0x7000 },

-  { 0x8700, 0x1115, 0x6000 },

-  { 0x8700, 0x1105, 0x5000 },

-  { 0x8700, 0x10f7, 0x4000 },

-  { 0x8700, 0x10f3, 0x3000 },

-  { 0x8700, 0x10f1, 0x2000 },

-  { 0x0700, 0x10f0, 0x0000 },

-  { 0x0700, 0x10f2, 0x0000 },

-  { 0x8700, 0x10f5, 0x2000 },

-  { 0x0700, 0x10f4, 0x0000 },

-  { 0x0700, 0x10f6, 0x0000 },

-  { 0x8700, 0x1101, 0x3000 },

-  { 0x9500, 0x10fb, 0x2000 },

-  { 0x0700, 0x10f8, 0x0000 },

-  { 0x0700, 0x1100, 0x0000 },

-  { 0x8700, 0x1103, 0x2000 },

-  { 0x0700, 0x1102, 0x0000 },

-  { 0x0700, 0x1104, 0x0000 },

-  { 0x8700, 0x110d, 0x4000 },

-  { 0x8700, 0x1109, 0x3000 },

-  { 0x8700, 0x1107, 0x2000 },

-  { 0x0700, 0x1106, 0x0000 },

-  { 0x0700, 0x1108, 0x0000 },

-  { 0x8700, 0x110b, 0x2000 },

-  { 0x0700, 0x110a, 0x0000 },

-  { 0x0700, 0x110c, 0x0000 },

-  { 0x8700, 0x1111, 0x3000 },

-  { 0x8700, 0x110f, 0x2000 },

-  { 0x0700, 0x110e, 0x0000 },

-  { 0x0700, 0x1110, 0x0000 },

-  { 0x8700, 0x1113, 0x2000 },

-  { 0x0700, 0x1112, 0x0000 },

-  { 0x0700, 0x1114, 0x0000 },

-  { 0x8700, 0x1125, 0x5000 },

-  { 0x8700, 0x111d, 0x4000 },

-  { 0x8700, 0x1119, 0x3000 },

-  { 0x8700, 0x1117, 0x2000 },

-  { 0x0700, 0x1116, 0x0000 },

-  { 0x0700, 0x1118, 0x0000 },

-  { 0x8700, 0x111b, 0x2000 },

-  { 0x0700, 0x111a, 0x0000 },

-  { 0x0700, 0x111c, 0x0000 },

-  { 0x8700, 0x1121, 0x3000 },

-  { 0x8700, 0x111f, 0x2000 },

-  { 0x0700, 0x111e, 0x0000 },

-  { 0x0700, 0x1120, 0x0000 },

-  { 0x8700, 0x1123, 0x2000 },

-  { 0x0700, 0x1122, 0x0000 },

-  { 0x0700, 0x1124, 0x0000 },

-  { 0x8700, 0x112d, 0x4000 },

-  { 0x8700, 0x1129, 0x3000 },

-  { 0x8700, 0x1127, 0x2000 },

-  { 0x0700, 0x1126, 0x0000 },

-  { 0x0700, 0x1128, 0x0000 },

-  { 0x8700, 0x112b, 0x2000 },

-  { 0x0700, 0x112a, 0x0000 },

-  { 0x0700, 0x112c, 0x0000 },

-  { 0x8700, 0x1131, 0x3000 },

-  { 0x8700, 0x112f, 0x2000 },

-  { 0x0700, 0x112e, 0x0000 },

-  { 0x0700, 0x1130, 0x0000 },

-  { 0x8700, 0x1133, 0x2000 },

-  { 0x0700, 0x1132, 0x0000 },

-  { 0x0700, 0x1134, 0x0000 },

-  { 0x8700, 0x1155, 0x6000 },

-  { 0x8700, 0x1145, 0x5000 },

-  { 0x8700, 0x113d, 0x4000 },

-  { 0x8700, 0x1139, 0x3000 },

-  { 0x8700, 0x1137, 0x2000 },

-  { 0x0700, 0x1136, 0x0000 },

-  { 0x0700, 0x1138, 0x0000 },

-  { 0x8700, 0x113b, 0x2000 },

-  { 0x0700, 0x113a, 0x0000 },

-  { 0x0700, 0x113c, 0x0000 },

-  { 0x8700, 0x1141, 0x3000 },

-  { 0x8700, 0x113f, 0x2000 },

-  { 0x0700, 0x113e, 0x0000 },

-  { 0x0700, 0x1140, 0x0000 },

-  { 0x8700, 0x1143, 0x2000 },

-  { 0x0700, 0x1142, 0x0000 },

-  { 0x0700, 0x1144, 0x0000 },

-  { 0x8700, 0x114d, 0x4000 },

-  { 0x8700, 0x1149, 0x3000 },

-  { 0x8700, 0x1147, 0x2000 },

-  { 0x0700, 0x1146, 0x0000 },

-  { 0x0700, 0x1148, 0x0000 },

-  { 0x8700, 0x114b, 0x2000 },

-  { 0x0700, 0x114a, 0x0000 },

-  { 0x0700, 0x114c, 0x0000 },

-  { 0x8700, 0x1151, 0x3000 },

-  { 0x8700, 0x114f, 0x2000 },

-  { 0x0700, 0x114e, 0x0000 },

-  { 0x0700, 0x1150, 0x0000 },

-  { 0x8700, 0x1153, 0x2000 },

-  { 0x0700, 0x1152, 0x0000 },

-  { 0x0700, 0x1154, 0x0000 },

-  { 0x8700, 0x116a, 0x5000 },

-  { 0x8700, 0x1162, 0x4000 },

-  { 0x8700, 0x1159, 0x3000 },

-  { 0x8700, 0x1157, 0x2000 },

-  { 0x0700, 0x1156, 0x0000 },

-  { 0x0700, 0x1158, 0x0000 },

-  { 0x8700, 0x1160, 0x2000 },

-  { 0x0700, 0x115f, 0x0000 },

-  { 0x0700, 0x1161, 0x0000 },

-  { 0x8700, 0x1166, 0x3000 },

-  { 0x8700, 0x1164, 0x2000 },

-  { 0x0700, 0x1163, 0x0000 },

-  { 0x0700, 0x1165, 0x0000 },

-  { 0x8700, 0x1168, 0x2000 },

-  { 0x0700, 0x1167, 0x0000 },

-  { 0x0700, 0x1169, 0x0000 },

-  { 0x8700, 0x1172, 0x4000 },

-  { 0x8700, 0x116e, 0x3000 },

-  { 0x8700, 0x116c, 0x2000 },

-  { 0x0700, 0x116b, 0x0000 },

-  { 0x0700, 0x116d, 0x0000 },

-  { 0x8700, 0x1170, 0x2000 },

-  { 0x0700, 0x116f, 0x0000 },

-  { 0x0700, 0x1171, 0x0000 },

-  { 0x8700, 0x1176, 0x3000 },

-  { 0x8700, 0x1174, 0x2000 },

-  { 0x0700, 0x1173, 0x0000 },

-  { 0x0700, 0x1175, 0x0000 },

-  { 0x8700, 0x1178, 0x2000 },

-  { 0x0700, 0x1177, 0x0000 },

-  { 0x0700, 0x1179, 0x0000 },

-  { 0x8700, 0x11bf, 0x7000 },

-  { 0x8700, 0x119a, 0x6000 },

-  { 0x8700, 0x118a, 0x5000 },

-  { 0x8700, 0x1182, 0x4000 },

-  { 0x8700, 0x117e, 0x3000 },

-  { 0x8700, 0x117c, 0x2000 },

-  { 0x0700, 0x117b, 0x0000 },

-  { 0x0700, 0x117d, 0x0000 },

-  { 0x8700, 0x1180, 0x2000 },

-  { 0x0700, 0x117f, 0x0000 },

-  { 0x0700, 0x1181, 0x0000 },

-  { 0x8700, 0x1186, 0x3000 },

-  { 0x8700, 0x1184, 0x2000 },

-  { 0x0700, 0x1183, 0x0000 },

-  { 0x0700, 0x1185, 0x0000 },

-  { 0x8700, 0x1188, 0x2000 },

-  { 0x0700, 0x1187, 0x0000 },

-  { 0x0700, 0x1189, 0x0000 },

-  { 0x8700, 0x1192, 0x4000 },

-  { 0x8700, 0x118e, 0x3000 },

-  { 0x8700, 0x118c, 0x2000 },

-  { 0x0700, 0x118b, 0x0000 },

-  { 0x0700, 0x118d, 0x0000 },

-  { 0x8700, 0x1190, 0x2000 },

-  { 0x0700, 0x118f, 0x0000 },

-  { 0x0700, 0x1191, 0x0000 },

-  { 0x8700, 0x1196, 0x3000 },

-  { 0x8700, 0x1194, 0x2000 },

-  { 0x0700, 0x1193, 0x0000 },

-  { 0x0700, 0x1195, 0x0000 },

-  { 0x8700, 0x1198, 0x2000 },

-  { 0x0700, 0x1197, 0x0000 },

-  { 0x0700, 0x1199, 0x0000 },

-  { 0x8700, 0x11af, 0x5000 },

-  { 0x8700, 0x11a2, 0x4000 },

-  { 0x8700, 0x119e, 0x3000 },

-  { 0x8700, 0x119c, 0x2000 },

-  { 0x0700, 0x119b, 0x0000 },

-  { 0x0700, 0x119d, 0x0000 },

-  { 0x8700, 0x11a0, 0x2000 },

-  { 0x0700, 0x119f, 0x0000 },

-  { 0x0700, 0x11a1, 0x0000 },

-  { 0x8700, 0x11ab, 0x3000 },

-  { 0x8700, 0x11a9, 0x2000 },

-  { 0x0700, 0x11a8, 0x0000 },

-  { 0x0700, 0x11aa, 0x0000 },

-  { 0x8700, 0x11ad, 0x2000 },

-  { 0x0700, 0x11ac, 0x0000 },

-  { 0x0700, 0x11ae, 0x0000 },

-  { 0x8700, 0x11b7, 0x4000 },

-  { 0x8700, 0x11b3, 0x3000 },

-  { 0x8700, 0x11b1, 0x2000 },

-  { 0x0700, 0x11b0, 0x0000 },

-  { 0x0700, 0x11b2, 0x0000 },

-  { 0x8700, 0x11b5, 0x2000 },

-  { 0x0700, 0x11b4, 0x0000 },

-  { 0x0700, 0x11b6, 0x0000 },

-  { 0x8700, 0x11bb, 0x3000 },

-  { 0x8700, 0x11b9, 0x2000 },

-  { 0x0700, 0x11b8, 0x0000 },

-  { 0x0700, 0x11ba, 0x0000 },

-  { 0x8700, 0x11bd, 0x2000 },

-  { 0x0700, 0x11bc, 0x0000 },

-  { 0x0700, 0x11be, 0x0000 },

-  { 0x8700, 0x11df, 0x6000 },

-  { 0x8700, 0x11cf, 0x5000 },

-  { 0x8700, 0x11c7, 0x4000 },

-  { 0x8700, 0x11c3, 0x3000 },

-  { 0x8700, 0x11c1, 0x2000 },

-  { 0x0700, 0x11c0, 0x0000 },

-  { 0x0700, 0x11c2, 0x0000 },

-  { 0x8700, 0x11c5, 0x2000 },

-  { 0x0700, 0x11c4, 0x0000 },

-  { 0x0700, 0x11c6, 0x0000 },

-  { 0x8700, 0x11cb, 0x3000 },

-  { 0x8700, 0x11c9, 0x2000 },

-  { 0x0700, 0x11c8, 0x0000 },

-  { 0x0700, 0x11ca, 0x0000 },

-  { 0x8700, 0x11cd, 0x2000 },

-  { 0x0700, 0x11cc, 0x0000 },

-  { 0x0700, 0x11ce, 0x0000 },

-  { 0x8700, 0x11d7, 0x4000 },

-  { 0x8700, 0x11d3, 0x3000 },

-  { 0x8700, 0x11d1, 0x2000 },

-  { 0x0700, 0x11d0, 0x0000 },

-  { 0x0700, 0x11d2, 0x0000 },

-  { 0x8700, 0x11d5, 0x2000 },

-  { 0x0700, 0x11d4, 0x0000 },

-  { 0x0700, 0x11d6, 0x0000 },

-  { 0x8700, 0x11db, 0x3000 },

-  { 0x8700, 0x11d9, 0x2000 },

-  { 0x0700, 0x11d8, 0x0000 },

-  { 0x0700, 0x11da, 0x0000 },

-  { 0x8700, 0x11dd, 0x2000 },

-  { 0x0700, 0x11dc, 0x0000 },

-  { 0x0700, 0x11de, 0x0000 },

-  { 0x8700, 0x11ef, 0x5000 },

-  { 0x8700, 0x11e7, 0x4000 },

-  { 0x8700, 0x11e3, 0x3000 },

-  { 0x8700, 0x11e1, 0x2000 },

-  { 0x0700, 0x11e0, 0x0000 },

-  { 0x0700, 0x11e2, 0x0000 },

-  { 0x8700, 0x11e5, 0x2000 },

-  { 0x0700, 0x11e4, 0x0000 },

-  { 0x0700, 0x11e6, 0x0000 },

-  { 0x8700, 0x11eb, 0x3000 },

-  { 0x8700, 0x11e9, 0x2000 },

-  { 0x0700, 0x11e8, 0x0000 },

-  { 0x0700, 0x11ea, 0x0000 },

-  { 0x8700, 0x11ed, 0x2000 },

-  { 0x0700, 0x11ec, 0x0000 },

-  { 0x0700, 0x11ee, 0x0000 },

-  { 0x8700, 0x11f7, 0x4000 },

-  { 0x8700, 0x11f3, 0x3000 },

-  { 0x8700, 0x11f1, 0x2000 },

-  { 0x0700, 0x11f0, 0x0000 },

-  { 0x0700, 0x11f2, 0x0000 },

-  { 0x8700, 0x11f5, 0x2000 },

-  { 0x0700, 0x11f4, 0x0000 },

-  { 0x0700, 0x11f6, 0x0000 },

-  { 0x8700, 0x1201, 0x3000 },

-  { 0x8700, 0x11f9, 0x2000 },

-  { 0x0700, 0x11f8, 0x0000 },

-  { 0x0700, 0x1200, 0x0000 },

-  { 0x8700, 0x1203, 0x2000 },

-  { 0x0700, 0x1202, 0x0000 },

-  { 0x0700, 0x1204, 0x0000 },

-  { 0x8700, 0x1292, 0x8000 },

-  { 0x8700, 0x1246, 0x7000 },

-  { 0x8700, 0x1226, 0x6000 },

-  { 0x8700, 0x1216, 0x5000 },

-  { 0x8700, 0x120e, 0x4000 },

-  { 0x8700, 0x120a, 0x3000 },

-  { 0x8700, 0x1208, 0x2000 },

-  { 0x0700, 0x1206, 0x0000 },

-  { 0x0700, 0x1209, 0x0000 },

-  { 0x8700, 0x120c, 0x2000 },

-  { 0x0700, 0x120b, 0x0000 },

-  { 0x0700, 0x120d, 0x0000 },

-  { 0x8700, 0x1212, 0x3000 },

-  { 0x8700, 0x1210, 0x2000 },

-  { 0x0700, 0x120f, 0x0000 },

-  { 0x0700, 0x1211, 0x0000 },

-  { 0x8700, 0x1214, 0x2000 },

-  { 0x0700, 0x1213, 0x0000 },

-  { 0x0700, 0x1215, 0x0000 },

-  { 0x8700, 0x121e, 0x4000 },

-  { 0x8700, 0x121a, 0x3000 },

-  { 0x8700, 0x1218, 0x2000 },

-  { 0x0700, 0x1217, 0x0000 },

-  { 0x0700, 0x1219, 0x0000 },

-  { 0x8700, 0x121c, 0x2000 },

-  { 0x0700, 0x121b, 0x0000 },

-  { 0x0700, 0x121d, 0x0000 },

-  { 0x8700, 0x1222, 0x3000 },

-  { 0x8700, 0x1220, 0x2000 },

-  { 0x0700, 0x121f, 0x0000 },

-  { 0x0700, 0x1221, 0x0000 },

-  { 0x8700, 0x1224, 0x2000 },

-  { 0x0700, 0x1223, 0x0000 },

-  { 0x0700, 0x1225, 0x0000 },

-  { 0x8700, 0x1236, 0x5000 },

-  { 0x8700, 0x122e, 0x4000 },

-  { 0x8700, 0x122a, 0x3000 },

-  { 0x8700, 0x1228, 0x2000 },

-  { 0x0700, 0x1227, 0x0000 },

-  { 0x0700, 0x1229, 0x0000 },

-  { 0x8700, 0x122c, 0x2000 },

-  { 0x0700, 0x122b, 0x0000 },

-  { 0x0700, 0x122d, 0x0000 },

-  { 0x8700, 0x1232, 0x3000 },

-  { 0x8700, 0x1230, 0x2000 },

-  { 0x0700, 0x122f, 0x0000 },

-  { 0x0700, 0x1231, 0x0000 },

-  { 0x8700, 0x1234, 0x2000 },

-  { 0x0700, 0x1233, 0x0000 },

-  { 0x0700, 0x1235, 0x0000 },

-  { 0x8700, 0x123e, 0x4000 },

-  { 0x8700, 0x123a, 0x3000 },

-  { 0x8700, 0x1238, 0x2000 },

-  { 0x0700, 0x1237, 0x0000 },

-  { 0x0700, 0x1239, 0x0000 },

-  { 0x8700, 0x123c, 0x2000 },

-  { 0x0700, 0x123b, 0x0000 },

-  { 0x0700, 0x123d, 0x0000 },

-  { 0x8700, 0x1242, 0x3000 },

-  { 0x8700, 0x1240, 0x2000 },

-  { 0x0700, 0x123f, 0x0000 },

-  { 0x0700, 0x1241, 0x0000 },

-  { 0x8700, 0x1244, 0x2000 },

-  { 0x0700, 0x1243, 0x0000 },

-  { 0x0700, 0x1245, 0x0000 },

-  { 0x8700, 0x126e, 0x6000 },

-  { 0x8700, 0x125c, 0x5000 },

-  { 0x8700, 0x1252, 0x4000 },

-  { 0x8700, 0x124c, 0x3000 },

-  { 0x8700, 0x124a, 0x2000 },

-  { 0x0700, 0x1248, 0x0000 },

-  { 0x0700, 0x124b, 0x0000 },

-  { 0x8700, 0x1250, 0x2000 },

-  { 0x0700, 0x124d, 0x0000 },

-  { 0x0700, 0x1251, 0x0000 },

-  { 0x8700, 0x1256, 0x3000 },

-  { 0x8700, 0x1254, 0x2000 },

-  { 0x0700, 0x1253, 0x0000 },

-  { 0x0700, 0x1255, 0x0000 },

-  { 0x8700, 0x125a, 0x2000 },

-  { 0x0700, 0x1258, 0x0000 },

-  { 0x0700, 0x125b, 0x0000 },

-  { 0x8700, 0x1266, 0x4000 },

-  { 0x8700, 0x1262, 0x3000 },

-  { 0x8700, 0x1260, 0x2000 },

-  { 0x0700, 0x125d, 0x0000 },

-  { 0x0700, 0x1261, 0x0000 },

-  { 0x8700, 0x1264, 0x2000 },

-  { 0x0700, 0x1263, 0x0000 },

-  { 0x0700, 0x1265, 0x0000 },

-  { 0x8700, 0x126a, 0x3000 },

-  { 0x8700, 0x1268, 0x2000 },

-  { 0x0700, 0x1267, 0x0000 },

-  { 0x0700, 0x1269, 0x0000 },

-  { 0x8700, 0x126c, 0x2000 },

-  { 0x0700, 0x126b, 0x0000 },

-  { 0x0700, 0x126d, 0x0000 },

-  { 0x8700, 0x127e, 0x5000 },

-  { 0x8700, 0x1276, 0x4000 },

-  { 0x8700, 0x1272, 0x3000 },

-  { 0x8700, 0x1270, 0x2000 },

-  { 0x0700, 0x126f, 0x0000 },

-  { 0x0700, 0x1271, 0x0000 },

-  { 0x8700, 0x1274, 0x2000 },

-  { 0x0700, 0x1273, 0x0000 },

-  { 0x0700, 0x1275, 0x0000 },

-  { 0x8700, 0x127a, 0x3000 },

-  { 0x8700, 0x1278, 0x2000 },

-  { 0x0700, 0x1277, 0x0000 },

-  { 0x0700, 0x1279, 0x0000 },

-  { 0x8700, 0x127c, 0x2000 },

-  { 0x0700, 0x127b, 0x0000 },

-  { 0x0700, 0x127d, 0x0000 },

-  { 0x8700, 0x1286, 0x4000 },

-  { 0x8700, 0x1282, 0x3000 },

-  { 0x8700, 0x1280, 0x2000 },

-  { 0x0700, 0x127f, 0x0000 },

-  { 0x0700, 0x1281, 0x0000 },

-  { 0x8700, 0x1284, 0x2000 },

-  { 0x0700, 0x1283, 0x0000 },

-  { 0x0700, 0x1285, 0x0000 },

-  { 0x8700, 0x128c, 0x3000 },

-  { 0x8700, 0x128a, 0x2000 },

-  { 0x0700, 0x1288, 0x0000 },

-  { 0x0700, 0x128b, 0x0000 },

-  { 0x8700, 0x1290, 0x2000 },

-  { 0x0700, 0x128d, 0x0000 },

-  { 0x0700, 0x1291, 0x0000 },

-  { 0x8700, 0x12dc, 0x7000 },

-  { 0x8700, 0x12b4, 0x6000 },

-  { 0x8700, 0x12a2, 0x5000 },

-  { 0x8700, 0x129a, 0x4000 },

-  { 0x8700, 0x1296, 0x3000 },

-  { 0x8700, 0x1294, 0x2000 },

-  { 0x0700, 0x1293, 0x0000 },

-  { 0x0700, 0x1295, 0x0000 },

-  { 0x8700, 0x1298, 0x2000 },

-  { 0x0700, 0x1297, 0x0000 },

-  { 0x0700, 0x1299, 0x0000 },

-  { 0x8700, 0x129e, 0x3000 },

-  { 0x8700, 0x129c, 0x2000 },

-  { 0x0700, 0x129b, 0x0000 },

-  { 0x0700, 0x129d, 0x0000 },

-  { 0x8700, 0x12a0, 0x2000 },

-  { 0x0700, 0x129f, 0x0000 },

-  { 0x0700, 0x12a1, 0x0000 },

-  { 0x8700, 0x12aa, 0x4000 },

-  { 0x8700, 0x12a6, 0x3000 },

-  { 0x8700, 0x12a4, 0x2000 },

-  { 0x0700, 0x12a3, 0x0000 },

-  { 0x0700, 0x12a5, 0x0000 },

-  { 0x8700, 0x12a8, 0x2000 },

-  { 0x0700, 0x12a7, 0x0000 },

-  { 0x0700, 0x12a9, 0x0000 },

-  { 0x8700, 0x12ae, 0x3000 },

-  { 0x8700, 0x12ac, 0x2000 },

-  { 0x0700, 0x12ab, 0x0000 },

-  { 0x0700, 0x12ad, 0x0000 },

-  { 0x8700, 0x12b2, 0x2000 },

-  { 0x0700, 0x12b0, 0x0000 },

-  { 0x0700, 0x12b3, 0x0000 },

-  { 0x8700, 0x12ca, 0x5000 },

-  { 0x8700, 0x12be, 0x4000 },

-  { 0x8700, 0x12ba, 0x3000 },

-  { 0x8700, 0x12b8, 0x2000 },

-  { 0x0700, 0x12b5, 0x0000 },

-  { 0x0700, 0x12b9, 0x0000 },

-  { 0x8700, 0x12bc, 0x2000 },

-  { 0x0700, 0x12bb, 0x0000 },

-  { 0x0700, 0x12bd, 0x0000 },

-  { 0x8700, 0x12c4, 0x3000 },

-  { 0x8700, 0x12c2, 0x2000 },

-  { 0x0700, 0x12c0, 0x0000 },

-  { 0x0700, 0x12c3, 0x0000 },

-  { 0x8700, 0x12c8, 0x2000 },

-  { 0x0700, 0x12c5, 0x0000 },

-  { 0x0700, 0x12c9, 0x0000 },

-  { 0x8700, 0x12d3, 0x4000 },

-  { 0x8700, 0x12ce, 0x3000 },

-  { 0x8700, 0x12cc, 0x2000 },

-  { 0x0700, 0x12cb, 0x0000 },

-  { 0x0700, 0x12cd, 0x0000 },

-  { 0x8700, 0x12d1, 0x2000 },

-  { 0x0700, 0x12d0, 0x0000 },

-  { 0x0700, 0x12d2, 0x0000 },

-  { 0x8700, 0x12d8, 0x3000 },

-  { 0x8700, 0x12d5, 0x2000 },

-  { 0x0700, 0x12d4, 0x0000 },

-  { 0x0700, 0x12d6, 0x0000 },

-  { 0x8700, 0x12da, 0x2000 },

-  { 0x0700, 0x12d9, 0x0000 },

-  { 0x0700, 0x12db, 0x0000 },

-  { 0x8700, 0x12fd, 0x6000 },

-  { 0x8700, 0x12ec, 0x5000 },

-  { 0x8700, 0x12e4, 0x4000 },

-  { 0x8700, 0x12e0, 0x3000 },

-  { 0x8700, 0x12de, 0x2000 },

-  { 0x0700, 0x12dd, 0x0000 },

-  { 0x0700, 0x12df, 0x0000 },

-  { 0x8700, 0x12e2, 0x2000 },

-  { 0x0700, 0x12e1, 0x0000 },

-  { 0x0700, 0x12e3, 0x0000 },

-  { 0x8700, 0x12e8, 0x3000 },

-  { 0x8700, 0x12e6, 0x2000 },

-  { 0x0700, 0x12e5, 0x0000 },

-  { 0x0700, 0x12e7, 0x0000 },

-  { 0x8700, 0x12ea, 0x2000 },

-  { 0x0700, 0x12e9, 0x0000 },

-  { 0x0700, 0x12eb, 0x0000 },

-  { 0x8700, 0x12f5, 0x4000 },

-  { 0x8700, 0x12f1, 0x3000 },

-  { 0x8700, 0x12ee, 0x2000 },

-  { 0x0700, 0x12ed, 0x0000 },

-  { 0x0700, 0x12f0, 0x0000 },

-  { 0x8700, 0x12f3, 0x2000 },

-  { 0x0700, 0x12f2, 0x0000 },

-  { 0x0700, 0x12f4, 0x0000 },

-  { 0x8700, 0x12f9, 0x3000 },

-  { 0x8700, 0x12f7, 0x2000 },

-  { 0x0700, 0x12f6, 0x0000 },

-  { 0x0700, 0x12f8, 0x0000 },

-  { 0x8700, 0x12fb, 0x2000 },

-  { 0x0700, 0x12fa, 0x0000 },

-  { 0x0700, 0x12fc, 0x0000 },

-  { 0x8700, 0x130d, 0x5000 },

-  { 0x8700, 0x1305, 0x4000 },

-  { 0x8700, 0x1301, 0x3000 },

-  { 0x8700, 0x12ff, 0x2000 },

-  { 0x0700, 0x12fe, 0x0000 },

-  { 0x0700, 0x1300, 0x0000 },

-  { 0x8700, 0x1303, 0x2000 },

-  { 0x0700, 0x1302, 0x0000 },

-  { 0x0700, 0x1304, 0x0000 },

-  { 0x8700, 0x1309, 0x3000 },

-  { 0x8700, 0x1307, 0x2000 },

-  { 0x0700, 0x1306, 0x0000 },

-  { 0x0700, 0x1308, 0x0000 },

-  { 0x8700, 0x130b, 0x2000 },

-  { 0x0700, 0x130a, 0x0000 },

-  { 0x0700, 0x130c, 0x0000 },

-  { 0x8700, 0x1319, 0x4000 },

-  { 0x8700, 0x1313, 0x3000 },

-  { 0x8700, 0x1310, 0x2000 },

-  { 0x0700, 0x130e, 0x0000 },

-  { 0x0700, 0x1312, 0x0000 },

-  { 0x8700, 0x1315, 0x2000 },

-  { 0x0700, 0x1314, 0x0000 },

-  { 0x0700, 0x1318, 0x0000 },

-  { 0x8700, 0x131d, 0x3000 },

-  { 0x8700, 0x131b, 0x2000 },

-  { 0x0700, 0x131a, 0x0000 },

-  { 0x0700, 0x131c, 0x0000 },

-  { 0x8700, 0x1320, 0x2000 },

-  { 0x0700, 0x131e, 0x0000 },

-  { 0x0700, 0x1321, 0x0000 },

-  { 0x8700, 0x1458, 0x9000 },

-  { 0x8700, 0x13cc, 0x8000 },

-  { 0x8d00, 0x1369, 0x7000 },

-  { 0x8700, 0x1342, 0x6000 },

-  { 0x8700, 0x1332, 0x5000 },

-  { 0x8700, 0x132a, 0x4000 },

-  { 0x8700, 0x1326, 0x3000 },

-  { 0x8700, 0x1324, 0x2000 },

-  { 0x0700, 0x1323, 0x0000 },

-  { 0x0700, 0x1325, 0x0000 },

-  { 0x8700, 0x1328, 0x2000 },

-  { 0x0700, 0x1327, 0x0000 },

-  { 0x0700, 0x1329, 0x0000 },

-  { 0x8700, 0x132e, 0x3000 },

-  { 0x8700, 0x132c, 0x2000 },

-  { 0x0700, 0x132b, 0x0000 },

-  { 0x0700, 0x132d, 0x0000 },

-  { 0x8700, 0x1330, 0x2000 },

-  { 0x0700, 0x132f, 0x0000 },

-  { 0x0700, 0x1331, 0x0000 },

-  { 0x8700, 0x133a, 0x4000 },

-  { 0x8700, 0x1336, 0x3000 },

-  { 0x8700, 0x1334, 0x2000 },

-  { 0x0700, 0x1333, 0x0000 },

-  { 0x0700, 0x1335, 0x0000 },

-  { 0x8700, 0x1338, 0x2000 },

-  { 0x0700, 0x1337, 0x0000 },

-  { 0x0700, 0x1339, 0x0000 },

-  { 0x8700, 0x133e, 0x3000 },

-  { 0x8700, 0x133c, 0x2000 },

-  { 0x0700, 0x133b, 0x0000 },

-  { 0x0700, 0x133d, 0x0000 },

-  { 0x8700, 0x1340, 0x2000 },

-  { 0x0700, 0x133f, 0x0000 },

-  { 0x0700, 0x1341, 0x0000 },

-  { 0x8700, 0x1353, 0x5000 },

-  { 0x8700, 0x134b, 0x4000 },

-  { 0x8700, 0x1346, 0x3000 },

-  { 0x8700, 0x1344, 0x2000 },

-  { 0x0700, 0x1343, 0x0000 },

-  { 0x0700, 0x1345, 0x0000 },

-  { 0x8700, 0x1349, 0x2000 },

-  { 0x0700, 0x1348, 0x0000 },

-  { 0x0700, 0x134a, 0x0000 },

-  { 0x8700, 0x134f, 0x3000 },

-  { 0x8700, 0x134d, 0x2000 },

-  { 0x0700, 0x134c, 0x0000 },

-  { 0x0700, 0x134e, 0x0000 },

-  { 0x8700, 0x1351, 0x2000 },

-  { 0x0700, 0x1350, 0x0000 },

-  { 0x0700, 0x1352, 0x0000 },

-  { 0x9500, 0x1361, 0x4000 },

-  { 0x8700, 0x1357, 0x3000 },

-  { 0x8700, 0x1355, 0x2000 },

-  { 0x0700, 0x1354, 0x0000 },

-  { 0x0700, 0x1356, 0x0000 },

-  { 0x8700, 0x1359, 0x2000 },

-  { 0x0700, 0x1358, 0x0000 },

-  { 0x0700, 0x135a, 0x0000 },

-  { 0x9500, 0x1365, 0x3000 },

-  { 0x9500, 0x1363, 0x2000 },

-  { 0x1500, 0x1362, 0x0000 },

-  { 0x1500, 0x1364, 0x0000 },

-  { 0x9500, 0x1367, 0x2000 },

-  { 0x1500, 0x1366, 0x0000 },

-  { 0x1500, 0x1368, 0x0000 },

-  { 0x8700, 0x13ac, 0x6000 },

-  { 0x8f00, 0x1379, 0x5000 },

-  { 0x8d00, 0x1371, 0x4000 },

-  { 0x8d00, 0x136d, 0x3000 },

-  { 0x8d00, 0x136b, 0x2000 },

-  { 0x0d00, 0x136a, 0x0000 },

-  { 0x0d00, 0x136c, 0x0000 },

-  { 0x8d00, 0x136f, 0x2000 },

-  { 0x0d00, 0x136e, 0x0000 },

-  { 0x0d00, 0x1370, 0x0000 },

-  { 0x8f00, 0x1375, 0x3000 },

-  { 0x8f00, 0x1373, 0x2000 },

-  { 0x0f00, 0x1372, 0x0000 },

-  { 0x0f00, 0x1374, 0x0000 },

-  { 0x8f00, 0x1377, 0x2000 },

-  { 0x0f00, 0x1376, 0x0000 },

-  { 0x0f00, 0x1378, 0x0000 },

-  { 0x8700, 0x13a4, 0x4000 },

-  { 0x8700, 0x13a0, 0x3000 },

-  { 0x8f00, 0x137b, 0x2000 },

-  { 0x0f00, 0x137a, 0x0000 },

-  { 0x0f00, 0x137c, 0x0000 },

-  { 0x8700, 0x13a2, 0x2000 },

-  { 0x0700, 0x13a1, 0x0000 },

-  { 0x0700, 0x13a3, 0x0000 },

-  { 0x8700, 0x13a8, 0x3000 },

-  { 0x8700, 0x13a6, 0x2000 },

-  { 0x0700, 0x13a5, 0x0000 },

-  { 0x0700, 0x13a7, 0x0000 },

-  { 0x8700, 0x13aa, 0x2000 },

-  { 0x0700, 0x13a9, 0x0000 },

-  { 0x0700, 0x13ab, 0x0000 },

-  { 0x8700, 0x13bc, 0x5000 },

-  { 0x8700, 0x13b4, 0x4000 },

-  { 0x8700, 0x13b0, 0x3000 },

-  { 0x8700, 0x13ae, 0x2000 },

-  { 0x0700, 0x13ad, 0x0000 },

-  { 0x0700, 0x13af, 0x0000 },

-  { 0x8700, 0x13b2, 0x2000 },

-  { 0x0700, 0x13b1, 0x0000 },

-  { 0x0700, 0x13b3, 0x0000 },

-  { 0x8700, 0x13b8, 0x3000 },

-  { 0x8700, 0x13b6, 0x2000 },

-  { 0x0700, 0x13b5, 0x0000 },

-  { 0x0700, 0x13b7, 0x0000 },

-  { 0x8700, 0x13ba, 0x2000 },

-  { 0x0700, 0x13b9, 0x0000 },

-  { 0x0700, 0x13bb, 0x0000 },

-  { 0x8700, 0x13c4, 0x4000 },

-  { 0x8700, 0x13c0, 0x3000 },

-  { 0x8700, 0x13be, 0x2000 },

-  { 0x0700, 0x13bd, 0x0000 },

-  { 0x0700, 0x13bf, 0x0000 },

-  { 0x8700, 0x13c2, 0x2000 },

-  { 0x0700, 0x13c1, 0x0000 },

-  { 0x0700, 0x13c3, 0x0000 },

-  { 0x8700, 0x13c8, 0x3000 },

-  { 0x8700, 0x13c6, 0x2000 },

-  { 0x0700, 0x13c5, 0x0000 },

-  { 0x0700, 0x13c7, 0x0000 },

-  { 0x8700, 0x13ca, 0x2000 },

-  { 0x0700, 0x13c9, 0x0000 },

-  { 0x0700, 0x13cb, 0x0000 },

-  { 0x8700, 0x1418, 0x7000 },

-  { 0x8700, 0x13ec, 0x6000 },

-  { 0x8700, 0x13dc, 0x5000 },

-  { 0x8700, 0x13d4, 0x4000 },

-  { 0x8700, 0x13d0, 0x3000 },

-  { 0x8700, 0x13ce, 0x2000 },

-  { 0x0700, 0x13cd, 0x0000 },

-  { 0x0700, 0x13cf, 0x0000 },

-  { 0x8700, 0x13d2, 0x2000 },

-  { 0x0700, 0x13d1, 0x0000 },

-  { 0x0700, 0x13d3, 0x0000 },

-  { 0x8700, 0x13d8, 0x3000 },

-  { 0x8700, 0x13d6, 0x2000 },

-  { 0x0700, 0x13d5, 0x0000 },

-  { 0x0700, 0x13d7, 0x0000 },

-  { 0x8700, 0x13da, 0x2000 },

-  { 0x0700, 0x13d9, 0x0000 },

-  { 0x0700, 0x13db, 0x0000 },

-  { 0x8700, 0x13e4, 0x4000 },

-  { 0x8700, 0x13e0, 0x3000 },

-  { 0x8700, 0x13de, 0x2000 },

-  { 0x0700, 0x13dd, 0x0000 },

-  { 0x0700, 0x13df, 0x0000 },

-  { 0x8700, 0x13e2, 0x2000 },

-  { 0x0700, 0x13e1, 0x0000 },

-  { 0x0700, 0x13e3, 0x0000 },

-  { 0x8700, 0x13e8, 0x3000 },

-  { 0x8700, 0x13e6, 0x2000 },

-  { 0x0700, 0x13e5, 0x0000 },

-  { 0x0700, 0x13e7, 0x0000 },

-  { 0x8700, 0x13ea, 0x2000 },

-  { 0x0700, 0x13e9, 0x0000 },

-  { 0x0700, 0x13eb, 0x0000 },

-  { 0x8700, 0x1408, 0x5000 },

-  { 0x8700, 0x13f4, 0x4000 },

-  { 0x8700, 0x13f0, 0x3000 },

-  { 0x8700, 0x13ee, 0x2000 },

-  { 0x0700, 0x13ed, 0x0000 },

-  { 0x0700, 0x13ef, 0x0000 },

-  { 0x8700, 0x13f2, 0x2000 },

-  { 0x0700, 0x13f1, 0x0000 },

-  { 0x0700, 0x13f3, 0x0000 },

-  { 0x8700, 0x1404, 0x3000 },

-  { 0x8700, 0x1402, 0x2000 },

-  { 0x0700, 0x1401, 0x0000 },

-  { 0x0700, 0x1403, 0x0000 },

-  { 0x8700, 0x1406, 0x2000 },

-  { 0x0700, 0x1405, 0x0000 },

-  { 0x0700, 0x1407, 0x0000 },

-  { 0x8700, 0x1410, 0x4000 },

-  { 0x8700, 0x140c, 0x3000 },

-  { 0x8700, 0x140a, 0x2000 },

-  { 0x0700, 0x1409, 0x0000 },

-  { 0x0700, 0x140b, 0x0000 },

-  { 0x8700, 0x140e, 0x2000 },

-  { 0x0700, 0x140d, 0x0000 },

-  { 0x0700, 0x140f, 0x0000 },

-  { 0x8700, 0x1414, 0x3000 },

-  { 0x8700, 0x1412, 0x2000 },

-  { 0x0700, 0x1411, 0x0000 },

-  { 0x0700, 0x1413, 0x0000 },

-  { 0x8700, 0x1416, 0x2000 },

-  { 0x0700, 0x1415, 0x0000 },

-  { 0x0700, 0x1417, 0x0000 },

-  { 0x8700, 0x1438, 0x6000 },

-  { 0x8700, 0x1428, 0x5000 },

-  { 0x8700, 0x1420, 0x4000 },

-  { 0x8700, 0x141c, 0x3000 },

-  { 0x8700, 0x141a, 0x2000 },

-  { 0x0700, 0x1419, 0x0000 },

-  { 0x0700, 0x141b, 0x0000 },

-  { 0x8700, 0x141e, 0x2000 },

-  { 0x0700, 0x141d, 0x0000 },

-  { 0x0700, 0x141f, 0x0000 },

-  { 0x8700, 0x1424, 0x3000 },

-  { 0x8700, 0x1422, 0x2000 },

-  { 0x0700, 0x1421, 0x0000 },

-  { 0x0700, 0x1423, 0x0000 },

-  { 0x8700, 0x1426, 0x2000 },

-  { 0x0700, 0x1425, 0x0000 },

-  { 0x0700, 0x1427, 0x0000 },

-  { 0x8700, 0x1430, 0x4000 },

-  { 0x8700, 0x142c, 0x3000 },

-  { 0x8700, 0x142a, 0x2000 },

-  { 0x0700, 0x1429, 0x0000 },

-  { 0x0700, 0x142b, 0x0000 },

-  { 0x8700, 0x142e, 0x2000 },

-  { 0x0700, 0x142d, 0x0000 },

-  { 0x0700, 0x142f, 0x0000 },

-  { 0x8700, 0x1434, 0x3000 },

-  { 0x8700, 0x1432, 0x2000 },

-  { 0x0700, 0x1431, 0x0000 },

-  { 0x0700, 0x1433, 0x0000 },

-  { 0x8700, 0x1436, 0x2000 },

-  { 0x0700, 0x1435, 0x0000 },

-  { 0x0700, 0x1437, 0x0000 },

-  { 0x8700, 0x1448, 0x5000 },

-  { 0x8700, 0x1440, 0x4000 },

-  { 0x8700, 0x143c, 0x3000 },

-  { 0x8700, 0x143a, 0x2000 },

-  { 0x0700, 0x1439, 0x0000 },

-  { 0x0700, 0x143b, 0x0000 },

-  { 0x8700, 0x143e, 0x2000 },

-  { 0x0700, 0x143d, 0x0000 },

-  { 0x0700, 0x143f, 0x0000 },

-  { 0x8700, 0x1444, 0x3000 },

-  { 0x8700, 0x1442, 0x2000 },

-  { 0x0700, 0x1441, 0x0000 },

-  { 0x0700, 0x1443, 0x0000 },

-  { 0x8700, 0x1446, 0x2000 },

-  { 0x0700, 0x1445, 0x0000 },

-  { 0x0700, 0x1447, 0x0000 },

-  { 0x8700, 0x1450, 0x4000 },

-  { 0x8700, 0x144c, 0x3000 },

-  { 0x8700, 0x144a, 0x2000 },

-  { 0x0700, 0x1449, 0x0000 },

-  { 0x0700, 0x144b, 0x0000 },

-  { 0x8700, 0x144e, 0x2000 },

-  { 0x0700, 0x144d, 0x0000 },

-  { 0x0700, 0x144f, 0x0000 },

-  { 0x8700, 0x1454, 0x3000 },

-  { 0x8700, 0x1452, 0x2000 },

-  { 0x0700, 0x1451, 0x0000 },

-  { 0x0700, 0x1453, 0x0000 },

-  { 0x8700, 0x1456, 0x2000 },

-  { 0x0700, 0x1455, 0x0000 },

-  { 0x0700, 0x1457, 0x0000 },

-  { 0x8700, 0x14d8, 0x8000 },

-  { 0x8700, 0x1498, 0x7000 },

-  { 0x8700, 0x1478, 0x6000 },

-  { 0x8700, 0x1468, 0x5000 },

-  { 0x8700, 0x1460, 0x4000 },

-  { 0x8700, 0x145c, 0x3000 },

-  { 0x8700, 0x145a, 0x2000 },

-  { 0x0700, 0x1459, 0x0000 },

-  { 0x0700, 0x145b, 0x0000 },

-  { 0x8700, 0x145e, 0x2000 },

-  { 0x0700, 0x145d, 0x0000 },

-  { 0x0700, 0x145f, 0x0000 },

-  { 0x8700, 0x1464, 0x3000 },

-  { 0x8700, 0x1462, 0x2000 },

-  { 0x0700, 0x1461, 0x0000 },

-  { 0x0700, 0x1463, 0x0000 },

-  { 0x8700, 0x1466, 0x2000 },

-  { 0x0700, 0x1465, 0x0000 },

-  { 0x0700, 0x1467, 0x0000 },

-  { 0x8700, 0x1470, 0x4000 },

-  { 0x8700, 0x146c, 0x3000 },

-  { 0x8700, 0x146a, 0x2000 },

-  { 0x0700, 0x1469, 0x0000 },

-  { 0x0700, 0x146b, 0x0000 },

-  { 0x8700, 0x146e, 0x2000 },

-  { 0x0700, 0x146d, 0x0000 },

-  { 0x0700, 0x146f, 0x0000 },

-  { 0x8700, 0x1474, 0x3000 },

-  { 0x8700, 0x1472, 0x2000 },

-  { 0x0700, 0x1471, 0x0000 },

-  { 0x0700, 0x1473, 0x0000 },

-  { 0x8700, 0x1476, 0x2000 },

-  { 0x0700, 0x1475, 0x0000 },

-  { 0x0700, 0x1477, 0x0000 },

-  { 0x8700, 0x1488, 0x5000 },

-  { 0x8700, 0x1480, 0x4000 },

-  { 0x8700, 0x147c, 0x3000 },

-  { 0x8700, 0x147a, 0x2000 },

-  { 0x0700, 0x1479, 0x0000 },

-  { 0x0700, 0x147b, 0x0000 },

-  { 0x8700, 0x147e, 0x2000 },

-  { 0x0700, 0x147d, 0x0000 },

-  { 0x0700, 0x147f, 0x0000 },

-  { 0x8700, 0x1484, 0x3000 },

-  { 0x8700, 0x1482, 0x2000 },

-  { 0x0700, 0x1481, 0x0000 },

-  { 0x0700, 0x1483, 0x0000 },

-  { 0x8700, 0x1486, 0x2000 },

-  { 0x0700, 0x1485, 0x0000 },

-  { 0x0700, 0x1487, 0x0000 },

-  { 0x8700, 0x1490, 0x4000 },

-  { 0x8700, 0x148c, 0x3000 },

-  { 0x8700, 0x148a, 0x2000 },

-  { 0x0700, 0x1489, 0x0000 },

-  { 0x0700, 0x148b, 0x0000 },

-  { 0x8700, 0x148e, 0x2000 },

-  { 0x0700, 0x148d, 0x0000 },

-  { 0x0700, 0x148f, 0x0000 },

-  { 0x8700, 0x1494, 0x3000 },

-  { 0x8700, 0x1492, 0x2000 },

-  { 0x0700, 0x1491, 0x0000 },

-  { 0x0700, 0x1493, 0x0000 },

-  { 0x8700, 0x1496, 0x2000 },

-  { 0x0700, 0x1495, 0x0000 },

-  { 0x0700, 0x1497, 0x0000 },

-  { 0x8700, 0x14b8, 0x6000 },

-  { 0x8700, 0x14a8, 0x5000 },

-  { 0x8700, 0x14a0, 0x4000 },

-  { 0x8700, 0x149c, 0x3000 },

-  { 0x8700, 0x149a, 0x2000 },

-  { 0x0700, 0x1499, 0x0000 },

-  { 0x0700, 0x149b, 0x0000 },

-  { 0x8700, 0x149e, 0x2000 },

-  { 0x0700, 0x149d, 0x0000 },

-  { 0x0700, 0x149f, 0x0000 },

-  { 0x8700, 0x14a4, 0x3000 },

-  { 0x8700, 0x14a2, 0x2000 },

-  { 0x0700, 0x14a1, 0x0000 },

-  { 0x0700, 0x14a3, 0x0000 },

-  { 0x8700, 0x14a6, 0x2000 },

-  { 0x0700, 0x14a5, 0x0000 },

-  { 0x0700, 0x14a7, 0x0000 },

-  { 0x8700, 0x14b0, 0x4000 },

-  { 0x8700, 0x14ac, 0x3000 },

-  { 0x8700, 0x14aa, 0x2000 },

-  { 0x0700, 0x14a9, 0x0000 },

-  { 0x0700, 0x14ab, 0x0000 },

-  { 0x8700, 0x14ae, 0x2000 },

-  { 0x0700, 0x14ad, 0x0000 },

-  { 0x0700, 0x14af, 0x0000 },

-  { 0x8700, 0x14b4, 0x3000 },

-  { 0x8700, 0x14b2, 0x2000 },

-  { 0x0700, 0x14b1, 0x0000 },

-  { 0x0700, 0x14b3, 0x0000 },

-  { 0x8700, 0x14b6, 0x2000 },

-  { 0x0700, 0x14b5, 0x0000 },

-  { 0x0700, 0x14b7, 0x0000 },

-  { 0x8700, 0x14c8, 0x5000 },

-  { 0x8700, 0x14c0, 0x4000 },

-  { 0x8700, 0x14bc, 0x3000 },

-  { 0x8700, 0x14ba, 0x2000 },

-  { 0x0700, 0x14b9, 0x0000 },

-  { 0x0700, 0x14bb, 0x0000 },

-  { 0x8700, 0x14be, 0x2000 },

-  { 0x0700, 0x14bd, 0x0000 },

-  { 0x0700, 0x14bf, 0x0000 },

-  { 0x8700, 0x14c4, 0x3000 },

-  { 0x8700, 0x14c2, 0x2000 },

-  { 0x0700, 0x14c1, 0x0000 },

-  { 0x0700, 0x14c3, 0x0000 },

-  { 0x8700, 0x14c6, 0x2000 },

-  { 0x0700, 0x14c5, 0x0000 },

-  { 0x0700, 0x14c7, 0x0000 },

-  { 0x8700, 0x14d0, 0x4000 },

-  { 0x8700, 0x14cc, 0x3000 },

-  { 0x8700, 0x14ca, 0x2000 },

-  { 0x0700, 0x14c9, 0x0000 },

-  { 0x0700, 0x14cb, 0x0000 },

-  { 0x8700, 0x14ce, 0x2000 },

-  { 0x0700, 0x14cd, 0x0000 },

-  { 0x0700, 0x14cf, 0x0000 },

-  { 0x8700, 0x14d4, 0x3000 },

-  { 0x8700, 0x14d2, 0x2000 },

-  { 0x0700, 0x14d1, 0x0000 },

-  { 0x0700, 0x14d3, 0x0000 },

-  { 0x8700, 0x14d6, 0x2000 },

-  { 0x0700, 0x14d5, 0x0000 },

-  { 0x0700, 0x14d7, 0x0000 },

-  { 0x8700, 0x1518, 0x7000 },

-  { 0x8700, 0x14f8, 0x6000 },

-  { 0x8700, 0x14e8, 0x5000 },

-  { 0x8700, 0x14e0, 0x4000 },

-  { 0x8700, 0x14dc, 0x3000 },

-  { 0x8700, 0x14da, 0x2000 },

-  { 0x0700, 0x14d9, 0x0000 },

-  { 0x0700, 0x14db, 0x0000 },

-  { 0x8700, 0x14de, 0x2000 },

-  { 0x0700, 0x14dd, 0x0000 },

-  { 0x0700, 0x14df, 0x0000 },

-  { 0x8700, 0x14e4, 0x3000 },

-  { 0x8700, 0x14e2, 0x2000 },

-  { 0x0700, 0x14e1, 0x0000 },

-  { 0x0700, 0x14e3, 0x0000 },

-  { 0x8700, 0x14e6, 0x2000 },

-  { 0x0700, 0x14e5, 0x0000 },

-  { 0x0700, 0x14e7, 0x0000 },

-  { 0x8700, 0x14f0, 0x4000 },

-  { 0x8700, 0x14ec, 0x3000 },

-  { 0x8700, 0x14ea, 0x2000 },

-  { 0x0700, 0x14e9, 0x0000 },

-  { 0x0700, 0x14eb, 0x0000 },

-  { 0x8700, 0x14ee, 0x2000 },

-  { 0x0700, 0x14ed, 0x0000 },

-  { 0x0700, 0x14ef, 0x0000 },

-  { 0x8700, 0x14f4, 0x3000 },

-  { 0x8700, 0x14f2, 0x2000 },

-  { 0x0700, 0x14f1, 0x0000 },

-  { 0x0700, 0x14f3, 0x0000 },

-  { 0x8700, 0x14f6, 0x2000 },

-  { 0x0700, 0x14f5, 0x0000 },

-  { 0x0700, 0x14f7, 0x0000 },

-  { 0x8700, 0x1508, 0x5000 },

-  { 0x8700, 0x1500, 0x4000 },

-  { 0x8700, 0x14fc, 0x3000 },

-  { 0x8700, 0x14fa, 0x2000 },

-  { 0x0700, 0x14f9, 0x0000 },

-  { 0x0700, 0x14fb, 0x0000 },

-  { 0x8700, 0x14fe, 0x2000 },

-  { 0x0700, 0x14fd, 0x0000 },

-  { 0x0700, 0x14ff, 0x0000 },

-  { 0x8700, 0x1504, 0x3000 },

-  { 0x8700, 0x1502, 0x2000 },

-  { 0x0700, 0x1501, 0x0000 },

-  { 0x0700, 0x1503, 0x0000 },

-  { 0x8700, 0x1506, 0x2000 },

-  { 0x0700, 0x1505, 0x0000 },

-  { 0x0700, 0x1507, 0x0000 },

-  { 0x8700, 0x1510, 0x4000 },

-  { 0x8700, 0x150c, 0x3000 },

-  { 0x8700, 0x150a, 0x2000 },

-  { 0x0700, 0x1509, 0x0000 },

-  { 0x0700, 0x150b, 0x0000 },

-  { 0x8700, 0x150e, 0x2000 },

-  { 0x0700, 0x150d, 0x0000 },

-  { 0x0700, 0x150f, 0x0000 },

-  { 0x8700, 0x1514, 0x3000 },

-  { 0x8700, 0x1512, 0x2000 },

-  { 0x0700, 0x1511, 0x0000 },

-  { 0x0700, 0x1513, 0x0000 },

-  { 0x8700, 0x1516, 0x2000 },

-  { 0x0700, 0x1515, 0x0000 },

-  { 0x0700, 0x1517, 0x0000 },

-  { 0x8700, 0x1538, 0x6000 },

-  { 0x8700, 0x1528, 0x5000 },

-  { 0x8700, 0x1520, 0x4000 },

-  { 0x8700, 0x151c, 0x3000 },

-  { 0x8700, 0x151a, 0x2000 },

-  { 0x0700, 0x1519, 0x0000 },

-  { 0x0700, 0x151b, 0x0000 },

-  { 0x8700, 0x151e, 0x2000 },

-  { 0x0700, 0x151d, 0x0000 },

-  { 0x0700, 0x151f, 0x0000 },

-  { 0x8700, 0x1524, 0x3000 },

-  { 0x8700, 0x1522, 0x2000 },

-  { 0x0700, 0x1521, 0x0000 },

-  { 0x0700, 0x1523, 0x0000 },

-  { 0x8700, 0x1526, 0x2000 },

-  { 0x0700, 0x1525, 0x0000 },

-  { 0x0700, 0x1527, 0x0000 },

-  { 0x8700, 0x1530, 0x4000 },

-  { 0x8700, 0x152c, 0x3000 },

-  { 0x8700, 0x152a, 0x2000 },

-  { 0x0700, 0x1529, 0x0000 },

-  { 0x0700, 0x152b, 0x0000 },

-  { 0x8700, 0x152e, 0x2000 },

-  { 0x0700, 0x152d, 0x0000 },

-  { 0x0700, 0x152f, 0x0000 },

-  { 0x8700, 0x1534, 0x3000 },

-  { 0x8700, 0x1532, 0x2000 },

-  { 0x0700, 0x1531, 0x0000 },

-  { 0x0700, 0x1533, 0x0000 },

-  { 0x8700, 0x1536, 0x2000 },

-  { 0x0700, 0x1535, 0x0000 },

-  { 0x0700, 0x1537, 0x0000 },

-  { 0x8700, 0x1548, 0x5000 },

-  { 0x8700, 0x1540, 0x4000 },

-  { 0x8700, 0x153c, 0x3000 },

-  { 0x8700, 0x153a, 0x2000 },

-  { 0x0700, 0x1539, 0x0000 },

-  { 0x0700, 0x153b, 0x0000 },

-  { 0x8700, 0x153e, 0x2000 },

-  { 0x0700, 0x153d, 0x0000 },

-  { 0x0700, 0x153f, 0x0000 },

-  { 0x8700, 0x1544, 0x3000 },

-  { 0x8700, 0x1542, 0x2000 },

-  { 0x0700, 0x1541, 0x0000 },

-  { 0x0700, 0x1543, 0x0000 },

-  { 0x8700, 0x1546, 0x2000 },

-  { 0x0700, 0x1545, 0x0000 },

-  { 0x0700, 0x1547, 0x0000 },

-  { 0x8700, 0x1550, 0x4000 },

-  { 0x8700, 0x154c, 0x3000 },

-  { 0x8700, 0x154a, 0x2000 },

-  { 0x0700, 0x1549, 0x0000 },

-  { 0x0700, 0x154b, 0x0000 },

-  { 0x8700, 0x154e, 0x2000 },

-  { 0x0700, 0x154d, 0x0000 },

-  { 0x0700, 0x154f, 0x0000 },

-  { 0x8700, 0x1554, 0x3000 },

-  { 0x8700, 0x1552, 0x2000 },

-  { 0x0700, 0x1551, 0x0000 },

-  { 0x0700, 0x1553, 0x0000 },

-  { 0x8700, 0x1556, 0x2000 },

-  { 0x0700, 0x1555, 0x0000 },

-  { 0x0700, 0x1557, 0x0000 },

-  { 0x9900, 0x22ae, 0xc000 },

-  { 0x8900, 0x1e24, 0xb001 },

-  { 0x8700, 0x17a2, 0xa000 },

-  { 0x8700, 0x1658, 0x9000 },

-  { 0x8700, 0x15d8, 0x8000 },

-  { 0x8700, 0x1598, 0x7000 },

-  { 0x8700, 0x1578, 0x6000 },

-  { 0x8700, 0x1568, 0x5000 },

-  { 0x8700, 0x1560, 0x4000 },

-  { 0x8700, 0x155c, 0x3000 },

-  { 0x8700, 0x155a, 0x2000 },

-  { 0x0700, 0x1559, 0x0000 },

-  { 0x0700, 0x155b, 0x0000 },

-  { 0x8700, 0x155e, 0x2000 },

-  { 0x0700, 0x155d, 0x0000 },

-  { 0x0700, 0x155f, 0x0000 },

-  { 0x8700, 0x1564, 0x3000 },

-  { 0x8700, 0x1562, 0x2000 },

-  { 0x0700, 0x1561, 0x0000 },

-  { 0x0700, 0x1563, 0x0000 },

-  { 0x8700, 0x1566, 0x2000 },

-  { 0x0700, 0x1565, 0x0000 },

-  { 0x0700, 0x1567, 0x0000 },

-  { 0x8700, 0x1570, 0x4000 },

-  { 0x8700, 0x156c, 0x3000 },

-  { 0x8700, 0x156a, 0x2000 },

-  { 0x0700, 0x1569, 0x0000 },

-  { 0x0700, 0x156b, 0x0000 },

-  { 0x8700, 0x156e, 0x2000 },

-  { 0x0700, 0x156d, 0x0000 },

-  { 0x0700, 0x156f, 0x0000 },

-  { 0x8700, 0x1574, 0x3000 },

-  { 0x8700, 0x1572, 0x2000 },

-  { 0x0700, 0x1571, 0x0000 },

-  { 0x0700, 0x1573, 0x0000 },

-  { 0x8700, 0x1576, 0x2000 },

-  { 0x0700, 0x1575, 0x0000 },

-  { 0x0700, 0x1577, 0x0000 },

-  { 0x8700, 0x1588, 0x5000 },

-  { 0x8700, 0x1580, 0x4000 },

-  { 0x8700, 0x157c, 0x3000 },

-  { 0x8700, 0x157a, 0x2000 },

-  { 0x0700, 0x1579, 0x0000 },

-  { 0x0700, 0x157b, 0x0000 },

-  { 0x8700, 0x157e, 0x2000 },

-  { 0x0700, 0x157d, 0x0000 },

-  { 0x0700, 0x157f, 0x0000 },

-  { 0x8700, 0x1584, 0x3000 },

-  { 0x8700, 0x1582, 0x2000 },

-  { 0x0700, 0x1581, 0x0000 },

-  { 0x0700, 0x1583, 0x0000 },

-  { 0x8700, 0x1586, 0x2000 },

-  { 0x0700, 0x1585, 0x0000 },

-  { 0x0700, 0x1587, 0x0000 },

-  { 0x8700, 0x1590, 0x4000 },

-  { 0x8700, 0x158c, 0x3000 },

-  { 0x8700, 0x158a, 0x2000 },

-  { 0x0700, 0x1589, 0x0000 },

-  { 0x0700, 0x158b, 0x0000 },

-  { 0x8700, 0x158e, 0x2000 },

-  { 0x0700, 0x158d, 0x0000 },

-  { 0x0700, 0x158f, 0x0000 },

-  { 0x8700, 0x1594, 0x3000 },

-  { 0x8700, 0x1592, 0x2000 },

-  { 0x0700, 0x1591, 0x0000 },

-  { 0x0700, 0x1593, 0x0000 },

-  { 0x8700, 0x1596, 0x2000 },

-  { 0x0700, 0x1595, 0x0000 },

-  { 0x0700, 0x1597, 0x0000 },

-  { 0x8700, 0x15b8, 0x6000 },

-  { 0x8700, 0x15a8, 0x5000 },

-  { 0x8700, 0x15a0, 0x4000 },

-  { 0x8700, 0x159c, 0x3000 },

-  { 0x8700, 0x159a, 0x2000 },

-  { 0x0700, 0x1599, 0x0000 },

-  { 0x0700, 0x159b, 0x0000 },

-  { 0x8700, 0x159e, 0x2000 },

-  { 0x0700, 0x159d, 0x0000 },

-  { 0x0700, 0x159f, 0x0000 },

-  { 0x8700, 0x15a4, 0x3000 },

-  { 0x8700, 0x15a2, 0x2000 },

-  { 0x0700, 0x15a1, 0x0000 },

-  { 0x0700, 0x15a3, 0x0000 },

-  { 0x8700, 0x15a6, 0x2000 },

-  { 0x0700, 0x15a5, 0x0000 },

-  { 0x0700, 0x15a7, 0x0000 },

-  { 0x8700, 0x15b0, 0x4000 },

-  { 0x8700, 0x15ac, 0x3000 },

-  { 0x8700, 0x15aa, 0x2000 },

-  { 0x0700, 0x15a9, 0x0000 },

-  { 0x0700, 0x15ab, 0x0000 },

-  { 0x8700, 0x15ae, 0x2000 },

-  { 0x0700, 0x15ad, 0x0000 },

-  { 0x0700, 0x15af, 0x0000 },

-  { 0x8700, 0x15b4, 0x3000 },

-  { 0x8700, 0x15b2, 0x2000 },

-  { 0x0700, 0x15b1, 0x0000 },

-  { 0x0700, 0x15b3, 0x0000 },

-  { 0x8700, 0x15b6, 0x2000 },

-  { 0x0700, 0x15b5, 0x0000 },

-  { 0x0700, 0x15b7, 0x0000 },

-  { 0x8700, 0x15c8, 0x5000 },

-  { 0x8700, 0x15c0, 0x4000 },

-  { 0x8700, 0x15bc, 0x3000 },

-  { 0x8700, 0x15ba, 0x2000 },

-  { 0x0700, 0x15b9, 0x0000 },

-  { 0x0700, 0x15bb, 0x0000 },

-  { 0x8700, 0x15be, 0x2000 },

-  { 0x0700, 0x15bd, 0x0000 },

-  { 0x0700, 0x15bf, 0x0000 },

-  { 0x8700, 0x15c4, 0x3000 },

-  { 0x8700, 0x15c2, 0x2000 },

-  { 0x0700, 0x15c1, 0x0000 },

-  { 0x0700, 0x15c3, 0x0000 },

-  { 0x8700, 0x15c6, 0x2000 },

-  { 0x0700, 0x15c5, 0x0000 },

-  { 0x0700, 0x15c7, 0x0000 },

-  { 0x8700, 0x15d0, 0x4000 },

-  { 0x8700, 0x15cc, 0x3000 },

-  { 0x8700, 0x15ca, 0x2000 },

-  { 0x0700, 0x15c9, 0x0000 },

-  { 0x0700, 0x15cb, 0x0000 },

-  { 0x8700, 0x15ce, 0x2000 },

-  { 0x0700, 0x15cd, 0x0000 },

-  { 0x0700, 0x15cf, 0x0000 },

-  { 0x8700, 0x15d4, 0x3000 },

-  { 0x8700, 0x15d2, 0x2000 },

-  { 0x0700, 0x15d1, 0x0000 },

-  { 0x0700, 0x15d3, 0x0000 },

-  { 0x8700, 0x15d6, 0x2000 },

-  { 0x0700, 0x15d5, 0x0000 },

-  { 0x0700, 0x15d7, 0x0000 },

-  { 0x8700, 0x1618, 0x7000 },

-  { 0x8700, 0x15f8, 0x6000 },

-  { 0x8700, 0x15e8, 0x5000 },

-  { 0x8700, 0x15e0, 0x4000 },

-  { 0x8700, 0x15dc, 0x3000 },

-  { 0x8700, 0x15da, 0x2000 },

-  { 0x0700, 0x15d9, 0x0000 },

-  { 0x0700, 0x15db, 0x0000 },

-  { 0x8700, 0x15de, 0x2000 },

-  { 0x0700, 0x15dd, 0x0000 },

-  { 0x0700, 0x15df, 0x0000 },

-  { 0x8700, 0x15e4, 0x3000 },

-  { 0x8700, 0x15e2, 0x2000 },

-  { 0x0700, 0x15e1, 0x0000 },

-  { 0x0700, 0x15e3, 0x0000 },

-  { 0x8700, 0x15e6, 0x2000 },

-  { 0x0700, 0x15e5, 0x0000 },

-  { 0x0700, 0x15e7, 0x0000 },

-  { 0x8700, 0x15f0, 0x4000 },

-  { 0x8700, 0x15ec, 0x3000 },

-  { 0x8700, 0x15ea, 0x2000 },

-  { 0x0700, 0x15e9, 0x0000 },

-  { 0x0700, 0x15eb, 0x0000 },

-  { 0x8700, 0x15ee, 0x2000 },

-  { 0x0700, 0x15ed, 0x0000 },

-  { 0x0700, 0x15ef, 0x0000 },

-  { 0x8700, 0x15f4, 0x3000 },

-  { 0x8700, 0x15f2, 0x2000 },

-  { 0x0700, 0x15f1, 0x0000 },

-  { 0x0700, 0x15f3, 0x0000 },

-  { 0x8700, 0x15f6, 0x2000 },

-  { 0x0700, 0x15f5, 0x0000 },

-  { 0x0700, 0x15f7, 0x0000 },

-  { 0x8700, 0x1608, 0x5000 },

-  { 0x8700, 0x1600, 0x4000 },

-  { 0x8700, 0x15fc, 0x3000 },

-  { 0x8700, 0x15fa, 0x2000 },

-  { 0x0700, 0x15f9, 0x0000 },

-  { 0x0700, 0x15fb, 0x0000 },

-  { 0x8700, 0x15fe, 0x2000 },

-  { 0x0700, 0x15fd, 0x0000 },

-  { 0x0700, 0x15ff, 0x0000 },

-  { 0x8700, 0x1604, 0x3000 },

-  { 0x8700, 0x1602, 0x2000 },

-  { 0x0700, 0x1601, 0x0000 },

-  { 0x0700, 0x1603, 0x0000 },

-  { 0x8700, 0x1606, 0x2000 },

-  { 0x0700, 0x1605, 0x0000 },

-  { 0x0700, 0x1607, 0x0000 },

-  { 0x8700, 0x1610, 0x4000 },

-  { 0x8700, 0x160c, 0x3000 },

-  { 0x8700, 0x160a, 0x2000 },

-  { 0x0700, 0x1609, 0x0000 },

-  { 0x0700, 0x160b, 0x0000 },

-  { 0x8700, 0x160e, 0x2000 },

-  { 0x0700, 0x160d, 0x0000 },

-  { 0x0700, 0x160f, 0x0000 },

-  { 0x8700, 0x1614, 0x3000 },

-  { 0x8700, 0x1612, 0x2000 },

-  { 0x0700, 0x1611, 0x0000 },

-  { 0x0700, 0x1613, 0x0000 },

-  { 0x8700, 0x1616, 0x2000 },

-  { 0x0700, 0x1615, 0x0000 },

-  { 0x0700, 0x1617, 0x0000 },

-  { 0x8700, 0x1638, 0x6000 },

-  { 0x8700, 0x1628, 0x5000 },

-  { 0x8700, 0x1620, 0x4000 },

-  { 0x8700, 0x161c, 0x3000 },

-  { 0x8700, 0x161a, 0x2000 },

-  { 0x0700, 0x1619, 0x0000 },

-  { 0x0700, 0x161b, 0x0000 },

-  { 0x8700, 0x161e, 0x2000 },

-  { 0x0700, 0x161d, 0x0000 },

-  { 0x0700, 0x161f, 0x0000 },

-  { 0x8700, 0x1624, 0x3000 },

-  { 0x8700, 0x1622, 0x2000 },

-  { 0x0700, 0x1621, 0x0000 },

-  { 0x0700, 0x1623, 0x0000 },

-  { 0x8700, 0x1626, 0x2000 },

-  { 0x0700, 0x1625, 0x0000 },

-  { 0x0700, 0x1627, 0x0000 },

-  { 0x8700, 0x1630, 0x4000 },

-  { 0x8700, 0x162c, 0x3000 },

-  { 0x8700, 0x162a, 0x2000 },

-  { 0x0700, 0x1629, 0x0000 },

-  { 0x0700, 0x162b, 0x0000 },

-  { 0x8700, 0x162e, 0x2000 },

-  { 0x0700, 0x162d, 0x0000 },

-  { 0x0700, 0x162f, 0x0000 },

-  { 0x8700, 0x1634, 0x3000 },

-  { 0x8700, 0x1632, 0x2000 },

-  { 0x0700, 0x1631, 0x0000 },

-  { 0x0700, 0x1633, 0x0000 },

-  { 0x8700, 0x1636, 0x2000 },

-  { 0x0700, 0x1635, 0x0000 },

-  { 0x0700, 0x1637, 0x0000 },

-  { 0x8700, 0x1648, 0x5000 },

-  { 0x8700, 0x1640, 0x4000 },

-  { 0x8700, 0x163c, 0x3000 },

-  { 0x8700, 0x163a, 0x2000 },

-  { 0x0700, 0x1639, 0x0000 },

-  { 0x0700, 0x163b, 0x0000 },

-  { 0x8700, 0x163e, 0x2000 },

-  { 0x0700, 0x163d, 0x0000 },

-  { 0x0700, 0x163f, 0x0000 },

-  { 0x8700, 0x1644, 0x3000 },

-  { 0x8700, 0x1642, 0x2000 },

-  { 0x0700, 0x1641, 0x0000 },

-  { 0x0700, 0x1643, 0x0000 },

-  { 0x8700, 0x1646, 0x2000 },

-  { 0x0700, 0x1645, 0x0000 },

-  { 0x0700, 0x1647, 0x0000 },

-  { 0x8700, 0x1650, 0x4000 },

-  { 0x8700, 0x164c, 0x3000 },

-  { 0x8700, 0x164a, 0x2000 },

-  { 0x0700, 0x1649, 0x0000 },

-  { 0x0700, 0x164b, 0x0000 },

-  { 0x8700, 0x164e, 0x2000 },

-  { 0x0700, 0x164d, 0x0000 },

-  { 0x0700, 0x164f, 0x0000 },

-  { 0x8700, 0x1654, 0x3000 },

-  { 0x8700, 0x1652, 0x2000 },

-  { 0x0700, 0x1651, 0x0000 },

-  { 0x0700, 0x1653, 0x0000 },

-  { 0x8700, 0x1656, 0x2000 },

-  { 0x0700, 0x1655, 0x0000 },

-  { 0x0700, 0x1657, 0x0000 },

-  { 0x8700, 0x16e4, 0x8000 },

-  { 0x8700, 0x16a4, 0x7000 },

-  { 0x8700, 0x1681, 0x6000 },

-  { 0x8700, 0x1668, 0x5000 },

-  { 0x8700, 0x1660, 0x4000 },

-  { 0x8700, 0x165c, 0x3000 },

-  { 0x8700, 0x165a, 0x2000 },

-  { 0x0700, 0x1659, 0x0000 },

-  { 0x0700, 0x165b, 0x0000 },

-  { 0x8700, 0x165e, 0x2000 },

-  { 0x0700, 0x165d, 0x0000 },

-  { 0x0700, 0x165f, 0x0000 },

-  { 0x8700, 0x1664, 0x3000 },

-  { 0x8700, 0x1662, 0x2000 },

-  { 0x0700, 0x1661, 0x0000 },

-  { 0x0700, 0x1663, 0x0000 },

-  { 0x8700, 0x1666, 0x2000 },

-  { 0x0700, 0x1665, 0x0000 },

-  { 0x0700, 0x1667, 0x0000 },

-  { 0x8700, 0x1670, 0x4000 },

-  { 0x8700, 0x166c, 0x3000 },

-  { 0x8700, 0x166a, 0x2000 },

-  { 0x0700, 0x1669, 0x0000 },

-  { 0x0700, 0x166b, 0x0000 },

-  { 0x9500, 0x166e, 0x2000 },

-  { 0x1500, 0x166d, 0x0000 },

-  { 0x0700, 0x166f, 0x0000 },

-  { 0x8700, 0x1674, 0x3000 },

-  { 0x8700, 0x1672, 0x2000 },

-  { 0x0700, 0x1671, 0x0000 },

-  { 0x0700, 0x1673, 0x0000 },

-  { 0x8700, 0x1676, 0x2000 },

-  { 0x0700, 0x1675, 0x0000 },

-  { 0x1d00, 0x1680, 0x0000 },

-  { 0x8700, 0x1691, 0x5000 },

-  { 0x8700, 0x1689, 0x4000 },

-  { 0x8700, 0x1685, 0x3000 },

-  { 0x8700, 0x1683, 0x2000 },

-  { 0x0700, 0x1682, 0x0000 },

-  { 0x0700, 0x1684, 0x0000 },

-  { 0x8700, 0x1687, 0x2000 },

-  { 0x0700, 0x1686, 0x0000 },

-  { 0x0700, 0x1688, 0x0000 },

-  { 0x8700, 0x168d, 0x3000 },

-  { 0x8700, 0x168b, 0x2000 },

-  { 0x0700, 0x168a, 0x0000 },

-  { 0x0700, 0x168c, 0x0000 },

-  { 0x8700, 0x168f, 0x2000 },

-  { 0x0700, 0x168e, 0x0000 },

-  { 0x0700, 0x1690, 0x0000 },

-  { 0x8700, 0x1699, 0x4000 },

-  { 0x8700, 0x1695, 0x3000 },

-  { 0x8700, 0x1693, 0x2000 },

-  { 0x0700, 0x1692, 0x0000 },

-  { 0x0700, 0x1694, 0x0000 },

-  { 0x8700, 0x1697, 0x2000 },

-  { 0x0700, 0x1696, 0x0000 },

-  { 0x0700, 0x1698, 0x0000 },

-  { 0x8700, 0x16a0, 0x3000 },

-  { 0x9600, 0x169b, 0x2000 },

-  { 0x0700, 0x169a, 0x0000 },

-  { 0x1200, 0x169c, 0x0000 },

-  { 0x8700, 0x16a2, 0x2000 },

-  { 0x0700, 0x16a1, 0x0000 },

-  { 0x0700, 0x16a3, 0x0000 },

-  { 0x8700, 0x16c4, 0x6000 },

-  { 0x8700, 0x16b4, 0x5000 },

-  { 0x8700, 0x16ac, 0x4000 },

-  { 0x8700, 0x16a8, 0x3000 },

-  { 0x8700, 0x16a6, 0x2000 },

-  { 0x0700, 0x16a5, 0x0000 },

-  { 0x0700, 0x16a7, 0x0000 },

-  { 0x8700, 0x16aa, 0x2000 },

-  { 0x0700, 0x16a9, 0x0000 },

-  { 0x0700, 0x16ab, 0x0000 },

-  { 0x8700, 0x16b0, 0x3000 },

-  { 0x8700, 0x16ae, 0x2000 },

-  { 0x0700, 0x16ad, 0x0000 },

-  { 0x0700, 0x16af, 0x0000 },

-  { 0x8700, 0x16b2, 0x2000 },

-  { 0x0700, 0x16b1, 0x0000 },

-  { 0x0700, 0x16b3, 0x0000 },

-  { 0x8700, 0x16bc, 0x4000 },

-  { 0x8700, 0x16b8, 0x3000 },

-  { 0x8700, 0x16b6, 0x2000 },

-  { 0x0700, 0x16b5, 0x0000 },

-  { 0x0700, 0x16b7, 0x0000 },

-  { 0x8700, 0x16ba, 0x2000 },

-  { 0x0700, 0x16b9, 0x0000 },

-  { 0x0700, 0x16bb, 0x0000 },

-  { 0x8700, 0x16c0, 0x3000 },

-  { 0x8700, 0x16be, 0x2000 },

-  { 0x0700, 0x16bd, 0x0000 },

-  { 0x0700, 0x16bf, 0x0000 },

-  { 0x8700, 0x16c2, 0x2000 },

-  { 0x0700, 0x16c1, 0x0000 },

-  { 0x0700, 0x16c3, 0x0000 },

-  { 0x8700, 0x16d4, 0x5000 },

-  { 0x8700, 0x16cc, 0x4000 },

-  { 0x8700, 0x16c8, 0x3000 },

-  { 0x8700, 0x16c6, 0x2000 },

-  { 0x0700, 0x16c5, 0x0000 },

-  { 0x0700, 0x16c7, 0x0000 },

-  { 0x8700, 0x16ca, 0x2000 },

-  { 0x0700, 0x16c9, 0x0000 },

-  { 0x0700, 0x16cb, 0x0000 },

-  { 0x8700, 0x16d0, 0x3000 },

-  { 0x8700, 0x16ce, 0x2000 },

-  { 0x0700, 0x16cd, 0x0000 },

-  { 0x0700, 0x16cf, 0x0000 },

-  { 0x8700, 0x16d2, 0x2000 },

-  { 0x0700, 0x16d1, 0x0000 },

-  { 0x0700, 0x16d3, 0x0000 },

-  { 0x8700, 0x16dc, 0x4000 },

-  { 0x8700, 0x16d8, 0x3000 },

-  { 0x8700, 0x16d6, 0x2000 },

-  { 0x0700, 0x16d5, 0x0000 },

-  { 0x0700, 0x16d7, 0x0000 },

-  { 0x8700, 0x16da, 0x2000 },

-  { 0x0700, 0x16d9, 0x0000 },

-  { 0x0700, 0x16db, 0x0000 },

-  { 0x8700, 0x16e0, 0x3000 },

-  { 0x8700, 0x16de, 0x2000 },

-  { 0x0700, 0x16dd, 0x0000 },

-  { 0x0700, 0x16df, 0x0000 },

-  { 0x8700, 0x16e2, 0x2000 },

-  { 0x0700, 0x16e1, 0x0000 },

-  { 0x0700, 0x16e3, 0x0000 },

-  { 0x8700, 0x1748, 0x7000 },

-  { 0x8c00, 0x1714, 0x6000 },

-  { 0x8700, 0x1703, 0x5000 },

-  { 0x9500, 0x16ec, 0x4000 },

-  { 0x8700, 0x16e8, 0x3000 },

-  { 0x8700, 0x16e6, 0x2000 },

-  { 0x0700, 0x16e5, 0x0000 },

-  { 0x0700, 0x16e7, 0x0000 },

-  { 0x8700, 0x16ea, 0x2000 },

-  { 0x0700, 0x16e9, 0x0000 },

-  { 0x1500, 0x16eb, 0x0000 },

-  { 0x8e00, 0x16f0, 0x3000 },

-  { 0x8e00, 0x16ee, 0x2000 },

-  { 0x1500, 0x16ed, 0x0000 },

-  { 0x0e00, 0x16ef, 0x0000 },

-  { 0x8700, 0x1701, 0x2000 },

-  { 0x0700, 0x1700, 0x0000 },

-  { 0x0700, 0x1702, 0x0000 },

-  { 0x8700, 0x170b, 0x4000 },

-  { 0x8700, 0x1707, 0x3000 },

-  { 0x8700, 0x1705, 0x2000 },

-  { 0x0700, 0x1704, 0x0000 },

-  { 0x0700, 0x1706, 0x0000 },

-  { 0x8700, 0x1709, 0x2000 },

-  { 0x0700, 0x1708, 0x0000 },

-  { 0x0700, 0x170a, 0x0000 },

-  { 0x8700, 0x1710, 0x3000 },

-  { 0x8700, 0x170e, 0x2000 },

-  { 0x0700, 0x170c, 0x0000 },

-  { 0x0700, 0x170f, 0x0000 },

-  { 0x8c00, 0x1712, 0x2000 },

-  { 0x0700, 0x1711, 0x0000 },

-  { 0x0c00, 0x1713, 0x0000 },

-  { 0x8700, 0x172f, 0x5000 },

-  { 0x8700, 0x1727, 0x4000 },

-  { 0x8700, 0x1723, 0x3000 },

-  { 0x8700, 0x1721, 0x2000 },

-  { 0x0700, 0x1720, 0x0000 },

-  { 0x0700, 0x1722, 0x0000 },

-  { 0x8700, 0x1725, 0x2000 },

-  { 0x0700, 0x1724, 0x0000 },

-  { 0x0700, 0x1726, 0x0000 },

-  { 0x8700, 0x172b, 0x3000 },

-  { 0x8700, 0x1729, 0x2000 },

-  { 0x0700, 0x1728, 0x0000 },

-  { 0x0700, 0x172a, 0x0000 },

-  { 0x8700, 0x172d, 0x2000 },

-  { 0x0700, 0x172c, 0x0000 },

-  { 0x0700, 0x172e, 0x0000 },

-  { 0x8700, 0x1740, 0x4000 },

-  { 0x8c00, 0x1733, 0x3000 },

-  { 0x8700, 0x1731, 0x2000 },

-  { 0x0700, 0x1730, 0x0000 },

-  { 0x0c00, 0x1732, 0x0000 },

-  { 0x9500, 0x1735, 0x2000 },

-  { 0x0c00, 0x1734, 0x0000 },

-  { 0x1500, 0x1736, 0x0000 },

-  { 0x8700, 0x1744, 0x3000 },

-  { 0x8700, 0x1742, 0x2000 },

-  { 0x0700, 0x1741, 0x0000 },

-  { 0x0700, 0x1743, 0x0000 },

-  { 0x8700, 0x1746, 0x2000 },

-  { 0x0700, 0x1745, 0x0000 },

-  { 0x0700, 0x1747, 0x0000 },

-  { 0x8700, 0x1782, 0x6000 },

-  { 0x8700, 0x1764, 0x5000 },

-  { 0x8700, 0x1750, 0x4000 },

-  { 0x8700, 0x174c, 0x3000 },

-  { 0x8700, 0x174a, 0x2000 },

-  { 0x0700, 0x1749, 0x0000 },

-  { 0x0700, 0x174b, 0x0000 },

-  { 0x8700, 0x174e, 0x2000 },

-  { 0x0700, 0x174d, 0x0000 },

-  { 0x0700, 0x174f, 0x0000 },

-  { 0x8700, 0x1760, 0x3000 },

-  { 0x8c00, 0x1752, 0x2000 },

-  { 0x0700, 0x1751, 0x0000 },

-  { 0x0c00, 0x1753, 0x0000 },

-  { 0x8700, 0x1762, 0x2000 },

-  { 0x0700, 0x1761, 0x0000 },

-  { 0x0700, 0x1763, 0x0000 },

-  { 0x8700, 0x176c, 0x4000 },

-  { 0x8700, 0x1768, 0x3000 },

-  { 0x8700, 0x1766, 0x2000 },

-  { 0x0700, 0x1765, 0x0000 },

-  { 0x0700, 0x1767, 0x0000 },

-  { 0x8700, 0x176a, 0x2000 },

-  { 0x0700, 0x1769, 0x0000 },

-  { 0x0700, 0x176b, 0x0000 },

-  { 0x8c00, 0x1772, 0x3000 },

-  { 0x8700, 0x176f, 0x2000 },

-  { 0x0700, 0x176e, 0x0000 },

-  { 0x0700, 0x1770, 0x0000 },

-  { 0x8700, 0x1780, 0x2000 },

-  { 0x0c00, 0x1773, 0x0000 },

-  { 0x0700, 0x1781, 0x0000 },

-  { 0x8700, 0x1792, 0x5000 },

-  { 0x8700, 0x178a, 0x4000 },

-  { 0x8700, 0x1786, 0x3000 },

-  { 0x8700, 0x1784, 0x2000 },

-  { 0x0700, 0x1783, 0x0000 },

-  { 0x0700, 0x1785, 0x0000 },

-  { 0x8700, 0x1788, 0x2000 },

-  { 0x0700, 0x1787, 0x0000 },

-  { 0x0700, 0x1789, 0x0000 },

-  { 0x8700, 0x178e, 0x3000 },

-  { 0x8700, 0x178c, 0x2000 },

-  { 0x0700, 0x178b, 0x0000 },

-  { 0x0700, 0x178d, 0x0000 },

-  { 0x8700, 0x1790, 0x2000 },

-  { 0x0700, 0x178f, 0x0000 },

-  { 0x0700, 0x1791, 0x0000 },

-  { 0x8700, 0x179a, 0x4000 },

-  { 0x8700, 0x1796, 0x3000 },

-  { 0x8700, 0x1794, 0x2000 },

-  { 0x0700, 0x1793, 0x0000 },

-  { 0x0700, 0x1795, 0x0000 },

-  { 0x8700, 0x1798, 0x2000 },

-  { 0x0700, 0x1797, 0x0000 },

-  { 0x0700, 0x1799, 0x0000 },

-  { 0x8700, 0x179e, 0x3000 },

-  { 0x8700, 0x179c, 0x2000 },

-  { 0x0700, 0x179b, 0x0000 },

-  { 0x0700, 0x179d, 0x0000 },

-  { 0x8700, 0x17a0, 0x2000 },

-  { 0x0700, 0x179f, 0x0000 },

-  { 0x0700, 0x17a1, 0x0000 },

-  { 0x8700, 0x1915, 0x9000 },

-  { 0x8700, 0x1837, 0x8000 },

-  { 0x8d00, 0x17e4, 0x7000 },

-  { 0x8a00, 0x17c2, 0x6000 },

-  { 0x8700, 0x17b2, 0x5000 },

-  { 0x8700, 0x17aa, 0x4000 },

-  { 0x8700, 0x17a6, 0x3000 },

-  { 0x8700, 0x17a4, 0x2000 },

-  { 0x0700, 0x17a3, 0x0000 },

-  { 0x0700, 0x17a5, 0x0000 },

-  { 0x8700, 0x17a8, 0x2000 },

-  { 0x0700, 0x17a7, 0x0000 },

-  { 0x0700, 0x17a9, 0x0000 },

-  { 0x8700, 0x17ae, 0x3000 },

-  { 0x8700, 0x17ac, 0x2000 },

-  { 0x0700, 0x17ab, 0x0000 },

-  { 0x0700, 0x17ad, 0x0000 },

-  { 0x8700, 0x17b0, 0x2000 },

-  { 0x0700, 0x17af, 0x0000 },

-  { 0x0700, 0x17b1, 0x0000 },

-  { 0x8c00, 0x17ba, 0x4000 },

-  { 0x8a00, 0x17b6, 0x3000 },

-  { 0x8100, 0x17b4, 0x2000 },

-  { 0x0700, 0x17b3, 0x0000 },

-  { 0x0100, 0x17b5, 0x0000 },

-  { 0x8c00, 0x17b8, 0x2000 },

-  { 0x0c00, 0x17b7, 0x0000 },

-  { 0x0c00, 0x17b9, 0x0000 },

-  { 0x8a00, 0x17be, 0x3000 },

-  { 0x8c00, 0x17bc, 0x2000 },

-  { 0x0c00, 0x17bb, 0x0000 },

-  { 0x0c00, 0x17bd, 0x0000 },

-  { 0x8a00, 0x17c0, 0x2000 },

-  { 0x0a00, 0x17bf, 0x0000 },

-  { 0x0a00, 0x17c1, 0x0000 },

-  { 0x8c00, 0x17d2, 0x5000 },

-  { 0x8c00, 0x17ca, 0x4000 },

-  { 0x8c00, 0x17c6, 0x3000 },

-  { 0x8a00, 0x17c4, 0x2000 },

-  { 0x0a00, 0x17c3, 0x0000 },

-  { 0x0a00, 0x17c5, 0x0000 },

-  { 0x8a00, 0x17c8, 0x2000 },

-  { 0x0a00, 0x17c7, 0x0000 },

-  { 0x0c00, 0x17c9, 0x0000 },

-  { 0x8c00, 0x17ce, 0x3000 },

-  { 0x8c00, 0x17cc, 0x2000 },

-  { 0x0c00, 0x17cb, 0x0000 },

-  { 0x0c00, 0x17cd, 0x0000 },

-  { 0x8c00, 0x17d0, 0x2000 },

-  { 0x0c00, 0x17cf, 0x0000 },

-  { 0x0c00, 0x17d1, 0x0000 },

-  { 0x9500, 0x17da, 0x4000 },

-  { 0x9500, 0x17d6, 0x3000 },

-  { 0x9500, 0x17d4, 0x2000 },

-  { 0x0c00, 0x17d3, 0x0000 },

-  { 0x1500, 0x17d5, 0x0000 },

-  { 0x9500, 0x17d8, 0x2000 },

-  { 0x0600, 0x17d7, 0x0000 },

-  { 0x1500, 0x17d9, 0x0000 },

-  { 0x8d00, 0x17e0, 0x3000 },

-  { 0x8700, 0x17dc, 0x2000 },

-  { 0x1700, 0x17db, 0x0000 },

-  { 0x0c00, 0x17dd, 0x0000 },

-  { 0x8d00, 0x17e2, 0x2000 },

-  { 0x0d00, 0x17e1, 0x0000 },

-  { 0x0d00, 0x17e3, 0x0000 },

-  { 0x8d00, 0x1811, 0x6000 },

-  { 0x9500, 0x1800, 0x5000 },

-  { 0x8f00, 0x17f2, 0x4000 },

-  { 0x8d00, 0x17e8, 0x3000 },

-  { 0x8d00, 0x17e6, 0x2000 },

-  { 0x0d00, 0x17e5, 0x0000 },

-  { 0x0d00, 0x17e7, 0x0000 },

-  { 0x8f00, 0x17f0, 0x2000 },

-  { 0x0d00, 0x17e9, 0x0000 },

-  { 0x0f00, 0x17f1, 0x0000 },

-  { 0x8f00, 0x17f6, 0x3000 },

-  { 0x8f00, 0x17f4, 0x2000 },

-  { 0x0f00, 0x17f3, 0x0000 },

-  { 0x0f00, 0x17f5, 0x0000 },

-  { 0x8f00, 0x17f8, 0x2000 },

-  { 0x0f00, 0x17f7, 0x0000 },

-  { 0x0f00, 0x17f9, 0x0000 },

-  { 0x9500, 0x1808, 0x4000 },

-  { 0x9500, 0x1804, 0x3000 },

-  { 0x9500, 0x1802, 0x2000 },

-  { 0x1500, 0x1801, 0x0000 },

-  { 0x1500, 0x1803, 0x0000 },

-  { 0x9100, 0x1806, 0x2000 },

-  { 0x1500, 0x1805, 0x0000 },

-  { 0x1500, 0x1807, 0x0000 },

-  { 0x8c00, 0x180c, 0x3000 },

-  { 0x9500, 0x180a, 0x2000 },

-  { 0x1500, 0x1809, 0x0000 },

-  { 0x0c00, 0x180b, 0x0000 },

-  { 0x9d00, 0x180e, 0x2000 },

-  { 0x0c00, 0x180d, 0x0000 },

-  { 0x0d00, 0x1810, 0x0000 },

-  { 0x8700, 0x1827, 0x5000 },

-  { 0x8d00, 0x1819, 0x4000 },

-  { 0x8d00, 0x1815, 0x3000 },

-  { 0x8d00, 0x1813, 0x2000 },

-  { 0x0d00, 0x1812, 0x0000 },

-  { 0x0d00, 0x1814, 0x0000 },

-  { 0x8d00, 0x1817, 0x2000 },

-  { 0x0d00, 0x1816, 0x0000 },

-  { 0x0d00, 0x1818, 0x0000 },

-  { 0x8700, 0x1823, 0x3000 },

-  { 0x8700, 0x1821, 0x2000 },

-  { 0x0700, 0x1820, 0x0000 },

-  { 0x0700, 0x1822, 0x0000 },

-  { 0x8700, 0x1825, 0x2000 },

-  { 0x0700, 0x1824, 0x0000 },

-  { 0x0700, 0x1826, 0x0000 },

-  { 0x8700, 0x182f, 0x4000 },

-  { 0x8700, 0x182b, 0x3000 },

-  { 0x8700, 0x1829, 0x2000 },

-  { 0x0700, 0x1828, 0x0000 },

-  { 0x0700, 0x182a, 0x0000 },

-  { 0x8700, 0x182d, 0x2000 },

-  { 0x0700, 0x182c, 0x0000 },

-  { 0x0700, 0x182e, 0x0000 },

-  { 0x8700, 0x1833, 0x3000 },

-  { 0x8700, 0x1831, 0x2000 },

-  { 0x0700, 0x1830, 0x0000 },

-  { 0x0700, 0x1832, 0x0000 },

-  { 0x8700, 0x1835, 0x2000 },

-  { 0x0700, 0x1834, 0x0000 },

-  { 0x0700, 0x1836, 0x0000 },

-  { 0x8700, 0x1877, 0x7000 },

-  { 0x8700, 0x1857, 0x6000 },

-  { 0x8700, 0x1847, 0x5000 },

-  { 0x8700, 0x183f, 0x4000 },

-  { 0x8700, 0x183b, 0x3000 },

-  { 0x8700, 0x1839, 0x2000 },

-  { 0x0700, 0x1838, 0x0000 },

-  { 0x0700, 0x183a, 0x0000 },

-  { 0x8700, 0x183d, 0x2000 },

-  { 0x0700, 0x183c, 0x0000 },

-  { 0x0700, 0x183e, 0x0000 },

-  { 0x8600, 0x1843, 0x3000 },

-  { 0x8700, 0x1841, 0x2000 },

-  { 0x0700, 0x1840, 0x0000 },

-  { 0x0700, 0x1842, 0x0000 },

-  { 0x8700, 0x1845, 0x2000 },

-  { 0x0700, 0x1844, 0x0000 },

-  { 0x0700, 0x1846, 0x0000 },

-  { 0x8700, 0x184f, 0x4000 },

-  { 0x8700, 0x184b, 0x3000 },

-  { 0x8700, 0x1849, 0x2000 },

-  { 0x0700, 0x1848, 0x0000 },

-  { 0x0700, 0x184a, 0x0000 },

-  { 0x8700, 0x184d, 0x2000 },

-  { 0x0700, 0x184c, 0x0000 },

-  { 0x0700, 0x184e, 0x0000 },

-  { 0x8700, 0x1853, 0x3000 },

-  { 0x8700, 0x1851, 0x2000 },

-  { 0x0700, 0x1850, 0x0000 },

-  { 0x0700, 0x1852, 0x0000 },

-  { 0x8700, 0x1855, 0x2000 },

-  { 0x0700, 0x1854, 0x0000 },

-  { 0x0700, 0x1856, 0x0000 },

-  { 0x8700, 0x1867, 0x5000 },

-  { 0x8700, 0x185f, 0x4000 },

-  { 0x8700, 0x185b, 0x3000 },

-  { 0x8700, 0x1859, 0x2000 },

-  { 0x0700, 0x1858, 0x0000 },

-  { 0x0700, 0x185a, 0x0000 },

-  { 0x8700, 0x185d, 0x2000 },

-  { 0x0700, 0x185c, 0x0000 },

-  { 0x0700, 0x185e, 0x0000 },

-  { 0x8700, 0x1863, 0x3000 },

-  { 0x8700, 0x1861, 0x2000 },

-  { 0x0700, 0x1860, 0x0000 },

-  { 0x0700, 0x1862, 0x0000 },

-  { 0x8700, 0x1865, 0x2000 },

-  { 0x0700, 0x1864, 0x0000 },

-  { 0x0700, 0x1866, 0x0000 },

-  { 0x8700, 0x186f, 0x4000 },

-  { 0x8700, 0x186b, 0x3000 },

-  { 0x8700, 0x1869, 0x2000 },

-  { 0x0700, 0x1868, 0x0000 },

-  { 0x0700, 0x186a, 0x0000 },

-  { 0x8700, 0x186d, 0x2000 },

-  { 0x0700, 0x186c, 0x0000 },

-  { 0x0700, 0x186e, 0x0000 },

-  { 0x8700, 0x1873, 0x3000 },

-  { 0x8700, 0x1871, 0x2000 },

-  { 0x0700, 0x1870, 0x0000 },

-  { 0x0700, 0x1872, 0x0000 },

-  { 0x8700, 0x1875, 0x2000 },

-  { 0x0700, 0x1874, 0x0000 },

-  { 0x0700, 0x1876, 0x0000 },

-  { 0x8700, 0x189f, 0x6000 },

-  { 0x8700, 0x188f, 0x5000 },

-  { 0x8700, 0x1887, 0x4000 },

-  { 0x8700, 0x1883, 0x3000 },

-  { 0x8700, 0x1881, 0x2000 },

-  { 0x0700, 0x1880, 0x0000 },

-  { 0x0700, 0x1882, 0x0000 },

-  { 0x8700, 0x1885, 0x2000 },

-  { 0x0700, 0x1884, 0x0000 },

-  { 0x0700, 0x1886, 0x0000 },

-  { 0x8700, 0x188b, 0x3000 },

-  { 0x8700, 0x1889, 0x2000 },

-  { 0x0700, 0x1888, 0x0000 },

-  { 0x0700, 0x188a, 0x0000 },

-  { 0x8700, 0x188d, 0x2000 },

-  { 0x0700, 0x188c, 0x0000 },

-  { 0x0700, 0x188e, 0x0000 },

-  { 0x8700, 0x1897, 0x4000 },

-  { 0x8700, 0x1893, 0x3000 },

-  { 0x8700, 0x1891, 0x2000 },

-  { 0x0700, 0x1890, 0x0000 },

-  { 0x0700, 0x1892, 0x0000 },

-  { 0x8700, 0x1895, 0x2000 },

-  { 0x0700, 0x1894, 0x0000 },

-  { 0x0700, 0x1896, 0x0000 },

-  { 0x8700, 0x189b, 0x3000 },

-  { 0x8700, 0x1899, 0x2000 },

-  { 0x0700, 0x1898, 0x0000 },

-  { 0x0700, 0x189a, 0x0000 },

-  { 0x8700, 0x189d, 0x2000 },

-  { 0x0700, 0x189c, 0x0000 },

-  { 0x0700, 0x189e, 0x0000 },

-  { 0x8700, 0x1905, 0x5000 },

-  { 0x8700, 0x18a7, 0x4000 },

-  { 0x8700, 0x18a3, 0x3000 },

-  { 0x8700, 0x18a1, 0x2000 },

-  { 0x0700, 0x18a0, 0x0000 },

-  { 0x0700, 0x18a2, 0x0000 },

-  { 0x8700, 0x18a5, 0x2000 },

-  { 0x0700, 0x18a4, 0x0000 },

-  { 0x0700, 0x18a6, 0x0000 },

-  { 0x8700, 0x1901, 0x3000 },

-  { 0x8c00, 0x18a9, 0x2000 },

-  { 0x0700, 0x18a8, 0x0000 },

-  { 0x0700, 0x1900, 0x0000 },

-  { 0x8700, 0x1903, 0x2000 },

-  { 0x0700, 0x1902, 0x0000 },

-  { 0x0700, 0x1904, 0x0000 },

-  { 0x8700, 0x190d, 0x4000 },

-  { 0x8700, 0x1909, 0x3000 },

-  { 0x8700, 0x1907, 0x2000 },

-  { 0x0700, 0x1906, 0x0000 },

-  { 0x0700, 0x1908, 0x0000 },

-  { 0x8700, 0x190b, 0x2000 },

-  { 0x0700, 0x190a, 0x0000 },

-  { 0x0700, 0x190c, 0x0000 },

-  { 0x8700, 0x1911, 0x3000 },

-  { 0x8700, 0x190f, 0x2000 },

-  { 0x0700, 0x190e, 0x0000 },

-  { 0x0700, 0x1910, 0x0000 },

-  { 0x8700, 0x1913, 0x2000 },

-  { 0x0700, 0x1912, 0x0000 },

-  { 0x0700, 0x1914, 0x0000 },

-  { 0x8500, 0x1d10, 0x8000 },

-  { 0x8700, 0x1963, 0x7000 },

-  { 0x9a00, 0x1940, 0x6000 },

-  { 0x8c00, 0x1928, 0x5000 },

-  { 0x8c00, 0x1920, 0x4000 },

-  { 0x8700, 0x1919, 0x3000 },

-  { 0x8700, 0x1917, 0x2000 },

-  { 0x0700, 0x1916, 0x0000 },

-  { 0x0700, 0x1918, 0x0000 },

-  { 0x8700, 0x191b, 0x2000 },

-  { 0x0700, 0x191a, 0x0000 },

-  { 0x0700, 0x191c, 0x0000 },

-  { 0x8a00, 0x1924, 0x3000 },

-  { 0x8c00, 0x1922, 0x2000 },

-  { 0x0c00, 0x1921, 0x0000 },

-  { 0x0a00, 0x1923, 0x0000 },

-  { 0x8a00, 0x1926, 0x2000 },

-  { 0x0a00, 0x1925, 0x0000 },

-  { 0x0c00, 0x1927, 0x0000 },

-  { 0x8a00, 0x1934, 0x4000 },

-  { 0x8a00, 0x1930, 0x3000 },

-  { 0x8a00, 0x192a, 0x2000 },

-  { 0x0a00, 0x1929, 0x0000 },

-  { 0x0a00, 0x192b, 0x0000 },

-  { 0x8c00, 0x1932, 0x2000 },

-  { 0x0a00, 0x1931, 0x0000 },

-  { 0x0a00, 0x1933, 0x0000 },

-  { 0x8a00, 0x1938, 0x3000 },

-  { 0x8a00, 0x1936, 0x2000 },

-  { 0x0a00, 0x1935, 0x0000 },

-  { 0x0a00, 0x1937, 0x0000 },

-  { 0x8c00, 0x193a, 0x2000 },

-  { 0x0c00, 0x1939, 0x0000 },

-  { 0x0c00, 0x193b, 0x0000 },

-  { 0x8700, 0x1953, 0x5000 },

-  { 0x8d00, 0x194b, 0x4000 },

-  { 0x8d00, 0x1947, 0x3000 },

-  { 0x9500, 0x1945, 0x2000 },

-  { 0x1500, 0x1944, 0x0000 },

-  { 0x0d00, 0x1946, 0x0000 },

-  { 0x8d00, 0x1949, 0x2000 },

-  { 0x0d00, 0x1948, 0x0000 },

-  { 0x0d00, 0x194a, 0x0000 },

-  { 0x8d00, 0x194f, 0x3000 },

-  { 0x8d00, 0x194d, 0x2000 },

-  { 0x0d00, 0x194c, 0x0000 },

-  { 0x0d00, 0x194e, 0x0000 },

-  { 0x8700, 0x1951, 0x2000 },

-  { 0x0700, 0x1950, 0x0000 },

-  { 0x0700, 0x1952, 0x0000 },

-  { 0x8700, 0x195b, 0x4000 },

-  { 0x8700, 0x1957, 0x3000 },

-  { 0x8700, 0x1955, 0x2000 },

-  { 0x0700, 0x1954, 0x0000 },

-  { 0x0700, 0x1956, 0x0000 },

-  { 0x8700, 0x1959, 0x2000 },

-  { 0x0700, 0x1958, 0x0000 },

-  { 0x0700, 0x195a, 0x0000 },

-  { 0x8700, 0x195f, 0x3000 },

-  { 0x8700, 0x195d, 0x2000 },

-  { 0x0700, 0x195c, 0x0000 },

-  { 0x0700, 0x195e, 0x0000 },

-  { 0x8700, 0x1961, 0x2000 },

-  { 0x0700, 0x1960, 0x0000 },

-  { 0x0700, 0x1962, 0x0000 },

-  { 0x9a00, 0x19f0, 0x6000 },

-  { 0x9a00, 0x19e0, 0x5000 },

-  { 0x8700, 0x196b, 0x4000 },

-  { 0x8700, 0x1967, 0x3000 },

-  { 0x8700, 0x1965, 0x2000 },

-  { 0x0700, 0x1964, 0x0000 },

-  { 0x0700, 0x1966, 0x0000 },

-  { 0x8700, 0x1969, 0x2000 },

-  { 0x0700, 0x1968, 0x0000 },

-  { 0x0700, 0x196a, 0x0000 },

-  { 0x8700, 0x1971, 0x3000 },

-  { 0x8700, 0x196d, 0x2000 },

-  { 0x0700, 0x196c, 0x0000 },

-  { 0x0700, 0x1970, 0x0000 },

-  { 0x8700, 0x1973, 0x2000 },

-  { 0x0700, 0x1972, 0x0000 },

-  { 0x0700, 0x1974, 0x0000 },

-  { 0x9a00, 0x19e8, 0x4000 },

-  { 0x9a00, 0x19e4, 0x3000 },

-  { 0x9a00, 0x19e2, 0x2000 },

-  { 0x1a00, 0x19e1, 0x0000 },

-  { 0x1a00, 0x19e3, 0x0000 },

-  { 0x9a00, 0x19e6, 0x2000 },

-  { 0x1a00, 0x19e5, 0x0000 },

-  { 0x1a00, 0x19e7, 0x0000 },

-  { 0x9a00, 0x19ec, 0x3000 },

-  { 0x9a00, 0x19ea, 0x2000 },

-  { 0x1a00, 0x19e9, 0x0000 },

-  { 0x1a00, 0x19eb, 0x0000 },

-  { 0x9a00, 0x19ee, 0x2000 },

-  { 0x1a00, 0x19ed, 0x0000 },

-  { 0x1a00, 0x19ef, 0x0000 },

-  { 0x8500, 0x1d00, 0x5000 },

-  { 0x9a00, 0x19f8, 0x4000 },

-  { 0x9a00, 0x19f4, 0x3000 },

-  { 0x9a00, 0x19f2, 0x2000 },

-  { 0x1a00, 0x19f1, 0x0000 },

-  { 0x1a00, 0x19f3, 0x0000 },

-  { 0x9a00, 0x19f6, 0x2000 },

-  { 0x1a00, 0x19f5, 0x0000 },

-  { 0x1a00, 0x19f7, 0x0000 },

-  { 0x9a00, 0x19fc, 0x3000 },

-  { 0x9a00, 0x19fa, 0x2000 },

-  { 0x1a00, 0x19f9, 0x0000 },

-  { 0x1a00, 0x19fb, 0x0000 },

-  { 0x9a00, 0x19fe, 0x2000 },

-  { 0x1a00, 0x19fd, 0x0000 },

-  { 0x1a00, 0x19ff, 0x0000 },

-  { 0x8500, 0x1d08, 0x4000 },

-  { 0x8500, 0x1d04, 0x3000 },

-  { 0x8500, 0x1d02, 0x2000 },

-  { 0x0500, 0x1d01, 0x0000 },

-  { 0x0500, 0x1d03, 0x0000 },

-  { 0x8500, 0x1d06, 0x2000 },

-  { 0x0500, 0x1d05, 0x0000 },

-  { 0x0500, 0x1d07, 0x0000 },

-  { 0x8500, 0x1d0c, 0x3000 },

-  { 0x8500, 0x1d0a, 0x2000 },

-  { 0x0500, 0x1d09, 0x0000 },

-  { 0x0500, 0x1d0b, 0x0000 },

-  { 0x8500, 0x1d0e, 0x2000 },

-  { 0x0500, 0x1d0d, 0x0000 },

-  { 0x0500, 0x1d0f, 0x0000 },

-  { 0x8600, 0x1d50, 0x7000 },

-  { 0x8600, 0x1d30, 0x6000 },

-  { 0x8500, 0x1d20, 0x5000 },

-  { 0x8500, 0x1d18, 0x4000 },

-  { 0x8500, 0x1d14, 0x3000 },

-  { 0x8500, 0x1d12, 0x2000 },

-  { 0x0500, 0x1d11, 0x0000 },

-  { 0x0500, 0x1d13, 0x0000 },

-  { 0x8500, 0x1d16, 0x2000 },

-  { 0x0500, 0x1d15, 0x0000 },

-  { 0x0500, 0x1d17, 0x0000 },

-  { 0x8500, 0x1d1c, 0x3000 },

-  { 0x8500, 0x1d1a, 0x2000 },

-  { 0x0500, 0x1d19, 0x0000 },

-  { 0x0500, 0x1d1b, 0x0000 },

-  { 0x8500, 0x1d1e, 0x2000 },

-  { 0x0500, 0x1d1d, 0x0000 },

-  { 0x0500, 0x1d1f, 0x0000 },

-  { 0x8500, 0x1d28, 0x4000 },

-  { 0x8500, 0x1d24, 0x3000 },

-  { 0x8500, 0x1d22, 0x2000 },

-  { 0x0500, 0x1d21, 0x0000 },

-  { 0x0500, 0x1d23, 0x0000 },

-  { 0x8500, 0x1d26, 0x2000 },

-  { 0x0500, 0x1d25, 0x0000 },

-  { 0x0500, 0x1d27, 0x0000 },

-  { 0x8600, 0x1d2c, 0x3000 },

-  { 0x8500, 0x1d2a, 0x2000 },

-  { 0x0500, 0x1d29, 0x0000 },

-  { 0x0500, 0x1d2b, 0x0000 },

-  { 0x8600, 0x1d2e, 0x2000 },

-  { 0x0600, 0x1d2d, 0x0000 },

-  { 0x0600, 0x1d2f, 0x0000 },

-  { 0x8600, 0x1d40, 0x5000 },

-  { 0x8600, 0x1d38, 0x4000 },

-  { 0x8600, 0x1d34, 0x3000 },

-  { 0x8600, 0x1d32, 0x2000 },

-  { 0x0600, 0x1d31, 0x0000 },

-  { 0x0600, 0x1d33, 0x0000 },

-  { 0x8600, 0x1d36, 0x2000 },

-  { 0x0600, 0x1d35, 0x0000 },

-  { 0x0600, 0x1d37, 0x0000 },

-  { 0x8600, 0x1d3c, 0x3000 },

-  { 0x8600, 0x1d3a, 0x2000 },

-  { 0x0600, 0x1d39, 0x0000 },

-  { 0x0600, 0x1d3b, 0x0000 },

-  { 0x8600, 0x1d3e, 0x2000 },

-  { 0x0600, 0x1d3d, 0x0000 },

-  { 0x0600, 0x1d3f, 0x0000 },

-  { 0x8600, 0x1d48, 0x4000 },

-  { 0x8600, 0x1d44, 0x3000 },

-  { 0x8600, 0x1d42, 0x2000 },

-  { 0x0600, 0x1d41, 0x0000 },

-  { 0x0600, 0x1d43, 0x0000 },

-  { 0x8600, 0x1d46, 0x2000 },

-  { 0x0600, 0x1d45, 0x0000 },

-  { 0x0600, 0x1d47, 0x0000 },

-  { 0x8600, 0x1d4c, 0x3000 },

-  { 0x8600, 0x1d4a, 0x2000 },

-  { 0x0600, 0x1d49, 0x0000 },

-  { 0x0600, 0x1d4b, 0x0000 },

-  { 0x8600, 0x1d4e, 0x2000 },

-  { 0x0600, 0x1d4d, 0x0000 },

-  { 0x0600, 0x1d4f, 0x0000 },

-  { 0x8900, 0x1e04, 0x6001 },

-  { 0x8600, 0x1d60, 0x5000 },

-  { 0x8600, 0x1d58, 0x4000 },

-  { 0x8600, 0x1d54, 0x3000 },

-  { 0x8600, 0x1d52, 0x2000 },

-  { 0x0600, 0x1d51, 0x0000 },

-  { 0x0600, 0x1d53, 0x0000 },

-  { 0x8600, 0x1d56, 0x2000 },

-  { 0x0600, 0x1d55, 0x0000 },

-  { 0x0600, 0x1d57, 0x0000 },

-  { 0x8600, 0x1d5c, 0x3000 },

-  { 0x8600, 0x1d5a, 0x2000 },

-  { 0x0600, 0x1d59, 0x0000 },

-  { 0x0600, 0x1d5b, 0x0000 },

-  { 0x8600, 0x1d5e, 0x2000 },

-  { 0x0600, 0x1d5d, 0x0000 },

-  { 0x0600, 0x1d5f, 0x0000 },

-  { 0x8500, 0x1d68, 0x4000 },

-  { 0x8500, 0x1d64, 0x3000 },

-  { 0x8500, 0x1d62, 0x2000 },

-  { 0x0600, 0x1d61, 0x0000 },

-  { 0x0500, 0x1d63, 0x0000 },

-  { 0x8500, 0x1d66, 0x2000 },

-  { 0x0500, 0x1d65, 0x0000 },

-  { 0x0500, 0x1d67, 0x0000 },

-  { 0x8900, 0x1e00, 0x3001 },

-  { 0x8500, 0x1d6a, 0x2000 },

-  { 0x0500, 0x1d69, 0x0000 },

-  { 0x0500, 0x1d6b, 0x0000 },

-  { 0x8900, 0x1e02, 0x2001 },

-  { 0x0500, 0x1e01, 0x0fff },

-  { 0x0500, 0x1e03, 0x0fff },

-  { 0x8900, 0x1e14, 0x5001 },

-  { 0x8900, 0x1e0c, 0x4001 },

-  { 0x8900, 0x1e08, 0x3001 },

-  { 0x8900, 0x1e06, 0x2001 },

-  { 0x0500, 0x1e05, 0x0fff },

-  { 0x0500, 0x1e07, 0x0fff },

-  { 0x8900, 0x1e0a, 0x2001 },

-  { 0x0500, 0x1e09, 0x0fff },

-  { 0x0500, 0x1e0b, 0x0fff },

-  { 0x8900, 0x1e10, 0x3001 },

-  { 0x8900, 0x1e0e, 0x2001 },

-  { 0x0500, 0x1e0d, 0x0fff },

-  { 0x0500, 0x1e0f, 0x0fff },

-  { 0x8900, 0x1e12, 0x2001 },

-  { 0x0500, 0x1e11, 0x0fff },

-  { 0x0500, 0x1e13, 0x0fff },

-  { 0x8900, 0x1e1c, 0x4001 },

-  { 0x8900, 0x1e18, 0x3001 },

-  { 0x8900, 0x1e16, 0x2001 },

-  { 0x0500, 0x1e15, 0x0fff },

-  { 0x0500, 0x1e17, 0x0fff },

-  { 0x8900, 0x1e1a, 0x2001 },

-  { 0x0500, 0x1e19, 0x0fff },

-  { 0x0500, 0x1e1b, 0x0fff },

-  { 0x8900, 0x1e20, 0x3001 },

-  { 0x8900, 0x1e1e, 0x2001 },

-  { 0x0500, 0x1e1d, 0x0fff },

-  { 0x0500, 0x1e1f, 0x0fff },

-  { 0x8900, 0x1e22, 0x2001 },

-  { 0x0500, 0x1e21, 0x0fff },

-  { 0x0500, 0x1e23, 0x0fff },

-  { 0x9600, 0x2045, 0xa000 },

-  { 0x8500, 0x1f32, 0x9008 },

-  { 0x8900, 0x1ea8, 0x8001 },

-  { 0x8900, 0x1e64, 0x7001 },

-  { 0x8900, 0x1e44, 0x6001 },

-  { 0x8900, 0x1e34, 0x5001 },

-  { 0x8900, 0x1e2c, 0x4001 },

-  { 0x8900, 0x1e28, 0x3001 },

-  { 0x8900, 0x1e26, 0x2001 },

-  { 0x0500, 0x1e25, 0x0fff },

-  { 0x0500, 0x1e27, 0x0fff },

-  { 0x8900, 0x1e2a, 0x2001 },

-  { 0x0500, 0x1e29, 0x0fff },

-  { 0x0500, 0x1e2b, 0x0fff },

-  { 0x8900, 0x1e30, 0x3001 },

-  { 0x8900, 0x1e2e, 0x2001 },

-  { 0x0500, 0x1e2d, 0x0fff },

-  { 0x0500, 0x1e2f, 0x0fff },

-  { 0x8900, 0x1e32, 0x2001 },

-  { 0x0500, 0x1e31, 0x0fff },

-  { 0x0500, 0x1e33, 0x0fff },

-  { 0x8900, 0x1e3c, 0x4001 },

-  { 0x8900, 0x1e38, 0x3001 },

-  { 0x8900, 0x1e36, 0x2001 },

-  { 0x0500, 0x1e35, 0x0fff },

-  { 0x0500, 0x1e37, 0x0fff },

-  { 0x8900, 0x1e3a, 0x2001 },

-  { 0x0500, 0x1e39, 0x0fff },

-  { 0x0500, 0x1e3b, 0x0fff },

-  { 0x8900, 0x1e40, 0x3001 },

-  { 0x8900, 0x1e3e, 0x2001 },

-  { 0x0500, 0x1e3d, 0x0fff },

-  { 0x0500, 0x1e3f, 0x0fff },

-  { 0x8900, 0x1e42, 0x2001 },

-  { 0x0500, 0x1e41, 0x0fff },

-  { 0x0500, 0x1e43, 0x0fff },

-  { 0x8900, 0x1e54, 0x5001 },

-  { 0x8900, 0x1e4c, 0x4001 },

-  { 0x8900, 0x1e48, 0x3001 },

-  { 0x8900, 0x1e46, 0x2001 },

-  { 0x0500, 0x1e45, 0x0fff },

-  { 0x0500, 0x1e47, 0x0fff },

-  { 0x8900, 0x1e4a, 0x2001 },

-  { 0x0500, 0x1e49, 0x0fff },

-  { 0x0500, 0x1e4b, 0x0fff },

-  { 0x8900, 0x1e50, 0x3001 },

-  { 0x8900, 0x1e4e, 0x2001 },

-  { 0x0500, 0x1e4d, 0x0fff },

-  { 0x0500, 0x1e4f, 0x0fff },

-  { 0x8900, 0x1e52, 0x2001 },

-  { 0x0500, 0x1e51, 0x0fff },

-  { 0x0500, 0x1e53, 0x0fff },

-  { 0x8900, 0x1e5c, 0x4001 },

-  { 0x8900, 0x1e58, 0x3001 },

-  { 0x8900, 0x1e56, 0x2001 },

-  { 0x0500, 0x1e55, 0x0fff },

-  { 0x0500, 0x1e57, 0x0fff },

-  { 0x8900, 0x1e5a, 0x2001 },

-  { 0x0500, 0x1e59, 0x0fff },

-  { 0x0500, 0x1e5b, 0x0fff },

-  { 0x8900, 0x1e60, 0x3001 },

-  { 0x8900, 0x1e5e, 0x2001 },

-  { 0x0500, 0x1e5d, 0x0fff },

-  { 0x0500, 0x1e5f, 0x0fff },

-  { 0x8900, 0x1e62, 0x2001 },

-  { 0x0500, 0x1e61, 0x0fff },

-  { 0x0500, 0x1e63, 0x0fff },

-  { 0x8900, 0x1e84, 0x6001 },

-  { 0x8900, 0x1e74, 0x5001 },

-  { 0x8900, 0x1e6c, 0x4001 },

-  { 0x8900, 0x1e68, 0x3001 },

-  { 0x8900, 0x1e66, 0x2001 },

-  { 0x0500, 0x1e65, 0x0fff },

-  { 0x0500, 0x1e67, 0x0fff },

-  { 0x8900, 0x1e6a, 0x2001 },

-  { 0x0500, 0x1e69, 0x0fff },

-  { 0x0500, 0x1e6b, 0x0fff },

-  { 0x8900, 0x1e70, 0x3001 },

-  { 0x8900, 0x1e6e, 0x2001 },

-  { 0x0500, 0x1e6d, 0x0fff },

-  { 0x0500, 0x1e6f, 0x0fff },

-  { 0x8900, 0x1e72, 0x2001 },

-  { 0x0500, 0x1e71, 0x0fff },

-  { 0x0500, 0x1e73, 0x0fff },

-  { 0x8900, 0x1e7c, 0x4001 },

-  { 0x8900, 0x1e78, 0x3001 },

-  { 0x8900, 0x1e76, 0x2001 },

-  { 0x0500, 0x1e75, 0x0fff },

-  { 0x0500, 0x1e77, 0x0fff },

-  { 0x8900, 0x1e7a, 0x2001 },

-  { 0x0500, 0x1e79, 0x0fff },

-  { 0x0500, 0x1e7b, 0x0fff },

-  { 0x8900, 0x1e80, 0x3001 },

-  { 0x8900, 0x1e7e, 0x2001 },

-  { 0x0500, 0x1e7d, 0x0fff },

-  { 0x0500, 0x1e7f, 0x0fff },

-  { 0x8900, 0x1e82, 0x2001 },

-  { 0x0500, 0x1e81, 0x0fff },

-  { 0x0500, 0x1e83, 0x0fff },

-  { 0x8900, 0x1e94, 0x5001 },

-  { 0x8900, 0x1e8c, 0x4001 },

-  { 0x8900, 0x1e88, 0x3001 },

-  { 0x8900, 0x1e86, 0x2001 },

-  { 0x0500, 0x1e85, 0x0fff },

-  { 0x0500, 0x1e87, 0x0fff },

-  { 0x8900, 0x1e8a, 0x2001 },

-  { 0x0500, 0x1e89, 0x0fff },

-  { 0x0500, 0x1e8b, 0x0fff },

-  { 0x8900, 0x1e90, 0x3001 },

-  { 0x8900, 0x1e8e, 0x2001 },

-  { 0x0500, 0x1e8d, 0x0fff },

-  { 0x0500, 0x1e8f, 0x0fff },

-  { 0x8900, 0x1e92, 0x2001 },

-  { 0x0500, 0x1e91, 0x0fff },

-  { 0x0500, 0x1e93, 0x0fff },

-  { 0x8900, 0x1ea0, 0x4001 },

-  { 0x8500, 0x1e98, 0x3000 },

-  { 0x8500, 0x1e96, 0x2000 },

-  { 0x0500, 0x1e95, 0x0fff },

-  { 0x0500, 0x1e97, 0x0000 },

-  { 0x8500, 0x1e9a, 0x2000 },

-  { 0x0500, 0x1e99, 0x0000 },

-  { 0x0500, 0x1e9b, 0x0fc5 },

-  { 0x8900, 0x1ea4, 0x3001 },

-  { 0x8900, 0x1ea2, 0x2001 },

-  { 0x0500, 0x1ea1, 0x0fff },

-  { 0x0500, 0x1ea3, 0x0fff },

-  { 0x8900, 0x1ea6, 0x2001 },

-  { 0x0500, 0x1ea5, 0x0fff },

-  { 0x0500, 0x1ea7, 0x0fff },

-  { 0x8900, 0x1ee8, 0x7001 },

-  { 0x8900, 0x1ec8, 0x6001 },

-  { 0x8900, 0x1eb8, 0x5001 },

-  { 0x8900, 0x1eb0, 0x4001 },

-  { 0x8900, 0x1eac, 0x3001 },

-  { 0x8900, 0x1eaa, 0x2001 },

-  { 0x0500, 0x1ea9, 0x0fff },

-  { 0x0500, 0x1eab, 0x0fff },

-  { 0x8900, 0x1eae, 0x2001 },

-  { 0x0500, 0x1ead, 0x0fff },

-  { 0x0500, 0x1eaf, 0x0fff },

-  { 0x8900, 0x1eb4, 0x3001 },

-  { 0x8900, 0x1eb2, 0x2001 },

-  { 0x0500, 0x1eb1, 0x0fff },

-  { 0x0500, 0x1eb3, 0x0fff },

-  { 0x8900, 0x1eb6, 0x2001 },

-  { 0x0500, 0x1eb5, 0x0fff },

-  { 0x0500, 0x1eb7, 0x0fff },

-  { 0x8900, 0x1ec0, 0x4001 },

-  { 0x8900, 0x1ebc, 0x3001 },

-  { 0x8900, 0x1eba, 0x2001 },

-  { 0x0500, 0x1eb9, 0x0fff },

-  { 0x0500, 0x1ebb, 0x0fff },

-  { 0x8900, 0x1ebe, 0x2001 },

-  { 0x0500, 0x1ebd, 0x0fff },

-  { 0x0500, 0x1ebf, 0x0fff },

-  { 0x8900, 0x1ec4, 0x3001 },

-  { 0x8900, 0x1ec2, 0x2001 },

-  { 0x0500, 0x1ec1, 0x0fff },

-  { 0x0500, 0x1ec3, 0x0fff },

-  { 0x8900, 0x1ec6, 0x2001 },

-  { 0x0500, 0x1ec5, 0x0fff },

-  { 0x0500, 0x1ec7, 0x0fff },

-  { 0x8900, 0x1ed8, 0x5001 },

-  { 0x8900, 0x1ed0, 0x4001 },

-  { 0x8900, 0x1ecc, 0x3001 },

-  { 0x8900, 0x1eca, 0x2001 },

-  { 0x0500, 0x1ec9, 0x0fff },

-  { 0x0500, 0x1ecb, 0x0fff },

-  { 0x8900, 0x1ece, 0x2001 },

-  { 0x0500, 0x1ecd, 0x0fff },

-  { 0x0500, 0x1ecf, 0x0fff },

-  { 0x8900, 0x1ed4, 0x3001 },

-  { 0x8900, 0x1ed2, 0x2001 },

-  { 0x0500, 0x1ed1, 0x0fff },

-  { 0x0500, 0x1ed3, 0x0fff },

-  { 0x8900, 0x1ed6, 0x2001 },

-  { 0x0500, 0x1ed5, 0x0fff },

-  { 0x0500, 0x1ed7, 0x0fff },

-  { 0x8900, 0x1ee0, 0x4001 },

-  { 0x8900, 0x1edc, 0x3001 },

-  { 0x8900, 0x1eda, 0x2001 },

-  { 0x0500, 0x1ed9, 0x0fff },

-  { 0x0500, 0x1edb, 0x0fff },

-  { 0x8900, 0x1ede, 0x2001 },

-  { 0x0500, 0x1edd, 0x0fff },

-  { 0x0500, 0x1edf, 0x0fff },

-  { 0x8900, 0x1ee4, 0x3001 },

-  { 0x8900, 0x1ee2, 0x2001 },

-  { 0x0500, 0x1ee1, 0x0fff },

-  { 0x0500, 0x1ee3, 0x0fff },

-  { 0x8900, 0x1ee6, 0x2001 },

-  { 0x0500, 0x1ee5, 0x0fff },

-  { 0x0500, 0x1ee7, 0x0fff },

-  { 0x8900, 0x1f0e, 0x6ff8 },

-  { 0x8900, 0x1ef8, 0x5001 },

-  { 0x8900, 0x1ef0, 0x4001 },

-  { 0x8900, 0x1eec, 0x3001 },

-  { 0x8900, 0x1eea, 0x2001 },

-  { 0x0500, 0x1ee9, 0x0fff },

-  { 0x0500, 0x1eeb, 0x0fff },

-  { 0x8900, 0x1eee, 0x2001 },

-  { 0x0500, 0x1eed, 0x0fff },

-  { 0x0500, 0x1eef, 0x0fff },

-  { 0x8900, 0x1ef4, 0x3001 },

-  { 0x8900, 0x1ef2, 0x2001 },

-  { 0x0500, 0x1ef1, 0x0fff },

-  { 0x0500, 0x1ef3, 0x0fff },

-  { 0x8900, 0x1ef6, 0x2001 },

-  { 0x0500, 0x1ef5, 0x0fff },

-  { 0x0500, 0x1ef7, 0x0fff },

-  { 0x8500, 0x1f06, 0x4008 },

-  { 0x8500, 0x1f02, 0x3008 },

-  { 0x8500, 0x1f00, 0x2008 },

-  { 0x0500, 0x1ef9, 0x0fff },

-  { 0x0500, 0x1f01, 0x0008 },

-  { 0x8500, 0x1f04, 0x2008 },

-  { 0x0500, 0x1f03, 0x0008 },

-  { 0x0500, 0x1f05, 0x0008 },

-  { 0x8900, 0x1f0a, 0x3ff8 },

-  { 0x8900, 0x1f08, 0x2ff8 },

-  { 0x0500, 0x1f07, 0x0008 },

-  { 0x0900, 0x1f09, 0x0ff8 },

-  { 0x8900, 0x1f0c, 0x2ff8 },

-  { 0x0900, 0x1f0b, 0x0ff8 },

-  { 0x0900, 0x1f0d, 0x0ff8 },

-  { 0x8500, 0x1f22, 0x5008 },

-  { 0x8900, 0x1f18, 0x4ff8 },

-  { 0x8500, 0x1f12, 0x3008 },

-  { 0x8500, 0x1f10, 0x2008 },

-  { 0x0900, 0x1f0f, 0x0ff8 },

-  { 0x0500, 0x1f11, 0x0008 },

-  { 0x8500, 0x1f14, 0x2008 },

-  { 0x0500, 0x1f13, 0x0008 },

-  { 0x0500, 0x1f15, 0x0008 },

-  { 0x8900, 0x1f1c, 0x3ff8 },

-  { 0x8900, 0x1f1a, 0x2ff8 },

-  { 0x0900, 0x1f19, 0x0ff8 },

-  { 0x0900, 0x1f1b, 0x0ff8 },

-  { 0x8500, 0x1f20, 0x2008 },

-  { 0x0900, 0x1f1d, 0x0ff8 },

-  { 0x0500, 0x1f21, 0x0008 },

-  { 0x8900, 0x1f2a, 0x4ff8 },

-  { 0x8500, 0x1f26, 0x3008 },

-  { 0x8500, 0x1f24, 0x2008 },

-  { 0x0500, 0x1f23, 0x0008 },

-  { 0x0500, 0x1f25, 0x0008 },

-  { 0x8900, 0x1f28, 0x2ff8 },

-  { 0x0500, 0x1f27, 0x0008 },

-  { 0x0900, 0x1f29, 0x0ff8 },

-  { 0x8900, 0x1f2e, 0x3ff8 },

-  { 0x8900, 0x1f2c, 0x2ff8 },

-  { 0x0900, 0x1f2b, 0x0ff8 },

-  { 0x0900, 0x1f2d, 0x0ff8 },

-  { 0x8500, 0x1f30, 0x2008 },

-  { 0x0900, 0x1f2f, 0x0ff8 },

-  { 0x0500, 0x1f31, 0x0008 },

-  { 0x9800, 0x1fbd, 0x8000 },

-  { 0x8500, 0x1f7a, 0x7070 },

-  { 0x8500, 0x1f56, 0x6000 },

-  { 0x8500, 0x1f42, 0x5008 },

-  { 0x8900, 0x1f3a, 0x4ff8 },

-  { 0x8500, 0x1f36, 0x3008 },

-  { 0x8500, 0x1f34, 0x2008 },

-  { 0x0500, 0x1f33, 0x0008 },

-  { 0x0500, 0x1f35, 0x0008 },

-  { 0x8900, 0x1f38, 0x2ff8 },

-  { 0x0500, 0x1f37, 0x0008 },

-  { 0x0900, 0x1f39, 0x0ff8 },

-  { 0x8900, 0x1f3e, 0x3ff8 },

-  { 0x8900, 0x1f3c, 0x2ff8 },

-  { 0x0900, 0x1f3b, 0x0ff8 },

-  { 0x0900, 0x1f3d, 0x0ff8 },

-  { 0x8500, 0x1f40, 0x2008 },

-  { 0x0900, 0x1f3f, 0x0ff8 },

-  { 0x0500, 0x1f41, 0x0008 },

-  { 0x8900, 0x1f4c, 0x4ff8 },

-  { 0x8900, 0x1f48, 0x3ff8 },

-  { 0x8500, 0x1f44, 0x2008 },

-  { 0x0500, 0x1f43, 0x0008 },

-  { 0x0500, 0x1f45, 0x0008 },

-  { 0x8900, 0x1f4a, 0x2ff8 },

-  { 0x0900, 0x1f49, 0x0ff8 },

-  { 0x0900, 0x1f4b, 0x0ff8 },

-  { 0x8500, 0x1f52, 0x3000 },

-  { 0x8500, 0x1f50, 0x2000 },

-  { 0x0900, 0x1f4d, 0x0ff8 },

-  { 0x0500, 0x1f51, 0x0008 },

-  { 0x8500, 0x1f54, 0x2000 },

-  { 0x0500, 0x1f53, 0x0008 },

-  { 0x0500, 0x1f55, 0x0008 },

-  { 0x8900, 0x1f6a, 0x5ff8 },

-  { 0x8500, 0x1f62, 0x4008 },

-  { 0x8900, 0x1f5d, 0x3ff8 },

-  { 0x8900, 0x1f59, 0x2ff8 },

-  { 0x0500, 0x1f57, 0x0008 },

-  { 0x0900, 0x1f5b, 0x0ff8 },

-  { 0x8500, 0x1f60, 0x2008 },

-  { 0x0900, 0x1f5f, 0x0ff8 },

-  { 0x0500, 0x1f61, 0x0008 },

-  { 0x8500, 0x1f66, 0x3008 },

-  { 0x8500, 0x1f64, 0x2008 },

-  { 0x0500, 0x1f63, 0x0008 },

-  { 0x0500, 0x1f65, 0x0008 },

-  { 0x8900, 0x1f68, 0x2ff8 },

-  { 0x0500, 0x1f67, 0x0008 },

-  { 0x0900, 0x1f69, 0x0ff8 },

-  { 0x8500, 0x1f72, 0x4056 },

-  { 0x8900, 0x1f6e, 0x3ff8 },

-  { 0x8900, 0x1f6c, 0x2ff8 },

-  { 0x0900, 0x1f6b, 0x0ff8 },

-  { 0x0900, 0x1f6d, 0x0ff8 },

-  { 0x8500, 0x1f70, 0x204a },

-  { 0x0900, 0x1f6f, 0x0ff8 },

-  { 0x0500, 0x1f71, 0x004a },

-  { 0x8500, 0x1f76, 0x3064 },

-  { 0x8500, 0x1f74, 0x2056 },

-  { 0x0500, 0x1f73, 0x0056 },

-  { 0x0500, 0x1f75, 0x0056 },

-  { 0x8500, 0x1f78, 0x2080 },

-  { 0x0500, 0x1f77, 0x0064 },

-  { 0x0500, 0x1f79, 0x0080 },

-  { 0x8800, 0x1f9c, 0x6000 },

-  { 0x8800, 0x1f8c, 0x5000 },

-  { 0x8500, 0x1f84, 0x4008 },

-  { 0x8500, 0x1f80, 0x3008 },

-  { 0x8500, 0x1f7c, 0x207e },

-  { 0x0500, 0x1f7b, 0x0070 },

-  { 0x0500, 0x1f7d, 0x007e },

-  { 0x8500, 0x1f82, 0x2008 },

-  { 0x0500, 0x1f81, 0x0008 },

-  { 0x0500, 0x1f83, 0x0008 },

-  { 0x8800, 0x1f88, 0x3000 },

-  { 0x8500, 0x1f86, 0x2008 },

-  { 0x0500, 0x1f85, 0x0008 },

-  { 0x0500, 0x1f87, 0x0008 },

-  { 0x8800, 0x1f8a, 0x2000 },

-  { 0x0800, 0x1f89, 0x0000 },

-  { 0x0800, 0x1f8b, 0x0000 },

-  { 0x8500, 0x1f94, 0x4008 },

-  { 0x8500, 0x1f90, 0x3008 },

-  { 0x8800, 0x1f8e, 0x2000 },

-  { 0x0800, 0x1f8d, 0x0000 },

-  { 0x0800, 0x1f8f, 0x0000 },

-  { 0x8500, 0x1f92, 0x2008 },

-  { 0x0500, 0x1f91, 0x0008 },

-  { 0x0500, 0x1f93, 0x0008 },

-  { 0x8800, 0x1f98, 0x3000 },

-  { 0x8500, 0x1f96, 0x2008 },

-  { 0x0500, 0x1f95, 0x0008 },

-  { 0x0500, 0x1f97, 0x0008 },

-  { 0x8800, 0x1f9a, 0x2000 },

-  { 0x0800, 0x1f99, 0x0000 },

-  { 0x0800, 0x1f9b, 0x0000 },

-  { 0x8800, 0x1fac, 0x5000 },

-  { 0x8500, 0x1fa4, 0x4008 },

-  { 0x8500, 0x1fa0, 0x3008 },

-  { 0x8800, 0x1f9e, 0x2000 },

-  { 0x0800, 0x1f9d, 0x0000 },

-  { 0x0800, 0x1f9f, 0x0000 },

-  { 0x8500, 0x1fa2, 0x2008 },

-  { 0x0500, 0x1fa1, 0x0008 },

-  { 0x0500, 0x1fa3, 0x0008 },

-  { 0x8800, 0x1fa8, 0x3000 },

-  { 0x8500, 0x1fa6, 0x2008 },

-  { 0x0500, 0x1fa5, 0x0008 },

-  { 0x0500, 0x1fa7, 0x0008 },

-  { 0x8800, 0x1faa, 0x2000 },

-  { 0x0800, 0x1fa9, 0x0000 },

-  { 0x0800, 0x1fab, 0x0000 },

-  { 0x8500, 0x1fb4, 0x4000 },

-  { 0x8500, 0x1fb0, 0x3008 },

-  { 0x8800, 0x1fae, 0x2000 },

-  { 0x0800, 0x1fad, 0x0000 },

-  { 0x0800, 0x1faf, 0x0000 },

-  { 0x8500, 0x1fb2, 0x2000 },

-  { 0x0500, 0x1fb1, 0x0008 },

-  { 0x0500, 0x1fb3, 0x0009 },

-  { 0x8900, 0x1fb9, 0x3ff8 },

-  { 0x8500, 0x1fb7, 0x2000 },

-  { 0x0500, 0x1fb6, 0x0000 },

-  { 0x0900, 0x1fb8, 0x0ff8 },

-  { 0x8900, 0x1fbb, 0x2fb6 },

-  { 0x0900, 0x1fba, 0x0fb6 },

-  { 0x0800, 0x1fbc, 0x0000 },

-  { 0x9d00, 0x2005, 0x7000 },

-  { 0x8500, 0x1fe1, 0x6008 },

-  { 0x9800, 0x1fce, 0x5000 },

-  { 0x8500, 0x1fc6, 0x4000 },

-  { 0x9800, 0x1fc1, 0x3000 },

-  { 0x9800, 0x1fbf, 0x2000 },

-  { 0x0500, 0x1fbe, 0x0000 },

-  { 0x1800, 0x1fc0, 0x0000 },

-  { 0x8500, 0x1fc3, 0x2009 },

-  { 0x0500, 0x1fc2, 0x0000 },

-  { 0x0500, 0x1fc4, 0x0000 },

-  { 0x8900, 0x1fca, 0x3faa },

-  { 0x8900, 0x1fc8, 0x2faa },

-  { 0x0500, 0x1fc7, 0x0000 },

-  { 0x0900, 0x1fc9, 0x0faa },

-  { 0x8800, 0x1fcc, 0x2000 },

-  { 0x0900, 0x1fcb, 0x0faa },

-  { 0x1800, 0x1fcd, 0x0000 },

-  { 0x8900, 0x1fd8, 0x4ff8 },

-  { 0x8500, 0x1fd2, 0x3000 },

-  { 0x8500, 0x1fd0, 0x2008 },

-  { 0x1800, 0x1fcf, 0x0000 },

-  { 0x0500, 0x1fd1, 0x0008 },

-  { 0x8500, 0x1fd6, 0x2000 },

-  { 0x0500, 0x1fd3, 0x0000 },

-  { 0x0500, 0x1fd7, 0x0000 },

-  { 0x9800, 0x1fdd, 0x3000 },

-  { 0x8900, 0x1fda, 0x2f9c },

-  { 0x0900, 0x1fd9, 0x0ff8 },

-  { 0x0900, 0x1fdb, 0x0f9c },

-  { 0x9800, 0x1fdf, 0x2000 },

-  { 0x1800, 0x1fde, 0x0000 },

-  { 0x0500, 0x1fe0, 0x0008 },

-  { 0x8500, 0x1ff3, 0x5009 },

-  { 0x8900, 0x1fe9, 0x4ff8 },

-  { 0x8500, 0x1fe5, 0x3007 },

-  { 0x8500, 0x1fe3, 0x2000 },

-  { 0x0500, 0x1fe2, 0x0000 },

-  { 0x0500, 0x1fe4, 0x0000 },

-  { 0x8500, 0x1fe7, 0x2000 },

-  { 0x0500, 0x1fe6, 0x0000 },

-  { 0x0900, 0x1fe8, 0x0ff8 },

-  { 0x9800, 0x1fed, 0x3000 },

-  { 0x8900, 0x1feb, 0x2f90 },

-  { 0x0900, 0x1fea, 0x0f90 },

-  { 0x0900, 0x1fec, 0x0ff9 },

-  { 0x9800, 0x1fef, 0x2000 },

-  { 0x1800, 0x1fee, 0x0000 },

-  { 0x0500, 0x1ff2, 0x0000 },

-  { 0x8800, 0x1ffc, 0x4000 },

-  { 0x8900, 0x1ff8, 0x3f80 },

-  { 0x8500, 0x1ff6, 0x2000 },

-  { 0x0500, 0x1ff4, 0x0000 },

-  { 0x0500, 0x1ff7, 0x0000 },

-  { 0x8900, 0x1ffa, 0x2f82 },

-  { 0x0900, 0x1ff9, 0x0f80 },

-  { 0x0900, 0x1ffb, 0x0f82 },

-  { 0x9d00, 0x2001, 0x3000 },

-  { 0x9800, 0x1ffe, 0x2000 },

-  { 0x1800, 0x1ffd, 0x0000 },

-  { 0x1d00, 0x2000, 0x0000 },

-  { 0x9d00, 0x2003, 0x2000 },

-  { 0x1d00, 0x2002, 0x0000 },

-  { 0x1d00, 0x2004, 0x0000 },

-  { 0x9500, 0x2025, 0x6000 },

-  { 0x9100, 0x2015, 0x5000 },

-  { 0x8100, 0x200d, 0x4000 },

-  { 0x9d00, 0x2009, 0x3000 },

-  { 0x9d00, 0x2007, 0x2000 },

-  { 0x1d00, 0x2006, 0x0000 },

-  { 0x1d00, 0x2008, 0x0000 },

-  { 0x9d00, 0x200b, 0x2000 },

-  { 0x1d00, 0x200a, 0x0000 },

-  { 0x0100, 0x200c, 0x0000 },

-  { 0x9100, 0x2011, 0x3000 },

-  { 0x8100, 0x200f, 0x2000 },

-  { 0x0100, 0x200e, 0x0000 },

-  { 0x1100, 0x2010, 0x0000 },

-  { 0x9100, 0x2013, 0x2000 },

-  { 0x1100, 0x2012, 0x0000 },

-  { 0x1100, 0x2014, 0x0000 },

-  { 0x9300, 0x201d, 0x4000 },

-  { 0x9300, 0x2019, 0x3000 },

-  { 0x9500, 0x2017, 0x2000 },

-  { 0x1500, 0x2016, 0x0000 },

-  { 0x1400, 0x2018, 0x0000 },

-  { 0x9400, 0x201b, 0x2000 },

-  { 0x1600, 0x201a, 0x0000 },

-  { 0x1400, 0x201c, 0x0000 },

-  { 0x9500, 0x2021, 0x3000 },

-  { 0x9400, 0x201f, 0x2000 },

-  { 0x1600, 0x201e, 0x0000 },

-  { 0x1500, 0x2020, 0x0000 },

-  { 0x9500, 0x2023, 0x2000 },

-  { 0x1500, 0x2022, 0x0000 },

-  { 0x1500, 0x2024, 0x0000 },

-  { 0x9500, 0x2035, 0x5000 },

-  { 0x8100, 0x202d, 0x4000 },

-  { 0x9c00, 0x2029, 0x3000 },

-  { 0x9500, 0x2027, 0x2000 },

-  { 0x1500, 0x2026, 0x0000 },

-  { 0x1b00, 0x2028, 0x0000 },

-  { 0x8100, 0x202b, 0x2000 },

-  { 0x0100, 0x202a, 0x0000 },

-  { 0x0100, 0x202c, 0x0000 },

-  { 0x9500, 0x2031, 0x3000 },

-  { 0x9d00, 0x202f, 0x2000 },

-  { 0x0100, 0x202e, 0x0000 },

-  { 0x1500, 0x2030, 0x0000 },

-  { 0x9500, 0x2033, 0x2000 },

-  { 0x1500, 0x2032, 0x0000 },

-  { 0x1500, 0x2034, 0x0000 },

-  { 0x9500, 0x203d, 0x4000 },

-  { 0x9400, 0x2039, 0x3000 },

-  { 0x9500, 0x2037, 0x2000 },

-  { 0x1500, 0x2036, 0x0000 },

-  { 0x1500, 0x2038, 0x0000 },

-  { 0x9500, 0x203b, 0x2000 },

-  { 0x1300, 0x203a, 0x0000 },

-  { 0x1500, 0x203c, 0x0000 },

-  { 0x9500, 0x2041, 0x3000 },

-  { 0x9000, 0x203f, 0x2000 },

-  { 0x1500, 0x203e, 0x0000 },

-  { 0x1000, 0x2040, 0x0000 },

-  { 0x9500, 0x2043, 0x2000 },

-  { 0x1500, 0x2042, 0x0000 },

-  { 0x1900, 0x2044, 0x0000 },

-  { 0x9900, 0x21ae, 0x9000 },

-  { 0x8900, 0x211a, 0x8000 },

-  { 0x9700, 0x20a7, 0x7000 },

-  { 0x8f00, 0x2076, 0x6000 },

-  { 0x9500, 0x2057, 0x5000 },

-  { 0x9500, 0x204d, 0x4000 },

-  { 0x9500, 0x2049, 0x3000 },

-  { 0x9500, 0x2047, 0x2000 },

-  { 0x1200, 0x2046, 0x0000 },

-  { 0x1500, 0x2048, 0x0000 },

-  { 0x9500, 0x204b, 0x2000 },

-  { 0x1500, 0x204a, 0x0000 },

-  { 0x1500, 0x204c, 0x0000 },

-  { 0x9500, 0x2051, 0x3000 },

-  { 0x9500, 0x204f, 0x2000 },

-  { 0x1500, 0x204e, 0x0000 },

-  { 0x1500, 0x2050, 0x0000 },

-  { 0x9500, 0x2053, 0x2000 },

-  { 0x1900, 0x2052, 0x0000 },

-  { 0x1000, 0x2054, 0x0000 },

-  { 0x8100, 0x206c, 0x4000 },

-  { 0x8100, 0x2062, 0x3000 },

-  { 0x8100, 0x2060, 0x2000 },

-  { 0x1d00, 0x205f, 0x0000 },

-  { 0x0100, 0x2061, 0x0000 },

-  { 0x8100, 0x206a, 0x2000 },

-  { 0x0100, 0x2063, 0x0000 },

-  { 0x0100, 0x206b, 0x0000 },

-  { 0x8f00, 0x2070, 0x3000 },

-  { 0x8100, 0x206e, 0x2000 },

-  { 0x0100, 0x206d, 0x0000 },

-  { 0x0100, 0x206f, 0x0000 },

-  { 0x8f00, 0x2074, 0x2000 },

-  { 0x0500, 0x2071, 0x0000 },

-  { 0x0f00, 0x2075, 0x0000 },

-  { 0x8f00, 0x2086, 0x5000 },

-  { 0x9200, 0x207e, 0x4000 },

-  { 0x9900, 0x207a, 0x3000 },

-  { 0x8f00, 0x2078, 0x2000 },

-  { 0x0f00, 0x2077, 0x0000 },

-  { 0x0f00, 0x2079, 0x0000 },

-  { 0x9900, 0x207c, 0x2000 },

-  { 0x1900, 0x207b, 0x0000 },

-  { 0x1600, 0x207d, 0x0000 },

-  { 0x8f00, 0x2082, 0x3000 },

-  { 0x8f00, 0x2080, 0x2000 },

-  { 0x0500, 0x207f, 0x0000 },

-  { 0x0f00, 0x2081, 0x0000 },

-  { 0x8f00, 0x2084, 0x2000 },

-  { 0x0f00, 0x2083, 0x0000 },

-  { 0x0f00, 0x2085, 0x0000 },

-  { 0x9200, 0x208e, 0x4000 },

-  { 0x9900, 0x208a, 0x3000 },

-  { 0x8f00, 0x2088, 0x2000 },

-  { 0x0f00, 0x2087, 0x0000 },

-  { 0x0f00, 0x2089, 0x0000 },

-  { 0x9900, 0x208c, 0x2000 },

-  { 0x1900, 0x208b, 0x0000 },

-  { 0x1600, 0x208d, 0x0000 },

-  { 0x9700, 0x20a3, 0x3000 },

-  { 0x9700, 0x20a1, 0x2000 },

-  { 0x1700, 0x20a0, 0x0000 },

-  { 0x1700, 0x20a2, 0x0000 },

-  { 0x9700, 0x20a5, 0x2000 },

-  { 0x1700, 0x20a4, 0x0000 },

-  { 0x1700, 0x20a6, 0x0000 },

-  { 0x8c00, 0x20e5, 0x6000 },

-  { 0x8c00, 0x20d5, 0x5000 },

-  { 0x9700, 0x20af, 0x4000 },

-  { 0x9700, 0x20ab, 0x3000 },

-  { 0x9700, 0x20a9, 0x2000 },

-  { 0x1700, 0x20a8, 0x0000 },

-  { 0x1700, 0x20aa, 0x0000 },

-  { 0x9700, 0x20ad, 0x2000 },

-  { 0x1700, 0x20ac, 0x0000 },

-  { 0x1700, 0x20ae, 0x0000 },

-  { 0x8c00, 0x20d1, 0x3000 },

-  { 0x9700, 0x20b1, 0x2000 },

-  { 0x1700, 0x20b0, 0x0000 },

-  { 0x0c00, 0x20d0, 0x0000 },

-  { 0x8c00, 0x20d3, 0x2000 },

-  { 0x0c00, 0x20d2, 0x0000 },

-  { 0x0c00, 0x20d4, 0x0000 },

-  { 0x8b00, 0x20dd, 0x4000 },

-  { 0x8c00, 0x20d9, 0x3000 },

-  { 0x8c00, 0x20d7, 0x2000 },

-  { 0x0c00, 0x20d6, 0x0000 },

-  { 0x0c00, 0x20d8, 0x0000 },

-  { 0x8c00, 0x20db, 0x2000 },

-  { 0x0c00, 0x20da, 0x0000 },

-  { 0x0c00, 0x20dc, 0x0000 },

-  { 0x8c00, 0x20e1, 0x3000 },

-  { 0x8b00, 0x20df, 0x2000 },

-  { 0x0b00, 0x20de, 0x0000 },

-  { 0x0b00, 0x20e0, 0x0000 },

-  { 0x8b00, 0x20e3, 0x2000 },

-  { 0x0b00, 0x20e2, 0x0000 },

-  { 0x0b00, 0x20e4, 0x0000 },

-  { 0x8500, 0x210a, 0x5000 },

-  { 0x8900, 0x2102, 0x4000 },

-  { 0x8c00, 0x20e9, 0x3000 },

-  { 0x8c00, 0x20e7, 0x2000 },

-  { 0x0c00, 0x20e6, 0x0000 },

-  { 0x0c00, 0x20e8, 0x0000 },

-  { 0x9a00, 0x2100, 0x2000 },

-  { 0x0c00, 0x20ea, 0x0000 },

-  { 0x1a00, 0x2101, 0x0000 },

-  { 0x9a00, 0x2106, 0x3000 },

-  { 0x9a00, 0x2104, 0x2000 },

-  { 0x1a00, 0x2103, 0x0000 },

-  { 0x1a00, 0x2105, 0x0000 },

-  { 0x9a00, 0x2108, 0x2000 },

-  { 0x0900, 0x2107, 0x0000 },

-  { 0x1a00, 0x2109, 0x0000 },

-  { 0x8900, 0x2112, 0x4000 },

-  { 0x8500, 0x210e, 0x3000 },

-  { 0x8900, 0x210c, 0x2000 },

-  { 0x0900, 0x210b, 0x0000 },

-  { 0x0900, 0x210d, 0x0000 },

-  { 0x8900, 0x2110, 0x2000 },

-  { 0x0500, 0x210f, 0x0000 },

-  { 0x0900, 0x2111, 0x0000 },

-  { 0x9a00, 0x2116, 0x3000 },

-  { 0x9a00, 0x2114, 0x2000 },

-  { 0x0500, 0x2113, 0x0000 },

-  { 0x0900, 0x2115, 0x0000 },

-  { 0x9a00, 0x2118, 0x2000 },

-  { 0x1a00, 0x2117, 0x0000 },

-  { 0x0900, 0x2119, 0x0000 },

-  { 0x8e00, 0x2162, 0x7000 },

-  { 0x9a00, 0x213a, 0x6000 },

-  { 0x8900, 0x212a, 0x5000 },

-  { 0x9a00, 0x2122, 0x4000 },

-  { 0x9a00, 0x211e, 0x3000 },

-  { 0x8900, 0x211c, 0x2000 },

-  { 0x0900, 0x211b, 0x0000 },

-  { 0x0900, 0x211d, 0x0000 },

-  { 0x9a00, 0x2120, 0x2000 },

-  { 0x1a00, 0x211f, 0x0000 },

-  { 0x1a00, 0x2121, 0x0000 },

-  { 0x8900, 0x2126, 0x3000 },

-  { 0x8900, 0x2124, 0x2000 },

-  { 0x1a00, 0x2123, 0x0000 },

-  { 0x1a00, 0x2125, 0x0000 },

-  { 0x8900, 0x2128, 0x2000 },

-  { 0x1a00, 0x2127, 0x0000 },

-  { 0x1a00, 0x2129, 0x0000 },

-  { 0x9a00, 0x2132, 0x4000 },

-  { 0x9a00, 0x212e, 0x3000 },

-  { 0x8900, 0x212c, 0x2000 },

-  { 0x0900, 0x212b, 0x0000 },

-  { 0x0900, 0x212d, 0x0000 },

-  { 0x8900, 0x2130, 0x2000 },

-  { 0x0500, 0x212f, 0x0000 },

-  { 0x0900, 0x2131, 0x0000 },

-  { 0x8700, 0x2136, 0x3000 },

-  { 0x8500, 0x2134, 0x2000 },

-  { 0x0900, 0x2133, 0x0000 },

-  { 0x0700, 0x2135, 0x0000 },

-  { 0x8700, 0x2138, 0x2000 },

-  { 0x0700, 0x2137, 0x0000 },

-  { 0x0500, 0x2139, 0x0000 },

-  { 0x9900, 0x214b, 0x5000 },

-  { 0x9900, 0x2143, 0x4000 },

-  { 0x8900, 0x213f, 0x3000 },

-  { 0x8500, 0x213d, 0x2000 },

-  { 0x1a00, 0x213b, 0x0000 },

-  { 0x0900, 0x213e, 0x0000 },

-  { 0x9900, 0x2141, 0x2000 },

-  { 0x1900, 0x2140, 0x0000 },

-  { 0x1900, 0x2142, 0x0000 },

-  { 0x8500, 0x2147, 0x3000 },

-  { 0x8900, 0x2145, 0x2000 },

-  { 0x1900, 0x2144, 0x0000 },

-  { 0x0500, 0x2146, 0x0000 },

-  { 0x8500, 0x2149, 0x2000 },

-  { 0x0500, 0x2148, 0x0000 },

-  { 0x1a00, 0x214a, 0x0000 },

-  { 0x8f00, 0x215a, 0x4000 },

-  { 0x8f00, 0x2156, 0x3000 },

-  { 0x8f00, 0x2154, 0x2000 },

-  { 0x0f00, 0x2153, 0x0000 },

-  { 0x0f00, 0x2155, 0x0000 },

-  { 0x8f00, 0x2158, 0x2000 },

-  { 0x0f00, 0x2157, 0x0000 },

-  { 0x0f00, 0x2159, 0x0000 },

-  { 0x8f00, 0x215e, 0x3000 },

-  { 0x8f00, 0x215c, 0x2000 },

-  { 0x0f00, 0x215b, 0x0000 },

-  { 0x0f00, 0x215d, 0x0000 },

-  { 0x8e00, 0x2160, 0x2000 },

-  { 0x0f00, 0x215f, 0x0000 },

-  { 0x0e00, 0x2161, 0x0000 },

-  { 0x8e00, 0x2182, 0x6000 },

-  { 0x8e00, 0x2172, 0x5000 },

-  { 0x8e00, 0x216a, 0x4000 },

-  { 0x8e00, 0x2166, 0x3000 },

-  { 0x8e00, 0x2164, 0x2000 },

-  { 0x0e00, 0x2163, 0x0000 },

-  { 0x0e00, 0x2165, 0x0000 },

-  { 0x8e00, 0x2168, 0x2000 },

-  { 0x0e00, 0x2167, 0x0000 },

-  { 0x0e00, 0x2169, 0x0000 },

-  { 0x8e00, 0x216e, 0x3000 },

-  { 0x8e00, 0x216c, 0x2000 },

-  { 0x0e00, 0x216b, 0x0000 },

-  { 0x0e00, 0x216d, 0x0000 },

-  { 0x8e00, 0x2170, 0x2000 },

-  { 0x0e00, 0x216f, 0x0000 },

-  { 0x0e00, 0x2171, 0x0000 },

-  { 0x8e00, 0x217a, 0x4000 },

-  { 0x8e00, 0x2176, 0x3000 },

-  { 0x8e00, 0x2174, 0x2000 },

-  { 0x0e00, 0x2173, 0x0000 },

-  { 0x0e00, 0x2175, 0x0000 },

-  { 0x8e00, 0x2178, 0x2000 },

-  { 0x0e00, 0x2177, 0x0000 },

-  { 0x0e00, 0x2179, 0x0000 },

-  { 0x8e00, 0x217e, 0x3000 },

-  { 0x8e00, 0x217c, 0x2000 },

-  { 0x0e00, 0x217b, 0x0000 },

-  { 0x0e00, 0x217d, 0x0000 },

-  { 0x8e00, 0x2180, 0x2000 },

-  { 0x0e00, 0x217f, 0x0000 },

-  { 0x0e00, 0x2181, 0x0000 },

-  { 0x9a00, 0x219e, 0x5000 },

-  { 0x9a00, 0x2196, 0x4000 },

-  { 0x9900, 0x2192, 0x3000 },

-  { 0x9900, 0x2190, 0x2000 },

-  { 0x0e00, 0x2183, 0x0000 },

-  { 0x1900, 0x2191, 0x0000 },

-  { 0x9900, 0x2194, 0x2000 },

-  { 0x1900, 0x2193, 0x0000 },

-  { 0x1a00, 0x2195, 0x0000 },

-  { 0x9900, 0x219a, 0x3000 },

-  { 0x9a00, 0x2198, 0x2000 },

-  { 0x1a00, 0x2197, 0x0000 },

-  { 0x1a00, 0x2199, 0x0000 },

-  { 0x9a00, 0x219c, 0x2000 },

-  { 0x1900, 0x219b, 0x0000 },

-  { 0x1a00, 0x219d, 0x0000 },

-  { 0x9900, 0x21a6, 0x4000 },

-  { 0x9a00, 0x21a2, 0x3000 },

-  { 0x9900, 0x21a0, 0x2000 },

-  { 0x1a00, 0x219f, 0x0000 },

-  { 0x1a00, 0x21a1, 0x0000 },

-  { 0x9a00, 0x21a4, 0x2000 },

-  { 0x1900, 0x21a3, 0x0000 },

-  { 0x1a00, 0x21a5, 0x0000 },

-  { 0x9a00, 0x21aa, 0x3000 },

-  { 0x9a00, 0x21a8, 0x2000 },

-  { 0x1a00, 0x21a7, 0x0000 },

-  { 0x1a00, 0x21a9, 0x0000 },

-  { 0x9a00, 0x21ac, 0x2000 },

-  { 0x1a00, 0x21ab, 0x0000 },

-  { 0x1a00, 0x21ad, 0x0000 },

-  { 0x9900, 0x222e, 0x8000 },

-  { 0x9a00, 0x21ee, 0x7000 },

-  { 0x9900, 0x21ce, 0x6000 },

-  { 0x9a00, 0x21be, 0x5000 },

-  { 0x9a00, 0x21b6, 0x4000 },

-  { 0x9a00, 0x21b2, 0x3000 },

-  { 0x9a00, 0x21b0, 0x2000 },

-  { 0x1a00, 0x21af, 0x0000 },

-  { 0x1a00, 0x21b1, 0x0000 },

-  { 0x9a00, 0x21b4, 0x2000 },

-  { 0x1a00, 0x21b3, 0x0000 },

-  { 0x1a00, 0x21b5, 0x0000 },

-  { 0x9a00, 0x21ba, 0x3000 },

-  { 0x9a00, 0x21b8, 0x2000 },

-  { 0x1a00, 0x21b7, 0x0000 },

-  { 0x1a00, 0x21b9, 0x0000 },

-  { 0x9a00, 0x21bc, 0x2000 },

-  { 0x1a00, 0x21bb, 0x0000 },

-  { 0x1a00, 0x21bd, 0x0000 },

-  { 0x9a00, 0x21c6, 0x4000 },

-  { 0x9a00, 0x21c2, 0x3000 },

-  { 0x9a00, 0x21c0, 0x2000 },

-  { 0x1a00, 0x21bf, 0x0000 },

-  { 0x1a00, 0x21c1, 0x0000 },

-  { 0x9a00, 0x21c4, 0x2000 },

-  { 0x1a00, 0x21c3, 0x0000 },

-  { 0x1a00, 0x21c5, 0x0000 },

-  { 0x9a00, 0x21ca, 0x3000 },

-  { 0x9a00, 0x21c8, 0x2000 },

-  { 0x1a00, 0x21c7, 0x0000 },

-  { 0x1a00, 0x21c9, 0x0000 },

-  { 0x9a00, 0x21cc, 0x2000 },

-  { 0x1a00, 0x21cb, 0x0000 },

-  { 0x1a00, 0x21cd, 0x0000 },

-  { 0x9a00, 0x21de, 0x5000 },

-  { 0x9a00, 0x21d6, 0x4000 },

-  { 0x9900, 0x21d2, 0x3000 },

-  { 0x9a00, 0x21d0, 0x2000 },

-  { 0x1900, 0x21cf, 0x0000 },

-  { 0x1a00, 0x21d1, 0x0000 },

-  { 0x9900, 0x21d4, 0x2000 },

-  { 0x1a00, 0x21d3, 0x0000 },

-  { 0x1a00, 0x21d5, 0x0000 },

-  { 0x9a00, 0x21da, 0x3000 },

-  { 0x9a00, 0x21d8, 0x2000 },

-  { 0x1a00, 0x21d7, 0x0000 },

-  { 0x1a00, 0x21d9, 0x0000 },

-  { 0x9a00, 0x21dc, 0x2000 },

-  { 0x1a00, 0x21db, 0x0000 },

-  { 0x1a00, 0x21dd, 0x0000 },

-  { 0x9a00, 0x21e6, 0x4000 },

-  { 0x9a00, 0x21e2, 0x3000 },

-  { 0x9a00, 0x21e0, 0x2000 },

-  { 0x1a00, 0x21df, 0x0000 },

-  { 0x1a00, 0x21e1, 0x0000 },

-  { 0x9a00, 0x21e4, 0x2000 },

-  { 0x1a00, 0x21e3, 0x0000 },

-  { 0x1a00, 0x21e5, 0x0000 },

-  { 0x9a00, 0x21ea, 0x3000 },

-  { 0x9a00, 0x21e8, 0x2000 },

-  { 0x1a00, 0x21e7, 0x0000 },

-  { 0x1a00, 0x21e9, 0x0000 },

-  { 0x9a00, 0x21ec, 0x2000 },

-  { 0x1a00, 0x21eb, 0x0000 },

-  { 0x1a00, 0x21ed, 0x0000 },

-  { 0x9900, 0x220e, 0x6000 },

-  { 0x9900, 0x21fe, 0x5000 },

-  { 0x9900, 0x21f6, 0x4000 },

-  { 0x9a00, 0x21f2, 0x3000 },

-  { 0x9a00, 0x21f0, 0x2000 },

-  { 0x1a00, 0x21ef, 0x0000 },

-  { 0x1a00, 0x21f1, 0x0000 },

-  { 0x9900, 0x21f4, 0x2000 },

-  { 0x1a00, 0x21f3, 0x0000 },

-  { 0x1900, 0x21f5, 0x0000 },

-  { 0x9900, 0x21fa, 0x3000 },

-  { 0x9900, 0x21f8, 0x2000 },

-  { 0x1900, 0x21f7, 0x0000 },

-  { 0x1900, 0x21f9, 0x0000 },

-  { 0x9900, 0x21fc, 0x2000 },

-  { 0x1900, 0x21fb, 0x0000 },

-  { 0x1900, 0x21fd, 0x0000 },

-  { 0x9900, 0x2206, 0x4000 },

-  { 0x9900, 0x2202, 0x3000 },

-  { 0x9900, 0x2200, 0x2000 },

-  { 0x1900, 0x21ff, 0x0000 },

-  { 0x1900, 0x2201, 0x0000 },

-  { 0x9900, 0x2204, 0x2000 },

-  { 0x1900, 0x2203, 0x0000 },

-  { 0x1900, 0x2205, 0x0000 },

-  { 0x9900, 0x220a, 0x3000 },

-  { 0x9900, 0x2208, 0x2000 },

-  { 0x1900, 0x2207, 0x0000 },

-  { 0x1900, 0x2209, 0x0000 },

-  { 0x9900, 0x220c, 0x2000 },

-  { 0x1900, 0x220b, 0x0000 },

-  { 0x1900, 0x220d, 0x0000 },

-  { 0x9900, 0x221e, 0x5000 },

-  { 0x9900, 0x2216, 0x4000 },

-  { 0x9900, 0x2212, 0x3000 },

-  { 0x9900, 0x2210, 0x2000 },

-  { 0x1900, 0x220f, 0x0000 },

-  { 0x1900, 0x2211, 0x0000 },

-  { 0x9900, 0x2214, 0x2000 },

-  { 0x1900, 0x2213, 0x0000 },

-  { 0x1900, 0x2215, 0x0000 },

-  { 0x9900, 0x221a, 0x3000 },

-  { 0x9900, 0x2218, 0x2000 },

-  { 0x1900, 0x2217, 0x0000 },

-  { 0x1900, 0x2219, 0x0000 },

-  { 0x9900, 0x221c, 0x2000 },

-  { 0x1900, 0x221b, 0x0000 },

-  { 0x1900, 0x221d, 0x0000 },

-  { 0x9900, 0x2226, 0x4000 },

-  { 0x9900, 0x2222, 0x3000 },

-  { 0x9900, 0x2220, 0x2000 },

-  { 0x1900, 0x221f, 0x0000 },

-  { 0x1900, 0x2221, 0x0000 },

-  { 0x9900, 0x2224, 0x2000 },

-  { 0x1900, 0x2223, 0x0000 },

-  { 0x1900, 0x2225, 0x0000 },

-  { 0x9900, 0x222a, 0x3000 },

-  { 0x9900, 0x2228, 0x2000 },

-  { 0x1900, 0x2227, 0x0000 },

-  { 0x1900, 0x2229, 0x0000 },

-  { 0x9900, 0x222c, 0x2000 },

-  { 0x1900, 0x222b, 0x0000 },

-  { 0x1900, 0x222d, 0x0000 },

-  { 0x9900, 0x226e, 0x7000 },

-  { 0x9900, 0x224e, 0x6000 },

-  { 0x9900, 0x223e, 0x5000 },

-  { 0x9900, 0x2236, 0x4000 },

-  { 0x9900, 0x2232, 0x3000 },

-  { 0x9900, 0x2230, 0x2000 },

-  { 0x1900, 0x222f, 0x0000 },

-  { 0x1900, 0x2231, 0x0000 },

-  { 0x9900, 0x2234, 0x2000 },

-  { 0x1900, 0x2233, 0x0000 },

-  { 0x1900, 0x2235, 0x0000 },

-  { 0x9900, 0x223a, 0x3000 },

-  { 0x9900, 0x2238, 0x2000 },

-  { 0x1900, 0x2237, 0x0000 },

-  { 0x1900, 0x2239, 0x0000 },

-  { 0x9900, 0x223c, 0x2000 },

-  { 0x1900, 0x223b, 0x0000 },

-  { 0x1900, 0x223d, 0x0000 },

-  { 0x9900, 0x2246, 0x4000 },

-  { 0x9900, 0x2242, 0x3000 },

-  { 0x9900, 0x2240, 0x2000 },

-  { 0x1900, 0x223f, 0x0000 },

-  { 0x1900, 0x2241, 0x0000 },

-  { 0x9900, 0x2244, 0x2000 },

-  { 0x1900, 0x2243, 0x0000 },

-  { 0x1900, 0x2245, 0x0000 },

-  { 0x9900, 0x224a, 0x3000 },

-  { 0x9900, 0x2248, 0x2000 },

-  { 0x1900, 0x2247, 0x0000 },

-  { 0x1900, 0x2249, 0x0000 },

-  { 0x9900, 0x224c, 0x2000 },

-  { 0x1900, 0x224b, 0x0000 },

-  { 0x1900, 0x224d, 0x0000 },

-  { 0x9900, 0x225e, 0x5000 },

-  { 0x9900, 0x2256, 0x4000 },

-  { 0x9900, 0x2252, 0x3000 },

-  { 0x9900, 0x2250, 0x2000 },

-  { 0x1900, 0x224f, 0x0000 },

-  { 0x1900, 0x2251, 0x0000 },

-  { 0x9900, 0x2254, 0x2000 },

-  { 0x1900, 0x2253, 0x0000 },

-  { 0x1900, 0x2255, 0x0000 },

-  { 0x9900, 0x225a, 0x3000 },

-  { 0x9900, 0x2258, 0x2000 },

-  { 0x1900, 0x2257, 0x0000 },

-  { 0x1900, 0x2259, 0x0000 },

-  { 0x9900, 0x225c, 0x2000 },

-  { 0x1900, 0x225b, 0x0000 },

-  { 0x1900, 0x225d, 0x0000 },

-  { 0x9900, 0x2266, 0x4000 },

-  { 0x9900, 0x2262, 0x3000 },

-  { 0x9900, 0x2260, 0x2000 },

-  { 0x1900, 0x225f, 0x0000 },

-  { 0x1900, 0x2261, 0x0000 },

-  { 0x9900, 0x2264, 0x2000 },

-  { 0x1900, 0x2263, 0x0000 },

-  { 0x1900, 0x2265, 0x0000 },

-  { 0x9900, 0x226a, 0x3000 },

-  { 0x9900, 0x2268, 0x2000 },

-  { 0x1900, 0x2267, 0x0000 },

-  { 0x1900, 0x2269, 0x0000 },

-  { 0x9900, 0x226c, 0x2000 },

-  { 0x1900, 0x226b, 0x0000 },

-  { 0x1900, 0x226d, 0x0000 },

-  { 0x9900, 0x228e, 0x6000 },

-  { 0x9900, 0x227e, 0x5000 },

-  { 0x9900, 0x2276, 0x4000 },

-  { 0x9900, 0x2272, 0x3000 },

-  { 0x9900, 0x2270, 0x2000 },

-  { 0x1900, 0x226f, 0x0000 },

-  { 0x1900, 0x2271, 0x0000 },

-  { 0x9900, 0x2274, 0x2000 },

-  { 0x1900, 0x2273, 0x0000 },

-  { 0x1900, 0x2275, 0x0000 },

-  { 0x9900, 0x227a, 0x3000 },

-  { 0x9900, 0x2278, 0x2000 },

-  { 0x1900, 0x2277, 0x0000 },

-  { 0x1900, 0x2279, 0x0000 },

-  { 0x9900, 0x227c, 0x2000 },

-  { 0x1900, 0x227b, 0x0000 },

-  { 0x1900, 0x227d, 0x0000 },

-  { 0x9900, 0x2286, 0x4000 },

-  { 0x9900, 0x2282, 0x3000 },

-  { 0x9900, 0x2280, 0x2000 },

-  { 0x1900, 0x227f, 0x0000 },

-  { 0x1900, 0x2281, 0x0000 },

-  { 0x9900, 0x2284, 0x2000 },

-  { 0x1900, 0x2283, 0x0000 },

-  { 0x1900, 0x2285, 0x0000 },

-  { 0x9900, 0x228a, 0x3000 },

-  { 0x9900, 0x2288, 0x2000 },

-  { 0x1900, 0x2287, 0x0000 },

-  { 0x1900, 0x2289, 0x0000 },

-  { 0x9900, 0x228c, 0x2000 },

-  { 0x1900, 0x228b, 0x0000 },

-  { 0x1900, 0x228d, 0x0000 },

-  { 0x9900, 0x229e, 0x5000 },

-  { 0x9900, 0x2296, 0x4000 },

-  { 0x9900, 0x2292, 0x3000 },

-  { 0x9900, 0x2290, 0x2000 },

-  { 0x1900, 0x228f, 0x0000 },

-  { 0x1900, 0x2291, 0x0000 },

-  { 0x9900, 0x2294, 0x2000 },

-  { 0x1900, 0x2293, 0x0000 },

-  { 0x1900, 0x2295, 0x0000 },

-  { 0x9900, 0x229a, 0x3000 },

-  { 0x9900, 0x2298, 0x2000 },

-  { 0x1900, 0x2297, 0x0000 },

-  { 0x1900, 0x2299, 0x0000 },

-  { 0x9900, 0x229c, 0x2000 },

-  { 0x1900, 0x229b, 0x0000 },

-  { 0x1900, 0x229d, 0x0000 },

-  { 0x9900, 0x22a6, 0x4000 },

-  { 0x9900, 0x22a2, 0x3000 },

-  { 0x9900, 0x22a0, 0x2000 },

-  { 0x1900, 0x229f, 0x0000 },

-  { 0x1900, 0x22a1, 0x0000 },

-  { 0x9900, 0x22a4, 0x2000 },

-  { 0x1900, 0x22a3, 0x0000 },

-  { 0x1900, 0x22a5, 0x0000 },

-  { 0x9900, 0x22aa, 0x3000 },

-  { 0x9900, 0x22a8, 0x2000 },

-  { 0x1900, 0x22a7, 0x0000 },

-  { 0x1900, 0x22a9, 0x0000 },

-  { 0x9900, 0x22ac, 0x2000 },

-  { 0x1900, 0x22ab, 0x0000 },

-  { 0x1900, 0x22ad, 0x0000 },

-  { 0x8f00, 0x2787, 0xb000 },

-  { 0x9a00, 0x250b, 0xa000 },

-  { 0x9900, 0x23ae, 0x9000 },

-  { 0x9a00, 0x232e, 0x8000 },

-  { 0x9900, 0x22ee, 0x7000 },

-  { 0x9900, 0x22ce, 0x6000 },

-  { 0x9900, 0x22be, 0x5000 },

-  { 0x9900, 0x22b6, 0x4000 },

-  { 0x9900, 0x22b2, 0x3000 },

-  { 0x9900, 0x22b0, 0x2000 },

-  { 0x1900, 0x22af, 0x0000 },

-  { 0x1900, 0x22b1, 0x0000 },

-  { 0x9900, 0x22b4, 0x2000 },

-  { 0x1900, 0x22b3, 0x0000 },

-  { 0x1900, 0x22b5, 0x0000 },

-  { 0x9900, 0x22ba, 0x3000 },

-  { 0x9900, 0x22b8, 0x2000 },

-  { 0x1900, 0x22b7, 0x0000 },

-  { 0x1900, 0x22b9, 0x0000 },

-  { 0x9900, 0x22bc, 0x2000 },

-  { 0x1900, 0x22bb, 0x0000 },

-  { 0x1900, 0x22bd, 0x0000 },

-  { 0x9900, 0x22c6, 0x4000 },

-  { 0x9900, 0x22c2, 0x3000 },

-  { 0x9900, 0x22c0, 0x2000 },

-  { 0x1900, 0x22bf, 0x0000 },

-  { 0x1900, 0x22c1, 0x0000 },

-  { 0x9900, 0x22c4, 0x2000 },

-  { 0x1900, 0x22c3, 0x0000 },

-  { 0x1900, 0x22c5, 0x0000 },

-  { 0x9900, 0x22ca, 0x3000 },

-  { 0x9900, 0x22c8, 0x2000 },

-  { 0x1900, 0x22c7, 0x0000 },

-  { 0x1900, 0x22c9, 0x0000 },

-  { 0x9900, 0x22cc, 0x2000 },

-  { 0x1900, 0x22cb, 0x0000 },

-  { 0x1900, 0x22cd, 0x0000 },

-  { 0x9900, 0x22de, 0x5000 },

-  { 0x9900, 0x22d6, 0x4000 },

-  { 0x9900, 0x22d2, 0x3000 },

-  { 0x9900, 0x22d0, 0x2000 },

-  { 0x1900, 0x22cf, 0x0000 },

-  { 0x1900, 0x22d1, 0x0000 },

-  { 0x9900, 0x22d4, 0x2000 },

-  { 0x1900, 0x22d3, 0x0000 },

-  { 0x1900, 0x22d5, 0x0000 },

-  { 0x9900, 0x22da, 0x3000 },

-  { 0x9900, 0x22d8, 0x2000 },

-  { 0x1900, 0x22d7, 0x0000 },

-  { 0x1900, 0x22d9, 0x0000 },

-  { 0x9900, 0x22dc, 0x2000 },

-  { 0x1900, 0x22db, 0x0000 },

-  { 0x1900, 0x22dd, 0x0000 },

-  { 0x9900, 0x22e6, 0x4000 },

-  { 0x9900, 0x22e2, 0x3000 },

-  { 0x9900, 0x22e0, 0x2000 },

-  { 0x1900, 0x22df, 0x0000 },

-  { 0x1900, 0x22e1, 0x0000 },

-  { 0x9900, 0x22e4, 0x2000 },

-  { 0x1900, 0x22e3, 0x0000 },

-  { 0x1900, 0x22e5, 0x0000 },

-  { 0x9900, 0x22ea, 0x3000 },

-  { 0x9900, 0x22e8, 0x2000 },

-  { 0x1900, 0x22e7, 0x0000 },

-  { 0x1900, 0x22e9, 0x0000 },

-  { 0x9900, 0x22ec, 0x2000 },

-  { 0x1900, 0x22eb, 0x0000 },

-  { 0x1900, 0x22ed, 0x0000 },

-  { 0x9a00, 0x230e, 0x6000 },

-  { 0x9900, 0x22fe, 0x5000 },

-  { 0x9900, 0x22f6, 0x4000 },

-  { 0x9900, 0x22f2, 0x3000 },

-  { 0x9900, 0x22f0, 0x2000 },

-  { 0x1900, 0x22ef, 0x0000 },

-  { 0x1900, 0x22f1, 0x0000 },

-  { 0x9900, 0x22f4, 0x2000 },

-  { 0x1900, 0x22f3, 0x0000 },

-  { 0x1900, 0x22f5, 0x0000 },

-  { 0x9900, 0x22fa, 0x3000 },

-  { 0x9900, 0x22f8, 0x2000 },

-  { 0x1900, 0x22f7, 0x0000 },

-  { 0x1900, 0x22f9, 0x0000 },

-  { 0x9900, 0x22fc, 0x2000 },

-  { 0x1900, 0x22fb, 0x0000 },

-  { 0x1900, 0x22fd, 0x0000 },

-  { 0x9a00, 0x2306, 0x4000 },

-  { 0x9a00, 0x2302, 0x3000 },

-  { 0x9a00, 0x2300, 0x2000 },

-  { 0x1900, 0x22ff, 0x0000 },

-  { 0x1a00, 0x2301, 0x0000 },

-  { 0x9a00, 0x2304, 0x2000 },

-  { 0x1a00, 0x2303, 0x0000 },

-  { 0x1a00, 0x2305, 0x0000 },

-  { 0x9900, 0x230a, 0x3000 },

-  { 0x9900, 0x2308, 0x2000 },

-  { 0x1a00, 0x2307, 0x0000 },

-  { 0x1900, 0x2309, 0x0000 },

-  { 0x9a00, 0x230c, 0x2000 },

-  { 0x1900, 0x230b, 0x0000 },

-  { 0x1a00, 0x230d, 0x0000 },

-  { 0x9a00, 0x231e, 0x5000 },

-  { 0x9a00, 0x2316, 0x4000 },

-  { 0x9a00, 0x2312, 0x3000 },

-  { 0x9a00, 0x2310, 0x2000 },

-  { 0x1a00, 0x230f, 0x0000 },

-  { 0x1a00, 0x2311, 0x0000 },

-  { 0x9a00, 0x2314, 0x2000 },

-  { 0x1a00, 0x2313, 0x0000 },

-  { 0x1a00, 0x2315, 0x0000 },

-  { 0x9a00, 0x231a, 0x3000 },

-  { 0x9a00, 0x2318, 0x2000 },

-  { 0x1a00, 0x2317, 0x0000 },

-  { 0x1a00, 0x2319, 0x0000 },

-  { 0x9a00, 0x231c, 0x2000 },

-  { 0x1a00, 0x231b, 0x0000 },

-  { 0x1a00, 0x231d, 0x0000 },

-  { 0x9a00, 0x2326, 0x4000 },

-  { 0x9a00, 0x2322, 0x3000 },

-  { 0x9900, 0x2320, 0x2000 },

-  { 0x1a00, 0x231f, 0x0000 },

-  { 0x1900, 0x2321, 0x0000 },

-  { 0x9a00, 0x2324, 0x2000 },

-  { 0x1a00, 0x2323, 0x0000 },

-  { 0x1a00, 0x2325, 0x0000 },

-  { 0x9200, 0x232a, 0x3000 },

-  { 0x9a00, 0x2328, 0x2000 },

-  { 0x1a00, 0x2327, 0x0000 },

-  { 0x1600, 0x2329, 0x0000 },

-  { 0x9a00, 0x232c, 0x2000 },

-  { 0x1a00, 0x232b, 0x0000 },

-  { 0x1a00, 0x232d, 0x0000 },

-  { 0x9a00, 0x236e, 0x7000 },

-  { 0x9a00, 0x234e, 0x6000 },

-  { 0x9a00, 0x233e, 0x5000 },

-  { 0x9a00, 0x2336, 0x4000 },

-  { 0x9a00, 0x2332, 0x3000 },

-  { 0x9a00, 0x2330, 0x2000 },

-  { 0x1a00, 0x232f, 0x0000 },

-  { 0x1a00, 0x2331, 0x0000 },

-  { 0x9a00, 0x2334, 0x2000 },

-  { 0x1a00, 0x2333, 0x0000 },

-  { 0x1a00, 0x2335, 0x0000 },

-  { 0x9a00, 0x233a, 0x3000 },

-  { 0x9a00, 0x2338, 0x2000 },

-  { 0x1a00, 0x2337, 0x0000 },

-  { 0x1a00, 0x2339, 0x0000 },

-  { 0x9a00, 0x233c, 0x2000 },

-  { 0x1a00, 0x233b, 0x0000 },

-  { 0x1a00, 0x233d, 0x0000 },

-  { 0x9a00, 0x2346, 0x4000 },

-  { 0x9a00, 0x2342, 0x3000 },

-  { 0x9a00, 0x2340, 0x2000 },

-  { 0x1a00, 0x233f, 0x0000 },

-  { 0x1a00, 0x2341, 0x0000 },

-  { 0x9a00, 0x2344, 0x2000 },

-  { 0x1a00, 0x2343, 0x0000 },

-  { 0x1a00, 0x2345, 0x0000 },

-  { 0x9a00, 0x234a, 0x3000 },

-  { 0x9a00, 0x2348, 0x2000 },

-  { 0x1a00, 0x2347, 0x0000 },

-  { 0x1a00, 0x2349, 0x0000 },

-  { 0x9a00, 0x234c, 0x2000 },

-  { 0x1a00, 0x234b, 0x0000 },

-  { 0x1a00, 0x234d, 0x0000 },

-  { 0x9a00, 0x235e, 0x5000 },

-  { 0x9a00, 0x2356, 0x4000 },

-  { 0x9a00, 0x2352, 0x3000 },

-  { 0x9a00, 0x2350, 0x2000 },

-  { 0x1a00, 0x234f, 0x0000 },

-  { 0x1a00, 0x2351, 0x0000 },

-  { 0x9a00, 0x2354, 0x2000 },

-  { 0x1a00, 0x2353, 0x0000 },

-  { 0x1a00, 0x2355, 0x0000 },

-  { 0x9a00, 0x235a, 0x3000 },

-  { 0x9a00, 0x2358, 0x2000 },

-  { 0x1a00, 0x2357, 0x0000 },

-  { 0x1a00, 0x2359, 0x0000 },

-  { 0x9a00, 0x235c, 0x2000 },

-  { 0x1a00, 0x235b, 0x0000 },

-  { 0x1a00, 0x235d, 0x0000 },

-  { 0x9a00, 0x2366, 0x4000 },

-  { 0x9a00, 0x2362, 0x3000 },

-  { 0x9a00, 0x2360, 0x2000 },

-  { 0x1a00, 0x235f, 0x0000 },

-  { 0x1a00, 0x2361, 0x0000 },

-  { 0x9a00, 0x2364, 0x2000 },

-  { 0x1a00, 0x2363, 0x0000 },

-  { 0x1a00, 0x2365, 0x0000 },

-  { 0x9a00, 0x236a, 0x3000 },

-  { 0x9a00, 0x2368, 0x2000 },

-  { 0x1a00, 0x2367, 0x0000 },

-  { 0x1a00, 0x2369, 0x0000 },

-  { 0x9a00, 0x236c, 0x2000 },

-  { 0x1a00, 0x236b, 0x0000 },

-  { 0x1a00, 0x236d, 0x0000 },

-  { 0x9a00, 0x238e, 0x6000 },

-  { 0x9a00, 0x237e, 0x5000 },

-  { 0x9a00, 0x2376, 0x4000 },

-  { 0x9a00, 0x2372, 0x3000 },

-  { 0x9a00, 0x2370, 0x2000 },

-  { 0x1a00, 0x236f, 0x0000 },

-  { 0x1a00, 0x2371, 0x0000 },

-  { 0x9a00, 0x2374, 0x2000 },

-  { 0x1a00, 0x2373, 0x0000 },

-  { 0x1a00, 0x2375, 0x0000 },

-  { 0x9a00, 0x237a, 0x3000 },

-  { 0x9a00, 0x2378, 0x2000 },

-  { 0x1a00, 0x2377, 0x0000 },

-  { 0x1a00, 0x2379, 0x0000 },

-  { 0x9900, 0x237c, 0x2000 },

-  { 0x1a00, 0x237b, 0x0000 },

-  { 0x1a00, 0x237d, 0x0000 },

-  { 0x9a00, 0x2386, 0x4000 },

-  { 0x9a00, 0x2382, 0x3000 },

-  { 0x9a00, 0x2380, 0x2000 },

-  { 0x1a00, 0x237f, 0x0000 },

-  { 0x1a00, 0x2381, 0x0000 },

-  { 0x9a00, 0x2384, 0x2000 },

-  { 0x1a00, 0x2383, 0x0000 },

-  { 0x1a00, 0x2385, 0x0000 },

-  { 0x9a00, 0x238a, 0x3000 },

-  { 0x9a00, 0x2388, 0x2000 },

-  { 0x1a00, 0x2387, 0x0000 },

-  { 0x1a00, 0x2389, 0x0000 },

-  { 0x9a00, 0x238c, 0x2000 },

-  { 0x1a00, 0x238b, 0x0000 },

-  { 0x1a00, 0x238d, 0x0000 },

-  { 0x9900, 0x239e, 0x5000 },

-  { 0x9a00, 0x2396, 0x4000 },

-  { 0x9a00, 0x2392, 0x3000 },

-  { 0x9a00, 0x2390, 0x2000 },

-  { 0x1a00, 0x238f, 0x0000 },

-  { 0x1a00, 0x2391, 0x0000 },

-  { 0x9a00, 0x2394, 0x2000 },

-  { 0x1a00, 0x2393, 0x0000 },

-  { 0x1a00, 0x2395, 0x0000 },

-  { 0x9a00, 0x239a, 0x3000 },

-  { 0x9a00, 0x2398, 0x2000 },

-  { 0x1a00, 0x2397, 0x0000 },

-  { 0x1a00, 0x2399, 0x0000 },

-  { 0x9900, 0x239c, 0x2000 },

-  { 0x1900, 0x239b, 0x0000 },

-  { 0x1900, 0x239d, 0x0000 },

-  { 0x9900, 0x23a6, 0x4000 },

-  { 0x9900, 0x23a2, 0x3000 },

-  { 0x9900, 0x23a0, 0x2000 },

-  { 0x1900, 0x239f, 0x0000 },

-  { 0x1900, 0x23a1, 0x0000 },

-  { 0x9900, 0x23a4, 0x2000 },

-  { 0x1900, 0x23a3, 0x0000 },

-  { 0x1900, 0x23a5, 0x0000 },

-  { 0x9900, 0x23aa, 0x3000 },

-  { 0x9900, 0x23a8, 0x2000 },

-  { 0x1900, 0x23a7, 0x0000 },

-  { 0x1900, 0x23a9, 0x0000 },

-  { 0x9900, 0x23ac, 0x2000 },

-  { 0x1900, 0x23ab, 0x0000 },

-  { 0x1900, 0x23ad, 0x0000 },

-  { 0x8f00, 0x248b, 0x8000 },

-  { 0x9a00, 0x241d, 0x7000 },

-  { 0x9a00, 0x23ce, 0x6000 },

-  { 0x9a00, 0x23be, 0x5000 },

-  { 0x9500, 0x23b6, 0x4000 },

-  { 0x9900, 0x23b2, 0x3000 },

-  { 0x9900, 0x23b0, 0x2000 },

-  { 0x1900, 0x23af, 0x0000 },

-  { 0x1900, 0x23b1, 0x0000 },

-  { 0x9600, 0x23b4, 0x2000 },

-  { 0x1900, 0x23b3, 0x0000 },

-  { 0x1200, 0x23b5, 0x0000 },

-  { 0x9a00, 0x23ba, 0x3000 },

-  { 0x9a00, 0x23b8, 0x2000 },

-  { 0x1a00, 0x23b7, 0x0000 },

-  { 0x1a00, 0x23b9, 0x0000 },

-  { 0x9a00, 0x23bc, 0x2000 },

-  { 0x1a00, 0x23bb, 0x0000 },

-  { 0x1a00, 0x23bd, 0x0000 },

-  { 0x9a00, 0x23c6, 0x4000 },

-  { 0x9a00, 0x23c2, 0x3000 },

-  { 0x9a00, 0x23c0, 0x2000 },

-  { 0x1a00, 0x23bf, 0x0000 },

-  { 0x1a00, 0x23c1, 0x0000 },

-  { 0x9a00, 0x23c4, 0x2000 },

-  { 0x1a00, 0x23c3, 0x0000 },

-  { 0x1a00, 0x23c5, 0x0000 },

-  { 0x9a00, 0x23ca, 0x3000 },

-  { 0x9a00, 0x23c8, 0x2000 },

-  { 0x1a00, 0x23c7, 0x0000 },

-  { 0x1a00, 0x23c9, 0x0000 },

-  { 0x9a00, 0x23cc, 0x2000 },

-  { 0x1a00, 0x23cb, 0x0000 },

-  { 0x1a00, 0x23cd, 0x0000 },

-  { 0x9a00, 0x240d, 0x5000 },

-  { 0x9a00, 0x2405, 0x4000 },

-  { 0x9a00, 0x2401, 0x3000 },

-  { 0x9a00, 0x23d0, 0x2000 },

-  { 0x1a00, 0x23cf, 0x0000 },

-  { 0x1a00, 0x2400, 0x0000 },

-  { 0x9a00, 0x2403, 0x2000 },

-  { 0x1a00, 0x2402, 0x0000 },

-  { 0x1a00, 0x2404, 0x0000 },

-  { 0x9a00, 0x2409, 0x3000 },

-  { 0x9a00, 0x2407, 0x2000 },

-  { 0x1a00, 0x2406, 0x0000 },

-  { 0x1a00, 0x2408, 0x0000 },

-  { 0x9a00, 0x240b, 0x2000 },

-  { 0x1a00, 0x240a, 0x0000 },

-  { 0x1a00, 0x240c, 0x0000 },

-  { 0x9a00, 0x2415, 0x4000 },

-  { 0x9a00, 0x2411, 0x3000 },

-  { 0x9a00, 0x240f, 0x2000 },

-  { 0x1a00, 0x240e, 0x0000 },

-  { 0x1a00, 0x2410, 0x0000 },

-  { 0x9a00, 0x2413, 0x2000 },

-  { 0x1a00, 0x2412, 0x0000 },

-  { 0x1a00, 0x2414, 0x0000 },

-  { 0x9a00, 0x2419, 0x3000 },

-  { 0x9a00, 0x2417, 0x2000 },

-  { 0x1a00, 0x2416, 0x0000 },

-  { 0x1a00, 0x2418, 0x0000 },

-  { 0x9a00, 0x241b, 0x2000 },

-  { 0x1a00, 0x241a, 0x0000 },

-  { 0x1a00, 0x241c, 0x0000 },

-  { 0x8f00, 0x246b, 0x6000 },

-  { 0x9a00, 0x2446, 0x5000 },

-  { 0x9a00, 0x2425, 0x4000 },

-  { 0x9a00, 0x2421, 0x3000 },

-  { 0x9a00, 0x241f, 0x2000 },

-  { 0x1a00, 0x241e, 0x0000 },

-  { 0x1a00, 0x2420, 0x0000 },

-  { 0x9a00, 0x2423, 0x2000 },

-  { 0x1a00, 0x2422, 0x0000 },

-  { 0x1a00, 0x2424, 0x0000 },

-  { 0x9a00, 0x2442, 0x3000 },

-  { 0x9a00, 0x2440, 0x2000 },

-  { 0x1a00, 0x2426, 0x0000 },

-  { 0x1a00, 0x2441, 0x0000 },

-  { 0x9a00, 0x2444, 0x2000 },

-  { 0x1a00, 0x2443, 0x0000 },

-  { 0x1a00, 0x2445, 0x0000 },

-  { 0x8f00, 0x2463, 0x4000 },

-  { 0x9a00, 0x244a, 0x3000 },

-  { 0x9a00, 0x2448, 0x2000 },

-  { 0x1a00, 0x2447, 0x0000 },

-  { 0x1a00, 0x2449, 0x0000 },

-  { 0x8f00, 0x2461, 0x2000 },

-  { 0x0f00, 0x2460, 0x0000 },

-  { 0x0f00, 0x2462, 0x0000 },

-  { 0x8f00, 0x2467, 0x3000 },

-  { 0x8f00, 0x2465, 0x2000 },

-  { 0x0f00, 0x2464, 0x0000 },

-  { 0x0f00, 0x2466, 0x0000 },

-  { 0x8f00, 0x2469, 0x2000 },

-  { 0x0f00, 0x2468, 0x0000 },

-  { 0x0f00, 0x246a, 0x0000 },

-  { 0x8f00, 0x247b, 0x5000 },

-  { 0x8f00, 0x2473, 0x4000 },

-  { 0x8f00, 0x246f, 0x3000 },

-  { 0x8f00, 0x246d, 0x2000 },

-  { 0x0f00, 0x246c, 0x0000 },

-  { 0x0f00, 0x246e, 0x0000 },

-  { 0x8f00, 0x2471, 0x2000 },

-  { 0x0f00, 0x2470, 0x0000 },

-  { 0x0f00, 0x2472, 0x0000 },

-  { 0x8f00, 0x2477, 0x3000 },

-  { 0x8f00, 0x2475, 0x2000 },

-  { 0x0f00, 0x2474, 0x0000 },

-  { 0x0f00, 0x2476, 0x0000 },

-  { 0x8f00, 0x2479, 0x2000 },

-  { 0x0f00, 0x2478, 0x0000 },

-  { 0x0f00, 0x247a, 0x0000 },

-  { 0x8f00, 0x2483, 0x4000 },

-  { 0x8f00, 0x247f, 0x3000 },

-  { 0x8f00, 0x247d, 0x2000 },

-  { 0x0f00, 0x247c, 0x0000 },

-  { 0x0f00, 0x247e, 0x0000 },

-  { 0x8f00, 0x2481, 0x2000 },

-  { 0x0f00, 0x2480, 0x0000 },

-  { 0x0f00, 0x2482, 0x0000 },

-  { 0x8f00, 0x2487, 0x3000 },

-  { 0x8f00, 0x2485, 0x2000 },

-  { 0x0f00, 0x2484, 0x0000 },

-  { 0x0f00, 0x2486, 0x0000 },

-  { 0x8f00, 0x2489, 0x2000 },

-  { 0x0f00, 0x2488, 0x0000 },

-  { 0x0f00, 0x248a, 0x0000 },

-  { 0x9a00, 0x24cb, 0x7000 },

-  { 0x9a00, 0x24ab, 0x6000 },

-  { 0x8f00, 0x249b, 0x5000 },

-  { 0x8f00, 0x2493, 0x4000 },

-  { 0x8f00, 0x248f, 0x3000 },

-  { 0x8f00, 0x248d, 0x2000 },

-  { 0x0f00, 0x248c, 0x0000 },

-  { 0x0f00, 0x248e, 0x0000 },

-  { 0x8f00, 0x2491, 0x2000 },

-  { 0x0f00, 0x2490, 0x0000 },

-  { 0x0f00, 0x2492, 0x0000 },

-  { 0x8f00, 0x2497, 0x3000 },

-  { 0x8f00, 0x2495, 0x2000 },

-  { 0x0f00, 0x2494, 0x0000 },

-  { 0x0f00, 0x2496, 0x0000 },

-  { 0x8f00, 0x2499, 0x2000 },

-  { 0x0f00, 0x2498, 0x0000 },

-  { 0x0f00, 0x249a, 0x0000 },

-  { 0x9a00, 0x24a3, 0x4000 },

-  { 0x9a00, 0x249f, 0x3000 },

-  { 0x9a00, 0x249d, 0x2000 },

-  { 0x1a00, 0x249c, 0x0000 },

-  { 0x1a00, 0x249e, 0x0000 },

-  { 0x9a00, 0x24a1, 0x2000 },

-  { 0x1a00, 0x24a0, 0x0000 },

-  { 0x1a00, 0x24a2, 0x0000 },

-  { 0x9a00, 0x24a7, 0x3000 },

-  { 0x9a00, 0x24a5, 0x2000 },

-  { 0x1a00, 0x24a4, 0x0000 },

-  { 0x1a00, 0x24a6, 0x0000 },

-  { 0x9a00, 0x24a9, 0x2000 },

-  { 0x1a00, 0x24a8, 0x0000 },

-  { 0x1a00, 0x24aa, 0x0000 },

-  { 0x9a00, 0x24bb, 0x5000 },

-  { 0x9a00, 0x24b3, 0x4000 },

-  { 0x9a00, 0x24af, 0x3000 },

-  { 0x9a00, 0x24ad, 0x2000 },

-  { 0x1a00, 0x24ac, 0x0000 },

-  { 0x1a00, 0x24ae, 0x0000 },

-  { 0x9a00, 0x24b1, 0x2000 },

-  { 0x1a00, 0x24b0, 0x0000 },

-  { 0x1a00, 0x24b2, 0x0000 },

-  { 0x9a00, 0x24b7, 0x3000 },

-  { 0x9a00, 0x24b5, 0x2000 },

-  { 0x1a00, 0x24b4, 0x0000 },

-  { 0x1a00, 0x24b6, 0x0000 },

-  { 0x9a00, 0x24b9, 0x2000 },

-  { 0x1a00, 0x24b8, 0x0000 },

-  { 0x1a00, 0x24ba, 0x0000 },

-  { 0x9a00, 0x24c3, 0x4000 },

-  { 0x9a00, 0x24bf, 0x3000 },

-  { 0x9a00, 0x24bd, 0x2000 },

-  { 0x1a00, 0x24bc, 0x0000 },

-  { 0x1a00, 0x24be, 0x0000 },

-  { 0x9a00, 0x24c1, 0x2000 },

-  { 0x1a00, 0x24c0, 0x0000 },

-  { 0x1a00, 0x24c2, 0x0000 },

-  { 0x9a00, 0x24c7, 0x3000 },

-  { 0x9a00, 0x24c5, 0x2000 },

-  { 0x1a00, 0x24c4, 0x0000 },

-  { 0x1a00, 0x24c6, 0x0000 },

-  { 0x9a00, 0x24c9, 0x2000 },

-  { 0x1a00, 0x24c8, 0x0000 },

-  { 0x1a00, 0x24ca, 0x0000 },

-  { 0x8f00, 0x24eb, 0x6000 },

-  { 0x9a00, 0x24db, 0x5000 },

-  { 0x9a00, 0x24d3, 0x4000 },

-  { 0x9a00, 0x24cf, 0x3000 },

-  { 0x9a00, 0x24cd, 0x2000 },

-  { 0x1a00, 0x24cc, 0x0000 },

-  { 0x1a00, 0x24ce, 0x0000 },

-  { 0x9a00, 0x24d1, 0x2000 },

-  { 0x1a00, 0x24d0, 0x0000 },

-  { 0x1a00, 0x24d2, 0x0000 },

-  { 0x9a00, 0x24d7, 0x3000 },

-  { 0x9a00, 0x24d5, 0x2000 },

-  { 0x1a00, 0x24d4, 0x0000 },

-  { 0x1a00, 0x24d6, 0x0000 },

-  { 0x9a00, 0x24d9, 0x2000 },

-  { 0x1a00, 0x24d8, 0x0000 },

-  { 0x1a00, 0x24da, 0x0000 },

-  { 0x9a00, 0x24e3, 0x4000 },

-  { 0x9a00, 0x24df, 0x3000 },

-  { 0x9a00, 0x24dd, 0x2000 },

-  { 0x1a00, 0x24dc, 0x0000 },

-  { 0x1a00, 0x24de, 0x0000 },

-  { 0x9a00, 0x24e1, 0x2000 },

-  { 0x1a00, 0x24e0, 0x0000 },

-  { 0x1a00, 0x24e2, 0x0000 },

-  { 0x9a00, 0x24e7, 0x3000 },

-  { 0x9a00, 0x24e5, 0x2000 },

-  { 0x1a00, 0x24e4, 0x0000 },

-  { 0x1a00, 0x24e6, 0x0000 },

-  { 0x9a00, 0x24e9, 0x2000 },

-  { 0x1a00, 0x24e8, 0x0000 },

-  { 0x0f00, 0x24ea, 0x0000 },

-  { 0x8f00, 0x24fb, 0x5000 },

-  { 0x8f00, 0x24f3, 0x4000 },

-  { 0x8f00, 0x24ef, 0x3000 },

-  { 0x8f00, 0x24ed, 0x2000 },

-  { 0x0f00, 0x24ec, 0x0000 },

-  { 0x0f00, 0x24ee, 0x0000 },

-  { 0x8f00, 0x24f1, 0x2000 },

-  { 0x0f00, 0x24f0, 0x0000 },

-  { 0x0f00, 0x24f2, 0x0000 },

-  { 0x8f00, 0x24f7, 0x3000 },

-  { 0x8f00, 0x24f5, 0x2000 },

-  { 0x0f00, 0x24f4, 0x0000 },

-  { 0x0f00, 0x24f6, 0x0000 },

-  { 0x8f00, 0x24f9, 0x2000 },

-  { 0x0f00, 0x24f8, 0x0000 },

-  { 0x0f00, 0x24fa, 0x0000 },

-  { 0x9a00, 0x2503, 0x4000 },

-  { 0x8f00, 0x24ff, 0x3000 },

-  { 0x8f00, 0x24fd, 0x2000 },

-  { 0x0f00, 0x24fc, 0x0000 },

-  { 0x0f00, 0x24fe, 0x0000 },

-  { 0x9a00, 0x2501, 0x2000 },

-  { 0x1a00, 0x2500, 0x0000 },

-  { 0x1a00, 0x2502, 0x0000 },

-  { 0x9a00, 0x2507, 0x3000 },

-  { 0x9a00, 0x2505, 0x2000 },

-  { 0x1a00, 0x2504, 0x0000 },

-  { 0x1a00, 0x2506, 0x0000 },

-  { 0x9a00, 0x2509, 0x2000 },

-  { 0x1a00, 0x2508, 0x0000 },

-  { 0x1a00, 0x250a, 0x0000 },

-  { 0x9a00, 0x260b, 0x9000 },

-  { 0x9a00, 0x258b, 0x8000 },

-  { 0x9a00, 0x254b, 0x7000 },

-  { 0x9a00, 0x252b, 0x6000 },

-  { 0x9a00, 0x251b, 0x5000 },

-  { 0x9a00, 0x2513, 0x4000 },

-  { 0x9a00, 0x250f, 0x3000 },

-  { 0x9a00, 0x250d, 0x2000 },

-  { 0x1a00, 0x250c, 0x0000 },

-  { 0x1a00, 0x250e, 0x0000 },

-  { 0x9a00, 0x2511, 0x2000 },

-  { 0x1a00, 0x2510, 0x0000 },

-  { 0x1a00, 0x2512, 0x0000 },

-  { 0x9a00, 0x2517, 0x3000 },

-  { 0x9a00, 0x2515, 0x2000 },

-  { 0x1a00, 0x2514, 0x0000 },

-  { 0x1a00, 0x2516, 0x0000 },

-  { 0x9a00, 0x2519, 0x2000 },

-  { 0x1a00, 0x2518, 0x0000 },

-  { 0x1a00, 0x251a, 0x0000 },

-  { 0x9a00, 0x2523, 0x4000 },

-  { 0x9a00, 0x251f, 0x3000 },

-  { 0x9a00, 0x251d, 0x2000 },

-  { 0x1a00, 0x251c, 0x0000 },

-  { 0x1a00, 0x251e, 0x0000 },

-  { 0x9a00, 0x2521, 0x2000 },

-  { 0x1a00, 0x2520, 0x0000 },

-  { 0x1a00, 0x2522, 0x0000 },

-  { 0x9a00, 0x2527, 0x3000 },

-  { 0x9a00, 0x2525, 0x2000 },

-  { 0x1a00, 0x2524, 0x0000 },

-  { 0x1a00, 0x2526, 0x0000 },

-  { 0x9a00, 0x2529, 0x2000 },

-  { 0x1a00, 0x2528, 0x0000 },

-  { 0x1a00, 0x252a, 0x0000 },

-  { 0x9a00, 0x253b, 0x5000 },

-  { 0x9a00, 0x2533, 0x4000 },

-  { 0x9a00, 0x252f, 0x3000 },

-  { 0x9a00, 0x252d, 0x2000 },

-  { 0x1a00, 0x252c, 0x0000 },

-  { 0x1a00, 0x252e, 0x0000 },

-  { 0x9a00, 0x2531, 0x2000 },

-  { 0x1a00, 0x2530, 0x0000 },

-  { 0x1a00, 0x2532, 0x0000 },

-  { 0x9a00, 0x2537, 0x3000 },

-  { 0x9a00, 0x2535, 0x2000 },

-  { 0x1a00, 0x2534, 0x0000 },

-  { 0x1a00, 0x2536, 0x0000 },

-  { 0x9a00, 0x2539, 0x2000 },

-  { 0x1a00, 0x2538, 0x0000 },

-  { 0x1a00, 0x253a, 0x0000 },

-  { 0x9a00, 0x2543, 0x4000 },

-  { 0x9a00, 0x253f, 0x3000 },

-  { 0x9a00, 0x253d, 0x2000 },

-  { 0x1a00, 0x253c, 0x0000 },

-  { 0x1a00, 0x253e, 0x0000 },

-  { 0x9a00, 0x2541, 0x2000 },

-  { 0x1a00, 0x2540, 0x0000 },

-  { 0x1a00, 0x2542, 0x0000 },

-  { 0x9a00, 0x2547, 0x3000 },

-  { 0x9a00, 0x2545, 0x2000 },

-  { 0x1a00, 0x2544, 0x0000 },

-  { 0x1a00, 0x2546, 0x0000 },

-  { 0x9a00, 0x2549, 0x2000 },

-  { 0x1a00, 0x2548, 0x0000 },

-  { 0x1a00, 0x254a, 0x0000 },

-  { 0x9a00, 0x256b, 0x6000 },

-  { 0x9a00, 0x255b, 0x5000 },

-  { 0x9a00, 0x2553, 0x4000 },

-  { 0x9a00, 0x254f, 0x3000 },

-  { 0x9a00, 0x254d, 0x2000 },

-  { 0x1a00, 0x254c, 0x0000 },

-  { 0x1a00, 0x254e, 0x0000 },

-  { 0x9a00, 0x2551, 0x2000 },

-  { 0x1a00, 0x2550, 0x0000 },

-  { 0x1a00, 0x2552, 0x0000 },

-  { 0x9a00, 0x2557, 0x3000 },

-  { 0x9a00, 0x2555, 0x2000 },

-  { 0x1a00, 0x2554, 0x0000 },

-  { 0x1a00, 0x2556, 0x0000 },

-  { 0x9a00, 0x2559, 0x2000 },

-  { 0x1a00, 0x2558, 0x0000 },

-  { 0x1a00, 0x255a, 0x0000 },

-  { 0x9a00, 0x2563, 0x4000 },

-  { 0x9a00, 0x255f, 0x3000 },

-  { 0x9a00, 0x255d, 0x2000 },

-  { 0x1a00, 0x255c, 0x0000 },

-  { 0x1a00, 0x255e, 0x0000 },

-  { 0x9a00, 0x2561, 0x2000 },

-  { 0x1a00, 0x2560, 0x0000 },

-  { 0x1a00, 0x2562, 0x0000 },

-  { 0x9a00, 0x2567, 0x3000 },

-  { 0x9a00, 0x2565, 0x2000 },

-  { 0x1a00, 0x2564, 0x0000 },

-  { 0x1a00, 0x2566, 0x0000 },

-  { 0x9a00, 0x2569, 0x2000 },

-  { 0x1a00, 0x2568, 0x0000 },

-  { 0x1a00, 0x256a, 0x0000 },

-  { 0x9a00, 0x257b, 0x5000 },

-  { 0x9a00, 0x2573, 0x4000 },

-  { 0x9a00, 0x256f, 0x3000 },

-  { 0x9a00, 0x256d, 0x2000 },

-  { 0x1a00, 0x256c, 0x0000 },

-  { 0x1a00, 0x256e, 0x0000 },

-  { 0x9a00, 0x2571, 0x2000 },

-  { 0x1a00, 0x2570, 0x0000 },

-  { 0x1a00, 0x2572, 0x0000 },

-  { 0x9a00, 0x2577, 0x3000 },

-  { 0x9a00, 0x2575, 0x2000 },

-  { 0x1a00, 0x2574, 0x0000 },

-  { 0x1a00, 0x2576, 0x0000 },

-  { 0x9a00, 0x2579, 0x2000 },

-  { 0x1a00, 0x2578, 0x0000 },

-  { 0x1a00, 0x257a, 0x0000 },

-  { 0x9a00, 0x2583, 0x4000 },

-  { 0x9a00, 0x257f, 0x3000 },

-  { 0x9a00, 0x257d, 0x2000 },

-  { 0x1a00, 0x257c, 0x0000 },

-  { 0x1a00, 0x257e, 0x0000 },

-  { 0x9a00, 0x2581, 0x2000 },

-  { 0x1a00, 0x2580, 0x0000 },

-  { 0x1a00, 0x2582, 0x0000 },

-  { 0x9a00, 0x2587, 0x3000 },

-  { 0x9a00, 0x2585, 0x2000 },

-  { 0x1a00, 0x2584, 0x0000 },

-  { 0x1a00, 0x2586, 0x0000 },

-  { 0x9a00, 0x2589, 0x2000 },

-  { 0x1a00, 0x2588, 0x0000 },

-  { 0x1a00, 0x258a, 0x0000 },

-  { 0x9a00, 0x25cb, 0x7000 },

-  { 0x9a00, 0x25ab, 0x6000 },

-  { 0x9a00, 0x259b, 0x5000 },

-  { 0x9a00, 0x2593, 0x4000 },

-  { 0x9a00, 0x258f, 0x3000 },

-  { 0x9a00, 0x258d, 0x2000 },

-  { 0x1a00, 0x258c, 0x0000 },

-  { 0x1a00, 0x258e, 0x0000 },

-  { 0x9a00, 0x2591, 0x2000 },

-  { 0x1a00, 0x2590, 0x0000 },

-  { 0x1a00, 0x2592, 0x0000 },

-  { 0x9a00, 0x2597, 0x3000 },

-  { 0x9a00, 0x2595, 0x2000 },

-  { 0x1a00, 0x2594, 0x0000 },

-  { 0x1a00, 0x2596, 0x0000 },

-  { 0x9a00, 0x2599, 0x2000 },

-  { 0x1a00, 0x2598, 0x0000 },

-  { 0x1a00, 0x259a, 0x0000 },

-  { 0x9a00, 0x25a3, 0x4000 },

-  { 0x9a00, 0x259f, 0x3000 },

-  { 0x9a00, 0x259d, 0x2000 },

-  { 0x1a00, 0x259c, 0x0000 },

-  { 0x1a00, 0x259e, 0x0000 },

-  { 0x9a00, 0x25a1, 0x2000 },

-  { 0x1a00, 0x25a0, 0x0000 },

-  { 0x1a00, 0x25a2, 0x0000 },

-  { 0x9a00, 0x25a7, 0x3000 },

-  { 0x9a00, 0x25a5, 0x2000 },

-  { 0x1a00, 0x25a4, 0x0000 },

-  { 0x1a00, 0x25a6, 0x0000 },

-  { 0x9a00, 0x25a9, 0x2000 },

-  { 0x1a00, 0x25a8, 0x0000 },

-  { 0x1a00, 0x25aa, 0x0000 },

-  { 0x9a00, 0x25bb, 0x5000 },

-  { 0x9a00, 0x25b3, 0x4000 },

-  { 0x9a00, 0x25af, 0x3000 },

-  { 0x9a00, 0x25ad, 0x2000 },

-  { 0x1a00, 0x25ac, 0x0000 },

-  { 0x1a00, 0x25ae, 0x0000 },

-  { 0x9a00, 0x25b1, 0x2000 },

-  { 0x1a00, 0x25b0, 0x0000 },

-  { 0x1a00, 0x25b2, 0x0000 },

-  { 0x9900, 0x25b7, 0x3000 },

-  { 0x9a00, 0x25b5, 0x2000 },

-  { 0x1a00, 0x25b4, 0x0000 },

-  { 0x1a00, 0x25b6, 0x0000 },

-  { 0x9a00, 0x25b9, 0x2000 },

-  { 0x1a00, 0x25b8, 0x0000 },

-  { 0x1a00, 0x25ba, 0x0000 },

-  { 0x9a00, 0x25c3, 0x4000 },

-  { 0x9a00, 0x25bf, 0x3000 },

-  { 0x9a00, 0x25bd, 0x2000 },

-  { 0x1a00, 0x25bc, 0x0000 },

-  { 0x1a00, 0x25be, 0x0000 },

-  { 0x9900, 0x25c1, 0x2000 },

-  { 0x1a00, 0x25c0, 0x0000 },

-  { 0x1a00, 0x25c2, 0x0000 },

-  { 0x9a00, 0x25c7, 0x3000 },

-  { 0x9a00, 0x25c5, 0x2000 },

-  { 0x1a00, 0x25c4, 0x0000 },

-  { 0x1a00, 0x25c6, 0x0000 },

-  { 0x9a00, 0x25c9, 0x2000 },

-  { 0x1a00, 0x25c8, 0x0000 },

-  { 0x1a00, 0x25ca, 0x0000 },

-  { 0x9a00, 0x25eb, 0x6000 },

-  { 0x9a00, 0x25db, 0x5000 },

-  { 0x9a00, 0x25d3, 0x4000 },

-  { 0x9a00, 0x25cf, 0x3000 },

-  { 0x9a00, 0x25cd, 0x2000 },

-  { 0x1a00, 0x25cc, 0x0000 },

-  { 0x1a00, 0x25ce, 0x0000 },

-  { 0x9a00, 0x25d1, 0x2000 },

-  { 0x1a00, 0x25d0, 0x0000 },

-  { 0x1a00, 0x25d2, 0x0000 },

-  { 0x9a00, 0x25d7, 0x3000 },

-  { 0x9a00, 0x25d5, 0x2000 },

-  { 0x1a00, 0x25d4, 0x0000 },

-  { 0x1a00, 0x25d6, 0x0000 },

-  { 0x9a00, 0x25d9, 0x2000 },

-  { 0x1a00, 0x25d8, 0x0000 },

-  { 0x1a00, 0x25da, 0x0000 },

-  { 0x9a00, 0x25e3, 0x4000 },

-  { 0x9a00, 0x25df, 0x3000 },

-  { 0x9a00, 0x25dd, 0x2000 },

-  { 0x1a00, 0x25dc, 0x0000 },

-  { 0x1a00, 0x25de, 0x0000 },

-  { 0x9a00, 0x25e1, 0x2000 },

-  { 0x1a00, 0x25e0, 0x0000 },

-  { 0x1a00, 0x25e2, 0x0000 },

-  { 0x9a00, 0x25e7, 0x3000 },

-  { 0x9a00, 0x25e5, 0x2000 },

-  { 0x1a00, 0x25e4, 0x0000 },

-  { 0x1a00, 0x25e6, 0x0000 },

-  { 0x9a00, 0x25e9, 0x2000 },

-  { 0x1a00, 0x25e8, 0x0000 },

-  { 0x1a00, 0x25ea, 0x0000 },

-  { 0x9900, 0x25fb, 0x5000 },

-  { 0x9a00, 0x25f3, 0x4000 },

-  { 0x9a00, 0x25ef, 0x3000 },

-  { 0x9a00, 0x25ed, 0x2000 },

-  { 0x1a00, 0x25ec, 0x0000 },

-  { 0x1a00, 0x25ee, 0x0000 },

-  { 0x9a00, 0x25f1, 0x2000 },

-  { 0x1a00, 0x25f0, 0x0000 },

-  { 0x1a00, 0x25f2, 0x0000 },

-  { 0x9a00, 0x25f7, 0x3000 },

-  { 0x9a00, 0x25f5, 0x2000 },

-  { 0x1a00, 0x25f4, 0x0000 },

-  { 0x1a00, 0x25f6, 0x0000 },

-  { 0x9900, 0x25f9, 0x2000 },

-  { 0x1900, 0x25f8, 0x0000 },

-  { 0x1900, 0x25fa, 0x0000 },

-  { 0x9a00, 0x2603, 0x4000 },

-  { 0x9900, 0x25ff, 0x3000 },

-  { 0x9900, 0x25fd, 0x2000 },

-  { 0x1900, 0x25fc, 0x0000 },

-  { 0x1900, 0x25fe, 0x0000 },

-  { 0x9a00, 0x2601, 0x2000 },

-  { 0x1a00, 0x2600, 0x0000 },

-  { 0x1a00, 0x2602, 0x0000 },

-  { 0x9a00, 0x2607, 0x3000 },

-  { 0x9a00, 0x2605, 0x2000 },

-  { 0x1a00, 0x2604, 0x0000 },

-  { 0x1a00, 0x2606, 0x0000 },

-  { 0x9a00, 0x2609, 0x2000 },

-  { 0x1a00, 0x2608, 0x0000 },

-  { 0x1a00, 0x260a, 0x0000 },

-  { 0x9a00, 0x268e, 0x8000 },

-  { 0x9a00, 0x264c, 0x7000 },

-  { 0x9a00, 0x262c, 0x6000 },

-  { 0x9a00, 0x261c, 0x5000 },

-  { 0x9a00, 0x2613, 0x4000 },

-  { 0x9a00, 0x260f, 0x3000 },

-  { 0x9a00, 0x260d, 0x2000 },

-  { 0x1a00, 0x260c, 0x0000 },

-  { 0x1a00, 0x260e, 0x0000 },

-  { 0x9a00, 0x2611, 0x2000 },

-  { 0x1a00, 0x2610, 0x0000 },

-  { 0x1a00, 0x2612, 0x0000 },

-  { 0x9a00, 0x2617, 0x3000 },

-  { 0x9a00, 0x2615, 0x2000 },

-  { 0x1a00, 0x2614, 0x0000 },

-  { 0x1a00, 0x2616, 0x0000 },

-  { 0x9a00, 0x261a, 0x2000 },

-  { 0x1a00, 0x2619, 0x0000 },

-  { 0x1a00, 0x261b, 0x0000 },

-  { 0x9a00, 0x2624, 0x4000 },

-  { 0x9a00, 0x2620, 0x3000 },

-  { 0x9a00, 0x261e, 0x2000 },

-  { 0x1a00, 0x261d, 0x0000 },

-  { 0x1a00, 0x261f, 0x0000 },

-  { 0x9a00, 0x2622, 0x2000 },

-  { 0x1a00, 0x2621, 0x0000 },

-  { 0x1a00, 0x2623, 0x0000 },

-  { 0x9a00, 0x2628, 0x3000 },

-  { 0x9a00, 0x2626, 0x2000 },

-  { 0x1a00, 0x2625, 0x0000 },

-  { 0x1a00, 0x2627, 0x0000 },

-  { 0x9a00, 0x262a, 0x2000 },

-  { 0x1a00, 0x2629, 0x0000 },

-  { 0x1a00, 0x262b, 0x0000 },

-  { 0x9a00, 0x263c, 0x5000 },

-  { 0x9a00, 0x2634, 0x4000 },

-  { 0x9a00, 0x2630, 0x3000 },

-  { 0x9a00, 0x262e, 0x2000 },

-  { 0x1a00, 0x262d, 0x0000 },

-  { 0x1a00, 0x262f, 0x0000 },

-  { 0x9a00, 0x2632, 0x2000 },

-  { 0x1a00, 0x2631, 0x0000 },

-  { 0x1a00, 0x2633, 0x0000 },

-  { 0x9a00, 0x2638, 0x3000 },

-  { 0x9a00, 0x2636, 0x2000 },

-  { 0x1a00, 0x2635, 0x0000 },

-  { 0x1a00, 0x2637, 0x0000 },

-  { 0x9a00, 0x263a, 0x2000 },

-  { 0x1a00, 0x2639, 0x0000 },

-  { 0x1a00, 0x263b, 0x0000 },

-  { 0x9a00, 0x2644, 0x4000 },

-  { 0x9a00, 0x2640, 0x3000 },

-  { 0x9a00, 0x263e, 0x2000 },

-  { 0x1a00, 0x263d, 0x0000 },

-  { 0x1a00, 0x263f, 0x0000 },

-  { 0x9a00, 0x2642, 0x2000 },

-  { 0x1a00, 0x2641, 0x0000 },

-  { 0x1a00, 0x2643, 0x0000 },

-  { 0x9a00, 0x2648, 0x3000 },

-  { 0x9a00, 0x2646, 0x2000 },

-  { 0x1a00, 0x2645, 0x0000 },

-  { 0x1a00, 0x2647, 0x0000 },

-  { 0x9a00, 0x264a, 0x2000 },

-  { 0x1a00, 0x2649, 0x0000 },

-  { 0x1a00, 0x264b, 0x0000 },

-  { 0x9a00, 0x266c, 0x6000 },

-  { 0x9a00, 0x265c, 0x5000 },

-  { 0x9a00, 0x2654, 0x4000 },

-  { 0x9a00, 0x2650, 0x3000 },

-  { 0x9a00, 0x264e, 0x2000 },

-  { 0x1a00, 0x264d, 0x0000 },

-  { 0x1a00, 0x264f, 0x0000 },

-  { 0x9a00, 0x2652, 0x2000 },

-  { 0x1a00, 0x2651, 0x0000 },

-  { 0x1a00, 0x2653, 0x0000 },

-  { 0x9a00, 0x2658, 0x3000 },

-  { 0x9a00, 0x2656, 0x2000 },

-  { 0x1a00, 0x2655, 0x0000 },

-  { 0x1a00, 0x2657, 0x0000 },

-  { 0x9a00, 0x265a, 0x2000 },

-  { 0x1a00, 0x2659, 0x0000 },

-  { 0x1a00, 0x265b, 0x0000 },

-  { 0x9a00, 0x2664, 0x4000 },

-  { 0x9a00, 0x2660, 0x3000 },

-  { 0x9a00, 0x265e, 0x2000 },

-  { 0x1a00, 0x265d, 0x0000 },

-  { 0x1a00, 0x265f, 0x0000 },

-  { 0x9a00, 0x2662, 0x2000 },

-  { 0x1a00, 0x2661, 0x0000 },

-  { 0x1a00, 0x2663, 0x0000 },

-  { 0x9a00, 0x2668, 0x3000 },

-  { 0x9a00, 0x2666, 0x2000 },

-  { 0x1a00, 0x2665, 0x0000 },

-  { 0x1a00, 0x2667, 0x0000 },

-  { 0x9a00, 0x266a, 0x2000 },

-  { 0x1a00, 0x2669, 0x0000 },

-  { 0x1a00, 0x266b, 0x0000 },

-  { 0x9a00, 0x267c, 0x5000 },

-  { 0x9a00, 0x2674, 0x4000 },

-  { 0x9a00, 0x2670, 0x3000 },

-  { 0x9a00, 0x266e, 0x2000 },

-  { 0x1a00, 0x266d, 0x0000 },

-  { 0x1900, 0x266f, 0x0000 },

-  { 0x9a00, 0x2672, 0x2000 },

-  { 0x1a00, 0x2671, 0x0000 },

-  { 0x1a00, 0x2673, 0x0000 },

-  { 0x9a00, 0x2678, 0x3000 },

-  { 0x9a00, 0x2676, 0x2000 },

-  { 0x1a00, 0x2675, 0x0000 },

-  { 0x1a00, 0x2677, 0x0000 },

-  { 0x9a00, 0x267a, 0x2000 },

-  { 0x1a00, 0x2679, 0x0000 },

-  { 0x1a00, 0x267b, 0x0000 },

-  { 0x9a00, 0x2686, 0x4000 },

-  { 0x9a00, 0x2682, 0x3000 },

-  { 0x9a00, 0x2680, 0x2000 },

-  { 0x1a00, 0x267d, 0x0000 },

-  { 0x1a00, 0x2681, 0x0000 },

-  { 0x9a00, 0x2684, 0x2000 },

-  { 0x1a00, 0x2683, 0x0000 },

-  { 0x1a00, 0x2685, 0x0000 },

-  { 0x9a00, 0x268a, 0x3000 },

-  { 0x9a00, 0x2688, 0x2000 },

-  { 0x1a00, 0x2687, 0x0000 },

-  { 0x1a00, 0x2689, 0x0000 },

-  { 0x9a00, 0x268c, 0x2000 },

-  { 0x1a00, 0x268b, 0x0000 },

-  { 0x1a00, 0x268d, 0x0000 },

-  { 0x9a00, 0x273f, 0x7000 },

-  { 0x9a00, 0x271e, 0x6000 },

-  { 0x9a00, 0x270e, 0x5000 },

-  { 0x9a00, 0x2703, 0x4000 },

-  { 0x9a00, 0x26a0, 0x3000 },

-  { 0x9a00, 0x2690, 0x2000 },

-  { 0x1a00, 0x268f, 0x0000 },

-  { 0x1a00, 0x2691, 0x0000 },

-  { 0x9a00, 0x2701, 0x2000 },

-  { 0x1a00, 0x26a1, 0x0000 },

-  { 0x1a00, 0x2702, 0x0000 },

-  { 0x9a00, 0x2708, 0x3000 },

-  { 0x9a00, 0x2706, 0x2000 },

-  { 0x1a00, 0x2704, 0x0000 },

-  { 0x1a00, 0x2707, 0x0000 },

-  { 0x9a00, 0x270c, 0x2000 },

-  { 0x1a00, 0x2709, 0x0000 },

-  { 0x1a00, 0x270d, 0x0000 },

-  { 0x9a00, 0x2716, 0x4000 },

-  { 0x9a00, 0x2712, 0x3000 },

-  { 0x9a00, 0x2710, 0x2000 },

-  { 0x1a00, 0x270f, 0x0000 },

-  { 0x1a00, 0x2711, 0x0000 },

-  { 0x9a00, 0x2714, 0x2000 },

-  { 0x1a00, 0x2713, 0x0000 },

-  { 0x1a00, 0x2715, 0x0000 },

-  { 0x9a00, 0x271a, 0x3000 },

-  { 0x9a00, 0x2718, 0x2000 },

-  { 0x1a00, 0x2717, 0x0000 },

-  { 0x1a00, 0x2719, 0x0000 },

-  { 0x9a00, 0x271c, 0x2000 },

-  { 0x1a00, 0x271b, 0x0000 },

-  { 0x1a00, 0x271d, 0x0000 },

-  { 0x9a00, 0x272f, 0x5000 },

-  { 0x9a00, 0x2726, 0x4000 },

-  { 0x9a00, 0x2722, 0x3000 },

-  { 0x9a00, 0x2720, 0x2000 },

-  { 0x1a00, 0x271f, 0x0000 },

-  { 0x1a00, 0x2721, 0x0000 },

-  { 0x9a00, 0x2724, 0x2000 },

-  { 0x1a00, 0x2723, 0x0000 },

-  { 0x1a00, 0x2725, 0x0000 },

-  { 0x9a00, 0x272b, 0x3000 },

-  { 0x9a00, 0x2729, 0x2000 },

-  { 0x1a00, 0x2727, 0x0000 },

-  { 0x1a00, 0x272a, 0x0000 },

-  { 0x9a00, 0x272d, 0x2000 },

-  { 0x1a00, 0x272c, 0x0000 },

-  { 0x1a00, 0x272e, 0x0000 },

-  { 0x9a00, 0x2737, 0x4000 },

-  { 0x9a00, 0x2733, 0x3000 },

-  { 0x9a00, 0x2731, 0x2000 },

-  { 0x1a00, 0x2730, 0x0000 },

-  { 0x1a00, 0x2732, 0x0000 },

-  { 0x9a00, 0x2735, 0x2000 },

-  { 0x1a00, 0x2734, 0x0000 },

-  { 0x1a00, 0x2736, 0x0000 },

-  { 0x9a00, 0x273b, 0x3000 },

-  { 0x9a00, 0x2739, 0x2000 },

-  { 0x1a00, 0x2738, 0x0000 },

-  { 0x1a00, 0x273a, 0x0000 },

-  { 0x9a00, 0x273d, 0x2000 },

-  { 0x1a00, 0x273c, 0x0000 },

-  { 0x1a00, 0x273e, 0x0000 },

-  { 0x9a00, 0x2767, 0x6000 },

-  { 0x9a00, 0x2751, 0x5000 },

-  { 0x9a00, 0x2747, 0x4000 },

-  { 0x9a00, 0x2743, 0x3000 },

-  { 0x9a00, 0x2741, 0x2000 },

-  { 0x1a00, 0x2740, 0x0000 },

-  { 0x1a00, 0x2742, 0x0000 },

-  { 0x9a00, 0x2745, 0x2000 },

-  { 0x1a00, 0x2744, 0x0000 },

-  { 0x1a00, 0x2746, 0x0000 },

-  { 0x9a00, 0x274b, 0x3000 },

-  { 0x9a00, 0x2749, 0x2000 },

-  { 0x1a00, 0x2748, 0x0000 },

-  { 0x1a00, 0x274a, 0x0000 },

-  { 0x9a00, 0x274f, 0x2000 },

-  { 0x1a00, 0x274d, 0x0000 },

-  { 0x1a00, 0x2750, 0x0000 },

-  { 0x9a00, 0x275d, 0x4000 },

-  { 0x9a00, 0x2759, 0x3000 },

-  { 0x9a00, 0x2756, 0x2000 },

-  { 0x1a00, 0x2752, 0x0000 },

-  { 0x1a00, 0x2758, 0x0000 },

-  { 0x9a00, 0x275b, 0x2000 },

-  { 0x1a00, 0x275a, 0x0000 },

-  { 0x1a00, 0x275c, 0x0000 },

-  { 0x9a00, 0x2763, 0x3000 },

-  { 0x9a00, 0x2761, 0x2000 },

-  { 0x1a00, 0x275e, 0x0000 },

-  { 0x1a00, 0x2762, 0x0000 },

-  { 0x9a00, 0x2765, 0x2000 },

-  { 0x1a00, 0x2764, 0x0000 },

-  { 0x1a00, 0x2766, 0x0000 },

-  { 0x8f00, 0x2777, 0x5000 },

-  { 0x9200, 0x276f, 0x4000 },

-  { 0x9200, 0x276b, 0x3000 },

-  { 0x9200, 0x2769, 0x2000 },

-  { 0x1600, 0x2768, 0x0000 },

-  { 0x1600, 0x276a, 0x0000 },

-  { 0x9200, 0x276d, 0x2000 },

-  { 0x1600, 0x276c, 0x0000 },

-  { 0x1600, 0x276e, 0x0000 },

-  { 0x9200, 0x2773, 0x3000 },

-  { 0x9200, 0x2771, 0x2000 },

-  { 0x1600, 0x2770, 0x0000 },

-  { 0x1600, 0x2772, 0x0000 },

-  { 0x9200, 0x2775, 0x2000 },

-  { 0x1600, 0x2774, 0x0000 },

-  { 0x0f00, 0x2776, 0x0000 },

-  { 0x8f00, 0x277f, 0x4000 },

-  { 0x8f00, 0x277b, 0x3000 },

-  { 0x8f00, 0x2779, 0x2000 },

-  { 0x0f00, 0x2778, 0x0000 },

-  { 0x0f00, 0x277a, 0x0000 },

-  { 0x8f00, 0x277d, 0x2000 },

-  { 0x0f00, 0x277c, 0x0000 },

-  { 0x0f00, 0x277e, 0x0000 },

-  { 0x8f00, 0x2783, 0x3000 },

-  { 0x8f00, 0x2781, 0x2000 },

-  { 0x0f00, 0x2780, 0x0000 },

-  { 0x0f00, 0x2782, 0x0000 },

-  { 0x8f00, 0x2785, 0x2000 },

-  { 0x0f00, 0x2784, 0x0000 },

-  { 0x0f00, 0x2786, 0x0000 },

-  { 0x9900, 0x29a0, 0xa000 },

-  { 0x9a00, 0x28a0, 0x9000 },

-  { 0x9a00, 0x2820, 0x8000 },

-  { 0x9900, 0x27dc, 0x7000 },

-  { 0x9a00, 0x27aa, 0x6000 },

-  { 0x9a00, 0x279a, 0x5000 },

-  { 0x8f00, 0x278f, 0x4000 },

-  { 0x8f00, 0x278b, 0x3000 },

-  { 0x8f00, 0x2789, 0x2000 },

-  { 0x0f00, 0x2788, 0x0000 },

-  { 0x0f00, 0x278a, 0x0000 },

-  { 0x8f00, 0x278d, 0x2000 },

-  { 0x0f00, 0x278c, 0x0000 },

-  { 0x0f00, 0x278e, 0x0000 },

-  { 0x8f00, 0x2793, 0x3000 },

-  { 0x8f00, 0x2791, 0x2000 },

-  { 0x0f00, 0x2790, 0x0000 },

-  { 0x0f00, 0x2792, 0x0000 },

-  { 0x9a00, 0x2798, 0x2000 },

-  { 0x1a00, 0x2794, 0x0000 },

-  { 0x1a00, 0x2799, 0x0000 },

-  { 0x9a00, 0x27a2, 0x4000 },

-  { 0x9a00, 0x279e, 0x3000 },

-  { 0x9a00, 0x279c, 0x2000 },

-  { 0x1a00, 0x279b, 0x0000 },

-  { 0x1a00, 0x279d, 0x0000 },

-  { 0x9a00, 0x27a0, 0x2000 },

-  { 0x1a00, 0x279f, 0x0000 },

-  { 0x1a00, 0x27a1, 0x0000 },

-  { 0x9a00, 0x27a6, 0x3000 },

-  { 0x9a00, 0x27a4, 0x2000 },

-  { 0x1a00, 0x27a3, 0x0000 },

-  { 0x1a00, 0x27a5, 0x0000 },

-  { 0x9a00, 0x27a8, 0x2000 },

-  { 0x1a00, 0x27a7, 0x0000 },

-  { 0x1a00, 0x27a9, 0x0000 },

-  { 0x9a00, 0x27bb, 0x5000 },

-  { 0x9a00, 0x27b3, 0x4000 },

-  { 0x9a00, 0x27ae, 0x3000 },

-  { 0x9a00, 0x27ac, 0x2000 },

-  { 0x1a00, 0x27ab, 0x0000 },

-  { 0x1a00, 0x27ad, 0x0000 },

-  { 0x9a00, 0x27b1, 0x2000 },

-  { 0x1a00, 0x27af, 0x0000 },

-  { 0x1a00, 0x27b2, 0x0000 },

-  { 0x9a00, 0x27b7, 0x3000 },

-  { 0x9a00, 0x27b5, 0x2000 },

-  { 0x1a00, 0x27b4, 0x0000 },

-  { 0x1a00, 0x27b6, 0x0000 },

-  { 0x9a00, 0x27b9, 0x2000 },

-  { 0x1a00, 0x27b8, 0x0000 },

-  { 0x1a00, 0x27ba, 0x0000 },

-  { 0x9900, 0x27d4, 0x4000 },

-  { 0x9900, 0x27d0, 0x3000 },

-  { 0x9a00, 0x27bd, 0x2000 },

-  { 0x1a00, 0x27bc, 0x0000 },

-  { 0x1a00, 0x27be, 0x0000 },

-  { 0x9900, 0x27d2, 0x2000 },

-  { 0x1900, 0x27d1, 0x0000 },

-  { 0x1900, 0x27d3, 0x0000 },

-  { 0x9900, 0x27d8, 0x3000 },

-  { 0x9900, 0x27d6, 0x2000 },

-  { 0x1900, 0x27d5, 0x0000 },

-  { 0x1900, 0x27d7, 0x0000 },

-  { 0x9900, 0x27da, 0x2000 },

-  { 0x1900, 0x27d9, 0x0000 },

-  { 0x1900, 0x27db, 0x0000 },

-  { 0x9a00, 0x2800, 0x6000 },

-  { 0x9900, 0x27f0, 0x5000 },

-  { 0x9900, 0x27e4, 0x4000 },

-  { 0x9900, 0x27e0, 0x3000 },

-  { 0x9900, 0x27de, 0x2000 },

-  { 0x1900, 0x27dd, 0x0000 },

-  { 0x1900, 0x27df, 0x0000 },

-  { 0x9900, 0x27e2, 0x2000 },

-  { 0x1900, 0x27e1, 0x0000 },

-  { 0x1900, 0x27e3, 0x0000 },

-  { 0x9600, 0x27e8, 0x3000 },

-  { 0x9600, 0x27e6, 0x2000 },

-  { 0x1900, 0x27e5, 0x0000 },

-  { 0x1200, 0x27e7, 0x0000 },

-  { 0x9600, 0x27ea, 0x2000 },

-  { 0x1200, 0x27e9, 0x0000 },

-  { 0x1200, 0x27eb, 0x0000 },

-  { 0x9900, 0x27f8, 0x4000 },

-  { 0x9900, 0x27f4, 0x3000 },

-  { 0x9900, 0x27f2, 0x2000 },

-  { 0x1900, 0x27f1, 0x0000 },

-  { 0x1900, 0x27f3, 0x0000 },

-  { 0x9900, 0x27f6, 0x2000 },

-  { 0x1900, 0x27f5, 0x0000 },

-  { 0x1900, 0x27f7, 0x0000 },

-  { 0x9900, 0x27fc, 0x3000 },

-  { 0x9900, 0x27fa, 0x2000 },

-  { 0x1900, 0x27f9, 0x0000 },

-  { 0x1900, 0x27fb, 0x0000 },

-  { 0x9900, 0x27fe, 0x2000 },

-  { 0x1900, 0x27fd, 0x0000 },

-  { 0x1900, 0x27ff, 0x0000 },

-  { 0x9a00, 0x2810, 0x5000 },

-  { 0x9a00, 0x2808, 0x4000 },

-  { 0x9a00, 0x2804, 0x3000 },

-  { 0x9a00, 0x2802, 0x2000 },

-  { 0x1a00, 0x2801, 0x0000 },

-  { 0x1a00, 0x2803, 0x0000 },

-  { 0x9a00, 0x2806, 0x2000 },

-  { 0x1a00, 0x2805, 0x0000 },

-  { 0x1a00, 0x2807, 0x0000 },

-  { 0x9a00, 0x280c, 0x3000 },

-  { 0x9a00, 0x280a, 0x2000 },

-  { 0x1a00, 0x2809, 0x0000 },

-  { 0x1a00, 0x280b, 0x0000 },

-  { 0x9a00, 0x280e, 0x2000 },

-  { 0x1a00, 0x280d, 0x0000 },

-  { 0x1a00, 0x280f, 0x0000 },

-  { 0x9a00, 0x2818, 0x4000 },

-  { 0x9a00, 0x2814, 0x3000 },

-  { 0x9a00, 0x2812, 0x2000 },

-  { 0x1a00, 0x2811, 0x0000 },

-  { 0x1a00, 0x2813, 0x0000 },

-  { 0x9a00, 0x2816, 0x2000 },

-  { 0x1a00, 0x2815, 0x0000 },

-  { 0x1a00, 0x2817, 0x0000 },

-  { 0x9a00, 0x281c, 0x3000 },

-  { 0x9a00, 0x281a, 0x2000 },

-  { 0x1a00, 0x2819, 0x0000 },

-  { 0x1a00, 0x281b, 0x0000 },

-  { 0x9a00, 0x281e, 0x2000 },

-  { 0x1a00, 0x281d, 0x0000 },

-  { 0x1a00, 0x281f, 0x0000 },

-  { 0x9a00, 0x2860, 0x7000 },

-  { 0x9a00, 0x2840, 0x6000 },

-  { 0x9a00, 0x2830, 0x5000 },

-  { 0x9a00, 0x2828, 0x4000 },

-  { 0x9a00, 0x2824, 0x3000 },

-  { 0x9a00, 0x2822, 0x2000 },

-  { 0x1a00, 0x2821, 0x0000 },

-  { 0x1a00, 0x2823, 0x0000 },

-  { 0x9a00, 0x2826, 0x2000 },

-  { 0x1a00, 0x2825, 0x0000 },

-  { 0x1a00, 0x2827, 0x0000 },

-  { 0x9a00, 0x282c, 0x3000 },

-  { 0x9a00, 0x282a, 0x2000 },

-  { 0x1a00, 0x2829, 0x0000 },

-  { 0x1a00, 0x282b, 0x0000 },

-  { 0x9a00, 0x282e, 0x2000 },

-  { 0x1a00, 0x282d, 0x0000 },

-  { 0x1a00, 0x282f, 0x0000 },

-  { 0x9a00, 0x2838, 0x4000 },

-  { 0x9a00, 0x2834, 0x3000 },

-  { 0x9a00, 0x2832, 0x2000 },

-  { 0x1a00, 0x2831, 0x0000 },

-  { 0x1a00, 0x2833, 0x0000 },

-  { 0x9a00, 0x2836, 0x2000 },

-  { 0x1a00, 0x2835, 0x0000 },

-  { 0x1a00, 0x2837, 0x0000 },

-  { 0x9a00, 0x283c, 0x3000 },

-  { 0x9a00, 0x283a, 0x2000 },

-  { 0x1a00, 0x2839, 0x0000 },

-  { 0x1a00, 0x283b, 0x0000 },

-  { 0x9a00, 0x283e, 0x2000 },

-  { 0x1a00, 0x283d, 0x0000 },

-  { 0x1a00, 0x283f, 0x0000 },

-  { 0x9a00, 0x2850, 0x5000 },

-  { 0x9a00, 0x2848, 0x4000 },

-  { 0x9a00, 0x2844, 0x3000 },

-  { 0x9a00, 0x2842, 0x2000 },

-  { 0x1a00, 0x2841, 0x0000 },

-  { 0x1a00, 0x2843, 0x0000 },

-  { 0x9a00, 0x2846, 0x2000 },

-  { 0x1a00, 0x2845, 0x0000 },

-  { 0x1a00, 0x2847, 0x0000 },

-  { 0x9a00, 0x284c, 0x3000 },

-  { 0x9a00, 0x284a, 0x2000 },

-  { 0x1a00, 0x2849, 0x0000 },

-  { 0x1a00, 0x284b, 0x0000 },

-  { 0x9a00, 0x284e, 0x2000 },

-  { 0x1a00, 0x284d, 0x0000 },

-  { 0x1a00, 0x284f, 0x0000 },

-  { 0x9a00, 0x2858, 0x4000 },

-  { 0x9a00, 0x2854, 0x3000 },

-  { 0x9a00, 0x2852, 0x2000 },

-  { 0x1a00, 0x2851, 0x0000 },

-  { 0x1a00, 0x2853, 0x0000 },

-  { 0x9a00, 0x2856, 0x2000 },

-  { 0x1a00, 0x2855, 0x0000 },

-  { 0x1a00, 0x2857, 0x0000 },

-  { 0x9a00, 0x285c, 0x3000 },

-  { 0x9a00, 0x285a, 0x2000 },

-  { 0x1a00, 0x2859, 0x0000 },

-  { 0x1a00, 0x285b, 0x0000 },

-  { 0x9a00, 0x285e, 0x2000 },

-  { 0x1a00, 0x285d, 0x0000 },

-  { 0x1a00, 0x285f, 0x0000 },

-  { 0x9a00, 0x2880, 0x6000 },

-  { 0x9a00, 0x2870, 0x5000 },

-  { 0x9a00, 0x2868, 0x4000 },

-  { 0x9a00, 0x2864, 0x3000 },

-  { 0x9a00, 0x2862, 0x2000 },

-  { 0x1a00, 0x2861, 0x0000 },

-  { 0x1a00, 0x2863, 0x0000 },

-  { 0x9a00, 0x2866, 0x2000 },

-  { 0x1a00, 0x2865, 0x0000 },

-  { 0x1a00, 0x2867, 0x0000 },

-  { 0x9a00, 0x286c, 0x3000 },

-  { 0x9a00, 0x286a, 0x2000 },

-  { 0x1a00, 0x2869, 0x0000 },

-  { 0x1a00, 0x286b, 0x0000 },

-  { 0x9a00, 0x286e, 0x2000 },

-  { 0x1a00, 0x286d, 0x0000 },

-  { 0x1a00, 0x286f, 0x0000 },

-  { 0x9a00, 0x2878, 0x4000 },

-  { 0x9a00, 0x2874, 0x3000 },

-  { 0x9a00, 0x2872, 0x2000 },

-  { 0x1a00, 0x2871, 0x0000 },

-  { 0x1a00, 0x2873, 0x0000 },

-  { 0x9a00, 0x2876, 0x2000 },

-  { 0x1a00, 0x2875, 0x0000 },

-  { 0x1a00, 0x2877, 0x0000 },

-  { 0x9a00, 0x287c, 0x3000 },

-  { 0x9a00, 0x287a, 0x2000 },

-  { 0x1a00, 0x2879, 0x0000 },

-  { 0x1a00, 0x287b, 0x0000 },

-  { 0x9a00, 0x287e, 0x2000 },

-  { 0x1a00, 0x287d, 0x0000 },

-  { 0x1a00, 0x287f, 0x0000 },

-  { 0x9a00, 0x2890, 0x5000 },

-  { 0x9a00, 0x2888, 0x4000 },

-  { 0x9a00, 0x2884, 0x3000 },

-  { 0x9a00, 0x2882, 0x2000 },

-  { 0x1a00, 0x2881, 0x0000 },

-  { 0x1a00, 0x2883, 0x0000 },

-  { 0x9a00, 0x2886, 0x2000 },

-  { 0x1a00, 0x2885, 0x0000 },

-  { 0x1a00, 0x2887, 0x0000 },

-  { 0x9a00, 0x288c, 0x3000 },

-  { 0x9a00, 0x288a, 0x2000 },

-  { 0x1a00, 0x2889, 0x0000 },

-  { 0x1a00, 0x288b, 0x0000 },

-  { 0x9a00, 0x288e, 0x2000 },

-  { 0x1a00, 0x288d, 0x0000 },

-  { 0x1a00, 0x288f, 0x0000 },

-  { 0x9a00, 0x2898, 0x4000 },

-  { 0x9a00, 0x2894, 0x3000 },

-  { 0x9a00, 0x2892, 0x2000 },

-  { 0x1a00, 0x2891, 0x0000 },

-  { 0x1a00, 0x2893, 0x0000 },

-  { 0x9a00, 0x2896, 0x2000 },

-  { 0x1a00, 0x2895, 0x0000 },

-  { 0x1a00, 0x2897, 0x0000 },

-  { 0x9a00, 0x289c, 0x3000 },

-  { 0x9a00, 0x289a, 0x2000 },

-  { 0x1a00, 0x2899, 0x0000 },

-  { 0x1a00, 0x289b, 0x0000 },

-  { 0x9a00, 0x289e, 0x2000 },

-  { 0x1a00, 0x289d, 0x0000 },

-  { 0x1a00, 0x289f, 0x0000 },

-  { 0x9900, 0x2920, 0x8000 },

-  { 0x9a00, 0x28e0, 0x7000 },

-  { 0x9a00, 0x28c0, 0x6000 },

-  { 0x9a00, 0x28b0, 0x5000 },

-  { 0x9a00, 0x28a8, 0x4000 },

-  { 0x9a00, 0x28a4, 0x3000 },

-  { 0x9a00, 0x28a2, 0x2000 },

-  { 0x1a00, 0x28a1, 0x0000 },

-  { 0x1a00, 0x28a3, 0x0000 },

-  { 0x9a00, 0x28a6, 0x2000 },

-  { 0x1a00, 0x28a5, 0x0000 },

-  { 0x1a00, 0x28a7, 0x0000 },

-  { 0x9a00, 0x28ac, 0x3000 },

-  { 0x9a00, 0x28aa, 0x2000 },

-  { 0x1a00, 0x28a9, 0x0000 },

-  { 0x1a00, 0x28ab, 0x0000 },

-  { 0x9a00, 0x28ae, 0x2000 },

-  { 0x1a00, 0x28ad, 0x0000 },

-  { 0x1a00, 0x28af, 0x0000 },

-  { 0x9a00, 0x28b8, 0x4000 },

-  { 0x9a00, 0x28b4, 0x3000 },

-  { 0x9a00, 0x28b2, 0x2000 },

-  { 0x1a00, 0x28b1, 0x0000 },

-  { 0x1a00, 0x28b3, 0x0000 },

-  { 0x9a00, 0x28b6, 0x2000 },

-  { 0x1a00, 0x28b5, 0x0000 },

-  { 0x1a00, 0x28b7, 0x0000 },

-  { 0x9a00, 0x28bc, 0x3000 },

-  { 0x9a00, 0x28ba, 0x2000 },

-  { 0x1a00, 0x28b9, 0x0000 },

-  { 0x1a00, 0x28bb, 0x0000 },

-  { 0x9a00, 0x28be, 0x2000 },

-  { 0x1a00, 0x28bd, 0x0000 },

-  { 0x1a00, 0x28bf, 0x0000 },

-  { 0x9a00, 0x28d0, 0x5000 },

-  { 0x9a00, 0x28c8, 0x4000 },

-  { 0x9a00, 0x28c4, 0x3000 },

-  { 0x9a00, 0x28c2, 0x2000 },

-  { 0x1a00, 0x28c1, 0x0000 },

-  { 0x1a00, 0x28c3, 0x0000 },

-  { 0x9a00, 0x28c6, 0x2000 },

-  { 0x1a00, 0x28c5, 0x0000 },

-  { 0x1a00, 0x28c7, 0x0000 },

-  { 0x9a00, 0x28cc, 0x3000 },

-  { 0x9a00, 0x28ca, 0x2000 },

-  { 0x1a00, 0x28c9, 0x0000 },

-  { 0x1a00, 0x28cb, 0x0000 },

-  { 0x9a00, 0x28ce, 0x2000 },

-  { 0x1a00, 0x28cd, 0x0000 },

-  { 0x1a00, 0x28cf, 0x0000 },

-  { 0x9a00, 0x28d8, 0x4000 },

-  { 0x9a00, 0x28d4, 0x3000 },

-  { 0x9a00, 0x28d2, 0x2000 },

-  { 0x1a00, 0x28d1, 0x0000 },

-  { 0x1a00, 0x28d3, 0x0000 },

-  { 0x9a00, 0x28d6, 0x2000 },

-  { 0x1a00, 0x28d5, 0x0000 },

-  { 0x1a00, 0x28d7, 0x0000 },

-  { 0x9a00, 0x28dc, 0x3000 },

-  { 0x9a00, 0x28da, 0x2000 },

-  { 0x1a00, 0x28d9, 0x0000 },

-  { 0x1a00, 0x28db, 0x0000 },

-  { 0x9a00, 0x28de, 0x2000 },

-  { 0x1a00, 0x28dd, 0x0000 },

-  { 0x1a00, 0x28df, 0x0000 },

-  { 0x9900, 0x2900, 0x6000 },

-  { 0x9a00, 0x28f0, 0x5000 },

-  { 0x9a00, 0x28e8, 0x4000 },

-  { 0x9a00, 0x28e4, 0x3000 },

-  { 0x9a00, 0x28e2, 0x2000 },

-  { 0x1a00, 0x28e1, 0x0000 },

-  { 0x1a00, 0x28e3, 0x0000 },

-  { 0x9a00, 0x28e6, 0x2000 },

-  { 0x1a00, 0x28e5, 0x0000 },

-  { 0x1a00, 0x28e7, 0x0000 },

-  { 0x9a00, 0x28ec, 0x3000 },

-  { 0x9a00, 0x28ea, 0x2000 },

-  { 0x1a00, 0x28e9, 0x0000 },

-  { 0x1a00, 0x28eb, 0x0000 },

-  { 0x9a00, 0x28ee, 0x2000 },

-  { 0x1a00, 0x28ed, 0x0000 },

-  { 0x1a00, 0x28ef, 0x0000 },

-  { 0x9a00, 0x28f8, 0x4000 },

-  { 0x9a00, 0x28f4, 0x3000 },

-  { 0x9a00, 0x28f2, 0x2000 },

-  { 0x1a00, 0x28f1, 0x0000 },

-  { 0x1a00, 0x28f3, 0x0000 },

-  { 0x9a00, 0x28f6, 0x2000 },

-  { 0x1a00, 0x28f5, 0x0000 },

-  { 0x1a00, 0x28f7, 0x0000 },

-  { 0x9a00, 0x28fc, 0x3000 },

-  { 0x9a00, 0x28fa, 0x2000 },

-  { 0x1a00, 0x28f9, 0x0000 },

-  { 0x1a00, 0x28fb, 0x0000 },

-  { 0x9a00, 0x28fe, 0x2000 },

-  { 0x1a00, 0x28fd, 0x0000 },

-  { 0x1a00, 0x28ff, 0x0000 },

-  { 0x9900, 0x2910, 0x5000 },

-  { 0x9900, 0x2908, 0x4000 },

-  { 0x9900, 0x2904, 0x3000 },

-  { 0x9900, 0x2902, 0x2000 },

-  { 0x1900, 0x2901, 0x0000 },

-  { 0x1900, 0x2903, 0x0000 },

-  { 0x9900, 0x2906, 0x2000 },

-  { 0x1900, 0x2905, 0x0000 },

-  { 0x1900, 0x2907, 0x0000 },

-  { 0x9900, 0x290c, 0x3000 },

-  { 0x9900, 0x290a, 0x2000 },

-  { 0x1900, 0x2909, 0x0000 },

-  { 0x1900, 0x290b, 0x0000 },

-  { 0x9900, 0x290e, 0x2000 },

-  { 0x1900, 0x290d, 0x0000 },

-  { 0x1900, 0x290f, 0x0000 },

-  { 0x9900, 0x2918, 0x4000 },

-  { 0x9900, 0x2914, 0x3000 },

-  { 0x9900, 0x2912, 0x2000 },

-  { 0x1900, 0x2911, 0x0000 },

-  { 0x1900, 0x2913, 0x0000 },

-  { 0x9900, 0x2916, 0x2000 },

-  { 0x1900, 0x2915, 0x0000 },

-  { 0x1900, 0x2917, 0x0000 },

-  { 0x9900, 0x291c, 0x3000 },

-  { 0x9900, 0x291a, 0x2000 },

-  { 0x1900, 0x2919, 0x0000 },

-  { 0x1900, 0x291b, 0x0000 },

-  { 0x9900, 0x291e, 0x2000 },

-  { 0x1900, 0x291d, 0x0000 },

-  { 0x1900, 0x291f, 0x0000 },

-  { 0x9900, 0x2960, 0x7000 },

-  { 0x9900, 0x2940, 0x6000 },

-  { 0x9900, 0x2930, 0x5000 },

-  { 0x9900, 0x2928, 0x4000 },

-  { 0x9900, 0x2924, 0x3000 },

-  { 0x9900, 0x2922, 0x2000 },

-  { 0x1900, 0x2921, 0x0000 },

-  { 0x1900, 0x2923, 0x0000 },

-  { 0x9900, 0x2926, 0x2000 },

-  { 0x1900, 0x2925, 0x0000 },

-  { 0x1900, 0x2927, 0x0000 },

-  { 0x9900, 0x292c, 0x3000 },

-  { 0x9900, 0x292a, 0x2000 },

-  { 0x1900, 0x2929, 0x0000 },

-  { 0x1900, 0x292b, 0x0000 },

-  { 0x9900, 0x292e, 0x2000 },

-  { 0x1900, 0x292d, 0x0000 },

-  { 0x1900, 0x292f, 0x0000 },

-  { 0x9900, 0x2938, 0x4000 },

-  { 0x9900, 0x2934, 0x3000 },

-  { 0x9900, 0x2932, 0x2000 },

-  { 0x1900, 0x2931, 0x0000 },

-  { 0x1900, 0x2933, 0x0000 },

-  { 0x9900, 0x2936, 0x2000 },

-  { 0x1900, 0x2935, 0x0000 },

-  { 0x1900, 0x2937, 0x0000 },

-  { 0x9900, 0x293c, 0x3000 },

-  { 0x9900, 0x293a, 0x2000 },

-  { 0x1900, 0x2939, 0x0000 },

-  { 0x1900, 0x293b, 0x0000 },

-  { 0x9900, 0x293e, 0x2000 },

-  { 0x1900, 0x293d, 0x0000 },

-  { 0x1900, 0x293f, 0x0000 },

-  { 0x9900, 0x2950, 0x5000 },

-  { 0x9900, 0x2948, 0x4000 },

-  { 0x9900, 0x2944, 0x3000 },

-  { 0x9900, 0x2942, 0x2000 },

-  { 0x1900, 0x2941, 0x0000 },

-  { 0x1900, 0x2943, 0x0000 },

-  { 0x9900, 0x2946, 0x2000 },

-  { 0x1900, 0x2945, 0x0000 },

-  { 0x1900, 0x2947, 0x0000 },

-  { 0x9900, 0x294c, 0x3000 },

-  { 0x9900, 0x294a, 0x2000 },

-  { 0x1900, 0x2949, 0x0000 },

-  { 0x1900, 0x294b, 0x0000 },

-  { 0x9900, 0x294e, 0x2000 },

-  { 0x1900, 0x294d, 0x0000 },

-  { 0x1900, 0x294f, 0x0000 },

-  { 0x9900, 0x2958, 0x4000 },

-  { 0x9900, 0x2954, 0x3000 },

-  { 0x9900, 0x2952, 0x2000 },

-  { 0x1900, 0x2951, 0x0000 },

-  { 0x1900, 0x2953, 0x0000 },

-  { 0x9900, 0x2956, 0x2000 },

-  { 0x1900, 0x2955, 0x0000 },

-  { 0x1900, 0x2957, 0x0000 },

-  { 0x9900, 0x295c, 0x3000 },

-  { 0x9900, 0x295a, 0x2000 },

-  { 0x1900, 0x2959, 0x0000 },

-  { 0x1900, 0x295b, 0x0000 },

-  { 0x9900, 0x295e, 0x2000 },

-  { 0x1900, 0x295d, 0x0000 },

-  { 0x1900, 0x295f, 0x0000 },

-  { 0x9900, 0x2980, 0x6000 },

-  { 0x9900, 0x2970, 0x5000 },

-  { 0x9900, 0x2968, 0x4000 },

-  { 0x9900, 0x2964, 0x3000 },

-  { 0x9900, 0x2962, 0x2000 },

-  { 0x1900, 0x2961, 0x0000 },

-  { 0x1900, 0x2963, 0x0000 },

-  { 0x9900, 0x2966, 0x2000 },

-  { 0x1900, 0x2965, 0x0000 },

-  { 0x1900, 0x2967, 0x0000 },

-  { 0x9900, 0x296c, 0x3000 },

-  { 0x9900, 0x296a, 0x2000 },

-  { 0x1900, 0x2969, 0x0000 },

-  { 0x1900, 0x296b, 0x0000 },

-  { 0x9900, 0x296e, 0x2000 },

-  { 0x1900, 0x296d, 0x0000 },

-  { 0x1900, 0x296f, 0x0000 },

-  { 0x9900, 0x2978, 0x4000 },

-  { 0x9900, 0x2974, 0x3000 },

-  { 0x9900, 0x2972, 0x2000 },

-  { 0x1900, 0x2971, 0x0000 },

-  { 0x1900, 0x2973, 0x0000 },

-  { 0x9900, 0x2976, 0x2000 },

-  { 0x1900, 0x2975, 0x0000 },

-  { 0x1900, 0x2977, 0x0000 },

-  { 0x9900, 0x297c, 0x3000 },

-  { 0x9900, 0x297a, 0x2000 },

-  { 0x1900, 0x2979, 0x0000 },

-  { 0x1900, 0x297b, 0x0000 },

-  { 0x9900, 0x297e, 0x2000 },

-  { 0x1900, 0x297d, 0x0000 },

-  { 0x1900, 0x297f, 0x0000 },

-  { 0x9200, 0x2990, 0x5000 },

-  { 0x9200, 0x2988, 0x4000 },

-  { 0x9200, 0x2984, 0x3000 },

-  { 0x9900, 0x2982, 0x2000 },

-  { 0x1900, 0x2981, 0x0000 },

-  { 0x1600, 0x2983, 0x0000 },

-  { 0x9200, 0x2986, 0x2000 },

-  { 0x1600, 0x2985, 0x0000 },

-  { 0x1600, 0x2987, 0x0000 },

-  { 0x9200, 0x298c, 0x3000 },

-  { 0x9200, 0x298a, 0x2000 },

-  { 0x1600, 0x2989, 0x0000 },

-  { 0x1600, 0x298b, 0x0000 },

-  { 0x9200, 0x298e, 0x2000 },

-  { 0x1600, 0x298d, 0x0000 },

-  { 0x1600, 0x298f, 0x0000 },

-  { 0x9200, 0x2998, 0x4000 },

-  { 0x9200, 0x2994, 0x3000 },

-  { 0x9200, 0x2992, 0x2000 },

-  { 0x1600, 0x2991, 0x0000 },

-  { 0x1600, 0x2993, 0x0000 },

-  { 0x9200, 0x2996, 0x2000 },

-  { 0x1600, 0x2995, 0x0000 },

-  { 0x1600, 0x2997, 0x0000 },

-  { 0x9900, 0x299c, 0x3000 },

-  { 0x9900, 0x299a, 0x2000 },

-  { 0x1900, 0x2999, 0x0000 },

-  { 0x1900, 0x299b, 0x0000 },

-  { 0x9900, 0x299e, 0x2000 },

-  { 0x1900, 0x299d, 0x0000 },

-  { 0x1900, 0x299f, 0x0000 },

-  { 0x9900, 0x2aa0, 0x9000 },

-  { 0x9900, 0x2a20, 0x8000 },

-  { 0x9900, 0x29e0, 0x7000 },

-  { 0x9900, 0x29c0, 0x6000 },

-  { 0x9900, 0x29b0, 0x5000 },

-  { 0x9900, 0x29a8, 0x4000 },

-  { 0x9900, 0x29a4, 0x3000 },

-  { 0x9900, 0x29a2, 0x2000 },

-  { 0x1900, 0x29a1, 0x0000 },

-  { 0x1900, 0x29a3, 0x0000 },

-  { 0x9900, 0x29a6, 0x2000 },

-  { 0x1900, 0x29a5, 0x0000 },

-  { 0x1900, 0x29a7, 0x0000 },

-  { 0x9900, 0x29ac, 0x3000 },

-  { 0x9900, 0x29aa, 0x2000 },

-  { 0x1900, 0x29a9, 0x0000 },

-  { 0x1900, 0x29ab, 0x0000 },

-  { 0x9900, 0x29ae, 0x2000 },

-  { 0x1900, 0x29ad, 0x0000 },

-  { 0x1900, 0x29af, 0x0000 },

-  { 0x9900, 0x29b8, 0x4000 },

-  { 0x9900, 0x29b4, 0x3000 },

-  { 0x9900, 0x29b2, 0x2000 },

-  { 0x1900, 0x29b1, 0x0000 },

-  { 0x1900, 0x29b3, 0x0000 },

-  { 0x9900, 0x29b6, 0x2000 },

-  { 0x1900, 0x29b5, 0x0000 },

-  { 0x1900, 0x29b7, 0x0000 },

-  { 0x9900, 0x29bc, 0x3000 },

-  { 0x9900, 0x29ba, 0x2000 },

-  { 0x1900, 0x29b9, 0x0000 },

-  { 0x1900, 0x29bb, 0x0000 },

-  { 0x9900, 0x29be, 0x2000 },

-  { 0x1900, 0x29bd, 0x0000 },

-  { 0x1900, 0x29bf, 0x0000 },

-  { 0x9900, 0x29d0, 0x5000 },

-  { 0x9900, 0x29c8, 0x4000 },

-  { 0x9900, 0x29c4, 0x3000 },

-  { 0x9900, 0x29c2, 0x2000 },

-  { 0x1900, 0x29c1, 0x0000 },

-  { 0x1900, 0x29c3, 0x0000 },

-  { 0x9900, 0x29c6, 0x2000 },

-  { 0x1900, 0x29c5, 0x0000 },

-  { 0x1900, 0x29c7, 0x0000 },

-  { 0x9900, 0x29cc, 0x3000 },

-  { 0x9900, 0x29ca, 0x2000 },

-  { 0x1900, 0x29c9, 0x0000 },

-  { 0x1900, 0x29cb, 0x0000 },

-  { 0x9900, 0x29ce, 0x2000 },

-  { 0x1900, 0x29cd, 0x0000 },

-  { 0x1900, 0x29cf, 0x0000 },

-  { 0x9600, 0x29d8, 0x4000 },

-  { 0x9900, 0x29d4, 0x3000 },

-  { 0x9900, 0x29d2, 0x2000 },

-  { 0x1900, 0x29d1, 0x0000 },

-  { 0x1900, 0x29d3, 0x0000 },

-  { 0x9900, 0x29d6, 0x2000 },

-  { 0x1900, 0x29d5, 0x0000 },

-  { 0x1900, 0x29d7, 0x0000 },

-  { 0x9900, 0x29dc, 0x3000 },

-  { 0x9600, 0x29da, 0x2000 },

-  { 0x1200, 0x29d9, 0x0000 },

-  { 0x1200, 0x29db, 0x0000 },

-  { 0x9900, 0x29de, 0x2000 },

-  { 0x1900, 0x29dd, 0x0000 },

-  { 0x1900, 0x29df, 0x0000 },

-  { 0x9900, 0x2a00, 0x6000 },

-  { 0x9900, 0x29f0, 0x5000 },

-  { 0x9900, 0x29e8, 0x4000 },

-  { 0x9900, 0x29e4, 0x3000 },

-  { 0x9900, 0x29e2, 0x2000 },

-  { 0x1900, 0x29e1, 0x0000 },

-  { 0x1900, 0x29e3, 0x0000 },

-  { 0x9900, 0x29e6, 0x2000 },

-  { 0x1900, 0x29e5, 0x0000 },

-  { 0x1900, 0x29e7, 0x0000 },

-  { 0x9900, 0x29ec, 0x3000 },

-  { 0x9900, 0x29ea, 0x2000 },

-  { 0x1900, 0x29e9, 0x0000 },

-  { 0x1900, 0x29eb, 0x0000 },

-  { 0x9900, 0x29ee, 0x2000 },

-  { 0x1900, 0x29ed, 0x0000 },

-  { 0x1900, 0x29ef, 0x0000 },

-  { 0x9900, 0x29f8, 0x4000 },

-  { 0x9900, 0x29f4, 0x3000 },

-  { 0x9900, 0x29f2, 0x2000 },

-  { 0x1900, 0x29f1, 0x0000 },

-  { 0x1900, 0x29f3, 0x0000 },

-  { 0x9900, 0x29f6, 0x2000 },

-  { 0x1900, 0x29f5, 0x0000 },

-  { 0x1900, 0x29f7, 0x0000 },

-  { 0x9600, 0x29fc, 0x3000 },

-  { 0x9900, 0x29fa, 0x2000 },

-  { 0x1900, 0x29f9, 0x0000 },

-  { 0x1900, 0x29fb, 0x0000 },

-  { 0x9900, 0x29fe, 0x2000 },

-  { 0x1200, 0x29fd, 0x0000 },

-  { 0x1900, 0x29ff, 0x0000 },

-  { 0x9900, 0x2a10, 0x5000 },

-  { 0x9900, 0x2a08, 0x4000 },

-  { 0x9900, 0x2a04, 0x3000 },

-  { 0x9900, 0x2a02, 0x2000 },

-  { 0x1900, 0x2a01, 0x0000 },

-  { 0x1900, 0x2a03, 0x0000 },

-  { 0x9900, 0x2a06, 0x2000 },

-  { 0x1900, 0x2a05, 0x0000 },

-  { 0x1900, 0x2a07, 0x0000 },

-  { 0x9900, 0x2a0c, 0x3000 },

-  { 0x9900, 0x2a0a, 0x2000 },

-  { 0x1900, 0x2a09, 0x0000 },

-  { 0x1900, 0x2a0b, 0x0000 },

-  { 0x9900, 0x2a0e, 0x2000 },

-  { 0x1900, 0x2a0d, 0x0000 },

-  { 0x1900, 0x2a0f, 0x0000 },

-  { 0x9900, 0x2a18, 0x4000 },

-  { 0x9900, 0x2a14, 0x3000 },

-  { 0x9900, 0x2a12, 0x2000 },

-  { 0x1900, 0x2a11, 0x0000 },

-  { 0x1900, 0x2a13, 0x0000 },

-  { 0x9900, 0x2a16, 0x2000 },

-  { 0x1900, 0x2a15, 0x0000 },

-  { 0x1900, 0x2a17, 0x0000 },

-  { 0x9900, 0x2a1c, 0x3000 },

-  { 0x9900, 0x2a1a, 0x2000 },

-  { 0x1900, 0x2a19, 0x0000 },

-  { 0x1900, 0x2a1b, 0x0000 },

-  { 0x9900, 0x2a1e, 0x2000 },

-  { 0x1900, 0x2a1d, 0x0000 },

-  { 0x1900, 0x2a1f, 0x0000 },

-  { 0x9900, 0x2a60, 0x7000 },

-  { 0x9900, 0x2a40, 0x6000 },

-  { 0x9900, 0x2a30, 0x5000 },

-  { 0x9900, 0x2a28, 0x4000 },

-  { 0x9900, 0x2a24, 0x3000 },

-  { 0x9900, 0x2a22, 0x2000 },

-  { 0x1900, 0x2a21, 0x0000 },

-  { 0x1900, 0x2a23, 0x0000 },

-  { 0x9900, 0x2a26, 0x2000 },

-  { 0x1900, 0x2a25, 0x0000 },

-  { 0x1900, 0x2a27, 0x0000 },

-  { 0x9900, 0x2a2c, 0x3000 },

-  { 0x9900, 0x2a2a, 0x2000 },

-  { 0x1900, 0x2a29, 0x0000 },

-  { 0x1900, 0x2a2b, 0x0000 },

-  { 0x9900, 0x2a2e, 0x2000 },

-  { 0x1900, 0x2a2d, 0x0000 },

-  { 0x1900, 0x2a2f, 0x0000 },

-  { 0x9900, 0x2a38, 0x4000 },

-  { 0x9900, 0x2a34, 0x3000 },

-  { 0x9900, 0x2a32, 0x2000 },

-  { 0x1900, 0x2a31, 0x0000 },

-  { 0x1900, 0x2a33, 0x0000 },

-  { 0x9900, 0x2a36, 0x2000 },

-  { 0x1900, 0x2a35, 0x0000 },

-  { 0x1900, 0x2a37, 0x0000 },

-  { 0x9900, 0x2a3c, 0x3000 },

-  { 0x9900, 0x2a3a, 0x2000 },

-  { 0x1900, 0x2a39, 0x0000 },

-  { 0x1900, 0x2a3b, 0x0000 },

-  { 0x9900, 0x2a3e, 0x2000 },

-  { 0x1900, 0x2a3d, 0x0000 },

-  { 0x1900, 0x2a3f, 0x0000 },

-  { 0x9900, 0x2a50, 0x5000 },

-  { 0x9900, 0x2a48, 0x4000 },

-  { 0x9900, 0x2a44, 0x3000 },

-  { 0x9900, 0x2a42, 0x2000 },

-  { 0x1900, 0x2a41, 0x0000 },

-  { 0x1900, 0x2a43, 0x0000 },

-  { 0x9900, 0x2a46, 0x2000 },

-  { 0x1900, 0x2a45, 0x0000 },

-  { 0x1900, 0x2a47, 0x0000 },

-  { 0x9900, 0x2a4c, 0x3000 },

-  { 0x9900, 0x2a4a, 0x2000 },

-  { 0x1900, 0x2a49, 0x0000 },

-  { 0x1900, 0x2a4b, 0x0000 },

-  { 0x9900, 0x2a4e, 0x2000 },

-  { 0x1900, 0x2a4d, 0x0000 },

-  { 0x1900, 0x2a4f, 0x0000 },

-  { 0x9900, 0x2a58, 0x4000 },

-  { 0x9900, 0x2a54, 0x3000 },

-  { 0x9900, 0x2a52, 0x2000 },

-  { 0x1900, 0x2a51, 0x0000 },

-  { 0x1900, 0x2a53, 0x0000 },

-  { 0x9900, 0x2a56, 0x2000 },

-  { 0x1900, 0x2a55, 0x0000 },

-  { 0x1900, 0x2a57, 0x0000 },

-  { 0x9900, 0x2a5c, 0x3000 },

-  { 0x9900, 0x2a5a, 0x2000 },

-  { 0x1900, 0x2a59, 0x0000 },

-  { 0x1900, 0x2a5b, 0x0000 },

-  { 0x9900, 0x2a5e, 0x2000 },

-  { 0x1900, 0x2a5d, 0x0000 },

-  { 0x1900, 0x2a5f, 0x0000 },

-  { 0x9900, 0x2a80, 0x6000 },

-  { 0x9900, 0x2a70, 0x5000 },

-  { 0x9900, 0x2a68, 0x4000 },

-  { 0x9900, 0x2a64, 0x3000 },

-  { 0x9900, 0x2a62, 0x2000 },

-  { 0x1900, 0x2a61, 0x0000 },

-  { 0x1900, 0x2a63, 0x0000 },

-  { 0x9900, 0x2a66, 0x2000 },

-  { 0x1900, 0x2a65, 0x0000 },

-  { 0x1900, 0x2a67, 0x0000 },

-  { 0x9900, 0x2a6c, 0x3000 },

-  { 0x9900, 0x2a6a, 0x2000 },

-  { 0x1900, 0x2a69, 0x0000 },

-  { 0x1900, 0x2a6b, 0x0000 },

-  { 0x9900, 0x2a6e, 0x2000 },

-  { 0x1900, 0x2a6d, 0x0000 },

-  { 0x1900, 0x2a6f, 0x0000 },

-  { 0x9900, 0x2a78, 0x4000 },

-  { 0x9900, 0x2a74, 0x3000 },

-  { 0x9900, 0x2a72, 0x2000 },

-  { 0x1900, 0x2a71, 0x0000 },

-  { 0x1900, 0x2a73, 0x0000 },

-  { 0x9900, 0x2a76, 0x2000 },

-  { 0x1900, 0x2a75, 0x0000 },

-  { 0x1900, 0x2a77, 0x0000 },

-  { 0x9900, 0x2a7c, 0x3000 },

-  { 0x9900, 0x2a7a, 0x2000 },

-  { 0x1900, 0x2a79, 0x0000 },

-  { 0x1900, 0x2a7b, 0x0000 },

-  { 0x9900, 0x2a7e, 0x2000 },

-  { 0x1900, 0x2a7d, 0x0000 },

-  { 0x1900, 0x2a7f, 0x0000 },

-  { 0x9900, 0x2a90, 0x5000 },

-  { 0x9900, 0x2a88, 0x4000 },

-  { 0x9900, 0x2a84, 0x3000 },

-  { 0x9900, 0x2a82, 0x2000 },

-  { 0x1900, 0x2a81, 0x0000 },

-  { 0x1900, 0x2a83, 0x0000 },

-  { 0x9900, 0x2a86, 0x2000 },

-  { 0x1900, 0x2a85, 0x0000 },

-  { 0x1900, 0x2a87, 0x0000 },

-  { 0x9900, 0x2a8c, 0x3000 },

-  { 0x9900, 0x2a8a, 0x2000 },

-  { 0x1900, 0x2a89, 0x0000 },

-  { 0x1900, 0x2a8b, 0x0000 },

-  { 0x9900, 0x2a8e, 0x2000 },

-  { 0x1900, 0x2a8d, 0x0000 },

-  { 0x1900, 0x2a8f, 0x0000 },

-  { 0x9900, 0x2a98, 0x4000 },

-  { 0x9900, 0x2a94, 0x3000 },

-  { 0x9900, 0x2a92, 0x2000 },

-  { 0x1900, 0x2a91, 0x0000 },

-  { 0x1900, 0x2a93, 0x0000 },

-  { 0x9900, 0x2a96, 0x2000 },

-  { 0x1900, 0x2a95, 0x0000 },

-  { 0x1900, 0x2a97, 0x0000 },

-  { 0x9900, 0x2a9c, 0x3000 },

-  { 0x9900, 0x2a9a, 0x2000 },

-  { 0x1900, 0x2a99, 0x0000 },

-  { 0x1900, 0x2a9b, 0x0000 },

-  { 0x9900, 0x2a9e, 0x2000 },

-  { 0x1900, 0x2a9d, 0x0000 },

-  { 0x1900, 0x2a9f, 0x0000 },

-  { 0x9a00, 0x2e92, 0x8000 },

-  { 0x9900, 0x2ae0, 0x7000 },

-  { 0x9900, 0x2ac0, 0x6000 },

-  { 0x9900, 0x2ab0, 0x5000 },

-  { 0x9900, 0x2aa8, 0x4000 },

-  { 0x9900, 0x2aa4, 0x3000 },

-  { 0x9900, 0x2aa2, 0x2000 },

-  { 0x1900, 0x2aa1, 0x0000 },

-  { 0x1900, 0x2aa3, 0x0000 },

-  { 0x9900, 0x2aa6, 0x2000 },

-  { 0x1900, 0x2aa5, 0x0000 },

-  { 0x1900, 0x2aa7, 0x0000 },

-  { 0x9900, 0x2aac, 0x3000 },

-  { 0x9900, 0x2aaa, 0x2000 },

-  { 0x1900, 0x2aa9, 0x0000 },

-  { 0x1900, 0x2aab, 0x0000 },

-  { 0x9900, 0x2aae, 0x2000 },

-  { 0x1900, 0x2aad, 0x0000 },

-  { 0x1900, 0x2aaf, 0x0000 },

-  { 0x9900, 0x2ab8, 0x4000 },

-  { 0x9900, 0x2ab4, 0x3000 },

-  { 0x9900, 0x2ab2, 0x2000 },

-  { 0x1900, 0x2ab1, 0x0000 },

-  { 0x1900, 0x2ab3, 0x0000 },

-  { 0x9900, 0x2ab6, 0x2000 },

-  { 0x1900, 0x2ab5, 0x0000 },

-  { 0x1900, 0x2ab7, 0x0000 },

-  { 0x9900, 0x2abc, 0x3000 },

-  { 0x9900, 0x2aba, 0x2000 },

-  { 0x1900, 0x2ab9, 0x0000 },

-  { 0x1900, 0x2abb, 0x0000 },

-  { 0x9900, 0x2abe, 0x2000 },

-  { 0x1900, 0x2abd, 0x0000 },

-  { 0x1900, 0x2abf, 0x0000 },

-  { 0x9900, 0x2ad0, 0x5000 },

-  { 0x9900, 0x2ac8, 0x4000 },

-  { 0x9900, 0x2ac4, 0x3000 },

-  { 0x9900, 0x2ac2, 0x2000 },

-  { 0x1900, 0x2ac1, 0x0000 },

-  { 0x1900, 0x2ac3, 0x0000 },

-  { 0x9900, 0x2ac6, 0x2000 },

-  { 0x1900, 0x2ac5, 0x0000 },

-  { 0x1900, 0x2ac7, 0x0000 },

-  { 0x9900, 0x2acc, 0x3000 },

-  { 0x9900, 0x2aca, 0x2000 },

-  { 0x1900, 0x2ac9, 0x0000 },

-  { 0x1900, 0x2acb, 0x0000 },

-  { 0x9900, 0x2ace, 0x2000 },

-  { 0x1900, 0x2acd, 0x0000 },

-  { 0x1900, 0x2acf, 0x0000 },

-  { 0x9900, 0x2ad8, 0x4000 },

-  { 0x9900, 0x2ad4, 0x3000 },

-  { 0x9900, 0x2ad2, 0x2000 },

-  { 0x1900, 0x2ad1, 0x0000 },

-  { 0x1900, 0x2ad3, 0x0000 },

-  { 0x9900, 0x2ad6, 0x2000 },

-  { 0x1900, 0x2ad5, 0x0000 },

-  { 0x1900, 0x2ad7, 0x0000 },

-  { 0x9900, 0x2adc, 0x3000 },

-  { 0x9900, 0x2ada, 0x2000 },

-  { 0x1900, 0x2ad9, 0x0000 },

-  { 0x1900, 0x2adb, 0x0000 },

-  { 0x9900, 0x2ade, 0x2000 },

-  { 0x1900, 0x2add, 0x0000 },

-  { 0x1900, 0x2adf, 0x0000 },

-  { 0x9a00, 0x2b00, 0x6000 },

-  { 0x9900, 0x2af0, 0x5000 },

-  { 0x9900, 0x2ae8, 0x4000 },

-  { 0x9900, 0x2ae4, 0x3000 },

-  { 0x9900, 0x2ae2, 0x2000 },

-  { 0x1900, 0x2ae1, 0x0000 },

-  { 0x1900, 0x2ae3, 0x0000 },

-  { 0x9900, 0x2ae6, 0x2000 },

-  { 0x1900, 0x2ae5, 0x0000 },

-  { 0x1900, 0x2ae7, 0x0000 },

-  { 0x9900, 0x2aec, 0x3000 },

-  { 0x9900, 0x2aea, 0x2000 },

-  { 0x1900, 0x2ae9, 0x0000 },

-  { 0x1900, 0x2aeb, 0x0000 },

-  { 0x9900, 0x2aee, 0x2000 },

-  { 0x1900, 0x2aed, 0x0000 },

-  { 0x1900, 0x2aef, 0x0000 },

-  { 0x9900, 0x2af8, 0x4000 },

-  { 0x9900, 0x2af4, 0x3000 },

-  { 0x9900, 0x2af2, 0x2000 },

-  { 0x1900, 0x2af1, 0x0000 },

-  { 0x1900, 0x2af3, 0x0000 },

-  { 0x9900, 0x2af6, 0x2000 },

-  { 0x1900, 0x2af5, 0x0000 },

-  { 0x1900, 0x2af7, 0x0000 },

-  { 0x9900, 0x2afc, 0x3000 },

-  { 0x9900, 0x2afa, 0x2000 },

-  { 0x1900, 0x2af9, 0x0000 },

-  { 0x1900, 0x2afb, 0x0000 },

-  { 0x9900, 0x2afe, 0x2000 },

-  { 0x1900, 0x2afd, 0x0000 },

-  { 0x1900, 0x2aff, 0x0000 },

-  { 0x9a00, 0x2e82, 0x5000 },

-  { 0x9a00, 0x2b08, 0x4000 },

-  { 0x9a00, 0x2b04, 0x3000 },

-  { 0x9a00, 0x2b02, 0x2000 },

-  { 0x1a00, 0x2b01, 0x0000 },

-  { 0x1a00, 0x2b03, 0x0000 },

-  { 0x9a00, 0x2b06, 0x2000 },

-  { 0x1a00, 0x2b05, 0x0000 },

-  { 0x1a00, 0x2b07, 0x0000 },

-  { 0x9a00, 0x2b0c, 0x3000 },

-  { 0x9a00, 0x2b0a, 0x2000 },

-  { 0x1a00, 0x2b09, 0x0000 },

-  { 0x1a00, 0x2b0b, 0x0000 },

-  { 0x9a00, 0x2e80, 0x2000 },

-  { 0x1a00, 0x2b0d, 0x0000 },

-  { 0x1a00, 0x2e81, 0x0000 },

-  { 0x9a00, 0x2e8a, 0x4000 },

-  { 0x9a00, 0x2e86, 0x3000 },

-  { 0x9a00, 0x2e84, 0x2000 },

-  { 0x1a00, 0x2e83, 0x0000 },

-  { 0x1a00, 0x2e85, 0x0000 },

-  { 0x9a00, 0x2e88, 0x2000 },

-  { 0x1a00, 0x2e87, 0x0000 },

-  { 0x1a00, 0x2e89, 0x0000 },

-  { 0x9a00, 0x2e8e, 0x3000 },

-  { 0x9a00, 0x2e8c, 0x2000 },

-  { 0x1a00, 0x2e8b, 0x0000 },

-  { 0x1a00, 0x2e8d, 0x0000 },

-  { 0x9a00, 0x2e90, 0x2000 },

-  { 0x1a00, 0x2e8f, 0x0000 },

-  { 0x1a00, 0x2e91, 0x0000 },

-  { 0x9a00, 0x2ed3, 0x7000 },

-  { 0x9a00, 0x2eb3, 0x6000 },

-  { 0x9a00, 0x2ea3, 0x5000 },

-  { 0x9a00, 0x2e9b, 0x4000 },

-  { 0x9a00, 0x2e96, 0x3000 },

-  { 0x9a00, 0x2e94, 0x2000 },

-  { 0x1a00, 0x2e93, 0x0000 },

-  { 0x1a00, 0x2e95, 0x0000 },

-  { 0x9a00, 0x2e98, 0x2000 },

-  { 0x1a00, 0x2e97, 0x0000 },

-  { 0x1a00, 0x2e99, 0x0000 },

-  { 0x9a00, 0x2e9f, 0x3000 },

-  { 0x9a00, 0x2e9d, 0x2000 },

-  { 0x1a00, 0x2e9c, 0x0000 },

-  { 0x1a00, 0x2e9e, 0x0000 },

-  { 0x9a00, 0x2ea1, 0x2000 },

-  { 0x1a00, 0x2ea0, 0x0000 },

-  { 0x1a00, 0x2ea2, 0x0000 },

-  { 0x9a00, 0x2eab, 0x4000 },

-  { 0x9a00, 0x2ea7, 0x3000 },

-  { 0x9a00, 0x2ea5, 0x2000 },

-  { 0x1a00, 0x2ea4, 0x0000 },

-  { 0x1a00, 0x2ea6, 0x0000 },

-  { 0x9a00, 0x2ea9, 0x2000 },

-  { 0x1a00, 0x2ea8, 0x0000 },

-  { 0x1a00, 0x2eaa, 0x0000 },

-  { 0x9a00, 0x2eaf, 0x3000 },

-  { 0x9a00, 0x2ead, 0x2000 },

-  { 0x1a00, 0x2eac, 0x0000 },

-  { 0x1a00, 0x2eae, 0x0000 },

-  { 0x9a00, 0x2eb1, 0x2000 },

-  { 0x1a00, 0x2eb0, 0x0000 },

-  { 0x1a00, 0x2eb2, 0x0000 },

-  { 0x9a00, 0x2ec3, 0x5000 },

-  { 0x9a00, 0x2ebb, 0x4000 },

-  { 0x9a00, 0x2eb7, 0x3000 },

-  { 0x9a00, 0x2eb5, 0x2000 },

-  { 0x1a00, 0x2eb4, 0x0000 },

-  { 0x1a00, 0x2eb6, 0x0000 },

-  { 0x9a00, 0x2eb9, 0x2000 },

-  { 0x1a00, 0x2eb8, 0x0000 },

-  { 0x1a00, 0x2eba, 0x0000 },

-  { 0x9a00, 0x2ebf, 0x3000 },

-  { 0x9a00, 0x2ebd, 0x2000 },

-  { 0x1a00, 0x2ebc, 0x0000 },

-  { 0x1a00, 0x2ebe, 0x0000 },

-  { 0x9a00, 0x2ec1, 0x2000 },

-  { 0x1a00, 0x2ec0, 0x0000 },

-  { 0x1a00, 0x2ec2, 0x0000 },

-  { 0x9a00, 0x2ecb, 0x4000 },

-  { 0x9a00, 0x2ec7, 0x3000 },

-  { 0x9a00, 0x2ec5, 0x2000 },

-  { 0x1a00, 0x2ec4, 0x0000 },

-  { 0x1a00, 0x2ec6, 0x0000 },

-  { 0x9a00, 0x2ec9, 0x2000 },

-  { 0x1a00, 0x2ec8, 0x0000 },

-  { 0x1a00, 0x2eca, 0x0000 },

-  { 0x9a00, 0x2ecf, 0x3000 },

-  { 0x9a00, 0x2ecd, 0x2000 },

-  { 0x1a00, 0x2ecc, 0x0000 },

-  { 0x1a00, 0x2ece, 0x0000 },

-  { 0x9a00, 0x2ed1, 0x2000 },

-  { 0x1a00, 0x2ed0, 0x0000 },

-  { 0x1a00, 0x2ed2, 0x0000 },

-  { 0x9a00, 0x2ef3, 0x6000 },

-  { 0x9a00, 0x2ee3, 0x5000 },

-  { 0x9a00, 0x2edb, 0x4000 },

-  { 0x9a00, 0x2ed7, 0x3000 },

-  { 0x9a00, 0x2ed5, 0x2000 },

-  { 0x1a00, 0x2ed4, 0x0000 },

-  { 0x1a00, 0x2ed6, 0x0000 },

-  { 0x9a00, 0x2ed9, 0x2000 },

-  { 0x1a00, 0x2ed8, 0x0000 },

-  { 0x1a00, 0x2eda, 0x0000 },

-  { 0x9a00, 0x2edf, 0x3000 },

-  { 0x9a00, 0x2edd, 0x2000 },

-  { 0x1a00, 0x2edc, 0x0000 },

-  { 0x1a00, 0x2ede, 0x0000 },

-  { 0x9a00, 0x2ee1, 0x2000 },

-  { 0x1a00, 0x2ee0, 0x0000 },

-  { 0x1a00, 0x2ee2, 0x0000 },

-  { 0x9a00, 0x2eeb, 0x4000 },

-  { 0x9a00, 0x2ee7, 0x3000 },

-  { 0x9a00, 0x2ee5, 0x2000 },

-  { 0x1a00, 0x2ee4, 0x0000 },

-  { 0x1a00, 0x2ee6, 0x0000 },

-  { 0x9a00, 0x2ee9, 0x2000 },

-  { 0x1a00, 0x2ee8, 0x0000 },

-  { 0x1a00, 0x2eea, 0x0000 },

-  { 0x9a00, 0x2eef, 0x3000 },

-  { 0x9a00, 0x2eed, 0x2000 },

-  { 0x1a00, 0x2eec, 0x0000 },

-  { 0x1a00, 0x2eee, 0x0000 },

-  { 0x9a00, 0x2ef1, 0x2000 },

-  { 0x1a00, 0x2ef0, 0x0000 },

-  { 0x1a00, 0x2ef2, 0x0000 },

-  { 0x9a00, 0x2f0f, 0x5000 },

-  { 0x9a00, 0x2f07, 0x4000 },

-  { 0x9a00, 0x2f03, 0x3000 },

-  { 0x9a00, 0x2f01, 0x2000 },

-  { 0x1a00, 0x2f00, 0x0000 },

-  { 0x1a00, 0x2f02, 0x0000 },

-  { 0x9a00, 0x2f05, 0x2000 },

-  { 0x1a00, 0x2f04, 0x0000 },

-  { 0x1a00, 0x2f06, 0x0000 },

-  { 0x9a00, 0x2f0b, 0x3000 },

-  { 0x9a00, 0x2f09, 0x2000 },

-  { 0x1a00, 0x2f08, 0x0000 },

-  { 0x1a00, 0x2f0a, 0x0000 },

-  { 0x9a00, 0x2f0d, 0x2000 },

-  { 0x1a00, 0x2f0c, 0x0000 },

-  { 0x1a00, 0x2f0e, 0x0000 },

-  { 0x9a00, 0x2f17, 0x4000 },

-  { 0x9a00, 0x2f13, 0x3000 },

-  { 0x9a00, 0x2f11, 0x2000 },

-  { 0x1a00, 0x2f10, 0x0000 },

-  { 0x1a00, 0x2f12, 0x0000 },

-  { 0x9a00, 0x2f15, 0x2000 },

-  { 0x1a00, 0x2f14, 0x0000 },

-  { 0x1a00, 0x2f16, 0x0000 },

-  { 0x9a00, 0x2f1b, 0x3000 },

-  { 0x9a00, 0x2f19, 0x2000 },

-  { 0x1a00, 0x2f18, 0x0000 },

-  { 0x1a00, 0x2f1a, 0x0000 },

-  { 0x9a00, 0x2f1d, 0x2000 },

-  { 0x1a00, 0x2f1c, 0x0000 },

-  { 0x1a00, 0x2f1e, 0x0000 },

-  { 0x8701, 0x00f0, 0xd000 },

-  { 0x8700, 0xa34d, 0xc000 },

-  { 0x9a00, 0x3391, 0xb000 },

-  { 0x8700, 0x3149, 0xa000 },

-  { 0x9500, 0x303d, 0x9000 },

-  { 0x9a00, 0x2f9f, 0x8000 },

-  { 0x9a00, 0x2f5f, 0x7000 },

-  { 0x9a00, 0x2f3f, 0x6000 },

-  { 0x9a00, 0x2f2f, 0x5000 },

-  { 0x9a00, 0x2f27, 0x4000 },

-  { 0x9a00, 0x2f23, 0x3000 },

-  { 0x9a00, 0x2f21, 0x2000 },

-  { 0x1a00, 0x2f20, 0x0000 },

-  { 0x1a00, 0x2f22, 0x0000 },

-  { 0x9a00, 0x2f25, 0x2000 },

-  { 0x1a00, 0x2f24, 0x0000 },

-  { 0x1a00, 0x2f26, 0x0000 },

-  { 0x9a00, 0x2f2b, 0x3000 },

-  { 0x9a00, 0x2f29, 0x2000 },

-  { 0x1a00, 0x2f28, 0x0000 },

-  { 0x1a00, 0x2f2a, 0x0000 },

-  { 0x9a00, 0x2f2d, 0x2000 },

-  { 0x1a00, 0x2f2c, 0x0000 },

-  { 0x1a00, 0x2f2e, 0x0000 },

-  { 0x9a00, 0x2f37, 0x4000 },

-  { 0x9a00, 0x2f33, 0x3000 },

-  { 0x9a00, 0x2f31, 0x2000 },

-  { 0x1a00, 0x2f30, 0x0000 },

-  { 0x1a00, 0x2f32, 0x0000 },

-  { 0x9a00, 0x2f35, 0x2000 },

-  { 0x1a00, 0x2f34, 0x0000 },

-  { 0x1a00, 0x2f36, 0x0000 },

-  { 0x9a00, 0x2f3b, 0x3000 },

-  { 0x9a00, 0x2f39, 0x2000 },

-  { 0x1a00, 0x2f38, 0x0000 },

-  { 0x1a00, 0x2f3a, 0x0000 },

-  { 0x9a00, 0x2f3d, 0x2000 },

-  { 0x1a00, 0x2f3c, 0x0000 },

-  { 0x1a00, 0x2f3e, 0x0000 },

-  { 0x9a00, 0x2f4f, 0x5000 },

-  { 0x9a00, 0x2f47, 0x4000 },

-  { 0x9a00, 0x2f43, 0x3000 },

-  { 0x9a00, 0x2f41, 0x2000 },

-  { 0x1a00, 0x2f40, 0x0000 },

-  { 0x1a00, 0x2f42, 0x0000 },

-  { 0x9a00, 0x2f45, 0x2000 },

-  { 0x1a00, 0x2f44, 0x0000 },

-  { 0x1a00, 0x2f46, 0x0000 },

-  { 0x9a00, 0x2f4b, 0x3000 },

-  { 0x9a00, 0x2f49, 0x2000 },

-  { 0x1a00, 0x2f48, 0x0000 },

-  { 0x1a00, 0x2f4a, 0x0000 },

-  { 0x9a00, 0x2f4d, 0x2000 },

-  { 0x1a00, 0x2f4c, 0x0000 },

-  { 0x1a00, 0x2f4e, 0x0000 },

-  { 0x9a00, 0x2f57, 0x4000 },

-  { 0x9a00, 0x2f53, 0x3000 },

-  { 0x9a00, 0x2f51, 0x2000 },

-  { 0x1a00, 0x2f50, 0x0000 },

-  { 0x1a00, 0x2f52, 0x0000 },

-  { 0x9a00, 0x2f55, 0x2000 },

-  { 0x1a00, 0x2f54, 0x0000 },

-  { 0x1a00, 0x2f56, 0x0000 },

-  { 0x9a00, 0x2f5b, 0x3000 },

-  { 0x9a00, 0x2f59, 0x2000 },

-  { 0x1a00, 0x2f58, 0x0000 },

-  { 0x1a00, 0x2f5a, 0x0000 },

-  { 0x9a00, 0x2f5d, 0x2000 },

-  { 0x1a00, 0x2f5c, 0x0000 },

-  { 0x1a00, 0x2f5e, 0x0000 },

-  { 0x9a00, 0x2f7f, 0x6000 },

-  { 0x9a00, 0x2f6f, 0x5000 },

-  { 0x9a00, 0x2f67, 0x4000 },

-  { 0x9a00, 0x2f63, 0x3000 },

-  { 0x9a00, 0x2f61, 0x2000 },

-  { 0x1a00, 0x2f60, 0x0000 },

-  { 0x1a00, 0x2f62, 0x0000 },

-  { 0x9a00, 0x2f65, 0x2000 },

-  { 0x1a00, 0x2f64, 0x0000 },

-  { 0x1a00, 0x2f66, 0x0000 },

-  { 0x9a00, 0x2f6b, 0x3000 },

-  { 0x9a00, 0x2f69, 0x2000 },

-  { 0x1a00, 0x2f68, 0x0000 },

-  { 0x1a00, 0x2f6a, 0x0000 },

-  { 0x9a00, 0x2f6d, 0x2000 },

-  { 0x1a00, 0x2f6c, 0x0000 },

-  { 0x1a00, 0x2f6e, 0x0000 },

-  { 0x9a00, 0x2f77, 0x4000 },

-  { 0x9a00, 0x2f73, 0x3000 },

-  { 0x9a00, 0x2f71, 0x2000 },

-  { 0x1a00, 0x2f70, 0x0000 },

-  { 0x1a00, 0x2f72, 0x0000 },

-  { 0x9a00, 0x2f75, 0x2000 },

-  { 0x1a00, 0x2f74, 0x0000 },

-  { 0x1a00, 0x2f76, 0x0000 },

-  { 0x9a00, 0x2f7b, 0x3000 },

-  { 0x9a00, 0x2f79, 0x2000 },

-  { 0x1a00, 0x2f78, 0x0000 },

-  { 0x1a00, 0x2f7a, 0x0000 },

-  { 0x9a00, 0x2f7d, 0x2000 },

-  { 0x1a00, 0x2f7c, 0x0000 },

-  { 0x1a00, 0x2f7e, 0x0000 },

-  { 0x9a00, 0x2f8f, 0x5000 },

-  { 0x9a00, 0x2f87, 0x4000 },

-  { 0x9a00, 0x2f83, 0x3000 },

-  { 0x9a00, 0x2f81, 0x2000 },

-  { 0x1a00, 0x2f80, 0x0000 },

-  { 0x1a00, 0x2f82, 0x0000 },

-  { 0x9a00, 0x2f85, 0x2000 },

-  { 0x1a00, 0x2f84, 0x0000 },

-  { 0x1a00, 0x2f86, 0x0000 },

-  { 0x9a00, 0x2f8b, 0x3000 },

-  { 0x9a00, 0x2f89, 0x2000 },

-  { 0x1a00, 0x2f88, 0x0000 },

-  { 0x1a00, 0x2f8a, 0x0000 },

-  { 0x9a00, 0x2f8d, 0x2000 },

-  { 0x1a00, 0x2f8c, 0x0000 },

-  { 0x1a00, 0x2f8e, 0x0000 },

-  { 0x9a00, 0x2f97, 0x4000 },

-  { 0x9a00, 0x2f93, 0x3000 },

-  { 0x9a00, 0x2f91, 0x2000 },

-  { 0x1a00, 0x2f90, 0x0000 },

-  { 0x1a00, 0x2f92, 0x0000 },

-  { 0x9a00, 0x2f95, 0x2000 },

-  { 0x1a00, 0x2f94, 0x0000 },

-  { 0x1a00, 0x2f96, 0x0000 },

-  { 0x9a00, 0x2f9b, 0x3000 },

-  { 0x9a00, 0x2f99, 0x2000 },

-  { 0x1a00, 0x2f98, 0x0000 },

-  { 0x1a00, 0x2f9a, 0x0000 },

-  { 0x9a00, 0x2f9d, 0x2000 },

-  { 0x1a00, 0x2f9c, 0x0000 },

-  { 0x1a00, 0x2f9e, 0x0000 },

-  { 0x9a00, 0x2ff9, 0x7000 },

-  { 0x9a00, 0x2fbf, 0x6000 },

-  { 0x9a00, 0x2faf, 0x5000 },

-  { 0x9a00, 0x2fa7, 0x4000 },

-  { 0x9a00, 0x2fa3, 0x3000 },

-  { 0x9a00, 0x2fa1, 0x2000 },

-  { 0x1a00, 0x2fa0, 0x0000 },

-  { 0x1a00, 0x2fa2, 0x0000 },

-  { 0x9a00, 0x2fa5, 0x2000 },

-  { 0x1a00, 0x2fa4, 0x0000 },

-  { 0x1a00, 0x2fa6, 0x0000 },

-  { 0x9a00, 0x2fab, 0x3000 },

-  { 0x9a00, 0x2fa9, 0x2000 },

-  { 0x1a00, 0x2fa8, 0x0000 },

-  { 0x1a00, 0x2faa, 0x0000 },

-  { 0x9a00, 0x2fad, 0x2000 },

-  { 0x1a00, 0x2fac, 0x0000 },

-  { 0x1a00, 0x2fae, 0x0000 },

-  { 0x9a00, 0x2fb7, 0x4000 },

-  { 0x9a00, 0x2fb3, 0x3000 },

-  { 0x9a00, 0x2fb1, 0x2000 },

-  { 0x1a00, 0x2fb0, 0x0000 },

-  { 0x1a00, 0x2fb2, 0x0000 },

-  { 0x9a00, 0x2fb5, 0x2000 },

-  { 0x1a00, 0x2fb4, 0x0000 },

-  { 0x1a00, 0x2fb6, 0x0000 },

-  { 0x9a00, 0x2fbb, 0x3000 },

-  { 0x9a00, 0x2fb9, 0x2000 },

-  { 0x1a00, 0x2fb8, 0x0000 },

-  { 0x1a00, 0x2fba, 0x0000 },

-  { 0x9a00, 0x2fbd, 0x2000 },

-  { 0x1a00, 0x2fbc, 0x0000 },

-  { 0x1a00, 0x2fbe, 0x0000 },

-  { 0x9a00, 0x2fcf, 0x5000 },

-  { 0x9a00, 0x2fc7, 0x4000 },

-  { 0x9a00, 0x2fc3, 0x3000 },

-  { 0x9a00, 0x2fc1, 0x2000 },

-  { 0x1a00, 0x2fc0, 0x0000 },

-  { 0x1a00, 0x2fc2, 0x0000 },

-  { 0x9a00, 0x2fc5, 0x2000 },

-  { 0x1a00, 0x2fc4, 0x0000 },

-  { 0x1a00, 0x2fc6, 0x0000 },

-  { 0x9a00, 0x2fcb, 0x3000 },

-  { 0x9a00, 0x2fc9, 0x2000 },

-  { 0x1a00, 0x2fc8, 0x0000 },

-  { 0x1a00, 0x2fca, 0x0000 },

-  { 0x9a00, 0x2fcd, 0x2000 },

-  { 0x1a00, 0x2fcc, 0x0000 },

-  { 0x1a00, 0x2fce, 0x0000 },

-  { 0x9a00, 0x2ff1, 0x4000 },

-  { 0x9a00, 0x2fd3, 0x3000 },

-  { 0x9a00, 0x2fd1, 0x2000 },

-  { 0x1a00, 0x2fd0, 0x0000 },

-  { 0x1a00, 0x2fd2, 0x0000 },

-  { 0x9a00, 0x2fd5, 0x2000 },

-  { 0x1a00, 0x2fd4, 0x0000 },

-  { 0x1a00, 0x2ff0, 0x0000 },

-  { 0x9a00, 0x2ff5, 0x3000 },

-  { 0x9a00, 0x2ff3, 0x2000 },

-  { 0x1a00, 0x2ff2, 0x0000 },

-  { 0x1a00, 0x2ff4, 0x0000 },

-  { 0x9a00, 0x2ff7, 0x2000 },

-  { 0x1a00, 0x2ff6, 0x0000 },

-  { 0x1a00, 0x2ff8, 0x0000 },

-  { 0x9600, 0x301d, 0x6000 },

-  { 0x9200, 0x300d, 0x5000 },

-  { 0x8600, 0x3005, 0x4000 },

-  { 0x9500, 0x3001, 0x3000 },

-  { 0x9a00, 0x2ffb, 0x2000 },

-  { 0x1a00, 0x2ffa, 0x0000 },

-  { 0x1d00, 0x3000, 0x0000 },

-  { 0x9500, 0x3003, 0x2000 },

-  { 0x1500, 0x3002, 0x0000 },

-  { 0x1a00, 0x3004, 0x0000 },

-  { 0x9200, 0x3009, 0x3000 },

-  { 0x8e00, 0x3007, 0x2000 },

-  { 0x0700, 0x3006, 0x0000 },

-  { 0x1600, 0x3008, 0x0000 },

-  { 0x9200, 0x300b, 0x2000 },

-  { 0x1600, 0x300a, 0x0000 },

-  { 0x1600, 0x300c, 0x0000 },

-  { 0x9200, 0x3015, 0x4000 },

-  { 0x9200, 0x3011, 0x3000 },

-  { 0x9200, 0x300f, 0x2000 },

-  { 0x1600, 0x300e, 0x0000 },

-  { 0x1600, 0x3010, 0x0000 },

-  { 0x9a00, 0x3013, 0x2000 },

-  { 0x1a00, 0x3012, 0x0000 },

-  { 0x1600, 0x3014, 0x0000 },

-  { 0x9200, 0x3019, 0x3000 },

-  { 0x9200, 0x3017, 0x2000 },

-  { 0x1600, 0x3016, 0x0000 },

-  { 0x1600, 0x3018, 0x0000 },

-  { 0x9200, 0x301b, 0x2000 },

-  { 0x1600, 0x301a, 0x0000 },

-  { 0x1100, 0x301c, 0x0000 },

-  { 0x8c00, 0x302d, 0x5000 },

-  { 0x8e00, 0x3025, 0x4000 },

-  { 0x8e00, 0x3021, 0x3000 },

-  { 0x9200, 0x301f, 0x2000 },

-  { 0x1200, 0x301e, 0x0000 },

-  { 0x1a00, 0x3020, 0x0000 },

-  { 0x8e00, 0x3023, 0x2000 },

-  { 0x0e00, 0x3022, 0x0000 },

-  { 0x0e00, 0x3024, 0x0000 },

-  { 0x8e00, 0x3029, 0x3000 },

-  { 0x8e00, 0x3027, 0x2000 },

-  { 0x0e00, 0x3026, 0x0000 },

-  { 0x0e00, 0x3028, 0x0000 },

-  { 0x8c00, 0x302b, 0x2000 },

-  { 0x0c00, 0x302a, 0x0000 },

-  { 0x0c00, 0x302c, 0x0000 },

-  { 0x8600, 0x3035, 0x4000 },

-  { 0x8600, 0x3031, 0x3000 },

-  { 0x8c00, 0x302f, 0x2000 },

-  { 0x0c00, 0x302e, 0x0000 },

-  { 0x1100, 0x3030, 0x0000 },

-  { 0x8600, 0x3033, 0x2000 },

-  { 0x0600, 0x3032, 0x0000 },

-  { 0x0600, 0x3034, 0x0000 },

-  { 0x8e00, 0x3039, 0x3000 },

-  { 0x9a00, 0x3037, 0x2000 },

-  { 0x1a00, 0x3036, 0x0000 },

-  { 0x0e00, 0x3038, 0x0000 },

-  { 0x8600, 0x303b, 0x2000 },

-  { 0x0e00, 0x303a, 0x0000 },

-  { 0x0700, 0x303c, 0x0000 },

-  { 0x8700, 0x30c0, 0x8000 },

-  { 0x8700, 0x307e, 0x7000 },

-  { 0x8700, 0x305e, 0x6000 },

-  { 0x8700, 0x304e, 0x5000 },

-  { 0x8700, 0x3046, 0x4000 },

-  { 0x8700, 0x3042, 0x3000 },

-  { 0x9a00, 0x303f, 0x2000 },

-  { 0x1a00, 0x303e, 0x0000 },

-  { 0x0700, 0x3041, 0x0000 },

-  { 0x8700, 0x3044, 0x2000 },

-  { 0x0700, 0x3043, 0x0000 },

-  { 0x0700, 0x3045, 0x0000 },

-  { 0x8700, 0x304a, 0x3000 },

-  { 0x8700, 0x3048, 0x2000 },

-  { 0x0700, 0x3047, 0x0000 },

-  { 0x0700, 0x3049, 0x0000 },

-  { 0x8700, 0x304c, 0x2000 },

-  { 0x0700, 0x304b, 0x0000 },

-  { 0x0700, 0x304d, 0x0000 },

-  { 0x8700, 0x3056, 0x4000 },

-  { 0x8700, 0x3052, 0x3000 },

-  { 0x8700, 0x3050, 0x2000 },

-  { 0x0700, 0x304f, 0x0000 },

-  { 0x0700, 0x3051, 0x0000 },

-  { 0x8700, 0x3054, 0x2000 },

-  { 0x0700, 0x3053, 0x0000 },

-  { 0x0700, 0x3055, 0x0000 },

-  { 0x8700, 0x305a, 0x3000 },

-  { 0x8700, 0x3058, 0x2000 },

-  { 0x0700, 0x3057, 0x0000 },

-  { 0x0700, 0x3059, 0x0000 },

-  { 0x8700, 0x305c, 0x2000 },

-  { 0x0700, 0x305b, 0x0000 },

-  { 0x0700, 0x305d, 0x0000 },

-  { 0x8700, 0x306e, 0x5000 },

-  { 0x8700, 0x3066, 0x4000 },

-  { 0x8700, 0x3062, 0x3000 },

-  { 0x8700, 0x3060, 0x2000 },

-  { 0x0700, 0x305f, 0x0000 },

-  { 0x0700, 0x3061, 0x0000 },

-  { 0x8700, 0x3064, 0x2000 },

-  { 0x0700, 0x3063, 0x0000 },

-  { 0x0700, 0x3065, 0x0000 },

-  { 0x8700, 0x306a, 0x3000 },

-  { 0x8700, 0x3068, 0x2000 },

-  { 0x0700, 0x3067, 0x0000 },

-  { 0x0700, 0x3069, 0x0000 },

-  { 0x8700, 0x306c, 0x2000 },

-  { 0x0700, 0x306b, 0x0000 },

-  { 0x0700, 0x306d, 0x0000 },

-  { 0x8700, 0x3076, 0x4000 },

-  { 0x8700, 0x3072, 0x3000 },

-  { 0x8700, 0x3070, 0x2000 },

-  { 0x0700, 0x306f, 0x0000 },

-  { 0x0700, 0x3071, 0x0000 },

-  { 0x8700, 0x3074, 0x2000 },

-  { 0x0700, 0x3073, 0x0000 },

-  { 0x0700, 0x3075, 0x0000 },

-  { 0x8700, 0x307a, 0x3000 },

-  { 0x8700, 0x3078, 0x2000 },

-  { 0x0700, 0x3077, 0x0000 },

-  { 0x0700, 0x3079, 0x0000 },

-  { 0x8700, 0x307c, 0x2000 },

-  { 0x0700, 0x307b, 0x0000 },

-  { 0x0700, 0x307d, 0x0000 },

-  { 0x9100, 0x30a0, 0x6000 },

-  { 0x8700, 0x308e, 0x5000 },

-  { 0x8700, 0x3086, 0x4000 },

-  { 0x8700, 0x3082, 0x3000 },

-  { 0x8700, 0x3080, 0x2000 },

-  { 0x0700, 0x307f, 0x0000 },

-  { 0x0700, 0x3081, 0x0000 },

-  { 0x8700, 0x3084, 0x2000 },

-  { 0x0700, 0x3083, 0x0000 },

-  { 0x0700, 0x3085, 0x0000 },

-  { 0x8700, 0x308a, 0x3000 },

-  { 0x8700, 0x3088, 0x2000 },

-  { 0x0700, 0x3087, 0x0000 },

-  { 0x0700, 0x3089, 0x0000 },

-  { 0x8700, 0x308c, 0x2000 },

-  { 0x0700, 0x308b, 0x0000 },

-  { 0x0700, 0x308d, 0x0000 },

-  { 0x8700, 0x3096, 0x4000 },

-  { 0x8700, 0x3092, 0x3000 },

-  { 0x8700, 0x3090, 0x2000 },

-  { 0x0700, 0x308f, 0x0000 },

-  { 0x0700, 0x3091, 0x0000 },

-  { 0x8700, 0x3094, 0x2000 },

-  { 0x0700, 0x3093, 0x0000 },

-  { 0x0700, 0x3095, 0x0000 },

-  { 0x9800, 0x309c, 0x3000 },

-  { 0x8c00, 0x309a, 0x2000 },

-  { 0x0c00, 0x3099, 0x0000 },

-  { 0x1800, 0x309b, 0x0000 },

-  { 0x8600, 0x309e, 0x2000 },

-  { 0x0600, 0x309d, 0x0000 },

-  { 0x0700, 0x309f, 0x0000 },

-  { 0x8700, 0x30b0, 0x5000 },

-  { 0x8700, 0x30a8, 0x4000 },

-  { 0x8700, 0x30a4, 0x3000 },

-  { 0x8700, 0x30a2, 0x2000 },

-  { 0x0700, 0x30a1, 0x0000 },

-  { 0x0700, 0x30a3, 0x0000 },

-  { 0x8700, 0x30a6, 0x2000 },

-  { 0x0700, 0x30a5, 0x0000 },

-  { 0x0700, 0x30a7, 0x0000 },

-  { 0x8700, 0x30ac, 0x3000 },

-  { 0x8700, 0x30aa, 0x2000 },

-  { 0x0700, 0x30a9, 0x0000 },

-  { 0x0700, 0x30ab, 0x0000 },

-  { 0x8700, 0x30ae, 0x2000 },

-  { 0x0700, 0x30ad, 0x0000 },

-  { 0x0700, 0x30af, 0x0000 },

-  { 0x8700, 0x30b8, 0x4000 },

-  { 0x8700, 0x30b4, 0x3000 },

-  { 0x8700, 0x30b2, 0x2000 },

-  { 0x0700, 0x30b1, 0x0000 },

-  { 0x0700, 0x30b3, 0x0000 },

-  { 0x8700, 0x30b6, 0x2000 },

-  { 0x0700, 0x30b5, 0x0000 },

-  { 0x0700, 0x30b7, 0x0000 },

-  { 0x8700, 0x30bc, 0x3000 },

-  { 0x8700, 0x30ba, 0x2000 },

-  { 0x0700, 0x30b9, 0x0000 },

-  { 0x0700, 0x30bb, 0x0000 },

-  { 0x8700, 0x30be, 0x2000 },

-  { 0x0700, 0x30bd, 0x0000 },

-  { 0x0700, 0x30bf, 0x0000 },

-  { 0x8700, 0x3105, 0x7000 },

-  { 0x8700, 0x30e0, 0x6000 },

-  { 0x8700, 0x30d0, 0x5000 },

-  { 0x8700, 0x30c8, 0x4000 },

-  { 0x8700, 0x30c4, 0x3000 },

-  { 0x8700, 0x30c2, 0x2000 },

-  { 0x0700, 0x30c1, 0x0000 },

-  { 0x0700, 0x30c3, 0x0000 },

-  { 0x8700, 0x30c6, 0x2000 },

-  { 0x0700, 0x30c5, 0x0000 },

-  { 0x0700, 0x30c7, 0x0000 },

-  { 0x8700, 0x30cc, 0x3000 },

-  { 0x8700, 0x30ca, 0x2000 },

-  { 0x0700, 0x30c9, 0x0000 },

-  { 0x0700, 0x30cb, 0x0000 },

-  { 0x8700, 0x30ce, 0x2000 },

-  { 0x0700, 0x30cd, 0x0000 },

-  { 0x0700, 0x30cf, 0x0000 },

-  { 0x8700, 0x30d8, 0x4000 },

-  { 0x8700, 0x30d4, 0x3000 },

-  { 0x8700, 0x30d2, 0x2000 },

-  { 0x0700, 0x30d1, 0x0000 },

-  { 0x0700, 0x30d3, 0x0000 },

-  { 0x8700, 0x30d6, 0x2000 },

-  { 0x0700, 0x30d5, 0x0000 },

-  { 0x0700, 0x30d7, 0x0000 },

-  { 0x8700, 0x30dc, 0x3000 },

-  { 0x8700, 0x30da, 0x2000 },

-  { 0x0700, 0x30d9, 0x0000 },

-  { 0x0700, 0x30db, 0x0000 },

-  { 0x8700, 0x30de, 0x2000 },

-  { 0x0700, 0x30dd, 0x0000 },

-  { 0x0700, 0x30df, 0x0000 },

-  { 0x8700, 0x30f0, 0x5000 },

-  { 0x8700, 0x30e8, 0x4000 },

-  { 0x8700, 0x30e4, 0x3000 },

-  { 0x8700, 0x30e2, 0x2000 },

-  { 0x0700, 0x30e1, 0x0000 },

-  { 0x0700, 0x30e3, 0x0000 },

-  { 0x8700, 0x30e6, 0x2000 },

-  { 0x0700, 0x30e5, 0x0000 },

-  { 0x0700, 0x30e7, 0x0000 },

-  { 0x8700, 0x30ec, 0x3000 },

-  { 0x8700, 0x30ea, 0x2000 },

-  { 0x0700, 0x30e9, 0x0000 },

-  { 0x0700, 0x30eb, 0x0000 },

-  { 0x8700, 0x30ee, 0x2000 },

-  { 0x0700, 0x30ed, 0x0000 },

-  { 0x0700, 0x30ef, 0x0000 },

-  { 0x8700, 0x30f8, 0x4000 },

-  { 0x8700, 0x30f4, 0x3000 },

-  { 0x8700, 0x30f2, 0x2000 },

-  { 0x0700, 0x30f1, 0x0000 },

-  { 0x0700, 0x30f3, 0x0000 },

-  { 0x8700, 0x30f6, 0x2000 },

-  { 0x0700, 0x30f5, 0x0000 },

-  { 0x0700, 0x30f7, 0x0000 },

-  { 0x8600, 0x30fc, 0x3000 },

-  { 0x8700, 0x30fa, 0x2000 },

-  { 0x0700, 0x30f9, 0x0000 },

-  { 0x1000, 0x30fb, 0x0000 },

-  { 0x8600, 0x30fe, 0x2000 },

-  { 0x0600, 0x30fd, 0x0000 },

-  { 0x0700, 0x30ff, 0x0000 },

-  { 0x8700, 0x3125, 0x6000 },

-  { 0x8700, 0x3115, 0x5000 },

-  { 0x8700, 0x310d, 0x4000 },

-  { 0x8700, 0x3109, 0x3000 },

-  { 0x8700, 0x3107, 0x2000 },

-  { 0x0700, 0x3106, 0x0000 },

-  { 0x0700, 0x3108, 0x0000 },

-  { 0x8700, 0x310b, 0x2000 },

-  { 0x0700, 0x310a, 0x0000 },

-  { 0x0700, 0x310c, 0x0000 },

-  { 0x8700, 0x3111, 0x3000 },

-  { 0x8700, 0x310f, 0x2000 },

-  { 0x0700, 0x310e, 0x0000 },

-  { 0x0700, 0x3110, 0x0000 },

-  { 0x8700, 0x3113, 0x2000 },

-  { 0x0700, 0x3112, 0x0000 },

-  { 0x0700, 0x3114, 0x0000 },

-  { 0x8700, 0x311d, 0x4000 },

-  { 0x8700, 0x3119, 0x3000 },

-  { 0x8700, 0x3117, 0x2000 },

-  { 0x0700, 0x3116, 0x0000 },

-  { 0x0700, 0x3118, 0x0000 },

-  { 0x8700, 0x311b, 0x2000 },

-  { 0x0700, 0x311a, 0x0000 },

-  { 0x0700, 0x311c, 0x0000 },

-  { 0x8700, 0x3121, 0x3000 },

-  { 0x8700, 0x311f, 0x2000 },

-  { 0x0700, 0x311e, 0x0000 },

-  { 0x0700, 0x3120, 0x0000 },

-  { 0x8700, 0x3123, 0x2000 },

-  { 0x0700, 0x3122, 0x0000 },

-  { 0x0700, 0x3124, 0x0000 },

-  { 0x8700, 0x3139, 0x5000 },

-  { 0x8700, 0x3131, 0x4000 },

-  { 0x8700, 0x3129, 0x3000 },

-  { 0x8700, 0x3127, 0x2000 },

-  { 0x0700, 0x3126, 0x0000 },

-  { 0x0700, 0x3128, 0x0000 },

-  { 0x8700, 0x312b, 0x2000 },

-  { 0x0700, 0x312a, 0x0000 },

-  { 0x0700, 0x312c, 0x0000 },

-  { 0x8700, 0x3135, 0x3000 },

-  { 0x8700, 0x3133, 0x2000 },

-  { 0x0700, 0x3132, 0x0000 },

-  { 0x0700, 0x3134, 0x0000 },

-  { 0x8700, 0x3137, 0x2000 },

-  { 0x0700, 0x3136, 0x0000 },

-  { 0x0700, 0x3138, 0x0000 },

-  { 0x8700, 0x3141, 0x4000 },

-  { 0x8700, 0x313d, 0x3000 },

-  { 0x8700, 0x313b, 0x2000 },

-  { 0x0700, 0x313a, 0x0000 },

-  { 0x0700, 0x313c, 0x0000 },

-  { 0x8700, 0x313f, 0x2000 },

-  { 0x0700, 0x313e, 0x0000 },

-  { 0x0700, 0x3140, 0x0000 },

-  { 0x8700, 0x3145, 0x3000 },

-  { 0x8700, 0x3143, 0x2000 },

-  { 0x0700, 0x3142, 0x0000 },

-  { 0x0700, 0x3144, 0x0000 },

-  { 0x8700, 0x3147, 0x2000 },

-  { 0x0700, 0x3146, 0x0000 },

-  { 0x0700, 0x3148, 0x0000 },

-  { 0x9a00, 0x3290, 0x9000 },

-  { 0x9a00, 0x3202, 0x8000 },

-  { 0x8700, 0x3189, 0x7000 },

-  { 0x8700, 0x3169, 0x6000 },

-  { 0x8700, 0x3159, 0x5000 },

-  { 0x8700, 0x3151, 0x4000 },

-  { 0x8700, 0x314d, 0x3000 },

-  { 0x8700, 0x314b, 0x2000 },

-  { 0x0700, 0x314a, 0x0000 },

-  { 0x0700, 0x314c, 0x0000 },

-  { 0x8700, 0x314f, 0x2000 },

-  { 0x0700, 0x314e, 0x0000 },

-  { 0x0700, 0x3150, 0x0000 },

-  { 0x8700, 0x3155, 0x3000 },

-  { 0x8700, 0x3153, 0x2000 },

-  { 0x0700, 0x3152, 0x0000 },

-  { 0x0700, 0x3154, 0x0000 },

-  { 0x8700, 0x3157, 0x2000 },

-  { 0x0700, 0x3156, 0x0000 },

-  { 0x0700, 0x3158, 0x0000 },

-  { 0x8700, 0x3161, 0x4000 },

-  { 0x8700, 0x315d, 0x3000 },

-  { 0x8700, 0x315b, 0x2000 },

-  { 0x0700, 0x315a, 0x0000 },

-  { 0x0700, 0x315c, 0x0000 },

-  { 0x8700, 0x315f, 0x2000 },

-  { 0x0700, 0x315e, 0x0000 },

-  { 0x0700, 0x3160, 0x0000 },

-  { 0x8700, 0x3165, 0x3000 },

-  { 0x8700, 0x3163, 0x2000 },

-  { 0x0700, 0x3162, 0x0000 },

-  { 0x0700, 0x3164, 0x0000 },

-  { 0x8700, 0x3167, 0x2000 },

-  { 0x0700, 0x3166, 0x0000 },

-  { 0x0700, 0x3168, 0x0000 },

-  { 0x8700, 0x3179, 0x5000 },

-  { 0x8700, 0x3171, 0x4000 },

-  { 0x8700, 0x316d, 0x3000 },

-  { 0x8700, 0x316b, 0x2000 },

-  { 0x0700, 0x316a, 0x0000 },

-  { 0x0700, 0x316c, 0x0000 },

-  { 0x8700, 0x316f, 0x2000 },

-  { 0x0700, 0x316e, 0x0000 },

-  { 0x0700, 0x3170, 0x0000 },

-  { 0x8700, 0x3175, 0x3000 },

-  { 0x8700, 0x3173, 0x2000 },

-  { 0x0700, 0x3172, 0x0000 },

-  { 0x0700, 0x3174, 0x0000 },

-  { 0x8700, 0x3177, 0x2000 },

-  { 0x0700, 0x3176, 0x0000 },

-  { 0x0700, 0x3178, 0x0000 },

-  { 0x8700, 0x3181, 0x4000 },

-  { 0x8700, 0x317d, 0x3000 },

-  { 0x8700, 0x317b, 0x2000 },

-  { 0x0700, 0x317a, 0x0000 },

-  { 0x0700, 0x317c, 0x0000 },

-  { 0x8700, 0x317f, 0x2000 },

-  { 0x0700, 0x317e, 0x0000 },

-  { 0x0700, 0x3180, 0x0000 },

-  { 0x8700, 0x3185, 0x3000 },

-  { 0x8700, 0x3183, 0x2000 },

-  { 0x0700, 0x3182, 0x0000 },

-  { 0x0700, 0x3184, 0x0000 },

-  { 0x8700, 0x3187, 0x2000 },

-  { 0x0700, 0x3186, 0x0000 },

-  { 0x0700, 0x3188, 0x0000 },

-  { 0x8700, 0x31aa, 0x6000 },

-  { 0x9a00, 0x319a, 0x5000 },

-  { 0x8f00, 0x3192, 0x4000 },

-  { 0x8700, 0x318d, 0x3000 },

-  { 0x8700, 0x318b, 0x2000 },

-  { 0x0700, 0x318a, 0x0000 },

-  { 0x0700, 0x318c, 0x0000 },

-  { 0x9a00, 0x3190, 0x2000 },

-  { 0x0700, 0x318e, 0x0000 },

-  { 0x1a00, 0x3191, 0x0000 },

-  { 0x9a00, 0x3196, 0x3000 },

-  { 0x8f00, 0x3194, 0x2000 },

-  { 0x0f00, 0x3193, 0x0000 },

-  { 0x0f00, 0x3195, 0x0000 },

-  { 0x9a00, 0x3198, 0x2000 },

-  { 0x1a00, 0x3197, 0x0000 },

-  { 0x1a00, 0x3199, 0x0000 },

-  { 0x8700, 0x31a2, 0x4000 },

-  { 0x9a00, 0x319e, 0x3000 },

-  { 0x9a00, 0x319c, 0x2000 },

-  { 0x1a00, 0x319b, 0x0000 },

-  { 0x1a00, 0x319d, 0x0000 },

-  { 0x8700, 0x31a0, 0x2000 },

-  { 0x1a00, 0x319f, 0x0000 },

-  { 0x0700, 0x31a1, 0x0000 },

-  { 0x8700, 0x31a6, 0x3000 },

-  { 0x8700, 0x31a4, 0x2000 },

-  { 0x0700, 0x31a3, 0x0000 },

-  { 0x0700, 0x31a5, 0x0000 },

-  { 0x8700, 0x31a8, 0x2000 },

-  { 0x0700, 0x31a7, 0x0000 },

-  { 0x0700, 0x31a9, 0x0000 },

-  { 0x8700, 0x31f2, 0x5000 },

-  { 0x8700, 0x31b2, 0x4000 },

-  { 0x8700, 0x31ae, 0x3000 },

-  { 0x8700, 0x31ac, 0x2000 },

-  { 0x0700, 0x31ab, 0x0000 },

-  { 0x0700, 0x31ad, 0x0000 },

-  { 0x8700, 0x31b0, 0x2000 },

-  { 0x0700, 0x31af, 0x0000 },

-  { 0x0700, 0x31b1, 0x0000 },

-  { 0x8700, 0x31b6, 0x3000 },

-  { 0x8700, 0x31b4, 0x2000 },

-  { 0x0700, 0x31b3, 0x0000 },

-  { 0x0700, 0x31b5, 0x0000 },

-  { 0x8700, 0x31f0, 0x2000 },

-  { 0x0700, 0x31b7, 0x0000 },

-  { 0x0700, 0x31f1, 0x0000 },

-  { 0x8700, 0x31fa, 0x4000 },

-  { 0x8700, 0x31f6, 0x3000 },

-  { 0x8700, 0x31f4, 0x2000 },

-  { 0x0700, 0x31f3, 0x0000 },

-  { 0x0700, 0x31f5, 0x0000 },

-  { 0x8700, 0x31f8, 0x2000 },

-  { 0x0700, 0x31f7, 0x0000 },

-  { 0x0700, 0x31f9, 0x0000 },

-  { 0x8700, 0x31fe, 0x3000 },

-  { 0x8700, 0x31fc, 0x2000 },

-  { 0x0700, 0x31fb, 0x0000 },

-  { 0x0700, 0x31fd, 0x0000 },

-  { 0x9a00, 0x3200, 0x2000 },

-  { 0x0700, 0x31ff, 0x0000 },

-  { 0x1a00, 0x3201, 0x0000 },

-  { 0x9a00, 0x3243, 0x7000 },

-  { 0x8f00, 0x3223, 0x6000 },

-  { 0x9a00, 0x3212, 0x5000 },

-  { 0x9a00, 0x320a, 0x4000 },

-  { 0x9a00, 0x3206, 0x3000 },

-  { 0x9a00, 0x3204, 0x2000 },

-  { 0x1a00, 0x3203, 0x0000 },

-  { 0x1a00, 0x3205, 0x0000 },

-  { 0x9a00, 0x3208, 0x2000 },

-  { 0x1a00, 0x3207, 0x0000 },

-  { 0x1a00, 0x3209, 0x0000 },

-  { 0x9a00, 0x320e, 0x3000 },

-  { 0x9a00, 0x320c, 0x2000 },

-  { 0x1a00, 0x320b, 0x0000 },

-  { 0x1a00, 0x320d, 0x0000 },

-  { 0x9a00, 0x3210, 0x2000 },

-  { 0x1a00, 0x320f, 0x0000 },

-  { 0x1a00, 0x3211, 0x0000 },

-  { 0x9a00, 0x321a, 0x4000 },

-  { 0x9a00, 0x3216, 0x3000 },

-  { 0x9a00, 0x3214, 0x2000 },

-  { 0x1a00, 0x3213, 0x0000 },

-  { 0x1a00, 0x3215, 0x0000 },

-  { 0x9a00, 0x3218, 0x2000 },

-  { 0x1a00, 0x3217, 0x0000 },

-  { 0x1a00, 0x3219, 0x0000 },

-  { 0x9a00, 0x321e, 0x3000 },

-  { 0x9a00, 0x321c, 0x2000 },

-  { 0x1a00, 0x321b, 0x0000 },

-  { 0x1a00, 0x321d, 0x0000 },

-  { 0x8f00, 0x3221, 0x2000 },

-  { 0x0f00, 0x3220, 0x0000 },

-  { 0x0f00, 0x3222, 0x0000 },

-  { 0x9a00, 0x3233, 0x5000 },

-  { 0x9a00, 0x322b, 0x4000 },

-  { 0x8f00, 0x3227, 0x3000 },

-  { 0x8f00, 0x3225, 0x2000 },

-  { 0x0f00, 0x3224, 0x0000 },

-  { 0x0f00, 0x3226, 0x0000 },

-  { 0x8f00, 0x3229, 0x2000 },

-  { 0x0f00, 0x3228, 0x0000 },

-  { 0x1a00, 0x322a, 0x0000 },

-  { 0x9a00, 0x322f, 0x3000 },

-  { 0x9a00, 0x322d, 0x2000 },

-  { 0x1a00, 0x322c, 0x0000 },

-  { 0x1a00, 0x322e, 0x0000 },

-  { 0x9a00, 0x3231, 0x2000 },

-  { 0x1a00, 0x3230, 0x0000 },

-  { 0x1a00, 0x3232, 0x0000 },

-  { 0x9a00, 0x323b, 0x4000 },

-  { 0x9a00, 0x3237, 0x3000 },

-  { 0x9a00, 0x3235, 0x2000 },

-  { 0x1a00, 0x3234, 0x0000 },

-  { 0x1a00, 0x3236, 0x0000 },

-  { 0x9a00, 0x3239, 0x2000 },

-  { 0x1a00, 0x3238, 0x0000 },

-  { 0x1a00, 0x323a, 0x0000 },

-  { 0x9a00, 0x323f, 0x3000 },

-  { 0x9a00, 0x323d, 0x2000 },

-  { 0x1a00, 0x323c, 0x0000 },

-  { 0x1a00, 0x323e, 0x0000 },

-  { 0x9a00, 0x3241, 0x2000 },

-  { 0x1a00, 0x3240, 0x0000 },

-  { 0x1a00, 0x3242, 0x0000 },

-  { 0x9a00, 0x326f, 0x6000 },

-  { 0x8f00, 0x325f, 0x5000 },

-  { 0x8f00, 0x3257, 0x4000 },

-  { 0x8f00, 0x3253, 0x3000 },

-  { 0x8f00, 0x3251, 0x2000 },

-  { 0x1a00, 0x3250, 0x0000 },

-  { 0x0f00, 0x3252, 0x0000 },

-  { 0x8f00, 0x3255, 0x2000 },

-  { 0x0f00, 0x3254, 0x0000 },

-  { 0x0f00, 0x3256, 0x0000 },

-  { 0x8f00, 0x325b, 0x3000 },

-  { 0x8f00, 0x3259, 0x2000 },

-  { 0x0f00, 0x3258, 0x0000 },

-  { 0x0f00, 0x325a, 0x0000 },

-  { 0x8f00, 0x325d, 0x2000 },

-  { 0x0f00, 0x325c, 0x0000 },

-  { 0x0f00, 0x325e, 0x0000 },

-  { 0x9a00, 0x3267, 0x4000 },

-  { 0x9a00, 0x3263, 0x3000 },

-  { 0x9a00, 0x3261, 0x2000 },

-  { 0x1a00, 0x3260, 0x0000 },

-  { 0x1a00, 0x3262, 0x0000 },

-  { 0x9a00, 0x3265, 0x2000 },

-  { 0x1a00, 0x3264, 0x0000 },

-  { 0x1a00, 0x3266, 0x0000 },

-  { 0x9a00, 0x326b, 0x3000 },

-  { 0x9a00, 0x3269, 0x2000 },

-  { 0x1a00, 0x3268, 0x0000 },

-  { 0x1a00, 0x326a, 0x0000 },

-  { 0x9a00, 0x326d, 0x2000 },

-  { 0x1a00, 0x326c, 0x0000 },

-  { 0x1a00, 0x326e, 0x0000 },

-  { 0x8f00, 0x3280, 0x5000 },

-  { 0x9a00, 0x3277, 0x4000 },

-  { 0x9a00, 0x3273, 0x3000 },

-  { 0x9a00, 0x3271, 0x2000 },

-  { 0x1a00, 0x3270, 0x0000 },

-  { 0x1a00, 0x3272, 0x0000 },

-  { 0x9a00, 0x3275, 0x2000 },

-  { 0x1a00, 0x3274, 0x0000 },

-  { 0x1a00, 0x3276, 0x0000 },

-  { 0x9a00, 0x327b, 0x3000 },

-  { 0x9a00, 0x3279, 0x2000 },

-  { 0x1a00, 0x3278, 0x0000 },

-  { 0x1a00, 0x327a, 0x0000 },

-  { 0x9a00, 0x327d, 0x2000 },

-  { 0x1a00, 0x327c, 0x0000 },

-  { 0x1a00, 0x327f, 0x0000 },

-  { 0x8f00, 0x3288, 0x4000 },

-  { 0x8f00, 0x3284, 0x3000 },

-  { 0x8f00, 0x3282, 0x2000 },

-  { 0x0f00, 0x3281, 0x0000 },

-  { 0x0f00, 0x3283, 0x0000 },

-  { 0x8f00, 0x3286, 0x2000 },

-  { 0x0f00, 0x3285, 0x0000 },

-  { 0x0f00, 0x3287, 0x0000 },

-  { 0x9a00, 0x328c, 0x3000 },

-  { 0x9a00, 0x328a, 0x2000 },

-  { 0x0f00, 0x3289, 0x0000 },

-  { 0x1a00, 0x328b, 0x0000 },

-  { 0x9a00, 0x328e, 0x2000 },

-  { 0x1a00, 0x328d, 0x0000 },

-  { 0x1a00, 0x328f, 0x0000 },

-  { 0x9a00, 0x3311, 0x8000 },

-  { 0x9a00, 0x32d0, 0x7000 },

-  { 0x9a00, 0x32b0, 0x6000 },

-  { 0x9a00, 0x32a0, 0x5000 },

-  { 0x9a00, 0x3298, 0x4000 },

-  { 0x9a00, 0x3294, 0x3000 },

-  { 0x9a00, 0x3292, 0x2000 },

-  { 0x1a00, 0x3291, 0x0000 },

-  { 0x1a00, 0x3293, 0x0000 },

-  { 0x9a00, 0x3296, 0x2000 },

-  { 0x1a00, 0x3295, 0x0000 },

-  { 0x1a00, 0x3297, 0x0000 },

-  { 0x9a00, 0x329c, 0x3000 },

-  { 0x9a00, 0x329a, 0x2000 },

-  { 0x1a00, 0x3299, 0x0000 },

-  { 0x1a00, 0x329b, 0x0000 },

-  { 0x9a00, 0x329e, 0x2000 },

-  { 0x1a00, 0x329d, 0x0000 },

-  { 0x1a00, 0x329f, 0x0000 },

-  { 0x9a00, 0x32a8, 0x4000 },

-  { 0x9a00, 0x32a4, 0x3000 },

-  { 0x9a00, 0x32a2, 0x2000 },

-  { 0x1a00, 0x32a1, 0x0000 },

-  { 0x1a00, 0x32a3, 0x0000 },

-  { 0x9a00, 0x32a6, 0x2000 },

-  { 0x1a00, 0x32a5, 0x0000 },

-  { 0x1a00, 0x32a7, 0x0000 },

-  { 0x9a00, 0x32ac, 0x3000 },

-  { 0x9a00, 0x32aa, 0x2000 },

-  { 0x1a00, 0x32a9, 0x0000 },

-  { 0x1a00, 0x32ab, 0x0000 },

-  { 0x9a00, 0x32ae, 0x2000 },

-  { 0x1a00, 0x32ad, 0x0000 },

-  { 0x1a00, 0x32af, 0x0000 },

-  { 0x9a00, 0x32c0, 0x5000 },

-  { 0x8f00, 0x32b8, 0x4000 },

-  { 0x8f00, 0x32b4, 0x3000 },

-  { 0x8f00, 0x32b2, 0x2000 },

-  { 0x0f00, 0x32b1, 0x0000 },

-  { 0x0f00, 0x32b3, 0x0000 },

-  { 0x8f00, 0x32b6, 0x2000 },

-  { 0x0f00, 0x32b5, 0x0000 },

-  { 0x0f00, 0x32b7, 0x0000 },

-  { 0x8f00, 0x32bc, 0x3000 },

-  { 0x8f00, 0x32ba, 0x2000 },

-  { 0x0f00, 0x32b9, 0x0000 },

-  { 0x0f00, 0x32bb, 0x0000 },

-  { 0x8f00, 0x32be, 0x2000 },

-  { 0x0f00, 0x32bd, 0x0000 },

-  { 0x0f00, 0x32bf, 0x0000 },

-  { 0x9a00, 0x32c8, 0x4000 },

-  { 0x9a00, 0x32c4, 0x3000 },

-  { 0x9a00, 0x32c2, 0x2000 },

-  { 0x1a00, 0x32c1, 0x0000 },

-  { 0x1a00, 0x32c3, 0x0000 },

-  { 0x9a00, 0x32c6, 0x2000 },

-  { 0x1a00, 0x32c5, 0x0000 },

-  { 0x1a00, 0x32c7, 0x0000 },

-  { 0x9a00, 0x32cc, 0x3000 },

-  { 0x9a00, 0x32ca, 0x2000 },

-  { 0x1a00, 0x32c9, 0x0000 },

-  { 0x1a00, 0x32cb, 0x0000 },

-  { 0x9a00, 0x32ce, 0x2000 },

-  { 0x1a00, 0x32cd, 0x0000 },

-  { 0x1a00, 0x32cf, 0x0000 },

-  { 0x9a00, 0x32f0, 0x6000 },

-  { 0x9a00, 0x32e0, 0x5000 },

-  { 0x9a00, 0x32d8, 0x4000 },

-  { 0x9a00, 0x32d4, 0x3000 },

-  { 0x9a00, 0x32d2, 0x2000 },

-  { 0x1a00, 0x32d1, 0x0000 },

-  { 0x1a00, 0x32d3, 0x0000 },

-  { 0x9a00, 0x32d6, 0x2000 },

-  { 0x1a00, 0x32d5, 0x0000 },

-  { 0x1a00, 0x32d7, 0x0000 },

-  { 0x9a00, 0x32dc, 0x3000 },

-  { 0x9a00, 0x32da, 0x2000 },

-  { 0x1a00, 0x32d9, 0x0000 },

-  { 0x1a00, 0x32db, 0x0000 },

-  { 0x9a00, 0x32de, 0x2000 },

-  { 0x1a00, 0x32dd, 0x0000 },

-  { 0x1a00, 0x32df, 0x0000 },

-  { 0x9a00, 0x32e8, 0x4000 },

-  { 0x9a00, 0x32e4, 0x3000 },

-  { 0x9a00, 0x32e2, 0x2000 },

-  { 0x1a00, 0x32e1, 0x0000 },

-  { 0x1a00, 0x32e3, 0x0000 },

-  { 0x9a00, 0x32e6, 0x2000 },

-  { 0x1a00, 0x32e5, 0x0000 },

-  { 0x1a00, 0x32e7, 0x0000 },

-  { 0x9a00, 0x32ec, 0x3000 },

-  { 0x9a00, 0x32ea, 0x2000 },

-  { 0x1a00, 0x32e9, 0x0000 },

-  { 0x1a00, 0x32eb, 0x0000 },

-  { 0x9a00, 0x32ee, 0x2000 },

-  { 0x1a00, 0x32ed, 0x0000 },

-  { 0x1a00, 0x32ef, 0x0000 },

-  { 0x9a00, 0x3301, 0x5000 },

-  { 0x9a00, 0x32f8, 0x4000 },

-  { 0x9a00, 0x32f4, 0x3000 },

-  { 0x9a00, 0x32f2, 0x2000 },

-  { 0x1a00, 0x32f1, 0x0000 },

-  { 0x1a00, 0x32f3, 0x0000 },

-  { 0x9a00, 0x32f6, 0x2000 },

-  { 0x1a00, 0x32f5, 0x0000 },

-  { 0x1a00, 0x32f7, 0x0000 },

-  { 0x9a00, 0x32fc, 0x3000 },

-  { 0x9a00, 0x32fa, 0x2000 },

-  { 0x1a00, 0x32f9, 0x0000 },

-  { 0x1a00, 0x32fb, 0x0000 },

-  { 0x9a00, 0x32fe, 0x2000 },

-  { 0x1a00, 0x32fd, 0x0000 },

-  { 0x1a00, 0x3300, 0x0000 },

-  { 0x9a00, 0x3309, 0x4000 },

-  { 0x9a00, 0x3305, 0x3000 },

-  { 0x9a00, 0x3303, 0x2000 },

-  { 0x1a00, 0x3302, 0x0000 },

-  { 0x1a00, 0x3304, 0x0000 },

-  { 0x9a00, 0x3307, 0x2000 },

-  { 0x1a00, 0x3306, 0x0000 },

-  { 0x1a00, 0x3308, 0x0000 },

-  { 0x9a00, 0x330d, 0x3000 },

-  { 0x9a00, 0x330b, 0x2000 },

-  { 0x1a00, 0x330a, 0x0000 },

-  { 0x1a00, 0x330c, 0x0000 },

-  { 0x9a00, 0x330f, 0x2000 },

-  { 0x1a00, 0x330e, 0x0000 },

-  { 0x1a00, 0x3310, 0x0000 },

-  { 0x9a00, 0x3351, 0x7000 },

-  { 0x9a00, 0x3331, 0x6000 },

-  { 0x9a00, 0x3321, 0x5000 },

-  { 0x9a00, 0x3319, 0x4000 },

-  { 0x9a00, 0x3315, 0x3000 },

-  { 0x9a00, 0x3313, 0x2000 },

-  { 0x1a00, 0x3312, 0x0000 },

-  { 0x1a00, 0x3314, 0x0000 },

-  { 0x9a00, 0x3317, 0x2000 },

-  { 0x1a00, 0x3316, 0x0000 },

-  { 0x1a00, 0x3318, 0x0000 },

-  { 0x9a00, 0x331d, 0x3000 },

-  { 0x9a00, 0x331b, 0x2000 },

-  { 0x1a00, 0x331a, 0x0000 },

-  { 0x1a00, 0x331c, 0x0000 },

-  { 0x9a00, 0x331f, 0x2000 },

-  { 0x1a00, 0x331e, 0x0000 },

-  { 0x1a00, 0x3320, 0x0000 },

-  { 0x9a00, 0x3329, 0x4000 },

-  { 0x9a00, 0x3325, 0x3000 },

-  { 0x9a00, 0x3323, 0x2000 },

-  { 0x1a00, 0x3322, 0x0000 },

-  { 0x1a00, 0x3324, 0x0000 },

-  { 0x9a00, 0x3327, 0x2000 },

-  { 0x1a00, 0x3326, 0x0000 },

-  { 0x1a00, 0x3328, 0x0000 },

-  { 0x9a00, 0x332d, 0x3000 },

-  { 0x9a00, 0x332b, 0x2000 },

-  { 0x1a00, 0x332a, 0x0000 },

-  { 0x1a00, 0x332c, 0x0000 },

-  { 0x9a00, 0x332f, 0x2000 },

-  { 0x1a00, 0x332e, 0x0000 },

-  { 0x1a00, 0x3330, 0x0000 },

-  { 0x9a00, 0x3341, 0x5000 },

-  { 0x9a00, 0x3339, 0x4000 },

-  { 0x9a00, 0x3335, 0x3000 },

-  { 0x9a00, 0x3333, 0x2000 },

-  { 0x1a00, 0x3332, 0x0000 },

-  { 0x1a00, 0x3334, 0x0000 },

-  { 0x9a00, 0x3337, 0x2000 },

-  { 0x1a00, 0x3336, 0x0000 },

-  { 0x1a00, 0x3338, 0x0000 },

-  { 0x9a00, 0x333d, 0x3000 },

-  { 0x9a00, 0x333b, 0x2000 },

-  { 0x1a00, 0x333a, 0x0000 },

-  { 0x1a00, 0x333c, 0x0000 },

-  { 0x9a00, 0x333f, 0x2000 },

-  { 0x1a00, 0x333e, 0x0000 },

-  { 0x1a00, 0x3340, 0x0000 },

-  { 0x9a00, 0x3349, 0x4000 },

-  { 0x9a00, 0x3345, 0x3000 },

-  { 0x9a00, 0x3343, 0x2000 },

-  { 0x1a00, 0x3342, 0x0000 },

-  { 0x1a00, 0x3344, 0x0000 },

-  { 0x9a00, 0x3347, 0x2000 },

-  { 0x1a00, 0x3346, 0x0000 },

-  { 0x1a00, 0x3348, 0x0000 },

-  { 0x9a00, 0x334d, 0x3000 },

-  { 0x9a00, 0x334b, 0x2000 },

-  { 0x1a00, 0x334a, 0x0000 },

-  { 0x1a00, 0x334c, 0x0000 },

-  { 0x9a00, 0x334f, 0x2000 },

-  { 0x1a00, 0x334e, 0x0000 },

-  { 0x1a00, 0x3350, 0x0000 },

-  { 0x9a00, 0x3371, 0x6000 },

-  { 0x9a00, 0x3361, 0x5000 },

-  { 0x9a00, 0x3359, 0x4000 },

-  { 0x9a00, 0x3355, 0x3000 },

-  { 0x9a00, 0x3353, 0x2000 },

-  { 0x1a00, 0x3352, 0x0000 },

-  { 0x1a00, 0x3354, 0x0000 },

-  { 0x9a00, 0x3357, 0x2000 },

-  { 0x1a00, 0x3356, 0x0000 },

-  { 0x1a00, 0x3358, 0x0000 },

-  { 0x9a00, 0x335d, 0x3000 },

-  { 0x9a00, 0x335b, 0x2000 },

-  { 0x1a00, 0x335a, 0x0000 },

-  { 0x1a00, 0x335c, 0x0000 },

-  { 0x9a00, 0x335f, 0x2000 },

-  { 0x1a00, 0x335e, 0x0000 },

-  { 0x1a00, 0x3360, 0x0000 },

-  { 0x9a00, 0x3369, 0x4000 },

-  { 0x9a00, 0x3365, 0x3000 },

-  { 0x9a00, 0x3363, 0x2000 },

-  { 0x1a00, 0x3362, 0x0000 },

-  { 0x1a00, 0x3364, 0x0000 },

-  { 0x9a00, 0x3367, 0x2000 },

-  { 0x1a00, 0x3366, 0x0000 },

-  { 0x1a00, 0x3368, 0x0000 },

-  { 0x9a00, 0x336d, 0x3000 },

-  { 0x9a00, 0x336b, 0x2000 },

-  { 0x1a00, 0x336a, 0x0000 },

-  { 0x1a00, 0x336c, 0x0000 },

-  { 0x9a00, 0x336f, 0x2000 },

-  { 0x1a00, 0x336e, 0x0000 },

-  { 0x1a00, 0x3370, 0x0000 },

-  { 0x9a00, 0x3381, 0x5000 },

-  { 0x9a00, 0x3379, 0x4000 },

-  { 0x9a00, 0x3375, 0x3000 },

-  { 0x9a00, 0x3373, 0x2000 },

-  { 0x1a00, 0x3372, 0x0000 },

-  { 0x1a00, 0x3374, 0x0000 },

-  { 0x9a00, 0x3377, 0x2000 },

-  { 0x1a00, 0x3376, 0x0000 },

-  { 0x1a00, 0x3378, 0x0000 },

-  { 0x9a00, 0x337d, 0x3000 },

-  { 0x9a00, 0x337b, 0x2000 },

-  { 0x1a00, 0x337a, 0x0000 },

-  { 0x1a00, 0x337c, 0x0000 },

-  { 0x9a00, 0x337f, 0x2000 },

-  { 0x1a00, 0x337e, 0x0000 },

-  { 0x1a00, 0x3380, 0x0000 },

-  { 0x9a00, 0x3389, 0x4000 },

-  { 0x9a00, 0x3385, 0x3000 },

-  { 0x9a00, 0x3383, 0x2000 },

-  { 0x1a00, 0x3382, 0x0000 },

-  { 0x1a00, 0x3384, 0x0000 },

-  { 0x9a00, 0x3387, 0x2000 },

-  { 0x1a00, 0x3386, 0x0000 },

-  { 0x1a00, 0x3388, 0x0000 },

-  { 0x9a00, 0x338d, 0x3000 },

-  { 0x9a00, 0x338b, 0x2000 },

-  { 0x1a00, 0x338a, 0x0000 },

-  { 0x1a00, 0x338c, 0x0000 },

-  { 0x9a00, 0x338f, 0x2000 },

-  { 0x1a00, 0x338e, 0x0000 },

-  { 0x1a00, 0x3390, 0x0000 },

-  { 0x8700, 0xa14d, 0xa000 },

-  { 0x8700, 0xa04d, 0x9000 },

-  { 0x9a00, 0x4dcf, 0x8000 },

-  { 0x9a00, 0x33d1, 0x7000 },

-  { 0x9a00, 0x33b1, 0x6000 },

-  { 0x9a00, 0x33a1, 0x5000 },

-  { 0x9a00, 0x3399, 0x4000 },

-  { 0x9a00, 0x3395, 0x3000 },

-  { 0x9a00, 0x3393, 0x2000 },

-  { 0x1a00, 0x3392, 0x0000 },

-  { 0x1a00, 0x3394, 0x0000 },

-  { 0x9a00, 0x3397, 0x2000 },

-  { 0x1a00, 0x3396, 0x0000 },

-  { 0x1a00, 0x3398, 0x0000 },

-  { 0x9a00, 0x339d, 0x3000 },

-  { 0x9a00, 0x339b, 0x2000 },

-  { 0x1a00, 0x339a, 0x0000 },

-  { 0x1a00, 0x339c, 0x0000 },

-  { 0x9a00, 0x339f, 0x2000 },

-  { 0x1a00, 0x339e, 0x0000 },

-  { 0x1a00, 0x33a0, 0x0000 },

-  { 0x9a00, 0x33a9, 0x4000 },

-  { 0x9a00, 0x33a5, 0x3000 },

-  { 0x9a00, 0x33a3, 0x2000 },

-  { 0x1a00, 0x33a2, 0x0000 },

-  { 0x1a00, 0x33a4, 0x0000 },

-  { 0x9a00, 0x33a7, 0x2000 },

-  { 0x1a00, 0x33a6, 0x0000 },

-  { 0x1a00, 0x33a8, 0x0000 },

-  { 0x9a00, 0x33ad, 0x3000 },

-  { 0x9a00, 0x33ab, 0x2000 },

-  { 0x1a00, 0x33aa, 0x0000 },

-  { 0x1a00, 0x33ac, 0x0000 },

-  { 0x9a00, 0x33af, 0x2000 },

-  { 0x1a00, 0x33ae, 0x0000 },

-  { 0x1a00, 0x33b0, 0x0000 },

-  { 0x9a00, 0x33c1, 0x5000 },

-  { 0x9a00, 0x33b9, 0x4000 },

-  { 0x9a00, 0x33b5, 0x3000 },

-  { 0x9a00, 0x33b3, 0x2000 },

-  { 0x1a00, 0x33b2, 0x0000 },

-  { 0x1a00, 0x33b4, 0x0000 },

-  { 0x9a00, 0x33b7, 0x2000 },

-  { 0x1a00, 0x33b6, 0x0000 },

-  { 0x1a00, 0x33b8, 0x0000 },

-  { 0x9a00, 0x33bd, 0x3000 },

-  { 0x9a00, 0x33bb, 0x2000 },

-  { 0x1a00, 0x33ba, 0x0000 },

-  { 0x1a00, 0x33bc, 0x0000 },

-  { 0x9a00, 0x33bf, 0x2000 },

-  { 0x1a00, 0x33be, 0x0000 },

-  { 0x1a00, 0x33c0, 0x0000 },

-  { 0x9a00, 0x33c9, 0x4000 },

-  { 0x9a00, 0x33c5, 0x3000 },

-  { 0x9a00, 0x33c3, 0x2000 },

-  { 0x1a00, 0x33c2, 0x0000 },

-  { 0x1a00, 0x33c4, 0x0000 },

-  { 0x9a00, 0x33c7, 0x2000 },

-  { 0x1a00, 0x33c6, 0x0000 },

-  { 0x1a00, 0x33c8, 0x0000 },

-  { 0x9a00, 0x33cd, 0x3000 },

-  { 0x9a00, 0x33cb, 0x2000 },

-  { 0x1a00, 0x33ca, 0x0000 },

-  { 0x1a00, 0x33cc, 0x0000 },

-  { 0x9a00, 0x33cf, 0x2000 },

-  { 0x1a00, 0x33ce, 0x0000 },

-  { 0x1a00, 0x33d0, 0x0000 },

-  { 0x9a00, 0x33f1, 0x6000 },

-  { 0x9a00, 0x33e1, 0x5000 },

-  { 0x9a00, 0x33d9, 0x4000 },

-  { 0x9a00, 0x33d5, 0x3000 },

-  { 0x9a00, 0x33d3, 0x2000 },

-  { 0x1a00, 0x33d2, 0x0000 },

-  { 0x1a00, 0x33d4, 0x0000 },

-  { 0x9a00, 0x33d7, 0x2000 },

-  { 0x1a00, 0x33d6, 0x0000 },

-  { 0x1a00, 0x33d8, 0x0000 },

-  { 0x9a00, 0x33dd, 0x3000 },

-  { 0x9a00, 0x33db, 0x2000 },

-  { 0x1a00, 0x33da, 0x0000 },

-  { 0x1a00, 0x33dc, 0x0000 },

-  { 0x9a00, 0x33df, 0x2000 },

-  { 0x1a00, 0x33de, 0x0000 },

-  { 0x1a00, 0x33e0, 0x0000 },

-  { 0x9a00, 0x33e9, 0x4000 },

-  { 0x9a00, 0x33e5, 0x3000 },

-  { 0x9a00, 0x33e3, 0x2000 },

-  { 0x1a00, 0x33e2, 0x0000 },

-  { 0x1a00, 0x33e4, 0x0000 },

-  { 0x9a00, 0x33e7, 0x2000 },

-  { 0x1a00, 0x33e6, 0x0000 },

-  { 0x1a00, 0x33e8, 0x0000 },

-  { 0x9a00, 0x33ed, 0x3000 },

-  { 0x9a00, 0x33eb, 0x2000 },

-  { 0x1a00, 0x33ea, 0x0000 },

-  { 0x1a00, 0x33ec, 0x0000 },

-  { 0x9a00, 0x33ef, 0x2000 },

-  { 0x1a00, 0x33ee, 0x0000 },

-  { 0x1a00, 0x33f0, 0x0000 },

-  { 0x8700, 0x4db5, 0x5000 },

-  { 0x9a00, 0x33f9, 0x4000 },

-  { 0x9a00, 0x33f5, 0x3000 },

-  { 0x9a00, 0x33f3, 0x2000 },

-  { 0x1a00, 0x33f2, 0x0000 },

-  { 0x1a00, 0x33f4, 0x0000 },

-  { 0x9a00, 0x33f7, 0x2000 },

-  { 0x1a00, 0x33f6, 0x0000 },

-  { 0x1a00, 0x33f8, 0x0000 },

-  { 0x9a00, 0x33fd, 0x3000 },

-  { 0x9a00, 0x33fb, 0x2000 },

-  { 0x1a00, 0x33fa, 0x0000 },

-  { 0x1a00, 0x33fc, 0x0000 },

-  { 0x9a00, 0x33ff, 0x2000 },

-  { 0x1a00, 0x33fe, 0x0000 },

-  { 0x0700, 0x3400, 0x0000 },

-  { 0x9a00, 0x4dc7, 0x4000 },

-  { 0x9a00, 0x4dc3, 0x3000 },

-  { 0x9a00, 0x4dc1, 0x2000 },

-  { 0x1a00, 0x4dc0, 0x0000 },

-  { 0x1a00, 0x4dc2, 0x0000 },

-  { 0x9a00, 0x4dc5, 0x2000 },

-  { 0x1a00, 0x4dc4, 0x0000 },

-  { 0x1a00, 0x4dc6, 0x0000 },

-  { 0x9a00, 0x4dcb, 0x3000 },

-  { 0x9a00, 0x4dc9, 0x2000 },

-  { 0x1a00, 0x4dc8, 0x0000 },

-  { 0x1a00, 0x4dca, 0x0000 },

-  { 0x9a00, 0x4dcd, 0x2000 },

-  { 0x1a00, 0x4dcc, 0x0000 },

-  { 0x1a00, 0x4dce, 0x0000 },

-  { 0x8700, 0xa00d, 0x7000 },

-  { 0x9a00, 0x4def, 0x6000 },

-  { 0x9a00, 0x4ddf, 0x5000 },

-  { 0x9a00, 0x4dd7, 0x4000 },

-  { 0x9a00, 0x4dd3, 0x3000 },

-  { 0x9a00, 0x4dd1, 0x2000 },

-  { 0x1a00, 0x4dd0, 0x0000 },

-  { 0x1a00, 0x4dd2, 0x0000 },

-  { 0x9a00, 0x4dd5, 0x2000 },

-  { 0x1a00, 0x4dd4, 0x0000 },

-  { 0x1a00, 0x4dd6, 0x0000 },

-  { 0x9a00, 0x4ddb, 0x3000 },

-  { 0x9a00, 0x4dd9, 0x2000 },

-  { 0x1a00, 0x4dd8, 0x0000 },

-  { 0x1a00, 0x4dda, 0x0000 },

-  { 0x9a00, 0x4ddd, 0x2000 },

-  { 0x1a00, 0x4ddc, 0x0000 },

-  { 0x1a00, 0x4dde, 0x0000 },

-  { 0x9a00, 0x4de7, 0x4000 },

-  { 0x9a00, 0x4de3, 0x3000 },

-  { 0x9a00, 0x4de1, 0x2000 },

-  { 0x1a00, 0x4de0, 0x0000 },

-  { 0x1a00, 0x4de2, 0x0000 },

-  { 0x9a00, 0x4de5, 0x2000 },

-  { 0x1a00, 0x4de4, 0x0000 },

-  { 0x1a00, 0x4de6, 0x0000 },

-  { 0x9a00, 0x4deb, 0x3000 },

-  { 0x9a00, 0x4de9, 0x2000 },

-  { 0x1a00, 0x4de8, 0x0000 },

-  { 0x1a00, 0x4dea, 0x0000 },

-  { 0x9a00, 0x4ded, 0x2000 },

-  { 0x1a00, 0x4dec, 0x0000 },

-  { 0x1a00, 0x4dee, 0x0000 },

-  { 0x9a00, 0x4dff, 0x5000 },

-  { 0x9a00, 0x4df7, 0x4000 },

-  { 0x9a00, 0x4df3, 0x3000 },

-  { 0x9a00, 0x4df1, 0x2000 },

-  { 0x1a00, 0x4df0, 0x0000 },

-  { 0x1a00, 0x4df2, 0x0000 },

-  { 0x9a00, 0x4df5, 0x2000 },

-  { 0x1a00, 0x4df4, 0x0000 },

-  { 0x1a00, 0x4df6, 0x0000 },

-  { 0x9a00, 0x4dfb, 0x3000 },

-  { 0x9a00, 0x4df9, 0x2000 },

-  { 0x1a00, 0x4df8, 0x0000 },

-  { 0x1a00, 0x4dfa, 0x0000 },

-  { 0x9a00, 0x4dfd, 0x2000 },

-  { 0x1a00, 0x4dfc, 0x0000 },

-  { 0x1a00, 0x4dfe, 0x0000 },

-  { 0x8700, 0xa005, 0x4000 },

-  { 0x8700, 0xa001, 0x3000 },

-  { 0x8700, 0x9fa5, 0x2000 },

-  { 0x0700, 0x4e00, 0x0000 },

-  { 0x0700, 0xa000, 0x0000 },

-  { 0x8700, 0xa003, 0x2000 },

-  { 0x0700, 0xa002, 0x0000 },

-  { 0x0700, 0xa004, 0x0000 },

-  { 0x8700, 0xa009, 0x3000 },

-  { 0x8700, 0xa007, 0x2000 },

-  { 0x0700, 0xa006, 0x0000 },

-  { 0x0700, 0xa008, 0x0000 },

-  { 0x8700, 0xa00b, 0x2000 },

-  { 0x0700, 0xa00a, 0x0000 },

-  { 0x0700, 0xa00c, 0x0000 },

-  { 0x8700, 0xa02d, 0x6000 },

-  { 0x8700, 0xa01d, 0x5000 },

-  { 0x8700, 0xa015, 0x4000 },

-  { 0x8700, 0xa011, 0x3000 },

-  { 0x8700, 0xa00f, 0x2000 },

-  { 0x0700, 0xa00e, 0x0000 },

-  { 0x0700, 0xa010, 0x0000 },

-  { 0x8700, 0xa013, 0x2000 },

-  { 0x0700, 0xa012, 0x0000 },

-  { 0x0700, 0xa014, 0x0000 },

-  { 0x8700, 0xa019, 0x3000 },

-  { 0x8700, 0xa017, 0x2000 },

-  { 0x0700, 0xa016, 0x0000 },

-  { 0x0700, 0xa018, 0x0000 },

-  { 0x8700, 0xa01b, 0x2000 },

-  { 0x0700, 0xa01a, 0x0000 },

-  { 0x0700, 0xa01c, 0x0000 },

-  { 0x8700, 0xa025, 0x4000 },

-  { 0x8700, 0xa021, 0x3000 },

-  { 0x8700, 0xa01f, 0x2000 },

-  { 0x0700, 0xa01e, 0x0000 },

-  { 0x0700, 0xa020, 0x0000 },

-  { 0x8700, 0xa023, 0x2000 },

-  { 0x0700, 0xa022, 0x0000 },

-  { 0x0700, 0xa024, 0x0000 },

-  { 0x8700, 0xa029, 0x3000 },

-  { 0x8700, 0xa027, 0x2000 },

-  { 0x0700, 0xa026, 0x0000 },

-  { 0x0700, 0xa028, 0x0000 },

-  { 0x8700, 0xa02b, 0x2000 },

-  { 0x0700, 0xa02a, 0x0000 },

-  { 0x0700, 0xa02c, 0x0000 },

-  { 0x8700, 0xa03d, 0x5000 },

-  { 0x8700, 0xa035, 0x4000 },

-  { 0x8700, 0xa031, 0x3000 },

-  { 0x8700, 0xa02f, 0x2000 },

-  { 0x0700, 0xa02e, 0x0000 },

-  { 0x0700, 0xa030, 0x0000 },

-  { 0x8700, 0xa033, 0x2000 },

-  { 0x0700, 0xa032, 0x0000 },

-  { 0x0700, 0xa034, 0x0000 },

-  { 0x8700, 0xa039, 0x3000 },

-  { 0x8700, 0xa037, 0x2000 },

-  { 0x0700, 0xa036, 0x0000 },

-  { 0x0700, 0xa038, 0x0000 },

-  { 0x8700, 0xa03b, 0x2000 },

-  { 0x0700, 0xa03a, 0x0000 },

-  { 0x0700, 0xa03c, 0x0000 },

-  { 0x8700, 0xa045, 0x4000 },

-  { 0x8700, 0xa041, 0x3000 },

-  { 0x8700, 0xa03f, 0x2000 },

-  { 0x0700, 0xa03e, 0x0000 },

-  { 0x0700, 0xa040, 0x0000 },

-  { 0x8700, 0xa043, 0x2000 },

-  { 0x0700, 0xa042, 0x0000 },

-  { 0x0700, 0xa044, 0x0000 },

-  { 0x8700, 0xa049, 0x3000 },

-  { 0x8700, 0xa047, 0x2000 },

-  { 0x0700, 0xa046, 0x0000 },

-  { 0x0700, 0xa048, 0x0000 },

-  { 0x8700, 0xa04b, 0x2000 },

-  { 0x0700, 0xa04a, 0x0000 },

-  { 0x0700, 0xa04c, 0x0000 },

-  { 0x8700, 0xa0cd, 0x8000 },

-  { 0x8700, 0xa08d, 0x7000 },

-  { 0x8700, 0xa06d, 0x6000 },

-  { 0x8700, 0xa05d, 0x5000 },

-  { 0x8700, 0xa055, 0x4000 },

-  { 0x8700, 0xa051, 0x3000 },

-  { 0x8700, 0xa04f, 0x2000 },

-  { 0x0700, 0xa04e, 0x0000 },

-  { 0x0700, 0xa050, 0x0000 },

-  { 0x8700, 0xa053, 0x2000 },

-  { 0x0700, 0xa052, 0x0000 },

-  { 0x0700, 0xa054, 0x0000 },

-  { 0x8700, 0xa059, 0x3000 },

-  { 0x8700, 0xa057, 0x2000 },

-  { 0x0700, 0xa056, 0x0000 },

-  { 0x0700, 0xa058, 0x0000 },

-  { 0x8700, 0xa05b, 0x2000 },

-  { 0x0700, 0xa05a, 0x0000 },

-  { 0x0700, 0xa05c, 0x0000 },

-  { 0x8700, 0xa065, 0x4000 },

-  { 0x8700, 0xa061, 0x3000 },

-  { 0x8700, 0xa05f, 0x2000 },

-  { 0x0700, 0xa05e, 0x0000 },

-  { 0x0700, 0xa060, 0x0000 },

-  { 0x8700, 0xa063, 0x2000 },

-  { 0x0700, 0xa062, 0x0000 },

-  { 0x0700, 0xa064, 0x0000 },

-  { 0x8700, 0xa069, 0x3000 },

-  { 0x8700, 0xa067, 0x2000 },

-  { 0x0700, 0xa066, 0x0000 },

-  { 0x0700, 0xa068, 0x0000 },

-  { 0x8700, 0xa06b, 0x2000 },

-  { 0x0700, 0xa06a, 0x0000 },

-  { 0x0700, 0xa06c, 0x0000 },

-  { 0x8700, 0xa07d, 0x5000 },

-  { 0x8700, 0xa075, 0x4000 },

-  { 0x8700, 0xa071, 0x3000 },

-  { 0x8700, 0xa06f, 0x2000 },

-  { 0x0700, 0xa06e, 0x0000 },

-  { 0x0700, 0xa070, 0x0000 },

-  { 0x8700, 0xa073, 0x2000 },

-  { 0x0700, 0xa072, 0x0000 },

-  { 0x0700, 0xa074, 0x0000 },

-  { 0x8700, 0xa079, 0x3000 },

-  { 0x8700, 0xa077, 0x2000 },

-  { 0x0700, 0xa076, 0x0000 },

-  { 0x0700, 0xa078, 0x0000 },

-  { 0x8700, 0xa07b, 0x2000 },

-  { 0x0700, 0xa07a, 0x0000 },

-  { 0x0700, 0xa07c, 0x0000 },

-  { 0x8700, 0xa085, 0x4000 },

-  { 0x8700, 0xa081, 0x3000 },

-  { 0x8700, 0xa07f, 0x2000 },

-  { 0x0700, 0xa07e, 0x0000 },

-  { 0x0700, 0xa080, 0x0000 },

-  { 0x8700, 0xa083, 0x2000 },

-  { 0x0700, 0xa082, 0x0000 },

-  { 0x0700, 0xa084, 0x0000 },

-  { 0x8700, 0xa089, 0x3000 },

-  { 0x8700, 0xa087, 0x2000 },

-  { 0x0700, 0xa086, 0x0000 },

-  { 0x0700, 0xa088, 0x0000 },

-  { 0x8700, 0xa08b, 0x2000 },

-  { 0x0700, 0xa08a, 0x0000 },

-  { 0x0700, 0xa08c, 0x0000 },

-  { 0x8700, 0xa0ad, 0x6000 },

-  { 0x8700, 0xa09d, 0x5000 },

-  { 0x8700, 0xa095, 0x4000 },

-  { 0x8700, 0xa091, 0x3000 },

-  { 0x8700, 0xa08f, 0x2000 },

-  { 0x0700, 0xa08e, 0x0000 },

-  { 0x0700, 0xa090, 0x0000 },

-  { 0x8700, 0xa093, 0x2000 },

-  { 0x0700, 0xa092, 0x0000 },

-  { 0x0700, 0xa094, 0x0000 },

-  { 0x8700, 0xa099, 0x3000 },

-  { 0x8700, 0xa097, 0x2000 },

-  { 0x0700, 0xa096, 0x0000 },

-  { 0x0700, 0xa098, 0x0000 },

-  { 0x8700, 0xa09b, 0x2000 },

-  { 0x0700, 0xa09a, 0x0000 },

-  { 0x0700, 0xa09c, 0x0000 },

-  { 0x8700, 0xa0a5, 0x4000 },

-  { 0x8700, 0xa0a1, 0x3000 },

-  { 0x8700, 0xa09f, 0x2000 },

-  { 0x0700, 0xa09e, 0x0000 },

-  { 0x0700, 0xa0a0, 0x0000 },

-  { 0x8700, 0xa0a3, 0x2000 },

-  { 0x0700, 0xa0a2, 0x0000 },

-  { 0x0700, 0xa0a4, 0x0000 },

-  { 0x8700, 0xa0a9, 0x3000 },

-  { 0x8700, 0xa0a7, 0x2000 },

-  { 0x0700, 0xa0a6, 0x0000 },

-  { 0x0700, 0xa0a8, 0x0000 },

-  { 0x8700, 0xa0ab, 0x2000 },

-  { 0x0700, 0xa0aa, 0x0000 },

-  { 0x0700, 0xa0ac, 0x0000 },

-  { 0x8700, 0xa0bd, 0x5000 },

-  { 0x8700, 0xa0b5, 0x4000 },

-  { 0x8700, 0xa0b1, 0x3000 },

-  { 0x8700, 0xa0af, 0x2000 },

-  { 0x0700, 0xa0ae, 0x0000 },

-  { 0x0700, 0xa0b0, 0x0000 },

-  { 0x8700, 0xa0b3, 0x2000 },

-  { 0x0700, 0xa0b2, 0x0000 },

-  { 0x0700, 0xa0b4, 0x0000 },

-  { 0x8700, 0xa0b9, 0x3000 },

-  { 0x8700, 0xa0b7, 0x2000 },

-  { 0x0700, 0xa0b6, 0x0000 },

-  { 0x0700, 0xa0b8, 0x0000 },

-  { 0x8700, 0xa0bb, 0x2000 },

-  { 0x0700, 0xa0ba, 0x0000 },

-  { 0x0700, 0xa0bc, 0x0000 },

-  { 0x8700, 0xa0c5, 0x4000 },

-  { 0x8700, 0xa0c1, 0x3000 },

-  { 0x8700, 0xa0bf, 0x2000 },

-  { 0x0700, 0xa0be, 0x0000 },

-  { 0x0700, 0xa0c0, 0x0000 },

-  { 0x8700, 0xa0c3, 0x2000 },

-  { 0x0700, 0xa0c2, 0x0000 },

-  { 0x0700, 0xa0c4, 0x0000 },

-  { 0x8700, 0xa0c9, 0x3000 },

-  { 0x8700, 0xa0c7, 0x2000 },

-  { 0x0700, 0xa0c6, 0x0000 },

-  { 0x0700, 0xa0c8, 0x0000 },

-  { 0x8700, 0xa0cb, 0x2000 },

-  { 0x0700, 0xa0ca, 0x0000 },

-  { 0x0700, 0xa0cc, 0x0000 },

-  { 0x8700, 0xa10d, 0x7000 },

-  { 0x8700, 0xa0ed, 0x6000 },

-  { 0x8700, 0xa0dd, 0x5000 },

-  { 0x8700, 0xa0d5, 0x4000 },

-  { 0x8700, 0xa0d1, 0x3000 },

-  { 0x8700, 0xa0cf, 0x2000 },

-  { 0x0700, 0xa0ce, 0x0000 },

-  { 0x0700, 0xa0d0, 0x0000 },

-  { 0x8700, 0xa0d3, 0x2000 },

-  { 0x0700, 0xa0d2, 0x0000 },

-  { 0x0700, 0xa0d4, 0x0000 },

-  { 0x8700, 0xa0d9, 0x3000 },

-  { 0x8700, 0xa0d7, 0x2000 },

-  { 0x0700, 0xa0d6, 0x0000 },

-  { 0x0700, 0xa0d8, 0x0000 },

-  { 0x8700, 0xa0db, 0x2000 },

-  { 0x0700, 0xa0da, 0x0000 },

-  { 0x0700, 0xa0dc, 0x0000 },

-  { 0x8700, 0xa0e5, 0x4000 },

-  { 0x8700, 0xa0e1, 0x3000 },

-  { 0x8700, 0xa0df, 0x2000 },

-  { 0x0700, 0xa0de, 0x0000 },

-  { 0x0700, 0xa0e0, 0x0000 },

-  { 0x8700, 0xa0e3, 0x2000 },

-  { 0x0700, 0xa0e2, 0x0000 },

-  { 0x0700, 0xa0e4, 0x0000 },

-  { 0x8700, 0xa0e9, 0x3000 },

-  { 0x8700, 0xa0e7, 0x2000 },

-  { 0x0700, 0xa0e6, 0x0000 },

-  { 0x0700, 0xa0e8, 0x0000 },

-  { 0x8700, 0xa0eb, 0x2000 },

-  { 0x0700, 0xa0ea, 0x0000 },

-  { 0x0700, 0xa0ec, 0x0000 },

-  { 0x8700, 0xa0fd, 0x5000 },

-  { 0x8700, 0xa0f5, 0x4000 },

-  { 0x8700, 0xa0f1, 0x3000 },

-  { 0x8700, 0xa0ef, 0x2000 },

-  { 0x0700, 0xa0ee, 0x0000 },

-  { 0x0700, 0xa0f0, 0x0000 },

-  { 0x8700, 0xa0f3, 0x2000 },

-  { 0x0700, 0xa0f2, 0x0000 },

-  { 0x0700, 0xa0f4, 0x0000 },

-  { 0x8700, 0xa0f9, 0x3000 },

-  { 0x8700, 0xa0f7, 0x2000 },

-  { 0x0700, 0xa0f6, 0x0000 },

-  { 0x0700, 0xa0f8, 0x0000 },

-  { 0x8700, 0xa0fb, 0x2000 },

-  { 0x0700, 0xa0fa, 0x0000 },

-  { 0x0700, 0xa0fc, 0x0000 },

-  { 0x8700, 0xa105, 0x4000 },

-  { 0x8700, 0xa101, 0x3000 },

-  { 0x8700, 0xa0ff, 0x2000 },

-  { 0x0700, 0xa0fe, 0x0000 },

-  { 0x0700, 0xa100, 0x0000 },

-  { 0x8700, 0xa103, 0x2000 },

-  { 0x0700, 0xa102, 0x0000 },

-  { 0x0700, 0xa104, 0x0000 },

-  { 0x8700, 0xa109, 0x3000 },

-  { 0x8700, 0xa107, 0x2000 },

-  { 0x0700, 0xa106, 0x0000 },

-  { 0x0700, 0xa108, 0x0000 },

-  { 0x8700, 0xa10b, 0x2000 },

-  { 0x0700, 0xa10a, 0x0000 },

-  { 0x0700, 0xa10c, 0x0000 },

-  { 0x8700, 0xa12d, 0x6000 },

-  { 0x8700, 0xa11d, 0x5000 },

-  { 0x8700, 0xa115, 0x4000 },

-  { 0x8700, 0xa111, 0x3000 },

-  { 0x8700, 0xa10f, 0x2000 },

-  { 0x0700, 0xa10e, 0x0000 },

-  { 0x0700, 0xa110, 0x0000 },

-  { 0x8700, 0xa113, 0x2000 },

-  { 0x0700, 0xa112, 0x0000 },

-  { 0x0700, 0xa114, 0x0000 },

-  { 0x8700, 0xa119, 0x3000 },

-  { 0x8700, 0xa117, 0x2000 },

-  { 0x0700, 0xa116, 0x0000 },

-  { 0x0700, 0xa118, 0x0000 },

-  { 0x8700, 0xa11b, 0x2000 },

-  { 0x0700, 0xa11a, 0x0000 },

-  { 0x0700, 0xa11c, 0x0000 },

-  { 0x8700, 0xa125, 0x4000 },

-  { 0x8700, 0xa121, 0x3000 },

-  { 0x8700, 0xa11f, 0x2000 },

-  { 0x0700, 0xa11e, 0x0000 },

-  { 0x0700, 0xa120, 0x0000 },

-  { 0x8700, 0xa123, 0x2000 },

-  { 0x0700, 0xa122, 0x0000 },

-  { 0x0700, 0xa124, 0x0000 },

-  { 0x8700, 0xa129, 0x3000 },

-  { 0x8700, 0xa127, 0x2000 },

-  { 0x0700, 0xa126, 0x0000 },

-  { 0x0700, 0xa128, 0x0000 },

-  { 0x8700, 0xa12b, 0x2000 },

-  { 0x0700, 0xa12a, 0x0000 },

-  { 0x0700, 0xa12c, 0x0000 },

-  { 0x8700, 0xa13d, 0x5000 },

-  { 0x8700, 0xa135, 0x4000 },

-  { 0x8700, 0xa131, 0x3000 },

-  { 0x8700, 0xa12f, 0x2000 },

-  { 0x0700, 0xa12e, 0x0000 },

-  { 0x0700, 0xa130, 0x0000 },

-  { 0x8700, 0xa133, 0x2000 },

-  { 0x0700, 0xa132, 0x0000 },

-  { 0x0700, 0xa134, 0x0000 },

-  { 0x8700, 0xa139, 0x3000 },

-  { 0x8700, 0xa137, 0x2000 },

-  { 0x0700, 0xa136, 0x0000 },

-  { 0x0700, 0xa138, 0x0000 },

-  { 0x8700, 0xa13b, 0x2000 },

-  { 0x0700, 0xa13a, 0x0000 },

-  { 0x0700, 0xa13c, 0x0000 },

-  { 0x8700, 0xa145, 0x4000 },

-  { 0x8700, 0xa141, 0x3000 },

-  { 0x8700, 0xa13f, 0x2000 },

-  { 0x0700, 0xa13e, 0x0000 },

-  { 0x0700, 0xa140, 0x0000 },

-  { 0x8700, 0xa143, 0x2000 },

-  { 0x0700, 0xa142, 0x0000 },

-  { 0x0700, 0xa144, 0x0000 },

-  { 0x8700, 0xa149, 0x3000 },

-  { 0x8700, 0xa147, 0x2000 },

-  { 0x0700, 0xa146, 0x0000 },

-  { 0x0700, 0xa148, 0x0000 },

-  { 0x8700, 0xa14b, 0x2000 },

-  { 0x0700, 0xa14a, 0x0000 },

-  { 0x0700, 0xa14c, 0x0000 },

-  { 0x8700, 0xa24d, 0x9000 },

-  { 0x8700, 0xa1cd, 0x8000 },

-  { 0x8700, 0xa18d, 0x7000 },

-  { 0x8700, 0xa16d, 0x6000 },

-  { 0x8700, 0xa15d, 0x5000 },

-  { 0x8700, 0xa155, 0x4000 },

-  { 0x8700, 0xa151, 0x3000 },

-  { 0x8700, 0xa14f, 0x2000 },

-  { 0x0700, 0xa14e, 0x0000 },

-  { 0x0700, 0xa150, 0x0000 },

-  { 0x8700, 0xa153, 0x2000 },

-  { 0x0700, 0xa152, 0x0000 },

-  { 0x0700, 0xa154, 0x0000 },

-  { 0x8700, 0xa159, 0x3000 },

-  { 0x8700, 0xa157, 0x2000 },

-  { 0x0700, 0xa156, 0x0000 },

-  { 0x0700, 0xa158, 0x0000 },

-  { 0x8700, 0xa15b, 0x2000 },

-  { 0x0700, 0xa15a, 0x0000 },

-  { 0x0700, 0xa15c, 0x0000 },

-  { 0x8700, 0xa165, 0x4000 },

-  { 0x8700, 0xa161, 0x3000 },

-  { 0x8700, 0xa15f, 0x2000 },

-  { 0x0700, 0xa15e, 0x0000 },

-  { 0x0700, 0xa160, 0x0000 },

-  { 0x8700, 0xa163, 0x2000 },

-  { 0x0700, 0xa162, 0x0000 },

-  { 0x0700, 0xa164, 0x0000 },

-  { 0x8700, 0xa169, 0x3000 },

-  { 0x8700, 0xa167, 0x2000 },

-  { 0x0700, 0xa166, 0x0000 },

-  { 0x0700, 0xa168, 0x0000 },

-  { 0x8700, 0xa16b, 0x2000 },

-  { 0x0700, 0xa16a, 0x0000 },

-  { 0x0700, 0xa16c, 0x0000 },

-  { 0x8700, 0xa17d, 0x5000 },

-  { 0x8700, 0xa175, 0x4000 },

-  { 0x8700, 0xa171, 0x3000 },

-  { 0x8700, 0xa16f, 0x2000 },

-  { 0x0700, 0xa16e, 0x0000 },

-  { 0x0700, 0xa170, 0x0000 },

-  { 0x8700, 0xa173, 0x2000 },

-  { 0x0700, 0xa172, 0x0000 },

-  { 0x0700, 0xa174, 0x0000 },

-  { 0x8700, 0xa179, 0x3000 },

-  { 0x8700, 0xa177, 0x2000 },

-  { 0x0700, 0xa176, 0x0000 },

-  { 0x0700, 0xa178, 0x0000 },

-  { 0x8700, 0xa17b, 0x2000 },

-  { 0x0700, 0xa17a, 0x0000 },

-  { 0x0700, 0xa17c, 0x0000 },

-  { 0x8700, 0xa185, 0x4000 },

-  { 0x8700, 0xa181, 0x3000 },

-  { 0x8700, 0xa17f, 0x2000 },

-  { 0x0700, 0xa17e, 0x0000 },

-  { 0x0700, 0xa180, 0x0000 },

-  { 0x8700, 0xa183, 0x2000 },

-  { 0x0700, 0xa182, 0x0000 },

-  { 0x0700, 0xa184, 0x0000 },

-  { 0x8700, 0xa189, 0x3000 },

-  { 0x8700, 0xa187, 0x2000 },

-  { 0x0700, 0xa186, 0x0000 },

-  { 0x0700, 0xa188, 0x0000 },

-  { 0x8700, 0xa18b, 0x2000 },

-  { 0x0700, 0xa18a, 0x0000 },

-  { 0x0700, 0xa18c, 0x0000 },

-  { 0x8700, 0xa1ad, 0x6000 },

-  { 0x8700, 0xa19d, 0x5000 },

-  { 0x8700, 0xa195, 0x4000 },

-  { 0x8700, 0xa191, 0x3000 },

-  { 0x8700, 0xa18f, 0x2000 },

-  { 0x0700, 0xa18e, 0x0000 },

-  { 0x0700, 0xa190, 0x0000 },

-  { 0x8700, 0xa193, 0x2000 },

-  { 0x0700, 0xa192, 0x0000 },

-  { 0x0700, 0xa194, 0x0000 },

-  { 0x8700, 0xa199, 0x3000 },

-  { 0x8700, 0xa197, 0x2000 },

-  { 0x0700, 0xa196, 0x0000 },

-  { 0x0700, 0xa198, 0x0000 },

-  { 0x8700, 0xa19b, 0x2000 },

-  { 0x0700, 0xa19a, 0x0000 },

-  { 0x0700, 0xa19c, 0x0000 },

-  { 0x8700, 0xa1a5, 0x4000 },

-  { 0x8700, 0xa1a1, 0x3000 },

-  { 0x8700, 0xa19f, 0x2000 },

-  { 0x0700, 0xa19e, 0x0000 },

-  { 0x0700, 0xa1a0, 0x0000 },

-  { 0x8700, 0xa1a3, 0x2000 },

-  { 0x0700, 0xa1a2, 0x0000 },

-  { 0x0700, 0xa1a4, 0x0000 },

-  { 0x8700, 0xa1a9, 0x3000 },

-  { 0x8700, 0xa1a7, 0x2000 },

-  { 0x0700, 0xa1a6, 0x0000 },

-  { 0x0700, 0xa1a8, 0x0000 },

-  { 0x8700, 0xa1ab, 0x2000 },

-  { 0x0700, 0xa1aa, 0x0000 },

-  { 0x0700, 0xa1ac, 0x0000 },

-  { 0x8700, 0xa1bd, 0x5000 },

-  { 0x8700, 0xa1b5, 0x4000 },

-  { 0x8700, 0xa1b1, 0x3000 },

-  { 0x8700, 0xa1af, 0x2000 },

-  { 0x0700, 0xa1ae, 0x0000 },

-  { 0x0700, 0xa1b0, 0x0000 },

-  { 0x8700, 0xa1b3, 0x2000 },

-  { 0x0700, 0xa1b2, 0x0000 },

-  { 0x0700, 0xa1b4, 0x0000 },

-  { 0x8700, 0xa1b9, 0x3000 },

-  { 0x8700, 0xa1b7, 0x2000 },

-  { 0x0700, 0xa1b6, 0x0000 },

-  { 0x0700, 0xa1b8, 0x0000 },

-  { 0x8700, 0xa1bb, 0x2000 },

-  { 0x0700, 0xa1ba, 0x0000 },

-  { 0x0700, 0xa1bc, 0x0000 },

-  { 0x8700, 0xa1c5, 0x4000 },

-  { 0x8700, 0xa1c1, 0x3000 },

-  { 0x8700, 0xa1bf, 0x2000 },

-  { 0x0700, 0xa1be, 0x0000 },

-  { 0x0700, 0xa1c0, 0x0000 },

-  { 0x8700, 0xa1c3, 0x2000 },

-  { 0x0700, 0xa1c2, 0x0000 },

-  { 0x0700, 0xa1c4, 0x0000 },

-  { 0x8700, 0xa1c9, 0x3000 },

-  { 0x8700, 0xa1c7, 0x2000 },

-  { 0x0700, 0xa1c6, 0x0000 },

-  { 0x0700, 0xa1c8, 0x0000 },

-  { 0x8700, 0xa1cb, 0x2000 },

-  { 0x0700, 0xa1ca, 0x0000 },

-  { 0x0700, 0xa1cc, 0x0000 },

-  { 0x8700, 0xa20d, 0x7000 },

-  { 0x8700, 0xa1ed, 0x6000 },

-  { 0x8700, 0xa1dd, 0x5000 },

-  { 0x8700, 0xa1d5, 0x4000 },

-  { 0x8700, 0xa1d1, 0x3000 },

-  { 0x8700, 0xa1cf, 0x2000 },

-  { 0x0700, 0xa1ce, 0x0000 },

-  { 0x0700, 0xa1d0, 0x0000 },

-  { 0x8700, 0xa1d3, 0x2000 },

-  { 0x0700, 0xa1d2, 0x0000 },

-  { 0x0700, 0xa1d4, 0x0000 },

-  { 0x8700, 0xa1d9, 0x3000 },

-  { 0x8700, 0xa1d7, 0x2000 },

-  { 0x0700, 0xa1d6, 0x0000 },

-  { 0x0700, 0xa1d8, 0x0000 },

-  { 0x8700, 0xa1db, 0x2000 },

-  { 0x0700, 0xa1da, 0x0000 },

-  { 0x0700, 0xa1dc, 0x0000 },

-  { 0x8700, 0xa1e5, 0x4000 },

-  { 0x8700, 0xa1e1, 0x3000 },

-  { 0x8700, 0xa1df, 0x2000 },

-  { 0x0700, 0xa1de, 0x0000 },

-  { 0x0700, 0xa1e0, 0x0000 },

-  { 0x8700, 0xa1e3, 0x2000 },

-  { 0x0700, 0xa1e2, 0x0000 },

-  { 0x0700, 0xa1e4, 0x0000 },

-  { 0x8700, 0xa1e9, 0x3000 },

-  { 0x8700, 0xa1e7, 0x2000 },

-  { 0x0700, 0xa1e6, 0x0000 },

-  { 0x0700, 0xa1e8, 0x0000 },

-  { 0x8700, 0xa1eb, 0x2000 },

-  { 0x0700, 0xa1ea, 0x0000 },

-  { 0x0700, 0xa1ec, 0x0000 },

-  { 0x8700, 0xa1fd, 0x5000 },

-  { 0x8700, 0xa1f5, 0x4000 },

-  { 0x8700, 0xa1f1, 0x3000 },

-  { 0x8700, 0xa1ef, 0x2000 },

-  { 0x0700, 0xa1ee, 0x0000 },

-  { 0x0700, 0xa1f0, 0x0000 },

-  { 0x8700, 0xa1f3, 0x2000 },

-  { 0x0700, 0xa1f2, 0x0000 },

-  { 0x0700, 0xa1f4, 0x0000 },

-  { 0x8700, 0xa1f9, 0x3000 },

-  { 0x8700, 0xa1f7, 0x2000 },

-  { 0x0700, 0xa1f6, 0x0000 },

-  { 0x0700, 0xa1f8, 0x0000 },

-  { 0x8700, 0xa1fb, 0x2000 },

-  { 0x0700, 0xa1fa, 0x0000 },

-  { 0x0700, 0xa1fc, 0x0000 },

-  { 0x8700, 0xa205, 0x4000 },

-  { 0x8700, 0xa201, 0x3000 },

-  { 0x8700, 0xa1ff, 0x2000 },

-  { 0x0700, 0xa1fe, 0x0000 },

-  { 0x0700, 0xa200, 0x0000 },

-  { 0x8700, 0xa203, 0x2000 },

-  { 0x0700, 0xa202, 0x0000 },

-  { 0x0700, 0xa204, 0x0000 },

-  { 0x8700, 0xa209, 0x3000 },

-  { 0x8700, 0xa207, 0x2000 },

-  { 0x0700, 0xa206, 0x0000 },

-  { 0x0700, 0xa208, 0x0000 },

-  { 0x8700, 0xa20b, 0x2000 },

-  { 0x0700, 0xa20a, 0x0000 },

-  { 0x0700, 0xa20c, 0x0000 },

-  { 0x8700, 0xa22d, 0x6000 },

-  { 0x8700, 0xa21d, 0x5000 },

-  { 0x8700, 0xa215, 0x4000 },

-  { 0x8700, 0xa211, 0x3000 },

-  { 0x8700, 0xa20f, 0x2000 },

-  { 0x0700, 0xa20e, 0x0000 },

-  { 0x0700, 0xa210, 0x0000 },

-  { 0x8700, 0xa213, 0x2000 },

-  { 0x0700, 0xa212, 0x0000 },

-  { 0x0700, 0xa214, 0x0000 },

-  { 0x8700, 0xa219, 0x3000 },

-  { 0x8700, 0xa217, 0x2000 },

-  { 0x0700, 0xa216, 0x0000 },

-  { 0x0700, 0xa218, 0x0000 },

-  { 0x8700, 0xa21b, 0x2000 },

-  { 0x0700, 0xa21a, 0x0000 },

-  { 0x0700, 0xa21c, 0x0000 },

-  { 0x8700, 0xa225, 0x4000 },

-  { 0x8700, 0xa221, 0x3000 },

-  { 0x8700, 0xa21f, 0x2000 },

-  { 0x0700, 0xa21e, 0x0000 },

-  { 0x0700, 0xa220, 0x0000 },

-  { 0x8700, 0xa223, 0x2000 },

-  { 0x0700, 0xa222, 0x0000 },

-  { 0x0700, 0xa224, 0x0000 },

-  { 0x8700, 0xa229, 0x3000 },

-  { 0x8700, 0xa227, 0x2000 },

-  { 0x0700, 0xa226, 0x0000 },

-  { 0x0700, 0xa228, 0x0000 },

-  { 0x8700, 0xa22b, 0x2000 },

-  { 0x0700, 0xa22a, 0x0000 },

-  { 0x0700, 0xa22c, 0x0000 },

-  { 0x8700, 0xa23d, 0x5000 },

-  { 0x8700, 0xa235, 0x4000 },

-  { 0x8700, 0xa231, 0x3000 },

-  { 0x8700, 0xa22f, 0x2000 },

-  { 0x0700, 0xa22e, 0x0000 },

-  { 0x0700, 0xa230, 0x0000 },

-  { 0x8700, 0xa233, 0x2000 },

-  { 0x0700, 0xa232, 0x0000 },

-  { 0x0700, 0xa234, 0x0000 },

-  { 0x8700, 0xa239, 0x3000 },

-  { 0x8700, 0xa237, 0x2000 },

-  { 0x0700, 0xa236, 0x0000 },

-  { 0x0700, 0xa238, 0x0000 },

-  { 0x8700, 0xa23b, 0x2000 },

-  { 0x0700, 0xa23a, 0x0000 },

-  { 0x0700, 0xa23c, 0x0000 },

-  { 0x8700, 0xa245, 0x4000 },

-  { 0x8700, 0xa241, 0x3000 },

-  { 0x8700, 0xa23f, 0x2000 },

-  { 0x0700, 0xa23e, 0x0000 },

-  { 0x0700, 0xa240, 0x0000 },

-  { 0x8700, 0xa243, 0x2000 },

-  { 0x0700, 0xa242, 0x0000 },

-  { 0x0700, 0xa244, 0x0000 },

-  { 0x8700, 0xa249, 0x3000 },

-  { 0x8700, 0xa247, 0x2000 },

-  { 0x0700, 0xa246, 0x0000 },

-  { 0x0700, 0xa248, 0x0000 },

-  { 0x8700, 0xa24b, 0x2000 },

-  { 0x0700, 0xa24a, 0x0000 },

-  { 0x0700, 0xa24c, 0x0000 },

-  { 0x8700, 0xa2cd, 0x8000 },

-  { 0x8700, 0xa28d, 0x7000 },

-  { 0x8700, 0xa26d, 0x6000 },

-  { 0x8700, 0xa25d, 0x5000 },

-  { 0x8700, 0xa255, 0x4000 },

-  { 0x8700, 0xa251, 0x3000 },

-  { 0x8700, 0xa24f, 0x2000 },

-  { 0x0700, 0xa24e, 0x0000 },

-  { 0x0700, 0xa250, 0x0000 },

-  { 0x8700, 0xa253, 0x2000 },

-  { 0x0700, 0xa252, 0x0000 },

-  { 0x0700, 0xa254, 0x0000 },

-  { 0x8700, 0xa259, 0x3000 },

-  { 0x8700, 0xa257, 0x2000 },

-  { 0x0700, 0xa256, 0x0000 },

-  { 0x0700, 0xa258, 0x0000 },

-  { 0x8700, 0xa25b, 0x2000 },

-  { 0x0700, 0xa25a, 0x0000 },

-  { 0x0700, 0xa25c, 0x0000 },

-  { 0x8700, 0xa265, 0x4000 },

-  { 0x8700, 0xa261, 0x3000 },

-  { 0x8700, 0xa25f, 0x2000 },

-  { 0x0700, 0xa25e, 0x0000 },

-  { 0x0700, 0xa260, 0x0000 },

-  { 0x8700, 0xa263, 0x2000 },

-  { 0x0700, 0xa262, 0x0000 },

-  { 0x0700, 0xa264, 0x0000 },

-  { 0x8700, 0xa269, 0x3000 },

-  { 0x8700, 0xa267, 0x2000 },

-  { 0x0700, 0xa266, 0x0000 },

-  { 0x0700, 0xa268, 0x0000 },

-  { 0x8700, 0xa26b, 0x2000 },

-  { 0x0700, 0xa26a, 0x0000 },

-  { 0x0700, 0xa26c, 0x0000 },

-  { 0x8700, 0xa27d, 0x5000 },

-  { 0x8700, 0xa275, 0x4000 },

-  { 0x8700, 0xa271, 0x3000 },

-  { 0x8700, 0xa26f, 0x2000 },

-  { 0x0700, 0xa26e, 0x0000 },

-  { 0x0700, 0xa270, 0x0000 },

-  { 0x8700, 0xa273, 0x2000 },

-  { 0x0700, 0xa272, 0x0000 },

-  { 0x0700, 0xa274, 0x0000 },

-  { 0x8700, 0xa279, 0x3000 },

-  { 0x8700, 0xa277, 0x2000 },

-  { 0x0700, 0xa276, 0x0000 },

-  { 0x0700, 0xa278, 0x0000 },

-  { 0x8700, 0xa27b, 0x2000 },

-  { 0x0700, 0xa27a, 0x0000 },

-  { 0x0700, 0xa27c, 0x0000 },

-  { 0x8700, 0xa285, 0x4000 },

-  { 0x8700, 0xa281, 0x3000 },

-  { 0x8700, 0xa27f, 0x2000 },

-  { 0x0700, 0xa27e, 0x0000 },

-  { 0x0700, 0xa280, 0x0000 },

-  { 0x8700, 0xa283, 0x2000 },

-  { 0x0700, 0xa282, 0x0000 },

-  { 0x0700, 0xa284, 0x0000 },

-  { 0x8700, 0xa289, 0x3000 },

-  { 0x8700, 0xa287, 0x2000 },

-  { 0x0700, 0xa286, 0x0000 },

-  { 0x0700, 0xa288, 0x0000 },

-  { 0x8700, 0xa28b, 0x2000 },

-  { 0x0700, 0xa28a, 0x0000 },

-  { 0x0700, 0xa28c, 0x0000 },

-  { 0x8700, 0xa2ad, 0x6000 },

-  { 0x8700, 0xa29d, 0x5000 },

-  { 0x8700, 0xa295, 0x4000 },

-  { 0x8700, 0xa291, 0x3000 },

-  { 0x8700, 0xa28f, 0x2000 },

-  { 0x0700, 0xa28e, 0x0000 },

-  { 0x0700, 0xa290, 0x0000 },

-  { 0x8700, 0xa293, 0x2000 },

-  { 0x0700, 0xa292, 0x0000 },

-  { 0x0700, 0xa294, 0x0000 },

-  { 0x8700, 0xa299, 0x3000 },

-  { 0x8700, 0xa297, 0x2000 },

-  { 0x0700, 0xa296, 0x0000 },

-  { 0x0700, 0xa298, 0x0000 },

-  { 0x8700, 0xa29b, 0x2000 },

-  { 0x0700, 0xa29a, 0x0000 },

-  { 0x0700, 0xa29c, 0x0000 },

-  { 0x8700, 0xa2a5, 0x4000 },

-  { 0x8700, 0xa2a1, 0x3000 },

-  { 0x8700, 0xa29f, 0x2000 },

-  { 0x0700, 0xa29e, 0x0000 },

-  { 0x0700, 0xa2a0, 0x0000 },

-  { 0x8700, 0xa2a3, 0x2000 },

-  { 0x0700, 0xa2a2, 0x0000 },

-  { 0x0700, 0xa2a4, 0x0000 },

-  { 0x8700, 0xa2a9, 0x3000 },

-  { 0x8700, 0xa2a7, 0x2000 },

-  { 0x0700, 0xa2a6, 0x0000 },

-  { 0x0700, 0xa2a8, 0x0000 },

-  { 0x8700, 0xa2ab, 0x2000 },

-  { 0x0700, 0xa2aa, 0x0000 },

-  { 0x0700, 0xa2ac, 0x0000 },

-  { 0x8700, 0xa2bd, 0x5000 },

-  { 0x8700, 0xa2b5, 0x4000 },

-  { 0x8700, 0xa2b1, 0x3000 },

-  { 0x8700, 0xa2af, 0x2000 },

-  { 0x0700, 0xa2ae, 0x0000 },

-  { 0x0700, 0xa2b0, 0x0000 },

-  { 0x8700, 0xa2b3, 0x2000 },

-  { 0x0700, 0xa2b2, 0x0000 },

-  { 0x0700, 0xa2b4, 0x0000 },

-  { 0x8700, 0xa2b9, 0x3000 },

-  { 0x8700, 0xa2b7, 0x2000 },

-  { 0x0700, 0xa2b6, 0x0000 },

-  { 0x0700, 0xa2b8, 0x0000 },

-  { 0x8700, 0xa2bb, 0x2000 },

-  { 0x0700, 0xa2ba, 0x0000 },

-  { 0x0700, 0xa2bc, 0x0000 },

-  { 0x8700, 0xa2c5, 0x4000 },

-  { 0x8700, 0xa2c1, 0x3000 },

-  { 0x8700, 0xa2bf, 0x2000 },

-  { 0x0700, 0xa2be, 0x0000 },

-  { 0x0700, 0xa2c0, 0x0000 },

-  { 0x8700, 0xa2c3, 0x2000 },

-  { 0x0700, 0xa2c2, 0x0000 },

-  { 0x0700, 0xa2c4, 0x0000 },

-  { 0x8700, 0xa2c9, 0x3000 },

-  { 0x8700, 0xa2c7, 0x2000 },

-  { 0x0700, 0xa2c6, 0x0000 },

-  { 0x0700, 0xa2c8, 0x0000 },

-  { 0x8700, 0xa2cb, 0x2000 },

-  { 0x0700, 0xa2ca, 0x0000 },

-  { 0x0700, 0xa2cc, 0x0000 },

-  { 0x8700, 0xa30d, 0x7000 },

-  { 0x8700, 0xa2ed, 0x6000 },

-  { 0x8700, 0xa2dd, 0x5000 },

-  { 0x8700, 0xa2d5, 0x4000 },

-  { 0x8700, 0xa2d1, 0x3000 },

-  { 0x8700, 0xa2cf, 0x2000 },

-  { 0x0700, 0xa2ce, 0x0000 },

-  { 0x0700, 0xa2d0, 0x0000 },

-  { 0x8700, 0xa2d3, 0x2000 },

-  { 0x0700, 0xa2d2, 0x0000 },

-  { 0x0700, 0xa2d4, 0x0000 },

-  { 0x8700, 0xa2d9, 0x3000 },

-  { 0x8700, 0xa2d7, 0x2000 },

-  { 0x0700, 0xa2d6, 0x0000 },

-  { 0x0700, 0xa2d8, 0x0000 },

-  { 0x8700, 0xa2db, 0x2000 },

-  { 0x0700, 0xa2da, 0x0000 },

-  { 0x0700, 0xa2dc, 0x0000 },

-  { 0x8700, 0xa2e5, 0x4000 },

-  { 0x8700, 0xa2e1, 0x3000 },

-  { 0x8700, 0xa2df, 0x2000 },

-  { 0x0700, 0xa2de, 0x0000 },

-  { 0x0700, 0xa2e0, 0x0000 },

-  { 0x8700, 0xa2e3, 0x2000 },

-  { 0x0700, 0xa2e2, 0x0000 },

-  { 0x0700, 0xa2e4, 0x0000 },

-  { 0x8700, 0xa2e9, 0x3000 },

-  { 0x8700, 0xa2e7, 0x2000 },

-  { 0x0700, 0xa2e6, 0x0000 },

-  { 0x0700, 0xa2e8, 0x0000 },

-  { 0x8700, 0xa2eb, 0x2000 },

-  { 0x0700, 0xa2ea, 0x0000 },

-  { 0x0700, 0xa2ec, 0x0000 },

-  { 0x8700, 0xa2fd, 0x5000 },

-  { 0x8700, 0xa2f5, 0x4000 },

-  { 0x8700, 0xa2f1, 0x3000 },

-  { 0x8700, 0xa2ef, 0x2000 },

-  { 0x0700, 0xa2ee, 0x0000 },

-  { 0x0700, 0xa2f0, 0x0000 },

-  { 0x8700, 0xa2f3, 0x2000 },

-  { 0x0700, 0xa2f2, 0x0000 },

-  { 0x0700, 0xa2f4, 0x0000 },

-  { 0x8700, 0xa2f9, 0x3000 },

-  { 0x8700, 0xa2f7, 0x2000 },

-  { 0x0700, 0xa2f6, 0x0000 },

-  { 0x0700, 0xa2f8, 0x0000 },

-  { 0x8700, 0xa2fb, 0x2000 },

-  { 0x0700, 0xa2fa, 0x0000 },

-  { 0x0700, 0xa2fc, 0x0000 },

-  { 0x8700, 0xa305, 0x4000 },

-  { 0x8700, 0xa301, 0x3000 },

-  { 0x8700, 0xa2ff, 0x2000 },

-  { 0x0700, 0xa2fe, 0x0000 },

-  { 0x0700, 0xa300, 0x0000 },

-  { 0x8700, 0xa303, 0x2000 },

-  { 0x0700, 0xa302, 0x0000 },

-  { 0x0700, 0xa304, 0x0000 },

-  { 0x8700, 0xa309, 0x3000 },

-  { 0x8700, 0xa307, 0x2000 },

-  { 0x0700, 0xa306, 0x0000 },

-  { 0x0700, 0xa308, 0x0000 },

-  { 0x8700, 0xa30b, 0x2000 },

-  { 0x0700, 0xa30a, 0x0000 },

-  { 0x0700, 0xa30c, 0x0000 },

-  { 0x8700, 0xa32d, 0x6000 },

-  { 0x8700, 0xa31d, 0x5000 },

-  { 0x8700, 0xa315, 0x4000 },

-  { 0x8700, 0xa311, 0x3000 },

-  { 0x8700, 0xa30f, 0x2000 },

-  { 0x0700, 0xa30e, 0x0000 },

-  { 0x0700, 0xa310, 0x0000 },

-  { 0x8700, 0xa313, 0x2000 },

-  { 0x0700, 0xa312, 0x0000 },

-  { 0x0700, 0xa314, 0x0000 },

-  { 0x8700, 0xa319, 0x3000 },

-  { 0x8700, 0xa317, 0x2000 },

-  { 0x0700, 0xa316, 0x0000 },

-  { 0x0700, 0xa318, 0x0000 },

-  { 0x8700, 0xa31b, 0x2000 },

-  { 0x0700, 0xa31a, 0x0000 },

-  { 0x0700, 0xa31c, 0x0000 },

-  { 0x8700, 0xa325, 0x4000 },

-  { 0x8700, 0xa321, 0x3000 },

-  { 0x8700, 0xa31f, 0x2000 },

-  { 0x0700, 0xa31e, 0x0000 },

-  { 0x0700, 0xa320, 0x0000 },

-  { 0x8700, 0xa323, 0x2000 },

-  { 0x0700, 0xa322, 0x0000 },

-  { 0x0700, 0xa324, 0x0000 },

-  { 0x8700, 0xa329, 0x3000 },

-  { 0x8700, 0xa327, 0x2000 },

-  { 0x0700, 0xa326, 0x0000 },

-  { 0x0700, 0xa328, 0x0000 },

-  { 0x8700, 0xa32b, 0x2000 },

-  { 0x0700, 0xa32a, 0x0000 },

-  { 0x0700, 0xa32c, 0x0000 },

-  { 0x8700, 0xa33d, 0x5000 },

-  { 0x8700, 0xa335, 0x4000 },

-  { 0x8700, 0xa331, 0x3000 },

-  { 0x8700, 0xa32f, 0x2000 },

-  { 0x0700, 0xa32e, 0x0000 },

-  { 0x0700, 0xa330, 0x0000 },

-  { 0x8700, 0xa333, 0x2000 },

-  { 0x0700, 0xa332, 0x0000 },

-  { 0x0700, 0xa334, 0x0000 },

-  { 0x8700, 0xa339, 0x3000 },

-  { 0x8700, 0xa337, 0x2000 },

-  { 0x0700, 0xa336, 0x0000 },

-  { 0x0700, 0xa338, 0x0000 },

-  { 0x8700, 0xa33b, 0x2000 },

-  { 0x0700, 0xa33a, 0x0000 },

-  { 0x0700, 0xa33c, 0x0000 },

-  { 0x8700, 0xa345, 0x4000 },

-  { 0x8700, 0xa341, 0x3000 },

-  { 0x8700, 0xa33f, 0x2000 },

-  { 0x0700, 0xa33e, 0x0000 },

-  { 0x0700, 0xa340, 0x0000 },

-  { 0x8700, 0xa343, 0x2000 },

-  { 0x0700, 0xa342, 0x0000 },

-  { 0x0700, 0xa344, 0x0000 },

-  { 0x8700, 0xa349, 0x3000 },

-  { 0x8700, 0xa347, 0x2000 },

-  { 0x0700, 0xa346, 0x0000 },

-  { 0x0700, 0xa348, 0x0000 },

-  { 0x8700, 0xa34b, 0x2000 },

-  { 0x0700, 0xa34a, 0x0000 },

-  { 0x0700, 0xa34c, 0x0000 },

-  { 0x8700, 0xfc4d, 0xb000 },

-  { 0x8700, 0xf97f, 0xa000 },

-  { 0x8700, 0xa44d, 0x9000 },

-  { 0x8700, 0xa3cd, 0x8000 },

-  { 0x8700, 0xa38d, 0x7000 },

-  { 0x8700, 0xa36d, 0x6000 },

-  { 0x8700, 0xa35d, 0x5000 },

-  { 0x8700, 0xa355, 0x4000 },

-  { 0x8700, 0xa351, 0x3000 },

-  { 0x8700, 0xa34f, 0x2000 },

-  { 0x0700, 0xa34e, 0x0000 },

-  { 0x0700, 0xa350, 0x0000 },

-  { 0x8700, 0xa353, 0x2000 },

-  { 0x0700, 0xa352, 0x0000 },

-  { 0x0700, 0xa354, 0x0000 },

-  { 0x8700, 0xa359, 0x3000 },

-  { 0x8700, 0xa357, 0x2000 },

-  { 0x0700, 0xa356, 0x0000 },

-  { 0x0700, 0xa358, 0x0000 },

-  { 0x8700, 0xa35b, 0x2000 },

-  { 0x0700, 0xa35a, 0x0000 },

-  { 0x0700, 0xa35c, 0x0000 },

-  { 0x8700, 0xa365, 0x4000 },

-  { 0x8700, 0xa361, 0x3000 },

-  { 0x8700, 0xa35f, 0x2000 },

-  { 0x0700, 0xa35e, 0x0000 },

-  { 0x0700, 0xa360, 0x0000 },

-  { 0x8700, 0xa363, 0x2000 },

-  { 0x0700, 0xa362, 0x0000 },

-  { 0x0700, 0xa364, 0x0000 },

-  { 0x8700, 0xa369, 0x3000 },

-  { 0x8700, 0xa367, 0x2000 },

-  { 0x0700, 0xa366, 0x0000 },

-  { 0x0700, 0xa368, 0x0000 },

-  { 0x8700, 0xa36b, 0x2000 },

-  { 0x0700, 0xa36a, 0x0000 },

-  { 0x0700, 0xa36c, 0x0000 },

-  { 0x8700, 0xa37d, 0x5000 },

-  { 0x8700, 0xa375, 0x4000 },

-  { 0x8700, 0xa371, 0x3000 },

-  { 0x8700, 0xa36f, 0x2000 },

-  { 0x0700, 0xa36e, 0x0000 },

-  { 0x0700, 0xa370, 0x0000 },

-  { 0x8700, 0xa373, 0x2000 },

-  { 0x0700, 0xa372, 0x0000 },

-  { 0x0700, 0xa374, 0x0000 },

-  { 0x8700, 0xa379, 0x3000 },

-  { 0x8700, 0xa377, 0x2000 },

-  { 0x0700, 0xa376, 0x0000 },

-  { 0x0700, 0xa378, 0x0000 },

-  { 0x8700, 0xa37b, 0x2000 },

-  { 0x0700, 0xa37a, 0x0000 },

-  { 0x0700, 0xa37c, 0x0000 },

-  { 0x8700, 0xa385, 0x4000 },

-  { 0x8700, 0xa381, 0x3000 },

-  { 0x8700, 0xa37f, 0x2000 },

-  { 0x0700, 0xa37e, 0x0000 },

-  { 0x0700, 0xa380, 0x0000 },

-  { 0x8700, 0xa383, 0x2000 },

-  { 0x0700, 0xa382, 0x0000 },

-  { 0x0700, 0xa384, 0x0000 },

-  { 0x8700, 0xa389, 0x3000 },

-  { 0x8700, 0xa387, 0x2000 },

-  { 0x0700, 0xa386, 0x0000 },

-  { 0x0700, 0xa388, 0x0000 },

-  { 0x8700, 0xa38b, 0x2000 },

-  { 0x0700, 0xa38a, 0x0000 },

-  { 0x0700, 0xa38c, 0x0000 },

-  { 0x8700, 0xa3ad, 0x6000 },

-  { 0x8700, 0xa39d, 0x5000 },

-  { 0x8700, 0xa395, 0x4000 },

-  { 0x8700, 0xa391, 0x3000 },

-  { 0x8700, 0xa38f, 0x2000 },

-  { 0x0700, 0xa38e, 0x0000 },

-  { 0x0700, 0xa390, 0x0000 },

-  { 0x8700, 0xa393, 0x2000 },

-  { 0x0700, 0xa392, 0x0000 },

-  { 0x0700, 0xa394, 0x0000 },

-  { 0x8700, 0xa399, 0x3000 },

-  { 0x8700, 0xa397, 0x2000 },

-  { 0x0700, 0xa396, 0x0000 },

-  { 0x0700, 0xa398, 0x0000 },

-  { 0x8700, 0xa39b, 0x2000 },

-  { 0x0700, 0xa39a, 0x0000 },

-  { 0x0700, 0xa39c, 0x0000 },

-  { 0x8700, 0xa3a5, 0x4000 },

-  { 0x8700, 0xa3a1, 0x3000 },

-  { 0x8700, 0xa39f, 0x2000 },

-  { 0x0700, 0xa39e, 0x0000 },

-  { 0x0700, 0xa3a0, 0x0000 },

-  { 0x8700, 0xa3a3, 0x2000 },

-  { 0x0700, 0xa3a2, 0x0000 },

-  { 0x0700, 0xa3a4, 0x0000 },

-  { 0x8700, 0xa3a9, 0x3000 },

-  { 0x8700, 0xa3a7, 0x2000 },

-  { 0x0700, 0xa3a6, 0x0000 },

-  { 0x0700, 0xa3a8, 0x0000 },

-  { 0x8700, 0xa3ab, 0x2000 },

-  { 0x0700, 0xa3aa, 0x0000 },

-  { 0x0700, 0xa3ac, 0x0000 },

-  { 0x8700, 0xa3bd, 0x5000 },

-  { 0x8700, 0xa3b5, 0x4000 },

-  { 0x8700, 0xa3b1, 0x3000 },

-  { 0x8700, 0xa3af, 0x2000 },

-  { 0x0700, 0xa3ae, 0x0000 },

-  { 0x0700, 0xa3b0, 0x0000 },

-  { 0x8700, 0xa3b3, 0x2000 },

-  { 0x0700, 0xa3b2, 0x0000 },

-  { 0x0700, 0xa3b4, 0x0000 },

-  { 0x8700, 0xa3b9, 0x3000 },

-  { 0x8700, 0xa3b7, 0x2000 },

-  { 0x0700, 0xa3b6, 0x0000 },

-  { 0x0700, 0xa3b8, 0x0000 },

-  { 0x8700, 0xa3bb, 0x2000 },

-  { 0x0700, 0xa3ba, 0x0000 },

-  { 0x0700, 0xa3bc, 0x0000 },

-  { 0x8700, 0xa3c5, 0x4000 },

-  { 0x8700, 0xa3c1, 0x3000 },

-  { 0x8700, 0xa3bf, 0x2000 },

-  { 0x0700, 0xa3be, 0x0000 },

-  { 0x0700, 0xa3c0, 0x0000 },

-  { 0x8700, 0xa3c3, 0x2000 },

-  { 0x0700, 0xa3c2, 0x0000 },

-  { 0x0700, 0xa3c4, 0x0000 },

-  { 0x8700, 0xa3c9, 0x3000 },

-  { 0x8700, 0xa3c7, 0x2000 },

-  { 0x0700, 0xa3c6, 0x0000 },

-  { 0x0700, 0xa3c8, 0x0000 },

-  { 0x8700, 0xa3cb, 0x2000 },

-  { 0x0700, 0xa3ca, 0x0000 },

-  { 0x0700, 0xa3cc, 0x0000 },

-  { 0x8700, 0xa40d, 0x7000 },

-  { 0x8700, 0xa3ed, 0x6000 },

-  { 0x8700, 0xa3dd, 0x5000 },

-  { 0x8700, 0xa3d5, 0x4000 },

-  { 0x8700, 0xa3d1, 0x3000 },

-  { 0x8700, 0xa3cf, 0x2000 },

-  { 0x0700, 0xa3ce, 0x0000 },

-  { 0x0700, 0xa3d0, 0x0000 },

-  { 0x8700, 0xa3d3, 0x2000 },

-  { 0x0700, 0xa3d2, 0x0000 },

-  { 0x0700, 0xa3d4, 0x0000 },

-  { 0x8700, 0xa3d9, 0x3000 },

-  { 0x8700, 0xa3d7, 0x2000 },

-  { 0x0700, 0xa3d6, 0x0000 },

-  { 0x0700, 0xa3d8, 0x0000 },

-  { 0x8700, 0xa3db, 0x2000 },

-  { 0x0700, 0xa3da, 0x0000 },

-  { 0x0700, 0xa3dc, 0x0000 },

-  { 0x8700, 0xa3e5, 0x4000 },

-  { 0x8700, 0xa3e1, 0x3000 },

-  { 0x8700, 0xa3df, 0x2000 },

-  { 0x0700, 0xa3de, 0x0000 },

-  { 0x0700, 0xa3e0, 0x0000 },

-  { 0x8700, 0xa3e3, 0x2000 },

-  { 0x0700, 0xa3e2, 0x0000 },

-  { 0x0700, 0xa3e4, 0x0000 },

-  { 0x8700, 0xa3e9, 0x3000 },

-  { 0x8700, 0xa3e7, 0x2000 },

-  { 0x0700, 0xa3e6, 0x0000 },

-  { 0x0700, 0xa3e8, 0x0000 },

-  { 0x8700, 0xa3eb, 0x2000 },

-  { 0x0700, 0xa3ea, 0x0000 },

-  { 0x0700, 0xa3ec, 0x0000 },

-  { 0x8700, 0xa3fd, 0x5000 },

-  { 0x8700, 0xa3f5, 0x4000 },

-  { 0x8700, 0xa3f1, 0x3000 },

-  { 0x8700, 0xa3ef, 0x2000 },

-  { 0x0700, 0xa3ee, 0x0000 },

-  { 0x0700, 0xa3f0, 0x0000 },

-  { 0x8700, 0xa3f3, 0x2000 },

-  { 0x0700, 0xa3f2, 0x0000 },

-  { 0x0700, 0xa3f4, 0x0000 },

-  { 0x8700, 0xa3f9, 0x3000 },

-  { 0x8700, 0xa3f7, 0x2000 },

-  { 0x0700, 0xa3f6, 0x0000 },

-  { 0x0700, 0xa3f8, 0x0000 },

-  { 0x8700, 0xa3fb, 0x2000 },

-  { 0x0700, 0xa3fa, 0x0000 },

-  { 0x0700, 0xa3fc, 0x0000 },

-  { 0x8700, 0xa405, 0x4000 },

-  { 0x8700, 0xa401, 0x3000 },

-  { 0x8700, 0xa3ff, 0x2000 },

-  { 0x0700, 0xa3fe, 0x0000 },

-  { 0x0700, 0xa400, 0x0000 },

-  { 0x8700, 0xa403, 0x2000 },

-  { 0x0700, 0xa402, 0x0000 },

-  { 0x0700, 0xa404, 0x0000 },

-  { 0x8700, 0xa409, 0x3000 },

-  { 0x8700, 0xa407, 0x2000 },

-  { 0x0700, 0xa406, 0x0000 },

-  { 0x0700, 0xa408, 0x0000 },

-  { 0x8700, 0xa40b, 0x2000 },

-  { 0x0700, 0xa40a, 0x0000 },

-  { 0x0700, 0xa40c, 0x0000 },

-  { 0x8700, 0xa42d, 0x6000 },

-  { 0x8700, 0xa41d, 0x5000 },

-  { 0x8700, 0xa415, 0x4000 },

-  { 0x8700, 0xa411, 0x3000 },

-  { 0x8700, 0xa40f, 0x2000 },

-  { 0x0700, 0xa40e, 0x0000 },

-  { 0x0700, 0xa410, 0x0000 },

-  { 0x8700, 0xa413, 0x2000 },

-  { 0x0700, 0xa412, 0x0000 },

-  { 0x0700, 0xa414, 0x0000 },

-  { 0x8700, 0xa419, 0x3000 },

-  { 0x8700, 0xa417, 0x2000 },

-  { 0x0700, 0xa416, 0x0000 },

-  { 0x0700, 0xa418, 0x0000 },

-  { 0x8700, 0xa41b, 0x2000 },

-  { 0x0700, 0xa41a, 0x0000 },

-  { 0x0700, 0xa41c, 0x0000 },

-  { 0x8700, 0xa425, 0x4000 },

-  { 0x8700, 0xa421, 0x3000 },

-  { 0x8700, 0xa41f, 0x2000 },

-  { 0x0700, 0xa41e, 0x0000 },

-  { 0x0700, 0xa420, 0x0000 },

-  { 0x8700, 0xa423, 0x2000 },

-  { 0x0700, 0xa422, 0x0000 },

-  { 0x0700, 0xa424, 0x0000 },

-  { 0x8700, 0xa429, 0x3000 },

-  { 0x8700, 0xa427, 0x2000 },

-  { 0x0700, 0xa426, 0x0000 },

-  { 0x0700, 0xa428, 0x0000 },

-  { 0x8700, 0xa42b, 0x2000 },

-  { 0x0700, 0xa42a, 0x0000 },

-  { 0x0700, 0xa42c, 0x0000 },

-  { 0x8700, 0xa43d, 0x5000 },

-  { 0x8700, 0xa435, 0x4000 },

-  { 0x8700, 0xa431, 0x3000 },

-  { 0x8700, 0xa42f, 0x2000 },

-  { 0x0700, 0xa42e, 0x0000 },

-  { 0x0700, 0xa430, 0x0000 },

-  { 0x8700, 0xa433, 0x2000 },

-  { 0x0700, 0xa432, 0x0000 },

-  { 0x0700, 0xa434, 0x0000 },

-  { 0x8700, 0xa439, 0x3000 },

-  { 0x8700, 0xa437, 0x2000 },

-  { 0x0700, 0xa436, 0x0000 },

-  { 0x0700, 0xa438, 0x0000 },

-  { 0x8700, 0xa43b, 0x2000 },

-  { 0x0700, 0xa43a, 0x0000 },

-  { 0x0700, 0xa43c, 0x0000 },

-  { 0x8700, 0xa445, 0x4000 },

-  { 0x8700, 0xa441, 0x3000 },

-  { 0x8700, 0xa43f, 0x2000 },

-  { 0x0700, 0xa43e, 0x0000 },

-  { 0x0700, 0xa440, 0x0000 },

-  { 0x8700, 0xa443, 0x2000 },

-  { 0x0700, 0xa442, 0x0000 },

-  { 0x0700, 0xa444, 0x0000 },

-  { 0x8700, 0xa449, 0x3000 },

-  { 0x8700, 0xa447, 0x2000 },

-  { 0x0700, 0xa446, 0x0000 },

-  { 0x0700, 0xa448, 0x0000 },

-  { 0x8700, 0xa44b, 0x2000 },

-  { 0x0700, 0xa44a, 0x0000 },

-  { 0x0700, 0xa44c, 0x0000 },

-  { 0x8300, 0xf8ff, 0x8000 },

-  { 0x9a00, 0xa490, 0x7000 },

-  { 0x8700, 0xa46d, 0x6000 },

-  { 0x8700, 0xa45d, 0x5000 },

-  { 0x8700, 0xa455, 0x4000 },

-  { 0x8700, 0xa451, 0x3000 },

-  { 0x8700, 0xa44f, 0x2000 },

-  { 0x0700, 0xa44e, 0x0000 },

-  { 0x0700, 0xa450, 0x0000 },

-  { 0x8700, 0xa453, 0x2000 },

-  { 0x0700, 0xa452, 0x0000 },

-  { 0x0700, 0xa454, 0x0000 },

-  { 0x8700, 0xa459, 0x3000 },

-  { 0x8700, 0xa457, 0x2000 },

-  { 0x0700, 0xa456, 0x0000 },

-  { 0x0700, 0xa458, 0x0000 },

-  { 0x8700, 0xa45b, 0x2000 },

-  { 0x0700, 0xa45a, 0x0000 },

-  { 0x0700, 0xa45c, 0x0000 },

-  { 0x8700, 0xa465, 0x4000 },

-  { 0x8700, 0xa461, 0x3000 },

-  { 0x8700, 0xa45f, 0x2000 },

-  { 0x0700, 0xa45e, 0x0000 },

-  { 0x0700, 0xa460, 0x0000 },

-  { 0x8700, 0xa463, 0x2000 },

-  { 0x0700, 0xa462, 0x0000 },

-  { 0x0700, 0xa464, 0x0000 },

-  { 0x8700, 0xa469, 0x3000 },

-  { 0x8700, 0xa467, 0x2000 },

-  { 0x0700, 0xa466, 0x0000 },

-  { 0x0700, 0xa468, 0x0000 },

-  { 0x8700, 0xa46b, 0x2000 },

-  { 0x0700, 0xa46a, 0x0000 },

-  { 0x0700, 0xa46c, 0x0000 },

-  { 0x8700, 0xa47d, 0x5000 },

-  { 0x8700, 0xa475, 0x4000 },

-  { 0x8700, 0xa471, 0x3000 },

-  { 0x8700, 0xa46f, 0x2000 },

-  { 0x0700, 0xa46e, 0x0000 },

-  { 0x0700, 0xa470, 0x0000 },

-  { 0x8700, 0xa473, 0x2000 },

-  { 0x0700, 0xa472, 0x0000 },

-  { 0x0700, 0xa474, 0x0000 },

-  { 0x8700, 0xa479, 0x3000 },

-  { 0x8700, 0xa477, 0x2000 },

-  { 0x0700, 0xa476, 0x0000 },

-  { 0x0700, 0xa478, 0x0000 },

-  { 0x8700, 0xa47b, 0x2000 },

-  { 0x0700, 0xa47a, 0x0000 },

-  { 0x0700, 0xa47c, 0x0000 },

-  { 0x8700, 0xa485, 0x4000 },

-  { 0x8700, 0xa481, 0x3000 },

-  { 0x8700, 0xa47f, 0x2000 },

-  { 0x0700, 0xa47e, 0x0000 },

-  { 0x0700, 0xa480, 0x0000 },

-  { 0x8700, 0xa483, 0x2000 },

-  { 0x0700, 0xa482, 0x0000 },

-  { 0x0700, 0xa484, 0x0000 },

-  { 0x8700, 0xa489, 0x3000 },

-  { 0x8700, 0xa487, 0x2000 },

-  { 0x0700, 0xa486, 0x0000 },

-  { 0x0700, 0xa488, 0x0000 },

-  { 0x8700, 0xa48b, 0x2000 },

-  { 0x0700, 0xa48a, 0x0000 },

-  { 0x0700, 0xa48c, 0x0000 },

-  { 0x9a00, 0xa4b0, 0x6000 },

-  { 0x9a00, 0xa4a0, 0x5000 },

-  { 0x9a00, 0xa498, 0x4000 },

-  { 0x9a00, 0xa494, 0x3000 },

-  { 0x9a00, 0xa492, 0x2000 },

-  { 0x1a00, 0xa491, 0x0000 },

-  { 0x1a00, 0xa493, 0x0000 },

-  { 0x9a00, 0xa496, 0x2000 },

-  { 0x1a00, 0xa495, 0x0000 },

-  { 0x1a00, 0xa497, 0x0000 },

-  { 0x9a00, 0xa49c, 0x3000 },

-  { 0x9a00, 0xa49a, 0x2000 },

-  { 0x1a00, 0xa499, 0x0000 },

-  { 0x1a00, 0xa49b, 0x0000 },

-  { 0x9a00, 0xa49e, 0x2000 },

-  { 0x1a00, 0xa49d, 0x0000 },

-  { 0x1a00, 0xa49f, 0x0000 },

-  { 0x9a00, 0xa4a8, 0x4000 },

-  { 0x9a00, 0xa4a4, 0x3000 },

-  { 0x9a00, 0xa4a2, 0x2000 },

-  { 0x1a00, 0xa4a1, 0x0000 },

-  { 0x1a00, 0xa4a3, 0x0000 },

-  { 0x9a00, 0xa4a6, 0x2000 },

-  { 0x1a00, 0xa4a5, 0x0000 },

-  { 0x1a00, 0xa4a7, 0x0000 },

-  { 0x9a00, 0xa4ac, 0x3000 },

-  { 0x9a00, 0xa4aa, 0x2000 },

-  { 0x1a00, 0xa4a9, 0x0000 },

-  { 0x1a00, 0xa4ab, 0x0000 },

-  { 0x9a00, 0xa4ae, 0x2000 },

-  { 0x1a00, 0xa4ad, 0x0000 },

-  { 0x1a00, 0xa4af, 0x0000 },

-  { 0x9a00, 0xa4c0, 0x5000 },

-  { 0x9a00, 0xa4b8, 0x4000 },

-  { 0x9a00, 0xa4b4, 0x3000 },

-  { 0x9a00, 0xa4b2, 0x2000 },

-  { 0x1a00, 0xa4b1, 0x0000 },

-  { 0x1a00, 0xa4b3, 0x0000 },

-  { 0x9a00, 0xa4b6, 0x2000 },

-  { 0x1a00, 0xa4b5, 0x0000 },

-  { 0x1a00, 0xa4b7, 0x0000 },

-  { 0x9a00, 0xa4bc, 0x3000 },

-  { 0x9a00, 0xa4ba, 0x2000 },

-  { 0x1a00, 0xa4b9, 0x0000 },

-  { 0x1a00, 0xa4bb, 0x0000 },

-  { 0x9a00, 0xa4be, 0x2000 },

-  { 0x1a00, 0xa4bd, 0x0000 },

-  { 0x1a00, 0xa4bf, 0x0000 },

-  { 0x8700, 0xd7a3, 0x4000 },

-  { 0x9a00, 0xa4c4, 0x3000 },

-  { 0x9a00, 0xa4c2, 0x2000 },

-  { 0x1a00, 0xa4c1, 0x0000 },

-  { 0x1a00, 0xa4c3, 0x0000 },

-  { 0x9a00, 0xa4c6, 0x2000 },

-  { 0x1a00, 0xa4c5, 0x0000 },

-  { 0x0700, 0xac00, 0x0000 },

-  { 0x8400, 0xdbff, 0x3000 },

-  { 0x8400, 0xdb7f, 0x2000 },

-  { 0x0400, 0xd800, 0x0000 },

-  { 0x0400, 0xdb80, 0x0000 },

-  { 0x8400, 0xdfff, 0x2000 },

-  { 0x0400, 0xdc00, 0x0000 },

-  { 0x0300, 0xe000, 0x0000 },

-  { 0x8700, 0xf93f, 0x7000 },

-  { 0x8700, 0xf91f, 0x6000 },

-  { 0x8700, 0xf90f, 0x5000 },

-  { 0x8700, 0xf907, 0x4000 },

-  { 0x8700, 0xf903, 0x3000 },

-  { 0x8700, 0xf901, 0x2000 },

-  { 0x0700, 0xf900, 0x0000 },

-  { 0x0700, 0xf902, 0x0000 },

-  { 0x8700, 0xf905, 0x2000 },

-  { 0x0700, 0xf904, 0x0000 },

-  { 0x0700, 0xf906, 0x0000 },

-  { 0x8700, 0xf90b, 0x3000 },

-  { 0x8700, 0xf909, 0x2000 },

-  { 0x0700, 0xf908, 0x0000 },

-  { 0x0700, 0xf90a, 0x0000 },

-  { 0x8700, 0xf90d, 0x2000 },

-  { 0x0700, 0xf90c, 0x0000 },

-  { 0x0700, 0xf90e, 0x0000 },

-  { 0x8700, 0xf917, 0x4000 },

-  { 0x8700, 0xf913, 0x3000 },

-  { 0x8700, 0xf911, 0x2000 },

-  { 0x0700, 0xf910, 0x0000 },

-  { 0x0700, 0xf912, 0x0000 },

-  { 0x8700, 0xf915, 0x2000 },

-  { 0x0700, 0xf914, 0x0000 },

-  { 0x0700, 0xf916, 0x0000 },

-  { 0x8700, 0xf91b, 0x3000 },

-  { 0x8700, 0xf919, 0x2000 },

-  { 0x0700, 0xf918, 0x0000 },

-  { 0x0700, 0xf91a, 0x0000 },

-  { 0x8700, 0xf91d, 0x2000 },

-  { 0x0700, 0xf91c, 0x0000 },

-  { 0x0700, 0xf91e, 0x0000 },

-  { 0x8700, 0xf92f, 0x5000 },

-  { 0x8700, 0xf927, 0x4000 },

-  { 0x8700, 0xf923, 0x3000 },

-  { 0x8700, 0xf921, 0x2000 },

-  { 0x0700, 0xf920, 0x0000 },

-  { 0x0700, 0xf922, 0x0000 },

-  { 0x8700, 0xf925, 0x2000 },

-  { 0x0700, 0xf924, 0x0000 },

-  { 0x0700, 0xf926, 0x0000 },

-  { 0x8700, 0xf92b, 0x3000 },

-  { 0x8700, 0xf929, 0x2000 },

-  { 0x0700, 0xf928, 0x0000 },

-  { 0x0700, 0xf92a, 0x0000 },

-  { 0x8700, 0xf92d, 0x2000 },

-  { 0x0700, 0xf92c, 0x0000 },

-  { 0x0700, 0xf92e, 0x0000 },

-  { 0x8700, 0xf937, 0x4000 },

-  { 0x8700, 0xf933, 0x3000 },

-  { 0x8700, 0xf931, 0x2000 },

-  { 0x0700, 0xf930, 0x0000 },

-  { 0x0700, 0xf932, 0x0000 },

-  { 0x8700, 0xf935, 0x2000 },

-  { 0x0700, 0xf934, 0x0000 },

-  { 0x0700, 0xf936, 0x0000 },

-  { 0x8700, 0xf93b, 0x3000 },

-  { 0x8700, 0xf939, 0x2000 },

-  { 0x0700, 0xf938, 0x0000 },

-  { 0x0700, 0xf93a, 0x0000 },

-  { 0x8700, 0xf93d, 0x2000 },

-  { 0x0700, 0xf93c, 0x0000 },

-  { 0x0700, 0xf93e, 0x0000 },

-  { 0x8700, 0xf95f, 0x6000 },

-  { 0x8700, 0xf94f, 0x5000 },

-  { 0x8700, 0xf947, 0x4000 },

-  { 0x8700, 0xf943, 0x3000 },

-  { 0x8700, 0xf941, 0x2000 },

-  { 0x0700, 0xf940, 0x0000 },

-  { 0x0700, 0xf942, 0x0000 },

-  { 0x8700, 0xf945, 0x2000 },

-  { 0x0700, 0xf944, 0x0000 },

-  { 0x0700, 0xf946, 0x0000 },

-  { 0x8700, 0xf94b, 0x3000 },

-  { 0x8700, 0xf949, 0x2000 },

-  { 0x0700, 0xf948, 0x0000 },

-  { 0x0700, 0xf94a, 0x0000 },

-  { 0x8700, 0xf94d, 0x2000 },

-  { 0x0700, 0xf94c, 0x0000 },

-  { 0x0700, 0xf94e, 0x0000 },

-  { 0x8700, 0xf957, 0x4000 },

-  { 0x8700, 0xf953, 0x3000 },

-  { 0x8700, 0xf951, 0x2000 },

-  { 0x0700, 0xf950, 0x0000 },

-  { 0x0700, 0xf952, 0x0000 },

-  { 0x8700, 0xf955, 0x2000 },

-  { 0x0700, 0xf954, 0x0000 },

-  { 0x0700, 0xf956, 0x0000 },

-  { 0x8700, 0xf95b, 0x3000 },

-  { 0x8700, 0xf959, 0x2000 },

-  { 0x0700, 0xf958, 0x0000 },

-  { 0x0700, 0xf95a, 0x0000 },

-  { 0x8700, 0xf95d, 0x2000 },

-  { 0x0700, 0xf95c, 0x0000 },

-  { 0x0700, 0xf95e, 0x0000 },

-  { 0x8700, 0xf96f, 0x5000 },

-  { 0x8700, 0xf967, 0x4000 },

-  { 0x8700, 0xf963, 0x3000 },

-  { 0x8700, 0xf961, 0x2000 },

-  { 0x0700, 0xf960, 0x0000 },

-  { 0x0700, 0xf962, 0x0000 },

-  { 0x8700, 0xf965, 0x2000 },

-  { 0x0700, 0xf964, 0x0000 },

-  { 0x0700, 0xf966, 0x0000 },

-  { 0x8700, 0xf96b, 0x3000 },

-  { 0x8700, 0xf969, 0x2000 },

-  { 0x0700, 0xf968, 0x0000 },

-  { 0x0700, 0xf96a, 0x0000 },

-  { 0x8700, 0xf96d, 0x2000 },

-  { 0x0700, 0xf96c, 0x0000 },

-  { 0x0700, 0xf96e, 0x0000 },

-  { 0x8700, 0xf977, 0x4000 },

-  { 0x8700, 0xf973, 0x3000 },

-  { 0x8700, 0xf971, 0x2000 },

-  { 0x0700, 0xf970, 0x0000 },

-  { 0x0700, 0xf972, 0x0000 },

-  { 0x8700, 0xf975, 0x2000 },

-  { 0x0700, 0xf974, 0x0000 },

-  { 0x0700, 0xf976, 0x0000 },

-  { 0x8700, 0xf97b, 0x3000 },

-  { 0x8700, 0xf979, 0x2000 },

-  { 0x0700, 0xf978, 0x0000 },

-  { 0x0700, 0xf97a, 0x0000 },

-  { 0x8700, 0xf97d, 0x2000 },

-  { 0x0700, 0xf97c, 0x0000 },

-  { 0x0700, 0xf97e, 0x0000 },

-  { 0x8700, 0xfb27, 0x9000 },

-  { 0x8700, 0xf9ff, 0x8000 },

-  { 0x8700, 0xf9bf, 0x7000 },

-  { 0x8700, 0xf99f, 0x6000 },

-  { 0x8700, 0xf98f, 0x5000 },

-  { 0x8700, 0xf987, 0x4000 },

-  { 0x8700, 0xf983, 0x3000 },

-  { 0x8700, 0xf981, 0x2000 },

-  { 0x0700, 0xf980, 0x0000 },

-  { 0x0700, 0xf982, 0x0000 },

-  { 0x8700, 0xf985, 0x2000 },

-  { 0x0700, 0xf984, 0x0000 },

-  { 0x0700, 0xf986, 0x0000 },

-  { 0x8700, 0xf98b, 0x3000 },

-  { 0x8700, 0xf989, 0x2000 },

-  { 0x0700, 0xf988, 0x0000 },

-  { 0x0700, 0xf98a, 0x0000 },

-  { 0x8700, 0xf98d, 0x2000 },

-  { 0x0700, 0xf98c, 0x0000 },

-  { 0x0700, 0xf98e, 0x0000 },

-  { 0x8700, 0xf997, 0x4000 },

-  { 0x8700, 0xf993, 0x3000 },

-  { 0x8700, 0xf991, 0x2000 },

-  { 0x0700, 0xf990, 0x0000 },

-  { 0x0700, 0xf992, 0x0000 },

-  { 0x8700, 0xf995, 0x2000 },

-  { 0x0700, 0xf994, 0x0000 },

-  { 0x0700, 0xf996, 0x0000 },

-  { 0x8700, 0xf99b, 0x3000 },

-  { 0x8700, 0xf999, 0x2000 },

-  { 0x0700, 0xf998, 0x0000 },

-  { 0x0700, 0xf99a, 0x0000 },

-  { 0x8700, 0xf99d, 0x2000 },

-  { 0x0700, 0xf99c, 0x0000 },

-  { 0x0700, 0xf99e, 0x0000 },

-  { 0x8700, 0xf9af, 0x5000 },

-  { 0x8700, 0xf9a7, 0x4000 },

-  { 0x8700, 0xf9a3, 0x3000 },

-  { 0x8700, 0xf9a1, 0x2000 },

-  { 0x0700, 0xf9a0, 0x0000 },

-  { 0x0700, 0xf9a2, 0x0000 },

-  { 0x8700, 0xf9a5, 0x2000 },

-  { 0x0700, 0xf9a4, 0x0000 },

-  { 0x0700, 0xf9a6, 0x0000 },

-  { 0x8700, 0xf9ab, 0x3000 },

-  { 0x8700, 0xf9a9, 0x2000 },

-  { 0x0700, 0xf9a8, 0x0000 },

-  { 0x0700, 0xf9aa, 0x0000 },

-  { 0x8700, 0xf9ad, 0x2000 },

-  { 0x0700, 0xf9ac, 0x0000 },

-  { 0x0700, 0xf9ae, 0x0000 },

-  { 0x8700, 0xf9b7, 0x4000 },

-  { 0x8700, 0xf9b3, 0x3000 },

-  { 0x8700, 0xf9b1, 0x2000 },

-  { 0x0700, 0xf9b0, 0x0000 },

-  { 0x0700, 0xf9b2, 0x0000 },

-  { 0x8700, 0xf9b5, 0x2000 },

-  { 0x0700, 0xf9b4, 0x0000 },

-  { 0x0700, 0xf9b6, 0x0000 },

-  { 0x8700, 0xf9bb, 0x3000 },

-  { 0x8700, 0xf9b9, 0x2000 },

-  { 0x0700, 0xf9b8, 0x0000 },

-  { 0x0700, 0xf9ba, 0x0000 },

-  { 0x8700, 0xf9bd, 0x2000 },

-  { 0x0700, 0xf9bc, 0x0000 },

-  { 0x0700, 0xf9be, 0x0000 },

-  { 0x8700, 0xf9df, 0x6000 },

-  { 0x8700, 0xf9cf, 0x5000 },

-  { 0x8700, 0xf9c7, 0x4000 },

-  { 0x8700, 0xf9c3, 0x3000 },

-  { 0x8700, 0xf9c1, 0x2000 },

-  { 0x0700, 0xf9c0, 0x0000 },

-  { 0x0700, 0xf9c2, 0x0000 },

-  { 0x8700, 0xf9c5, 0x2000 },

-  { 0x0700, 0xf9c4, 0x0000 },

-  { 0x0700, 0xf9c6, 0x0000 },

-  { 0x8700, 0xf9cb, 0x3000 },

-  { 0x8700, 0xf9c9, 0x2000 },

-  { 0x0700, 0xf9c8, 0x0000 },

-  { 0x0700, 0xf9ca, 0x0000 },

-  { 0x8700, 0xf9cd, 0x2000 },

-  { 0x0700, 0xf9cc, 0x0000 },

-  { 0x0700, 0xf9ce, 0x0000 },

-  { 0x8700, 0xf9d7, 0x4000 },

-  { 0x8700, 0xf9d3, 0x3000 },

-  { 0x8700, 0xf9d1, 0x2000 },

-  { 0x0700, 0xf9d0, 0x0000 },

-  { 0x0700, 0xf9d2, 0x0000 },

-  { 0x8700, 0xf9d5, 0x2000 },

-  { 0x0700, 0xf9d4, 0x0000 },

-  { 0x0700, 0xf9d6, 0x0000 },

-  { 0x8700, 0xf9db, 0x3000 },

-  { 0x8700, 0xf9d9, 0x2000 },

-  { 0x0700, 0xf9d8, 0x0000 },

-  { 0x0700, 0xf9da, 0x0000 },

-  { 0x8700, 0xf9dd, 0x2000 },

-  { 0x0700, 0xf9dc, 0x0000 },

-  { 0x0700, 0xf9de, 0x0000 },

-  { 0x8700, 0xf9ef, 0x5000 },

-  { 0x8700, 0xf9e7, 0x4000 },

-  { 0x8700, 0xf9e3, 0x3000 },

-  { 0x8700, 0xf9e1, 0x2000 },

-  { 0x0700, 0xf9e0, 0x0000 },

-  { 0x0700, 0xf9e2, 0x0000 },

-  { 0x8700, 0xf9e5, 0x2000 },

-  { 0x0700, 0xf9e4, 0x0000 },

-  { 0x0700, 0xf9e6, 0x0000 },

-  { 0x8700, 0xf9eb, 0x3000 },

-  { 0x8700, 0xf9e9, 0x2000 },

-  { 0x0700, 0xf9e8, 0x0000 },

-  { 0x0700, 0xf9ea, 0x0000 },

-  { 0x8700, 0xf9ed, 0x2000 },

-  { 0x0700, 0xf9ec, 0x0000 },

-  { 0x0700, 0xf9ee, 0x0000 },

-  { 0x8700, 0xf9f7, 0x4000 },

-  { 0x8700, 0xf9f3, 0x3000 },

-  { 0x8700, 0xf9f1, 0x2000 },

-  { 0x0700, 0xf9f0, 0x0000 },

-  { 0x0700, 0xf9f2, 0x0000 },

-  { 0x8700, 0xf9f5, 0x2000 },

-  { 0x0700, 0xf9f4, 0x0000 },

-  { 0x0700, 0xf9f6, 0x0000 },

-  { 0x8700, 0xf9fb, 0x3000 },

-  { 0x8700, 0xf9f9, 0x2000 },

-  { 0x0700, 0xf9f8, 0x0000 },

-  { 0x0700, 0xf9fa, 0x0000 },

-  { 0x8700, 0xf9fd, 0x2000 },

-  { 0x0700, 0xf9fc, 0x0000 },

-  { 0x0700, 0xf9fe, 0x0000 },

-  { 0x8700, 0xfa41, 0x7000 },

-  { 0x8700, 0xfa1f, 0x6000 },

-  { 0x8700, 0xfa0f, 0x5000 },

-  { 0x8700, 0xfa07, 0x4000 },

-  { 0x8700, 0xfa03, 0x3000 },

-  { 0x8700, 0xfa01, 0x2000 },

-  { 0x0700, 0xfa00, 0x0000 },

-  { 0x0700, 0xfa02, 0x0000 },

-  { 0x8700, 0xfa05, 0x2000 },

-  { 0x0700, 0xfa04, 0x0000 },

-  { 0x0700, 0xfa06, 0x0000 },

-  { 0x8700, 0xfa0b, 0x3000 },

-  { 0x8700, 0xfa09, 0x2000 },

-  { 0x0700, 0xfa08, 0x0000 },

-  { 0x0700, 0xfa0a, 0x0000 },

-  { 0x8700, 0xfa0d, 0x2000 },

-  { 0x0700, 0xfa0c, 0x0000 },

-  { 0x0700, 0xfa0e, 0x0000 },

-  { 0x8700, 0xfa17, 0x4000 },

-  { 0x8700, 0xfa13, 0x3000 },

-  { 0x8700, 0xfa11, 0x2000 },

-  { 0x0700, 0xfa10, 0x0000 },

-  { 0x0700, 0xfa12, 0x0000 },

-  { 0x8700, 0xfa15, 0x2000 },

-  { 0x0700, 0xfa14, 0x0000 },

-  { 0x0700, 0xfa16, 0x0000 },

-  { 0x8700, 0xfa1b, 0x3000 },

-  { 0x8700, 0xfa19, 0x2000 },

-  { 0x0700, 0xfa18, 0x0000 },

-  { 0x0700, 0xfa1a, 0x0000 },

-  { 0x8700, 0xfa1d, 0x2000 },

-  { 0x0700, 0xfa1c, 0x0000 },

-  { 0x0700, 0xfa1e, 0x0000 },

-  { 0x8700, 0xfa31, 0x5000 },

-  { 0x8700, 0xfa27, 0x4000 },

-  { 0x8700, 0xfa23, 0x3000 },

-  { 0x8700, 0xfa21, 0x2000 },

-  { 0x0700, 0xfa20, 0x0000 },

-  { 0x0700, 0xfa22, 0x0000 },

-  { 0x8700, 0xfa25, 0x2000 },

-  { 0x0700, 0xfa24, 0x0000 },

-  { 0x0700, 0xfa26, 0x0000 },

-  { 0x8700, 0xfa2b, 0x3000 },

-  { 0x8700, 0xfa29, 0x2000 },

-  { 0x0700, 0xfa28, 0x0000 },

-  { 0x0700, 0xfa2a, 0x0000 },

-  { 0x8700, 0xfa2d, 0x2000 },

-  { 0x0700, 0xfa2c, 0x0000 },

-  { 0x0700, 0xfa30, 0x0000 },

-  { 0x8700, 0xfa39, 0x4000 },

-  { 0x8700, 0xfa35, 0x3000 },

-  { 0x8700, 0xfa33, 0x2000 },

-  { 0x0700, 0xfa32, 0x0000 },

-  { 0x0700, 0xfa34, 0x0000 },

-  { 0x8700, 0xfa37, 0x2000 },

-  { 0x0700, 0xfa36, 0x0000 },

-  { 0x0700, 0xfa38, 0x0000 },

-  { 0x8700, 0xfa3d, 0x3000 },

-  { 0x8700, 0xfa3b, 0x2000 },

-  { 0x0700, 0xfa3a, 0x0000 },

-  { 0x0700, 0xfa3c, 0x0000 },

-  { 0x8700, 0xfa3f, 0x2000 },

-  { 0x0700, 0xfa3e, 0x0000 },

-  { 0x0700, 0xfa40, 0x0000 },

-  { 0x8700, 0xfa61, 0x6000 },

-  { 0x8700, 0xfa51, 0x5000 },

-  { 0x8700, 0xfa49, 0x4000 },

-  { 0x8700, 0xfa45, 0x3000 },

-  { 0x8700, 0xfa43, 0x2000 },

-  { 0x0700, 0xfa42, 0x0000 },

-  { 0x0700, 0xfa44, 0x0000 },

-  { 0x8700, 0xfa47, 0x2000 },

-  { 0x0700, 0xfa46, 0x0000 },

-  { 0x0700, 0xfa48, 0x0000 },

-  { 0x8700, 0xfa4d, 0x3000 },

-  { 0x8700, 0xfa4b, 0x2000 },

-  { 0x0700, 0xfa4a, 0x0000 },

-  { 0x0700, 0xfa4c, 0x0000 },

-  { 0x8700, 0xfa4f, 0x2000 },

-  { 0x0700, 0xfa4e, 0x0000 },

-  { 0x0700, 0xfa50, 0x0000 },

-  { 0x8700, 0xfa59, 0x4000 },

-  { 0x8700, 0xfa55, 0x3000 },

-  { 0x8700, 0xfa53, 0x2000 },

-  { 0x0700, 0xfa52, 0x0000 },

-  { 0x0700, 0xfa54, 0x0000 },

-  { 0x8700, 0xfa57, 0x2000 },

-  { 0x0700, 0xfa56, 0x0000 },

-  { 0x0700, 0xfa58, 0x0000 },

-  { 0x8700, 0xfa5d, 0x3000 },

-  { 0x8700, 0xfa5b, 0x2000 },

-  { 0x0700, 0xfa5a, 0x0000 },

-  { 0x0700, 0xfa5c, 0x0000 },

-  { 0x8700, 0xfa5f, 0x2000 },

-  { 0x0700, 0xfa5e, 0x0000 },

-  { 0x0700, 0xfa60, 0x0000 },

-  { 0x8500, 0xfb06, 0x5000 },

-  { 0x8700, 0xfa69, 0x4000 },

-  { 0x8700, 0xfa65, 0x3000 },

-  { 0x8700, 0xfa63, 0x2000 },

-  { 0x0700, 0xfa62, 0x0000 },

-  { 0x0700, 0xfa64, 0x0000 },

-  { 0x8700, 0xfa67, 0x2000 },

-  { 0x0700, 0xfa66, 0x0000 },

-  { 0x0700, 0xfa68, 0x0000 },

-  { 0x8500, 0xfb02, 0x3000 },

-  { 0x8500, 0xfb00, 0x2000 },

-  { 0x0700, 0xfa6a, 0x0000 },

-  { 0x0500, 0xfb01, 0x0000 },

-  { 0x8500, 0xfb04, 0x2000 },

-  { 0x0500, 0xfb03, 0x0000 },

-  { 0x0500, 0xfb05, 0x0000 },

-  { 0x8700, 0xfb1f, 0x4000 },

-  { 0x8500, 0xfb16, 0x3000 },

-  { 0x8500, 0xfb14, 0x2000 },

-  { 0x0500, 0xfb13, 0x0000 },

-  { 0x0500, 0xfb15, 0x0000 },

-  { 0x8700, 0xfb1d, 0x2000 },

-  { 0x0500, 0xfb17, 0x0000 },

-  { 0x0c00, 0xfb1e, 0x0000 },

-  { 0x8700, 0xfb23, 0x3000 },

-  { 0x8700, 0xfb21, 0x2000 },

-  { 0x0700, 0xfb20, 0x0000 },

-  { 0x0700, 0xfb22, 0x0000 },

-  { 0x8700, 0xfb25, 0x2000 },

-  { 0x0700, 0xfb24, 0x0000 },

-  { 0x0700, 0xfb26, 0x0000 },

-  { 0x8700, 0xfbac, 0x8000 },

-  { 0x8700, 0xfb6c, 0x7000 },

-  { 0x8700, 0xfb4c, 0x6000 },

-  { 0x8700, 0xfb38, 0x5000 },

-  { 0x8700, 0xfb2f, 0x4000 },

-  { 0x8700, 0xfb2b, 0x3000 },

-  { 0x9900, 0xfb29, 0x2000 },

-  { 0x0700, 0xfb28, 0x0000 },

-  { 0x0700, 0xfb2a, 0x0000 },

-  { 0x8700, 0xfb2d, 0x2000 },

-  { 0x0700, 0xfb2c, 0x0000 },

-  { 0x0700, 0xfb2e, 0x0000 },

-  { 0x8700, 0xfb33, 0x3000 },

-  { 0x8700, 0xfb31, 0x2000 },

-  { 0x0700, 0xfb30, 0x0000 },

-  { 0x0700, 0xfb32, 0x0000 },

-  { 0x8700, 0xfb35, 0x2000 },

-  { 0x0700, 0xfb34, 0x0000 },

-  { 0x0700, 0xfb36, 0x0000 },

-  { 0x8700, 0xfb43, 0x4000 },

-  { 0x8700, 0xfb3c, 0x3000 },

-  { 0x8700, 0xfb3a, 0x2000 },

-  { 0x0700, 0xfb39, 0x0000 },

-  { 0x0700, 0xfb3b, 0x0000 },

-  { 0x8700, 0xfb40, 0x2000 },

-  { 0x0700, 0xfb3e, 0x0000 },

-  { 0x0700, 0xfb41, 0x0000 },

-  { 0x8700, 0xfb48, 0x3000 },

-  { 0x8700, 0xfb46, 0x2000 },

-  { 0x0700, 0xfb44, 0x0000 },

-  { 0x0700, 0xfb47, 0x0000 },

-  { 0x8700, 0xfb4a, 0x2000 },

-  { 0x0700, 0xfb49, 0x0000 },

-  { 0x0700, 0xfb4b, 0x0000 },

-  { 0x8700, 0xfb5c, 0x5000 },

-  { 0x8700, 0xfb54, 0x4000 },

-  { 0x8700, 0xfb50, 0x3000 },

-  { 0x8700, 0xfb4e, 0x2000 },

-  { 0x0700, 0xfb4d, 0x0000 },

-  { 0x0700, 0xfb4f, 0x0000 },

-  { 0x8700, 0xfb52, 0x2000 },

-  { 0x0700, 0xfb51, 0x0000 },

-  { 0x0700, 0xfb53, 0x0000 },

-  { 0x8700, 0xfb58, 0x3000 },

-  { 0x8700, 0xfb56, 0x2000 },

-  { 0x0700, 0xfb55, 0x0000 },

-  { 0x0700, 0xfb57, 0x0000 },

-  { 0x8700, 0xfb5a, 0x2000 },

-  { 0x0700, 0xfb59, 0x0000 },

-  { 0x0700, 0xfb5b, 0x0000 },

-  { 0x8700, 0xfb64, 0x4000 },

-  { 0x8700, 0xfb60, 0x3000 },

-  { 0x8700, 0xfb5e, 0x2000 },

-  { 0x0700, 0xfb5d, 0x0000 },

-  { 0x0700, 0xfb5f, 0x0000 },

-  { 0x8700, 0xfb62, 0x2000 },

-  { 0x0700, 0xfb61, 0x0000 },

-  { 0x0700, 0xfb63, 0x0000 },

-  { 0x8700, 0xfb68, 0x3000 },

-  { 0x8700, 0xfb66, 0x2000 },

-  { 0x0700, 0xfb65, 0x0000 },

-  { 0x0700, 0xfb67, 0x0000 },

-  { 0x8700, 0xfb6a, 0x2000 },

-  { 0x0700, 0xfb69, 0x0000 },

-  { 0x0700, 0xfb6b, 0x0000 },

-  { 0x8700, 0xfb8c, 0x6000 },

-  { 0x8700, 0xfb7c, 0x5000 },

-  { 0x8700, 0xfb74, 0x4000 },

-  { 0x8700, 0xfb70, 0x3000 },

-  { 0x8700, 0xfb6e, 0x2000 },

-  { 0x0700, 0xfb6d, 0x0000 },

-  { 0x0700, 0xfb6f, 0x0000 },

-  { 0x8700, 0xfb72, 0x2000 },

-  { 0x0700, 0xfb71, 0x0000 },

-  { 0x0700, 0xfb73, 0x0000 },

-  { 0x8700, 0xfb78, 0x3000 },

-  { 0x8700, 0xfb76, 0x2000 },

-  { 0x0700, 0xfb75, 0x0000 },

-  { 0x0700, 0xfb77, 0x0000 },

-  { 0x8700, 0xfb7a, 0x2000 },

-  { 0x0700, 0xfb79, 0x0000 },

-  { 0x0700, 0xfb7b, 0x0000 },

-  { 0x8700, 0xfb84, 0x4000 },

-  { 0x8700, 0xfb80, 0x3000 },

-  { 0x8700, 0xfb7e, 0x2000 },

-  { 0x0700, 0xfb7d, 0x0000 },

-  { 0x0700, 0xfb7f, 0x0000 },

-  { 0x8700, 0xfb82, 0x2000 },

-  { 0x0700, 0xfb81, 0x0000 },

-  { 0x0700, 0xfb83, 0x0000 },

-  { 0x8700, 0xfb88, 0x3000 },

-  { 0x8700, 0xfb86, 0x2000 },

-  { 0x0700, 0xfb85, 0x0000 },

-  { 0x0700, 0xfb87, 0x0000 },

-  { 0x8700, 0xfb8a, 0x2000 },

-  { 0x0700, 0xfb89, 0x0000 },

-  { 0x0700, 0xfb8b, 0x0000 },

-  { 0x8700, 0xfb9c, 0x5000 },

-  { 0x8700, 0xfb94, 0x4000 },

-  { 0x8700, 0xfb90, 0x3000 },

-  { 0x8700, 0xfb8e, 0x2000 },

-  { 0x0700, 0xfb8d, 0x0000 },

-  { 0x0700, 0xfb8f, 0x0000 },

-  { 0x8700, 0xfb92, 0x2000 },

-  { 0x0700, 0xfb91, 0x0000 },

-  { 0x0700, 0xfb93, 0x0000 },

-  { 0x8700, 0xfb98, 0x3000 },

-  { 0x8700, 0xfb96, 0x2000 },

-  { 0x0700, 0xfb95, 0x0000 },

-  { 0x0700, 0xfb97, 0x0000 },

-  { 0x8700, 0xfb9a, 0x2000 },

-  { 0x0700, 0xfb99, 0x0000 },

-  { 0x0700, 0xfb9b, 0x0000 },

-  { 0x8700, 0xfba4, 0x4000 },

-  { 0x8700, 0xfba0, 0x3000 },

-  { 0x8700, 0xfb9e, 0x2000 },

-  { 0x0700, 0xfb9d, 0x0000 },

-  { 0x0700, 0xfb9f, 0x0000 },

-  { 0x8700, 0xfba2, 0x2000 },

-  { 0x0700, 0xfba1, 0x0000 },

-  { 0x0700, 0xfba3, 0x0000 },

-  { 0x8700, 0xfba8, 0x3000 },

-  { 0x8700, 0xfba6, 0x2000 },

-  { 0x0700, 0xfba5, 0x0000 },

-  { 0x0700, 0xfba7, 0x0000 },

-  { 0x8700, 0xfbaa, 0x2000 },

-  { 0x0700, 0xfba9, 0x0000 },

-  { 0x0700, 0xfbab, 0x0000 },

-  { 0x8700, 0xfc0d, 0x7000 },

-  { 0x8700, 0xfbed, 0x6000 },

-  { 0x8700, 0xfbdd, 0x5000 },

-  { 0x8700, 0xfbd5, 0x4000 },

-  { 0x8700, 0xfbb0, 0x3000 },

-  { 0x8700, 0xfbae, 0x2000 },

-  { 0x0700, 0xfbad, 0x0000 },

-  { 0x0700, 0xfbaf, 0x0000 },

-  { 0x8700, 0xfbd3, 0x2000 },

-  { 0x0700, 0xfbb1, 0x0000 },

-  { 0x0700, 0xfbd4, 0x0000 },

-  { 0x8700, 0xfbd9, 0x3000 },

-  { 0x8700, 0xfbd7, 0x2000 },

-  { 0x0700, 0xfbd6, 0x0000 },

-  { 0x0700, 0xfbd8, 0x0000 },

-  { 0x8700, 0xfbdb, 0x2000 },

-  { 0x0700, 0xfbda, 0x0000 },

-  { 0x0700, 0xfbdc, 0x0000 },

-  { 0x8700, 0xfbe5, 0x4000 },

-  { 0x8700, 0xfbe1, 0x3000 },

-  { 0x8700, 0xfbdf, 0x2000 },

-  { 0x0700, 0xfbde, 0x0000 },

-  { 0x0700, 0xfbe0, 0x0000 },

-  { 0x8700, 0xfbe3, 0x2000 },

-  { 0x0700, 0xfbe2, 0x0000 },

-  { 0x0700, 0xfbe4, 0x0000 },

-  { 0x8700, 0xfbe9, 0x3000 },

-  { 0x8700, 0xfbe7, 0x2000 },

-  { 0x0700, 0xfbe6, 0x0000 },

-  { 0x0700, 0xfbe8, 0x0000 },

-  { 0x8700, 0xfbeb, 0x2000 },

-  { 0x0700, 0xfbea, 0x0000 },

-  { 0x0700, 0xfbec, 0x0000 },

-  { 0x8700, 0xfbfd, 0x5000 },

-  { 0x8700, 0xfbf5, 0x4000 },

-  { 0x8700, 0xfbf1, 0x3000 },

-  { 0x8700, 0xfbef, 0x2000 },

-  { 0x0700, 0xfbee, 0x0000 },

-  { 0x0700, 0xfbf0, 0x0000 },

-  { 0x8700, 0xfbf3, 0x2000 },

-  { 0x0700, 0xfbf2, 0x0000 },

-  { 0x0700, 0xfbf4, 0x0000 },

-  { 0x8700, 0xfbf9, 0x3000 },

-  { 0x8700, 0xfbf7, 0x2000 },

-  { 0x0700, 0xfbf6, 0x0000 },

-  { 0x0700, 0xfbf8, 0x0000 },

-  { 0x8700, 0xfbfb, 0x2000 },

-  { 0x0700, 0xfbfa, 0x0000 },

-  { 0x0700, 0xfbfc, 0x0000 },

-  { 0x8700, 0xfc05, 0x4000 },

-  { 0x8700, 0xfc01, 0x3000 },

-  { 0x8700, 0xfbff, 0x2000 },

-  { 0x0700, 0xfbfe, 0x0000 },

-  { 0x0700, 0xfc00, 0x0000 },

-  { 0x8700, 0xfc03, 0x2000 },

-  { 0x0700, 0xfc02, 0x0000 },

-  { 0x0700, 0xfc04, 0x0000 },

-  { 0x8700, 0xfc09, 0x3000 },

-  { 0x8700, 0xfc07, 0x2000 },

-  { 0x0700, 0xfc06, 0x0000 },

-  { 0x0700, 0xfc08, 0x0000 },

-  { 0x8700, 0xfc0b, 0x2000 },

-  { 0x0700, 0xfc0a, 0x0000 },

-  { 0x0700, 0xfc0c, 0x0000 },

-  { 0x8700, 0xfc2d, 0x6000 },

-  { 0x8700, 0xfc1d, 0x5000 },

-  { 0x8700, 0xfc15, 0x4000 },

-  { 0x8700, 0xfc11, 0x3000 },

-  { 0x8700, 0xfc0f, 0x2000 },

-  { 0x0700, 0xfc0e, 0x0000 },

-  { 0x0700, 0xfc10, 0x0000 },

-  { 0x8700, 0xfc13, 0x2000 },

-  { 0x0700, 0xfc12, 0x0000 },

-  { 0x0700, 0xfc14, 0x0000 },

-  { 0x8700, 0xfc19, 0x3000 },

-  { 0x8700, 0xfc17, 0x2000 },

-  { 0x0700, 0xfc16, 0x0000 },

-  { 0x0700, 0xfc18, 0x0000 },

-  { 0x8700, 0xfc1b, 0x2000 },

-  { 0x0700, 0xfc1a, 0x0000 },

-  { 0x0700, 0xfc1c, 0x0000 },

-  { 0x8700, 0xfc25, 0x4000 },

-  { 0x8700, 0xfc21, 0x3000 },

-  { 0x8700, 0xfc1f, 0x2000 },

-  { 0x0700, 0xfc1e, 0x0000 },

-  { 0x0700, 0xfc20, 0x0000 },

-  { 0x8700, 0xfc23, 0x2000 },

-  { 0x0700, 0xfc22, 0x0000 },

-  { 0x0700, 0xfc24, 0x0000 },

-  { 0x8700, 0xfc29, 0x3000 },

-  { 0x8700, 0xfc27, 0x2000 },

-  { 0x0700, 0xfc26, 0x0000 },

-  { 0x0700, 0xfc28, 0x0000 },

-  { 0x8700, 0xfc2b, 0x2000 },

-  { 0x0700, 0xfc2a, 0x0000 },

-  { 0x0700, 0xfc2c, 0x0000 },

-  { 0x8700, 0xfc3d, 0x5000 },

-  { 0x8700, 0xfc35, 0x4000 },

-  { 0x8700, 0xfc31, 0x3000 },

-  { 0x8700, 0xfc2f, 0x2000 },

-  { 0x0700, 0xfc2e, 0x0000 },

-  { 0x0700, 0xfc30, 0x0000 },

-  { 0x8700, 0xfc33, 0x2000 },

-  { 0x0700, 0xfc32, 0x0000 },

-  { 0x0700, 0xfc34, 0x0000 },

-  { 0x8700, 0xfc39, 0x3000 },

-  { 0x8700, 0xfc37, 0x2000 },

-  { 0x0700, 0xfc36, 0x0000 },

-  { 0x0700, 0xfc38, 0x0000 },

-  { 0x8700, 0xfc3b, 0x2000 },

-  { 0x0700, 0xfc3a, 0x0000 },

-  { 0x0700, 0xfc3c, 0x0000 },

-  { 0x8700, 0xfc45, 0x4000 },

-  { 0x8700, 0xfc41, 0x3000 },

-  { 0x8700, 0xfc3f, 0x2000 },

-  { 0x0700, 0xfc3e, 0x0000 },

-  { 0x0700, 0xfc40, 0x0000 },

-  { 0x8700, 0xfc43, 0x2000 },

-  { 0x0700, 0xfc42, 0x0000 },

-  { 0x0700, 0xfc44, 0x0000 },

-  { 0x8700, 0xfc49, 0x3000 },

-  { 0x8700, 0xfc47, 0x2000 },

-  { 0x0700, 0xfc46, 0x0000 },

-  { 0x0700, 0xfc48, 0x0000 },

-  { 0x8700, 0xfc4b, 0x2000 },

-  { 0x0700, 0xfc4a, 0x0000 },

-  { 0x0700, 0xfc4c, 0x0000 },

-  { 0x8700, 0xfeac, 0xa000 },

-  { 0x8700, 0xfd5d, 0x9000 },

-  { 0x8700, 0xfccd, 0x8000 },

-  { 0x8700, 0xfc8d, 0x7000 },

-  { 0x8700, 0xfc6d, 0x6000 },

-  { 0x8700, 0xfc5d, 0x5000 },

-  { 0x8700, 0xfc55, 0x4000 },

-  { 0x8700, 0xfc51, 0x3000 },

-  { 0x8700, 0xfc4f, 0x2000 },

-  { 0x0700, 0xfc4e, 0x0000 },

-  { 0x0700, 0xfc50, 0x0000 },

-  { 0x8700, 0xfc53, 0x2000 },

-  { 0x0700, 0xfc52, 0x0000 },

-  { 0x0700, 0xfc54, 0x0000 },

-  { 0x8700, 0xfc59, 0x3000 },

-  { 0x8700, 0xfc57, 0x2000 },

-  { 0x0700, 0xfc56, 0x0000 },

-  { 0x0700, 0xfc58, 0x0000 },

-  { 0x8700, 0xfc5b, 0x2000 },

-  { 0x0700, 0xfc5a, 0x0000 },

-  { 0x0700, 0xfc5c, 0x0000 },

-  { 0x8700, 0xfc65, 0x4000 },

-  { 0x8700, 0xfc61, 0x3000 },

-  { 0x8700, 0xfc5f, 0x2000 },

-  { 0x0700, 0xfc5e, 0x0000 },

-  { 0x0700, 0xfc60, 0x0000 },

-  { 0x8700, 0xfc63, 0x2000 },

-  { 0x0700, 0xfc62, 0x0000 },

-  { 0x0700, 0xfc64, 0x0000 },

-  { 0x8700, 0xfc69, 0x3000 },

-  { 0x8700, 0xfc67, 0x2000 },

-  { 0x0700, 0xfc66, 0x0000 },

-  { 0x0700, 0xfc68, 0x0000 },

-  { 0x8700, 0xfc6b, 0x2000 },

-  { 0x0700, 0xfc6a, 0x0000 },

-  { 0x0700, 0xfc6c, 0x0000 },

-  { 0x8700, 0xfc7d, 0x5000 },

-  { 0x8700, 0xfc75, 0x4000 },

-  { 0x8700, 0xfc71, 0x3000 },

-  { 0x8700, 0xfc6f, 0x2000 },

-  { 0x0700, 0xfc6e, 0x0000 },

-  { 0x0700, 0xfc70, 0x0000 },

-  { 0x8700, 0xfc73, 0x2000 },

-  { 0x0700, 0xfc72, 0x0000 },

-  { 0x0700, 0xfc74, 0x0000 },

-  { 0x8700, 0xfc79, 0x3000 },

-  { 0x8700, 0xfc77, 0x2000 },

-  { 0x0700, 0xfc76, 0x0000 },

-  { 0x0700, 0xfc78, 0x0000 },

-  { 0x8700, 0xfc7b, 0x2000 },

-  { 0x0700, 0xfc7a, 0x0000 },

-  { 0x0700, 0xfc7c, 0x0000 },

-  { 0x8700, 0xfc85, 0x4000 },

-  { 0x8700, 0xfc81, 0x3000 },

-  { 0x8700, 0xfc7f, 0x2000 },

-  { 0x0700, 0xfc7e, 0x0000 },

-  { 0x0700, 0xfc80, 0x0000 },

-  { 0x8700, 0xfc83, 0x2000 },

-  { 0x0700, 0xfc82, 0x0000 },

-  { 0x0700, 0xfc84, 0x0000 },

-  { 0x8700, 0xfc89, 0x3000 },

-  { 0x8700, 0xfc87, 0x2000 },

-  { 0x0700, 0xfc86, 0x0000 },

-  { 0x0700, 0xfc88, 0x0000 },

-  { 0x8700, 0xfc8b, 0x2000 },

-  { 0x0700, 0xfc8a, 0x0000 },

-  { 0x0700, 0xfc8c, 0x0000 },

-  { 0x8700, 0xfcad, 0x6000 },

-  { 0x8700, 0xfc9d, 0x5000 },

-  { 0x8700, 0xfc95, 0x4000 },

-  { 0x8700, 0xfc91, 0x3000 },

-  { 0x8700, 0xfc8f, 0x2000 },

-  { 0x0700, 0xfc8e, 0x0000 },

-  { 0x0700, 0xfc90, 0x0000 },

-  { 0x8700, 0xfc93, 0x2000 },

-  { 0x0700, 0xfc92, 0x0000 },

-  { 0x0700, 0xfc94, 0x0000 },

-  { 0x8700, 0xfc99, 0x3000 },

-  { 0x8700, 0xfc97, 0x2000 },

-  { 0x0700, 0xfc96, 0x0000 },

-  { 0x0700, 0xfc98, 0x0000 },

-  { 0x8700, 0xfc9b, 0x2000 },

-  { 0x0700, 0xfc9a, 0x0000 },

-  { 0x0700, 0xfc9c, 0x0000 },

-  { 0x8700, 0xfca5, 0x4000 },

-  { 0x8700, 0xfca1, 0x3000 },

-  { 0x8700, 0xfc9f, 0x2000 },

-  { 0x0700, 0xfc9e, 0x0000 },

-  { 0x0700, 0xfca0, 0x0000 },

-  { 0x8700, 0xfca3, 0x2000 },

-  { 0x0700, 0xfca2, 0x0000 },

-  { 0x0700, 0xfca4, 0x0000 },

-  { 0x8700, 0xfca9, 0x3000 },

-  { 0x8700, 0xfca7, 0x2000 },

-  { 0x0700, 0xfca6, 0x0000 },

-  { 0x0700, 0xfca8, 0x0000 },

-  { 0x8700, 0xfcab, 0x2000 },

-  { 0x0700, 0xfcaa, 0x0000 },

-  { 0x0700, 0xfcac, 0x0000 },

-  { 0x8700, 0xfcbd, 0x5000 },

-  { 0x8700, 0xfcb5, 0x4000 },

-  { 0x8700, 0xfcb1, 0x3000 },

-  { 0x8700, 0xfcaf, 0x2000 },

-  { 0x0700, 0xfcae, 0x0000 },

-  { 0x0700, 0xfcb0, 0x0000 },

-  { 0x8700, 0xfcb3, 0x2000 },

-  { 0x0700, 0xfcb2, 0x0000 },

-  { 0x0700, 0xfcb4, 0x0000 },

-  { 0x8700, 0xfcb9, 0x3000 },

-  { 0x8700, 0xfcb7, 0x2000 },

-  { 0x0700, 0xfcb6, 0x0000 },

-  { 0x0700, 0xfcb8, 0x0000 },

-  { 0x8700, 0xfcbb, 0x2000 },

-  { 0x0700, 0xfcba, 0x0000 },

-  { 0x0700, 0xfcbc, 0x0000 },

-  { 0x8700, 0xfcc5, 0x4000 },

-  { 0x8700, 0xfcc1, 0x3000 },

-  { 0x8700, 0xfcbf, 0x2000 },

-  { 0x0700, 0xfcbe, 0x0000 },

-  { 0x0700, 0xfcc0, 0x0000 },

-  { 0x8700, 0xfcc3, 0x2000 },

-  { 0x0700, 0xfcc2, 0x0000 },

-  { 0x0700, 0xfcc4, 0x0000 },

-  { 0x8700, 0xfcc9, 0x3000 },

-  { 0x8700, 0xfcc7, 0x2000 },

-  { 0x0700, 0xfcc6, 0x0000 },

-  { 0x0700, 0xfcc8, 0x0000 },

-  { 0x8700, 0xfccb, 0x2000 },

-  { 0x0700, 0xfcca, 0x0000 },

-  { 0x0700, 0xfccc, 0x0000 },

-  { 0x8700, 0xfd0d, 0x7000 },

-  { 0x8700, 0xfced, 0x6000 },

-  { 0x8700, 0xfcdd, 0x5000 },

-  { 0x8700, 0xfcd5, 0x4000 },

-  { 0x8700, 0xfcd1, 0x3000 },

-  { 0x8700, 0xfccf, 0x2000 },

-  { 0x0700, 0xfcce, 0x0000 },

-  { 0x0700, 0xfcd0, 0x0000 },

-  { 0x8700, 0xfcd3, 0x2000 },

-  { 0x0700, 0xfcd2, 0x0000 },

-  { 0x0700, 0xfcd4, 0x0000 },

-  { 0x8700, 0xfcd9, 0x3000 },

-  { 0x8700, 0xfcd7, 0x2000 },

-  { 0x0700, 0xfcd6, 0x0000 },

-  { 0x0700, 0xfcd8, 0x0000 },

-  { 0x8700, 0xfcdb, 0x2000 },

-  { 0x0700, 0xfcda, 0x0000 },

-  { 0x0700, 0xfcdc, 0x0000 },

-  { 0x8700, 0xfce5, 0x4000 },

-  { 0x8700, 0xfce1, 0x3000 },

-  { 0x8700, 0xfcdf, 0x2000 },

-  { 0x0700, 0xfcde, 0x0000 },

-  { 0x0700, 0xfce0, 0x0000 },

-  { 0x8700, 0xfce3, 0x2000 },

-  { 0x0700, 0xfce2, 0x0000 },

-  { 0x0700, 0xfce4, 0x0000 },

-  { 0x8700, 0xfce9, 0x3000 },

-  { 0x8700, 0xfce7, 0x2000 },

-  { 0x0700, 0xfce6, 0x0000 },

-  { 0x0700, 0xfce8, 0x0000 },

-  { 0x8700, 0xfceb, 0x2000 },

-  { 0x0700, 0xfcea, 0x0000 },

-  { 0x0700, 0xfcec, 0x0000 },

-  { 0x8700, 0xfcfd, 0x5000 },

-  { 0x8700, 0xfcf5, 0x4000 },

-  { 0x8700, 0xfcf1, 0x3000 },

-  { 0x8700, 0xfcef, 0x2000 },

-  { 0x0700, 0xfcee, 0x0000 },

-  { 0x0700, 0xfcf0, 0x0000 },

-  { 0x8700, 0xfcf3, 0x2000 },

-  { 0x0700, 0xfcf2, 0x0000 },

-  { 0x0700, 0xfcf4, 0x0000 },

-  { 0x8700, 0xfcf9, 0x3000 },

-  { 0x8700, 0xfcf7, 0x2000 },

-  { 0x0700, 0xfcf6, 0x0000 },

-  { 0x0700, 0xfcf8, 0x0000 },

-  { 0x8700, 0xfcfb, 0x2000 },

-  { 0x0700, 0xfcfa, 0x0000 },

-  { 0x0700, 0xfcfc, 0x0000 },

-  { 0x8700, 0xfd05, 0x4000 },

-  { 0x8700, 0xfd01, 0x3000 },

-  { 0x8700, 0xfcff, 0x2000 },

-  { 0x0700, 0xfcfe, 0x0000 },

-  { 0x0700, 0xfd00, 0x0000 },

-  { 0x8700, 0xfd03, 0x2000 },

-  { 0x0700, 0xfd02, 0x0000 },

-  { 0x0700, 0xfd04, 0x0000 },

-  { 0x8700, 0xfd09, 0x3000 },

-  { 0x8700, 0xfd07, 0x2000 },

-  { 0x0700, 0xfd06, 0x0000 },

-  { 0x0700, 0xfd08, 0x0000 },

-  { 0x8700, 0xfd0b, 0x2000 },

-  { 0x0700, 0xfd0a, 0x0000 },

-  { 0x0700, 0xfd0c, 0x0000 },

-  { 0x8700, 0xfd2d, 0x6000 },

-  { 0x8700, 0xfd1d, 0x5000 },

-  { 0x8700, 0xfd15, 0x4000 },

-  { 0x8700, 0xfd11, 0x3000 },

-  { 0x8700, 0xfd0f, 0x2000 },

-  { 0x0700, 0xfd0e, 0x0000 },

-  { 0x0700, 0xfd10, 0x0000 },

-  { 0x8700, 0xfd13, 0x2000 },

-  { 0x0700, 0xfd12, 0x0000 },

-  { 0x0700, 0xfd14, 0x0000 },

-  { 0x8700, 0xfd19, 0x3000 },

-  { 0x8700, 0xfd17, 0x2000 },

-  { 0x0700, 0xfd16, 0x0000 },

-  { 0x0700, 0xfd18, 0x0000 },

-  { 0x8700, 0xfd1b, 0x2000 },

-  { 0x0700, 0xfd1a, 0x0000 },

-  { 0x0700, 0xfd1c, 0x0000 },

-  { 0x8700, 0xfd25, 0x4000 },

-  { 0x8700, 0xfd21, 0x3000 },

-  { 0x8700, 0xfd1f, 0x2000 },

-  { 0x0700, 0xfd1e, 0x0000 },

-  { 0x0700, 0xfd20, 0x0000 },

-  { 0x8700, 0xfd23, 0x2000 },

-  { 0x0700, 0xfd22, 0x0000 },

-  { 0x0700, 0xfd24, 0x0000 },

-  { 0x8700, 0xfd29, 0x3000 },

-  { 0x8700, 0xfd27, 0x2000 },

-  { 0x0700, 0xfd26, 0x0000 },

-  { 0x0700, 0xfd28, 0x0000 },

-  { 0x8700, 0xfd2b, 0x2000 },

-  { 0x0700, 0xfd2a, 0x0000 },

-  { 0x0700, 0xfd2c, 0x0000 },

-  { 0x8700, 0xfd3d, 0x5000 },

-  { 0x8700, 0xfd35, 0x4000 },

-  { 0x8700, 0xfd31, 0x3000 },

-  { 0x8700, 0xfd2f, 0x2000 },

-  { 0x0700, 0xfd2e, 0x0000 },

-  { 0x0700, 0xfd30, 0x0000 },

-  { 0x8700, 0xfd33, 0x2000 },

-  { 0x0700, 0xfd32, 0x0000 },

-  { 0x0700, 0xfd34, 0x0000 },

-  { 0x8700, 0xfd39, 0x3000 },

-  { 0x8700, 0xfd37, 0x2000 },

-  { 0x0700, 0xfd36, 0x0000 },

-  { 0x0700, 0xfd38, 0x0000 },

-  { 0x8700, 0xfd3b, 0x2000 },

-  { 0x0700, 0xfd3a, 0x0000 },

-  { 0x0700, 0xfd3c, 0x0000 },

-  { 0x8700, 0xfd55, 0x4000 },

-  { 0x8700, 0xfd51, 0x3000 },

-  { 0x9200, 0xfd3f, 0x2000 },

-  { 0x1600, 0xfd3e, 0x0000 },

-  { 0x0700, 0xfd50, 0x0000 },

-  { 0x8700, 0xfd53, 0x2000 },

-  { 0x0700, 0xfd52, 0x0000 },

-  { 0x0700, 0xfd54, 0x0000 },

-  { 0x8700, 0xfd59, 0x3000 },

-  { 0x8700, 0xfd57, 0x2000 },

-  { 0x0700, 0xfd56, 0x0000 },

-  { 0x0700, 0xfd58, 0x0000 },

-  { 0x8700, 0xfd5b, 0x2000 },

-  { 0x0700, 0xfd5a, 0x0000 },

-  { 0x0700, 0xfd5c, 0x0000 },

-  { 0x8c00, 0xfe09, 0x8000 },

-  { 0x8700, 0xfd9f, 0x7000 },

-  { 0x8700, 0xfd7d, 0x6000 },

-  { 0x8700, 0xfd6d, 0x5000 },

-  { 0x8700, 0xfd65, 0x4000 },

-  { 0x8700, 0xfd61, 0x3000 },

-  { 0x8700, 0xfd5f, 0x2000 },

-  { 0x0700, 0xfd5e, 0x0000 },

-  { 0x0700, 0xfd60, 0x0000 },

-  { 0x8700, 0xfd63, 0x2000 },

-  { 0x0700, 0xfd62, 0x0000 },

-  { 0x0700, 0xfd64, 0x0000 },

-  { 0x8700, 0xfd69, 0x3000 },

-  { 0x8700, 0xfd67, 0x2000 },

-  { 0x0700, 0xfd66, 0x0000 },

-  { 0x0700, 0xfd68, 0x0000 },

-  { 0x8700, 0xfd6b, 0x2000 },

-  { 0x0700, 0xfd6a, 0x0000 },

-  { 0x0700, 0xfd6c, 0x0000 },

-  { 0x8700, 0xfd75, 0x4000 },

-  { 0x8700, 0xfd71, 0x3000 },

-  { 0x8700, 0xfd6f, 0x2000 },

-  { 0x0700, 0xfd6e, 0x0000 },

-  { 0x0700, 0xfd70, 0x0000 },

-  { 0x8700, 0xfd73, 0x2000 },

-  { 0x0700, 0xfd72, 0x0000 },

-  { 0x0700, 0xfd74, 0x0000 },

-  { 0x8700, 0xfd79, 0x3000 },

-  { 0x8700, 0xfd77, 0x2000 },

-  { 0x0700, 0xfd76, 0x0000 },

-  { 0x0700, 0xfd78, 0x0000 },

-  { 0x8700, 0xfd7b, 0x2000 },

-  { 0x0700, 0xfd7a, 0x0000 },

-  { 0x0700, 0xfd7c, 0x0000 },

-  { 0x8700, 0xfd8d, 0x5000 },

-  { 0x8700, 0xfd85, 0x4000 },

-  { 0x8700, 0xfd81, 0x3000 },

-  { 0x8700, 0xfd7f, 0x2000 },

-  { 0x0700, 0xfd7e, 0x0000 },

-  { 0x0700, 0xfd80, 0x0000 },

-  { 0x8700, 0xfd83, 0x2000 },

-  { 0x0700, 0xfd82, 0x0000 },

-  { 0x0700, 0xfd84, 0x0000 },

-  { 0x8700, 0xfd89, 0x3000 },

-  { 0x8700, 0xfd87, 0x2000 },

-  { 0x0700, 0xfd86, 0x0000 },

-  { 0x0700, 0xfd88, 0x0000 },

-  { 0x8700, 0xfd8b, 0x2000 },

-  { 0x0700, 0xfd8a, 0x0000 },

-  { 0x0700, 0xfd8c, 0x0000 },

-  { 0x8700, 0xfd97, 0x4000 },

-  { 0x8700, 0xfd93, 0x3000 },

-  { 0x8700, 0xfd8f, 0x2000 },

-  { 0x0700, 0xfd8e, 0x0000 },

-  { 0x0700, 0xfd92, 0x0000 },

-  { 0x8700, 0xfd95, 0x2000 },

-  { 0x0700, 0xfd94, 0x0000 },

-  { 0x0700, 0xfd96, 0x0000 },

-  { 0x8700, 0xfd9b, 0x3000 },

-  { 0x8700, 0xfd99, 0x2000 },

-  { 0x0700, 0xfd98, 0x0000 },

-  { 0x0700, 0xfd9a, 0x0000 },

-  { 0x8700, 0xfd9d, 0x2000 },

-  { 0x0700, 0xfd9c, 0x0000 },

-  { 0x0700, 0xfd9e, 0x0000 },

-  { 0x8700, 0xfdbf, 0x6000 },

-  { 0x8700, 0xfdaf, 0x5000 },

-  { 0x8700, 0xfda7, 0x4000 },

-  { 0x8700, 0xfda3, 0x3000 },

-  { 0x8700, 0xfda1, 0x2000 },

-  { 0x0700, 0xfda0, 0x0000 },

-  { 0x0700, 0xfda2, 0x0000 },

-  { 0x8700, 0xfda5, 0x2000 },

-  { 0x0700, 0xfda4, 0x0000 },

-  { 0x0700, 0xfda6, 0x0000 },

-  { 0x8700, 0xfdab, 0x3000 },

-  { 0x8700, 0xfda9, 0x2000 },

-  { 0x0700, 0xfda8, 0x0000 },

-  { 0x0700, 0xfdaa, 0x0000 },

-  { 0x8700, 0xfdad, 0x2000 },

-  { 0x0700, 0xfdac, 0x0000 },

-  { 0x0700, 0xfdae, 0x0000 },

-  { 0x8700, 0xfdb7, 0x4000 },

-  { 0x8700, 0xfdb3, 0x3000 },

-  { 0x8700, 0xfdb1, 0x2000 },

-  { 0x0700, 0xfdb0, 0x0000 },

-  { 0x0700, 0xfdb2, 0x0000 },

-  { 0x8700, 0xfdb5, 0x2000 },

-  { 0x0700, 0xfdb4, 0x0000 },

-  { 0x0700, 0xfdb6, 0x0000 },

-  { 0x8700, 0xfdbb, 0x3000 },

-  { 0x8700, 0xfdb9, 0x2000 },

-  { 0x0700, 0xfdb8, 0x0000 },

-  { 0x0700, 0xfdba, 0x0000 },

-  { 0x8700, 0xfdbd, 0x2000 },

-  { 0x0700, 0xfdbc, 0x0000 },

-  { 0x0700, 0xfdbe, 0x0000 },

-  { 0x8700, 0xfdf7, 0x5000 },

-  { 0x8700, 0xfdc7, 0x4000 },

-  { 0x8700, 0xfdc3, 0x3000 },

-  { 0x8700, 0xfdc1, 0x2000 },

-  { 0x0700, 0xfdc0, 0x0000 },

-  { 0x0700, 0xfdc2, 0x0000 },

-  { 0x8700, 0xfdc5, 0x2000 },

-  { 0x0700, 0xfdc4, 0x0000 },

-  { 0x0700, 0xfdc6, 0x0000 },

-  { 0x8700, 0xfdf3, 0x3000 },

-  { 0x8700, 0xfdf1, 0x2000 },

-  { 0x0700, 0xfdf0, 0x0000 },

-  { 0x0700, 0xfdf2, 0x0000 },

-  { 0x8700, 0xfdf5, 0x2000 },

-  { 0x0700, 0xfdf4, 0x0000 },

-  { 0x0700, 0xfdf6, 0x0000 },

-  { 0x8c00, 0xfe01, 0x4000 },

-  { 0x8700, 0xfdfb, 0x3000 },

-  { 0x8700, 0xfdf9, 0x2000 },

-  { 0x0700, 0xfdf8, 0x0000 },

-  { 0x0700, 0xfdfa, 0x0000 },

-  { 0x9a00, 0xfdfd, 0x2000 },

-  { 0x1700, 0xfdfc, 0x0000 },

-  { 0x0c00, 0xfe00, 0x0000 },

-  { 0x8c00, 0xfe05, 0x3000 },

-  { 0x8c00, 0xfe03, 0x2000 },

-  { 0x0c00, 0xfe02, 0x0000 },

-  { 0x0c00, 0xfe04, 0x0000 },

-  { 0x8c00, 0xfe07, 0x2000 },

-  { 0x0c00, 0xfe06, 0x0000 },

-  { 0x0c00, 0xfe08, 0x0000 },

-  { 0x9900, 0xfe66, 0x7000 },

-  { 0x9500, 0xfe45, 0x6000 },

-  { 0x9600, 0xfe35, 0x5000 },

-  { 0x8c00, 0xfe21, 0x4000 },

-  { 0x8c00, 0xfe0d, 0x3000 },

-  { 0x8c00, 0xfe0b, 0x2000 },

-  { 0x0c00, 0xfe0a, 0x0000 },

-  { 0x0c00, 0xfe0c, 0x0000 },

-  { 0x8c00, 0xfe0f, 0x2000 },

-  { 0x0c00, 0xfe0e, 0x0000 },

-  { 0x0c00, 0xfe20, 0x0000 },

-  { 0x9100, 0xfe31, 0x3000 },

-  { 0x8c00, 0xfe23, 0x2000 },

-  { 0x0c00, 0xfe22, 0x0000 },

-  { 0x1500, 0xfe30, 0x0000 },

-  { 0x9000, 0xfe33, 0x2000 },

-  { 0x1100, 0xfe32, 0x0000 },

-  { 0x1000, 0xfe34, 0x0000 },

-  { 0x9600, 0xfe3d, 0x4000 },

-  { 0x9600, 0xfe39, 0x3000 },

-  { 0x9600, 0xfe37, 0x2000 },

-  { 0x1200, 0xfe36, 0x0000 },

-  { 0x1200, 0xfe38, 0x0000 },

-  { 0x9600, 0xfe3b, 0x2000 },

-  { 0x1200, 0xfe3a, 0x0000 },

-  { 0x1200, 0xfe3c, 0x0000 },

-  { 0x9600, 0xfe41, 0x3000 },

-  { 0x9600, 0xfe3f, 0x2000 },

-  { 0x1200, 0xfe3e, 0x0000 },

-  { 0x1200, 0xfe40, 0x0000 },

-  { 0x9600, 0xfe43, 0x2000 },

-  { 0x1200, 0xfe42, 0x0000 },

-  { 0x1200, 0xfe44, 0x0000 },

-  { 0x9500, 0xfe56, 0x5000 },

-  { 0x9000, 0xfe4d, 0x4000 },

-  { 0x9500, 0xfe49, 0x3000 },

-  { 0x9600, 0xfe47, 0x2000 },

-  { 0x1500, 0xfe46, 0x0000 },

-  { 0x1200, 0xfe48, 0x0000 },

-  { 0x9500, 0xfe4b, 0x2000 },

-  { 0x1500, 0xfe4a, 0x0000 },

-  { 0x1500, 0xfe4c, 0x0000 },

-  { 0x9500, 0xfe51, 0x3000 },

-  { 0x9000, 0xfe4f, 0x2000 },

-  { 0x1000, 0xfe4e, 0x0000 },

-  { 0x1500, 0xfe50, 0x0000 },

-  { 0x9500, 0xfe54, 0x2000 },

-  { 0x1500, 0xfe52, 0x0000 },

-  { 0x1500, 0xfe55, 0x0000 },

-  { 0x9200, 0xfe5e, 0x4000 },

-  { 0x9200, 0xfe5a, 0x3000 },

-  { 0x9100, 0xfe58, 0x2000 },

-  { 0x1500, 0xfe57, 0x0000 },

-  { 0x1600, 0xfe59, 0x0000 },

-  { 0x9200, 0xfe5c, 0x2000 },

-  { 0x1600, 0xfe5b, 0x0000 },

-  { 0x1600, 0xfe5d, 0x0000 },

-  { 0x9900, 0xfe62, 0x3000 },

-  { 0x9500, 0xfe60, 0x2000 },

-  { 0x1500, 0xfe5f, 0x0000 },

-  { 0x1500, 0xfe61, 0x0000 },

-  { 0x9900, 0xfe64, 0x2000 },

-  { 0x1100, 0xfe63, 0x0000 },

-  { 0x1900, 0xfe65, 0x0000 },

-  { 0x8700, 0xfe8c, 0x6000 },

-  { 0x8700, 0xfe7c, 0x5000 },

-  { 0x8700, 0xfe73, 0x4000 },

-  { 0x9500, 0xfe6b, 0x3000 },

-  { 0x9700, 0xfe69, 0x2000 },

-  { 0x1500, 0xfe68, 0x0000 },

-  { 0x1500, 0xfe6a, 0x0000 },

-  { 0x8700, 0xfe71, 0x2000 },

-  { 0x0700, 0xfe70, 0x0000 },

-  { 0x0700, 0xfe72, 0x0000 },

-  { 0x8700, 0xfe78, 0x3000 },

-  { 0x8700, 0xfe76, 0x2000 },

-  { 0x0700, 0xfe74, 0x0000 },

-  { 0x0700, 0xfe77, 0x0000 },

-  { 0x8700, 0xfe7a, 0x2000 },

-  { 0x0700, 0xfe79, 0x0000 },

-  { 0x0700, 0xfe7b, 0x0000 },

-  { 0x8700, 0xfe84, 0x4000 },

-  { 0x8700, 0xfe80, 0x3000 },

-  { 0x8700, 0xfe7e, 0x2000 },

-  { 0x0700, 0xfe7d, 0x0000 },

-  { 0x0700, 0xfe7f, 0x0000 },

-  { 0x8700, 0xfe82, 0x2000 },

-  { 0x0700, 0xfe81, 0x0000 },

-  { 0x0700, 0xfe83, 0x0000 },

-  { 0x8700, 0xfe88, 0x3000 },

-  { 0x8700, 0xfe86, 0x2000 },

-  { 0x0700, 0xfe85, 0x0000 },

-  { 0x0700, 0xfe87, 0x0000 },

-  { 0x8700, 0xfe8a, 0x2000 },

-  { 0x0700, 0xfe89, 0x0000 },

-  { 0x0700, 0xfe8b, 0x0000 },

-  { 0x8700, 0xfe9c, 0x5000 },

-  { 0x8700, 0xfe94, 0x4000 },

-  { 0x8700, 0xfe90, 0x3000 },

-  { 0x8700, 0xfe8e, 0x2000 },

-  { 0x0700, 0xfe8d, 0x0000 },

-  { 0x0700, 0xfe8f, 0x0000 },

-  { 0x8700, 0xfe92, 0x2000 },

-  { 0x0700, 0xfe91, 0x0000 },

-  { 0x0700, 0xfe93, 0x0000 },

-  { 0x8700, 0xfe98, 0x3000 },

-  { 0x8700, 0xfe96, 0x2000 },

-  { 0x0700, 0xfe95, 0x0000 },

-  { 0x0700, 0xfe97, 0x0000 },

-  { 0x8700, 0xfe9a, 0x2000 },

-  { 0x0700, 0xfe99, 0x0000 },

-  { 0x0700, 0xfe9b, 0x0000 },

-  { 0x8700, 0xfea4, 0x4000 },

-  { 0x8700, 0xfea0, 0x3000 },

-  { 0x8700, 0xfe9e, 0x2000 },

-  { 0x0700, 0xfe9d, 0x0000 },

-  { 0x0700, 0xfe9f, 0x0000 },

-  { 0x8700, 0xfea2, 0x2000 },

-  { 0x0700, 0xfea1, 0x0000 },

-  { 0x0700, 0xfea3, 0x0000 },

-  { 0x8700, 0xfea8, 0x3000 },

-  { 0x8700, 0xfea6, 0x2000 },

-  { 0x0700, 0xfea5, 0x0000 },

-  { 0x0700, 0xfea7, 0x0000 },

-  { 0x8700, 0xfeaa, 0x2000 },

-  { 0x0700, 0xfea9, 0x0000 },

-  { 0x0700, 0xfeab, 0x0000 },

-  { 0x8700, 0xffaf, 0x9000 },

-  { 0x8900, 0xff2f, 0x8020 },

-  { 0x8700, 0xfeec, 0x7000 },

-  { 0x8700, 0xfecc, 0x6000 },

-  { 0x8700, 0xfebc, 0x5000 },

-  { 0x8700, 0xfeb4, 0x4000 },

-  { 0x8700, 0xfeb0, 0x3000 },

-  { 0x8700, 0xfeae, 0x2000 },

-  { 0x0700, 0xfead, 0x0000 },

-  { 0x0700, 0xfeaf, 0x0000 },

-  { 0x8700, 0xfeb2, 0x2000 },

-  { 0x0700, 0xfeb1, 0x0000 },

-  { 0x0700, 0xfeb3, 0x0000 },

-  { 0x8700, 0xfeb8, 0x3000 },

-  { 0x8700, 0xfeb6, 0x2000 },

-  { 0x0700, 0xfeb5, 0x0000 },

-  { 0x0700, 0xfeb7, 0x0000 },

-  { 0x8700, 0xfeba, 0x2000 },

-  { 0x0700, 0xfeb9, 0x0000 },

-  { 0x0700, 0xfebb, 0x0000 },

-  { 0x8700, 0xfec4, 0x4000 },

-  { 0x8700, 0xfec0, 0x3000 },

-  { 0x8700, 0xfebe, 0x2000 },

-  { 0x0700, 0xfebd, 0x0000 },

-  { 0x0700, 0xfebf, 0x0000 },

-  { 0x8700, 0xfec2, 0x2000 },

-  { 0x0700, 0xfec1, 0x0000 },

-  { 0x0700, 0xfec3, 0x0000 },

-  { 0x8700, 0xfec8, 0x3000 },

-  { 0x8700, 0xfec6, 0x2000 },

-  { 0x0700, 0xfec5, 0x0000 },

-  { 0x0700, 0xfec7, 0x0000 },

-  { 0x8700, 0xfeca, 0x2000 },

-  { 0x0700, 0xfec9, 0x0000 },

-  { 0x0700, 0xfecb, 0x0000 },

-  { 0x8700, 0xfedc, 0x5000 },

-  { 0x8700, 0xfed4, 0x4000 },

-  { 0x8700, 0xfed0, 0x3000 },

-  { 0x8700, 0xfece, 0x2000 },

-  { 0x0700, 0xfecd, 0x0000 },

-  { 0x0700, 0xfecf, 0x0000 },

-  { 0x8700, 0xfed2, 0x2000 },

-  { 0x0700, 0xfed1, 0x0000 },

-  { 0x0700, 0xfed3, 0x0000 },

-  { 0x8700, 0xfed8, 0x3000 },

-  { 0x8700, 0xfed6, 0x2000 },

-  { 0x0700, 0xfed5, 0x0000 },

-  { 0x0700, 0xfed7, 0x0000 },

-  { 0x8700, 0xfeda, 0x2000 },

-  { 0x0700, 0xfed9, 0x0000 },

-  { 0x0700, 0xfedb, 0x0000 },

-  { 0x8700, 0xfee4, 0x4000 },

-  { 0x8700, 0xfee0, 0x3000 },

-  { 0x8700, 0xfede, 0x2000 },

-  { 0x0700, 0xfedd, 0x0000 },

-  { 0x0700, 0xfedf, 0x0000 },

-  { 0x8700, 0xfee2, 0x2000 },

-  { 0x0700, 0xfee1, 0x0000 },

-  { 0x0700, 0xfee3, 0x0000 },

-  { 0x8700, 0xfee8, 0x3000 },

-  { 0x8700, 0xfee6, 0x2000 },

-  { 0x0700, 0xfee5, 0x0000 },

-  { 0x0700, 0xfee7, 0x0000 },

-  { 0x8700, 0xfeea, 0x2000 },

-  { 0x0700, 0xfee9, 0x0000 },

-  { 0x0700, 0xfeeb, 0x0000 },

-  { 0x9500, 0xff0f, 0x6000 },

-  { 0x8700, 0xfefc, 0x5000 },

-  { 0x8700, 0xfef4, 0x4000 },

-  { 0x8700, 0xfef0, 0x3000 },

-  { 0x8700, 0xfeee, 0x2000 },

-  { 0x0700, 0xfeed, 0x0000 },

-  { 0x0700, 0xfeef, 0x0000 },

-  { 0x8700, 0xfef2, 0x2000 },

-  { 0x0700, 0xfef1, 0x0000 },

-  { 0x0700, 0xfef3, 0x0000 },

-  { 0x8700, 0xfef8, 0x3000 },

-  { 0x8700, 0xfef6, 0x2000 },

-  { 0x0700, 0xfef5, 0x0000 },

-  { 0x0700, 0xfef7, 0x0000 },

-  { 0x8700, 0xfefa, 0x2000 },

-  { 0x0700, 0xfef9, 0x0000 },

-  { 0x0700, 0xfefb, 0x0000 },

-  { 0x9500, 0xff07, 0x4000 },

-  { 0x9500, 0xff03, 0x3000 },

-  { 0x9500, 0xff01, 0x2000 },

-  { 0x0100, 0xfeff, 0x0000 },

-  { 0x1500, 0xff02, 0x0000 },

-  { 0x9500, 0xff05, 0x2000 },

-  { 0x1700, 0xff04, 0x0000 },

-  { 0x1500, 0xff06, 0x0000 },

-  { 0x9900, 0xff0b, 0x3000 },

-  { 0x9200, 0xff09, 0x2000 },

-  { 0x1600, 0xff08, 0x0000 },

-  { 0x1500, 0xff0a, 0x0000 },

-  { 0x9100, 0xff0d, 0x2000 },

-  { 0x1500, 0xff0c, 0x0000 },

-  { 0x1500, 0xff0e, 0x0000 },

-  { 0x9500, 0xff1f, 0x5000 },

-  { 0x8d00, 0xff17, 0x4000 },

-  { 0x8d00, 0xff13, 0x3000 },

-  { 0x8d00, 0xff11, 0x2000 },

-  { 0x0d00, 0xff10, 0x0000 },

-  { 0x0d00, 0xff12, 0x0000 },

-  { 0x8d00, 0xff15, 0x2000 },

-  { 0x0d00, 0xff14, 0x0000 },

-  { 0x0d00, 0xff16, 0x0000 },

-  { 0x9500, 0xff1b, 0x3000 },

-  { 0x8d00, 0xff19, 0x2000 },

-  { 0x0d00, 0xff18, 0x0000 },

-  { 0x1500, 0xff1a, 0x0000 },

-  { 0x9900, 0xff1d, 0x2000 },

-  { 0x1900, 0xff1c, 0x0000 },

-  { 0x1900, 0xff1e, 0x0000 },

-  { 0x8900, 0xff27, 0x4020 },

-  { 0x8900, 0xff23, 0x3020 },

-  { 0x8900, 0xff21, 0x2020 },

-  { 0x1500, 0xff20, 0x0000 },

-  { 0x0900, 0xff22, 0x0020 },

-  { 0x8900, 0xff25, 0x2020 },

-  { 0x0900, 0xff24, 0x0020 },

-  { 0x0900, 0xff26, 0x0020 },

-  { 0x8900, 0xff2b, 0x3020 },

-  { 0x8900, 0xff29, 0x2020 },

-  { 0x0900, 0xff28, 0x0020 },

-  { 0x0900, 0xff2a, 0x0020 },

-  { 0x8900, 0xff2d, 0x2020 },

-  { 0x0900, 0xff2c, 0x0020 },

-  { 0x0900, 0xff2e, 0x0020 },

-  { 0x8700, 0xff6f, 0x7000 },

-  { 0x8500, 0xff4f, 0x6fe0 },

-  { 0x9000, 0xff3f, 0x5000 },

-  { 0x8900, 0xff37, 0x4020 },

-  { 0x8900, 0xff33, 0x3020 },

-  { 0x8900, 0xff31, 0x2020 },

-  { 0x0900, 0xff30, 0x0020 },

-  { 0x0900, 0xff32, 0x0020 },

-  { 0x8900, 0xff35, 0x2020 },

-  { 0x0900, 0xff34, 0x0020 },

-  { 0x0900, 0xff36, 0x0020 },

-  { 0x9600, 0xff3b, 0x3000 },

-  { 0x8900, 0xff39, 0x2020 },

-  { 0x0900, 0xff38, 0x0020 },

-  { 0x0900, 0xff3a, 0x0020 },

-  { 0x9200, 0xff3d, 0x2000 },

-  { 0x1500, 0xff3c, 0x0000 },

-  { 0x1800, 0xff3e, 0x0000 },

-  { 0x8500, 0xff47, 0x4fe0 },

-  { 0x8500, 0xff43, 0x3fe0 },

-  { 0x8500, 0xff41, 0x2fe0 },

-  { 0x1800, 0xff40, 0x0000 },

-  { 0x0500, 0xff42, 0x0fe0 },

-  { 0x8500, 0xff45, 0x2fe0 },

-  { 0x0500, 0xff44, 0x0fe0 },

-  { 0x0500, 0xff46, 0x0fe0 },

-  { 0x8500, 0xff4b, 0x3fe0 },

-  { 0x8500, 0xff49, 0x2fe0 },

-  { 0x0500, 0xff48, 0x0fe0 },

-  { 0x0500, 0xff4a, 0x0fe0 },

-  { 0x8500, 0xff4d, 0x2fe0 },

-  { 0x0500, 0xff4c, 0x0fe0 },

-  { 0x0500, 0xff4e, 0x0fe0 },

-  { 0x9600, 0xff5f, 0x5000 },

-  { 0x8500, 0xff57, 0x4fe0 },

-  { 0x8500, 0xff53, 0x3fe0 },

-  { 0x8500, 0xff51, 0x2fe0 },

-  { 0x0500, 0xff50, 0x0fe0 },

-  { 0x0500, 0xff52, 0x0fe0 },

-  { 0x8500, 0xff55, 0x2fe0 },

-  { 0x0500, 0xff54, 0x0fe0 },

-  { 0x0500, 0xff56, 0x0fe0 },

-  { 0x9600, 0xff5b, 0x3000 },

-  { 0x8500, 0xff59, 0x2fe0 },

-  { 0x0500, 0xff58, 0x0fe0 },

-  { 0x0500, 0xff5a, 0x0fe0 },

-  { 0x9200, 0xff5d, 0x2000 },

-  { 0x1900, 0xff5c, 0x0000 },

-  { 0x1900, 0xff5e, 0x0000 },

-  { 0x8700, 0xff67, 0x4000 },

-  { 0x9200, 0xff63, 0x3000 },

-  { 0x9500, 0xff61, 0x2000 },

-  { 0x1200, 0xff60, 0x0000 },

-  { 0x1600, 0xff62, 0x0000 },

-  { 0x9000, 0xff65, 0x2000 },

-  { 0x1500, 0xff64, 0x0000 },

-  { 0x0700, 0xff66, 0x0000 },

-  { 0x8700, 0xff6b, 0x3000 },

-  { 0x8700, 0xff69, 0x2000 },

-  { 0x0700, 0xff68, 0x0000 },

-  { 0x0700, 0xff6a, 0x0000 },

-  { 0x8700, 0xff6d, 0x2000 },

-  { 0x0700, 0xff6c, 0x0000 },

-  { 0x0700, 0xff6e, 0x0000 },

-  { 0x8700, 0xff8f, 0x6000 },

-  { 0x8700, 0xff7f, 0x5000 },

-  { 0x8700, 0xff77, 0x4000 },

-  { 0x8700, 0xff73, 0x3000 },

-  { 0x8700, 0xff71, 0x2000 },

-  { 0x0600, 0xff70, 0x0000 },

-  { 0x0700, 0xff72, 0x0000 },

-  { 0x8700, 0xff75, 0x2000 },

-  { 0x0700, 0xff74, 0x0000 },

-  { 0x0700, 0xff76, 0x0000 },

-  { 0x8700, 0xff7b, 0x3000 },

-  { 0x8700, 0xff79, 0x2000 },

-  { 0x0700, 0xff78, 0x0000 },

-  { 0x0700, 0xff7a, 0x0000 },

-  { 0x8700, 0xff7d, 0x2000 },

-  { 0x0700, 0xff7c, 0x0000 },

-  { 0x0700, 0xff7e, 0x0000 },

-  { 0x8700, 0xff87, 0x4000 },

-  { 0x8700, 0xff83, 0x3000 },

-  { 0x8700, 0xff81, 0x2000 },

-  { 0x0700, 0xff80, 0x0000 },

-  { 0x0700, 0xff82, 0x0000 },

-  { 0x8700, 0xff85, 0x2000 },

-  { 0x0700, 0xff84, 0x0000 },

-  { 0x0700, 0xff86, 0x0000 },

-  { 0x8700, 0xff8b, 0x3000 },

-  { 0x8700, 0xff89, 0x2000 },

-  { 0x0700, 0xff88, 0x0000 },

-  { 0x0700, 0xff8a, 0x0000 },

-  { 0x8700, 0xff8d, 0x2000 },

-  { 0x0700, 0xff8c, 0x0000 },

-  { 0x0700, 0xff8e, 0x0000 },

-  { 0x8600, 0xff9f, 0x5000 },

-  { 0x8700, 0xff97, 0x4000 },

-  { 0x8700, 0xff93, 0x3000 },

-  { 0x8700, 0xff91, 0x2000 },

-  { 0x0700, 0xff90, 0x0000 },

-  { 0x0700, 0xff92, 0x0000 },

-  { 0x8700, 0xff95, 0x2000 },

-  { 0x0700, 0xff94, 0x0000 },

-  { 0x0700, 0xff96, 0x0000 },

-  { 0x8700, 0xff9b, 0x3000 },

-  { 0x8700, 0xff99, 0x2000 },

-  { 0x0700, 0xff98, 0x0000 },

-  { 0x0700, 0xff9a, 0x0000 },

-  { 0x8700, 0xff9d, 0x2000 },

-  { 0x0700, 0xff9c, 0x0000 },

-  { 0x0600, 0xff9e, 0x0000 },

-  { 0x8700, 0xffa7, 0x4000 },

-  { 0x8700, 0xffa3, 0x3000 },

-  { 0x8700, 0xffa1, 0x2000 },

-  { 0x0700, 0xffa0, 0x0000 },

-  { 0x0700, 0xffa2, 0x0000 },

-  { 0x8700, 0xffa5, 0x2000 },

-  { 0x0700, 0xffa4, 0x0000 },

-  { 0x0700, 0xffa6, 0x0000 },

-  { 0x8700, 0xffab, 0x3000 },

-  { 0x8700, 0xffa9, 0x2000 },

-  { 0x0700, 0xffa8, 0x0000 },

-  { 0x0700, 0xffaa, 0x0000 },

-  { 0x8700, 0xffad, 0x2000 },

-  { 0x0700, 0xffac, 0x0000 },

-  { 0x0700, 0xffae, 0x0000 },

-  { 0x8701, 0x004c, 0x8000 },

-  { 0x8701, 0x0008, 0x7000 },

-  { 0x8700, 0xffd6, 0x6000 },

-  { 0x8700, 0xffc2, 0x5000 },

-  { 0x8700, 0xffb7, 0x4000 },

-  { 0x8700, 0xffb3, 0x3000 },

-  { 0x8700, 0xffb1, 0x2000 },

-  { 0x0700, 0xffb0, 0x0000 },

-  { 0x0700, 0xffb2, 0x0000 },

-  { 0x8700, 0xffb5, 0x2000 },

-  { 0x0700, 0xffb4, 0x0000 },

-  { 0x0700, 0xffb6, 0x0000 },

-  { 0x8700, 0xffbb, 0x3000 },

-  { 0x8700, 0xffb9, 0x2000 },

-  { 0x0700, 0xffb8, 0x0000 },

-  { 0x0700, 0xffba, 0x0000 },

-  { 0x8700, 0xffbd, 0x2000 },

-  { 0x0700, 0xffbc, 0x0000 },

-  { 0x0700, 0xffbe, 0x0000 },

-  { 0x8700, 0xffcc, 0x4000 },

-  { 0x8700, 0xffc6, 0x3000 },

-  { 0x8700, 0xffc4, 0x2000 },

-  { 0x0700, 0xffc3, 0x0000 },

-  { 0x0700, 0xffc5, 0x0000 },

-  { 0x8700, 0xffca, 0x2000 },

-  { 0x0700, 0xffc7, 0x0000 },

-  { 0x0700, 0xffcb, 0x0000 },

-  { 0x8700, 0xffd2, 0x3000 },

-  { 0x8700, 0xffce, 0x2000 },

-  { 0x0700, 0xffcd, 0x0000 },

-  { 0x0700, 0xffcf, 0x0000 },

-  { 0x8700, 0xffd4, 0x2000 },

-  { 0x0700, 0xffd3, 0x0000 },

-  { 0x0700, 0xffd5, 0x0000 },

-  { 0x9900, 0xffec, 0x5000 },

-  { 0x9800, 0xffe3, 0x4000 },

-  { 0x8700, 0xffdc, 0x3000 },

-  { 0x8700, 0xffda, 0x2000 },

-  { 0x0700, 0xffd7, 0x0000 },

-  { 0x0700, 0xffdb, 0x0000 },

-  { 0x9700, 0xffe1, 0x2000 },

-  { 0x1700, 0xffe0, 0x0000 },

-  { 0x1900, 0xffe2, 0x0000 },

-  { 0x9a00, 0xffe8, 0x3000 },

-  { 0x9700, 0xffe5, 0x2000 },

-  { 0x1a00, 0xffe4, 0x0000 },

-  { 0x1700, 0xffe6, 0x0000 },

-  { 0x9900, 0xffea, 0x2000 },

-  { 0x1900, 0xffe9, 0x0000 },

-  { 0x1900, 0xffeb, 0x0000 },

-  { 0x8701, 0x0000, 0x4000 },

-  { 0x8100, 0xfffa, 0x3000 },

-  { 0x9a00, 0xffee, 0x2000 },

-  { 0x1a00, 0xffed, 0x0000 },

-  { 0x0100, 0xfff9, 0x0000 },

-  { 0x9a00, 0xfffc, 0x2000 },

-  { 0x0100, 0xfffb, 0x0000 },

-  { 0x1a00, 0xfffd, 0x0000 },

-  { 0x8701, 0x0004, 0x3000 },

-  { 0x8701, 0x0002, 0x2000 },

-  { 0x0701, 0x0001, 0x0000 },

-  { 0x0701, 0x0003, 0x0000 },

-  { 0x8701, 0x0006, 0x2000 },

-  { 0x0701, 0x0005, 0x0000 },

-  { 0x0701, 0x0007, 0x0000 },

-  { 0x8701, 0x002a, 0x6000 },

-  { 0x8701, 0x0019, 0x5000 },

-  { 0x8701, 0x0011, 0x4000 },

-  { 0x8701, 0x000d, 0x3000 },

-  { 0x8701, 0x000a, 0x2000 },

-  { 0x0701, 0x0009, 0x0000 },

-  { 0x0701, 0x000b, 0x0000 },

-  { 0x8701, 0x000f, 0x2000 },

-  { 0x0701, 0x000e, 0x0000 },

-  { 0x0701, 0x0010, 0x0000 },

-  { 0x8701, 0x0015, 0x3000 },

-  { 0x8701, 0x0013, 0x2000 },

-  { 0x0701, 0x0012, 0x0000 },

-  { 0x0701, 0x0014, 0x0000 },

-  { 0x8701, 0x0017, 0x2000 },

-  { 0x0701, 0x0016, 0x0000 },

-  { 0x0701, 0x0018, 0x0000 },

-  { 0x8701, 0x0021, 0x4000 },

-  { 0x8701, 0x001d, 0x3000 },

-  { 0x8701, 0x001b, 0x2000 },

-  { 0x0701, 0x001a, 0x0000 },

-  { 0x0701, 0x001c, 0x0000 },

-  { 0x8701, 0x001f, 0x2000 },

-  { 0x0701, 0x001e, 0x0000 },

-  { 0x0701, 0x0020, 0x0000 },

-  { 0x8701, 0x0025, 0x3000 },

-  { 0x8701, 0x0023, 0x2000 },

-  { 0x0701, 0x0022, 0x0000 },

-  { 0x0701, 0x0024, 0x0000 },

-  { 0x8701, 0x0028, 0x2000 },

-  { 0x0701, 0x0026, 0x0000 },

-  { 0x0701, 0x0029, 0x0000 },

-  { 0x8701, 0x003a, 0x5000 },

-  { 0x8701, 0x0032, 0x4000 },

-  { 0x8701, 0x002e, 0x3000 },

-  { 0x8701, 0x002c, 0x2000 },

-  { 0x0701, 0x002b, 0x0000 },

-  { 0x0701, 0x002d, 0x0000 },

-  { 0x8701, 0x0030, 0x2000 },

-  { 0x0701, 0x002f, 0x0000 },

-  { 0x0701, 0x0031, 0x0000 },

-  { 0x8701, 0x0036, 0x3000 },

-  { 0x8701, 0x0034, 0x2000 },

-  { 0x0701, 0x0033, 0x0000 },

-  { 0x0701, 0x0035, 0x0000 },

-  { 0x8701, 0x0038, 0x2000 },

-  { 0x0701, 0x0037, 0x0000 },

-  { 0x0701, 0x0039, 0x0000 },

-  { 0x8701, 0x0044, 0x4000 },

-  { 0x8701, 0x0040, 0x3000 },

-  { 0x8701, 0x003d, 0x2000 },

-  { 0x0701, 0x003c, 0x0000 },

-  { 0x0701, 0x003f, 0x0000 },

-  { 0x8701, 0x0042, 0x2000 },

-  { 0x0701, 0x0041, 0x0000 },

-  { 0x0701, 0x0043, 0x0000 },

-  { 0x8701, 0x0048, 0x3000 },

-  { 0x8701, 0x0046, 0x2000 },

-  { 0x0701, 0x0045, 0x0000 },

-  { 0x0701, 0x0047, 0x0000 },

-  { 0x8701, 0x004a, 0x2000 },

-  { 0x0701, 0x0049, 0x0000 },

-  { 0x0701, 0x004b, 0x0000 },

-  { 0x8701, 0x00b0, 0x7000 },

-  { 0x8701, 0x0090, 0x6000 },

-  { 0x8701, 0x0080, 0x5000 },

-  { 0x8701, 0x0056, 0x4000 },

-  { 0x8701, 0x0052, 0x3000 },

-  { 0x8701, 0x0050, 0x2000 },

-  { 0x0701, 0x004d, 0x0000 },

-  { 0x0701, 0x0051, 0x0000 },

-  { 0x8701, 0x0054, 0x2000 },

-  { 0x0701, 0x0053, 0x0000 },

-  { 0x0701, 0x0055, 0x0000 },

-  { 0x8701, 0x005a, 0x3000 },

-  { 0x8701, 0x0058, 0x2000 },

-  { 0x0701, 0x0057, 0x0000 },

-  { 0x0701, 0x0059, 0x0000 },

-  { 0x8701, 0x005c, 0x2000 },

-  { 0x0701, 0x005b, 0x0000 },

-  { 0x0701, 0x005d, 0x0000 },

-  { 0x8701, 0x0088, 0x4000 },

-  { 0x8701, 0x0084, 0x3000 },

-  { 0x8701, 0x0082, 0x2000 },

-  { 0x0701, 0x0081, 0x0000 },

-  { 0x0701, 0x0083, 0x0000 },

-  { 0x8701, 0x0086, 0x2000 },

-  { 0x0701, 0x0085, 0x0000 },

-  { 0x0701, 0x0087, 0x0000 },

-  { 0x8701, 0x008c, 0x3000 },

-  { 0x8701, 0x008a, 0x2000 },

-  { 0x0701, 0x0089, 0x0000 },

-  { 0x0701, 0x008b, 0x0000 },

-  { 0x8701, 0x008e, 0x2000 },

-  { 0x0701, 0x008d, 0x0000 },

-  { 0x0701, 0x008f, 0x0000 },

-  { 0x8701, 0x00a0, 0x5000 },

-  { 0x8701, 0x0098, 0x4000 },

-  { 0x8701, 0x0094, 0x3000 },

-  { 0x8701, 0x0092, 0x2000 },

-  { 0x0701, 0x0091, 0x0000 },

-  { 0x0701, 0x0093, 0x0000 },

-  { 0x8701, 0x0096, 0x2000 },

-  { 0x0701, 0x0095, 0x0000 },

-  { 0x0701, 0x0097, 0x0000 },

-  { 0x8701, 0x009c, 0x3000 },

-  { 0x8701, 0x009a, 0x2000 },

-  { 0x0701, 0x0099, 0x0000 },

-  { 0x0701, 0x009b, 0x0000 },

-  { 0x8701, 0x009e, 0x2000 },

-  { 0x0701, 0x009d, 0x0000 },

-  { 0x0701, 0x009f, 0x0000 },

-  { 0x8701, 0x00a8, 0x4000 },

-  { 0x8701, 0x00a4, 0x3000 },

-  { 0x8701, 0x00a2, 0x2000 },

-  { 0x0701, 0x00a1, 0x0000 },

-  { 0x0701, 0x00a3, 0x0000 },

-  { 0x8701, 0x00a6, 0x2000 },

-  { 0x0701, 0x00a5, 0x0000 },

-  { 0x0701, 0x00a7, 0x0000 },

-  { 0x8701, 0x00ac, 0x3000 },

-  { 0x8701, 0x00aa, 0x2000 },

-  { 0x0701, 0x00a9, 0x0000 },

-  { 0x0701, 0x00ab, 0x0000 },

-  { 0x8701, 0x00ae, 0x2000 },

-  { 0x0701, 0x00ad, 0x0000 },

-  { 0x0701, 0x00af, 0x0000 },

-  { 0x8701, 0x00d0, 0x6000 },

-  { 0x8701, 0x00c0, 0x5000 },

-  { 0x8701, 0x00b8, 0x4000 },

-  { 0x8701, 0x00b4, 0x3000 },

-  { 0x8701, 0x00b2, 0x2000 },

-  { 0x0701, 0x00b1, 0x0000 },

-  { 0x0701, 0x00b3, 0x0000 },

-  { 0x8701, 0x00b6, 0x2000 },

-  { 0x0701, 0x00b5, 0x0000 },

-  { 0x0701, 0x00b7, 0x0000 },

-  { 0x8701, 0x00bc, 0x3000 },

-  { 0x8701, 0x00ba, 0x2000 },

-  { 0x0701, 0x00b9, 0x0000 },

-  { 0x0701, 0x00bb, 0x0000 },

-  { 0x8701, 0x00be, 0x2000 },

-  { 0x0701, 0x00bd, 0x0000 },

-  { 0x0701, 0x00bf, 0x0000 },

-  { 0x8701, 0x00c8, 0x4000 },

-  { 0x8701, 0x00c4, 0x3000 },

-  { 0x8701, 0x00c2, 0x2000 },

-  { 0x0701, 0x00c1, 0x0000 },

-  { 0x0701, 0x00c3, 0x0000 },

-  { 0x8701, 0x00c6, 0x2000 },

-  { 0x0701, 0x00c5, 0x0000 },

-  { 0x0701, 0x00c7, 0x0000 },

-  { 0x8701, 0x00cc, 0x3000 },

-  { 0x8701, 0x00ca, 0x2000 },

-  { 0x0701, 0x00c9, 0x0000 },

-  { 0x0701, 0x00cb, 0x0000 },

-  { 0x8701, 0x00ce, 0x2000 },

-  { 0x0701, 0x00cd, 0x0000 },

-  { 0x0701, 0x00cf, 0x0000 },

-  { 0x8701, 0x00e0, 0x5000 },

-  { 0x8701, 0x00d8, 0x4000 },

-  { 0x8701, 0x00d4, 0x3000 },

-  { 0x8701, 0x00d2, 0x2000 },

-  { 0x0701, 0x00d1, 0x0000 },

-  { 0x0701, 0x00d3, 0x0000 },

-  { 0x8701, 0x00d6, 0x2000 },

-  { 0x0701, 0x00d5, 0x0000 },

-  { 0x0701, 0x00d7, 0x0000 },

-  { 0x8701, 0x00dc, 0x3000 },

-  { 0x8701, 0x00da, 0x2000 },

-  { 0x0701, 0x00d9, 0x0000 },

-  { 0x0701, 0x00db, 0x0000 },

-  { 0x8701, 0x00de, 0x2000 },

-  { 0x0701, 0x00dd, 0x0000 },

-  { 0x0701, 0x00df, 0x0000 },

-  { 0x8701, 0x00e8, 0x4000 },

-  { 0x8701, 0x00e4, 0x3000 },

-  { 0x8701, 0x00e2, 0x2000 },

-  { 0x0701, 0x00e1, 0x0000 },

-  { 0x0701, 0x00e3, 0x0000 },

-  { 0x8701, 0x00e6, 0x2000 },

-  { 0x0701, 0x00e5, 0x0000 },

-  { 0x0701, 0x00e7, 0x0000 },

-  { 0x8701, 0x00ec, 0x3000 },

-  { 0x8701, 0x00ea, 0x2000 },

-  { 0x0701, 0x00e9, 0x0000 },

-  { 0x0701, 0x00eb, 0x0000 },

-  { 0x8701, 0x00ee, 0x2000 },

-  { 0x0701, 0x00ed, 0x0000 },

-  { 0x0701, 0x00ef, 0x0000 },

-  { 0x8501, 0xd459, 0xb000 },

-  { 0x9a01, 0xd080, 0xa000 },

-  { 0x8701, 0x045f, 0x9000 },

-  { 0x8701, 0x0349, 0x8000 },

-  { 0x9a01, 0x013c, 0x7000 },

-  { 0x8f01, 0x0119, 0x6000 },

-  { 0x8f01, 0x0109, 0x5000 },

-  { 0x8701, 0x00f8, 0x4000 },

-  { 0x8701, 0x00f4, 0x3000 },

-  { 0x8701, 0x00f2, 0x2000 },

-  { 0x0701, 0x00f1, 0x0000 },

-  { 0x0701, 0x00f3, 0x0000 },

-  { 0x8701, 0x00f6, 0x2000 },

-  { 0x0701, 0x00f5, 0x0000 },

-  { 0x0701, 0x00f7, 0x0000 },

-  { 0x9501, 0x0101, 0x3000 },

-  { 0x8701, 0x00fa, 0x2000 },

-  { 0x0701, 0x00f9, 0x0000 },

-  { 0x1501, 0x0100, 0x0000 },

-  { 0x8f01, 0x0107, 0x2000 },

-  { 0x1a01, 0x0102, 0x0000 },

-  { 0x0f01, 0x0108, 0x0000 },

-  { 0x8f01, 0x0111, 0x4000 },

-  { 0x8f01, 0x010d, 0x3000 },

-  { 0x8f01, 0x010b, 0x2000 },

-  { 0x0f01, 0x010a, 0x0000 },

-  { 0x0f01, 0x010c, 0x0000 },

-  { 0x8f01, 0x010f, 0x2000 },

-  { 0x0f01, 0x010e, 0x0000 },

-  { 0x0f01, 0x0110, 0x0000 },

-  { 0x8f01, 0x0115, 0x3000 },

-  { 0x8f01, 0x0113, 0x2000 },

-  { 0x0f01, 0x0112, 0x0000 },

-  { 0x0f01, 0x0114, 0x0000 },

-  { 0x8f01, 0x0117, 0x2000 },

-  { 0x0f01, 0x0116, 0x0000 },

-  { 0x0f01, 0x0118, 0x0000 },

-  { 0x8f01, 0x0129, 0x5000 },

-  { 0x8f01, 0x0121, 0x4000 },

-  { 0x8f01, 0x011d, 0x3000 },

-  { 0x8f01, 0x011b, 0x2000 },

-  { 0x0f01, 0x011a, 0x0000 },

-  { 0x0f01, 0x011c, 0x0000 },

-  { 0x8f01, 0x011f, 0x2000 },

-  { 0x0f01, 0x011e, 0x0000 },

-  { 0x0f01, 0x0120, 0x0000 },

-  { 0x8f01, 0x0125, 0x3000 },

-  { 0x8f01, 0x0123, 0x2000 },

-  { 0x0f01, 0x0122, 0x0000 },

-  { 0x0f01, 0x0124, 0x0000 },

-  { 0x8f01, 0x0127, 0x2000 },

-  { 0x0f01, 0x0126, 0x0000 },

-  { 0x0f01, 0x0128, 0x0000 },

-  { 0x8f01, 0x0131, 0x4000 },

-  { 0x8f01, 0x012d, 0x3000 },

-  { 0x8f01, 0x012b, 0x2000 },

-  { 0x0f01, 0x012a, 0x0000 },

-  { 0x0f01, 0x012c, 0x0000 },

-  { 0x8f01, 0x012f, 0x2000 },

-  { 0x0f01, 0x012e, 0x0000 },

-  { 0x0f01, 0x0130, 0x0000 },

-  { 0x9a01, 0x0138, 0x3000 },

-  { 0x8f01, 0x0133, 0x2000 },

-  { 0x0f01, 0x0132, 0x0000 },

-  { 0x1a01, 0x0137, 0x0000 },

-  { 0x9a01, 0x013a, 0x2000 },

-  { 0x1a01, 0x0139, 0x0000 },

-  { 0x1a01, 0x013b, 0x0000 },

-  { 0x8701, 0x031c, 0x6000 },

-  { 0x8701, 0x030c, 0x5000 },

-  { 0x8701, 0x0304, 0x4000 },

-  { 0x8701, 0x0300, 0x3000 },

-  { 0x9a01, 0x013e, 0x2000 },

-  { 0x1a01, 0x013d, 0x0000 },

-  { 0x1a01, 0x013f, 0x0000 },

-  { 0x8701, 0x0302, 0x2000 },

-  { 0x0701, 0x0301, 0x0000 },

-  { 0x0701, 0x0303, 0x0000 },

-  { 0x8701, 0x0308, 0x3000 },

-  { 0x8701, 0x0306, 0x2000 },

-  { 0x0701, 0x0305, 0x0000 },

-  { 0x0701, 0x0307, 0x0000 },

-  { 0x8701, 0x030a, 0x2000 },

-  { 0x0701, 0x0309, 0x0000 },

-  { 0x0701, 0x030b, 0x0000 },

-  { 0x8701, 0x0314, 0x4000 },

-  { 0x8701, 0x0310, 0x3000 },

-  { 0x8701, 0x030e, 0x2000 },

-  { 0x0701, 0x030d, 0x0000 },

-  { 0x0701, 0x030f, 0x0000 },

-  { 0x8701, 0x0312, 0x2000 },

-  { 0x0701, 0x0311, 0x0000 },

-  { 0x0701, 0x0313, 0x0000 },

-  { 0x8701, 0x0318, 0x3000 },

-  { 0x8701, 0x0316, 0x2000 },

-  { 0x0701, 0x0315, 0x0000 },

-  { 0x0701, 0x0317, 0x0000 },

-  { 0x8701, 0x031a, 0x2000 },

-  { 0x0701, 0x0319, 0x0000 },

-  { 0x0701, 0x031b, 0x0000 },

-  { 0x8701, 0x0339, 0x5000 },

-  { 0x8701, 0x0331, 0x4000 },

-  { 0x8f01, 0x0321, 0x3000 },

-  { 0x8701, 0x031e, 0x2000 },

-  { 0x0701, 0x031d, 0x0000 },

-  { 0x0f01, 0x0320, 0x0000 },

-  { 0x8f01, 0x0323, 0x2000 },

-  { 0x0f01, 0x0322, 0x0000 },

-  { 0x0701, 0x0330, 0x0000 },

-  { 0x8701, 0x0335, 0x3000 },

-  { 0x8701, 0x0333, 0x2000 },

-  { 0x0701, 0x0332, 0x0000 },

-  { 0x0701, 0x0334, 0x0000 },

-  { 0x8701, 0x0337, 0x2000 },

-  { 0x0701, 0x0336, 0x0000 },

-  { 0x0701, 0x0338, 0x0000 },

-  { 0x8701, 0x0341, 0x4000 },

-  { 0x8701, 0x033d, 0x3000 },

-  { 0x8701, 0x033b, 0x2000 },

-  { 0x0701, 0x033a, 0x0000 },

-  { 0x0701, 0x033c, 0x0000 },

-  { 0x8701, 0x033f, 0x2000 },

-  { 0x0701, 0x033e, 0x0000 },

-  { 0x0701, 0x0340, 0x0000 },

-  { 0x8701, 0x0345, 0x3000 },

-  { 0x8701, 0x0343, 0x2000 },

-  { 0x0701, 0x0342, 0x0000 },

-  { 0x0701, 0x0344, 0x0000 },

-  { 0x8701, 0x0347, 0x2000 },

-  { 0x0701, 0x0346, 0x0000 },

-  { 0x0701, 0x0348, 0x0000 },

-  { 0x8901, 0x041f, 0x7028 },

-  { 0x9501, 0x039f, 0x6000 },

-  { 0x8701, 0x038e, 0x5000 },

-  { 0x8701, 0x0386, 0x4000 },

-  { 0x8701, 0x0382, 0x3000 },

-  { 0x8701, 0x0380, 0x2000 },

-  { 0x0e01, 0x034a, 0x0000 },

-  { 0x0701, 0x0381, 0x0000 },

-  { 0x8701, 0x0384, 0x2000 },

-  { 0x0701, 0x0383, 0x0000 },

-  { 0x0701, 0x0385, 0x0000 },

-  { 0x8701, 0x038a, 0x3000 },

-  { 0x8701, 0x0388, 0x2000 },

-  { 0x0701, 0x0387, 0x0000 },

-  { 0x0701, 0x0389, 0x0000 },

-  { 0x8701, 0x038c, 0x2000 },

-  { 0x0701, 0x038b, 0x0000 },

-  { 0x0701, 0x038d, 0x0000 },

-  { 0x8701, 0x0396, 0x4000 },

-  { 0x8701, 0x0392, 0x3000 },

-  { 0x8701, 0x0390, 0x2000 },

-  { 0x0701, 0x038f, 0x0000 },

-  { 0x0701, 0x0391, 0x0000 },

-  { 0x8701, 0x0394, 0x2000 },

-  { 0x0701, 0x0393, 0x0000 },

-  { 0x0701, 0x0395, 0x0000 },

-  { 0x8701, 0x039a, 0x3000 },

-  { 0x8701, 0x0398, 0x2000 },

-  { 0x0701, 0x0397, 0x0000 },

-  { 0x0701, 0x0399, 0x0000 },

-  { 0x8701, 0x039c, 0x2000 },

-  { 0x0701, 0x039b, 0x0000 },

-  { 0x0701, 0x039d, 0x0000 },

-  { 0x8901, 0x040f, 0x5028 },

-  { 0x8901, 0x0407, 0x4028 },

-  { 0x8901, 0x0403, 0x3028 },

-  { 0x8901, 0x0401, 0x2028 },

-  { 0x0901, 0x0400, 0x0028 },

-  { 0x0901, 0x0402, 0x0028 },

-  { 0x8901, 0x0405, 0x2028 },

-  { 0x0901, 0x0404, 0x0028 },

-  { 0x0901, 0x0406, 0x0028 },

-  { 0x8901, 0x040b, 0x3028 },

-  { 0x8901, 0x0409, 0x2028 },

-  { 0x0901, 0x0408, 0x0028 },

-  { 0x0901, 0x040a, 0x0028 },

-  { 0x8901, 0x040d, 0x2028 },

-  { 0x0901, 0x040c, 0x0028 },

-  { 0x0901, 0x040e, 0x0028 },

-  { 0x8901, 0x0417, 0x4028 },

-  { 0x8901, 0x0413, 0x3028 },

-  { 0x8901, 0x0411, 0x2028 },

-  { 0x0901, 0x0410, 0x0028 },

-  { 0x0901, 0x0412, 0x0028 },

-  { 0x8901, 0x0415, 0x2028 },

-  { 0x0901, 0x0414, 0x0028 },

-  { 0x0901, 0x0416, 0x0028 },

-  { 0x8901, 0x041b, 0x3028 },

-  { 0x8901, 0x0419, 0x2028 },

-  { 0x0901, 0x0418, 0x0028 },

-  { 0x0901, 0x041a, 0x0028 },

-  { 0x8901, 0x041d, 0x2028 },

-  { 0x0901, 0x041c, 0x0028 },

-  { 0x0901, 0x041e, 0x0028 },

-  { 0x8501, 0x043f, 0x6fd8 },

-  { 0x8501, 0x042f, 0x5fd8 },

-  { 0x8901, 0x0427, 0x4028 },

-  { 0x8901, 0x0423, 0x3028 },

-  { 0x8901, 0x0421, 0x2028 },

-  { 0x0901, 0x0420, 0x0028 },

-  { 0x0901, 0x0422, 0x0028 },

-  { 0x8901, 0x0425, 0x2028 },

-  { 0x0901, 0x0424, 0x0028 },

-  { 0x0901, 0x0426, 0x0028 },

-  { 0x8501, 0x042b, 0x3fd8 },

-  { 0x8501, 0x0429, 0x2fd8 },

-  { 0x0501, 0x0428, 0x0fd8 },

-  { 0x0501, 0x042a, 0x0fd8 },

-  { 0x8501, 0x042d, 0x2fd8 },

-  { 0x0501, 0x042c, 0x0fd8 },

-  { 0x0501, 0x042e, 0x0fd8 },

-  { 0x8501, 0x0437, 0x4fd8 },

-  { 0x8501, 0x0433, 0x3fd8 },

-  { 0x8501, 0x0431, 0x2fd8 },

-  { 0x0501, 0x0430, 0x0fd8 },

-  { 0x0501, 0x0432, 0x0fd8 },

-  { 0x8501, 0x0435, 0x2fd8 },

-  { 0x0501, 0x0434, 0x0fd8 },

-  { 0x0501, 0x0436, 0x0fd8 },

-  { 0x8501, 0x043b, 0x3fd8 },

-  { 0x8501, 0x0439, 0x2fd8 },

-  { 0x0501, 0x0438, 0x0fd8 },

-  { 0x0501, 0x043a, 0x0fd8 },

-  { 0x8501, 0x043d, 0x2fd8 },

-  { 0x0501, 0x043c, 0x0fd8 },

-  { 0x0501, 0x043e, 0x0fd8 },

-  { 0x8501, 0x044f, 0x5fd8 },

-  { 0x8501, 0x0447, 0x4fd8 },

-  { 0x8501, 0x0443, 0x3fd8 },

-  { 0x8501, 0x0441, 0x2fd8 },

-  { 0x0501, 0x0440, 0x0fd8 },

-  { 0x0501, 0x0442, 0x0fd8 },

-  { 0x8501, 0x0445, 0x2fd8 },

-  { 0x0501, 0x0444, 0x0fd8 },

-  { 0x0501, 0x0446, 0x0fd8 },

-  { 0x8501, 0x044b, 0x3fd8 },

-  { 0x8501, 0x0449, 0x2fd8 },

-  { 0x0501, 0x0448, 0x0fd8 },

-  { 0x0501, 0x044a, 0x0fd8 },

-  { 0x8501, 0x044d, 0x2fd8 },

-  { 0x0501, 0x044c, 0x0fd8 },

-  { 0x0501, 0x044e, 0x0fd8 },

-  { 0x8701, 0x0457, 0x4000 },

-  { 0x8701, 0x0453, 0x3000 },

-  { 0x8701, 0x0451, 0x2000 },

-  { 0x0701, 0x0450, 0x0000 },

-  { 0x0701, 0x0452, 0x0000 },

-  { 0x8701, 0x0455, 0x2000 },

-  { 0x0701, 0x0454, 0x0000 },

-  { 0x0701, 0x0456, 0x0000 },

-  { 0x8701, 0x045b, 0x3000 },

-  { 0x8701, 0x0459, 0x2000 },

-  { 0x0701, 0x0458, 0x0000 },

-  { 0x0701, 0x045a, 0x0000 },

-  { 0x8701, 0x045d, 0x2000 },

-  { 0x0701, 0x045c, 0x0000 },

-  { 0x0701, 0x045e, 0x0000 },

-  { 0x9a01, 0xd000, 0x8000 },

-  { 0x8d01, 0x04a1, 0x7000 },

-  { 0x8701, 0x047f, 0x6000 },

-  { 0x8701, 0x046f, 0x5000 },

-  { 0x8701, 0x0467, 0x4000 },

-  { 0x8701, 0x0463, 0x3000 },

-  { 0x8701, 0x0461, 0x2000 },

-  { 0x0701, 0x0460, 0x0000 },

-  { 0x0701, 0x0462, 0x0000 },

-  { 0x8701, 0x0465, 0x2000 },

-  { 0x0701, 0x0464, 0x0000 },

-  { 0x0701, 0x0466, 0x0000 },

-  { 0x8701, 0x046b, 0x3000 },

-  { 0x8701, 0x0469, 0x2000 },

-  { 0x0701, 0x0468, 0x0000 },

-  { 0x0701, 0x046a, 0x0000 },

-  { 0x8701, 0x046d, 0x2000 },

-  { 0x0701, 0x046c, 0x0000 },

-  { 0x0701, 0x046e, 0x0000 },

-  { 0x8701, 0x0477, 0x4000 },

-  { 0x8701, 0x0473, 0x3000 },

-  { 0x8701, 0x0471, 0x2000 },

-  { 0x0701, 0x0470, 0x0000 },

-  { 0x0701, 0x0472, 0x0000 },

-  { 0x8701, 0x0475, 0x2000 },

-  { 0x0701, 0x0474, 0x0000 },

-  { 0x0701, 0x0476, 0x0000 },

-  { 0x8701, 0x047b, 0x3000 },

-  { 0x8701, 0x0479, 0x2000 },

-  { 0x0701, 0x0478, 0x0000 },

-  { 0x0701, 0x047a, 0x0000 },

-  { 0x8701, 0x047d, 0x2000 },

-  { 0x0701, 0x047c, 0x0000 },

-  { 0x0701, 0x047e, 0x0000 },

-  { 0x8701, 0x048f, 0x5000 },

-  { 0x8701, 0x0487, 0x4000 },

-  { 0x8701, 0x0483, 0x3000 },

-  { 0x8701, 0x0481, 0x2000 },

-  { 0x0701, 0x0480, 0x0000 },

-  { 0x0701, 0x0482, 0x0000 },

-  { 0x8701, 0x0485, 0x2000 },

-  { 0x0701, 0x0484, 0x0000 },

-  { 0x0701, 0x0486, 0x0000 },

-  { 0x8701, 0x048b, 0x3000 },

-  { 0x8701, 0x0489, 0x2000 },

-  { 0x0701, 0x0488, 0x0000 },

-  { 0x0701, 0x048a, 0x0000 },

-  { 0x8701, 0x048d, 0x2000 },

-  { 0x0701, 0x048c, 0x0000 },

-  { 0x0701, 0x048e, 0x0000 },

-  { 0x8701, 0x0497, 0x4000 },

-  { 0x8701, 0x0493, 0x3000 },

-  { 0x8701, 0x0491, 0x2000 },

-  { 0x0701, 0x0490, 0x0000 },

-  { 0x0701, 0x0492, 0x0000 },

-  { 0x8701, 0x0495, 0x2000 },

-  { 0x0701, 0x0494, 0x0000 },

-  { 0x0701, 0x0496, 0x0000 },

-  { 0x8701, 0x049b, 0x3000 },

-  { 0x8701, 0x0499, 0x2000 },

-  { 0x0701, 0x0498, 0x0000 },

-  { 0x0701, 0x049a, 0x0000 },

-  { 0x8701, 0x049d, 0x2000 },

-  { 0x0701, 0x049c, 0x0000 },

-  { 0x0d01, 0x04a0, 0x0000 },

-  { 0x8701, 0x081a, 0x6000 },

-  { 0x8701, 0x080a, 0x5000 },

-  { 0x8d01, 0x04a9, 0x4000 },

-  { 0x8d01, 0x04a5, 0x3000 },

-  { 0x8d01, 0x04a3, 0x2000 },

-  { 0x0d01, 0x04a2, 0x0000 },

-  { 0x0d01, 0x04a4, 0x0000 },

-  { 0x8d01, 0x04a7, 0x2000 },

-  { 0x0d01, 0x04a6, 0x0000 },

-  { 0x0d01, 0x04a8, 0x0000 },

-  { 0x8701, 0x0803, 0x3000 },

-  { 0x8701, 0x0801, 0x2000 },

-  { 0x0701, 0x0800, 0x0000 },

-  { 0x0701, 0x0802, 0x0000 },

-  { 0x8701, 0x0805, 0x2000 },

-  { 0x0701, 0x0804, 0x0000 },

-  { 0x0701, 0x0808, 0x0000 },

-  { 0x8701, 0x0812, 0x4000 },

-  { 0x8701, 0x080e, 0x3000 },

-  { 0x8701, 0x080c, 0x2000 },

-  { 0x0701, 0x080b, 0x0000 },

-  { 0x0701, 0x080d, 0x0000 },

-  { 0x8701, 0x0810, 0x2000 },

-  { 0x0701, 0x080f, 0x0000 },

-  { 0x0701, 0x0811, 0x0000 },

-  { 0x8701, 0x0816, 0x3000 },

-  { 0x8701, 0x0814, 0x2000 },

-  { 0x0701, 0x0813, 0x0000 },

-  { 0x0701, 0x0815, 0x0000 },

-  { 0x8701, 0x0818, 0x2000 },

-  { 0x0701, 0x0817, 0x0000 },

-  { 0x0701, 0x0819, 0x0000 },

-  { 0x8701, 0x082a, 0x5000 },

-  { 0x8701, 0x0822, 0x4000 },

-  { 0x8701, 0x081e, 0x3000 },

-  { 0x8701, 0x081c, 0x2000 },

-  { 0x0701, 0x081b, 0x0000 },

-  { 0x0701, 0x081d, 0x0000 },

-  { 0x8701, 0x0820, 0x2000 },

-  { 0x0701, 0x081f, 0x0000 },

-  { 0x0701, 0x0821, 0x0000 },

-  { 0x8701, 0x0826, 0x3000 },

-  { 0x8701, 0x0824, 0x2000 },

-  { 0x0701, 0x0823, 0x0000 },

-  { 0x0701, 0x0825, 0x0000 },

-  { 0x8701, 0x0828, 0x2000 },

-  { 0x0701, 0x0827, 0x0000 },

-  { 0x0701, 0x0829, 0x0000 },

-  { 0x8701, 0x0832, 0x4000 },

-  { 0x8701, 0x082e, 0x3000 },

-  { 0x8701, 0x082c, 0x2000 },

-  { 0x0701, 0x082b, 0x0000 },

-  { 0x0701, 0x082d, 0x0000 },

-  { 0x8701, 0x0830, 0x2000 },

-  { 0x0701, 0x082f, 0x0000 },

-  { 0x0701, 0x0831, 0x0000 },

-  { 0x8701, 0x0837, 0x3000 },

-  { 0x8701, 0x0834, 0x2000 },

-  { 0x0701, 0x0833, 0x0000 },

-  { 0x0701, 0x0835, 0x0000 },

-  { 0x8701, 0x083c, 0x2000 },

-  { 0x0701, 0x0838, 0x0000 },

-  { 0x0701, 0x083f, 0x0000 },

-  { 0x9a01, 0xd040, 0x7000 },

-  { 0x9a01, 0xd020, 0x6000 },

-  { 0x9a01, 0xd010, 0x5000 },

-  { 0x9a01, 0xd008, 0x4000 },

-  { 0x9a01, 0xd004, 0x3000 },

-  { 0x9a01, 0xd002, 0x2000 },

-  { 0x1a01, 0xd001, 0x0000 },

-  { 0x1a01, 0xd003, 0x0000 },

-  { 0x9a01, 0xd006, 0x2000 },

-  { 0x1a01, 0xd005, 0x0000 },

-  { 0x1a01, 0xd007, 0x0000 },

-  { 0x9a01, 0xd00c, 0x3000 },

-  { 0x9a01, 0xd00a, 0x2000 },

-  { 0x1a01, 0xd009, 0x0000 },

-  { 0x1a01, 0xd00b, 0x0000 },

-  { 0x9a01, 0xd00e, 0x2000 },

-  { 0x1a01, 0xd00d, 0x0000 },

-  { 0x1a01, 0xd00f, 0x0000 },

-  { 0x9a01, 0xd018, 0x4000 },

-  { 0x9a01, 0xd014, 0x3000 },

-  { 0x9a01, 0xd012, 0x2000 },

-  { 0x1a01, 0xd011, 0x0000 },

-  { 0x1a01, 0xd013, 0x0000 },

-  { 0x9a01, 0xd016, 0x2000 },

-  { 0x1a01, 0xd015, 0x0000 },

-  { 0x1a01, 0xd017, 0x0000 },

-  { 0x9a01, 0xd01c, 0x3000 },

-  { 0x9a01, 0xd01a, 0x2000 },

-  { 0x1a01, 0xd019, 0x0000 },

-  { 0x1a01, 0xd01b, 0x0000 },

-  { 0x9a01, 0xd01e, 0x2000 },

-  { 0x1a01, 0xd01d, 0x0000 },

-  { 0x1a01, 0xd01f, 0x0000 },

-  { 0x9a01, 0xd030, 0x5000 },

-  { 0x9a01, 0xd028, 0x4000 },

-  { 0x9a01, 0xd024, 0x3000 },

-  { 0x9a01, 0xd022, 0x2000 },

-  { 0x1a01, 0xd021, 0x0000 },

-  { 0x1a01, 0xd023, 0x0000 },

-  { 0x9a01, 0xd026, 0x2000 },

-  { 0x1a01, 0xd025, 0x0000 },

-  { 0x1a01, 0xd027, 0x0000 },

-  { 0x9a01, 0xd02c, 0x3000 },

-  { 0x9a01, 0xd02a, 0x2000 },

-  { 0x1a01, 0xd029, 0x0000 },

-  { 0x1a01, 0xd02b, 0x0000 },

-  { 0x9a01, 0xd02e, 0x2000 },

-  { 0x1a01, 0xd02d, 0x0000 },

-  { 0x1a01, 0xd02f, 0x0000 },

-  { 0x9a01, 0xd038, 0x4000 },

-  { 0x9a01, 0xd034, 0x3000 },

-  { 0x9a01, 0xd032, 0x2000 },

-  { 0x1a01, 0xd031, 0x0000 },

-  { 0x1a01, 0xd033, 0x0000 },

-  { 0x9a01, 0xd036, 0x2000 },

-  { 0x1a01, 0xd035, 0x0000 },

-  { 0x1a01, 0xd037, 0x0000 },

-  { 0x9a01, 0xd03c, 0x3000 },

-  { 0x9a01, 0xd03a, 0x2000 },

-  { 0x1a01, 0xd039, 0x0000 },

-  { 0x1a01, 0xd03b, 0x0000 },

-  { 0x9a01, 0xd03e, 0x2000 },

-  { 0x1a01, 0xd03d, 0x0000 },

-  { 0x1a01, 0xd03f, 0x0000 },

-  { 0x9a01, 0xd060, 0x6000 },

-  { 0x9a01, 0xd050, 0x5000 },

-  { 0x9a01, 0xd048, 0x4000 },

-  { 0x9a01, 0xd044, 0x3000 },

-  { 0x9a01, 0xd042, 0x2000 },

-  { 0x1a01, 0xd041, 0x0000 },

-  { 0x1a01, 0xd043, 0x0000 },

-  { 0x9a01, 0xd046, 0x2000 },

-  { 0x1a01, 0xd045, 0x0000 },

-  { 0x1a01, 0xd047, 0x0000 },

-  { 0x9a01, 0xd04c, 0x3000 },

-  { 0x9a01, 0xd04a, 0x2000 },

-  { 0x1a01, 0xd049, 0x0000 },

-  { 0x1a01, 0xd04b, 0x0000 },

-  { 0x9a01, 0xd04e, 0x2000 },

-  { 0x1a01, 0xd04d, 0x0000 },

-  { 0x1a01, 0xd04f, 0x0000 },

-  { 0x9a01, 0xd058, 0x4000 },

-  { 0x9a01, 0xd054, 0x3000 },

-  { 0x9a01, 0xd052, 0x2000 },

-  { 0x1a01, 0xd051, 0x0000 },

-  { 0x1a01, 0xd053, 0x0000 },

-  { 0x9a01, 0xd056, 0x2000 },

-  { 0x1a01, 0xd055, 0x0000 },

-  { 0x1a01, 0xd057, 0x0000 },

-  { 0x9a01, 0xd05c, 0x3000 },

-  { 0x9a01, 0xd05a, 0x2000 },

-  { 0x1a01, 0xd059, 0x0000 },

-  { 0x1a01, 0xd05b, 0x0000 },

-  { 0x9a01, 0xd05e, 0x2000 },

-  { 0x1a01, 0xd05d, 0x0000 },

-  { 0x1a01, 0xd05f, 0x0000 },

-  { 0x9a01, 0xd070, 0x5000 },

-  { 0x9a01, 0xd068, 0x4000 },

-  { 0x9a01, 0xd064, 0x3000 },

-  { 0x9a01, 0xd062, 0x2000 },

-  { 0x1a01, 0xd061, 0x0000 },

-  { 0x1a01, 0xd063, 0x0000 },

-  { 0x9a01, 0xd066, 0x2000 },

-  { 0x1a01, 0xd065, 0x0000 },

-  { 0x1a01, 0xd067, 0x0000 },

-  { 0x9a01, 0xd06c, 0x3000 },

-  { 0x9a01, 0xd06a, 0x2000 },

-  { 0x1a01, 0xd069, 0x0000 },

-  { 0x1a01, 0xd06b, 0x0000 },

-  { 0x9a01, 0xd06e, 0x2000 },

-  { 0x1a01, 0xd06d, 0x0000 },

-  { 0x1a01, 0xd06f, 0x0000 },

-  { 0x9a01, 0xd078, 0x4000 },

-  { 0x9a01, 0xd074, 0x3000 },

-  { 0x9a01, 0xd072, 0x2000 },

-  { 0x1a01, 0xd071, 0x0000 },

-  { 0x1a01, 0xd073, 0x0000 },

-  { 0x9a01, 0xd076, 0x2000 },

-  { 0x1a01, 0xd075, 0x0000 },

-  { 0x1a01, 0xd077, 0x0000 },

-  { 0x9a01, 0xd07c, 0x3000 },

-  { 0x9a01, 0xd07a, 0x2000 },

-  { 0x1a01, 0xd079, 0x0000 },

-  { 0x1a01, 0xd07b, 0x0000 },

-  { 0x9a01, 0xd07e, 0x2000 },

-  { 0x1a01, 0xd07d, 0x0000 },

-  { 0x1a01, 0xd07f, 0x0000 },

-  { 0x9a01, 0xd18d, 0x9000 },

-  { 0x9a01, 0xd10a, 0x8000 },

-  { 0x9a01, 0xd0c0, 0x7000 },

-  { 0x9a01, 0xd0a0, 0x6000 },

-  { 0x9a01, 0xd090, 0x5000 },

-  { 0x9a01, 0xd088, 0x4000 },

-  { 0x9a01, 0xd084, 0x3000 },

-  { 0x9a01, 0xd082, 0x2000 },

-  { 0x1a01, 0xd081, 0x0000 },

-  { 0x1a01, 0xd083, 0x0000 },

-  { 0x9a01, 0xd086, 0x2000 },

-  { 0x1a01, 0xd085, 0x0000 },

-  { 0x1a01, 0xd087, 0x0000 },

-  { 0x9a01, 0xd08c, 0x3000 },

-  { 0x9a01, 0xd08a, 0x2000 },

-  { 0x1a01, 0xd089, 0x0000 },

-  { 0x1a01, 0xd08b, 0x0000 },

-  { 0x9a01, 0xd08e, 0x2000 },

-  { 0x1a01, 0xd08d, 0x0000 },

-  { 0x1a01, 0xd08f, 0x0000 },

-  { 0x9a01, 0xd098, 0x4000 },

-  { 0x9a01, 0xd094, 0x3000 },

-  { 0x9a01, 0xd092, 0x2000 },

-  { 0x1a01, 0xd091, 0x0000 },

-  { 0x1a01, 0xd093, 0x0000 },

-  { 0x9a01, 0xd096, 0x2000 },

-  { 0x1a01, 0xd095, 0x0000 },

-  { 0x1a01, 0xd097, 0x0000 },

-  { 0x9a01, 0xd09c, 0x3000 },

-  { 0x9a01, 0xd09a, 0x2000 },

-  { 0x1a01, 0xd099, 0x0000 },

-  { 0x1a01, 0xd09b, 0x0000 },

-  { 0x9a01, 0xd09e, 0x2000 },

-  { 0x1a01, 0xd09d, 0x0000 },

-  { 0x1a01, 0xd09f, 0x0000 },

-  { 0x9a01, 0xd0b0, 0x5000 },

-  { 0x9a01, 0xd0a8, 0x4000 },

-  { 0x9a01, 0xd0a4, 0x3000 },

-  { 0x9a01, 0xd0a2, 0x2000 },

-  { 0x1a01, 0xd0a1, 0x0000 },

-  { 0x1a01, 0xd0a3, 0x0000 },

-  { 0x9a01, 0xd0a6, 0x2000 },

-  { 0x1a01, 0xd0a5, 0x0000 },

-  { 0x1a01, 0xd0a7, 0x0000 },

-  { 0x9a01, 0xd0ac, 0x3000 },

-  { 0x9a01, 0xd0aa, 0x2000 },

-  { 0x1a01, 0xd0a9, 0x0000 },

-  { 0x1a01, 0xd0ab, 0x0000 },

-  { 0x9a01, 0xd0ae, 0x2000 },

-  { 0x1a01, 0xd0ad, 0x0000 },

-  { 0x1a01, 0xd0af, 0x0000 },

-  { 0x9a01, 0xd0b8, 0x4000 },

-  { 0x9a01, 0xd0b4, 0x3000 },

-  { 0x9a01, 0xd0b2, 0x2000 },

-  { 0x1a01, 0xd0b1, 0x0000 },

-  { 0x1a01, 0xd0b3, 0x0000 },

-  { 0x9a01, 0xd0b6, 0x2000 },

-  { 0x1a01, 0xd0b5, 0x0000 },

-  { 0x1a01, 0xd0b7, 0x0000 },

-  { 0x9a01, 0xd0bc, 0x3000 },

-  { 0x9a01, 0xd0ba, 0x2000 },

-  { 0x1a01, 0xd0b9, 0x0000 },

-  { 0x1a01, 0xd0bb, 0x0000 },

-  { 0x9a01, 0xd0be, 0x2000 },

-  { 0x1a01, 0xd0bd, 0x0000 },

-  { 0x1a01, 0xd0bf, 0x0000 },

-  { 0x9a01, 0xd0e0, 0x6000 },

-  { 0x9a01, 0xd0d0, 0x5000 },

-  { 0x9a01, 0xd0c8, 0x4000 },

-  { 0x9a01, 0xd0c4, 0x3000 },

-  { 0x9a01, 0xd0c2, 0x2000 },

-  { 0x1a01, 0xd0c1, 0x0000 },

-  { 0x1a01, 0xd0c3, 0x0000 },

-  { 0x9a01, 0xd0c6, 0x2000 },

-  { 0x1a01, 0xd0c5, 0x0000 },

-  { 0x1a01, 0xd0c7, 0x0000 },

-  { 0x9a01, 0xd0cc, 0x3000 },

-  { 0x9a01, 0xd0ca, 0x2000 },

-  { 0x1a01, 0xd0c9, 0x0000 },

-  { 0x1a01, 0xd0cb, 0x0000 },

-  { 0x9a01, 0xd0ce, 0x2000 },

-  { 0x1a01, 0xd0cd, 0x0000 },

-  { 0x1a01, 0xd0cf, 0x0000 },

-  { 0x9a01, 0xd0d8, 0x4000 },

-  { 0x9a01, 0xd0d4, 0x3000 },

-  { 0x9a01, 0xd0d2, 0x2000 },

-  { 0x1a01, 0xd0d1, 0x0000 },

-  { 0x1a01, 0xd0d3, 0x0000 },

-  { 0x9a01, 0xd0d6, 0x2000 },

-  { 0x1a01, 0xd0d5, 0x0000 },

-  { 0x1a01, 0xd0d7, 0x0000 },

-  { 0x9a01, 0xd0dc, 0x3000 },

-  { 0x9a01, 0xd0da, 0x2000 },

-  { 0x1a01, 0xd0d9, 0x0000 },

-  { 0x1a01, 0xd0db, 0x0000 },

-  { 0x9a01, 0xd0de, 0x2000 },

-  { 0x1a01, 0xd0dd, 0x0000 },

-  { 0x1a01, 0xd0df, 0x0000 },

-  { 0x9a01, 0xd0f0, 0x5000 },

-  { 0x9a01, 0xd0e8, 0x4000 },

-  { 0x9a01, 0xd0e4, 0x3000 },

-  { 0x9a01, 0xd0e2, 0x2000 },

-  { 0x1a01, 0xd0e1, 0x0000 },

-  { 0x1a01, 0xd0e3, 0x0000 },

-  { 0x9a01, 0xd0e6, 0x2000 },

-  { 0x1a01, 0xd0e5, 0x0000 },

-  { 0x1a01, 0xd0e7, 0x0000 },

-  { 0x9a01, 0xd0ec, 0x3000 },

-  { 0x9a01, 0xd0ea, 0x2000 },

-  { 0x1a01, 0xd0e9, 0x0000 },

-  { 0x1a01, 0xd0eb, 0x0000 },

-  { 0x9a01, 0xd0ee, 0x2000 },

-  { 0x1a01, 0xd0ed, 0x0000 },

-  { 0x1a01, 0xd0ef, 0x0000 },

-  { 0x9a01, 0xd102, 0x4000 },

-  { 0x9a01, 0xd0f4, 0x3000 },

-  { 0x9a01, 0xd0f2, 0x2000 },

-  { 0x1a01, 0xd0f1, 0x0000 },

-  { 0x1a01, 0xd0f3, 0x0000 },

-  { 0x9a01, 0xd100, 0x2000 },

-  { 0x1a01, 0xd0f5, 0x0000 },

-  { 0x1a01, 0xd101, 0x0000 },

-  { 0x9a01, 0xd106, 0x3000 },

-  { 0x9a01, 0xd104, 0x2000 },

-  { 0x1a01, 0xd103, 0x0000 },

-  { 0x1a01, 0xd105, 0x0000 },

-  { 0x9a01, 0xd108, 0x2000 },

-  { 0x1a01, 0xd107, 0x0000 },

-  { 0x1a01, 0xd109, 0x0000 },

-  { 0x9a01, 0xd14d, 0x7000 },

-  { 0x9a01, 0xd12d, 0x6000 },

-  { 0x9a01, 0xd11a, 0x5000 },

-  { 0x9a01, 0xd112, 0x4000 },

-  { 0x9a01, 0xd10e, 0x3000 },

-  { 0x9a01, 0xd10c, 0x2000 },

-  { 0x1a01, 0xd10b, 0x0000 },

-  { 0x1a01, 0xd10d, 0x0000 },

-  { 0x9a01, 0xd110, 0x2000 },

-  { 0x1a01, 0xd10f, 0x0000 },

-  { 0x1a01, 0xd111, 0x0000 },

-  { 0x9a01, 0xd116, 0x3000 },

-  { 0x9a01, 0xd114, 0x2000 },

-  { 0x1a01, 0xd113, 0x0000 },

-  { 0x1a01, 0xd115, 0x0000 },

-  { 0x9a01, 0xd118, 0x2000 },

-  { 0x1a01, 0xd117, 0x0000 },

-  { 0x1a01, 0xd119, 0x0000 },

-  { 0x9a01, 0xd122, 0x4000 },

-  { 0x9a01, 0xd11e, 0x3000 },

-  { 0x9a01, 0xd11c, 0x2000 },

-  { 0x1a01, 0xd11b, 0x0000 },

-  { 0x1a01, 0xd11d, 0x0000 },

-  { 0x9a01, 0xd120, 0x2000 },

-  { 0x1a01, 0xd11f, 0x0000 },

-  { 0x1a01, 0xd121, 0x0000 },

-  { 0x9a01, 0xd126, 0x3000 },

-  { 0x9a01, 0xd124, 0x2000 },

-  { 0x1a01, 0xd123, 0x0000 },

-  { 0x1a01, 0xd125, 0x0000 },

-  { 0x9a01, 0xd12b, 0x2000 },

-  { 0x1a01, 0xd12a, 0x0000 },

-  { 0x1a01, 0xd12c, 0x0000 },

-  { 0x9a01, 0xd13d, 0x5000 },

-  { 0x9a01, 0xd135, 0x4000 },

-  { 0x9a01, 0xd131, 0x3000 },

-  { 0x9a01, 0xd12f, 0x2000 },

-  { 0x1a01, 0xd12e, 0x0000 },

-  { 0x1a01, 0xd130, 0x0000 },

-  { 0x9a01, 0xd133, 0x2000 },

-  { 0x1a01, 0xd132, 0x0000 },

-  { 0x1a01, 0xd134, 0x0000 },

-  { 0x9a01, 0xd139, 0x3000 },

-  { 0x9a01, 0xd137, 0x2000 },

-  { 0x1a01, 0xd136, 0x0000 },

-  { 0x1a01, 0xd138, 0x0000 },

-  { 0x9a01, 0xd13b, 0x2000 },

-  { 0x1a01, 0xd13a, 0x0000 },

-  { 0x1a01, 0xd13c, 0x0000 },

-  { 0x9a01, 0xd145, 0x4000 },

-  { 0x9a01, 0xd141, 0x3000 },

-  { 0x9a01, 0xd13f, 0x2000 },

-  { 0x1a01, 0xd13e, 0x0000 },

-  { 0x1a01, 0xd140, 0x0000 },

-  { 0x9a01, 0xd143, 0x2000 },

-  { 0x1a01, 0xd142, 0x0000 },

-  { 0x1a01, 0xd144, 0x0000 },

-  { 0x9a01, 0xd149, 0x3000 },

-  { 0x9a01, 0xd147, 0x2000 },

-  { 0x1a01, 0xd146, 0x0000 },

-  { 0x1a01, 0xd148, 0x0000 },

-  { 0x9a01, 0xd14b, 0x2000 },

-  { 0x1a01, 0xd14a, 0x0000 },

-  { 0x1a01, 0xd14c, 0x0000 },

-  { 0x8a01, 0xd16d, 0x6000 },

-  { 0x9a01, 0xd15d, 0x5000 },

-  { 0x9a01, 0xd155, 0x4000 },

-  { 0x9a01, 0xd151, 0x3000 },

-  { 0x9a01, 0xd14f, 0x2000 },

-  { 0x1a01, 0xd14e, 0x0000 },

-  { 0x1a01, 0xd150, 0x0000 },

-  { 0x9a01, 0xd153, 0x2000 },

-  { 0x1a01, 0xd152, 0x0000 },

-  { 0x1a01, 0xd154, 0x0000 },

-  { 0x9a01, 0xd159, 0x3000 },

-  { 0x9a01, 0xd157, 0x2000 },

-  { 0x1a01, 0xd156, 0x0000 },

-  { 0x1a01, 0xd158, 0x0000 },

-  { 0x9a01, 0xd15b, 0x2000 },

-  { 0x1a01, 0xd15a, 0x0000 },

-  { 0x1a01, 0xd15c, 0x0000 },

-  { 0x8a01, 0xd165, 0x4000 },

-  { 0x9a01, 0xd161, 0x3000 },

-  { 0x9a01, 0xd15f, 0x2000 },

-  { 0x1a01, 0xd15e, 0x0000 },

-  { 0x1a01, 0xd160, 0x0000 },

-  { 0x9a01, 0xd163, 0x2000 },

-  { 0x1a01, 0xd162, 0x0000 },

-  { 0x1a01, 0xd164, 0x0000 },

-  { 0x8c01, 0xd169, 0x3000 },

-  { 0x8c01, 0xd167, 0x2000 },

-  { 0x0a01, 0xd166, 0x0000 },

-  { 0x0c01, 0xd168, 0x0000 },

-  { 0x9a01, 0xd16b, 0x2000 },

-  { 0x1a01, 0xd16a, 0x0000 },

-  { 0x1a01, 0xd16c, 0x0000 },

-  { 0x8c01, 0xd17d, 0x5000 },

-  { 0x8101, 0xd175, 0x4000 },

-  { 0x8a01, 0xd171, 0x3000 },

-  { 0x8a01, 0xd16f, 0x2000 },

-  { 0x0a01, 0xd16e, 0x0000 },

-  { 0x0a01, 0xd170, 0x0000 },

-  { 0x8101, 0xd173, 0x2000 },

-  { 0x0a01, 0xd172, 0x0000 },

-  { 0x0101, 0xd174, 0x0000 },

-  { 0x8101, 0xd179, 0x3000 },

-  { 0x8101, 0xd177, 0x2000 },

-  { 0x0101, 0xd176, 0x0000 },

-  { 0x0101, 0xd178, 0x0000 },

-  { 0x8c01, 0xd17b, 0x2000 },

-  { 0x0101, 0xd17a, 0x0000 },

-  { 0x0c01, 0xd17c, 0x0000 },

-  { 0x8c01, 0xd185, 0x4000 },

-  { 0x8c01, 0xd181, 0x3000 },

-  { 0x8c01, 0xd17f, 0x2000 },

-  { 0x0c01, 0xd17e, 0x0000 },

-  { 0x0c01, 0xd180, 0x0000 },

-  { 0x9a01, 0xd183, 0x2000 },

-  { 0x0c01, 0xd182, 0x0000 },

-  { 0x1a01, 0xd184, 0x0000 },

-  { 0x8c01, 0xd189, 0x3000 },

-  { 0x8c01, 0xd187, 0x2000 },

-  { 0x0c01, 0xd186, 0x0000 },

-  { 0x0c01, 0xd188, 0x0000 },

-  { 0x8c01, 0xd18b, 0x2000 },

-  { 0x0c01, 0xd18a, 0x0000 },

-  { 0x1a01, 0xd18c, 0x0000 },

-  { 0x9a01, 0xd32f, 0x8000 },

-  { 0x9a01, 0xd1cd, 0x7000 },

-  { 0x8c01, 0xd1ad, 0x6000 },

-  { 0x9a01, 0xd19d, 0x5000 },

-  { 0x9a01, 0xd195, 0x4000 },

-  { 0x9a01, 0xd191, 0x3000 },

-  { 0x9a01, 0xd18f, 0x2000 },

-  { 0x1a01, 0xd18e, 0x0000 },

-  { 0x1a01, 0xd190, 0x0000 },

-  { 0x9a01, 0xd193, 0x2000 },

-  { 0x1a01, 0xd192, 0x0000 },

-  { 0x1a01, 0xd194, 0x0000 },

-  { 0x9a01, 0xd199, 0x3000 },

-  { 0x9a01, 0xd197, 0x2000 },

-  { 0x1a01, 0xd196, 0x0000 },

-  { 0x1a01, 0xd198, 0x0000 },

-  { 0x9a01, 0xd19b, 0x2000 },

-  { 0x1a01, 0xd19a, 0x0000 },

-  { 0x1a01, 0xd19c, 0x0000 },

-  { 0x9a01, 0xd1a5, 0x4000 },

-  { 0x9a01, 0xd1a1, 0x3000 },

-  { 0x9a01, 0xd19f, 0x2000 },

-  { 0x1a01, 0xd19e, 0x0000 },

-  { 0x1a01, 0xd1a0, 0x0000 },

-  { 0x9a01, 0xd1a3, 0x2000 },

-  { 0x1a01, 0xd1a2, 0x0000 },

-  { 0x1a01, 0xd1a4, 0x0000 },

-  { 0x9a01, 0xd1a9, 0x3000 },

-  { 0x9a01, 0xd1a7, 0x2000 },

-  { 0x1a01, 0xd1a6, 0x0000 },

-  { 0x1a01, 0xd1a8, 0x0000 },

-  { 0x8c01, 0xd1ab, 0x2000 },

-  { 0x0c01, 0xd1aa, 0x0000 },

-  { 0x0c01, 0xd1ac, 0x0000 },

-  { 0x9a01, 0xd1bd, 0x5000 },

-  { 0x9a01, 0xd1b5, 0x4000 },

-  { 0x9a01, 0xd1b1, 0x3000 },

-  { 0x9a01, 0xd1af, 0x2000 },

-  { 0x1a01, 0xd1ae, 0x0000 },

-  { 0x1a01, 0xd1b0, 0x0000 },

-  { 0x9a01, 0xd1b3, 0x2000 },

-  { 0x1a01, 0xd1b2, 0x0000 },

-  { 0x1a01, 0xd1b4, 0x0000 },

-  { 0x9a01, 0xd1b9, 0x3000 },

-  { 0x9a01, 0xd1b7, 0x2000 },

-  { 0x1a01, 0xd1b6, 0x0000 },

-  { 0x1a01, 0xd1b8, 0x0000 },

-  { 0x9a01, 0xd1bb, 0x2000 },

-  { 0x1a01, 0xd1ba, 0x0000 },

-  { 0x1a01, 0xd1bc, 0x0000 },

-  { 0x9a01, 0xd1c5, 0x4000 },

-  { 0x9a01, 0xd1c1, 0x3000 },

-  { 0x9a01, 0xd1bf, 0x2000 },

-  { 0x1a01, 0xd1be, 0x0000 },

-  { 0x1a01, 0xd1c0, 0x0000 },

-  { 0x9a01, 0xd1c3, 0x2000 },

-  { 0x1a01, 0xd1c2, 0x0000 },

-  { 0x1a01, 0xd1c4, 0x0000 },

-  { 0x9a01, 0xd1c9, 0x3000 },

-  { 0x9a01, 0xd1c7, 0x2000 },

-  { 0x1a01, 0xd1c6, 0x0000 },

-  { 0x1a01, 0xd1c8, 0x0000 },

-  { 0x9a01, 0xd1cb, 0x2000 },

-  { 0x1a01, 0xd1ca, 0x0000 },

-  { 0x1a01, 0xd1cc, 0x0000 },

-  { 0x9a01, 0xd30f, 0x6000 },

-  { 0x9a01, 0xd1dd, 0x5000 },

-  { 0x9a01, 0xd1d5, 0x4000 },

-  { 0x9a01, 0xd1d1, 0x3000 },

-  { 0x9a01, 0xd1cf, 0x2000 },

-  { 0x1a01, 0xd1ce, 0x0000 },

-  { 0x1a01, 0xd1d0, 0x0000 },

-  { 0x9a01, 0xd1d3, 0x2000 },

-  { 0x1a01, 0xd1d2, 0x0000 },

-  { 0x1a01, 0xd1d4, 0x0000 },

-  { 0x9a01, 0xd1d9, 0x3000 },

-  { 0x9a01, 0xd1d7, 0x2000 },

-  { 0x1a01, 0xd1d6, 0x0000 },

-  { 0x1a01, 0xd1d8, 0x0000 },

-  { 0x9a01, 0xd1db, 0x2000 },

-  { 0x1a01, 0xd1da, 0x0000 },

-  { 0x1a01, 0xd1dc, 0x0000 },

-  { 0x9a01, 0xd307, 0x4000 },

-  { 0x9a01, 0xd303, 0x3000 },

-  { 0x9a01, 0xd301, 0x2000 },

-  { 0x1a01, 0xd300, 0x0000 },

-  { 0x1a01, 0xd302, 0x0000 },

-  { 0x9a01, 0xd305, 0x2000 },

-  { 0x1a01, 0xd304, 0x0000 },

-  { 0x1a01, 0xd306, 0x0000 },

-  { 0x9a01, 0xd30b, 0x3000 },

-  { 0x9a01, 0xd309, 0x2000 },

-  { 0x1a01, 0xd308, 0x0000 },

-  { 0x1a01, 0xd30a, 0x0000 },

-  { 0x9a01, 0xd30d, 0x2000 },

-  { 0x1a01, 0xd30c, 0x0000 },

-  { 0x1a01, 0xd30e, 0x0000 },

-  { 0x9a01, 0xd31f, 0x5000 },

-  { 0x9a01, 0xd317, 0x4000 },

-  { 0x9a01, 0xd313, 0x3000 },

-  { 0x9a01, 0xd311, 0x2000 },

-  { 0x1a01, 0xd310, 0x0000 },

-  { 0x1a01, 0xd312, 0x0000 },

-  { 0x9a01, 0xd315, 0x2000 },

-  { 0x1a01, 0xd314, 0x0000 },

-  { 0x1a01, 0xd316, 0x0000 },

-  { 0x9a01, 0xd31b, 0x3000 },

-  { 0x9a01, 0xd319, 0x2000 },

-  { 0x1a01, 0xd318, 0x0000 },

-  { 0x1a01, 0xd31a, 0x0000 },

-  { 0x9a01, 0xd31d, 0x2000 },

-  { 0x1a01, 0xd31c, 0x0000 },

-  { 0x1a01, 0xd31e, 0x0000 },

-  { 0x9a01, 0xd327, 0x4000 },

-  { 0x9a01, 0xd323, 0x3000 },

-  { 0x9a01, 0xd321, 0x2000 },

-  { 0x1a01, 0xd320, 0x0000 },

-  { 0x1a01, 0xd322, 0x0000 },

-  { 0x9a01, 0xd325, 0x2000 },

-  { 0x1a01, 0xd324, 0x0000 },

-  { 0x1a01, 0xd326, 0x0000 },

-  { 0x9a01, 0xd32b, 0x3000 },

-  { 0x9a01, 0xd329, 0x2000 },

-  { 0x1a01, 0xd328, 0x0000 },

-  { 0x1a01, 0xd32a, 0x0000 },

-  { 0x9a01, 0xd32d, 0x2000 },

-  { 0x1a01, 0xd32c, 0x0000 },

-  { 0x1a01, 0xd32e, 0x0000 },

-  { 0x8901, 0xd418, 0x7000 },

-  { 0x9a01, 0xd34f, 0x6000 },

-  { 0x9a01, 0xd33f, 0x5000 },

-  { 0x9a01, 0xd337, 0x4000 },

-  { 0x9a01, 0xd333, 0x3000 },

-  { 0x9a01, 0xd331, 0x2000 },

-  { 0x1a01, 0xd330, 0x0000 },

-  { 0x1a01, 0xd332, 0x0000 },

-  { 0x9a01, 0xd335, 0x2000 },

-  { 0x1a01, 0xd334, 0x0000 },

-  { 0x1a01, 0xd336, 0x0000 },

-  { 0x9a01, 0xd33b, 0x3000 },

-  { 0x9a01, 0xd339, 0x2000 },

-  { 0x1a01, 0xd338, 0x0000 },

-  { 0x1a01, 0xd33a, 0x0000 },

-  { 0x9a01, 0xd33d, 0x2000 },

-  { 0x1a01, 0xd33c, 0x0000 },

-  { 0x1a01, 0xd33e, 0x0000 },

-  { 0x9a01, 0xd347, 0x4000 },

-  { 0x9a01, 0xd343, 0x3000 },

-  { 0x9a01, 0xd341, 0x2000 },

-  { 0x1a01, 0xd340, 0x0000 },

-  { 0x1a01, 0xd342, 0x0000 },

-  { 0x9a01, 0xd345, 0x2000 },

-  { 0x1a01, 0xd344, 0x0000 },

-  { 0x1a01, 0xd346, 0x0000 },

-  { 0x9a01, 0xd34b, 0x3000 },

-  { 0x9a01, 0xd349, 0x2000 },

-  { 0x1a01, 0xd348, 0x0000 },

-  { 0x1a01, 0xd34a, 0x0000 },

-  { 0x9a01, 0xd34d, 0x2000 },

-  { 0x1a01, 0xd34c, 0x0000 },

-  { 0x1a01, 0xd34e, 0x0000 },

-  { 0x8901, 0xd408, 0x5000 },

-  { 0x8901, 0xd400, 0x4000 },

-  { 0x9a01, 0xd353, 0x3000 },

-  { 0x9a01, 0xd351, 0x2000 },

-  { 0x1a01, 0xd350, 0x0000 },

-  { 0x1a01, 0xd352, 0x0000 },

-  { 0x9a01, 0xd355, 0x2000 },

-  { 0x1a01, 0xd354, 0x0000 },

-  { 0x1a01, 0xd356, 0x0000 },

-  { 0x8901, 0xd404, 0x3000 },

-  { 0x8901, 0xd402, 0x2000 },

-  { 0x0901, 0xd401, 0x0000 },

-  { 0x0901, 0xd403, 0x0000 },

-  { 0x8901, 0xd406, 0x2000 },

-  { 0x0901, 0xd405, 0x0000 },

-  { 0x0901, 0xd407, 0x0000 },

-  { 0x8901, 0xd410, 0x4000 },

-  { 0x8901, 0xd40c, 0x3000 },

-  { 0x8901, 0xd40a, 0x2000 },

-  { 0x0901, 0xd409, 0x0000 },

-  { 0x0901, 0xd40b, 0x0000 },

-  { 0x8901, 0xd40e, 0x2000 },

-  { 0x0901, 0xd40d, 0x0000 },

-  { 0x0901, 0xd40f, 0x0000 },

-  { 0x8901, 0xd414, 0x3000 },

-  { 0x8901, 0xd412, 0x2000 },

-  { 0x0901, 0xd411, 0x0000 },

-  { 0x0901, 0xd413, 0x0000 },

-  { 0x8901, 0xd416, 0x2000 },

-  { 0x0901, 0xd415, 0x0000 },

-  { 0x0901, 0xd417, 0x0000 },

-  { 0x8901, 0xd438, 0x6000 },

-  { 0x8501, 0xd428, 0x5000 },

-  { 0x8501, 0xd420, 0x4000 },

-  { 0x8501, 0xd41c, 0x3000 },

-  { 0x8501, 0xd41a, 0x2000 },

-  { 0x0901, 0xd419, 0x0000 },

-  { 0x0501, 0xd41b, 0x0000 },

-  { 0x8501, 0xd41e, 0x2000 },

-  { 0x0501, 0xd41d, 0x0000 },

-  { 0x0501, 0xd41f, 0x0000 },

-  { 0x8501, 0xd424, 0x3000 },

-  { 0x8501, 0xd422, 0x2000 },

-  { 0x0501, 0xd421, 0x0000 },

-  { 0x0501, 0xd423, 0x0000 },

-  { 0x8501, 0xd426, 0x2000 },

-  { 0x0501, 0xd425, 0x0000 },

-  { 0x0501, 0xd427, 0x0000 },

-  { 0x8501, 0xd430, 0x4000 },

-  { 0x8501, 0xd42c, 0x3000 },

-  { 0x8501, 0xd42a, 0x2000 },

-  { 0x0501, 0xd429, 0x0000 },

-  { 0x0501, 0xd42b, 0x0000 },

-  { 0x8501, 0xd42e, 0x2000 },

-  { 0x0501, 0xd42d, 0x0000 },

-  { 0x0501, 0xd42f, 0x0000 },

-  { 0x8901, 0xd434, 0x3000 },

-  { 0x8501, 0xd432, 0x2000 },

-  { 0x0501, 0xd431, 0x0000 },

-  { 0x0501, 0xd433, 0x0000 },

-  { 0x8901, 0xd436, 0x2000 },

-  { 0x0901, 0xd435, 0x0000 },

-  { 0x0901, 0xd437, 0x0000 },

-  { 0x8901, 0xd448, 0x5000 },

-  { 0x8901, 0xd440, 0x4000 },

-  { 0x8901, 0xd43c, 0x3000 },

-  { 0x8901, 0xd43a, 0x2000 },

-  { 0x0901, 0xd439, 0x0000 },

-  { 0x0901, 0xd43b, 0x0000 },

-  { 0x8901, 0xd43e, 0x2000 },

-  { 0x0901, 0xd43d, 0x0000 },

-  { 0x0901, 0xd43f, 0x0000 },

-  { 0x8901, 0xd444, 0x3000 },

-  { 0x8901, 0xd442, 0x2000 },

-  { 0x0901, 0xd441, 0x0000 },

-  { 0x0901, 0xd443, 0x0000 },

-  { 0x8901, 0xd446, 0x2000 },

-  { 0x0901, 0xd445, 0x0000 },

-  { 0x0901, 0xd447, 0x0000 },

-  { 0x8501, 0xd450, 0x4000 },

-  { 0x8901, 0xd44c, 0x3000 },

-  { 0x8901, 0xd44a, 0x2000 },

-  { 0x0901, 0xd449, 0x0000 },

-  { 0x0901, 0xd44b, 0x0000 },

-  { 0x8501, 0xd44e, 0x2000 },

-  { 0x0901, 0xd44d, 0x0000 },

-  { 0x0501, 0xd44f, 0x0000 },

-  { 0x8501, 0xd454, 0x3000 },

-  { 0x8501, 0xd452, 0x2000 },

-  { 0x0501, 0xd451, 0x0000 },

-  { 0x0501, 0xd453, 0x0000 },

-  { 0x8501, 0xd457, 0x2000 },

-  { 0x0501, 0xd456, 0x0000 },

-  { 0x0501, 0xd458, 0x0000 },

-  { 0x8702, 0xf876, 0xb000 },

-  { 0x8901, 0xd670, 0xa000 },

-  { 0x8901, 0xd570, 0x9000 },

-  { 0x8901, 0xd4e4, 0x8000 },

-  { 0x8501, 0xd499, 0x7000 },

-  { 0x8901, 0xd479, 0x6000 },

-  { 0x8901, 0xd469, 0x5000 },

-  { 0x8501, 0xd461, 0x4000 },

-  { 0x8501, 0xd45d, 0x3000 },

-  { 0x8501, 0xd45b, 0x2000 },

-  { 0x0501, 0xd45a, 0x0000 },

-  { 0x0501, 0xd45c, 0x0000 },

-  { 0x8501, 0xd45f, 0x2000 },

-  { 0x0501, 0xd45e, 0x0000 },

-  { 0x0501, 0xd460, 0x0000 },

-  { 0x8501, 0xd465, 0x3000 },

-  { 0x8501, 0xd463, 0x2000 },

-  { 0x0501, 0xd462, 0x0000 },

-  { 0x0501, 0xd464, 0x0000 },

-  { 0x8501, 0xd467, 0x2000 },

-  { 0x0501, 0xd466, 0x0000 },

-  { 0x0901, 0xd468, 0x0000 },

-  { 0x8901, 0xd471, 0x4000 },

-  { 0x8901, 0xd46d, 0x3000 },

-  { 0x8901, 0xd46b, 0x2000 },

-  { 0x0901, 0xd46a, 0x0000 },

-  { 0x0901, 0xd46c, 0x0000 },

-  { 0x8901, 0xd46f, 0x2000 },

-  { 0x0901, 0xd46e, 0x0000 },

-  { 0x0901, 0xd470, 0x0000 },

-  { 0x8901, 0xd475, 0x3000 },

-  { 0x8901, 0xd473, 0x2000 },

-  { 0x0901, 0xd472, 0x0000 },

-  { 0x0901, 0xd474, 0x0000 },

-  { 0x8901, 0xd477, 0x2000 },

-  { 0x0901, 0xd476, 0x0000 },

-  { 0x0901, 0xd478, 0x0000 },

-  { 0x8501, 0xd489, 0x5000 },

-  { 0x8901, 0xd481, 0x4000 },

-  { 0x8901, 0xd47d, 0x3000 },

-  { 0x8901, 0xd47b, 0x2000 },

-  { 0x0901, 0xd47a, 0x0000 },

-  { 0x0901, 0xd47c, 0x0000 },

-  { 0x8901, 0xd47f, 0x2000 },

-  { 0x0901, 0xd47e, 0x0000 },

-  { 0x0901, 0xd480, 0x0000 },

-  { 0x8501, 0xd485, 0x3000 },

-  { 0x8501, 0xd483, 0x2000 },

-  { 0x0501, 0xd482, 0x0000 },

-  { 0x0501, 0xd484, 0x0000 },

-  { 0x8501, 0xd487, 0x2000 },

-  { 0x0501, 0xd486, 0x0000 },

-  { 0x0501, 0xd488, 0x0000 },

-  { 0x8501, 0xd491, 0x4000 },

-  { 0x8501, 0xd48d, 0x3000 },

-  { 0x8501, 0xd48b, 0x2000 },

-  { 0x0501, 0xd48a, 0x0000 },

-  { 0x0501, 0xd48c, 0x0000 },

-  { 0x8501, 0xd48f, 0x2000 },

-  { 0x0501, 0xd48e, 0x0000 },

-  { 0x0501, 0xd490, 0x0000 },

-  { 0x8501, 0xd495, 0x3000 },

-  { 0x8501, 0xd493, 0x2000 },

-  { 0x0501, 0xd492, 0x0000 },

-  { 0x0501, 0xd494, 0x0000 },

-  { 0x8501, 0xd497, 0x2000 },

-  { 0x0501, 0xd496, 0x0000 },

-  { 0x0501, 0xd498, 0x0000 },

-  { 0x8501, 0xd4c3, 0x6000 },

-  { 0x8901, 0xd4b1, 0x5000 },

-  { 0x8901, 0xd4a6, 0x4000 },

-  { 0x8901, 0xd49e, 0x3000 },

-  { 0x8501, 0xd49b, 0x2000 },

-  { 0x0501, 0xd49a, 0x0000 },

-  { 0x0901, 0xd49c, 0x0000 },

-  { 0x8901, 0xd4a2, 0x2000 },

-  { 0x0901, 0xd49f, 0x0000 },

-  { 0x0901, 0xd4a5, 0x0000 },

-  { 0x8901, 0xd4ac, 0x3000 },

-  { 0x8901, 0xd4aa, 0x2000 },

-  { 0x0901, 0xd4a9, 0x0000 },

-  { 0x0901, 0xd4ab, 0x0000 },

-  { 0x8901, 0xd4af, 0x2000 },

-  { 0x0901, 0xd4ae, 0x0000 },

-  { 0x0901, 0xd4b0, 0x0000 },

-  { 0x8501, 0xd4b9, 0x4000 },

-  { 0x8901, 0xd4b5, 0x3000 },

-  { 0x8901, 0xd4b3, 0x2000 },

-  { 0x0901, 0xd4b2, 0x0000 },

-  { 0x0901, 0xd4b4, 0x0000 },

-  { 0x8501, 0xd4b7, 0x2000 },

-  { 0x0501, 0xd4b6, 0x0000 },

-  { 0x0501, 0xd4b8, 0x0000 },

-  { 0x8501, 0xd4bf, 0x3000 },

-  { 0x8501, 0xd4bd, 0x2000 },

-  { 0x0501, 0xd4bb, 0x0000 },

-  { 0x0501, 0xd4be, 0x0000 },

-  { 0x8501, 0xd4c1, 0x2000 },

-  { 0x0501, 0xd4c0, 0x0000 },

-  { 0x0501, 0xd4c2, 0x0000 },

-  { 0x8901, 0xd4d4, 0x5000 },

-  { 0x8501, 0xd4cc, 0x4000 },

-  { 0x8501, 0xd4c8, 0x3000 },

-  { 0x8501, 0xd4c6, 0x2000 },

-  { 0x0501, 0xd4c5, 0x0000 },

-  { 0x0501, 0xd4c7, 0x0000 },

-  { 0x8501, 0xd4ca, 0x2000 },

-  { 0x0501, 0xd4c9, 0x0000 },

-  { 0x0501, 0xd4cb, 0x0000 },

-  { 0x8901, 0xd4d0, 0x3000 },

-  { 0x8501, 0xd4ce, 0x2000 },

-  { 0x0501, 0xd4cd, 0x0000 },

-  { 0x0501, 0xd4cf, 0x0000 },

-  { 0x8901, 0xd4d2, 0x2000 },

-  { 0x0901, 0xd4d1, 0x0000 },

-  { 0x0901, 0xd4d3, 0x0000 },

-  { 0x8901, 0xd4dc, 0x4000 },

-  { 0x8901, 0xd4d8, 0x3000 },

-  { 0x8901, 0xd4d6, 0x2000 },

-  { 0x0901, 0xd4d5, 0x0000 },

-  { 0x0901, 0xd4d7, 0x0000 },

-  { 0x8901, 0xd4da, 0x2000 },

-  { 0x0901, 0xd4d9, 0x0000 },

-  { 0x0901, 0xd4db, 0x0000 },

-  { 0x8901, 0xd4e0, 0x3000 },

-  { 0x8901, 0xd4de, 0x2000 },

-  { 0x0901, 0xd4dd, 0x0000 },

-  { 0x0901, 0xd4df, 0x0000 },

-  { 0x8901, 0xd4e2, 0x2000 },

-  { 0x0901, 0xd4e1, 0x0000 },

-  { 0x0901, 0xd4e3, 0x0000 },

-  { 0x8501, 0xd529, 0x7000 },

-  { 0x8901, 0xd504, 0x6000 },

-  { 0x8501, 0xd4f4, 0x5000 },

-  { 0x8501, 0xd4ec, 0x4000 },

-  { 0x8901, 0xd4e8, 0x3000 },

-  { 0x8901, 0xd4e6, 0x2000 },

-  { 0x0901, 0xd4e5, 0x0000 },

-  { 0x0901, 0xd4e7, 0x0000 },

-  { 0x8501, 0xd4ea, 0x2000 },

-  { 0x0901, 0xd4e9, 0x0000 },

-  { 0x0501, 0xd4eb, 0x0000 },

-  { 0x8501, 0xd4f0, 0x3000 },

-  { 0x8501, 0xd4ee, 0x2000 },

-  { 0x0501, 0xd4ed, 0x0000 },

-  { 0x0501, 0xd4ef, 0x0000 },

-  { 0x8501, 0xd4f2, 0x2000 },

-  { 0x0501, 0xd4f1, 0x0000 },

-  { 0x0501, 0xd4f3, 0x0000 },

-  { 0x8501, 0xd4fc, 0x4000 },

-  { 0x8501, 0xd4f8, 0x3000 },

-  { 0x8501, 0xd4f6, 0x2000 },

-  { 0x0501, 0xd4f5, 0x0000 },

-  { 0x0501, 0xd4f7, 0x0000 },

-  { 0x8501, 0xd4fa, 0x2000 },

-  { 0x0501, 0xd4f9, 0x0000 },

-  { 0x0501, 0xd4fb, 0x0000 },

-  { 0x8501, 0xd500, 0x3000 },

-  { 0x8501, 0xd4fe, 0x2000 },

-  { 0x0501, 0xd4fd, 0x0000 },

-  { 0x0501, 0xd4ff, 0x0000 },

-  { 0x8501, 0xd502, 0x2000 },

-  { 0x0501, 0xd501, 0x0000 },

-  { 0x0501, 0xd503, 0x0000 },

-  { 0x8901, 0xd518, 0x5000 },

-  { 0x8901, 0xd50f, 0x4000 },

-  { 0x8901, 0xd509, 0x3000 },

-  { 0x8901, 0xd507, 0x2000 },

-  { 0x0901, 0xd505, 0x0000 },

-  { 0x0901, 0xd508, 0x0000 },

-  { 0x8901, 0xd50d, 0x2000 },

-  { 0x0901, 0xd50a, 0x0000 },

-  { 0x0901, 0xd50e, 0x0000 },

-  { 0x8901, 0xd513, 0x3000 },

-  { 0x8901, 0xd511, 0x2000 },

-  { 0x0901, 0xd510, 0x0000 },

-  { 0x0901, 0xd512, 0x0000 },

-  { 0x8901, 0xd516, 0x2000 },

-  { 0x0901, 0xd514, 0x0000 },

-  { 0x0901, 0xd517, 0x0000 },

-  { 0x8501, 0xd521, 0x4000 },

-  { 0x8901, 0xd51c, 0x3000 },

-  { 0x8901, 0xd51a, 0x2000 },

-  { 0x0901, 0xd519, 0x0000 },

-  { 0x0901, 0xd51b, 0x0000 },

-  { 0x8501, 0xd51f, 0x2000 },

-  { 0x0501, 0xd51e, 0x0000 },

-  { 0x0501, 0xd520, 0x0000 },

-  { 0x8501, 0xd525, 0x3000 },

-  { 0x8501, 0xd523, 0x2000 },

-  { 0x0501, 0xd522, 0x0000 },

-  { 0x0501, 0xd524, 0x0000 },

-  { 0x8501, 0xd527, 0x2000 },

-  { 0x0501, 0xd526, 0x0000 },

-  { 0x0501, 0xd528, 0x0000 },

-  { 0x8901, 0xd54f, 0x6000 },

-  { 0x8901, 0xd539, 0x5000 },

-  { 0x8501, 0xd531, 0x4000 },

-  { 0x8501, 0xd52d, 0x3000 },

-  { 0x8501, 0xd52b, 0x2000 },

-  { 0x0501, 0xd52a, 0x0000 },

-  { 0x0501, 0xd52c, 0x0000 },

-  { 0x8501, 0xd52f, 0x2000 },

-  { 0x0501, 0xd52e, 0x0000 },

-  { 0x0501, 0xd530, 0x0000 },

-  { 0x8501, 0xd535, 0x3000 },

-  { 0x8501, 0xd533, 0x2000 },

-  { 0x0501, 0xd532, 0x0000 },

-  { 0x0501, 0xd534, 0x0000 },

-  { 0x8501, 0xd537, 0x2000 },

-  { 0x0501, 0xd536, 0x0000 },

-  { 0x0901, 0xd538, 0x0000 },

-  { 0x8901, 0xd543, 0x4000 },

-  { 0x8901, 0xd53e, 0x3000 },

-  { 0x8901, 0xd53c, 0x2000 },

-  { 0x0901, 0xd53b, 0x0000 },

-  { 0x0901, 0xd53d, 0x0000 },

-  { 0x8901, 0xd541, 0x2000 },

-  { 0x0901, 0xd540, 0x0000 },

-  { 0x0901, 0xd542, 0x0000 },

-  { 0x8901, 0xd54b, 0x3000 },

-  { 0x8901, 0xd546, 0x2000 },

-  { 0x0901, 0xd544, 0x0000 },

-  { 0x0901, 0xd54a, 0x0000 },

-  { 0x8901, 0xd54d, 0x2000 },

-  { 0x0901, 0xd54c, 0x0000 },

-  { 0x0901, 0xd54e, 0x0000 },

-  { 0x8501, 0xd560, 0x5000 },

-  { 0x8501, 0xd558, 0x4000 },

-  { 0x8501, 0xd554, 0x3000 },

-  { 0x8501, 0xd552, 0x2000 },

-  { 0x0901, 0xd550, 0x0000 },

-  { 0x0501, 0xd553, 0x0000 },

-  { 0x8501, 0xd556, 0x2000 },

-  { 0x0501, 0xd555, 0x0000 },

-  { 0x0501, 0xd557, 0x0000 },

-  { 0x8501, 0xd55c, 0x3000 },

-  { 0x8501, 0xd55a, 0x2000 },

-  { 0x0501, 0xd559, 0x0000 },

-  { 0x0501, 0xd55b, 0x0000 },

-  { 0x8501, 0xd55e, 0x2000 },

-  { 0x0501, 0xd55d, 0x0000 },

-  { 0x0501, 0xd55f, 0x0000 },

-  { 0x8501, 0xd568, 0x4000 },

-  { 0x8501, 0xd564, 0x3000 },

-  { 0x8501, 0xd562, 0x2000 },

-  { 0x0501, 0xd561, 0x0000 },

-  { 0x0501, 0xd563, 0x0000 },

-  { 0x8501, 0xd566, 0x2000 },

-  { 0x0501, 0xd565, 0x0000 },

-  { 0x0501, 0xd567, 0x0000 },

-  { 0x8901, 0xd56c, 0x3000 },

-  { 0x8501, 0xd56a, 0x2000 },

-  { 0x0501, 0xd569, 0x0000 },

-  { 0x0501, 0xd56b, 0x0000 },

-  { 0x8901, 0xd56e, 0x2000 },

-  { 0x0901, 0xd56d, 0x0000 },

-  { 0x0901, 0xd56f, 0x0000 },

-  { 0x8501, 0xd5f0, 0x8000 },

-  { 0x8901, 0xd5b0, 0x7000 },

-  { 0x8501, 0xd590, 0x6000 },

-  { 0x8901, 0xd580, 0x5000 },

-  { 0x8901, 0xd578, 0x4000 },

-  { 0x8901, 0xd574, 0x3000 },

-  { 0x8901, 0xd572, 0x2000 },

-  { 0x0901, 0xd571, 0x0000 },

-  { 0x0901, 0xd573, 0x0000 },

-  { 0x8901, 0xd576, 0x2000 },

-  { 0x0901, 0xd575, 0x0000 },

-  { 0x0901, 0xd577, 0x0000 },

-  { 0x8901, 0xd57c, 0x3000 },

-  { 0x8901, 0xd57a, 0x2000 },

-  { 0x0901, 0xd579, 0x0000 },

-  { 0x0901, 0xd57b, 0x0000 },

-  { 0x8901, 0xd57e, 0x2000 },

-  { 0x0901, 0xd57d, 0x0000 },

-  { 0x0901, 0xd57f, 0x0000 },

-  { 0x8501, 0xd588, 0x4000 },

-  { 0x8901, 0xd584, 0x3000 },

-  { 0x8901, 0xd582, 0x2000 },

-  { 0x0901, 0xd581, 0x0000 },

-  { 0x0901, 0xd583, 0x0000 },

-  { 0x8501, 0xd586, 0x2000 },

-  { 0x0901, 0xd585, 0x0000 },

-  { 0x0501, 0xd587, 0x0000 },

-  { 0x8501, 0xd58c, 0x3000 },

-  { 0x8501, 0xd58a, 0x2000 },

-  { 0x0501, 0xd589, 0x0000 },

-  { 0x0501, 0xd58b, 0x0000 },

-  { 0x8501, 0xd58e, 0x2000 },

-  { 0x0501, 0xd58d, 0x0000 },

-  { 0x0501, 0xd58f, 0x0000 },

-  { 0x8901, 0xd5a0, 0x5000 },

-  { 0x8501, 0xd598, 0x4000 },

-  { 0x8501, 0xd594, 0x3000 },

-  { 0x8501, 0xd592, 0x2000 },

-  { 0x0501, 0xd591, 0x0000 },

-  { 0x0501, 0xd593, 0x0000 },

-  { 0x8501, 0xd596, 0x2000 },

-  { 0x0501, 0xd595, 0x0000 },

-  { 0x0501, 0xd597, 0x0000 },

-  { 0x8501, 0xd59c, 0x3000 },

-  { 0x8501, 0xd59a, 0x2000 },

-  { 0x0501, 0xd599, 0x0000 },

-  { 0x0501, 0xd59b, 0x0000 },

-  { 0x8501, 0xd59e, 0x2000 },

-  { 0x0501, 0xd59d, 0x0000 },

-  { 0x0501, 0xd59f, 0x0000 },

-  { 0x8901, 0xd5a8, 0x4000 },

-  { 0x8901, 0xd5a4, 0x3000 },

-  { 0x8901, 0xd5a2, 0x2000 },

-  { 0x0901, 0xd5a1, 0x0000 },

-  { 0x0901, 0xd5a3, 0x0000 },

-  { 0x8901, 0xd5a6, 0x2000 },

-  { 0x0901, 0xd5a5, 0x0000 },

-  { 0x0901, 0xd5a7, 0x0000 },

-  { 0x8901, 0xd5ac, 0x3000 },

-  { 0x8901, 0xd5aa, 0x2000 },

-  { 0x0901, 0xd5a9, 0x0000 },

-  { 0x0901, 0xd5ab, 0x0000 },

-  { 0x8901, 0xd5ae, 0x2000 },

-  { 0x0901, 0xd5ad, 0x0000 },

-  { 0x0901, 0xd5af, 0x0000 },

-  { 0x8501, 0xd5d0, 0x6000 },

-  { 0x8501, 0xd5c0, 0x5000 },

-  { 0x8901, 0xd5b8, 0x4000 },

-  { 0x8901, 0xd5b4, 0x3000 },

-  { 0x8901, 0xd5b2, 0x2000 },

-  { 0x0901, 0xd5b1, 0x0000 },

-  { 0x0901, 0xd5b3, 0x0000 },

-  { 0x8901, 0xd5b6, 0x2000 },

-  { 0x0901, 0xd5b5, 0x0000 },

-  { 0x0901, 0xd5b7, 0x0000 },

-  { 0x8501, 0xd5bc, 0x3000 },

-  { 0x8501, 0xd5ba, 0x2000 },

-  { 0x0901, 0xd5b9, 0x0000 },

-  { 0x0501, 0xd5bb, 0x0000 },

-  { 0x8501, 0xd5be, 0x2000 },

-  { 0x0501, 0xd5bd, 0x0000 },

-  { 0x0501, 0xd5bf, 0x0000 },

-  { 0x8501, 0xd5c8, 0x4000 },

-  { 0x8501, 0xd5c4, 0x3000 },

-  { 0x8501, 0xd5c2, 0x2000 },

-  { 0x0501, 0xd5c1, 0x0000 },

-  { 0x0501, 0xd5c3, 0x0000 },

-  { 0x8501, 0xd5c6, 0x2000 },

-  { 0x0501, 0xd5c5, 0x0000 },

-  { 0x0501, 0xd5c7, 0x0000 },

-  { 0x8501, 0xd5cc, 0x3000 },

-  { 0x8501, 0xd5ca, 0x2000 },

-  { 0x0501, 0xd5c9, 0x0000 },

-  { 0x0501, 0xd5cb, 0x0000 },

-  { 0x8501, 0xd5ce, 0x2000 },

-  { 0x0501, 0xd5cd, 0x0000 },

-  { 0x0501, 0xd5cf, 0x0000 },

-  { 0x8901, 0xd5e0, 0x5000 },

-  { 0x8901, 0xd5d8, 0x4000 },

-  { 0x8901, 0xd5d4, 0x3000 },

-  { 0x8501, 0xd5d2, 0x2000 },

-  { 0x0501, 0xd5d1, 0x0000 },

-  { 0x0501, 0xd5d3, 0x0000 },

-  { 0x8901, 0xd5d6, 0x2000 },

-  { 0x0901, 0xd5d5, 0x0000 },

-  { 0x0901, 0xd5d7, 0x0000 },

-  { 0x8901, 0xd5dc, 0x3000 },

-  { 0x8901, 0xd5da, 0x2000 },

-  { 0x0901, 0xd5d9, 0x0000 },

-  { 0x0901, 0xd5db, 0x0000 },

-  { 0x8901, 0xd5de, 0x2000 },

-  { 0x0901, 0xd5dd, 0x0000 },

-  { 0x0901, 0xd5df, 0x0000 },

-  { 0x8901, 0xd5e8, 0x4000 },

-  { 0x8901, 0xd5e4, 0x3000 },

-  { 0x8901, 0xd5e2, 0x2000 },

-  { 0x0901, 0xd5e1, 0x0000 },

-  { 0x0901, 0xd5e3, 0x0000 },

-  { 0x8901, 0xd5e6, 0x2000 },

-  { 0x0901, 0xd5e5, 0x0000 },

-  { 0x0901, 0xd5e7, 0x0000 },

-  { 0x8901, 0xd5ec, 0x3000 },

-  { 0x8901, 0xd5ea, 0x2000 },

-  { 0x0901, 0xd5e9, 0x0000 },

-  { 0x0901, 0xd5eb, 0x0000 },

-  { 0x8501, 0xd5ee, 0x2000 },

-  { 0x0901, 0xd5ed, 0x0000 },

-  { 0x0501, 0xd5ef, 0x0000 },

-  { 0x8501, 0xd630, 0x7000 },

-  { 0x8901, 0xd610, 0x6000 },

-  { 0x8501, 0xd600, 0x5000 },

-  { 0x8501, 0xd5f8, 0x4000 },

-  { 0x8501, 0xd5f4, 0x3000 },

-  { 0x8501, 0xd5f2, 0x2000 },

-  { 0x0501, 0xd5f1, 0x0000 },

-  { 0x0501, 0xd5f3, 0x0000 },

-  { 0x8501, 0xd5f6, 0x2000 },

-  { 0x0501, 0xd5f5, 0x0000 },

-  { 0x0501, 0xd5f7, 0x0000 },

-  { 0x8501, 0xd5fc, 0x3000 },

-  { 0x8501, 0xd5fa, 0x2000 },

-  { 0x0501, 0xd5f9, 0x0000 },

-  { 0x0501, 0xd5fb, 0x0000 },

-  { 0x8501, 0xd5fe, 0x2000 },

-  { 0x0501, 0xd5fd, 0x0000 },

-  { 0x0501, 0xd5ff, 0x0000 },

-  { 0x8901, 0xd608, 0x4000 },

-  { 0x8501, 0xd604, 0x3000 },

-  { 0x8501, 0xd602, 0x2000 },

-  { 0x0501, 0xd601, 0x0000 },

-  { 0x0501, 0xd603, 0x0000 },

-  { 0x8501, 0xd606, 0x2000 },

-  { 0x0501, 0xd605, 0x0000 },

-  { 0x0501, 0xd607, 0x0000 },

-  { 0x8901, 0xd60c, 0x3000 },

-  { 0x8901, 0xd60a, 0x2000 },

-  { 0x0901, 0xd609, 0x0000 },

-  { 0x0901, 0xd60b, 0x0000 },

-  { 0x8901, 0xd60e, 0x2000 },

-  { 0x0901, 0xd60d, 0x0000 },

-  { 0x0901, 0xd60f, 0x0000 },

-  { 0x8901, 0xd620, 0x5000 },

-  { 0x8901, 0xd618, 0x4000 },

-  { 0x8901, 0xd614, 0x3000 },

-  { 0x8901, 0xd612, 0x2000 },

-  { 0x0901, 0xd611, 0x0000 },

-  { 0x0901, 0xd613, 0x0000 },

-  { 0x8901, 0xd616, 0x2000 },

-  { 0x0901, 0xd615, 0x0000 },

-  { 0x0901, 0xd617, 0x0000 },

-  { 0x8901, 0xd61c, 0x3000 },

-  { 0x8901, 0xd61a, 0x2000 },

-  { 0x0901, 0xd619, 0x0000 },

-  { 0x0901, 0xd61b, 0x0000 },

-  { 0x8901, 0xd61e, 0x2000 },

-  { 0x0901, 0xd61d, 0x0000 },

-  { 0x0901, 0xd61f, 0x0000 },

-  { 0x8501, 0xd628, 0x4000 },

-  { 0x8501, 0xd624, 0x3000 },

-  { 0x8501, 0xd622, 0x2000 },

-  { 0x0901, 0xd621, 0x0000 },

-  { 0x0501, 0xd623, 0x0000 },

-  { 0x8501, 0xd626, 0x2000 },

-  { 0x0501, 0xd625, 0x0000 },

-  { 0x0501, 0xd627, 0x0000 },

-  { 0x8501, 0xd62c, 0x3000 },

-  { 0x8501, 0xd62a, 0x2000 },

-  { 0x0501, 0xd629, 0x0000 },

-  { 0x0501, 0xd62b, 0x0000 },

-  { 0x8501, 0xd62e, 0x2000 },

-  { 0x0501, 0xd62d, 0x0000 },

-  { 0x0501, 0xd62f, 0x0000 },

-  { 0x8901, 0xd650, 0x6000 },

-  { 0x8901, 0xd640, 0x5000 },

-  { 0x8501, 0xd638, 0x4000 },

-  { 0x8501, 0xd634, 0x3000 },

-  { 0x8501, 0xd632, 0x2000 },

-  { 0x0501, 0xd631, 0x0000 },

-  { 0x0501, 0xd633, 0x0000 },

-  { 0x8501, 0xd636, 0x2000 },

-  { 0x0501, 0xd635, 0x0000 },

-  { 0x0501, 0xd637, 0x0000 },

-  { 0x8901, 0xd63c, 0x3000 },

-  { 0x8501, 0xd63a, 0x2000 },

-  { 0x0501, 0xd639, 0x0000 },

-  { 0x0501, 0xd63b, 0x0000 },

-  { 0x8901, 0xd63e, 0x2000 },

-  { 0x0901, 0xd63d, 0x0000 },

-  { 0x0901, 0xd63f, 0x0000 },

-  { 0x8901, 0xd648, 0x4000 },

-  { 0x8901, 0xd644, 0x3000 },

-  { 0x8901, 0xd642, 0x2000 },

-  { 0x0901, 0xd641, 0x0000 },

-  { 0x0901, 0xd643, 0x0000 },

-  { 0x8901, 0xd646, 0x2000 },

-  { 0x0901, 0xd645, 0x0000 },

-  { 0x0901, 0xd647, 0x0000 },

-  { 0x8901, 0xd64c, 0x3000 },

-  { 0x8901, 0xd64a, 0x2000 },

-  { 0x0901, 0xd649, 0x0000 },

-  { 0x0901, 0xd64b, 0x0000 },

-  { 0x8901, 0xd64e, 0x2000 },

-  { 0x0901, 0xd64d, 0x0000 },

-  { 0x0901, 0xd64f, 0x0000 },

-  { 0x8501, 0xd660, 0x5000 },

-  { 0x8501, 0xd658, 0x4000 },

-  { 0x8901, 0xd654, 0x3000 },

-  { 0x8901, 0xd652, 0x2000 },

-  { 0x0901, 0xd651, 0x0000 },

-  { 0x0901, 0xd653, 0x0000 },

-  { 0x8501, 0xd656, 0x2000 },

-  { 0x0901, 0xd655, 0x0000 },

-  { 0x0501, 0xd657, 0x0000 },

-  { 0x8501, 0xd65c, 0x3000 },

-  { 0x8501, 0xd65a, 0x2000 },

-  { 0x0501, 0xd659, 0x0000 },

-  { 0x0501, 0xd65b, 0x0000 },

-  { 0x8501, 0xd65e, 0x2000 },

-  { 0x0501, 0xd65d, 0x0000 },

-  { 0x0501, 0xd65f, 0x0000 },

-  { 0x8501, 0xd668, 0x4000 },

-  { 0x8501, 0xd664, 0x3000 },

-  { 0x8501, 0xd662, 0x2000 },

-  { 0x0501, 0xd661, 0x0000 },

-  { 0x0501, 0xd663, 0x0000 },

-  { 0x8501, 0xd666, 0x2000 },

-  { 0x0501, 0xd665, 0x0000 },

-  { 0x0501, 0xd667, 0x0000 },

-  { 0x8501, 0xd66c, 0x3000 },

-  { 0x8501, 0xd66a, 0x2000 },

-  { 0x0501, 0xd669, 0x0000 },

-  { 0x0501, 0xd66b, 0x0000 },

-  { 0x8501, 0xd66e, 0x2000 },

-  { 0x0501, 0xd66d, 0x0000 },

-  { 0x0501, 0xd66f, 0x0000 },

-  { 0x8501, 0xd774, 0x9000 },

-  { 0x8901, 0xd6f4, 0x8000 },

-  { 0x8901, 0xd6b4, 0x7000 },

-  { 0x8501, 0xd690, 0x6000 },

-  { 0x8901, 0xd680, 0x5000 },

-  { 0x8901, 0xd678, 0x4000 },

-  { 0x8901, 0xd674, 0x3000 },

-  { 0x8901, 0xd672, 0x2000 },

-  { 0x0901, 0xd671, 0x0000 },

-  { 0x0901, 0xd673, 0x0000 },

-  { 0x8901, 0xd676, 0x2000 },

-  { 0x0901, 0xd675, 0x0000 },

-  { 0x0901, 0xd677, 0x0000 },

-  { 0x8901, 0xd67c, 0x3000 },

-  { 0x8901, 0xd67a, 0x2000 },

-  { 0x0901, 0xd679, 0x0000 },

-  { 0x0901, 0xd67b, 0x0000 },

-  { 0x8901, 0xd67e, 0x2000 },

-  { 0x0901, 0xd67d, 0x0000 },

-  { 0x0901, 0xd67f, 0x0000 },

-  { 0x8901, 0xd688, 0x4000 },

-  { 0x8901, 0xd684, 0x3000 },

-  { 0x8901, 0xd682, 0x2000 },

-  { 0x0901, 0xd681, 0x0000 },

-  { 0x0901, 0xd683, 0x0000 },

-  { 0x8901, 0xd686, 0x2000 },

-  { 0x0901, 0xd685, 0x0000 },

-  { 0x0901, 0xd687, 0x0000 },

-  { 0x8501, 0xd68c, 0x3000 },

-  { 0x8501, 0xd68a, 0x2000 },

-  { 0x0901, 0xd689, 0x0000 },

-  { 0x0501, 0xd68b, 0x0000 },

-  { 0x8501, 0xd68e, 0x2000 },

-  { 0x0501, 0xd68d, 0x0000 },

-  { 0x0501, 0xd68f, 0x0000 },

-  { 0x8501, 0xd6a0, 0x5000 },

-  { 0x8501, 0xd698, 0x4000 },

-  { 0x8501, 0xd694, 0x3000 },

-  { 0x8501, 0xd692, 0x2000 },

-  { 0x0501, 0xd691, 0x0000 },

-  { 0x0501, 0xd693, 0x0000 },

-  { 0x8501, 0xd696, 0x2000 },

-  { 0x0501, 0xd695, 0x0000 },

-  { 0x0501, 0xd697, 0x0000 },

-  { 0x8501, 0xd69c, 0x3000 },

-  { 0x8501, 0xd69a, 0x2000 },

-  { 0x0501, 0xd699, 0x0000 },

-  { 0x0501, 0xd69b, 0x0000 },

-  { 0x8501, 0xd69e, 0x2000 },

-  { 0x0501, 0xd69d, 0x0000 },

-  { 0x0501, 0xd69f, 0x0000 },

-  { 0x8901, 0xd6ac, 0x4000 },

-  { 0x8901, 0xd6a8, 0x3000 },

-  { 0x8501, 0xd6a2, 0x2000 },

-  { 0x0501, 0xd6a1, 0x0000 },

-  { 0x0501, 0xd6a3, 0x0000 },

-  { 0x8901, 0xd6aa, 0x2000 },

-  { 0x0901, 0xd6a9, 0x0000 },

-  { 0x0901, 0xd6ab, 0x0000 },

-  { 0x8901, 0xd6b0, 0x3000 },

-  { 0x8901, 0xd6ae, 0x2000 },

-  { 0x0901, 0xd6ad, 0x0000 },

-  { 0x0901, 0xd6af, 0x0000 },

-  { 0x8901, 0xd6b2, 0x2000 },

-  { 0x0901, 0xd6b1, 0x0000 },

-  { 0x0901, 0xd6b3, 0x0000 },

-  { 0x8501, 0xd6d4, 0x6000 },

-  { 0x8501, 0xd6c4, 0x5000 },

-  { 0x8901, 0xd6bc, 0x4000 },

-  { 0x8901, 0xd6b8, 0x3000 },

-  { 0x8901, 0xd6b6, 0x2000 },

-  { 0x0901, 0xd6b5, 0x0000 },

-  { 0x0901, 0xd6b7, 0x0000 },

-  { 0x8901, 0xd6ba, 0x2000 },

-  { 0x0901, 0xd6b9, 0x0000 },

-  { 0x0901, 0xd6bb, 0x0000 },

-  { 0x8901, 0xd6c0, 0x3000 },

-  { 0x8901, 0xd6be, 0x2000 },

-  { 0x0901, 0xd6bd, 0x0000 },

-  { 0x0901, 0xd6bf, 0x0000 },

-  { 0x8501, 0xd6c2, 0x2000 },

-  { 0x1901, 0xd6c1, 0x0000 },

-  { 0x0501, 0xd6c3, 0x0000 },

-  { 0x8501, 0xd6cc, 0x4000 },

-  { 0x8501, 0xd6c8, 0x3000 },

-  { 0x8501, 0xd6c6, 0x2000 },

-  { 0x0501, 0xd6c5, 0x0000 },

-  { 0x0501, 0xd6c7, 0x0000 },

-  { 0x8501, 0xd6ca, 0x2000 },

-  { 0x0501, 0xd6c9, 0x0000 },

-  { 0x0501, 0xd6cb, 0x0000 },

-  { 0x8501, 0xd6d0, 0x3000 },

-  { 0x8501, 0xd6ce, 0x2000 },

-  { 0x0501, 0xd6cd, 0x0000 },

-  { 0x0501, 0xd6cf, 0x0000 },

-  { 0x8501, 0xd6d2, 0x2000 },

-  { 0x0501, 0xd6d1, 0x0000 },

-  { 0x0501, 0xd6d3, 0x0000 },

-  { 0x8901, 0xd6e4, 0x5000 },

-  { 0x8501, 0xd6dc, 0x4000 },

-  { 0x8501, 0xd6d8, 0x3000 },

-  { 0x8501, 0xd6d6, 0x2000 },

-  { 0x0501, 0xd6d5, 0x0000 },

-  { 0x0501, 0xd6d7, 0x0000 },

-  { 0x8501, 0xd6da, 0x2000 },

-  { 0x0501, 0xd6d9, 0x0000 },

-  { 0x1901, 0xd6db, 0x0000 },

-  { 0x8501, 0xd6e0, 0x3000 },

-  { 0x8501, 0xd6de, 0x2000 },

-  { 0x0501, 0xd6dd, 0x0000 },

-  { 0x0501, 0xd6df, 0x0000 },

-  { 0x8901, 0xd6e2, 0x2000 },

-  { 0x0501, 0xd6e1, 0x0000 },

-  { 0x0901, 0xd6e3, 0x0000 },

-  { 0x8901, 0xd6ec, 0x4000 },

-  { 0x8901, 0xd6e8, 0x3000 },

-  { 0x8901, 0xd6e6, 0x2000 },

-  { 0x0901, 0xd6e5, 0x0000 },

-  { 0x0901, 0xd6e7, 0x0000 },

-  { 0x8901, 0xd6ea, 0x2000 },

-  { 0x0901, 0xd6e9, 0x0000 },

-  { 0x0901, 0xd6eb, 0x0000 },

-  { 0x8901, 0xd6f0, 0x3000 },

-  { 0x8901, 0xd6ee, 0x2000 },

-  { 0x0901, 0xd6ed, 0x0000 },

-  { 0x0901, 0xd6ef, 0x0000 },

-  { 0x8901, 0xd6f2, 0x2000 },

-  { 0x0901, 0xd6f1, 0x0000 },

-  { 0x0901, 0xd6f3, 0x0000 },

-  { 0x8901, 0xd734, 0x7000 },

-  { 0x8501, 0xd714, 0x6000 },

-  { 0x8501, 0xd704, 0x5000 },

-  { 0x8501, 0xd6fc, 0x4000 },

-  { 0x8901, 0xd6f8, 0x3000 },

-  { 0x8901, 0xd6f6, 0x2000 },

-  { 0x0901, 0xd6f5, 0x0000 },

-  { 0x0901, 0xd6f7, 0x0000 },

-  { 0x8901, 0xd6fa, 0x2000 },

-  { 0x0901, 0xd6f9, 0x0000 },

-  { 0x1901, 0xd6fb, 0x0000 },

-  { 0x8501, 0xd700, 0x3000 },

-  { 0x8501, 0xd6fe, 0x2000 },

-  { 0x0501, 0xd6fd, 0x0000 },

-  { 0x0501, 0xd6ff, 0x0000 },

-  { 0x8501, 0xd702, 0x2000 },

-  { 0x0501, 0xd701, 0x0000 },

-  { 0x0501, 0xd703, 0x0000 },

-  { 0x8501, 0xd70c, 0x4000 },

-  { 0x8501, 0xd708, 0x3000 },

-  { 0x8501, 0xd706, 0x2000 },

-  { 0x0501, 0xd705, 0x0000 },

-  { 0x0501, 0xd707, 0x0000 },

-  { 0x8501, 0xd70a, 0x2000 },

-  { 0x0501, 0xd709, 0x0000 },

-  { 0x0501, 0xd70b, 0x0000 },

-  { 0x8501, 0xd710, 0x3000 },

-  { 0x8501, 0xd70e, 0x2000 },

-  { 0x0501, 0xd70d, 0x0000 },

-  { 0x0501, 0xd70f, 0x0000 },

-  { 0x8501, 0xd712, 0x2000 },

-  { 0x0501, 0xd711, 0x0000 },

-  { 0x0501, 0xd713, 0x0000 },

-  { 0x8901, 0xd724, 0x5000 },

-  { 0x8901, 0xd71c, 0x4000 },

-  { 0x8501, 0xd718, 0x3000 },

-  { 0x8501, 0xd716, 0x2000 },

-  { 0x1901, 0xd715, 0x0000 },

-  { 0x0501, 0xd717, 0x0000 },

-  { 0x8501, 0xd71a, 0x2000 },

-  { 0x0501, 0xd719, 0x0000 },

-  { 0x0501, 0xd71b, 0x0000 },

-  { 0x8901, 0xd720, 0x3000 },

-  { 0x8901, 0xd71e, 0x2000 },

-  { 0x0901, 0xd71d, 0x0000 },

-  { 0x0901, 0xd71f, 0x0000 },

-  { 0x8901, 0xd722, 0x2000 },

-  { 0x0901, 0xd721, 0x0000 },

-  { 0x0901, 0xd723, 0x0000 },

-  { 0x8901, 0xd72c, 0x4000 },

-  { 0x8901, 0xd728, 0x3000 },

-  { 0x8901, 0xd726, 0x2000 },

-  { 0x0901, 0xd725, 0x0000 },

-  { 0x0901, 0xd727, 0x0000 },

-  { 0x8901, 0xd72a, 0x2000 },

-  { 0x0901, 0xd729, 0x0000 },

-  { 0x0901, 0xd72b, 0x0000 },

-  { 0x8901, 0xd730, 0x3000 },

-  { 0x8901, 0xd72e, 0x2000 },

-  { 0x0901, 0xd72d, 0x0000 },

-  { 0x0901, 0xd72f, 0x0000 },

-  { 0x8901, 0xd732, 0x2000 },

-  { 0x0901, 0xd731, 0x0000 },

-  { 0x0901, 0xd733, 0x0000 },

-  { 0x8501, 0xd754, 0x6000 },

-  { 0x8501, 0xd744, 0x5000 },

-  { 0x8501, 0xd73c, 0x4000 },

-  { 0x8501, 0xd738, 0x3000 },

-  { 0x8501, 0xd736, 0x2000 },

-  { 0x1901, 0xd735, 0x0000 },

-  { 0x0501, 0xd737, 0x0000 },

-  { 0x8501, 0xd73a, 0x2000 },

-  { 0x0501, 0xd739, 0x0000 },

-  { 0x0501, 0xd73b, 0x0000 },

-  { 0x8501, 0xd740, 0x3000 },

-  { 0x8501, 0xd73e, 0x2000 },

-  { 0x0501, 0xd73d, 0x0000 },

-  { 0x0501, 0xd73f, 0x0000 },

-  { 0x8501, 0xd742, 0x2000 },

-  { 0x0501, 0xd741, 0x0000 },

-  { 0x0501, 0xd743, 0x0000 },

-  { 0x8501, 0xd74c, 0x4000 },

-  { 0x8501, 0xd748, 0x3000 },

-  { 0x8501, 0xd746, 0x2000 },

-  { 0x0501, 0xd745, 0x0000 },

-  { 0x0501, 0xd747, 0x0000 },

-  { 0x8501, 0xd74a, 0x2000 },

-  { 0x0501, 0xd749, 0x0000 },

-  { 0x0501, 0xd74b, 0x0000 },

-  { 0x8501, 0xd750, 0x3000 },

-  { 0x8501, 0xd74e, 0x2000 },

-  { 0x0501, 0xd74d, 0x0000 },

-  { 0x1901, 0xd74f, 0x0000 },

-  { 0x8501, 0xd752, 0x2000 },

-  { 0x0501, 0xd751, 0x0000 },

-  { 0x0501, 0xd753, 0x0000 },

-  { 0x8901, 0xd764, 0x5000 },

-  { 0x8901, 0xd75c, 0x4000 },

-  { 0x8901, 0xd758, 0x3000 },

-  { 0x8901, 0xd756, 0x2000 },

-  { 0x0501, 0xd755, 0x0000 },

-  { 0x0901, 0xd757, 0x0000 },

-  { 0x8901, 0xd75a, 0x2000 },

-  { 0x0901, 0xd759, 0x0000 },

-  { 0x0901, 0xd75b, 0x0000 },

-  { 0x8901, 0xd760, 0x3000 },

-  { 0x8901, 0xd75e, 0x2000 },

-  { 0x0901, 0xd75d, 0x0000 },

-  { 0x0901, 0xd75f, 0x0000 },

-  { 0x8901, 0xd762, 0x2000 },

-  { 0x0901, 0xd761, 0x0000 },

-  { 0x0901, 0xd763, 0x0000 },

-  { 0x8901, 0xd76c, 0x4000 },

-  { 0x8901, 0xd768, 0x3000 },

-  { 0x8901, 0xd766, 0x2000 },

-  { 0x0901, 0xd765, 0x0000 },

-  { 0x0901, 0xd767, 0x0000 },

-  { 0x8901, 0xd76a, 0x2000 },

-  { 0x0901, 0xd769, 0x0000 },

-  { 0x0901, 0xd76b, 0x0000 },

-  { 0x8501, 0xd770, 0x3000 },

-  { 0x8901, 0xd76e, 0x2000 },

-  { 0x0901, 0xd76d, 0x0000 },

-  { 0x1901, 0xd76f, 0x0000 },

-  { 0x8501, 0xd772, 0x2000 },

-  { 0x0501, 0xd771, 0x0000 },

-  { 0x0501, 0xd773, 0x0000 },

-  { 0x8d01, 0xd7f8, 0x8000 },

-  { 0x8501, 0xd7b4, 0x7000 },

-  { 0x8901, 0xd794, 0x6000 },

-  { 0x8501, 0xd784, 0x5000 },

-  { 0x8501, 0xd77c, 0x4000 },

-  { 0x8501, 0xd778, 0x3000 },

-  { 0x8501, 0xd776, 0x2000 },

-  { 0x0501, 0xd775, 0x0000 },

-  { 0x0501, 0xd777, 0x0000 },

-  { 0x8501, 0xd77a, 0x2000 },

-  { 0x0501, 0xd779, 0x0000 },

-  { 0x0501, 0xd77b, 0x0000 },

-  { 0x8501, 0xd780, 0x3000 },

-  { 0x8501, 0xd77e, 0x2000 },

-  { 0x0501, 0xd77d, 0x0000 },

-  { 0x0501, 0xd77f, 0x0000 },

-  { 0x8501, 0xd782, 0x2000 },

-  { 0x0501, 0xd781, 0x0000 },

-  { 0x0501, 0xd783, 0x0000 },

-  { 0x8501, 0xd78c, 0x4000 },

-  { 0x8501, 0xd788, 0x3000 },

-  { 0x8501, 0xd786, 0x2000 },

-  { 0x0501, 0xd785, 0x0000 },

-  { 0x0501, 0xd787, 0x0000 },

-  { 0x8501, 0xd78a, 0x2000 },

-  { 0x1901, 0xd789, 0x0000 },

-  { 0x0501, 0xd78b, 0x0000 },

-  { 0x8901, 0xd790, 0x3000 },

-  { 0x8501, 0xd78e, 0x2000 },

-  { 0x0501, 0xd78d, 0x0000 },

-  { 0x0501, 0xd78f, 0x0000 },

-  { 0x8901, 0xd792, 0x2000 },

-  { 0x0901, 0xd791, 0x0000 },

-  { 0x0901, 0xd793, 0x0000 },

-  { 0x8901, 0xd7a4, 0x5000 },

-  { 0x8901, 0xd79c, 0x4000 },

-  { 0x8901, 0xd798, 0x3000 },

-  { 0x8901, 0xd796, 0x2000 },

-  { 0x0901, 0xd795, 0x0000 },

-  { 0x0901, 0xd797, 0x0000 },

-  { 0x8901, 0xd79a, 0x2000 },

-  { 0x0901, 0xd799, 0x0000 },

-  { 0x0901, 0xd79b, 0x0000 },

-  { 0x8901, 0xd7a0, 0x3000 },

-  { 0x8901, 0xd79e, 0x2000 },

-  { 0x0901, 0xd79d, 0x0000 },

-  { 0x0901, 0xd79f, 0x0000 },

-  { 0x8901, 0xd7a2, 0x2000 },

-  { 0x0901, 0xd7a1, 0x0000 },

-  { 0x0901, 0xd7a3, 0x0000 },

-  { 0x8501, 0xd7ac, 0x4000 },

-  { 0x8901, 0xd7a8, 0x3000 },

-  { 0x8901, 0xd7a6, 0x2000 },

-  { 0x0901, 0xd7a5, 0x0000 },

-  { 0x0901, 0xd7a7, 0x0000 },

-  { 0x8501, 0xd7aa, 0x2000 },

-  { 0x1901, 0xd7a9, 0x0000 },

-  { 0x0501, 0xd7ab, 0x0000 },

-  { 0x8501, 0xd7b0, 0x3000 },

-  { 0x8501, 0xd7ae, 0x2000 },

-  { 0x0501, 0xd7ad, 0x0000 },

-  { 0x0501, 0xd7af, 0x0000 },

-  { 0x8501, 0xd7b2, 0x2000 },

-  { 0x0501, 0xd7b1, 0x0000 },

-  { 0x0501, 0xd7b3, 0x0000 },

-  { 0x8d01, 0xd7d8, 0x6000 },

-  { 0x8501, 0xd7c4, 0x5000 },

-  { 0x8501, 0xd7bc, 0x4000 },

-  { 0x8501, 0xd7b8, 0x3000 },

-  { 0x8501, 0xd7b6, 0x2000 },

-  { 0x0501, 0xd7b5, 0x0000 },

-  { 0x0501, 0xd7b7, 0x0000 },

-  { 0x8501, 0xd7ba, 0x2000 },

-  { 0x0501, 0xd7b9, 0x0000 },

-  { 0x0501, 0xd7bb, 0x0000 },

-  { 0x8501, 0xd7c0, 0x3000 },

-  { 0x8501, 0xd7be, 0x2000 },

-  { 0x0501, 0xd7bd, 0x0000 },

-  { 0x0501, 0xd7bf, 0x0000 },

-  { 0x8501, 0xd7c2, 0x2000 },

-  { 0x0501, 0xd7c1, 0x0000 },

-  { 0x1901, 0xd7c3, 0x0000 },

-  { 0x8d01, 0xd7d0, 0x4000 },

-  { 0x8501, 0xd7c8, 0x3000 },

-  { 0x8501, 0xd7c6, 0x2000 },

-  { 0x0501, 0xd7c5, 0x0000 },

-  { 0x0501, 0xd7c7, 0x0000 },

-  { 0x8d01, 0xd7ce, 0x2000 },

-  { 0x0501, 0xd7c9, 0x0000 },

-  { 0x0d01, 0xd7cf, 0x0000 },

-  { 0x8d01, 0xd7d4, 0x3000 },

-  { 0x8d01, 0xd7d2, 0x2000 },

-  { 0x0d01, 0xd7d1, 0x0000 },

-  { 0x0d01, 0xd7d3, 0x0000 },

-  { 0x8d01, 0xd7d6, 0x2000 },

-  { 0x0d01, 0xd7d5, 0x0000 },

-  { 0x0d01, 0xd7d7, 0x0000 },

-  { 0x8d01, 0xd7e8, 0x5000 },

-  { 0x8d01, 0xd7e0, 0x4000 },

-  { 0x8d01, 0xd7dc, 0x3000 },

-  { 0x8d01, 0xd7da, 0x2000 },

-  { 0x0d01, 0xd7d9, 0x0000 },

-  { 0x0d01, 0xd7db, 0x0000 },

-  { 0x8d01, 0xd7de, 0x2000 },

-  { 0x0d01, 0xd7dd, 0x0000 },

-  { 0x0d01, 0xd7df, 0x0000 },

-  { 0x8d01, 0xd7e4, 0x3000 },

-  { 0x8d01, 0xd7e2, 0x2000 },

-  { 0x0d01, 0xd7e1, 0x0000 },

-  { 0x0d01, 0xd7e3, 0x0000 },

-  { 0x8d01, 0xd7e6, 0x2000 },

-  { 0x0d01, 0xd7e5, 0x0000 },

-  { 0x0d01, 0xd7e7, 0x0000 },

-  { 0x8d01, 0xd7f0, 0x4000 },

-  { 0x8d01, 0xd7ec, 0x3000 },

-  { 0x8d01, 0xd7ea, 0x2000 },

-  { 0x0d01, 0xd7e9, 0x0000 },

-  { 0x0d01, 0xd7eb, 0x0000 },

-  { 0x8d01, 0xd7ee, 0x2000 },

-  { 0x0d01, 0xd7ed, 0x0000 },

-  { 0x0d01, 0xd7ef, 0x0000 },

-  { 0x8d01, 0xd7f4, 0x3000 },

-  { 0x8d01, 0xd7f2, 0x2000 },

-  { 0x0d01, 0xd7f1, 0x0000 },

-  { 0x0d01, 0xd7f3, 0x0000 },

-  { 0x8d01, 0xd7f6, 0x2000 },

-  { 0x0d01, 0xd7f5, 0x0000 },

-  { 0x0d01, 0xd7f7, 0x0000 },

-  { 0x8702, 0xf836, 0x7000 },

-  { 0x8702, 0xf816, 0x6000 },

-  { 0x8702, 0xf806, 0x5000 },

-  { 0x8702, 0x0000, 0x4000 },

-  { 0x8d01, 0xd7fc, 0x3000 },

-  { 0x8d01, 0xd7fa, 0x2000 },

-  { 0x0d01, 0xd7f9, 0x0000 },

-  { 0x0d01, 0xd7fb, 0x0000 },

-  { 0x8d01, 0xd7fe, 0x2000 },

-  { 0x0d01, 0xd7fd, 0x0000 },

-  { 0x0d01, 0xd7ff, 0x0000 },

-  { 0x8702, 0xf802, 0x3000 },

-  { 0x8702, 0xf800, 0x2000 },

-  { 0x0702, 0xa6d6, 0x0000 },

-  { 0x0702, 0xf801, 0x0000 },

-  { 0x8702, 0xf804, 0x2000 },

-  { 0x0702, 0xf803, 0x0000 },

-  { 0x0702, 0xf805, 0x0000 },

-  { 0x8702, 0xf80e, 0x4000 },

-  { 0x8702, 0xf80a, 0x3000 },

-  { 0x8702, 0xf808, 0x2000 },

-  { 0x0702, 0xf807, 0x0000 },

-  { 0x0702, 0xf809, 0x0000 },

-  { 0x8702, 0xf80c, 0x2000 },

-  { 0x0702, 0xf80b, 0x0000 },

-  { 0x0702, 0xf80d, 0x0000 },

-  { 0x8702, 0xf812, 0x3000 },

-  { 0x8702, 0xf810, 0x2000 },

-  { 0x0702, 0xf80f, 0x0000 },

-  { 0x0702, 0xf811, 0x0000 },

-  { 0x8702, 0xf814, 0x2000 },

-  { 0x0702, 0xf813, 0x0000 },

-  { 0x0702, 0xf815, 0x0000 },

-  { 0x8702, 0xf826, 0x5000 },

-  { 0x8702, 0xf81e, 0x4000 },

-  { 0x8702, 0xf81a, 0x3000 },

-  { 0x8702, 0xf818, 0x2000 },

-  { 0x0702, 0xf817, 0x0000 },

-  { 0x0702, 0xf819, 0x0000 },

-  { 0x8702, 0xf81c, 0x2000 },

-  { 0x0702, 0xf81b, 0x0000 },

-  { 0x0702, 0xf81d, 0x0000 },

-  { 0x8702, 0xf822, 0x3000 },

-  { 0x8702, 0xf820, 0x2000 },

-  { 0x0702, 0xf81f, 0x0000 },

-  { 0x0702, 0xf821, 0x0000 },

-  { 0x8702, 0xf824, 0x2000 },

-  { 0x0702, 0xf823, 0x0000 },

-  { 0x0702, 0xf825, 0x0000 },

-  { 0x8702, 0xf82e, 0x4000 },

-  { 0x8702, 0xf82a, 0x3000 },

-  { 0x8702, 0xf828, 0x2000 },

-  { 0x0702, 0xf827, 0x0000 },

-  { 0x0702, 0xf829, 0x0000 },

-  { 0x8702, 0xf82c, 0x2000 },

-  { 0x0702, 0xf82b, 0x0000 },

-  { 0x0702, 0xf82d, 0x0000 },

-  { 0x8702, 0xf832, 0x3000 },

-  { 0x8702, 0xf830, 0x2000 },

-  { 0x0702, 0xf82f, 0x0000 },

-  { 0x0702, 0xf831, 0x0000 },

-  { 0x8702, 0xf834, 0x2000 },

-  { 0x0702, 0xf833, 0x0000 },

-  { 0x0702, 0xf835, 0x0000 },

-  { 0x8702, 0xf856, 0x6000 },

-  { 0x8702, 0xf846, 0x5000 },

-  { 0x8702, 0xf83e, 0x4000 },

-  { 0x8702, 0xf83a, 0x3000 },

-  { 0x8702, 0xf838, 0x2000 },

-  { 0x0702, 0xf837, 0x0000 },

-  { 0x0702, 0xf839, 0x0000 },

-  { 0x8702, 0xf83c, 0x2000 },

-  { 0x0702, 0xf83b, 0x0000 },

-  { 0x0702, 0xf83d, 0x0000 },

-  { 0x8702, 0xf842, 0x3000 },

-  { 0x8702, 0xf840, 0x2000 },

-  { 0x0702, 0xf83f, 0x0000 },

-  { 0x0702, 0xf841, 0x0000 },

-  { 0x8702, 0xf844, 0x2000 },

-  { 0x0702, 0xf843, 0x0000 },

-  { 0x0702, 0xf845, 0x0000 },

-  { 0x8702, 0xf84e, 0x4000 },

-  { 0x8702, 0xf84a, 0x3000 },

-  { 0x8702, 0xf848, 0x2000 },

-  { 0x0702, 0xf847, 0x0000 },

-  { 0x0702, 0xf849, 0x0000 },

-  { 0x8702, 0xf84c, 0x2000 },

-  { 0x0702, 0xf84b, 0x0000 },

-  { 0x0702, 0xf84d, 0x0000 },

-  { 0x8702, 0xf852, 0x3000 },

-  { 0x8702, 0xf850, 0x2000 },

-  { 0x0702, 0xf84f, 0x0000 },

-  { 0x0702, 0xf851, 0x0000 },

-  { 0x8702, 0xf854, 0x2000 },

-  { 0x0702, 0xf853, 0x0000 },

-  { 0x0702, 0xf855, 0x0000 },

-  { 0x8702, 0xf866, 0x5000 },

-  { 0x8702, 0xf85e, 0x4000 },

-  { 0x8702, 0xf85a, 0x3000 },

-  { 0x8702, 0xf858, 0x2000 },

-  { 0x0702, 0xf857, 0x0000 },

-  { 0x0702, 0xf859, 0x0000 },

-  { 0x8702, 0xf85c, 0x2000 },

-  { 0x0702, 0xf85b, 0x0000 },

-  { 0x0702, 0xf85d, 0x0000 },

-  { 0x8702, 0xf862, 0x3000 },

-  { 0x8702, 0xf860, 0x2000 },

-  { 0x0702, 0xf85f, 0x0000 },

-  { 0x0702, 0xf861, 0x0000 },

-  { 0x8702, 0xf864, 0x2000 },

-  { 0x0702, 0xf863, 0x0000 },

-  { 0x0702, 0xf865, 0x0000 },

-  { 0x8702, 0xf86e, 0x4000 },

-  { 0x8702, 0xf86a, 0x3000 },

-  { 0x8702, 0xf868, 0x2000 },

-  { 0x0702, 0xf867, 0x0000 },

-  { 0x0702, 0xf869, 0x0000 },

-  { 0x8702, 0xf86c, 0x2000 },

-  { 0x0702, 0xf86b, 0x0000 },

-  { 0x0702, 0xf86d, 0x0000 },

-  { 0x8702, 0xf872, 0x3000 },

-  { 0x8702, 0xf870, 0x2000 },

-  { 0x0702, 0xf86f, 0x0000 },

-  { 0x0702, 0xf871, 0x0000 },

-  { 0x8702, 0xf874, 0x2000 },

-  { 0x0702, 0xf873, 0x0000 },

-  { 0x0702, 0xf875, 0x0000 },

-  { 0x8702, 0xf976, 0x9000 },

-  { 0x8702, 0xf8f6, 0x8000 },

-  { 0x8702, 0xf8b6, 0x7000 },

-  { 0x8702, 0xf896, 0x6000 },

-  { 0x8702, 0xf886, 0x5000 },

-  { 0x8702, 0xf87e, 0x4000 },

-  { 0x8702, 0xf87a, 0x3000 },

-  { 0x8702, 0xf878, 0x2000 },

-  { 0x0702, 0xf877, 0x0000 },

-  { 0x0702, 0xf879, 0x0000 },

-  { 0x8702, 0xf87c, 0x2000 },

-  { 0x0702, 0xf87b, 0x0000 },

-  { 0x0702, 0xf87d, 0x0000 },

-  { 0x8702, 0xf882, 0x3000 },

-  { 0x8702, 0xf880, 0x2000 },

-  { 0x0702, 0xf87f, 0x0000 },

-  { 0x0702, 0xf881, 0x0000 },

-  { 0x8702, 0xf884, 0x2000 },

-  { 0x0702, 0xf883, 0x0000 },

-  { 0x0702, 0xf885, 0x0000 },

-  { 0x8702, 0xf88e, 0x4000 },

-  { 0x8702, 0xf88a, 0x3000 },

-  { 0x8702, 0xf888, 0x2000 },

-  { 0x0702, 0xf887, 0x0000 },

-  { 0x0702, 0xf889, 0x0000 },

-  { 0x8702, 0xf88c, 0x2000 },

-  { 0x0702, 0xf88b, 0x0000 },

-  { 0x0702, 0xf88d, 0x0000 },

-  { 0x8702, 0xf892, 0x3000 },

-  { 0x8702, 0xf890, 0x2000 },

-  { 0x0702, 0xf88f, 0x0000 },

-  { 0x0702, 0xf891, 0x0000 },

-  { 0x8702, 0xf894, 0x2000 },

-  { 0x0702, 0xf893, 0x0000 },

-  { 0x0702, 0xf895, 0x0000 },

-  { 0x8702, 0xf8a6, 0x5000 },

-  { 0x8702, 0xf89e, 0x4000 },

-  { 0x8702, 0xf89a, 0x3000 },

-  { 0x8702, 0xf898, 0x2000 },

-  { 0x0702, 0xf897, 0x0000 },

-  { 0x0702, 0xf899, 0x0000 },

-  { 0x8702, 0xf89c, 0x2000 },

-  { 0x0702, 0xf89b, 0x0000 },

-  { 0x0702, 0xf89d, 0x0000 },

-  { 0x8702, 0xf8a2, 0x3000 },

-  { 0x8702, 0xf8a0, 0x2000 },

-  { 0x0702, 0xf89f, 0x0000 },

-  { 0x0702, 0xf8a1, 0x0000 },

-  { 0x8702, 0xf8a4, 0x2000 },

-  { 0x0702, 0xf8a3, 0x0000 },

-  { 0x0702, 0xf8a5, 0x0000 },

-  { 0x8702, 0xf8ae, 0x4000 },

-  { 0x8702, 0xf8aa, 0x3000 },

-  { 0x8702, 0xf8a8, 0x2000 },

-  { 0x0702, 0xf8a7, 0x0000 },

-  { 0x0702, 0xf8a9, 0x0000 },

-  { 0x8702, 0xf8ac, 0x2000 },

-  { 0x0702, 0xf8ab, 0x0000 },

-  { 0x0702, 0xf8ad, 0x0000 },

-  { 0x8702, 0xf8b2, 0x3000 },

-  { 0x8702, 0xf8b0, 0x2000 },

-  { 0x0702, 0xf8af, 0x0000 },

-  { 0x0702, 0xf8b1, 0x0000 },

-  { 0x8702, 0xf8b4, 0x2000 },

-  { 0x0702, 0xf8b3, 0x0000 },

-  { 0x0702, 0xf8b5, 0x0000 },

-  { 0x8702, 0xf8d6, 0x6000 },

-  { 0x8702, 0xf8c6, 0x5000 },

-  { 0x8702, 0xf8be, 0x4000 },

-  { 0x8702, 0xf8ba, 0x3000 },

-  { 0x8702, 0xf8b8, 0x2000 },

-  { 0x0702, 0xf8b7, 0x0000 },

-  { 0x0702, 0xf8b9, 0x0000 },

-  { 0x8702, 0xf8bc, 0x2000 },

-  { 0x0702, 0xf8bb, 0x0000 },

-  { 0x0702, 0xf8bd, 0x0000 },

-  { 0x8702, 0xf8c2, 0x3000 },

-  { 0x8702, 0xf8c0, 0x2000 },

-  { 0x0702, 0xf8bf, 0x0000 },

-  { 0x0702, 0xf8c1, 0x0000 },

-  { 0x8702, 0xf8c4, 0x2000 },

-  { 0x0702, 0xf8c3, 0x0000 },

-  { 0x0702, 0xf8c5, 0x0000 },

-  { 0x8702, 0xf8ce, 0x4000 },

-  { 0x8702, 0xf8ca, 0x3000 },

-  { 0x8702, 0xf8c8, 0x2000 },

-  { 0x0702, 0xf8c7, 0x0000 },

-  { 0x0702, 0xf8c9, 0x0000 },

-  { 0x8702, 0xf8cc, 0x2000 },

-  { 0x0702, 0xf8cb, 0x0000 },

-  { 0x0702, 0xf8cd, 0x0000 },

-  { 0x8702, 0xf8d2, 0x3000 },

-  { 0x8702, 0xf8d0, 0x2000 },

-  { 0x0702, 0xf8cf, 0x0000 },

-  { 0x0702, 0xf8d1, 0x0000 },

-  { 0x8702, 0xf8d4, 0x2000 },

-  { 0x0702, 0xf8d3, 0x0000 },

-  { 0x0702, 0xf8d5, 0x0000 },

-  { 0x8702, 0xf8e6, 0x5000 },

-  { 0x8702, 0xf8de, 0x4000 },

-  { 0x8702, 0xf8da, 0x3000 },

-  { 0x8702, 0xf8d8, 0x2000 },

-  { 0x0702, 0xf8d7, 0x0000 },

-  { 0x0702, 0xf8d9, 0x0000 },

-  { 0x8702, 0xf8dc, 0x2000 },

-  { 0x0702, 0xf8db, 0x0000 },

-  { 0x0702, 0xf8dd, 0x0000 },

-  { 0x8702, 0xf8e2, 0x3000 },

-  { 0x8702, 0xf8e0, 0x2000 },

-  { 0x0702, 0xf8df, 0x0000 },

-  { 0x0702, 0xf8e1, 0x0000 },

-  { 0x8702, 0xf8e4, 0x2000 },

-  { 0x0702, 0xf8e3, 0x0000 },

-  { 0x0702, 0xf8e5, 0x0000 },

-  { 0x8702, 0xf8ee, 0x4000 },

-  { 0x8702, 0xf8ea, 0x3000 },

-  { 0x8702, 0xf8e8, 0x2000 },

-  { 0x0702, 0xf8e7, 0x0000 },

-  { 0x0702, 0xf8e9, 0x0000 },

-  { 0x8702, 0xf8ec, 0x2000 },

-  { 0x0702, 0xf8eb, 0x0000 },

-  { 0x0702, 0xf8ed, 0x0000 },

-  { 0x8702, 0xf8f2, 0x3000 },

-  { 0x8702, 0xf8f0, 0x2000 },

-  { 0x0702, 0xf8ef, 0x0000 },

-  { 0x0702, 0xf8f1, 0x0000 },

-  { 0x8702, 0xf8f4, 0x2000 },

-  { 0x0702, 0xf8f3, 0x0000 },

-  { 0x0702, 0xf8f5, 0x0000 },

-  { 0x8702, 0xf936, 0x7000 },

-  { 0x8702, 0xf916, 0x6000 },

-  { 0x8702, 0xf906, 0x5000 },

-  { 0x8702, 0xf8fe, 0x4000 },

-  { 0x8702, 0xf8fa, 0x3000 },

-  { 0x8702, 0xf8f8, 0x2000 },

-  { 0x0702, 0xf8f7, 0x0000 },

-  { 0x0702, 0xf8f9, 0x0000 },

-  { 0x8702, 0xf8fc, 0x2000 },

-  { 0x0702, 0xf8fb, 0x0000 },

-  { 0x0702, 0xf8fd, 0x0000 },

-  { 0x8702, 0xf902, 0x3000 },

-  { 0x8702, 0xf900, 0x2000 },

-  { 0x0702, 0xf8ff, 0x0000 },

-  { 0x0702, 0xf901, 0x0000 },

-  { 0x8702, 0xf904, 0x2000 },

-  { 0x0702, 0xf903, 0x0000 },

-  { 0x0702, 0xf905, 0x0000 },

-  { 0x8702, 0xf90e, 0x4000 },

-  { 0x8702, 0xf90a, 0x3000 },

-  { 0x8702, 0xf908, 0x2000 },

-  { 0x0702, 0xf907, 0x0000 },

-  { 0x0702, 0xf909, 0x0000 },

-  { 0x8702, 0xf90c, 0x2000 },

-  { 0x0702, 0xf90b, 0x0000 },

-  { 0x0702, 0xf90d, 0x0000 },

-  { 0x8702, 0xf912, 0x3000 },

-  { 0x8702, 0xf910, 0x2000 },

-  { 0x0702, 0xf90f, 0x0000 },

-  { 0x0702, 0xf911, 0x0000 },

-  { 0x8702, 0xf914, 0x2000 },

-  { 0x0702, 0xf913, 0x0000 },

-  { 0x0702, 0xf915, 0x0000 },

-  { 0x8702, 0xf926, 0x5000 },

-  { 0x8702, 0xf91e, 0x4000 },

-  { 0x8702, 0xf91a, 0x3000 },

-  { 0x8702, 0xf918, 0x2000 },

-  { 0x0702, 0xf917, 0x0000 },

-  { 0x0702, 0xf919, 0x0000 },

-  { 0x8702, 0xf91c, 0x2000 },

-  { 0x0702, 0xf91b, 0x0000 },

-  { 0x0702, 0xf91d, 0x0000 },

-  { 0x8702, 0xf922, 0x3000 },

-  { 0x8702, 0xf920, 0x2000 },

-  { 0x0702, 0xf91f, 0x0000 },

-  { 0x0702, 0xf921, 0x0000 },

-  { 0x8702, 0xf924, 0x2000 },

-  { 0x0702, 0xf923, 0x0000 },

-  { 0x0702, 0xf925, 0x0000 },

-  { 0x8702, 0xf92e, 0x4000 },

-  { 0x8702, 0xf92a, 0x3000 },

-  { 0x8702, 0xf928, 0x2000 },

-  { 0x0702, 0xf927, 0x0000 },

-  { 0x0702, 0xf929, 0x0000 },

-  { 0x8702, 0xf92c, 0x2000 },

-  { 0x0702, 0xf92b, 0x0000 },

-  { 0x0702, 0xf92d, 0x0000 },

-  { 0x8702, 0xf932, 0x3000 },

-  { 0x8702, 0xf930, 0x2000 },

-  { 0x0702, 0xf92f, 0x0000 },

-  { 0x0702, 0xf931, 0x0000 },

-  { 0x8702, 0xf934, 0x2000 },

-  { 0x0702, 0xf933, 0x0000 },

-  { 0x0702, 0xf935, 0x0000 },

-  { 0x8702, 0xf956, 0x6000 },

-  { 0x8702, 0xf946, 0x5000 },

-  { 0x8702, 0xf93e, 0x4000 },

-  { 0x8702, 0xf93a, 0x3000 },

-  { 0x8702, 0xf938, 0x2000 },

-  { 0x0702, 0xf937, 0x0000 },

-  { 0x0702, 0xf939, 0x0000 },

-  { 0x8702, 0xf93c, 0x2000 },

-  { 0x0702, 0xf93b, 0x0000 },

-  { 0x0702, 0xf93d, 0x0000 },

-  { 0x8702, 0xf942, 0x3000 },

-  { 0x8702, 0xf940, 0x2000 },

-  { 0x0702, 0xf93f, 0x0000 },

-  { 0x0702, 0xf941, 0x0000 },

-  { 0x8702, 0xf944, 0x2000 },

-  { 0x0702, 0xf943, 0x0000 },

-  { 0x0702, 0xf945, 0x0000 },

-  { 0x8702, 0xf94e, 0x4000 },

-  { 0x8702, 0xf94a, 0x3000 },

-  { 0x8702, 0xf948, 0x2000 },

-  { 0x0702, 0xf947, 0x0000 },

-  { 0x0702, 0xf949, 0x0000 },

-  { 0x8702, 0xf94c, 0x2000 },

-  { 0x0702, 0xf94b, 0x0000 },

-  { 0x0702, 0xf94d, 0x0000 },

-  { 0x8702, 0xf952, 0x3000 },

-  { 0x8702, 0xf950, 0x2000 },

-  { 0x0702, 0xf94f, 0x0000 },

-  { 0x0702, 0xf951, 0x0000 },

-  { 0x8702, 0xf954, 0x2000 },

-  { 0x0702, 0xf953, 0x0000 },

-  { 0x0702, 0xf955, 0x0000 },

-  { 0x8702, 0xf966, 0x5000 },

-  { 0x8702, 0xf95e, 0x4000 },

-  { 0x8702, 0xf95a, 0x3000 },

-  { 0x8702, 0xf958, 0x2000 },

-  { 0x0702, 0xf957, 0x0000 },

-  { 0x0702, 0xf959, 0x0000 },

-  { 0x8702, 0xf95c, 0x2000 },

-  { 0x0702, 0xf95b, 0x0000 },

-  { 0x0702, 0xf95d, 0x0000 },

-  { 0x8702, 0xf962, 0x3000 },

-  { 0x8702, 0xf960, 0x2000 },

-  { 0x0702, 0xf95f, 0x0000 },

-  { 0x0702, 0xf961, 0x0000 },

-  { 0x8702, 0xf964, 0x2000 },

-  { 0x0702, 0xf963, 0x0000 },

-  { 0x0702, 0xf965, 0x0000 },

-  { 0x8702, 0xf96e, 0x4000 },

-  { 0x8702, 0xf96a, 0x3000 },

-  { 0x8702, 0xf968, 0x2000 },

-  { 0x0702, 0xf967, 0x0000 },

-  { 0x0702, 0xf969, 0x0000 },

-  { 0x8702, 0xf96c, 0x2000 },

-  { 0x0702, 0xf96b, 0x0000 },

-  { 0x0702, 0xf96d, 0x0000 },

-  { 0x8702, 0xf972, 0x3000 },

-  { 0x8702, 0xf970, 0x2000 },

-  { 0x0702, 0xf96f, 0x0000 },

-  { 0x0702, 0xf971, 0x0000 },

-  { 0x8702, 0xf974, 0x2000 },

-  { 0x0702, 0xf973, 0x0000 },

-  { 0x0702, 0xf975, 0x0000 },

-  { 0x810e, 0x0077, 0x9000 },

-  { 0x8702, 0xf9f6, 0x8000 },

-  { 0x8702, 0xf9b6, 0x7000 },

-  { 0x8702, 0xf996, 0x6000 },

-  { 0x8702, 0xf986, 0x5000 },

-  { 0x8702, 0xf97e, 0x4000 },

-  { 0x8702, 0xf97a, 0x3000 },

-  { 0x8702, 0xf978, 0x2000 },

-  { 0x0702, 0xf977, 0x0000 },

-  { 0x0702, 0xf979, 0x0000 },

-  { 0x8702, 0xf97c, 0x2000 },

-  { 0x0702, 0xf97b, 0x0000 },

-  { 0x0702, 0xf97d, 0x0000 },

-  { 0x8702, 0xf982, 0x3000 },

-  { 0x8702, 0xf980, 0x2000 },

-  { 0x0702, 0xf97f, 0x0000 },

-  { 0x0702, 0xf981, 0x0000 },

-  { 0x8702, 0xf984, 0x2000 },

-  { 0x0702, 0xf983, 0x0000 },

-  { 0x0702, 0xf985, 0x0000 },

-  { 0x8702, 0xf98e, 0x4000 },

-  { 0x8702, 0xf98a, 0x3000 },

-  { 0x8702, 0xf988, 0x2000 },

-  { 0x0702, 0xf987, 0x0000 },

-  { 0x0702, 0xf989, 0x0000 },

-  { 0x8702, 0xf98c, 0x2000 },

-  { 0x0702, 0xf98b, 0x0000 },

-  { 0x0702, 0xf98d, 0x0000 },

-  { 0x8702, 0xf992, 0x3000 },

-  { 0x8702, 0xf990, 0x2000 },

-  { 0x0702, 0xf98f, 0x0000 },

-  { 0x0702, 0xf991, 0x0000 },

-  { 0x8702, 0xf994, 0x2000 },

-  { 0x0702, 0xf993, 0x0000 },

-  { 0x0702, 0xf995, 0x0000 },

-  { 0x8702, 0xf9a6, 0x5000 },

-  { 0x8702, 0xf99e, 0x4000 },

-  { 0x8702, 0xf99a, 0x3000 },

-  { 0x8702, 0xf998, 0x2000 },

-  { 0x0702, 0xf997, 0x0000 },

-  { 0x0702, 0xf999, 0x0000 },

-  { 0x8702, 0xf99c, 0x2000 },

-  { 0x0702, 0xf99b, 0x0000 },

-  { 0x0702, 0xf99d, 0x0000 },

-  { 0x8702, 0xf9a2, 0x3000 },

-  { 0x8702, 0xf9a0, 0x2000 },

-  { 0x0702, 0xf99f, 0x0000 },

-  { 0x0702, 0xf9a1, 0x0000 },

-  { 0x8702, 0xf9a4, 0x2000 },

-  { 0x0702, 0xf9a3, 0x0000 },

-  { 0x0702, 0xf9a5, 0x0000 },

-  { 0x8702, 0xf9ae, 0x4000 },

-  { 0x8702, 0xf9aa, 0x3000 },

-  { 0x8702, 0xf9a8, 0x2000 },

-  { 0x0702, 0xf9a7, 0x0000 },

-  { 0x0702, 0xf9a9, 0x0000 },

-  { 0x8702, 0xf9ac, 0x2000 },

-  { 0x0702, 0xf9ab, 0x0000 },

-  { 0x0702, 0xf9ad, 0x0000 },

-  { 0x8702, 0xf9b2, 0x3000 },

-  { 0x8702, 0xf9b0, 0x2000 },

-  { 0x0702, 0xf9af, 0x0000 },

-  { 0x0702, 0xf9b1, 0x0000 },

-  { 0x8702, 0xf9b4, 0x2000 },

-  { 0x0702, 0xf9b3, 0x0000 },

-  { 0x0702, 0xf9b5, 0x0000 },

-  { 0x8702, 0xf9d6, 0x6000 },

-  { 0x8702, 0xf9c6, 0x5000 },

-  { 0x8702, 0xf9be, 0x4000 },

-  { 0x8702, 0xf9ba, 0x3000 },

-  { 0x8702, 0xf9b8, 0x2000 },

-  { 0x0702, 0xf9b7, 0x0000 },

-  { 0x0702, 0xf9b9, 0x0000 },

-  { 0x8702, 0xf9bc, 0x2000 },

-  { 0x0702, 0xf9bb, 0x0000 },

-  { 0x0702, 0xf9bd, 0x0000 },

-  { 0x8702, 0xf9c2, 0x3000 },

-  { 0x8702, 0xf9c0, 0x2000 },

-  { 0x0702, 0xf9bf, 0x0000 },

-  { 0x0702, 0xf9c1, 0x0000 },

-  { 0x8702, 0xf9c4, 0x2000 },

-  { 0x0702, 0xf9c3, 0x0000 },

-  { 0x0702, 0xf9c5, 0x0000 },

-  { 0x8702, 0xf9ce, 0x4000 },

-  { 0x8702, 0xf9ca, 0x3000 },

-  { 0x8702, 0xf9c8, 0x2000 },

-  { 0x0702, 0xf9c7, 0x0000 },

-  { 0x0702, 0xf9c9, 0x0000 },

-  { 0x8702, 0xf9cc, 0x2000 },

-  { 0x0702, 0xf9cb, 0x0000 },

-  { 0x0702, 0xf9cd, 0x0000 },

-  { 0x8702, 0xf9d2, 0x3000 },

-  { 0x8702, 0xf9d0, 0x2000 },

-  { 0x0702, 0xf9cf, 0x0000 },

-  { 0x0702, 0xf9d1, 0x0000 },

-  { 0x8702, 0xf9d4, 0x2000 },

-  { 0x0702, 0xf9d3, 0x0000 },

-  { 0x0702, 0xf9d5, 0x0000 },

-  { 0x8702, 0xf9e6, 0x5000 },

-  { 0x8702, 0xf9de, 0x4000 },

-  { 0x8702, 0xf9da, 0x3000 },

-  { 0x8702, 0xf9d8, 0x2000 },

-  { 0x0702, 0xf9d7, 0x0000 },

-  { 0x0702, 0xf9d9, 0x0000 },

-  { 0x8702, 0xf9dc, 0x2000 },

-  { 0x0702, 0xf9db, 0x0000 },

-  { 0x0702, 0xf9dd, 0x0000 },

-  { 0x8702, 0xf9e2, 0x3000 },

-  { 0x8702, 0xf9e0, 0x2000 },

-  { 0x0702, 0xf9df, 0x0000 },

-  { 0x0702, 0xf9e1, 0x0000 },

-  { 0x8702, 0xf9e4, 0x2000 },

-  { 0x0702, 0xf9e3, 0x0000 },

-  { 0x0702, 0xf9e5, 0x0000 },

-  { 0x8702, 0xf9ee, 0x4000 },

-  { 0x8702, 0xf9ea, 0x3000 },

-  { 0x8702, 0xf9e8, 0x2000 },

-  { 0x0702, 0xf9e7, 0x0000 },

-  { 0x0702, 0xf9e9, 0x0000 },

-  { 0x8702, 0xf9ec, 0x2000 },

-  { 0x0702, 0xf9eb, 0x0000 },

-  { 0x0702, 0xf9ed, 0x0000 },

-  { 0x8702, 0xf9f2, 0x3000 },

-  { 0x8702, 0xf9f0, 0x2000 },

-  { 0x0702, 0xf9ef, 0x0000 },

-  { 0x0702, 0xf9f1, 0x0000 },

-  { 0x8702, 0xf9f4, 0x2000 },

-  { 0x0702, 0xf9f3, 0x0000 },

-  { 0x0702, 0xf9f5, 0x0000 },

-  { 0x810e, 0x0037, 0x7000 },

-  { 0x8702, 0xfa16, 0x6000 },

-  { 0x8702, 0xfa06, 0x5000 },

-  { 0x8702, 0xf9fe, 0x4000 },

-  { 0x8702, 0xf9fa, 0x3000 },

-  { 0x8702, 0xf9f8, 0x2000 },

-  { 0x0702, 0xf9f7, 0x0000 },

-  { 0x0702, 0xf9f9, 0x0000 },

-  { 0x8702, 0xf9fc, 0x2000 },

-  { 0x0702, 0xf9fb, 0x0000 },

-  { 0x0702, 0xf9fd, 0x0000 },

-  { 0x8702, 0xfa02, 0x3000 },

-  { 0x8702, 0xfa00, 0x2000 },

-  { 0x0702, 0xf9ff, 0x0000 },

-  { 0x0702, 0xfa01, 0x0000 },

-  { 0x8702, 0xfa04, 0x2000 },

-  { 0x0702, 0xfa03, 0x0000 },

-  { 0x0702, 0xfa05, 0x0000 },

-  { 0x8702, 0xfa0e, 0x4000 },

-  { 0x8702, 0xfa0a, 0x3000 },

-  { 0x8702, 0xfa08, 0x2000 },

-  { 0x0702, 0xfa07, 0x0000 },

-  { 0x0702, 0xfa09, 0x0000 },

-  { 0x8702, 0xfa0c, 0x2000 },

-  { 0x0702, 0xfa0b, 0x0000 },

-  { 0x0702, 0xfa0d, 0x0000 },

-  { 0x8702, 0xfa12, 0x3000 },

-  { 0x8702, 0xfa10, 0x2000 },

-  { 0x0702, 0xfa0f, 0x0000 },

-  { 0x0702, 0xfa11, 0x0000 },

-  { 0x8702, 0xfa14, 0x2000 },

-  { 0x0702, 0xfa13, 0x0000 },

-  { 0x0702, 0xfa15, 0x0000 },

-  { 0x810e, 0x0027, 0x5000 },

-  { 0x810e, 0x0001, 0x4000 },

-  { 0x8702, 0xfa1a, 0x3000 },

-  { 0x8702, 0xfa18, 0x2000 },

-  { 0x0702, 0xfa17, 0x0000 },

-  { 0x0702, 0xfa19, 0x0000 },

-  { 0x8702, 0xfa1c, 0x2000 },

-  { 0x0702, 0xfa1b, 0x0000 },

-  { 0x0702, 0xfa1d, 0x0000 },

-  { 0x810e, 0x0023, 0x3000 },

-  { 0x810e, 0x0021, 0x2000 },

-  { 0x010e, 0x0020, 0x0000 },

-  { 0x010e, 0x0022, 0x0000 },

-  { 0x810e, 0x0025, 0x2000 },

-  { 0x010e, 0x0024, 0x0000 },

-  { 0x010e, 0x0026, 0x0000 },

-  { 0x810e, 0x002f, 0x4000 },

-  { 0x810e, 0x002b, 0x3000 },

-  { 0x810e, 0x0029, 0x2000 },

-  { 0x010e, 0x0028, 0x0000 },

-  { 0x010e, 0x002a, 0x0000 },

-  { 0x810e, 0x002d, 0x2000 },

-  { 0x010e, 0x002c, 0x0000 },

-  { 0x010e, 0x002e, 0x0000 },

-  { 0x810e, 0x0033, 0x3000 },

-  { 0x810e, 0x0031, 0x2000 },

-  { 0x010e, 0x0030, 0x0000 },

-  { 0x010e, 0x0032, 0x0000 },

-  { 0x810e, 0x0035, 0x2000 },

-  { 0x010e, 0x0034, 0x0000 },

-  { 0x010e, 0x0036, 0x0000 },

-  { 0x810e, 0x0057, 0x6000 },

-  { 0x810e, 0x0047, 0x5000 },

-  { 0x810e, 0x003f, 0x4000 },

-  { 0x810e, 0x003b, 0x3000 },

-  { 0x810e, 0x0039, 0x2000 },

-  { 0x010e, 0x0038, 0x0000 },

-  { 0x010e, 0x003a, 0x0000 },

-  { 0x810e, 0x003d, 0x2000 },

-  { 0x010e, 0x003c, 0x0000 },

-  { 0x010e, 0x003e, 0x0000 },

-  { 0x810e, 0x0043, 0x3000 },

-  { 0x810e, 0x0041, 0x2000 },

-  { 0x010e, 0x0040, 0x0000 },

-  { 0x010e, 0x0042, 0x0000 },

-  { 0x810e, 0x0045, 0x2000 },

-  { 0x010e, 0x0044, 0x0000 },

-  { 0x010e, 0x0046, 0x0000 },

-  { 0x810e, 0x004f, 0x4000 },

-  { 0x810e, 0x004b, 0x3000 },

-  { 0x810e, 0x0049, 0x2000 },

-  { 0x010e, 0x0048, 0x0000 },

-  { 0x010e, 0x004a, 0x0000 },

-  { 0x810e, 0x004d, 0x2000 },

-  { 0x010e, 0x004c, 0x0000 },

-  { 0x010e, 0x004e, 0x0000 },

-  { 0x810e, 0x0053, 0x3000 },

-  { 0x810e, 0x0051, 0x2000 },

-  { 0x010e, 0x0050, 0x0000 },

-  { 0x010e, 0x0052, 0x0000 },

-  { 0x810e, 0x0055, 0x2000 },

-  { 0x010e, 0x0054, 0x0000 },

-  { 0x010e, 0x0056, 0x0000 },

-  { 0x810e, 0x0067, 0x5000 },

-  { 0x810e, 0x005f, 0x4000 },

-  { 0x810e, 0x005b, 0x3000 },

-  { 0x810e, 0x0059, 0x2000 },

-  { 0x010e, 0x0058, 0x0000 },

-  { 0x010e, 0x005a, 0x0000 },

-  { 0x810e, 0x005d, 0x2000 },

-  { 0x010e, 0x005c, 0x0000 },

-  { 0x010e, 0x005e, 0x0000 },

-  { 0x810e, 0x0063, 0x3000 },

-  { 0x810e, 0x0061, 0x2000 },

-  { 0x010e, 0x0060, 0x0000 },

-  { 0x010e, 0x0062, 0x0000 },

-  { 0x810e, 0x0065, 0x2000 },

-  { 0x010e, 0x0064, 0x0000 },

-  { 0x010e, 0x0066, 0x0000 },

-  { 0x810e, 0x006f, 0x4000 },

-  { 0x810e, 0x006b, 0x3000 },

-  { 0x810e, 0x0069, 0x2000 },

-  { 0x010e, 0x0068, 0x0000 },

-  { 0x010e, 0x006a, 0x0000 },

-  { 0x810e, 0x006d, 0x2000 },

-  { 0x010e, 0x006c, 0x0000 },

-  { 0x010e, 0x006e, 0x0000 },

-  { 0x810e, 0x0073, 0x3000 },

-  { 0x810e, 0x0071, 0x2000 },

-  { 0x010e, 0x0070, 0x0000 },

-  { 0x010e, 0x0072, 0x0000 },

-  { 0x810e, 0x0075, 0x2000 },

-  { 0x010e, 0x0074, 0x0000 },

-  { 0x010e, 0x0076, 0x0000 },

-  { 0x8c0e, 0x0177, 0x8000 },

-  { 0x8c0e, 0x0137, 0x7000 },

-  { 0x8c0e, 0x0117, 0x6000 },

-  { 0x8c0e, 0x0107, 0x5000 },

-  { 0x810e, 0x007f, 0x4000 },

-  { 0x810e, 0x007b, 0x3000 },

-  { 0x810e, 0x0079, 0x2000 },

-  { 0x010e, 0x0078, 0x0000 },

-  { 0x010e, 0x007a, 0x0000 },

-  { 0x810e, 0x007d, 0x2000 },

-  { 0x010e, 0x007c, 0x0000 },

-  { 0x010e, 0x007e, 0x0000 },

-  { 0x8c0e, 0x0103, 0x3000 },

-  { 0x8c0e, 0x0101, 0x2000 },

-  { 0x0c0e, 0x0100, 0x0000 },

-  { 0x0c0e, 0x0102, 0x0000 },

-  { 0x8c0e, 0x0105, 0x2000 },

-  { 0x0c0e, 0x0104, 0x0000 },

-  { 0x0c0e, 0x0106, 0x0000 },

-  { 0x8c0e, 0x010f, 0x4000 },

-  { 0x8c0e, 0x010b, 0x3000 },

-  { 0x8c0e, 0x0109, 0x2000 },

-  { 0x0c0e, 0x0108, 0x0000 },

-  { 0x0c0e, 0x010a, 0x0000 },

-  { 0x8c0e, 0x010d, 0x2000 },

-  { 0x0c0e, 0x010c, 0x0000 },

-  { 0x0c0e, 0x010e, 0x0000 },

-  { 0x8c0e, 0x0113, 0x3000 },

-  { 0x8c0e, 0x0111, 0x2000 },

-  { 0x0c0e, 0x0110, 0x0000 },

-  { 0x0c0e, 0x0112, 0x0000 },

-  { 0x8c0e, 0x0115, 0x2000 },

-  { 0x0c0e, 0x0114, 0x0000 },

-  { 0x0c0e, 0x0116, 0x0000 },

-  { 0x8c0e, 0x0127, 0x5000 },

-  { 0x8c0e, 0x011f, 0x4000 },

-  { 0x8c0e, 0x011b, 0x3000 },

-  { 0x8c0e, 0x0119, 0x2000 },

-  { 0x0c0e, 0x0118, 0x0000 },

-  { 0x0c0e, 0x011a, 0x0000 },

-  { 0x8c0e, 0x011d, 0x2000 },

-  { 0x0c0e, 0x011c, 0x0000 },

-  { 0x0c0e, 0x011e, 0x0000 },

-  { 0x8c0e, 0x0123, 0x3000 },

-  { 0x8c0e, 0x0121, 0x2000 },

-  { 0x0c0e, 0x0120, 0x0000 },

-  { 0x0c0e, 0x0122, 0x0000 },

-  { 0x8c0e, 0x0125, 0x2000 },

-  { 0x0c0e, 0x0124, 0x0000 },

-  { 0x0c0e, 0x0126, 0x0000 },

-  { 0x8c0e, 0x012f, 0x4000 },

-  { 0x8c0e, 0x012b, 0x3000 },

-  { 0x8c0e, 0x0129, 0x2000 },

-  { 0x0c0e, 0x0128, 0x0000 },

-  { 0x0c0e, 0x012a, 0x0000 },

-  { 0x8c0e, 0x012d, 0x2000 },

-  { 0x0c0e, 0x012c, 0x0000 },

-  { 0x0c0e, 0x012e, 0x0000 },

-  { 0x8c0e, 0x0133, 0x3000 },

-  { 0x8c0e, 0x0131, 0x2000 },

-  { 0x0c0e, 0x0130, 0x0000 },

-  { 0x0c0e, 0x0132, 0x0000 },

-  { 0x8c0e, 0x0135, 0x2000 },

-  { 0x0c0e, 0x0134, 0x0000 },

-  { 0x0c0e, 0x0136, 0x0000 },

-  { 0x8c0e, 0x0157, 0x6000 },

-  { 0x8c0e, 0x0147, 0x5000 },

-  { 0x8c0e, 0x013f, 0x4000 },

-  { 0x8c0e, 0x013b, 0x3000 },

-  { 0x8c0e, 0x0139, 0x2000 },

-  { 0x0c0e, 0x0138, 0x0000 },

-  { 0x0c0e, 0x013a, 0x0000 },

-  { 0x8c0e, 0x013d, 0x2000 },

-  { 0x0c0e, 0x013c, 0x0000 },

-  { 0x0c0e, 0x013e, 0x0000 },

-  { 0x8c0e, 0x0143, 0x3000 },

-  { 0x8c0e, 0x0141, 0x2000 },

-  { 0x0c0e, 0x0140, 0x0000 },

-  { 0x0c0e, 0x0142, 0x0000 },

-  { 0x8c0e, 0x0145, 0x2000 },

-  { 0x0c0e, 0x0144, 0x0000 },

-  { 0x0c0e, 0x0146, 0x0000 },

-  { 0x8c0e, 0x014f, 0x4000 },

-  { 0x8c0e, 0x014b, 0x3000 },

-  { 0x8c0e, 0x0149, 0x2000 },

-  { 0x0c0e, 0x0148, 0x0000 },

-  { 0x0c0e, 0x014a, 0x0000 },

-  { 0x8c0e, 0x014d, 0x2000 },

-  { 0x0c0e, 0x014c, 0x0000 },

-  { 0x0c0e, 0x014e, 0x0000 },

-  { 0x8c0e, 0x0153, 0x3000 },

-  { 0x8c0e, 0x0151, 0x2000 },

-  { 0x0c0e, 0x0150, 0x0000 },

-  { 0x0c0e, 0x0152, 0x0000 },

-  { 0x8c0e, 0x0155, 0x2000 },

-  { 0x0c0e, 0x0154, 0x0000 },

-  { 0x0c0e, 0x0156, 0x0000 },

-  { 0x8c0e, 0x0167, 0x5000 },

-  { 0x8c0e, 0x015f, 0x4000 },

-  { 0x8c0e, 0x015b, 0x3000 },

-  { 0x8c0e, 0x0159, 0x2000 },

-  { 0x0c0e, 0x0158, 0x0000 },

-  { 0x0c0e, 0x015a, 0x0000 },

-  { 0x8c0e, 0x015d, 0x2000 },

-  { 0x0c0e, 0x015c, 0x0000 },

-  { 0x0c0e, 0x015e, 0x0000 },

-  { 0x8c0e, 0x0163, 0x3000 },

-  { 0x8c0e, 0x0161, 0x2000 },

-  { 0x0c0e, 0x0160, 0x0000 },

-  { 0x0c0e, 0x0162, 0x0000 },

-  { 0x8c0e, 0x0165, 0x2000 },

-  { 0x0c0e, 0x0164, 0x0000 },

-  { 0x0c0e, 0x0166, 0x0000 },

-  { 0x8c0e, 0x016f, 0x4000 },

-  { 0x8c0e, 0x016b, 0x3000 },

-  { 0x8c0e, 0x0169, 0x2000 },

-  { 0x0c0e, 0x0168, 0x0000 },

-  { 0x0c0e, 0x016a, 0x0000 },

-  { 0x8c0e, 0x016d, 0x2000 },

-  { 0x0c0e, 0x016c, 0x0000 },

-  { 0x0c0e, 0x016e, 0x0000 },

-  { 0x8c0e, 0x0173, 0x3000 },

-  { 0x8c0e, 0x0171, 0x2000 },

-  { 0x0c0e, 0x0170, 0x0000 },

-  { 0x0c0e, 0x0172, 0x0000 },

-  { 0x8c0e, 0x0175, 0x2000 },

-  { 0x0c0e, 0x0174, 0x0000 },

-  { 0x0c0e, 0x0176, 0x0000 },

-  { 0x8c0e, 0x01b7, 0x7000 },

-  { 0x8c0e, 0x0197, 0x6000 },

-  { 0x8c0e, 0x0187, 0x5000 },

-  { 0x8c0e, 0x017f, 0x4000 },

-  { 0x8c0e, 0x017b, 0x3000 },

-  { 0x8c0e, 0x0179, 0x2000 },

-  { 0x0c0e, 0x0178, 0x0000 },

-  { 0x0c0e, 0x017a, 0x0000 },

-  { 0x8c0e, 0x017d, 0x2000 },

-  { 0x0c0e, 0x017c, 0x0000 },

-  { 0x0c0e, 0x017e, 0x0000 },

-  { 0x8c0e, 0x0183, 0x3000 },

-  { 0x8c0e, 0x0181, 0x2000 },

-  { 0x0c0e, 0x0180, 0x0000 },

-  { 0x0c0e, 0x0182, 0x0000 },

-  { 0x8c0e, 0x0185, 0x2000 },

-  { 0x0c0e, 0x0184, 0x0000 },

-  { 0x0c0e, 0x0186, 0x0000 },

-  { 0x8c0e, 0x018f, 0x4000 },

-  { 0x8c0e, 0x018b, 0x3000 },

-  { 0x8c0e, 0x0189, 0x2000 },

-  { 0x0c0e, 0x0188, 0x0000 },

-  { 0x0c0e, 0x018a, 0x0000 },

-  { 0x8c0e, 0x018d, 0x2000 },

-  { 0x0c0e, 0x018c, 0x0000 },

-  { 0x0c0e, 0x018e, 0x0000 },

-  { 0x8c0e, 0x0193, 0x3000 },

-  { 0x8c0e, 0x0191, 0x2000 },

-  { 0x0c0e, 0x0190, 0x0000 },

-  { 0x0c0e, 0x0192, 0x0000 },

-  { 0x8c0e, 0x0195, 0x2000 },

-  { 0x0c0e, 0x0194, 0x0000 },

-  { 0x0c0e, 0x0196, 0x0000 },

-  { 0x8c0e, 0x01a7, 0x5000 },

-  { 0x8c0e, 0x019f, 0x4000 },

-  { 0x8c0e, 0x019b, 0x3000 },

-  { 0x8c0e, 0x0199, 0x2000 },

-  { 0x0c0e, 0x0198, 0x0000 },

-  { 0x0c0e, 0x019a, 0x0000 },

-  { 0x8c0e, 0x019d, 0x2000 },

-  { 0x0c0e, 0x019c, 0x0000 },

-  { 0x0c0e, 0x019e, 0x0000 },

-  { 0x8c0e, 0x01a3, 0x3000 },

-  { 0x8c0e, 0x01a1, 0x2000 },

-  { 0x0c0e, 0x01a0, 0x0000 },

-  { 0x0c0e, 0x01a2, 0x0000 },

-  { 0x8c0e, 0x01a5, 0x2000 },

-  { 0x0c0e, 0x01a4, 0x0000 },

-  { 0x0c0e, 0x01a6, 0x0000 },

-  { 0x8c0e, 0x01af, 0x4000 },

-  { 0x8c0e, 0x01ab, 0x3000 },

-  { 0x8c0e, 0x01a9, 0x2000 },

-  { 0x0c0e, 0x01a8, 0x0000 },

-  { 0x0c0e, 0x01aa, 0x0000 },

-  { 0x8c0e, 0x01ad, 0x2000 },

-  { 0x0c0e, 0x01ac, 0x0000 },

-  { 0x0c0e, 0x01ae, 0x0000 },

-  { 0x8c0e, 0x01b3, 0x3000 },

-  { 0x8c0e, 0x01b1, 0x2000 },

-  { 0x0c0e, 0x01b0, 0x0000 },

-  { 0x0c0e, 0x01b2, 0x0000 },

-  { 0x8c0e, 0x01b5, 0x2000 },

-  { 0x0c0e, 0x01b4, 0x0000 },

-  { 0x0c0e, 0x01b6, 0x0000 },

-  { 0x8c0e, 0x01d7, 0x6000 },

-  { 0x8c0e, 0x01c7, 0x5000 },

-  { 0x8c0e, 0x01bf, 0x4000 },

-  { 0x8c0e, 0x01bb, 0x3000 },

-  { 0x8c0e, 0x01b9, 0x2000 },

-  { 0x0c0e, 0x01b8, 0x0000 },

-  { 0x0c0e, 0x01ba, 0x0000 },

-  { 0x8c0e, 0x01bd, 0x2000 },

-  { 0x0c0e, 0x01bc, 0x0000 },

-  { 0x0c0e, 0x01be, 0x0000 },

-  { 0x8c0e, 0x01c3, 0x3000 },

-  { 0x8c0e, 0x01c1, 0x2000 },

-  { 0x0c0e, 0x01c0, 0x0000 },

-  { 0x0c0e, 0x01c2, 0x0000 },

-  { 0x8c0e, 0x01c5, 0x2000 },

-  { 0x0c0e, 0x01c4, 0x0000 },

-  { 0x0c0e, 0x01c6, 0x0000 },

-  { 0x8c0e, 0x01cf, 0x4000 },

-  { 0x8c0e, 0x01cb, 0x3000 },

-  { 0x8c0e, 0x01c9, 0x2000 },

-  { 0x0c0e, 0x01c8, 0x0000 },

-  { 0x0c0e, 0x01ca, 0x0000 },

-  { 0x8c0e, 0x01cd, 0x2000 },

-  { 0x0c0e, 0x01cc, 0x0000 },

-  { 0x0c0e, 0x01ce, 0x0000 },

-  { 0x8c0e, 0x01d3, 0x3000 },

-  { 0x8c0e, 0x01d1, 0x2000 },

-  { 0x0c0e, 0x01d0, 0x0000 },

-  { 0x0c0e, 0x01d2, 0x0000 },

-  { 0x8c0e, 0x01d5, 0x2000 },

-  { 0x0c0e, 0x01d4, 0x0000 },

-  { 0x0c0e, 0x01d6, 0x0000 },

-  { 0x8c0e, 0x01e7, 0x5000 },

-  { 0x8c0e, 0x01df, 0x4000 },

-  { 0x8c0e, 0x01db, 0x3000 },

-  { 0x8c0e, 0x01d9, 0x2000 },

-  { 0x0c0e, 0x01d8, 0x0000 },

-  { 0x0c0e, 0x01da, 0x0000 },

-  { 0x8c0e, 0x01dd, 0x2000 },

-  { 0x0c0e, 0x01dc, 0x0000 },

-  { 0x0c0e, 0x01de, 0x0000 },

-  { 0x8c0e, 0x01e3, 0x3000 },

-  { 0x8c0e, 0x01e1, 0x2000 },

-  { 0x0c0e, 0x01e0, 0x0000 },

-  { 0x0c0e, 0x01e2, 0x0000 },

-  { 0x8c0e, 0x01e5, 0x2000 },

-  { 0x0c0e, 0x01e4, 0x0000 },

-  { 0x0c0e, 0x01e6, 0x0000 },

-  { 0x8c0e, 0x01ef, 0x4000 },

-  { 0x8c0e, 0x01eb, 0x3000 },

-  { 0x8c0e, 0x01e9, 0x2000 },

-  { 0x0c0e, 0x01e8, 0x0000 },

-  { 0x0c0e, 0x01ea, 0x0000 },

-  { 0x8c0e, 0x01ed, 0x2000 },

-  { 0x0c0e, 0x01ec, 0x0000 },

-  { 0x0c0e, 0x01ee, 0x0000 },

-  { 0x830f, 0xfffd, 0x2000 },

-  { 0x030f, 0x0000, 0x0000 },

-  { 0x0310, 0x0000, 0x1000 },

-  { 0x0310, 0xfffd, 0x0000 },

-};

-

-

-/* In some environments, external functions have to be preceded by some magic.

-In my world (Unix), they do not. Use a macro to deal with this. */

-

-#ifndef EXPORT

-#define EXPORT

-#endif

-

-

-

-/*************************************************

-*         Search table and return data           *

-*************************************************/

-

-/* Two values are returned: the category is ucp_C, ucp_L, etc. The detailed

-character type is ucp_Lu, ucp_Nd, etc.

-

-Arguments:

-  c           the character value

-  type_ptr    the detailed character type is returned here

-  case_ptr    for letters, the opposite case is returned here, if there

-                is one, else zero

-

-Returns:      the character type category or -1 if not found

-*/

-

-EXPORT int

-ucp_findchar(const int c, int *type_ptr, int *case_ptr)

-{

-cnode *node = ucp_table;

-register int cc = c;

-int case_offset;

-

-for (;;)

-  {

-  register int d = node->f1 | ((node->f0 & f0_chhmask) << 16);

-  if (cc == d) break;

-  if (cc < d)

-    {

-    if ((node->f0 & f0_leftexists) == 0) return -1;

-    node ++;

-    }

-  else

-    {

-    register int roffset = (node->f2 & f2_rightmask) >> f2_rightshift;

-    if (roffset == 0) return -1;

-    node += 1 << (roffset - 1);

-    }

-  }

-

-switch ((*type_ptr = ((node->f0 & f0_typemask) >> f0_typeshift)))

-  {

-  case ucp_Cc:

-  case ucp_Cf:

-  case ucp_Cn:

-  case ucp_Co:

-  case ucp_Cs:

-  return ucp_C;

-  break;

-

-  case ucp_Ll:

-  case ucp_Lu:

-  case_offset = node->f2 & f2_casemask;

-  if ((case_offset & 0x0100) != 0) case_offset |= 0xfffff000;

-  *case_ptr = (case_offset == 0)? 0 : cc + case_offset;

-  return ucp_L;

-

-  case ucp_Lm:

-  case ucp_Lo:

-  case ucp_Lt:

-  *case_ptr = 0;

-  return ucp_L;

-  break;

-

-  case ucp_Mc:

-  case ucp_Me:

-  case ucp_Mn:

-  return ucp_M;

-  break;

-

-  case ucp_Nd:

-  case ucp_Nl:

-  case ucp_No:

-  return ucp_N;

-  break;

-

-  case ucp_Pc:

-  case ucp_Pd:

-  case ucp_Pe:

-  case ucp_Pf:

-  case ucp_Pi:

-  case ucp_Ps:

-  case ucp_Po:

-  return ucp_P;

-  break;

-

-  case ucp_Sc:

-  case ucp_Sk:

-  case ucp_Sm:

-  case ucp_So:

-  return ucp_S;

-  break;

-

-  case ucp_Zl:

-  case ucp_Zp:

-  case ucp_Zs:

-  return ucp_Z;

-  break;

-

-  default:         /* "Should never happen" */

-  return -1;

-  break;

-  }

-}

-

-/* End of ucp_findchar.c */

-

-

-/* End of pcre_ucp_findchar.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function for validating UTF-8 character

-strings. */

-

-

-

-

-/*************************************************

-*         Validate a UTF-8 string                *

-*************************************************/

-

-/* This function is called (optionally) at the start of compile or match, to

-validate that a supposed UTF-8 string is actually valid. The early check means

-that subsequent code can assume it is dealing with a valid string. The check

-can be turned off for maximum performance, but the consequences of supplying

-an invalid string are then undefined.

-

-Arguments:

-  string       points to the string

-  length       length of string, or -1 if the string is zero-terminated

-

-Returns:       < 0    if the string is a valid UTF-8 string

-               >= 0   otherwise; the value is the offset of the bad byte

-*/

-

-EXPORT int

-_pcre_valid_utf8(const uschar *string, int length)

-{

-register const uschar *p;

-

-if (length < 0)

-  {

-  for (p = string; *p != 0; p++);

-  length = p - string;

-  }

-

-for (p = string; length-- > 0; p++)

-  {

-  register int ab;

-  register int c = *p;

-  if (c < 128) continue;

-  if ((c & 0xc0) != 0xc0) return p - string;

-  ab = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */

-  if (length < ab) return p - string;

-  length -= ab;

-

-  /* Check top bits in the second byte */

-  if ((*(++p) & 0xc0) != 0x80) return p - string;

-

-  /* Check for overlong sequences for each different length */

-  switch (ab)

-    {

-    /* Check for xx00 000x */

-    case 1:

-    if ((c & 0x3e) == 0) return p - string;

-    continue;   /* We know there aren't any more bytes to check */

-

-    /* Check for 1110 0000, xx0x xxxx */

-    case 2:

-    if (c == 0xe0 && (*p & 0x20) == 0) return p - string;

-    break;

-

-    /* Check for 1111 0000, xx00 xxxx */

-    case 3:

-    if (c == 0xf0 && (*p & 0x30) == 0) return p - string;

-    break;

-

-    /* Check for 1111 1000, xx00 0xxx */

-    case 4:

-    if (c == 0xf8 && (*p & 0x38) == 0) return p - string;

-    break;

-

-    /* Check for leading 0xfe or 0xff, and then for 1111 1100, xx00 00xx */

-    case 5:

-    if (c == 0xfe || c == 0xff ||

-       (c == 0xfc && (*p & 0x3c) == 0)) return p - string;

-    break;

-    }

-

-  /* Check for valid bytes after the 2nd, if any; all must start 10 */

-  while (--ab > 0)

-    {

-    if ((*(++p) & 0xc0) != 0x80) return p - string;

-    }

-  }

-

-return -1;

-}

-

-/* End of pcre_valid_utf8.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains the external function pcre_version(), which returns a

-string that identifies the PCRE version that is in use. */

-

-

-

-

-/*************************************************

-*          Return version string                 *

-*************************************************/

-

-#define STRING(a)  # a

-#define XSTRING(s) STRING(s)

-

-EXPORT const char *

-pcre_version(void)

-{

-return XSTRING(PCRE_MAJOR) "." XSTRING(PCRE_MINOR) " " XSTRING(PCRE_DATE);

-}

-

-/* End of pcre_version.c */

-/*************************************************

-*      Perl-Compatible Regular Expressions       *

-*************************************************/

-

-/* PCRE is a library of functions to support regular expressions whose syntax

-and semantics are as close as possible to those of the Perl 5 language.

-

-                       Written by Philip Hazel

-           Copyright (c) 1997-2005 University of Cambridge

-

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

-Redistribution and use in source and binary forms, with or without

-modification, are permitted provided that the following conditions are met:

-

-    * Redistributions of source code must retain the above copyright notice,

-      this list of conditions and the following disclaimer.

-

-    * Redistributions in binary form must reproduce the above copyright

-      notice, this list of conditions and the following disclaimer in the

-      documentation and/or other materials provided with the distribution.

-

-    * Neither the name of the University of Cambridge nor the names of its

-      contributors may be used to endorse or promote products derived from

-      this software without specific prior written permission.

-

-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

-POSSIBILITY OF SUCH DAMAGE.

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

-*/

-

-

-/* This module contains an internal function that is used to match an extended

-class (one that contains characters whose values are > 255). It is used by both

-pcre_exec() and pcre_def_exec(). */

-

-

-

-

-/*************************************************

-*       Match character against an XCLASS        *

-*************************************************/

-

-/* This function is called to match a character against an extended class that

-might contain values > 255.

-

-Arguments:

-  c           the character

-  data        points to the flag byte of the XCLASS data

-

-Returns:      TRUE if character matches, else FALSE

-*/

-

-EXPORT BOOL

-_pcre_xclass(int c, const uschar *data)

-{

-int t;

-BOOL negated = (*data & XCL_NOT) != 0;

-

-/* Character values < 256 are matched against a bitmap, if one is present. If

-not, we still carry on, because there may be ranges that start below 256 in the

-additional data. */

-

-if (c < 256)

-  {

-  if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)

-    return !negated;   /* char found */

-  }

-

-/* First skip the bit map if present. Then match against the list of Unicode

-properties or large chars or ranges that end with a large char. We won't ever

-encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */

-

-if ((*data++ & XCL_MAP) != 0) data += 32;

-

-while ((t = *data++) != XCL_END)

-  {

-  int x, y;

-  if (t == XCL_SINGLE)

-    {

-    GETCHARINC(x, data);

-    if (c == x) return !negated;

-    }

-  else if (t == XCL_RANGE)

-    {

-    GETCHARINC(x, data);

-    GETCHARINC(y, data);

-    if (c >= x && c <= y) return !negated;

-    }

-

-#ifdef SUPPORT_UCP

-  else  /* XCL_PROP & XCL_NOTPROP */

-    {

-    int chartype, othercase;

-    int rqdtype = *data++;

-    int category = ucp_findchar(c, &chartype, &othercase);

-    if (rqdtype >= 128)

-      {

-      if ((rqdtype - 128 == category) == (t == XCL_PROP)) return !negated;

-      }

-    else

-      {

-      if ((rqdtype == chartype) == (t == XCL_PROP)) return !negated;

-      }

-    }

-#endif  /* SUPPORT_UCP */

-  }

-

-return negated;   /* char did not match */

-}

-

-/* End of pcre_xclass.c */

diff --git a/lib/wrappers/postgres.nim b/lib/wrappers/postgres.nim
deleted file mode 100755
index d99e5651c..000000000
--- a/lib/wrappers/postgres.nim
+++ /dev/null
@@ -1,350 +0,0 @@
-# This module contains the definitions for structures and externs for
-# functions used by frontend postgres applications. It is based on
-# Postgresql's libpq-fe.h.
-#
-# It is for postgreSQL version 7.4 and higher with support for the v3.0
-# connection-protocol.
-#
-
-{.deadCodeElim: on.}
-
-when defined(windows): 
-  const 
-    dllName = "libpq.dll"
-elif defined(macosx): 
-  const 
-    dllName = "libpq.dylib"
-else: 
-  const 
-    dllName = "libpq.so(.5|)"
-type 
-  POid* = ptr Oid
-  Oid* = int32
-
-const 
-  ERROR_MSG_LENGTH* = 4096
-  CMDSTATUS_LEN* = 40
-
-type 
-  TSockAddr* = array[1..112, int8]
-  TPGresAttDesc*{.pure, final.} = object 
-    name*: cstring
-    adtid*: Oid
-    adtsize*: int
-
-  PPGresAttDesc* = ptr TPGresAttDesc
-  PPPGresAttDesc* = ptr PPGresAttDesc
-  TPGresAttValue*{.pure, final.} = object 
-    length*: int32
-    value*: cstring
-
-  PPGresAttValue* = ptr TPGresAttValue
-  PPPGresAttValue* = ptr PPGresAttValue
-  PExecStatusType* = ptr TExecStatusType
-  TExecStatusType* = enum 
-    PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, 
-    PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR
-  TPGlobjfuncs*{.pure, final.} = object 
-    fn_lo_open*: Oid
-    fn_lo_close*: Oid
-    fn_lo_creat*: Oid
-    fn_lo_unlink*: Oid
-    fn_lo_lseek*: Oid
-    fn_lo_tell*: Oid
-    fn_lo_read*: Oid
-    fn_lo_write*: Oid
-
-  PPGlobjfuncs* = ptr TPGlobjfuncs
-  PConnStatusType* = ptr TConnStatusType
-  TConnStatusType* = enum 
-    CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, 
-    CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, 
-    CONNECTION_SSL_STARTUP, CONNECTION_NEEDED
-  TPGconn*{.pure, final.} = object 
-    pghost*: cstring
-    pgtty*: cstring
-    pgport*: cstring
-    pgoptions*: cstring
-    dbName*: cstring
-    status*: TConnStatusType
-    errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char]
-    Pfin*: TFile
-    Pfout*: TFile
-    Pfdebug*: TFile
-    sock*: int32
-    laddr*: TSockAddr
-    raddr*: TSockAddr
-    salt*: array[0..(2) - 1, char]
-    asyncNotifyWaiting*: int32
-    notifyList*: pointer
-    pguser*: cstring
-    pgpass*: cstring
-    lobjfuncs*: PPGlobjfuncs
-
-  PPGconn* = ptr TPGconn
-  TPGresult*{.pure, final.} = object 
-    ntups*: int32
-    numAttributes*: int32
-    attDescs*: PPGresAttDesc
-    tuples*: PPPGresAttValue
-    tupArrSize*: int32
-    resultStatus*: TExecStatusType
-    cmdStatus*: array[0..(CMDSTATUS_LEN) - 1, char]
-    binary*: int32
-    conn*: PPGconn
-
-  PPGresult* = ptr TPGresult
-  PPostgresPollingStatusType* = ptr PostgresPollingStatusType
-  PostgresPollingStatusType* = enum 
-    PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING, 
-    PGRES_POLLING_OK, PGRES_POLLING_ACTIVE
-  PPGTransactionStatusType* = ptr PGTransactionStatusType
-  PGTransactionStatusType* = enum 
-    PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR, 
-    PQTRANS_UNKNOWN
-  PPGVerbosity* = ptr PGVerbosity
-  PGVerbosity* = enum 
-    PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE
-  PpgNotify* = ptr pgNotify
-  pgNotify*{.pure, final.} = object 
-    relname*: cstring
-    be_pid*: int32
-    extra*: cstring
-
-  PQnoticeReceiver* = proc (arg: pointer, res: PPGresult){.cdecl.}
-  PQnoticeProcessor* = proc (arg: pointer, message: cstring){.cdecl.}
-  Ppqbool* = ptr pqbool
-  pqbool* = char
-  P_PQprintOpt* = ptr PQprintOpt
-  PQprintOpt*{.pure, final.} = object 
-    header*: pqbool
-    align*: pqbool
-    standard*: pqbool
-    html3*: pqbool
-    expanded*: pqbool
-    pager*: pqbool
-    fieldSep*: cstring
-    tableOpt*: cstring
-    caption*: cstring
-    fieldName*: ptr cstring
-
-  P_PQconninfoOption* = ptr PQconninfoOption
-  PQconninfoOption*{.pure, final.} = object 
-    keyword*: cstring
-    envvar*: cstring
-    compiled*: cstring
-    val*: cstring
-    label*: cstring
-    dispchar*: cstring
-    dispsize*: int32
-
-  PPQArgBlock* = ptr PQArgBlock
-  PQArgBlock*{.pure, final.} = object 
-    length*: int32
-    isint*: int32
-    p*: pointer
-
-
-proc PQconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
-    importc: "PQconnectStart".}
-proc PQconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQconnectPoll".}
-proc PQconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, 
-    importc: "PQconnectdb".}
-proc PQsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring, 
-                   pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
-    cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
-proc PQsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn
-proc PQfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
-proc PQconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName, 
-    importc: "PQconndefaults".}
-proc PQconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName, 
-    importc: "PQconninfoFree".}
-proc PQresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQresetStart".}
-proc PQresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQresetPoll".}
-proc PQreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
-proc PQrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQrequestCancel".}
-proc PQdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
-proc PQuser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
-proc PQpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
-proc PQhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
-proc PQport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
-proc PQtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
-proc PQoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQoptions".}
-proc PQstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName, 
-    importc: "PQstatus".}
-proc PQtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl, 
-    dynlib: dllName, importc: "PQtransactionStatus".}
-proc PQparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQparameterStatus".}
-proc PQprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQprotocolVersion".}
-proc PQerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQerrorMessage".}
-proc PQsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                      importc: "PQsocket".}
-proc PQbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQbackendPID".}
-proc PQclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQclientEncoding".}
-proc PQsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQsetClientEncoding".}
-when defined(USE_SSL): 
-  # Get the SSL structure associated with a connection  
-  proc PQgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName, 
-                                       importc: "PQgetssl".}
-proc PQsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
-    cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
-proc PQtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName, 
-    importc: "PQtrace".}
-proc PQuntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
-proc PQsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
-    cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
-proc PQsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor, 
-                           arg: pointer): PQnoticeProcessor{.cdecl, 
-    dynlib: dllName, importc: "PQsetNoticeProcessor".}
-proc PQexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName, 
-    importc: "PQexec".}
-proc PQexecParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                   paramTypes: POid, paramValues: cstringArray, 
-                   paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
-    cdecl, dynlib: dllName, importc: "PQexecParams".}
-proc PQexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32, 
-                     paramValues: cstringArray, 
-                     paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
-    cdecl, dynlib: dllName, importc: "PQexecPrepared".}
-proc PQsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName, 
-    importc: "PQsendQuery".}
-proc PQsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32, 
-                        paramTypes: POid, paramValues: cstringArray, 
-                        paramLengths, paramFormats: ptr int32, 
-                        resultFormat: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQsendQueryParams".}
-proc PQsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32, 
-                          paramValues: cstringArray, 
-                          paramLengths, paramFormats: ptr int32, 
-                          resultFormat: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQsendQueryPrepared".}
-proc PQgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName, 
-    importc: "PQgetResult".}
-proc PQisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                      importc: "PQisBusy".}
-proc PQconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQconsumeInput".}
-proc PQnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName, 
-    importc: "PQnotifies".}
-proc PQputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQputCopyData".}
-proc PQputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQputCopyEnd".}
-proc PQgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetCopyData".}
-proc PQgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQgetline".}
-proc PQputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName, 
-    importc: "PQputline".}
-proc PQgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
-proc PQputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQputnbytes".}
-proc PQendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-                                       importc: "PQendcopy".}
-proc PQsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQsetnonblocking".}
-proc PQisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName, 
-    importc: "PQisnonblocking".}
-proc PQflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
-proc PQfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32, 
-           result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
-    cdecl, dynlib: dllName, importc: "PQfn".}
-proc PQresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName, 
-    importc: "PQresultStatus".}
-proc PQresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQresStatus".}
-proc PQresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQresultErrorMessage".}
-proc PQresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQresultErrorField".}
-proc PQntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-                                        importc: "PQntuples".}
-proc PQnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-                                        importc: "PQnfields".}
-proc PQbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName, 
-    importc: "PQbinaryTuples".}
-proc PQfname*(res: PPGresult, field_num: int32): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQfname".}
-proc PQfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "PQfnumber".}
-proc PQftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "PQftable".}
-proc PQftablecol*(res: PPGresult, field_num: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQftablecol".}
-proc PQfformat*(res: PPGresult, field_num: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "PQfformat".}
-proc PQftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "PQftype".}
-proc PQfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQfsize".}
-proc PQfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQfmod".}
-proc PQcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQcmdStatus".}
-proc PQoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQoidStatus".}
-proc PQoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName, 
-                                       importc: "PQoidValue".}
-proc PQcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName, 
-    importc: "PQcmdTuples".}
-proc PQgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
-    cdecl, dynlib: dllName, importc: "PQgetvalue".}
-proc PQgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetlength".}
-proc PQgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
-    cdecl, dynlib: dllName, importc: "PQgetisnull".}
-proc PQclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
-proc PQfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
-proc PQmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
-    cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
-proc PQescapeString*(till, `from`: cstring, len: int): int{.cdecl, 
-    dynlib: dllName, importc: "PQescapeString".}
-proc PQescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
-    cdecl, dynlib: dllName, importc: "PQescapeBytea".}
-proc PQunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl, 
-    dynlib: dllName, importc: "PQunescapeBytea".}
-proc PQprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl, 
-    dynlib: dllName, importc: "PQprint".}
-proc PQdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32, 
-                      fieldSep: cstring, printHeader: int32, quiet: int32){.
-    cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
-proc PQprintTuples*(res: PPGresult, fout: TFile, printAttName: int32, 
-                    terseOutput: int32, width: int32){.cdecl, dynlib: dllName, 
-    importc: "PQprintTuples".}
-proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl, 
-    dynlib: dllName, importc: "lo_open".}
-proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_close".}
-proc lo_read*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
-    cdecl, dynlib: dllName, importc: "lo_read".}
-proc lo_write*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
-    cdecl, dynlib: dllName, importc: "lo_write".}
-proc lo_lseek*(conn: PPGconn, fd: int32, offset: int32, whence: int32): int32{.
-    cdecl, dynlib: dllName, importc: "lo_lseek".}
-proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName, 
-    importc: "lo_creat".}
-proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_tell".}
-proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName, 
-    importc: "lo_unlink".}
-proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName, 
-    importc: "lo_import".}
-proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl, 
-    dynlib: dllName, importc: "lo_export".}
-proc PQmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName, 
-    importc: "PQmblen".}
-proc PQenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
-proc PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn = 
-  result = PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
diff --git a/lib/wrappers/python.nim b/lib/wrappers/python.nim
deleted file mode 100755
index ea9ef1fd5..000000000
--- a/lib/wrappers/python.nim
+++ /dev/null
@@ -1,1583 +0,0 @@
-#
-#    Light-weight binding for the Python interpreter
-#       (c) 2010 Andreas Rumpf 
-#    Based on 'PythonEngine' module by Dr. Dietmar Budelsky
-#
-#
-#************************************************************************
-#                                                                        
-# Module:  Unit 'PythonEngine'     Copyright (c) 1997                    
-#                                                                        
-# Version: 3.0                     Dr. Dietmar Budelsky                  
-# Sub-Version: 0.25                dbudelsky@web.de                      
-#                                  Germany                               
-#                                                                        
-#                                  Morgan Martinet                       
-#                                  4721 rue Brebeuf                      
-#                                  H2J 3L2 MONTREAL (QC)                 
-#                                  CANADA                                
-#                                  e-mail: mmm@free.fr                   
-#                                                                        
-#  look our page at: http://www.multimania.com/marat                     
-#************************************************************************
-#  Functionality:  Delphi Components that provide an interface to the    
-#                  Python language (see python.txt for more infos on     
-#                  Python itself).                                       
-#                                                                        
-#************************************************************************
-#  Contributors:                                                         
-#      Grzegorz Makarewicz (mak@mikroplan.com.pl)                        
-#      Andrew Robinson (andy@hps1.demon.co.uk)                           
-#      Mark Watts(mark_watts@hotmail.com)                                
-#      Olivier Deckmyn (olivier.deckmyn@mail.dotcom.fr)                  
-#      Sigve Tjora (public@tjora.no)                                     
-#      Mark Derricutt (mark@talios.com)                                  
-#      Igor E. Poteryaev (jah@mail.ru)                                   
-#      Yuri Filimonov (fil65@mail.ru)                                    
-#      Stefan Hoffmeister (Stefan.Hoffmeister@Econos.de)                 
-#************************************************************************
-# This source code is distributed with no WARRANTY, for no reason or use.
-# Everyone is allowed to use and change this code free for his own tasks 
-# and projects, as long as this header and its copyright text is intact. 
-# For changed versions of this code, which are public distributed the    
-# following additional conditions have to be fullfilled:                 
-# 1) The header has to contain a comment on the change and the author of 
-#    it.                                                                 
-# 2) A copy of the changed source has to be sent to the above E-Mail     
-#    address or my then valid address, if this is possible to the        
-#    author.                                                             
-# The second condition has the target to maintain an up to date central  
-# version of the component. If this condition is not acceptable for      
-# confidential or legal reasons, everyone is free to derive a component  
-# or to generate a diff file to my or other original sources.            
-# Dr. Dietmar Budelsky, 1997-11-17                                       
-#************************************************************************
-
-{.deadCodeElim: on.}
-
-import 
-  dynlib
-
-
-when defined(windows): 
-  const dllname = "python(26|25|24|23|22|21|20|16|15).dll"
-elif defined(macosx):
-  const dllname = "libpython(2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).dylib"
-else: 
-  const dllver = ".1"
-  const dllname = "libpython(2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).so" & dllver
-  
-const 
-  PYT_METHOD_BUFFER_INCREASE* = 10
-  PYT_MEMBER_BUFFER_INCREASE* = 10
-  PYT_GETSET_BUFFER_INCREASE* = 10
-  METH_VARARGS* = 0x0001
-  METH_KEYWORDS* = 0x0002 # Masks for the co_flags field of PyCodeObject
-  CO_OPTIMIZED* = 0x0001
-  CO_NEWLOCALS* = 0x0002
-  CO_VARARGS* = 0x0004
-  CO_VARKEYWORDS* = 0x0008
-
-type                          # Rich comparison opcodes introduced in version 2.1
-  TRichComparisonOpcode* = enum 
-    pyLT, pyLE, pyEQ, pyNE, pyGT, pyGE
-
-const
-  Py_TPFLAGS_HAVE_GETCHARBUFFER* = (1 shl 0) # PySequenceMethods contains sq_contains
-  Py_TPFLAGS_HAVE_SEQUENCE_IN* = (1 shl 1) # Objects which participate in garbage collection (see objimp.h)
-  Py_TPFLAGS_GC* = (1 shl 2)  # PySequenceMethods and PyNumberMethods contain in-place operators
-  Py_TPFLAGS_HAVE_INPLACEOPS* = (1 shl 3) # PyNumberMethods do their own coercion */
-  Py_TPFLAGS_CHECKTYPES* = (1 shl 4)
-  Py_TPFLAGS_HAVE_RICHCOMPARE* = (1 shl 5) # Objects which are weakly referencable if their tp_weaklistoffset is >0
-                                           # XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE?
-                                           # These both indicate a feature that appeared in the same alpha release.
-  Py_TPFLAGS_HAVE_WEAKREFS* = (1 shl 6) # tp_iter is defined
-  Py_TPFLAGS_HAVE_ITER* = (1 shl 7) # New members introduced by Python 2.2 exist
-  Py_TPFLAGS_HAVE_CLASS* = (1 shl 8) # Set if the type object is dynamically allocated
-  Py_TPFLAGS_HEAPTYPE* = (1 shl 9) # Set if the type allows subclassing
-  Py_TPFLAGS_BASETYPE* = (1 shl 10) # Set if the type is 'ready' -- fully initialized
-  Py_TPFLAGS_READY* = (1 shl 12) # Set while the type is being 'readied', to prevent recursive ready calls
-  Py_TPFLAGS_READYING* = (1 shl 13) # Objects support garbage collection (see objimp.h)
-  Py_TPFLAGS_HAVE_GC* = (1 shl 14)
-  Py_TPFLAGS_DEFAULT* = Py_TPFLAGS_HAVE_GETCHARBUFFER or
-      Py_TPFLAGS_HAVE_SEQUENCE_IN or Py_TPFLAGS_HAVE_INPLACEOPS or
-      Py_TPFLAGS_HAVE_RICHCOMPARE or Py_TPFLAGS_HAVE_WEAKREFS or
-      Py_TPFLAGS_HAVE_ITER or Py_TPFLAGS_HAVE_CLASS 
-
-type 
-  TPFlag* = enum 
-    tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfGC, tpfHaveInplaceOps, 
-    tpfCheckTypes, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 
-    tpfHaveClass, tpfHeapType, tpfBaseType, tpfReady, tpfReadying, tpfHaveGC
-  TPFlags* = set[TPFlag]
-
-const 
-  TPFLAGS_DEFAULT* = {tpfHaveGetCharBuffer, tpfHaveSequenceIn, 
-    tpfHaveInplaceOps, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 
-    tpfHaveClass}
-
-const # Python opcodes
-  single_input* = 256 
-  file_input* = 257
-  eval_input* = 258
-  funcdef* = 259
-  parameters* = 260
-  varargslist* = 261
-  fpdef* = 262
-  fplist* = 263
-  stmt* = 264
-  simple_stmt* = 265
-  small_stmt* = 266
-  expr_stmt* = 267
-  augassign* = 268
-  print_stmt* = 269
-  del_stmt* = 270
-  pass_stmt* = 271
-  flow_stmt* = 272
-  break_stmt* = 273
-  continue_stmt* = 274
-  return_stmt* = 275
-  raise_stmt* = 276
-  import_stmt* = 277
-  import_as_name* = 278
-  dotted_as_name* = 279
-  dotted_name* = 280
-  global_stmt* = 281
-  exec_stmt* = 282
-  assert_stmt* = 283
-  compound_stmt* = 284
-  if_stmt* = 285
-  while_stmt* = 286
-  for_stmt* = 287
-  try_stmt* = 288
-  except_clause* = 289
-  suite* = 290
-  test* = 291
-  and_test* = 291
-  not_test* = 293
-  comparison* = 294
-  comp_op* = 295
-  expr* = 296
-  xor_expr* = 297
-  and_expr* = 298
-  shift_expr* = 299
-  arith_expr* = 300
-  term* = 301
-  factor* = 302
-  power* = 303
-  atom* = 304
-  listmaker* = 305
-  lambdef* = 306
-  trailer* = 307
-  subscriptlist* = 308
-  subscript* = 309
-  sliceop* = 310
-  exprlist* = 311
-  testlist* = 312
-  dictmaker* = 313
-  classdef* = 314
-  arglist* = 315
-  argument* = 316
-  list_iter* = 317
-  list_for* = 318
-  list_if* = 319
-
-const 
-  T_SHORT* = 0
-  T_INT* = 1
-  T_LONG* = 2
-  T_FLOAT* = 3
-  T_DOUBLE* = 4
-  T_STRING* = 5
-  T_OBJECT* = 6
-  T_CHAR* = 7                 # 1-character string
-  T_BYTE* = 8                 # 8-bit signed int
-  T_UBYTE* = 9
-  T_USHORT* = 10
-  T_UINT* = 11
-  T_ULONG* = 12
-  T_STRING_INPLACE* = 13
-  T_OBJECT_EX* = 16 
-  READONLY* = 1
-  RO* = READONLY              # Shorthand 
-  READ_RESTRICTED* = 2
-  WRITE_RESTRICTED* = 4
-  RESTRICTED* = (READ_RESTRICTED or WRITE_RESTRICTED)
-
-type 
-  TPyMemberType* = enum 
-    mtShort, mtInt, mtLong, mtFloat, mtDouble, mtString, mtObject, mtChar, 
-    mtByte, mtUByte, mtUShort, mtUInt, mtULong, mtStringInplace, mtObjectEx
-  TPyMemberFlag* = enum 
-    mfDefault, mfReadOnly, mfReadRestricted, mfWriteRestricted, mfRestricted
-
-type 
-  PInt* = ptr int
-
-#  PLong* = ptr int32
-#  PFloat* = ptr float32
-#  PShort* = ptr int8
-  
-type 
-  PP_frozen* = ptr Pfrozen
-  P_frozen* = ptr Tfrozen
-  PPyObject* = ptr TPyObject
-  PPPyObject* = ptr PPyObject
-  PPPPyObject* = ptr PPPyObject
-  PPyIntObject* = ptr TPyIntObject
-  PPyTypeObject* = ptr TPyTypeObject
-  PPySliceObject* = ptr TPySliceObject
-  TPyCFunction* = proc (self, args: PPyObject): PPyObject{.cdecl.}
-  Tunaryfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Tbinaryfunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.}
-  Tternaryfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.}
-  Tinquiry* = proc (ob1: PPyObject): int{.cdecl.}
-  Tcoercion* = proc (ob1, ob2: PPPyObject): int{.cdecl.}
-  Tintargfunc* = proc (ob1: PPyObject, i: int): PPyObject{.cdecl.}
-  Tintintargfunc* = proc (ob1: PPyObject, i1, i2: int): PPyObject{.cdecl.}
-  Tintobjargproc* = proc (ob1: PPyObject, i: int, ob2: PPyObject): int{.cdecl.}
-  Tintintobjargproc* = proc (ob1: PPyObject, i1, i2: int, ob2: PPyObject): int{.
-      cdecl.}
-  Tobjobjargproc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.}
-  Tpydestructor* = proc (ob: PPyObject){.cdecl.}
-  Tprintfunc* = proc (ob: PPyObject, f: TFile, i: int): int{.cdecl.}
-  Tgetattrfunc* = proc (ob1: PPyObject, name: cstring): PPyObject{.cdecl.}
-  Tsetattrfunc* = proc (ob1: PPyObject, name: cstring, ob2: PPyObject): int{.
-      cdecl.}
-  Tcmpfunc* = proc (ob1, ob2: PPyObject): int{.cdecl.}
-  Treprfunc* = proc (ob: PPyObject): PPyObject{.cdecl.}
-  Thashfunc* = proc (ob: PPyObject): int32{.cdecl.}
-  Tgetattrofunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.}
-  Tsetattrofunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} 
-  Tgetreadbufferproc* = proc (ob1: PPyObject, i: int, p: Pointer): int{.cdecl.}
-  Tgetwritebufferproc* = proc (ob1: PPyObject, i: int, p: Pointer): int{.cdecl.}
-  Tgetsegcountproc* = proc (ob1: PPyObject, i: int): int{.cdecl.}
-  Tgetcharbufferproc* = proc (ob1: PPyObject, i: int, pstr: cstring): int{.cdecl.}
-  Tobjobjproc* = proc (ob1, ob2: PPyObject): int{.cdecl.}
-  Tvisitproc* = proc (ob1: PPyObject, p: Pointer): int{.cdecl.}
-  Ttraverseproc* = proc (ob1: PPyObject, prc: TVisitproc, p: Pointer): int{.
-      cdecl.}
-  Trichcmpfunc* = proc (ob1, ob2: PPyObject, i: int): PPyObject{.cdecl.}
-  Tgetiterfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Titernextfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.}
-  Tdescrgetfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.}
-  Tdescrsetfunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.}
-  Tinitproc* = proc (self, args, kwds: PPyObject): int{.cdecl.}
-  Tnewfunc* = proc (subtype: PPyTypeObject, args, kwds: PPyObject): PPyObject{.
-      cdecl.}
-  Tallocfunc* = proc (self: PPyTypeObject, nitems: int): PPyObject{.cdecl.}
-  TPyNumberMethods*{.final.} = object 
-    nb_add*: Tbinaryfunc
-    nb_substract*: Tbinaryfunc
-    nb_multiply*: Tbinaryfunc
-    nb_divide*: Tbinaryfunc
-    nb_remainder*: Tbinaryfunc
-    nb_divmod*: Tbinaryfunc
-    nb_power*: Tternaryfunc
-    nb_negative*: Tunaryfunc
-    nb_positive*: Tunaryfunc
-    nb_absolute*: Tunaryfunc
-    nb_nonzero*: Tinquiry
-    nb_invert*: Tunaryfunc
-    nb_lshift*: Tbinaryfunc
-    nb_rshift*: Tbinaryfunc
-    nb_and*: Tbinaryfunc
-    nb_xor*: Tbinaryfunc
-    nb_or*: Tbinaryfunc
-    nb_coerce*: Tcoercion
-    nb_int*: Tunaryfunc
-    nb_long*: Tunaryfunc
-    nb_float*: Tunaryfunc
-    nb_oct*: Tunaryfunc
-    nb_hex*: Tunaryfunc       #/ jah 29-sep-2000: updated for python 2.0
-                              #/                   added from .h
-    nb_inplace_add*: Tbinaryfunc
-    nb_inplace_subtract*: Tbinaryfunc
-    nb_inplace_multiply*: Tbinaryfunc
-    nb_inplace_divide*: Tbinaryfunc
-    nb_inplace_remainder*: Tbinaryfunc
-    nb_inplace_power*: Tternaryfunc
-    nb_inplace_lshift*: Tbinaryfunc
-    nb_inplace_rshift*: Tbinaryfunc
-    nb_inplace_and*: Tbinaryfunc
-    nb_inplace_xor*: Tbinaryfunc
-    nb_inplace_or*: Tbinaryfunc # Added in release 2.2
-                                # The following require the Py_TPFLAGS_HAVE_CLASS flag
-    nb_floor_divide*: Tbinaryfunc
-    nb_true_divide*: Tbinaryfunc
-    nb_inplace_floor_divide*: Tbinaryfunc
-    nb_inplace_true_divide*: Tbinaryfunc
-
-  PPyNumberMethods* = ptr TPyNumberMethods
-  TPySequenceMethods*{.final.} = object 
-    sq_length*: Tinquiry
-    sq_concat*: Tbinaryfunc
-    sq_repeat*: Tintargfunc
-    sq_item*: Tintargfunc
-    sq_slice*: Tintintargfunc
-    sq_ass_item*: Tintobjargproc
-    sq_ass_slice*: Tintintobjargproc 
-    sq_contains*: Tobjobjproc
-    sq_inplace_concat*: Tbinaryfunc
-    sq_inplace_repeat*: Tintargfunc
-
-  PPySequenceMethods* = ptr TPySequenceMethods
-  TPyMappingMethods*{.final.} = object 
-    mp_length*: Tinquiry
-    mp_subscript*: Tbinaryfunc
-    mp_ass_subscript*: Tobjobjargproc
-
-  PPyMappingMethods* = ptr TPyMappingMethods 
-  TPyBufferProcs*{.final.} = object 
-    bf_getreadbuffer*: Tgetreadbufferproc
-    bf_getwritebuffer*: Tgetwritebufferproc
-    bf_getsegcount*: Tgetsegcountproc
-    bf_getcharbuffer*: Tgetcharbufferproc
-
-  PPyBufferProcs* = ptr TPyBufferProcs
-  TPy_complex*{.final.} = object 
-    float*: float64
-    imag*: float64
-
-  TPyObject*{.pure.} = object 
-    ob_refcnt*: int
-    ob_type*: PPyTypeObject
-
-  TPyIntObject* = object of TPyObject
-    ob_ival*: int32
-
-  PByte* = ptr int8
-  Tfrozen*{.final.} = object 
-    name*: cstring
-    code*: PByte
-    size*: int
-
-  TPySliceObject* = object of TPyObject
-    start*, stop*, step*: PPyObject
-
-  PPyMethodDef* = ptr TPyMethodDef
-  TPyMethodDef*{.final.} = object  # structmember.h
-    ml_name*: cstring
-    ml_meth*: TPyCFunction
-    ml_flags*: int
-    ml_doc*: cstring
-
-  PPyMemberDef* = ptr TPyMemberDef
-  TPyMemberDef*{.final.} = object  # descrobject.h
-                                   # Descriptors
-    name*: cstring
-    theType*: int
-    offset*: int
-    flags*: int
-    doc*: cstring
-
-  Tgetter* = proc (obj: PPyObject, context: Pointer): PPyObject{.cdecl.}
-  Tsetter* = proc (obj, value: PPyObject, context: Pointer): int{.cdecl.}
-  PPyGetSetDef* = ptr TPyGetSetDef
-  TPyGetSetDef*{.final.} = object 
-    name*: cstring
-    get*: Tgetter
-    setter*: Tsetter
-    doc*: cstring
-    closure*: Pointer
-
-  Twrapperfunc* = proc (self, args: PPyObject, wrapped: Pointer): PPyObject{.
-      cdecl.}
-  pwrapperbase* = ptr Twrapperbase
-  Twrapperbase*{.final.} = object  # Various kinds of descriptor objects
-                                   ##define PyDescr_COMMON \
-                                   #          PyObject_HEAD \
-                                   #          PyTypeObject *d_type; \
-                                   #          PyObject *d_name
-                                   #  
-    name*: cstring
-    wrapper*: Twrapperfunc
-    doc*: cstring
-
-  PPyDescrObject* = ptr TPyDescrObject
-  TPyDescrObject* = object of TPyObject
-    d_type*: PPyTypeObject
-    d_name*: PPyObject
-
-  PPyMethodDescrObject* = ptr TPyMethodDescrObject
-  TPyMethodDescrObject* = object of TPyDescrObject
-    d_method*: PPyMethodDef
-
-  PPyMemberDescrObject* = ptr TPyMemberDescrObject
-  TPyMemberDescrObject* = object of TPyDescrObject
-    d_member*: PPyMemberDef
-
-  PPyGetSetDescrObject* = ptr TPyGetSetDescrObject
-  TPyGetSetDescrObject* = object of TPyDescrObject
-    d_getset*: PPyGetSetDef
-
-  PPyWrapperDescrObject* = ptr TPyWrapperDescrObject
-  TPyWrapperDescrObject* = object of TPyDescrObject # object.h
-    d_base*: pwrapperbase
-    d_wrapped*: Pointer       # This can be any function pointer
-  
-  TPyTypeObject* = object of TPyObject
-    ob_size*: int             # Number of items in variable part
-    tp_name*: cstring         # For printing
-    tp_basicsize*, tp_itemsize*: int # For allocation
-                                     # Methods to implement standard operations
-    tp_dealloc*: Tpydestructor
-    tp_print*: Tprintfunc
-    tp_getattr*: Tgetattrfunc
-    tp_setattr*: Tsetattrfunc
-    tp_compare*: Tcmpfunc
-    tp_repr*: Treprfunc       # Method suites for standard classes
-    tp_as_number*: PPyNumberMethods
-    tp_as_sequence*: PPySequenceMethods
-    tp_as_mapping*: PPyMappingMethods # More standard operations (here for binary compatibility)
-    tp_hash*: Thashfunc
-    tp_call*: Tternaryfunc
-    tp_str*: Treprfunc
-    tp_getattro*: Tgetattrofunc
-    tp_setattro*: Tsetattrofunc #/ jah 29-sep-2000: updated for python 2.0
-                                # Functions to access object as input/output buffer
-    tp_as_buffer*: PPyBufferProcs # Flags to define presence of optional/expanded features
-    tp_flags*: int32
-    tp_doc*: cstring          # Documentation string
-                              # call function for all accessible objects
-    tp_traverse*: Ttraverseproc # delete references to contained objects
-    tp_clear*: Tinquiry       # rich comparisons
-    tp_richcompare*: Trichcmpfunc # weak reference enabler
-    tp_weaklistoffset*: int32 # Iterators
-    tp_iter*: Tgetiterfunc
-    tp_iternext*: Titernextfunc # Attribute descriptor and subclassing stuff
-    tp_methods*: PPyMethodDef
-    tp_members*: PPyMemberDef
-    tp_getset*: PPyGetSetDef
-    tp_base*: PPyTypeObject
-    tp_dict*: PPyObject
-    tp_descr_get*: Tdescrgetfunc
-    tp_descr_set*: Tdescrsetfunc
-    tp_dictoffset*: int32
-    tp_init*: Tinitproc
-    tp_alloc*: Tallocfunc
-    tp_new*: Tnewfunc
-    tp_free*: Tpydestructor   # Low-level free-memory routine
-    tp_is_gc*: Tinquiry       # For PyObject_IS_GC
-    tp_bases*: PPyObject
-    tp_mro*: PPyObject        # method resolution order
-    tp_cache*: PPyObject
-    tp_subclasses*: PPyObject
-    tp_weaklist*: PPyObject   #More spares
-    tp_xxx7*: pointer
-    tp_xxx8*: pointer
-
-  PPyMethodChain* = ptr TPyMethodChain
-  TPyMethodChain*{.final.} = object 
-    methods*: PPyMethodDef
-    link*: PPyMethodChain
-
-  PPyClassObject* = ptr TPyClassObject
-  TPyClassObject* = object of TPyObject
-    cl_bases*: PPyObject      # A tuple of class objects
-    cl_dict*: PPyObject       # A dictionary
-    cl_name*: PPyObject       # A string
-                              # The following three are functions or NULL
-    cl_getattr*: PPyObject
-    cl_setattr*: PPyObject
-    cl_delattr*: PPyObject
-
-  PPyInstanceObject* = ptr TPyInstanceObject
-  TPyInstanceObject* = object of TPyObject 
-    in_class*: PPyClassObject # The class object
-    in_dict*: PPyObject       # A dictionary
-  
-  PPyMethodObject* = ptr TPyMethodObject
-  TPyMethodObject* = object of TPyObject # Bytecode object, compile.h
-    im_func*: PPyObject       # The function implementing the method
-    im_self*: PPyObject       # The instance it is bound to, or NULL
-    im_class*: PPyObject      # The class that defined the method
-  
-  PPyCodeObject* = ptr TPyCodeObject
-  TPyCodeObject* = object of TPyObject # from pystate.h
-    co_argcount*: int         # #arguments, except *args
-    co_nlocals*: int          # #local variables
-    co_stacksize*: int        # #entries needed for evaluation stack
-    co_flags*: int            # CO_..., see below
-    co_code*: PPyObject       # instruction opcodes (it hides a PyStringObject)
-    co_consts*: PPyObject     # list (constants used)
-    co_names*: PPyObject      # list of strings (names used)
-    co_varnames*: PPyObject   # tuple of strings (local variable names)
-    co_freevars*: PPyObject   # tuple of strings (free variable names)
-    co_cellvars*: PPyObject   # tuple of strings (cell variable names)
-                              # The rest doesn't count for hash/cmp
-    co_filename*: PPyObject   # string (where it was loaded from)
-    co_name*: PPyObject       # string (name, for reference)
-    co_firstlineno*: int      # first source line number
-    co_lnotab*: PPyObject     # string (encoding addr<->lineno mapping)
-  
-  PPyInterpreterState* = ptr TPyInterpreterState
-  PPyThreadState* = ptr TPyThreadState
-  PPyFrameObject* = ptr TPyFrameObject # Interpreter environments
-  TPyInterpreterState*{.final.} = object  # Thread specific information
-    next*: PPyInterpreterState
-    tstate_head*: PPyThreadState
-    modules*: PPyObject
-    sysdict*: PPyObject
-    builtins*: PPyObject
-    checkinterval*: int
-
-  TPyThreadState*{.final.} = object  # from frameobject.h
-    next*: PPyThreadState
-    interp*: PPyInterpreterState
-    frame*: PPyFrameObject
-    recursion_depth*: int
-    ticker*: int
-    tracing*: int
-    sys_profilefunc*: PPyObject
-    sys_tracefunc*: PPyObject
-    curexc_type*: PPyObject
-    curexc_value*: PPyObject
-    curexc_traceback*: PPyObject
-    exc_type*: PPyObject
-    exc_value*: PPyObject
-    exc_traceback*: PPyObject
-    dict*: PPyObject
-
-  PPyTryBlock* = ptr TPyTryBlock
-  TPyTryBlock*{.final.} = object 
-    b_type*: int              # what kind of block this is
-    b_handler*: int           # where to jump to find handler
-    b_level*: int             # value stack level to pop to
-  
-  CO_MAXBLOCKS* = range[0..19]
-  TPyFrameObject* = object of TPyObject # start of the VAR_HEAD of an object
-                                        # From traceback.c
-    ob_size*: int             # Number of items in variable part
-                              # End of the Head of an object
-    f_back*: PPyFrameObject   # previous frame, or NULL
-    f_code*: PPyCodeObject    # code segment
-    f_builtins*: PPyObject    # builtin symbol table (PyDictObject)
-    f_globals*: PPyObject     # global symbol table (PyDictObject)
-    f_locals*: PPyObject      # local symbol table (PyDictObject)
-    f_valuestack*: PPPyObject # points after the last local
-                              # Next free slot in f_valuestack. Frame creation sets to f_valuestack.
-                              # Frame evaluation usually NULLs it, but a frame that yields sets it
-                              # to the current stack top. 
-    f_stacktop*: PPPyObject
-    f_trace*: PPyObject       # Trace function
-    f_exc_type*, f_exc_value*, f_exc_traceback*: PPyObject
-    f_tstate*: PPyThreadState
-    f_lasti*: int             # Last instruction if called
-    f_lineno*: int            # Current line number
-    f_restricted*: int        # Flag set if restricted operations
-                              # in this scope
-    f_iblock*: int            # index in f_blockstack
-    f_blockstack*: array[CO_MAXBLOCKS, TPyTryBlock] # for try and loop blocks
-    f_nlocals*: int           # number of locals
-    f_ncells*: int
-    f_nfreevars*: int
-    f_stacksize*: int         # size of value stack
-    f_localsplus*: array[0..0, PPyObject] # locals+stack, dynamically sized
-  
-  PPyTraceBackObject* = ptr TPyTraceBackObject
-  TPyTraceBackObject* = object of TPyObject # Parse tree node interface
-    tb_next*: PPyTraceBackObject
-    tb_frame*: PPyFrameObject
-    tb_lasti*: int
-    tb_lineno*: int
-
-  PNode* = ptr Tnode
-  Tnode*{.final.} = object    # From weakrefobject.h
-    n_type*: int16
-    n_str*: cstring
-    n_lineno*: int16
-    n_nchildren*: int16
-    n_child*: PNode
-
-  PPyWeakReference* = ptr TPyWeakReference
-  TPyWeakReference* = object of TPyObject 
-    wr_object*: PPyObject
-    wr_callback*: PPyObject
-    hash*: int32
-    wr_prev*: PPyWeakReference
-    wr_next*: PPyWeakReference
-
-
-const                         
-  PyDateTime_DATE_DATASIZE* = 4 # # of bytes for year, month, and day
-  PyDateTime_TIME_DATASIZE* = 6 # # of bytes for hour, minute, second, and usecond
-  PyDateTime_DATETIME_DATASIZE* = 10 # # of bytes for year, month, 
-                                     # day, hour, minute, second, and usecond. 
-
-type 
-  TPyDateTime_Delta* = object of TPyObject
-    hashcode*: int            # -1 when unknown
-    days*: int                # -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS
-    seconds*: int             # 0 <= seconds < 24*3600 is invariant
-    microseconds*: int        # 0 <= microseconds < 1000000 is invariant
-  
-  PPyDateTime_Delta* = ptr TPyDateTime_Delta
-  TPyDateTime_TZInfo* = object of TPyObject # a pure abstract base clase
-  PPyDateTime_TZInfo* = ptr TPyDateTime_TZInfo 
-  TPyDateTime_BaseTZInfo* = object of TPyObject
-    hashcode*: int
-    hastzinfo*: bool          # boolean flag
-  
-  PPyDateTime_BaseTZInfo* = ptr TPyDateTime_BaseTZInfo 
-  TPyDateTime_BaseTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_TIME_DATASIZE), int8]
-
-  PPyDateTime_BaseTime* = ptr TPyDateTime_BaseTime
-  TPyDateTime_Time* = object of TPyDateTime_BaseTime # hastzinfo true
-    tzinfo*: PPyObject
-
-  PPyDateTime_Time* = ptr TPyDateTime_Time 
-  TPyDateTime_Date* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATE_DATASIZE), int8]
-
-  PPyDateTime_Date* = ptr TPyDateTime_Date 
-  TPyDateTime_BaseDateTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8]
-
-  PPyDateTime_BaseDateTime* = ptr TPyDateTime_BaseDateTime
-  TPyDateTime_DateTime* = object of TPyDateTime_BaseTZInfo
-    data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8]
-    tzinfo*: PPyObject
-
-  PPyDateTime_DateTime* = ptr TPyDateTime_DateTime 
-
-#----------------------------------------------------#
-#                                                    #
-#         New exception classes                      #
-#                                                    #
-#----------------------------------------------------#
-
-#
-#  // Python's exceptions
-#  EPythonError   = object(Exception)
-#      EName: String;
-#      EValue: String;
-#  end;
-#  EPyExecError   = object(EPythonError)
-#  end;
-#
-#  // Standard exception classes of Python
-#
-#/// jah 29-sep-2000: updated for python 2.0
-#///                   base classes updated according python documentation
-#
-#{ Hierarchy of Python exceptions, Python 2.3, copied from <INSTALL>\Python\exceptions.c
-#
-#Exception\n\
-# |\n\
-# +-- SystemExit\n\
-# +-- StopIteration\n\
-# +-- StandardError\n\
-# |    |\n\
-# |    +-- KeyboardInterrupt\n\
-# |    +-- ImportError\n\
-# |    +-- EnvironmentError\n\
-# |    |    |\n\
-# |    |    +-- IOError\n\
-# |    |    +-- OSError\n\
-# |    |         |\n\
-# |    |         +-- WindowsError\n\
-# |    |         +-- VMSError\n\
-# |    |\n\
-# |    +-- EOFError\n\
-# |    +-- RuntimeError\n\
-# |    |    |\n\
-# |    |    +-- NotImplementedError\n\
-# |    |\n\
-# |    +-- NameError\n\
-# |    |    |\n\
-# |    |    +-- UnboundLocalError\n\
-# |    |\n\
-# |    +-- AttributeError\n\
-# |    +-- SyntaxError\n\
-# |    |    |\n\
-# |    |    +-- IndentationError\n\
-# |    |         |\n\
-# |    |         +-- TabError\n\
-# |    |\n\
-# |    +-- TypeError\n\
-# |    +-- AssertionError\n\
-# |    +-- LookupError\n\
-# |    |    |\n\
-# |    |    +-- IndexError\n\
-# |    |    +-- KeyError\n\
-# |    |\n\
-# |    +-- ArithmeticError\n\
-# |    |    |\n\
-# |    |    +-- OverflowError\n\
-# |    |    +-- ZeroDivisionError\n\
-# |    |    +-- FloatingPointError\n\
-# |    |\n\
-# |    +-- ValueError\n\
-# |    |    |\n\
-# |    |    +-- UnicodeError\n\
-# |    |        |\n\
-# |    |        +-- UnicodeEncodeError\n\
-# |    |        +-- UnicodeDecodeError\n\
-# |    |        +-- UnicodeTranslateError\n\
-# |    |\n\
-# |    +-- ReferenceError\n\
-# |    +-- SystemError\n\
-# |    +-- MemoryError\n\
-# |\n\
-# +---Warning\n\
-#      |\n\
-#      +-- UserWarning\n\
-#      +-- DeprecationWarning\n\
-#      +-- PendingDeprecationWarning\n\
-#      +-- SyntaxWarning\n\
-#      +-- OverflowWarning\n\
-#      +-- RuntimeWarning\n\
-#      +-- FutureWarning"
-#}
-#   EPyException = class (EPythonError);
-#   EPyStandardError = class (EPyException);
-#   EPyArithmeticError = class (EPyStandardError);
-#   EPyLookupError = class (EPyStandardError);
-#   EPyAssertionError = class (EPyStandardError);
-#   EPyAttributeError = class (EPyStandardError);
-#   EPyEOFError = class (EPyStandardError);
-#   EPyFloatingPointError = class (EPyArithmeticError);
-#   EPyEnvironmentError = class (EPyStandardError);
-#   EPyIOError = class (EPyEnvironmentError);
-#   EPyOSError = class (EPyEnvironmentError);
-#   EPyImportError = class (EPyStandardError);
-#   EPyIndexError = class (EPyLookupError);
-#   EPyKeyError = class (EPyLookupError);
-#   EPyKeyboardInterrupt = class (EPyStandardError);
-#   EPyMemoryError = class (EPyStandardError);
-#   EPyNameError = class (EPyStandardError);
-#   EPyOverflowError = class (EPyArithmeticError);
-#   EPyRuntimeError = class (EPyStandardError);
-#   EPyNotImplementedError = class (EPyRuntimeError);
-#   EPySyntaxError = class (EPyStandardError)
-#   public
-#      EFileName: string;
-#      ELineStr: string;
-#      ELineNumber: Integer;
-#      EOffset: Integer;
-#   end;
-#   EPyIndentationError = class (EPySyntaxError);
-#   EPyTabError = class (EPyIndentationError);
-#   EPySystemError = class (EPyStandardError);
-#   EPySystemExit = class (EPyException);
-#   EPyTypeError = class (EPyStandardError);
-#   EPyUnboundLocalError = class (EPyNameError);
-#   EPyValueError = class (EPyStandardError);
-#   EPyUnicodeError = class (EPyValueError);
-#   UnicodeEncodeError = class (EPyUnicodeError);
-#   UnicodeDecodeError = class (EPyUnicodeError);
-#   UnicodeTranslateError = class (EPyUnicodeError);
-#   EPyZeroDivisionError = class (EPyArithmeticError);
-#   EPyStopIteration = class(EPyException);
-#   EPyWarning = class (EPyException);
-#   EPyUserWarning = class (EPyWarning);
-#   EPyDeprecationWarning = class (EPyWarning);
-#   PendingDeprecationWarning = class (EPyWarning);
-#   FutureWarning = class (EPyWarning);
-#   EPySyntaxWarning = class (EPyWarning);
-#   EPyOverflowWarning = class (EPyWarning);
-#   EPyRuntimeWarning = class (EPyWarning);
-#   EPyReferenceError = class (EPyStandardError);
-#
-
-var 
-  PyArg_Parse*: proc (args: PPyObject, format: cstring): int{.cdecl, varargs.} 
-  PyArg_ParseTuple*: proc (args: PPyObject, format: cstring, x1: Pointer = nil, 
-                           x2: Pointer = nil, x3: Pointer = nil): int{.cdecl, varargs.} 
-  Py_BuildValue*: proc (format: cstring): PPyObject{.cdecl, varargs.} 
-  PyCode_Addr2Line*: proc (co: PPyCodeObject, addrq: int): int{.cdecl.}
-  DLL_Py_GetBuildInfo*: proc (): cstring{.cdecl.}
-
-var
-  Py_DebugFlag*: PInt
-  Py_VerboseFlag*: PInt
-  Py_InteractiveFlag*: PInt
-  Py_OptimizeFlag*: PInt
-  Py_NoSiteFlag*: PInt
-  Py_UseClassExceptionsFlag*: PInt
-  Py_FrozenFlag*: PInt
-  Py_TabcheckFlag*: PInt
-  Py_UnicodeFlag*: PInt
-  Py_IgnoreEnvironmentFlag*: PInt
-  Py_DivisionWarningFlag*: PInt 
-  #_PySys_TraceFunc:    PPPyObject;
-  #_PySys_ProfileFunc: PPPPyObject;
-  PyImport_FrozenModules*: PP_frozen
-  Py_None*: PPyObject
-  Py_Ellipsis*: PPyObject
-  Py_False*: PPyIntObject
-  Py_True*: PPyIntObject
-  Py_NotImplemented*: PPyObject
-  PyExc_AttributeError*: PPPyObject
-  PyExc_EOFError*: PPPyObject
-  PyExc_IOError*: PPPyObject
-  PyExc_ImportError*: PPPyObject
-  PyExc_IndexError*: PPPyObject
-  PyExc_KeyError*: PPPyObject
-  PyExc_KeyboardInterrupt*: PPPyObject
-  PyExc_MemoryError*: PPPyObject
-  PyExc_NameError*: PPPyObject
-  PyExc_OverflowError*: PPPyObject
-  PyExc_RuntimeError*: PPPyObject
-  PyExc_SyntaxError*: PPPyObject
-  PyExc_SystemError*: PPPyObject
-  PyExc_SystemExit*: PPPyObject
-  PyExc_TypeError*: PPPyObject
-  PyExc_ValueError*: PPPyObject
-  PyExc_ZeroDivisionError*: PPPyObject
-  PyExc_ArithmeticError*: PPPyObject
-  PyExc_Exception*: PPPyObject
-  PyExc_FloatingPointError*: PPPyObject
-  PyExc_LookupError*: PPPyObject
-  PyExc_StandardError*: PPPyObject
-  PyExc_AssertionError*: PPPyObject
-  PyExc_EnvironmentError*: PPPyObject
-  PyExc_IndentationError*: PPPyObject
-  PyExc_MemoryErrorInst*: PPPyObject
-  PyExc_NotImplementedError*: PPPyObject
-  PyExc_OSError*: PPPyObject
-  PyExc_TabError*: PPPyObject
-  PyExc_UnboundLocalError*: PPPyObject
-  PyExc_UnicodeError*: PPPyObject
-  PyExc_Warning*: PPPyObject
-  PyExc_DeprecationWarning*: PPPyObject
-  PyExc_RuntimeWarning*: PPPyObject
-  PyExc_SyntaxWarning*: PPPyObject
-  PyExc_UserWarning*: PPPyObject
-  PyExc_OverflowWarning*: PPPyObject
-  PyExc_ReferenceError*: PPPyObject
-  PyExc_StopIteration*: PPPyObject
-  PyExc_FutureWarning*: PPPyObject
-  PyExc_PendingDeprecationWarning*: PPPyObject
-  PyExc_UnicodeDecodeError*: PPPyObject
-  PyExc_UnicodeEncodeError*: PPPyObject
-  PyExc_UnicodeTranslateError*: PPPyObject
-  PyType_Type*: PPyTypeObject
-  PyCFunction_Type*: PPyTypeObject
-  PyCObject_Type*: PPyTypeObject
-  PyClass_Type*: PPyTypeObject
-  PyCode_Type*: PPyTypeObject
-  PyComplex_Type*: PPyTypeObject
-  PyDict_Type*: PPyTypeObject
-  PyFile_Type*: PPyTypeObject
-  PyFloat_Type*: PPyTypeObject
-  PyFrame_Type*: PPyTypeObject
-  PyFunction_Type*: PPyTypeObject
-  PyInstance_Type*: PPyTypeObject
-  PyInt_Type*: PPyTypeObject
-  PyList_Type*: PPyTypeObject
-  PyLong_Type*: PPyTypeObject
-  PyMethod_Type*: PPyTypeObject
-  PyModule_Type*: PPyTypeObject
-  PyObject_Type*: PPyTypeObject
-  PyRange_Type*: PPyTypeObject
-  PySlice_Type*: PPyTypeObject
-  PyString_Type*: PPyTypeObject
-  PyTuple_Type*: PPyTypeObject
-  PyBaseObject_Type*: PPyTypeObject
-  PyBuffer_Type*: PPyTypeObject
-  PyCallIter_Type*: PPyTypeObject
-  PyCell_Type*: PPyTypeObject
-  PyClassMethod_Type*: PPyTypeObject
-  PyProperty_Type*: PPyTypeObject
-  PySeqIter_Type*: PPyTypeObject
-  PyStaticMethod_Type*: PPyTypeObject
-  PySuper_Type*: PPyTypeObject
-  PySymtableEntry_Type*: PPyTypeObject
-  PyTraceBack_Type*: PPyTypeObject
-  PyUnicode_Type*: PPyTypeObject
-  PyWrapperDescr_Type*: PPyTypeObject
-  PyBaseString_Type*: PPyTypeObject
-  PyBool_Type*: PPyTypeObject
-  PyEnum_Type*: PPyTypeObject
-
-  #PyArg_GetObject: proc(args: PPyObject; nargs, i: integer; p_a: PPPyObject): integer; cdecl;
-  #PyArg_GetLong: proc(args: PPyObject; nargs, i: integer; p_a: PLong): integer; cdecl;
-  #PyArg_GetShort: proc(args: PPyObject; nargs, i: integer; p_a: PShort): integer; cdecl;
-  #PyArg_GetFloat: proc(args: PPyObject; nargs, i: integer; p_a: PFloat): integer; cdecl;
-  #PyArg_GetString: proc(args: PPyObject; nargs, i: integer; p_a: PString): integer; cdecl;
-  #PyArgs_VaParse:  proc (args: PPyObject; format: PChar; 
-  #                          va_list: array of const): integer; cdecl;
-  # Does not work!
-  # Py_VaBuildValue: proc (format: PChar; va_list: array of const): PPyObject; cdecl;
-  #PyBuiltin_Init: proc; cdecl;
-proc PyComplex_FromCComplex*(c: TPy_complex): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_FromDoubles*(realv, imag: float64): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_RealAsDouble*(op: PPyObject): float64{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_ImagAsDouble*(op: PPyObject): float64{.cdecl, importc, dynlib: dllname.}
-proc PyComplex_AsCComplex*(op: PPyObject): TPy_complex{.cdecl, importc, dynlib: dllname.}
-proc PyCFunction_GetFunction*(ob: PPyObject): Pointer{.cdecl, importc, dynlib: dllname.}
-proc PyCFunction_GetSelf*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyCallable_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyCObject_FromVoidPtr*(cobj, destruct: Pointer): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyCObject_AsVoidPtr*(ob: PPyObject): Pointer{.cdecl, importc, dynlib: dllname.}
-proc PyClass_New*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyClass_IsSubclass*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc Py_InitModule4*(name: cstring, methods: PPyMethodDef, doc: cstring, 
-                         passthrough: PPyObject, Api_Version: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyErr_BadArgument*(): int{.cdecl, importc, dynlib: dllname.}
-proc PyErr_BadInternalCall*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_CheckSignals*(): int{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Clear*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_Fetch*(errtype, errvalue, errtraceback: PPPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_NoMemory*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Occurred*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_Print*(){.cdecl, importc, dynlib: dllname.}
-proc PyErr_Restore*(errtype, errvalue, errtraceback: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetFromErrno*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetNone*(value: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetObject*(ob1, ob2: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyErr_SetString*(ErrorObject: PPyObject, text: cstring){.cdecl, importc, dynlib: dllname.}
-proc PyImport_GetModuleDict*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyInt_FromLong*(x: int32): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc Py_Initialize*(){.cdecl, importc, dynlib: dllname.}
-proc Py_Exit*(RetVal: int){.cdecl, importc, dynlib: dllname.}
-proc PyEval_GetBuiltins*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_GetItem*(mp, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_SetItem*(mp, key, item: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_DelItem*(mp, key: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Clear*(mp: PPyObject){.cdecl, importc, dynlib: dllname.}
-proc PyDict_Next*(mp: PPyObject, pos: PInt, key, value: PPPyObject): int{.
-      cdecl, importc, dynlib: dllname.}
-proc PyDict_Keys*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Values*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Items*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_Size*(mp: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_DelItemString*(dp: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.}
-proc PyDict_New*(): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_GetItemString*(dp: PPyObject, key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyDict_SetItemString*(dp: PPyObject, key: cstring, item: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}
-proc PyDictProxy_New*(obj: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyModule_GetDict*(module: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_Str*(v: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyRun_String*(str: cstring, start: int, globals: PPyObject, 
-                       locals: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyRun_SimpleString*(str: cstring): int{.cdecl, importc, dynlib: dllname.}
-proc PyString_AsString*(ob: PPyObject): cstring{.cdecl, importc, dynlib: dllname.}
-proc PyString_FromString*(str: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PySys_SetArgv*(argc: int, argv: cstringArray){.cdecl, importc, dynlib: dllname.} 
-  #+ means, Grzegorz or me has tested his non object version of this function
-  #+
-proc PyCFunction_New*(md: PPyMethodDef, ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyEval_CallObject*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_CallObjectWithKeywords*(ob1, ob2, ob3: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyEval_GetFrame*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetGlobals*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetLocals*(): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_GetOwner*(): PPyObject {.cdecl, importc, dynlib: dllname.}
-proc PyEval_GetRestricted*(): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_InitThreads*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_RestoreThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_SaveThread*(): PPyThreadState{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_FromString*(pc1, pc2: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_GetLine*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_Name*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_SetBufSize*(ob: PPyObject, i: int){.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_SoftSpace*(ob: PPyObject, i: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_WriteObject*(ob1, ob2: PPyObject, i: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyFile_WriteString*(s: cstring, ob: PPyObject){.cdecl, importc, dynlib: dllname.} #+
-proc PyFloat_AsDouble*(ob: PPyObject): float64{.cdecl, importc, dynlib: dllname.} #+
-proc PyFloat_FromDouble*(db: float64): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_GetCode*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_GetGlobals*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyFunction_New*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_AddModule*(name: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_Cleanup*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyImport_GetMagicNumber*(): int32{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_ImportFrozenModule*(key: cstring): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_ImportModule*(name: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyImport_Import*(name: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-                                                               
-proc PyImport_Init*() {.cdecl, importc, dynlib: dllname.}
-proc PyImport_ReloadModule*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyInstance_New*(obClass, obArg, obKW: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyInt_AsLong*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Append*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_AsTuple*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyList_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Insert*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Reverse*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_SetItem*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_SetSlice*(ob: PPyObject, i1, i2: int, ob2: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #+
-proc PyList_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyList_Sort*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsDouble*(ob: PPyObject): float64{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_AsLong*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_FromDouble*(db: float64): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyLong_FromLong*(L: int32): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromString*(pc: cstring, ppc: var cstring, i: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyLong_FromUnsignedLong*(val: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsUnsignedLong*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromUnicode*(ob: PPyObject, a, b: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_FromLongLong*(val: Int64): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyLong_AsLongLong*(ob: PPyObject): Int64{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_GetItemString*(ob: PPyObject, key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_HasKey*(ob, key: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_HasKeyString*(ob: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyMapping_SetItemString*(ob: PPyObject, key: cstring, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyMethod_Class*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_Function*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_New*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyMethod_Self*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyModule_GetName*(ob: PPyObject): cstring{.cdecl, importc, dynlib: dllname.} #-
-proc PyModule_New*(key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Absolute*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Add*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_And*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Coerce*(ob1, ob2: var PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Divide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_FloorDivide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_TrueDivide*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Divmod*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Float*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Int*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Invert*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Long*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Lshift*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Multiply*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Negative*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Or*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Positive*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Power*(ob1, ob2, ob3: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Remainder*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Rshift*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Subtract*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyNumber_Xor*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyOS_InitInterrupts*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyOS_InterruptOccurred*(): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_CallObject*(ob, args: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Compare*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GetAttr*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyObject_GetAttrString*(ob: PPyObject, c: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GetItem*(ob, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_DelItem*(ob, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_HasAttrString*(ob: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Hash*(ob: PPyObject): int32{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsTrue*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Repr*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_SetAttr*(ob1, ob2, ob3: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_SetAttrString*(ob: PPyObject, key: cstring, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyObject_SetItem*(ob1, ob2, ob3: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_Init*(ob: PPyObject, t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_InitVar*(ob: PPyObject, t: PPyTypeObject, size: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyObject_New*(t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_NewVar*(t: PPyTypeObject, size: int): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_Free*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsInstance*(inst, cls: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_IsSubclass*(derived, cls: PPyObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyObject_GenericGetAttr*(obj, name: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyObject_GenericSetAttr*(obj, name, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Malloc*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_New*(t: PPyTypeObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_NewVar*(t: PPyTypeObject, size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Resize*(t: PPyObject, newsize: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Del*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_Track*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyObject_GC_UnTrack*(ob: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyRange_New*(l1, l2, l3: int32, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Check*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Concat*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Count*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_In*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Index*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Length*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Repeat*(ob: PPyObject, count: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_SetItem*(ob: PPyObject, i: int, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySequence_SetSlice*(ob: PPyObject, i1, i2: int, value: PPyObject): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySequence_DelSlice*(ob: PPyObject, i1, i2: int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Tuple*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PySequence_Contains*(ob, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySlice_GetIndices*(ob: PPySliceObject, len: int, 
-                             start, stop, step: var int): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySlice_GetIndicesEx*(ob: PPySliceObject, len: int, 
-                               start, stop, step, slicelength: var int): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PySlice_New*(start, stop, step: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Concat*(ob1: var PPyObject, ob2: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyString_ConcatAndDel*(ob1: var PPyObject, ob2: PPyObject){.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Format*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_FromStringAndSize*(s: cstring, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyString_DecodeEscape*(s: cstring, length: int, errors: cstring, 
-                                unicode: int, recode_encoding: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyString_Repr*(ob: PPyObject, smartquotes: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PySys_GetObject*(s: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} 
-#-
-#PySys_Init:procedure; cdecl, importc, dynlib: dllname;
-#-
-proc PySys_SetObject*(s: cstring, ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PySys_SetPath*(path: cstring){.cdecl, importc, dynlib: dllname.} #-
-#PyTraceBack_Fetch:function:PPyObject; cdecl, importc, dynlib: dllname;
-#-
-proc PyTraceBack_Here*(p: pointer): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyTraceBack_Print*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-#PyTraceBack_Store:function (ob:PPyObject):integer; cdecl, importc, dynlib: dllname;
-#+
-proc PyTuple_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc PyTuple_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_SetItem*(ob: PPyObject, key: int, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyTuple_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyType_IsSubtype*(a, b: PPyTypeObject): int{.cdecl, importc, dynlib: dllname.}
-proc PyType_GenericAlloc*(atype: PPyTypeObject, nitems: int): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyType_GenericNew*(atype: PPyTypeObject, args, kwds: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}
-proc PyType_Ready*(atype: PPyTypeObject): int{.cdecl, importc, dynlib: dllname.} #+
-proc PyUnicode_FromWideChar*(w: pointer, size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+
-proc PyUnicode_AsWideChar*(unicode: PPyObject, w: pointer, size: int): int{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc PyUnicode_FromOrdinal*(ordinal: int): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_GetObject*(theRef: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_NewProxy*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWeakref_NewRef*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyWrapper_New*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc PyBool_FromLong*(ok: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc Py_AtExit*(prc: proc ()): int{.cdecl, importc, dynlib: dllname.} #-
-#Py_Cleanup:procedure; cdecl, importc, dynlib: dllname;
-#-
-proc Py_CompileString*(s1, s2: cstring, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #-
-proc Py_FatalError*(s: cstring){.cdecl, importc, dynlib: dllname.} #-
-proc Py_FindMethod*(md: PPyMethodDef, ob: PPyObject, key: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_FindMethodInChain*(mc: PPyMethodChain, ob: PPyObject, key: cstring): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_FlushLine*(){.cdecl, importc, dynlib: dllname.} #+
-proc Py_Finalize*(){.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_ExceptionMatches*(exc: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_GivenExceptionMatches*(raised_exc, exc: PPyObject): int{.cdecl, importc, dynlib: dllname.} #-
-proc PyEval_EvalCode*(co: PPyCodeObject, globals, locals: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #+
-proc Py_GetVersion*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetCopyright*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetExecPrefix*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetPath*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetPrefix*(): cstring{.cdecl, importc, dynlib: dllname.} #+
-proc Py_GetProgramName*(): cstring{.cdecl, importc, dynlib: dllname.} #-
-proc PyParser_SimpleParseString*(str: cstring, start: int): PNode{.cdecl, importc, dynlib: dllname.} #-
-proc PyNode_Free*(n: PNode){.cdecl, importc, dynlib: dllname.} #-
-proc PyErr_NewException*(name: cstring, base, dict: PPyObject): PPyObject{.
-      cdecl, importc, dynlib: dllname.}                 #-
-proc Py_Malloc*(size: int): Pointer {.cdecl, importc, dynlib: dllname.}
-proc PyMem_Malloc*(size: int): Pointer {.cdecl, importc, dynlib: dllname.}
-proc PyObject_CallMethod*(obj: PPyObject, theMethod, 
-                              format: cstring): PPyObject{.cdecl, importc, dynlib: dllname.}
-proc Py_SetProgramName*(name: cstring){.cdecl, importc, dynlib: dllname.}
-proc Py_IsInitialized*(): int{.cdecl, importc, dynlib: dllname.}
-proc Py_GetProgramFullPath*(): cstring{.cdecl, importc, dynlib: dllname.}
-proc Py_NewInterpreter*(): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc Py_EndInterpreter*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyEval_AcquireLock*(){.cdecl, importc, dynlib: dllname.}
-proc PyEval_ReleaseLock*(){.cdecl, importc, dynlib: dllname.}
-proc PyEval_AcquireThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyEval_ReleaseThread*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_New*(): PPyInterpreterState{.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_Clear*(interp: PPyInterpreterState){.cdecl, importc, dynlib: dllname.}
-proc PyInterpreterState_Delete*(interp: PPyInterpreterState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_New*(interp: PPyInterpreterState): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Clear*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Delete*(tstate: PPyThreadState){.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Get*(): PPyThreadState{.cdecl, importc, dynlib: dllname.}
-proc PyThreadState_Swap*(tstate: PPyThreadState): PPyThreadState{.cdecl, importc, dynlib: dllname.} 
-
-#Further exported Objects, may be implemented later
-#
-#    PyCode_New: Pointer;
-#    PyErr_SetInterrupt: Pointer;
-#    PyFile_AsFile: Pointer;
-#    PyFile_FromFile: Pointer;
-#    PyFloat_AsString: Pointer;
-#    PyFrame_BlockPop: Pointer;
-#    PyFrame_BlockSetup: Pointer;
-#    PyFrame_ExtendStack: Pointer;
-#    PyFrame_FastToLocals: Pointer;
-#    PyFrame_LocalsToFast: Pointer;
-#    PyFrame_New: Pointer;
-#    PyGrammar_AddAccelerators: Pointer;
-#    PyGrammar_FindDFA: Pointer;
-#    PyGrammar_LabelRepr: Pointer;
-#    PyInstance_DoBinOp: Pointer;
-#    PyInt_GetMax: Pointer;
-#    PyMarshal_Init: Pointer;
-#    PyMarshal_ReadLongFromFile: Pointer;
-#    PyMarshal_ReadObjectFromFile: Pointer;
-#    PyMarshal_ReadObjectFromString: Pointer;
-#    PyMarshal_WriteLongToFile: Pointer;
-#    PyMarshal_WriteObjectToFile: Pointer;
-#    PyMember_Get: Pointer;
-#    PyMember_Set: Pointer;
-#    PyNode_AddChild: Pointer;
-#    PyNode_Compile: Pointer;
-#    PyNode_New: Pointer;
-#    PyOS_GetLastModificationTime: Pointer;
-#    PyOS_Readline: Pointer;
-#    PyOS_strtol: Pointer;
-#    PyOS_strtoul: Pointer;
-#    PyObject_CallFunction: Pointer;
-#    PyObject_CallMethod: Pointer;
-#    PyObject_Print: Pointer;
-#    PyParser_AddToken: Pointer;
-#    PyParser_Delete: Pointer;
-#    PyParser_New: Pointer;
-#    PyParser_ParseFile: Pointer;
-#    PyParser_ParseString: Pointer;
-#    PyParser_SimpleParseFile: Pointer;
-#    PyRun_AnyFile: Pointer;
-#    PyRun_File: Pointer;
-#    PyRun_InteractiveLoop: Pointer;
-#    PyRun_InteractiveOne: Pointer;
-#    PyRun_SimpleFile: Pointer;
-#    PySys_GetFile: Pointer;
-#    PyToken_OneChar: Pointer;
-#    PyToken_TwoChars: Pointer;
-#    PyTokenizer_Free: Pointer;
-#    PyTokenizer_FromFile: Pointer;
-#    PyTokenizer_FromString: Pointer;
-#    PyTokenizer_Get: Pointer;
-#    Py_Main: Pointer;
-#    _PyObject_NewVar: Pointer;
-#    _PyParser_Grammar: Pointer;
-#    _PyParser_TokenNames: Pointer;
-#    _PyThread_Started: Pointer;
-#    _Py_c_diff: Pointer;
-#    _Py_c_neg: Pointer;
-#    _Py_c_pow: Pointer;
-#    _Py_c_prod: Pointer;
-#    _Py_c_quot: Pointer;
-#    _Py_c_sum: Pointer;
-#
-
-# This function handles all cardinals, pointer types (with no adjustment of pointers!)
-# (Extended) floats, which are handled as Python doubles and currencies, handled
-# as (normalized) Python doubles.
-proc PyImport_ExecCodeModule*(name: String, codeobject: PPyObject): PPyObject
-proc PyString_Check*(obj: PPyObject): bool
-proc PyString_CheckExact*(obj: PPyObject): bool
-proc PyFloat_Check*(obj: PPyObject): bool
-proc PyFloat_CheckExact*(obj: PPyObject): bool
-proc PyInt_Check*(obj: PPyObject): bool
-proc PyInt_CheckExact*(obj: PPyObject): bool
-proc PyLong_Check*(obj: PPyObject): bool
-proc PyLong_CheckExact*(obj: PPyObject): bool
-proc PyTuple_Check*(obj: PPyObject): bool
-proc PyTuple_CheckExact*(obj: PPyObject): bool
-proc PyInstance_Check*(obj: PPyObject): bool
-proc PyClass_Check*(obj: PPyObject): bool
-proc PyMethod_Check*(obj: PPyObject): bool
-proc PyList_Check*(obj: PPyObject): bool
-proc PyList_CheckExact*(obj: PPyObject): bool
-proc PyDict_Check*(obj: PPyObject): bool
-proc PyDict_CheckExact*(obj: PPyObject): bool
-proc PyModule_Check*(obj: PPyObject): bool
-proc PyModule_CheckExact*(obj: PPyObject): bool
-proc PySlice_Check*(obj: PPyObject): bool
-proc PyFunction_Check*(obj: PPyObject): bool
-proc PyUnicode_Check*(obj: PPyObject): bool
-proc PyUnicode_CheckExact*(obj: PPyObject): bool
-proc PyType_IS_GC*(t: PPyTypeObject): bool
-proc PyObject_IS_GC*(obj: PPyObject): bool
-proc PyBool_Check*(obj: PPyObject): bool
-proc PyBaseString_Check*(obj: PPyObject): bool
-proc PyEnum_Check*(obj: PPyObject): bool
-proc PyObject_TypeCheck*(obj: PPyObject, t: PPyTypeObject): bool
-proc Py_InitModule*(name: cstring, md: PPyMethodDef): PPyObject
-proc PyType_HasFeature*(AType: PPyTypeObject, AFlag: int): bool
-# implementation
-
-proc Py_INCREF*(op: PPyObject) {.inline.} = 
-  Inc(op.ob_refcnt)
-
-proc Py_DECREF*(op: PPyObject) {.inline.} = 
-  Dec(op.ob_refcnt)
-  if op.ob_refcnt == 0: 
-    op.ob_type.tp_dealloc(op)
-
-proc Py_XINCREF*(op: PPyObject) {.inline.} = 
-  if op != nil: Py_INCREF(op)
-  
-proc Py_XDECREF*(op: PPyObject) {.inline.} = 
-  if op != nil: Py_DECREF(op)
-  
-proc PyImport_ExecCodeModule(name: string, codeobject: PPyObject): PPyObject = 
-  var m, d, v, modules: PPyObject
-  m = PyImport_AddModule(cstring(name))
-  if m == nil: 
-    return nil
-  d = PyModule_GetDict(m)
-  if PyDict_GetItemString(d, "__builtins__") == nil: 
-    if PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()) != 0: 
-      return nil
-  if PyDict_SetItemString(d, "__file__", 
-                          PPyCodeObject(codeobject).co_filename) != 0: 
-    PyErr_Clear() # Not important enough to report
-  v = PyEval_EvalCode(PPyCodeObject(codeobject), d, d) # XXX owner ?
-  if v == nil: 
-    return nil
-  Py_XDECREF(v)
-  modules = PyImport_GetModuleDict()
-  if PyDict_GetItemString(modules, cstring(name)) == nil: 
-    PyErr_SetString(PyExc_ImportError^ , cstring(
-        "Loaded module " & name & "not found in sys.modules"))
-    return nil
-  Py_XINCREF(m)
-  Result = m
-
-proc PyString_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyString_Type)
-
-proc PyString_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyString_Type)
-
-proc PyFloat_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyFloat_Type)
-
-proc PyFloat_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyFloat_Type)
-
-proc PyInt_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyInt_Type)
-
-proc PyInt_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyInt_Type)
-
-proc PyLong_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyLong_Type)
-
-proc PyLong_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyLong_Type)
-
-proc PyTuple_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyTuple_Type)
-
-proc PyTuple_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyTuple_Type)
-
-proc PyInstance_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyInstance_Type)
-
-proc PyClass_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyClass_Type)
-
-proc PyMethod_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyMethod_Type)
-
-proc PyList_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyList_Type)
-
-proc PyList_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyList_Type)
-
-proc PyDict_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyDict_Type)
-
-proc PyDict_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyDict_Type)
-
-proc PyModule_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyModule_Type)
-
-proc PyModule_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PyModule_Type)
-
-proc PySlice_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj^ .ob_type == PySlice_Type)
-
-proc PyFunction_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and
-      ((obj.ob_type == PyCFunction_Type) or
-      (obj.ob_type == PyFunction_Type))
-
-proc PyUnicode_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyUnicode_Type)
-
-proc PyUnicode_CheckExact(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyUnicode_Type)
-
-proc PyType_IS_GC(t: PPyTypeObject): bool = 
-  Result = PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC)
-
-proc PyObject_IS_GC(obj: PPyObject): bool = 
-  Result = PyType_IS_GC(obj.ob_type) and
-      ((obj.ob_type.tp_is_gc == nil) or (obj.ob_type.tp_is_gc(obj) == 1))
-
-proc PyBool_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyBool_Type)
-
-proc PyBaseString_Check(obj: PPyObject): bool = 
-  Result = PyObject_TypeCheck(obj, PyBaseString_Type)
-
-proc PyEnum_Check(obj: PPyObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == PyEnum_Type)
-
-proc PyObject_TypeCheck(obj: PPyObject, t: PPyTypeObject): bool = 
-  Result = (obj != nil) and (obj.ob_type == t)
-  if not Result and (obj != nil) and (t != nil): 
-    Result = PyType_IsSubtype(obj.ob_type, t) == 1
-  
-proc Py_InitModule(name: cstring, md: PPyMethodDef): PPyObject = 
-  result = Py_InitModule4(name, md, nil, nil, 1012)
-
-proc PyType_HasFeature(AType: PPyTypeObject, AFlag: int): bool = 
-  #(((t)->tp_flags & (f)) != 0)
-  Result = (AType.tp_flags and AFlag) != 0
-
-proc init(lib: TLibHandle) = 
-  Py_DebugFlag = cast[PInt](symAddr(lib, "Py_DebugFlag"))
-  Py_VerboseFlag = cast[PInt](symAddr(lib, "Py_VerboseFlag"))
-  Py_InteractiveFlag = cast[PInt](symAddr(lib, "Py_InteractiveFlag"))
-  Py_OptimizeFlag = cast[PInt](symAddr(lib, "Py_OptimizeFlag"))
-  Py_NoSiteFlag = cast[PInt](symAddr(lib, "Py_NoSiteFlag"))
-  Py_UseClassExceptionsFlag = cast[PInt](symAddr(lib, "Py_UseClassExceptionsFlag"))
-  Py_FrozenFlag = cast[PInt](symAddr(lib, "Py_FrozenFlag"))
-  Py_TabcheckFlag = cast[PInt](symAddr(lib, "Py_TabcheckFlag"))
-  Py_UnicodeFlag = cast[PInt](symAddr(lib, "Py_UnicodeFlag"))
-  Py_IgnoreEnvironmentFlag = cast[PInt](symAddr(lib, "Py_IgnoreEnvironmentFlag"))
-  Py_DivisionWarningFlag = cast[PInt](symAddr(lib, "Py_DivisionWarningFlag"))
-  Py_None = cast[PPyObject](symAddr(lib, "_Py_NoneStruct"))
-  Py_Ellipsis = cast[PPyObject](symAddr(lib, "_Py_EllipsisObject"))
-  Py_False = cast[PPyIntObject](symAddr(lib, "_Py_ZeroStruct"))
-  Py_True = cast[PPyIntObject](symAddr(lib, "_Py_TrueStruct"))
-  Py_NotImplemented = cast[PPyObject](symAddr(lib, "_Py_NotImplementedStruct"))
-  PyImport_FrozenModules = cast[PP_frozen](symAddr(lib, "PyImport_FrozenModules"))
-  PyExc_AttributeError = cast[PPPyObject](symAddr(lib, "PyExc_AttributeError"))
-  PyExc_EOFError = cast[PPPyObject](symAddr(lib, "PyExc_EOFError"))
-  PyExc_IOError = cast[PPPyObject](symAddr(lib, "PyExc_IOError"))
-  PyExc_ImportError = cast[PPPyObject](symAddr(lib, "PyExc_ImportError"))
-  PyExc_IndexError = cast[PPPyObject](symAddr(lib, "PyExc_IndexError"))
-  PyExc_KeyError = cast[PPPyObject](symAddr(lib, "PyExc_KeyError"))
-  PyExc_KeyboardInterrupt = cast[PPPyObject](symAddr(lib, "PyExc_KeyboardInterrupt"))
-  PyExc_MemoryError = cast[PPPyObject](symAddr(lib, "PyExc_MemoryError"))
-  PyExc_NameError = cast[PPPyObject](symAddr(lib, "PyExc_NameError"))
-  PyExc_OverflowError = cast[PPPyObject](symAddr(lib, "PyExc_OverflowError"))
-  PyExc_RuntimeError = cast[PPPyObject](symAddr(lib, "PyExc_RuntimeError"))
-  PyExc_SyntaxError = cast[PPPyObject](symAddr(lib, "PyExc_SyntaxError"))
-  PyExc_SystemError = cast[PPPyObject](symAddr(lib, "PyExc_SystemError"))
-  PyExc_SystemExit = cast[PPPyObject](symAddr(lib, "PyExc_SystemExit"))
-  PyExc_TypeError = cast[PPPyObject](symAddr(lib, "PyExc_TypeError"))
-  PyExc_ValueError = cast[PPPyObject](symAddr(lib, "PyExc_ValueError"))
-  PyExc_ZeroDivisionError = cast[PPPyObject](symAddr(lib, "PyExc_ZeroDivisionError"))
-  PyExc_ArithmeticError = cast[PPPyObject](symAddr(lib, "PyExc_ArithmeticError"))
-  PyExc_Exception = cast[PPPyObject](symAddr(lib, "PyExc_Exception"))
-  PyExc_FloatingPointError = cast[PPPyObject](symAddr(lib, "PyExc_FloatingPointError"))
-  PyExc_LookupError = cast[PPPyObject](symAddr(lib, "PyExc_LookupError"))
-  PyExc_StandardError = cast[PPPyObject](symAddr(lib, "PyExc_StandardError"))
-  PyExc_AssertionError = cast[PPPyObject](symAddr(lib, "PyExc_AssertionError"))
-  PyExc_EnvironmentError = cast[PPPyObject](symAddr(lib, "PyExc_EnvironmentError"))
-  PyExc_IndentationError = cast[PPPyObject](symAddr(lib, "PyExc_IndentationError"))
-  PyExc_MemoryErrorInst = cast[PPPyObject](symAddr(lib, "PyExc_MemoryErrorInst"))
-  PyExc_NotImplementedError = cast[PPPyObject](symAddr(lib, "PyExc_NotImplementedError"))
-  PyExc_OSError = cast[PPPyObject](symAddr(lib, "PyExc_OSError"))
-  PyExc_TabError = cast[PPPyObject](symAddr(lib, "PyExc_TabError"))
-  PyExc_UnboundLocalError = cast[PPPyObject](symAddr(lib, "PyExc_UnboundLocalError"))
-  PyExc_UnicodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeError"))
-  PyExc_Warning = cast[PPPyObject](symAddr(lib, "PyExc_Warning"))
-  PyExc_DeprecationWarning = cast[PPPyObject](symAddr(lib, "PyExc_DeprecationWarning"))
-  PyExc_RuntimeWarning = cast[PPPyObject](symAddr(lib, "PyExc_RuntimeWarning"))
-  PyExc_SyntaxWarning = cast[PPPyObject](symAddr(lib, "PyExc_SyntaxWarning"))
-  PyExc_UserWarning = cast[PPPyObject](symAddr(lib, "PyExc_UserWarning"))
-  PyExc_OverflowWarning = cast[PPPyObject](symAddr(lib, "PyExc_OverflowWarning"))
-  PyExc_ReferenceError = cast[PPPyObject](symAddr(lib, "PyExc_ReferenceError"))
-  PyExc_StopIteration = cast[PPPyObject](symAddr(lib, "PyExc_StopIteration"))
-  PyExc_FutureWarning = cast[PPPyObject](symAddr(lib, "PyExc_FutureWarning"))
-  PyExc_PendingDeprecationWarning = cast[PPPyObject](symAddr(lib, 
-      "PyExc_PendingDeprecationWarning"))
-  PyExc_UnicodeDecodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeDecodeError"))
-  PyExc_UnicodeEncodeError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeEncodeError"))
-  PyExc_UnicodeTranslateError = cast[PPPyObject](symAddr(lib, "PyExc_UnicodeTranslateError"))
-  PyType_Type = cast[PPyTypeObject](symAddr(lib, "PyType_Type"))
-  PyCFunction_Type = cast[PPyTypeObject](symAddr(lib, "PyCFunction_Type"))
-  PyCObject_Type = cast[PPyTypeObject](symAddr(lib, "PyCObject_Type"))
-  PyClass_Type = cast[PPyTypeObject](symAddr(lib, "PyClass_Type"))
-  PyCode_Type = cast[PPyTypeObject](symAddr(lib, "PyCode_Type"))
-  PyComplex_Type = cast[PPyTypeObject](symAddr(lib, "PyComplex_Type"))
-  PyDict_Type = cast[PPyTypeObject](symAddr(lib, "PyDict_Type"))
-  PyFile_Type = cast[PPyTypeObject](symAddr(lib, "PyFile_Type"))
-  PyFloat_Type = cast[PPyTypeObject](symAddr(lib, "PyFloat_Type"))
-  PyFrame_Type = cast[PPyTypeObject](symAddr(lib, "PyFrame_Type"))
-  PyFunction_Type = cast[PPyTypeObject](symAddr(lib, "PyFunction_Type"))
-  PyInstance_Type = cast[PPyTypeObject](symAddr(lib, "PyInstance_Type"))
-  PyInt_Type = cast[PPyTypeObject](symAddr(lib, "PyInt_Type"))
-  PyList_Type = cast[PPyTypeObject](symAddr(lib, "PyList_Type"))
-  PyLong_Type = cast[PPyTypeObject](symAddr(lib, "PyLong_Type"))
-  PyMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyMethod_Type"))
-  PyModule_Type = cast[PPyTypeObject](symAddr(lib, "PyModule_Type"))
-  PyObject_Type = cast[PPyTypeObject](symAddr(lib, "PyObject_Type"))
-  PyRange_Type = cast[PPyTypeObject](symAddr(lib, "PyRange_Type"))
-  PySlice_Type = cast[PPyTypeObject](symAddr(lib, "PySlice_Type"))
-  PyString_Type = cast[PPyTypeObject](symAddr(lib, "PyString_Type"))
-  PyTuple_Type = cast[PPyTypeObject](symAddr(lib, "PyTuple_Type"))
-  PyUnicode_Type = cast[PPyTypeObject](symAddr(lib, "PyUnicode_Type"))
-  PyBaseObject_Type = cast[PPyTypeObject](symAddr(lib, "PyBaseObject_Type"))
-  PyBuffer_Type = cast[PPyTypeObject](symAddr(lib, "PyBuffer_Type"))
-  PyCallIter_Type = cast[PPyTypeObject](symAddr(lib, "PyCallIter_Type"))
-  PyCell_Type = cast[PPyTypeObject](symAddr(lib, "PyCell_Type"))
-  PyClassMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyClassMethod_Type"))
-  PyProperty_Type = cast[PPyTypeObject](symAddr(lib, "PyProperty_Type"))
-  PySeqIter_Type = cast[PPyTypeObject](symAddr(lib, "PySeqIter_Type"))
-  PyStaticMethod_Type = cast[PPyTypeObject](symAddr(lib, "PyStaticMethod_Type"))
-  PySuper_Type = cast[PPyTypeObject](symAddr(lib, "PySuper_Type"))
-  PySymtableEntry_Type = cast[PPyTypeObject](symAddr(lib, "PySymtableEntry_Type"))
-  PyTraceBack_Type = cast[PPyTypeObject](symAddr(lib, "PyTraceBack_Type"))
-  PyWrapperDescr_Type = cast[PPyTypeObject](symAddr(lib, "PyWrapperDescr_Type"))
-  PyBaseString_Type = cast[PPyTypeObject](symAddr(lib, "PyBaseString_Type"))
-  PyBool_Type = cast[PPyTypeObject](symAddr(lib, "PyBool_Type"))
-  PyEnum_Type = cast[PPyTypeObject](symAddr(lib, "PyEnum_Type"))
-
-# Unfortunately we have to duplicate the loading mechanism here, because Nimrod
-# does not support variables from dynamic libraries. Well designed API's don't
-# require this anyway. Python is an exception.
-
-var
-  lib: TLibHandle
-
-when defined(windows): 
-  const
-    LibNames = ["python26.dll", "python25.dll", 
-      "python24.dll", "python23.dll", "python22.dll", "python21.dll", 
-      "python20.dll", "python16.dll", "python15.dll"]
-elif defined(macosx):
-  const
-    LibNames = ["libpython2.6.dylib", "libpython2.5.dylib", 
-      "libpython2.4.dylib", "libpython2.3.dylib", "libpython2.2.dylib", 
-      "libpython2.1.dylib", "libpython2.0.dylib",
-      "libpython1.6.dylib", "libpython1.5.dylib"]
-else: 
-  const
-    LibNames = ["libpython2.6.so" & dllver, 
-      "libpython2.5.so" & dllver, 
-      "libpython2.4.so" & dllver, 
-      "libpython2.3.so" & dllver, 
-      "libpython2.2.so" & dllver, 
-      "libpython2.1.so" & dllver, 
-      "libpython2.0.so" & dllver,
-      "libpython1.6.so" & dllver, 
-      "libpython1.5.so" & dllver]
-  
-for libName in items(libNames): 
-  lib = loadLib(libName)
-  if lib != nil: break
-
-if lib == nil: quit("could not load python library")
-init(lib)
-
diff --git a/lib/wrappers/sdl/sdl.nim b/lib/wrappers/sdl/sdl.nim
deleted file mode 100755
index a4c8273b8..000000000
--- a/lib/wrappers/sdl/sdl.nim
+++ /dev/null
@@ -1,2551 +0,0 @@
-#******************************************************************************
-#
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
-#             Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997-2004  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL.h
-#                          SDL_main.h
-#                          SDL_types.h
-#                          SDL_rwops.h
-#                          SDL_timer.h
-#                          SDL_audio.h
-#                          SDL_cdrom.h
-#                          SDL_joystick.h
-#                          SDL_mouse.h
-#                          SDL_keyboard.h
-#                          SDL_events.h
-#                          SDL_video.h
-#                          SDL_byteorder.h
-#                          SDL_version.h
-#                          SDL_active.h
-#                          SDL_thread.h
-#                          SDL_mutex .h
-#                          SDL_getenv.h
-#                          SDL_loadso.h
-#
-# The initial developer of this Pascal code was :
-# Dominique Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominique Louis are
-# Copyright (C) 2000 - 2004 Dominique Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so
-#   They are available from...
-#   http://www.libsdl.org .
-#
-# Programming Notes
-# -----------------
-#
-#
-#
-#
-# Revision History
-# ----------------
-#   May      08 2001 - DL : Added Keyboard  State Array ( See demos for how to
-#                           use )
-#                           PKeyStateArr = ^TKeyStateArr;
-#                           TKeyStateArr = array[0..65000] of byte;
-#                           As most games will need it.
-#
-#   April    02 2001 - DL : Added SDL_getenv.h definitions and tested version
-#                           1.2.0 compatability.
-#
-#   March    13 2001 - MT : Added Linux compatibility.
-#
-#   March    10 2001 - MT : Added externalsyms for DEFINES
-#                           Changed the license header
-#
-#   March    09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem
-#
-#   March    01 2001 - DL : Update conversion of version 1.1.8
-#
-#   July     22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions
-#                           from Matthias Thoma and Eric Grange.
-#
-#   October  12 2001 - DL : Various changes as suggested by Matthias Thoma and
-#                           David Acklam
-#
-#   October  24 2001 - DL : Added FreePascal support as per suggestions from
-#                           Dean Ellis.
-#
-#   October  27 2001 - DL : Added SDL_BUTTON macro
-#
-#  November  08 2001 - DL : Bug fix as pointed out by Puthoon.
-#
-#  November  29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon
-#                           Rushton.
-#
-#  November  30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton.
-#
-#  December  11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in
-#                           Components
-#
-#  January   05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias
-#                           Thoma and also made sure the _getenv from
-#                           MSVCRT.DLL uses the right calling convention
-#
-#  January   25 2002 - DL : Updated conversion of SDL_AddTimer &
-#                           SDL_RemoveTimer as per suggestions from Matthias
-#                           Thoma.
-#
-#  January   27 2002 - DL : Commented out exported function putenv and getenv
-#                           So that developers get used to using SDL_putenv
-#                           SDL_getenv, as they are more portable
-#
-#  March     05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users.
-#
-#  October   23 2002 - DL : Added Delphi 3 Define of Win32.
-#                           If you intend to you Delphi 3...
-#                           ( which is officially unsupported ) make sure you
-#                           remove references to $EXTERNALSYM in this and other
-#                           SDL files.
-#
-# November  29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was
-#                          pointed out by Todd Lang
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#
-#  Revision 1.31  2007/05/29 21:30:48  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.30  2007/05/29 19:31:03  savage
-#  Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold)
-#
-#  Revision 1.29  2007/05/20 20:29:11  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.26  2007/02/11 13:38:04  savage
-#  Added Nintendo DS support - Thanks Dean.
-#
-#  Revision 1.25  2006/12/02 00:12:52  savage
-#  Updated to latest version
-#
-#  Revision 1.24  2006/05/18 21:10:04  savage
-#  Added 1.2.10 Changes
-#
-#  Revision 1.23  2005/12/04 23:17:52  drellis
-#  Added declaration of SInt8 and PSInt8
-#
-#  Revision 1.22  2005/05/24 21:59:03  savage
-#  Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis.
-#
-#  Revision 1.21  2005/05/22 18:42:31  savage
-#  Changes as suggested by Michalis Kamburelis. Thanks again.
-#
-#  Revision 1.20  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.19  2005/01/05 01:47:06  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.18  2005/01/04 23:14:41  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.17  2005/01/03 18:40:59  savage
-#  Updated Version number to reflect latest one
-#
-#  Revision 1.16  2005/01/01 02:02:06  savage
-#  Updated to v1.2.8
-#
-#  Revision 1.15  2004/12/24 18:57:11  savage
-#  forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
-#
-#  Revision 1.14  2004/12/23 23:42:18  savage
-#  Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
-#
-#  Revision 1.13  2004/09/30 22:31:59  savage
-#  Updated with slightly different header comments
-#
-#  Revision 1.12  2004/09/12 21:52:58  savage
-#  Slight changes to fix some issues with the sdl classes.
-#
-#  Revision 1.11  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.10  2004/07/20 23:57:33  savage
-#  Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
-#  In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
-#
-#  Revision 1.9  2004/07/03 22:07:22  savage
-#  Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
-#
-#  Revision 1.8  2004/05/10 14:10:03  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.7  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.6  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.5  2004/02/22 15:32:10  savage
-#  SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
-#
-#  Revision 1.4  2004/02/21 23:24:29  savage
-#  SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
-#
-#  Revision 1.3  2004/02/18 22:35:51  savage
-#  Brought sdl.pas up to 1.2.7 compatability
-#  Thus...
-#  Added SDL_GL_STEREO,
-#      SDL_GL_MULTISAMPLEBUFFERS,
-#      SDL_GL_MULTISAMPLESAMPLES
-#
-#  Add DLL/Shared object functions
-#  function SDL_LoadObject( const sofile : PChar ) : Pointer;
-#
-#  function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
-#
-#  procedure SDL_UnloadObject( handle : Pointer );
-#
-#  Added function to create RWops from const memory: SDL_RWFromConstMem()
-#  function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
-#
-#  Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
-#
-#  Revision 1.2  2004/02/17 21:37:12  savage
-#  Tidying up of units
-#
-#  Revision 1.1  2004/02/05 00:08:20  savage
-#  Module 1.0 release
-#
-#
-
-{.deadCodeElim: on.}
-when defined(windows): 
-  const 
-    LibName = "SDL.dll"
-elif defined(macosx): 
-  const 
-    LibName = "libSDL-1.2.0.dylib"
-else: 
-  const 
-    LibName = "libSDL.so"
-const 
-  MAJOR_VERSION* = 1'i8
-  MINOR_VERSION* = 2'i8
-  PATCHLEVEL* = 11'i8         # SDL.h constants
-  INIT_TIMER* = 0x00000001
-  INIT_AUDIO* = 0x00000010
-  INIT_VIDEO* = 0x00000020
-  INIT_CDROM* = 0x00000100
-  INIT_JOYSTICK* = 0x00000200
-  INIT_NOPARACHUTE* = 0x00100000 # Don't catch fatal signals
-  INIT_EVENTTHREAD* = 0x01000000 # Not supported on all OS's
-  INIT_EVERYTHING* = 0x0000FFFF # SDL_error.h constants
-  ERR_MAX_STRLEN* = 128
-  ERR_MAX_ARGS* = 5           # SDL_types.h constants
-  PRESSED* = 0x00000001
-  RELEASED* = 0x00000000      # SDL_timer.h constants
-                              # This is the OS scheduler timeslice, in milliseconds
-  TIMESLICE* = 10             # This is the maximum resolution of the SDL timer on all platforms
-  TIMER_RESOLUTION* = 10      # Experimentally determined
-                              # SDL_audio.h constants
-  AUDIO_U8* = 0x00000008      # Unsigned 8-bit samples
-  AUDIO_S8* = 0x00008008      # Signed 8-bit samples
-  AUDIO_U16LSB* = 0x00000010  # Unsigned 16-bit samples
-  AUDIO_S16LSB* = 0x00008010  # Signed 16-bit samples
-  AUDIO_U16MSB* = 0x00001010  # As above, but big-endian byte order
-  AUDIO_S16MSB* = 0x00009010  # As above, but big-endian byte order
-  AUDIO_U16* = AUDIO_U16LSB
-  AUDIO_S16* = AUDIO_S16LSB   # SDL_cdrom.h constants
-                              # The maximum number of CD-ROM tracks on a disk
-  MAX_TRACKS* = 99            # The types of CD-ROM track possible
-  AUDIO_TRACK* = 0x00000000
-  DATA_TRACK* = 0x00000004    # Conversion functions from frames to Minute/Second/Frames and vice versa
-  CD_FPS* = 75                # SDL_byteorder.h constants
-                              # The two types of endianness
-  LIL_ENDIAN* = 1234
-  BIG_ENDIAN* = 4321
-
-when cpuEndian == littleEndian: 
-  const 
-    BYTEORDER* = LIL_ENDIAN   # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16LSB
-    AUDIO_S16SYS* = AUDIO_S16LSB
-else: 
-  const 
-    BYTEORDER* = BIG_ENDIAN   # Native audio byte ordering
-    AUDIO_U16SYS* = AUDIO_U16MSB
-    AUDIO_S16SYS* = AUDIO_S16MSB
-const 
-  MIX_MAXVOLUME* = 128        # SDL_joystick.h constants
-  MAX_JOYSTICKS* = 2          # only 2 are supported in the multimedia API
-  MAX_AXES* = 6               # each joystick can have up to 6 axes
-  MAX_BUTTONS* = 32           # and 32 buttons
-  AXIS_MIN* = - 32768         # minimum value for axis coordinate
-  AXIS_MAX* = 32767           # maximum value for axis coordinate
-  JOY_AXIS_THRESHOLD* = (toFloat((AXIS_MAX) - (AXIS_MIN)) / 100.000) # 1% motion
-  HAT_CENTERED* = 0x00000000
-  HAT_UP* = 0x00000001
-  HAT_RIGHT* = 0x00000002
-  HAT_DOWN* = 0x00000004
-  HAT_LEFT* = 0x00000008
-  HAT_RIGHTUP* = HAT_RIGHT or HAT_UP
-  HAT_RIGHTDOWN* = HAT_RIGHT or HAT_DOWN
-  HAT_LEFTUP* = HAT_LEFT or HAT_UP
-  HAT_LEFTDOWN* = HAT_LEFT or HAT_DOWN # SDL_events.h constants
-
-type 
-  TEventKind* = enum          # kind of an SDL event
-    NOEVENT = 0,              # Unused (do not remove)
-    ACTIVEEVENT = 1,          # Application loses/gains visibility
-    KEYDOWN = 2,              # Keys pressed
-    KEYUP = 3,                # Keys released
-    MOUSEMOTION = 4,          # Mouse moved
-    MOUSEBUTTONDOWN = 5,      # Mouse button pressed
-    MOUSEBUTTONUP = 6,        # Mouse button released
-    JOYAXISMOTION = 7,        # Joystick axis motion
-    JOYBALLMOTION = 8,        # Joystick trackball motion
-    JOYHATMOTION = 9,         # Joystick hat position change
-    JOYBUTTONDOWN = 10,       # Joystick button pressed
-    JOYBUTTONUP = 11,         # Joystick button released
-    QUITEV = 12,              # User-requested quit ( Changed due to procedure conflict )
-    SYSWMEVENT = 13,          # System specific event
-    EVENT_RESERVEDA = 14,     # Reserved for future use..
-    EVENT_RESERVED = 15,      # Reserved for future use..
-    VIDEORESIZE = 16,         # User resized video mode
-    VIDEOEXPOSE = 17,         # Screen needs to be redrawn
-    EVENT_RESERVED2 = 18,     # Reserved for future use..
-    EVENT_RESERVED3 = 19,     # Reserved for future use..
-    EVENT_RESERVED4 = 20,     # Reserved for future use..
-    EVENT_RESERVED5 = 21,     # Reserved for future use..
-    EVENT_RESERVED6 = 22,     # Reserved for future use..
-    EVENT_RESERVED7 = 23,     # Reserved for future use..
-                              # Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
-    USEREVENT = 24 # This last event is only for bounding internal arrays
-                   # It is the number of bits in the event mask datatype -- int32
-
-const 
-  NUMEVENTS* = 32
-  ALLEVENTS* = 0xFFFFFFFF
-  ACTIVEEVENTMASK* = 1 shl ord(ACTIVEEVENT)
-  KEYDOWNMASK* = 1 shl ord(KEYDOWN)
-  KEYUPMASK* = 1 shl ord(KEYUP)
-  MOUSEMOTIONMASK* = 1 shl ord(MOUSEMOTION)
-  MOUSEBUTTONDOWNMASK* = 1 shl ord(MOUSEBUTTONDOWN)
-  MOUSEBUTTONUPMASK* = 1 shl ord(MOUSEBUTTONUP)
-  MOUSEEVENTMASK* = 1 shl ord(MOUSEMOTION) or 1 shl ord(MOUSEBUTTONDOWN) or
-      1 shl ord(MOUSEBUTTONUP)
-  JOYAXISMOTIONMASK* = 1 shl ord(JOYAXISMOTION)
-  JOYBALLMOTIONMASK* = 1 shl ord(JOYBALLMOTION)
-  JOYHATMOTIONMASK* = 1 shl ord(JOYHATMOTION)
-  JOYBUTTONDOWNMASK* = 1 shl ord(JOYBUTTONDOWN)
-  JOYBUTTONUPMASK* = 1 shl ord(JOYBUTTONUP)
-  JOYEVENTMASK* = 1 shl ord(JOYAXISMOTION) or 1 shl ord(JOYBALLMOTION) or
-      1 shl ord(JOYHATMOTION) or 1 shl ord(JOYBUTTONDOWN) or
-      1 shl ord(JOYBUTTONUP)
-  VIDEORESIZEMASK* = 1 shl ord(VIDEORESIZE)
-  QUITMASK* = 1 shl ord(QUITEV)
-  SYSWMEVENTMASK* = 1 shl ord(SYSWMEVENT)
-  QUERY* = - 1
-  IGNORE* = 0
-  DISABLE* = 0
-  ENABLE* = 1                 #SDL_keyboard.h constants
-                              # This is the mask which refers to all hotkey bindings
-  ALL_HOTKEYS* = 0xFFFFFFFF # Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
-                            #  'delay' is the initial delay in ms between the time when a key is
-                            #  pressed, and keyboard repeat begins.
-                            #  'interval' is the time in ms between keyboard repeat events.
-  DEFAULT_REPEAT_DELAY* = 500
-  DEFAULT_REPEAT_INTERVAL* = 30 # The keyboard syms have been cleverly chosen to map to ASCII
-  K_UNKNOWN* = 0
-  K_FIRST* = 0
-  K_BACKSPACE* = 8
-  K_TAB* = 9
-  K_CLEAR* = 12
-  K_RETURN* = 13
-  K_PAUSE* = 19
-  K_ESCAPE* = 27
-  K_SPACE* = 32
-  K_EXCLAIM* = 33
-  K_QUOTEDBL* = 34
-  K_HASH* = 35
-  K_DOLLAR* = 36
-  K_AMPERSAND* = 38
-  K_QUOTE* = 39
-  K_LEFTPAREN* = 40
-  K_RIGHTPAREN* = 41
-  K_ASTERISK* = 42
-  K_PLUS* = 43
-  K_COMMA* = 44
-  K_MINUS* = 45
-  K_PERIOD* = 46
-  K_SLASH* = 47
-  K_0* = 48
-  K_1* = 49
-  K_2* = 50
-  K_3* = 51
-  K_4* = 52
-  K_5* = 53
-  K_6* = 54
-  K_7* = 55
-  K_8* = 56
-  K_9* = 57
-  K_COLON* = 58
-  K_SEMICOLON* = 59
-  K_LESS* = 60
-  K_EQUALS* = 61
-  K_GREATER* = 62
-  K_QUESTION* = 63
-  K_AT* = 64                  # Skip uppercase letters
-  K_LEFTBRACKET* = 91
-  K_BACKSLASH* = 92
-  K_RIGHTBRACKET* = 93
-  K_CARET* = 94
-  K_UNDERSCORE* = 95
-  K_BACKQUOTE* = 96
-  K_a* = 97
-  K_b* = 98
-  K_c* = 99
-  K_d* = 100
-  K_e* = 101
-  K_f* = 102
-  K_g* = 103
-  K_h* = 104
-  K_i* = 105
-  K_j* = 106
-  K_k* = 107
-  K_l* = 108
-  K_m* = 109
-  K_n* = 110
-  K_o* = 111
-  K_p* = 112
-  K_q* = 113
-  K_r* = 114
-  K_s* = 115
-  K_t* = 116
-  K_u* = 117
-  K_v* = 118
-  K_w* = 119
-  K_x* = 120
-  K_y* = 121
-  K_z* = 122
-  K_DELETE* = 127             # End of ASCII mapped keysyms
-                              # International keyboard syms
-  K_WORLD_0* = 160            # 0xA0
-  K_WORLD_1* = 161
-  K_WORLD_2* = 162
-  K_WORLD_3* = 163
-  K_WORLD_4* = 164
-  K_WORLD_5* = 165
-  K_WORLD_6* = 166
-  K_WORLD_7* = 167
-  K_WORLD_8* = 168
-  K_WORLD_9* = 169
-  K_WORLD_10* = 170
-  K_WORLD_11* = 171
-  K_WORLD_12* = 172
-  K_WORLD_13* = 173
-  K_WORLD_14* = 174
-  K_WORLD_15* = 175
-  K_WORLD_16* = 176
-  K_WORLD_17* = 177
-  K_WORLD_18* = 178
-  K_WORLD_19* = 179
-  K_WORLD_20* = 180
-  K_WORLD_21* = 181
-  K_WORLD_22* = 182
-  K_WORLD_23* = 183
-  K_WORLD_24* = 184
-  K_WORLD_25* = 185
-  K_WORLD_26* = 186
-  K_WORLD_27* = 187
-  K_WORLD_28* = 188
-  K_WORLD_29* = 189
-  K_WORLD_30* = 190
-  K_WORLD_31* = 191
-  K_WORLD_32* = 192
-  K_WORLD_33* = 193
-  K_WORLD_34* = 194
-  K_WORLD_35* = 195
-  K_WORLD_36* = 196
-  K_WORLD_37* = 197
-  K_WORLD_38* = 198
-  K_WORLD_39* = 199
-  K_WORLD_40* = 200
-  K_WORLD_41* = 201
-  K_WORLD_42* = 202
-  K_WORLD_43* = 203
-  K_WORLD_44* = 204
-  K_WORLD_45* = 205
-  K_WORLD_46* = 206
-  K_WORLD_47* = 207
-  K_WORLD_48* = 208
-  K_WORLD_49* = 209
-  K_WORLD_50* = 210
-  K_WORLD_51* = 211
-  K_WORLD_52* = 212
-  K_WORLD_53* = 213
-  K_WORLD_54* = 214
-  K_WORLD_55* = 215
-  K_WORLD_56* = 216
-  K_WORLD_57* = 217
-  K_WORLD_58* = 218
-  K_WORLD_59* = 219
-  K_WORLD_60* = 220
-  K_WORLD_61* = 221
-  K_WORLD_62* = 222
-  K_WORLD_63* = 223
-  K_WORLD_64* = 224
-  K_WORLD_65* = 225
-  K_WORLD_66* = 226
-  K_WORLD_67* = 227
-  K_WORLD_68* = 228
-  K_WORLD_69* = 229
-  K_WORLD_70* = 230
-  K_WORLD_71* = 231
-  K_WORLD_72* = 232
-  K_WORLD_73* = 233
-  K_WORLD_74* = 234
-  K_WORLD_75* = 235
-  K_WORLD_76* = 236
-  K_WORLD_77* = 237
-  K_WORLD_78* = 238
-  K_WORLD_79* = 239
-  K_WORLD_80* = 240
-  K_WORLD_81* = 241
-  K_WORLD_82* = 242
-  K_WORLD_83* = 243
-  K_WORLD_84* = 244
-  K_WORLD_85* = 245
-  K_WORLD_86* = 246
-  K_WORLD_87* = 247
-  K_WORLD_88* = 248
-  K_WORLD_89* = 249
-  K_WORLD_90* = 250
-  K_WORLD_91* = 251
-  K_WORLD_92* = 252
-  K_WORLD_93* = 253
-  K_WORLD_94* = 254
-  K_WORLD_95* = 255           # 0xFF
-                              # Numeric keypad
-  K_KP0* = 256
-  K_KP1* = 257
-  K_KP2* = 258
-  K_KP3* = 259
-  K_KP4* = 260
-  K_KP5* = 261
-  K_KP6* = 262
-  K_KP7* = 263
-  K_KP8* = 264
-  K_KP9* = 265
-  K_KP_PERIOD* = 266
-  K_KP_DIVIDE* = 267
-  K_KP_MULTIPLY* = 268
-  K_KP_MINUS* = 269
-  K_KP_PLUS* = 270
-  K_KP_ENTER* = 271
-  K_KP_EQUALS* = 272          # Arrows + Home/End pad
-  K_UP* = 273
-  K_DOWN* = 274
-  K_RIGHT* = 275
-  K_LEFT* = 276
-  K_INSERT* = 277
-  K_HOME* = 278
-  K_END* = 279
-  K_PAGEUP* = 280
-  K_PAGEDOWN* = 281           # Function keys
-  K_F1* = 282
-  K_F2* = 283
-  K_F3* = 284
-  K_F4* = 285
-  K_F5* = 286
-  K_F6* = 287
-  K_F7* = 288
-  K_F8* = 289
-  K_F9* = 290
-  K_F10* = 291
-  K_F11* = 292
-  K_F12* = 293
-  K_F13* = 294
-  K_F14* = 295
-  K_F15* = 296                # Key state modifier keys
-  K_NUMLOCK* = 300
-  K_CAPSLOCK* = 301
-  K_SCROLLOCK* = 302
-  K_RSHIFT* = 303
-  K_LSHIFT* = 304
-  K_RCTRL* = 305
-  K_LCTRL* = 306
-  K_RALT* = 307
-  K_LALT* = 308
-  K_RMETA* = 309
-  K_LMETA* = 310
-  K_LSUPER* = 311             # Left "Windows" key
-  K_RSUPER* = 312             # Right "Windows" key
-  K_MODE* = 313               # "Alt Gr" key
-  K_COMPOSE* = 314            # Multi-key compose key
-                              # Miscellaneous function keys
-  K_HELP* = 315
-  K_PRINT* = 316
-  K_SYSREQ* = 317
-  K_BREAK* = 318
-  K_MENU* = 319
-  K_POWER* = 320              # Power Macintosh power key
-  K_EURO* = 321               # Some european keyboards
-  K_GP2X_UP* = 0
-  K_GP2X_UPLEFT* = 1
-  K_GP2X_LEFT* = 2
-  K_GP2X_DOWNLEFT* = 3
-  K_GP2X_DOWN* = 4
-  K_GP2X_DOWNRIGHT* = 5
-  K_GP2X_RIGHT* = 6
-  K_GP2X_UPRIGHT* = 7
-  K_GP2X_START* = 8
-  K_GP2X_SELECT* = 9
-  K_GP2X_L* = 10
-  K_GP2X_R* = 11
-  K_GP2X_A* = 12
-  K_GP2X_B* = 13
-  K_GP2X_Y* = 14
-  K_GP2X_X* = 15
-  K_GP2X_VOLUP* = 16
-  K_GP2X_VOLDOWN* = 17
-  K_GP2X_CLICK* = 18
-
-const                         # Enumeration of valid key mods (possibly OR'd together)
-  KMOD_NONE* = 0x00000000
-  KMOD_LSHIFT* = 0x00000001
-  KMOD_RSHIFT* = 0x00000002
-  KMOD_LCTRL* = 0x00000040
-  KMOD_RCTRL* = 0x00000080
-  KMOD_LALT* = 0x00000100
-  KMOD_RALT* = 0x00000200
-  KMOD_LMETA* = 0x00000400
-  KMOD_RMETA* = 0x00000800
-  KMOD_NUM* = 0x00001000
-  KMOD_CAPS* = 0x00002000
-  KMOD_MODE* = 44000
-  KMOD_RESERVED* = 0x00008000
-  KMOD_CTRL* = (KMOD_LCTRL or KMOD_RCTRL)
-  KMOD_SHIFT* = (KMOD_LSHIFT or KMOD_RSHIFT)
-  KMOD_ALT* = (KMOD_LALT or KMOD_RALT)
-  KMOD_META* = (KMOD_LMETA or KMOD_RMETA) #SDL_video.h constants
-                                          # Transparency definitions: These define alpha as the opacity of a surface */
-  ALPHA_OPAQUE* = 255
-  ALPHA_TRANSPARENT* = 0 # These are the currently supported flags for the SDL_surface
-                         # Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
-  SWSURFACE* = 0x00000000     # Surface is in system memory
-  HWSURFACE* = 0x00000001     # Surface is in video memory
-  ASYNCBLIT* = 0x00000004     # Use asynchronous blits if possible
-                              # Available for SDL_SetVideoMode()
-  ANYFORMAT* = 0x10000000     # Allow any video depth/pixel-format
-  HWPALETTE* = 0x20000000     # Surface has exclusive palette
-  DOUBLEBUF* = 0x40000000     # Set up double-buffered video mode
-  FULLSCREEN* = 0x80000000    # Surface is a full screen display
-  OPENGL* = 0x00000002        # Create an OpenGL rendering context
-  OPENGLBLIT* = 0x00000002    # Create an OpenGL rendering context
-  RESIZABLE* = 0x00000010     # This video mode may be resized
-  NOFRAME* = 0x00000020       # No window caption or edge frame
-                              # Used internally (read-only)
-  HWACCEL* = 0x00000100       # Blit uses hardware acceleration
-  SRCCOLORKEY* = 0x00001000   # Blit uses a source color key
-  RLEACCELOK* = 0x00002000    # Private flag
-  RLEACCEL* = 0x00004000      # Colorkey blit is RLE accelerated
-  SRCALPHA* = 0x00010000      # Blit uses source alpha blending
-  SRCCLIPPING* = 0x00100000   # Blit uses source clipping
-  PREALLOC* = 0x01000000 # Surface uses preallocated memory
-                         # The most common video overlay formats.
-                         #    For an explanation of these pixel formats, see:
-                         #    http://www.webartz.com/fourcc/indexyuv.htm
-                         #
-                         #   For information on the relationship between color spaces, see:
-                         #
-                         #   
-                         #   http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
-  YV12_OVERLAY* = 0x32315659  # Planar mode: Y + V + U  (3 planes)
-  IYUV_OVERLAY* = 0x56555949  # Planar mode: Y + U + V  (3 planes)
-  YUY2_OVERLAY* = 0x32595559  # Packed mode: Y0+U0+Y1+V0 (1 plane)
-  UYVY_OVERLAY* = 0x59565955  # Packed mode: U0+Y0+V0+Y1 (1 plane)
-  YVYU_OVERLAY* = 0x55595659  # Packed mode: Y0+V0+Y1+U0 (1 plane)
-                              # flags for SDL_SetPalette()
-  LOGPAL* = 0x00000001
-  PHYSPAL* = 0x00000002 #SDL_mouse.h constants
-                        # Used as a mask when testing buttons in buttonstate
-                        #    Button 1:	Left mouse button
-                        #    Button 2:	Middle mouse button
-                        #    Button 3:	Right mouse button
-                        #    Button 4:	Mouse Wheel Up
-                        #    Button 5:	Mouse Wheel Down
-                        #
-  BUTTON_LEFT* = 1
-  BUTTON_MIDDLE* = 2
-  BUTTON_RIGHT* = 3
-  BUTTON_WHEELUP* = 4
-  BUTTON_WHEELDOWN* = 5
-  BUTTON_LMASK* = PRESSED shl (BUTTON_LEFT - 1)
-  BUTTON_MMASK* = PRESSED shl (BUTTON_MIDDLE - 1)
-  BUTTON_RMask* = PRESSED shl (BUTTON_RIGHT - 1) # SDL_active.h constants
-                                                 # The available application states
-  APPMOUSEFOCUS* = 0x00000001 # The app has mouse coverage
-  APPINPUTFOCUS* = 0x00000002 # The app has input focus
-  APPACTIVE* = 0x00000004 # The application is active
-                          # SDL_mutex.h constants
-                          # Synchronization functions which can time out return this value
-                          #  they time out.
-  MUTEX_TIMEDOUT* = 1         # This is the timeout value which corresponds to never time out
-  MUTEX_MAXWAIT* = not int(0)
-  GRAB_QUERY* = - 1
-  GRAB_OFF* = 0
-  GRAB_ON* = 1                #SDL_GRAB_FULLSCREEN // Used internally
-
-type 
-  THandle* = int              #SDL_types.h types
-                              # Basic data types
-  TBool* = enum 
-    sdlFALSE, sdlTRUE
-  PUInt8Array* = ptr TUInt8Array
-  TUInt8Array* = array[0..high(int) shr 1, byte]
-  PUInt16* = ptr UInt16
-  UInt16* = int16
-  PUInt32* = ptr int32
-  UInt32* = int32
-  PUInt64* = ptr UInt64
-  UInt64*{.final.} = object 
-    hi*: int32
-    lo*: int32
-
-  PSInt64* = ptr SInt64
-  SInt64*{.final.} = object 
-    hi*: int32
-    lo*: int32
-
-  TGrabMode* = int32         # SDL_error.h types
-  Terrorcode* = enum 
-    ENOMEM, EFREAD, EFWRITE, EFSEEK, LASTERROR
-  errorcode* = Terrorcode
-  TArg*{.final.} = object 
-    buf*: array[0..ERR_MAX_STRLEN - 1, int8]
-
-  Perror* = ptr Terror
-  Terror*{.final.} = object  # This is a numeric value corresponding to the current error
-                             # SDL_rwops.h types
-                             # This is the read/write operation structure -- very basic
-                             # some helper types to handle the unions
-                             # "packed" is only guessed
-    error*: int # This is a key used to index into a language hashtable containing
-                #       internationalized versions of the SDL error messages.  If the key
-                #       is not in the hashtable, or no hashtable is available, the key is
-                #       used directly as an error message format string.
-    key*: array[0..ERR_MAX_STRLEN - 1, int8] # These are the arguments for the error functions
-    argc*: int
-    args*: array[0..ERR_MAX_ARGS - 1, TArg]
-
-  TStdio*{.final.} = object 
-    autoclose*: int           # FILE * is only defined in Kylix so we use a simple Pointer
-    fp*: Pointer
-
-  TMem*{.final.} = object 
-    base*: ptr byte
-    here*: ptr byte
-    stop*: ptr byte
-
-  PRWops* = ptr TRWops        # now the pointer to function types
-  TSeek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.}
-  TRead* = proc (context: PRWops, thePtr: Pointer, size: int, maxnum: int): int{.
-      cdecl.}
-  TWrite* = proc (context: PRWops, thePtr: Pointer, size: int, num: int): int{.
-      cdecl.}
-  TClose* = proc (context: PRWops): int{.cdecl.} # the variant record itself
-  TRWops*{.final.} = object 
-    seek*: TSeek
-    read*: TRead
-    write*: TWrite
-    closeFile*: TClose        # a keyword as name is not allowed
-                              # be warned! structure alignment may arise at this point
-    theType*: cint
-    mem*: TMem
-  
-  RWops* = TRWops             # SDL_timer.h types
-                              # Function prototype for the timer callback function
-  TTimerCallback* = proc (interval: int32): int32{.cdecl.}
-  TNewTimerCallback* = proc (interval: int32, param: Pointer): int32{.cdecl.}
-
-  PTimerID* = ptr TTimerID
-  TTimerID*{.final.} = object 
-    interval*: int32
-    callback*: TNewTimerCallback
-    param*: Pointer
-    last_alarm*: int32
-    next*: PTimerID
-
-  TAudioSpecCallback* = proc (userdata: Pointer, stream: ptr byte, length: int){.
-      cdecl.}                 # SDL_audio.h types
-                              # The calculated values in this structure are calculated by SDL_OpenAudio()
-  PAudioSpec* = ptr TAudioSpec
-  TAudioSpec*{.final.} = object  # A structure to hold a set of audio conversion filters and buffers
-    freq*: int                # DSP frequency -- samples per second
-    format*: UInt16           # Audio data format
-    channels*: byte          # Number of channels: 1 mono, 2 stereo
-    silence*: byte           # Audio buffer silence value (calculated)
-    samples*: UInt16          # Audio buffer size in samples
-    padding*: UInt16          # Necessary for some compile environments
-    size*: int32 # Audio buffer size in bytes (calculated)
-                 # This function is called when the audio device needs more data.
-                 # 'stream' is a pointer to the audio data buffer
-                 # 'len' is the length of that buffer in bytes.
-                 # Once the callback returns, the buffer will no longer be valid.
-                 # Stereo samples are stored in a LRLRLR ordering.
-    callback*: TAudioSpecCallback
-    userdata*: Pointer
-
-  PAudioCVT* = ptr TAudioCVT
-  PAudioCVTFilter* = ptr TAudioCVTFilter
-  TAudioCVTFilter*{.final.} = object 
-    cvt*: PAudioCVT
-    format*: UInt16
-
-  PAudioCVTFilterArray* = ptr TAudioCVTFilterArray
-  TAudioCVTFilterArray* = array[0..9, PAudioCVTFilter]
-  TAudioCVT*{.final.} = object 
-    needed*: int              # Set to 1 if conversion possible
-    src_format*: UInt16       # Source audio format
-    dst_format*: UInt16       # Target audio format
-    rate_incr*: float64       # Rate conversion increment
-    buf*: ptr byte              # Buffer to hold entire audio data
-    length*: int              # Length of original audio buffer
-    len_cvt*: int             # Length of converted audio buffer
-    len_mult*: int            # buffer must be len*len_mult big
-    len_ratio*: float64       # Given len, final size is len*len_ratio
-    filters*: TAudioCVTFilterArray
-    filter_index*: int        # Current audio conversion function
-  
-  TAudiostatus* = enum        # SDL_cdrom.h types
-    AUDIO_STOPPED, AUDIO_PLAYING, AUDIO_PAUSED
-  TCDStatus* = enum 
-    CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED
-  PCDTrack* = ptr TCDTrack
-  TCDTrack*{.final.} = object  # This structure is only current as of the last call to SDL_CDStatus()
-    id*: byte                # Track number
-    theType*: byte           # Data or audio track
-    unused*: UInt16
-    len*: int32              # Length, in frames, of this track
-    offset*: int32           # Offset, in frames, from start of disk
-  
-  PCD* = ptr TCD
-  TCD*{.final.} = object      #SDL_joystick.h types
-    id*: int                  # Private drive identifier
-    status*: TCDStatus        # Current drive status
-                              # The rest of this structure is only valid if there's a CD in drive
-    numtracks*: int           # Number of tracks on disk
-    cur_track*: int           # Current track position
-    cur_frame*: int           # Current frame offset within current track
-    track*: array[0..MAX_TRACKS, TCDTrack]
-
-  PTransAxis* = ptr TTransAxis
-  TTransAxis*{.final.} = object  # The private structure used to keep track of a joystick
-    offset*: int
-    scale*: float32
-
-  PJoystick_hwdata* = ptr TJoystick_hwdata
-  TJoystick_hwdata*{.final.} = object  # joystick ID
-    id*: int                  # values used to translate device-specific coordinates into  SDL-standard ranges
-    transaxis*: array[0..5, TTransAxis]
-
-  PBallDelta* = ptr TBallDelta
-  TBallDelta*{.final.} = object  # Current ball motion deltas
-                                 # The SDL joystick structure
-    dx*: int
-    dy*: int
-
-  PJoystick* = ptr TJoystick
-  TJoystick*{.final.} = object  # SDL_verion.h types
-    index*: byte             # Device index
-    name*: cstring            # Joystick name - system dependent
-    naxes*: int               # Number of axis controls on the joystick
-    axes*: PUInt16            # Current axis states
-    nhats*: int               # Number of hats on the joystick
-    hats*: ptr byte             # Current hat states
-    nballs*: int              # Number of trackballs on the joystick
-    balls*: PBallDelta        # Current ball motion deltas
-    nbuttons*: int            # Number of buttons on the joystick
-    buttons*: ptr byte          # Current button states
-    hwdata*: PJoystick_hwdata # Driver dependent information
-    ref_count*: int           # Reference count for multiple opens
-  
-  Pversion* = ptr Tversion
-  Tversion*{.final.} = object  # SDL_keyboard.h types
-    major*: byte
-    minor*: byte
-    patch*: byte
-
-  TKey* = int32
-  TMod* = int32
-  PKeySym* = ptr TKeySym
-  TKeySym*{.final.} = object  # SDL_events.h types
-                              #Checks the event queue for messages and optionally returns them.
-                              #   If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-                              #   the back of the event queue.
-                              #   If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-                              #   of the event queue, matching 'mask', will be returned and will not
-                              #   be removed from the queue.
-                              #   If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-                              #   of the event queue, matching 'mask', will be returned and will be
-                              #   removed from the queue.
-                              #   This function returns the number of events actually stored, or -1
-                              #   if there was an error.  This function is thread-safe.
-    scancode*: byte           # hardware specific scancode
-    sym*: TKey                # SDL virtual keysym
-    modifier*: TMod           # current key modifiers
-    unicode*: UInt16          # translated character
-  
-  TEventAction* = enum        # Application visibility event structure
-    ADDEVENT, PEEKEVENT, GETEVENT
-  TActiveEvent*{.final.} = object  # SDL_ACTIVEEVENT
-                                   # Keyboard event structure
-    gain*: byte              # Whether given states were gained or lost (1/0)
-    state*: byte             # A mask of the focus states
-  
-  TKeyboardEvent*{.final.} = object  # SDL_KEYDOWN or SDL_KEYUP
-                                     # Mouse motion event structure
-    which*: byte             # The keyboard device index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-    keysym*: TKeySym
-
-  TMouseMotionEvent*{.final.} = object  # SDL_MOUSEMOTION
-                                        # Mouse button event structure
-    which*: byte             # The mouse device index
-    state*: byte             # The current button state
-    x*, y*: UInt16            # The X/Y coordinates of the mouse
-    xrel*: int16             # The relative motion in the X direction
-    yrel*: int16             # The relative motion in the Y direction
-  
-  TMouseButtonEvent*{.final.} = object  # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
-                                        # Joystick axis motion event structure
-    which*: byte             # The mouse device index
-    button*: byte            # The mouse button index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-    x*: UInt16                # The X coordinates of the mouse at press time
-    y*: UInt16                # The Y coordinates of the mouse at press time
-  
-  TJoyAxisEvent*{.final.} = object  # SDL_JOYAXISMOTION
-                                    # Joystick trackball motion event structure
-    which*: byte             # The joystick device index
-    axis*: byte              # The joystick axis index
-    value*: int16            # The axis value (range: -32768 to 32767)
-  
-  TJoyBallEvent*{.final.} = object  # SDL_JOYAVBALLMOTION
-                                    # Joystick hat position change event structure
-    which*: byte             # The joystick device index
-    ball*: byte              # The joystick trackball index
-    xrel*: int16             # The relative motion in the X direction
-    yrel*: int16             # The relative motion in the Y direction
-  
-  TJoyHatEvent*{.final.} = object  # SDL_JOYHATMOTION */
-                                   # Joystick button event structure
-    which*: byte             # The joystick device index */
-    hat*: byte               # The joystick hat index */
-    value*: byte             # The hat position value:
-                             # 8   1   2
-                             # 7   0   3
-                             # 6   5   4
-                             # Note that zero means the POV is centered.
-  
-  TJoyButtonEvent*{.final.} = object  # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
-                                      # The "window resized" event
-                                      # When you get this event, you are
-                                      # responsible for setting a new video
-                                      # mode with the new width and height.
-    which*: byte             # The joystick device index
-    button*: byte            # The joystick button index
-    state*: byte             # SDL_PRESSED or SDL_RELEASED
-  
-  TResizeEvent*{.final.} = object  # SDL_VIDEORESIZE
-                                   # A user-defined event type
-    w*: cint                   # New width
-    h*: cint                   # New height
-  
-  PUserEvent* = ptr TUserEvent
-  TUserEvent*{.final.} = object  # SDL_USEREVENT through SDL_NUMEVENTS-1
-    code*: cint                # User defined event code
-    data1*: Pointer           # User defined data pointer
-    data2*: Pointer           # User defined data pointer 
-  
-
-when defined(Unix): 
-  type                        #These are the various supported subsystems under UNIX
-    TSysWm* = enum 
-      SYSWM_X11
-when defined(WINDOWS): 
-  type 
-    PSysWMmsg* = ptr TSysWMmsg
-    TSysWMmsg*{.final.} = object 
-      version*: Tversion
-      hwnd*: THandle          # The window for the message
-      msg*: int               # The type of message
-      w_Param*: int32         # WORD message parameter
-      lParam*: int32          # LONG message parameter
-    
-elif defined(Unix): 
-  type                        # The Linux custom event structure
-    PSysWMmsg* = ptr TSysWMmsg
-    TSysWMmsg*{.final.} = object 
-      version*: Tversion
-      subsystem*: TSysWm
-      when false: 
-          event*: TXEvent
-
-    
-else: 
-  type                        # The generic custom event structure
-    PSysWMmsg* = ptr TSysWMmsg
-    TSysWMmsg*{.final.} = object 
-      version*: Tversion
-      data*: int
-
-# The Windows custom window manager information structure
-
-when defined(WINDOWS): 
-  type 
-    PSysWMinfo* = ptr TSysWMinfo
-    TSysWMinfo*{.final.} = object 
-      version*: Tversion
-      window*: THandle        # The display window
-    
-elif defined(Unix): 
-  type 
-    TX11*{.final.} = object 
-      when false: 
-          display*: PDisplay  # The X11 display
-          window*: TWindow    # The X11 display window
-                              # These locking functions should be called around
-                              # any X11 functions using the display variable.
-                              # They lock the event thread, so should not be
-                              # called around event functions or from event filters.
-          lock_func*: Pointer
-          unlock_func*: Pointer # Introduced in SDL 1.0.2
-          fswindow*: TWindow  # The X11 fullscreen window
-          wmwindow*: TWindow  # The X11 managed input window
-        
-    
-  type 
-    PSysWMinfo* = ptr TSysWMinfo
-    TSysWMinfo*{.final.} = object 
-      version*: Tversion
-      subsystem*: TSysWm
-      X11*: TX11
-
-else: 
-  type # The generic custom window manager information structure
-    PSysWMinfo* = ptr TSysWMinfo
-    TSysWMinfo*{.final.} = object 
-      version*: Tversion
-      data*: int
-
-type 
-  PSysWMEvent* = ptr TSysWMEvent
-  TSysWMEvent*{.final.} = object 
-    msg*: PSysWMmsg
-
-  PEvent* = ptr TEvent
-  TEvent*{.final.} = object  
-    # This function sets up a filter to process all events before they
-    # change internal state and are posted to the internal event queue.
-    # The filter is protypted as:
-    case kind*: TEventKind # SDL_NOEVENT, SDL_QUITEV: ();
-    of ACTIVEEVENT: 
-      gain*: byte              # Whether given states were gained or lost (1/0)
-      state*: byte             # A mask of the focus states
-    of KEYDOWN, KEYUP: 
-      keystate*: byte             # SDL_PRESSED or SDL_RELEASED
-      scancode*: byte           # hardware specific scancode
-      sym*: TKey                # SDL virtual keysym
-      modifier*: TMod           # current key modifiers
-      unicode*: UInt16          # translated character
-    of MOUSEMOTION: 
-      motionState*: byte             # The current button state
-      motionX*, motionY*: UInt16            # The X/Y coordinates of the mouse
-      xrel*: int16             # The relative motion in the X direction
-      yrel*: int16             # The relative motion in the Y direction
-    of MOUSEBUTTONDOWN, MOUSEBUTTONUP: 
-      button*: byte            # The mouse button index
-      buttonState*: byte             # SDL_PRESSED or SDL_RELEASED
-      align: byte
-      x*: UInt16                # The X coordinates of the mouse at press time
-      y*: UInt16                # The Y coordinates of the mouse at press time
-    of JOYAXISMOTION: 
-      axis*: byte              # The joystick axis index
-      value*: int16            # The axis value (range: -32768 to 32767)
-    of JOYBALLMOTION: 
-      ball*: byte              # The joystick trackball index
-      joyXrel*: int16             # The relative motion in the X direction
-      joyYrel*: int16             # The relative motion in the Y direction
-  
-    of JOYHATMOTION: 
-      hat*: byte               # The joystick hat index
-      hatValue*: byte          # The hat position value:
-                               # 8   1   2
-                               # 7   0   3
-                               # 6   5   4
-                               # Note that zero means the POV is centered.
-
-    of JOYBUTTONDOWN, JOYBUTTONUP: 
-      joybutton*: byte            # The joystick button index
-      joyState*: byte             # SDL_PRESSED or SDL_RELEASED
-  
-    of VIDEORESIZE: 
-      w*: cint                   # New width
-      h*: cint                   # New height
-    of USEREVENT: 
-      code*: cint                # User defined event code
-      data1*: Pointer           # User defined data pointer
-      data2*: Pointer           # User defined data pointer 
-    else: nil
-
-  
-  TEventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types
-                                                     # Useful data types
-  PPSDL_Rect* = ptr PRect
-  PRect* = ptr TRect
-  TRect*{.final.} = object 
-    x*, y*: int16
-    w*, h*: UInt16
-
-  Rect* = TRect
-  PColor* = ptr TColor
-  TColor*{.final.} = object 
-    r*: byte
-    g*: byte
-    b*: byte
-    unused*: byte
-
-  PColorArray* = ptr TColorArray
-  TColorArray* = array[0..65000, TColor]
-  PPalette* = ptr TPalette
-  TPalette*{.final.} = object  # Everything in the pixel format structure is read-only
-    ncolors*: int
-    colors*: PColorArray
-
-  PPixelFormat* = ptr TPixelFormat
-  TPixelFormat*{.final.} = object  # The structure passed to the low level blit functions
-    palette*: PPalette
-    BitsPerPixel*: byte
-    BytesPerPixel*: byte
-    Rloss*: byte
-    Gloss*: byte
-    Bloss*: byte
-    Aloss*: byte
-    Rshift*: byte
-    Gshift*: byte
-    Bshift*: byte
-    Ashift*: byte
-    RMask*: int32
-    GMask*: int32
-    BMask*: int32
-    AMask*: int32
-    colorkey*: int32         # RGB color key information
-    alpha*: byte             # Alpha value information (per-surface alpha)
-  
-  PBlitInfo* = ptr TBlitInfo
-  TBlitInfo*{.final.} = object  # typedef for private surface blitting functions
-    s_pixels*: ptr byte
-    s_width*: int
-    s_height*: int
-    s_skip*: int
-    d_pixels*: ptr byte
-    d_width*: int
-    d_height*: int
-    d_skip*: int
-    aux_data*: Pointer
-    src*: PPixelFormat
-    table*: ptr byte
-    dst*: PPixelFormat
-
-  PSurface* = ptr TSurface
-  TBlit* = proc (src: PSurface, srcrect: PRect, 
-                 dst: PSurface, dstrect: PRect): int{.cdecl.}
-  TSurface*{.final.} = object  # Useful for determining the video hardware capabilities
-    flags*: int32            # Read-only
-    format*: PPixelFormat     # Read-only
-    w*, h*: cint              # Read-only
-    pitch*: UInt16            # Read-only
-    pixels*: Pointer          # Read-write
-    offset*: cint             # Private
-    hwdata*: Pointer          #TPrivate_hwdata;  Hardware-specific surface info
-                              # clipping information:
-    clip_rect*: TRect         # Read-only
-    unused1*: int32           # for binary compatibility
-                              # Allow recursive locks
-    locked*: int32            # Private
-                              # info for fast blit mapping to other surfaces
-    Blitmap*: Pointer         # PSDL_BlitMap; //   Private
-                              # format version, bumped at every change to invalidate blit maps
-    format_version*: cint      # Private
-    refcount*: cint
-
-  PVideoInfo* = ptr TVideoInfo
-  TVideoInfo*{.final.} = object  # The YUV hardware video overlay
-    hw_available*: byte 
-    blit_hw*: byte 
-    UnusedBits3*: byte       # Unused at this point
-    video_mem*: int32        # The total amount of video memory (in K)
-    vfmt*: PPixelFormat       # Value: The format of the video surface
-    current_w*: int32        # Value: The current video mode width
-    current_h*: int32        # Value: The current video mode height
-  
-  POverlay* = ptr TOverlay
-  TOverlay*{.final.} = object  # Public enumeration for setting the OpenGL window attributes.
-    format*: int32           # Overlay format
-    w*, h*: int               # Width and height of overlay
-    planes*: int              # Number of planes in the overlay. Usually either 1 or 3
-    pitches*: PUInt16         # An array of pitches, one for each plane. Pitch is the length of a row in bytes.
-    pixels*: ptr ptr byte # An array of pointers to the data of each plane. The overlay should be locked before these pointers are used.
-    hw_overlay*: int32    # This will be set to 1 if the overlay is hardware accelerated.
-  
-  TGLAttr* = enum 
-    GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE, 
-    GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE, 
-    GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO, 
-    GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL, 
-    GL_SWAP_CONTROL
-  PCursor* = ptr TCursor
-  TCursor*{.final.} = object  # SDL_mutex.h types
-    area*: TRect              # The area of the mouse cursor
-    hot_x*, hot_y*: int16    # The "tip" of the cursor
-    data*: ptr byte             # B/W cursor data
-    mask*: ptr byte             # B/W cursor mask
-    save*: array[1..2, ptr byte] # Place to save cursor area
-    wm_cursor*: Pointer       # Window-manager cursor
-  
-
-type 
-  PMutex* = ptr TMutex
-  TMutex*{.final.} = object 
-  Psemaphore* = ptr Tsemaphore
-  Tsemaphore*{.final.} = object 
-  PSem* = ptr TSem
-  TSem* = TSemaphore
-  PCond* = ptr TCond
-  TCond*{.final.} = object    # SDL_thread.h types
-
-when defined(WINDOWS): 
-  type 
-    TSYS_ThreadHandle* = THandle
-when defined(Unix): 
-  type 
-    TSYS_ThreadHandle* = pointer
-type                          # This is the system-independent thread info structure
-  PThread* = ptr TThread
-  TThread*{.final.} = object  # Helper Types
-                              # Keyboard  State Array ( See demos for how to use )
-    threadid*: int32
-    handle*: TSYS_ThreadHandle
-    status*: int
-    errbuf*: TError
-    data*: Pointer
-
-  PKeyStateArr* = ptr TKeyStateArr
-  TKeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas
-  PInteger* = ptr int
-  PByte* = ptr int8
-  PWord* = ptr int16
-  PLongWord* = ptr int32      # General arrays
-  PByteArray* = ptr TByteArray
-  TByteArray* = array[0..32767, int8]
-  PWordArray* = ptr TWordArray
-  TWordArray* = array[0..16383, int16] # Generic procedure pointer
-  TProcedure* = proc () #------------------------------------------------------------------------------
-# initialization
-#------------------------------------------------------------------------------
-# This function loads the SDL dynamically linked library and initializes
-#  the subsystems specified by 'flags' (and those satisfying dependencies)
-#  Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
-#  signal handlers for some commonly ignored fatal signals (like SIGSEGV)
-
-proc Init*(flags: int32): int{.cdecl, importc: "SDL_Init", dynlib: LibName.}
-  # This function initializes specific SDL subsystems
-proc InitSubSystem*(flags: int32): int{.cdecl, importc: "SDL_InitSubSystem", 
-    dynlib: LibName.}
-  # This function cleans up specific SDL subsystems
-proc QuitSubSystem*(flags: int32){.cdecl, importc: "SDL_QuitSubSystem", 
-                                    dynlib: LibName.}
-  # This function returns mask of the specified subsystems which have
-  #  been initialized.
-  #  If 'flags' is 0, it returns a mask of all initialized subsystems.
-proc WasInit*(flags: int32): int32{.cdecl, importc: "SDL_WasInit", 
-                                      dynlib: LibName.}
-  # This function cleans up all initialized subsystems and unloads the
-  #  dynamically linked library.  You should call it upon all exit conditions.
-proc Quit*(){.cdecl, importc: "SDL_Quit", dynlib: LibName.}
-when defined(WINDOWS): 
-  # This should be called from your WinMain() function, if any
-  proc RegisterApp*(name: cstring, style: int32, h_Inst: Pointer): int{.cdecl, 
-      importc: "SDL_RegisterApp", dynlib: LibName.}
-proc TableSize*(table: cstring): int
-  #------------------------------------------------------------------------------
-  # error-handling
-  #------------------------------------------------------------------------------
-  # Public functions
-proc GetError*(): cstring{.cdecl, importc: "SDL_GetError", dynlib: LibName.}
-proc SetError*(fmt: cstring){.cdecl, importc: "SDL_SetError", dynlib: LibName.}
-proc ClearError*(){.cdecl, importc: "SDL_ClearError", dynlib: LibName.}
-when not (defined(WINDOWS)): 
-  proc Error*(Code: Terrorcode){.cdecl, importc: "SDL_Error", dynlib: LibName.}
-proc OutOfMemory*()
-  #------------------------------------------------------------------------------
-  # io handling
-  #------------------------------------------------------------------------------
-  # Functions to create SDL_RWops structures from various data sources
-proc RWFromFile*(filename, mode: cstring): PRWops{.cdecl, 
-    importc: "SDL_RWFromFile", dynlib: LibName.}
-proc FreeRW*(area: PRWops){.cdecl, importc: "SDL_FreeRW", dynlib: LibName.}
-  #fp is FILE *fp ???
-proc RWFromFP*(fp: Pointer, autoclose: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromFP", dynlib: LibName.}
-proc RWFromMem*(mem: Pointer, size: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromMem", dynlib: LibName.}
-proc RWFromConstMem*(mem: Pointer, size: int): PRWops{.cdecl, 
-    importc: "SDL_RWFromConstMem", dynlib: LibName.}
-proc AllocRW*(): PRWops{.cdecl, importc: "SDL_AllocRW", dynlib: LibName.}
-proc RWSeek*(context: PRWops, offset: int, whence: int): int
-proc RWTell*(context: PRWops): int
-proc RWRead*(context: PRWops, theptr: Pointer, size: int, n: int): int
-proc RWWrite*(context: PRWops, theptr: Pointer, size: int, n: int): int
-proc RWClose*(context: PRWops): int
-  #------------------------------------------------------------------------------
-  # time-handling
-  #------------------------------------------------------------------------------
-  # Get the number of milliseconds since the SDL library initialization.
-  # Note that this value wraps if the program runs for more than ~49 days.
-proc GetTicks*(): int32{.cdecl, importc: "SDL_GetTicks", dynlib: LibName.}
-  # Wait a specified number of milliseconds before returning
-proc Delay*(msec: int32){.cdecl, importc: "SDL_Delay", dynlib: LibName.}
-  # Add a new timer to the pool of timers already running.
-  # Returns a timer ID, or NULL when an error occurs.
-proc AddTimer*(interval: int32, callback: TNewTimerCallback, param: Pointer): PTimerID{.
-    cdecl, importc: "SDL_AddTimer", dynlib: LibName.}
-  # Remove one of the multiple timers knowing its ID.
-  # Returns a boolean value indicating success.
-proc RemoveTimer*(t: PTimerID): TBool{.cdecl, importc: "SDL_RemoveTimer", 
-                                       dynlib: LibName.}
-proc SetTimer*(interval: int32, callback: TTimerCallback): int{.cdecl, 
-    importc: "SDL_SetTimer", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # audio-routines
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the audio driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-proc AudioInit*(driver_name: cstring): int{.cdecl, importc: "SDL_AudioInit", 
-    dynlib: LibName.}
-proc AudioQuit*(){.cdecl, importc: "SDL_AudioQuit", dynlib: LibName.}
-  # This function fills the given character buffer with the name of the
-  #  current audio driver, and returns a Pointer to it if the audio driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc AudioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, 
-    importc: "SDL_AudioDriverName", dynlib: LibName.}
-  # This function opens the audio device with the desired parameters, and
-  #  returns 0 if successful, placing the actual hardware parameters in the
-  #  structure pointed to by 'obtained'.  If 'obtained' is NULL, the audio
-  #  data passed to the callback function will be guaranteed to be in the
-  #  requested format, and will be automatically converted to the hardware
-  #  audio format if necessary.  This function returns -1 if it failed
-  #  to open the audio device, or couldn't set up the audio thread.
-  #
-  #  When filling in the desired audio spec structure,
-  #   'desired->freq' should be the desired audio frequency in samples-per-second.
-  #   'desired->format' should be the desired audio format.
-  #   'desired->samples' is the desired size of the audio buffer, in samples.
-  #      This number should be a power of two, and may be adjusted by the audio
-  #      driver to a value more suitable for the hardware.  Good values seem to
-  #      range between 512 and 8096 inclusive, depending on the application and
-  #      CPU speed.  Smaller values yield faster response time, but can lead
-  #      to underflow if the application is doing heavy processing and cannot
-  #      fill the audio buffer in time.  A stereo sample consists of both right
-  #      and left channels in LR ordering.
-  #      Note that the number of samples is directly related to time by the
-  #      following formula:  ms = (samples*1000)/freq
-  #   'desired->size' is the size in bytes of the audio buffer, and is
-  #      calculated by SDL_OpenAudio().
-  #   'desired->silence' is the value used to set the buffer to silence,
-  #      and is calculated by SDL_OpenAudio().
-  #   'desired->callback' should be set to a function that will be called
-  #      when the audio device is ready for more data.  It is passed a pointer
-  #      to the audio buffer, and the length in bytes of the audio buffer.
-  #      This function usually runs in a separate thread, and so you should
-  #      protect data structures that it accesses by calling SDL_LockAudio()
-  #      and SDL_UnlockAudio() in your code.
-  #   'desired->userdata' is passed as the first parameter to your callback
-  #      function.
-  #
-  #  The audio device starts out playing silence when it's opened, and should
-  #  be enabled for playing by calling SDL_PauseAudio(0) when you are ready
-  #  for your audio callback function to be called.  Since the audio driver
-  #  may modify the requested size of the audio buffer, you should allocate
-  #  any local mixing buffers after you open the audio device.
-proc OpenAudio*(desired, obtained: PAudioSpec): int{.cdecl, 
-    importc: "SDL_OpenAudio", dynlib: LibName.}
-  # Get the current audio state:
-proc GetAudioStatus*(): TAudiostatus{.cdecl, importc: "SDL_GetAudioStatus", 
-                                      dynlib: LibName.}
-  # This function pauses and unpauses the audio callback processing.
-  #  It should be called with a parameter of 0 after opening the audio
-  #  device to start playing sound.  This is so you can safely initialize
-  #  data for your callback function after opening the audio device.
-  #  Silence will be written to the audio device during the pause.
-proc PauseAudio*(pause_on: int){.cdecl, importc: "SDL_PauseAudio", 
-                                 dynlib: LibName.}
-  # This function loads a WAVE from the data source, automatically freeing
-  #  that source if 'freesrc' is non-zero.  For example, to load a WAVE file,
-  #  you could do:
-  #  SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
-  #
-  #  If this function succeeds, it returns the given SDL_AudioSpec,
-  #  filled with the audio data format of the wave data, and sets
-  #  'audio_buf' to a malloc()'d buffer containing the audio data,
-  #  and sets 'audio_len' to the length of that audio buffer, in bytes.
-  #  You need to free the audio buffer with SDL_FreeWAV() when you are
-  #  done with it.
-  #
-  #  This function returns NULL and sets the SDL error message if the
-  #  wave file cannot be opened, uses an unknown data format, or is
-  #  corrupt.  Currently raw and MS-ADPCM WAVE files are supported.
-proc LoadWAV_RW*(src: PRWops, freesrc: int, spec: PAudioSpec, audio_buf: ptr byte, 
-                 audiolen: PUInt32): PAudioSpec{.cdecl, 
-    importc: "SDL_LoadWAV_RW", dynlib: LibName.}
-  # Compatibility convenience function -- loads a WAV from a file
-proc LoadWAV*(filename: cstring, spec: PAudioSpec, audio_buf: ptr byte, 
-              audiolen: PUInt32): PAudioSpec
-  # This function frees data previously allocated with SDL_LoadWAV_RW()
-proc FreeWAV*(audio_buf: ptr byte){.cdecl, importc: "SDL_FreeWAV", dynlib: LibName.}
-  # This function takes a source format and rate and a destination format
-  #  and rate, and initializes the 'cvt' structure with information needed
-  #  by SDL_ConvertAudio() to convert a buffer of audio data from one format
-  #  to the other.
-  #  This function returns 0, or -1 if there was an error.
-proc BuildAudioCVT*(cvt: PAudioCVT, src_format: UInt16, src_channels: byte, 
-                    src_rate: int, dst_format: UInt16, dst_channels: byte, 
-                    dst_rate: int): int{.cdecl, importc: "SDL_BuildAudioCVT", 
-    dynlib: LibName.}
-  # Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
-  #  created an audio buffer cvt->buf, and filled it with cvt->len bytes of
-  #  audio data in the source format, this function will convert it in-place
-  #  to the desired format.
-  #  The data conversion may expand the size of the audio data, so the buffer
-  #  cvt->buf should be allocated after the cvt structure is initialized by
-  #  SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
-proc ConvertAudio*(cvt: PAudioCVT): int{.cdecl, importc: "SDL_ConvertAudio", 
-    dynlib: LibName.}
-  # This takes two audio buffers of the playing audio format and mixes
-  #  them, performing addition, volume adjustment, and overflow clipping.
-  #  The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
-  #  for full audio volume.  Note this does not change hardware volume.
-  #  This is provided for convenience -- you can mix your own audio data.
-proc MixAudio*(dst, src: ptr byte, length: int32, volume: int){.cdecl, 
-    importc: "SDL_MixAudio", dynlib: LibName.}
-  # The lock manipulated by these functions protects the callback function.
-  #  During a LockAudio/UnlockAudio pair, you can be guaranteed that the
-  #  callback function is not running.  Do not call these from the callback
-  #  function or you will cause deadlock.
-proc LockAudio*(){.cdecl, importc: "SDL_LockAudio", dynlib: LibName.}
-proc UnlockAudio*(){.cdecl, importc: "SDL_UnlockAudio", dynlib: LibName.}
-  # This function shuts down audio processing and closes the audio device.
-proc CloseAudio*(){.cdecl, importc: "SDL_CloseAudio", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # CD-routines
-  #------------------------------------------------------------------------------
-  # Returns the number of CD-ROM drives on the system, or -1 if
-  #  SDL_Init() has not been called with the SDL_INIT_CDROM flag.
-proc CDNumDrives*(): int{.cdecl, importc: "SDL_CDNumDrives", dynlib: LibName.}
-  # Returns a human-readable, system-dependent identifier for the CD-ROM.
-  #   Example:
-  #   "/dev/cdrom"
-  #   "E:"
-  #   "/dev/disk/ide/1/master"
-proc CDName*(drive: int): cstring{.cdecl, importc: "SDL_CDName", dynlib: LibName.}
-  # Opens a CD-ROM drive for access.  It returns a drive handle on success,
-  #  or NULL if the drive was invalid or busy.  This newly opened CD-ROM
-  #  becomes the default CD used when other CD functions are passed a NULL
-  #  CD-ROM handle.
-  #  Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
-proc CDOpen*(drive: int): PCD{.cdecl, importc: "SDL_CDOpen", dynlib: LibName.}
-  # This function returns the current status of the given drive.
-  #  If the drive has a CD in it, the table of contents of the CD and current
-  #  play position of the CD will be stored in the SDL_CD structure.
-proc CDStatus*(cdrom: PCD): TCDStatus{.cdecl, importc: "SDL_CDStatus", 
-                                       dynlib: LibName.}
-  #  Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
-  #   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play
-  #   until the end of the CD.  This function will skip data tracks.
-  #   This function should only be called after calling SDL_CDStatus() to
-  #   get track information about the CD.
-  #
-  #   For example:
-  #   // Play entire CD:
-  #  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
-  #   // Play last track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
-  #   begin
-  #    SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
-  #   end;
-  #
-  #   // Play first and second track and 10 seconds of third track:
-  #   if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
-  #    SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
-  #
-  #   This function returns 0, or -1 if there was an error.
-proc CDPlayTracks*(cdrom: PCD, start_track: int, start_frame: int, ntracks: int, 
-                   nframes: int): int{.cdecl, importc: "SDL_CDPlayTracks", 
-                                       dynlib: LibName.}
-  #  Play the given CD starting at 'start' frame for 'length' frames.
-  #   It returns 0, or -1 if there was an error.
-proc CDPlay*(cdrom: PCD, start: int, len: int): int{.cdecl, 
-    importc: "SDL_CDPlay", dynlib: LibName.}
-  # Pause play -- returns 0, or -1 on error
-proc CDPause*(cdrom: PCD): int{.cdecl, importc: "SDL_CDPause", dynlib: LibName.}
-  # Resume play -- returns 0, or -1 on error
-proc CDResume*(cdrom: PCD): int{.cdecl, importc: "SDL_CDResume", dynlib: LibName.}
-  # Stop play -- returns 0, or -1 on error
-proc CDStop*(cdrom: PCD): int{.cdecl, importc: "SDL_CDStop", dynlib: LibName.}
-  # Eject CD-ROM -- returns 0, or -1 on error
-proc CDEject*(cdrom: PCD): int{.cdecl, importc: "SDL_CDEject", dynlib: LibName.}
-  # Closes the handle for the CD-ROM drive
-proc CDClose*(cdrom: PCD){.cdecl, importc: "SDL_CDClose", dynlib: LibName.}
-  # Given a status, returns true if there's a disk in the drive
-proc CDInDrive*(status: TCDStatus): bool
-  # Conversion functions from frames to Minute/Second/Frames and vice versa
-proc FRAMES_TO_MSF*(frames: int, M: var int, S: var int, F: var int)
-proc MSF_TO_FRAMES*(M: int, S: int, F: int): int
-  #------------------------------------------------------------------------------
-  # JoyStick-routines
-  #------------------------------------------------------------------------------
-  # Count the number of joysticks attached to the system
-proc NumJoysticks*(): int{.cdecl, importc: "SDL_NumJoysticks", dynlib: LibName.}
-  # Get the implementation dependent name of a joystick.
-  #  This can be called before any joysticks are opened.
-  #  If no name can be found, this function returns NULL.
-proc JoystickName*(index: int): cstring{.cdecl, importc: "SDL_JoystickName", 
-    dynlib: LibName.}
-  # Open a joystick for use - the index passed as an argument refers to
-  #  the N'th joystick on the system.  This index is the value which will
-  #  identify this joystick in future joystick events.
-  #
-  #  This function returns a joystick identifier, or NULL if an error occurred.
-proc JoystickOpen*(index: int): PJoystick{.cdecl, importc: "SDL_JoystickOpen", 
-    dynlib: LibName.}
-  # Returns 1 if the joystick has been opened, or 0 if it has not.
-proc JoystickOpened*(index: int): int{.cdecl, importc: "SDL_JoystickOpened", 
-                                       dynlib: LibName.}
-  # Get the device index of an opened joystick.
-proc JoystickIndex*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickIndex", dynlib: LibName.}
-  # Get the number of general axis controls on a joystick
-proc JoystickNumAxes*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumAxes", dynlib: LibName.}
-  # Get the number of trackballs on a joystick
-  #  Joystick trackballs have only relative motion events associated
-  #  with them and their state cannot be polled.
-proc JoystickNumBalls*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumBalls", dynlib: LibName.}
-  # Get the number of POV hats on a joystick
-proc JoystickNumHats*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumHats", dynlib: LibName.}
-  # Get the number of buttons on a joystick
-proc JoystickNumButtons*(joystick: PJoystick): int{.cdecl, 
-    importc: "SDL_JoystickNumButtons", dynlib: LibName.}
-  # Update the current state of the open joysticks.
-  #  This is called automatically by the event loop if any joystick
-  #  events are enabled.
-proc JoystickUpdate*(){.cdecl, importc: "SDL_JoystickUpdate", dynlib: LibName.}
-  # Enable/disable joystick event polling.
-  #  If joystick events are disabled, you must call SDL_JoystickUpdate()
-  #  yourself and check the state of the joystick when you want joystick
-  #  information.
-  #  The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
-proc JoystickEventState*(state: int): int{.cdecl, 
-    importc: "SDL_JoystickEventState", dynlib: LibName.}
-  # Get the current state of an axis control on a joystick
-  #  The state is a value ranging from -32768 to 32767.
-  #  The axis indices start at index 0.
-proc JoystickGetAxis*(joystick: PJoystick, axis: int): int16{.cdecl, 
-    importc: "SDL_JoystickGetAxis", dynlib: LibName.}
-  # The hat indices start at index 0.
-proc JoystickGetHat*(joystick: PJoystick, hat: int): byte{.cdecl, 
-    importc: "SDL_JoystickGetHat", dynlib: LibName.}
-  # Get the ball axis change since the last poll
-  #  This returns 0, or -1 if you passed it invalid parameters.
-  #  The ball indices start at index 0.
-proc JoystickGetBall*(joystick: PJoystick, ball: int, dx: var int, dy: var int): int{.
-    cdecl, importc: "SDL_JoystickGetBall", dynlib: LibName.}
-  # Get the current state of a button on a joystick
-  #  The button indices start at index 0.
-proc JoystickGetButton*(joystick: PJoystick, Button: int): byte{.cdecl, 
-    importc: "SDL_JoystickGetButton", dynlib: LibName.}
-  # Close a joystick previously opened with SDL_JoystickOpen()
-proc JoystickClose*(joystick: PJoystick){.cdecl, importc: "SDL_JoystickClose", 
-    dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # event-handling
-  #------------------------------------------------------------------------------
-  # Pumps the event loop, gathering events from the input devices.
-  #  This function updates the event queue and internal input device state.
-  #  This should only be run in the thread that sets the video mode.
-proc PumpEvents*(){.cdecl, importc: "SDL_PumpEvents", dynlib: LibName.}
-  # Checks the event queue for messages and optionally returns them.
-  #  If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
-  #  the back of the event queue.
-  #  If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will not
-  #  be removed from the queue.
-  #  If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
-  #  of the event queue, matching 'mask', will be returned and will be
-  #  removed from the queue.
-  #  This function returns the number of events actually stored, or -1
-  #  if there was an error.  This function is thread-safe.
-proc PeepEvents*(events: PEvent, numevents: int, action: Teventaction, 
-                 mask: int32): int{.cdecl, importc: "SDL_PeepEvents", 
-                                     dynlib: LibName.}
-  # Polls for currently pending events, and returns 1 if there are any pending
-  #   events, or 0 if there are none available.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc PollEvent*(event: PEvent): int{.cdecl, importc: "SDL_PollEvent", 
-                                     dynlib: LibName.}
-  #  Waits indefinitely for the next available event, returning 1, or 0 if there
-  #   was an error while waiting for events.  If 'event' is not NULL, the next
-  #   event is removed from the queue and stored in that area.
-proc WaitEvent*(event: PEvent): int{.cdecl, importc: "SDL_WaitEvent", 
-                                     dynlib: LibName.}
-proc PushEvent*(event: PEvent): int{.cdecl, importc: "SDL_PushEvent", 
-                                     dynlib: LibName.}
-  # If the filter returns 1, then the event will be added to the internal queue.
-  #  If it returns 0, then the event will be dropped from the queue, but the
-  #  internal state will still be updated.  This allows selective filtering of
-  #  dynamically arriving events.
-  #
-  #  WARNING:  Be very careful of what you do in the event filter function, as
-  #            it may run in a different thread!
-  #
-  #  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
-  #  event filter is only called when the window manager desires to close the
-  #  application window.  If the event filter returns 1, then the window will
-  #  be closed, otherwise the window will remain open if possible.
-  #  If the quit event is generated by an interrupt signal, it will bypass the
-  #  internal queue and be delivered to the application at the next event poll.
-proc SetEventFilter*(filter: TEventFilter){.cdecl, 
-    importc: "SDL_SetEventFilter", dynlib: LibName.}
-  # Return the current event filter - can be used to "chain" filters.
-  #  If there is no event filter set, this function returns NULL.
-proc GetEventFilter*(): TEventFilter{.cdecl, importc: "SDL_GetEventFilter", 
-                                      dynlib: LibName.}
-  # This function allows you to set the state of processing certain events.
-  #  If 'state' is set to SDL_IGNORE, that event will be automatically dropped
-  #  from the event queue and will not event be filtered.
-  #  If 'state' is set to SDL_ENABLE, that event will be processed normally.
-  #  If 'state' is set to SDL_QUERY, SDL_EventState() will return the
-  #  current processing state of the specified event.
-proc EventState*(theType: byte, state: int): byte{.cdecl, 
-    importc: "SDL_EventState", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Version Routines
-  #------------------------------------------------------------------------------
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library.
-proc VERSION*(X: var TVersion)
-  # This macro turns the version numbers into a numeric value:
-  #   (1,2,3) -> (1203)
-  #   This assumes that there will never be more than 100 patchlevels
-proc VERSIONNUM*(X, Y, Z: int): int
-  # This is the version number macro for the current SDL version
-proc COMPILEDVERSION*(): int
-  # This macro will evaluate to true if compiled with SDL at least X.Y.Z
-proc VERSION_ATLEAST*(X: int, Y: int, Z: int): bool
-  # This function gets the version of the dynamically linked SDL library.
-  #  it should NOT be used to fill a version structure, instead you should
-  #  use the SDL_Version() macro.
-proc Linked_Version*(): Pversion{.cdecl, importc: "SDL_Linked_Version", 
-                                  dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # video
-  #------------------------------------------------------------------------------
-  # These functions are used internally, and should not be used unless you
-  #  have a specific need to specify the video driver you want to use.
-  #  You should normally use SDL_Init() or SDL_InitSubSystem().
-  #
-  #  SDL_VideoInit() initializes the video subsystem -- sets up a connection
-  #  to the window manager, etc, and determines the current video mode and
-  #  pixel format, but does not initialize a window or graphics mode.
-  #  Note that event handling is activated by this routine.
-  #
-  #  If you use both sound and video in your application, you need to call
-  #  SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
-  #  you won't be able to set full-screen display modes.
-proc VideoInit*(driver_name: cstring, flags: int32): int{.cdecl, 
-    importc: "SDL_VideoInit", dynlib: LibName.}
-proc VideoQuit*(){.cdecl, importc: "SDL_VideoQuit", dynlib: LibName.}
-  # This function fills the given character buffer with the name of the
-  #  video driver, and returns a pointer to it if the video driver has
-  #  been initialized.  It returns NULL if no driver has been initialized.
-proc VideoDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, 
-    importc: "SDL_VideoDriverName", dynlib: LibName.}
-  # This function returns a pointer to the current display surface.
-  #  If SDL is doing format conversion on the display surface, this
-  #  function returns the publicly visible surface, not the real video
-  #  surface.
-proc GetVideoSurface*(): PSurface{.cdecl, importc: "SDL_GetVideoSurface", 
-                                   dynlib: LibName.}
-  # This function returns a read-only pointer to information about the
-  #  video hardware.  If this is called before SDL_SetVideoMode(), the 'vfmt'
-  #  member of the returned structure will contain the pixel format of the
-  #  "best" video mode.
-proc GetVideoInfo*(): PVideoInfo{.cdecl, importc: "SDL_GetVideoInfo", 
-                                  dynlib: LibName.}
-  # Check to see if a particular video mode is supported.
-  #  It returns 0 if the requested mode is not supported under any bit depth,
-  #  or returns the bits-per-pixel of the closest available mode with the
-  #  given width and height.  If this bits-per-pixel is different from the
-  #  one used when setting the video mode, SDL_SetVideoMode() will succeed,
-  #  but will emulate the requested bits-per-pixel with a shadow surface.
-  #
-  #  The arguments to SDL_VideoModeOK() are the same ones you would pass to
-  #  SDL_SetVideoMode()
-proc VideoModeOK*(width, height, bpp: int, flags: int32): int{.cdecl, 
-    importc: "SDL_VideoModeOK", importc: "SDL_VideoModeOK", dynlib: LibName.}
-  # Return a pointer to an array of available screen dimensions for the
-  #  given format and video flags, sorted largest to smallest.  Returns
-  #  NULL if there are no dimensions available for a particular format,
-  #  or (SDL_Rect **)-1 if any dimension is okay for the given format.
-  #
-  #  if 'format' is NULL, the mode list will be for the format given
-  #  by SDL_GetVideoInfo( ) - > vfmt
-proc ListModes*(format: PPixelFormat, flags: int32): PPSDL_Rect{.cdecl, 
-    importc: "SDL_ListModes", dynlib: LibName.}
-  # Set up a video mode with the specified width, height and bits-per-pixel.
-  #
-  #  If 'bpp' is 0, it is treated as the current display bits per pixel.
-  #
-  #  If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
-  #  requested bits-per-pixel, but will return whatever video pixel format is
-  #  available.  The default is to emulate the requested pixel format if it
-  #  is not natively available.
-  #
-  #  If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
-  #  video memory, if possible, and you may have to call SDL_LockSurface()
-  #  in order to access the raw framebuffer.  Otherwise, the video surface
-  #  will be created in system memory.
-  #
-  #  If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
-  #  updates asynchronously, but you must always lock before accessing pixels.
-  #  SDL will wait for updates to complete before returning from the lock.
-  #
-  #  If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
-  #  that the colors set by SDL_SetColors() will be the colors you get.
-  #  Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
-  #  of the colors exactly the way they are requested, and you should look
-  #  at the video surface structure to determine the actual palette.
-  #  If SDL cannot guarantee that the colors you request can be set,
-  #  i.e. if the colormap is shared, then the video surface may be created
-  #  under emulation in system memory, overriding the SDL_HWSURFACE flag.
-  #
-  #  If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
-  #  a fullscreen video mode.  The default is to create a windowed mode
-  #  if the current graphics system has a window manager.
-  #  If the SDL library is able to set a fullscreen video mode, this flag
-  #  will be set in the surface that is returned.
-  #
-  #  If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
-  #  two surfaces in video memory and swap between them when you call
-  #  SDL_Flip().  This is usually slower than the normal single-buffering
-  #  scheme, but prevents "tearing" artifacts caused by modifying video
-  #  memory while the monitor is refreshing.  It should only be used by
-  #  applications that redraw the entire screen on every update.
-  #
-  #  This function returns the video framebuffer surface, or NULL if it fails.
-proc SetVideoMode*(width, height, bpp: int, flags: int32): PSurface{.cdecl, 
-    importc: "SDL_SetVideoMode", dynlib: LibName.}
-  # Makes sure the given list of rectangles is updated on the given screen.
-  #  If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
-  #  screen.
-  #  These functions should not be called while 'screen' is locked.
-proc UpdateRects*(screen: PSurface, numrects: int, rects: PRect){.cdecl, 
-    importc: "SDL_UpdateRects", dynlib: LibName.}
-proc UpdateRect*(screen: PSurface, x, y: int32, w, h: int32){.cdecl, 
-    importc: "SDL_UpdateRect", dynlib: LibName.}
-  # On hardware that supports double-buffering, this function sets up a flip
-  #  and returns.  The hardware will wait for vertical retrace, and then swap
-  #  video buffers before the next video surface blit or lock will return.
-  #  On hardware that doesn not support double-buffering, this is equivalent
-  #  to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
-  #  The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
-  #  setting the video mode for this function to perform hardware flipping.
-  #  This function returns 0 if successful, or -1 if there was an error.
-proc Flip*(screen: PSurface): int{.cdecl, importc: "SDL_Flip", dynlib: LibName.}
-  # Set the gamma correction for each of the color channels.
-  #  The gamma values range (approximately) between 0.1 and 10.0
-  #
-  #  If this function isn't supported directly by the hardware, it will
-  #  be emulated using gamma ramps, if available.  If successful, this
-  #  function returns 0, otherwise it returns -1.
-proc SetGamma*(redgamma: float32, greengamma: float32, bluegamma: float32): int{.
-    cdecl, importc: "SDL_SetGamma", dynlib: LibName.}
-  # Set the gamma translation table for the red, green, and blue channels
-  #  of the video hardware.  Each table is an array of 256 16-bit quantities,
-  #  representing a mapping between the input and output for that channel.
-  #  The input is the index into the array, and the output is the 16-bit
-  #  gamma value at that index, scaled to the output color precision.
-  #
-  #  You may pass NULL for any of the channels to leave it unchanged.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc SetGammaRamp*(redtable: PUInt16, greentable: PUInt16, bluetable: PUInt16): int{.
-    cdecl, importc: "SDL_SetGammaRamp", dynlib: LibName.}
-  # Retrieve the current values of the gamma translation tables.
-  #
-  #  You must pass in valid pointers to arrays of 256 16-bit quantities.
-  #  Any of the pointers may be NULL to ignore that channel.
-  #  If the call succeeds, it will return 0.  If the display driver or
-  #  hardware does not support gamma translation, or otherwise fails,
-  #  this function will return -1.
-proc GetGammaRamp*(redtable: PUInt16, greentable: PUInt16, bluetable: PUInt16): int{.
-    cdecl, importc: "SDL_GetGammaRamp", dynlib: LibName.}
-  # Sets a portion of the colormap for the given 8-bit surface.  If 'surface'
-  #  is not a palettized surface, this function does nothing, returning 0.
-  #  If all of the colors were set as passed to SDL_SetColors(), it will
-  #  return 1.  If not all the color entries were set exactly as given,
-  #  it will return 0, and you should look at the surface palette to
-  #  determine the actual color palette.
-  #
-  #  When 'surface' is the surface associated with the current display, the
-  #  display colormap will be updated with the requested colors.  If
-  #  SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
-  #  will always return 1, and the palette is guaranteed to be set the way
-  #  you desire, even if the window colormap has to be warped or run under
-  #  emulation.
-proc SetColors*(surface: PSurface, colors: PColor, firstcolor: int, ncolors: int): int{.
-    cdecl, importc: "SDL_SetColors", dynlib: LibName.}
-  # Sets a portion of the colormap for a given 8-bit surface.
-  #  'flags' is one or both of:
-  #  SDL_LOGPAL  -- set logical palette, which controls how blits are mapped
-  #                 to/from the surface,
-  #  SDL_PHYSPAL -- set physical palette, which controls how pixels look on
-  #                 the screen
-  #  Only screens have physical palettes. Separate change of physical/logical
-  #  palettes is only possible if the screen has SDL_HWPALETTE set.
-  #
-  #  The return value is 1 if all colours could be set as requested, and 0
-  #  otherwise.
-  #
-  #  SDL_SetColors() is equivalent to calling this function with
-  #  flags = (SDL_LOGPAL or SDL_PHYSPAL).
-proc SetPalette*(surface: PSurface, flags: int, colors: PColor, firstcolor: int, 
-                 ncolors: int): int{.cdecl, importc: "SDL_SetPalette", 
-                                     dynlib: LibName.}
-  # Maps an RGB triple to an opaque pixel value for a given pixel format
-proc MapRGB*(format: PPixelFormat, r: byte, g: byte, b: byte): int32{.cdecl, 
-    importc: "SDL_MapRGB", dynlib: LibName.}
-  # Maps an RGBA quadruple to a pixel value for a given pixel format
-proc MapRGBA*(format: PPixelFormat, r: byte, g: byte, b: byte, a: byte): int32{.
-    cdecl, importc: "SDL_MapRGBA", dynlib: LibName.}
-  # Maps a pixel value into the RGB components for a given pixel format
-proc GetRGB*(pixel: int32, fmt: PPixelFormat, r: ptr byte, g: ptr byte, b: ptr byte){.
-    cdecl, importc: "SDL_GetRGB", dynlib: LibName.}
-  # Maps a pixel value into the RGBA components for a given pixel format
-proc GetRGBA*(pixel: int32, fmt: PPixelFormat, r: ptr byte, g: ptr byte, b: ptr byte, 
-              a: ptr byte){.cdecl, importc: "SDL_GetRGBA", dynlib: LibName.}
-  # Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
-  #  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
-  #  If the depth is greater than 8 bits, the pixel format is set using the
-  #  flags '[RGB]mask'.
-  #  If the function runs out of memory, it will return NULL.
-  #
-  #  The 'flags' tell what kind of surface to create.
-  #  SDL_SWSURFACE means that the surface should be created in system memory.
-  #  SDL_HWSURFACE means that the surface should be created in video memory,
-  #  with the same format as the display surface.  This is useful for surfaces
-  #  that will not change much, to take advantage of hardware acceleration
-  #  when being blitted to the display surface.
-  #  SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
-  #  this surface, but you must always lock it before accessing the pixels.
-  #  SDL will wait for current blits to finish before returning from the lock.
-  #  SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
-  #  If the hardware supports acceleration of colorkey blits between
-  #  two surfaces in video memory, SDL will try to place the surface in
-  #  video memory. If this isn't possible or if there is no hardware
-  #  acceleration available, the surface will be placed in system memory.
-  #  SDL_SRCALPHA means that the surface will be used for alpha blits and
-  #  if the hardware supports hardware acceleration of alpha blits between
-  #  two surfaces in video memory, to place the surface in video memory
-  #  if possible, otherwise it will be placed in system memory.
-  #  If the surface is created in video memory, blits will be _much_ faster,
-  #  but the surface format must be identical to the video surface format,
-  #  and the only way to access the pixels member of the surface is to use
-  #  the SDL_LockSurface() and SDL_UnlockSurface() calls.
-  #  If the requested surface actually resides in video memory, SDL_HWSURFACE
-  #  will be set in the flags member of the returned surface.  If for some
-  #  reason the surface could not be placed in video memory, it will not have
-  #  the SDL_HWSURFACE flag set, and will be created in system memory instead.
-proc AllocSurface*(flags: int32, width, height, depth: int, 
-                   RMask, GMask, BMask, AMask: int32): PSurface
-proc CreateRGBSurface*(flags: int32, width, height, depth: int, 
-                       RMask, GMask, BMask, AMask: int32): PSurface{.cdecl, 
-    importc: "SDL_CreateRGBSurface", dynlib: LibName.}
-proc CreateRGBSurfaceFrom*(pixels: Pointer, width, height, depth, pitch: int, 
-                           RMask, GMask, BMask, AMask: int32): PSurface{.cdecl, 
-    importc: "SDL_CreateRGBSurfaceFrom", dynlib: LibName.}
-proc FreeSurface*(surface: PSurface){.cdecl, importc: "SDL_FreeSurface", 
-                                      dynlib: LibName.}
-proc MustLock*(Surface: PSurface): bool
-  # SDL_LockSurface() sets up a surface for directly accessing the pixels.
-  #  Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
-  #  to and read from 'surface->pixels', using the pixel format stored in
-  #  'surface->format'.  Once you are done accessing the surface, you should
-  #  use SDL_UnlockSurface() to release it.
-  #
-  #  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
-  #  to 0, then you can read and write to the surface at any time, and the
-  #  pixel format of the surface will not change.  In particular, if the
-  #  SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
-  #  will not need to lock the display surface before accessing it.
-  #
-  #  No operating system or library calls should be made between lock/unlock
-  #  pairs, as critical system locks may be held during this time.
-  #
-  #  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
-proc LockSurface*(surface: PSurface): int{.cdecl, importc: "SDL_LockSurface", 
-    dynlib: LibName.}
-proc UnlockSurface*(surface: PSurface){.cdecl, importc: "SDL_UnlockSurface", 
-                                        dynlib: LibName.}
-  # Load a surface from a seekable SDL data source (memory or file.)
-  #  If 'freesrc' is non-zero, the source will be closed after being read.
-  #  Returns the new surface, or NULL if there was an error.
-  #  The new surface should be freed with SDL_FreeSurface().
-proc LoadBMP_RW*(src: PRWops, freesrc: int): PSurface{.cdecl, 
-    importc: "SDL_LoadBMP_RW", dynlib: LibName.}
-  # Convenience macro -- load a surface from a file
-proc LoadBMP*(filename: cstring): PSurface
-  # Save a surface to a seekable SDL data source (memory or file.)
-  #  If 'freedst' is non-zero, the source will be closed after being written.
-  #  Returns 0 if successful or -1 if there was an error.
-proc SaveBMP_RW*(surface: PSurface, dst: PRWops, freedst: int): int{.cdecl, 
-    importc: "SDL_SaveBMP_RW", dynlib: LibName.}
-  # Convenience macro -- save a surface to a file
-proc SaveBMP*(surface: PSurface, filename: cstring): int
-  # Sets the color key (transparent pixel) in a blittable surface.
-  #  If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
-  #  'key' will be the transparent pixel in the source image of a blit.
-  #  SDL_RLEACCEL requests RLE acceleration for the surface if present,
-  #  and removes RLE acceleration if absent.
-  #  If 'flag' is 0, this function clears any current color key.
-  #  This function returns 0, or -1 if there was an error.
-proc SetColorKey*(surface: PSurface, flag, key: int32): int{.cdecl, 
-    importc: "SDL_SetColorKey", dynlib: LibName.}
-  # This function sets the alpha value for the entire surface, as opposed to
-  #  using the alpha component of each pixel. This value measures the range
-  #  of transparency of the surface, 0 being completely transparent to 255
-  #  being completely opaque. An 'alpha' value of 255 causes blits to be
-  #  opaque, the source pixels copied to the destination (the default). Note
-  #  that per-surface alpha can be combined with colorkey transparency.
-  #
-  #  If 'flag' is 0, alpha blending is disabled for the surface.
-  #  If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
-  #  OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
-  #  surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
-proc SetAlpha*(surface: PSurface, flag: int32, alpha: byte): int{.cdecl, 
-    importc: "SDL_SetAlpha", dynlib: LibName.}
-  # Sets the clipping rectangle for the destination surface in a blit.
-  #
-  #  If the clip rectangle is NULL, clipping will be disabled.
-  #  If the clip rectangle doesn't intersect the surface, the function will
-  #  return SDL_FALSE and blits will be completely clipped.  Otherwise the
-  #  function returns SDL_TRUE and blits to the surface will be clipped to
-  #  the intersection of the surface area and the clipping rectangle.
-  #
-  #  Note that blits are automatically clipped to the edges of the source
-  #  and destination surfaces.
-proc SetClipRect*(surface: PSurface, rect: PRect){.cdecl, 
-    importc: "SDL_SetClipRect", dynlib: LibName.}
-  # Gets the clipping rectangle for the destination surface in a blit.
-  #  'rect' must be a pointer to a valid rectangle which will be filled
-  #  with the correct values.
-proc GetClipRect*(surface: PSurface, rect: PRect){.cdecl, 
-    importc: "SDL_GetClipRect", dynlib: LibName.}
-  # Creates a new surface of the specified format, and then copies and maps
-  #  the given surface to it so the blit of the converted surface will be as
-  #  fast as possible.  If this function fails, it returns NULL.
-  #
-  #  The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
-  #  semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
-  #  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
-  #  surface.
-  #
-  #  This function is used internally by SDL_DisplayFormat().
-proc ConvertSurface*(src: PSurface, fmt: PPixelFormat, flags: int32): PSurface{.
-    cdecl, importc: "SDL_ConvertSurface", dynlib: LibName.}
-  #
-  #  This performs a fast blit from the source surface to the destination
-  #  surface.  It assumes that the source and destination rectangles are
-  #  the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
-  #  surface (src or dst) is copied.  The final blit rectangles are saved
-  #  in 'srcrect' and 'dstrect' after all clipping is performed.
-  #  If the blit is successful, it returns 0, otherwise it returns -1.
-  #
-  #  The blit function should not be called on a locked surface.
-  #
-  #  The blit semantics for surfaces with and without alpha and colorkey
-  #  are defined as follows:
-  #
-  #  RGBA->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using alpha-channel).
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value);
-  #   set destination alpha to opaque.
-  #      SDL_SRCALPHA not set:
-  #   copy RGB, set destination alpha to opaque.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  RGBA->RGBA:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source alpha channel) the RGB values;
-  #   leave destination alpha untouched. [Note: is this correct?]
-  #   SDL_SRCCOLORKEY ignored.
-  #      SDL_SRCALPHA not set:
-  #   copy all of RGBA to the destination.
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   RGB values of the source colour key, ignoring alpha in the
-  #   comparison.
-  #
-  #  RGB->RGB:
-  #      SDL_SRCALPHA set:
-  #   alpha-blend (using the source per-surface alpha value).
-  #      SDL_SRCALPHA not set:
-  #   copy RGB.
-  #      both:
-  #   if SDL_SRCCOLORKEY set, only copy the pixels matching the
-  #   source colour key.
-  #
-  #  If either of the surfaces were in video memory, and the blit returns -2,
-  #  the video memory was lost, so it should be reloaded with artwork and
-  #  re-blitted:
-  #  while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
-  #  begin
-  #  while ( SDL_LockSurface(image) < 0 ) do
-  #   Sleep(10);
-  #  -- Write image pixels to image->pixels --
-  #  SDL_UnlockSurface(image);
-  # end;
-  #
-  #  This happens under DirectX 5.0 when the system switches away from your
-  #  fullscreen application.  The lock will also fail until you have access
-  #  to the video memory again.
-  # You should call SDL_BlitSurface() unless you know exactly how SDL
-  #   blitting works internally and how to use the other blit functions.
-proc BlitSurface*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int
-  #  This is the public blit function, SDL_BlitSurface(), and it performs
-  #   rectangle validation and clipping before passing it to SDL_LowerBlit()
-proc UpperBlit*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int{.
-    cdecl, importc: "SDL_UpperBlit", dynlib: LibName.}
-  # This is a semi-private blit function and it performs low-level surface
-  #  blitting only.
-proc LowerBlit*(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int{.
-    cdecl, importc: "SDL_LowerBlit", dynlib: LibName.}
-  # This function performs a fast fill of the given rectangle with 'color'
-  #  The given rectangle is clipped to the destination surface clip area
-  #  and the final fill rectangle is saved in the passed in pointer.
-  #  If 'dstrect' is NULL, the whole surface will be filled with 'color'
-  #  The color should be a pixel of the format used by the surface, and
-  #  can be generated by the SDL_MapRGB() function.
-  #  This function returns 0 on success, or -1 on error.
-proc FillRect*(dst: PSurface, dstrect: PRect, color: int32): int{.cdecl, 
-    importc: "SDL_FillRect", dynlib: LibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer, suitable for fast
-  #  blitting onto the display surface.  It calls SDL_ConvertSurface()
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc DisplayFormat*(surface: PSurface): PSurface{.cdecl, 
-    importc: "SDL_DisplayFormat", dynlib: LibName.}
-  # This function takes a surface and copies it to a new surface of the
-  #  pixel format and colors of the video framebuffer (if possible),
-  #  suitable for fast alpha blitting onto the display surface.
-  #  The new surface will always have an alpha channel.
-  #
-  #  If you want to take advantage of hardware colorkey or alpha blit
-  #  acceleration, you should set the colorkey and alpha value before
-  #  calling this function.
-  #
-  #  If the conversion fails or runs out of memory, it returns NULL
-proc DisplayFormatAlpha*(surface: PSurface): PSurface{.cdecl, 
-    importc: "SDL_DisplayFormatAlpha", dynlib: LibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  #* YUV video surface overlay functions                                       */
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-  # This function creates a video output overlay
-  #  Calling the returned surface an overlay is something of a misnomer because
-  #  the contents of the display surface underneath the area where the overlay
-  #  is shown is undefined - it may be overwritten with the converted YUV data.
-proc CreateYUVOverlay*(width: int, height: int, format: int32, 
-                       display: PSurface): POverlay{.cdecl, 
-    importc: "SDL_CreateYUVOverlay", dynlib: LibName.}
-  # Lock an overlay for direct access, and unlock it when you are done
-proc LockYUVOverlay*(Overlay: POverlay): int{.cdecl, 
-    importc: "SDL_LockYUVOverlay", dynlib: LibName.}
-proc UnlockYUVOverlay*(Overlay: POverlay){.cdecl, 
-    importc: "SDL_UnlockYUVOverlay", dynlib: LibName.}
-  # Blit a video overlay to the display surface.
-  #  The contents of the video surface underneath the blit destination are
-  #  not defined.
-  #  The width and height of the destination rectangle may be different from
-  #  that of the overlay, but currently only 2x scaling is supported.
-proc DisplayYUVOverlay*(Overlay: POverlay, dstrect: PRect): int{.cdecl, 
-    importc: "SDL_DisplayYUVOverlay", dynlib: LibName.}
-  # Free a video overlay
-proc FreeYUVOverlay*(Overlay: POverlay){.cdecl, importc: "SDL_FreeYUVOverlay", 
-    dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # OpenGL Routines
-  #------------------------------------------------------------------------------
-  # Dynamically load a GL driver, if SDL is built with dynamic GL.
-  #
-  #  SDL links normally with the OpenGL library on your system by default,
-  #  but you can compile it to dynamically load the GL driver at runtime.
-  #  If you do this, you need to retrieve all of the GL functions used in
-  #  your program from the dynamic library using SDL_GL_GetProcAddress().
-  #
-  #  This is disabled in default builds of SDL.
-proc GL_LoadLibrary*(filename: cstring): int{.cdecl, 
-    importc: "SDL_GL_LoadLibrary", dynlib: LibName.}
-  # Get the address of a GL function (for extension functions)
-proc GL_GetProcAddress*(procname: cstring): Pointer{.cdecl, 
-    importc: "SDL_GL_GetProcAddress", dynlib: LibName.}
-  # Set an attribute of the OpenGL subsystem before intialization.
-proc GL_SetAttribute*(attr: TGLAttr, value: int): int{.cdecl, 
-    importc: "SDL_GL_SetAttribute", dynlib: LibName.}
-  # Get an attribute of the OpenGL subsystem from the windowing
-  #  interface, such as glX. This is of course different from getting
-  #  the values from SDL's internal OpenGL subsystem, which only
-  #  stores the values you request before initialization.
-  #
-  #  Developers should track the values they pass into SDL_GL_SetAttribute
-  #  themselves if they want to retrieve these values.
-proc GL_GetAttribute*(attr: TGLAttr, value: var int): int{.cdecl, 
-    importc: "SDL_GL_GetAttribute", dynlib: LibName.}
-  # Swap the OpenGL buffers, if double-buffering is supported.
-proc GL_SwapBuffers*(){.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.}
-  # Internal functions that should not be called unless you have read
-  #  and understood the source code for these functions.
-proc GL_UpdateRects*(numrects: int, rects: PRect){.cdecl, 
-    importc: "SDL_GL_UpdateRects", dynlib: LibName.}
-proc GL_Lock*(){.cdecl, importc: "SDL_GL_Lock", dynlib: LibName.}
-proc GL_Unlock*(){.cdecl, importc: "SDL_GL_Unlock", dynlib: LibName.}
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  #* These functions allow interaction with the window manager, if any.        *
-  #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Sets/Gets the title and icon text of the display window
-proc WM_GetCaption*(title: var cstring, icon: var cstring){.cdecl, 
-    importc: "SDL_WM_GetCaption", dynlib: LibName.}
-proc WM_SetCaption*(title: cstring, icon: cstring){.cdecl, 
-    importc: "SDL_WM_SetCaption", dynlib: LibName.}
-  # Sets the icon for the display window.
-  #  This function must be called before the first call to SDL_SetVideoMode().
-  #  It takes an icon surface, and a mask in MSB format.
-  #  If 'mask' is NULL, the entire icon surface will be used as the icon.
-proc WM_SetIcon*(icon: PSurface, mask: byte){.cdecl, importc: "SDL_WM_SetIcon", 
-    dynlib: LibName.}
-  # This function iconifies the window, and returns 1 if it succeeded.
-  #  If the function succeeds, it generates an SDL_APPACTIVE loss event.
-  #  This function is a noop and returns 0 in non-windowed environments.
-proc WM_IconifyWindow*(): int{.cdecl, importc: "SDL_WM_IconifyWindow", 
-                               dynlib: LibName.}
-  # Toggle fullscreen mode without changing the contents of the screen.
-  #  If the display surface does not require locking before accessing
-  #  the pixel information, then the memory pointers will not change.
-  #
-  #  If this function was able to toggle fullscreen mode (change from
-  #  running in a window to fullscreen, or vice-versa), it will return 1.
-  #  If it is not implemented, or fails, it returns 0.
-  #
-  #  The next call to SDL_SetVideoMode() will set the mode fullscreen
-  #  attribute based on the flags parameter - if SDL_FULLSCREEN is not
-  #  set, then the display will be windowed by default where supported.
-  #
-  #  This is currently only implemented in the X11 video driver.
-proc WM_ToggleFullScreen*(surface: PSurface): int{.cdecl, 
-    importc: "SDL_WM_ToggleFullScreen", dynlib: LibName.}
-  # Grabbing means that the mouse is confined to the application window,
-  #  and nearly all keyboard input is passed directly to the application,
-  #  and not interpreted by a window manager, if any.
-proc WM_GrabInput*(mode: TGrabMode): TGrabMode{.cdecl, 
-    importc: "SDL_WM_GrabInput", dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # mouse-routines
-  #------------------------------------------------------------------------------
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  current mouse cursor position.  You can pass NULL for either x or y.
-proc GetMouseState*(x: var int, y: var int): byte{.cdecl, 
-    importc: "SDL_GetMouseState", dynlib: LibName.}
-  # Retrieve the current state of the mouse.
-  #  The current button state is returned as a button bitmask, which can
-  #  be tested using the SDL_BUTTON(X) macros, and x and y are set to the
-  #  mouse deltas since the last call to SDL_GetRelativeMouseState().
-proc GetRelativeMouseState*(x: var int, y: var int): byte{.cdecl, 
-    importc: "SDL_GetRelativeMouseState", dynlib: LibName.}
-  # Set the position of the mouse cursor (generates a mouse motion event)
-proc WarpMouse*(x, y: UInt16){.cdecl, importc: "SDL_WarpMouse", dynlib: LibName.}
-  # Create a cursor using the specified data and mask (in MSB format).
-  #  The cursor width must be a multiple of 8 bits.
-  #
-  #  The cursor is created in black and white according to the following:
-  #  data  mask    resulting pixel on screen
-  #   0     1       White
-  #   1     1       Black
-  #   0     0       Transparent
-  #   1     0       Inverted color if possible, black if not.
-  #
-  #  Cursors created with this function must be freed with SDL_FreeCursor().
-proc CreateCursor*(data, mask: ptr byte, w, h, hot_x, hot_y: int): PCursor{.cdecl, 
-    importc: "SDL_CreateCursor", dynlib: LibName.}
-  # Set the currently active cursor to the specified one.
-  #  If the cursor is currently visible, the change will be immediately
-  #  represented on the display.
-proc SetCursor*(cursor: PCursor){.cdecl, importc: "SDL_SetCursor", 
-                                  dynlib: LibName.}
-  # Returns the currently active cursor.
-proc GetCursor*(): PCursor{.cdecl, importc: "SDL_GetCursor", dynlib: LibName.}
-  # Deallocates a cursor created with SDL_CreateCursor().
-proc FreeCursor*(cursor: PCursor){.cdecl, importc: "SDL_FreeCursor", 
-                                   dynlib: LibName.}
-  # Toggle whether or not the cursor is shown on the screen.
-  #  The cursor start off displayed, but can be turned off.
-  #  SDL_ShowCursor() returns 1 if the cursor was being displayed
-  #  before the call, or 0 if it was not.  You can query the current
-  #  state by passing a 'toggle' value of -1.
-proc ShowCursor*(toggle: int): int{.cdecl, importc: "SDL_ShowCursor", 
-                                    dynlib: LibName.}
-proc BUTTON*(Button: int): int
-  #------------------------------------------------------------------------------
-  # Keyboard-routines
-  #------------------------------------------------------------------------------
-  # Enable/Disable UNICODE translation of keyboard input.
-  #  This translation has some overhead, so translation defaults off.
-  #  If 'enable' is 1, translation is enabled.
-  #  If 'enable' is 0, translation is disabled.
-  #  If 'enable' is -1, the translation state is not changed.
-  #  It returns the previous state of keyboard translation.
-proc EnableUNICODE*(enable: int): int{.cdecl, importc: "SDL_EnableUNICODE", 
-                                       dynlib: LibName.}
-  # If 'delay' is set to 0, keyboard repeat is disabled.
-proc EnableKeyRepeat*(delay: int, interval: int): int{.cdecl, 
-    importc: "SDL_EnableKeyRepeat", dynlib: LibName.}
-proc GetKeyRepeat*(delay: PInteger, interval: PInteger){.cdecl, 
-    importc: "SDL_GetKeyRepeat", dynlib: LibName.}
-  # Get a snapshot of the current state of the keyboard.
-  #  Returns an array of keystates, indexed by the SDLK_* syms.
-  #  Used:
-  #
-  #  byte *keystate = SDL_GetKeyState(NULL);
-  #  if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed
-proc GetKeyState*(numkeys: pointer): ptr byte{.cdecl, importc: "SDL_GetKeyState", 
-    dynlib: LibName.}
-  # Get the current key modifier state
-proc GetModState*(): TMod{.cdecl, importc: "SDL_GetModState", dynlib: LibName.}
-  # Set the current key modifier state
-  #  This does not change the keyboard state, only the key modifier flags.
-proc SetModState*(modstate: TMod){.cdecl, importc: "SDL_SetModState", 
-                                   dynlib: LibName.}
-  # Get the name of an SDL virtual keysym
-proc GetKeyName*(key: TKey): cstring{.cdecl, importc: "SDL_GetKeyName", 
-                                      dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Active Routines
-  #------------------------------------------------------------------------------
-  # This function returns the current state of the application, which is a
-  #  bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
-  #  SDL_APPACTIVE.  If SDL_APPACTIVE is set, then the user is able to
-  #  see your application, otherwise it has been iconified or disabled.
-proc GetAppState*(): byte{.cdecl, importc: "SDL_GetAppState", dynlib: LibName.}
-  # Mutex functions
-  # Create a mutex, initialized unlocked
-proc CreateMutex*(): PMutex{.cdecl, importc: "SDL_CreateMutex", dynlib: LibName.}
-  # Lock the mutex  (Returns 0, or -1 on error)
-proc mutexP*(mutex: Pmutex): int{.cdecl, importc: "SDL_mutexP", dynlib: LibName.}
-proc LockMutex*(mutex: Pmutex): int
-  # Unlock the mutex  (Returns 0, or -1 on error)
-proc mutexV*(mutex: Pmutex): int{.cdecl, importc: "SDL_mutexV", dynlib: LibName.}
-proc UnlockMutex*(mutex: Pmutex): int
-  # Destroy a mutex
-proc DestroyMutex*(mutex: Pmutex){.cdecl, importc: "SDL_DestroyMutex", 
-                                   dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Semaphore functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a semaphore, initialized with value, returns NULL on failure.
-proc CreateSemaphore*(initial_value: int32): PSem{.cdecl, 
-    importc: "SDL_CreateSemaphore", dynlib: LibName.}
-  # Destroy a semaphore
-proc DestroySemaphore*(sem: Psem){.cdecl, importc: "SDL_DestroySemaphore", 
-                                   dynlib: LibName.}
-  # This function suspends the calling thread until the semaphore pointed
-  #  to by sem has a positive count. It then atomically decreases the semaphore
-  #  count.
-proc SemWait*(sem: Psem): int{.cdecl, importc: "SDL_SemWait", dynlib: LibName.}
-  # Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
-  #   SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
-proc SemTryWait*(sem: Psem): int{.cdecl, importc: "SDL_SemTryWait", 
-                                  dynlib: LibName.}
-  # Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
-  #   the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
-  #   the allotted time, and -1 on error.
-  #   On some platforms this function is implemented by looping with a delay
-  #   of 1 ms, and so should be avoided if possible.
-proc SemWaitTimeout*(sem: Psem, ms: int32): int{.cdecl, 
-    importc: "SDL_SemWaitTimeout", dynlib: LibName.}
-  # Atomically increases the semaphore's count (not blocking), returns 0,
-  #   or -1 on error.
-proc SemPost*(sem: Psem): int{.cdecl, importc: "SDL_SemPost", dynlib: LibName.}
-  # Returns the current count of the semaphore
-proc SemValue*(sem: Psem): int32{.cdecl, importc: "SDL_SemValue", 
-                                   dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a condition variable
-proc CreateCond*(): PCond{.cdecl, importc: "SDL_CreateCond", dynlib: LibName.}
-  # Destroy a condition variable
-proc DestroyCond*(cond: PCond){.cdecl, importc: "SDL_DestroyCond", 
-                                dynlib: LibName.}
-  # Restart one of the threads that are waiting on the condition variable,
-  #   returns 0 or -1 on error.
-proc CondSignal*(cond: Pcond): int{.cdecl, importc: "SDL_CondSignal", 
-                                    dynlib: LibName.}
-  # Restart all threads that are waiting on the condition variable,
-  #  returns 0 or -1 on error.
-proc CondBroadcast*(cond: Pcond): int{.cdecl, importc: "SDL_CondBroadcast", 
-                                       dynlib: LibName.}
-  # Wait on the condition variable, unlocking the provided mutex.
-  #  The mutex must be locked before entering this function!
-  #  Returns 0 when it is signaled, or -1 on error.
-proc CondWait*(cond: Pcond, mut: Pmutex): int{.cdecl, importc: "SDL_CondWait", 
-    dynlib: LibName.}
-  # Waits for at most 'ms' milliseconds, and returns 0 if the condition
-  #  variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
-  #  signaled in the allotted time, and -1 on error.
-  #  On some platforms this function is implemented by looping with a delay
-  #  of 1 ms, and so should be avoided if possible.
-proc CondWaitTimeout*(cond: Pcond, mut: Pmutex, ms: int32): int{.cdecl, 
-    importc: "SDL_CondWaitTimeout", dynlib: LibName.}
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Condition variable functions
-  # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-  # Create a thread
-proc CreateThread*(fn, data: Pointer): PThread{.cdecl, 
-    importc: "SDL_CreateThread", dynlib: LibName.}
-  # Get the 32-bit thread identifier for the current thread
-proc ThreadID*(): int32{.cdecl, importc: "SDL_ThreadID", dynlib: LibName.}
-  # Get the 32-bit thread identifier for the specified thread,
-  #  equivalent to SDL_ThreadID() if the specified thread is NULL.
-proc GetThreadID*(thread: PThread): int32{.cdecl, importc: "SDL_GetThreadID", 
-    dynlib: LibName.}
-  # Wait for a thread to finish.
-  #  The return code for the thread function is placed in the area
-  #  pointed to by 'status', if 'status' is not NULL.
-proc WaitThread*(thread: PThread, status: var int){.cdecl, 
-    importc: "SDL_WaitThread", dynlib: LibName.}
-  # Forcefully kill a thread without worrying about its state
-proc KillThread*(thread: PThread){.cdecl, importc: "SDL_KillThread", 
-                                   dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  # Get Environment Routines
-  #------------------------------------------------------------------------------
-  #*
-  # * This function gives you custom hooks into the window manager information.
-  # * It fills the structure pointed to by 'info' with custom information and
-  # * returns 1 if the function is implemented.  If it's not implemented, or
-  # * the version member of the 'info' structure is invalid, it returns 0.
-  # *
-proc GetWMInfo*(info: PSysWMinfo): int{.cdecl, importc: "SDL_GetWMInfo", 
-                                        dynlib: LibName.}
-  #------------------------------------------------------------------------------
-  #SDL_loadso.h
-  #* This function dynamically loads a shared object and returns a pointer
-  # * to the object handle (or NULL if there was an error).
-  # * The 'sofile' parameter is a system dependent name of the object file.
-  # *
-proc LoadObject*(sofile: cstring): Pointer{.cdecl, importc: "SDL_LoadObject", 
-    dynlib: LibName.}
-  #* Given an object handle, this function looks up the address of the
-  # * named function in the shared object and returns it.  This address
-  # * is no longer valid after calling SDL_UnloadObject().
-  # *
-proc LoadFunction*(handle: Pointer, name: cstring): Pointer{.cdecl, 
-    importc: "SDL_LoadFunction", dynlib: LibName.}
-  #* Unload a shared object from memory *
-proc UnloadObject*(handle: Pointer){.cdecl, importc: "SDL_UnloadObject", 
-                                     dynlib: LibName.}
-  #------------------------------------------------------------------------------
-proc Swap32*(D: int32): int32
-  # Bitwise Checking functions
-proc IsBitOn*(value: int, bit: int8): bool
-proc TurnBitOn*(value: int, bit: int8): int
-proc TurnBitOff*(value: int, bit: int8): int
-# implementation
-
-proc TABLESIZE(table: cstring): int = 
-  Result = SizeOf(table) div SizeOf(table[0])
-
-proc OutOfMemory() = 
-  when not (defined(WINDOWS)): Error(ENOMEM)
-  
-proc RWSeek(context: PRWops, offset: int, whence: int): int = 
-  Result = context.seek(context, offset, whence)
-
-proc RWTell(context: PRWops): int = 
-  Result = context.seek(context, 0, 1)
-
-proc RWRead(context: PRWops, theptr: Pointer, size: int, n: int): int = 
-  Result = context.read(context, theptr, size, n)
-
-proc RWWrite(context: PRWops, theptr: Pointer, size: int, n: int): int = 
-  Result = context.write(context, theptr, size, n)
-
-proc RWClose(context: PRWops): int = 
-  Result = context.closeFile(context)
-
-proc LoadWAV(filename: cstring, spec: PAudioSpec, audio_buf: ptr byte, 
-             audiolen: PUInt32): PAudioSpec = 
-  Result = LoadWAV_RW(RWFromFile(filename, "rb"), 1, spec, audio_buf, audiolen)
-
-proc CDInDrive(status: TCDStatus): bool = 
-  Result = ord(status) > ord(CD_ERROR)
-
-proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) = 
-  var value: int
-  value = frames
-  F = value mod CD_FPS
-  value = value div CD_FPS
-  S = value mod 60
-  value = value div 60
-  M = value
-
-proc MSF_TO_FRAMES(M: int, S: int, F: int): int = 
-  Result = M * 60 * CD_FPS + S * CD_FPS + F
-
-proc VERSION(X: var TVersion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
-
-proc VERSIONNUM(X, Y, Z: int): int = 
-  Result = X * 1000 + Y * 100 + Z
-
-proc COMPILEDVERSION(): int = 
-  Result = VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL)
-
-proc VERSION_ATLEAST(X, Y, Z: int): bool = 
-  Result = (COMPILEDVERSION() >= VERSIONNUM(X, Y, Z))
-
-proc LoadBMP(filename: cstring): PSurface = 
-  Result = LoadBMP_RW(RWFromFile(filename, "rb"), 1)
-
-proc SaveBMP(surface: PSurface, filename: cstring): int = 
-  Result = SaveBMP_RW(surface, RWFromFile(filename, "wb"), 1)
-
-proc BlitSurface(src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int = 
-  Result = UpperBlit(src, srcrect, dst, dstrect)
-
-proc AllocSurface(flags: int32, width, height, depth: int, 
-                  RMask, GMask, BMask, AMask: int32): PSurface = 
-  Result = CreateRGBSurface(flags, width, height, depth, RMask, GMask, BMask, 
-                            AMask)
-
-proc MustLock(Surface: PSurface): bool = 
-  Result = ((surface^ .offset != 0) or
-      ((surface^ .flags and (HWSURFACE or ASYNCBLIT or RLEACCEL)) != 0))
-
-proc LockMutex(mutex: Pmutex): int = 
-  Result = mutexP(mutex)
-
-proc UnlockMutex(mutex: Pmutex): int = 
-  Result = mutexV(mutex)
-
-proc BUTTON(Button: int): int = 
-  Result = PRESSED shl (Button - 1)
-
-proc Swap32(D: int32): int32 = 
-  Result = ((D shl 24) or ((D shl 8) and 0x00FF0000) or
-      ((D shr 8) and 0x0000FF00) or (D shr 24))
-
-proc IsBitOn(value: int, bit: int8): bool = 
-  result = ((value and (1 shl ze(bit))) != 0)
-
-proc TurnBitOn(value: int, bit: int8): int = 
-  result = (value or (1 shl ze(bit)))
-
-proc TurnBitOff(value: int, bit: int8): int = 
-  result = (value and not (1 shl ze(bit)))
diff --git a/lib/wrappers/sdl/sdl_gfx.nim b/lib/wrappers/sdl/sdl_gfx.nim
deleted file mode 100755
index cf36c4989..000000000
--- a/lib/wrappers/sdl/sdl_gfx.nim
+++ /dev/null
@@ -1,452 +0,0 @@
-#
-#  $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
-#
-#
-#
-#  $Log: sdl_gfx.pas,v $
-#  Revision 1.3  2007/05/29 21:31:04  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.2  2007/05/20 20:30:18  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.1  2005/01/03 19:08:32  savage
-#  Header for the SDL_Gfx library.
-#
-#
-#
-#
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    gfxLibName = "SDL_gfx.dll"
-elif defined(macosx): 
-  const 
-    gfxLibName = "libSDL_gfx.dylib"
-else: 
-  const 
-    gfxLibName = "libSDL_gfx.so"
-const                         # Some rates in Hz
-  FPS_UPPER_LIMIT* = 200
-  FPS_LOWER_LIMIT* = 1
-  FPS_DEFAULT* = 30           # ---- Defines
-  SMOOTHING_OFF* = 0
-  SMOOTHING_ON* = 1
-
-type 
-  PFPSmanager* = ptr TFPSmanager
-  TFPSmanager*{.final.} = object  # ---- Structures
-    framecount*: Uint32
-    rateticks*: float32
-    lastticks*: Uint32
-    rate*: Uint32
-
-  PColorRGBA* = ptr TColorRGBA
-  TColorRGBA*{.final.} = object 
-    r*: byte
-    g*: byte
-    b*: byte
-    a*: byte
-
-  PColorY* = ptr TColorY
-  TColorY*{.final.} = object  #
-                              #
-                              # SDL_framerate: framerate manager
-                              #
-                              # LGPL (c) A. Schiffler
-                              #
-                              #
-    y*: byte
-
-
-proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate", 
-    dynlib: gfxLibName.}
-proc setFramerate*(manager: PFPSmanager, rate: cint): cint{.cdecl, 
-    importc: "SDL_setFramerate", dynlib: gfxLibName.}
-proc getFramerate*(manager: PFPSmanager): cint{.cdecl, 
-    importc: "SDL_getFramerate", dynlib: gfxLibName.}
-proc framerateDelay*(manager: PFPSmanager){.cdecl, 
-    importc: "SDL_framerateDelay", dynlib: gfxLibName.}
-  #
-  #
-  # SDL_gfxPrimitives: graphics primitives for SDL
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Note: all ___Color routines expect the color to be in format 0xRRGGBBAA 
-  # Pixel 
-proc pixelColor*(dst: PSurface, x: int16, y: int16, color: Uint32): cint{.
-    cdecl, importc: "pixelColor", dynlib: gfxLibName.}
-proc pixelRGBA*(dst: PSurface, x: int16, y: int16, r: byte, g: byte, 
-                b: byte, a: byte): cint{.cdecl, importc: "pixelRGBA", 
-    dynlib: gfxLibName.}
-  # Horizontal line 
-proc hlineColor*(dst: PSurface, x1: int16, x2: int16, y: int16, color: Uint32): cint{.
-    cdecl, importc: "hlineColor", dynlib: gfxLibName.}
-proc hlineRGBA*(dst: PSurface, x1: int16, x2: int16, y: int16, r: byte, 
-                g: byte, b: byte, a: byte): cint{.cdecl, importc: "hlineRGBA", 
-    dynlib: gfxLibName.}
-  # Vertical line 
-proc vlineColor*(dst: PSurface, x: int16, y1: int16, y2: int16, color: Uint32): cint{.
-    cdecl, importc: "vlineColor", dynlib: gfxLibName.}
-proc vlineRGBA*(dst: PSurface, x: int16, y1: int16, y2: int16, r: byte, 
-                g: byte, b: byte, a: byte): cint{.cdecl, importc: "vlineRGBA", 
-    dynlib: gfxLibName.}
-  # Rectangle 
-proc rectangleColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                     y2: int16, color: Uint32): cint{.cdecl, 
-    importc: "rectangleColor", dynlib: gfxLibName.}
-proc rectangleRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                    y2: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "rectangleRGBA", dynlib: gfxLibName.}
-  # Filled rectangle (Box) 
-proc boxColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-               color: Uint32): cint{.cdecl, importc: "boxColor", 
-                                    dynlib: gfxLibName.}
-proc boxRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-              r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "boxRGBA", dynlib: gfxLibName.}
-  # Line 
-proc lineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                color: Uint32): cint{.cdecl, importc: "lineColor", 
-                                     dynlib: gfxLibName.}
-proc lineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-               r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "lineRGBA", dynlib: gfxLibName.}
-  # AA Line 
-proc aalineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                  color: Uint32): cint{.cdecl, importc: "aalineColor", 
-                                       dynlib: gfxLibName.}
-proc aalineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aalineRGBA", dynlib: gfxLibName.}
-  # Circle 
-proc circleColor*(dst: PSurface, x: int16, y: int16, r: int16, color: Uint32): cint{.
-    cdecl, importc: "circleColor", dynlib: gfxLibName.}
-proc circleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
-                 g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "circleRGBA", dynlib: gfxLibName.}
-  # AA Circle 
-proc aacircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
-                    color: Uint32): cint{.cdecl, importc: "aacircleColor", 
-    dynlib: gfxLibName.}
-proc aacircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
-                   g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aacircleRGBA", dynlib: gfxLibName.}
-  # Filled Circle 
-proc filledCircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
-                        color: Uint32): cint{.cdecl, 
-    importc: "filledCircleColor", dynlib: gfxLibName.}
-proc filledCircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                       r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "filledCircleRGBA", dynlib: gfxLibName.}
-  # Ellipse 
-proc ellipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                   color: Uint32): cint{.cdecl, importc: "ellipseColor", 
-                                        dynlib: gfxLibName.}
-proc ellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                  r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "ellipseRGBA", dynlib: gfxLibName.}
-  # AA Ellipse 
-proc aaellipseColor*(dst: PSurface, xc: int16, yc: int16, rx: int16, 
-                     ry: int16, color: Uint32): cint{.cdecl, 
-    importc: "aaellipseColor", dynlib: gfxLibName.}
-proc aaellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
-                    r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aaellipseRGBA", dynlib: gfxLibName.}
-  # Filled Ellipse 
-proc filledEllipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, 
-                         ry: int16, color: Uint32): cint{.cdecl, 
-    importc: "filledEllipseColor", dynlib: gfxLibName.}
-proc filledEllipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, 
-                        ry: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "filledEllipseRGBA", dynlib: gfxLibName.}
-  # Pie
-proc pieColor*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
-               finish: int16, color: Uint32): cint{.cdecl, importc: "pieColor", 
-    dynlib: gfxLibName.}
-proc pieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
-              finish: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "pieRGBA", dynlib: gfxLibName.}
-  # Filled Pie
-proc filledPieColor*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                     start: int16, finish: int16, color: Uint32): cint{.cdecl, 
-    importc: "filledPieColor", dynlib: gfxLibName.}
-proc filledPieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
-                    start: int16, finish: int16, r: byte, g: byte, b: byte, 
-                    a: byte): cint{.cdecl, importc: "filledPieRGBA", 
-                                    dynlib: gfxLibName.}
-  # Trigon
-proc trigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                  x3: int16, y3: int16, color: Uint32): cint{.cdecl, 
-    importc: "trigonColor", dynlib: gfxLibName.}
-proc trigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
-                 x3: int16, y3: int16, r: byte, g: byte, b: byte, a: byte): cint{.
-    cdecl, importc: "trigonRGBA", dynlib: gfxLibName.}
-  # AA-Trigon
-proc aatrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                    y2: int16, x3: int16, y3: int16, color: Uint32): cint{.
-    cdecl, importc: "aatrigonColor", dynlib: gfxLibName.}
-proc aatrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                   y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
-                   b: byte, a: byte): cint{.cdecl, importc: "aatrigonRGBA", 
-    dynlib: gfxLibName.}
-  # Filled Trigon
-proc filledTrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                        y2: int16, x3: int16, y3: int16, color: Uint32): cint{.
-    cdecl, importc: "filledTrigonColor", dynlib: gfxLibName.}
-proc filledTrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
-                       y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
-                       b: byte, a: byte): cint{.cdecl, 
-    importc: "filledTrigonRGBA", dynlib: gfxLibName.}
-  # Polygon
-proc polygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                   color: Uint32): cint{.cdecl, importc: "polygonColor", 
-                                        dynlib: gfxLibName.}
-proc polygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
-                  g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "polygonRGBA", dynlib: gfxLibName.}
-  # AA-Polygon
-proc aapolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                     color: Uint32): cint{.cdecl, importc: "aapolygonColor", 
-    dynlib: gfxLibName.}
-proc aapolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
-                    g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "aapolygonRGBA", dynlib: gfxLibName.}
-  # Filled Polygon
-proc filledPolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                         color: Uint32): cint{.cdecl, 
-    importc: "filledPolygonColor", dynlib: gfxLibName.}
-proc filledPolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
-                        r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "filledPolygonRGBA", dynlib: gfxLibName.}
-  # Bezier
-  # s = number of steps
-proc bezierColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
-                  color: Uint32): cint{.cdecl, importc: "bezierColor", 
-                                       dynlib: gfxLibName.}
-proc bezierRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
-                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "bezierRGBA", dynlib: gfxLibName.}
-  # Characters/Strings
-proc characterColor*(dst: PSurface, x: int16, y: int16, c: char, color: Uint32): cint{.
-    cdecl, importc: "characterColor", dynlib: gfxLibName.}
-proc characterRGBA*(dst: PSurface, x: int16, y: int16, c: char, r: byte, 
-                    g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "characterRGBA", dynlib: gfxLibName.}
-proc stringColor*(dst: PSurface, x: int16, y: int16, c: cstring, color: Uint32): cint{.
-    cdecl, importc: "stringColor", dynlib: gfxLibName.}
-proc stringRGBA*(dst: PSurface, x: int16, y: int16, c: cstring, r: byte, 
-                 g: byte, b: byte, a: byte): cint{.cdecl, 
-    importc: "stringRGBA", dynlib: gfxLibName.}
-proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: cint, ch: cint){.cdecl, 
-    importc: "gfxPrimitivesSetFont", dynlib: gfxLibName.}
-  #
-  #
-  # SDL_imageFilter - bytes-image "filter" routines
-  # (uses inline x86 MMX optimizations if available)
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # Comments:                                                                           
-  #  1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. 
-  #  2.) Data that is not within an 8 byte boundary is processed using the C routine.   
-  #  3.) Convolution routines do not have C routines at this time.                      
-  # Detect MMX capability in CPU
-proc imageFilterMMXdetect*(): cint{.cdecl, importc: "SDL_imageFilterMMXdetect", 
-                                   dynlib: gfxLibName.}
-  # Force use of MMX off (or turn possible use back on)
-proc imageFilterMMXoff*(){.cdecl, importc: "SDL_imageFilterMMXoff", 
-                           dynlib: gfxLibName.}
-proc imageFilterMMXon*(){.cdecl, importc: "SDL_imageFilterMMXon", 
-                          dynlib: gfxLibName.}
-  #
-  # All routines return:
-  #   0   OK
-  #  -1   Error (internal error, parameter error)
-  #
-  #  SDL_imageFilterAdd: D = saturation255(S1 + S2)
-proc imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAdd", dynlib: gfxLibName.}
-  #  SDL_imageFilterMean: D = S1/2 + S2/2
-proc imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMean", dynlib: gfxLibName.}
-  #  SDL_imageFilterSub: D = saturation0(S1 - S2)
-proc imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSub", dynlib: gfxLibName.}
-  #  SDL_imageFilterAbsDiff: D = | S1 - S2 |
-proc imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAbsDiff", dynlib: gfxLibName.}
-  #  SDL_imageFilterMult: D = saturation(S1 * S2)
-proc imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMult", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultNor: D = S1 * S2   (non-MMX)
-proc imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterMultNor", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
-proc imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                            len: cint): cint{.cdecl, 
-    importc: "SDL_imageFilterMultDivby2", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
-proc imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring, 
-                            len: cint): cint{.cdecl, 
-    importc: "SDL_imageFilterMultDivby4", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitAnd: D = S1 & S2
-proc imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitAnd", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitOr: D = S1 | S2
-proc imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitOr", dynlib: gfxLibName.}
-  #  SDL_imageFilterDiv: D = S1 / S2   (non-MMX)
-proc imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterDiv", dynlib: gfxLibName.}
-  #  SDL_imageFilterBitNegation: D = !S
-proc imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: cint): cint{.
-    cdecl, importc: "SDL_imageFilterBitNegation", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddByte: D = saturation255(S + C)
-proc imageFilterAddByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
-    cdecl, importc: "SDL_imageFilterAddByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
-proc imageFilterAddUint*(Src1: cstring, Dest: cstring, len: cint, C: cint): cint{.
-    cdecl, importc: "SDL_imageFilterAddUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
-proc imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
-    cdecl, importc: "SDL_imageFilterAddByteToHalf", dynlib: gfxLibName.}
-  #  SDL_imageFilterSubByte: D = saturation0(S - C)
-proc imageFilterSubByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
-    cdecl, importc: "SDL_imageFilterSubByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
-proc imageFilterSubUint*(Src1: cstring, Dest: cstring, len: cint, C: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSubUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRight: D = saturation0(S >> N)
-proc imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
-proc imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftRightUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterMultByByte: D = saturation255(S * C)
-proc imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
-    cdecl, importc: "SDL_imageFilterMultByByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
-proc imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring, len: cint, 
-    N: char, C: char): cint{.cdecl, 
-                            importc: "SDL_imageFilterShiftRightAndMultByByte", 
-                            dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeftByte: D = (S << N)
-proc imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeftByte", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
-proc imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeftUint", dynlib: gfxLibName.}
-  #  SDL_imageFilterShiftLeft: D = saturation255(S << N)
-proc imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
-    cdecl, importc: "SDL_imageFilterShiftLeft", dynlib: gfxLibName.}
-  #  SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
-proc imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring, len: cint, 
-                                        T: char): cint{.cdecl, 
-    importc: "SDL_imageFilterBinarizeUsingThreshold", dynlib: gfxLibName.}
-  #  SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
-proc imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: cint, Tmin: int8, 
-                             Tmax: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterClipToRange", dynlib: gfxLibName.}
-  #  SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
-proc imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: cint, 
-                                 Cmin: cint, Cmax: cint, Nmin: cint, Nmax: cint): cint{.
-    cdecl, importc: "SDL_imageFilterNormalizeLinear", dynlib: gfxLibName.}
-  # !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! 
-  #  SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring, rows: cint, 
-    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel3x3Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring, rows: cint, 
-    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel5x5Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring, rows: cint, 
-    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel7x7Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring, rows: cint, 
-    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel9x9Divide", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel3x3ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel5x5ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel7x7ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
-proc imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring, 
-    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterConvolveKernel9x9ShiftRight", dynlib: gfxLibName.}
-  #  SDL_imageFilterSobelX: Dij = saturation255( ... )
-proc imageFilterSobelX*(Src: cstring, Dest: cstring, rows: cint, columns: cint): cint{.
-    cdecl, importc: "SDL_imageFilterSobelX", dynlib: gfxLibName.}
-  #  SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
-proc imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: cint, 
-                                  columns: cint, NRightShift: char): cint{.cdecl, 
-    importc: "SDL_imageFilterSobelXShiftRight", dynlib: gfxLibName.}
-  # Align/restore stack to 32 byte boundary -- Functionality untested! --
-proc imageFilterAlignStack*(){.cdecl, importc: "SDL_imageFilterAlignStack", 
-                               dynlib: gfxLibName.}
-proc imageFilterRestoreStack*(){.cdecl, importc: "SDL_imageFilterRestoreStack", 
-                                 dynlib: gfxLibName.}
-  #
-  #
-  # SDL_rotozoom - rotozoomer
-  #
-  # LGPL (c) A. Schiffler
-  #
-  #
-  # 
-  # 
-  # rotozoomSurface()
-  #
-  # Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc rotozoomSurface*(src: PSurface, angle: float64, zoom: float64, smooth: cint): PSurface{.
-    cdecl, importc: "rotozoomSurface", dynlib: gfxLibName.}
-proc rotozoomSurfaceXY*(src: PSurface, angle: float64, zoomx: float64, 
-                        zoomy: float64, smooth: cint): PSurface{.cdecl, 
-    importc: "rotozoomSurfaceXY", dynlib: gfxLibName.}
-  # Returns the size of the target surface for a rotozoomSurface() call 
-proc rotozoomSurfaceSize*(width: cint, height: cint, angle: float64, 
-                          zoom: float64, dstwidth: var cint, dstheight: var cint){.
-    cdecl, importc: "rotozoomSurfaceSize", dynlib: gfxLibName.}
-proc rotozoomSurfaceSizeXY*(width: cint, height: cint, angle: float64, 
-                            zoomx: float64, zoomy: float64, dstwidth: var cint, 
-                            dstheight: var cint){.cdecl, 
-    importc: "rotozoomSurfaceSizeXY", dynlib: gfxLibName.}
-  #
-  #
-  # zoomSurface()
-  #
-  # Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-  # 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
-  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-  #
-  #
-proc zoomSurface*(src: PSurface, zoomx: float64, zoomy: float64, smooth: cint): PSurface{.
-    cdecl, importc: "zoomSurface", dynlib: gfxLibName.}
-  # Returns the size of the target surface for a zoomSurface() call 
-proc zoomSurfaceSize*(width: cint, height: cint, zoomx: float64, zoomy: float64, 
-                      dstwidth: var cint, dstheight: var cint){.cdecl, 
-    importc: "zoomSurfaceSize", dynlib: gfxLibName.}
-# implementation
diff --git a/lib/wrappers/sdl/sdl_image.nim b/lib/wrappers/sdl/sdl_image.nim
deleted file mode 100755
index cc770a07f..000000000
--- a/lib/wrappers/sdl/sdl_image.nim
+++ /dev/null
@@ -1,232 +0,0 @@
-#
-#  $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
-#  
-#
-#******************************************************************************
-#                                                                              
-#       Borland Delphi SDL_Image - An example image loading library for use    
-#                                  with SDL                                    
-#       Conversion of the Simple DirectMedia Layer Image Headers               
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_image.h                                         
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Dominique Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#   A simple library to load images of various formats as SDL surfaces         
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas in your search path.                                               
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#   See the Aliens Demo on how to make use of this libaray                     
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April    02 2001 - MT : Initial Translation                                
-#                                                                              
-#   May      08 2001 - DL : Added ExternalSym derectives and copyright header  
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_image.pas,v $
-#  Revision 1.14  2007/05/29 21:31:13  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.13  2007/05/20 20:30:54  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.12  2006/12/02 00:14:40  savage
-#  Updated to latest version
-#
-#  Revision 1.11  2005/04/10 18:22:59  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.10  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.9  2005/01/05 01:47:07  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.8  2005/01/04 23:14:44  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.7  2005/01/01 02:03:12  savage
-#  Updated to v1.2.4
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    ImageLibName = "SDL_Image.dll"
-elif defined(macosx): 
-  const 
-    ImageLibName = "libSDL_image-1.2.0.dylib"
-else: 
-  const 
-    ImageLibName = "libSDL_image.so"
-const 
-  IMAGE_MAJOR_VERSION* = 1'i8
-  IMAGE_MINOR_VERSION* = 2'i8
-  IMAGE_PATCHLEVEL* = 5'i8
-
-# This macro can be used to fill a version structure with the compile-time
-#  version of the SDL_image library. 
-
-proc IMAGE_VERSION*(X: var TVersion)
-  # This function gets the version of the dynamically linked SDL_image library.
-  #   it should NOT be used to fill a version structure, instead you should
-  #   use the SDL_IMAGE_VERSION() macro.
-  # 
-proc IMG_Linked_Version*(): Pversion{.importc: "IMG_Linked_Version", 
-                                      dynlib: ImageLibName.}
-  # Load an image from an SDL data source.
-  #   The 'type' may be one of: "BMP", "GIF", "PNG", etc.
-  #
-  #   If the image format supports a transparent pixel, SDL will set the
-  #   colorkey for the surface.  You can enable RLE acceleration on the
-  #   surface afterwards by calling:
-  #        SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
-  #
-proc IMG_LoadTyped_RW*(src: PRWops, freesrc: cint, theType: cstring): PSurface{.
-    cdecl, importc: "IMG_LoadTyped_RW", dynlib: ImageLibName.}
-  # Convenience functions 
-proc IMG_Load*(theFile: cstring): PSurface{.cdecl, importc: "IMG_Load", 
-    dynlib: ImageLibName.}
-proc IMG_Load_RW*(src: PRWops, freesrc: cint): PSurface{.cdecl, 
-    importc: "IMG_Load_RW", dynlib: ImageLibName.}
-  # Invert the alpha of a surface for use with OpenGL
-  #  This function is now a no-op, and only provided for backwards compatibility. 
-proc IMG_InvertAlpha*(theOn: cint): cint{.cdecl, importc: "IMG_InvertAlpha", 
-                                        dynlib: ImageLibName.}
-  # Functions to detect a file type, given a seekable source 
-proc IMG_isBMP*(src: PRWops): cint{.cdecl, importc: "IMG_isBMP", 
-                                   dynlib: ImageLibName.}
-proc IMG_isGIF*(src: PRWops): cint{.cdecl, importc: "IMG_isGIF", 
-                                   dynlib: ImageLibName.}
-proc IMG_isJPG*(src: PRWops): cint{.cdecl, importc: "IMG_isJPG", 
-                                   dynlib: ImageLibName.}
-proc IMG_isLBM*(src: PRWops): cint{.cdecl, importc: "IMG_isLBM", 
-                                   dynlib: ImageLibName.}
-proc IMG_isPCX*(src: PRWops): cint{.cdecl, importc: "IMG_isPCX", 
-                                   dynlib: ImageLibName.}
-proc IMG_isPNG*(src: PRWops): cint{.cdecl, importc: "IMG_isPNG", 
-                                   dynlib: ImageLibName.}
-proc IMG_isPNM*(src: PRWops): cint{.cdecl, importc: "IMG_isPNM", 
-                                   dynlib: ImageLibName.}
-proc IMG_isTIF*(src: PRWops): cint{.cdecl, importc: "IMG_isTIF", 
-                                   dynlib: ImageLibName.}
-proc IMG_isXCF*(src: PRWops): cint{.cdecl, importc: "IMG_isXCF", 
-                                   dynlib: ImageLibName.}
-proc IMG_isXPM*(src: PRWops): cint{.cdecl, importc: "IMG_isXPM", 
-                                   dynlib: ImageLibName.}
-proc IMG_isXV*(src: PRWops): cint{.cdecl, importc: "IMG_isXV", 
-                                  dynlib: ImageLibName.}
-  # Individual loading functions 
-proc IMG_LoadBMP_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadBMP_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadGIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadGIF_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadJPG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadJPG_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadLBM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadLBM_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadPCX_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPCX_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadPNM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNM_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadPNG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNG_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadTGA_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTGA_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadTIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTIF_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadXCF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXCF_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadXPM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXPM_RW", 
-    dynlib: ImageLibName.}
-proc IMG_LoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW", 
-    dynlib: ImageLibName.}
-proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl, 
-    importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.}
-
-proc IMAGE_VERSION(X: var TVersion) = 
-  X.major = IMAGE_MAJOR_VERSION
-  X.minor = IMAGE_MINOR_VERSION
-  X.patch = IMAGE_PATCHLEVEL
-
diff --git a/lib/wrappers/sdl/sdl_mixer.nim b/lib/wrappers/sdl/sdl_mixer.nim
deleted file mode 100755
index 09abe182f..000000000
--- a/lib/wrappers/sdl/sdl_mixer.nim
+++ /dev/null
@@ -1,484 +0,0 @@
-#******************************************************************************
-#
-#  $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
-#
-#
-#
-#       Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
-#       Conversion of the Simple DirectMedia Layer Headers
-#
-# Portions created by Sam Lantinga <slouken@devolution.com> are
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
-# 5635-34 Springhouse Dr.
-# Pleasanton, CA 94588 (USA)
-#
-# All Rights Reserved.
-#
-# The original files are : SDL_mixer.h
-#                          music_cmd.h
-#                          wavestream.h
-#                          timidity.h
-#                          playmidi.h
-#                          music_ogg.h
-#                          mikmod.h
-#
-# The initial developer of this Pascal code was :
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>
-#
-# Portions created by Dominqiue Louis are
-# Copyright (C) 2000 - 2001 Dominqiue Louis.
-#
-#
-# Contributor(s)
-# --------------
-# Matthias Thoma <ma.thoma@gmx.de>
-#
-# Obtained through:
-# Joint Endeavour of Delphi Innovators ( Project JEDI )
-#
-# You may retrieve the latest version of this file at the Project
-# JEDI home page, located at http://delphi-jedi.org
-#
-# The contents of this file are used with permission, subject to
-# the Mozilla Public License Version 1.1 (the "License"); you may
-# not use this file except in compliance with the License. You may
-# obtain a copy of the License at
-# http://www.mozilla.org/MPL/MPL-1.1.html
-#
-# Software distributed under the License is distributed on an
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# Description
-# -----------
-#
-#
-#
-#
-#
-#
-#
-# Requires
-# --------
-#   SDL.pas & SMPEG.pas somewhere within your search path.
-#
-# Programming Notes
-# -----------------
-#   See the Aliens Demo to see how this library is used
-#
-# Revision History
-# ----------------
-#   April    02 2001 - DL : Initial Translation
-#
-#  February  02 2002 - DL : Update to version 1.2.1
-#
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more
-#                          Pascal compilers. Initial support is now included
-#                          for GnuPascal, VirtualPascal, TMT and obviously
-#                          continue support for Delphi Kylix and FreePascal.
-#
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support
-#
-#   April   30 2003 - DL : under instruction from David Mears AKA
-#                          Jason Siletto, I have added FPC Linux support.
-#                          This was compiled with fpc 1.1, so remember to set
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
-#
-#
-#  $Log: sdl_mixer.pas,v $
-#  Revision 1.18  2007/05/29 21:31:44  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.17  2007/05/20 20:31:17  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.16  2006/12/02 00:16:17  savage
-#  Updated to latest version
-#
-#  Revision 1.15  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.14  2005/02/24 20:20:07  savage
-#  Changed definition of MusicType and added GetMusicType function
-#
-#  Revision 1.13  2005/01/05 01:47:09  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.12  2005/01/04 23:14:56  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.11  2005/01/01 02:05:19  savage
-#  Updated to v1.2.6
-#
-#  Revision 1.10  2004/09/12 21:45:17  savage
-#  Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
-#
-#  Revision 1.9  2004/08/27 21:48:24  savage
-#  IFDEFed out Smpeg support on MacOS X
-#
-#  Revision 1.8  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.7  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.6  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.5  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.4  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.3  2004/03/31 10:05:08  savage
-#  Better defines for Endianess under FreePascal and Borland compilers.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#
-#
-#******************************************************************************
-
-import 
-  sdl, smpeg
-
-when defined(windows): 
-  const 
-    MixerLibName = "SDL_mixer.dll"
-elif defined(macosx): 
-  const 
-    MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else: 
-  const 
-    MixerLibName = "libSDL_mixer.so"
-const 
-  MAJOR_VERSION* = 1'i8
-  MINOR_VERSION* = 2'i8
-  PATCHLEVEL* = 7'i8    # Backwards compatibility
-  
-  CHANNELS* = 8           # Good default values for a PC soundcard
-  DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32): 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16LSB
-else: 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16MSB
-const 
-  DEFAULT_CHANNELS* = 2
-  MAX_VOLUME* = 128       # Volume of a chunk
-  PATH_MAX* = 255             # mikmod.h constants
-                              #*
-                              #  * Library version
-                              #  *
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr TMusicCMD
-  TMusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr TWAVStream
-  TWAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: Pointer
-    start*: int32
-    stop*: int32
-    cvt*: TAudioCVT
-
-  PMidiEvent* = ptr TMidiEvent
-  TMidiEvent*{.final.} = object 
-    time*: int32
-    channel*: byte
-    typ*: byte
-    a*: byte
-    b*: byte
-
-  PMidiSong* = ptr TMidiSong
-  TMidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr TOGG_Music
-  TOGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: int32
-    volume*: int32              #vf: OggVorbis_File;
-    section*: int32
-    cvt*: TAudioCVT
-    len_available*: int32
-    snd_available*: pointer
-
-  TErrorEnum* = enum 
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, 
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, 
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, 
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, 
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, 
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, 
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, 
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, 
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, 
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, 
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, 
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, 
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, 
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, 
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, 
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, 
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, 
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, 
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr TMODULE
-  TMODULE*{.final.} = object 
-  PUNIMOD* = ptr TUNIMOD
-  TUNIMOD* = TMODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk
-  PChunk* = ptr TChunk
-  TChunk*{.final.} = object 
-    allocated*: cint
-    abuf*: pointer
-    alen*: Uint32
-    volume*: byte            # Per-sample volume, 0-128
-  
-  TFading* = enum 
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  TMusicType* = enum 
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
-  PMusic* = ptr TMusic
-  TMusic*{.final.} = object  # The internal format for a music chunk interpreted via mikmod
-    mixtype*: TMusicType      # other fields are not aviable
-                              #    data : TMusicUnion;
-                              #    fading : TMix_Fading;
-                              #    fade_volume : integer;
-                              #    fade_step : integer;
-                              #    fade_steps : integer;
-                              #    error : integer;
-  
-  TMixFunction* = proc (udata, stream: pointer, length: cint): Pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library.
-
-proc VERSION*(X: var sdl.TVersion)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro.
-proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version", 
-                                      dynlib: MixerLibName.}
-  # Open the mixer with a certain audio format
-proc OpenAudio*(frequency: cint, format: Uint16, channels: cint, 
-                    chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio", 
-    dynlib: MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  #
-proc AllocateChannels*(numchannels: cint): cint{.cdecl, 
-    importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  #
-proc QuerySpec*(frequency: var cint, format: var Uint16, channels: var cint): cint{.
-    cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file
-proc LoadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl, 
-    importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
-proc LoadWAV*(filename: cstring): PChunk
-proc LoadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS", 
-    dynlib: MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer
-proc QuickLoad_WAV*(mem: pointer): PChunk{.cdecl, 
-    importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
-  # Free an audio chunk previously loaded
-proc FreeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk", 
-                                        dynlib: MixerLibName.}
-proc FreeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", 
-                                        dynlib: MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc GetMusicType*(music: PMusic): TMusicType{.cdecl, 
-    importc: "Mix_GetMusicType", dynlib: MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, 
-    importc: "Mix_SetPostMix", dynlib: MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  #
-proc HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, 
-    importc: "Mix_HookMusic", dynlib: MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  #
-proc HookMusicFinished*(music_finished: Pointer){.cdecl, 
-    importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
-  # Get a pointer to the user data for the current music hook
-proc GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", 
-                                       dynlib: MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type 
-  TChannel_finished* = proc (channel: cint){.cdecl.}
-
-proc ChannelFinished*(channel_finished: TChannel_finished){.cdecl, 
-    importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
-const 
-  CHANNEL_POST* = - 2     
-
-type 
-  TEffectFunc* = proc (chan: cint, stream: Pointer, length: cint, 
-                       udata: Pointer): Pointer{.cdecl.}     
-  TEffectDone* = proc (chan: cint, udata: Pointer): Pointer{.cdecl.} 
-proc RegisterEffect*(chan: cint, f: TEffectFunc, d: TEffectDone, 
-                         arg: Pointer): cint{.cdecl, 
-    importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
-
-proc UnregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl, 
-    importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
-
-proc UnregisterAllEffects*(channel: cint): cint{.cdecl, 
-    importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
-const 
-  EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
-  
-proc SetPanning*(channel: cint, left: byte, right: byte): cint{.cdecl, 
-    importc: "Mix_SetPanning", dynlib: MixerLibName.}
-
-proc SetPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetPosition", dynlib: MixerLibName.}
-
-proc SetDistance*(channel: cint, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetDistance", dynlib: MixerLibName.}
-
-proc SetReverseStereo*(channel: cint, flip: cint): cint{.cdecl, 
-    importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
-
-proc ReserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels", 
-    dynlib: MixerLibName.}
-
-proc GroupChannel*(which: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannel", dynlib: MixerLibName.}
-proc GroupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannels", dynlib: MixerLibName.}
-proc GroupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable", 
-    dynlib: MixerLibName.}
-proc GroupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount", 
-                                     dynlib: MixerLibName.}
-proc GroupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest", 
-                                      dynlib: MixerLibName.}
-proc GroupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer", 
-                                     dynlib: MixerLibName.}
-proc PlayChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                           ticks: cint): cint{.cdecl, 
-    importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
-proc PlayChannel*(channel: cint, chunk: PChunk, loops: cint): cint
-proc PlayMusic*(music: PMusic, loops: cint): cint{.cdecl, 
-    importc: "Mix_PlayMusic", dynlib: MixerLibName.}
-proc FadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
-proc FadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                             ms: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
-proc FadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
-
-proc Volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume", 
-    dynlib: MixerLibName.}
-proc VolumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl, 
-    importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
-proc VolumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic", 
-    dynlib: MixerLibName.}
-
-proc HaltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel", 
-    dynlib: MixerLibName.}
-proc HaltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup", 
-                                    dynlib: MixerLibName.}
-proc HaltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic", 
-                            dynlib: MixerLibName.}
-  # Change the expiration delay for a particular channel.
-  #   The sample will stop playing after the 'ticks' milliseconds have elapsed,
-  #   or remove the expiration if 'ticks' is -1
-  #
-proc ExpireChannel*(channel: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
-  # Halt a channel, fading it out progressively till it's silent
-  #   The ms parameter indicates the number of milliseconds the fading
-  #   will take.
-  #
-proc FadeOutChannel*(which: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
-proc FadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
-proc FadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", 
-                                      dynlib: MixerLibName.}
-  # Query the fading status of a channel
-proc FadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic", 
-                                      dynlib: MixerLibName.}
-proc FadingChannel*(which: cint): TFading{.cdecl, 
-    importc: "Mix_FadingChannel", dynlib: MixerLibName.}
-
-proc Pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
-proc Resume*(channel: cint){.cdecl, importc: "Mix_Resume", 
-                                dynlib: MixerLibName.}
-proc Paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused", 
-                                     dynlib: MixerLibName.}
-
-proc PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
-proc ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
-proc RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
-proc PausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic", 
-                              dynlib: MixerLibName.}
-
-proc SetMusicPosition*(position: float64): cint{.cdecl, 
-    importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
-
-proc Playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing", 
-                                      dynlib: MixerLibName.}
-proc PlayingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic", 
-                               dynlib: MixerLibName.}
-
-proc SetMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD", 
-    dynlib: MixerLibName.}
-
-proc SetSynchroValue*(value: cint): cint{.cdecl, 
-    importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
-proc GetSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue", 
-                                  dynlib: MixerLibName.}
-
-proc GetChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", 
-    dynlib: MixerLibName.}
-
-proc CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
-
-proc VERSION(X: var sdl.Tversion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
-
-proc LoadWAV(filename: cstring): PChunk = 
-  result = LoadWAV_RW(RWFromFile(filename, "rb"), 1)
-
-proc PlayChannel(channel: cint, chunk: PChunk, loops: cint): cint = 
-  result = PlayChannelTimed(channel, chunk, loops, - 1)
-
-proc FadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint = 
-  result = FadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
diff --git a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim b/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim
deleted file mode 100755
index 885e9845b..000000000
--- a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim
+++ /dev/null
@@ -1,351 +0,0 @@
-#******************************************************************************
-# Copy of SDL_Mixer without smpeg dependency and mp3 support                    
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    MixerLibName = "SDL_mixer.dll"
-elif defined(macosx): 
-  const 
-    MixerLibName = "libSDL_mixer-1.2.0.dylib"
-else: 
-  const 
-    MixerLibName = "libSDL_mixer.so"
-const 
-  MAJOR_VERSION* = 1'i8
-  MINOR_VERSION* = 2'i8
-  PATCHLEVEL* = 7'i8    # Backwards compatibility
-   
-  CHANNELS* = 8           # Good default values for a PC soundcard 
-  DEFAULT_FREQUENCY* = 22050
-
-when defined(IA32): 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16LSB
-else: 
-  const 
-    DEFAULT_FORMAT* = AUDIO_S16MSB
-const 
-  DEFAULT_CHANNELS* = 2
-  MAX_VOLUME* = 128       # Volume of a chunk 
-  PATH_MAX* = 255
-  
-  LIBMIKMOD_VERSION_MAJOR* = 3
-  LIBMIKMOD_VERSION_MINOR* = 1
-  LIBMIKMOD_REVISION* = 8
-  LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
-      (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
-
-type                          #music_cmd.h types
-  PMusicCMD* = ptr TMusicCMD
-  TMusicCMD*{.final.} = object  #wavestream.h types
-    filename*: array[0..PATH_MAX - 1, char]
-    cmd*: array[0..PATH_MAX - 1, char]
-    pid*: TSYS_ThreadHandle
-
-  PWAVStream* = ptr TWAVStream
-  TWAVStream*{.final.} = object  #playmidi.h types
-    wavefp*: Pointer
-    start*: int32
-    stop*: int32
-    cvt*: TAudioCVT
-
-  PMidiEvent* = ptr TMidiEvent
-  TMidiEvent*{.final.} = object 
-    time*: int32
-    channel*: byte
-    typ*: byte
-    a*: byte
-    b*: byte
-
-  PMidiSong* = ptr TMidiSong
-  TMidiSong*{.final.} = object  #music_ogg.h types
-    samples*: int32
-    events*: PMidiEvent
-
-  POGG_Music* = ptr TOGG_Music
-  TOGG_Music*{.final.} = object  # mikmod.h types
-                                 #*
-                                 #  * Error codes
-                                 #  *
-    playing*: cint
-    volume*: cint              #vf: OggVorbis_File;
-    section*: cint
-    cvt*: TAudioCVT
-    len_available*: cint
-    snd_available*: pointer
-
-  TErrorEnum* = enum 
-    MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, 
-    MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, 
-    MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, 
-    MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, 
-    MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, 
-    MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, 
-    MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, 
-    MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, 
-    MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, 
-    MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, 
-    MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, 
-    MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, 
-    MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, 
-    MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, 
-    MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, 
-    MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, 
-    MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, 
-    MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, 
-    MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
-  PMODULE* = ptr TMODULE
-  TMODULE*{.final.} = object 
-  PUNIMOD* = ptr TUNIMOD
-  TUNIMOD* = TMODULE          #SDL_mixer.h types
-                              # The internal format for an audio chunk 
-  PChunk* = ptr TChunk
-  TChunk*{.final.} = object 
-    allocated*: cint
-    abuf*: pointer
-    alen*: Uint32
-    volume*: byte            # Per-sample volume, 0-128 
-  
-  TFading* = enum 
-    MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
-  TMusicType* = enum 
-    MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
-  PMusic* = ptr TMusic
-  TMusic*{.final.} = object 
-    typ*: TMusicType
-
-  TMixFunction* = proc (udata, stream: pointer, length: cint): Pointer{.
-      cdecl.} # This macro can be used to fill a version structure with the compile-time
-              #  version of the SDL_mixer library. 
-
-proc VERSION*(X: var sdl.TVersion)
-  # This function gets the version of the dynamically linked SDL_mixer library.
-  #     It should NOT be used to fill a version structure, instead you should use the
-  #     SDL_MIXER_VERSION() macro. 
-proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version", 
-                                      dynlib: MixerLibName.}
-  # Open the mixer with a certain audio format 
-proc OpenAudio*(frequency: cint, format: Uint16, channels: cint, 
-                    chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio", 
-    dynlib: MixerLibName.}
-  # Dynamically change the number of channels managed by the mixer.
-  #   If decreasing the number of channels, the upper channels are
-  #   stopped.
-  #   This function returns the new number of allocated channels.
-  # 
-proc AllocateChannels*(numchannels: cint): cint{.cdecl, 
-    importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
-  # Find out what the actual audio device parameters are.
-  #   This function returns 1 if the audio has been opened, 0 otherwise.
-  # 
-proc QuerySpec*(frequency: var cint, format: var Uint16, channels: var cint): cint{.
-    cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
-  # Load a wave file or a music (.mod .s3m .it .xm) file 
-proc LoadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl, 
-    importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
-proc LoadWAV*(filename: cstring): PChunk
-proc LoadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS", 
-    dynlib: MixerLibName.}
-  # Load a wave file of the mixer format from a memory buffer 
-proc QuickLoad_WAV*(mem: pointer): PChunk{.cdecl, 
-    importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
-  # Free an audio chunk previously loaded 
-proc FreeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk", 
-                                        dynlib: MixerLibName.}
-proc FreeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", 
-                                        dynlib: MixerLibName.}
-  # Find out the music format of a mixer music, or the currently playing
-  #   music, if 'music' is NULL.
-proc GetMusicType*(music: PMusic): TMusicType{.cdecl, 
-    importc: "Mix_GetMusicType", dynlib: MixerLibName.}
-  # Set a function that is called after all mixing is performed.
-  #   This can be used to provide real-time visual display of the audio stream
-  #   or add a custom mixer filter for the stream data.
-  #
-proc SetPostMix*(mixfunc: TMixFunction, arg: Pointer){.cdecl, 
-    importc: "Mix_SetPostMix", dynlib: MixerLibName.}
-  # Add your own music player or additional mixer function.
-  #   If 'mix_func' is NULL, the default music player is re-enabled.
-  # 
-proc HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, 
-    importc: "Mix_HookMusic", dynlib: MixerLibName.}
-  # Add your own callback when the music has finished playing.
-  # 
-proc HookMusicFinished*(music_finished: Pointer){.cdecl, 
-    importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
-  # Get a pointer to the user data for the current music hook 
-proc GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", 
-                                       dynlib: MixerLibName.}
-  #* Add your own callback when a channel has finished playing. NULL
-  # * to disable callback.*
-type 
-  TChannel_finished* = proc (channel: cint){.cdecl.}
-
-proc ChannelFinished*(channel_finished: TChannel_finished){.cdecl, 
-    importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
-const 
-  CHANNEL_POST* = - 2 
-  
-type 
-  TEffectFunc* = proc (chan: cint, stream: Pointer, length: cint, 
-                           udata: Pointer): Pointer{.cdecl.} 
-  TEffectDone* = proc (chan: cint, udata: Pointer): Pointer{.cdecl.} 
-
-proc RegisterEffect*(chan: cint, f: TEffectFunc, d: TEffectDone, 
-                         arg: Pointer): cint{.cdecl, 
-    importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
-
-proc UnregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl, 
-    importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
-
-proc UnregisterAllEffects*(channel: cint): cint{.cdecl, 
-    importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
-
-const 
-  EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"  
-  
-proc SetPanning*(channel: cint, left: byte, right: byte): cint{.cdecl, 
-    importc: "Mix_SetPanning", dynlib: MixerLibName.}
-   
-proc SetPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetPosition", dynlib: MixerLibName.}
-   
-proc SetDistance*(channel: cint, distance: byte): cint{.cdecl, 
-    importc: "Mix_SetDistance", dynlib: MixerLibName.}
-
-proc SetReverseStereo*(channel: cint, flip: cint): cint{.cdecl, 
-    importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
-
-proc ReserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels", 
-    dynlib: MixerLibName.}
-
-proc GroupChannel*(which: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannel", dynlib: MixerLibName.}
-  # Assign several consecutive channels to a group 
-proc GroupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl, 
-    importc: "Mix_GroupChannels", dynlib: MixerLibName.}
-  # Finds the first available channel in a group of channels 
-proc GroupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable", 
-    dynlib: MixerLibName.}
-  # Returns the number of channels in a group. This is also a subtle
-  #   way to get the total number of channels when 'tag' is -1
-  # 
-proc GroupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount", 
-                                     dynlib: MixerLibName.}
-  # Finds the "oldest" sample playing in a group of channels 
-proc GroupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest", 
-                                      dynlib: MixerLibName.}
-  # Finds the "most recent" (i.e. last) sample playing in a group of channels 
-proc GroupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer", 
-                                     dynlib: MixerLibName.}
-  # The same as above, but the sound is played at most 'ticks' milliseconds 
-proc PlayChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                           ticks: cint): cint{.cdecl, 
-    importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
-
-proc PlayChannel*(channel: cint, chunk: PChunk, loops: cint): cint
-proc PlayMusic*(music: PMusic, loops: cint): cint{.cdecl, 
-    importc: "Mix_PlayMusic", dynlib: MixerLibName.}
-  # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions 
-proc FadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
-proc FadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint, 
-                             ms: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
-proc FadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
-  # Set the volume in the range of 0-128 of a specific channel or chunk.
-  #   If the specified channel is -1, set volume for all channels.
-  #   Returns the original volume.
-  #   If the specified volume is -1, just return the current volume.
-  #
-proc Volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume", 
-    dynlib: MixerLibName.}
-proc VolumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl, 
-    importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
-proc VolumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic", 
-    dynlib: MixerLibName.}
-  # Halt playing of a particular channel 
-proc HaltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel", 
-    dynlib: MixerLibName.}
-proc HaltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup", 
-                                    dynlib: MixerLibName.}
-proc HaltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic", 
-                            dynlib: MixerLibName.}
-
-proc ExpireChannel*(channel: cint, ticks: cint): cint{.cdecl, 
-    importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
-
-proc FadeOutChannel*(which: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
-proc FadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, 
-    importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
-proc FadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", 
-                                      dynlib: MixerLibName.}
-  # Query the fading status of a channel 
-proc FadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic", 
-                                      dynlib: MixerLibName.}
-proc FadingChannel*(which: cint): TFading{.cdecl, 
-    importc: "Mix_FadingChannel", dynlib: MixerLibName.}
-  # Pause/Resume a particular channel 
-proc Pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
-proc Resume*(channel: cint){.cdecl, importc: "Mix_Resume", 
-                                dynlib: MixerLibName.}
-proc Paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused", 
-                                     dynlib: MixerLibName.}
-  # Pause/Resume the music stream 
-proc PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
-proc ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
-proc RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
-proc PausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic", 
-                              dynlib: MixerLibName.}
-  # Set the current position in the music stream.
-  #  This returns 0 if successful, or -1 if it failed or isn't implemented.
-  #  This function is only implemented for MOD music formats (set pattern
-  #  order number) and for OGG music (set position in seconds), at the
-  #  moment.
-  #
-proc SetMusicPosition*(position: float64): cint{.cdecl, 
-    importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
-  # Check the status of a specific channel.
-  #   If the specified channel is -1, check all channels.
-  #
-proc Playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing", 
-                                      dynlib: MixerLibName.}
-proc PlayingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic", 
-                               dynlib: MixerLibName.}
-  # Stop music and set external music playback command 
-proc SetMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD", 
-    dynlib: MixerLibName.}
-  # Synchro value is set by MikMod from modules while playing 
-proc SetSynchroValue*(value: cint): cint{.cdecl, 
-    importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
-proc GetSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue", 
-                                  dynlib: MixerLibName.}
-  #
-  #  Get the Mix_Chunk currently associated with a mixer channel
-  #    Returns nil if it's an invalid channel, or there's no chunk associated.
-  #
-proc GetChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", 
-    dynlib: MixerLibName.}
-  # Close the mixer, halting all playing audio 
-proc CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
-  # We'll use SDL for reporting errors 
-
-proc VERSION(X: var Tversion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
-
-proc LoadWAV(filename: cstring): PChunk = 
-  result = LoadWAV_RW(RWFromFile(filename, "rb"), 1)
-
-proc PlayChannel(channel: cint, chunk: PChunk, loops: cint): cint = 
-  result = PlayChannelTimed(channel, chunk, loops, - 1)
-
-proc FadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint = 
-  result = FadeInChannelTimed(channel, chunk, loops, ms, - 1)
-
diff --git a/lib/wrappers/sdl/sdl_net.nim b/lib/wrappers/sdl/sdl_net.nim
deleted file mode 100755
index bfd4f0a28..000000000
--- a/lib/wrappers/sdl/sdl_net.nim
+++ /dev/null
@@ -1,427 +0,0 @@
-#******************************************************************************
-#
-#  $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
-#
-#
-#                                                                              
-#       Borland Delphi SDL_Net - A x-platform network library for use with SDL.
-#       Conversion of the Simple DirectMedia Layer Network Headers             
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_net.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   SDL.pas somehere in your search path                                       
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   April   09 2001 - DL : Initial Translation                                 
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_net.pas,v $
-#  Revision 1.7  2005/01/01 02:14:21  savage
-#  Updated to v1.2.5
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:23  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#
-#
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    NetLibName = "SDL_net.dll"
-elif defined(macosx): 
-  const 
-    NetLibName = "libSDL_net.dylib"
-else: 
-  const 
-    NetLibName = "libSDL_net.so"
-const                         #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
-  MAJOR_VERSION* = 1'i8
-  MINOR_VERSION* = 2'i8
-  PATCHLEVEL* = 5'i8     # SDL_Net.h constants
-                         #* Resolve a host name and port to an IP address in network form.
-                         #   If the function succeeds, it will return 0.
-                         #   If the host couldn't be resolved, the host portion of the returned
-                         #   address will be INADDR_NONE, and the function will return -1.
-                         #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-                         # *
-  INADDR_ANY* = 0x00000000
-  INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
-                            #* UDP network API                                                     *
-                            #***********************************************************************
-                            #* The maximum channels on a a UDP socket *
-  MAX_UDPCHANNELS* = 32   #* The maximum addresses bound to a single UDP socket channel *
-  MAX_UDPADDRESSES* = 4
-
-type  # SDL_net.h types
-      #***********************************************************************
-      #* IPv4 hostname resolution API                                        *
-      #***********************************************************************
-  PIPAddress* = ptr TIPAddress
-  TIPAddress*{.final.} = object  #* TCP network API                                                     
-    host*: Uint32             # 32-bit IPv4 host address */
-    port*: Uint16             # 16-bit protocol port */
-  
-  PTCPSocket* = ptr TTCPSocket
-  TTCPSocket*{.final.} = object  # UDP network API
-    ready*: int
-    channel*: int
-    remoteAddress*: TIPaddress
-    localAddress*: TIPaddress
-    sflag*: int
-
-  PUDP_Channel* = ptr TUDP_Channel
-  TUDP_Channel*{.final.} = object 
-    numbound*: int
-    address*: array[0..MAX_UDPADDRESSES - 1, TIPAddress]
-
-  PUDPSocket* = ptr TUDPSocket
-  TUDPSocket*{.final.} = object 
-    ready*: int
-    channel*: int
-    address*: TIPAddress
-    binding*: array[0..MAX_UDPCHANNELS - 1, TUDP_Channel]
-
-  PUDPpacket* = ptr TUDPpacket
-  PPUDPpacket* = ptr PUDPpacket
-  TUDPpacket*{.final.} = object  #***********************************************************************
-                                 #* Hooks for checking sockets for available data                       *
-                                 #***********************************************************************
-    channel*: int             #* The src/dst channel of the packet *
-    data*: pointer            #* The packet data *
-    length*: int              #* The length of the packet data *
-    maxlen*: int              #* The size of the data buffer *
-    status*: int              #* packet status after sending *
-    address*: TIPAddress      #* The source/dest address of an incoming/outgoing packet *
-  
-  PSocket* = ptr TSocket
-  TSocket*{.final.} = object 
-    ready*: int
-    channel*: int
-
-  PSocketSet* = ptr TSocketSet
-  TSocketSet*{.final.} = object  # Any network socket can be safely cast to this socket type *
-    numsockets*: int
-    maxsockets*: int
-    sockets*: PSocket
-
-  PGenericSocket* = ptr TGenericSocket
-  TGenericSocket*{.final.} = object 
-    ready*: int
-
-
-proc VERSION*(X: var Tversion)
-  #* Initialize/Cleanup the network API
-  #   SDL must be initialized before calls to functions in this library,
-  #   because this library uses utility functions from the SDL library.
-  #*
-proc Init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}
-proc Quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}
-  #* Resolve a host name and port to an IP address in network form.
-  #   If the function succeeds, it will return 0.
-  #   If the host couldn't be resolved, the host portion of the returned
-  #   address will be INADDR_NONE, and the function will return -1.
-  #   If 'host' is NULL, the resolved host will be set to INADDR_ANY.
-  # *
-proc ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
-    cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}
-  #* Resolve an ip address to a host name in canonical form.
-  #   If the ip couldn't be resolved, this function returns NULL,
-  #   otherwise a pointer to a static buffer containing the hostname
-  #   is returned.  Note that this function is not thread-safe.
-  #*
-proc ResolveIP*(ip: var TIPaddress): cstring{.cdecl, 
-    importc: "SDLNet_ResolveIP", dynlib: NetLibName.}
-  #***********************************************************************
-  #* TCP network API                                                     *
-  #***********************************************************************
-  #* Open a TCP network socket
-  #   If ip.host is INADDR_NONE, this creates a local server socket on the
-  #   given port, otherwise a TCP connection to the remote host and port is
-  #   attempted.  The address passed in should already be swapped to network
-  #   byte order (addresses returned from SDLNet_ResolveHost() are already
-  #   in the correct form).
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl, 
-    importc: "SDLNet_TCP_Open", dynlib: NetLibName.}
-  #* Accept an incoming connection on the given server socket.
-  #   The newly created socket is returned, or NULL if there was an error.
-  #*
-proc TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl, 
-    importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}
-  #* Get the IP address of the remote system associated with the socket.
-  #   If the socket is a server socket, this function returns NULL.
-  #*
-proc TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl, 
-    importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}
-  #* Send 'len' bytes of 'data' over the non-server socket 'sock'
-  #   This function returns the actual amount of data sent.  If the return value
-  #   is less than the amount of data sent, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl, 
-    importc: "SDLNet_TCP_Send", dynlib: NetLibName.}
-  #* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
-  #   and store them in the buffer pointed to by 'data'.
-  #   This function returns the actual amount of data received.  If the return
-  #   value is less than or equal to zero, then either the remote connection was
-  #   closed, or an unknown socket error occurred.
-  #*
-proc TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl, 
-    importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}
-  #* Close a TCP network socket *
-proc TCP_Close*(sock: PTCPsocket){.cdecl, importc: "SDLNet_TCP_Close", 
-                                       dynlib: NetLibName.}
-  #***********************************************************************
-  #* UDP network API                                                     *
-  #***********************************************************************
-  #* Allocate/resize/free a single UDP packet 'size' bytes long.
-  #   The new packet is returned, or NULL if the function ran out of memory.
-  # *
-proc AllocPacket*(size: int): PUDPpacket{.cdecl, 
-    importc: "SDLNet_AllocPacket", dynlib: NetLibName.}
-proc ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl, 
-    importc: "SDLNet_ResizePacket", dynlib: NetLibName.}
-proc FreePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket", 
-    dynlib: NetLibName.}
-  #* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
-  #   each 'size' bytes long.
-  #   A pointer to the first packet in the array is returned, or NULL if the
-  #   function ran out of memory.
-  # *
-proc AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl, 
-    importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}
-proc FreePacketV*(packetV: PUDPpacket){.cdecl, 
-    importc: "SDLNet_FreePacketV", dynlib: NetLibName.}
-  #* Open a UDP network socket
-  #   If 'port' is non-zero, the UDP socket is bound to a local port.
-  #   This allows other systems to send to this socket via a known port.
-  #*
-proc UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc: "SDLNet_UDP_Open", 
-    dynlib: NetLibName.}
-  #* Bind the address 'address' to the requested channel on the UDP socket.
-  #   If the channel is -1, then the first unbound channel will be bound with
-  #   the given address as it's primary address.
-  #   If the channel is already bound, this new address will be added to the
-  #   list of valid source addresses for packets arriving on the channel.
-  #   If the channel is not already bound, then the address becomes the primary
-  #   address, to which all outbound packets on the channel are sent.
-  #   This function returns the channel which was bound, or -1 on error.
-  #*
-proc UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
-    cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}
-  #* Unbind all addresses from the given channel *
-proc UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl, 
-    importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}
-  #* Get the primary IP address of the remote system associated with the
-  #   socket and channel.  If the channel is -1, then the primary IP port
-  #   of the UDP socket is returned -- this is only meaningful for sockets
-  #   opened with a specific port.
-  #   If the channel is not bound and not -1, this function returns NULL.
-  # *
-proc UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.cdecl, 
-    importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}
-  #* Send a vector of packets to the the channels specified within the packet.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   Each packet will be updated with the status of the packet after it has
-  #   been sent, -1 if the packet send failed.
-  #   This function returns the number of packets sent.
-  #*
-proc UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
-    cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}
-  #* Send a single packet to the specified channel.
-  #   If the channel specified in the packet is -1, the packet will be sent to
-  #   the address in the 'src' member of the packet.
-  #   The packet will be updated with the status of the packet after it has
-  #   been sent.
-  #   This function returns 1 if the packet was sent, or 0 on error.
-  #*
-proc UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
-    cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.}
-  #* Receive a vector of pending packets from the UDP socket.
-  #   The returned packets contain the source address and the channel they arrived
-  #   on.  If they did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl, 
-    importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}
-  #* Receive a single packet from the UDP socket.
-  #   The returned packet contains the source address and the channel it arrived
-  #   on.  If it did not arrive on a bound channel, the the channel will be set
-  #   to -1.
-  #   The channels are checked in highest to lowest order, so if an address is
-  #   bound to multiple channels, the highest channel with the source address
-  #   bound will be returned.
-  #   This function returns the number of packets read from the network, or -1
-  #   on error.  This function does not block, so can return 0 packets pending.
-  #*
-proc UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl, 
-    importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}
-  #* Close a UDP network socket *
-proc UDP_Close*(sock: PUDPsocket){.cdecl, importc: "SDLNet_UDP_Close", 
-                                       dynlib: NetLibName.}
-  #***********************************************************************
-  #* Hooks for checking sockets for available data                       *
-  #***********************************************************************
-  #* Allocate a socket set for use with SDLNet_CheckSockets()
-  #   This returns a socket set for up to 'maxsockets' sockets, or NULL if
-  #   the function ran out of memory.
-  # *
-proc AllocSocketSet*(maxsockets: int): PSocketSet{.cdecl, 
-    importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}
-  #* Add a socket to a set of sockets to be checked for available data *
-proc AddSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
-    cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.}
-proc TCP_AddSocket*(theSet: PSocketSet, sock: PTCPSocket): int
-proc UDP_AddSocket*(theSet: PSocketSet, sock: PUDPSocket): int
-  #* Remove a socket from a set of sockets to be checked for available data *
-proc DelSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
-    cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.}
-proc TCP_DelSocket*(theSet: PSocketSet, sock: PTCPSocket): int
-  # SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-proc UDP_DelSocket*(theSet: PSocketSet, sock: PUDPSocket): int
-  #SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
-  #* This function checks to see if data is available for reading on the
-  #   given set of sockets.  If 'timeout' is 0, it performs a quick poll,
-  #   otherwise the function returns when either data is available for
-  #   reading, or the timeout in milliseconds has elapsed, which ever occurs
-  #   first.  This function returns the number of sockets ready for reading,
-  #   or -1 if there was an error with the select() system call.
-  #*
-proc CheckSockets*(theSet: PSocketSet, timeout: int32): int{.cdecl, 
-    importc: "SDLNet_CheckSockets", dynlib: NetLibName.}
-  #* After calling SDLNet_CheckSockets(), you can use this function on a
-  #   socket that was in the socket set, to find out if data is available
-  #   for reading.
-  #*
-proc SocketReady*(sock: PGenericSocket): bool
-  #* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
-proc FreeSocketSet*(theSet: PSocketSet){.cdecl, 
-    importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.}
-  #***********************************************************************
-  #* Platform-independent data conversion functions                      *
-  #***********************************************************************
-  #* Write a 16/32 bit value to network packet buffer *
-proc Write16*(value: Uint16, area: Pointer){.cdecl, 
-    importc: "SDLNet_Write16", dynlib: NetLibName.}
-proc Write32*(value: Uint32, area: Pointer){.cdecl, 
-    importc: "SDLNet_Write32", dynlib: NetLibName.}
-  #* Read a 16/32 bit value from network packet buffer *
-proc Read16*(area: Pointer): Uint16{.cdecl, importc: "SDLNet_Read16", 
-    dynlib: NetLibName.}
-proc Read32*(area: Pointer): Uint32{.cdecl, importc: "SDLNet_Read32", 
-    dynlib: NetLibName.}
-
-proc VERSION(X: var Tversion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
-
-proc TCP_AddSocket(theSet: PSocketSet, sock: PTCPSocket): int = 
-  result = AddSocket(theSet, cast[PGenericSocket](sock))
-
-proc UDP_AddSocket(theSet: PSocketSet, sock: PUDPSocket): int = 
-  result = AddSocket(theSet, cast[PGenericSocket](sock))
-
-proc TCP_DelSocket(theSet: PSocketSet, sock: PTCPSocket): int = 
-  result = DelSocket(theSet, cast[PGenericSocket](sock))
-
-proc UDP_DelSocket(theSet: PSocketSet, sock: PUDPSocket): int = 
-  result = DelSocket(theSet, cast[PGenericSocket](sock))
-
-proc SocketReady(sock: PGenericSocket): bool = 
-  result = ((sock != nil) and (sock.ready == 1))
-
diff --git a/lib/wrappers/sdl/sdl_ttf.nim b/lib/wrappers/sdl/sdl_ttf.nim
deleted file mode 100755
index ca4b56f5a..000000000
--- a/lib/wrappers/sdl/sdl_ttf.nim
+++ /dev/null
@@ -1,343 +0,0 @@
-#
-#  $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
-#
-#
-#******************************************************************************
-#                                                                              
-#          JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer          
-#       Conversion of the Simple DirectMedia Layer Headers                     
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : SDL_ttf.h                                           
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Dominqiue Louis <Dominique@SavageSoftware.com.au>                            
-#                                                                              
-# Portions created by Dominqiue Louis are                                      
-# Copyright (C) 2000 - 2001 Dominqiue Louis.                                   
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL.so          
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid        
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: sdl_ttf.pas,v $
-#  Revision 1.18  2007/06/01 11:16:33  savage
-#  Added IFDEF UNIX for Workaround.
-#
-#  Revision 1.17  2007/06/01 08:38:21  savage
-#  Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
-#
-#  Revision 1.16  2007/05/29 21:32:14  savage
-#  Changes as suggested by Almindor for 64bit compatibility.
-#
-#  Revision 1.15  2007/05/20 20:32:45  savage
-#  Initial Changes to Handle 64 Bits
-#
-#  Revision 1.14  2006/12/02 00:19:01  savage
-#  Updated to latest version
-#
-#  Revision 1.13  2005/04/10 11:48:33  savage
-#  Changes as suggested by Michalis, thanks.
-#
-#  Revision 1.12  2005/01/05 01:47:14  savage
-#  Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
-#
-#  Revision 1.11  2005/01/04 23:14:57  savage
-#  Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
-#
-#  Revision 1.10  2005/01/02 19:07:32  savage
-#  Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
-#
-#  Revision 1.9  2005/01/01 02:15:20  savage
-#  Updated to v2.0.7
-#
-#  Revision 1.8  2004/10/07 21:02:32  savage
-#  Fix for FPC
-#
-#  Revision 1.7  2004/09/30 22:39:50  savage
-#  Added a true type font class which contains a wrap text function.
-#  Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
-#
-#  Revision 1.6  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.5  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.4  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.3  2004/04/01 20:53:24  savage
-#  Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/16 22:16:40  savage
-#  v1.0 changes
-#
-#  
-#
-#******************************************************************************
-#
-#  Define this to workaround a known bug in some freetype versions.
-#  The error manifests as TTF_RenderGlyph_Solid returning nil (error)
-#  and error message (in SDL_Error) is
-#  "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
-#  See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
-#
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    ttfLibName = "SDL_ttf.dll"
-elif defined(macosx): 
-  const 
-    ttfLibName = "libSDL_ttf-2.0.0.dylib"
-else: 
-  const 
-    ttfLibName = "libSDL_ttf.so"
-const 
-  MAJOR_VERSION* = 2'i8
-  MINOR_VERSION* = 0'i8
-  PATCHLEVEL* = 8'i8      # Backwards compatibility
-
-  STYLE_NORMAL* = 0x00000000
-  STYLE_BOLD* = 0x00000001
-  STYLE_ITALIC* = 0x00000002
-  STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
-  UNICODE_BOM_NATIVE* = 0x0000FEFF
-  UNICODE_BOM_SWAPPED* = 0x0000FFFE
-
-type 
-  PFont* = ptr Tfont
-  TFont{.final.} = object  
-  
-  
-# This macro can be used to fill a version structure with the compile-time
-# version of the SDL_ttf library. 
-
-proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version", 
-                                      dynlib: ttfLibName.}
-  # This function tells the library whether UNICODE text is generally
-  #   byteswapped.  A UNICODE BOM character in a string will override
-  #   this setting for the remainder of that string.
-  #
-proc ByteSwappedUNICODE*(swapped: cint){.cdecl, 
-    importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
-  #returns 0 on succes, -1 if error occurs
-proc Init*(): cint{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
-  #
-  # Open a font file and create a font of the specified point size.
-  # Some .fon fonts will have several sizes embedded in the file, so the
-  # point size becomes the index of choosing which size.  If the value
-  # is too high, the last indexed size will be the default.
-  #
-proc OpenFont*(filename: cstring, ptsize: cint): PFont{.cdecl, 
-    importc: "TTF_OpenFont", dynlib: ttfLibName.}
-proc OpenFontIndex*(filename: cstring, ptsize: cint, index: int32): PFont{.
-    cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
-proc OpenFontRW*(src: PRWops, freesrc: cint, ptsize: cint): PFont{.cdecl, 
-    importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
-proc OpenFontIndexRW*(src: PRWops, freesrc: cint, ptsize: cint, index: int32): PFont{.
-    cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
-proc GetFontStyle*(font: PFont): cint{.cdecl, 
-    importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
-proc SetFontStyle*(font: PFont, style: cint){.cdecl, 
-    importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
-  # Get the total height of the font - usually equal to point size 
-proc FontHeight*(font: PFont): cint{.cdecl, importc: "TTF_FontHeight", 
-    dynlib: ttfLibName.}
-  # Get the offset from the baseline to the top of the font
-  #   This is a positive value, relative to the baseline.
-  #
-proc FontAscent*(font: PFont): cint{.cdecl, importc: "TTF_FontAscent", 
-    dynlib: ttfLibName.}
-  # Get the offset from the baseline to the bottom of the font
-  #   This is a negative value, relative to the baseline.
-  #
-proc FontDescent*(font: PFont): cint{.cdecl, importc: "TTF_FontDescent", 
-    dynlib: ttfLibName.}
-  # Get the recommended spacing between lines of text for this font 
-proc FontLineSkip*(font: PFont): cint{.cdecl, 
-    importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
-  # Get the number of faces of the font 
-proc FontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces", 
-    dynlib: ttfLibName.}
-  # Get the font face attributes, if any 
-proc FontFaceIsFixedWidth*(font: PFont): cint{.cdecl, 
-    importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
-proc FontFaceFamilyName*(font: PFont): cstring{.cdecl, 
-    importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
-proc FontFaceStyleName*(font: PFont): cstring{.cdecl, 
-    importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
-  # Get the metrics (dimensions) of a glyph 
-proc GlyphMetrics*(font: PFont, ch: Uint16, minx: var cint, 
-                       maxx: var cint, miny: var cint, maxy: var cint, 
-                       advance: var cint): cint{.cdecl, 
-    importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
-  # Get the dimensions of a rendered string of text 
-proc SizeText*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
-proc SizeUTF8*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
-proc SizeUNICODE*(font: PFont, text: PUint16, w: var cint, y: var cint): cint{.
-    cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderUTF8_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
-proc RenderUNICODE_Solid*(font: PFont, text: PUint16, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
-  #
-  #Create an 8-bit palettized surface and render the given glyph at
-  #   fast quality with the given font and color.  The 0 pixel is the
-  #   colorkey, giving a transparent background, and the 1 pixel is set
-  #   to the text color.  The glyph is rendered without any padding or
-  #   centering in the X direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderGlyph_Solid*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given text at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderText_Shaded*(font: PFont, text: cstring, fg: TColor, 
-                            bg: TColor): PSurface{.cdecl, 
-    importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
-proc RenderUTF8_Shaded*(font: PFont, text: cstring, fg: TColor, 
-                            bg: TColor): PSurface{.cdecl, 
-    importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
-proc RenderUNICODE_Shaded*(font: PFont, text: PUint16, fg: TColor, 
-                               bg: TColor): PSurface{.cdecl, 
-    importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
-  # Create an 8-bit palettized surface and render the given glyph at
-  #   high quality with the given font and colors.  The 0 pixel is background,
-  #   while other pixels have varying degrees of the foreground color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderGlyph_Shaded*(font: PFont, ch: Uint16, fg: TColor, bg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
-  # Create a 32-bit ARGB surface and render the given text at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderText_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
-proc RenderUTF8_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
-proc RenderUNICODE_Blended*(font: PFont, text: PUint16, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
-  # Create a 32-bit ARGB surface and render the given glyph at high quality,
-  #   using alpha blending to dither the font with the given color.
-  #   The glyph is rendered without any padding or centering in the X
-  #   direction, and aligned normally in the Y direction.
-  #   This function returns the new surface, or NULL if there was an error.
-  #
-proc RenderGlyph_Blended*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
-    cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
-  # For compatibility with previous versions, here are the old functions 
-  ##define TTF_RenderText(font, text, fg, bg)
-  #	TTF_RenderText_Shaded(font, text, fg, bg)
-  ##define TTF_RenderUTF8(font, text, fg, bg)	
-  #	TTF_RenderUTF8_Shaded(font, text, fg, bg)
-  ##define TTF_RenderUNICODE(font, text, fg, bg)	
-  #	TTF_RenderUNICODE_Shaded(font, text, fg, bg)
-  # Close an opened font file 
-proc CloseFont*(font: PFont){.cdecl, importc: "TTF_CloseFont", 
-                                      dynlib: ttfLibName.}
-  #De-initialize TTF engine
-proc Quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
-  # Check if the TTF engine is initialized
-proc WasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
-
-
-proc VERSION*(X: var sdl.Tversion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
-
-
-when not (defined(Workaround_RenderText_Solid)): 
-  proc RenderText_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
-      cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
-else: 
-  proc RenderText_Solid(font: PFont, text: cstring, fg: TColor): PSurface = 
-    var Black: TColor         # initialized to zero
-    result = RenderText_Shaded(font, text, fg, Black)
-
diff --git a/lib/wrappers/sdl/smpeg.nim b/lib/wrappers/sdl/smpeg.nim
deleted file mode 100755
index a836379ac..000000000
--- a/lib/wrappers/sdl/smpeg.nim
+++ /dev/null
@@ -1,335 +0,0 @@
-#******************************************************************************
-#
-#  $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
-#  
-#
-#                                                                              
-#       Borland Delphi SMPEG - SDL MPEG Player Library                         
-#       Conversion of the SMPEG - SDL MPEG Player Library                      
-#                                                                              
-# Portions created by Sam Lantinga <slouken@devolution.com> are                
-# Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga                     
-# 5635-34 Springhouse Dr.                                                      
-# Pleasanton, CA 94588 (USA)                                                   
-#                                                                              
-# All Rights Reserved.                                                         
-#                                                                              
-# The original files are : smpeg.h                                             
-#                                                                              
-# The initial developer of this Pascal code was :                              
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Portions created by Matthias Thoma are                                       
-# Copyright (C) 2000 - 2001 Matthias Thoma.                                    
-#                                                                              
-#                                                                              
-# Contributor(s)                                                               
-# --------------                                                               
-# Tom Jones <tigertomjones@gmx.de>  His Project inspired this conversion       
-# Matthias Thoma <ma.thoma@gmx.de>                                             
-#                                                                              
-# Obtained through:                                                            
-# Joint Endeavour of Delphi Innovators ( Project JEDI )                        
-#                                                                              
-# You may retrieve the latest version of this file at the Project              
-# JEDI home page, located at http://delphi-jedi.org                            
-#                                                                              
-# The contents of this file are used with permission, subject to               
-# the Mozilla Public License Version 1.1 (the "License"); you may              
-# not use this file except in compliance with the License. You may             
-# obtain a copy of the License at                                              
-# http://www.mozilla.org/MPL/MPL-1.1.html                                      
-#                                                                              
-# Software distributed under the License is distributed on an                  
-# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               
-# implied. See the License for the specific language governing                 
-# rights and limitations under the License.                                    
-#                                                                              
-# Description                                                                  
-# -----------                                                                  
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Requires                                                                     
-# --------                                                                     
-#   The SDL Runtime libraris on Win32  : SDL.dll on Linux : libSDL-1.2.so.0    
-#   They are available from...                                                 
-#   http://www.libsdl.org .                                                    
-#                                                                              
-# Programming Notes                                                            
-# -----------------                                                            
-#                                                                              
-#                                                                              
-#                                                                              
-#                                                                              
-# Revision History                                                             
-# ----------------                                                             
-#   May      08 2001 - MT : Initial conversion                                 
-#                                                                              
-#   October  12 2001 - DA : Various changes as suggested by David Acklam       
-#                                                                              
-#   April   03 2003 - DL : Added jedi-sdl.inc include file to support more     
-#                          Pascal compilers. Initial support is now included   
-#                          for GnuPascal, VirtualPascal, TMT and obviously     
-#                          continue support for Delphi Kylix and FreePascal.   
-#                                                                              
-#   April   08 2003 - MK : Aka Mr Kroket - Added Better FPC support            
-#                          Fixed all invalid calls to DLL.                     
-#                          Changed constant names to:                          
-#                          const                                               
-#                          STATUS_SMPEG_ERROR = -1;                            
-#                          STATUS_SMPEG_STOPPED = 0;                           
-#                          STATUS_SMPEG_PLAYING = 1;                           
-#                          because SMPEG_ERROR is a function (_SMPEG_error     
-#                          isn't correct), and cannot be two elements with the 
-#                          same name                                           
-#                                                                              
-#   April   24 2003 - DL : under instruction from Alexey Barkovoy, I have added
-#                          better TMT Pascal support and under instruction     
-#                          from Prof. Abimbola Olowofoyeku (The African Chief),
-#                          I have added better Gnu Pascal support              
-#                                                                              
-#   April   30 2003 - DL : under instruction from David Mears AKA              
-#                          Jason Siletto, I have added FPC Linux support.      
-#                          This was compiled with fpc 1.1, so remember to set  
-#                          include file path. ie. -Fi/usr/share/fpcsrc/rtl/*   
-#                                                                              
-#
-#  $Log: smpeg.pas,v $
-#  Revision 1.7  2004/08/14 22:54:30  savage
-#  Updated so that Library name defines are correctly defined for MacOS X.
-#
-#  Revision 1.6  2004/05/10 14:10:04  savage
-#  Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
-#
-#  Revision 1.5  2004/04/13 09:32:08  savage
-#  Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
-#
-#  Revision 1.4  2004/04/02 10:40:55  savage
-#  Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
-#
-#  Revision 1.3  2004/03/31 22:20:02  savage
-#  Windows unit not used in this file, so it was removed to keep the code tidy.
-#
-#  Revision 1.2  2004/03/30 20:23:28  savage
-#  Tidied up use of UNIX compiler directive.
-#
-#  Revision 1.1  2004/02/14 23:35:42  savage
-#  version 1 of sdl_image, sdl_mixer and smpeg.
-#
-#  
-#
-#******************************************************************************
-
-import 
-  sdl
-
-when defined(windows): 
-  const 
-    SmpegLibName = "smpeg.dll"
-elif defined(macosx): 
-  const 
-    SmpegLibName = "libsmpeg.dylib"
-else: 
-  const 
-    SmpegLibName = "libsmpeg.so"
-const 
-  FILTER_INFO_MB_ERROR* = 1
-  FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG 
-
-type 
-  TFilterInfo*{.final.} = object 
-    yuv_mb_square_error*: PUint16
-    yuv_pixel_square_error*: PUint16
-
-  PFilterInfo* = ptr TFilterInfo # MPEG filter definition 
-  PFilter* = ptr TFilter # Callback functions for the filter 
-  TFilterCallback* = proc (dest, source: POverlay, region: PRect, 
-                                 filter_info: PFilterInfo, data: Pointer): Pointer{.
-      cdecl.}
-  TFilterDestroy* = proc (Filter: PFilter): Pointer{.cdecl.} # The filter definition itself 
-  TFilter*{.final.} = object  # The null filter (default). It simply copies the source rectangle to the video overlay. 
-    flags*: Uint32
-    data*: Pointer
-    callback*: TFilterCallback
-    destroy*: TFilterDestroy
-
-
-proc filter_null*(): PFilter{.cdecl, importc: "SMPEGfilter_null", 
-    dynlib: SmpegLibName.}
-  # The bilinear filter. A basic low-pass filter that will produce a smoother image. 
-proc filter_bilinear*(): PFilter{.cdecl, 
-    importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.}
-  # The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness 
-proc filter_deblocking*(): PFilter{.cdecl, 
-    importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.}
-  #------------------------------------------------------------------------------
-  # SMPEG.h
-  #------------------------------------------------------------------------------
-const 
-  MAJOR_VERSION* = 0'i8
-  MINOR_VERSION* = 4'i8
-  PATCHLEVEL* = 2'i8
-
-type 
-  TVersion*{.final.} = object 
-    major*: byte
-    minor*: byte
-    patch*: byte
-
-  Pversion* = ptr Tversion # This is the actual SMPEG object
-  TSMPEG*{.final.} = object 
-  PSMPEG* = ptr TSMPEG        # Used to get information about the SMPEG object 
-  TInfo*{.final.} = object 
-    has_audio*: int32
-    has_video*: int32
-    width*: int32
-    height*: int32
-    current_frame*: int32
-    current_fps*: float64
-    audio_string*: array[0..79, char]
-    audio_current_frame*: int32
-    current_offset*: UInt32
-    total_size*: UInt32
-    current_time*: float64
-    total_time*: float64
-
-  PInfo* = ptr TInfo # Possible MPEG status codes 
-
-const 
-  STATUS_ERROR* = - 1
-  STATUS_STOPPED* = 0
-  STATUS_PLAYING* = 1
-
-type 
-  Tstatus* = int32
-  Pstatus* = ptr int32     # Matches the declaration of SDL_UpdateRect() 
-  TDisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): Pointer{.
-      cdecl.} # Create a new SMPEG object from an MPEG file.
-              #  On return, if 'info' is not NULL, it will be filled with information
-              #  about the MPEG object.
-              #  This function returns a new SMPEG object.  Use error() to find out
-              #  whether or not there was a problem building the MPEG stream.
-              #  The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
-              #  subsystem. If not, you will have to use the playaudio() function below
-              #  to extract the decoded data. 
-
-proc SMPEG_new*(theFile: cstring, info: PInfo, audio: int): PSMPEG{.cdecl, 
-    importc: "SMPEG_new", dynlib: SmpegLibName.}
-  # The same as above for a file descriptor 
-proc new_descr*(theFile: int, info: PInfo, audio: int): PSMPEG{.
-    cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.}
-  #  The same as above but for a raw chunk of data.  SMPEG makes a copy of the
-  #   data, so the application is free to delete after a successful call to this
-  #   function. 
-proc new_data*(data: Pointer, size: int, info: PInfo, audio: int): PSMPEG{.
-    cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.}
-  # Get current information about an SMPEG object 
-proc getinfo*(mpeg: PSMPEG, info: PInfo){.cdecl, 
-    importc: "SMPEG_getinfo", dynlib: SmpegLibName.}
-  #procedure getinfo(mpeg: PSMPEG; info: Pointer);
-  #cdecl; external  SmpegLibName;
-  # Enable or disable audio playback in MPEG stream 
-proc enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, 
-    importc: "SMPEG_enableaudio", dynlib: SmpegLibName.}
-  # Enable or disable video playback in MPEG stream 
-proc enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, 
-    importc: "SMPEG_enablevideo", dynlib: SmpegLibName.}
-  # Delete an SMPEG object 
-proc delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete", 
-                                  dynlib: SmpegLibName.}
-  # Get the current status of an SMPEG object 
-proc status*(mpeg: PSMPEG): Tstatus{.cdecl, importc: "SMPEG_status", 
-    dynlib: SmpegLibName.}
-  # status
-  # Set the audio volume of an MPEG stream, in the range 0-100 
-proc setvolume*(mpeg: PSMPEG, volume: int){.cdecl, 
-    importc: "SMPEG_setvolume", dynlib: SmpegLibName.}
-  # Set the destination surface for MPEG video playback
-  #  'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
-  #  'callback' is a function called when an area of 'dst' needs to be updated.
-  #  If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. 
-proc setdisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: Pmutex, 
-                       callback: TDisplayCallback){.cdecl, 
-    importc: "SMPEG_setdisplay", dynlib: SmpegLibName.}
-  # Set or clear looping play on an SMPEG object 
-proc loop*(mpeg: PSMPEG, repeat: int){.cdecl, importc: "SMPEG_loop", 
-    dynlib: SmpegLibName.}
-  # Scale pixel display on an SMPEG object 
-proc scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl, 
-    importc: "SMPEG_scaleXY", dynlib: SmpegLibName.}
-proc scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale", 
-    dynlib: SmpegLibName.}
-proc Double*(mpeg: PSMPEG, doubleit: bool)
-  # Move the video display area within the destination surface 
-proc move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move", 
-    dynlib: SmpegLibName.}
-  # Set the region of the video to be shown 
-proc setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl, 
-    importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.}
-  # Play an SMPEG object 
-proc play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play", 
-                                dynlib: SmpegLibName.}
-  # Pause/Resume playback of an SMPEG object
-proc pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause", 
-                                 dynlib: SmpegLibName.}
-  # Stop playback of an SMPEG object 
-proc stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop", 
-                                dynlib: SmpegLibName.}
-  # Rewind the play position of an SMPEG object to the beginning of the MPEG 
-proc rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind", 
-                                  dynlib: SmpegLibName.}
-  # Seek 'bytes' bytes in the MPEG stream 
-proc seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek", 
-    dynlib: SmpegLibName.}
-  # Skip 'seconds' seconds in the MPEG stream 
-proc skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip", 
-    dynlib: SmpegLibName.}
-  # Render a particular frame in the MPEG video
-  #   API CHANGE: This function no longer takes a target surface and position.
-  #               Use setdisplay() and move() to set this information. 
-proc renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl, 
-    importc: "SMPEG_renderFrame", dynlib: SmpegLibName.}
-  # Render the last frame of an MPEG video 
-proc renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl, 
-    importc: "SMPEG_renderFinal", dynlib: SmpegLibName.}
-  # Set video filter 
-proc filter*(mpeg: PSMPEG, filter: PFilter): PFilter{.cdecl, 
-    importc: "SMPEG_filter", dynlib: SmpegLibName.}
-  # Return NULL if there is no error in the MPEG stream, or an error message
-  #   if there was a fatal error in the MPEG stream for the SMPEG object. 
-proc error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error", 
-    dynlib: SmpegLibName.}
-  # Exported callback function for audio playback.
-  #   The function takes a buffer and the amount of data to fill, and returns
-  #   the amount of data in bytes that was actually written.  This will be the
-  #   amount requested unless the MPEG audio has finished.
-  #
-proc playAudio*(mpeg: PSMPEG, stream: pointer, length: int): int{.cdecl, 
-    importc: "SMPEG_playAudio", dynlib: SmpegLibName.}
-  # Wrapper for playAudio() that can be passed to SDL and SDL_mixer 
-proc playAudioSDL*(mpeg: Pointer, stream: pointer, length: int){.cdecl, 
-    importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.}
-  # Get the best SDL audio spec for the audio stream 
-proc wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl, 
-    importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.}
-  # Inform SMPEG of the actual SDL audio spec used for sound playback 
-proc actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl, 
-    importc: "SMPEG_actualSpec", dynlib: SmpegLibName.}
-  # This macro can be used to fill a version structure with the compile-time
-  #  version of the SDL library. 
-proc GETVERSION*(X: var Tversion)
-# implementation
-
-proc double(mpeg: PSMPEG, doubleit: bool) = 
-  if doubleit: scale(mpeg, 2)
-  else: scale(mpeg, 1)
-  
-proc GETVERSION(X: var Tversion) = 
-  X.major = MAJOR_VERSION
-  X.minor = MINOR_VERSION
-  X.patch = PATCHLEVEL
diff --git a/lib/wrappers/tinyc.nim b/lib/wrappers/tinyc.nim
index f685c714d..8d2ba3802 100755..100644
--- a/lib/wrappers/tinyc.nim
+++ b/lib/wrappers/tinyc.nim
@@ -1,6 +1,6 @@
 #
 #
-#            Nimrod's Runtime Library
+#            Nim's Runtime Library
 #        (c) Copyright 2010 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
@@ -8,10 +8,10 @@
 #
 
 type
-  TccState {.pure, final.} = object
-  PccState* = ptr TccState
-  
-  TErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.}
+  CcState {.pure, final.} = object
+  PccState* = ptr CcState
+
+  ErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.}
 
 proc openCCState*(): PccState {.importc: "tcc_new", cdecl.}
   ## create a new TCC compilation context
@@ -19,44 +19,39 @@ proc openCCState*(): PccState {.importc: "tcc_new", cdecl.}
 proc closeCCState*(s: PccState) {.importc: "tcc_delete", cdecl.}
   ## free a TCC compilation context
 
-proc enableDebug*(s: PccState) {.importc: "tcc_enable_debug", cdecl.}
-  ## add debug information in the generated code
-
-proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: TErrorFunc) {.
+proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: ErrorFunc) {.
   cdecl, importc: "tcc_set_error_func".}
   ## set error/warning display callback
 
-proc setWarning*(s: PccState, warningName: cstring, value: int) {.cdecl,
-  importc: "tcc_set_warning".}
-  ## set/reset a warning
+proc setOptions*(s: PccState, options: cstring) {.cdecl, importc: "tcc_set_options".}
+  ## set a options
 
-# preprocessor 
+# preprocessor
 
-proc addIncludePath*(s: PccState, pathname: cstring) {.cdecl, 
+proc addIncludePath*(s: PccState, pathname: cstring) {.cdecl,
   importc: "tcc_add_include_path".}
   ## add include path
 
-proc addSysincludePath*(s: PccState, pathname: cstring) {.cdecl, 
+proc addSysincludePath*(s: PccState, pathname: cstring) {.cdecl,
   importc: "tcc_add_sysinclude_path".}
   ## add in system include path
 
-
-proc defineSymbol*(s: PccState, sym, value: cstring) {.cdecl, 
+proc defineSymbol*(s: PccState, sym, value: cstring) {.cdecl,
   importc: "tcc_define_symbol".}
   ## define preprocessor symbol 'sym'. Can put optional value
 
-proc undefineSymbol*(s: PccState, sym: cstring) {.cdecl, 
+proc undefineSymbol*(s: PccState, sym: cstring) {.cdecl,
   importc: "tcc_undefine_symbol".}
   ## undefine preprocess symbol 'sym'
 
-# compiling 
+# compiling
 
-proc addFile*(s: PccState, filename: cstring): cint {.cdecl, 
+proc addFile*(s: PccState, filename: cstring): cint {.cdecl,
   importc: "tcc_add_file".}
   ## add a file (either a C file, dll, an object, a library or an ld
   ## script). Return -1 if error.
 
-proc compileString*(s: PccState, buf: cstring): cint {.cdecl, 
+proc compileString*(s: PccState, buf: cstring): cint {.cdecl,
   importc: "tcc_compile_string".}
   ## compile a string containing a C source. Return non zero if error.
 
@@ -64,18 +59,14 @@ proc compileString*(s: PccState, buf: cstring): cint {.cdecl,
 
 
 const
-  OutputMemory*: cint = 0 ## output will be ran in memory (no
+  OutputMemory*: cint = 1 ## output will be ran in memory (no
                           ## output file) (default)
-  OutputExe*: cint = 1 ## executable file
-  OutputDll*: cint = 2 ## dynamic library
-  OutputObj*: cint = 3 ## object file
-  OutputPreprocess*: cint = 4 ## preprocessed file (used internally)
-  
-  OutputFormatElf*: cint = 0 ## default output format: ELF
-  OutputFormatBinary*: cint = 1 ## binary image output
-  OutputFormatCoff*: cint = 2 ## COFF
-
-proc setOutputType*(s: PCCState, outputType: cint): cint {.cdecl, 
+  OutputExe*: cint = 2 ## executable file
+  OutputDll*: cint = 3 ## dynamic library
+  OutputObj*: cint = 4 ## object file
+  OutputPreprocess*: cint = 5 ## preprocessed file (used internally)
+
+proc setOutputType*(s: PccState, outputType: cint): cint {.cdecl,
   importc: "tcc_set_output_type".}
   ## set output type. MUST BE CALLED before any compilation
 
@@ -83,7 +74,7 @@ proc addLibraryPath*(s: PccState, pathname: cstring): cint {.cdecl,
   importc: "tcc_add_library_path".}
   ## equivalent to -Lpath option
 
-proc addLibrary*(s: PCCState, libraryname: cstring): cint {.cdecl,
+proc addLibrary*(s: PccState, libraryname: cstring): cint {.cdecl,
   importc: "tcc_add_library".}
   ## the library name is the same as the argument of the '-l' option
 
@@ -114,5 +105,3 @@ proc getSymbol*(s: PccState, name: cstring): pointer {.cdecl,
 proc setLibPath*(s: PccState, path: cstring) {.cdecl,
   importc: "tcc_set_lib_path".}
   ## set CONFIG_TCCDIR at runtime
-  
-
diff --git a/lib/wrappers/x11/cursorfont.nim b/lib/wrappers/x11/cursorfont.nim
deleted file mode 100755
index b262ad7c1..000000000
--- a/lib/wrappers/x11/cursorfont.nim
+++ /dev/null
@@ -1,110 +0,0 @@
-# $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ 
-#
-#
-#Copyright 1987, 1998  The Open Group
-#
-#Permission to use, copy, modify, distribute, and sell this software and its
-#documentation for any purpose is hereby granted without fee, provided that
-#the above copyright notice appear in all copies and that both that
-#copyright notice and this permission notice appear in supporting
-#documentation.
-#
-#The above copyright notice and this permission notice shall be included
-#in all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-#OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of The Open Group shall
-#not be used in advertising or otherwise to promote the sale, use or
-#other dealings in this Software without prior written authorization
-#from The Open Group.
-#
-#
-
-const 
-  XC_num_glyphs* = 154
-  XC_X_cursor* = 0
-  XC_arrow* = 2
-  XC_based_arrow_down* = 4
-  XC_based_arrow_up* = 6
-  XC_boat* = 8
-  XC_bogosity* = 10
-  XC_bottom_left_corner* = 12
-  XC_bottom_right_corner* = 14
-  XC_bottom_side* = 16
-  XC_bottom_tee* = 18
-  XC_box_spiral* = 20
-  XC_center_ptr* = 22
-  XC_circle* = 24
-  XC_clock* = 26
-  XC_coffee_mug* = 28
-  XC_cross* = 30
-  XC_cross_reverse* = 32
-  XC_crosshair* = 34
-  XC_diamond_cross* = 36
-  XC_dot* = 38
-  XC_dotbox* = 40
-  XC_double_arrow* = 42
-  XC_draft_large* = 44
-  XC_draft_small* = 46
-  XC_draped_box* = 48
-  XC_exchange* = 50
-  XC_fleur* = 52
-  XC_gobbler* = 54
-  XC_gumby* = 56
-  XC_hand1* = 58
-  XC_hand2* = 60
-  XC_heart* = 62
-  XC_icon* = 64
-  XC_iron_cross* = 66
-  XC_left_ptr* = 68
-  XC_left_side* = 70
-  XC_left_tee* = 72
-  XC_leftbutton* = 74
-  XC_ll_angle* = 76
-  XC_lr_angle* = 78
-  XC_man* = 80
-  XC_middlebutton* = 82
-  XC_mouse* = 84
-  XC_pencil* = 86
-  XC_pirate* = 88
-  XC_plus* = 90
-  XC_question_arrow* = 92
-  XC_right_ptr* = 94
-  XC_right_side* = 96
-  XC_right_tee* = 98
-  XC_rightbutton* = 100
-  XC_rtl_logo* = 102
-  XC_sailboat* = 104
-  XC_sb_down_arrow* = 106
-  XC_sb_h_double_arrow* = 108
-  XC_sb_left_arrow* = 110
-  XC_sb_right_arrow* = 112
-  XC_sb_up_arrow* = 114
-  XC_sb_v_double_arrow* = 116
-  XC_shuttle* = 118
-  XC_sizing* = 120
-  XC_spider* = 122
-  XC_spraycan* = 124
-  XC_star* = 126
-  XC_target* = 128
-  XC_tcross* = 130
-  XC_top_left_arrow* = 132
-  XC_top_left_corner* = 134
-  XC_top_right_corner* = 136
-  XC_top_side* = 138
-  XC_top_tee* = 140
-  XC_trek* = 142
-  XC_ul_angle* = 144
-  XC_umbrella* = 146
-  XC_ur_angle* = 148
-  XC_watch* = 150
-  XC_xterm* = 152
-
-# implementation
diff --git a/lib/wrappers/x11/keysym.nim b/lib/wrappers/x11/keysym.nim
deleted file mode 100755
index b1fe13b80..000000000
--- a/lib/wrappers/x11/keysym.nim
+++ /dev/null
@@ -1,1925 +0,0 @@
-#
-#Converted from X11/keysym.h and X11/keysymdef.h
-#
-#Capital letter consts renamed from XK_... to XKc_...
-# (since Pascal isn't case-sensitive)
-#
-#i.e.
-#C      Pascal
-#XK_a   XK_a
-#XK_A   XKc_A
-#
-
-#* default keysyms *
-
-const 
-  XK_VoidSymbol* = 0x00FFFFFF # void symbol 
-
-when defined(XK_MISCELLANY) or true: 
-  const
-    #*
-    # * TTY Functions, cleverly chosen to map to ascii, for convenience of
-    # * programming, but could have been arbitrary (at the cost of lookup
-    # * tables in client code.
-    # *
-    XK_BackSpace* = 0x0000FF08  # back space, back char 
-    XK_Tab* = 0x0000FF09
-    XK_Linefeed* = 0x0000FF0A   # Linefeed, LF 
-    XK_Clear* = 0x0000FF0B
-    XK_Return* = 0x0000FF0D     # Return, enter 
-    XK_Pause* = 0x0000FF13      # Pause, hold 
-    XK_Scroll_Lock* = 0x0000FF14
-    XK_Sys_Req* = 0x0000FF15
-    XK_Escape* = 0x0000FF1B
-    XK_Delete* = 0x0000FFFF     # Delete, rubout 
-                                # International & multi-key character composition 
-    XK_Multi_key* = 0x0000FF20  # Multi-key character compose 
-    XK_Codeinput* = 0x0000FF37
-    XK_SingleCandidate* = 0x0000FF3C
-    XK_MultipleCandidate* = 0x0000FF3D
-    XK_PreviousCandidate* = 0x0000FF3E # Japanese keyboard support 
-    XK_Kanji* = 0x0000FF21      # Kanji, Kanji convert 
-    XK_Muhenkan* = 0x0000FF22   # Cancel Conversion 
-    XK_Henkan_Mode* = 0x0000FF23 # Start/Stop Conversion 
-    XK_Henkan* = 0x0000FF23     # Alias for Henkan_Mode 
-    XK_Romaji* = 0x0000FF24     # to Romaji 
-    XK_Hiragana* = 0x0000FF25   # to Hiragana 
-    XK_Katakana* = 0x0000FF26   # to Katakana 
-    XK_Hiragana_Katakana* = 0x0000FF27 # Hiragana/Katakana toggle 
-    XK_Zenkaku* = 0x0000FF28    # to Zenkaku 
-    XK_Hankaku* = 0x0000FF29    # to Hankaku 
-    XK_Zenkaku_Hankaku* = 0x0000FF2A # Zenkaku/Hankaku toggle 
-    XK_Touroku* = 0x0000FF2B    # Add to Dictionary 
-    XK_Massyo* = 0x0000FF2C     # Delete from Dictionary 
-    XK_Kana_Lock* = 0x0000FF2D  # Kana Lock 
-    XK_Kana_Shift* = 0x0000FF2E # Kana Shift 
-    XK_Eisu_Shift* = 0x0000FF2F # Alphanumeric Shift 
-    XK_Eisu_toggle* = 0x0000FF30 # Alphanumeric toggle 
-    XK_Kanji_Bangou* = 0x0000FF37 # Codeinput 
-    XK_Zen_Koho* = 0x0000FF3D   # Multiple/All Candidate(s) 
-    XK_Mae_Koho* = 0x0000FF3E   # Previous Candidate 
-                                # = $FF31 thru = $FF3F are under XK_KOREAN 
-                                # Cursor control & motion 
-    XK_Home* = 0x0000FF50
-    XK_Left* = 0x0000FF51       # Move left, left arrow 
-    XK_Up* = 0x0000FF52         # Move up, up arrow 
-    XK_Right* = 0x0000FF53      # Move right, right arrow 
-    XK_Down* = 0x0000FF54       # Move down, down arrow 
-    XK_Prior* = 0x0000FF55      # Prior, previous 
-    XK_Page_Up* = 0x0000FF55
-    XK_Next* = 0x0000FF56       # Next 
-    XK_Page_Down* = 0x0000FF56
-    XK_End* = 0x0000FF57        # EOL 
-    XK_Begin* = 0x0000FF58      # BOL 
-                                # Misc Functions 
-    XK_Select* = 0x0000FF60     # Select, mark 
-    XK_Print* = 0x0000FF61
-    XK_Execute* = 0x0000FF62    # Execute, run, do 
-    XK_Insert* = 0x0000FF63     # Insert, insert here 
-    XK_Undo* = 0x0000FF65       # Undo, oops 
-    XK_Redo* = 0x0000FF66       # redo, again 
-    XK_Menu* = 0x0000FF67
-    XK_Find* = 0x0000FF68       # Find, search 
-    XK_Cancel* = 0x0000FF69     # Cancel, stop, abort, exit 
-    XK_Help* = 0x0000FF6A       # Help 
-    XK_Break* = 0x0000FF6B
-    XK_Mode_switch* = 0x0000FF7E # Character set switch 
-    XK_script_switch* = 0x0000FF7E # Alias for mode_switch 
-    XK_Num_Lock* = 0x0000FF7F   # Keypad Functions, keypad numbers cleverly chosen to map to ascii 
-    XK_KP_Space* = 0x0000FF80   # space 
-    XK_KP_Tab* = 0x0000FF89
-    XK_KP_Enter* = 0x0000FF8D   # enter 
-    XK_KP_F1* = 0x0000FF91      # PF1, KP_A, ... 
-    XK_KP_F2* = 0x0000FF92
-    XK_KP_F3* = 0x0000FF93
-    XK_KP_F4* = 0x0000FF94
-    XK_KP_Home* = 0x0000FF95
-    XK_KP_Left* = 0x0000FF96
-    XK_KP_Up* = 0x0000FF97
-    XK_KP_Right* = 0x0000FF98
-    XK_KP_Down* = 0x0000FF99
-    XK_KP_Prior* = 0x0000FF9A
-    XK_KP_Page_Up* = 0x0000FF9A
-    XK_KP_Next* = 0x0000FF9B
-    XK_KP_Page_Down* = 0x0000FF9B
-    XK_KP_End* = 0x0000FF9C
-    XK_KP_Begin* = 0x0000FF9D
-    XK_KP_Insert* = 0x0000FF9E
-    XK_KP_Delete* = 0x0000FF9F
-    XK_KP_Equal* = 0x0000FFBD   # equals 
-    XK_KP_Multiply* = 0x0000FFAA
-    XK_KP_Add* = 0x0000FFAB
-    XK_KP_Separator* = 0x0000FFAC # separator, often comma 
-    XK_KP_Subtract* = 0x0000FFAD
-    XK_KP_Decimal* = 0x0000FFAE
-    XK_KP_Divide* = 0x0000FFAF
-    XK_KP_0* = 0x0000FFB0
-    XK_KP_1* = 0x0000FFB1
-    XK_KP_2* = 0x0000FFB2
-    XK_KP_3* = 0x0000FFB3
-    XK_KP_4* = 0x0000FFB4
-    XK_KP_5* = 0x0000FFB5
-    XK_KP_6* = 0x0000FFB6
-    XK_KP_7* = 0x0000FFB7
-    XK_KP_8* = 0x0000FFB8
-    XK_KP_9* = 0x0000FFB9 #*
-                          # * Auxilliary Functions; note the duplicate definitions for left and right
-                          # * function keys;  Sun keyboards and a few other manufactures have such
-                          # * function key groups on the left and/or right sides of the keyboard.
-                          # * We've not found a keyboard with more than 35 function keys total.
-                          # *
-    XK_F1* = 0x0000FFBE
-    XK_F2* = 0x0000FFBF
-    XK_F3* = 0x0000FFC0
-    XK_F4* = 0x0000FFC1
-    XK_F5* = 0x0000FFC2
-    XK_F6* = 0x0000FFC3
-    XK_F7* = 0x0000FFC4
-    XK_F8* = 0x0000FFC5
-    XK_F9* = 0x0000FFC6
-    XK_F10* = 0x0000FFC7
-    XK_F11* = 0x0000FFC8
-    XK_L1* = 0x0000FFC8
-    XK_F12* = 0x0000FFC9
-    XK_L2* = 0x0000FFC9
-    XK_F13* = 0x0000FFCA
-    XK_L3* = 0x0000FFCA
-    XK_F14* = 0x0000FFCB
-    XK_L4* = 0x0000FFCB
-    XK_F15* = 0x0000FFCC
-    XK_L5* = 0x0000FFCC
-    XK_F16* = 0x0000FFCD
-    XK_L6* = 0x0000FFCD
-    XK_F17* = 0x0000FFCE
-    XK_L7* = 0x0000FFCE
-    XK_F18* = 0x0000FFCF
-    XK_L8* = 0x0000FFCF
-    XK_F19* = 0x0000FFD0
-    XK_L9* = 0x0000FFD0
-    XK_F20* = 0x0000FFD1
-    XK_L10* = 0x0000FFD1
-    XK_F21* = 0x0000FFD2
-    XK_R1* = 0x0000FFD2
-    XK_F22* = 0x0000FFD3
-    XK_R2* = 0x0000FFD3
-    XK_F23* = 0x0000FFD4
-    XK_R3* = 0x0000FFD4
-    XK_F24* = 0x0000FFD5
-    XK_R4* = 0x0000FFD5
-    XK_F25* = 0x0000FFD6
-    XK_R5* = 0x0000FFD6
-    XK_F26* = 0x0000FFD7
-    XK_R6* = 0x0000FFD7
-    XK_F27* = 0x0000FFD8
-    XK_R7* = 0x0000FFD8
-    XK_F28* = 0x0000FFD9
-    XK_R8* = 0x0000FFD9
-    XK_F29* = 0x0000FFDA
-    XK_R9* = 0x0000FFDA
-    XK_F30* = 0x0000FFDB
-    XK_R10* = 0x0000FFDB
-    XK_F31* = 0x0000FFDC
-    XK_R11* = 0x0000FFDC
-    XK_F32* = 0x0000FFDD
-    XK_R12* = 0x0000FFDD
-    XK_F33* = 0x0000FFDE
-    XK_R13* = 0x0000FFDE
-    XK_F34* = 0x0000FFDF
-    XK_R14* = 0x0000FFDF
-    XK_F35* = 0x0000FFE0
-    XK_R15* = 0x0000FFE0        # Modifiers 
-    XK_Shift_L* = 0x0000FFE1    # Left shift 
-    XK_Shift_R* = 0x0000FFE2    # Right shift 
-    XK_Control_L* = 0x0000FFE3  # Left control 
-    XK_Control_R* = 0x0000FFE4  # Right control 
-    XK_Caps_Lock* = 0x0000FFE5  # Caps lock 
-    XK_Shift_Lock* = 0x0000FFE6 # Shift lock 
-    XK_Meta_L* = 0x0000FFE7     # Left meta 
-    XK_Meta_R* = 0x0000FFE8     # Right meta 
-    XK_Alt_L* = 0x0000FFE9      # Left alt 
-    XK_Alt_R* = 0x0000FFEA      # Right alt 
-    XK_Super_L* = 0x0000FFEB    # Left super 
-    XK_Super_R* = 0x0000FFEC    # Right super 
-    XK_Hyper_L* = 0x0000FFED    # Left hyper 
-    XK_Hyper_R* = 0x0000FFEE    # Right hyper 
-# XK_MISCELLANY 
-#*
-# * ISO 9995 Function and Modifier Keys
-# * Byte 3 = = $FE
-# *
-
-when defined(XK_XKB_KEYS) or true: 
-  const
-    XK_ISO_Lock* = 0x0000FE01
-    XK_ISO_Level2_Latch* = 0x0000FE02
-    XK_ISO_Level3_Shift* = 0x0000FE03
-    XK_ISO_Level3_Latch* = 0x0000FE04
-    XK_ISO_Level3_Lock* = 0x0000FE05
-    XK_ISO_Group_Shift* = 0x0000FF7E # Alias for mode_switch 
-    XK_ISO_Group_Latch* = 0x0000FE06
-    XK_ISO_Group_Lock* = 0x0000FE07
-    XK_ISO_Next_Group* = 0x0000FE08
-    XK_ISO_Next_Group_Lock* = 0x0000FE09
-    XK_ISO_Prev_Group* = 0x0000FE0A
-    XK_ISO_Prev_Group_Lock* = 0x0000FE0B
-    XK_ISO_First_Group* = 0x0000FE0C
-    XK_ISO_First_Group_Lock* = 0x0000FE0D
-    XK_ISO_Last_Group* = 0x0000FE0E
-    XK_ISO_Last_Group_Lock* = 0x0000FE0F
-    XK_ISO_Left_Tab* = 0x0000FE20
-    XK_ISO_Move_Line_Up* = 0x0000FE21
-    XK_ISO_Move_Line_Down* = 0x0000FE22
-    XK_ISO_Partial_Line_Up* = 0x0000FE23
-    XK_ISO_Partial_Line_Down* = 0x0000FE24
-    XK_ISO_Partial_Space_Left* = 0x0000FE25
-    XK_ISO_Partial_Space_Right* = 0x0000FE26
-    XK_ISO_Set_Margin_Left* = 0x0000FE27
-    XK_ISO_Set_Margin_Right* = 0x0000FE28
-    XK_ISO_Release_Margin_Left* = 0x0000FE29
-    XK_ISO_Release_Margin_Right* = 0x0000FE2A
-    XK_ISO_Release_Both_Margins* = 0x0000FE2B
-    XK_ISO_Fast_Cursor_Left* = 0x0000FE2C
-    XK_ISO_Fast_Cursor_Right* = 0x0000FE2D
-    XK_ISO_Fast_Cursor_Up* = 0x0000FE2E
-    XK_ISO_Fast_Cursor_Down* = 0x0000FE2F
-    XK_ISO_Continuous_Underline* = 0x0000FE30
-    XK_ISO_Discontinuous_Underline* = 0x0000FE31
-    XK_ISO_Emphasize* = 0x0000FE32
-    XK_ISO_Center_Object* = 0x0000FE33
-    XK_ISO_Enter* = 0x0000FE34
-    XK_dead_grave* = 0x0000FE50
-    XK_dead_acute* = 0x0000FE51
-    XK_dead_circumflex* = 0x0000FE52
-    XK_dead_tilde* = 0x0000FE53
-    XK_dead_macron* = 0x0000FE54
-    XK_dead_breve* = 0x0000FE55
-    XK_dead_abovedot* = 0x0000FE56
-    XK_dead_diaeresis* = 0x0000FE57
-    XK_dead_abovering* = 0x0000FE58
-    XK_dead_doubleacute* = 0x0000FE59
-    XK_dead_caron* = 0x0000FE5A
-    XK_dead_cedilla* = 0x0000FE5B
-    XK_dead_ogonek* = 0x0000FE5C
-    XK_dead_iota* = 0x0000FE5D
-    XK_dead_voiced_sound* = 0x0000FE5E
-    XK_dead_semivoiced_sound* = 0x0000FE5F
-    XK_dead_belowdot* = 0x0000FE60
-    XK_dead_hook* = 0x0000FE61
-    XK_dead_horn* = 0x0000FE62
-    XK_First_Virtual_Screen* = 0x0000FED0
-    XK_Prev_Virtual_Screen* = 0x0000FED1
-    XK_Next_Virtual_Screen* = 0x0000FED2
-    XK_Last_Virtual_Screen* = 0x0000FED4
-    XK_Terminate_Server* = 0x0000FED5
-    XK_AccessX_Enable* = 0x0000FE70
-    XK_AccessX_Feedback_Enable* = 0x0000FE71
-    XK_RepeatKeys_Enable* = 0x0000FE72
-    XK_SlowKeys_Enable* = 0x0000FE73
-    XK_BounceKeys_Enable* = 0x0000FE74
-    XK_StickyKeys_Enable* = 0x0000FE75
-    XK_MouseKeys_Enable* = 0x0000FE76
-    XK_MouseKeys_Accel_Enable* = 0x0000FE77
-    XK_Overlay1_Enable* = 0x0000FE78
-    XK_Overlay2_Enable* = 0x0000FE79
-    XK_AudibleBell_Enable* = 0x0000FE7A
-    XK_Pointer_Left* = 0x0000FEE0
-    XK_Pointer_Right* = 0x0000FEE1
-    XK_Pointer_Up* = 0x0000FEE2
-    XK_Pointer_Down* = 0x0000FEE3
-    XK_Pointer_UpLeft* = 0x0000FEE4
-    XK_Pointer_UpRight* = 0x0000FEE5
-    XK_Pointer_DownLeft* = 0x0000FEE6
-    XK_Pointer_DownRight* = 0x0000FEE7
-    XK_Pointer_Button_Dflt* = 0x0000FEE8
-    XK_Pointer_Button1* = 0x0000FEE9
-    XK_Pointer_Button2* = 0x0000FEEA
-    XK_Pointer_Button3* = 0x0000FEEB
-    XK_Pointer_Button4* = 0x0000FEEC
-    XK_Pointer_Button5* = 0x0000FEED
-    XK_Pointer_DblClick_Dflt* = 0x0000FEEE
-    XK_Pointer_DblClick1* = 0x0000FEEF
-    XK_Pointer_DblClick2* = 0x0000FEF0
-    XK_Pointer_DblClick3* = 0x0000FEF1
-    XK_Pointer_DblClick4* = 0x0000FEF2
-    XK_Pointer_DblClick5* = 0x0000FEF3
-    XK_Pointer_Drag_Dflt* = 0x0000FEF4
-    XK_Pointer_Drag1* = 0x0000FEF5
-    XK_Pointer_Drag2* = 0x0000FEF6
-    XK_Pointer_Drag3* = 0x0000FEF7
-    XK_Pointer_Drag4* = 0x0000FEF8
-    XK_Pointer_Drag5* = 0x0000FEFD
-    XK_Pointer_EnableKeys* = 0x0000FEF9
-    XK_Pointer_Accelerate* = 0x0000FEFA
-    XK_Pointer_DfltBtnNext* = 0x0000FEFB
-    XK_Pointer_DfltBtnPrev* = 0x0000FEFC
-  #*
-  # * 3270 Terminal Keys
-  # * Byte 3 = = $FD
-  # *
-
-when defined(XK_3270) or true: 
-  const
-    XK_3270_Duplicate* = 0x0000FD01
-    XK_3270_FieldMark* = 0x0000FD02
-    XK_3270_Right2* = 0x0000FD03
-    XK_3270_Left2* = 0x0000FD04
-    XK_3270_BackTab* = 0x0000FD05
-    XK_3270_EraseEOF* = 0x0000FD06
-    XK_3270_EraseInput* = 0x0000FD07
-    XK_3270_Reset* = 0x0000FD08
-    XK_3270_Quit* = 0x0000FD09
-    XK_3270_PA1* = 0x0000FD0A
-    XK_3270_PA2* = 0x0000FD0B
-    XK_3270_PA3* = 0x0000FD0C
-    XK_3270_Test* = 0x0000FD0D
-    XK_3270_Attn* = 0x0000FD0E
-    XK_3270_CursorBlink* = 0x0000FD0F
-    XK_3270_AltCursor* = 0x0000FD10
-    XK_3270_KeyClick* = 0x0000FD11
-    XK_3270_Jump* = 0x0000FD12
-    XK_3270_Ident* = 0x0000FD13
-    XK_3270_Rule* = 0x0000FD14
-    XK_3270_Copy* = 0x0000FD15
-    XK_3270_Play* = 0x0000FD16
-    XK_3270_Setup* = 0x0000FD17
-    XK_3270_Record* = 0x0000FD18
-    XK_3270_ChangeScreen* = 0x0000FD19
-    XK_3270_DeleteWord* = 0x0000FD1A
-    XK_3270_ExSelect* = 0x0000FD1B
-    XK_3270_CursorSelect* = 0x0000FD1C
-    XK_3270_PrintScreen* = 0x0000FD1D
-    XK_3270_Enter* = 0x0000FD1E
-#*
-# *  Latin 1
-# *  Byte 3 = 0
-# *
-
-when defined(XK_LATIN1) or true: 
-  const
-    XK_space* = 0x00000020
-    XK_exclam* = 0x00000021
-    XK_quotedbl* = 0x00000022
-    XK_numbersign* = 0x00000023
-    XK_dollar* = 0x00000024
-    XK_percent* = 0x00000025
-    XK_ampersand* = 0x00000026
-    XK_apostrophe* = 0x00000027
-    XK_quoteright* = 0x00000027 # deprecated 
-    XK_parenleft* = 0x00000028
-    XK_parenright* = 0x00000029
-    XK_asterisk* = 0x0000002A
-    XK_plus* = 0x0000002B
-    XK_comma* = 0x0000002C
-    XK_minus* = 0x0000002D
-    XK_period* = 0x0000002E
-    XK_slash* = 0x0000002F
-    XK_0* = 0x00000030
-    XK_1* = 0x00000031
-    XK_2* = 0x00000032
-    XK_3* = 0x00000033
-    XK_4* = 0x00000034
-    XK_5* = 0x00000035
-    XK_6* = 0x00000036
-    XK_7* = 0x00000037
-    XK_8* = 0x00000038
-    XK_9* = 0x00000039
-    XK_colon* = 0x0000003A
-    XK_semicolon* = 0x0000003B
-    XK_less* = 0x0000003C
-    XK_equal* = 0x0000003D
-    XK_greater* = 0x0000003E
-    XK_question* = 0x0000003F
-    XK_at* = 0x00000040
-    XKc_A* = 0x00000041
-    XKc_B* = 0x00000042
-    XKc_C* = 0x00000043
-    XKc_D* = 0x00000044
-    XKc_E* = 0x00000045
-    XKc_F* = 0x00000046
-    XKc_G* = 0x00000047
-    XKc_H* = 0x00000048
-    XKc_I* = 0x00000049
-    XKc_J* = 0x0000004A
-    XKc_K* = 0x0000004B
-    XKc_L* = 0x0000004C
-    XKc_M* = 0x0000004D
-    XKc_N* = 0x0000004E
-    XKc_O* = 0x0000004F
-    XKc_P* = 0x00000050
-    XKc_Q* = 0x00000051
-    XKc_R* = 0x00000052
-    XKc_S* = 0x00000053
-    XKc_T* = 0x00000054
-    XKc_U* = 0x00000055
-    XKc_V* = 0x00000056
-    XKc_W* = 0x00000057
-    XKc_X* = 0x00000058
-    XKc_Y* = 0x00000059
-    XKc_Z* = 0x0000005A
-    XK_bracketleft* = 0x0000005B
-    XK_backslash* = 0x0000005C
-    XK_bracketright* = 0x0000005D
-    XK_asciicircum* = 0x0000005E
-    XK_underscore* = 0x0000005F
-    XK_grave* = 0x00000060
-    XK_quoteleft* = 0x00000060  # deprecated 
-    XK_a* = 0x00000061
-    XK_b* = 0x00000062
-    XK_c* = 0x00000063
-    XK_d* = 0x00000064
-    XK_e* = 0x00000065
-    XK_f* = 0x00000066
-    XK_g* = 0x00000067
-    XK_h* = 0x00000068
-    XK_i* = 0x00000069
-    XK_j* = 0x0000006A
-    XK_k* = 0x0000006B
-    XK_l* = 0x0000006C
-    XK_m* = 0x0000006D
-    XK_n* = 0x0000006E
-    XK_o* = 0x0000006F
-    XK_p* = 0x00000070
-    XK_q* = 0x00000071
-    XK_r* = 0x00000072
-    XK_s* = 0x00000073
-    XK_t* = 0x00000074
-    XK_u* = 0x00000075
-    XK_v* = 0x00000076
-    XK_w* = 0x00000077
-    XK_x* = 0x00000078
-    XK_y* = 0x00000079
-    XK_z* = 0x0000007A
-    XK_braceleft* = 0x0000007B
-    XK_bar* = 0x0000007C
-    XK_braceright* = 0x0000007D
-    XK_asciitilde* = 0x0000007E
-    XK_nobreakspace* = 0x000000A0
-    XK_exclamdown* = 0x000000A1
-    XK_cent* = 0x000000A2
-    XK_sterling* = 0x000000A3
-    XK_currency* = 0x000000A4
-    XK_yen* = 0x000000A5
-    XK_brokenbar* = 0x000000A6
-    XK_section* = 0x000000A7
-    XK_diaeresis* = 0x000000A8
-    XK_copyright* = 0x000000A9
-    XK_ordfeminine* = 0x000000AA
-    XK_guillemotleft* = 0x000000AB # left angle quotation mark 
-    XK_notsign* = 0x000000AC
-    XK_hyphen* = 0x000000AD
-    XK_registered* = 0x000000AE
-    XK_macron* = 0x000000AF
-    XK_degree* = 0x000000B0
-    XK_plusminus* = 0x000000B1
-    XK_twosuperior* = 0x000000B2
-    XK_threesuperior* = 0x000000B3
-    XK_acute* = 0x000000B4
-    XK_mu* = 0x000000B5
-    XK_paragraph* = 0x000000B6
-    XK_periodcentered* = 0x000000B7
-    XK_cedilla* = 0x000000B8
-    XK_onesuperior* = 0x000000B9
-    XK_masculine* = 0x000000BA
-    XK_guillemotright* = 0x000000BB # right angle quotation mark 
-    XK_onequarter* = 0x000000BC
-    XK_onehalf* = 0x000000BD
-    XK_threequarters* = 0x000000BE
-    XK_questiondown* = 0x000000BF
-    XKc_Agrave* = 0x000000C0
-    XKc_Aacute* = 0x000000C1
-    XKc_Acircumflex* = 0x000000C2
-    XKc_Atilde* = 0x000000C3
-    XKc_Adiaeresis* = 0x000000C4
-    XKc_Aring* = 0x000000C5
-    XKc_AE* = 0x000000C6
-    XKc_Ccedilla* = 0x000000C7
-    XKc_Egrave* = 0x000000C8
-    XKc_Eacute* = 0x000000C9
-    XKc_Ecircumflex* = 0x000000CA
-    XKc_Ediaeresis* = 0x000000CB
-    XKc_Igrave* = 0x000000CC
-    XKc_Iacute* = 0x000000CD
-    XKc_Icircumflex* = 0x000000CE
-    XKc_Idiaeresis* = 0x000000CF
-    XKc_ETH* = 0x000000D0
-    XKc_Ntilde* = 0x000000D1
-    XKc_Ograve* = 0x000000D2
-    XKc_Oacute* = 0x000000D3
-    XKc_Ocircumflex* = 0x000000D4
-    XKc_Otilde* = 0x000000D5
-    XKc_Odiaeresis* = 0x000000D6
-    XK_multiply* = 0x000000D7
-    XKc_Ooblique* = 0x000000D8
-    XKc_Oslash* = XKc_Ooblique
-    XKc_Ugrave* = 0x000000D9
-    XKc_Uacute* = 0x000000DA
-    XKc_Ucircumflex* = 0x000000DB
-    XKc_Udiaeresis* = 0x000000DC
-    XKc_Yacute* = 0x000000DD
-    XKc_THORN* = 0x000000DE
-    XK_ssharp* = 0x000000DF
-    XK_agrave* = 0x000000E0
-    XK_aacute* = 0x000000E1
-    XK_acircumflex* = 0x000000E2
-    XK_atilde* = 0x000000E3
-    XK_adiaeresis* = 0x000000E4
-    XK_aring* = 0x000000E5
-    XK_ae* = 0x000000E6
-    XK_ccedilla* = 0x000000E7
-    XK_egrave* = 0x000000E8
-    XK_eacute* = 0x000000E9
-    XK_ecircumflex* = 0x000000EA
-    XK_ediaeresis* = 0x000000EB
-    XK_igrave* = 0x000000EC
-    XK_iacute* = 0x000000ED
-    XK_icircumflex* = 0x000000EE
-    XK_idiaeresis* = 0x000000EF
-    XK_eth* = 0x000000F0
-    XK_ntilde* = 0x000000F1
-    XK_ograve* = 0x000000F2
-    XK_oacute* = 0x000000F3
-    XK_ocircumflex* = 0x000000F4
-    XK_otilde* = 0x000000F5
-    XK_odiaeresis* = 0x000000F6
-    XK_division* = 0x000000F7
-    XK_oslash* = 0x000000F8
-    XK_ooblique* = XK_oslash
-    XK_ugrave* = 0x000000F9
-    XK_uacute* = 0x000000FA
-    XK_ucircumflex* = 0x000000FB
-    XK_udiaeresis* = 0x000000FC
-    XK_yacute* = 0x000000FD
-    XK_thorn* = 0x000000FE
-    XK_ydiaeresis* = 0x000000FF
-# XK_LATIN1 
-#*
-# *   Latin 2
-# *   Byte 3 = 1
-# *
-
-when defined(XK_LATIN2) or true: 
-  const
-    XKc_Aogonek* = 0x000001A1
-    XK_breve* = 0x000001A2
-    XKc_Lstroke* = 0x000001A3
-    XKc_Lcaron* = 0x000001A5
-    XKc_Sacute* = 0x000001A6
-    XKc_Scaron* = 0x000001A9
-    XKc_Scedilla* = 0x000001AA
-    XKc_Tcaron* = 0x000001AB
-    XKc_Zacute* = 0x000001AC
-    XKc_Zcaron* = 0x000001AE
-    XKc_Zabovedot* = 0x000001AF
-    XK_aogonek* = 0x000001B1
-    XK_ogonek* = 0x000001B2
-    XK_lstroke* = 0x000001B3
-    XK_lcaron* = 0x000001B5
-    XK_sacute* = 0x000001B6
-    XK_caron* = 0x000001B7
-    XK_scaron* = 0x000001B9
-    XK_scedilla* = 0x000001BA
-    XK_tcaron* = 0x000001BB
-    XK_zacute* = 0x000001BC
-    XK_doubleacute* = 0x000001BD
-    XK_zcaron* = 0x000001BE
-    XK_zabovedot* = 0x000001BF
-    XKc_Racute* = 0x000001C0
-    XKc_Abreve* = 0x000001C3
-    XKc_Lacute* = 0x000001C5
-    XKc_Cacute* = 0x000001C6
-    XKc_Ccaron* = 0x000001C8
-    XKc_Eogonek* = 0x000001CA
-    XKc_Ecaron* = 0x000001CC
-    XKc_Dcaron* = 0x000001CF
-    XKc_Dstroke* = 0x000001D0
-    XKc_Nacute* = 0x000001D1
-    XKc_Ncaron* = 0x000001D2
-    XKc_Odoubleacute* = 0x000001D5
-    XKc_Rcaron* = 0x000001D8
-    XKc_Uring* = 0x000001D9
-    XKc_Udoubleacute* = 0x000001DB
-    XKc_Tcedilla* = 0x000001DE
-    XK_racute* = 0x000001E0
-    XK_abreve* = 0x000001E3
-    XK_lacute* = 0x000001E5
-    XK_cacute* = 0x000001E6
-    XK_ccaron* = 0x000001E8
-    XK_eogonek* = 0x000001EA
-    XK_ecaron* = 0x000001EC
-    XK_dcaron* = 0x000001EF
-    XK_dstroke* = 0x000001F0
-    XK_nacute* = 0x000001F1
-    XK_ncaron* = 0x000001F2
-    XK_odoubleacute* = 0x000001F5
-    XK_udoubleacute* = 0x000001FB
-    XK_rcaron* = 0x000001F8
-    XK_uring* = 0x000001F9
-    XK_tcedilla* = 0x000001FE
-    XK_abovedot* = 0x000001FF
-# XK_LATIN2 
-#*
-# *   Latin 3
-# *   Byte 3 = 2
-# *
-
-when defined(XK_LATIN3) or true: 
-  const
-    XKc_Hstroke* = 0x000002A1
-    XKc_Hcircumflex* = 0x000002A6
-    XKc_Iabovedot* = 0x000002A9
-    XKc_Gbreve* = 0x000002AB
-    XKc_Jcircumflex* = 0x000002AC
-    XK_hstroke* = 0x000002B1
-    XK_hcircumflex* = 0x000002B6
-    XK_idotless* = 0x000002B9
-    XK_gbreve* = 0x000002BB
-    XK_jcircumflex* = 0x000002BC
-    XKc_Cabovedot* = 0x000002C5
-    XKc_Ccircumflex* = 0x000002C6
-    XKc_Gabovedot* = 0x000002D5
-    XKc_Gcircumflex* = 0x000002D8
-    XKc_Ubreve* = 0x000002DD
-    XKc_Scircumflex* = 0x000002DE
-    XK_cabovedot* = 0x000002E5
-    XK_ccircumflex* = 0x000002E6
-    XK_gabovedot* = 0x000002F5
-    XK_gcircumflex* = 0x000002F8
-    XK_ubreve* = 0x000002FD
-    XK_scircumflex* = 0x000002FE
-# XK_LATIN3 
-#*
-# *   Latin 4
-# *   Byte 3 = 3
-# *
-
-when defined(XK_LATIN4) or true: 
-  const
-    XK_kra* = 0x000003A2
-    XK_kappa* = 0x000003A2      # deprecated 
-    XKc_Rcedilla* = 0x000003A3
-    XKc_Itilde* = 0x000003A5
-    XKc_Lcedilla* = 0x000003A6
-    XKc_Emacron* = 0x000003AA
-    XKc_Gcedilla* = 0x000003AB
-    XKc_Tslash* = 0x000003AC
-    XK_rcedilla* = 0x000003B3
-    XK_itilde* = 0x000003B5
-    XK_lcedilla* = 0x000003B6
-    XK_emacron* = 0x000003BA
-    XK_gcedilla* = 0x000003BB
-    XK_tslash* = 0x000003BC
-    XKc_ENG* = 0x000003BD
-    XK_eng* = 0x000003BF
-    XKc_Amacron* = 0x000003C0
-    XKc_Iogonek* = 0x000003C7
-    XKc_Eabovedot* = 0x000003CC
-    XKc_Imacron* = 0x000003CF
-    XKc_Ncedilla* = 0x000003D1
-    XKc_Omacron* = 0x000003D2
-    XKc_Kcedilla* = 0x000003D3
-    XKc_Uogonek* = 0x000003D9
-    XKc_Utilde* = 0x000003DD
-    XKc_Umacron* = 0x000003DE
-    XK_amacron* = 0x000003E0
-    XK_iogonek* = 0x000003E7
-    XK_eabovedot* = 0x000003EC
-    XK_imacron* = 0x000003EF
-    XK_ncedilla* = 0x000003F1
-    XK_omacron* = 0x000003F2
-    XK_kcedilla* = 0x000003F3
-    XK_uogonek* = 0x000003F9
-    XK_utilde* = 0x000003FD
-    XK_umacron* = 0x000003FE
-# XK_LATIN4 
-#*
-# * Latin-8
-# * Byte 3 = 18
-# *
-
-when defined(XK_LATIN8) or true: 
-  const
-    XKc_Babovedot* = 0x000012A1
-    XK_babovedot* = 0x000012A2
-    XKc_Dabovedot* = 0x000012A6
-    XKc_Wgrave* = 0x000012A8
-    XKc_Wacute* = 0x000012AA
-    XK_dabovedot* = 0x000012AB
-    XKc_Ygrave* = 0x000012AC
-    XKc_Fabovedot* = 0x000012B0
-    XK_fabovedot* = 0x000012B1
-    XKc_Mabovedot* = 0x000012B4
-    XK_mabovedot* = 0x000012B5
-    XKc_Pabovedot* = 0x000012B7
-    XK_wgrave* = 0x000012B8
-    XK_pabovedot* = 0x000012B9
-    XK_wacute* = 0x000012BA
-    XKc_Sabovedot* = 0x000012BB
-    XK_ygrave* = 0x000012BC
-    XKc_Wdiaeresis* = 0x000012BD
-    XK_wdiaeresis* = 0x000012BE
-    XK_sabovedot* = 0x000012BF
-    XKc_Wcircumflex* = 0x000012D0
-    XKc_Tabovedot* = 0x000012D7
-    XKc_Ycircumflex* = 0x000012DE
-    XK_wcircumflex* = 0x000012F0
-    XK_tabovedot* = 0x000012F7
-    XK_ycircumflex* = 0x000012FE
-# XK_LATIN8 
-#*
-# * Latin-9 (a.k.a. Latin-0)
-# * Byte 3 = 19
-# *
-
-when defined(XK_LATIN9) or true: 
-  const
-    XKc_OE* = 0x000013BC
-    XK_oe* = 0x000013BD
-    XKc_Ydiaeresis* = 0x000013BE
-# XK_LATIN9 
-#*
-# * Katakana
-# * Byte 3 = 4
-# *
-
-when defined(XK_KATAKANA) or true: 
-  const
-    XK_overline* = 0x0000047E
-    XK_kana_fullstop* = 0x000004A1
-    XK_kana_openingbracket* = 0x000004A2
-    XK_kana_closingbracket* = 0x000004A3
-    XK_kana_comma* = 0x000004A4
-    XK_kana_conjunctive* = 0x000004A5
-    XK_kana_middledot* = 0x000004A5 # deprecated 
-    XKc_kana_WO* = 0x000004A6
-    XK_kana_a* = 0x000004A7
-    XK_kana_i* = 0x000004A8
-    XK_kana_u* = 0x000004A9
-    XK_kana_e* = 0x000004AA
-    XK_kana_o* = 0x000004AB
-    XK_kana_ya* = 0x000004AC
-    XK_kana_yu* = 0x000004AD
-    XK_kana_yo* = 0x000004AE
-    XK_kana_tsu* = 0x000004AF
-    XK_kana_tu* = 0x000004AF    # deprecated 
-    XK_prolongedsound* = 0x000004B0
-    XKc_kana_A* = 0x000004B1
-    XKc_kana_I* = 0x000004B2
-    XKc_kana_U* = 0x000004B3
-    XKc_kana_E* = 0x000004B4
-    XKc_kana_O* = 0x000004B5
-    XKc_kana_KA* = 0x000004B6
-    XKc_kana_KI* = 0x000004B7
-    XKc_kana_KU* = 0x000004B8
-    XKc_kana_KE* = 0x000004B9
-    XKc_kana_KO* = 0x000004BA
-    XKc_kana_SA* = 0x000004BB
-    XKc_kana_SHI* = 0x000004BC
-    XKc_kana_SU* = 0x000004BD
-    XKc_kana_SE* = 0x000004BE
-    XKc_kana_SO* = 0x000004BF
-    XKc_kana_TA* = 0x000004C0
-    XKc_kana_CHI* = 0x000004C1
-    XKc_kana_TI* = 0x000004C1   # deprecated 
-    XKc_kana_TSU* = 0x000004C2
-    XKc_kana_TU* = 0x000004C2   # deprecated 
-    XKc_kana_TE* = 0x000004C3
-    XKc_kana_TO* = 0x000004C4
-    XKc_kana_NA* = 0x000004C5
-    XKc_kana_NI* = 0x000004C6
-    XKc_kana_NU* = 0x000004C7
-    XKc_kana_NE* = 0x000004C8
-    XKc_kana_NO* = 0x000004C9
-    XKc_kana_HA* = 0x000004CA
-    XKc_kana_HI* = 0x000004CB
-    XKc_kana_FU* = 0x000004CC
-    XKc_kana_HU* = 0x000004CC   # deprecated 
-    XKc_kana_HE* = 0x000004CD
-    XKc_kana_HO* = 0x000004CE
-    XKc_kana_MA* = 0x000004CF
-    XKc_kana_MI* = 0x000004D0
-    XKc_kana_MU* = 0x000004D1
-    XKc_kana_ME* = 0x000004D2
-    XKc_kana_MO* = 0x000004D3
-    XKc_kana_YA* = 0x000004D4
-    XKc_kana_YU* = 0x000004D5
-    XKc_kana_YO* = 0x000004D6
-    XKc_kana_RA* = 0x000004D7
-    XKc_kana_RI* = 0x000004D8
-    XKc_kana_RU* = 0x000004D9
-    XKc_kana_RE* = 0x000004DA
-    XKc_kana_RO* = 0x000004DB
-    XKc_kana_WA* = 0x000004DC
-    XKc_kana_N* = 0x000004DD
-    XK_voicedsound* = 0x000004DE
-    XK_semivoicedsound* = 0x000004DF
-    XK_kana_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_KATAKANA 
-#*
-# *  Arabic
-# *  Byte 3 = 5
-# *
-
-when defined(XK_ARABIC) or true: 
-  const
-    XK_Farsi_0* = 0x00000590
-    XK_Farsi_1* = 0x00000591
-    XK_Farsi_2* = 0x00000592
-    XK_Farsi_3* = 0x00000593
-    XK_Farsi_4* = 0x00000594
-    XK_Farsi_5* = 0x00000595
-    XK_Farsi_6* = 0x00000596
-    XK_Farsi_7* = 0x00000597
-    XK_Farsi_8* = 0x00000598
-    XK_Farsi_9* = 0x00000599
-    XK_Arabic_percent* = 0x000005A5
-    XK_Arabic_superscript_alef* = 0x000005A6
-    XK_Arabic_tteh* = 0x000005A7
-    XK_Arabic_peh* = 0x000005A8
-    XK_Arabic_tcheh* = 0x000005A9
-    XK_Arabic_ddal* = 0x000005AA
-    XK_Arabic_rreh* = 0x000005AB
-    XK_Arabic_comma* = 0x000005AC
-    XK_Arabic_fullstop* = 0x000005AE
-    XK_Arabic_0* = 0x000005B0
-    XK_Arabic_1* = 0x000005B1
-    XK_Arabic_2* = 0x000005B2
-    XK_Arabic_3* = 0x000005B3
-    XK_Arabic_4* = 0x000005B4
-    XK_Arabic_5* = 0x000005B5
-    XK_Arabic_6* = 0x000005B6
-    XK_Arabic_7* = 0x000005B7
-    XK_Arabic_8* = 0x000005B8
-    XK_Arabic_9* = 0x000005B9
-    XK_Arabic_semicolon* = 0x000005BB
-    XK_Arabic_question_mark* = 0x000005BF
-    XK_Arabic_hamza* = 0x000005C1
-    XK_Arabic_maddaonalef* = 0x000005C2
-    XK_Arabic_hamzaonalef* = 0x000005C3
-    XK_Arabic_hamzaonwaw* = 0x000005C4
-    XK_Arabic_hamzaunderalef* = 0x000005C5
-    XK_Arabic_hamzaonyeh* = 0x000005C6
-    XK_Arabic_alef* = 0x000005C7
-    XK_Arabic_beh* = 0x000005C8
-    XK_Arabic_tehmarbuta* = 0x000005C9
-    XK_Arabic_teh* = 0x000005CA
-    XK_Arabic_theh* = 0x000005CB
-    XK_Arabic_jeem* = 0x000005CC
-    XK_Arabic_hah* = 0x000005CD
-    XK_Arabic_khah* = 0x000005CE
-    XK_Arabic_dal* = 0x000005CF
-    XK_Arabic_thal* = 0x000005D0
-    XK_Arabic_ra* = 0x000005D1
-    XK_Arabic_zain* = 0x000005D2
-    XK_Arabic_seen* = 0x000005D3
-    XK_Arabic_sheen* = 0x000005D4
-    XK_Arabic_sad* = 0x000005D5
-    XK_Arabic_dad* = 0x000005D6
-    XK_Arabic_tah* = 0x000005D7
-    XK_Arabic_zah* = 0x000005D8
-    XK_Arabic_ain* = 0x000005D9
-    XK_Arabic_ghain* = 0x000005DA
-    XK_Arabic_tatweel* = 0x000005E0
-    XK_Arabic_feh* = 0x000005E1
-    XK_Arabic_qaf* = 0x000005E2
-    XK_Arabic_kaf* = 0x000005E3
-    XK_Arabic_lam* = 0x000005E4
-    XK_Arabic_meem* = 0x000005E5
-    XK_Arabic_noon* = 0x000005E6
-    XK_Arabic_ha* = 0x000005E7
-    XK_Arabic_heh* = 0x000005E7 # deprecated 
-    XK_Arabic_waw* = 0x000005E8
-    XK_Arabic_alefmaksura* = 0x000005E9
-    XK_Arabic_yeh* = 0x000005EA
-    XK_Arabic_fathatan* = 0x000005EB
-    XK_Arabic_dammatan* = 0x000005EC
-    XK_Arabic_kasratan* = 0x000005ED
-    XK_Arabic_fatha* = 0x000005EE
-    XK_Arabic_damma* = 0x000005EF
-    XK_Arabic_kasra* = 0x000005F0
-    XK_Arabic_shadda* = 0x000005F1
-    XK_Arabic_sukun* = 0x000005F2
-    XK_Arabic_madda_above* = 0x000005F3
-    XK_Arabic_hamza_above* = 0x000005F4
-    XK_Arabic_hamza_below* = 0x000005F5
-    XK_Arabic_jeh* = 0x000005F6
-    XK_Arabic_veh* = 0x000005F7
-    XK_Arabic_keheh* = 0x000005F8
-    XK_Arabic_gaf* = 0x000005F9
-    XK_Arabic_noon_ghunna* = 0x000005FA
-    XK_Arabic_heh_doachashmee* = 0x000005FB
-    XK_Farsi_yeh* = 0x000005FC
-    XK_Arabic_farsi_yeh* = XK_Farsi_yeh
-    XK_Arabic_yeh_baree* = 0x000005FD
-    XK_Arabic_heh_goal* = 0x000005FE
-    XK_Arabic_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_ARABIC 
-#*
-# * Cyrillic
-# * Byte 3 = 6
-# *
-
-when defined(XK_CYRILLIC) or true: 
-  const
-    XKc_Cyrillic_GHE_bar* = 0x00000680
-    XK_Cyrillic_ghe_bar* = 0x00000690
-    XKc_Cyrillic_ZHE_descender* = 0x00000681
-    XK_Cyrillic_zhe_descender* = 0x00000691
-    XKc_Cyrillic_KA_descender* = 0x00000682
-    XK_Cyrillic_ka_descender* = 0x00000692
-    XKc_Cyrillic_KA_vertstroke* = 0x00000683
-    XK_Cyrillic_ka_vertstroke* = 0x00000693
-    XKc_Cyrillic_EN_descender* = 0x00000684
-    XK_Cyrillic_en_descender* = 0x00000694
-    XKc_Cyrillic_U_straight* = 0x00000685
-    XK_Cyrillic_u_straight* = 0x00000695
-    XKc_Cyrillic_U_straight_bar* = 0x00000686
-    XK_Cyrillic_u_straight_bar* = 0x00000696
-    XKc_Cyrillic_HA_descender* = 0x00000687
-    XK_Cyrillic_ha_descender* = 0x00000697
-    XKc_Cyrillic_CHE_descender* = 0x00000688
-    XK_Cyrillic_che_descender* = 0x00000698
-    XKc_Cyrillic_CHE_vertstroke* = 0x00000689
-    XK_Cyrillic_che_vertstroke* = 0x00000699
-    XKc_Cyrillic_SHHA* = 0x0000068A
-    XK_Cyrillic_shha* = 0x0000069A
-    XKc_Cyrillic_SCHWA* = 0x0000068C
-    XK_Cyrillic_schwa* = 0x0000069C
-    XKc_Cyrillic_I_macron* = 0x0000068D
-    XK_Cyrillic_i_macron* = 0x0000069D
-    XKc_Cyrillic_O_bar* = 0x0000068E
-    XK_Cyrillic_o_bar* = 0x0000069E
-    XKc_Cyrillic_U_macron* = 0x0000068F
-    XK_Cyrillic_u_macron* = 0x0000069F
-    XK_Serbian_dje* = 0x000006A1
-    XK_Macedonia_gje* = 0x000006A2
-    XK_Cyrillic_io* = 0x000006A3
-    XK_Ukrainian_ie* = 0x000006A4
-    XK_Ukranian_je* = 0x000006A4 # deprecated 
-    XK_Macedonia_dse* = 0x000006A5
-    XK_Ukrainian_i* = 0x000006A6
-    XK_Ukranian_i* = 0x000006A6 # deprecated 
-    XK_Ukrainian_yi* = 0x000006A7
-    XK_Ukranian_yi* = 0x000006A7 # deprecated 
-    XK_Cyrillic_je* = 0x000006A8
-    XK_Serbian_je* = 0x000006A8 # deprecated 
-    XK_Cyrillic_lje* = 0x000006A9
-    XK_Serbian_lje* = 0x000006A9 # deprecated 
-    XK_Cyrillic_nje* = 0x000006AA
-    XK_Serbian_nje* = 0x000006AA # deprecated 
-    XK_Serbian_tshe* = 0x000006AB
-    XK_Macedonia_kje* = 0x000006AC
-    XK_Ukrainian_ghe_with_upturn* = 0x000006AD
-    XK_Byelorussian_shortu* = 0x000006AE
-    XK_Cyrillic_dzhe* = 0x000006AF
-    XK_Serbian_dze* = 0x000006AF # deprecated 
-    XK_numerosign* = 0x000006B0
-    XKc_Serbian_DJE* = 0x000006B1
-    XKc_Macedonia_GJE* = 0x000006B2
-    XKc_Cyrillic_IO* = 0x000006B3
-    XKc_Ukrainian_IE* = 0x000006B4
-    XKc_Ukranian_JE* = 0x000006B4 # deprecated 
-    XKc_Macedonia_DSE* = 0x000006B5
-    XKc_Ukrainian_I* = 0x000006B6
-    XKc_Ukranian_I* = 0x000006B6 # deprecated 
-    XKc_Ukrainian_YI* = 0x000006B7
-    XKc_Ukranian_YI* = 0x000006B7 # deprecated 
-    XKc_Cyrillic_JE* = 0x000006B8
-    XKc_Serbian_JE* = 0x000006B8 # deprecated 
-    XKc_Cyrillic_LJE* = 0x000006B9
-    XKc_Serbian_LJE* = 0x000006B9 # deprecated 
-    XKc_Cyrillic_NJE* = 0x000006BA
-    XKc_Serbian_NJE* = 0x000006BA # deprecated 
-    XKc_Serbian_TSHE* = 0x000006BB
-    XKc_Macedonia_KJE* = 0x000006BC
-    XKc_Ukrainian_GHE_WITH_UPTURN* = 0x000006BD
-    XKc_Byelorussian_SHORTU* = 0x000006BE
-    XKc_Cyrillic_DZHE* = 0x000006BF
-    XKc_Serbian_DZE* = 0x000006BF # deprecated 
-    XK_Cyrillic_yu* = 0x000006C0
-    XK_Cyrillic_a* = 0x000006C1
-    XK_Cyrillic_be* = 0x000006C2
-    XK_Cyrillic_tse* = 0x000006C3
-    XK_Cyrillic_de* = 0x000006C4
-    XK_Cyrillic_ie* = 0x000006C5
-    XK_Cyrillic_ef* = 0x000006C6
-    XK_Cyrillic_ghe* = 0x000006C7
-    XK_Cyrillic_ha* = 0x000006C8
-    XK_Cyrillic_i* = 0x000006C9
-    XK_Cyrillic_shorti* = 0x000006CA
-    XK_Cyrillic_ka* = 0x000006CB
-    XK_Cyrillic_el* = 0x000006CC
-    XK_Cyrillic_em* = 0x000006CD
-    XK_Cyrillic_en* = 0x000006CE
-    XK_Cyrillic_o* = 0x000006CF
-    XK_Cyrillic_pe* = 0x000006D0
-    XK_Cyrillic_ya* = 0x000006D1
-    XK_Cyrillic_er* = 0x000006D2
-    XK_Cyrillic_es* = 0x000006D3
-    XK_Cyrillic_te* = 0x000006D4
-    XK_Cyrillic_u* = 0x000006D5
-    XK_Cyrillic_zhe* = 0x000006D6
-    XK_Cyrillic_ve* = 0x000006D7
-    XK_Cyrillic_softsign* = 0x000006D8
-    XK_Cyrillic_yeru* = 0x000006D9
-    XK_Cyrillic_ze* = 0x000006DA
-    XK_Cyrillic_sha* = 0x000006DB
-    XK_Cyrillic_e* = 0x000006DC
-    XK_Cyrillic_shcha* = 0x000006DD
-    XK_Cyrillic_che* = 0x000006DE
-    XK_Cyrillic_hardsign* = 0x000006DF
-    XKc_Cyrillic_YU* = 0x000006E0
-    XKc_Cyrillic_A* = 0x000006E1
-    XKc_Cyrillic_BE* = 0x000006E2
-    XKc_Cyrillic_TSE* = 0x000006E3
-    XKc_Cyrillic_DE* = 0x000006E4
-    XKc_Cyrillic_IE* = 0x000006E5
-    XKc_Cyrillic_EF* = 0x000006E6
-    XKc_Cyrillic_GHE* = 0x000006E7
-    XKc_Cyrillic_HA* = 0x000006E8
-    XKc_Cyrillic_I* = 0x000006E9
-    XKc_Cyrillic_SHORTI* = 0x000006EA
-    XKc_Cyrillic_KA* = 0x000006EB
-    XKc_Cyrillic_EL* = 0x000006EC
-    XKc_Cyrillic_EM* = 0x000006ED
-    XKc_Cyrillic_EN* = 0x000006EE
-    XKc_Cyrillic_O* = 0x000006EF
-    XKc_Cyrillic_PE* = 0x000006F0
-    XKc_Cyrillic_YA* = 0x000006F1
-    XKc_Cyrillic_ER* = 0x000006F2
-    XKc_Cyrillic_ES* = 0x000006F3
-    XKc_Cyrillic_TE* = 0x000006F4
-    XKc_Cyrillic_U* = 0x000006F5
-    XKc_Cyrillic_ZHE* = 0x000006F6
-    XKc_Cyrillic_VE* = 0x000006F7
-    XKc_Cyrillic_SOFTSIGN* = 0x000006F8
-    XKc_Cyrillic_YERU* = 0x000006F9
-    XKc_Cyrillic_ZE* = 0x000006FA
-    XKc_Cyrillic_SHA* = 0x000006FB
-    XKc_Cyrillic_E* = 0x000006FC
-    XKc_Cyrillic_SHCHA* = 0x000006FD
-    XKc_Cyrillic_CHE* = 0x000006FE
-    XKc_Cyrillic_HARDSIGN* = 0x000006FF
-# XK_CYRILLIC 
-#*
-# * Greek
-# * Byte 3 = 7
-# *
-
-when defined(XK_GREEK) or true: 
-  const
-    XKc_Greek_ALPHAaccent* = 0x000007A1
-    XKc_Greek_EPSILONaccent* = 0x000007A2
-    XKc_Greek_ETAaccent* = 0x000007A3
-    XKc_Greek_IOTAaccent* = 0x000007A4
-    XKc_Greek_IOTAdieresis* = 0x000007A5
-    XKc_Greek_IOTAdiaeresis* = XKc_Greek_IOTAdieresis # old typo 
-    XKc_Greek_OMICRONaccent* = 0x000007A7
-    XKc_Greek_UPSILONaccent* = 0x000007A8
-    XKc_Greek_UPSILONdieresis* = 0x000007A9
-    XKc_Greek_OMEGAaccent* = 0x000007AB
-    XK_Greek_accentdieresis* = 0x000007AE
-    XK_Greek_horizbar* = 0x000007AF
-    XK_Greek_alphaaccent* = 0x000007B1
-    XK_Greek_epsilonaccent* = 0x000007B2
-    XK_Greek_etaaccent* = 0x000007B3
-    XK_Greek_iotaaccent* = 0x000007B4
-    XK_Greek_iotadieresis* = 0x000007B5
-    XK_Greek_iotaaccentdieresis* = 0x000007B6
-    XK_Greek_omicronaccent* = 0x000007B7
-    XK_Greek_upsilonaccent* = 0x000007B8
-    XK_Greek_upsilondieresis* = 0x000007B9
-    XK_Greek_upsilonaccentdieresis* = 0x000007BA
-    XK_Greek_omegaaccent* = 0x000007BB
-    XKc_Greek_ALPHA* = 0x000007C1
-    XKc_Greek_BETA* = 0x000007C2
-    XKc_Greek_GAMMA* = 0x000007C3
-    XKc_Greek_DELTA* = 0x000007C4
-    XKc_Greek_EPSILON* = 0x000007C5
-    XKc_Greek_ZETA* = 0x000007C6
-    XKc_Greek_ETA* = 0x000007C7
-    XKc_Greek_THETA* = 0x000007C8
-    XKc_Greek_IOTA* = 0x000007C9
-    XKc_Greek_KAPPA* = 0x000007CA
-    XKc_Greek_LAMDA* = 0x000007CB
-    XKc_Greek_LAMBDA* = 0x000007CB
-    XKc_Greek_MU* = 0x000007CC
-    XKc_Greek_NU* = 0x000007CD
-    XKc_Greek_XI* = 0x000007CE
-    XKc_Greek_OMICRON* = 0x000007CF
-    XKc_Greek_PI* = 0x000007D0
-    XKc_Greek_RHO* = 0x000007D1
-    XKc_Greek_SIGMA* = 0x000007D2
-    XKc_Greek_TAU* = 0x000007D4
-    XKc_Greek_UPSILON* = 0x000007D5
-    XKc_Greek_PHI* = 0x000007D6
-    XKc_Greek_CHI* = 0x000007D7
-    XKc_Greek_PSI* = 0x000007D8
-    XKc_Greek_OMEGA* = 0x000007D9
-    XK_Greek_alpha* = 0x000007E1
-    XK_Greek_beta* = 0x000007E2
-    XK_Greek_gamma* = 0x000007E3
-    XK_Greek_delta* = 0x000007E4
-    XK_Greek_epsilon* = 0x000007E5
-    XK_Greek_zeta* = 0x000007E6
-    XK_Greek_eta* = 0x000007E7
-    XK_Greek_theta* = 0x000007E8
-    XK_Greek_iota* = 0x000007E9
-    XK_Greek_kappa* = 0x000007EA
-    XK_Greek_lamda* = 0x000007EB
-    XK_Greek_lambda* = 0x000007EB
-    XK_Greek_mu* = 0x000007EC
-    XK_Greek_nu* = 0x000007ED
-    XK_Greek_xi* = 0x000007EE
-    XK_Greek_omicron* = 0x000007EF
-    XK_Greek_pi* = 0x000007F0
-    XK_Greek_rho* = 0x000007F1
-    XK_Greek_sigma* = 0x000007F2
-    XK_Greek_finalsmallsigma* = 0x000007F3
-    XK_Greek_tau* = 0x000007F4
-    XK_Greek_upsilon* = 0x000007F5
-    XK_Greek_phi* = 0x000007F6
-    XK_Greek_chi* = 0x000007F7
-    XK_Greek_psi* = 0x000007F8
-    XK_Greek_omega* = 0x000007F9
-    XK_Greek_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_GREEK 
-#*
-# * Technical
-# * Byte 3 = 8
-# *
-
-when defined(XK_TECHNICAL) or true: 
-  const
-    XK_leftradical* = 0x000008A1
-    XK_topleftradical* = 0x000008A2
-    XK_horizconnector* = 0x000008A3
-    XK_topintegral* = 0x000008A4
-    XK_botintegral* = 0x000008A5
-    XK_vertconnector* = 0x000008A6
-    XK_topleftsqbracket* = 0x000008A7
-    XK_botleftsqbracket* = 0x000008A8
-    XK_toprightsqbracket* = 0x000008A9
-    XK_botrightsqbracket* = 0x000008AA
-    XK_topleftparens* = 0x000008AB
-    XK_botleftparens* = 0x000008AC
-    XK_toprightparens* = 0x000008AD
-    XK_botrightparens* = 0x000008AE
-    XK_leftmiddlecurlybrace* = 0x000008AF
-    XK_rightmiddlecurlybrace* = 0x000008B0
-    XK_topleftsummation* = 0x000008B1
-    XK_botleftsummation* = 0x000008B2
-    XK_topvertsummationconnector* = 0x000008B3
-    XK_botvertsummationconnector* = 0x000008B4
-    XK_toprightsummation* = 0x000008B5
-    XK_botrightsummation* = 0x000008B6
-    XK_rightmiddlesummation* = 0x000008B7
-    XK_lessthanequal* = 0x000008BC
-    XK_notequal* = 0x000008BD
-    XK_greaterthanequal* = 0x000008BE
-    XK_integral* = 0x000008BF
-    XK_therefore* = 0x000008C0
-    XK_variation* = 0x000008C1
-    XK_infinity* = 0x000008C2
-    XK_nabla* = 0x000008C5
-    XK_approximate* = 0x000008C8
-    XK_similarequal* = 0x000008C9
-    XK_ifonlyif* = 0x000008CD
-    XK_implies* = 0x000008CE
-    XK_identical* = 0x000008CF
-    XK_radical* = 0x000008D6
-    XK_includedin* = 0x000008DA
-    XK_includes* = 0x000008DB
-    XK_intersection* = 0x000008DC
-    XK_union* = 0x000008DD
-    XK_logicaland* = 0x000008DE
-    XK_logicalor* = 0x000008DF
-    XK_partialderivative* = 0x000008EF
-    XK_function* = 0x000008F6
-    XK_leftarrow* = 0x000008FB
-    XK_uparrow* = 0x000008FC
-    XK_rightarrow* = 0x000008FD
-    XK_downarrow* = 0x000008FE
-# XK_TECHNICAL 
-#*
-# *  Special
-# *  Byte 3 = 9
-# *
-
-when defined(XK_SPECIAL): 
-  const
-    XK_blank* = 0x000009DF
-    XK_soliddiamond* = 0x000009E0
-    XK_checkerboard* = 0x000009E1
-    XK_ht* = 0x000009E2
-    XK_ff* = 0x000009E3
-    XK_cr* = 0x000009E4
-    XK_lf* = 0x000009E5
-    XK_nl* = 0x000009E8
-    XK_vt* = 0x000009E9
-    XK_lowrightcorner* = 0x000009EA
-    XK_uprightcorner* = 0x000009EB
-    XK_upleftcorner* = 0x000009EC
-    XK_lowleftcorner* = 0x000009ED
-    XK_crossinglines* = 0x000009EE
-    XK_horizlinescan1* = 0x000009EF
-    XK_horizlinescan3* = 0x000009F0
-    XK_horizlinescan5* = 0x000009F1
-    XK_horizlinescan7* = 0x000009F2
-    XK_horizlinescan9* = 0x000009F3
-    XK_leftt* = 0x000009F4
-    XK_rightt* = 0x000009F5
-    XK_bott* = 0x000009F6
-    XK_topt* = 0x000009F7
-    XK_vertbar* = 0x000009F8
-# XK_SPECIAL 
-#*
-# *  Publishing
-# *  Byte 3 = a
-# *
-
-when defined(XK_PUBLISHING) or true: 
-  const
-    XK_emspace* = 0x00000AA1
-    XK_enspace* = 0x00000AA2
-    XK_em3space* = 0x00000AA3
-    XK_em4space* = 0x00000AA4
-    XK_digitspace* = 0x00000AA5
-    XK_punctspace* = 0x00000AA6
-    XK_thinspace* = 0x00000AA7
-    XK_hairspace* = 0x00000AA8
-    XK_emdash* = 0x00000AA9
-    XK_endash* = 0x00000AAA
-    XK_signifblank* = 0x00000AAC
-    XK_ellipsis* = 0x00000AAE
-    XK_doubbaselinedot* = 0x00000AAF
-    XK_onethird* = 0x00000AB0
-    XK_twothirds* = 0x00000AB1
-    XK_onefifth* = 0x00000AB2
-    XK_twofifths* = 0x00000AB3
-    XK_threefifths* = 0x00000AB4
-    XK_fourfifths* = 0x00000AB5
-    XK_onesixth* = 0x00000AB6
-    XK_fivesixths* = 0x00000AB7
-    XK_careof* = 0x00000AB8
-    XK_figdash* = 0x00000ABB
-    XK_leftanglebracket* = 0x00000ABC
-    XK_decimalpoint* = 0x00000ABD
-    XK_rightanglebracket* = 0x00000ABE
-    XK_marker* = 0x00000ABF
-    XK_oneeighth* = 0x00000AC3
-    XK_threeeighths* = 0x00000AC4
-    XK_fiveeighths* = 0x00000AC5
-    XK_seveneighths* = 0x00000AC6
-    XK_trademark* = 0x00000AC9
-    XK_signaturemark* = 0x00000ACA
-    XK_trademarkincircle* = 0x00000ACB
-    XK_leftopentriangle* = 0x00000ACC
-    XK_rightopentriangle* = 0x00000ACD
-    XK_emopencircle* = 0x00000ACE
-    XK_emopenrectangle* = 0x00000ACF
-    XK_leftsinglequotemark* = 0x00000AD0
-    XK_rightsinglequotemark* = 0x00000AD1
-    XK_leftdoublequotemark* = 0x00000AD2
-    XK_rightdoublequotemark* = 0x00000AD3
-    XK_prescription* = 0x00000AD4
-    XK_minutes* = 0x00000AD6
-    XK_seconds* = 0x00000AD7
-    XK_latincross* = 0x00000AD9
-    XK_hexagram* = 0x00000ADA
-    XK_filledrectbullet* = 0x00000ADB
-    XK_filledlefttribullet* = 0x00000ADC
-    XK_filledrighttribullet* = 0x00000ADD
-    XK_emfilledcircle* = 0x00000ADE
-    XK_emfilledrect* = 0x00000ADF
-    XK_enopencircbullet* = 0x00000AE0
-    XK_enopensquarebullet* = 0x00000AE1
-    XK_openrectbullet* = 0x00000AE2
-    XK_opentribulletup* = 0x00000AE3
-    XK_opentribulletdown* = 0x00000AE4
-    XK_openstar* = 0x00000AE5
-    XK_enfilledcircbullet* = 0x00000AE6
-    XK_enfilledsqbullet* = 0x00000AE7
-    XK_filledtribulletup* = 0x00000AE8
-    XK_filledtribulletdown* = 0x00000AE9
-    XK_leftpointer* = 0x00000AEA
-    XK_rightpointer* = 0x00000AEB
-    XK_club* = 0x00000AEC
-    XK_diamond* = 0x00000AED
-    XK_heart* = 0x00000AEE
-    XK_maltesecross* = 0x00000AF0
-    XK_dagger* = 0x00000AF1
-    XK_doubledagger* = 0x00000AF2
-    XK_checkmark* = 0x00000AF3
-    XK_ballotcross* = 0x00000AF4
-    XK_musicalsharp* = 0x00000AF5
-    XK_musicalflat* = 0x00000AF6
-    XK_malesymbol* = 0x00000AF7
-    XK_femalesymbol* = 0x00000AF8
-    XK_telephone* = 0x00000AF9
-    XK_telephonerecorder* = 0x00000AFA
-    XK_phonographcopyright* = 0x00000AFB
-    XK_caret* = 0x00000AFC
-    XK_singlelowquotemark* = 0x00000AFD
-    XK_doublelowquotemark* = 0x00000AFE
-    XK_cursor* = 0x00000AFF
-# XK_PUBLISHING 
-#*
-# *  APL
-# *  Byte 3 = b
-# *
-
-when defined(XK_APL) or true: 
-  const
-    XK_leftcaret* = 0x00000BA3
-    XK_rightcaret* = 0x00000BA6
-    XK_downcaret* = 0x00000BA8
-    XK_upcaret* = 0x00000BA9
-    XK_overbar* = 0x00000BC0
-    XK_downtack* = 0x00000BC2
-    XK_upshoe* = 0x00000BC3
-    XK_downstile* = 0x00000BC4
-    XK_underbar* = 0x00000BC6
-    XK_jot* = 0x00000BCA
-    XK_quad* = 0x00000BCC
-    XK_uptack* = 0x00000BCE
-    XK_circle* = 0x00000BCF
-    XK_upstile* = 0x00000BD3
-    XK_downshoe* = 0x00000BD6
-    XK_rightshoe* = 0x00000BD8
-    XK_leftshoe* = 0x00000BDA
-    XK_lefttack* = 0x00000BDC
-    XK_righttack* = 0x00000BFC
-# XK_APL 
-#*
-# * Hebrew
-# * Byte 3 = c
-# *
-
-when defined(XK_HEBREW) or true: 
-  const
-    XK_hebrew_doublelowline* = 0x00000CDF
-    XK_hebrew_aleph* = 0x00000CE0
-    XK_hebrew_bet* = 0x00000CE1
-    XK_hebrew_beth* = 0x00000CE1 # deprecated 
-    XK_hebrew_gimel* = 0x00000CE2
-    XK_hebrew_gimmel* = 0x00000CE2 # deprecated 
-    XK_hebrew_dalet* = 0x00000CE3
-    XK_hebrew_daleth* = 0x00000CE3 # deprecated 
-    XK_hebrew_he* = 0x00000CE4
-    XK_hebrew_waw* = 0x00000CE5
-    XK_hebrew_zain* = 0x00000CE6
-    XK_hebrew_zayin* = 0x00000CE6 # deprecated 
-    XK_hebrew_chet* = 0x00000CE7
-    XK_hebrew_het* = 0x00000CE7 # deprecated 
-    XK_hebrew_tet* = 0x00000CE8
-    XK_hebrew_teth* = 0x00000CE8 # deprecated 
-    XK_hebrew_yod* = 0x00000CE9
-    XK_hebrew_finalkaph* = 0x00000CEA
-    XK_hebrew_kaph* = 0x00000CEB
-    XK_hebrew_lamed* = 0x00000CEC
-    XK_hebrew_finalmem* = 0x00000CED
-    XK_hebrew_mem* = 0x00000CEE
-    XK_hebrew_finalnun* = 0x00000CEF
-    XK_hebrew_nun* = 0x00000CF0
-    XK_hebrew_samech* = 0x00000CF1
-    XK_hebrew_samekh* = 0x00000CF1 # deprecated 
-    XK_hebrew_ayin* = 0x00000CF2
-    XK_hebrew_finalpe* = 0x00000CF3
-    XK_hebrew_pe* = 0x00000CF4
-    XK_hebrew_finalzade* = 0x00000CF5
-    XK_hebrew_finalzadi* = 0x00000CF5 # deprecated 
-    XK_hebrew_zade* = 0x00000CF6
-    XK_hebrew_zadi* = 0x00000CF6 # deprecated 
-    XK_hebrew_qoph* = 0x00000CF7
-    XK_hebrew_kuf* = 0x00000CF7 # deprecated 
-    XK_hebrew_resh* = 0x00000CF8
-    XK_hebrew_shin* = 0x00000CF9
-    XK_hebrew_taw* = 0x00000CFA
-    XK_hebrew_taf* = 0x00000CFA # deprecated 
-    XK_Hebrew_switch* = 0x0000FF7E # Alias for mode_switch 
-# XK_HEBREW 
-#*
-# * Thai
-# * Byte 3 = d
-# *
-
-when defined(XK_THAI) or true: 
-  const
-    XK_Thai_kokai* = 0x00000DA1
-    XK_Thai_khokhai* = 0x00000DA2
-    XK_Thai_khokhuat* = 0x00000DA3
-    XK_Thai_khokhwai* = 0x00000DA4
-    XK_Thai_khokhon* = 0x00000DA5
-    XK_Thai_khorakhang* = 0x00000DA6
-    XK_Thai_ngongu* = 0x00000DA7
-    XK_Thai_chochan* = 0x00000DA8
-    XK_Thai_choching* = 0x00000DA9
-    XK_Thai_chochang* = 0x00000DAA
-    XK_Thai_soso* = 0x00000DAB
-    XK_Thai_chochoe* = 0x00000DAC
-    XK_Thai_yoying* = 0x00000DAD
-    XK_Thai_dochada* = 0x00000DAE
-    XK_Thai_topatak* = 0x00000DAF
-    XK_Thai_thothan* = 0x00000DB0
-    XK_Thai_thonangmontho* = 0x00000DB1
-    XK_Thai_thophuthao* = 0x00000DB2
-    XK_Thai_nonen* = 0x00000DB3
-    XK_Thai_dodek* = 0x00000DB4
-    XK_Thai_totao* = 0x00000DB5
-    XK_Thai_thothung* = 0x00000DB6
-    XK_Thai_thothahan* = 0x00000DB7
-    XK_Thai_thothong* = 0x00000DB8
-    XK_Thai_nonu* = 0x00000DB9
-    XK_Thai_bobaimai* = 0x00000DBA
-    XK_Thai_popla* = 0x00000DBB
-    XK_Thai_phophung* = 0x00000DBC
-    XK_Thai_fofa* = 0x00000DBD
-    XK_Thai_phophan* = 0x00000DBE
-    XK_Thai_fofan* = 0x00000DBF
-    XK_Thai_phosamphao* = 0x00000DC0
-    XK_Thai_moma* = 0x00000DC1
-    XK_Thai_yoyak* = 0x00000DC2
-    XK_Thai_rorua* = 0x00000DC3
-    XK_Thai_ru* = 0x00000DC4
-    XK_Thai_loling* = 0x00000DC5
-    XK_Thai_lu* = 0x00000DC6
-    XK_Thai_wowaen* = 0x00000DC7
-    XK_Thai_sosala* = 0x00000DC8
-    XK_Thai_sorusi* = 0x00000DC9
-    XK_Thai_sosua* = 0x00000DCA
-    XK_Thai_hohip* = 0x00000DCB
-    XK_Thai_lochula* = 0x00000DCC
-    XK_Thai_oang* = 0x00000DCD
-    XK_Thai_honokhuk* = 0x00000DCE
-    XK_Thai_paiyannoi* = 0x00000DCF
-    XK_Thai_saraa* = 0x00000DD0
-    XK_Thai_maihanakat* = 0x00000DD1
-    XK_Thai_saraaa* = 0x00000DD2
-    XK_Thai_saraam* = 0x00000DD3
-    XK_Thai_sarai* = 0x00000DD4
-    XK_Thai_saraii* = 0x00000DD5
-    XK_Thai_saraue* = 0x00000DD6
-    XK_Thai_sarauee* = 0x00000DD7
-    XK_Thai_sarau* = 0x00000DD8
-    XK_Thai_sarauu* = 0x00000DD9
-    XK_Thai_phinthu* = 0x00000DDA
-    XK_Thai_maihanakat_maitho* = 0x00000DDE
-    XK_Thai_baht* = 0x00000DDF
-    XK_Thai_sarae* = 0x00000DE0
-    XK_Thai_saraae* = 0x00000DE1
-    XK_Thai_sarao* = 0x00000DE2
-    XK_Thai_saraaimaimuan* = 0x00000DE3
-    XK_Thai_saraaimaimalai* = 0x00000DE4
-    XK_Thai_lakkhangyao* = 0x00000DE5
-    XK_Thai_maiyamok* = 0x00000DE6
-    XK_Thai_maitaikhu* = 0x00000DE7
-    XK_Thai_maiek* = 0x00000DE8
-    XK_Thai_maitho* = 0x00000DE9
-    XK_Thai_maitri* = 0x00000DEA
-    XK_Thai_maichattawa* = 0x00000DEB
-    XK_Thai_thanthakhat* = 0x00000DEC
-    XK_Thai_nikhahit* = 0x00000DED
-    XK_Thai_leksun* = 0x00000DF0
-    XK_Thai_leknung* = 0x00000DF1
-    XK_Thai_leksong* = 0x00000DF2
-    XK_Thai_leksam* = 0x00000DF3
-    XK_Thai_leksi* = 0x00000DF4
-    XK_Thai_lekha* = 0x00000DF5
-    XK_Thai_lekhok* = 0x00000DF6
-    XK_Thai_lekchet* = 0x00000DF7
-    XK_Thai_lekpaet* = 0x00000DF8
-    XK_Thai_lekkao* = 0x00000DF9
-# XK_THAI 
-#*
-# *   Korean
-# *   Byte 3 = e
-# *
-
-when defined(XK_KOREAN) or true: 
-  const
-    XK_Hangul* = 0x0000FF31     # Hangul start/stop(toggle) 
-    XK_Hangul_Start* = 0x0000FF32 # Hangul start 
-    XK_Hangul_End* = 0x0000FF33 # Hangul end, English start 
-    XK_Hangul_Hanja* = 0x0000FF34 # Start Hangul->Hanja Conversion 
-    XK_Hangul_Jamo* = 0x0000FF35 # Hangul Jamo mode 
-    XK_Hangul_Romaja* = 0x0000FF36 # Hangul Romaja mode 
-    XK_Hangul_Codeinput* = 0x0000FF37 # Hangul code input mode 
-    XK_Hangul_Jeonja* = 0x0000FF38 # Jeonja mode 
-    XK_Hangul_Banja* = 0x0000FF39 # Banja mode 
-    XK_Hangul_PreHanja* = 0x0000FF3A # Pre Hanja conversion 
-    XK_Hangul_PostHanja* = 0x0000FF3B # Post Hanja conversion 
-    XK_Hangul_SingleCandidate* = 0x0000FF3C # Single candidate 
-    XK_Hangul_MultipleCandidate* = 0x0000FF3D # Multiple candidate 
-    XK_Hangul_PreviousCandidate* = 0x0000FF3E # Previous candidate 
-    XK_Hangul_Special* = 0x0000FF3F # Special symbols 
-    XK_Hangul_switch* = 0x0000FF7E # Alias for mode_switch 
-                                   # Hangul Consonant Characters 
-    XK_Hangul_Kiyeog* = 0x00000EA1
-    XK_Hangul_SsangKiyeog* = 0x00000EA2
-    XK_Hangul_KiyeogSios* = 0x00000EA3
-    XK_Hangul_Nieun* = 0x00000EA4
-    XK_Hangul_NieunJieuj* = 0x00000EA5
-    XK_Hangul_NieunHieuh* = 0x00000EA6
-    XK_Hangul_Dikeud* = 0x00000EA7
-    XK_Hangul_SsangDikeud* = 0x00000EA8
-    XK_Hangul_Rieul* = 0x00000EA9
-    XK_Hangul_RieulKiyeog* = 0x00000EAA
-    XK_Hangul_RieulMieum* = 0x00000EAB
-    XK_Hangul_RieulPieub* = 0x00000EAC
-    XK_Hangul_RieulSios* = 0x00000EAD
-    XK_Hangul_RieulTieut* = 0x00000EAE
-    XK_Hangul_RieulPhieuf* = 0x00000EAF
-    XK_Hangul_RieulHieuh* = 0x00000EB0
-    XK_Hangul_Mieum* = 0x00000EB1
-    XK_Hangul_Pieub* = 0x00000EB2
-    XK_Hangul_SsangPieub* = 0x00000EB3
-    XK_Hangul_PieubSios* = 0x00000EB4
-    XK_Hangul_Sios* = 0x00000EB5
-    XK_Hangul_SsangSios* = 0x00000EB6
-    XK_Hangul_Ieung* = 0x00000EB7
-    XK_Hangul_Jieuj* = 0x00000EB8
-    XK_Hangul_SsangJieuj* = 0x00000EB9
-    XK_Hangul_Cieuc* = 0x00000EBA
-    XK_Hangul_Khieuq* = 0x00000EBB
-    XK_Hangul_Tieut* = 0x00000EBC
-    XK_Hangul_Phieuf* = 0x00000EBD
-    XK_Hangul_Hieuh* = 0x00000EBE # Hangul Vowel Characters 
-    XK_Hangul_A* = 0x00000EBF
-    XK_Hangul_AE* = 0x00000EC0
-    XK_Hangul_YA* = 0x00000EC1
-    XK_Hangul_YAE* = 0x00000EC2
-    XK_Hangul_EO* = 0x00000EC3
-    XK_Hangul_E* = 0x00000EC4
-    XK_Hangul_YEO* = 0x00000EC5
-    XK_Hangul_YE* = 0x00000EC6
-    XK_Hangul_O* = 0x00000EC7
-    XK_Hangul_WA* = 0x00000EC8
-    XK_Hangul_WAE* = 0x00000EC9
-    XK_Hangul_OE* = 0x00000ECA
-    XK_Hangul_YO* = 0x00000ECB
-    XK_Hangul_U* = 0x00000ECC
-    XK_Hangul_WEO* = 0x00000ECD
-    XK_Hangul_WE* = 0x00000ECE
-    XK_Hangul_WI* = 0x00000ECF
-    XK_Hangul_YU* = 0x00000ED0
-    XK_Hangul_EU* = 0x00000ED1
-    XK_Hangul_YI* = 0x00000ED2
-    XK_Hangul_I* = 0x00000ED3   # Hangul syllable-final (JongSeong) Characters 
-    XK_Hangul_J_Kiyeog* = 0x00000ED4
-    XK_Hangul_J_SsangKiyeog* = 0x00000ED5
-    XK_Hangul_J_KiyeogSios* = 0x00000ED6
-    XK_Hangul_J_Nieun* = 0x00000ED7
-    XK_Hangul_J_NieunJieuj* = 0x00000ED8
-    XK_Hangul_J_NieunHieuh* = 0x00000ED9
-    XK_Hangul_J_Dikeud* = 0x00000EDA
-    XK_Hangul_J_Rieul* = 0x00000EDB
-    XK_Hangul_J_RieulKiyeog* = 0x00000EDC
-    XK_Hangul_J_RieulMieum* = 0x00000EDD
-    XK_Hangul_J_RieulPieub* = 0x00000EDE
-    XK_Hangul_J_RieulSios* = 0x00000EDF
-    XK_Hangul_J_RieulTieut* = 0x00000EE0
-    XK_Hangul_J_RieulPhieuf* = 0x00000EE1
-    XK_Hangul_J_RieulHieuh* = 0x00000EE2
-    XK_Hangul_J_Mieum* = 0x00000EE3
-    XK_Hangul_J_Pieub* = 0x00000EE4
-    XK_Hangul_J_PieubSios* = 0x00000EE5
-    XK_Hangul_J_Sios* = 0x00000EE6
-    XK_Hangul_J_SsangSios* = 0x00000EE7
-    XK_Hangul_J_Ieung* = 0x00000EE8
-    XK_Hangul_J_Jieuj* = 0x00000EE9
-    XK_Hangul_J_Cieuc* = 0x00000EEA
-    XK_Hangul_J_Khieuq* = 0x00000EEB
-    XK_Hangul_J_Tieut* = 0x00000EEC
-    XK_Hangul_J_Phieuf* = 0x00000EED
-    XK_Hangul_J_Hieuh* = 0x00000EEE # Ancient Hangul Consonant Characters 
-    XK_Hangul_RieulYeorinHieuh* = 0x00000EEF
-    XK_Hangul_SunkyeongeumMieum* = 0x00000EF0
-    XK_Hangul_SunkyeongeumPieub* = 0x00000EF1
-    XK_Hangul_PanSios* = 0x00000EF2
-    XK_Hangul_KkogjiDalrinIeung* = 0x00000EF3
-    XK_Hangul_SunkyeongeumPhieuf* = 0x00000EF4
-    XK_Hangul_YeorinHieuh* = 0x00000EF5 # Ancient Hangul Vowel Characters 
-    XK_Hangul_AraeA* = 0x00000EF6
-    XK_Hangul_AraeAE* = 0x00000EF7 # Ancient Hangul syllable-final (JongSeong) Characters 
-    XK_Hangul_J_PanSios* = 0x00000EF8
-    XK_Hangul_J_KkogjiDalrinIeung* = 0x00000EF9
-    XK_Hangul_J_YeorinHieuh* = 0x00000EFA # Korean currency symbol 
-    XK_Korean_Won* = 0x00000EFF
-# XK_KOREAN 
-#*
-# *   Armenian
-# *   Byte 3 = = $14
-# *
-
-when defined(XK_ARMENIAN) or true: 
-  const
-    XK_Armenian_eternity* = 0x000014A1
-    XK_Armenian_ligature_ew* = 0x000014A2
-    XK_Armenian_full_stop* = 0x000014A3
-    XK_Armenian_verjaket* = 0x000014A3
-    XK_Armenian_parenright* = 0x000014A4
-    XK_Armenian_parenleft* = 0x000014A5
-    XK_Armenian_guillemotright* = 0x000014A6
-    XK_Armenian_guillemotleft* = 0x000014A7
-    XK_Armenian_em_dash* = 0x000014A8
-    XK_Armenian_dot* = 0x000014A9
-    XK_Armenian_mijaket* = 0x000014A9
-    XK_Armenian_separation_mark* = 0x000014AA
-    XK_Armenian_but* = 0x000014AA
-    XK_Armenian_comma* = 0x000014AB
-    XK_Armenian_en_dash* = 0x000014AC
-    XK_Armenian_hyphen* = 0x000014AD
-    XK_Armenian_yentamna* = 0x000014AD
-    XK_Armenian_ellipsis* = 0x000014AE
-    XK_Armenian_exclam* = 0x000014AF
-    XK_Armenian_amanak* = 0x000014AF
-    XK_Armenian_accent* = 0x000014B0
-    XK_Armenian_shesht* = 0x000014B0
-    XK_Armenian_question* = 0x000014B1
-    XK_Armenian_paruyk* = 0x000014B1
-    XKc_Armenian_AYB* = 0x000014B2
-    XK_Armenian_ayb* = 0x000014B3
-    XKc_Armenian_BEN* = 0x000014B4
-    XK_Armenian_ben* = 0x000014B5
-    XKc_Armenian_GIM* = 0x000014B6
-    XK_Armenian_gim* = 0x000014B7
-    XKc_Armenian_DA* = 0x000014B8
-    XK_Armenian_da* = 0x000014B9
-    XKc_Armenian_YECH* = 0x000014BA
-    XK_Armenian_yech* = 0x000014BB
-    XKc_Armenian_ZA* = 0x000014BC
-    XK_Armenian_za* = 0x000014BD
-    XKc_Armenian_E* = 0x000014BE
-    XK_Armenian_e* = 0x000014BF
-    XKc_Armenian_AT* = 0x000014C0
-    XK_Armenian_at* = 0x000014C1
-    XKc_Armenian_TO* = 0x000014C2
-    XK_Armenian_to* = 0x000014C3
-    XKc_Armenian_ZHE* = 0x000014C4
-    XK_Armenian_zhe* = 0x000014C5
-    XKc_Armenian_INI* = 0x000014C6
-    XK_Armenian_ini* = 0x000014C7
-    XKc_Armenian_LYUN* = 0x000014C8
-    XK_Armenian_lyun* = 0x000014C9
-    XKc_Armenian_KHE* = 0x000014CA
-    XK_Armenian_khe* = 0x000014CB
-    XKc_Armenian_TSA* = 0x000014CC
-    XK_Armenian_tsa* = 0x000014CD
-    XKc_Armenian_KEN* = 0x000014CE
-    XK_Armenian_ken* = 0x000014CF
-    XKc_Armenian_HO* = 0x000014D0
-    XK_Armenian_ho* = 0x000014D1
-    XKc_Armenian_DZA* = 0x000014D2
-    XK_Armenian_dza* = 0x000014D3
-    XKc_Armenian_GHAT* = 0x000014D4
-    XK_Armenian_ghat* = 0x000014D5
-    XKc_Armenian_TCHE* = 0x000014D6
-    XK_Armenian_tche* = 0x000014D7
-    XKc_Armenian_MEN* = 0x000014D8
-    XK_Armenian_men* = 0x000014D9
-    XKc_Armenian_HI* = 0x000014DA
-    XK_Armenian_hi* = 0x000014DB
-    XKc_Armenian_NU* = 0x000014DC
-    XK_Armenian_nu* = 0x000014DD
-    XKc_Armenian_SHA* = 0x000014DE
-    XK_Armenian_sha* = 0x000014DF
-    XKc_Armenian_VO* = 0x000014E0
-    XK_Armenian_vo* = 0x000014E1
-    XKc_Armenian_CHA* = 0x000014E2
-    XK_Armenian_cha* = 0x000014E3
-    XKc_Armenian_PE* = 0x000014E4
-    XK_Armenian_pe* = 0x000014E5
-    XKc_Armenian_JE* = 0x000014E6
-    XK_Armenian_je* = 0x000014E7
-    XKc_Armenian_RA* = 0x000014E8
-    XK_Armenian_ra* = 0x000014E9
-    XKc_Armenian_SE* = 0x000014EA
-    XK_Armenian_se* = 0x000014EB
-    XKc_Armenian_VEV* = 0x000014EC
-    XK_Armenian_vev* = 0x000014ED
-    XKc_Armenian_TYUN* = 0x000014EE
-    XK_Armenian_tyun* = 0x000014EF
-    XKc_Armenian_RE* = 0x000014F0
-    XK_Armenian_re* = 0x000014F1
-    XKc_Armenian_TSO* = 0x000014F2
-    XK_Armenian_tso* = 0x000014F3
-    XKc_Armenian_VYUN* = 0x000014F4
-    XK_Armenian_vyun* = 0x000014F5
-    XKc_Armenian_PYUR* = 0x000014F6
-    XK_Armenian_pyur* = 0x000014F7
-    XKc_Armenian_KE* = 0x000014F8
-    XK_Armenian_ke* = 0x000014F9
-    XKc_Armenian_O* = 0x000014FA
-    XK_Armenian_o* = 0x000014FB
-    XKc_Armenian_FE* = 0x000014FC
-    XK_Armenian_fe* = 0x000014FD
-    XK_Armenian_apostrophe* = 0x000014FE
-    XK_Armenian_section_sign* = 0x000014FF
-# XK_ARMENIAN 
-#*
-# *   Georgian
-# *   Byte 3 = = $15
-# *
-
-when defined(XK_GEORGIAN) or true: 
-  const
-    XK_Georgian_an* = 0x000015D0
-    XK_Georgian_ban* = 0x000015D1
-    XK_Georgian_gan* = 0x000015D2
-    XK_Georgian_don* = 0x000015D3
-    XK_Georgian_en* = 0x000015D4
-    XK_Georgian_vin* = 0x000015D5
-    XK_Georgian_zen* = 0x000015D6
-    XK_Georgian_tan* = 0x000015D7
-    XK_Georgian_in* = 0x000015D8
-    XK_Georgian_kan* = 0x000015D9
-    XK_Georgian_las* = 0x000015DA
-    XK_Georgian_man* = 0x000015DB
-    XK_Georgian_nar* = 0x000015DC
-    XK_Georgian_on* = 0x000015DD
-    XK_Georgian_par* = 0x000015DE
-    XK_Georgian_zhar* = 0x000015DF
-    XK_Georgian_rae* = 0x000015E0
-    XK_Georgian_san* = 0x000015E1
-    XK_Georgian_tar* = 0x000015E2
-    XK_Georgian_un* = 0x000015E3
-    XK_Georgian_phar* = 0x000015E4
-    XK_Georgian_khar* = 0x000015E5
-    XK_Georgian_ghan* = 0x000015E6
-    XK_Georgian_qar* = 0x000015E7
-    XK_Georgian_shin* = 0x000015E8
-    XK_Georgian_chin* = 0x000015E9
-    XK_Georgian_can* = 0x000015EA
-    XK_Georgian_jil* = 0x000015EB
-    XK_Georgian_cil* = 0x000015EC
-    XK_Georgian_char* = 0x000015ED
-    XK_Georgian_xan* = 0x000015EE
-    XK_Georgian_jhan* = 0x000015EF
-    XK_Georgian_hae* = 0x000015F0
-    XK_Georgian_he* = 0x000015F1
-    XK_Georgian_hie* = 0x000015F2
-    XK_Georgian_we* = 0x000015F3
-    XK_Georgian_har* = 0x000015F4
-    XK_Georgian_hoe* = 0x000015F5
-    XK_Georgian_fi* = 0x000015F6
-# XK_GEORGIAN 
-#*
-# * Azeri (and other Turkic or Caucasian languages of ex-USSR)
-# * Byte 3 = = $16
-# *
-
-when defined(XK_CAUCASUS) or true: 
-  # latin 
-  const
-    XKc_Ccedillaabovedot* = 0x000016A2
-    XKc_Xabovedot* = 0x000016A3
-    XKc_Qabovedot* = 0x000016A5
-    XKc_Ibreve* = 0x000016A6
-    XKc_IE* = 0x000016A7
-    XKc_UO* = 0x000016A8
-    XKc_Zstroke* = 0x000016A9
-    XKc_Gcaron* = 0x000016AA
-    XKc_Obarred* = 0x000016AF
-    XK_ccedillaabovedot* = 0x000016B2
-    XK_xabovedot* = 0x000016B3
-    XKc_Ocaron* = 0x000016B4
-    XK_qabovedot* = 0x000016B5
-    XK_ibreve* = 0x000016B6
-    XK_ie* = 0x000016B7
-    XK_uo* = 0x000016B8
-    XK_zstroke* = 0x000016B9
-    XK_gcaron* = 0x000016BA
-    XK_ocaron* = 0x000016BD
-    XK_obarred* = 0x000016BF
-    XKc_SCHWA* = 0x000016C6
-    XK_schwa* = 0x000016F6 # those are not really Caucasus, but I put them here for now 
-                           # For Inupiak 
-    XKc_Lbelowdot* = 0x000016D1
-    XKc_Lstrokebelowdot* = 0x000016D2
-    XK_lbelowdot* = 0x000016E1
-    XK_lstrokebelowdot* = 0x000016E2 # For Guarani 
-    XKc_Gtilde* = 0x000016D3
-    XK_gtilde* = 0x000016E3
-# XK_CAUCASUS 
-#*
-# *   Vietnamese
-# *   Byte 3 = = $1e
-# *
-
-when defined(XK_VIETNAMESE) or true:
-  const 
-    XKc_Abelowdot* = 0x00001EA0
-    XK_abelowdot* = 0x00001EA1
-    XKc_Ahook* = 0x00001EA2
-    XK_ahook* = 0x00001EA3
-    XKc_Acircumflexacute* = 0x00001EA4
-    XK_acircumflexacute* = 0x00001EA5
-    XKc_Acircumflexgrave* = 0x00001EA6
-    XK_acircumflexgrave* = 0x00001EA7
-    XKc_Acircumflexhook* = 0x00001EA8
-    XK_acircumflexhook* = 0x00001EA9
-    XKc_Acircumflextilde* = 0x00001EAA
-    XK_acircumflextilde* = 0x00001EAB
-    XKc_Acircumflexbelowdot* = 0x00001EAC
-    XK_acircumflexbelowdot* = 0x00001EAD
-    XKc_Abreveacute* = 0x00001EAE
-    XK_abreveacute* = 0x00001EAF
-    XKc_Abrevegrave* = 0x00001EB0
-    XK_abrevegrave* = 0x00001EB1
-    XKc_Abrevehook* = 0x00001EB2
-    XK_abrevehook* = 0x00001EB3
-    XKc_Abrevetilde* = 0x00001EB4
-    XK_abrevetilde* = 0x00001EB5
-    XKc_Abrevebelowdot* = 0x00001EB6
-    XK_abrevebelowdot* = 0x00001EB7
-    XKc_Ebelowdot* = 0x00001EB8
-    XK_ebelowdot* = 0x00001EB9
-    XKc_Ehook* = 0x00001EBA
-    XK_ehook* = 0x00001EBB
-    XKc_Etilde* = 0x00001EBC
-    XK_etilde* = 0x00001EBD
-    XKc_Ecircumflexacute* = 0x00001EBE
-    XK_ecircumflexacute* = 0x00001EBF
-    XKc_Ecircumflexgrave* = 0x00001EC0
-    XK_ecircumflexgrave* = 0x00001EC1
-    XKc_Ecircumflexhook* = 0x00001EC2
-    XK_ecircumflexhook* = 0x00001EC3
-    XKc_Ecircumflextilde* = 0x00001EC4
-    XK_ecircumflextilde* = 0x00001EC5
-    XKc_Ecircumflexbelowdot* = 0x00001EC6
-    XK_ecircumflexbelowdot* = 0x00001EC7
-    XKc_Ihook* = 0x00001EC8
-    XK_ihook* = 0x00001EC9
-    XKc_Ibelowdot* = 0x00001ECA
-    XK_ibelowdot* = 0x00001ECB
-    XKc_Obelowdot* = 0x00001ECC
-    XK_obelowdot* = 0x00001ECD
-    XKc_Ohook* = 0x00001ECE
-    XK_ohook* = 0x00001ECF
-    XKc_Ocircumflexacute* = 0x00001ED0
-    XK_ocircumflexacute* = 0x00001ED1
-    XKc_Ocircumflexgrave* = 0x00001ED2
-    XK_ocircumflexgrave* = 0x00001ED3
-    XKc_Ocircumflexhook* = 0x00001ED4
-    XK_ocircumflexhook* = 0x00001ED5
-    XKc_Ocircumflextilde* = 0x00001ED6
-    XK_ocircumflextilde* = 0x00001ED7
-    XKc_Ocircumflexbelowdot* = 0x00001ED8
-    XK_ocircumflexbelowdot* = 0x00001ED9
-    XKc_Ohornacute* = 0x00001EDA
-    XK_ohornacute* = 0x00001EDB
-    XKc_Ohorngrave* = 0x00001EDC
-    XK_ohorngrave* = 0x00001EDD
-    XKc_Ohornhook* = 0x00001EDE
-    XK_ohornhook* = 0x00001EDF
-    XKc_Ohorntilde* = 0x00001EE0
-    XK_ohorntilde* = 0x00001EE1
-    XKc_Ohornbelowdot* = 0x00001EE2
-    XK_ohornbelowdot* = 0x00001EE3
-    XKc_Ubelowdot* = 0x00001EE4
-    XK_ubelowdot* = 0x00001EE5
-    XKc_Uhook* = 0x00001EE6
-    XK_uhook* = 0x00001EE7
-    XKc_Uhornacute* = 0x00001EE8
-    XK_uhornacute* = 0x00001EE9
-    XKc_Uhorngrave* = 0x00001EEA
-    XK_uhorngrave* = 0x00001EEB
-    XKc_Uhornhook* = 0x00001EEC
-    XK_uhornhook* = 0x00001EED
-    XKc_Uhorntilde* = 0x00001EEE
-    XK_uhorntilde* = 0x00001EEF
-    XKc_Uhornbelowdot* = 0x00001EF0
-    XK_uhornbelowdot* = 0x00001EF1
-    XKc_Ybelowdot* = 0x00001EF4
-    XK_ybelowdot* = 0x00001EF5
-    XKc_Yhook* = 0x00001EF6
-    XK_yhook* = 0x00001EF7
-    XKc_Ytilde* = 0x00001EF8
-    XK_ytilde* = 0x00001EF9
-    XKc_Ohorn* = 0x00001EFA     # U+01a0 
-    XK_ohorn* = 0x00001EFB      # U+01a1 
-    XKc_Uhorn* = 0x00001EFC     # U+01af 
-    XK_uhorn* = 0x00001EFD      # U+01b0 
-    XK_combining_tilde* = 0x00001E9F # U+0303 
-    XK_combining_grave* = 0x00001EF2 # U+0300 
-    XK_combining_acute* = 0x00001EF3 # U+0301 
-    XK_combining_hook* = 0x00001EFE # U+0309 
-    XK_combining_belowdot* = 0x00001EFF # U+0323 
-# XK_VIETNAMESE 
-
-when defined(XK_CURRENCY) or true: 
-  const
-    XK_EcuSign* = 0x000020A0
-    XK_ColonSign* = 0x000020A1
-    XK_CruzeiroSign* = 0x000020A2
-    XK_FFrancSign* = 0x000020A3
-    XK_LiraSign* = 0x000020A4
-    XK_MillSign* = 0x000020A5
-    XK_NairaSign* = 0x000020A6
-    XK_PesetaSign* = 0x000020A7
-    XK_RupeeSign* = 0x000020A8
-    XK_WonSign* = 0x000020A9
-    XK_NewSheqelSign* = 0x000020AA
-    XK_DongSign* = 0x000020AB
-    XK_EuroSign* = 0x000020AC
-# implementation
diff --git a/lib/wrappers/x11/x.nim b/lib/wrappers/x11/x.nim
deleted file mode 100755
index aa6e7f821..000000000
--- a/lib/wrappers/x11/x.nim
+++ /dev/null
@@ -1,399 +0,0 @@
-
-#
-#  Automatically converted by H2Pas 0.99.15 from x.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    x.h
-#
-# Pointers to basic pascal types, inserted by h2pas conversion program.
-
-const 
-  X_PROTOCOL* = 11
-  X_PROTOCOL_REVISION* = 0
-
-type
-  culong* = int
-  cuchar* = char
-  PXID* = ptr TXID
-  TXID* = culong
-  PMask* = ptr TMask
-  TMask* = culong
-  PPAtom* = ptr PAtom
-  PAtom* = ptr TAtom
-  TAtom* = culong
-  PVisualID* = ptr TVisualID
-  TVisualID* = culong
-  PTime* = ptr TTime
-  TTime* = culong
-  PPWindow* = ptr PWindow
-  PWindow* = ptr TWindow
-  TWindow* = TXID
-  PDrawable* = ptr TDrawable
-  TDrawable* = TXID
-  PFont* = ptr TFont
-  TFont* = TXID
-  PPixmap* = ptr TPixmap
-  TPixmap* = TXID
-  PCursor* = ptr TCursor
-  TCursor* = TXID
-  PColormap* = ptr TColormap
-  TColormap* = TXID
-  PGContext* = ptr TGContext
-  TGContext* = TXID
-  PKeySym* = ptr TKeySym
-  TKeySym* = TXID
-  PKeyCode* = ptr TKeyCode
-  TKeyCode* = cuchar
-
-const 
-  None* = 0
-  ParentRelative* = 1
-  CopyFromParent* = 0
-  PointerWindow* = 0
-  InputFocus* = 1
-  PointerRoot* = 1
-  AnyPropertyType* = 0
-  AnyKey* = 0
-  AnyButton* = 0
-  AllTemporary* = 0
-  CurrentTime* = 0
-  NoSymbol* = 0
-  NoEventMask* = 0
-  KeyPressMask* = 1 shl 0
-  KeyReleaseMask* = 1 shl 1
-  ButtonPressMask* = 1 shl 2
-  ButtonReleaseMask* = 1 shl 3
-  EnterWindowMask* = 1 shl 4
-  LeaveWindowMask* = 1 shl 5
-  PointerMotionMask* = 1 shl 6
-  PointerMotionHintMask* = 1 shl 7
-  Button1MotionMask* = 1 shl 8
-  Button2MotionMask* = 1 shl 9
-  Button3MotionMask* = 1 shl 10
-  Button4MotionMask* = 1 shl 11
-  Button5MotionMask* = 1 shl 12
-  ButtonMotionMask* = 1 shl 13
-  KeymapStateMask* = 1 shl 14
-  ExposureMask* = 1 shl 15
-  VisibilityChangeMask* = 1 shl 16
-  StructureNotifyMask* = 1 shl 17
-  ResizeRedirectMask* = 1 shl 18
-  SubstructureNotifyMask* = 1 shl 19
-  SubstructureRedirectMask* = 1 shl 20
-  FocusChangeMask* = 1 shl 21
-  PropertyChangeMask* = 1 shl 22
-  ColormapChangeMask* = 1 shl 23
-  OwnerGrabButtonMask* = 1 shl 24
-  KeyPress* = 2
-  KeyRelease* = 3
-  ButtonPress* = 4
-  ButtonRelease* = 5
-  MotionNotify* = 6
-  EnterNotify* = 7
-  LeaveNotify* = 8
-  FocusIn* = 9
-  FocusOut* = 10
-  KeymapNotify* = 11
-  Expose* = 12
-  GraphicsExpose* = 13
-  NoExpose* = 14
-  VisibilityNotify* = 15
-  CreateNotify* = 16
-  DestroyNotify* = 17
-  UnmapNotify* = 18
-  MapNotify* = 19
-  MapRequest* = 20
-  ReparentNotify* = 21
-  ConfigureNotify* = 22
-  ConfigureRequest* = 23
-  GravityNotify* = 24
-  ResizeRequest* = 25
-  CirculateNotify* = 26
-  CirculateRequest* = 27
-  PropertyNotify* = 28
-  SelectionClear* = 29
-  SelectionRequest* = 30
-  SelectionNotify* = 31
-  ColormapNotify* = 32
-  ClientMessage* = 33
-  MappingNotify* = 34
-  LASTEvent* = 35
-  ShiftMask* = 1 shl 0
-  LockMask* = 1 shl 1
-  ControlMask* = 1 shl 2
-  Mod1Mask* = 1 shl 3
-  Mod2Mask* = 1 shl 4
-  Mod3Mask* = 1 shl 5
-  Mod4Mask* = 1 shl 6
-  Mod5Mask* = 1 shl 7
-  ShiftMapIndex* = 0
-  LockMapIndex* = 1
-  ControlMapIndex* = 2
-  Mod1MapIndex* = 3
-  Mod2MapIndex* = 4
-  Mod3MapIndex* = 5
-  Mod4MapIndex* = 6
-  Mod5MapIndex* = 7
-  Button1Mask* = 1 shl 8
-  Button2Mask* = 1 shl 9
-  Button3Mask* = 1 shl 10
-  Button4Mask* = 1 shl 11
-  Button5Mask* = 1 shl 12
-  AnyModifier* = 1 shl 15
-  Button1* = 1
-  Button2* = 2
-  Button3* = 3
-  Button4* = 4
-  Button5* = 5
-  NotifyNormal* = 0
-  NotifyGrab* = 1
-  NotifyUngrab* = 2
-  NotifyWhileGrabbed* = 3
-  NotifyHint* = 1
-  NotifyAncestor* = 0
-  NotifyVirtual* = 1
-  NotifyInferior* = 2
-  NotifyNonlinear* = 3
-  NotifyNonlinearVirtual* = 4
-  NotifyPointer* = 5
-  NotifyPointerRoot* = 6
-  NotifyDetailNone* = 7
-  VisibilityUnobscured* = 0
-  VisibilityPartiallyObscured* = 1
-  VisibilityFullyObscured* = 2
-  PlaceOnTop* = 0
-  PlaceOnBottom* = 1
-  FamilyInternet* = 0
-  FamilyDECnet* = 1
-  FamilyChaos* = 2
-  FamilyInternet6* = 6
-  FamilyServerInterpreted* = 5
-  PropertyNewValue* = 0
-  PropertyDelete* = 1
-  ColormapUninstalled* = 0
-  ColormapInstalled* = 1
-  GrabModeSync* = 0
-  GrabModeAsync* = 1
-  GrabSuccess* = 0
-  AlreadyGrabbed* = 1
-  GrabInvalidTime* = 2
-  GrabNotViewable* = 3
-  GrabFrozen* = 4
-  AsyncPointer* = 0
-  SyncPointer* = 1
-  ReplayPointer* = 2
-  AsyncKeyboard* = 3
-  SyncKeyboard* = 4
-  ReplayKeyboard* = 5
-  AsyncBoth* = 6
-  SyncBoth* = 7
-  RevertToNone* = None
-  RevertToPointerRoot* = PointerRoot
-  RevertToParent* = 2
-  Success* = 0
-  BadRequest* = 1
-  BadValue* = 2
-  BadWindow* = 3
-  BadPixmap* = 4
-  BadAtom* = 5
-  BadCursor* = 6
-  BadFont* = 7
-  BadMatch* = 8
-  BadDrawable* = 9
-  BadAccess* = 10
-  BadAlloc* = 11
-  BadColor* = 12
-  BadGC* = 13
-  BadIDChoice* = 14
-  BadName* = 15
-  BadLength* = 16
-  BadImplementation* = 17
-  FirstExtensionError* = 128
-  LastExtensionError* = 255
-  InputOutput* = 1
-  InputOnly* = 2
-  CWBackPixmap* = 1 shl 0
-  CWBackPixel* = 1 shl 1
-  CWBorderPixmap* = 1 shl 2
-  CWBorderPixel* = 1 shl 3
-  CWBitGravity* = 1 shl 4
-  CWWinGravity* = 1 shl 5
-  CWBackingStore* = 1 shl 6
-  CWBackingPlanes* = 1 shl 7
-  CWBackingPixel* = 1 shl 8
-  CWOverrideRedirect* = 1 shl 9
-  CWSaveUnder* = 1 shl 10
-  CWEventMask* = 1 shl 11
-  CWDontPropagate* = 1 shl 12
-  CWColormap* = 1 shl 13
-  CWCursor* = 1 shl 14
-  CWX* = 1 shl 0
-  CWY* = 1 shl 1
-  CWWidth* = 1 shl 2
-  CWHeight* = 1 shl 3
-  CWBorderWidth* = 1 shl 4
-  CWSibling* = 1 shl 5
-  CWStackMode* = 1 shl 6
-  ForgetGravity* = 0
-  NorthWestGravity* = 1
-  NorthGravity* = 2
-  NorthEastGravity* = 3
-  WestGravity* = 4
-  CenterGravity* = 5
-  EastGravity* = 6
-  SouthWestGravity* = 7
-  SouthGravity* = 8
-  SouthEastGravity* = 9
-  StaticGravity* = 10
-  UnmapGravity* = 0
-  NotUseful* = 0
-  WhenMapped* = 1
-  Always* = 2
-  IsUnmapped* = 0
-  IsUnviewable* = 1
-  IsViewable* = 2
-  SetModeInsert* = 0
-  SetModeDelete* = 1
-  DestroyAll* = 0
-  RetainPermanent* = 1
-  RetainTemporary* = 2
-  Above* = 0
-  Below* = 1
-  TopIf* = 2
-  BottomIf* = 3
-  Opposite* = 4
-  RaiseLowest* = 0
-  LowerHighest* = 1
-  PropModeReplace* = 0
-  PropModePrepend* = 1
-  PropModeAppend* = 2
-  GXclear* = 0x00000000
-  GXand* = 0x00000001
-  GXandReverse* = 0x00000002
-  GXcopy* = 0x00000003
-  GXandInverted* = 0x00000004
-  GXnoop* = 0x00000005
-  GXxor* = 0x00000006
-  GXor* = 0x00000007
-  GXnor* = 0x00000008
-  GXequiv* = 0x00000009
-  GXinvert* = 0x0000000A
-  GXorReverse* = 0x0000000B
-  GXcopyInverted* = 0x0000000C
-  GXorInverted* = 0x0000000D
-  GXnand* = 0x0000000E
-  GXset* = 0x0000000F
-  LineSolid* = 0
-  LineOnOffDash* = 1
-  LineDoubleDash* = 2
-  CapNotLast* = 0
-  CapButt* = 1
-  CapRound* = 2
-  CapProjecting* = 3
-  JoinMiter* = 0
-  JoinRound* = 1
-  JoinBevel* = 2
-  FillSolid* = 0
-  FillTiled* = 1
-  FillStippled* = 2
-  FillOpaqueStippled* = 3
-  EvenOddRule* = 0
-  WindingRule* = 1
-  ClipByChildren* = 0
-  IncludeInferiors* = 1
-  Unsorted* = 0
-  YSorted* = 1
-  YXSorted* = 2
-  YXBanded* = 3
-  CoordModeOrigin* = 0
-  CoordModePrevious* = 1
-  Complex* = 0
-  Nonconvex* = 1
-  Convex* = 2
-  ArcChord* = 0
-  ArcPieSlice* = 1
-  GCFunction* = 1 shl 0
-  GCPlaneMask* = 1 shl 1
-  GCForeground* = 1 shl 2
-  GCBackground* = 1 shl 3
-  GCLineWidth* = 1 shl 4
-  GCLineStyle* = 1 shl 5
-  GCCapStyle* = 1 shl 6
-  GCJoinStyle* = 1 shl 7
-  GCFillStyle* = 1 shl 8
-  GCFillRule* = 1 shl 9
-  GCTile* = 1 shl 10
-  GCStipple* = 1 shl 11
-  GCTileStipXOrigin* = 1 shl 12
-  GCTileStipYOrigin* = 1 shl 13
-  GCFont* = 1 shl 14
-  GCSubwindowMode* = 1 shl 15
-  GCGraphicsExposures* = 1 shl 16
-  GCClipXOrigin* = 1 shl 17
-  GCClipYOrigin* = 1 shl 18
-  GCClipMask* = 1 shl 19
-  GCDashOffset* = 1 shl 20
-  GCDashList* = 1 shl 21
-  GCArcMode* = 1 shl 22
-  GCLastBit* = 22
-  FontLeftToRight* = 0
-  FontRightToLeft* = 1
-  FontChange* = 255
-  XYBitmap* = 0
-  XYPixmap* = 1
-  ZPixmap* = 2
-  AllocNone* = 0
-  AllocAll* = 1
-  DoRed* = 1 shl 0
-  DoGreen* = 1 shl 1
-  DoBlue* = 1 shl 2
-  CursorShape* = 0
-  TileShape* = 1
-  StippleShape* = 2
-  AutoRepeatModeOff* = 0
-  AutoRepeatModeOn* = 1
-  AutoRepeatModeDefault* = 2
-  LedModeOff* = 0
-  LedModeOn* = 1
-  KBKeyClickPercent* = 1 shl 0
-  KBBellPercent* = 1 shl 1
-  KBBellPitch* = 1 shl 2
-  KBBellDuration* = 1 shl 3
-  KBLed* = 1 shl 4
-  KBLedMode* = 1 shl 5
-  KBKey* = 1 shl 6
-  KBAutoRepeatMode* = 1 shl 7
-  MappingSuccess* = 0
-  MappingBusy* = 1
-  MappingFailed* = 2
-  MappingModifier* = 0
-  MappingKeyboard* = 1
-  MappingPointer* = 2
-  DontPreferBlanking* = 0
-  PreferBlanking* = 1
-  DefaultBlanking* = 2
-  DisableScreenSaver* = 0
-  DisableScreenInterval* = 0
-  DontAllowExposures* = 0
-  AllowExposures* = 1
-  DefaultExposures* = 2
-  ScreenSaverReset* = 0
-  ScreenSaverActive* = 1
-  HostInsert* = 0
-  HostDelete* = 1
-  EnableAccess* = 1
-  DisableAccess* = 0
-  StaticGray* = 0
-  GrayScale* = 1
-  StaticColor* = 2
-  PseudoColor* = 3
-  TrueColor* = 4
-  DirectColor* = 5
-  LSBFirst* = 0
-  MSBFirst* = 1
-
-# implementation
diff --git a/lib/wrappers/x11/xatom.nim b/lib/wrappers/x11/xatom.nim
deleted file mode 100755
index b2e1dca91..000000000
--- a/lib/wrappers/x11/xatom.nim
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# THIS IS A GENERATED FILE
-#
-# Do not change!  Changing this file implies a protocol change!
-#
-
-import  
-  X
-
-const 
-  XA_PRIMARY* = TAtom(1)
-  XA_SECONDARY* = TAtom(2)
-  XA_ARC* = TAtom(3)
-  XA_ATOM* = TAtom(4)
-  XA_BITMAP* = TAtom(5)
-  XA_CARDINAL* = TAtom(6)
-  XA_COLORMAP* = TAtom(7)
-  XA_CURSOR* = TAtom(8)
-  XA_CUT_BUFFER0* = TAtom(9)
-  XA_CUT_BUFFER1* = TAtom(10)
-  XA_CUT_BUFFER2* = TAtom(11)
-  XA_CUT_BUFFER3* = TAtom(12)
-  XA_CUT_BUFFER4* = TAtom(13)
-  XA_CUT_BUFFER5* = TAtom(14)
-  XA_CUT_BUFFER6* = TAtom(15)
-  XA_CUT_BUFFER7* = TAtom(16)
-  XA_DRAWABLE* = TAtom(17)
-  XA_FONT* = TAtom(18)
-  XA_INTEGER* = TAtom(19)
-  XA_PIXMAP* = TAtom(20)
-  XA_POINT* = TAtom(21)
-  XA_RECTANGLE* = TAtom(22)
-  XA_RESOURCE_MANAGER* = TAtom(23)
-  XA_RGB_COLOR_MAP* = TAtom(24)
-  XA_RGB_BEST_MAP* = TAtom(25)
-  XA_RGB_BLUE_MAP* = TAtom(26)
-  XA_RGB_DEFAULT_MAP* = TAtom(27)
-  XA_RGB_GRAY_MAP* = TAtom(28)
-  XA_RGB_GREEN_MAP* = TAtom(29)
-  XA_RGB_RED_MAP* = TAtom(30)
-  XA_STRING* = TAtom(31)
-  XA_VISUALID* = TAtom(32)
-  XA_WINDOW* = TAtom(33)
-  XA_WM_COMMAND* = TAtom(34)
-  XA_WM_HINTS* = TAtom(35)
-  XA_WM_CLIENT_MACHINE* = TAtom(36)
-  XA_WM_ICON_NAME* = TAtom(37)
-  XA_WM_ICON_SIZE* = TAtom(38)
-  XA_WM_NAME* = TAtom(39)
-  XA_WM_NORMAL_HINTS* = TAtom(40)
-  XA_WM_SIZE_HINTS* = TAtom(41)
-  XA_WM_ZOOM_HINTS* = TAtom(42)
-  XA_MIN_SPACE* = TAtom(43)
-  XA_NORM_SPACE* = TAtom(44)
-  XA_MAX_SPACE* = TAtom(45)
-  XA_END_SPACE* = TAtom(46)
-  XA_SUPERSCRIPT_X* = TAtom(47)
-  XA_SUPERSCRIPT_Y* = TAtom(48)
-  XA_SUBSCRIPT_X* = TAtom(49)
-  XA_SUBSCRIPT_Y* = TAtom(50)
-  XA_UNDERLINE_POSITION* = TAtom(51)
-  XA_UNDERLINE_THICKNESS* = TAtom(52)
-  XA_STRIKEOUT_ASCENT* = TAtom(53)
-  XA_STRIKEOUT_DESCENT* = TAtom(54)
-  XA_ITALIC_ANGLE* = TAtom(55)
-  XA_X_HEIGHT* = TAtom(56)
-  XA_QUAD_WIDTH* = TAtom(57)
-  XA_WEIGHT* = TAtom(58)
-  XA_POINT_SIZE* = TAtom(59)
-  XA_RESOLUTION* = TAtom(60)
-  XA_COPYRIGHT* = TAtom(61)
-  XA_NOTICE* = TAtom(62)
-  XA_FONT_NAME* = TAtom(63)
-  XA_FAMILY_NAME* = TAtom(64)
-  XA_FULL_NAME* = TAtom(65)
-  XA_CAP_HEIGHT* = TAtom(66)
-  XA_WM_CLASS* = TAtom(67)
-  XA_WM_TRANSIENT_FOR* = TAtom(68)
-  XA_LAST_PREDEFINED* = TAtom(68)
-
-# implementation
diff --git a/lib/wrappers/x11/xcms.nim b/lib/wrappers/x11/xcms.nim
deleted file mode 100755
index 57aad6ae0..000000000
--- a/lib/wrappers/x11/xcms.nim
+++ /dev/null
@@ -1,396 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "X11" 
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xcms.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xcms.h
-#
-
-const 
-  XcmsFailure* = 0
-  XcmsSuccess* = 1
-  XcmsSuccessWithCompression* = 2
-
-type 
-  PXcmsColorFormat* = ptr TXcmsColorFormat
-  TXcmsColorFormat* = int32
-
-proc XcmsUndefinedFormat*(): TXcmsColorFormat
-proc XcmsCIEXYZFormat*(): TXcmsColorFormat
-proc XcmsCIEuvYFormat*(): TXcmsColorFormat
-proc XcmsCIExyYFormat*(): TXcmsColorFormat
-proc XcmsCIELabFormat*(): TXcmsColorFormat
-proc XcmsCIELuvFormat*(): TXcmsColorFormat
-proc XcmsTekHVCFormat*(): TXcmsColorFormat
-proc XcmsRGBFormat*(): TXcmsColorFormat
-proc XcmsRGBiFormat*(): TXcmsColorFormat
-const 
-  XcmsInitNone* = 0x00000000
-  XcmsInitSuccess* = 0x00000001
-  XcmsInitFailure* = 0x000000FF
-
-when defined(MACROS): 
-  proc DisplayOfCCC*(ccc: int32): int32
-  proc ScreenNumberOfCCC*(ccc: int32): int32
-  proc VisualOfCCC*(ccc: int32): int32
-  proc ClientWhitePointOfCCC*(ccc: int32): int32
-  proc ScreenWhitePointOfCCC*(ccc: int32): int32
-  proc FunctionSetOfCCC*(ccc: int32): int32
-type 
-  PXcmsFloat* = ptr TXcmsFloat
-  TXcmsFloat* = float64
-  PXcmsRGB* = ptr TXcmsRGB
-  TXcmsRGB*{.final.} = object 
-    red*: int16
-    green*: int16
-    blue*: int16
-
-  PXcmsRGBi* = ptr TXcmsRGBi
-  TXcmsRGBi*{.final.} = object 
-    red*: TXcmsFloat
-    green*: TXcmsFloat
-    blue*: TXcmsFloat
-
-  PXcmsCIEXYZ* = ptr TXcmsCIEXYZ
-  TXcmsCIEXYZ*{.final.} = object 
-    X*: TXcmsFloat
-    Y*: TXcmsFloat
-    Z*: TXcmsFloat
-
-  PXcmsCIEuvY* = ptr TXcmsCIEuvY
-  TXcmsCIEuvY*{.final.} = object 
-    u_prime*: TXcmsFloat
-    v_prime*: TXcmsFloat
-    Y*: TXcmsFloat
-
-  PXcmsCIExyY* = ptr TXcmsCIExyY
-  TXcmsCIExyY*{.final.} = object 
-    x*: TXcmsFloat
-    y*: TXcmsFloat
-    theY*: TXcmsFloat
-
-  PXcmsCIELab* = ptr TXcmsCIELab
-  TXcmsCIELab*{.final.} = object 
-    L_star*: TXcmsFloat
-    a_star*: TXcmsFloat
-    b_star*: TXcmsFloat
-
-  PXcmsCIELuv* = ptr TXcmsCIELuv
-  TXcmsCIELuv*{.final.} = object 
-    L_star*: TXcmsFloat
-    u_star*: TXcmsFloat
-    v_star*: TXcmsFloat
-
-  PXcmsTekHVC* = ptr TXcmsTekHVC
-  TXcmsTekHVC*{.final.} = object 
-    H*: TXcmsFloat
-    V*: TXcmsFloat
-    C*: TXcmsFloat
-
-  PXcmsPad* = ptr TXcmsPad
-  TXcmsPad*{.final.} = object 
-    pad0*: TXcmsFloat
-    pad1*: TXcmsFloat
-    pad2*: TXcmsFloat
-    pad3*: TXcmsFloat
-
-  PXcmsColor* = ptr TXcmsColor
-  TXcmsColor*{.final.} = object  # spec : record
-                                 #            case longint of
-                                 #               0 : ( RGB : TXcmsRGB );
-                                 #               1 : ( RGBi : TXcmsRGBi );
-                                 #               2 : ( CIEXYZ : TXcmsCIEXYZ );
-                                 #               3 : ( CIEuvY : TXcmsCIEuvY );
-                                 #               4 : ( CIExyY : TXcmsCIExyY );
-                                 #               5 : ( CIELab : TXcmsCIELab );
-                                 #               6 : ( CIELuv : TXcmsCIELuv );
-                                 #               7 : ( TekHVC : TXcmsTekHVC );
-                                 #               8 : ( Pad : TXcmsPad ); 
-                                 #            end; 
-    pad*: TXcmsPad
-    pixel*: int32
-    format*: TXcmsColorFormat
-
-  PXcmsPerScrnInfo* = ptr TXcmsPerScrnInfo
-  TXcmsPerScrnInfo*{.final.} = object 
-    screenWhitePt*: TXcmsColor
-    functionSet*: TXPointer
-    screenData*: TXPointer
-    state*: int8
-    pad*: array[0..2, char]
-
-  PXcmsCCC* = ptr TXcmsCCC
-  TXcmsCompressionProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, 
-                                para3: int32, para4: int32, para5: PBool): TStatus{.
-      cdecl.}
-  TXcmsWhiteAdjustProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, 
-                                para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-      cdecl.}
-  TXcmsCCC*{.final.} = object 
-    dpy*: PDisplay
-    screenNumber*: int32
-    visual*: PVisual
-    clientWhitePt*: TXcmsColor
-    gamutCompProc*: TXcmsCompressionProc
-    gamutCompClientData*: TXPointer
-    whitePtAdjProc*: TXcmsWhiteAdjustProc
-    whitePtAdjClientData*: TXPointer
-    pPerScrnInfo*: PXcmsPerScrnInfo
-
-  TXcmsCCCRec* = TXcmsCCC
-  PXcmsCCCRec* = ptr TXcmsCCCRec
-  TXcmsScreenInitProc* = proc (para1: PDisplay, para2: int32, 
-                               para3: PXcmsPerScrnInfo): TStatus{.cdecl.}
-  TXcmsScreenFreeProc* = proc (para1: TXPointer){.cdecl.}
-  TXcmsConversionProc* = proc (){.cdecl.}
-  PXcmsFuncListPtr* = ptr TXcmsFuncListPtr
-  TXcmsFuncListPtr* = TXcmsConversionProc
-  TXcmsParseStringProc* = proc (para1: cstring, para2: PXcmsColor): int32{.cdecl.}
-  PXcmsColorSpace* = ptr TXcmsColorSpace
-  TXcmsColorSpace*{.final.} = object 
-    prefix*: cstring
-    id*: TXcmsColorFormat
-    parseString*: TXcmsParseStringProc
-    to_CIEXYZ*: TXcmsFuncListPtr
-    from_CIEXYZ*: TXcmsFuncListPtr
-    inverse_flag*: int32
-
-  PXcmsFunctionSet* = ptr TXcmsFunctionSet
-  TXcmsFunctionSet*{.final.} = object  # error
-                                       #extern Status XcmsAddColorSpace (
-                                       #in declaration at line 323 
-    DDColorSpaces*: ptr PXcmsColorSpace
-    screenInitProc*: TXcmsScreenInitProc
-    screenFreeProc*: TXcmsScreenFreeProc
-
-
-proc XcmsAddFunctionSet*(para1: PXcmsFunctionSet): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsAllocColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                     para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                          para4: PXcmsColor, para5: PXcmsColor, 
-                          para6: TXcmsColorFormat): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCCCOfColormap*(para1: PDisplay, para2: TColormap): TXcmsCCC{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabClipLab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELabQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELabQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELabToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIELabWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvClipLuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvClipuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCIELuvQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsCIELuvToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIELuvWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIELab*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToCIExyY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEXYZToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToCIELuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIEuvYToTekHVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsCIExyYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsClientWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsConvertColors*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                        para4: TXcmsColorFormat, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsCreateCCC*(para1: PDisplay, para2: int32, para3: PVisual, 
-                    para4: PXcmsColor, para5: TXcmsCompressionProc, 
-                    para6: TXPointer, para7: TXcmsWhiteAdjustProc, 
-                    para8: TXPointer): TXcmsCCC{.cdecl, dynlib: libX11, importc.}
-proc XcmsDefaultCCC*(para1: PDisplay, para2: int32): TXcmsCCC{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsDisplayOfCCC*(para1: TXcmsCCC): PDisplay{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsFormatOfPrefix*(para1: cstring): TXcmsColorFormat{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsFreeCCC*(para1: TXcmsCCC){.cdecl, dynlib: libX11, importc.}
-proc XcmsLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                      para4: PXcmsColor, para5: PXcmsColor, 
-                      para6: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsPrefixOfFormat*(para1: TXcmsColorFormat): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsQueryBlack*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryBlue*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                     para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsQueryColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                      para4: int32, para5: TXcmsColorFormat): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsQueryGreen*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryRed*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsQueryWhite*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsRGBiToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsRGBiToRGB*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                    para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsRGBToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                    para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsScreenNumberOfCCC*(para1: TXcmsCCC): int32{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsScreenWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetCCCOfColormap*(para1: PDisplay, para2: TColormap, para3: TXcmsCCC): TXcmsCCC{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsSetCompressionProc*(para1: TXcmsCCC, para2: TXcmsCompressionProc, 
-                             para3: TXPointer): TXcmsCompressionProc{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetWhiteAdjustProc*(para1: TXcmsCCC, para2: TXcmsWhiteAdjustProc, 
-                             para3: TXPointer): TXcmsWhiteAdjustProc{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsSetWhitePoint*(para1: TXcmsCCC, para2: PXcmsColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsStoreColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsStoreColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipV*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                      para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCClipVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, 
-                       para4: int32, para5: PBool): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCQueryMaxV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCQueryMaxVC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMaxVSamples*(para1: TXcmsCCC, para2: TXcmsFloat, 
-                                 para3: PXcmsColor, para4: int32): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCQueryMinV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, 
-                          para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XcmsTekHVCToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, 
-                         para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XcmsTekHVCWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, 
-                                 para3: PXcmsColor, para4: TXcmsColorFormat, 
-                                 para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XcmsVisualOfCCC*(para1: TXcmsCCC): PVisual{.cdecl, dynlib: libX11, importc.}
-# implementation
-
-proc XcmsUndefinedFormat(): TXcmsColorFormat = 
-  result = 0x00000000'i32
-
-proc XcmsCIEXYZFormat(): TXcmsColorFormat = 
-  result = 0x00000001'i32
-
-proc XcmsCIEuvYFormat(): TXcmsColorFormat = 
-  result = 0x00000002'i32
-
-proc XcmsCIExyYFormat(): TXcmsColorFormat = 
-  result = 0x00000003'i32
-
-proc XcmsCIELabFormat(): TXcmsColorFormat = 
-  result = 0x00000004'i32
-
-proc XcmsCIELuvFormat(): TXcmsColorFormat = 
-  result = 0x00000005'i32
-
-proc XcmsTekHVCFormat(): TXcmsColorFormat = 
-  result = 0x00000006'i32
-
-proc XcmsRGBFormat(): TXcmsColorFormat = 
-  result = 0x80000000'i32
-
-proc XcmsRGBiFormat(): TXcmsColorFormat = 
-  result = 0x80000001'i32
-
-when defined(MACROS): 
-  proc DisplayOfCCC(ccc: int32): int32 = 
-    result = ccc.dpy
-
-  proc ScreenNumberOfCCC(ccc: int32): int32 = 
-    result = ccc.screenNumber
-
-  proc VisualOfCCC(ccc: int32): int32 = 
-    result = ccc.visual
-
-  proc ClientWhitePointOfCCC(ccc: int32): int32 = 
-    result = addr(ccc.clientWhitePt)
-
-  proc ScreenWhitePointOfCCC(ccc: int32): int32 = 
-    result = addr(ccc.pPerScrnInfo.screenWhitePt)
-
-  proc FunctionSetOfCCC(ccc: int32): int32 = 
-    result = ccc.pPerScrnInfo.functionSet
diff --git a/lib/wrappers/x11/xf86dga.nim b/lib/wrappers/x11/xf86dga.nim
deleted file mode 100755
index 376f11861..000000000
--- a/lib/wrappers/x11/xf86dga.nim
+++ /dev/null
@@ -1,235 +0,0 @@
-#
-#   Copyright (c) 1999  XFree86 Inc
-#
-# $XFree86: xc/include/extensions/xf86dga.h,v 3.20 1999/10/13 04:20:48 dawes Exp $ 
-
-import 
-  x, xlib
-
-const 
-  libXxf86dga* = "libXxf86dga.so"
-
-#type 
-#  cfloat* = float32
-
-# $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $ 
-#
-#
-#Copyright (c) 1995  Jon Tombs
-#Copyright (c) 1995  XFree86 Inc
-#
-#
-#************************************************************************
-#
-#   THIS IS THE OLD DGA API AND IS OBSOLETE.  PLEASE DO NOT USE IT ANYMORE
-#
-#************************************************************************
-
-type 
-  PPcchar* = ptr ptr cstring
-
-const 
-  X_XF86DGAQueryVersion* = 0
-  X_XF86DGAGetVideoLL* = 1
-  X_XF86DGADirectVideo* = 2
-  X_XF86DGAGetViewPortSize* = 3
-  X_XF86DGASetViewPort* = 4
-  X_XF86DGAGetVidPage* = 5
-  X_XF86DGASetVidPage* = 6
-  X_XF86DGAInstallColormap* = 7
-  X_XF86DGAQueryDirectVideo* = 8
-  X_XF86DGAViewPortChanged* = 9
-  XF86DGADirectPresent* = 0x00000001
-  XF86DGADirectGraphics* = 0x00000002
-  XF86DGADirectMouse* = 0x00000004
-  XF86DGADirectKeyb* = 0x00000008
-  XF86DGAHasColormap* = 0x00000100
-  XF86DGADirectColormap* = 0x00000200
-
-proc XF86DGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, 
-                          minorVersion: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XF86DGAQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVideoLL*(dpy: PDisplay, screen: cint, base_addr: Pcint, 
-                        width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVideo*(dpy: PDisplay, screen: cint, base_addr: PPcchar, 
-                      width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGADirectVideo*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGADirectVideoLL*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetViewPortSize*(dpy: PDisplay, screen: cint, width: Pcint, 
-                             height: Pcint): TStatus{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XF86DGASetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAGetVidPage*(dpy: PDisplay, screen: cint, vid_page: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGASetVidPage*(dpy: PDisplay, screen: cint, vid_page: cint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAInstallColormap*(dpy: PDisplay, screen: cint, Colormap: TColormap): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAForkApp*(screen: cint): cint{.CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAQueryDirectVideo*(dpy: PDisplay, screen: cint, flags: Pcint): TStatus{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XF86DGAViewPortChanged*(dpy: PDisplay, screen: cint, n: cint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-const 
-  X_XDGAQueryVersion* = 0     # 1 through 9 are in xf86dga1.pp 
-                              # 10 and 11 are reserved to avoid conflicts with rogue DGA extensions 
-  X_XDGAQueryModes* = 12
-  X_XDGASetMode* = 13
-  X_XDGASetViewport* = 14
-  X_XDGAInstallColormap* = 15
-  X_XDGASelectInput* = 16
-  X_XDGAFillRectangle* = 17
-  X_XDGACopyArea* = 18
-  X_XDGACopyTransparentArea* = 19
-  X_XDGAGetViewportStatus* = 20
-  X_XDGASync* = 21
-  X_XDGAOpenFramebuffer* = 22
-  X_XDGACloseFramebuffer* = 23
-  X_XDGASetClientVersion* = 24
-  X_XDGAChangePixmapMode* = 25
-  X_XDGACreateColormap* = 26
-  XDGAConcurrentAccess* = 0x00000001
-  XDGASolidFillRect* = 0x00000002
-  XDGABlitRect* = 0x00000004
-  XDGABlitTransRect* = 0x00000008
-  XDGAPixmap* = 0x00000010
-  XDGAInterlaced* = 0x00010000
-  XDGADoublescan* = 0x00020000
-  XDGAFlipImmediate* = 0x00000001
-  XDGAFlipRetrace* = 0x00000002
-  XDGANeedRoot* = 0x00000001
-  XF86DGANumberEvents* = 7
-  XDGAPixmapModeLarge* = 0
-  XDGAPixmapModeSmall* = 1
-  XF86DGAClientNotLocal* = 0
-  XF86DGANoDirectVideoMode* = 1
-  XF86DGAScreenNotActive* = 2
-  XF86DGADirectNotActivated* = 3
-  XF86DGAOperationNotSupported* = 4
-  XF86DGANumberErrors* = (XF86DGAOperationNotSupported + 1)
-
-type 
-  PXDGAMode* = ptr TXDGAMode
-  TXDGAMode*{.final.} = object 
-    num*: cint                # A unique identifier for the mode (num > 0) 
-    name*: cstring            # name of mode given in the XF86Config 
-    verticalRefresh*: cfloat
-    flags*: cint              # DGA_CONCURRENT_ACCESS, etc... 
-    imageWidth*: cint         # linear accessible portion (pixels) 
-    imageHeight*: cint
-    pixmapWidth*: cint        # Xlib accessible portion (pixels) 
-    pixmapHeight*: cint       # both fields ignored if no concurrent access 
-    bytesPerScanline*: cint
-    byteOrder*: cint          # MSBFirst, LSBFirst 
-    depth*: cint
-    bitsPerPixel*: cint
-    redMask*: culong
-    greenMask*: culong
-    blueMask*: culong
-    visualClass*: cshort
-    viewportWidth*: cint
-    viewportHeight*: cint
-    xViewportStep*: cint      # viewport position granularity 
-    yViewportStep*: cint
-    maxViewportX*: cint       # max viewport origin 
-    maxViewportY*: cint
-    viewportFlags*: cint      # types of page flipping possible 
-    reserved1*: cint
-    reserved2*: cint
-
-  PXDGADevice* = ptr TXDGADevice
-  TXDGADevice*{.final.} = object 
-    mode*: TXDGAMode
-    data*: Pcuchar
-    pixmap*: TPixmap
-
-  PXDGAButtonEvent* = ptr TXDGAButtonEvent
-  TXDGAButtonEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    button*: cuint
-
-  PXDGAKeyEvent* = ptr TXDGAKeyEvent
-  TXDGAKeyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    keycode*: cuint
-
-  PXDGAMotionEvent* = ptr TXDGAMotionEvent
-  TXDGAMotionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    display*: PDisplay
-    screen*: cint
-    time*: TTime
-    state*: cuint
-    dx*: cint
-    dy*: cint
-
-  PXDGAEvent* = ptr TXDGAEvent
-  TXDGAEvent*{.final.} = object 
-    pad*: array[0..23, clong] # sorry you have to cast if you want access
-                              #Case LongInt Of
-                              #      0 : (_type : cint);
-                              #      1 : (xbutton : TXDGAButtonEvent);
-                              #      2 : (xkey : TXDGAKeyEvent);
-                              #      3 : (xmotion : TXDGAMotionEvent);
-                              #      4 : (pad : Array[0..23] Of clong);
-  
-
-proc XDGAQueryExtension*(dpy: PDisplay, eventBase: Pcint, erroBase: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, minorVersion: Pcint): TBool{.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAQueryModes*(dpy: PDisplay, screen: cint, num: Pcint): PXDGAMode{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASetMode*(dpy: PDisplay, screen: cint, mode: cint): PXDGADevice{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAOpenFramebuffer*(dpy: PDisplay, screen: cint): TBool{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACloseFramebuffer*(dpy: PDisplay, screen: cint){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASetViewport*(dpy: PDisplay, screen: cint, x: cint, y: cint, flags: cint){.
-    CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAInstallColormap*(dpy: PDisplay, screen: cint, cmap: TColormap){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACreateColormap*(dpy: PDisplay, screen: cint, device: PXDGADevice, 
-                         alloc: cint): TColormap{.CDecl, dynlib: libXxf86dga, 
-    importc.}
-proc XDGASelectInput*(dpy: PDisplay, screen: cint, event_mask: clong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAFillRectangle*(dpy: PDisplay, screen: cint, x: cint, y: cint, 
-                        width: cuint, height: cuint, color: culong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACopyArea*(dpy: PDisplay, screen: cint, srcx: cint, srcy: cint, 
-                   width: cuint, height: cuint, dstx: cint, dsty: cint){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGACopyTransparentArea*(dpy: PDisplay, screen: cint, srcx: cint, 
-                              srcy: cint, width: cuint, height: cuint, 
-                              dstx: cint, dsty: cint, key: culong){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGAGetViewportStatus*(dpy: PDisplay, screen: cint): cint{.CDecl, 
-    dynlib: libXxf86dga, importc.}
-proc XDGASync*(dpy: PDisplay, screen: cint){.CDecl, dynlib: libXxf86dga, importc.}
-proc XDGASetClientVersion*(dpy: PDisplay): TBool{.CDecl, dynlib: libXxf86dga, 
-    importc.}
-proc XDGAChangePixmapMode*(dpy: PDisplay, screen: cint, x: Pcint, y: Pcint, 
-                           mode: cint){.CDecl, dynlib: libXxf86dga, importc.}
-proc XDGAKeyEventToXKeyEvent*(dk: PXDGAKeyEvent, xk: PXKeyEvent){.CDecl, 
-    dynlib: libXxf86dga, importc.}
-# implementation
diff --git a/lib/wrappers/x11/xf86vmode.nim b/lib/wrappers/x11/xf86vmode.nim
deleted file mode 100755
index 18a922cab..000000000
--- a/lib/wrappers/x11/xf86vmode.nim
+++ /dev/null
@@ -1,229 +0,0 @@
-# $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $ 
-#
-#
-#Copyright 1995  Kaleb S. KEITHLEY
-#
-#Permission is hereby granted, free of charge, to any person obtaining
-#a copy of this software and associated documentation files (the
-#"Software"), to deal in the Software without restriction, including
-#without limitation the rights to use, copy, modify, merge, publish,
-#distribute, sublicense, and/or sell copies of the Software, and to
-#permit persons to whom the Software is furnished to do so, subject to
-#the following conditions:
-#
-#The above copyright notice and this permission notice shall be
-#included in all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES 
-#OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-#OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of Kaleb S. KEITHLEY 
-#shall not be used in advertising or otherwise to promote the sale, use 
-#or other dealings in this Software without prior written authorization
-#from Kaleb S. KEITHLEY
-#
-#
-# $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $ 
-# THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION 
-
-import 
-  x, xlib
-
-const 
-  libXxf86vm* = "libXxf86vm.so"
-
-type 
-  PINT32* = ptr int32
-
-const 
-  X_XF86VidModeQueryVersion* = 0
-  X_XF86VidModeGetModeLine* = 1
-  X_XF86VidModeModModeLine* = 2
-  X_XF86VidModeSwitchMode* = 3
-  X_XF86VidModeGetMonitor* = 4
-  X_XF86VidModeLockModeSwitch* = 5
-  X_XF86VidModeGetAllModeLines* = 6
-  X_XF86VidModeAddModeLine* = 7
-  X_XF86VidModeDeleteModeLine* = 8
-  X_XF86VidModeValidateModeLine* = 9
-  X_XF86VidModeSwitchToMode* = 10
-  X_XF86VidModeGetViewPort* = 11
-  X_XF86VidModeSetViewPort* = 12 # new for version 2.x of this extension 
-  X_XF86VidModeGetDotClocks* = 13
-  X_XF86VidModeSetClientVersion* = 14
-  X_XF86VidModeSetGamma* = 15
-  X_XF86VidModeGetGamma* = 16
-  X_XF86VidModeGetGammaRamp* = 17
-  X_XF86VidModeSetGammaRamp* = 18
-  X_XF86VidModeGetGammaRampSize* = 19
-  X_XF86VidModeGetPermissions* = 20
-  CLKFLAG_PROGRAMABLE* = 1
-
-when defined(XF86VIDMODE_EVENTS): 
-  const 
-    XF86VidModeNotify* = 0
-    XF86VidModeNumberEvents* = (XF86VidModeNotify + 1)
-    XF86VidModeNotifyMask* = 0x00000001
-    XF86VidModeNonEvent* = 0
-    XF86VidModeModeChange* = 1
-else: 
-  const 
-    XF86VidModeNumberEvents* = 0
-const 
-  XF86VidModeBadClock* = 0
-  XF86VidModeBadHTimings* = 1
-  XF86VidModeBadVTimings* = 2
-  XF86VidModeModeUnsuitable* = 3
-  XF86VidModeExtensionDisabled* = 4
-  XF86VidModeClientNotLocal* = 5
-  XF86VidModeZoomLocked* = 6
-  XF86VidModeNumberErrors* = (XF86VidModeZoomLocked + 1)
-  XF86VM_READ_PERMISSION* = 1
-  XF86VM_WRITE_PERMISSION* = 2
-
-type 
-  PXF86VidModeModeLine* = ptr TXF86VidModeModeLine
-  TXF86VidModeModeLine*{.final.} = object 
-    hdisplay*: cushort
-    hsyncstart*: cushort
-    hsyncend*: cushort
-    htotal*: cushort
-    hskew*: cushort
-    vdisplay*: cushort
-    vsyncstart*: cushort
-    vsyncend*: cushort
-    vtotal*: cushort
-    flags*: cuint
-    privsize*: cint
-    c_private*: PINT32
-
-  PPPXF86VidModeModeInfo* = ptr PPXF86VidModeModeInfo
-  PPXF86VidModeModeInfo* = ptr PXF86VidModeModeInfo
-  PXF86VidModeModeInfo* = ptr TXF86VidModeModeInfo
-  TXF86VidModeModeInfo*{.final.} = object 
-    dotclock*: cuint
-    hdisplay*: cushort
-    hsyncstart*: cushort
-    hsyncend*: cushort
-    htotal*: cushort
-    hskew*: cushort
-    vdisplay*: cushort
-    vsyncstart*: cushort
-    vsyncend*: cushort
-    vtotal*: cushort
-    flags*: cuint
-    privsize*: cint
-    c_private*: PINT32
-
-  PXF86VidModeSyncRange* = ptr TXF86VidModeSyncRange
-  TXF86VidModeSyncRange*{.final.} = object 
-    hi*: cfloat
-    lo*: cfloat
-
-  PXF86VidModeMonitor* = ptr TXF86VidModeMonitor
-  TXF86VidModeMonitor*{.final.} = object 
-    vendor*: cstring
-    model*: cstring
-    EMPTY*: cfloat
-    nhsync*: cuchar
-    hsync*: PXF86VidModeSyncRange
-    nvsync*: cuchar
-    vsync*: PXF86VidModeSyncRange
-
-  PXF86VidModeNotifyEvent* = ptr TXF86VidModeNotifyEvent
-  TXF86VidModeNotifyEvent*{.final.} = object 
-    theType*: cint            # of event 
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent req 
-    display*: PDisplay        # Display the event was read from 
-    root*: TWindow            # root window of event screen 
-    state*: cint              # What happened 
-    kind*: cint               # What happened 
-    forced*: TBool            # extents of new region 
-    time*: TTime              # event timestamp 
-  
-  PXF86VidModeGamma* = ptr TXF86VidModeGamma
-  TXF86VidModeGamma*{.final.} = object 
-    red*: cfloat              # Red Gamma value 
-    green*: cfloat            # Green Gamma value 
-    blue*: cfloat             # Blue Gamma value 
-  
-
-when defined(MACROS): 
-  proc XF86VidModeSelectNextMode*(disp: PDisplay, scr: cint): TBool
-  proc XF86VidModeSelectPrevMode*(disp: PDisplay, scr: cint): TBool
-proc XF86VidModeQueryVersion*(dpy: PDisplay, majorVersion: Pcint, 
-                              minorVersion: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeQueryExtension*(dpy: PDisplay, event_base: Pcint, 
-                                error_base: Pcint): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetClientVersion*(dpy: PDisplay): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetModeLine*(dpy: PDisplay, screen: cint, dotclock: Pcint, 
-                             modeline: PXF86VidModeModeLine): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetAllModeLines*(dpy: PDisplay, screen: cint, modecount: Pcint, 
-                                 modelinesPtr: PPPXF86VidModeModeInfo): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeAddModeLine*(dpy: PDisplay, screen: cint, 
-                             new_modeline: PXF86VidModeModeInfo, 
-                             after_modeline: PXF86VidModeModeInfo): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeDeleteModeLine*(dpy: PDisplay, screen: cint, 
-                                modeline: PXF86VidModeModeInfo): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeModModeLine*(dpy: PDisplay, screen: cint, 
-                             modeline: PXF86VidModeModeLine): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeValidateModeLine*(dpy: PDisplay, screen: cint, 
-                                  modeline: PXF86VidModeModeInfo): TStatus{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSwitchMode*(dpy: PDisplay, screen: cint, zoom: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSwitchToMode*(dpy: PDisplay, screen: cint, 
-                              modeline: PXF86VidModeModeInfo): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeLockModeSwitch*(dpy: PDisplay, screen: cint, lock: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetMonitor*(dpy: PDisplay, screen: cint, 
-                            monitor: PXF86VidModeMonitor): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetViewPort*(dpy: PDisplay, screen: cint, x_return: Pcint, 
-                             y_return: Pcint): TBool{.CDecl, dynlib: libXxf86vm, 
-    importc.}
-proc XF86VidModeSetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetDotClocks*(dpy: PDisplay, screen: cint, flags_return: Pcint, 
-                              number_of_clocks_return: Pcint, 
-                              max_dot_clock_return: Pcint, clocks_return: PPcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeSetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, 
-                              red_array: Pcushort, green_array: Pcushort, 
-                              blue_array: Pcushort): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, 
-                              red_array: Pcushort, green_array: Pcushort, 
-                              blue_array: Pcushort): TBool{.CDecl, 
-    dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetGammaRampSize*(dpy: PDisplay, screen: cint, size: Pcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-proc XF86VidModeGetPermissions*(dpy: PDisplay, screen: cint, permissions: Pcint): TBool{.
-    CDecl, dynlib: libXxf86vm, importc.}
-# implementation
-
-when defined(MACROS): 
-  proc XF86VidModeSelectNextMode(disp: PDisplay, scr: cint): TBool = 
-    XF86VidModeSelectNextMode = XF86VidModeSwitchMode(disp, scr, 1)
-
-  proc XF86VidModeSelectPrevMode(disp: PDisplay, scr: cint): TBool = 
-    XF86VidModeSelectPrevMode = XF86VidModeSwitchMode(disp, scr, - 1)
diff --git a/lib/wrappers/x11/xi.nim b/lib/wrappers/x11/xi.nim
deleted file mode 100755
index d1b9f7846..000000000
--- a/lib/wrappers/x11/xi.nim
+++ /dev/null
@@ -1,307 +0,0 @@
-#
-# $Xorg: XI.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $
-#
-#************************************************************
-#
-#Copyright 1989, 1998  The Open Group
-#
-#Permission to use, copy, modify, distribute, and sell this software and its
-#documentation for any purpose is hereby granted without fee, provided that
-#the above copyright notice appear in all copies and that both that
-#copyright notice and this permission notice appear in supporting
-#documentation.
-#
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-#
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-#OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-#AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-#Except as contained in this notice, the name of The Open Group shall not be
-#used in advertising or otherwise to promote the sale, use or other dealings
-#in this Software without prior written authorization from The Open Group.
-#
-#Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its
-#documentation for any purpose and without fee is hereby granted,
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in
-#supporting documentation, and that the name of Hewlett-Packard not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.
-#
-#HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#********************************************************/
-# $XFree86: xc/include/extensions/XI.h,v 1.5 2001/12/14 19:53:28 dawes Exp $
-#
-# Definitions used by the server, library and client
-#
-#        Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Histroy:
-#        2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and chnaged it to
-#                     "reocrd" only.
-#        2004/10/07 - Removed the "uses X;" line. The unit does not need it.
-#        2004/10/03 - Conversion from C header to Pascal unit.
-#
-
-const 
-  sz_xGetExtensionVersionReq* = 8
-  sz_xGetExtensionVersionReply* = 32
-  sz_xListInputDevicesReq* = 4
-  sz_xListInputDevicesReply* = 32
-  sz_xOpenDeviceReq* = 8
-  sz_xOpenDeviceReply* = 32
-  sz_xCloseDeviceReq* = 8
-  sz_xSetDeviceModeReq* = 8
-  sz_xSetDeviceModeReply* = 32
-  sz_xSelectExtensionEventReq* = 12
-  sz_xGetSelectedExtensionEventsReq* = 8
-  sz_xGetSelectedExtensionEventsReply* = 32
-  sz_xChangeDeviceDontPropagateListReq* = 12
-  sz_xGetDeviceDontPropagateListReq* = 8
-  sz_xGetDeviceDontPropagateListReply* = 32
-  sz_xGetDeviceMotionEventsReq* = 16
-  sz_xGetDeviceMotionEventsReply* = 32
-  sz_xChangeKeyboardDeviceReq* = 8
-  sz_xChangeKeyboardDeviceReply* = 32
-  sz_xChangePointerDeviceReq* = 8
-  sz_xChangePointerDeviceReply* = 32
-  sz_xGrabDeviceReq* = 20
-  sz_xGrabDeviceReply* = 32
-  sz_xUngrabDeviceReq* = 12
-  sz_xGrabDeviceKeyReq* = 20
-  sz_xGrabDeviceKeyReply* = 32
-  sz_xUngrabDeviceKeyReq* = 16
-  sz_xGrabDeviceButtonReq* = 20
-  sz_xGrabDeviceButtonReply* = 32
-  sz_xUngrabDeviceButtonReq* = 16
-  sz_xAllowDeviceEventsReq* = 12
-  sz_xGetDeviceFocusReq* = 8
-  sz_xGetDeviceFocusReply* = 32
-  sz_xSetDeviceFocusReq* = 16
-  sz_xGetFeedbackControlReq* = 8
-  sz_xGetFeedbackControlReply* = 32
-  sz_xChangeFeedbackControlReq* = 12
-  sz_xGetDeviceKeyMappingReq* = 8
-  sz_xGetDeviceKeyMappingReply* = 32
-  sz_xChangeDeviceKeyMappingReq* = 8
-  sz_xGetDeviceModifierMappingReq* = 8
-  sz_xSetDeviceModifierMappingReq* = 8
-  sz_xSetDeviceModifierMappingReply* = 32
-  sz_xGetDeviceButtonMappingReq* = 8
-  sz_xGetDeviceButtonMappingReply* = 32
-  sz_xSetDeviceButtonMappingReq* = 8
-  sz_xSetDeviceButtonMappingReply* = 32
-  sz_xQueryDeviceStateReq* = 8
-  sz_xQueryDeviceStateReply* = 32
-  sz_xSendExtensionEventReq* = 16
-  sz_xDeviceBellReq* = 8
-  sz_xSetDeviceValuatorsReq* = 8
-  sz_xSetDeviceValuatorsReply* = 32
-  sz_xGetDeviceControlReq* = 8
-  sz_xGetDeviceControlReply* = 32
-  sz_xChangeDeviceControlReq* = 8
-  sz_xChangeDeviceControlReply* = 32
-
-const 
-  INAME* = "XInputExtension"
-
-const 
-  XI_KEYBOARD* = "KEYBOARD"
-  XI_MOUSE* = "MOUSE"
-  XI_TABLET* = "TABLET"
-  XI_TOUCHSCREEN* = "TOUCHSCREEN"
-  XI_TOUCHPAD* = "TOUCHPAD"
-  XI_BARCODE* = "BARCODE"
-  XI_BUTTONBOX* = "BUTTONBOX"
-  XI_KNOB_BOX* = "KNOB_BOX"
-  XI_ONE_KNOB* = "ONE_KNOB"
-  XI_NINE_KNOB* = "NINE_KNOB"
-  XI_TRACKBALL* = "TRACKBALL"
-  XI_QUADRATURE* = "QUADRATURE"
-  XI_ID_MODULE* = "ID_MODULE"
-  XI_SPACEBALL* = "SPACEBALL"
-  XI_DATAGLOVE* = "DATAGLOVE"
-  XI_EYETRACKER* = "EYETRACKER"
-  XI_CURSORKEYS* = "CURSORKEYS"
-  XI_FOOTMOUSE* = "FOOTMOUSE"
-
-const 
-  Dont_Check* = 0
-  XInput_Initial_Release* = 1
-  XInput_Add_XDeviceBell* = 2
-  XInput_Add_XSetDeviceValuators* = 3
-  XInput_Add_XChangeDeviceControl* = 4
-
-const 
-  XI_Absent* = 0
-  XI_Present* = 1
-
-const 
-  XI_Initial_Release_Major* = 1
-  XI_Initial_Release_Minor* = 0
-
-const 
-  XI_Add_XDeviceBell_Major* = 1
-  XI_Add_XDeviceBell_Minor* = 1
-
-const 
-  XI_Add_XSetDeviceValuators_Major* = 1
-  XI_Add_XSetDeviceValuators_Minor* = 2
-
-const 
-  XI_Add_XChangeDeviceControl_Major* = 1
-  XI_Add_XChangeDeviceControl_Minor* = 3
-
-const 
-  DEVICE_RESOLUTION* = 1
-
-const 
-  NoSuchExtension* = 1
-
-const 
-  COUNT* = 0
-  CREATE* = 1
-
-const 
-  NewPointer* = 0
-  NewKeyboard* = 1
-
-const 
-  XPOINTER* = 0
-  XKEYBOARD* = 1
-
-const 
-  UseXKeyboard* = 0x000000FF
-
-const 
-  IsXPointer* = 0
-  IsXKeyboard* = 1
-  IsXExtensionDevice* = 2
-
-const 
-  AsyncThisDevice* = 0
-  SyncThisDevice* = 1
-  ReplayThisDevice* = 2
-  AsyncOtherDevices* = 3
-  AsyncAll* = 4
-  SyncAll* = 5
-
-const 
-  FollowKeyboard* = 3
-  RevertToFollowKeyboard* = 3
-
-const 
-  DvAccelNum* = int(1) shl 0
-  DvAccelDenom* = int(1) shl 1
-  DvThreshold* = int(1) shl 2
-
-const 
-  DvKeyClickPercent* = int(1) shl 0
-  DvPercent* = int(1) shl 1
-  DvPitch* = int(1) shl 2
-  DvDuration* = int(1) shl 3
-  DvLed* = int(1) shl 4
-  DvLedMode* = int(1) shl 5
-  DvKey* = int(1) shl 6
-  DvAutoRepeatMode* = 1 shl 7
-
-const 
-  DvString* = int(1) shl 0
-
-const 
-  DvInteger* = int(1) shl 0
-
-const 
-  DeviceMode* = int(1) shl 0
-  Relative* = 0
-  Absolute* = 1               # Merged from Metrolink tree for XINPUT stuff 
-  TS_Raw* = 57
-  TS_Scaled* = 58
-  SendCoreEvents* = 59
-  DontSendCoreEvents* = 60    # End of merged section 
-
-const 
-  ProximityState* = int(1) shl 1
-  InProximity* = int(0) shl 1
-  OutOfProximity* = int(1) shl 1
-
-const 
-  AddToList* = 0
-  DeleteFromList* = 1
-
-const 
-  KeyClass* = 0
-  ButtonClass* = 1
-  ValuatorClass* = 2
-  FeedbackClass* = 3
-  ProximityClass* = 4
-  FocusClass* = 5
-  OtherClass* = 6
-
-const 
-  KbdFeedbackClass* = 0
-  PtrFeedbackClass* = 1
-  StringFeedbackClass* = 2
-  IntegerFeedbackClass* = 3
-  LedFeedbackClass* = 4
-  BellFeedbackClass* = 5
-
-const 
-  devicePointerMotionHint* = 0
-  deviceButton1Motion* = 1
-  deviceButton2Motion* = 2
-  deviceButton3Motion* = 3
-  deviceButton4Motion* = 4
-  deviceButton5Motion* = 5
-  deviceButtonMotion* = 6
-  deviceButtonGrab* = 7
-  deviceOwnerGrabButton* = 8
-  noExtensionEvent* = 9
-
-const 
-  XI_BadDevice* = 0
-  XI_BadEvent* = 1
-  XI_BadMode* = 2
-  XI_DeviceBusy* = 3
-  XI_BadClass* = 4 # Make XEventClass be a CARD32 for 64 bit servers.  Don't affect client
-                   #  definition of XEventClass since that would be a library interface change.
-                   #  See the top of X.h for more _XSERVER64 magic.
-                   #
-
-when defined(XSERVER64): 
-  type 
-    XEventClass* = CARD32
-else: 
-  type 
-    XEventClass* = int32
-#******************************************************************
-# *
-# * Extension version structure.
-# *
-# 
-
-type 
-  PXExtensionVersion* = ptr TXExtensionVersion
-  TXExtensionVersion*{.final.} = object 
-    present*: int16
-    major_version*: int16
-    minor_version*: int16
-
-
-# implementation
diff --git a/lib/wrappers/x11/xinerama.nim b/lib/wrappers/x11/xinerama.nim
deleted file mode 100755
index 96f5d7da3..000000000
--- a/lib/wrappers/x11/xinerama.nim
+++ /dev/null
@@ -1,25 +0,0 @@
-# Converted from X11/Xinerama.h 
-import                        
-  xlib
-
-const
-  xineramaLib = "libXinerama.so"
-
-type 
-  PXineramaScreenInfo* = ptr TXineramaScreenInfo
-  TXineramaScreenInfo*{.final.} = object 
-    screen_number*: cint
-    x_org*: int16
-    y_org*: int16
-    width*: int16
-    height*: int16
-
-
-proc XineramaQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
-    cdecl, dynlib: xineramaLib, importc.}
-proc XineramaQueryVersion*(dpy: PDisplay, major: Pcint, minor: Pcint): TStatus{.
-    cdecl, dynlib: xineramaLib, importc.}
-proc XineramaIsActive*(dpy: PDisplay): TBool{.cdecl, dynlib: xineramaLib, importc.}
-proc XineramaQueryScreens*(dpy: PDisplay, number: Pcint): PXineramaScreenInfo{.
-    cdecl, dynlib: xineramaLib, importc.}
-
diff --git a/lib/wrappers/x11/xkb.nim b/lib/wrappers/x11/xkb.nim
deleted file mode 100755
index f1b0448a8..000000000
--- a/lib/wrappers/x11/xkb.nim
+++ /dev/null
@@ -1,2409 +0,0 @@
-#
-# $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-# $Xorg: XKBstr.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-# $Xorg: XKBgeom.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
-#************************************************************
-#
-#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-#
-#Permission to use, copy, modify, and distribute this
-#software and its documentation for any purpose and without
-#fee is hereby granted, provided that the above copyright
-#notice appear in all copies and that both that copyright
-#notice and this permission notice appear in supporting
-#documentation, and that the name of Silicon Graphics not be
-#used in advertising or publicity pertaining to distribution
-#of the software without specific prior written permission.
-#Silicon Graphics makes no representation about the suitability
-#of this software for any purpose. It is provided "as is"
-#without any express or implied warranty.
-#
-#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-#THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-#********************************************************
-# $XFree86: xc/include/extensions/XKB.h,v 1.5 2002/11/20 04:49:01 dawes Exp $
-# $XFree86: xc/include/extensions/XKBgeom.h,v 3.9 2002/09/18 17:11:40 tsi Exp $
-#
-# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Thanks:
-#         I want to thanks to oliebol for putting up with all of the problems that was found
-#         while translating this code. ;)
-#
-#         I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
-#         wierd questions ;)
-#
-#         Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
-#         understanding some of the problems I had converting this headers and pointing me to resources
-#         that helped translating this headers.
-#
-# Ido
-#
-#History:
-#        2004/10/15           - Fixed a bug of accessing second based records by removing "paced record" and
-#                               chnaged it to "reocrd" only.
-#        2004/10/04 - 06      - Convertion from the c header of XKBgeom.h.
-#        2004/10/03           - Removed the XKBstr_UNIT compiler decleration. Afther the joined files,
-#                                                                                     There is no need for it anymore.
-#                                                                             - There is a need to define (for now) XKBgeom (compiler define) in order
-#                                                                               to use the code of it. At this moment, I did not yet converted it to Pascal.
-#
-#        2004/09/17 - 10/04   - Convertion from the c header of XKBstr.
-#
-#        2004/10/03           - Joined xkbstr.pas into xkb.pas because of the circular calls problems.
-#                             - Added the history of xkbstr.pas above this addition.
-#
-#        2004/09/17           - Fixed a wrong convertion number of XkbPerKeyBitArraySize, insted
-#                               of float, it's now converted into integer (as it should have been).
-#
-#        2004/09/15 - 16      - Convertion from the c header of XKB.h.
-#
-
-import 
-  X, Xlib
-
-proc XkbCharToInt*(v: int8): int16
-proc XkbIntTo2Chars*(i: int16, h, L: var int8)
-proc Xkb2CharsToInt*(h, L: int8): int16
-  #
-  #          Common data structures and access macros
-  #        
-type
-  PWord* = ptr array[0..64_000, int16]
-  PByte* = ptr byte
-  PXkbStatePtr* = ptr TXkbStateRec
-  TXkbStateRec*{.final.} = object 
-    group*: int8
-    locked_group*: int8
-    base_group*: int16
-    latched_group*: int16
-    mods*: int8
-    base_mods*: int8
-    latched_mods*: int8
-    locked_mods*: int8
-    compat_state*: int8
-    grab_mods*: int8
-    compat_grab_mods*: int8
-    lookup_mods*: int8
-    compat_lookup_mods*: int8
-    ptr_buttons*: int16
-
-
-proc XkbModLocks*(s: PXkbStatePtr): int8
-proc XkbStateMods*(s: PXkbStatePtr): int16
-proc XkbGroupLock*(s: PXkbStatePtr): int8
-proc XkbStateGroup*(s: PXkbStatePtr): int16
-proc XkbStateFieldFromRec*(s: PXkbStatePtr): int
-proc XkbGrabStateFromRec*(s: PXkbStatePtr): int
-type 
-  PXkbModsPtr* = ptr TXkbModsRec
-  TXkbModsRec*{.final.} = object 
-    mask*: int8               # effective mods
-    real_mods*: int8
-    vmods*: int16
-
-
-type 
-  PXkbKTMapEntryPtr* = ptr TXkbKTMapEntryRec
-  TXkbKTMapEntryRec*{.final.} = object 
-    active*: bool
-    level*: int8
-    mods*: TXkbModsRec
-
-
-type 
-  PXkbKeyTypePtr* = ptr TXkbKeyTypeRec
-  TXkbKeyTypeRec*{.final.} = object 
-    mods*: TXkbModsRec
-    num_levels*: int8
-    map_count*: int8
-    map*: PXkbKTMapEntryPtr
-    preserve*: PXkbModsPtr
-    name*: TAtom
-    level_names*: TAtom
-
-
-proc XkbNumGroups*(g: int16): int16
-proc XkbOutOfRangeGroupInfo*(g: int16): int16
-proc XkbOutOfRangeGroupAction*(g: int16): int16
-proc XkbOutOfRangeGroupNumber*(g: int16): int16
-proc XkbSetGroupInfo*(g, w, n: int16): int16
-proc XkbSetNumGroups*(g, n: int16): int16
-  #
-  #          Structures and access macros used primarily by the server
-  #        
-type 
-  PXkbBehavior* = ptr TXkbBehavior
-  TXkbBehavior*{.final.} = object 
-    theType*: int8
-    data*: int8
-
-
-type 
-  PXkbModAction* = ptr TXkbModAction
-  TXkbModAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    mask*: int8
-    real_mods*: int8
-    vmods1*: int8
-    vmods2*: int8
-
-
-proc XkbModActionVMods*(a: PXkbModAction): int16
-proc XkbSetModActionVMods*(a: PXkbModAction, v: int8)
-type 
-  PXkbGroupAction* = ptr TXkbGroupAction
-  TXkbGroupAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    group_XXX*: int8
-
-
-proc XkbSAGroup*(a: PXkbGroupAction): int8
-proc XkbSASetGroupProc*(a: PXkbGroupAction, g: int8)
-type 
-  PXkbISOAction* = ptr TXkbISOAction
-  TXkbISOAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    mask*: int8
-    real_mods*: int8
-    group_XXX*: int8
-    affect*: int8
-    vmods1*: int8
-    vmods2*: int8
-
-
-type 
-  PXkbPtrAction* = ptr TXkbPtrAction
-  TXkbPtrAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    high_XXX*: int8
-    low_XXX*: int8
-    high_YYY*: int8
-    low_YYY*: int8
-
-
-proc XkbPtrActionX*(a: PXkbPtrAction): int16
-proc XkbPtrActionY*(a: PXkbPtrAction): int16
-proc XkbSetPtrActionX*(a: PXkbPtrAction, x: int8)
-proc XkbSetPtrActionY*(a: PXkbPtrAction, y: int8)
-type 
-  PXkbPtrBtnAction* = ptr TXkbPtrBtnAction
-  TXkbPtrBtnAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    count*: int8
-    button*: int8
-
-
-type 
-  PXkbPtrDfltAction* = ptr TXkbPtrDfltAction
-  TXkbPtrDfltAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    affect*: int8
-    valueXXX*: int8
-
-
-proc XkbSAPtrDfltValue*(a: PXkbPtrDfltAction): int8
-proc XkbSASetPtrDfltValue*(a: PXkbPtrDfltAction, c: pointer)
-type 
-  PXkbSwitchScreenAction* = ptr TXkbSwitchScreenAction
-  TXkbSwitchScreenAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    screenXXX*: int8
-
-
-proc XkbSAScreen*(a: PXkbSwitchScreenAction): int8
-proc XkbSASetScreen*(a: PXkbSwitchScreenAction, s: pointer)
-type 
-  PXkbCtrlsAction* = ptr TXkbCtrlsAction
-  TXkbCtrlsAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    ctrls3*: int8
-    ctrls2*: int8
-    ctrls1*: int8
-    ctrls0*: int8
-
-
-proc XkbActionSetCtrls*(a: PXkbCtrlsAction, c: int8)
-proc XkbActionCtrls*(a: PXkbCtrlsAction): int16
-type 
-  PXkbMessageAction* = ptr TXkbMessageAction
-  TXkbMessageAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    message*: array[0..5, char]
-
-
-type 
-  PXkbRedirectKeyAction* = ptr TXkbRedirectKeyAction
-  TXkbRedirectKeyAction*{.final.} = object 
-    theType*: int8
-    new_key*: int8
-    mods_mask*: int8
-    mods*: int8
-    vmods_mask0*: int8
-    vmods_mask1*: int8
-    vmods0*: int8
-    vmods1*: int8
-
-
-proc XkbSARedirectVMods*(a: PXkbRedirectKeyAction): int16
-proc XkbSARedirectSetVMods*(a: PXkbRedirectKeyAction, m: int8)
-proc XkbSARedirectVModsMask*(a: PXkbRedirectKeyAction): int16
-proc XkbSARedirectSetVModsMask*(a: PXkbRedirectKeyAction, m: int8)
-type 
-  PXkbDeviceBtnAction* = ptr TXkbDeviceBtnAction
-  TXkbDeviceBtnAction*{.final.} = object 
-    theType*: int8
-    flags*: int8
-    count*: int8
-    button*: int8
-    device*: int8
-
-
-type 
-  PXkbDeviceValuatorAction* = ptr TXkbDeviceValuatorAction
-  TXkbDeviceValuatorAction*{.final.} = object  #
-                                               #      Macros to classify key actions
-                                               #                
-    theType*: int8
-    device*: int8
-    v1_what*: int8
-    v1_ndx*: int8
-    v1_value*: int8
-    v2_what*: int8
-    v2_ndx*: int8
-    v2_value*: int8
-
-
-const 
-  XkbAnyActionDataSize* = 7
-
-type 
-  PXkbAnyAction* = ptr TXkbAnyAction
-  TXkbAnyAction*{.final.} = object 
-    theType*: int8
-    data*: array[0..XkbAnyActionDataSize - 1, int8]
-
-
-proc XkbIsModAction*(a: PXkbAnyAction): bool
-proc XkbIsGroupAction*(a: PXkbAnyAction): bool
-proc XkbIsPtrAction*(a: PXkbAnyAction): bool
-type 
-  PXkbAction* = ptr TXkbAction
-  TXkbAction*{.final.} = object  #
-                                 #      XKB request codes, used in:
-                                 #      -  xkbReqType field of all requests
-                                 #      -  requestMinor field of some events
-                                 #                
-    any*: TXkbAnyAction
-    mods*: TXkbModAction
-    group*: TXkbGroupAction
-    iso*: TXkbISOAction
-    thePtr*: TXkbPtrAction
-    btn*: TXkbPtrBtnAction
-    dflt*: TXkbPtrDfltAction
-    screen*: TXkbSwitchScreenAction
-    ctrls*: TXkbCtrlsAction
-    msg*: TXkbMessageAction
-    redirect*: TXkbRedirectKeyAction
-    devbtn*: TXkbDeviceBtnAction
-    devval*: TXkbDeviceValuatorAction
-    theType*: int8
-
-
-const 
-  X_kbUseExtension* = 0
-  X_kbSelectEvents* = 1
-  X_kbBell* = 3
-  X_kbGetState* = 4
-  X_kbLatchLockState* = 5
-  X_kbGetControls* = 6
-  X_kbSetControls* = 7
-  X_kbGetMap* = 8
-  X_kbSetMap* = 9
-  X_kbGetCompatMap* = 10
-  X_kbSetCompatMap* = 11
-  X_kbGetIndicatorState* = 12
-  X_kbGetIndicatorMap* = 13
-  X_kbSetIndicatorMap* = 14
-  X_kbGetNamedIndicator* = 15
-  X_kbSetNamedIndicator* = 16
-  X_kbGetNames* = 17
-  X_kbSetNames* = 18
-  X_kbGetGeometry* = 19
-  X_kbSetGeometry* = 20
-  X_kbPerClientFlags* = 21
-  X_kbListComponents* = 22
-  X_kbGetKbdByName* = 23
-  X_kbGetDeviceInfo* = 24
-  X_kbSetDeviceInfo* = 25
-  X_kbSetDebuggingFlags* = 101 #
-                               #      In the X sense, XKB reports only one event.
-                               #      The type field of all XKB events is XkbEventCode
-                               #                
-
-const 
-  XkbEventCode* = 0
-  XkbNumberEvents* = XkbEventCode + 1 #
-                                      #      XKB has a minor event code so it can use one X event code for
-                                      #      multiple purposes.
-                                      #       - reported in the xkbType field of all XKB events.
-                                      #       - XkbSelectEventDetails: Indicates the event for which event details
-                                      #         are being changed
-                                      #                
-
-const 
-  XkbNewKeyboardNotify* = 0
-  XkbMapNotify* = 1
-  XkbStateNotify* = 2
-  XkbControlsNotify* = 3
-  XkbIndicatorStateNotify* = 4
-  XkbIndicatorMapNotify* = 5
-  XkbNamesNotify* = 6
-  XkbCompatMapNotify* = 7
-  XkbBellNotify* = 8
-  XkbActionMessage* = 9
-  XkbAccessXNotify* = 10
-  XkbExtensionDeviceNotify* = 11 #
-                                 #      Event Mask:
-                                 #       - XkbSelectEvents:  Specifies event interest.
-                                 #    
-
-const 
-  XkbNewKeyboardNotifyMask* = int(1) shl 0
-  XkbMapNotifyMask* = int(1) shl 1
-  XkbStateNotifyMask* = int(1) shl 2
-  XkbControlsNotifyMask* = int(1) shl 3
-  XkbIndicatorStateNotifyMask* = int(1) shl 4
-  XkbIndicatorMapNotifyMask* = int(1) shl 5
-  XkbNamesNotifyMask* = int(1) shl 6
-  XkbCompatMapNotifyMask* = int(1) shl 7
-  XkbBellNotifyMask* = int(1) shl 8
-  XkbActionMessageMask* = int(1) shl 9
-  XkbAccessXNotifyMask* = int(1) shl 10
-  XkbExtensionDeviceNotifyMask* = int(1) shl 11
-  XkbAllEventsMask* = 0x00000FFF #
-                                 #      NewKeyboardNotify event details:
-                                 #    
-
-const 
-  XkbNKN_KeycodesMask* = int(1) shl 0
-  XkbNKN_GeometryMask* = int(1) shl 1
-  XkbNKN_DeviceIDMask* = int(1) shl 2
-  XkbAllNewKeyboardEventsMask* = 0x00000007 #
-                                            #      AccessXNotify event types:
-                                            #       - The 'what' field of AccessXNotify events reports the
-                                            #         reason that the event was generated.
-                                            #                
-
-const 
-  XkbAXN_SKPress* = 0
-  XkbAXN_SKAccept* = 1
-  XkbAXN_SKReject* = 2
-  XkbAXN_SKRelease* = 3
-  XkbAXN_BKAccept* = 4
-  XkbAXN_BKReject* = 5
-  XkbAXN_AXKWarning* = 6 #
-                         #      AccessXNotify details:
-                         #      - Used as an event detail mask to limit the conditions under which
-                         #        AccessXNotify events are reported
-                         #                
-
-const 
-  XkbAXN_SKPressMask* = int(1) shl 0
-  XkbAXN_SKAcceptMask* = int(1) shl 1
-  XkbAXN_SKRejectMask* = int(1) shl 2
-  XkbAXN_SKReleaseMask* = int(1) shl 3
-  XkbAXN_BKAcceptMask* = int(1) shl 4
-  XkbAXN_BKRejectMask* = int(1) shl 5
-  XkbAXN_AXKWarningMask* = int(1) shl 6
-  XkbAllAccessXEventsMask* = 0x0000000F #
-                                        #      State detail mask:
-                                        #       - The 'changed' field of StateNotify events reports which of
-                                        #         the keyboard state components have changed.
-                                        #       - Used as an event detail mask to limit the conditions under
-                                        #         which StateNotify events are reported.
-                                        #                
-
-const 
-  XkbModifierStateMask* = int(1) shl 0
-  XkbModifierBaseMask* = int(1) shl 1
-  XkbModifierLatchMask* = int(1) shl 2
-  XkbModifierLockMask* = int(1) shl 3
-  XkbGroupStateMask* = int(1) shl 4
-  XkbGroupBaseMask* = int(1) shl 5
-  XkbGroupLatchMask* = int(1) shl 6
-  XkbGroupLockMask* = int(1) shl 7
-  XkbCompatStateMask* = int(1) shl 8
-  XkbGrabModsMask* = int(1) shl 9
-  XkbCompatGrabModsMask* = int(1) shl 10
-  XkbLookupModsMask* = int(1) shl 11
-  XkbCompatLookupModsMask* = int(1) shl 12
-  XkbPointerButtonMask* = int(1) shl 13
-  XkbAllStateComponentsMask* = 0x00003FFF #
-                                          #      Controls detail masks:
-                                          #       The controls specified in XkbAllControlsMask:
-                                          #       - The 'changed' field of ControlsNotify events reports which of
-                                          #         the keyboard controls have changed.
-                                          #       - The 'changeControls' field of the SetControls request specifies
-                                          #         the controls for which values are to be changed.
-                                          #       - Used as an event detail mask to limit the conditions under
-                                          #         which ControlsNotify events are reported.
-                                          #
-                                          #       The controls specified in the XkbAllBooleanCtrlsMask:
-                                          #       - The 'enabledControls' field of ControlsNotify events reports the
-                                          #         current status of the boolean controls.
-                                          #       - The 'enabledControlsChanges' field of ControlsNotify events reports
-                                          #         any boolean controls that have been turned on or off.
-                                          #       - The 'affectEnabledControls' and 'enabledControls' fields of the
-                                          #         kbSetControls request change the set of enabled controls.
-                                          #       - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of
-                                          #         an XkbControlsRec specify the controls to be changed if the keyboard
-                                          #         times out and the values to which they should be changed.
-                                          #       - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags
-                                          #         request specifies the specify the controls to be reset when the
-                                          #         client exits and the values to which they should be reset.
-                                          #       - The 'ctrls' field of an indicator map specifies the controls
-                                          #         that drive the indicator.
-                                          #       - Specifies the boolean controls affected by the SetControls and
-                                          #         LockControls key actions.
-                                          #                
-
-const 
-  XkbRepeatKeysMask* = int(1) shl 0
-  XkbSlowKeysMask* = int(1) shl 1
-  XkbBounceKeysMask* = int(1) shl 2
-  XkbStickyKeysMask* = int(1) shl 3
-  XkbMouseKeysMask* = int(1) shl 4
-  XkbMouseKeysAccelMask* = int(1) shl 5
-  XkbAccessXKeysMask* = int(1) shl 6
-  XkbAccessXTimeoutMask* = int(1) shl 7
-  XkbAccessXFeedbackMask* = int(1) shl 8
-  XkbAudibleBellMask* = int(1) shl 9
-  XkbOverlay1Mask* = int(1) shl 10
-  XkbOverlay2Mask* = int(1) shl 11
-  XkbIgnoreGroupLockMask* = int(1) shl 12
-  XkbGroupsWrapMask* = int(1) shl 27
-  XkbInternalModsMask* = int(1) shl 28
-  XkbIgnoreLockModsMask* = int(1) shl 29
-  XkbPerKeyRepeatMask* = int(1) shl 30
-  XkbControlsEnabledMask* = int(1) shl 31
-  XkbAccessXOptionsMask* = XkbStickyKeysMask or XkbAccessXFeedbackMask
-  XkbAllBooleanCtrlsMask* = 0x00001FFF
-  XkbAllControlsMask* = 0xF8001FFF #
-                                   #      Compatibility Map Compontents:
-                                   #       - Specifies the components to be allocated in XkbAllocCompatMap.
-                                   #                
-
-const 
-  XkbSymInterpMask* = 1 shl 0
-  XkbGroupCompatMask* = 1 shl 1
-  XkbAllCompatMask* = 0x00000003 #
-                                 #      Assorted constants and limits.
-                                 #                
-
-const 
-  XkbAllIndicatorsMask* = 0xFFFFFFFF #
-                                     #      Map components masks:
-                                     #      Those in AllMapComponentsMask:
-                                     #       - Specifies the individual fields to be loaded or changed for the
-                                     #         GetMap and SetMap requests.
-                                     #      Those in ClientInfoMask:
-                                     #       - Specifies the components to be allocated by XkbAllocClientMap.
-                                     #      Those in ServerInfoMask:
-                                     #       - Specifies the components to be allocated by XkbAllocServerMap.
-                                     #                
-
-const 
-  XkbKeyTypesMask* = 1 shl 0
-  XkbKeySymsMask* = 1 shl 1
-  XkbModifierMapMask* = 1 shl 2
-  XkbExplicitComponentsMask* = 1 shl 3
-  XkbKeyActionsMask* = 1 shl 4
-  XkbKeyBehaviorsMask* = 1 shl 5
-  XkbVirtualModsMask* = 1 shl 6
-  XkbVirtualModMapMask* = 1 shl 7
-  XkbAllClientInfoMask* = XkbKeyTypesMask or XkbKeySymsMask or
-      XkbModifierMapMask
-  XkbAllServerInfoMask* = XkbExplicitComponentsMask or XkbKeyActionsMask or
-      XkbKeyBehaviorsMask or XkbVirtualModsMask or XkbVirtualModMapMask
-  XkbAllMapComponentsMask* = XkbAllClientInfoMask or XkbAllServerInfoMask #
-                                                                          #      Names component mask:
-                                                                          #       - Specifies the names to be loaded or changed for the GetNames and
-                                                                          #         SetNames requests.
-                                                                          #       - Specifies the names that have changed in a NamesNotify event.
-                                                                          #       - Specifies the names components to be allocated by XkbAllocNames.
-                                                                          #                
-
-const 
-  XkbKeycodesNameMask* = 1 shl 0
-  XkbGeometryNameMask* = 1 shl 1
-  XkbSymbolsNameMask* = 1 shl 2
-  XkbPhysSymbolsNameMask* = 1 shl 3
-  XkbTypesNameMask* = 1 shl 4
-  XkbCompatNameMask* = 1 shl 5
-  XkbKeyTypeNamesMask* = 1 shl 6
-  XkbKTLevelNamesMask* = 1 shl 7
-  XkbIndicatorNamesMask* = 1 shl 8
-  XkbKeyNamesMask* = 1 shl 9
-  XkbKeyAliasesMask* = 1 shl 10
-  XkbVirtualModNamesMask* = 1 shl 11
-  XkbGroupNamesMask* = 1 shl 12
-  XkbRGNamesMask* = 1 shl 13
-  XkbComponentNamesMask* = 0x0000003F
-  XkbAllNamesMask* = 0x00003FFF #
-                                #      Miscellaneous event details:
-                                #      - event detail masks for assorted events that don't reall
-                                #        have any details.
-                                #                
-
-const 
-  XkbAllStateEventsMask* = XkbAllStateComponentsMask
-  XkbAllMapEventsMask* = XkbAllMapComponentsMask
-  XkbAllControlEventsMask* = XkbAllControlsMask
-  XkbAllIndicatorEventsMask* = XkbAllIndicatorsMask
-  XkbAllNameEventsMask* = XkbAllNamesMask
-  XkbAllCompatMapEventsMask* = XkbAllCompatMask
-  XkbAllBellEventsMask* = int(1) shl 0
-  XkbAllActionMessagesMask* = int(1) shl 0 #
-                                           #      XKB reports one error:  BadKeyboard
-                                           #      A further reason for the error is encoded into to most significant
-                                           #      byte of the resourceID for the error:
-                                           #         XkbErr_BadDevice - the device in question was not found
-                                           #         XkbErr_BadClass  - the device was found but it doesn't belong to
-                                           #                            the appropriate class.
-                                           #         XkbErr_BadId     - the device was found and belongs to the right
-                                           #                            class, but not feedback with a matching id was
-                                           #                            found.
-                                           #      The low byte of the resourceID for this error contains the device
-                                           #      id, class specifier or feedback id that failed.
-                                           #                
-
-const 
-  XkbKeyboard* = 0
-  XkbNumberErrors* = 1
-  XkbErr_BadDevice* = 0x000000FF
-  XkbErr_BadClass* = 0x000000FE
-  XkbErr_BadId* = 0x000000FD #
-                             #      Keyboard Components Mask:
-                             #      - Specifies the components that follow a GetKeyboardByNameReply
-                             #                
-
-const 
-  XkbClientMapMask* = int(1) shl 0
-  XkbServerMapMask* = int(1) shl 1
-  XkbCompatMapMask* = int(1) shl 2
-  XkbIndicatorMapMask* = int(1) shl 3
-  XkbNamesMask* = int(1) shl 4
-  XkbGeometryMask* = int(1) shl 5
-  XkbControlsMask* = int(1) shl 6
-  XkbAllComponentsMask* = 0x0000007F #
-                                     #      AccessX Options Mask
-                                     #       - The 'accessXOptions' field of an XkbControlsRec specifies the
-                                     #         AccessX options that are currently in effect.
-                                     #       - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'
-                                     #         fields of an XkbControlsRec specify the Access X options to be
-                                     #         changed if the keyboard times out and the values to which they
-                                     #         should be changed.
-                                     #                
-
-const 
-  XkbAX_SKPressFBMask* = int(1) shl 0
-  XkbAX_SKAcceptFBMask* = int(1) shl 1
-  XkbAX_FeatureFBMask* = int(1) shl 2
-  XkbAX_SlowWarnFBMask* = int(1) shl 3
-  XkbAX_IndicatorFBMask* = int(1) shl 4
-  XkbAX_StickyKeysFBMask* = int(1) shl 5
-  XkbAX_TwoKeysMask* = int(1) shl 6
-  XkbAX_LatchToLockMask* = int(1) shl 7
-  XkbAX_SKReleaseFBMask* = int(1) shl 8
-  XkbAX_SKRejectFBMask* = int(1) shl 9
-  XkbAX_BKRejectFBMask* = int(1) shl 10
-  XkbAX_DumbBellFBMask* = int(1) shl 11
-  XkbAX_FBOptionsMask* = 0x00000F3F
-  XkbAX_SKOptionsMask* = 0x000000C0
-  XkbAX_AllOptionsMask* = 0x00000FFF #
-                                     #      XkbUseCoreKbd is used to specify the core keyboard without having
-                                     #                        to look up its X input extension identifier.
-                                     #      XkbUseCorePtr is used to specify the core pointer without having
-                                     #                        to look up its X input extension identifier.
-                                     #      XkbDfltXIClass is used to specify "don't care" any place that the
-                                     #                        XKB protocol is looking for an X Input Extension
-                                     #                        device class.
-                                     #      XkbDfltXIId is used to specify "don't care" any place that the
-                                     #                        XKB protocol is looking for an X Input Extension
-                                     #                        feedback identifier.
-                                     #      XkbAllXIClasses is used to get information about all device indicators,
-                                     #                        whether they're part of the indicator feedback class
-                                     #                        or the keyboard feedback class.
-                                     #      XkbAllXIIds is used to get information about all device indicator
-                                     #                        feedbacks without having to list them.
-                                     #      XkbXINone is used to indicate that no class or id has been specified.
-                                     #      XkbLegalXILedClass(c)  True if 'c' specifies a legal class with LEDs
-                                     #      XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells
-                                     #      XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device
-                                     #      XkbExplicitXIClass(c)  True if 'c' explicitly specifies a device class
-                                     #      XkbExplicitXIId(c)     True if 'i' explicitly specifies a device id
-                                     #      XkbSingleXIClass(c)    True if 'c' specifies exactly one device class,
-                                     #                             including the default.
-                                     #      XkbSingleXIId(i)       True if 'i' specifies exactly one device
-                                     #                              identifier, including the default.
-                                     #                
-
-const 
-  XkbUseCoreKbd* = 0x00000100
-  XkbUseCorePtr* = 0x00000200
-  XkbDfltXIClass* = 0x00000300
-  XkbDfltXIId* = 0x00000400
-  XkbAllXIClasses* = 0x00000500
-  XkbAllXIIds* = 0x00000600
-  XkbXINone* = 0x0000FF00
-
-proc XkbLegalXILedClass*(c: int): bool
-proc XkbLegalXIBellClass*(c: int): bool
-proc XkbExplicitXIDevice*(c: int): bool
-proc XkbExplicitXIClass*(c: int): bool
-proc XkbExplicitXIId*(c: int): bool
-proc XkbSingleXIClass*(c: int): bool
-proc XkbSingleXIId*(c: int): bool
-const 
-  XkbNoModifier* = 0x000000FF
-  XkbNoShiftLevel* = 0x000000FF
-  XkbNoShape* = 0x000000FF
-  XkbNoIndicator* = 0x000000FF
-  XkbNoModifierMask* = 0
-  XkbAllModifiersMask* = 0x000000FF
-  XkbAllVirtualModsMask* = 0x0000FFFF
-  XkbNumKbdGroups* = 4
-  XkbMaxKbdGroup* = XkbNumKbdGroups - 1
-  XkbMaxMouseKeysBtn* = 4 #
-                          #      Group Index and Mask:
-                          #       - Indices into the kt_index array of a key type.
-                          #       - Mask specifies types to be changed for XkbChangeTypesOfKey
-                          #    
-
-const 
-  XkbGroup1Index* = 0
-  XkbGroup2Index* = 1
-  XkbGroup3Index* = 2
-  XkbGroup4Index* = 3
-  XkbAnyGroup* = 254
-  XkbAllGroups* = 255
-  XkbGroup1Mask* = 1 shl 0
-  XkbGroup2Mask* = 1 shl 1
-  XkbGroup3Mask* = 1 shl 2
-  XkbGroup4Mask* = 1 shl 3
-  XkbAnyGroupMask* = 1 shl 7
-  XkbAllGroupsMask* = 0x0000000F #
-                                 #      BuildCoreState: Given a keyboard group and a modifier state,
-                                 #                      construct the value to be reported an event.
-                                 #      GroupForCoreState:  Given the state reported in an event,
-                                 #                      determine the keyboard group.
-                                 #      IsLegalGroup:   Returns TRUE if 'g' is a valid group index.
-                                 #                
-
-proc XkbBuildCoreState*(m, g: int): int
-proc XkbGroupForCoreState*(s: int): int
-proc XkbIsLegalGroup*(g: int): bool
-  #
-  #      GroupsWrap values:
-  #       - The 'groupsWrap' field of an XkbControlsRec specifies the
-  #         treatment of out of range groups.
-  #       - Bits 6 and 7 of the group info field of a key symbol map
-  #         specify the interpretation of out of range groups for the
-  #         corresponding key.
-  #                
-const 
-  XkbWrapIntoRange* = 0x00000000
-  XkbClampIntoRange* = 0x00000040
-  XkbRedirectIntoRange* = 0x00000080 #
-                                     #      Action flags:  Reported in the 'flags' field of most key actions.
-                                     #      Interpretation depends on the type of the action; not all actions
-                                     #      accept all flags.
-                                     #
-                                     #      Option                    Used for Actions
-                                     #      ------                    ----------------
-                                     #      ClearLocks                SetMods, LatchMods, SetGroup, LatchGroup
-                                     #      LatchToLock               SetMods, LatchMods, SetGroup, LatchGroup
-                                     #      LockNoLock                LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
-                                     #      LockNoUnlock              LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
-                                     #      UseModMapMods             SetMods, LatchMods, LockMods, ISOLock
-                                     #      GroupAbsolute             SetGroup, LatchGroup, LockGroup, ISOLock
-                                     #      UseDfltButton             PtrBtn, LockPtrBtn
-                                     #      NoAcceleration            MovePtr
-                                     #      MoveAbsoluteX             MovePtr
-                                     #      MoveAbsoluteY             MovePtr
-                                     #      ISODfltIsGroup            ISOLock
-                                     #      ISONoAffectMods           ISOLock
-                                     #      ISONoAffectGroup          ISOLock
-                                     #      ISONoAffectPtr            ISOLock
-                                     #      ISONoAffectCtrls          ISOLock
-                                     #      MessageOnPress            ActionMessage
-                                     #      MessageOnRelease          ActionMessage
-                                     #      MessageGenKeyEvent        ActionMessage
-                                     #      AffectDfltBtn             SetPtrDflt
-                                     #      DfltBtnAbsolute           SetPtrDflt
-                                     #      SwitchApplication SwitchScreen
-                                     #      SwitchAbsolute            SwitchScreen
-                                     #                
-
-const 
-  XkbSA_ClearLocks* = int(1) shl 0
-  XkbSA_LatchToLock* = int(1) shl 1
-  XkbSA_LockNoLock* = int(1) shl 0
-  XkbSA_LockNoUnlock* = int(1) shl 1
-  XkbSA_UseModMapMods* = int(1) shl 2
-  XkbSA_GroupAbsolute* = int(1) shl 2
-  XkbSA_UseDfltButton* = 0
-  XkbSA_NoAcceleration* = int(1) shl 0
-  XkbSA_MoveAbsoluteX* = int(1) shl 1
-  XkbSA_MoveAbsoluteY* = int(1) shl 2
-  XkbSA_ISODfltIsGroup* = int(1) shl 7
-  XkbSA_ISONoAffectMods* = int(1) shl 6
-  XkbSA_ISONoAffectGroup* = int(1) shl 5
-  XkbSA_ISONoAffectPtr* = int(1) shl 4
-  XkbSA_ISONoAffectCtrls* = int(1) shl 3
-  XkbSA_ISOAffectMask* = 0x00000078
-  XkbSA_MessageOnPress* = int(1) shl 0
-  XkbSA_MessageOnRelease* = int(1) shl 1
-  XkbSA_MessageGenKeyEvent* = int(1) shl 2
-  XkbSA_AffectDfltBtn* = 1
-  XkbSA_DfltBtnAbsolute* = int(1) shl 2
-  XkbSA_SwitchApplication* = int(1) shl 0
-  XkbSA_SwitchAbsolute* = int(1) shl 2 #
-                                       #      The following values apply to the SA_DeviceValuator
-                                       #      action only.  Valuator operations specify the action
-                                       #      to be taken.   Values specified in the action are
-                                       #      multiplied by 2^scale before they are applied.
-                                       #                
-
-const 
-  XkbSA_IgnoreVal* = 0x00000000
-  XkbSA_SetValMin* = 0x00000010
-  XkbSA_SetValCenter* = 0x00000020
-  XkbSA_SetValMax* = 0x00000030
-  XkbSA_SetValRelative* = 0x00000040
-  XkbSA_SetValAbsolute* = 0x00000050
-  XkbSA_ValOpMask* = 0x00000070
-  XkbSA_ValScaleMask* = 0x00000007
-
-proc XkbSA_ValOp*(a: int): int
-proc XkbSA_ValScale*(a: int): int
-  #
-  #      Action types: specifies the type of a key action.  Reported in the
-  #      type field of all key actions.
-  #                
-const 
-  XkbSA_NoAction* = 0x00000000
-  XkbSA_SetMods* = 0x00000001
-  XkbSA_LatchMods* = 0x00000002
-  XkbSA_LockMods* = 0x00000003
-  XkbSA_SetGroup* = 0x00000004
-  XkbSA_LatchGroup* = 0x00000005
-  XkbSA_LockGroup* = 0x00000006
-  XkbSA_MovePtr* = 0x00000007
-  XkbSA_PtrBtn* = 0x00000008
-  XkbSA_LockPtrBtn* = 0x00000009
-  XkbSA_SetPtrDflt* = 0x0000000A
-  XkbSA_ISOLock* = 0x0000000B
-  XkbSA_Terminate* = 0x0000000C
-  XkbSA_SwitchScreen* = 0x0000000D
-  XkbSA_SetControls* = 0x0000000E
-  XkbSA_LockControls* = 0x0000000F
-  XkbSA_ActionMessage* = 0x00000010
-  XkbSA_RedirectKey* = 0x00000011
-  XkbSA_DeviceBtn* = 0x00000012
-  XkbSA_LockDeviceBtn* = 0x00000013
-  XkbSA_DeviceValuator* = 0x00000014
-  XkbSA_LastAction* = XkbSA_DeviceValuator
-  XkbSA_NumActions* = XkbSA_LastAction + 1
-
-const 
-  XkbSA_XFree86Private* = 0x00000086
-#
-#      Specifies the key actions that clear latched groups or modifiers.
-#                
-
-const  ##define        XkbSA_BreakLatch \
-       #        ((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\
-       #        (1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\
-       #        (1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\
-       #        (1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))
-       #
-  XkbSA_BreakLatch* = (1 shl XkbSA_PtrBtn) or (1 shl XkbSA_LockPtrBtn) or
-      (1 shl XkbSA_Terminate) or (1 shl XkbSA_SwitchScreen) or
-      (1 shl XkbSA_SetControls) or (1 shl XkbSA_LockControls) or
-      (1 shl XkbSA_ActionMessage) or (1 shl XkbSA_RedirectKey) or
-      (1 shl XkbSA_DeviceBtn) or (1 shl XkbSA_LockDeviceBtn) #
-                                                             #      Key Behavior Qualifier:
-                                                             #         KB_Permanent indicates that the behavior describes an unalterable
-                                                             #         characteristic of the keyboard, not an XKB software-simulation of
-                                                             #         the listed behavior.
-                                                             #      Key Behavior Types:
-                                                             #         Specifies the behavior of the underlying key.
-                                                             #                
-
-const 
-  XkbKB_Permanent* = 0x00000080
-  XkbKB_OpMask* = 0x0000007F
-  XkbKB_Default* = 0x00000000
-  XkbKB_Lock* = 0x00000001
-  XkbKB_RadioGroup* = 0x00000002
-  XkbKB_Overlay1* = 0x00000003
-  XkbKB_Overlay2* = 0x00000004
-  XkbKB_RGAllowNone* = 0x00000080 #
-                                  #      Various macros which describe the range of legal keycodes.
-                                  #                
-
-const 
-  XkbMinLegalKeyCode* = 8
-  XkbMaxLegalKeyCode* = 255
-  XkbMaxKeyCount* = XkbMaxLegalKeyCode - XkbMinLegalKeyCode + 1
-  XkbPerKeyBitArraySize* = (XkbMaxLegalKeyCode + 1) div 8
-
-proc XkbIsLegalKeycode*(k: int): bool
-type 
-  PXkbControlsPtr* = ptr TXkbControlsRec
-  TXkbControlsRec*{.final.} = object 
-    mk_dflt_btn*: int8
-    num_groups*: int8
-    groups_wrap*: int8
-    internal*: TXkbModsRec
-    ignore_lock*: TXkbModsRec
-    enabled_ctrls*: int16
-    repeat_delay*: int16
-    repeat_interval*: int16
-    slow_keys_delay*: int16
-    debounce_delay*: int16
-    mk_delay*: int16
-    mk_interval*: int16
-    mk_time_to_max*: int16
-    mk_max_speed*: int16
-    mk_curve*: int16
-    ax_options*: int16
-    ax_timeout*: int16
-    axt_opts_mask*: int16
-    axt_opts_values*: int16
-    axt_ctrls_mask*: int16
-    axt_ctrls_values*: int16
-    per_key_repeat*: array[0..XkbPerKeyBitArraySize - 1, int8]
-
-
-proc XkbAX_AnyFeedback*(c: PXkbControlsPtr): int16
-proc XkbAX_NeedOption*(c: PXkbControlsPtr, w: int16): int16
-proc XkbAX_NeedFeedback*(c: PXkbControlsPtr, w: int16): bool
-  #
-  #      Assorted constants and limits.
-  #                
-const 
-  XkbNumModifiers* = 8
-  XkbNumVirtualMods* = 16
-  XkbNumIndicators* = 32
-  XkbMaxRadioGroups* = 32
-  XkbAllRadioGroupsMask* = 0xFFFFFFFF
-  XkbMaxShiftLevel* = 63
-  XkbMaxSymsPerKey* = XkbMaxShiftLevel * XkbNumKbdGroups
-  XkbRGMaxMembers* = 12
-  XkbActionMessageLength* = 6
-  XkbKeyNameLength* = 4
-  XkbMaxRedirectCount* = 8
-  XkbGeomPtsPerMM* = 10
-  XkbGeomMaxColors* = 32
-  XkbGeomMaxLabelColors* = 3
-  XkbGeomMaxPriority* = 255
-
-type 
-  PXkbServerMapPtr* = ptr TXkbServerMapRec
-  TXkbServerMapRec*{.final.} = object 
-    num_acts*: int16
-    size_acts*: int16
-    acts*: ptr array[0..0xfff, TXkbAction]
-    behaviors*: PXkbBehavior
-    key_acts*: PWord
-    explicit*: PByte
-    vmods*: array[0..XkbNumVirtualMods - 1, int8]
-    vmodmap*: PWord
-
-
-proc XkbSMKeyActionsPtr*(m: PXkbServerMapPtr, k: int16): PXkbAction
-  #
-  #          Structures and access macros used primarily by clients
-  #        
-type 
-  PXkbSymMapPtr* = ptr TXkbSymMapRec
-  TXkbSymMapRec*{.final.} = object 
-    kt_index*: array[0..XkbNumKbdGroups - 1, int8]
-    group_info*: int8
-    width*: int8
-    offset*: int8
-
-
-type 
-  PXkbClientMapPtr* = ptr TXkbClientMapRec
-  TXkbClientMapRec*{.final.} = object 
-    size_types*: int8
-    num_types*: int8
-    types*: ptr array[0..0xffff, TXkbKeyTypeRec]
-    size_syms*: int16
-    num_syms*: int16
-    syms*: ptr array[0..0xffff, TKeySym]
-    key_sym_map*: ptr array[0..0xffff, TXkbSymMapRec]
-    modmap*: PByte
-
-
-proc XkbCMKeyGroupInfo*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyNumGroups*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyGroupWidth*(m: PXkbClientMapPtr, k: int16, g: int8): int8
-proc XkbCMKeyGroupsWidth*(m: PXkbClientMapPtr, k: int16): int8
-proc XkbCMKeyTypeIndex*(m: PXkbClientMapPtr, k: int16, g: int8): int8
-proc XkbCMKeyType*(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr
-proc XkbCMKeyNumSyms*(m: PXkbClientMapPtr, k: int16): int16
-proc XkbCMKeySymsOffset*(m: PXkbClientMapPtr, k: int16): int8
-  #
-  #          Compatibility structures and access macros
-  #        
-type 
-  PXkbSymInterpretPtr* = ptr TXkbSymInterpretRec
-  TXkbSymInterpretRec*{.final.} = object 
-    sym*: TKeySym
-    flags*: int8
-    match*: int8
-    mods*: int8
-    virtual_mod*: int8
-    act*: TXkbAnyAction
-
-
-type 
-  PXkbCompatMapPtr* = ptr TXkbCompatMapRec
-  TXkbCompatMapRec*{.final.} = object 
-    sym_interpret*: PXkbSymInterpretPtr
-    groups*: array[0..XkbNumKbdGroups - 1, TXkbModsRec]
-    num_si*: int16
-    size_si*: int16
-
-
-type 
-  PXkbIndicatorMapPtr* = ptr TXkbIndicatorMapRec
-  TXkbIndicatorMapRec*{.final.} = object 
-    flags*: int8
-    which_groups*: int8
-    groups*: int8
-    which_mods*: int8
-    mods*: TXkbModsRec
-    ctrls*: int16
-
-
-proc XkbIM_IsAuto*(i: PXkbIndicatorMapPtr): bool
-proc XkbIM_InUse*(i: PXkbIndicatorMapPtr): bool
-type 
-  PXkbIndicatorPtr* = ptr TXkbIndicatorRec
-  TXkbIndicatorRec*{.final.} = object 
-    phys_indicators*: int32
-    maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
-
-
-type 
-  PXkbKeyNamePtr* = ptr TXkbKeyNameRec
-  TXkbKeyNameRec*{.final.} = object 
-    name*: array[0..XkbKeyNameLength - 1, Char]
-
-
-type 
-  PXkbKeyAliasPtr* = ptr TXkbKeyAliasRec
-  TXkbKeyAliasRec*{.final.} = object  #
-                                      #          Names for everything
-                                      #        
-    float*: array[0..XkbKeyNameLength - 1, Char]
-    alias*: array[0..XkbKeyNameLength - 1, Char]
-
-
-type 
-  PXkbNamesPtr* = ptr TXkbNamesRec
-  TXkbNamesRec*{.final.} = object  #
-                                   #      Key Type index and mask for the four standard key types.
-                                   #                
-    keycodes*: TAtom
-    geometry*: TAtom
-    symbols*: TAtom
-    types*: TAtom
-    compat*: TAtom
-    vmods*: array[0..XkbNumVirtualMods - 1, TAtom]
-    indicators*: array[0..XkbNumIndicators - 1, TAtom]
-    groups*: array[0..XkbNumKbdGroups - 1, TAtom]
-    keys*: PXkbKeyNamePtr
-    key_aliases*: PXkbKeyAliasPtr
-    radio_groups*: PAtom
-    phys_symbols*: TAtom
-    num_keys*: int8
-    num_key_aliases*: int8
-    num_rg*: int16
-
-
-const 
-  XkbOneLevelIndex* = 0
-  XkbTwoLevelIndex* = 1
-  XkbAlphabeticIndex* = 2
-  XkbKeypadIndex* = 3
-  XkbLastRequiredType* = XkbKeypadIndex
-  XkbNumRequiredTypes* = XkbLastRequiredType + 1
-  XkbMaxKeyTypes* = 255
-  XkbOneLevelMask* = 1 shl 0
-  XkbTwoLevelMask* = 1 shl 1
-  XkbAlphabeticMask* = 1 shl 2
-  XkbKeypadMask* = 1 shl 3
-  XkbAllRequiredTypes* = 0x0000000F
-
-proc XkbShiftLevel*(n: int8): int8
-proc XkbShiftLevelMask*(n: int8): int8
-  #
-  #      Extension name and version information
-  #                
-const 
-  XkbName* = "XKEYBOARD"
-  XkbMajorVersion* = 1
-  XkbMinorVersion* = 0 #
-                       #      Explicit map components:
-                       #       - Used in the 'explicit' field of an XkbServerMap.  Specifies
-                       #         the keyboard components that should _not_ be updated automatically
-                       #         in response to core protocol keyboard mapping requests.
-                       #                
-
-const 
-  XkbExplicitKeyTypesMask* = 0x0000000F
-  XkbExplicitKeyType1Mask* = 1 shl 0
-  XkbExplicitKeyType2Mask* = 1 shl 1
-  XkbExplicitKeyType3Mask* = 1 shl 2
-  XkbExplicitKeyType4Mask* = 1 shl 3
-  XkbExplicitInterpretMask* = 1 shl 4
-  XkbExplicitAutoRepeatMask* = 1 shl 5
-  XkbExplicitBehaviorMask* = 1 shl 6
-  XkbExplicitVModMapMask* = 1 shl 7
-  XkbAllExplicitMask* = 0x000000FF #
-                                   #      Symbol interpretations flags:
-                                   #       - Used in the flags field of a symbol interpretation
-                                   #                
-
-const 
-  XkbSI_AutoRepeat* = 1 shl 0
-  XkbSI_LockingKey* = 1 shl 1 #
-                              #      Symbol interpretations match specification:
-                              #       - Used in the match field of a symbol interpretation to specify
-                              #         the conditions under which an interpretation is used.
-                              #                
-
-const 
-  XkbSI_LevelOneOnly* = 0x00000080
-  XkbSI_OpMask* = 0x0000007F
-  XkbSI_NoneOf* = 0
-  XkbSI_AnyOfOrNone* = 1
-  XkbSI_AnyOf* = 2
-  XkbSI_AllOf* = 3
-  XkbSI_Exactly* = 4 #
-                     #      Indicator map flags:
-                     #       - Used in the flags field of an indicator map to indicate the
-                     #         conditions under which and indicator can be changed and the
-                     #         effects of changing the indicator.
-                     #                
-
-const 
-  XkbIM_NoExplicit* = int(1) shl 7
-  XkbIM_NoAutomatic* = int(1) shl 6
-  XkbIM_LEDDrivesKB* = int(1) shl 5 #
-                                    #      Indicator map component specifications:
-                                    #       - Used by the 'which_groups' and 'which_mods' fields of an indicator
-                                    #         map to specify which keyboard components should be used to drive
-                                    #         the indicator.
-                                    #                
-
-const 
-  XkbIM_UseBase* = int(1) shl 0
-  XkbIM_UseLatched* = int(1) shl 1
-  XkbIM_UseLocked* = int(1) shl 2
-  XkbIM_UseEffective* = int(1) shl 3
-  XkbIM_UseCompat* = int(1) shl 4
-  XkbIM_UseNone* = 0
-  XkbIM_UseAnyGroup* = XkbIM_UseBase or XkbIM_UseLatched or XkbIM_UseLocked or
-      XkbIM_UseEffective
-  XkbIM_UseAnyMods* = XkbIM_UseAnyGroup or XkbIM_UseCompat #
-                                                           #      GetByName components:
-                                                           #       - Specifies desired or necessary components to GetKbdByName request.
-                                                           #       - Reports the components that were found in a GetKbdByNameReply
-                                                           #                
-
-const 
-  XkbGBN_TypesMask* = int(1) shl 0
-  XkbGBN_CompatMapMask* = int(1) shl 1
-  XkbGBN_ClientSymbolsMask* = int(1) shl 2
-  XkbGBN_ServerSymbolsMask* = int(1) shl 3
-  XkbGBN_SymbolsMask* = XkbGBN_ClientSymbolsMask or XkbGBN_ServerSymbolsMask
-  XkbGBN_IndicatorMapMask* = int(1) shl 4
-  XkbGBN_KeyNamesMask* = int(1) shl 5
-  XkbGBN_GeometryMask* = int(1) shl 6
-  XkbGBN_OtherNamesMask* = int(1) shl 7
-  XkbGBN_AllComponentsMask* = 0x000000FF #
-                                         #       ListComponents flags
-                                         #                        
-
-const 
-  XkbLC_Hidden* = int(1) shl 0
-  XkbLC_Default* = int(1) shl 1
-  XkbLC_Partial* = int(1) shl 2
-  XkbLC_AlphanumericKeys* = int(1) shl 8
-  XkbLC_ModifierKeys* = int(1) shl 9
-  XkbLC_KeypadKeys* = int(1) shl 10
-  XkbLC_FunctionKeys* = int(1) shl 11
-  XkbLC_AlternateGroup* = int(1) shl 12 #
-                                        #      X Input Extension Interactions
-                                        #      - Specifies the possible interactions between XKB and the X input
-                                        #        extension
-                                        #      - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)
-                                        #        XKB information about an extension device.
-                                        #      - Reports the list of supported optional features in the reply to
-                                        #        XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.
-                                        #      XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify
-                                        #      events to indicate an attempt to use an unsupported feature.
-                                        #                
-
-const 
-  XkbXI_KeyboardsMask* = int(1) shl 0
-  XkbXI_ButtonActionsMask* = int(1) shl 1
-  XkbXI_IndicatorNamesMask* = int(1) shl 2
-  XkbXI_IndicatorMapsMask* = int(1) shl 3
-  XkbXI_IndicatorStateMask* = int(1) shl 4
-  XkbXI_UnsupportedFeatureMask* = int(1) shl 15
-  XkbXI_AllFeaturesMask* = 0x0000001F
-  XkbXI_AllDeviceFeaturesMask* = 0x0000001E
-  XkbXI_IndicatorsMask* = 0x0000001C
-  XkbAllExtensionDeviceEventsMask* = 0x0000801F #
-                                                #      Per-Client Flags:
-                                                #       - Specifies flags to be changed by the PerClientFlags request.
-                                                #                
-
-const 
-  XkbPCF_DetectableAutoRepeatMask* = int(1) shl 0
-  XkbPCF_GrabsUseXKBStateMask* = int(1) shl 1
-  XkbPCF_AutoResetControlsMask* = int(1) shl 2
-  XkbPCF_LookupStateWhenGrabbed* = int(1) shl 3
-  XkbPCF_SendEventUsesXKBState* = int(1) shl 4
-  XkbPCF_AllFlagsMask* = 0x0000001F #
-                                    #      Debugging flags and controls
-                                    #                
-
-const 
-  XkbDF_DisableLocks* = 1 shl 0
-
-type 
-  PXkbPropertyPtr* = ptr TXkbPropertyRec
-  TXkbPropertyRec*{.final.} = object 
-    name*: cstring
-    value*: cstring
-
-
-type 
-  PXkbColorPtr* = ptr TXkbColorRec
-  TXkbColorRec*{.final.} = object 
-    pixel*: int16
-    spec*: cstring
-
-
-type 
-  PXkbPointPtr* = ptr TXkbPointRec
-  TXkbPointRec*{.final.} = object 
-    x*: int16
-    y*: int16
-
-
-type 
-  PXkbBoundsPtr* = ptr TXkbBoundsRec
-  TXkbBoundsRec*{.final.} = object 
-    x1*: int16
-    y1*: int16
-    x2*: int16
-    y2*: int16
-
-
-proc XkbBoundsWidth*(b: PXkbBoundsPtr): int16
-proc XkbBoundsHeight*(b: PXkbBoundsPtr): int16
-type 
-  PXkbOutlinePtr* = ptr TXkbOutlineRec
-  TXkbOutlineRec*{.final.} = object 
-    num_points*: int16
-    sz_points*: int16
-    corner_radius*: int16
-    points*: PXkbPointPtr
-
-
-type 
-  PXkbShapePtr* = ptr TXkbShapeRec
-  TXkbShapeRec*{.final.} = object 
-    name*: TAtom
-    num_outlines*: int16
-    sz_outlines*: int16
-    outlines*: ptr array [0..0xffff, TXkbOutlineRec]
-    approx*: ptr array[0..0xffff, TXkbOutlineRec]
-    primary*: ptr array[0..0xffff, TXkbOutlineRec]
-    bounds*: TXkbBoundsRec
-
-
-proc XkbOutlineIndex*(s: PXkbShapePtr, o: PXkbOutlinePtr): int32
-type 
-  PXkbShapeDoodadPtr* = ptr TXkbShapeDoodadRec
-  TXkbShapeDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    color_ndx*: int16
-    shape_ndx*: int16
-
-
-type 
-  PXkbTextDoodadPtr* = ptr TXkbTextDoodadRec
-  TXkbTextDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    width*: int16
-    height*: int16
-    color_ndx*: int16
-    text*: cstring
-    font*: cstring
-
-
-type 
-  PXkbIndicatorDoodadPtr* = ptr TXkbIndicatorDoodadRec
-  TXkbIndicatorDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    shape_ndx*: int16
-    on_color_ndx*: int16
-    off_color_ndx*: int16
-
-
-type 
-  PXkbLogoDoodadPtr* = ptr TXkbLogoDoodadRec
-  TXkbLogoDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-    color_ndx*: int16
-    shape_ndx*: int16
-    logo_name*: cstring
-
-
-type 
-  PXkbAnyDoodadPtr* = ptr TXkbAnyDoodadRec
-  TXkbAnyDoodadRec*{.final.} = object 
-    name*: TAtom
-    theType*: int8
-    priority*: int8
-    top*: int16
-    left*: int16
-    angle*: int16
-
-
-type 
-  PXkbDoodadPtr* = ptr TXkbDoodadRec
-  TXkbDoodadRec*{.final.} = object 
-    any*: TXkbAnyDoodadRec
-    shape*: TXkbShapeDoodadRec
-    text*: TXkbTextDoodadRec
-    indicator*: TXkbIndicatorDoodadRec
-    logo*: TXkbLogoDoodadRec
-
-
-const 
-  XkbUnknownDoodad* = 0
-  XkbOutlineDoodad* = 1
-  XkbSolidDoodad* = 2
-  XkbTextDoodad* = 3
-  XkbIndicatorDoodad* = 4
-  XkbLogoDoodad* = 5
-
-type 
-  PXkbKeyPtr* = ptr TXkbKeyRec
-  TXkbKeyRec*{.final.} = object 
-    name*: TXkbKeyNameRec
-    gap*: int16
-    shape_ndx*: int8
-    color_ndx*: int8
-
-
-type 
-  PXkbRowPtr* = ptr TXkbRowRec
-  TXkbRowRec*{.final.} = object 
-    top*: int16
-    left*: int16
-    num_keys*: int16
-    sz_keys*: int16
-    vertical*: int16
-    Keys*: PXkbKeyPtr
-    bounds*: TXkbBoundsRec
-
-
-type 
-  PXkbOverlayPtr* = ptr TXkbOverlayRec #forward for TXkbSectionRec use.
-                                       #Do not add more "type"
-  PXkbSectionPtr* = ptr TXkbSectionRec
-  TXkbSectionRec*{.final.} = object  #Do not add more "type"
-    name*: TAtom
-    priority*: int8
-    top*: int16
-    left*: int16
-    width*: int16
-    height*: int16
-    angle*: int16
-    num_rows*: int16
-    num_doodads*: int16
-    num_overlays*: int16
-    rows*: PXkbRowPtr
-    doodads*: PXkbDoodadPtr
-    bounds*: TXkbBoundsRec
-    overlays*: PXkbOverlayPtr
-
-  PXkbOverlayKeyPtr* = ptr TXkbOverlayKeyRec
-  TXkbOverlayKeyRec*{.final.} = object  #Do not add more "type"
-    over*: TXkbKeyNameRec
-    under*: TXkbKeyNameRec
-
-  PXkbOverlayRowPtr* = ptr TXkbOverlayRowRec
-  TXkbOverlayRowRec*{.final.} = object  #Do not add more "type"
-    row_under*: int16
-    num_keys*: int16
-    sz_keys*: int16
-    keys*: PXkbOverlayKeyPtr
-
-  TXkbOverlayRec*{.final.} = object 
-    name*: TAtom
-    section_under*: PXkbSectionPtr
-    num_rows*: int16
-    sz_rows*: int16
-    rows*: PXkbOverlayRowPtr
-    bounds*: PXkbBoundsPtr
-
-
-type 
-  PXkbGeometryRec* = ptr TXkbGeometryRec
-  PXkbGeometryPtr* = PXkbGeometryRec
-  TXkbGeometryRec*{.final.} = object 
-    name*: TAtom
-    width_mm*: int16
-    height_mm*: int16
-    label_font*: cstring
-    label_color*: PXkbColorPtr
-    base_color*: PXkbColorPtr
-    sz_properties*: int16
-    sz_colors*: int16
-    sz_shapes*: int16
-    sz_sections*: int16
-    sz_doodads*: int16
-    sz_key_aliases*: int16
-    num_properties*: int16
-    num_colors*: int16
-    num_shapes*: int16
-    num_sections*: int16
-    num_doodads*: int16
-    num_key_aliases*: int16
-    properties*: ptr array[0..0xffff, TXkbPropertyRec]
-    colors*: ptr array[0..0xffff, TXkbColorRec]
-    shapes*: ptr array[0..0xffff, TXkbShapeRec]
-    sections*: ptr array[0..0xffff, TXkbSectionRec]
-    key_aliases*: ptr array[0..0xffff, TXkbKeyAliasRec]
-
-
-const 
-  XkbGeomPropertiesMask* = 1 shl 0
-  XkbGeomColorsMask* = 1 shl 1
-  XkbGeomShapesMask* = 1 shl 2
-  XkbGeomSectionsMask* = 1 shl 3
-  XkbGeomDoodadsMask* = 1 shl 4
-  XkbGeomKeyAliasesMask* = 1 shl 5
-  XkbGeomAllMask* = 0x0000003F
-
-type 
-  PXkbGeometrySizesPtr* = ptr TXkbGeometrySizesRec
-  TXkbGeometrySizesRec*{.final.} = object  #
-                                           #          Tie it all together into one big keyboard description
-                                           #        
-    which*: int16
-    num_properties*: int16
-    num_colors*: int16
-    num_shapes*: int16
-    num_sections*: int16
-    num_doodads*: int16
-    num_key_aliases*: int16
-
-
-type 
-  PXkbDescPtr* = ptr TXkbDescRec
-  TXkbDescRec*{.final.} = object 
-    dpy*: PDisplay
-    flags*: int16
-    device_spec*: int16
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    ctrls*: PXkbControlsPtr
-    server*: PXkbServerMapPtr
-    map*: PXkbClientMapPtr
-    indicators*: PXkbIndicatorPtr
-    names*: PXkbNamesPtr
-    compat*: PXkbCompatMapPtr
-    geom*: PXkbGeometryPtr
-
-
-proc XkbKeyKeyTypeIndex*(d: PXkbDescPtr, k: int16, g: int8): int8
-proc XkbKeyKeyType*(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr
-proc XkbKeyGroupWidth*(d: PXkbDescPtr, k: int16, g: int8): int8
-proc XkbKeyGroupsWidth*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyGroupInfo*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyNumGroups*(d: PXkbDescPtr, k: int16): int8
-proc XkbKeyNumSyms*(d: PXkbDescPtr, k: int16): int16
-proc XkbKeySym*(d: PXkbDescPtr, k: int16, n: int16): TKeySym
-proc XkbKeySymEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym
-proc XkbKeyAction*(d: PXkbDescPtr, k: int16, n: int16): PXkbAction
-proc XkbKeyActionEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8
-proc XkbKeyHasActions*(d: PXkbDescPtr, k: int16): bool
-proc XkbKeyNumActions*(d: PXkbDescPtr, k: int16): int16
-proc XkbKeyActionsPtr*(d: PXkbDescPtr, k: int16): PXkbAction
-proc XkbKeycodeInRange*(d: PXkbDescPtr, k: int16): bool
-proc XkbNumKeys*(d: PXkbDescPtr): int8
-  #
-  #          The following structures can be used to track changes
-  #          to a keyboard device
-  #        
-type 
-  PXkbMapChangesPtr* = ptr TXkbMapChangesRec
-  TXkbMapChangesRec*{.final.} = object 
-    changed*: int16
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    first_type*: int8
-    num_types*: int8
-    first_key_sym*: TKeyCode
-    num_key_syms*: int8
-    first_key_act*: TKeyCode
-    num_key_acts*: int8
-    first_key_behavior*: TKeyCode
-    num_key_behaviors*: int8
-    first_key_explicit*: TKeyCode
-    num_key_explicit*: int8
-    first_modmap_key*: TKeyCode
-    num_modmap_keys*: int8
-    first_vmodmap_key*: TKeyCode
-    num_vmodmap_keys*: int8
-    pad*: int8
-    vmods*: int16
-
-
-type 
-  PXkbControlsChangesPtr* = ptr TXkbControlsChangesRec
-  TXkbControlsChangesRec*{.final.} = object 
-    changed_ctrls*: int16
-    enabled_ctrls_changes*: int16
-    num_groups_changed*: bool
-
-
-type 
-  PXkbIndicatorChangesPtr* = ptr TXkbIndicatorChangesRec
-  TXkbIndicatorChangesRec*{.final.} = object 
-    state_changes*: int16
-    map_changes*: int16
-
-
-type 
-  PXkbNameChangesPtr* = ptr TXkbNameChangesRec
-  TXkbNameChangesRec*{.final.} = object 
-    changed*: int16
-    first_type*: int8
-    num_types*: int8
-    first_lvl*: int8
-    num_lvls*: int8
-    num_aliases*: int8
-    num_rg*: int8
-    first_key*: int8
-    num_keys*: int8
-    changed_vmods*: int16
-    changed_indicators*: int32
-    changed_groups*: int8
-
-
-type 
-  PXkbCompatChangesPtr* = ptr TXkbCompatChangesRec
-  TXkbCompatChangesRec*{.final.} = object 
-    changed_groups*: int8
-    first_si*: int16
-    num_si*: int16
-
-
-type 
-  PXkbChangesPtr* = ptr TXkbChangesRec
-  TXkbChangesRec*{.final.} = object  #
-                                     #          These data structures are used to construct a keymap from
-                                     #          a set of components or to list components in the server
-                                     #          database.
-                                     #        
-    device_spec*: int16
-    state_changes*: int16
-    map*: TXkbMapChangesRec
-    ctrls*: TXkbControlsChangesRec
-    indicators*: TXkbIndicatorChangesRec
-    names*: TXkbNameChangesRec
-    compat*: TXkbCompatChangesRec
-
-
-type 
-  PXkbComponentNamesPtr* = ptr TXkbComponentNamesRec
-  TXkbComponentNamesRec*{.final.} = object 
-    keymap*: ptr int16
-    keycodes*: ptr int16
-    types*: ptr int16
-    compat*: ptr int16
-    symbols*: ptr int16
-    geometry*: ptr int16
-
-
-type 
-  PXkbComponentNamePtr* = ptr TXkbComponentNameRec
-  TXkbComponentNameRec*{.final.} = object 
-    flags*: int16
-    name*: cstring
-
-
-type 
-  PXkbComponentListPtr* = ptr TXkbComponentListRec
-  TXkbComponentListRec*{.final.} = object  #
-                                           #          The following data structures describe and track changes to a
-                                           #          non-keyboard extension device
-                                           #        
-    num_keymaps*: int16
-    num_keycodes*: int16
-    num_types*: int16
-    num_compat*: int16
-    num_symbols*: int16
-    num_geometry*: int16
-    keymaps*: PXkbComponentNamePtr
-    keycodes*: PXkbComponentNamePtr
-    types*: PXkbComponentNamePtr
-    compat*: PXkbComponentNamePtr
-    symbols*: PXkbComponentNamePtr
-    geometry*: PXkbComponentNamePtr
-
-
-type 
-  PXkbDeviceLedInfoPtr* = ptr TXkbDeviceLedInfoRec
-  TXkbDeviceLedInfoRec*{.final.} = object 
-    led_class*: int16
-    led_id*: int16
-    phys_indicators*: int16
-    maps_present*: int16
-    names_present*: int16
-    state*: int16
-    names*: array[0..XkbNumIndicators - 1, TAtom]
-    maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
-
-
-type 
-  PXkbDeviceInfoPtr* = ptr TXkbDeviceInfoRec
-  TXkbDeviceInfoRec*{.final.} = object 
-    name*: cstring
-    theType*: TAtom
-    device_spec*: int16
-    has_own_state*: bool
-    supported*: int16
-    unsupported*: int16
-    num_btns*: int16
-    btn_acts*: PXkbAction
-    sz_leds*: int16
-    num_leds*: int16
-    dflt_kbd_fb*: int16
-    dflt_led_fb*: int16
-    leds*: PXkbDeviceLedInfoPtr
-
-
-proc XkbXI_DevHasBtnActs*(d: PXkbDeviceInfoPtr): bool
-proc XkbXI_LegalDevBtn*(d: PXkbDeviceInfoPtr, b: int16): bool
-proc XkbXI_DevHasLeds*(d: PXkbDeviceInfoPtr): bool
-type 
-  PXkbDeviceLedChangesPtr* = ptr TXkbDeviceLedChangesRec
-  TXkbDeviceLedChangesRec*{.final.} = object 
-    led_class*: int16
-    led_id*: int16
-    defined*: int16           #names or maps changed
-    next*: PXkbDeviceLedChangesPtr
-
-
-type 
-  PXkbDeviceChangesPtr* = ptr TXkbDeviceChangesRec
-  TXkbDeviceChangesRec*{.final.} = object 
-    changed*: int16
-    first_btn*: int16
-    num_btns*: int16
-    leds*: TXkbDeviceLedChangesRec
-
-
-proc XkbShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr
-proc XkbShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr
-proc XkbSetShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                             c: PXkbColorPtr)
-proc XkbSetShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                             s: PXkbShapePtr)
-proc XkbTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr
-proc XkbSetTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, 
-                            c: PXkbColorPtr)
-proc XkbIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr
-proc XkbIndicatorDoodadOnColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
-proc XkbIndicatorDoodadOffColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
-proc XkbSetIndicatorDoodadOnColor*(g: PXkbGeometryPtr, 
-                                   d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
-proc XkbSetIndicatorDoodadOffColor*(g: PXkbGeometryPtr, 
-                                    d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
-proc XkbSetIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                 s: PXkbShapeDoodadPtr)
-proc XkbLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr
-proc XkbLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr
-proc XkbSetLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                            c: PXkbColorPtr)
-proc XkbSetLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                            s: PXkbShapeDoodadPtr)
-proc XkbKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr
-proc XkbKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr
-proc XkbSetKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr)
-proc XkbSetKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr)
-proc XkbGeomColorIndex*(g: PXkbGeometryPtr, c: PXkbColorPtr): int32
-proc XkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, value: cstring): PXkbPropertyPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomProperty".}
-proc XkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-proc XkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
-proc XkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
-proc XkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, sz_outlines: int16): PXkbShapePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomShape".}
-proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbAddGeomKey".}
-proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbAddGeomRow".}
-proc XkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, 
-                        sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
-proc XkbAddGeomOverlay*(section: PXkbSectionPtr, name: TAtom, sz_rows: int16): PXkbOverlayPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOverlay".}
-proc XkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, 
-                           sz_keys: int16): PXkbOverlayRowPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
-proc XkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                           over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-proc XkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                       name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbAddGeomDoodad".}
-proc XkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                            freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomKeyAliases".}
-proc XkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomColors".}
-proc XkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, freeAll: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeomDoodads".}
-proc XkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                            freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomProperties".}
-proc XkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOverlayKeys".}
-proc XkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, 
-                             count: int16, freeAll: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
-proc XkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOverlays".}
-proc XkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, freeAll: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeomKeys".}
-proc XkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, 
-                      freeAll: bool){.cdecl, dynlib: libX11, 
-                                      importc: "XkbFreeGeomRows".}
-proc XkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomSections".}
-proc XkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomPoints".}
-proc XkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, 
-                          freeAll: bool){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeGeomOutlines".}
-proc XkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                        freeAll: bool){.cdecl, dynlib: libX11, 
-                                        importc: "XkbFreeGeomShapes".}
-proc XkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
-proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomProps".}
-proc XkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
-proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomColors".}
-proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomShapes".}
-proc XkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
-proc XkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
-proc XkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
-proc XkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
-proc XkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
-proc XkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
-proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomOutlines".}
-proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomRows".}
-proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomPoints".}
-proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocGeomKeys".}
-proc XkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
-proc XkbSetGeometryProc*(dpy: PDisplay, deviceSpec: int16, geom: PXkbGeometryPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbSetGeometry".}
-proc XkbComputeShapeTop*(shape: PXkbShapePtr, bounds: PXkbBoundsPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbComputeShapeTop".}
-proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeShapeBounds".}
-proc XkbComputeRowBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                          row: PXkbRowPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeRowBounds".}
-proc XkbComputeSectionBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbComputeSectionBounds".}
-proc XkbFindOverlayForKey*(geom: PXkbGeometryPtr, wanted: PXkbSectionPtr, 
-                           under: cstring): cstring{.cdecl, dynlib: libX11, 
-    importc: "XkbFindOverlayForKey".}
-proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetGeometry".}
-proc XkbGetNamedGeometry*(dpy: PDisplay, xkb: PXkbDescPtr, name: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetNamedGeometry".}
-when defined(XKB_IN_SERVER): 
-  proc SrvXkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, 
-                              float: cstring): PXkbKeyAliasPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-  proc SrvXkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
-  proc SrvXkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, 
-                            name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, 
-      importc: "XkbAddGeomDoodad".}
-  proc SrvXkbAddGeomKey*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
-  proc SrvXkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
-  proc SrvXkbAddGeomOverlay*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                             over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-  proc SrvXkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, 
-                                sz_keys: int16): PXkbOverlayRowPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
-  proc SrvXkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, 
-                                over: cstring, under: cstring): PXkbOverlayKeyPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
-  proc SrvXkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, 
-                              value: cstring): PXkbPropertyPtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomProperty".}
-  proc SrvXkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomRow".}
-  proc SrvXkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, 
-                             sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
-      cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
-  proc SrvXkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, 
-                           sz_outlines: int16): PXkbShapePtr{.cdecl, 
-      dynlib: libX11, importc: "XkbAddGeomShape".}
-  proc SrvXkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
-  proc SrvXkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomColors".}
-  proc SrvXkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
-  proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, 
-      dynlib: libX11, importc: "XkbAllocGeomKeys".}
-  proc SrvXkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOutlines".}
-  proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, 
-      dynlib: libX11, importc: "XkbAllocGeomPoints".}
-  proc SrvXkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomProps".}
-  proc SrvXkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomRows".}
-  proc SrvXkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
-  proc SrvXkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
-  proc SrvXkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
-  proc SrvXkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
-  proc SrvXkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
-  proc SrvXkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeomShapes".}
-  proc SrvXkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
-      cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
-  proc SrvXkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, 
-                                 count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomKeyAliases".}
-  proc SrvXkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomColors".}
-  proc SrvXkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, 
-                              freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomDoodads".}
-  proc SrvXkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, 
-                                 count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomProperties".}
-  proc SrvXkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, 
-                                  count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlayKeys".}
-  proc SrvXkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, 
-                                  count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
-  proc SrvXkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, 
-                               count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomOverlays".}
-  proc SrvXkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, 
-                           freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomKeys".}
-  proc SrvXkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, 
-                           freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomRows".}
-  proc SrvXkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, 
-                               count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomSections".}
-  proc SrvXkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, 
-                             count: int16, freeAll: bool){.cdecl, 
-      dynlib: libX11, importc: "XkbFreeGeomPoints".}
-  proc SrvXkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, 
-                               freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomOutlines".}
-  proc SrvXkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, 
-                             freeAll: bool){.cdecl, dynlib: libX11, 
-      importc: "XkbFreeGeomShapes".}
-  proc SrvXkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
-      cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
-# implementation
-
-import                        #************************************ xkb ************************************
-  xi
-
-proc XkbLegalXILedClass(c: int): bool = 
-  ##define XkbLegalXILedClass(c) (((c)==KbdFeedbackClass)||((c)==LedFeedbackClass)||
-  #                                ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
-  Result = (c == KbdFeedbackClass) or (c == LedFeedbackClass) or
-      (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
-
-proc XkbLegalXIBellClass(c: int): bool = 
-  ##define XkbLegalXIBellClass(c) (((c)==KbdFeedbackClass)||((c)==BellFeedbackClass)||
-  #                                 ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
-  Result = (c == KbdFeedbackClass) or (c == BellFeedbackClass) or
-      (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
-
-proc XkbExplicitXIDevice(c: int): bool = 
-  ##define XkbExplicitXIDevice(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbExplicitXIClass(c: int): bool = 
-  ##define XkbExplicitXIClass(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbExplicitXIId(c: int): bool = 
-  ##define XkbExplicitXIId(c) (((c)&(~0xff))==0)
-  Result = (c and (not 0x000000FF)) == 0
-
-proc XkbSingleXIClass(c: int): bool = 
-  ##define XkbSingleXIClass(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))
-  Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIClass)
-
-proc XkbSingleXIId(c: int): bool = 
-  ##define XkbSingleXIId(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIId))
-  Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIId)
-
-proc XkbBuildCoreState(m, g: int): int = 
-  ##define XkbBuildCoreState(m,g) ((((g)&0x3)<<13)|((m)&0xff))
-  Result = ((g and 0x00000003) shl 13) or (m and 0x000000FF)
-
-proc XkbGroupForCoreState(s: int): int = 
-  ##define XkbGroupForCoreState(s) (((s)>>13)&0x3)
-  Result = (s shr 13) and 0x00000003
-
-proc XkbIsLegalGroup(g: int): bool = 
-  ##define XkbIsLegalGroup(g) (((g)>=0)&&((g)<XkbNumKbdGroups))
-  Result = (g >= 0) and (g < XkbNumKbdGroups)
-
-proc XkbSA_ValOp(a: int): int = 
-  ##define XkbSA_ValOp(a) ((a)&XkbSA_ValOpMask)
-  Result = a and XkbSA_ValOpMask
-
-proc XkbSA_ValScale(a: int): int = 
-  ##define XkbSA_ValScale(a) ((a)&XkbSA_ValScaleMask)
-  Result = a and XkbSA_ValScaleMask
-
-proc XkbIsModAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsModAction(a) (((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))
-  Result = (ze(a.theType) >= XkbSA_SetMods) and (ze(a.theType) <= XkbSA_LockMods)
-
-proc XkbIsGroupAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsGroupAction(a) (((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))
-  Result = (ze(a.theType) >= XkbSA_SetGroup) or (ze(a.theType) <= XkbSA_LockGroup)
-
-proc XkbIsPtrAction(a: PXkbAnyAction): bool = 
-  ##define XkbIsPtrAction(a) (((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))
-  Result = (ze(a.theType) >= XkbSA_MovePtr) and
-      (ze(a.theType) <= XkbSA_SetPtrDflt)
-
-proc XkbIsLegalKeycode(k: int): bool = 
-  ##define        XkbIsLegalKeycode(k)    (((k)>=XkbMinLegalKeyCode)&&((k)<=XkbMaxLegalKeyCode))
-  Result = (k >= XkbMinLegalKeyCode) and (k <= XkbMaxLegalKeyCode)
-
-proc XkbShiftLevel(n: int8): int8 = 
-  ##define XkbShiftLevel(n) ((n)-1)
-  Result = n - 1'i8
-
-proc XkbShiftLevelMask(n: int8): int8 = 
-  ##define XkbShiftLevelMask(n) (1<<((n)-1))
-  Result = 1'i8 shl (n - 1'i8)
-
-proc XkbCharToInt(v: int8): int16 = 
-  ##define XkbCharToInt(v) ((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))
-  if ((v and 0x80'i8) != 0'i8): Result = v or (not 0xFF'i16)
-  else: Result = int16(v and 0x7F'i8)
-  
-proc XkbIntTo2Chars(i: int16, h, L: var int8) = 
-  ##define XkbIntTo2Chars(i,h,l) (((h)=((i>>8)&0xff)),((l)=((i)&0xff)))
-  h = toU8((i shr 8'i16) and 0x00FF'i16)
-  L = toU8(i and 0xFF'i16)
-
-proc Xkb2CharsToInt(h, L: int8): int16 = 
-  when defined(cpu64): 
-    ##define Xkb2CharsToInt(h,l) ((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)): (int)(((h)<<8)|(l)&0x7fff))
-    if (h and 0x80'i8) != 0'i8: 
-      Result = toU16((ze(h) shl 8) or ze(L) or not 0x0000FFFF)
-    else: 
-      Result = toU16((ze(h) shl 8) or ze(L) and 0x00007FFF)
-  else: 
-    ##define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l)))
-    Result = toU16(ze(h) shl 8 or ze(L))
-
-proc XkbModLocks(s: PXkbStatePtr): int8 = 
-  ##define XkbModLocks(s) ((s)->locked_mods)
-  Result = s.locked_mods
-
-proc XkbStateMods(s: PXkbStatePtr): int16 = 
-  ##define XkbStateMods(s) ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))
-  Result = s.base_mods or s.latched_mods or XkbModLocks(s)
-
-proc XkbGroupLock(s: PXkbStatePtr): int8 = 
-  ##define XkbGroupLock(s) ((s)->locked_group)
-  Result = s.locked_group
-
-proc XkbStateGroup(s: PXkbStatePtr): int16 = 
-  ##define XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))
-  Result = S.base_group + (s.latched_group) + XkbGroupLock(s)
-
-proc XkbStateFieldFromRec(s: PXkbStatePtr): int = 
-  ##define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group)
-  Result = XkbBuildCoreState(s.lookup_mods, s.group)
-
-proc XkbGrabStateFromRec(s: PXkbStatePtr): int = 
-  ##define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group)
-  Result = XkbBuildCoreState(s.grab_mods, s.group)
-
-proc XkbNumGroups(g: int16): int16 = 
-  ##define XkbNumGroups(g) ((g)&0x0f)
-  Result = g and 0x0000000F'i16
-
-proc XkbOutOfRangeGroupInfo(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)
-  Result = g and 0x000000F0'i16
-
-proc XkbOutOfRangeGroupAction(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupAction(g) ((g)&0xc0)
-  Result = g and 0x000000C0'i16
-
-proc XkbOutOfRangeGroupNumber(g: int16): int16 = 
-  ##define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)
-  Result = (g and 0x00000030'i16) shr 4'i16
-
-proc XkbSetGroupInfo(g, w, n: int16): int16 = 
-  ##define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))
-  Result = (w and 0x000000C0'i16) or 
-    ((n and 3'i16) shl 4'i16) or (g and 0x0000000F'i16)
-
-proc XkbSetNumGroups(g, n: int16): int16 = 
-  ##define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))
-  Result = (g and 0x000000F0'i16) or (n and 0x0000000F'i16)
-
-proc XkbModActionVMods(a: PXkbModAction): int16 = 
-  ##define XkbModActionVMods(a) ((short)(((a)->vmods1<<8)|((a)->vmods2)))
-  Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods2))
-
-proc XkbSetModActionVMods(a: PXkbModAction, v: int8) = 
-  ##define XkbSetModActionVMods(a,v) (((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))
-  a.vmods1 = toU8((ze(v) shr 8) and 0x000000FF)
-  a.vmods2 = toU8(ze(v) and 0x000000FF)
-
-proc XkbSAGroup(a: PXkbGroupAction): int8 = 
-  ##define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX))
-  Result = int8(XkbCharToInt(a.group_XXX))
-
-proc XkbSASetGroupProc(a: PXkbGroupAction, g: int8) = 
-  ##define XkbSASetGroup(a,g) ((a)->group_XXX=(g))
-  a.group_XXX = g
-
-proc XkbPtrActionX(a: PXkbPtrAction): int16 = 
-  ##define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX))
-  Result = int16(Xkb2CharsToInt(a.high_XXX, a.low_XXX))
-
-proc XkbPtrActionY(a: PXkbPtrAction): int16 = 
-  ##define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY))
-  Result = int16(Xkb2CharsToInt(a.high_YYY, a.low_YYY))
-
-proc XkbSetPtrActionX(a: PXkbPtrAction, x: int8) = 
-  ##define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX))
-  XkbIntTo2Chars(x, a.high_XXX, a.low_XXX)
-
-proc XkbSetPtrActionY(a: PXkbPtrAction, y: int8) = 
-  ##define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY))
-  XkbIntTo2Chars(y, a.high_YYY, a.low_YYY)
-
-proc XkbSAPtrDfltValue(a: PXkbPtrDfltAction): int8 = 
-  ##define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX))
-  Result = int8(XkbCharToInt(a.valueXXX))
-
-proc XkbSASetPtrDfltValue(a: PXkbPtrDfltAction, c: pointer) = 
-  ##define XkbSASetPtrDfltValue(a,c) ((a)->valueXXX= ((c)&0xff))
-  a.valueXXX = toU8(cast[int](c))
-
-proc XkbSAScreen(a: PXkbSwitchScreenAction): int8 = 
-  ##define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX))
-  Result = toU8(XkbCharToInt(a.screenXXX))
-
-proc XkbSASetScreen(a: PXkbSwitchScreenAction, s: pointer) = 
-  ##define XkbSASetScreen(a,s) ((a)->screenXXX= ((s)&0xff))
-  a.screenXXX = toU8(cast[int](s))
-
-proc XkbActionSetCtrls(a: PXkbCtrlsAction, c: int8) = 
-  ##define XkbActionSetCtrls(a,c) (((a)->ctrls3=(((c)>>24)&0xff)),((a)->ctrls2=(((c)>>16)&0xff)),
-  #                                 ((a)->ctrls1=(((c)>>8)&0xff)),((a)->ctrls0=((c)&0xff)))        
-  a.ctrls3 = toU8((ze(c) shr 24) and 0x000000FF)
-  a.ctrls2 = toU8((ze(c) shr 16) and 0x000000FF)
-  a.ctrls1 = toU8((ze(c) shr 8) and 0x000000FF)
-  a.ctrls0 = toU8(ze(c) and 0x000000FF)
-
-proc XkbActionCtrls(a: PXkbCtrlsAction): int16 = 
-  ##define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|(((unsigned int)(a)->ctrls2)<<16)|
-  #                            (((unsigned int)(a)->ctrls1)<<8)|((unsigned int)((a)->ctrls0)))      
-  Result = toU16((ze(a.ctrls3) shl 24) or (ze(a.ctrls2) shl 16) or 
-     (ze(a.ctrls1) shl 8) or ze(a.ctrls0))
-
-proc XkbSARedirectVMods(a: PXkbRedirectKeyAction): int16 = 
-  ##define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|((unsigned int)(a)->vmods0))
-  Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods0))
-
-proc XkbSARedirectSetVMods(a: PXkbRedirectKeyAction, m: int8) = 
-  ##define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
-  a.vmods_mask1 = toU8((ze(m) shr 8) and 0x000000FF)
-  a.vmods_mask0 = toU8(ze(m) or 0x000000FF)
-
-proc XkbSARedirectVModsMask(a: PXkbRedirectKeyAction): int16 = 
-  ##define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|
-  #                                     ((unsigned int)(a)->vmods_mask0))
-  Result = toU16((ze(a.vmods_mask1) shl 8) or ze(a.vmods_mask0))
-
-proc XkbSARedirectSetVModsMask(a: PXkbRedirectKeyAction, m: int8) = 
-  ##define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
-  a.vmods_mask1 = toU8(ze(m) shr 8 and 0x000000FF)
-  a.vmods_mask0 = toU8(ze(m) and 0x000000FF)
-
-proc XkbAX_AnyFeedback(c: PXkbControlsPtr): int16 = 
-  ##define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask)
-  Result = toU16(ze(c.enabled_ctrls) and XkbAccessXFeedbackMask)
-
-proc XkbAX_NeedOption(c: PXkbControlsPtr, w: int16): int16 = 
-  ##define XkbAX_NeedOption(c,w) ((c)->ax_options&(w))
-  Result = toU16(ze(c.ax_options) and ze(w))
-
-proc XkbAX_NeedFeedback(c: PXkbControlsPtr, w: int16): bool = 
-  ##define XkbAX_NeedFeedback(c,w) (XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))
-  Result = (XkbAX_AnyFeedback(c) > 0'i16) and (XkbAX_NeedOption(c, w) > 0'i16)
-
-proc XkbSMKeyActionsPtr(m: PXkbServerMapPtr, k: int16): PXkbAction = 
-  ##define XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])
-  Result = addr(m.acts[ze(m.key_acts[ze(k)])])
-
-proc XkbCMKeyGroupInfo(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeyGroupInfo(m,k) ((m)->key_sym_map[k].group_info)
-  Result = m.key_sym_map[ze(k)].group_info
-
-proc XkbCMKeyNumGroups(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeyNumGroups(m,k) (XkbNumGroups((m)->key_sym_map[k].group_info))
-  Result = toU8(XkbNumGroups(m.key_sym_map[ze(k)].group_info))
-
-proc XkbCMKeyGroupWidth(m: PXkbClientMapPtr, k: int16, g: int8): int8 = 
-  ##define XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)
-  Result = XkbCMKeyType(m, k, g).num_levels
-
-proc XkbCMKeyGroupsWidth(m: PXkbClientMapPtr, K: int16): int8 = 
-  ##define XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)
-  Result = m.key_sym_map[ze(k)].width
-
-proc XkbCMKeyTypeIndex(m: PXkbClientMapPtr, k: int16, g: int8): int8 = 
-  ##define XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])
-  Result = m.key_sym_map[ze(k)].kt_index[ze(g) and 0x00000003]
-
-proc XkbCMKeyType(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr = 
-  ##define XkbCMKeyType(m,k,g) (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])
-  Result = addr(m.types[ze(XkbCMKeyTypeIndex(m, k, g))])
-
-proc XkbCMKeyNumSyms(m: PXkbClientMapPtr, k: int16): int16 = 
-  ##define XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))
-  Result = toU16(ze(XkbCMKeyGroupsWidth(m, k)) or ze(XkbCMKeyNumGroups(m, k)))
-
-proc XkbCMKeySymsOffset(m: PXkbClientMapPtr, k: int16): int8 = 
-  ##define XkbCMKeySymsOffset(m,k) ((m)->key_sym_map[k].offset)
-  Result = m.key_sym_map[ze(k)].offset
-
-proc XkbCMKeySymsPtr*(m: PXkbClientMapPtr, k: int16): PKeySym = 
-  ##define XkbCMKeySymsPtr(m,k) (&(m)->syms[XkbCMKeySymsOffset(m,k)])
-  Result = addr(m.syms[ze(XkbCMKeySymsOffset(m, k))])
-
-proc XkbIM_IsAuto(i: PXkbIndicatorMapPtr): bool = 
-  ##define XkbIM_IsAuto(i) ((((i)->flags&XkbIM_NoAutomatic)==0)&&(((i)->which_groups&&(i)->groups)||
-  #                           ((i)->which_mods&&(i)->mods.mask)||  ((i)->ctrls)))
-  Result = ((ze(i.flags) and XkbIM_NoAutomatic) == 0) and
-      (((i.which_groups > 0'i8) and (i.groups > 0'i8)) or
-      ((i.which_mods > 0'i8) and (i.mods.mask > 0'i8)) or (i.ctrls > 0'i8))
-
-proc XkbIM_InUse(i: PXkbIndicatorMapPtr): bool = 
-  ##define XkbIM_InUse(i) (((i)->flags)||((i)->which_groups)||((i)->which_mods)||((i)->ctrls)) 
-  Result = (i.flags > 0'i8) or (i.which_groups > 0'i8) or (i.which_mods > 0'i8) or
-      (i.ctrls > 0'i8)
-
-proc XkbKeyKeyTypeIndex(d: PXkbDescPtr, k: int16, g: int8): int8 = 
-  ##define XkbKeyKeyTypeIndex(d,k,g)      (XkbCMKeyTypeIndex((d)->map,k,g))
-  Result = XkbCMKeyTypeIndex(d.map, k, g)
-
-proc XkbKeyKeyType(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr = 
-  ##define XkbKeyKeyType(d,k,g) (XkbCMKeyType((d)->map,k,g))
-  Result = XkbCMKeyType(d.map, k, g)
-
-proc XkbKeyGroupWidth(d: PXkbDescPtr, k: int16, g: int8): int8 = 
-  ##define XkbKeyGroupWidth(d,k,g) (XkbCMKeyGroupWidth((d)->map,k,g))
-  Result = XkbCMKeyGroupWidth(d.map, k, g)
-
-proc XkbKeyGroupsWidth(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyGroupsWidth(d,k) (XkbCMKeyGroupsWidth((d)->map,k))
-  Result = XkbCMKeyGroupsWidth(d.map, k)
-
-proc XkbKeyGroupInfo(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k)))
-  Result = XkbCMKeyGroupInfo(d.map, k)
-
-proc XkbKeyNumGroups(d: PXkbDescPtr, k: int16): int8 = 
-  ##define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k)))
-  Result = XkbCMKeyNumGroups(d.map, k)
-
-proc XkbKeyNumSyms(d: PXkbDescPtr, k: int16): int16 = 
-  ##define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k)))
-  Result = XkbCMKeyNumSyms(d.map, k)
-
-proc XkbKeySymsPtr*(d: PXkbDescPtr, k: int16): PKeySym = 
-  ##define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k)))
-  Result = XkbCMKeySymsPtr(d.map, k)
-
-proc XkbKeySym(d: PXkbDescPtr, k: int16, n: int16): TKeySym = 
-  ##define XkbKeySym(d,k,n) (XkbKeySymsPtr(d,k)[n])
-  Result = cast[ptr array[0..0xffff, TKeySym]](XkbKeySymsPtr(d, k))[ze(n)] # XXX: this seems strange!
-
-proc XkbKeySymEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym = 
-  ##define XkbKeySymEntry(d,k,sl,g) (XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))
-  Result = XkbKeySym(d, k, toU16(ze(XkbKeyGroupsWidth(d, k)) * ze(g) + ze(sl)))
-
-proc XkbKeyAction(d: PXkbDescPtr, k: int16, n: int16): PXkbAction = 
-  ##define XkbKeyAction(d,k,n) (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)
-  #if (XkbKeyHasActions(d, k)): 
-  #  Result = XkbKeyActionsPtr(d, k)[ze(n)] #Buggy !!!
-  assert(false)
-  result = nil
-  
-proc XkbKeyActionEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8 = 
-  ##define XkbKeyActionEntry(d,k,sl,g) (XkbKeyHasActions(d,k) ?
-  #                                      XkbKeyAction(d, k, ((XkbKeyGroupsWidth(d, k) * (g))+(sl))):NULL)
-  if XkbKeyHasActions(d, k): 
-    Result = XkbKeyGroupsWidth(d, k) *% g +% toU8(sl)
-  else: 
-    Result = 0'i8
-  
-proc XkbKeyHasActions(d: PXkbDescPtr, k: int16): bool = 
-  ##define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0)
-  Result = d.server.key_acts[ze(k)] != 0'i16
-
-proc XkbKeyNumActions(d: PXkbDescPtr, k: int16): int16 = 
-  ##define XkbKeyNumActions(d,k) (XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)
-  if (XkbKeyHasActions(d, k)): Result = XkbKeyNumSyms(d, k)
-  else: Result = 1'i16
-  
-proc XkbKeyActionsPtr(d: PXkbDescPtr, k: int16): PXkbAction = 
-  ##define XkbKeyActionsPtr(d,k) (XkbSMKeyActionsPtr((d)->server,k))
-  Result = XkbSMKeyActionsPtr(d.server, k)
-
-proc XkbKeycodeInRange(d: PXkbDescPtr, k: int16): bool = 
-  ##define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&& ((k)<=(d)->max_key_code))
-  Result = (char(toU8(k)) >= d.min_key_code) and (char(toU8(k)) <= d.max_key_code)
-
-proc XkbNumKeys(d: PXkbDescPtr): int8 = 
-  ##define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1)
-  Result = toU8(ord(d.max_key_code) - ord(d.min_key_code) + 1)
-
-proc XkbXI_DevHasBtnActs(d: PXkbDeviceInfoPtr): bool = 
-  ##define XkbXI_DevHasBtnActs(d) (((d)->num_btns>0)&&((d)->btn_acts!=NULL))
-  Result = (d.num_btns > 0'i16) and (not (d.btn_acts == nil))
-
-proc XkbXI_LegalDevBtn(d: PXkbDeviceInfoPtr, b: int16): bool = 
-  ##define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))
-  Result = XkbXI_DevHasBtnActs(d) and (b <% d.num_btns)
-
-proc XkbXI_DevHasLeds(d: PXkbDeviceInfoPtr): bool = 
-  ##define XkbXI_DevHasLeds(d) (((d)->num_leds>0)&&((d)->leds!=NULL))
-  Result = (d.num_leds > 0'i16) and (not (d.leds == nil))
-
-proc XkbBoundsWidth(b: PXkbBoundsPtr): int16 = 
-  ##define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
-  Result = (b.x2) - b.x1
-
-proc XkbBoundsHeight(b: PXkbBoundsPtr): int16 = 
-  ##define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
-  Result = (b.y2) - b.y1
-
-proc XkbOutlineIndex(s: PXkbShapePtr, o: PXkbOutlinePtr): int32 = 
-  ##define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
-  Result = int32((cast[TAddress](o) - cast[TAddress](addr(s.outlines[0]))) div sizeof(PXkbOutlinePtr))
-
-proc XkbShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr = 
-  ##define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr((g.colors[ze(d.color_ndx)]))
-
-proc XkbShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr = 
-  ##define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = addr(g.shapes[ze(d.shape_ndx)])
-
-proc XkbSetShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                            c: PXkbColorPtr) = 
-  ##define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, 
-                            s: PXkbShapePtr) = 
-  ##define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr = 
-  ##define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr(g.colors[ze(d.color_ndx)])
-
-proc XkbSetTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, 
-                           c: PXkbColorPtr) = 
-  ##define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr = 
-  ##define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
-
-proc XkbIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = 
-  ##define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
-  Result = addr(g.colors[ze(d.on_color_ndx)])
-
-proc XkbIndicatorDoodadOffColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = 
-  ##define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
-  Result = addr(g.colors[ze(d.off_color_ndx)])
-
-proc XkbSetIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                  c: PXkbColorPtr) = 
-  ##define XkbSetIndicatorDoodadOnColor(g,d,c) ((d)->on_color_ndx= (c)-&(g)->colors[0])
-  d.on_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetIndicatorDoodadOffColor(g: PXkbGeometryPtr, 
-                                   d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) = 
-  ##define        XkbSetIndicatorDoodadOffColor(g,d,c) ((d)->off_color_ndx= (c)-&(g)->colors[0])
-  d.off_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
-
-proc XkbSetIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, 
-                                s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetIndicatorDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - (cast[TAddress](addr(g.shapes[0])))) div sizeof(TXkbShapeRec))
-
-proc XkbLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr = 
-  ##define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
-  Result = addr(g.colors[ze(d.color_ndx)])
-
-proc XkbLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr = 
-  ##define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
-
-proc XkbSetLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                           c: PXkbColorPtr) = 
-  ##define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
-  d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
-
-proc XkbSetLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, 
-                           s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
-  d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr = 
-  ##define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
-  Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(k.shape_ndx)]))
-
-proc XkbKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr = 
-  ##define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
-  Result = addr(g.colors[ze(k.color_ndx)])
-
-proc XkbSetKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr) = 
-  ##define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
-  k.shape_ndx = toU8((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
-
-proc XkbSetKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr) = 
-  ##define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
-  k.color_ndx = toU8((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
-
-proc XkbGeomColorIndex(g: PXkbGeometryPtr, c: PXkbColorPtr): int32 = 
-  ##define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
-  Result = toU16((cast[TAddress](c) - (cast[TAddress](addr(g.colors[0])))) div sizeof(TxkbColorRec))
diff --git a/lib/wrappers/x11/xkblib.nim b/lib/wrappers/x11/xkblib.nim
deleted file mode 100755
index 92d438a60..000000000
--- a/lib/wrappers/x11/xkblib.nim
+++ /dev/null
@@ -1,699 +0,0 @@
-# $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $
-#************************************************************
-#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-#
-#Permission to use, copy, modify, and distribute this
-#software and its documentation for any purpose and without
-#fee is hereby granted, provided that the above copyright
-#notice appear in all copies and that both that copyright
-#notice and this permission notice appear in supporting
-#documentation, and that the name of Silicon Graphics not be
-#used in advertising or publicity pertaining to distribution
-#of the software without specific prior written permission.
-#Silicon Graphics makes no representation about the suitability
-#of this software for any purpose. It is provided "as is"
-#without any express or implied warranty.
-#
-#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE,
-#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-#THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-#********************************************************/
-# $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $
-#
-# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
-#
-#Thanks:
-#         I want to thanks to oliebol for putting up with all of the problems that was found
-#         while translating this code. ;)
-#
-#         I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
-#         wierd questions ;)
-#
-#         Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
-#         understanding some of the problems I had converting this headers and pointing me to resources
-#         that helped translating this headers.
-#
-# Ido
-#
-#History:
-#        2004/10/15        - Fixed a bug of accessing second based records by removing "paced record" and
-#                            chnaged it to "reocrd" only.
-#        2004/10/10        - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call.
-#        2004/10/06 - 09   - Convertion `from` the c header of XKBlib.h
-#
-#
-
-import 
-  X, Xlib, XKB
-
-type 
-  PXkbAnyEvent* = ptr TXkbAnyEvent
-  TXkbAnyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds;
-    xkb_type*: int16          # XKB event minor code
-    device*: int16            # device ID
-  
-
-type 
-  PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent
-  TXkbNewKeyboardNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbNewKeyboardNotify
-    device*: int16            # device ID
-    old_device*: int16        # device ID of previous keyboard
-    min_key_code*: int16      # minimum key code
-    max_key_code*: int16      # maximum key code
-    old_min_key_code*: int16  # min key code of previous kbd
-    old_max_key_code*: int16  # max key code of previous kbd
-    changed*: int16           # changed aspects of the keyboard
-    req_major*: int8          # major and minor opcode of req
-    req_minor*: int8          # that caused change, if applicable
-  
-
-type 
-  PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent
-  TXkbMapNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbMapNotify
-    device*: int16            # device ID
-    changed*: int16           # fields which have been changed
-    flags*: int16             # reserved
-    first_type*: int16        # first changed key type
-    num_types*: int16         # number of changed key types
-    min_key_code*: TKeyCode
-    max_key_code*: TKeyCode
-    first_key_sym*: TKeyCode
-    first_key_act*: TKeyCode
-    first_key_behavior*: TKeyCode
-    first_key_explicit*: TKeyCode
-    first_modmap_key*: TKeyCode
-    first_vmodmap_key*: TKeyCode
-    num_key_syms*: int16
-    num_key_acts*: int16
-    num_key_behaviors*: int16
-    num_key_explicit*: int16
-    num_modmap_keys*: int16
-    num_vmodmap_keys*: int16
-    vmods*: int16             # mask of changed virtual mods
-  
-
-type 
-  PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent
-  TXkbStateNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbStateNotify
-    device*: int16            # device ID
-    changed*: int16           # mask of changed state components
-    group*: int16             # keyboard group
-    base_group*: int16        # base keyboard group
-    latched_group*: int16     # latched keyboard group
-    locked_group*: int16      # locked keyboard group
-    mods*: int16              # modifier state
-    base_mods*: int16         # base modifier state
-    latched_mods*: int16      # latched modifiers
-    locked_mods*: int16       # locked modifiers
-    compat_state*: int16      # compatibility state
-    grab_mods*: int8          # mods used for grabs
-    compat_grab_mods*: int8   # grab mods for non-XKB clients
-    lookup_mods*: int8        # mods sent to clients
-    compat_lookup_mods*: int8 # mods sent to non-XKB clients
-    ptr_buttons*: int16       # pointer button state
-    keycode*: TKeyCode        # keycode that caused the change
-    event_type*: int8         # KeyPress or KeyRelease
-    req_major*: int8          # Major opcode of request
-    req_minor*: int8          # Minor opcode of request
-  
-
-type 
-  PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent
-  TXkbControlsNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbControlsNotify
-    device*: int16            # device ID
-    changed_ctrls*: int16     # controls with changed sub-values
-    enabled_ctrls*: int16     # controls currently enabled
-    enabled_ctrl_changes*: int16 # controls just {en,dis}abled
-    num_groups*: int16        # total groups on keyboard
-    keycode*: TKeyCode        # key that caused change or 0
-    event_type*: int8         # type of event that caused change
-    req_major*: int8          # if keycode==0, major and minor
-    req_minor*: int8          # opcode of req that caused change
-  
-
-type 
-  PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent
-  TXkbIndicatorNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbIndicatorNotify
-    device*: int16            # device
-    changed*: int16           # indicators with new state or map
-    state*: int16             # current state of all indicators
-  
-
-type 
-  PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent
-  TXkbNamesNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbNamesNotify
-    device*: int16            # device ID
-    changed*: int32           # names that have changed
-    first_type*: int16        # first key type with new name
-    num_types*: int16         # number of key types with new names
-    first_lvl*: int16         # first key type new new level names
-    num_lvls*: int16          # # of key types w/new level names
-    num_aliases*: int16       # total number of key aliases
-    num_radio_groups*: int16  # total number of radio groups
-    changed_vmods*: int16     # virtual modifiers with new names
-    changed_groups*: int16    # groups with new names
-    changed_indicators*: int16 # indicators with new names
-    first_key*: int16         # first key with new name
-    num_keys*: int16          # number of keys with new names
-  
-
-type 
-  PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent
-  TXkbCompatMapNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbCompatMapNotify
-    device*: int16            # device ID
-    changed_groups*: int16    # groups with new compat maps
-    first_si*: int16          # first new symbol interp
-    num_si*: int16            # number of new symbol interps
-    num_total_si*: int16      # total # of symbol interps
-  
-
-type 
-  PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent
-  TXkbBellNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbBellNotify
-    device*: int16            # device ID
-    percent*: int16           # requested volume as a % of maximum
-    pitch*: int16             # requested pitch in Hz
-    duration*: int16          # requested duration in useconds
-    bell_class*: int16        # (input extension) feedback class
-    bell_id*: int16           # (input extension) ID of feedback
-    name*: TAtom              # "name" of requested bell
-    window*: TWindow          # window associated with event
-    event_only*: bool         # "event only" requested
-  
-
-type 
-  PXkbActionMessageEvent* = ptr TXkbActionMessageEvent
-  TXkbActionMessageEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbActionMessage
-    device*: int16            # device ID
-    keycode*: TKeyCode        # key that generated the event
-    press*: bool              # true if act caused by key press
-    key_event_follows*: bool  # true if key event also generated
-    group*: int16             # effective group
-    mods*: int16              # effective mods
-    message*: array[0..XkbActionMessageLength, Char] # message -- leave space for NUL
-  
-
-type 
-  PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent
-  TXkbAccessXNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbAccessXNotify
-    device*: int16            # device ID
-    detail*: int16            # XkbAXN_*
-    keycode*: int16           # key of event
-    sk_delay*: int16          # current slow keys delay
-    debounce_delay*: int16    # current debounce delay
-  
-
-type 
-  PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent
-  TXkbExtensionDeviceNotifyEvent*{.final.} = object 
-    theType*: int16           # XkbAnyEvent
-    serial*: int32            # of last req processed by server
-    send_event*: bool         # is this `from` a SendEvent request?
-    display*: PDisplay        # Display the event was read `from`
-    time*: TTime              # milliseconds
-    xkb_type*: int16          # XkbExtensionDeviceNotify
-    device*: int16            # device ID
-    reason*: int16            # reason for the event
-    supported*: int16         # mask of supported features
-    unsupported*: int16       # mask of unsupported features
-                              # that some app tried to use
-    first_btn*: int16         # first button that changed
-    num_btns*: int16          # range of buttons changed
-    leds_defined*: int16      # indicators with names or maps
-    led_state*: int16         # current state of the indicators
-    led_class*: int16         # feedback class for led changes
-    led_id*: int16            # feedback id for led changes
-  
-
-type 
-  PXkbEvent* = ptr TXkbEvent
-  TXkbEvent*{.final.} = object 
-    theType*: int16
-    any*: TXkbAnyEvent
-    new_kbd*: TXkbNewKeyboardNotifyEvent
-    map*: TXkbMapNotifyEvent
-    state*: TXkbStateNotifyEvent
-    ctrls*: TXkbControlsNotifyEvent
-    indicators*: TXkbIndicatorNotifyEvent
-    names*: TXkbNamesNotifyEvent
-    compat*: TXkbCompatMapNotifyEvent
-    bell*: TXkbBellNotifyEvent
-    message*: TXkbActionMessageEvent
-    accessx*: TXkbAccessXNotifyEvent
-    device*: TXkbExtensionDeviceNotifyEvent
-    core*: TXEvent
-
-
-type
-  PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec
-  TXkbKbdDpyStateRec*{.final.} = object  # XkbOpenDisplay error codes 
-
-const 
-  XkbOD_Success* = 0
-  XkbOD_BadLibraryVersion* = 1
-  XkbOD_ConnectionRefused* = 2
-  XkbOD_NonXkbServer* = 3
-  XkbOD_BadServerVersion* = 4 # Values for XlibFlags 
-
-const 
-  XkbLC_ForceLatin1Lookup* = 1 shl 0
-  XkbLC_ConsumeLookupMods* = 1 shl 1
-  XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2
-  XkbLC_IgnoreNewKeyboards* = 1 shl 3
-  XkbLC_ControlFallback* = 1 shl 4
-  XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29
-  XkbLC_ComposeLED* = 1 shl 30
-  XkbLC_BeepOnComposeFail* = 1 shl 31
-  XkbLC_AllComposeControls* = 0xC0000000
-  XkbLC_AllControls* = 0xC000001F
-
-proc XkbIgnoreExtension*(ignore: bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbIgnoreExtension".}
-proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn, 
-                                    reason: ptr int16): PDisplay{.cdecl, 
-    dynlib: libX11, importc: "XkbOpenDisplay".}
-proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn, 
-                                       errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbQueryExtension".}
-proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbUseExtension".}
-proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLibraryVersion".}
-proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbSetXlibControls".}
-proc XkbGetXlibControls*(dpy: PDisplay): int16{.cdecl, dynlib: libX11, 
-    importc: "XkbGetXlibControls".}
-type 
-  TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{.
-      cdecl.}
-
-type 
-  TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
-
-proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
-    cdecl, dynlib: libX11, importc: "XkbSetAtomFuncs".}
-proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
-    cdecl, dynlib: libX11, importc: "XkbKeycodeToKeysym".}
-proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbKeysymToModifiers".}
-proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode, 
-                      modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLookupKeySym".}
-proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16, 
-                          buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
-    cdecl, dynlib: libX11, importc: "XkbLookupKeyBinding".}
-proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode, 
-                          modifiers, modifiers_return: int16, 
-                          keysym_return: PKeySym): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbTranslateKeyCode".}
-proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16, 
-                         buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
-    cdecl, dynlib: libX11, importc: "XkbTranslateKeySym".}
-proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetAutoRepeatRate".}
-proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16, 
-                           delayRtrn, intervalRtrn: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetAutoRepeatRate".}
-proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbChangeEnabledControls".}
-proc XkbDeviceBell*(dpy: PDisplay, win: TWindow, 
-                    deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbDeviceBell".}
-proc XkbForceDeviceBell*(dpy: PDisplay, 
-                         deviceSpec, bellClass, bellID, percent: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbForceDeviceBell".}
-proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow, 
-                         deviceSpec, bellClass, bellID, percent: int16, 
-                         name: TAtom): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbDeviceBellEvent".}
-proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbBell".}
-proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbForceBell".}
-proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
-    cdecl, dynlib: libX11, importc: "XkbBellEvent".}
-proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSelectEvents".}
-proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16, 
-                            affect, details: int32): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSelectEventDetails".}
-proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent, 
-                        wanted: int16){.cdecl, dynlib: libX11, 
-                                        importc: "XkbNoteMapChanges".}
-proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent, 
-                         wanted: int16){.cdecl, dynlib: libX11, 
-    importc: "XkbNoteNameChanges".}
-proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetIndicatorState".}
-proc XkbGetDeviceIndicatorState*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 pStateRtrn: PWord): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceIndicatorState".}
-proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetIndicatorMap".}
-proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetIndicatorMap".}
-proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
-proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
-proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr, 
-                                c: PXkbIndicatorChangesPtr): TStatus
-proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr, 
-                             c: PXkbIndicatorChangesPtr): bool
-proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16, 
-                           pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr, 
-                           pRealRtrn: ptr bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbGetNamedIndicator".}
-proc XkbGetNamedDeviceIndicator*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 name: TAtom, pNdxRtrn: ptr int16, 
-                                 pStateRtrn: ptr bool, 
-                                 pMapRtrn: PXkbIndicatorMapPtr, 
-                                 pRealRtrn: ptr bool): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetNamedDeviceIndicator".}
-proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom, 
-                           changeState, state, createNewMap: bool, 
-                           pMap: PXkbIndicatorMapPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetNamedIndicator".}
-proc XkbSetNamedDeviceIndicator*(dpy: PDisplay, 
-                                 deviceSpec, ledClass, ledID: int16, 
-                                 name: TAtom, 
-                                 changeState, state, createNewMap: bool, 
-                                 pMap: PXkbIndicatorMapPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetNamedDeviceIndicator".}
-proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLockModifiers".}
-proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbLatchModifiers".}
-proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLockGroup".}
-proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbLatchGroup".}
-proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal, 
-    realValues, affectVirtual, virtualValues: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetServerInternalMods".}
-proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues, 
-    affectVirtual, virtualValues: int16): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetIgnoreLockMods".}
-proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbVirtualModsToReal".}
-proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr, 
-                             map_rtrn: PByte): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbComputeEffectiveMap".}
-proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbInitCanonicalKeyTypes".}
-proc XkbAllocKeyboard*(): PXkbDescPtr{.cdecl, dynlib: libX11, 
-                                       importc: "XkbAllocKeyboard".}
-proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeKeyboard".}
-proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocClientMap".}
-proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocServerMap".}
-proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeClientMap".}
-proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeServerMap".}
-proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16, 
-                    want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddKeyType".}
-proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbAllocIndicatorMaps".}
-proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeIndicatorMaps".}
-proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.cdecl, 
-    dynlib: libX11, importc: "XkbGetMap".}
-proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetUpdatedMap".}
-proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr, 
-                       changes: PXkbMapChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetMapChanges".}
-proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbRefreshKeyboardMapping".}
-proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyTypes".}
-proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeySyms".}
-proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyActions".}
-proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16, 
-                         desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyBehaviors".}
-proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetVirtualMods".}
-proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16, 
-                                  desc: PXkbDescPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetKeyExplicitComponents".}
-proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16, 
-                           desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyModifierMap".}
-proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocControls".}
-proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeControls".}
-proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetControls".}
-proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetControls".}
-proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr, 
-                             new: PXkbControlsNotifyEvent, wanted: int16){.
-    cdecl, dynlib: libX11, importc: "XkbNoteControlsChanges".}
-proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr, 
-                            c: PXkbControlsChangesPtr): TStatus
-proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool
-proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbAllocCompatMap".}
-proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeCompatMap".}
-proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetCompatMap".}
-proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr, 
-                      updateActions: bool): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetCompatMap".}
-proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr, 
-                         updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddSymInterpret".}
-proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16, 
-                    nTotalRG, nTotalAliases: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbAllocNames".}
-proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetNames".}
-proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16, 
-                  desc: PXkbDescPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbSetNames".}
-proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr, 
-                     changes: PXkbNameChangesPtr): bool{.cdecl, dynlib: libX11, 
-    importc: "XkbChangeNames".}
-proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, 
-    dynlib: libX11, importc: "XkbFreeNames".}
-proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbGetState".}
-proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetMap".}
-proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbChangeMap".}
-proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool, 
-                                 supported: ptr bool): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDetectableAutoRepeat".}
-proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
-    cdecl, dynlib: libX11, importc: "XkbGetDetectableAutoRepeat".}
-proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16, 
-                              auto_ctrls, auto_values: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetAutoResetControls".}
-proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbGetAutoResetControls".}
-proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetPerClientControls".}
-proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbGetPerClientControls".}
-proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbCopyKeyType".}
-proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbCopyKeyTypes".}
-proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16, 
-                       want_preserve: bool, new_num_lvls: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeyType".}
-proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeySyms".}
-proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
-    cdecl, dynlib: libX11, importc: "XkbResizeKeyActions".}
-proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16, 
-                          groups: int16, newTypes: ptr int16, 
-                          pChanges: PXkbMapChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbChangeTypesOfKey".}
-    
-proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16, 
-                        ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
-    cdecl, dynlib: libX11, importc: "XkbListComponents".}
-proc XkbFreeComponentList*(list: PXkbComponentListPtr){.cdecl, dynlib: libX11, 
-    importc: "XkbFreeComponentList".}
-proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
-    cdecl, dynlib: libX11, importc: "XkbGetKeyboard".}
-proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16, 
-                           names: PXkbComponentNamesPtr, want, need: int16, 
-                           load: bool): PXkbDescPtr{.cdecl, dynlib: libX11, 
-    importc: "XkbGetKeyboardByName".}
-    
-proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr, 
-                                map_width: int16,  # keyboard device
-                                core_syms: PKeySym,  # always mapWidth symbols
-                                protected: int16,  # explicit key types
-                                types_inout: ptr int16,  # always four type indices
-                                xkb_syms_rtrn: PKeySym): int16{.cdecl, 
-    dynlib: libX11, importc: "XkbKeyTypesForCoreSymbols".}
-  # must have enough space
-proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr,  
-                             key: TKeyCode,  # key to be updated
-                             changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbApplyCompatMapToKey".}
-  # resulting changes to map
-proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr,  
-                           first_key: TKeyCode,  # first changed key
-                           num_keys,
-                           map_width: int16, 
-                           core_keysyms: PKeySym,  # symbols `from` core keymap
-                           changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbUpdateMapFromCore".}
-
-proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAddDeviceLedInfo".}
-proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
-    cdecl, dynlib: libX11, importc: "XkbResizeDeviceButtonActions".}
-proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbAllocDeviceInfo".}
-proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
-    cdecl, dynlib: libX11, importc: "XkbFreeDeviceInfo".}
-proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr, 
-                           new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
-    cdecl, dynlib: libX11, importc: "XkbNoteDeviceChanges".}
-proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
-    cdecl, dynlib: libX11, importc: "XkbGetDeviceInfo".}
-proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                              changes: PXkbDeviceChangesPtr): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceInfoChanges".}
-proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                                all: bool, first, nBtns: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceButtonActions".}
-proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                          ledClass, ledId, which: int16): TStatus{.cdecl, 
-    dynlib: libX11, importc: "XkbGetDeviceLedInfo".}
-proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetDeviceInfo".}
-proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr, 
-                          changes: PXkbDeviceChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbChangeDeviceInfo".}
-proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                          ledClass, ledID, which: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDeviceLedInfo".}
-proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, 
-                                first, nBtns: int16): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbSetDeviceButtonActions".}
-
-proc XkbToControl*(c: int8): int8{.cdecl, dynlib: libX11, 
-                                   importc: "XkbToControl".}
-
-proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring, 
-                           ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{.
-    cdecl, dynlib: libX11, importc: "XkbSetDebuggingFlags".}
-proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16, 
-                                changes: PXkbChangesPtr): bool{.cdecl, 
-    dynlib: libX11, importc: "XkbApplyVirtualModChanges".}
-
-# implementation
-
-proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = 
-  ##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w)))
-  o.map_changes = o.map_changes or (n.map_changes and w)
-
-proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = 
-  ##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w)))
-  o.state_changes = o.state_changes or (n.state_changes and (w))
-
-proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr, 
-                               c: PXkbIndicatorChangesPtr): TStatus = 
-  ##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x)
-  Result = XkbGetIndicatorMap(d, c.map_changes, x)
-
-proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr, 
-                            c: PXkbIndicatorChangesPtr): bool = 
-  ##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x))
-  Result = XkbSetIndicatorMap(d, c.map_changes, x)
-
-proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr, 
-                           c: PXkbControlsChangesPtr): TStatus = 
-  ##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
-  Result = XkbGetControls(d, c.changed_ctrls, x)
-
-proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool = 
-  ##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
-  Result = XkbSetControls(d, c.changed_ctrls, x)
diff --git a/lib/wrappers/x11/xlib.nim b/lib/wrappers/x11/xlib.nim
deleted file mode 100755
index 19ebda9e0..000000000
--- a/lib/wrappers/x11/xlib.nim
+++ /dev/null
@@ -1,2218 +0,0 @@
-
-import 
-  x
-
-const 
-  libX11* = "libX11.so"
-
-type
-  cuint* = cint
-  cunsigned* = cint
-  cushort* = int16
-  Pcint* = ptr cint
-  PPcint* = ptr Pcint
-  PPcuchar* = ptr ptr cuchar
-  PWideChar* = ptr int16
-  PPChar* = ptr cstring
-  PPPChar* = ptr ptr cstring
-  Pculong* = ptr int
-  Pcuchar* = cstring
-  Pcuint* = ptr cint
-  Pcushort* = ptr int16
-#  Automatically converted by H2Pas 0.99.15 from xlib.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xlib.h
-
-const 
-  XlibSpecificationRelease* = 6
-
-type 
-  PXPointer* = ptr TXPointer
-  TXPointer* = ptr char
-  PBool* = ptr TBool
-  TBool* = int           #cint?
-  PStatus* = ptr TStatus
-  TStatus* = cint
-
-const 
-  QueuedAlready* = 0
-  QueuedAfterReading* = 1
-  QueuedAfterFlush* = 2
-
-type 
-  PPXExtData* = ptr PXExtData
-  PXExtData* = ptr TXExtData
-  TXExtData*{.final.} = object 
-    number*: cint
-    next*: PXExtData
-    free_private*: proc (extension: PXExtData): cint{.cdecl.}
-    private_data*: TXPointer
-
-  PXExtCodes* = ptr TXExtCodes
-  TXExtCodes*{.final.} = object 
-    extension*: cint
-    major_opcode*: cint
-    first_event*: cint
-    first_error*: cint
-
-  PXPixmapFormatValues* = ptr TXPixmapFormatValues
-  TXPixmapFormatValues*{.final.} = object 
-    depth*: cint
-    bits_per_pixel*: cint
-    scanline_pad*: cint
-
-  PXGCValues* = ptr TXGCValues
-  TXGCValues*{.final.} = object 
-    function*: cint
-    plane_mask*: culong
-    foreground*: culong
-    background*: culong
-    line_width*: cint
-    line_style*: cint
-    cap_style*: cint
-    join_style*: cint
-    fill_style*: cint
-    fill_rule*: cint
-    arc_mode*: cint
-    tile*: TPixmap
-    stipple*: TPixmap
-    ts_x_origin*: cint
-    ts_y_origin*: cint
-    font*: TFont
-    subwindow_mode*: cint
-    graphics_exposures*: TBool
-    clip_x_origin*: cint
-    clip_y_origin*: cint
-    clip_mask*: TPixmap
-    dash_offset*: cint
-    dashes*: cchar
-
-  PXGC* = ptr TXGC
-  TXGC*{.final.} = object 
-  TGC* = PXGC
-  PGC* = ptr TGC
-  PVisual* = ptr TVisual
-  TVisual*{.final.} = object 
-    ext_data*: PXExtData
-    visualid*: TVisualID
-    c_class*: cint
-    red_mask*, green_mask*, blue_mask*: culong
-    bits_per_rgb*: cint
-    map_entries*: cint
-
-  PDepth* = ptr TDepth
-  TDepth*{.final.} = object 
-    depth*: cint
-    nvisuals*: cint
-    visuals*: PVisual
-
-  PXDisplay* = ptr TXDisplay
-  TXDisplay*{.final.} = object 
-  PScreen* = ptr TScreen
-  TScreen*{.final.} = object 
-    ext_data*: PXExtData
-    display*: PXDisplay
-    root*: TWindow
-    width*, height*: cint
-    mwidth*, mheight*: cint
-    ndepths*: cint
-    depths*: PDepth
-    root_depth*: cint
-    root_visual*: PVisual
-    default_gc*: TGC
-    cmap*: TColormap
-    white_pixel*: culong
-    black_pixel*: culong
-    max_maps*, min_maps*: cint
-    backing_store*: cint
-    save_unders*: TBool
-    root_input_mask*: clong
-
-  PScreenFormat* = ptr TScreenFormat
-  TScreenFormat*{.final.} = object 
-    ext_data*: PXExtData
-    depth*: cint
-    bits_per_pixel*: cint
-    scanline_pad*: cint
-
-  PXSetWindowAttributes* = ptr TXSetWindowAttributes
-  TXSetWindowAttributes*{.final.} = object 
-    background_pixmap*: TPixmap
-    background_pixel*: culong
-    border_pixmap*: TPixmap
-    border_pixel*: culong
-    bit_gravity*: cint
-    win_gravity*: cint
-    backing_store*: cint
-    backing_planes*: culong
-    backing_pixel*: culong
-    save_under*: TBool
-    event_mask*: clong
-    do_not_propagate_mask*: clong
-    override_redirect*: TBool
-    colormap*: TColormap
-    cursor*: TCursor
-
-  PXWindowAttributes* = ptr TXWindowAttributes
-  TXWindowAttributes*{.final.} = object 
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    depth*: cint
-    visual*: PVisual
-    root*: TWindow
-    c_class*: cint
-    bit_gravity*: cint
-    win_gravity*: cint
-    backing_store*: cint
-    backing_planes*: culong
-    backing_pixel*: culong
-    save_under*: TBool
-    colormap*: TColormap
-    map_installed*: TBool
-    map_state*: cint
-    all_event_masks*: clong
-    your_event_mask*: clong
-    do_not_propagate_mask*: clong
-    override_redirect*: TBool
-    screen*: PScreen
-
-  PXHostAddress* = ptr TXHostAddress
-  TXHostAddress*{.final.} = object 
-    family*: cint
-    len*: cint
-    address*: cstring
-
-  PXServerInterpretedAddress* = ptr TXServerInterpretedAddress
-  TXServerInterpretedAddress*{.final.} = object 
-    typelength*: cint
-    valuelength*: cint
-    theType*: cstring
-    value*: cstring
-
-  PXImage* = ptr TXImage
-  TF*{.final.} = object 
-    create_image*: proc (para1: PXDisplay, para2: PVisual, para3: cuint, 
-                         para4: cint, para5: cint, para6: cstring, para7: cuint, 
-                         para8: cuint, para9: cint, para10: cint): PXImage{.
-        cdecl.}
-    destroy_image*: proc (para1: PXImage): cint{.cdecl.}
-    get_pixel*: proc (para1: PXImage, para2: cint, para3: cint): culong{.cdecl.}
-    put_pixel*: proc (para1: PXImage, para2: cint, para3: cint, para4: culong): cint{.
-        cdecl.}
-    sub_image*: proc (para1: PXImage, para2: cint, para3: cint, para4: cuint, 
-                      para5: cuint): PXImage{.cdecl.}
-    add_pixel*: proc (para1: PXImage, para2: clong): cint{.cdecl.}
-
-  TXImage*{.final.} = object 
-    width*, height*: cint
-    xoffset*: cint
-    format*: cint
-    data*: cstring
-    byte_order*: cint
-    bitmap_unit*: cint
-    bitmap_bit_order*: cint
-    bitmap_pad*: cint
-    depth*: cint
-    bytes_per_line*: cint
-    bits_per_pixel*: cint
-    red_mask*: culong
-    green_mask*: culong
-    blue_mask*: culong
-    obdata*: TXPointer
-    f*: TF
-
-  PXWindowChanges* = ptr TXWindowChanges
-  TXWindowChanges*{.final.} = object 
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    sibling*: TWindow
-    stack_mode*: cint
-
-  PXColor* = ptr TXColor
-  TXColor*{.final.} = object 
-    pixel*: culong
-    red*, green*, blue*: cushort
-    flags*: cchar
-    pad*: cchar
-
-  PXSegment* = ptr TXSegment
-  TXSegment*{.final.} = object 
-    x1*, y1*, x2*, y2*: cshort
-
-  PXPoint* = ptr TXPoint
-  TXPoint*{.final.} = object 
-    x*, y*: cshort
-
-  PXRectangle* = ptr TXRectangle
-  TXRectangle*{.final.} = object 
-    x*, y*: cshort
-    width*, height*: cushort
-
-  PXArc* = ptr TXArc
-  TXArc*{.final.} = object 
-    x*, y*: cshort
-    width*, height*: cushort
-    angle1*, angle2*: cshort
-
-  PXKeyboardControl* = ptr TXKeyboardControl
-  TXKeyboardControl*{.final.} = object 
-    key_click_percent*: cint
-    bell_percent*: cint
-    bell_pitch*: cint
-    bell_duration*: cint
-    led*: cint
-    led_mode*: cint
-    key*: cint
-    auto_repeat_mode*: cint
-
-  PXKeyboardState* = ptr TXKeyboardState
-  TXKeyboardState*{.final.} = object 
-    key_click_percent*: cint
-    bell_percent*: cint
-    bell_pitch*, bell_duration*: cuint
-    led_mask*: culong
-    global_auto_repeat*: cint
-    auto_repeats*: array[0..31, cchar]
-
-  PXTimeCoord* = ptr TXTimeCoord
-  TXTimeCoord*{.final.} = object 
-    time*: TTime
-    x*, y*: cshort
-
-  PXModifierKeymap* = ptr TXModifierKeymap
-  TXModifierKeymap*{.final.} = object 
-    max_keypermod*: cint
-    modifiermap*: PKeyCode
-
-  PDisplay* = ptr TDisplay
-  TDisplay* = TXDisplay
-  PXPrivate* = ptr TXPrivate
-  TXPrivate*{.final.} = object 
-  PXrmHashBucketRec* = ptr TXrmHashBucketRec
-  TXrmHashBucketRec*{.final.} = object 
-  PXPrivDisplay* = ptr TXPrivDisplay
-  TXPrivDisplay*{.final.} = object 
-    ext_data*: PXExtData
-    private1*: PXPrivate
-    fd*: cint
-    private2*: cint
-    proto_major_version*: cint
-    proto_minor_version*: cint
-    vendor*: cstring
-    private3*: TXID
-    private4*: TXID
-    private5*: TXID
-    private6*: cint
-    resource_alloc*: proc (para1: PXDisplay): TXID{.cdecl.}
-    byte_order*: cint
-    bitmap_unit*: cint
-    bitmap_pad*: cint
-    bitmap_bit_order*: cint
-    nformats*: cint
-    pixmap_format*: PScreenFormat
-    private8*: cint
-    release*: cint
-    private9*, private10*: PXPrivate
-    qlen*: cint
-    last_request_read*: culong
-    request*: culong
-    private11*: TXPointer
-    private12*: TXPointer
-    private13*: TXPointer
-    private14*: TXPointer
-    max_request_size*: cunsigned
-    db*: PXrmHashBucketRec
-    private15*: proc (para1: PXDisplay): cint{.cdecl.}
-    display_name*: cstring
-    default_screen*: cint
-    nscreens*: cint
-    screens*: PScreen
-    motion_buffer*: culong
-    private16*: culong
-    min_keycode*: cint
-    max_keycode*: cint
-    private17*: TXPointer
-    private18*: TXPointer
-    private19*: cint
-    xdefaults*: cstring
-
-  PXKeyEvent* = ptr TXKeyEvent
-  TXKeyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    keycode*: cuint
-    same_screen*: TBool
-
-  PXKeyPressedEvent* = ptr TXKeyPressedEvent
-  TXKeyPressedEvent* = TXKeyEvent
-  PXKeyReleasedEvent* = ptr TXKeyReleasedEvent
-  TXKeyReleasedEvent* = TXKeyEvent
-  PXButtonEvent* = ptr TXButtonEvent
-  TXButtonEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    button*: cuint
-    same_screen*: TBool
-
-  PXButtonPressedEvent* = ptr TXButtonPressedEvent
-  TXButtonPressedEvent* = TXButtonEvent
-  PXButtonReleasedEvent* = ptr TXButtonReleasedEvent
-  TXButtonReleasedEvent* = TXButtonEvent
-  PXMotionEvent* = ptr TXMotionEvent
-  TXMotionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    state*: cuint
-    is_hint*: cchar
-    same_screen*: TBool
-
-  PXPointerMovedEvent* = ptr TXPointerMovedEvent
-  TXPointerMovedEvent* = TXMotionEvent
-  PXCrossingEvent* = ptr TXCrossingEvent
-  TXCrossingEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    root*: TWindow
-    subwindow*: TWindow
-    time*: TTime
-    x*, y*: cint
-    x_root*, y_root*: cint
-    mode*: cint
-    detail*: cint
-    same_screen*: TBool
-    focus*: TBool
-    state*: cuint
-
-  PXEnterWindowEvent* = ptr TXEnterWindowEvent
-  TXEnterWindowEvent* = TXCrossingEvent
-  PXLeaveWindowEvent* = ptr TXLeaveWindowEvent
-  TXLeaveWindowEvent* = TXCrossingEvent
-  PXFocusChangeEvent* = ptr TXFocusChangeEvent
-  TXFocusChangeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    mode*: cint
-    detail*: cint
-
-  PXFocusInEvent* = ptr TXFocusInEvent
-  TXFocusInEvent* = TXFocusChangeEvent
-  PXFocusOutEvent* = ptr TXFocusOutEvent
-  TXFocusOutEvent* = TXFocusChangeEvent
-  PXKeymapEvent* = ptr TXKeymapEvent
-  TXKeymapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    key_vector*: array[0..31, cchar]
-
-  PXExposeEvent* = ptr TXExposeEvent
-  TXExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    count*: cint
-
-  PXGraphicsExposeEvent* = ptr TXGraphicsExposeEvent
-  TXGraphicsExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    x*, y*: cint
-    width*, height*: cint
-    count*: cint
-    major_code*: cint
-    minor_code*: cint
-
-  PXNoExposeEvent* = ptr TXNoExposeEvent
-  TXNoExposeEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    major_code*: cint
-    minor_code*: cint
-
-  PXVisibilityEvent* = ptr TXVisibilityEvent
-  TXVisibilityEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    state*: cint
-
-  PXCreateWindowEvent* = ptr TXCreateWindowEvent
-  TXCreateWindowEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    override_redirect*: TBool
-
-  PXDestroyWindowEvent* = ptr TXDestroyWindowEvent
-  TXDestroyWindowEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-
-  PXUnmapEvent* = ptr TXUnmapEvent
-  TXUnmapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    from_configure*: TBool
-
-  PXMapEvent* = ptr TXMapEvent
-  TXMapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    override_redirect*: TBool
-
-  PXMapRequestEvent* = ptr TXMapRequestEvent
-  TXMapRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-
-  PXReparentEvent* = ptr TXReparentEvent
-  TXReparentEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    parent*: TWindow
-    x*, y*: cint
-    override_redirect*: TBool
-
-  PXConfigureEvent* = ptr TXConfigureEvent
-  TXConfigureEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    above*: TWindow
-    override_redirect*: TBool
-
-  PXGravityEvent* = ptr TXGravityEvent
-  TXGravityEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    x*, y*: cint
-
-  PXResizeRequestEvent* = ptr TXResizeRequestEvent
-  TXResizeRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    width*, height*: cint
-
-  PXConfigureRequestEvent* = ptr TXConfigureRequestEvent
-  TXConfigureRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    x*, y*: cint
-    width*, height*: cint
-    border_width*: cint
-    above*: TWindow
-    detail*: cint
-    value_mask*: culong
-
-  PXCirculateEvent* = ptr TXCirculateEvent
-  TXCirculateEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    event*: TWindow
-    window*: TWindow
-    place*: cint
-
-  PXCirculateRequestEvent* = ptr TXCirculateRequestEvent
-  TXCirculateRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    parent*: TWindow
-    window*: TWindow
-    place*: cint
-
-  PXPropertyEvent* = ptr TXPropertyEvent
-  TXPropertyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    atom*: TAtom
-    time*: TTime
-    state*: cint
-
-  PXSelectionClearEvent* = ptr TXSelectionClearEvent
-  TXSelectionClearEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    selection*: TAtom
-    time*: TTime
-
-  PXSelectionRequestEvent* = ptr TXSelectionRequestEvent
-  TXSelectionRequestEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    owner*: TWindow
-    requestor*: TWindow
-    selection*: TAtom
-    target*: TAtom
-    property*: TAtom
-    time*: TTime
-
-  PXSelectionEvent* = ptr TXSelectionEvent
-  TXSelectionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    requestor*: TWindow
-    selection*: TAtom
-    target*: TAtom
-    property*: TAtom
-    time*: TTime
-
-  PXColormapEvent* = ptr TXColormapEvent
-  TXColormapEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    colormap*: TColormap
-    c_new*: TBool
-    state*: cint
-
-  PXClientMessageEvent* = ptr TXClientMessageEvent
-  TXClientMessageEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    message_type*: TAtom
-    format*: cint
-    data*: array[0..19, char]
-
-  PXMappingEvent* = ptr TXMappingEvent
-  TXMappingEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-    request*: cint
-    first_keycode*: cint
-    count*: cint
-
-  PXErrorEvent* = ptr TXErrorEvent
-  TXErrorEvent*{.final.} = object 
-    theType*: cint
-    display*: PDisplay
-    resourceid*: TXID
-    serial*: culong
-    error_code*: cuchar
-    request_code*: cuchar
-    minor_code*: cuchar
-
-  PXAnyEvent* = ptr TXAnyEvent
-  TXAnyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    window*: TWindow
-
-  PXEvent* = ptr TXEvent
-  TXEvent*{.final.} = object 
-    theType*: cint
-    pad*: array[0..22, clong] #
-                              #       case longint of
-                              #          0 : ( theType : cint );
-                              #          1 : ( xany : TXAnyEvent );
-                              #          2 : ( xkey : TXKeyEvent );
-                              #          3 : ( xbutton : TXButtonEvent );
-                              #          4 : ( xmotion : TXMotionEvent );
-                              #          5 : ( xcrossing : TXCrossingEvent );
-                              #          6 : ( xfocus : TXFocusChangeEvent );
-                              #          7 : ( xexpose : TXExposeEvent );
-                              #          8 : ( xgraphicsexpose : TXGraphicsExposeEvent );
-                              #          9 : ( xnoexpose : TXNoExposeEvent );
-                              #          10 : ( xvisibility : TXVisibilityEvent );
-                              #          11 : ( xcreatewindow : TXCreateWindowEvent );
-                              #          12 : ( xdestroywindow : TXDestroyWindowEvent );
-                              #          13 : ( xunmap : TXUnmapEvent );
-                              #          14 : ( xmap : TXMapEvent );
-                              #          15 : ( xmaprequest : TXMapRequestEvent );
-                              #          16 : ( xreparent : TXReparentEvent );
-                              #          17 : ( xconfigure : TXConfigureEvent );
-                              #          18 : ( xgravity : TXGravityEvent );
-                              #          19 : ( xresizerequest : TXResizeRequestEvent );
-                              #          20 : ( xconfigurerequest : TXConfigureRequestEvent );
-                              #          21 : ( xcirculate : TXCirculateEvent );
-                              #          22 : ( xcirculaterequest : TXCirculateRequestEvent );
-                              #          23 : ( xproperty : TXPropertyEvent );
-                              #          24 : ( xselectionclear : TXSelectionClearEvent );
-                              #          25 : ( xselectionrequest : TXSelectionRequestEvent );
-                              #          26 : ( xselection : TXSelectionEvent );
-                              #          27 : ( xcolormap : TXColormapEvent );
-                              #          28 : ( xclient : TXClientMessageEvent );
-                              #          29 : ( xmapping : TXMappingEvent );
-                              #          30 : ( xerror : TXErrorEvent );
-                              #          31 : ( xkeymap : TXKeymapEvent );
-                              #          32 : ( pad : array[0..23] of clong );
-                              #          
-  
-
-type 
-  PXCharStruct* = ptr TXCharStruct
-  TXCharStruct*{.final.} = object 
-    lbearing*: cshort
-    rbearing*: cshort
-    width*: cshort
-    ascent*: cshort
-    descent*: cshort
-    attributes*: cushort
-
-  PXFontProp* = ptr TXFontProp
-  TXFontProp*{.final.} = object 
-    name*: TAtom
-    card32*: culong
-
-  PPPXFontStruct* = ptr PPXFontStruct
-  PPXFontStruct* = ptr PXFontStruct
-  PXFontStruct* = ptr TXFontStruct
-  TXFontStruct*{.final.} = object 
-    ext_data*: PXExtData
-    fid*: TFont
-    direction*: cunsigned
-    min_char_or_byte2*: cunsigned
-    max_char_or_byte2*: cunsigned
-    min_byte1*: cunsigned
-    max_byte1*: cunsigned
-    all_chars_exist*: TBool
-    default_char*: cunsigned
-    n_properties*: cint
-    properties*: PXFontProp
-    min_bounds*: TXCharStruct
-    max_bounds*: TXCharStruct
-    per_char*: PXCharStruct
-    ascent*: cint
-    descent*: cint
-
-  PXTextItem* = ptr TXTextItem
-  TXTextItem*{.final.} = object 
-    chars*: cstring
-    nchars*: cint
-    delta*: cint
-    font*: TFont
-
-  PXChar2b* = ptr TXChar2b
-  TXChar2b*{.final.} = object 
-    byte1*: cuchar
-    byte2*: cuchar
-
-  PXTextItem16* = ptr TXTextItem16
-  TXTextItem16*{.final.} = object 
-    chars*: PXChar2b
-    nchars*: cint
-    delta*: cint
-    font*: TFont
-
-  PXEDataObject* = ptr TXEDataObject
-  TXEDataObject*{.final.} = object 
-    display*: PDisplay        #case longint of
-                              #          0 : ( display : PDisplay );
-                              #          1 : ( gc : TGC );
-                              #          2 : ( visual : PVisual );
-                              #          3 : ( screen : PScreen );
-                              #          4 : ( pixmap_format : PScreenFormat );
-                              #          5 : ( font : PXFontStruct );
-  
-  PXFontSetExtents* = ptr TXFontSetExtents
-  TXFontSetExtents*{.final.} = object 
-    max_ink_extent*: TXRectangle
-    max_logical_extent*: TXRectangle
-
-  PXOM* = ptr TXOM
-  TXOM*{.final.} = object 
-  PXOC* = ptr TXOC
-  TXOC*{.final.} = object 
-  TXFontSet* = PXOC
-  PXFontSet* = ptr TXFontSet
-  PXmbTextItem* = ptr TXmbTextItem
-  TXmbTextItem*{.final.} = object 
-    chars*: cstring
-    nchars*: cint
-    delta*: cint
-    font_set*: TXFontSet
-
-  PXwcTextItem* = ptr TXwcTextItem
-  TXwcTextItem*{.final.} = object 
-    chars*: PWideChar         #wchar_t*
-    nchars*: cint
-    delta*: cint
-    font_set*: TXFontSet
-
-
-const 
-  XNRequiredCharSet* = "requiredCharSet"
-  XNQueryOrientation* = "queryOrientation"
-  XNBaseFontName* = "baseFontName"
-  XNOMAutomatic* = "omAutomatic"
-  XNMissingCharSet* = "missingCharSet"
-  XNDefaultString* = "defaultString"
-  XNOrientation* = "orientation"
-  XNDirectionalDependentDrawing* = "directionalDependentDrawing"
-  XNContextualDrawing* = "contextualDrawing"
-  XNFontInfo* = "fontInfo"
-
-type 
-  PXOMCharSetList* = ptr TXOMCharSetList
-  TXOMCharSetList*{.final.} = object 
-    charset_count*: cint
-    charset_list*: PPChar
-
-  PXOrientation* = ptr TXOrientation
-  TXOrientation* = enum 
-    XOMOrientation_LTR_TTB, XOMOrientation_RTL_TTB, XOMOrientation_TTB_LTR, 
-    XOMOrientation_TTB_RTL, XOMOrientation_Context
-  PXOMOrientation* = ptr TXOMOrientation
-  TXOMOrientation*{.final.} = object 
-    num_orientation*: cint
-    orientation*: PXOrientation
-
-  PXOMFontInfo* = ptr TXOMFontInfo
-  TXOMFontInfo*{.final.} = object 
-    num_font*: cint
-    font_struct_list*: ptr PXFontStruct
-    font_name_list*: PPChar
-
-  PXIM* = ptr TXIM
-  TXIM*{.final.} = object 
-  PXIC* = ptr TXIC
-  TXIC*{.final.} = object 
-  TXIMProc* = proc (para1: TXIM, para2: TXPointer, para3: TXPointer){.cdecl.}
-  TXICProc* = proc (para1: TXIC, para2: TXPointer, para3: TXPointer): TBool{.
-      cdecl.}
-  TXIDProc* = proc (para1: PDisplay, para2: TXPointer, para3: TXPointer){.cdecl.}
-  PXIMStyle* = ptr TXIMStyle
-  TXIMStyle* = culong
-  PXIMStyles* = ptr TXIMStyles
-  TXIMStyles*{.final.} = object 
-    count_styles*: cushort
-    supported_styles*: PXIMStyle
-
-
-const 
-  XIMPreeditArea* = 0x00000001
-  XIMPreeditCallbacks* = 0x00000002
-  XIMPreeditPosition* = 0x00000004
-  XIMPreeditNothing* = 0x00000008
-  XIMPreeditNone* = 0x00000010
-  XIMStatusArea* = 0x00000100
-  XIMStatusCallbacks* = 0x00000200
-  XIMStatusNothing* = 0x00000400
-  XIMStatusNone* = 0x00000800
-  XNVaNestedList* = "XNVaNestedList"
-  XNQueryInputStyle* = "queryInputStyle"
-  XNClientWindow* = "clientWindow"
-  XNInputStyle* = "inputStyle"
-  XNFocusWindow* = "focusWindow"
-  XNResourceName* = "resourceName"
-  XNResourceClass* = "resourceClass"
-  XNGeometryCallback* = "geometryCallback"
-  XNDestroyCallback* = "destroyCallback"
-  XNFilterEvents* = "filterEvents"
-  XNPreeditStartCallback* = "preeditStartCallback"
-  XNPreeditDoneCallback* = "preeditDoneCallback"
-  XNPreeditDrawCallback* = "preeditDrawCallback"
-  XNPreeditCaretCallback* = "preeditCaretCallback"
-  XNPreeditStateNotifyCallback* = "preeditStateNotifyCallback"
-  XNPreeditAttributes* = "preeditAttributes"
-  XNStatusStartCallback* = "statusStartCallback"
-  XNStatusDoneCallback* = "statusDoneCallback"
-  XNStatusDrawCallback* = "statusDrawCallback"
-  XNStatusAttributes* = "statusAttributes"
-  XNArea* = "area"
-  XNAreaNeeded* = "areaNeeded"
-  XNSpotLocation* = "spotLocation"
-  XNColormap* = "colorMap"
-  XNStdColormap* = "stdColorMap"
-  XNForeground* = "foreground"
-  XNBackground* = "background"
-  XNBackgroundPixmap* = "backgroundPixmap"
-  XNFontSet* = "fontSet"
-  XNLineSpace* = "lineSpace"
-  XNCursor* = "cursor"
-  XNQueryIMValuesList* = "queryIMValuesList"
-  XNQueryICValuesList* = "queryICValuesList"
-  XNVisiblePosition* = "visiblePosition"
-  XNR6PreeditCallback* = "r6PreeditCallback"
-  XNStringConversionCallback* = "stringConversionCallback"
-  XNStringConversion* = "stringConversion"
-  XNResetState* = "resetState"
-  XNHotKey* = "hotKey"
-  XNHotKeyState* = "hotKeyState"
-  XNPreeditState* = "preeditState"
-  XNSeparatorofNestedList* = "separatorofNestedList"
-  XBufferOverflow* = - (1)
-  XLookupNone* = 1
-  XLookupChars* = 2
-  XLookupKeySymVal* = 3
-  XLookupBoth* = 4
-
-type 
-  PXVaNestedList* = ptr TXVaNestedList
-  TXVaNestedList* = pointer
-  PXIMCallback* = ptr TXIMCallback
-  TXIMCallback*{.final.} = object 
-    client_data*: TXPointer
-    callback*: TXIMProc
-
-  PXICCallback* = ptr TXICCallback
-  TXICCallback*{.final.} = object 
-    client_data*: TXPointer
-    callback*: TXICProc
-
-  PXIMFeedback* = ptr TXIMFeedback
-  TXIMFeedback* = culong
-
-const 
-  XIMReverse* = 1
-  XIMUnderline* = 1 shl 1
-  XIMHighlight* = 1 shl 2
-  XIMPrimary* = 1 shl 5
-  XIMSecondary* = 1 shl 6
-  XIMTertiary* = 1 shl 7
-  XIMVisibleToForward* = 1 shl 8
-  XIMVisibleToBackword* = 1 shl 9
-  XIMVisibleToCenter* = 1 shl 10
-
-type 
-  PXIMText* = ptr TXIMText
-  TXIMText*{.final.} = object 
-    len*: cushort
-    feedback*: PXIMFeedback
-    encoding_is_wchar*: TBool
-    multi_byte*: cstring
-
-  PXIMPreeditState* = ptr TXIMPreeditState
-  TXIMPreeditState* = culong
-
-const 
-  XIMPreeditUnKnown* = 0
-  XIMPreeditEnable* = 1
-  XIMPreeditDisable* = 1 shl 1
-
-type 
-  PXIMPreeditStateNotifyCallbackStruct* = ptr TXIMPreeditStateNotifyCallbackStruct
-  TXIMPreeditStateNotifyCallbackStruct*{.final.} = object 
-    state*: TXIMPreeditState
-
-  PXIMResetState* = ptr TXIMResetState
-  TXIMResetState* = culong
-
-const 
-  XIMInitialState* = 1
-  XIMPreserveState* = 1 shl 1
-
-type 
-  PXIMStringConversionFeedback* = ptr TXIMStringConversionFeedback
-  TXIMStringConversionFeedback* = culong
-
-const 
-  XIMStringConversionLeftEdge* = 0x00000001
-  XIMStringConversionRightEdge* = 0x00000002
-  XIMStringConversionTopEdge* = 0x00000004
-  XIMStringConversionBottomEdge* = 0x00000008
-  XIMStringConversionConcealed* = 0x00000010
-  XIMStringConversionWrapped* = 0x00000020
-
-type 
-  PXIMStringConversionText* = ptr TXIMStringConversionText
-  TXIMStringConversionText*{.final.} = object 
-    len*: cushort
-    feedback*: PXIMStringConversionFeedback
-    encoding_is_wchar*: TBool
-    mbs*: cstring
-
-  PXIMStringConversionPosition* = ptr TXIMStringConversionPosition
-  TXIMStringConversionPosition* = cushort
-  PXIMStringConversionType* = ptr TXIMStringConversionType
-  TXIMStringConversionType* = cushort
-
-const 
-  XIMStringConversionBuffer* = 0x00000001
-  XIMStringConversionLine* = 0x00000002
-  XIMStringConversionWord* = 0x00000003
-  XIMStringConversionChar* = 0x00000004
-
-type 
-  PXIMStringConversionOperation* = ptr TXIMStringConversionOperation
-  TXIMStringConversionOperation* = cushort
-
-const 
-  XIMStringConversionSubstitution* = 0x00000001
-  XIMStringConversionRetrieval* = 0x00000002
-
-type 
-  PXIMCaretDirection* = ptr TXIMCaretDirection
-  TXIMCaretDirection* = enum 
-    XIMForwardChar, XIMBackwardChar, XIMForwardWord, XIMBackwardWord, 
-    XIMCaretUp, XIMCaretDown, XIMNextLine, XIMPreviousLine, XIMLineStart, 
-    XIMLineEnd, XIMAbsolutePosition, XIMDontChange
-  PXIMStringConversionCallbackStruct* = ptr TXIMStringConversionCallbackStruct
-  TXIMStringConversionCallbackStruct*{.final.} = object 
-    position*: TXIMStringConversionPosition
-    direction*: TXIMCaretDirection
-    operation*: TXIMStringConversionOperation
-    factor*: cushort
-    text*: PXIMStringConversionText
-
-  PXIMPreeditDrawCallbackStruct* = ptr TXIMPreeditDrawCallbackStruct
-  TXIMPreeditDrawCallbackStruct*{.final.} = object 
-    caret*: cint
-    chg_first*: cint
-    chg_length*: cint
-    text*: PXIMText
-
-  PXIMCaretStyle* = ptr TXIMCaretStyle
-  TXIMCaretStyle* = enum 
-    XIMIsInvisible, XIMIsPrimary, XIMIsSecondary
-  PXIMPreeditCaretCallbackStruct* = ptr TXIMPreeditCaretCallbackStruct
-  TXIMPreeditCaretCallbackStruct*{.final.} = object 
-    position*: cint
-    direction*: TXIMCaretDirection
-    style*: TXIMCaretStyle
-
-  PXIMStatusDataType* = ptr TXIMStatusDataType
-  TXIMStatusDataType* = enum 
-    XIMTextType, XIMBitmapType
-  PXIMStatusDrawCallbackStruct* = ptr TXIMStatusDrawCallbackStruct
-  TXIMStatusDrawCallbackStruct*{.final.} = object 
-    theType*: TXIMStatusDataType
-    bitmap*: TPixmap
-
-  PXIMHotKeyTrigger* = ptr TXIMHotKeyTrigger
-  TXIMHotKeyTrigger*{.final.} = object 
-    keysym*: TKeySym
-    modifier*: cint
-    modifier_mask*: cint
-
-  PXIMHotKeyTriggers* = ptr TXIMHotKeyTriggers
-  TXIMHotKeyTriggers*{.final.} = object 
-    num_hot_key*: cint
-    key*: PXIMHotKeyTrigger
-
-  PXIMHotKeyState* = ptr TXIMHotKeyState
-  TXIMHotKeyState* = culong
-
-const 
-  XIMHotKeyStateON* = 0x00000001
-  XIMHotKeyStateOFF* = 0x00000002
-
-type 
-  PXIMValuesList* = ptr TXIMValuesList
-  TXIMValuesList*{.final.} = object 
-    count_values*: cushort
-    supported_values*: PPChar
-
-
-type 
-  funcdisp* = proc (display: PDisplay): cint{.cdecl.}
-  funcifevent* = proc (display: PDisplay, event: PXEvent, p: TXPointer): TBool{.
-      cdecl.}
-  chararr32* = array[0..31, char]
-
-const 
-  AllPlanes*: culong = culong(not 0)
-
-proc XLoadQueryFont*(para1: PDisplay, para2: cstring): PXFontStruct{.cdecl, 
-    dynlib: libX11, importc.}
-proc XQueryFont*(para1: PDisplay, para2: TXID): PXFontStruct{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetMotionEvents*(para1: PDisplay, para2: TWindow, para3: TTime, 
-                       para4: TTime, para5: Pcint): PXTimeCoord{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDeleteModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, 
-                              para3: cint): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetModifierMapping*(para1: PDisplay): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInsertModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, 
-                              para3: cint): PXModifierKeymap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XNewModifiermap*(para1: cint): PXModifierKeymap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, para4: cint, 
-                   para5: cint, para6: cstring, para7: cuint, para8: cuint, 
-                   para9: cint, para10: cint): PXImage{.cdecl, dynlib: libX11, 
-    importc.}
-proc XInitImage*(para1: PXImage): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, 
-                para5: cuint, para6: cuint, para7: culong, para8: cint): PXImage{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetSubImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, 
-                   para5: cuint, para6: cuint, para7: culong, para8: cint, 
-                   para9: PXImage, para10: cint, para11: cint): PXImage{.cdecl, 
-    dynlib: libX11, importc.}
-proc XOpenDisplay*(para1: cstring): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XrmInitialize*(){.cdecl, dynlib: libX11, importc.}
-proc XFetchBytes*(para1: PDisplay, para2: Pcint): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFetchBuffer*(para1: PDisplay, para2: Pcint, para3: cint): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetAtomName*(para1: PDisplay, para2: TAtom): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetAtomNames*(para1: PDisplay, para2: PAtom, para3: cint, para4: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetDefault*(para1: PDisplay, para2: cstring, para3: cstring): cstring{.
-    cdecl, dynlib: libX11, importc.}
-proc XDisplayName*(para1: cstring): cstring{.cdecl, dynlib: libX11, importc.}
-proc XKeysymToString*(para1: TKeySym): cstring{.cdecl, dynlib: libX11, importc.}
-proc XSynchronize*(para1: PDisplay, para2: TBool): funcdisp{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetAfterFunction*(para1: PDisplay, para2: funcdisp): funcdisp{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInternAtom*(para1: PDisplay, para2: cstring, para3: TBool): TAtom{.cdecl, 
-    dynlib: libX11, importc.}
-proc XInternAtoms*(para1: PDisplay, para2: PPchar, para3: cint, para4: TBool, 
-                   para5: PAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XCopyColormapAndFree*(para1: PDisplay, para2: TColormap): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreateColormap*(para1: PDisplay, para2: TWindow, para3: PVisual, 
-                      para4: cint): TColormap{.cdecl, dynlib: libX11, importc.}
-proc XCreatePixmapCursor*(para1: PDisplay, para2: TPixmap, para3: TPixmap, 
-                          para4: PXColor, para5: PXColor, para6: cuint, 
-                          para7: cuint): TCursor{.cdecl, dynlib: libX11, importc.}
-proc XCreateGlyphCursor*(para1: PDisplay, para2: TFont, para3: TFont, 
-                         para4: cuint, para5: cuint, para6: PXColor, 
-                         para7: PXColor): TCursor{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateFontCursor*(para1: PDisplay, para2: cuint): TCursor{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLoadFont*(para1: PDisplay, para2: cstring): TFont{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateGC*(para1: PDisplay, para2: TDrawable, para3: culong, 
-                para4: PXGCValues): TGC{.cdecl, dynlib: libX11, importc.}
-proc XGContextFromGC*(para1: TGC): TGContext{.cdecl, dynlib: libX11, importc.}
-proc XFlushGC*(para1: PDisplay, para2: TGC){.cdecl, dynlib: libX11, importc.}
-proc XCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                    para4: cuint, para5: cuint): TPixmap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateBitmapFromData*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                            para4: cuint, para5: cuint): TPixmap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreatePixmapFromBitmapData*(para1: PDisplay, para2: TDrawable, 
-                                  para3: cstring, para4: cuint, para5: cuint, 
-                                  para6: culong, para7: culong, para8: cuint): TPixmap{.
-    cdecl, dynlib: libX11, importc.}
-proc XCreateSimpleWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                          para4: cint, para5: cuint, para6: cuint, para7: cuint, 
-                          para8: culong, para9: culong): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetSelectionOwner*(para1: PDisplay, para2: TAtom): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCreateWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, 
-                    para5: cuint, para6: cuint, para7: cuint, para8: cint, 
-                    para9: cuint, para10: PVisual, para11: culong, 
-                    para12: PXSetWindowAttributes): TWindow{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListInstalledColormaps*(para1: PDisplay, para2: TWindow, para3: Pcint): PColormap{.
-    cdecl, dynlib: libX11, importc.}
-proc XListFonts*(para1: PDisplay, para2: cstring, para3: cint, para4: Pcint): PPChar{.
-    cdecl, dynlib: libX11, importc.}
-proc XListFontsWithInfo*(para1: PDisplay, para2: cstring, para3: cint, 
-                         para4: Pcint, para5: PPXFontStruct): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetFontPath*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListExtensions*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListProperties*(para1: PDisplay, para2: TWindow, para3: Pcint): PAtom{.
-    cdecl, dynlib: libX11, importc.}
-proc XListHosts*(para1: PDisplay, para2: Pcint, para3: PBool): PXHostAddress{.
-    cdecl, dynlib: libX11, importc.}
-proc XKeycodeToKeysym*(para1: PDisplay, para2: TKeyCode, para3: cint): TKeySym{.
-    cdecl, dynlib: libX11, importc.}
-proc XLookupKeysym*(para1: PXKeyEvent, para2: cint): TKeySym{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetKeyboardMapping*(para1: PDisplay, para2: TKeyCode, para3: cint, 
-                          para4: Pcint): PKeySym{.cdecl, dynlib: libX11, importc.}
-proc XStringToKeysym*(para1: cstring): TKeySym{.cdecl, dynlib: libX11, importc.}
-proc XMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, importc.}
-proc XExtendedMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XResourceManagerString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XScreenResourceString*(para1: PScreen): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayMotionBufferSize*(para1: PDisplay): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XVisualIDFromVisual*(para1: PVisual): TVisualID{.cdecl, dynlib: libX11, 
-    importc.}
-proc XInitThreads*(): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XLockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.}
-proc XUnlockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.}
-proc XInitExtension*(para1: PDisplay, para2: cstring): PXExtCodes{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddExtension*(para1: PDisplay): PXExtCodes{.cdecl, dynlib: libX11, importc.}
-proc XFindOnExtensionList*(para1: PPXExtData, para2: cint): PXExtData{.cdecl, 
-    dynlib: libX11, importc.}
-proc XEHeadOfExtensionList*(para1: TXEDataObject): PPXExtData{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRootWindow*(para1: PDisplay, para2: cint): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultRootWindow*(para1: PDisplay): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRootWindowOfScreen*(para1: PScreen): TWindow{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultVisual*(para1: PDisplay, para2: cint): PVisual{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultVisualOfScreen*(para1: PScreen): PVisual{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultGC*(para1: PDisplay, para2: cint): TGC{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultGCOfScreen*(para1: PScreen): TGC{.cdecl, dynlib: libX11, importc.}
-proc XBlackPixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XWhitePixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllPlanes*(): culong{.cdecl, dynlib: libX11, importc.}
-proc XBlackPixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XWhitePixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, 
-    importc.}
-proc XNextRequest*(para1: PDisplay): culong{.cdecl, dynlib: libX11, importc.}
-proc XLastKnownRequestProcessed*(para1: PDisplay): culong{.cdecl, 
-    dynlib: libX11, importc.}
-proc XServerVendor*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDisplayString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDefaultColormap*(para1: PDisplay, para2: cint): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultColormapOfScreen*(para1: PScreen): TColormap{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDisplayOfScreen*(para1: PScreen): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XScreenOfDisplay*(para1: PDisplay, para2: cint): PScreen{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDefaultScreenOfDisplay*(para1: PDisplay): PScreen{.cdecl, dynlib: libX11, 
-    importc.}
-proc XEventMaskOfScreen*(para1: PScreen): clong{.cdecl, dynlib: libX11, importc.}
-proc XScreenNumberOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  TXErrorHandler* = proc (para1: PDisplay, para2: PXErrorEvent): cint{.cdecl.}
-
-proc XSetErrorHandler*(para1: TXErrorHandler): TXErrorHandler{.cdecl, 
-    dynlib: libX11, importc.}
-type 
-  TXIOErrorHandler* = proc (para1: PDisplay): cint{.cdecl.}
-
-proc XSetIOErrorHandler*(para1: TXIOErrorHandler): TXIOErrorHandler{.cdecl, 
-    dynlib: libX11, importc.}
-proc XListPixmapFormats*(para1: PDisplay, para2: Pcint): PXPixmapFormatValues{.
-    cdecl, dynlib: libX11, importc.}
-proc XListDepths*(para1: PDisplay, para2: cint, para3: Pcint): Pcint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XReconfigureWMWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                           para4: cuint, para5: PXWindowChanges): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PPAtom, 
-                      para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PAtom, para4: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XIconifyWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XWithdrawWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetCommand*(para1: PDisplay, para2: TWindow, para3: PPPchar, para4: Pcint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PPWindow, 
-                            para4: Pcint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                            para4: cint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeStringList*(para1: PPchar){.cdecl, dynlib: libX11, importc.}
-proc XSetTransientForHint*(para1: PDisplay, para2: TWindow, para3: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XActivateScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAddHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XAddToExtensionList*(para1: PPXExtData, para2: PXExtData): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddToSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAllocColor*(para1: PDisplay, para2: TColormap, para3: PXColor): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XAllocColorCells*(para1: PDisplay, para2: TColormap, para3: TBool, 
-                       para4: Pculong, para5: cuint, para6: Pculong, 
-                       para7: cuint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XAllocColorPlanes*(para1: PDisplay, para2: TColormap, para3: TBool, 
-                        para4: Pculong, para5: cint, para6: cint, para7: cint, 
-                        para8: cint, para9: Pculong, para10: Pculong, 
-                        para11: Pculong): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                       para4: PXColor, para5: PXColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAllowEvents*(para1: PDisplay, para2: cint, para3: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XAutoRepeatOff*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XAutoRepeatOn*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBell*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapBitOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapPad*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XBitmapUnit*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XCellsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XChangeActivePointerGrab*(para1: PDisplay, para2: cuint, para3: TCursor, 
-                               para4: TTime): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XChangeGC*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XChangeKeyboardControl*(para1: PDisplay, para2: culong, 
-                             para3: PXKeyboardControl): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeKeyboardMapping*(para1: PDisplay, para2: cint, para3: cint, 
-                             para4: PKeySym, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangePointerControl*(para1: PDisplay, para2: TBool, para3: TBool, 
-                            para4: cint, para5: cint, para6: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, 
-                      para4: TAtom, para5: cint, para6: cint, para7: Pcuchar, 
-                      para8: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XChangeSaveSet*(para1: PDisplay, para2: TWindow, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XChangeWindowAttributes*(para1: PDisplay, para2: TWindow, para3: culong, 
-                              para4: PXSetWindowAttributes): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCheckIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-                    para4: TXPointer): TBool{.cdecl, dynlib: libX11, importc.}
-proc XCheckMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XCheckTypedEvent*(para1: PDisplay, para2: cint, para3: PXEvent): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XCheckTypedWindowEvent*(para1: PDisplay, para2: TWindow, para3: cint, 
-                             para4: PXEvent): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCheckWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, 
-                        para4: PXEvent): TBool{.cdecl, dynlib: libX11, importc.}
-proc XCirculateSubwindows*(para1: PDisplay, para2: TWindow, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCirculateSubwindowsDown*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCirculateSubwindowsUp*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XClearArea*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, 
-                 para5: cuint, para6: cuint, para7: TBool): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XClearWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XCloseDisplay*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XConfigureWindow*(para1: PDisplay, para2: TWindow, para3: cuint, 
-                       para4: PXWindowChanges): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XConnectionNumber*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XConvertSelection*(para1: PDisplay, para2: TAtom, para3: TAtom, 
-                        para4: TAtom, para5: TWindow, para6: TTime): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCopyArea*(para1: PDisplay, para2: TDrawable, para3: TDrawable, para4: TGC, 
-                para5: cint, para6: cint, para7: cuint, para8: cuint, 
-                para9: cint, para10: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XCopyGC*(para1: PDisplay, para2: TGC, para3: culong, para4: TGC): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XCopyPlane*(para1: PDisplay, para2: TDrawable, para3: TDrawable, 
-                 para4: TGC, para5: cint, para6: cint, para7: cuint, 
-                 para8: cuint, para9: cint, para10: cint, para11: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDefaultDepth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultDepthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDefaultScreen*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XDefineCursor*(para1: PDisplay, para2: TWindow, para3: TCursor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDeleteProperty*(para1: PDisplay, para2: TWindow, para3: TAtom): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDestroyWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDestroySubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDoesBackingStore*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XDoesSaveUnders*(para1: PScreen): TBool{.cdecl, dynlib: libX11, importc.}
-proc XDisableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayCells*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayHeight*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayHeightMM*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDisplayKeycodes*(para1: PDisplay, para2: Pcint, para3: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDisplayPlanes*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayWidth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayWidthMM*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-               para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, 
-                para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                       para4: cint, para5: cint, para6: cstring, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawImageString16*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                         para4: cint, para5: cint, para6: PXChar2b, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDrawLine*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                para5: cint, para6: cint, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawLines*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, 
-                 para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawPoint*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                 para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XDrawPoints*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, 
-                  para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDrawRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                     para5: cint, para6: cuint, para7: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                      para4: PXRectangle, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawSegments*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                    para4: PXSegment, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDrawString*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: cstring, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawString16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                    para5: cint, para6: PXChar2b, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                para5: cint, para6: PXTextItem, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XDrawText16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXTextItem16, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XEnableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XEventsQueued*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFetchName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-               para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, 
-                para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XFillPolygon*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                   para4: PXPoint, para5: cint, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFillRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                     para5: cint, para6: cuint, para7: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFillRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                      para4: PXRectangle, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFlush*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XForceScreenSaver*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFree*(para1: pointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeColors*(para1: PDisplay, para2: TColormap, para3: Pculong, 
-                  para4: cint, para5: culong): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeCursor*(para1: PDisplay, para2: TCursor): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreeExtensionList*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeFont*(para1: PDisplay, para2: PXFontStruct): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeFontInfo*(para1: PPchar, para2: PXFontStruct, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XFreeFontNames*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeFontPath*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeGC*(para1: PDisplay, para2: TGC): cint{.cdecl, dynlib: libX11, importc.}
-proc XFreeModifiermap*(para1: PXModifierKeymap): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFreePixmap*(para1: PDisplay, para2: TPixmap): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, 
-                para5: cuint, para6: cuint, para7: cuint, para8: cint, 
-                para9: cint, para10: Pcint, para11: Pcint, para12: Pcint, 
-                para13: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetErrorDatabaseText*(para1: PDisplay, para2: cstring, para3: cstring, 
-                            para4: cstring, para5: cstring, para6: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetErrorText*(para1: PDisplay, para2: cint, para3: cstring, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetFontProperty*(para1: PXFontStruct, para2: TAtom, para3: Pculong): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetGCValues*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetGeometry*(para1: PDisplay, para2: TDrawable, para3: PWindow, 
-                   para4: Pcint, para5: Pcint, para6: Pcuint, para7: Pcuint, 
-                   para8: Pcuint, para9: Pcuint): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetIconName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetInputFocus*(para1: PDisplay, para2: PWindow, para3: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetKeyboardControl*(para1: PDisplay, para2: PXKeyboardState): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetPointerControl*(para1: PDisplay, para2: Pcint, para3: Pcint, 
-                         para4: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetScreenSaver*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: Pcint, 
-                      para5: Pcint): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetTransientForHint*(para1: PDisplay, para2: TWindow, para3: PWindow): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWindowProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, 
-                         para4: clong, para5: clong, para6: TBool, para7: TAtom, 
-                         para8: PAtom, para9: Pcint, para10: Pculong, 
-                         para11: Pculong, para12: PPcuchar): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetWindowAttributes*(para1: PDisplay, para2: TWindow, 
-                           para3: PXWindowAttributes): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow, 
-                  para5: TBool, para6: cuint, para7: cint, para8: cint, 
-                  para9: TWindow, para10: TCursor): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow, 
-               para5: TBool, para6: cint, para7: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGrabKeyboard*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cint, 
-                    para5: cint, para6: TTime): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XGrabPointer*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cuint, 
-                   para5: cint, para6: cint, para7: TWindow, para8: TCursor, 
-                   para9: TTime): cint{.cdecl, dynlib: libX11, importc.}
-proc XGrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XHeightMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XHeightOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-               para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XImageByteOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XInstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XKeysymToKeycode*(para1: PDisplay, para2: TKeySym): TKeyCode{.cdecl, 
-    dynlib: libX11, importc.}
-proc XKillClient*(para1: PDisplay, para2: TXID): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                   para4: PXColor, para5: PXColor): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLowerWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMapRaised*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XMapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMaxCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XMinCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XMoveResizeWindow*(para1: PDisplay, para2: TWindow, para3: cint, 
-                        para4: cint, para5: cuint, para6: cuint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMoveWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XNextEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XNoOp*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XParseColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                  para4: PXColor): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XParseGeometry*(para1: cstring, para2: Pcint, para3: Pcint, para4: Pcuint, 
-                     para5: Pcuint): cint{.cdecl, dynlib: libX11, importc.}
-proc XPeekEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XPeekIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, 
-                   para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XPending*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XPlanesOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XProtocolRevision*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XProtocolVersion*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XPutBackEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXImage, 
-                para5: cint, para6: cint, para7: cint, para8: cint, 
-                para9: cuint, para10: cuint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQLength*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XQueryBestCursor*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                       para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestSize*(para1: PDisplay, para2: cint, para3: TDrawable, 
-                     para4: cuint, para5: cuint, para6: Pcuint, para7: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestStipple*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                        para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryBestTile*(para1: PDisplay, para2: TDrawable, para3: cuint, 
-                     para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XQueryColors*(para1: PDisplay, para2: TColormap, para3: PXColor, 
-                   para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XQueryExtension*(para1: PDisplay, para2: cstring, para3: Pcint, 
-                      para4: Pcint, para5: Pcint): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-  #?
-proc XQueryKeymap*(para1: PDisplay, para2: chararr32): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XQueryPointer*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                    para4: PWindow, para5: Pcint, para6: Pcint, para7: Pcint, 
-                    para8: Pcint, para9: Pcuint): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTextExtents*(para1: PDisplay, para2: TXID, para3: cstring, 
-                        para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, 
-                        para8: PXCharStruct): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTextExtents16*(para1: PDisplay, para2: TXID, para3: PXChar2b, 
-                          para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, 
-                          para8: PXCharStruct): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XQueryTree*(para1: PDisplay, para2: TWindow, para3: PWindow, 
-                 para4: PWindow, para5: PPWindow, para6: Pcuint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XRaiseWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XReadBitmapFile*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                      para4: Pcuint, para5: Pcuint, para6: PPixmap, 
-                      para7: Pcint, para8: Pcint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XReadBitmapFileData*(para1: cstring, para2: Pcuint, para3: Pcuint, 
-                          para4: PPcuchar, para5: Pcint, para6: Pcint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRebindKeysym*(para1: PDisplay, para2: TKeySym, para3: PKeySym, 
-                    para4: cint, para5: Pcuchar, para6: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRecolorCursor*(para1: PDisplay, para2: TCursor, para3: PXColor, 
-                     para4: PXColor): cint{.cdecl, dynlib: libX11, importc.}
-proc XRefreshKeyboardMapping*(para1: PXMappingEvent): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveFromSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRemoveHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XReparentWindow*(para1: PDisplay, para2: TWindow, para3: TWindow, 
-                      para4: cint, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XResetScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XResizeWindow*(para1: PDisplay, para2: TWindow, para3: cuint, para4: cuint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRestackWindows*(para1: PDisplay, para2: PWindow, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XRotateBuffers*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRotateWindowProperties*(para1: PDisplay, para2: TWindow, para3: PAtom, 
-                              para4: cint, para5: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XScreenCount*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XSelectInput*(para1: PDisplay, para2: TWindow, para3: clong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSendEvent*(para1: PDisplay, para2: TWindow, para3: TBool, para4: clong, 
-                 para5: PXEvent): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetAccessControl*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetArcMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetBackground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetClipMask*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetClipOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetClipRectangles*(para1: PDisplay, para2: TGC, para3: cint, para4: cint, 
-                         para5: PXRectangle, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetCloseDownMode*(para1: PDisplay, para2: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetCommand*(para1: PDisplay, para2: TWindow, para3: PPchar, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetDashes*(para1: PDisplay, para2: TGC, para3: cint, para4: cstring, 
-                 para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetFillRule*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFillStyle*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFont*(para1: PDisplay, para2: TGC, para3: TFont): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFontPath*(para1: PDisplay, para2: PPchar, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetForeground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetFunction*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetGraphicsExposures*(para1: PDisplay, para2: TGC, para3: TBool): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetIconName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetInputFocus*(para1: PDisplay, para2: TWindow, para3: cint, para4: TTime): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetLineAttributes*(para1: PDisplay, para2: TGC, para3: cuint, para4: cint, 
-                         para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetModifierMapping*(para1: PDisplay, para2: PXModifierKeymap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetPlaneMask*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetScreenSaver*(para1: PDisplay, para2: cint, para3: cint, para4: cint, 
-                      para5: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetSelectionOwner*(para1: PDisplay, para2: TAtom, para3: TWindow, 
-                         para4: TTime): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetState*(para1: PDisplay, para2: TGC, para3: culong, para4: culong, 
-                para5: cint, para6: culong): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSetStipple*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetSubwindowMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetTSOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetTile*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetWindowBackground*(para1: PDisplay, para2: TWindow, para3: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBackgroundPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorder*(para1: PDisplay, para2: TWindow, para3: culong): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorderPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowBorderWidth*(para1: PDisplay, para2: TWindow, para3: cuint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWindowColormap*(para1: PDisplay, para2: TWindow, para3: TColormap): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreBuffer*(para1: PDisplay, para2: cstring, para3: cint, para4: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreBytes*(para1: PDisplay, para2: cstring, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStoreColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XStoreColors*(para1: PDisplay, para2: TColormap, para3: PXColor, 
-                   para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XStoreName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStoreNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, 
-                       para4: culong, para5: cint): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XSync*(para1: PDisplay, para2: TBool): cint{.cdecl, dynlib: libX11, importc.}
-proc XTextExtents*(para1: PXFontStruct, para2: cstring, para3: cint, 
-                   para4: Pcint, para5: Pcint, para6: Pcint, para7: PXCharStruct): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XTextExtents16*(para1: PXFontStruct, para2: PXChar2b, para3: cint, 
-                     para4: Pcint, para5: Pcint, para6: Pcint, 
-                     para7: PXCharStruct): cint{.cdecl, dynlib: libX11, importc.}
-proc XTextWidth*(para1: PXFontStruct, para2: cstring, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XTextWidth16*(para1: PXFontStruct, para2: PXChar2b, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XTranslateCoordinates*(para1: PDisplay, para2: TWindow, para3: TWindow, 
-                            para4: cint, para5: cint, para6: Pcint, 
-                            para7: Pcint, para8: PWindow): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUndefineCursor*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUngrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUngrabKeyboard*(para1: PDisplay, para2: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabPointer*(para1: PDisplay, para2: TTime): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUngrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XUninstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnloadFont*(para1: PDisplay, para2: TFont): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XUnmapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnmapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XVendorRelease*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XWarpPointer*(para1: PDisplay, para2: TWindow, para3: TWindow, para4: cint, 
-                   para5: cint, para6: cuint, para7: cuint, para8: cint, 
-                   para9: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XWidthMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XWidthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.}
-proc XWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, para4: PXEvent): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XWriteBitmapFile*(para1: PDisplay, para2: cstring, para3: TPixmap, 
-                       para4: cuint, para5: cuint, para6: cint, para7: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSupportsLocale*(): TBool{.cdecl, dynlib: libX11, importc.}
-proc XSetLocaleModifiers*(para1: cstring): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XOpenOM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, 
-              para4: cstring): TXOM{.cdecl, dynlib: libX11, importc.}
-proc XCloseOM*(para1: TXOM): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XSetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayOfOM*(para1: TXOM): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XLocaleOfOM*(para1: TXOM): cstring{.cdecl, dynlib: libX11, importc.}
-proc XCreateOC*(para1: TXOM): TXOC{.varargs, cdecl, dynlib: libX11, importc.}
-proc XDestroyOC*(para1: TXOC){.cdecl, dynlib: libX11, importc.}
-proc XOMOfOC*(para1: TXOC): TXOM{.cdecl, dynlib: libX11, importc.}
-proc XSetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateFontSet*(para1: PDisplay, para2: cstring, para3: PPPchar, 
-                     para4: Pcint, para5: PPchar): TXFontSet{.cdecl, 
-    dynlib: libX11, importc.}
-proc XFreeFontSet*(para1: PDisplay, para2: TXFontSet){.cdecl, dynlib: libX11, 
-    importc.}
-proc XFontsOfFontSet*(para1: TXFontSet, para2: PPPXFontStruct, para3: PPPchar): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XBaseFontNameListOfFontSet*(para1: TXFontSet): cstring{.cdecl, 
-    dynlib: libX11, importc.}
-proc XLocaleOfFontSet*(para1: TXFontSet): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-proc XContextDependentDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XDirectionalDependentDrawing*(para1: TXFontSet): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XContextualDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XExtentsOfFontSet*(para1: TXFontSet): PXFontSetExtents{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbTextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextEscapement*(para1: TXFontSet, para2: PWideChar, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XmbTextExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                     para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcTextExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, 
-                     para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8TextExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                       para4: PXRectangle, para5: PXRectangle): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbTextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                            para4: PXRectangle, para5: PXRectangle, para6: cint, 
-                            para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextPerCharExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, 
-                            para4: PXRectangle, para5: PXRectangle, para6: cint, 
-                            para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, 
-                              para4: PXRectangle, para5: PXRectangle, 
-                              para6: cint, para7: Pcint, para8: PXRectangle, 
-                              para9: PXRectangle): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                  para5: cint, para6: PXwcTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8DrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, 
-                    para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                    para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                    para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XwcDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                    para4: TGC, para5: cint, para6: cint, para7: PWideChar, 
-                    para8: cint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8DrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                      para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                      para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XmbDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                         para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                         para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XwcDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                         para4: TGC, para5: cint, para6: cint, para7: PWideChar, 
-                         para8: cint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8DrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, 
-                           para4: TGC, para5: cint, para6: cint, para7: cstring, 
-                           para8: cint){.cdecl, dynlib: libX11, importc.}
-proc XOpenIM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, 
-              para4: cstring): TXIM{.cdecl, dynlib: libX11, importc.}
-proc XCloseIM*(para1: TXIM): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XSetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XDisplayOfIM*(para1: TXIM): PDisplay{.cdecl, dynlib: libX11, importc.}
-proc XLocaleOfIM*(para1: TXIM): cstring{.cdecl, dynlib: libX11, importc.}
-proc XCreateIC*(para1: TXIM): TXIC{.varargs, cdecl, dynlib: libX11, importc.}
-proc XDestroyIC*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XSetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XUnsetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.}
-proc XwcResetIC*(para1: TXIC): PWideChar{.cdecl, dynlib: libX11, importc.}
-proc XmbResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.}
-proc Xutf8ResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.}
-proc XSetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XGetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, 
-    importc.}
-proc XIMOfIC*(para1: TXIC): TXIM{.cdecl, dynlib: libX11, importc.}
-proc XFilterEvent*(para1: PXEvent, para2: TWindow): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XmbLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, 
-                      para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: PWideChar, 
-                      para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8LookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, 
-                        para4: cint, para5: PKeySym, para6: PStatus): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XVaCreateNestedList*(unused: cint): TXVaNestedList{.varargs, cdecl, 
-    dynlib: libX11, importc.}
-proc XRegisterIMInstantiateCallback*(para1: PDisplay, para2: PXrmHashBucketRec, 
-                                     para3: cstring, para4: cstring, 
-                                     para5: TXIDProc, para6: TXPointer): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XUnregisterIMInstantiateCallback*(para1: PDisplay, 
-                                       para2: PXrmHashBucketRec, para3: cstring, 
-                                       para4: cstring, para5: TXIDProc, 
-                                       para6: TXPointer): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-type 
-  TXConnectionWatchProc* = proc (para1: PDisplay, para2: TXPointer, para3: cint, 
-                                 para4: TBool, para5: PXPointer){.cdecl.}
-
-proc XInternalConnectionNumbers*(para1: PDisplay, para2: PPcint, para3: Pcint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XProcessInternalConnection*(para1: PDisplay, para2: cint){.cdecl, 
-    dynlib: libX11, importc.}
-proc XAddConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, 
-                          para3: TXPointer): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRemoveConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, 
-                             para3: TXPointer){.cdecl, dynlib: libX11, importc.}
-proc XSetAuthorization*(para1: cstring, para2: cint, para3: cstring, para4: cint){.
-    cdecl, dynlib: libX11, importc.}
-  #
-  #  _Xmbtowc?
-  #  _Xwctomb?
-  #
-when defined(MACROS): 
-  proc ConnectionNumber*(dpy: PDisplay): cint
-  proc RootWindow*(dpy: PDisplay, scr: cint): TWindow
-  proc DefaultScreen*(dpy: PDisplay): cint
-  proc DefaultRootWindow*(dpy: PDisplay): TWindow
-  proc DefaultVisual*(dpy: PDisplay, scr: cint): PVisual
-  proc DefaultGC*(dpy: PDisplay, scr: cint): TGC
-  proc BlackPixel*(dpy: PDisplay, scr: cint): culong
-  proc WhitePixel*(dpy: PDisplay, scr: cint): culong
-  proc QLength*(dpy: PDisplay): cint
-  proc DisplayWidth*(dpy: PDisplay, scr: cint): cint
-  proc DisplayHeight*(dpy: PDisplay, scr: cint): cint
-  proc DisplayWidthMM*(dpy: PDisplay, scr: cint): cint
-  proc DisplayHeightMM*(dpy: PDisplay, scr: cint): cint
-  proc DisplayPlanes*(dpy: PDisplay, scr: cint): cint
-  proc DisplayCells*(dpy: PDisplay, scr: cint): cint
-  proc ScreenCount*(dpy: PDisplay): cint
-  proc ServerVendor*(dpy: PDisplay): cstring
-  proc ProtocolVersion*(dpy: PDisplay): cint
-  proc ProtocolRevision*(dpy: PDisplay): cint
-  proc VendorRelease*(dpy: PDisplay): cint
-  proc DisplayString*(dpy: PDisplay): cstring
-  proc DefaultDepth*(dpy: PDisplay, scr: cint): cint
-  proc DefaultColormap*(dpy: PDisplay, scr: cint): TColormap
-  proc BitmapUnit*(dpy: PDisplay): cint
-  proc BitmapBitOrder*(dpy: PDisplay): cint
-  proc BitmapPad*(dpy: PDisplay): cint
-  proc ImageByteOrder*(dpy: PDisplay): cint
-  proc NextRequest*(dpy: PDisplay): culong
-  proc LastKnownRequestProcessed*(dpy: PDisplay): culong
-  proc ScreenOfDisplay*(dpy: PDisplay, scr: cint): PScreen
-  proc DefaultScreenOfDisplay*(dpy: PDisplay): PScreen
-  proc DisplayOfScreen*(s: PScreen): PDisplay
-  proc RootWindowOfScreen*(s: PScreen): TWindow
-  proc BlackPixelOfScreen*(s: PScreen): culong
-  proc WhitePixelOfScreen*(s: PScreen): culong
-  proc DefaultColormapOfScreen*(s: PScreen): TColormap
-  proc DefaultDepthOfScreen*(s: PScreen): cint
-  proc DefaultGCOfScreen*(s: PScreen): TGC
-  proc DefaultVisualOfScreen*(s: PScreen): PVisual
-  proc WidthOfScreen*(s: PScreen): cint
-  proc HeightOfScreen*(s: PScreen): cint
-  proc WidthMMOfScreen*(s: PScreen): cint
-  proc HeightMMOfScreen*(s: PScreen): cint
-  proc PlanesOfScreen*(s: PScreen): cint
-  proc CellsOfScreen*(s: PScreen): cint
-  proc MinCmapsOfScreen*(s: PScreen): cint
-  proc MaxCmapsOfScreen*(s: PScreen): cint
-  proc DoesSaveUnders*(s: PScreen): TBool
-  proc DoesBackingStore*(s: PScreen): cint
-  proc EventMaskOfScreen*(s: PScreen): clong
-  proc XAllocID*(dpy: PDisplay): TXID
-# implementation
-
-when defined(MACROS): 
-  proc ConnectionNumber(dpy: PDisplay): cint = 
-    ConnectionNumber = (PXPrivDisplay(dpy))^ .fd
-
-  proc RootWindow(dpy: PDisplay, scr: cint): TWindow = 
-    RootWindow = (ScreenOfDisplay(dpy, scr))^ .root
-
-  proc DefaultScreen(dpy: PDisplay): cint = 
-    DefaultScreen = (PXPrivDisplay(dpy))^ .default_screen
-
-  proc DefaultRootWindow(dpy: PDisplay): TWindow = 
-    DefaultRootWindow = (ScreenOfDisplay(dpy, DefaultScreen(dpy)))^ .root
-
-  proc DefaultVisual(dpy: PDisplay, scr: cint): PVisual = 
-    DefaultVisual = (ScreenOfDisplay(dpy, scr))^ .root_visual
-
-  proc DefaultGC(dpy: PDisplay, scr: cint): TGC = 
-    DefaultGC = (ScreenOfDisplay(dpy, scr))^ .default_gc
-
-  proc BlackPixel(dpy: PDisplay, scr: cint): culong = 
-    BlackPixel = (ScreenOfDisplay(dpy, scr))^ .black_pixel
-
-  proc WhitePixel(dpy: PDisplay, scr: cint): culong = 
-    WhitePixel = (ScreenOfDisplay(dpy, scr))^ .white_pixel
-
-  proc QLength(dpy: PDisplay): cint = 
-    QLength = (PXPrivDisplay(dpy))^ .qlen
-
-  proc DisplayWidth(dpy: PDisplay, scr: cint): cint = 
-    DisplayWidth = (ScreenOfDisplay(dpy, scr))^ .width
-
-  proc DisplayHeight(dpy: PDisplay, scr: cint): cint = 
-    DisplayHeight = (ScreenOfDisplay(dpy, scr))^ .height
-
-  proc DisplayWidthMM(dpy: PDisplay, scr: cint): cint = 
-    DisplayWidthMM = (ScreenOfDisplay(dpy, scr))^ .mwidth
-
-  proc DisplayHeightMM(dpy: PDisplay, scr: cint): cint = 
-    DisplayHeightMM = (ScreenOfDisplay(dpy, scr))^ .mheight
-
-  proc DisplayPlanes(dpy: PDisplay, scr: cint): cint = 
-    DisplayPlanes = (ScreenOfDisplay(dpy, scr))^ .root_depth
-
-  proc DisplayCells(dpy: PDisplay, scr: cint): cint = 
-    DisplayCells = (DefaultVisual(dpy, scr))^ .map_entries
-
-  proc ScreenCount(dpy: PDisplay): cint = 
-    ScreenCount = (PXPrivDisplay(dpy))^ .nscreens
-
-  proc ServerVendor(dpy: PDisplay): cstring = 
-    ServerVendor = (PXPrivDisplay(dpy))^ .vendor
-
-  proc ProtocolVersion(dpy: PDisplay): cint = 
-    ProtocolVersion = (PXPrivDisplay(dpy))^ .proto_major_version
-
-  proc ProtocolRevision(dpy: PDisplay): cint = 
-    ProtocolRevision = (PXPrivDisplay(dpy))^ .proto_minor_version
-
-  proc VendorRelease(dpy: PDisplay): cint = 
-    VendorRelease = (PXPrivDisplay(dpy))^ .release
-
-  proc DisplayString(dpy: PDisplay): cstring = 
-    DisplayString = (PXPrivDisplay(dpy))^ .display_name
-
-  proc DefaultDepth(dpy: PDisplay, scr: cint): cint = 
-    DefaultDepth = (ScreenOfDisplay(dpy, scr))^ .root_depth
-
-  proc DefaultColormap(dpy: PDisplay, scr: cint): TColormap = 
-    DefaultColormap = (ScreenOfDisplay(dpy, scr))^ .cmap
-
-  proc BitmapUnit(dpy: PDisplay): cint = 
-    BitmapUnit = (PXPrivDisplay(dpy))^ .bitmap_unit
-
-  proc BitmapBitOrder(dpy: PDisplay): cint = 
-    BitmapBitOrder = (PXPrivDisplay(dpy))^ .bitmap_bit_order
-
-  proc BitmapPad(dpy: PDisplay): cint = 
-    BitmapPad = (PXPrivDisplay(dpy))^ .bitmap_pad
-
-  proc ImageByteOrder(dpy: PDisplay): cint = 
-    ImageByteOrder = (PXPrivDisplay(dpy))^ .byte_order
-
-  proc NextRequest(dpy: PDisplay): culong = 
-    NextRequest = ((PXPrivDisplay(dpy))^ .request) + 1
-
-  proc LastKnownRequestProcessed(dpy: PDisplay): culong = 
-    LastKnownRequestProcessed = (PXPrivDisplay(dpy))^ .last_request_read
-
-  proc ScreenOfDisplay(dpy: PDisplay, scr: cint): PScreen = 
-    ScreenOfDisplay = addr((((PXPrivDisplay(dpy))^ .screens)[scr]))
-
-  proc DefaultScreenOfDisplay(dpy: PDisplay): PScreen = 
-    DefaultScreenOfDisplay = ScreenOfDisplay(dpy, DefaultScreen(dpy))
-
-  proc DisplayOfScreen(s: PScreen): PDisplay = 
-    DisplayOfScreen = s^ .display
-
-  proc RootWindowOfScreen(s: PScreen): TWindow = 
-    RootWindowOfScreen = s^ .root
-
-  proc BlackPixelOfScreen(s: PScreen): culong = 
-    BlackPixelOfScreen = s^ .black_pixel
-
-  proc WhitePixelOfScreen(s: PScreen): culong = 
-    WhitePixelOfScreen = s^ .white_pixel
-
-  proc DefaultColormapOfScreen(s: PScreen): TColormap = 
-    DefaultColormapOfScreen = s^ .cmap
-
-  proc DefaultDepthOfScreen(s: PScreen): cint = 
-    DefaultDepthOfScreen = s^ .root_depth
-
-  proc DefaultGCOfScreen(s: PScreen): TGC = 
-    DefaultGCOfScreen = s^ .default_gc
-
-  proc DefaultVisualOfScreen(s: PScreen): PVisual = 
-    DefaultVisualOfScreen = s^ .root_visual
-
-  proc WidthOfScreen(s: PScreen): cint = 
-    WidthOfScreen = s^ .width
-
-  proc HeightOfScreen(s: PScreen): cint = 
-    HeightOfScreen = s^ .height
-
-  proc WidthMMOfScreen(s: PScreen): cint = 
-    WidthMMOfScreen = s^ .mwidth
-
-  proc HeightMMOfScreen(s: PScreen): cint = 
-    HeightMMOfScreen = s^ .mheight
-
-  proc PlanesOfScreen(s: PScreen): cint = 
-    PlanesOfScreen = s^ .root_depth
-
-  proc CellsOfScreen(s: PScreen): cint = 
-    CellsOfScreen = (DefaultVisualOfScreen(s))^ .map_entries
-
-  proc MinCmapsOfScreen(s: PScreen): cint = 
-    MinCmapsOfScreen = s^ .min_maps
-
-  proc MaxCmapsOfScreen(s: PScreen): cint = 
-    MaxCmapsOfScreen = s^ .max_maps
-
-  proc DoesSaveUnders(s: PScreen): TBool = 
-    DoesSaveUnders = s^ .save_unders
-
-  proc DoesBackingStore(s: PScreen): cint = 
-    DoesBackingStore = s^ .backing_store
-
-  proc EventMaskOfScreen(s: PScreen): clong = 
-    EventMaskOfScreen = s^ .root_input_mask
-
-  proc XAllocID(dpy: PDisplay): TXID = 
-    XAllocID = (PXPrivDisplay(dpy))^ .resource_alloc(dpy)
diff --git a/lib/wrappers/x11/xrandr.nim b/lib/wrappers/x11/xrandr.nim
deleted file mode 100755
index ee6f1705b..000000000
--- a/lib/wrappers/x11/xrandr.nim
+++ /dev/null
@@ -1,194 +0,0 @@
-#
-#  $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
-# 
-#  Copyright (C) 2000 Compaq Computer Corporation, Inc.
-#  Copyright (C) 2002 Hewlett-Packard Company, Inc.
-# 
-#  Permission to use, copy, modify, distribute, and sell this software and its
-#  documentation for any purpose is hereby granted without fee, provided that
-#  the above copyright notice appear in all copies and that both that
-#  copyright notice and this permission notice appear in supporting
-#  documentation, and that the name of Compaq not be used in advertising or
-#  publicity pertaining to distribution of the software without specific,
-#  written prior permission.  HP makes no representations about the
-#  suitability of this software for any purpose.  It is provided "as is"
-#  without express or implied warranty.
-# 
-#  HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
-#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-#  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-#  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
-#  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# 
-#  Author:  Jim Gettys, HP Labs, HP.
-#
-
-import 
-  x, xlib
-
-const 
-  libXrandr* = "libXrandr.so"
-  
-# * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $
-# *
-# * Copyright (C) 2000, Compaq Computer Corporation, 
-# * Copyright (C) 2002, Hewlett Packard, Inc.
-# *
-# * Permission to use, copy, modify, distribute, and sell this software and its
-# * documentation for any purpose is hereby granted without fee, provided that
-# * the above copyright notice appear in all copies and that both that
-# * copyright notice and this permission notice appear in supporting
-# * documentation, and that the name of Compaq or HP not be used in advertising
-# * or publicity pertaining to distribution of the software without specific,
-# * written prior permission.  HP makes no representations about the
-# * suitability of this software for any purpose.  It is provided "as is"
-# * without express or implied warranty.
-# *
-# * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
-# * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-# * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
-# * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# *
-# * Author:  Jim Gettys, HP Labs, Hewlett-Packard, Inc.
-# *
-
-type 
-  PRotation* = ptr TRotation
-  TRotation* = cushort
-  PSizeID* = ptr TSizeID
-  TSizeID* = cushort
-  PSubpixelOrder* = ptr TSubpixelOrder
-  TSubpixelOrder* = cushort
-
-const 
-  RANDR_NAME* = "RANDR"
-  RANDR_MAJOR* = 1
-  RANDR_MINOR* = 1
-  RRNumberErrors* = 0
-  RRNumberEvents* = 1
-  constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately 
-  X_RROldGetScreenInfo* = 1
-  X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id 
-  constX_RRSetScreenConfig* = 2
-  X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated 
-  constX_RRSelectInput* = 4
-  constX_RRGetScreenInfo* = 5      # used in XRRSelectInput 
-  RRScreenChangeNotifyMask* = 1 shl 0
-  RRScreenChangeNotify* = 0   # used in the rotation field; rotation and reflection in 0.1 proto. 
-  RR_Rotate_0* = 1
-  RR_Rotate_90* = 2
-  RR_Rotate_180* = 4
-  RR_Rotate_270* = 8          # new in 1.0 protocol, to allow reflection of screen 
-  RR_Reflect_X* = 16
-  RR_Reflect_Y* = 32
-  RRSetConfigSuccess* = 0
-  RRSetConfigInvalidConfigTime* = 1
-  RRSetConfigInvalidTime* = 2
-  RRSetConfigFailed* = 3
-
-type 
-  PXRRScreenSize* = ptr TXRRScreenSize
-  TXRRScreenSize*{.final.} = object  #
-                                     #   Events.
-                                     #
-    width*, height*: cint
-    mwidth*, mheight*: cint
-
-  TXRRScreenChangeNotifyEvent*{.final.} = object  # internal representation is private to the library 
-    typ*: cint                # event base 
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    window*: TWindow          # window which selected for this event 
-    root*: TWindow            # Root window for changed screen 
-    timestamp*: TTime         # when the screen change occurred 
-    config_timestamp*: TTime  # when the last configuration change 
-    size_index*: TSizeID
-    subpixel_order*: TSubpixelOrder
-    rotation*: TRotation
-    width*: cint
-    height*: cint
-    mwidth*: cint
-    mheight*: cint
-
-  PXRRScreenConfiguration* = ptr TXRRScreenConfiguration
-  TXRRScreenConfiguration*{.final.} = object 
-
-proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint, 
-                      minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr, 
-    importc.}
-proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  Note that screen configuration changes are only permitted if the client can
-  #  prove it has up to date configuration information.  We are trying to
-  #  insist that it become possible for screens to change dynamically, so
-  #  we want to ensure the client knows what it is talking about when requesting
-  #  changes.
-  #
-proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration, 
-                         draw: TDrawable, size_index: cint, rotation: TRotation, 
-                         timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr, 
-    importc.}
-  # added in v1.1, sorry for the lame name 
-proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration, 
-                                draw: TDrawable, size_index: cint, 
-                                rotation: TRotation, rate: cshort, 
-                                timestamp: TTime): TStatus{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigRotations*(config: PXRRScreenConfiguration, 
-                         current_rotation: PRotation): TRotation{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint, 
-                     nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.}
-proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration, 
-                                    rotation: PRotation): TSizeID{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  returns the screen configuration for the specified screen; does a lazy
-  #  evalution to delay getting the information, and caches the result.
-  #  These routines should be used in preference to XRRGetScreenInfo
-  #  to avoid unneeded round trips to the X server.  These are new
-  #  in protocol version 0.1.
-  #
-proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl, 
-    dynlib: libXrandr, importc.}
-proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl, 
-    dynlib: libXrandr, importc.}
-  #
-  #  the following are always safe to call, even if RandR is not implemented 
-  #  on a screen 
-  #
-proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{.
-    cdecl, dynlib: libXrandr, importc.}
-proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{.
-    cdecl, dynlib: libXrandr, importc.}
-  #
-  #  intended to take RRScreenChangeNotify,  or 
-  #  ConfigureNotify (on the root window)
-  #  returns 1 if it is an event type it understands, 0 if not
-  #
-proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr, 
-    importc.}
-# implementation
diff --git a/lib/wrappers/x11/xrender.nim b/lib/wrappers/x11/xrender.nim
deleted file mode 100755
index 7b85fc9a7..000000000
--- a/lib/wrappers/x11/xrender.nim
+++ /dev/null
@@ -1,231 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xrender.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xrender.h
-#
-
-type 
-  PGlyph* = ptr TGlyph
-  TGlyph* = int32
-  PGlyphSet* = ptr TGlyphSet
-  TGlyphSet* = int32
-  PPicture* = ptr TPicture
-  TPicture* = int32
-  PPictFormat* = ptr TPictFormat
-  TPictFormat* = int32
-
-const 
-  RENDER_NAME* = "RENDER"
-  RENDER_MAJOR* = 0
-  RENDER_MINOR* = 0
-  constX_RenderQueryVersion* = 0
-  X_RenderQueryPictFormats* = 1
-  X_RenderQueryPictIndexValues* = 2
-  X_RenderQueryDithers* = 3
-  constX_RenderCreatePicture* = 4
-  constX_RenderChangePicture* = 5
-  X_RenderSetPictureClipRectangles* = 6
-  constX_RenderFreePicture* = 7
-  constX_RenderComposite* = 8
-  X_RenderScale* = 9
-  X_RenderTrapezoids* = 10
-  X_RenderTriangles* = 11
-  X_RenderTriStrip* = 12
-  X_RenderTriFan* = 13
-  X_RenderColorTrapezoids* = 14
-  X_RenderColorTriangles* = 15
-  X_RenderTransform* = 16
-  constX_RenderCreateGlyphSet* = 17
-  constX_RenderReferenceGlyphSet* = 18
-  constX_RenderFreeGlyphSet* = 19
-  constX_RenderAddGlyphs* = 20
-  constX_RenderAddGlyphsFromPicture* = 21
-  constX_RenderFreeGlyphs* = 22
-  constX_RenderCompositeGlyphs8* = 23
-  constX_RenderCompositeGlyphs16* = 24
-  constX_RenderCompositeGlyphs32* = 25
-  BadPictFormat* = 0
-  BadPicture* = 1
-  BadPictOp* = 2
-  BadGlyphSet* = 3
-  BadGlyph* = 4
-  RenderNumberErrors* = BadGlyph + 1
-  PictTypeIndexed* = 0
-  PictTypeDirect* = 1
-  PictOpClear* = 0
-  PictOpSrc* = 1
-  PictOpDst* = 2
-  PictOpOver* = 3
-  PictOpOverReverse* = 4
-  PictOpIn* = 5
-  PictOpInReverse* = 6
-  PictOpOut* = 7
-  PictOpOutReverse* = 8
-  PictOpAtop* = 9
-  PictOpAtopReverse* = 10
-  PictOpXor* = 11
-  PictOpAdd* = 12
-  PictOpSaturate* = 13
-  PictOpMaximum* = 13
-  PolyEdgeSharp* = 0
-  PolyEdgeSmooth* = 1
-  PolyModePrecise* = 0
-  PolyModeImprecise* = 1
-  CPRepeat* = 1 shl 0
-  CPAlphaMap* = 1 shl 1
-  CPAlphaXOrigin* = 1 shl 2
-  CPAlphaYOrigin* = 1 shl 3
-  CPClipXOrigin* = 1 shl 4
-  CPClipYOrigin* = 1 shl 5
-  CPClipMask* = 1 shl 6
-  CPGraphicsExposure* = 1 shl 7
-  CPSubwindowMode* = 1 shl 8
-  CPPolyEdge* = 1 shl 9
-  CPPolyMode* = 1 shl 10
-  CPDither* = 1 shl 11
-  CPLastBit* = 11
-
-type 
-  PXRenderDirectFormat* = ptr TXRenderDirectFormat
-  TXRenderDirectFormat*{.final.} = object 
-    red*: int16
-    redMask*: int16
-    green*: int16
-    greenMask*: int16
-    blue*: int16
-    blueMask*: int16
-    alpha*: int16
-    alphaMask*: int16
-
-  PXRenderPictFormat* = ptr TXRenderPictFormat
-  TXRenderPictFormat*{.final.} = object 
-    id*: TPictFormat
-    thetype*: int32
-    depth*: int32
-    direct*: TXRenderDirectFormat
-    colormap*: TColormap
-
-
-const 
-  PictFormatID* = 1 shl 0
-  PictFormatType* = 1 shl 1
-  PictFormatDepth* = 1 shl 2
-  PictFormatRed* = 1 shl 3
-  PictFormatRedMask* = 1 shl 4
-  PictFormatGreen* = 1 shl 5
-  PictFormatGreenMask* = 1 shl 6
-  PictFormatBlue* = 1 shl 7
-  PictFormatBlueMask* = 1 shl 8
-  PictFormatAlpha* = 1 shl 9
-  PictFormatAlphaMask* = 1 shl 10
-  PictFormatColormap* = 1 shl 11
-
-type 
-  PXRenderVisual* = ptr TXRenderVisual
-  TXRenderVisual*{.final.} = object 
-    visual*: PVisual
-    format*: PXRenderPictFormat
-
-  PXRenderDepth* = ptr TXRenderDepth
-  TXRenderDepth*{.final.} = object 
-    depth*: int32
-    nvisuals*: int32
-    visuals*: PXRenderVisual
-
-  PXRenderScreen* = ptr TXRenderScreen
-  TXRenderScreen*{.final.} = object 
-    depths*: PXRenderDepth
-    ndepths*: int32
-    fallback*: PXRenderPictFormat
-
-  PXRenderInfo* = ptr TXRenderInfo
-  TXRenderInfo*{.final.} = object 
-    format*: PXRenderPictFormat
-    nformat*: int32
-    screen*: PXRenderScreen
-    nscreen*: int32
-    depth*: PXRenderDepth
-    ndepth*: int32
-    visual*: PXRenderVisual
-    nvisual*: int32
-
-  PXRenderPictureAttributes* = ptr TXRenderPictureAttributes
-  TXRenderPictureAttributes*{.final.} = object 
-    repeat*: TBool
-    alpha_map*: TPicture
-    alpha_x_origin*: int32
-    alpha_y_origin*: int32
-    clip_x_origin*: int32
-    clip_y_origin*: int32
-    clip_mask*: TPixmap
-    graphics_exposures*: TBool
-    subwindow_mode*: int32
-    poly_edge*: int32
-    poly_mode*: int32
-    dither*: TAtom
-
-  PXGlyphInfo* = ptr TXGlyphInfo
-  TXGlyphInfo*{.final.} = object 
-    width*: int16
-    height*: int16
-    x*: int16
-    y*: int16
-    xOff*: int16
-    yOff*: int16
-
-
-proc XRenderQueryExtension*(dpy: PDisplay, event_basep: ptr int32, 
-                            error_basep: ptr int32): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderQueryVersion*(dpy: PDisplay, major_versionp: ptr int32, 
-                          minor_versionp: ptr int32): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XRenderFindVisualFormat*(dpy: PDisplay, visual: PVisual): PXRenderPictFormat{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderFindFormat*(dpy: PDisplay, mask: int32, 
-                        `template`: PXRenderPictFormat, count: int32): PXRenderPictFormat{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderCreatePicture*(dpy: PDisplay, drawable: TDrawable, 
-                           format: PXRenderPictFormat, valuemask: int32, 
-                           attributes: PXRenderPictureAttributes): TPicture{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderChangePicture*(dpy: PDisplay, picture: TPicture, valuemask: int32, 
-                           attributes: PXRenderPictureAttributes){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderComposite*(dpy: PDisplay, op: int32, src: TPicture, mask: TPicture, 
-                       dst: TPicture, src_x: int32, src_y: int32, mask_x: int32, 
-                       mask_y: int32, dst_x: int32, dst_y: int32, width: int32, 
-                       height: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderCreateGlyphSet*(dpy: PDisplay, format: PXRenderPictFormat): TGlyphSet{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderReferenceGlyphSet*(dpy: PDisplay, existing: TGlyphSet): TGlyphSet{.
-    cdecl, dynlib: libX11, importc.}
-proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.cdecl, 
-    dynlib: libX11, importc.}
-proc XRenderAddGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, 
-                       glyphs: PXGlyphInfo, nglyphs: int32, images: cstring, 
-                       nbyte_images: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderFreeGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, 
-                        nglyphs: int32){.cdecl, dynlib: libX11, importc.}
-proc XRenderCompositeString8*(dpy: PDisplay, op: int32, src: TPicture, 
-                              dst: TPicture, maskFormat: PXRenderPictFormat, 
-                              glyphset: TGlyphSet, xSrc: int32, ySrc: int32, 
-                              xDst: int32, yDst: int32, str: cstring, 
-                              nchar: int32){.cdecl, dynlib: libX11, importc.}
-# implementation
diff --git a/lib/wrappers/x11/xresource.nim b/lib/wrappers/x11/xresource.nim
deleted file mode 100755
index ddb2a89c2..000000000
--- a/lib/wrappers/x11/xresource.nim
+++ /dev/null
@@ -1,200 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xresource.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xresource.h
-#
-
-proc Xpermalloc*(para1: int32): cstring{.cdecl, dynlib: libX11, importc.}
-type 
-  PXrmQuark* = ptr TXrmQuark
-  TXrmQuark* = int32
-  TXrmQuarkList* = PXrmQuark
-  PXrmQuarkList* = ptr TXrmQuarkList
-
-proc NULLQUARK*(): TXrmQuark
-type 
-  PXrmString* = ptr TXrmString
-  TXrmString* = ptr char
-
-proc NULLSTRING*(): TXrmString
-proc XrmStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmPermStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmQuarkToString*(para1: TXrmQuark): TXrmString{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmUniqueQuark*(): TXrmQuark{.cdecl, dynlib: libX11, importc.}
-when defined(MACROS): 
-  proc XrmStringsEqual*(a1, a2: cstring): bool
-type 
-  PXrmBinding* = ptr TXrmBinding
-  TXrmBinding* = enum 
-    XrmBindTightly, XrmBindLoosely
-  TXrmBindingList* = PXrmBinding
-  PXrmBindingList* = ptr TXrmBindingList
-
-proc XrmStringToQuarkList*(para1: cstring, para2: TXrmQuarkList){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmStringToBindingQuarkList*(para1: cstring, para2: TXrmBindingList, 
-                                  para3: TXrmQuarkList){.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  PXrmName* = ptr TXrmName
-  TXrmName* = TXrmQuark
-  PXrmNameList* = ptr TXrmNameList
-  TXrmNameList* = TXrmQuarkList
-
-when defined(MACROS): 
-  proc XrmNameToString*(name: int32): TXrmString
-  proc XrmStringToName*(str: cstring): int32
-  proc XrmStringToNameList*(str: cstring, name: PXrmQuark)
-type 
-  PXrmClass* = ptr TXrmClass
-  TXrmClass* = TXrmQuark
-  PXrmClassList* = ptr TXrmClassList
-  TXrmClassList* = TXrmQuarkList
-
-when defined(MACROS): 
-  proc XrmClassToString*(c_class: int32): TXrmString
-  proc XrmStringToClass*(c_class: cstring): int32
-  proc XrmStringToClassList*(str: cstring, c_class: PXrmQuark)
-type 
-  PXrmRepresentation* = ptr TXrmRepresentation
-  TXrmRepresentation* = TXrmQuark
-
-when defined(MACROS): 
-  proc XrmStringToRepresentation*(str: cstring): int32
-  proc XrmRepresentationToString*(thetype: int32): TXrmString
-type 
-  PXrmValue* = ptr TXrmValue
-  TXrmValue*{.final.} = object 
-    size*: int32
-    address*: TXPointer
-
-  TXrmValuePtr* = PXrmValue
-  PXrmValuePtr* = ptr TXrmValuePtr
-  PXrmHashBucketRec* = ptr TXrmHashBucketRec
-  TXrmHashBucketRec*{.final.} = object 
-  TXrmHashBucket* = PXrmHashBucketRec
-  PXrmHashBucket* = ptr TXrmHashBucket
-  PXrmHashTable* = ptr TXrmHashTable
-  TXrmHashTable* = ptr TXrmHashBucket
-  TXrmDatabase* = PXrmHashBucketRec
-  PXrmDatabase* = ptr TXrmDatabase
-
-proc XrmDestroyDatabase*(para1: TXrmDatabase){.cdecl, dynlib: libX11, importc.}
-proc XrmQPutResource*(para1: PXrmDatabase, para2: TXrmBindingList, 
-                      para3: TXrmQuarkList, para4: TXrmRepresentation, 
-                      para5: PXrmValue){.cdecl, dynlib: libX11, importc.}
-proc XrmPutResource*(para1: PXrmDatabase, para2: cstring, para3: cstring, 
-                     para4: PXrmValue){.cdecl, dynlib: libX11, importc.}
-proc XrmQPutStringResource*(para1: PXrmDatabase, para2: TXrmBindingList, 
-                            para3: TXrmQuarkList, para4: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmPutStringResource*(para1: PXrmDatabase, para2: cstring, para3: cstring){.
-    cdecl, dynlib: libX11, importc.}
-proc XrmPutLineResource*(para1: PXrmDatabase, para2: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmQGetResource*(para1: TXrmDatabase, para2: TXrmNameList, 
-                      para3: TXrmClassList, para4: PXrmRepresentation, 
-                      para5: PXrmValue): TBool{.cdecl, dynlib: libX11, importc.}
-proc XrmGetResource*(para1: TXrmDatabase, para2: cstring, para3: cstring, 
-                     para4: PPchar, para5: PXrmValue): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-  # There is no definition of TXrmSearchList 
-  #function XrmQGetSearchList(para1:TXrmDatabase; para2:TXrmNameList; para3:TXrmClassList; para4:TXrmSearchList; para5:longint):TBool;cdecl;external libX11;
-  #function XrmQGetSearchResource(para1:TXrmSearchList; para2:TXrmName; para3:TXrmClass; para4:PXrmRepresentation; para5:PXrmValue):TBool;cdecl;external libX11;
-proc XrmSetDatabase*(para1: PDisplay, para2: TXrmDatabase){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmGetDatabase*(para1: PDisplay): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmGetFileDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmCombineFileDatabase*(para1: cstring, para2: PXrmDatabase, para3: TBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XrmGetStringDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmPutFileDatabase*(para1: TXrmDatabase, para2: cstring){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmMergeDatabases*(para1: TXrmDatabase, para2: PXrmDatabase){.cdecl, 
-    dynlib: libX11, importc.}
-proc XrmCombineDatabase*(para1: TXrmDatabase, para2: PXrmDatabase, para3: TBool){.
-    cdecl, dynlib: libX11, importc.}
-const 
-  XrmEnumAllLevels* = 0
-  XrmEnumOneLevel* = 1
-
-type 
-  funcbool* = proc (): TBool
-
-proc XrmEnumerateDatabase*(para1: TXrmDatabase, para2: TXrmNameList, 
-                           para3: TXrmClassList, para4: int32, para5: funcbool, 
-                           para6: TXPointer): TBool{.cdecl, dynlib: libX11, 
-    importc.}
-proc XrmLocaleOfDatabase*(para1: TXrmDatabase): cstring{.cdecl, dynlib: libX11, 
-    importc.}
-type 
-  PXrmOptionKind* = ptr TXrmOptionKind
-  TXrmOptionKind* = enum 
-    XrmoptionNoArg, XrmoptionIsArg, XrmoptionStickyArg, XrmoptionSepArg, 
-    XrmoptionResArg, XrmoptionSkipArg, XrmoptionSkipLine, XrmoptionSkipNArgs
-  PXrmOptionDescRec* = ptr TXrmOptionDescRec
-  TXrmOptionDescRec*{.final.} = object 
-    option*: cstring
-    specifier*: cstring
-    argKind*: TXrmOptionKind
-    value*: TXPointer
-
-  TXrmOptionDescList* = PXrmOptionDescRec
-  PXrmOptionDescList* = ptr TXrmOptionDescList
-
-proc XrmParseCommand*(para1: PXrmDatabase, para2: TXrmOptionDescList, 
-                      para3: int32, para4: cstring, para5: ptr int32, 
-                      para6: PPchar){.cdecl, dynlib: libX11, importc.}
-# implementation
-
-proc NULLQUARK(): TXrmQuark = 
-  result = TXrmQuark(0)
-
-proc NULLSTRING(): TXrmString = 
-  result = nil
-
-when defined(MACROS): 
-  proc XrmStringsEqual(a1, a2: cstring): bool = 
-    result = (strcomp(a1, a2)) == 0
-
-  proc XrmNameToString(name: int32): TXrmString = 
-    result = XrmQuarkToString(name)
-
-  proc XrmStringToName(str: cstring): int32 = 
-    result = XrmStringToQuark(str)
-
-  proc XrmStringToNameList(str: cstring, name: PXrmQuark) = 
-    XrmStringToQuarkList(str, name)
-
-  proc XrmClassToString(c_class: int32): TXrmString = 
-    result = XrmQuarkToString(c_class)
-
-  proc XrmStringToClass(c_class: cstring): int32 = 
-    result = XrmStringToQuark(c_class)
-
-  proc XrmStringToClassList(str: cstring, c_class: PXrmQuark) = 
-    XrmStringToQuarkList(str, c_class)
-
-  proc XrmStringToRepresentation(str: cstring): int32 = 
-    result = XrmStringToQuark(str)
-
-  proc XrmRepresentationToString(thetype: int32): TXrmString = 
-    result = XrmQuarkToString(thetype)
diff --git a/lib/wrappers/x11/xshm.nim b/lib/wrappers/x11/xshm.nim
deleted file mode 100755
index e56bd87b1..000000000
--- a/lib/wrappers/x11/xshm.nim
+++ /dev/null
@@ -1,77 +0,0 @@
-
-import 
-  x, xlib
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xshm.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xshm.h
-#
-
-const 
-  constX_ShmQueryVersion* = 0
-  constX_ShmAttach* = 1
-  constX_ShmDetach* = 2
-  constX_ShmPutImage* = 3
-  constX_ShmGetImage* = 4
-  constX_ShmCreatePixmap* = 5
-  ShmCompletion* = 0
-  ShmNumberEvents* = ShmCompletion + 1
-  BadShmSeg* = 0
-  ShmNumberErrors* = BadShmSeg + 1
-
-type 
-  PShmSeg* = ptr TShmSeg
-  TShmSeg* = culong
-  PXShmCompletionEvent* = ptr TXShmCompletionEvent
-  TXShmCompletionEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong
-    send_event*: TBool
-    display*: PDisplay
-    drawable*: TDrawable
-    major_code*: cint
-    minor_code*: cint
-    shmseg*: TShmSeg
-    offset*: culong
-
-  PXShmSegmentInfo* = ptr TXShmSegmentInfo
-  TXShmSegmentInfo*{.final.} = object 
-    shmseg*: TShmSeg
-    shmid*: cint
-    shmaddr*: cstring
-    readOnly*: TBool
-
-
-proc XShmQueryExtension*(para1: PDisplay): TBool{.cdecl, dynlib: libX11, importc.}
-proc XShmGetEventBase*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XShmQueryVersion*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: PBool): TBool{.
-    cdecl, dynlib: libX11, importc.}
-proc XShmPixmapFormat*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.}
-proc XShmAttach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmDetach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, 
-                   para4: PXImage, para5: cint, para6: cint, para7: cint, 
-                   para8: cint, para9: cuint, para10: cuint, para11: TBool): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XShmGetImage*(para1: PDisplay, para2: TDrawable, para3: PXImage, 
-                   para4: cint, para5: cint, para6: culong): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, 
-                      para4: cint, para5: cstring, para6: PXShmSegmentInfo, 
-                      para7: cuint, para8: cuint): PXImage{.cdecl, 
-    dynlib: libX11, importc.}
-proc XShmCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cstring, 
-                       para4: PXShmSegmentInfo, para5: cuint, para6: cuint, 
-                       para7: cuint): TPixmap{.cdecl, dynlib: libX11, importc.}
-# implementation
diff --git a/lib/wrappers/x11/xutil.nim b/lib/wrappers/x11/xutil.nim
deleted file mode 100755
index 563702123..000000000
--- a/lib/wrappers/x11/xutil.nim
+++ /dev/null
@@ -1,412 +0,0 @@
-
-import 
-  x, xlib, keysym
-
-#const 
-#  libX11* = "libX11.so"
-
-#
-#  Automatically converted by H2Pas 0.99.15 from xutil.h
-#  The following command line parameters were used:
-#    -p
-#    -T
-#    -S
-#    -d
-#    -c
-#    xutil.h
-#
-
-const 
-  NoValue* = 0x00000000
-  XValue* = 0x00000001
-  YValue* = 0x00000002
-  WidthValue* = 0x00000004
-  HeightValue* = 0x00000008
-  AllValues* = 0x0000000F
-  XNegative* = 0x00000010
-  YNegative* = 0x00000020
-
-type 
-  TCPoint*{.final.} = object 
-    x*: cint
-    y*: cint
-
-  PXSizeHints* = ptr TXSizeHints
-  TXSizeHints*{.final.} = object 
-    flags*: clong
-    x*, y*: cint
-    width*, height*: cint
-    min_width*, min_height*: cint
-    max_width*, max_height*: cint
-    width_inc*, height_inc*: cint
-    min_aspect*, max_aspect*: TCPoint
-    base_width*, base_height*: cint
-    win_gravity*: cint
-
-
-const 
-  USPosition* = 1 shl 0
-  USSize* = 1 shl 1
-  PPosition* = 1 shl 2
-  PSize* = 1 shl 3
-  PMinSize* = 1 shl 4
-  PMaxSize* = 1 shl 5
-  PResizeInc* = 1 shl 6
-  PAspect* = 1 shl 7
-  PBaseSize* = 1 shl 8
-  PWinGravity* = 1 shl 9
-  PAllHints* = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or
-      PAspect
-
-type 
-  PXWMHints* = ptr TXWMHints
-  TXWMHints*{.final.} = object 
-    flags*: clong
-    input*: TBool
-    initial_state*: cint
-    icon_pixmap*: TPixmap
-    icon_window*: TWindow
-    icon_x*, icon_y*: cint
-    icon_mask*: TPixmap
-    window_group*: TXID
-
-
-const 
-  InputHint* = 1 shl 0
-  StateHint* = 1 shl 1
-  IconPixmapHint* = 1 shl 2
-  IconWindowHint* = 1 shl 3
-  IconPositionHint* = 1 shl 4
-  IconMaskHint* = 1 shl 5
-  WindowGroupHint* = 1 shl 6
-  AllHints* = InputHint or StateHint or IconPixmapHint or IconWindowHint or
-      IconPositionHint or IconMaskHint or WindowGroupHint
-  XUrgencyHint* = 1 shl 8
-  WithdrawnState* = 0
-  NormalState* = 1
-  IconicState* = 3
-  DontCareState* = 0
-  ZoomState* = 2
-  InactiveState* = 4
-
-type 
-  PXTextProperty* = ptr TXTextProperty
-  TXTextProperty*{.final.} = object 
-    value*: pcuchar
-    encoding*: TAtom
-    format*: cint
-    nitems*: culong
-
-
-const 
-  XNoMemory* = - 1
-  XLocaleNotSupported* = - 2
-  XConverterNotFound* = - 3
-
-type 
-  PXICCEncodingStyle* = ptr TXICCEncodingStyle
-  TXICCEncodingStyle* = enum 
-    XStringStyle, XCompoundTextStyle, XTextStyle, XStdICCTextStyle, 
-    XUTF8StringStyle
-  PPXIconSize* = ptr PXIconSize
-  PXIconSize* = ptr TXIconSize
-  TXIconSize*{.final.} = object 
-    min_width*, min_height*: cint
-    max_width*, max_height*: cint
-    width_inc*, height_inc*: cint
-
-  PXClassHint* = ptr TXClassHint
-  TXClassHint*{.final.} = object 
-    res_name*: cstring
-    res_class*: cstring
-
-
-type 
-  PXComposeStatus* = ptr TXComposeStatus
-  TXComposeStatus*{.final.} = object 
-    compose_ptr*: TXPointer
-    chars_matched*: cint
-
-
-type 
-  PXRegion* = ptr TXRegion
-  TXRegion*{.final.} = object 
-  TRegion* = PXRegion
-  PRegion* = ptr TRegion
-
-const 
-  RectangleOut* = 0
-  RectangleIn* = 1
-  RectanglePart* = 2
-
-type 
-  PXVisualInfo* = ptr TXVisualInfo
-  TXVisualInfo*{.final.} = object 
-    visual*: PVisual
-    visualid*: TVisualID
-    screen*: cint
-    depth*: cint
-    class*: cint
-    red_mask*: culong
-    green_mask*: culong
-    blue_mask*: culong
-    colormap_size*: cint
-    bits_per_rgb*: cint
-
-
-const 
-  VisualNoMask* = 0x00000000
-  VisualIDMask* = 0x00000001
-  VisualScreenMask* = 0x00000002
-  VisualDepthMask* = 0x00000004
-  VisualClassMask* = 0x00000008
-  VisualRedMaskMask* = 0x00000010
-  VisualGreenMaskMask* = 0x00000020
-  VisualBlueMaskMask* = 0x00000040
-  VisualColormapSizeMask* = 0x00000080
-  VisualBitsPerRGBMask* = 0x00000100
-  VisualAllMask* = 0x000001FF
-
-type 
-  PPXStandardColormap* = ptr PXStandardColormap
-  PXStandardColormap* = ptr TXStandardColormap
-  TXStandardColormap*{.final.} = object 
-    colormap*: TColormap
-    red_max*: culong
-    red_mult*: culong
-    green_max*: culong
-    green_mult*: culong
-    blue_max*: culong
-    blue_mult*: culong
-    base_pixel*: culong
-    visualid*: TVisualID
-    killid*: TXID
-
-
-const 
-  BitmapSuccess* = 0
-  BitmapOpenFailed* = 1
-  BitmapFileInvalid* = 2
-  BitmapNoMemory* = 3
-  XCSUCCESS* = 0
-  XCNOMEM* = 1
-  XCNOENT* = 2
-  ReleaseByFreeingColormap*: TXID = TXID(1)
-
-type 
-  PXContext* = ptr TXContext
-  TXContext* = cint
-
-proc XAllocClassHint*(): PXClassHint{.cdecl, dynlib: libX11, importc.}
-proc XAllocIconSize*(): PXIconSize{.cdecl, dynlib: libX11, importc.}
-proc XAllocSizeHints*(): PXSizeHints{.cdecl, dynlib: libX11, importc.}
-proc XAllocStandardColormap*(): PXStandardColormap{.cdecl, dynlib: libX11, 
-    importc.}
-proc XAllocWMHints*(): PXWMHints{.cdecl, dynlib: libX11, importc.}
-proc XClipBox*(para1: TRegion, para2: PXRectangle): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XCreateRegion*(): TRegion{.cdecl, dynlib: libX11, importc.}
-proc XDefaultString*(): cstring{.cdecl, dynlib: libX11, importc.}
-proc XDeleteContext*(para1: PDisplay, para2: TXID, para3: TXContext): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XDestroyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
-proc XEmptyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.}
-proc XEqualRegion*(para1: TRegion, para2: TRegion): cint{.cdecl, dynlib: libX11, 
-    importc.}
-proc XFindContext*(para1: PDisplay, para2: TXID, para3: TXContext, 
-                   para4: PXPointer): cint{.cdecl, dynlib: libX11, importc.}
-proc XGetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetIconSizes*(para1: PDisplay, para2: TWindow, para3: PPXIconSize, 
-                    para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetRGBColormaps*(para1: PDisplay, para2: TWindow, 
-                       para3: PPXStandardColormap, para4: Pcint, para5: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                    para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetStandardColormap*(para1: PDisplay, para2: TWindow, 
-                           para3: PXStandardColormap, para4: TAtom): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetVisualInfo*(para1: PDisplay, para2: clong, para3: PXVisualInfo, 
-                     para4: Pcint): PXVisualInfo{.cdecl, dynlib: libX11, importc.}
-proc XGetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMHints*(para1: PDisplay, para2: TWindow): PXWMHints{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XGetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                        para4: ptr int): TStatus{.cdecl, dynlib: libX11, importc.}
-proc XGetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                      para4: ptr int, para5: TAtom): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XGetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{.
-    cdecl, dynlib: libX11, importc.}
-proc XIntersectRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XConvertCase*(para1: TKeySym, para2: PKeySym, para3: PKeySym){.cdecl, 
-    dynlib: libX11, importc.}
-proc XLookupString*(para1: PXKeyEvent, para2: cstring, para3: cint, 
-                    para4: PKeySym, para5: PXComposeStatus): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XMatchVisualInfo*(para1: PDisplay, para2: cint, para3: cint, para4: cint, 
-                       para5: PXVisualInfo): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XOffsetRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPointInRegion*(para1: TRegion, para2: cint, para3: cint): TBool{.cdecl, 
-    dynlib: libX11, importc.}
-proc XPolygonRegion*(para1: PXPoint, para2: cint, para3: cint): TRegion{.cdecl, 
-    dynlib: libX11, importc.}
-proc XRectInRegion*(para1: TRegion, para2: cint, para3: cint, para4: cuint, 
-                    para5: cuint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSaveContext*(para1: PDisplay, para2: TXID, para3: TXContext, 
-                   para4: cstring): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetIconSizes*(para1: PDisplay, para2: TWindow, para3: PXIconSize, 
-                    para4: cint): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetRGBColormaps*(para1: PDisplay, para2: TWindow, 
-                       para3: PXStandardColormap, para4: cint, para5: TAtom){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                    para4: TAtom): cint{.cdecl, dynlib: libX11, importc.}
-proc XSetStandardProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                             para4: cstring, para5: TPixmap, para6: PPchar, 
-                             para7: cint, para8: PXSizeHints): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: TAtom){.cdecl, dynlib: libX11, importc.}
-proc XSetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMHints*(para1: PDisplay, para2: TWindow, para3: PXWMHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints){.
-    cdecl, dynlib: libX11, importc.}
-proc XSetWMProperties*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, 
-                       para4: PXTextProperty, para5: PPchar, para6: cint, 
-                       para7: PXSizeHints, para8: PXWMHints, para9: PXClassHint){.
-    cdecl, dynlib: libX11, importc.}
-proc XmbSetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                         para4: cstring, para5: PPchar, para6: cint, 
-                         para7: PXSizeHints, para8: PXWMHints, 
-                         para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
-proc Xutf8SetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, 
-                           para4: cstring, para5: PPchar, para6: cint, 
-                           para7: PXSizeHints, para8: PXWMHints, 
-                           para9: PXClassHint){.cdecl, dynlib: libX11, importc.}
-proc XSetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, 
-                      para4: TAtom){.cdecl, dynlib: libX11, importc.}
-proc XSetRegion*(para1: PDisplay, para2: TGC, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetStandardColormap*(para1: PDisplay, para2: TWindow, 
-                           para3: PXStandardColormap, para4: TAtom){.cdecl, 
-    dynlib: libX11, importc.}
-proc XSetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XShrinkRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XStringListToTextProperty*(para1: PPchar, para2: cint, 
-                                para3: PXTextProperty): TStatus{.cdecl, 
-    dynlib: libX11, importc.}
-proc XSubtractRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XmbTextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, 
-                                para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XwcTextListToTextProperty*(para1: PDisplay, para2: ptr ptr int16, para3: cint, 
-                                para4: TXICCEncodingStyle, para5: PXTextProperty): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc Xutf8TextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, 
-                                  para4: TXICCEncodingStyle, 
-                                  para5: PXTextProperty): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcFreeStringList*(para1: ptr ptr int16){.cdecl, dynlib: libX11, importc.}
-proc XTextPropertyToStringList*(para1: PXTextProperty, para2: PPPchar, 
-                                para3: Pcint): TStatus{.cdecl, dynlib: libX11, 
-    importc.}
-proc XmbTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                para3: PPPchar, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XwcTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                para3: ptr ptr ptr int16, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc Xutf8TextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, 
-                                  para3: PPPchar, para4: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XUnionRectWithRegion*(para1: PXRectangle, para2: TRegion, para3: TRegion): cint{.
-    cdecl, dynlib: libX11, importc.}
-proc XUnionRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, 
-                  para5: cuint, para6: PXSizeHints, para7: Pcint, para8: Pcint, 
-                  para9: Pcint, para10: Pcint, para11: Pcint): cint{.cdecl, 
-    dynlib: libX11, importc.}
-proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, 
-    dynlib: libX11, importc.}
-when defined(MACROS): 
-  proc XDestroyImage*(ximage: PXImage): cint
-  proc XGetPixel*(ximage: PXImage, x, y: cint): culong
-  proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint
-  proc XSubImage*(ximage: PXImage, x, y: cint, width, height: cuint): PXImage
-  proc XAddPixel*(ximage: PXImage, value: clong): cint
-  proc IsKeypadKey*(keysym: TKeySym): bool
-  proc IsPrivateKeypadKey*(keysym: TKeySym): bool
-  proc IsCursorKey*(keysym: TKeySym): bool
-  proc IsPFKey*(keysym: TKeySym): bool
-  proc IsFunctionKey*(keysym: TKeySym): bool
-  proc IsMiscFunctionKey*(keysym: TKeySym): bool
-  proc IsModifierKey*(keysym: TKeySym): bool
-    #function XUniqueContext : TXContext;
-    #function XStringToContext(_string : Pchar) : TXContext;
-# implementation
-
-when defined(MACROS): 
-  proc XDestroyImage(ximage: PXImage): cint = 
-    XDestroyImage = ximage^ .f.destroy_image(ximage)
-
-  proc XGetPixel(ximage: PXImage, x, y: cint): culong = 
-    XGetPixel = ximage^ .f.get_pixel(ximage, x, y)
-
-  proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint = 
-    XPutPixel = ximage^ .f.put_pixel(ximage, x, y, pixel)
-
-  proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage = 
-    XSubImage = ximage^ .f.sub_image(ximage, x, y, width, height)
-
-  proc XAddPixel(ximage: PXImage, value: clong): cint = 
-    XAddPixel = ximage^ .f.add_pixel(ximage, value)
-
-  proc IsKeypadKey(keysym: TKeySym): bool = 
-    IsKeypadKey = (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal)
-
-  proc IsPrivateKeypadKey(keysym: TKeySym): bool = 
-    IsPrivateKeypadKey = (keysym >= 0x11000000) and (keysym <= 0x1100FFFF)
-
-  proc IsCursorKey(keysym: TKeySym): bool = 
-    IsCursorKey = (keysym >= XK_Home) and (keysym < XK_Select)
-
-  proc IsPFKey(keysym: TKeySym): bool = 
-    IsPFKey = (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4)
-
-  proc IsFunctionKey(keysym: TKeySym): bool = 
-    IsFunctionKey = (keysym >= XK_F1) and (keysym <= XK_F35)
-
-  proc IsMiscFunctionKey(keysym: TKeySym): bool = 
-    IsMiscFunctionKey = (keysym >= XK_Select) and (keysym <= XK_Break)
-
-  proc IsModifierKey(keysym: TKeySym): bool = 
-    IsModifierKey = ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or
-        (keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock)
diff --git a/lib/wrappers/x11/xv.nim b/lib/wrappers/x11/xv.nim
deleted file mode 100755
index 45ab61418..000000000
--- a/lib/wrappers/x11/xv.nim
+++ /dev/null
@@ -1,84 +0,0 @@
-#***********************************************************
-#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
-#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its 
-#documentation for any purpose and without fee is hereby granted, 
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in 
-#supporting documentation, and that the names of Digital or MIT not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.  
-#
-#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#******************************************************************
-# $XFree86: xc/include/extensions/Xv.h,v 1.3 1999/05/23 06:33:22 dawes Exp $ 
-
-import 
-  x
-
-const 
-  XvName* = "libXVideo.so"
-  XvVersion* = 2
-  XvRevision* = 2             # Symbols 
-
-type 
-  TXvPortID* = TXID
-  TXvEncodingID* = TXID
-
-const 
-  XvNone* = 0
-  XvInput* = 0
-  XvOutput* = 1
-  XvInputMask* = 1 shl XvInput
-  XvOutputMask* = 1 shl XvOutput
-  XvVideoMask* = 0x00000004
-  XvStillMask* = 0x00000008
-  XvImageMask* = 0x00000010   # These two are not client viewable 
-  XvPixmapMask* = 0x00010000
-  XvWindowMask* = 0x00020000
-  XvGettable* = 0x00000001
-  XvSettable* = 0x00000002
-  XvRGB* = 0
-  XvYUV* = 1
-  XvPacked* = 0
-  XvPlanar* = 1
-  XvTopToBottom* = 0
-  XvBottomToTop* = 1          # Events 
-  XvVideoNotify* = 0
-  XvPortNotify* = 1
-  XvNumEvents* = 2            # Video Notify Reasons 
-  XvStarted* = 0
-  XvStopped* = 1
-  XvBusy* = 2
-  XvPreempted* = 3
-  XvHardError* = 4
-  XvLastReason* = 4
-  XvNumReasons* = XvLastReason + 1
-  XvStartedMask* = 1 shl XvStarted
-  XvStoppedMask* = 1 shl XvStopped
-  XvBusyMask* = 1 shl XvBusy
-  XvPreemptedMask* = 1 shl XvPreempted
-  XvHardErrorMask* = 1 shl XvHardError
-  XvAnyReasonMask* = (1 shl XvNumReasons) - 1
-  XvNoReasonMask* = 0         # Errors 
-  XvBadPort* = 0
-  XvBadEncoding* = 1
-  XvBadControl* = 2
-  XvNumErrors* = 3            # Status 
-  XvBadExtension* = 1
-  XvAlreadyGrabbed* = 2
-  XvInvalidTime* = 3
-  XvBadReply* = 4
-  XvBadAlloc* = 5
-
-# implementation
diff --git a/lib/wrappers/x11/xvlib.nim b/lib/wrappers/x11/xvlib.nim
deleted file mode 100755
index 19fd0d000..000000000
--- a/lib/wrappers/x11/xvlib.nim
+++ /dev/null
@@ -1,234 +0,0 @@
-#***********************************************************
-#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
-#and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-#
-#                        All Rights Reserved
-#
-#Permission to use, copy, modify, and distribute this software and its 
-#documentation for any purpose and without fee is hereby granted, 
-#provided that the above copyright notice appear in all copies and that
-#both that copyright notice and this permission notice appear in 
-#supporting documentation, and that the names of Digital or MIT not be
-#used in advertising or publicity pertaining to distribution of the
-#software without specific, written prior permission.  
-#
-#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-#SOFTWARE.
-#
-#******************************************************************
-# $XFree86: xc/include/extensions/Xvlib.h,v 1.3 1999/12/11 19:28:48 mvojkovi Exp $ 
-#*
-#** File: 
-#**
-#**   Xvlib.h --- Xv library public header file
-#**
-#** Author: 
-#**
-#**   David Carver (Digital Workstation Engineering/Project Athena)
-#**
-#** Revisions:
-#**
-#**   26.06.91 Carver
-#**     - changed XvFreeAdaptors to XvFreeAdaptorInfo
-#**     - changed XvFreeEncodings to XvFreeEncodingInfo
-#**
-#**   11.06.91 Carver
-#**     - changed SetPortControl to SetPortAttribute
-#**     - changed GetPortControl to GetPortAttribute
-#**     - changed QueryBestSize
-#**
-#**   05.15.91 Carver
-#**     - version 2.0 upgrade
-#**
-#**   01.24.91 Carver
-#**     - version 1.4 upgrade
-#**
-#*
-
-import 
-  x, xlib, xshm, xv
-
-const 
-  libXv* = "libXv.so"
-
-type 
-  PXvRational* = ptr TXvRational
-  TXvRational*{.final.} = object 
-    numerator*: cint
-    denominator*: cint
-
-  PXvAttribute* = ptr TXvAttribute
-  TXvAttribute*{.final.} = object 
-    flags*: cint              # XvGettable, XvSettable 
-    min_value*: cint
-    max_value*: cint
-    name*: cstring
-
-  PPXvEncodingInfo* = ptr PXvEncodingInfo
-  PXvEncodingInfo* = ptr TXvEncodingInfo
-  TXvEncodingInfo*{.final.} = object 
-    encoding_id*: TXvEncodingID
-    name*: cstring
-    width*: culong
-    height*: culong
-    rate*: TXvRational
-    num_encodings*: culong
-
-  PXvFormat* = ptr TXvFormat
-  TXvFormat*{.final.} = object 
-    depth*: cchar
-    visual_id*: culong
-
-  PPXvAdaptorInfo* = ptr PXvAdaptorInfo
-  PXvAdaptorInfo* = ptr TXvAdaptorInfo
-  TXvAdaptorInfo*{.final.} = object 
-    base_id*: TXvPortID
-    num_ports*: culong
-    thetype*: cchar
-    name*: cstring
-    num_formats*: culong
-    formats*: PXvFormat
-    num_adaptors*: culong
-
-  PXvVideoNotifyEvent* = ptr TXvVideoNotifyEvent
-  TXvVideoNotifyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    drawable*: TDrawable      # drawable 
-    reason*: culong           # what generated this event 
-    port_id*: TXvPortID       # what port 
-    time*: TTime              # milliseconds 
-  
-  PXvPortNotifyEvent* = ptr TXvPortNotifyEvent
-  TXvPortNotifyEvent*{.final.} = object 
-    theType*: cint
-    serial*: culong           # # of last request processed by server 
-    send_event*: TBool        # true if this came from a SendEvent request 
-    display*: PDisplay        # Display the event was read from 
-    port_id*: TXvPortID       # what port 
-    time*: TTime              # milliseconds 
-    attribute*: TAtom         # atom that identifies attribute 
-    value*: clong             # value of attribute 
-  
-  PXvEvent* = ptr TXvEvent
-  TXvEvent*{.final.} = object 
-    pad*: array[0..23, clong] #case longint of
-                              #      0 : (
-                              #            theType : cint;
-                              #	  );
-                              #      1 : (
-                              #            xvvideo : TXvVideoNotifyEvent;
-                              #          );
-                              #      2 : (
-                              #            xvport : TXvPortNotifyEvent;
-                              #          );
-                              #      3 : (
-                              #            
-                              #          );
-  
-  PXvImageFormatValues* = ptr TXvImageFormatValues
-  TXvImageFormatValues*{.final.} = object 
-    id*: cint                 # Unique descriptor for the format 
-    theType*: cint            # XvRGB, XvYUV 
-    byte_order*: cint         # LSBFirst, MSBFirst 
-    guid*: array[0..15, cchar] # Globally Unique IDentifier 
-    bits_per_pixel*: cint
-    format*: cint             # XvPacked, XvPlanar 
-    num_planes*: cint         # for RGB formats only 
-    depth*: cint
-    red_mask*: cuint
-    green_mask*: cuint
-    blue_mask*: cuint         # for YUV formats only 
-    y_sample_bits*: cuint
-    u_sample_bits*: cuint
-    v_sample_bits*: cuint
-    horz_y_period*: cuint
-    horz_u_period*: cuint
-    horz_v_period*: cuint
-    vert_y_period*: cuint
-    vert_u_period*: cuint
-    vert_v_period*: cuint
-    component_order*: array[0..31, char] # eg. UYVY 
-    scanline_order*: cint     # XvTopToBottom, XvBottomToTop 
-  
-  PXvImage* = ptr TXvImage
-  TXvImage*{.final.} = object 
-    id*: cint
-    width*, height*: cint
-    data_size*: cint          # bytes 
-    num_planes*: cint
-    pitches*: pcint           # bytes 
-    offsets*: pcint           # bytes 
-    data*: pointer
-    obdata*: TXPointer
-
-
-proc XvQueryExtension*(display: PDisplay, p_version, p_revision, p_requestBase, 
-    p_eventBase, p_errorBase: pcuint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvQueryAdaptors*(display: PDisplay, window: TWindow, p_nAdaptors: pcuint, 
-                      p_pAdaptors: PPXvAdaptorInfo): cint{.cdecl, dynlib: libXv, 
-    importc.}
-proc XvQueryEncodings*(display: PDisplay, port: TXvPortID, p_nEncoding: pcuint, 
-                       p_pEncoding: PPXvEncodingInfo): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvPutVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvPutStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGetVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGetStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, 
-                 vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvStopVideo*(display: PDisplay, port: TXvPortID, drawable: TDrawable): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvGrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvUngrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSelectVideoNotify*(display: PDisplay, drawable: TDrawable, onoff: TBool): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSelectPortNotify*(display: PDisplay, port: TXvPortID, onoff: TBool): cint{.
-    cdecl, dynlib: libXv, importc.}
-proc XvSetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, 
-                         value: cint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvGetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, 
-                         p_value: pcint): cint{.cdecl, dynlib: libXv, importc.}
-proc XvQueryBestSize*(display: PDisplay, port: TXvPortID, motion: TBool, 
-                      vid_w, vid_h, drw_w, drw_h: cuint, 
-                      p_actual_width, p_actual_height: pcuint): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvQueryPortAttributes*(display: PDisplay, port: TXvPortID, number: pcint): PXvAttribute{.
-    cdecl, dynlib: libXv, importc.}
-proc XvFreeAdaptorInfo*(adaptors: PXvAdaptorInfo){.cdecl, dynlib: libXv, importc.}
-proc XvFreeEncodingInfo*(encodings: PXvEncodingInfo){.cdecl, dynlib: libXv, 
-    importc.}
-proc XvListImageFormats*(display: PDisplay, port_id: TXvPortID, 
-                         count_return: pcint): PXvImageFormatValues{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvCreateImage*(display: PDisplay, port: TXvPortID, id: cint, data: pointer, 
-                    width, height: cint): PXvImage{.cdecl, dynlib: libXv, 
-    importc.}
-proc XvPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, 
-                 image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, 
-                 dest_x, dest_y: cint, dest_w, dest_h: cuint): cint{.cdecl, 
-    dynlib: libXv, importc.}
-proc XvShmPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, 
-                    image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, 
-                    dest_x, dest_y: cint, dest_w, dest_h: cuint, 
-                    send_event: TBool): cint{.cdecl, dynlib: libXv, importc.}
-proc XvShmCreateImage*(display: PDisplay, port: TXvPortID, id: cint, 
-                       data: pointer, width, height: cint, 
-                       shminfo: PXShmSegmentInfo): PXvImage{.cdecl, 
-    dynlib: libXv, importc.}
-# implementation
diff --git a/lib/wrappers/zip/libzip.nim b/lib/wrappers/zip/libzip.nim
deleted file mode 100755
index 2f8abc46c..000000000
--- a/lib/wrappers/zip/libzip.nim
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by
-## Dieter Baron and Thomas Klausner. However, this does not need any external
-## library (DLL, lib*.so), as the source for this library is included and
-## compiled with this interface.
-
-#
-#  zip.h -- exported declarations.
-#  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-#
-#  This file is part of libzip, a library to manipulate ZIP archives.
-#  The authors can be contacted at <libzip@nih.at>
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in
-#     the documentation and/or other materials provided with the
-#     distribution.
-#  3. The names of the authors may not be used to endorse or promote
-#     products derived from this software without specific prior
-#     written permission.
-# 
-#  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-#  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-#  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-#  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-import times
-
-{.compile: "libzip_all.c".}
-when defined(unix):
-  {.passl: "-lz".}
-
-type 
-  Tzip_source_cmd* = int32
-
-  Tzip_source_callback* = proc (state: pointer, data: pointer, length: int, 
-                                cmd: Tzip_source_cmd): int {.cdecl.}
-  Pzip_stat* = ptr Tzip_stat
-  Tzip_stat* {.final, pure.} = object 
-    name*: cstring            ## name of the file  
-    index*: int32             ## index within archive  
-    crc*: int32               ## crc of file data  
-    mtime*: TTime             ## modification time  
-    size*: int                ## size of file (uncompressed)  
-    comp_size*: int           ## size of file (compressed)  
-    comp_method*: int16       ## compression method used  
-    encryption_method*: int16 ## encryption method used  
-  
-  Tzip {.final, pure.} = object
-  Tzip_source {.final, pure.} = object 
-  Tzip_file {.final, pure.} = object
-
-  Pzip* = ptr Tzip ## represents a zip archive
-  Pzip_file* = ptr Tzip_file ## represents a file within an archive
-  Pzip_source* = ptr Tzip_source ## represents a source for an archive
-
-
-# flags for zip_name_locate, zip_fopen, zip_stat, ...  
-const 
-  ZIP_CREATE* = 1'i32
-  ZIP_EXCL* = 2'i32
-  ZIP_CHECKCONS* = 4'i32 
-  ZIP_FL_NOCASE* = 1'i32        ## ignore case on name lookup  
-  ZIP_FL_NODIR* = 2'i32         ## ignore directory component  
-  ZIP_FL_COMPRESSED* = 4'i32    ## read compressed data  
-  ZIP_FL_UNCHANGED* = 8'i32     ## use original data, ignoring changes  
-  ZIP_FL_RECOMPRESS* = 16'i32   ## force recompression of data  
-
-const  # archive global flags flags  
-  ZIP_AFL_TORRENT* = 1'i32      ##  torrent zipped  
-
-const # libzip error codes  
-  ZIP_ER_OK* = 0'i32            ## N No error  
-  ZIP_ER_MULTIDISK* = 1'i32     ## N Multi-disk zip archives not supported  
-  ZIP_ER_RENAME* = 2'i32        ## S Renaming temporary file failed  
-  ZIP_ER_CLOSE* = 3'i32         ## S Closing zip archive failed  
-  ZIP_ER_SEEK* = 4'i32          ## S Seek error  
-  ZIP_ER_READ* = 5'i32          ## S Read error  
-  ZIP_ER_WRITE* = 6'i32         ## S Write error  
-  ZIP_ER_CRC* = 7'i32           ## N CRC error  
-  ZIP_ER_ZIPCLOSED* = 8'i32     ## N Containing zip archive was closed  
-  ZIP_ER_NOENT* = 9'i32         ## N No such file  
-  ZIP_ER_EXISTS* = 10'i32       ## N File already exists  
-  ZIP_ER_OPEN* = 11'i32         ## S Can't open file  
-  ZIP_ER_TMPOPEN* = 12'i32      ## S Failure to create temporary file  
-  ZIP_ER_ZLIB* = 13'i32         ## Z Zlib error  
-  ZIP_ER_MEMORY* = 14'i32       ## N Malloc failure  
-  ZIP_ER_CHANGED* = 15'i32      ## N Entry has been changed  
-  ZIP_ER_COMPNOTSUPP* = 16'i32  ## N Compression method not supported  
-  ZIP_ER_EOF* = 17'i32          ## N Premature EOF  
-  ZIP_ER_INVAL* = 18'i32        ## N Invalid argument  
-  ZIP_ER_NOZIP* = 19'i32        ## N Not a zip archive  
-  ZIP_ER_INTERNAL* = 20'i32     ## N Internal error  
-  ZIP_ER_INCONS* = 21'i32       ## N Zip archive inconsistent  
-  ZIP_ER_REMOVE* = 22'i32       ## S Can't remove file  
-  ZIP_ER_DELETED* = 23'i32      ## N Entry has been deleted  
-   
-const # type of system error value  
-  ZIP_ET_NONE* = 0'i32          ## sys_err unused  
-  ZIP_ET_SYS* = 1'i32           ## sys_err is errno  
-  ZIP_ET_ZLIB* = 2'i32          ## sys_err is zlib error code  
-
-const # compression methods  
-  ZIP_CM_DEFAULT* = -1'i32      ## better of deflate or store  
-  ZIP_CM_STORE* = 0'i32         ## stored (uncompressed)  
-  ZIP_CM_SHRINK* = 1'i32        ## shrunk  
-  ZIP_CM_REDUCE_1* = 2'i32      ## reduced with factor 1  
-  ZIP_CM_REDUCE_2* = 3'i32      ## reduced with factor 2  
-  ZIP_CM_REDUCE_3* = 4'i32      ## reduced with factor 3  
-  ZIP_CM_REDUCE_4* = 5'i32      ## reduced with factor 4  
-  ZIP_CM_IMPLODE* = 6'i32       ## imploded  
-                                ## 7 - Reserved for Tokenizing compression algorithm  
-  ZIP_CM_DEFLATE* = 8'i32       ## deflated  
-  ZIP_CM_DEFLATE64* = 9'i32     ## deflate64  
-  ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding  
-                                  ## 11 - Reserved by PKWARE  
-  ZIP_CM_BZIP2* = 12'i32        ## compressed using BZIP2 algorithm  
-                                ## 13 - Reserved by PKWARE  
-  ZIP_CM_LZMA* = 14'i32         ## LZMA (EFS)  
-                                ## 15-17 - Reserved by PKWARE  
-  ZIP_CM_TERSE* = 18'i32        ## compressed using IBM TERSE (new)  
-  ZIP_CM_LZ77* = 19'i32         ## IBM LZ77 z Architecture (PFS)  
-  ZIP_CM_WAVPACK* = 97'i32      ## WavPack compressed data  
-  ZIP_CM_PPMD* = 98'i32         ## PPMd version I, Rev 1  
-
-const  # encryption methods                              
-  ZIP_EM_NONE* = 0'i32            ## not encrypted  
-  ZIP_EM_TRAD_PKWARE* = 1'i32     ## traditional PKWARE encryption 
-
-const 
-  ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm  
-
-const 
-  ZIP_SOURCE_OPEN* = 0'i32        ## prepare for reading  
-  ZIP_SOURCE_READ* = 1'i32        ## read data  
-  ZIP_SOURCE_CLOSE* = 2'i32       ## reading is done  
-  ZIP_SOURCE_STAT* = 3'i32        ## get meta information  
-  ZIP_SOURCE_ERROR* = 4'i32       ## get error information  
-  constZIP_SOURCE_FREE* = 5'i32   ## cleanup and free resources  
-
-proc zip_add*(para1: Pzip, para2: cstring, para3: Pzip_source): int32 {.cdecl, 
-    importc: "zip_add".}
-proc zip_add_dir*(para1: Pzip, para2: cstring): int32 {.cdecl,  
-    importc: "zip_add_dir".}
-proc zip_close*(para1: Pzip) {.cdecl, importc: "zip_close".}
-proc zip_delete*(para1: Pzip, para2: int32): int32 {.cdecl,
-    importc: "zip_delete".}
-proc zip_error_clear*(para1: Pzip) {.cdecl, importc: "zip_error_clear".}
-proc zip_error_get*(para1: Pzip, para2: ptr int32, para3: ptr int32) {.cdecl, 
-    importc: "zip_error_get".}
-proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl,  
-    importc: "zip_error_get_sys_type".}
-proc zip_error_to_str*(para1: cstring, para2: int, para3: int32, 
-                       para4: int32): int32 {.cdecl,
-    importc: "zip_error_to_str".}
-proc zip_fclose*(para1: Pzip_file) {.cdecl,
-    importc: "zip_fclose".}
-proc zip_file_error_clear*(para1: Pzip_file) {.cdecl, 
-    importc: "zip_file_error_clear".}
-proc zip_file_error_get*(para1: Pzip_file, para2: ptr int32, para3: ptr int32) {.
-    cdecl, importc: "zip_file_error_get".}
-proc zip_file_strerror*(para1: Pzip_file): cstring {.cdecl,
-    importc: "zip_file_strerror".}
-proc zip_fopen*(para1: Pzip, para2: cstring, para3: int32): Pzip_file {.cdecl, 
-    importc: "zip_fopen".}
-proc zip_fopen_index*(para1: Pzip, para2: int32, para3: int32): Pzip_file {.
-    cdecl, importc: "zip_fopen_index".}
-proc zip_fread*(para1: Pzip_file, para2: pointer, para3: int): int {.
-    cdecl, importc: "zip_fread".}
-proc zip_get_archive_comment*(para1: Pzip, para2: ptr int32, para3: int32): cstring {.
-    cdecl, importc: "zip_get_archive_comment".}
-proc zip_get_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
-    cdecl, importc: "zip_get_archive_flag".}
-proc zip_get_file_comment*(para1: Pzip, para2: int32, para3: ptr int32, 
-                           para4: int32): cstring {.cdecl, 
-    importc: "zip_get_file_comment".}
-proc zip_get_name*(para1: Pzip, para2: int32, para3: int32): cstring {.cdecl, 
-    importc: "zip_get_name".}
-proc zip_get_num_files*(para1: Pzip): int32 {.cdecl,
-    importc: "zip_get_num_files".}
-proc zip_name_locate*(para1: Pzip, para2: cstring, para3: int32): int32 {.cdecl, 
-    importc: "zip_name_locate".}
-proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): Pzip {.cdecl, 
-    importc: "zip_open".}
-proc zip_rename*(para1: Pzip, para2: int32, para3: cstring): int32 {.cdecl, 
-    importc: "zip_rename".}
-proc zip_replace*(para1: Pzip, para2: int32, para3: Pzip_source): int32 {.cdecl, 
-    importc: "zip_replace".}
-proc zip_set_archive_comment*(para1: Pzip, para2: cstring, para3: int32): int32 {.
-    cdecl, importc: "zip_set_archive_comment".}
-proc zip_set_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
-    cdecl, importc: "zip_set_archive_flag".}
-proc zip_set_file_comment*(para1: Pzip, para2: int32, para3: cstring, 
-                           para4: int32): int32 {.cdecl, 
-    importc: "zip_set_file_comment".}
-proc zip_source_buffer*(para1: Pzip, para2: pointer, para3: int, para4: int32): Pzip_source {.
-    cdecl, importc: "zip_source_buffer".}
-proc zip_source_file*(para1: Pzip, para2: cstring, para3: int, para4: int): Pzip_source {.
-    cdecl, importc: "zip_source_file".}
-proc zip_source_filep*(para1: Pzip, para2: TFile, para3: int, para4: int): Pzip_source {.
-    cdecl, importc: "zip_source_filep".}
-proc zip_source_free*(para1: Pzip_source) {.cdecl, 
-    importc: "zip_source_free".}
-proc zip_source_function*(para1: Pzip, para2: Tzip_source_callback, 
-                          para3: pointer): Pzip_source {.cdecl, 
-    importc: "zip_source_function".}
-proc zip_source_zip*(para1: Pzip, para2: Pzip, para3: int32, para4: int32, 
-                     para5: int, para6: int): Pzip_source {.cdecl, 
-    importc: "zip_source_zip".}
-proc zip_stat*(para1: Pzip, para2: cstring, para3: int32, para4: Pzip_stat): int32 {.
-    cdecl, importc: "zip_stat".}
-proc zip_stat_index*(para1: Pzip, para2: int32, para3: int32, para4: Pzip_stat): int32 {.
-    cdecl, importc: "zip_stat_index".}
-proc zip_stat_init*(para1: Pzip_stat) {.cdecl, importc: "zip_stat_init".}
-proc zip_strerror*(para1: Pzip): cstring {.cdecl, importc: "zip_strerror".}
-proc zip_unchange*(para1: Pzip, para2: int32): int32 {.cdecl,
-    importc: "zip_unchange".}
-proc zip_unchange_all*(para1: Pzip): int32 {.cdecl, importc: "zip_unchange_all".}
-proc zip_unchange_archive*(para1: Pzip): int32 {.cdecl, 
-    importc: "zip_unchange_archive".}
diff --git a/lib/wrappers/zip/libzip_all.c b/lib/wrappers/zip/libzip_all.c
deleted file mode 100755
index 797374b29..000000000
--- a/lib/wrappers/zip/libzip_all.c
+++ /dev/null
@@ -1,4189 +0,0 @@
-/*
-  zipint.h -- internal declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <zlib.h>
-
-/*
-#ifdef _MSC_VER
-#define ZIP_EXTERN __declspec(dllimport)
-#endif
-*/
-
-/*
-  zip.h -- exported declarations.
-  Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
-
-  This file is part of libzip, a library to manipulate ZIP archives.
-  The authors can be contacted at <libzip@nih.at>
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
-  3. The names of the authors may not be used to endorse or promote
-     products derived from this software without specific prior
-     written permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-#ifndef ZIP_EXTERN
-#define ZIP_EXTERN
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <time.h>
-
-/* flags for zip_open */
-
-#define ZIP_CREATE           1
-#define ZIP_EXCL             2
-#define ZIP_CHECKCONS        4
-
-
-/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
-
-#define ZIP_FL_NOCASE                1 /* ignore case on name lookup */
-#define ZIP_FL_NODIR                2 /* ignore directory component */
-#define ZIP_FL_COMPRESSED        4 /* read compressed data */
-#define ZIP_FL_UNCHANGED        8 /* use original data, ignoring changes */
-#define ZIP_FL_RECOMPRESS      16 /* force recompression of data */
-
-/* archive global flags flags */
-
-#define ZIP_AFL_TORRENT                1 /* torrent zipped */
-
-/* libzip error codes */
-
-#define ZIP_ER_OK             0  /* N No error */
-#define ZIP_ER_MULTIDISK      1  /* N Multi-disk zip archives not supported */
-#define ZIP_ER_RENAME         2  /* S Renaming temporary file failed */
-#define ZIP_ER_CLOSE          3  /* S Closing zip archive failed */
-#define ZIP_ER_SEEK           4  /* S Seek error */
-#define ZIP_ER_READ           5  /* S Read error */
-#define ZIP_ER_WRITE          6  /* S Write error */
-#define ZIP_ER_CRC            7  /* N CRC error */
-#define ZIP_ER_ZIPCLOSED      8  /* N Containing zip archive was closed */
-#define ZIP_ER_NOENT          9  /* N No such file */
-#define ZIP_ER_EXISTS        10  /* N File already exists */
-#define ZIP_ER_OPEN          11  /* S Can't open file */
-#define ZIP_ER_TMPOPEN       12  /* S Failure to create temporary file */
-#define ZIP_ER_ZLIB          13  /* Z Zlib error */
-#define ZIP_ER_MEMORY        14  /* N Malloc failure */
-#define ZIP_ER_CHANGED       15  /* N Entry has been changed */
-#define ZIP_ER_COMPNOTSUPP   16  /* N Compression method not supported */
-#define ZIP_ER_EOF           17  /* N Premature EOF */
-#define ZIP_ER_INVAL         18  /* N Invalid argument */
-#define ZIP_ER_NOZIP         19  /* N Not a zip archive */
-#define ZIP_ER_INTERNAL      20  /* N Internal error */
-#define ZIP_ER_INCONS        21  /* N Zip archive inconsistent */
-#define ZIP_ER_REMOVE        22  /* S Can't remove file */
-#define ZIP_ER_DELETED       23  /* N Entry has been deleted */
-
-
-/* type of system error value */
-
-#define ZIP_ET_NONE              0  /* sys_err unused */
-#define ZIP_ET_SYS              1  /* sys_err is errno */
-#define ZIP_ET_ZLIB              2  /* sys_err is zlib error code */
-
-/* compression methods */
-
-#define ZIP_CM_DEFAULT              -1  /* better of deflate or store */
-#define ZIP_CM_STORE               0  /* stored (uncompressed) */
-#define ZIP_CM_SHRINK               1  /* shrunk */
-#define ZIP_CM_REDUCE_1               2  /* reduced with factor 1 */
-#define ZIP_CM_REDUCE_2               3  /* reduced with factor 2 */
-#define ZIP_CM_REDUCE_3               4  /* reduced with factor 3 */
-#define ZIP_CM_REDUCE_4               5  /* reduced with factor 4 */
-#define ZIP_CM_IMPLODE               6  /* imploded */
-/* 7 - Reserved for Tokenizing compression algorithm */
-#define ZIP_CM_DEFLATE               8  /* deflated */
-#define ZIP_CM_DEFLATE64       9  /* deflate64 */
-#define ZIP_CM_PKWARE_IMPLODE 10  /* PKWARE imploding */
-/* 11 - Reserved by PKWARE */
-#define ZIP_CM_BZIP2          12  /* compressed using BZIP2 algorithm */
-/* 13 - Reserved by PKWARE */
-#define ZIP_CM_LZMA              14  /* LZMA (EFS) */
-/* 15-17 - Reserved by PKWARE */
-#define ZIP_CM_TERSE              18  /* compressed using IBM TERSE (new) */
-#define ZIP_CM_LZ77           19  /* IBM LZ77 z Architecture (PFS) */
-#define ZIP_CM_WAVPACK              97  /* WavPack compressed data */
-#define ZIP_CM_PPMD              98  /* PPMd version I, Rev 1 */
-
-/* encryption methods */
-
-#define ZIP_EM_NONE               0  /* not encrypted */
-#define ZIP_EM_TRAD_PKWARE     1  /* traditional PKWARE encryption */
-#if 0 /* Strong Encryption Header not parsed yet */
-#define ZIP_EM_DES        0x6601  /* strong encryption: DES */
-#define ZIP_EM_RC2_OLD    0x6602  /* strong encryption: RC2, version < 5.2 */
-#define ZIP_EM_3DES_168   0x6603
-#define ZIP_EM_3DES_112   0x6609
-#define ZIP_EM_AES_128    0x660e
-#define ZIP_EM_AES_192    0x660f
-#define ZIP_EM_AES_256    0x6610
-#define ZIP_EM_RC2        0x6702  /* strong encryption: RC2, version >= 5.2 */
-#define ZIP_EM_RC4        0x6801
-#endif
-#define ZIP_EM_UNKNOWN    0xffff  /* unknown algorithm */
-
-typedef long myoff_t; /* XXX: 64 bit support */
-
-enum zip_source_cmd {
-    ZIP_SOURCE_OPEN,        /* prepare for reading */
-    ZIP_SOURCE_READ,         /* read data */
-    ZIP_SOURCE_CLOSE,        /* reading is done */
-    ZIP_SOURCE_STAT,        /* get meta information */
-    ZIP_SOURCE_ERROR,        /* get error information */
-    ZIP_SOURCE_FREE        /* cleanup and free resources */
-};
-
-typedef ssize_t (*zip_source_callback)(void *state, void *data,
-                                       size_t len, enum zip_source_cmd cmd);
-
-struct zip_stat {
-    const char *name;                        /* name of the file */
-    int index;                                /* index within archive */
-    unsigned int crc;                        /* crc of file data */
-    time_t mtime;                        /* modification time */
-    myoff_t size;                                /* size of file (uncompressed) */
-    myoff_t comp_size;                        /* size of file (compressed) */
-    unsigned short comp_method;                /* compression method used */
-    unsigned short encryption_method;        /* encryption method used */
-};
-
-struct zip;
-struct zip_file;
-struct zip_source;
-
-
-ZIP_EXTERN int zip_add(struct zip *, const char *, struct zip_source *);
-ZIP_EXTERN int zip_add_dir(struct zip *, const char *);
-ZIP_EXTERN int zip_close(struct zip *);
-ZIP_EXTERN int zip_delete(struct zip *, int);
-ZIP_EXTERN void zip_error_clear(struct zip *);
-ZIP_EXTERN void zip_error_get(struct zip *, int *, int *);
-ZIP_EXTERN int zip_error_get_sys_type(int);
-ZIP_EXTERN int zip_error_to_str(char *, size_t, int, int);
-ZIP_EXTERN int zip_fclose(struct zip_file *);
-ZIP_EXTERN void zip_file_error_clear(struct zip_file *);
-ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *);
-ZIP_EXTERN const char *zip_file_strerror(struct zip_file *);
-ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, int);
-ZIP_EXTERN struct zip_file *zip_fopen_index(struct zip *, int, int);
-ZIP_EXTERN ssize_t zip_fread(struct zip_file *, void *, size_t);
-ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, int);
-ZIP_EXTERN int zip_get_archive_flag(struct zip *, int, int);
-ZIP_EXTERN const char *zip_get_file_comment(struct zip *, int, int *, int);
-ZIP_EXTERN const char *zip_get_name(struct zip *, int, int);
-ZIP_EXTERN int zip_get_num_files(struct zip *);
-ZIP_EXTERN int zip_name_locate(struct zip *, const char *, int);
-ZIP_EXTERN struct zip *zip_open(const char *, int, int *);
-ZIP_EXTERN int zip_rename(struct zip *, int, const char *);
-ZIP_EXTERN int zip_replace(struct zip *, int, struct zip_source *);
-ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, int);
-ZIP_EXTERN int zip_set_archive_flag(struct zip *, int, int);
-ZIP_EXTERN int zip_set_file_comment(struct zip *, int, const char *, int);
-ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *,
-                                                myoff_t, int);
-ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *,
-                                              myoff_t, myoff_t);
-ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *,
-                                               myoff_t, myoff_t);
-ZIP_EXTERN void zip_source_free(struct zip_source *);
-ZIP_EXTERN struct zip_source *zip_source_function(struct zip *,
-                                                  zip_source_callback, void *);
-ZIP_EXTERN struct zip_source *zip_source_zip(struct zip *, struct zip *,
-                                             int, int, myoff_t, myoff_t);
-ZIP_EXTERN int zip_stat(struct zip *, const char *, int, struct zip_stat *);
-ZIP_EXTERN int zip_stat_index(struct zip *, int, int, struct zip_stat *);
-ZIP_EXTERN void zip_stat_init(struct zip_stat *);
-ZIP_EXTERN const char *zip_strerror(struct zip *);
-ZIP_EXTERN int zip_unchange(struct zip *, int);
-ZIP_EXTERN int zip_unchange_all(struct zip *);
-ZIP_EXTERN int zip_unchange_archive(struct zip *);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
-   */
-/* #undef HAVE_DECL_TZNAME */
-
-#define HAVE_CONFIG_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `fseeko' function. */
-#define HAVE_FSEEKO 1
-
-/* Define to 1 if you have the `ftello' function. */
-#define HAVE_FTELLO 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `z' library (-lz). */
-#define HAVE_LIBZ 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mkstemp' function. */
-#define HAVE_MKSTEMP 1
-
-/* Define to 1 if you have the `MoveFileExA' function. */
-/* #undef HAVE_MOVEFILEEXA */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if `tm_zone' is member of `struct tm'. */
-#define HAVE_STRUCT_TM_TM_ZONE 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
-   `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#define HAVE_TM_ZONE 1
-
-/* Define to 1 if you don't have `tm_zone' but do have the external array
-   `tzname'. */
-/* #undef HAVE_TZNAME */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Name of package */
-#define PACKAGE "libzip"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "libzip@nih.at"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libzip"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libzip 0.9"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libzip"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.9"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-/* #undef TM_IN_SYS_TIME */
-
-/* Version number of package */
-#define VERSION "0.9"
-
-
-#ifndef HAVE_MKSTEMP
-int _zip_mkstemp(char *);
-#define mkstemp _zip_mkstemp
-#endif
-
-#ifdef HAVE_MOVEFILEEXA
-#include <windows.h>
-#define _zip_rename(s, t)                                                \
-        (!MoveFileExA((s), (t),                                                \
-                     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING))
-#else
-#define _zip_rename        rename
-#endif
-
-#ifndef HAVE_FSEEKO
-#define fseeko(s, o, w)        (fseek((s), (long int)(o), (w)))
-#endif
-#ifndef HAVE_FTELLO
-#define ftello(s)        ((long)ftell((s)))
-#endif
-
-
-#define CENTRAL_MAGIC "PK\1\2"
-#define LOCAL_MAGIC   "PK\3\4"
-#define EOCD_MAGIC    "PK\5\6"
-#define DATADES_MAGIC "PK\7\8"
-#define TORRENT_SIG        "TORRENTZIPPED-"
-#define TORRENT_SIG_LEN        14
-#define TORRENT_CRC_LEN 8
-#define TORRENT_MEM_LEVEL        8
-#define CDENTRYSIZE         46u
-#define LENTRYSIZE          30
-#define MAXCOMLEN        65536
-#define EOCDLEN             22
-#define CDBUFSIZE       (MAXCOMLEN+EOCDLEN)
-#define BUFSIZE                8192
-
-
-/* state of change of a file in zip archive */
-
-enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
-                 ZIP_ST_ADDED, ZIP_ST_RENAMED };
-
-/* constants for struct zip_file's member flags */
-
-#define ZIP_ZF_EOF        1 /* EOF reached */
-#define ZIP_ZF_DECOMP        2 /* decompress data */
-#define ZIP_ZF_CRC        4 /* compute and compare CRC */
-
-/* directory entry: general purpose bit flags */
-
-#define ZIP_GPBF_ENCRYPTED                0x0001        /* is encrypted */
-#define ZIP_GPBF_DATA_DESCRIPTOR        0x0008        /* crc/size after file data */
-#define ZIP_GPBF_STRONG_ENCRYPTION        0x0040  /* uses strong encryption */
-
-/* error information */
-
-struct zip_error {
-    int zip_err;        /* libzip error code (ZIP_ER_*) */
-    int sys_err;        /* copy of errno (E*) or zlib error code */
-    char *str;                /* string representation or NULL */
-};
-
-/* zip archive, part of API */
-
-struct zip {
-    char *zn;                        /* file name */
-    FILE *zp;                        /* file */
-    struct zip_error error;        /* error information */
-
-    unsigned int flags;                /* archive global flags */
-    unsigned int ch_flags;        /* changed archive global flags */
-
-    struct zip_cdir *cdir;        /* central directory */
-    char *ch_comment;                /* changed archive comment */
-    int ch_comment_len;                /* length of changed zip archive
-                                 * comment, -1 if unchanged */
-    int nentry;                        /* number of entries */
-    int nentry_alloc;                /* number of entries allocated */
-    struct zip_entry *entry;        /* entries */
-    int nfile;                        /* number of opened files within archive */
-    int nfile_alloc;                /* number of files allocated */
-    struct zip_file **file;        /* opened files within archive */
-};
-
-/* file in zip archive, part of API */
-
-struct zip_file {
-    struct zip *za;                /* zip archive containing this file */
-    struct zip_error error;        /* error information */
-    int flags;                        /* -1: eof, >0: error */
-
-    int method;                        /* compression method */
-    myoff_t fpos;                        /* position within zip file (fread/fwrite) */
-    unsigned long bytes_left;        /* number of bytes left to read */
-    unsigned long cbytes_left;  /* number of bytes of compressed data left */
-    
-    unsigned long crc;                /* CRC so far */
-    unsigned long crc_orig;        /* CRC recorded in archive */
-    
-    char *buffer;
-    z_stream *zstr;
-};
-
-/* zip archive directory entry (central or local) */
-
-struct zip_dirent {
-    unsigned short version_madeby;        /* (c)  version of creator */
-    unsigned short version_needed;        /* (cl) version needed to extract */
-    unsigned short bitflags;                /* (cl) general purpose bit flag */
-    unsigned short comp_method;                /* (cl) compression method used */
-    time_t last_mod;                        /* (cl) time of last modification */
-    unsigned int crc;                        /* (cl) CRC-32 of uncompressed data */
-    unsigned int comp_size;                /* (cl) size of commpressed data */
-    unsigned int uncomp_size;                /* (cl) size of uncommpressed data */
-    char *filename;                        /* (cl) file name (NUL-terminated) */
-    unsigned short filename_len;        /* (cl) length of filename (w/o NUL) */
-    char *extrafield;                        /* (cl) extra field */
-    unsigned short extrafield_len;        /* (cl) length of extra field */
-    char *comment;                        /* (c)  file comment */
-    unsigned short comment_len;                /* (c)  length of file comment */
-    unsigned short disk_number;                /* (c)  disk number start */
-    unsigned short int_attrib;                /* (c)  internal file attributes */
-    unsigned int ext_attrib;                /* (c)  external file attributes */
-    unsigned int offset;                /* (c)  offset of local header  */
-};
-
-/* zip archive central directory */
-
-struct zip_cdir {
-    struct zip_dirent *entry;        /* directory entries */
-    int nentry;                        /* number of entries */
-
-    unsigned int size;                /* size of central direcotry */
-    unsigned int offset;        /* offset of central directory in file */
-    char *comment;                /* zip archive comment */
-    unsigned short comment_len;        /* length of zip archive comment */
-};
-
-
-
-struct zip_source {
-    zip_source_callback f;
-    void *ud;
-};
-
-/* entry in zip archive directory */
-
-struct zip_entry {
-    enum zip_state state;
-    struct zip_source *source;
-    char *ch_filename;
-    char *ch_comment;
-    int ch_comment_len;
-};
-
-
-
-extern const char * const _zip_err_str[];
-extern const int _zip_nerr_str;
-extern const int _zip_err_type[];
-
-
-
-#define ZIP_ENTRY_DATA_CHANGED(x)        \
-                        ((x)->state == ZIP_ST_REPLACED  \
-                         || (x)->state == ZIP_ST_ADDED)
-
-
-
-int _zip_cdir_compute_crc(struct zip *, uLong *);
-void _zip_cdir_free(struct zip_cdir *);
-struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
-int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
-
-void _zip_dirent_finalize(struct zip_dirent *);
-void _zip_dirent_init(struct zip_dirent *);
-int _zip_dirent_read(struct zip_dirent *, FILE *,
-                     unsigned char **, unsigned int, int, struct zip_error *);
-void _zip_dirent_torrent_normalize(struct zip_dirent *);
-int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
-
-void _zip_entry_free(struct zip_entry *);
-void _zip_entry_init(struct zip *, int);
-struct zip_entry *_zip_entry_new(struct zip *);
-
-void _zip_error_clear(struct zip_error *);
-void _zip_error_copy(struct zip_error *, struct zip_error *);
-void _zip_error_fini(struct zip_error *);
-void _zip_error_get(struct zip_error *, int *, int *);
-void _zip_error_init(struct zip_error *);
-void _zip_error_set(struct zip_error *, int, int);
-const char *_zip_error_strerror(struct zip_error *);
-
-int _zip_file_fillbuf(void *, size_t, struct zip_file *);
-unsigned int _zip_file_get_offset(struct zip *, int);
-
-int _zip_filerange_crc(FILE *, myoff_t, myoff_t, uLong *, struct zip_error *);
-
-struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *,
-                                         myoff_t, myoff_t);
-
-void _zip_free(struct zip *);
-const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
-int _zip_local_header_read(struct zip *, int);
-void *_zip_memdup(const void *, size_t, struct zip_error *);
-int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
-struct zip *_zip_new(struct zip_error *);
-unsigned short _zip_read2(unsigned char **);
-unsigned int _zip_read4(unsigned char **);
-int _zip_replace(struct zip *, int, const char *, struct zip_source *);
-int _zip_set_name(struct zip *, int, const char *);
-int _zip_unchange(struct zip *, int, int);
-void _zip_unchange_data(struct zip_entry *);
-
-         
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-const char *
-_zip_error_strerror(struct zip_error *err)
-{
-    const char *zs, *ss;
-    char buf[128], *s;
-
-    _zip_error_fini(err);
-
-    if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
-        sprintf(buf, "Unknown error %d", err->zip_err);
-        zs = NULL;
-        ss = buf;
-    }
-    else {
-        zs = _zip_err_str[err->zip_err];
-        
-        switch (_zip_err_type[err->zip_err]) {
-        case ZIP_ET_SYS:
-            ss = strerror(err->sys_err);
-            break;
-
-        case ZIP_ET_ZLIB:
-            ss = zError(err->sys_err);
-            break;
-
-        default:
-            ss = NULL;
-        }
-    }
-
-    if (ss == NULL)
-        return zs;
-    else {
-        if ((s=(char *)malloc(strlen(ss)
-                              + (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
-            return _zip_err_str[ZIP_ER_MEMORY];
-        
-        sprintf(s, "%s%s%s",
-                (zs ? zs : ""),
-                (zs ? ": " : ""),
-                ss);
-        err->str = s;
-
-        return s;
-    }
-}
-
-#include <stdlib.h>
-
-
-
-void
-_zip_error_clear(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-}
-
-
-
-void
-_zip_error_copy(struct zip_error *dst, struct zip_error *src)
-{
-    dst->zip_err = src->zip_err;
-    dst->sys_err = src->sys_err;
-}
-
-
-
-void
-_zip_error_fini(struct zip_error *err)
-{
-    free(err->str);
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_get(struct zip_error *err, int *zep, int *sep)
-{
-    if (zep)
-        *zep = err->zip_err;
-    if (sep) {
-        if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
-            *sep = err->sys_err;
-        else
-            *sep = 0;
-    }
-}
-
-
-
-void
-_zip_error_init(struct zip_error *err)
-{
-    err->zip_err = ZIP_ER_OK;
-    err->sys_err = 0;
-    err->str = NULL;
-}
-
-
-
-void
-_zip_error_set(struct zip_error *err, int ze, int se)
-{
-    if (err) {
-        err->zip_err = ze;
-        err->sys_err = se;
-    }
-}
-
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-
-
-int
-_zip_mkstemp(char *path)
-{
-        int fd;   
-        char *start, *trv;
-        struct stat sbuf;
-        pid_t pid;
-
-        /* To guarantee multiple calls generate unique names even if
-           the file is not created. 676 different possibilities with 7
-           or more X's, 26 with 6 or less. */
-        static char xtra[2] = "aa";
-        int xcnt = 0;
-
-        pid = getpid();
-
-        /* Move to end of path and count trailing X's. */
-        for (trv = path; *trv; ++trv)
-                if (*trv == 'X')
-                        xcnt++;
-                else
-                        xcnt = 0;        
-
-        /* Use at least one from xtra.  Use 2 if more than 6 X's. */
-        if (*(trv - 1) == 'X')
-                *--trv = xtra[0];
-        if (xcnt > 6 && *(trv - 1) == 'X')
-                *--trv = xtra[1];
-
-        /* Set remaining X's to pid digits with 0's to the left. */
-        while (*--trv == 'X') {
-                *trv = (pid % 10) + '0';
-                pid /= 10;
-        }
-
-        /* update xtra for next call. */
-        if (xtra[0] != 'z')
-                xtra[0]++;
-        else {
-                xtra[0] = 'a';
-                if (xtra[1] != 'z')
-                        xtra[1]++;
-                else
-                        xtra[1] = 'a';
-        }
-
-        /*
-         * check the target directory; if you have six X's and it
-         * doesn't exist this runs for a *very* long time.
-         */
-        for (start = trv + 1;; --trv) {
-                if (trv <= path)
-                        break;
-                if (*trv == '/') {
-                        *trv = '\0';
-                        if (stat(path, &sbuf))
-                                return (0);
-                        if (!S_ISDIR(sbuf.st_mode)) {
-                                errno = ENOTDIR;
-                                return (0);
-                        }
-                        *trv = '/';
-                        break;
-                }
-        }
-
-        for (;;) {
-                if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0)
-                        return (fd);
-                if (errno != EEXIST)
-                        return (0);
-
-                /* tricky little algorithm for backward compatibility */
-                for (trv = start;;) {
-                        if (!*trv)
-                                return (0);
-                        if (*trv == 'z')
-                                *trv++ = 'a';
-                        else {
-                                if (isdigit((unsigned char)*trv))
-                                        *trv = 'a';
-                                else
-                                        ++*trv;
-                                break;
-                        }
-                }
-        }
-        /*NOTREACHED*/
-}
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-static time_t _zip_d2u_time(int, int);
-static char *_zip_readfpstr(FILE *, unsigned int, int, struct zip_error *);
-static char *_zip_readstr(unsigned char **, int, int, struct zip_error *);
-static void _zip_u2d_time(time_t, unsigned short *, unsigned short *);
-static void _zip_write2(unsigned short, FILE *);
-static void _zip_write4(unsigned int, FILE *);
-
-
-
-void
-_zip_cdir_free(struct zip_cdir *cd)
-{
-    int i;
-
-    if (!cd)
-        return;
-
-    for (i=0; i<cd->nentry; i++)
-        _zip_dirent_finalize(cd->entry+i);
-    free(cd->comment);
-    free(cd->entry);
-    free(cd);
-}
-
-
-
-struct zip_cdir *
-_zip_cdir_new(int nentry, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    
-    if ((cd=(struct zip_cdir *)malloc(sizeof(*cd))) == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if ((cd->entry=(struct zip_dirent *)malloc(sizeof(*(cd->entry))*nentry))
-        == NULL) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        free(cd);
-        return NULL;
-    }
-
-    /* entries must be initialized by caller */
-
-    cd->nentry = nentry;
-    cd->size = cd->offset = 0;
-    cd->comment = NULL;
-    cd->comment_len = 0;
-
-    return cd;
-}
-
-
-
-int
-_zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error)
-{
-    int i;
-
-    cd->offset = ftello(fp);
-
-    for (i=0; i<cd->nentry; i++) {
-        if (_zip_dirent_write(cd->entry+i, fp, 0, error) != 0)
-            return -1;
-    }
-
-    cd->size = ftello(fp) - cd->offset;
-    
-    /* clearerr(fp); */
-    fwrite(EOCD_MAGIC, 1, 4, fp);
-    _zip_write4(0, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write2((unsigned short)cd->nentry, fp);
-    _zip_write4(cd->size, fp);
-    _zip_write4(cd->offset, fp);
-    _zip_write2(cd->comment_len, fp);
-    fwrite(cd->comment, 1, cd->comment_len, fp);
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-void
-_zip_dirent_finalize(struct zip_dirent *zde)
-{
-    free(zde->filename);
-    zde->filename = NULL;
-    free(zde->extrafield);
-    zde->extrafield = NULL;
-    free(zde->comment);
-    zde->comment = NULL;
-}
-
-
-
-void
-_zip_dirent_init(struct zip_dirent *de)
-{
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 0;
-    de->comp_method = 0;
-    de->last_mod = 0;
-    de->crc = 0;
-    de->comp_size = 0;
-    de->uncomp_size = 0;
-    de->filename = NULL;
-    de->filename_len = 0;
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    de->comment = NULL;
-    de->comment_len = 0;
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-}
-
-
-
-/* _zip_dirent_read(zde, fp, bufp, left, localp, error):
-   Fills the zip directory entry zde.
-
-   If bufp is non-NULL, data is taken from there and bufp is advanced
-   by the amount of data used; no more than left bytes are used.
-   Otherwise data is read from fp as needed.
-
-   If localp != 0, it reads a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_read(struct zip_dirent *zde, FILE *fp,
-                 unsigned char **bufp, unsigned int left, int localp,
-                 struct zip_error *error)
-{
-    unsigned char buf[CDENTRYSIZE];
-    unsigned char *cur;
-    unsigned short dostime, dosdate;
-    unsigned int size;
-
-    if (localp)
-        size = LENTRYSIZE;
-    else
-        size = CDENTRYSIZE;
-    
-    if (bufp) {
-        /* use data from buffer */
-        cur = *bufp;
-        if (left < size) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-    }
-    else {
-        /* read entry from disk */
-        if ((fread(buf, 1, size, fp)<size)) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        left = size;
-        cur = buf;
-    }
-
-    if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return -1;
-    }
-    cur += 4;
-
-    
-    /* convert buffercontents to zip_dirent */
-    
-    if (!localp)
-        zde->version_madeby = _zip_read2(&cur);
-    else
-        zde->version_madeby = 0;
-    zde->version_needed = _zip_read2(&cur);
-    zde->bitflags = _zip_read2(&cur);
-    zde->comp_method = _zip_read2(&cur);
-    
-    /* convert to time_t */
-    dostime = _zip_read2(&cur);
-    dosdate = _zip_read2(&cur);
-    zde->last_mod = _zip_d2u_time(dostime, dosdate);
-    
-    zde->crc = _zip_read4(&cur);
-    zde->comp_size = _zip_read4(&cur);
-    zde->uncomp_size = _zip_read4(&cur);
-    
-    zde->filename_len = _zip_read2(&cur);
-    zde->extrafield_len = _zip_read2(&cur);
-    
-    if (localp) {
-        zde->comment_len = 0;
-        zde->disk_number = 0;
-        zde->int_attrib = 0;
-        zde->ext_attrib = 0;
-        zde->offset = 0;
-    } else {
-        zde->comment_len = _zip_read2(&cur);
-        zde->disk_number = _zip_read2(&cur);
-        zde->int_attrib = _zip_read2(&cur);
-        zde->ext_attrib = _zip_read4(&cur);
-        zde->offset = _zip_read4(&cur);
-    }
-
-    zde->filename = NULL;
-    zde->extrafield = NULL;
-    zde->comment = NULL;
-
-    if (bufp) {
-        if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len
-                                  +zde->comment_len)) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-
-        if (zde->filename_len) {
-            zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readstr(&cur, zde->extrafield_len, 0,
-                                           error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readstr(&cur, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-    else {
-        if (zde->filename_len) {
-            zde->filename = _zip_readfpstr(fp, zde->filename_len, 1, error);
-            if (!zde->filename)
-                    return -1;
-        }
-
-        if (zde->extrafield_len) {
-            zde->extrafield = _zip_readfpstr(fp, zde->extrafield_len, 0,
-                                             error);
-            if (!zde->extrafield)
-                return -1;
-        }
-
-        if (zde->comment_len) {
-            zde->comment = _zip_readfpstr(fp, zde->comment_len, 0, error);
-            if (!zde->comment)
-                return -1;
-        }
-    }
-
-    if (bufp)
-      *bufp = cur;
-
-    return 0;
-}
-
-
-
-/* _zip_dirent_torrent_normalize(de);
-   Set values suitable for torrentzip.
-*/
-
-void
-_zip_dirent_torrent_normalize(struct zip_dirent *de)
-{
-    static struct tm torrenttime;
-    static time_t last_mod = 0;
-
-    if (last_mod == 0) {
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time_t now;
-        struct tm *l;
-#endif
-
-        torrenttime.tm_sec = 0;
-        torrenttime.tm_min = 32;
-        torrenttime.tm_hour = 23;
-        torrenttime.tm_mday = 24;
-        torrenttime.tm_mon = 11;
-        torrenttime.tm_year = 96;
-        torrenttime.tm_wday = 0;
-        torrenttime.tm_yday = 0;
-        torrenttime.tm_isdst = 0;
-
-#ifdef HAVE_STRUCT_TM_TM_ZONE
-        time(&now);
-        l = localtime(&now);
-        torrenttime.tm_gmtoff = l->tm_gmtoff;
-        torrenttime.tm_zone = l->tm_zone;
-#endif
-
-        last_mod = mktime(&torrenttime);
-    }
-    
-    de->version_madeby = 0;
-    de->version_needed = 20; /* 2.0 */
-    de->bitflags = 2; /* maximum compression */
-    de->comp_method = ZIP_CM_DEFLATE;
-    de->last_mod = last_mod;
-
-    de->disk_number = 0;
-    de->int_attrib = 0;
-    de->ext_attrib = 0;
-    de->offset = 0;
-
-    free(de->extrafield);
-    de->extrafield = NULL;
-    de->extrafield_len = 0;
-    free(de->comment);
-    de->comment = NULL;
-    de->comment_len = 0;
-}
-
-
-
-/* _zip_dirent_write(zde, fp, localp, error):
-   Writes zip directory entry zde to file fp.
-
-   If localp != 0, it writes a local header instead of a central
-   directory entry.
-
-   Returns 0 if successful. On error, error is filled in and -1 is
-   returned.
-*/
-
-int
-_zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp,
-                  struct zip_error *error)
-{
-    unsigned short dostime, dosdate;
-
-    fwrite(localp ? LOCAL_MAGIC : CENTRAL_MAGIC, 1, 4, fp);
-
-    if (!localp)
-        _zip_write2(zde->version_madeby, fp);
-    _zip_write2(zde->version_needed, fp);
-    _zip_write2(zde->bitflags, fp);
-    _zip_write2(zde->comp_method, fp);
-
-    _zip_u2d_time(zde->last_mod, &dostime, &dosdate);
-    _zip_write2(dostime, fp);
-    _zip_write2(dosdate, fp);
-    
-    _zip_write4(zde->crc, fp);
-    _zip_write4(zde->comp_size, fp);
-    _zip_write4(zde->uncomp_size, fp);
-    
-    _zip_write2(zde->filename_len, fp);
-    _zip_write2(zde->extrafield_len, fp);
-    
-    if (!localp) {
-        _zip_write2(zde->comment_len, fp);
-        _zip_write2(zde->disk_number, fp);
-        _zip_write2(zde->int_attrib, fp);
-        _zip_write4(zde->ext_attrib, fp);
-        _zip_write4(zde->offset, fp);
-    }
-
-    if (zde->filename_len)
-        fwrite(zde->filename, 1, zde->filename_len, fp);
-
-    if (zde->extrafield_len)
-        fwrite(zde->extrafield, 1, zde->extrafield_len, fp);
-
-    if (!localp) {
-        if (zde->comment_len)
-            fwrite(zde->comment, 1, zde->comment_len, fp);
-    }
-
-    if (ferror(fp)) {
-        _zip_error_set(error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static time_t
-_zip_d2u_time(int dtime, int ddate)
-{
-    struct tm *tm;
-    time_t now;
-
-    now = time(NULL);
-    tm = localtime(&now);
-    /* let mktime decide if DST is in effect */
-    tm->tm_isdst = -1;
-    
-    tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
-    tm->tm_mon = ((ddate>>5)&15) - 1;
-    tm->tm_mday = ddate&31;
-
-    tm->tm_hour = (dtime>>11)&31;
-    tm->tm_min = (dtime>>5)&63;
-    tm->tm_sec = (dtime<<1)&62;
-
-    return mktime(tm);
-}
-
-
-
-unsigned short
-_zip_read2(unsigned char **a)
-{
-    unsigned short ret;
-
-    ret = (*a)[0]+((*a)[1]<<8);
-    *a += 2;
-
-    return ret;
-}
-
-
-
-unsigned int
-_zip_read4(unsigned char **a)
-{
-    unsigned int ret;
-
-    ret = ((((((*a)[3]<<8)+(*a)[2])<<8)+(*a)[1])<<8)+(*a)[0];
-    *a += 4;
-
-    return ret;
-}
-
-
-
-static char *
-_zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    if (fread(r, 1, len, fp)<len) {
-        free(r);
-        _zip_error_set(error, ZIP_ER_READ, errno);
-        return NULL;
-    }
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-    
-    return r;
-}
-
-
-
-static char *
-_zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error)
-{
-    char *r, *o;
-
-    r = (char *)malloc(nulp ? len+1 : len);
-    if (!r) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    memcpy(r, *buf, len);
-    *buf += len;
-
-    if (nulp) {
-        /* replace any in-string NUL characters with spaces */
-        r[len] = 0;
-        for (o=r; o<r+len; o++)
-            if (*o == '\0')
-                *o = ' ';
-    }
-
-    return r;
-}
-
-
-
-static void
-_zip_write2(unsigned short i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-
-    return;
-}
-
-
-
-static void
-_zip_write4(unsigned int i, FILE *fp)
-{
-    putc(i&0xff, fp);
-    putc((i>>8)&0xff, fp);
-    putc((i>>16)&0xff, fp);
-    putc((i>>24)&0xff, fp);
-    
-    return;
-}
-
-
-
-static void
-_zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate)
-{
-    struct tm *tm;
-
-    tm = localtime(&time);
-    *ddate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5)
-        + tm->tm_mday;
-    *dtime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5)
-        + ((tm->tm_sec)>>1);
-
-    return;
-}
-
-
-
-ZIP_EXTERN int
-zip_delete(struct zip *za, int idx)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    /* allow duplicate file names, because the file will
-     * be removed directly afterwards */
-    if (_zip_unchange(za, idx, 1) != 0)
-        return -1;
-
-    za->entry[idx].state = ZIP_ST_DELETED;
-
-    return 0;
-}
-
-
-
-ZIP_EXTERN void
-zip_error_clear(struct zip *za)
-{
-    _zip_error_clear(&za->error);
-}
-
-
-ZIP_EXTERN int
-zip_add(struct zip *za, const char *name, struct zip_source *source)
-{
-    if (name == NULL || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-        
-    return _zip_replace(za, -1, name, source);
-}
-
-
-ZIP_EXTERN int
-zip_error_get_sys_type(int ze)
-{
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return 0;
-
-    return _zip_err_type[ze];
-}
-
-
-ZIP_EXTERN void
-zip_error_get(struct zip *za, int *zep, int *sep)
-{
-    _zip_error_get(&za->error, zep, sep);
-}
-
-
-const char * const _zip_err_str[] = {
-    "No error",
-    "Multi-disk zip archives not supported",
-    "Renaming temporary file failed",
-    "Closing zip archive failed",
-    "Seek error",
-    "Read error",
-    "Write error",
-    "CRC error",
-    "Containing zip archive was closed",
-    "No such file",
-    "File already exists",
-    "Can't open file",
-    "Failure to create temporary file",
-    "Zlib error",
-    "Malloc failure",
-    "Entry has been changed",
-    "Compression method not supported",
-    "Premature EOF",
-    "Invalid argument",
-    "Not a zip archive",
-    "Internal error",
-    "Zip archive inconsistent",
-    "Can't remove file",
-    "Entry has been deleted",
-};
-
-const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
-
-#define N ZIP_ET_NONE
-#define S ZIP_ET_SYS
-#define Z ZIP_ET_ZLIB
-
-const int _zip_err_type[] = {
-    N,
-    N,
-    S,
-    S,
-    S,
-    S,
-    S,
-    N,
-    N,
-    N,
-    N,
-    S,
-    S,
-    Z,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    N,
-    S,
-    N,
-};
-
-
-struct zip_entry *
-_zip_entry_new(struct zip *za)
-{
-    struct zip_entry *ze;
-    if (!za) {
-        ze = (struct zip_entry *)malloc(sizeof(struct zip_entry));
-        if (!ze) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return NULL;
-        }
-    }
-    else {
-        if (za->nentry >= za->nentry_alloc-1) {
-            za->nentry_alloc += 16;
-            za->entry = (struct zip_entry *)realloc(za->entry,
-                                                    sizeof(struct zip_entry)
-                                                    * za->nentry_alloc);
-            if (!za->entry) {
-                _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-                return NULL;
-            }
-        }
-        ze = za->entry+za->nentry;
-    }
-
-    ze->state = ZIP_ST_UNCHANGED;
-
-    ze->ch_filename = NULL;
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-    ze->source = NULL;
-
-    if (za)
-        za->nentry++;
-
-    return ze;
-}
-
-
-void
-_zip_entry_free(struct zip_entry *ze)
-{
-    free(ze->ch_filename);
-    ze->ch_filename = NULL;
-    free(ze->ch_comment);
-    ze->ch_comment = NULL;
-    ze->ch_comment_len = -1;
-
-    _zip_unchange_data(ze);
-}
-
-
-static int add_data(struct zip *, struct zip_source *, struct zip_dirent *,
-                    FILE *);
-static int add_data_comp(zip_source_callback, void *, struct zip_stat *,
-                         FILE *, struct zip_error *);
-static int add_data_uncomp(struct zip *, zip_source_callback, void *,
-                           struct zip_stat *, FILE *);
-static void ch_set_error(struct zip_error *, zip_source_callback, void *);
-static int copy_data(FILE *, myoff_t, FILE *, struct zip_error *);
-static int write_cdir(struct zip *, struct zip_cdir *, FILE *);
-static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *);
-static int _zip_changed(struct zip *, int *);
-static char *_zip_create_temp_output(struct zip *, FILE **);
-static int _zip_torrentzip_cmp(const void *, const void *);
-
-
-
-struct filelist {
-    int idx;
-    const char *name;
-};
-
-
-
-ZIP_EXTERN int
-zip_close(struct zip *za)
-{
-    int survivors;
-    int i, j, error;
-    char *temp;
-    FILE *out;
-    mode_t mask;
-    struct zip_cdir *cd;
-    struct zip_dirent de;
-    struct filelist *filelist;
-    int reopen_on_error;
-    int new_torrentzip;
-
-    reopen_on_error = 0;
-
-    if (za == NULL)
-        return -1;
-
-    if (!_zip_changed(za, &survivors)) {
-        _zip_free(za);
-        return 0;
-    }
-
-    /* don't create zip files with no entries */
-    if (survivors == 0) {
-        if (za->zn && za->zp) {
-            if (remove(za->zn) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_REMOVE, errno);
-                return -1;
-            }
-        }
-        _zip_free(za);
-        return 0;
-    }               
-
-    if ((filelist=(struct filelist *)malloc(sizeof(filelist[0])*survivors))
-        == NULL)
-        return -1;
-
-    if ((cd=_zip_cdir_new(survivors, &za->error)) == NULL) {
-        free(filelist);
-        return -1;
-    }
-
-    for (i=0; i<survivors; i++)
-        _zip_dirent_init(&cd->entry[i]);
-
-    /* archive comment is special for torrentzip */
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
-        cd->comment = _zip_memdup(TORRENT_SIG "XXXXXXXX",
-                                  TORRENT_SIG_LEN + TORRENT_CRC_LEN,
-                                  &za->error);
-        if (cd->comment == NULL) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-        cd->comment_len = TORRENT_SIG_LEN + TORRENT_CRC_LEN;
-    }
-    else if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, ZIP_FL_UNCHANGED) == 0) {
-        if (_zip_cdir_set_comment(cd, za) == -1) {
-            _zip_cdir_free(cd);
-            free(filelist);
-            return -1;
-        }
-    }
-
-    if ((temp=_zip_create_temp_output(za, &out)) == NULL) {
-        _zip_cdir_free(cd);
-        return -1;
-    }
-
-
-    /* create list of files with index into original archive  */
-    for (i=j=0; i<za->nentry; i++) {
-        if (za->entry[i].state == ZIP_ST_DELETED)
-            continue;
-
-        filelist[j].idx = i;
-        filelist[j].name = zip_get_name(za, i, 0);
-        j++;
-    }
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        qsort(filelist, survivors, sizeof(filelist[0]),
-              _zip_torrentzip_cmp);
-
-    new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
-                      && zip_get_archive_flag(za, ZIP_AFL_TORRENT,
-                                              ZIP_FL_UNCHANGED) == 0);
-    error = 0;
-    for (j=0; j<survivors; j++) {
-        i = filelist[j].idx;
-
-        /* create new local directory entry */
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            _zip_dirent_init(&de);
-
-            if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-                _zip_dirent_torrent_normalize(&de);
-                
-            /* use it as central directory entry */
-            memcpy(cd->entry+j, &de, sizeof(cd->entry[j]));
-
-            /* set/update file name */
-            if (za->entry[i].ch_filename == NULL) {
-                if (za->entry[i].state == ZIP_ST_ADDED) {
-                    de.filename = strdup("-");
-                    de.filename_len = 1;
-                    cd->entry[j].filename = "-";
-                }
-                else {
-                    de.filename = strdup(za->cdir->entry[i].filename);
-                    de.filename_len = strlen(de.filename);
-                    cd->entry[j].filename = za->cdir->entry[i].filename;
-                    cd->entry[j].filename_len = de.filename_len;
-                }
-            }
-        }
-        else {
-            /* copy existing directory entries */
-            if (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0) {
-                _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-                error = 1;
-                break;
-            }
-            if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) {
-                error = 1;
-                break;
-            }
-            if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
-                de.crc = za->cdir->entry[i].crc;
-                de.comp_size = za->cdir->entry[i].comp_size;
-                de.uncomp_size = za->cdir->entry[i].uncomp_size;
-                de.bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR;
-            }
-            memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j]));
-        }
-
-        if (za->entry[i].ch_filename) {
-            free(de.filename);
-            if ((de.filename=strdup(za->entry[i].ch_filename)) == NULL) {
-                error = 1;
-                break;
-            }
-            de.filename_len = strlen(de.filename);
-            cd->entry[j].filename = za->entry[i].ch_filename;
-            cd->entry[j].filename_len = de.filename_len;
-        }
-
-        if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0
-            && za->entry[i].ch_comment_len != -1) {
-            /* as the rest of cd entries, its malloc/free is done by za */
-            cd->entry[j].comment = za->entry[i].ch_comment;
-            cd->entry[j].comment_len = za->entry[i].ch_comment_len;
-        }
-
-        cd->entry[j].offset = ftello(out);
-
-        if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
-            struct zip_source *zs;
-
-            zs = NULL;
-            if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) {
-                if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1))
-                    == NULL) {
-                    error = 1;
-                    break;
-                }
-            }
-
-            if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) {
-                error = 1;
-                break;
-            }
-            cd->entry[j].last_mod = de.last_mod;
-            cd->entry[j].comp_method = de.comp_method;
-            cd->entry[j].comp_size = de.comp_size;
-            cd->entry[j].uncomp_size = de.uncomp_size;
-            cd->entry[j].crc = de.crc;
-        }
-        else {
-            if (_zip_dirent_write(&de, out, 1, &za->error) < 0) {
-                error = 1;
-                break;
-            }
-            /* we just read the local dirent, file is at correct position */
-            if (copy_data(za->zp, cd->entry[j].comp_size, out,
-                          &za->error) < 0) {
-                error = 1;
-                break;
-            }
-        }
-
-        _zip_dirent_finalize(&de);
-    }
-
-    if (!error) {
-        if (write_cdir(za, cd, out) < 0)
-            error = 1;
-    }
-   
-    /* pointers in cd entries are owned by za */
-    cd->nentry = 0;
-    _zip_cdir_free(cd);
-
-    if (error) {
-        _zip_dirent_finalize(&de);
-        fclose(out);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-
-    if (fclose(out) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_CLOSE, errno);
-        remove(temp);
-        free(temp);
-        return -1;
-    }
-    
-    if (za->zp) {
-        fclose(za->zp);
-        za->zp = NULL;
-        reopen_on_error = 1;
-    }
-    if (_zip_rename(temp, za->zn) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_RENAME, errno);
-        remove(temp);
-        free(temp);
-        if (reopen_on_error) {
-            /* ignore errors, since we're already in an error case */
-            za->zp = fopen(za->zn, "rb");
-        }
-        return -1;
-    }
-    mask = umask(0);
-    umask(mask);
-    chmod(za->zn, 0666&~mask);
-
-    _zip_free(za);
-    free(temp);
-    
-    return 0;
-}
-
-
-
-static int
-add_data(struct zip *za, struct zip_source *zs, struct zip_dirent *de, FILE *ft)
-{
-    myoff_t offstart, offend;
-    zip_source_callback cb;
-    void *ud;
-    struct zip_stat st;
-    
-    cb = zs->f;
-    ud = zs->ud;
-
-    if (cb(ud, &st, sizeof(st), ZIP_SOURCE_STAT) < (ssize_t)sizeof(st)) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_OPEN) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offstart = ftello(ft);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-
-    if (st.comp_method != ZIP_CM_STORE) {
-        if (add_data_comp(cb, ud, &st, ft, &za->error) < 0)
-            return -1;
-    }
-    else {
-        if (add_data_uncomp(za, cb, ud, &st, ft) < 0)
-            return -1;
-    }
-
-    if (cb(ud, NULL, 0, ZIP_SOURCE_CLOSE) < 0) {
-        ch_set_error(&za->error, cb, ud);
-        return -1;
-    }
-
-    offend = ftello(ft);
-
-    if (fseeko(ft, offstart, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    
-    de->last_mod = st.mtime;
-    de->comp_method = st.comp_method;
-    de->crc = st.crc;
-    de->uncomp_size = st.size;
-    de->comp_size = st.comp_size;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        _zip_dirent_torrent_normalize(de);
-
-    if (_zip_dirent_write(de, ft, 1, &za->error) < 0)
-        return -1;
-    
-    if (fseeko(ft, offend, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-add_data_comp(zip_source_callback cb, void *ud, struct zip_stat *st,FILE *ft,
-              struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    ssize_t n;
-
-    st->comp_size = 0;
-    while ((n=cb(ud, buf, sizeof(buf), ZIP_SOURCE_READ)) > 0) {
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        st->comp_size += n;
-    }
-    if (n < 0) {
-        ch_set_error(error, cb, ud);
-        return -1;
-    }        
-
-    return 0;
-}
-
-
-
-static int
-add_data_uncomp(struct zip *za, zip_source_callback cb, void *ud,
-                struct zip_stat *st, FILE *ft)
-{
-    char b1[BUFSIZE], b2[BUFSIZE];
-    int end, flush, ret;
-    ssize_t n;
-    size_t n2;
-    z_stream zstr;
-    int mem_level;
-
-    st->comp_method = ZIP_CM_DEFLATE;
-    st->comp_size = st->size = 0;
-    st->crc = crc32(0, NULL, 0);
-
-    zstr.zalloc = Z_NULL;
-    zstr.zfree = Z_NULL;
-    zstr.opaque = NULL;
-    zstr.avail_in = 0;
-    zstr.avail_out = 0;
-
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
-        mem_level = TORRENT_MEM_LEVEL;
-    else
-        mem_level = MAX_MEM_LEVEL;
-
-    /* -MAX_WBITS: undocumented feature of zlib to _not_ write a zlib header */
-    deflateInit2(&zstr, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, mem_level,
-                 Z_DEFAULT_STRATEGY);
-
-    zstr.next_out = (Bytef *)b2;
-    zstr.avail_out = sizeof(b2);
-    zstr.avail_in = 0;
-
-    flush = 0;
-    end = 0;
-    while (!end) {
-        if (zstr.avail_in == 0 && !flush) {
-            if ((n=cb(ud, b1, sizeof(b1), ZIP_SOURCE_READ)) < 0) {
-                ch_set_error(&za->error, cb, ud);
-                deflateEnd(&zstr);
-                return -1;
-            }
-            if (n > 0) {
-                zstr.avail_in = n;
-                zstr.next_in = (Bytef *)b1;
-                st->size += n;
-                st->crc = crc32(st->crc, (Bytef *)b1, n);
-            }
-            else
-                flush = Z_FINISH;
-        }
-
-        ret = deflate(&zstr, flush);
-        if (ret != Z_OK && ret != Z_STREAM_END) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-        
-        if (zstr.avail_out != sizeof(b2)) {
-            n2 = sizeof(b2) - zstr.avail_out;
-            
-            if (fwrite(b2, 1, n2, ft) != n2) {
-                _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-                return -1;
-            }
-        
-            zstr.next_out = (Bytef *)b2;
-            zstr.avail_out = sizeof(b2);
-            st->comp_size += n2;
-        }
-
-        if (ret == Z_STREAM_END) {
-            deflateEnd(&zstr);
-            end = 1;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static void
-ch_set_error(struct zip_error *error, zip_source_callback cb, void *ud)
-{
-    int e[2];
-
-    if ((cb(ud, e, sizeof(e), ZIP_SOURCE_ERROR)) < (ssize_t)sizeof(e)) {
-        error->zip_err = ZIP_ER_INTERNAL;
-        error->sys_err = 0;
-    }
-    else {
-        error->zip_err = e[0];
-        error->sys_err = e[1];
-    }
-}
-
-
-
-static int
-copy_data(FILE *fs, myoff_t len, FILE *ft, struct zip_error *error)
-{
-    char buf[BUFSIZE];
-    int n, nn;
-
-    if (len == 0)
-        return 0;
-
-    while (len > 0) {
-        nn = len > sizeof(buf) ? sizeof(buf) : len;
-        if ((n=fread(buf, 1, nn, fs)) < 0) {
-            _zip_error_set(error, ZIP_ER_READ, errno);
-            return -1;
-        }
-        else if (n == 0) {
-            _zip_error_set(error, ZIP_ER_EOF, 0);
-            return -1;
-        }
-
-        if (fwrite(buf, 1, n, ft) != (size_t)n) {
-            _zip_error_set(error, ZIP_ER_WRITE, errno);
-            return -1;
-        }
-        
-        len -= n;
-    }
-
-    return 0;
-}
-
-
-
-static int
-write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out)
-{
-    myoff_t offset;
-    uLong crc;
-    char buf[TORRENT_CRC_LEN+1];
-    
-    if (_zip_cdir_write(cd, out, &za->error) < 0)
-        return -1;
-    
-    if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0)
-        return 0;
-
-
-    /* fix up torrentzip comment */
-
-    offset = ftello(out);
-
-    if (_zip_filerange_crc(out, cd->offset, cd->size, &crc, &za->error) < 0)
-        return -1;
-
-    snprintf(buf, sizeof(buf), "%08lX", (long)crc);
-
-    if (fseeko(out, offset-TORRENT_CRC_LEN, SEEK_SET) < 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-
-    if (fwrite(buf, TORRENT_CRC_LEN, 1, out) != 1) {
-        _zip_error_set(&za->error, ZIP_ER_WRITE, errno);
-        return -1;
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src)
-{
-    if (src->ch_comment_len != -1) {
-        dest->comment = _zip_memdup(src->ch_comment,
-                                    src->ch_comment_len, &src->error);
-        if (dest->comment == NULL)
-            return -1;
-        dest->comment_len = src->ch_comment_len;
-    } else {
-        if (src->cdir && src->cdir->comment) {
-            dest->comment = _zip_memdup(src->cdir->comment,
-                                        src->cdir->comment_len, &src->error);
-            if (dest->comment == NULL)
-                return -1;
-            dest->comment_len = src->cdir->comment_len;
-        }
-    }
-
-    return 0;
-}
-
-
-
-static int
-_zip_changed(struct zip *za, int *survivorsp)
-{
-    int changed, i, survivors;
-
-    changed = survivors = 0;
-
-    if (za->ch_comment_len != -1
-        || za->ch_flags != za->flags)
-        changed = 1;
-
-    for (i=0; i<za->nentry; i++) {
-        if ((za->entry[i].state != ZIP_ST_UNCHANGED)
-            || (za->entry[i].ch_comment_len != -1))
-            changed = 1;
-        if (za->entry[i].state != ZIP_ST_DELETED)
-            survivors++;
-    }
-
-    *survivorsp = survivors;
-
-    return changed;
-}
-
-
-
-static char *
-_zip_create_temp_output(struct zip *za, FILE **outp)
-{
-    char *temp;
-    int tfd;
-    FILE *tfp;
-    
-    if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    sprintf(temp, "%s.XXXXXX", za->zn);
-
-    if ((tfd=mkstemp(temp)) == -1) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        free(temp);
-        return NULL;
-    }
-    
-    if ((tfp=fdopen(tfd, "r+b")) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
-        close(tfd);
-        remove(temp);
-        free(temp);
-        return NULL;
-    }
-
-    *outp = tfp;
-    return temp;
-}
-
-
-
-static int
-_zip_torrentzip_cmp(const void *a, const void *b)
-{
-    return strcasecmp(((const struct filelist *)a)->name,
-                      ((const struct filelist *)b)->name);
-}
-
-
-
-ZIP_EXTERN int
-zip_add_dir(struct zip *za, const char *name)
-{
-    int len, ret;
-    char *s;
-    struct zip_source *source;
-
-    if (name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    s = NULL;
-    len = strlen(name);
-
-    if (name[len-1] != '/') {
-        if ((s=(char *)malloc(len+2)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            return -1;
-        }
-        strcpy(s, name);
-        s[len] = '/';
-        s[len+1] = '\0';
-    }
-
-    if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) {
-        free(s);
-        return -1;
-    }
-        
-    ret = _zip_replace(za, -1, s ? s : name, source);
-
-    free(s);
-    if (ret < 0)
-        zip_source_free(source);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_error_to_str(char *buf, size_t len, int ze, int se)
-{
-    const char *zs, *ss;
-
-    if (ze < 0 || ze >= _zip_nerr_str)
-        return snprintf(buf, len, "Unknown error %d", ze);
-
-    zs = _zip_err_str[ze];
-        
-    switch (_zip_err_type[ze]) {
-    case ZIP_ET_SYS:
-        ss = strerror(se);
-        break;
-        
-    case ZIP_ET_ZLIB:
-        ss = zError(se);
-        break;
-        
-    default:
-        ss = NULL;
-    }
-
-    return snprintf(buf, len, "%s%s%s",
-                    zs, (ss ? ": " : ""), (ss ? ss : ""));
-}
-
-
-ZIP_EXTERN void
-zip_file_error_clear(struct zip_file *zf)
-{
-    _zip_error_clear(&zf->error);
-}
-
-
-ZIP_EXTERN int
-zip_fclose(struct zip_file *zf)
-{
-    int i, ret;
-    
-    if (zf->zstr)
-        inflateEnd(zf->zstr);
-    free(zf->buffer);
-    free(zf->zstr);
-
-    for (i=0; i<zf->za->nfile; i++) {
-        if (zf->za->file[i] == zf) {
-            zf->za->file[i] = zf->za->file[zf->za->nfile-1];
-            zf->za->nfile--;
-            break;
-        }
-    }
-
-    ret = 0;
-    if (zf->error.zip_err)
-        ret = zf->error.zip_err;
-    else if ((zf->flags & ZIP_ZF_CRC) && (zf->flags & ZIP_ZF_EOF)) {
-        /* if EOF, compare CRC */
-        if (zf->crc_orig != zf->crc)
-            ret = ZIP_ER_CRC;
-    }
-
-    free(zf);
-    return ret;
-}
-
-
-int
-_zip_filerange_crc(FILE *fp, myoff_t start, myoff_t len, uLong *crcp,
-                   struct zip_error *errp)
-{
-    Bytef buf[BUFSIZE];
-    size_t n;
-
-    *crcp = crc32(0L, Z_NULL, 0);
-
-    if (fseeko(fp, start, SEEK_SET) != 0) {
-        _zip_error_set(errp, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    
-    while (len > 0) {
-        n = len > BUFSIZE ? BUFSIZE : len;
-        if ((n=fread(buf, 1, n, fp)) <= 0) {
-            _zip_error_set(errp, ZIP_ER_READ, errno);
-            return -1;
-        }
-
-        *crcp = crc32(*crcp, buf, n);
-
-        len-= n;
-    }
-
-    return 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_file_strerror(struct zip_file *zf)
-{
-    return _zip_error_strerror(&zf->error);
-}
-
-
-/* _zip_file_get_offset(za, ze):
-   Returns the offset of the file data for entry ze.
-
-   On error, fills in za->error and returns 0.
-*/
-
-unsigned int
-_zip_file_get_offset(struct zip *za, int idx)
-{
-    struct zip_dirent de;
-    unsigned int offset;
-
-    offset = za->cdir->entry[idx].offset;
-
-    if (fseeko(za->zp, offset, SEEK_SET) != 0) {
-        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
-        return 0;
-    }
-
-    if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0)
-        return 0;
-
-    offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
-
-    _zip_dirent_finalize(&de);
-
-    return offset;
-}
-
-
-ZIP_EXTERN void
-zip_file_error_get(struct zip_file *zf, int *zep, int *sep)
-{
-    _zip_error_get(&zf->error, zep, sep);
-}
-
-
-static struct zip_file *_zip_file_new(struct zip *za);
-
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen_index(struct zip *za, int fileno, int flags)
-{
-    int len, ret;
-    int zfflags;
-    struct zip_file *zf;
-
-    if ((fileno < 0) || (fileno >= za->nentry)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+fileno)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (fileno >= za->cdir->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    zfflags = 0;
-    switch (za->cdir->entry[fileno].comp_method) {
-    case ZIP_CM_STORE:
-        zfflags |= ZIP_ZF_CRC;
-        break;
-
-    case ZIP_CM_DEFLATE:
-        if ((flags & ZIP_FL_COMPRESSED) == 0)
-            zfflags |= ZIP_ZF_CRC | ZIP_ZF_DECOMP;
-        break;
-    default:
-        if ((flags & ZIP_FL_COMPRESSED) == 0) {
-            _zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
-            return NULL;
-        }
-        break;
-    }
-
-    zf = _zip_file_new(za);
-
-    zf->flags = zfflags;
-    /* zf->name = za->cdir->entry[fileno].filename; */
-    zf->method = za->cdir->entry[fileno].comp_method;
-    zf->bytes_left = za->cdir->entry[fileno].uncomp_size;
-    zf->cbytes_left = za->cdir->entry[fileno].comp_size;
-    zf->crc_orig = za->cdir->entry[fileno].crc;
-
-    if ((zf->fpos=_zip_file_get_offset(za, fileno)) == 0) {
-        zip_fclose(zf);
-        return NULL;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0)
-        zf->bytes_left = zf->cbytes_left;
-    else {
-        if ((zf->buffer=(char *)malloc(BUFSIZE)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-
-        len = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-        if (len <= 0) {
-            _zip_error_copy(&za->error, &zf->error);
-            zip_fclose(zf);
-        return NULL;
-        }
-
-        if ((zf->zstr = (z_stream *)malloc(sizeof(z_stream))) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            zip_fclose(zf);
-            return NULL;
-        }
-        zf->zstr->zalloc = Z_NULL;
-        zf->zstr->zfree = Z_NULL;
-        zf->zstr->opaque = NULL;
-        zf->zstr->next_in = (Bytef *)zf->buffer;
-        zf->zstr->avail_in = len;
-        
-        /* negative value to tell zlib that there is no header */
-        if ((ret=inflateInit2(zf->zstr, -MAX_WBITS)) != Z_OK) {
-            _zip_error_set(&za->error, ZIP_ER_ZLIB, ret);
-            zip_fclose(zf);
-            return NULL;
-        }
-    }
-    
-    return zf;
-}
-
-
-
-int
-_zip_file_fillbuf(void *buf, size_t buflen, struct zip_file *zf)
-{
-    int i, j;
-
-    if (zf->error.zip_err != ZIP_ER_OK)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || zf->cbytes_left <= 0 || buflen <= 0)
-        return 0;
-    
-    if (fseeko(zf->za->zp, zf->fpos, SEEK_SET) < 0) {
-        _zip_error_set(&zf->error, ZIP_ER_SEEK, errno);
-        return -1;
-    }
-    if (buflen < zf->cbytes_left)
-        i = buflen;
-    else
-        i = zf->cbytes_left;
-
-    j = fread(buf, 1, i, zf->za->zp);
-    if (j == 0) {
-        _zip_error_set(&zf->error, ZIP_ER_EOF, 0);
-        j = -1;
-    }
-    else if (j < 0)
-        _zip_error_set(&zf->error, ZIP_ER_READ, errno);
-    else {
-        zf->fpos += j;
-        zf->cbytes_left -= j;
-    }
-
-    return j;        
-}
-
-
-
-static struct zip_file *
-_zip_file_new(struct zip *za)
-{
-    struct zip_file *zf, **file;
-    int n;
-
-    if ((zf=(struct zip_file *)malloc(sizeof(struct zip_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-    
-    if (za->nfile >= za->nfile_alloc-1) {
-        n = za->nfile_alloc + 10;
-        file = (struct zip_file **)realloc(za->file,
-                                           n*sizeof(struct zip_file *));
-        if (file == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(zf);
-            return NULL;
-        }
-        za->nfile_alloc = n;
-        za->file = file;
-    }
-
-    za->file[za->nfile++] = zf;
-
-    zf->za = za;
-    _zip_error_init(&zf->error);
-    zf->flags = 0;
-    zf->crc = crc32(0L, Z_NULL, 0);
-    zf->crc_orig = 0;
-    zf->method = -1;
-    zf->bytes_left = zf->cbytes_left = 0;
-    zf->fpos = 0;
-    zf->buffer = NULL;
-    zf->zstr = NULL;
-
-    return zf;
-}
-
-
-ZIP_EXTERN struct zip_file *
-zip_fopen(struct zip *za, const char *fname, int flags)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return NULL;
-
-    return zip_fopen_index(za, idx, flags);
-}
-
-
-ZIP_EXTERN int
-zip_set_file_comment(struct zip *za, int idx, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (idx < 0 || idx >= za->nentry
-        || len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = tmpcom;
-    za->entry[idx].ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_file(struct zip *za, const char *fname, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (fname == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, fname, NULL, start, len);
-}
-
-
-struct read_data {
-    const char *buf, *data, *end;
-    time_t mtime;
-    int freep;
-};
-
-static ssize_t read_data(void *state, void *data, size_t len,
-                         enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_buffer(struct zip *za, const void *data, myoff_t len, int freep)
-{
-    struct read_data *f;
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if (len < 0 || (data == NULL && len > 0)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_data *)malloc(sizeof(*f))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->data = (const char *)data;
-    f->end = ((const char *)data)+len;
-    f->freep = freep;
-    f->mtime = time(NULL);
-    
-    if ((zs=zip_source_function(za, read_data, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_data *z;
-    char *buf;
-    size_t n;
-
-    z = (struct read_data *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        z->buf = z->data;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        n = z->end - z->buf;
-        if (n > len)
-            n = len;
-
-        if (n) {
-            memcpy(buf, z->buf, n);
-            z->buf += n;
-        }
-
-        return n;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = z->mtime;
-            st->size = z->end - z->data;
-            
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            e[0] = e[1] = 0;
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        if (z->freep) {
-            free((void *)z->data);
-            z->data = NULL;
-        }
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-int
-_zip_set_name(struct zip *za, int idx, const char *name)
-{
-    char *s;
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry || name == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((i=_zip_name_locate(za, name, 0, NULL)) != -1 && i != idx) {
-        _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-        return -1;
-    }
-
-    /* no effective name change */
-    if (i == idx)
-        return 0;
-    
-    if ((s=strdup(name)) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return -1;
-    }
-    
-    if (za->entry[idx].state == ZIP_ST_UNCHANGED) 
-        za->entry[idx].state = ZIP_ST_RENAMED;
-
-    free(za->entry[idx].ch_filename);
-    za->entry[idx].ch_filename = s;
-
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_flag(struct zip *za, int flag, int value)
-{
-    if (value)
-        za->ch_flags |= flag;
-    else
-        za->ch_flags &= ~flag;
-
-    return 0;
-}
-
-
-void
-_zip_unchange_data(struct zip_entry *ze)
-{
-    if (ze->source) {
-        (void)ze->source->f(ze->source->ud, NULL, 0, ZIP_SOURCE_FREE);
-        free(ze->source);
-        ze->source = NULL;
-    }
-    
-    ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED;
-}
-
-
-ZIP_EXTERN int
-zip_unchange_archive(struct zip *za)
-{
-    free(za->ch_comment);
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-
-    za->ch_flags = za->flags;
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange(struct zip *za, int idx)
-{
-    return _zip_unchange(za, idx, 0);
-}
-
-
-
-int
-_zip_unchange(struct zip *za, int idx, int allow_duplicates)
-{
-    int i;
-    
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (za->entry[idx].ch_filename) {
-        if (!allow_duplicates) {
-            i = _zip_name_locate(za,
-                         _zip_get_name(za, idx, ZIP_FL_UNCHANGED, NULL),
-                                 0, NULL);
-            if (i != -1 && i != idx) {
-                _zip_error_set(&za->error, ZIP_ER_EXISTS, 0);
-                return -1;
-            }
-        }
-
-        free(za->entry[idx].ch_filename);
-        za->entry[idx].ch_filename = NULL;
-    }
-
-    free(za->entry[idx].ch_comment);
-    za->entry[idx].ch_comment = NULL;
-    za->entry[idx].ch_comment_len = -1;
-
-    _zip_unchange_data(za->entry+idx);
-
-    return 0;
-}
-
-ZIP_EXTERN int
-zip_unchange_all(struct zip *za)
-{
-    int ret, i;
-
-    ret = 0;
-    for (i=0; i<za->nentry; i++)
-        ret |= _zip_unchange(za, i, 1);
-
-    ret |= zip_unchange_archive(za);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_set_archive_comment(struct zip *za, const char *comment, int len)
-{
-    char *tmpcom;
-
-    if (len < 0 || len > MAXCOMLEN
-        || (len > 0 && comment == NULL)) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (len > 0) {
-        if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL)
-            return -1;
-    }
-    else
-        tmpcom = NULL;
-
-    free(za->ch_comment);
-    za->ch_comment = tmpcom;
-    za->ch_comment_len = len;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_replace(struct zip *za, int idx, struct zip_source *source)
-{
-    if (idx < 0 || idx >= za->nentry || source == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if (_zip_replace(za, idx, NULL, source) == -1)
-        return -1;
-
-    return 0;
-}
-
-
-
-
-int
-_zip_replace(struct zip *za, int idx, const char *name,
-             struct zip_source *source)
-{
-    if (idx == -1) {
-        if (_zip_entry_new(za) == NULL)
-            return -1;
-
-        idx = za->nentry - 1;
-    }
-    
-    _zip_unchange_data(za->entry+idx);
-
-    if (name && _zip_set_name(za, idx, name) != 0)
-        return -1;
-    
-    za->entry[idx].state = ((za->cdir == NULL || idx >= za->cdir->nentry)
-                            ? ZIP_ST_ADDED : ZIP_ST_REPLACED);
-    za->entry[idx].source = source;
-
-    return idx;
-}
-
-
-ZIP_EXTERN int
-zip_rename(struct zip *za, int idx, const char *name)
-{
-    const char *old_name;
-    int old_is_dir, new_is_dir;
-    
-    if (idx >= za->nentry || idx < 0 || name[0] == '\0') {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((old_name=zip_get_name(za, idx, 0)) == NULL)
-        return -1;
-                                                                    
-    new_is_dir = (name[strlen(name)-1] == '/');
-    old_is_dir = (old_name[strlen(old_name)-1] == '/');
-
-    if (new_is_dir != old_is_dir) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    return _zip_set_name(za, idx, name);
-}
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void set_error(int *, struct zip_error *, int);
-static struct zip *_zip_allocate_new(const char *, int *);
-static int _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *);
-static void _zip_check_torrentzip(struct zip *);
-static struct zip_cdir *_zip_find_central_dir(FILE *, int, int *, myoff_t);
-static int _zip_file_exists(const char *, int, int *);
-static int _zip_headercomp(struct zip_dirent *, int,
-                           struct zip_dirent *, int);
-static unsigned char *_zip_memmem(const unsigned char *, int,
-                                  const unsigned char *, int);
-static struct zip_cdir *_zip_readcdir(FILE *, unsigned char *, unsigned char *,
-                                 int, int, struct zip_error *);
-
-
-
-ZIP_EXTERN struct zip *
-zip_open(const char *fn, int flags, int *zep)
-{
-    FILE *fp;
-    struct zip *za;
-    struct zip_cdir *cdir;
-    int i;
-    myoff_t len;
-    
-    switch (_zip_file_exists(fn, flags, zep)) {
-    case -1:
-        return NULL;
-    case 0:
-        return _zip_allocate_new(fn, zep);
-    default:
-        break;
-    }
-
-    if ((fp=fopen(fn, "rb")) == NULL) {
-        set_error(zep, NULL, ZIP_ER_OPEN);
-        return NULL;
-    }
-
-    fseeko(fp, 0, SEEK_END);
-    len = ftello(fp);
-
-    /* treat empty files as empty archives */
-    if (len == 0) {
-        if ((za=_zip_allocate_new(fn, zep)) == NULL)
-            fclose(fp);
-        else
-            za->zp = fp;
-        return za;
-    }
-
-    cdir = _zip_find_central_dir(fp, flags, zep, len);
-    if (cdir == NULL) {
-        fclose(fp);
-        return NULL;
-    }
-
-    if ((za=_zip_allocate_new(fn, zep)) == NULL) {
-        _zip_cdir_free(cdir);
-        fclose(fp);
-        return NULL;
-    }
-
-    za->cdir = cdir;
-    za->zp = fp;
-
-    if ((za->entry=(struct zip_entry *)malloc(sizeof(*(za->entry))
-                                              * cdir->nentry)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        _zip_free(za);
-        return NULL;
-    }
-    for (i=0; i<cdir->nentry; i++)
-        _zip_entry_new(za);
-
-    _zip_check_torrentzip(za);
-    za->ch_flags = za->flags;
-
-    return za;
-}
-
-
-
-static void
-set_error(int *zep, struct zip_error *err, int ze)
-{
-    int se;
-
-    if (err) {
-        _zip_error_get(err, &ze, &se);
-        if (zip_error_get_sys_type(ze) == ZIP_ET_SYS)
-            errno = se;
-    }
-
-    if (zep)
-        *zep = ze;
-}
-
-
-
-/* _zip_readcdir:
-   tries to find a valid end-of-central-directory at the beginning of
-   buf, and then the corresponding central directory entries.
-   Returns a struct zip_cdir which contains the central directory 
-   entries, or NULL if unsuccessful. */
-
-static struct zip_cdir *
-_zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen,
-              int flags, struct zip_error *error)
-{
-    struct zip_cdir *cd;
-    unsigned char *cdp, **bufp;
-    int i, comlen, nentry;
-
-    comlen = buf + buflen - eocd - EOCDLEN;
-    if (comlen < 0) {
-        /* not enough bytes left for comment */
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    /* check for end-of-central-dir magic */
-    if (memcmp(eocd, EOCD_MAGIC, 4) != 0) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        return NULL;
-    }
-
-    if (memcmp(eocd+4, "\0\0\0\0", 4) != 0) {
-        _zip_error_set(error, ZIP_ER_MULTIDISK, 0);
-        return NULL;
-    }
-
-    cdp = eocd + 8;
-    /* number of cdir-entries on this disk */
-    i = _zip_read2(&cdp);
-    /* number of cdir-entries */
-    nentry = _zip_read2(&cdp);
-
-    if ((cd=_zip_cdir_new(nentry, error)) == NULL)
-        return NULL;
-
-    cd->size = _zip_read4(&cdp);
-    cd->offset = _zip_read4(&cdp);
-    cd->comment = NULL;
-    cd->comment_len = _zip_read2(&cdp);
-
-    if ((comlen < cd->comment_len) || (cd->nentry != i)) {
-        _zip_error_set(error, ZIP_ER_NOZIP, 0);
-        free(cd);
-        return NULL;
-    }
-    if ((flags & ZIP_CHECKCONS) && comlen != cd->comment_len) {
-        _zip_error_set(error, ZIP_ER_INCONS, 0);
-        free(cd);
-        return NULL;
-    }
-
-    if (cd->comment_len) {
-        if ((cd->comment=(char *)_zip_memdup(eocd+EOCDLEN,
-                                             cd->comment_len, error))
-            == NULL) {
-            free(cd);
-            return NULL;
-        }
-    }
-
-    cdp = eocd;
-    if (cd->size < (unsigned int)(eocd-buf)) {
-        /* if buffer already read in, use it */
-        cdp = eocd - cd->size;
-        bufp = &cdp;
-    }
-    else {
-        /* go to start of cdir and read it entry by entry */
-        bufp = NULL;
-        clearerr(fp);
-        fseeko(fp, cd->offset, SEEK_SET);
-        /* possible consistency check: cd->offset =
-           len-(cd->size+cd->comment_len+EOCDLEN) ? */
-        if (ferror(fp) || ((unsigned long)ftello(fp) != cd->offset)) {
-            /* seek error or offset of cdir wrong */
-            if (ferror(fp))
-                _zip_error_set(error, ZIP_ER_SEEK, errno);
-            else
-                _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            free(cd);
-            return NULL;
-        }
-    }
-
-    for (i=0; i<cd->nentry; i++) {
-        if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0,
-                              error)) < 0) {
-            cd->nentry = i;
-            _zip_cdir_free(cd);
-            return NULL;
-        }
-    }
-    
-    return cd;
-}
-
-
-
-/* _zip_checkcons:
-   Checks the consistency of the central directory by comparing central
-   directory entries with local headers and checking for plausible
-   file and header offsets. Returns -1 if not plausible, else the
-   difference between the lowest and the highest fileposition reached */
-
-static int
-_zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error)
-{
-    int i;
-    unsigned int min, max, j;
-    struct zip_dirent temp;
-
-    if (cd->nentry) {
-        max = cd->entry[0].offset;
-        min = cd->entry[0].offset;
-    }
-    else
-        min = max = 0;
-
-    for (i=0; i<cd->nentry; i++) {
-        if (cd->entry[i].offset < min)
-            min = cd->entry[i].offset;
-        if (min > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        j = cd->entry[i].offset + cd->entry[i].comp_size
-            + cd->entry[i].filename_len + LENTRYSIZE;
-        if (j > max)
-            max = j;
-        if (max > cd->offset) {
-            _zip_error_set(error, ZIP_ER_NOZIP, 0);
-            return -1;
-        }
-        
-        if (fseeko(fp, cd->entry[i].offset, SEEK_SET) != 0) {
-            _zip_error_set(error, ZIP_ER_SEEK, 0);
-            return -1;
-        }
-        
-        if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1)
-            return -1;
-        
-        if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) {
-            _zip_error_set(error, ZIP_ER_INCONS, 0);
-            _zip_dirent_finalize(&temp);
-            return -1;
-        }
-        _zip_dirent_finalize(&temp);
-    }
-
-    return max - min;
-}
-
-
-
-/* _zip_check_torrentzip:
-   check wether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
-
-static void
-_zip_check_torrentzip(struct zip *za)
-{
-    uLong crc_got, crc_should;
-    char buf[8+1];
-    char *end;
-
-    if (za->zp == NULL || za->cdir == NULL)
-        return;
-
-    if (za->cdir->comment_len != TORRENT_SIG_LEN+8
-        || strncmp(za->cdir->comment, TORRENT_SIG, TORRENT_SIG_LEN) != 0)
-        return;
-
-    memcpy(buf, za->cdir->comment+TORRENT_SIG_LEN, 8);
-    buf[8] = '\0';
-    errno = 0;
-    crc_should = strtoul(buf, &end, 16);
-    if ((crc_should == UINT_MAX && errno != 0) || (end && *end))
-        return;
-
-    if (_zip_filerange_crc(za->zp, za->cdir->offset, za->cdir->size,
-                           &crc_got, NULL) < 0)
-        return;
-
-    if (crc_got == crc_should)
-        za->flags |= ZIP_AFL_TORRENT;
-}
-
-
-
-
-/* _zip_headercomp:
-   compares two headers h1 and h2; if they are local headers, set
-   local1p or local2p respectively to 1, else 0. Return 0 if they
-   are identical, -1 if not. */
-
-static int
-_zip_headercomp(struct zip_dirent *h1, int local1p, struct zip_dirent *h2,
-           int local2p)
-{
-    if ((h1->version_needed != h2->version_needed)
-#if 0
-        /* some zip-files have different values in local
-           and global headers for the bitflags */
-        || (h1->bitflags != h2->bitflags)
-#endif
-        || (h1->comp_method != h2->comp_method)
-        || (h1->last_mod != h2->last_mod)
-        || (h1->filename_len != h2->filename_len)
-        || !h1->filename || !h2->filename
-        || strcmp(h1->filename, h2->filename))
-        return -1;
-
-    /* check that CRC and sizes are zero if data descriptor is used */
-    if ((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local1p
-        && (h1->crc != 0
-            || h1->comp_size != 0
-            || h1->uncomp_size != 0))
-        return -1;
-    if ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local2p
-        && (h2->crc != 0
-            || h2->comp_size != 0
-            || h2->uncomp_size != 0))
-        return -1;
-    
-    /* check that CRC and sizes are equal if no data descriptor is used */
-    if (((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local1p == 0)
-        && ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local2p == 0)) {
-        if ((h1->crc != h2->crc)
-            || (h1->comp_size != h2->comp_size)
-            || (h1->uncomp_size != h2->uncomp_size))
-            return -1;
-    }
-    
-    if ((local1p == local2p)
-        && ((h1->extrafield_len != h2->extrafield_len)
-            || (h1->extrafield_len && h2->extrafield
-                && memcmp(h1->extrafield, h2->extrafield,
-                          h1->extrafield_len))))
-        return -1;
-
-    /* if either is local, nothing more to check */
-    if (local1p || local2p)
-        return 0;
-
-    if ((h1->version_madeby != h2->version_madeby)
-        || (h1->disk_number != h2->disk_number)
-        || (h1->int_attrib != h2->int_attrib)
-        || (h1->ext_attrib != h2->ext_attrib)
-        || (h1->offset != h2->offset)
-        || (h1->comment_len != h2->comment_len)
-        || (h1->comment_len && h2->comment
-            && memcmp(h1->comment, h2->comment, h1->comment_len)))
-        return -1;
-
-    return 0;
-}
-
-
-
-static struct zip *
-_zip_allocate_new(const char *fn, int *zep)
-{
-    struct zip *za;
-    struct zip_error error;
-
-    if ((za=_zip_new(&error)) == NULL) {
-        set_error(zep, &error, 0);
-        return NULL;
-    }
-        
-    za->zn = strdup(fn);
-    if (!za->zn) {
-        _zip_free(za);
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-    return za;
-}
-
-
-
-static int
-_zip_file_exists(const char *fn, int flags, int *zep)
-{
-    struct stat st;
-
-    if (fn == NULL) {
-        set_error(zep, NULL, ZIP_ER_INVAL);
-        return -1;
-    }
-    
-    if (stat(fn, &st) != 0) {
-        if (flags & ZIP_CREATE)
-            return 0;
-        else {
-            set_error(zep, NULL, ZIP_ER_OPEN);
-            return -1;
-        }
-    }
-    else if ((flags & ZIP_EXCL)) {
-        set_error(zep, NULL, ZIP_ER_EXISTS);
-        return -1;
-    }
-    /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
-       just like open() */
-
-    return 1;
-}
-
-
-
-static struct zip_cdir *
-_zip_find_central_dir(FILE *fp, int flags, int *zep, myoff_t len)
-{
-    struct zip_cdir *cdir, *cdirnew;
-    unsigned char *buf, *match;
-    int a, best, buflen, i;
-    struct zip_error zerr;
-
-    i = fseeko(fp, -(len < CDBUFSIZE ? len : CDBUFSIZE), SEEK_END);
-    if (i == -1 && errno != EFBIG) {
-        /* seek before start of file on my machine */
-        set_error(zep, NULL, ZIP_ER_SEEK);
-        return NULL;
-    }
-
-    /* 64k is too much for stack */
-    if ((buf=(unsigned char *)malloc(CDBUFSIZE)) == NULL) {
-        set_error(zep, NULL, ZIP_ER_MEMORY);
-        return NULL;
-    }
-
-    clearerr(fp);
-    buflen = fread(buf, 1, CDBUFSIZE, fp);
-
-    if (ferror(fp)) {
-        set_error(zep, NULL, ZIP_ER_READ);
-        free(buf);
-        return NULL;
-    }
-    
-    best = -1;
-    cdir = NULL;
-    match = buf;
-    _zip_error_set(&zerr, ZIP_ER_NOZIP, 0);
-
-    while ((match=_zip_memmem(match, buflen-(match-buf)-18,
-                              (const unsigned char *)EOCD_MAGIC, 4))!=NULL) {
-        /* found match -- check, if good */
-        /* to avoid finding the same match all over again */
-        match++;
-        if ((cdirnew=_zip_readcdir(fp, buf, match-1, buflen, flags,
-                                   &zerr)) == NULL)
-            continue;
-
-        if (cdir) {
-            if (best <= 0)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            a = _zip_checkcons(fp, cdirnew, &zerr);
-            if (best < a) {
-                _zip_cdir_free(cdir);
-                cdir = cdirnew;
-                best = a;
-            }
-            else
-                _zip_cdir_free(cdirnew);
-        }
-        else {
-            cdir = cdirnew;
-            if (flags & ZIP_CHECKCONS)
-                best = _zip_checkcons(fp, cdir, &zerr);
-            else
-                best = 0;
-        }
-        cdirnew = NULL;
-    }
-
-    free(buf);
-    
-    if (best < 0) {
-        set_error(zep, &zerr, 0);
-        _zip_cdir_free(cdir);
-        return NULL;
-    }
-
-    return cdir;
-}
-
-
-
-static unsigned char *
-_zip_memmem(const unsigned char *big, int biglen, const unsigned char *little, 
-       int littlelen)
-{
-    const unsigned char *p;
-    
-    if ((biglen < littlelen) || (littlelen == 0))
-        return NULL;
-    p = big-1;
-    while ((p=(const unsigned char *)
-                memchr(p+1, little[0], (size_t)(big-(p+1)+biglen-littlelen+1)))
-           != NULL) {
-        if (memcmp(p+1, little+1, littlelen-1)==0)
-            return (unsigned char *)p;
-    }
-
-    return NULL;
-}
-
-
-/* _zip_new:
-   creates a new zipfile struct, and sets the contents to zero; returns
-   the new struct. */
-
-struct zip *
-_zip_new(struct zip_error *error)
-{
-    struct zip *za;
-
-    za = (struct zip *)malloc(sizeof(struct zip));
-    if (!za) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    za->zn = NULL;
-    za->zp = NULL;
-    _zip_error_init(&za->error);
-    za->cdir = NULL;
-    za->ch_comment = NULL;
-    za->ch_comment_len = -1;
-    za->nentry = za->nentry_alloc = 0;
-    za->entry = NULL;
-    za->nfile = za->nfile_alloc = 0;
-    za->file = NULL;
-    za->flags = za->ch_flags = 0;
-    
-    return za;
-}
-
-
-void *
-_zip_memdup(const void *mem, size_t len, struct zip_error *error)
-{
-    void *ret;
-
-    ret = malloc(len);
-    if (!ret) {
-        _zip_error_set(error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    memcpy(ret, mem, len);
-
-    return ret;
-}
-
-
-ZIP_EXTERN int
-zip_get_num_files(struct zip *za)
-{
-    if (za == NULL)
-        return -1;
-
-    return za->nentry;
-}
-
-ZIP_EXTERN const char *
-zip_get_name(struct zip *za, int idx, int flags)
-{
-    return _zip_get_name(za, idx, flags, &za->error);
-}
-
-
-
-const char *
-_zip_get_name(struct zip *za, int idx, int flags, struct zip_error *error)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0) {
-        if (za->entry[idx].state == ZIP_ST_DELETED) {
-            _zip_error_set(error, ZIP_ER_DELETED, 0);
-            return NULL;
-        }
-        if (za->entry[idx].ch_filename)
-            return za->entry[idx].ch_filename;
-    }
-
-    if (za->cdir == NULL || idx >= za->cdir->nentry) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-    
-    return za->cdir->entry[idx].filename;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_file_comment(struct zip *za, int idx, int *lenp, int flags)
-{
-    if (idx < 0 || idx >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->entry[idx].ch_comment_len == -1)) {
-        if (lenp != NULL)
-            *lenp = za->cdir->entry[idx].comment_len;
-        return za->cdir->entry[idx].comment;
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->entry[idx].ch_comment_len;
-    return za->entry[idx].ch_comment;
-}
-
-
-ZIP_EXTERN int
-zip_get_archive_flag(struct zip *za, int flag, int flags)
-{
-    int fl;
-
-    fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags;
-
-    return (fl & flag) ? 1 : 0;
-}
-
-
-ZIP_EXTERN const char *
-zip_get_archive_comment(struct zip *za, int *lenp, int flags)
-{
-    if ((flags & ZIP_FL_UNCHANGED)
-        || (za->ch_comment_len == -1)) {
-        if (za->cdir) {
-            if (lenp != NULL)
-                *lenp = za->cdir->comment_len;
-            return za->cdir->comment;
-        }
-        else {
-            if (lenp != NULL)
-                *lenp = -1;
-            return NULL;
-        }
-    }
-    
-    if (lenp != NULL)
-        *lenp = za->ch_comment_len;
-    return za->ch_comment;
-}
-
-
-/* _zip_free:
-   frees the space allocated to a zipfile struct, and closes the
-   corresponding file. */
-
-void
-_zip_free(struct zip *za)
-{
-    int i;
-
-    if (za == NULL)
-        return;
-
-    if (za->zn)
-        free(za->zn);
-
-    if (za->zp)
-        fclose(za->zp);
-
-    _zip_cdir_free(za->cdir);
-
-    if (za->entry) {
-        for (i=0; i<za->nentry; i++) {
-            _zip_entry_free(za->entry+i);
-        }
-        free(za->entry);
-    }
-
-    for (i=0; i<za->nfile; i++) {
-        if (za->file[i]->error.zip_err == ZIP_ER_OK) {
-            _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
-            za->file[i]->za = NULL;
-        }
-    }
-
-    free(za->file);
-    
-    free(za);
-
-    return;
-}
-
-
-ZIP_EXTERN ssize_t
-zip_fread(struct zip_file *zf, void *outbuf, size_t toread)
-{
-    int ret;
-    size_t out_before, len;
-    int i;
-
-    if (!zf)
-        return -1;
-
-    if (zf->error.zip_err != 0)
-        return -1;
-
-    if ((zf->flags & ZIP_ZF_EOF) || (toread == 0))
-        return 0;
-
-    if (zf->bytes_left == 0) {
-        zf->flags |= ZIP_ZF_EOF;
-        if (zf->flags & ZIP_ZF_CRC) {
-            if (zf->crc != zf->crc_orig) {
-                _zip_error_set(&zf->error, ZIP_ER_CRC, 0);
-                return -1;
-            }
-        }
-        return 0;
-    }
-    
-    if ((zf->flags & ZIP_ZF_DECOMP) == 0) {
-        ret = _zip_file_fillbuf(outbuf, toread, zf);
-        if (ret > 0) {
-            if (zf->flags & ZIP_ZF_CRC)
-                zf->crc = crc32(zf->crc, (Bytef *)outbuf, ret);
-            zf->bytes_left -= ret;
-        }
-        return ret;
-    }
-    
-    zf->zstr->next_out = (Bytef *)outbuf;
-    zf->zstr->avail_out = toread;
-    out_before = zf->zstr->total_out;
-    
-    /* endless loop until something has been accomplished */
-    for (;;) {
-        ret = inflate(zf->zstr, Z_SYNC_FLUSH);
-
-        switch (ret) {
-        case Z_OK:
-        case Z_STREAM_END:
-            /* all ok */
-            /* Z_STREAM_END probably won't happen, since we didn't
-               have a header */
-            len = zf->zstr->total_out - out_before;
-            if (len >= zf->bytes_left || len >= toread) {
-                if (zf->flags & ZIP_ZF_CRC)
-                    zf->crc = crc32(zf->crc, (Bytef *)outbuf, len);
-                zf->bytes_left -= len;
-                return len;
-            }
-            break;
-
-        case Z_BUF_ERROR:
-            if (zf->zstr->avail_in == 0) {
-                i = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf);
-                if (i == 0) {
-                    _zip_error_set(&zf->error, ZIP_ER_INCONS, 0);
-                    return -1;
-                }
-                else if (i < 0)
-                    return -1;
-                zf->zstr->next_in = (Bytef *)zf->buffer;
-                zf->zstr->avail_in = i;
-                continue;
-            }
-            /* fallthrough */
-        case Z_NEED_DICT:
-        case Z_DATA_ERROR:
-        case Z_STREAM_ERROR:
-        case Z_MEM_ERROR:
-            _zip_error_set(&zf->error, ZIP_ER_ZLIB, ret);
-            return -1;
-        }
-    }
-}
-
-
-ZIP_EXTERN const char *
-zip_strerror(struct zip *za)
-{
-    return _zip_error_strerror(&za->error);
-}
-
-
-ZIP_EXTERN void
-zip_stat_init(struct zip_stat *st)
-{
-    st->name = NULL;
-    st->index = -1;
-    st->crc = 0;
-    st->mtime = (time_t)-1;
-    st->size = -1;
-    st->comp_size = -1;
-    st->comp_method = ZIP_CM_STORE;
-    st->encryption_method = ZIP_EM_NONE;
-}
-
-
-ZIP_EXTERN int
-zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st)
-{
-    const char *name;
-    
-    if (index < 0 || index >= za->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-
-    if ((name=zip_get_name(za, index, flags)) == NULL)
-        return -1;
-    
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(za->entry+index)) {
-        if (za->entry[index].source->f(za->entry[index].source->ud,
-                                     st, sizeof(*st), ZIP_SOURCE_STAT) < 0) {
-            _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-            return -1;
-        }
-    }
-    else {
-        if (za->cdir == NULL || index >= za->cdir->nentry) {
-            _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-            return -1;
-        }
-        
-        st->crc = za->cdir->entry[index].crc;
-        st->size = za->cdir->entry[index].uncomp_size;
-        st->mtime = za->cdir->entry[index].last_mod;
-        st->comp_size = za->cdir->entry[index].comp_size;
-        st->comp_method = za->cdir->entry[index].comp_method;
-        if (za->cdir->entry[index].bitflags & ZIP_GPBF_ENCRYPTED) {
-            if (za->cdir->entry[index].bitflags & ZIP_GPBF_STRONG_ENCRYPTION) {
-                /* XXX */
-                st->encryption_method = ZIP_EM_UNKNOWN;
-            }
-            else
-                st->encryption_method = ZIP_EM_TRAD_PKWARE;
-        }
-        else
-            st->encryption_method = ZIP_EM_NONE;
-        /* st->bitflags = za->cdir->entry[index].bitflags; */
-    }
-
-    st->index = index;
-    st->name = name;
-    
-    return 0;
-}
-
-
-ZIP_EXTERN int
-zip_stat(struct zip *za, const char *fname, int flags, struct zip_stat *st)
-{
-    int idx;
-
-    if ((idx=zip_name_locate(za, fname, flags)) < 0)
-        return -1;
-
-    return zip_stat_index(za, idx, flags, st);
-}
-
-
-struct read_zip {
-    struct zip_file *zf;
-    struct zip_stat st;
-    myoff_t off, len;
-};
-
-static ssize_t read_zip(void *st, void *data, size_t len,
-                        enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_zip(struct zip *za, struct zip *srcza, int srcidx, int flags,
-               myoff_t start, myoff_t len)
-{
-    struct zip_error error;
-    struct zip_source *zs;
-    struct read_zip *p;
-
-    /* XXX: ZIP_FL_RECOMPRESS */
-
-    if (za == NULL)
-        return NULL;
-
-    if (srcza == NULL || start < 0 || len < -1 || srcidx < 0 || srcidx >= srcza->nentry) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((flags & ZIP_FL_UNCHANGED) == 0
-        && ZIP_ENTRY_DATA_CHANGED(srcza->entry+srcidx)) {
-        _zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
-        return NULL;
-    }
-
-    if (len == 0)
-        len = -1;
-
-    if (start == 0 && len == -1 && (flags & ZIP_FL_RECOMPRESS) == 0)
-        flags |= ZIP_FL_COMPRESSED;
-    else
-        flags &= ~ZIP_FL_COMPRESSED;
-
-    if ((p=(struct read_zip *)malloc(sizeof(*p))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-        
-    _zip_error_copy(&error, &srcza->error);
-        
-    if (zip_stat_index(srcza, srcidx, flags, &p->st) < 0
-        || (p->zf=zip_fopen_index(srcza, srcidx, flags)) == NULL) {
-        free(p);
-        _zip_error_copy(&za->error, &srcza->error);
-        _zip_error_copy(&srcza->error, &error);
-        
-        return NULL;
-    }
-    p->off = start;
-    p->len = len;
-
-    if ((flags & ZIP_FL_COMPRESSED) == 0) {
-        p->st.size = p->st.comp_size = len;
-        p->st.comp_method = ZIP_CM_STORE;
-        p->st.crc = 0;
-    }
-    
-    if ((zs=zip_source_function(za, read_zip, p)) == NULL) {
-        free(p);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_zip(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_zip *z;
-    char b[8192], *buf;
-    int i, n;
-
-    z = (struct read_zip *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        for (n=0; n<z->off; n+= i) {
-            i = (z->off-n > sizeof(b) ? sizeof(b) : z->off-n);
-            if ((i=zip_fread(z->zf, b, i)) < 0) {
-                zip_fclose(z->zf);
-                z->zf = NULL;
-                return -1;
-            }
-        }
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->len != -1)
-            n = len > z->len ? z->len : len;
-        else
-            n = len;
-        
-
-        if ((i=zip_fread(z->zf, buf, n)) < 0)
-            return -1;
-
-        if (z->len != -1)
-            z->len -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        if (len < sizeof(z->st))
-            return -1;
-        len = sizeof(z->st);
-
-        memcpy(data, &z->st, len);
-        return len;
-
-    case ZIP_SOURCE_ERROR:
-        {
-            int *e;
-
-            if (len < sizeof(int)*2)
-                return -1;
-
-            e = (int *)data;
-            zip_file_error_get(z->zf, e, e+1);
-        }
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        zip_fclose(z->zf);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_function(struct zip *za, zip_source_callback zcb, void *ud)
-{
-    struct zip_source *zs;
-
-    if (za == NULL)
-        return NULL;
-
-    if ((zs=(struct zip_source *)malloc(sizeof(*zs))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    zs->f = zcb;
-    zs->ud = ud;
-    
-    return zs;
-}
-
-
-ZIP_EXTERN void
-zip_source_free(struct zip_source *source)
-{
-    if (source == NULL)
-        return;
-
-    (void)source->f(source->ud, NULL, 0, ZIP_SOURCE_FREE);
-
-    free(source);
-}
-
-
-struct read_file {
-    char *fname;        /* name of file to copy from */
-    FILE *f;                /* file to copy from */
-    myoff_t off;                /* start offset of */
-    myoff_t len;                /* lengt of data to copy */
-    myoff_t remain;        /* bytes remaining to be copied */
-    int e[2];                /* error codes */
-};
-
-static ssize_t read_file(void *state, void *data, size_t len,
-                     enum zip_source_cmd cmd);
-
-
-
-ZIP_EXTERN struct zip_source *
-zip_source_filep(struct zip *za, FILE *file, myoff_t start, myoff_t len)
-{
-    if (za == NULL)
-        return NULL;
-
-    if (file == NULL || start < 0 || len < -1) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    return _zip_source_file_or_p(za, NULL, file, start, len);
-}
-
-
-
-struct zip_source *
-_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file,
-                      myoff_t start, myoff_t len)
-{
-    struct read_file *f;
-    struct zip_source *zs;
-
-    if (file == NULL && fname == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
-    if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) {
-        _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-        return NULL;
-    }
-
-    f->fname = NULL;
-    if (fname) {
-        if ((f->fname=strdup(fname)) == NULL) {
-            _zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-            free(f);
-            return NULL;
-        }
-    }
-    f->f = file;
-    f->off = start;
-    f->len = (len ? len : -1);
-    
-    if ((zs=zip_source_function(za, read_file, f)) == NULL) {
-        free(f);
-        return NULL;
-    }
-
-    return zs;
-}
-
-
-
-static ssize_t
-read_file(void *state, void *data, size_t len, enum zip_source_cmd cmd)
-{
-    struct read_file *z;
-    char *buf;
-    int i, n;
-
-    z = (struct read_file *)state;
-    buf = (char *)data;
-
-    switch (cmd) {
-    case ZIP_SOURCE_OPEN:
-        if (z->fname) {
-            if ((z->f=fopen(z->fname, "rb")) == NULL) {
-                z->e[0] = ZIP_ER_OPEN;
-                z->e[1] = errno;
-                return -1;
-            }
-        }
-
-        if (fseeko(z->f, z->off, SEEK_SET) < 0) {
-            z->e[0] = ZIP_ER_SEEK;
-            z->e[1] = errno;
-            return -1;
-        }
-        z->remain = z->len;
-        return 0;
-        
-    case ZIP_SOURCE_READ:
-        if (z->remain != -1)
-            n = len > z->remain ? z->remain : len;
-        else
-            n = len;
-        
-        if ((i=fread(buf, 1, n, z->f)) < 0) {
-            z->e[0] = ZIP_ER_READ;
-            z->e[1] = errno;
-            return -1;
-        }
-
-        if (z->remain != -1)
-            z->remain -= i;
-
-        return i;
-        
-    case ZIP_SOURCE_CLOSE:
-        if (z->fname) {
-            fclose(z->f);
-            z->f = NULL;
-        }
-        return 0;
-
-    case ZIP_SOURCE_STAT:
-        {
-            struct zip_stat *st;
-            struct stat fst;
-            int err;
-            
-            if (len < sizeof(*st))
-                return -1;
-
-            if (z->f)
-                err = fstat(fileno(z->f), &fst);
-            else
-                err = stat(z->fname, &fst);
-
-            if (err != 0) {
-                z->e[0] = ZIP_ER_READ; /* best match */
-                z->e[1] = errno;
-                return -1;
-            }
-
-            st = (struct zip_stat *)data;
-
-            zip_stat_init(st);
-            st->mtime = fst.st_mtime;
-            if (z->len != -1)
-                st->size = z->len;
-            else if ((fst.st_mode&S_IFMT) == S_IFREG)
-                st->size = fst.st_size;
-
-            return sizeof(*st);
-        }
-
-    case ZIP_SOURCE_ERROR:
-        if (len < sizeof(int)*2)
-            return -1;
-
-        memcpy(data, z->e, sizeof(int)*2);
-        return sizeof(int)*2;
-
-    case ZIP_SOURCE_FREE:
-        free(z->fname);
-        if (z->f)
-            fclose(z->f);
-        free(z);
-        return 0;
-
-    default:
-        ;
-    }
-
-    return -1;
-}
-
-
-ZIP_EXTERN int
-zip_name_locate(struct zip *za, const char *fname, int flags)
-{
-    return _zip_name_locate(za, fname, flags, &za->error);
-}
-
-
-
-int
-_zip_name_locate(struct zip *za, const char *fname, int flags,
-                 struct zip_error *error)
-{
-    int (*cmp)(const char *, const char *);
-    const char *fn, *p;
-    int i, n;
-
-    if (fname == NULL) {
-        _zip_error_set(error, ZIP_ER_INVAL, 0);
-        return -1;
-    }
-    
-    cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
-
-    n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
-    for (i=0; i<n; i++) {
-        if (flags & ZIP_FL_UNCHANGED)
-            fn = za->cdir->entry[i].filename;
-        else
-            fn = _zip_get_name(za, i, flags, error);
-
-        /* newly added (partially filled) entry */
-        if (fn == NULL)
-            continue;
-        
-        if (flags & ZIP_FL_NODIR) {
-            p = strrchr(fn, '/');
-            if (p)
-                fn = p+1;
-        }
-
-        if (cmp(fname, fn) == 0)
-            return i;
-    }
-
-    _zip_error_set(error, ZIP_ER_NOENT, 0);
-    return -1;
-}
-
diff --git a/lib/wrappers/zip/zlib.nim b/lib/wrappers/zip/zlib.nim
deleted file mode 100755
index 9b49b9663..000000000
--- a/lib/wrappers/zip/zlib.nim
+++ /dev/null
@@ -1,181 +0,0 @@
-# Converted from Pascal
-
-## Interface to the zlib http://www.zlib.net/ compression library.
-
-when defined(windows):
-  const libz = "zlib1.dll"
-elif defined(macosx):
-  const libz = "libz.dylib"
-else:
-  const libz = "libz.so"
-
-type
-  Uint* = int32
-  Ulong* = int
-  Ulongf* = int
-  Pulongf* = ptr Ulongf
-  z_off_t* = int32
-  pbyte* = cstring
-  pbytef* = cstring
-  TAllocfunc* = proc (p: pointer, items: uInt, size: uInt): pointer{.cdecl.}
-  TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
-  TInternalState*{.final, pure.} = object 
-  PInternalState* = ptr TInternalstate
-  TZStream*{.final, pure.} = object 
-    next_in*: pbytef
-    avail_in*: uInt
-    total_in*: uLong
-    next_out*: pbytef
-    avail_out*: uInt
-    total_out*: uLong
-    msg*: pbytef
-    state*: PInternalState
-    zalloc*: TAllocFunc
-    zfree*: TFreeFunc
-    opaque*: pointer
-    data_type*: int32
-    adler*: uLong
-    reserved*: uLong
-
-  TZStreamRec* = TZStream
-  PZstream* = ptr TZStream
-  gzFile* = pointer
-
-const 
-  Z_NO_FLUSH* = 0
-  Z_PARTIAL_FLUSH* = 1
-  Z_SYNC_FLUSH* = 2
-  Z_FULL_FLUSH* = 3
-  Z_FINISH* = 4
-  Z_OK* = 0
-  Z_STREAM_END* = 1
-  Z_NEED_DICT* = 2
-  Z_ERRNO* = -1
-  Z_STREAM_ERROR* = -2
-  Z_DATA_ERROR* = -3
-  Z_MEM_ERROR* = -4
-  Z_BUF_ERROR* = -5
-  Z_VERSION_ERROR* = -6
-  Z_NO_COMPRESSION* = 0
-  Z_BEST_SPEED* = 1
-  Z_BEST_COMPRESSION* = 9
-  Z_DEFAULT_COMPRESSION* = -1
-  Z_FILTERED* = 1
-  Z_HUFFMAN_ONLY* = 2
-  Z_DEFAULT_STRATEGY* = 0
-  Z_BINARY* = 0
-  Z_ASCII* = 1
-  Z_UNKNOWN* = 2
-  Z_DEFLATED* = 8
-  Z_NULL* = 0
-
-proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".}
-proc deflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflate".}
-proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateEnd".}
-proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflate".}
-proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateEnd".}
-proc deflateSetDictionary*(strm: var TZStream, dictionary: pbytef, 
-                           dictLength: uInt): int32{.cdecl, dynlib: libz, 
-    importc: "deflateSetDictionary".}
-proc deflateCopy*(dest, source: var TZstream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateCopy".}
-proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "deflateReset".}
-proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{.
-    cdecl, dynlib: libz, importc: "deflateParams".}
-proc inflateSetDictionary*(strm: var TZStream, dictionary: pbytef, 
-                           dictLength: uInt): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSetDictionary".}
-proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSync".}
-proc inflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateReset".}
-proc compress*(dest: pbytef, destLen: puLongf, source: pbytef, sourceLen: uLong): cint{.
-    cdecl, dynlib: libz, importc: "compress".}
-proc compress2*(dest: pbytef, destLen: puLongf, source: pbytef, 
-                sourceLen: uLong, level: cint): cint{.cdecl, dynlib: libz, 
-    importc: "compress2".}
-proc uncompress*(dest: pbytef, destLen: puLongf, source: pbytef, 
-                 sourceLen: uLong): cint{.cdecl, dynlib: libz, 
-    importc: "uncompress".}
-proc gzopen*(path: cstring, mode: cstring): gzFile{.cdecl, dynlib: libz, 
-    importc: "gzopen".}
-proc gzdopen*(fd: int32, mode: cstring): gzFile{.cdecl, dynlib: libz, 
-    importc: "gzdopen".}
-proc gzsetparams*(thefile: gzFile, level: int32, strategy: int32): int32{.cdecl, 
-    dynlib: libz, importc: "gzsetparams".}
-proc gzread*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzread".}
-proc gzwrite*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, 
-    dynlib: libz, importc: "gzwrite".}
-proc gzprintf*(thefile: gzFile, format: pbytef): int32{.varargs, cdecl, 
-    dynlib: libz, importc: "gzprintf".}
-proc gzputs*(thefile: gzFile, s: pbytef): int32{.cdecl, dynlib: libz, 
-    importc: "gzputs".}
-proc gzgets*(thefile: gzFile, buf: pbytef, length: int32): pbytef{.cdecl, 
-    dynlib: libz, importc: "gzgets".}
-proc gzputc*(thefile: gzFile, c: char): char{.cdecl, dynlib: libz, 
-    importc: "gzputc".}
-proc gzgetc*(thefile: gzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".}
-proc gzflush*(thefile: gzFile, flush: int32): int32{.cdecl, dynlib: libz, 
-    importc: "gzflush".}
-proc gzseek*(thefile: gzFile, offset: z_off_t, whence: int32): z_off_t{.cdecl, 
-    dynlib: libz, importc: "gzseek".}
-proc gzrewind*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
-proc gztell*(thefile: gzFile): z_off_t{.cdecl, dynlib: libz, importc: "gztell".}
-proc gzeof*(thefile: gzFile): int {.cdecl, dynlib: libz, importc: "gzeof".}
-proc gzclose*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".}
-proc gzerror*(thefile: gzFile, errnum: var int32): pbytef{.cdecl, dynlib: libz, 
-    importc: "gzerror".}
-proc adler32*(adler: uLong, buf: pbytef, length: uInt): uLong{.cdecl, 
-    dynlib: libz, importc: "adler32".}
-proc crc32*(crc: uLong, buf: pbytef, length: uInt): uLong{.cdecl, dynlib: libz, 
-    importc: "crc32".}
-proc deflateInitu*(strm: var TZStream, level: int32, version: cstring, 
-                   stream_size: int32): int32{.cdecl, dynlib: libz, 
-    importc: "deflateInit_".}
-proc inflateInitu*(strm: var TZStream, version: cstring,
-                   stream_size: int32): int32 {.
-    cdecl, dynlib: libz, importc: "inflateInit_".}
-proc deflateInit*(strm: var TZStream, level: int32): int32
-proc inflateInit*(strm: var TZStream): int32
-proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32, 
-                    windowBits: int32, memLevel: int32, strategy: int32, 
-                    version: cstring, stream_size: int32): int32 {.cdecl, 
-                    dynlib: libz, importc: "deflateInit2_".}
-proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring, 
-                    stream_size: int32): int32{.cdecl, dynlib: libz, 
-    importc: "inflateInit2_".}
-proc deflateInit2*(strm: var TZStream, 
-                   level, `method`, windowBits, memLevel,
-                   strategy: int32): int32
-proc inflateInit2*(strm: var TZStream, windowBits: int32): int32
-proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
-proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz, 
-    importc: "inflateSyncPoint".}
-proc get_crc_table*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
-
-proc deflateInit(strm: var TZStream, level: int32): int32 = 
-  result = deflateInitu(strm, level, ZLIB_VERSION(), sizeof(TZStream))
-
-proc inflateInit(strm: var TZStream): int32 = 
-  result = inflateInitu(strm, ZLIB_VERSION(), sizeof(TZStream))
-
-proc deflateInit2(strm: var TZStream, 
-                  level, `method`, windowBits, memLevel,
-                  strategy: int32): int32 = 
-  result = deflateInit2u(strm, level, `method`, windowBits, memLevel, 
-                         strategy, ZLIB_VERSION(), sizeof(TZStream))
-
-proc inflateInit2(strm: var TZStream, windowBits: int32): int32 = 
-  result = inflateInit2u(strm, windowBits, ZLIB_VERSION(), sizeof(TZStream))
-
-proc zlibAllocMem*(AppData: Pointer, Items, Size: int): Pointer {.cdecl.} = 
-  result = Alloc(Items * Size)
-
-proc zlibFreeMem*(AppData, `Block`: Pointer) {.cdecl.} = 
-  dealloc(`Block`)
diff --git a/lib/wrappers/zip/zzip.nim b/lib/wrappers/zip/zzip.nim
deleted file mode 100755
index a656322ee..000000000
--- a/lib/wrappers/zip/zzip.nim
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-#
-#            Nimrod's Runtime Library
-#        (c) Copyright 2008 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## This module is an interface to the zzip library. 
-
-#   Author: 
-#   Guido Draheim <guidod@gmx.de>
-#   Tomi Ollila <Tomi.Ollila@iki.fi>
-#   Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
-#          All rights reserved, 
-#             usage allowed under the restrictions of the
-#         Lesser GNU General Public License 
-#             or alternatively the restrictions 
-#             of the Mozilla Public License 1.1
-
-when defined(windows):
-  const
-    dllname = "zzip.dll"
-else:
-  const 
-    dllname = "libzzip.so"
-
-type 
-  TZZipError* = int32
-const
-  ZZIP_ERROR* = -4096'i32
-  ZZIP_NO_ERROR* = 0'i32            # no error, may be used if user sets it.
-  ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32  # out of memory  
-  ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32  # failed to open zipfile, see errno for details 
-  ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32  # failed to fstat zipfile, see errno for details
-  ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32  # failed to lseek zipfile, see errno for details
-  ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32  # failed to read zipfile, see errno for details  
-  ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32
-  ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32
-  ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32
-  ZZIP_ENOENT* = ZZIP_ERROR - 28'i32
-  ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32
-  ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32
-  ZZIP_UNDEF* = ZZIP_ERROR - 32'i32
-  ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32
-
-  ZZIP_CASELESS* = 1'i32 shl 12'i32
-  ZZIP_NOPATHS* = 1'i32 shl 13'i32
-  ZZIP_PREFERZIP* = 1'i32 shl 14'i32
-  ZZIP_ONLYZIP* = 1'i32 shl 16'i32
-  ZZIP_FACTORY* = 1'i32 shl 17'i32
-  ZZIP_ALLOWREAL* = 1'i32 shl 18'i32
-  ZZIP_THREADED* = 1'i32 shl 19'i32
-  
-type
-  TZZipDir* {.final, pure.} = object
-  TZZipFile* {.final, pure.} = object
-  TZZipPluginIO* {.final, pure.} = object
-
-  TZZipDirent* {.final, pure.} = object  
-    d_compr*: int32  ## compression method
-    d_csize*: int32  ## compressed size  
-    st_size*: int32  ## file size / decompressed size
-    d_name*: cstring ## file name / strdupped name
-
-  TZZipStat* = TZZipDirent    
-
-proc zzip_strerror*(errcode: int32): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror".}
-proc zzip_strerror_of*(dir: ptr TZZipDir): cstring  {.cdecl, dynlib: dllname, 
-    importc: "zzip_strerror_of".}
-proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_errno".}
-
-proc zzip_geterror*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_error".}
-proc zzip_seterror*(dir: ptr TZZipDir, errcode: int32) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seterror".}
-proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname, 
-    importc: "zzip_compr_str".}
-proc zzip_dirhandle*(fp: ptr TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirhandle".}
-proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dirfd".}
-proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_real".}
-proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_real".}
-proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname, 
-    importc: "zzip_realdir".}
-proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_realfd".}
-
-proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_alloc".}
-proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_free".}
-
-proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_fdopen".}
-proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open".}
-proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_close".}
-proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_dir_read".}
-
-proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname, 
-    importc: "zzip_opendir".}
-proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-    importc: "zzip_closedir".}
-proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname, 
-    importc: "zzip_readdir".}
-proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, 
-                                      importc: "zzip_rewinddir".}
-proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_telldir".}
-proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname, 
-    importc: "zzip_seekdir".}
-
-proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_file_open".}
-proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_file_close".}
-proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_file_read".}
-proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open".}
-proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_close".}
-proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
-    cdecl, dynlib: dllname, importc: "zzip_read".}
-
-proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_freopen".}
-proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_fopen".}
-proc zzip_fread*(p: pointer, size: int, nmemb: int, 
-                 file: ptr TZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_fread".}
-proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, 
-    importc: "zzip_fclose".}
-
-proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_rewind".}
-proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {.
-    cdecl, dynlib: dllname, importc: "zzip_seek".}
-proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname, 
-    importc: "zzip_tell".}
-
-proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat, 
-                    flags: int32): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_dir_stat".}
-proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, 
-    dynlib: dllname, importc: "zzip_file_stat".}
-proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname, 
-    importc: "zzip_fstat".}
-
-proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring, 
-                          o_flags: int32, o_modes: int32, ext: cstringArray, 
-                          io: ptr TZZipPluginIO): ptr TZZipFile {.cdecl, 
-    dynlib: dllname, importc: "zzip_open_shared_io".}
-proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32, 
-                       ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipFile {.
-    cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
-proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, 
-                          ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
-proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, 
-                           ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
-    cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}